@opengeni/runtime 4.6.1 → 4.6.2-canary.39853438886001

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.
@@ -1 +1 @@
1
- {"version":1,"files":{"ogtool":"#!/usr/bin/env node\nvar{defineProperty:st,getOwnPropertyNames:Bi,getOwnPropertyDescriptor:Wi}=Object,Ki=Object.prototype.hasOwnProperty;function Hi(e){return this[e]}var Xi=(e)=>{var t=(so??=new WeakMap).get(e),o;if(t)return t;if(t=st({},\"__esModule\",{value:!0}),e&&typeof e===\"object\"||typeof e===\"function\"){for(var r of Bi(e))if(!Ki.call(t,r))st(t,r,{get:Hi.bind(e,r),enumerable:!(o=Wi(e,r))||o.enumerable})}return so.set(e,t),t},so;var Yi=(e)=>e;function Qi(e,t){this[e]=Yi.bind(null,t)}var ea=(e,t)=>{for(var o in t)st(e,o,{get:t[o],enumerable:!0,configurable:!0,set:Qi.bind(t,o)})};var Ru={};ea(Ru,{callOutput:()=>to,imageSaveFailureOutput:()=>Vi,listProjection:()=>eo,materializeCallImages:()=>oo,preflightImagePath:()=>Ui,resolveTool:()=>Qt,showOutput:()=>Fi});module.exports=Xi(Ru);var Li=require(\"node:crypto\"),P=require(\"node:fs\"),Se=require(\"node:path\");var Pi=require(\"node:crypto\");function x(e){return e()}var io;function l(e,t,o){function r(a,c){if(!a._zod)Object.defineProperty(a,\"_zod\",{value:{def:c,constr:s,traits:new Set},enumerable:!1});if(a._zod.traits.has(e))return;a._zod.traits.add(e),t(a,c);let u=s.prototype,p=Object.keys(u);for(let d=0;d<p.length;d++){let h=p[d];if(!(h in a))a[h]=u[h].bind(a)}}let n=o?.Parent??Object;class i extends n{}Object.defineProperty(i,\"name\",{value:e});function s(a){var c;let u=o?.Parent?new i:this;r(u,a),(c=u._zod).deferred??(c.deferred=[]);for(let p of u._zod.deferred)p();return u}return Object.defineProperty(s,\"init\",{value:r}),Object.defineProperty(s,Symbol.hasInstance,{value:(a)=>{if(o?.Parent&&a instanceof o.Parent)return!0;return a?._zod?.traits?.has(e)}}),Object.defineProperty(s,\"name\",{value:e}),s}var Du=Symbol(\"zod_brand\");class F extends Error{constructor(){super(\"Encountered Promise during synchronous parse. Use .parseAsync() instead.\")}}class de extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`);this.name=\"ZodEncodeError\"}}(io=globalThis).__zod_globalConfig??(io.__zod_globalConfig={});var ie=globalThis.__zod_globalConfig;function R(e){if(e)Object.assign(ie,e);return ie}function Oe(e){let t=Object.values(e).filter((r)=>typeof r===\"number\");return Object.entries(e).filter(([r,n])=>t.indexOf(+r)===-1).map(([r,n])=>n)}function me(e,t){if(typeof t===\"bigint\")return t.toString();return t}function fe(e){return{get value(){{let o=e();return Object.defineProperty(this,\"value\",{value:o}),o}throw Error(\"cached value already set\")}}}function Pe(e){return e===null||e===void 0}function Ie(e){let t=e.startsWith(\"^\")?1:0,o=e.endsWith(\"$\")?e.length-1:e.length;return e.slice(t,o)}function co(e,t){let o=e/t,r=Math.round(o),n=Number.EPSILON*Math.max(Math.abs(o),1);if(Math.abs(o-r)<n)return 0;return o-r}var ao=Symbol(\"evaluating\");function _(e,t,o){let r=void 0;Object.defineProperty(e,t,{get(){if(r===ao)return;if(r===void 0)r=ao,r=o();return r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function Q(e,t,o){Object.defineProperty(e,t,{value:o,writable:!0,enumerable:!0,configurable:!0})}function J(...e){let t={};for(let o of e){let r=Object.getOwnPropertyDescriptors(o);Object.assign(t,r)}return Object.defineProperties({},t)}function at(e){return JSON.stringify(e)}function uo(e){return e.toLowerCase().trim().replace(/[^\\w\\s-]/g,\"\").replace(/[\\s_-]+/g,\"-\").replace(/^-+|-+$/g,\"\")}var ct=\"captureStackTrace\"in Error?Error.captureStackTrace:(...e)=>{};function ae(e){return typeof e===\"object\"&&e!==null&&!Array.isArray(e)}var lo=fe(()=>{if(ie.jitless)return!1;if(typeof navigator<\"u\"&&navigator?.userAgent?.includes(\"Cloudflare\"))return!1;try{return new Function(\"\"),!0}catch(e){return!1}});function ee(e){if(ae(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;if(typeof t!==\"function\")return!0;let o=t.prototype;if(ae(o)===!1)return!1;if(Object.prototype.hasOwnProperty.call(o,\"isPrototypeOf\")===!1)return!1;return!0}function ut(e){if(ee(e))return{...e};if(Array.isArray(e))return[...e];if(e instanceof Map)return new Map(e);if(e instanceof Set)return new Set(e);return e}var po=new Set([\"string\",\"number\",\"symbol\"]);function q(e){return e.replace(/[.*+?^${}()|[\\]\\\\]/g,\"\\\\$&\")}function D(e,t,o){let r=new e._zod.constr(t??e._zod.def);if(!t||o?.parent)r._zod.parent=e;return r}function f(e){let t=e;if(!t)return{};if(typeof t===\"string\")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error(\"Cannot specify both `message` and `error` params\");t.error=t.message}if(delete t.message,typeof t.error===\"string\")return{...t,error:()=>t.error};return t}function mo(e){return Object.keys(e).filter((t)=>e[t]._zod.optin===\"optional\"&&e[t]._zod.optout===\"optional\")}var fo={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-340282346638528860000000000000000000000,340282346638528860000000000000000000000],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function ta(e,t){let o=e._zod.def,r=o.checks;if(r&&r.length>0)throw Error(\".pick() cannot be used on object schemas containing refinements\");let i=J(e._zod.def,{get shape(){let s={};for(let a in t){if(!(a in o.shape))throw Error(`Unrecognized key: \"${a}\"`);if(!t[a])continue;s[a]=o.shape[a]}return Q(this,\"shape\",s),s},checks:[]});return D(e,i)}function oa(e,t){let o=e._zod.def,r=o.checks;if(r&&r.length>0)throw Error(\".omit() cannot be used on object schemas containing refinements\");let i=J(e._zod.def,{get shape(){let s={...e._zod.def.shape};for(let a in t){if(!(a in o.shape))throw Error(`Unrecognized key: \"${a}\"`);if(!t[a])continue;delete s[a]}return Q(this,\"shape\",s),s},checks:[]});return D(e,i)}function ra(e,t){if(!ee(t))throw Error(\"Invalid input to extend: expected a plain object\");let o=e._zod.def.checks;if(o&&o.length>0){let i=e._zod.def.shape;for(let s in t)if(Object.getOwnPropertyDescriptor(i,s)!==void 0)throw Error(\"Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.\")}let n=J(e._zod.def,{get shape(){let i={...e._zod.def.shape,...t};return Q(this,\"shape\",i),i}});return D(e,n)}function na(e,t){if(!ee(t))throw Error(\"Invalid input to safeExtend: expected a plain object\");let o=J(e._zod.def,{get shape(){let r={...e._zod.def.shape,...t};return Q(this,\"shape\",r),r}});return D(e,o)}function sa(e,t){if(e._zod.def.checks?.length)throw Error(\".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.\");let o=J(e._zod.def,{get shape(){let r={...e._zod.def.shape,...t._zod.def.shape};return Q(this,\"shape\",r),r},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return D(e,o)}function ia(e,t,o){let n=t._zod.def.checks;if(n&&n.length>0)throw Error(\".partial() cannot be used on object schemas containing refinements\");let s=J(t._zod.def,{get shape(){let a=t._zod.def.shape,c={...a};if(o)for(let u in o){if(!(u in a))throw Error(`Unrecognized key: \"${u}\"`);if(!o[u])continue;c[u]=e?new e({type:\"optional\",innerType:a[u]}):a[u]}else for(let u in a)c[u]=e?new e({type:\"optional\",innerType:a[u]}):a[u];return Q(this,\"shape\",c),c},checks:[]});return D(t,s)}function aa(e,t,o){let r=J(t._zod.def,{get shape(){let n=t._zod.def.shape,i={...n};if(o)for(let s in o){if(!(s in i))throw Error(`Unrecognized key: \"${s}\"`);if(!o[s])continue;i[s]=new e({type:\"nonoptional\",innerType:n[s]})}else for(let s in n)i[s]=new e({type:\"nonoptional\",innerType:n[s]});return Q(this,\"shape\",i),i}});return D(t,r)}function te(e,t=0){if(e.aborted===!0)return!0;for(let o=t;o<e.issues.length;o++)if(e.issues[o]?.continue!==!0)return!0;return!1}function ho(e,t=0){if(e.aborted===!0)return!0;for(let o=t;o<e.issues.length;o++)if(e.issues[o]?.continue===!1)return!0;return!1}function B(e,t){return t.map((o)=>{var r;return(r=o).path??(r.path=[]),o.path.unshift(e),o})}function Ce(e){return typeof e===\"string\"?e:e?.message}function N(e,t,o){let r=e.message?e.message:Ce(e.inst?._zod.def?.error?.(e))??Ce(t?.error?.(e))??Ce(o.customError?.(e))??Ce(o.localeError?.(e))??\"Invalid input\",{inst:n,continue:i,input:s,...a}=e;if(a.path??(a.path=[]),a.message=r,t?.reportInput)a.input=s;return a}function Ze(e){if(Array.isArray(e))return\"array\";if(typeof e===\"string\")return\"string\";return\"unknown\"}function oe(...e){let[t,o,r]=e;if(typeof t===\"string\")return{message:t,code:\"custom\",input:o,inst:r};return{...t}}var go=(e,t)=>{e.name=\"$ZodError\",Object.defineProperty(e,\"_zod\",{value:e._zod,enumerable:!1}),Object.defineProperty(e,\"issues\",{value:t,enumerable:!1}),e.message=JSON.stringify(t,me,2),Object.defineProperty(e,\"toString\",{value:()=>e.message,enumerable:!1})},Re=l(\"$ZodError\",go),lt=l(\"$ZodError\",go,{Parent:Error});function yo(e,t=(o)=>o.message){let o={},r=[];for(let n of e.issues)if(n.path.length>0)o[n.path[0]]=o[n.path[0]]||[],o[n.path[0]].push(t(n));else r.push(t(n));return{formErrors:r,fieldErrors:o}}function _o(e,t=(o)=>o.message){let o={_errors:[]},r=(n,i=[])=>{for(let s of n.issues)if(s.code===\"invalid_union\"&&s.errors.length)s.errors.map((a)=>r({issues:a},[...i,...s.path]));else if(s.code===\"invalid_key\")r({issues:s.issues},[...i,...s.path]);else if(s.code===\"invalid_element\")r({issues:s.issues},[...i,...s.path]);else{let a=[...i,...s.path];if(a.length===0)o._errors.push(t(s));else{let c=o,u=0;while(u<a.length){let p=a[u];if(u!==a.length-1)c[p]=c[p]||{_errors:[]};else c[p]=c[p]||{_errors:[]},c[p]._errors.push(t(s));c=c[p],u++}}}};return r(e),o}var Ne=(e)=>(t,o,r,n)=>{let i=r?{...r,async:!1}:{async:!1},s=t._zod.run({value:o,issues:[]},i);if(s instanceof Promise)throw new F;if(s.issues.length){let a=new(n?.Err??e)(s.issues.map((c)=>N(c,i,R())));throw ct(a,n?.callee),a}return s.value};var je=(e)=>async(t,o,r,n)=>{let i=r?{...r,async:!0}:{async:!0},s=t._zod.run({value:o,issues:[]},i);if(s instanceof Promise)s=await s;if(s.issues.length){let a=new(n?.Err??e)(s.issues.map((c)=>N(c,i,R())));throw ct(a,n?.callee),a}return s.value};var he=(e)=>(t,o,r)=>{let n=r?{...r,async:!1}:{async:!1},i=t._zod.run({value:o,issues:[]},n);if(i instanceof Promise)throw new F;return i.issues.length?{success:!1,error:new(e??Re)(i.issues.map((s)=>N(s,n,R())))}:{success:!0,data:i.value}},xo=he(lt),ge=(e)=>async(t,o,r)=>{let n=r?{...r,async:!0}:{async:!0},i=t._zod.run({value:o,issues:[]},n);if(i instanceof Promise)i=await i;return i.issues.length?{success:!1,error:new e(i.issues.map((s)=>N(s,n,R())))}:{success:!0,data:i.value}},wo=ge(lt),bo=(e)=>(t,o,r)=>{let n=r?{...r,direction:\"backward\"}:{direction:\"backward\"};return Ne(e)(t,o,n)};var vo=(e)=>(t,o,r)=>Ne(e)(t,o,r);var zo=(e)=>async(t,o,r)=>{let n=r?{...r,direction:\"backward\"}:{direction:\"backward\"};return je(e)(t,o,n)};var $o=(e)=>async(t,o,r)=>je(e)(t,o,r);var To=(e)=>(t,o,r)=>{let n=r?{...r,direction:\"backward\"}:{direction:\"backward\"};return he(e)(t,o,n)};var ko=(e)=>(t,o,r)=>he(e)(t,o,r);var Ao=(e)=>async(t,o,r)=>{let n=r?{...r,direction:\"backward\"}:{direction:\"backward\"};return ge(e)(t,o,n)};var Eo=(e)=>async(t,o,r)=>ge(e)(t,o,r);var So=/^[cC][0-9a-z]{6,}$/,Co=/^[0-9a-z]+$/,Oo=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Po=/^[0-9a-vA-V]{20}$/,Io=/^[A-Za-z0-9]{27}$/,Zo=/^[a-zA-Z0-9_-]{21}$/,Ro=/^P(?:(\\d+W)|(?!.*W)(?=\\d|T\\d)(\\d+Y)?(\\d+M)?(\\d+D)?(T(?=\\d)(\\d+H)?(\\d+M)?(\\d+([.,]\\d+)?S)?)?)$/;var No=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,pt=(e)=>{if(!e)return/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`)};var jo=/^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$/;var ua=\"^(\\\\p{Extended_Pictographic}|\\\\p{Emoji_Component})+$\";function Do(){return new RegExp(ua,\"u\")}var Mo=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Lo=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;var Go=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\\/([0-9]|[1-2][0-9]|3[0-2])$/,Fo=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Uo=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,dt=/^[A-Za-z0-9_-]*$/;var Vo=/^https?$/,Jo=/^\\+[1-9]\\d{6,14}$/,qo=\"(?:(?:\\\\d\\\\d[2468][048]|\\\\d\\\\d[13579][26]|\\\\d\\\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\\\d|30)|(?:02)-(?:0[1-9]|1\\\\d|2[0-8])))\",Bo=new RegExp(`^${qo}$`);function Wo(e){return typeof e.precision===\"number\"?e.precision===-1?\"(?:[01]\\\\d|2[0-3]):[0-5]\\\\d\":e.precision===0?\"(?:[01]\\\\d|2[0-3]):[0-5]\\\\d:[0-5]\\\\d\":`(?:[01]\\\\d|2[0-3]):[0-5]\\\\d:[0-5]\\\\d\\\\.\\\\d{${e.precision}}`:\"(?:[01]\\\\d|2[0-3]):[0-5]\\\\d(?::[0-5]\\\\d(?:\\\\.\\\\d+)?)?\"}function Ko(e){return new RegExp(`^${Wo(e)}$`)}function Ho(e){let t=Wo({precision:e.precision}),o=[\"Z\"];if(e.local)o.push(\"\");if(e.offset)o.push(\"([+-](?:[01]\\\\d|2[0-3]):[0-5]\\\\d)\");let r=`${t}(?:${o.join(\"|\")})`;return new RegExp(`^${qo}T(?:${r})$`)}var Xo=(e)=>{let t=e?`[\\\\s\\\\S]{${e?.minimum??0},${e?.maximum??\"\"}}`:\"[\\\\s\\\\S]*\";return new RegExp(`^${t}$`)};var Yo=/^-?\\d+$/,mt=/^-?\\d+(?:\\.\\d+)?$/,Qo=/^(?:true|false)$/i,er=/^null$/i;var tr=/^[^A-Z]*$/,or=/^[^a-z]*$/;var S=l(\"$ZodCheck\",(e,t)=>{var o;e._zod??(e._zod={}),e._zod.def=t,(o=e._zod).onattach??(o.onattach=[])}),rr={number:\"number\",bigint:\"bigint\",object:\"date\"},ft=l(\"$ZodCheckLessThan\",(e,t)=>{S.init(e,t);let o=rr[typeof t.value];e._zod.onattach.push((r)=>{let n=r._zod.bag,i=(t.inclusive?n.maximum:n.exclusiveMaximum)??Number.POSITIVE_INFINITY;if(t.value<i)if(t.inclusive)n.maximum=t.value;else n.exclusiveMaximum=t.value}),e._zod.check=(r)=>{if(t.inclusive?r.value<=t.value:r.value<t.value)return;r.issues.push({origin:o,code:\"too_big\",maximum:typeof t.value===\"object\"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),ht=l(\"$ZodCheckGreaterThan\",(e,t)=>{S.init(e,t);let o=rr[typeof t.value];e._zod.onattach.push((r)=>{let n=r._zod.bag,i=(t.inclusive?n.minimum:n.exclusiveMinimum)??Number.NEGATIVE_INFINITY;if(t.value>i)if(t.inclusive)n.minimum=t.value;else n.exclusiveMinimum=t.value}),e._zod.check=(r)=>{if(t.inclusive?r.value>=t.value:r.value>t.value)return;r.issues.push({origin:o,code:\"too_small\",minimum:typeof t.value===\"object\"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),nr=l(\"$ZodCheckMultipleOf\",(e,t)=>{S.init(e,t),e._zod.onattach.push((o)=>{var r;(r=o._zod.bag).multipleOf??(r.multipleOf=t.value)}),e._zod.check=(o)=>{if(typeof o.value!==typeof t.value)throw Error(\"Cannot mix number and bigint in multiple_of check.\");if(typeof o.value===\"bigint\"?o.value%t.value===BigInt(0):co(o.value,t.value)===0)return;o.issues.push({origin:typeof o.value,code:\"not_multiple_of\",divisor:t.value,input:o.value,inst:e,continue:!t.abort})}}),sr=l(\"$ZodCheckNumberFormat\",(e,t)=>{S.init(e,t),t.format=t.format||\"float64\";let o=t.format?.includes(\"int\"),r=o?\"int\":\"number\",[n,i]=fo[t.format];e._zod.onattach.push((s)=>{let a=s._zod.bag;if(a.format=t.format,a.minimum=n,a.maximum=i,o)a.pattern=Yo}),e._zod.check=(s)=>{let a=s.value;if(o){if(!Number.isInteger(a)){s.issues.push({expected:r,format:t.format,code:\"invalid_type\",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){if(a>0)s.issues.push({input:a,code:\"too_big\",maximum:Number.MAX_SAFE_INTEGER,note:\"Integers must be within the safe integer range.\",inst:e,origin:r,inclusive:!0,continue:!t.abort});else s.issues.push({input:a,code:\"too_small\",minimum:Number.MIN_SAFE_INTEGER,note:\"Integers must be within the safe integer range.\",inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}if(a<n)s.issues.push({origin:\"number\",input:a,code:\"too_small\",minimum:n,inclusive:!0,inst:e,continue:!t.abort});if(a>i)s.issues.push({origin:\"number\",input:a,code:\"too_big\",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}});var ir=l(\"$ZodCheckMaxLength\",(e,t)=>{var o;S.init(e,t),(o=e._zod.def).when??(o.when=(r)=>{let n=r.value;return!Pe(n)&&n.length!==void 0}),e._zod.onattach.push((r)=>{let n=r._zod.bag.maximum??Number.POSITIVE_INFINITY;if(t.maximum<n)r._zod.bag.maximum=t.maximum}),e._zod.check=(r)=>{let n=r.value;if(n.length<=t.maximum)return;let s=Ze(n);r.issues.push({origin:s,code:\"too_big\",maximum:t.maximum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),ar=l(\"$ZodCheckMinLength\",(e,t)=>{var o;S.init(e,t),(o=e._zod.def).when??(o.when=(r)=>{let n=r.value;return!Pe(n)&&n.length!==void 0}),e._zod.onattach.push((r)=>{let n=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;if(t.minimum>n)r._zod.bag.minimum=t.minimum}),e._zod.check=(r)=>{let n=r.value;if(n.length>=t.minimum)return;let s=Ze(n);r.issues.push({origin:s,code:\"too_small\",minimum:t.minimum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),cr=l(\"$ZodCheckLengthEquals\",(e,t)=>{var o;S.init(e,t),(o=e._zod.def).when??(o.when=(r)=>{let n=r.value;return!Pe(n)&&n.length!==void 0}),e._zod.onattach.push((r)=>{let n=r._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=(r)=>{let n=r.value,i=n.length;if(i===t.length)return;let s=Ze(n),a=i>t.length;r.issues.push({origin:s,...a?{code:\"too_big\",maximum:t.length}:{code:\"too_small\",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),ye=l(\"$ZodCheckStringFormat\",(e,t)=>{var o,r;if(S.init(e,t),e._zod.onattach.push((n)=>{let i=n._zod.bag;if(i.format=t.format,t.pattern)i.patterns??(i.patterns=new Set),i.patterns.add(t.pattern)}),t.pattern)(o=e._zod).check??(o.check=(n)=>{if(t.pattern.lastIndex=0,t.pattern.test(n.value))return;n.issues.push({origin:\"string\",code:\"invalid_format\",format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})});else(r=e._zod).check??(r.check=()=>{})}),ur=l(\"$ZodCheckRegex\",(e,t)=>{ye.init(e,t),e._zod.check=(o)=>{if(t.pattern.lastIndex=0,t.pattern.test(o.value))return;o.issues.push({origin:\"string\",code:\"invalid_format\",format:\"regex\",input:o.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),lr=l(\"$ZodCheckLowerCase\",(e,t)=>{t.pattern??(t.pattern=tr),ye.init(e,t)}),pr=l(\"$ZodCheckUpperCase\",(e,t)=>{t.pattern??(t.pattern=or),ye.init(e,t)}),dr=l(\"$ZodCheckIncludes\",(e,t)=>{S.init(e,t);let o=q(t.includes),r=new RegExp(typeof t.position===\"number\"?`^.{${t.position}}${o}`:o);t.pattern=r,e._zod.onattach.push((n)=>{let i=n._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(r)}),e._zod.check=(n)=>{if(n.value.includes(t.includes,t.position))return;n.issues.push({origin:\"string\",code:\"invalid_format\",format:\"includes\",includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),mr=l(\"$ZodCheckStartsWith\",(e,t)=>{S.init(e,t);let o=new RegExp(`^${q(t.prefix)}.*`);t.pattern??(t.pattern=o),e._zod.onattach.push((r)=>{let n=r._zod.bag;n.patterns??(n.patterns=new Set),n.patterns.add(o)}),e._zod.check=(r)=>{if(r.value.startsWith(t.prefix))return;r.issues.push({origin:\"string\",code:\"invalid_format\",format:\"starts_with\",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),fr=l(\"$ZodCheckEndsWith\",(e,t)=>{S.init(e,t);let o=new RegExp(`.*${q(t.suffix)}$`);t.pattern??(t.pattern=o),e._zod.onattach.push((r)=>{let n=r._zod.bag;n.patterns??(n.patterns=new Set),n.patterns.add(o)}),e._zod.check=(r)=>{if(r.value.endsWith(t.suffix))return;r.issues.push({origin:\"string\",code:\"invalid_format\",format:\"ends_with\",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}});var hr=l(\"$ZodCheckOverwrite\",(e,t)=>{S.init(e,t),e._zod.check=(o)=>{o.value=t.tx(o.value)}});class gt{constructor(e=[]){if(this.content=[],this.indent=0,this)this.args=e}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if(typeof e===\"function\"){e(this,{execution:\"sync\"}),e(this,{execution:\"async\"});return}let o=e.split(`\n`).filter((i)=>i),r=Math.min(...o.map((i)=>i.length-i.trimStart().length)),n=o.map((i)=>i.slice(r)).map((i)=>\" \".repeat(this.indent*2)+i);for(let i of n)this.content.push(i)}compile(){let e=Function,t=this?.args,r=[...(this?.content??[\"\"]).map((n)=>` ${n}`)];return new e(...t,r.join(`\n`))}}var yr={major:4,minor:4,patch:3};var w=l(\"$ZodType\",(e,t)=>{var o;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=yr;let r=[...e._zod.def.checks??[]];if(e._zod.traits.has(\"$ZodCheck\"))r.unshift(e);for(let n of r)for(let i of n._zod.onattach)i(e);if(r.length===0)(o=e._zod).deferred??(o.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let n=(s,a,c)=>{let u=te(s),p;for(let d of a){if(d._zod.def.when){if(ho(s))continue;if(!d._zod.def.when(s))continue}else if(u)continue;let h=s.issues.length,m=d._zod.check(s);if(m instanceof Promise&&c?.async===!1)throw new F;if(p||m instanceof Promise)p=(p??Promise.resolve()).then(async()=>{if(await m,s.issues.length===h)return;if(!u)u=te(s,h)});else{if(s.issues.length===h)continue;if(!u)u=te(s,h)}}if(p)return p.then(()=>s);return s},i=(s,a,c)=>{if(te(s))return s.aborted=!0,s;let u=n(a,r,c);if(u instanceof Promise){if(c.async===!1)throw new F;return u.then((p)=>e._zod.parse(p,c))}return e._zod.parse(u,c)};e._zod.run=(s,a)=>{if(a.skipChecks)return e._zod.parse(s,a);if(a.direction===\"backward\"){let u=e._zod.parse({value:s.value,issues:[]},{...a,skipChecks:!0});if(u instanceof Promise)return u.then((p)=>i(p,s,a));return i(u,s,a)}let c=e._zod.parse(s,a);if(c instanceof Promise){if(a.async===!1)throw new F;return c.then((u)=>n(u,r,a))}return n(c,r,a)}}_(e,\"~standard\",()=>({validate:(n)=>{try{let i=xo(e,n);return i.success?{value:i.data}:{issues:i.error?.issues}}catch(i){return wo(e,n).then((s)=>s.success?{value:s.data}:{issues:s.error?.issues})}},vendor:\"zod\",version:1}))}),Ge=l(\"$ZodString\",(e,t)=>{w.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Xo(e._zod.bag),e._zod.parse=(o,r)=>{if(t.coerce)try{o.value=String(o.value)}catch(n){}if(typeof o.value===\"string\")return o;return o.issues.push({expected:\"string\",code:\"invalid_type\",input:o.value,inst:e}),o}}),b=l(\"$ZodStringFormat\",(e,t)=>{ye.init(e,t),Ge.init(e,t)}),kr=l(\"$ZodGUID\",(e,t)=>{t.pattern??(t.pattern=No),b.init(e,t)}),Ar=l(\"$ZodUUID\",(e,t)=>{if(t.version){let r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(r===void 0)throw Error(`Invalid UUID version: \"${t.version}\"`);t.pattern??(t.pattern=pt(r))}else t.pattern??(t.pattern=pt());b.init(e,t)}),Er=l(\"$ZodEmail\",(e,t)=>{t.pattern??(t.pattern=jo),b.init(e,t)}),Sr=l(\"$ZodURL\",(e,t)=>{b.init(e,t),e._zod.check=(o)=>{try{let r=o.value.trim();if(!t.normalize&&t.protocol?.source===Vo.source){if(!/^https?:\\/\\//i.test(r)){o.issues.push({code:\"invalid_format\",format:\"url\",note:\"Invalid URL format\",input:o.value,inst:e,continue:!t.abort});return}}let n=new URL(r);if(t.hostname){if(t.hostname.lastIndex=0,!t.hostname.test(n.hostname))o.issues.push({code:\"invalid_format\",format:\"url\",note:\"Invalid hostname\",pattern:t.hostname.source,input:o.value,inst:e,continue:!t.abort})}if(t.protocol){if(t.protocol.lastIndex=0,!t.protocol.test(n.protocol.endsWith(\":\")?n.protocol.slice(0,-1):n.protocol))o.issues.push({code:\"invalid_format\",format:\"url\",note:\"Invalid protocol\",pattern:t.protocol.source,input:o.value,inst:e,continue:!t.abort})}if(t.normalize)o.value=n.href;else o.value=r;return}catch(r){o.issues.push({code:\"invalid_format\",format:\"url\",input:o.value,inst:e,continue:!t.abort})}}}),Cr=l(\"$ZodEmoji\",(e,t)=>{t.pattern??(t.pattern=Do()),b.init(e,t)}),Or=l(\"$ZodNanoID\",(e,t)=>{t.pattern??(t.pattern=Zo),b.init(e,t)}),Pr=l(\"$ZodCUID\",(e,t)=>{t.pattern??(t.pattern=So),b.init(e,t)}),Ir=l(\"$ZodCUID2\",(e,t)=>{t.pattern??(t.pattern=Co),b.init(e,t)}),Zr=l(\"$ZodULID\",(e,t)=>{t.pattern??(t.pattern=Oo),b.init(e,t)}),Rr=l(\"$ZodXID\",(e,t)=>{t.pattern??(t.pattern=Po),b.init(e,t)}),Nr=l(\"$ZodKSUID\",(e,t)=>{t.pattern??(t.pattern=Io),b.init(e,t)}),jr=l(\"$ZodISODateTime\",(e,t)=>{t.pattern??(t.pattern=Ho(t)),b.init(e,t)}),Dr=l(\"$ZodISODate\",(e,t)=>{t.pattern??(t.pattern=Bo),b.init(e,t)}),Mr=l(\"$ZodISOTime\",(e,t)=>{t.pattern??(t.pattern=Ko(t)),b.init(e,t)}),Lr=l(\"$ZodISODuration\",(e,t)=>{t.pattern??(t.pattern=Ro),b.init(e,t)}),Gr=l(\"$ZodIPv4\",(e,t)=>{t.pattern??(t.pattern=Mo),b.init(e,t),e._zod.bag.format=\"ipv4\"}),Fr=l(\"$ZodIPv6\",(e,t)=>{t.pattern??(t.pattern=Lo),b.init(e,t),e._zod.bag.format=\"ipv6\",e._zod.check=(o)=>{try{new URL(`http://[${o.value}]`)}catch{o.issues.push({code:\"invalid_format\",format:\"ipv6\",input:o.value,inst:e,continue:!t.abort})}}});var Ur=l(\"$ZodCIDRv4\",(e,t)=>{t.pattern??(t.pattern=Go),b.init(e,t)}),Vr=l(\"$ZodCIDRv6\",(e,t)=>{t.pattern??(t.pattern=Fo),b.init(e,t),e._zod.check=(o)=>{let r=o.value.split(\"/\");try{if(r.length!==2)throw Error();let[n,i]=r;if(!i)throw Error();let s=Number(i);if(`${s}`!==i)throw Error();if(s<0||s>128)throw Error();new URL(`http://[${n}]`)}catch{o.issues.push({code:\"invalid_format\",format:\"cidrv6\",input:o.value,inst:e,continue:!t.abort})}}});function Jr(e){if(e===\"\")return!0;if(/\\s/.test(e))return!1;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var qr=l(\"$ZodBase64\",(e,t)=>{t.pattern??(t.pattern=Uo),b.init(e,t),e._zod.bag.contentEncoding=\"base64\",e._zod.check=(o)=>{if(Jr(o.value))return;o.issues.push({code:\"invalid_format\",format:\"base64\",input:o.value,inst:e,continue:!t.abort})}});function la(e){if(!dt.test(e))return!1;let t=e.replace(/[-_]/g,(r)=>r===\"-\"?\"+\":\"/\"),o=t.padEnd(Math.ceil(t.length/4)*4,\"=\");return Jr(o)}var Br=l(\"$ZodBase64URL\",(e,t)=>{t.pattern??(t.pattern=dt),b.init(e,t),e._zod.bag.contentEncoding=\"base64url\",e._zod.check=(o)=>{if(la(o.value))return;o.issues.push({code:\"invalid_format\",format:\"base64url\",input:o.value,inst:e,continue:!t.abort})}}),Wr=l(\"$ZodE164\",(e,t)=>{t.pattern??(t.pattern=Jo),b.init(e,t)});function pa(e,t=null){try{let o=e.split(\".\");if(o.length!==3)return!1;let[r]=o;if(!r)return!1;let n=JSON.parse(atob(r));if(\"typ\"in n&&n?.typ!==\"JWT\")return!1;if(!n.alg)return!1;if(t&&(!(\"alg\"in n)||n.alg!==t))return!1;return!0}catch{return!1}}var Kr=l(\"$ZodJWT\",(e,t)=>{b.init(e,t),e._zod.check=(o)=>{if(pa(o.value,t.alg))return;o.issues.push({code:\"invalid_format\",format:\"jwt\",input:o.value,inst:e,continue:!t.abort})}});var _t=l(\"$ZodNumber\",(e,t)=>{w.init(e,t),e._zod.pattern=e._zod.bag.pattern??mt,e._zod.parse=(o,r)=>{if(t.coerce)try{o.value=Number(o.value)}catch(s){}let n=o.value;if(typeof n===\"number\"&&!Number.isNaN(n)&&Number.isFinite(n))return o;let i=typeof n===\"number\"?Number.isNaN(n)?\"NaN\":!Number.isFinite(n)?\"Infinity\":void 0:void 0;return o.issues.push({expected:\"number\",code:\"invalid_type\",input:n,inst:e,...i?{received:i}:{}}),o}}),Hr=l(\"$ZodNumberFormat\",(e,t)=>{sr.init(e,t),_t.init(e,t)}),Xr=l(\"$ZodBoolean\",(e,t)=>{w.init(e,t),e._zod.pattern=Qo,e._zod.parse=(o,r)=>{if(t.coerce)try{o.value=Boolean(o.value)}catch(i){}let n=o.value;if(typeof n===\"boolean\")return o;return o.issues.push({expected:\"boolean\",code:\"invalid_type\",input:n,inst:e}),o}});var Yr=l(\"$ZodNull\",(e,t)=>{w.init(e,t),e._zod.pattern=er,e._zod.values=new Set([null]),e._zod.parse=(o,r)=>{let n=o.value;if(n===null)return o;return o.issues.push({expected:\"null\",code:\"invalid_type\",input:n,inst:e}),o}});var Qr=l(\"$ZodUnknown\",(e,t)=>{w.init(e,t),e._zod.parse=(o)=>o}),en=l(\"$ZodNever\",(e,t)=>{w.init(e,t),e._zod.parse=(o,r)=>(o.issues.push({expected:\"never\",code:\"invalid_type\",input:o.value,inst:e}),o)});function _r(e,t,o){if(e.issues.length)t.issues.push(...B(o,e.issues));t.value[o]=e.value}var tn=l(\"$ZodArray\",(e,t)=>{w.init(e,t),e._zod.parse=(o,r)=>{let n=o.value;if(!Array.isArray(n))return o.issues.push({expected:\"array\",code:\"invalid_type\",input:n,inst:e}),o;o.value=Array(n.length);let i=[];for(let s=0;s<n.length;s++){let a=n[s],c=t.element._zod.run({value:a,issues:[]},r);if(c instanceof Promise)i.push(c.then((u)=>_r(u,o,s)));else _r(c,o,s)}if(i.length)return Promise.all(i).then(()=>o);return o}});function Le(e,t,o,r,n,i){let s=o in r;if(e.issues.length){if(n&&i&&!s)return;t.issues.push(...B(o,e.issues))}if(!s&&!n){if(!e.issues.length)t.issues.push({code:\"invalid_type\",expected:\"nonoptional\",input:void 0,path:[o]});return}if(e.value===void 0){if(s)t.value[o]=void 0}else t.value[o]=e.value}function on(e){let t=Object.keys(e.shape);for(let r of t)if(!e.shape?.[r]?._zod?.traits?.has(\"$ZodType\"))throw Error(`Invalid element at key \"${r}\": expected a Zod schema`);let o=mo(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(o)}}function rn(e,t,o,r,n,i){let s=[],a=n.keySet,c=n.catchall._zod,u=c.def.type,p=c.optin===\"optional\",d=c.optout===\"optional\";for(let h in t){if(h===\"__proto__\")continue;if(a.has(h))continue;if(u===\"never\"){s.push(h);continue}let m=c.run({value:t[h],issues:[]},r);if(m instanceof Promise)e.push(m.then((y)=>Le(y,o,h,t,p,d)));else Le(m,o,h,t,p,d)}if(s.length)o.issues.push({code:\"unrecognized_keys\",keys:s,input:t,inst:i});if(!e.length)return o;return Promise.all(e).then(()=>o)}var da=l(\"$ZodObject\",(e,t)=>{if(w.init(e,t),!Object.getOwnPropertyDescriptor(t,\"shape\")?.get){let a=t.shape;Object.defineProperty(t,\"shape\",{get:()=>{let c={...a};return Object.defineProperty(t,\"shape\",{value:c}),c}})}let r=fe(()=>on(t));_(e._zod,\"propValues\",()=>{let a=t.shape,c={};for(let u in a){let p=a[u]._zod;if(p.values){c[u]??(c[u]=new Set);for(let d of p.values)c[u].add(d)}}return c});let n=ae,i=t.catchall,s;e._zod.parse=(a,c)=>{s??(s=r.value);let u=a.value;if(!n(u))return a.issues.push({expected:\"object\",code:\"invalid_type\",input:u,inst:e}),a;a.value={};let p=[],d=s.shape;for(let h of s.keys){let m=d[h],y=m._zod.optin===\"optional\",G=m._zod.optout===\"optional\",A=m._zod.run({value:u[h],issues:[]},c);if(A instanceof Promise)p.push(A.then((nt)=>Le(nt,a,h,u,y,G)));else Le(A,a,h,u,y,G)}if(!i)return p.length?Promise.all(p).then(()=>a):a;return rn(p,u,a,c,r.value,e)}}),nn=l(\"$ZodObjectJIT\",(e,t)=>{da.init(e,t);let o=e._zod.parse,r=fe(()=>on(t)),n=(h)=>{let m=new gt([\"shape\",\"payload\",\"ctx\"]),y=r.value,G=(j)=>{let T=at(j);return`shape[${T}]._zod.run({ value: input[${T}], issues: [] }, ctx)`};m.write(\"const input = payload.value;\");let A=Object.create(null),nt=0;for(let j of y.keys)A[j]=`key_${nt++}`;m.write(\"const newResult = {};\");for(let j of y.keys){let T=A[j],E=at(j),ro=h[j],no=ro?._zod?.optin===\"optional\",qi=ro?._zod?.optout===\"optional\";if(m.write(`const ${T} = ${G(j)};`),no&&qi)m.write(`\n if (${T}.issues.length) {\n if (${E} in input) {\n payload.issues = payload.issues.concat(${T}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${E}, ...iss.path] : [${E}]\n })));\n }\n }\n \n if (${T}.value === undefined) {\n if (${E} in input) {\n newResult[${E}] = undefined;\n }\n } else {\n newResult[${E}] = ${T}.value;\n }\n \n `);else if(!no)m.write(`\n const ${T}_present = ${E} in input;\n if (${T}.issues.length) {\n payload.issues = payload.issues.concat(${T}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${E}, ...iss.path] : [${E}]\n })));\n }\n if (!${T}_present && !${T}.issues.length) {\n payload.issues.push({\n code: \"invalid_type\",\n expected: \"nonoptional\",\n input: undefined,\n path: [${E}]\n });\n }\n\n if (${T}_present) {\n if (${T}.value === undefined) {\n newResult[${E}] = undefined;\n } else {\n newResult[${E}] = ${T}.value;\n }\n }\n\n `);else m.write(`\n if (${T}.issues.length) {\n payload.issues = payload.issues.concat(${T}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${E}, ...iss.path] : [${E}]\n })));\n }\n \n if (${T}.value === undefined) {\n if (${E} in input) {\n newResult[${E}] = undefined;\n }\n } else {\n newResult[${E}] = ${T}.value;\n }\n \n `)}m.write(\"payload.value = newResult;\"),m.write(\"return payload;\");let Ji=m.compile();return(j,T)=>Ji(h,j,T)},i,s=ae,a=!ie.jitless,u=a&&lo.value,p=t.catchall,d;e._zod.parse=(h,m)=>{d??(d=r.value);let y=h.value;if(!s(y))return h.issues.push({expected:\"object\",code:\"invalid_type\",input:y,inst:e}),h;if(a&&u&&m?.async===!1&&m.jitless!==!0){if(!i)i=n(t.shape);if(h=i(h,m),!p)return h;return rn([],y,h,m,d,e)}return o(h,m)}});function xr(e,t,o,r){for(let i of e)if(i.issues.length===0)return t.value=i.value,t;let n=e.filter((i)=>!te(i));if(n.length===1)return t.value=n[0].value,n[0];return t.issues.push({code:\"invalid_union\",input:t.value,inst:o,errors:e.map((i)=>i.issues.map((s)=>N(s,r,R())))}),t}var xt=l(\"$ZodUnion\",(e,t)=>{w.init(e,t),_(e._zod,\"optin\",()=>t.options.some((r)=>r._zod.optin===\"optional\")?\"optional\":void 0),_(e._zod,\"optout\",()=>t.options.some((r)=>r._zod.optout===\"optional\")?\"optional\":void 0),_(e._zod,\"values\",()=>{if(t.options.every((r)=>r._zod.values))return new Set(t.options.flatMap((r)=>Array.from(r._zod.values)));return}),_(e._zod,\"pattern\",()=>{if(t.options.every((r)=>r._zod.pattern)){let r=t.options.map((n)=>n._zod.pattern);return new RegExp(`^(${r.map((n)=>Ie(n.source)).join(\"|\")})$`)}return});let o=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,n)=>{if(o)return o(r,n);let i=!1,s=[];for(let a of t.options){let c=a._zod.run({value:r.value,issues:[]},n);if(c instanceof Promise)s.push(c),i=!0;else{if(c.issues.length===0)return c;s.push(c)}}if(!i)return xr(s,r,e,n);return Promise.all(s).then((a)=>xr(a,r,e,n))}});var sn=l(\"$ZodDiscriminatedUnion\",(e,t)=>{t.inclusive=!1,xt.init(e,t);let o=e._zod.parse;_(e._zod,\"propValues\",()=>{let n={};for(let i of t.options){let s=i._zod.propValues;if(!s||Object.keys(s).length===0)throw Error(`Invalid discriminated union option at index \"${t.options.indexOf(i)}\"`);for(let[a,c]of Object.entries(s)){if(!n[a])n[a]=new Set;for(let u of c)n[a].add(u)}}return n});let r=fe(()=>{let n=t.options,i=new Map;for(let s of n){let a=s._zod.propValues?.[t.discriminator];if(!a||a.size===0)throw Error(`Invalid discriminated union option at index \"${t.options.indexOf(s)}\"`);for(let c of a){if(i.has(c))throw Error(`Duplicate discriminator value \"${String(c)}\"`);i.set(c,s)}}return i});e._zod.parse=(n,i)=>{let s=n.value;if(!ae(s))return n.issues.push({code:\"invalid_type\",expected:\"object\",input:s,inst:e}),n;let a=r.value.get(s?.[t.discriminator]);if(a)return a._zod.run(n,i);if(t.unionFallback||i.direction===\"backward\")return o(n,i);return n.issues.push({code:\"invalid_union\",errors:[],note:\"No matching discriminator\",discriminator:t.discriminator,options:Array.from(r.value.keys()),input:s,path:[t.discriminator],inst:e}),n}}),an=l(\"$ZodIntersection\",(e,t)=>{w.init(e,t),e._zod.parse=(o,r)=>{let n=o.value,i=t.left._zod.run({value:n,issues:[]},r),s=t.right._zod.run({value:n,issues:[]},r);if(i instanceof Promise||s instanceof Promise)return Promise.all([i,s]).then(([c,u])=>wr(o,c,u));return wr(o,i,s)}});function yt(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e===+t)return{valid:!0,data:e};if(ee(e)&&ee(t)){let o=Object.keys(t),r=Object.keys(e).filter((i)=>o.indexOf(i)!==-1),n={...e,...t};for(let i of r){let s=yt(e[i],t[i]);if(!s.valid)return{valid:!1,mergeErrorPath:[i,...s.mergeErrorPath]};n[i]=s.data}return{valid:!0,data:n}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let o=[];for(let r=0;r<e.length;r++){let n=e[r],i=t[r],s=yt(n,i);if(!s.valid)return{valid:!1,mergeErrorPath:[r,...s.mergeErrorPath]};o.push(s.data)}return{valid:!0,data:o}}return{valid:!1,mergeErrorPath:[]}}function wr(e,t,o){let r=new Map,n;for(let a of t.issues)if(a.code===\"unrecognized_keys\"){n??(n=a);for(let c of a.keys){if(!r.has(c))r.set(c,{});r.get(c).l=!0}}else e.issues.push(a);for(let a of o.issues)if(a.code===\"unrecognized_keys\")for(let c of a.keys){if(!r.has(c))r.set(c,{});r.get(c).r=!0}else e.issues.push(a);let i=[...r].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(i.length&&n)e.issues.push({...n,keys:i});if(te(e))return e;let s=yt(t.value,o.value);if(!s.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(s.mergeErrorPath)}`);return e.value=s.data,e}var cn=l(\"$ZodRecord\",(e,t)=>{w.init(e,t),e._zod.parse=(o,r)=>{let n=o.value;if(!ee(n))return o.issues.push({expected:\"record\",code:\"invalid_type\",input:n,inst:e}),o;let i=[],s=t.keyType._zod.values;if(s){o.value={};let a=new Set;for(let u of s)if(typeof u===\"string\"||typeof u===\"number\"||typeof u===\"symbol\"){a.add(typeof u===\"number\"?u.toString():u);let p=t.keyType._zod.run({value:u,issues:[]},r);if(p instanceof Promise)throw Error(\"Async schemas not supported in object keys currently\");if(p.issues.length){o.issues.push({code:\"invalid_key\",origin:\"record\",issues:p.issues.map((m)=>N(m,r,R())),input:u,path:[u],inst:e});continue}let d=p.value,h=t.valueType._zod.run({value:n[u],issues:[]},r);if(h instanceof Promise)i.push(h.then((m)=>{if(m.issues.length)o.issues.push(...B(u,m.issues));o.value[d]=m.value}));else{if(h.issues.length)o.issues.push(...B(u,h.issues));o.value[d]=h.value}}let c;for(let u in n)if(!a.has(u))c=c??[],c.push(u);if(c&&c.length>0)o.issues.push({code:\"unrecognized_keys\",input:n,inst:e,keys:c})}else{o.value={};for(let a of Reflect.ownKeys(n)){if(a===\"__proto__\")continue;if(!Object.prototype.propertyIsEnumerable.call(n,a))continue;let c=t.keyType._zod.run({value:a,issues:[]},r);if(c instanceof Promise)throw Error(\"Async schemas not supported in object keys currently\");if(typeof a===\"string\"&&mt.test(a)&&c.issues.length){let d=t.keyType._zod.run({value:Number(a),issues:[]},r);if(d instanceof Promise)throw Error(\"Async schemas not supported in object keys currently\");if(d.issues.length===0)c=d}if(c.issues.length){if(t.mode===\"loose\")o.value[a]=n[a];else o.issues.push({code:\"invalid_key\",origin:\"record\",issues:c.issues.map((d)=>N(d,r,R())),input:a,path:[a],inst:e});continue}let p=t.valueType._zod.run({value:n[a],issues:[]},r);if(p instanceof Promise)i.push(p.then((d)=>{if(d.issues.length)o.issues.push(...B(a,d.issues));o.value[c.value]=d.value}));else{if(p.issues.length)o.issues.push(...B(a,p.issues));o.value[c.value]=p.value}}}if(i.length)return Promise.all(i).then(()=>o);return o}});var un=l(\"$ZodEnum\",(e,t)=>{w.init(e,t);let o=Oe(t.entries),r=new Set(o);e._zod.values=r,e._zod.pattern=new RegExp(`^(${o.filter((n)=>po.has(typeof n)).map((n)=>typeof n===\"string\"?q(n):n.toString()).join(\"|\")})$`),e._zod.parse=(n,i)=>{let s=n.value;if(r.has(s))return n;return n.issues.push({code:\"invalid_value\",values:o,input:s,inst:e}),n}}),ln=l(\"$ZodLiteral\",(e,t)=>{if(w.init(e,t),t.values.length===0)throw Error(\"Cannot create literal schema with no valid values\");let o=new Set(t.values);e._zod.values=o,e._zod.pattern=new RegExp(`^(${t.values.map((r)=>typeof r===\"string\"?q(r):r?q(r.toString()):String(r)).join(\"|\")})$`),e._zod.parse=(r,n)=>{let i=r.value;if(o.has(i))return r;return r.issues.push({code:\"invalid_value\",values:t.values,input:i,inst:e}),r}});var pn=l(\"$ZodTransform\",(e,t)=>{w.init(e,t),e._zod.optin=\"optional\",e._zod.parse=(o,r)=>{if(r.direction===\"backward\")throw new de(e.constructor.name);let n=t.transform(o.value,o);if(r.async)return(n instanceof Promise?n:Promise.resolve(n)).then((s)=>(o.value=s,o.fallback=!0,o));if(n instanceof Promise)throw new F;return o.value=n,o.fallback=!0,o}});function br(e,t){if(t===void 0&&(e.issues.length||e.fallback))return{issues:[],value:void 0};return e}var wt=l(\"$ZodOptional\",(e,t)=>{w.init(e,t),e._zod.optin=\"optional\",e._zod.optout=\"optional\",_(e._zod,\"values\",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),_(e._zod,\"pattern\",()=>{let o=t.innerType._zod.pattern;return o?new RegExp(`^(${Ie(o.source)})?$`):void 0}),e._zod.parse=(o,r)=>{if(t.innerType._zod.optin===\"optional\"){let n=o.value,i=t.innerType._zod.run(o,r);if(i instanceof Promise)return i.then((s)=>br(s,n));return br(i,n)}if(o.value===void 0)return o;return t.innerType._zod.run(o,r)}}),dn=l(\"$ZodExactOptional\",(e,t)=>{wt.init(e,t),_(e._zod,\"values\",()=>t.innerType._zod.values),_(e._zod,\"pattern\",()=>t.innerType._zod.pattern),e._zod.parse=(o,r)=>t.innerType._zod.run(o,r)}),mn=l(\"$ZodNullable\",(e,t)=>{w.init(e,t),_(e._zod,\"optin\",()=>t.innerType._zod.optin),_(e._zod,\"optout\",()=>t.innerType._zod.optout),_(e._zod,\"pattern\",()=>{let o=t.innerType._zod.pattern;return o?new RegExp(`^(${Ie(o.source)}|null)$`):void 0}),_(e._zod,\"values\",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(o,r)=>{if(o.value===null)return o;return t.innerType._zod.run(o,r)}}),fn=l(\"$ZodDefault\",(e,t)=>{w.init(e,t),e._zod.optin=\"optional\",_(e._zod,\"values\",()=>t.innerType._zod.values),e._zod.parse=(o,r)=>{if(r.direction===\"backward\")return t.innerType._zod.run(o,r);if(o.value===void 0)return o.value=t.defaultValue,o;let n=t.innerType._zod.run(o,r);if(n instanceof Promise)return n.then((i)=>vr(i,t));return vr(n,t)}});function vr(e,t){if(e.value===void 0)e.value=t.defaultValue;return e}var hn=l(\"$ZodPrefault\",(e,t)=>{w.init(e,t),e._zod.optin=\"optional\",_(e._zod,\"values\",()=>t.innerType._zod.values),e._zod.parse=(o,r)=>{if(r.direction===\"backward\")return t.innerType._zod.run(o,r);if(o.value===void 0)o.value=t.defaultValue;return t.innerType._zod.run(o,r)}}),gn=l(\"$ZodNonOptional\",(e,t)=>{w.init(e,t),_(e._zod,\"values\",()=>{let o=t.innerType._zod.values;return o?new Set([...o].filter((r)=>r!==void 0)):void 0}),e._zod.parse=(o,r)=>{let n=t.innerType._zod.run(o,r);if(n instanceof Promise)return n.then((i)=>zr(i,e));return zr(n,e)}});function zr(e,t){if(!e.issues.length&&e.value===void 0)e.issues.push({code:\"invalid_type\",expected:\"nonoptional\",input:e.value,inst:t});return e}var yn=l(\"$ZodCatch\",(e,t)=>{w.init(e,t),e._zod.optin=\"optional\",_(e._zod,\"optout\",()=>t.innerType._zod.optout),_(e._zod,\"values\",()=>t.innerType._zod.values),e._zod.parse=(o,r)=>{if(r.direction===\"backward\")return t.innerType._zod.run(o,r);let n=t.innerType._zod.run(o,r);if(n instanceof Promise)return n.then((i)=>{if(o.value=i.value,i.issues.length)o.value=t.catchValue({...o,error:{issues:i.issues.map((s)=>N(s,r,R()))},input:o.value}),o.issues=[],o.fallback=!0;return o});if(o.value=n.value,n.issues.length)o.value=t.catchValue({...o,error:{issues:n.issues.map((i)=>N(i,r,R()))},input:o.value}),o.issues=[],o.fallback=!0;return o}});var _n=l(\"$ZodPipe\",(e,t)=>{w.init(e,t),_(e._zod,\"values\",()=>t.in._zod.values),_(e._zod,\"optin\",()=>t.in._zod.optin),_(e._zod,\"optout\",()=>t.out._zod.optout),_(e._zod,\"propValues\",()=>t.in._zod.propValues),e._zod.parse=(o,r)=>{if(r.direction===\"backward\"){let i=t.out._zod.run(o,r);if(i instanceof Promise)return i.then((s)=>Me(s,t.in,r));return Me(i,t.in,r)}let n=t.in._zod.run(o,r);if(n instanceof Promise)return n.then((i)=>Me(i,t.out,r));return Me(n,t.out,r)}});function Me(e,t,o){if(e.issues.length)return e.aborted=!0,e;return t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},o)}var xn=l(\"$ZodReadonly\",(e,t)=>{w.init(e,t),_(e._zod,\"propValues\",()=>t.innerType._zod.propValues),_(e._zod,\"values\",()=>t.innerType._zod.values),_(e._zod,\"optin\",()=>t.innerType?._zod?.optin),_(e._zod,\"optout\",()=>t.innerType?._zod?.optout),e._zod.parse=(o,r)=>{if(r.direction===\"backward\")return t.innerType._zod.run(o,r);let n=t.innerType._zod.run(o,r);if(n instanceof Promise)return n.then($r);return $r(n)}});function $r(e){return e.value=Object.freeze(e.value),e}var wn=l(\"$ZodLazy\",(e,t)=>{w.init(e,t),_(e._zod,\"innerType\",()=>{let o=t;if(!o._cachedInner)o._cachedInner=t.getter();return o._cachedInner}),_(e._zod,\"pattern\",()=>e._zod.innerType?._zod?.pattern),_(e._zod,\"propValues\",()=>e._zod.innerType?._zod?.propValues),_(e._zod,\"optin\",()=>e._zod.innerType?._zod?.optin??void 0),_(e._zod,\"optout\",()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(o,r)=>e._zod.innerType._zod.run(o,r)}),bn=l(\"$ZodCustom\",(e,t)=>{S.init(e,t),w.init(e,t),e._zod.parse=(o,r)=>o,e._zod.check=(o)=>{let r=o.value,n=t.fn(r);if(n instanceof Promise)return n.then((i)=>Tr(i,o,r,e));Tr(n,o,r,e);return}});function Tr(e,t,o,r){if(!e){let n={code:\"custom\",input:o,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};if(r._zod.def.params)n.params=r._zod.def.params;t.issues.push(oe(n))}}var vn,nl=Symbol(\"ZodOutput\"),sl=Symbol(\"ZodInput\");class zn{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let o=t[0];if(this._map.set(e,o),o&&typeof o===\"object\"&&\"id\"in o)this._idmap.set(o.id,e);return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);if(t&&typeof t===\"object\"&&\"id\"in t)this._idmap.delete(t.id);return this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let o={...this.get(t)??{}};delete o.id;let r={...o,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function ma(){return new zn}(vn=globalThis).__zod_globalRegistry??(vn.__zod_globalRegistry=ma());var re=globalThis.__zod_globalRegistry;function $n(e,t){return new e({type:\"string\",...f(t)})}function Tn(e,t){return new e({type:\"string\",format:\"email\",check:\"string_format\",abort:!1,...f(t)})}function bt(e,t){return new e({type:\"string\",format:\"guid\",check:\"string_format\",abort:!1,...f(t)})}function kn(e,t){return new e({type:\"string\",format:\"uuid\",check:\"string_format\",abort:!1,...f(t)})}function An(e,t){return new e({type:\"string\",format:\"uuid\",check:\"string_format\",abort:!1,version:\"v4\",...f(t)})}function En(e,t){return new e({type:\"string\",format:\"uuid\",check:\"string_format\",abort:!1,version:\"v6\",...f(t)})}function Sn(e,t){return new e({type:\"string\",format:\"uuid\",check:\"string_format\",abort:!1,version:\"v7\",...f(t)})}function Cn(e,t){return new e({type:\"string\",format:\"url\",check:\"string_format\",abort:!1,...f(t)})}function On(e,t){return new e({type:\"string\",format:\"emoji\",check:\"string_format\",abort:!1,...f(t)})}function Pn(e,t){return new e({type:\"string\",format:\"nanoid\",check:\"string_format\",abort:!1,...f(t)})}function In(e,t){return new e({type:\"string\",format:\"cuid\",check:\"string_format\",abort:!1,...f(t)})}function Zn(e,t){return new e({type:\"string\",format:\"cuid2\",check:\"string_format\",abort:!1,...f(t)})}function Rn(e,t){return new e({type:\"string\",format:\"ulid\",check:\"string_format\",abort:!1,...f(t)})}function Nn(e,t){return new e({type:\"string\",format:\"xid\",check:\"string_format\",abort:!1,...f(t)})}function jn(e,t){return new e({type:\"string\",format:\"ksuid\",check:\"string_format\",abort:!1,...f(t)})}function Dn(e,t){return new e({type:\"string\",format:\"ipv4\",check:\"string_format\",abort:!1,...f(t)})}function Mn(e,t){return new e({type:\"string\",format:\"ipv6\",check:\"string_format\",abort:!1,...f(t)})}function Ln(e,t){return new e({type:\"string\",format:\"cidrv4\",check:\"string_format\",abort:!1,...f(t)})}function Gn(e,t){return new e({type:\"string\",format:\"cidrv6\",check:\"string_format\",abort:!1,...f(t)})}function Fn(e,t){return new e({type:\"string\",format:\"base64\",check:\"string_format\",abort:!1,...f(t)})}function Un(e,t){return new e({type:\"string\",format:\"base64url\",check:\"string_format\",abort:!1,...f(t)})}function Vn(e,t){return new e({type:\"string\",format:\"e164\",check:\"string_format\",abort:!1,...f(t)})}function Jn(e,t){return new e({type:\"string\",format:\"jwt\",check:\"string_format\",abort:!1,...f(t)})}function qn(e,t){return new e({type:\"string\",format:\"datetime\",check:\"string_format\",offset:!1,local:!1,precision:null,...f(t)})}function Bn(e,t){return new e({type:\"string\",format:\"date\",check:\"string_format\",...f(t)})}function Wn(e,t){return new e({type:\"string\",format:\"time\",check:\"string_format\",precision:null,...f(t)})}function Kn(e,t){return new e({type:\"string\",format:\"duration\",check:\"string_format\",...f(t)})}function Hn(e,t){return new e({type:\"number\",checks:[],...f(t)})}function Xn(e,t){return new e({type:\"number\",check:\"number_format\",abort:!1,format:\"safeint\",...f(t)})}function Yn(e,t){return new e({type:\"boolean\",...f(t)})}function Qn(e,t){return new e({type:\"null\",...f(t)})}function es(e){return new e({type:\"unknown\"})}function ts(e,t){return new e({type:\"never\",...f(t)})}function Fe(e,t){return new ft({check:\"less_than\",...f(t),value:e,inclusive:!1})}function _e(e,t){return new ft({check:\"less_than\",...f(t),value:e,inclusive:!0})}function Ue(e,t){return new ht({check:\"greater_than\",...f(t),value:e,inclusive:!1})}function xe(e,t){return new ht({check:\"greater_than\",...f(t),value:e,inclusive:!0})}function Ve(e,t){return new nr({check:\"multiple_of\",...f(t),value:e})}function Je(e,t){return new ir({check:\"max_length\",...f(t),maximum:e})}function ce(e,t){return new ar({check:\"min_length\",...f(t),minimum:e})}function qe(e,t){return new cr({check:\"length_equals\",...f(t),length:e})}function vt(e,t){return new ur({check:\"string_format\",format:\"regex\",...f(t),pattern:e})}function zt(e){return new lr({check:\"string_format\",format:\"lowercase\",...f(e)})}function $t(e){return new pr({check:\"string_format\",format:\"uppercase\",...f(e)})}function Tt(e,t){return new dr({check:\"string_format\",format:\"includes\",...f(t),includes:e})}function kt(e,t){return new mr({check:\"string_format\",format:\"starts_with\",...f(t),prefix:e})}function At(e,t){return new fr({check:\"string_format\",format:\"ends_with\",...f(t),suffix:e})}function K(e){return new hr({check:\"overwrite\",tx:e})}function Et(e){return K((t)=>t.normalize(e))}function St(){return K((e)=>e.trim())}function Ct(){return K((e)=>e.toLowerCase())}function Ot(){return K((e)=>e.toUpperCase())}function Pt(){return K((e)=>uo(e))}function os(e,t,o){return new e({type:\"array\",element:t,...f(o)})}function rs(e,t,o){return new e({type:\"custom\",check:\"custom\",fn:t,...f(o)})}function ns(e,t){let o=fa((r)=>(r.addIssue=(n)=>{if(typeof n===\"string\")r.issues.push(oe(n,r.value,o._zod.def));else{let i=n;if(i.fatal)i.continue=!1;i.code??(i.code=\"custom\"),i.input??(i.input=r.value),i.inst??(i.inst=o),i.continue??(i.continue=!o._zod.def.abort),r.issues.push(oe(i))}},e(r.value,r)),t);return o}function fa(e,t){let o=new S({check:\"custom\",...f(t)});return o._zod.check=e,o}function It(e){let t=e?.target??\"draft-2020-12\";if(t===\"draft-4\")t=\"draft-04\";if(t===\"draft-7\")t=\"draft-07\";return{processors:e.processors??{},metadataRegistry:e?.metadata??re,target:t,unrepresentable:e?.unrepresentable??\"throw\",override:e?.override??(()=>{}),io:e?.io??\"output\",counter:0,seen:new Map,cycles:e?.cycles??\"ref\",reused:e?.reused??\"inline\",external:e?.external??void 0}}function k(e,t,o={path:[],schemaPath:[]}){var r;let n=e._zod.def,i=t.seen.get(e);if(i){if(i.count++,o.schemaPath.includes(e))i.cycle=o.path;return i.schema}let s={schema:{},count:1,cycle:void 0,path:o.path};t.seen.set(e,s);let a=e._zod.toJSONSchema?.();if(a)s.schema=a;else{let p={...o,schemaPath:[...o.schemaPath,e],path:o.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,s.schema,p);else{let h=s.schema,m=t.processors[n.type];if(!m)throw Error(`[toJSONSchema]: Non-representable type encountered: ${n.type}`);m(e,t,h,p)}let d=e._zod.parent;if(d){if(!s.ref)s.ref=d;k(d,t,p),t.seen.get(d).isParent=!0}}let c=t.metadataRegistry.get(e);if(c)Object.assign(s.schema,c);if(t.io===\"input\"&&O(e))delete s.schema.examples,delete s.schema.default;if(t.io===\"input\"&&\"_prefault\"in s.schema)(r=s.schema).default??(r.default=s.schema._prefault);return delete s.schema._prefault,t.seen.get(e).schema}function Zt(e,t){let o=e.seen.get(t);if(!o)throw Error(\"Unprocessed schema. This is a bug in Zod.\");let r=new Map;for(let s of e.seen.entries()){let a=e.metadataRegistry.get(s[0])?.id;if(a){let c=r.get(a);if(c&&c!==s[0])throw Error(`Duplicate schema id \"${a}\" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(a,s[0])}}let n=(s)=>{let a=e.target===\"draft-2020-12\"?\"$defs\":\"definitions\";if(e.external){let d=e.external.registry.get(s[0])?.id,h=e.external.uri??((y)=>y);if(d)return{ref:h(d)};let m=s[1].defId??s[1].schema.id??`schema${e.counter++}`;return s[1].defId=m,{defId:m,ref:`${h(\"__shared\")}#/${a}/${m}`}}if(s[1]===o)return{ref:\"#\"};let u=`${\"#\"}/${a}/`,p=s[1].schema.id??`__schema${e.counter++}`;return{defId:p,ref:u+p}},i=(s)=>{if(s[1].schema.$ref)return;let a=s[1],{ref:c,defId:u}=n(s);if(a.def={...a.schema},u)a.defId=u;let p=a.schema;for(let d in p)delete p[d];p.$ref=c};if(e.cycles===\"throw\")for(let s of e.seen.entries()){let a=s[1];if(a.cycle)throw Error(`Cycle detected: #/${a.cycle?.join(\"/\")}/<root>\n\nSet the \\`cycles\\` parameter to \\`\"ref\"\\` to resolve cyclical schemas with defs.`)}for(let s of e.seen.entries()){let a=s[1];if(t===s[0]){i(s);continue}if(e.external){let u=e.external.registry.get(s[0])?.id;if(t!==s[0]&&u){i(s);continue}}if(e.metadataRegistry.get(s[0])?.id){i(s);continue}if(a.cycle){i(s);continue}if(a.count>1){if(e.reused===\"ref\"){i(s);continue}}}}function Rt(e,t){let o=e.seen.get(t);if(!o)throw Error(\"Unprocessed schema. This is a bug in Zod.\");let r=(a)=>{let c=e.seen.get(a);if(c.ref===null)return;let u=c.def??c.schema,p={...u},d=c.ref;if(c.ref=null,d){r(d);let m=e.seen.get(d),y=m.schema;if(y.$ref&&(e.target===\"draft-07\"||e.target===\"draft-04\"||e.target===\"openapi-3.0\"))u.allOf=u.allOf??[],u.allOf.push(y);else Object.assign(u,y);if(Object.assign(u,p),a._zod.parent===d)for(let A in u){if(A===\"$ref\"||A===\"allOf\")continue;if(!(A in p))delete u[A]}if(y.$ref&&m.def)for(let A in u){if(A===\"$ref\"||A===\"allOf\")continue;if(A in m.def&&JSON.stringify(u[A])===JSON.stringify(m.def[A]))delete u[A]}}let h=a._zod.parent;if(h&&h!==d){r(h);let m=e.seen.get(h);if(m?.schema.$ref){if(u.$ref=m.schema.$ref,m.def)for(let y in u){if(y===\"$ref\"||y===\"allOf\")continue;if(y in m.def&&JSON.stringify(u[y])===JSON.stringify(m.def[y]))delete u[y]}}}e.override({zodSchema:a,jsonSchema:u,path:c.path??[]})};for(let a of[...e.seen.entries()].reverse())r(a[0]);let n={};if(e.target===\"draft-2020-12\")n.$schema=\"https://json-schema.org/draft/2020-12/schema\";else if(e.target===\"draft-07\")n.$schema=\"http://json-schema.org/draft-07/schema#\";else if(e.target===\"draft-04\")n.$schema=\"http://json-schema.org/draft-04/schema#\";else if(e.target===\"openapi-3.0\");if(e.external?.uri){let a=e.external.registry.get(t)?.id;if(!a)throw Error(\"Schema is missing an `id` property\");n.$id=e.external.uri(a)}Object.assign(n,o.def??o.schema);let i=e.metadataRegistry.get(t)?.id;if(i!==void 0&&n.id===i)delete n.id;let s=e.external?.defs??{};for(let a of e.seen.entries()){let c=a[1];if(c.def&&c.defId){if(c.def.id===c.defId)delete c.def.id;s[c.defId]=c.def}}if(e.external);else if(Object.keys(s).length>0)if(e.target===\"draft-2020-12\")n.$defs=s;else n.definitions=s;try{let a=JSON.parse(JSON.stringify(n));return Object.defineProperty(a,\"~standard\",{value:{...t[\"~standard\"],jsonSchema:{input:we(t,\"input\",e.processors),output:we(t,\"output\",e.processors)}},enumerable:!1,writable:!1}),a}catch(a){throw Error(\"Error converting schema to JSON.\")}}function O(e,t){let o=t??{seen:new Set};if(o.seen.has(e))return!1;o.seen.add(e);let r=e._zod.def;if(r.type===\"transform\")return!0;if(r.type===\"array\")return O(r.element,o);if(r.type===\"set\")return O(r.valueType,o);if(r.type===\"lazy\")return O(r.getter(),o);if(r.type===\"promise\"||r.type===\"optional\"||r.type===\"nonoptional\"||r.type===\"nullable\"||r.type===\"readonly\"||r.type===\"default\"||r.type===\"prefault\")return O(r.innerType,o);if(r.type===\"intersection\")return O(r.left,o)||O(r.right,o);if(r.type===\"record\"||r.type===\"map\")return O(r.keyType,o)||O(r.valueType,o);if(r.type===\"pipe\"){if(e._zod.traits.has(\"$ZodCodec\"))return!0;return O(r.in,o)||O(r.out,o)}if(r.type===\"object\"){for(let n in r.shape)if(O(r.shape[n],o))return!0;return!1}if(r.type===\"union\"){for(let n of r.options)if(O(n,o))return!0;return!1}if(r.type===\"tuple\"){for(let n of r.items)if(O(n,o))return!0;if(r.rest&&O(r.rest,o))return!0;return!1}return!1}var ss=(e,t={})=>(o)=>{let r=It({...o,processors:t});return k(e,r),Zt(r,e),Rt(r,e)},we=(e,t,o={})=>(r)=>{let{libraryOptions:n,target:i}=r??{},s=It({...n??{},target:i,io:t,processors:o});return k(e,s),Zt(s,e),Rt(s,e)};var ha={guid:\"uuid\",url:\"uri\",datetime:\"date-time\",json_string:\"json-string\",regex:\"\"},is=(e,t,o,r)=>{let n=o;n.type=\"string\";let{minimum:i,maximum:s,format:a,patterns:c,contentEncoding:u}=e._zod.bag;if(typeof i===\"number\")n.minLength=i;if(typeof s===\"number\")n.maxLength=s;if(a){if(n.format=ha[a]??a,n.format===\"\")delete n.format;if(a===\"time\")delete n.format}if(u)n.contentEncoding=u;if(c&&c.size>0){let p=[...c];if(p.length===1)n.pattern=p[0].source;else if(p.length>1)n.allOf=[...p.map((d)=>({...t.target===\"draft-07\"||t.target===\"draft-04\"||t.target===\"openapi-3.0\"?{type:\"string\"}:{},pattern:d.source}))]}},as=(e,t,o,r)=>{let n=o,{minimum:i,maximum:s,format:a,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:p}=e._zod.bag;if(typeof a===\"string\"&&a.includes(\"int\"))n.type=\"integer\";else n.type=\"number\";let d=typeof p===\"number\"&&p>=(i??Number.NEGATIVE_INFINITY),h=typeof u===\"number\"&&u<=(s??Number.POSITIVE_INFINITY),m=t.target===\"draft-04\"||t.target===\"openapi-3.0\";if(d)if(m)n.minimum=p,n.exclusiveMinimum=!0;else n.exclusiveMinimum=p;else if(typeof i===\"number\")n.minimum=i;if(h)if(m)n.maximum=u,n.exclusiveMaximum=!0;else n.exclusiveMaximum=u;else if(typeof s===\"number\")n.maximum=s;if(typeof c===\"number\")n.multipleOf=c},cs=(e,t,o,r)=>{o.type=\"boolean\"};var us=(e,t,o,r)=>{if(t.target===\"openapi-3.0\")o.type=\"string\",o.nullable=!0,o.enum=[null];else o.type=\"null\"};var ls=(e,t,o,r)=>{o.not={}};var ps=(e,t,o,r)=>{};var ds=(e,t,o,r)=>{let n=e._zod.def,i=Oe(n.entries);if(i.every((s)=>typeof s===\"number\"))o.type=\"number\";if(i.every((s)=>typeof s===\"string\"))o.type=\"string\";o.enum=i},ms=(e,t,o,r)=>{let n=e._zod.def,i=[];for(let s of n.values)if(s===void 0){if(t.unrepresentable===\"throw\")throw Error(\"Literal `undefined` cannot be represented in JSON Schema\")}else if(typeof s===\"bigint\")if(t.unrepresentable===\"throw\")throw Error(\"BigInt literals cannot be represented in JSON Schema\");else i.push(Number(s));else i.push(s);if(i.length===0);else if(i.length===1){let s=i[0];if(o.type=s===null?\"null\":typeof s,t.target===\"draft-04\"||t.target===\"openapi-3.0\")o.enum=[s];else o.const=s}else{if(i.every((s)=>typeof s===\"number\"))o.type=\"number\";if(i.every((s)=>typeof s===\"string\"))o.type=\"string\";if(i.every((s)=>typeof s===\"boolean\"))o.type=\"boolean\";if(i.every((s)=>s===null))o.type=\"null\";o.enum=i}};var fs=(e,t,o,r)=>{if(t.unrepresentable===\"throw\")throw Error(\"Custom types cannot be represented in JSON Schema\")};var hs=(e,t,o,r)=>{if(t.unrepresentable===\"throw\")throw Error(\"Transforms cannot be represented in JSON Schema\")};var gs=(e,t,o,r)=>{let n=o,i=e._zod.def,{minimum:s,maximum:a}=e._zod.bag;if(typeof s===\"number\")n.minItems=s;if(typeof a===\"number\")n.maxItems=a;n.type=\"array\",n.items=k(i.element,t,{...r,path:[...r.path,\"items\"]})},ys=(e,t,o,r)=>{let n=o,i=e._zod.def;n.type=\"object\",n.properties={};let s=i.shape;for(let u in s)n.properties[u]=k(s[u],t,{...r,path:[...r.path,\"properties\",u]});let a=new Set(Object.keys(s)),c=new Set([...a].filter((u)=>{let p=i.shape[u]._zod;if(t.io===\"input\")return p.optin===void 0;else return p.optout===void 0}));if(c.size>0)n.required=Array.from(c);if(i.catchall?._zod.def.type===\"never\")n.additionalProperties=!1;else if(!i.catchall){if(t.io===\"output\")n.additionalProperties=!1}else if(i.catchall)n.additionalProperties=k(i.catchall,t,{...r,path:[...r.path,\"additionalProperties\"]})},_s=(e,t,o,r)=>{let n=e._zod.def,i=n.inclusive===!1,s=n.options.map((a,c)=>k(a,t,{...r,path:[...r.path,i?\"oneOf\":\"anyOf\",c]}));if(i)o.oneOf=s;else o.anyOf=s},xs=(e,t,o,r)=>{let n=e._zod.def,i=k(n.left,t,{...r,path:[...r.path,\"allOf\",0]}),s=k(n.right,t,{...r,path:[...r.path,\"allOf\",1]}),a=(u)=>(\"allOf\"in u)&&Object.keys(u).length===1,c=[...a(i)?i.allOf:[i],...a(s)?s.allOf:[s]];o.allOf=c};var ws=(e,t,o,r)=>{let n=o,i=e._zod.def;n.type=\"object\";let s=i.keyType,c=s._zod.bag?.patterns;if(i.mode===\"loose\"&&c&&c.size>0){let p=k(i.valueType,t,{...r,path:[...r.path,\"patternProperties\",\"*\"]});n.patternProperties={};for(let d of c)n.patternProperties[d.source]=p}else{if(t.target===\"draft-07\"||t.target===\"draft-2020-12\")n.propertyNames=k(i.keyType,t,{...r,path:[...r.path,\"propertyNames\"]});n.additionalProperties=k(i.valueType,t,{...r,path:[...r.path,\"additionalProperties\"]})}let u=s._zod.values;if(u){let p=[...u].filter((d)=>typeof d===\"string\"||typeof d===\"number\");if(p.length>0)n.required=p}},bs=(e,t,o,r)=>{let n=e._zod.def,i=k(n.innerType,t,r),s=t.seen.get(e);if(t.target===\"openapi-3.0\")s.ref=n.innerType,o.nullable=!0;else o.anyOf=[i,{type:\"null\"}]},vs=(e,t,o,r)=>{let n=e._zod.def;k(n.innerType,t,r);let i=t.seen.get(e);i.ref=n.innerType},zs=(e,t,o,r)=>{let n=e._zod.def;k(n.innerType,t,r);let i=t.seen.get(e);i.ref=n.innerType,o.default=JSON.parse(JSON.stringify(n.defaultValue))},$s=(e,t,o,r)=>{let n=e._zod.def;k(n.innerType,t,r);let i=t.seen.get(e);if(i.ref=n.innerType,t.io===\"input\")o._prefault=JSON.parse(JSON.stringify(n.defaultValue))},Ts=(e,t,o,r)=>{let n=e._zod.def;k(n.innerType,t,r);let i=t.seen.get(e);i.ref=n.innerType;let s;try{s=n.catchValue(void 0)}catch{throw Error(\"Dynamic catch values are not supported in JSON Schema\")}o.default=s},ks=(e,t,o,r)=>{let n=e._zod.def,i=n.in._zod.traits.has(\"$ZodTransform\"),s=t.io===\"input\"?i?n.out:n.in:n.out;k(s,t,r);let a=t.seen.get(e);a.ref=s},As=(e,t,o,r)=>{let n=e._zod.def;k(n.innerType,t,r);let i=t.seen.get(e);i.ref=n.innerType,o.readOnly=!0};var Nt=(e,t,o,r)=>{let n=e._zod.def;k(n.innerType,t,r);let i=t.seen.get(e);i.ref=n.innerType},Es=(e,t,o,r)=>{let n=e._zod.innerType;k(n,t,r);let i=t.seen.get(e);i.ref=n};var va=l(\"ZodISODateTime\",(e,t)=>{jr.init(e,t),z.init(e,t)});function Ss(e){return qn(va,e)}var za=l(\"ZodISODate\",(e,t)=>{Dr.init(e,t),z.init(e,t)});function Cs(e){return Bn(za,e)}var $a=l(\"ZodISOTime\",(e,t)=>{Mr.init(e,t),z.init(e,t)});function Os(e){return Wn($a,e)}var Ta=l(\"ZodISODuration\",(e,t)=>{Lr.init(e,t),z.init(e,t)});function Ps(e){return Kn(Ta,e)}var Ea=(e,t)=>{Re.init(e,t),e.name=\"ZodError\",Object.defineProperties(e,{format:{value:(o)=>_o(e,o)},flatten:{value:(o)=>yo(e,o)},addIssue:{value:(o)=>{e.issues.push(o),e.message=JSON.stringify(e.issues,me,2)}},addIssues:{value:(o)=>{e.issues.push(...o),e.message=JSON.stringify(e.issues,me,2)}},isEmpty:{get(){return e.issues.length===0}}})};var I=l(\"ZodError\",Ea,{Parent:Error});var Is=Ne(I),Zs=je(I),Rs=he(I),Ns=ge(I),js=bo(I),Ds=vo(I),Ms=zo(I),Ls=$o(I),Gs=To(I),Fs=ko(I),Us=Ao(I),Vs=Eo(I);var Js=new WeakMap;function be(e,t,o){let r=Object.getPrototypeOf(e),n=Js.get(r);if(!n)n=new Set,Js.set(r,n);if(n.has(t))return;n.add(t);for(let i in o){let s=o[i];Object.defineProperty(r,i,{configurable:!0,enumerable:!1,get(){let a=s.bind(this);return Object.defineProperty(this,i,{configurable:!0,writable:!0,enumerable:!0,value:a}),a},set(a){Object.defineProperty(this,i,{configurable:!0,writable:!0,enumerable:!0,value:a})}})}}var v=l(\"ZodType\",(e,t)=>(w.init(e,t),Object.assign(e[\"~standard\"],{jsonSchema:{input:we(e,\"input\"),output:we(e,\"output\")}}),e.toJSONSchema=ss(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,\"_def\",{value:t}),e.parse=(o,r)=>Is(e,o,r,{callee:e.parse}),e.safeParse=(o,r)=>Rs(e,o,r),e.parseAsync=async(o,r)=>Zs(e,o,r,{callee:e.parseAsync}),e.safeParseAsync=async(o,r)=>Ns(e,o,r),e.spa=e.safeParseAsync,e.encode=(o,r)=>js(e,o,r),e.decode=(o,r)=>Ds(e,o,r),e.encodeAsync=async(o,r)=>Ms(e,o,r),e.decodeAsync=async(o,r)=>Ls(e,o,r),e.safeEncode=(o,r)=>Gs(e,o,r),e.safeDecode=(o,r)=>Fs(e,o,r),e.safeEncodeAsync=async(o,r)=>Us(e,o,r),e.safeDecodeAsync=async(o,r)=>Vs(e,o,r),be(e,\"ZodType\",{check(...o){let r=this.def;return this.clone(J(r,{checks:[...r.checks??[],...o.map((n)=>typeof n===\"function\"?{_zod:{check:n,def:{check:\"custom\"},onattach:[]}}:n)]}),{parent:!0})},with(...o){return this.check(...o)},clone(o,r){return D(this,o,r)},brand(){return this},register(o,r){return o.add(this,r),this},refine(o,r){return this.check(kc(o,r))},superRefine(o,r){return this.check(Ac(o,r))},overwrite(o){return this.check(K(o))},optional(){return Hs(this)},exactOptional(){return pc(this)},nullable(){return Xs(this)},nullish(){return Hs(Xs(this))},nonoptional(o){return yc(this,o)},array(){return U(this)},or(o){return Dt([this,o])},and(o){return ic(this,o)},transform(o){return Ys(this,uc(o))},default(o){return fc(this,o)},prefault(o){return gc(this,o)},catch(o){return xc(this,o)},pipe(o){return Ys(this,o)},readonly(){return vc(this)},describe(o){let r=this.clone();return re.add(r,{description:o}),r},meta(...o){if(o.length===0)return re.get(this);let r=this.clone();return re.add(r,o[0]),r},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(o){return o(this)}}),Object.defineProperty(e,\"description\",{get(){return re.get(e)?.description},configurable:!0}),e)),Qs=l(\"_ZodString\",(e,t)=>{Ge.init(e,t),v.init(e,t),e._zod.processJSONSchema=(r,n,i)=>is(e,r,n,i);let o=e._zod.bag;e.format=o.format??null,e.minLength=o.minimum??null,e.maxLength=o.maximum??null,be(e,\"_ZodString\",{regex(...r){return this.check(vt(...r))},includes(...r){return this.check(Tt(...r))},startsWith(...r){return this.check(kt(...r))},endsWith(...r){return this.check(At(...r))},min(...r){return this.check(ce(...r))},max(...r){return this.check(Je(...r))},length(...r){return this.check(qe(...r))},nonempty(...r){return this.check(ce(1,...r))},lowercase(r){return this.check(zt(r))},uppercase(r){return this.check($t(r))},trim(){return this.check(St())},normalize(...r){return this.check(Et(...r))},toLowerCase(){return this.check(Ct())},toUpperCase(){return this.check(Ot())},slugify(){return this.check(Pt())}})}),Ca=l(\"ZodString\",(e,t)=>{Ge.init(e,t),Qs.init(e,t),e.email=(o)=>e.check(Tn(Oa,o)),e.url=(o)=>e.check(Cn(Pa,o)),e.jwt=(o)=>e.check(Jn(Ba,o)),e.emoji=(o)=>e.check(On(Ia,o)),e.guid=(o)=>e.check(bt(qs,o)),e.uuid=(o)=>e.check(kn(We,o)),e.uuidv4=(o)=>e.check(An(We,o)),e.uuidv6=(o)=>e.check(En(We,o)),e.uuidv7=(o)=>e.check(Sn(We,o)),e.nanoid=(o)=>e.check(Pn(Za,o)),e.guid=(o)=>e.check(bt(qs,o)),e.cuid=(o)=>e.check(In(Ra,o)),e.cuid2=(o)=>e.check(Zn(Na,o)),e.ulid=(o)=>e.check(Rn(ja,o)),e.base64=(o)=>e.check(Fn(Va,o)),e.base64url=(o)=>e.check(Un(Ja,o)),e.xid=(o)=>e.check(Nn(Da,o)),e.ksuid=(o)=>e.check(jn(Ma,o)),e.ipv4=(o)=>e.check(Dn(La,o)),e.ipv6=(o)=>e.check(Mn(Ga,o)),e.cidrv4=(o)=>e.check(Ln(Fa,o)),e.cidrv6=(o)=>e.check(Gn(Ua,o)),e.e164=(o)=>e.check(Vn(qa,o)),e.datetime=(o)=>e.check(Ss(o)),e.date=(o)=>e.check(Cs(o)),e.time=(o)=>e.check(Os(o)),e.duration=(o)=>e.check(Ps(o))});function g(e){return $n(Ca,e)}var z=l(\"ZodStringFormat\",(e,t)=>{b.init(e,t),Qs.init(e,t)}),Oa=l(\"ZodEmail\",(e,t)=>{Er.init(e,t),z.init(e,t)});var qs=l(\"ZodGUID\",(e,t)=>{kr.init(e,t),z.init(e,t)});var We=l(\"ZodUUID\",(e,t)=>{Ar.init(e,t),z.init(e,t)});var Pa=l(\"ZodURL\",(e,t)=>{Sr.init(e,t),z.init(e,t)});var Ia=l(\"ZodEmoji\",(e,t)=>{Cr.init(e,t),z.init(e,t)});var Za=l(\"ZodNanoID\",(e,t)=>{Or.init(e,t),z.init(e,t)});var Ra=l(\"ZodCUID\",(e,t)=>{Pr.init(e,t),z.init(e,t)});var Na=l(\"ZodCUID2\",(e,t)=>{Ir.init(e,t),z.init(e,t)});var ja=l(\"ZodULID\",(e,t)=>{Zr.init(e,t),z.init(e,t)});var Da=l(\"ZodXID\",(e,t)=>{Rr.init(e,t),z.init(e,t)});var Ma=l(\"ZodKSUID\",(e,t)=>{Nr.init(e,t),z.init(e,t)});var La=l(\"ZodIPv4\",(e,t)=>{Gr.init(e,t),z.init(e,t)});var Ga=l(\"ZodIPv6\",(e,t)=>{Fr.init(e,t),z.init(e,t)});var Fa=l(\"ZodCIDRv4\",(e,t)=>{Ur.init(e,t),z.init(e,t)});var Ua=l(\"ZodCIDRv6\",(e,t)=>{Vr.init(e,t),z.init(e,t)});var Va=l(\"ZodBase64\",(e,t)=>{qr.init(e,t),z.init(e,t)});var Ja=l(\"ZodBase64URL\",(e,t)=>{Br.init(e,t),z.init(e,t)});var qa=l(\"ZodE164\",(e,t)=>{Wr.init(e,t),z.init(e,t)});var Ba=l(\"ZodJWT\",(e,t)=>{Kr.init(e,t),z.init(e,t)});var ei=l(\"ZodNumber\",(e,t)=>{_t.init(e,t),v.init(e,t),e._zod.processJSONSchema=(r,n,i)=>as(e,r,n,i),be(e,\"ZodNumber\",{gt(r,n){return this.check(Ue(r,n))},gte(r,n){return this.check(xe(r,n))},min(r,n){return this.check(xe(r,n))},lt(r,n){return this.check(Fe(r,n))},lte(r,n){return this.check(_e(r,n))},max(r,n){return this.check(_e(r,n))},int(r){return this.check(Bs(r))},safe(r){return this.check(Bs(r))},positive(r){return this.check(Ue(0,r))},nonnegative(r){return this.check(xe(0,r))},negative(r){return this.check(Fe(0,r))},nonpositive(r){return this.check(_e(0,r))},multipleOf(r,n){return this.check(Ve(r,n))},step(r,n){return this.check(Ve(r,n))},finite(){return this}});let o=e._zod.bag;e.minValue=Math.max(o.minimum??Number.NEGATIVE_INFINITY,o.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(o.maximum??Number.POSITIVE_INFINITY,o.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(o.format??\"\").includes(\"int\")||Number.isSafeInteger(o.multipleOf??0.5),e.isFinite=!0,e.format=o.format??null});function ve(e){return Hn(ei,e)}var Wa=l(\"ZodNumberFormat\",(e,t)=>{Hr.init(e,t),ei.init(e,t)});function Bs(e){return Xn(Wa,e)}var Ka=l(\"ZodBoolean\",(e,t)=>{Xr.init(e,t),v.init(e,t),e._zod.processJSONSchema=(o,r,n)=>cs(e,o,r,n)});function ue(e){return Yn(Ka,e)}var Ha=l(\"ZodNull\",(e,t)=>{Yr.init(e,t),v.init(e,t),e._zod.processJSONSchema=(o,r,n)=>us(e,o,r,n)});function Xa(e){return Qn(Ha,e)}var Ya=l(\"ZodUnknown\",(e,t)=>{Qr.init(e,t),v.init(e,t),e._zod.processJSONSchema=(o,r,n)=>ps(e,o,r,n)});function Ws(){return es(Ya)}var Qa=l(\"ZodNever\",(e,t)=>{en.init(e,t),v.init(e,t),e._zod.processJSONSchema=(o,r,n)=>ls(e,o,r,n)});function ec(e){return ts(Qa,e)}var tc=l(\"ZodArray\",(e,t)=>{tn.init(e,t),v.init(e,t),e._zod.processJSONSchema=(o,r,n)=>gs(e,o,r,n),e.element=t.element,be(e,\"ZodArray\",{min(o,r){return this.check(ce(o,r))},nonempty(o){return this.check(ce(1,o))},max(o,r){return this.check(Je(o,r))},length(o,r){return this.check(qe(o,r))},unwrap(){return this.element}})});function U(e,t){return os(tc,e,t)}var oc=l(\"ZodObject\",(e,t)=>{nn.init(e,t),v.init(e,t),e._zod.processJSONSchema=(o,r,n)=>ys(e,o,r,n),_(e,\"shape\",()=>t.shape),be(e,\"ZodObject\",{keyof(){return H(Object.keys(this._zod.def.shape))},catchall(o){return this.clone({...this._zod.def,catchall:o})},passthrough(){return this.clone({...this._zod.def,catchall:Ws()})},loose(){return this.clone({...this._zod.def,catchall:Ws()})},strict(){return this.clone({...this._zod.def,catchall:ec()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(o){return ra(this,o)},safeExtend(o){return na(this,o)},merge(o){return sa(this,o)},pick(o){return ta(this,o)},omit(o){return oa(this,o)},partial(...o){return ia(oi,this,o[0])},required(...o){return aa(ri,this,o[0])}})});function C(e,t){let o={type:\"object\",shape:e??{},...f(t)};return new oc(o)}var ti=l(\"ZodUnion\",(e,t)=>{xt.init(e,t),v.init(e,t),e._zod.processJSONSchema=(o,r,n)=>_s(e,o,r,n),e.options=t.options});function Dt(e,t){return new ti({type:\"union\",options:e,...f(t)})}var rc=l(\"ZodDiscriminatedUnion\",(e,t)=>{ti.init(e,t),sn.init(e,t)});function nc(e,t,o){return new rc({type:\"union\",options:t,discriminator:e,...f(o)})}var sc=l(\"ZodIntersection\",(e,t)=>{an.init(e,t),v.init(e,t),e._zod.processJSONSchema=(o,r,n)=>xs(e,o,r,n)});function ic(e,t){return new sc({type:\"intersection\",left:e,right:t})}var Ks=l(\"ZodRecord\",(e,t)=>{cn.init(e,t),v.init(e,t),e._zod.processJSONSchema=(o,r,n)=>ws(e,o,r,n),e.keyType=t.keyType,e.valueType=t.valueType});function Ke(e,t,o){if(!t||!t._zod)return new Ks({type:\"record\",keyType:g(),valueType:e,...f(t)});return new Ks({type:\"record\",keyType:e,valueType:t,...f(o)})}var jt=l(\"ZodEnum\",(e,t)=>{un.init(e,t),v.init(e,t),e._zod.processJSONSchema=(r,n,i)=>ds(e,r,n,i),e.enum=t.entries,e.options=Object.values(t.entries);let o=new Set(Object.keys(t.entries));e.extract=(r,n)=>{let i={};for(let s of r)if(o.has(s))i[s]=t.entries[s];else throw Error(`Key ${s} not found in enum`);return new jt({...t,checks:[],...f(n),entries:i})},e.exclude=(r,n)=>{let i={...t.entries};for(let s of r)if(o.has(s))delete i[s];else throw Error(`Key ${s} not found in enum`);return new jt({...t,checks:[],...f(n),entries:i})}});function H(e,t){let o=Array.isArray(e)?Object.fromEntries(e.map((r)=>[r,r])):e;return new jt({type:\"enum\",entries:o,...f(t)})}var ac=l(\"ZodLiteral\",(e,t)=>{ln.init(e,t),v.init(e,t),e._zod.processJSONSchema=(o,r,n)=>ms(e,o,r,n),e.values=new Set(t.values),Object.defineProperty(e,\"value\",{get(){if(t.values.length>1)throw Error(\"This schema contains multiple valid literal values. Use `.values` instead.\");return t.values[0]}})});function X(e,t){return new ac({type:\"literal\",values:Array.isArray(e)?e:[e],...f(t)})}var cc=l(\"ZodTransform\",(e,t)=>{pn.init(e,t),v.init(e,t),e._zod.processJSONSchema=(o,r,n)=>hs(e,o,r,n),e._zod.parse=(o,r)=>{if(r.direction===\"backward\")throw new de(e.constructor.name);o.addIssue=(i)=>{if(typeof i===\"string\")o.issues.push(oe(i,o.value,t));else{let s=i;if(s.fatal)s.continue=!1;s.code??(s.code=\"custom\"),s.input??(s.input=o.value),s.inst??(s.inst=e),o.issues.push(oe(s))}};let n=t.transform(o.value,o);if(n instanceof Promise)return n.then((i)=>(o.value=i,o.fallback=!0,o));return o.value=n,o.fallback=!0,o}});function uc(e){return new cc({type:\"transform\",transform:e})}var oi=l(\"ZodOptional\",(e,t)=>{wt.init(e,t),v.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Nt(e,o,r,n),e.unwrap=()=>e._zod.def.innerType});function Hs(e){return new oi({type:\"optional\",innerType:e})}var lc=l(\"ZodExactOptional\",(e,t)=>{dn.init(e,t),v.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Nt(e,o,r,n),e.unwrap=()=>e._zod.def.innerType});function pc(e){return new lc({type:\"optional\",innerType:e})}var dc=l(\"ZodNullable\",(e,t)=>{mn.init(e,t),v.init(e,t),e._zod.processJSONSchema=(o,r,n)=>bs(e,o,r,n),e.unwrap=()=>e._zod.def.innerType});function Xs(e){return new dc({type:\"nullable\",innerType:e})}var mc=l(\"ZodDefault\",(e,t)=>{fn.init(e,t),v.init(e,t),e._zod.processJSONSchema=(o,r,n)=>zs(e,o,r,n),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function fc(e,t){return new mc({type:\"default\",innerType:e,get defaultValue(){return typeof t===\"function\"?t():ut(t)}})}var hc=l(\"ZodPrefault\",(e,t)=>{hn.init(e,t),v.init(e,t),e._zod.processJSONSchema=(o,r,n)=>$s(e,o,r,n),e.unwrap=()=>e._zod.def.innerType});function gc(e,t){return new hc({type:\"prefault\",innerType:e,get defaultValue(){return typeof t===\"function\"?t():ut(t)}})}var ri=l(\"ZodNonOptional\",(e,t)=>{gn.init(e,t),v.init(e,t),e._zod.processJSONSchema=(o,r,n)=>vs(e,o,r,n),e.unwrap=()=>e._zod.def.innerType});function yc(e,t){return new ri({type:\"nonoptional\",innerType:e,...f(t)})}var _c=l(\"ZodCatch\",(e,t)=>{yn.init(e,t),v.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Ts(e,o,r,n),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function xc(e,t){return new _c({type:\"catch\",innerType:e,catchValue:typeof t===\"function\"?t:()=>t})}var wc=l(\"ZodPipe\",(e,t)=>{_n.init(e,t),v.init(e,t),e._zod.processJSONSchema=(o,r,n)=>ks(e,o,r,n),e.in=t.in,e.out=t.out});function Ys(e,t){return new wc({type:\"pipe\",in:e,out:t})}var bc=l(\"ZodReadonly\",(e,t)=>{xn.init(e,t),v.init(e,t),e._zod.processJSONSchema=(o,r,n)=>As(e,o,r,n),e.unwrap=()=>e._zod.def.innerType});function vc(e){return new bc({type:\"readonly\",innerType:e})}var zc=l(\"ZodLazy\",(e,t)=>{wn.init(e,t),v.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Es(e,o,r,n),e.unwrap=()=>e._zod.def.getter()});function $c(e){return new zc({type:\"lazy\",getter:e})}var Tc=l(\"ZodCustom\",(e,t)=>{bn.init(e,t),v.init(e,t),e._zod.processJSONSchema=(o,r,n)=>fs(e,o,r,n)});function kc(e,t={}){return rs(Tc,e,t)}function Ac(e,t){return ns(e,t)}function Mt(e){let t=$c(()=>Dt([g(e),ve(),ue(),Xa(),U(t),Ke(g(),t)]));return t}var si=x(()=>H([\"account:read\",\"account:admin\",\"members:manage\",\"workspace:create\",\"billing:read\",\"billing:manage\",\"workspace:read\",\"workspace:admin\",\"sessions:create\",\"sessions:read\",\"sessions:control\",\"stream:view\",\"stream:control\",\"stream:acknowledge\",\"files:upload\",\"files:read\",\"files:write\",\"terminal:attach\",\"documents:manage\",\"documents:search\",\"scheduled_tasks:manage\",\"scheduled_tasks:run\",\"github:manage\",\"github:use\",\"api_keys:manage\",\"usage_allowances:manage\",\"connections:read\",\"connections:write\",\"capabilities:manage\",\"environments:manage\",\"environments:use\",\"variable-sets:list\",\"variable-sets:read\",\"variable-sets:write\",\"variable-sets:manage\",\"variable-sets:attach\",\"variable-sets:use\",\"secrets:list\",\"secrets:read\",\"secrets:write\",\"secrets:use\",\"mcp_servers:attach\",\"codemode:call\",\"goals:manage\",\"enrollments:read\",\"enrollments:manage\",\"rigs:use\",\"rigs:manage\",\"artifacts:read\",\"artifacts:publish\"]));var ai=1;var Ec=4096,ci=16777216,Sc=8,Cc=1024,Oc=1;var Lt=x(()=>g().regex(/^[0-9a-f]{64}$/u)),Pc=x(()=>g().min(1).max(256).regex(/^[A-Za-z0-9_-]+$/u)),ui=x(()=>g().min(1).max(512).regex(/^[^\\u0000-\\u001f\\u007f]+$/u)),Ic=x(()=>g().min(1).max(128).regex(/^[A-Za-z_$][A-Za-z0-9_$]*$/u).refine((e)=>![\"__proto__\",\"prototype\",\"constructor\"].includes(e),{message:\"unsafe Codemode namespace segment\"})),Gt=x(()=>Ke(g().max(512),Mt())),li=x(()=>C({serverId:Pc,toolName:ui}).strict());var pi=x(()=>C({src:g().min(1).max(8192),mimeType:g().min(1).max(128).optional(),sizes:U(g().min(1).max(64)).max(16).optional(),theme:H([\"light\",\"dark\"]).optional()}).strict()),Zc=x(()=>C({title:g().max(512).optional(),readOnlyHint:ue().optional(),destructiveHint:ue().optional(),idempotentHint:ue().optional(),openWorldHint:ue().optional()}).loose()),ii=Gt;var Rc=x(()=>C({identity:li,modelName:ui,codemodePath:U(Ic).min(2).max(Sc),title:g().min(1).max(512).optional(),description:g().max(32768).optional(),inputSchema:ii,outputSchema:ii.optional(),annotations:Zc.optional(),icons:U(pi).max(16).optional(),source:H([\"opengeni\",\"files\",\"docs\",\"mcp\",\"codex_apps\",\"interaction\"]),approval:H([\"none\",\"human\",\"policy\"])}).strict());var di=x(()=>C({version:X(ai),accountId:g().uuid(),workspaceId:g().uuid(),sessionId:g().uuid(),turnId:g().uuid(),attemptId:g().uuid(),executionGeneration:ve().int().positive(),generation:ve().int().positive(),digest:Lt,createdAt:g().datetime({offset:!0}),firstPartyMcpPermissions:U(si).max(128).optional(),entries:U(Rc).max(Ec)}).strict().superRefine((e,t)=>{let o=new Set,r=new Set,n=new Set;for(let[i,s]of e.entries.entries()){let a=`${s.identity.serverId}\\x00${s.identity.toolName}`,c=s.codemodePath.join(\".\");if(o.has(a))t.addIssue({code:\"custom\",path:[\"entries\",i,\"identity\"],message:\"duplicate tool identity\"});if(r.has(s.modelName))t.addIssue({code:\"custom\",path:[\"entries\",i,\"modelName\"],message:\"duplicate model tool name\"});if(n.has(c))t.addIssue({code:\"custom\",path:[\"entries\",i,\"codemodePath\"],message:\"duplicate Codemode tool path\"});o.add(a),r.add(s.modelName),n.add(c)}})),mi=x(()=>C({kind:H([\"model\",\"codemode\"]),subjectId:g().min(1).max(1024)}).strict());var ze=x(()=>Ke(g().max(256),Mt()).optional()),Y=x(()=>Ke(g().max(512),Mt()).optional()),Nc=x(()=>C({type:X(\"text\"),text:g(),annotations:ze,_meta:Y}).loose()),jc=x(()=>C({type:X(\"image\"),data:g(),mimeType:g().min(1).max(128),annotations:ze,_meta:Y}).loose()),Dc=x(()=>C({type:X(\"audio\"),data:g(),mimeType:g().min(1).max(128),annotations:ze,_meta:Y}).loose()),Mc=x(()=>C({type:X(\"resource_link\"),name:g().min(1).max(1024),title:g().max(1024).optional(),uri:g().min(1).max(16384),description:g().max(32768).optional(),mimeType:g().max(128).optional(),size:ve().int().nonnegative().optional(),icons:U(pi).max(16).optional(),annotations:ze,_meta:Y}).loose()),Lc=x(()=>C({uri:g().min(1).max(16384),mimeType:g().max(128).optional(),text:g(),_meta:Y}).loose()),Gc=x(()=>C({uri:g().min(1).max(16384),mimeType:g().max(128).optional(),blob:g(),_meta:Y}).loose()),Fc=x(()=>C({type:X(\"resource\"),resource:Dt([Lc,Gc]),annotations:ze,_meta:Y}).loose()),Uc=x(()=>nc(\"type\",[Nc,jc,Dc,Mc,Fc])),He=x(()=>C({content:U(Uc).max(Cc),structuredContent:Gt.optional(),isError:ue().optional(),_meta:Y}).loose());var Hp={siteArtifactId:g().uuid().optional(),siteVersionId:g().uuid().optional()};var Vc=x(()=>H([\"queued\",\"waiting_for_approval\",\"running\",\"completed\",\"failed\",\"outcome_unknown\",\"cancelled\"])),Ft=x(()=>C({version:X(Oc),operationId:g().uuid(),accountId:g().uuid(),workspaceId:g().uuid(),sessionId:g().uuid(),turnId:g().uuid(),attemptId:g().uuid(),executionGeneration:ve().int().positive(),catalogDigest:Lt,requestDigest:Lt,identity:li,arguments:Gt,caller:mi.refine((e)=>e.kind===\"codemode\",{message:\"Codemode operation caller must be codemode\"}),state:Vc,durableApproval:X(!0).optional(),approvalRequestId:g().uuid().optional(),result:He.nullable(),errorCode:g().min(1).max(128).nullable(),errorMessage:g().min(1).max(4096).nullable(),createdAt:g().datetime({offset:!0}),claimedAt:g().datetime({offset:!0}).nullable(),executionStartedAt:g().datetime({offset:!0}).nullable(),completedAt:g().datetime({offset:!0}).nullable(),updatedAt:g().datetime({offset:!0})}).strict());var fi=x(()=>C({operation:Ft,dispatch:H([\"accepted\",\"already_running\",\"terminal\",\"unavailable\",\"rejected\"])}).strict());var hi=\"/v1/workspaces/site-host\",Jc=/^\\/v1\\/workspaces\\/site-host\\/published-artifacts\\/([^/]+)\\/(?:data|files|sql)(?:\\/|$)/u,qc=\"00000000-0000-0000-0000-000000000000\";class Xe extends Error{code=\"site_session_path_unsupported\";constructor(){super(\"Unsupported Site session API path\");this.name=\"SiteSessionPathError\"}}class yi extends Error{code=\"site_data_unsupported\";constructor(){super(\"This Site host does not provide Site Data\");this.name=\"SiteDataUnsupportedError\"}}function Bc(e){return/[%\\\\#\\u0000-\\u0020\\u007f]/u.test(e)||e.split(\"/\").some((t)=>t===\".\"||t===\"..\")}function Wc(e,t){let o=new URL(e,\"http://site.invalid\");if(o.pathname===\"/v1/config/client\"){let r=o.searchParams.getAll(\"workspaceId\");if(r.length>1||r.length===1&&r[0]!==\"site-host\"&&r[0]!==t)throw new Xe;if(t!==\"site-host\")o.searchParams.set(\"workspaceId\",t);return o.pathname+o.search}return e.replace(\"/workspaces/site-host\",`/workspaces/${encodeURIComponent(t)}`)}function Kc(e,t,o,r){if(o===\"site-host\")return e;if(!r)throw new yi;return t.replace(\"/published-artifacts/current/\",`/published-artifacts/${encodeURIComponent(r)}/`)}function _i(e,t){let o=e.split(\"?\")[0];if(!(o===hi||o.startsWith(`${hi}/`))&&o!==\"/v1/config/client\"||Bc(o))throw new Xe;let n=Wc(e,t),i=Jc.exec(o);if(i){if(i[1]!==\"current\")throw new Xe;return Kc(e,n,t)}let s=new URL(n,\"http://site.invalid\");if(s.searchParams.get(\"originSiteId\")===\"current\"&&t!==\"site-host\")return s.searchParams.set(\"originSiteId\",qc),s.pathname+s.search;return n}var gi=[\"text\",\"annotations\",\"model\",\"reasoningEffort\",\"latencyMode\",\"controlEtag\",\"expectedDraftRevision\"],Yp=Object.freeze({\"sessions.send\":[\"type\",\"payload\",\"clientEventId\"],\"sessions.steer\":[...gi,\"clientEventId\"],\"sessions.control\":[\"action\",\"reason\",\"clientEventId\",\"expectedControlEtag\"],\"sessions.composerDraft.put\":[\"text\",\"annotations\",\"resources\",\"model\",\"reasoningEffort\",\"latencyMode\",\"expectedRevision\"],\"sessions.composerDraft.submit\":[...gi,\"resources\",\"connectionAccounts\",\"clientEventId\",\"delivery\"],\"sessions.queue.move\":[\"clientEventId\",\"expectedQueueVersion\",\"beforeTurnId\"],\"sessions.queue.edit\":[\"clientEventId\",\"expectedTurnVersion\",\"expectedDraftRevision\",\"replaceDraft\"],\"sessions.queue.steer\":[\"clientEventId\",\"expectedTurnVersion\",\"controlEtag\"],\"sessions.queue.delete\":[\"clientEventId\",\"expectedTurnVersion\",\"reason\"]});var Qp=Object.freeze([\"initialMessage\",\"requestedSessionId\",\"idempotencyKey\",\"clientEventId\",\"model\",\"reasoningEffort\",\"latencyMode\",\"startMode\",\"metadata\"]);function xi(e){let t=e.structuredContent;if(t===void 0||t===null)return e;let o=e.content.filter((r)=>!Hc(r)||!Xc(r.text,t));if(o.length===e.content.length)return e;return{...e,content:o}}function Hc(e){if(!e||typeof e!==\"object\"||Array.isArray(e))return!1;let t=e;if(t.type!==\"text\"||typeof t.text!==\"string\")return!1;return Object.keys(t).every((o)=>o===\"type\"||o===\"text\")}function Xc(e,t){let o=e.replace(/^[ \\t\\n\\r]+/u,\"\");if(!o.startsWith(\"{\")&&!o.startsWith(\"[\"))return!1;let r;try{r=JSON.parse(e)}catch{return!1}return!Ut(r)&&Vt(r,t)}function Ut(e){if(typeof e===\"number\")return Number.isInteger(e)&&!Number.isSafeInteger(e);if(Array.isArray(e))return e.some(Ut);if(e&&typeof e===\"object\")return Object.values(e).some(Ut);return!1}function Vt(e,t){if(e===t)return!0;if(typeof e!==\"object\"||typeof t!==\"object\"||e===null||t===null)return!1;if(Array.isArray(e)||Array.isArray(t)){if(!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length)return!1;return e.every((i,s)=>Vt(i,t[s]))}let o=e,r=t,n=Object.keys(o);if(n.length!==Object.keys(r).length)return!1;return n.every((i)=>Object.hasOwn(r,i)&&Vt(o[i],r[i]))}var wi=require(\"node:crypto\");class le extends Error{code=\"tool_not_found\";constructor(){super(\"Tool is not present in the active gateway catalog\");this.name=\"ToolGatewayToolNotFoundError\"}}class Jt extends Error{code=\"catalog_integrity_failed\";constructor(){super(\"Tool catalog digest does not match its authoritative content\");this.name=\"ToolGatewayCatalogIntegrityError\"}}class qt extends Error{code=\"catalog_too_large\";constructor(){super(\"Tool catalog exceeds the maximum serialized size\");this.name=\"ToolGatewayCatalogTooLargeError\"}}class $e extends Error{code=\"tool_path_collision\";constructor(e,t){super(t===\"extends_leaf\"?`Tool path ${e.join(\".\")} extends a tool leaf`:`Tool path ${e.join(\".\")} collides`);this.name=\"ToolGatewayPathCollisionError\"}}function Te(e){return wi.createHash(\"sha256\").update(JSON.stringify(Bt(e)),\"utf8\").digest(\"hex\")}function bi(e,t){return Te({domain:\"opengeni.tool-definition\",version:1,accountId:e.accountId,workspaceId:e.workspaceId,entry:t})}function pe(e,t){return e<t?-1:e>t?1:0}function Bt(e){if(Array.isArray(e))return e.map(Bt);if(e!==null&&typeof e===\"object\")return Object.fromEntries(Object.entries(e).sort(([t],[o])=>pe(t,o)).map(([t,o])=>[t,Bt(o)]));return e}function zi(e,t){let o=$i();for(let r of e.entries)Yc(o,r);return[`// Generated by ${t.generatedBy}. Do not edit.`,`// ${t.catalogDigestLabel??\"Tool catalog digest\"}: ${e.digest}`,...t.typedResultWrapperType?[\"// Typed calls normally return their structured output. If image blocks are present,\",\"// they return CodemodeMultimodalValue<T> with local image paths and original content.\"]:[],`import type { ${[t.callOptionsType,t.fallbackResultType,...t.typedResultWrapperType?[t.typedResultWrapperType]:[]].join(\", \")} } from ${JSON.stringify(t.moduleSpecifier)};`,\"\",`declare module ${JSON.stringify(t.moduleSpecifier)} {`,` interface ${t.interfaceName} {`,...Ti(o,4,t),\" }\",\"}\",\"\",\"export {};\",\"\"].join(`\n`)}function Wt(e){return M(e,e,new Set,0)}function $i(){return{children:new Map,entry:null}}function Yc(e,t){let o=e;for(let[r,n]of t.codemodePath.entries()){if(o.entry)throw new $e(t.codemodePath,\"extends_leaf\");let i=o.children.get(n);if(!i)i=$i(),o.children.set(n,i);if(o=i,r===t.codemodePath.length-1){if(o.entry||o.children.size>0)throw new $e(t.codemodePath,\"collision\");o.entry=t}}}function Ti(e,t,o){let r=[];for(let[n,i]of[...e.children].sort(([s],[a])=>pe(s,a))){if(i.entry){let s=i.entry,a=Wt(s.inputSchema),c=s.outputSchema?Wt(s.outputSchema):null,u=c?o.typedResultWrapperType?`${c} | ${o.typedResultWrapperType}<${c}>`:c:o.fallbackResultType,p=su(s.description??s.title);if(p)r.push(...iu(p,t));r.push(`${ne(t)}readonly ${n}: (`),r.push(`${ne(t+2)}argumentsValue${Qc(s.inputSchema)?\"?\":\"\"}: ${a},`),r.push(`${ne(t+2)}options?: ${o.callOptionsType},`),r.push(`${ne(t)}) => Promise<${u}>;`);continue}r.push(`${ne(t)}readonly ${n}: {`),r.push(...Ti(i,t+2,o)),r.push(`${ne(t)}};`)}return r}function Qc(e){if(!se(e))return!1;return(Array.isArray(e.required)?e.required.filter((o)=>typeof o===\"string\"):[]).length===0&&(e.type===\"object\"||se(e.properties))}function M(e,t,o,r){if(r>48||e===!0)return\"unknown\";if(e===!1)return\"never\";if(!se(e))return\"unknown\";if(typeof e.$ref===\"string\"){if(!e.$ref.startsWith(\"#/\")||o.has(e.$ref))return\"unknown\";let a=nu(t,e.$ref);if(a===void 0)return\"unknown\";let c=new Set(o);return c.add(e.$ref),M(a,t,c,r+1)}if(Object.hasOwn(e,\"const\"))return Ye(e.const);if(Array.isArray(e.enum))return ke(e.enum.map(Ye));let n=[];if(Array.isArray(e.oneOf))n.push(ke(e.oneOf.map((a)=>M(a,t,o,r+1))));if(Array.isArray(e.anyOf))n.push(ke(e.anyOf.map((a)=>M(a,t,o,r+1))));if(Array.isArray(e.allOf))n.push(vi(e.allOf.map((a)=>M(a,t,o,r+1))));if(n.length>0){let a=vi(n);return e.nullable===!0?ke([a,\"null\"]):a}let s=(Array.isArray(e.type)?e.type.filter((a)=>typeof a===\"string\"):typeof e.type===\"string\"?[e.type]:ru(e)).map((a)=>eu(a,e,t,o,r+1));if(e.nullable===!0)s.push(\"null\");return ke(s.length>0?s:[\"unknown\"])}function eu(e,t,o,r,n){if(e===\"null\"||e===\"boolean\"||e===\"string\")return e;if(e===\"integer\"||e===\"number\")return\"number\";if(e===\"array\")return tu(t,o,r,n);if(e!==\"object\")return\"unknown\";return ou(t,o,r,n)}function tu(e,t,o,r){if(Array.isArray(e.prefixItems)){let i=e.prefixItems.map((a)=>M(a,t,o,r+1));if(e.items===!1)return`readonly [${i.join(\", \")}]`;let s=e.items===void 0||e.items===!0?\"unknown\":M(e.items,t,o,r+1);return`readonly [${i.join(\", \")}${i.length>0?\", \":\"\"}...${s}[]]`}return`readonly (${e.items===void 0||e.items===!0?\"unknown\":M(e.items,t,o,r+1)})[]`}function ou(e,t,o,r){let n=se(e.properties)?e.properties:{},i=new Set(Array.isArray(e.required)?e.required.filter((c)=>typeof c===\"string\"):[]),s=Object.entries(n).sort(([c],[u])=>pe(c,u)),a=s.map(([c,u])=>`readonly ${Kt(c)}${i.has(c)?\"\":\"?\"}: ${M(u,t,o,r+1)}`);for(let c of[...i].filter((u)=>!Object.hasOwn(n,u)).sort(pe))a.push(`readonly ${Kt(c)}: unknown`);if(e.additionalProperties!==!1){if(s.length===0&&e.additionalProperties!==void 0&&e.additionalProperties!==!0)return`Readonly<Record<string, ${M(e.additionalProperties,t,o,r+1)}>>`;a.push(\"readonly [key: string]: unknown\")}return a.length===0?\"Record<string, never>\":`{ ${a.join(\"; \")} }`}function ru(e){if(se(e.properties)||Object.hasOwn(e,\"additionalProperties\"))return[\"object\"];if(Object.hasOwn(e,\"items\")||Array.isArray(e.prefixItems))return[\"array\"];return[]}function nu(e,t){let o=e;for(let r of t.slice(2).split(\"/\")){if(!se(o))return;let n=r.replace(/~1/gu,\"/\").replace(/~0/gu,\"~\");if(!Object.hasOwn(o,n))return;o=o[n]}return o}function Ye(e){if(e===null||typeof e===\"string\"||typeof e===\"number\"||typeof e===\"boolean\")return JSON.stringify(e);if(Array.isArray(e))return`readonly [${e.map(Ye).join(\", \")}]`;if(se(e))return`{ ${Object.entries(e).sort(([t],[o])=>pe(t,o)).map(([t,o])=>`readonly ${Kt(t)}: ${Ye(o)}`).join(\"; \")} }`;return\"unknown\"}function ke(e){let t=[...new Set(e)];if(t.includes(\"unknown\"))return\"unknown\";if(t.length===0)return\"never\";return t.length===1?t[0]:t.map(ki).join(\" | \")}function vi(e){let t=[...new Set(e.filter((o)=>o!==\"unknown\"))];return t.length===0?\"unknown\":t.length===1?t[0]:t.map(ki).join(\" & \")}function ki(e){return/[|&]/u.test(e)?`(${e})`:e}function Kt(e){return/^[A-Za-z_$][A-Za-z0-9_$]*$/u.test(e)?e:JSON.stringify(e)}function su(e){if(!e)return null;let t=e.replace(/\\s+/gu,\" \").trim().replace(/\\*\\//gu,\"*\\\\/\");if(!t)return null;return t.length<=512?t:`${t.slice(0,509)}...`}function iu(e,t){return[`${ne(t)}/** ${e} */`]}function ne(e){return\" \".repeat(e)}function se(e){return e!==null&&typeof e===\"object\"&&!Array.isArray(e)}var Z=require(\"node:fs/promises\"),Qe=require(\"node:os\"),V=require(\"node:path\"),Ai=16777216,au=\"opengeni-codemode-image-\",cu=86400000,uu=3600000,Ei=0;async function et(e,t={}){let o=e.content.filter((a)=>a.type===\"image\");if(t.requireOne&&o.length!==1)throw Error(\"Codemode browser screenshot must return exactly one image block\");if(o.length===0)return[];if(t.saveTo!==void 0&&o.length!==1)throw Error(\"An explicit image path requires exactly one image block\");let r=0,n=o.map((a)=>{let c=pu(a.mimeType);if(r+=a.data.length,a.data.length===0||a.data.length>Ai||r>Ai)throw Error(\"Codemode image exceeds the Code Mode result limit\");let u=Buffer.from(a.data,\"base64\");if(u.length===0||u.toString(\"base64\")!==a.data||!du(u,c))throw Error(\"Codemode image bytes are invalid\");return{bytes:u,mimeType:c}}),i;if(t.saveTo===void 0)await lu(),i=await Z.mkdtemp(V.join(Qe.tmpdir(),au));else{if(t.saveTo.length===0)throw TypeError(\"Image saveTo must be a nonempty path\");await Z.mkdir(V.dirname(V.resolve(t.saveTo)),{recursive:!0})}let s=[];try{for(let[a,c]of n.entries()){let u=c.mimeType===\"image/jpeg\"?\"jpg\":c.mimeType.split(\"/\")[1],p=t.saveTo===void 0?V.join(i,n.length===1?`frame.${u}`:`image-${a+1}.${u}`):V.resolve(t.saveTo);await Z.writeFile(p,c.bytes,{flag:\"wx\",mode:384}),s.push({path:p,mimeType:c.mimeType,sizeBytes:c.bytes.length})}}catch(a){if(i)await Z.rm(i,{recursive:!0,force:!0});throw a}return s}async function lu(){let e=Date.now();if(e-Ei<uu)return;if(Ei=e,typeof process.getuid!==\"function\")return;try{let t=0;for(let o of await Z.readdir(Qe.tmpdir(),{withFileTypes:!0})){if(!o.isDirectory()||!/^opengeni-codemode-image-[A-Za-z0-9]{6}$/u.test(o.name))continue;let r=V.join(Qe.tmpdir(),o.name),n=await Z.lstat(r);if(!n.isDirectory()||n.uid!==process.getuid()||(n.mode&63)!==0||e-n.mtimeMs<cu)continue;if(await Z.rm(r,{recursive:!0,force:!0}),++t>=64)break}}catch{}}function pu(e){if(e===\"image/png\"||e===\"image/jpeg\"||e===\"image/webp\")return e;throw Error(`Codemode image has unsupported type: ${e}`)}function du(e,t){switch(t){case\"image/png\":return e.length>=8&&e.subarray(0,8).equals(Buffer.from(\"89504e470d0a1a0a\",\"hex\"));case\"image/jpeg\":return e.length>=3&&e[0]===255&&e[1]===216&&e[2]===255;case\"image/webp\":return e.length>=12&&e.toString(\"ascii\",0,4)===\"RIFF\"&&e.toString(\"ascii\",8,12)===\"WEBP\"}}function Si(e,t={}){let o=tt(e);return zi({digest:o.digest,entries:o.entries},{moduleSpecifier:t.moduleSpecifier??\"@opengeni/codemode\",interfaceName:\"CodemodeGeneratedTools\",callOptionsType:\"CodemodeCallOptions\",fallbackResultType:\"CodemodeToolResult\",typedResultWrapperType:\"CodemodeMultimodalValue\",generatedBy:\"@opengeni/codemode via @opengeni/tool-gateway\",catalogDigestLabel:\"Attempt catalog digest\"})}class L extends Error{status;code=\"codemode_transport_error\";remoteCode;retryable;outcomeUnknown;details;constructor(e,t=null,o={}){super(e);this.status=t;this.name=\"CodemodeTransportError\",this.remoteCode=o.code??null,this.retryable=o.retryable??null,this.outcomeUnknown=o.outcomeUnknown??null,this.details=o.details??null}}class Ae extends Error{operation;code;constructor(e,t){super(e.errorMessage??`Codemode operation ${e.state}`);this.operation=e;this.code=t;this.name=\"CodemodeOperationError\",Object.defineProperty(this,\"operation\",{value:e,enumerable:!1})}}class Ee extends Error{operationId;approvalRequestId;code=\"codemode_approval_pending\";state=\"waiting_for_approval\";constructor(e,t){super(`Operation ${e} is waiting for approval. After review, read or resume this handle; do not submit its arguments again.`);this.operationId=e;this.approvalRequestId=t;this.name=\"CodemodeApprovalPendingError\"}}class Ii extends Error{result;code;retryable;constructor(e){let t=wu(e);super(t.message);this.result=e;this.name=\"CodemodeToolCallError\",this.code=t.code,this.retryable=t.retryable}}class Zi extends Error{code=\"invalid_tool_result\";constructor(e){super(e);this.name=\"CodemodeToolContractError\"}}class Yt{options;baseUrl;fetchImpl;pollIntervalMs;timeoutMs;catalogSnapshot=null;constructor(e){this.options=e;if(this.baseUrl=e.baseUrl.replace(/\\/+$/u,\"\"),!/^https?:\\/\\//u.test(this.baseUrl))throw Error(\"Codemode baseUrl must be an absolute HTTP(S) URL\");this.fetchImpl=e.fetch??globalThis.fetch.bind(globalThis),this.pollIntervalMs=ot(e.pollIntervalMs??500,50,30000),this.timeoutMs=ot(e.timeoutMs??600000,1000,3600000)}async catalog(e={}){if(this.catalogSnapshot&&!e.refresh)return this.catalogSnapshot;let t=await this.request(\"/catalog\",{method:\"GET\",...e.signal?{signal:e.signal}:{}}),o=tt(await t.json());return this.catalogSnapshot=o,o}async tools(e={}){return hu(await this.catalog(e),this)}async call(e,t={},o={}){return(await this.callResolved((r)=>r.entries.find((n)=>n.identity.serverId===e.serverId&&n.identity.toolName===e.toolName)??null,t,o)).result}async callResolved(e,t,o){let r=await this.catalog(o.signal?{signal:o.signal}:{}),n=e(r);if(!n)throw new le;let i=()=>{if(o.expectedDefinitionDigest!==void 0&&o.expectedDefinitionDigest!==bi(r,n))throw new L(\"The tool definition changed before execution\",409,{code:\"tool_definition_stale\",retryable:!0,outcomeUnknown:!1})};i();let s=o.operationId??Pi.randomUUID(),a=Date.now()+ot(o.timeoutMs??this.timeoutMs,1000,3600000),c=!1,u=!1,p=null,d=0;while(!0){if(Ht(o.signal),Date.now()>=a)throw new L(`Codemode operation ${s} did not settle before the client deadline`);if(!c||(p?.state===\"queued\"||p?.state===\"running\")&&Date.now()>=d){c=!0,d=Date.now()+2000;try{p=await this.submit(s,r.digest,n.identity,t,o.signal)}catch(m){if(p===null&&!u&&m instanceof L&&m.outcomeUnknown!==!0&&m.retryable!==!1&&m.remoteCode===\"codemode_catalog_stale\"){if(u=!0,r=await this.catalog({refresh:!0,...o.signal?{signal:o.signal}:{}}),n=e(r),!n)throw new le;i(),c=!1,d=0;continue}if(o.signal?.aborted)throw m;if(p===null&&!mu(m))throw m;let y;try{y=await this.read(s,o.signal)}catch(G){if(o.signal?.aborted)throw G;throw new L(`Codemode operation ${s} could not be reconciled after its submission response failed`,null,{code:\"codemode_operation_recovery_unavailable\",retryable:!0,outcomeUnknown:!0,details:{operationId:s}})}fu(y,{operationId:s,catalog:r,identity:n.identity,arguments:t}),p=y}}else p=await this.read(s,o.signal);if(p.state===\"waiting_for_approval\")throw new Ee(p.operationId,p.approvalRequestId);if(p.state===\"completed\")return{result:He.parse(p.result),entry:n};if([\"failed\",\"outcome_unknown\",\"cancelled\"].includes(p.state))throw new Ae(p,p.errorCode??`codemode_${p.state}`);await Xt(this.pollIntervalMs,o.signal)}}async callPath(e,t={},o={}){if(e.length<2||e.some((r)=>r.length===0))throw new le;return(await this.callResolved((r)=>Ci(r,e),t,o)).result}async callPathValue(e,t={},o={}){if(e.length<2||e.some((s)=>s.length===0))throw new le;let{result:r,entry:n}=await this.callResolved((s)=>Ci(s,e),t,o);if(!n.outputSchema)return r;if(r.isError)throw new Ii(r);if(!r.structuredContent)throw new Zi(`Codemode tool ${e.join(\".\")} declared outputSchema but returned no structured content`);if(!r.content.some((s)=>s.type===\"image\"))return r.structuredContent;let i=await et(r);return{structuredContent:r.structuredContent,images:i,otherContent:r.content.filter((s)=>s.type!==\"image\")}}async submit(e,t,o,r,n){return await Oi(n,async()=>{let i=await this.request(\"/calls\",{method:\"POST\",...n?{signal:n}:{},headers:{\"content-type\":\"application/json\"},body:JSON.stringify({operationId:e,catalogDigest:t,identity:o,arguments:r,durableApproval:!0})});return fi.parse(await i.json()).operation})}async status(e,t){let o=await this.read(e,t);return{operationId:o.operationId,state:o.state,approvalRequestId:o.approvalRequestId,result:o.result,errorCode:o.errorCode,errorMessage:o.errorMessage}}async resume(e,t={}){let o=Date.now()+ot(t.timeoutMs??this.timeoutMs,1000,3600000);while(!0){Ht(t.signal);let r=await this.read(e,t.signal);if(r.state===\"waiting_for_approval\")throw new Ee(r.operationId,r.approvalRequestId);if(r.state===\"completed\")return He.parse(r.result);if([\"failed\",\"outcome_unknown\",\"cancelled\"].includes(r.state))throw new Ae(r,r.errorCode??`codemode_${r.state}`);if(Date.now()>=o)throw new L(`Codemode operation ${e} did not settle before the client deadline`);await Xt(this.pollIntervalMs,t.signal)}}async read(e,t){return await Oi(t,async()=>{let o=await this.request(`/calls/${e}`,{method:\"GET\",...t?{signal:t}:{}});return Ft.parse(await o.json())})}async sessionRequest(e,t){return _i(e,\"site-host\"),this.request(`/sdk${e}`,t,!1)}async request(e,t,o=!0){let r=typeof this.options.token===\"function\"?await this.options.token():this.options.token,n=await this.fetchImpl(`${this.baseUrl}${e}`,{...t,headers:{...Object.fromEntries(new Headers(t.headers).entries()),authorization:`Bearer ${r}`,\"x-opengeni-codemode-capabilities\":\"durable-approval-v1\"}});if(!n.ok&&o){let i=`Codemode request failed with HTTP ${n.status}`,s={};try{let a=bu(await n.json());if(a?.message)i=a.message;if(a)s={...a.code?{code:a.code}:{},...a.retryable===void 0?{}:{retryable:a.retryable},...a.outcomeUnknown===void 0?{}:{outcomeUnknown:a.outcomeUnknown},...a.details?{details:a.details}:{}}}catch{}throw new L(i,n.status,s)}return n}}function mu(e){return!(e instanceof L)||e.outcomeUnknown===!0}function fu(e,t){if(e.operationId===t.operationId&&e.accountId===t.catalog.accountId&&e.workspaceId===t.catalog.workspaceId&&e.sessionId===t.catalog.sessionId&&e.turnId===t.catalog.turnId&&e.attemptId===t.catalog.attemptId&&e.executionGeneration===t.catalog.executionGeneration&&e.catalogDigest===t.catalog.digest&&e.identity.serverId===t.identity.serverId&&e.identity.toolName===t.identity.toolName&&Te(e.arguments)===Te(t.arguments))return;throw new L(\"Codemode operation id is already bound to a different request\",409,{code:\"codemode_operation_conflict\",retryable:!1,outcomeUnknown:!1})}function hu(e,t){let o=tt(e),r=Object.create(null);for(let n of o.entries){let i=r;for(let c of n.codemodePath.slice(0,-1)){let u=i[c];if(typeof u===\"function\")throw Error(\"Codemode path collides with a tool\");if(!u)u=Object.create(null),i[c]=u;i=u}let s=n.codemodePath.at(-1),a=async(c={},u={})=>await t.callPathValue(n.codemodePath,c,u);Object.defineProperty(a,\"entry\",{value:n,enumerable:!1}),i[s]=a}return r}function gu(e){let{createdAt:t,...o}=e;return Te(o)}function tt(e){return _u(e).catalog}var yu=new WeakMap;function _u(e){if(e!==null&&typeof e===\"object\"){let i=yu.get(e);if(i)return{...i}}let t=di.parse(e),o=xu(t),{digest:r,...n}=t;if(gu(n)!==r)throw new Jt;return{catalog:t,byteLength:o}}function xu(e){let t=new TextEncoder().encode(JSON.stringify(e)).byteLength;if(t>ci)throw new qt;return t}function ot(e,t,o){if(!Number.isFinite(e))return t;return Math.max(t,Math.min(o,Math.floor(e)))}function Ht(e){if(e?.aborted)throw e.reason??new DOMException(\"Aborted\",\"AbortError\")}function wu(e){let o=e.structuredContent?.error;return{code:typeof o?.code===\"string\"?o.code:\"tool_error\",message:typeof o?.message===\"string\"?o.message:\"Codemode tool failed\",retryable:o?.retryable===!0}}function Ci(e,t){let o=e.entries.filter((r)=>r.codemodePath.length===t.length&&r.codemodePath.every((n,i)=>n===t[i]));return o.length===1?o[0]:null}function bu(e){if(!e||typeof e!==\"object\"||Array.isArray(e))return null;let t=e,o=t.error&&typeof t.error===\"object\"&&!Array.isArray(t.error)?t.error:t,r=o.details&&typeof o.details===\"object\"&&!Array.isArray(o.details)?o.details:void 0,n=r?.code,i=typeof n===\"string\"&&/^[a-z0-9_]{1,128}$/u.test(n)?n:void 0,s=typeof o.message===\"string\"?o.message:void 0,a=typeof o.retryable===\"boolean\"?o.retryable:void 0,c=typeof o.outcomeUnknown===\"boolean\"?o.outcomeUnknown:void 0;return s||i||a!==void 0||c!==void 0||r?{...s?{message:s}:{},...i?{code:i}:{},...a===void 0?{}:{retryable:a},...c===void 0?{}:{outcomeUnknown:c},...r?{details:r}:{}}:null}var vu=[100,250,500,1000,2000];function zu(e){return e instanceof L&&e.status!==null&&e.status>=500&&e.retryable===!0&&e.outcomeUnknown!==!0}async function Oi(e,t){for(let o=0;;o+=1)try{return await t()}catch(r){let n=vu[o];if(n===void 0||e?.aborted||!zu(r))throw r;await Xt(n+Math.floor(Math.random()*n),e)}}async function Xt(e,t){if(!t){await new Promise((o)=>setTimeout(o,e));return}Ht(t),await new Promise((o,r)=>{let n=setTimeout(()=>{t.removeEventListener(\"abort\",i),o()},e),i=()=>{clearTimeout(n),r(t.reason??new DOMException(\"Aborted\",\"AbortError\"))};t.addEventListener(\"abort\",i,{once:!0})})}var Ri={name:\"@opengeni/ogtool\",version:\"4.6.1\",description:\"Codemode CLI and typed client entrypoint for an Opengeni execution attempt.\",license:\"Apache-2.0\",repository:{type:\"git\",url:\"git+https://github.com/Cloudgeni-ai/opengeni.git\",directory:\"packages/ogtool\"},bin:{ogtool:\"./dist/bin/ogtool.cjs\"},files:[\"dist\",\"src\"],type:\"module\",sideEffects:!1,main:\"./src/index.ts\",module:\"./src/index.ts\",types:\"./src/index.ts\",exports:{\".\":{types:\"./src/index.ts\",default:\"./src/index.ts\"}},publishConfig:{access:\"public\",provenance:!0},scripts:{typecheck:\"tsrs --noEmit\",test:\"bun test\",build:\"bun build.ts\",prepublishOnly:\"bash ../../scripts/prepublish-guard\"},dependencies:{\"@opengeni/codemode\":\"workspace:*\",\"@opengeni/contracts\":\"workspace:*\"},devDependencies:{tsup:\"^8.5.0\",typescript:\"7.0.2\"},engines:{node:\">=18\"}};function Ni(e){return(e.description||e.title||\"\").split(/\\p{White_Space}+/u).filter(Boolean).join(\" \")}function Tu(e){let t=Ni(e),o=Array.from(t);return o.length<=160?t:`${o.slice(0,159).join(\"\")}…`}function ku(e){return e.replace(/[\\u0000-\\u001f\\u007f-\\u009f]/gu,(t)=>`\\\\u${t.charCodeAt(0).toString(16).padStart(4,\"0\")}`)}function ji(e){let t={full:!1,json:!1,query:\"\",offset:0},o=new Set,r=()=>Error(\"usage: ogtool list [--full | --json] [--query <substring>] [--limit <1..100>] [--offset <nonnegative integer>]\");for(let n=0;n<e.length;n++){let i=e[n],s=i.indexOf(\"=\"),a=s<0?i:i.slice(0,s);if(o.has(a))throw r();if(o.add(a),a===\"--full\"||a===\"--json\"){if(s>=0)throw r();t[a===\"--full\"?\"full\":\"json\"]=!0}else if(a===\"--query\"||a===\"--limit\"||a===\"--offset\"){let c=s<0?e[++n]:i.slice(s+1);if(c===void 0||s<0&&c.startsWith(\"-\"))throw r();if(a===\"--query\")t.query=c;else{if(!/^[0-9]+$/u.test(c)||!Number.isSafeInteger(Number(c)))throw r();let u=Number(c);if(a===\"--limit\"&&(u<1||u>100))throw r();t[a===\"--limit\"?\"limit\":\"offset\"]=u}}else throw r()}if(t.full&&o.size!==1)throw r();return t}function Di(e,t){let o=e.entries.filter((c)=>c.codemodePath.join(\".\").includes(t.query)||Ni(c).includes(t.query)),r=o.slice(t.offset,t.limit===void 0?void 0:t.offset+t.limit).map((c)=>({path:c.codemodePath.join(\".\"),description:Tu(c)})),n=t.json?[]:r.map((c)=>`${c.path}${c.description?` — ${ku(c.description)}`:\"\"}\n`),i=t.offset+r.length<o.length?t.offset+r.length:null,s={catalogDigest:e.digest,total:o.length,offset:t.offset,nextOffset:i,tools:r};return t.json?`${JSON.stringify(s)}\n`:n.join(\"\")+`# total: ${s.total}; offset: ${s.offset}; nextOffset: ${i??\"none\"}\n`+(i===null?\"\":`# Continue with --offset ${i} (keep the same --query and --limit).\n`)}var Au=/(?<!\\\\)\\\\(\\{\\{secret(?:file)?:)/gu;function Mi(e){if(e===void 0)return{};let t;try{t=JSON.parse(e)}catch{let o=e.replace(Au,\"$1\");try{if(o===e)throw Error(\"unchanged\");t=JSON.parse(o)}catch{throw Error(e.includes(\"{{secret\")?\"tool arguments must be valid JSON; inside `ogtool call` write a reference as \\\\{{secret:…}} with one backslash\":\"tool arguments must be valid JSON\")}}if(!t||typeof t!==\"object\"||Array.isArray(t))throw Error(\"tool arguments must be a JSON object\");return t}var Eu=\"@opengeni/ogtool\",Gi=Ri.version;function rt(e=1){let t=[\"usage:\",\" ogtool list [--full | --json]\",\" [--query <substring>] [--limit <1..100>] [--offset <nonnegative integer>]\",\" ogtool show <tool-path-or-model-name>\",\" ogtool call <tool-path-or-model-name> [json-object] [--full] [--save-image <path>]\",\" ogtool read <operation-id>\",\" ogtool resume <operation-id>\",\" ogtool declarations [output-file]\",\" ogtool doctor\",\" ogtool --version\",\"\",\"list returns all authorized tools by default; --limit/--offset are opt-in slices\",\"call omits a text block that only repeats structuredContent; --full prints the exact result\",\"call writes images (such as screenshots) to files and prints their paths instead of base64;\",\" --save-image saves the result's single image at that path and never overwrites\",\" if the call completes but its image cannot be saved, the result is still printed\",\" with imageSaveError and the exit code is 4; do not repeat that call\",\"\",\"requires OPENGENI_CODEMODE_URL and OPENGENI_CODEMODE_TOKEN or OPENGENI_CODEMODE_TOKEN_FILE\"].join(`\n`);(e===0?process.stdout:process.stderr).write(`${t}\n`),process.exitCode=e}function Su(){let e=process.env.OPENGENI_CODEMODE_URL?.trim(),t=process.env.OPENGENI_CODEMODE_TOKEN!==void 0,o=process.env.OPENGENI_CODEMODE_TOKEN_FILE?.trim();if(!e)throw Error(\"OPENGENI_CODEMODE_URL is required\");if(!t&&!o)throw Error(\"OPENGENI_CODEMODE_TOKEN or OPENGENI_CODEMODE_TOKEN_FILE is required\");return new Yt({baseUrl:e,token:t?async()=>Cu():async()=>Ou(o)})}function Cu(){let e=process.env.OPENGENI_CODEMODE_TOKEN?.trim();if(!e)throw Error(\"OPENGENI_CODEMODE_TOKEN is empty\");return e}function Ou(e){let t;try{t=P.readFileSync(e,\"utf8\").trim()}catch{throw Error(\"OPENGENI_CODEMODE_TOKEN_FILE is not readable\")}if(!t)throw Error(\"OPENGENI_CODEMODE_TOKEN_FILE is empty\");return t}function Pu(){let e=process.env.OPENGENI_CODEMODE_TOKEN,t=e!==void 0,o=Boolean(e?.trim().length),r=process.env.OPENGENI_CODEMODE_TOKEN_FILE??null,n=process.env.OPENGENI_CODEMODE_URL??null,i=!1,s=null;if(n)try{s=new URL(n).protocol,i=s===\"http:\"||s===\"https:\"}catch{i=!1}let a=!1,c=!1;if(r)try{a=P.statSync(r).isFile(),c=a&&P.readFileSync(r,\"utf8\").trim().length>0}catch{a=!1}let u=t?\"environment\":r?\"file\":null,d=i&&(t?o:c);process.stdout.write(`${JSON.stringify({ok:d,package:Eu,version:Gi,node:process.version,urlConfigured:n!==null,urlValid:i,protocol:s,tokenMode:u,directTokenConfigured:t,directTokenNonempty:o,tokenFileConfigured:r!==null,tokenFileReadable:a,tokenFileNonempty:c,packageSpec:process.env.OPENGENI_OGTOOL_PACKAGE_SPEC??null},null,2)}\n`),process.exitCode=d?0:1}function Qt(e,t){let o=e.entries.filter((r)=>r.modelName===t||r.codemodePath.join(\".\")===t||`${r.identity.serverId}.${r.identity.toolName}`===t);if(o.length!==1)throw Error(o.length===0?`Unknown Codemode tool: ${t}`:`Ambiguous tool: ${t}`);return o[0]}function eo(e){return{catalogDigest:e.digest,attemptId:e.attemptId,tools:e.entries.map((t)=>({name:t.modelName,path:t.codemodePath.join(\".\"),identity:t.identity,...t.title?{title:t.title}:{},...t.description?{description:t.description}:{},inputSchema:t.inputSchema,...t.outputSchema?{outputSchema:t.outputSchema}:{},...t.annotations?{annotations:t.annotations}:{},approval:t.approval,source:t.source}))}}function Fi(e,t){let o=Qt(e,t),r=eo({...e,entries:[o]});return`${JSON.stringify(r.tools[0],null,2)}\n`}function to(e,t=!1){let o=t?e:xi(e);return`${JSON.stringify(o,null,2)}\n`}async function oo(e,t={}){if(t.full&&t.saveTo===void 0)return e;let o=await et(e,{...t.saveTo===void 0?{}:{saveTo:t.saveTo}});if(t.saveTo!==void 0&&o.length!==1)throw Error(\"--save-image needs a result with exactly one image\");if(t.full||o.length===0)return e;let r=0;return{...e,content:e.content.map((n)=>{if(n.type!==\"image\")return n;let i=o[r++];return{type:\"image\",mimeType:i.mimeType,path:i.path,sizeBytes:i.sizeBytes}})}}function Ui(e){let t=Se.resolve(e),o=!0;try{P.lstatSync(t)}catch(r){if(r.code!==\"ENOENT\")throw r;o=!1}if(o)throw Error(`--save-image ${t} already exists; choose a new path (nothing was called)`);P.mkdirSync(Se.dirname(t),{recursive:!0}),P.accessSync(Se.dirname(t),P.constants.W_OK)}async function Vi(e,t,o,r){let n=e;if(!r)try{n=await oo(e)}catch{n=e}return to({...n,imageSaveError:{operationId:o,message:t instanceof Error?t.message:String(t),note:\"The call completed; only saving its image failed. Do not repeat the call.\"}},r)}function Iu(e){let t=!1,o,r=[];for(let n=0;n<e.length;n+=1){let i=e[n];if(i===\"--full\")t=!0;else if(i===\"--save-image\"){let s=e[++n];if(!s)throw Error(\"--save-image requires a path\");o=s}else if(i.startsWith(\"--save-image=\")){if(o=i.slice(13),!o)throw Error(\"--save-image requires a path\")}else r.push(i)}return{full:t,...o===void 0?{}:{saveTo:o},rest:r}}async function Zu(){let e=process.argv[2];if(e===\"--help\"||e===\"-h\"||e===\"help\")return rt(0);if(e===\"--version\"||e===\"-V\"||e===\"version\"){process.stdout.write(`${Gi}\n`);return}if(e===\"doctor\")return Pu();if(!e)return rt();let t=process.argv.slice(3);if((e===\"list\"||e===\"show\")&&t.length===1&&(t[0]===\"--help\"||t[0]===\"-h\"))return rt(0);let o=e===\"list\"?ji(t):null;if(e===\"show\"&&(t.length!==1||!t[0]||t[0].startsWith(\"-\")))throw Error(\"usage: ogtool show <tool-path-or-model-name>\");let r=Su();if(e===\"read\"||e===\"resume\"){if(t.length!==1||!/^[0-9a-f-]{36}$/iu.test(t[0]))throw Error(\"A valid operation ID is required\");let n=e===\"read\"?await r.status(t[0]):await r.resume(t[0]);process.stdout.write(`${JSON.stringify(n,null,2)}\n`);return}if(e===\"list\"){let n=await r.catalog();if(o.full)process.stdout.write(`${JSON.stringify(eo(n),null,2)}\n`);else process.stdout.write(Di(n,o));return}if(e===\"show\"){process.stdout.write(Fi(await r.catalog(),t[0]));return}if(e===\"call\"){let{full:n,saveTo:i,rest:s}=Iu(t),[a,c]=s;if(!a)throw Error(\"tool path or model name is required\");let u=Mi(c),p=await r.catalog(),d=Qt(p,a);if(i!==void 0)Ui(i);let h=Li.randomUUID(),m=await r.call(d.identity,u,{operationId:h}),y;try{y=await oo(m,{full:n,...i===void 0?{}:{saveTo:i}})}catch(G){process.stdout.write(await Vi(m,G,h,n)),process.exitCode=4;return}process.stdout.write(to(y,n));return}if(e===\"declarations\"){let n=await r.catalog(),i=Si(n),s=process.argv[3];if(!s||s===\"-\")process.stdout.write(i);else P.writeFileSync(s,i,{encoding:\"utf8\",mode:384}),process.stdout.write(`${JSON.stringify({catalogDigest:n.digest,output:s},null,2)}\n`);return}return rt()}Zu().catch((e)=>{if(e instanceof Ee){process.stdout.write(`${JSON.stringify({operationId:e.operationId,state:e.state,code:e.code,approvalRequestId:e.approvalRequestId,message:e.message})}\n`),process.exitCode=2;return}if(e instanceof Ae){process.stdout.write(`${JSON.stringify({operationId:e.operation.operationId,state:e.operation.state,code:e.code,message:e.message})}\n`),process.exitCode=e.operation.state===\"outcome_unknown\"?3:1;return}let t=e&&typeof e===\"object\"&&\"code\"in e?String(e.code):null;process.stderr.write(`${e instanceof Error?e.message:String(e)}\n`),process.exitCode=t===\"tool_outcome_unknown\"?3:1});\n","client.mjs":"import{createRequire as IT}from\"node:module\";var bT=Object.create;var{getPrototypeOf:vT,defineProperty:Ou,getOwnPropertyNames:_T}=Object;var $u=Object.prototype.hasOwnProperty;function wT(e){return this[e]}var xT,ST,ho=(e,t,n)=>{var r=e!=null&&typeof e===\"object\";if(r){var o=t?xT??=new WeakMap:ST??=new WeakMap,s=o.get(e);if(s)return s}n=e!=null?bT(vT(e)):{};let i=t||!e||!e.__esModule||!$u.call(e,\"default\")?Ou(n,\"default\",{value:e,enumerable:!0}):n;if(e&&typeof e===\"object\"||typeof e===\"function\"){for(let a of _T(e))if(!$u.call(i,a))Ou(i,a,{get:wT.bind(e,a),enumerable:!0})}if(r)o.set(e,i);return i};var g=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var _e=IT(import.meta.url);var et=g(function(xE){xE.getValueAsString=function(t){if(Number.isNaN(t))return\"Nan\";else if(!Number.isFinite(t))if(t<0)return\"-Inf\";else return\"+Inf\";else return`${t}`};xE.removeLabels=function(t,n,r){let o=Sa(n,r);delete t[o]};xE.setValue=function(t,n,r){let o=Sa(r);return t[o]={value:typeof n===\"number\"?n:0,labels:r||{}},t};xE.setValueDelta=function(t,n,r,o=\"\"){let s=typeof n===\"number\"?n:0;if(t[o])t[o].value+=s;else t[o]={value:s,labels:r};return t};xE.getLabels=function(e,t){if(typeof t[0]===\"object\")return t[0];if(e.length!==t.length)throw Error(`Invalid number of arguments (${t.length}): \"${t.join(\", \")}\" for label names (${e.length}): \"${e.join(\", \")}\".`);let n={};for(let r=0;r<e.length;r++)n[e[r]]=t[r];return n};function Og(e,t){if(e.length===0)return\"\";let n=\"\";for(let r=0;r<e.length;r++){let o=e[r],s=t[o];if(s===void 0)continue;n+=`${o}:${s},`}return n}function Sa(e,t){if(t)return Og(t,e);let n=Object.keys(e);if(n.length>1)n.sort();return Og(n,e)}xE.hashObject=Sa;xE.isObject=function(t){return t!==null&&typeof t===\"object\"};xE.nowTimestamp=function(){return Date.now()/1000};class $g extends Map{add(e,t){if(this.has(e))this.get(e).push(t);else this.set(e,[t])}}xE.Grouper=$g});var Nn=g(function(TW,Ra){var{getValueAsString:Mg}=et();class He{static get PROMETHEUS_CONTENT_TYPE(){return\"text/plain; version=0.0.4; charset=utf-8\"}static get OPENMETRICS_CONTENT_TYPE(){return\"application/openmetrics-text; version=1.0.0; charset=utf-8\"}constructor(e=He.PROMETHEUS_CONTENT_TYPE){if(this._metrics={},this._collectors=[],this._defaultLabels={},e!==He.PROMETHEUS_CONTENT_TYPE&&e!==He.OPENMETRICS_CONTENT_TYPE)throw TypeError(`Content type ${e} is unsupported`);this._contentType=e}getMetricsAsArray(){return Object.values(this._metrics)}async getMetricsAsString(e){let t=typeof e.getForPromString===\"function\"?await e.getForPromString():await e.get(),n=ka(t.name),r=`# HELP ${n} ${ka(t.help)}`,o=`# TYPE ${n} ${t.type}`,s=[r,o],i=Object.keys(this._defaultLabels).length>0?this._defaultLabels:null,a=this.contentType===He.OPENMETRICS_CONTENT_TYPE;for(let c of t.values||[]){let{metricName:l=n,labels:u={}}=c,{sharedLabels:p={}}=c;if(a&&t.type===\"counter\")l=`${l}_total`;if(i)u={...u,...i,...u};let m=Ia(u,p),d=OE(p),f=[...m,d].filter(Boolean),h=f.length?`{${f.join(\",\")}}`:\"\",y=`${l}${h} ${Mg(c.value)}`,{exemplar:_}=c;if(_&&a){let E=Ia(_.labelSet);y+=` # {${E.join(\",\")}} ${Mg(_.value)} ${_.timestamp}`}s.push(y)}return s.join(`\n`)}async metrics(){let e=this.contentType===He.OPENMETRICS_CONTENT_TYPE,t=this.getMetricsAsArray().map((r)=>{if(e&&r.type===\"counter\")r.name=ME(r.name);return this.getMetricsAsString(r)}),n=await Promise.all(t);return e?`${n.join(`\n`)}\n# EOF\n`:`${n.join(`\n\n`)}\n`}registerMetric(e){if(this._metrics[e.name]&&this._metrics[e.name]!==e)throw Error(`A metric with the name ${e.name} has already been registered.`);this._metrics[e.name]=e}clear(){this._metrics={},this._defaultLabels={}}async getMetricsAsJSON(){let e=[],t=Object.keys(this._defaultLabels),n=[];for(let o of this.getMetricsAsArray())n.push(o.get());let r=await Promise.all(n);for(let o of r){if(o.values&&t.length>0)for(let s of o.values){s.labels=Object.assign({},s.labels);for(let i of t)s.labels[i]=s.labels[i]||this._defaultLabels[i]}e.push(o)}return e}removeSingleMetric(e){delete this._metrics[e]}getSingleMetricAsString(e){return this.getMetricsAsString(this._metrics[e])}getSingleMetric(e){return this._metrics[e]}setDefaultLabels(e){this._defaultLabels=e}resetMetrics(){for(let e in this._metrics)this._metrics[e].reset()}get contentType(){return this._contentType}setContentType(e){if(e===He.OPENMETRICS_CONTENT_TYPE||e===He.PROMETHEUS_CONTENT_TYPE)this._contentType=e;else throw Error(`Content type ${e} is unsupported`)}static merge(e){let t=e[0].contentType;for(let o of e)if(o.contentType!==t)throw Error(\"Registers can only be merged if they have the same content type\");let n=new He(t);return e.reduce((o,s)=>o.concat(s.getMetricsAsArray()),[]).forEach(n.registerMetric,n),n}}function Ia(e,t){let{hasOwnProperty:n}=Object.prototype,r=[];for(let[o,s]of Object.entries(e))if(!t||!n.call(t,o))r.push(`${o}=\"${$E(s)}\"`);return r}var qg=new WeakMap;function OE(e){let t=qg.get(e);if(t)return t;let r=Ia(e).join(\",\");return qg.set(e,r),r}function $E(e){if(typeof e!==\"string\")return e;return ka(e).replace(/\"/g,\"\\\\\\\"\")}function ka(e){return e.replace(/\\\\/g,\"\\\\\\\\\").replace(/\\n/g,\"\\\\n\")}function ME(e){return e.replace(/_total$/,\"\")}Ra.exports=He;Ra.exports.globalRegistry=new He});var yn=g(function(jE){var zg=_e(\"util\"),qE=/^[a-zA-Z_:][a-zA-Z0-9_:]*$/,zE=/^[a-zA-Z_][a-zA-Z0-9_]*$/;jE.validateMetricName=function(e){return qE.test(e)};jE.validateLabelName=function(e=[]){return e.every((t)=>zE.test(t))};jE.validateLabel=function(t,n){for(let r in n)if(!t.includes(r))throw Error(`Added label \"${r}\" is not included in initial labelset: ${zg.inspect(t)}`)}});var Nr=g(function(CW,Ng){var Dn=Nn(),{isObject:LE}=et(),{validateMetricName:GE,validateLabelName:BE}=yn();class jg{constructor(e,t={}){if(!LE(e))throw TypeError(\"constructor expected a config object\");if(Object.assign(this,{labelNames:[],registers:[Dn.globalRegistry],aggregator:\"sum\",enableExemplars:!1},t,e),!this.registers)this.registers=[Dn.globalRegistry];if(!this.help)throw Error(\"Missing mandatory help parameter\");if(!this.name)throw Error(\"Missing mandatory name parameter\");if(!GE(this.name))throw Error(\"Invalid metric name\");if(!BE(this.labelNames))throw Error(\"Invalid label name\");if(this.collect&&typeof this.collect!==\"function\")throw Error('Optional \"collect\" parameter must be a function');if(this.labelNames)this.sortedLabelNames=[...this.labelNames].sort();else this.sortedLabelNames=[];this.reset();for(let n of this.registers){if(this.enableExemplars&&n.contentType===Dn.PROMETHEUS_CONTENT_TYPE)throw TypeError(\"Exemplars are supported only on OpenMetrics registries\");n.registerMetric(this)}}reset(){}}Ng.exports={Metric:jg}});var Ta=g(function(EW,Ug){class Dg{constructor(e={},t=null){this.labelSet=e,this.value=t}validateExemplarLabelSet(e){let t=\"\";for(let[n,r]of Object.entries(e))t+=`${n}${r}`;if(t.length>128)throw RangeError(\"Label set size must be smaller than 128 UTF-8 chars\")}}Ug.exports=Dg});var Aa=g(function(PW,Wg){var Fg=_e(\"util\"),{hashObject:VE,isObject:Lg,getLabels:Gg,removeLabels:FE,nowTimestamp:JE}=et(),{validateLabel:Bg}=yn(),{Metric:WE}=Nr(),KE=Ta();class Jg extends WE{constructor(e){super(e);if(this.type=\"counter\",this.defaultLabels={},this.defaultValue=1,this.defaultExemplarLabelSet={},e.enableExemplars)this.enableExemplars=!0,this.inc=this.incWithExemplar;else this.inc=this.incWithoutExemplar}incWithoutExemplar(e,t){let n=\"\";if(Lg(e))n=VE(e,this.sortedLabelNames),Bg(this.labelNames,e);else t=e,e={};if(t&&!Number.isFinite(t))throw TypeError(`Value is not a valid number: ${Fg.format(t)}`);if(t<0)throw Error(\"It is not possible to decrease a counter\");if(t===null||t===void 0)t=1;return Vg(this.hashMap,t,e,n),{labelHash:n}}incWithExemplar({labels:e=this.defaultLabels,value:t=this.defaultValue,exemplarLabels:n=this.defaultExemplarLabelSet}={}){let r=this.incWithoutExemplar(e,t);this.updateExemplar(n,t,r.labelHash)}updateExemplar(e,t,n){if(e===this.defaultExemplarLabelSet)return;if(!Lg(this.hashMap[n].exemplar))this.hashMap[n].exemplar=new KE;this.hashMap[n].exemplar.validateExemplarLabelSet(e),this.hashMap[n].exemplar.labelSet=e,this.hashMap[n].exemplar.value=t?t:1,this.hashMap[n].exemplar.timestamp=JE()}reset(){if(this.hashMap={},this.labelNames.length===0)Vg(this.hashMap,0)}async get(){if(this.collect){let e=this.collect();if(e instanceof Promise)await e}return{help:this.help,name:this.name,type:this.type,values:Object.values(this.hashMap),aggregator:this.aggregator}}labels(...e){let t=Gg(this.labelNames,e)||{};return{inc:this.inc.bind(this,t)}}remove(...e){let t=Gg(this.labelNames,e)||{};return Bg(this.labelNames,t),FE.call(this,this.hashMap,t,this.sortedLabelNames)}}function Vg(e,t,n={},r=\"\"){if(e[r])e[r].value+=t;else e[r]={value:t,labels:n};return e}Wg.exports=Jg});var Ae=g(function(OW,eh){var Bo=_e(\"util\"),{setValue:Zg,setValueDelta:HE,getLabels:Kg,hashObject:Yg,isObject:Xg,removeLabels:ZE}=et(),{validateLabel:Go}=yn(),{Metric:YE}=Nr();class Qg extends YE{constructor(e){super(e);this.type=\"gauge\"}set(e,t){t=Ea(e,t),e=Ca(e),XE(this,e,t)}reset(){if(this.hashMap={},this.labelNames.length===0)Zg(this.hashMap,0,{})}inc(e,t){if(t=Ea(e,t),e=Ca(e),t===void 0)t=1;Hg(this,e,t)}dec(e,t){if(t=Ea(e,t),e=Ca(e),t===void 0)t=1;Hg(this,e,-t)}setToCurrentTime(e){let t=Date.now()/1000;if(e===void 0)this.set(t);else this.set(e,t)}startTimer(e){let t=process.hrtime();return(n)=>{let r=process.hrtime(t),o=r[0]+r[1]/1e9;return this.set(Object.assign({},e,n),o),o}}async get(){if(this.collect){let e=this.collect();if(e instanceof Promise)await e}return{help:this.help,name:this.name,type:this.type,values:Object.values(this.hashMap),aggregator:this.aggregator}}_getValue(e){let t=Yg(e||{},this.sortedLabelNames);return this.hashMap[t]?this.hashMap[t].value:0}labels(...e){let t=Kg(this.labelNames,e);return Go(this.labelNames,t),{inc:this.inc.bind(this,t),dec:this.dec.bind(this,t),set:this.set.bind(this,t),setToCurrentTime:this.setToCurrentTime.bind(this,t),startTimer:this.startTimer.bind(this,t)}}remove(...e){let t=Kg(this.labelNames,e);Go(this.labelNames,t),ZE.call(this,this.hashMap,t,this.sortedLabelNames)}}function XE(e,t,n){if(typeof n!==\"number\")throw TypeError(`Value is not a valid number: ${Bo.format(n)}`);Go(e.labelNames,t),Zg(e.hashMap,n,t)}function Hg(e,t,n){if(typeof n!==\"number\")throw TypeError(`Delta is not a valid number: ${Bo.format(n)}`);Go(e.labelNames,t);let r=Yg(t,e.sortedLabelNames);HE(e.hashMap,n,t,r)}function Ca(e){return Xg(e)?e:{}}function Ea(e,t){return Xg(e)?t:e}eh.exports=Qg});var Ma=g(function($W,ah){var rh=_e(\"util\"),{getLabels:th,hashObject:Vo,isObject:oh,removeLabels:QE,nowTimestamp:e0}=et(),{validateLabel:Oa}=yn(),{Metric:t0}=Nr(),n0=Ta();class sh extends t0{constructor(e){super(e,{buckets:[0.005,0.01,0.025,0.05,0.1,0.25,0.5,1,2.5,5,10]});this.type=\"histogram\",this.defaultLabels={},this.defaultExemplarLabelSet={},this.enableExemplars=!1;for(let t of this.labelNames)if(t===\"le\")throw Error(\"le is a reserved label keyword\");if(this.upperBounds=this.buckets,this.bucketValues=this.upperBounds.reduce((t,n)=>(t[n]=0,t),{}),e.enableExemplars)this.enableExemplars=!0,this.bucketExemplars=this.upperBounds.reduce((t,n)=>(t[n]=null,t),{}),Object.freeze(this.bucketExemplars),this.observe=this.observeWithExemplar;else this.observe=this.observeWithoutExemplar;if(Object.freeze(this.bucketValues),Object.freeze(this.upperBounds),this.labelNames.length===0)this.hashMap={[Vo({})]:$a({},this.bucketValues,this.bucketExemplars)}}observeWithoutExemplar(e,t){Pa.call(this,e===0?0:e||{})(t)}observeWithExemplar({labels:e=this.defaultLabels,value:t,exemplarLabels:n=this.defaultExemplarLabelSet}={}){Pa.call(this,e===0?0:e||{})(t),this.updateExemplar(e,t,n)}updateExemplar(e,t,n){if(Object.keys(n).length===0)return;let r=Vo(e,this.sortedLabelNames),o=ih(this.upperBounds,t),{bucketExemplars:s}=this.hashMap[r],i=s[o];if(!oh(i))i=new n0,s[o]=i;i.validateExemplarLabelSet(n),i.labelSet=n,i.value=t,i.timestamp=e0()}async get(){let e=await this.getForPromString();return e.values=e.values.map(a0),e}async getForPromString(){if(this.collect){let n=this.collect();if(n instanceof Promise)await n}let t=Object.values(this.hashMap).map(s0(this)).reduce(i0(this),[]);return{name:this.name,help:this.help,type:this.type,values:t,aggregator:this.aggregator}}reset(){this.hashMap={}}zero(e){let t=Vo(e,this.sortedLabelNames);this.hashMap[t]=$a(e,this.bucketValues,this.bucketExemplars)}startTimer(e,t){return this.enableExemplars?r0.call(this,e,t)():nh.call(this,e)()}labels(...e){let t=th(this.labelNames,e);return Oa(this.labelNames,t),{observe:Pa.call(this,t),startTimer:nh.call(this,t)}}remove(...e){let t=th(this.labelNames,e);Oa(this.labelNames,t),QE.call(this,this.hashMap,t,this.sortedLabelNames)}}function nh(e){return()=>{let t=process.hrtime();return(n)=>{let r=process.hrtime(t),o=r[0]+r[1]/1e9;return this.observe(Object.assign({},e,n),o),o}}}function r0(e,t){return()=>{let n=process.hrtime();return(r,o)=>{let s=process.hrtime(n),i=s[0]+s[1]/1e9;return this.observe({labels:Object.assign({},e,r),value:i,exemplarLabels:Object.assign({},t,o)}),i}}}function Fo(e,t,n,r,o={}){return{labels:e,sharedLabels:o,value:t,metricName:n,exemplar:r}}function ih(e,t){for(let n=0;n<e.length;n++){let r=e[n];if(t<=r)return r}return-1}function Pa(e){return(t)=>{let n=o0(e,t);if(Oa(this.labelNames,n.labels),!Number.isFinite(n.value))throw TypeError(`Value is not a valid number: ${rh.format(n.value)}`);let r=Vo(n.labels,this.sortedLabelNames),o=this.hashMap[r];if(!o)o=$a(n.labels,this.bucketValues,this.bucketExemplars);let s=ih(this.upperBounds,n.value);if(o.sum+=n.value,o.count+=1,Object.prototype.hasOwnProperty.call(o.bucketValues,s))o.bucketValues[s]+=1;this.hashMap[r]=o}}function $a(e,t,n){let r={labels:e,bucketValues:{...t},sum:0,count:0};if(n)r.bucketExemplars={...n};return r}function o0(e,t){return oh(e)?{labels:e,value:t}:{value:e,labels:{}}}function s0(e){let t=`${e.name}_bucket`;return(n)=>{let r=0;return{buckets:e.upperBounds.map((s)=>(r+=n.bucketValues[s],Fo({le:s},r,t,n.bucketExemplars?n.bucketExemplars[s]:null,n.labels))),data:n}}}function i0(e){return(t,n)=>{t.push(...n.buckets);let r={le:\"+Inf\"};return t.push(Fo(r,n.data.count,`${e.name}_bucket`,n.data.bucketExemplars?n.data.bucketExemplars[\"-1\"]:null,n.data.labels),Fo({},n.data.sum,`${e.name}_sum`,void 0,n.data.labels),Fo({},n.data.count,`${e.name}_count`,void 0,n.data.labels)),t}}function a0(e){let{sharedLabels:t,labels:n,...r}=e;for(let o of Object.keys(t))n[o]=t[o];return r.labels=n,r}ah.exports=sh});var qa=g(function(MW,ch){function Ze(){}Ze.prototype.clear=function(){this._root=null,this.size=0};Ze.prototype.find=function(e){var t=this._root;while(t!==null){var n=this._comparator(e,t.data);if(n===0)return t.data;else t=t.get_child(n>0)}return null};Ze.prototype.findIter=function(e){var t=this._root,n=this.iterator();while(t!==null){var r=this._comparator(e,t.data);if(r===0)return n._cursor=t,n;else n._ancestors.push(t),t=t.get_child(r>0)}return null};Ze.prototype.lowerBound=function(e){var t=this._root,n=this.iterator(),r=this._comparator;while(t!==null){var o=r(e,t.data);if(o===0)return n._cursor=t,n;n._ancestors.push(t),t=t.get_child(o>0)}for(var s=n._ancestors.length-1;s>=0;--s)if(t=n._ancestors[s],r(e,t.data)<0)return n._cursor=t,n._ancestors.length=s,n;return n._ancestors.length=0,n};Ze.prototype.upperBound=function(e){var t=this.lowerBound(e),n=this._comparator;while(t.data()!==null&&n(t.data(),e)===0)t.next();return t};Ze.prototype.min=function(){var e=this._root;if(e===null)return null;while(e.left!==null)e=e.left;return e.data};Ze.prototype.max=function(){var e=this._root;if(e===null)return null;while(e.right!==null)e=e.right;return e.data};Ze.prototype.iterator=function(){return new Un(this)};Ze.prototype.each=function(e){var t=this.iterator(),n;while((n=t.next())!==null)if(e(n)===!1)return};Ze.prototype.reach=function(e){var t=this.iterator(),n;while((n=t.prev())!==null)if(e(n)===!1)return};function Un(e){this._tree=e,this._ancestors=[],this._cursor=null}Un.prototype.data=function(){return this._cursor!==null?this._cursor.data:null};Un.prototype.next=function(){if(this._cursor===null){var e=this._tree._root;if(e!==null)this._minNode(e)}else if(this._cursor.right===null){var t;do if(t=this._cursor,this._ancestors.length)this._cursor=this._ancestors.pop();else{this._cursor=null;break}while(this._cursor.right===t)}else this._ancestors.push(this._cursor),this._minNode(this._cursor.right);return this._cursor!==null?this._cursor.data:null};Un.prototype.prev=function(){if(this._cursor===null){var e=this._tree._root;if(e!==null)this._maxNode(e)}else if(this._cursor.left===null){var t;do if(t=this._cursor,this._ancestors.length)this._cursor=this._ancestors.pop();else{this._cursor=null;break}while(this._cursor.left===t)}else this._ancestors.push(this._cursor),this._maxNode(this._cursor.left);return this._cursor!==null?this._cursor.data:null};Un.prototype._minNode=function(e){while(e.left!==null)this._ancestors.push(e),e=e.left;this._cursor=e};Un.prototype._maxNode=function(e){while(e.right!==null)this._ancestors.push(e),e=e.right;this._cursor=e};ch.exports=Ze});var dh=g(function(qW,uh){var c0=qa();function Ln(e){this.data=e,this.left=null,this.right=null,this.red=!0}Ln.prototype.get_child=function(e){return e?this.right:this.left};Ln.prototype.set_child=function(e,t){if(e)this.right=t;else this.left=t};function Jo(e){this._root=null,this._comparator=e,this.size=0}Jo.prototype=new c0;Jo.prototype.insert=function(e){var t=!1;if(this._root===null)this._root=new Ln(e),t=!0,this.size++;else{var n=new Ln(void 0),r=0,o=0,s=null,i=n,a=null,c=this._root;i.right=this._root;while(!0){if(c===null)c=new Ln(e),a.set_child(r,c),t=!0,this.size++;else if(Ne(c.left)&&Ne(c.right))c.red=!0,c.left.red=!1,c.right.red=!1;if(Ne(c)&&Ne(a)){var l=i.right===s;if(c===a.get_child(o))i.set_child(l,Dr(s,!o));else i.set_child(l,lh(s,!o))}var u=this._comparator(c.data,e);if(u===0)break;if(o=r,r=u<0,s!==null)i=s;s=a,a=c,c=c.get_child(r)}this._root=n.right}return this._root.red=!1,t};Jo.prototype.remove=function(e){if(this._root===null)return!1;var t=new Ln(void 0),n=t;n.right=this._root;var r=null,o=null,s=null,i=1;while(n.get_child(i)!==null){var a=i;o=r,r=n,n=n.get_child(i);var c=this._comparator(e,n.data);if(i=c>0,c===0)s=n;if(!Ne(n)&&!Ne(n.get_child(i))){if(Ne(n.get_child(!i))){var l=Dr(n,i);r.set_child(a,l),r=l}else if(!Ne(n.get_child(!i))){var u=r.get_child(!a);if(u!==null)if(!Ne(u.get_child(!a))&&!Ne(u.get_child(a)))r.red=!1,u.red=!0,n.red=!0;else{var p=o.right===r;if(Ne(u.get_child(a)))o.set_child(p,lh(r,a));else if(Ne(u.get_child(!a)))o.set_child(p,Dr(r,a));var m=o.get_child(p);m.red=!0,n.red=!0,m.left.red=!1,m.right.red=!1}}}}if(s!==null)s.data=n.data,r.set_child(r.right===n,n.get_child(n.left===null)),this.size--;if(this._root=t.right,this._root!==null)this._root.red=!1;return s!==null};function Ne(e){return e!==null&&e.red}function Dr(e,t){var n=e.get_child(!t);return e.set_child(!t,n.get_child(t)),n.set_child(t,e),e.red=!0,n.red=!1,n}function lh(e,t){return e.set_child(!t,Dr(e.get_child(!t),!t)),Dr(e,t)}uh.exports=Jo});var mh=g(function(zW,ph){var l0=qa();function Ur(e){this.data=e,this.left=null,this.right=null}Ur.prototype.get_child=function(e){return e?this.right:this.left};Ur.prototype.set_child=function(e,t){if(e)this.right=t;else this.left=t};function Wo(e){this._root=null,this._comparator=e,this.size=0}Wo.prototype=new l0;Wo.prototype.insert=function(e){if(this._root===null)return this._root=new Ur(e),this.size++,!0;var t=0,n=null,r=this._root;while(!0){if(r===null)return r=new Ur(e),n.set_child(t,r),ret=!0,this.size++,!0;if(this._comparator(r.data,e)===0)return!1;t=this._comparator(r.data,e)<0,n=r,r=r.get_child(t)}};Wo.prototype.remove=function(e){if(this._root===null)return!1;var t=new Ur(void 0),n=t;n.right=this._root;var r=null,o=null,s=1;while(n.get_child(s)!==null){r=n,n=n.get_child(s);var i=this._comparator(e,n.data);if(s=i>0,i===0)o=n}if(o!==null)return o.data=n.data,r.set_child(r.right===n,n.get_child(n.left===null)),this._root=t.right,this.size--,!0;else return!1};ph.exports=Wo});var gh=g(function(jW,fh){fh.exports={RBTree:dh(),BinTree:mh()}});var bh=g(function(NW,yh){var u0=gh().RBTree;function ie(e,t,n){this.discrete=e===!1,this.delta=e||0.01,this.K=t===void 0?25:t,this.CX=n===void 0?1.1:n,this.centroids=new u0(hh),this.nreset=0,this.reset()}ie.prototype.reset=function(){this.centroids.clear(),this.n=0,this.nreset+=1,this.last_cumulate=0};ie.prototype.size=function(){return this.centroids.size};ie.prototype.toArray=function(e){var t=[];if(e)this._cumulate(!0),this.centroids.each(function(n){t.push(n)});else this.centroids.each(function(n){t.push({mean:n.mean,n:n.n})});return t};ie.prototype.summary=function(){var e=this.discrete?\"exact \":\"approximating \",t=[e+this.n+\" samples using \"+this.size()+\" centroids\",\"min = \"+this.percentile(0),\"Q1 = \"+this.percentile(0.25),\"Q2 = \"+this.percentile(0.5),\"Q3 = \"+this.percentile(0.75),\"max = \"+this.percentile(1)];return t.join(`\n`)};function hh(e,t){return e.mean>t.mean?1:e.mean<t.mean?-1:0}function d0(e,t){return e.mean_cumn-t.mean_cumn}ie.prototype.push=function(e,t){t=t||1,e=Array.isArray(e)?e:[e];for(var n=0;n<e.length;n++)this._digest(e[n],t)};ie.prototype.push_centroid=function(e){e=Array.isArray(e)?e:[e];for(var t=0;t<e.length;t++)this._digest(e[t].mean,e[t].n)};ie.prototype._cumulate=function(e){if(this.n===this.last_cumulate||!e&&this.CX&&this.CX>this.n/this.last_cumulate)return;var t=0;this.centroids.each(function(n){n.mean_cumn=t+n.n/2,t=n.cumn=t+n.n}),this.n=this.last_cumulate=t};ie.prototype.find_nearest=function(e){if(this.size()===0)return null;var t=this.centroids.lowerBound({mean:e}),n=t.data()===null?t.prev():t.data();if(n.mean===e||this.discrete)return n;var r=t.prev();if(r&&Math.abs(r.mean-e)<Math.abs(n.mean-e))return r;else return n};ie.prototype._new_centroid=function(e,t,n){var r={mean:e,n:t,cumn:n};return this.centroids.insert(r),this.n+=t,r};ie.prototype._addweight=function(e,t,n){if(t!==e.mean)e.mean+=n*(t-e.mean)/(e.n+n);e.cumn+=n,e.mean_cumn+=n/2,e.n+=n,this.n+=n};ie.prototype._digest=function(e,t){var n=this.centroids.min(),r=this.centroids.max(),o=this.find_nearest(e);if(o&&o.mean===e)this._addweight(o,e,t);else if(o===n)this._new_centroid(e,t,0);else if(o===r)this._new_centroid(e,t,this.n);else if(this.discrete)this._new_centroid(e,t,o.cumn);else{var s=o.mean_cumn/this.n,i=Math.floor(4*this.n*this.delta*s*(1-s));if(i-o.n>=t)this._addweight(o,e,t);else this._new_centroid(e,t,o.cumn)}if(this._cumulate(!1),!this.discrete&&this.K&&this.size()>this.K/this.delta)this.compress()};ie.prototype.bound_mean=function(e){var t=this.centroids.upperBound({mean:e}),n=t.prev(),r=n.mean===e?n:t.next();return[n,r]};ie.prototype.p_rank=function(e){var t=Array.isArray(e)?e:[e],n=t.map(this._p_rank,this);return Array.isArray(e)?n:n[0]};ie.prototype._p_rank=function(e){if(this.size()===0)return;else if(e<this.centroids.min().mean)return 0;else if(e>this.centroids.max().mean)return 1;this._cumulate(!0);var t=this.bound_mean(e),n=t[0],r=t[1];if(this.discrete)return n.cumn/this.n;else{var o=n.mean_cumn;if(n!==r)o+=(e-n.mean)*(r.mean_cumn-n.mean_cumn)/(r.mean-n.mean);return o/this.n}};ie.prototype.bound_mean_cumn=function(e){this.centroids._comparator=d0;var t=this.centroids.upperBound({mean_cumn:e});this.centroids._comparator=hh;var n=t.prev(),r=n&&n.mean_cumn===e?n:t.next();return[n,r]};ie.prototype.percentile=function(e){var t=Array.isArray(e)?e:[e],n=t.map(this._percentile,this);return Array.isArray(e)?n:n[0]};ie.prototype._percentile=function(e){if(this.size()===0)return;this._cumulate(!0);var t=this.n*e,n=this.bound_mean_cumn(t),r=n[0],o=n[1];if(o===r||r===null||o===null)return(r||o).mean;else if(!this.discrete)return r.mean+(t-r.mean_cumn)*(o.mean-r.mean)/(o.mean_cumn-r.mean_cumn);else if(t<=r.cumn)return r.mean;else return o.mean};function p0(e){var t=Math.floor(Math.random()*e.length);return e.splice(t,1)[0]}ie.prototype.compress=function(){if(this.compressing)return;var e=this.toArray();this.reset(),this.compressing=!0;while(e.length>0)this.push_centroid(p0(e));this._cumulate(!0),this.compressing=!1};function $t(e){this.config=e||{},this.mode=this.config.mode||\"auto\",ie.call(this,this.mode===\"cont\"?e.delta:!1),this.digest_ratio=this.config.ratio||0.9,this.digest_thresh=this.config.thresh||1000,this.n_unique=0}$t.prototype=Object.create(ie.prototype);$t.prototype.constructor=$t;$t.prototype.push=function(e){ie.prototype.push.call(this,e),this.check_continuous()};$t.prototype._new_centroid=function(e,t,n){this.n_unique+=1,ie.prototype._new_centroid.call(this,e,t,n)};$t.prototype._addweight=function(e,t,n){if(e.n===1)this.n_unique-=1;ie.prototype._addweight.call(this,e,t,n)};$t.prototype.check_continuous=function(){if(this.mode!==\"auto\"||this.size()<this.digest_thresh)return!1;if(this.n_unique/this.size()>this.digest_ratio)return this.mode=\"cont\",this.discrete=!1,this.delta=this.config.delta||0.01,this.compress(),!0;return!1};yh.exports={TDigest:ie,Digest:$t}});var xh=g(function(DW,wh){var{TDigest:vh}=bh();class _h{constructor(e,t){this.maxAgeSeconds=e||0,this.ageBuckets=t||0,this.shouldRotate=e&&t,this.ringBuffer=Array(t).fill(new vh),this.currentBuffer=0,this.lastRotateTimestampMillis=Date.now(),this.durationBetweenRotatesMillis=e*1000/t||1/0}size(){return za.call(this).size()}percentile(e){return za.call(this).percentile(e)}push(e){za.call(this),this.ringBuffer.forEach((t)=>{t.push(e)})}reset(){this.ringBuffer.forEach((e)=>{e.reset()})}compress(){this.ringBuffer.forEach((e)=>{e.compress()})}}function za(){let e=Date.now()-this.lastRotateTimestampMillis;while(e>this.durationBetweenRotatesMillis&&this.shouldRotate){if(this.ringBuffer[this.currentBuffer]=new vh,++this.currentBuffer>=this.ringBuffer.length)this.currentBuffer=0;e-=this.durationBetweenRotatesMillis,this.lastRotateTimestampMillis+=this.durationBetweenRotatesMillis}return this.ringBuffer[this.currentBuffer]}wh.exports=_h});var Ph=g(function(UW,Eh){var Rh=_e(\"util\"),{getLabels:Sh,hashObject:Th,removeLabels:m0}=et(),{validateLabel:ja}=yn(),{Metric:f0}=Nr(),Ah=xh();class Ch extends f0{constructor(e){super(e,{percentiles:[0.01,0.05,0.5,0.9,0.95,0.99,0.999],compressCount:1000,hashMap:{}});this.type=\"summary\";for(let t of this.labelNames)if(t===\"quantile\")throw Error(\"quantile is a reserved label keyword\");if(this.labelNames.length===0)this.hashMap={[Th({})]:{labels:{},td:new Ah(this.maxAgeSeconds,this.ageBuckets),count:0,sum:0}}}observe(e,t){kh.call(this,e===0?0:e||{})(t)}async get(){if(this.collect){let n=this.collect();if(n instanceof Promise)await n}let e=Object.keys(this.hashMap),t=[];return e.forEach((n)=>{let r=this.hashMap[n];if(r)if(this.pruneAgedBuckets&&r.td.size()===0)delete this.hashMap[n];else g0(r,this.percentiles).forEach((o)=>{t.push(o)}),t.push(y0(r,this)),t.push(h0(r,this))}),{name:this.name,help:this.help,type:this.type,values:t,aggregator:this.aggregator}}reset(){Object.values(this.hashMap).forEach((t)=>{t.td.reset(),t.count=0,t.sum=0})}startTimer(e){return Ih.call(this,e)()}labels(...e){let t=Sh(this.labelNames,e);return ja(this.labelNames,t),{observe:kh.call(this,t),startTimer:Ih.call(this,t)}}remove(...e){let t=Sh(this.labelNames,e);ja(this.labelNames,t),m0.call(this,this.hashMap,t,this.sortedLabelNames)}}function g0(e,t){return e.td.compress(),t.map((n)=>{let r=e.td.percentile(n);return{labels:Object.assign({quantile:n},e.labels),value:r?r:0}})}function h0(e,t){return{metricName:`${t.name}_count`,labels:e.labels,value:e.count}}function y0(e,t){return{metricName:`${t.name}_sum`,labels:e.labels,value:e.sum}}function Ih(e){return()=>{let t=process.hrtime();return(n)=>{let r=process.hrtime(t),o=r[0]+r[1]/1e9;return this.observe(Object.assign({},e,n),o),o}}}function kh(e){return(t)=>{let n=b0(e,t);if(ja(this.labelNames,e),!Number.isFinite(n.value))throw TypeError(`Value is not a valid number: ${Rh.format(n.value)}`);let r=Th(n.labels,this.sortedLabelNames),o=this.hashMap[r];if(!o)o={labels:n.labels,td:new Ah(this.maxAgeSeconds,this.ageBuckets),count:0,sum:0};if(o.td.push(n.value),o.count++,o.count%this.compressCount===0)o.td.compress();o.sum+=n.value,this.hashMap[r]=o}}function b0(e,t){if(t===void 0)return{value:e,labels:{}};return{labels:e,value:t}}Eh.exports=Ch});var Mh=g(function(LW,$h){var Gn=_e(\"url\"),v0=_e(\"http\"),_0=_e(\"https\"),{gzipSync:w0}=_e(\"zlib\"),{globalRegistry:x0}=Nn();class Oh{constructor(e,t,n){if(!n)n=x0;this.registry=n,this.gatewayUrl=e;let{requireJobName:r,...o}={requireJobName:!0,...t};this.requireJobName=r,this.requestOptions=o}pushAdd(e={}){if(this.requireJobName&&!e.jobName)throw Error(\"Missing jobName parameter\");return Na.call(this,\"POST\",e.jobName,e.groupings)}push(e={}){if(this.requireJobName&&!e.jobName)throw Error(\"Missing jobName parameter\");return Na.call(this,\"PUT\",e.jobName,e.groupings)}delete(e={}){if(this.requireJobName&&!e.jobName)throw Error(\"Missing jobName parameter\");return Na.call(this,\"DELETE\",e.jobName,e.groupings)}}async function Na(e,t,n){let r=Gn.parse(this.gatewayUrl),o=r.pathname&&r.pathname!==\"/\"?r.pathname:\"\",s=t?`/job/${encodeURIComponent(t)}${S0(n)}`:\"\",i=`${o}/metrics${s}`,a=Gn.resolve(this.gatewayUrl,i),c=Gn.parse(a),l=I0(c.href)?_0:v0,u=Object.assign(c,this.requestOptions,{method:e});return new Promise((p,m)=>{if(e===\"DELETE\"&&u.headers)delete u.headers[\"Content-Encoding\"];let d=l.request(u,(f)=>{let h=\"\";f.setEncoding(\"utf8\"),f.on(\"data\",(y)=>{h+=y}),f.on(\"end\",()=>{if(f.statusCode>=400)m(Error(`push failed with status ${f.statusCode}, ${h}`));else p({resp:f,body:h})})});if(d.on(\"error\",(f)=>{m(f)}),d.on(\"timeout\",()=>{d.destroy(Error(\"Pushgateway request timed out\"))}),e!==\"DELETE\")this.registry.metrics().then((f)=>{if(u.headers&&u.headers[\"Content-Encoding\"]===\"gzip\")f=w0(f);d.write(f),d.end()}).catch((f)=>{m(f)});else d.end()})}function S0(e){if(!e)return\"\";return Object.keys(e).map((t)=>`/${encodeURIComponent(t)}/${encodeURIComponent(e[t])}`).join(\"\")}function I0(e){return e.search(/^https/)!==-1}$h.exports=Oh});var Da=g(function(k0){k0.linearBuckets=(e,t,n)=>{if(n<1)throw Error(\"Linear buckets needs a positive count\");let r=Array(n);for(let o=0;o<n;o++)r[o]=e+o*t;return r};k0.exponentialBuckets=(e,t,n)=>{if(e<=0)throw Error(\"Exponential buckets needs a positive start\");if(n<1)throw Error(\"Exponential buckets needs a positive count\");if(t<=1)throw Error(\"Exponential buckets needs a factor greater than 1\");let r=Array(n);for(let o=0;o<n;o++)r[o]=e,e*=t;return r}});var Ua=g(function(qh){Object.defineProperty(qh,\"__esModule\",{value:!0});qh.VERSION=void 0;qh.VERSION=\"1.9.1\"});var Gh=g(function(Uh){Object.defineProperty(Uh,\"__esModule\",{value:!0});Uh.isCompatible=Uh._makeCompatibilityCheck=void 0;var Nh=Ua(),jh=/^(\\d+)\\.(\\d+)\\.(\\d+)(-(.+))?$/;function Dh(e){let t=new Set([e]),n=new Set,r=e.match(jh);if(!r)return()=>!1;let o={major:+r[1],minor:+r[2],patch:+r[3],prerelease:r[4]};if(o.prerelease!=null)return function(c){return c===e};function s(a){return n.add(a),!1}function i(a){return t.add(a),!0}return function(c){if(t.has(c))return!0;if(n.has(c))return!1;let l=c.match(jh);if(!l)return s(c);let u={major:+l[1],minor:+l[2],patch:+l[3],prerelease:l[4]};if(u.prerelease!=null)return s(c);if(o.major!==u.major)return s(c);if(o.major===0){if(o.minor===u.minor&&o.patch<=u.patch)return i(c);return s(c)}if(o.minor<=u.minor)return i(c);return s(c)}}Uh._makeCompatibilityCheck=Dh;Uh.isCompatible=Dh(Nh.VERSION)});var bn=g(function(Vh){Object.defineProperty(Vh,\"__esModule\",{value:!0});Vh.unregisterGlobal=Vh.getGlobal=Vh.registerGlobal=void 0;var De=Ua(),Bh=Gh(),C0=De.VERSION.split(\".\")[0],Lr=Symbol.for(`opentelemetry.js.api.${C0}`),Gr=typeof globalThis===\"object\"?globalThis:typeof self===\"object\"?self:typeof window===\"object\"?window:typeof global===\"object\"?global:{};function E0(e,t,n,r=!1){var o;let s=Gr[Lr]=(o=Gr[Lr])!==null&&o!==void 0?o:{version:De.VERSION};if(!r&&s[e]){let i=Error(`@opentelemetry/api: Attempted duplicate registration of API: ${e}`);return n.error(i.stack||i.message),!1}if(s.version!==De.VERSION){let i=Error(`@opentelemetry/api: Registration of version v${s.version} for ${e} does not match previously registered API v${De.VERSION}`);return n.error(i.stack||i.message),!1}return s[e]=t,n.debug(`@opentelemetry/api: Registered a global for ${e} v${De.VERSION}.`),!0}Vh.registerGlobal=E0;function P0(e){var t,n;let r=(t=Gr[Lr])===null||t===void 0?void 0:t.version;if(!r||!Bh.isCompatible(r))return;return(n=Gr[Lr])===null||n===void 0?void 0:n[e]}Vh.getGlobal=P0;function O0(e,t){t.debug(`@opentelemetry/api: Unregistering a global for ${e} v${De.VERSION}.`);let n=Gr[Lr];if(n)delete n[e]}Vh.unregisterGlobal=O0});var Zh=g(function(Kh){Object.defineProperty(Kh,\"__esModule\",{value:!0});Kh.DiagComponentLogger=void 0;var Jh=bn();class Wh{constructor(e){this._namespace=e.namespace||\"DiagComponentLogger\"}debug(...e){return Br(\"debug\",this._namespace,e)}error(...e){return Br(\"error\",this._namespace,e)}info(...e){return Br(\"info\",this._namespace,e)}warn(...e){return Br(\"warn\",this._namespace,e)}verbose(...e){return Br(\"verbose\",this._namespace,e)}}Kh.DiagComponentLogger=Wh;function Br(e,t,n){let r=Jh.getGlobal(\"diag\");if(!r)return;return r[e](t,...n)}});var Ko=g(function(Yh){Object.defineProperty(Yh,\"__esModule\",{value:!0});Yh.DiagLogLevel=void 0;var q0;(function(e){e[e.NONE=0]=\"NONE\",e[e.ERROR=30]=\"ERROR\",e[e.WARN=50]=\"WARN\",e[e.INFO=60]=\"INFO\",e[e.DEBUG=70]=\"DEBUG\",e[e.VERBOSE=80]=\"VERBOSE\",e[e.ALL=9999]=\"ALL\"})(q0=Yh.DiagLogLevel||(Yh.DiagLogLevel={}))});var ey=g(function(Xh){Object.defineProperty(Xh,\"__esModule\",{value:!0});Xh.createLogLevelDiagLogger=void 0;var be=Ko();function z0(e,t){if(e<be.DiagLogLevel.NONE)e=be.DiagLogLevel.NONE;else if(e>be.DiagLogLevel.ALL)e=be.DiagLogLevel.ALL;t=t||{};function n(r,o){let s=t[r];if(typeof s===\"function\"&&e>=o)return s.bind(t);return function(){}}return{error:n(\"error\",be.DiagLogLevel.ERROR),warn:n(\"warn\",be.DiagLogLevel.WARN),info:n(\"info\",be.DiagLogLevel.INFO),debug:n(\"debug\",be.DiagLogLevel.DEBUG),verbose:n(\"verbose\",be.DiagLogLevel.VERBOSE)}}Xh.createLogLevelDiagLogger=z0});var vn=g(function(ry){Object.defineProperty(ry,\"__esModule\",{value:!0});ry.DiagAPI=void 0;var ty=Zh(),ny=ey(),Ho=Ko(),Mt=bn(),j0=\"diag\";class Ga{static instance(){if(!this._instance)this._instance=new Ga;return this._instance}constructor(){function e(r){return function(...o){let s=Mt.getGlobal(\"diag\");if(!s)return;return s[r](...o)}}let t=this,n=(r,o={logLevel:Ho.DiagLogLevel.INFO})=>{var s,i,a;if(r===t){let u=Error(\"Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation\");return t.error((s=u.stack)!==null&&s!==void 0?s:u.message),!1}if(typeof o===\"number\")o={logLevel:o};let c=Mt.getGlobal(\"diag\"),l=ny.createLogLevelDiagLogger((i=o.logLevel)!==null&&i!==void 0?i:Ho.DiagLogLevel.INFO,r);if(c&&!o.suppressOverrideMessage){let u=(a=Error().stack)!==null&&a!==void 0?a:\"<failed to generate stacktrace>\";c.warn(`Current logger will be overwritten from ${u}`),l.warn(`Current logger will overwrite one already registered from ${u}`)}return Mt.registerGlobal(\"diag\",l,t,!0)};t.setLogger=n,t.disable=()=>{Mt.unregisterGlobal(j0,t)},t.createComponentLogger=(r)=>new ty.DiagComponentLogger(r),t.verbose=e(\"verbose\"),t.debug=e(\"debug\"),t.info=e(\"info\"),t.warn=e(\"warn\"),t.error=e(\"error\")}}ry.DiagAPI=Ga});var ay=g(function(sy){Object.defineProperty(sy,\"__esModule\",{value:!0});sy.BaggageImpl=void 0;class Bn{constructor(e){this._entries=e?new Map(e):new Map}getEntry(e){let t=this._entries.get(e);if(!t)return;return Object.assign({},t)}getAllEntries(){return Array.from(this._entries.entries())}setEntry(e,t){let n=new Bn(this._entries);return n._entries.set(e,t),n}removeEntry(e){let t=new Bn(this._entries);return t._entries.delete(e),t}removeEntries(...e){let t=new Bn(this._entries);for(let n of e)t._entries.delete(n);return t}clear(){return new Bn}}sy.BaggageImpl=Bn});var uy=g(function(cy){Object.defineProperty(cy,\"__esModule\",{value:!0});cy.baggageEntryMetadataSymbol=void 0;cy.baggageEntryMetadataSymbol=Symbol(\"BaggageEntryMetadata\")});var Ba=g(function(fy){Object.defineProperty(fy,\"__esModule\",{value:!0});fy.baggageEntryMetadataFromString=fy.createBaggage=void 0;var dy=vn(),py=ay(),my=uy(),N0=dy.DiagAPI.instance();function D0(e={}){return new py.BaggageImpl(new Map(Object.entries(e)))}fy.createBaggage=D0;function U0(e){if(typeof e!==\"string\")N0.error(`Cannot create baggage metadata from unknown type: ${typeof e}`),e=\"\";return{__TYPE__:my.baggageEntryMetadataSymbol,toString(){return e}}}fy.baggageEntryMetadataFromString=U0});var Vr=g(function(hy){Object.defineProperty(hy,\"__esModule\",{value:!0});hy.ROOT_CONTEXT=hy.createContextKey=void 0;function G0(e){return Symbol.for(e)}hy.createContextKey=G0;class Zo{constructor(e){let t=this;t._currentContext=e?new Map(e):new Map,t.getValue=(n)=>t._currentContext.get(n),t.setValue=(n,r)=>{let o=new Zo(t._currentContext);return o._currentContext.set(n,r),o},t.deleteValue=(n)=>{let r=new Zo(t._currentContext);return r._currentContext.delete(n),r}}}hy.ROOT_CONTEXT=new Zo});var wy=g(function(vy){Object.defineProperty(vy,\"__esModule\",{value:!0});vy.DiagConsoleLogger=vy._originalConsoleMethods=void 0;var Va=[{n:\"error\",c:\"error\"},{n:\"warn\",c:\"warn\"},{n:\"info\",c:\"info\"},{n:\"debug\",c:\"debug\"},{n:\"verbose\",c:\"trace\"}];vy._originalConsoleMethods={};if(typeof console<\"u\"){let e=[\"error\",\"warn\",\"info\",\"debug\",\"trace\",\"log\"];for(let t of e)if(typeof console[t]===\"function\")vy._originalConsoleMethods[t]=console[t]}class by{constructor(){function e(t){return function(...n){let r=vy._originalConsoleMethods[t];if(typeof r!==\"function\")r=vy._originalConsoleMethods.log;if(typeof r!==\"function\"&&console){if(r=console[t],typeof r!==\"function\")r=console.log}if(typeof r===\"function\")return r.apply(console,n)}}for(let t=0;t<Va.length;t++)this[Va[t].n]=e(Va[t].c)}}vy.DiagConsoleLogger=by});var Qa=g(function(xy){Object.defineProperty(xy,\"__esModule\",{value:!0});xy.createNoopMeter=xy.NOOP_OBSERVABLE_UP_DOWN_COUNTER_METRIC=xy.NOOP_OBSERVABLE_GAUGE_METRIC=xy.NOOP_OBSERVABLE_COUNTER_METRIC=xy.NOOP_UP_DOWN_COUNTER_METRIC=xy.NOOP_HISTOGRAM_METRIC=xy.NOOP_GAUGE_METRIC=xy.NOOP_COUNTER_METRIC=xy.NOOP_METER=xy.NoopObservableUpDownCounterMetric=xy.NoopObservableGaugeMetric=xy.NoopObservableCounterMetric=xy.NoopObservableMetric=xy.NoopHistogramMetric=xy.NoopGaugeMetric=xy.NoopUpDownCounterMetric=xy.NoopCounterMetric=xy.NoopMetric=xy.NoopMeter=void 0;class Fa{constructor(){}createGauge(e,t){return xy.NOOP_GAUGE_METRIC}createHistogram(e,t){return xy.NOOP_HISTOGRAM_METRIC}createCounter(e,t){return xy.NOOP_COUNTER_METRIC}createUpDownCounter(e,t){return xy.NOOP_UP_DOWN_COUNTER_METRIC}createObservableGauge(e,t){return xy.NOOP_OBSERVABLE_GAUGE_METRIC}createObservableCounter(e,t){return xy.NOOP_OBSERVABLE_COUNTER_METRIC}createObservableUpDownCounter(e,t){return xy.NOOP_OBSERVABLE_UP_DOWN_COUNTER_METRIC}addBatchObservableCallback(e,t){}removeBatchObservableCallback(e){}}xy.NoopMeter=Fa;class Vn{}xy.NoopMetric=Vn;class Ja extends Vn{add(e,t){}}xy.NoopCounterMetric=Ja;class Wa extends Vn{add(e,t){}}xy.NoopUpDownCounterMetric=Wa;class Ka extends Vn{record(e,t){}}xy.NoopGaugeMetric=Ka;class Ha extends Vn{record(e,t){}}xy.NoopHistogramMetric=Ha;class Fr{addCallback(e){}removeCallback(e){}}xy.NoopObservableMetric=Fr;class Za extends Fr{}xy.NoopObservableCounterMetric=Za;class Ya extends Fr{}xy.NoopObservableGaugeMetric=Ya;class Xa extends Fr{}xy.NoopObservableUpDownCounterMetric=Xa;xy.NOOP_METER=new Fa;xy.NOOP_COUNTER_METRIC=new Ja;xy.NOOP_GAUGE_METRIC=new Ka;xy.NOOP_HISTOGRAM_METRIC=new Ha;xy.NOOP_UP_DOWN_COUNTER_METRIC=new Wa;xy.NOOP_OBSERVABLE_COUNTER_METRIC=new Za;xy.NOOP_OBSERVABLE_GAUGE_METRIC=new Ya;xy.NOOP_OBSERVABLE_UP_DOWN_COUNTER_METRIC=new Xa;function V0(){return xy.NOOP_METER}xy.createNoopMeter=V0});var $y=g(function(Oy){Object.defineProperty(Oy,\"__esModule\",{value:!0});Oy.ValueType=void 0;var tP;(function(e){e[e.INT=0]=\"INT\",e[e.DOUBLE=1]=\"DOUBLE\"})(tP=Oy.ValueType||(Oy.ValueType={}))});var tc=g(function(My){Object.defineProperty(My,\"__esModule\",{value:!0});My.defaultTextMapSetter=My.defaultTextMapGetter=void 0;My.defaultTextMapGetter={get(e,t){if(e==null)return;return e[t]},keys(e){if(e==null)return[];return Object.keys(e)}};My.defaultTextMapSetter={set(e,t,n){if(e==null)return;e[t]=n}}});var Uy=g(function(Ny){Object.defineProperty(Ny,\"__esModule\",{value:!0});Ny.NoopContextManager=void 0;var zy=Vr();class jy{active(){return zy.ROOT_CONTEXT}with(e,t,n,...r){return t.call(n,...r)}bind(e,t){return t}enable(){return this}disable(){return this}}Ny.NoopContextManager=jy});var Jr=g(function(Gy){Object.defineProperty(Gy,\"__esModule\",{value:!0});Gy.ContextAPI=void 0;var Ly=Uy(),Fn=bn(),Xo=vn(),nc=\"context\",rP=new Ly.NoopContextManager;class rc{constructor(){}static getInstance(){if(!this._instance)this._instance=new rc;return this._instance}setGlobalContextManager(e){return Fn.registerGlobal(nc,e,Xo.DiagAPI.instance())}active(){return this._getContextManager().active()}with(e,t,n,...r){return this._getContextManager().with(e,t,n,...r)}bind(e,t){return this._getContextManager().bind(e,t)}_getContextManager(){return Fn.getGlobal(nc)||rP}disable(){this._getContextManager().disable(),Fn.unregisterGlobal(nc,Xo.DiagAPI.instance())}}Gy.ContextAPI=rc});var sc=g(function(Vy){Object.defineProperty(Vy,\"__esModule\",{value:!0});Vy.TraceFlags=void 0;var oP;(function(e){e[e.NONE=0]=\"NONE\",e[e.SAMPLED=1]=\"SAMPLED\"})(oP=Vy.TraceFlags||(Vy.TraceFlags={}))});var Qo=g(function(Jy){Object.defineProperty(Jy,\"__esModule\",{value:!0});Jy.INVALID_SPAN_CONTEXT=Jy.INVALID_TRACEID=Jy.INVALID_SPANID=void 0;var Fy=sc();Jy.INVALID_SPANID=\"0000000000000000\";Jy.INVALID_TRACEID=\"00000000000000000000000000000000\";Jy.INVALID_SPAN_CONTEXT={traceId:Jy.INVALID_TRACEID,spanId:Jy.INVALID_SPANID,traceFlags:Fy.TraceFlags.NONE}});var es=g(function(Xy){Object.defineProperty(Xy,\"__esModule\",{value:!0});Xy.NonRecordingSpan=void 0;var Zy=Qo();class Yy{constructor(e=Zy.INVALID_SPAN_CONTEXT){this._spanContext=e}spanContext(){return this._spanContext}setAttribute(e,t){return this}setAttributes(e){return this}addEvent(e,t){return this}addLink(e){return this}addLinks(e){return this}setStatus(e){return this}updateName(e){return this}end(e){}isRecording(){return!1}recordException(e,t){}}Xy.NonRecordingSpan=Yy});var cc=g(function(ob){Object.defineProperty(ob,\"__esModule\",{value:!0});ob.getSpanContext=ob.setSpanContext=ob.deleteSpan=ob.setSpan=ob.getActiveSpan=ob.getSpan=void 0;var eb=Vr(),tb=es(),nb=Jr(),ic=eb.createContextKey(\"OpenTelemetry Context Key SPAN\");function ac(e){return e.getValue(ic)||void 0}ob.getSpan=ac;function sP(){return ac(nb.ContextAPI.getInstance().active())}ob.getActiveSpan=sP;function rb(e,t){return e.setValue(ic,t)}ob.setSpan=rb;function iP(e){return e.deleteValue(ic)}ob.deleteSpan=iP;function aP(e,t){return rb(e,new tb.NonRecordingSpan(t))}ob.setSpanContext=aP;function cP(e){var t;return(t=ac(e))===null||t===void 0?void 0:t.spanContext()}ob.getSpanContext=cP});var rs=g(function(ub){Object.defineProperty(ub,\"__esModule\",{value:!0});ub.wrapSpanContext=ub.isSpanContextValid=ub.isValidSpanId=ub.isValidTraceId=void 0;var ns=Qo(),ib=es(),ts=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1]);function ab(e,t){if(typeof e!==\"string\"||e.length!==t)return!1;let n=0;for(let r=0;r<e.length;r+=4)n+=(ts[e.charCodeAt(r)]|0)+(ts[e.charCodeAt(r+1)]|0)+(ts[e.charCodeAt(r+2)]|0)+(ts[e.charCodeAt(r+3)]|0);return n===t}function cb(e){return ab(e,32)&&e!==ns.INVALID_TRACEID}ub.isValidTraceId=cb;function lb(e){return ab(e,16)&&e!==ns.INVALID_SPANID}ub.isValidSpanId=lb;function fP(e){return cb(e.traceId)&&lb(e.spanId)}ub.isSpanContextValid=fP;function gP(e){return new ib.NonRecordingSpan(e)}ub.wrapSpanContext=gP});var uc=g(function(gb){Object.defineProperty(gb,\"__esModule\",{value:!0});gb.NoopTracer=void 0;var pb=Jr(),os=cc(),Jn=es(),mb=rs(),lc=pb.ContextAPI.getInstance();class fb{startSpan(e,t,n=lc.active()){if(Boolean(t===null||t===void 0?void 0:t.root))return new Jn.NonRecordingSpan;let o=n&&os.getSpanContext(n);if(vP(o)&&mb.isSpanContextValid(o))return new Jn.NonRecordingSpan(o);else return new Jn.NonRecordingSpan}startActiveSpan(e,t,n,r){let o,s,i;if(arguments.length<2)return;else if(arguments.length===2)i=t;else if(arguments.length===3)o=t,i=n;else o=t,s=n,i=r;let a=s!==null&&s!==void 0?s:lc.active(),c=this.startSpan(e,o,a),l=os.setSpan(a,c);return lc.with(l,i,void 0,c)}}gb.NoopTracer=fb;function vP(e){return e!==null&&typeof e===\"object\"&&\"spanId\"in e&&typeof e.spanId===\"string\"&&\"traceId\"in e&&typeof e.traceId===\"string\"&&\"traceFlags\"in e&&typeof e.traceFlags===\"number\"}});var dc=g(function(vb){Object.defineProperty(vb,\"__esModule\",{value:!0});vb.ProxyTracer=void 0;var yb=uc(),_P=new yb.NoopTracer;class bb{constructor(e,t,n,r){this._provider=e,this.name=t,this.version=n,this.options=r}startSpan(e,t,n){return this._getTracer().startSpan(e,t,n)}startActiveSpan(e,t,n,r){let o=this._getTracer();return Reflect.apply(o.startActiveSpan,o,arguments)}_getTracer(){if(this._delegate)return this._delegate;let e=this._provider.getDelegateTracer(this.name,this.version,this.options);if(!e)return _P;return this._delegate=e,this._delegate}}vb.ProxyTracer=bb});var kb=g(function(Sb){Object.defineProperty(Sb,\"__esModule\",{value:!0});Sb.NoopTracerProvider=void 0;var wb=uc();class xb{getTracer(e,t,n){return new wb.NoopTracer}}Sb.NoopTracerProvider=xb});var pc=g(function(Cb){Object.defineProperty(Cb,\"__esModule\",{value:!0});Cb.ProxyTracerProvider=void 0;var Rb=dc(),Tb=kb(),wP=new Tb.NoopTracerProvider;class Ab{getTracer(e,t,n){var r;return(r=this.getDelegateTracer(e,t,n))!==null&&r!==void 0?r:new Rb.ProxyTracer(this,e,t,n)}getDelegate(){var e;return(e=this._delegate)!==null&&e!==void 0?e:wP}setDelegate(e){this._delegate=e}getDelegateTracer(e,t,n){var r;return(r=this._delegate)===null||r===void 0?void 0:r.getTracer(e,t,n)}}Cb.ProxyTracerProvider=Ab});var Ob=g(function(Pb){Object.defineProperty(Pb,\"__esModule\",{value:!0});Pb.SamplingDecision=void 0;var xP;(function(e){e[e.NOT_RECORD=0]=\"NOT_RECORD\",e[e.RECORD=1]=\"RECORD\",e[e.RECORD_AND_SAMPLED=2]=\"RECORD_AND_SAMPLED\"})(xP=Pb.SamplingDecision||(Pb.SamplingDecision={}))});var Mb=g(function($b){Object.defineProperty($b,\"__esModule\",{value:!0});$b.SpanKind=void 0;var SP;(function(e){e[e.INTERNAL=0]=\"INTERNAL\",e[e.SERVER=1]=\"SERVER\",e[e.CLIENT=2]=\"CLIENT\",e[e.PRODUCER=3]=\"PRODUCER\",e[e.CONSUMER=4]=\"CONSUMER\"})(SP=$b.SpanKind||($b.SpanKind={}))});var zb=g(function(qb){Object.defineProperty(qb,\"__esModule\",{value:!0});qb.SpanStatusCode=void 0;var IP;(function(e){e[e.UNSET=0]=\"UNSET\",e[e.OK=1]=\"OK\",e[e.ERROR=2]=\"ERROR\"})(IP=qb.SpanStatusCode||(qb.SpanStatusCode={}))});var Db=g(function(jb){Object.defineProperty(jb,\"__esModule\",{value:!0});jb.validateValue=jb.validateKey=void 0;var hc=\"[_0-9a-z-*/]\",kP=`[a-z]${hc}{0,255}`,RP=`[a-z0-9]${hc}{0,240}@[a-z]${hc}{0,13}`,TP=new RegExp(`^(?:${kP}|${RP})$`),AP=/^[ -~]{0,255}[!-~]$/,CP=/,|=/;function EP(e){return TP.test(e)}jb.validateKey=EP;function PP(e){return AP.test(e)&&!CP.test(e)}jb.validateValue=PP});var Fb=g(function(Bb){Object.defineProperty(Bb,\"__esModule\",{value:!0});Bb.TraceStateImpl=void 0;var ss=Db(),Ub=32,$P=512,Lb=\",\",Gb=\"=\";class yc{constructor(e){if(this._internalState=new Map,e)this._parse(e)}set(e,t){let n=this._clone();if(n._internalState.has(e))n._internalState.delete(e);return n._internalState.set(e,t),n}unset(e){let t=this._clone();return t._internalState.delete(e),t}get(e){return this._internalState.get(e)}serialize(){return Array.from(this._internalState.keys()).reduceRight((e,t)=>(e.push(t+Gb+this.get(t)),e),[]).join(Lb)}_parse(e){if(e.length>$P)return;if(this._internalState=e.split(Lb).reduceRight((t,n)=>{let r=n.trim(),o=r.indexOf(Gb);if(o!==-1){let s=r.slice(0,o),i=r.slice(o+1,n.length);if(ss.validateKey(s)&&ss.validateValue(i))t.set(s,i)}return t},new Map),this._internalState.size>Ub)this._internalState=new Map(Array.from(this._internalState.entries()).reverse().slice(0,Ub))}_keys(){return Array.from(this._internalState.keys()).reverse()}_clone(){let e=new yc;return e._internalState=new Map(this._internalState),e}}Bb.TraceStateImpl=yc});var Hb=g(function(Wb){Object.defineProperty(Wb,\"__esModule\",{value:!0});Wb.createTraceState=void 0;var Jb=Fb();function MP(e){return new Jb.TraceStateImpl(e)}Wb.createTraceState=MP});var Qb=g(function(Yb){Object.defineProperty(Yb,\"__esModule\",{value:!0});Yb.context=void 0;var Zb=Jr();Yb.context=Zb.ContextAPI.getInstance()});var rv=g(function(tv){Object.defineProperty(tv,\"__esModule\",{value:!0});tv.diag=void 0;var ev=vn();tv.diag=ev.DiagAPI.instance()});var av=g(function(sv){Object.defineProperty(sv,\"__esModule\",{value:!0});sv.NOOP_METER_PROVIDER=sv.NoopMeterProvider=void 0;var ov=Qa();class bc{getMeter(e,t,n){return ov.NOOP_METER}}sv.NoopMeterProvider=bc;sv.NOOP_METER_PROVIDER=new bc});var dv=g(function(lv){Object.defineProperty(lv,\"__esModule\",{value:!0});lv.MetricsAPI=void 0;var cv=av(),Wn=bn(),is=vn(),vc=\"metrics\";class _c{constructor(){}static getInstance(){if(!this._instance)this._instance=new _c;return this._instance}setGlobalMeterProvider(e){return Wn.registerGlobal(vc,e,is.DiagAPI.instance())}getMeterProvider(){return Wn.getGlobal(vc)||cv.NOOP_METER_PROVIDER}getMeter(e,t,n){return this.getMeterProvider().getMeter(e,t,n)}disable(){Wn.unregisterGlobal(vc,is.DiagAPI.instance())}}lv.MetricsAPI=_c});var gv=g(function(mv){Object.defineProperty(mv,\"__esModule\",{value:!0});mv.metrics=void 0;var pv=dv();mv.metrics=pv.MetricsAPI.getInstance()});var vv=g(function(yv){Object.defineProperty(yv,\"__esModule\",{value:!0});yv.NoopTextMapPropagator=void 0;class hv{inject(e,t){}extract(e,t){return e}fields(){return[]}}yv.NoopTextMapPropagator=hv});var kv=g(function(Sv){Object.defineProperty(Sv,\"__esModule\",{value:!0});Sv.deleteBaggage=Sv.setBaggage=Sv.getActiveBaggage=Sv.getBaggage=void 0;var _v=Jr(),wv=Vr(),wc=wv.createContextKey(\"OpenTelemetry Baggage Key\");function xv(e){return e.getValue(wc)||void 0}Sv.getBaggage=xv;function zP(){return xv(_v.ContextAPI.getInstance().active())}Sv.getActiveBaggage=zP;function jP(e,t){return e.setValue(wc,t)}Sv.setBaggage=jP;function NP(e){return e.deleteValue(wc)}Sv.deleteBaggage=NP});var Ev=g(function(Av){Object.defineProperty(Av,\"__esModule\",{value:!0});Av.PropagationAPI=void 0;var Kn=bn(),Rv=vv(),as=tc(),qt=kv(),Tv=Ba(),cs=vn(),xc=\"propagation\",GP=new Rv.NoopTextMapPropagator;class Sc{constructor(){this.createBaggage=Tv.createBaggage,this.getBaggage=qt.getBaggage,this.getActiveBaggage=qt.getActiveBaggage,this.setBaggage=qt.setBaggage,this.deleteBaggage=qt.deleteBaggage}static getInstance(){if(!this._instance)this._instance=new Sc;return this._instance}setGlobalPropagator(e){return Kn.registerGlobal(xc,e,cs.DiagAPI.instance())}inject(e,t,n=as.defaultTextMapSetter){return this._getGlobalPropagator().inject(e,t,n)}extract(e,t,n=as.defaultTextMapGetter){return this._getGlobalPropagator().extract(e,t,n)}fields(){return this._getGlobalPropagator().fields()}disable(){Kn.unregisterGlobal(xc,cs.DiagAPI.instance())}_getGlobalPropagator(){return Kn.getGlobal(xc)||GP}}Av.PropagationAPI=Sc});var Mv=g(function(Ov){Object.defineProperty(Ov,\"__esModule\",{value:!0});Ov.propagation=void 0;var Pv=Ev();Ov.propagation=Pv.PropagationAPI.getInstance()});var jv=g(function(qv){Object.defineProperty(qv,\"__esModule\",{value:!0});qv.TraceAPI=void 0;var Hn=bn(),ls=pc(),us=rs(),Ue=cc(),ds=vn(),Ic=\"trace\";class kc{constructor(){this._proxyTracerProvider=new ls.ProxyTracerProvider,this.wrapSpanContext=us.wrapSpanContext,this.isSpanContextValid=us.isSpanContextValid,this.deleteSpan=Ue.deleteSpan,this.getSpan=Ue.getSpan,this.getActiveSpan=Ue.getActiveSpan,this.getSpanContext=Ue.getSpanContext,this.setSpan=Ue.setSpan,this.setSpanContext=Ue.setSpanContext}static getInstance(){if(!this._instance)this._instance=new kc;return this._instance}setGlobalTracerProvider(e){let t=Hn.registerGlobal(Ic,this._proxyTracerProvider,ds.DiagAPI.instance());if(t)this._proxyTracerProvider.setDelegate(e);return t}getTracerProvider(){return Hn.getGlobal(Ic)||this._proxyTracerProvider}getTracer(e,t){return this.getTracerProvider().getTracer(e,t)}disable(){Hn.unregisterGlobal(Ic,ds.DiagAPI.instance()),this._proxyTracerProvider=new ls.ProxyTracerProvider}}qv.TraceAPI=kc});var Lv=g(function(Dv){Object.defineProperty(Dv,\"__esModule\",{value:!0});Dv.trace=void 0;var Nv=jv();Dv.trace=Nv.TraceAPI.getInstance()});var Vv=g(function(X){Object.defineProperty(X,\"__esModule\",{value:!0});X.trace=X.propagation=X.metrics=X.diag=X.context=X.INVALID_SPAN_CONTEXT=X.INVALID_TRACEID=X.INVALID_SPANID=X.isValidSpanId=X.isValidTraceId=X.isSpanContextValid=X.createTraceState=X.TraceFlags=X.SpanStatusCode=X.SpanKind=X.SamplingDecision=X.ProxyTracerProvider=X.ProxyTracer=X.defaultTextMapSetter=X.defaultTextMapGetter=X.ValueType=X.createNoopMeter=X.DiagLogLevel=X.DiagConsoleLogger=X.ROOT_CONTEXT=X.createContextKey=X.baggageEntryMetadataFromString=void 0;var BP=Ba();Object.defineProperty(X,\"baggageEntryMetadataFromString\",{enumerable:!0,get:function(){return BP.baggageEntryMetadataFromString}});var Gv=Vr();Object.defineProperty(X,\"createContextKey\",{enumerable:!0,get:function(){return Gv.createContextKey}});Object.defineProperty(X,\"ROOT_CONTEXT\",{enumerable:!0,get:function(){return Gv.ROOT_CONTEXT}});var VP=wy();Object.defineProperty(X,\"DiagConsoleLogger\",{enumerable:!0,get:function(){return VP.DiagConsoleLogger}});var FP=Ko();Object.defineProperty(X,\"DiagLogLevel\",{enumerable:!0,get:function(){return FP.DiagLogLevel}});var JP=Qa();Object.defineProperty(X,\"createNoopMeter\",{enumerable:!0,get:function(){return JP.createNoopMeter}});var WP=$y();Object.defineProperty(X,\"ValueType\",{enumerable:!0,get:function(){return WP.ValueType}});var Bv=tc();Object.defineProperty(X,\"defaultTextMapGetter\",{enumerable:!0,get:function(){return Bv.defaultTextMapGetter}});Object.defineProperty(X,\"defaultTextMapSetter\",{enumerable:!0,get:function(){return Bv.defaultTextMapSetter}});var KP=dc();Object.defineProperty(X,\"ProxyTracer\",{enumerable:!0,get:function(){return KP.ProxyTracer}});var HP=pc();Object.defineProperty(X,\"ProxyTracerProvider\",{enumerable:!0,get:function(){return HP.ProxyTracerProvider}});var ZP=Ob();Object.defineProperty(X,\"SamplingDecision\",{enumerable:!0,get:function(){return ZP.SamplingDecision}});var YP=Mb();Object.defineProperty(X,\"SpanKind\",{enumerable:!0,get:function(){return YP.SpanKind}});var XP=zb();Object.defineProperty(X,\"SpanStatusCode\",{enumerable:!0,get:function(){return XP.SpanStatusCode}});var QP=sc();Object.defineProperty(X,\"TraceFlags\",{enumerable:!0,get:function(){return QP.TraceFlags}});var eO=Hb();Object.defineProperty(X,\"createTraceState\",{enumerable:!0,get:function(){return eO.createTraceState}});var Rc=rs();Object.defineProperty(X,\"isSpanContextValid\",{enumerable:!0,get:function(){return Rc.isSpanContextValid}});Object.defineProperty(X,\"isValidTraceId\",{enumerable:!0,get:function(){return Rc.isValidTraceId}});Object.defineProperty(X,\"isValidSpanId\",{enumerable:!0,get:function(){return Rc.isValidSpanId}});var Tc=Qo();Object.defineProperty(X,\"INVALID_SPANID\",{enumerable:!0,get:function(){return Tc.INVALID_SPANID}});Object.defineProperty(X,\"INVALID_TRACEID\",{enumerable:!0,get:function(){return Tc.INVALID_TRACEID}});Object.defineProperty(X,\"INVALID_SPAN_CONTEXT\",{enumerable:!0,get:function(){return Tc.INVALID_SPAN_CONTEXT}});var ps=Qb();Object.defineProperty(X,\"context\",{enumerable:!0,get:function(){return ps.context}});var ms=rv();Object.defineProperty(X,\"diag\",{enumerable:!0,get:function(){return ms.diag}});var fs=gv();Object.defineProperty(X,\"metrics\",{enumerable:!0,get:function(){return fs.metrics}});var gs=Mv();Object.defineProperty(X,\"propagation\",{enumerable:!0,get:function(){return gs.propagation}});var hs=Lv();Object.defineProperty(X,\"trace\",{enumerable:!0,get:function(){return hs.trace}});X.default={context:ps.context,diag:ms.diag,metrics:fs.metrics,propagation:gs.propagation,trace:hs.trace}});var Fv=g(function(sH,Cc){var ys=Vv(),Ac=Aa();Cc.exports=(e,t={})=>{let n=e?[e]:void 0,r=t.prefix?t.prefix:\"\",o=t.labels?t.labels:{},s=t.enableExemplars?t.enableExemplars:!1,i=Object.keys(o),a=process.cpuUsage(),c=new Ac({name:r+\"process_cpu_user_seconds_total\",help:\"Total user CPU time spent in seconds.\",enableExemplars:s,registers:n,labelNames:i,collect(){let p=process.cpuUsage(),m=p.user-a.user,d=p.system-a.system;if(a=p,this.enableExemplars){let f={},h=ys.trace.getSpan(ys.context.active());if(h)f={traceId:h.spanContext().traceId,spanId:h.spanContext().spanId};c.inc({labels:o,value:m/1e6,exemplarLabels:f}),l.inc({labels:o,value:d/1e6,exemplarLabels:f}),u.inc({labels:o,value:(m+d)/1e6,exemplarLabels:f})}else c.inc(o,m/1e6),l.inc(o,d/1e6),u.inc(o,(m+d)/1e6)}}),l=new Ac({name:r+\"process_cpu_system_seconds_total\",help:\"Total system CPU time spent in seconds.\",enableExemplars:s,registers:n,labelNames:i}),u=new Ac({name:r+\"process_cpu_seconds_total\",help:\"Total user and system CPU time spent in seconds.\",enableExemplars:s,registers:n,labelNames:i})};Cc.exports.metricNames=[\"process_cpu_user_seconds_total\",\"process_cpu_system_seconds_total\",\"process_cpu_seconds_total\"]});var Jv=g(function(iH,Ec){var rO=Ae(),oO=Math.round(Date.now()/1000-process.uptime());Ec.exports=(e,t={})=>{let n=t.prefix?t.prefix:\"\",r=t.labels?t.labels:{},o=Object.keys(r);new rO({name:n+\"process_start_time_seconds\",help:\"Start time of the process since unix epoch in seconds.\",registers:e?[e]:void 0,labelNames:o,aggregator:\"omit\",collect(){this.set(r,oO)}})};Ec.exports.metricNames=[\"process_start_time_seconds\"]});var Kv=g(function(aH,Oc){var Pc=Ae(),Wv=_e(\"fs\"),sO=[\"VmSize\",\"VmRSS\",\"VmData\"];function iO(e){return e.split(`\n`).reduce((t,n)=>{if(!sO.some((s)=>n.startsWith(s)))return t;let r=n.split(\":\"),o=r[1].trim();return o=o.substr(0,o.length-3),o=Number(o)*1024,t[r[0]]=o,t},{})}Oc.exports=(e,t={})=>{let n=e?[e]:void 0,r=t.prefix?t.prefix:\"\",o=t.labels?t.labels:{},s=Object.keys(o),i=new Pc({name:r+\"process_resident_memory_bytes\",help:\"Resident memory size in bytes.\",registers:n,labelNames:s,collect(){try{let l=Wv.readFileSync(\"/proc/self/status\",\"utf8\"),u=iO(l);i.set(o,u.VmRSS),a.set(o,u.VmSize),c.set(o,u.VmData)}catch{}}}),a=new Pc({name:r+\"process_virtual_memory_bytes\",help:\"Virtual memory size in bytes.\",registers:n,labelNames:s}),c=new Pc({name:r+\"process_heap_bytes\",help:\"Process heap size in bytes.\",registers:n,labelNames:s})};Oc.exports.metricNames=[\"process_resident_memory_bytes\",\"process_virtual_memory_bytes\",\"process_heap_bytes\"]});var $c=g(function(cH,Hv){function aO(){try{return process.memoryUsage()}catch{return}}Hv.exports=aO});var Zv=g(function(lH,qc){var cO=Ae(),Mc=Kv(),lO=$c();function uO(e,t={}){let n=t.prefix?t.prefix:\"\",r=t.labels?t.labels:{},o=Object.keys(r);new cO({name:n+\"process_resident_memory_bytes\",help:\"Resident memory size in bytes.\",registers:e?[e]:void 0,labelNames:o,collect(){let s=lO();if(s)this.set(r,s.rss)}})}qc.exports=(e,t)=>process.platform===\"linux\"?Mc(e,t):uO(e,t);qc.exports.metricNames=process.platform===\"linux\"?Mc.metricNames:[\"process_resident_memory_bytes\"]});var Qv=g(function(uH,zc){var dO=Ae(),Yv=_e(\"fs\"),Xv=_e(\"process\");zc.exports=(e,t={})=>{if(Xv.platform!==\"linux\")return;let n=t.prefix?t.prefix:\"\",r=t.labels?t.labels:{},o=Object.keys(r);new dO({name:n+\"process_open_fds\",help:\"Number of open file descriptors.\",registers:e?[e]:void 0,labelNames:o,collect(){try{let s=Yv.readdirSync(\"/proc/self/fd\");this.set(r,s.length-1)}catch{}}})};zc.exports.metricNames=[\"process_open_fds\"]});var t_=g(function(dH,jc){var pO=Ae(),e_=_e(\"fs\"),Wr;jc.exports=(e,t={})=>{if(Wr===void 0)try{let i=e_.readFileSync(\"/proc/self/limits\",\"utf8\").split(`\n`);for(let a of i)if(a.startsWith(\"Max open files\")){let c=a.split(/ +/);Wr=Number(c[1]);break}}catch{return}if(Wr===void 0)return;let n=t.prefix?t.prefix:\"\",r=t.labels?t.labels:{},o=Object.keys(r);new pO({name:n+\"process_max_fds\",help:\"Maximum number of open file descriptors.\",registers:e?[e]:void 0,labelNames:o,collect(){if(Wr!==void 0)this.set(r,Wr)}})};jc.exports.metricNames=[\"process_max_fds\"]});var d_=g(function(pH,Nc){var zt=Ae(),bs;try{bs=_e(\"perf_hooks\")}catch{}var r_=\"nodejs_eventloop_lag_seconds\",o_=\"nodejs_eventloop_lag_min_seconds\",s_=\"nodejs_eventloop_lag_max_seconds\",i_=\"nodejs_eventloop_lag_mean_seconds\",a_=\"nodejs_eventloop_lag_stddev_seconds\",c_=\"nodejs_eventloop_lag_p50_seconds\",l_=\"nodejs_eventloop_lag_p90_seconds\",u_=\"nodejs_eventloop_lag_p99_seconds\";function n_(e,t,n){let r=process.hrtime(e),s=(r[0]*1e9+r[1])/1e9;t.set(n,s)}Nc.exports=(e,t={})=>{let n=t.prefix?t.prefix:\"\",r=t.labels?t.labels:{},o=Object.keys(r),s=e?[e]:void 0,i=()=>{let h=process.hrtime();setImmediate(n_,h,a,r)};if(bs&&bs.monitorEventLoopDelay)try{let h=bs.monitorEventLoopDelay({resolution:t.eventLoopMonitoringPrecision});h.enable(),i=()=>{let y=process.hrtime();setImmediate(n_,y,a,r),c.set(r,h.min/1e9),l.set(r,h.max/1e9),u.set(r,h.mean/1e9),p.set(r,h.stddev/1e9),m.set(r,h.percentile(50)/1e9),d.set(r,h.percentile(90)/1e9),f.set(r,h.percentile(99)/1e9),h.reset()}}catch(h){if(h.code===\"ERR_NOT_IMPLEMENTED\")return;throw h}let a=new zt({name:n+r_,help:\"Lag of event loop in seconds.\",registers:s,labelNames:o,aggregator:\"average\",collect:i}),c=new zt({name:n+o_,help:\"The minimum recorded event loop delay.\",registers:s,labelNames:o,aggregator:\"min\"}),l=new zt({name:n+s_,help:\"The maximum recorded event loop delay.\",registers:s,labelNames:o,aggregator:\"max\"}),u=new zt({name:n+i_,help:\"The mean of the recorded event loop delays.\",registers:s,labelNames:o,aggregator:\"average\"}),p=new zt({name:n+a_,help:\"The standard deviation of the recorded event loop delays.\",registers:s,labelNames:o,aggregator:\"average\"}),m=new zt({name:n+c_,help:\"The 50th percentile of the recorded event loop delays.\",registers:s,labelNames:o,aggregator:\"average\"}),d=new zt({name:n+l_,help:\"The 90th percentile of the recorded event loop delays.\",registers:s,labelNames:o,aggregator:\"average\"}),f=new zt({name:n+u_,help:\"The 99th percentile of the recorded event loop delays.\",registers:s,labelNames:o,aggregator:\"average\"})};Nc.exports.metricNames=[r_,o_,s_,i_,a_,c_,l_,u_]});var Zn=g(function(mH,p_){function mO(e){let t={};for(let n=0;n<e.length;n++){let r=e[n];if(!r||typeof r.constructor>\"u\")continue;if(Object.hasOwnProperty.call(t,r.constructor.name))t[r.constructor.name]+=1;else t[r.constructor.name]=1}return t}function fO(e,t,n){e.reset();for(let r in t)e.set(Object.assign({type:r},n||{}),t[r])}p_.exports={aggregateByObjectName:mO,updateMetrics:fO}});var f_=g(function(fH,Dc){var{aggregateByObjectName:gO}=Zn(),{updateMetrics:hO}=Zn(),m_=Ae();Dc.exports=(e,t={})=>{if(typeof process._getActiveHandles!==\"function\")return;let n=e?[e]:void 0,r=t.prefix?t.prefix:\"\",o=t.labels?t.labels:{},s=Object.keys(o);new m_({name:r+\"nodejs_active_handles\",help:\"Number of active libuv handles grouped by handle type. Every handle type is C++ class name.\",labelNames:[\"type\",...s],registers:n,collect(){let i=process._getActiveHandles();hO(this,gO(i),o)}}),new m_({name:r+\"nodejs_active_handles_total\",help:\"Total number of active handles.\",registers:n,labelNames:s,collect(){let i=process._getActiveHandles();this.set(o,i.length)}})};Dc.exports.metricNames=[\"nodejs_active_handles\",\"nodejs_active_handles_total\"]});var h_=g(function(gH,Uc){var g_=Ae(),{aggregateByObjectName:yO}=Zn(),{updateMetrics:bO}=Zn();Uc.exports=(e,t={})=>{if(typeof process._getActiveRequests!==\"function\")return;let n=t.prefix?t.prefix:\"\",r=t.labels?t.labels:{},o=Object.keys(r);new g_({name:n+\"nodejs_active_requests\",help:\"Number of active libuv requests grouped by request type. Every request type is C++ class name.\",labelNames:[\"type\",...o],registers:e?[e]:void 0,collect(){let s=process._getActiveRequests();bO(this,yO(s),r)}}),new g_({name:n+\"nodejs_active_requests_total\",help:\"Total number of active requests.\",registers:e?[e]:void 0,labelNames:o,collect(){let s=process._getActiveRequests();this.set(r,s.length)}})};Uc.exports.metricNames=[\"nodejs_active_requests\",\"nodejs_active_requests_total\"]});var b_=g(function(hH,Lc){var y_=Ae(),{updateMetrics:vO}=Zn();Lc.exports=(e,t={})=>{if(typeof process.getActiveResourcesInfo!==\"function\")return;let n=t.prefix?t.prefix:\"\",r=t.labels?t.labels:{},o=Object.keys(r);new y_({name:n+\"nodejs_active_resources\",help:\"Number of active resources that are currently keeping the event loop alive, grouped by async resource type.\",labelNames:[\"type\",...o],registers:e?[e]:void 0,collect(){let s=process.getActiveResourcesInfo(),i={};for(let a=0;a<s.length;a++){let c=s[a];if(Object.hasOwn(i,c))i[c]+=1;else i[c]=1}vO(this,i,r)}}),new y_({name:n+\"nodejs_active_resources_total\",help:\"Total number of active resources.\",registers:e?[e]:void 0,labelNames:o,collect(){let s=process.getActiveResourcesInfo();this.set(r,s.length)}})};Lc.exports.metricNames=[\"nodejs_active_resources\",\"nodejs_active_resources_total\"]});var v_=g(function(yH,Bc){var Gc=Ae(),_O=$c();Bc.exports=(e,t={})=>{if(typeof process.memoryUsage!==\"function\")return;let n=t.labels?t.labels:{},r=Object.keys(n),o=e?[e]:void 0,s=t.prefix?t.prefix:\"\",i=()=>{let u=_O();if(u){if(a.set(n,u.heapTotal),c.set(n,u.heapUsed),u.external!==void 0)l.set(n,u.external)}},a=new Gc({name:s+\"nodejs_heap_size_total_bytes\",help:\"Process heap size from Node.js in bytes.\",registers:o,labelNames:r,collect:i}),c=new Gc({name:s+\"nodejs_heap_size_used_bytes\",help:\"Process heap size used from Node.js in bytes.\",registers:o,labelNames:r}),l=new Gc({name:s+\"nodejs_external_memory_bytes\",help:\"Node.js external memory size in bytes.\",registers:o,labelNames:r})};Bc.exports.metricNames=[\"nodejs_heap_size_total_bytes\",\"nodejs_heap_size_used_bytes\",\"nodejs_external_memory_bytes\"]});var w_=g(function(bH,Fc){var wO=Ae(),vs=_e(\"v8\"),__=[\"total\",\"used\",\"available\"],Vc={};__.forEach((e)=>{Vc[e]=`nodejs_heap_space_size_${e}_bytes`});Fc.exports=(e,t={})=>{try{vs.getHeapSpaceStatistics()}catch(a){if(a.code===\"ERR_NOT_IMPLEMENTED\")return;throw a}let n=e?[e]:void 0,r=t.prefix?t.prefix:\"\",o=t.labels?t.labels:{},s=[\"space\",...Object.keys(o)],i={};__.forEach((a)=>{i[a]=new wO({name:r+Vc[a],help:`Process heap space size ${a} from Node.js in bytes.`,labelNames:s,registers:n})}),i.total.collect=()=>{for(let a of vs.getHeapSpaceStatistics()){let c=a.space_name.substr(0,a.space_name.indexOf(\"_space\"));i.total.set({space:c,...o},a.space_size),i.used.set({space:c,...o},a.space_used_size),i.available.set({space:c,...o},a.space_available_size)}}};Fc.exports.metricNames=Object.values(Vc)});var S_=g(function(vH,Wc){var xO=Ae(),x_=process.version,Jc=x_.slice(1).split(\".\").map(Number);Wc.exports=(e,t={})=>{let n=t.prefix?t.prefix:\"\",r=t.labels?t.labels:{},o=Object.keys(r);new xO({name:n+\"nodejs_version_info\",help:\"Node.js version info.\",labelNames:[\"version\",\"major\",\"minor\",\"patch\",...o],registers:e?[e]:void 0,aggregator:\"first\",collect(){this.labels(x_,Jc[0],Jc[1],Jc[2],...Object.values(r)).set(1)}})};Wc.exports.metricNames=[\"nodejs_version_info\"]});var k_=g(function(_H,Kc){var SO=Ma(),_t;try{_t=_e(\"perf_hooks\")}catch{}var I_=\"nodejs_gc_duration_seconds\",IO=[0.001,0.01,0.1,1,2,5],Yn=[];if(_t&&_t.constants)Yn[_t.constants.NODE_PERFORMANCE_GC_MAJOR]=\"major\",Yn[_t.constants.NODE_PERFORMANCE_GC_MINOR]=\"minor\",Yn[_t.constants.NODE_PERFORMANCE_GC_INCREMENTAL]=\"incremental\",Yn[_t.constants.NODE_PERFORMANCE_GC_WEAKCB]=\"weakcb\";Kc.exports=(e,t={})=>{if(!_t)return;let n=t.prefix?t.prefix:\"\",r=t.labels?t.labels:{},o=Object.keys(r),s=t.gcDurationBuckets?t.gcDurationBuckets:IO,i=new SO({name:n+I_,help:\"Garbage collection duration by kind, one of major, minor, incremental or weakcb.\",labelNames:[\"kind\",...o],enableExemplars:!1,buckets:s,registers:e?[e]:void 0});new _t.PerformanceObserver((c)=>{let l=c.getEntries()[0],u=l.detail?Yn[l.detail.kind]:Yn[l.kind];i.observe(Object.assign({kind:u},r),l.duration/1000)}).observe({entryTypes:[\"gc\"]})};Kc.exports.metricNames=[I_]});var T_=g(function(wH,Hc){var{isObject:kO}=et(),RO=Fv(),TO=Jv(),AO=Zv(),CO=Qv(),EO=t_(),PO=d_(),OO=f_(),$O=h_(),MO=b_(),qO=v_(),zO=w_(),jO=S_(),NO=k_(),R_={processCpuTotal:RO,processStartTime:TO,osMemoryHeap:AO,processOpenFileDescriptors:CO,processMaxFileDescriptors:EO,eventLoopLag:PO,...typeof process.getActiveResourcesInfo===\"function\"?{processResources:MO}:{},processHandles:OO,processRequests:$O,heapSizeAndUsed:qO,heapSpacesSizeAndUsed:zO,version:jO,gc:NO},DO=Object.keys(R_);Hc.exports=function(t){if(t!==null&&t!==void 0&&!kO(t))throw TypeError(\"config must be null, undefined, or an object\");t={eventLoopMonitoringPrecision:10,...t};for(let n of Object.values(R_))n(t.register,t)};Hc.exports.metricsList=DO});var Zc=g(function(GO){var{Grouper:UO,hashObject:LO}=et();function Xn(e){return(t)=>{if(t.length===0)return;let n={help:t[0].help,name:t[0].name,type:t[0].type,values:[],aggregator:t[0].aggregator},r=new UO;return t.forEach((o)=>{o.values.forEach((s)=>{let i=LO(s.labels);r.add(`${s.metricName}_${i}`,s)})}),r.forEach((o)=>{if(o.length===0)return;let s={value:e(o),labels:o[0].labels};if(o[0].metricName)s.metricName=o[0].metricName;n.values.push(s)}),n}}GO.AggregatorFactory=Xn;GO.aggregators={sum:Xn((e)=>e.reduce((t,n)=>t+n.value,0)),first:Xn((e)=>e[0].value),omit:()=>{},average:Xn((e)=>e.reduce((t,n)=>t+n.value,0)/e.length),min:Xn((e)=>e.reduce((t,n)=>Math.min(t,n.value),1/0)),max:Xn((e)=>e.reduce((t,n)=>Math.max(t,n.value),-1/0))}});var O_=g(function(SH,P_){var wt=Nn(),{Grouper:FO}=et(),{aggregators:JO}=Zc(),_n=()=>{let e=_e(\"cluster\");return _n=()=>e,e},C_=\"prom-client:getMetricsReq\",Yc=\"prom-client:getMetricsRes\",E_=[wt.globalRegistry],WO=0,A_=!1,Xc=new Map;class Qc extends wt{constructor(e=wt.PROMETHEUS_CONTENT_TYPE){super(e);KO()}clusterMetrics(){let e=WO++;return new Promise((t,n)=>{let r=!1;function o(a,c){if(r)return;if(r=!0,a)n(a);else t(c)}let s={responses:[],pending:0,done:o,errorTimeout:setTimeout(()=>{let a=Error(\"Operation timed out.\");s.done(a)},5000)};Xc.set(e,s);let i={type:C_,requestId:e};for(let a in _n().workers)if(_n().workers[a].isConnected())_n().workers[a].send(i),s.pending++;if(s.pending===0)clearTimeout(s.errorTimeout),process.nextTick(()=>o(null,\"\"))})}get contentType(){return super.contentType}static aggregate(e,t=wt.PROMETHEUS_CONTENT_TYPE){let n=new wt,r=new FO;return n.setContentType(t),e.forEach((o)=>{o.forEach((s)=>{r.add(s.name,s)})}),r.forEach((o)=>{let s=o[0].aggregator,i=JO[s];if(typeof i!==\"function\")throw Error(`'${s}' is not a defined aggregator.`);let a=i(o);if(a){let c=Object.assign({get:()=>a},a);n.registerMetric(c)}}),n}static setRegistries(e){if(!Array.isArray(e))e=[e];e.forEach((t)=>{if(!(t instanceof wt))throw TypeError(`Expected Registry, got ${typeof t}`)}),E_=e}}function KO(){if(A_)return;if(A_=!0,_n().isMaster)_n().on(\"message\",(e,t)=>{if(t.type===Yc){let n=Xc.get(t.requestId);if(t.error){n.done(Error(t.error));return}if(t.metrics.forEach((r)=>n.responses.push(r)),n.pending--,n.pending===0){Xc.delete(t.requestId),clearTimeout(n.errorTimeout);let o=Qc.aggregate(n.responses).metrics();n.done(null,o)}}});if(_n().isWorker)process.on(\"message\",(e)=>{if(e.type===C_)Promise.all(E_.map((t)=>t.getMetricsAsJSON())).then((t)=>{process.send({type:Yc,requestId:e.requestId,metrics:t})}).catch((t)=>{process.send({type:Yc,requestId:e.requestId,error:t.message})})})}P_.exports=Qc});var M_=g(function($_){$_.register=Nn().globalRegistry;$_.Registry=Nn();Object.defineProperty($_,\"contentType\",{configurable:!1,enumerable:!0,get(){return $_.register.contentType},set(e){$_.register.setContentType(e)}});$_.prometheusContentType=$_.Registry.PROMETHEUS_CONTENT_TYPE;$_.openMetricsContentType=$_.Registry.OPENMETRICS_CONTENT_TYPE;$_.validateMetricName=yn().validateMetricName;$_.Counter=Aa();$_.Gauge=Ae();$_.Histogram=Ma();$_.Summary=Ph();$_.Pushgateway=Mh();$_.linearBuckets=Da().linearBuckets;$_.exponentialBuckets=Da().exponentialBuckets;$_.collectDefaultMetrics=T_();$_.aggregators=Zc().aggregators;$_.AggregatorRegistry=O_()});var Xr=g(function(U_){Object.defineProperty(U_,\"__esModule\",{value:!0});U_.regexpCode=U_.getEsmExportName=U_.getProperty=U_.safeStringify=U_.stringify=U_.strConcat=U_.addCodeArg=U_.str=U_._=U_.nil=U_._Code=U_.Name=U_.IDENTIFIER=U_._CodeOrName=void 0;class xs{}U_._CodeOrName=xs;U_.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;class Qn extends xs{constructor(e){super();if(!U_.IDENTIFIER.test(e))throw Error(\"CodeGen: name must be a valid identifier\");this.str=e}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}}U_.Name=Qn;class Ye extends xs{constructor(e){super();this._items=typeof e===\"string\"?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let e=this._items[0];return e===\"\"||e==='\"\"'}get str(){var e;return(e=this._str)!==null&&e!==void 0?e:this._str=this._items.reduce((t,n)=>`${t}${n}`,\"\")}get names(){var e;return(e=this._names)!==null&&e!==void 0?e:this._names=this._items.reduce((t,n)=>{if(n instanceof Qn)t[n.str]=(t[n.str]||0)+1;return t},{})}}U_._Code=Ye;U_.nil=new Ye(\"\");function N_(e,...t){let n=[e[0]],r=0;while(r<t.length)il(n,t[r]),n.push(e[++r]);return new Ye(n)}U_._=N_;var sl=new Ye(\"+\");function D_(e,...t){let n=[Yr(e[0])],r=0;while(r<t.length)n.push(sl),il(n,t[r]),n.push(sl,Yr(e[++r]));return g$(n),new Ye(n)}U_.str=D_;function il(e,t){if(t instanceof Ye)e.push(...t._items);else if(t instanceof Qn)e.push(t);else e.push(b$(t))}U_.addCodeArg=il;function g$(e){let t=1;while(t<e.length-1){if(e[t]===sl){let n=h$(e[t-1],e[t+1]);if(n!==void 0){e.splice(t-1,3,n);continue}e[t++]=\"+\"}t++}}function h$(e,t){if(t==='\"\"')return e;if(e==='\"\"')return t;if(typeof e==\"string\"){if(t instanceof Qn||e[e.length-1]!=='\"')return;if(typeof t!=\"string\")return`${e.slice(0,-1)}${t}\"`;if(t[0]==='\"')return e.slice(0,-1)+t.slice(1);return}if(typeof t==\"string\"&&t[0]==='\"'&&!(e instanceof Qn))return`\"${e}${t.slice(1)}`;return}function y$(e,t){return t.emptyStr()?e:e.emptyStr()?t:D_`${e}${t}`}U_.strConcat=y$;function b$(e){return typeof e==\"number\"||typeof e==\"boolean\"||e===null?e:Yr(Array.isArray(e)?e.join(\",\"):e)}function v$(e){return new Ye(Yr(e))}U_.stringify=v$;function Yr(e){return JSON.stringify(e).replace(/\\u2028/g,\"\\\\u2028\").replace(/\\u2029/g,\"\\\\u2029\")}U_.safeStringify=Yr;function _$(e){return typeof e==\"string\"&&U_.IDENTIFIER.test(e)?new Ye(`.${e}`):N_`[${e}]`}U_.getProperty=_$;function w$(e){if(typeof e==\"string\"&&U_.IDENTIFIER.test(e))return new Ye(`${e}`);throw Error(`CodeGen: invalid export name: ${e}, use explicit $id name mapping`)}U_.getEsmExportName=w$;function x$(e){return new Ye(e.toString())}U_.regexpCode=x$});var ul=g(function(V_){Object.defineProperty(V_,\"__esModule\",{value:!0});V_.ValueScope=V_.ValueScopeName=V_.Scope=V_.varKinds=V_.UsedValueState=void 0;var Q=Xr();class G_ extends Error{constructor(e){super(`CodeGen: \"code\" for ${e} not defined`);this.value=e.value}}var Is;(function(e){e[e.Started=0]=\"Started\",e[e.Completed=1]=\"Completed\"})(Is||(V_.UsedValueState=Is={}));V_.varKinds={const:new Q.Name(\"const\"),let:new Q.Name(\"let\"),var:new Q.Name(\"var\")};class cl{constructor({prefixes:e,parent:t}={}){this._names={},this._prefixes=e,this._parent=t}toName(e){return e instanceof Q.Name?e:this.name(e)}name(e){return new Q.Name(this._newName(e))}_newName(e){let t=this._names[e]||this._nameGroup(e);return`${e}${t.index++}`}_nameGroup(e){var t,n;if(((n=(t=this._parent)===null||t===void 0?void 0:t._prefixes)===null||n===void 0?void 0:n.has(e))||this._prefixes&&!this._prefixes.has(e))throw Error(`CodeGen: prefix \"${e}\" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}}V_.Scope=cl;class ll extends Q.Name{constructor(e,t){super(t);this.prefix=e}setValue(e,{property:t,itemIndex:n}){this.value=e,this.scopePath=Q._`.${new Q.Name(t)}[${n}]`}}V_.ValueScopeName=ll;var q$=Q._`\\n`;class B_ extends cl{constructor(e){super(e);this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?q$:Q.nil}}get(){return this._scope}name(e){return new ll(e,this._newName(e))}value(e,t){var n;if(t.ref===void 0)throw Error(\"CodeGen: ref must be passed in value\");let r=this.toName(e),{prefix:o}=r,s=(n=t.key)!==null&&n!==void 0?n:t.ref,i=this._values[o];if(i){let l=i.get(s);if(l)return l}else i=this._values[o]=new Map;i.set(s,r);let a=this._scope[o]||(this._scope[o]=[]),c=a.length;return a[c]=t.ref,r.setValue(t,{property:o,itemIndex:c}),r}getValue(e,t){let n=this._values[e];if(!n)return;return n.get(t)}scopeRefs(e,t=this._values){return this._reduceValues(t,(n)=>{if(n.scopePath===void 0)throw Error(`CodeGen: name \"${n}\" has no value`);return Q._`${e}${n.scopePath}`})}scopeCode(e=this._values,t,n){return this._reduceValues(e,(r)=>{if(r.value===void 0)throw Error(`CodeGen: name \"${r}\" has no value`);return r.value.code},t,n)}_reduceValues(e,t,n={},r){let o=Q.nil;for(let s in e){let i=e[s];if(!i)continue;let a=n[s]=n[s]||new Map;i.forEach((c)=>{if(a.has(c))return;a.set(c,Is.Started);let l=t(c);if(l){let u=this.opts.es5?V_.varKinds.var:V_.varKinds.const;o=Q._`${o}${u} ${c} = ${l};${this.opts._n}`}else if(l=r===null||r===void 0?void 0:r(c))o=Q._`${o}${l}${this.opts._n}`;else throw new G_(c);a.set(c,Is.Completed)})}return o}}V_.ValueScope=B_});var N=g(function(Ce){Object.defineProperty(Ce,\"__esModule\",{value:!0});Ce.or=Ce.and=Ce.not=Ce.CodeGen=Ce.operators=Ce.varKinds=Ce.ValueScopeName=Ce.ValueScope=Ce.Scope=Ce.Name=Ce.regexpCode=Ce.stringify=Ce.getProperty=Ce.nil=Ce.strConcat=Ce.str=Ce._=void 0;var k=Xr(),ue=ul(),jt=Xr();Object.defineProperty(Ce,\"_\",{enumerable:!0,get:function(){return jt._}});Object.defineProperty(Ce,\"str\",{enumerable:!0,get:function(){return jt.str}});Object.defineProperty(Ce,\"strConcat\",{enumerable:!0,get:function(){return jt.strConcat}});Object.defineProperty(Ce,\"nil\",{enumerable:!0,get:function(){return jt.nil}});Object.defineProperty(Ce,\"getProperty\",{enumerable:!0,get:function(){return jt.getProperty}});Object.defineProperty(Ce,\"stringify\",{enumerable:!0,get:function(){return jt.stringify}});Object.defineProperty(Ce,\"regexpCode\",{enumerable:!0,get:function(){return jt.regexpCode}});Object.defineProperty(Ce,\"Name\",{enumerable:!0,get:function(){return jt.Name}});var Es=ul();Object.defineProperty(Ce,\"Scope\",{enumerable:!0,get:function(){return Es.Scope}});Object.defineProperty(Ce,\"ValueScope\",{enumerable:!0,get:function(){return Es.ValueScope}});Object.defineProperty(Ce,\"ValueScopeName\",{enumerable:!0,get:function(){return Es.ValueScopeName}});Object.defineProperty(Ce,\"varKinds\",{enumerable:!0,get:function(){return Es.varKinds}});Ce.operators={GT:new k._Code(\">\"),GTE:new k._Code(\">=\"),LT:new k._Code(\"<\"),LTE:new k._Code(\"<=\"),EQ:new k._Code(\"===\"),NEQ:new k._Code(\"!==\"),NOT:new k._Code(\"!\"),OR:new k._Code(\"||\"),AND:new k._Code(\"&&\"),ADD:new k._Code(\"+\")};class Nt{optimizeNodes(){return this}optimizeNames(e,t){return this}}class J_ extends Nt{constructor(e,t,n){super();this.varKind=e,this.name=t,this.rhs=n}render({es5:e,_n:t}){let n=e?ue.varKinds.var:this.varKind,r=this.rhs===void 0?\"\":` = ${this.rhs}`;return`${n} ${this.name}${r};`+t}optimizeNames(e,t){if(!e[this.name.str])return;if(this.rhs)this.rhs=tr(this.rhs,e,t);return this}get names(){return this.rhs instanceof k._CodeOrName?this.rhs.names:{}}}class ml extends Nt{constructor(e,t,n){super();this.lhs=e,this.rhs=t,this.sideEffects=n}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,t){if(this.lhs instanceof k.Name&&!e[this.lhs.str]&&!this.sideEffects)return;return this.rhs=tr(this.rhs,e,t),this}get names(){let e=this.lhs instanceof k.Name?{}:{...this.lhs.names};return Cs(e,this.rhs)}}class W_ extends ml{constructor(e,t,n,r){super(e,n,r);this.op=t}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}}class K_ extends Nt{constructor(e){super();this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}}class H_ extends Nt{constructor(e){super();this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:\"\"};`+e}}class Z_ extends Nt{constructor(e){super();this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}}class Y_ extends Nt{constructor(e){super();this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,t){return this.code=tr(this.code,e,t),this}get names(){return this.code instanceof k._CodeOrName?this.code.names:{}}}class Ps extends Nt{constructor(e=[]){super();this.nodes=e}render(e){return this.nodes.reduce((t,n)=>t+n.render(e),\"\")}optimizeNodes(){let{nodes:e}=this,t=e.length;while(t--){let n=e[t].optimizeNodes();if(Array.isArray(n))e.splice(t,1,...n);else if(n)e[t]=n;else e.splice(t,1)}return e.length>0?this:void 0}optimizeNames(e,t){let{nodes:n}=this,r=n.length;while(r--){let o=n[r];if(o.optimizeNames(e,t))continue;D$(e,o.names),n.splice(r,1)}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,t)=>wn(e,t.names),{})}}class Dt extends Ps{render(e){return\"{\"+e._n+super.render(e)+\"}\"+e._n}}class X_ extends Ps{}class Qr extends Dt{}Qr.kind=\"else\";class xt extends Dt{constructor(e,t){super(t);this.condition=e}render(e){let t=`if(${this.condition})`+super.render(e);if(this.else)t+=\"else \"+this.else.render(e);return t}optimizeNodes(){super.optimizeNodes();let e=this.condition;if(e===!0)return this.nodes;let t=this.else;if(t){let n=t.optimizeNodes();t=this.else=Array.isArray(n)?new Qr(n):n}if(t){if(e===!1)return t instanceof xt?t:t.nodes;if(this.nodes.length)return this;return new xt(rw(e),t instanceof xt?[t]:t.nodes)}if(e===!1||!this.nodes.length)return;return this}optimizeNames(e,t){var n;if(this.else=(n=this.else)===null||n===void 0?void 0:n.optimizeNames(e,t),!(super.optimizeNames(e,t)||this.else))return;return this.condition=tr(this.condition,e,t),this}get names(){let e=super.names;if(Cs(e,this.condition),this.else)wn(e,this.else.names);return e}}xt.kind=\"if\";class er extends Dt{}er.kind=\"for\";class Q_ extends er{constructor(e){super();this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,t){if(!super.optimizeNames(e,t))return;return this.iteration=tr(this.iteration,e,t),this}get names(){return wn(super.names,this.iteration.names)}}class ew extends er{constructor(e,t,n,r){super();this.varKind=e,this.name=t,this.from=n,this.to=r}render(e){let t=e.es5?ue.varKinds.var:this.varKind,{name:n,from:r,to:o}=this;return`for(${t} ${n}=${r}; ${n}<${o}; ${n}++)`+super.render(e)}get names(){let e=Cs(super.names,this.from);return Cs(e,this.to)}}class dl extends er{constructor(e,t,n,r){super();this.loop=e,this.varKind=t,this.name=n,this.iterable=r}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,t){if(!super.optimizeNames(e,t))return;return this.iterable=tr(this.iterable,e,t),this}get names(){return wn(super.names,this.iterable.names)}}class ks extends Dt{constructor(e,t,n){super();this.name=e,this.args=t,this.async=n}render(e){return`${this.async?\"async \":\"\"}function ${this.name}(${this.args})`+super.render(e)}}ks.kind=\"func\";class Rs extends Ps{render(e){return\"return \"+super.render(e)}}Rs.kind=\"return\";class tw extends Dt{render(e){let t=\"try\"+super.render(e);if(this.catch)t+=this.catch.render(e);if(this.finally)t+=this.finally.render(e);return t}optimizeNodes(){var e,t;return super.optimizeNodes(),(e=this.catch)===null||e===void 0||e.optimizeNodes(),(t=this.finally)===null||t===void 0||t.optimizeNodes(),this}optimizeNames(e,t){var n,r;return super.optimizeNames(e,t),(n=this.catch)===null||n===void 0||n.optimizeNames(e,t),(r=this.finally)===null||r===void 0||r.optimizeNames(e,t),this}get names(){let e=super.names;if(this.catch)wn(e,this.catch.names);if(this.finally)wn(e,this.finally.names);return e}}class Ts extends Dt{constructor(e){super();this.error=e}render(e){return`catch(${this.error})`+super.render(e)}}Ts.kind=\"catch\";class As extends Dt{render(e){return\"finally\"+super.render(e)}}As.kind=\"finally\";class nw{constructor(e,t={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...t,_n:t.lines?`\n`:\"\"},this._extScope=e,this._scope=new ue.Scope({parent:e}),this._nodes=[new X_]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,t){let n=this._extScope.value(e,t);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(e,t){return this._extScope.getValue(e,t)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,t,n,r){let o=this._scope.toName(t);if(n!==void 0&&r)this._constants[o.str]=n;return this._leafNode(new J_(e,o,n)),o}const(e,t,n){return this._def(ue.varKinds.const,e,t,n)}let(e,t,n){return this._def(ue.varKinds.let,e,t,n)}var(e,t,n){return this._def(ue.varKinds.var,e,t,n)}assign(e,t,n){return this._leafNode(new ml(e,t,n))}add(e,t){return this._leafNode(new W_(e,Ce.operators.ADD,t))}code(e){if(typeof e==\"function\")e();else if(e!==k.nil)this._leafNode(new Y_(e));return this}object(...e){let t=[\"{\"];for(let[n,r]of e){if(t.length>1)t.push(\",\");if(t.push(n),n!==r||this.opts.es5)t.push(\":\"),k.addCodeArg(t,r)}return t.push(\"}\"),new k._Code(t)}if(e,t,n){if(this._blockNode(new xt(e)),t&&n)this.code(t).else().code(n).endIf();else if(t)this.code(t).endIf();else if(n)throw Error('CodeGen: \"else\" body without \"then\" body');return this}elseIf(e){return this._elseNode(new xt(e))}else(){return this._elseNode(new Qr)}endIf(){return this._endBlockNode(xt,Qr)}_for(e,t){if(this._blockNode(e),t)this.code(t).endFor();return this}for(e,t){return this._for(new Q_(e),t)}forRange(e,t,n,r,o=this.opts.es5?ue.varKinds.var:ue.varKinds.let){let s=this._scope.toName(e);return this._for(new ew(o,s,t,n),()=>r(s))}forOf(e,t,n,r=ue.varKinds.const){let o=this._scope.toName(e);if(this.opts.es5){let s=t instanceof k.Name?t:this.var(\"_arr\",t);return this.forRange(\"_i\",0,k._`${s}.length`,(i)=>{this.var(o,k._`${s}[${i}]`),n(o)})}return this._for(new dl(\"of\",r,o,t),()=>n(o))}forIn(e,t,n,r=this.opts.es5?ue.varKinds.var:ue.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,k._`Object.keys(${t})`,n);let o=this._scope.toName(e);return this._for(new dl(\"in\",r,o,t),()=>n(o))}endFor(){return this._endBlockNode(er)}label(e){return this._leafNode(new K_(e))}break(e){return this._leafNode(new H_(e))}return(e){let t=new Rs;if(this._blockNode(t),this.code(e),t.nodes.length!==1)throw Error('CodeGen: \"return\" should have one node');return this._endBlockNode(Rs)}try(e,t,n){if(!t&&!n)throw Error('CodeGen: \"try\" without \"catch\" and \"finally\"');let r=new tw;if(this._blockNode(r),this.code(e),t){let o=this.name(\"e\");this._currNode=r.catch=new Ts(o),t(o)}if(n)this._currNode=r.finally=new As,this.code(n);return this._endBlockNode(Ts,As)}throw(e){return this._leafNode(new Z_(e))}block(e,t){if(this._blockStarts.push(this._nodes.length),e)this.code(e).endBlock(t);return this}endBlock(e){let t=this._blockStarts.pop();if(t===void 0)throw Error(\"CodeGen: not in self-balancing block\");let n=this._nodes.length-t;if(n<0||e!==void 0&&n!==e)throw Error(`CodeGen: wrong number of nodes: ${n} vs ${e} expected`);return this._nodes.length=t,this}func(e,t=k.nil,n,r){if(this._blockNode(new ks(e,t,n)),r)this.code(r).endFunc();return this}endFunc(){return this._endBlockNode(ks)}optimize(e=1){while(e-- >0)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(e){return this._currNode.nodes.push(e),this}_blockNode(e){this._currNode.nodes.push(e),this._nodes.push(e)}_endBlockNode(e,t){let n=this._currNode;if(n instanceof e||t&&n instanceof t)return this._nodes.pop(),this;throw Error(`CodeGen: not in block \"${t?`${e.kind}/${t.kind}`:e.kind}\"`)}_elseNode(e){let t=this._currNode;if(!(t instanceof xt))throw Error('CodeGen: \"else\" without \"if\"');return this._currNode=t.else=e,this}get _root(){return this._nodes[0]}get _currNode(){let e=this._nodes;return e[e.length-1]}set _currNode(e){let t=this._nodes;t[t.length-1]=e}}Ce.CodeGen=nw;function wn(e,t){for(let n in t)e[n]=(e[n]||0)+(t[n]||0);return e}function Cs(e,t){return t instanceof k._CodeOrName?wn(e,t.names):e}function tr(e,t,n){if(e instanceof k.Name)return r(e);if(!o(e))return e;return new k._Code(e._items.reduce((s,i)=>{if(i instanceof k.Name)i=r(i);if(i instanceof k._Code)s.push(...i._items);else s.push(i);return s},[]));function r(s){let i=n[s.str];if(i===void 0||t[s.str]!==1)return s;return delete t[s.str],i}function o(s){return s instanceof k._Code&&s._items.some((i)=>i instanceof k.Name&&t[i.str]===1&&n[i.str]!==void 0)}}function D$(e,t){for(let n in t)e[n]=(e[n]||0)-(t[n]||0)}function rw(e){return typeof e==\"boolean\"||typeof e==\"number\"||e===null?!e:k._`!${pl(e)}`}Ce.not=rw;var U$=ow(Ce.operators.AND);function L$(...e){return e.reduce(U$)}Ce.and=L$;var G$=ow(Ce.operators.OR);function B$(...e){return e.reduce(G$)}Ce.or=B$;function ow(e){return(t,n)=>t===k.nil?n:n===k.nil?t:k._`${pl(t)} ${e} ${pl(n)}`}function pl(e){return e instanceof k.Name?e:k._`(${e})`}});var B=g(function(fw){Object.defineProperty(fw,\"__esModule\",{value:!0});fw.checkStrictMode=fw.getErrorPath=fw.Type=fw.useFunc=fw.setEvaluated=fw.evaluatedPropsToName=fw.mergeEvaluated=fw.eachItem=fw.unescapeJsonPointer=fw.escapeJsonPointer=fw.escapeFragment=fw.unescapeFragment=fw.schemaRefOrVal=fw.schemaHasRulesButRef=fw.schemaHasRules=fw.checkUnknownRules=fw.alwaysValidSchema=fw.toHash=void 0;var M=N(),cw=Xr();function W$(e){let t={};for(let n of e)t[n]=!0;return t}fw.toHash=W$;function K$(e,t){if(typeof t==\"boolean\")return t;if(Object.keys(t).length===0)return!0;return lw(e,t),!uw(t,e.self.RULES.all)}fw.alwaysValidSchema=K$;function lw(e,t=e.schema){let{opts:n,self:r}=e;if(!n.strictSchema)return;if(typeof t===\"boolean\")return;let o=r.RULES.keywords;for(let s in t)if(!o[s])mw(e,`unknown keyword: \"${s}\"`)}fw.checkUnknownRules=lw;function uw(e,t){if(typeof e==\"boolean\")return!e;for(let n in e)if(t[n])return!0;return!1}fw.schemaHasRules=uw;function H$(e,t){if(typeof e==\"boolean\")return!e;for(let n in e)if(n!==\"$ref\"&&t.all[n])return!0;return!1}fw.schemaHasRulesButRef=H$;function Z$({topSchemaRef:e,schemaPath:t},n,r,o){if(!o){if(typeof n==\"number\"||typeof n==\"boolean\")return n;if(typeof n==\"string\")return M._`${n}`}return M._`${e}${t}${M.getProperty(r)}`}fw.schemaRefOrVal=Z$;function Y$(e){return dw(decodeURIComponent(e))}fw.unescapeFragment=Y$;function X$(e){return encodeURIComponent(gl(e))}fw.escapeFragment=X$;function gl(e){if(typeof e==\"number\")return`${e}`;return e.replace(/~/g,\"~0\").replace(/\\//g,\"~1\")}fw.escapeJsonPointer=gl;function dw(e){return e.replace(/~1/g,\"/\").replace(/~0/g,\"~\")}fw.unescapeJsonPointer=dw;function Q$(e,t){if(Array.isArray(e))for(let n of e)t(n);else t(e)}fw.eachItem=Q$;function iw({mergeNames:e,mergeToName:t,mergeValues:n,resultToName:r}){return(o,s,i,a)=>{let c=i===void 0?s:i instanceof M.Name?(s instanceof M.Name?e(o,s,i):t(o,s,i),i):s instanceof M.Name?(t(o,i,s),s):n(s,i);return a===M.Name&&!(c instanceof M.Name)?r(o,c):c}}fw.mergeEvaluated={props:iw({mergeNames:(e,t,n)=>e.if(M._`${n} !== true && ${t} !== undefined`,()=>{e.if(M._`${t} === true`,()=>e.assign(n,!0),()=>e.assign(n,M._`${n} || {}`).code(M._`Object.assign(${n}, ${t})`))}),mergeToName:(e,t,n)=>e.if(M._`${n} !== true`,()=>{if(t===!0)e.assign(n,!0);else e.assign(n,M._`${n} || {}`),hl(e,n,t)}),mergeValues:(e,t)=>e===!0?!0:{...e,...t},resultToName:pw}),items:iw({mergeNames:(e,t,n)=>e.if(M._`${n} !== true && ${t} !== undefined`,()=>e.assign(n,M._`${t} === true ? true : ${n} > ${t} ? ${n} : ${t}`)),mergeToName:(e,t,n)=>e.if(M._`${n} !== true`,()=>e.assign(n,t===!0?!0:M._`${n} > ${t} ? ${n} : ${t}`)),mergeValues:(e,t)=>e===!0?!0:Math.max(e,t),resultToName:(e,t)=>e.var(\"items\",t)})};function pw(e,t){if(t===!0)return e.var(\"props\",!0);let n=e.var(\"props\",M._`{}`);if(t!==void 0)hl(e,n,t);return n}fw.evaluatedPropsToName=pw;function hl(e,t,n){Object.keys(n).forEach((r)=>e.assign(M._`${t}${M.getProperty(r)}`,!0))}fw.setEvaluated=hl;var aw={};function e1(e,t){return e.scopeValue(\"func\",{ref:t,code:aw[t.code]||(aw[t.code]=new cw._Code(t.code))})}fw.useFunc=e1;var fl;(function(e){e[e.Num=0]=\"Num\",e[e.Str=1]=\"Str\"})(fl||(fw.Type=fl={}));function t1(e,t,n){if(e instanceof M.Name){let r=t===fl.Num;return n?r?M._`\"[\" + ${e} + \"]\"`:M._`\"['\" + ${e} + \"']\"`:r?M._`\"/\" + ${e}`:M._`\"/\" + ${e}.replace(/~/g, \"~0\").replace(/\\\\//g, \"~1\")`}return n?M.getProperty(e).toString():\"/\"+gl(e)}fw.getErrorPath=t1;function mw(e,t,n=e.opts.strictSchema){if(!n)return;if(t=`strict mode: ${t}`,n===!0)throw Error(t);e.self.logger.warn(t)}fw.checkStrictMode=mw});var Le=g(function(hw){Object.defineProperty(hw,\"__esModule\",{value:!0});var Z=N(),v1={data:new Z.Name(\"data\"),valCxt:new Z.Name(\"valCxt\"),instancePath:new Z.Name(\"instancePath\"),parentData:new Z.Name(\"parentData\"),parentDataProperty:new Z.Name(\"parentDataProperty\"),rootData:new Z.Name(\"rootData\"),dynamicAnchors:new Z.Name(\"dynamicAnchors\"),vErrors:new Z.Name(\"vErrors\"),errors:new Z.Name(\"errors\"),this:new Z.Name(\"this\"),self:new Z.Name(\"self\"),scope:new Z.Name(\"scope\"),json:new Z.Name(\"json\"),jsonPos:new Z.Name(\"jsonPos\"),jsonLen:new Z.Name(\"jsonLen\"),jsonPart:new Z.Name(\"jsonPart\")};hw.default=v1});var eo=g(function(_w){Object.defineProperty(_w,\"__esModule\",{value:!0});_w.extendErrors=_w.resetErrorsCount=_w.reportExtraError=_w.reportError=_w.keyword$DataError=_w.keywordError=void 0;var R=N(),Ut=B(),Re=Le();_w.keywordError={message:({keyword:e})=>R.str`must pass \"${e}\" keyword validation`};_w.keyword$DataError={message:({keyword:e,schemaType:t})=>t?R.str`\"${e}\" keyword must be ${t} ($data)`:R.str`\"${e}\" keyword is invalid ($data)`};function w1(e,t=_w.keywordError,n,r){let{it:o}=e,{gen:s,compositeRule:i,allErrors:a}=o,c=vw(e,t,n);if(r!==null&&r!==void 0?r:i||a)yw(s,c);else bw(o,R._`[${c}]`)}_w.reportError=w1;function x1(e,t=_w.keywordError,n){let{it:r}=e,{gen:o,compositeRule:s,allErrors:i}=r,a=vw(e,t,n);if(yw(o,a),!(s||i))bw(r,Re.default.vErrors)}_w.reportExtraError=x1;function S1(e,t){e.assign(Re.default.errors,t),e.if(R._`${Re.default.vErrors} !== null`,()=>e.if(t,()=>e.assign(R._`${Re.default.vErrors}.length`,t),()=>e.assign(Re.default.vErrors,null)))}_w.resetErrorsCount=S1;function I1({gen:e,keyword:t,schemaValue:n,data:r,errsCount:o,it:s}){if(o===void 0)throw Error(\"ajv implementation error\");let i=e.name(\"err\");e.forRange(\"i\",o,Re.default.errors,(a)=>{if(e.const(i,R._`${Re.default.vErrors}[${a}]`),e.if(R._`${i}.instancePath === undefined`,()=>e.assign(R._`${i}.instancePath`,R.strConcat(Re.default.instancePath,s.errorPath))),e.assign(R._`${i}.schemaPath`,R.str`${s.errSchemaPath}/${t}`),s.opts.verbose)e.assign(R._`${i}.schema`,n),e.assign(R._`${i}.data`,r)})}_w.extendErrors=I1;function yw(e,t){let n=e.const(\"err\",t);e.if(R._`${Re.default.vErrors} === null`,()=>e.assign(Re.default.vErrors,R._`[${n}]`),R._`${Re.default.vErrors}.push(${n})`),e.code(R._`${Re.default.errors}++`)}function bw(e,t){let{gen:n,validateName:r,schemaEnv:o}=e;if(o.$async)n.throw(R._`new ${e.ValidationError}(${t})`);else n.assign(R._`${r}.errors`,t),n.return(!1)}var xn={keyword:new R.Name(\"keyword\"),schemaPath:new R.Name(\"schemaPath\"),params:new R.Name(\"params\"),propertyName:new R.Name(\"propertyName\"),message:new R.Name(\"message\"),schema:new R.Name(\"schema\"),parentSchema:new R.Name(\"parentSchema\")};function vw(e,t,n){let{createErrors:r}=e.it;if(r===!1)return R._`{}`;return k1(e,t,n)}function k1(e,t,n={}){let{gen:r,it:o}=e,s=[R1(o,n),T1(e,n)];return A1(e,t,s),r.object(...s)}function R1({errorPath:e},{instancePath:t}){let n=t?R.str`${e}${Ut.getErrorPath(t,Ut.Type.Str)}`:e;return[Re.default.instancePath,R.strConcat(Re.default.instancePath,n)]}function T1({keyword:e,it:{errSchemaPath:t}},{schemaPath:n,parentSchema:r}){let o=r?t:R.str`${t}/${e}`;if(n)o=R.str`${o}${Ut.getErrorPath(n,Ut.Type.Str)}`;return[xn.schemaPath,o]}function A1(e,{params:t,message:n},r){let{keyword:o,data:s,schemaValue:i,it:a}=e,{opts:c,propertyName:l,topSchemaRef:u,schemaPath:p}=a;if(r.push([xn.keyword,o],[xn.params,typeof t==\"function\"?t(e):t||R._`{}`]),c.messages)r.push([xn.message,typeof n==\"function\"?n(e):n]);if(c.verbose)r.push([xn.schema,i],[xn.parentSchema,R._`${u}${p}`],[Re.default.data,s]);if(l)r.push([xn.propertyName,l])}});var Tw=g(function(kw){Object.defineProperty(kw,\"__esModule\",{value:!0});kw.boolOrEmptySchema=kw.topBoolOrEmptySchema=void 0;var xw=eo(),Sw=N(),$1=Le(),M1={message:\"boolean schema is false\"};function q1(e){let{gen:t,schema:n,validateName:r}=e;if(n===!1)Iw(e,!1);else if(typeof n==\"object\"&&n.$async===!0)t.return($1.default.data);else t.assign(Sw._`${r}.errors`,null),t.return(!0)}kw.topBoolOrEmptySchema=q1;function z1(e,t){let{gen:n,schema:r}=e;if(r===!1)n.var(t,!1),Iw(e);else n.var(t,!0)}kw.boolOrEmptySchema=z1;function Iw(e,t){let{gen:n,data:r}=e;xw.reportError({gen:n,keyword:\"false schema\",data:r,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:e},M1,void 0,t)}});var bl=g(function(Aw){Object.defineProperty(Aw,\"__esModule\",{value:!0});Aw.getRules=Aw.isJSONType=void 0;var N1=[\"string\",\"number\",\"integer\",\"boolean\",\"null\",\"object\",\"array\"],D1=new Set(N1);function U1(e){return typeof e==\"string\"&&D1.has(e)}Aw.isJSONType=U1;function L1(){let e={number:{type:\"number\",rules:[]},string:{type:\"string\",rules:[]},array:{type:\"array\",rules:[]},object:{type:\"object\",rules:[]}};return{types:{...e,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},e.number,e.string,e.array,e.object],post:{rules:[]},all:{},keywords:{}}}Aw.getRules=L1});var vl=g(function(Ow){Object.defineProperty(Ow,\"__esModule\",{value:!0});Ow.shouldUseRule=Ow.shouldUseGroup=Ow.schemaHasRulesForType=void 0;function B1({schema:e,self:t},n){let r=t.RULES.types[n];return r&&r!==!0&&Ew(e,r)}Ow.schemaHasRulesForType=B1;function Ew(e,t){return t.rules.some((n)=>Pw(e,n))}Ow.shouldUseGroup=Ew;function Pw(e,t){var n;return e[t.keyword]!==void 0||((n=t.definition.implements)===null||n===void 0?void 0:n.some((r)=>e[r]!==void 0))}Ow.shouldUseRule=Pw});var to=g(function(Dw){Object.defineProperty(Dw,\"__esModule\",{value:!0});Dw.reportTypeError=Dw.checkDataTypes=Dw.checkDataType=Dw.coerceAndCheckDataType=Dw.getJSONTypes=Dw.getSchemaTypes=Dw.DataType=void 0;var Mw=bl(),qw=vl(),zw=eo(),S=N(),$s=B(),nr;(function(e){e[e.Correct=0]=\"Correct\",e[e.Wrong=1]=\"Wrong\"})(nr||(Dw.DataType=nr={}));function J1(e){let t=jw(e.type);if(t.includes(\"null\")){if(e.nullable===!1)throw Error(\"type: null contradicts nullable: false\")}else{if(!t.length&&e.nullable!==void 0)throw Error('\"nullable\" cannot be used without \"type\"');if(e.nullable===!0)t.push(\"null\")}return t}Dw.getSchemaTypes=J1;function jw(e){let t=Array.isArray(e)?e:e?[e]:[];if(t.every(Mw.isJSONType))return t;throw Error(\"type must be JSONType or JSONType[]: \"+t.join(\",\"))}Dw.getJSONTypes=jw;function W1(e,t){let{gen:n,data:r,opts:o}=e,s=K1(t,o.coerceTypes),i=t.length>0&&!(s.length===0&&t.length===1&&qw.schemaHasRulesForType(e,t[0]));if(i){let a=wl(t,r,o.strictNumbers,nr.Wrong);n.if(a,()=>{if(s.length)H1(e,t,s);else xl(e)})}return i}Dw.coerceAndCheckDataType=W1;var Nw=new Set([\"string\",\"number\",\"integer\",\"boolean\",\"null\"]);function K1(e,t){return t?e.filter((n)=>Nw.has(n)||t===\"array\"&&n===\"array\"):[]}function H1(e,t,n){let{gen:r,data:o,opts:s}=e,i=r.let(\"dataType\",S._`typeof ${o}`),a=r.let(\"coerced\",S._`undefined`);if(s.coerceTypes===\"array\")r.if(S._`${i} == 'object' && Array.isArray(${o}) && ${o}.length == 1`,()=>r.assign(o,S._`${o}[0]`).assign(i,S._`typeof ${o}`).if(wl(t,o,s.strictNumbers),()=>r.assign(a,o)));r.if(S._`${a} !== undefined`);for(let l of n)if(Nw.has(l)||l===\"array\"&&s.coerceTypes===\"array\")c(l);r.else(),xl(e),r.endIf(),r.if(S._`${a} !== undefined`,()=>{r.assign(o,a),Z1(e,a)});function c(l){switch(l){case\"string\":r.elseIf(S._`${i} == \"number\" || ${i} == \"boolean\"`).assign(a,S._`\"\" + ${o}`).elseIf(S._`${o} === null`).assign(a,S._`\"\"`);return;case\"number\":r.elseIf(S._`${i} == \"boolean\" || ${o} === null\n || (${i} == \"string\" && ${o} && ${o} == +${o})`).assign(a,S._`+${o}`);return;case\"integer\":r.elseIf(S._`${i} === \"boolean\" || ${o} === null\n || (${i} === \"string\" && ${o} && ${o} == +${o} && !(${o} % 1))`).assign(a,S._`+${o}`);return;case\"boolean\":r.elseIf(S._`${o} === \"false\" || ${o} === 0 || ${o} === null`).assign(a,!1).elseIf(S._`${o} === \"true\" || ${o} === 1`).assign(a,!0);return;case\"null\":r.elseIf(S._`${o} === \"\" || ${o} === 0 || ${o} === false`),r.assign(a,null);return;case\"array\":r.elseIf(S._`${i} === \"string\" || ${i} === \"number\"\n || ${i} === \"boolean\" || ${o} === null`).assign(a,S._`[${o}]`)}}}function Z1({gen:e,parentData:t,parentDataProperty:n},r){e.if(S._`${t} !== undefined`,()=>e.assign(S._`${t}[${n}]`,r))}function _l(e,t,n,r=nr.Correct){let o=r===nr.Correct?S.operators.EQ:S.operators.NEQ,s;switch(e){case\"null\":return S._`${t} ${o} null`;case\"array\":s=S._`Array.isArray(${t})`;break;case\"object\":s=S._`${t} && typeof ${t} == \"object\" && !Array.isArray(${t})`;break;case\"integer\":s=i(S._`!(${t} % 1) && !isNaN(${t})`);break;case\"number\":s=i();break;default:return S._`typeof ${t} ${o} ${e}`}return r===nr.Correct?s:S.not(s);function i(a=S.nil){return S.and(S._`typeof ${t} == \"number\"`,a,n?S._`isFinite(${t})`:S.nil)}}Dw.checkDataType=_l;function wl(e,t,n,r){if(e.length===1)return _l(e[0],t,n,r);let o,s=$s.toHash(e);if(s.array&&s.object){let i=S._`typeof ${t} != \"object\"`;o=s.null?i:S._`!${t} || ${i}`,delete s.null,delete s.array,delete s.object}else o=S.nil;if(s.number)delete s.integer;for(let i in s)o=S.and(o,_l(i,t,n,r));return o}Dw.checkDataTypes=wl;var Y1={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>typeof e==\"string\"?S._`{type: ${e}}`:S._`{type: ${t}}`};function xl(e){let t=X1(e);zw.reportError(t,Y1)}Dw.reportTypeError=xl;function X1(e){let{gen:t,data:n,schema:r}=e,o=$s.schemaRefOrVal(e,r,\"type\");return{gen:t,keyword:\"type\",data:n,schema:r.type,schemaCode:o,schemaValue:o,parentSchema:r,params:{},it:e}}});var Fw=g(function(Bw){Object.defineProperty(Bw,\"__esModule\",{value:!0});Bw.assignDefaults=void 0;var Ge=N(),Gw=B();function sM(e,t){let{properties:n,items:r}=e.schema;if(t===\"object\"&&n)for(let o in n)Lw(e,o,n[o].default);else if(t===\"array\"&&Array.isArray(r))r.forEach((o,s)=>Lw(e,s,o.default))}Bw.assignDefaults=sM;function Lw(e,t,n){let{gen:r,compositeRule:o,data:s,opts:i}=e;if(n===void 0)return;let a=Ge._`${s}${Ge.getProperty(t)}`;if(o){Gw.checkStrictMode(e,`default is ignored for: ${a}`);return}let c=Ge._`${a} === undefined`;if(i.useDefaults===\"empty\")c=Ge._`${c} || ${a} === null || ${a} === \"\"`;r.if(c,Ge._`${a} = ${Ge.stringify(n)}`)}});var Be=g(function(Hw){Object.defineProperty(Hw,\"__esModule\",{value:!0});Hw.validateUnion=Hw.validateArray=Hw.usePattern=Hw.callValidateCode=Hw.schemaProperties=Hw.allSchemaProperties=Hw.noPropertyInData=Hw.propertyInData=Hw.isOwnProperty=Hw.hasPropFunc=Hw.reportMissingProp=Hw.checkMissingProp=Hw.checkReportMissingProp=void 0;var q=N(),rr=B(),Lt=Le(),Jw=B();function iM(e,t){let{gen:n,data:r,it:o}=e;n.if(Il(n,r,t,o.opts.ownProperties),()=>{e.setParams({missingProperty:q._`${t}`},!0),e.error()})}Hw.checkReportMissingProp=iM;function aM({gen:e,data:t,it:{opts:n}},r,o){return q.or(...r.map((s)=>q.and(Il(e,t,s,n.ownProperties),q._`${o} = ${s}`)))}Hw.checkMissingProp=aM;function cM(e,t){e.setParams({missingProperty:t},!0),e.error()}Hw.reportMissingProp=cM;function Ww(e){return e.scopeValue(\"func\",{ref:Object.prototype.hasOwnProperty,code:q._`Object.prototype.hasOwnProperty`})}Hw.hasPropFunc=Ww;function Sl(e,t,n){return q._`${Ww(e)}.call(${t}, ${n})`}Hw.isOwnProperty=Sl;function lM(e,t,n,r){let o=q._`${t}${q.getProperty(n)} !== undefined`;return r?q._`${o} && ${Sl(e,t,n)}`:o}Hw.propertyInData=lM;function Il(e,t,n,r){let o=q._`${t}${q.getProperty(n)} === undefined`;return r?q.or(o,q.not(Sl(e,t,n))):o}Hw.noPropertyInData=Il;function Kw(e){return e?Object.keys(e).filter((t)=>t!==\"__proto__\"):[]}Hw.allSchemaProperties=Kw;function uM(e,t){return Kw(t).filter((n)=>!rr.alwaysValidSchema(e,t[n]))}Hw.schemaProperties=uM;function dM({schemaCode:e,data:t,it:{gen:n,topSchemaRef:r,schemaPath:o,errorPath:s},it:i},a,c,l){let u=l?q._`${e}, ${t}, ${r}${o}`:t,p=[[Lt.default.instancePath,q.strConcat(Lt.default.instancePath,s)],[Lt.default.parentData,i.parentData],[Lt.default.parentDataProperty,i.parentDataProperty],[Lt.default.rootData,Lt.default.rootData]];if(i.opts.dynamicRef)p.push([Lt.default.dynamicAnchors,Lt.default.dynamicAnchors]);let m=q._`${u}, ${n.object(...p)}`;return c!==q.nil?q._`${a}.call(${c}, ${m})`:q._`${a}(${m})`}Hw.callValidateCode=dM;var pM=q._`new RegExp`;function mM({gen:e,it:{opts:t}},n){let r=t.unicodeRegExp?\"u\":\"\",{regExp:o}=t.code,s=o(n,r);return e.scopeValue(\"pattern\",{key:s.toString(),ref:s,code:q._`${o.code===\"new RegExp\"?pM:Jw.useFunc(e,o)}(${n}, ${r})`})}Hw.usePattern=mM;function fM(e){let{gen:t,data:n,keyword:r,it:o}=e,s=t.name(\"valid\");if(o.allErrors){let a=t.let(\"valid\",!0);return i(()=>t.assign(a,!1)),a}return t.var(s,!0),i(()=>t.break()),s;function i(a){let c=t.const(\"len\",q._`${n}.length`);t.forRange(\"i\",0,c,(l)=>{e.subschema({keyword:r,dataProp:l,dataPropType:rr.Type.Num},s),t.if(q.not(s),a)})}}Hw.validateArray=fM;function gM(e){let{gen:t,schema:n,keyword:r,it:o}=e;if(!Array.isArray(n))throw Error(\"ajv implementation error\");if(n.some((c)=>rr.alwaysValidSchema(o,c))&&!o.opts.unevaluated)return;let i=t.let(\"valid\",!1),a=t.name(\"_valid\");t.block(()=>n.forEach((c,l)=>{let u=e.subschema({keyword:r,schemaProp:l,compositeRule:!0},a);if(t.assign(i,q._`${i} || ${a}`),!e.mergeValidEvaluated(u,a))t.if(q.not(i))})),e.result(i,()=>e.reset(),()=>e.error(!0))}Hw.validateUnion=gM});var rx=g(function(tx){Object.defineProperty(tx,\"__esModule\",{value:!0});tx.validateKeywordUsage=tx.validSchemaType=tx.funcKeywordCode=tx.macroKeywordCode=void 0;var Y=N(),Sn=Le(),Xw=Be(),Qw=eo();function AM(e,t){let{gen:n,keyword:r,schema:o,parentSchema:s,it:i}=e,a=t.macro.call(i.self,o,s,i),c=ex(n,r,a);if(i.opts.validateSchema!==!1)i.self.validateSchema(a,!0);let l=n.name(\"valid\");e.subschema({schema:a,schemaPath:Y.nil,errSchemaPath:`${i.errSchemaPath}/${r}`,topSchemaRef:c,compositeRule:!0},l),e.pass(l,()=>e.error(!0))}tx.macroKeywordCode=AM;function CM(e,t){var n;let{gen:r,keyword:o,schema:s,parentSchema:i,$data:a,it:c}=e;PM(c,t);let l=!a&&t.compile?t.compile.call(c.self,s,i,c):t.validate,u=ex(r,o,l),p=r.let(\"valid\");e.block$data(p,m),e.ok((n=t.valid)!==null&&n!==void 0?n:p);function m(){if(t.errors===!1){if(h(),t.modifying)Yw(e);y(()=>e.error())}else{let _=t.async?d():f();if(t.modifying)Yw(e);y(()=>EM(e,_))}}function d(){let _=r.let(\"ruleErrs\",null);return r.try(()=>h(Y._`await `),(E)=>r.assign(p,!1).if(Y._`${E} instanceof ${c.ValidationError}`,()=>r.assign(_,Y._`${E}.errors`),()=>r.throw(E))),_}function f(){let _=Y._`${u}.errors`;return r.assign(_,null),h(Y.nil),_}function h(_=t.async?Y._`await `:Y.nil){let E=c.opts.passContext?Sn.default.this:Sn.default.self,T=!((\"compile\"in t)&&!a||t.schema===!1);r.assign(p,Y._`${_}${Xw.callValidateCode(e,u,E,T)}`,t.modifying)}function y(_){var E;r.if(Y.not((E=t.valid)!==null&&E!==void 0?E:p),_)}}tx.funcKeywordCode=CM;function Yw(e){let{gen:t,data:n,it:r}=e;t.if(r.parentData,()=>t.assign(n,Y._`${r.parentData}[${r.parentDataProperty}]`))}function EM(e,t){let{gen:n}=e;n.if(Y._`Array.isArray(${t})`,()=>{n.assign(Sn.default.vErrors,Y._`${Sn.default.vErrors} === null ? ${t} : ${Sn.default.vErrors}.concat(${t})`).assign(Sn.default.errors,Y._`${Sn.default.vErrors}.length`),Qw.extendErrors(e)},()=>e.error())}function PM({schemaEnv:e},t){if(t.async&&!e.$async)throw Error(\"async keyword in sync schema\")}function ex(e,t,n){if(n===void 0)throw Error(`keyword \"${t}\" failed to compile`);return e.scopeValue(\"keyword\",typeof n==\"function\"?{ref:n}:{ref:n,code:Y.stringify(n)})}function OM(e,t,n=!1){return!t.length||t.some((r)=>r===\"array\"?Array.isArray(e):r===\"object\"?e&&typeof e==\"object\"&&!Array.isArray(e):typeof e==r||n&&typeof e>\"u\")}tx.validSchemaType=OM;function $M({schema:e,opts:t,self:n,errSchemaPath:r},o,s){if(Array.isArray(o.keyword)?!o.keyword.includes(s):o.keyword!==s)throw Error(\"ajv implementation error\");let i=o.dependencies;if(i===null||i===void 0?void 0:i.some((a)=>!Object.prototype.hasOwnProperty.call(e,a)))throw Error(`parent schema must have dependencies of ${s}: ${i.join(\",\")}`);if(o.validateSchema){if(!o.validateSchema(e[s])){let c=`keyword \"${s}\" value is invalid at path \"${r}\": `+n.errorsText(o.validateSchema.errors);if(t.validateSchema===\"log\")n.logger.error(c);else throw Error(c)}}}tx.validateKeywordUsage=$M});var ix=g(function(ox){Object.defineProperty(ox,\"__esModule\",{value:!0});ox.extendSubschemaMode=ox.extendSubschemaData=ox.getSubschema=void 0;var he=N(),Ms=B();function jM(e,{keyword:t,schemaProp:n,schema:r,schemaPath:o,errSchemaPath:s,topSchemaRef:i}){if(t!==void 0&&r!==void 0)throw Error('both \"keyword\" and \"schema\" passed, only one allowed');if(t!==void 0){let a=e.schema[t];return n===void 0?{schema:a,schemaPath:he._`${e.schemaPath}${he.getProperty(t)}`,errSchemaPath:`${e.errSchemaPath}/${t}`}:{schema:a[n],schemaPath:he._`${e.schemaPath}${he.getProperty(t)}${he.getProperty(n)}`,errSchemaPath:`${e.errSchemaPath}/${t}/${Ms.escapeFragment(n)}`}}if(r!==void 0){if(o===void 0||s===void 0||i===void 0)throw Error('\"schemaPath\", \"errSchemaPath\" and \"topSchemaRef\" are required with \"schema\"');return{schema:r,schemaPath:o,topSchemaRef:i,errSchemaPath:s}}throw Error('either \"keyword\" or \"schema\" must be passed')}ox.getSubschema=jM;function NM(e,t,{dataProp:n,dataPropType:r,data:o,dataTypes:s,propertyName:i}){if(o!==void 0&&n!==void 0)throw Error('both \"data\" and \"dataProp\" passed, only one allowed');let{gen:a}=t;if(n!==void 0){let{errorPath:l,dataPathArr:u,opts:p}=t,m=a.let(\"data\",he._`${t.data}${he.getProperty(n)}`,!0);c(m),e.errorPath=he.str`${l}${Ms.getErrorPath(n,r,p.jsPropertySyntax)}`,e.parentDataProperty=he._`${n}`,e.dataPathArr=[...u,e.parentDataProperty]}if(o!==void 0){let l=o instanceof he.Name?o:a.let(\"data\",o,!0);if(c(l),i!==void 0)e.propertyName=i}if(s)e.dataTypes=s;function c(l){e.data=l,e.dataLevel=t.dataLevel+1,e.dataTypes=[],t.definedProperties=new Set,e.parentData=t.data,e.dataNames=[...t.dataNames,l]}}ox.extendSubschemaData=NM;function DM(e,{jtdDiscriminator:t,jtdMetadata:n,compositeRule:r,createErrors:o,allErrors:s}){if(r!==void 0)e.compositeRule=r;if(o!==void 0)e.createErrors=o;if(s!==void 0)e.allErrors=s;e.jtdDiscriminator=t,e.jtdMetadata=n}ox.extendSubschemaMode=DM});var kl=g(function(iZ,ax){ax.exports=function e(t,n){if(t===n)return!0;if(t&&n&&typeof t==\"object\"&&typeof n==\"object\"){if(t.constructor!==n.constructor)return!1;var r,o,s;if(Array.isArray(t)){if(r=t.length,r!=n.length)return!1;for(o=r;o--!==0;)if(!e(t[o],n[o]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if(s=Object.keys(t),r=s.length,r!==Object.keys(n).length)return!1;for(o=r;o--!==0;)if(!Object.prototype.hasOwnProperty.call(n,s[o]))return!1;for(o=r;o--!==0;){var i=s[o];if(!e(t[i],n[i]))return!1}return!0}return t!==t&&n!==n}});var lx=g(function(aZ,cx){var Gt=cx.exports=function(e,t,n){if(typeof t==\"function\")n=t,t={};n=t.cb||n;var r=typeof n==\"function\"?n:n.pre||function(){},o=n.post||function(){};qs(t,r,o,e,\"\",e)};Gt.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};Gt.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};Gt.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};Gt.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};function qs(e,t,n,r,o,s,i,a,c,l){if(r&&typeof r==\"object\"&&!Array.isArray(r)){t(r,o,s,i,a,c,l);for(var u in r){var p=r[u];if(Array.isArray(p)){if(u in Gt.arrayKeywords)for(var m=0;m<p.length;m++)qs(e,t,n,p[m],o+\"/\"+u+\"/\"+m,s,o,u,r,m)}else if(u in Gt.propsKeywords){if(p&&typeof p==\"object\")for(var d in p)qs(e,t,n,p[d],o+\"/\"+u+\"/\"+GM(d),s,o,u,r,d)}else if(u in Gt.keywords||e.allKeys&&!(u in Gt.skipKeywords))qs(e,t,n,p,o+\"/\"+u,s,o,u,r)}n(r,o,s,i,a,c,l)}}function GM(e){return e.replace(/~/g,\"~0\").replace(/\\//g,\"~1\")}});var no=g(function(fx){Object.defineProperty(fx,\"__esModule\",{value:!0});fx.getSchemaRefs=fx.resolveUrl=fx.normalizeId=fx._getFullPath=fx.getFullPath=fx.inlineRef=void 0;var ux=B(),BM=kl(),VM=lx(),FM=new Set([\"type\",\"format\",\"pattern\",\"maxLength\",\"minLength\",\"maxProperties\",\"minProperties\",\"maxItems\",\"minItems\",\"maximum\",\"minimum\",\"uniqueItems\",\"multipleOf\",\"required\",\"enum\",\"const\"]);function JM(e,t=!0){if(typeof e==\"boolean\")return!0;if(t===!0)return!Rl(e);if(!t)return!1;return dx(e)<=t}fx.inlineRef=JM;var WM=new Set([\"$ref\",\"$recursiveRef\",\"$recursiveAnchor\",\"$dynamicRef\",\"$dynamicAnchor\"]);function Rl(e){for(let t in e){if(WM.has(t))return!0;let n=e[t];if(Array.isArray(n)&&n.some(Rl))return!0;if(typeof n==\"object\"&&Rl(n))return!0}return!1}function dx(e){let t=0;for(let n in e){if(n===\"$ref\")return 1/0;if(t++,FM.has(n))continue;if(typeof e[n]==\"object\")ux.eachItem(e[n],(r)=>t+=dx(r));if(t===1/0)return 1/0}return t}function px(e,t=\"\",n){if(n!==!1)t=or(t);let r=e.parse(t);return mx(e,r)}fx.getFullPath=px;function mx(e,t){return e.serialize(t).split(\"#\")[0]+\"#\"}fx._getFullPath=mx;var KM=/#\\/?$/;function or(e){return e?e.replace(KM,\"\"):\"\"}fx.normalizeId=or;function HM(e,t,n){return n=or(n),e.resolve(t,n)}fx.resolveUrl=HM;var ZM=/^[a-z_][-a-z0-9._]*$/i;function YM(e,t){if(typeof e==\"boolean\")return{};let{schemaId:n,uriResolver:r}=this.opts,o=or(e[n]||t),s={\"\":o},i=px(r,o,!1),a={},c=new Set;return VM(e,{allKeys:!0},(p,m,d,f)=>{if(f===void 0)return;let h=i+m,y=s[f];if(typeof p[n]==\"string\")y=_.call(this,p[n]);E.call(this,p.$anchor),E.call(this,p.$dynamicAnchor),s[m]=y;function _(T){let A=this.opts.uriResolver.resolve;if(T=or(y?A(y,T):T),c.has(T))throw u(T);c.add(T);let x=this.refs[T];if(typeof x==\"string\")x=this.refs[x];if(typeof x==\"object\")l(p,x.schema,T);else if(T!==or(h))if(T[0]===\"#\")l(p,a[T],T),a[T]=p;else this.refs[T]=h;return T}function E(T){if(typeof T==\"string\"){if(!ZM.test(T))throw Error(`invalid anchor \"${T}\"`);_.call(this,`#${T}`)}}}),a;function l(p,m,d){if(m!==void 0&&!BM(p,m))throw u(d)}function u(p){return Error(`reference \"${p}\" resolves to more than one schema`)}}fx.getSchemaRefs=YM});var In=g(function(Ex){Object.defineProperty(Ex,\"__esModule\",{value:!0});Ex.getData=Ex.KeywordCxt=Ex.validateFunctionCode=void 0;var js=Tw(),zs=to(),ir=vl(),Bt=to(),vx=Fw(),rt=rx(),sr=ix(),v=N(),z=Le(),_x=no(),ve=B(),nt=eo();function rq(e){if(Sx(e)){if(Ix(e),xx(e)){iq(e);return}}wx(e,()=>js.topBoolOrEmptySchema(e))}Ex.validateFunctionCode=rq;function wx({gen:e,validateName:t,schema:n,schemaEnv:r,opts:o},s){if(o.code.es5)e.func(t,v._`${z.default.data}, ${z.default.valCxt}`,r.$async,()=>{e.code(v._`\"use strict\"; ${hx(n,o)}`),sq(e,o),e.code(s)});else e.func(t,v._`${z.default.data}, ${oq(o)}`,r.$async,()=>e.code(hx(n,o)).code(s))}function oq(e){return v._`{${z.default.instancePath}=\"\", ${z.default.parentData}, ${z.default.parentDataProperty}, ${z.default.rootData}=${z.default.data}${e.dynamicRef?v._`, ${z.default.dynamicAnchors}={}`:v.nil}}={}`}function sq(e,t){e.if(z.default.valCxt,()=>{if(e.var(z.default.instancePath,v._`${z.default.valCxt}.${z.default.instancePath}`),e.var(z.default.parentData,v._`${z.default.valCxt}.${z.default.parentData}`),e.var(z.default.parentDataProperty,v._`${z.default.valCxt}.${z.default.parentDataProperty}`),e.var(z.default.rootData,v._`${z.default.valCxt}.${z.default.rootData}`),t.dynamicRef)e.var(z.default.dynamicAnchors,v._`${z.default.valCxt}.${z.default.dynamicAnchors}`)},()=>{if(e.var(z.default.instancePath,v._`\"\"`),e.var(z.default.parentData,v._`undefined`),e.var(z.default.parentDataProperty,v._`undefined`),e.var(z.default.rootData,z.default.data),t.dynamicRef)e.var(z.default.dynamicAnchors,v._`{}`)})}function iq(e){let{schema:t,opts:n,gen:r}=e;wx(e,()=>{if(n.$comment&&t.$comment)Rx(e);if(dq(e),r.let(z.default.vErrors,null),r.let(z.default.errors,0),n.unevaluated)aq(e);kx(e),fq(e)});return}function aq(e){let{gen:t,validateName:n}=e;e.evaluated=t.const(\"evaluated\",v._`${n}.evaluated`),t.if(v._`${e.evaluated}.dynamicProps`,()=>t.assign(v._`${e.evaluated}.props`,v._`undefined`)),t.if(v._`${e.evaluated}.dynamicItems`,()=>t.assign(v._`${e.evaluated}.items`,v._`undefined`))}function hx(e,t){let n=typeof e==\"object\"&&e[t.schemaId];return n&&(t.code.source||t.code.process)?v._`/*# sourceURL=${n} */`:v.nil}function cq(e,t){if(Sx(e)){if(Ix(e),xx(e)){lq(e,t);return}}js.boolOrEmptySchema(e,t)}function xx({schema:e,self:t}){if(typeof e==\"boolean\")return!e;for(let n in e)if(t.RULES.all[n])return!0;return!1}function Sx(e){return typeof e.schema!=\"boolean\"}function lq(e,t){let{schema:n,gen:r,opts:o}=e;if(o.$comment&&n.$comment)Rx(e);pq(e),mq(e);let s=r.const(\"_errs\",z.default.errors);kx(e,s),r.var(t,v._`${s} === ${z.default.errors}`)}function Ix(e){ve.checkUnknownRules(e),uq(e)}function kx(e,t){if(e.opts.jtd)return yx(e,[],!1,t);let n=zs.getSchemaTypes(e.schema),r=zs.coerceAndCheckDataType(e,n);yx(e,n,!r,t)}function uq(e){let{schema:t,errSchemaPath:n,opts:r,self:o}=e;if(t.$ref&&r.ignoreKeywordsWithRef&&ve.schemaHasRulesButRef(t,o.RULES))o.logger.warn(`$ref: keywords ignored in schema at path \"${n}\"`)}function dq(e){let{schema:t,opts:n}=e;if(t.default!==void 0&&n.useDefaults&&n.strictSchema)ve.checkStrictMode(e,\"default is ignored in the schema root\")}function pq(e){let t=e.schema[e.opts.schemaId];if(t)e.baseId=_x.resolveUrl(e.opts.uriResolver,e.baseId,t)}function mq(e){if(e.schema.$async&&!e.schemaEnv.$async)throw Error(\"async schema in sync schema\")}function Rx({gen:e,schemaEnv:t,schema:n,errSchemaPath:r,opts:o}){let s=n.$comment;if(o.$comment===!0)e.code(v._`${z.default.self}.logger.log(${s})`);else if(typeof o.$comment==\"function\"){let i=v.str`${r}/$comment`,a=e.scopeValue(\"root\",{ref:t.root});e.code(v._`${z.default.self}.opts.$comment(${s}, ${i}, ${a}.schema)`)}}function fq(e){let{gen:t,schemaEnv:n,validateName:r,ValidationError:o,opts:s}=e;if(n.$async)t.if(v._`${z.default.errors} === 0`,()=>t.return(z.default.data),()=>t.throw(v._`new ${o}(${z.default.vErrors})`));else{if(t.assign(v._`${r}.errors`,z.default.vErrors),s.unevaluated)gq(e);t.return(v._`${z.default.errors} === 0`)}}function gq({gen:e,evaluated:t,props:n,items:r}){if(n instanceof v.Name)e.assign(v._`${t}.props`,n);if(r instanceof v.Name)e.assign(v._`${t}.items`,r)}function yx(e,t,n,r){let{gen:o,schema:s,data:i,allErrors:a,opts:c,self:l}=e,{RULES:u}=l;if(s.$ref&&(c.ignoreKeywordsWithRef||!ve.schemaHasRulesButRef(s,u))){o.block(()=>Ax(e,\"$ref\",u.all.$ref.definition));return}if(!c.jtd)hq(e,t);o.block(()=>{for(let m of u.rules)p(m);p(u.post)});function p(m){if(!ir.shouldUseGroup(s,m))return;if(m.type){if(o.if(Bt.checkDataType(m.type,i,c.strictNumbers)),bx(e,m),t.length===1&&t[0]===m.type&&n)o.else(),Bt.reportTypeError(e);o.endIf()}else bx(e,m);if(!a)o.if(v._`${z.default.errors} === ${r||0}`)}}function bx(e,t){let{gen:n,schema:r,opts:{useDefaults:o}}=e;if(o)vx.assignDefaults(e,t.type);n.block(()=>{for(let s of t.rules)if(ir.shouldUseRule(r,s))Ax(e,s.keyword,s.definition,t.type)})}function hq(e,t){if(e.schemaEnv.meta||!e.opts.strictTypes)return;if(yq(e,t),!e.opts.allowUnionTypes)bq(e,t);vq(e,e.dataTypes)}function yq(e,t){if(!t.length)return;if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach((n)=>{if(!Tx(e.dataTypes,n))Tl(e,`type \"${n}\" not allowed by context \"${e.dataTypes.join(\",\")}\"`)}),wq(e,t)}function bq(e,t){if(t.length>1&&!(t.length===2&&t.includes(\"null\")))Tl(e,\"use allowUnionTypes to allow union type keyword\")}function vq(e,t){let n=e.self.RULES.all;for(let r in n){let o=n[r];if(typeof o==\"object\"&&ir.shouldUseRule(e.schema,o)){let{type:s}=o.definition;if(s.length&&!s.some((i)=>_q(t,i)))Tl(e,`missing type \"${s.join(\",\")}\" for keyword \"${r}\"`)}}}function _q(e,t){return e.includes(t)||t===\"number\"&&e.includes(\"integer\")}function Tx(e,t){return e.includes(t)||t===\"integer\"&&e.includes(\"number\")}function wq(e,t){let n=[];for(let r of e.dataTypes)if(Tx(t,r))n.push(r);else if(t.includes(\"integer\")&&r===\"number\")n.push(\"integer\");e.dataTypes=n}function Tl(e,t){let n=e.schemaEnv.baseId+e.errSchemaPath;t+=` at \"${n}\" (strictTypes)`,ve.checkStrictMode(e,t,e.opts.strictTypes)}class Al{constructor(e,t,n){if(rt.validateKeywordUsage(e,t,n),this.gen=e.gen,this.allErrors=e.allErrors,this.keyword=n,this.data=e.data,this.schema=e.schema[n],this.$data=t.$data&&e.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=ve.schemaRefOrVal(e,this.schema,n,this.$data),this.schemaType=t.schemaType,this.parentSchema=e.schema,this.params={},this.it=e,this.def=t,this.$data)this.schemaCode=e.gen.const(\"vSchema\",Cx(this.$data,e));else if(this.schemaCode=this.schemaValue,!rt.validSchemaType(this.schema,t.schemaType,t.allowUndefined))throw Error(`${n} value must be ${JSON.stringify(t.schemaType)}`);if(\"code\"in t?t.trackErrors:t.errors!==!1)this.errsCount=e.gen.const(\"_errs\",z.default.errors)}result(e,t,n){this.failResult(v.not(e),t,n)}failResult(e,t,n){if(this.gen.if(e),n)n();else this.error();if(t){if(this.gen.else(),t(),this.allErrors)this.gen.endIf()}else if(this.allErrors)this.gen.endIf();else this.gen.else()}pass(e,t){this.failResult(v.not(e),void 0,t)}fail(e){if(e===void 0){if(this.error(),!this.allErrors)this.gen.if(!1);return}if(this.gen.if(e),this.error(),this.allErrors)this.gen.endIf();else this.gen.else()}fail$data(e){if(!this.$data)return this.fail(e);let{schemaCode:t}=this;this.fail(v._`${t} !== undefined && (${v.or(this.invalid$data(),e)})`)}error(e,t,n){if(t){this.setParams(t),this._error(e,n),this.setParams({});return}this._error(e,n)}_error(e,t){(e?nt.reportExtraError:nt.reportError)(this,this.def.error,t)}$dataError(){nt.reportError(this,this.def.$dataError||nt.keyword$DataError)}reset(){if(this.errsCount===void 0)throw Error('add \"trackErrors\" to keyword definition');nt.resetErrorsCount(this.gen,this.errsCount)}ok(e){if(!this.allErrors)this.gen.if(e)}setParams(e,t){if(t)Object.assign(this.params,e);else this.params=e}block$data(e,t,n=v.nil){this.gen.block(()=>{this.check$data(e,n),t()})}check$data(e=v.nil,t=v.nil){if(!this.$data)return;let{gen:n,schemaCode:r,schemaType:o,def:s}=this;if(n.if(v.or(v._`${r} === undefined`,t)),e!==v.nil)n.assign(e,!0);if(o.length||s.validateSchema){if(n.elseIf(this.invalid$data()),this.$dataError(),e!==v.nil)n.assign(e,!1)}n.else()}invalid$data(){let{gen:e,schemaCode:t,schemaType:n,def:r,it:o}=this;return v.or(s(),i());function s(){if(n.length){if(!(t instanceof v.Name))throw Error(\"ajv implementation error\");let a=Array.isArray(n)?n:[n];return v._`${Bt.checkDataTypes(a,t,o.opts.strictNumbers,Bt.DataType.Wrong)}`}return v.nil}function i(){if(r.validateSchema){let a=e.scopeValue(\"validate$data\",{ref:r.validateSchema});return v._`!${a}(${t})`}return v.nil}}subschema(e,t){let n=sr.getSubschema(this.it,e);sr.extendSubschemaData(n,this.it,e),sr.extendSubschemaMode(n,e);let r={...this.it,...n,items:void 0,props:void 0};return cq(r,t),r}mergeEvaluated(e,t){let{it:n,gen:r}=this;if(!n.opts.unevaluated)return;if(n.props!==!0&&e.props!==void 0)n.props=ve.mergeEvaluated.props(r,e.props,n.props,t);if(n.items!==!0&&e.items!==void 0)n.items=ve.mergeEvaluated.items(r,e.items,n.items,t)}mergeValidEvaluated(e,t){let{it:n,gen:r}=this;if(n.opts.unevaluated&&(n.props!==!0||n.items!==!0))return r.if(t,()=>this.mergeEvaluated(e,v.Name)),!0}}Ex.KeywordCxt=Al;function Ax(e,t,n,r){let o=new Al(e,n,t);if(\"code\"in n)n.code(o,r);else if(o.$data&&n.validate)rt.funcKeywordCode(o,n);else if(\"macro\"in n)rt.macroKeywordCode(o,n);else if(n.compile||n.validate)rt.funcKeywordCode(o,n)}var xq=/^\\/(?:[^~]|~0|~1)*$/,Sq=/^([0-9]+)(#|\\/(?:[^~]|~0|~1)*)?$/;function Cx(e,{dataLevel:t,dataNames:n,dataPathArr:r}){let o,s;if(e===\"\")return z.default.rootData;if(e[0]===\"/\"){if(!xq.test(e))throw Error(`Invalid JSON-pointer: ${e}`);o=e,s=z.default.rootData}else{let l=Sq.exec(e);if(!l)throw Error(`Invalid JSON-pointer: ${e}`);let u=+l[1];if(o=l[2],o===\"#\"){if(u>=t)throw Error(c(\"property/index\",u));return r[t-u]}if(u>t)throw Error(c(\"data\",u));if(s=n[t-u],!o)return s}let i=s,a=o.split(\"/\");for(let l of a)if(l)s=v._`${s}${v.getProperty(ve.unescapeJsonPointer(l))}`,i=v._`${i} && ${s}`;return i;function c(l,u){return`Cannot access ${l} ${u} levels up, current level is ${t}`}}Ex.getData=Cx});var ar=g(function($x){Object.defineProperty($x,\"__esModule\",{value:!0});class Ox extends Error{constructor(e){super(\"validation failed\");this.errors=e,this.ajv=this.validation=!0}}$x.default=Ox});var kn=g(function(qx){Object.defineProperty(qx,\"__esModule\",{value:!0});var cr=no();class Mx extends Error{constructor(e,t,n,r){super(r||`can't resolve reference ${n} from id ${t}`);this.missingRef=cr.resolveUrl(e,t,n),this.missingSchema=cr.normalizeId(cr.getFullPath(e,this.missingRef))}}qx.default=Mx});var oo=g(function(Nx){Object.defineProperty(Nx,\"__esModule\",{value:!0});Nx.resolveSchema=Nx.getCompilingSchema=Nx.resolveRef=Nx.compileSchema=Nx.SchemaEnv=void 0;var de=N(),Aq=ar(),Rn=Le(),pe=no(),Ns=B(),zx=In();class ro{constructor(e){var t;this.refs={},this.dynamicAnchors={};let n;if(typeof e.schema==\"object\")n=e.schema;this.schema=e.schema,this.schemaId=e.schemaId,this.root=e.root||this,this.baseId=(t=e.baseId)!==null&&t!==void 0?t:pe.normalizeId(n===null||n===void 0?void 0:n[e.schemaId||\"$id\"]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=n===null||n===void 0?void 0:n.$async,this.refs={}}}Nx.SchemaEnv=ro;function El(e){let t=jx.call(this,e);if(t)return t;let n=pe.getFullPath(this.opts.uriResolver,e.root.baseId),{es5:r,lines:o}=this.opts.code,{ownProperties:s}=this.opts,i=new de.CodeGen(this.scope,{es5:r,lines:o,ownProperties:s}),a;if(e.$async)a=i.scopeValue(\"Error\",{ref:Aq.default,code:de._`require(\"ajv/dist/runtime/validation_error\").default`});let c=i.scopeName(\"validate\");e.validateName=c;let l={gen:i,allErrors:this.opts.allErrors,data:Rn.default.data,parentData:Rn.default.parentData,parentDataProperty:Rn.default.parentDataProperty,dataNames:[Rn.default.data],dataPathArr:[de.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:i.scopeValue(\"schema\",this.opts.code.source===!0?{ref:e.schema,code:de.stringify(e.schema)}:{ref:e.schema}),validateName:c,ValidationError:a,schema:e.schema,schemaEnv:e,rootId:n,baseId:e.baseId||n,schemaPath:de.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?\"\":\"#\"),errorPath:de._`\"\"`,opts:this.opts,self:this},u;try{this._compilations.add(e),zx.validateFunctionCode(l),i.optimize(this.opts.code.optimize);let p=i.toString();if(u=`${i.scopeRefs(Rn.default.scope)}return ${p}`,this.opts.code.process)u=this.opts.code.process(u,e);let d=Function(`${Rn.default.self}`,`${Rn.default.scope}`,u)(this,this.scope.get());if(this.scope.value(c,{ref:d}),d.errors=null,d.schema=e.schema,d.schemaEnv=e,e.$async)d.$async=!0;if(this.opts.code.source===!0)d.source={validateName:c,validateCode:p,scopeValues:i._values};if(this.opts.unevaluated){let{props:f,items:h}=l;if(d.evaluated={props:f instanceof de.Name?void 0:f,items:h instanceof de.Name?void 0:h,dynamicProps:f instanceof de.Name,dynamicItems:h instanceof de.Name},d.source)d.source.evaluated=de.stringify(d.evaluated)}return e.validate=d,e}catch(p){if(delete e.validate,delete e.validateName,u)this.logger.error(\"Error compiling schema, function code:\",u);throw p}finally{this._compilations.delete(e)}}Nx.compileSchema=El;function Cq(e,t,n){var r;n=pe.resolveUrl(this.opts.uriResolver,t,n);let o=e.refs[n];if(o)return o;let s=Oq.call(this,e,n);if(s===void 0){let i=(r=e.localRefs)===null||r===void 0?void 0:r[n],{schemaId:a}=this.opts;if(i)s=new ro({schema:i,schemaId:a,root:e,baseId:t})}if(s===void 0)return;return e.refs[n]=Eq.call(this,s)}Nx.resolveRef=Cq;function Eq(e){if(pe.inlineRef(e.schema,this.opts.inlineRefs))return e.schema;return e.validate?e:El.call(this,e)}function jx(e){for(let t of this._compilations)if(Pq(t,e))return t}Nx.getCompilingSchema=jx;function Pq(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function Oq(e,t){let n;while(typeof(n=this.refs[t])==\"string\")t=n;return n||this.schemas[t]||Ds.call(this,e,t)}function Ds(e,t){let n=this.opts.uriResolver.parse(t),r=pe._getFullPath(this.opts.uriResolver,n),o=pe.getFullPath(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&r===o)return Cl.call(this,n,e);let s=pe.normalizeId(r),i=this.refs[s]||this.schemas[s];if(typeof i==\"string\"){let a=Ds.call(this,e,i);if(typeof(a===null||a===void 0?void 0:a.schema)!==\"object\")return;return Cl.call(this,n,a)}if(typeof(i===null||i===void 0?void 0:i.schema)!==\"object\")return;if(!i.validate)El.call(this,i);if(s===pe.normalizeId(t)){let{schema:a}=i,{schemaId:c}=this.opts,l=a[c];if(l)o=pe.resolveUrl(this.opts.uriResolver,o,l);return new ro({schema:a,schemaId:c,root:e,baseId:o})}return Cl.call(this,n,i)}Nx.resolveSchema=Ds;var $q=new Set([\"properties\",\"patternProperties\",\"enum\",\"dependencies\",\"definitions\"]);function Cl(e,{baseId:t,schema:n,root:r}){var o;if(((o=e.fragment)===null||o===void 0?void 0:o[0])!==\"/\")return;for(let a of e.fragment.slice(1).split(\"/\")){if(typeof n===\"boolean\")return;let c=n[Ns.unescapeFragment(a)];if(c===void 0)return;n=c;let l=typeof n===\"object\"&&n[this.opts.schemaId];if(!$q.has(a)&&l)t=pe.resolveUrl(this.opts.uriResolver,t,l)}let s;if(typeof n!=\"boolean\"&&n.$ref&&!Ns.schemaHasRulesButRef(n,this.RULES)){let a=pe.resolveUrl(this.opts.uriResolver,t,n.$ref);s=Ds.call(this,r,a)}let{schemaId:i}=this.opts;if(s=s||new ro({schema:n,schemaId:i,root:r,baseId:t}),s.schema!==s.root.schema)return s;return}});var Ux=g(function(mZ,Nq){Nq.exports={$id:\"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#\",description:\"Meta-schema for $data reference (JSON AnySchema extension proposal)\",type:\"object\",required:[\"$data\"],properties:{$data:{type:\"string\",anyOf:[{format:\"relative-json-pointer\"},{format:\"json-pointer\"}]}},additionalProperties:!1}});var $l=g(function(fZ,Jx){var Dq=RegExp.prototype.test.bind(/^[\\da-f]{8}-[\\da-f]{4}-[\\da-f]{4}-[\\da-f]{4}-[\\da-f]{12}$/iu),Gx=RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\\d|1\\d{2}|[1-9]\\d|\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|1\\d{2}|[1-9]\\d|\\d)$/u),Pl=RegExp.prototype.test.bind(/^[\\da-f]{2}$/iu),Bx=RegExp.prototype.test.bind(/^[\\da-z\\-._~]$/iu),Uq=RegExp.prototype.test.bind(/^[\\da-z\\-._~!$&'()*+,;=:@/]$/iu);function Ol(e){let t=\"\",n=0,r=0;for(r=0;r<e.length;r++){if(n=e[r].charCodeAt(0),n===48)continue;if(!(n>=48&&n<=57||n>=65&&n<=70||n>=97&&n<=102))return\"\";t+=e[r];break}for(r+=1;r<e.length;r++){if(n=e[r].charCodeAt(0),!(n>=48&&n<=57||n>=65&&n<=70||n>=97&&n<=102))return\"\";t+=e[r]}return t}var Lq=RegExp.prototype.test.bind(/[^!\"$&'()*+,\\-.;=_`a-z{}~]/u);function Lx(e){return e.length=0,!0}function Gq(e,t,n){if(e.length){let r=Ol(e);if(r!==\"\")t.push(r);else return n.error=!0,!1;e.length=0}return!0}function Bq(e){let t=0,n={error:!1,address:\"\",zone:\"\"},r=[],o=[],s=!1,i=!1,a=Gq;for(let c=0;c<e.length;c++){let l=e[c];if(l===\"[\"||l===\"]\")continue;if(l===\":\"){if(s===!0)i=!0;if(!a(o,r,n))break;if(++t>7){n.error=!0;break}if(c>0&&e[c-1]===\":\")s=!0;r.push(\":\");continue}else if(l===\"%\"){if(!a(o,r,n))break;a=Lx}else{o.push(l);continue}}if(o.length)if(a===Lx)n.zone=o.join(\"\");else if(i)r.push(o.join(\"\"));else r.push(Ol(o));return n.address=r.join(\"\"),n}function Vx(e){if(Vq(e,\":\")<2)return{host:e,isIPV6:!1};let t=Bq(e);if(!t.error){let{address:n,address:r}=t;if(t.zone)n+=\"%\"+t.zone,r+=\"%25\"+t.zone;return{host:n,isIPV6:!0,escapedHost:r}}else return{host:e,isIPV6:!1}}function Vq(e,t){let n=0;for(let r=0;r<e.length;r++)if(e[r]===t)n++;return n}function Fq(e){let t=e,n=[],r=-1,o=0;while(o=t.length){if(o===1)if(t===\".\")break;else if(t===\"/\"){n.push(\"/\");break}else{n.push(t);break}else if(o===2){if(t[0]===\".\"){if(t[1]===\".\")break;else if(t[1]===\"/\"){t=t.slice(2);continue}}else if(t[0]===\"/\"){if(t[1]===\".\"||t[1]===\"/\"){n.push(\"/\");break}}}else if(o===3){if(t===\"/..\"){if(n.length!==0)n.pop();n.push(\"/\");break}}if(t[0]===\".\"){if(t[1]===\".\"){if(t[2]===\"/\"){t=t.slice(3);continue}}else if(t[1]===\"/\"){t=t.slice(2);continue}}else if(t[0]===\"/\"){if(t[1]===\".\"){if(t[2]===\"/\"){t=t.slice(2);continue}else if(t[2]===\".\"){if(t[3]===\"/\"){if(t=t.slice(3),n.length!==0)n.pop();continue}}}}if((r=t.indexOf(\"/\",1))===-1){n.push(t);break}else n.push(t.slice(0,r)),t=t.slice(r)}return n.join(\"\")}var Jq={\"@\":\"%40\",\"/\":\"%2F\",\"?\":\"%3F\",\"#\":\"%23\",\":\":\"%3A\"},Wq=/[@/?#:]/g,Kq=/[@/?#]/g;function Fx(e,t){let n=t?Kq:Wq;return n.lastIndex=0,e.replace(n,(r)=>Jq[r])}function Hq(e,t=!1){if(e.indexOf(\"%\")===-1)return e;let n=\"\";for(let r=0;r<e.length;r++){if(e[r]===\"%\"&&r+2<e.length){let o=e.slice(r+1,r+3);if(Pl(o)){let s=o.toUpperCase(),i=String.fromCharCode(parseInt(s,16));if(t&&Bx(i))n+=i;else n+=\"%\"+s;r+=2;continue}}n+=e[r]}return n}function Zq(e){let t=\"\";for(let n=0;n<e.length;n++){if(e[n]===\"%\"&&n+2<e.length){let r=e.slice(n+1,n+3);if(Pl(r)){let o=r.toUpperCase(),s=String.fromCharCode(parseInt(o,16));if(s!==\".\"&&Bx(s))t+=s;else t+=\"%\"+o;n+=2;continue}}if(Uq(e[n]))t+=e[n];else t+=escape(e[n])}return t}function Yq(e){let t=\"\";for(let n=0;n<e.length;n++){if(e[n]===\"%\"&&n+2<e.length){let r=e.slice(n+1,n+3);if(Pl(r)){t+=\"%\"+r.toUpperCase(),n+=2;continue}}t+=escape(e[n])}return t}function Xq(e){let t=[];if(e.userinfo!==void 0)t.push(e.userinfo),t.push(\"@\");if(e.host!==void 0){let n=unescape(e.host);if(!Gx(n)){let r=Vx(n);if(r.isIPV6===!0)n=`[${r.escapedHost}]`;else n=Fx(n,!1)}t.push(n)}if(typeof e.port===\"number\"||typeof e.port===\"string\")t.push(\":\"),t.push(String(e.port));return t.length?t.join(\"\"):void 0}Jx.exports={nonSimpleDomain:Lq,recomposeAuthority:Xq,reescapeHostDelimiters:Fx,normalizePercentEncoding:Hq,normalizePathEncoding:Zq,escapePreservingEscapes:Yq,removeDotSegments:Fq,isIPv4:Gx,isUUID:Dq,normalizeIPv6:Vx,stringArrayToHexStripped:Ol}});var Yx=g(function(gZ,Zx){var{isUUID:Qq}=$l(),ez=/([\\da-z][\\d\\-a-z]{0,31}):((?:[\\w!$'()*+,\\-.:;=@]|%[\\da-f]{2})+)/iu,tz=[\"http\",\"https\",\"ws\",\"wss\",\"urn\",\"urn:uuid\"];function nz(e){return tz.indexOf(e)!==-1}function Ml(e){if(e.secure===!0)return!0;else if(e.secure===!1)return!1;else if(e.scheme)return e.scheme.length===3&&(e.scheme[0]===\"w\"||e.scheme[0]===\"W\")&&(e.scheme[1]===\"s\"||e.scheme[1]===\"S\")&&(e.scheme[2]===\"s\"||e.scheme[2]===\"S\");else return!1}function Wx(e){if(!e.host)e.error=e.error||\"HTTP URIs must have a host.\";return e}function Kx(e){let t=String(e.scheme).toLowerCase()===\"https\";if(e.port===(t?443:80)||e.port===\"\")e.port=void 0;if(!e.path)e.path=\"/\";return e}function rz(e){return e.secure=Ml(e),e.resourceName=(e.path||\"/\")+(e.query?\"?\"+e.query:\"\"),e.path=void 0,e.query=void 0,e}function oz(e){if(e.port===(Ml(e)?443:80)||e.port===\"\")e.port=void 0;if(typeof e.secure===\"boolean\")e.scheme=e.secure?\"wss\":\"ws\",e.secure=void 0;if(e.resourceName){let[t,n]=e.resourceName.split(\"?\");e.path=t&&t!==\"/\"?t:void 0,e.query=n,e.resourceName=void 0}return e.fragment=void 0,e}function sz(e,t){if(!e.path)return e.error=\"URN can not be parsed\",e;let n=e.path.match(ez);if(n){let r=t.scheme||e.scheme||\"urn\";e.nid=n[1].toLowerCase(),e.nss=n[2];let o=`${r}:${t.nid||e.nid}`,s=ql(o);if(e.path=void 0,s)e=s.parse(e,t)}else e.error=e.error||\"URN can not be parsed.\";return e}function iz(e,t){if(e.nid===void 0)throw Error(\"URN without nid cannot be serialized\");let n=t.scheme||e.scheme||\"urn\",r=e.nid.toLowerCase(),o=`${n}:${t.nid||r}`,s=ql(o);if(s)e=s.serialize(e,t);let i=e,a=e.nss;return i.path=`${r||t.nid}:${a}`,t.skipEscape=!0,i}function az(e,t){let n=e;if(n.uuid=n.nss,n.nss=void 0,!t.tolerant&&(!n.uuid||!Qq(n.uuid)))n.error=n.error||\"UUID is not valid.\";return n}function cz(e){let t=e;return t.nss=(e.uuid||\"\").toLowerCase(),t}var Hx={scheme:\"http\",domainHost:!0,parse:Wx,serialize:Kx},lz={scheme:\"https\",domainHost:Hx.domainHost,parse:Wx,serialize:Kx},Us={scheme:\"ws\",domainHost:!0,parse:rz,serialize:oz},uz={scheme:\"wss\",domainHost:Us.domainHost,parse:Us.parse,serialize:Us.serialize},dz={scheme:\"urn\",parse:sz,serialize:iz,skipNormalize:!0},pz={scheme:\"urn:uuid\",parse:az,serialize:cz,skipNormalize:!0},Ls={http:Hx,https:lz,ws:Us,wss:uz,urn:dz,\"urn:uuid\":pz};Object.setPrototypeOf(Ls,null);function ql(e){return e&&(Ls[e]||Ls[e.toLowerCase()])||void 0}Zx.exports={wsIsSecure:Ml,SCHEMES:Ls,isValidSchemeName:nz,getSchemeHandler:ql}});var nS=g(function(hZ,Vs){var{normalizeIPv6:mz,removeDotSegments:so,recomposeAuthority:fz,normalizePercentEncoding:gz,normalizePathEncoding:hz,escapePreservingEscapes:yz,reescapeHostDelimiters:bz,isIPv4:vz,nonSimpleDomain:_z}=$l(),{SCHEMES:wz,getSchemeHandler:Qx}=Yx();function xz(e,t){if(typeof e===\"string\")e=Cz(e,t);else if(typeof e===\"object\")e=Bs(Tn(e,t),t);return e}function Sz(e,t,n){let r=n?Object.assign({scheme:\"null\"},n):{scheme:\"null\"},{parsed:o,malformedAuthorityOrPort:s}=Gs(e,r),{parsed:i,malformedAuthorityOrPort:a}=Gs(t,r);if(s||a)throw Error(o.error||i.error||\"URI is malformed.\");let c=eS(o,i,r,!0);return r.skipEscape=!0,Tn(c,r)}function eS(e,t,n,r){let o={};if(!r)e=Bs(Tn(e,n),n),t=Bs(Tn(t,n),n);if(n=n||{},!n.tolerant&&t.scheme)o.scheme=t.scheme,o.userinfo=t.userinfo,o.host=t.host,o.port=t.port,o.path=so(t.path||\"\"),o.query=t.query;else{if(t.userinfo!==void 0||t.host!==void 0||t.port!==void 0)o.userinfo=t.userinfo,o.host=t.host,o.port=t.port,o.path=so(t.path||\"\"),o.query=t.query;else{if(!t.path)if(o.path=e.path,t.query!==void 0)o.query=t.query;else o.query=e.query;else{if(t.path[0]===\"/\")o.path=so(t.path);else{if((e.userinfo!==void 0||e.host!==void 0||e.port!==void 0)&&!e.path)o.path=\"/\"+t.path;else if(!e.path)o.path=t.path;else o.path=e.path.slice(0,e.path.lastIndexOf(\"/\")+1)+t.path;o.path=so(o.path)}o.query=t.query}o.userinfo=e.userinfo,o.host=e.host,o.port=e.port}o.scheme=e.scheme}return o.fragment=t.fragment,o}function Iz(e,t,n){let r=Xx(e,n),o=Xx(t,n);return r!==void 0&&o!==void 0&&r.toLowerCase()===o.toLowerCase()}function Tn(e,t){let n={host:e.host,scheme:e.scheme,userinfo:e.userinfo,port:e.port,path:e.path,query:e.query,nid:e.nid,nss:e.nss,uuid:e.uuid,fragment:e.fragment,reference:e.reference,resourceName:e.resourceName,secure:e.secure,error:\"\"},r=Object.assign({},t),o=[],s=Qx(r.scheme||n.scheme);if(s&&s.serialize)s.serialize(n,r);if(n.path!==void 0)if(!r.skipEscape){if(n.path=yz(n.path),n.scheme!==void 0)n.path=n.path.split(\"%3A\").join(\":\")}else n.path=gz(n.path);if(r.reference!==\"suffix\"&&n.scheme)o.push(n.scheme,\":\");let i=fz(n);if(i!==void 0){if(r.reference!==\"suffix\")o.push(\"//\");if(o.push(i),n.path&&n.path[0]!==\"/\")o.push(\"/\")}if(n.path!==void 0){let a=n.path;if(!r.absolutePath&&(!s||!s.absolutePath))a=so(a);if(i===void 0&&a[0]===\"/\"&&a[1]===\"/\")a=\"/%2F\"+a.slice(2);o.push(a)}if(n.query!==void 0)o.push(\"?\",n.query);if(n.fragment!==void 0)o.push(\"#\",n.fragment);return o.join(\"\")}var kz=/^(?:([^#/:?]+):)?(?:\\/\\/((?:([^#/?@]*)@)?(\\[[^#/?\\]]+\\]|[^#/:?]*)(?::(\\d*))?))?([^#?]*)(?:\\?([^#]*))?(?:#((?:.|[\\n\\r])*))?/u,Rz=/^(?:[^#/:?]+:)?\\/\\/([^/?#]*)/,Tz=/^(?:[^#/:?]+:)?([/\\\\\\t\\n\\r]*)/;function Az(e,t){if(t[2]!==void 0&&e.path&&e.path[0]!==\"/\")return'URI path must start with \"/\" when authority is present.';if(typeof e.port===\"number\"&&(e.port<0||e.port>65535))return\"URI port is malformed.\";return}function Gs(e,t){let n=Object.assign({},t),r={scheme:void 0,userinfo:void 0,host:\"\",port:void 0,path:\"\",query:void 0,fragment:void 0},o=!1,s=!1;if(n.reference===\"suffix\")if(n.scheme)e=n.scheme+\":\"+e;else e=\"//\"+e;let i=e.match(Rz);if(i!==null&&i[1].indexOf(\"\\\\\")!==-1)r.error=\"URI authority must not contain a literal backslash.\",o=!0;let a=e.match(Tz);if(a!==null){let l=a[1],u=l.replace(/[\\t\\n\\r]/g,\"\");if(u.length>=2){if(u.slice(0,2)!==\"//\")r.error=r.error||\"URI authority must not contain a literal backslash.\",o=!0;else if(l.length!==u.length)r.error=r.error||\"URI authority introducer must not contain whitespace.\",o=!0}}let c=e.match(kz);if(c){if(r.scheme=c[1],r.userinfo=c[3],r.host=c[4],r.port=parseInt(c[5],10),r.path=c[6]||\"\",r.query=c[7],r.fragment=c[8],isNaN(r.port))r.port=c[5];let l=Az(r,c);if(l!==void 0)r.error=r.error||l,o=!0;if(r.host)if(vz(r.host)===!1){let m=mz(r.host);r.host=m.host.toLowerCase(),s=m.isIPV6}else s=!0;if(r.scheme===void 0&&r.userinfo===void 0&&r.host===void 0&&r.port===void 0&&r.query===void 0&&!r.path)r.reference=\"same-document\";else if(r.scheme===void 0)r.reference=\"relative\";else if(r.fragment===void 0)r.reference=\"absolute\";else r.reference=\"uri\";if(n.reference&&n.reference!==\"suffix\"&&n.reference!==r.reference)r.error=r.error||\"URI is not a \"+n.reference+\" reference.\";let u=Qx(n.scheme||r.scheme);if(!n.unicodeSupport&&(!u||!u.unicodeSupport)){if(r.host&&(n.domainHost||u&&u.domainHost)&&s===!1&&_z(r.host))try{r.host=new URL(\"http://\"+r.host).hostname}catch(p){r.error=r.error||\"Host's domain name can not be converted to ASCII: \"+p}}if(!u||u&&!u.skipNormalize){if(e.indexOf(\"%\")!==-1){if(r.scheme!==void 0)r.scheme=unescape(r.scheme);if(r.host!==void 0)r.host=bz(unescape(r.host),s)}if(r.path)r.path=hz(r.path);if(r.fragment)try{r.fragment=encodeURI(decodeURIComponent(r.fragment))}catch{r.error=r.error||\"URI malformed\"}}if(u&&u.parse)u.parse(r,n)}else r.error=r.error||\"URI can not be parsed.\";return{parsed:r,malformedAuthorityOrPort:o}}function Bs(e,t){return Gs(e,t).parsed}function Cz(e,t){return tS(e,t).normalized}function tS(e,t){let{parsed:n,malformedAuthorityOrPort:r}=Gs(e,t);return{normalized:r?e:Tn(n,t),malformedAuthorityOrPort:r}}function Xx(e,t){if(typeof e===\"string\"){let{normalized:n,malformedAuthorityOrPort:r}=tS(e,t);return r?void 0:n}if(typeof e===\"object\")return Tn(e,t)}var zl={SCHEMES:wz,normalize:xz,resolve:Sz,resolveComponent:eS,equal:Iz,serialize:Tn,parse:Bs};Vs.exports=zl;Vs.exports.default=zl;Vs.exports.fastUri=zl});var sS=g(function(oS){Object.defineProperty(oS,\"__esModule\",{value:!0});var rS=nS();rS.code='require(\"ajv/dist/runtime/uri\").default';oS.default=rS});var Js=g(function(St){Object.defineProperty(St,\"__esModule\",{value:!0});St.CodeGen=St.Name=St.nil=St.stringify=St.str=St._=St.KeywordCxt=void 0;var Pz=In();Object.defineProperty(St,\"KeywordCxt\",{enumerable:!0,get:function(){return Pz.KeywordCxt}});var ur=N();Object.defineProperty(St,\"_\",{enumerable:!0,get:function(){return ur._}});Object.defineProperty(St,\"str\",{enumerable:!0,get:function(){return ur.str}});Object.defineProperty(St,\"stringify\",{enumerable:!0,get:function(){return ur.stringify}});Object.defineProperty(St,\"nil\",{enumerable:!0,get:function(){return ur.nil}});Object.defineProperty(St,\"Name\",{enumerable:!0,get:function(){return ur.Name}});Object.defineProperty(St,\"CodeGen\",{enumerable:!0,get:function(){return ur.CodeGen}});var Oz=ar(),uS=kn(),dS=bl(),ot=oo(),pS=N(),st=no(),Vt=to(),lr=B(),iS=Ux(),$z=sS(),mS=(e,t)=>new RegExp(e,t);mS.code=\"new RegExp\";var Mz=[\"removeAdditional\",\"useDefaults\",\"coerceTypes\"],qz=new Set([\"validate\",\"serialize\",\"parse\",\"wrapper\",\"root\",\"schema\",\"keyword\",\"pattern\",\"formats\",\"validate$data\",\"func\",\"obj\",\"Error\"]),zz={errorDataPath:\"\",format:\"`validateFormats: false` can be used instead.\",nullable:'\"nullable\" keyword is supported by default.',jsonPointers:\"Deprecated jsPropertySyntax can be used instead.\",extendRefs:\"Deprecated ignoreKeywordsWithRef can be used instead.\",missingRefs:\"Pass empty schema with $id that should be ignored to ajv.addSchema.\",processCode:\"Use option `code: {process: (code, schemaEnv: object) => string}`\",sourceCode:\"Use option `code: {source: true}`\",strictDefaults:\"It is default now, see option `strict`.\",strictKeywords:\"It is default now, see option `strict`.\",uniqueItems:'\"uniqueItems\" keyword is always validated.',unknownFormats:\"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).\",cache:\"Map is used as cache, schema object as key.\",serialize:\"Map is used as cache, schema object as key.\",ajvErrors:\"It is default now.\"},jz={ignoreKeywordsWithRef:\"\",jsPropertySyntax:\"\",unicode:'\"minLength\"/\"maxLength\" account for unicode characters by default.'},aS=200;function Nz(e){var t,n,r,o,s,i,a,c,l,u,p,m,d,f,h,y,_,E,T,A,x,K,C,D,V;let L=e.strict,H=(t=e.code)===null||t===void 0?void 0:t.optimize,oe=H===!0||H===void 0?1:H||0,Te=(r=(n=e.code)===null||n===void 0?void 0:n.regExp)!==null&&r!==void 0?r:mS,je=(o=e.uriResolver)!==null&&o!==void 0?o:$z.default;return{strictSchema:(i=(s=e.strictSchema)!==null&&s!==void 0?s:L)!==null&&i!==void 0?i:!0,strictNumbers:(c=(a=e.strictNumbers)!==null&&a!==void 0?a:L)!==null&&c!==void 0?c:!0,strictTypes:(u=(l=e.strictTypes)!==null&&l!==void 0?l:L)!==null&&u!==void 0?u:\"log\",strictTuples:(m=(p=e.strictTuples)!==null&&p!==void 0?p:L)!==null&&m!==void 0?m:\"log\",strictRequired:(f=(d=e.strictRequired)!==null&&d!==void 0?d:L)!==null&&f!==void 0?f:!1,code:e.code?{...e.code,optimize:oe,regExp:Te}:{optimize:oe,regExp:Te},loopRequired:(h=e.loopRequired)!==null&&h!==void 0?h:aS,loopEnum:(y=e.loopEnum)!==null&&y!==void 0?y:aS,meta:(_=e.meta)!==null&&_!==void 0?_:!0,messages:(E=e.messages)!==null&&E!==void 0?E:!0,inlineRefs:(T=e.inlineRefs)!==null&&T!==void 0?T:!0,schemaId:(A=e.schemaId)!==null&&A!==void 0?A:\"$id\",addUsedSchema:(x=e.addUsedSchema)!==null&&x!==void 0?x:!0,validateSchema:(K=e.validateSchema)!==null&&K!==void 0?K:!0,validateFormats:(C=e.validateFormats)!==null&&C!==void 0?C:!0,unicodeRegExp:(D=e.unicodeRegExp)!==null&&D!==void 0?D:!0,int32range:(V=e.int32range)!==null&&V!==void 0?V:!0,uriResolver:je}}class Fs{constructor(e={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=new Set,this._loading={},this._cache=new Map,e=this.opts={...e,...Nz(e)};let{es5:t,lines:n}=this.opts.code;this.scope=new pS.ValueScope({scope:{},prefixes:qz,es5:t,lines:n}),this.logger=Vz(e.logger);let r=e.validateFormats;if(e.validateFormats=!1,this.RULES=dS.getRules(),cS.call(this,zz,e,\"NOT SUPPORTED\"),cS.call(this,jz,e,\"DEPRECATED\",\"warn\"),this._metaOpts=Gz.call(this),e.formats)Uz.call(this);if(this._addVocabularies(),this._addDefaultMetaSchema(),e.keywords)Lz.call(this,e.keywords);if(typeof e.meta==\"object\")this.addMetaSchema(e.meta);Dz.call(this),e.validateFormats=r}_addVocabularies(){this.addKeyword(\"$async\")}_addDefaultMetaSchema(){let{$data:e,meta:t,schemaId:n}=this.opts,r=iS;if(n===\"id\")r={...iS},r.id=r.$id,delete r.$id;if(t&&e)this.addMetaSchema(r,r[n],!1)}defaultMeta(){let{meta:e,schemaId:t}=this.opts;return this.opts.defaultMeta=typeof e==\"object\"?e[t]||e:void 0}validate(e,t){let n;if(typeof e==\"string\"){if(n=this.getSchema(e),!n)throw Error(`no schema with key or ref \"${e}\"`)}else n=this.compile(e);let r=n(t);if(!(\"$async\"in n))this.errors=n.errors;return r}compile(e,t){let n=this._addSchema(e,t);return n.validate||this._compileSchemaEnv(n)}compileAsync(e,t){if(typeof this.opts.loadSchema!=\"function\")throw Error(\"options.loadSchema should be a function\");let{loadSchema:n}=this.opts;return r.call(this,e,t);async function r(l,u){await o.call(this,l.$schema);let p=this._addSchema(l,u);return p.validate||s.call(this,p)}async function o(l){if(l&&!this.getSchema(l))await r.call(this,{$ref:l},!0)}async function s(l){try{return this._compileSchemaEnv(l)}catch(u){if(!(u instanceof uS.default))throw u;return i.call(this,u),await a.call(this,u.missingSchema),s.call(this,l)}}function i({missingSchema:l,missingRef:u}){if(this.refs[l])throw Error(`AnySchema ${l} is loaded but ${u} cannot be resolved`)}async function a(l){let u=await c.call(this,l);if(!this.refs[l])await o.call(this,u.$schema);if(!this.refs[l])this.addSchema(u,l,t)}async function c(l){let u=this._loading[l];if(u)return u;try{return await(this._loading[l]=n(l))}finally{delete this._loading[l]}}}addSchema(e,t,n,r=this.opts.validateSchema){if(Array.isArray(e)){for(let s of e)this.addSchema(s,void 0,n,r);return this}let o;if(typeof e===\"object\"){let{schemaId:s}=this.opts;if(o=e[s],o!==void 0&&typeof o!=\"string\")throw Error(`schema ${s} must be string`)}return t=st.normalizeId(t||o),this._checkUnique(t),this.schemas[t]=this._addSchema(e,n,t,r,!0),this}addMetaSchema(e,t,n=this.opts.validateSchema){return this.addSchema(e,t,!0,n),this}validateSchema(e,t){if(typeof e==\"boolean\")return!0;let n;if(n=e.$schema,n!==void 0&&typeof n!=\"string\")throw Error(\"$schema must be a string\");if(n=n||this.opts.defaultMeta||this.defaultMeta(),!n)return this.logger.warn(\"meta-schema not available\"),this.errors=null,!0;let r=this.validate(n,e);if(!r&&t){let o=\"schema is invalid: \"+this.errorsText();if(this.opts.validateSchema===\"log\")this.logger.error(o);else throw Error(o)}return r}getSchema(e){let t;while(typeof(t=lS.call(this,e))==\"string\")e=t;if(t===void 0){let{schemaId:n}=this.opts,r=new ot.SchemaEnv({schema:{},schemaId:n});if(t=ot.resolveSchema.call(this,r,e),!t)return;this.refs[e]=t}return t.validate||this._compileSchemaEnv(t)}removeSchema(e){if(e instanceof RegExp)return this._removeAllSchemas(this.schemas,e),this._removeAllSchemas(this.refs,e),this;switch(typeof e){case\"undefined\":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case\"string\":{let t=lS.call(this,e);if(typeof t==\"object\")this._cache.delete(t.schema);return delete this.schemas[e],delete this.refs[e],this}case\"object\":{let t=e;this._cache.delete(t);let n=e[this.opts.schemaId];if(n)n=st.normalizeId(n),delete this.schemas[n],delete this.refs[n];return this}default:throw Error(\"ajv.removeSchema: invalid parameter\")}}addVocabulary(e){for(let t of e)this.addKeyword(t);return this}addKeyword(e,t){let n;if(typeof e==\"string\"){if(n=e,typeof t==\"object\")this.logger.warn(\"these parameters are deprecated, see docs for addKeyword\"),t.keyword=n}else if(typeof e==\"object\"&&t===void 0){if(t=e,n=t.keyword,Array.isArray(n)&&!n.length)throw Error(\"addKeywords: keyword must be string or non-empty array\")}else throw Error(\"invalid addKeywords parameters\");if(Jz.call(this,n,t),!t)return lr.eachItem(n,(o)=>jl.call(this,o)),this;Kz.call(this,t);let r={...t,type:Vt.getJSONTypes(t.type),schemaType:Vt.getJSONTypes(t.schemaType)};return lr.eachItem(n,r.type.length===0?(o)=>jl.call(this,o,r):(o)=>r.type.forEach((s)=>jl.call(this,o,r,s))),this}getKeyword(e){let t=this.RULES.all[e];return typeof t==\"object\"?t.definition:!!t}removeKeyword(e){let{RULES:t}=this;delete t.keywords[e],delete t.all[e];for(let n of t.rules){let r=n.rules.findIndex((o)=>o.keyword===e);if(r>=0)n.rules.splice(r,1)}return this}addFormat(e,t){if(typeof t==\"string\")t=new RegExp(t);return this.formats[e]=t,this}errorsText(e=this.errors,{separator:t=\", \",dataVar:n=\"data\"}={}){if(!e||e.length===0)return\"No errors\";return e.map((r)=>`${n}${r.instancePath} ${r.message}`).reduce((r,o)=>r+t+o)}$dataMetaSchema(e,t){let n=this.RULES.all;e=JSON.parse(JSON.stringify(e));for(let r of t){let o=r.split(\"/\").slice(1),s=e;for(let i of o)s=s[i];for(let i in n){let a=n[i];if(typeof a!=\"object\")continue;let{$data:c}=a.definition,l=s[i];if(c&&l)s[i]=fS(l)}}return e}_removeAllSchemas(e,t){for(let n in e){let r=e[n];if(!t||t.test(n)){if(typeof r==\"string\")delete e[n];else if(r&&!r.meta)this._cache.delete(r.schema),delete e[n]}}}_addSchema(e,t,n,r=this.opts.validateSchema,o=this.opts.addUsedSchema){let s,{schemaId:i}=this.opts;if(typeof e==\"object\")s=e[i];else if(this.opts.jtd)throw Error(\"schema must be object\");else if(typeof e!=\"boolean\")throw Error(\"schema must be object or boolean\");let a=this._cache.get(e);if(a!==void 0)return a;n=st.normalizeId(s||n);let c=st.getSchemaRefs.call(this,e,n);if(a=new ot.SchemaEnv({schema:e,schemaId:i,meta:t,baseId:n,localRefs:c}),this._cache.set(a.schema,a),o&&!n.startsWith(\"#\")){if(n)this._checkUnique(n);this.refs[n]=a}if(r)this.validateSchema(e,!0);return a}_checkUnique(e){if(this.schemas[e]||this.refs[e])throw Error(`schema with key or id \"${e}\" already exists`)}_compileSchemaEnv(e){if(e.meta)this._compileMetaSchema(e);else ot.compileSchema.call(this,e);if(!e.validate)throw Error(\"ajv implementation error\");return e.validate}_compileMetaSchema(e){let t=this.opts;this.opts=this._metaOpts;try{ot.compileSchema.call(this,e)}finally{this.opts=t}}}Fs.ValidationError=Oz.default;Fs.MissingRefError=uS.default;St.default=Fs;function cS(e,t,n,r=\"error\"){for(let o in e){let s=o;if(s in t)this.logger[r](`${n}: option ${o}. ${e[s]}`)}}function lS(e){return e=st.normalizeId(e),this.schemas[e]||this.refs[e]}function Dz(){let e=this.opts.schemas;if(!e)return;if(Array.isArray(e))this.addSchema(e);else for(let t in e)this.addSchema(e[t],t)}function Uz(){for(let e in this.opts.formats){let t=this.opts.formats[e];if(t)this.addFormat(e,t)}}function Lz(e){if(Array.isArray(e)){this.addVocabulary(e);return}this.logger.warn(\"keywords option as map is deprecated, pass array\");for(let t in e){let n=e[t];if(!n.keyword)n.keyword=t;this.addKeyword(n)}}function Gz(){let e={...this.opts};for(let t of Mz)delete e[t];return e}var Bz={log(){},warn(){},error(){}};function Vz(e){if(e===!1)return Bz;if(e===void 0)return console;if(e.log&&e.warn&&e.error)return e;throw Error(\"logger must implement log, warn and error methods\")}var Fz=/^[a-z_$][a-z0-9_$:-]*$/i;function Jz(e,t){let{RULES:n}=this;if(lr.eachItem(e,(r)=>{if(n.keywords[r])throw Error(`Keyword ${r} is already defined`);if(!Fz.test(r))throw Error(`Keyword ${r} has invalid name`)}),!t)return;if(t.$data&&!((\"code\"in t)||(\"validate\"in t)))throw Error('$data keyword must have \"code\" or \"validate\" function')}function jl(e,t,n){var r;let o=t===null||t===void 0?void 0:t.post;if(n&&o)throw Error('keyword with \"post\" flag cannot have \"type\"');let{RULES:s}=this,i=o?s.post:s.rules.find(({type:c})=>c===n);if(!i)i={type:n,rules:[]},s.rules.push(i);if(s.keywords[e]=!0,!t)return;let a={keyword:e,definition:{...t,type:Vt.getJSONTypes(t.type),schemaType:Vt.getJSONTypes(t.schemaType)}};if(t.before)Wz.call(this,i,a,t.before);else i.rules.push(a);s.all[e]=a,(r=t.implements)===null||r===void 0||r.forEach((c)=>this.addKeyword(c))}function Wz(e,t,n){let r=e.rules.findIndex((o)=>o.keyword===n);if(r>=0)e.rules.splice(r,0,t);else e.rules.push(t),this.logger.warn(`rule ${n} is not defined`)}function Kz(e){let{metaSchema:t}=e;if(t===void 0)return;if(e.$data&&this.opts.$data)t=fS(t);e.validateSchema=this.compile(t,!0)}var Hz={$ref:\"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#\"};function fS(e){return{anyOf:[e,Hz]}}});var hS=g(function(gS){Object.defineProperty(gS,\"__esModule\",{value:!0});var Xz={keyword:\"id\",code(){throw Error('NOT SUPPORTED: keyword \"id\", use \"$id\" for schema ID')}};gS.default=Xz});var Zs=g(function(bS){Object.defineProperty(bS,\"__esModule\",{value:!0});bS.callRef=bS.getValidate=void 0;var ej=kn(),Ks=Be(),ee=N(),dr=Le(),Hs=oo(),Ft=B(),tj={keyword:\"$ref\",schemaType:\"string\",code(e){let{gen:t,schema:n,it:r}=e,{baseId:o,schemaEnv:s,validateName:i,opts:a,self:c}=r,{root:l}=s;if((n===\"#\"||n===\"#/\")&&o===l.baseId)return p();let u=Hs.resolveRef.call(c,l,o,n);if(u===void 0)throw new ej.default(r.opts.uriResolver,o,n);if(u instanceof Hs.SchemaEnv)return m(u);return d(u);function p(){if(s===l)return Ws(e,i,s,s.$async);let f=t.scopeValue(\"root\",{ref:l});return Ws(e,ee._`${f}.validate`,l,l.$async)}function m(f){let h=yS(e,f);Ws(e,h,f,f.$async)}function d(f){let h=t.scopeValue(\"schema\",a.code.source===!0?{ref:f,code:ee.stringify(f)}:{ref:f}),y=t.name(\"valid\"),_=e.subschema({schema:f,dataTypes:[],schemaPath:ee.nil,topSchemaRef:h,errSchemaPath:n},y);e.mergeEvaluated(_),e.ok(y)}}};function yS(e,t){let{gen:n}=e;return t.validate?n.scopeValue(\"validate\",{ref:t.validate}):ee._`${n.scopeValue(\"wrapper\",{ref:t})}.validate`}bS.getValidate=yS;function Ws(e,t,n,r){let{gen:o,it:s}=e,{allErrors:i,schemaEnv:a,opts:c}=s,l=c.passContext?dr.default.this:ee.nil;if(r)u();else p();function u(){if(!a.$async)throw Error(\"async schema referenced by sync schema\");let f=o.let(\"valid\");o.try(()=>{if(o.code(ee._`await ${Ks.callValidateCode(e,t,l)}`),d(t),!i)o.assign(f,!0)},(h)=>{if(o.if(ee._`!(${h} instanceof ${s.ValidationError})`,()=>o.throw(h)),m(h),!i)o.assign(f,!1)}),e.ok(f)}function p(){e.result(Ks.callValidateCode(e,t,l),()=>d(t),()=>m(t))}function m(f){let h=ee._`${f}.errors`;o.assign(dr.default.vErrors,ee._`${dr.default.vErrors} === null ? ${h} : ${dr.default.vErrors}.concat(${h})`),o.assign(dr.default.errors,ee._`${dr.default.vErrors}.length`)}function d(f){var h;if(!s.opts.unevaluated)return;let y=(h=n===null||n===void 0?void 0:n.validate)===null||h===void 0?void 0:h.evaluated;if(s.props!==!0)if(y&&!y.dynamicProps){if(y.props!==void 0)s.props=Ft.mergeEvaluated.props(o,y.props,s.props)}else{let _=o.var(\"props\",ee._`${f}.evaluated.props`);s.props=Ft.mergeEvaluated.props(o,_,s.props,ee.Name)}if(s.items!==!0)if(y&&!y.dynamicItems){if(y.items!==void 0)s.items=Ft.mergeEvaluated.items(o,y.items,s.items)}else{let _=o.var(\"items\",ee._`${f}.evaluated.items`);s.items=Ft.mergeEvaluated.items(o,_,s.items,ee.Name)}}}bS.callRef=Ws;bS.default=tj});var Nl=g(function(_S){Object.defineProperty(_S,\"__esModule\",{value:!0});var oj=hS(),sj=Zs(),ij=[\"$schema\",\"$id\",\"$defs\",\"$vocabulary\",{keyword:\"$comment\"},\"definitions\",oj.default,sj.default];_S.default=ij});var xS=g(function(wS){Object.defineProperty(wS,\"__esModule\",{value:!0});var Wt=N(),Jt=Wt.operators,Ys={maximum:{okStr:\"<=\",ok:Jt.LTE,fail:Jt.GT},minimum:{okStr:\">=\",ok:Jt.GTE,fail:Jt.LT},exclusiveMaximum:{okStr:\"<\",ok:Jt.LT,fail:Jt.GTE},exclusiveMinimum:{okStr:\">\",ok:Jt.GT,fail:Jt.LTE}},cj={message:({keyword:e,schemaCode:t})=>Wt.str`must be ${Ys[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>Wt._`{comparison: ${Ys[e].okStr}, limit: ${t}}`},lj={keyword:Object.keys(Ys),type:\"number\",schemaType:\"number\",$data:!0,error:cj,code(e){let{keyword:t,data:n,schemaCode:r}=e;e.fail$data(Wt._`${n} ${Ys[t].fail} ${r} || isNaN(${n})`)}};wS.default=lj});var IS=g(function(SS){Object.defineProperty(SS,\"__esModule\",{value:!0});var it=N(),dj={message:({schemaCode:e})=>it.str`must be multiple of ${e}`,params:({schemaCode:e})=>it._`{multipleOf: ${e}}`},pj={keyword:\"multipleOf\",type:\"number\",schemaType:\"number\",$data:!0,error:dj,code(e){let{gen:t,data:n,schemaCode:r,it:o}=e,s=o.opts.multipleOfPrecision,i=t.let(\"res\"),a=s?it._`Math.abs(Math.round(${i}) - ${i}) > 1e-${s}`:it._`${i} !== parseInt(${i})`;e.fail$data(it._`(${r} === 0 || (${i} = ${n}/${r}, ${a}))`)}};SS.default=pj});var TS=g(function(RS){Object.defineProperty(RS,\"__esModule\",{value:!0});function kS(e){let t=e.length,n=0,r=0,o;while(r<t)if(n++,o=e.charCodeAt(r++),o>=55296&&o<=56319&&r<t){if(o=e.charCodeAt(r),(o&64512)===56320)r++}return n}RS.default=kS;kS.code='require(\"ajv/dist/runtime/ucs2length\").default'});var ES=g(function(CS){Object.defineProperty(CS,\"__esModule\",{value:!0});var Ee=N(),AS=B(),gj=TS(),hj={message({keyword:e,schemaCode:t}){return Ee.str`must NOT have ${e===\"maxLength\"?\"more\":\"fewer\"} than ${t} characters`},params:({schemaCode:e})=>Ee._`{limit: ${e}}`},yj={keyword:[\"maxLength\",\"minLength\"],type:\"string\",schemaType:\"number\",$data:!0,error:hj,code(e){let{keyword:t,data:n,schemaCode:r,it:o}=e,s=t===\"maxLength\"?Ee.operators.GT:Ee.operators.LT,i=o.opts.unicode===!1?Ee._`${n}.length`:Ee._`${AS.useFunc(e.gen,gj.default)}(${n})`;e.fail$data(Ee._`${i} ${s} ${r}`)}};CS.default=yj});var MS=g(function($S){Object.defineProperty($S,\"__esModule\",{value:!0});var PS=Be(),OS=B(),Ve=N(),vj={message:({schemaCode:e})=>Ve.str`must match pattern \"${e}\"`,params:({schemaCode:e})=>Ve._`{pattern: ${e}}`},_j={keyword:\"pattern\",type:\"string\",schemaType:\"string\",$data:!0,error:vj,code(e){let{gen:t,data:n,$data:r,schema:o,schemaCode:s,it:i}=e,a=i.opts.unicodeRegExp?\"u\":\"\";if(r){let{regExp:c}=i.opts.code,l=c.code===\"new RegExp\"?Ve._`new RegExp`:OS.useFunc(t,c),u=t.let(\"valid\");t.try(()=>t.assign(u,Ve._`${l}(${s}, ${a}).test(${n})`),()=>t.assign(u,!1)),e.fail$data(Ve._`!${u}`)}else{let c=PS.usePattern(e,o);e.fail$data(Ve._`!${c}.test(${n})`)}}};$S.default=_j});var zS=g(function(qS){Object.defineProperty(qS,\"__esModule\",{value:!0});var at=N(),xj={message({keyword:e,schemaCode:t}){return at.str`must NOT have ${e===\"maxProperties\"?\"more\":\"fewer\"} than ${t} properties`},params:({schemaCode:e})=>at._`{limit: ${e}}`},Sj={keyword:[\"maxProperties\",\"minProperties\"],type:\"object\",schemaType:\"number\",$data:!0,error:xj,code(e){let{keyword:t,data:n,schemaCode:r}=e,o=t===\"maxProperties\"?at.operators.GT:at.operators.LT;e.fail$data(at._`Object.keys(${n}).length ${o} ${r}`)}};qS.default=Sj});var DS=g(function(NS){Object.defineProperty(NS,\"__esModule\",{value:!0});var ct=Be(),lt=N(),jS=B(),kj={message:({params:{missingProperty:e}})=>lt.str`must have required property '${e}'`,params:({params:{missingProperty:e}})=>lt._`{missingProperty: ${e}}`},Rj={keyword:\"required\",type:\"object\",schemaType:\"array\",$data:!0,error:kj,code(e){let{gen:t,schema:n,schemaCode:r,data:o,$data:s,it:i}=e,{opts:a}=i;if(!s&&n.length===0)return;let c=n.length>=a.loopRequired;if(i.allErrors)l();else u();if(a.strictRequired){let d=e.parentSchema.properties,{definedProperties:f}=e.it;for(let h of n)if((d===null||d===void 0?void 0:d[h])===void 0&&!f.has(h)){let y=i.schemaEnv.baseId+i.errSchemaPath,_=`required property \"${h}\" is not defined at \"${y}\" (strictRequired)`;jS.checkStrictMode(i,_,i.opts.strictRequired)}}function l(){if(c||s)e.block$data(lt.nil,p);else for(let d of n)ct.checkReportMissingProp(e,d)}function u(){let d=t.let(\"missing\");if(c||s){let f=t.let(\"valid\",!0);e.block$data(f,()=>m(d,f)),e.ok(f)}else t.if(ct.checkMissingProp(e,n,d)),ct.reportMissingProp(e,d),t.else()}function p(){t.forOf(\"prop\",r,(d)=>{e.setParams({missingProperty:d}),t.if(ct.noPropertyInData(t,o,d,a.ownProperties),()=>e.error())})}function m(d,f){e.setParams({missingProperty:d}),t.forOf(d,r,()=>{t.assign(f,ct.propertyInData(t,o,d,a.ownProperties)),t.if(lt.not(f),()=>{e.error(),t.break()})},lt.nil)}}};NS.default=Rj});var LS=g(function(US){Object.defineProperty(US,\"__esModule\",{value:!0});var ut=N(),Aj={message({keyword:e,schemaCode:t}){return ut.str`must NOT have ${e===\"maxItems\"?\"more\":\"fewer\"} than ${t} items`},params:({schemaCode:e})=>ut._`{limit: ${e}}`},Cj={keyword:[\"maxItems\",\"minItems\"],type:\"array\",schemaType:\"number\",$data:!0,error:Aj,code(e){let{keyword:t,data:n,schemaCode:r}=e,o=t===\"maxItems\"?ut.operators.GT:ut.operators.LT;e.fail$data(ut._`${n}.length ${o} ${r}`)}};US.default=Cj});var Xs=g(function(BS){Object.defineProperty(BS,\"__esModule\",{value:!0});var GS=kl();GS.code='require(\"ajv/dist/runtime/equal\").default';BS.default=GS});var JS=g(function(FS){Object.defineProperty(FS,\"__esModule\",{value:!0});var pr=to(),W=N(),VS=B(),Oj=Xs(),$j={message:({params:{i:e,j:t}})=>W.str`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>W._`{i: ${e}, j: ${t}}`},Mj={keyword:\"uniqueItems\",type:\"array\",schemaType:\"boolean\",$data:!0,error:$j,code(e){let{gen:t,data:n,$data:r,schema:o,parentSchema:s,schemaCode:i,it:a}=e;if(!r&&!o)return;let c=t.let(\"valid\"),l=s.items?pr.getSchemaTypes(s.items):[];e.block$data(c,u,W._`${i} === false`),e.ok(c);function u(){let f=t.let(\"i\",W._`${n}.length`),h=t.let(\"j\");e.setParams({i:f,j:h}),t.assign(c,!0),t.if(W._`${f} > 1`,()=>(p()?m:d)(f,h))}function p(){return l.length>0&&!l.some((f)=>f===\"object\"||f===\"array\")}function m(f,h){let y=t.name(\"item\"),_=pr.checkDataTypes(l,y,a.opts.strictNumbers,pr.DataType.Wrong),E=t.const(\"indices\",W._`{}`);t.for(W._`;${f}--;`,()=>{if(t.let(y,W._`${n}[${f}]`),t.if(_,W._`continue`),l.length>1)t.if(W._`typeof ${y} == \"string\"`,W._`${y} += \"_\"`);t.if(W._`typeof ${E}[${y}] == \"number\"`,()=>{t.assign(h,W._`${E}[${y}]`),e.error(),t.assign(c,!1).break()}).code(W._`${E}[${y}] = ${f}`)})}function d(f,h){let y=VS.useFunc(t,Oj.default),_=t.name(\"outer\");t.label(_).for(W._`;${f}--;`,()=>t.for(W._`${h} = ${f}; ${h}--;`,()=>t.if(W._`${y}(${n}[${f}], ${n}[${h}])`,()=>{e.error(),t.assign(c,!1).break(_)})))}}};FS.default=Mj});var HS=g(function(KS){Object.defineProperty(KS,\"__esModule\",{value:!0});var mr=N(),WS=B(),zj=Xs(),jj={message:\"must be equal to constant\",params:({schemaCode:e})=>mr._`{allowedValue: ${e}}`},Nj={keyword:\"const\",$data:!0,error:jj,code(e){let{gen:t,data:n,$data:r,schemaCode:o,schema:s}=e;if(r||s&&typeof s==\"object\")e.fail$data(mr._`!${WS.useFunc(t,zj.default)}(${n}, ${o})`);else e.fail(mr._`${s} !== ${n}`)}};KS.default=Nj});var XS=g(function(YS){Object.defineProperty(YS,\"__esModule\",{value:!0});var dt=N(),ZS=B(),Uj=Xs(),Lj={message:\"must be equal to one of the allowed values\",params:({schemaCode:e})=>dt._`{allowedValues: ${e}}`},Gj={keyword:\"enum\",schemaType:\"array\",$data:!0,error:Lj,code(e){let{gen:t,data:n,$data:r,schema:o,schemaCode:s,it:i}=e;if(!r&&o.length===0)throw Error(\"enum must have non-empty array\");let a=o.length>=i.opts.loopEnum,c,l=()=>c!==null&&c!==void 0?c:c=ZS.useFunc(t,Uj.default),u;if(a||r)u=t.let(\"valid\"),e.block$data(u,p);else{if(!Array.isArray(o))throw Error(\"ajv implementation error\");let d=t.const(\"vSchema\",s);u=dt.or(...o.map((f,h)=>m(d,h)))}e.pass(u);function p(){t.assign(u,!1),t.forOf(\"v\",s,(d)=>t.if(dt._`${l()}(${n}, ${d})`,()=>t.assign(u,!0).break()))}function m(d,f){let h=o[f];return typeof h===\"object\"&&h!==null?dt._`${l()}(${n}, ${d}[${f}])`:dt._`${n} === ${h}`}}};YS.default=Gj});var Dl=g(function(QS){Object.defineProperty(QS,\"__esModule\",{value:!0});var Vj=xS(),Fj=IS(),Jj=ES(),Wj=MS(),Kj=zS(),Hj=DS(),Zj=LS(),Yj=JS(),Xj=HS(),Qj=XS(),eN=[Vj.default,Fj.default,Jj.default,Wj.default,Kj.default,Hj.default,Zj.default,Yj.default,{keyword:\"type\",schemaType:[\"string\",\"array\"]},{keyword:\"nullable\",schemaType:\"boolean\"},Xj.default,Qj.default];QS.default=eN});var Ul=g(function(tI){Object.defineProperty(tI,\"__esModule\",{value:!0});tI.validateAdditionalItems=void 0;var Pe=N(),fr=B(),nN={message:({params:{len:e}})=>Pe.str`must NOT have more than ${e} items`,params:({params:{len:e}})=>Pe._`{limit: ${e}}`},rN={keyword:\"additionalItems\",type:\"array\",schemaType:[\"boolean\",\"object\"],before:\"uniqueItems\",error:nN,code(e){let{parentSchema:t,it:n}=e,{items:r}=t;if(!Array.isArray(r)){fr.checkStrictMode(n,'\"additionalItems\" is ignored when \"items\" is not an array of schemas');return}eI(e,r)}};function eI(e,t){let{gen:n,schema:r,data:o,keyword:s,it:i}=e;i.items=!0;let a=n.const(\"len\",Pe._`${o}.length`);if(r===!1)e.setParams({len:t.length}),e.pass(Pe._`${a} <= ${t.length}`);else if(typeof r==\"object\"&&!fr.alwaysValidSchema(i,r)){let l=n.var(\"valid\",Pe._`${a} <= ${t.length}`);n.if(Pe.not(l),()=>c(l)),e.ok(l)}function c(l){n.forRange(\"i\",t.length,a,(u)=>{if(e.subschema({keyword:s,dataProp:u,dataPropType:fr.Type.Num},l),!i.allErrors)n.if(Pe.not(l),()=>n.break())})}}tI.validateAdditionalItems=eI;tI.default=rN});var Ll=g(function(sI){Object.defineProperty(sI,\"__esModule\",{value:!0});sI.validateTuple=void 0;var Qs=N(),Kt=B(),rI=Be(),sN={keyword:\"items\",type:\"array\",schemaType:[\"object\",\"array\",\"boolean\"],before:\"uniqueItems\",code(e){let{schema:t,it:n}=e;if(Array.isArray(t))return oI(e,\"additionalItems\",t);if(n.items=!0,Kt.alwaysValidSchema(n,t))return;e.ok(rI.validateArray(e))}};function oI(e,t,n=e.schema){let{gen:r,parentSchema:o,data:s,keyword:i,it:a}=e;if(u(o),a.opts.unevaluated&&n.length&&a.items!==!0)a.items=Kt.mergeEvaluated.items(r,n.length,a.items);let c=r.name(\"valid\"),l=r.const(\"len\",Qs._`${s}.length`);n.forEach((p,m)=>{if(Kt.alwaysValidSchema(a,p))return;r.if(Qs._`${l} > ${m}`,()=>e.subschema({keyword:i,schemaProp:m,dataProp:m},c)),e.ok(c)});function u(p){let{opts:m,errSchemaPath:d}=a,f=n.length,h=f===p.minItems&&(f===p.maxItems||p[t]===!1);if(m.strictTuples&&!h){let y=`\"${i}\" is ${f}-tuple, but minItems or maxItems/${t} are not specified or different at path \"${d}\"`;Kt.checkStrictMode(a,y,m.strictTuples)}}}sI.validateTuple=oI;sI.default=sN});var lI=g(function(cI){Object.defineProperty(cI,\"__esModule\",{value:!0});var aI=Ll(),aN={keyword:\"prefixItems\",type:\"array\",schemaType:[\"array\"],before:\"uniqueItems\",code:(e)=>aI.validateTuple(e,\"items\")};cI.default=aN});var fI=g(function(mI){Object.defineProperty(mI,\"__esModule\",{value:!0});var ei=N(),uI=B(),dI=Be(),pI=Ul(),lN={message:({params:{len:e}})=>ei.str`must NOT have more than ${e} items`,params:({params:{len:e}})=>ei._`{limit: ${e}}`},uN={keyword:\"items\",type:\"array\",schemaType:[\"object\",\"boolean\"],before:\"uniqueItems\",error:lN,code(e){let{schema:t,parentSchema:n,it:r}=e,{prefixItems:o}=n;if(r.items=!0,uI.alwaysValidSchema(r,t))return;if(o)pI.validateAdditionalItems(e,o);else e.ok(dI.validateArray(e))}};mI.default=uN});var hI=g(function(gI){Object.defineProperty(gI,\"__esModule\",{value:!0});var ae=N(),Ht=B(),pN={message:({params:{min:e,max:t}})=>t===void 0?ae.str`must contain at least ${e} valid item(s)`:ae.str`must contain at least ${e} and no more than ${t} valid item(s)`,params:({params:{min:e,max:t}})=>t===void 0?ae._`{minContains: ${e}}`:ae._`{minContains: ${e}, maxContains: ${t}}`},mN={keyword:\"contains\",type:\"array\",schemaType:[\"object\",\"boolean\"],before:\"uniqueItems\",trackErrors:!0,error:pN,code(e){let{gen:t,schema:n,parentSchema:r,data:o,it:s}=e,i,a,{minContains:c,maxContains:l}=r;if(s.opts.next)i=c===void 0?1:c,a=l;else i=1;let u=t.const(\"len\",ae._`${o}.length`);if(e.setParams({min:i,max:a}),a===void 0&&i===0){Ht.checkStrictMode(s,'\"minContains\" == 0 without \"maxContains\": \"contains\" keyword ignored');return}if(a!==void 0&&i>a){Ht.checkStrictMode(s,'\"minContains\" > \"maxContains\" is always invalid'),e.fail();return}if(Ht.alwaysValidSchema(s,n)){let h=ae._`${u} >= ${i}`;if(a!==void 0)h=ae._`${h} && ${u} <= ${a}`;e.pass(h);return}s.items=!0;let p=t.name(\"valid\");if(a===void 0&&i===1)d(p,()=>t.if(p,()=>t.break()));else if(i===0){if(t.let(p,!0),a!==void 0)t.if(ae._`${o}.length > 0`,m)}else t.let(p,!1),m();e.result(p,()=>e.reset());function m(){let h=t.name(\"_valid\"),y=t.let(\"count\",0);d(h,()=>t.if(h,()=>f(y)))}function d(h,y){t.forRange(\"i\",0,u,(_)=>{e.subschema({keyword:\"contains\",dataProp:_,dataPropType:Ht.Type.Num,compositeRule:!0},h),y()})}function f(h){if(t.code(ae._`${h}++`),a===void 0)t.if(ae._`${h} >= ${i}`,()=>t.assign(p,!0).break());else if(t.if(ae._`${h} > ${a}`,()=>t.assign(p,!1).break()),i===1)t.assign(p,!0);else t.if(ae._`${h} >= ${i}`,()=>t.assign(p,!0))}}};gI.default=mN});var ti=g(function(_I){Object.defineProperty(_I,\"__esModule\",{value:!0});_I.validateSchemaDeps=_I.validatePropertyDeps=_I.error=void 0;var gr=N(),yI=B(),pt=Be();_I.error={message:({params:{property:e,depsCount:t,deps:n}})=>gr.str`must have ${t===1?\"property\":\"properties\"} ${n} when property ${e} is present`,params:({params:{property:e,depsCount:t,deps:n,missingProperty:r}})=>gr._`{property: ${e},\n missingProperty: ${r},\n depsCount: ${t},\n deps: ${n}}`};var gN={keyword:\"dependencies\",type:\"object\",schemaType:\"object\",error:_I.error,code(e){let[t,n]=hN(e);bI(e,t),vI(e,n)}};function hN({schema:e}){let t={},n={};for(let r in e){if(r===\"__proto__\")continue;let o=Array.isArray(e[r])?t:n;o[r]=e[r]}return[t,n]}function bI(e,t=e.schema){let{gen:n,data:r,it:o}=e;if(Object.keys(t).length===0)return;let s=n.let(\"missing\");for(let i in t){let a=t[i];if(a.length===0)continue;let c=pt.propertyInData(n,r,i,o.opts.ownProperties);if(e.setParams({property:i,depsCount:a.length,deps:a.join(\", \")}),o.allErrors)n.if(c,()=>{for(let l of a)pt.checkReportMissingProp(e,l)});else n.if(gr._`${c} && (${pt.checkMissingProp(e,a,s)})`),pt.reportMissingProp(e,s),n.else()}}_I.validatePropertyDeps=bI;function vI(e,t=e.schema){let{gen:n,data:r,keyword:o,it:s}=e,i=n.name(\"valid\");for(let a in t){if(yI.alwaysValidSchema(s,t[a]))continue;n.if(pt.propertyInData(n,r,a,s.opts.ownProperties),()=>{let c=e.subschema({keyword:o,schemaProp:a},i);e.mergeValidEvaluated(c,i)},()=>n.var(i,!0)),e.ok(i)}}_I.validateSchemaDeps=vI;_I.default=gN});var kI=g(function(II){Object.defineProperty(II,\"__esModule\",{value:!0});var ni=N(),SI=B(),vN={message:\"property name must be valid\",params:({params:e})=>ni._`{propertyName: ${e.propertyName}}`},_N={keyword:\"propertyNames\",type:\"object\",schemaType:[\"object\",\"boolean\"],error:vN,code(e){let{gen:t,schema:n,data:r,it:o}=e;if(SI.alwaysValidSchema(o,n))return;let s=t.name(\"valid\");t.forIn(\"key\",r,(i)=>{e.setParams({propertyName:i}),e.subschema({keyword:\"propertyNames\",data:i,dataTypes:[\"string\"],propertyName:i,compositeRule:!0},s),t.if(ni.not(s),()=>{if(e.error(!0),!o.allErrors)t.break()})}),e.ok(s)}};II.default=_N});var Gl=g(function(RI){Object.defineProperty(RI,\"__esModule\",{value:!0});var Zt=Be(),me=N(),xN=Le(),Yt=B(),SN={message:\"must NOT have additional properties\",params:({params:e})=>me._`{additionalProperty: ${e.additionalProperty}}`},IN={keyword:\"additionalProperties\",type:[\"object\"],schemaType:[\"boolean\",\"object\"],allowUndefined:!0,trackErrors:!0,error:SN,code(e){let{gen:t,schema:n,parentSchema:r,data:o,errsCount:s,it:i}=e;if(!s)throw Error(\"ajv implementation error\");let{allErrors:a,opts:c}=i;if(i.props=!0,c.removeAdditional!==\"all\"&&Yt.alwaysValidSchema(i,n))return;let l=Zt.allSchemaProperties(r.properties),u=Zt.allSchemaProperties(r.patternProperties);p(),e.ok(me._`${s} === ${xN.default.errors}`);function p(){t.forIn(\"key\",o,(y)=>{if(!l.length&&!u.length)f(y);else t.if(m(y),()=>f(y))})}function m(y){let _;if(l.length>8){let E=Yt.schemaRefOrVal(i,r.properties,\"properties\");_=Zt.isOwnProperty(t,E,y)}else if(l.length)_=me.or(...l.map((E)=>me._`${y} === ${E}`));else _=me.nil;if(u.length)_=me.or(_,...u.map((E)=>me._`${Zt.usePattern(e,E)}.test(${y})`));return me.not(_)}function d(y){t.code(me._`delete ${o}[${y}]`)}function f(y){if(c.removeAdditional===\"all\"||c.removeAdditional&&n===!1){d(y);return}if(n===!1){if(e.setParams({additionalProperty:y}),e.error(),!a)t.break();return}if(typeof n==\"object\"&&!Yt.alwaysValidSchema(i,n)){let _=t.name(\"valid\");if(c.removeAdditional===\"failing\")h(y,_,!1),t.if(me.not(_),()=>{e.reset(),d(y)});else if(h(y,_),!a)t.if(me.not(_),()=>t.break())}}function h(y,_,E){let T={keyword:\"additionalProperties\",dataProp:y,dataPropType:Yt.Type.Str};if(E===!1)Object.assign(T,{compositeRule:!0,createErrors:!1,allErrors:!1});e.subschema(T,_)}}};RI.default=IN});var EI=g(function(CI){Object.defineProperty(CI,\"__esModule\",{value:!0});var AI=In(),ri=Be(),hr=B(),TI=Gl(),RN={keyword:\"properties\",type:\"object\",schemaType:\"object\",code(e){let{gen:t,schema:n,parentSchema:r,data:o,it:s}=e;if(s.opts.removeAdditional===\"all\"&&r.additionalProperties===void 0)TI.default.code(new AI.KeywordCxt(s,TI.default,\"additionalProperties\"));let i=ri.allSchemaProperties(n);for(let p of i)s.definedProperties.add(p);if(s.opts.unevaluated&&i.length&&s.props!==!0)s.props=hr.mergeEvaluated.props(t,hr.toHash(i),s.props);let a=i.filter((p)=>!hr.alwaysValidSchema(s,n[p]));if(a.length===0)return;let c=t.name(\"valid\");for(let p of a){if(l(p))u(p);else{if(t.if(ri.propertyInData(t,o,p,s.opts.ownProperties)),u(p),!s.allErrors)t.else().var(c,!0);t.endIf()}e.it.definedProperties.add(p),e.ok(c)}function l(p){return s.opts.useDefaults&&!s.compositeRule&&n[p].default!==void 0}function u(p){e.subschema({keyword:\"properties\",schemaProp:p,dataProp:p},c)}}};CI.default=RN});var OI=g(function(PI){Object.defineProperty(PI,\"__esModule\",{value:!0});var oi=Be(),Xt=N(),si=B(),ii=B(),AN={keyword:\"patternProperties\",type:\"object\",schemaType:\"object\",code(e){let{gen:t,schema:n,data:r,parentSchema:o,it:s}=e,{opts:i}=s,a=oi.allSchemaProperties(n),c=a.filter((h)=>si.alwaysValidSchema(s,n[h]));if(a.length===0||c.length===a.length&&(!s.opts.unevaluated||s.props===!0))return;let l=i.strictSchema&&!i.allowMatchingProperties&&o.properties,u=t.name(\"valid\");if(s.props!==!0&&!(s.props instanceof Xt.Name))s.props=ii.evaluatedPropsToName(t,s.props);let{props:p}=s;m();function m(){for(let h of a){if(l)d(h);if(s.allErrors)f(h);else t.var(u,!0),f(h),t.if(u)}}function d(h){for(let y in l)if(new RegExp(h).test(y))si.checkStrictMode(s,`property ${y} matches pattern ${h} (use allowMatchingProperties)`)}function f(h){t.forIn(\"key\",r,(y)=>{t.if(Xt._`${oi.usePattern(e,h)}.test(${y})`,()=>{let _=c.includes(h);if(!_)e.subschema({keyword:\"patternProperties\",schemaProp:h,dataProp:y,dataPropType:ii.Type.Str},u);if(s.opts.unevaluated&&p!==!0)t.assign(Xt._`${p}[${y}]`,!0);else if(!_&&!s.allErrors)t.if(Xt.not(u),()=>t.break())})})}}};PI.default=AN});var qI=g(function(MI){Object.defineProperty(MI,\"__esModule\",{value:!0});var $I=B(),EN={keyword:\"not\",schemaType:[\"object\",\"boolean\"],trackErrors:!0,code(e){let{gen:t,schema:n,it:r}=e;if($I.alwaysValidSchema(r,n)){e.fail();return}let o=t.name(\"valid\");e.subschema({keyword:\"not\",compositeRule:!0,createErrors:!1,allErrors:!1},o),e.failResult(o,()=>e.reset(),()=>e.error())},error:{message:\"must NOT be valid\"}};MI.default=EN});var NI=g(function(jI){Object.defineProperty(jI,\"__esModule\",{value:!0});var zI=Be(),ON={keyword:\"anyOf\",schemaType:\"array\",trackErrors:!0,code:zI.validateUnion,error:{message:\"must match a schema in anyOf\"}};jI.default=ON});var LI=g(function(UI){Object.defineProperty(UI,\"__esModule\",{value:!0});var Qt=N(),DI=B(),MN={message:\"must match exactly one schema in oneOf\",params:({params:e})=>Qt._`{passingSchemas: ${e.passing}}`},qN={keyword:\"oneOf\",schemaType:\"array\",trackErrors:!0,error:MN,code(e){let{gen:t,schema:n,parentSchema:r,it:o}=e;if(!Array.isArray(n))throw Error(\"ajv implementation error\");if(o.opts.discriminator&&r.discriminator)return;let s=n,i=t.let(\"valid\",!1),a=t.let(\"passing\",null),c=t.name(\"_valid\");e.setParams({passing:a}),t.block(l),e.result(i,()=>e.reset(),()=>e.error(!0));function l(){s.forEach((u,p)=>{let m;if(DI.alwaysValidSchema(o,u))t.var(c,!0);else m=e.subschema({keyword:\"oneOf\",schemaProp:p,compositeRule:!0},c);if(p>0)t.if(Qt._`${c} && ${i}`).assign(i,!1).assign(a,Qt._`[${a}, ${p}]`).else();t.if(c,()=>{if(t.assign(i,!0),t.assign(a,p),m)e.mergeEvaluated(m,Qt.Name)})})}}};UI.default=qN});var VI=g(function(BI){Object.defineProperty(BI,\"__esModule\",{value:!0});var GI=B(),jN={keyword:\"allOf\",schemaType:\"array\",code(e){let{gen:t,schema:n,it:r}=e;if(!Array.isArray(n))throw Error(\"ajv implementation error\");let o=t.name(\"valid\");n.forEach((s,i)=>{if(GI.alwaysValidSchema(r,s))return;let a=e.subschema({keyword:\"allOf\",schemaProp:i},o);e.ok(o),e.mergeEvaluated(a)})}};BI.default=jN});var WI=g(function(JI){Object.defineProperty(JI,\"__esModule\",{value:!0});var en=N(),ai=B(),DN={message:({params:e})=>en.str`must match \"${e.ifClause}\" schema`,params:({params:e})=>en._`{failingKeyword: ${e.ifClause}}`},UN={keyword:\"if\",schemaType:[\"object\",\"boolean\"],trackErrors:!0,error:DN,code(e){let{gen:t,parentSchema:n,it:r}=e;if(n.then===void 0&&n.else===void 0)ai.checkStrictMode(r,'\"if\" without \"then\" and \"else\" is ignored');let o=FI(r,\"then\"),s=FI(r,\"else\");if(!o&&!s)return;let i=t.let(\"valid\",!0),a=t.name(\"_valid\");if(c(),e.reset(),o&&s){let u=t.let(\"ifClause\");e.setParams({ifClause:u}),t.if(a,l(\"then\",u),l(\"else\",u))}else if(o)t.if(a,l(\"then\"));else t.if(en.not(a),l(\"else\"));e.pass(i,()=>e.error(!0));function c(){let u=e.subschema({keyword:\"if\",compositeRule:!0,createErrors:!1,allErrors:!1},a);e.mergeEvaluated(u)}function l(u,p){return()=>{let m=e.subschema({keyword:u},a);if(t.assign(i,a),e.mergeValidEvaluated(m,i),p)t.assign(p,en._`${u}`);else e.setParams({ifClause:u})}}}};function FI(e,t){let n=e.schema[t];return n!==void 0&&!ai.alwaysValidSchema(e,n)}JI.default=UN});var ZI=g(function(HI){Object.defineProperty(HI,\"__esModule\",{value:!0});var KI=B(),GN={keyword:[\"then\",\"else\"],schemaType:[\"object\",\"boolean\"],code({keyword:e,parentSchema:t,it:n}){if(t.if===void 0)KI.checkStrictMode(n,`\"${e}\" without \"if\" is ignored`)}};HI.default=GN});var Bl=g(function(YI){Object.defineProperty(YI,\"__esModule\",{value:!0});var VN=Ul(),FN=lI(),JN=Ll(),WN=fI(),KN=hI(),HN=ti(),ZN=kI(),YN=Gl(),XN=EI(),QN=OI(),eD=qI(),tD=NI(),nD=LI(),rD=VI(),oD=WI(),sD=ZI();function iD(e=!1){let t=[eD.default,tD.default,nD.default,rD.default,oD.default,sD.default,ZN.default,YN.default,HN.default,XN.default,QN.default];if(e)t.push(FN.default,WN.default);else t.push(VN.default,JN.default);return t.push(KN.default),t}YI.default=iD});var QI=g(function(XI){Object.defineProperty(XI,\"__esModule\",{value:!0});var U=N(),cD={message:({schemaCode:e})=>U.str`must match format \"${e}\"`,params:({schemaCode:e})=>U._`{format: ${e}}`},lD={keyword:\"format\",type:[\"number\",\"string\"],schemaType:\"string\",$data:!0,error:cD,code(e,t){let{gen:n,data:r,$data:o,schema:s,schemaCode:i,it:a}=e,{opts:c,errSchemaPath:l,schemaEnv:u,self:p}=a;if(!c.validateFormats)return;if(o)m();else d();function m(){let f=n.scopeValue(\"formats\",{ref:p.formats,code:c.code.formats}),h=n.const(\"fDef\",U._`${f}[${i}]`),y=n.let(\"fType\"),_=n.let(\"format\");n.if(U._`typeof ${h} == \"object\" && !(${h} instanceof RegExp)`,()=>n.assign(y,U._`${h}.type || \"string\"`).assign(_,U._`${h}.validate`),()=>n.assign(y,U._`\"string\"`).assign(_,h)),e.fail$data(U.or(E(),T()));function E(){if(c.strictSchema===!1)return U.nil;return U._`${i} && !${_}`}function T(){let A=u.$async?U._`(${h}.async ? await ${_}(${r}) : ${_}(${r}))`:U._`${_}(${r})`,x=U._`(typeof ${_} == \"function\" ? ${A} : ${_}.test(${r}))`;return U._`${_} && ${_} !== true && ${y} === ${t} && !${x}`}}function d(){let f=p.formats[s];if(!f){E();return}if(f===!0)return;let[h,y,_]=T(f);if(h===t)e.pass(A());function E(){if(c.strictSchema===!1){p.logger.warn(x());return}throw Error(x());function x(){return`unknown format \"${s}\" ignored in schema at path \"${l}\"`}}function T(x){let K=x instanceof RegExp?U.regexpCode(x):c.code.formats?U._`${c.code.formats}${U.getProperty(s)}`:void 0,C=n.scopeValue(\"formats\",{key:s,ref:x,code:K});if(typeof x==\"object\"&&!(x instanceof RegExp))return[x.type||\"string\",x.validate,U._`${C}.validate`];return[\"string\",x,C]}function A(){if(typeof f==\"object\"&&!(f instanceof RegExp)&&f.async){if(!u.$async)throw Error(\"async format in sync schema\");return U._`await ${_}(${r})`}return typeof y==\"function\"?U._`${_}(${r})`:U._`${_}.test(${r})`}}}};XI.default=lD});var Vl=g(function(ek){Object.defineProperty(ek,\"__esModule\",{value:!0});var dD=QI(),pD=[dD.default];ek.default=pD});var Fl=g(function(tk){Object.defineProperty(tk,\"__esModule\",{value:!0});tk.contentVocabulary=tk.metadataVocabulary=void 0;tk.metadataVocabulary=[\"title\",\"description\",\"default\",\"deprecated\",\"readOnly\",\"writeOnly\",\"examples\"];tk.contentVocabulary=[\"contentMediaType\",\"contentEncoding\",\"contentSchema\"]});var Jl=g(function(rk){Object.defineProperty(rk,\"__esModule\",{value:!0});var gD=Nl(),hD=Dl(),yD=Bl(),bD=Vl(),ci=Fl(),vD=[gD.default,hD.default,(0,yD.default)(),bD.default,ci.metadataVocabulary,ci.contentVocabulary];rk.default=vD});var ak=g(function(sk){Object.defineProperty(sk,\"__esModule\",{value:!0});sk.DiscrError=void 0;var ok;(function(e){e.Tag=\"tag\",e.Mapping=\"mapping\"})(ok||(sk.DiscrError=ok={}))});var ui=g(function(lk){Object.defineProperty(lk,\"__esModule\",{value:!0});var Fe=N(),yr=ak(),li=oo(),wD=kn(),ck=B(),xD={message:({params:{discrError:e,tagName:t}})=>e===yr.DiscrError.Tag?`tag \"${t}\" must be string`:`value of tag \"${t}\" must be in oneOf`,params:({params:{discrError:e,tag:t,tagName:n}})=>Fe._`{error: ${e}, tag: ${n}, tagValue: ${t}}`},SD={keyword:\"discriminator\",type:\"object\",schemaType:\"object\",error:xD,code(e){let{gen:t,data:n,schema:r,parentSchema:o,it:s}=e,{oneOf:i}=o;if(!s.opts.discriminator)throw Error(\"discriminator: requires discriminator option\");let a=r.propertyName;if(typeof a!=\"string\")throw Error(\"discriminator: requires propertyName\");if(r.mapping)throw Error(\"discriminator: mapping is not supported\");if(!i)throw Error(\"discriminator: requires oneOf keyword\");let c=t.let(\"valid\",!1),l=t.const(\"tag\",Fe._`${n}${Fe.getProperty(a)}`);t.if(Fe._`typeof ${l} == \"string\"`,()=>u(),()=>e.error(!1,{discrError:yr.DiscrError.Tag,tag:l,tagName:a})),e.ok(c);function u(){let d=m();t.if(!1);for(let f in d)t.elseIf(Fe._`${l} === ${f}`),t.assign(c,p(d[f]));t.else(),e.error(!1,{discrError:yr.DiscrError.Mapping,tag:l,tagName:a}),t.endIf()}function p(d){let f=t.name(\"valid\"),h=e.subschema({keyword:\"oneOf\",schemaProp:d},f);return e.mergeEvaluated(h,Fe.Name),f}function m(){var d;let f={},h=_(o),y=!0;for(let A=0;A<i.length;A++){let x=i[A];if((x===null||x===void 0?void 0:x.$ref)&&!ck.schemaHasRulesButRef(x,s.self.RULES)){let C=x.$ref;if(x=li.resolveRef.call(s.self,s.schemaEnv.root,s.baseId,C),x instanceof li.SchemaEnv)x=x.schema;if(x===void 0)throw new wD.default(s.opts.uriResolver,s.baseId,C)}let K=(d=x===null||x===void 0?void 0:x.properties)===null||d===void 0?void 0:d[a];if(typeof K!=\"object\")throw Error(`discriminator: oneOf subschemas (or referenced schemas) must have \"properties/${a}\"`);y=y&&(h||_(x)),E(K,A)}if(!y)throw Error(`discriminator: \"${a}\" must be required`);return f;function _({required:A}){return Array.isArray(A)&&A.includes(a)}function E(A,x){if(A.const)T(A.const,x);else if(A.enum)for(let K of A.enum)T(K,x);else throw Error(`discriminator: \"properties/${a}\" must have \"const\" or \"enum\"`)}function T(A,x){if(typeof A!=\"string\"||A in f)throw Error(`discriminator: \"${a}\" values must be unique strings`);f[A]=x}}}};lk.default=SD});var uk=g(function(u6,kD){kD.exports={$schema:\"http://json-schema.org/draft-07/schema#\",$id:\"http://json-schema.org/draft-07/schema#\",title:\"Core schema meta-schema\",definitions:{schemaArray:{type:\"array\",minItems:1,items:{$ref:\"#\"}},nonNegativeInteger:{type:\"integer\",minimum:0},nonNegativeIntegerDefault0:{allOf:[{$ref:\"#/definitions/nonNegativeInteger\"},{default:0}]},simpleTypes:{enum:[\"array\",\"boolean\",\"integer\",\"null\",\"number\",\"object\",\"string\"]},stringArray:{type:\"array\",items:{type:\"string\"},uniqueItems:!0,default:[]}},type:[\"object\",\"boolean\"],properties:{$id:{type:\"string\",format:\"uri-reference\"},$schema:{type:\"string\",format:\"uri\"},$ref:{type:\"string\",format:\"uri-reference\"},$comment:{type:\"string\"},title:{type:\"string\"},description:{type:\"string\"},default:!0,readOnly:{type:\"boolean\",default:!1},examples:{type:\"array\",items:!0},multipleOf:{type:\"number\",exclusiveMinimum:0},maximum:{type:\"number\"},exclusiveMaximum:{type:\"number\"},minimum:{type:\"number\"},exclusiveMinimum:{type:\"number\"},maxLength:{$ref:\"#/definitions/nonNegativeInteger\"},minLength:{$ref:\"#/definitions/nonNegativeIntegerDefault0\"},pattern:{type:\"string\",format:\"regex\"},additionalItems:{$ref:\"#\"},items:{anyOf:[{$ref:\"#\"},{$ref:\"#/definitions/schemaArray\"}],default:!0},maxItems:{$ref:\"#/definitions/nonNegativeInteger\"},minItems:{$ref:\"#/definitions/nonNegativeIntegerDefault0\"},uniqueItems:{type:\"boolean\",default:!1},contains:{$ref:\"#\"},maxProperties:{$ref:\"#/definitions/nonNegativeInteger\"},minProperties:{$ref:\"#/definitions/nonNegativeIntegerDefault0\"},required:{$ref:\"#/definitions/stringArray\"},additionalProperties:{$ref:\"#\"},definitions:{type:\"object\",additionalProperties:{$ref:\"#\"},default:{}},properties:{type:\"object\",additionalProperties:{$ref:\"#\"},default:{}},patternProperties:{type:\"object\",additionalProperties:{$ref:\"#\"},propertyNames:{format:\"regex\"},default:{}},dependencies:{type:\"object\",additionalProperties:{anyOf:[{$ref:\"#\"},{$ref:\"#/definitions/stringArray\"}]}},propertyNames:{$ref:\"#\"},const:!0,enum:{type:\"array\",items:!0,minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:\"#/definitions/simpleTypes\"},{type:\"array\",items:{$ref:\"#/definitions/simpleTypes\"},minItems:1,uniqueItems:!0}]},format:{type:\"string\"},contentMediaType:{type:\"string\"},contentEncoding:{type:\"string\"},if:{$ref:\"#\"},then:{$ref:\"#\"},else:{$ref:\"#\"},allOf:{$ref:\"#/definitions/schemaArray\"},anyOf:{$ref:\"#/definitions/schemaArray\"},oneOf:{$ref:\"#/definitions/schemaArray\"},not:{$ref:\"#\"}},default:!0}});var pk=g(function(Oe,Wl){Object.defineProperty(Oe,\"__esModule\",{value:!0});Oe.MissingRefError=Oe.ValidationError=Oe.CodeGen=Oe.Name=Oe.nil=Oe.stringify=Oe.str=Oe._=Oe.KeywordCxt=Oe.Ajv=void 0;var RD=Js(),TD=Jl(),AD=ui(),dk=uk(),CD=[\"/properties\"],di=\"http://json-schema.org/draft-07/schema\";class io extends RD.default{_addVocabularies(){if(super._addVocabularies(),TD.default.forEach((e)=>this.addVocabulary(e)),this.opts.discriminator)this.addKeyword(AD.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let e=this.opts.$data?this.$dataMetaSchema(dk,CD):dk;this.addMetaSchema(e,di,!1),this.refs[\"http://json-schema.org/schema\"]=di}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(di)?di:void 0)}}Oe.Ajv=io;Wl.exports=Oe=io;Wl.exports.Ajv=io;Object.defineProperty(Oe,\"__esModule\",{value:!0});Oe.default=io;var ED=In();Object.defineProperty(Oe,\"KeywordCxt\",{enumerable:!0,get:function(){return ED.KeywordCxt}});var br=N();Object.defineProperty(Oe,\"_\",{enumerable:!0,get:function(){return br._}});Object.defineProperty(Oe,\"str\",{enumerable:!0,get:function(){return br.str}});Object.defineProperty(Oe,\"stringify\",{enumerable:!0,get:function(){return br.stringify}});Object.defineProperty(Oe,\"nil\",{enumerable:!0,get:function(){return br.nil}});Object.defineProperty(Oe,\"Name\",{enumerable:!0,get:function(){return br.Name}});Object.defineProperty(Oe,\"CodeGen\",{enumerable:!0,get:function(){return br.CodeGen}});var PD=ar();Object.defineProperty(Oe,\"ValidationError\",{enumerable:!0,get:function(){return PD.default}});var OD=kn();Object.defineProperty(Oe,\"MissingRefError\",{enumerable:!0,get:function(){return OD.default}})});var Kl=g(function(gk){Object.defineProperty(gk,\"__esModule\",{value:!0});gk.dynamicAnchor=void 0;var vr=N(),qD=Le(),pi=oo(),mk=Zs(),zD={keyword:\"$dynamicAnchor\",schemaType:\"string\",code:(e)=>fk(e,e.schema)};function fk(e,t){let{gen:n,it:r}=e;r.schemaEnv.root.dynamicAnchors[t]=!0;let o=vr._`${qD.default.dynamicAnchors}${vr.getProperty(t)}`,s=r.errSchemaPath===\"#\"?r.validateName:jD(e);n.if(vr._`!${o}`,()=>n.assign(o,s))}gk.dynamicAnchor=fk;function jD(e){let{schemaEnv:t,schema:n,self:r}=e.it,{root:o,baseId:s,localRefs:i,meta:a}=t.root,{schemaId:c}=r.opts,l=new pi.SchemaEnv({schema:n,schemaId:c,root:o,baseId:s,localRefs:i,meta:a});return pi.compileSchema.call(r,l),mk.getValidate(e,l)}gk.default=zD});var Hl=g(function(bk){Object.defineProperty(bk,\"__esModule\",{value:!0});bk.dynamicRef=void 0;var mi=N(),DD=Le(),fi=Zs(),UD={keyword:\"$dynamicRef\",schemaType:\"string\",code:(e)=>yk(e,e.schema)};function yk(e,t){let{gen:n,keyword:r,it:o}=e;if(t[0]!==\"#\")throw Error(`\"${r}\" only supports hash fragment reference`);let s=t.slice(1);if(o.allErrors)i();else{let c=n.let(\"valid\",!1);i(c),e.ok(c)}function i(c){if(o.schemaEnv.root.dynamicAnchors[s]){let l=n.let(\"_v\",mi._`${DD.default.dynamicAnchors}${mi.getProperty(s)}`);n.if(l,a(l,c),a(o.validateName,c))}else a(o.validateName,c)()}function a(c,l){return l?()=>n.block(()=>{fi.callRef(e,c),n.let(l,!0)}):()=>fi.callRef(e,c)}}bk.dynamicRef=yk;bk.default=UD});var Sk=g(function(xk){Object.defineProperty(xk,\"__esModule\",{value:!0});var _k=Kl(),wk=B(),GD={keyword:\"$recursiveAnchor\",schemaType:\"boolean\",code(e){if(e.schema)_k.dynamicAnchor(e,\"\");else wk.checkStrictMode(e.it,\"$recursiveAnchor: false is ignored\")}};xk.default=GD});var Rk=g(function(kk){Object.defineProperty(kk,\"__esModule\",{value:!0});var Ik=Hl(),VD={keyword:\"$recursiveRef\",schemaType:\"string\",code:(e)=>Ik.dynamicRef(e,e.schema)};kk.default=VD});var Zl=g(function(Tk){Object.defineProperty(Tk,\"__esModule\",{value:!0});var JD=Kl(),WD=Hl(),KD=Sk(),HD=Rk(),ZD=[JD.default,WD.default,KD.default,HD.default];Tk.default=ZD});var Ck=g(function(Ak){Object.defineProperty(Ak,\"__esModule\",{value:!0});var gi=ti(),XD={keyword:\"dependentRequired\",type:\"object\",schemaType:\"object\",error:gi.error,code:(e)=>gi.validatePropertyDeps(e)};Ak.default=XD});var Ok=g(function(Pk){Object.defineProperty(Pk,\"__esModule\",{value:!0});var Ek=ti(),eU={keyword:\"dependentSchemas\",type:\"object\",schemaType:\"object\",code:(e)=>Ek.validateSchemaDeps(e)};Pk.default=eU});var qk=g(function(Mk){Object.defineProperty(Mk,\"__esModule\",{value:!0});var $k=B(),nU={keyword:[\"maxContains\",\"minContains\"],type:\"array\",schemaType:\"number\",code({keyword:e,parentSchema:t,it:n}){if(t.contains===void 0)$k.checkStrictMode(n,`\"${e}\" without \"contains\" is ignored`)}};Mk.default=nU});var Yl=g(function(zk){Object.defineProperty(zk,\"__esModule\",{value:!0});var oU=Ck(),sU=Ok(),iU=qk(),aU=[oU.default,sU.default,iU.default];zk.default=aU});var Nk=g(function(jk){Object.defineProperty(jk,\"__esModule\",{value:!0});var Se=N(),hi=B(),lU=Le(),uU={message:\"must NOT have unevaluated properties\",params:({params:e})=>Se._`{unevaluatedProperty: ${e.unevaluatedProperty}}`},dU={keyword:\"unevaluatedProperties\",type:\"object\",schemaType:[\"boolean\",\"object\"],trackErrors:!0,error:uU,code(e){let{gen:t,schema:n,data:r,errsCount:o,it:s}=e;if(!o)throw Error(\"ajv implementation error\");let{allErrors:i,props:a}=s;if(a instanceof Se.Name)t.if(Se._`${a} !== true`,()=>t.forIn(\"key\",r,(p)=>t.if(l(a,p),()=>c(p))));else if(a!==!0)t.forIn(\"key\",r,(p)=>a===void 0?c(p):t.if(u(a,p),()=>c(p)));s.props=!0,e.ok(Se._`${o} === ${lU.default.errors}`);function c(p){if(n===!1){if(e.setParams({unevaluatedProperty:p}),e.error(),!i)t.break();return}if(!hi.alwaysValidSchema(s,n)){let m=t.name(\"valid\");if(e.subschema({keyword:\"unevaluatedProperties\",dataProp:p,dataPropType:hi.Type.Str},m),!i)t.if(Se.not(m),()=>t.break())}}function l(p,m){return Se._`!${p} || !${p}[${m}]`}function u(p,m){let d=[];for(let f in p)if(p[f]===!0)d.push(Se._`${m} !== ${f}`);return Se.and(...d)}}};jk.default=dU});var Uk=g(function(Dk){Object.defineProperty(Dk,\"__esModule\",{value:!0});var $e=N(),yi=B(),mU={message:({params:{len:e}})=>$e.str`must NOT have more than ${e} items`,params:({params:{len:e}})=>$e._`{limit: ${e}}`},fU={keyword:\"unevaluatedItems\",type:\"array\",schemaType:[\"boolean\",\"object\"],error:mU,code(e){let{gen:t,schema:n,data:r,it:o}=e,s=o.items||0;if(s===!0)return;let i=t.const(\"len\",$e._`${r}.length`);if(n===!1)e.setParams({len:s}),e.fail($e._`${i} > ${s}`);else if(typeof n==\"object\"&&!yi.alwaysValidSchema(o,n)){let c=t.var(\"valid\",$e._`${i} <= ${s}`);t.if($e.not(c),()=>a(c,s)),e.ok(c)}o.items=!0;function a(c,l){t.forRange(\"i\",l,i,(u)=>{if(e.subschema({keyword:\"unevaluatedItems\",dataProp:u,dataPropType:yi.Type.Num},c),!o.allErrors)t.if($e.not(c),()=>t.break())})}}};Dk.default=fU});var Xl=g(function(Lk){Object.defineProperty(Lk,\"__esModule\",{value:!0});var hU=Nk(),yU=Uk(),bU=[hU.default,yU.default];Lk.default=bU});var Gk=g(function(P6,_U){_U.exports={$schema:\"https://json-schema.org/draft/2019-09/schema\",$id:\"https://json-schema.org/draft/2019-09/schema\",$vocabulary:{\"https://json-schema.org/draft/2019-09/vocab/core\":!0,\"https://json-schema.org/draft/2019-09/vocab/applicator\":!0,\"https://json-schema.org/draft/2019-09/vocab/validation\":!0,\"https://json-schema.org/draft/2019-09/vocab/meta-data\":!0,\"https://json-schema.org/draft/2019-09/vocab/format\":!1,\"https://json-schema.org/draft/2019-09/vocab/content\":!0},$recursiveAnchor:!0,title:\"Core and Validation specifications meta-schema\",allOf:[{$ref:\"meta/core\"},{$ref:\"meta/applicator\"},{$ref:\"meta/validation\"},{$ref:\"meta/meta-data\"},{$ref:\"meta/format\"},{$ref:\"meta/content\"}],type:[\"object\",\"boolean\"],properties:{definitions:{$comment:\"While no longer an official keyword as it is replaced by $defs, this keyword is retained in the meta-schema to prevent incompatible extensions as it remains in common use.\",type:\"object\",additionalProperties:{$recursiveRef:\"#\"},default:{}},dependencies:{$comment:'\"dependencies\" is no longer a keyword, but schema authors should avoid redefining it to facilitate a smooth transition to \"dependentSchemas\" and \"dependentRequired\"',type:\"object\",additionalProperties:{anyOf:[{$recursiveRef:\"#\"},{$ref:\"meta/validation#/$defs/stringArray\"}]}}}}});var Bk=g(function(O6,wU){wU.exports={$schema:\"https://json-schema.org/draft/2019-09/schema\",$id:\"https://json-schema.org/draft/2019-09/meta/applicator\",$vocabulary:{\"https://json-schema.org/draft/2019-09/vocab/applicator\":!0},$recursiveAnchor:!0,title:\"Applicator vocabulary meta-schema\",type:[\"object\",\"boolean\"],properties:{additionalItems:{$recursiveRef:\"#\"},unevaluatedItems:{$recursiveRef:\"#\"},items:{anyOf:[{$recursiveRef:\"#\"},{$ref:\"#/$defs/schemaArray\"}]},contains:{$recursiveRef:\"#\"},additionalProperties:{$recursiveRef:\"#\"},unevaluatedProperties:{$recursiveRef:\"#\"},properties:{type:\"object\",additionalProperties:{$recursiveRef:\"#\"},default:{}},patternProperties:{type:\"object\",additionalProperties:{$recursiveRef:\"#\"},propertyNames:{format:\"regex\"},default:{}},dependentSchemas:{type:\"object\",additionalProperties:{$recursiveRef:\"#\"}},propertyNames:{$recursiveRef:\"#\"},if:{$recursiveRef:\"#\"},then:{$recursiveRef:\"#\"},else:{$recursiveRef:\"#\"},allOf:{$ref:\"#/$defs/schemaArray\"},anyOf:{$ref:\"#/$defs/schemaArray\"},oneOf:{$ref:\"#/$defs/schemaArray\"},not:{$recursiveRef:\"#\"}},$defs:{schemaArray:{type:\"array\",minItems:1,items:{$recursiveRef:\"#\"}}}}});var Vk=g(function($6,xU){xU.exports={$schema:\"https://json-schema.org/draft/2019-09/schema\",$id:\"https://json-schema.org/draft/2019-09/meta/content\",$vocabulary:{\"https://json-schema.org/draft/2019-09/vocab/content\":!0},$recursiveAnchor:!0,title:\"Content vocabulary meta-schema\",type:[\"object\",\"boolean\"],properties:{contentMediaType:{type:\"string\"},contentEncoding:{type:\"string\"},contentSchema:{$recursiveRef:\"#\"}}}});var Fk=g(function(M6,SU){SU.exports={$schema:\"https://json-schema.org/draft/2019-09/schema\",$id:\"https://json-schema.org/draft/2019-09/meta/core\",$vocabulary:{\"https://json-schema.org/draft/2019-09/vocab/core\":!0},$recursiveAnchor:!0,title:\"Core vocabulary meta-schema\",type:[\"object\",\"boolean\"],properties:{$id:{type:\"string\",format:\"uri-reference\",$comment:\"Non-empty fragments not allowed.\",pattern:\"^[^#]*#?$\"},$schema:{type:\"string\",format:\"uri\"},$anchor:{type:\"string\",pattern:\"^[A-Za-z][-A-Za-z0-9.:_]*$\"},$ref:{type:\"string\",format:\"uri-reference\"},$recursiveRef:{type:\"string\",format:\"uri-reference\"},$recursiveAnchor:{type:\"boolean\",default:!1},$vocabulary:{type:\"object\",propertyNames:{type:\"string\",format:\"uri\"},additionalProperties:{type:\"boolean\"}},$comment:{type:\"string\"},$defs:{type:\"object\",additionalProperties:{$recursiveRef:\"#\"},default:{}}}}});var Jk=g(function(q6,IU){IU.exports={$schema:\"https://json-schema.org/draft/2019-09/schema\",$id:\"https://json-schema.org/draft/2019-09/meta/format\",$vocabulary:{\"https://json-schema.org/draft/2019-09/vocab/format\":!0},$recursiveAnchor:!0,title:\"Format vocabulary meta-schema\",type:[\"object\",\"boolean\"],properties:{format:{type:\"string\"}}}});var Wk=g(function(z6,kU){kU.exports={$schema:\"https://json-schema.org/draft/2019-09/schema\",$id:\"https://json-schema.org/draft/2019-09/meta/meta-data\",$vocabulary:{\"https://json-schema.org/draft/2019-09/vocab/meta-data\":!0},$recursiveAnchor:!0,title:\"Meta-data vocabulary meta-schema\",type:[\"object\",\"boolean\"],properties:{title:{type:\"string\"},description:{type:\"string\"},default:!0,deprecated:{type:\"boolean\",default:!1},readOnly:{type:\"boolean\",default:!1},writeOnly:{type:\"boolean\",default:!1},examples:{type:\"array\",items:!0}}}});var Kk=g(function(j6,RU){RU.exports={$schema:\"https://json-schema.org/draft/2019-09/schema\",$id:\"https://json-schema.org/draft/2019-09/meta/validation\",$vocabulary:{\"https://json-schema.org/draft/2019-09/vocab/validation\":!0},$recursiveAnchor:!0,title:\"Validation vocabulary meta-schema\",type:[\"object\",\"boolean\"],properties:{multipleOf:{type:\"number\",exclusiveMinimum:0},maximum:{type:\"number\"},exclusiveMaximum:{type:\"number\"},minimum:{type:\"number\"},exclusiveMinimum:{type:\"number\"},maxLength:{$ref:\"#/$defs/nonNegativeInteger\"},minLength:{$ref:\"#/$defs/nonNegativeIntegerDefault0\"},pattern:{type:\"string\",format:\"regex\"},maxItems:{$ref:\"#/$defs/nonNegativeInteger\"},minItems:{$ref:\"#/$defs/nonNegativeIntegerDefault0\"},uniqueItems:{type:\"boolean\",default:!1},maxContains:{$ref:\"#/$defs/nonNegativeInteger\"},minContains:{$ref:\"#/$defs/nonNegativeInteger\",default:1},maxProperties:{$ref:\"#/$defs/nonNegativeInteger\"},minProperties:{$ref:\"#/$defs/nonNegativeIntegerDefault0\"},required:{$ref:\"#/$defs/stringArray\"},dependentRequired:{type:\"object\",additionalProperties:{$ref:\"#/$defs/stringArray\"}},const:!0,enum:{type:\"array\",items:!0},type:{anyOf:[{$ref:\"#/$defs/simpleTypes\"},{type:\"array\",items:{$ref:\"#/$defs/simpleTypes\"},minItems:1,uniqueItems:!0}]}},$defs:{nonNegativeInteger:{type:\"integer\",minimum:0},nonNegativeIntegerDefault0:{$ref:\"#/$defs/nonNegativeInteger\",default:0},simpleTypes:{enum:[\"array\",\"boolean\",\"integer\",\"null\",\"number\",\"object\",\"string\"]},stringArray:{type:\"array\",items:{type:\"string\"},uniqueItems:!0,default:[]}}}});var Zk=g(function(Hk){Object.defineProperty(Hk,\"__esModule\",{value:!0});var TU=Gk(),AU=Bk(),CU=Vk(),EU=Fk(),PU=Jk(),OU=Wk(),$U=Kk(),MU=[\"/properties\"];function qU(e){return[TU,AU,CU,EU,t(this,PU),OU,t(this,$U)].forEach((n)=>this.addMetaSchema(n,void 0,!1)),this;function t(n,r){return e?n.$dataMetaSchema(r,MU):r}}Hk.default=qU});var Yk=g(function(Me,eu){Object.defineProperty(Me,\"__esModule\",{value:!0});Me.MissingRefError=Me.ValidationError=Me.CodeGen=Me.Name=Me.nil=Me.stringify=Me.str=Me._=Me.KeywordCxt=Me.Ajv2019=void 0;var jU=Js(),NU=Jl(),DU=Zl(),UU=Yl(),LU=Xl(),GU=ui(),BU=Zk(),Ql=\"https://json-schema.org/draft/2019-09/schema\";class ao extends jU.default{constructor(e={}){super({...e,dynamicRef:!0,next:!0,unevaluated:!0})}_addVocabularies(){if(super._addVocabularies(),this.addVocabulary(DU.default),NU.default.forEach((e)=>this.addVocabulary(e)),this.addVocabulary(UU.default),this.addVocabulary(LU.default),this.opts.discriminator)this.addKeyword(GU.default)}_addDefaultMetaSchema(){super._addDefaultMetaSchema();let{$data:e,meta:t}=this.opts;if(!t)return;BU.default.call(this,e),this.refs[\"http://json-schema.org/schema\"]=Ql}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(Ql)?Ql:void 0)}}Me.Ajv2019=ao;eu.exports=Me=ao;eu.exports.Ajv2019=ao;Object.defineProperty(Me,\"__esModule\",{value:!0});Me.default=ao;var VU=In();Object.defineProperty(Me,\"KeywordCxt\",{enumerable:!0,get:function(){return VU.KeywordCxt}});var _r=N();Object.defineProperty(Me,\"_\",{enumerable:!0,get:function(){return _r._}});Object.defineProperty(Me,\"str\",{enumerable:!0,get:function(){return _r.str}});Object.defineProperty(Me,\"stringify\",{enumerable:!0,get:function(){return _r.stringify}});Object.defineProperty(Me,\"nil\",{enumerable:!0,get:function(){return _r.nil}});Object.defineProperty(Me,\"Name\",{enumerable:!0,get:function(){return _r.Name}});Object.defineProperty(Me,\"CodeGen\",{enumerable:!0,get:function(){return _r.CodeGen}});var FU=ar();Object.defineProperty(Me,\"ValidationError\",{enumerable:!0,get:function(){return FU.default}});var JU=kn();Object.defineProperty(Me,\"MissingRefError\",{enumerable:!0,get:function(){return JU.default}})});var Qk=g(function(Xk){Object.defineProperty(Xk,\"__esModule\",{value:!0});var HU=Nl(),ZU=Dl(),YU=Bl(),XU=Zl(),QU=Yl(),eL=Xl(),tL=Vl(),bi=Fl(),nL=[XU.default,HU.default,ZU.default,(0,YU.default)(!0),tL.default,bi.metadataVocabulary,bi.contentVocabulary,QU.default,eL.default];Xk.default=nL});var eR=g(function(K6,oL){oL.exports={$schema:\"https://json-schema.org/draft/2020-12/schema\",$id:\"https://json-schema.org/draft/2020-12/schema\",$vocabulary:{\"https://json-schema.org/draft/2020-12/vocab/core\":!0,\"https://json-schema.org/draft/2020-12/vocab/applicator\":!0,\"https://json-schema.org/draft/2020-12/vocab/unevaluated\":!0,\"https://json-schema.org/draft/2020-12/vocab/validation\":!0,\"https://json-schema.org/draft/2020-12/vocab/meta-data\":!0,\"https://json-schema.org/draft/2020-12/vocab/format-annotation\":!0,\"https://json-schema.org/draft/2020-12/vocab/content\":!0},$dynamicAnchor:\"meta\",title:\"Core and Validation specifications meta-schema\",allOf:[{$ref:\"meta/core\"},{$ref:\"meta/applicator\"},{$ref:\"meta/unevaluated\"},{$ref:\"meta/validation\"},{$ref:\"meta/meta-data\"},{$ref:\"meta/format-annotation\"},{$ref:\"meta/content\"}],type:[\"object\",\"boolean\"],$comment:\"This meta-schema also defines keywords that have appeared in previous drafts in order to prevent incompatible extensions as they remain in common use.\",properties:{definitions:{$comment:'\"definitions\" has been replaced by \"$defs\".',type:\"object\",additionalProperties:{$dynamicRef:\"#meta\"},deprecated:!0,default:{}},dependencies:{$comment:'\"dependencies\" has been split and replaced by \"dependentSchemas\" and \"dependentRequired\" in order to serve their differing semantics.',type:\"object\",additionalProperties:{anyOf:[{$dynamicRef:\"#meta\"},{$ref:\"meta/validation#/$defs/stringArray\"}]},deprecated:!0,default:{}},$recursiveAnchor:{$comment:'\"$recursiveAnchor\" has been replaced by \"$dynamicAnchor\".',$ref:\"meta/core#/$defs/anchorString\",deprecated:!0},$recursiveRef:{$comment:'\"$recursiveRef\" has been replaced by \"$dynamicRef\".',$ref:\"meta/core#/$defs/uriReferenceString\",deprecated:!0}}}});var tR=g(function(H6,sL){sL.exports={$schema:\"https://json-schema.org/draft/2020-12/schema\",$id:\"https://json-schema.org/draft/2020-12/meta/applicator\",$vocabulary:{\"https://json-schema.org/draft/2020-12/vocab/applicator\":!0},$dynamicAnchor:\"meta\",title:\"Applicator vocabulary meta-schema\",type:[\"object\",\"boolean\"],properties:{prefixItems:{$ref:\"#/$defs/schemaArray\"},items:{$dynamicRef:\"#meta\"},contains:{$dynamicRef:\"#meta\"},additionalProperties:{$dynamicRef:\"#meta\"},properties:{type:\"object\",additionalProperties:{$dynamicRef:\"#meta\"},default:{}},patternProperties:{type:\"object\",additionalProperties:{$dynamicRef:\"#meta\"},propertyNames:{format:\"regex\"},default:{}},dependentSchemas:{type:\"object\",additionalProperties:{$dynamicRef:\"#meta\"},default:{}},propertyNames:{$dynamicRef:\"#meta\"},if:{$dynamicRef:\"#meta\"},then:{$dynamicRef:\"#meta\"},else:{$dynamicRef:\"#meta\"},allOf:{$ref:\"#/$defs/schemaArray\"},anyOf:{$ref:\"#/$defs/schemaArray\"},oneOf:{$ref:\"#/$defs/schemaArray\"},not:{$dynamicRef:\"#meta\"}},$defs:{schemaArray:{type:\"array\",minItems:1,items:{$dynamicRef:\"#meta\"}}}}});var nR=g(function(Z6,iL){iL.exports={$schema:\"https://json-schema.org/draft/2020-12/schema\",$id:\"https://json-schema.org/draft/2020-12/meta/unevaluated\",$vocabulary:{\"https://json-schema.org/draft/2020-12/vocab/unevaluated\":!0},$dynamicAnchor:\"meta\",title:\"Unevaluated applicator vocabulary meta-schema\",type:[\"object\",\"boolean\"],properties:{unevaluatedItems:{$dynamicRef:\"#meta\"},unevaluatedProperties:{$dynamicRef:\"#meta\"}}}});var rR=g(function(Y6,aL){aL.exports={$schema:\"https://json-schema.org/draft/2020-12/schema\",$id:\"https://json-schema.org/draft/2020-12/meta/content\",$vocabulary:{\"https://json-schema.org/draft/2020-12/vocab/content\":!0},$dynamicAnchor:\"meta\",title:\"Content vocabulary meta-schema\",type:[\"object\",\"boolean\"],properties:{contentEncoding:{type:\"string\"},contentMediaType:{type:\"string\"},contentSchema:{$dynamicRef:\"#meta\"}}}});var oR=g(function(X6,cL){cL.exports={$schema:\"https://json-schema.org/draft/2020-12/schema\",$id:\"https://json-schema.org/draft/2020-12/meta/core\",$vocabulary:{\"https://json-schema.org/draft/2020-12/vocab/core\":!0},$dynamicAnchor:\"meta\",title:\"Core vocabulary meta-schema\",type:[\"object\",\"boolean\"],properties:{$id:{$ref:\"#/$defs/uriReferenceString\",$comment:\"Non-empty fragments not allowed.\",pattern:\"^[^#]*#?$\"},$schema:{$ref:\"#/$defs/uriString\"},$ref:{$ref:\"#/$defs/uriReferenceString\"},$anchor:{$ref:\"#/$defs/anchorString\"},$dynamicRef:{$ref:\"#/$defs/uriReferenceString\"},$dynamicAnchor:{$ref:\"#/$defs/anchorString\"},$vocabulary:{type:\"object\",propertyNames:{$ref:\"#/$defs/uriString\"},additionalProperties:{type:\"boolean\"}},$comment:{type:\"string\"},$defs:{type:\"object\",additionalProperties:{$dynamicRef:\"#meta\"}}},$defs:{anchorString:{type:\"string\",pattern:\"^[A-Za-z_][-A-Za-z0-9._]*$\"},uriString:{type:\"string\",format:\"uri\"},uriReferenceString:{type:\"string\",format:\"uri-reference\"}}}});var sR=g(function(Q6,lL){lL.exports={$schema:\"https://json-schema.org/draft/2020-12/schema\",$id:\"https://json-schema.org/draft/2020-12/meta/format-annotation\",$vocabulary:{\"https://json-schema.org/draft/2020-12/vocab/format-annotation\":!0},$dynamicAnchor:\"meta\",title:\"Format vocabulary meta-schema for annotation results\",type:[\"object\",\"boolean\"],properties:{format:{type:\"string\"}}}});var iR=g(function(e9,uL){uL.exports={$schema:\"https://json-schema.org/draft/2020-12/schema\",$id:\"https://json-schema.org/draft/2020-12/meta/meta-data\",$vocabulary:{\"https://json-schema.org/draft/2020-12/vocab/meta-data\":!0},$dynamicAnchor:\"meta\",title:\"Meta-data vocabulary meta-schema\",type:[\"object\",\"boolean\"],properties:{title:{type:\"string\"},description:{type:\"string\"},default:!0,deprecated:{type:\"boolean\",default:!1},readOnly:{type:\"boolean\",default:!1},writeOnly:{type:\"boolean\",default:!1},examples:{type:\"array\",items:!0}}}});var aR=g(function(t9,dL){dL.exports={$schema:\"https://json-schema.org/draft/2020-12/schema\",$id:\"https://json-schema.org/draft/2020-12/meta/validation\",$vocabulary:{\"https://json-schema.org/draft/2020-12/vocab/validation\":!0},$dynamicAnchor:\"meta\",title:\"Validation vocabulary meta-schema\",type:[\"object\",\"boolean\"],properties:{type:{anyOf:[{$ref:\"#/$defs/simpleTypes\"},{type:\"array\",items:{$ref:\"#/$defs/simpleTypes\"},minItems:1,uniqueItems:!0}]},const:!0,enum:{type:\"array\",items:!0},multipleOf:{type:\"number\",exclusiveMinimum:0},maximum:{type:\"number\"},exclusiveMaximum:{type:\"number\"},minimum:{type:\"number\"},exclusiveMinimum:{type:\"number\"},maxLength:{$ref:\"#/$defs/nonNegativeInteger\"},minLength:{$ref:\"#/$defs/nonNegativeIntegerDefault0\"},pattern:{type:\"string\",format:\"regex\"},maxItems:{$ref:\"#/$defs/nonNegativeInteger\"},minItems:{$ref:\"#/$defs/nonNegativeIntegerDefault0\"},uniqueItems:{type:\"boolean\",default:!1},maxContains:{$ref:\"#/$defs/nonNegativeInteger\"},minContains:{$ref:\"#/$defs/nonNegativeInteger\",default:1},maxProperties:{$ref:\"#/$defs/nonNegativeInteger\"},minProperties:{$ref:\"#/$defs/nonNegativeIntegerDefault0\"},required:{$ref:\"#/$defs/stringArray\"},dependentRequired:{type:\"object\",additionalProperties:{$ref:\"#/$defs/stringArray\"}}},$defs:{nonNegativeInteger:{type:\"integer\",minimum:0},nonNegativeIntegerDefault0:{$ref:\"#/$defs/nonNegativeInteger\",default:0},simpleTypes:{enum:[\"array\",\"boolean\",\"integer\",\"null\",\"number\",\"object\",\"string\"]},stringArray:{type:\"array\",items:{type:\"string\"},uniqueItems:!0,default:[]}}}});var lR=g(function(cR){Object.defineProperty(cR,\"__esModule\",{value:!0});var pL=eR(),mL=tR(),fL=nR(),gL=rR(),hL=oR(),yL=sR(),bL=iR(),vL=aR(),_L=[\"/properties\"];function wL(e){return[pL,mL,fL,gL,hL,t(this,yL),bL,t(this,vL)].forEach((n)=>this.addMetaSchema(n,void 0,!1)),this;function t(n,r){return e?n.$dataMetaSchema(r,_L):r}}cR.default=wL});var uR=g(function(qe,nu){Object.defineProperty(qe,\"__esModule\",{value:!0});qe.MissingRefError=qe.ValidationError=qe.CodeGen=qe.Name=qe.nil=qe.stringify=qe.str=qe._=qe.KeywordCxt=qe.Ajv2020=void 0;var SL=Js(),IL=Qk(),kL=ui(),RL=lR(),tu=\"https://json-schema.org/draft/2020-12/schema\";class co extends SL.default{constructor(e={}){super({...e,dynamicRef:!0,next:!0,unevaluated:!0})}_addVocabularies(){if(super._addVocabularies(),IL.default.forEach((e)=>this.addVocabulary(e)),this.opts.discriminator)this.addKeyword(kL.default)}_addDefaultMetaSchema(){super._addDefaultMetaSchema();let{$data:e,meta:t}=this.opts;if(!t)return;RL.default.call(this,e),this.refs[\"http://json-schema.org/schema\"]=tu}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(tu)?tu:void 0)}}qe.Ajv2020=co;nu.exports=qe=co;nu.exports.Ajv2020=co;Object.defineProperty(qe,\"__esModule\",{value:!0});qe.default=co;var TL=In();Object.defineProperty(qe,\"KeywordCxt\",{enumerable:!0,get:function(){return TL.KeywordCxt}});var wr=N();Object.defineProperty(qe,\"_\",{enumerable:!0,get:function(){return wr._}});Object.defineProperty(qe,\"str\",{enumerable:!0,get:function(){return wr.str}});Object.defineProperty(qe,\"stringify\",{enumerable:!0,get:function(){return wr.stringify}});Object.defineProperty(qe,\"nil\",{enumerable:!0,get:function(){return wr.nil}});Object.defineProperty(qe,\"Name\",{enumerable:!0,get:function(){return wr.Name}});Object.defineProperty(qe,\"CodeGen\",{enumerable:!0,get:function(){return wr.CodeGen}});var AL=ar();Object.defineProperty(qe,\"ValidationError\",{enumerable:!0,get:function(){return AL.default}});var CL=kn();Object.defineProperty(qe,\"MissingRefError\",{enumerable:!0,get:function(){return CL.default}})});import{randomUUID as BG}from\"node:crypto\";function I(e){return e()}var Mu;function b(e,t,n){function r(a,c){if(!a._zod)Object.defineProperty(a,\"_zod\",{value:{def:c,constr:i,traits:new Set},enumerable:!1});if(a._zod.traits.has(e))return;a._zod.traits.add(e),t(a,c);let l=i.prototype,u=Object.keys(l);for(let p=0;p<u.length;p++){let m=u[p];if(!(m in a))a[m]=l[m].bind(a)}}let o=n?.Parent??Object;class s extends o{}Object.defineProperty(s,\"name\",{value:e});function i(a){var c;let l=n?.Parent?new s:this;r(l,a),(c=l._zod).deferred??(c.deferred=[]);for(let u of l._zod.deferred)u();return l}return Object.defineProperty(i,\"init\",{value:r}),Object.defineProperty(i,Symbol.hasInstance,{value:(a)=>{if(n?.Parent&&a instanceof n.Parent)return!0;return a?._zod?.traits?.has(e)}}),Object.defineProperty(i,\"name\",{value:e}),i}var nB=Symbol(\"zod_brand\");class bt extends Error{constructor(){super(\"Encountered Promise during synchronous parse. Use .parseAsync() instead.\")}}class kr extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`);this.name=\"ZodEncodeError\"}}(Mu=globalThis).__zod_globalConfig??(Mu.__zod_globalConfig={});var $n=globalThis.__zod_globalConfig;function We(e){if(e)Object.assign($n,e);return $n}function bo(e){let t=Object.values(e).filter((r)=>typeof r===\"number\");return Object.entries(e).filter(([r,o])=>t.indexOf(+r)===-1).map(([r,o])=>o)}function Rr(e,t){if(typeof t===\"bigint\")return t.toString();return t}function Tr(e){return{get value(){{let n=e();return Object.defineProperty(this,\"value\",{value:n}),n}throw Error(\"cached value already set\")}}}function vo(e){return e===null||e===void 0}function _o(e){let t=e.startsWith(\"^\")?1:0,n=e.endsWith(\"$\")?e.length-1:e.length;return e.slice(t,n)}function zu(e,t){let n=e/t,r=Math.round(n),o=Number.EPSILON*Math.max(Math.abs(n),1);if(Math.abs(n-r)<o)return 0;return n-r}var qu=Symbol(\"evaluating\");function J(e,t,n){let r=void 0;Object.defineProperty(e,t,{get(){if(r===qu)return;if(r===void 0)r=qu,r=n();return r},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function ln(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Rt(...e){let t={};for(let n of e){let r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function Oi(e){return JSON.stringify(e)}function ju(e){return e.toLowerCase().trim().replace(/[^\\w\\s-]/g,\"\").replace(/[\\s_-]+/g,\"-\").replace(/^-+|-+$/g,\"\")}var $i=\"captureStackTrace\"in Error?Error.captureStackTrace:(...e)=>{};function Mn(e){return typeof e===\"object\"&&e!==null&&!Array.isArray(e)}var Nu=Tr(()=>{if($n.jitless)return!1;if(typeof navigator<\"u\"&&navigator?.userAgent?.includes(\"Cloudflare\"))return!1;try{return new Function(\"\"),!0}catch(e){return!1}});function un(e){if(Mn(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;if(typeof t!==\"function\")return!0;let n=t.prototype;if(Mn(n)===!1)return!1;if(Object.prototype.hasOwnProperty.call(n,\"isPrototypeOf\")===!1)return!1;return!0}function Mi(e){if(un(e))return{...e};if(Array.isArray(e))return[...e];if(e instanceof Map)return new Map(e);if(e instanceof Set)return new Set(e);return e}var Du=new Set([\"string\",\"number\",\"symbol\"]);function Tt(e){return e.replace(/[.*+?^${}()|[\\]\\\\]/g,\"\\\\$&\")}function Xe(e,t,n){let r=new e._zod.constr(t??e._zod.def);if(!t||n?.parent)r._zod.parent=e;return r}function P(e){let t=e;if(!t)return{};if(typeof t===\"string\")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error(\"Cannot specify both `message` and `error` params\");t.error=t.message}if(delete t.message,typeof t.error===\"string\")return{...t,error:()=>t.error};return t}function Uu(e){return Object.keys(e).filter((t)=>e[t]._zod.optin===\"optional\"&&e[t]._zod.optout===\"optional\")}var Lu={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-340282346638528860000000000000000000000,340282346638528860000000000000000000000],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function kT(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(\".pick() cannot be used on object schemas containing refinements\");let s=Rt(e._zod.def,{get shape(){let i={};for(let a in t){if(!(a in n.shape))throw Error(`Unrecognized key: \"${a}\"`);if(!t[a])continue;i[a]=n.shape[a]}return ln(this,\"shape\",i),i},checks:[]});return Xe(e,s)}function RT(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(\".omit() cannot be used on object schemas containing refinements\");let s=Rt(e._zod.def,{get shape(){let i={...e._zod.def.shape};for(let a in t){if(!(a in n.shape))throw Error(`Unrecognized key: \"${a}\"`);if(!t[a])continue;delete i[a]}return ln(this,\"shape\",i),i},checks:[]});return Xe(e,s)}function TT(e,t){if(!un(t))throw Error(\"Invalid input to extend: expected a plain object\");let n=e._zod.def.checks;if(n&&n.length>0){let s=e._zod.def.shape;for(let i in t)if(Object.getOwnPropertyDescriptor(s,i)!==void 0)throw Error(\"Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.\")}let o=Rt(e._zod.def,{get shape(){let s={...e._zod.def.shape,...t};return ln(this,\"shape\",s),s}});return Xe(e,o)}function AT(e,t){if(!un(t))throw Error(\"Invalid input to safeExtend: expected a plain object\");let n=Rt(e._zod.def,{get shape(){let r={...e._zod.def.shape,...t};return ln(this,\"shape\",r),r}});return Xe(e,n)}function CT(e,t){if(e._zod.def.checks?.length)throw Error(\".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.\");let n=Rt(e._zod.def,{get shape(){let r={...e._zod.def.shape,...t._zod.def.shape};return ln(this,\"shape\",r),r},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return Xe(e,n)}function ET(e,t,n){let o=t._zod.def.checks;if(o&&o.length>0)throw Error(\".partial() cannot be used on object schemas containing refinements\");let i=Rt(t._zod.def,{get shape(){let a=t._zod.def.shape,c={...a};if(n)for(let l in n){if(!(l in a))throw Error(`Unrecognized key: \"${l}\"`);if(!n[l])continue;c[l]=e?new e({type:\"optional\",innerType:a[l]}):a[l]}else for(let l in a)c[l]=e?new e({type:\"optional\",innerType:a[l]}):a[l];return ln(this,\"shape\",c),c},checks:[]});return Xe(t,i)}function PT(e,t,n){let r=Rt(t._zod.def,{get shape(){let o=t._zod.def.shape,s={...o};if(n)for(let i in n){if(!(i in s))throw Error(`Unrecognized key: \"${i}\"`);if(!n[i])continue;s[i]=new e({type:\"nonoptional\",innerType:o[i]})}else for(let i in o)s[i]=new e({type:\"nonoptional\",innerType:o[i]});return ln(this,\"shape\",s),s}});return Xe(t,r)}function dn(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Gu(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function At(e,t){return t.map((n)=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function yo(e){return typeof e===\"string\"?e:e?.message}function Ke(e,t,n){let r=e.message?e.message:yo(e.inst?._zod.def?.error?.(e))??yo(t?.error?.(e))??yo(n.customError?.(e))??yo(n.localeError?.(e))??\"Invalid input\",{inst:o,continue:s,input:i,...a}=e;if(a.path??(a.path=[]),a.message=r,t?.reportInput)a.input=i;return a}function wo(e){if(Array.isArray(e))return\"array\";if(typeof e===\"string\")return\"string\";return\"unknown\"}function pn(...e){let[t,n,r]=e;if(typeof t===\"string\")return{message:t,code:\"custom\",input:n,inst:r};return{...t}}var Bu=(e,t)=>{e.name=\"$ZodError\",Object.defineProperty(e,\"_zod\",{value:e._zod,enumerable:!1}),Object.defineProperty(e,\"issues\",{value:t,enumerable:!1}),e.message=JSON.stringify(t,Rr,2),Object.defineProperty(e,\"toString\",{value:()=>e.message,enumerable:!1})},xo=b(\"$ZodError\",Bu),qi=b(\"$ZodError\",Bu,{Parent:Error});function Vu(e,t=(n)=>n.message){let n={},r=[];for(let o of e.issues)if(o.path.length>0)n[o.path[0]]=n[o.path[0]]||[],n[o.path[0]].push(t(o));else r.push(t(o));return{formErrors:r,fieldErrors:n}}function Fu(e,t=(n)=>n.message){let n={_errors:[]},r=(o,s=[])=>{for(let i of o.issues)if(i.code===\"invalid_union\"&&i.errors.length)i.errors.map((a)=>r({issues:a},[...s,...i.path]));else if(i.code===\"invalid_key\")r({issues:i.issues},[...s,...i.path]);else if(i.code===\"invalid_element\")r({issues:i.issues},[...s,...i.path]);else{let a=[...s,...i.path];if(a.length===0)n._errors.push(t(i));else{let c=n,l=0;while(l<a.length){let u=a[l];if(l!==a.length-1)c[u]=c[u]||{_errors:[]};else c[u]=c[u]||{_errors:[]},c[u]._errors.push(t(i));c=c[u],l++}}}};return r(e),n}var So=(e)=>(t,n,r,o)=>{let s=r?{...r,async:!1}:{async:!1},i=t._zod.run({value:n,issues:[]},s);if(i instanceof Promise)throw new bt;if(i.issues.length){let a=new(o?.Err??e)(i.issues.map((c)=>Ke(c,s,We())));throw $i(a,o?.callee),a}return i.value};var Io=(e)=>async(t,n,r,o)=>{let s=r?{...r,async:!0}:{async:!0},i=t._zod.run({value:n,issues:[]},s);if(i instanceof Promise)i=await i;if(i.issues.length){let a=new(o?.Err??e)(i.issues.map((c)=>Ke(c,s,We())));throw $i(a,o?.callee),a}return i.value};var Ar=(e)=>(t,n,r)=>{let o=r?{...r,async:!1}:{async:!1},s=t._zod.run({value:n,issues:[]},o);if(s instanceof Promise)throw new bt;return s.issues.length?{success:!1,error:new(e??xo)(s.issues.map((i)=>Ke(i,o,We())))}:{success:!0,data:s.value}},Ju=Ar(qi),Cr=(e)=>async(t,n,r)=>{let o=r?{...r,async:!0}:{async:!0},s=t._zod.run({value:n,issues:[]},o);if(s instanceof Promise)s=await s;return s.issues.length?{success:!1,error:new e(s.issues.map((i)=>Ke(i,o,We())))}:{success:!0,data:s.value}},Wu=Cr(qi),Ku=(e)=>(t,n,r)=>{let o=r?{...r,direction:\"backward\"}:{direction:\"backward\"};return So(e)(t,n,o)};var Hu=(e)=>(t,n,r)=>So(e)(t,n,r);var Zu=(e)=>async(t,n,r)=>{let o=r?{...r,direction:\"backward\"}:{direction:\"backward\"};return Io(e)(t,n,o)};var Yu=(e)=>async(t,n,r)=>Io(e)(t,n,r);var Xu=(e)=>(t,n,r)=>{let o=r?{...r,direction:\"backward\"}:{direction:\"backward\"};return Ar(e)(t,n,o)};var Qu=(e)=>(t,n,r)=>Ar(e)(t,n,r);var ed=(e)=>async(t,n,r)=>{let o=r?{...r,direction:\"backward\"}:{direction:\"backward\"};return Cr(e)(t,n,o)};var td=(e)=>async(t,n,r)=>Cr(e)(t,n,r);var nd=/^[cC][0-9a-z]{6,}$/,rd=/^[0-9a-z]+$/,od=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,sd=/^[0-9a-vA-V]{20}$/,id=/^[A-Za-z0-9]{27}$/,ad=/^[a-zA-Z0-9_-]{21}$/,cd=/^P(?:(\\d+W)|(?!.*W)(?=\\d|T\\d)(\\d+Y)?(\\d+M)?(\\d+D)?(T(?=\\d)(\\d+H)?(\\d+M)?(\\d+([.,]\\d+)?S)?)?)$/;var ld=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,zi=(e)=>{if(!e)return/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`)};var ud=/^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$/;var $T=\"^(\\\\p{Extended_Pictographic}|\\\\p{Emoji_Component})+$\";function dd(){return new RegExp($T,\"u\")}var pd=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,md=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;var fd=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\\/([0-9]|[1-2][0-9]|3[0-2])$/,gd=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,hd=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,ji=/^[A-Za-z0-9_-]*$/;var yd=/^https?$/,bd=/^\\+[1-9]\\d{6,14}$/,vd=\"(?:(?:\\\\d\\\\d[2468][048]|\\\\d\\\\d[13579][26]|\\\\d\\\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\\\d|30)|(?:02)-(?:0[1-9]|1\\\\d|2[0-8])))\",_d=new RegExp(`^${vd}$`);function wd(e){return typeof e.precision===\"number\"?e.precision===-1?\"(?:[01]\\\\d|2[0-3]):[0-5]\\\\d\":e.precision===0?\"(?:[01]\\\\d|2[0-3]):[0-5]\\\\d:[0-5]\\\\d\":`(?:[01]\\\\d|2[0-3]):[0-5]\\\\d:[0-5]\\\\d\\\\.\\\\d{${e.precision}}`:\"(?:[01]\\\\d|2[0-3]):[0-5]\\\\d(?::[0-5]\\\\d(?:\\\\.\\\\d+)?)?\"}function xd(e){return new RegExp(`^${wd(e)}$`)}function Sd(e){let t=wd({precision:e.precision}),n=[\"Z\"];if(e.local)n.push(\"\");if(e.offset)n.push(\"([+-](?:[01]\\\\d|2[0-3]):[0-5]\\\\d)\");let r=`${t}(?:${n.join(\"|\")})`;return new RegExp(`^${vd}T(?:${r})$`)}var Id=(e)=>{let t=e?`[\\\\s\\\\S]{${e?.minimum??0},${e?.maximum??\"\"}}`:\"[\\\\s\\\\S]*\";return new RegExp(`^${t}$`)};var kd=/^-?\\d+$/,Ni=/^-?\\d+(?:\\.\\d+)?$/,Rd=/^(?:true|false)$/i,Td=/^null$/i;var Ad=/^[^A-Z]*$/,Cd=/^[^a-z]*$/;var we=b(\"$ZodCheck\",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Ed={number:\"number\",bigint:\"bigint\",object:\"date\"},Di=b(\"$ZodCheckLessThan\",(e,t)=>{we.init(e,t);let n=Ed[typeof t.value];e._zod.onattach.push((r)=>{let o=r._zod.bag,s=(t.inclusive?o.maximum:o.exclusiveMaximum)??Number.POSITIVE_INFINITY;if(t.value<s)if(t.inclusive)o.maximum=t.value;else o.exclusiveMaximum=t.value}),e._zod.check=(r)=>{if(t.inclusive?r.value<=t.value:r.value<t.value)return;r.issues.push({origin:n,code:\"too_big\",maximum:typeof t.value===\"object\"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Ui=b(\"$ZodCheckGreaterThan\",(e,t)=>{we.init(e,t);let n=Ed[typeof t.value];e._zod.onattach.push((r)=>{let o=r._zod.bag,s=(t.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;if(t.value>s)if(t.inclusive)o.minimum=t.value;else o.exclusiveMinimum=t.value}),e._zod.check=(r)=>{if(t.inclusive?r.value>=t.value:r.value>t.value)return;r.issues.push({origin:n,code:\"too_small\",minimum:typeof t.value===\"object\"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Pd=b(\"$ZodCheckMultipleOf\",(e,t)=>{we.init(e,t),e._zod.onattach.push((n)=>{var r;(r=n._zod.bag).multipleOf??(r.multipleOf=t.value)}),e._zod.check=(n)=>{if(typeof n.value!==typeof t.value)throw Error(\"Cannot mix number and bigint in multiple_of check.\");if(typeof n.value===\"bigint\"?n.value%t.value===BigInt(0):zu(n.value,t.value)===0)return;n.issues.push({origin:typeof n.value,code:\"not_multiple_of\",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Od=b(\"$ZodCheckNumberFormat\",(e,t)=>{we.init(e,t),t.format=t.format||\"float64\";let n=t.format?.includes(\"int\"),r=n?\"int\":\"number\",[o,s]=Lu[t.format];e._zod.onattach.push((i)=>{let a=i._zod.bag;if(a.format=t.format,a.minimum=o,a.maximum=s,n)a.pattern=kd}),e._zod.check=(i)=>{let a=i.value;if(n){if(!Number.isInteger(a)){i.issues.push({expected:r,format:t.format,code:\"invalid_type\",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){if(a>0)i.issues.push({input:a,code:\"too_big\",maximum:Number.MAX_SAFE_INTEGER,note:\"Integers must be within the safe integer range.\",inst:e,origin:r,inclusive:!0,continue:!t.abort});else i.issues.push({input:a,code:\"too_small\",minimum:Number.MIN_SAFE_INTEGER,note:\"Integers must be within the safe integer range.\",inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}if(a<o)i.issues.push({origin:\"number\",input:a,code:\"too_small\",minimum:o,inclusive:!0,inst:e,continue:!t.abort});if(a>s)i.issues.push({origin:\"number\",input:a,code:\"too_big\",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}});var $d=b(\"$ZodCheckMaxLength\",(e,t)=>{var n;we.init(e,t),(n=e._zod.def).when??(n.when=(r)=>{let o=r.value;return!vo(o)&&o.length!==void 0}),e._zod.onattach.push((r)=>{let o=r._zod.bag.maximum??Number.POSITIVE_INFINITY;if(t.maximum<o)r._zod.bag.maximum=t.maximum}),e._zod.check=(r)=>{let o=r.value;if(o.length<=t.maximum)return;let i=wo(o);r.issues.push({origin:i,code:\"too_big\",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Md=b(\"$ZodCheckMinLength\",(e,t)=>{var n;we.init(e,t),(n=e._zod.def).when??(n.when=(r)=>{let o=r.value;return!vo(o)&&o.length!==void 0}),e._zod.onattach.push((r)=>{let o=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;if(t.minimum>o)r._zod.bag.minimum=t.minimum}),e._zod.check=(r)=>{let o=r.value;if(o.length>=t.minimum)return;let i=wo(o);r.issues.push({origin:i,code:\"too_small\",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),qd=b(\"$ZodCheckLengthEquals\",(e,t)=>{var n;we.init(e,t),(n=e._zod.def).when??(n.when=(r)=>{let o=r.value;return!vo(o)&&o.length!==void 0}),e._zod.onattach.push((r)=>{let o=r._zod.bag;o.minimum=t.length,o.maximum=t.length,o.length=t.length}),e._zod.check=(r)=>{let o=r.value,s=o.length;if(s===t.length)return;let i=wo(o),a=s>t.length;r.issues.push({origin:i,...a?{code:\"too_big\",maximum:t.length}:{code:\"too_small\",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),Er=b(\"$ZodCheckStringFormat\",(e,t)=>{var n,r;if(we.init(e,t),e._zod.onattach.push((o)=>{let s=o._zod.bag;if(s.format=t.format,t.pattern)s.patterns??(s.patterns=new Set),s.patterns.add(t.pattern)}),t.pattern)(n=e._zod).check??(n.check=(o)=>{if(t.pattern.lastIndex=0,t.pattern.test(o.value))return;o.issues.push({origin:\"string\",code:\"invalid_format\",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})});else(r=e._zod).check??(r.check=()=>{})}),zd=b(\"$ZodCheckRegex\",(e,t)=>{Er.init(e,t),e._zod.check=(n)=>{if(t.pattern.lastIndex=0,t.pattern.test(n.value))return;n.issues.push({origin:\"string\",code:\"invalid_format\",format:\"regex\",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),jd=b(\"$ZodCheckLowerCase\",(e,t)=>{t.pattern??(t.pattern=Ad),Er.init(e,t)}),Nd=b(\"$ZodCheckUpperCase\",(e,t)=>{t.pattern??(t.pattern=Cd),Er.init(e,t)}),Dd=b(\"$ZodCheckIncludes\",(e,t)=>{we.init(e,t);let n=Tt(t.includes),r=new RegExp(typeof t.position===\"number\"?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push((o)=>{let s=o._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(r)}),e._zod.check=(o)=>{if(o.value.includes(t.includes,t.position))return;o.issues.push({origin:\"string\",code:\"invalid_format\",format:\"includes\",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),Ud=b(\"$ZodCheckStartsWith\",(e,t)=>{we.init(e,t);let n=new RegExp(`^${Tt(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push((r)=>{let o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=(r)=>{if(r.value.startsWith(t.prefix))return;r.issues.push({origin:\"string\",code:\"invalid_format\",format:\"starts_with\",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),Ld=b(\"$ZodCheckEndsWith\",(e,t)=>{we.init(e,t);let n=new RegExp(`.*${Tt(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push((r)=>{let o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=(r)=>{if(r.value.endsWith(t.suffix))return;r.issues.push({origin:\"string\",code:\"invalid_format\",format:\"ends_with\",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}});var Gd=b(\"$ZodCheckOverwrite\",(e,t)=>{we.init(e,t),e._zod.check=(n)=>{n.value=t.tx(n.value)}});class Li{constructor(e=[]){if(this.content=[],this.indent=0,this)this.args=e}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if(typeof e===\"function\"){e(this,{execution:\"sync\"}),e(this,{execution:\"async\"});return}let n=e.split(`\n`).filter((s)=>s),r=Math.min(...n.map((s)=>s.length-s.trimStart().length)),o=n.map((s)=>s.slice(r)).map((s)=>\" \".repeat(this.indent*2)+s);for(let s of o)this.content.push(s)}compile(){let e=Function,t=this?.args,r=[...(this?.content??[\"\"]).map((o)=>` ${o}`)];return new e(...t,r.join(`\n`))}}var Vd={major:4,minor:4,patch:3};var te=b(\"$ZodType\",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Vd;let r=[...e._zod.def.checks??[]];if(e._zod.traits.has(\"$ZodCheck\"))r.unshift(e);for(let o of r)for(let s of o._zod.onattach)s(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let o=(i,a,c)=>{let l=dn(i),u;for(let p of a){if(p._zod.def.when){if(Gu(i))continue;if(!p._zod.def.when(i))continue}else if(l)continue;let m=i.issues.length,d=p._zod.check(i);if(d instanceof Promise&&c?.async===!1)throw new bt;if(u||d instanceof Promise)u=(u??Promise.resolve()).then(async()=>{if(await d,i.issues.length===m)return;if(!l)l=dn(i,m)});else{if(i.issues.length===m)continue;if(!l)l=dn(i,m)}}if(u)return u.then(()=>i);return i},s=(i,a,c)=>{if(dn(i))return i.aborted=!0,i;let l=o(a,r,c);if(l instanceof Promise){if(c.async===!1)throw new bt;return l.then((u)=>e._zod.parse(u,c))}return e._zod.parse(l,c)};e._zod.run=(i,a)=>{if(a.skipChecks)return e._zod.parse(i,a);if(a.direction===\"backward\"){let l=e._zod.parse({value:i.value,issues:[]},{...a,skipChecks:!0});if(l instanceof Promise)return l.then((u)=>s(u,i,a));return s(l,i,a)}let c=e._zod.parse(i,a);if(c instanceof Promise){if(a.async===!1)throw new bt;return c.then((l)=>o(l,r,a))}return o(c,r,a)}}J(e,\"~standard\",()=>({validate:(o)=>{try{let s=Ju(e,o);return s.success?{value:s.data}:{issues:s.error?.issues}}catch(s){return Wu(e,o).then((i)=>i.success?{value:i.data}:{issues:i.error?.issues})}},vendor:\"zod\",version:1}))}),Ao=b(\"$ZodString\",(e,t)=>{te.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Id(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch(o){}if(typeof n.value===\"string\")return n;return n.issues.push({expected:\"string\",code:\"invalid_type\",input:n.value,inst:e}),n}}),ne=b(\"$ZodStringFormat\",(e,t)=>{Er.init(e,t),Ao.init(e,t)}),Qd=b(\"$ZodGUID\",(e,t)=>{t.pattern??(t.pattern=ld),ne.init(e,t)}),ep=b(\"$ZodUUID\",(e,t)=>{if(t.version){let r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(r===void 0)throw Error(`Invalid UUID version: \"${t.version}\"`);t.pattern??(t.pattern=zi(r))}else t.pattern??(t.pattern=zi());ne.init(e,t)}),tp=b(\"$ZodEmail\",(e,t)=>{t.pattern??(t.pattern=ud),ne.init(e,t)}),np=b(\"$ZodURL\",(e,t)=>{ne.init(e,t),e._zod.check=(n)=>{try{let r=n.value.trim();if(!t.normalize&&t.protocol?.source===yd.source){if(!/^https?:\\/\\//i.test(r)){n.issues.push({code:\"invalid_format\",format:\"url\",note:\"Invalid URL format\",input:n.value,inst:e,continue:!t.abort});return}}let o=new URL(r);if(t.hostname){if(t.hostname.lastIndex=0,!t.hostname.test(o.hostname))n.issues.push({code:\"invalid_format\",format:\"url\",note:\"Invalid hostname\",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})}if(t.protocol){if(t.protocol.lastIndex=0,!t.protocol.test(o.protocol.endsWith(\":\")?o.protocol.slice(0,-1):o.protocol))n.issues.push({code:\"invalid_format\",format:\"url\",note:\"Invalid protocol\",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})}if(t.normalize)n.value=o.href;else n.value=r;return}catch(r){n.issues.push({code:\"invalid_format\",format:\"url\",input:n.value,inst:e,continue:!t.abort})}}}),rp=b(\"$ZodEmoji\",(e,t)=>{t.pattern??(t.pattern=dd()),ne.init(e,t)}),op=b(\"$ZodNanoID\",(e,t)=>{t.pattern??(t.pattern=ad),ne.init(e,t)}),sp=b(\"$ZodCUID\",(e,t)=>{t.pattern??(t.pattern=nd),ne.init(e,t)}),ip=b(\"$ZodCUID2\",(e,t)=>{t.pattern??(t.pattern=rd),ne.init(e,t)}),ap=b(\"$ZodULID\",(e,t)=>{t.pattern??(t.pattern=od),ne.init(e,t)}),cp=b(\"$ZodXID\",(e,t)=>{t.pattern??(t.pattern=sd),ne.init(e,t)}),lp=b(\"$ZodKSUID\",(e,t)=>{t.pattern??(t.pattern=id),ne.init(e,t)}),up=b(\"$ZodISODateTime\",(e,t)=>{t.pattern??(t.pattern=Sd(t)),ne.init(e,t)}),dp=b(\"$ZodISODate\",(e,t)=>{t.pattern??(t.pattern=_d),ne.init(e,t)}),pp=b(\"$ZodISOTime\",(e,t)=>{t.pattern??(t.pattern=xd(t)),ne.init(e,t)}),mp=b(\"$ZodISODuration\",(e,t)=>{t.pattern??(t.pattern=cd),ne.init(e,t)}),fp=b(\"$ZodIPv4\",(e,t)=>{t.pattern??(t.pattern=pd),ne.init(e,t),e._zod.bag.format=\"ipv4\"}),gp=b(\"$ZodIPv6\",(e,t)=>{t.pattern??(t.pattern=md),ne.init(e,t),e._zod.bag.format=\"ipv6\",e._zod.check=(n)=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:\"invalid_format\",format:\"ipv6\",input:n.value,inst:e,continue:!t.abort})}}});var hp=b(\"$ZodCIDRv4\",(e,t)=>{t.pattern??(t.pattern=fd),ne.init(e,t)}),yp=b(\"$ZodCIDRv6\",(e,t)=>{t.pattern??(t.pattern=gd),ne.init(e,t),e._zod.check=(n)=>{let r=n.value.split(\"/\");try{if(r.length!==2)throw Error();let[o,s]=r;if(!s)throw Error();let i=Number(s);if(`${i}`!==s)throw Error();if(i<0||i>128)throw Error();new URL(`http://[${o}]`)}catch{n.issues.push({code:\"invalid_format\",format:\"cidrv6\",input:n.value,inst:e,continue:!t.abort})}}});function bp(e){if(e===\"\")return!0;if(/\\s/.test(e))return!1;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var vp=b(\"$ZodBase64\",(e,t)=>{t.pattern??(t.pattern=hd),ne.init(e,t),e._zod.bag.contentEncoding=\"base64\",e._zod.check=(n)=>{if(bp(n.value))return;n.issues.push({code:\"invalid_format\",format:\"base64\",input:n.value,inst:e,continue:!t.abort})}});function MT(e){if(!ji.test(e))return!1;let t=e.replace(/[-_]/g,(r)=>r===\"-\"?\"+\":\"/\"),n=t.padEnd(Math.ceil(t.length/4)*4,\"=\");return bp(n)}var _p=b(\"$ZodBase64URL\",(e,t)=>{t.pattern??(t.pattern=ji),ne.init(e,t),e._zod.bag.contentEncoding=\"base64url\",e._zod.check=(n)=>{if(MT(n.value))return;n.issues.push({code:\"invalid_format\",format:\"base64url\",input:n.value,inst:e,continue:!t.abort})}}),wp=b(\"$ZodE164\",(e,t)=>{t.pattern??(t.pattern=bd),ne.init(e,t)});function qT(e,t=null){try{let n=e.split(\".\");if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let o=JSON.parse(atob(r));if(\"typ\"in o&&o?.typ!==\"JWT\")return!1;if(!o.alg)return!1;if(t&&(!(\"alg\"in o)||o.alg!==t))return!1;return!0}catch{return!1}}var xp=b(\"$ZodJWT\",(e,t)=>{ne.init(e,t),e._zod.check=(n)=>{if(qT(n.value,t.alg))return;n.issues.push({code:\"invalid_format\",format:\"jwt\",input:n.value,inst:e,continue:!t.abort})}});var Bi=b(\"$ZodNumber\",(e,t)=>{te.init(e,t),e._zod.pattern=e._zod.bag.pattern??Ni,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch(i){}let o=n.value;if(typeof o===\"number\"&&!Number.isNaN(o)&&Number.isFinite(o))return n;let s=typeof o===\"number\"?Number.isNaN(o)?\"NaN\":!Number.isFinite(o)?\"Infinity\":void 0:void 0;return n.issues.push({expected:\"number\",code:\"invalid_type\",input:o,inst:e,...s?{received:s}:{}}),n}}),Sp=b(\"$ZodNumberFormat\",(e,t)=>{Od.init(e,t),Bi.init(e,t)}),Ip=b(\"$ZodBoolean\",(e,t)=>{te.init(e,t),e._zod.pattern=Rd,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Boolean(n.value)}catch(s){}let o=n.value;if(typeof o===\"boolean\")return n;return n.issues.push({expected:\"boolean\",code:\"invalid_type\",input:o,inst:e}),n}});var kp=b(\"$ZodNull\",(e,t)=>{te.init(e,t),e._zod.pattern=Td,e._zod.values=new Set([null]),e._zod.parse=(n,r)=>{let o=n.value;if(o===null)return n;return n.issues.push({expected:\"null\",code:\"invalid_type\",input:o,inst:e}),n}});var Rp=b(\"$ZodUnknown\",(e,t)=>{te.init(e,t),e._zod.parse=(n)=>n}),Tp=b(\"$ZodNever\",(e,t)=>{te.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:\"never\",code:\"invalid_type\",input:n.value,inst:e}),n)});function Fd(e,t,n){if(e.issues.length)t.issues.push(...At(n,e.issues));t.value[n]=e.value}var Ap=b(\"$ZodArray\",(e,t)=>{te.init(e,t),e._zod.parse=(n,r)=>{let o=n.value;if(!Array.isArray(o))return n.issues.push({expected:\"array\",code:\"invalid_type\",input:o,inst:e}),n;n.value=Array(o.length);let s=[];for(let i=0;i<o.length;i++){let a=o[i],c=t.element._zod.run({value:a,issues:[]},r);if(c instanceof Promise)s.push(c.then((l)=>Fd(l,n,i)));else Fd(c,n,i)}if(s.length)return Promise.all(s).then(()=>n);return n}});function To(e,t,n,r,o,s){let i=n in r;if(e.issues.length){if(o&&s&&!i)return;t.issues.push(...At(n,e.issues))}if(!i&&!o){if(!e.issues.length)t.issues.push({code:\"invalid_type\",expected:\"nonoptional\",input:void 0,path:[n]});return}if(e.value===void 0){if(i)t.value[n]=void 0}else t.value[n]=e.value}function Cp(e){let t=Object.keys(e.shape);for(let r of t)if(!e.shape?.[r]?._zod?.traits?.has(\"$ZodType\"))throw Error(`Invalid element at key \"${r}\": expected a Zod schema`);let n=Uu(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function Ep(e,t,n,r,o,s){let i=[],a=o.keySet,c=o.catchall._zod,l=c.def.type,u=c.optin===\"optional\",p=c.optout===\"optional\";for(let m in t){if(m===\"__proto__\")continue;if(a.has(m))continue;if(l===\"never\"){i.push(m);continue}let d=c.run({value:t[m],issues:[]},r);if(d instanceof Promise)e.push(d.then((f)=>To(f,n,m,t,u,p)));else To(d,n,m,t,u,p)}if(i.length)n.issues.push({code:\"unrecognized_keys\",keys:i,input:t,inst:s});if(!e.length)return n;return Promise.all(e).then(()=>n)}var zT=b(\"$ZodObject\",(e,t)=>{if(te.init(e,t),!Object.getOwnPropertyDescriptor(t,\"shape\")?.get){let a=t.shape;Object.defineProperty(t,\"shape\",{get:()=>{let c={...a};return Object.defineProperty(t,\"shape\",{value:c}),c}})}let r=Tr(()=>Cp(t));J(e._zod,\"propValues\",()=>{let a=t.shape,c={};for(let l in a){let u=a[l]._zod;if(u.values){c[l]??(c[l]=new Set);for(let p of u.values)c[l].add(p)}}return c});let o=Mn,s=t.catchall,i;e._zod.parse=(a,c)=>{i??(i=r.value);let l=a.value;if(!o(l))return a.issues.push({expected:\"object\",code:\"invalid_type\",input:l,inst:e}),a;a.value={};let u=[],p=i.shape;for(let m of i.keys){let d=p[m],f=d._zod.optin===\"optional\",h=d._zod.optout===\"optional\",y=d._zod.run({value:l[m],issues:[]},c);if(y instanceof Promise)u.push(y.then((_)=>To(_,a,m,l,f,h)));else To(y,a,m,l,f,h)}if(!s)return u.length?Promise.all(u).then(()=>a):a;return Ep(u,l,a,c,r.value,e)}}),Pp=b(\"$ZodObjectJIT\",(e,t)=>{zT.init(e,t);let n=e._zod.parse,r=Tr(()=>Cp(t)),o=(m)=>{let d=new Li([\"shape\",\"payload\",\"ctx\"]),f=r.value,h=(T)=>{let A=Oi(T);return`shape[${A}]._zod.run({ value: input[${A}], issues: [] }, ctx)`};d.write(\"const input = payload.value;\");let y=Object.create(null),_=0;for(let T of f.keys)y[T]=`key_${_++}`;d.write(\"const newResult = {};\");for(let T of f.keys){let A=y[T],x=Oi(T),K=m[T],C=K?._zod?.optin===\"optional\",D=K?._zod?.optout===\"optional\";if(d.write(`const ${A} = ${h(T)};`),C&&D)d.write(`\n if (${A}.issues.length) {\n if (${x} in input) {\n payload.issues = payload.issues.concat(${A}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${x}, ...iss.path] : [${x}]\n })));\n }\n }\n \n if (${A}.value === undefined) {\n if (${x} in input) {\n newResult[${x}] = undefined;\n }\n } else {\n newResult[${x}] = ${A}.value;\n }\n \n `);else if(!C)d.write(`\n const ${A}_present = ${x} in input;\n if (${A}.issues.length) {\n payload.issues = payload.issues.concat(${A}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${x}, ...iss.path] : [${x}]\n })));\n }\n if (!${A}_present && !${A}.issues.length) {\n payload.issues.push({\n code: \"invalid_type\",\n expected: \"nonoptional\",\n input: undefined,\n path: [${x}]\n });\n }\n\n if (${A}_present) {\n if (${A}.value === undefined) {\n newResult[${x}] = undefined;\n } else {\n newResult[${x}] = ${A}.value;\n }\n }\n\n `);else d.write(`\n if (${A}.issues.length) {\n payload.issues = payload.issues.concat(${A}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${x}, ...iss.path] : [${x}]\n })));\n }\n \n if (${A}.value === undefined) {\n if (${x} in input) {\n newResult[${x}] = undefined;\n }\n } else {\n newResult[${x}] = ${A}.value;\n }\n \n `)}d.write(\"payload.value = newResult;\"),d.write(\"return payload;\");let E=d.compile();return(T,A)=>E(m,T,A)},s,i=Mn,a=!$n.jitless,l=a&&Nu.value,u=t.catchall,p;e._zod.parse=(m,d)=>{p??(p=r.value);let f=m.value;if(!i(f))return m.issues.push({expected:\"object\",code:\"invalid_type\",input:f,inst:e}),m;if(a&&l&&d?.async===!1&&d.jitless!==!0){if(!s)s=o(t.shape);if(m=s(m,d),!u)return m;return Ep([],f,m,d,p,e)}return n(m,d)}});function Jd(e,t,n,r){for(let s of e)if(s.issues.length===0)return t.value=s.value,t;let o=e.filter((s)=>!dn(s));if(o.length===1)return t.value=o[0].value,o[0];return t.issues.push({code:\"invalid_union\",input:t.value,inst:n,errors:e.map((s)=>s.issues.map((i)=>Ke(i,r,We())))}),t}var Vi=b(\"$ZodUnion\",(e,t)=>{te.init(e,t),J(e._zod,\"optin\",()=>t.options.some((r)=>r._zod.optin===\"optional\")?\"optional\":void 0),J(e._zod,\"optout\",()=>t.options.some((r)=>r._zod.optout===\"optional\")?\"optional\":void 0),J(e._zod,\"values\",()=>{if(t.options.every((r)=>r._zod.values))return new Set(t.options.flatMap((r)=>Array.from(r._zod.values)));return}),J(e._zod,\"pattern\",()=>{if(t.options.every((r)=>r._zod.pattern)){let r=t.options.map((o)=>o._zod.pattern);return new RegExp(`^(${r.map((o)=>_o(o.source)).join(\"|\")})$`)}return});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,o)=>{if(n)return n(r,o);let s=!1,i=[];for(let a of t.options){let c=a._zod.run({value:r.value,issues:[]},o);if(c instanceof Promise)i.push(c),s=!0;else{if(c.issues.length===0)return c;i.push(c)}}if(!s)return Jd(i,r,e,o);return Promise.all(i).then((a)=>Jd(a,r,e,o))}});var Op=b(\"$ZodDiscriminatedUnion\",(e,t)=>{t.inclusive=!1,Vi.init(e,t);let n=e._zod.parse;J(e._zod,\"propValues\",()=>{let o={};for(let s of t.options){let i=s._zod.propValues;if(!i||Object.keys(i).length===0)throw Error(`Invalid discriminated union option at index \"${t.options.indexOf(s)}\"`);for(let[a,c]of Object.entries(i)){if(!o[a])o[a]=new Set;for(let l of c)o[a].add(l)}}return o});let r=Tr(()=>{let o=t.options,s=new Map;for(let i of o){let a=i._zod.propValues?.[t.discriminator];if(!a||a.size===0)throw Error(`Invalid discriminated union option at index \"${t.options.indexOf(i)}\"`);for(let c of a){if(s.has(c))throw Error(`Duplicate discriminator value \"${String(c)}\"`);s.set(c,i)}}return s});e._zod.parse=(o,s)=>{let i=o.value;if(!Mn(i))return o.issues.push({code:\"invalid_type\",expected:\"object\",input:i,inst:e}),o;let a=r.value.get(i?.[t.discriminator]);if(a)return a._zod.run(o,s);if(t.unionFallback||s.direction===\"backward\")return n(o,s);return o.issues.push({code:\"invalid_union\",errors:[],note:\"No matching discriminator\",discriminator:t.discriminator,options:Array.from(r.value.keys()),input:i,path:[t.discriminator],inst:e}),o}}),$p=b(\"$ZodIntersection\",(e,t)=>{te.init(e,t),e._zod.parse=(n,r)=>{let o=n.value,s=t.left._zod.run({value:o,issues:[]},r),i=t.right._zod.run({value:o,issues:[]},r);if(s instanceof Promise||i instanceof Promise)return Promise.all([s,i]).then(([c,l])=>Wd(n,c,l));return Wd(n,s,i)}});function Gi(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e===+t)return{valid:!0,data:e};if(un(e)&&un(t)){let n=Object.keys(t),r=Object.keys(e).filter((s)=>n.indexOf(s)!==-1),o={...e,...t};for(let s of r){let i=Gi(e[s],t[s]);if(!i.valid)return{valid:!1,mergeErrorPath:[s,...i.mergeErrorPath]};o[s]=i.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let o=e[r],s=t[r],i=Gi(o,s);if(!i.valid)return{valid:!1,mergeErrorPath:[r,...i.mergeErrorPath]};n.push(i.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Wd(e,t,n){let r=new Map,o;for(let a of t.issues)if(a.code===\"unrecognized_keys\"){o??(o=a);for(let c of a.keys){if(!r.has(c))r.set(c,{});r.get(c).l=!0}}else e.issues.push(a);for(let a of n.issues)if(a.code===\"unrecognized_keys\")for(let c of a.keys){if(!r.has(c))r.set(c,{});r.get(c).r=!0}else e.issues.push(a);let s=[...r].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(s.length&&o)e.issues.push({...o,keys:s});if(dn(e))return e;let i=Gi(t.value,n.value);if(!i.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(i.mergeErrorPath)}`);return e.value=i.data,e}var Mp=b(\"$ZodRecord\",(e,t)=>{te.init(e,t),e._zod.parse=(n,r)=>{let o=n.value;if(!un(o))return n.issues.push({expected:\"record\",code:\"invalid_type\",input:o,inst:e}),n;let s=[],i=t.keyType._zod.values;if(i){n.value={};let a=new Set;for(let l of i)if(typeof l===\"string\"||typeof l===\"number\"||typeof l===\"symbol\"){a.add(typeof l===\"number\"?l.toString():l);let u=t.keyType._zod.run({value:l,issues:[]},r);if(u instanceof Promise)throw Error(\"Async schemas not supported in object keys currently\");if(u.issues.length){n.issues.push({code:\"invalid_key\",origin:\"record\",issues:u.issues.map((d)=>Ke(d,r,We())),input:l,path:[l],inst:e});continue}let p=u.value,m=t.valueType._zod.run({value:o[l],issues:[]},r);if(m instanceof Promise)s.push(m.then((d)=>{if(d.issues.length)n.issues.push(...At(l,d.issues));n.value[p]=d.value}));else{if(m.issues.length)n.issues.push(...At(l,m.issues));n.value[p]=m.value}}let c;for(let l in o)if(!a.has(l))c=c??[],c.push(l);if(c&&c.length>0)n.issues.push({code:\"unrecognized_keys\",input:o,inst:e,keys:c})}else{n.value={};for(let a of Reflect.ownKeys(o)){if(a===\"__proto__\")continue;if(!Object.prototype.propertyIsEnumerable.call(o,a))continue;let c=t.keyType._zod.run({value:a,issues:[]},r);if(c instanceof Promise)throw Error(\"Async schemas not supported in object keys currently\");if(typeof a===\"string\"&&Ni.test(a)&&c.issues.length){let p=t.keyType._zod.run({value:Number(a),issues:[]},r);if(p instanceof Promise)throw Error(\"Async schemas not supported in object keys currently\");if(p.issues.length===0)c=p}if(c.issues.length){if(t.mode===\"loose\")n.value[a]=o[a];else n.issues.push({code:\"invalid_key\",origin:\"record\",issues:c.issues.map((p)=>Ke(p,r,We())),input:a,path:[a],inst:e});continue}let u=t.valueType._zod.run({value:o[a],issues:[]},r);if(u instanceof Promise)s.push(u.then((p)=>{if(p.issues.length)n.issues.push(...At(a,p.issues));n.value[c.value]=p.value}));else{if(u.issues.length)n.issues.push(...At(a,u.issues));n.value[c.value]=u.value}}}if(s.length)return Promise.all(s).then(()=>n);return n}});var qp=b(\"$ZodEnum\",(e,t)=>{te.init(e,t);let n=bo(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter((o)=>Du.has(typeof o)).map((o)=>typeof o===\"string\"?Tt(o):o.toString()).join(\"|\")})$`),e._zod.parse=(o,s)=>{let i=o.value;if(r.has(i))return o;return o.issues.push({code:\"invalid_value\",values:n,input:i,inst:e}),o}}),zp=b(\"$ZodLiteral\",(e,t)=>{if(te.init(e,t),t.values.length===0)throw Error(\"Cannot create literal schema with no valid values\");let n=new Set(t.values);e._zod.values=n,e._zod.pattern=new RegExp(`^(${t.values.map((r)=>typeof r===\"string\"?Tt(r):r?Tt(r.toString()):String(r)).join(\"|\")})$`),e._zod.parse=(r,o)=>{let s=r.value;if(n.has(s))return r;return r.issues.push({code:\"invalid_value\",values:t.values,input:s,inst:e}),r}});var jp=b(\"$ZodTransform\",(e,t)=>{te.init(e,t),e._zod.optin=\"optional\",e._zod.parse=(n,r)=>{if(r.direction===\"backward\")throw new kr(e.constructor.name);let o=t.transform(n.value,n);if(r.async)return(o instanceof Promise?o:Promise.resolve(o)).then((i)=>(n.value=i,n.fallback=!0,n));if(o instanceof Promise)throw new bt;return n.value=o,n.fallback=!0,n}});function Kd(e,t){if(t===void 0&&(e.issues.length||e.fallback))return{issues:[],value:void 0};return e}var Fi=b(\"$ZodOptional\",(e,t)=>{te.init(e,t),e._zod.optin=\"optional\",e._zod.optout=\"optional\",J(e._zod,\"values\",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),J(e._zod,\"pattern\",()=>{let n=t.innerType._zod.pattern;return n?new RegExp(`^(${_o(n.source)})?$`):void 0}),e._zod.parse=(n,r)=>{if(t.innerType._zod.optin===\"optional\"){let o=n.value,s=t.innerType._zod.run(n,r);if(s instanceof Promise)return s.then((i)=>Kd(i,o));return Kd(s,o)}if(n.value===void 0)return n;return t.innerType._zod.run(n,r)}}),Np=b(\"$ZodExactOptional\",(e,t)=>{Fi.init(e,t),J(e._zod,\"values\",()=>t.innerType._zod.values),J(e._zod,\"pattern\",()=>t.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),Dp=b(\"$ZodNullable\",(e,t)=>{te.init(e,t),J(e._zod,\"optin\",()=>t.innerType._zod.optin),J(e._zod,\"optout\",()=>t.innerType._zod.optout),J(e._zod,\"pattern\",()=>{let n=t.innerType._zod.pattern;return n?new RegExp(`^(${_o(n.source)}|null)$`):void 0}),J(e._zod,\"values\",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,r)=>{if(n.value===null)return n;return t.innerType._zod.run(n,r)}}),Up=b(\"$ZodDefault\",(e,t)=>{te.init(e,t),e._zod.optin=\"optional\",J(e._zod,\"values\",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction===\"backward\")return t.innerType._zod.run(n,r);if(n.value===void 0)return n.value=t.defaultValue,n;let o=t.innerType._zod.run(n,r);if(o instanceof Promise)return o.then((s)=>Hd(s,t));return Hd(o,t)}});function Hd(e,t){if(e.value===void 0)e.value=t.defaultValue;return e}var Lp=b(\"$ZodPrefault\",(e,t)=>{te.init(e,t),e._zod.optin=\"optional\",J(e._zod,\"values\",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction===\"backward\")return t.innerType._zod.run(n,r);if(n.value===void 0)n.value=t.defaultValue;return t.innerType._zod.run(n,r)}}),Gp=b(\"$ZodNonOptional\",(e,t)=>{te.init(e,t),J(e._zod,\"values\",()=>{let n=t.innerType._zod.values;return n?new Set([...n].filter((r)=>r!==void 0)):void 0}),e._zod.parse=(n,r)=>{let o=t.innerType._zod.run(n,r);if(o instanceof Promise)return o.then((s)=>Zd(s,e));return Zd(o,e)}});function Zd(e,t){if(!e.issues.length&&e.value===void 0)e.issues.push({code:\"invalid_type\",expected:\"nonoptional\",input:e.value,inst:t});return e}var Bp=b(\"$ZodCatch\",(e,t)=>{te.init(e,t),e._zod.optin=\"optional\",J(e._zod,\"optout\",()=>t.innerType._zod.optout),J(e._zod,\"values\",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction===\"backward\")return t.innerType._zod.run(n,r);let o=t.innerType._zod.run(n,r);if(o instanceof Promise)return o.then((s)=>{if(n.value=s.value,s.issues.length)n.value=t.catchValue({...n,error:{issues:s.issues.map((i)=>Ke(i,r,We()))},input:n.value}),n.issues=[],n.fallback=!0;return n});if(n.value=o.value,o.issues.length)n.value=t.catchValue({...n,error:{issues:o.issues.map((s)=>Ke(s,r,We()))},input:n.value}),n.issues=[],n.fallback=!0;return n}});var Ji=b(\"$ZodPipe\",(e,t)=>{te.init(e,t),J(e._zod,\"values\",()=>t.in._zod.values),J(e._zod,\"optin\",()=>t.in._zod.optin),J(e._zod,\"optout\",()=>t.out._zod.optout),J(e._zod,\"propValues\",()=>t.in._zod.propValues),e._zod.parse=(n,r)=>{if(r.direction===\"backward\"){let s=t.out._zod.run(n,r);if(s instanceof Promise)return s.then((i)=>Ro(i,t.in,r));return Ro(s,t.in,r)}let o=t.in._zod.run(n,r);if(o instanceof Promise)return o.then((s)=>Ro(s,t.out,r));return Ro(o,t.out,r)}});function Ro(e,t,n){if(e.issues.length)return e.aborted=!0,e;return t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}var Vp=b(\"$ZodPreprocess\",(e,t)=>{Ji.init(e,t)}),Fp=b(\"$ZodReadonly\",(e,t)=>{te.init(e,t),J(e._zod,\"propValues\",()=>t.innerType._zod.propValues),J(e._zod,\"values\",()=>t.innerType._zod.values),J(e._zod,\"optin\",()=>t.innerType?._zod?.optin),J(e._zod,\"optout\",()=>t.innerType?._zod?.optout),e._zod.parse=(n,r)=>{if(r.direction===\"backward\")return t.innerType._zod.run(n,r);let o=t.innerType._zod.run(n,r);if(o instanceof Promise)return o.then(Yd);return Yd(o)}});function Yd(e){return e.value=Object.freeze(e.value),e}var Jp=b(\"$ZodLazy\",(e,t)=>{te.init(e,t),J(e._zod,\"innerType\",()=>{let n=t;if(!n._cachedInner)n._cachedInner=t.getter();return n._cachedInner}),J(e._zod,\"pattern\",()=>e._zod.innerType?._zod?.pattern),J(e._zod,\"propValues\",()=>e._zod.innerType?._zod?.propValues),J(e._zod,\"optin\",()=>e._zod.innerType?._zod?.optin??void 0),J(e._zod,\"optout\",()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(n,r)=>e._zod.innerType._zod.run(n,r)}),Wp=b(\"$ZodCustom\",(e,t)=>{we.init(e,t),te.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=(n)=>{let r=n.value,o=t.fn(r);if(o instanceof Promise)return o.then((s)=>Xd(s,n,r,e));Xd(o,n,r,e);return}});function Xd(e,t,n,r){if(!e){let o={code:\"custom\",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};if(r._zod.def.params)o.params=r._zod.def.params;t.issues.push(pn(o))}}var Kp,xB=Symbol(\"ZodOutput\"),SB=Symbol(\"ZodInput\");class Hp{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];if(this._map.set(e,n),n&&typeof n===\"object\"&&\"id\"in n)this._idmap.set(n.id,e);return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);if(t&&typeof t===\"object\"&&\"id\"in t)this._idmap.delete(t.id);return this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function jT(){return new Hp}(Kp=globalThis).__zod_globalRegistry??(Kp.__zod_globalRegistry=jT());var mn=globalThis.__zod_globalRegistry;function Zp(e,t){return new e({type:\"string\",...P(t)})}function Yp(e,t){return new e({type:\"string\",format:\"email\",check:\"string_format\",abort:!1,...P(t)})}function Wi(e,t){return new e({type:\"string\",format:\"guid\",check:\"string_format\",abort:!1,...P(t)})}function Xp(e,t){return new e({type:\"string\",format:\"uuid\",check:\"string_format\",abort:!1,...P(t)})}function Qp(e,t){return new e({type:\"string\",format:\"uuid\",check:\"string_format\",abort:!1,version:\"v4\",...P(t)})}function em(e,t){return new e({type:\"string\",format:\"uuid\",check:\"string_format\",abort:!1,version:\"v6\",...P(t)})}function tm(e,t){return new e({type:\"string\",format:\"uuid\",check:\"string_format\",abort:!1,version:\"v7\",...P(t)})}function nm(e,t){return new e({type:\"string\",format:\"url\",check:\"string_format\",abort:!1,...P(t)})}function rm(e,t){return new e({type:\"string\",format:\"emoji\",check:\"string_format\",abort:!1,...P(t)})}function om(e,t){return new e({type:\"string\",format:\"nanoid\",check:\"string_format\",abort:!1,...P(t)})}function sm(e,t){return new e({type:\"string\",format:\"cuid\",check:\"string_format\",abort:!1,...P(t)})}function im(e,t){return new e({type:\"string\",format:\"cuid2\",check:\"string_format\",abort:!1,...P(t)})}function am(e,t){return new e({type:\"string\",format:\"ulid\",check:\"string_format\",abort:!1,...P(t)})}function cm(e,t){return new e({type:\"string\",format:\"xid\",check:\"string_format\",abort:!1,...P(t)})}function lm(e,t){return new e({type:\"string\",format:\"ksuid\",check:\"string_format\",abort:!1,...P(t)})}function um(e,t){return new e({type:\"string\",format:\"ipv4\",check:\"string_format\",abort:!1,...P(t)})}function dm(e,t){return new e({type:\"string\",format:\"ipv6\",check:\"string_format\",abort:!1,...P(t)})}function pm(e,t){return new e({type:\"string\",format:\"cidrv4\",check:\"string_format\",abort:!1,...P(t)})}function mm(e,t){return new e({type:\"string\",format:\"cidrv6\",check:\"string_format\",abort:!1,...P(t)})}function fm(e,t){return new e({type:\"string\",format:\"base64\",check:\"string_format\",abort:!1,...P(t)})}function gm(e,t){return new e({type:\"string\",format:\"base64url\",check:\"string_format\",abort:!1,...P(t)})}function hm(e,t){return new e({type:\"string\",format:\"e164\",check:\"string_format\",abort:!1,...P(t)})}function ym(e,t){return new e({type:\"string\",format:\"jwt\",check:\"string_format\",abort:!1,...P(t)})}function bm(e,t){return new e({type:\"string\",format:\"datetime\",check:\"string_format\",offset:!1,local:!1,precision:null,...P(t)})}function vm(e,t){return new e({type:\"string\",format:\"date\",check:\"string_format\",...P(t)})}function _m(e,t){return new e({type:\"string\",format:\"time\",check:\"string_format\",precision:null,...P(t)})}function wm(e,t){return new e({type:\"string\",format:\"duration\",check:\"string_format\",...P(t)})}function xm(e,t){return new e({type:\"number\",checks:[],...P(t)})}function Sm(e,t){return new e({type:\"number\",check:\"number_format\",abort:!1,format:\"safeint\",...P(t)})}function Im(e,t){return new e({type:\"boolean\",...P(t)})}function km(e,t){return new e({type:\"null\",...P(t)})}function Rm(e){return new e({type:\"unknown\"})}function Tm(e,t){return new e({type:\"never\",...P(t)})}function Co(e,t){return new Di({check:\"less_than\",...P(t),value:e,inclusive:!1})}function Pr(e,t){return new Di({check:\"less_than\",...P(t),value:e,inclusive:!0})}function Eo(e,t){return new Ui({check:\"greater_than\",...P(t),value:e,inclusive:!1})}function Or(e,t){return new Ui({check:\"greater_than\",...P(t),value:e,inclusive:!0})}function Po(e,t){return new Pd({check:\"multiple_of\",...P(t),value:e})}function Oo(e,t){return new $d({check:\"max_length\",...P(t),maximum:e})}function qn(e,t){return new Md({check:\"min_length\",...P(t),minimum:e})}function $o(e,t){return new qd({check:\"length_equals\",...P(t),length:e})}function Ki(e,t){return new zd({check:\"string_format\",format:\"regex\",...P(t),pattern:e})}function Hi(e){return new jd({check:\"string_format\",format:\"lowercase\",...P(e)})}function Zi(e){return new Nd({check:\"string_format\",format:\"uppercase\",...P(e)})}function Yi(e,t){return new Dd({check:\"string_format\",format:\"includes\",...P(t),includes:e})}function Xi(e,t){return new Ud({check:\"string_format\",format:\"starts_with\",...P(t),prefix:e})}function Qi(e,t){return new Ld({check:\"string_format\",format:\"ends_with\",...P(t),suffix:e})}function Et(e){return new Gd({check:\"overwrite\",tx:e})}function ea(e){return Et((t)=>t.normalize(e))}function ta(){return Et((e)=>e.trim())}function na(){return Et((e)=>e.toLowerCase())}function ra(){return Et((e)=>e.toUpperCase())}function oa(){return Et((e)=>ju(e))}function Am(e,t,n){return new e({type:\"array\",element:t,...P(n)})}function Cm(e,t,n){return new e({type:\"custom\",check:\"custom\",fn:t,...P(n)})}function Em(e,t){let n=NT((r)=>(r.addIssue=(o)=>{if(typeof o===\"string\")r.issues.push(pn(o,r.value,n._zod.def));else{let s=o;if(s.fatal)s.continue=!1;s.code??(s.code=\"custom\"),s.input??(s.input=r.value),s.inst??(s.inst=n),s.continue??(s.continue=!n._zod.def.abort),r.issues.push(pn(s))}},e(r.value,r)),t);return n}function NT(e,t){let n=new we({check:\"custom\",...P(t)});return n._zod.check=e,n}function sa(e){let t=e?.target??\"draft-2020-12\";if(t===\"draft-4\")t=\"draft-04\";if(t===\"draft-7\")t=\"draft-07\";return{processors:e.processors??{},metadataRegistry:e?.metadata??mn,target:t,unrepresentable:e?.unrepresentable??\"throw\",override:e?.override??(()=>{}),io:e?.io??\"output\",counter:0,seen:new Map,cycles:e?.cycles??\"ref\",reused:e?.reused??\"inline\",external:e?.external??void 0}}function le(e,t,n={path:[],schemaPath:[]}){var r;let o=e._zod.def,s=t.seen.get(e);if(s){if(s.count++,n.schemaPath.includes(e))s.cycle=n.path;return s.schema}let i={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,i);let a=e._zod.toJSONSchema?.();if(a)i.schema=a;else{let u={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,i.schema,u);else{let m=i.schema,d=t.processors[o.type];if(!d)throw Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);d(e,t,m,u)}let p=e._zod.parent;if(p){if(!i.ref)i.ref=p;le(p,t,u),t.seen.get(p).isParent=!0}}let c=t.metadataRegistry.get(e);if(c)Object.assign(i.schema,c);if(t.io===\"input\"&&ke(e))delete i.schema.examples,delete i.schema.default;if(t.io===\"input\"&&\"_prefault\"in i.schema)(r=i.schema).default??(r.default=i.schema._prefault);return delete i.schema._prefault,t.seen.get(e).schema}function ia(e,t){let n=e.seen.get(t);if(!n)throw Error(\"Unprocessed schema. This is a bug in Zod.\");let r=new Map;for(let i of e.seen.entries()){let a=e.metadataRegistry.get(i[0])?.id;if(a){let c=r.get(a);if(c&&c!==i[0])throw Error(`Duplicate schema id \"${a}\" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(a,i[0])}}let o=(i)=>{let a=e.target===\"draft-2020-12\"?\"$defs\":\"definitions\";if(e.external){let p=e.external.registry.get(i[0])?.id,m=e.external.uri??((f)=>f);if(p)return{ref:m(p)};let d=i[1].defId??i[1].schema.id??`schema${e.counter++}`;return i[1].defId=d,{defId:d,ref:`${m(\"__shared\")}#/${a}/${d}`}}if(i[1]===n)return{ref:\"#\"};let l=`${\"#\"}/${a}/`,u=i[1].schema.id??`__schema${e.counter++}`;return{defId:u,ref:l+u}},s=(i)=>{if(i[1].schema.$ref)return;let a=i[1],{ref:c,defId:l}=o(i);if(a.def={...a.schema},l)a.defId=l;let u=a.schema;for(let p in u)delete u[p];u.$ref=c};if(e.cycles===\"throw\")for(let i of e.seen.entries()){let a=i[1];if(a.cycle)throw Error(`Cycle detected: #/${a.cycle?.join(\"/\")}/<root>\n\nSet the \\`cycles\\` parameter to \\`\"ref\"\\` to resolve cyclical schemas with defs.`)}for(let i of e.seen.entries()){let a=i[1];if(t===i[0]){s(i);continue}if(e.external){let l=e.external.registry.get(i[0])?.id;if(t!==i[0]&&l){s(i);continue}}if(e.metadataRegistry.get(i[0])?.id){s(i);continue}if(a.cycle){s(i);continue}if(a.count>1){if(e.reused===\"ref\"){s(i);continue}}}}function aa(e,t){let n=e.seen.get(t);if(!n)throw Error(\"Unprocessed schema. This is a bug in Zod.\");let r=(a)=>{let c=e.seen.get(a);if(c.ref===null)return;let l=c.def??c.schema,u={...l},p=c.ref;if(c.ref=null,p){r(p);let d=e.seen.get(p),f=d.schema;if(f.$ref&&(e.target===\"draft-07\"||e.target===\"draft-04\"||e.target===\"openapi-3.0\"))l.allOf=l.allOf??[],l.allOf.push(f);else Object.assign(l,f);if(Object.assign(l,u),a._zod.parent===p)for(let y in l){if(y===\"$ref\"||y===\"allOf\")continue;if(!(y in u))delete l[y]}if(f.$ref&&d.def)for(let y in l){if(y===\"$ref\"||y===\"allOf\")continue;if(y in d.def&&JSON.stringify(l[y])===JSON.stringify(d.def[y]))delete l[y]}}let m=a._zod.parent;if(m&&m!==p){r(m);let d=e.seen.get(m);if(d?.schema.$ref){if(l.$ref=d.schema.$ref,d.def)for(let f in l){if(f===\"$ref\"||f===\"allOf\")continue;if(f in d.def&&JSON.stringify(l[f])===JSON.stringify(d.def[f]))delete l[f]}}}e.override({zodSchema:a,jsonSchema:l,path:c.path??[]})};for(let a of[...e.seen.entries()].reverse())r(a[0]);let o={};if(e.target===\"draft-2020-12\")o.$schema=\"https://json-schema.org/draft/2020-12/schema\";else if(e.target===\"draft-07\")o.$schema=\"http://json-schema.org/draft-07/schema#\";else if(e.target===\"draft-04\")o.$schema=\"http://json-schema.org/draft-04/schema#\";else if(e.target===\"openapi-3.0\");if(e.external?.uri){let a=e.external.registry.get(t)?.id;if(!a)throw Error(\"Schema is missing an `id` property\");o.$id=e.external.uri(a)}Object.assign(o,n.def??n.schema);let s=e.metadataRegistry.get(t)?.id;if(s!==void 0&&o.id===s)delete o.id;let i=e.external?.defs??{};for(let a of e.seen.entries()){let c=a[1];if(c.def&&c.defId){if(c.def.id===c.defId)delete c.def.id;i[c.defId]=c.def}}if(e.external);else if(Object.keys(i).length>0)if(e.target===\"draft-2020-12\")o.$defs=i;else o.definitions=i;try{let a=JSON.parse(JSON.stringify(o));return Object.defineProperty(a,\"~standard\",{value:{...t[\"~standard\"],jsonSchema:{input:$r(t,\"input\",e.processors),output:$r(t,\"output\",e.processors)}},enumerable:!1,writable:!1}),a}catch(a){throw Error(\"Error converting schema to JSON.\")}}function ke(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===\"transform\")return!0;if(r.type===\"array\")return ke(r.element,n);if(r.type===\"set\")return ke(r.valueType,n);if(r.type===\"lazy\")return ke(r.getter(),n);if(r.type===\"promise\"||r.type===\"optional\"||r.type===\"nonoptional\"||r.type===\"nullable\"||r.type===\"readonly\"||r.type===\"default\"||r.type===\"prefault\")return ke(r.innerType,n);if(r.type===\"intersection\")return ke(r.left,n)||ke(r.right,n);if(r.type===\"record\"||r.type===\"map\")return ke(r.keyType,n)||ke(r.valueType,n);if(r.type===\"pipe\"){if(e._zod.traits.has(\"$ZodCodec\"))return!0;return ke(r.in,n)||ke(r.out,n)}if(r.type===\"object\"){for(let o in r.shape)if(ke(r.shape[o],n))return!0;return!1}if(r.type===\"union\"){for(let o of r.options)if(ke(o,n))return!0;return!1}if(r.type===\"tuple\"){for(let o of r.items)if(ke(o,n))return!0;if(r.rest&&ke(r.rest,n))return!0;return!1}return!1}var Pm=(e,t={})=>(n)=>{let r=sa({...n,processors:t});return le(e,r),ia(r,e),aa(r,e)},$r=(e,t,n={})=>(r)=>{let{libraryOptions:o,target:s}=r??{},i=sa({...o??{},target:s,io:t,processors:n});return le(e,i),ia(i,e),aa(i,e)};var DT={guid:\"uuid\",url:\"uri\",datetime:\"date-time\",json_string:\"json-string\",regex:\"\"},Om=(e,t,n,r)=>{let o=n;o.type=\"string\";let{minimum:s,maximum:i,format:a,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof s===\"number\")o.minLength=s;if(typeof i===\"number\")o.maxLength=i;if(a){if(o.format=DT[a]??a,o.format===\"\")delete o.format;if(a===\"time\")delete o.format}if(l)o.contentEncoding=l;if(c&&c.size>0){let u=[...c];if(u.length===1)o.pattern=u[0].source;else if(u.length>1)o.allOf=[...u.map((p)=>({...t.target===\"draft-07\"||t.target===\"draft-04\"||t.target===\"openapi-3.0\"?{type:\"string\"}:{},pattern:p.source}))]}},$m=(e,t,n,r)=>{let o=n,{minimum:s,maximum:i,format:a,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;if(typeof a===\"string\"&&a.includes(\"int\"))o.type=\"integer\";else o.type=\"number\";let p=typeof u===\"number\"&&u>=(s??Number.NEGATIVE_INFINITY),m=typeof l===\"number\"&&l<=(i??Number.POSITIVE_INFINITY),d=t.target===\"draft-04\"||t.target===\"openapi-3.0\";if(p)if(d)o.minimum=u,o.exclusiveMinimum=!0;else o.exclusiveMinimum=u;else if(typeof s===\"number\")o.minimum=s;if(m)if(d)o.maximum=l,o.exclusiveMaximum=!0;else o.exclusiveMaximum=l;else if(typeof i===\"number\")o.maximum=i;if(typeof c===\"number\")o.multipleOf=c},Mm=(e,t,n,r)=>{n.type=\"boolean\"};var qm=(e,t,n,r)=>{if(t.target===\"openapi-3.0\")n.type=\"string\",n.nullable=!0,n.enum=[null];else n.type=\"null\"};var zm=(e,t,n,r)=>{n.not={}};var jm=(e,t,n,r)=>{};var Nm=(e,t,n,r)=>{let o=e._zod.def,s=bo(o.entries);if(s.every((i)=>typeof i===\"number\"))n.type=\"number\";if(s.every((i)=>typeof i===\"string\"))n.type=\"string\";n.enum=s},Dm=(e,t,n,r)=>{let o=e._zod.def,s=[];for(let i of o.values)if(i===void 0){if(t.unrepresentable===\"throw\")throw Error(\"Literal `undefined` cannot be represented in JSON Schema\")}else if(typeof i===\"bigint\")if(t.unrepresentable===\"throw\")throw Error(\"BigInt literals cannot be represented in JSON Schema\");else s.push(Number(i));else s.push(i);if(s.length===0);else if(s.length===1){let i=s[0];if(n.type=i===null?\"null\":typeof i,t.target===\"draft-04\"||t.target===\"openapi-3.0\")n.enum=[i];else n.const=i}else{if(s.every((i)=>typeof i===\"number\"))n.type=\"number\";if(s.every((i)=>typeof i===\"string\"))n.type=\"string\";if(s.every((i)=>typeof i===\"boolean\"))n.type=\"boolean\";if(s.every((i)=>i===null))n.type=\"null\";n.enum=s}};var Um=(e,t,n,r)=>{if(t.unrepresentable===\"throw\")throw Error(\"Custom types cannot be represented in JSON Schema\")};var Lm=(e,t,n,r)=>{if(t.unrepresentable===\"throw\")throw Error(\"Transforms cannot be represented in JSON Schema\")};var Gm=(e,t,n,r)=>{let o=n,s=e._zod.def,{minimum:i,maximum:a}=e._zod.bag;if(typeof i===\"number\")o.minItems=i;if(typeof a===\"number\")o.maxItems=a;o.type=\"array\",o.items=le(s.element,t,{...r,path:[...r.path,\"items\"]})},Bm=(e,t,n,r)=>{let o=n,s=e._zod.def;o.type=\"object\",o.properties={};let i=s.shape;for(let l in i)o.properties[l]=le(i[l],t,{...r,path:[...r.path,\"properties\",l]});let a=new Set(Object.keys(i)),c=new Set([...a].filter((l)=>{let u=s.shape[l]._zod;if(t.io===\"input\")return u.optin===void 0;else return u.optout===void 0}));if(c.size>0)o.required=Array.from(c);if(s.catchall?._zod.def.type===\"never\")o.additionalProperties=!1;else if(!s.catchall){if(t.io===\"output\")o.additionalProperties=!1}else if(s.catchall)o.additionalProperties=le(s.catchall,t,{...r,path:[...r.path,\"additionalProperties\"]})},Vm=(e,t,n,r)=>{let o=e._zod.def,s=o.inclusive===!1,i=o.options.map((a,c)=>le(a,t,{...r,path:[...r.path,s?\"oneOf\":\"anyOf\",c]}));if(s)n.oneOf=i;else n.anyOf=i},Fm=(e,t,n,r)=>{let o=e._zod.def,s=le(o.left,t,{...r,path:[...r.path,\"allOf\",0]}),i=le(o.right,t,{...r,path:[...r.path,\"allOf\",1]}),a=(l)=>(\"allOf\"in l)&&Object.keys(l).length===1,c=[...a(s)?s.allOf:[s],...a(i)?i.allOf:[i]];n.allOf=c};var Jm=(e,t,n,r)=>{let o=n,s=e._zod.def;o.type=\"object\";let i=s.keyType,c=i._zod.bag?.patterns;if(s.mode===\"loose\"&&c&&c.size>0){let u=le(s.valueType,t,{...r,path:[...r.path,\"patternProperties\",\"*\"]});o.patternProperties={};for(let p of c)o.patternProperties[p.source]=u}else{if(t.target===\"draft-07\"||t.target===\"draft-2020-12\")o.propertyNames=le(s.keyType,t,{...r,path:[...r.path,\"propertyNames\"]});o.additionalProperties=le(s.valueType,t,{...r,path:[...r.path,\"additionalProperties\"]})}let l=i._zod.values;if(l){let u=[...l].filter((p)=>typeof p===\"string\"||typeof p===\"number\");if(u.length>0)o.required=u}},Wm=(e,t,n,r)=>{let o=e._zod.def,s=le(o.innerType,t,r),i=t.seen.get(e);if(t.target===\"openapi-3.0\")i.ref=o.innerType,n.nullable=!0;else n.anyOf=[s,{type:\"null\"}]},Km=(e,t,n,r)=>{let o=e._zod.def;le(o.innerType,t,r);let s=t.seen.get(e);s.ref=o.innerType},Hm=(e,t,n,r)=>{let o=e._zod.def;le(o.innerType,t,r);let s=t.seen.get(e);s.ref=o.innerType,n.default=JSON.parse(JSON.stringify(o.defaultValue))},Zm=(e,t,n,r)=>{let o=e._zod.def;le(o.innerType,t,r);let s=t.seen.get(e);if(s.ref=o.innerType,t.io===\"input\")n._prefault=JSON.parse(JSON.stringify(o.defaultValue))},Ym=(e,t,n,r)=>{let o=e._zod.def;le(o.innerType,t,r);let s=t.seen.get(e);s.ref=o.innerType;let i;try{i=o.catchValue(void 0)}catch{throw Error(\"Dynamic catch values are not supported in JSON Schema\")}n.default=i},Xm=(e,t,n,r)=>{let o=e._zod.def,s=o.in._zod.traits.has(\"$ZodTransform\"),i=t.io===\"input\"?s?o.out:o.in:o.out;le(i,t,r);let a=t.seen.get(e);a.ref=i},Qm=(e,t,n,r)=>{let o=e._zod.def;le(o.innerType,t,r);let s=t.seen.get(e);s.ref=o.innerType,n.readOnly=!0};var ca=(e,t,n,r)=>{let o=e._zod.def;le(o.innerType,t,r);let s=t.seen.get(e);s.ref=o.innerType},ef=(e,t,n,r)=>{let o=e._zod.innerType;le(o,t,r);let s=t.seen.get(e);s.ref=o};var JT=b(\"ZodISODateTime\",(e,t)=>{up.init(e,t),se.init(e,t)});function tf(e){return bm(JT,e)}var WT=b(\"ZodISODate\",(e,t)=>{dp.init(e,t),se.init(e,t)});function nf(e){return vm(WT,e)}var KT=b(\"ZodISOTime\",(e,t)=>{pp.init(e,t),se.init(e,t)});function rf(e){return _m(KT,e)}var HT=b(\"ZodISODuration\",(e,t)=>{mp.init(e,t),se.init(e,t)});function of(e){return wm(HT,e)}var XT=(e,t)=>{xo.init(e,t),e.name=\"ZodError\",Object.defineProperties(e,{format:{value:(n)=>Fu(e,n)},flatten:{value:(n)=>Vu(e,n)},addIssue:{value:(n)=>{e.issues.push(n),e.message=JSON.stringify(e.issues,Rr,2)}},addIssues:{value:(n)=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,Rr,2)}},isEmpty:{get(){return e.issues.length===0}}})};var ze=b(\"ZodError\",XT,{Parent:Error});var sf=So(ze),af=Io(ze),cf=Ar(ze),lf=Cr(ze),uf=Ku(ze),df=Hu(ze),pf=Zu(ze),mf=Yu(ze),ff=Xu(ze),gf=Qu(ze),hf=ed(ze),yf=td(ze);var bf=new WeakMap;function Mr(e,t,n){let r=Object.getPrototypeOf(e),o=bf.get(r);if(!o)o=new Set,bf.set(r,o);if(o.has(t))return;o.add(t);for(let s in n){let i=n[s];Object.defineProperty(r,s,{configurable:!0,enumerable:!1,get(){let a=i.bind(this);return Object.defineProperty(this,s,{configurable:!0,writable:!0,enumerable:!0,value:a}),a},set(a){Object.defineProperty(this,s,{configurable:!0,writable:!0,enumerable:!0,value:a})}})}}var re=b(\"ZodType\",(e,t)=>(te.init(e,t),Object.assign(e[\"~standard\"],{jsonSchema:{input:$r(e,\"input\"),output:$r(e,\"output\")}}),e.toJSONSchema=Pm(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,\"_def\",{value:t}),e.parse=(n,r)=>sf(e,n,r,{callee:e.parse}),e.safeParse=(n,r)=>cf(e,n,r),e.parseAsync=async(n,r)=>af(e,n,r,{callee:e.parseAsync}),e.safeParseAsync=async(n,r)=>lf(e,n,r),e.spa=e.safeParseAsync,e.encode=(n,r)=>uf(e,n,r),e.decode=(n,r)=>df(e,n,r),e.encodeAsync=async(n,r)=>pf(e,n,r),e.decodeAsync=async(n,r)=>mf(e,n,r),e.safeEncode=(n,r)=>ff(e,n,r),e.safeDecode=(n,r)=>gf(e,n,r),e.safeEncodeAsync=async(n,r)=>hf(e,n,r),e.safeDecodeAsync=async(n,r)=>yf(e,n,r),Mr(e,\"ZodType\",{check(...n){let r=this.def;return this.clone(Rt(r,{checks:[...r.checks??[],...n.map((o)=>typeof o===\"function\"?{_zod:{check:o,def:{check:\"custom\"},onattach:[]}}:o)]}),{parent:!0})},with(...n){return this.check(...n)},clone(n,r){return Xe(this,n,r)},brand(){return this},register(n,r){return n.add(this,r),this},refine(n,r){return this.check(WA(n,r))},superRefine(n,r){return this.check(KA(n,r))},overwrite(n){return this.check(Et(n))},optional(){return xf(this)},exactOptional(){return $A(this)},nullable(){return Sf(this)},nullish(){return xf(Sf(this))},nonoptional(n){return DA(this,n)},array(){return ge(this)},or(n){return zn([this,n])},and(n){return CA(this,n)},transform(n){return If(this,Cf(n))},default(n){return zA(this,n)},prefault(n){return NA(this,n)},catch(n){return LA(this,n)},pipe(n){return If(this,n)},readonly(){return VA(this)},describe(n){let r=this.clone();return mn.add(r,{description:n}),r},meta(...n){if(n.length===0)return mn.get(this);let r=this.clone();return mn.add(r,n[0]),r},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(n){return n(this)}}),Object.defineProperty(e,\"description\",{get(){return mn.get(e)?.description},configurable:!0}),e)),kf=b(\"_ZodString\",(e,t)=>{Ao.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,s)=>Om(e,r,o,s);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,Mr(e,\"_ZodString\",{regex(...r){return this.check(Ki(...r))},includes(...r){return this.check(Yi(...r))},startsWith(...r){return this.check(Xi(...r))},endsWith(...r){return this.check(Qi(...r))},min(...r){return this.check(qn(...r))},max(...r){return this.check(Oo(...r))},length(...r){return this.check($o(...r))},nonempty(...r){return this.check(qn(1,...r))},lowercase(r){return this.check(Hi(r))},uppercase(r){return this.check(Zi(r))},trim(){return this.check(ta())},normalize(...r){return this.check(ea(...r))},toLowerCase(){return this.check(na())},toUpperCase(){return this.check(ra())},slugify(){return this.check(oa())}})}),eA=b(\"ZodString\",(e,t)=>{Ao.init(e,t),kf.init(e,t),e.email=(n)=>e.check(Yp(tA,n)),e.url=(n)=>e.check(nm(nA,n)),e.jwt=(n)=>e.check(ym(yA,n)),e.emoji=(n)=>e.check(rm(rA,n)),e.guid=(n)=>e.check(Wi(vf,n)),e.uuid=(n)=>e.check(Xp(qo,n)),e.uuidv4=(n)=>e.check(Qp(qo,n)),e.uuidv6=(n)=>e.check(em(qo,n)),e.uuidv7=(n)=>e.check(tm(qo,n)),e.nanoid=(n)=>e.check(om(oA,n)),e.guid=(n)=>e.check(Wi(vf,n)),e.cuid=(n)=>e.check(sm(sA,n)),e.cuid2=(n)=>e.check(im(iA,n)),e.ulid=(n)=>e.check(am(aA,n)),e.base64=(n)=>e.check(fm(fA,n)),e.base64url=(n)=>e.check(gm(gA,n)),e.xid=(n)=>e.check(cm(cA,n)),e.ksuid=(n)=>e.check(lm(lA,n)),e.ipv4=(n)=>e.check(um(uA,n)),e.ipv6=(n)=>e.check(dm(dA,n)),e.cidrv4=(n)=>e.check(pm(pA,n)),e.cidrv6=(n)=>e.check(mm(mA,n)),e.e164=(n)=>e.check(hm(hA,n)),e.datetime=(n)=>e.check(tf(n)),e.date=(n)=>e.check(nf(n)),e.time=(n)=>e.check(rf(n)),e.duration=(n)=>e.check(of(n))});function w(e){return Zp(eA,e)}var se=b(\"ZodStringFormat\",(e,t)=>{ne.init(e,t),kf.init(e,t)}),tA=b(\"ZodEmail\",(e,t)=>{tp.init(e,t),se.init(e,t)});var vf=b(\"ZodGUID\",(e,t)=>{Qd.init(e,t),se.init(e,t)});var qo=b(\"ZodUUID\",(e,t)=>{ep.init(e,t),se.init(e,t)});var nA=b(\"ZodURL\",(e,t)=>{np.init(e,t),se.init(e,t)});var rA=b(\"ZodEmoji\",(e,t)=>{rp.init(e,t),se.init(e,t)});var oA=b(\"ZodNanoID\",(e,t)=>{op.init(e,t),se.init(e,t)});var sA=b(\"ZodCUID\",(e,t)=>{sp.init(e,t),se.init(e,t)});var iA=b(\"ZodCUID2\",(e,t)=>{ip.init(e,t),se.init(e,t)});var aA=b(\"ZodULID\",(e,t)=>{ap.init(e,t),se.init(e,t)});var cA=b(\"ZodXID\",(e,t)=>{cp.init(e,t),se.init(e,t)});var lA=b(\"ZodKSUID\",(e,t)=>{lp.init(e,t),se.init(e,t)});var uA=b(\"ZodIPv4\",(e,t)=>{fp.init(e,t),se.init(e,t)});var dA=b(\"ZodIPv6\",(e,t)=>{gp.init(e,t),se.init(e,t)});var pA=b(\"ZodCIDRv4\",(e,t)=>{hp.init(e,t),se.init(e,t)});var mA=b(\"ZodCIDRv6\",(e,t)=>{yp.init(e,t),se.init(e,t)});var fA=b(\"ZodBase64\",(e,t)=>{vp.init(e,t),se.init(e,t)});var gA=b(\"ZodBase64URL\",(e,t)=>{_p.init(e,t),se.init(e,t)});var hA=b(\"ZodE164\",(e,t)=>{wp.init(e,t),se.init(e,t)});var yA=b(\"ZodJWT\",(e,t)=>{xp.init(e,t),se.init(e,t)});var Rf=b(\"ZodNumber\",(e,t)=>{Bi.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,s)=>$m(e,r,o,s),Mr(e,\"ZodNumber\",{gt(r,o){return this.check(Eo(r,o))},gte(r,o){return this.check(Or(r,o))},min(r,o){return this.check(Or(r,o))},lt(r,o){return this.check(Co(r,o))},lte(r,o){return this.check(Pr(r,o))},max(r,o){return this.check(Pr(r,o))},int(r){return this.check(_f(r))},safe(r){return this.check(_f(r))},positive(r){return this.check(Eo(0,r))},nonnegative(r){return this.check(Or(0,r))},negative(r){return this.check(Co(0,r))},nonpositive(r){return this.check(Pr(0,r))},multipleOf(r,o){return this.check(Po(r,o))},step(r,o){return this.check(Po(r,o))},finite(){return this}});let n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??\"\").includes(\"int\")||Number.isSafeInteger(n.multipleOf??0.5),e.isFinite=!0,e.format=n.format??null});function xe(e){return xm(Rf,e)}var bA=b(\"ZodNumberFormat\",(e,t)=>{Sp.init(e,t),Rf.init(e,t)});function _f(e){return Sm(bA,e)}var vA=b(\"ZodBoolean\",(e,t)=>{Ip.init(e,t),re.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Mm(e,n,r,o)});function fe(e){return Im(vA,e)}var _A=b(\"ZodNull\",(e,t)=>{kp.init(e,t),re.init(e,t),e._zod.processJSONSchema=(n,r,o)=>qm(e,n,r,o)});function wA(e){return km(_A,e)}var xA=b(\"ZodUnknown\",(e,t)=>{Rp.init(e,t),re.init(e,t),e._zod.processJSONSchema=(n,r,o)=>jm(e,n,r,o)});function la(){return Rm(xA)}var SA=b(\"ZodNever\",(e,t)=>{Tp.init(e,t),re.init(e,t),e._zod.processJSONSchema=(n,r,o)=>zm(e,n,r,o)});function IA(e){return Tm(SA,e)}var kA=b(\"ZodArray\",(e,t)=>{Ap.init(e,t),re.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Gm(e,n,r,o),e.element=t.element,Mr(e,\"ZodArray\",{min(n,r){return this.check(qn(n,r))},nonempty(n){return this.check(qn(1,n))},max(n,r){return this.check(Oo(n,r))},length(n,r){return this.check($o(n,r))},unwrap(){return this.element}})});function ge(e,t){return Am(kA,e,t)}var RA=b(\"ZodObject\",(e,t)=>{Pp.init(e,t),re.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Bm(e,n,r,o),J(e,\"shape\",()=>t.shape),Mr(e,\"ZodObject\",{keyof(){return ce(Object.keys(this._zod.def.shape))},catchall(n){return this.clone({...this._zod.def,catchall:n})},passthrough(){return this.clone({...this._zod.def,catchall:la()})},loose(){return this.clone({...this._zod.def,catchall:la()})},strict(){return this.clone({...this._zod.def,catchall:IA()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(n){return TT(this,n)},safeExtend(n){return AT(this,n)},merge(n){return CT(this,n)},pick(n){return kT(this,n)},omit(n){return RT(this,n)},partial(...n){return ET(Ef,this,n[0])},required(...n){return PT(Pf,this,n[0])}})});function G(e,t){let n={type:\"object\",shape:e??{},...P(t)};return new RA(n)}var Tf=b(\"ZodUnion\",(e,t)=>{Vi.init(e,t),re.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Vm(e,n,r,o),e.options=t.options});function zn(e,t){return new Tf({type:\"union\",options:e,...P(t)})}var TA=b(\"ZodDiscriminatedUnion\",(e,t)=>{Tf.init(e,t),Op.init(e,t)});function Af(e,t,n){return new TA({type:\"union\",options:t,discriminator:e,...P(n)})}var AA=b(\"ZodIntersection\",(e,t)=>{$p.init(e,t),re.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Fm(e,n,r,o)});function CA(e,t){return new AA({type:\"intersection\",left:e,right:t})}var wf=b(\"ZodRecord\",(e,t)=>{Mp.init(e,t),re.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Jm(e,n,r,o),e.keyType=t.keyType,e.valueType=t.valueType});function qr(e,t,n){if(!t||!t._zod)return new wf({type:\"record\",keyType:w(),valueType:e,...P(t)});return new wf({type:\"record\",keyType:e,valueType:t,...P(n)})}var ua=b(\"ZodEnum\",(e,t)=>{qp.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,s)=>Nm(e,r,o,s),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(r,o)=>{let s={};for(let i of r)if(n.has(i))s[i]=t.entries[i];else throw Error(`Key ${i} not found in enum`);return new ua({...t,checks:[],...P(o),entries:s})},e.exclude=(r,o)=>{let s={...t.entries};for(let i of r)if(n.has(i))delete s[i];else throw Error(`Key ${i} not found in enum`);return new ua({...t,checks:[],...P(o),entries:s})}});function ce(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map((r)=>[r,r])):e;return new ua({type:\"enum\",entries:n,...P(t)})}var EA=b(\"ZodLiteral\",(e,t)=>{zp.init(e,t),re.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Dm(e,n,r,o),e.values=new Set(t.values),Object.defineProperty(e,\"value\",{get(){if(t.values.length>1)throw Error(\"This schema contains multiple valid literal values. Use `.values` instead.\");return t.values[0]}})});function ye(e,t){return new EA({type:\"literal\",values:Array.isArray(e)?e:[e],...P(t)})}var PA=b(\"ZodTransform\",(e,t)=>{jp.init(e,t),re.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Lm(e,n,r,o),e._zod.parse=(n,r)=>{if(r.direction===\"backward\")throw new kr(e.constructor.name);n.addIssue=(s)=>{if(typeof s===\"string\")n.issues.push(pn(s,n.value,t));else{let i=s;if(i.fatal)i.continue=!1;i.code??(i.code=\"custom\"),i.input??(i.input=n.value),i.inst??(i.inst=e),n.issues.push(pn(i))}};let o=t.transform(n.value,n);if(o instanceof Promise)return o.then((s)=>(n.value=s,n.fallback=!0,n));return n.value=o,n.fallback=!0,n}});function Cf(e){return new PA({type:\"transform\",transform:e})}var Ef=b(\"ZodOptional\",(e,t)=>{Fi.init(e,t),re.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ca(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function xf(e){return new Ef({type:\"optional\",innerType:e})}var OA=b(\"ZodExactOptional\",(e,t)=>{Np.init(e,t),re.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ca(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function $A(e){return new OA({type:\"optional\",innerType:e})}var MA=b(\"ZodNullable\",(e,t)=>{Dp.init(e,t),re.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Wm(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Sf(e){return new MA({type:\"nullable\",innerType:e})}var qA=b(\"ZodDefault\",(e,t)=>{Up.init(e,t),re.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Hm(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function zA(e,t){return new qA({type:\"default\",innerType:e,get defaultValue(){return typeof t===\"function\"?t():Mi(t)}})}var jA=b(\"ZodPrefault\",(e,t)=>{Lp.init(e,t),re.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Zm(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function NA(e,t){return new jA({type:\"prefault\",innerType:e,get defaultValue(){return typeof t===\"function\"?t():Mi(t)}})}var Pf=b(\"ZodNonOptional\",(e,t)=>{Gp.init(e,t),re.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Km(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function DA(e,t){return new Pf({type:\"nonoptional\",innerType:e,...P(t)})}var UA=b(\"ZodCatch\",(e,t)=>{Bp.init(e,t),re.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Ym(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function LA(e,t){return new UA({type:\"catch\",innerType:e,catchValue:typeof t===\"function\"?t:()=>t})}var Of=b(\"ZodPipe\",(e,t)=>{Ji.init(e,t),re.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Xm(e,n,r,o),e.in=t.in,e.out=t.out});function If(e,t){return new Of({type:\"pipe\",in:e,out:t})}var GA=b(\"ZodPreprocess\",(e,t)=>{Of.init(e,t),Vp.init(e,t)}),BA=b(\"ZodReadonly\",(e,t)=>{Fp.init(e,t),re.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Qm(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function VA(e){return new BA({type:\"readonly\",innerType:e})}var FA=b(\"ZodLazy\",(e,t)=>{Jp.init(e,t),re.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ef(e,n,r,o),e.unwrap=()=>e._zod.def.getter()});function $f(e){return new FA({type:\"lazy\",getter:e})}var JA=b(\"ZodCustom\",(e,t)=>{Wp.init(e,t),re.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Um(e,n,r,o)});function WA(e,t={}){return Cm(JA,e,t)}function KA(e,t){return Em(e,t)}function da(e){let t=$f(()=>zn([w(e),xe(),fe(),wA(),ge(t),qr(w(),t)]));return t}function HA(e,t){return new GA({type:\"pipe\",in:Cf(e),out:t})}var Qe={invalid_type:\"invalid_type\",too_big:\"too_big\",too_small:\"too_small\",invalid_format:\"invalid_format\",not_multiple_of:\"not_multiple_of\",unrecognized_keys:\"unrecognized_keys\",invalid_union:\"invalid_union\",invalid_key:\"invalid_key\",invalid_element:\"invalid_element\",invalid_value:\"invalid_value\",custom:\"custom\"};var Mf;(function(e){})(Mf||(Mf={}));var zo=I(()=>ce([\"account:read\",\"account:admin\",\"members:manage\",\"workspace:create\",\"billing:read\",\"billing:manage\",\"workspace:read\",\"workspace:admin\",\"sessions:create\",\"sessions:read\",\"sessions:control\",\"stream:view\",\"stream:control\",\"stream:acknowledge\",\"files:upload\",\"files:read\",\"files:write\",\"terminal:attach\",\"documents:manage\",\"documents:search\",\"scheduled_tasks:manage\",\"scheduled_tasks:run\",\"github:manage\",\"github:use\",\"api_keys:manage\",\"usage_allowances:manage\",\"connections:read\",\"connections:write\",\"capabilities:manage\",\"environments:manage\",\"environments:use\",\"variable-sets:list\",\"variable-sets:read\",\"variable-sets:write\",\"variable-sets:manage\",\"variable-sets:attach\",\"variable-sets:use\",\"secrets:list\",\"secrets:read\",\"secrets:write\",\"secrets:use\",\"mcp_servers:attach\",\"codemode:call\",\"goals:manage\",\"enrollments:read\",\"enrollments:manage\",\"rigs:use\",\"rigs:manage\",\"artifacts:read\",\"artifacts:publish\"]));var pa=1;var ZA=4096,zf=16777216,YA=8,XA=1024,ma=1;var fn=I(()=>w().regex(/^[0-9a-f]{64}$/u)),QA=I(()=>w().min(1).max(256).regex(/^[A-Za-z0-9_-]+$/u)),jf=I(()=>w().min(1).max(512).regex(/^[^\\u0000-\\u001f\\u007f]+$/u)),Nf=I(()=>w().min(1).max(128).regex(/^[A-Za-z_$][A-Za-z0-9_$]*$/u).refine((e)=>![\"__proto__\",\"prototype\",\"constructor\"].includes(e),{message:\"unsafe Codemode namespace segment\"})),jn=I(()=>qr(w().max(512),da())),jo=I(()=>G({serverId:QA,toolName:jf}).strict()),Df=jo,Uf=I(()=>G({src:w().min(1).max(8192),mimeType:w().min(1).max(128).optional(),sizes:ge(w().min(1).max(64)).max(16).optional(),theme:ce([\"light\",\"dark\"]).optional()}).strict()),eC=I(()=>G({title:w().max(512).optional(),readOnlyHint:fe().optional(),destructiveHint:fe().optional(),idempotentHint:fe().optional(),openWorldHint:fe().optional()}).loose()),qf=jn;var Lf=I(()=>G({identity:jo,modelName:jf,codemodePath:ge(Nf).min(2).max(YA),title:w().min(1).max(512).optional(),description:w().max(32768).optional(),inputSchema:qf,outputSchema:qf.optional(),annotations:eC.optional(),icons:ge(Uf).max(16).optional(),source:ce([\"opengeni\",\"files\",\"docs\",\"mcp\",\"codex_apps\",\"interaction\"]),approval:ce([\"none\",\"human\",\"policy\"])}).strict()),Gf=Lf;var Bf=I(()=>G({version:ye(pa),accountId:w().uuid(),workspaceId:w().uuid(),sessionId:w().uuid(),turnId:w().uuid(),attemptId:w().uuid(),executionGeneration:xe().int().positive(),generation:xe().int().positive(),digest:fn,createdAt:w().datetime({offset:!0}),firstPartyMcpPermissions:ge(zo).max(128).optional(),entries:ge(Lf).max(ZA)}).strict().superRefine((e,t)=>{let n=new Set,r=new Set,o=new Set;for(let[s,i]of e.entries.entries()){let a=`${i.identity.serverId}\\x00${i.identity.toolName}`,c=i.codemodePath.join(\".\");if(n.has(a))t.addIssue({code:\"custom\",path:[\"entries\",s,\"identity\"],message:\"duplicate tool identity\"});if(r.has(i.modelName))t.addIssue({code:\"custom\",path:[\"entries\",s,\"modelName\"],message:\"duplicate model tool name\"});if(o.has(c))t.addIssue({code:\"custom\",path:[\"entries\",s,\"codemodePath\"],message:\"duplicate Codemode tool path\"});n.add(a),r.add(i.modelName),o.add(c)}})),No=I(()=>G({kind:ce([\"model\",\"codemode\"]),subjectId:w().min(1).max(1024)}).strict()),fa=I(()=>G({operationId:w().uuid(),catalogDigest:fn,identity:jo,arguments:jn,caller:No}).strict()),zr=I(()=>qr(w().max(256),da()).optional()),Pt=I(()=>qr(w().max(512),da()).optional()),tC=I(()=>G({type:ye(\"text\"),text:w(),annotations:zr,_meta:Pt}).loose()),nC=I(()=>G({type:ye(\"image\"),data:w(),mimeType:w().min(1).max(128),annotations:zr,_meta:Pt}).loose()),rC=I(()=>G({type:ye(\"audio\"),data:w(),mimeType:w().min(1).max(128),annotations:zr,_meta:Pt}).loose()),oC=I(()=>G({type:ye(\"resource_link\"),name:w().min(1).max(1024),title:w().max(1024).optional(),uri:w().min(1).max(16384),description:w().max(32768).optional(),mimeType:w().max(128).optional(),size:xe().int().nonnegative().optional(),icons:ge(Uf).max(16).optional(),annotations:zr,_meta:Pt}).loose()),sC=I(()=>G({uri:w().min(1).max(16384),mimeType:w().max(128).optional(),text:w(),_meta:Pt}).loose()),iC=I(()=>G({uri:w().min(1).max(16384),mimeType:w().max(128).optional(),blob:w(),_meta:Pt}).loose()),aC=I(()=>G({type:ye(\"resource\"),resource:zn([sC,iC]),annotations:zr,_meta:Pt}).loose()),cC=I(()=>Af(\"type\",[tC,nC,rC,oC,aC])),jr=I(()=>G({content:ge(cC).max(XA),structuredContent:jn.optional(),isError:fe().optional(),_meta:Pt}).loose()),Vf=jr,Ff=I(()=>G({operationId:w().uuid().optional(),catalogDigest:fn,identity:Df,arguments:jn,siteArtifactId:w().uuid().optional(),siteVersionId:w().uuid().optional(),approvalToken:w().regex(/^ogta_[A-Za-z0-9_-]{43}$/u).optional()}).strict().superRefine(ha));var Jf=I(()=>zn([G({identity:Df}).strict(),G({path:ge(Nf).min(2).max(8)}).strict()])),Wf={siteArtifactId:w().uuid().optional(),siteVersionId:w().uuid().optional()},Kf=I(()=>G({target:Jf,...Wf}).strict().superRefine(ha));var ga=I(()=>G({target:Jf,operationId:w().uuid(),arguments:jn,expectedDefinitionDigest:fn.optional(),approvalToken:w().regex(/^ogta_[A-Za-z0-9_-]{43}$/u).optional(),...Wf}).strict().superRefine(ha));function ha(e,t){if(e.siteArtifactId===void 0===(e.siteVersionId===void 0))return;t.addIssue({code:\"custom\",message:\"siteArtifactId and siteVersionId must be provided together\",path:[e.siteArtifactId===void 0?\"siteArtifactId\":\"siteVersionId\"]})}var lC=I(()=>ce([\"queued\",\"waiting_for_approval\",\"running\",\"completed\",\"failed\",\"outcome_unknown\",\"cancelled\"])),ya=I(()=>G({version:ye(ma),operationId:w().uuid(),accountId:w().uuid(),workspaceId:w().uuid(),sessionId:w().uuid(),turnId:w().uuid(),attemptId:w().uuid(),executionGeneration:xe().int().positive(),catalogDigest:fn,requestDigest:fn,identity:jo,arguments:jn,caller:No.refine((e)=>e.kind===\"codemode\",{message:\"Codemode operation caller must be codemode\"}),state:lC,durableApproval:ye(!0).optional(),approvalRequestId:w().uuid().optional(),result:jr.nullable(),errorCode:w().min(1).max(128).nullable(),errorMessage:w().min(1).max(4096).nullable(),createdAt:w().datetime({offset:!0}),claimedAt:w().datetime({offset:!0}).nullable(),executionStartedAt:w().datetime({offset:!0}).nullable(),completedAt:w().datetime({offset:!0}).nullable(),updatedAt:w().datetime({offset:!0})}).strict());var Hf=I(()=>G({operation:ya,dispatch:ce([\"accepted\",\"already_running\",\"terminal\",\"unavailable\",\"rejected\"])}).strict()),ba=I(()=>G({version:ye(ma),operationId:w().uuid(),catalogDigest:fn}).strict()),va=I(()=>G({version:ye(ma),operationId:w().uuid(),status:ce([\"accepted\",\"already_running\",\"terminal\",\"unavailable\",\"rejected\"])}).strict());var uC=Object.freeze([{id:\"config.client\",method:\"GET\",pattern:/^\\/v1\\/config\\/client$/u},{id:\"workspace.get\",method:\"GET\",pattern:/^$/u},{id:\"site.config\",method:\"GET\",pattern:/^\\/site\\/config$/u},{id:\"models.list\",method:\"GET\",pattern:/^\\/model-catalog$/u},{id:\"sessions.list\",method:\"GET\",pattern:/^\\/sessions$/u},{id:\"sessions.create\",method:\"POST\",pattern:/^\\/sessions$/u,agent:!0},{id:\"sessions.get\",method:\"GET\",pattern:new RegExp(\"^/sessions/[A-Za-z0-9_-]{1,128}$\",\"u\")},{id:\"sessions.events\",method:\"GET\",pattern:new RegExp(\"^/sessions/[A-Za-z0-9_-]{1,128}/events$\",\"u\")},{id:\"sessions.stream\",method:\"GET\",pattern:new RegExp(\"^/sessions/[A-Za-z0-9_-]{1,128}/events/stream$\",\"u\"),stream:!0},{id:\"sessions.send\",method:\"POST\",pattern:new RegExp(\"^/sessions/[A-Za-z0-9_-]{1,128}/events$\",\"u\"),agent:!0},{id:\"sessions.steer\",method:\"POST\",pattern:new RegExp(\"^/sessions/[A-Za-z0-9_-]{1,128}/steer$\",\"u\"),agent:!0},{id:\"sessions.control\",method:\"POST\",pattern:new RegExp(\"^/sessions/[A-Za-z0-9_-]{1,128}/control$\",\"u\"),agent:!0},{id:\"sessions.queue\",method:\"GET\",pattern:new RegExp(\"^/sessions/[A-Za-z0-9_-]{1,128}/queue$\",\"u\")},{id:\"sessions.queue.item\",method:\"POST\",pattern:new RegExp(\"^/sessions/[A-Za-z0-9_-]{1,128}/queue/[A-Za-z0-9_-]{1,128}/(?:move|edit|steer|delete)$\",\"u\"),agent:!0},{id:\"sessions.composerDraft.get\",method:\"GET\",pattern:new RegExp(\"^/sessions/[A-Za-z0-9_-]{1,128}/composer-draft$\",\"u\")},{id:\"sessions.composerDraft.put\",method:\"PUT\",pattern:new RegExp(\"^/sessions/[A-Za-z0-9_-]{1,128}/composer-draft$\",\"u\")},{id:\"sessions.composerDraft.submit\",method:\"POST\",pattern:new RegExp(\"^/sessions/[A-Za-z0-9_-]{1,128}/composer-draft/submit$\",\"u\"),agent:!0},{id:\"sessions.humanInput\",method:\"GET\",pattern:new RegExp(\"^/sessions/[A-Za-z0-9_-]{1,128}/human-input-requests$\",\"u\")},{id:\"sessions.humanInput.get\",method:\"GET\",pattern:new RegExp(\"^/sessions/[A-Za-z0-9_-]{1,128}/human-input-requests/[A-Za-z0-9_-]{1,128}$\",\"u\")},{id:\"data.read\",method:\"GET\",pattern:new RegExp(\"^/published-artifacts/current/(?:data|files)(?:/[A-Za-z0-9._~:@!$&'()*+,;=-]+)*$\",\"u\")},{id:\"data.write\",method:\"POST\",pattern:new RegExp(\"^/published-artifacts/current/(?:data|files)(?:/[A-Za-z0-9._~:@!$&'()*+,;=-]+)*$\",\"u\")},{id:\"data.put\",method:\"PUT\",pattern:new RegExp(\"^/published-artifacts/current/(?:data|files)(?:/[A-Za-z0-9._~:@!$&'()*+,;=-]+)*$\",\"u\")},{id:\"data.patch\",method:\"PATCH\",pattern:new RegExp(\"^/published-artifacts/current/(?:data|files)(?:/[A-Za-z0-9._~:@!$&'()*+,;=-]+)*$\",\"u\")},{id:\"data.delete\",method:\"DELETE\",pattern:new RegExp(\"^/published-artifacts/current/(?:data|files)(?:/[A-Za-z0-9._~:@!$&'()*+,;=-]+)*$\",\"u\")},{id:\"sql.run\",method:\"POST\",pattern:/^\\/published-artifacts\\/current\\/sql\\/queries\\/[A-Za-z][A-Za-z0-9_-]{0,63}$/u},{id:\"site.report\",method:\"POST\",pattern:/^\\/site\\/reports$/u}]),gV=Object.freeze([\"catalog\",\"declarations\",\"call\",\"resolve\",\"invoke\"]);function Zf(e,t){if(/[%\\\\#\\u0000-\\u0020\\u007f]/u.test(t))return null;if(t.split(\"/\").some((s)=>s===\".\"||s===\"..\"))return null;let n=e.toUpperCase(),r;if(t===\"/v1/config/client\")r=t;else if(t===\"/v1/workspaces/site-host\")r=\"\";else if(t.startsWith(\"/v1/workspaces/site-host/\"))r=t.slice(24);else return null;let o=uC.find((s)=>s.method===n&&s.pattern.test(r));return o?{operation:o,suffix:r}:null}var dC=I(()=>G({id:w().max(64).describe(\"Stable report requirement identifier, at most 64 ASCII characters; not a title or status.\").regex(/^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/),title:w().trim().min(1).max(512).describe(\"Short human-readable report title, at most 512 UTF-8 bytes. Keep normal spaces; do not put the report or a progress transcript here.\").refine((e)=>new TextEncoder().encode(e).byteLength<=512,\"Report title exceeds 512 UTF-8 bytes\")}).strict()),Yf=I(()=>ge(dC).max(16).superRefine((e,t)=>{if(new Set(e.map((n)=>n.id)).size!==e.length)t.addIssue({code:\"custom\",message:\"Duplicate report requirement IDs\"})}));var _a=I(()=>ce([\"automatic\",\"review_first\",\"off\"]));var pC=I(()=>G({knowledge:_a,instructions:_a,skills:_a}).strict()),xV=Object.freeze({knowledge:\"automatic\",instructions:\"automatic\",skills:\"automatic\"}),Xf=I(()=>pC.partial());var mC={vaultsPerOwnerScope:200,itemsPerVault:2000,fieldsPerItem:50,versionsPerField:10,nameMaxChars:120,descriptionMaxChars:2000,websitesPerItem:20,websiteMaxChars:2048,textValueMaxBytes:65536,fileValueMaxBytes:262144,referenceMaxChars:300,execEnvMaxBytes:262144,execValueMaxBytes:102400,policyVaultIdsMax:200,searchResultsMax:50,searchScanMax:1000,searchCursorMaxChars:1024,providerReadsPerAttempt:50,providerValueCacheMs:60000};var Qf=I(()=>Af(\"mode\",[G({mode:ye(\"all\")}).strict(),G({mode:ye(\"selected\"),vaultIds:ge(w().uuid()).max(mC.policyVaultIdsMax)}).strict()])),RV=Object.freeze({mode:\"all\"});var fC=[\"webSearch\",\"humanInput\",\"skills\",\"goals\",\"subagents\",\"knowledge\",\"schedules\",\"artifacts\",\"browser\",\"secrets\",\"media\",\"workspaceFiles\",\"workspaceConnectors\",\"workspaceAdmin\"];var PV=fC.filter((e)=>e!==\"skills\"),gC=I(()=>zn([ye(\"read\"),ye(\"manage\"),ye(!1)])),hC=I(()=>ce([\"all\",\"none\"])),yC=I(()=>G({webSearch:fe().optional(),humanInput:fe().optional(),skills:gC.optional(),goals:fe().optional(),subagents:fe().optional(),knowledge:fe().optional(),schedules:fe().optional(),artifacts:fe().optional(),browser:fe().optional(),secrets:fe().optional(),media:fe().optional(),workspaceFiles:fe().optional(),workspaceConnectors:fe().optional(),workspaceAdmin:fe().optional()}).strict()),bC=I(()=>zn([ye(\"all\"),ye(\"none\"),yC.extend({from:hC}).strict()])),vC=I(()=>ce([\"opengeni\",\"markdown\"])),_C=8000,eg=65536,wC=I(()=>w().trim().min(1).max(_C)),tg=I(()=>G({capabilities:bC.optional(),identity:wC.nullable().optional(),instructions:w().trim().min(1).max(eg).optional(),renderer:vC.optional(),vaultPolicy:Qf.optional()}).strict());var xC=[\"web\",\"slack\",\"api_key\",\"embedded\",\"scheduled\",\"agent\",\"voice\",\"site\",\"automation\",\"mcp\",\"system\"],ng=I(()=>ce(xC));var rg=[\"openai\",\"azure\",\"codex-subscription\",\"supergrok-subscription\",\"opengeni-gateway\",\"workspace-gateway\",\"organization-gateway\",\"openrouter\",\"workspace-openrouter\",\"organization-openrouter\",\"opper\",\"workspace-opper\",\"organization-opper\",\"organization-openai\",\"organization-azure-openai\",\"registry\"],og=I(()=>ce(rg)),qV=new Set(rg.filter((e)=>e!==\"registry\"));var SC=[\"github.com\",\"gitlab.com\",\"dev.azure.com\",\"slack.com\",\"chatgpt.com\",\"x.com\",\"reddit.com\",\"fiken.no\",\"api.atlassian.com\",\"googleapis.com\",\"gmailmcp.googleapis.com\",\"mcp.slack.com\",\"api.mobbin.com\",\"mcp.linear.app\",\"mcp.asana.com\",\"mcp.stripe.com\",\"mcp.figma.com\",\"mcp.canva.com\",\"mcp.sentry.dev\",\"mcp.vercel.com\",\"bindings.mcp.cloudflare.com\",\"mcp.paypal.com\",\"mcp.monday.com\",\"mcp.airtable.com\",\"mcp.zapier.com\",\"mcp.webflow.com\",\"mcp.supabase.com\",\"mcp.clickup.com\",\"mcp.calendly.com\",\"mcp.box.com\",\"mcp.dropbox.com\",\"mcp.amplitude.com\",\"mcp.posthog.com\",\"mcp.pagerduty.com\",\"mcp.apollo.io\",\"api.ahrefs.com\",\"mcp.semrush.com\",\"mcp.frontapp.com\",\"mcp.otter.ai\",\"mcp.notion.com\",\"mcp.hubspot.com\",\"mcp.atlassian.com\",\"mcp.intercom.com\"],zV=new Set(SC);var sg=[\"exec_command\",\"write_stdin\",\"view_image\",\"apply_patch\",\"skill_read\",\"repository_skill_read\",\"request_human_input\",\"list_models\",\"code_search\",\"tool_search\",\"tool_list\",\"tool_invoke\",\"generate_image\",\"generate_video\",\"get_video_generation_capabilities\",\"computer_screenshot\",\"web_search_call\",\"image_generation_call\",\"code_interpreter_call\",\"file_search_call\",\"computer_call\",\"local_shell_call\",\"shell_call\",\"apply_patch_call\"],ig=[\"skill_checkout\",\"skill_publish\",\"skill_install\",\"skill_remove\",\"skill_save\",\"skill_search\",\"operation_read\",\"knowledge_source_fetch\",\"knowledge_source_read\",\"files_get_download_url\"];var ag=\"/v1/workspaces/site-host\",lg=/^\\/v1\\/workspaces\\/site-host\\/published-artifacts\\/([^/]+)\\/(?:data|files|sql)(?:\\/|$)/u,ug=\"00000000-0000-0000-0000-000000000000\",dg=\"x-opengeni-site-frame\",pg=\"preview\",mg=\"x-opengeni-site-frame-id\";class Ot extends Error{code=\"site_session_path_unsupported\";constructor(){super(\"Unsupported Site session API path\");this.name=\"SiteSessionPathError\"}}class Do extends Error{code=\"site_data_unsupported\";constructor(){super(\"This Site host does not provide Site Data\");this.name=\"SiteDataUnsupportedError\"}}function IC(e){return/[%\\\\#\\u0000-\\u0020\\u007f]/u.test(e)||e.split(\"/\").some((t)=>t===\".\"||t===\"..\")}function fg(e,t){let n=new URL(e,\"http://site.invalid\");if(n.pathname===\"/v1/config/client\"){let r=n.searchParams.getAll(\"workspaceId\");if(r.length>1||r.length===1&&r[0]!==\"site-host\"&&r[0]!==t)throw new Ot;if(t!==\"site-host\")n.searchParams.set(\"workspaceId\",t);return n.pathname+n.search}return e.replace(\"/workspaces/site-host\",`/workspaces/${encodeURIComponent(t)}`)}function gg(e,t,n,r){if(n===\"site-host\")return e;if(!r)throw new Do;return t.replace(\"/published-artifacts/current/\",`/published-artifacts/${encodeURIComponent(r)}/`)}function hg(e,t,n=\"GET\",r){let o=e.split(\"?\")[0],s=Zf(n,o);if(!s)throw new Ot;let i=fg(e,t);if(lg.test(o))return gg(e,i,t,r);if(s.operation.id!==\"sessions.list\")return i;let a=new URL(i,\"http://site.invalid\"),c=a.searchParams.getAll(\"originSiteId\"),l=a.searchParams.getAll(\"siteAccessId\"),u=a.searchParams.getAll(\"view\");if(u.length>1||u.length===1&&u[0]!==\"page\"||c.length+l.length!==1||(c[0]??l[0])!==\"current\")throw new Ot;if(t===\"site-host\")return e;return a.searchParams.set(l.length?\"siteAccessId\":\"originSiteId\",r??ug),a.pathname+a.search}function yg(e,t){let n=e.split(\"?\")[0];if(!(n===ag||n.startsWith(`${ag}/`))&&n!==\"/v1/config/client\"||IC(n))throw new Ot;let o=fg(e,t),s=lg.exec(n);if(s){if(s[1]!==\"current\")throw new Ot;return gg(e,o,t)}let i=new URL(o,\"http://site.invalid\");if(i.searchParams.get(\"originSiteId\")===\"current\"&&t!==\"site-host\")return i.searchParams.set(\"originSiteId\",ug),i.pathname+i.search;return o}function bg(e){let t=new Headers(e),n=(t.get(\"connection\")??\"\").split(\",\").map((r)=>r.trim().toLowerCase());for(let r of[...t.keys()])if(n.includes(r)||/^(authorization|proxy-authorization|cookie|cookie2|host|origin|referer|connection|keep-alive|proxy-connection|te|trailer|transfer-encoding|upgrade|content-length|accept-encoding|forwarded|x-api-key)$/i.test(r)||/^(sec-|x-forwarded-|x-opengeni-(access-key|external-actor|site-|managed-actor))/i.test(r))t.delete(r);return t}var cg=[\"text\",\"annotations\",\"model\",\"reasoningEffort\",\"latencyMode\",\"controlEtag\",\"expectedDraftRevision\"],DV=Object.freeze({\"sessions.send\":[\"type\",\"payload\",\"clientEventId\"],\"sessions.steer\":[...cg,\"clientEventId\"],\"sessions.control\":[\"action\",\"reason\",\"clientEventId\",\"expectedControlEtag\"],\"sessions.composerDraft.put\":[\"text\",\"annotations\",\"resources\",\"model\",\"reasoningEffort\",\"latencyMode\",\"expectedRevision\"],\"sessions.composerDraft.submit\":[...cg,\"resources\",\"connectionAccounts\",\"clientEventId\",\"delivery\"],\"sessions.queue.move\":[\"clientEventId\",\"expectedQueueVersion\",\"beforeTurnId\"],\"sessions.queue.edit\":[\"clientEventId\",\"expectedTurnVersion\",\"expectedDraftRevision\",\"replaceDraft\"],\"sessions.queue.steer\":[\"clientEventId\",\"expectedTurnVersion\",\"controlEtag\"],\"sessions.queue.delete\":[\"clientEventId\",\"expectedTurnVersion\",\"reason\"]});var UV=Object.freeze([\"initialMessage\",\"requestedSessionId\",\"idempotencyKey\",\"clientEventId\",\"model\",\"reasoningEffort\",\"latencyMode\",\"startMode\",\"metadata\"]);var kC=\"tool_result_spilled\",RC=\"application/json\";var TC=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/,AC=I(()=>G({type:ye(kC),sandboxPath:w().min(1).max(4096).nullable(),fileId:w().regex(TC),byteSize:xe().int().positive().safe(),mediaType:ye(RC)}).strict());function vg(e){return AC.safeParse(e).success}function gn(e){if(!e||typeof e!==\"object\"||Array.isArray(e))return e;let t=new Set([\"title\",\"description\",\"examples\",\"$comment\"]),n=new Set([\"properties\",\"patternProperties\",\"$defs\",\"definitions\",\"dependentSchemas\"]),r=new Set([\"allOf\",\"anyOf\",\"oneOf\",\"prefixItems\"]),o=new Set([\"items\",\"contains\",\"additionalProperties\",\"unevaluatedProperties\",\"unevaluatedItems\",\"propertyNames\",\"not\",\"if\",\"then\",\"else\"]);return Object.fromEntries(Object.entries(e).flatMap(([s,i])=>{if(t.has(s))return[];if(n.has(s)&&i&&typeof i===\"object\"&&!Array.isArray(i))return[[s,Object.fromEntries(Object.entries(i).map(([a,c])=>[a,gn(c)]))]];if(r.has(s)&&Array.isArray(i))return[[s,i.map(gn)]];if(o.has(s))return[[s,gn(i)]];return[[s,i]]}))}var wa=I(()=>ce([\"docker\",\"modal\",\"local\",\"none\",\"daytona\",\"runloop\",\"e2b\",\"blaxel\",\"cloudflare\",\"vercel\",\"selfhosted\",\"opensandbox\",\"compute\"]));var Uo=[\"set_session_title\",\"notify_user\",\"notification_withdraw\",\"inbox_tidy\",\"goal_set\",\"goal_update\",\"goal_progress\",\"wait_for_input\",\"goal_complete\",\"goal_pause\",\"goal_resume\",\"knowledge_search\",\"knowledge_prepare_save\",\"knowledge_get\",\"knowledge_browse\",\"knowledge_save\",\"knowledge_retain_file\",\"knowledge_retain_message\",\"knowledge_archive\",\"instruction_policy_save\",\"instruction_policy_get\",\"memory_search\",\"memory_save\",\"memory_correct\",\"preference_registry_summary\",\"preference_registry_get\",\"task_notes_list\",\"task_note_save\",\"task_note_archive\",\"task_note_replace\",\"work_claim_upsert\",\"work_claim_release\",\"knowledge_propose\",\"knowledge_correct\",\"task_note_promote_knowledge\",\"task_note_promote_instruction_policy\",\"task_note_promote_preference\",\"instruction_policy_propose\",\"preference_propose\",\"remember\",\"remember_confirm\",\"company_profile_propose\",\"company_profile_confirm\",\"sandboxes_list\",\"sandbox_attach\",\"sandbox_swap\",\"run_on\",\"sandbox_provision\",\"connected_machine_remove\",\"connected_machine_enroll_token\",\"connected_machine_enable_screen_control\",\"project_list\",\"project_get\",\"project_create\",\"project_update\",\"project_reorder\",\"project_delete\",\"session_set_project\",\"admin_actions_search\",\"admin_action_describe\",\"admin_action_call\",\"rig_list\",\"rig_get\",\"rig_propose_change\",\"rig_verify\",\"rig_promote\",\"sessions_list\",\"session_get\",\"session_set_model\",\"session_events\",\"session_wait\",\"command_wait\",\"command_read\",\"session_create\",\"session_send_message\",\"session_message_status\",\"session_target_get\",\"session_target_set\",\"session_pause\",\"session_resume\",\"session_steer\",\"session_human_input_respond\",\"set_other_session_title\",\"interaction_discover\",\"browser_open\",\"browser_tabs\",\"browser_observe\",\"browser_read\",\"browser_screenshot\",\"browser_act\",\"browser_clipboard\",\"browser_debug\",\"browser_downloads\",\"browser_download_save\",\"browser_record\",\"browser_auth\",\"interaction_request_human\",\"browser_identity\",\"browser_publish\",\"browser_lifecycle\",\"computer_open\",\"computer_targets\",\"computer_observe\",\"computer_clipboard\",\"computer_act\",\"computer_lifecycle\",\"excel_run\",\"secret_search\",\"secret_save\",\"secret_get\",\"secret_move\",\"secret_delete\",\"variable_set_list\",\"environment_list\",\"variable_set_get_variable\",\"variable_set_set_variable\",\"environment_set_variable\",\"capability_catalog_search\",\"capability_authorization_request\",\"custom_mcp_setup_request\",\"github_connect_link\",\"github_repositories_list\",\"social_connections_list\",\"social_posts_recent\",\"social_daily_analysis_context\",\"social_search_live\",\"social_mentions_live\",\"social_thread_fetch\",\"social_posts_sync\",\"social_post_reply\",\"x_accounts_list\",\"x_search_live\",\"x_mentions_live\",\"x_thread_fetch\",\"x_posts_sync\",\"x_post_reply\",\"reddit_accounts_list\",\"reddit_search_live\",\"reddit_mentions_live\",\"reddit_thread_fetch\",\"reddit_posts_sync\",\"reddit_post_reply\",\"scheduled_tasks_list\",\"scheduled_tasks_get\",\"scheduled_tasks_create\",\"scheduled_tasks_update\",\"scheduled_tasks_pause\",\"scheduled_tasks_resume\",\"scheduled_tasks_trigger\",\"scheduled_tasks_delete\",\"scheduled_task_runs_list\",\"slack_bot_list_channels\",\"slack_bot_search\",\"slack_bot_channel_history\",\"slack_bot_thread_replies\",\"slack_bot_list_users\",\"slack_bot_list_files\",\"slack_bot_file_info\",\"slack_bot_file_content\",\"slack_bot_upload_file\",\"slack_bot_post_message\",\"slack_bot_delete_message\",\"slack_bot_prepare_message\",\"slack_bot_send_prepared_message\",\"fiken_companies_list\",\"fiken_contacts_list\",\"fiken_contact_create\",\"fiken_products_list\",\"fiken_invoices_list\",\"fiken_invoice_get\",\"fiken_invoice_draft_create\",\"fiken_bank_accounts_list\",\"fiken_purchases_list\",\"fiken_sales_list\",\"atlassian_sources_list\",\"atlassian_search\",\"atlassian_get\",\"artifacts_list\",\"artifacts_get_source\",\"artifacts_prepare_upload\",\"artifacts_create\",\"artifacts_publish\",\"artifacts_rollback\",\"artifacts_archive\",\"artifacts_restore\",\"site_data_describe\",\"site_data_define_collection\",\"site_data_query\",\"site_data_write\",\"site_data_import\",\"site_data_export\",\"site_data_reset\",\"site_files_list\",\"site_files_upload\",\"site_files_delete\",\"site_publication_get\",\"site_publication_update\",\"site_publication_apply_fix\",\"site_hostname_check\",\"site_sql_inspect\",\"site_sql_enable\",\"site_sql_migrate\",\"site_sql_define_query\",\"site_sql_query\",\"site_sql_run\",\"site_sql_execute\",\"site_sql_export\",\"site_sql_import\",\"site_sql_reset\",\"sandbox_file_publish\",\"editable_artifact_list\",\"editable_artifact_create\",\"editable_artifact_import\",\"editable_artifact_get\",\"editable_artifact_inspect\",\"editable_artifact_apply\",\"editable_artifact_export\",\"editable_artifact_export_status\"],CC=I(()=>ce(Uo)),EC=[\"interaction_discover\",\"browser_open\",\"browser_tabs\",\"browser_observe\",\"browser_read\",\"browser_screenshot\",\"browser_act\",\"browser_clipboard\",\"browser_debug\",\"browser_downloads\",\"browser_download_save\",\"browser_record\",\"browser_auth\",\"interaction_request_human\",\"browser_identity\",\"browser_publish\",\"browser_lifecycle\",\"computer_open\",\"computer_targets\",\"computer_observe\",\"computer_clipboard\",\"computer_act\",\"computer_lifecycle\"],PC=new Set(EC),Sg=[\"memory_search\",\"memory_save\",\"memory_correct\",\"knowledge_propose\",\"knowledge_correct\",\"task_note_promote_instruction_policy\",\"task_note_promote_preference\",\"instruction_policy_propose\",\"preference_propose\",\"remember\",\"remember_confirm\"],OC=new Set(Sg),Ig=[\"variable_set_list\",\"environment_list\",\"variable_set_get_variable\",\"variable_set_set_variable\",\"environment_set_variable\"],$C=new Set(Ig);var MC=[\"slack_bot_post_message\",\"atlassian_sources_list\",\"atlassian_search\",\"atlassian_get\",...Sg,...Ig],qC=new Set(MC),sF=Uo.filter((e)=>!PC.has(e)&&!qC.has(e)),iF=new Set([...Uo,...ig,...sg]);var zC=[\"admin_actions_search\",\"admin_action_describe\",\"admin_action_call\"],jC=new Set(zC),aF=Uo.filter((e)=>!OC.has(e)&&!$C.has(e)&&!e.startsWith(\"social_\")&&!e.startsWith(\"x_\")&&!e.startsWith(\"reddit_\")&&(!e.startsWith(\"slack_bot_\")||e===\"slack_bot_list_channels\"||e===\"slack_bot_prepare_message\"||e===\"slack_bot_send_prepared_message\")&&!e.startsWith(\"fiken_\")&&!e.startsWith(\"atlassian_\")&&!jC.has(e));var NC=I(()=>ce([\"private\",\"workspace\"]));var DC=256,kg=25;var cF=Object.freeze({sessionDefaults:null,allowedProviders:null,allowedModels:null,modelCompactionThresholds:Object.freeze({}),realtimeVoice:Object.freeze({}),realtimeDefaultModel:null,updatedAt:null});var UC={subjectId:w().min(1),label:w().min(1).optional()};var LC=I(()=>qr(w(),la()));var GC=\"https://chromewebstore.google.com/detail/opengeni-browser/phpmmcbeelfkcinjfbbggegjdcdmnnch\",lF=[{code:\"attached_browser_unavailable\",capabilityId:\"api:connected-machine\",purpose:\"chrome\",problem:\"No Chrome profile is connected through the browser extension.\",rationale:\"Connect your Chrome so the agent can use it.\",nextStep:`connect their computer as a Connected Machine, then add the browser extension to Chrome: ${GC}`},{code:\"personal_machine_permission_required\",capabilityId:\"api:connected-machine\",problem:\"This is a personal (Only me) machine, and its owner has not allowed this chat to use it yet.\",rationale:\"Allow this chat to use your computer.\",nextStep:\"open this chat in Opengeni and allow it to use their machine\"}];var BC=I(()=>w().regex(/^[A-Za-z0-9_-]{16,128}$/)),uF={workspaceId:w().uuid(),accountId:w().uuid(),allowScreenControl:fe(),iat:xe().int().nonnegative(),exp:xe().int().positive(),jti:BC.optional()};var VC=/^[A-Za-z0-9_-]+$/,FC=I(()=>w().min(1).regex(VC)),JC=I(()=>ge(FC.max(200)).max(64));var WC=I(()=>ce([\"user\",\"scheduled_task\",\"api\",\"goal\",\"system\",\"compaction\"]));var KC=I(()=>ce([\"review_changes\",\"preserve_intent\",\"autonomous_adaptation\"]));var HC=8192,ZC=8192,YC=2048;var XC=512,_g=4096,QC=16;function Rg(e){return new TextEncoder().encode(e).byteLength}function Lo(e,t){return w().min(1).max(e).describe(`${t}: at most ${e} UTF-8 bytes. Write concise, human-readable text with normal spacing; summarize instead of compressing words.`).refine((n)=>Rg(n)<=e,{message:`${t} exceeds ${e} UTF-8 bytes`})}function eE(e,t){let n=new TextEncoder,r=n.encode(e),o=n.encode(t),s=Math.min(r.length,o.length);for(let i=0;i<s;i+=1){let a=r[i]-o[i];if(a!==0)return a}return r.length-o.length}function tE(e){return[...new Set(e.map((t)=>t.replace(/^ +| +$/g,\"\")))].sort(eE)}var nE=I(()=>ge(Lo(XC,\"goal root constraint\")).transform(tE).pipe(ge(w().min(1)).max(QC).refine((e)=>e.reduce((t,n)=>t+Rg(n),0)<=_g,{message:`goal root constraints exceed ${_g} aggregate UTF-8 bytes`}))),rE=Lo(HC,\"goal text\"),oE=Lo(ZC,\"goal success criteria\"),dF=Lo(YC,\"goal rationale\");var sE=I(()=>G({text:rE,successCriteria:oE.optional(),rootConstraints:nE.optional(),reportRequirements:Yf.optional(),maxAutoContinuations:xe().int().positive().optional(),mutationPolicy:KC.optional()}));var iE=\"$opengeniCleared\",pF=JSON.stringify({[iE]:!0});var aE=\"$opengeniOpenSuffix\",mF=JSON.stringify({[aE]:!0});var cE=I(()=>G({kind:ce([\"subject\",\"service\"]),...UC}));var Tg=16384,Ag=2048,wg=512,lE=256,xg=1048576,uE=I(()=>ce([\"user_message\",\"assistant_message\",\"tool_output\"])),dE=I(()=>ce([\"user.message\",\"agent.message.completed\",\"agent.toolCall.output\"]));function Cg(e){return new TextEncoder().encode(e).byteLength}function hn(e,t){return w().superRefine((n,r)=>{if(Cg(n)>e)r.addIssue({code:Qe.custom,message:`${t} must be at most ${e} UTF-8 bytes`})})}var Eg=I(()=>G({kind:uE,eventId:w().uuid(),eventType:dE,sequence:xe().int().positive(),turnId:w().uuid().nullable(),startOffset:xe().int().nonnegative(),endOffset:xe().int().nonnegative(),contextBefore:hn(wg,\"annotation source contextBefore\"),contextAfter:hn(wg,\"annotation source contextAfter\"),label:hn(lE,\"annotation source label\").optional()}).strict().superRefine((e,t)=>{if(e.endOffset<e.startOffset)t.addIssue({code:Qe.custom,path:[\"endOffset\"],message:\"annotation source endOffset must not precede startOffset\"});let n=e.eventType===\"user.message\"?\"user_message\":e.eventType===\"agent.message.completed\"?\"assistant_message\":\"tool_output\";if(e.kind!==n)t.addIssue({code:Qe.custom,path:[\"kind\"],message:\"annotation source kind does not match eventType\"})})),Pg=I(()=>G({id:w().uuid(),source:Eg,quote:hn(Tg,\"annotation quote\"),note:hn(Ag,\"annotation note\")}).strict().superRefine((e,t)=>{if(!e.quote.trim())t.addIssue({code:Qe.custom,path:[\"quote\"],message:\"annotation quote must contain non-whitespace text\"})})),pE=I(()=>Pg.superRefine((e,t)=>{if(!e.note.trim())t.addIssue({code:Qe.custom,path:[\"note\"],message:\"annotation note must contain non-whitespace text\"})})),mE=I(()=>G({id:w().uuid(),source:Eg,quote:hn(Tg,\"annotation quote\"),note:hn(Ag,\"annotation note\").refine((e)=>e.trim().length>0,{message:\"annotation note must contain non-whitespace text\"}),ordinal:xe().int().positive()}).strict());function xa(e){return ge(e).superRefine((t,n)=>{let r=new Set;for(let o=0;o<t.length;o+=1){let s=t[o].id;if(typeof s===\"string\"&&r.has(s))n.addIssue({code:Qe.custom,path:[o,\"id\"],message:\"annotation ids must be unique\"});if(typeof s===\"string\")r.add(s)}if(Cg(JSON.stringify(t))>xg)n.addIssue({code:Qe.custom,message:`annotations must be at most ${xg} UTF-8 bytes`})})}var fF=xa(Pg),gF=xa(pE),hF=xa(mE).superRefine((e,t)=>{for(let n=0;n<e.length;n+=1)if(e[n].ordinal!==n+1)t.addIssue({code:Qe.custom,path:[n,\"ordinal\"],message:\"annotation ordinals must be contiguous and match array order\"})});var fE=\"[Session goal frozen when this turn was accepted]\";var yF=hE({agentLearning:Xf.optional(),excludedMcpServerIds:JC.optional(),visibility:NC.optional(),sandboxBackend:wa.optional(),targetSandboxId:w().uuid().optional(),workingDir:w().min(1).optional(),variableSetId:w().uuid().optional(),variableSetIds:ge(w().uuid()).max(kg).optional(),rigId:w().uuid().optional(),goal:sE.optional(),firstPartyMcpPermissions:ge(zo).optional(),firstPartyMcpTools:ge(CC).optional(),agent:tg.optional()});var gE=[\"child_terminal_result\",\"child_requires_action\",\"child_requires_action_resolved\",\"child_paused\",\"child_waiting_capacity\",\"child_progress\"],bF=new Set(gE);var vF=`${fE}\n`;function hE(e,t={}){return HA((n)=>{if(!n||typeof n!==\"object\"||Array.isArray(n))return n;let r=n;if(t.rejectKeys?.some((s)=>Object.hasOwn(r,s)))return null;let o=r.variableSetId!==void 0||r.environmentId===void 0?r:{...r,variableSetId:r.environmentId};if(o.variableSetIds===void 0&&o.variableSetId!==void 0)return{...o,variableSetIds:o.variableSetId===null?[]:[o.variableSetId]};return o},G(e).superRefine((n,r)=>{let o=n;if(!Array.isArray(o.variableSetIds))return;if(new Set(o.variableSetIds).size!==o.variableSetIds.length)r.addIssue({code:Qe.custom,path:[\"variableSetIds\"],message:\"variableSetIds must not contain duplicates\"});if(o.variableSetId===void 0)return;let s=o.variableSetIds.length>0?o.variableSetIds[o.variableSetIds.length-1]:null;if(o.variableSetId!==s)r.addIssue({code:Qe.custom,path:[\"variableSetId\"],message:\"variableSetId must match the last variableSetIds entry\"})}))}var _F=kg*2;var yE=I(()=>ce([\"file\",\"dir\",\"symlink\",\"other\"]));var bE=$f(()=>G({name:w(),path:w(),type:yE,sizeBytes:xe().int().nonnegative().nullable(),mtimeMs:xe().int().nonnegative().nullable(),mode:xe().int().nullable(),children:ge(bE).optional(),truncated:fe().default(!1)}));var vE=I(()=>cE.extend({subjectId:w().min(1).max(1024),label:w().min(1).max(256).optional()})),_E=I(()=>LC.refine((e)=>{try{return new TextEncoder().encode(JSON.stringify(e)).byteLength<=4096}catch{return!1}},{message:\"Host export initiator context exceeds 4096 UTF-8 bytes\"})),wF={initiator:vE.nullable(),initiatorContext:_E,origin:WC.nullable(),surface:ng.nullable().optional(),modelProvider:og.nullable().optional()};var xF=DC*4;var wE=[\"id\",\"workspaceId\",\"sessionId\",\"sequence\",\"coveredThrough\",\"type\",\"payload\",\"occurredAt\",\"clientEventId\",\"turnId\",\"turnGeneration\",\"turnAttemptId\",\"turnAssociation\",\"duplicateOfEventId\",\"duplicateReason\"],SF=new Set([...wE,\"toJSON\"]);import{createHash as rG,randomUUID as oG}from\"node:crypto\";var Zr=ho(M_(),1);import{createHash as m4,randomUUID as p$}from\"node:crypto\";import{AsyncLocalStorage as c$}from\"node:async_hooks\";var q_=new c$;function _s(e,t){if(typeof e!==\"object\"||e===null)return;try{let n=Object.getOwnPropertyDescriptor(e,t);return n&&\"value\"in n?n.value:void 0}catch{return}}function nl(e){let t=_s(e,\"traceId\"),n=_s(e,\"spanId\"),r=_s(e,\"traceFlags\");if(typeof t!==\"string\"||typeof n!==\"string\")return;if(!/^[0-9a-f]{32}$/.test(t)||/^0+$/.test(t))return;if(!/^[0-9a-f]{16}$/.test(n)||/^0+$/.test(n))return;if(r!==void 0&&(typeof r!==\"string\"||!/^[0-9a-f]{2}$/.test(r)))return;return{traceId:t,spanId:n,...r===void 0?{}:{traceFlags:r}}}function Kr(){return nl(q_.getStore())}function ws(e,t){let n=nl(e),r=_s(e,\"addLink\");return q_.run(n?{...n,addLink:typeof r===\"function\"?r:void 0}:void 0,t)}import{AsyncLocalStorage as l$}from\"node:async_hooks\";import{createHash as u$}from\"node:crypto\";var Hr=new l$;function rl(e){let t=Hr.getStore(),n=Kr();return(...r)=>Hr.run(t,()=>ws(n,()=>e(...r)))}function ol(e,t){let n=Hr.getStore();if(!n||typeof e!==\"string\")return t();let r;try{r=`mcp_${u$(\"sha256\").update(\"opengeni:mcp-call:v1\\x00\").update(n.scope).update(\"\\x00\").update(e).digest(\"hex\").slice(0,32)}`}catch{return t()}if(n.callKey===r)return t();return Hr.run({...n,callKey:r,nextRequest:0},t)}function j_(e){let t=Hr.getStore(),n=performance.now(),r=t?.callKey?{mcpCallKey:t.callKey}:{},o=e===\"network_headers\"&&t?++t.nextRequest:void 0,s;try{s=t?.observer.startSpan(`mcp.phase.${e}`,{...r,...o===void 0?{}:{attempt:o}})}catch{}let i=s??Kr(),a=!1;return{traceContext:i,run:(c)=>ws(i,c),end:(c=\"completed\")=>{if(a)return;a=!0;let l=Math.max(0,performance.now()-n);try{s?.end({attributes:{outcome:c,\"opengeni.duration_ms\":l},...c===\"completed\"?{}:{error:Error(`MCP phase ${c}`)}})}catch{}try{t?.observer.observeHistogram({name:\"opengeni_mcp_phase_duration_seconds\",help:\"MCP execution phase duration; nested phases are not additive.\",labels:{phase:e,outcome:c},value:l/1000})}catch{}}}}async function tt(e,t,n){let r=j_(e);try{let o=await r.run(t),s=\"completed\";try{s=n?.(o)??s}catch{}return r.end(s),o}catch(o){throw r.end(\"failed\"),o}}var w4=p$();var x4=new Set([...wa.options,\"unprovisioned\"]);var m$=[\"workspace_writer_unattributed\"],S4=new Set(m$);var f$=new Set([\"agent_command_wake_failed\",\"api_startup_failed\",\"api_uncaught_exception\",\"api_unhandled_rejection\",\"artifact_materializer_native_input_framing_failed\",\"artifact_materializer_native_snapshot_open_failed\",\"artifact_materializer_native_state_mismatch\",\"artifact_materializer_source_content_type_mismatch\",\"artifact_materializer_source_open_failed\",\"artifact_materializer_source_revalidation_failed\",\"artifact_materializer_source_stream_identity_mismatch\",\"cleared_goal_live_publish_failed\",\"codex_failover_checkpoint_failed\",\"codex_fleet_shadow_failed\",\"codex_lease_loss_checkpoint_failed\",\"codex_active_credential_read_failed\",\"command_yield_timeout\",\"conflict\",\"control_wake_dispatch_failed\",\"fenced_event_live_publish_failed\",\"forbidden\",\"host_export_batch_delivery_failed\",\"host_export_failure_settlement_stale\",\"host_export_pump_iteration_failed\",\"host_export_retention_prune_failed\",\"idempotency_conflict\",\"incompatible_exposed_ports\",\"internal_error\",\"knowledge_index_defer_failed\",\"knowledge_index_embedding_failed\",\"knowledge_index_failed\",\"knowledge_index_persistence_failed\",\"knowledge_index_usage_limit_reached\",\"limit_exceeded\",\"mcp_close_failed\",\"mcp_connect_failed\",\"mcp_tool_call_failed\",\"mcp_tools_list_failed\",\"mcp_transport_failed\",\"memory_edit_embedding_failed\",\"memory_hybrid_vector_failed\",\"memory_save_embedding_failed\",\"nats_auth_callout_start_failed\",\"nested_agent_depth_exceeded\",\"nested_agent_depth_override_forbidden\",\"not_found\",\"oauth_operation_failed\",\"otlp_export_failed\",\"parallel_session_title_generation_failed\",\"parallel_session_title_persistence_failed\",\"payment_required\",\"provider_verification_failed\",\"sandbox_channel_a_cancelled\",\"sandbox_channel_a_lifecycle_conflict\",\"sandbox_channel_a_operation_failed\",\"sandbox_channel_a_provider_busy\",\"sandbox_channel_a_provider_unavailable\",\"screenshot_capture_failed\",\"session_event_live_publish_failed\",\"session_archive_failed\",\"session_archive_hash_mismatch\",\"session_archive_object_missing\",\"session_archive_storage_failed\",\"session_workflow_wake_failed\",\"snapshot_operation_failed\",\"startup_dependency_retry\",\"temporal_sdk_failure_logged\",\"tool_list_too_large\",\"tool_result_too_large\",\"codemode_operation_failed\",\"unauthenticated\",\"upstream_unavailable\",\"validation_failed\",\"worker_draining\",\"worker_operation_failed\",\"worker_shutdown_request_failed\",\"worker_cleanup_drain_exhausted\",\"workspace_control_live_publish_failed\"]),I4=new Map([...f$].map((e)=>[e,e.replaceAll(\"_\",\" \")]));var ht=ho(pk(),1),ER=ho(Yk(),1),PR=ho(uR(),1);var OL={test:()=>!0};function ru(e,t){try{return new RegExp(e,t)}catch{}if(t.includes(\"u\"))try{return new RegExp(e,t.replaceAll(\"u\",\"\"))}catch{}return OL}var dR=Object.assign((e,t)=>ru(e,t),{code:\"compileSchemaPattern\"});var $L=/^-?(?:0|[1-9]\\d*)$/u,ML=/^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?$/u;function pR(e,t){let n=e,r=!1;for(let o=0;o<4;o+=1){if(t(n))break;let s=new Map;for(let a of t.errors??[]){let c=qL(n,a);if(c===It)continue;s.set(a.instancePath,c)}if(s.size===0)break;let i=structuredClone(n);for(let[a,c]of s)if(!DL(i,a,c))return;n=i,r=!0}return r?n:void 0}var It=Symbol(\"no replacement\");function qL(e,t){if(t.keyword!==\"type\"||t.instancePath===\"\")return It;let n=String(t.params.type??\"\").split(\",\"),r=NL(e,t.instancePath);if(typeof r!==\"string\")return It;let o=zL(r,n);if(o!==void 0)return o;if(n.includes(\"boolean\")&&(r===\"true\"||r===\"false\"))return r===\"true\";return jL(r,n)}function zL(e,t){let n=t.includes(\"integer\"),r=t.includes(\"number\");if(!n&&!r)return;if(r?!ML.test(e):!$L.test(e))return;let o=Number(e);if(!Number.isFinite(o))return;if(!r&&!Number.isSafeInteger(o))return;return o}function jL(e,t){let n=t.includes(\"object\"),r=t.includes(\"array\");if(!n&&!r)return It;let o=e.trim();if(!(n&&o.startsWith(\"{\"))&&!(r&&o.startsWith(\"[\")))return It;let s;try{s=JSON.parse(o)}catch{return It}if(Array.isArray(s))return r?s:It;if(s!==null&&typeof s===\"object\")return n?s:It;return It}function mR(e){return e.split(\"/\").slice(1).map((t)=>t.replace(/~1/gu,\"/\").replace(/~0/gu,\"~\"))}function NL(e,t){let n=e;for(let r of mR(t)){if(n===null||typeof n!==\"object\")return;if(!Object.hasOwn(n,r))return;n=n[r]}return n}function DL(e,t,n){let r=mR(t),o=r.pop();if(o===void 0)return!1;let s=e;for(let i of r){if(s===null||typeof s!==\"object\"||!Object.hasOwn(s,i))return!1;s=s[i]}if(s===null||typeof s!==\"object\"||!Object.hasOwn(s,o))return!1;return s[o]=n,!0}import{createHash as WL}from\"node:crypto\";var UL=8,fR=120,gR=160,wi=10,LL=60;function yR(e,t){let n=[],r=new Set,o=0,s=GL(e??[]);if(t)try{s=BL(e??[],t)}catch{}for(let i of s){if(r.has(i.message))continue;if(r.add(i.message),n.length<UL)n.push(i);else o+=1}return{issues:n,omittedIssueCount:o}}function GL(e){let t=e.find((r)=>r.keyword===\"anyOf\"||r.keyword===\"oneOf\");if(!t)return e.map(au);let n=Ie(kt(t.instancePath));return[{path:n,keyword:t.keyword,message:`${lo(n)} must match ${t.keyword===\"oneOf\"?\"exactly one\":\"one\"} declared alternative input format`}]}function BL(e,t){if(!e.some((d)=>d.keyword===\"anyOf\"||d.keyword===\"oneOf\"))return e.map(au);let n=[],r=new Map(e.map((d,f)=>[d,f])),o=JL(t.schema,t.arguments,e),s=vi(o.uncertain,(d)=>d.instancePath,!1),i=(d)=>!o.sites.has(An(d.schemaPath,d.instancePath))&&ou(d.instancePath).some((f)=>(s.get(f)??[]).some((h)=>d.schemaPath===h.prefix||d.schemaPath.startsWith(`${h.prefix}/`))),a=(d,f,h)=>r.get(d)<r.get(f)&&!o.sites.has(An(d.schemaPath,d.instancePath))&&!i(d)&&VL(d,f,h);for(let d of e){if(d.keyword!==\"anyOf\"&&d.keyword!==\"oneOf\")continue;let f=An(d.schemaPath,d.instancePath),h=o.ambiguous.has(f)?void 0:o.schemas.has(f)?o.schemas.get(f):uo(t.schema,d.schemaPath);if(!Array.isArray(h)||h.some((C)=>!F(C)&&typeof C!==\"boolean\")){n.push({error:d,branchPrefixes:[],selected:void 0,unresolved:!0,replacement:{path:Ie(kt(d.instancePath)),keyword:d.keyword,message:`${lo(Ie(kt(d.instancePath)))} must match ${d.keyword===\"oneOf\"?\"exactly one\":\"one\"} declared alternative input format`}});continue}let y=h,_=y.map((C,D)=>F(C)?vR(C,`${d.schemaPath}/${D}`,t.schema):[`${d.schemaPath}/${D}`]),E=y.map((C)=>F(C)?_R(C,t.schema):[]),T=_i(t.arguments,kt(d.instancePath)),A=E.flatMap((C,D)=>y[D]===!1||C.some((V)=>{let L=_i(T.value,V.path);return L.present&&!V.values.some((H)=>H===L.value)})?[]:[D]),x=A.length===1&&A.length<y.length?A[0]:void 0,K;if(x===void 0){let C=E[0]?.find((oe)=>E.every((Te)=>Te.some((je)=>iu(je.path,oe.path)))),D=C&&_i(T.value,C.path),V=C&&E.map((oe)=>oe.find((Te)=>iu(Te.path,C.path))),L=V?.flatMap((oe)=>oe.values),H=L&&[...new Set(L)];if(C&&D&&V&&H?.length&&(D.present&&!H.some((oe)=>oe===D.value)||!D.present&&V.every((oe)=>oe.required))){let oe=Ie([...kt(d.instancePath),...C.path]),Te=xR(H),je=!D.present&&V.every((yT)=>yT.required);K={path:oe,keyword:je?\"required\":d.keyword,message:je?`missing required property \"${oe}\" (selects one of ${Te})`:`${lo(oe)} must be one of ${Te}`}}}n.push({error:d,branchPrefixes:_,selected:x,replacement:K})}let c=new Map,l=vi(e,(d)=>d.instancePath,!0),u=vi(n,(d)=>d.error.instancePath,!0),p=new WeakMap,m=(d,f)=>{let h=p.get(f);if(!h)h=vi(f,(x)=>x.error.instancePath,!1),p.set(f,h);let y=ou(d.instancePath).flatMap((x)=>h.get(x)??[]);for(let x of y){if(d===x.error)continue;if(x.unresolved&&r.get(d)<r.get(x.error)&&!o.sites.has(An(d.schemaPath,d.instancePath))&&!i(d)&&(d.instancePath===x.error.instancePath||d.instancePath.startsWith(`${x.error.instancePath}/`)))return[];let K=x.branchPrefixes.flatMap((C,D)=>a(d,x.error,C)?[D]:[]);if(K.length&&(x.selected===void 0||!K.includes(x.selected)))return[]}let _=y.find((x)=>x.error===d);if(!_){let x=au(d);return[i(d)?{...x,message:`an independent constraint or alternative reports: ${x.message}`}:x]}if(_.selected!==void 0)return[];if(_.replacement)return[_.replacement];let E=c.get(_);if(E)return[E];let T=_.branchPrefixes.slice(0,wi).map((x,K)=>{let C=(u.get(_.error.instancePath)??[]).filter((H)=>r.get(H.error)<r.get(_.error)&&a(H.error,_.error,x)),D=(l.get(_.error.instancePath)??[]).filter((H)=>H!==_.error&&a(H,_.error,x)).flatMap((H)=>m(H,C)).map((H)=>H.message),V=[...new Set(D)],L=V.slice(0,2);if(V.length>L.length)L.push(\"other declared requirements\");return`alternative ${K+1}${L.length?` (${L.join(\"; \")})`:\"\"}`});if(_.branchPrefixes.length>wi)T.push(\"other declared alternatives\");let A={path:Ie(kt(d.instancePath)),keyword:d.keyword,message:xr(`${lo(Ie(kt(d.instancePath)))} must match ${d.keyword===\"oneOf\"?\"exactly one\":\"one\"} declared input format: ${T.join(\" or \")}`,640)};return c.set(_,A),[A]};return e.flatMap((d)=>m(d,n))}function vi(e,t,n){let r=new Map;for(let o of e){let s=n?ou(t(o)):[t(o)];for(let i of s){let a=r.get(i);if(a)a.push(o);else r.set(i,[o])}}return r}function ou(e){let t=[e],n=e;while(n)n=n.slice(0,n.lastIndexOf(\"/\")),t.push(n);return t}function VL(e,t,n){return(e.instancePath===t.instancePath||e.instancePath.startsWith(`${t.instancePath}/`))&&n.some((r)=>e.schemaPath===r||e.schemaPath.startsWith(`${r}/`))}function F(e){return e!==null&&typeof e===\"object\"&&!Array.isArray(e)}var hR=new WeakMap,su=new WeakMap,bR=new WeakMap;function uo(e,t,n){let r=hR.get(e);if(!r){r=new Map([[\"#\",e]]);let a=new Set,c=new WeakMap,l=new WeakMap,u=new Set,p=(d,f)=>{if(a.has(d))return;let h=r.get(d);if(h&&h!==f)r.delete(d),a.add(d);else r.set(d,f)},m=(d,f,h,y)=>{if(u.has(d))return;u.add(d),p(f,d);let _=h;if(typeof d.$id===\"string\"){_=d.$id;try{if(h)_=new URL(_,h).href}catch{}p(_,d),p(`${_}#`,d),y=\"#\"}if(c.set(d,_),l.set(d,y),typeof d.$anchor===\"string\"){if(p(`#${d.$anchor}`,d),_)p(`${_}#${d.$anchor}`,d)}for(let[E,T]of FL(d))m(T,`${f}/${E}`,_,`${y}/${E}`);u.delete(d)};m(e,\"#\",\"\",\"#\"),hR.set(e,r),su.set(e,c),bR.set(e,l)}let o=n&&su.get(e)?.get(n);if(o)if(t.startsWith(\"#\"))t=`${o}${t}`;else try{t=new URL(t,o).href}catch{}let s=r.get(t);if(s)return s;let i=t.lastIndexOf(\"/\");while(i>=0){let a=r.get(t.slice(0,i));if(a){let c=a;for(let l of kt(t.slice(i))){if(!c||typeof c!==\"object\")return;c=c[l]}return c}i=i===0?-1:t.lastIndexOf(\"/\",i-1)}return}function FL(e){let t=[];for(let n of[\"$defs\",\"definitions\",\"properties\",\"patternProperties\",\"dependentSchemas\",\"dependencies\"]){let r=e[n];if(F(r)){for(let[o,s]of Object.entries(r))if(F(s))t.push([`${n}/${tn(o)}`,s])}}for(let n of[\"anyOf\",\"oneOf\",\"allOf\",\"prefixItems\",\"items\"]){let r=e[n];if(Array.isArray(r))r.forEach((o,s)=>{if(F(o))t.push([`${n}/${s}`,o])})}for(let n of[\"items\",\"additionalItems\",\"additionalProperties\",\"unevaluatedProperties\",\"not\",\"if\",\"then\",\"else\",\"contains\",\"propertyNames\"]){let r=e[n];if(F(r))t.push([n,r])}return t}function tn(e){return e.replace(/~/gu,\"~0\").replace(/\\//gu,\"~1\")}function An(e,t){return JSON.stringify([e,t])}function JL(e,t,n){let r=new Set,o=new Map,s=[],i=new Set,a=new Map(n.filter((m)=>m.keyword===\"if\").map((m)=>[An(m.schemaPath,m.instancePath),m.params.failingKeyword])),c=new Set,l=new WeakMap,u=0,p=(m,d,f,h,y)=>{let _=l.get(m);if(_===void 0)_=u++,l.set(m,_);let E=JSON.stringify([_,d,h,y]);if(c.has(E))return;c.add(E);let T=su.get(e)?.get(m),A=T&&bR.get(e)?.get(m),x=[...new Set([d,...A?[A,`${T}${A}`]:[]])];for(let C of x)for(let[D,V]of Object.entries(m)){let L=An(`${C}/${D}`,h);if(y)r.add(L);if(i.has(L))continue;if(o.has(L)&&o.get(L)!==V)o.delete(L),i.add(L);else o.set(L,V)}if(typeof m.$ref===\"string\"){let C=uo(e,m.$ref,m);if(F(C))p(C,m.$ref,f,h,y)}if(Array.isArray(m.allOf))m.allOf.forEach((C,D)=>{if(F(C))p(C,`${d}/allOf/${D}`,f,h,y)});for(let C of[\"anyOf\",\"oneOf\"]){let D=m[C];if(!Array.isArray(D))continue;let V=D.flatMap((H,oe)=>{if(H===!1)return[];if(!F(H))return[oe];return _R(H,e).some((Te)=>{let je=_i(f,Te.path);return je.present&&!Te.values.includes(je.value)})?[]:[oe]}),L=V.length===1&&V.length<D.length?V[0]:void 0;D.forEach((H,oe)=>{if(F(H))p(H,`${d}/${C}/${oe}`,f,h,y&&oe===L)})}if(f&&typeof f===\"object\"&&!Array.isArray(f)){if(F(m.properties)){for(let[C,D]of Object.entries(m.properties))if(F(D)&&Object.hasOwn(f,C))p(D,`${d}/properties/${tn(C)}`,f[C],`${h}/${tn(C)}`,y)}if(F(m.dependentSchemas)){for(let[C,D]of Object.entries(m.dependentSchemas))if(F(D)&&Object.hasOwn(f,C))p(D,`${d}/dependentSchemas/${tn(C)}`,f,h,y)}}if(f&&typeof f===\"object\"&&!Array.isArray(f)){let C=F(m.properties)?m.properties:{},D=F(m.patternProperties)?Object.entries(m.patternProperties).map(([V,L])=>[V,ru(V,\"u\"),L]):[];for(let[V,L]of Object.entries(f)){let H=!1;for(let[oe,Te,je]of D)if(Te.test(V)){if(H=!0,F(je))p(je,`${d}/patternProperties/${tn(oe)}`,L,`${h}/${tn(V)}`,y)}if(!Object.hasOwn(C,V)&&!H&&F(m.additionalProperties))p(m.additionalProperties,`${d}/additionalProperties`,L,`${h}/${tn(V)}`,y)}if(F(m.dependencies)){for(let[V,L]of Object.entries(m.dependencies))if(F(L)&&Object.hasOwn(f,V))p(L,`${d}/dependencies/${tn(V)}`,f,h,y)}}if(Array.isArray(f)){let C=Array.isArray(m.prefixItems)?m.prefixItems:Array.isArray(m.items)?m.items:[],D=Array.isArray(m.prefixItems)?\"prefixItems\":\"items\";f.forEach((V,L)=>{let H=C[L]??(F(m.items)?m.items:m.additionalItems);if(F(H))p(H,C[L]?`${d}/${D}/${L}`:`${d}/${F(m.items)?\"items\":\"additionalItems\"}`,V,`${h}/${L}`,y)})}for(let C of[\"contains\",\"propertyNames\",\"unevaluatedProperties\",\"unevaluatedItems\"]){let D=m[C];if(F(D))for(let V of vR(D,`${d}/${C}`,e).slice(1))s.push({prefix:V,instancePath:h})}let K=a.get(An(`${d}/if`,h));if((K===\"then\"||K===\"else\")&&F(m[K]))p(m[K],`${d}/${K}`,f,h,y);c.delete(E)};return uo(e,\"#\"),p(e,\"#\",t,\"\",!0),{sites:r,schemas:o,ambiguous:i,uncertain:s}}function vR(e,t,n){let r=[t],o=new Set,s=(i)=>{if(o.has(i))return;if(o.add(i),typeof i.$ref===\"string\"){let a=uo(n,i.$ref,i);if(F(a))r.push(i.$ref),s(a)}for(let a of[\"properties\",\"patternProperties\",\"dependentSchemas\"]){let c=i[a];if(F(c)){for(let l of Object.values(c))if(F(l))s(l)}}for(let a of[\"anyOf\",\"oneOf\",\"allOf\",\"prefixItems\"]){let c=i[a];if(Array.isArray(c)){for(let l of c)if(F(l))s(l)}}for(let a of[\"items\",\"additionalItems\",\"additionalProperties\",\"unevaluatedProperties\",\"not\",\"if\",\"then\",\"else\",\"contains\",\"propertyNames\"]){let c=i[a];if(F(c))s(c);else if(a===\"items\"&&Array.isArray(c)){for(let l of c)if(F(l))s(l)}}};return s(e),r}function _R(e,t){let n=[],r=new Set,o=(i,a,c)=>{if(r.has(i))return;if(r.add(i),typeof i.$ref===\"string\"){let u=uo(t,i.$ref,i);if(F(u))o(u,a,c)}let l=\"const\"in i?[i.const]:Array.isArray(i.enum)?i.enum:[];if(l.length&&l.every((u)=>u===null||[\"string\",\"number\",\"boolean\"].includes(typeof u)))n.push({path:a,values:l,required:c});if(Array.isArray(i.allOf)){for(let u of i.allOf)if(F(u))o(u,a,c)}if(F(i.properties)){for(let[u,p]of Object.entries(i.properties))if(F(p))o(p,[...a,u],c&&Array.isArray(i.required)&&i.required.includes(u))}r.delete(i)};o(e,[],!0);let s=[];for(let i of n){let a=s.findIndex((c)=>iu(c.path,i.path));if(a<0)s.push(i);else{let c=s[a];s[a]={path:i.path,values:c.values.filter((l)=>i.values.includes(l)),required:c.required||i.required}}}return s}function _i(e,t){let n=e;for(let r of t){if(n===null||typeof n!==\"object\"||!Object.hasOwn(n,r))return{present:!1,value:void 0};n=n[r]}return{present:!0,value:n}}function iu(e,t){return e.length===t.length&&e.every((n,r)=>n===t[r])}function wR(e,t=0){let n=e.map((r)=>r.message);if(t>0)n.push(`and ${t} more ${t===1?\"problem\":\"problems\"}`);return n.join(\"; \")}function au(e){let t=e.params??{},n=kt(e.instancePath),r=lo(Ie(n)),o=e.propertyName!==void 0?\"propertyNames\":e.keyword;switch(o){case\"required\":{let s=Ie([...n,String(t.missingProperty)]);return{path:s,keyword:e.keyword,message:`missing required property \"${s}\"`}}case\"dependentRequired\":case\"dependencies\":{let s=Ie([...n,String(t.missingProperty)]),i=Ie([...n,String(t.property)]);return{path:s,keyword:e.keyword,message:`missing required property \"${s}\" (required when \"${i}\" is present)`}}case\"additionalProperties\":case\"unevaluatedProperties\":{let s=t.additionalProperty??t.unevaluatedProperty,i=Ie([...n,String(s)]);return{path:i,keyword:e.keyword,message:`property \"${i}\" is not allowed`}}case\"type\":{let s=Array.isArray(t.type)?t.type.join(\" or \"):String(t.type);return{path:Ie(n),keyword:e.keyword,message:`${r} must be ${xr(s,gR)}`}}case\"enum\":{let s=Array.isArray(t.allowedValues)?xR(t.allowedValues):null;return{path:Ie(n),keyword:e.keyword,message:s?`${r} must be one of ${s}`:`${r} must be one of the allowed values`}}case\"const\":return{path:Ie(n),keyword:e.keyword,message:`${r} must equal ${SR(t.allowedValue)}`};case\"propertyNames\":return{path:Ie(n),keyword:o,message:`${r} has a property name the schema does not allow`};default:return{path:Ie(n),keyword:xr(e.keyword,64),message:`${r} ${xr(cu(e.message??\"is invalid\"),gR)}`}}}function lo(e){return e?`\"${e}\"`:\"arguments\"}function kt(e){if(!e)return[];return e.slice(1).split(\"/\").map((t)=>t.replace(/~1/gu,\"/\").replace(/~0/gu,\"~\"))}function Ie(e){let t=\"\";for(let n of e){if(/^(?:0|[1-9][0-9]*)$/u.test(n))t+=`[${n}]`;else if(!t)t=cu(n);else if(/^[A-Za-z_$][A-Za-z0-9_$-]*$/u.test(n))t+=`.${n}`;else t+=`[${JSON.stringify(n)}]`;if(t.length>fR)break}return xr(t,fR)}function xR(e){if(e.length===0)return null;let t=e.slice(0,wi).map(SR);if(e.length>wi)t.push(\"...\");return t.join(\", \")}function SR(e){let t;try{t=JSON.stringify(e)??String(e)}catch{t=\"the schema constant\"}return xr(cu(t),LL)}function cu(e){return e.replace(/[\\u0000-\\u001f\\u007f]+/gu,\" \").trim()}function xr(e,t){return e.length<=t?e:`${e.slice(0,t-3)}...`}class xi extends Error{code=\"catalog_stale\";constructor(){super(\"Tool catalog is stale for the active gateway\");this.name=\"ToolGatewayCatalogStaleError\"}}class mt extends Error{code=\"tool_not_found\";constructor(){super(\"Tool is not present in the active gateway catalog\");this.name=\"ToolGatewayToolNotFoundError\"}}class Cn extends Error{code=\"approval_required\";constructor(){super(\"Tool requires human approval\");this.name=\"ToolGatewayApprovalRequiredError\"}}class lu extends Error{code=\"tool_blocked\";constructor(){super(\"This action is blocked by your tool permissions\");this.name=\"ToolGatewayBlockedError\"}}class uu extends Error{code=\"catalog_integrity_failed\";constructor(){super(\"Tool catalog digest does not match its authoritative content\");this.name=\"ToolGatewayCatalogIntegrityError\"}}class du extends Error{code=\"catalog_too_large\";constructor(){super(\"Tool catalog exceeds the maximum serialized size\");this.name=\"ToolGatewayCatalogTooLargeError\"}}class nn extends Error{code=\"tool_path_collision\";constructor(e,t){super(t===\"extends_leaf\"?`Tool path ${e.join(\".\")} extends a tool leaf`:`Tool path ${e.join(\".\")} collides`);this.name=\"ToolGatewayPathCollisionError\"}}class pu extends Error{code=\"tool_schema_invalid\";constructor(e){super(\"Tool is unavailable because its input or output schema is invalid\",{cause:e});this.name=\"ToolGatewaySchemaCompilationError\"}}class Si extends Error{code=\"invalid_tool_arguments\";issues;omittedIssueCount;summary;constructor(e=[],t=0){let n=wR(e,t);super(n?`Tool arguments do not match the tool's input schema: ${n}`:\"Tool arguments do not match the tool's input schema\");this.name=\"ToolGatewayInputValidationError\",this.issues=e,this.omittedIssueCount=t,this.summary=n}}class Ii extends Error{code=\"invalid_tool_result\";constructor(){super(\"Tool result does not match the gateway catalog output schema\");this.name=\"ToolGatewayOutputValidationError\"}}function ft(e){return WL(\"sha256\").update(JSON.stringify(mu(e)),\"utf8\").digest(\"hex\")}function po(e,t){return ft({domain:\"opengeni.tool-definition\",version:1,accountId:e.accountId,workspaceId:e.workspaceId,entry:t})}function rn(e,t){return e<t?-1:e>t?1:0}function mu(e){if(Array.isArray(e))return e.map(mu);if(e!==null&&typeof e===\"object\")return Object.fromEntries(Object.entries(e).sort(([t],[n])=>rn(t,n)).map(([t,n])=>[t,mu(n)]));return e}function Ri(e,t){let n=kR();for(let r of e.entries)KL(n,r);return[`// Generated by ${t.generatedBy}. Do not edit.`,`// ${t.catalogDigestLabel??\"Tool catalog digest\"}: ${e.digest}`,...t.typedResultWrapperType?[\"// Typed calls normally return their structured output. If image blocks are present,\",\"// they return CodemodeMultimodalValue<T> with local image paths and original content.\"]:[],`import type { ${[t.callOptionsType,t.fallbackResultType,...t.typedResultWrapperType?[t.typedResultWrapperType]:[]].join(\", \")} } from ${JSON.stringify(t.moduleSpecifier)};`,\"\",`declare module ${JSON.stringify(t.moduleSpecifier)} {`,` interface ${t.interfaceName} {`,...RR(n,4,t),\" }\",\"}\",\"\",\"export {};\",\"\"].join(`\n`)}function fu(e){return gt(e,e,new Set,0)}function kR(){return{children:new Map,entry:null}}function KL(e,t){let n=e;for(let[r,o]of t.codemodePath.entries()){if(n.entry)throw new nn(t.codemodePath,\"extends_leaf\");let s=n.children.get(o);if(!s)s=kR(),n.children.set(o,s);if(n=s,r===t.codemodePath.length-1){if(n.entry||n.children.size>0)throw new nn(t.codemodePath,\"collision\");n.entry=t}}}function RR(e,t,n){let r=[];for(let[o,s]of[...e.children].sort(([i],[a])=>rn(i,a))){if(s.entry){let i=s.entry,a=fu(i.inputSchema),c=i.outputSchema?fu(i.outputSchema):null,l=c?n.typedResultWrapperType?`${c} | ${n.typedResultWrapperType}<${c}>`:c:n.fallbackResultType,u=tG(i.description??i.title);if(u)r.push(...nG(u,t));r.push(`${En(t)}readonly ${o}: (`),r.push(`${En(t+2)}argumentsValue${HL(i.inputSchema)?\"?\":\"\"}: ${a},`),r.push(`${En(t+2)}options?: ${n.callOptionsType},`),r.push(`${En(t)}) => Promise<${l}>;`);continue}r.push(`${En(t)}readonly ${o}: {`),r.push(...RR(s,t+2,n)),r.push(`${En(t)}};`)}return r}function HL(e){if(!Pn(e))return!1;return(Array.isArray(e.required)?e.required.filter((n)=>typeof n===\"string\"):[]).length===0&&(e.type===\"object\"||Pn(e.properties))}function gt(e,t,n,r){if(r>48||e===!0)return\"unknown\";if(e===!1)return\"never\";if(!Pn(e))return\"unknown\";if(typeof e.$ref===\"string\"){if(!e.$ref.startsWith(\"#/\")||n.has(e.$ref))return\"unknown\";let a=eG(t,e.$ref);if(a===void 0)return\"unknown\";let c=new Set(n);return c.add(e.$ref),gt(a,t,c,r+1)}if(Object.hasOwn(e,\"const\"))return ki(e.const);if(Array.isArray(e.enum))return mo(e.enum.map(ki));let o=[];if(Array.isArray(e.oneOf))o.push(mo(e.oneOf.map((a)=>gt(a,t,n,r+1))));if(Array.isArray(e.anyOf))o.push(mo(e.anyOf.map((a)=>gt(a,t,n,r+1))));if(Array.isArray(e.allOf))o.push(IR(e.allOf.map((a)=>gt(a,t,n,r+1))));if(o.length>0){let a=IR(o);return e.nullable===!0?mo([a,\"null\"]):a}let i=(Array.isArray(e.type)?e.type.filter((a)=>typeof a===\"string\"):typeof e.type===\"string\"?[e.type]:QL(e)).map((a)=>ZL(a,e,t,n,r+1));if(e.nullable===!0)i.push(\"null\");return mo(i.length>0?i:[\"unknown\"])}function ZL(e,t,n,r,o){if(e===\"null\"||e===\"boolean\"||e===\"string\")return e;if(e===\"integer\"||e===\"number\")return\"number\";if(e===\"array\")return YL(t,n,r,o);if(e!==\"object\")return\"unknown\";return XL(t,n,r,o)}function YL(e,t,n,r){if(Array.isArray(e.prefixItems)){let s=e.prefixItems.map((a)=>gt(a,t,n,r+1));if(e.items===!1)return`readonly [${s.join(\", \")}]`;let i=e.items===void 0||e.items===!0?\"unknown\":gt(e.items,t,n,r+1);return`readonly [${s.join(\", \")}${s.length>0?\", \":\"\"}...${i}[]]`}return`readonly (${e.items===void 0||e.items===!0?\"unknown\":gt(e.items,t,n,r+1)})[]`}function XL(e,t,n,r){let o=Pn(e.properties)?e.properties:{},s=new Set(Array.isArray(e.required)?e.required.filter((c)=>typeof c===\"string\"):[]),i=Object.entries(o).sort(([c],[l])=>rn(c,l)),a=i.map(([c,l])=>`readonly ${gu(c)}${s.has(c)?\"\":\"?\"}: ${gt(l,t,n,r+1)}`);for(let c of[...s].filter((l)=>!Object.hasOwn(o,l)).sort(rn))a.push(`readonly ${gu(c)}: unknown`);if(e.additionalProperties!==!1){if(i.length===0&&e.additionalProperties!==void 0&&e.additionalProperties!==!0)return`Readonly<Record<string, ${gt(e.additionalProperties,t,n,r+1)}>>`;a.push(\"readonly [key: string]: unknown\")}return a.length===0?\"Record<string, never>\":`{ ${a.join(\"; \")} }`}function QL(e){if(Pn(e.properties)||Object.hasOwn(e,\"additionalProperties\"))return[\"object\"];if(Object.hasOwn(e,\"items\")||Array.isArray(e.prefixItems))return[\"array\"];return[]}function eG(e,t){let n=e;for(let r of t.slice(2).split(\"/\")){if(!Pn(n))return;let o=r.replace(/~1/gu,\"/\").replace(/~0/gu,\"~\");if(!Object.hasOwn(n,o))return;n=n[o]}return n}function ki(e){if(e===null||typeof e===\"string\"||typeof e===\"number\"||typeof e===\"boolean\")return JSON.stringify(e);if(Array.isArray(e))return`readonly [${e.map(ki).join(\", \")}]`;if(Pn(e))return`{ ${Object.entries(e).sort(([t],[n])=>rn(t,n)).map(([t,n])=>`readonly ${gu(t)}: ${ki(n)}`).join(\"; \")} }`;return\"unknown\"}function mo(e){let t=[...new Set(e)];if(t.includes(\"unknown\"))return\"unknown\";if(t.length===0)return\"never\";return t.length===1?t[0]:t.map(TR).join(\" | \")}function IR(e){let t=[...new Set(e.filter((n)=>n!==\"unknown\"))];return t.length===0?\"unknown\":t.length===1?t[0]:t.map(TR).join(\" & \")}function TR(e){return/[|&]/u.test(e)?`(${e})`:e}function gu(e){return/^[A-Za-z_$][A-Za-z0-9_$]*$/u.test(e)?e:JSON.stringify(e)}function tG(e){if(!e)return null;let t=e.replace(/\\s+/gu,\" \").trim().replace(/\\*\\//gu,\"*\\\\/\");if(!t)return null;return t.length<=512?t:`${t.slice(0,509)}...`}function nG(e,t){return[`${En(t)}/** ${e} */`]}function En(e){return\" \".repeat(e)}function Pn(e){return e!==null&&typeof e===\"object\"&&!Array.isArray(e)}class OR{definitions;entries;constructor(e){this.definitions=e;this.entries=e.map(({entry:t})=>t)}create(e){return new $R(e.catalogDigest,this.definitions,e.authorize,e.requireApproval,e.confirmModelApproval,e.resolveApproval,e.resolveArguments)}}class $R{catalogDigest;authorize;requireApproval;confirmModelApproval;resolveApproval;resolveArguments;byIdentity=new Map;byModelName=new Map;constructor(e,t,n,r,o,s,i){this.catalogDigest=e;this.authorize=n;this.requireApproval=r;this.confirmModelApproval=o;this.resolveApproval=s;this.resolveArguments=i;for(let a of t)this.byIdentity.set(Ti(a.entry.identity),a),this.byModelName.set(a.entry.modelName,a)}async call(e,t={}){return await(await this.prepareCallWithModelApproval(e,t,!1)).execute()}async prepareCall(e,t={}){return await this.prepareCallWithModelApproval(e,t,!1)}async prepareCallWithModelApproval(e,t,n){return ol(t.sourceCallId??e.operationId,async()=>{let r=await tt(\"gateway_policy\",()=>this.prepareCallCore(e,t,n));return{...r,execute:rl(r.execute)}})}async prepareCallCore(e,t,n){let r=Ff.parse({operationId:e.operationId,catalogDigest:e.catalogDigest,identity:e.identity,arguments:e.arguments}),o=r.operationId??e.operationId,s=e.caller;if(r.catalogDigest!==this.catalogDigest)throw new xi;let i=this.byIdentity.get(Ti(r.identity));if(!i)throw new mt;if(!this.resolveApproval&&this.requireApproval?.(i.entry,s,t))throw new Cn;let a=r.arguments;if(!i.validateInput(a)){let p=iG(a)?pR(a,i.diagnoseInput()):void 0;if(!p)throw CR(i,a);if(!i.validateInput(p))throw CR(i,p);a=p}if(s.kind===\"model\"&&!this.resolveApproval&&i.entry.approval===\"human\"&&!n)throw new Cn;let c={operationId:o,catalogDigest:r.catalogDigest,identity:r.identity,arguments:a,caller:s};await tt(\"provider_authorization\",()=>this.authorize?.({call:c,entry:i.entry}));let l=this.resolveApproval?await this.resolveApproval({call:c,entry:i.entry}):i.entry.approval===\"human\"?\"ask\":\"allow\";if(l===\"block\")throw new lu;if(this.resolveApproval&&l===\"ask\"&&(s.kind===\"model\"?!n:t.transportMeta?.approvalConfirmed!==!0))throw new Cn;if(l===\"ask\")await tt(\"preflight\",()=>i.preflightCall?.({call:c,entry:i.entry,context:t}));let u=await tt(\"lifecycle_prepare\",()=>i.lifecycle?.prepare({call:c,entry:i.entry,context:t}));return{call:c,entry:i.entry,approvalDecision:l,...u?.waitingForApproval?{waitingForApproval:u.waitingForApproval}:{},effectDigest:this.effectDigest(r.identity),approvalAuthorityDigest:i.approvalAuthorityDigest??ft({version:1,catalogDigest:this.catalogDigest,identity:i.entry.identity}),execute:async()=>tt(\"execution\",async()=>{if(u?.waitingForApproval)throw new Cn;let p=this.resolveArguments?await this.resolveArguments({call:c,entry:i.entry,arguments:structuredClone(a),context:t}):a;await tt(\"lifecycle_begin\",()=>u?.begin?.());let m;try{if(m=Vf.parse(await i.execute(p,{operationId:o,caller:s,...t.sourceCallId===void 0?{}:{sourceCallId:t.sourceCallId},...t.transportMeta===void 0?{}:{transportMeta:t.transportMeta},...t.signal===void 0?{}:{signal:t.signal}})),!m.isError&&i.validateOutput){if(!(m.structuredContent!==void 0&&i.validateOutput(m.structuredContent))&&!vg(m.structuredContent))throw new Ii}}catch(d){throw await tt(\"lifecycle_complete\",()=>u?.complete?.({outcome:\"failed\",error:d})),d}return await tt(\"lifecycle_complete\",()=>u?.complete?.({outcome:\"completed\",result:m})),m},(p)=>p.isError?\"rejected\":\"completed\")}}effectDigest(e){let t=this.byIdentity.get(Ti(e));if(!t)throw new mt;let{entry:n}=t;return ft({version:1,identity:n.identity,source:n.source,inputSchema:gn(n.inputSchema),outputSchema:gn(n.outputSchema??null),readOnly:n.annotations?.readOnlyHint??null,destructive:n.annotations?.destructiveHint??null,idempotent:n.annotations?.idempotentHint??null,authority:t.effectAuthorityDigest??t.approvalAuthorityDigest??null})}async callModel(e){let t=this.byModelName.get(e.modelName);if(!t)throw new mt;let n={operationId:e.operationId??oG(),catalogDigest:this.catalogDigest,identity:t.entry.identity,arguments:e.arguments,caller:{kind:\"model\",subjectId:e.subjectId}},r={...e.sourceCallId===void 0?{}:{sourceCallId:e.sourceCallId},...e.transportMeta===void 0?{}:{transportMeta:e.transportMeta},...e.signal===void 0?{}:{signal:e.signal}},o=t.entry.approval===\"human\"&&this.confirmModelApproval?.({entry:t.entry,modelName:e.modelName,subjectId:e.subjectId})===!0;return await(await this.prepareCallWithModelApproval(n,r,o)).execute()}}function MR(e){let t=lG(e),n,r,o=e.map((s,i)=>{let{execute:a,approvalAuthorityDigest:c,effectAuthorityDigest:l,requiresProviderPreflight:u,preflightCall:p,lifecycle:m,codemodePath:d,...f}=s;if(c!==void 0&&!/^[0-9a-f]{64}$/u.test(c))throw Error(\"Tool gateway approval authority digest must be lowercase SHA-256 hex\");if(l!==void 0&&!/^[0-9a-f]{64}$/u.test(l))throw Error(\"Tool gateway effect authority digest must be lowercase SHA-256 hex\");let h=Gf.parse({...f,codemodePath:t[i]}),y=structuredClone(h.inputSchema),_=h.outputSchema?structuredClone(h.outputSchema):null,E,T,A=()=>{if(E)return E;if(T)throw T;try{let K=n??=AR(\"first_error\");return E={input:hu(K,y),output:_?hu(K,_):null},E}catch(K){throw T=new pu(K),T}},x;return{entry:h,execute:a,approvalAuthorityDigest:c,effectAuthorityDigest:l,preflightCall:p,lifecycle:m,get validateInput(){return A().input},diagnoseInput:()=>x??=hu(r??=AR(\"all_errors\"),y),get validateOutput(){return A().output}}});return new OR(o)}var sG=512,On=new Map,qR=65536;function AR(e){let t={allErrors:e===\"all_errors\",coerceTypes:!1,strict:!1,useDefaults:!1,validateFormats:!1,code:{regExp:dR}},n={draft7:new ht.default(t),draft2019:new ER.default(t),draft2020:new PR.default(t)};if(e===\"all_errors\")for(let r of Object.values(n))r.removeKeyword(\"pattern\").addKeyword(cG);return{mode:e,...n}}function iG(e){try{let t=JSON.stringify(e);return t!==void 0&&t.length<=qR}catch{return!1}}function aG(e){let t=0;for(let n of e)t+=1;return t}var cG={keyword:\"pattern\",type:\"string\",schemaType:\"string\",error:{message:({schemaCode:e})=>ht.str`must match pattern \"${e}\"`,params:({schemaCode:e})=>ht._`{pattern: ${e}}`},code(e){let{gen:t,data:n,schema:r,parentSchema:o,it:s}=e,i=s.opts.unicodeRegExp?\"u\":\"\",a=t.scopeValue(\"pattern\",{key:`${r}/${i}`,ref:s.opts.code.regExp(r,i)}),c=o.maxLength;if(typeof c!==\"number\"){e.fail(ht._`!${a}.test(${n})`);return}let l=s.opts.unicode===!1?ht._`${n}.length`:ht._`${t.scopeValue(\"func\",{ref:aG})}(${n})`;e.fail(ht._`${l} <= ${c} && !${a}.test(${n})`)}};function CR(e,t){let n=e.validateInput.errors,r;try{let i=JSON.stringify(t);if(i!==void 0&&i.length<=qR){r={schema:e.entry.inputSchema,arguments:t};let a=e.diagnoseInput();if(!a(t)&&a.errors?.length)n=a.errors}}catch{}let{issues:o,omittedIssueCount:s}=yR(n,r);return new Si(o,s)}function hu(e,t){let n=typeof t.$schema===\"string\"?t.$schema:\"\",r=n.includes(\"2020-12\")?\"2020-12\":n.includes(\"2019-09\")?\"2019-09\":\"draft7\",o=`${e.mode}:${r}:${ft(t)}`,s=On.get(o);if(s)return On.delete(o),On.set(o,s),s;let i=r===\"2020-12\"?e.draft2020.compile(t):r===\"2019-09\"?e.draft2019.compile(t):e.draft7.compile(t);while(On.size>=sG){let a=On.keys().next().value;if(a===void 0)break;On.delete(a)}return On.set(o,i),i}function lG(e){let t=e.map(uG);return dG(t),t}function uG(e){let t=e.codemodePath?.length?[...e.codemodePath]:[e.identity.serverId,e.identity.toolName],n=t.map(mG);if(t.every((s,i)=>s===n[i]))return n;let r=`_${fG(e.identity)}`,o=n.at(-1);return[...n.slice(0,-1),`${o.slice(0,128-r.length)}${r}`]}function dG(e){let t={children:new Map,leaf:!1},n=[...e].sort(pG);for(let r of n){let o=t;for(let[s,i]of r.entries()){if(o.leaf)throw new nn(r,\"extends_leaf\");let a=o.children.get(i);if(!a)a={children:new Map,leaf:!1},o.children.set(i,a);if(o=a,s===r.length-1){if(o.leaf||o.children.size>0)throw new nn(r,\"collision\");o.leaf=!0}}}}function pG(e,t){let n=Math.min(e.length,t.length);for(let r=0;r<n;r+=1){let o=rn(e[r],t[r]);if(o!==0)return o}return e.length-t.length}function mG(e){let t=e.replace(/[^A-Za-z0-9_$]/gu,\"_\");if(!/^[A-Za-z_$]/u.test(t))t=`_${t}`;if([\"__proto__\",\"prototype\",\"constructor\"].includes(t))t=`_${t}`;return t.slice(0,128)||\"_\"}function fG(e){return rG(\"sha256\").update(Ti(e),\"utf8\").digest(\"hex\").slice(0,10)}function Ti(e){return`${e.serverId}\\x00${e.toolName}`}import{lstat as gG,mkdir as hG,mkdtemp as yG,readdir as bG,rm as DR,writeFile as vG}from\"node:fs/promises\";import{tmpdir as yu}from\"node:os\";import{dirname as _G,join as bu,resolve as zR}from\"node:path\";var jR=16777216,wG=\"opengeni-codemode-image-\",xG=86400000,SG=3600000,NR=0;async function Ai(e,t={}){let n=e.content.filter((a)=>a.type===\"image\");if(t.requireOne&&n.length!==1)throw Error(\"Codemode browser screenshot must return exactly one image block\");if(n.length===0)return[];if(t.saveTo!==void 0&&n.length!==1)throw Error(\"An explicit image path requires exactly one image block\");let r=0,o=n.map((a)=>{let c=kG(a.mimeType);if(r+=a.data.length,a.data.length===0||a.data.length>jR||r>jR)throw Error(\"Codemode image exceeds the Code Mode result limit\");let l=Buffer.from(a.data,\"base64\");if(l.length===0||l.toString(\"base64\")!==a.data||!RG(l,c))throw Error(\"Codemode image bytes are invalid\");return{bytes:l,mimeType:c}}),s;if(t.saveTo===void 0)await IG(),s=await yG(bu(yu(),wG));else{if(t.saveTo.length===0)throw TypeError(\"Image saveTo must be a nonempty path\");await hG(_G(zR(t.saveTo)),{recursive:!0})}let i=[];try{for(let[a,c]of o.entries()){let l=c.mimeType===\"image/jpeg\"?\"jpg\":c.mimeType.split(\"/\")[1],u=t.saveTo===void 0?bu(s,o.length===1?`frame.${l}`:`image-${a+1}.${l}`):zR(t.saveTo);await vG(u,c.bytes,{flag:\"wx\",mode:384}),i.push({path:u,mimeType:c.mimeType,sizeBytes:c.bytes.length})}}catch(a){if(s)await DR(s,{recursive:!0,force:!0});throw a}return i}async function IG(){let e=Date.now();if(e-NR<SG)return;if(NR=e,typeof process.getuid!==\"function\")return;try{let t=0;for(let n of await bG(yu(),{withFileTypes:!0})){if(!n.isDirectory()||!/^opengeni-codemode-image-[A-Za-z0-9]{6}$/u.test(n.name))continue;let r=bu(yu(),n.name),o=await gG(r);if(!o.isDirectory()||o.uid!==process.getuid()||(o.mode&63)!==0||e-o.mtimeMs<xG)continue;if(await DR(r,{recursive:!0,force:!0}),++t>=64)break}}catch{}}function kG(e){if(e===\"image/png\"||e===\"image/jpeg\"||e===\"image/webp\")return e;throw Error(`Codemode image has unsupported type: ${e}`)}function RG(e,t){switch(t){case\"image/png\":return e.length>=8&&e.subarray(0,8).equals(Buffer.from(\"89504e470d0a1a0a\",\"hex\"));case\"image/jpeg\":return e.length>=3&&e[0]===255&&e[1]===216&&e[2]===255;case\"image/webp\":return e.length>=12&&e.toString(\"ascii\",0,4)===\"RIFF\"&&e.toString(\"ascii\",8,12)===\"WEBP\"}}import{readFile as TG}from\"node:fs/promises\";var Sr={url:\"OPENGENI_CODEMODE_URL\",token:\"OPENGENI_CODEMODE_TOKEN\",tokenFile:\"OPENGENI_CODEMODE_TOKEN_FILE\"},vu=null;function on(e=process.env){let t=_u(e,Sr.url),n=e[Sr.token]!==void 0,r=n?void 0:_u(e,Sr.tokenFile),o=`${t}\\x00${n?\"direct\":`file:${r}`}`;if(e===process.env&&vu?.key===o)return vu.client;let s=new wu({baseUrl:t,token:n?async()=>_u(e,Sr.token):async()=>await CG(r)});if(e===process.env)vu={key:o,client:s};return s}function AG(e=()=>on()){let t=(n)=>new Proxy(async(r={},o={})=>await(await e()).callPathValue(n,r,o),{get(r,o){if(o===\"then\")return;if(o===Symbol.toStringTag)return\"CodemodeTool\";if(typeof o!==\"string\")return;return t([...n,o])},set(){return!1}});return new Proxy(Object.create(null),{get(n,r){if(r===\"then\")return;if(r===Symbol.toStringTag)return\"CodemodeTools\";if(typeof r!==\"string\")return;return t([r])},set(){return!1}})}var J9=AG();async function CG(e){let t;try{t=(await TG(e,\"utf8\")).trim()}catch{throw Error(`${Sr.tokenFile} is not readable`)}if(!t)throw Error(`${Sr.tokenFile} is empty`);return t}function _u(e,t){let n=e[t]?.trim();if(!n)throw Error(`${t} is required`);return n}import{randomBytes as LR}from\"node:crypto\";class fo extends Error{result;code;retryable;constructor(e){let t=EG(e);super(t.message);this.result=e;this.name=\"CodemodeToolExecutionError\",this.code=t.code,this.retryable=t.retryable}}function UR(e=()=>on()){return typeof e===\"function\"?e:()=>e}async function O(e,t,n,r){let o=await(await e()).callPath(t,n,r);if(o.isError)throw new fo(o);if(!o.structuredContent)throw Error(`Codemode tool ${t.join(\".\")} returned no structured content`);return o.structuredContent}function EG(e){let n=e.structuredContent?.error;return{code:typeof n?.code===\"string\"?n.code:\"tool_error\",message:typeof n?.message===\"string\"?n.message:\"Codemode tool failed\",retryable:n?.retryable===!0}}var sn={list:[\"artifacts\",\"list\"],create:[\"artifacts\",\"create\"],import:[\"artifacts\",\"import\"],get:[\"artifacts\",\"get\"],inspect:[\"artifacts\",\"inspect\"],apply:[\"artifacts\",\"apply\"],export:[\"artifacts\",\"export\"],exportStatus:[\"artifacts\",\"exportStatus\"]},PG=Object.freeze({stable:qG,document:zG});class xu{client;ids=PG;constructor(e){this.client=e}async list(e={},t={}){return(await O(this.client,sn.list,e,t)).artifacts}async create(e,t,n={}){let r=await O(this.client,sn.create,{modality:e,title:t},n);return new go(this.client,r.id,r)}async import(e,t,n,r={}){let o=await O(this.client,sn.import,{fileId:e,modality:t,title:n},r);return new go(this.client,o.id,o)}use(e){return typeof e===\"string\"?new go(this.client,e):new go(this.client,e.id,e)}}var OG=Object.freeze({paragraph:\"p\",table:\"dt\",\"page-break\":\"pb\",section:\"sec\",header:\"hdr\",footer:\"ftr\",comment:\"dc\",\"tracked-change\":\"chg\"}),$G=0xffffffffffffffffn,MG=BigInt(Number.MAX_SAFE_INTEGER)-1n;function qG(){let e=LR(16);if(e.subarray(0,8).every((t)=>t===0))e[0]=1;if(e.subarray(8,16).every((t)=>t===0))e[8]=1;return e.toString(\"hex\")}function zG(e,t){let n=jG(t),r=LR(7);r[0]=(r[0]??0)&31;let o=0n;for(let s of r)o=o<<8n|BigInt(s);if(o===0n)o=1n;if(o>MG)throw Error(\"Generated document id counter exceeds the canonical limit\");return`${OG[e]}/${n.toString(16).padStart(16,\"0\")}${o.toString(16).padStart(16,\"0\")}`}function jG(e){if(typeof e===\"number\"&&(!Number.isSafeInteger(e)||e<0)||typeof e===\"string\"&&!/^(?:0|[1-9][0-9]*)$/u.test(e))throw TypeError(\"Document id namespace must be an unsigned decimal integer\");let t=BigInt(e);if(t<0n||t>$G)throw RangeError(\"Document id namespace is outside the uint64 range\");return t}class go{client;id;metadata;constructor(e,t,n=null){this.client=e;this.id=t;this.metadata=n}async get(e={}){let t=await O(this.client,sn.get,{artifactId:this.id},e);return this.metadata=t,t}async inspect(e,t={}){let n=(await this.currentMetadata(t)).modality,r=await O(this.client,sn.inspect,{artifactId:this.id,modality:n,request:e},t);return this.metadata=r.artifact,r}async apply(e,t={}){let n=await this.currentMetadata(t),r=await O(this.client,sn.apply,{artifactId:this.id,modality:n.modality,expectedHeadSequence:n.headSequence,expectedStateHash:n.stateHash,commands:e},t);return this.metadata=r.artifact,r}async export(e,t={},n={}){let r=await O(this.client,sn.export,{artifactId:this.id,format:e,options:t},n);return this.metadata=r.artifact,new GR(this.client,r.artifact.id,r.versionId,r.jobId,r.sourceHeadSequence,r.sourceStateHash)}async currentMetadata(e){return this.metadata??await this.get(e)}}class GR{client;artifactId;versionId;jobId;sourceHeadSequence;sourceStateHash;constructor(e,t,n,r,o,s){this.client=e;this.artifactId=t;this.versionId=n;this.jobId=r;this.sourceHeadSequence=o;this.sourceStateHash=s}async status(e={}){return await O(this.client,sn.exportStatus,{artifactId:this.artifactId,versionId:this.versionId,jobId:this.jobId},e)}}var j={discover:[\"interaction\",\"discover\"],browserOpen:[\"interaction\",\"browser\",\"open\"],browserTabs:[\"interaction\",\"browser\",\"tabs\"],browserObserve:[\"interaction\",\"browser\",\"observe\"],browserRead:[\"interaction\",\"browser\",\"read\"],browserScreenshot:[\"interaction\",\"browser\",\"screenshot\"],browserAct:[\"interaction\",\"browser\",\"act\"],browserClipboard:[\"interaction\",\"browser\",\"clipboard\"],browserDebug:[\"interaction\",\"browser\",\"debug\"],browserDownloads:[\"interaction\",\"browser\",\"downloads\"],browserDownloadSave:[\"interaction\",\"browser\",\"downloadSave\"],browserAuth:[\"interaction\",\"browser\",\"auth\"],requestHuman:[\"interaction\",\"requestHuman\"],browserIdentity:[\"interaction\",\"browser\",\"identity\"],browserPublish:[\"interaction\",\"browser\",\"publish\"],browserLifecycle:[\"interaction\",\"browser\",\"lifecycle\"],computerOpen:[\"interaction\",\"computer\",\"open\"],computerTargets:[\"interaction\",\"computer\",\"targets\"],computerObserve:[\"interaction\",\"computer\",\"observe\"],computerClipboard:[\"interaction\",\"computer\",\"clipboard\"],computerAct:[\"interaction\",\"computer\",\"act\"],computerLifecycle:[\"interaction\",\"computer\",\"lifecycle\"]};class BR{browsers;computers;artifacts;auth;constructor(e=()=>on()){let t=UR(e);this.browsers=new VR(t),this.computers=new QR(t),this.artifacts=new xu(t),this.auth=new YR(t)}async discover(e={},t={}){return await O(this.browsers.client,j.discover,e,t)}async requestHuman(e,t={}){return await O(this.browsers.client,j.requestHuman,e,t)}}class VR{client;identities;constructor(e){this.client=e;this.identities=new FR(e)}async list(e={},t={}){return(await O(this.client,j.discover,e,t)).browsers}async open(e={},t={}){let n=await O(this.client,j.browserOpen,e,t);return new Su(this.client,n.session.id)}use(e){return new Su(this.client,e)}}class FR{client;constructor(e){this.client=e}async list(e={},t={}){return(await O(this.client,j.browserIdentity,{operation:\"list\",...e},t)).result}async get(e,t={}){return(await O(this.client,j.browserIdentity,{operation:\"get\",identityId:e},t)).result}async create(e,t={}){return(await O(this.client,j.browserIdentity,{operation:\"create\",name:e},t)).result}async revisions(e,t={}){return(await O(this.client,j.browserIdentity,{operation:\"revisions\",identityId:e},t)).result}async update(e,t,n={}){return(await O(this.client,j.browserIdentity,{operation:\"update\",identityId:e,...t},n)).result}}class Su{client;id;tabs;auth;clipboard;downloads;constructor(e,t){this.client=e;this.id=t;this.tabs=new HR(e,t),this.auth=new XR(e,t),this.clipboard=new KR(e,t,this.tabs),this.downloads=new JR(e,t)}async refresh(e={}){return(await O(this.client,j.browserOpen,{browserSessionId:this.id},e)).session}async observe(e,t={}){return await this.tabs.use(await this.tabs.resolveId(e,t)).observe(t)}async observeFull(e,t={}){return await this.tabs.use(await this.tabs.resolveId(e,t)).observeFull(t)}async read(e={},t={}){let{targetId:n,...r}=e;return await this.tabs.use(await this.tabs.resolveId(n,t)).read(r,t)}async screenshot(e={},t={}){return await this.tabs.use(await this.tabs.resolveId(e.targetId,t)).screenshot(e,t)}async act(e,t={},n={}){let r=await this.tabs.resolveId(t.targetId,n);return await this.tabs.use(r).act(e,t,n)}async diagnostics(e,t={},n={}){return await O(this.client,j.browserDebug,{browserSessionId:this.id,targetId:await this.tabs.resolveId(e,n),...t},n)}async publish(e,t={}){return await O(this.client,j.browserPublish,{browserSessionId:this.id,...e},t)}async suspend(e={}){return await this.lifecycle(\"suspend\",e)}async resume(e={}){return await this.lifecycle(\"resume\",e)}async end(e={}){return await this.lifecycle(\"end\",e)}async lifecycle(e,t){return await O(this.client,j.browserLifecycle,{browserSessionId:this.id,action:e},t)}}class JR{client;browserSessionId;constructor(e,t){this.client=e;this.browserSessionId=t}async list(e={}){return await O(this.client,j.browserDownloads,{browserSessionId:this.browserSessionId,operation:\"list\"},e)}download(e){return new WR(this.client,this.browserSessionId,e)}}class WR{client;browserSessionId;id;constructor(e,t,n){this.client=e;this.browserSessionId=t;this.id=n}async get(e={}){return await O(this.client,j.browserDownloads,{browserSessionId:this.browserSessionId,operation:\"get\",downloadId:this.id},e)}async saveToWorkspace(e,t={},n={}){return await O(this.client,j.browserDownloadSave,{browserSessionId:this.browserSessionId,downloadId:this.id,destinationPath:e,...t.overwrite===void 0?{}:{overwrite:t.overwrite}},n)}}class KR{client;browserSessionId;tabs;constructor(e,t,n){this.client=e;this.browserSessionId=t;this.tabs=n}async read(e={}){return await O(this.client,j.browserClipboard,{browserSessionId:this.browserSessionId},e)}async write(e,t={},n={}){return await this.act({type:\"clipboard\",operation:\"write\",text:e},t,n)}async clear(e={},t={}){return await this.act({type:\"clipboard\",operation:\"clear\"},e,t)}async copy(e={},t={}){let{targetId:n,expectedTargetGeneration:r,expectedDocumentGeneration:o,expectedFrameId:s,...i}=e;return await this.act({type:\"clipboard\",operation:\"copy\",...i},{targetId:n,expectedTargetGeneration:r,expectedDocumentGeneration:o,expectedFrameId:s},t)}async paste(e={},t={}){let{targetId:n,expectedTargetGeneration:r,expectedDocumentGeneration:o,expectedFrameId:s,...i}=e;return await this.act({type:\"clipboard\",operation:\"paste\",...i},{targetId:n,expectedTargetGeneration:r,expectedDocumentGeneration:o,expectedFrameId:s},t)}async act(e,t,n){let{targetId:r,...o}=t;return await this.tabs.use(await this.tabs.resolveId(r,n)).act(e,o,n)}}class HR{client;browserSessionId;constructor(e,t){this.client=e;this.browserSessionId=t}async list(e={}){return await O(this.client,j.browserTabs,{operation:\"list\",browserSessionId:this.browserSessionId},e)}async selected(e={}){return this.use(await this.resolveId(void 0,e))}use(e){return new ZR(this.client,this.browserSessionId,e)}async open(e,t={}){let n=await this.list(t),r=await O(this.client,j.browserTabs,{operation:\"open\",browserSessionId:this.browserSessionId,...e?{url:e}:{}},t),o=new Set(n.targets.map((i)=>i.id)),s=r.targets.find((i)=>!o.has(i.id))??r.targets.find((i)=>i.selected);if(!s)throw Error(\"Browser opened no discoverable tab\");return this.use(s.id)}async select(e,t={}){if(!(await O(this.client,j.browserTabs,{operation:\"select\",browserSessionId:this.browserSessionId,targetId:e},t)).targets.some((r)=>r.id===e&&r.selected))throw Error(\"Browser did not select the requested tab\");return this.use(e)}async close(e,t={}){return await O(this.client,j.browserTabs,{operation:\"close\",browserSessionId:this.browserSessionId,targetId:e},t)}async resolveId(e,t){let n=await this.list(t);if(e){if(!n.targets.some((o)=>o.id===e))throw Error(`Browser tab is unavailable: ${e}`);return e}let r=n.targets.filter((o)=>o.selected);if(r.length===1)return r[0].id;if(n.targets.length===1)return n.targets[0].id;if(n.targets.length===0)throw Error(\"Browser has no tabs\");throw Error(\"Browser target is ambiguous; select an exact tab\")}}class ZR{client;browserSessionId;id;constructor(e,t,n){this.client=e;this.browserSessionId=t;this.id=n}async observe(e={}){return await O(this.client,j.browserObserve,{browserSessionId:this.browserSessionId,targetId:this.id},e)}async observeFull(e={}){return await O(this.client,j.browserObserve,{browserSessionId:this.browserSessionId,targetId:this.id,view:\"full\"},e)}async read(e={},t={}){return await O(this.client,j.browserRead,{browserSessionId:this.browserSessionId,targetId:this.id,...e},t)}async screenshot(e={},t={}){let n=await(await this.client()).callPath(j.browserScreenshot,{browserSessionId:this.browserSessionId,targetId:this.id,...e.fullPage===void 0?{}:{fullPage:e.fullPage},...e.quality===void 0?{}:{quality:e.quality}},t);return await NG(n,e.saveTo)}async act(e,t={},n={}){return await O(this.client,j.browserAct,{browserSessionId:this.browserSessionId,targetId:this.id,action:e,...t},n)}async navigate(e,t={}){let{waitUntil:n,...r}=t,o=n?{type:\"navigate\",url:e,waitUntil:n}:{type:\"navigate\",url:e};return await this.act(o,{},r)}async setPermission(e,t,n={},r={}){return await this.act({type:\"permission\",permission:e,setting:t},n,r)}async requestHuman(e,t={},n={}){let r=await this.observe(n);return await O(this.client,j.requestHuman,{operation:\"request\",resourceKind:\"browser_session\",resourceId:this.browserSessionId,targetId:this.id,expectedControllerGeneration:r.target.controllerGeneration,expectedTargetGeneration:r.target.targetGeneration,expectedDocumentGeneration:r.target.documentGeneration,kind:t.kind??\"other\",reason:e,...t.authRunId?{authRunId:t.authRunId}:{},...t.expiresInSeconds===void 0?{}:{expiresInSeconds:t.expiresInSeconds}},n)}getByRole(e,t={}){return new an(this,{kind:\"role\",role:e,...t})}getByText(e){return new an(this,{kind:\"text\",text:e})}getByLabel(e){return new an(this,{kind:\"label\",text:e})}getByPlaceholder(e){return new an(this,{kind:\"placeholder\",text:e})}getByTestId(e){return new an(this,{kind:\"test_id\",value:e})}locator(e){return new an(this,{kind:\"css\",selector:e})}ref(e){return new an(this,{kind:\"ref\",ref:e})}}class an{tab;locator;constructor(e,t){this.tab=e;this.locator=t}async click(e={},t={}){return await this.tab.act({type:\"click\",locator:this.locator,...e},{},t)}async doubleClick(e={}){return await this.tab.act({type:\"double_click\",locator:this.locator},{},e)}async hover(e={}){return await this.tab.act({type:\"hover\",locator:this.locator},{},e)}async fill(e,t={}){return await this.tab.act({type:\"fill\",locator:this.locator,value:e},{},t)}async type(e,t={}){return await this.tab.act({type:\"type\",locator:this.locator,text:e},{},t)}async press(e,t={}){return await this.tab.act({type:\"press\",locator:this.locator,key:e},{},t)}async select(e,t={}){return await this.tab.act({type:\"select\",locator:this.locator,values:e},{},t)}async check(e=!0,t={}){return await this.tab.act({type:\"check\",locator:this.locator,checked:e},{},t)}}class YR{client;constructor(e){this.client=e}async listConnections(e={},t={}){return(await O(this.client,j.browserAuth,{operation:\"list_connections\",...e},t)).result}async getConnection(e,t={}){return(await O(this.client,j.browserAuth,{operation:\"get_connection\",siteAuthConnectionId:e},t)).result}async listRuns(e={},t={}){return(await O(this.client,j.browserAuth,{operation:\"list_runs\",...e},t)).result}async getRun(e,t={}){return(await O(this.client,j.browserAuth,{operation:\"get_run\",authRunId:e},t)).result}use(e,t){return new ku(this.client,e,t)}}class XR{client;browserSessionId;constructor(e,t){this.client=e;this.browserSessionId=t}async listRuns(e={},t={}){return(await O(this.client,j.browserAuth,{operation:\"list_runs\",browserSessionId:this.browserSessionId,...e},t)).result}async start(e,t={}){let n=await O(this.client,j.browserAuth,{operation:\"start\",browserSessionId:this.browserSessionId,...e},t);return this.use(n.result.run.id)}use(e){return new ku(this.client,this.browserSessionId,e)}}class ku{client;browserSessionId;id;constructor(e,t,n){this.client=e;this.browserSessionId=t;this.id=n}async get(e={}){let t=await O(this.client,j.browserAuth,{operation:\"get_run\",authRunId:this.id},e);if(t.result.browserSessionId!==this.browserSessionId)throw Error(\"Auth run belongs to another BrowserSession\");return t.result}async report(e,t={}){return(await O(this.client,j.browserAuth,{operation:\"report\",browserSessionId:this.browserSessionId,authRunId:this.id,...e},t)).result}async advanceExternal(e,t={}){return(await O(this.client,j.browserAuth,{operation:\"advance_external\",browserSessionId:this.browserSessionId,authRunId:this.id,...e},t)).result}async verify(e,t={}){return(await O(this.client,j.browserAuth,{operation:\"verify\",browserSessionId:this.browserSessionId,authRunId:this.id,...e},t)).result}}class QR{client;constructor(e){this.client=e}async list(e={},t={}){return(await O(this.client,j.discover,e,t)).computers}async open(e={},t={}){let n=await O(this.client,j.computerOpen,e,t);return new Iu(this.client,n.session.id)}use(e){return new Iu(this.client,e)}}class Iu{client;id;targets;apps;clipboard;constructor(e,t){this.client=e;this.id=t;this.targets=new tT(e,t),this.apps=this.targets,this.clipboard=new eT(e,t,this.targets)}async refresh(e={}){return(await O(this.client,j.computerOpen,{computerSessionId:this.id},e)).session}async observe(e,t={}){return await this.targets.use(await this.targets.resolveId(e,t)).observe(t)}async act(e,t={},n={}){return await this.targets.use(await this.targets.resolveId(t.targetId,n)).act(e,t,n)}async launch(e,t={}){let n=await this.targets.resolveId(void 0,t);return await this.targets.use(n).act({type:\"launch\",applicationId:e},{},t),await this.targets.list(t)}async end(e={}){return await O(this.client,j.computerLifecycle,{computerSessionId:this.id,action:\"end\"},e)}}class eT{client;computerSessionId;targets;constructor(e,t,n){this.client=e;this.computerSessionId=t;this.targets=n}async read(e={}){return await O(this.client,j.computerClipboard,{computerSessionId:this.computerSessionId},e)}async write(e,t={},n={}){return await this.mutate({type:\"clipboard\",operation:\"write\",text:e},t,n)}async clear(e={},t={}){return await this.mutate({type:\"clipboard\",operation:\"clear\"},e,t)}async copy(e={},t={}){return await this.mutate({type:\"clipboard\",operation:\"copy\"},e,t)}async paste(e={},t={}){return await this.mutate({type:\"clipboard\",operation:\"paste\"},e,t)}async mutate(e,t,n){let r=await this.targets.resolveSeatId(t.targetId,n);return await this.targets.use(r).act(e,{},n)}}class tT{client;computerSessionId;constructor(e,t){this.client=e;this.computerSessionId=t}async list(e={}){return await O(this.client,j.computerTargets,{computerSessionId:this.computerSessionId},e)}use(e){return new nT(this.client,this.computerSessionId,e)}async focused(e={}){return this.use(await this.resolveId(void 0,e))}async resolveId(e,t){let n=await this.list(t);if(e){if(!n.targets.some((o)=>o.id===e))throw Error(`Computer target is unavailable: ${e}`);return e}let r=n.targets.filter((o)=>o.focused);if(r.length===1)return r[0].id;if(n.targets.length===1)return n.targets[0].id;if(n.targets.length===0)throw Error(\"Computer has no app, window, or screen targets\");throw Error(\"Computer target is ambiguous; select an exact app or window\")}async resolveSeatId(e,t){if(e)return await this.resolveId(e,t);let r=(await this.list(t)).targets.filter((o)=>o.kind===\"screen\");if(r.length===1)return r[0].id;return await this.resolveId(void 0,t)}}class nT{client;computerSessionId;id;constructor(e,t,n){this.client=e;this.computerSessionId=t;this.id=n}async observe(e={}){return await O(this.client,j.computerObserve,{computerSessionId:this.computerSessionId,targetId:this.id},e)}async act(e,t={},n={}){return await O(this.client,j.computerAct,{computerSessionId:this.computerSessionId,targetId:this.id,action:e,...t},n)}async requestHuman(e,t={},n={}){let r=await this.observe(n);return await O(this.client,j.requestHuman,{operation:\"request\",resourceKind:\"computer_session\",resourceId:this.computerSessionId,targetId:this.id,expectedControllerGeneration:r.target.controllerGeneration,expectedTargetGeneration:r.target.targetGeneration,expectedDocumentGeneration:null,kind:t.kind??\"other\",reason:e,...t.expiresInSeconds===void 0?{}:{expiresInSeconds:t.expiresInSeconds}},n)}getByRole(e,t={}){return new Ir(this,{kind:\"role\",role:e,...t})}getByText(e,t){return new Ir(this,{kind:\"text\",text:e,...t?{exact:t}:{}})}getByLabel(e,t){return new Ir(this,{kind:\"label\",text:e,...t?{exact:t}:{}})}getByIdentifier(e){return new Ir(this,{kind:\"identifier\",value:e})}ref(e){return new Ir(this,{kind:\"ref\",ref:e})}}class Ir{target;locator;constructor(e,t){this.target=e;this.locator=t}async invoke(e={}){return await this.semantic(\"invoke\",void 0,e)}async focus(e={}){return await this.semantic(\"focus\",void 0,e)}async setValue(e,t={}){return await this.semantic(\"set_value\",e,t)}async select(e={}){return await this.semantic(\"select\",void 0,e)}async expand(e={}){return await this.semantic(\"expand\",void 0,e)}async collapse(e={}){return await this.semantic(\"collapse\",void 0,e)}async semantic(e,t,n){return await this.target.act({type:\"semantic\",locator:this.locator,action:e,...t===void 0?{}:{value:t}},{},n)}}async function NG(e,t){if(e.isError)throw new fo(e);if(!e.structuredContent)throw Error(\"Codemode tool interaction.browser.screenshot returned no structured content\");let n=e.content.find((o)=>o.type===\"image\");if(typeof e.structuredContent.mediaType===\"string\"&&n&&e.structuredContent.mediaType!==n.mimeType)throw Error(\"Codemode browser screenshot image type differs from frame metadata\");return{...(await Ai(e,{...t===void 0?{}:{saveTo:t},requireOne:!0}))[0],metadata:e.structuredContent}}function DG(e=()=>on()){return new BR(e)}var r5=DG();function c5(e,t={}){let n=Ci(e);return Ri({digest:n.digest,entries:n.entries},{moduleSpecifier:t.moduleSpecifier??\"@opengeni/codemode\",interfaceName:\"CodemodeGeneratedTools\",callOptionsType:\"CodemodeCallOptions\",fallbackResultType:\"CodemodeToolResult\",typedResultWrapperType:\"CodemodeMultimodalValue\",generatedBy:\"@opengeni/codemode via @opengeni/tool-gateway\",catalogDigestLabel:\"Attempt catalog digest\"})}import{randomUUID as oT}from\"node:crypto\";var Ru='(()=>{var Z=(e,t,n)=>()=>{if(e)try{t=e(e=0)}catch(s){n=[s]}if(n)throw n[0];return t};function Le(e){return e!==null&&typeof e===\"object\"&&!Array.isArray(e)?e:null}function dt(e,t=Number.MAX_SAFE_INTEGER){return typeof e===\"number\"&&Number.isSafeInteger(e)&&e>=0&&e<=t}function Ss(e){let t=e.slice(0,2048).replace(/[\\\\u0000-\\\\u001f\\\\u007f]+/g,\" \").trim(),n=new TextEncoder().encode(t),s=Math.min(n.length,1024);while(s>0&&s<n.length&&(n[s]&192)===128)s-=1;return new TextDecoder().decode(n.slice(0,s)).trim()}function gt(e){let t=Le(e);if(!t)return null;let n=Le(t.sessionUsageLimit)??t;if(n.code!==\"session_usage_limit_reached\")return null;let s=Le(n.details)??n;if(s.basis!==\"model_api_equivalent_v1\"||typeof s.rootSessionId!==\"string\"||!bs.test(s.rootSessionId)||!dt(s.limitMicros,10000000000000)||!dt(s.usedMicros))return null;let i={code:\"session_usage_limit_reached\",basis:\"model_api_equivalent_v1\",rootSessionId:s.rootSessionId.toLowerCase(),limitMicros:s.limitMicros,usedMicros:s.usedMicros,message:\"\"},r=typeof n.message===\"string\"?Ss(n.message):\"\";return{...i,message:r||ws(i)}}function pt(e){if(e>0&&e<1e4)return\"<$0.01\";return`$${(e/1e6).toLocaleString(\"en-US\",{minimumFractionDigits:2,maximumFractionDigits:2})}`}function ws(e){return`This task\\'s usage limit is reached (${pt(e.usedMicros)} of ${pt(e.limitMicros)} API-equivalent model usage). A person can raise or remove the limit to continue.`}var bs;var mt=Z(()=>{bs=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i});function yt(e){if(e.status!==400&&e.status!==422)return!1;let t;try{t=JSON.parse(e.body)}catch{return!1}if(!t||typeof t!==\"object\")return!1;let n=t,s=n.error&&typeof n.error===\"object\"?n.error:n,i=typeof s.message===\"string\"?s.message:\"\",r=/^Invalid session create request: (.+) failed schema validation$/.exec(i);if(s.code===\"INVALID_SESSION_CREATE_REQUEST\"&&r?.[1]?.split(/,\\\\s*/).includes(\"startMode\"))return!0;let o=s.details&&typeof s.details===\"object\"?s.details:null;return(Array.isArray(o?.issues)?o.issues:[]).some((c)=>{if(!c||typeof c!==\"object\")return!1;let u=c.path;return u===\"startMode\"||Array.isArray(u)&&u.length===1&&u[0]===\"startMode\"})}function ft(e){return new pe(\"The server did not confirm the requested usage limit; it may not support usage limits. Read the limit again before relying on it.\",{sessionId:e})}function Je(e){try{let t=JSON.parse(e);if(!t||typeof t!==\"object\"||Array.isArray(t))return null;let n=t;return gt(n.error&&typeof n.error===\"object\"&&!Array.isArray(n.error)?n.error:n)}catch{return null}}function Ve(e){try{let t=JSON.parse(e);if(!t||typeof t!==\"object\"||Array.isArray(t))return null;let n=t,s=n.error&&typeof n.error===\"object\"&&!Array.isArray(n.error)?n.error:n;if(s.code!==\"allowance_exhausted\")return null;let i=s.details&&typeof s.details===\"object\"&&!Array.isArray(s.details)?s.details:s;if(i.scope!==\"workspace\"&&i.scope!==\"member\")return null;if(i.resetsAt!==null&&typeof i.resetsAt!==\"string\")return null;return{scope:i.scope,resetsAt:i.resetsAt,...typeof i.subjectId===\"string\"?{subjectId:i.subjectId}:{}}}catch{return null}}function vs(e){if(!e)return null;try{let t=JSON.parse(e);if(!t||typeof t!==\"object\"||Array.isArray(t))return null;let n=t,s=n.error&&typeof n.error===\"object\"&&!Array.isArray(n.error)?n.error:n,i=We(s.code),r=We(s.message),o=ht(s.requestId),a=typeof s.retryable===\"boolean\"?s.retryable:void 0,c=typeof s.outcomeUnknown===\"boolean\"?s.outcomeUnknown:void 0,u=ks(s.details);if(!i&&!r&&!o&&a===void 0&&c===void 0&&!u)return null;return{code:i,message:r,requestId:o,retryable:a,outcomeUnknown:c,details:u}}catch{return null}}function ks(e){if(!e||typeof e!==\"object\"||Array.isArray(e))return;let t=Object.entries(e).slice(0,16),n={};for(let[s,i]of t){if(!/^[a-zA-Z][\\\\w.-]{0,63}$/.test(s))continue;if(typeof i===\"string\"){let r=We(i);if(r!==void 0)n[s]=r}else if(typeof i===\"number\"||typeof i===\"boolean\"||i===null)n[s]=i;else if(s===\"action\"&&typeof i===\"object\"&&!Array.isArray(i)&&i.type===\"upgrade\"&&i.href===\"/billing\")n.action={type:\"upgrade\",href:\"/billing\"}}return Object.keys(n).length>0?n:void 0}function We(e){if(typeof e!==\"string\")return;let t=new TextEncoder().encode(e);return t.byteLength<=512?e:new TextDecoder().decode(t.slice(0,512))}function Is(e){return e===408||e===409||e===425||e===429||e>=500}function ht(e){if(typeof e!==\"string\"||e.length>128||!/^[\\\\w.:-]+$/.test(e))return;return e}function K(e){return e instanceof DOMException&&e.name===\"AbortError\"||e instanceof Error&&e.name===\"AbortError\"}function j(e){if(e instanceof P)return e.retryable;return e instanceof TypeError}var P,ze,Ne,Fe,pe,we,He,ve,L;var V=Z(()=>{mt();P=class P extends Error{status;code;retryable;correlationId;outcomeUnknown;body;details;constructor(e,t,n={}){let s=vs(t),i=s?.requestId??ht(n.correlationId),r=e>=502&&e<=504,o=n.mutation!==void 0,a=s?.message??(o?\"Request failed.\":t||\"(empty body)\"),c=n.displayMessage??(r&&o?s?.message??\"The workspace is temporarily unavailable — retry.\":`API ${e}: ${a}`);super(i?`${c} Reference: ${i}.`:c);this.name=\"OpenGeniApiError\",this.status=e,this.code=n.code??s?.code??(r&&o?\"upstream_unavailable\":void 0),this.retryable=n.retryable??s?.retryable??Is(e),this.correlationId=i,this.outcomeUnknown=n.outcomeUnknown??s?.outcomeUnknown??(r&&!!n.mutation&&!s),this.body=!o||s?t:\"\",this.details=s?.details}};ze=class ze extends P{constructor(e){super(e.status,e.body,{code:\"OPENGENI_SETUP_REQUIRED\",retryable:!1,correlationId:e.correlationId,displayMessage:\"Private chats require organization_private_session_settings.enabled (migration 0323). An organization owner or admin can enable Only me chats in the web app under Organization settings > Security & data, or use updateOrganizationPrivateSessionSettings from @opengeni/sdk/organization-private-session-settings with enabled: true, the current expectedVersion and a stable operationId (PATCH /v1/organizations/:organizationId/private-session-settings; an organization key needs workspace:admin). If platform readiness is unavailable, ask the deployment operator to activate session tenancy first.\"});this.name=\"OpenGeniSetupError\"}};Ne=class Ne extends P{scope;resetsAt;subjectId;constructor(e,t,n={}){super(e,t,{...n,code:\"allowance_exhausted\",retryable:!1,outcomeUnknown:!1});this.name=\"OpenGeniAllowanceExhaustedError\";let s=Ve(t);this.scope=s?.scope??\"workspace\",this.resetsAt=s?.resetsAt??null,this.subjectId=s?.subjectId}};Fe=class Fe extends P{rootSessionId;limitMicros;usedMicros;constructor(e,t,n={}){super(e,t,{...n,code:\"session_usage_limit_reached\",retryable:!1,outcomeUnknown:!1});this.name=\"OpenGeniSessionUsageLimitReachedError\";let s=Je(t);this.rootSessionId=s?.rootSessionId,this.limitMicros=s?.limitMicros,this.usedMicros=s?.usedMicros}};pe=class pe extends Error{code=\"session_usage_limit_unsupported\";sessionId;constructor(e,t={}){super(e,t.cause===void 0?void 0:{cause:t.cause});this.name=\"OpenGeniSessionUsageLimitUnsupportedError\",this.sessionId=t.sessionId??null}};we=class we extends Error{code=\"secure_context_required\";retryable=!1;reason;constructor(e){super(e===\"insecure_context\"?\"Couldn’t attach this file because this page is open over HTTP. Attachments require a secure HTTPS connection. Open the secure site or configure HTTPS for this deployment.\":\"Couldn’t attach this file because secure browser cryptography is unavailable. Attachments require HTTPS and Web Crypto support. Open a secure site in a supported browser or configure HTTPS for this deployment.\");this.name=\"OpenGeniSecureContextRequiredError\",this.reason=e}};He=class He extends P{};ve=class ve extends Error{expected;actual;constructor(e,t){super(`API contract mismatch: client expects ${e}, API serves ${t}`);this.name=\"OpenGeniApiContractMismatchError\",this.expected=e,this.actual=t}};L=class L extends Error{constructor(e){super(e);this.name=\"OpenGeniStreamError\"}}});function ke(e){let t=null,n=0,s=!1,i=null,r=null,o=()=>{if(i&&i.epoch===n)return i;let l=s,p={epoch:n,controller:new AbortController,waiters:0,settled:!1};return i=p,p.promise=(async()=>{try{let d=await e(l,p.controller.signal);if(p.epoch===n&&!p.controller.signal.aborted)t=d,s=!1;return d}finally{if(p.settled=!0,i===p)i=null}})(),p.promise.catch(()=>{return}),p},a=(l,p)=>{if(i===l)i=null;if(r?.load===l)r=null;l.controller.abort(p)},c=(l,p)=>{if(p?.aborted)return Promise.reject(Rt(p));return l.waiters+=1,new Promise((d,m)=>{let y=!1,R=()=>{if(y)return!1;return y=!0,l.waiters-=1,p?.removeEventListener(\"abort\",w),!0},w=()=>{if(!R())return;let S=Rt(p);if(m(S),l.waiters===0&&!l.settled)a(l,S)};p?.addEventListener(\"abort\",w,{once:!0}),l.promise.then((S)=>{if(R())d(S)},(S)=>{if(R())m(S)})})},u=()=>{t=null,n+=1,s=!0};return{async load(l={}){if(l.signal?.throwIfAborted(),l.refresh)u();if(t)return t;return await c(o(),l.signal)},async reloadAfterStale(l,p){p?.throwIfAborted();let d=r;if(d?.staleDigest===l&&(d.settled===null?d.load.epoch===n:d.settled===t))return await c(d.load,p);u();let m=o(),y={staleDigest:l,load:m,settled:null};return r=y,m.promise.then((R)=>{if(r!==y)return;if(R.digest===l)r=null;else y.settled=R},()=>{if(r===y)r=null}),await c(m,p)},invalidate(l){if(t?.digest===l)u()}}}function Rt(e){return e.reason??new DOMException(\"The operation was aborted.\",\"AbortError\")}function St(e,t,n){let s=`/v1/workspaces/${encodeURIComponent(t)}/tools`,i,r=()=>i??=n(),o=new Set,a=new Map,c=new Map,u=new Map,l=0,p=(b)=>{if(!u.has(b)&&u.size>=256)u.delete(u.keys().next().value);let h=++l;return u.set(b,h),h},d=new Map,m=(b)=>{let h=me(b),f=a.get(h);if(!f){if(f=ke(async(T,C)=>{let v=await e.requestJson(\"POST\",`${s}/resolve`,{target:b},{},{signal:C});return{...v,digest:v.definitionDigest}}),a.size>=256)a.delete(a.keys().next().value);a.set(h,f)}return f},y=(b,h,f)=>{let T=me(b);if(u.get(T)!==f)return;if(c.size>=256)c.delete(c.keys().next().value);c.set(T,h)},R=async(b,h={})=>{if(h.siteArtifactId||h.siteVersionId)return await e.requestJson(\"POST\",`${s}/resolve`,{target:b,siteArtifactId:h.siteArtifactId,siteVersionId:h.siteVersionId},{},h.signal?{signal:h.signal}:{});let f=me(b),T=p(f);if(h.refresh)c.delete(f);let C=await m(b).load(h);return y(b,C,T),C},w=(b,h={})=>e.requestJson(\"POST\",`${s}/invoke`,b,{},h),S=async(b,h={},f={})=>{if(f.approvalToken&&(f.approvalBinding===\"catalog\"||o.has(f.approvalToken))){if(\"identity\"in b)return await r().$call(b.identity,h,f);let N=r();for(let gs of b.path)N=N[gs];return await N(h,f)}if(f.approvalToken&&!f.operationId)throw TypeError(\"operationId is required when using an approval token\");f.signal?.throwIfAborted();let T=f.operationId??crypto.randomUUID(),C=me(b),v=p(C);if(f.refreshCatalog)c.delete(C);let k=f.refreshCatalog?await m(b).load({refresh:!0,...f.signal?{signal:f.signal}:{}}):c.get(C),q=f.approvalToken?d.get(f.approvalToken):void 0,H=f.expectedDefinitionDigest!==void 0?f.expectedDefinitionDigest:f.approvalToken?void 0:k?.definitionDigest;if(q&&(q.operationId!==T||(\"identity\"in b)&&me({identity:q.tool.entry.identity})!==C))throw new ie(T,q.tool.definitionDigest,H??\"\",q.tool.entry.identity);let Q=(N)=>w({operationId:T,target:b,arguments:h,...N===void 0?{}:{expectedDefinitionDigest:N},...f.approvalToken?{approvalToken:f.approvalToken}:{}},f.signal?{signal:f.signal}:{}),J;try{J=await Q(H)}catch(N){if(!Ps(N)||H===void 0)throw N;if(u.get(C)===v)c.delete(C);if(f.expectedDefinitionDigest!==void 0&&!f.approvalToken)throw N;if(k=await m(b).reloadAfterStale(H,f.signal),y(b,k,v),f.approvalToken||f.expectedDefinitionDigest!==void 0)throw new ie(T,H,k.definitionDigest,k.entry.identity);J=await Q(k.definitionDigest)}if(f.approvalToken)d.delete(f.approvalToken);if(y(b,J.tool,v),J.result.isError)throw new Ie(J.result);return J.tool.entry.outputSchema&&J.result.structuredContent!==void 0?J.result.structuredContent:J.result},I=async(b,h={},f={})=>{let T=await R({identity:b},{...f.signal?{signal:f.signal}:{}}),C=await e.requestJson(\"POST\",`${s}/target-approvals`,{identity:b,arguments:h,operationId:f.operationId??crypto.randomUUID(),expectedDefinitionDigest:f.expectedDefinitionDigest===void 0?T.definitionDigest:f.expectedDefinitionDigest},{},f.signal?{signal:f.signal}:{});if(d.size>=256)d.delete(d.keys().next().value);return d.set(C.approvalToken,C),C},x=(b)=>new Proxy(async(h={},f={})=>S({path:b},h,f),{get:(h,f)=>f===\"then\"||typeof f!==\"string\"?void 0:x([...b,f])});return new Proxy(Object.create(null),{get:(b,h)=>{if(h===\"then\"||typeof h!==\"string\")return;if(h===\"$targetProtocol\")return 1;if(h===\"$resolve\")return R;if(h===\"$invoke\")return w;if(h===\"$manifest\")return(f,T={})=>e.requestJson(\"POST\",`${s}/manifest`,f,{},T);if(h===\"$call\")return(f,T,C)=>S({identity:f},T,C);if(h===\"$approveTarget\")return I;if(h===\"$approve\")return async(...f)=>{let T=await r().$approve(...f);if(o.size>=256)o.delete(o.values().next().value);return o.add(T.approvalToken),T};if(h===\"$catalog\")return r().$catalog;if(h===\"$declarations\")return r().$declarations;return x([h])}})}var me=(e)=>(\"identity\"in e)?JSON.stringify([\"identity\",e.identity.serverId,e.identity.toolName]):JSON.stringify([\"path\",...e.path]),Ps=(e)=>{if(typeof e!==\"object\"||e===null)return!1;if(\"outcomeUnknown\"in e&&e.outcomeUnknown===!0||\"retryable\"in e&&e.retryable===!1)return!1;return e instanceof P?e.status===409&&e.details?.code===\"tool_definition_stale\":typeof e===\"object\"&&e!==null&&(\"code\"in e)&&e.code===\"tool_definition_stale\"};var wt=Z(()=>{V();Ae()});class re{transport;constructor(e){this.transport=e}forWorkspace(e){let t=Os(e,\"workspaceId\");if(this.transport.toolGatewayMode!==\"catalog\")return St(this.transport,t,()=>new re({toolGatewayMode:\"catalog\",requestJson:this.transport.requestJson.bind(this.transport)}).forWorkspace(t));let n=`/v1/workspaces/${encodeURIComponent(t)}/tools/catalog`,s=ke(async(d,m)=>await this.transport.requestJson(\"GET\",n,void 0,{},{signal:m})),i=new Map,r=async(d={})=>await s.load({...d.refresh?{refresh:!0}:{},...d.signal?{signal:d.signal}:{}}),o=async(d,m)=>await s.reloadAfterStale(d,m),a=async(d,m,y)=>{if(y.approvalToken&&!y.operationId)throw TypeError(\"operationId is required when using an approval token\");let R=y.operationId??crypto.randomUUID(),w=await r({...y.refreshCatalog===void 0?{}:{refresh:y.refreshCatalog},...y.signal?{signal:y.signal}:{}}),S=async(b)=>{let h=d(b),f=y.approvalToken?i.get(y.approvalToken):void 0;if(f&&(f.operationId!==R||f.catalogDigest!==b.digest||!xs(f.identity,h)))throw new ie(R,f.catalogDigest,b.digest,h);let T={operationId:R,catalogDigest:b.digest,identity:h,arguments:m,...y.approvalToken?{approvalToken:y.approvalToken}:{}},C;try{C=await this.transport.requestJson(\"POST\",`/v1/workspaces/${encodeURIComponent(t)}/tools/calls`,T,{},y.signal?{signal:y.signal}:{})}catch(k){if(Ce(k))s.invalidate(b.digest);else if(y.approvalToken)i.delete(y.approvalToken);throw k}if(y.approvalToken)i.delete(y.approvalToken);if(C.catalogDigest!==b.digest)s.invalidate(b.digest);if(C.result.isError)throw new Ie(C.result);return kt(b,h)?.outputSchema&&C.result.structuredContent!==void 0?C.result.structuredContent:C.result};try{return await S(w)}catch(b){if(!Ce(b))throw b}let I=await o(w.digest,y.signal),x=d(I);if(y.approvalToken&&I.digest!==w.digest)throw new ie(R,w.digest,I.digest,x);return await S(I)},c=async(d,m={},y={})=>await a((R)=>vt(R,d),m,y),u=async(d,m={},y={})=>{let R=y.operationId??crypto.randomUUID(),w=async(x)=>{let b={operationId:R,catalogDigest:x.digest,identity:vt(x,d),arguments:m};try{let h=await this.transport.requestJson(\"POST\",`/v1/workspaces/${encodeURIComponent(t)}/tools/approvals`,b,{},y.signal?{signal:y.signal}:{});return i.set(h.approvalToken,{operationId:h.operationId,catalogDigest:h.catalogDigest,identity:h.identity}),h}catch(h){if(Ce(h))s.invalidate(x.digest);throw h}},S=await r(y.signal?{signal:y.signal}:{});try{return await w(S)}catch(x){if(!Ce(x))throw x}let I=await o(S.digest,y.signal);return await w(I)},l=async(d,m={},y={})=>await a((R)=>Ts(R,d).identity,m,y),p=(d)=>new Proxy(async(m={},y={})=>await l(d,m,y),{get:(m,y)=>{if(y===\"then\")return;if(typeof y!==\"string\")return;return p([...d,y])}});return new Proxy(Object.create(null),{get:(d,m)=>{if(m===\"then\")return;if(m===\"$catalog\")return r;if(m===\"$call\")return c;if(m===\"$approve\")return u;if(m===\"$declarations\")return async(y={})=>await this.transport.requestJson(\"GET\",`/v1/workspaces/${encodeURIComponent(t)}/tools/declarations`,void 0,{},y.signal?{signal:y.signal}:{});if(typeof m!==\"string\")return;return p([m])}})}}function kt(e,t){return e.entries.find((n)=>n.identity.serverId===t.serverId&&n.identity.toolName===t.toolName)}function xs(e,t){return e.serverId===t.serverId&&e.toolName===t.toolName}function vt(e,t){let n=kt(e,t);if(!n)throw Error(`Tool is not present in the workspace catalog: ${t.serverId}/${t.toolName}`);return n.identity}function Ts(e,t){let n=e.entries.find((s)=>s.codemodePath.length===t.length&&s.codemodePath.every((i,r)=>i===t[r]));if(!n)throw Error(`Tool is not present in the workspace catalog: ${t.join(\".\")}`);return n}function Ce(e){if(typeof e!==\"object\"||e===null||\"outcomeUnknown\"in e&&e.outcomeUnknown===!0||\"retryable\"in e&&e.retryable===!1)return!1;return e instanceof P&&e.status===409&&e.details?.code===\"catalog_stale\"||typeof e===\"object\"&&e!==null&&\"code\"in e&&e.code===\"catalog_stale\"}function Os(e,t){let n=e.trim();if(!n)throw TypeError(`${t} is required`);return n}var Ie,ie;var Ae=Z(()=>{wt();V();Ie=class Ie extends Error{result;code;retryable;outcomeUnknown;constructor(e){let t=e.structuredContent;super(typeof t?.error?.message===\"string\"?t.error.message:\"Tool call failed\");this.result=e;this.name=\"OpenGeniToolCallError\",this.code=typeof t?.error?.code===\"string\"?t.error.code:\"tool_error\",this.retryable=t?.error?.retryable===!0,this.outcomeUnknown=t?.error?.outcomeUnknown===!0}};ie=class ie extends Error{operationId;previousCatalogDigest;catalogDigest;identity;code=\"tool_reapproval_required\";retryable=!1;constructor(e,t,n,s){super(\"The workspace tool catalog changed after approval. Request a new approval for the refreshed tool identity and retry with the same operation ID.\");this.operationId=e;this.previousCatalogDigest=t;this.catalogDigest=n;this.identity=s;this.name=\"OpenGeniToolReapprovalRequiredError\"}}});function bi(e,t){if(e.length<t.length)return!1;let n=e.length-t.length;return t.every((s,i)=>e[n+i]===s)}function Si(e){for(let t of e.matchAll(mi)){let n=t[2]??t[3];if(!n)continue;let s=n.replace(/([a-z0-9])([A-Z])/g,\"$1 $2\").replace(/([A-Z]+)([A-Z][a-z])/g,\"$1 $2\").toLowerCase().split(/[^a-z0-9]+/).filter(Boolean),i=s.at(-1);if(i&&fi.has(i))return!0;if(i&&hi.some((r)=>i.endsWith(r)))return!0;if(Ri.some((r)=>bi(s,r)))return!0}return!1}function wi(e){for(let t of e.matchAll(ci))if(!ui.test(t[0]))return!0;return!1}function vi(e){if(/[?:#]/u.test(e))return!1;let[t,...n]=e.split(\"/\");if(!t||n.length===0||n.some((s)=>!s))return!1;if(!gi.has(t)||n.some((s)=>!/^[A-Z][A-Za-z0-9_-]*$/u.test(s)))return!1;return!0}function ki(e){if(di.some((t)=>t.test(e)))return!0;for(let t of e.matchAll(li)){let n=t[0];if(n.toLowerCase().startsWith(\"www.\"))return!0;if(!/[/?#]/u.test(n))continue;let r=(n.split(/[/?#]/u,1)[0]??\"\").replace(/:\\\\d{1,5}$/u,\"\").split(\".\").at(-1)?.toLowerCase();if(r&&pi.has(r))continue;if(vi(n))continue;return!0}return!1}function Pi(e){return e.normalize(\"NFKC\").replace(Ai,\"\").replace(Ci,\"\")}function xi(e){let t=Pi(e);if(ai.some((n)=>n.test(t)))return!0;if(wi(t))return!0;if(ki(t))return!0;if(yi.test(t))return!0;if(Si(t))return!0;if(Ii.test(t))return!0;return!1}function Ti(e){if(Ge===void 0)Ge=typeof Intl.Segmenter===\"function\"?new Intl.Segmenter(void 0,{granularity:\"grapheme\"}):null;if(Ge)return Array.from(Ge.segment(e),(n)=>n.segment);let t=[];for(let n of e){let s=t.at(-1);if(s&&(/^[\\\\p{Mark}\\\\u{FE0E}\\\\u{FE0F}\\\\p{Emoji_Modifier}]$/u.test(n)||n===\"‍\"||s.endsWith(\"‍\")))t[t.length-1]=`${s}${n}`;else t.push(n)}return t}function qi(e){return e.replace(Oi,`\\n`)}function Ei(e,t){if(e===null||e===void 0)return null;if(t===\"user\")return e;let n=qi(e);if(n===e)return e;return n.split(`\\n`).map((s)=>s.trim()).find(Boolean)??null}function _i(e){let t=e.split(/\\\\s+/u),n=t.length>10?t.slice(0,10).join(\" \"):e,s=Ti(n);if(s.length<=80)return n;let i=s.slice(0,80).join(\"\"),r=i.search(/\\\\s+\\\\S*$/u);return(r>=16?i.slice(0,r):i).trimEnd()}function et(e){if(typeof e!==\"string\")return null;let t=e.slice(0,4096).replace(/[\\\\u0000-\\\\u001f\\\\u007f-\\\\u009f]+/gu,`\\n`).split(/\\\\n+/u);for(let n of t){let s=n.trim();if(!s||xi(s))continue;let i=_i(s.replace(/\\\\s+/gu,\" \")).replace(/[\\\\s.!?,;:\\\\-–—]+$/u,\"\").trim();if(i)return i}return null}function $n(e){let t=typeof e===\"string\"?e.trim():\"\";return oi.test(t)?`Conversation ${t.slice(0,13)}`:\"New conversation\"}function tt(e){let t=e.title?.trim()??\"\";return e.titleSource!==\"user\"&&(!t||t===\"New conversation\")}function Bn(e,t={}){let n=e.title?.trim()??\"\";if(e.titleSource===\"user\")return n||$n(e.id);if(n&&!tt(e)){let s=Ei(n,e.titleSource)?.trim();if(s)return s}for(let s of t.metadataKeys??[]){let i=e.metadata?.[s];if(typeof i===\"string\"&&i.trim().length>0)return i.trim()}return et(e.initialMessage)??$n(e.id)}var oi,Ge,ai,ci,ui,li,di,pi,gi,mi,yi,fi,hi,Ri,Ii,Ai,Ci,Oi;var Ln=Z(()=>{oi=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu,ai=[/-----BEGIN [A-Z ]*PRIVATE KEY-----/iu,/\\\\bBearer\\\\s+[A-Za-z0-9._~+/=-]{8,}/iu,/\\\\b(?:sk-(?:proj-)?|gh[oprsu]_|github_pat_|glpat-|xox[baprs]-)[A-Za-z0-9_-]{8,}/iu,/\\\\bAKIA[0-9A-Z]{16}\\\\b/u,/\\\\bAIza[0-9A-Za-z_-]{20,}\\\\b/u,/\\\\beyJ[A-Za-z0-9_-]+\\\\.eyJ[A-Za-z0-9_-]+\\\\.[A-Za-z0-9_-]+\\\\b/u,/[?&](?:access_token|api_key|apikey|password|secret|token)=[^\\\\s&#]+/iu],ci=/\\\\b[a-z][a-z0-9+.-]*:\\\\S+/giu,ui=/^[a-z]:[\\\\\\\\/](?![\\\\\\\\/])[^:]*$/iu,li=/\\\\b(?:www\\\\.)?(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\\\\.)+[a-z](?:[a-z0-9-]{0,61}[a-z0-9])?(?::\\\\d{1,5})?(?:[/?#][^\\\\s]*)?/giu,di=[/\\\\blocalhost(?:(?::\\\\d{1,5})(?:[/?#][^\\\\s]*)?|[/?#][^\\\\s]*)/iu,/\\\\b(?:(?:25[0-5]|2[0-4]\\\\d|1?\\\\d?\\\\d)\\\\.){3}(?:25[0-5]|2[0-4]\\\\d|1?\\\\d?\\\\d)(?:(?::\\\\d{1,5})(?:[/?#][^\\\\s]*)?|[/?#][^\\\\s]*)/u,/\\\\[(?=[0-9a-f:.]*:[0-9a-f:.]*\\\\])[0-9a-f:.]+\\\\](?:(?::\\\\d{1,5})(?:[/?#][^\\\\s]*)?|[/?#][^\\\\s]*)/iu],pi=new Set([\"css\",\"html\",\"js\",\"json\",\"jsx\",\"lock\",\"md\",\"sql\",\"toml\",\"ts\",\"tsx\",\"xml\",\"yaml\",\"yml\"]),gi=new Set([\"ASP.NET\",\"AWS.SDK\",\"Microsoft.Extensions\",\"System.IO\"]),mi=/(?:^|[^A-Za-z0-9])(?:([\\'\"])([A-Za-z][A-Za-z0-9_. -]*)\\\\1|([A-Za-z][A-Za-z0-9_.-]*))\\\\s*[=:]\\\\s*[^\\\\s,;]+/gu,yi=/\\\\b(?:api[ _-]?key|access[ _-]?token|auth[ _-]?token|credential|credentials|password|passwd|private[ _-]?key|secret|token)\\\\b\\\\s*[=:]\\\\s*[^\\\\s,;]+/iu,fi=new Set([\"credential\",\"credentials\",\"password\",\"passwd\",\"secret\",\"token\"]),hi=[\"apikey\",\"accesskey\",\"accesskeyid\",\"accesstoken\",\"authtoken\",\"credential\",\"credentials\",\"password\",\"passwd\",\"privatekey\",\"secret\",\"secretkey\",\"token\"],Ri=[[\"api\",\"key\"],[\"access\",\"key\"],[\"access\",\"key\",\"id\"],[\"auth\",\"key\"],[\"private\",\"key\"],[\"secret\",\"key\"]];Ii=/\\\\b(?=[A-Za-z0-9_-]{32,}\\\\b)(?=[A-Za-z0-9_-]*[A-Za-z])(?=[A-Za-z0-9_-]*\\\\d)[A-Za-z0-9_-]+\\\\b/u,Ai=/\\\\p{Default_Ignorable_Code_Point}+/gu,Ci=/\\\\\\\\+(?=[\"\\'])/gu;Oi=/<[||][^<>||\\\\s]{1,64}[||]>/gu});function Me(e){let t=e.metadata._opengeniSiteOrigin,n=t&&typeof t.siteId===\"string\"&&/^[\\\\da-f]{8}-[\\\\da-f]{4}-[\\\\da-f]{4}-[\\\\da-f]{4}-[\\\\da-f]{12}$/i.test(t.siteId)&&typeof t.title===\"string\"?{siteId:t.siteId,title:t.title}:null,s=e.metadata.scheduledTaskId;return{id:e.id,workspaceId:e.workspaceId,accountId:e.accountId,status:e.status,backgroundCommandActivity:e.backgroundCommandActivity,hasSchedules:e.hasSchedules,hasUpcomingSchedules:e.hasUpcomingSchedules,title:e.title,titleSource:e.titleSource,displayTitle:Bn(e),renameSeed:tt(e)?et(e.initialMessage)??\"\":e.title?.trim()??\"\",scheduledTaskId:typeof s===\"string\"&&s.length>0?s:null,siteOrigin:n,...e.model?{model:e.model}:{},...e.reasoningEffort?{reasoningEffort:e.reasoningEffort}:{},createdBy:e.createdBy,channelId:e.channelId,parentSessionId:e.parentSessionId,rootSessionId:e.rootSessionId,effectiveControl:e.effectiveControl,inputWait:e.inputWait,lastSequence:e.lastSequence,pinned:e.pinned??!1,pinnedAt:e.pinnedAt??null,pinVersion:e.pinVersion??0,unread:e.unread??!1,activelyWorking:e.activelyWorking??!1,attentionVersion:e.attentionVersion??0,archived:e.archived??!1,archivedAt:e.archivedAt??null,importedArchive:e.importedArchive,...e.retention?{retention:e.retention}:{},archiveVersion:e.archiveVersion??0,treeStats:e.treeStats,requiresActionSince:e.requiresActionSince,...e.admissionBlock!==void 0?{admissionBlock:e.admissionBlock}:{},createdAt:e.createdAt,updatedAt:e.updatedAt}}var Wn=Z(()=>{Ln()});var zn=Z(()=>{Wn()});var ms=Object.freeze([{id:\"config.client\",method:\"GET\",pattern:/^\\\\/v1\\\\/config\\\\/client$/u},{id:\"workspace.get\",method:\"GET\",pattern:/^$/u},{id:\"site.config\",method:\"GET\",pattern:/^\\\\/site\\\\/config$/u},{id:\"models.list\",method:\"GET\",pattern:/^\\\\/model-catalog$/u},{id:\"sessions.list\",method:\"GET\",pattern:/^\\\\/sessions$/u},{id:\"sessions.create\",method:\"POST\",pattern:/^\\\\/sessions$/u,agent:!0},{id:\"sessions.get\",method:\"GET\",pattern:new RegExp(\"^/sessions/[A-Za-z0-9_-]{1,128}$\",\"u\")},{id:\"sessions.events\",method:\"GET\",pattern:new RegExp(\"^/sessions/[A-Za-z0-9_-]{1,128}/events$\",\"u\")},{id:\"sessions.stream\",method:\"GET\",pattern:new RegExp(\"^/sessions/[A-Za-z0-9_-]{1,128}/events/stream$\",\"u\"),stream:!0},{id:\"sessions.send\",method:\"POST\",pattern:new RegExp(\"^/sessions/[A-Za-z0-9_-]{1,128}/events$\",\"u\"),agent:!0},{id:\"sessions.steer\",method:\"POST\",pattern:new RegExp(\"^/sessions/[A-Za-z0-9_-]{1,128}/steer$\",\"u\"),agent:!0},{id:\"sessions.control\",method:\"POST\",pattern:new RegExp(\"^/sessions/[A-Za-z0-9_-]{1,128}/control$\",\"u\"),agent:!0},{id:\"sessions.queue\",method:\"GET\",pattern:new RegExp(\"^/sessions/[A-Za-z0-9_-]{1,128}/queue$\",\"u\")},{id:\"sessions.queue.item\",method:\"POST\",pattern:new RegExp(\"^/sessions/[A-Za-z0-9_-]{1,128}/queue/[A-Za-z0-9_-]{1,128}/(?:move|edit|steer|delete)$\",\"u\"),agent:!0},{id:\"sessions.composerDraft.get\",method:\"GET\",pattern:new RegExp(\"^/sessions/[A-Za-z0-9_-]{1,128}/composer-draft$\",\"u\")},{id:\"sessions.composerDraft.put\",method:\"PUT\",pattern:new RegExp(\"^/sessions/[A-Za-z0-9_-]{1,128}/composer-draft$\",\"u\")},{id:\"sessions.composerDraft.submit\",method:\"POST\",pattern:new RegExp(\"^/sessions/[A-Za-z0-9_-]{1,128}/composer-draft/submit$\",\"u\"),agent:!0},{id:\"sessions.humanInput\",method:\"GET\",pattern:new RegExp(\"^/sessions/[A-Za-z0-9_-]{1,128}/human-input-requests$\",\"u\")},{id:\"sessions.humanInput.get\",method:\"GET\",pattern:new RegExp(\"^/sessions/[A-Za-z0-9_-]{1,128}/human-input-requests/[A-Za-z0-9_-]{1,128}$\",\"u\")},{id:\"data.read\",method:\"GET\",pattern:new RegExp(\"^/published-artifacts/current/(?:data|files)(?:/[A-Za-z0-9._~:@!$&\\'()*+,;=-]+)*$\",\"u\")},{id:\"data.write\",method:\"POST\",pattern:new RegExp(\"^/published-artifacts/current/(?:data|files)(?:/[A-Za-z0-9._~:@!$&\\'()*+,;=-]+)*$\",\"u\")},{id:\"data.put\",method:\"PUT\",pattern:new RegExp(\"^/published-artifacts/current/(?:data|files)(?:/[A-Za-z0-9._~:@!$&\\'()*+,;=-]+)*$\",\"u\")},{id:\"data.patch\",method:\"PATCH\",pattern:new RegExp(\"^/published-artifacts/current/(?:data|files)(?:/[A-Za-z0-9._~:@!$&\\'()*+,;=-]+)*$\",\"u\")},{id:\"data.delete\",method:\"DELETE\",pattern:new RegExp(\"^/published-artifacts/current/(?:data|files)(?:/[A-Za-z0-9._~:@!$&\\'()*+,;=-]+)*$\",\"u\")},{id:\"sql.run\",method:\"POST\",pattern:/^\\\\/published-artifacts\\\\/current\\\\/sql\\\\/queries\\\\/[A-Za-z][A-Za-z0-9_-]{0,63}$/u},{id:\"site.report\",method:\"POST\",pattern:/^\\\\/site\\\\/reports$/u}]),Cr=Object.freeze([\"catalog\",\"declarations\",\"call\",\"resolve\",\"invoke\"]);function ct(e,t){if(/[%\\\\\\\\#\\\\u0000-\\\\u0020\\\\u007f]/u.test(t))return null;if(t.split(\"/\").some((r)=>r===\".\"||r===\"..\"))return null;let n=e.toUpperCase(),s;if(t===\"/v1/config/client\")s=t;else if(t===\"/v1/workspaces/site-host\")s=\"\";else if(t.startsWith(\"/v1/workspaces/site-host/\"))s=t.slice(24);else return null;let i=ms.find((r)=>r.method===n&&r.pattern.test(s));return i?{operation:i,suffix:s}:null}var ys=/^\\\\/v1\\\\/workspaces\\\\/site-host\\\\/published-artifacts\\\\/([^/]+)\\\\/(?:data|files|sql)(?:\\\\/|$)/u,fs=\"00000000-0000-0000-0000-000000000000\";class Se extends Error{code=\"site_session_path_unsupported\";constructor(){super(\"Unsupported Site session API path\");this.name=\"SiteSessionPathError\"}}class lt extends Error{code=\"site_data_unsupported\";constructor(){super(\"This Site host does not provide Site Data\");this.name=\"SiteDataUnsupportedError\"}}function hs(e,t){let n=new URL(e,\"http://site.invalid\");if(n.pathname===\"/v1/config/client\"){let s=n.searchParams.getAll(\"workspaceId\");if(s.length>1||s.length===1&&s[0]!==\"site-host\"&&s[0]!==t)throw new Se;if(t!==\"site-host\")n.searchParams.set(\"workspaceId\",t);return n.pathname+n.search}return e.replace(\"/workspaces/site-host\",`/workspaces/${encodeURIComponent(t)}`)}function Rs(e,t,n,s){if(n===\"site-host\")return e;if(!s)throw new lt;return t.replace(\"/published-artifacts/current/\",`/published-artifacts/${encodeURIComponent(s)}/`)}function de(e,t,n=\"GET\",s){let i=e.split(\"?\")[0],r=ct(n,i);if(!r)throw new Se;let o=hs(e,t);if(ys.test(i))return Rs(e,o,t,s);if(r.operation.id!==\"sessions.list\")return o;let a=new URL(o,\"http://site.invalid\"),c=a.searchParams.getAll(\"originSiteId\"),u=a.searchParams.getAll(\"siteAccessId\"),l=a.searchParams.getAll(\"view\");if(l.length>1||l.length===1&&l[0]!==\"page\"||c.length+u.length!==1||(c[0]??u[0])!==\"current\")throw new Se;if(t===\"site-host\")return e;return a.searchParams.set(u.length?\"siteAccessId\":\"originSiteId\",s??fs),a.pathname+a.search}var ut=[\"text\",\"annotations\",\"model\",\"reasoningEffort\",\"latencyMode\",\"controlEtag\",\"expectedDraftRevision\"],Tr=Object.freeze({\"sessions.send\":[\"type\",\"payload\",\"clientEventId\"],\"sessions.steer\":[...ut,\"clientEventId\"],\"sessions.control\":[\"action\",\"reason\",\"clientEventId\",\"expectedControlEtag\"],\"sessions.composerDraft.put\":[\"text\",\"annotations\",\"resources\",\"model\",\"reasoningEffort\",\"latencyMode\",\"expectedRevision\"],\"sessions.composerDraft.submit\":[...ut,\"resources\",\"connectionAccounts\",\"clientEventId\",\"delivery\"],\"sessions.queue.move\":[\"clientEventId\",\"expectedQueueVersion\",\"beforeTurnId\"],\"sessions.queue.edit\":[\"clientEventId\",\"expectedTurnVersion\",\"expectedDraftRevision\",\"replaceDraft\"],\"sessions.queue.steer\":[\"clientEventId\",\"expectedTurnVersion\",\"controlEtag\"],\"sessions.queue.delete\":[\"clientEventId\",\"expectedTurnVersion\",\"reason\"]});var Or=Object.freeze([\"initialMessage\",\"requestedSessionId\",\"idempotencyKey\",\"clientEventId\",\"model\",\"reasoningEffort\",\"latencyMode\",\"startMode\",\"metadata\"]);var Cs=\"opengeni.site.http\",ge=\"site-host\";async function bt(e,t,n){let s=new Request(t,n),i=new URL(s.url),r=`${i.pathname}${i.search}`;de(r,ge,s.method);let o=new MessageChannel,a=crypto.randomUUID(),c=n?.body instanceof ArrayBuffer||ArrayBuffer.isView(n?.body)||typeof Blob<\"u\"&&n?.body instanceof Blob,u=s.body?c?await s.arrayBuffer():await s.text():void 0;return await new Promise((l,p)=>{let d,m=!1,y=()=>{m=!0,s.signal.removeEventListener(\"abort\",R),o.port1.close()},R=()=>{if(m)return;e.postMessage({type:\"opengeni.site.cancel\",version:2,requestId:a});let w=s.signal.reason??new DOMException(\"Cancelled\",\"AbortError\");d?.error(w),p(w),y()};if(o.port1.onmessage=(w)=>{let S=w.data;if(S.error){let I=Error(S.error);d?.error(I),p(I),y()}else if(S.status){let I=S.body?new ReadableStream({start(x){d=x},pull(){o.port1.postMessage(\"pull\")},cancel(){d=void 0,R()}}):null;if(l(new Response(I,{status:S.status,headers:S.headers})),!S.body)y()}else if(S.done)d?.close(),y();else if(S.chunk)d?.enqueue(S.chunk)},s.signal.aborted){R();return}s.signal.addEventListener(\"abort\",R,{once:!0}),e.postMessage({type:Cs,requestId:a,path:r,method:s.method,headers:[...s.headers],...u===void 0?{}:{body:u}},[o.port2])})}Ae();var It=\"X-OpenGeni-Session-Sequence\",Ke=new WeakMap;function At(e,t){if(t===null||typeof e!==\"object\"||e===null)return;let n=Number(t);if(Number.isSafeInteger(n)&&n>=0)Ke.set(e,n)}function Ct(e,t){if(typeof e!==\"object\"||e===null||typeof t!==\"object\"||t===null)return;let n=Ke.get(e);if(n!==void 0)Ke.set(t,n)}var qs=[\"agent.toolCall.created\",\"agent.toolCall.output\",\"agent.reasoning.delta\",\"sandbox.command.output.delta\",\"terminal.pty.output.delta\"],Es=[\"agent.model.request\",\"agent.model.usage\"],Kr=[...qs,...Es];var Pt=\"X-OpenGeni-Conversation-Filter\";function Pe(e){let t=new URLSearchParams;for(let[s,i]of Object.entries(e)){if(i===void 0)continue;for(let r of Array.isArray(i)?i:[i])t.append(s,String(r))}let n=t.toString();return n?`?${n}`:\"\"}V();var G=encodeURIComponent;function _s(e){let t={};if(e.q)t.q=e.q;if(e.type)t.type=e.type;if(e.includeArchived)t.includeArchived=\"true\";if(e.cursor)t.cursor=e.cursor;if(e.limit)t.limit=String(e.limit);return t}function xt(e,t){let n=`/v1/workspaces/${G(t)}`,s=(a)=>`${n}/vaults/${G(a)}`,i=(a,c)=>`${s(a)}/items/${G(c)}`,r=(a,c,u)=>`${i(a,c)}/fields/${G(u)}`,o=(a,c,u,l,p)=>e.requestJson(a,c,u,l??{},p?{signal:p}:{});return{listVaults:async(a)=>(await o(\"GET\",`${n}/vaults`,void 0,{},a)).vaults,getVault:(a,c)=>o(\"GET\",s(a),void 0,{},c),createVault:(a)=>o(\"POST\",`${n}/vaults`,a),updateVault:(a,c)=>o(\"PATCH\",s(a),c),deleteVault:(a,c)=>e.requestJson(\"DELETE\",s(a),{confirmName:c},{},{responseType:\"void\"}),syncVault:(a)=>o(\"POST\",`${s(a)}/sync`,{}),listItems:(a,c={},u)=>o(\"GET\",`${s(a)}/items`,void 0,_s(c),u),getItem:(a,c,u)=>o(\"GET\",i(a,c),void 0,{},u),createItem:(a,c)=>o(\"POST\",`${s(a)}/items`,c),updateItem:(a,c,u)=>o(\"PATCH\",i(a,c),u),deleteItem:(a,c,u=!1)=>e.requestJson(\"DELETE\",i(a,c),void 0,u?{permanent:\"true\"}:{},{responseType:\"void\"}),restoreItem:(a,c)=>o(\"POST\",`${i(a,c)}/restore`,{}),moveItem:(a,c,u)=>o(\"POST\",`${i(a,c)}/move`,u),revealField:(a,c,u,l)=>o(\"POST\",`${r(a,c,u)}/reveal`,l===void 0?{}:{version:l}),listFieldVersions:async(a,c,u,l)=>(await o(\"GET\",`${r(a,c,u)}/versions`,void 0,{},l)).versions,restoreFieldVersion:(a,c,u,l)=>o(\"POST\",`${r(a,c,u)}/restore`,{version:l}),getSessionSecrets:(a,c)=>o(\"GET\",`${n}/sessions/${G(a)}/secrets`,void 0,{},c),setSessionVaultPolicy:(a,c)=>o(\"PUT\",`${n}/sessions/${G(a)}/vault-policy`,{policy:c}),installOnePassword:(a)=>o(\"POST\",`${n}/connections/1password/install`,a),listOnePasswordConnections:async(a)=>(await o(\"GET\",`${n}/connections/1password/service-accounts`,void 0,{},a)).connections,replaceOnePasswordToken:(a,c)=>o(\"PUT\",`${n}/connections/${G(a)}/1password/token`,c),disconnectOnePassword:(a)=>o(\"DELETE\",`${n}/connections/${G(a)}/1password`),listProviderVaults:async(a,c)=>(await o(\"GET\",`${n}/connections/${G(a)}/provider-vaults`,void 0,{},c)).vaults,installVaultProvider:(a)=>o(\"POST\",`${n}/vault-providers/connections`,a),getVaultProviderCatalog:(a)=>o(\"GET\",`${n}/vault-providers/connections`,void 0,{},a),listVaultProviderConnections:async(a)=>(await o(\"GET\",`${n}/vault-providers/connections`,void 0,{},a)).connections,replaceVaultProviderCredentials:(a,c)=>o(\"PUT\",`${n}/vault-providers/connections/${G(a)}/credentials`,c),disconnectVaultProvider:(a)=>o(\"DELETE\",`${n}/vault-providers/connections/${G(a)}`),verifyVaultProviderConnection:(a)=>o(\"POST\",`${n}/vault-providers/connections/${G(a)}/verify`,{}),linkProviderVault:(a)=>o(\"POST\",`${n}/vaults/link`,a),createManagedProviderVault:(a,c)=>o(\"POST\",`${n}/connections/${G(a)}/managed-vaults`,c)}}V();async function*Y(e){let t=e.getReader(),n=new TextDecoder,s=\"\",i,r,o=null,a=()=>{let u=o===null?null:{...i!==void 0?{id:i}:{},...r!==void 0?{event:r}:{},data:o.join(`\\n`)};return i=void 0,r=void 0,o=null,u},c=(u)=>{if(u===\"\")return a();if(u.startsWith(\":\"))return null;let l=u.indexOf(\":\"),p=l===-1?u:u.slice(0,l),d=l===-1?\"\":u.slice(l+1);if(d.startsWith(\" \"))d=d.slice(1);if(p===\"data\")(o??=[]).push(d);else if(p===\"event\")r=d;else if(p===\"id\")i=d;return null};try{while(!0){let{done:u,value:l}=await t.read();if(u)break;s+=n.decode(l,{stream:!0});let p=s.indexOf(`\\n`);while(p!==-1){let d=s.slice(0,p);if(s=s.slice(p+1),d.endsWith(\"\\\\r\"))d=d.slice(0,-1);let m=c(d);if(m)yield m;p=s.indexOf(`\\n`)}}}finally{t.cancel().catch(()=>{});try{t.releaseLock()}catch{}}}var Ot=Symbol.for(\"@opengeni/sdk/session-event-stream-covered-through\");async function*qt(e,t={}){let n=t.signal,s=t.reconnect??!0,i=t.reconnectDelayMs??500,r=t.maxReconnectDelayMs??1e4,o=t.reconnectJitterRatio??0.2,a=t.beforeLiveTimeoutMs??15000,c=t.heartbeatTimeoutMs??45000,u=t.maxReconnectAttempts??Number.POSITIVE_INFINITY,l=t.after??0,p=0,d=i,m=!1,y=!1;while(!0){if(n?.aborted)break;t.onStateChange?.(m||p>0?\"reconnecting\":\"connecting\");let R=l;try{if(y&&t.beforeReconnect){let S=await Gs(t.beforeReconnect,l,n);if(n?.aborted)return;if(typeof S===\"number\"&&Number.isSafeInteger(S))l=Math.max(l,S);R=l}y=!0;let w=await e.openStream(l,n);m=!0,p=0,d=i;try{t.onOpen?.()}catch{}await ee(t.beforeLive,a,n),t.onStateChange?.(\"live\");for await(let S of Y(te(w,c,n))){if(n?.aborted)return;let I=Us(S.data);if(!I)continue;let x=Ds(S.id,I.sequence);if($s(I,x),x<=l)continue;if(I.sequence>l+1){for await(let b of Ms(e,l,I.sequence-1))if(l=b.sequence,yield b,n?.aborted)return}l=x,yield I}if(!s)return;if(l===R)await Tt(W(i,o),n);continue}catch(w){if(n?.aborted||K(w))return;if(!s||!j(w))throw w;if(p+=1,p>u)throw new L(`event stream gave up after ${u} consecutive failed reconnect attempts: ${w instanceof Error?w.message:String(w)}`)}await Tt(W(d,o),n),d=Math.min(Math.max(d*2,i),r)}}async function ee(e,t,n){if(!e)return;let s,i,r=new Promise((o,a)=>{if(s=setTimeout(()=>a(TypeError(`stream reconciliation timed out after ${t}ms`)),t),n)i=()=>a(new DOMException(\"Aborted\",\"AbortError\")),n.addEventListener(\"abort\",i,{once:!0})});try{await Promise.race([Promise.resolve().then(e),r])}finally{if(s!==void 0)clearTimeout(s);if(n&&i)n.removeEventListener(\"abort\",i)}}async function Gs(e,t,n){if(!n)return await e(t);if(n.aborted)throw new DOMException(\"Aborted\",\"AbortError\");let s,i=new Promise((r,o)=>{s=()=>o(new DOMException(\"Aborted\",\"AbortError\")),n.addEventListener(\"abort\",s,{once:!0})});try{return await Promise.race([Promise.resolve().then(()=>e(t)),i])}finally{if(s)n.removeEventListener(\"abort\",s)}}function W(e,t){if(e<=0||t<=0)return e;let n=Math.min(t,1),s=e*n;return Math.max(0,e-s+Math.random()*s*2)}function te(e,t,n){if(!Number.isSafeInteger(t)||t<=0)throw RangeError(\"stream heartbeat timeout must be a positive safe integer\");let s=e.getReader();return new ReadableStream({pull:async(i)=>{let r,o;try{let a=await Promise.race([s.read(),new Promise((c,u)=>{if(r=setTimeout(()=>u(TypeError(`event stream heartbeat timed out after ${t}ms`)),t),n)o=()=>u(new DOMException(\"Aborted\",\"AbortError\")),n.addEventListener(\"abort\",o,{once:!0})})]);if(a.done)i.close();else i.enqueue(a.value)}catch(a){s.cancel(a).catch(()=>{}),i.error(a)}finally{if(r!==void 0)clearTimeout(r);if(n&&o)n.removeEventListener(\"abort\",o)}},cancel:(i)=>{s.cancel(i).catch(()=>{})}})}async function*Ms(e,t,n){let s=t;while(s<n){let r=(await e.listEvents(s,Math.min(500,n-s))).filter((o)=>o.sequence>s&&o.sequence<=n).sort((o,a)=>o.sequence-a.sequence);if(r.length===0)throw new L(`event replay backfill stalled: expected sequences ${s+1}..${n} but the replay endpoint returned none of them`);for(let o of r){if(o.sequence!==s+1)throw new L(`event replay backfill is missing sequence ${s+1} (replay endpoint skipped to ${o.sequence}); refusing to deliver with a gap`);s=o.sequence,yield o}}}function Us(e){let t;try{t=JSON.parse(e)}catch{return null}if(typeof t!==\"object\"||t===null||typeof t.sequence!==\"number\"||typeof t.type!==\"string\"||typeof t.id!==\"string\")return null;return t}function Et(e){let t=e[Ot];return typeof t===\"number\"&&Number.isSafeInteger(t)&&t>=e.sequence?t:null}function Ds(e,t){if(e===void 0||!/^\\\\d+$/.test(e))return t;let n=Number(e);return Number.isSafeInteger(n)&&n>=t?n:t}function $s(e,t){Object.defineProperty(e,Ot,{value:t,enumerable:!1,configurable:!1,writable:!1})}async function Tt(e,t){if(t?.aborted||e<=0)return;await new Promise((n)=>{let s=setTimeout(i,e);function i(){clearTimeout(s),t?.removeEventListener(\"abort\",i),n()}t?.addEventListener(\"abort\",i,{once:!0})})}var Bs=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}|\\\\d+|[A-Za-z0-9_-]{20,})$/i;function Ls(e){return e.split(\"/\").map((t)=>Bs.test(t)?\":id\":t).join(\"/\")}function Ws(e){let t=e.trim(),n=/^@(-?\\\\d+)$/.exec(t);if(n)return new Date(Number(n[1])*1000);let s=Date.parse(t);return Number.isNaN(s)?null:new Date(s)}function zs(e){let t=new Map;if(!e)return t;for(let n of e.matchAll(/<([^>]*)>\\\\s*((?:;\\\\s*[^;,]+)*)/g)){let s=/;\\\\s*rel=\"?([^\";,]+)\"?/i.exec(n[2]??\"\")?.[1];if(!s)continue;for(let i of s.toLowerCase().split(/\\\\s+/))if(!t.has(i))t.set(i,n[1])}return t}function Ns(e,t,n){let s=n.get(\"deprecation\"),i=n.get(\"sunset\");if(!s&&!i)return null;let r=t;try{r=new URL(t,\"http://opengeni.invalid\").pathname}catch{}let o=i?Date.parse(i):Number.NaN,a=zs(n.get(\"link\"));return{method:e.toUpperCase(),route:Ls(r),path:r,deprecatedAt:s?Ws(s):null,sunset:Number.isNaN(o)?null:new Date(o),link:a.get(\"deprecation\")??a.get(\"sunset\")??null,successor:a.get(\"successor-version\")??null}}var _t=new Set;function Fs(e){let t=`${e.method} ${e.route}`;if(_t.has(t))return;_t.add(t);let n=e.sunset?` and will be removed after ${e.sunset.toISOString()}`:\"\",s=e.link?` Migration notes: ${e.link}.`:\"\";console.warn(`[@opengeni/sdk] ${t} is deprecated${n}.${s} Upgrade @opengeni/sdk, or pass onDeprecation to handle this notice.`)}function Gt(e,t){if(t===!1)return e;let n=t??Fs,s=new Set;return async(i,r)=>{let o=await e(i,r);try{let a=o.headers;if(a&&(a.get(\"deprecation\")||a.get(\"sunset\"))){let c=r?.method??(typeof Request<\"u\"&&i instanceof Request?i.method:\"GET\"),u=typeof i===\"string\"?i:i instanceof URL?i.href:i.url,l=Ns(c,u,a);if(l){let p=`${l.method} ${l.route}`;if(!s.has(p))s.add(p),n(l)}}}catch{}return o}}V();var xe=Object.freeze({maxAttempts:4,initialDelayMs:250,maxDelayMs:2000,maxElapsedMs:5000}),Js=10,Mt=60000;function Te(e,t,n,s){if(typeof e!==\"number\"||!Number.isFinite(e))return t;return Math.min(Math.max(e,n),s)}function Ut(e){if(e===!1)return null;let t=e&&typeof e===\"object\"?e:{},n=Math.floor(Te(t.maxAttempts,xe.maxAttempts,1,Js));if(n<=1)return null;let s=Te(t.maxElapsedMs,xe.maxElapsedMs,0,Mt),i=Te(t.maxDelayMs,xe.maxDelayMs,0,Mt),r=Te(t.initialDelayMs,xe.initialDelayMs,0,i);return{maxAttempts:n,initialDelayMs:r,maxDelayMs:i,maxElapsedMs:s}}function Dt(e){let t=e.toUpperCase();return t===\"GET\"||t===\"HEAD\"}function je(e){return e===502||e===503||e===504}var $t=new WeakSet;function Ye(e){if(e instanceof TypeError)$t.add(e)}var Bt=new WeakSet;function A(e,t){let n=new P(502,e,t);return Bt.add(n),n}var Vs=/failed to fetch|fetch failed|networkerror|network error|load failed|network request failed|network connection was lost|terminated|err_http2|econnreset|socket hang up/iu;function Lt(e){if(e instanceof P)return!Bt.has(e)&&je(e.status)&&e.retryable;if(!(e instanceof TypeError))return!1;return $t.has(e)||Vs.test(e.message)}function Wt(e,t=Date.now()){if(e===null||e===void 0)return null;let n=e.trim();if(!n)return null;if(/^\\\\d+$/.test(n)){let i=Number(n);return Number.isSafeInteger(i)?i*1000:null}if(!/[A-Za-z]/.test(n))return null;let s=Date.parse(n);if(!Number.isFinite(s))return null;return Math.max(0,s-t)}function zt(e,t,n,s,i=Math.random){if(t>=e.maxAttempts)return null;let r;if(s!==null)r=s*(1+0.2*Math.min(Math.max(i(),0),1));else{let o=Math.min(e.maxDelayMs,e.initialDelayMs*2**(t-1));r=o/2+o/2*Math.min(Math.max(i(),0),1)}if(n+r>e.maxElapsedMs)return null;return Math.round(r)}function Nt(e,t){if(t?.aborted)return Promise.reject(t.reason??new DOMException(\"Request aborted\",\"AbortError\"));return new Promise((n,s)=>{let i=()=>{clearTimeout(r),s(t?.reason??new DOMException(\"Request aborted\",\"AbortError\"))},r=setTimeout(()=>{t?.removeEventListener(\"abort\",i),n()},e);t?.addEventListener(\"abort\",i,{once:!0})})}V();async function*Jt(e,t={}){let n=t.signal,s=t.reconnect??!0,i=t.reconnectDelayMs??500,r=t.maxReconnectDelayMs??1e4,o=t.reconnectJitterRatio??0.2,a=t.beforeLiveTimeoutMs??15000,c=t.heartbeatTimeoutMs??45000,u=t.maxReconnectAttempts??Number.POSITIVE_INFINITY,l=t.after??0,p=0,d=i,m=!1;for(;;){if(n?.aborted)return;t.onStateChange?.(m||p>0?\"reconnecting\":\"connecting\");let y=l;try{let R=await e.openStream(l,n);m=!0,p=0,d=i,await ee(t.beforeLive,a,n),t.onStateChange?.(\"live\");for await(let w of Y(te(R,c,n))){if(n?.aborted)return;let S=Hs(w.data);if(!S||S.sequence<=l)continue;l=S.sequence,yield S}if(!s)return;if(l===y)await Ft(W(i,o),n);continue}catch(R){if(n?.aborted||K(R))return;if(!s||!j(R))throw R;if(p+=1,p>u)throw new L(`workspace control stream gave up after ${u} reconnect attempts: ${R instanceof Error?R.message:String(R)}`)}await Ft(W(d,o),n),d=Math.min(Math.max(d*2,i),r)}}function Hs(e){let t;try{t=JSON.parse(e)}catch{return null}if(typeof t!==\"object\"||t===null||t.type!==\"workspace.control.changed\"||typeof t.id!==\"string\"||typeof t.sequence!==\"number\")return null;return t}async function Ft(e,t){if(t?.aborted||e<=0)return;await new Promise((n)=>{let s=setTimeout(i,e);function i(){clearTimeout(s),t?.removeEventListener(\"abort\",i),n()}t?.addEventListener(\"abort\",i,{once:!0})})}V();async function*Ht(e,t={}){let n=t.signal,s=t.reconnect??!0,i=t.reconnectDelayMs??500,r=t.maxReconnectDelayMs??1e4,o=t.reconnectJitterRatio??0.2,a=t.beforeLiveTimeoutMs??15000,c=t.heartbeatTimeoutMs??45000,u=t.maxReconnectAttempts??Number.POSITIVE_INFINITY,l=t.after??0,p=0,d=i,m=!1;for(;;){if(n?.aborted)return;t.onStateChange?.(m||p>0?\"reconnecting\":\"connecting\");let y=l;try{let R=await e.openStream(l,n);m=!0,p=0,d=i,await ee(t.beforeLive,a,n),t.onStateChange?.(\"live\");for await(let w of Y(te(R,c,n))){if(n?.aborted)return;let S=Ks(w.data);if(!S||S.sequence<=l)continue;l=S.sequence,yield S}if(!s)return;if(l===y)await Vt(W(i,o),n);continue}catch(R){if(n?.aborted||K(R))return;if(!s||!j(R))throw R;if(p+=1,p>u)throw new L(`workspace interaction stream gave up after ${u} reconnect attempts: ${R instanceof Error?R.message:String(R)}`)}await Vt(W(d,o),n),d=Math.min(Math.max(d*2,i),r)}}function Ks(e){let t;try{t=JSON.parse(e)}catch{return null}if(!js(t)||t.type!==\"workspace.interaction.changed\"||typeof t.workspaceId!==\"string\"||typeof t.sequence!==\"number\"||!Number.isSafeInteger(t.sequence)||t.sequence<0||t.revision!==t.sequence||typeof t.occurredAt!==\"string\")return null;return t}function js(e){return typeof e===\"object\"&&e!==null&&!Array.isArray(e)}async function Vt(e,t){if(t?.aborted||e<=0)return;await new Promise((n)=>{let s=setTimeout(i,e);function i(){clearTimeout(s),t?.removeEventListener(\"abort\",i),n()}t?.addEventListener(\"abort\",i,{once:!0})})}V();async function*jt(e,t={}){let n=t.signal,s=t.reconnect??!0,i=t.reconnectDelayMs??500,r=t.maxReconnectDelayMs??1e4,o=t.reconnectJitterRatio??0.2,a=t.beforeLiveTimeoutMs??15000,c=t.heartbeatTimeoutMs??45000,u=t.maxReconnectAttempts??Number.POSITIVE_INFINITY,l=t.controlAfter??0,p=t.interactionAfter??0,d=0,m=i,y=!1;for(;;){if(n?.aborted)return;t.onStateChange?.(y||d>0?\"reconnecting\":\"connecting\");let R=`${l}:${p}`;try{let w=await e.openStream(l,p,n);y=!0,d=0,m=i,await ee(t.beforeLive,a,n),t.onStateChange?.(\"live\");for await(let S of Y(te(w,c,n))){if(n?.aborted)return;let I=Ys(S.data);if(!I)continue;if(I.type===\"workspace.control.changed\"){if(I.sequence<=l)continue;l=I.sequence}else if(I.type===\"workspace.interaction.changed\"){if(I.sequence<=p)continue;p=I.sequence}yield I}if(!s)return;if(`${l}:${p}`===R)await Kt(W(i,o),n);continue}catch(w){if(n?.aborted||K(w))return;if(!s||!j(w))throw w;if(d+=1,d>u)throw new L(`workspace live stream gave up after ${u} reconnect attempts: ${w instanceof Error?w.message:String(w)}`)}await Kt(W(m,o),n),m=Math.min(Math.max(m*2,i),r)}}function Ys(e){let t;try{t=JSON.parse(e)}catch{return null}if(!Xs(t))return null;if(t.type===\"workspace.sessions.changed\"&&typeof t.workspaceId===\"string\"&&typeof t.available===\"boolean\"&&(t.sessionIds===null||Array.isArray(t.sessionIds)&&t.sessionIds.every((n)=>typeof n===\"string\"))){let{siteSessionIds:n,...s}=t;return Array.isArray(n)&&n.every((i)=>typeof i===\"string\")?{...s,siteSessionIds:n}:s}if(typeof t.sequence!==\"number\")return null;if(t.type===\"workspace.control.changed\"&&typeof t.id===\"string\"&&Number.isSafeInteger(t.sequence))return t;if(t.type===\"workspace.interaction.changed\"&&typeof t.workspaceId===\"string\"&&Number.isSafeInteger(t.sequence)&&t.sequence>=0&&t.revision===t.sequence&&typeof t.occurredAt===\"string\")return t;return null}function Xs(e){return typeof e===\"object\"&&e!==null&&!Array.isArray(e)}async function Kt(e,t){if(t?.aborted||e<=0)return;await new Promise((n)=>{let s=setTimeout(i,e);function i(){clearTimeout(s),t?.removeEventListener(\"abort\",i),n()}t?.addEventListener(\"abort\",i,{once:!0})})}function Yt(e){return e.driverId===\"opengeni.cdp.ephemeral-context.v1\"?\"ephemeral_context\":\"private_profile\"}var Xt=32768,Qs=1e8;class Xe{attachedBrowsers;authRuns;browsers;computers;identities;interventions;networkRoutes;siteAuthConnections;constructor(e){this.attachedBrowsers=new un(e),this.authRuns=new rn(e),this.browsers=new gn(e),this.computers=new bn(e),this.identities=new dn(e),this.interventions=new an(e),this.networkRoutes=new en(e),this.siteAuthConnections=new nn(e)}}class en{transport;constructor(e){this.transport=e}async list(e,t={}){return await this.transport.listNetworkRoutes(e,t)}route(e,t){return new tn(this.transport,e,t)}async create(e,t,n={}){let s=await this.transport.createNetworkRoute(e,t,n);return this.route(e,s.route.id)}}class tn{transport;workspaceId;id;constructor(e,t,n){this.transport=e;this.workspaceId=t;this.id=n}async get(e={}){return await this.transport.getNetworkRoute(this.workspaceId,this.id,e)}async update(e,t={}){return await this.transport.updateNetworkRoute(this.workspaceId,this.id,e,t)}}class nn{transport;constructor(e){this.transport=e}async list(e,t={}){return await this.transport.listSiteAuthConnections(e,t)}connection(e,t){return new sn(this.transport,e,t)}async create(e,t,n={}){let s=await this.transport.createSiteAuthConnection(e,t,n);return this.connection(e,s.connection.id)}}class sn{transport;workspaceId;id;constructor(e,t,n){this.transport=e;this.workspaceId=t;this.id=n}async get(e={}){return await this.transport.getSiteAuthConnection(this.workspaceId,this.id,e)}async update(e,t={}){return await this.transport.updateSiteAuthConnection(this.workspaceId,this.id,e,t)}}class rn{transport;constructor(e){this.transport=e}async list(e,t={}){return await this.transport.listAuthRuns(e,t)}async get(e,t,n={}){return await this.transport.getAuthRun(e,t,n)}run(e,t,n){return new Qe(this.transport,e,t,n)}}class on{transport;workspaceId;browserSessionId;constructor(e,t,n){this.transport=e;this.workspaceId=t;this.browserSessionId=n}async list(e={}){return await this.transport.listAuthRuns(this.workspaceId,{...e,browserSessionId:this.browserSessionId})}run(e){return new Qe(this.transport,this.workspaceId,this.browserSessionId,e)}async start(e,t={}){let n=await this.transport.startBrowserAuthRun(this.workspaceId,this.browserSessionId,e,t);return this.run(n.run.id)}}class Qe{transport;workspaceId;browserSessionId;id;constructor(e,t,n,s){this.transport=e;this.workspaceId=t;this.browserSessionId=n;this.id=s}async get(e={}){let t=await this.transport.getAuthRun(this.workspaceId,this.id,e);if(t.browserSessionId!==this.browserSessionId)throw Error(\"AuthRun belongs to another BrowserSession\");return t}async report(e,t={}){return await this.transport.reportBrowserAuthRun(this.workspaceId,this.browserSessionId,this.id,e,t)}async advanceExternal(e,t={}){return await this.transport.advanceExternalBrowserAuthRun(this.workspaceId,this.browserSessionId,this.id,e,t)}async openExternalFlow(e,t={}){return await this.transport.openExternalBrowserAuthFlow(this.workspaceId,this.browserSessionId,this.id,e,t)}async verify(e,t={}){return await this.transport.verifyBrowserAuthRun(this.workspaceId,this.browserSessionId,this.id,e,t)}}class an{transport;constructor(e){this.transport=e}async list(e,t={}){return await this.transport.listInteractionInterventions(e,t)}intervention(e,t){return new cn(this.transport,e,t)}async create(e,t,n={}){let s=await this.transport.createInteractionIntervention(e,t,n);return this.intervention(e,s.intervention.id)}}class cn{transport;workspaceId;id;constructor(e,t,n){this.transport=e;this.workspaceId=t;this.id=n}async get(e={}){return await this.transport.getInteractionIntervention(this.workspaceId,this.id,e)}async resolve(e,t={}){return await this.transport.resolveInteractionIntervention(this.workspaceId,this.id,e,t)}}class un{transport;constructor(e){this.transport=e}async list(e,t={}){return await this.transport.listAttachedBrowsers(e,t)}device(e,t){return new ln(this.transport,e,t)}}class ln{transport;workspaceId;id;constructor(e,t,n){this.transport=e;this.workspaceId=t;this.id=n}async get(e={}){return await this.transport.getAttachedBrowser(this.workspaceId,this.id,e)}}class dn{transport;constructor(e){this.transport=e}async list(e,t={}){return await this.transport.listBrowserIdentities(e,t)}identity(e,t){return new pn(this.transport,e,t)}async create(e,t,n={}){let s=await this.transport.createBrowserIdentity(e,t,n);return this.identity(e,s.identity.id)}}class pn{transport;workspaceId;id;constructor(e,t,n){this.transport=e;this.workspaceId=t;this.id=n}async get(e={}){return await this.transport.getBrowserIdentity(this.workspaceId,this.id,e)}async revisions(e={}){return await this.transport.listBrowserRevisions(this.workspaceId,this.id,e)}async update(e,t={}){return await this.transport.updateBrowserIdentity(this.workspaceId,this.id,e,t)}}class gn{transport;constructor(e){this.transport=e}async list(e,t={}){return await this.transport.listBrowserSessions(e,t)}session(e,t){return new mn(this.transport,e,t)}async open(e,t,n={}){let s=await this.transport.createBrowserSession(e,t,n);return this.session(e,s.session.id)}async currentOrOpen(e){let t=e.signal?{signal:e.signal}:{},n=await this.list(e.workspaceId,t),s=ei(n.sessions.filter((i)=>Yt(i)===(e.storageMode??\"private_profile\")),e.associationSessionId);if(s){let i=this.session(e.workspaceId,s.id);if(s.lifecycle===\"suspended\")await i.resume({operationId:e.operationId??crypto.randomUUID()},t);return i}return await this.open(e.workspaceId,{operationId:e.operationId??crypto.randomUUID(),sessionId:e.associationSessionId,...e.name!==void 0?{name:e.name}:{},...e.initialUrl!==void 0?{initialUrl:e.initialUrl}:{},...e.headless!==void 0?{headless:e.headless}:{},...e.storageMode!==void 0?{storageMode:e.storageMode}:{},...e.placement!==void 0?{placement:e.placement}:{},...e.identityId!==void 0?{identityId:e.identityId}:{},...e.baseRevisionId!==void 0?{baseRevisionId:e.baseRevisionId}:{},...e.networkRouteId!==void 0?{networkRouteId:e.networkRouteId}:{},...e.linkedComputerSessionId!==void 0?{linkedComputerSessionId:e.linkedComputerSessionId}:{}},t)}}class mn{transport;workspaceId;id;auth;clipboard;downloads;tabs;targets;constructor(e,t,n){this.transport=e;this.workspaceId=t;this.id=n;this.auth=new on(e,t,n),this.clipboard=new yn(e,t,n),this.downloads=new fn(e,t,n),this.tabs=new Rn(e,t,n),this.targets=this.tabs}async get(e={}){return await this.transport.getBrowserSession(this.workspaceId,this.id,e)}async observe(e,t={}){return await this.transport.observeBrowserTarget(this.workspaceId,this.id,e,t)}async targetState(e,t={}){return await this.transport.getBrowserTargetState(this.workspaceId,this.id,e,t)}async readDom(e,t,n={}){return await this.transport.readBrowserDom(this.workspaceId,this.id,e,t,n)}async capture(e,t={},n={}){return await this.transport.captureBrowserTarget(this.workspaceId,this.id,e,t,n)}async screenshot(e,t={},n={}){return await this.capture(e,n,t)}async act(e,t={}){return await this.transport.actInBrowser(this.workspaceId,this.id,e,t)}async receipt(e,t={}){return await this.transport.getBrowserActionReceipt(this.workspaceId,this.id,e,t)}async diagnostics(e,t={}){return await this.transport.listBrowserDiagnostics(this.workspaceId,this.id,e,t)}async attach(e,t={}){return await this.transport.attachBrowserSession(this.workspaceId,this.id,e,t)}async heartbeat(e={}){return await this.transport.heartbeatBrowserSession(this.workspaceId,this.id,e)}async publishRevision(e,t={}){return await this.transport.publishBrowserRevision(this.workspaceId,this.id,e,t)}async suspend(e={operationId:crypto.randomUUID()},t={}){return await this.transport.suspendBrowserSession(this.workspaceId,this.id,e,t)}async resume(e={operationId:crypto.randomUUID()},t={}){return await this.transport.resumeBrowserSession(this.workspaceId,this.id,e,t)}async end(e={operationId:crypto.randomUUID()},t={}){return await this.transport.endBrowserSession(this.workspaceId,this.id,e,t)}}class yn{transport;workspaceId;browserSessionId;constructor(e,t,n){this.transport=e;this.workspaceId=t;this.browserSessionId=n}async read(e={}){let t=await this.transport.readBrowserClipboard(this.workspaceId,this.browserSessionId,e);if(t.browserSessionId!==this.browserSessionId)throw Error(\"Browser clipboard belongs to another BrowserSession\");return t}}class fn{transport;workspaceId;browserSessionId;constructor(e,t,n){this.transport=e;this.workspaceId=t;this.browserSessionId=n}async list(e={}){return await this.transport.listBrowserDownloads(this.workspaceId,this.browserSessionId,e)}download(e){return new hn(this.transport,this.workspaceId,this.browserSessionId,e)}}class hn{transport;workspaceId;browserSessionId;id;constructor(e,t,n,s){this.transport=e;this.workspaceId=t;this.browserSessionId=n;this.id=s}async get(e={}){let t=await this.transport.getBrowserDownload(this.workspaceId,this.browserSessionId,this.id,e);if(t.browserSessionId!==this.browserSessionId)throw Error(\"BrowserDownload belongs to another BrowserSession\");return t}async saveToWorkspace(e,t={}){let{operationId:n=crypto.randomUUID(),overwrite:s=!1,...i}=t,r=await this.transport.saveBrowserDownload(this.workspaceId,this.browserSessionId,this.id,{operationId:n,destinationPath:e,overwrite:s},i);if(r.download.id!==this.id||r.download.browserSessionId!==this.browserSessionId)throw Error(\"BrowserDownload save returned another resource\");return r}}class Rn{transport;workspaceId;browserSessionId;constructor(e,t,n){this.transport=e;this.workspaceId=t;this.browserSessionId=n}async list(e={}){return await this.transport.listBrowserTargets(this.workspaceId,this.browserSessionId,e)}async open(e,t={}){return await this.transport.openBrowserTarget(this.workspaceId,this.browserSessionId,e===void 0?{}:{url:e},t)}async select(e,t={}){return await this.transport.selectBrowserTarget(this.workspaceId,this.browserSessionId,e,t)}async close(e,t={}){return await this.transport.closeBrowserTarget(this.workspaceId,this.browserSessionId,e,t)}}class bn{transport;constructor(e){this.transport=e}async list(e,t={}){return await this.transport.listComputerSessions(e,t)}session(e,t){return new Sn(this.transport,e,t)}async open(e,t,n={}){let s=await this.transport.createComputerSession(e,t,n);return this.session(e,s.session.id)}async currentOrOpen(e){let t=e.signal?{signal:e.signal}:{},n=await this.list(e.workspaceId,t),s=ti(n.sessions,e.associationSessionId);if(s)return this.session(e.workspaceId,s.id);return await this.open(e.workspaceId,{operationId:e.operationId??crypto.randomUUID(),sessionId:e.associationSessionId,...e.name!==void 0?{name:e.name}:{},...e.placement!==void 0?{placement:e.placement}:{}},t)}}class Sn{transport;workspaceId;id;targets;apps;clipboard;constructor(e,t,n){this.transport=e;this.workspaceId=t;this.id=n;this.targets=new vn(e,t,n),this.apps=this.targets,this.clipboard=new wn(e,t,n)}async get(e={}){return await this.transport.getComputerSession(this.workspaceId,this.id,e)}async observe(e,t={}){return await this.transport.observeComputerTarget(this.workspaceId,this.id,e,t)}async capture(e,t={}){return await this.transport.captureComputerTarget(this.workspaceId,this.id,e,t)}async callNativeTool(e,t={}){if(!this.transport.callNativeComputerTool)throw Error(\"Native CUA tools require a current interaction transport\");return await this.transport.callNativeComputerTool(this.workspaceId,this.id,e,t)}async act(e,t={}){return await this.transport.actInComputer(this.workspaceId,this.id,e,t)}async nativeReceipt(e,t={}){if(!this.transport.getNativeComputerToolReceipt)throw Error(\"Native CUA receipts require a current interaction transport\");return await this.transport.getNativeComputerToolReceipt(this.workspaceId,this.id,e,t)}async receipt(e,t={}){return await this.transport.getComputerActionReceipt(this.workspaceId,this.id,e,t)}async attach(e,t={}){return await this.transport.attachComputerSession(this.workspaceId,this.id,e,t)}async inputPosture(e={}){if(!this.transport.getComputerInputPosture)throw Error(\"Computer input posture requires a current interaction transport.\");return await this.transport.getComputerInputPosture(this.workspaceId,this.id,e)}async heartbeat(e={}){return await this.transport.heartbeatComputerSession(this.workspaceId,this.id,e)}async end(e={operationId:crypto.randomUUID()},t={}){return await this.transport.endComputerSession(this.workspaceId,this.id,e,t)}}class wn{transport;workspaceId;computerSessionId;constructor(e,t,n){this.transport=e;this.workspaceId=t;this.computerSessionId=n}async read(e={}){let t=await this.transport.readComputerClipboard(this.workspaceId,this.computerSessionId,e);if(t.computerSessionId!==this.computerSessionId)throw Error(\"Computer clipboard belongs to another ComputerSession\");return t}}class vn{transport;workspaceId;computerSessionId;constructor(e,t,n){this.transport=e;this.workspaceId=t;this.computerSessionId=n}async list(e={}){return await this.transport.listComputerTargets(this.workspaceId,this.computerSessionId,e)}}function kn(e){if(!xn(e))throw Error(\"browser frame metadata is invalid\");let t=new Set([\"frameId\",\"browserSessionId\",\"controllerGeneration\",\"targetId\",\"targetGeneration\",\"documentGeneration\",\"sequence\",\"mediaType\",\"width\",\"height\",\"deviceScaleFactor\",\"scrollX\",\"scrollY\",\"capturedAt\"]);if(Object.keys(e).some((r)=>!t.has(r)))throw Error(\"browser frame metadata contains unknown fields\");let n=[\"frameId\",\"browserSessionId\",\"controllerGeneration\",\"targetId\",\"targetGeneration\",\"documentGeneration\",\"mediaType\",\"capturedAt\"];for(let r of n){let o=e[r],a=r===\"targetId\"?512:r===\"capturedAt\"?128:256;if(typeof o!==\"string\"||o.length<1||Cn(o)>a)throw Error(\"browser frame metadata is invalid\")}let s=[\"sequence\",\"width\",\"height\",\"deviceScaleFactor\",\"scrollX\",\"scrollY\"];for(let r of s)if(typeof e[r]!==\"number\"||!Number.isFinite(e[r]))throw Error(\"browser frame metadata is invalid\");let i=e;if(!Number.isSafeInteger(i.sequence)||i.sequence<0||!Number.isSafeInteger(i.width)||!Number.isSafeInteger(i.height))throw Error(\"browser frame metadata integers are invalid\");if(An(i.width,i.height),i.deviceScaleFactor<=0||i.deviceScaleFactor>16||Math.abs(i.scrollX)>1e9||Math.abs(i.scrollY)>1e9)throw Error(\"browser frame geometry metadata is invalid\");if(i.mediaType!==\"image/jpeg\"&&i.mediaType!==\"image/png\")throw Error(\"browser frame media type is invalid\");if(!Pn(i.browserSessionId))throw Error(\"browser frame session id is invalid\");if(!/^[A-Za-z0-9][A-Za-z0-9._:-]*$/u.test(i.controllerGeneration))throw Error(\"browser frame controller generation is invalid\");if(!Number.isFinite(new Date(i.capturedAt).valueOf()))throw Error(\"browser frame timestamp is invalid\");return i}function Zs(e){if(!xn(e))throw Error(\"computer frame metadata is invalid\");let t=new Set([\"frameId\",\"computerSessionId\",\"controllerGeneration\",\"targetId\",\"targetGeneration\",\"sequence\",\"mediaType\",\"width\",\"height\",\"capturedAt\",\"sha256\"]);if(Object.keys(e).some((i)=>!t.has(i)))throw Error(\"computer frame metadata contains unknown fields\");let n=[\"frameId\",\"computerSessionId\",\"controllerGeneration\",\"targetId\",\"targetGeneration\",\"mediaType\",\"capturedAt\",\"sha256\"];for(let i of n){let r=e[i],o=i===\"targetId\"?512:i===\"capturedAt\"?128:256;if(typeof r!==\"string\"||r.length<1||Cn(r)>o)throw Error(\"computer frame metadata is invalid\")}let s=e;if(!Number.isSafeInteger(s.sequence)||s.sequence<0||!Number.isSafeInteger(s.width)||!Number.isSafeInteger(s.height))throw Error(\"computer frame metadata integers are invalid\");if(An(s.width,s.height),s.mediaType!==\"image/jpeg\"&&s.mediaType!==\"image/png\")throw Error(\"computer frame media type is invalid\");if(!Pn(s.computerSessionId))throw Error(\"computer frame session id is invalid\");if(!/^[A-Za-z0-9][A-Za-z0-9._:-]*$/u.test(s.controllerGeneration))throw Error(\"computer frame controller generation is invalid\");if(!Number.isFinite(new Date(s.capturedAt).valueOf()))throw Error(\"computer frame timestamp is invalid\");if(!/^[0-9a-f]{64}$/u.test(s.sha256))throw Error(\"computer frame digest is invalid\");return s}function In(e){if(!e||e.length>32768||!/^[A-Za-z0-9_-]+$/u.test(e))throw Error(\"computer frame metadata header is invalid\");let t=e.replace(/-/gu,\"+\").replace(/_/gu,\"/\"),n=t.padEnd(Math.ceil(t.length/4)*4,\"=\"),s;try{s=atob(n)}catch{throw Error(\"computer frame metadata header is invalid\")}let i=Uint8Array.from(s,(o)=>o.charCodeAt(0)),r;try{r=JSON.parse(new TextDecoder(\"utf-8\",{fatal:!0}).decode(i))}catch{throw Error(\"computer frame metadata header is invalid\")}return Zs(r)}function ei(e,t){let n=e.filter((s)=>![\"ending\",\"ended\",\"failed\",\"lost\"].includes(s.lifecycle)&&s.associations.some((i)=>i.sessionId===t));return n.sort((s,i)=>Qt(i,t)-Qt(s,t)),n[0]??null}function ti(e,t){let n=e.filter((s)=>[\"starting\",\"active\",\"restoring\"].includes(s.lifecycle)&&s.associations.some((i)=>i.sessionId===t));return n.sort((s,i)=>Zt(i,t)-Zt(s,t)),n[0]??null}function Qt(e,t){let n=e.associations.filter((i)=>i.sessionId===t).map((i)=>Date.parse(i.lastUsedAt)).filter(Number.isFinite).reduce((i,r)=>Math.max(i,r),0),s=Date.parse(e.lastUsedAt);return Math.max(n,Number.isFinite(s)?s:0)}function Zt(e,t){let n=e.associations.filter((i)=>i.sessionId===t).map((i)=>Date.parse(i.lastUsedAt)).filter(Number.isFinite).reduce((i,r)=>Math.max(i,r),0),s=Date.parse(e.lastUsedAt);return Math.max(n,Number.isFinite(s)?s:0)}function An(e,t){if(!Number.isSafeInteger(e)||!Number.isSafeInteger(t)||e<1||t<1||e>Xt||t>Xt||e*t>Qs)throw Error(\"browser image dimensions exceed their bounded envelope\")}function Cn(e){return new TextEncoder().encode(e).byteLength}function Pn(e){return/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu.test(e)}function xn(e){return typeof e===\"object\"&&e!==null&&!Array.isArray(e)}var oe=\"2026-09-plugins-and-skills-v1\",Ze=\"x-opengeni-api-contract\",Oe=\"x-opengeni-correlation-id\";var qe=1048576,Tn=33554432;var On=536870912;var _e=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/,qn=/^[0-9a-f]{64}$/,En=/^\\\\d{4}-\\\\d{2}-\\\\d{2}T\\\\d{2}:\\\\d{2}:\\\\d{2}(?:\\\\.\\\\d+)?(?:Z|[+-]\\\\d{2}:\\\\d{2})$/,_n=/^\\\\/v1\\\\/workspaces\\\\/([0-9a-f-]+)\\\\/artifacts\\\\/([0-9a-f-]+)\\\\/content$/;function Gn(e,t){if(!ne(e,si))return null;let n=e;if(n.available!==!0||n.kind!==\"file\"||typeof n.artifactId!==\"string\"||!_e.test(n.artifactId)||typeof n.contentType!==\"string\"||!/^[a-z0-9][a-z0-9!#$&^_.+-]{0,62}\\\\/[a-z0-9][a-z0-9!#$&^_.+-]{0,62}$/.test(n.contentType)||!Ee(n.originalBytes,1,5000000000)||typeof n.sha256!==\"string\"||!qn.test(n.sha256)||typeof n.retainedAt!==\"string\"||n.retainedAt.length>64||!En.test(n.retainedAt)||!Number.isFinite(Date.parse(n.retainedAt))||!ne(n.retention,Un)||!ne(n.retrieval,Dn))return null;let s=n.retention;if(s.policy!==\"workspace_file\"||s.expiresAt!==null)return null;let i=n.retrieval;if(i.method!==\"GET\"||i.acceptRanges!==\"bytes\"||i.maxRangeBytes!==1048576||typeof i.path!==\"string\"||i.path.length>256)return null;let r=_n.exec(i.path);if(!r||!_e.test(r[1]??\"\")||r[2]!==n.artifactId||t!==void 0&&r[1]!==t)return null;return e}function Mn(e,t){if(!ne(e,ni))return null;let n=e;if(n.available!==!0||n.kind!==\"generated_image\"||typeof n.artifactId!==\"string\"||!_e.test(n.artifactId)||![\"image/png\",\"image/jpeg\",\"image/webp\"].includes(String(n.contentType))||!Ee(n.originalBytes,1,67108864)||typeof n.sha256!==\"string\"||!qn.test(n.sha256)||typeof n.retainedAt!==\"string\"||n.retainedAt.length>64||!En.test(n.retainedAt)||!Number.isFinite(Date.parse(n.retainedAt))||!ne(n.dimensions,ii)||!ne(n.retention,Un)||!ne(n.retrieval,Dn))return null;let s=n.dimensions;if(!Ee(s.width,1,16384)||!Ee(s.height,1,16384)||Number(s.width)*Number(s.height)>67108864)return null;let i=n.retention;if(i.policy!==\"workspace_file\"||i.expiresAt!==null)return null;let r=n.retrieval;if(r.method!==\"GET\"||r.acceptRanges!==\"bytes\"||r.maxRangeBytes!==1048576||typeof r.path!==\"string\"||r.path.length>256)return null;let o=_n.exec(r.path);if(!o||!_e.test(o[1]??\"\")||o[2]!==n.artifactId||t!==void 0&&o[1]!==t)return null;return e}var ni=new Set([\"available\",\"artifactId\",\"kind\",\"contentType\",\"originalBytes\",\"sha256\",\"retainedAt\",\"dimensions\",\"retention\",\"retrieval\"]),si=new Set([\"available\",\"artifactId\",\"kind\",\"contentType\",\"originalBytes\",\"sha256\",\"retainedAt\",\"retention\",\"retrieval\"]),ii=new Set([\"width\",\"height\"]),Un=new Set([\"policy\",\"expiresAt\"]),Dn=new Set([\"method\",\"path\",\"acceptRanges\",\"maxRangeBytes\"]);var ri=new Set([\"type\",\"sandboxPath\",\"filename\",\"artifact\"]),vo=new Set([...ri,\"access\"]);function ne(e,t){return e!==null&&typeof e===\"object\"&&!Array.isArray(e)&&Object.keys(e).length===t.size&&Object.keys(e).every((n)=>t.has(n))}function Ee(e,t,n){return Number.isSafeInteger(e)&&Number(e)>=t&&Number(e)<=n}function nt(e){let{limit:t,parentSessionId:n,scopeSubjectId:s}=e,i={};if(e.originSiteId)i.originSiteId=e.originSiteId;if(e.siteAccessId)i.siteAccessId=e.siteAccessId;if(t!==void 0)i.limit=String(t);if(n!==void 0)i.parentSessionId=n??\"null\";if(s!==void 0)i.scopeSubjectId=s;return i}var Gi=[\"siteAccessId\",\"originSiteId\",\"channelId\",\"createdBy\",\"updatedFrom\",\"updatedBefore\",\"createdFrom\",\"createdBefore\"],Mi=[\"updatedFrom\",\"updatedBefore\",\"createdFrom\",\"createdBefore\",\"sortBy\",\"archiveStatus\"];function Ui(e){return Boolean(e.needsYouOnly)||Boolean(e.contentArchivedOnly)||Boolean(e.mineOnly)||Gi.some((t)=>e[t]!==void 0)}function F(e){return Error(`The connected API does not support ${e}`)}function g(e,t){return`/v1/workspaces/${e}/sessions/${t}`}function Di(e){if(e.apiContract)return e.apiContract;return typeof window<\"u\"&&typeof document<\"u\"&&!e.apiKey?\"strict\":\"compatible\"}function Nn(e){let{associatedSessionId:t,includeTerminal:n,...s}=e;return{query:{...t?{associatedSessionId:t}:{},...n!==void 0?{includeTerminal:String(n)}:{}},request:s}}function Fn(e,t){let n,s,i=new Promise((r,o)=>{n=r,s=o});return{controller:new AbortController,consumers:0,generation:e,promise:i,resolve:n,reject:s,started:!1,listeners:new Set(t?[t]:[])}}function Jn(e){if(Object.prototype.hasOwnProperty.call(e,\"tools\"))throw TypeError(\"Message-level tools are not supported; update the session tool policy before sending.\")}function Vn(e){if(!(\"agentConfig\"in e)||!e.agentConfig?.machineTarget)return e;let{workingDir:t,...n}=e.agentConfig.machineTarget;if(t===void 0)return e;let s=t.trim();return{...e,agentConfig:{...e.agentConfig,machineTarget:{...n,...s?{workingDir:s}:{}}}}}function $i(e){return{forWorkspace(t){let n=t.trim();if(!n)throw TypeError(\"workspaceId is required\");let s,i=()=>s??=Promise.resolve().then(() => (Ae(),{})).then(({})=>new re(e).forWorkspace(n)),r=(o)=>new Proxy(async(...a)=>{let c=await i();for(let u of o)c=c[u];if(typeof c!==\"function\")throw TypeError(\"Tool path is not callable\");return await Reflect.apply(c,void 0,a)},{get:(a,c)=>{if(c===\"then\")return;if(typeof c!==\"string\")return;return r([...o,c])}});return new Proxy(Object.create(null),{get:(o,a)=>{if(a===\"$targetProtocol\")return e.toolGatewayMode===\"catalog\"?void 0:1;if(a===\"then\")return;if(typeof a!==\"string\")return;return r([a])}})}}}class st{get toolGatewayMode(){return this.options.toolGatewayMode??\"target\"}externalActorHeader;serviceInitiatorHeader;serviceContextHeader;baseUrl;options;fetchImpl;sessionCommandTimeoutMs;apiContractStrict;readRetryPolicy;active=new Map;generations=new Map;queued=new Map;interaction;tools;constructor(e){this.baseUrl=e.baseUrl.replace(/\\\\/+$/,\"\"),this.options=e,this.fetchImpl=Gt(e.fetch??((n,s)=>fetch(n,s)),e.onDeprecation);let t=e.sessionCommandTimeoutMs??15000;if(!Number.isFinite(t)||t<=0)throw RangeError(\"sessionCommandTimeoutMs must be a finite positive number\");this.sessionCommandTimeoutMs=t,this.apiContractStrict=Di(e)===\"strict\",this.readRetryPolicy=Ut(e.readRetry),this.interaction=new Xe(this),this.tools=$i(this)}async transcribeAudio(e,t){let n=crypto.randomUUID(),s=new FormData,i=zi(t.mimeType),r=t.audio instanceof File?t.audio:t.audio instanceof Uint8Array?new File([Uint8Array.from(t.audio)],i,{type:t.mimeType}):new File([t.audio],i,{type:t.mimeType||t.audio.type});if(s.append(\"audio\",r,i),s.append(\"mimeType\",t.mimeType),t.durationSeconds!==void 0)s.append(\"durationSeconds\",String(t.durationSeconds));let o;try{o=await this.fetchImpl(this.url(`/v1/workspaces/${e}/transcriptions`),{method:\"POST\",headers:{...this.headers(n),Accept:\"application/json\"},body:s,...t.signal?{signal:t.signal}:{}})}catch(c){if(t.signal?.aborted)throw c;throw ce(n)}if(D(o,this.apiContractStrict),!o.ok)throw await M(o,{method:\"POST\",correlationId:n});await fe(o,{method:\"POST\",correlationId:n});let a;try{a=await o.json()}catch{throw new P(o.status,\"Invalid transcription response.\",{code:\"invalid_response\",mutation:!0,correlationId:n})}if(!Bi(a))throw new P(o.status,\"Invalid transcription response.\",{code:\"invalid_response\",mutation:!0,correlationId:n});return a}async createTranscriptionRecording(e,t){return ye(await this.requestJson(\"POST\",`/v1/workspaces/${e}/transcription-recordings`,{recordingId:t.recordingId,mimeType:t.mimeType},{},t.signal?{signal:t.signal}:{}))}async getTranscriptionRecording(e,t,n={}){return ye(await this.requestJson(\"GET\",`/v1/workspaces/${e}/transcription-recordings/${t}`,void 0,{},n.signal?{signal:n.signal}:{}))}async listTranscriptionRecordings(e,t={}){let n=await this.requestJson(\"GET\",`/v1/workspaces/${e}/transcription-recordings`,void 0,{},t.signal?{signal:t.signal}:{});if(!Wi(n))throw A(\"Invalid transcription recording list response.\",{code:\"invalid_response\"});return n}async uploadTranscriptionRecordingChunk(e,t,n,s){let i=crypto.randomUUID(),r;try{r=await this.fetchImpl(this.url(`/v1/workspaces/${e}/transcription-recordings/${t}/chunks/${n}`),{method:\"PUT\",headers:{...this.headers(i),Accept:\"application/json\",\"Content-Type\":s.mimeType,\"x-opengeni-chunk-sha256\":s.sha256,\"x-opengeni-chunk-start-milliseconds\":String(s.startMilliseconds),\"x-opengeni-chunk-duration-milliseconds\":String(s.durationMilliseconds)},body:s.audio instanceof Uint8Array?Uint8Array.from(s.audio):s.audio,...s.signal?{signal:s.signal}:{}})}catch(a){if(s.signal?.aborted)throw a;throw ce(i)}if(D(r,this.apiContractStrict),!r.ok)throw await M(r,{method:\"PUT\",correlationId:i});await fe(r,{method:\"PUT\",correlationId:i});let o=await r.json().catch(()=>null);if(!Li(o))throw new P(r.status,\"Invalid transcription chunk response.\",{code:\"invalid_response\",mutation:!0,correlationId:i});return o}async finalizeTranscriptionRecording(e,t,n){return ye(await this.requestJson(\"POST\",`/v1/workspaces/${e}/transcription-recordings/${t}/finalize`,{chunkCount:n.chunkCount,totalBytes:n.totalBytes,totalDurationMilliseconds:n.totalDurationMilliseconds},{},n.signal?{signal:n.signal}:{}))}async processNextTranscriptionRecordingSegment(e,t,n={}){return ye(await this.requestJson(\"POST\",`/v1/workspaces/${e}/transcription-recordings/${t}/process-next`,{},{},n.signal?{signal:n.signal}:{}))}async discardTranscriptionRecording(e,t,n={}){return ye(await this.requestJson(\"DELETE\",`/v1/workspaces/${e}/transcription-recordings/${t}`,void 0,{},n.signal?{signal:n.signal}:{}))}async createSession(e,t){let n=t.usageLimitMicros!==void 0&&t.usageLimitMicros!==null,s=n&&t.startMode===void 0?{...t,startMode:\"standard\"}:t,i;try{i=await this.requestJson(\"POST\",`/v1/workspaces/${encodeURIComponent(e)}/sessions`,s)}catch(r){if(n&&s.startMode===\"standard\"&&r instanceof P&&yt(r))throw new pe(\"This server does not support task usage limits, so the session was not created. Create it without a usage limit, or upgrade the server.\",{sessionId:null,cause:r});throw r}return Fi(t.usageLimitMicros,i),i}async getSessionUsageLimit(e,t,n={}){return await this.requestJson(\"GET\",`/v1/workspaces/${encodeURIComponent(e)}/sessions/${encodeURIComponent(t)}/usage-limit`,void 0,{},n)}async setSessionUsageLimit(e,t,n){let s=await this.requestJson(\"PUT\",`/v1/workspaces/${encodeURIComponent(e)}/sessions/${encodeURIComponent(t)}/usage-limit`,n);if(s.limitMicros!==n.limitMicros)throw ft(t);return s}async getNewSessionDraft(e,t={}){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/new-session-draft`,void 0,{},t)}async saveNewSessionDraft(e,t){return await this.requestJson(\"PUT\",`/v1/workspaces/${e}/new-session-draft`,t)}async getWorkspaceCredentialProvider(e){return this.requestJson(\"GET\",`/v1/workspaces/${e}/credential-provider`)}async putWorkspaceCredentialProvider(e,t){return this.requestJson(\"PUT\",`/v1/workspaces/${e}/credential-provider`,t)}async deleteWorkspaceCredentialProvider(e){await this.requestVoid(\"DELETE\",`/v1/workspaces/${e}/credential-provider`)}async listWorkspaceWebhooks(e){return this.requestJson(\"GET\",`/v1/workspaces/${e}/webhooks`)}async createWorkspaceWebhook(e,t){return this.requestJson(\"POST\",`/v1/workspaces/${e}/webhooks`,t)}async updateWorkspaceWebhook(e,t,n){return this.requestJson(\"PATCH\",`/v1/workspaces/${e}/webhooks/${t}`,n)}async deleteWorkspaceWebhook(e,t){await this.requestVoid(\"DELETE\",`/v1/workspaces/${e}/webhooks/${t}`)}async listWorkspaceWebhookDeliveries(e,t,n={}){return this.requestJson(\"GET\",`/v1/workspaces/${e}/webhooks/${t}/deliveries`,void 0,n.limit!==void 0?{limit:String(n.limit)}:{})}async redeliverWorkspaceWebhookDelivery(e,t,n){return this.requestJson(\"POST\",`/v1/workspaces/${e}/webhooks/${t}/deliveries/${n}/redeliver`)}async listWorkspaceSandboxImages(e){return this.requestJson(\"GET\",`/v1/workspaces/${e}/sandbox-images`)}async createFeedback(e,t){return this.requestJson(\"POST\",`/v1/workspaces/${e}/feedback`,t)}async listOwnFeedback(e,t={}){let n=new URLSearchParams;if(t.sessionId)n.set(\"sessionId\",t.sessionId);if(t.limit!==void 0)n.set(\"limit\",String(t.limit));if(t.includeTurns!==void 0)n.set(\"includeTurns\",String(t.includeTurns));return this.requestJson(\"GET\",`/v1/workspaces/${e}/feedback${n.size?`?${n}`:\"\"}`)}async getSession(e,t,n={}){let s=g(e,t);return await this.sharedRead(s,(i)=>this.requestJson(\"GET\",s,void 0,{},{signal:i}),n)}async getToolActionReview(e,t,n){return await this.requestJson(\"GET\",`${g(e,t)}/tool-reviews/${encodeURIComponent(n)}`)}async getToolReviewDetails(e,t,n,s){let i=new URLSearchParams({actionDigest:s.actionDigest,path:s.path??\"\",offset:String(s.offset??0)});return await this.requestJson(\"GET\",`${g(e,t)}/tool-reviews/${encodeURIComponent(n)}/details?${i}`)}async getSessionModelContext(e,t){return await this.requestJson(\"GET\",`${g(e,t)}/model-context`)}async updateSession(e,t,n){return await this.requestJson(\"PATCH\",g(e,t),n)}async getSessionTenancyCreateCapabilities(e){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/session-tenancy/capabilities`)}async updateSessionVisibility(e,t,n){return await this.requestJson(\"PUT\",`${g(e,t)}/visibility`,n)}async previewSessionVisibilityChange(e,t,n){return await this.requestJson(\"GET\",`${g(e,t)}/visibility/preview?visibility=${encodeURIComponent(n)}`)}async forkSession(e,t,n){return await this.requestJson(\"POST\",`${g(e,t)}/forks`,n)}async updateSessionToolPolicy(e,t,n){return await this.requestJson(\"PUT\",`${g(e,t)}/tool-policy`,n)}async updateSessionAgent(e,t,n){return await this.requestJson(\"PUT\",`${g(e,t)}/agent`,n)}async updateSessionSkills(e,t,n){return await this.requestJson(\"PUT\",`${g(e,t)}/skills`,n)}async updateSessionMcpApprovalPolicy(e,t,n,s){return await this.requestJson(\"PATCH\",`${g(e,t)}/mcp-servers/${encodeURIComponent(n)}/approval-policy`,s)}async searchSessionMessages(e,t,n={}){return this.requestJson(\"GET\",`/v1/workspaces/${e}/session-message-search`,void 0,{query:t.query,...t.sessionId!==void 0?{sessionId:t.sessionId}:{},...t.groupBy!==void 0?{groupBy:t.groupBy}:{},...t.archiveStatus!==void 0?{archiveStatus:t.archiveStatus}:{},...t.limit!==void 0?{limit:String(t.limit)}:{},...t.cursor!==void 0?{cursor:t.cursor}:{}},n)}async getSessionMessagePreview(e,t,n,s={}){return this.requestJson(\"GET\",`/v1/workspaces/${encodeURIComponent(e)}/sessions/${encodeURIComponent(t)}/events/${encodeURIComponent(n.eventId)}/message-preview`,void 0,{sequence:String(n.sequence)},s)}async listSessions(e,t={}){if(t.search?.trim()||t.originSiteId){let n=await this.listSessionPage(e,t);return[...n.pinned,...n.sessions]}return await this.requestJson(\"GET\",`/v1/workspaces/${e}/sessions`,void 0,nt(t))}async listSessionBackgroundCommands(e,t,n={}){return await this.requestJson(\"GET\",`${g(e,t)}/background-commands`,void 0,{},n)}async listWorkspaceBackgroundCommands(e,t={}){let n=await this.requestJson(\"GET\",`/v1/workspaces/${encodeURIComponent(e)}/sessions`,void 0,{view:\"running_commands\",...t.cursor?{cursor:t.cursor}:{}},t);if(!n||!Array.isArray(n.commands)||!(\"nextCursor\"in n))throw Error(\"This server does not support the workspace running commands view.\");return n}async cancelSessionBackgroundCommand(e,t,n){return await this.requestJson(\"DELETE\",`${g(e,t)}/background-commands/${n}`)}async listSessionPage(e,t={}){let n=await this.requestSessionPage(`/v1/workspaces/${e}/sessions`,t);if(\"projection\"in n)throw F(\"full session details\");return n}async listSessionSummaryPage(e,t={}){let n=await this.requestSessionPage(`/v1/workspaces/${e}/sessions`,t,!0);if(\"projection\"in n)return n;await Promise.resolve().then(() => zn());return{...n,projection:\"summary\",pinned:n.pinned.map(Me),sessions:n.sessions.map(Me)}}async requestSessionPage(e,t,n=!1){let s=t.search?.trim(),i;try{let c={view:\"page\",...nt(t)};if(n)c.projection=\"summary\";if(t.cursor!==void 0)c.cursor=t.cursor;if(s)c.search=s;if(t.channelId!==void 0)c.channelId=t.channelId??\"null\";if(t.createdBy)c.createdByKind=t.createdBy.kind,c.createdBySubjectId=t.createdBy.subjectId;for(let u of Mi){let l=t[u];if(l)c[u]=l}if(t.pinsOnly)c.pinsOnly=\"true\";if(t.includeTotals)c.includeTotals=\"true\";if(t.needsYouOnly)c.needsYouOnly=\"true\";if(t.contentArchivedOnly)c.contentArchivedOnly=\"true\";if(t.mineOnly)c.mineOnly=\"true\";if(t.includePinned===!1)c.includePinned=\"false\";if(t.archivedOnly)c.archivedOnly=\"true\";if(t.siteConversations)c.siteConversations=t.siteConversations;i=await this.requestJson(\"GET\",e,void 0,c,{signal:t.signal})}catch(c){if(c instanceof P&&c.status===410)throw new He(c.status,c.body,{...c.code?{code:c.code}:{},retryable:c.retryable,...c.correlationId?{correlationId:c.correlationId}:{},outcomeUnknown:c.outcomeUnknown,displayMessage:\"The session list changed — refresh and try again.\"});throw c}let r=i,o=Array.isArray(r),a=Ui(t);if(t.sortBy!==void 0&&(o||r.sortBy!==t.sortBy)||t.archiveStatus!==void 0&&(o||r.archiveStatus!==t.archiveStatus))throw F(\"the requested session sorting/archive filter\");if(o){let c=t.includeTotals?\"complete session totals\":t.cursor?\"stable session-page cursors\":s?\"session search\":t.pinsOnly?\"pins-only session lists\":t.archivedOnly?\"archived session lists\":a?\"filtered session lists\":null;if(c)throw F(c);return{pinned:[],sessions:r,nextCursor:null}}if(t.includeTotals&&r.totals===void 0)throw F(\"complete session totals\");if(t.needsYouOnly&&r.needsYouOnly!==!0)throw F(\"attention session filtering\");if(t.contentArchivedOnly&&r.contentArchivedOnly!==!0)throw F(\"read-only session filtering\");if(t.mineOnly&&r.mineOnly!==!0)throw F(\"your-sessions filtering\");if(a&&r.filtersApplied!==!0)throw F(\"filtered session lists\");if(t.originSiteId&&(!r.originSiteId||t.originSiteId!==\"current\"&&r.originSiteId!==t.originSiteId))throw F(\"Site-filtered session lists\");if(t.siteAccessId&&(!r.siteAccessId||t.siteAccessId!==\"current\"&&t.siteAccessId!==r.siteAccessId))throw F(\"Site access-filtered session lists\");return r}async recordSiteOpened(e,t){return this.requestJson(\"POST\",`/v1/workspaces/${encodeURIComponent(e)}/published-artifacts/${encodeURIComponent(t)}/opened`)}async listSiteSessionAccess(e,t){return this.requestJson(\"GET\",`/v1/workspaces/${encodeURIComponent(e)}/published-artifacts/${encodeURIComponent(t)}/session-access`)}async setSiteSessionAccess(e,t,n,s){return this.requestJson(s?\"PUT\":\"DELETE\",`/v1/workspaces/${encodeURIComponent(e)}/published-artifacts/${encodeURIComponent(t)}/session-access/${encodeURIComponent(n)}`)}async listAgentTopology(e,t={}){let n=t.query?.trim()||t.search?.trim();if(n&&t.subject)throw TypeError(\"listAgentTopology query cannot be combined with an exact subject\");let s=nt(t);if(t.rootSessionId)s.rootSessionId=t.rootSessionId;if(t.cursor)s.cursor=t.cursor;if(n)s.query=n;if(t.statuses?.length)s.statuses=t.statuses.join(\",\");if(t.activeOnly!==void 0)s.activeOnly=t.activeOnly?\"true\":\"false\";if(t.recentHours!==void 0)s.recentHours=String(t.recentHours);if(t.subject)s.subjectNamespace=t.subject.namespace,s.subjectType=t.subject.type,s.subjectKey=t.subject.canonicalKey;if(t.claimLimit!==void 0)s.claimLimit=String(t.claimLimit);return await this.requestJson(\"GET\",`/v1/workspaces/${e}/agent-topology`,void 0,s)}async updateSessionPin(e,t,n){return await this.requestJson(\"PUT\",`${g(e,t)}/pin`,n)}async updateSessionAttention(e,t,n){return await this.requestJson(\"PUT\",`${g(e,t)}/attention`,n)}async updateSessionArchive(e,t,n){return await this.requestJson(\"PUT\",`${g(e,t)}/archive`,n)}async updateSessionRetention(e,t,n){return await this.requestJson(\"PUT\",`${g(e,t)}/retention`,n)}async deleteSession(e,t){return await this.requestJson(\"DELETE\",g(e,t))}async getSessionLineage(e,t,n={}){let s=`${g(e,t)}/lineage`;return await this.sharedRead(s,(i)=>this.requestJson(\"GET\",s,void 0,{},{signal:i}),n)}sharedRead(e,t,n={}){if(n.signal?.aborted)return Promise.reject(n.signal.reason??new DOMException(\"Request aborted\",\"AbortError\"));let s=this.active.get(e);if(s){if(!n.fresh)return this.observeRead(s,n.onRequestStart),this.consumeSharedRead(e,s,n.signal);let c=s.generation+1,u=this.queued.get(e);if(u&&u.generation>=c)return this.observeRead(u,n.onRequestStart),this.consumeSharedRead(e,u,n.signal);let l=u?.promise??s.promise;return this.queueRead(e,l,c,t,n)}let i=this.queued.get(e);if(i&&(!n.fresh||!i.started))return this.observeRead(i,n.onRequestStart),this.consumeSharedRead(e,i,n.signal);if(i)return this.queueRead(e,i.promise,i.generation+1,t,n);let r=(this.generations.get(e)??0)+1,o=Fn(r,n.onRequestStart),a=this.consumeSharedRead(e,o,n.signal);return this.launchRead(e,o,t),a}queueRead(e,t,n,s,i){let r=Fn(n,i.onRequestStart),o=this.consumeSharedRead(e,r,i.signal);this.queued.set(e,r);let a=()=>this.launchRead(e,r,s);t.then(a,a);let c=()=>{if(this.queued.get(e)!==r)return;if(this.queued.delete(e),!this.active.has(e))this.generations.delete(e)};return r.promise.then(c,c),o}launchRead(e,t,n){if(t.controller.signal.aborted)return;t.started=!0,this.generations.set(e,t.generation),this.active.set(e,t);try{t.stamp=this.options.beginSharedRead?.()}catch{}for(let r of t.listeners)try{r(t.stamp)}catch{}t.listeners.clear();let s=()=>{if(this.active.get(e)!==t)return;if(this.active.delete(e),!this.queued.has(e))this.generations.delete(e)},i;try{i=n(t.controller.signal)}catch(r){s(),t.reject(r);return}i.then((r)=>{s(),t.resolve(r)},(r)=>{s(),t.reject(r)})}consumeSharedRead(e,t,n){t.consumers+=1;let s=!1,i=()=>{if(s)return;if(s=!0,t.consumers-=1,!n?.aborted||t.consumers>0)return;let o=n.reason;if(t.controller.abort(o),this.active.get(e)===t)this.active.delete(e);if(this.queued.get(e)===t)this.queued.delete(e);if(!this.active.has(e)&&!this.queued.has(e))this.generations.delete(e);t.reject(o)};return n?.addEventListener(\"abort\",i,{once:!0}),ae(t.promise,n).finally(()=>{n?.removeEventListener(\"abort\",i),i()})}observeRead(e,t){if(!t)return;if(!e.started){e.listeners.add(t);return}if(e.stamp===void 0)return;try{t(e.stamp)}catch{}}async negotiateCodexRealtimeWebrtc(e,t,n,s={}){return await this.requestJson(\"POST\",`${g(e,t)}/realtime/webrtc`,n,{},{signal:s.signal})}async negotiateRealtimeWebsocket(e,t,n,s={}){return await this.requestJson(\"POST\",`${g(e,t)}/realtime/websocket`,n,{},{signal:s.signal})}async negotiateGatewayRealtime(e,t,n,s={}){return await this.requestJson(\"POST\",`${g(e,t)}/realtime/gateway`,n,{},{signal:s.signal})}async negotiateXaiSubscriptionRealtime(e,t,n,s={}){return await this.requestJson(\"POST\",`${g(e,t)}/realtime/supergrok`,n,{},{signal:s.signal})}async activateCodexRealtimeConnection(e,t,n,s,i,r={}){return await this.requestJson(\"POST\",`${g(e,t)}/realtime/${n}/connections/${s}/activate`,i,{},{signal:r.signal})}async beginSessionRealtime(e,t,n){return await this.requestJson(\"POST\",`${g(e,t)}/realtime`,n)}async heartbeatSessionRealtime(e,t,n,s){return await this.requestJson(\"PATCH\",`${g(e,t)}/realtime/${n}/heartbeat`,s)}async syncSessionRealtimeLedger(e,t,n,s){return await this.requestJson(\"POST\",`${g(e,t)}/realtime/${n}/sync`,s)}async endSessionRealtime(e,t,n,s){return await this.requestJson(\"DELETE\",`${g(e,t)}/realtime/${n}`,s)}async listTurns(e,t,n={}){return await this.requestJson(\"GET\",`${g(e,t)}/turns`,void 0,{...n.limit!==void 0?{limit:String(n.limit)}:{},...n.latestStarted?{latestStarted:\"1\"}:{}},{signal:n.signal})}async getLatestStartedTurn(e,t,n={}){return(await this.listTurns(e,t,{latestStarted:!0,signal:n.signal}))[0]??null}async listMachines(e,t={}){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/machines`,void 0,{...t.sessionId!==void 0?{sessionId:t.sessionId}:{}},{signal:t.signal})}async updateMachineAgent(e,t){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/machines/${t}/update`)}async enableMachineScreenControl(e,t){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/machines/${t}/screen-control`,{})}async openMachinePrivacySettings(e,t,n){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/machines/${t}/privacy-settings`,n)}async previewMachineAudience(e,t,n){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/machines/${t}/audience/preview`,n)}async changeMachineAudience(e,t,n){return await this.requestJson(\"PUT\",`/v1/workspaces/${e}/machines/${t}/audience`,n)}async updateMachineOperationPolicy(e,t,n){return await this.requestJson(\"PATCH\",`/v1/workspaces/${e}/machines/${t}/operation-policy`,n)}async machineMetricsSeries(e,t,n={}){return(await this.requestJson(\"GET\",`/v1/workspaces/${e}/machines/${t}/metrics/series`,void 0,{...n.window!==void 0?{window:n.window}:{}})).samples}async removeEnrollment(e,t,n={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/enrollments/${t}/revoke`,n)}async lookupDeviceEnrollment(e){return await this.requestJson(\"POST\",\"/v1/enrollments/device/lookup\",{userCode:e})}async approveDeviceEnrollment(e,t){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/enrollments/device/approve`,{userCode:t.userCode,allowScreenControl:t.allowScreenControl??!1,...t.scope?{scope:t.scope}:{}})}async denyDeviceEnrollment(e,t){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/enrollments/device/deny`,{userCode:t.userCode})}async mintEnrollToken(e,t={}){let n=\"scope\"in t?t.scope:void 0;return await this.requestJson(\"POST\",`/v1/workspaces/${e}/enrollments/token`,{allowScreenControl:t.allowScreenControl??!1,...n?{scope:n}:{}})}async swapActiveSandbox(e,t,n){return await this.requestJson(\"POST\",`${g(e,t)}/active-sandbox`,n)}async listScheduledTasks(e,t={}){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/scheduled-tasks`,void 0,{...t.offset!==void 0?{offset:String(t.offset)}:{},...t.sessionId?{sessionId:t.sessionId}:{},...t.limit!==void 0?{limit:String(t.limit)}:{}})}async getScheduledTask(e,t){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/scheduled-tasks/${t}`)}async listScheduledTaskSlackChannels(e,t,n){let s=new URLSearchParams({connectionId:t});if(n)s.set(\"cursor\",n);return await this.requestJson(\"GET\",`/v1/workspaces/${e}/scheduled-task-slack-channels?${s}`)}async listEvents(e,t,n={}){return(await this.listEventPage(e,t,n)).events}async listEventPage(e,t,n={}){if(n.latest&&[\"includeTypes\",\"excludeTypes\",\"includeClasses\",\"excludeClasses\"].some((x)=>Object.prototype.hasOwnProperty.call(n,x)))throw TypeError(\"latest cannot be combined with event filters\");if(n.resultMode===\"compact\"&&!n.latest)throw TypeError(\"resultMode=compact requires latest\");let s=n.resultMode===\"compact\"?null:n,i=crypto.randomUUID(),r=await this.fetchImpl(this.url(`${g(e,t)}/events`,{...s?.after!==void 0?{after:String(s.after)}:{},...s?.before!==void 0?{before:String(s.before)}:{},...s?.limit!==void 0?{limit:String(s.limit)}:{},...s?.compact?{compact:\"1\"}:{},...n.mode?{mode:n.mode}:{},...s?.direction?{direction:s.direction}:{},...n.payloadMode?{payloadMode:n.payloadMode}:{},...n.resultMode?{resultMode:n.resultMode}:{},...s?.includeTypes?.length?{includeTypes:s.includeTypes.join(\",\")}:{},...s?.excludeTypes?.length?{excludeTypes:s.excludeTypes.join(\",\")}:{},...s?.includeClasses?.length?{includeClasses:s.includeClasses.join(\",\")}:{},...s?.excludeClasses?.length?{excludeClasses:s.excludeClasses.join(\",\")}:{},...s?.presentedToolCalls===\"include\"?{presentedToolCalls:\"include\"}:{},...s?.toolOutputs===\"preview\"?{toolOutputs:\"preview\"}:{},...n.latest?{latest:n.latest}:{}}),{method:\"GET\",headers:{...this.headers(i),Accept:\"application/json\"}});if(D(r,this.apiContractStrict),!r.ok)throw await M(r,{method:\"GET\",correlationId:i});await fe(r,{method:\"GET\",correlationId:i});let o=await r.json();if(n.resultMode===\"compact\")return o;let a=o,c=(x)=>{let b=r.headers.get(x);if(b===null)return null;let h=Number(b);return Number.isSafeInteger(h)&&h>=0?h:null},u=r.headers.get(\"X-OpenGeni-Event-Mode\")===\"forensic\"?\"forensic\":\"monitoring\",l=r.headers.get(\"X-OpenGeni-Event-Direction\")===\"after\"?\"after\":\"before\",p=r.headers.get(\"X-OpenGeni-Payload-Mode\"),d=p===\"none\"||p===\"full\"?p:\"summary\",m=c(\"X-OpenGeni-Covered-First\"),y=c(\"X-OpenGeni-Covered-Last\"),R=c(\"X-OpenGeni-Page-Bytes\")??new TextEncoder().encode(JSON.stringify(a)).byteLength,w=c(\"X-OpenGeni-Page-Max-Bytes\")??1048576,S=r.headers.get(\"X-OpenGeni-Truncated-By\"),I=S===\"count\"||S===\"bytes\"||S===\"http_bytes\"?S:null;return{events:a,mode:u,payloadMode:d,direction:l,bytes:R,maxBytes:w,truncated:r.headers.get(\"X-OpenGeni-Page-Truncated\")===\"true\",hasMore:r.headers.get(\"X-OpenGeni-Has-More\")===\"true\",truncatedBy:I,coveredSequence:m===null||y===null?null:{first:m,last:y},nextAfter:c(\"X-OpenGeni-Next-After\"),nextBefore:c(\"X-OpenGeni-Next-Before\"),forensicExact:r.headers.get(\"X-OpenGeni-Forensic-Exact\")===\"true\",conversationFilter:c(Pt)}}async getLatestEventResult(e,t,n={latest:\"terminal\"}){return await this.listEventPage(e,t,{...n,resultMode:\"compact\"})}async sendEvent(e,t,n){return await this.requestSessionCommand(\"POST\",`${g(e,t)}/events`,n)}async sendMessage(e,t,n){let s=typeof n===\"string\"?{text:n}:n;Jn(s);let{clientEventId:i,...r}=s;return await this.sendEvent(e,t,{type:\"user.message\",...i!==void 0?{clientEventId:i}:{},payload:r})}async pauseSession(e,t,n={}){return await this.controlSession(e,t,{action:\"pause\",clientEventId:n.clientEventId??crypto.randomUUID(),...n.reason?{reason:n.reason}:{},...n.expectedControlEtag?{expectedControlEtag:n.expectedControlEtag}:{}})}async sendApprovalDecision(e,t,n){let{clientEventId:s,...i}=n;return await this.sendEvent(e,t,{type:\"user.approvalDecision\",...s!==void 0?{clientEventId:s}:{},payload:i})}async listHumanInputRequests(e,t,n={}){let s=await this.requestJson(\"GET\",`${g(e,t)}/human-input-requests`,void 0,n.status?{status:n.status}:void 0);return Ct(s,s.requests),s.requests}async getHumanInputRequest(e,t,n){return await this.requestJson(\"GET\",`${g(e,t)}/human-input-requests/${n}`)}async submitHumanInputResponse(e,t,n,s,i={}){return await this.sendEvent(e,t,{type:\"user.humanInputResponse\",...i.clientEventId?{clientEventId:i.clientEventId}:{},payload:{requestId:n,response:s}})}streamEvents(e,t,n={}){return qt(this.eventStreamTransport(e,t),n)}eventStreamTransport(e,t){return{openStream:async(n,s)=>await this.openEventStream(e,t,{after:n,...s?{signal:s}:{}}),listEvents:async(n,s)=>await this.listEvents(e,t,{after:n,limit:s})}}async openEventStream(e,t,n={}){let s=this.url(`${g(e,t)}/events/stream`,{after:String(n.after??0)}),i=crypto.randomUUID(),r=await this.fetchImpl(s,{method:\"GET\",headers:{...this.headers(i),Accept:\"text/event-stream\"},...n.signal?{signal:n.signal}:{}});if(D(r,this.apiContractStrict),!r.ok)throw await M(r,{method:\"GET\",correlationId:i});if(!r.body)throw new P(r.status,\"SSE response did not include a readable body\");return r.body}async getQueue(e,t){let n=`${g(e,t)}/queue`;return await this.sharedRead(n,()=>this.requestSessionCommand(\"GET\",n))}async moveQueueItem(e,t,n,s){return await this.requestSessionCommand(\"POST\",`${g(e,t)}/queue/${n}/move`,s)}async editQueueItem(e,t,n,s){return await this.requestSessionCommand(\"POST\",`${g(e,t)}/queue/${n}/edit`,s)}async steerQueueItem(e,t,n,s){return await this.requestSessionCommand(\"POST\",`${g(e,t)}/queue/${n}/steer`,s)}async deleteQueueItem(e,t,n,s){return await this.requestSessionCommand(\"POST\",`${g(e,t)}/queue/${n}/delete`,s)}async getComposerDraft(e,t,n={}){return await this.requestSessionCommand(\"GET\",`${g(e,t)}/composer-draft`,void 0,n)}async saveComposerDraft(e,t,n){return await this.requestSessionCommand(\"PUT\",`${g(e,t)}/composer-draft`,n)}async submitComposerDraft(e,t,n){return await this.requestSessionCommand(\"POST\",`${g(e,t)}/composer-draft/submit`,n)}async getSandboxRecovery(e,t){return this.requestJson(\"GET\",`${g(e,t)}/sandbox-recovery`)}async recoverSandbox(e,t,n){return this.requestSessionCommand(\"POST\",`${g(e,t)}/sandbox-recovery`,n)}async retrySession(e,t,n){return await this.requestSessionCommand(\"POST\",`${g(e,t)}/retry`,n)}async controlSession(e,t,n){return await this.requestSessionCommand(\"POST\",`${g(e,t)}/control`,n)}async resumeSession(e,t,n={}){return await this.controlSession(e,t,{action:\"resume\",clientEventId:n.clientEventId??crypto.randomUUID(),...n.reason?{reason:n.reason}:{},...n.expectedControlEtag?{expectedControlEtag:n.expectedControlEtag}:{}})}async cancelSession(e,t,n={}){return await this.controlSession(e,t,{action:\"cancel\",clientEventId:n.clientEventId??crypto.randomUUID(),...n.reason?{reason:n.reason}:{},...n.expectedControlEtag?{expectedControlEtag:n.expectedControlEtag}:{}})}async setWorkspacePauseTimer(e,t){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/pause-timer`,t)}async setWorkspaceInferenceState(e,t){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/inference-control`,t)}async listWorkspaceControlEvents(e,t={}){return(await this.listWorkspaceControlEventPage(e,t)).events}async listWorkspaceControlEventPage(e,t={}){let n=crypto.randomUUID(),s=await this.fetchImpl(this.url(`/v1/workspaces/${e}/control-events`,{...t.after!==void 0?{after:String(t.after)}:{},...t.limit!==void 0?{limit:String(t.limit)}:{}}),{method:\"GET\",headers:{...this.headers(n),Accept:\"application/json\"}});if(D(s,this.apiContractStrict),!s.ok)throw await M(s,{method:\"GET\",correlationId:n});await fe(s,{method:\"GET\",correlationId:n});let i=await s.json(),r=s.headers.get(\"X-OpenGeni-Page-Bytes\"),o=s.headers.get(\"X-OpenGeni-Next-After\"),a=r===null?Number.NaN:Number(r),c=o===null?null:Number(o);return{events:i,bytes:Number.isSafeInteger(a)&&a>=0?a:new TextEncoder().encode(JSON.stringify(i)).byteLength,truncated:s.headers.get(\"X-OpenGeni-Page-Truncated\")===\"true\",nextAfter:c!==null&&Number.isSafeInteger(c)&&c>=0?c:null}}streamWorkspaceControlEvents(e,t={}){return Jt(this.workspaceControlStreamTransport(e),t)}streamWorkspaceLiveEvents(e,t={}){return jt(this.workspaceLiveStreamTransport(e),t)}workspaceLiveStreamTransport(e){return{openStream:async(t,n,s)=>await this.openWorkspaceLiveEventStream(e,{controlAfter:t,interactionAfter:n,...s?{signal:s}:{}})}}async openWorkspaceLiveEventStream(e,t={}){let n=crypto.randomUUID(),s=await this.fetchImpl(this.url(`/v1/workspaces/${e}/live-events/stream`,{controlAfter:String(t.controlAfter??0),interactionAfter:String(t.interactionAfter??0)}),{method:\"GET\",headers:{...this.headers(n),Accept:\"text/event-stream\"},...t.signal?{signal:t.signal}:{}});if(D(s,this.apiContractStrict),!s.ok)throw await M(s,{method:\"GET\",correlationId:n});if(!s.body)throw new P(s.status,\"SSE response did not include a readable body\");return s.body}workspaceControlStreamTransport(e){return{openStream:async(t,n)=>await this.openWorkspaceControlEventStream(e,{after:t,...n?{signal:n}:{}})}}async openWorkspaceControlEventStream(e,t={}){let n=crypto.randomUUID(),s=await this.fetchImpl(this.url(`/v1/workspaces/${e}/control-events/stream`,{after:String(t.after??0)}),{method:\"GET\",headers:{...this.headers(n),Accept:\"text/event-stream\"},...t.signal?{signal:t.signal}:{}});if(D(s,this.apiContractStrict),!s.ok)throw await M(s,{method:\"GET\",correlationId:n});if(!s.body)throw new P(s.status,\"SSE response did not include a readable body\");return s.body}async steerMessage(e,t,n){let s=typeof n===\"string\"?{text:n}:n;return Jn(s),await this.requestSessionCommand(\"POST\",`${g(e,t)}/steer`,s)}async getGoal(e,t,n={}){let s=`${g(e,t)}/goal`;return await this.sharedRead(s,(i)=>this.requestJson(\"GET\",s,void 0,{},{signal:i}),n)}async findGoal(e,t,n={}){let s=`${g(e,t)}/goal`,i={absent:\"null\"};return await this.sharedRead(`${s}?absent=null`,(r)=>this.requestJson(\"GET\",s,void 0,i,{signal:r}),n)}async updateGoal(e,t,n){return await this.requestJson(\"PATCH\",`${g(e,t)}/goal`,n)}async listGoalRevisions(e,t){return await this.requestJson(\"GET\",`${g(e,t)}/goal/revisions`)}async listGoalRevisionPage(e,t,n={}){let s=new URLSearchParams;if(n.limit!==void 0)s.set(\"limit\",String(n.limit));if(n.before!==void 0)s.set(\"before\",n.before);let i=s.size>0?`?${s.toString()}`:\"\";return await this.requestJson(\"GET\",`${g(e,t)}/goal/revisions/page${i}`)}async rejectGoalRevision(e,t,n,s){return await this.requestJson(\"POST\",`${g(e,t)}/goal/revisions/${n}/reject`,s)}async rollbackGoalRevision(e,t,n,s){return await this.requestJson(\"POST\",`${g(e,t)}/goal/revisions/${n}/rollback`,s)}async applyGoalRevision(e,t,n,s){return await this.requestJson(\"POST\",`${g(e,t)}/goal/revisions/${n}/apply`,s)}async deleteGoal(e,t){await this.requestVoid(\"DELETE\",`${g(e,t)}/goal`)}async pauseGoal(e,t,n={}){return await this.updateGoal(e,t,{status:\"paused\",...n.rationale!==void 0?{rationale:n.rationale}:{}})}async resumeGoal(e,t){return await this.updateGoal(e,t,{status:\"active\"})}async clearSessionContext(e,t){await this.requestVoid(\"POST\",`${g(e,t)}/context/clear`,{confirm:!0})}async compactSessionContext(e,t){return await this.requestJson(\"POST\",`${g(e,t)}/context/compact`,{})}async fsList(e,t,n={},s={}){return await this.requestJson(\"POST\",`${g(e,t)}/fs/list`,n,{},s)}async fsListBatch(e,t,n,s={}){return await this.requestJson(\"POST\",`${g(e,t)}/fs/list-batch`,n,{},s)}async fsRead(e,t,n,s={}){return await this.requestJson(\"POST\",n.workspaceOnly?`${g(e,t)}/fs/read-workspace`:`${g(e,t)}/fs/read`,n,{},s)}async publishSandboxFileArtifact(e,t,n,s={}){return await this.requestJson(\"POST\",`${g(e,t)}/artifacts/publish`,n,{},s)}async fsWrite(e,t,n){return await this.requestJson(\"POST\",`${g(e,t)}/fs/write`,n)}async fsDelete(e,t,n){return await this.requestJson(\"POST\",`${g(e,t)}/fs/delete`,n)}async fsMove(e,t,n){return await this.requestJson(\"POST\",`${g(e,t)}/fs/move`,n)}async fsMkdir(e,t,n){return await this.requestJson(\"POST\",`${g(e,t)}/fs/mkdir`,n)}async gitStatus(e,t,n={},s={}){return await this.requestJson(\"POST\",`${g(e,t)}/git/status`,n,{},s)}async gitDiff(e,t,n={},s={}){return await this.requestJson(\"POST\",`${g(e,t)}/git/diff`,n,{},s)}async gitReadBatch(e,t,n,s={}){return await this.requestJson(\"POST\",`${g(e,t)}/git/read-batch`,n,{},s)}async gitLog(e,t,n={}){return await this.requestJson(\"POST\",`${g(e,t)}/git/log`,n)}async gitShow(e,t,n){return await this.requestJson(\"POST\",`${g(e,t)}/git/show`,n)}async getWorkspaceCapture(e,t,n={}){return await this.requestJson(\"GET\",`${g(e,t)}/workspace/capture`,void 0,{},n)}async getWorkspaceCaptureFile(e,t,n,s,i={}){let r={path:n};if(s!==void 0)r.revision=String(s);return await this.requestJson(\"GET\",`${g(e,t)}/workspace/capture/file`,void 0,r,i)}async terminalExec(e,t,n){return await this.requestJson(\"POST\",`${g(e,t)}/terminal/exec`,n)}async terminalPtyOpen(e,t,n={}){return await this.requestJson(\"POST\",`${g(e,t)}/terminal/pty`,n)}async terminalPtyWrite(e,t,n){await this.requestVoid(\"POST\",`${g(e,t)}/terminal/pty/write`,n)}async terminalPtyResize(e,t,n){await this.requestVoid(\"POST\",`${g(e,t)}/terminal/pty/resize`,n)}async terminalPtyClose(e,t,n){await this.requestVoid(\"POST\",`${g(e,t)}/terminal/pty/close`,n)}async getStreamCapabilities(e,t,n={}){return await this.requestJson(\"GET\",`${g(e,t)}/stream-capabilities`,void 0,{},n)}async acknowledgeStream(e,t,n={}){return await this.requestJson(\"POST\",`${g(e,t)}/stream-capabilities/acknowledge`,n)}async attachViewer(e,t,n={}){return await this.requestJson(\"POST\",`${g(e,t)}/viewers`,n)}async heartbeatViewer(e,t,n,s){return await this.requestJson(\"POST\",`${g(e,t)}/viewers/${n}/heartbeat`,s)}async detachViewer(e,t,n){await this.requestVoid(\"DELETE\",`${g(e,t)}/viewers/${n}`)}streamWorkspaceInteractionRevisions(e,t={}){return Ht(this.workspaceInteractionRevisionStreamTransport(e),t)}workspaceInteractionRevisionStreamTransport(e){return{openStream:async(t,n)=>await this.openWorkspaceInteractionRevisionStream(e,{after:t,...n?{signal:n}:{}})}}async openWorkspaceInteractionRevisionStream(e,t={}){let n=crypto.randomUUID(),s=await this.fetchImpl(this.url(`/v1/workspaces/${e}/interaction-events/stream`,{after:String(t.after??0)}),{method:\"GET\",headers:{...this.headers(n),Accept:\"text/event-stream\"},...t.signal?{signal:t.signal}:{}});if(D(s,this.apiContractStrict),!s.ok)throw await M(s,{method:\"GET\",correlationId:n});if(!s.body)throw new P(s.status,\"SSE response did not include a readable body\");return s.body}async listNetworkRoutes(e,t={}){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/network-routes`,void 0,t.includeArchived?{includeArchived:\"true\"}:{},t)}async getNetworkRoute(e,t,n={}){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/network-routes/${encodeURIComponent(t)}`,void 0,{},n)}async createNetworkRoute(e,t,n={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/network-routes`,t,{},n)}async updateNetworkRoute(e,t,n,s={}){return await this.requestJson(\"PATCH\",`/v1/workspaces/${e}/network-routes/${encodeURIComponent(t)}`,n,{},s)}async listSiteAuthConnections(e,t={}){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/site-auth-connections`,void 0,t.includeArchived?{includeArchived:\"true\"}:{},t)}async getSiteAuthConnection(e,t,n={}){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/site-auth-connections/${encodeURIComponent(t)}`,void 0,{},n)}async createSiteAuthConnection(e,t,n={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/site-auth-connections`,t,{},n)}async updateSiteAuthConnection(e,t,n,s={}){return await this.requestJson(\"PATCH\",`/v1/workspaces/${e}/site-auth-connections/${encodeURIComponent(t)}`,n,{},s)}async listAuthRuns(e,t={}){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/auth-runs`,void 0,{...t.browserSessionId?{browserSessionId:t.browserSessionId}:{},...t.siteAuthConnectionId?{siteAuthConnectionId:t.siteAuthConnectionId}:{},...t.includeSettled?{includeSettled:\"true\"}:{}},t)}async getAuthRun(e,t,n={}){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/auth-runs/${encodeURIComponent(t)}`,void 0,{},n)}async startBrowserAuthRun(e,t,n,s={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/browser-sessions/${encodeURIComponent(t)}/auth-runs`,n,{},s)}async reportBrowserAuthRun(e,t,n,s,i={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/browser-sessions/${encodeURIComponent(t)}/auth-runs/${encodeURIComponent(n)}/report`,s,{},i)}async advanceExternalBrowserAuthRun(e,t,n,s,i={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/browser-sessions/${encodeURIComponent(t)}/auth-runs/${encodeURIComponent(n)}/external-auth`,s,{},i)}async openExternalBrowserAuthFlow(e,t,n,s,i={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/browser-sessions/${encodeURIComponent(t)}/auth-runs/${encodeURIComponent(n)}/external-auth/interactive`,s,{},i)}async verifyBrowserAuthRun(e,t,n,s,i={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/browser-sessions/${encodeURIComponent(t)}/auth-runs/${encodeURIComponent(n)}/verify`,s,{},i)}async listInteractionInterventions(e,t={}){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/interaction-interventions`,void 0,{...t.resourceKind?{resourceKind:t.resourceKind}:{},...t.resourceId?{resourceId:t.resourceId}:{},...t.includeSettled?{includeSettled:\"true\"}:{}},t)}async getInteractionIntervention(e,t,n={}){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/interaction-interventions/${encodeURIComponent(t)}`,void 0,{},n)}async createInteractionIntervention(e,t,n={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/interaction-interventions`,t,{},n)}async resolveInteractionIntervention(e,t,n,s={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/interaction-interventions/${encodeURIComponent(t)}/resolve`,n,{},s)}async listAttachedBrowsers(e,t={}){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/attached-browsers`,void 0,t.includeDisconnected?{includeDisconnected:\"true\"}:{},t)}async getAttachedBrowser(e,t,n={}){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/attached-browsers/${encodeURIComponent(t)}`,void 0,{},n)}async listBrowserIdentities(e,t={}){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/browser-identities`,void 0,t.includeArchived?{includeArchived:\"true\"}:{},t)}async getBrowserIdentity(e,t,n={}){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/browser-identities/${encodeURIComponent(t)}`,void 0,{},n)}async createBrowserIdentity(e,t,n={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/browser-identities`,t,{},n)}async updateBrowserIdentity(e,t,n,s={}){return await this.requestJson(\"PATCH\",`/v1/workspaces/${e}/browser-identities/${encodeURIComponent(t)}`,n,{},s)}async listBrowserRevisions(e,t,n={}){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/browser-identities/${encodeURIComponent(t)}/revisions`,void 0,{},n)}async listBrowserSessions(e,t={}){let{query:n,request:s}=Nn(t);return await this.requestJson(\"GET\",`/v1/workspaces/${e}/browser-sessions`,void 0,n,s)}async getBrowserSession(e,t,n={}){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/browser-sessions/${encodeURIComponent(t)}`,void 0,{},n)}async readBrowserClipboard(e,t,n={}){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/browser-sessions/${encodeURIComponent(t)}/clipboard`,void 0,{},n)}async listBrowserDownloads(e,t,n={}){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/browser-sessions/${encodeURIComponent(t)}/downloads`,void 0,{},n)}async getBrowserDownload(e,t,n,s={}){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/browser-sessions/${encodeURIComponent(t)}/downloads/${encodeURIComponent(n)}`,void 0,{},s)}async saveBrowserDownload(e,t,n,s,i={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/browser-sessions/${encodeURIComponent(t)}/downloads/${encodeURIComponent(n)}/save`,s,{},i)}async startBrowserRecording(e,t,n,s={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/browser-sessions/${encodeURIComponent(t)}/recordings`,{targetId:n},{},s)}async getBrowserRecording(e,t,n,s={}){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/browser-sessions/${encodeURIComponent(t)}/recordings/${encodeURIComponent(n)}`,void 0,{},s)}async saveBrowserRecording(e,t,n,s,i={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/browser-sessions/${encodeURIComponent(t)}/recordings/${encodeURIComponent(n)}/save`,s,{},i)}async createBrowserSession(e,t,n={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/browser-sessions`,t,{},n)}async listBrowserTargets(e,t,n={}){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/browser-sessions/${encodeURIComponent(t)}/targets`,void 0,{},n)}async openBrowserTarget(e,t,n={},s={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/browser-sessions/${encodeURIComponent(t)}/targets`,n,{},s)}async openBrowserTargetWithInventory(e,t,n={},s={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/browser-sessions/${encodeURIComponent(t)}/targets/open-with-inventory`,n,{},s)}async selectBrowserTarget(e,t,n,s={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/browser-sessions/${encodeURIComponent(t)}/targets/${encodeURIComponent(n)}/select`,{},{},s)}async captureBrowserTarget(e,t,n,s={},i={}){let r=new URLSearchParams;if(i.fullPage!==void 0){if(typeof i.fullPage!==\"boolean\")throw TypeError(\"browser screenshot fullPage must be a boolean\");r.set(\"fullPage\",String(i.fullPage))}if(i.format!==void 0){if(i.format!==\"jpeg\"&&i.format!==\"png\")throw TypeError(\"browser screenshot format must be jpeg or png\");r.set(\"format\",i.format)}if(i.quality!==void 0){if(!Number.isSafeInteger(i.quality)||i.quality<1||i.quality>100)throw RangeError(\"browser screenshot quality must be an integer from 1 to 100\");r.set(\"quality\",String(i.quality))}let o=r.size>0?`?${r}`:\"\",a=await this.requestResponse(\"GET\",`/v1/workspaces/${e}/browser-sessions/${encodeURIComponent(t)}/targets/${encodeURIComponent(n)}/screenshot${o}`,{},s),c=a.headers.get(\"content-type\")?.split(\";\",1)[0]?.trim().toLowerCase(),u=a.headers.get(\"x-opengeni-browser-frame\");if(c!==\"image/jpeg\"&&c!==\"image/png\"||!u||u.length>65536)throw await U(a,\"browser frame metadata is invalid\"),A(\"browser frame metadata is invalid\");let l;try{l=kn(JSON.parse(atob(u.replace(/-/gu,\"+\").replace(/_/gu,\"/\"))))}catch{throw await U(a,\"browser frame metadata is invalid\"),A(\"browser frame metadata is invalid\")}let p=await he(a,25165824,null);if(l.browserSessionId!==t||l.targetId!==n||l.mediaType!==c)throw A(\"browser frame evidence does not match its request\");return{...l,data:p}}async closeBrowserTarget(e,t,n,s={}){return await this.requestJson(\"DELETE\",`/v1/workspaces/${e}/browser-sessions/${encodeURIComponent(t)}/targets/${encodeURIComponent(n)}`,void 0,{},s)}async observeBrowserTarget(e,t,n,s={}){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/browser-sessions/${encodeURIComponent(t)}/targets/${encodeURIComponent(n)}/observation`,void 0,{},s)}async getBrowserTargetState(e,t,n,s={}){let i=await this.requestJson(\"GET\",`/v1/workspaces/${e}/browser-sessions/${encodeURIComponent(t)}/targets/${encodeURIComponent(n)}/state`,void 0,{},s);if(i.browserSessionId!==t||i.targetId!==n)throw A(\"browser target state belongs to another binding\");return i}async readBrowserDom(e,t,n,s,i={}){let r=await this.requestJson(\"POST\",`/v1/workspaces/${e}/browser-sessions/${encodeURIComponent(t)}/targets/${encodeURIComponent(n)}/dom-read`,s,{},i);if(r.browserSessionId!==t||r.targetId!==n||r.kind!==s.kind||r.targetGeneration!==s.expectedTargetGeneration||r.documentGeneration!==s.expectedDocumentGeneration||r.frameId!==s.expectedFrameId)throw A(\"browser DOM read belongs to another binding\");return r}async actInBrowser(e,t,n,s={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/browser-sessions/${encodeURIComponent(t)}/actions`,n,{},s)}async getBrowserActionReceipt(e,t,n,s={}){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/browser-sessions/${encodeURIComponent(t)}/operations/${encodeURIComponent(n)}`,void 0,{},s)}async listBrowserDiagnostics(e,t,n,s={}){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/browser-sessions/${encodeURIComponent(t)}/targets/${encodeURIComponent(n)}/diagnostics`,void 0,{...s.kinds?.length?{kinds:s.kinds.join(\",\")}:{},...s.after!==void 0?{after:String(s.after)}:{},...s.limit!==void 0?{limit:String(s.limit)}:{}},s.signal?{signal:s.signal}:{})}async attachBrowserSession(e,t,n,s={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/browser-sessions/${encodeURIComponent(t)}/attachments`,n,{},s)}async heartbeatBrowserSession(e,t,n={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/browser-sessions/${encodeURIComponent(t)}/heartbeat`,{},{},n)}async publishBrowserRevision(e,t,n,s={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/browser-sessions/${encodeURIComponent(t)}/revisions`,n,{},s)}async suspendBrowserSession(e,t,n,s={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/browser-sessions/${encodeURIComponent(t)}/suspend`,n,{},s)}async resumeBrowserSession(e,t,n,s={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/browser-sessions/${encodeURIComponent(t)}/resume`,n,{},s)}async endBrowserSession(e,t,n,s={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/browser-sessions/${encodeURIComponent(t)}/end`,n,{},s)}async inspectBrowserSessionWorkingCopy(e,t,n={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/browser-sessions/${encodeURIComponent(t)}/working-copy/inspection`,{},{},n)}async adoptBrowserSessionWorkingCopy(e,t,n,s={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/browser-sessions/${encodeURIComponent(t)}/working-copy/adoptions`,n,{},s)}async getBrowserSessionWorkingCopyAdoption(e,t,n,s={}){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/browser-sessions/${encodeURIComponent(t)}/working-copy/adoptions/${encodeURIComponent(n)}`,void 0,{},s)}async revertBrowserSessionWorkingCopyAdoption(e,t,n,s={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/browser-sessions/${encodeURIComponent(t)}/working-copy/adoptions/${encodeURIComponent(n)}/revert`,{},{},s)}async listComputerSessions(e,t={}){let{query:n,request:s}=Nn(t);return await this.requestJson(\"GET\",`/v1/workspaces/${e}/computer-sessions`,void 0,n,s)}async getComputerSession(e,t,n={}){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/computer-sessions/${encodeURIComponent(t)}`,void 0,{},n)}async readComputerClipboard(e,t,n={}){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/computer-sessions/${encodeURIComponent(t)}/clipboard`,void 0,{},n)}async getComputerInputPosture(e,t,n={}){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/computer-sessions/${encodeURIComponent(t)}/input-posture`,void 0,{},n)}async createComputerSession(e,t,n={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/computer-sessions`,t,{},n)}async listComputerTargets(e,t,n={}){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/computer-sessions/${encodeURIComponent(t)}/targets`,void 0,{},n)}async observeComputerTarget(e,t,n,s={}){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/computer-sessions/${encodeURIComponent(t)}/targets/${encodeURIComponent(n)}/observation`,void 0,{},s)}async captureComputerTarget(e,t,n,s={}){let i=await this.requestResponse(\"GET\",`/v1/workspaces/${e}/computer-sessions/${encodeURIComponent(t)}/targets/${encodeURIComponent(n)}/screenshot`,{},s),r=i.headers.get(\"content-type\")?.split(\";\",1)[0]?.trim().toLowerCase();if(r!==\"image/jpeg\"&&r!==\"image/png\")throw await U(i,\"computer frame media type is invalid\"),A(\"computer frame media type is invalid\");let o=i.headers.get(\"x-opengeni-computer-frame\");if(!o||o.length>32768)throw await U(i,\"computer frame metadata is invalid\"),A(\"computer frame metadata is invalid\");let a;try{a=In(o)}catch{throw await U(i,\"computer frame metadata is invalid\"),A(\"computer frame metadata is invalid\")}let c=await he(i,262144,null);if(Ki(a,{computerSessionId:t,targetId:n,mediaType:r,sha256:await Kn(c)}))throw A(\"computer frame evidence does not match its request\");return{...a,data:c}}async callNativeComputerTool(e,t,n,s={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/computer-sessions/${encodeURIComponent(t)}/native-calls`,n,{},s)}async actInComputer(e,t,n,s={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/computer-sessions/${encodeURIComponent(t)}/actions`,n,{},s)}async getNativeComputerToolReceipt(e,t,n,s={}){let i=await this.requestJson(\"GET\",`/v1/workspaces/${e}/computer-sessions/${encodeURIComponent(t)}/operations/${encodeURIComponent(n)}`,void 0,{},s);if(i?.targetId!==null)throw Error(\"Expected a native computer receipt\");return i}async getComputerActionReceipt(e,t,n,s={}){let i=await this.requestJson(\"GET\",`/v1/workspaces/${e}/computer-sessions/${encodeURIComponent(t)}/operations/${encodeURIComponent(n)}`,void 0,{},s);if(typeof i?.targetId!==\"string\")throw Error(\"Expected a computer action receipt\");return i}async attachComputerSession(e,t,n,s={}){let i=await this.requestJson(\"POST\",`/v1/workspaces/${e}/computer-sessions/${encodeURIComponent(t)}/attachments`,n,{},s);if(i.stream.kind===\"direct_rfb\")return{...i,stream:{...i.stream,inputAllowed:i.stream.inputAllowed===!0}};return i}async heartbeatComputerSession(e,t,n={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/computer-sessions/${encodeURIComponent(t)}/heartbeat`,{},{},n)}async endComputerSession(e,t,n,s={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/computer-sessions/${encodeURIComponent(t)}/end`,n,{},s)}async getClientConfig(e={}){let t=await this.requestJson(\"GET\",\"/v1/config/client\",void 0,e.workspaceId===void 0?{}:{workspaceId:e.workspaceId},e);if(this.apiContractStrict&&t.apiContractRevision!==oe)throw new ve(oe,String(t.apiContractRevision||\"(missing)\"));return t}async getWorkspaceModelCatalog(e,t={}){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/model-catalog`,void 0,{},t)}async listWorkspaceGatewayCustomModels(e){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/gateway-custom-models`)}async createWorkspaceGatewayCustomModel(e,t){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/gateway-custom-models`,t)}async deleteWorkspaceGatewayCustomModel(e,t,n){if(!/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu.test(t))throw TypeError(\"customModelId must be a UUID\");await this.requestVoid(\"DELETE\",`/v1/workspaces/${e}/gateway-custom-models/${encodeURIComponent(t)}`,n)}async listWorkspaceOpenRouterCustomModels(e){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/openrouter-custom-models`)}async createWorkspaceOpenRouterCustomModel(e,t){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/openrouter-custom-models`,t)}async deleteWorkspaceOpenRouterCustomModel(e,t,n){if(!/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu.test(t))throw TypeError(\"customModelId must be a UUID\");await this.requestVoid(\"DELETE\",`/v1/workspaces/${e}/openrouter-custom-models/${encodeURIComponent(t)}`,n)}async listWorkspaceOpperCustomModels(e){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/opper-custom-models`)}async createWorkspaceOpperCustomModel(e,t){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/opper-custom-models`,t)}async deleteWorkspaceOpperCustomModel(e,t,n){if(!/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu.test(t))throw TypeError(\"customModelId must be a UUID\");await this.requestVoid(\"DELETE\",`/v1/workspaces/${e}/opper-custom-models/${encodeURIComponent(t)}`,n)}async getWorkspaceClaudeSubscriptionUsage(e){return this.requestJson(\"GET\",`/v1/workspaces/${e}/model-providers/claude_subscription/usage`)}async getWorkspaceSubscriptionUsagePools(e){return this.requestJson(\"GET\",`/v1/workspaces/${e}/subscription-usage-pools`)}async getOrganizationSubscriptionUsagePools(e){return this.requestJson(\"GET\",`/v1/organizations/${e}/subscription-usage-pools`)}async listClaudeSubscriptionAccounts(e){return this.requestJson(\"GET\",`/v1/workspaces/${e}/claude/accounts`)}async activateClaudeSubscriptionAccount(e,t){return this.requestJson(\"POST\",`/v1/workspaces/${e}/claude/accounts/${encodeURIComponent(t)}/activate`,{})}async setClaudeSubscriptionRotationSettings(e,t){return this.requestJson(\"PATCH\",`/v1/workspaces/${e}/claude/settings`,t)}async setClaudeSubscriptionAccountAllocator(e,t,n){return this.requestJson(\"PATCH\",`/v1/workspaces/${e}/claude/accounts/${encodeURIComponent(t)}/allocator`,n)}async renameClaudeSubscriptionAccount(e,t,n){return this.requestJson(\"PATCH\",`/v1/workspaces/${e}/claude/accounts/${encodeURIComponent(t)}`,{label:n})}async disconnectClaudeSubscriptionAccount(e,t){return this.requestJson(\"DELETE\",`/v1/workspaces/${e}/claude/accounts/${encodeURIComponent(t)}`,{})}async getClaudeSubscriptionAccountUsage(e,t){return this.requestJson(\"GET\",`/v1/workspaces/${e}/claude/accounts/${encodeURIComponent(t)}/usage`)}async refreshClaudeSubscriptionAccountUsage(e,t){return this.requestJson(\"POST\",`/v1/workspaces/${e}/claude/accounts/${encodeURIComponent(t)}/usage/refresh`,{})}async listOrganizationClaudeSubscriptionAccounts(e){return this.requestJson(\"GET\",`/v1/organizations/${e}/claude/accounts`)}async activateOrganizationClaudeSubscriptionAccount(e,t){return this.requestJson(\"POST\",`/v1/organizations/${e}/claude/accounts/${encodeURIComponent(t)}/activate`,{})}async setOrganizationClaudeSubscriptionRotationSettings(e,t){return this.requestJson(\"PATCH\",`/v1/organizations/${e}/claude/settings`,t)}async setOrganizationClaudeSubscriptionAccountAllocator(e,t,n){return this.requestJson(\"PATCH\",`/v1/organizations/${e}/claude/accounts/${encodeURIComponent(t)}/allocator`,n)}async renameOrganizationClaudeSubscriptionAccount(e,t,n){return this.requestJson(\"PATCH\",`/v1/organizations/${e}/claude/accounts/${encodeURIComponent(t)}`,{label:n})}async disconnectOrganizationClaudeSubscriptionAccount(e,t){return this.requestJson(\"DELETE\",`/v1/organizations/${e}/claude/accounts/${encodeURIComponent(t)}`,{})}async getOrganizationClaudeSubscriptionAccountUsage(e,t){return this.requestJson(\"GET\",`/v1/organizations/${e}/claude/accounts/${encodeURIComponent(t)}/usage`)}async refreshOrganizationClaudeSubscriptionAccountUsage(e,t){return this.requestJson(\"POST\",`/v1/organizations/${e}/claude/accounts/${encodeURIComponent(t)}/usage/refresh`,{})}async connectClaudeSubscriptionSetupToken(e,t){return this.requestJson(\"POST\",`/v1/workspaces/${e}/claude/accounts/setup-token`,t)}async connectOrganizationClaudeSubscriptionSetupToken(e,t){return this.requestJson(\"POST\",`/v1/organizations/${e}/claude/accounts/setup-token`,t)}async startWorkspaceClaudeSubscriptionOAuth(e,t={}){return this.requestJson(\"POST\",`/v1/workspaces/${e}/model-providers/claude_subscription/oauth/start`,t)}async completeWorkspaceClaudeSubscriptionOAuth(e,t){return this.requestJson(\"POST\",`/v1/workspaces/${e}/model-providers/claude_subscription/oauth/complete`,t)}async startOrganizationClaudeSubscriptionOAuth(e,t={}){return this.requestJson(\"POST\",`/v1/organizations/${e}/model-providers/claude_subscription/oauth/start`,t)}async completeOrganizationClaudeSubscriptionOAuth(e,t){return this.requestJson(\"POST\",`/v1/organizations/${e}/model-providers/claude_subscription/oauth/complete`,t)}async refreshWorkspaceClaudeSubscriptionUsage(e){return this.requestJson(\"POST\",`/v1/workspaces/${e}/model-providers/claude_subscription/usage/refresh`,{})}async getOrganizationClaudeSubscriptionUsage(e){return this.requestJson(\"GET\",`/v1/organizations/${e}/model-providers/claude_subscription/usage`)}async refreshOrganizationClaudeSubscriptionUsage(e){return this.requestJson(\"POST\",`/v1/organizations/${e}/model-providers/claude_subscription/usage/refresh`,{})}async getOrganizationModelProviderConnection(e,t){return await this.requestJson(\"GET\",`/v1/organizations/${e}/model-providers/${t}`)}async upsertOrganizationModelProviderConnection(e,t,n){return await this.requestJson(\"PUT\",`/v1/organizations/${e}/model-providers/${t}`,n)}async revokeOrganizationModelProviderConnection(e,t,n){return await this.requestJson(\"DELETE\",`/v1/organizations/${e}/model-providers/${t}`,n)}async listWorkspaceClaudeCustomModels(e,t){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/model-providers/${t}/custom-models`)}async createWorkspaceClaudeCustomModel(e,t,n){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/model-providers/${t}/custom-models`,n)}async deleteWorkspaceClaudeCustomModel(e,t,n,s){if(!/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu.test(n))throw TypeError(\"customModelId must be a UUID\");await this.requestVoid(\"DELETE\",`/v1/workspaces/${e}/model-providers/${t}/custom-models/${encodeURIComponent(n)}`,s)}async listOrganizationProviderCustomModels(e,t){return await this.requestJson(\"GET\",`/v1/organizations/${e}/model-providers/${t}/custom-models`)}async createOrganizationProviderCustomModel(e,t,n){return await this.requestJson(\"POST\",`/v1/organizations/${e}/model-providers/${t}/custom-models`,n)}async deleteOrganizationProviderCustomModel(e,t,n,s){if(!/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu.test(n))throw TypeError(\"customModelId must be a UUID\");return await this.requestJson(\"DELETE\",`/v1/organizations/${e}/model-providers/${t}/custom-models/${encodeURIComponent(n)}`,s)}async getWorkspaceModelAccessPolicy(e){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/model-policy`)}async deleteWorkspaceModelAccessPolicy(e){return await this.requestJson(\"DELETE\",`/v1/workspaces/${e}/model-policy`)}async getOrganizationModelDefaults(e){return await this.requestJson(\"GET\",`/v1/organizations/${e}/model-defaults`)}async updateOrganizationModelDefaults(e,t){return await this.requestJson(\"PATCH\",`/v1/organizations/${e}/model-defaults`,t)}async getOrganizationModelAccountSettings(e){return await this.requestJson(\"GET\",`/v1/organizations/${e}/model-account-settings`)}async updateOrganizationModelAccountSettings(e,t){return await this.requestJson(\"PATCH\",`/v1/organizations/${e}/model-account-settings`,t)}async getModelAccountSettingsOverview(e,t={}){let n=new URLSearchParams;if(t.after!==void 0)n.set(\"after\",t.after);if(t.limit!==void 0)n.set(\"limit\",String(t.limit));return await this.requestJson(\"GET\",`/v1/organizations/${e}/model-account-settings/overview${n.size?`?${n}`:\"\"}`)}async getWorkspaceModelAccountSettings(e){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/model-account-settings`)}async updateWorkspaceModelAccountSettings(e,t){return await this.requestJson(\"PATCH\",`/v1/workspaces/${e}/model-account-settings`,t)}async getSessionModelAccount(e,t){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/sessions/${t}/model-account`)}async setSessionModelAccount(e,t,n){return await this.requestJson(\"PUT\",`/v1/workspaces/${e}/sessions/${t}/model-account`,n)}async getModelAccountPreferences(e){return await this.requestJson(\"GET\",`/v1/organizations/${e}/me/model-account-preferences`)}async updateModelAccountPreferences(e,t){return await this.requestJson(\"PATCH\",`/v1/organizations/${e}/me/model-account-preferences`,t)}async getOrganizationAgentAdminAccess(e){return await this.requestJson(\"GET\",`/v1/organizations/${e}/agent-admin-access`)}async updateOrganizationAgentAdminAccess(e,t){return await this.requestJson(\"PATCH\",`/v1/organizations/${e}/agent-admin-access`,t)}async getOrganizationPrivacySettings(e){return await this.requestJson(\"GET\",`/v1/organizations/${e}/privacy-settings`)}async updateOrganizationPrivacySettings(e,t){return await this.requestJson(\"PATCH\",`/v1/organizations/${e}/privacy-settings`,t)}async updateWorkspaceModelAccessPolicy(e,t){return await this.requestJson(\"PUT\",`/v1/workspaces/${e}/model-policy`,t)}async getWorkspaceRealtimeModelCatalog(e,t={}){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/realtime-model-catalog`,void 0,{},t)}async getAccessContext(){return await this.requestJson(\"GET\",\"/v1/access/me\")}async listOrganizationMemberships(){return await this.requestJson(\"GET\",\"/v1/organization-memberships\")}async listUserResourceAuthorities(e,t){let n=new URLSearchParams({scope:\"user\",resourceKind:t.resourceKind});if(t.cursor)n.set(\"cursor\",t.cursor);if(t.limit!==void 0)n.set(\"limit\",String(t.limit));return await this.requestJson(\"GET\",`/v1/workspaces/${e}/user-resource-authorities?${n.toString()}`)}async revokeUserResourceGrant(e,t){return await this.requestJson(\"DELETE\",`/v1/workspaces/${e}/user-resource-authorities/grants/${t}?scope=user`)}async createOrganization(e){return await this.requestJson(\"POST\",\"/v1/organizations\",e)}async createAdditionalOrganization(e){return await this.requestJson(\"POST\",\"/v1/organizations/additional\",e)}async listOrganizationInvitations(e={}){let t=new URLSearchParams;if(e.cursor)t.set(\"cursor\",e.cursor);if(e.limit!==void 0)t.set(\"limit\",String(e.limit));let n=t.size>0?`?${t.toString()}`:\"\";return await this.requestJson(\"GET\",`/v1/organization-invitations${n}`)}async listOrganizationInvitationsForOrganization(e,t={}){let n=new URLSearchParams;if(t.cursor)n.set(\"cursor\",t.cursor);if(t.limit!==void 0)n.set(\"limit\",String(t.limit));let s=n.size>0?`?${n.toString()}`:\"\";return await this.requestJson(\"GET\",`/v1/organizations/${e}/invitations${s}`)}async createOrganizationInvitation(e,t){return await this.requestJson(\"POST\",`/v1/organizations/${e}/invitations`,t)}async acceptOrganizationInvitation(e,t){return await this.requestJson(\"POST\",`/v1/organization-invitations/${e}/accept`,t)}async revokeOrganizationInvitation(e,t,n){return await this.requestJson(\"POST\",`/v1/organizations/${e}/invitations/${t}/revoke`,n)}async listOrganizationAdministrationMembers(e){return await this.requestJson(\"GET\",`/v1/organizations/${e}/members`)}async listOrganizationMembers(e){return await this.listOrganizationAdministrationMembers(e)}async getOrganizationAdministrationOverview(e){return await this.requestJson(\"GET\",`/v1/organizations/${e}/overview`)}async createOrganizationWorkspace(e,t){return await this.requestJson(\"POST\",`/v1/organizations/${e}/workspaces`,t)}async updateOrganizationWorkspace(e,t,n){return await this.requestJson(\"PATCH\",`/v1/organizations/${e}/workspaces/${t}`,n)}async updateOrganizationWorkspaceSettings(e,t,n){return await this.requestJson(\"PATCH\",`/v1/organizations/${e}/workspaces/${t}/settings`,n)}async deleteOrganizationWorkspace(e,t){await this.requestVoid(\"DELETE\",`/v1/organizations/${e}/workspaces/${t}`)}async putOrganizationWorkspaceMember(e,t,n,s){return await this.requestJson(\"PUT\",`/v1/organizations/${e}/workspaces/${t}/members/${n}`,s)}async revokeOrganizationWorkspaceMember(e,t,n,s){return await this.requestJson(\"POST\",`/v1/organizations/${e}/workspaces/${t}/members/${n}/revoke`,s)}async updateOrganizationName(e,t){return await this.requestJson(\"PATCH\",`/v1/organizations/${e}`,t)}async updateOrganizationMember(e,t,n){return await this.requestJson(\"PATCH\",`/v1/organizations/${e}/members/${t}`,n)}async getOrganizationRetentionPolicy(e){return await this.requestJson(\"GET\",`/v1/organizations/${e}/retention-policy`)}async updateOrganizationRetentionPolicy(e,t){return await this.requestJson(\"PATCH\",`/v1/organizations/${e}/retention-policy`,t)}async getOrganizationRecovery(e){return await this.requestJson(\"GET\",`/v1/organizations/${e}/recovery`)}async configureOrganizationRecoveryPolicy(e,t){return await this.requestJson(\"PUT\",`/v1/organizations/${e}/recovery/policy`,t)}async acceptOrganizationRecoveryCustody(e,t){return await this.requestJson(\"POST\",`/v1/organizations/${e}/recovery/policy/accept`,t)}async disableOrganizationRecoveryPolicy(e,t){return await this.requestJson(\"POST\",`/v1/organizations/${e}/recovery/policy/disable`,t)}async startOrganizationRecoveryOperation(e,t){return await this.requestJson(\"POST\",`/v1/organizations/${e}/recovery/operations`,t)}async approveOrganizationRecoveryOperation(e,t,n){return await this.requestJson(\"POST\",`/v1/organizations/${e}/recovery/operations/${t}/approve`,n)}async cancelOrganizationRecoveryOperation(e,t,n){return await this.requestJson(\"POST\",`/v1/organizations/${e}/recovery/operations/${t}/cancel`,n)}async executeOrganizationRecoveryOperation(e,t,n){return await this.requestJson(\"POST\",`/v1/organizations/${e}/recovery/operations/${t}/execute`,n)}async searchPublicSkills(e,t){return this.requestJson(\"GET\",`/v1/workspaces/${encodeURIComponent(e)}/skills/search?q=${encodeURIComponent(t)}`)}async listWorkspaces(){return await this.requestJson(\"GET\",\"/v1/workspaces\")}connectTransport(){let e=(t)=>`/v1/workspaces/${encodeURIComponent(t)}/connect`;return{catalog:(t,n)=>this.requestJson(\"GET\",`${e(t)}/catalog`,void 0,void 0,n),accounts:(t,n)=>this.requestJson(\"GET\",`${e(t)}/accounts`,void 0,void 0,n),pending:(t,n)=>this.requestJson(\"GET\",`${e(t)}/attempts`,void 0,void 0,n),begin:(t,n,s)=>this.requestJson(\"POST\",`${e(t)}/attempts`,n,void 0,s),get:(t,n,s)=>this.requestJson(\"GET\",`${e(t)}/attempts/${encodeURIComponent(n)}`,void 0,void 0,s),advance:(t,n,s,i)=>this.requestJson(\"POST\",`${e(t)}/attempts/${encodeURIComponent(n)}/advance`,s,void 0,i),cancel:(t,n,s,i)=>this.requestJson(\"POST\",`${e(t)}/attempts/${encodeURIComponent(n)}/cancel`,s,void 0,i),disconnect:async(t,n,s)=>{if(n.startsWith(\"social:\")){let o=n.slice(7);if(!/^[0-9a-f-]{36}$/i.test(o))throw Error(\"Invalid social account ID\");await this.disconnectSocialConnection(t,o);return}if(n.startsWith(\"lens-registration:\")){let o=n.slice(18);if(!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(o))throw Error(\"Invalid Lens registration ID\");await this.requestJson(\"DELETE\",`/v1/workspaces/${encodeURIComponent(t)}/pr-review/registrations/${o}`,void 0,void 0,s);return}if(n.startsWith(\"github-installation:\")){let o=n.slice(20);if(!/^[1-9][0-9]*$/.test(o)||!Number.isSafeInteger(Number(o)))throw Error(\"Invalid GitHub installation ID\");await this.requestJson(\"DELETE\",`/v1/workspaces/${encodeURIComponent(t)}/github/installations/${o}`,void 0,void 0,s);return}let i=s?.expectedVersion;if(i!==void 0&&(!Number.isSafeInteger(i)||i<1))throw Error(\"invalid expected connection version\");let r=i===void 0?\"\":`?expectedVersion=${i}`;await this.requestJson(\"DELETE\",`/v1/workspaces/${encodeURIComponent(t)}/connections/${encodeURIComponent(n)}${r}`,void 0,void 0,s)}}}async browseAtlassianSources(e,t){return this.requestJson(\"GET\",`/v1/workspaces/${e}/connections/atlassian/${t}/browse`)}async saveAtlassianSources(e,t,n){return this.requestJson(\"POST\",`/v1/workspaces/${e}/connections/atlassian/${t}/source`,n)}async setAtlassianLifecycle(e,t,n){return this.requestJson(\"PATCH\",`/v1/workspaces/${e}/connections/atlassian/${t}/lifecycle`,n)}async beginConnect(e,t){return this.requestJson(\"POST\",`/v1/workspaces/${e}/connect/attempts`,t)}async createWorkspace(e){return await this.requestJson(\"POST\",\"/v1/workspaces\",e)}async ensureWorkspace(e){return await this.requestJson(\"PUT\",\"/v1/workspaces/external\",e)}async getWorkspace(e){return await this.requestJson(\"GET\",`/v1/workspaces/${e}`)}async getWorkspaceState(e,t={}){let n=new URLSearchParams;if(t.attemptId)n.set(\"attemptId\",t.attemptId);let s=n.size>0?`?${n.toString()}`:\"\";return await this.requestJson(\"GET\",`/v1/workspaces/${e}/workspace-state${s}`)}async exportWorkspaceState(e,t={}){let n=new URLSearchParams;if(t.attemptId)n.set(\"attemptId\",t.attemptId);let s=n.size>0?`?${n.toString()}`:\"\";return await this.requestJson(\"GET\",`/v1/workspaces/${e}/workspace-state/export${s}`)}async updateWorkspace(e,t){return await this.requestJson(\"PATCH\",`/v1/workspaces/${e}`,t)}async listWorkspaceInstructionPolicies(e,t={}){let n=new URLSearchParams;if(t.kind!==void 0)n.set(\"kind\",t.kind);if(t.scope!==void 0)n.set(\"scope\",t.scope);if(t.roleKey!==void 0)n.set(\"roleKey\",t.roleKey);if(t.afterRevision!==void 0)n.set(\"afterRevision\",String(t.afterRevision));if(t.limit!==void 0)n.set(\"limit\",String(t.limit));let s=n.toString();return await this.requestJson(\"GET\",`/v1/workspaces/${e}/instruction-policies${s?`?${s}`:\"\"}`)}async getWorkspaceLearningHistory(e,t={}){let n=new URLSearchParams;if(t.limit!==void 0)n.set(\"limit\",String(t.limit));let s=n.toString();return await this.requestJson(\"GET\",`/v1/workspaces/${e}/learning${s?`?${s}`:\"\"}`)}async undoGovernedLearningActivation(e,t,n={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/learning/activations/${encodeURIComponent(t)}/undo`,n)}async getWorkspaceInstructionPolicyRevision(e,t){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/instruction-policies/${encodeURIComponent(t)}`)}async createWorkspaceInstructionPolicyDraft(e,t,n={}){return await this.requestSessionCommand(\"POST\",`/v1/workspaces/${e}/instruction-policies/drafts`,t,n)}async listWorkspaceInstructionPolicyOnboardingProposals(e,t={}){let n=new URLSearchParams;if(t.limit!==void 0)n.set(\"limit\",String(t.limit));let s=n.toString();return await this.requestJson(\"GET\",`/v1/workspaces/${e}/instruction-policies/onboarding-proposals${s?`?${s}`:\"\"}`)}async createWorkspaceInstructionPolicyOnboardingProposal(e,t){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/instruction-policies/onboarding-proposals`,t)}async importLegacyWorkspaceInstructionPolicyDraft(e,t={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/instruction-policies/import-legacy`,t)}async diffWorkspaceInstructionPolicyRevisions(e,t){let n=new URLSearchParams({fromRevisionId:t.fromRevisionId,toRevisionId:t.toRevisionId});return await this.requestJson(\"GET\",`/v1/workspaces/${e}/instruction-policies/diff?${n}`)}async activateWorkspaceInstructionPolicyRevision(e,t,n,s={}){return await this.requestSessionCommand(\"POST\",`/v1/workspaces/${e}/instruction-policies/${encodeURIComponent(t)}/activate`,n,s)}async rollbackWorkspaceInstructionPolicyRevision(e,t){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/instruction-policies/rollback`,t)}async listCompanyProfile(e,t={}){let n=new URLSearchParams;if(t.afterRevision!==void 0)n.set(\"afterRevision\",String(t.afterRevision));if(t.limit!==void 0)n.set(\"limit\",String(t.limit));let s=n.toString();return await this.requestJson(\"GET\",`/v1/workspaces/${e}/company-profile${s?`?${s}`:\"\"}`)}async getCompanyProfileRevision(e,t){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/company-profile/revisions/${encodeURIComponent(t)}`)}async getCompanyProfileAgentPolicy(e){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/company-profile/agent-policy`)}async updateCompanyProfileAgentPolicy(e,t){return await this.requestJson(\"PATCH\",`/v1/workspaces/${e}/company-profile/agent-policy`,t)}async updateCompanyProfile(e,t){return await this.requestJson(\"PUT\",`/v1/workspaces/${e}/company-profile`,t)}async diffCompanyProfileRevisions(e,t){let n=new URLSearchParams(t);return await this.requestJson(\"GET\",`/v1/workspaces/${e}/company-profile/diff?${n}`)}async activateCompanyProfileRevision(e,t,n){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/company-profile/revisions/${encodeURIComponent(t)}/activate`,n)}async rollbackCompanyProfile(e,t){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/company-profile/rollback`,t)}async listPreferenceRegistry(e,t={}){let n=new URLSearchParams;if(t.scope)n.set(\"scope\",t.scope);if(t.status)n.set(\"status\",t.status);if(t.limit!==void 0)n.set(\"limit\",String(t.limit));let s=n.toString();return await this.requestJson(\"GET\",`/v1/workspaces/${e}/preferences${s?`?${s}`:\"\"}`)}async getPreferenceRegistry(e,t){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/preferences/${encodeURIComponent(t)}`)}async createPreferenceRegistryProposal(e,t){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/preferences/proposals`,t)}async activatePreferenceRegistryRevision(e,t,n){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/preferences/${encodeURIComponent(t)}/activate`,n)}async correctPreferenceRegistry(e,t,n){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/preferences/${encodeURIComponent(t)}/correct`,n)}async changePreferenceRegistryScope(e,t,n){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/preferences/${encodeURIComponent(t)}/scope`,n)}async deactivatePreferenceRegistry(e,t,n){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/preferences/${encodeURIComponent(t)}/deactivate`,n)}async supersedePreferenceRegistry(e,t,n){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/preferences/${encodeURIComponent(t)}/supersede`,n)}async rejectPreferenceRegistryProposal(e,t,n){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/preferences/${encodeURIComponent(t)}/reject`,n)}async getPreferenceRegistrySummary(e){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/preferences/summary`)}async getPreferenceRegistryFullContent(e,t){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/preferences/full-content`,{retrievalHandle:t})}async deleteWorkspace(e){await this.requestVoid(\"DELETE\",`/v1/workspaces/${e}`)}async listWorkspaceMembers(e){return(await this.requestJson(\"GET\",`/v1/workspaces/${e}/members`)).members}async listWorkspaceMemberCandidates(e){return(await this.requestJson(\"GET\",`/v1/workspaces/${e}/member-candidates`)).members}async addWorkspaceMember(e,t){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/members`,t)}async updateWorkspaceMember(e,t,n){return await this.requestJson(\"PATCH\",`/v1/workspaces/${e}/members/${encodeURIComponent(t)}`,n)}async removeWorkspaceMember(e,t){await this.requestVoid(\"DELETE\",`/v1/workspaces/${e}/members/${encodeURIComponent(t)}`)}async prepareSlackUserLinkAccess(e,t){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/integrations/slack/user-link-intents`,t)}async getSlackUserLinkAccess(e,t){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/integrations/slack/user-link-intents/${t}`)}async requestSlackUserLinkWorkspaceAccess(e,t,n){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/integrations/slack/user-link-intents/${t}/request-access`,n)}async cancelSlackUserLinkAccess(e,t,n){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/integrations/slack/user-link-intents/${t}/cancel`,n)}async listSlackUserLinkAccessRequests(e){return(await this.requestJson(\"GET\",`/v1/workspaces/${e}/members/access-requests/slack`)).requests}async approveSlackUserLinkAccessRequest(e,t,n){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/members/access-requests/slack/${t}/approve`,n)}async denySlackUserLinkAccessRequest(e,t,n){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/members/access-requests/slack/${t}/deny`,n)}async createScheduledTask(e,t){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/scheduled-tasks`,Vn(t))}async updateScheduledTask(e,t,n){return await this.requestJson(\"PATCH\",`/v1/workspaces/${e}/scheduled-tasks/${t}`,Vn(n))}async pauseScheduledTask(e,t){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/scheduled-tasks/${t}/pause`)}async listPrivateScheduledTaskSummaries(e){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/scheduled-tasks/private-summaries`)}async pausePrivateScheduledTask(e,t){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/scheduled-tasks/private-summaries/${t}/pause`)}async resumeScheduledTask(e,t){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/scheduled-tasks/${t}/resume`)}async triggerScheduledTask(e,t,n={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/scheduled-tasks/${t}/trigger`,n.triggerId?{triggerId:n.triggerId}:void 0)}async deleteScheduledTask(e,t){await this.requestJson(\"DELETE\",`/v1/workspaces/${e}/scheduled-tasks/${t}`)}async listScheduledTaskRuns(e,t,n={}){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/scheduled-tasks/${t}/runs`,void 0,{...n.limit!==void 0?{limit:String(n.limit)}:{}})}async refreshScheduledTaskAccess(e,t,n){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/scheduled-tasks/${t}/refresh-access`,n)}async listScheduledTaskAccessAttention(e){return(await this.requestJson(\"GET\",`/v1/workspaces/${e}/scheduled-tasks/attention`)).tasks}vaults(e){return xt(this,e)}async listChannels(e){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/channels`)}async createChannel(e,t){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/channels`,t)}async updateChannel(e,t,n){return await this.requestJson(\"PATCH\",`/v1/workspaces/${e}/channels/${t}`,n)}async reorderChannels(e,t){return await this.requestJson(\"PUT\",`/v1/workspaces/${e}/channels/order`,t)}async deleteChannel(e,t){await this.requestJson(\"DELETE\",`/v1/workspaces/${e}/channels/${t}`)}async updateSessionChannel(e,t,n){return await this.requestJson(\"PUT\",`${g(e,t)}/channel`,n)}async listRigs(e){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/rigs`)}async createRig(e,t){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/rigs`,t)}async getRig(e,t){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/rigs/${t}`)}async updateRig(e,t,n){return await this.requestJson(\"PATCH\",`/v1/workspaces/${e}/rigs/${t}`,n)}async deleteRig(e,t){await this.requestJson(\"DELETE\",`/v1/workspaces/${e}/rigs/${t}`)}async listRigVersions(e,t){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/rigs/${t}/versions`)}async activateRigVersion(e,t,n){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/rigs/${t}/versions/${n}/activate`)}async listRigChanges(e,t){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/rigs/${t}/changes`)}async proposeRigChange(e,t,n){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/rigs/${t}/changes`,n)}async getRigChange(e,t,n){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/rigs/${t}/changes/${n}`)}async verifyRigChange(e,t,n){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/rigs/${t}/changes/${n}/verify`)}async promoteRigChange(e,t,n){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/rigs/${t}/changes/${n}/promote`)}async verifyRig(e,t){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/rigs/${t}/verify`)}async beginFileUpload(e,t,n={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/files/uploads`,t,{},n)}async completeFileUpload(e,t,n={}){return(await this.requestJson(\"POST\",`/v1/workspaces/${e}/files/uploads/${t}/complete`,void 0,{},n)).file}async uploadFile(e,t){if(t.timeoutMs!==void 0&&(!Number.isFinite(t.timeoutMs)||t.timeoutMs<=0))throw Error(\"File upload timeout must be a positive number\");Vi();let n=async(u,l)=>{let p=new AbortController,d,m=new Promise((y,R)=>{d=setTimeout(()=>{p.abort(),R(Error(\"File upload timed out. Retry the upload.\"))},u)});try{return await Promise.race([l(p.signal),m])}finally{if(d!==void 0)clearTimeout(d)}},s=t.data instanceof Uint8Array?new Blob([t.data.slice()]):t.data instanceof ArrayBuffer?t.data.slice(0):t.data,i=typeof s===\"string\"?new TextEncoder().encode(s).byteLength:s instanceof Blob?s.size:s.byteLength,r=t.sha256??await Hi(s),o=await n(30000,async(u)=>await this.beginFileUpload(e,{filename:t.filename,contentType:t.contentType,...t.scope?{scope:t.scope}:{},sizeBytes:i,sha256:r,...t.appShot?{appShot:t.appShot}:{}},{signal:u})),a=t.timeoutMs??Math.max(120000,Math.ceil(i/262144)*1000),c=await n(a,async(u)=>await this.fetchImpl(o.putUrl,{method:\"PUT\",credentials:\"omit\",headers:{...o.requiredHeaders},body:s,signal:u}));if(!c.ok)throw await M(c,{method:\"PUT\"});return await n(30000,async(u)=>await this.completeFileUpload(e,o.uploadId,{signal:u}))}async listFiles(e,t={}){let n=new URLSearchParams;if(t.scope)n.set(\"scope\",t.scope);if(t.limit!==void 0)n.set(\"limit\",String(t.limit));if(t.cursor)n.set(\"cursor\",t.cursor);return this.requestJson(\"GET\",`/v1/workspaces/${e}/files${n.size?`?${n}`:\"\"}`)}async updateFileVisibility(e,t,n,s={}){return await this.requestJson(\"PUT\",`/v1/workspaces/${encodeURIComponent(e)}/files/${encodeURIComponent(t)}/visibility`,n,void 0,s)}async getFile(e,t,n={}){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/files/${t}${n.sessionId?`?sessionId=${encodeURIComponent(n.sessionId)}`:\"\"}`,void 0,{},n)}async getRetainedArtifact(e,t){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/artifacts/${t}`)}async getRetainedArtifactContent(e,t,n={}){return await this.getRetainedArtifactContentAtPath(`/v1/workspaces/${e}/artifacts/${t}/content`,n)}async getSessionRetainedArtifact(e,t,n){return await this.requestJson(\"GET\",`${g(e,t)}/artifacts/${n}`)}async getSessionRetainedArtifactContent(e,t,n,s={}){return await this.getRetainedArtifactContentAtPath(`${g(e,t)}/artifacts/${n}/content`,s)}async downloadRetainedArtifact(e,t,n={}){jn(e,t);let s=await this.downloadRetainedArtifactBytes(t,n);return{artifact:t,bytes:s}}async createRetainedArtifactDownloadUrl(e,t,n={}){jn(e,t);let s=await this.createFileDownloadUrl(e,t.artifactId,n);return Xn(s),s}async downloadRetainedScreenshot(e,t,n,s={}){let i=await this.getSessionRetainedArtifact(e,t,n);if(!i.available)return{metadata:i,bytes:null};if(!((i.kind===\"computer_screenshot\"||i.kind===\"browser_screenshot\")&&[\"image/png\",\"image/jpeg\",\"image/webp\"].includes(i.contentType))||!i.dimensions||i.originalBytes<=0||i.originalBytes>Tn)throw A(\"retained screenshot metadata is invalid\");let o=await this.downloadRetainedArtifactBytes(i,s);return{metadata:i,bytes:o}}async downloadRetainedArtifactBytes(e,t){let n=t.maxRetries??2;if(!Number.isInteger(n)||n<0||n>3)throw RangeError(\"retained artifact maxRetries must be an integer from 0 to 3\");let s=new Uint8Array(e.originalBytes),i=Math.min(e.retrieval.maxRangeBytes,qe);if(!Number.isSafeInteger(i)||i<=0)throw A(\"retained artifact range metadata is invalid\");for(let r=0;r<s.byteLength;r+=i){t.signal?.throwIfAborted();let o=Math.min(r+i,s.byteLength)-1,a=null;for(let u=0;u<=n;u+=1)try{a=await this.getRetainedArtifactContentAtPath(e.retrieval.path,{range:`bytes=${r}-${o}`,...t.signal?{signal:t.signal}:{}});break}catch(l){if(t.signal?.throwIfAborted(),u>=n||l instanceof P&&l.status>=400&&l.status<500)throw l}if(!a)throw A(\"retained artifact range retry exhausted\");let c=o-r+1;if(a.status!==206||a.contentType!==e.contentType||a.contentLength!==c||a.contentRange!==`bytes ${r}-${o}/${e.originalBytes}`)throw A(\"retained artifact range response is invalid\");s.set(a.bytes,r)}if(await Kn(s)!==e.sha256)throw A(\"retained artifact checksum mismatch\");return s}async getRetainedArtifactContentAtPath(e,t){if(t.range&&(t.range.length>128||/[^\\\\x20-\\\\x7e]/.test(t.range)))throw RangeError(\"retained artifact range must be at most 128 printable ASCII bytes\");let n=crypto.randomUUID(),s=await this.fetchImpl(this.url(e),{method:\"GET\",headers:{...this.headers(n),Accept:\"application/octet-stream\",...t.range?{Range:t.range}:{}},...t.signal?{signal:t.signal}:{}});try{D(s,this.apiContractStrict)}catch(o){throw await U(s,\"retained artifact API contract mismatch\"),o}if(!s.ok)throw await M(s,{method:\"GET\",correlationId:n});if(s.status!==200&&s.status!==206)throw await U(s,\"unexpected retained artifact response status\"),new P(s.status,\"unexpected retained artifact response status\");if(s.headers.get(\"accept-ranges\")!==\"bytes\")throw await U(s,\"retained artifact response omitted byte-range support\"),A(\"retained artifact response omitted byte-range support\");let i;try{i=Yi(s.headers.get(\"content-length\"))}catch(o){throw await U(s,\"invalid retained artifact content-length\"),o}let r=await he(s,qe,i);return{bytes:r,status:s.status,contentType:s.headers.get(\"content-type\")??\"application/octet-stream\",contentLength:r.byteLength,contentRange:s.headers.get(\"content-range\"),acceptRanges:\"bytes\"}}async createFileDownloadUrl(e,t,n={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/files/${t}/download-url${n.sessionId?`?sessionId=${encodeURIComponent(n.sessionId)}`:\"\"}`,void 0,{},n)}async getVideoGenerationSettings(e,t={}){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/video-generation`,void 0,{},t)}async updateVideoGenerationPolicy(e,t,n={}){return await this.requestJson(\"PUT\",`/v1/workspaces/${e}/video-generation/policy`,t,{},n)}async getVideoGenerationOperation(e,t,n={}){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/video-generation/operations/${t}`,void 0,{},n)}async createVideoArtifactPlaybackSource(e,t,n={}){let s=await this.requestJson(\"POST\",`/v1/workspaces/${e}/artifacts/${t}/playback-source`,void 0,{},n);return ji(s,t),s}async createDocumentBase(e,t){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/document-bases`,t)}async getDocumentBase(e,t){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/document-bases/${t}`)}async addDocument(e,t,n){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/document-bases/${t}/documents`,n)}async listDocuments(e,t){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/document-bases/${t}/documents`)}async getDocumentOriginalFile(e,t){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/documents/${t}/original-file`)}async createKnowledgeDrop(e,t){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/knowledge/drops`,t)}async moveDocument(e,t,n={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/documents/${t}/move`,n)}async deleteDocument(e,t,n){await this.requestVoid(\"DELETE\",`/v1/workspaces/${e}/document-bases/${t}/documents/${n}`)}async listKnowledgeEntries(e,t={}){return this.requestJson(\"POST\",`/v1/workspaces/${e}/knowledge/entries/search`,t)}async getKnowledgeEntry(e,t,n={}){let s=new URLSearchParams;if(n.revisionId!==void 0)s.set(\"revisionId\",n.revisionId);if(n.view!==void 0)s.set(\"view\",n.view);let i=s.toString();return this.requestJson(\"GET\",`/v1/workspaces/${e}/knowledge/entries/${t}${i?`?${i}`:\"\"}`)}async createKnowledgeFileDownloadUrl(e,t,n){return this.requestJson(\"POST\",`/v1/workspaces/${e}/knowledge/entries/${t}/file/download-url`,n?{revisionId:n}:{})}async saveKnowledgeEntry(e,t){return this.requestJson(\"POST\",`/v1/workspaces/${e}/knowledge/entries`,t)}async reviewKnowledgeEntry(e,t){let{entryId:n,...s}=t;return this.requestJson(\"POST\",`/v1/workspaces/${e}/knowledge/entries/${n}/review`,s)}async listKnowledgeReviewBatches(e,t={}){let n=new URLSearchParams;for(let[s,i]of Object.entries(t))if(i!==void 0)n.set(s,String(i));return this.requestJson(\"GET\",`/v1/workspaces/${e}/knowledge/review-groups?${n}`)}async reviewKnowledgeEntries(e,t){return this.requestJson(\"POST\",`/v1/workspaces/${e}/knowledge/entries/review`,t)}async listKnowledgeEntryHistory(e,t,n){return this.requestJson(\"GET\",`/v1/workspaces/${e}/knowledge/entries/${t}/history${n?`?beforeRevision=${n}`:\"\"}`)}async restoreKnowledgeEntry(e,t){let{entryId:n,...s}=t;return this.requestJson(\"POST\",`/v1/workspaces/${e}/knowledge/entries/${n}/restore`,s)}async archiveKnowledgeEntry(e,t,n){return this.requestJson(\"POST\",`/v1/workspaces/${e}/knowledge/entries/${t}/archive`,n)}async getAgentLearningSettings(e,t,n){return this.requestJson(\"POST\",`/v1/workspaces/${e}/agent-learning/read`,{scope:t,source:n})}async saveAgentLearningSettings(e,t){return this.requestJson(\"POST\",`/v1/workspaces/${e}/agent-learning`,t)}async listAgentLearningOverrides(e,t){return this.requestJson(\"GET\",`/v1/workspaces/${e}/agent-learning/overrides?scope=${t}`)}async reviewAgentInstruction(e,t){return this.requestJson(\"POST\",`/v1/workspaces/${e}/agent-learning/instructions/review`,t)}async listAgentInstructionReviews(e,t){return this.requestJson(\"GET\",`/v1/workspaces/${e}/agent-learning/instructions/reviews${t?`?cursor=${encodeURIComponent(t)}`:\"\"}`)}async updateWorkspaceSettings(e,t){return await this.requestJson(\"PATCH\",`/v1/workspaces/${e}/settings`,t)}async setWorkspaceDefaultRig(e,t){return await this.requestJson(\"PUT\",`/v1/workspaces/${e}/default-rig`,t)}async listCapabilities(e){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/capabilities`)}async createCapability(e,t){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/capabilities`,t)}async getConnectorToolPermissions(e,t,n={}){let s=new URLSearchParams;if(n.connectionId)s.set(\"connectionId\",n.connectionId);if(n.instanceKey)s.set(\"instanceKey\",n.instanceKey);return await this.requestJson(\"GET\",`/v1/workspaces/${e}/capabilities/${encodeURIComponent(t)}/tool-permissions${s.size?`?${s}`:\"\"}`,void 0,{},n)}async updateConnectorToolPermissions(e,t,n,s={}){return await this.requestJson(\"PATCH\",`/v1/workspaces/${e}/capabilities/${encodeURIComponent(t)}/tool-permissions`,n,{},s)}async getSessionMcpToolPermissions(e,t,n={}){let s=new URLSearchParams({serverId:t.serverId,url:t.url});return await this.requestJson(\"GET\",`/v1/workspaces/${e}/session-mcp-tool-permissions?${s}`,void 0,{},n)}async updateSessionMcpToolPermissions(e,t,n={}){return await this.requestJson(\"PATCH\",`/v1/workspaces/${e}/session-mcp-tool-permissions`,t,{},n)}async enableCapability(e,t,n={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/capabilities/${encodeURIComponent(t)}/enable`,n)}async disableCapability(e,t){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/capabilities/${encodeURIComponent(t)}/disable`)}async listArtifactCatalog(e,t={}){let n=new URLSearchParams;for(let i of[\"sourceSessionId\",\"q\",\"kind\",\"sort\",\"status\",\"limit\",\"cursor\"])if(t[i]!==void 0)n.set(i,String(t[i]));let s=n.size?`?${n.toString()}`:\"\";return this.requestJson(\"GET\",`/v1/workspaces/${encodeURIComponent(e)}/artifact-catalog${s}`,void 0,void 0,t)}async updateArtifactPin(e,t,n,s,i={}){return this.requestJson(\"PUT\",`/v1/workspaces/${encodeURIComponent(e)}/artifact-catalog/${encodeURIComponent(t)}/${encodeURIComponent(n)}/pin`,{pinned:s},void 0,i)}async listWorkspaceArtifacts(e,t={}){let n=new URLSearchParams;if(t.limit!==void 0)n.set(\"limit\",String(t.limit));if(t.cursor)n.set(\"cursor\",t.cursor);if(t.status)n.set(\"status\",t.status);if(t.sourceSessionId)n.set(\"sourceSessionId\",t.sourceSessionId);let s=n.size>0?`?${n.toString()}`:\"\";return await this.requestJson(\"GET\",`/v1/workspaces/${encodeURIComponent(e)}/published-artifacts${s}`,void 0,void 0,t)}async getWorkspaceArtifact(e,t,n={}){return await this.requestJson(\"GET\",`/v1/workspaces/${encodeURIComponent(e)}/published-artifacts/${encodeURIComponent(t)}`,void 0,void 0,n)}async getWorkspaceArtifactHtml(e,t,n){return(await this.requestResponse(\"GET\",`/v1/workspaces/${encodeURIComponent(e)}/published-artifacts/${encodeURIComponent(t)}/html`,{versionId:n.versionId},n)).text()}async rollbackWorkspaceArtifact(e,t,n,s={}){return await this.requestJson(\"POST\",`/v1/workspaces/${encodeURIComponent(e)}/published-artifacts/${encodeURIComponent(t)}/rollback`,n,void 0,s)}async duplicateWorkspaceArtifact(e,t,n,s={}){return await this.requestJson(\"POST\",`/v1/workspaces/${encodeURIComponent(e)}/published-artifacts/${encodeURIComponent(t)}/duplicate`,n,void 0,s)}async setWorkspaceArtifactStatus(e,t,n,s={}){return await this.requestJson(\"PATCH\",`/v1/workspaces/${encodeURIComponent(e)}/published-artifacts/${encodeURIComponent(t)}/status`,n,void 0,s)}async updateWorkspaceArtifactVisibility(e,t,n,s={}){return await this.requestJson(\"PUT\",`/v1/workspaces/${encodeURIComponent(e)}/published-artifacts/${encodeURIComponent(t)}/visibility`,n,void 0,s)}async getSiteData(e,t,n={}){return await this.requestJson(\"GET\",`${O(e,t)}/data`,void 0,void 0,n)}async defineSiteDataCollection(e,t,n,s,i={}){return await this.requestJson(\"PUT\",`${O(e,t)}/data/collections/${encodeURIComponent(n)}`,s,void 0,i)}async deleteSiteDataCollection(e,t,n,s={}){return await this.requestJson(\"DELETE\",`${O(e,t)}/data/collections/${encodeURIComponent(n)}`,void 0,{confirm:\"true\"},s)}async resetSiteDataCollection(e,t,n,s={}){return await this.requestJson(\"POST\",`${O(e,t)}/data/collections/${encodeURIComponent(n)}/reset`,{confirm:!0},void 0,s)}async querySiteData(e,t,n,s={}){return await this.requestJson(\"POST\",`${O(e,t)}/data/query`,n,void 0,s)}async writeSiteData(e,t,n,s={}){return await this.requestJson(\"POST\",`${O(e,t)}/data/write`,n,void 0,s)}async importSiteData(e,t,n,s,i={}){return await this.requestJson(\"POST\",`${O(e,t)}/data/collections/${encodeURIComponent(n)}/import`,s,void 0,i)}async exportSiteData(e,t,n,s={}){let i=s.format??\"json\",r=await this.requestResponse(\"GET\",`${O(e,t)}/data/collections/${encodeURIComponent(n)}/export`,{format:i},{...s,accept:i===\"csv\"?\"text/csv\":\"application/json\"});return{content:await r.text(),contentType:r.headers.get(\"content-type\")??\"\",truncated:r.headers.get(\"x-opengeni-export-truncated\")===\"true\"}}async listSiteDataFiles(e,t,n={}){return await this.requestJson(\"GET\",`${O(e,t)}/files`,void 0,{...n.limit===void 0?{}:{limit:String(n.limit)},...n.cursor?{cursor:n.cursor}:{}},n)}async getSiteDataFileUrl(e,t,n,s={}){return await this.requestJson(\"GET\",`${O(e,t)}/files/${encodeURIComponent(n)}`,void 0,void 0,s)}async deleteSiteDataFile(e,t,n,s={}){return await this.requestJson(\"DELETE\",`${O(e,t)}/files/${encodeURIComponent(n)}`,void 0,void 0,s)}async getSiteSql(e,t,n={}){return await this.requestJson(\"GET\",`${O(e,t)}/sql`,void 0,void 0,n)}async updateSiteSqlSettings(e,t,n,s={}){return await this.requestJson(\"PUT\",`${O(e,t)}/sql/settings`,n,void 0,s)}async migrateSiteSql(e,t,n,s={}){return await this.requestJson(\"POST\",`${O(e,t)}/sql/migrations`,n,void 0,s)}async defineSiteSqlQuery(e,t,n,s,i={}){return await this.requestJson(\"PUT\",`${O(e,t)}/sql/queries/${encodeURIComponent(n)}`,s,void 0,i)}async deleteSiteSqlQuery(e,t,n,s={}){return await this.requestJson(\"DELETE\",`${O(e,t)}/sql/queries/${encodeURIComponent(n)}`,void 0,void 0,s)}async runSiteSqlQuery(e,t,n,s={},i={}){return await this.requestJson(\"POST\",`${O(e,t)}/sql/queries/${encodeURIComponent(n)}`,s,void 0,i)}async querySiteSql(e,t,n,s={}){return await this.requestJson(\"POST\",`${O(e,t)}/sql/query`,n,void 0,s)}async executeSiteSql(e,t,n,s={}){return await this.requestJson(\"POST\",`${O(e,t)}/sql/execute`,n,void 0,s)}async inspectSiteSql(e,t,n={}){return await this.requestJson(\"GET\",`${O(e,t)}/sql/inspect`,void 0,void 0,n)}async exportSiteSql(e,t,n={}){let s=n.format??\"sql\",i=await this.requestResponse(\"GET\",`${O(e,t)}/sql/export`,{format:s,...n.table?{table:n.table}:{},...n.cursor?{cursor:n.cursor}:{},...n.maxBytes!==void 0?{maxBytes:String(n.maxBytes)}:{}},{...n,accept:s===\"json\"?\"application/json\":\"*/*\"});return{content:await i.text(),contentType:i.headers.get(\"content-type\")??\"\",truncated:i.headers.get(\"x-opengeni-export-truncated\")===\"true\",nextCursor:i.headers.get(\"x-opengeni-export-next-cursor\")||null}}async importSiteSql(e,t,n,s={}){return await this.requestJson(\"POST\",`${O(e,t)}/sql/import`,n,void 0,s)}async resetSiteSql(e,t,n={},s={}){return await this.requestJson(\"POST\",`${O(e,t)}/sql/reset`,{confirm:!0,...n},void 0,s)}async getSitePublication(e,t,n={}){return await this.requestJson(\"GET\",X(e,t),void 0,void 0,n)}async updateSitePublication(e,t,n,s={}){return await this.requestJson(\"PUT\",X(e,t),n,void 0,s)}async unpublishSite(e,t,n={}){return await this.requestJson(\"DELETE\",X(e,t),void 0,void 0,n)}async applySitePublicationFix(e,t,n,s={}){return await this.requestJson(\"POST\",`${X(e,t)}/fixes`,n,void 0,s)}async getSitePlatformUsage(e,t={}){return await this.requestJson(\"GET\",`/v1/workspaces/${encodeURIComponent(e)}/site-platform-usage`,void 0,void 0,t)}async checkSiteHostname(e,t,n={}){return await this.requestJson(\"GET\",`/v1/workspaces/${encodeURIComponent(e)}/site-hostnames/${encodeURIComponent(t)}`,void 0,void 0,n)}async takeDownSite(e,t,n,s={}){return await this.requestJson(\"POST\",`${X(e,t)}/takedown`,n,void 0,s)}async restoreSite(e,t,n={}){return await this.requestJson(\"POST\",`${X(e,t)}/restore`,{},void 0,n)}async listSiteAbuseReports(e,t,n={}){return await this.requestJson(\"GET\",`${X(e,t)}/reports`,void 0,void 0,n)}async updateSiteAbuseReport(e,t,n,s,i={}){return await this.requestJson(\"PATCH\",`${X(e,t)}/reports/${encodeURIComponent(n)}`,s,void 0,i)}async getSiteLimitProfile(e,t={}){return await this.requestJson(\"GET\",`/v1/workspaces/${encodeURIComponent(e)}/site-limit-profile`,void 0,void 0,t)}async updateSiteLimitProfile(e,t,n={}){return await this.requestJson(\"PUT\",`/v1/workspaces/${encodeURIComponent(e)}/site-limit-profile`,t,void 0,n)}async authorizeSiteViewer(e,t={}){return await this.requestJson(\"POST\",\"/v1/site-auth/authorize\",e,void 0,t)}async discoverMcpCapabilities(e,t={}){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/capabilities/discovery/mcp-registry`,void 0,{...t.query!==void 0?{query:t.query}:{},...t.limit!==void 0?{limit:String(t.limit)}:{}})}async discoverPlugins(e,t={}){return this.requestJson(\"GET\",`/v1/workspaces/${e}/capabilities/discovery/plugins`,void 0,{...t.id?{id:t.id}:{},...t.query?{query:t.query}:{},...t.provider?{provider:t.provider}:{},...t.offset!==void 0?{offset:String(t.offset)}:{}})}async inspectMcpAuthentication(e,t){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/capabilities/discovery/mcp-auth`,{url:t})}async listApiIntegrations(e){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/integrations`)}async listIntegrationDefinitions(e){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/integrations/definitions`)}async previewApiIntegration(e,t){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/integrations/preview`,t)}async startApiIntegrationOAuth(e,t){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/integrations/oauth/start`,t)}async installApiIntegration(e,t){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/integrations/install`,t)}async previewApiIntegrationUninstall(e,t,n){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/integrations/${encodeURIComponent(t)}/instances/${encodeURIComponent(n)}/uninstall-preview`)}async uninstallApiIntegration(e,t,n,s){return await this.requestJson(\"DELETE\",`/v1/workspaces/${e}/integrations/${encodeURIComponent(t)}/instances/${encodeURIComponent(n)}`,s)}async listIntegrationFacets(e,t,n){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/integrations/${encodeURIComponent(t)}/instances/${encodeURIComponent(n)}/facets`)}async configureIntegrationFacet(e,t,n,s,i){return await this.requestJson(\"PUT\",`/v1/workspaces/${e}/integrations/${encodeURIComponent(t)}/instances/${encodeURIComponent(n)}/facets/${encodeURIComponent(s)}`,i)}async browseGoogleDriveFacetSource(e,t,n,s,i={}){let r=new URLSearchParams;if(i.parentId)r.set(\"parentId\",i.parentId);if(i.pageToken)r.set(\"pageToken\",i.pageToken);let o=r.size>0?`?${r}`:\"\";return await this.requestJson(\"GET\",`/v1/workspaces/${e}/integrations/${encodeURIComponent(t)}/instances/${encodeURIComponent(n)}/facets/${encodeURIComponent(s)}/browse${o}`)}async saveGoogleDriveFacetSource(e,t,n,s,i){return await this.requestJson(\"PUT\",`/v1/workspaces/${e}/integrations/${encodeURIComponent(t)}/instances/${encodeURIComponent(n)}/facets/${encodeURIComponent(s)}/source`,i)}async pauseIntegrationFacet(e,t,n,s,i){return await this.mutateIntegrationFacetLifecycle(e,t,n,s,\"pause\",i)}async resumeIntegrationFacet(e,t,n,s,i){return await this.mutateIntegrationFacetLifecycle(e,t,n,s,\"resume\",i)}async removeIntegrationFacet(e,t,n,s,i){return await this.requestJson(\"DELETE\",`/v1/workspaces/${e}/integrations/${encodeURIComponent(t)}/instances/${encodeURIComponent(n)}/facets/${encodeURIComponent(s)}`,i)}async mutateIntegrationFacetLifecycle(e,t,n,s,i,r){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/integrations/${encodeURIComponent(t)}/instances/${encodeURIComponent(n)}/facets/${encodeURIComponent(s)}/${i}`,r)}async previewPlugin(e,t){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/plugins/preview`,t)}async getInstalledPluginDetails(e,t){return this.requestJson(\"GET\",`/v1/workspaces/${e}/plugins/details`,void 0,{pluginKey:t})}async listInstalledPlugins(e){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/plugins`)}async installPlugin(e,t){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/plugins/install`,t)}async previewPluginUninstall(e,t){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/plugins/${encodeURIComponent(t)}/uninstall-preview`)}async uninstallPlugin(e,t,n){return await this.requestJson(\"DELETE\",`/v1/workspaces/${e}/plugins/${encodeURIComponent(t)}`,n)}async previewSkillImport(e,t){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/skills/preview`,t)}async installSkill(e,t){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/skills/install`,t)}async listInstalledSkills(e){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/skills`)}async listWorkspaceSkills(e,t={}){let n=new URLSearchParams;if(t.cursor!==void 0)n.set(\"cursor\",t.cursor);if(t.limit!==void 0)n.set(\"limit\",String(t.limit));if(t.sessionId!==void 0)n.set(\"sessionId\",t.sessionId);let s=n.size?`?${n.toString()}`:\"\";return this.requestJson(\"GET\",`/v1/workspaces/${e}/skills/content${s}`)}async readWorkspaceSkill(e,t,n){let s=n?`?revisionId=${encodeURIComponent(n)}`:\"\";return this.requestJson(\"GET\",`/v1/workspaces/${e}/skills/content/${encodeURIComponent(t)}${s}`)}async saveWorkspaceSkill(e,t){return this.requestJson(\"POST\",`/v1/workspaces/${e}/skills/content/save`,t)}async removeWorkspaceSkill(e,t,n){return this.requestJson(\"POST\",`/v1/workspaces/${e}/skills/content/${encodeURIComponent(t)}/remove`,n)}async approveWorkspaceSkill(e,t,n){return this.requestJson(\"POST\",`/v1/workspaces/${e}/skills/content/${encodeURIComponent(t)}/approve`,n)}async restoreWorkspaceSkill(e,t,n){return this.requestJson(\"POST\",`/v1/workspaces/${e}/skills/content/${encodeURIComponent(t)}/restore`,n)}async rejectWorkspaceSkill(e,t,n){return this.requestJson(\"POST\",`/v1/workspaces/${e}/skills/content/${encodeURIComponent(t)}/reject`,n)}async installLibrarySkill(e,t,n){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/skills/library/${encodeURIComponent(t)}/install`,n)}async previewSkillUninstall(e,t){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/skills/${encodeURIComponent(t)}/uninstall-preview`)}async uninstallSkill(e,t,n){return await this.requestJson(\"DELETE\",`/v1/workspaces/${e}/skills/${encodeURIComponent(t)}`,n)}async listOwnConnectionAccounts(e,t={}){return(await this.requestJson(\"GET\",`/v1/workspaces/${e}/connections/accounts`,void 0,t.includeInactive===!0?{includeInactive:\"true\"}:{})).connections}async listConnections(e){return(await this.requestJson(\"GET\",`/v1/workspaces/${e}/connections`)).connections}async personalGitHubStatus(e){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/connections/github`)}async startPersonalGitHubOAuth(e,t={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/connections/github/oauth/start`,t)}async reconnectPersonalGitHub(e,t,n={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/connections/${t}/github/reconnect`,n)}async disconnectPersonalGitHub(e,t,n){return(await this.requestJson(\"DELETE\",`/v1/workspaces/${e}/connections/${t}`,n)).connection}async listPersonalGitHubRepositories(e,t,n={}){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/connections/${t}/github/repositories`,void 0,{...n.cursor!==void 0?{cursor:String(n.cursor)}:{},...n.limit!==void 0?{limit:String(n.limit)}:{}})}async replacePersonalGitHubRepositorySelections(e,t,n){return await this.requestJson(\"PUT\",`/v1/workspaces/${e}/connections/${t}/github/repositories`,n)}async verifyPersonalGitHubRepositorySelections(e,t,n){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/connections/${t}/github/repositories/verify`,n)}async listSlackInstallationBindings(e){return(await this.requestJson(\"GET\",`/v1/workspaces/${e}/connections/slack-bot/bindings`)).bindings}async createConnection(e,t){return(await this.requestJson(\"POST\",`/v1/workspaces/${e}/connections`,t)).connection}async installFikenConnection(e,t){return(await this.requestJson(\"POST\",`/v1/workspaces/${e}/connections/fiken/install`,t)).connection}async startFikenOAuth(e,t={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/connections/fiken/oauth/start`,t)}async listAvailableOpenGeniSlackBots(e){return this.requestJson(\"GET\",`/v1/workspaces/${e}/connections/slack-bot/available`)}async getOpenGeniSlackBotOrganizationAccess(e,t){return this.requestJson(\"GET\",`/v1/workspaces/${e}/connections/${t}/slack-bot/organization-access`)}async setOpenGeniSlackBotOrganizationAccess(e,t,n){return this.requestJson(\"PUT\",`/v1/workspaces/${e}/connections/${t}/slack-bot/organization-access`,n)}async startOpenGeniSlackBotInstall(e,t={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/connections/slack-bot/install`,t)}async listOpenGeniSlackReactionChannels(e,t,n){let s=new URLSearchParams({connectionId:t});if(n)s.set(\"cursor\",n);return await this.requestJson(\"GET\",`/v1/workspaces/${e}/integrations/slack/reaction-channels?${s}`)}async listOpenGeniSlackChannelRoutes(e,t){let n=new URLSearchParams({connectionId:t});return await this.requestJson(\"GET\",`/v1/workspaces/${e}/integrations/slack/channel-routes?${n}`)}async updateOpenGeniSlackChannelRoutes(e,t){await this.requestJson(\"PUT\",`/v1/workspaces/${e}/integrations/slack/channel-routes`,t)}async updateConnection(e,t,n){return(await this.requestJson(\"PATCH\",`/v1/workspaces/${e}/connections/${t}`,n)).connection}async deleteConnection(e,t){return(await this.requestJson(\"DELETE\",`/v1/workspaces/${e}/connections/${t}`)).connection}async disconnectGoogleDriveConnection(e,t,n){return(await this.requestJson(\"DELETE\",`/v1/workspaces/${e}/connections/${t}`,n)).connection}async transitionGoogleDriveLifecycle(e,t,n){return(await this.requestJson(\"PATCH\",`/v1/workspaces/${e}/connections/google-drive/${t}/lifecycle`,n)).connection}async startConnectionOAuth(e,t,n={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/connections/oauth/start`,t,{},n)}async startSocialOAuth(e,t){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/social/oauth/start`,t)}async listSocialConnections(e){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/social/connections`)}async disconnectSocialConnection(e,t){return await this.requestJson(\"DELETE\",`/v1/workspaces/${e}/social/connections/${t}`)}catalogAssetUrl(e){return e?`${this.baseUrl}/v1/${e}`:null}async downloadCatalogAsset(e,t={}){if(!/^catalog-assets\\\\/[a-zA-Z0-9_./-]+$/.test(e)||e.split(\"/\").some((r)=>!r||r===\".\"||r===\"..\"))throw TypeError(\"A catalog asset path is required\");let n=await this.requestResponse(\"GET\",`/v1/${e}`,{},t),s=n.headers.get(\"content-type\")?.split(\";\")[0]??\"\";if(!s.startsWith(\"image/\"))throw await n.body?.cancel(),Error(\"The catalog asset is not an image\");let i=await he(n,2000000,null);return new Blob([Uint8Array.from(i)],{type:s})}async getGitHubApp(e,t={}){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/github/app`,void 0,t.returnPath?{returnPath:t.returnPath}:void 0)}githubConnectUrl(e,t){return this.url(`/v1/workspaces/${e}/github/connect`,{state:t})}async listGitHubRepositories(e){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/github/repositories`)}async getGitHubActionPolicies(e){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/github/action-policies`)}async updateGitHubActionPolicy(e,t){return await this.requestJson(\"PATCH\",`/v1/workspaces/${e}/github/action-policies`,t)}async syncGitHubRepositories(e){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/github/repositories/sync`)}async unlinkGitHubInstallation(e,t){await this.requestVoid(\"DELETE\",`/v1/workspaces/${e}/github/installations/${t}`)}async createGitHubAppManifest(e,t={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/github/app-manifest`,t)}async listApiKeys(e){return(await this.requestJson(\"GET\",`/v1/workspaces/${e}/api-keys`)).apiKeys}async createApiKey(e,t){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/api-keys`,t)}async deleteApiKey(e,t){return await this.requestJson(\"DELETE\",`/v1/workspaces/${e}/api-keys/${t}`)}async listOrganizationApiKeys(e){return(await this.requestJson(\"GET\",`/v1/organizations/${e}/api-keys`)).apiKeys}async createOrganizationApiKey(e,t){return await this.requestJson(\"POST\",`/v1/organizations/${e}/api-keys`,t)}async deleteOrganizationApiKey(e,t){return await this.requestJson(\"DELETE\",`/v1/organizations/${e}/api-keys/${t}`)}async listOrganizationMcpConnections(e){return await this.requestJson(\"GET\",`/v1/organizations/${e}/mcp-connections`)}async updateOrganizationMcpConnection(e,t,n){return await this.requestJson(\"PATCH\",`/v1/organizations/${e}/mcp-connections/${t}`,n)}async deleteOrganizationMcpConnection(e,t){await this.requestVoid(\"DELETE\",`/v1/organizations/${e}/mcp-connections/${t}`,{})}async listPersonalApiKeys(e){return await this.requestJson(\"GET\",`/v1/organizations/${e}/personal-api-keys`)}async createPersonalApiKey(e,t){return await this.requestJson(\"POST\",`/v1/organizations/${e}/personal-api-keys`,t)}async revokePersonalApiKey(e,t){await this.requestVoid(\"DELETE\",`/v1/organizations/${e}/personal-api-keys/${t}`,{})}async listOrganizationServiceAccounts(e){return await this.requestJson(\"GET\",`/v1/organizations/${e}/service-accounts`)}async getOrganizationServiceAccount(e,t){return await this.requestJson(\"GET\",`/v1/organizations/${e}/service-accounts/${t}`)}async createOrganizationServiceAccount(e,t){return await this.requestJson(\"POST\",`/v1/organizations/${e}/service-accounts`,t)}async updateOrganizationServiceAccount(e,t,n){return await this.requestJson(\"PATCH\",`/v1/organizations/${e}/service-accounts/${t}`,n)}async deleteOrganizationServiceAccount(e,t){await this.requestVoid(\"DELETE\",`/v1/organizations/${e}/service-accounts/${t}`)}async getMcpConnectionRequest(e){return await this.requestJson(\"GET\",`/v1/mcp-connections/requests/${encodeURIComponent(e)}`)}async answerMcpConnectionRequest(e,t){return await this.requestJson(\"POST\",`/v1/mcp-connections/requests/${encodeURIComponent(e)}`,t)}async listInbox(e={}){let t=e.workspaceId?`?workspaceId=${encodeURIComponent(e.workspaceId)}`:\"\";return await this.requestJson(\"GET\",`/v1/inbox${t}`)}async updateInboxItem(e,t){await this.requestJson(\"PATCH\",`/v1/inbox/items/${encodeURIComponent(e)}`,t)}async getInboxSettings(){return await this.requestJson(\"GET\",\"/v1/inbox/settings\")}async updateInboxSettings(e){return await this.requestJson(\"PUT\",\"/v1/inbox/settings\",e)}async getMemberNotifications(e){return await this.requestJson(\"GET\",`/v1/workspaces/${encodeURIComponent(e)}/inbox/member-notifications`)}async updateMemberNotifications(e,t){return await this.requestJson(\"PUT\",`/v1/workspaces/${encodeURIComponent(e)}/inbox/member-notifications`,t)}async getSessionInboxMute(e,t){return await this.requestJson(\"GET\",`${g(e,t)}/inbox-mute`)}async setSessionInboxMute(e,t,n){return await this.requestJson(\"PUT\",`${g(e,t)}/inbox-mute`,n)}async getSessionAdminAccess(e,t){return await this.requestJson(\"GET\",`${g(e,t)}/admin-access`)}async grantSessionAdminAccess(e,t,n={}){return await this.requestJson(\"PUT\",`${g(e,t)}/admin-access`,n)}async revokeSessionAdminAccess(e,t){return await this.requestJson(\"DELETE\",`${g(e,t)}/admin-access`)}async authorizeNativeApp(e){return await this.requestJson(\"POST\",\"/v1/native-app/authorize\",e)}async exchangeNativeAppCode(e){return await this.requestJson(\"POST\",\"/v1/native-app/token\",e)}async createOfficeWorkbookTicket(e){return await this.requestJson(\"POST\",`/v1/workspaces/${encodeURIComponent(e)}/office/workbook-tickets`,{})}async listOfficeWorkbooks(e){let{workbooks:t}=await this.requestJson(\"GET\",`/v1/workspaces/${encodeURIComponent(e)}/office/workbooks`);return t}async signOutNativeApp(){await this.requestJson(\"POST\",\"/v1/native-app/sign-out\",{})}async getNativePushDevice(){let{device:e}=await this.requestJson(\"GET\",\"/v1/native-app/push-device\");return e}async registerNativePushDevice(e){let{device:t}=await this.requestJson(\"PUT\",\"/v1/native-app/push-device\",e);return t}async unregisterNativePushDevice(){await this.requestJson(\"DELETE\",\"/v1/native-app/push-device\")}async listOrganizationSessions(e,t={}){return await this.requestJson(\"GET\",`/v1/organizations/${e}/sessions`,void 0,{...t.limit===void 0?{}:{limit:String(t.limit)},...t.cursor===void 0?{}:{cursor:t.cursor},...t.scopeSubjectId?{scopeSubjectId:t.scopeSubjectId}:{},...t.status===void 0?{}:{status:t.status}},{signal:t.signal})}async*iterateOrganizationSessions(e,t={}){let n;do{let s=await this.listOrganizationSessions(e,{...t,...n===void 0?{}:{cursor:n}});for(let i of s.sessions)yield i;n=s.nextCursor??void 0}while(n!==void 0)}async getBilling(e={}){return await this.requestJson(\"GET\",\"/v1/billing\",void 0,{...e.accountId!==void 0?{accountId:e.accountId}:{}})}async getOrganizationUsageSummary(e,t={}){return await this.requestJson(\"GET\",\"/v1/billing/usage-summary\",void 0,{accountId:e.accountId,period:e.period??\"month\"},t)}async getOrganizationModelUsage(e,t={}){return await this.requestJson(\"GET\",\"/v1/billing/usage-models\",void 0,{accountId:e.accountId,period:e.period??\"month\",...e.afterWorkspaceId?{afterWorkspaceId:e.afterWorkspaceId}:{}},t)}async getOrganizationUsageWorkspacePage(e,t={}){return await this.requestJson(\"GET\",\"/v1/billing/usage-workspaces\",void 0,{accountId:e.accountId,period:e.period??\"month\",until:e.until,...e.afterWorkspaceId?{afterWorkspaceId:e.afterWorkspaceId}:{}},t)}async getBillingUsage(e={}){return await this.requestJson(\"GET\",\"/v1/billing/usage\",void 0,{...e.accountId!==void 0?{accountId:e.accountId}:{},...e.workspaceId!==void 0?{workspaceId:e.workspaceId}:{}})}async getWorkspaceInsights(e,t={}){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/insights`,void 0,{range:t.range??\"week\",...t.provider!==void 0?{provider:t.provider}:{},...t.model!==void 0?{model:t.model}:{},...t.rootSessionId!==void 0?{rootSessionId:t.rootSessionId}:{},...t.sessionId!==void 0?{sessionId:t.sessionId}:{}},{signal:t.signal})}async getWorkspaceInsightsSiteUsage(e,t={},n={}){return this.requestJson(\"GET\",`/v1/workspaces/${encodeURIComponent(e)}/insights/sites`,void 0,{range:t.range??\"month\"},n)}async getWorkspaceInsightsUsage(e,t={},n={}){return await this.requestJson(\"GET\",`/v1/workspaces/${encodeURIComponent(e)}/insights/usage${Pe(t)}`,void 0,{},n)}async getOrganizationInsightsUsage(e,t={},n={}){return await this.requestJson(\"GET\",`/v1/organizations/${encodeURIComponent(e)}/insights/usage${Pe(t)}`,void 0,{},n)}async listInsightsCalls(e,t={},n={}){let s=e.kind===\"workspace\"?`/v1/workspaces/${encodeURIComponent(e.workspaceId)}/insights/calls`:`/v1/organizations/${encodeURIComponent(e.accountId)}/insights/calls`;return await this.requestJson(\"GET\",`${s}${Pe(t)}`,void 0,{},n)}async getBillingEntitlements(e={}){return await this.requestJson(\"GET\",\"/v1/billing/entitlements\",void 0,{...e.accountId!==void 0?{accountId:e.accountId}:{}})}async createBillingCheckout(e){return await this.requestJson(\"POST\",\"/v1/billing/checkout\",e)}async getBillingCheckout(e,t={}){return await this.requestJson(\"GET\",`/v1/billing/checkout/${encodeURIComponent(e)}`,void 0,{...t.accountId!==void 0?{accountId:t.accountId}:{}})}async createBillingPortalSession(e={}){return await this.requestJson(\"POST\",\"/v1/billing/portal\",e)}async getBillingSubscriptionPlans(e={}){return await this.requestJson(\"GET\",\"/v1/billing/subscription/plans\",void 0,e)}async createSubscriptionCheckout(e){return await this.requestJson(\"POST\",\"/v1/billing/subscription/checkout\",e)}async upgradeBillingSubscription(e){return await this.requestJson(\"POST\",\"/v1/billing/subscription/upgrade\",e)}async changeBillingSubscription(e){return await this.requestJson(\"POST\",\"/v1/billing/subscription/change\",e)}async cancelBillingSubscription(e){return await this.requestJson(\"POST\",\"/v1/billing/subscription/cancel\",e)}async createSubscriptionPortalSession(e={}){return await this.requestJson(\"POST\",\"/v1/billing/subscription/portal\",e)}apiUrl(e){if(!e.startsWith(\"/\"))throw TypeError(\"API path must start with /\");return`${this.baseUrl}${e}`}withHeaders(e){let t={...e},n=this.options.headers,i=new this.constructor({...this.options,headers:()=>({...typeof n===\"function\"?n():n,...t})});if(this.externalActorHeader!==void 0)i.externalActorHeader=this.externalActorHeader;return i.serviceInitiatorHeader=this.serviceInitiatorHeader,i.serviceContextHeader=this.serviceContextHeader,i}async fetchApi(e,t={}){let n=typeof globalThis.location?.href===\"string\"?globalThis.location.href:void 0,s=new URL(this.baseUrl.endsWith(\"/\")?this.baseUrl:`${this.baseUrl}/`,n),i=new URL(e,s);if(i.origin!==s.origin||!`${i.pathname}/`.startsWith(s.pathname))throw TypeError(\"fetchApi only reaches this client\\'s API base URL\");let r=new Headers(t.headers);for(let[o,a]of Object.entries(this.headers()))if(!r.has(o))r.set(o,a);return await this.fetchImpl(i.href,{...t,headers:r})}headers(e){let t=typeof this.options.headers===\"function\"?this.options.headers():this.options.headers,n={...this.options.apiKey?{Authorization:`Bearer ${this.options.apiKey}`}:{},...t,[Ze]:oe,...e?{[Oe]:e}:{}},s=Object.keys(n).map((o)=>o.toLowerCase()),i=this.externalActorHeader!==void 0||s.includes(\"x-opengeni-external-actor\"),r=this.serviceInitiatorHeader!==void 0||s.includes(\"x-opengeni-service-initiator\")||s.includes(\"x-opengeni-service-context\");if(i&&r)throw Error(\"asUser and asService attribution headers are mutually exclusive\");if(this.externalActorHeader){for(let o of Object.keys(n))if(o.toLowerCase()===\"x-opengeni-external-actor\")delete n[o];n[\"x-opengeni-external-actor\"]=this.externalActorHeader}if(this.serviceInitiatorHeader!==void 0){for(let o of Object.keys(n)){let a=o.toLowerCase();if(a===\"x-opengeni-service-initiator\"||a===\"x-opengeni-service-context\")delete n[o]}if(n[\"x-opengeni-service-initiator\"]=this.serviceInitiatorHeader,this.serviceContextHeader!==void 0)n[\"x-opengeni-service-context\"]=this.serviceContextHeader}return n}url(e,t={}){let n=new URLSearchParams(t).toString();return`${this.baseUrl}${e}${n?`?${n}`:\"\"}`}async codexStatus(e){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/codex/status`)}async codexConnectStart(e){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/codex/connect/start`,{})}async codexConnectPoll(e,t){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/codex/connect/poll`,{state:t})}async codexUsage(e){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/codex/usage`)}async codexAccountUsage(e,t){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/codex/accounts/${t}/usage`)}async organizationCodexAccountUsage(e,t){return await this.requestJson(\"GET\",`/v1/organizations/${e}/codex/accounts/${encodeURIComponent(t)}/usage`)}async refreshCodexUsage(e){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/codex/usage/refresh`)}async codexOverview(e){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/codex/overview`)}async codexDisconnect(e){return await this.requestJson(\"DELETE\",`/v1/workspaces/${e}/codex`)}async listCodexAccounts(e){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/codex/accounts`)}async listSessionCodexAccounts(e,t){return await this.requestJson(\"GET\",`${g(e,t)}/codex-accounts`)}async activateCodexAccount(e,t){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/codex/accounts/${t}/activate`)}async designateCodexAppsAccount(e,t,n){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/codex/apps`,{accountId:t,expectedVersion:n})}async clearCodexAppsAccount(e,t){return await this.requestJson(\"DELETE\",`/v1/workspaces/${e}/codex/apps`,{expectedVersion:t})}async setCodexRotationSettings(e,t){return await this.requestJson(\"PATCH\",`/v1/workspaces/${e}/codex/settings`,t)}async setCodexAccountAllocator(e,t,n){return await this.requestJson(\"PATCH\",`/v1/workspaces/${e}/codex/accounts/${t}/allocator`,n)}async disconnectCodexAccount(e,t){return await this.requestJson(\"DELETE\",`/v1/workspaces/${e}/codex/accounts/${t}`)}async renameCodexAccount(e,t,n){return await this.requestJson(\"PATCH\",`/v1/workspaces/${e}/codex/accounts/${t}`,{label:n})}async pinSessionCodexAccount(e,t,n){return await this.requestJson(\"POST\",`${g(e,t)}/codex-account`,{target:n})}async getModelConnectionAccess(e){return await this.requestJson(\"GET\",`/v1/${e.scope}/${encodeURIComponent(e.scopeId)}/model-connections/${e.kind}/${encodeURIComponent(e.connectionId)}/access`)}async updateModelConnectionAccess(e,t){return await this.requestJson(\"PUT\",`/v1/${e.scope}/${encodeURIComponent(e.scopeId)}/model-connections/${e.kind}/${encodeURIComponent(e.connectionId)}/access`,t)}async listOrganizationSuperGrokAccounts(e){return await this.requestJson(\"GET\",`/v1/organizations/${e}/supergrok/accounts`)}async organizationSupergrokConnectStart(e){return await this.requestJson(\"POST\",`/v1/organizations/${e}/supergrok/connect/start`,{})}async organizationSupergrokConnectPoll(e,t){return await this.requestJson(\"POST\",`/v1/organizations/${e}/supergrok/connect/poll`,{state:t})}async activateOrganizationSuperGrokAccount(e,t){return await this.requestJson(\"POST\",`/v1/organizations/${e}/supergrok/accounts/${t}/activate`,{})}async setOrganizationSuperGrokRotationSettings(e,t){return await this.requestJson(\"PATCH\",`/v1/organizations/${e}/supergrok/settings`,t)}async setOrganizationSuperGrokAccountAllocator(e,t,n){return await this.requestJson(\"PATCH\",`/v1/organizations/${e}/supergrok/accounts/${t}/allocator`,n)}async renameOrganizationSuperGrokAccount(e,t,n){return await this.requestJson(\"PATCH\",`/v1/organizations/${e}/supergrok/accounts/${t}`,{label:n})}async disconnectOrganizationSuperGrokAccount(e,t){return await this.requestJson(\"DELETE\",`/v1/organizations/${e}/supergrok/accounts/${t}`,{})}async supergrokStatus(e){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/supergrok/status`)}async supergrokConnectStart(e,t=\"workspace\"){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/supergrok/connect/start`,{scope:t})}async supergrokConnectPoll(e,t){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/supergrok/connect/poll`,{state:t})}async listSuperGrokAccounts(e){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/supergrok/accounts`)}async activateSuperGrokAccount(e,t){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/supergrok/accounts/${t}/activate`,{})}async setSuperGrokRotationSettings(e,t){return await this.requestJson(\"PATCH\",`/v1/workspaces/${e}/supergrok/settings`,t)}async setSuperGrokAccountAllocator(e,t,n){return await this.requestJson(\"PATCH\",`/v1/workspaces/${e}/supergrok/accounts/${t}/allocator`,n)}async renameSuperGrokAccount(e,t,n){return await this.requestJson(\"PATCH\",`/v1/workspaces/${e}/supergrok/accounts/${t}`,{label:n})}async disconnectSuperGrokAccount(e,t){return await this.requestJson(\"DELETE\",`/v1/workspaces/${e}/supergrok/accounts/${t}`,{})}async requestSessionCommand(e,t,n,s={}){return await this.requestJson(e,t,n,{},{signal:s.signal,timeoutMs:s.timeoutMs??this.sessionCommandTimeoutMs})}async requestJson(e,t,n,s={},i={}){let r=crypto.randomUUID(),o=Ni(i);try{let a=Dt(e)?this.readRetryPolicy:null;if(!a)return await this.requestJsonAttempt(e,t,n,s,i,o.signal,r,null);let c=Date.now();for(let u=1;;u+=1){let l={transportFailure:!1,gatewayFailure:!1,retryAfterMs:null};try{return await this.requestJsonAttempt(e,t,n,s,i,o.signal,r,l)}catch(p){let d=l.transportFailure||l.gatewayFailure&&Lt(p);if(o.signal?.aborted||!d)throw p;let m=zt(a,u,Date.now()-c,l.retryAfterMs);if(m===null)throw p;await Nt(m,o.signal)}}}finally{o.dispose()}}async requestJsonAttempt(e,t,n,s,i,r,o,a){if(r?.aborted)throw r.reason??new DOMException(\"Request aborted\",\"AbortError\");let c=this.headers(o),u;try{u=await ae(this.fetchImpl(this.url(t,s),{method:e,headers:{...c,Accept:\"application/json\",...n!==void 0?{\"Content-Type\":\"application/json\"}:{}},...n!==void 0?{body:JSON.stringify(n)}:{},...r?{signal:r}:{}}),r)}catch(l){if(i.signal?.aborted)throw l;if(ue(e))throw ce(o);if(l instanceof TypeError&&a)a.transportFailure=!0;throw Ye(l),l}D(u,this.apiContractStrict);try{if(!u.ok){if(a&&je(u.status))a.gatewayFailure=!0,a.retryAfterMs=Wt(u.headers.get(\"retry-after\"));throw await ae(M(u,{method:e,correlationId:o}),r)}if(i.responseType===\"void\"){await ae(U(u,\"discarding void API response\"),r);return}await ae(fe(u,{method:e,correlationId:o}),r);let l=await ae(u.json(),r);return At(l,u.headers.get(It)),l}catch(l){if(i.signal?.aborted)throw l;if(l instanceof P)throw l;if(ue(e))throw ce(o);if(l instanceof TypeError&&a)a.transportFailure=!0;throw Ye(l),l}}async requestResponse(e,t,n={},s={}){let i=crypto.randomUUID(),r=this.headers(i),o;try{o=await this.fetchImpl(this.url(t,n),{method:e,headers:{...r,Accept:s.accept??\"application/octet-stream\"},...s.signal?{signal:s.signal}:{}})}catch(a){if(ue(e))throw ce(i);throw a}if(D(o,this.apiContractStrict),!o.ok)throw await M(o,{method:e,correlationId:i});return o}async requestVoid(e,t,n){let s=crypto.randomUUID(),i=this.headers(s),r;try{r=await this.fetchImpl(this.url(t),{method:e,headers:{...i,Accept:\"application/json\",...n!==void 0?{\"Content-Type\":\"application/json\"}:{}},...n!==void 0?{body:JSON.stringify(n)}:{}})}catch(o){if(ue(e))throw ce(s);throw o}if(D(r,this.apiContractStrict),!r.ok)throw await M(r,{method:e,correlationId:s})}}function D(e,t){if(!t)return;let n=e.headers.get(Ze);if(n&&n!==oe)throw new ve(oe,n)}function Bi(e){if(!e||typeof e!==\"object\"||Array.isArray(e))return!1;let t=e;return typeof t.text===\"string\"&&Array.isArray(t.languages)&&t.languages.every((n)=>typeof n===\"string\")}function Li(e){if(!e||typeof e!==\"object\"||Array.isArray(e))return!1;let t=e;if(!it({recording:t.recording,segments:[]}))return!1;if(!t.chunk||typeof t.chunk!==\"object\"||Array.isArray(t.chunk))return!1;let n=t.chunk;return typeof n.chunkNumber===\"number\"&&typeof n.byteLength===\"number\"&&typeof n.sha256===\"string\"&&typeof n.startMilliseconds===\"number\"&&typeof n.durationMilliseconds===\"number\"&&typeof n.deduplicated===\"boolean\"}function it(e){if(!e||typeof e!==\"object\"||Array.isArray(e))return!1;let t=e;if(!t.recording||typeof t.recording!==\"object\"||Array.isArray(t.recording))return!1;let n=t.recording;return typeof n.id===\"string\"&&typeof n.workspaceId===\"string\"&&typeof n.mimeType===\"string\"&&typeof n.state===\"string\"&&typeof n.nextChunkNumber===\"number\"&&typeof n.chunkCount===\"number\"&&typeof n.totalBytes===\"number\"&&typeof n.totalDurationMilliseconds===\"number\"&&typeof n.segmentCount===\"number\"&&typeof n.completedSegmentCount===\"number\"&&(n.transcriptText===null||typeof n.transcriptText===\"string\")&&Array.isArray(n.languages)&&(n.errorCode===null||typeof n.errorCode===\"string\")&&typeof n.retryable===\"boolean\"&&typeof n.objectsCleaned===\"boolean\"&&typeof n.createdAt===\"string\"&&typeof n.updatedAt===\"string\"&&typeof n.expiresAt===\"string\"&&(t.retryAfterMilliseconds===void 0||typeof t.retryAfterMilliseconds===\"number\"&&Number.isInteger(t.retryAfterMilliseconds)&&t.retryAfterMilliseconds>0&&t.retryAfterMilliseconds<=60000)&&Array.isArray(t.segments)}function ye(e){if(it(e))return e;throw A(\"Invalid transcription recording response.\",{code:\"invalid_response\"})}function Wi(e){if(!e||typeof e!==\"object\"||Array.isArray(e))return!1;let t=e.recordings;return Array.isArray(t)&&t.length<=50&&t.every((n)=>it({recording:n,segments:[]}))}function zi(e){switch(e.trim().toLowerCase().split(\";\")[0]??\"audio/webm\"){case\"audio/mp4\":case\"audio/m4a\":return\"audio.mp4\";case\"audio/ogg\":return\"audio.ogg\";case\"audio/mpeg\":case\"audio/mp3\":return\"audio.mp3\";case\"audio/wav\":case\"audio/x-wav\":return\"audio.wav\";case\"audio/webm\":default:return\"audio.webm\"}}var Hn=16384;function Ni(e){let t=e.timeoutMs??0;if(t<=0)return{signal:e.signal,dispose:()=>{return}};let n=new AbortController,s=()=>n.abort(e.signal?.reason);if(e.signal?.aborted)s();else e.signal?.addEventListener(\"abort\",s,{once:!0});let i=setTimeout(()=>n.abort(new DOMException(\"Request timed out\",\"TimeoutError\")),t);return{signal:n.signal,dispose:()=>{clearTimeout(i),e.signal?.removeEventListener(\"abort\",s)}}}async function ae(e,t){if(!t)return await e;if(t.aborted)throw t.reason??new DOMException(\"Request aborted\",\"AbortError\");return await new Promise((n,s)=>{let i=()=>{r(),s(t.reason??new DOMException(\"Request aborted\",\"AbortError\"))},r=()=>t.removeEventListener(\"abort\",i);t.addEventListener(\"abort\",i,{once:!0}),e.then((o)=>{r(),n(o)},(o)=>{r(),s(o)})})}function Fi(e,t){if(e===void 0||e===null)return;if(t.usageLimit?.limitMicros===e)return;throw new pe(`The session ${t.id} was created, but the server did not confirm its usage limit; it may not support usage limits. Set the limit with setSessionUsageLimit before sending work, or treat the task as unlimited.`,{sessionId:t.id})}async function M(e,t){let n=await Ji(e),i=new((Ve(n))?Ne:(Je(n))?Fe:P)(e.status,n,{correlationId:e.headers.get(Oe)??t.correlationId,mutation:ue(t.method)});return i.status>=400&&i.status<500&&(i.code===\"SESSION_TENANCY_NOT_ACTIVATED\"||i.code===\"OPENGENI_SETUP_REQUIRED\")?new ze(i):i}async function fe(e,t){if(Yn(e.headers.get(\"content-type\")))return;throw await U(e,\"unexpected non-JSON API response\"),A(\"\",{code:\"upstream_unavailable\",retryable:!0,correlationId:e.headers.get(Oe)??t.correlationId,outcomeUnknown:ue(t.method),displayMessage:\"The workspace is temporarily unavailable — retry.\"})}async function Ji(e){if(!Yn(e.headers.get(\"content-type\")))return await U(e,\"discarding API error body\"),\"\";if(Number(e.headers.get(\"content-length\"))>Hn)return await U(e,\"discarding API error body\"),\"\";try{return new TextDecoder().decode(await he(e,Hn,null))}catch{return\"\"}}function Yn(e){return/^(application\\\\/json|[^;]+\\\\+json)\\\\s*(;|$)/i.test(e??\"\")}function ue(e){return e!==\"GET\"&&e!==\"HEAD\"&&e!==\"OPTIONS\"}function ce(e){return new P(0,\"\",{code:\"network_error\",retryable:!0,correlationId:e,outcomeUnknown:!0,mutation:!0,displayMessage:\"The request could not be confirmed — reconcile before retrying.\"})}function Vi(){let e=typeof window<\"u\"?window.isSecureContext:typeof globalThis.isSecureContext===\"boolean\"?globalThis.isSecureContext:void 0;if(e===void 0)return;if(!e)throw new we(\"insecure_context\");if(typeof globalThis.crypto>\"u\"||typeof globalThis.crypto.subtle?.digest!==\"function\")throw new we(\"web_crypto_unavailable\")}async function Hi(e){let t=typeof e===\"string\"?new TextEncoder().encode(e):e instanceof Blob?new Uint8Array(await e.arrayBuffer()):new Uint8Array(e),n=await globalThis.crypto.subtle.digest(\"SHA-256\",t);return[...new Uint8Array(n)].map((s)=>s.toString(16).padStart(2,\"0\")).join(\"\")}async function Kn(e){let t=Uint8Array.from(e),n=await globalThis.crypto.subtle.digest(\"SHA-256\",t.buffer);return[...new Uint8Array(n)].map((s)=>s.toString(16).padStart(2,\"0\")).join(\"\")}function Ki(e,t){if(e.computerSessionId!==t.computerSessionId)return\"frame_session_mismatch\";if(e.targetId!==t.targetId)return\"frame_target_mismatch\";if(e.mediaType!==t.mediaType)return\"frame_media_mismatch\";if(e.sha256!==t.sha256)return\"frame_digest_mismatch\";return null}async function U(e,t){await e.body?.cancel(t).catch(()=>{return})}function jn(e,t){if(!Mn(t,e)&&!Gn(t,e))throw A(\"retained workspace artifact receipt is invalid\")}function Xn(e){if(!e||typeof e.url!==\"string\"||typeof e.expiresAt!==\"string\"||!Number.isFinite(Date.parse(e.expiresAt)))throw A(\"retained artifact download URL is invalid\");let t;try{t=new URL(e.url)}catch{throw A(\"retained artifact download URL is invalid\")}if(![\"http:\",\"https:\"].includes(t.protocol)||t.username||t.password)throw A(\"retained artifact download URL is unsafe\")}function ji(e,t){if(!e||e.schemaVersion!==1||e.artifactId!==t||e.contentType!==\"video/mp4\"||e.acceptRanges!==\"bytes\"||!Number.isSafeInteger(e.sizeBytes)||e.sizeBytes<=0||e.sizeBytes>On||!/^[0-9a-f]{64}$/.test(e.sha256))throw A(\"generated-video playback source is invalid\");Xn({url:e.url,expiresAt:e.expiresAt})}function Yi(e){if(e===null)return null;if(!/^\\\\d+$/.test(e))throw A(\"invalid retained artifact content-length\");let t=Number(e);if(!Number.isSafeInteger(t)||t>qe)throw A(\"retained artifact response exceeds the SDK byte limit\");return t}async function he(e,t,n){if(!e.body){if(n!==null&&n!==0)throw A(\"retained artifact response length mismatch\");return new Uint8Array}let s=e.body.getReader(),i=[],r=0;try{while(!0){let{done:c,value:u}=await s.read();if(c)break;if(r+=u.byteLength,r>t)throw await s.cancel(\"retained artifact response exceeded the SDK byte limit\").catch(()=>{return}),A(\"retained artifact response exceeds the SDK byte limit\");i.push(u)}}finally{s.releaseLock()}if(n!==null&&r!==n)throw A(\"retained artifact response length mismatch\");let o=new Uint8Array(r),a=0;for(let c of i)o.set(c,a),a+=c.byteLength;return o}function O(e,t){return`/v1/workspaces/${encodeURIComponent(e)}/published-artifacts/${encodeURIComponent(t)}`}function X(e,t){return`${O(e,t)}/publication`}class Re extends Error{code;status;details;constructor(e,t,n,s={}){super(t);this.code=e;this.status=n;this.details=s;this.name=\"OpenGeniSiteDataError\"}}var rt=\"/v1/workspaces/site-host/published-artifacts/current\";function Qn(e,t){let n=async(u,l={})=>{if(!await t())throw new Re(\"site_data_unsupported\",\"This Site host does not provide Site Data\",0);let p=await e(`${rt}${u}`,l),d=await p.text(),m=null;try{m=d?JSON.parse(d):null}catch{m=null}if(p.ok)return m;throw Qi(p.status,m)},s=(u)=>({method:\"POST\",headers:{\"content-type\":\"application/json\"},body:JSON.stringify(u)}),i=async(u)=>(await n(\"/data/write\",s({operations:u}))).results,r=async(u)=>{let[l]=await i([u]);if(!l||!(\"record\"in l))throw new Re(\"request_failed\",\"Unexpected Site Data response\",200);return l.record},o=async(u,l,p)=>(await n(\"/data/query\",s({collection:u,limit:1,count:!0,...l?{where:l}:{},...p?{scope:p}:{}}))).count??0;return{data:{collection(u){return{name:u,list:async(p={})=>await n(\"/data/query\",s({collection:u,...p})),get:async(p)=>{try{return(await n(\"/data/get\",s({collection:u,...Ue(p)}))).record}catch(d){if(d instanceof Re&&d.code===\"not_found\")return null;throw d}},insert:async(p,d={})=>await r({op:\"insert\",collection:u,data:p,...d.key===void 0?{}:{key:d.key}}),put:async(p,d,m={})=>await r({op:\"put\",collection:u,key:p,data:d,...m}),patch:async(p,d,m={})=>await r({op:\"patch\",collection:u,...Ue(p),data:d,...m}),delete:async(p,d={})=>{await i([{op:\"delete\",collection:u,...Ue(p),...d}])},increment:async(p,d,m)=>await r({op:\"increment\",collection:u,...Ue(p),field:d,...m===void 0?{}:{by:m}}),count:async(p,d={})=>await o(u,p,d.scope)}},batch:i,count:async(u,l)=>await o(u,l)},files:{upload:async(u,l={})=>{let p=u instanceof Blob?u:new Blob([u instanceof Uint8Array?u.slice():u],{type:l.contentType??\"application/octet-stream\"}),d=l.name??(typeof File<\"u\"&&u instanceof File?u.name:\"file\"),m=new URLSearchParams({name:d,scope:l.scope??\"shared\"});return await n(`/files?${m}`,{method:\"POST\",headers:{\"content-type\":l.contentType??(p.type||\"application/octet-stream\")},body:await p.arrayBuffer()})},list:async(u={})=>{let l=new URLSearchParams;if(u.limit!==void 0)l.set(\"limit\",String(u.limit));if(u.cursor)l.set(\"cursor\",u.cursor);let p=l.size?`?${l}`:\"\";return await n(`/files${p}`,{method:\"GET\"})},url:async(u)=>await n(`/files/${encodeURIComponent(u)}`,{method:\"GET\"}),delete:async(u)=>{await n(`/files/${encodeURIComponent(u)}`,{method:\"DELETE\"})}}}}function Ue(e){if(typeof e===\"string\")return{key:e};if(\"id\"in e)return{id:e.id};return{key:e.key}}var Xi=new Set([\"validation\",\"conflict\",\"not_found\",\"forbidden\",\"not_available_for_viewer\",\"quota_exceeded\",\"rate_limited\"]);function Qi(e,t){let n=typeof t===\"object\"&&t!==null&&\"error\"in t?t.error:null,s=typeof n===\"object\"&&n!==null?n:{},i=typeof s.details===\"object\"&&s.details!==null?s.details:{},r=i.code,o=r&&Xi.has(r)?r:e===404?\"not_found\":e===403?\"forbidden\":e===413?\"quota_exceeded\":e===429?\"rate_limited\":\"request_failed\",a=typeof s.message===\"string\"&&s.message?s.message:`Site Data request failed with HTTP ${e}`;return new Re(o,a,e,i)}class be extends Error{code;status;details;constructor(e,t,n,s={}){super(t);this.code=e;this.status=n;this.details=s;this.name=\"OpenGeniSiteSqlError\"}}var Zi=/^[A-Za-z][A-Za-z0-9_-]{0,63}$/u,er=new Set([\"validation\",\"not_found\",\"forbidden\",\"not_available_for_viewer\",\"conflict\",\"quota_exceeded\",\"rate_limited\",\"sql_error\",\"unavailable\",\"disabled\"]);function Zn(e,t){return{async run(n,s={}){if(!Zi.test(n))throw new be(\"validation\",\"Invalid query name\",0);if(Object.keys(s).some((a)=>a===\"viewer\"||a.startsWith(\"viewer_\")))throw new be(\"validation\",\"viewer parameters are bound by the host, not the Site\",0);if(!await t())throw new be(\"site_sql_unsupported\",\"This Site host does not provide Site SQL\",0);let i=await e(`${rt}/sql/queries/${encodeURIComponent(n)}`,{method:\"POST\",headers:{\"content-type\":\"application/json\"},body:JSON.stringify({params:s})}),r=await i.text(),o=null;try{o=r?JSON.parse(r):null}catch{o=null}if(i.ok)return o;throw tr(i.status,o)}}}function tr(e,t){let n=typeof t===\"object\"&&t!==null&&\"error\"in t?t.error:null,s=typeof n===\"object\"&&n!==null?n:{},i=typeof s.details===\"object\"&&s.details!==null?s.details:{},r=typeof i.code===\"string\"?i.code:void 0,o=r&&er.has(r)?r:e===404?\"not_found\":e===403?\"forbidden\":e===413?\"quota_exceeded\":e===429?\"rate_limited\":\"request_failed\",a=typeof s.message===\"string\"&&s.message?s.message:`Site SQL request failed with HTTP ${e}`;return new be(o,a,e,i)}var es=\"The model returned no final reply after a reply reminder. Completed work is preserved; the goal and later updates are unaffected.\";function ts(e){return e!==null&&typeof e===\"object\"&&!Array.isArray(e)&&e.emptyFinalReply===!0}class ot extends Error{code;event;constructor(e,t,n=null){super(t);this.name=\"OpenGeniChatError\",this.code=e,this.event=n}}function z(){return{chunks:[],terminal:null}}class $e{workspaceId;sessionId;events=[];turnId;pending=null;failure=null;emptyFinalReply=!1;segments=[];openTools=new Map;constructor(e,t,n){this.workspaceId=e;this.sessionId=t;this.turnId=n}get text(){return this.segments.filter((e)=>!e.commentary).map((e)=>e.text).filter((e)=>e.length>0).join(`\\n\\n`)}push(e){let t=typeof e.turnId===\"string\"?e.turnId:null;if(this.turnId&&t&&t!==this.turnId)return{chunks:[],terminal:null};if(!this.turnId&&t&&nr(e.type))this.turnId=t;this.events.push(e);let n=se(e.payload);switch(e.type){case\"agent.message.delta\":{let s=E(n.text);if(!s)return z();let i=E(n.messageId)||null;if(i)return this.messageDelta(i,s,De(n));let r=this.segments.at(-1);if(De(n)){if(r?.open&&r.commentary)r.text+=s;else this.closeSegments(),this.segments.push({text:s,open:!0,commentary:!0,messageId:null});return z()}if(r?.open&&!r.commentary)r.text+=s;else return this.closeSegments(),{chunks:[this.startSegment(s,!0,null)],terminal:null};return{chunks:[{type:\"text\",text:s}],terminal:null}}case\"agent.message.completed\":{let s=E(n.text)??\"\",i=E(n.messageId)||null;if(i)return this.messageCompleted(i,s,De(n));let r=this.segments.at(-1);if(De(n)){if(r?.commentary&&(r.open||s.startsWith(r.text))){if(r.open=!1,s)r.text=s;return z()}if(!(r&&!r.commentary&&r.open&&s.startsWith(r.text))){if(s)this.closeSegments(),this.segments.push({text:s,open:!1,commentary:!0,messageId:null});return z()}}let o=r?.commentary?void 0:r;if(!o||!o.open&&o.text&&!s.startsWith(o.text)){if(!s)return z();if(n.phase===void 0&&this.latestAnswer()?.text===s)return z();return this.closeSegments(),{chunks:[this.startSegment(s,!1,null)],terminal:null}}return o.open=!1,{chunks:this.extendAnswer(o,s),terminal:null}}case\"agent.toolCall.created\":{this.closeSegments();let s=E(n.name)??\"tool\",i=E(n.id);if(i)this.openTools.set(i,s);return{chunks:[{type:\"tool\",name:s,status:\"started\",...i?{callId:i}:{},...\"arguments\"in n?{input:n.arguments}:{}}],terminal:null}}case\"agent.toolCall.output\":{let s=E(n.id),i=(s?this.openTools.get(s):void 0)??\"tool\";if(s)this.openTools.delete(s);return{chunks:[{type:\"tool\",name:i,status:rr(n)?\"failed\":\"completed\",...s?{callId:s}:{}}],terminal:null}}case\"session.requiresAction\":{let s=sr(n);if(!s)return{chunks:[],terminal:null};return this.pending=s,{chunks:[...this.settleSegments(),{type:\"pending\",pending:s}],terminal:\"pending\"}}case\"session.humanInput.requested\":{let s=ir(n);if(!s)return{chunks:[],terminal:null};return this.pending=s,{chunks:[...this.settleSegments(),{type:\"pending\",pending:s}],terminal:\"pending\"}}case\"turn.completed\":return this.emptyFinalReply=ts(n),{chunks:this.settleSegments(),terminal:\"completed\"};case\"turn.failed\":return this.failure=e,{chunks:this.settleSegments(),terminal:\"failed\"};case\"turn.cancelled\":return{chunks:this.settleSegments(),terminal:\"cancelled\"};default:return{chunks:[],terminal:null}}}reply(e){let t=this.text;return{text:t,sessionId:this.sessionId,workspaceId:this.workspaceId,turnId:this.turnId,status:e===\"pending\"?\"pending\":e===\"cancelled\"?\"cancelled\":\"completed\",pending:this.pending,...this.emptyFinalReply?{emptyFinalReply:!0,notice:es}:{},events:[...this.events],toString:()=>t}}failureError(){let e=se(this.failure?.payload),t=E(e.code)??\"turn_failed\",n=E(e.error)??E(e.message)??\"The turn failed.\";return new ot(t,n,this.failure)}messageDelta(e,t,n){let s=this.segmentOf(e);if(s?.open)return s.text+=t,s.commentary?z():{chunks:[{type:\"text\",text:t}],terminal:null};if(this.closeSegments(),n)return this.segments.push({text:t,open:!0,commentary:!0,messageId:e}),z();return{chunks:[this.startSegment(t,!0,e)],terminal:null}}messageCompleted(e,t,n){let s=this.segmentOf(e)??this.unidentifiedStreamingSegment(t);if(s){if(s.messageId=e,s.open=!1,s.commentary){if(t)s.text=t;return z()}return{chunks:this.extendAnswer(s,t),terminal:null}}if(!t)return z();if(n)return this.segments.push({text:t,open:!1,commentary:!0,messageId:e}),z();return{chunks:[this.startSegment(t,!1,e)],terminal:null}}segmentOf(e){return this.findLastSegment((t)=>t.messageId===e)}unidentifiedStreamingSegment(e){let t=this.segments.at(-1);return t?.open&&t.messageId===null&&e.startsWith(t.text)?t:void 0}latestAnswer(){return this.findLastSegment((e)=>!e.commentary)}findLastSegment(e){for(let t=this.segments.length-1;t>=0;t-=1){let n=this.segments[t];if(e(n))return n}return}extendAnswer(e,t){if(t.length<=e.text.length||!t.startsWith(e.text))return[];if(e!==this.latestAnswer())return[];let n=t.slice(e.text.length);return e.text=t,[{type:\"text\",text:n}]}closeSegments(){for(let e of this.segments)e.open=!1}settleSegments(){if(this.closeSegments(),this.emptyFinalReply)return[];if(this.segments.some((t)=>!t.commentary))return[];let e=[...this.segments].reverse().find((t)=>t.commentary&&t.text);if(!e)return[];return e.commentary=!1,[{type:\"text\",text:e.text}]}startSegment(e,t,n){let s=this.segments.some((i)=>!i.commentary)?`\\n\\n`:\"\";return this.segments.push({text:e,open:t,commentary:!1,messageId:n}),{type:\"text\",text:s+e}}}function De(e){return e.phase===\"commentary\"}function nr(e){return e.startsWith(\"turn.\")||e.startsWith(\"agent.\")||e===\"user.message\"}function sr(e){let n=(Array.isArray(e.approvals)?e.approvals:[])[0];if(!n)return null;let s=se(n),i=se(s.rawItem),r=E(i.callId)??E(i.id)??E(s.id)??E(s.callId);if(!r)return null;return{kind:\"approval\",requestId:r,name:E(s.name)??E(s.toolName)??E(i.name)??null,payload:n}}function ir(e){let t=se(e.request),n=E(t.id);if(!n||!Array.isArray(t.questions))return null;return{kind:\"human_input\",requestId:n,name:null,payload:e.request}}function se(e){return e&&typeof e===\"object\"&&!Array.isArray(e)?e:{}}function E(e){return typeof e===\"string\"?e:void 0}function rr(e){if(e.error===!0||e.failed===!0)return!0;let t=e.output;return!!t&&typeof t===\"object\"&&t.isError===!0}function is(e,t){let n=async(s,i={})=>{i.signal?.throwIfAborted();let r=new AbortController,o=()=>r.abort(i.signal?.reason);i.signal?.addEventListener(\"abort\",o,{once:!0});let a=i.after??0,c=0,u=\"\",l=i.turnId||a===0?new $e(t,s,i.turnId??null):null,p=[],d=null,m={event:null},y,R,w=()=>{if(R?.abort(),y)Promise.resolve(y.return(void 0)).catch(()=>{return});y=void 0,R=void 0},S=()=>R?.abort(r.signal.reason);r.signal.addEventListener(\"abort\",S);let I=(v)=>{for(let k of v)if(k.type===\"text\")r.signal.throwIfAborted(),u+=k.text,i.onText?.(k.text)},x=(v)=>{l=new $e(t,s,v);for(let k of p){let q=l.push(k);if(q.terminal&&q.terminal!==\"pending\")d=q.terminal}p=[]},b=(v)=>{let k=ss(v);if(k<=c)return;if(c=k,!l){if(k<=a){p.push(v);return}if(!rs(v)&&!Be(v))return;x(v.turnId??ns(p))}let q=l;if((!v.turnId||!q.turnId||v.turnId===q.turnId)&&Be(v)){if(!q.turnId&&v.turnId)q.turnId=v.turnId;if(v.type!==\"session.status.changed\")m.event=v;if(k>a)return}let Q=q.push(v);if(k>a)I(Q.chunks);if(Q.terminal&&Q.terminal!==\"pending\")d=Q.terminal},h=(v)=>{if(r.signal.throwIfAborted(),v===\"failed\")throw l.failureError();return{sessionId:s,turnId:l?.turnId??null,text:u,status:v===\"pending\"?\"pending\":v===\"cancelled\"?\"cancelled\":\"completed\",after:Math.max(a,c)}},f=()=>at(()=>e.getSession(t,s,{fresh:!0,signal:r.signal}),r.signal),T=async(v)=>{while(c<v){let k=c,q=await at(()=>e.listEventPage(t,s,{after:c,before:v+1,direction:\"after\",limit:200,mode:\"forensic\",payloadMode:\"full\"}),r.signal);for(let H of q.events)if(b(H),d&&c>a)return;if(c=Math.max(c,q.nextAfter??q.coveredSequence?.last??0),c<=k)throw Error(\"The Site AI event replay did not reach the session cursor.\")}},C=(v)=>v.status===\"requires_action\"&&(!v.activeTurnId||!l?.turnId||v.activeTurnId===l.turnId);try{let v=await f();if(await T(Math.min(a,v.lastSequence)),d)return h(d);for(;;){if(await T(v.lastSequence),d)return h(d);if(C(v)){let k=await f();if(k.lastSequence>c){v=k;continue}if(C(k)){if(!l)x(k.activeTurnId??ns(p));else if(!l.turnId)l.turnId=k.activeTurnId??null;if(m.event&&ss(m.event)>a)I(l.push(m.event).chunks);return h(\"pending\")}v=k}R=new AbortController,y=e.streamEvents(t,s,{after:Math.max(a,c),signal:R.signal});for(;;){let k=await at(()=>y.next(),r.signal);if(k.done)throw Error(\"The Site AI event stream ended before the turn settled.\");if(b(k.value),d)return h(d);if(Be(k.value)&&(!k.value.turnId||k.value.turnId===l?.turnId)){w(),v=await f();break}}}}finally{i.signal?.removeEventListener(\"abort\",o),r.abort(),w(),r.signal.removeEventListener(\"abort\",S)}};return{async run(s,i={}){i.signal?.throwIfAborted();let r=await e.createSession(t,{initialMessage:s.initialMessage,idempotencyKey:s.idempotencyKey??crypto.randomUUID(),...s.model===void 0?{}:{model:s.model},...s.reasoningEffort===void 0?{}:{reasoningEffort:s.reasoningEffort},...s.latencyMode===void 0?{}:{latencyMode:s.latencyMode}});return i.onSession?.(r.id),await n(r.id,i)},result:n}}function Be(e){return e.type===\"session.requiresAction\"||e.type===\"session.humanInput.requested\"||e.type===\"session.status.changed\"&&se(e.payload).status===\"requires_action\"}function rs(e){return e.type.startsWith(\"turn.\")||e.type.startsWith(\"agent.\")||e.type===\"user.message\"}function ns(e){for(let t=e.length-1;t>=0;t-=1){let n=e[t];if(n.turnId&&(rs(n)||Be(n)))return n.turnId}return null}function ss(e){return Math.max(e.sequence,e.coveredThrough??0,Et(e)??0)}async function at(e,t){t.throwIfAborted();let n=()=>{},s=new Promise((i,r)=>{n=()=>r(t.reason),t.addEventListener(\"abort\",n,{once:!0})});try{let i=await Promise.race([e(),s]);return t.throwIfAborted(),i}finally{t.removeEventListener(\"abort\",n)}}var le=2,or=\"opengeni.site.connect\",cs=\"opengeni.site.ready\",ar=\"opengeni.site.request\",cr=\"opengeni.site.response\",ur=\"opengeni.site.cancel\",us=\"__opengeniSiteBridgeBootstrapV2\",lr=\"/__opengeni/site-tools\",dr=\"viewer\",pr=\"auth.signIn\";class _ extends Error{code;retryable;outcomeUnknown;constructor(e,t,n=!1,s=!1){super(t);this.code=e;this.retryable=n;this.outcomeUnknown=s;this.name=\"OpenGeniSiteBridgeError\"}}function ls(e={}){let t=gr(e)?new ds(e):new ps(e),n=Qn((a,c)=>t.fetch(`https://site.opengeni.invalid${a}`,c),()=>t.siteDataSupported()),s=Zn((a,c)=>t.fetch(`https://site.opengeni.invalid${a}`,c),()=>t.siteDataSupported()),i=null,r=null,o=new st({baseUrl:\"https://site.opengeni.invalid\",toolGatewayMode:e.toolGatewayMode??\"target\",fetch:(a,c)=>t.fetch(a,c)});return{client:o,ai:is(o,ge),workspaceId:ge,tools:new re(t).forWorkspace(\"site-host\"),data:n.data,files:n.files,sql:s,get viewer(){if(!i){let a=t.viewer();i=a,a.catch(()=>{if(i===a)i=null})}return i},get capabilities(){return r??=vr(t),r},auth:{signIn:()=>t.signIn()},close:()=>t.close()}}class ds{toolGatewayMode;fetchImpl;basePath;constructor(e){this.toolGatewayMode=e.toolGatewayMode??\"target\",this.fetchImpl=e.fetch??globalThis.fetch.bind(globalThis);let t=e.localCodemodePath;this.basePath=(typeof t===\"string\"?t:lr).replace(/\\\\/+$/u,\"\")}close(){}async siteDataSupported(){return!1}async viewer(){return null}async signIn(){return{started:!1}}async fetch(e,t){let n=new Request(e,t),s=new URL(n.url),i=`${s.pathname}${s.search}`;return de(i,ge,n.method),this.fetchImpl(`${this.basePath}/sdk${i}`,{method:n.method,headers:n.headers,signal:n.signal,...n.body?{body:await n.text()}:{}})}async requestJson(e,t,n,s,i={}){let r=mr(e,t),o=await this.fetchImpl(`${this.basePath}${r}`,{method:e,...i.signal?{signal:i.signal}:{},...n===void 0?{}:{headers:{\"content-type\":\"application/json\"},body:JSON.stringify(n)}}),a=await o.json();if(o.ok)return a;let c=B(a)&&B(a.error)?a.error:{};throw new _(typeof c.code===\"string\"?c.code:\"local_codemode_error\",typeof c.message===\"string\"?c.message:`Local Site tool request failed with HTTP ${o.status}`,c.retryable===!0,c.outcomeUnknown===!0)}}function gr(e){if(e.localCodemodePath===!1||e.bootstrapPort)return!1;if(typeof e.localCodemodePath===\"string\")return!0;let t=e.siteWindow??globalThis.window;return Boolean(t&&t.parent===t)}function mr(e,t){if(e===\"GET\"&&t.endsWith(\"/tools/catalog\"))return\"/catalog\";if(e===\"GET\"&&t.endsWith(\"/tools/declarations\"))return\"/declarations\";if(e===\"POST\"&&t.endsWith(\"/tools/calls\"))return\"/calls\";if(e===\"POST\"&&t.endsWith(\"/tools/resolve\"))return\"/resolve\";if(e===\"POST\"&&t.endsWith(\"/tools/invoke\"))return\"/invoke\";throw new _(\"unsupported_request\",\"Unsupported Site tool request\")}function yr(e){return{...e.operationId===void 0?{}:{operationId:e.operationId},catalogDigest:e.catalogDigest,identity:e.identity,arguments:e.arguments}}function fr(e){return{target:e.target,operationId:e.operationId,arguments:e.arguments,...e.expectedDefinitionDigest===void 0?{}:{expectedDefinitionDigest:e.expectedDefinitionDigest}}}class ps{toolGatewayMode;targetTools=!1;siteData=!1;viewerSupported=!1;options;bootstrap;port=null;connecting=null;closed=!1;constructor(e){this.toolGatewayMode=e.toolGatewayMode??\"target\",this.options=e,this.bootstrap=hr(e)}async fetch(e,t){return bt(await this.connect(),e,t)}async siteDataSupported(){return await this.connect(),this.siteData}async viewer(){if(await this.connect(),!this.viewerSupported)return null;let e=await this.request({method:dr},{});if(!Ir(e))throw new _(\"invalid_viewer\",\"The Site host returned an invalid viewer\");return e}async signIn(){if(await this.connect(),!this.viewerSupported)return{started:!1};let e=await this.request({method:pr},{});return{started:B(e)&&e.started===!0}}async requestJson(e,t,n,s,i={}){if(e===\"POST\"&&(t.endsWith(\"/tools/resolve\")||t.endsWith(\"/tools/invoke\"))){if(await this.connect(),!this.targetTools)throw new _(\"target_tools_unsupported\",\"Upgrade the Site host to use targeted tools\");if(!B(n))throw TypeError(\"Site target payload is required\");let r=n;return await this.request(t.endsWith(\"/tools/resolve\")?{method:\"resolve\",payload:{target:r.target}}:{method:\"invoke\",payload:fr(r)},i)}if(e===\"GET\"&&t.endsWith(\"/tools/catalog\"))return await this.request({method:\"catalog\"},i);if(e===\"GET\"&&t.endsWith(\"/tools/declarations\"))return await this.request({method:\"declarations\"},i);if(e===\"POST\"&&t.endsWith(\"/tools/calls\")){if(!B(n))throw TypeError(\"Site tool call payload is required\");return await this.request({method:\"call\",payload:yr(n)},i)}throw new _(\"unsupported_request\",\"Unsupported Site bridge request\")}close(){if(this.closed)return;this.closed=!0,this.bootstrap.close(),this.port?.close(),this.port=null}async request(e,t){let n=await this.connect(),s=crypto.randomUUID(),i=as(t.timeoutMs??this.options.requestTimeoutMs??120000,\"requestTimeoutMs\");return await new Promise((r,o)=>{let a=setTimeout(()=>{l(),os(n,s),o(e.method===\"call\"||e.method===\"invoke\"?new _(\"timeout\",\"Site tool request timed out after execution may have started\",!1,!0):new _(\"timeout\",\"Site tool request timed out\",!0))},i),c=()=>{l(),os(n,s),o(t.signal?.reason??new DOMException(\"Request aborted\",\"AbortError\"))},u=(p)=>{let d=p.data;if(!B(d)||d.type!==cr||d.version!==le||d.requestId!==s||typeof d.ok!==\"boolean\")return;if(l(),d.ok){r(d.value);return}let m=B(d.error)?d.error:{};o(new _(typeof m.code===\"string\"?m.code:\"bridge_error\",typeof m.message===\"string\"?m.message:\"Site tool request failed\",m.retryable===!0,m.outcomeUnknown===!0))},l=()=>{clearTimeout(a),t.signal?.removeEventListener(\"abort\",c),n.removeEventListener(\"message\",u)};if(t.signal?.aborted){c();return}t.signal?.addEventListener(\"abort\",c,{once:!0}),n.addEventListener(\"message\",u),n.postMessage({type:ar,version:le,requestId:s,...e})})}async connect(){if(this.closed)throw new _(\"closed\",\"Site bridge is closed\");if(this.port)return this.port;if(this.connecting)return await this.connecting;let e=(this.options.createMessageChannel??(()=>new MessageChannel))(),t=as(this.options.connectTimeoutMs??1e4,\"connectTimeoutMs\");return this.connecting=new Promise((n,s)=>{let i=!0,r=setTimeout(()=>{a(),e.port1.close(),s(new _(\"host_timeout\",\"The Site host did not respond\"))},t),o=(c)=>{let u=c.data;if(!B(u)||u.type!==cs||u.version!==le)return;a(),this.targetTools=u.targetTools===1,this.siteData=u.siteData===1,this.viewerSupported=u.viewer===1,this.port=e.port1,n(e.port1)},a=()=>{i=!1,clearTimeout(r),e.port1.removeEventListener(\"message\",o)};e.port1.addEventListener(\"message\",o),e.port1.start(),this.bootstrap.port().then((c)=>{if(!i)return;if(this.closed)throw new _(\"closed\",\"Site bridge is closed\");c.postMessage({type:or,version:le},[e.port2])}).catch((c)=>{a(),e.port1.close(),s(c)})}).finally(()=>{this.connecting=null}),await this.connecting}}function hr(e){if(e.bootstrapPort)return{port:async()=>e.bootstrapPort,close:()=>e.bootstrapPort?.close()};let t=e.siteWindow??globalThis.window,n=e.parentWindow??t?.parent;if(!t||!n||n===t)return{port:async()=>{throw new _(\"host_unavailable\",\"The Site client must run inside a hosted iframe\")},close:()=>{return}};let s=Rr(t);if(s)return{port:async()=>s,close:()=>{return}};let i=null,r=null,o=(l)=>{if(l.source!==n||!Sr(l.data)||l.ports.length!==1)return;c(),i=l.ports[0],i.start(),br(t,i),a?.(i)},a=null,c=()=>t.removeEventListener(\"message\",o),u=new Promise((l,p)=>{a=l,r=p,t.addEventListener(\"message\",o)});return u.catch(()=>{return}),{port:async()=>await u,close:()=>{c(),r?.(new _(\"closed\",\"Site bridge is closed\")),a=null,r=null}}}function Rr(e){let t=e[us];if(!B(t))return null;let n=t.port;return n&&typeof n.postMessage===\"function\"&&typeof n.addEventListener===\"function\"&&typeof n.start===\"function\"?n:null}function br(e,t){try{Object.defineProperty(e,us,{configurable:!0,value:{port:t}})}catch{}}function Sr(e){return B(e)&&e.type===cs&&e.version===le}var wr=[\"member\",\"invited\",\"user\",\"guest\"];async function vr(e){try{if(!await e.siteDataSupported())return null;let t=await e.fetch(\"https://site.opengeni.invalid/v1/workspaces/site-host/site/config\",{method:\"GET\",headers:{accept:\"application/json\"}});if(!t.ok)return await t.body?.cancel(),null;let n=(await t.json())?.capabilities;return kr(n)?n:null}catch{return null}}function kr(e){return B(e)&&typeof e.agent===\"boolean\"&&typeof e.workspaceTools===\"boolean\"&&(e.siteData===\"viewer\"||e.siteData===\"guest\")&&Array.isArray(e.sqlQueryAudiences)&&e.sqlQueryAudiences.every((t)=>t===\"everyone\"||t===\"signed_in\")&&(e.viewAs===null||e.viewAs===\"invited\"||e.viewAs===\"public\")}function Ir(e){return B(e)&&wr.includes(String(e.kind))&&typeof e.id===\"string\"&&e.id.length>0&&(e.name===null||typeof e.name===\"string\")&&(e.email===null||typeof e.email===\"string\")&&typeof e.signedIn===\"boolean\"}function os(e,t){e.postMessage({type:ur,version:le,requestId:t})}function as(e,t){if(!Number.isFinite(e)||e<=0)throw RangeError(`${t} must be positive`);return e}function B(e){return typeof e===\"object\"&&e!==null&&!Array.isArray(e)}Object.defineProperty(globalThis,\"createOpenGeniSiteClient\",{configurable:!0,value:ls});})();\\n';var rT=\"/__opengeni/site-tools/client.js\";var cn=\"/__opengeni/site-tools\";function w5(e=()=>on()){let t=typeof e===\"function\"?e:()=>e,n=oT();return async(r)=>{try{let o=new URL(r.url).pathname;if(o===rT){if(r.method!==\"GET\"&&r.method!==\"HEAD\")return new Response(\"Method not allowed\",{status:405,headers:{allow:\"GET, HEAD\"}});return new Response(r.method===\"HEAD\"?null:Ru,{headers:{\"content-type\":\"text/javascript; charset=utf-8\",\"cache-control\":\"no-cache\"}})}let s=await t();if(r.method===\"POST\"&&(o===`${cn}/resolve`||o===`${cn}/invoke`)){let i=o.endsWith(\"/invoke\"),a=await r.json().catch(()=>null),c=(i?ga:Kf).safeParse(a);if(!c.success||c.data.siteArtifactId||c.data.siteVersionId||\"approvalToken\"in c.data&&c.data.approvalToken)return yt(400,\"invalid_request\",\"Invalid Site target request\");let l=await s.catalog({signal:r.signal}),u=c.data.target,p=l.entries.filter((y)=>(\"identity\"in u)?y.identity.serverId===u.identity.serverId&&y.identity.toolName===u.identity.toolName:y.codemodePath.length===u.path.length&&y.codemodePath.every((_,E)=>_===u.path[E]));if(p.length!==1)return yt(404,\"tool_unavailable\",\"Tool unavailable\");let m=p[0],d={version:1,entry:m,definitionDigest:po(l,m)};if(!i)return Response.json(d);let f=ga.parse(a);if(f.expectedDefinitionDigest!==void 0&&f.expectedDefinitionDigest!==d.definitionDigest)return yt(409,\"tool_definition_stale\",\"The tool definition changed\",!0);r.signal.throwIfAborted();let h=await s.call(m.identity,f.arguments,{operationId:f.operationId,expectedDefinitionDigest:d.definitionDigest,signal:r.signal});return Response.json({operationId:f.operationId,tool:d,result:h})}if(o.startsWith(`${cn}/sdk/`)){let i=o.slice(`${cn}/sdk`.length)+new URL(r.url).search;try{hg(i,\"preview\",r.method)}catch(u){if(u instanceof Ot||u instanceof Do)return yt(404,u.code,u.message);throw u}let a=bg(r.headers);a.set(dg,pg),a.set(mg,n);let c=await s.sessionRequest(i,{method:r.method,signal:r.signal,headers:a,...r.body?{body:await r.text()}:{}}),l=new Headers(c.headers);return l.delete(\"content-encoding\"),l.delete(\"content-length\"),l.delete(\"transfer-encoding\"),new Response(c.body,{status:c.status,statusText:c.statusText,headers:l})}if(r.method===\"GET\"&&o===`${cn}/catalog`){let i=await s.catalog({signal:r.signal});return Response.json(UG(i))}if(r.method===\"GET\"&&o===`${cn}/declarations`){let i=await s.catalog({signal:r.signal});return Response.json({catalogDigest:i.digest,moduleSpecifier:\"@opengeni/sdk\",source:Ri({digest:i.digest,entries:i.entries},{moduleSpecifier:\"@opengeni/sdk\",interfaceName:\"OpenGeniGeneratedTools\",callOptionsType:\"OpenGeniToolCallOptions\",fallbackResultType:\"ToolGatewayResult\",generatedBy:\"@opengeni/codemode local Site preview\",catalogDigestLabel:\"Attempt catalog digest\"})})}if(r.method===\"POST\"&&o===`${cn}/calls`){let i=await r.json();if(!LG(i))return yt(400,\"invalid_request\",\"Invalid Site tool call\");let a=await s.catalog({signal:r.signal});if(i.catalogDigest!==a.digest)return yt(409,\"catalog_stale\",\"The local Site tool catalog changed\",!0);let c=i.operationId??oT(),l=a.entries.find((p)=>p.identity.serverId===i.identity.serverId&&p.identity.toolName===i.identity.toolName);if(!l)return yt(404,\"tool_unavailable\",\"Tool unavailable\");let u=await s.call(i.identity,i.arguments,{operationId:c,expectedDefinitionDigest:po(a,l),signal:r.signal});return Response.json({operationId:c,catalogDigest:a.digest,result:u})}return yt(404,\"not_found\",\"Local Site tool endpoint not found\")}catch(o){if(o instanceof Je){let s=new URL(r.url).pathname===`${cn}/calls`&&o.remoteCode===\"tool_definition_stale\"&&o.retryable===!0&&o.outcomeUnknown===!1;return yt(o.status&&o.status>=400&&o.status<=599?o.status:502,s?\"catalog_stale\":o.remoteCode??o.code,o.message,o.retryable===!0,o.outcomeUnknown===!0)}return yt(500,\"local_codemode_error\",o instanceof Error?o.message:\"Local Site tool request failed\")}}}function UG(e){return{version:e.version,generation:e.generation,digest:e.digest,createdAt:e.createdAt,entries:e.entries}}function LG(e){if(!Tu(e)||typeof e.catalogDigest!==\"string\")return!1;if(e.operationId!==void 0&&typeof e.operationId!==\"string\")return!1;return Tu(e.identity)&&typeof e.identity.serverId===\"string\"&&typeof e.identity.toolName===\"string\"&&Tu(e.arguments)}function yt(e,t,n,r=!1,o=!1){return Response.json({error:{code:t,message:n,retryable:r,...o?{outcomeUnknown:!0}:{}}},{status:e})}function Tu(e){return typeof e===\"object\"&&e!==null&&!Array.isArray(e)}import{createHash as GG,randomUUID as sT}from\"node:crypto\";async function I5(e,t={}){let n=t.maxItems??1e4,r=t.maxPages??200;if(!Number.isSafeInteger(n)||n<1||n>50000||!Number.isSafeInteger(r)||r<1||r>1000)throw Error(\"Invalid selection limit\");let o=new Set,s=new Set,i;for(let a=0;a<r;a++){t.signal?.throwIfAborted();let c=await e(i,t.signal);if(t.signal?.throwIfAborted(),!Array.isArray(c?.ids)||c.ids.length>50000)throw Error(\"Invalid selection page\");for(let l of c.ids){if(typeof l!==\"string\"||!l||l.length>256)throw Error(\"Invalid selection ID\");if(o.add(l),o.size>n)throw Error(\"Selection exceeds item limit; no complete selection returned\")}if(!c.nextPageToken)return Object.freeze([...o]);if(typeof c.nextPageToken!==\"string\"||c.nextPageToken.length>4096)throw Error(\"Invalid page token\");if(!c.ids.length||s.has(c.nextPageToken))throw Error(\"Pagination did not progress; no complete selection returned\");s.add(c.nextPageToken),i=c.nextPageToken}throw Error(\"Selection exceeds page limit; no complete selection returned\")}function k5(e,t=1000){if(!Number.isSafeInteger(t)||t<1||t>1000||e.length>50000)throw Error(\"Invalid batch limit\");if(e.some((o)=>typeof o!==\"string\"||!o||o.length>256))throw Error(\"Invalid selection ID\");let n=[...new Set(e)],r=Array.from({length:Math.ceil(n.length/t)},(o,s)=>Object.freeze({operationId:sT(),ids:Object.freeze(n.slice(s*t,(s+1)*t))}));return Object.freeze({id:sT(),selectionDigest:GG(\"sha256\").update(JSON.stringify(n)).digest(\"hex\"),count:n.length,batches:Object.freeze(r)})}function R5(e,t){let n=new Map,r=new Set(e.batches.map((s)=>s.operationId));for(let s of t){if(![\"acknowledged\",\"failed_before_effect\",\"unknown\",\"waiting\"].includes(s.outcome))throw Error(\"Invalid batch outcome\");if(!r.has(s.operationId)||n.has(s.operationId))throw Error(\"Receipt does not uniquely identify a planned batch\");n.set(s.operationId,s.outcome)}let o={acknowledged:0,failed_before_effect:0,unknown:0,waiting:0,unstarted:0};for(let s of e.batches)o[n.get(s.operationId)??\"unstarted\"]+=s.ids.length;return{selected:e.count,...o,individualStateVerified:!1}}class Je extends Error{status;code=\"codemode_transport_error\";remoteCode;retryable;outcomeUnknown;details;constructor(e,t=null,n={}){super(e);this.status=t;this.name=\"CodemodeTransportError\",this.remoteCode=n.code??null,this.retryable=n.retryable??null,this.outcomeUnknown=n.outcomeUnknown??null,this.details=n.details??null}}class Au extends Error{operation;code;constructor(e,t){super(e.errorMessage??`Codemode operation ${e.state}`);this.operation=e;this.code=t;this.name=\"CodemodeOperationError\",Object.defineProperty(this,\"operation\",{value:e,enumerable:!1})}}class Cu extends Error{operationId;approvalRequestId;code=\"codemode_approval_pending\";state=\"waiting_for_approval\";constructor(e,t){super(`Operation ${e} is waiting for approval. After review, read or resume this handle; do not submit its arguments again.`);this.operationId=e;this.approvalRequestId=t;this.name=\"CodemodeApprovalPendingError\"}}class lT extends Error{result;code;retryable;constructor(e){let t=HG(e);super(t.message);this.result=e;this.name=\"CodemodeToolCallError\",this.code=t.code,this.retryable=t.retryable}}class uT extends Error{code=\"invalid_tool_result\";constructor(e){super(e);this.name=\"CodemodeToolContractError\"}}class wu{options;baseUrl;fetchImpl;pollIntervalMs;timeoutMs;catalogSnapshot=null;constructor(e){this.options=e;if(this.baseUrl=e.baseUrl.replace(/\\/+$/u,\"\"),!/^https?:\\/\\//u.test(this.baseUrl))throw Error(\"Codemode baseUrl must be an absolute HTTP(S) URL\");this.fetchImpl=e.fetch??globalThis.fetch.bind(globalThis),this.pollIntervalMs=Ei(e.pollIntervalMs??500,50,30000),this.timeoutMs=Ei(e.timeoutMs??600000,1000,3600000)}async catalog(e={}){if(this.catalogSnapshot&&!e.refresh)return this.catalogSnapshot;let t=await this.request(\"/catalog\",{method:\"GET\",...e.signal?{signal:e.signal}:{}}),n=Ci(await t.json());return this.catalogSnapshot=n,n}async tools(e={}){return JG(await this.catalog(e),this)}async call(e,t={},n={}){return(await this.callResolved((r)=>r.entries.find((o)=>o.identity.serverId===e.serverId&&o.identity.toolName===e.toolName)??null,t,n)).result}async callResolved(e,t,n){let r=await this.catalog(n.signal?{signal:n.signal}:{}),o=e(r);if(!o)throw new mt;let s=()=>{if(n.expectedDefinitionDigest!==void 0&&n.expectedDefinitionDigest!==po(r,o))throw new Je(\"The tool definition changed before execution\",409,{code:\"tool_definition_stale\",retryable:!0,outcomeUnknown:!1})};s();let i=n.operationId??BG(),a=Date.now()+Ei(n.timeoutMs??this.timeoutMs,1000,3600000),c=!1,l=!1,u=null,p=0;while(!0){if(Eu(n.signal),Date.now()>=a)throw new Je(`Codemode operation ${i} did not settle before the client deadline`);if(!c||(u?.state===\"queued\"||u?.state===\"running\")&&Date.now()>=p){c=!0,p=Date.now()+2000;try{u=await this.submit(i,r.digest,o.identity,t,n.signal)}catch(d){if(u===null&&!l&&d instanceof Je&&d.outcomeUnknown!==!0&&d.retryable!==!1&&d.remoteCode===\"codemode_catalog_stale\"){if(l=!0,r=await this.catalog({refresh:!0,...n.signal?{signal:n.signal}:{}}),o=e(r),!o)throw new mt;s(),c=!1,p=0;continue}if(n.signal?.aborted)throw d;if(u===null&&!VG(d))throw d;let f;try{f=await this.read(i,n.signal)}catch(h){if(n.signal?.aborted)throw h;throw new Je(`Codemode operation ${i} could not be reconciled after its submission response failed`,null,{code:\"codemode_operation_recovery_unavailable\",retryable:!0,outcomeUnknown:!0,details:{operationId:i}})}FG(f,{operationId:i,catalog:r,identity:o.identity,arguments:t}),u=f}}else u=await this.read(i,n.signal);if(u.state===\"waiting_for_approval\")throw new Cu(u.operationId,u.approvalRequestId);if(u.state===\"completed\")return{result:jr.parse(u.result),entry:o};if([\"failed\",\"outcome_unknown\",\"cancelled\"].includes(u.state))throw new Au(u,u.errorCode??`codemode_${u.state}`);await Pu(this.pollIntervalMs,n.signal)}}async callPath(e,t={},n={}){if(e.length<2||e.some((r)=>r.length===0))throw new mt;return(await this.callResolved((r)=>aT(r,e),t,n)).result}async callPathValue(e,t={},n={}){if(e.length<2||e.some((i)=>i.length===0))throw new mt;let{result:r,entry:o}=await this.callResolved((i)=>aT(i,e),t,n);if(!o.outputSchema)return r;if(r.isError)throw new lT(r);if(!r.structuredContent)throw new uT(`Codemode tool ${e.join(\".\")} declared outputSchema but returned no structured content`);if(!r.content.some((i)=>i.type===\"image\"))return r.structuredContent;let s=await Ai(r);return{structuredContent:r.structuredContent,images:s,otherContent:r.content.filter((i)=>i.type!==\"image\")}}async submit(e,t,n,r,o){return await cT(o,async()=>{let s=await this.request(\"/calls\",{method:\"POST\",...o?{signal:o}:{},headers:{\"content-type\":\"application/json\"},body:JSON.stringify({operationId:e,catalogDigest:t,identity:n,arguments:r,durableApproval:!0})});return Hf.parse(await s.json()).operation})}async status(e,t){let n=await this.read(e,t);return{operationId:n.operationId,state:n.state,approvalRequestId:n.approvalRequestId,result:n.result,errorCode:n.errorCode,errorMessage:n.errorMessage}}async resume(e,t={}){let n=Date.now()+Ei(t.timeoutMs??this.timeoutMs,1000,3600000);while(!0){Eu(t.signal);let r=await this.read(e,t.signal);if(r.state===\"waiting_for_approval\")throw new Cu(r.operationId,r.approvalRequestId);if(r.state===\"completed\")return jr.parse(r.result);if([\"failed\",\"outcome_unknown\",\"cancelled\"].includes(r.state))throw new Au(r,r.errorCode??`codemode_${r.state}`);if(Date.now()>=n)throw new Je(`Codemode operation ${e} did not settle before the client deadline`);await Pu(this.pollIntervalMs,t.signal)}}async read(e,t){return await cT(t,async()=>{let n=await this.request(`/calls/${e}`,{method:\"GET\",...t?{signal:t}:{}});return ya.parse(await n.json())})}async sessionRequest(e,t){return yg(e,\"site-host\"),this.request(`/sdk${e}`,t,!1)}async request(e,t,n=!0){let r=typeof this.options.token===\"function\"?await this.options.token():this.options.token,o=await this.fetchImpl(`${this.baseUrl}${e}`,{...t,headers:{...Object.fromEntries(new Headers(t.headers).entries()),authorization:`Bearer ${r}`,\"x-opengeni-codemode-capabilities\":\"durable-approval-v1\"}});if(!o.ok&&n){let s=`Codemode request failed with HTTP ${o.status}`,i={};try{let a=ZG(await o.json());if(a?.message)s=a.message;if(a)i={...a.code?{code:a.code}:{},...a.retryable===void 0?{}:{retryable:a.retryable},...a.outcomeUnknown===void 0?{}:{outcomeUnknown:a.outcomeUnknown},...a.details?{details:a.details}:{}}}catch{}throw new Je(s,o.status,i)}return o}}function VG(e){return!(e instanceof Je)||e.outcomeUnknown===!0}function FG(e,t){if(e.operationId===t.operationId&&e.accountId===t.catalog.accountId&&e.workspaceId===t.catalog.workspaceId&&e.sessionId===t.catalog.sessionId&&e.turnId===t.catalog.turnId&&e.attemptId===t.catalog.attemptId&&e.executionGeneration===t.catalog.executionGeneration&&e.catalogDigest===t.catalog.digest&&e.identity.serverId===t.identity.serverId&&e.identity.toolName===t.identity.toolName&&ft(e.arguments)===ft(t.arguments))return;throw new Je(\"Codemode operation id is already bound to a different request\",409,{code:\"codemode_operation_conflict\",retryable:!1,outcomeUnknown:!1})}function JG(e,t){let n=Ci(e),r=Object.create(null);for(let o of n.entries){let s=r;for(let c of o.codemodePath.slice(0,-1)){let l=s[c];if(typeof l===\"function\")throw Error(\"Codemode path collides with a tool\");if(!l)l=Object.create(null),s[c]=l;s=l}let i=o.codemodePath.at(-1),a=async(c={},l={})=>await t.callPathValue(o.codemodePath,c,l);Object.defineProperty(a,\"entry\",{value:o,enumerable:!1}),s[i]=a}return r}class dT{catalog;gateway;constructor(e,t){this.catalog=e;this.gateway=t}async call(e,t={}){return await(await this.prepareCall(e,t)).execute()}async prepareCall(e,t={}){let n=fa.parse(e);return await this.gateway.prepareCall(n,t)}effectDigest(e){return this.gateway.effectDigest(e)}async callModel(e){return await this.gateway.callModel(e)}}function M5(e){let t=(e.createdAt??new Date).toISOString(),n=MR(e.definitions.map((s)=>({...s,execute:async(i,a)=>await s.execute(i,{...a,caller:No.parse(a.caller)})}))),r={version:pa,...e.scope,generation:e.generation,createdAt:t,...e.firstPartyMcpPermissions!==void 0?{firstPartyMcpPermissions:[...e.firstPartyMcpPermissions]}:{},entries:[...n.entries]},o=WG({...r,digest:pT(r)});return new dT(o,n.create({catalogDigest:o.digest,requireApproval:(s,i)=>i.kind===\"codemode\"&&s.approval===\"human\",...e.confirmModelApproval?{confirmModelApproval:({entry:s,subjectId:i})=>e.confirmModelApproval({modelName:s.modelName,subjectId:i})}:{},...e.authorize?{authorize:async({call:s,entry:i})=>await e.authorize({call:fa.parse(s),entry:i})}:{},...e.resolveArguments?{resolveArguments:e.resolveArguments}:{}}))}function pT(e){let{createdAt:t,...n}=e;return ft(n)}function q5(e){return ft(e)}function z5(e,t){if(!iT.test(e)||!iT.test(t))throw Error(\"Codemode dispatch subject requires UUID workspace and attempt ids\");return`codemode.${e}.${t}.dispatch`}function j5(e){return new TextEncoder().encode(JSON.stringify(ba.parse(e)))}function N5(e){return ba.parse(JSON.parse(new TextDecoder().decode(e)))}function D5(e){return new TextEncoder().encode(JSON.stringify(va.parse(e)))}function U5(e){return va.parse(JSON.parse(new TextDecoder().decode(e)))}function Ci(e){return hT(e).catalog}var mT=new WeakMap;function WG(e){let t=hT(structuredClone(e));if(fT(t.catalog))gT(t.catalog),mT.set(t.catalog,t);return t.catalog}function fT(e){if(e===null||typeof e!==\"object\")return!0;let t=Object.getPrototypeOf(e);if(!Array.isArray(e)&&t!==Object.prototype&&t!==null)return!1;for(let n of Object.values(e))if(!fT(n))return!1;return!0}function gT(e){if(e===null||typeof e!==\"object\")return;for(let t of Object.values(e))gT(t);Object.freeze(e)}function hT(e){if(e!==null&&typeof e===\"object\"){let s=mT.get(e);if(s)return{...s}}let t=Bf.parse(e),n=KG(t),{digest:r,...o}=t;if(pT(o)!==r)throw new uu;return{catalog:t,byteLength:n}}function KG(e){let t=new TextEncoder().encode(JSON.stringify(e)).byteLength;if(t>zf)throw new du;return t}var iT=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu;function Ei(e,t,n){if(!Number.isFinite(e))return t;return Math.max(t,Math.min(n,Math.floor(e)))}function Eu(e){if(e?.aborted)throw e.reason??new DOMException(\"Aborted\",\"AbortError\")}function HG(e){let n=e.structuredContent?.error;return{code:typeof n?.code===\"string\"?n.code:\"tool_error\",message:typeof n?.message===\"string\"?n.message:\"Codemode tool failed\",retryable:n?.retryable===!0}}function aT(e,t){let n=e.entries.filter((r)=>r.codemodePath.length===t.length&&r.codemodePath.every((o,s)=>o===t[s]));return n.length===1?n[0]:null}function ZG(e){if(!e||typeof e!==\"object\"||Array.isArray(e))return null;let t=e,n=t.error&&typeof t.error===\"object\"&&!Array.isArray(t.error)?t.error:t,r=n.details&&typeof n.details===\"object\"&&!Array.isArray(n.details)?n.details:void 0,o=r?.code,s=typeof o===\"string\"&&/^[a-z0-9_]{1,128}$/u.test(o)?o:void 0,i=typeof n.message===\"string\"?n.message:void 0,a=typeof n.retryable===\"boolean\"?n.retryable:void 0,c=typeof n.outcomeUnknown===\"boolean\"?n.outcomeUnknown:void 0;return i||s||a!==void 0||c!==void 0||r?{...i?{message:i}:{},...s?{code:s}:{},...a===void 0?{}:{retryable:a},...c===void 0?{}:{outcomeUnknown:c},...r?{details:r}:{}}:null}var YG=[100,250,500,1000,2000];function XG(e){return e instanceof Je&&e.status!==null&&e.status>=500&&e.retryable===!0&&e.outcomeUnknown!==!0}async function cT(e,t){for(let n=0;;n+=1)try{return await t()}catch(r){let o=YG[n];if(o===void 0||e?.aborted||!XG(r))throw r;await Pu(o+Math.floor(Math.random()*o),e)}}async function Pu(e,t){if(!t){await new Promise((n)=>setTimeout(n,e));return}Eu(t),await new Promise((n,r)=>{let o=setTimeout(()=>{t.removeEventListener(\"abort\",s),n()},e),s=()=>{clearTimeout(o),r(t.reason??new DOMException(\"Aborted\",\"AbortError\"))};t.addEventListener(\"abort\",s,{once:!0})})}export{Cn as AttemptToolApprovalRequiredError,uu as AttemptToolCatalogIntegrityError,xi as AttemptToolCatalogStaleError,du as AttemptToolCatalogTooLargeError,dT as AttemptToolEnvironment,Si as AttemptToolInputValidationError,mt as AttemptToolNotFoundError,Ii as AttemptToolOutputValidationError,nn as AttemptToolPathCollisionError,Sr as CODEMODE_ENVIRONMENT,cn as CODEMODE_SITE_LOCAL_PATH,Cu as CodemodeApprovalPendingError,go as CodemodeArtifact,xu as CodemodeArtifactCollection,GR as CodemodeArtifactExport,YR as CodemodeAuth,ku as CodemodeAuthRun,Su as CodemodeBrowser,XR as CodemodeBrowserAuth,KR as CodemodeBrowserClipboard,VR as CodemodeBrowserCollection,WR as CodemodeBrowserDownload,JR as CodemodeBrowserDownloadCollection,FR as CodemodeBrowserIdentityCollection,an as CodemodeBrowserLocator,ZR as CodemodeBrowserTab,HR as CodemodeBrowserTabCollection,wu as CodemodeClient,Iu as CodemodeComputer,eT as CodemodeComputerClipboard,QR as CodemodeComputerCollection,Ir as CodemodeComputerLocator,nT as CodemodeComputerTarget,tT as CodemodeComputerTargetCollection,Au as CodemodeOperationError,lT as CodemodeToolCallError,uT as CodemodeToolContractError,fo as CodemodeToolExecutionError,Je as CodemodeTransportError,BR as OpenGeniCodemode,O as callStructured,PG as codemodeArtifactIds,UR as codemodeClientProvider,z5 as codemodeDispatchSubject,I5 as collectIdPages,JG as compileCodemodeTools,M5 as createAttemptToolEnvironment,w5 as createCodemodeSiteRequestHandler,AG as createCodemodeTools,DG as createOpenGeniCodemode,U5 as decodeCodemodeDispatchAck,N5 as decodeCodemodeDispatchRequest,pT as digestAttemptToolCatalog,q5 as digestCodemodeOperationRequest,D5 as encodeCodemodeDispatchAck,j5 as encodeCodemodeDispatchRequest,on as environmentCodemodeClient,c5 as generateCodemodeDeclarations,XG as isTransientCodemodeTransportError,fu as jsonSchemaToTypeScript,Ai as materializeCodemodeImages,r5 as openGeni,Ci as parseVerifiedAttemptToolCatalog,k5 as planIdBatches,R5 as summarizeIdBatches,J9 as tools,hT as verifyAttemptToolCatalog};\n","package.json":"{\"type\":\"commonjs\"}\n"}}
1
+ {"version":1,"files":{"ogtool":"#!/usr/bin/env node\nvar{defineProperty:st,getOwnPropertyNames:Bi,getOwnPropertyDescriptor:Wi}=Object,Ki=Object.prototype.hasOwnProperty;function Hi(e){return this[e]}var Xi=(e)=>{var t=(so??=new WeakMap).get(e),o;if(t)return t;if(t=st({},\"__esModule\",{value:!0}),e&&typeof e===\"object\"||typeof e===\"function\"){for(var r of Bi(e))if(!Ki.call(t,r))st(t,r,{get:Hi.bind(e,r),enumerable:!(o=Wi(e,r))||o.enumerable})}return so.set(e,t),t},so;var Yi=(e)=>e;function Qi(e,t){this[e]=Yi.bind(null,t)}var ea=(e,t)=>{for(var o in t)st(e,o,{get:t[o],enumerable:!0,configurable:!0,set:Qi.bind(t,o)})};var Ru={};ea(Ru,{callOutput:()=>to,imageSaveFailureOutput:()=>Vi,listProjection:()=>eo,materializeCallImages:()=>oo,preflightImagePath:()=>Ui,resolveTool:()=>Qt,showOutput:()=>Fi});module.exports=Xi(Ru);var Li=require(\"node:crypto\"),P=require(\"node:fs\"),Se=require(\"node:path\");var Pi=require(\"node:crypto\");function x(e){return e()}var io;function l(e,t,o){function r(a,c){if(!a._zod)Object.defineProperty(a,\"_zod\",{value:{def:c,constr:s,traits:new Set},enumerable:!1});if(a._zod.traits.has(e))return;a._zod.traits.add(e),t(a,c);let u=s.prototype,p=Object.keys(u);for(let d=0;d<p.length;d++){let h=p[d];if(!(h in a))a[h]=u[h].bind(a)}}let n=o?.Parent??Object;class i extends n{}Object.defineProperty(i,\"name\",{value:e});function s(a){var c;let u=o?.Parent?new i:this;r(u,a),(c=u._zod).deferred??(c.deferred=[]);for(let p of u._zod.deferred)p();return u}return Object.defineProperty(s,\"init\",{value:r}),Object.defineProperty(s,Symbol.hasInstance,{value:(a)=>{if(o?.Parent&&a instanceof o.Parent)return!0;return a?._zod?.traits?.has(e)}}),Object.defineProperty(s,\"name\",{value:e}),s}var Du=Symbol(\"zod_brand\");class F extends Error{constructor(){super(\"Encountered Promise during synchronous parse. Use .parseAsync() instead.\")}}class de extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`);this.name=\"ZodEncodeError\"}}(io=globalThis).__zod_globalConfig??(io.__zod_globalConfig={});var ie=globalThis.__zod_globalConfig;function R(e){if(e)Object.assign(ie,e);return ie}function Oe(e){let t=Object.values(e).filter((r)=>typeof r===\"number\");return Object.entries(e).filter(([r,n])=>t.indexOf(+r)===-1).map(([r,n])=>n)}function me(e,t){if(typeof t===\"bigint\")return t.toString();return t}function fe(e){return{get value(){{let o=e();return Object.defineProperty(this,\"value\",{value:o}),o}throw Error(\"cached value already set\")}}}function Pe(e){return e===null||e===void 0}function Ie(e){let t=e.startsWith(\"^\")?1:0,o=e.endsWith(\"$\")?e.length-1:e.length;return e.slice(t,o)}function co(e,t){let o=e/t,r=Math.round(o),n=Number.EPSILON*Math.max(Math.abs(o),1);if(Math.abs(o-r)<n)return 0;return o-r}var ao=Symbol(\"evaluating\");function _(e,t,o){let r=void 0;Object.defineProperty(e,t,{get(){if(r===ao)return;if(r===void 0)r=ao,r=o();return r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function Q(e,t,o){Object.defineProperty(e,t,{value:o,writable:!0,enumerable:!0,configurable:!0})}function J(...e){let t={};for(let o of e){let r=Object.getOwnPropertyDescriptors(o);Object.assign(t,r)}return Object.defineProperties({},t)}function at(e){return JSON.stringify(e)}function uo(e){return e.toLowerCase().trim().replace(/[^\\w\\s-]/g,\"\").replace(/[\\s_-]+/g,\"-\").replace(/^-+|-+$/g,\"\")}var ct=\"captureStackTrace\"in Error?Error.captureStackTrace:(...e)=>{};function ae(e){return typeof e===\"object\"&&e!==null&&!Array.isArray(e)}var lo=fe(()=>{if(ie.jitless)return!1;if(typeof navigator<\"u\"&&navigator?.userAgent?.includes(\"Cloudflare\"))return!1;try{return new Function(\"\"),!0}catch(e){return!1}});function ee(e){if(ae(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;if(typeof t!==\"function\")return!0;let o=t.prototype;if(ae(o)===!1)return!1;if(Object.prototype.hasOwnProperty.call(o,\"isPrototypeOf\")===!1)return!1;return!0}function ut(e){if(ee(e))return{...e};if(Array.isArray(e))return[...e];if(e instanceof Map)return new Map(e);if(e instanceof Set)return new Set(e);return e}var po=new Set([\"string\",\"number\",\"symbol\"]);function q(e){return e.replace(/[.*+?^${}()|[\\]\\\\]/g,\"\\\\$&\")}function D(e,t,o){let r=new e._zod.constr(t??e._zod.def);if(!t||o?.parent)r._zod.parent=e;return r}function f(e){let t=e;if(!t)return{};if(typeof t===\"string\")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error(\"Cannot specify both `message` and `error` params\");t.error=t.message}if(delete t.message,typeof t.error===\"string\")return{...t,error:()=>t.error};return t}function mo(e){return Object.keys(e).filter((t)=>e[t]._zod.optin===\"optional\"&&e[t]._zod.optout===\"optional\")}var fo={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-340282346638528860000000000000000000000,340282346638528860000000000000000000000],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function ta(e,t){let o=e._zod.def,r=o.checks;if(r&&r.length>0)throw Error(\".pick() cannot be used on object schemas containing refinements\");let i=J(e._zod.def,{get shape(){let s={};for(let a in t){if(!(a in o.shape))throw Error(`Unrecognized key: \"${a}\"`);if(!t[a])continue;s[a]=o.shape[a]}return Q(this,\"shape\",s),s},checks:[]});return D(e,i)}function oa(e,t){let o=e._zod.def,r=o.checks;if(r&&r.length>0)throw Error(\".omit() cannot be used on object schemas containing refinements\");let i=J(e._zod.def,{get shape(){let s={...e._zod.def.shape};for(let a in t){if(!(a in o.shape))throw Error(`Unrecognized key: \"${a}\"`);if(!t[a])continue;delete s[a]}return Q(this,\"shape\",s),s},checks:[]});return D(e,i)}function ra(e,t){if(!ee(t))throw Error(\"Invalid input to extend: expected a plain object\");let o=e._zod.def.checks;if(o&&o.length>0){let i=e._zod.def.shape;for(let s in t)if(Object.getOwnPropertyDescriptor(i,s)!==void 0)throw Error(\"Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.\")}let n=J(e._zod.def,{get shape(){let i={...e._zod.def.shape,...t};return Q(this,\"shape\",i),i}});return D(e,n)}function na(e,t){if(!ee(t))throw Error(\"Invalid input to safeExtend: expected a plain object\");let o=J(e._zod.def,{get shape(){let r={...e._zod.def.shape,...t};return Q(this,\"shape\",r),r}});return D(e,o)}function sa(e,t){if(e._zod.def.checks?.length)throw Error(\".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.\");let o=J(e._zod.def,{get shape(){let r={...e._zod.def.shape,...t._zod.def.shape};return Q(this,\"shape\",r),r},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return D(e,o)}function ia(e,t,o){let n=t._zod.def.checks;if(n&&n.length>0)throw Error(\".partial() cannot be used on object schemas containing refinements\");let s=J(t._zod.def,{get shape(){let a=t._zod.def.shape,c={...a};if(o)for(let u in o){if(!(u in a))throw Error(`Unrecognized key: \"${u}\"`);if(!o[u])continue;c[u]=e?new e({type:\"optional\",innerType:a[u]}):a[u]}else for(let u in a)c[u]=e?new e({type:\"optional\",innerType:a[u]}):a[u];return Q(this,\"shape\",c),c},checks:[]});return D(t,s)}function aa(e,t,o){let r=J(t._zod.def,{get shape(){let n=t._zod.def.shape,i={...n};if(o)for(let s in o){if(!(s in i))throw Error(`Unrecognized key: \"${s}\"`);if(!o[s])continue;i[s]=new e({type:\"nonoptional\",innerType:n[s]})}else for(let s in n)i[s]=new e({type:\"nonoptional\",innerType:n[s]});return Q(this,\"shape\",i),i}});return D(t,r)}function te(e,t=0){if(e.aborted===!0)return!0;for(let o=t;o<e.issues.length;o++)if(e.issues[o]?.continue!==!0)return!0;return!1}function ho(e,t=0){if(e.aborted===!0)return!0;for(let o=t;o<e.issues.length;o++)if(e.issues[o]?.continue===!1)return!0;return!1}function B(e,t){return t.map((o)=>{var r;return(r=o).path??(r.path=[]),o.path.unshift(e),o})}function Ce(e){return typeof e===\"string\"?e:e?.message}function N(e,t,o){let r=e.message?e.message:Ce(e.inst?._zod.def?.error?.(e))??Ce(t?.error?.(e))??Ce(o.customError?.(e))??Ce(o.localeError?.(e))??\"Invalid input\",{inst:n,continue:i,input:s,...a}=e;if(a.path??(a.path=[]),a.message=r,t?.reportInput)a.input=s;return a}function Ze(e){if(Array.isArray(e))return\"array\";if(typeof e===\"string\")return\"string\";return\"unknown\"}function oe(...e){let[t,o,r]=e;if(typeof t===\"string\")return{message:t,code:\"custom\",input:o,inst:r};return{...t}}var go=(e,t)=>{e.name=\"$ZodError\",Object.defineProperty(e,\"_zod\",{value:e._zod,enumerable:!1}),Object.defineProperty(e,\"issues\",{value:t,enumerable:!1}),e.message=JSON.stringify(t,me,2),Object.defineProperty(e,\"toString\",{value:()=>e.message,enumerable:!1})},Re=l(\"$ZodError\",go),lt=l(\"$ZodError\",go,{Parent:Error});function yo(e,t=(o)=>o.message){let o={},r=[];for(let n of e.issues)if(n.path.length>0)o[n.path[0]]=o[n.path[0]]||[],o[n.path[0]].push(t(n));else r.push(t(n));return{formErrors:r,fieldErrors:o}}function _o(e,t=(o)=>o.message){let o={_errors:[]},r=(n,i=[])=>{for(let s of n.issues)if(s.code===\"invalid_union\"&&s.errors.length)s.errors.map((a)=>r({issues:a},[...i,...s.path]));else if(s.code===\"invalid_key\")r({issues:s.issues},[...i,...s.path]);else if(s.code===\"invalid_element\")r({issues:s.issues},[...i,...s.path]);else{let a=[...i,...s.path];if(a.length===0)o._errors.push(t(s));else{let c=o,u=0;while(u<a.length){let p=a[u];if(u!==a.length-1)c[p]=c[p]||{_errors:[]};else c[p]=c[p]||{_errors:[]},c[p]._errors.push(t(s));c=c[p],u++}}}};return r(e),o}var Ne=(e)=>(t,o,r,n)=>{let i=r?{...r,async:!1}:{async:!1},s=t._zod.run({value:o,issues:[]},i);if(s instanceof Promise)throw new F;if(s.issues.length){let a=new(n?.Err??e)(s.issues.map((c)=>N(c,i,R())));throw ct(a,n?.callee),a}return s.value};var je=(e)=>async(t,o,r,n)=>{let i=r?{...r,async:!0}:{async:!0},s=t._zod.run({value:o,issues:[]},i);if(s instanceof Promise)s=await s;if(s.issues.length){let a=new(n?.Err??e)(s.issues.map((c)=>N(c,i,R())));throw ct(a,n?.callee),a}return s.value};var he=(e)=>(t,o,r)=>{let n=r?{...r,async:!1}:{async:!1},i=t._zod.run({value:o,issues:[]},n);if(i instanceof Promise)throw new F;return i.issues.length?{success:!1,error:new(e??Re)(i.issues.map((s)=>N(s,n,R())))}:{success:!0,data:i.value}},xo=he(lt),ge=(e)=>async(t,o,r)=>{let n=r?{...r,async:!0}:{async:!0},i=t._zod.run({value:o,issues:[]},n);if(i instanceof Promise)i=await i;return i.issues.length?{success:!1,error:new e(i.issues.map((s)=>N(s,n,R())))}:{success:!0,data:i.value}},wo=ge(lt),bo=(e)=>(t,o,r)=>{let n=r?{...r,direction:\"backward\"}:{direction:\"backward\"};return Ne(e)(t,o,n)};var vo=(e)=>(t,o,r)=>Ne(e)(t,o,r);var zo=(e)=>async(t,o,r)=>{let n=r?{...r,direction:\"backward\"}:{direction:\"backward\"};return je(e)(t,o,n)};var $o=(e)=>async(t,o,r)=>je(e)(t,o,r);var To=(e)=>(t,o,r)=>{let n=r?{...r,direction:\"backward\"}:{direction:\"backward\"};return he(e)(t,o,n)};var ko=(e)=>(t,o,r)=>he(e)(t,o,r);var Ao=(e)=>async(t,o,r)=>{let n=r?{...r,direction:\"backward\"}:{direction:\"backward\"};return ge(e)(t,o,n)};var Eo=(e)=>async(t,o,r)=>ge(e)(t,o,r);var So=/^[cC][0-9a-z]{6,}$/,Co=/^[0-9a-z]+$/,Oo=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Po=/^[0-9a-vA-V]{20}$/,Io=/^[A-Za-z0-9]{27}$/,Zo=/^[a-zA-Z0-9_-]{21}$/,Ro=/^P(?:(\\d+W)|(?!.*W)(?=\\d|T\\d)(\\d+Y)?(\\d+M)?(\\d+D)?(T(?=\\d)(\\d+H)?(\\d+M)?(\\d+([.,]\\d+)?S)?)?)$/;var No=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,pt=(e)=>{if(!e)return/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`)};var jo=/^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$/;var ua=\"^(\\\\p{Extended_Pictographic}|\\\\p{Emoji_Component})+$\";function Do(){return new RegExp(ua,\"u\")}var Mo=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Lo=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;var Go=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\\/([0-9]|[1-2][0-9]|3[0-2])$/,Fo=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Uo=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,dt=/^[A-Za-z0-9_-]*$/;var Vo=/^https?$/,Jo=/^\\+[1-9]\\d{6,14}$/,qo=\"(?:(?:\\\\d\\\\d[2468][048]|\\\\d\\\\d[13579][26]|\\\\d\\\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\\\d|30)|(?:02)-(?:0[1-9]|1\\\\d|2[0-8])))\",Bo=new RegExp(`^${qo}$`);function Wo(e){return typeof e.precision===\"number\"?e.precision===-1?\"(?:[01]\\\\d|2[0-3]):[0-5]\\\\d\":e.precision===0?\"(?:[01]\\\\d|2[0-3]):[0-5]\\\\d:[0-5]\\\\d\":`(?:[01]\\\\d|2[0-3]):[0-5]\\\\d:[0-5]\\\\d\\\\.\\\\d{${e.precision}}`:\"(?:[01]\\\\d|2[0-3]):[0-5]\\\\d(?::[0-5]\\\\d(?:\\\\.\\\\d+)?)?\"}function Ko(e){return new RegExp(`^${Wo(e)}$`)}function Ho(e){let t=Wo({precision:e.precision}),o=[\"Z\"];if(e.local)o.push(\"\");if(e.offset)o.push(\"([+-](?:[01]\\\\d|2[0-3]):[0-5]\\\\d)\");let r=`${t}(?:${o.join(\"|\")})`;return new RegExp(`^${qo}T(?:${r})$`)}var Xo=(e)=>{let t=e?`[\\\\s\\\\S]{${e?.minimum??0},${e?.maximum??\"\"}}`:\"[\\\\s\\\\S]*\";return new RegExp(`^${t}$`)};var Yo=/^-?\\d+$/,mt=/^-?\\d+(?:\\.\\d+)?$/,Qo=/^(?:true|false)$/i,er=/^null$/i;var tr=/^[^A-Z]*$/,or=/^[^a-z]*$/;var S=l(\"$ZodCheck\",(e,t)=>{var o;e._zod??(e._zod={}),e._zod.def=t,(o=e._zod).onattach??(o.onattach=[])}),rr={number:\"number\",bigint:\"bigint\",object:\"date\"},ft=l(\"$ZodCheckLessThan\",(e,t)=>{S.init(e,t);let o=rr[typeof t.value];e._zod.onattach.push((r)=>{let n=r._zod.bag,i=(t.inclusive?n.maximum:n.exclusiveMaximum)??Number.POSITIVE_INFINITY;if(t.value<i)if(t.inclusive)n.maximum=t.value;else n.exclusiveMaximum=t.value}),e._zod.check=(r)=>{if(t.inclusive?r.value<=t.value:r.value<t.value)return;r.issues.push({origin:o,code:\"too_big\",maximum:typeof t.value===\"object\"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),ht=l(\"$ZodCheckGreaterThan\",(e,t)=>{S.init(e,t);let o=rr[typeof t.value];e._zod.onattach.push((r)=>{let n=r._zod.bag,i=(t.inclusive?n.minimum:n.exclusiveMinimum)??Number.NEGATIVE_INFINITY;if(t.value>i)if(t.inclusive)n.minimum=t.value;else n.exclusiveMinimum=t.value}),e._zod.check=(r)=>{if(t.inclusive?r.value>=t.value:r.value>t.value)return;r.issues.push({origin:o,code:\"too_small\",minimum:typeof t.value===\"object\"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),nr=l(\"$ZodCheckMultipleOf\",(e,t)=>{S.init(e,t),e._zod.onattach.push((o)=>{var r;(r=o._zod.bag).multipleOf??(r.multipleOf=t.value)}),e._zod.check=(o)=>{if(typeof o.value!==typeof t.value)throw Error(\"Cannot mix number and bigint in multiple_of check.\");if(typeof o.value===\"bigint\"?o.value%t.value===BigInt(0):co(o.value,t.value)===0)return;o.issues.push({origin:typeof o.value,code:\"not_multiple_of\",divisor:t.value,input:o.value,inst:e,continue:!t.abort})}}),sr=l(\"$ZodCheckNumberFormat\",(e,t)=>{S.init(e,t),t.format=t.format||\"float64\";let o=t.format?.includes(\"int\"),r=o?\"int\":\"number\",[n,i]=fo[t.format];e._zod.onattach.push((s)=>{let a=s._zod.bag;if(a.format=t.format,a.minimum=n,a.maximum=i,o)a.pattern=Yo}),e._zod.check=(s)=>{let a=s.value;if(o){if(!Number.isInteger(a)){s.issues.push({expected:r,format:t.format,code:\"invalid_type\",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){if(a>0)s.issues.push({input:a,code:\"too_big\",maximum:Number.MAX_SAFE_INTEGER,note:\"Integers must be within the safe integer range.\",inst:e,origin:r,inclusive:!0,continue:!t.abort});else s.issues.push({input:a,code:\"too_small\",minimum:Number.MIN_SAFE_INTEGER,note:\"Integers must be within the safe integer range.\",inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}if(a<n)s.issues.push({origin:\"number\",input:a,code:\"too_small\",minimum:n,inclusive:!0,inst:e,continue:!t.abort});if(a>i)s.issues.push({origin:\"number\",input:a,code:\"too_big\",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}});var ir=l(\"$ZodCheckMaxLength\",(e,t)=>{var o;S.init(e,t),(o=e._zod.def).when??(o.when=(r)=>{let n=r.value;return!Pe(n)&&n.length!==void 0}),e._zod.onattach.push((r)=>{let n=r._zod.bag.maximum??Number.POSITIVE_INFINITY;if(t.maximum<n)r._zod.bag.maximum=t.maximum}),e._zod.check=(r)=>{let n=r.value;if(n.length<=t.maximum)return;let s=Ze(n);r.issues.push({origin:s,code:\"too_big\",maximum:t.maximum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),ar=l(\"$ZodCheckMinLength\",(e,t)=>{var o;S.init(e,t),(o=e._zod.def).when??(o.when=(r)=>{let n=r.value;return!Pe(n)&&n.length!==void 0}),e._zod.onattach.push((r)=>{let n=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;if(t.minimum>n)r._zod.bag.minimum=t.minimum}),e._zod.check=(r)=>{let n=r.value;if(n.length>=t.minimum)return;let s=Ze(n);r.issues.push({origin:s,code:\"too_small\",minimum:t.minimum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),cr=l(\"$ZodCheckLengthEquals\",(e,t)=>{var o;S.init(e,t),(o=e._zod.def).when??(o.when=(r)=>{let n=r.value;return!Pe(n)&&n.length!==void 0}),e._zod.onattach.push((r)=>{let n=r._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=(r)=>{let n=r.value,i=n.length;if(i===t.length)return;let s=Ze(n),a=i>t.length;r.issues.push({origin:s,...a?{code:\"too_big\",maximum:t.length}:{code:\"too_small\",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),ye=l(\"$ZodCheckStringFormat\",(e,t)=>{var o,r;if(S.init(e,t),e._zod.onattach.push((n)=>{let i=n._zod.bag;if(i.format=t.format,t.pattern)i.patterns??(i.patterns=new Set),i.patterns.add(t.pattern)}),t.pattern)(o=e._zod).check??(o.check=(n)=>{if(t.pattern.lastIndex=0,t.pattern.test(n.value))return;n.issues.push({origin:\"string\",code:\"invalid_format\",format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})});else(r=e._zod).check??(r.check=()=>{})}),ur=l(\"$ZodCheckRegex\",(e,t)=>{ye.init(e,t),e._zod.check=(o)=>{if(t.pattern.lastIndex=0,t.pattern.test(o.value))return;o.issues.push({origin:\"string\",code:\"invalid_format\",format:\"regex\",input:o.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),lr=l(\"$ZodCheckLowerCase\",(e,t)=>{t.pattern??(t.pattern=tr),ye.init(e,t)}),pr=l(\"$ZodCheckUpperCase\",(e,t)=>{t.pattern??(t.pattern=or),ye.init(e,t)}),dr=l(\"$ZodCheckIncludes\",(e,t)=>{S.init(e,t);let o=q(t.includes),r=new RegExp(typeof t.position===\"number\"?`^.{${t.position}}${o}`:o);t.pattern=r,e._zod.onattach.push((n)=>{let i=n._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(r)}),e._zod.check=(n)=>{if(n.value.includes(t.includes,t.position))return;n.issues.push({origin:\"string\",code:\"invalid_format\",format:\"includes\",includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),mr=l(\"$ZodCheckStartsWith\",(e,t)=>{S.init(e,t);let o=new RegExp(`^${q(t.prefix)}.*`);t.pattern??(t.pattern=o),e._zod.onattach.push((r)=>{let n=r._zod.bag;n.patterns??(n.patterns=new Set),n.patterns.add(o)}),e._zod.check=(r)=>{if(r.value.startsWith(t.prefix))return;r.issues.push({origin:\"string\",code:\"invalid_format\",format:\"starts_with\",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),fr=l(\"$ZodCheckEndsWith\",(e,t)=>{S.init(e,t);let o=new RegExp(`.*${q(t.suffix)}$`);t.pattern??(t.pattern=o),e._zod.onattach.push((r)=>{let n=r._zod.bag;n.patterns??(n.patterns=new Set),n.patterns.add(o)}),e._zod.check=(r)=>{if(r.value.endsWith(t.suffix))return;r.issues.push({origin:\"string\",code:\"invalid_format\",format:\"ends_with\",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}});var hr=l(\"$ZodCheckOverwrite\",(e,t)=>{S.init(e,t),e._zod.check=(o)=>{o.value=t.tx(o.value)}});class gt{constructor(e=[]){if(this.content=[],this.indent=0,this)this.args=e}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if(typeof e===\"function\"){e(this,{execution:\"sync\"}),e(this,{execution:\"async\"});return}let o=e.split(`\n`).filter((i)=>i),r=Math.min(...o.map((i)=>i.length-i.trimStart().length)),n=o.map((i)=>i.slice(r)).map((i)=>\" \".repeat(this.indent*2)+i);for(let i of n)this.content.push(i)}compile(){let e=Function,t=this?.args,r=[...(this?.content??[\"\"]).map((n)=>` ${n}`)];return new e(...t,r.join(`\n`))}}var yr={major:4,minor:4,patch:3};var w=l(\"$ZodType\",(e,t)=>{var o;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=yr;let r=[...e._zod.def.checks??[]];if(e._zod.traits.has(\"$ZodCheck\"))r.unshift(e);for(let n of r)for(let i of n._zod.onattach)i(e);if(r.length===0)(o=e._zod).deferred??(o.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let n=(s,a,c)=>{let u=te(s),p;for(let d of a){if(d._zod.def.when){if(ho(s))continue;if(!d._zod.def.when(s))continue}else if(u)continue;let h=s.issues.length,m=d._zod.check(s);if(m instanceof Promise&&c?.async===!1)throw new F;if(p||m instanceof Promise)p=(p??Promise.resolve()).then(async()=>{if(await m,s.issues.length===h)return;if(!u)u=te(s,h)});else{if(s.issues.length===h)continue;if(!u)u=te(s,h)}}if(p)return p.then(()=>s);return s},i=(s,a,c)=>{if(te(s))return s.aborted=!0,s;let u=n(a,r,c);if(u instanceof Promise){if(c.async===!1)throw new F;return u.then((p)=>e._zod.parse(p,c))}return e._zod.parse(u,c)};e._zod.run=(s,a)=>{if(a.skipChecks)return e._zod.parse(s,a);if(a.direction===\"backward\"){let u=e._zod.parse({value:s.value,issues:[]},{...a,skipChecks:!0});if(u instanceof Promise)return u.then((p)=>i(p,s,a));return i(u,s,a)}let c=e._zod.parse(s,a);if(c instanceof Promise){if(a.async===!1)throw new F;return c.then((u)=>n(u,r,a))}return n(c,r,a)}}_(e,\"~standard\",()=>({validate:(n)=>{try{let i=xo(e,n);return i.success?{value:i.data}:{issues:i.error?.issues}}catch(i){return wo(e,n).then((s)=>s.success?{value:s.data}:{issues:s.error?.issues})}},vendor:\"zod\",version:1}))}),Ge=l(\"$ZodString\",(e,t)=>{w.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Xo(e._zod.bag),e._zod.parse=(o,r)=>{if(t.coerce)try{o.value=String(o.value)}catch(n){}if(typeof o.value===\"string\")return o;return o.issues.push({expected:\"string\",code:\"invalid_type\",input:o.value,inst:e}),o}}),b=l(\"$ZodStringFormat\",(e,t)=>{ye.init(e,t),Ge.init(e,t)}),kr=l(\"$ZodGUID\",(e,t)=>{t.pattern??(t.pattern=No),b.init(e,t)}),Ar=l(\"$ZodUUID\",(e,t)=>{if(t.version){let r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(r===void 0)throw Error(`Invalid UUID version: \"${t.version}\"`);t.pattern??(t.pattern=pt(r))}else t.pattern??(t.pattern=pt());b.init(e,t)}),Er=l(\"$ZodEmail\",(e,t)=>{t.pattern??(t.pattern=jo),b.init(e,t)}),Sr=l(\"$ZodURL\",(e,t)=>{b.init(e,t),e._zod.check=(o)=>{try{let r=o.value.trim();if(!t.normalize&&t.protocol?.source===Vo.source){if(!/^https?:\\/\\//i.test(r)){o.issues.push({code:\"invalid_format\",format:\"url\",note:\"Invalid URL format\",input:o.value,inst:e,continue:!t.abort});return}}let n=new URL(r);if(t.hostname){if(t.hostname.lastIndex=0,!t.hostname.test(n.hostname))o.issues.push({code:\"invalid_format\",format:\"url\",note:\"Invalid hostname\",pattern:t.hostname.source,input:o.value,inst:e,continue:!t.abort})}if(t.protocol){if(t.protocol.lastIndex=0,!t.protocol.test(n.protocol.endsWith(\":\")?n.protocol.slice(0,-1):n.protocol))o.issues.push({code:\"invalid_format\",format:\"url\",note:\"Invalid protocol\",pattern:t.protocol.source,input:o.value,inst:e,continue:!t.abort})}if(t.normalize)o.value=n.href;else o.value=r;return}catch(r){o.issues.push({code:\"invalid_format\",format:\"url\",input:o.value,inst:e,continue:!t.abort})}}}),Cr=l(\"$ZodEmoji\",(e,t)=>{t.pattern??(t.pattern=Do()),b.init(e,t)}),Or=l(\"$ZodNanoID\",(e,t)=>{t.pattern??(t.pattern=Zo),b.init(e,t)}),Pr=l(\"$ZodCUID\",(e,t)=>{t.pattern??(t.pattern=So),b.init(e,t)}),Ir=l(\"$ZodCUID2\",(e,t)=>{t.pattern??(t.pattern=Co),b.init(e,t)}),Zr=l(\"$ZodULID\",(e,t)=>{t.pattern??(t.pattern=Oo),b.init(e,t)}),Rr=l(\"$ZodXID\",(e,t)=>{t.pattern??(t.pattern=Po),b.init(e,t)}),Nr=l(\"$ZodKSUID\",(e,t)=>{t.pattern??(t.pattern=Io),b.init(e,t)}),jr=l(\"$ZodISODateTime\",(e,t)=>{t.pattern??(t.pattern=Ho(t)),b.init(e,t)}),Dr=l(\"$ZodISODate\",(e,t)=>{t.pattern??(t.pattern=Bo),b.init(e,t)}),Mr=l(\"$ZodISOTime\",(e,t)=>{t.pattern??(t.pattern=Ko(t)),b.init(e,t)}),Lr=l(\"$ZodISODuration\",(e,t)=>{t.pattern??(t.pattern=Ro),b.init(e,t)}),Gr=l(\"$ZodIPv4\",(e,t)=>{t.pattern??(t.pattern=Mo),b.init(e,t),e._zod.bag.format=\"ipv4\"}),Fr=l(\"$ZodIPv6\",(e,t)=>{t.pattern??(t.pattern=Lo),b.init(e,t),e._zod.bag.format=\"ipv6\",e._zod.check=(o)=>{try{new URL(`http://[${o.value}]`)}catch{o.issues.push({code:\"invalid_format\",format:\"ipv6\",input:o.value,inst:e,continue:!t.abort})}}});var Ur=l(\"$ZodCIDRv4\",(e,t)=>{t.pattern??(t.pattern=Go),b.init(e,t)}),Vr=l(\"$ZodCIDRv6\",(e,t)=>{t.pattern??(t.pattern=Fo),b.init(e,t),e._zod.check=(o)=>{let r=o.value.split(\"/\");try{if(r.length!==2)throw Error();let[n,i]=r;if(!i)throw Error();let s=Number(i);if(`${s}`!==i)throw Error();if(s<0||s>128)throw Error();new URL(`http://[${n}]`)}catch{o.issues.push({code:\"invalid_format\",format:\"cidrv6\",input:o.value,inst:e,continue:!t.abort})}}});function Jr(e){if(e===\"\")return!0;if(/\\s/.test(e))return!1;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var qr=l(\"$ZodBase64\",(e,t)=>{t.pattern??(t.pattern=Uo),b.init(e,t),e._zod.bag.contentEncoding=\"base64\",e._zod.check=(o)=>{if(Jr(o.value))return;o.issues.push({code:\"invalid_format\",format:\"base64\",input:o.value,inst:e,continue:!t.abort})}});function la(e){if(!dt.test(e))return!1;let t=e.replace(/[-_]/g,(r)=>r===\"-\"?\"+\":\"/\"),o=t.padEnd(Math.ceil(t.length/4)*4,\"=\");return Jr(o)}var Br=l(\"$ZodBase64URL\",(e,t)=>{t.pattern??(t.pattern=dt),b.init(e,t),e._zod.bag.contentEncoding=\"base64url\",e._zod.check=(o)=>{if(la(o.value))return;o.issues.push({code:\"invalid_format\",format:\"base64url\",input:o.value,inst:e,continue:!t.abort})}}),Wr=l(\"$ZodE164\",(e,t)=>{t.pattern??(t.pattern=Jo),b.init(e,t)});function pa(e,t=null){try{let o=e.split(\".\");if(o.length!==3)return!1;let[r]=o;if(!r)return!1;let n=JSON.parse(atob(r));if(\"typ\"in n&&n?.typ!==\"JWT\")return!1;if(!n.alg)return!1;if(t&&(!(\"alg\"in n)||n.alg!==t))return!1;return!0}catch{return!1}}var Kr=l(\"$ZodJWT\",(e,t)=>{b.init(e,t),e._zod.check=(o)=>{if(pa(o.value,t.alg))return;o.issues.push({code:\"invalid_format\",format:\"jwt\",input:o.value,inst:e,continue:!t.abort})}});var _t=l(\"$ZodNumber\",(e,t)=>{w.init(e,t),e._zod.pattern=e._zod.bag.pattern??mt,e._zod.parse=(o,r)=>{if(t.coerce)try{o.value=Number(o.value)}catch(s){}let n=o.value;if(typeof n===\"number\"&&!Number.isNaN(n)&&Number.isFinite(n))return o;let i=typeof n===\"number\"?Number.isNaN(n)?\"NaN\":!Number.isFinite(n)?\"Infinity\":void 0:void 0;return o.issues.push({expected:\"number\",code:\"invalid_type\",input:n,inst:e,...i?{received:i}:{}}),o}}),Hr=l(\"$ZodNumberFormat\",(e,t)=>{sr.init(e,t),_t.init(e,t)}),Xr=l(\"$ZodBoolean\",(e,t)=>{w.init(e,t),e._zod.pattern=Qo,e._zod.parse=(o,r)=>{if(t.coerce)try{o.value=Boolean(o.value)}catch(i){}let n=o.value;if(typeof n===\"boolean\")return o;return o.issues.push({expected:\"boolean\",code:\"invalid_type\",input:n,inst:e}),o}});var Yr=l(\"$ZodNull\",(e,t)=>{w.init(e,t),e._zod.pattern=er,e._zod.values=new Set([null]),e._zod.parse=(o,r)=>{let n=o.value;if(n===null)return o;return o.issues.push({expected:\"null\",code:\"invalid_type\",input:n,inst:e}),o}});var Qr=l(\"$ZodUnknown\",(e,t)=>{w.init(e,t),e._zod.parse=(o)=>o}),en=l(\"$ZodNever\",(e,t)=>{w.init(e,t),e._zod.parse=(o,r)=>(o.issues.push({expected:\"never\",code:\"invalid_type\",input:o.value,inst:e}),o)});function _r(e,t,o){if(e.issues.length)t.issues.push(...B(o,e.issues));t.value[o]=e.value}var tn=l(\"$ZodArray\",(e,t)=>{w.init(e,t),e._zod.parse=(o,r)=>{let n=o.value;if(!Array.isArray(n))return o.issues.push({expected:\"array\",code:\"invalid_type\",input:n,inst:e}),o;o.value=Array(n.length);let i=[];for(let s=0;s<n.length;s++){let a=n[s],c=t.element._zod.run({value:a,issues:[]},r);if(c instanceof Promise)i.push(c.then((u)=>_r(u,o,s)));else _r(c,o,s)}if(i.length)return Promise.all(i).then(()=>o);return o}});function Le(e,t,o,r,n,i){let s=o in r;if(e.issues.length){if(n&&i&&!s)return;t.issues.push(...B(o,e.issues))}if(!s&&!n){if(!e.issues.length)t.issues.push({code:\"invalid_type\",expected:\"nonoptional\",input:void 0,path:[o]});return}if(e.value===void 0){if(s)t.value[o]=void 0}else t.value[o]=e.value}function on(e){let t=Object.keys(e.shape);for(let r of t)if(!e.shape?.[r]?._zod?.traits?.has(\"$ZodType\"))throw Error(`Invalid element at key \"${r}\": expected a Zod schema`);let o=mo(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(o)}}function rn(e,t,o,r,n,i){let s=[],a=n.keySet,c=n.catchall._zod,u=c.def.type,p=c.optin===\"optional\",d=c.optout===\"optional\";for(let h in t){if(h===\"__proto__\")continue;if(a.has(h))continue;if(u===\"never\"){s.push(h);continue}let m=c.run({value:t[h],issues:[]},r);if(m instanceof Promise)e.push(m.then((y)=>Le(y,o,h,t,p,d)));else Le(m,o,h,t,p,d)}if(s.length)o.issues.push({code:\"unrecognized_keys\",keys:s,input:t,inst:i});if(!e.length)return o;return Promise.all(e).then(()=>o)}var da=l(\"$ZodObject\",(e,t)=>{if(w.init(e,t),!Object.getOwnPropertyDescriptor(t,\"shape\")?.get){let a=t.shape;Object.defineProperty(t,\"shape\",{get:()=>{let c={...a};return Object.defineProperty(t,\"shape\",{value:c}),c}})}let r=fe(()=>on(t));_(e._zod,\"propValues\",()=>{let a=t.shape,c={};for(let u in a){let p=a[u]._zod;if(p.values){c[u]??(c[u]=new Set);for(let d of p.values)c[u].add(d)}}return c});let n=ae,i=t.catchall,s;e._zod.parse=(a,c)=>{s??(s=r.value);let u=a.value;if(!n(u))return a.issues.push({expected:\"object\",code:\"invalid_type\",input:u,inst:e}),a;a.value={};let p=[],d=s.shape;for(let h of s.keys){let m=d[h],y=m._zod.optin===\"optional\",G=m._zod.optout===\"optional\",A=m._zod.run({value:u[h],issues:[]},c);if(A instanceof Promise)p.push(A.then((nt)=>Le(nt,a,h,u,y,G)));else Le(A,a,h,u,y,G)}if(!i)return p.length?Promise.all(p).then(()=>a):a;return rn(p,u,a,c,r.value,e)}}),nn=l(\"$ZodObjectJIT\",(e,t)=>{da.init(e,t);let o=e._zod.parse,r=fe(()=>on(t)),n=(h)=>{let m=new gt([\"shape\",\"payload\",\"ctx\"]),y=r.value,G=(j)=>{let T=at(j);return`shape[${T}]._zod.run({ value: input[${T}], issues: [] }, ctx)`};m.write(\"const input = payload.value;\");let A=Object.create(null),nt=0;for(let j of y.keys)A[j]=`key_${nt++}`;m.write(\"const newResult = {};\");for(let j of y.keys){let T=A[j],E=at(j),ro=h[j],no=ro?._zod?.optin===\"optional\",qi=ro?._zod?.optout===\"optional\";if(m.write(`const ${T} = ${G(j)};`),no&&qi)m.write(`\n if (${T}.issues.length) {\n if (${E} in input) {\n payload.issues = payload.issues.concat(${T}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${E}, ...iss.path] : [${E}]\n })));\n }\n }\n \n if (${T}.value === undefined) {\n if (${E} in input) {\n newResult[${E}] = undefined;\n }\n } else {\n newResult[${E}] = ${T}.value;\n }\n \n `);else if(!no)m.write(`\n const ${T}_present = ${E} in input;\n if (${T}.issues.length) {\n payload.issues = payload.issues.concat(${T}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${E}, ...iss.path] : [${E}]\n })));\n }\n if (!${T}_present && !${T}.issues.length) {\n payload.issues.push({\n code: \"invalid_type\",\n expected: \"nonoptional\",\n input: undefined,\n path: [${E}]\n });\n }\n\n if (${T}_present) {\n if (${T}.value === undefined) {\n newResult[${E}] = undefined;\n } else {\n newResult[${E}] = ${T}.value;\n }\n }\n\n `);else m.write(`\n if (${T}.issues.length) {\n payload.issues = payload.issues.concat(${T}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${E}, ...iss.path] : [${E}]\n })));\n }\n \n if (${T}.value === undefined) {\n if (${E} in input) {\n newResult[${E}] = undefined;\n }\n } else {\n newResult[${E}] = ${T}.value;\n }\n \n `)}m.write(\"payload.value = newResult;\"),m.write(\"return payload;\");let Ji=m.compile();return(j,T)=>Ji(h,j,T)},i,s=ae,a=!ie.jitless,u=a&&lo.value,p=t.catchall,d;e._zod.parse=(h,m)=>{d??(d=r.value);let y=h.value;if(!s(y))return h.issues.push({expected:\"object\",code:\"invalid_type\",input:y,inst:e}),h;if(a&&u&&m?.async===!1&&m.jitless!==!0){if(!i)i=n(t.shape);if(h=i(h,m),!p)return h;return rn([],y,h,m,d,e)}return o(h,m)}});function xr(e,t,o,r){for(let i of e)if(i.issues.length===0)return t.value=i.value,t;let n=e.filter((i)=>!te(i));if(n.length===1)return t.value=n[0].value,n[0];return t.issues.push({code:\"invalid_union\",input:t.value,inst:o,errors:e.map((i)=>i.issues.map((s)=>N(s,r,R())))}),t}var xt=l(\"$ZodUnion\",(e,t)=>{w.init(e,t),_(e._zod,\"optin\",()=>t.options.some((r)=>r._zod.optin===\"optional\")?\"optional\":void 0),_(e._zod,\"optout\",()=>t.options.some((r)=>r._zod.optout===\"optional\")?\"optional\":void 0),_(e._zod,\"values\",()=>{if(t.options.every((r)=>r._zod.values))return new Set(t.options.flatMap((r)=>Array.from(r._zod.values)));return}),_(e._zod,\"pattern\",()=>{if(t.options.every((r)=>r._zod.pattern)){let r=t.options.map((n)=>n._zod.pattern);return new RegExp(`^(${r.map((n)=>Ie(n.source)).join(\"|\")})$`)}return});let o=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,n)=>{if(o)return o(r,n);let i=!1,s=[];for(let a of t.options){let c=a._zod.run({value:r.value,issues:[]},n);if(c instanceof Promise)s.push(c),i=!0;else{if(c.issues.length===0)return c;s.push(c)}}if(!i)return xr(s,r,e,n);return Promise.all(s).then((a)=>xr(a,r,e,n))}});var sn=l(\"$ZodDiscriminatedUnion\",(e,t)=>{t.inclusive=!1,xt.init(e,t);let o=e._zod.parse;_(e._zod,\"propValues\",()=>{let n={};for(let i of t.options){let s=i._zod.propValues;if(!s||Object.keys(s).length===0)throw Error(`Invalid discriminated union option at index \"${t.options.indexOf(i)}\"`);for(let[a,c]of Object.entries(s)){if(!n[a])n[a]=new Set;for(let u of c)n[a].add(u)}}return n});let r=fe(()=>{let n=t.options,i=new Map;for(let s of n){let a=s._zod.propValues?.[t.discriminator];if(!a||a.size===0)throw Error(`Invalid discriminated union option at index \"${t.options.indexOf(s)}\"`);for(let c of a){if(i.has(c))throw Error(`Duplicate discriminator value \"${String(c)}\"`);i.set(c,s)}}return i});e._zod.parse=(n,i)=>{let s=n.value;if(!ae(s))return n.issues.push({code:\"invalid_type\",expected:\"object\",input:s,inst:e}),n;let a=r.value.get(s?.[t.discriminator]);if(a)return a._zod.run(n,i);if(t.unionFallback||i.direction===\"backward\")return o(n,i);return n.issues.push({code:\"invalid_union\",errors:[],note:\"No matching discriminator\",discriminator:t.discriminator,options:Array.from(r.value.keys()),input:s,path:[t.discriminator],inst:e}),n}}),an=l(\"$ZodIntersection\",(e,t)=>{w.init(e,t),e._zod.parse=(o,r)=>{let n=o.value,i=t.left._zod.run({value:n,issues:[]},r),s=t.right._zod.run({value:n,issues:[]},r);if(i instanceof Promise||s instanceof Promise)return Promise.all([i,s]).then(([c,u])=>wr(o,c,u));return wr(o,i,s)}});function yt(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e===+t)return{valid:!0,data:e};if(ee(e)&&ee(t)){let o=Object.keys(t),r=Object.keys(e).filter((i)=>o.indexOf(i)!==-1),n={...e,...t};for(let i of r){let s=yt(e[i],t[i]);if(!s.valid)return{valid:!1,mergeErrorPath:[i,...s.mergeErrorPath]};n[i]=s.data}return{valid:!0,data:n}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let o=[];for(let r=0;r<e.length;r++){let n=e[r],i=t[r],s=yt(n,i);if(!s.valid)return{valid:!1,mergeErrorPath:[r,...s.mergeErrorPath]};o.push(s.data)}return{valid:!0,data:o}}return{valid:!1,mergeErrorPath:[]}}function wr(e,t,o){let r=new Map,n;for(let a of t.issues)if(a.code===\"unrecognized_keys\"){n??(n=a);for(let c of a.keys){if(!r.has(c))r.set(c,{});r.get(c).l=!0}}else e.issues.push(a);for(let a of o.issues)if(a.code===\"unrecognized_keys\")for(let c of a.keys){if(!r.has(c))r.set(c,{});r.get(c).r=!0}else e.issues.push(a);let i=[...r].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(i.length&&n)e.issues.push({...n,keys:i});if(te(e))return e;let s=yt(t.value,o.value);if(!s.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(s.mergeErrorPath)}`);return e.value=s.data,e}var cn=l(\"$ZodRecord\",(e,t)=>{w.init(e,t),e._zod.parse=(o,r)=>{let n=o.value;if(!ee(n))return o.issues.push({expected:\"record\",code:\"invalid_type\",input:n,inst:e}),o;let i=[],s=t.keyType._zod.values;if(s){o.value={};let a=new Set;for(let u of s)if(typeof u===\"string\"||typeof u===\"number\"||typeof u===\"symbol\"){a.add(typeof u===\"number\"?u.toString():u);let p=t.keyType._zod.run({value:u,issues:[]},r);if(p instanceof Promise)throw Error(\"Async schemas not supported in object keys currently\");if(p.issues.length){o.issues.push({code:\"invalid_key\",origin:\"record\",issues:p.issues.map((m)=>N(m,r,R())),input:u,path:[u],inst:e});continue}let d=p.value,h=t.valueType._zod.run({value:n[u],issues:[]},r);if(h instanceof Promise)i.push(h.then((m)=>{if(m.issues.length)o.issues.push(...B(u,m.issues));o.value[d]=m.value}));else{if(h.issues.length)o.issues.push(...B(u,h.issues));o.value[d]=h.value}}let c;for(let u in n)if(!a.has(u))c=c??[],c.push(u);if(c&&c.length>0)o.issues.push({code:\"unrecognized_keys\",input:n,inst:e,keys:c})}else{o.value={};for(let a of Reflect.ownKeys(n)){if(a===\"__proto__\")continue;if(!Object.prototype.propertyIsEnumerable.call(n,a))continue;let c=t.keyType._zod.run({value:a,issues:[]},r);if(c instanceof Promise)throw Error(\"Async schemas not supported in object keys currently\");if(typeof a===\"string\"&&mt.test(a)&&c.issues.length){let d=t.keyType._zod.run({value:Number(a),issues:[]},r);if(d instanceof Promise)throw Error(\"Async schemas not supported in object keys currently\");if(d.issues.length===0)c=d}if(c.issues.length){if(t.mode===\"loose\")o.value[a]=n[a];else o.issues.push({code:\"invalid_key\",origin:\"record\",issues:c.issues.map((d)=>N(d,r,R())),input:a,path:[a],inst:e});continue}let p=t.valueType._zod.run({value:n[a],issues:[]},r);if(p instanceof Promise)i.push(p.then((d)=>{if(d.issues.length)o.issues.push(...B(a,d.issues));o.value[c.value]=d.value}));else{if(p.issues.length)o.issues.push(...B(a,p.issues));o.value[c.value]=p.value}}}if(i.length)return Promise.all(i).then(()=>o);return o}});var un=l(\"$ZodEnum\",(e,t)=>{w.init(e,t);let o=Oe(t.entries),r=new Set(o);e._zod.values=r,e._zod.pattern=new RegExp(`^(${o.filter((n)=>po.has(typeof n)).map((n)=>typeof n===\"string\"?q(n):n.toString()).join(\"|\")})$`),e._zod.parse=(n,i)=>{let s=n.value;if(r.has(s))return n;return n.issues.push({code:\"invalid_value\",values:o,input:s,inst:e}),n}}),ln=l(\"$ZodLiteral\",(e,t)=>{if(w.init(e,t),t.values.length===0)throw Error(\"Cannot create literal schema with no valid values\");let o=new Set(t.values);e._zod.values=o,e._zod.pattern=new RegExp(`^(${t.values.map((r)=>typeof r===\"string\"?q(r):r?q(r.toString()):String(r)).join(\"|\")})$`),e._zod.parse=(r,n)=>{let i=r.value;if(o.has(i))return r;return r.issues.push({code:\"invalid_value\",values:t.values,input:i,inst:e}),r}});var pn=l(\"$ZodTransform\",(e,t)=>{w.init(e,t),e._zod.optin=\"optional\",e._zod.parse=(o,r)=>{if(r.direction===\"backward\")throw new de(e.constructor.name);let n=t.transform(o.value,o);if(r.async)return(n instanceof Promise?n:Promise.resolve(n)).then((s)=>(o.value=s,o.fallback=!0,o));if(n instanceof Promise)throw new F;return o.value=n,o.fallback=!0,o}});function br(e,t){if(t===void 0&&(e.issues.length||e.fallback))return{issues:[],value:void 0};return e}var wt=l(\"$ZodOptional\",(e,t)=>{w.init(e,t),e._zod.optin=\"optional\",e._zod.optout=\"optional\",_(e._zod,\"values\",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),_(e._zod,\"pattern\",()=>{let o=t.innerType._zod.pattern;return o?new RegExp(`^(${Ie(o.source)})?$`):void 0}),e._zod.parse=(o,r)=>{if(t.innerType._zod.optin===\"optional\"){let n=o.value,i=t.innerType._zod.run(o,r);if(i instanceof Promise)return i.then((s)=>br(s,n));return br(i,n)}if(o.value===void 0)return o;return t.innerType._zod.run(o,r)}}),dn=l(\"$ZodExactOptional\",(e,t)=>{wt.init(e,t),_(e._zod,\"values\",()=>t.innerType._zod.values),_(e._zod,\"pattern\",()=>t.innerType._zod.pattern),e._zod.parse=(o,r)=>t.innerType._zod.run(o,r)}),mn=l(\"$ZodNullable\",(e,t)=>{w.init(e,t),_(e._zod,\"optin\",()=>t.innerType._zod.optin),_(e._zod,\"optout\",()=>t.innerType._zod.optout),_(e._zod,\"pattern\",()=>{let o=t.innerType._zod.pattern;return o?new RegExp(`^(${Ie(o.source)}|null)$`):void 0}),_(e._zod,\"values\",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(o,r)=>{if(o.value===null)return o;return t.innerType._zod.run(o,r)}}),fn=l(\"$ZodDefault\",(e,t)=>{w.init(e,t),e._zod.optin=\"optional\",_(e._zod,\"values\",()=>t.innerType._zod.values),e._zod.parse=(o,r)=>{if(r.direction===\"backward\")return t.innerType._zod.run(o,r);if(o.value===void 0)return o.value=t.defaultValue,o;let n=t.innerType._zod.run(o,r);if(n instanceof Promise)return n.then((i)=>vr(i,t));return vr(n,t)}});function vr(e,t){if(e.value===void 0)e.value=t.defaultValue;return e}var hn=l(\"$ZodPrefault\",(e,t)=>{w.init(e,t),e._zod.optin=\"optional\",_(e._zod,\"values\",()=>t.innerType._zod.values),e._zod.parse=(o,r)=>{if(r.direction===\"backward\")return t.innerType._zod.run(o,r);if(o.value===void 0)o.value=t.defaultValue;return t.innerType._zod.run(o,r)}}),gn=l(\"$ZodNonOptional\",(e,t)=>{w.init(e,t),_(e._zod,\"values\",()=>{let o=t.innerType._zod.values;return o?new Set([...o].filter((r)=>r!==void 0)):void 0}),e._zod.parse=(o,r)=>{let n=t.innerType._zod.run(o,r);if(n instanceof Promise)return n.then((i)=>zr(i,e));return zr(n,e)}});function zr(e,t){if(!e.issues.length&&e.value===void 0)e.issues.push({code:\"invalid_type\",expected:\"nonoptional\",input:e.value,inst:t});return e}var yn=l(\"$ZodCatch\",(e,t)=>{w.init(e,t),e._zod.optin=\"optional\",_(e._zod,\"optout\",()=>t.innerType._zod.optout),_(e._zod,\"values\",()=>t.innerType._zod.values),e._zod.parse=(o,r)=>{if(r.direction===\"backward\")return t.innerType._zod.run(o,r);let n=t.innerType._zod.run(o,r);if(n instanceof Promise)return n.then((i)=>{if(o.value=i.value,i.issues.length)o.value=t.catchValue({...o,error:{issues:i.issues.map((s)=>N(s,r,R()))},input:o.value}),o.issues=[],o.fallback=!0;return o});if(o.value=n.value,n.issues.length)o.value=t.catchValue({...o,error:{issues:n.issues.map((i)=>N(i,r,R()))},input:o.value}),o.issues=[],o.fallback=!0;return o}});var _n=l(\"$ZodPipe\",(e,t)=>{w.init(e,t),_(e._zod,\"values\",()=>t.in._zod.values),_(e._zod,\"optin\",()=>t.in._zod.optin),_(e._zod,\"optout\",()=>t.out._zod.optout),_(e._zod,\"propValues\",()=>t.in._zod.propValues),e._zod.parse=(o,r)=>{if(r.direction===\"backward\"){let i=t.out._zod.run(o,r);if(i instanceof Promise)return i.then((s)=>Me(s,t.in,r));return Me(i,t.in,r)}let n=t.in._zod.run(o,r);if(n instanceof Promise)return n.then((i)=>Me(i,t.out,r));return Me(n,t.out,r)}});function Me(e,t,o){if(e.issues.length)return e.aborted=!0,e;return t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},o)}var xn=l(\"$ZodReadonly\",(e,t)=>{w.init(e,t),_(e._zod,\"propValues\",()=>t.innerType._zod.propValues),_(e._zod,\"values\",()=>t.innerType._zod.values),_(e._zod,\"optin\",()=>t.innerType?._zod?.optin),_(e._zod,\"optout\",()=>t.innerType?._zod?.optout),e._zod.parse=(o,r)=>{if(r.direction===\"backward\")return t.innerType._zod.run(o,r);let n=t.innerType._zod.run(o,r);if(n instanceof Promise)return n.then($r);return $r(n)}});function $r(e){return e.value=Object.freeze(e.value),e}var wn=l(\"$ZodLazy\",(e,t)=>{w.init(e,t),_(e._zod,\"innerType\",()=>{let o=t;if(!o._cachedInner)o._cachedInner=t.getter();return o._cachedInner}),_(e._zod,\"pattern\",()=>e._zod.innerType?._zod?.pattern),_(e._zod,\"propValues\",()=>e._zod.innerType?._zod?.propValues),_(e._zod,\"optin\",()=>e._zod.innerType?._zod?.optin??void 0),_(e._zod,\"optout\",()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(o,r)=>e._zod.innerType._zod.run(o,r)}),bn=l(\"$ZodCustom\",(e,t)=>{S.init(e,t),w.init(e,t),e._zod.parse=(o,r)=>o,e._zod.check=(o)=>{let r=o.value,n=t.fn(r);if(n instanceof Promise)return n.then((i)=>Tr(i,o,r,e));Tr(n,o,r,e);return}});function Tr(e,t,o,r){if(!e){let n={code:\"custom\",input:o,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};if(r._zod.def.params)n.params=r._zod.def.params;t.issues.push(oe(n))}}var vn,nl=Symbol(\"ZodOutput\"),sl=Symbol(\"ZodInput\");class zn{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let o=t[0];if(this._map.set(e,o),o&&typeof o===\"object\"&&\"id\"in o)this._idmap.set(o.id,e);return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);if(t&&typeof t===\"object\"&&\"id\"in t)this._idmap.delete(t.id);return this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let o={...this.get(t)??{}};delete o.id;let r={...o,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function ma(){return new zn}(vn=globalThis).__zod_globalRegistry??(vn.__zod_globalRegistry=ma());var re=globalThis.__zod_globalRegistry;function $n(e,t){return new e({type:\"string\",...f(t)})}function Tn(e,t){return new e({type:\"string\",format:\"email\",check:\"string_format\",abort:!1,...f(t)})}function bt(e,t){return new e({type:\"string\",format:\"guid\",check:\"string_format\",abort:!1,...f(t)})}function kn(e,t){return new e({type:\"string\",format:\"uuid\",check:\"string_format\",abort:!1,...f(t)})}function An(e,t){return new e({type:\"string\",format:\"uuid\",check:\"string_format\",abort:!1,version:\"v4\",...f(t)})}function En(e,t){return new e({type:\"string\",format:\"uuid\",check:\"string_format\",abort:!1,version:\"v6\",...f(t)})}function Sn(e,t){return new e({type:\"string\",format:\"uuid\",check:\"string_format\",abort:!1,version:\"v7\",...f(t)})}function Cn(e,t){return new e({type:\"string\",format:\"url\",check:\"string_format\",abort:!1,...f(t)})}function On(e,t){return new e({type:\"string\",format:\"emoji\",check:\"string_format\",abort:!1,...f(t)})}function Pn(e,t){return new e({type:\"string\",format:\"nanoid\",check:\"string_format\",abort:!1,...f(t)})}function In(e,t){return new e({type:\"string\",format:\"cuid\",check:\"string_format\",abort:!1,...f(t)})}function Zn(e,t){return new e({type:\"string\",format:\"cuid2\",check:\"string_format\",abort:!1,...f(t)})}function Rn(e,t){return new e({type:\"string\",format:\"ulid\",check:\"string_format\",abort:!1,...f(t)})}function Nn(e,t){return new e({type:\"string\",format:\"xid\",check:\"string_format\",abort:!1,...f(t)})}function jn(e,t){return new e({type:\"string\",format:\"ksuid\",check:\"string_format\",abort:!1,...f(t)})}function Dn(e,t){return new e({type:\"string\",format:\"ipv4\",check:\"string_format\",abort:!1,...f(t)})}function Mn(e,t){return new e({type:\"string\",format:\"ipv6\",check:\"string_format\",abort:!1,...f(t)})}function Ln(e,t){return new e({type:\"string\",format:\"cidrv4\",check:\"string_format\",abort:!1,...f(t)})}function Gn(e,t){return new e({type:\"string\",format:\"cidrv6\",check:\"string_format\",abort:!1,...f(t)})}function Fn(e,t){return new e({type:\"string\",format:\"base64\",check:\"string_format\",abort:!1,...f(t)})}function Un(e,t){return new e({type:\"string\",format:\"base64url\",check:\"string_format\",abort:!1,...f(t)})}function Vn(e,t){return new e({type:\"string\",format:\"e164\",check:\"string_format\",abort:!1,...f(t)})}function Jn(e,t){return new e({type:\"string\",format:\"jwt\",check:\"string_format\",abort:!1,...f(t)})}function qn(e,t){return new e({type:\"string\",format:\"datetime\",check:\"string_format\",offset:!1,local:!1,precision:null,...f(t)})}function Bn(e,t){return new e({type:\"string\",format:\"date\",check:\"string_format\",...f(t)})}function Wn(e,t){return new e({type:\"string\",format:\"time\",check:\"string_format\",precision:null,...f(t)})}function Kn(e,t){return new e({type:\"string\",format:\"duration\",check:\"string_format\",...f(t)})}function Hn(e,t){return new e({type:\"number\",checks:[],...f(t)})}function Xn(e,t){return new e({type:\"number\",check:\"number_format\",abort:!1,format:\"safeint\",...f(t)})}function Yn(e,t){return new e({type:\"boolean\",...f(t)})}function Qn(e,t){return new e({type:\"null\",...f(t)})}function es(e){return new e({type:\"unknown\"})}function ts(e,t){return new e({type:\"never\",...f(t)})}function Fe(e,t){return new ft({check:\"less_than\",...f(t),value:e,inclusive:!1})}function _e(e,t){return new ft({check:\"less_than\",...f(t),value:e,inclusive:!0})}function Ue(e,t){return new ht({check:\"greater_than\",...f(t),value:e,inclusive:!1})}function xe(e,t){return new ht({check:\"greater_than\",...f(t),value:e,inclusive:!0})}function Ve(e,t){return new nr({check:\"multiple_of\",...f(t),value:e})}function Je(e,t){return new ir({check:\"max_length\",...f(t),maximum:e})}function ce(e,t){return new ar({check:\"min_length\",...f(t),minimum:e})}function qe(e,t){return new cr({check:\"length_equals\",...f(t),length:e})}function vt(e,t){return new ur({check:\"string_format\",format:\"regex\",...f(t),pattern:e})}function zt(e){return new lr({check:\"string_format\",format:\"lowercase\",...f(e)})}function $t(e){return new pr({check:\"string_format\",format:\"uppercase\",...f(e)})}function Tt(e,t){return new dr({check:\"string_format\",format:\"includes\",...f(t),includes:e})}function kt(e,t){return new mr({check:\"string_format\",format:\"starts_with\",...f(t),prefix:e})}function At(e,t){return new fr({check:\"string_format\",format:\"ends_with\",...f(t),suffix:e})}function K(e){return new hr({check:\"overwrite\",tx:e})}function Et(e){return K((t)=>t.normalize(e))}function St(){return K((e)=>e.trim())}function Ct(){return K((e)=>e.toLowerCase())}function Ot(){return K((e)=>e.toUpperCase())}function Pt(){return K((e)=>uo(e))}function os(e,t,o){return new e({type:\"array\",element:t,...f(o)})}function rs(e,t,o){return new e({type:\"custom\",check:\"custom\",fn:t,...f(o)})}function ns(e,t){let o=fa((r)=>(r.addIssue=(n)=>{if(typeof n===\"string\")r.issues.push(oe(n,r.value,o._zod.def));else{let i=n;if(i.fatal)i.continue=!1;i.code??(i.code=\"custom\"),i.input??(i.input=r.value),i.inst??(i.inst=o),i.continue??(i.continue=!o._zod.def.abort),r.issues.push(oe(i))}},e(r.value,r)),t);return o}function fa(e,t){let o=new S({check:\"custom\",...f(t)});return o._zod.check=e,o}function It(e){let t=e?.target??\"draft-2020-12\";if(t===\"draft-4\")t=\"draft-04\";if(t===\"draft-7\")t=\"draft-07\";return{processors:e.processors??{},metadataRegistry:e?.metadata??re,target:t,unrepresentable:e?.unrepresentable??\"throw\",override:e?.override??(()=>{}),io:e?.io??\"output\",counter:0,seen:new Map,cycles:e?.cycles??\"ref\",reused:e?.reused??\"inline\",external:e?.external??void 0}}function k(e,t,o={path:[],schemaPath:[]}){var r;let n=e._zod.def,i=t.seen.get(e);if(i){if(i.count++,o.schemaPath.includes(e))i.cycle=o.path;return i.schema}let s={schema:{},count:1,cycle:void 0,path:o.path};t.seen.set(e,s);let a=e._zod.toJSONSchema?.();if(a)s.schema=a;else{let p={...o,schemaPath:[...o.schemaPath,e],path:o.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,s.schema,p);else{let h=s.schema,m=t.processors[n.type];if(!m)throw Error(`[toJSONSchema]: Non-representable type encountered: ${n.type}`);m(e,t,h,p)}let d=e._zod.parent;if(d){if(!s.ref)s.ref=d;k(d,t,p),t.seen.get(d).isParent=!0}}let c=t.metadataRegistry.get(e);if(c)Object.assign(s.schema,c);if(t.io===\"input\"&&O(e))delete s.schema.examples,delete s.schema.default;if(t.io===\"input\"&&\"_prefault\"in s.schema)(r=s.schema).default??(r.default=s.schema._prefault);return delete s.schema._prefault,t.seen.get(e).schema}function Zt(e,t){let o=e.seen.get(t);if(!o)throw Error(\"Unprocessed schema. This is a bug in Zod.\");let r=new Map;for(let s of e.seen.entries()){let a=e.metadataRegistry.get(s[0])?.id;if(a){let c=r.get(a);if(c&&c!==s[0])throw Error(`Duplicate schema id \"${a}\" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(a,s[0])}}let n=(s)=>{let a=e.target===\"draft-2020-12\"?\"$defs\":\"definitions\";if(e.external){let d=e.external.registry.get(s[0])?.id,h=e.external.uri??((y)=>y);if(d)return{ref:h(d)};let m=s[1].defId??s[1].schema.id??`schema${e.counter++}`;return s[1].defId=m,{defId:m,ref:`${h(\"__shared\")}#/${a}/${m}`}}if(s[1]===o)return{ref:\"#\"};let u=`${\"#\"}/${a}/`,p=s[1].schema.id??`__schema${e.counter++}`;return{defId:p,ref:u+p}},i=(s)=>{if(s[1].schema.$ref)return;let a=s[1],{ref:c,defId:u}=n(s);if(a.def={...a.schema},u)a.defId=u;let p=a.schema;for(let d in p)delete p[d];p.$ref=c};if(e.cycles===\"throw\")for(let s of e.seen.entries()){let a=s[1];if(a.cycle)throw Error(`Cycle detected: #/${a.cycle?.join(\"/\")}/<root>\n\nSet the \\`cycles\\` parameter to \\`\"ref\"\\` to resolve cyclical schemas with defs.`)}for(let s of e.seen.entries()){let a=s[1];if(t===s[0]){i(s);continue}if(e.external){let u=e.external.registry.get(s[0])?.id;if(t!==s[0]&&u){i(s);continue}}if(e.metadataRegistry.get(s[0])?.id){i(s);continue}if(a.cycle){i(s);continue}if(a.count>1){if(e.reused===\"ref\"){i(s);continue}}}}function Rt(e,t){let o=e.seen.get(t);if(!o)throw Error(\"Unprocessed schema. This is a bug in Zod.\");let r=(a)=>{let c=e.seen.get(a);if(c.ref===null)return;let u=c.def??c.schema,p={...u},d=c.ref;if(c.ref=null,d){r(d);let m=e.seen.get(d),y=m.schema;if(y.$ref&&(e.target===\"draft-07\"||e.target===\"draft-04\"||e.target===\"openapi-3.0\"))u.allOf=u.allOf??[],u.allOf.push(y);else Object.assign(u,y);if(Object.assign(u,p),a._zod.parent===d)for(let A in u){if(A===\"$ref\"||A===\"allOf\")continue;if(!(A in p))delete u[A]}if(y.$ref&&m.def)for(let A in u){if(A===\"$ref\"||A===\"allOf\")continue;if(A in m.def&&JSON.stringify(u[A])===JSON.stringify(m.def[A]))delete u[A]}}let h=a._zod.parent;if(h&&h!==d){r(h);let m=e.seen.get(h);if(m?.schema.$ref){if(u.$ref=m.schema.$ref,m.def)for(let y in u){if(y===\"$ref\"||y===\"allOf\")continue;if(y in m.def&&JSON.stringify(u[y])===JSON.stringify(m.def[y]))delete u[y]}}}e.override({zodSchema:a,jsonSchema:u,path:c.path??[]})};for(let a of[...e.seen.entries()].reverse())r(a[0]);let n={};if(e.target===\"draft-2020-12\")n.$schema=\"https://json-schema.org/draft/2020-12/schema\";else if(e.target===\"draft-07\")n.$schema=\"http://json-schema.org/draft-07/schema#\";else if(e.target===\"draft-04\")n.$schema=\"http://json-schema.org/draft-04/schema#\";else if(e.target===\"openapi-3.0\");if(e.external?.uri){let a=e.external.registry.get(t)?.id;if(!a)throw Error(\"Schema is missing an `id` property\");n.$id=e.external.uri(a)}Object.assign(n,o.def??o.schema);let i=e.metadataRegistry.get(t)?.id;if(i!==void 0&&n.id===i)delete n.id;let s=e.external?.defs??{};for(let a of e.seen.entries()){let c=a[1];if(c.def&&c.defId){if(c.def.id===c.defId)delete c.def.id;s[c.defId]=c.def}}if(e.external);else if(Object.keys(s).length>0)if(e.target===\"draft-2020-12\")n.$defs=s;else n.definitions=s;try{let a=JSON.parse(JSON.stringify(n));return Object.defineProperty(a,\"~standard\",{value:{...t[\"~standard\"],jsonSchema:{input:we(t,\"input\",e.processors),output:we(t,\"output\",e.processors)}},enumerable:!1,writable:!1}),a}catch(a){throw Error(\"Error converting schema to JSON.\")}}function O(e,t){let o=t??{seen:new Set};if(o.seen.has(e))return!1;o.seen.add(e);let r=e._zod.def;if(r.type===\"transform\")return!0;if(r.type===\"array\")return O(r.element,o);if(r.type===\"set\")return O(r.valueType,o);if(r.type===\"lazy\")return O(r.getter(),o);if(r.type===\"promise\"||r.type===\"optional\"||r.type===\"nonoptional\"||r.type===\"nullable\"||r.type===\"readonly\"||r.type===\"default\"||r.type===\"prefault\")return O(r.innerType,o);if(r.type===\"intersection\")return O(r.left,o)||O(r.right,o);if(r.type===\"record\"||r.type===\"map\")return O(r.keyType,o)||O(r.valueType,o);if(r.type===\"pipe\"){if(e._zod.traits.has(\"$ZodCodec\"))return!0;return O(r.in,o)||O(r.out,o)}if(r.type===\"object\"){for(let n in r.shape)if(O(r.shape[n],o))return!0;return!1}if(r.type===\"union\"){for(let n of r.options)if(O(n,o))return!0;return!1}if(r.type===\"tuple\"){for(let n of r.items)if(O(n,o))return!0;if(r.rest&&O(r.rest,o))return!0;return!1}return!1}var ss=(e,t={})=>(o)=>{let r=It({...o,processors:t});return k(e,r),Zt(r,e),Rt(r,e)},we=(e,t,o={})=>(r)=>{let{libraryOptions:n,target:i}=r??{},s=It({...n??{},target:i,io:t,processors:o});return k(e,s),Zt(s,e),Rt(s,e)};var ha={guid:\"uuid\",url:\"uri\",datetime:\"date-time\",json_string:\"json-string\",regex:\"\"},is=(e,t,o,r)=>{let n=o;n.type=\"string\";let{minimum:i,maximum:s,format:a,patterns:c,contentEncoding:u}=e._zod.bag;if(typeof i===\"number\")n.minLength=i;if(typeof s===\"number\")n.maxLength=s;if(a){if(n.format=ha[a]??a,n.format===\"\")delete n.format;if(a===\"time\")delete n.format}if(u)n.contentEncoding=u;if(c&&c.size>0){let p=[...c];if(p.length===1)n.pattern=p[0].source;else if(p.length>1)n.allOf=[...p.map((d)=>({...t.target===\"draft-07\"||t.target===\"draft-04\"||t.target===\"openapi-3.0\"?{type:\"string\"}:{},pattern:d.source}))]}},as=(e,t,o,r)=>{let n=o,{minimum:i,maximum:s,format:a,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:p}=e._zod.bag;if(typeof a===\"string\"&&a.includes(\"int\"))n.type=\"integer\";else n.type=\"number\";let d=typeof p===\"number\"&&p>=(i??Number.NEGATIVE_INFINITY),h=typeof u===\"number\"&&u<=(s??Number.POSITIVE_INFINITY),m=t.target===\"draft-04\"||t.target===\"openapi-3.0\";if(d)if(m)n.minimum=p,n.exclusiveMinimum=!0;else n.exclusiveMinimum=p;else if(typeof i===\"number\")n.minimum=i;if(h)if(m)n.maximum=u,n.exclusiveMaximum=!0;else n.exclusiveMaximum=u;else if(typeof s===\"number\")n.maximum=s;if(typeof c===\"number\")n.multipleOf=c},cs=(e,t,o,r)=>{o.type=\"boolean\"};var us=(e,t,o,r)=>{if(t.target===\"openapi-3.0\")o.type=\"string\",o.nullable=!0,o.enum=[null];else o.type=\"null\"};var ls=(e,t,o,r)=>{o.not={}};var ps=(e,t,o,r)=>{};var ds=(e,t,o,r)=>{let n=e._zod.def,i=Oe(n.entries);if(i.every((s)=>typeof s===\"number\"))o.type=\"number\";if(i.every((s)=>typeof s===\"string\"))o.type=\"string\";o.enum=i},ms=(e,t,o,r)=>{let n=e._zod.def,i=[];for(let s of n.values)if(s===void 0){if(t.unrepresentable===\"throw\")throw Error(\"Literal `undefined` cannot be represented in JSON Schema\")}else if(typeof s===\"bigint\")if(t.unrepresentable===\"throw\")throw Error(\"BigInt literals cannot be represented in JSON Schema\");else i.push(Number(s));else i.push(s);if(i.length===0);else if(i.length===1){let s=i[0];if(o.type=s===null?\"null\":typeof s,t.target===\"draft-04\"||t.target===\"openapi-3.0\")o.enum=[s];else o.const=s}else{if(i.every((s)=>typeof s===\"number\"))o.type=\"number\";if(i.every((s)=>typeof s===\"string\"))o.type=\"string\";if(i.every((s)=>typeof s===\"boolean\"))o.type=\"boolean\";if(i.every((s)=>s===null))o.type=\"null\";o.enum=i}};var fs=(e,t,o,r)=>{if(t.unrepresentable===\"throw\")throw Error(\"Custom types cannot be represented in JSON Schema\")};var hs=(e,t,o,r)=>{if(t.unrepresentable===\"throw\")throw Error(\"Transforms cannot be represented in JSON Schema\")};var gs=(e,t,o,r)=>{let n=o,i=e._zod.def,{minimum:s,maximum:a}=e._zod.bag;if(typeof s===\"number\")n.minItems=s;if(typeof a===\"number\")n.maxItems=a;n.type=\"array\",n.items=k(i.element,t,{...r,path:[...r.path,\"items\"]})},ys=(e,t,o,r)=>{let n=o,i=e._zod.def;n.type=\"object\",n.properties={};let s=i.shape;for(let u in s)n.properties[u]=k(s[u],t,{...r,path:[...r.path,\"properties\",u]});let a=new Set(Object.keys(s)),c=new Set([...a].filter((u)=>{let p=i.shape[u]._zod;if(t.io===\"input\")return p.optin===void 0;else return p.optout===void 0}));if(c.size>0)n.required=Array.from(c);if(i.catchall?._zod.def.type===\"never\")n.additionalProperties=!1;else if(!i.catchall){if(t.io===\"output\")n.additionalProperties=!1}else if(i.catchall)n.additionalProperties=k(i.catchall,t,{...r,path:[...r.path,\"additionalProperties\"]})},_s=(e,t,o,r)=>{let n=e._zod.def,i=n.inclusive===!1,s=n.options.map((a,c)=>k(a,t,{...r,path:[...r.path,i?\"oneOf\":\"anyOf\",c]}));if(i)o.oneOf=s;else o.anyOf=s},xs=(e,t,o,r)=>{let n=e._zod.def,i=k(n.left,t,{...r,path:[...r.path,\"allOf\",0]}),s=k(n.right,t,{...r,path:[...r.path,\"allOf\",1]}),a=(u)=>(\"allOf\"in u)&&Object.keys(u).length===1,c=[...a(i)?i.allOf:[i],...a(s)?s.allOf:[s]];o.allOf=c};var ws=(e,t,o,r)=>{let n=o,i=e._zod.def;n.type=\"object\";let s=i.keyType,c=s._zod.bag?.patterns;if(i.mode===\"loose\"&&c&&c.size>0){let p=k(i.valueType,t,{...r,path:[...r.path,\"patternProperties\",\"*\"]});n.patternProperties={};for(let d of c)n.patternProperties[d.source]=p}else{if(t.target===\"draft-07\"||t.target===\"draft-2020-12\")n.propertyNames=k(i.keyType,t,{...r,path:[...r.path,\"propertyNames\"]});n.additionalProperties=k(i.valueType,t,{...r,path:[...r.path,\"additionalProperties\"]})}let u=s._zod.values;if(u){let p=[...u].filter((d)=>typeof d===\"string\"||typeof d===\"number\");if(p.length>0)n.required=p}},bs=(e,t,o,r)=>{let n=e._zod.def,i=k(n.innerType,t,r),s=t.seen.get(e);if(t.target===\"openapi-3.0\")s.ref=n.innerType,o.nullable=!0;else o.anyOf=[i,{type:\"null\"}]},vs=(e,t,o,r)=>{let n=e._zod.def;k(n.innerType,t,r);let i=t.seen.get(e);i.ref=n.innerType},zs=(e,t,o,r)=>{let n=e._zod.def;k(n.innerType,t,r);let i=t.seen.get(e);i.ref=n.innerType,o.default=JSON.parse(JSON.stringify(n.defaultValue))},$s=(e,t,o,r)=>{let n=e._zod.def;k(n.innerType,t,r);let i=t.seen.get(e);if(i.ref=n.innerType,t.io===\"input\")o._prefault=JSON.parse(JSON.stringify(n.defaultValue))},Ts=(e,t,o,r)=>{let n=e._zod.def;k(n.innerType,t,r);let i=t.seen.get(e);i.ref=n.innerType;let s;try{s=n.catchValue(void 0)}catch{throw Error(\"Dynamic catch values are not supported in JSON Schema\")}o.default=s},ks=(e,t,o,r)=>{let n=e._zod.def,i=n.in._zod.traits.has(\"$ZodTransform\"),s=t.io===\"input\"?i?n.out:n.in:n.out;k(s,t,r);let a=t.seen.get(e);a.ref=s},As=(e,t,o,r)=>{let n=e._zod.def;k(n.innerType,t,r);let i=t.seen.get(e);i.ref=n.innerType,o.readOnly=!0};var Nt=(e,t,o,r)=>{let n=e._zod.def;k(n.innerType,t,r);let i=t.seen.get(e);i.ref=n.innerType},Es=(e,t,o,r)=>{let n=e._zod.innerType;k(n,t,r);let i=t.seen.get(e);i.ref=n};var va=l(\"ZodISODateTime\",(e,t)=>{jr.init(e,t),z.init(e,t)});function Ss(e){return qn(va,e)}var za=l(\"ZodISODate\",(e,t)=>{Dr.init(e,t),z.init(e,t)});function Cs(e){return Bn(za,e)}var $a=l(\"ZodISOTime\",(e,t)=>{Mr.init(e,t),z.init(e,t)});function Os(e){return Wn($a,e)}var Ta=l(\"ZodISODuration\",(e,t)=>{Lr.init(e,t),z.init(e,t)});function Ps(e){return Kn(Ta,e)}var Ea=(e,t)=>{Re.init(e,t),e.name=\"ZodError\",Object.defineProperties(e,{format:{value:(o)=>_o(e,o)},flatten:{value:(o)=>yo(e,o)},addIssue:{value:(o)=>{e.issues.push(o),e.message=JSON.stringify(e.issues,me,2)}},addIssues:{value:(o)=>{e.issues.push(...o),e.message=JSON.stringify(e.issues,me,2)}},isEmpty:{get(){return e.issues.length===0}}})};var I=l(\"ZodError\",Ea,{Parent:Error});var Is=Ne(I),Zs=je(I),Rs=he(I),Ns=ge(I),js=bo(I),Ds=vo(I),Ms=zo(I),Ls=$o(I),Gs=To(I),Fs=ko(I),Us=Ao(I),Vs=Eo(I);var Js=new WeakMap;function be(e,t,o){let r=Object.getPrototypeOf(e),n=Js.get(r);if(!n)n=new Set,Js.set(r,n);if(n.has(t))return;n.add(t);for(let i in o){let s=o[i];Object.defineProperty(r,i,{configurable:!0,enumerable:!1,get(){let a=s.bind(this);return Object.defineProperty(this,i,{configurable:!0,writable:!0,enumerable:!0,value:a}),a},set(a){Object.defineProperty(this,i,{configurable:!0,writable:!0,enumerable:!0,value:a})}})}}var v=l(\"ZodType\",(e,t)=>(w.init(e,t),Object.assign(e[\"~standard\"],{jsonSchema:{input:we(e,\"input\"),output:we(e,\"output\")}}),e.toJSONSchema=ss(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,\"_def\",{value:t}),e.parse=(o,r)=>Is(e,o,r,{callee:e.parse}),e.safeParse=(o,r)=>Rs(e,o,r),e.parseAsync=async(o,r)=>Zs(e,o,r,{callee:e.parseAsync}),e.safeParseAsync=async(o,r)=>Ns(e,o,r),e.spa=e.safeParseAsync,e.encode=(o,r)=>js(e,o,r),e.decode=(o,r)=>Ds(e,o,r),e.encodeAsync=async(o,r)=>Ms(e,o,r),e.decodeAsync=async(o,r)=>Ls(e,o,r),e.safeEncode=(o,r)=>Gs(e,o,r),e.safeDecode=(o,r)=>Fs(e,o,r),e.safeEncodeAsync=async(o,r)=>Us(e,o,r),e.safeDecodeAsync=async(o,r)=>Vs(e,o,r),be(e,\"ZodType\",{check(...o){let r=this.def;return this.clone(J(r,{checks:[...r.checks??[],...o.map((n)=>typeof n===\"function\"?{_zod:{check:n,def:{check:\"custom\"},onattach:[]}}:n)]}),{parent:!0})},with(...o){return this.check(...o)},clone(o,r){return D(this,o,r)},brand(){return this},register(o,r){return o.add(this,r),this},refine(o,r){return this.check(kc(o,r))},superRefine(o,r){return this.check(Ac(o,r))},overwrite(o){return this.check(K(o))},optional(){return Hs(this)},exactOptional(){return pc(this)},nullable(){return Xs(this)},nullish(){return Hs(Xs(this))},nonoptional(o){return yc(this,o)},array(){return U(this)},or(o){return Dt([this,o])},and(o){return ic(this,o)},transform(o){return Ys(this,uc(o))},default(o){return fc(this,o)},prefault(o){return gc(this,o)},catch(o){return xc(this,o)},pipe(o){return Ys(this,o)},readonly(){return vc(this)},describe(o){let r=this.clone();return re.add(r,{description:o}),r},meta(...o){if(o.length===0)return re.get(this);let r=this.clone();return re.add(r,o[0]),r},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(o){return o(this)}}),Object.defineProperty(e,\"description\",{get(){return re.get(e)?.description},configurable:!0}),e)),Qs=l(\"_ZodString\",(e,t)=>{Ge.init(e,t),v.init(e,t),e._zod.processJSONSchema=(r,n,i)=>is(e,r,n,i);let o=e._zod.bag;e.format=o.format??null,e.minLength=o.minimum??null,e.maxLength=o.maximum??null,be(e,\"_ZodString\",{regex(...r){return this.check(vt(...r))},includes(...r){return this.check(Tt(...r))},startsWith(...r){return this.check(kt(...r))},endsWith(...r){return this.check(At(...r))},min(...r){return this.check(ce(...r))},max(...r){return this.check(Je(...r))},length(...r){return this.check(qe(...r))},nonempty(...r){return this.check(ce(1,...r))},lowercase(r){return this.check(zt(r))},uppercase(r){return this.check($t(r))},trim(){return this.check(St())},normalize(...r){return this.check(Et(...r))},toLowerCase(){return this.check(Ct())},toUpperCase(){return this.check(Ot())},slugify(){return this.check(Pt())}})}),Ca=l(\"ZodString\",(e,t)=>{Ge.init(e,t),Qs.init(e,t),e.email=(o)=>e.check(Tn(Oa,o)),e.url=(o)=>e.check(Cn(Pa,o)),e.jwt=(o)=>e.check(Jn(Ba,o)),e.emoji=(o)=>e.check(On(Ia,o)),e.guid=(o)=>e.check(bt(qs,o)),e.uuid=(o)=>e.check(kn(We,o)),e.uuidv4=(o)=>e.check(An(We,o)),e.uuidv6=(o)=>e.check(En(We,o)),e.uuidv7=(o)=>e.check(Sn(We,o)),e.nanoid=(o)=>e.check(Pn(Za,o)),e.guid=(o)=>e.check(bt(qs,o)),e.cuid=(o)=>e.check(In(Ra,o)),e.cuid2=(o)=>e.check(Zn(Na,o)),e.ulid=(o)=>e.check(Rn(ja,o)),e.base64=(o)=>e.check(Fn(Va,o)),e.base64url=(o)=>e.check(Un(Ja,o)),e.xid=(o)=>e.check(Nn(Da,o)),e.ksuid=(o)=>e.check(jn(Ma,o)),e.ipv4=(o)=>e.check(Dn(La,o)),e.ipv6=(o)=>e.check(Mn(Ga,o)),e.cidrv4=(o)=>e.check(Ln(Fa,o)),e.cidrv6=(o)=>e.check(Gn(Ua,o)),e.e164=(o)=>e.check(Vn(qa,o)),e.datetime=(o)=>e.check(Ss(o)),e.date=(o)=>e.check(Cs(o)),e.time=(o)=>e.check(Os(o)),e.duration=(o)=>e.check(Ps(o))});function g(e){return $n(Ca,e)}var z=l(\"ZodStringFormat\",(e,t)=>{b.init(e,t),Qs.init(e,t)}),Oa=l(\"ZodEmail\",(e,t)=>{Er.init(e,t),z.init(e,t)});var qs=l(\"ZodGUID\",(e,t)=>{kr.init(e,t),z.init(e,t)});var We=l(\"ZodUUID\",(e,t)=>{Ar.init(e,t),z.init(e,t)});var Pa=l(\"ZodURL\",(e,t)=>{Sr.init(e,t),z.init(e,t)});var Ia=l(\"ZodEmoji\",(e,t)=>{Cr.init(e,t),z.init(e,t)});var Za=l(\"ZodNanoID\",(e,t)=>{Or.init(e,t),z.init(e,t)});var Ra=l(\"ZodCUID\",(e,t)=>{Pr.init(e,t),z.init(e,t)});var Na=l(\"ZodCUID2\",(e,t)=>{Ir.init(e,t),z.init(e,t)});var ja=l(\"ZodULID\",(e,t)=>{Zr.init(e,t),z.init(e,t)});var Da=l(\"ZodXID\",(e,t)=>{Rr.init(e,t),z.init(e,t)});var Ma=l(\"ZodKSUID\",(e,t)=>{Nr.init(e,t),z.init(e,t)});var La=l(\"ZodIPv4\",(e,t)=>{Gr.init(e,t),z.init(e,t)});var Ga=l(\"ZodIPv6\",(e,t)=>{Fr.init(e,t),z.init(e,t)});var Fa=l(\"ZodCIDRv4\",(e,t)=>{Ur.init(e,t),z.init(e,t)});var Ua=l(\"ZodCIDRv6\",(e,t)=>{Vr.init(e,t),z.init(e,t)});var Va=l(\"ZodBase64\",(e,t)=>{qr.init(e,t),z.init(e,t)});var Ja=l(\"ZodBase64URL\",(e,t)=>{Br.init(e,t),z.init(e,t)});var qa=l(\"ZodE164\",(e,t)=>{Wr.init(e,t),z.init(e,t)});var Ba=l(\"ZodJWT\",(e,t)=>{Kr.init(e,t),z.init(e,t)});var ei=l(\"ZodNumber\",(e,t)=>{_t.init(e,t),v.init(e,t),e._zod.processJSONSchema=(r,n,i)=>as(e,r,n,i),be(e,\"ZodNumber\",{gt(r,n){return this.check(Ue(r,n))},gte(r,n){return this.check(xe(r,n))},min(r,n){return this.check(xe(r,n))},lt(r,n){return this.check(Fe(r,n))},lte(r,n){return this.check(_e(r,n))},max(r,n){return this.check(_e(r,n))},int(r){return this.check(Bs(r))},safe(r){return this.check(Bs(r))},positive(r){return this.check(Ue(0,r))},nonnegative(r){return this.check(xe(0,r))},negative(r){return this.check(Fe(0,r))},nonpositive(r){return this.check(_e(0,r))},multipleOf(r,n){return this.check(Ve(r,n))},step(r,n){return this.check(Ve(r,n))},finite(){return this}});let o=e._zod.bag;e.minValue=Math.max(o.minimum??Number.NEGATIVE_INFINITY,o.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(o.maximum??Number.POSITIVE_INFINITY,o.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(o.format??\"\").includes(\"int\")||Number.isSafeInteger(o.multipleOf??0.5),e.isFinite=!0,e.format=o.format??null});function ve(e){return Hn(ei,e)}var Wa=l(\"ZodNumberFormat\",(e,t)=>{Hr.init(e,t),ei.init(e,t)});function Bs(e){return Xn(Wa,e)}var Ka=l(\"ZodBoolean\",(e,t)=>{Xr.init(e,t),v.init(e,t),e._zod.processJSONSchema=(o,r,n)=>cs(e,o,r,n)});function ue(e){return Yn(Ka,e)}var Ha=l(\"ZodNull\",(e,t)=>{Yr.init(e,t),v.init(e,t),e._zod.processJSONSchema=(o,r,n)=>us(e,o,r,n)});function Xa(e){return Qn(Ha,e)}var Ya=l(\"ZodUnknown\",(e,t)=>{Qr.init(e,t),v.init(e,t),e._zod.processJSONSchema=(o,r,n)=>ps(e,o,r,n)});function Ws(){return es(Ya)}var Qa=l(\"ZodNever\",(e,t)=>{en.init(e,t),v.init(e,t),e._zod.processJSONSchema=(o,r,n)=>ls(e,o,r,n)});function ec(e){return ts(Qa,e)}var tc=l(\"ZodArray\",(e,t)=>{tn.init(e,t),v.init(e,t),e._zod.processJSONSchema=(o,r,n)=>gs(e,o,r,n),e.element=t.element,be(e,\"ZodArray\",{min(o,r){return this.check(ce(o,r))},nonempty(o){return this.check(ce(1,o))},max(o,r){return this.check(Je(o,r))},length(o,r){return this.check(qe(o,r))},unwrap(){return this.element}})});function U(e,t){return os(tc,e,t)}var oc=l(\"ZodObject\",(e,t)=>{nn.init(e,t),v.init(e,t),e._zod.processJSONSchema=(o,r,n)=>ys(e,o,r,n),_(e,\"shape\",()=>t.shape),be(e,\"ZodObject\",{keyof(){return H(Object.keys(this._zod.def.shape))},catchall(o){return this.clone({...this._zod.def,catchall:o})},passthrough(){return this.clone({...this._zod.def,catchall:Ws()})},loose(){return this.clone({...this._zod.def,catchall:Ws()})},strict(){return this.clone({...this._zod.def,catchall:ec()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(o){return ra(this,o)},safeExtend(o){return na(this,o)},merge(o){return sa(this,o)},pick(o){return ta(this,o)},omit(o){return oa(this,o)},partial(...o){return ia(oi,this,o[0])},required(...o){return aa(ri,this,o[0])}})});function C(e,t){let o={type:\"object\",shape:e??{},...f(t)};return new oc(o)}var ti=l(\"ZodUnion\",(e,t)=>{xt.init(e,t),v.init(e,t),e._zod.processJSONSchema=(o,r,n)=>_s(e,o,r,n),e.options=t.options});function Dt(e,t){return new ti({type:\"union\",options:e,...f(t)})}var rc=l(\"ZodDiscriminatedUnion\",(e,t)=>{ti.init(e,t),sn.init(e,t)});function nc(e,t,o){return new rc({type:\"union\",options:t,discriminator:e,...f(o)})}var sc=l(\"ZodIntersection\",(e,t)=>{an.init(e,t),v.init(e,t),e._zod.processJSONSchema=(o,r,n)=>xs(e,o,r,n)});function ic(e,t){return new sc({type:\"intersection\",left:e,right:t})}var Ks=l(\"ZodRecord\",(e,t)=>{cn.init(e,t),v.init(e,t),e._zod.processJSONSchema=(o,r,n)=>ws(e,o,r,n),e.keyType=t.keyType,e.valueType=t.valueType});function Ke(e,t,o){if(!t||!t._zod)return new Ks({type:\"record\",keyType:g(),valueType:e,...f(t)});return new Ks({type:\"record\",keyType:e,valueType:t,...f(o)})}var jt=l(\"ZodEnum\",(e,t)=>{un.init(e,t),v.init(e,t),e._zod.processJSONSchema=(r,n,i)=>ds(e,r,n,i),e.enum=t.entries,e.options=Object.values(t.entries);let o=new Set(Object.keys(t.entries));e.extract=(r,n)=>{let i={};for(let s of r)if(o.has(s))i[s]=t.entries[s];else throw Error(`Key ${s} not found in enum`);return new jt({...t,checks:[],...f(n),entries:i})},e.exclude=(r,n)=>{let i={...t.entries};for(let s of r)if(o.has(s))delete i[s];else throw Error(`Key ${s} not found in enum`);return new jt({...t,checks:[],...f(n),entries:i})}});function H(e,t){let o=Array.isArray(e)?Object.fromEntries(e.map((r)=>[r,r])):e;return new jt({type:\"enum\",entries:o,...f(t)})}var ac=l(\"ZodLiteral\",(e,t)=>{ln.init(e,t),v.init(e,t),e._zod.processJSONSchema=(o,r,n)=>ms(e,o,r,n),e.values=new Set(t.values),Object.defineProperty(e,\"value\",{get(){if(t.values.length>1)throw Error(\"This schema contains multiple valid literal values. Use `.values` instead.\");return t.values[0]}})});function X(e,t){return new ac({type:\"literal\",values:Array.isArray(e)?e:[e],...f(t)})}var cc=l(\"ZodTransform\",(e,t)=>{pn.init(e,t),v.init(e,t),e._zod.processJSONSchema=(o,r,n)=>hs(e,o,r,n),e._zod.parse=(o,r)=>{if(r.direction===\"backward\")throw new de(e.constructor.name);o.addIssue=(i)=>{if(typeof i===\"string\")o.issues.push(oe(i,o.value,t));else{let s=i;if(s.fatal)s.continue=!1;s.code??(s.code=\"custom\"),s.input??(s.input=o.value),s.inst??(s.inst=e),o.issues.push(oe(s))}};let n=t.transform(o.value,o);if(n instanceof Promise)return n.then((i)=>(o.value=i,o.fallback=!0,o));return o.value=n,o.fallback=!0,o}});function uc(e){return new cc({type:\"transform\",transform:e})}var oi=l(\"ZodOptional\",(e,t)=>{wt.init(e,t),v.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Nt(e,o,r,n),e.unwrap=()=>e._zod.def.innerType});function Hs(e){return new oi({type:\"optional\",innerType:e})}var lc=l(\"ZodExactOptional\",(e,t)=>{dn.init(e,t),v.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Nt(e,o,r,n),e.unwrap=()=>e._zod.def.innerType});function pc(e){return new lc({type:\"optional\",innerType:e})}var dc=l(\"ZodNullable\",(e,t)=>{mn.init(e,t),v.init(e,t),e._zod.processJSONSchema=(o,r,n)=>bs(e,o,r,n),e.unwrap=()=>e._zod.def.innerType});function Xs(e){return new dc({type:\"nullable\",innerType:e})}var mc=l(\"ZodDefault\",(e,t)=>{fn.init(e,t),v.init(e,t),e._zod.processJSONSchema=(o,r,n)=>zs(e,o,r,n),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function fc(e,t){return new mc({type:\"default\",innerType:e,get defaultValue(){return typeof t===\"function\"?t():ut(t)}})}var hc=l(\"ZodPrefault\",(e,t)=>{hn.init(e,t),v.init(e,t),e._zod.processJSONSchema=(o,r,n)=>$s(e,o,r,n),e.unwrap=()=>e._zod.def.innerType});function gc(e,t){return new hc({type:\"prefault\",innerType:e,get defaultValue(){return typeof t===\"function\"?t():ut(t)}})}var ri=l(\"ZodNonOptional\",(e,t)=>{gn.init(e,t),v.init(e,t),e._zod.processJSONSchema=(o,r,n)=>vs(e,o,r,n),e.unwrap=()=>e._zod.def.innerType});function yc(e,t){return new ri({type:\"nonoptional\",innerType:e,...f(t)})}var _c=l(\"ZodCatch\",(e,t)=>{yn.init(e,t),v.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Ts(e,o,r,n),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function xc(e,t){return new _c({type:\"catch\",innerType:e,catchValue:typeof t===\"function\"?t:()=>t})}var wc=l(\"ZodPipe\",(e,t)=>{_n.init(e,t),v.init(e,t),e._zod.processJSONSchema=(o,r,n)=>ks(e,o,r,n),e.in=t.in,e.out=t.out});function Ys(e,t){return new wc({type:\"pipe\",in:e,out:t})}var bc=l(\"ZodReadonly\",(e,t)=>{xn.init(e,t),v.init(e,t),e._zod.processJSONSchema=(o,r,n)=>As(e,o,r,n),e.unwrap=()=>e._zod.def.innerType});function vc(e){return new bc({type:\"readonly\",innerType:e})}var zc=l(\"ZodLazy\",(e,t)=>{wn.init(e,t),v.init(e,t),e._zod.processJSONSchema=(o,r,n)=>Es(e,o,r,n),e.unwrap=()=>e._zod.def.getter()});function $c(e){return new zc({type:\"lazy\",getter:e})}var Tc=l(\"ZodCustom\",(e,t)=>{bn.init(e,t),v.init(e,t),e._zod.processJSONSchema=(o,r,n)=>fs(e,o,r,n)});function kc(e,t={}){return rs(Tc,e,t)}function Ac(e,t){return ns(e,t)}function Mt(e){let t=$c(()=>Dt([g(e),ve(),ue(),Xa(),U(t),Ke(g(),t)]));return t}var si=x(()=>H([\"account:read\",\"account:admin\",\"members:manage\",\"workspace:create\",\"billing:read\",\"billing:manage\",\"workspace:read\",\"workspace:admin\",\"sessions:create\",\"sessions:read\",\"sessions:control\",\"stream:view\",\"stream:control\",\"stream:acknowledge\",\"files:upload\",\"files:read\",\"files:write\",\"terminal:attach\",\"documents:manage\",\"documents:search\",\"scheduled_tasks:manage\",\"scheduled_tasks:run\",\"github:manage\",\"github:use\",\"api_keys:manage\",\"usage_allowances:manage\",\"connections:read\",\"connections:write\",\"capabilities:manage\",\"environments:manage\",\"environments:use\",\"variable-sets:list\",\"variable-sets:read\",\"variable-sets:write\",\"variable-sets:manage\",\"variable-sets:attach\",\"variable-sets:use\",\"secrets:list\",\"secrets:read\",\"secrets:write\",\"secrets:use\",\"mcp_servers:attach\",\"codemode:call\",\"goals:manage\",\"enrollments:read\",\"enrollments:manage\",\"rigs:use\",\"rigs:manage\",\"artifacts:read\",\"artifacts:publish\"]));var ai=1;var Ec=4096,ci=16777216,Sc=8,Cc=1024,Oc=1;var Lt=x(()=>g().regex(/^[0-9a-f]{64}$/u)),Pc=x(()=>g().min(1).max(256).regex(/^[A-Za-z0-9_-]+$/u)),ui=x(()=>g().min(1).max(512).regex(/^[^\\u0000-\\u001f\\u007f]+$/u)),Ic=x(()=>g().min(1).max(128).regex(/^[A-Za-z_$][A-Za-z0-9_$]*$/u).refine((e)=>![\"__proto__\",\"prototype\",\"constructor\"].includes(e),{message:\"unsafe Codemode namespace segment\"})),Gt=x(()=>Ke(g().max(512),Mt())),li=x(()=>C({serverId:Pc,toolName:ui}).strict());var pi=x(()=>C({src:g().min(1).max(8192),mimeType:g().min(1).max(128).optional(),sizes:U(g().min(1).max(64)).max(16).optional(),theme:H([\"light\",\"dark\"]).optional()}).strict()),Zc=x(()=>C({title:g().max(512).optional(),readOnlyHint:ue().optional(),destructiveHint:ue().optional(),idempotentHint:ue().optional(),openWorldHint:ue().optional()}).loose()),ii=Gt;var Rc=x(()=>C({identity:li,modelName:ui,codemodePath:U(Ic).min(2).max(Sc),title:g().min(1).max(512).optional(),description:g().max(32768).optional(),inputSchema:ii,outputSchema:ii.optional(),annotations:Zc.optional(),icons:U(pi).max(16).optional(),source:H([\"opengeni\",\"files\",\"docs\",\"mcp\",\"codex_apps\",\"interaction\"]),approval:H([\"none\",\"human\",\"policy\"])}).strict());var di=x(()=>C({version:X(ai),accountId:g().uuid(),workspaceId:g().uuid(),sessionId:g().uuid(),turnId:g().uuid(),attemptId:g().uuid(),executionGeneration:ve().int().positive(),generation:ve().int().positive(),digest:Lt,createdAt:g().datetime({offset:!0}),firstPartyMcpPermissions:U(si).max(128).optional(),entries:U(Rc).max(Ec)}).strict().superRefine((e,t)=>{let o=new Set,r=new Set,n=new Set;for(let[i,s]of e.entries.entries()){let a=`${s.identity.serverId}\\x00${s.identity.toolName}`,c=s.codemodePath.join(\".\");if(o.has(a))t.addIssue({code:\"custom\",path:[\"entries\",i,\"identity\"],message:\"duplicate tool identity\"});if(r.has(s.modelName))t.addIssue({code:\"custom\",path:[\"entries\",i,\"modelName\"],message:\"duplicate model tool name\"});if(n.has(c))t.addIssue({code:\"custom\",path:[\"entries\",i,\"codemodePath\"],message:\"duplicate Codemode tool path\"});o.add(a),r.add(s.modelName),n.add(c)}})),mi=x(()=>C({kind:H([\"model\",\"codemode\"]),subjectId:g().min(1).max(1024)}).strict());var ze=x(()=>Ke(g().max(256),Mt()).optional()),Y=x(()=>Ke(g().max(512),Mt()).optional()),Nc=x(()=>C({type:X(\"text\"),text:g(),annotations:ze,_meta:Y}).loose()),jc=x(()=>C({type:X(\"image\"),data:g(),mimeType:g().min(1).max(128),annotations:ze,_meta:Y}).loose()),Dc=x(()=>C({type:X(\"audio\"),data:g(),mimeType:g().min(1).max(128),annotations:ze,_meta:Y}).loose()),Mc=x(()=>C({type:X(\"resource_link\"),name:g().min(1).max(1024),title:g().max(1024).optional(),uri:g().min(1).max(16384),description:g().max(32768).optional(),mimeType:g().max(128).optional(),size:ve().int().nonnegative().optional(),icons:U(pi).max(16).optional(),annotations:ze,_meta:Y}).loose()),Lc=x(()=>C({uri:g().min(1).max(16384),mimeType:g().max(128).optional(),text:g(),_meta:Y}).loose()),Gc=x(()=>C({uri:g().min(1).max(16384),mimeType:g().max(128).optional(),blob:g(),_meta:Y}).loose()),Fc=x(()=>C({type:X(\"resource\"),resource:Dt([Lc,Gc]),annotations:ze,_meta:Y}).loose()),Uc=x(()=>nc(\"type\",[Nc,jc,Dc,Mc,Fc])),He=x(()=>C({content:U(Uc).max(Cc),structuredContent:Gt.optional(),isError:ue().optional(),_meta:Y}).loose());var Hp={siteArtifactId:g().uuid().optional(),siteVersionId:g().uuid().optional()};var Vc=x(()=>H([\"queued\",\"waiting_for_approval\",\"running\",\"completed\",\"failed\",\"outcome_unknown\",\"cancelled\"])),Ft=x(()=>C({version:X(Oc),operationId:g().uuid(),accountId:g().uuid(),workspaceId:g().uuid(),sessionId:g().uuid(),turnId:g().uuid(),attemptId:g().uuid(),executionGeneration:ve().int().positive(),catalogDigest:Lt,requestDigest:Lt,identity:li,arguments:Gt,caller:mi.refine((e)=>e.kind===\"codemode\",{message:\"Codemode operation caller must be codemode\"}),state:Vc,durableApproval:X(!0).optional(),approvalRequestId:g().uuid().optional(),result:He.nullable(),errorCode:g().min(1).max(128).nullable(),errorMessage:g().min(1).max(4096).nullable(),createdAt:g().datetime({offset:!0}),claimedAt:g().datetime({offset:!0}).nullable(),executionStartedAt:g().datetime({offset:!0}).nullable(),completedAt:g().datetime({offset:!0}).nullable(),updatedAt:g().datetime({offset:!0})}).strict());var fi=x(()=>C({operation:Ft,dispatch:H([\"accepted\",\"already_running\",\"terminal\",\"unavailable\",\"rejected\"])}).strict());var hi=\"/v1/workspaces/site-host\",Jc=/^\\/v1\\/workspaces\\/site-host\\/published-artifacts\\/([^/]+)\\/(?:data|files|sql)(?:\\/|$)/u,qc=\"00000000-0000-0000-0000-000000000000\";class Xe extends Error{code=\"site_session_path_unsupported\";constructor(){super(\"Unsupported Site session API path\");this.name=\"SiteSessionPathError\"}}class yi extends Error{code=\"site_data_unsupported\";constructor(){super(\"This Site host does not provide Site Data\");this.name=\"SiteDataUnsupportedError\"}}function Bc(e){return/[%\\\\#\\u0000-\\u0020\\u007f]/u.test(e)||e.split(\"/\").some((t)=>t===\".\"||t===\"..\")}function Wc(e,t){let o=new URL(e,\"http://site.invalid\");if(o.pathname===\"/v1/config/client\"){let r=o.searchParams.getAll(\"workspaceId\");if(r.length>1||r.length===1&&r[0]!==\"site-host\"&&r[0]!==t)throw new Xe;if(t!==\"site-host\")o.searchParams.set(\"workspaceId\",t);return o.pathname+o.search}return e.replace(\"/workspaces/site-host\",`/workspaces/${encodeURIComponent(t)}`)}function Kc(e,t,o,r){if(o===\"site-host\")return e;if(!r)throw new yi;return t.replace(\"/published-artifacts/current/\",`/published-artifacts/${encodeURIComponent(r)}/`)}function _i(e,t){let o=e.split(\"?\")[0];if(!(o===hi||o.startsWith(`${hi}/`))&&o!==\"/v1/config/client\"||Bc(o))throw new Xe;let n=Wc(e,t),i=Jc.exec(o);if(i){if(i[1]!==\"current\")throw new Xe;return Kc(e,n,t)}let s=new URL(n,\"http://site.invalid\");if(s.searchParams.get(\"originSiteId\")===\"current\"&&t!==\"site-host\")return s.searchParams.set(\"originSiteId\",qc),s.pathname+s.search;return n}var gi=[\"text\",\"annotations\",\"model\",\"reasoningEffort\",\"latencyMode\",\"controlEtag\",\"expectedDraftRevision\"],Yp=Object.freeze({\"sessions.send\":[\"type\",\"payload\",\"clientEventId\"],\"sessions.steer\":[...gi,\"clientEventId\"],\"sessions.control\":[\"action\",\"reason\",\"clientEventId\",\"expectedControlEtag\"],\"sessions.composerDraft.put\":[\"text\",\"annotations\",\"resources\",\"model\",\"reasoningEffort\",\"latencyMode\",\"expectedRevision\"],\"sessions.composerDraft.submit\":[...gi,\"resources\",\"connectionAccounts\",\"clientEventId\",\"delivery\"],\"sessions.queue.move\":[\"clientEventId\",\"expectedQueueVersion\",\"beforeTurnId\"],\"sessions.queue.edit\":[\"clientEventId\",\"expectedTurnVersion\",\"expectedDraftRevision\",\"replaceDraft\"],\"sessions.queue.steer\":[\"clientEventId\",\"expectedTurnVersion\",\"controlEtag\"],\"sessions.queue.delete\":[\"clientEventId\",\"expectedTurnVersion\",\"reason\"]});var Qp=Object.freeze([\"initialMessage\",\"requestedSessionId\",\"idempotencyKey\",\"clientEventId\",\"model\",\"reasoningEffort\",\"latencyMode\",\"startMode\",\"metadata\"]);function xi(e){let t=e.structuredContent;if(t===void 0||t===null)return e;let o=e.content.filter((r)=>!Hc(r)||!Xc(r.text,t));if(o.length===e.content.length)return e;return{...e,content:o}}function Hc(e){if(!e||typeof e!==\"object\"||Array.isArray(e))return!1;let t=e;if(t.type!==\"text\"||typeof t.text!==\"string\")return!1;return Object.keys(t).every((o)=>o===\"type\"||o===\"text\")}function Xc(e,t){let o=e.replace(/^[ \\t\\n\\r]+/u,\"\");if(!o.startsWith(\"{\")&&!o.startsWith(\"[\"))return!1;let r;try{r=JSON.parse(e)}catch{return!1}return!Ut(r)&&Vt(r,t)}function Ut(e){if(typeof e===\"number\")return Number.isInteger(e)&&!Number.isSafeInteger(e);if(Array.isArray(e))return e.some(Ut);if(e&&typeof e===\"object\")return Object.values(e).some(Ut);return!1}function Vt(e,t){if(e===t)return!0;if(typeof e!==\"object\"||typeof t!==\"object\"||e===null||t===null)return!1;if(Array.isArray(e)||Array.isArray(t)){if(!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length)return!1;return e.every((i,s)=>Vt(i,t[s]))}let o=e,r=t,n=Object.keys(o);if(n.length!==Object.keys(r).length)return!1;return n.every((i)=>Object.hasOwn(r,i)&&Vt(o[i],r[i]))}var wi=require(\"node:crypto\");class le extends Error{code=\"tool_not_found\";constructor(){super(\"Tool is not present in the active gateway catalog\");this.name=\"ToolGatewayToolNotFoundError\"}}class Jt extends Error{code=\"catalog_integrity_failed\";constructor(){super(\"Tool catalog digest does not match its authoritative content\");this.name=\"ToolGatewayCatalogIntegrityError\"}}class qt extends Error{code=\"catalog_too_large\";constructor(){super(\"Tool catalog exceeds the maximum serialized size\");this.name=\"ToolGatewayCatalogTooLargeError\"}}class $e extends Error{code=\"tool_path_collision\";constructor(e,t){super(t===\"extends_leaf\"?`Tool path ${e.join(\".\")} extends a tool leaf`:`Tool path ${e.join(\".\")} collides`);this.name=\"ToolGatewayPathCollisionError\"}}function Te(e){return wi.createHash(\"sha256\").update(JSON.stringify(Bt(e)),\"utf8\").digest(\"hex\")}function bi(e,t){return Te({domain:\"opengeni.tool-definition\",version:1,accountId:e.accountId,workspaceId:e.workspaceId,entry:t})}function pe(e,t){return e<t?-1:e>t?1:0}function Bt(e){if(Array.isArray(e))return e.map(Bt);if(e!==null&&typeof e===\"object\")return Object.fromEntries(Object.entries(e).sort(([t],[o])=>pe(t,o)).map(([t,o])=>[t,Bt(o)]));return e}function zi(e,t){let o=$i();for(let r of e.entries)Yc(o,r);return[`// Generated by ${t.generatedBy}. Do not edit.`,`// ${t.catalogDigestLabel??\"Tool catalog digest\"}: ${e.digest}`,...t.typedResultWrapperType?[\"// Typed calls normally return their structured output. If image blocks are present,\",\"// they return CodemodeMultimodalValue<T> with local image paths and original content.\"]:[],`import type { ${[t.callOptionsType,t.fallbackResultType,...t.typedResultWrapperType?[t.typedResultWrapperType]:[]].join(\", \")} } from ${JSON.stringify(t.moduleSpecifier)};`,\"\",`declare module ${JSON.stringify(t.moduleSpecifier)} {`,` interface ${t.interfaceName} {`,...Ti(o,4,t),\" }\",\"}\",\"\",\"export {};\",\"\"].join(`\n`)}function Wt(e){return M(e,e,new Set,0)}function $i(){return{children:new Map,entry:null}}function Yc(e,t){let o=e;for(let[r,n]of t.codemodePath.entries()){if(o.entry)throw new $e(t.codemodePath,\"extends_leaf\");let i=o.children.get(n);if(!i)i=$i(),o.children.set(n,i);if(o=i,r===t.codemodePath.length-1){if(o.entry||o.children.size>0)throw new $e(t.codemodePath,\"collision\");o.entry=t}}}function Ti(e,t,o){let r=[];for(let[n,i]of[...e.children].sort(([s],[a])=>pe(s,a))){if(i.entry){let s=i.entry,a=Wt(s.inputSchema),c=s.outputSchema?Wt(s.outputSchema):null,u=c?o.typedResultWrapperType?`${c} | ${o.typedResultWrapperType}<${c}>`:c:o.fallbackResultType,p=su(s.description??s.title);if(p)r.push(...iu(p,t));r.push(`${ne(t)}readonly ${n}: (`),r.push(`${ne(t+2)}argumentsValue${Qc(s.inputSchema)?\"?\":\"\"}: ${a},`),r.push(`${ne(t+2)}options?: ${o.callOptionsType},`),r.push(`${ne(t)}) => Promise<${u}>;`);continue}r.push(`${ne(t)}readonly ${n}: {`),r.push(...Ti(i,t+2,o)),r.push(`${ne(t)}};`)}return r}function Qc(e){if(!se(e))return!1;return(Array.isArray(e.required)?e.required.filter((o)=>typeof o===\"string\"):[]).length===0&&(e.type===\"object\"||se(e.properties))}function M(e,t,o,r){if(r>48||e===!0)return\"unknown\";if(e===!1)return\"never\";if(!se(e))return\"unknown\";if(typeof e.$ref===\"string\"){if(!e.$ref.startsWith(\"#/\")||o.has(e.$ref))return\"unknown\";let a=nu(t,e.$ref);if(a===void 0)return\"unknown\";let c=new Set(o);return c.add(e.$ref),M(a,t,c,r+1)}if(Object.hasOwn(e,\"const\"))return Ye(e.const);if(Array.isArray(e.enum))return ke(e.enum.map(Ye));let n=[];if(Array.isArray(e.oneOf))n.push(ke(e.oneOf.map((a)=>M(a,t,o,r+1))));if(Array.isArray(e.anyOf))n.push(ke(e.anyOf.map((a)=>M(a,t,o,r+1))));if(Array.isArray(e.allOf))n.push(vi(e.allOf.map((a)=>M(a,t,o,r+1))));if(n.length>0){let a=vi(n);return e.nullable===!0?ke([a,\"null\"]):a}let s=(Array.isArray(e.type)?e.type.filter((a)=>typeof a===\"string\"):typeof e.type===\"string\"?[e.type]:ru(e)).map((a)=>eu(a,e,t,o,r+1));if(e.nullable===!0)s.push(\"null\");return ke(s.length>0?s:[\"unknown\"])}function eu(e,t,o,r,n){if(e===\"null\"||e===\"boolean\"||e===\"string\")return e;if(e===\"integer\"||e===\"number\")return\"number\";if(e===\"array\")return tu(t,o,r,n);if(e!==\"object\")return\"unknown\";return ou(t,o,r,n)}function tu(e,t,o,r){if(Array.isArray(e.prefixItems)){let i=e.prefixItems.map((a)=>M(a,t,o,r+1));if(e.items===!1)return`readonly [${i.join(\", \")}]`;let s=e.items===void 0||e.items===!0?\"unknown\":M(e.items,t,o,r+1);return`readonly [${i.join(\", \")}${i.length>0?\", \":\"\"}...${s}[]]`}return`readonly (${e.items===void 0||e.items===!0?\"unknown\":M(e.items,t,o,r+1)})[]`}function ou(e,t,o,r){let n=se(e.properties)?e.properties:{},i=new Set(Array.isArray(e.required)?e.required.filter((c)=>typeof c===\"string\"):[]),s=Object.entries(n).sort(([c],[u])=>pe(c,u)),a=s.map(([c,u])=>`readonly ${Kt(c)}${i.has(c)?\"\":\"?\"}: ${M(u,t,o,r+1)}`);for(let c of[...i].filter((u)=>!Object.hasOwn(n,u)).sort(pe))a.push(`readonly ${Kt(c)}: unknown`);if(e.additionalProperties!==!1){if(s.length===0&&e.additionalProperties!==void 0&&e.additionalProperties!==!0)return`Readonly<Record<string, ${M(e.additionalProperties,t,o,r+1)}>>`;a.push(\"readonly [key: string]: unknown\")}return a.length===0?\"Record<string, never>\":`{ ${a.join(\"; \")} }`}function ru(e){if(se(e.properties)||Object.hasOwn(e,\"additionalProperties\"))return[\"object\"];if(Object.hasOwn(e,\"items\")||Array.isArray(e.prefixItems))return[\"array\"];return[]}function nu(e,t){let o=e;for(let r of t.slice(2).split(\"/\")){if(!se(o))return;let n=r.replace(/~1/gu,\"/\").replace(/~0/gu,\"~\");if(!Object.hasOwn(o,n))return;o=o[n]}return o}function Ye(e){if(e===null||typeof e===\"string\"||typeof e===\"number\"||typeof e===\"boolean\")return JSON.stringify(e);if(Array.isArray(e))return`readonly [${e.map(Ye).join(\", \")}]`;if(se(e))return`{ ${Object.entries(e).sort(([t],[o])=>pe(t,o)).map(([t,o])=>`readonly ${Kt(t)}: ${Ye(o)}`).join(\"; \")} }`;return\"unknown\"}function ke(e){let t=[...new Set(e)];if(t.includes(\"unknown\"))return\"unknown\";if(t.length===0)return\"never\";return t.length===1?t[0]:t.map(ki).join(\" | \")}function vi(e){let t=[...new Set(e.filter((o)=>o!==\"unknown\"))];return t.length===0?\"unknown\":t.length===1?t[0]:t.map(ki).join(\" & \")}function ki(e){return/[|&]/u.test(e)?`(${e})`:e}function Kt(e){return/^[A-Za-z_$][A-Za-z0-9_$]*$/u.test(e)?e:JSON.stringify(e)}function su(e){if(!e)return null;let t=e.replace(/\\s+/gu,\" \").trim().replace(/\\*\\//gu,\"*\\\\/\");if(!t)return null;return t.length<=512?t:`${t.slice(0,509)}...`}function iu(e,t){return[`${ne(t)}/** ${e} */`]}function ne(e){return\" \".repeat(e)}function se(e){return e!==null&&typeof e===\"object\"&&!Array.isArray(e)}var Z=require(\"node:fs/promises\"),Qe=require(\"node:os\"),V=require(\"node:path\"),Ai=16777216,au=\"opengeni-codemode-image-\",cu=86400000,uu=3600000,Ei=0;async function et(e,t={}){let o=e.content.filter((a)=>a.type===\"image\");if(t.requireOne&&o.length!==1)throw Error(\"Codemode browser screenshot must return exactly one image block\");if(o.length===0)return[];if(t.saveTo!==void 0&&o.length!==1)throw Error(\"An explicit image path requires exactly one image block\");let r=0,n=o.map((a)=>{let c=pu(a.mimeType);if(r+=a.data.length,a.data.length===0||a.data.length>Ai||r>Ai)throw Error(\"Codemode image exceeds the Code Mode result limit\");let u=Buffer.from(a.data,\"base64\");if(u.length===0||u.toString(\"base64\")!==a.data||!du(u,c))throw Error(\"Codemode image bytes are invalid\");return{bytes:u,mimeType:c}}),i;if(t.saveTo===void 0)await lu(),i=await Z.mkdtemp(V.join(Qe.tmpdir(),au));else{if(t.saveTo.length===0)throw TypeError(\"Image saveTo must be a nonempty path\");await Z.mkdir(V.dirname(V.resolve(t.saveTo)),{recursive:!0})}let s=[];try{for(let[a,c]of n.entries()){let u=c.mimeType===\"image/jpeg\"?\"jpg\":c.mimeType.split(\"/\")[1],p=t.saveTo===void 0?V.join(i,n.length===1?`frame.${u}`:`image-${a+1}.${u}`):V.resolve(t.saveTo);await Z.writeFile(p,c.bytes,{flag:\"wx\",mode:384}),s.push({path:p,mimeType:c.mimeType,sizeBytes:c.bytes.length})}}catch(a){if(i)await Z.rm(i,{recursive:!0,force:!0});throw a}return s}async function lu(){let e=Date.now();if(e-Ei<uu)return;if(Ei=e,typeof process.getuid!==\"function\")return;try{let t=0;for(let o of await Z.readdir(Qe.tmpdir(),{withFileTypes:!0})){if(!o.isDirectory()||!/^opengeni-codemode-image-[A-Za-z0-9]{6}$/u.test(o.name))continue;let r=V.join(Qe.tmpdir(),o.name),n=await Z.lstat(r);if(!n.isDirectory()||n.uid!==process.getuid()||(n.mode&63)!==0||e-n.mtimeMs<cu)continue;if(await Z.rm(r,{recursive:!0,force:!0}),++t>=64)break}}catch{}}function pu(e){if(e===\"image/png\"||e===\"image/jpeg\"||e===\"image/webp\")return e;throw Error(`Codemode image has unsupported type: ${e}`)}function du(e,t){switch(t){case\"image/png\":return e.length>=8&&e.subarray(0,8).equals(Buffer.from(\"89504e470d0a1a0a\",\"hex\"));case\"image/jpeg\":return e.length>=3&&e[0]===255&&e[1]===216&&e[2]===255;case\"image/webp\":return e.length>=12&&e.toString(\"ascii\",0,4)===\"RIFF\"&&e.toString(\"ascii\",8,12)===\"WEBP\"}}function Si(e,t={}){let o=tt(e);return zi({digest:o.digest,entries:o.entries},{moduleSpecifier:t.moduleSpecifier??\"@opengeni/codemode\",interfaceName:\"CodemodeGeneratedTools\",callOptionsType:\"CodemodeCallOptions\",fallbackResultType:\"CodemodeToolResult\",typedResultWrapperType:\"CodemodeMultimodalValue\",generatedBy:\"@opengeni/codemode via @opengeni/tool-gateway\",catalogDigestLabel:\"Attempt catalog digest\"})}class L extends Error{status;code=\"codemode_transport_error\";remoteCode;retryable;outcomeUnknown;details;constructor(e,t=null,o={}){super(e);this.status=t;this.name=\"CodemodeTransportError\",this.remoteCode=o.code??null,this.retryable=o.retryable??null,this.outcomeUnknown=o.outcomeUnknown??null,this.details=o.details??null}}class Ae extends Error{operation;code;constructor(e,t){super(e.errorMessage??`Codemode operation ${e.state}`);this.operation=e;this.code=t;this.name=\"CodemodeOperationError\",Object.defineProperty(this,\"operation\",{value:e,enumerable:!1})}}class Ee extends Error{operationId;approvalRequestId;code=\"codemode_approval_pending\";state=\"waiting_for_approval\";constructor(e,t){super(`Operation ${e} is waiting for approval. After review, read or resume this handle; do not submit its arguments again.`);this.operationId=e;this.approvalRequestId=t;this.name=\"CodemodeApprovalPendingError\"}}class Ii extends Error{result;code;retryable;constructor(e){let t=wu(e);super(t.message);this.result=e;this.name=\"CodemodeToolCallError\",this.code=t.code,this.retryable=t.retryable}}class Zi extends Error{code=\"invalid_tool_result\";constructor(e){super(e);this.name=\"CodemodeToolContractError\"}}class Yt{options;baseUrl;fetchImpl;pollIntervalMs;timeoutMs;catalogSnapshot=null;constructor(e){this.options=e;if(this.baseUrl=e.baseUrl.replace(/\\/+$/u,\"\"),!/^https?:\\/\\//u.test(this.baseUrl))throw Error(\"Codemode baseUrl must be an absolute HTTP(S) URL\");this.fetchImpl=e.fetch??globalThis.fetch.bind(globalThis),this.pollIntervalMs=ot(e.pollIntervalMs??500,50,30000),this.timeoutMs=ot(e.timeoutMs??600000,1000,3600000)}async catalog(e={}){if(this.catalogSnapshot&&!e.refresh)return this.catalogSnapshot;let t=await this.request(\"/catalog\",{method:\"GET\",...e.signal?{signal:e.signal}:{}}),o=tt(await t.json());return this.catalogSnapshot=o,o}async tools(e={}){return hu(await this.catalog(e),this)}async call(e,t={},o={}){return(await this.callResolved((r)=>r.entries.find((n)=>n.identity.serverId===e.serverId&&n.identity.toolName===e.toolName)??null,t,o)).result}async callResolved(e,t,o){let r=await this.catalog(o.signal?{signal:o.signal}:{}),n=e(r);if(!n)throw new le;let i=()=>{if(o.expectedDefinitionDigest!==void 0&&o.expectedDefinitionDigest!==bi(r,n))throw new L(\"The tool definition changed before execution\",409,{code:\"tool_definition_stale\",retryable:!0,outcomeUnknown:!1})};i();let s=o.operationId??Pi.randomUUID(),a=Date.now()+ot(o.timeoutMs??this.timeoutMs,1000,3600000),c=!1,u=!1,p=null,d=0;while(!0){if(Ht(o.signal),Date.now()>=a)throw new L(`Codemode operation ${s} did not settle before the client deadline`);if(!c||(p?.state===\"queued\"||p?.state===\"running\")&&Date.now()>=d){c=!0,d=Date.now()+2000;try{p=await this.submit(s,r.digest,n.identity,t,o.signal)}catch(m){if(p===null&&!u&&m instanceof L&&m.outcomeUnknown!==!0&&m.retryable!==!1&&m.remoteCode===\"codemode_catalog_stale\"){if(u=!0,r=await this.catalog({refresh:!0,...o.signal?{signal:o.signal}:{}}),n=e(r),!n)throw new le;i(),c=!1,d=0;continue}if(o.signal?.aborted)throw m;if(p===null&&!mu(m))throw m;let y;try{y=await this.read(s,o.signal)}catch(G){if(o.signal?.aborted)throw G;throw new L(`Codemode operation ${s} could not be reconciled after its submission response failed`,null,{code:\"codemode_operation_recovery_unavailable\",retryable:!0,outcomeUnknown:!0,details:{operationId:s}})}fu(y,{operationId:s,catalog:r,identity:n.identity,arguments:t}),p=y}}else p=await this.read(s,o.signal);if(p.state===\"waiting_for_approval\")throw new Ee(p.operationId,p.approvalRequestId);if(p.state===\"completed\")return{result:He.parse(p.result),entry:n};if([\"failed\",\"outcome_unknown\",\"cancelled\"].includes(p.state))throw new Ae(p,p.errorCode??`codemode_${p.state}`);await Xt(this.pollIntervalMs,o.signal)}}async callPath(e,t={},o={}){if(e.length<2||e.some((r)=>r.length===0))throw new le;return(await this.callResolved((r)=>Ci(r,e),t,o)).result}async callPathValue(e,t={},o={}){if(e.length<2||e.some((s)=>s.length===0))throw new le;let{result:r,entry:n}=await this.callResolved((s)=>Ci(s,e),t,o);if(!n.outputSchema)return r;if(r.isError)throw new Ii(r);if(!r.structuredContent)throw new Zi(`Codemode tool ${e.join(\".\")} declared outputSchema but returned no structured content`);if(!r.content.some((s)=>s.type===\"image\"))return r.structuredContent;let i=await et(r);return{structuredContent:r.structuredContent,images:i,otherContent:r.content.filter((s)=>s.type!==\"image\")}}async submit(e,t,o,r,n){return await Oi(n,async()=>{let i=await this.request(\"/calls\",{method:\"POST\",...n?{signal:n}:{},headers:{\"content-type\":\"application/json\"},body:JSON.stringify({operationId:e,catalogDigest:t,identity:o,arguments:r,durableApproval:!0})});return fi.parse(await i.json()).operation})}async status(e,t){let o=await this.read(e,t);return{operationId:o.operationId,state:o.state,approvalRequestId:o.approvalRequestId,result:o.result,errorCode:o.errorCode,errorMessage:o.errorMessage}}async resume(e,t={}){let o=Date.now()+ot(t.timeoutMs??this.timeoutMs,1000,3600000);while(!0){Ht(t.signal);let r=await this.read(e,t.signal);if(r.state===\"waiting_for_approval\")throw new Ee(r.operationId,r.approvalRequestId);if(r.state===\"completed\")return He.parse(r.result);if([\"failed\",\"outcome_unknown\",\"cancelled\"].includes(r.state))throw new Ae(r,r.errorCode??`codemode_${r.state}`);if(Date.now()>=o)throw new L(`Codemode operation ${e} did not settle before the client deadline`);await Xt(this.pollIntervalMs,t.signal)}}async read(e,t){return await Oi(t,async()=>{let o=await this.request(`/calls/${e}`,{method:\"GET\",...t?{signal:t}:{}});return Ft.parse(await o.json())})}async sessionRequest(e,t){return _i(e,\"site-host\"),this.request(`/sdk${e}`,t,!1)}async request(e,t,o=!0){let r=typeof this.options.token===\"function\"?await this.options.token():this.options.token,n=await this.fetchImpl(`${this.baseUrl}${e}`,{...t,headers:{...Object.fromEntries(new Headers(t.headers).entries()),authorization:`Bearer ${r}`,\"x-opengeni-codemode-capabilities\":\"durable-approval-v1\"}});if(!n.ok&&o){let i=`Codemode request failed with HTTP ${n.status}`,s={};try{let a=bu(await n.json());if(a?.message)i=a.message;if(a)s={...a.code?{code:a.code}:{},...a.retryable===void 0?{}:{retryable:a.retryable},...a.outcomeUnknown===void 0?{}:{outcomeUnknown:a.outcomeUnknown},...a.details?{details:a.details}:{}}}catch{}throw new L(i,n.status,s)}return n}}function mu(e){return!(e instanceof L)||e.outcomeUnknown===!0}function fu(e,t){if(e.operationId===t.operationId&&e.accountId===t.catalog.accountId&&e.workspaceId===t.catalog.workspaceId&&e.sessionId===t.catalog.sessionId&&e.turnId===t.catalog.turnId&&e.attemptId===t.catalog.attemptId&&e.executionGeneration===t.catalog.executionGeneration&&e.catalogDigest===t.catalog.digest&&e.identity.serverId===t.identity.serverId&&e.identity.toolName===t.identity.toolName&&Te(e.arguments)===Te(t.arguments))return;throw new L(\"Codemode operation id is already bound to a different request\",409,{code:\"codemode_operation_conflict\",retryable:!1,outcomeUnknown:!1})}function hu(e,t){let o=tt(e),r=Object.create(null);for(let n of o.entries){let i=r;for(let c of n.codemodePath.slice(0,-1)){let u=i[c];if(typeof u===\"function\")throw Error(\"Codemode path collides with a tool\");if(!u)u=Object.create(null),i[c]=u;i=u}let s=n.codemodePath.at(-1),a=async(c={},u={})=>await t.callPathValue(n.codemodePath,c,u);Object.defineProperty(a,\"entry\",{value:n,enumerable:!1}),i[s]=a}return r}function gu(e){let{createdAt:t,...o}=e;return Te(o)}function tt(e){return _u(e).catalog}var yu=new WeakMap;function _u(e){if(e!==null&&typeof e===\"object\"){let i=yu.get(e);if(i)return{...i}}let t=di.parse(e),o=xu(t),{digest:r,...n}=t;if(gu(n)!==r)throw new Jt;return{catalog:t,byteLength:o}}function xu(e){let t=new TextEncoder().encode(JSON.stringify(e)).byteLength;if(t>ci)throw new qt;return t}function ot(e,t,o){if(!Number.isFinite(e))return t;return Math.max(t,Math.min(o,Math.floor(e)))}function Ht(e){if(e?.aborted)throw e.reason??new DOMException(\"Aborted\",\"AbortError\")}function wu(e){let o=e.structuredContent?.error;return{code:typeof o?.code===\"string\"?o.code:\"tool_error\",message:typeof o?.message===\"string\"?o.message:\"Codemode tool failed\",retryable:o?.retryable===!0}}function Ci(e,t){let o=e.entries.filter((r)=>r.codemodePath.length===t.length&&r.codemodePath.every((n,i)=>n===t[i]));return o.length===1?o[0]:null}function bu(e){if(!e||typeof e!==\"object\"||Array.isArray(e))return null;let t=e,o=t.error&&typeof t.error===\"object\"&&!Array.isArray(t.error)?t.error:t,r=o.details&&typeof o.details===\"object\"&&!Array.isArray(o.details)?o.details:void 0,n=r?.code,i=typeof n===\"string\"&&/^[a-z0-9_]{1,128}$/u.test(n)?n:void 0,s=typeof o.message===\"string\"?o.message:void 0,a=typeof o.retryable===\"boolean\"?o.retryable:void 0,c=typeof o.outcomeUnknown===\"boolean\"?o.outcomeUnknown:void 0;return s||i||a!==void 0||c!==void 0||r?{...s?{message:s}:{},...i?{code:i}:{},...a===void 0?{}:{retryable:a},...c===void 0?{}:{outcomeUnknown:c},...r?{details:r}:{}}:null}var vu=[100,250,500,1000,2000];function zu(e){return e instanceof L&&e.status!==null&&e.status>=500&&e.retryable===!0&&e.outcomeUnknown!==!0}async function Oi(e,t){for(let o=0;;o+=1)try{return await t()}catch(r){let n=vu[o];if(n===void 0||e?.aborted||!zu(r))throw r;await Xt(n+Math.floor(Math.random()*n),e)}}async function Xt(e,t){if(!t){await new Promise((o)=>setTimeout(o,e));return}Ht(t),await new Promise((o,r)=>{let n=setTimeout(()=>{t.removeEventListener(\"abort\",i),o()},e),i=()=>{clearTimeout(n),r(t.reason??new DOMException(\"Aborted\",\"AbortError\"))};t.addEventListener(\"abort\",i,{once:!0})})}var Ri={name:\"@opengeni/ogtool\",version:\"4.6.2-canary.39853438886001\",description:\"Codemode CLI and typed client entrypoint for an Opengeni execution attempt.\",license:\"Apache-2.0\",repository:{type:\"git\",url:\"git+https://github.com/Cloudgeni-ai/opengeni.git\",directory:\"packages/ogtool\"},bin:{ogtool:\"./dist/bin/ogtool.cjs\"},files:[\"dist\",\"src\"],type:\"module\",sideEffects:!1,main:\"./src/index.ts\",module:\"./src/index.ts\",types:\"./src/index.ts\",exports:{\".\":{types:\"./src/index.ts\",default:\"./src/index.ts\"}},publishConfig:{access:\"public\",provenance:!0},scripts:{typecheck:\"tsrs --noEmit\",test:\"bun test\",build:\"bun build.ts\",prepublishOnly:\"bash ../../scripts/prepublish-guard\"},dependencies:{\"@opengeni/codemode\":\"workspace:*\",\"@opengeni/contracts\":\"workspace:*\"},devDependencies:{tsup:\"^8.5.0\",typescript:\"7.0.2\"},engines:{node:\">=18\"}};function Ni(e){return(e.description||e.title||\"\").split(/\\p{White_Space}+/u).filter(Boolean).join(\" \")}function Tu(e){let t=Ni(e),o=Array.from(t);return o.length<=160?t:`${o.slice(0,159).join(\"\")}…`}function ku(e){return e.replace(/[\\u0000-\\u001f\\u007f-\\u009f]/gu,(t)=>`\\\\u${t.charCodeAt(0).toString(16).padStart(4,\"0\")}`)}function ji(e){let t={full:!1,json:!1,query:\"\",offset:0},o=new Set,r=()=>Error(\"usage: ogtool list [--full | --json] [--query <substring>] [--limit <1..100>] [--offset <nonnegative integer>]\");for(let n=0;n<e.length;n++){let i=e[n],s=i.indexOf(\"=\"),a=s<0?i:i.slice(0,s);if(o.has(a))throw r();if(o.add(a),a===\"--full\"||a===\"--json\"){if(s>=0)throw r();t[a===\"--full\"?\"full\":\"json\"]=!0}else if(a===\"--query\"||a===\"--limit\"||a===\"--offset\"){let c=s<0?e[++n]:i.slice(s+1);if(c===void 0||s<0&&c.startsWith(\"-\"))throw r();if(a===\"--query\")t.query=c;else{if(!/^[0-9]+$/u.test(c)||!Number.isSafeInteger(Number(c)))throw r();let u=Number(c);if(a===\"--limit\"&&(u<1||u>100))throw r();t[a===\"--limit\"?\"limit\":\"offset\"]=u}}else throw r()}if(t.full&&o.size!==1)throw r();return t}function Di(e,t){let o=e.entries.filter((c)=>c.codemodePath.join(\".\").includes(t.query)||Ni(c).includes(t.query)),r=o.slice(t.offset,t.limit===void 0?void 0:t.offset+t.limit).map((c)=>({path:c.codemodePath.join(\".\"),description:Tu(c)})),n=t.json?[]:r.map((c)=>`${c.path}${c.description?` — ${ku(c.description)}`:\"\"}\n`),i=t.offset+r.length<o.length?t.offset+r.length:null,s={catalogDigest:e.digest,total:o.length,offset:t.offset,nextOffset:i,tools:r};return t.json?`${JSON.stringify(s)}\n`:n.join(\"\")+`# total: ${s.total}; offset: ${s.offset}; nextOffset: ${i??\"none\"}\n`+(i===null?\"\":`# Continue with --offset ${i} (keep the same --query and --limit).\n`)}var Au=/(?<!\\\\)\\\\(\\{\\{secret(?:file)?:)/gu;function Mi(e){if(e===void 0)return{};let t;try{t=JSON.parse(e)}catch{let o=e.replace(Au,\"$1\");try{if(o===e)throw Error(\"unchanged\");t=JSON.parse(o)}catch{throw Error(e.includes(\"{{secret\")?\"tool arguments must be valid JSON; inside `ogtool call` write a reference as \\\\{{secret:…}} with one backslash\":\"tool arguments must be valid JSON\")}}if(!t||typeof t!==\"object\"||Array.isArray(t))throw Error(\"tool arguments must be a JSON object\");return t}var Eu=\"@opengeni/ogtool\",Gi=Ri.version;function rt(e=1){let t=[\"usage:\",\" ogtool list [--full | --json]\",\" [--query <substring>] [--limit <1..100>] [--offset <nonnegative integer>]\",\" ogtool show <tool-path-or-model-name>\",\" ogtool call <tool-path-or-model-name> [json-object] [--full] [--save-image <path>]\",\" ogtool read <operation-id>\",\" ogtool resume <operation-id>\",\" ogtool declarations [output-file]\",\" ogtool doctor\",\" ogtool --version\",\"\",\"list returns all authorized tools by default; --limit/--offset are opt-in slices\",\"call omits a text block that only repeats structuredContent; --full prints the exact result\",\"call writes images (such as screenshots) to files and prints their paths instead of base64;\",\" --save-image saves the result's single image at that path and never overwrites\",\" if the call completes but its image cannot be saved, the result is still printed\",\" with imageSaveError and the exit code is 4; do not repeat that call\",\"\",\"requires OPENGENI_CODEMODE_URL and OPENGENI_CODEMODE_TOKEN or OPENGENI_CODEMODE_TOKEN_FILE\"].join(`\n`);(e===0?process.stdout:process.stderr).write(`${t}\n`),process.exitCode=e}function Su(){let e=process.env.OPENGENI_CODEMODE_URL?.trim(),t=process.env.OPENGENI_CODEMODE_TOKEN!==void 0,o=process.env.OPENGENI_CODEMODE_TOKEN_FILE?.trim();if(!e)throw Error(\"OPENGENI_CODEMODE_URL is required\");if(!t&&!o)throw Error(\"OPENGENI_CODEMODE_TOKEN or OPENGENI_CODEMODE_TOKEN_FILE is required\");return new Yt({baseUrl:e,token:t?async()=>Cu():async()=>Ou(o)})}function Cu(){let e=process.env.OPENGENI_CODEMODE_TOKEN?.trim();if(!e)throw Error(\"OPENGENI_CODEMODE_TOKEN is empty\");return e}function Ou(e){let t;try{t=P.readFileSync(e,\"utf8\").trim()}catch{throw Error(\"OPENGENI_CODEMODE_TOKEN_FILE is not readable\")}if(!t)throw Error(\"OPENGENI_CODEMODE_TOKEN_FILE is empty\");return t}function Pu(){let e=process.env.OPENGENI_CODEMODE_TOKEN,t=e!==void 0,o=Boolean(e?.trim().length),r=process.env.OPENGENI_CODEMODE_TOKEN_FILE??null,n=process.env.OPENGENI_CODEMODE_URL??null,i=!1,s=null;if(n)try{s=new URL(n).protocol,i=s===\"http:\"||s===\"https:\"}catch{i=!1}let a=!1,c=!1;if(r)try{a=P.statSync(r).isFile(),c=a&&P.readFileSync(r,\"utf8\").trim().length>0}catch{a=!1}let u=t?\"environment\":r?\"file\":null,d=i&&(t?o:c);process.stdout.write(`${JSON.stringify({ok:d,package:Eu,version:Gi,node:process.version,urlConfigured:n!==null,urlValid:i,protocol:s,tokenMode:u,directTokenConfigured:t,directTokenNonempty:o,tokenFileConfigured:r!==null,tokenFileReadable:a,tokenFileNonempty:c,packageSpec:process.env.OPENGENI_OGTOOL_PACKAGE_SPEC??null},null,2)}\n`),process.exitCode=d?0:1}function Qt(e,t){let o=e.entries.filter((r)=>r.modelName===t||r.codemodePath.join(\".\")===t||`${r.identity.serverId}.${r.identity.toolName}`===t);if(o.length!==1)throw Error(o.length===0?`Unknown Codemode tool: ${t}`:`Ambiguous tool: ${t}`);return o[0]}function eo(e){return{catalogDigest:e.digest,attemptId:e.attemptId,tools:e.entries.map((t)=>({name:t.modelName,path:t.codemodePath.join(\".\"),identity:t.identity,...t.title?{title:t.title}:{},...t.description?{description:t.description}:{},inputSchema:t.inputSchema,...t.outputSchema?{outputSchema:t.outputSchema}:{},...t.annotations?{annotations:t.annotations}:{},approval:t.approval,source:t.source}))}}function Fi(e,t){let o=Qt(e,t),r=eo({...e,entries:[o]});return`${JSON.stringify(r.tools[0],null,2)}\n`}function to(e,t=!1){let o=t?e:xi(e);return`${JSON.stringify(o,null,2)}\n`}async function oo(e,t={}){if(t.full&&t.saveTo===void 0)return e;let o=await et(e,{...t.saveTo===void 0?{}:{saveTo:t.saveTo}});if(t.saveTo!==void 0&&o.length!==1)throw Error(\"--save-image needs a result with exactly one image\");if(t.full||o.length===0)return e;let r=0;return{...e,content:e.content.map((n)=>{if(n.type!==\"image\")return n;let i=o[r++];return{type:\"image\",mimeType:i.mimeType,path:i.path,sizeBytes:i.sizeBytes}})}}function Ui(e){let t=Se.resolve(e),o=!0;try{P.lstatSync(t)}catch(r){if(r.code!==\"ENOENT\")throw r;o=!1}if(o)throw Error(`--save-image ${t} already exists; choose a new path (nothing was called)`);P.mkdirSync(Se.dirname(t),{recursive:!0}),P.accessSync(Se.dirname(t),P.constants.W_OK)}async function Vi(e,t,o,r){let n=e;if(!r)try{n=await oo(e)}catch{n=e}return to({...n,imageSaveError:{operationId:o,message:t instanceof Error?t.message:String(t),note:\"The call completed; only saving its image failed. Do not repeat the call.\"}},r)}function Iu(e){let t=!1,o,r=[];for(let n=0;n<e.length;n+=1){let i=e[n];if(i===\"--full\")t=!0;else if(i===\"--save-image\"){let s=e[++n];if(!s)throw Error(\"--save-image requires a path\");o=s}else if(i.startsWith(\"--save-image=\")){if(o=i.slice(13),!o)throw Error(\"--save-image requires a path\")}else r.push(i)}return{full:t,...o===void 0?{}:{saveTo:o},rest:r}}async function Zu(){let e=process.argv[2];if(e===\"--help\"||e===\"-h\"||e===\"help\")return rt(0);if(e===\"--version\"||e===\"-V\"||e===\"version\"){process.stdout.write(`${Gi}\n`);return}if(e===\"doctor\")return Pu();if(!e)return rt();let t=process.argv.slice(3);if((e===\"list\"||e===\"show\")&&t.length===1&&(t[0]===\"--help\"||t[0]===\"-h\"))return rt(0);let o=e===\"list\"?ji(t):null;if(e===\"show\"&&(t.length!==1||!t[0]||t[0].startsWith(\"-\")))throw Error(\"usage: ogtool show <tool-path-or-model-name>\");let r=Su();if(e===\"read\"||e===\"resume\"){if(t.length!==1||!/^[0-9a-f-]{36}$/iu.test(t[0]))throw Error(\"A valid operation ID is required\");let n=e===\"read\"?await r.status(t[0]):await r.resume(t[0]);process.stdout.write(`${JSON.stringify(n,null,2)}\n`);return}if(e===\"list\"){let n=await r.catalog();if(o.full)process.stdout.write(`${JSON.stringify(eo(n),null,2)}\n`);else process.stdout.write(Di(n,o));return}if(e===\"show\"){process.stdout.write(Fi(await r.catalog(),t[0]));return}if(e===\"call\"){let{full:n,saveTo:i,rest:s}=Iu(t),[a,c]=s;if(!a)throw Error(\"tool path or model name is required\");let u=Mi(c),p=await r.catalog(),d=Qt(p,a);if(i!==void 0)Ui(i);let h=Li.randomUUID(),m=await r.call(d.identity,u,{operationId:h}),y;try{y=await oo(m,{full:n,...i===void 0?{}:{saveTo:i}})}catch(G){process.stdout.write(await Vi(m,G,h,n)),process.exitCode=4;return}process.stdout.write(to(y,n));return}if(e===\"declarations\"){let n=await r.catalog(),i=Si(n),s=process.argv[3];if(!s||s===\"-\")process.stdout.write(i);else P.writeFileSync(s,i,{encoding:\"utf8\",mode:384}),process.stdout.write(`${JSON.stringify({catalogDigest:n.digest,output:s},null,2)}\n`);return}return rt()}Zu().catch((e)=>{if(e instanceof Ee){process.stdout.write(`${JSON.stringify({operationId:e.operationId,state:e.state,code:e.code,approvalRequestId:e.approvalRequestId,message:e.message})}\n`),process.exitCode=2;return}if(e instanceof Ae){process.stdout.write(`${JSON.stringify({operationId:e.operation.operationId,state:e.operation.state,code:e.code,message:e.message})}\n`),process.exitCode=e.operation.state===\"outcome_unknown\"?3:1;return}let t=e&&typeof e===\"object\"&&\"code\"in e?String(e.code):null;process.stderr.write(`${e instanceof Error?e.message:String(e)}\n`),process.exitCode=t===\"tool_outcome_unknown\"?3:1});\n","client.mjs":"import{createRequire as IT}from\"node:module\";var bT=Object.create;var{getPrototypeOf:vT,defineProperty:Ou,getOwnPropertyNames:_T}=Object;var $u=Object.prototype.hasOwnProperty;function wT(e){return this[e]}var xT,ST,ho=(e,t,n)=>{var r=e!=null&&typeof e===\"object\";if(r){var o=t?xT??=new WeakMap:ST??=new WeakMap,s=o.get(e);if(s)return s}n=e!=null?bT(vT(e)):{};let i=t||!e||!e.__esModule||!$u.call(e,\"default\")?Ou(n,\"default\",{value:e,enumerable:!0}):n;if(e&&typeof e===\"object\"||typeof e===\"function\"){for(let a of _T(e))if(!$u.call(i,a))Ou(i,a,{get:wT.bind(e,a),enumerable:!0})}if(r)o.set(e,i);return i};var g=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var _e=IT(import.meta.url);var et=g(function(xE){xE.getValueAsString=function(t){if(Number.isNaN(t))return\"Nan\";else if(!Number.isFinite(t))if(t<0)return\"-Inf\";else return\"+Inf\";else return`${t}`};xE.removeLabels=function(t,n,r){let o=Sa(n,r);delete t[o]};xE.setValue=function(t,n,r){let o=Sa(r);return t[o]={value:typeof n===\"number\"?n:0,labels:r||{}},t};xE.setValueDelta=function(t,n,r,o=\"\"){let s=typeof n===\"number\"?n:0;if(t[o])t[o].value+=s;else t[o]={value:s,labels:r};return t};xE.getLabels=function(e,t){if(typeof t[0]===\"object\")return t[0];if(e.length!==t.length)throw Error(`Invalid number of arguments (${t.length}): \"${t.join(\", \")}\" for label names (${e.length}): \"${e.join(\", \")}\".`);let n={};for(let r=0;r<e.length;r++)n[e[r]]=t[r];return n};function Og(e,t){if(e.length===0)return\"\";let n=\"\";for(let r=0;r<e.length;r++){let o=e[r],s=t[o];if(s===void 0)continue;n+=`${o}:${s},`}return n}function Sa(e,t){if(t)return Og(t,e);let n=Object.keys(e);if(n.length>1)n.sort();return Og(n,e)}xE.hashObject=Sa;xE.isObject=function(t){return t!==null&&typeof t===\"object\"};xE.nowTimestamp=function(){return Date.now()/1000};class $g extends Map{add(e,t){if(this.has(e))this.get(e).push(t);else this.set(e,[t])}}xE.Grouper=$g});var Nn=g(function(TW,Ra){var{getValueAsString:Mg}=et();class He{static get PROMETHEUS_CONTENT_TYPE(){return\"text/plain; version=0.0.4; charset=utf-8\"}static get OPENMETRICS_CONTENT_TYPE(){return\"application/openmetrics-text; version=1.0.0; charset=utf-8\"}constructor(e=He.PROMETHEUS_CONTENT_TYPE){if(this._metrics={},this._collectors=[],this._defaultLabels={},e!==He.PROMETHEUS_CONTENT_TYPE&&e!==He.OPENMETRICS_CONTENT_TYPE)throw TypeError(`Content type ${e} is unsupported`);this._contentType=e}getMetricsAsArray(){return Object.values(this._metrics)}async getMetricsAsString(e){let t=typeof e.getForPromString===\"function\"?await e.getForPromString():await e.get(),n=ka(t.name),r=`# HELP ${n} ${ka(t.help)}`,o=`# TYPE ${n} ${t.type}`,s=[r,o],i=Object.keys(this._defaultLabels).length>0?this._defaultLabels:null,a=this.contentType===He.OPENMETRICS_CONTENT_TYPE;for(let c of t.values||[]){let{metricName:l=n,labels:u={}}=c,{sharedLabels:p={}}=c;if(a&&t.type===\"counter\")l=`${l}_total`;if(i)u={...u,...i,...u};let m=Ia(u,p),d=OE(p),f=[...m,d].filter(Boolean),h=f.length?`{${f.join(\",\")}}`:\"\",y=`${l}${h} ${Mg(c.value)}`,{exemplar:_}=c;if(_&&a){let E=Ia(_.labelSet);y+=` # {${E.join(\",\")}} ${Mg(_.value)} ${_.timestamp}`}s.push(y)}return s.join(`\n`)}async metrics(){let e=this.contentType===He.OPENMETRICS_CONTENT_TYPE,t=this.getMetricsAsArray().map((r)=>{if(e&&r.type===\"counter\")r.name=ME(r.name);return this.getMetricsAsString(r)}),n=await Promise.all(t);return e?`${n.join(`\n`)}\n# EOF\n`:`${n.join(`\n\n`)}\n`}registerMetric(e){if(this._metrics[e.name]&&this._metrics[e.name]!==e)throw Error(`A metric with the name ${e.name} has already been registered.`);this._metrics[e.name]=e}clear(){this._metrics={},this._defaultLabels={}}async getMetricsAsJSON(){let e=[],t=Object.keys(this._defaultLabels),n=[];for(let o of this.getMetricsAsArray())n.push(o.get());let r=await Promise.all(n);for(let o of r){if(o.values&&t.length>0)for(let s of o.values){s.labels=Object.assign({},s.labels);for(let i of t)s.labels[i]=s.labels[i]||this._defaultLabels[i]}e.push(o)}return e}removeSingleMetric(e){delete this._metrics[e]}getSingleMetricAsString(e){return this.getMetricsAsString(this._metrics[e])}getSingleMetric(e){return this._metrics[e]}setDefaultLabels(e){this._defaultLabels=e}resetMetrics(){for(let e in this._metrics)this._metrics[e].reset()}get contentType(){return this._contentType}setContentType(e){if(e===He.OPENMETRICS_CONTENT_TYPE||e===He.PROMETHEUS_CONTENT_TYPE)this._contentType=e;else throw Error(`Content type ${e} is unsupported`)}static merge(e){let t=e[0].contentType;for(let o of e)if(o.contentType!==t)throw Error(\"Registers can only be merged if they have the same content type\");let n=new He(t);return e.reduce((o,s)=>o.concat(s.getMetricsAsArray()),[]).forEach(n.registerMetric,n),n}}function Ia(e,t){let{hasOwnProperty:n}=Object.prototype,r=[];for(let[o,s]of Object.entries(e))if(!t||!n.call(t,o))r.push(`${o}=\"${$E(s)}\"`);return r}var qg=new WeakMap;function OE(e){let t=qg.get(e);if(t)return t;let r=Ia(e).join(\",\");return qg.set(e,r),r}function $E(e){if(typeof e!==\"string\")return e;return ka(e).replace(/\"/g,\"\\\\\\\"\")}function ka(e){return e.replace(/\\\\/g,\"\\\\\\\\\").replace(/\\n/g,\"\\\\n\")}function ME(e){return e.replace(/_total$/,\"\")}Ra.exports=He;Ra.exports.globalRegistry=new He});var yn=g(function(jE){var zg=_e(\"util\"),qE=/^[a-zA-Z_:][a-zA-Z0-9_:]*$/,zE=/^[a-zA-Z_][a-zA-Z0-9_]*$/;jE.validateMetricName=function(e){return qE.test(e)};jE.validateLabelName=function(e=[]){return e.every((t)=>zE.test(t))};jE.validateLabel=function(t,n){for(let r in n)if(!t.includes(r))throw Error(`Added label \"${r}\" is not included in initial labelset: ${zg.inspect(t)}`)}});var Nr=g(function(CW,Ng){var Dn=Nn(),{isObject:LE}=et(),{validateMetricName:GE,validateLabelName:BE}=yn();class jg{constructor(e,t={}){if(!LE(e))throw TypeError(\"constructor expected a config object\");if(Object.assign(this,{labelNames:[],registers:[Dn.globalRegistry],aggregator:\"sum\",enableExemplars:!1},t,e),!this.registers)this.registers=[Dn.globalRegistry];if(!this.help)throw Error(\"Missing mandatory help parameter\");if(!this.name)throw Error(\"Missing mandatory name parameter\");if(!GE(this.name))throw Error(\"Invalid metric name\");if(!BE(this.labelNames))throw Error(\"Invalid label name\");if(this.collect&&typeof this.collect!==\"function\")throw Error('Optional \"collect\" parameter must be a function');if(this.labelNames)this.sortedLabelNames=[...this.labelNames].sort();else this.sortedLabelNames=[];this.reset();for(let n of this.registers){if(this.enableExemplars&&n.contentType===Dn.PROMETHEUS_CONTENT_TYPE)throw TypeError(\"Exemplars are supported only on OpenMetrics registries\");n.registerMetric(this)}}reset(){}}Ng.exports={Metric:jg}});var Ta=g(function(EW,Ug){class Dg{constructor(e={},t=null){this.labelSet=e,this.value=t}validateExemplarLabelSet(e){let t=\"\";for(let[n,r]of Object.entries(e))t+=`${n}${r}`;if(t.length>128)throw RangeError(\"Label set size must be smaller than 128 UTF-8 chars\")}}Ug.exports=Dg});var Aa=g(function(PW,Wg){var Fg=_e(\"util\"),{hashObject:VE,isObject:Lg,getLabels:Gg,removeLabels:FE,nowTimestamp:JE}=et(),{validateLabel:Bg}=yn(),{Metric:WE}=Nr(),KE=Ta();class Jg extends WE{constructor(e){super(e);if(this.type=\"counter\",this.defaultLabels={},this.defaultValue=1,this.defaultExemplarLabelSet={},e.enableExemplars)this.enableExemplars=!0,this.inc=this.incWithExemplar;else this.inc=this.incWithoutExemplar}incWithoutExemplar(e,t){let n=\"\";if(Lg(e))n=VE(e,this.sortedLabelNames),Bg(this.labelNames,e);else t=e,e={};if(t&&!Number.isFinite(t))throw TypeError(`Value is not a valid number: ${Fg.format(t)}`);if(t<0)throw Error(\"It is not possible to decrease a counter\");if(t===null||t===void 0)t=1;return Vg(this.hashMap,t,e,n),{labelHash:n}}incWithExemplar({labels:e=this.defaultLabels,value:t=this.defaultValue,exemplarLabels:n=this.defaultExemplarLabelSet}={}){let r=this.incWithoutExemplar(e,t);this.updateExemplar(n,t,r.labelHash)}updateExemplar(e,t,n){if(e===this.defaultExemplarLabelSet)return;if(!Lg(this.hashMap[n].exemplar))this.hashMap[n].exemplar=new KE;this.hashMap[n].exemplar.validateExemplarLabelSet(e),this.hashMap[n].exemplar.labelSet=e,this.hashMap[n].exemplar.value=t?t:1,this.hashMap[n].exemplar.timestamp=JE()}reset(){if(this.hashMap={},this.labelNames.length===0)Vg(this.hashMap,0)}async get(){if(this.collect){let e=this.collect();if(e instanceof Promise)await e}return{help:this.help,name:this.name,type:this.type,values:Object.values(this.hashMap),aggregator:this.aggregator}}labels(...e){let t=Gg(this.labelNames,e)||{};return{inc:this.inc.bind(this,t)}}remove(...e){let t=Gg(this.labelNames,e)||{};return Bg(this.labelNames,t),FE.call(this,this.hashMap,t,this.sortedLabelNames)}}function Vg(e,t,n={},r=\"\"){if(e[r])e[r].value+=t;else e[r]={value:t,labels:n};return e}Wg.exports=Jg});var Ae=g(function(OW,eh){var Bo=_e(\"util\"),{setValue:Zg,setValueDelta:HE,getLabels:Kg,hashObject:Yg,isObject:Xg,removeLabels:ZE}=et(),{validateLabel:Go}=yn(),{Metric:YE}=Nr();class Qg extends YE{constructor(e){super(e);this.type=\"gauge\"}set(e,t){t=Ea(e,t),e=Ca(e),XE(this,e,t)}reset(){if(this.hashMap={},this.labelNames.length===0)Zg(this.hashMap,0,{})}inc(e,t){if(t=Ea(e,t),e=Ca(e),t===void 0)t=1;Hg(this,e,t)}dec(e,t){if(t=Ea(e,t),e=Ca(e),t===void 0)t=1;Hg(this,e,-t)}setToCurrentTime(e){let t=Date.now()/1000;if(e===void 0)this.set(t);else this.set(e,t)}startTimer(e){let t=process.hrtime();return(n)=>{let r=process.hrtime(t),o=r[0]+r[1]/1e9;return this.set(Object.assign({},e,n),o),o}}async get(){if(this.collect){let e=this.collect();if(e instanceof Promise)await e}return{help:this.help,name:this.name,type:this.type,values:Object.values(this.hashMap),aggregator:this.aggregator}}_getValue(e){let t=Yg(e||{},this.sortedLabelNames);return this.hashMap[t]?this.hashMap[t].value:0}labels(...e){let t=Kg(this.labelNames,e);return Go(this.labelNames,t),{inc:this.inc.bind(this,t),dec:this.dec.bind(this,t),set:this.set.bind(this,t),setToCurrentTime:this.setToCurrentTime.bind(this,t),startTimer:this.startTimer.bind(this,t)}}remove(...e){let t=Kg(this.labelNames,e);Go(this.labelNames,t),ZE.call(this,this.hashMap,t,this.sortedLabelNames)}}function XE(e,t,n){if(typeof n!==\"number\")throw TypeError(`Value is not a valid number: ${Bo.format(n)}`);Go(e.labelNames,t),Zg(e.hashMap,n,t)}function Hg(e,t,n){if(typeof n!==\"number\")throw TypeError(`Delta is not a valid number: ${Bo.format(n)}`);Go(e.labelNames,t);let r=Yg(t,e.sortedLabelNames);HE(e.hashMap,n,t,r)}function Ca(e){return Xg(e)?e:{}}function Ea(e,t){return Xg(e)?t:e}eh.exports=Qg});var Ma=g(function($W,ah){var rh=_e(\"util\"),{getLabels:th,hashObject:Vo,isObject:oh,removeLabels:QE,nowTimestamp:e0}=et(),{validateLabel:Oa}=yn(),{Metric:t0}=Nr(),n0=Ta();class sh extends t0{constructor(e){super(e,{buckets:[0.005,0.01,0.025,0.05,0.1,0.25,0.5,1,2.5,5,10]});this.type=\"histogram\",this.defaultLabels={},this.defaultExemplarLabelSet={},this.enableExemplars=!1;for(let t of this.labelNames)if(t===\"le\")throw Error(\"le is a reserved label keyword\");if(this.upperBounds=this.buckets,this.bucketValues=this.upperBounds.reduce((t,n)=>(t[n]=0,t),{}),e.enableExemplars)this.enableExemplars=!0,this.bucketExemplars=this.upperBounds.reduce((t,n)=>(t[n]=null,t),{}),Object.freeze(this.bucketExemplars),this.observe=this.observeWithExemplar;else this.observe=this.observeWithoutExemplar;if(Object.freeze(this.bucketValues),Object.freeze(this.upperBounds),this.labelNames.length===0)this.hashMap={[Vo({})]:$a({},this.bucketValues,this.bucketExemplars)}}observeWithoutExemplar(e,t){Pa.call(this,e===0?0:e||{})(t)}observeWithExemplar({labels:e=this.defaultLabels,value:t,exemplarLabels:n=this.defaultExemplarLabelSet}={}){Pa.call(this,e===0?0:e||{})(t),this.updateExemplar(e,t,n)}updateExemplar(e,t,n){if(Object.keys(n).length===0)return;let r=Vo(e,this.sortedLabelNames),o=ih(this.upperBounds,t),{bucketExemplars:s}=this.hashMap[r],i=s[o];if(!oh(i))i=new n0,s[o]=i;i.validateExemplarLabelSet(n),i.labelSet=n,i.value=t,i.timestamp=e0()}async get(){let e=await this.getForPromString();return e.values=e.values.map(a0),e}async getForPromString(){if(this.collect){let n=this.collect();if(n instanceof Promise)await n}let t=Object.values(this.hashMap).map(s0(this)).reduce(i0(this),[]);return{name:this.name,help:this.help,type:this.type,values:t,aggregator:this.aggregator}}reset(){this.hashMap={}}zero(e){let t=Vo(e,this.sortedLabelNames);this.hashMap[t]=$a(e,this.bucketValues,this.bucketExemplars)}startTimer(e,t){return this.enableExemplars?r0.call(this,e,t)():nh.call(this,e)()}labels(...e){let t=th(this.labelNames,e);return Oa(this.labelNames,t),{observe:Pa.call(this,t),startTimer:nh.call(this,t)}}remove(...e){let t=th(this.labelNames,e);Oa(this.labelNames,t),QE.call(this,this.hashMap,t,this.sortedLabelNames)}}function nh(e){return()=>{let t=process.hrtime();return(n)=>{let r=process.hrtime(t),o=r[0]+r[1]/1e9;return this.observe(Object.assign({},e,n),o),o}}}function r0(e,t){return()=>{let n=process.hrtime();return(r,o)=>{let s=process.hrtime(n),i=s[0]+s[1]/1e9;return this.observe({labels:Object.assign({},e,r),value:i,exemplarLabels:Object.assign({},t,o)}),i}}}function Fo(e,t,n,r,o={}){return{labels:e,sharedLabels:o,value:t,metricName:n,exemplar:r}}function ih(e,t){for(let n=0;n<e.length;n++){let r=e[n];if(t<=r)return r}return-1}function Pa(e){return(t)=>{let n=o0(e,t);if(Oa(this.labelNames,n.labels),!Number.isFinite(n.value))throw TypeError(`Value is not a valid number: ${rh.format(n.value)}`);let r=Vo(n.labels,this.sortedLabelNames),o=this.hashMap[r];if(!o)o=$a(n.labels,this.bucketValues,this.bucketExemplars);let s=ih(this.upperBounds,n.value);if(o.sum+=n.value,o.count+=1,Object.prototype.hasOwnProperty.call(o.bucketValues,s))o.bucketValues[s]+=1;this.hashMap[r]=o}}function $a(e,t,n){let r={labels:e,bucketValues:{...t},sum:0,count:0};if(n)r.bucketExemplars={...n};return r}function o0(e,t){return oh(e)?{labels:e,value:t}:{value:e,labels:{}}}function s0(e){let t=`${e.name}_bucket`;return(n)=>{let r=0;return{buckets:e.upperBounds.map((s)=>(r+=n.bucketValues[s],Fo({le:s},r,t,n.bucketExemplars?n.bucketExemplars[s]:null,n.labels))),data:n}}}function i0(e){return(t,n)=>{t.push(...n.buckets);let r={le:\"+Inf\"};return t.push(Fo(r,n.data.count,`${e.name}_bucket`,n.data.bucketExemplars?n.data.bucketExemplars[\"-1\"]:null,n.data.labels),Fo({},n.data.sum,`${e.name}_sum`,void 0,n.data.labels),Fo({},n.data.count,`${e.name}_count`,void 0,n.data.labels)),t}}function a0(e){let{sharedLabels:t,labels:n,...r}=e;for(let o of Object.keys(t))n[o]=t[o];return r.labels=n,r}ah.exports=sh});var qa=g(function(MW,ch){function Ze(){}Ze.prototype.clear=function(){this._root=null,this.size=0};Ze.prototype.find=function(e){var t=this._root;while(t!==null){var n=this._comparator(e,t.data);if(n===0)return t.data;else t=t.get_child(n>0)}return null};Ze.prototype.findIter=function(e){var t=this._root,n=this.iterator();while(t!==null){var r=this._comparator(e,t.data);if(r===0)return n._cursor=t,n;else n._ancestors.push(t),t=t.get_child(r>0)}return null};Ze.prototype.lowerBound=function(e){var t=this._root,n=this.iterator(),r=this._comparator;while(t!==null){var o=r(e,t.data);if(o===0)return n._cursor=t,n;n._ancestors.push(t),t=t.get_child(o>0)}for(var s=n._ancestors.length-1;s>=0;--s)if(t=n._ancestors[s],r(e,t.data)<0)return n._cursor=t,n._ancestors.length=s,n;return n._ancestors.length=0,n};Ze.prototype.upperBound=function(e){var t=this.lowerBound(e),n=this._comparator;while(t.data()!==null&&n(t.data(),e)===0)t.next();return t};Ze.prototype.min=function(){var e=this._root;if(e===null)return null;while(e.left!==null)e=e.left;return e.data};Ze.prototype.max=function(){var e=this._root;if(e===null)return null;while(e.right!==null)e=e.right;return e.data};Ze.prototype.iterator=function(){return new Un(this)};Ze.prototype.each=function(e){var t=this.iterator(),n;while((n=t.next())!==null)if(e(n)===!1)return};Ze.prototype.reach=function(e){var t=this.iterator(),n;while((n=t.prev())!==null)if(e(n)===!1)return};function Un(e){this._tree=e,this._ancestors=[],this._cursor=null}Un.prototype.data=function(){return this._cursor!==null?this._cursor.data:null};Un.prototype.next=function(){if(this._cursor===null){var e=this._tree._root;if(e!==null)this._minNode(e)}else if(this._cursor.right===null){var t;do if(t=this._cursor,this._ancestors.length)this._cursor=this._ancestors.pop();else{this._cursor=null;break}while(this._cursor.right===t)}else this._ancestors.push(this._cursor),this._minNode(this._cursor.right);return this._cursor!==null?this._cursor.data:null};Un.prototype.prev=function(){if(this._cursor===null){var e=this._tree._root;if(e!==null)this._maxNode(e)}else if(this._cursor.left===null){var t;do if(t=this._cursor,this._ancestors.length)this._cursor=this._ancestors.pop();else{this._cursor=null;break}while(this._cursor.left===t)}else this._ancestors.push(this._cursor),this._maxNode(this._cursor.left);return this._cursor!==null?this._cursor.data:null};Un.prototype._minNode=function(e){while(e.left!==null)this._ancestors.push(e),e=e.left;this._cursor=e};Un.prototype._maxNode=function(e){while(e.right!==null)this._ancestors.push(e),e=e.right;this._cursor=e};ch.exports=Ze});var dh=g(function(qW,uh){var c0=qa();function Ln(e){this.data=e,this.left=null,this.right=null,this.red=!0}Ln.prototype.get_child=function(e){return e?this.right:this.left};Ln.prototype.set_child=function(e,t){if(e)this.right=t;else this.left=t};function Jo(e){this._root=null,this._comparator=e,this.size=0}Jo.prototype=new c0;Jo.prototype.insert=function(e){var t=!1;if(this._root===null)this._root=new Ln(e),t=!0,this.size++;else{var n=new Ln(void 0),r=0,o=0,s=null,i=n,a=null,c=this._root;i.right=this._root;while(!0){if(c===null)c=new Ln(e),a.set_child(r,c),t=!0,this.size++;else if(Ne(c.left)&&Ne(c.right))c.red=!0,c.left.red=!1,c.right.red=!1;if(Ne(c)&&Ne(a)){var l=i.right===s;if(c===a.get_child(o))i.set_child(l,Dr(s,!o));else i.set_child(l,lh(s,!o))}var u=this._comparator(c.data,e);if(u===0)break;if(o=r,r=u<0,s!==null)i=s;s=a,a=c,c=c.get_child(r)}this._root=n.right}return this._root.red=!1,t};Jo.prototype.remove=function(e){if(this._root===null)return!1;var t=new Ln(void 0),n=t;n.right=this._root;var r=null,o=null,s=null,i=1;while(n.get_child(i)!==null){var a=i;o=r,r=n,n=n.get_child(i);var c=this._comparator(e,n.data);if(i=c>0,c===0)s=n;if(!Ne(n)&&!Ne(n.get_child(i))){if(Ne(n.get_child(!i))){var l=Dr(n,i);r.set_child(a,l),r=l}else if(!Ne(n.get_child(!i))){var u=r.get_child(!a);if(u!==null)if(!Ne(u.get_child(!a))&&!Ne(u.get_child(a)))r.red=!1,u.red=!0,n.red=!0;else{var p=o.right===r;if(Ne(u.get_child(a)))o.set_child(p,lh(r,a));else if(Ne(u.get_child(!a)))o.set_child(p,Dr(r,a));var m=o.get_child(p);m.red=!0,n.red=!0,m.left.red=!1,m.right.red=!1}}}}if(s!==null)s.data=n.data,r.set_child(r.right===n,n.get_child(n.left===null)),this.size--;if(this._root=t.right,this._root!==null)this._root.red=!1;return s!==null};function Ne(e){return e!==null&&e.red}function Dr(e,t){var n=e.get_child(!t);return e.set_child(!t,n.get_child(t)),n.set_child(t,e),e.red=!0,n.red=!1,n}function lh(e,t){return e.set_child(!t,Dr(e.get_child(!t),!t)),Dr(e,t)}uh.exports=Jo});var mh=g(function(zW,ph){var l0=qa();function Ur(e){this.data=e,this.left=null,this.right=null}Ur.prototype.get_child=function(e){return e?this.right:this.left};Ur.prototype.set_child=function(e,t){if(e)this.right=t;else this.left=t};function Wo(e){this._root=null,this._comparator=e,this.size=0}Wo.prototype=new l0;Wo.prototype.insert=function(e){if(this._root===null)return this._root=new Ur(e),this.size++,!0;var t=0,n=null,r=this._root;while(!0){if(r===null)return r=new Ur(e),n.set_child(t,r),ret=!0,this.size++,!0;if(this._comparator(r.data,e)===0)return!1;t=this._comparator(r.data,e)<0,n=r,r=r.get_child(t)}};Wo.prototype.remove=function(e){if(this._root===null)return!1;var t=new Ur(void 0),n=t;n.right=this._root;var r=null,o=null,s=1;while(n.get_child(s)!==null){r=n,n=n.get_child(s);var i=this._comparator(e,n.data);if(s=i>0,i===0)o=n}if(o!==null)return o.data=n.data,r.set_child(r.right===n,n.get_child(n.left===null)),this._root=t.right,this.size--,!0;else return!1};ph.exports=Wo});var gh=g(function(jW,fh){fh.exports={RBTree:dh(),BinTree:mh()}});var bh=g(function(NW,yh){var u0=gh().RBTree;function ie(e,t,n){this.discrete=e===!1,this.delta=e||0.01,this.K=t===void 0?25:t,this.CX=n===void 0?1.1:n,this.centroids=new u0(hh),this.nreset=0,this.reset()}ie.prototype.reset=function(){this.centroids.clear(),this.n=0,this.nreset+=1,this.last_cumulate=0};ie.prototype.size=function(){return this.centroids.size};ie.prototype.toArray=function(e){var t=[];if(e)this._cumulate(!0),this.centroids.each(function(n){t.push(n)});else this.centroids.each(function(n){t.push({mean:n.mean,n:n.n})});return t};ie.prototype.summary=function(){var e=this.discrete?\"exact \":\"approximating \",t=[e+this.n+\" samples using \"+this.size()+\" centroids\",\"min = \"+this.percentile(0),\"Q1 = \"+this.percentile(0.25),\"Q2 = \"+this.percentile(0.5),\"Q3 = \"+this.percentile(0.75),\"max = \"+this.percentile(1)];return t.join(`\n`)};function hh(e,t){return e.mean>t.mean?1:e.mean<t.mean?-1:0}function d0(e,t){return e.mean_cumn-t.mean_cumn}ie.prototype.push=function(e,t){t=t||1,e=Array.isArray(e)?e:[e];for(var n=0;n<e.length;n++)this._digest(e[n],t)};ie.prototype.push_centroid=function(e){e=Array.isArray(e)?e:[e];for(var t=0;t<e.length;t++)this._digest(e[t].mean,e[t].n)};ie.prototype._cumulate=function(e){if(this.n===this.last_cumulate||!e&&this.CX&&this.CX>this.n/this.last_cumulate)return;var t=0;this.centroids.each(function(n){n.mean_cumn=t+n.n/2,t=n.cumn=t+n.n}),this.n=this.last_cumulate=t};ie.prototype.find_nearest=function(e){if(this.size()===0)return null;var t=this.centroids.lowerBound({mean:e}),n=t.data()===null?t.prev():t.data();if(n.mean===e||this.discrete)return n;var r=t.prev();if(r&&Math.abs(r.mean-e)<Math.abs(n.mean-e))return r;else return n};ie.prototype._new_centroid=function(e,t,n){var r={mean:e,n:t,cumn:n};return this.centroids.insert(r),this.n+=t,r};ie.prototype._addweight=function(e,t,n){if(t!==e.mean)e.mean+=n*(t-e.mean)/(e.n+n);e.cumn+=n,e.mean_cumn+=n/2,e.n+=n,this.n+=n};ie.prototype._digest=function(e,t){var n=this.centroids.min(),r=this.centroids.max(),o=this.find_nearest(e);if(o&&o.mean===e)this._addweight(o,e,t);else if(o===n)this._new_centroid(e,t,0);else if(o===r)this._new_centroid(e,t,this.n);else if(this.discrete)this._new_centroid(e,t,o.cumn);else{var s=o.mean_cumn/this.n,i=Math.floor(4*this.n*this.delta*s*(1-s));if(i-o.n>=t)this._addweight(o,e,t);else this._new_centroid(e,t,o.cumn)}if(this._cumulate(!1),!this.discrete&&this.K&&this.size()>this.K/this.delta)this.compress()};ie.prototype.bound_mean=function(e){var t=this.centroids.upperBound({mean:e}),n=t.prev(),r=n.mean===e?n:t.next();return[n,r]};ie.prototype.p_rank=function(e){var t=Array.isArray(e)?e:[e],n=t.map(this._p_rank,this);return Array.isArray(e)?n:n[0]};ie.prototype._p_rank=function(e){if(this.size()===0)return;else if(e<this.centroids.min().mean)return 0;else if(e>this.centroids.max().mean)return 1;this._cumulate(!0);var t=this.bound_mean(e),n=t[0],r=t[1];if(this.discrete)return n.cumn/this.n;else{var o=n.mean_cumn;if(n!==r)o+=(e-n.mean)*(r.mean_cumn-n.mean_cumn)/(r.mean-n.mean);return o/this.n}};ie.prototype.bound_mean_cumn=function(e){this.centroids._comparator=d0;var t=this.centroids.upperBound({mean_cumn:e});this.centroids._comparator=hh;var n=t.prev(),r=n&&n.mean_cumn===e?n:t.next();return[n,r]};ie.prototype.percentile=function(e){var t=Array.isArray(e)?e:[e],n=t.map(this._percentile,this);return Array.isArray(e)?n:n[0]};ie.prototype._percentile=function(e){if(this.size()===0)return;this._cumulate(!0);var t=this.n*e,n=this.bound_mean_cumn(t),r=n[0],o=n[1];if(o===r||r===null||o===null)return(r||o).mean;else if(!this.discrete)return r.mean+(t-r.mean_cumn)*(o.mean-r.mean)/(o.mean_cumn-r.mean_cumn);else if(t<=r.cumn)return r.mean;else return o.mean};function p0(e){var t=Math.floor(Math.random()*e.length);return e.splice(t,1)[0]}ie.prototype.compress=function(){if(this.compressing)return;var e=this.toArray();this.reset(),this.compressing=!0;while(e.length>0)this.push_centroid(p0(e));this._cumulate(!0),this.compressing=!1};function $t(e){this.config=e||{},this.mode=this.config.mode||\"auto\",ie.call(this,this.mode===\"cont\"?e.delta:!1),this.digest_ratio=this.config.ratio||0.9,this.digest_thresh=this.config.thresh||1000,this.n_unique=0}$t.prototype=Object.create(ie.prototype);$t.prototype.constructor=$t;$t.prototype.push=function(e){ie.prototype.push.call(this,e),this.check_continuous()};$t.prototype._new_centroid=function(e,t,n){this.n_unique+=1,ie.prototype._new_centroid.call(this,e,t,n)};$t.prototype._addweight=function(e,t,n){if(e.n===1)this.n_unique-=1;ie.prototype._addweight.call(this,e,t,n)};$t.prototype.check_continuous=function(){if(this.mode!==\"auto\"||this.size()<this.digest_thresh)return!1;if(this.n_unique/this.size()>this.digest_ratio)return this.mode=\"cont\",this.discrete=!1,this.delta=this.config.delta||0.01,this.compress(),!0;return!1};yh.exports={TDigest:ie,Digest:$t}});var xh=g(function(DW,wh){var{TDigest:vh}=bh();class _h{constructor(e,t){this.maxAgeSeconds=e||0,this.ageBuckets=t||0,this.shouldRotate=e&&t,this.ringBuffer=Array(t).fill(new vh),this.currentBuffer=0,this.lastRotateTimestampMillis=Date.now(),this.durationBetweenRotatesMillis=e*1000/t||1/0}size(){return za.call(this).size()}percentile(e){return za.call(this).percentile(e)}push(e){za.call(this),this.ringBuffer.forEach((t)=>{t.push(e)})}reset(){this.ringBuffer.forEach((e)=>{e.reset()})}compress(){this.ringBuffer.forEach((e)=>{e.compress()})}}function za(){let e=Date.now()-this.lastRotateTimestampMillis;while(e>this.durationBetweenRotatesMillis&&this.shouldRotate){if(this.ringBuffer[this.currentBuffer]=new vh,++this.currentBuffer>=this.ringBuffer.length)this.currentBuffer=0;e-=this.durationBetweenRotatesMillis,this.lastRotateTimestampMillis+=this.durationBetweenRotatesMillis}return this.ringBuffer[this.currentBuffer]}wh.exports=_h});var Ph=g(function(UW,Eh){var Rh=_e(\"util\"),{getLabels:Sh,hashObject:Th,removeLabels:m0}=et(),{validateLabel:ja}=yn(),{Metric:f0}=Nr(),Ah=xh();class Ch extends f0{constructor(e){super(e,{percentiles:[0.01,0.05,0.5,0.9,0.95,0.99,0.999],compressCount:1000,hashMap:{}});this.type=\"summary\";for(let t of this.labelNames)if(t===\"quantile\")throw Error(\"quantile is a reserved label keyword\");if(this.labelNames.length===0)this.hashMap={[Th({})]:{labels:{},td:new Ah(this.maxAgeSeconds,this.ageBuckets),count:0,sum:0}}}observe(e,t){kh.call(this,e===0?0:e||{})(t)}async get(){if(this.collect){let n=this.collect();if(n instanceof Promise)await n}let e=Object.keys(this.hashMap),t=[];return e.forEach((n)=>{let r=this.hashMap[n];if(r)if(this.pruneAgedBuckets&&r.td.size()===0)delete this.hashMap[n];else g0(r,this.percentiles).forEach((o)=>{t.push(o)}),t.push(y0(r,this)),t.push(h0(r,this))}),{name:this.name,help:this.help,type:this.type,values:t,aggregator:this.aggregator}}reset(){Object.values(this.hashMap).forEach((t)=>{t.td.reset(),t.count=0,t.sum=0})}startTimer(e){return Ih.call(this,e)()}labels(...e){let t=Sh(this.labelNames,e);return ja(this.labelNames,t),{observe:kh.call(this,t),startTimer:Ih.call(this,t)}}remove(...e){let t=Sh(this.labelNames,e);ja(this.labelNames,t),m0.call(this,this.hashMap,t,this.sortedLabelNames)}}function g0(e,t){return e.td.compress(),t.map((n)=>{let r=e.td.percentile(n);return{labels:Object.assign({quantile:n},e.labels),value:r?r:0}})}function h0(e,t){return{metricName:`${t.name}_count`,labels:e.labels,value:e.count}}function y0(e,t){return{metricName:`${t.name}_sum`,labels:e.labels,value:e.sum}}function Ih(e){return()=>{let t=process.hrtime();return(n)=>{let r=process.hrtime(t),o=r[0]+r[1]/1e9;return this.observe(Object.assign({},e,n),o),o}}}function kh(e){return(t)=>{let n=b0(e,t);if(ja(this.labelNames,e),!Number.isFinite(n.value))throw TypeError(`Value is not a valid number: ${Rh.format(n.value)}`);let r=Th(n.labels,this.sortedLabelNames),o=this.hashMap[r];if(!o)o={labels:n.labels,td:new Ah(this.maxAgeSeconds,this.ageBuckets),count:0,sum:0};if(o.td.push(n.value),o.count++,o.count%this.compressCount===0)o.td.compress();o.sum+=n.value,this.hashMap[r]=o}}function b0(e,t){if(t===void 0)return{value:e,labels:{}};return{labels:e,value:t}}Eh.exports=Ch});var Mh=g(function(LW,$h){var Gn=_e(\"url\"),v0=_e(\"http\"),_0=_e(\"https\"),{gzipSync:w0}=_e(\"zlib\"),{globalRegistry:x0}=Nn();class Oh{constructor(e,t,n){if(!n)n=x0;this.registry=n,this.gatewayUrl=e;let{requireJobName:r,...o}={requireJobName:!0,...t};this.requireJobName=r,this.requestOptions=o}pushAdd(e={}){if(this.requireJobName&&!e.jobName)throw Error(\"Missing jobName parameter\");return Na.call(this,\"POST\",e.jobName,e.groupings)}push(e={}){if(this.requireJobName&&!e.jobName)throw Error(\"Missing jobName parameter\");return Na.call(this,\"PUT\",e.jobName,e.groupings)}delete(e={}){if(this.requireJobName&&!e.jobName)throw Error(\"Missing jobName parameter\");return Na.call(this,\"DELETE\",e.jobName,e.groupings)}}async function Na(e,t,n){let r=Gn.parse(this.gatewayUrl),o=r.pathname&&r.pathname!==\"/\"?r.pathname:\"\",s=t?`/job/${encodeURIComponent(t)}${S0(n)}`:\"\",i=`${o}/metrics${s}`,a=Gn.resolve(this.gatewayUrl,i),c=Gn.parse(a),l=I0(c.href)?_0:v0,u=Object.assign(c,this.requestOptions,{method:e});return new Promise((p,m)=>{if(e===\"DELETE\"&&u.headers)delete u.headers[\"Content-Encoding\"];let d=l.request(u,(f)=>{let h=\"\";f.setEncoding(\"utf8\"),f.on(\"data\",(y)=>{h+=y}),f.on(\"end\",()=>{if(f.statusCode>=400)m(Error(`push failed with status ${f.statusCode}, ${h}`));else p({resp:f,body:h})})});if(d.on(\"error\",(f)=>{m(f)}),d.on(\"timeout\",()=>{d.destroy(Error(\"Pushgateway request timed out\"))}),e!==\"DELETE\")this.registry.metrics().then((f)=>{if(u.headers&&u.headers[\"Content-Encoding\"]===\"gzip\")f=w0(f);d.write(f),d.end()}).catch((f)=>{m(f)});else d.end()})}function S0(e){if(!e)return\"\";return Object.keys(e).map((t)=>`/${encodeURIComponent(t)}/${encodeURIComponent(e[t])}`).join(\"\")}function I0(e){return e.search(/^https/)!==-1}$h.exports=Oh});var Da=g(function(k0){k0.linearBuckets=(e,t,n)=>{if(n<1)throw Error(\"Linear buckets needs a positive count\");let r=Array(n);for(let o=0;o<n;o++)r[o]=e+o*t;return r};k0.exponentialBuckets=(e,t,n)=>{if(e<=0)throw Error(\"Exponential buckets needs a positive start\");if(n<1)throw Error(\"Exponential buckets needs a positive count\");if(t<=1)throw Error(\"Exponential buckets needs a factor greater than 1\");let r=Array(n);for(let o=0;o<n;o++)r[o]=e,e*=t;return r}});var Ua=g(function(qh){Object.defineProperty(qh,\"__esModule\",{value:!0});qh.VERSION=void 0;qh.VERSION=\"1.9.1\"});var Gh=g(function(Uh){Object.defineProperty(Uh,\"__esModule\",{value:!0});Uh.isCompatible=Uh._makeCompatibilityCheck=void 0;var Nh=Ua(),jh=/^(\\d+)\\.(\\d+)\\.(\\d+)(-(.+))?$/;function Dh(e){let t=new Set([e]),n=new Set,r=e.match(jh);if(!r)return()=>!1;let o={major:+r[1],minor:+r[2],patch:+r[3],prerelease:r[4]};if(o.prerelease!=null)return function(c){return c===e};function s(a){return n.add(a),!1}function i(a){return t.add(a),!0}return function(c){if(t.has(c))return!0;if(n.has(c))return!1;let l=c.match(jh);if(!l)return s(c);let u={major:+l[1],minor:+l[2],patch:+l[3],prerelease:l[4]};if(u.prerelease!=null)return s(c);if(o.major!==u.major)return s(c);if(o.major===0){if(o.minor===u.minor&&o.patch<=u.patch)return i(c);return s(c)}if(o.minor<=u.minor)return i(c);return s(c)}}Uh._makeCompatibilityCheck=Dh;Uh.isCompatible=Dh(Nh.VERSION)});var bn=g(function(Vh){Object.defineProperty(Vh,\"__esModule\",{value:!0});Vh.unregisterGlobal=Vh.getGlobal=Vh.registerGlobal=void 0;var De=Ua(),Bh=Gh(),C0=De.VERSION.split(\".\")[0],Lr=Symbol.for(`opentelemetry.js.api.${C0}`),Gr=typeof globalThis===\"object\"?globalThis:typeof self===\"object\"?self:typeof window===\"object\"?window:typeof global===\"object\"?global:{};function E0(e,t,n,r=!1){var o;let s=Gr[Lr]=(o=Gr[Lr])!==null&&o!==void 0?o:{version:De.VERSION};if(!r&&s[e]){let i=Error(`@opentelemetry/api: Attempted duplicate registration of API: ${e}`);return n.error(i.stack||i.message),!1}if(s.version!==De.VERSION){let i=Error(`@opentelemetry/api: Registration of version v${s.version} for ${e} does not match previously registered API v${De.VERSION}`);return n.error(i.stack||i.message),!1}return s[e]=t,n.debug(`@opentelemetry/api: Registered a global for ${e} v${De.VERSION}.`),!0}Vh.registerGlobal=E0;function P0(e){var t,n;let r=(t=Gr[Lr])===null||t===void 0?void 0:t.version;if(!r||!Bh.isCompatible(r))return;return(n=Gr[Lr])===null||n===void 0?void 0:n[e]}Vh.getGlobal=P0;function O0(e,t){t.debug(`@opentelemetry/api: Unregistering a global for ${e} v${De.VERSION}.`);let n=Gr[Lr];if(n)delete n[e]}Vh.unregisterGlobal=O0});var Zh=g(function(Kh){Object.defineProperty(Kh,\"__esModule\",{value:!0});Kh.DiagComponentLogger=void 0;var Jh=bn();class Wh{constructor(e){this._namespace=e.namespace||\"DiagComponentLogger\"}debug(...e){return Br(\"debug\",this._namespace,e)}error(...e){return Br(\"error\",this._namespace,e)}info(...e){return Br(\"info\",this._namespace,e)}warn(...e){return Br(\"warn\",this._namespace,e)}verbose(...e){return Br(\"verbose\",this._namespace,e)}}Kh.DiagComponentLogger=Wh;function Br(e,t,n){let r=Jh.getGlobal(\"diag\");if(!r)return;return r[e](t,...n)}});var Ko=g(function(Yh){Object.defineProperty(Yh,\"__esModule\",{value:!0});Yh.DiagLogLevel=void 0;var q0;(function(e){e[e.NONE=0]=\"NONE\",e[e.ERROR=30]=\"ERROR\",e[e.WARN=50]=\"WARN\",e[e.INFO=60]=\"INFO\",e[e.DEBUG=70]=\"DEBUG\",e[e.VERBOSE=80]=\"VERBOSE\",e[e.ALL=9999]=\"ALL\"})(q0=Yh.DiagLogLevel||(Yh.DiagLogLevel={}))});var ey=g(function(Xh){Object.defineProperty(Xh,\"__esModule\",{value:!0});Xh.createLogLevelDiagLogger=void 0;var be=Ko();function z0(e,t){if(e<be.DiagLogLevel.NONE)e=be.DiagLogLevel.NONE;else if(e>be.DiagLogLevel.ALL)e=be.DiagLogLevel.ALL;t=t||{};function n(r,o){let s=t[r];if(typeof s===\"function\"&&e>=o)return s.bind(t);return function(){}}return{error:n(\"error\",be.DiagLogLevel.ERROR),warn:n(\"warn\",be.DiagLogLevel.WARN),info:n(\"info\",be.DiagLogLevel.INFO),debug:n(\"debug\",be.DiagLogLevel.DEBUG),verbose:n(\"verbose\",be.DiagLogLevel.VERBOSE)}}Xh.createLogLevelDiagLogger=z0});var vn=g(function(ry){Object.defineProperty(ry,\"__esModule\",{value:!0});ry.DiagAPI=void 0;var ty=Zh(),ny=ey(),Ho=Ko(),Mt=bn(),j0=\"diag\";class Ga{static instance(){if(!this._instance)this._instance=new Ga;return this._instance}constructor(){function e(r){return function(...o){let s=Mt.getGlobal(\"diag\");if(!s)return;return s[r](...o)}}let t=this,n=(r,o={logLevel:Ho.DiagLogLevel.INFO})=>{var s,i,a;if(r===t){let u=Error(\"Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation\");return t.error((s=u.stack)!==null&&s!==void 0?s:u.message),!1}if(typeof o===\"number\")o={logLevel:o};let c=Mt.getGlobal(\"diag\"),l=ny.createLogLevelDiagLogger((i=o.logLevel)!==null&&i!==void 0?i:Ho.DiagLogLevel.INFO,r);if(c&&!o.suppressOverrideMessage){let u=(a=Error().stack)!==null&&a!==void 0?a:\"<failed to generate stacktrace>\";c.warn(`Current logger will be overwritten from ${u}`),l.warn(`Current logger will overwrite one already registered from ${u}`)}return Mt.registerGlobal(\"diag\",l,t,!0)};t.setLogger=n,t.disable=()=>{Mt.unregisterGlobal(j0,t)},t.createComponentLogger=(r)=>new ty.DiagComponentLogger(r),t.verbose=e(\"verbose\"),t.debug=e(\"debug\"),t.info=e(\"info\"),t.warn=e(\"warn\"),t.error=e(\"error\")}}ry.DiagAPI=Ga});var ay=g(function(sy){Object.defineProperty(sy,\"__esModule\",{value:!0});sy.BaggageImpl=void 0;class Bn{constructor(e){this._entries=e?new Map(e):new Map}getEntry(e){let t=this._entries.get(e);if(!t)return;return Object.assign({},t)}getAllEntries(){return Array.from(this._entries.entries())}setEntry(e,t){let n=new Bn(this._entries);return n._entries.set(e,t),n}removeEntry(e){let t=new Bn(this._entries);return t._entries.delete(e),t}removeEntries(...e){let t=new Bn(this._entries);for(let n of e)t._entries.delete(n);return t}clear(){return new Bn}}sy.BaggageImpl=Bn});var uy=g(function(cy){Object.defineProperty(cy,\"__esModule\",{value:!0});cy.baggageEntryMetadataSymbol=void 0;cy.baggageEntryMetadataSymbol=Symbol(\"BaggageEntryMetadata\")});var Ba=g(function(fy){Object.defineProperty(fy,\"__esModule\",{value:!0});fy.baggageEntryMetadataFromString=fy.createBaggage=void 0;var dy=vn(),py=ay(),my=uy(),N0=dy.DiagAPI.instance();function D0(e={}){return new py.BaggageImpl(new Map(Object.entries(e)))}fy.createBaggage=D0;function U0(e){if(typeof e!==\"string\")N0.error(`Cannot create baggage metadata from unknown type: ${typeof e}`),e=\"\";return{__TYPE__:my.baggageEntryMetadataSymbol,toString(){return e}}}fy.baggageEntryMetadataFromString=U0});var Vr=g(function(hy){Object.defineProperty(hy,\"__esModule\",{value:!0});hy.ROOT_CONTEXT=hy.createContextKey=void 0;function G0(e){return Symbol.for(e)}hy.createContextKey=G0;class Zo{constructor(e){let t=this;t._currentContext=e?new Map(e):new Map,t.getValue=(n)=>t._currentContext.get(n),t.setValue=(n,r)=>{let o=new Zo(t._currentContext);return o._currentContext.set(n,r),o},t.deleteValue=(n)=>{let r=new Zo(t._currentContext);return r._currentContext.delete(n),r}}}hy.ROOT_CONTEXT=new Zo});var wy=g(function(vy){Object.defineProperty(vy,\"__esModule\",{value:!0});vy.DiagConsoleLogger=vy._originalConsoleMethods=void 0;var Va=[{n:\"error\",c:\"error\"},{n:\"warn\",c:\"warn\"},{n:\"info\",c:\"info\"},{n:\"debug\",c:\"debug\"},{n:\"verbose\",c:\"trace\"}];vy._originalConsoleMethods={};if(typeof console<\"u\"){let e=[\"error\",\"warn\",\"info\",\"debug\",\"trace\",\"log\"];for(let t of e)if(typeof console[t]===\"function\")vy._originalConsoleMethods[t]=console[t]}class by{constructor(){function e(t){return function(...n){let r=vy._originalConsoleMethods[t];if(typeof r!==\"function\")r=vy._originalConsoleMethods.log;if(typeof r!==\"function\"&&console){if(r=console[t],typeof r!==\"function\")r=console.log}if(typeof r===\"function\")return r.apply(console,n)}}for(let t=0;t<Va.length;t++)this[Va[t].n]=e(Va[t].c)}}vy.DiagConsoleLogger=by});var Qa=g(function(xy){Object.defineProperty(xy,\"__esModule\",{value:!0});xy.createNoopMeter=xy.NOOP_OBSERVABLE_UP_DOWN_COUNTER_METRIC=xy.NOOP_OBSERVABLE_GAUGE_METRIC=xy.NOOP_OBSERVABLE_COUNTER_METRIC=xy.NOOP_UP_DOWN_COUNTER_METRIC=xy.NOOP_HISTOGRAM_METRIC=xy.NOOP_GAUGE_METRIC=xy.NOOP_COUNTER_METRIC=xy.NOOP_METER=xy.NoopObservableUpDownCounterMetric=xy.NoopObservableGaugeMetric=xy.NoopObservableCounterMetric=xy.NoopObservableMetric=xy.NoopHistogramMetric=xy.NoopGaugeMetric=xy.NoopUpDownCounterMetric=xy.NoopCounterMetric=xy.NoopMetric=xy.NoopMeter=void 0;class Fa{constructor(){}createGauge(e,t){return xy.NOOP_GAUGE_METRIC}createHistogram(e,t){return xy.NOOP_HISTOGRAM_METRIC}createCounter(e,t){return xy.NOOP_COUNTER_METRIC}createUpDownCounter(e,t){return xy.NOOP_UP_DOWN_COUNTER_METRIC}createObservableGauge(e,t){return xy.NOOP_OBSERVABLE_GAUGE_METRIC}createObservableCounter(e,t){return xy.NOOP_OBSERVABLE_COUNTER_METRIC}createObservableUpDownCounter(e,t){return xy.NOOP_OBSERVABLE_UP_DOWN_COUNTER_METRIC}addBatchObservableCallback(e,t){}removeBatchObservableCallback(e){}}xy.NoopMeter=Fa;class Vn{}xy.NoopMetric=Vn;class Ja extends Vn{add(e,t){}}xy.NoopCounterMetric=Ja;class Wa extends Vn{add(e,t){}}xy.NoopUpDownCounterMetric=Wa;class Ka extends Vn{record(e,t){}}xy.NoopGaugeMetric=Ka;class Ha extends Vn{record(e,t){}}xy.NoopHistogramMetric=Ha;class Fr{addCallback(e){}removeCallback(e){}}xy.NoopObservableMetric=Fr;class Za extends Fr{}xy.NoopObservableCounterMetric=Za;class Ya extends Fr{}xy.NoopObservableGaugeMetric=Ya;class Xa extends Fr{}xy.NoopObservableUpDownCounterMetric=Xa;xy.NOOP_METER=new Fa;xy.NOOP_COUNTER_METRIC=new Ja;xy.NOOP_GAUGE_METRIC=new Ka;xy.NOOP_HISTOGRAM_METRIC=new Ha;xy.NOOP_UP_DOWN_COUNTER_METRIC=new Wa;xy.NOOP_OBSERVABLE_COUNTER_METRIC=new Za;xy.NOOP_OBSERVABLE_GAUGE_METRIC=new Ya;xy.NOOP_OBSERVABLE_UP_DOWN_COUNTER_METRIC=new Xa;function V0(){return xy.NOOP_METER}xy.createNoopMeter=V0});var $y=g(function(Oy){Object.defineProperty(Oy,\"__esModule\",{value:!0});Oy.ValueType=void 0;var tP;(function(e){e[e.INT=0]=\"INT\",e[e.DOUBLE=1]=\"DOUBLE\"})(tP=Oy.ValueType||(Oy.ValueType={}))});var tc=g(function(My){Object.defineProperty(My,\"__esModule\",{value:!0});My.defaultTextMapSetter=My.defaultTextMapGetter=void 0;My.defaultTextMapGetter={get(e,t){if(e==null)return;return e[t]},keys(e){if(e==null)return[];return Object.keys(e)}};My.defaultTextMapSetter={set(e,t,n){if(e==null)return;e[t]=n}}});var Uy=g(function(Ny){Object.defineProperty(Ny,\"__esModule\",{value:!0});Ny.NoopContextManager=void 0;var zy=Vr();class jy{active(){return zy.ROOT_CONTEXT}with(e,t,n,...r){return t.call(n,...r)}bind(e,t){return t}enable(){return this}disable(){return this}}Ny.NoopContextManager=jy});var Jr=g(function(Gy){Object.defineProperty(Gy,\"__esModule\",{value:!0});Gy.ContextAPI=void 0;var Ly=Uy(),Fn=bn(),Xo=vn(),nc=\"context\",rP=new Ly.NoopContextManager;class rc{constructor(){}static getInstance(){if(!this._instance)this._instance=new rc;return this._instance}setGlobalContextManager(e){return Fn.registerGlobal(nc,e,Xo.DiagAPI.instance())}active(){return this._getContextManager().active()}with(e,t,n,...r){return this._getContextManager().with(e,t,n,...r)}bind(e,t){return this._getContextManager().bind(e,t)}_getContextManager(){return Fn.getGlobal(nc)||rP}disable(){this._getContextManager().disable(),Fn.unregisterGlobal(nc,Xo.DiagAPI.instance())}}Gy.ContextAPI=rc});var sc=g(function(Vy){Object.defineProperty(Vy,\"__esModule\",{value:!0});Vy.TraceFlags=void 0;var oP;(function(e){e[e.NONE=0]=\"NONE\",e[e.SAMPLED=1]=\"SAMPLED\"})(oP=Vy.TraceFlags||(Vy.TraceFlags={}))});var Qo=g(function(Jy){Object.defineProperty(Jy,\"__esModule\",{value:!0});Jy.INVALID_SPAN_CONTEXT=Jy.INVALID_TRACEID=Jy.INVALID_SPANID=void 0;var Fy=sc();Jy.INVALID_SPANID=\"0000000000000000\";Jy.INVALID_TRACEID=\"00000000000000000000000000000000\";Jy.INVALID_SPAN_CONTEXT={traceId:Jy.INVALID_TRACEID,spanId:Jy.INVALID_SPANID,traceFlags:Fy.TraceFlags.NONE}});var es=g(function(Xy){Object.defineProperty(Xy,\"__esModule\",{value:!0});Xy.NonRecordingSpan=void 0;var Zy=Qo();class Yy{constructor(e=Zy.INVALID_SPAN_CONTEXT){this._spanContext=e}spanContext(){return this._spanContext}setAttribute(e,t){return this}setAttributes(e){return this}addEvent(e,t){return this}addLink(e){return this}addLinks(e){return this}setStatus(e){return this}updateName(e){return this}end(e){}isRecording(){return!1}recordException(e,t){}}Xy.NonRecordingSpan=Yy});var cc=g(function(ob){Object.defineProperty(ob,\"__esModule\",{value:!0});ob.getSpanContext=ob.setSpanContext=ob.deleteSpan=ob.setSpan=ob.getActiveSpan=ob.getSpan=void 0;var eb=Vr(),tb=es(),nb=Jr(),ic=eb.createContextKey(\"OpenTelemetry Context Key SPAN\");function ac(e){return e.getValue(ic)||void 0}ob.getSpan=ac;function sP(){return ac(nb.ContextAPI.getInstance().active())}ob.getActiveSpan=sP;function rb(e,t){return e.setValue(ic,t)}ob.setSpan=rb;function iP(e){return e.deleteValue(ic)}ob.deleteSpan=iP;function aP(e,t){return rb(e,new tb.NonRecordingSpan(t))}ob.setSpanContext=aP;function cP(e){var t;return(t=ac(e))===null||t===void 0?void 0:t.spanContext()}ob.getSpanContext=cP});var rs=g(function(ub){Object.defineProperty(ub,\"__esModule\",{value:!0});ub.wrapSpanContext=ub.isSpanContextValid=ub.isValidSpanId=ub.isValidTraceId=void 0;var ns=Qo(),ib=es(),ts=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1]);function ab(e,t){if(typeof e!==\"string\"||e.length!==t)return!1;let n=0;for(let r=0;r<e.length;r+=4)n+=(ts[e.charCodeAt(r)]|0)+(ts[e.charCodeAt(r+1)]|0)+(ts[e.charCodeAt(r+2)]|0)+(ts[e.charCodeAt(r+3)]|0);return n===t}function cb(e){return ab(e,32)&&e!==ns.INVALID_TRACEID}ub.isValidTraceId=cb;function lb(e){return ab(e,16)&&e!==ns.INVALID_SPANID}ub.isValidSpanId=lb;function fP(e){return cb(e.traceId)&&lb(e.spanId)}ub.isSpanContextValid=fP;function gP(e){return new ib.NonRecordingSpan(e)}ub.wrapSpanContext=gP});var uc=g(function(gb){Object.defineProperty(gb,\"__esModule\",{value:!0});gb.NoopTracer=void 0;var pb=Jr(),os=cc(),Jn=es(),mb=rs(),lc=pb.ContextAPI.getInstance();class fb{startSpan(e,t,n=lc.active()){if(Boolean(t===null||t===void 0?void 0:t.root))return new Jn.NonRecordingSpan;let o=n&&os.getSpanContext(n);if(vP(o)&&mb.isSpanContextValid(o))return new Jn.NonRecordingSpan(o);else return new Jn.NonRecordingSpan}startActiveSpan(e,t,n,r){let o,s,i;if(arguments.length<2)return;else if(arguments.length===2)i=t;else if(arguments.length===3)o=t,i=n;else o=t,s=n,i=r;let a=s!==null&&s!==void 0?s:lc.active(),c=this.startSpan(e,o,a),l=os.setSpan(a,c);return lc.with(l,i,void 0,c)}}gb.NoopTracer=fb;function vP(e){return e!==null&&typeof e===\"object\"&&\"spanId\"in e&&typeof e.spanId===\"string\"&&\"traceId\"in e&&typeof e.traceId===\"string\"&&\"traceFlags\"in e&&typeof e.traceFlags===\"number\"}});var dc=g(function(vb){Object.defineProperty(vb,\"__esModule\",{value:!0});vb.ProxyTracer=void 0;var yb=uc(),_P=new yb.NoopTracer;class bb{constructor(e,t,n,r){this._provider=e,this.name=t,this.version=n,this.options=r}startSpan(e,t,n){return this._getTracer().startSpan(e,t,n)}startActiveSpan(e,t,n,r){let o=this._getTracer();return Reflect.apply(o.startActiveSpan,o,arguments)}_getTracer(){if(this._delegate)return this._delegate;let e=this._provider.getDelegateTracer(this.name,this.version,this.options);if(!e)return _P;return this._delegate=e,this._delegate}}vb.ProxyTracer=bb});var kb=g(function(Sb){Object.defineProperty(Sb,\"__esModule\",{value:!0});Sb.NoopTracerProvider=void 0;var wb=uc();class xb{getTracer(e,t,n){return new wb.NoopTracer}}Sb.NoopTracerProvider=xb});var pc=g(function(Cb){Object.defineProperty(Cb,\"__esModule\",{value:!0});Cb.ProxyTracerProvider=void 0;var Rb=dc(),Tb=kb(),wP=new Tb.NoopTracerProvider;class Ab{getTracer(e,t,n){var r;return(r=this.getDelegateTracer(e,t,n))!==null&&r!==void 0?r:new Rb.ProxyTracer(this,e,t,n)}getDelegate(){var e;return(e=this._delegate)!==null&&e!==void 0?e:wP}setDelegate(e){this._delegate=e}getDelegateTracer(e,t,n){var r;return(r=this._delegate)===null||r===void 0?void 0:r.getTracer(e,t,n)}}Cb.ProxyTracerProvider=Ab});var Ob=g(function(Pb){Object.defineProperty(Pb,\"__esModule\",{value:!0});Pb.SamplingDecision=void 0;var xP;(function(e){e[e.NOT_RECORD=0]=\"NOT_RECORD\",e[e.RECORD=1]=\"RECORD\",e[e.RECORD_AND_SAMPLED=2]=\"RECORD_AND_SAMPLED\"})(xP=Pb.SamplingDecision||(Pb.SamplingDecision={}))});var Mb=g(function($b){Object.defineProperty($b,\"__esModule\",{value:!0});$b.SpanKind=void 0;var SP;(function(e){e[e.INTERNAL=0]=\"INTERNAL\",e[e.SERVER=1]=\"SERVER\",e[e.CLIENT=2]=\"CLIENT\",e[e.PRODUCER=3]=\"PRODUCER\",e[e.CONSUMER=4]=\"CONSUMER\"})(SP=$b.SpanKind||($b.SpanKind={}))});var zb=g(function(qb){Object.defineProperty(qb,\"__esModule\",{value:!0});qb.SpanStatusCode=void 0;var IP;(function(e){e[e.UNSET=0]=\"UNSET\",e[e.OK=1]=\"OK\",e[e.ERROR=2]=\"ERROR\"})(IP=qb.SpanStatusCode||(qb.SpanStatusCode={}))});var Db=g(function(jb){Object.defineProperty(jb,\"__esModule\",{value:!0});jb.validateValue=jb.validateKey=void 0;var hc=\"[_0-9a-z-*/]\",kP=`[a-z]${hc}{0,255}`,RP=`[a-z0-9]${hc}{0,240}@[a-z]${hc}{0,13}`,TP=new RegExp(`^(?:${kP}|${RP})$`),AP=/^[ -~]{0,255}[!-~]$/,CP=/,|=/;function EP(e){return TP.test(e)}jb.validateKey=EP;function PP(e){return AP.test(e)&&!CP.test(e)}jb.validateValue=PP});var Fb=g(function(Bb){Object.defineProperty(Bb,\"__esModule\",{value:!0});Bb.TraceStateImpl=void 0;var ss=Db(),Ub=32,$P=512,Lb=\",\",Gb=\"=\";class yc{constructor(e){if(this._internalState=new Map,e)this._parse(e)}set(e,t){let n=this._clone();if(n._internalState.has(e))n._internalState.delete(e);return n._internalState.set(e,t),n}unset(e){let t=this._clone();return t._internalState.delete(e),t}get(e){return this._internalState.get(e)}serialize(){return Array.from(this._internalState.keys()).reduceRight((e,t)=>(e.push(t+Gb+this.get(t)),e),[]).join(Lb)}_parse(e){if(e.length>$P)return;if(this._internalState=e.split(Lb).reduceRight((t,n)=>{let r=n.trim(),o=r.indexOf(Gb);if(o!==-1){let s=r.slice(0,o),i=r.slice(o+1,n.length);if(ss.validateKey(s)&&ss.validateValue(i))t.set(s,i)}return t},new Map),this._internalState.size>Ub)this._internalState=new Map(Array.from(this._internalState.entries()).reverse().slice(0,Ub))}_keys(){return Array.from(this._internalState.keys()).reverse()}_clone(){let e=new yc;return e._internalState=new Map(this._internalState),e}}Bb.TraceStateImpl=yc});var Hb=g(function(Wb){Object.defineProperty(Wb,\"__esModule\",{value:!0});Wb.createTraceState=void 0;var Jb=Fb();function MP(e){return new Jb.TraceStateImpl(e)}Wb.createTraceState=MP});var Qb=g(function(Yb){Object.defineProperty(Yb,\"__esModule\",{value:!0});Yb.context=void 0;var Zb=Jr();Yb.context=Zb.ContextAPI.getInstance()});var rv=g(function(tv){Object.defineProperty(tv,\"__esModule\",{value:!0});tv.diag=void 0;var ev=vn();tv.diag=ev.DiagAPI.instance()});var av=g(function(sv){Object.defineProperty(sv,\"__esModule\",{value:!0});sv.NOOP_METER_PROVIDER=sv.NoopMeterProvider=void 0;var ov=Qa();class bc{getMeter(e,t,n){return ov.NOOP_METER}}sv.NoopMeterProvider=bc;sv.NOOP_METER_PROVIDER=new bc});var dv=g(function(lv){Object.defineProperty(lv,\"__esModule\",{value:!0});lv.MetricsAPI=void 0;var cv=av(),Wn=bn(),is=vn(),vc=\"metrics\";class _c{constructor(){}static getInstance(){if(!this._instance)this._instance=new _c;return this._instance}setGlobalMeterProvider(e){return Wn.registerGlobal(vc,e,is.DiagAPI.instance())}getMeterProvider(){return Wn.getGlobal(vc)||cv.NOOP_METER_PROVIDER}getMeter(e,t,n){return this.getMeterProvider().getMeter(e,t,n)}disable(){Wn.unregisterGlobal(vc,is.DiagAPI.instance())}}lv.MetricsAPI=_c});var gv=g(function(mv){Object.defineProperty(mv,\"__esModule\",{value:!0});mv.metrics=void 0;var pv=dv();mv.metrics=pv.MetricsAPI.getInstance()});var vv=g(function(yv){Object.defineProperty(yv,\"__esModule\",{value:!0});yv.NoopTextMapPropagator=void 0;class hv{inject(e,t){}extract(e,t){return e}fields(){return[]}}yv.NoopTextMapPropagator=hv});var kv=g(function(Sv){Object.defineProperty(Sv,\"__esModule\",{value:!0});Sv.deleteBaggage=Sv.setBaggage=Sv.getActiveBaggage=Sv.getBaggage=void 0;var _v=Jr(),wv=Vr(),wc=wv.createContextKey(\"OpenTelemetry Baggage Key\");function xv(e){return e.getValue(wc)||void 0}Sv.getBaggage=xv;function zP(){return xv(_v.ContextAPI.getInstance().active())}Sv.getActiveBaggage=zP;function jP(e,t){return e.setValue(wc,t)}Sv.setBaggage=jP;function NP(e){return e.deleteValue(wc)}Sv.deleteBaggage=NP});var Ev=g(function(Av){Object.defineProperty(Av,\"__esModule\",{value:!0});Av.PropagationAPI=void 0;var Kn=bn(),Rv=vv(),as=tc(),qt=kv(),Tv=Ba(),cs=vn(),xc=\"propagation\",GP=new Rv.NoopTextMapPropagator;class Sc{constructor(){this.createBaggage=Tv.createBaggage,this.getBaggage=qt.getBaggage,this.getActiveBaggage=qt.getActiveBaggage,this.setBaggage=qt.setBaggage,this.deleteBaggage=qt.deleteBaggage}static getInstance(){if(!this._instance)this._instance=new Sc;return this._instance}setGlobalPropagator(e){return Kn.registerGlobal(xc,e,cs.DiagAPI.instance())}inject(e,t,n=as.defaultTextMapSetter){return this._getGlobalPropagator().inject(e,t,n)}extract(e,t,n=as.defaultTextMapGetter){return this._getGlobalPropagator().extract(e,t,n)}fields(){return this._getGlobalPropagator().fields()}disable(){Kn.unregisterGlobal(xc,cs.DiagAPI.instance())}_getGlobalPropagator(){return Kn.getGlobal(xc)||GP}}Av.PropagationAPI=Sc});var Mv=g(function(Ov){Object.defineProperty(Ov,\"__esModule\",{value:!0});Ov.propagation=void 0;var Pv=Ev();Ov.propagation=Pv.PropagationAPI.getInstance()});var jv=g(function(qv){Object.defineProperty(qv,\"__esModule\",{value:!0});qv.TraceAPI=void 0;var Hn=bn(),ls=pc(),us=rs(),Ue=cc(),ds=vn(),Ic=\"trace\";class kc{constructor(){this._proxyTracerProvider=new ls.ProxyTracerProvider,this.wrapSpanContext=us.wrapSpanContext,this.isSpanContextValid=us.isSpanContextValid,this.deleteSpan=Ue.deleteSpan,this.getSpan=Ue.getSpan,this.getActiveSpan=Ue.getActiveSpan,this.getSpanContext=Ue.getSpanContext,this.setSpan=Ue.setSpan,this.setSpanContext=Ue.setSpanContext}static getInstance(){if(!this._instance)this._instance=new kc;return this._instance}setGlobalTracerProvider(e){let t=Hn.registerGlobal(Ic,this._proxyTracerProvider,ds.DiagAPI.instance());if(t)this._proxyTracerProvider.setDelegate(e);return t}getTracerProvider(){return Hn.getGlobal(Ic)||this._proxyTracerProvider}getTracer(e,t){return this.getTracerProvider().getTracer(e,t)}disable(){Hn.unregisterGlobal(Ic,ds.DiagAPI.instance()),this._proxyTracerProvider=new ls.ProxyTracerProvider}}qv.TraceAPI=kc});var Lv=g(function(Dv){Object.defineProperty(Dv,\"__esModule\",{value:!0});Dv.trace=void 0;var Nv=jv();Dv.trace=Nv.TraceAPI.getInstance()});var Vv=g(function(X){Object.defineProperty(X,\"__esModule\",{value:!0});X.trace=X.propagation=X.metrics=X.diag=X.context=X.INVALID_SPAN_CONTEXT=X.INVALID_TRACEID=X.INVALID_SPANID=X.isValidSpanId=X.isValidTraceId=X.isSpanContextValid=X.createTraceState=X.TraceFlags=X.SpanStatusCode=X.SpanKind=X.SamplingDecision=X.ProxyTracerProvider=X.ProxyTracer=X.defaultTextMapSetter=X.defaultTextMapGetter=X.ValueType=X.createNoopMeter=X.DiagLogLevel=X.DiagConsoleLogger=X.ROOT_CONTEXT=X.createContextKey=X.baggageEntryMetadataFromString=void 0;var BP=Ba();Object.defineProperty(X,\"baggageEntryMetadataFromString\",{enumerable:!0,get:function(){return BP.baggageEntryMetadataFromString}});var Gv=Vr();Object.defineProperty(X,\"createContextKey\",{enumerable:!0,get:function(){return Gv.createContextKey}});Object.defineProperty(X,\"ROOT_CONTEXT\",{enumerable:!0,get:function(){return Gv.ROOT_CONTEXT}});var VP=wy();Object.defineProperty(X,\"DiagConsoleLogger\",{enumerable:!0,get:function(){return VP.DiagConsoleLogger}});var FP=Ko();Object.defineProperty(X,\"DiagLogLevel\",{enumerable:!0,get:function(){return FP.DiagLogLevel}});var JP=Qa();Object.defineProperty(X,\"createNoopMeter\",{enumerable:!0,get:function(){return JP.createNoopMeter}});var WP=$y();Object.defineProperty(X,\"ValueType\",{enumerable:!0,get:function(){return WP.ValueType}});var Bv=tc();Object.defineProperty(X,\"defaultTextMapGetter\",{enumerable:!0,get:function(){return Bv.defaultTextMapGetter}});Object.defineProperty(X,\"defaultTextMapSetter\",{enumerable:!0,get:function(){return Bv.defaultTextMapSetter}});var KP=dc();Object.defineProperty(X,\"ProxyTracer\",{enumerable:!0,get:function(){return KP.ProxyTracer}});var HP=pc();Object.defineProperty(X,\"ProxyTracerProvider\",{enumerable:!0,get:function(){return HP.ProxyTracerProvider}});var ZP=Ob();Object.defineProperty(X,\"SamplingDecision\",{enumerable:!0,get:function(){return ZP.SamplingDecision}});var YP=Mb();Object.defineProperty(X,\"SpanKind\",{enumerable:!0,get:function(){return YP.SpanKind}});var XP=zb();Object.defineProperty(X,\"SpanStatusCode\",{enumerable:!0,get:function(){return XP.SpanStatusCode}});var QP=sc();Object.defineProperty(X,\"TraceFlags\",{enumerable:!0,get:function(){return QP.TraceFlags}});var eO=Hb();Object.defineProperty(X,\"createTraceState\",{enumerable:!0,get:function(){return eO.createTraceState}});var Rc=rs();Object.defineProperty(X,\"isSpanContextValid\",{enumerable:!0,get:function(){return Rc.isSpanContextValid}});Object.defineProperty(X,\"isValidTraceId\",{enumerable:!0,get:function(){return Rc.isValidTraceId}});Object.defineProperty(X,\"isValidSpanId\",{enumerable:!0,get:function(){return Rc.isValidSpanId}});var Tc=Qo();Object.defineProperty(X,\"INVALID_SPANID\",{enumerable:!0,get:function(){return Tc.INVALID_SPANID}});Object.defineProperty(X,\"INVALID_TRACEID\",{enumerable:!0,get:function(){return Tc.INVALID_TRACEID}});Object.defineProperty(X,\"INVALID_SPAN_CONTEXT\",{enumerable:!0,get:function(){return Tc.INVALID_SPAN_CONTEXT}});var ps=Qb();Object.defineProperty(X,\"context\",{enumerable:!0,get:function(){return ps.context}});var ms=rv();Object.defineProperty(X,\"diag\",{enumerable:!0,get:function(){return ms.diag}});var fs=gv();Object.defineProperty(X,\"metrics\",{enumerable:!0,get:function(){return fs.metrics}});var gs=Mv();Object.defineProperty(X,\"propagation\",{enumerable:!0,get:function(){return gs.propagation}});var hs=Lv();Object.defineProperty(X,\"trace\",{enumerable:!0,get:function(){return hs.trace}});X.default={context:ps.context,diag:ms.diag,metrics:fs.metrics,propagation:gs.propagation,trace:hs.trace}});var Fv=g(function(sH,Cc){var ys=Vv(),Ac=Aa();Cc.exports=(e,t={})=>{let n=e?[e]:void 0,r=t.prefix?t.prefix:\"\",o=t.labels?t.labels:{},s=t.enableExemplars?t.enableExemplars:!1,i=Object.keys(o),a=process.cpuUsage(),c=new Ac({name:r+\"process_cpu_user_seconds_total\",help:\"Total user CPU time spent in seconds.\",enableExemplars:s,registers:n,labelNames:i,collect(){let p=process.cpuUsage(),m=p.user-a.user,d=p.system-a.system;if(a=p,this.enableExemplars){let f={},h=ys.trace.getSpan(ys.context.active());if(h)f={traceId:h.spanContext().traceId,spanId:h.spanContext().spanId};c.inc({labels:o,value:m/1e6,exemplarLabels:f}),l.inc({labels:o,value:d/1e6,exemplarLabels:f}),u.inc({labels:o,value:(m+d)/1e6,exemplarLabels:f})}else c.inc(o,m/1e6),l.inc(o,d/1e6),u.inc(o,(m+d)/1e6)}}),l=new Ac({name:r+\"process_cpu_system_seconds_total\",help:\"Total system CPU time spent in seconds.\",enableExemplars:s,registers:n,labelNames:i}),u=new Ac({name:r+\"process_cpu_seconds_total\",help:\"Total user and system CPU time spent in seconds.\",enableExemplars:s,registers:n,labelNames:i})};Cc.exports.metricNames=[\"process_cpu_user_seconds_total\",\"process_cpu_system_seconds_total\",\"process_cpu_seconds_total\"]});var Jv=g(function(iH,Ec){var rO=Ae(),oO=Math.round(Date.now()/1000-process.uptime());Ec.exports=(e,t={})=>{let n=t.prefix?t.prefix:\"\",r=t.labels?t.labels:{},o=Object.keys(r);new rO({name:n+\"process_start_time_seconds\",help:\"Start time of the process since unix epoch in seconds.\",registers:e?[e]:void 0,labelNames:o,aggregator:\"omit\",collect(){this.set(r,oO)}})};Ec.exports.metricNames=[\"process_start_time_seconds\"]});var Kv=g(function(aH,Oc){var Pc=Ae(),Wv=_e(\"fs\"),sO=[\"VmSize\",\"VmRSS\",\"VmData\"];function iO(e){return e.split(`\n`).reduce((t,n)=>{if(!sO.some((s)=>n.startsWith(s)))return t;let r=n.split(\":\"),o=r[1].trim();return o=o.substr(0,o.length-3),o=Number(o)*1024,t[r[0]]=o,t},{})}Oc.exports=(e,t={})=>{let n=e?[e]:void 0,r=t.prefix?t.prefix:\"\",o=t.labels?t.labels:{},s=Object.keys(o),i=new Pc({name:r+\"process_resident_memory_bytes\",help:\"Resident memory size in bytes.\",registers:n,labelNames:s,collect(){try{let l=Wv.readFileSync(\"/proc/self/status\",\"utf8\"),u=iO(l);i.set(o,u.VmRSS),a.set(o,u.VmSize),c.set(o,u.VmData)}catch{}}}),a=new Pc({name:r+\"process_virtual_memory_bytes\",help:\"Virtual memory size in bytes.\",registers:n,labelNames:s}),c=new Pc({name:r+\"process_heap_bytes\",help:\"Process heap size in bytes.\",registers:n,labelNames:s})};Oc.exports.metricNames=[\"process_resident_memory_bytes\",\"process_virtual_memory_bytes\",\"process_heap_bytes\"]});var $c=g(function(cH,Hv){function aO(){try{return process.memoryUsage()}catch{return}}Hv.exports=aO});var Zv=g(function(lH,qc){var cO=Ae(),Mc=Kv(),lO=$c();function uO(e,t={}){let n=t.prefix?t.prefix:\"\",r=t.labels?t.labels:{},o=Object.keys(r);new cO({name:n+\"process_resident_memory_bytes\",help:\"Resident memory size in bytes.\",registers:e?[e]:void 0,labelNames:o,collect(){let s=lO();if(s)this.set(r,s.rss)}})}qc.exports=(e,t)=>process.platform===\"linux\"?Mc(e,t):uO(e,t);qc.exports.metricNames=process.platform===\"linux\"?Mc.metricNames:[\"process_resident_memory_bytes\"]});var Qv=g(function(uH,zc){var dO=Ae(),Yv=_e(\"fs\"),Xv=_e(\"process\");zc.exports=(e,t={})=>{if(Xv.platform!==\"linux\")return;let n=t.prefix?t.prefix:\"\",r=t.labels?t.labels:{},o=Object.keys(r);new dO({name:n+\"process_open_fds\",help:\"Number of open file descriptors.\",registers:e?[e]:void 0,labelNames:o,collect(){try{let s=Yv.readdirSync(\"/proc/self/fd\");this.set(r,s.length-1)}catch{}}})};zc.exports.metricNames=[\"process_open_fds\"]});var t_=g(function(dH,jc){var pO=Ae(),e_=_e(\"fs\"),Wr;jc.exports=(e,t={})=>{if(Wr===void 0)try{let i=e_.readFileSync(\"/proc/self/limits\",\"utf8\").split(`\n`);for(let a of i)if(a.startsWith(\"Max open files\")){let c=a.split(/ +/);Wr=Number(c[1]);break}}catch{return}if(Wr===void 0)return;let n=t.prefix?t.prefix:\"\",r=t.labels?t.labels:{},o=Object.keys(r);new pO({name:n+\"process_max_fds\",help:\"Maximum number of open file descriptors.\",registers:e?[e]:void 0,labelNames:o,collect(){if(Wr!==void 0)this.set(r,Wr)}})};jc.exports.metricNames=[\"process_max_fds\"]});var d_=g(function(pH,Nc){var zt=Ae(),bs;try{bs=_e(\"perf_hooks\")}catch{}var r_=\"nodejs_eventloop_lag_seconds\",o_=\"nodejs_eventloop_lag_min_seconds\",s_=\"nodejs_eventloop_lag_max_seconds\",i_=\"nodejs_eventloop_lag_mean_seconds\",a_=\"nodejs_eventloop_lag_stddev_seconds\",c_=\"nodejs_eventloop_lag_p50_seconds\",l_=\"nodejs_eventloop_lag_p90_seconds\",u_=\"nodejs_eventloop_lag_p99_seconds\";function n_(e,t,n){let r=process.hrtime(e),s=(r[0]*1e9+r[1])/1e9;t.set(n,s)}Nc.exports=(e,t={})=>{let n=t.prefix?t.prefix:\"\",r=t.labels?t.labels:{},o=Object.keys(r),s=e?[e]:void 0,i=()=>{let h=process.hrtime();setImmediate(n_,h,a,r)};if(bs&&bs.monitorEventLoopDelay)try{let h=bs.monitorEventLoopDelay({resolution:t.eventLoopMonitoringPrecision});h.enable(),i=()=>{let y=process.hrtime();setImmediate(n_,y,a,r),c.set(r,h.min/1e9),l.set(r,h.max/1e9),u.set(r,h.mean/1e9),p.set(r,h.stddev/1e9),m.set(r,h.percentile(50)/1e9),d.set(r,h.percentile(90)/1e9),f.set(r,h.percentile(99)/1e9),h.reset()}}catch(h){if(h.code===\"ERR_NOT_IMPLEMENTED\")return;throw h}let a=new zt({name:n+r_,help:\"Lag of event loop in seconds.\",registers:s,labelNames:o,aggregator:\"average\",collect:i}),c=new zt({name:n+o_,help:\"The minimum recorded event loop delay.\",registers:s,labelNames:o,aggregator:\"min\"}),l=new zt({name:n+s_,help:\"The maximum recorded event loop delay.\",registers:s,labelNames:o,aggregator:\"max\"}),u=new zt({name:n+i_,help:\"The mean of the recorded event loop delays.\",registers:s,labelNames:o,aggregator:\"average\"}),p=new zt({name:n+a_,help:\"The standard deviation of the recorded event loop delays.\",registers:s,labelNames:o,aggregator:\"average\"}),m=new zt({name:n+c_,help:\"The 50th percentile of the recorded event loop delays.\",registers:s,labelNames:o,aggregator:\"average\"}),d=new zt({name:n+l_,help:\"The 90th percentile of the recorded event loop delays.\",registers:s,labelNames:o,aggregator:\"average\"}),f=new zt({name:n+u_,help:\"The 99th percentile of the recorded event loop delays.\",registers:s,labelNames:o,aggregator:\"average\"})};Nc.exports.metricNames=[r_,o_,s_,i_,a_,c_,l_,u_]});var Zn=g(function(mH,p_){function mO(e){let t={};for(let n=0;n<e.length;n++){let r=e[n];if(!r||typeof r.constructor>\"u\")continue;if(Object.hasOwnProperty.call(t,r.constructor.name))t[r.constructor.name]+=1;else t[r.constructor.name]=1}return t}function fO(e,t,n){e.reset();for(let r in t)e.set(Object.assign({type:r},n||{}),t[r])}p_.exports={aggregateByObjectName:mO,updateMetrics:fO}});var f_=g(function(fH,Dc){var{aggregateByObjectName:gO}=Zn(),{updateMetrics:hO}=Zn(),m_=Ae();Dc.exports=(e,t={})=>{if(typeof process._getActiveHandles!==\"function\")return;let n=e?[e]:void 0,r=t.prefix?t.prefix:\"\",o=t.labels?t.labels:{},s=Object.keys(o);new m_({name:r+\"nodejs_active_handles\",help:\"Number of active libuv handles grouped by handle type. Every handle type is C++ class name.\",labelNames:[\"type\",...s],registers:n,collect(){let i=process._getActiveHandles();hO(this,gO(i),o)}}),new m_({name:r+\"nodejs_active_handles_total\",help:\"Total number of active handles.\",registers:n,labelNames:s,collect(){let i=process._getActiveHandles();this.set(o,i.length)}})};Dc.exports.metricNames=[\"nodejs_active_handles\",\"nodejs_active_handles_total\"]});var h_=g(function(gH,Uc){var g_=Ae(),{aggregateByObjectName:yO}=Zn(),{updateMetrics:bO}=Zn();Uc.exports=(e,t={})=>{if(typeof process._getActiveRequests!==\"function\")return;let n=t.prefix?t.prefix:\"\",r=t.labels?t.labels:{},o=Object.keys(r);new g_({name:n+\"nodejs_active_requests\",help:\"Number of active libuv requests grouped by request type. Every request type is C++ class name.\",labelNames:[\"type\",...o],registers:e?[e]:void 0,collect(){let s=process._getActiveRequests();bO(this,yO(s),r)}}),new g_({name:n+\"nodejs_active_requests_total\",help:\"Total number of active requests.\",registers:e?[e]:void 0,labelNames:o,collect(){let s=process._getActiveRequests();this.set(r,s.length)}})};Uc.exports.metricNames=[\"nodejs_active_requests\",\"nodejs_active_requests_total\"]});var b_=g(function(hH,Lc){var y_=Ae(),{updateMetrics:vO}=Zn();Lc.exports=(e,t={})=>{if(typeof process.getActiveResourcesInfo!==\"function\")return;let n=t.prefix?t.prefix:\"\",r=t.labels?t.labels:{},o=Object.keys(r);new y_({name:n+\"nodejs_active_resources\",help:\"Number of active resources that are currently keeping the event loop alive, grouped by async resource type.\",labelNames:[\"type\",...o],registers:e?[e]:void 0,collect(){let s=process.getActiveResourcesInfo(),i={};for(let a=0;a<s.length;a++){let c=s[a];if(Object.hasOwn(i,c))i[c]+=1;else i[c]=1}vO(this,i,r)}}),new y_({name:n+\"nodejs_active_resources_total\",help:\"Total number of active resources.\",registers:e?[e]:void 0,labelNames:o,collect(){let s=process.getActiveResourcesInfo();this.set(r,s.length)}})};Lc.exports.metricNames=[\"nodejs_active_resources\",\"nodejs_active_resources_total\"]});var v_=g(function(yH,Bc){var Gc=Ae(),_O=$c();Bc.exports=(e,t={})=>{if(typeof process.memoryUsage!==\"function\")return;let n=t.labels?t.labels:{},r=Object.keys(n),o=e?[e]:void 0,s=t.prefix?t.prefix:\"\",i=()=>{let u=_O();if(u){if(a.set(n,u.heapTotal),c.set(n,u.heapUsed),u.external!==void 0)l.set(n,u.external)}},a=new Gc({name:s+\"nodejs_heap_size_total_bytes\",help:\"Process heap size from Node.js in bytes.\",registers:o,labelNames:r,collect:i}),c=new Gc({name:s+\"nodejs_heap_size_used_bytes\",help:\"Process heap size used from Node.js in bytes.\",registers:o,labelNames:r}),l=new Gc({name:s+\"nodejs_external_memory_bytes\",help:\"Node.js external memory size in bytes.\",registers:o,labelNames:r})};Bc.exports.metricNames=[\"nodejs_heap_size_total_bytes\",\"nodejs_heap_size_used_bytes\",\"nodejs_external_memory_bytes\"]});var w_=g(function(bH,Fc){var wO=Ae(),vs=_e(\"v8\"),__=[\"total\",\"used\",\"available\"],Vc={};__.forEach((e)=>{Vc[e]=`nodejs_heap_space_size_${e}_bytes`});Fc.exports=(e,t={})=>{try{vs.getHeapSpaceStatistics()}catch(a){if(a.code===\"ERR_NOT_IMPLEMENTED\")return;throw a}let n=e?[e]:void 0,r=t.prefix?t.prefix:\"\",o=t.labels?t.labels:{},s=[\"space\",...Object.keys(o)],i={};__.forEach((a)=>{i[a]=new wO({name:r+Vc[a],help:`Process heap space size ${a} from Node.js in bytes.`,labelNames:s,registers:n})}),i.total.collect=()=>{for(let a of vs.getHeapSpaceStatistics()){let c=a.space_name.substr(0,a.space_name.indexOf(\"_space\"));i.total.set({space:c,...o},a.space_size),i.used.set({space:c,...o},a.space_used_size),i.available.set({space:c,...o},a.space_available_size)}}};Fc.exports.metricNames=Object.values(Vc)});var S_=g(function(vH,Wc){var xO=Ae(),x_=process.version,Jc=x_.slice(1).split(\".\").map(Number);Wc.exports=(e,t={})=>{let n=t.prefix?t.prefix:\"\",r=t.labels?t.labels:{},o=Object.keys(r);new xO({name:n+\"nodejs_version_info\",help:\"Node.js version info.\",labelNames:[\"version\",\"major\",\"minor\",\"patch\",...o],registers:e?[e]:void 0,aggregator:\"first\",collect(){this.labels(x_,Jc[0],Jc[1],Jc[2],...Object.values(r)).set(1)}})};Wc.exports.metricNames=[\"nodejs_version_info\"]});var k_=g(function(_H,Kc){var SO=Ma(),_t;try{_t=_e(\"perf_hooks\")}catch{}var I_=\"nodejs_gc_duration_seconds\",IO=[0.001,0.01,0.1,1,2,5],Yn=[];if(_t&&_t.constants)Yn[_t.constants.NODE_PERFORMANCE_GC_MAJOR]=\"major\",Yn[_t.constants.NODE_PERFORMANCE_GC_MINOR]=\"minor\",Yn[_t.constants.NODE_PERFORMANCE_GC_INCREMENTAL]=\"incremental\",Yn[_t.constants.NODE_PERFORMANCE_GC_WEAKCB]=\"weakcb\";Kc.exports=(e,t={})=>{if(!_t)return;let n=t.prefix?t.prefix:\"\",r=t.labels?t.labels:{},o=Object.keys(r),s=t.gcDurationBuckets?t.gcDurationBuckets:IO,i=new SO({name:n+I_,help:\"Garbage collection duration by kind, one of major, minor, incremental or weakcb.\",labelNames:[\"kind\",...o],enableExemplars:!1,buckets:s,registers:e?[e]:void 0});new _t.PerformanceObserver((c)=>{let l=c.getEntries()[0],u=l.detail?Yn[l.detail.kind]:Yn[l.kind];i.observe(Object.assign({kind:u},r),l.duration/1000)}).observe({entryTypes:[\"gc\"]})};Kc.exports.metricNames=[I_]});var T_=g(function(wH,Hc){var{isObject:kO}=et(),RO=Fv(),TO=Jv(),AO=Zv(),CO=Qv(),EO=t_(),PO=d_(),OO=f_(),$O=h_(),MO=b_(),qO=v_(),zO=w_(),jO=S_(),NO=k_(),R_={processCpuTotal:RO,processStartTime:TO,osMemoryHeap:AO,processOpenFileDescriptors:CO,processMaxFileDescriptors:EO,eventLoopLag:PO,...typeof process.getActiveResourcesInfo===\"function\"?{processResources:MO}:{},processHandles:OO,processRequests:$O,heapSizeAndUsed:qO,heapSpacesSizeAndUsed:zO,version:jO,gc:NO},DO=Object.keys(R_);Hc.exports=function(t){if(t!==null&&t!==void 0&&!kO(t))throw TypeError(\"config must be null, undefined, or an object\");t={eventLoopMonitoringPrecision:10,...t};for(let n of Object.values(R_))n(t.register,t)};Hc.exports.metricsList=DO});var Zc=g(function(GO){var{Grouper:UO,hashObject:LO}=et();function Xn(e){return(t)=>{if(t.length===0)return;let n={help:t[0].help,name:t[0].name,type:t[0].type,values:[],aggregator:t[0].aggregator},r=new UO;return t.forEach((o)=>{o.values.forEach((s)=>{let i=LO(s.labels);r.add(`${s.metricName}_${i}`,s)})}),r.forEach((o)=>{if(o.length===0)return;let s={value:e(o),labels:o[0].labels};if(o[0].metricName)s.metricName=o[0].metricName;n.values.push(s)}),n}}GO.AggregatorFactory=Xn;GO.aggregators={sum:Xn((e)=>e.reduce((t,n)=>t+n.value,0)),first:Xn((e)=>e[0].value),omit:()=>{},average:Xn((e)=>e.reduce((t,n)=>t+n.value,0)/e.length),min:Xn((e)=>e.reduce((t,n)=>Math.min(t,n.value),1/0)),max:Xn((e)=>e.reduce((t,n)=>Math.max(t,n.value),-1/0))}});var O_=g(function(SH,P_){var wt=Nn(),{Grouper:FO}=et(),{aggregators:JO}=Zc(),_n=()=>{let e=_e(\"cluster\");return _n=()=>e,e},C_=\"prom-client:getMetricsReq\",Yc=\"prom-client:getMetricsRes\",E_=[wt.globalRegistry],WO=0,A_=!1,Xc=new Map;class Qc extends wt{constructor(e=wt.PROMETHEUS_CONTENT_TYPE){super(e);KO()}clusterMetrics(){let e=WO++;return new Promise((t,n)=>{let r=!1;function o(a,c){if(r)return;if(r=!0,a)n(a);else t(c)}let s={responses:[],pending:0,done:o,errorTimeout:setTimeout(()=>{let a=Error(\"Operation timed out.\");s.done(a)},5000)};Xc.set(e,s);let i={type:C_,requestId:e};for(let a in _n().workers)if(_n().workers[a].isConnected())_n().workers[a].send(i),s.pending++;if(s.pending===0)clearTimeout(s.errorTimeout),process.nextTick(()=>o(null,\"\"))})}get contentType(){return super.contentType}static aggregate(e,t=wt.PROMETHEUS_CONTENT_TYPE){let n=new wt,r=new FO;return n.setContentType(t),e.forEach((o)=>{o.forEach((s)=>{r.add(s.name,s)})}),r.forEach((o)=>{let s=o[0].aggregator,i=JO[s];if(typeof i!==\"function\")throw Error(`'${s}' is not a defined aggregator.`);let a=i(o);if(a){let c=Object.assign({get:()=>a},a);n.registerMetric(c)}}),n}static setRegistries(e){if(!Array.isArray(e))e=[e];e.forEach((t)=>{if(!(t instanceof wt))throw TypeError(`Expected Registry, got ${typeof t}`)}),E_=e}}function KO(){if(A_)return;if(A_=!0,_n().isMaster)_n().on(\"message\",(e,t)=>{if(t.type===Yc){let n=Xc.get(t.requestId);if(t.error){n.done(Error(t.error));return}if(t.metrics.forEach((r)=>n.responses.push(r)),n.pending--,n.pending===0){Xc.delete(t.requestId),clearTimeout(n.errorTimeout);let o=Qc.aggregate(n.responses).metrics();n.done(null,o)}}});if(_n().isWorker)process.on(\"message\",(e)=>{if(e.type===C_)Promise.all(E_.map((t)=>t.getMetricsAsJSON())).then((t)=>{process.send({type:Yc,requestId:e.requestId,metrics:t})}).catch((t)=>{process.send({type:Yc,requestId:e.requestId,error:t.message})})})}P_.exports=Qc});var M_=g(function($_){$_.register=Nn().globalRegistry;$_.Registry=Nn();Object.defineProperty($_,\"contentType\",{configurable:!1,enumerable:!0,get(){return $_.register.contentType},set(e){$_.register.setContentType(e)}});$_.prometheusContentType=$_.Registry.PROMETHEUS_CONTENT_TYPE;$_.openMetricsContentType=$_.Registry.OPENMETRICS_CONTENT_TYPE;$_.validateMetricName=yn().validateMetricName;$_.Counter=Aa();$_.Gauge=Ae();$_.Histogram=Ma();$_.Summary=Ph();$_.Pushgateway=Mh();$_.linearBuckets=Da().linearBuckets;$_.exponentialBuckets=Da().exponentialBuckets;$_.collectDefaultMetrics=T_();$_.aggregators=Zc().aggregators;$_.AggregatorRegistry=O_()});var Xr=g(function(U_){Object.defineProperty(U_,\"__esModule\",{value:!0});U_.regexpCode=U_.getEsmExportName=U_.getProperty=U_.safeStringify=U_.stringify=U_.strConcat=U_.addCodeArg=U_.str=U_._=U_.nil=U_._Code=U_.Name=U_.IDENTIFIER=U_._CodeOrName=void 0;class xs{}U_._CodeOrName=xs;U_.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;class Qn extends xs{constructor(e){super();if(!U_.IDENTIFIER.test(e))throw Error(\"CodeGen: name must be a valid identifier\");this.str=e}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}}U_.Name=Qn;class Ye extends xs{constructor(e){super();this._items=typeof e===\"string\"?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let e=this._items[0];return e===\"\"||e==='\"\"'}get str(){var e;return(e=this._str)!==null&&e!==void 0?e:this._str=this._items.reduce((t,n)=>`${t}${n}`,\"\")}get names(){var e;return(e=this._names)!==null&&e!==void 0?e:this._names=this._items.reduce((t,n)=>{if(n instanceof Qn)t[n.str]=(t[n.str]||0)+1;return t},{})}}U_._Code=Ye;U_.nil=new Ye(\"\");function N_(e,...t){let n=[e[0]],r=0;while(r<t.length)il(n,t[r]),n.push(e[++r]);return new Ye(n)}U_._=N_;var sl=new Ye(\"+\");function D_(e,...t){let n=[Yr(e[0])],r=0;while(r<t.length)n.push(sl),il(n,t[r]),n.push(sl,Yr(e[++r]));return g$(n),new Ye(n)}U_.str=D_;function il(e,t){if(t instanceof Ye)e.push(...t._items);else if(t instanceof Qn)e.push(t);else e.push(b$(t))}U_.addCodeArg=il;function g$(e){let t=1;while(t<e.length-1){if(e[t]===sl){let n=h$(e[t-1],e[t+1]);if(n!==void 0){e.splice(t-1,3,n);continue}e[t++]=\"+\"}t++}}function h$(e,t){if(t==='\"\"')return e;if(e==='\"\"')return t;if(typeof e==\"string\"){if(t instanceof Qn||e[e.length-1]!=='\"')return;if(typeof t!=\"string\")return`${e.slice(0,-1)}${t}\"`;if(t[0]==='\"')return e.slice(0,-1)+t.slice(1);return}if(typeof t==\"string\"&&t[0]==='\"'&&!(e instanceof Qn))return`\"${e}${t.slice(1)}`;return}function y$(e,t){return t.emptyStr()?e:e.emptyStr()?t:D_`${e}${t}`}U_.strConcat=y$;function b$(e){return typeof e==\"number\"||typeof e==\"boolean\"||e===null?e:Yr(Array.isArray(e)?e.join(\",\"):e)}function v$(e){return new Ye(Yr(e))}U_.stringify=v$;function Yr(e){return JSON.stringify(e).replace(/\\u2028/g,\"\\\\u2028\").replace(/\\u2029/g,\"\\\\u2029\")}U_.safeStringify=Yr;function _$(e){return typeof e==\"string\"&&U_.IDENTIFIER.test(e)?new Ye(`.${e}`):N_`[${e}]`}U_.getProperty=_$;function w$(e){if(typeof e==\"string\"&&U_.IDENTIFIER.test(e))return new Ye(`${e}`);throw Error(`CodeGen: invalid export name: ${e}, use explicit $id name mapping`)}U_.getEsmExportName=w$;function x$(e){return new Ye(e.toString())}U_.regexpCode=x$});var ul=g(function(V_){Object.defineProperty(V_,\"__esModule\",{value:!0});V_.ValueScope=V_.ValueScopeName=V_.Scope=V_.varKinds=V_.UsedValueState=void 0;var Q=Xr();class G_ extends Error{constructor(e){super(`CodeGen: \"code\" for ${e} not defined`);this.value=e.value}}var Is;(function(e){e[e.Started=0]=\"Started\",e[e.Completed=1]=\"Completed\"})(Is||(V_.UsedValueState=Is={}));V_.varKinds={const:new Q.Name(\"const\"),let:new Q.Name(\"let\"),var:new Q.Name(\"var\")};class cl{constructor({prefixes:e,parent:t}={}){this._names={},this._prefixes=e,this._parent=t}toName(e){return e instanceof Q.Name?e:this.name(e)}name(e){return new Q.Name(this._newName(e))}_newName(e){let t=this._names[e]||this._nameGroup(e);return`${e}${t.index++}`}_nameGroup(e){var t,n;if(((n=(t=this._parent)===null||t===void 0?void 0:t._prefixes)===null||n===void 0?void 0:n.has(e))||this._prefixes&&!this._prefixes.has(e))throw Error(`CodeGen: prefix \"${e}\" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}}V_.Scope=cl;class ll extends Q.Name{constructor(e,t){super(t);this.prefix=e}setValue(e,{property:t,itemIndex:n}){this.value=e,this.scopePath=Q._`.${new Q.Name(t)}[${n}]`}}V_.ValueScopeName=ll;var q$=Q._`\\n`;class B_ extends cl{constructor(e){super(e);this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?q$:Q.nil}}get(){return this._scope}name(e){return new ll(e,this._newName(e))}value(e,t){var n;if(t.ref===void 0)throw Error(\"CodeGen: ref must be passed in value\");let r=this.toName(e),{prefix:o}=r,s=(n=t.key)!==null&&n!==void 0?n:t.ref,i=this._values[o];if(i){let l=i.get(s);if(l)return l}else i=this._values[o]=new Map;i.set(s,r);let a=this._scope[o]||(this._scope[o]=[]),c=a.length;return a[c]=t.ref,r.setValue(t,{property:o,itemIndex:c}),r}getValue(e,t){let n=this._values[e];if(!n)return;return n.get(t)}scopeRefs(e,t=this._values){return this._reduceValues(t,(n)=>{if(n.scopePath===void 0)throw Error(`CodeGen: name \"${n}\" has no value`);return Q._`${e}${n.scopePath}`})}scopeCode(e=this._values,t,n){return this._reduceValues(e,(r)=>{if(r.value===void 0)throw Error(`CodeGen: name \"${r}\" has no value`);return r.value.code},t,n)}_reduceValues(e,t,n={},r){let o=Q.nil;for(let s in e){let i=e[s];if(!i)continue;let a=n[s]=n[s]||new Map;i.forEach((c)=>{if(a.has(c))return;a.set(c,Is.Started);let l=t(c);if(l){let u=this.opts.es5?V_.varKinds.var:V_.varKinds.const;o=Q._`${o}${u} ${c} = ${l};${this.opts._n}`}else if(l=r===null||r===void 0?void 0:r(c))o=Q._`${o}${l}${this.opts._n}`;else throw new G_(c);a.set(c,Is.Completed)})}return o}}V_.ValueScope=B_});var N=g(function(Ce){Object.defineProperty(Ce,\"__esModule\",{value:!0});Ce.or=Ce.and=Ce.not=Ce.CodeGen=Ce.operators=Ce.varKinds=Ce.ValueScopeName=Ce.ValueScope=Ce.Scope=Ce.Name=Ce.regexpCode=Ce.stringify=Ce.getProperty=Ce.nil=Ce.strConcat=Ce.str=Ce._=void 0;var k=Xr(),ue=ul(),jt=Xr();Object.defineProperty(Ce,\"_\",{enumerable:!0,get:function(){return jt._}});Object.defineProperty(Ce,\"str\",{enumerable:!0,get:function(){return jt.str}});Object.defineProperty(Ce,\"strConcat\",{enumerable:!0,get:function(){return jt.strConcat}});Object.defineProperty(Ce,\"nil\",{enumerable:!0,get:function(){return jt.nil}});Object.defineProperty(Ce,\"getProperty\",{enumerable:!0,get:function(){return jt.getProperty}});Object.defineProperty(Ce,\"stringify\",{enumerable:!0,get:function(){return jt.stringify}});Object.defineProperty(Ce,\"regexpCode\",{enumerable:!0,get:function(){return jt.regexpCode}});Object.defineProperty(Ce,\"Name\",{enumerable:!0,get:function(){return jt.Name}});var Es=ul();Object.defineProperty(Ce,\"Scope\",{enumerable:!0,get:function(){return Es.Scope}});Object.defineProperty(Ce,\"ValueScope\",{enumerable:!0,get:function(){return Es.ValueScope}});Object.defineProperty(Ce,\"ValueScopeName\",{enumerable:!0,get:function(){return Es.ValueScopeName}});Object.defineProperty(Ce,\"varKinds\",{enumerable:!0,get:function(){return Es.varKinds}});Ce.operators={GT:new k._Code(\">\"),GTE:new k._Code(\">=\"),LT:new k._Code(\"<\"),LTE:new k._Code(\"<=\"),EQ:new k._Code(\"===\"),NEQ:new k._Code(\"!==\"),NOT:new k._Code(\"!\"),OR:new k._Code(\"||\"),AND:new k._Code(\"&&\"),ADD:new k._Code(\"+\")};class Nt{optimizeNodes(){return this}optimizeNames(e,t){return this}}class J_ extends Nt{constructor(e,t,n){super();this.varKind=e,this.name=t,this.rhs=n}render({es5:e,_n:t}){let n=e?ue.varKinds.var:this.varKind,r=this.rhs===void 0?\"\":` = ${this.rhs}`;return`${n} ${this.name}${r};`+t}optimizeNames(e,t){if(!e[this.name.str])return;if(this.rhs)this.rhs=tr(this.rhs,e,t);return this}get names(){return this.rhs instanceof k._CodeOrName?this.rhs.names:{}}}class ml extends Nt{constructor(e,t,n){super();this.lhs=e,this.rhs=t,this.sideEffects=n}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,t){if(this.lhs instanceof k.Name&&!e[this.lhs.str]&&!this.sideEffects)return;return this.rhs=tr(this.rhs,e,t),this}get names(){let e=this.lhs instanceof k.Name?{}:{...this.lhs.names};return Cs(e,this.rhs)}}class W_ extends ml{constructor(e,t,n,r){super(e,n,r);this.op=t}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}}class K_ extends Nt{constructor(e){super();this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}}class H_ extends Nt{constructor(e){super();this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:\"\"};`+e}}class Z_ extends Nt{constructor(e){super();this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}}class Y_ extends Nt{constructor(e){super();this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,t){return this.code=tr(this.code,e,t),this}get names(){return this.code instanceof k._CodeOrName?this.code.names:{}}}class Ps extends Nt{constructor(e=[]){super();this.nodes=e}render(e){return this.nodes.reduce((t,n)=>t+n.render(e),\"\")}optimizeNodes(){let{nodes:e}=this,t=e.length;while(t--){let n=e[t].optimizeNodes();if(Array.isArray(n))e.splice(t,1,...n);else if(n)e[t]=n;else e.splice(t,1)}return e.length>0?this:void 0}optimizeNames(e,t){let{nodes:n}=this,r=n.length;while(r--){let o=n[r];if(o.optimizeNames(e,t))continue;D$(e,o.names),n.splice(r,1)}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,t)=>wn(e,t.names),{})}}class Dt extends Ps{render(e){return\"{\"+e._n+super.render(e)+\"}\"+e._n}}class X_ extends Ps{}class Qr extends Dt{}Qr.kind=\"else\";class xt extends Dt{constructor(e,t){super(t);this.condition=e}render(e){let t=`if(${this.condition})`+super.render(e);if(this.else)t+=\"else \"+this.else.render(e);return t}optimizeNodes(){super.optimizeNodes();let e=this.condition;if(e===!0)return this.nodes;let t=this.else;if(t){let n=t.optimizeNodes();t=this.else=Array.isArray(n)?new Qr(n):n}if(t){if(e===!1)return t instanceof xt?t:t.nodes;if(this.nodes.length)return this;return new xt(rw(e),t instanceof xt?[t]:t.nodes)}if(e===!1||!this.nodes.length)return;return this}optimizeNames(e,t){var n;if(this.else=(n=this.else)===null||n===void 0?void 0:n.optimizeNames(e,t),!(super.optimizeNames(e,t)||this.else))return;return this.condition=tr(this.condition,e,t),this}get names(){let e=super.names;if(Cs(e,this.condition),this.else)wn(e,this.else.names);return e}}xt.kind=\"if\";class er extends Dt{}er.kind=\"for\";class Q_ extends er{constructor(e){super();this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,t){if(!super.optimizeNames(e,t))return;return this.iteration=tr(this.iteration,e,t),this}get names(){return wn(super.names,this.iteration.names)}}class ew extends er{constructor(e,t,n,r){super();this.varKind=e,this.name=t,this.from=n,this.to=r}render(e){let t=e.es5?ue.varKinds.var:this.varKind,{name:n,from:r,to:o}=this;return`for(${t} ${n}=${r}; ${n}<${o}; ${n}++)`+super.render(e)}get names(){let e=Cs(super.names,this.from);return Cs(e,this.to)}}class dl extends er{constructor(e,t,n,r){super();this.loop=e,this.varKind=t,this.name=n,this.iterable=r}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,t){if(!super.optimizeNames(e,t))return;return this.iterable=tr(this.iterable,e,t),this}get names(){return wn(super.names,this.iterable.names)}}class ks extends Dt{constructor(e,t,n){super();this.name=e,this.args=t,this.async=n}render(e){return`${this.async?\"async \":\"\"}function ${this.name}(${this.args})`+super.render(e)}}ks.kind=\"func\";class Rs extends Ps{render(e){return\"return \"+super.render(e)}}Rs.kind=\"return\";class tw extends Dt{render(e){let t=\"try\"+super.render(e);if(this.catch)t+=this.catch.render(e);if(this.finally)t+=this.finally.render(e);return t}optimizeNodes(){var e,t;return super.optimizeNodes(),(e=this.catch)===null||e===void 0||e.optimizeNodes(),(t=this.finally)===null||t===void 0||t.optimizeNodes(),this}optimizeNames(e,t){var n,r;return super.optimizeNames(e,t),(n=this.catch)===null||n===void 0||n.optimizeNames(e,t),(r=this.finally)===null||r===void 0||r.optimizeNames(e,t),this}get names(){let e=super.names;if(this.catch)wn(e,this.catch.names);if(this.finally)wn(e,this.finally.names);return e}}class Ts extends Dt{constructor(e){super();this.error=e}render(e){return`catch(${this.error})`+super.render(e)}}Ts.kind=\"catch\";class As extends Dt{render(e){return\"finally\"+super.render(e)}}As.kind=\"finally\";class nw{constructor(e,t={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...t,_n:t.lines?`\n`:\"\"},this._extScope=e,this._scope=new ue.Scope({parent:e}),this._nodes=[new X_]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,t){let n=this._extScope.value(e,t);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(e,t){return this._extScope.getValue(e,t)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,t,n,r){let o=this._scope.toName(t);if(n!==void 0&&r)this._constants[o.str]=n;return this._leafNode(new J_(e,o,n)),o}const(e,t,n){return this._def(ue.varKinds.const,e,t,n)}let(e,t,n){return this._def(ue.varKinds.let,e,t,n)}var(e,t,n){return this._def(ue.varKinds.var,e,t,n)}assign(e,t,n){return this._leafNode(new ml(e,t,n))}add(e,t){return this._leafNode(new W_(e,Ce.operators.ADD,t))}code(e){if(typeof e==\"function\")e();else if(e!==k.nil)this._leafNode(new Y_(e));return this}object(...e){let t=[\"{\"];for(let[n,r]of e){if(t.length>1)t.push(\",\");if(t.push(n),n!==r||this.opts.es5)t.push(\":\"),k.addCodeArg(t,r)}return t.push(\"}\"),new k._Code(t)}if(e,t,n){if(this._blockNode(new xt(e)),t&&n)this.code(t).else().code(n).endIf();else if(t)this.code(t).endIf();else if(n)throw Error('CodeGen: \"else\" body without \"then\" body');return this}elseIf(e){return this._elseNode(new xt(e))}else(){return this._elseNode(new Qr)}endIf(){return this._endBlockNode(xt,Qr)}_for(e,t){if(this._blockNode(e),t)this.code(t).endFor();return this}for(e,t){return this._for(new Q_(e),t)}forRange(e,t,n,r,o=this.opts.es5?ue.varKinds.var:ue.varKinds.let){let s=this._scope.toName(e);return this._for(new ew(o,s,t,n),()=>r(s))}forOf(e,t,n,r=ue.varKinds.const){let o=this._scope.toName(e);if(this.opts.es5){let s=t instanceof k.Name?t:this.var(\"_arr\",t);return this.forRange(\"_i\",0,k._`${s}.length`,(i)=>{this.var(o,k._`${s}[${i}]`),n(o)})}return this._for(new dl(\"of\",r,o,t),()=>n(o))}forIn(e,t,n,r=this.opts.es5?ue.varKinds.var:ue.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,k._`Object.keys(${t})`,n);let o=this._scope.toName(e);return this._for(new dl(\"in\",r,o,t),()=>n(o))}endFor(){return this._endBlockNode(er)}label(e){return this._leafNode(new K_(e))}break(e){return this._leafNode(new H_(e))}return(e){let t=new Rs;if(this._blockNode(t),this.code(e),t.nodes.length!==1)throw Error('CodeGen: \"return\" should have one node');return this._endBlockNode(Rs)}try(e,t,n){if(!t&&!n)throw Error('CodeGen: \"try\" without \"catch\" and \"finally\"');let r=new tw;if(this._blockNode(r),this.code(e),t){let o=this.name(\"e\");this._currNode=r.catch=new Ts(o),t(o)}if(n)this._currNode=r.finally=new As,this.code(n);return this._endBlockNode(Ts,As)}throw(e){return this._leafNode(new Z_(e))}block(e,t){if(this._blockStarts.push(this._nodes.length),e)this.code(e).endBlock(t);return this}endBlock(e){let t=this._blockStarts.pop();if(t===void 0)throw Error(\"CodeGen: not in self-balancing block\");let n=this._nodes.length-t;if(n<0||e!==void 0&&n!==e)throw Error(`CodeGen: wrong number of nodes: ${n} vs ${e} expected`);return this._nodes.length=t,this}func(e,t=k.nil,n,r){if(this._blockNode(new ks(e,t,n)),r)this.code(r).endFunc();return this}endFunc(){return this._endBlockNode(ks)}optimize(e=1){while(e-- >0)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(e){return this._currNode.nodes.push(e),this}_blockNode(e){this._currNode.nodes.push(e),this._nodes.push(e)}_endBlockNode(e,t){let n=this._currNode;if(n instanceof e||t&&n instanceof t)return this._nodes.pop(),this;throw Error(`CodeGen: not in block \"${t?`${e.kind}/${t.kind}`:e.kind}\"`)}_elseNode(e){let t=this._currNode;if(!(t instanceof xt))throw Error('CodeGen: \"else\" without \"if\"');return this._currNode=t.else=e,this}get _root(){return this._nodes[0]}get _currNode(){let e=this._nodes;return e[e.length-1]}set _currNode(e){let t=this._nodes;t[t.length-1]=e}}Ce.CodeGen=nw;function wn(e,t){for(let n in t)e[n]=(e[n]||0)+(t[n]||0);return e}function Cs(e,t){return t instanceof k._CodeOrName?wn(e,t.names):e}function tr(e,t,n){if(e instanceof k.Name)return r(e);if(!o(e))return e;return new k._Code(e._items.reduce((s,i)=>{if(i instanceof k.Name)i=r(i);if(i instanceof k._Code)s.push(...i._items);else s.push(i);return s},[]));function r(s){let i=n[s.str];if(i===void 0||t[s.str]!==1)return s;return delete t[s.str],i}function o(s){return s instanceof k._Code&&s._items.some((i)=>i instanceof k.Name&&t[i.str]===1&&n[i.str]!==void 0)}}function D$(e,t){for(let n in t)e[n]=(e[n]||0)-(t[n]||0)}function rw(e){return typeof e==\"boolean\"||typeof e==\"number\"||e===null?!e:k._`!${pl(e)}`}Ce.not=rw;var U$=ow(Ce.operators.AND);function L$(...e){return e.reduce(U$)}Ce.and=L$;var G$=ow(Ce.operators.OR);function B$(...e){return e.reduce(G$)}Ce.or=B$;function ow(e){return(t,n)=>t===k.nil?n:n===k.nil?t:k._`${pl(t)} ${e} ${pl(n)}`}function pl(e){return e instanceof k.Name?e:k._`(${e})`}});var B=g(function(fw){Object.defineProperty(fw,\"__esModule\",{value:!0});fw.checkStrictMode=fw.getErrorPath=fw.Type=fw.useFunc=fw.setEvaluated=fw.evaluatedPropsToName=fw.mergeEvaluated=fw.eachItem=fw.unescapeJsonPointer=fw.escapeJsonPointer=fw.escapeFragment=fw.unescapeFragment=fw.schemaRefOrVal=fw.schemaHasRulesButRef=fw.schemaHasRules=fw.checkUnknownRules=fw.alwaysValidSchema=fw.toHash=void 0;var M=N(),cw=Xr();function W$(e){let t={};for(let n of e)t[n]=!0;return t}fw.toHash=W$;function K$(e,t){if(typeof t==\"boolean\")return t;if(Object.keys(t).length===0)return!0;return lw(e,t),!uw(t,e.self.RULES.all)}fw.alwaysValidSchema=K$;function lw(e,t=e.schema){let{opts:n,self:r}=e;if(!n.strictSchema)return;if(typeof t===\"boolean\")return;let o=r.RULES.keywords;for(let s in t)if(!o[s])mw(e,`unknown keyword: \"${s}\"`)}fw.checkUnknownRules=lw;function uw(e,t){if(typeof e==\"boolean\")return!e;for(let n in e)if(t[n])return!0;return!1}fw.schemaHasRules=uw;function H$(e,t){if(typeof e==\"boolean\")return!e;for(let n in e)if(n!==\"$ref\"&&t.all[n])return!0;return!1}fw.schemaHasRulesButRef=H$;function Z$({topSchemaRef:e,schemaPath:t},n,r,o){if(!o){if(typeof n==\"number\"||typeof n==\"boolean\")return n;if(typeof n==\"string\")return M._`${n}`}return M._`${e}${t}${M.getProperty(r)}`}fw.schemaRefOrVal=Z$;function Y$(e){return dw(decodeURIComponent(e))}fw.unescapeFragment=Y$;function X$(e){return encodeURIComponent(gl(e))}fw.escapeFragment=X$;function gl(e){if(typeof e==\"number\")return`${e}`;return e.replace(/~/g,\"~0\").replace(/\\//g,\"~1\")}fw.escapeJsonPointer=gl;function dw(e){return e.replace(/~1/g,\"/\").replace(/~0/g,\"~\")}fw.unescapeJsonPointer=dw;function Q$(e,t){if(Array.isArray(e))for(let n of e)t(n);else t(e)}fw.eachItem=Q$;function iw({mergeNames:e,mergeToName:t,mergeValues:n,resultToName:r}){return(o,s,i,a)=>{let c=i===void 0?s:i instanceof M.Name?(s instanceof M.Name?e(o,s,i):t(o,s,i),i):s instanceof M.Name?(t(o,i,s),s):n(s,i);return a===M.Name&&!(c instanceof M.Name)?r(o,c):c}}fw.mergeEvaluated={props:iw({mergeNames:(e,t,n)=>e.if(M._`${n} !== true && ${t} !== undefined`,()=>{e.if(M._`${t} === true`,()=>e.assign(n,!0),()=>e.assign(n,M._`${n} || {}`).code(M._`Object.assign(${n}, ${t})`))}),mergeToName:(e,t,n)=>e.if(M._`${n} !== true`,()=>{if(t===!0)e.assign(n,!0);else e.assign(n,M._`${n} || {}`),hl(e,n,t)}),mergeValues:(e,t)=>e===!0?!0:{...e,...t},resultToName:pw}),items:iw({mergeNames:(e,t,n)=>e.if(M._`${n} !== true && ${t} !== undefined`,()=>e.assign(n,M._`${t} === true ? true : ${n} > ${t} ? ${n} : ${t}`)),mergeToName:(e,t,n)=>e.if(M._`${n} !== true`,()=>e.assign(n,t===!0?!0:M._`${n} > ${t} ? ${n} : ${t}`)),mergeValues:(e,t)=>e===!0?!0:Math.max(e,t),resultToName:(e,t)=>e.var(\"items\",t)})};function pw(e,t){if(t===!0)return e.var(\"props\",!0);let n=e.var(\"props\",M._`{}`);if(t!==void 0)hl(e,n,t);return n}fw.evaluatedPropsToName=pw;function hl(e,t,n){Object.keys(n).forEach((r)=>e.assign(M._`${t}${M.getProperty(r)}`,!0))}fw.setEvaluated=hl;var aw={};function e1(e,t){return e.scopeValue(\"func\",{ref:t,code:aw[t.code]||(aw[t.code]=new cw._Code(t.code))})}fw.useFunc=e1;var fl;(function(e){e[e.Num=0]=\"Num\",e[e.Str=1]=\"Str\"})(fl||(fw.Type=fl={}));function t1(e,t,n){if(e instanceof M.Name){let r=t===fl.Num;return n?r?M._`\"[\" + ${e} + \"]\"`:M._`\"['\" + ${e} + \"']\"`:r?M._`\"/\" + ${e}`:M._`\"/\" + ${e}.replace(/~/g, \"~0\").replace(/\\\\//g, \"~1\")`}return n?M.getProperty(e).toString():\"/\"+gl(e)}fw.getErrorPath=t1;function mw(e,t,n=e.opts.strictSchema){if(!n)return;if(t=`strict mode: ${t}`,n===!0)throw Error(t);e.self.logger.warn(t)}fw.checkStrictMode=mw});var Le=g(function(hw){Object.defineProperty(hw,\"__esModule\",{value:!0});var Z=N(),v1={data:new Z.Name(\"data\"),valCxt:new Z.Name(\"valCxt\"),instancePath:new Z.Name(\"instancePath\"),parentData:new Z.Name(\"parentData\"),parentDataProperty:new Z.Name(\"parentDataProperty\"),rootData:new Z.Name(\"rootData\"),dynamicAnchors:new Z.Name(\"dynamicAnchors\"),vErrors:new Z.Name(\"vErrors\"),errors:new Z.Name(\"errors\"),this:new Z.Name(\"this\"),self:new Z.Name(\"self\"),scope:new Z.Name(\"scope\"),json:new Z.Name(\"json\"),jsonPos:new Z.Name(\"jsonPos\"),jsonLen:new Z.Name(\"jsonLen\"),jsonPart:new Z.Name(\"jsonPart\")};hw.default=v1});var eo=g(function(_w){Object.defineProperty(_w,\"__esModule\",{value:!0});_w.extendErrors=_w.resetErrorsCount=_w.reportExtraError=_w.reportError=_w.keyword$DataError=_w.keywordError=void 0;var R=N(),Ut=B(),Re=Le();_w.keywordError={message:({keyword:e})=>R.str`must pass \"${e}\" keyword validation`};_w.keyword$DataError={message:({keyword:e,schemaType:t})=>t?R.str`\"${e}\" keyword must be ${t} ($data)`:R.str`\"${e}\" keyword is invalid ($data)`};function w1(e,t=_w.keywordError,n,r){let{it:o}=e,{gen:s,compositeRule:i,allErrors:a}=o,c=vw(e,t,n);if(r!==null&&r!==void 0?r:i||a)yw(s,c);else bw(o,R._`[${c}]`)}_w.reportError=w1;function x1(e,t=_w.keywordError,n){let{it:r}=e,{gen:o,compositeRule:s,allErrors:i}=r,a=vw(e,t,n);if(yw(o,a),!(s||i))bw(r,Re.default.vErrors)}_w.reportExtraError=x1;function S1(e,t){e.assign(Re.default.errors,t),e.if(R._`${Re.default.vErrors} !== null`,()=>e.if(t,()=>e.assign(R._`${Re.default.vErrors}.length`,t),()=>e.assign(Re.default.vErrors,null)))}_w.resetErrorsCount=S1;function I1({gen:e,keyword:t,schemaValue:n,data:r,errsCount:o,it:s}){if(o===void 0)throw Error(\"ajv implementation error\");let i=e.name(\"err\");e.forRange(\"i\",o,Re.default.errors,(a)=>{if(e.const(i,R._`${Re.default.vErrors}[${a}]`),e.if(R._`${i}.instancePath === undefined`,()=>e.assign(R._`${i}.instancePath`,R.strConcat(Re.default.instancePath,s.errorPath))),e.assign(R._`${i}.schemaPath`,R.str`${s.errSchemaPath}/${t}`),s.opts.verbose)e.assign(R._`${i}.schema`,n),e.assign(R._`${i}.data`,r)})}_w.extendErrors=I1;function yw(e,t){let n=e.const(\"err\",t);e.if(R._`${Re.default.vErrors} === null`,()=>e.assign(Re.default.vErrors,R._`[${n}]`),R._`${Re.default.vErrors}.push(${n})`),e.code(R._`${Re.default.errors}++`)}function bw(e,t){let{gen:n,validateName:r,schemaEnv:o}=e;if(o.$async)n.throw(R._`new ${e.ValidationError}(${t})`);else n.assign(R._`${r}.errors`,t),n.return(!1)}var xn={keyword:new R.Name(\"keyword\"),schemaPath:new R.Name(\"schemaPath\"),params:new R.Name(\"params\"),propertyName:new R.Name(\"propertyName\"),message:new R.Name(\"message\"),schema:new R.Name(\"schema\"),parentSchema:new R.Name(\"parentSchema\")};function vw(e,t,n){let{createErrors:r}=e.it;if(r===!1)return R._`{}`;return k1(e,t,n)}function k1(e,t,n={}){let{gen:r,it:o}=e,s=[R1(o,n),T1(e,n)];return A1(e,t,s),r.object(...s)}function R1({errorPath:e},{instancePath:t}){let n=t?R.str`${e}${Ut.getErrorPath(t,Ut.Type.Str)}`:e;return[Re.default.instancePath,R.strConcat(Re.default.instancePath,n)]}function T1({keyword:e,it:{errSchemaPath:t}},{schemaPath:n,parentSchema:r}){let o=r?t:R.str`${t}/${e}`;if(n)o=R.str`${o}${Ut.getErrorPath(n,Ut.Type.Str)}`;return[xn.schemaPath,o]}function A1(e,{params:t,message:n},r){let{keyword:o,data:s,schemaValue:i,it:a}=e,{opts:c,propertyName:l,topSchemaRef:u,schemaPath:p}=a;if(r.push([xn.keyword,o],[xn.params,typeof t==\"function\"?t(e):t||R._`{}`]),c.messages)r.push([xn.message,typeof n==\"function\"?n(e):n]);if(c.verbose)r.push([xn.schema,i],[xn.parentSchema,R._`${u}${p}`],[Re.default.data,s]);if(l)r.push([xn.propertyName,l])}});var Tw=g(function(kw){Object.defineProperty(kw,\"__esModule\",{value:!0});kw.boolOrEmptySchema=kw.topBoolOrEmptySchema=void 0;var xw=eo(),Sw=N(),$1=Le(),M1={message:\"boolean schema is false\"};function q1(e){let{gen:t,schema:n,validateName:r}=e;if(n===!1)Iw(e,!1);else if(typeof n==\"object\"&&n.$async===!0)t.return($1.default.data);else t.assign(Sw._`${r}.errors`,null),t.return(!0)}kw.topBoolOrEmptySchema=q1;function z1(e,t){let{gen:n,schema:r}=e;if(r===!1)n.var(t,!1),Iw(e);else n.var(t,!0)}kw.boolOrEmptySchema=z1;function Iw(e,t){let{gen:n,data:r}=e;xw.reportError({gen:n,keyword:\"false schema\",data:r,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:e},M1,void 0,t)}});var bl=g(function(Aw){Object.defineProperty(Aw,\"__esModule\",{value:!0});Aw.getRules=Aw.isJSONType=void 0;var N1=[\"string\",\"number\",\"integer\",\"boolean\",\"null\",\"object\",\"array\"],D1=new Set(N1);function U1(e){return typeof e==\"string\"&&D1.has(e)}Aw.isJSONType=U1;function L1(){let e={number:{type:\"number\",rules:[]},string:{type:\"string\",rules:[]},array:{type:\"array\",rules:[]},object:{type:\"object\",rules:[]}};return{types:{...e,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},e.number,e.string,e.array,e.object],post:{rules:[]},all:{},keywords:{}}}Aw.getRules=L1});var vl=g(function(Ow){Object.defineProperty(Ow,\"__esModule\",{value:!0});Ow.shouldUseRule=Ow.shouldUseGroup=Ow.schemaHasRulesForType=void 0;function B1({schema:e,self:t},n){let r=t.RULES.types[n];return r&&r!==!0&&Ew(e,r)}Ow.schemaHasRulesForType=B1;function Ew(e,t){return t.rules.some((n)=>Pw(e,n))}Ow.shouldUseGroup=Ew;function Pw(e,t){var n;return e[t.keyword]!==void 0||((n=t.definition.implements)===null||n===void 0?void 0:n.some((r)=>e[r]!==void 0))}Ow.shouldUseRule=Pw});var to=g(function(Dw){Object.defineProperty(Dw,\"__esModule\",{value:!0});Dw.reportTypeError=Dw.checkDataTypes=Dw.checkDataType=Dw.coerceAndCheckDataType=Dw.getJSONTypes=Dw.getSchemaTypes=Dw.DataType=void 0;var Mw=bl(),qw=vl(),zw=eo(),S=N(),$s=B(),nr;(function(e){e[e.Correct=0]=\"Correct\",e[e.Wrong=1]=\"Wrong\"})(nr||(Dw.DataType=nr={}));function J1(e){let t=jw(e.type);if(t.includes(\"null\")){if(e.nullable===!1)throw Error(\"type: null contradicts nullable: false\")}else{if(!t.length&&e.nullable!==void 0)throw Error('\"nullable\" cannot be used without \"type\"');if(e.nullable===!0)t.push(\"null\")}return t}Dw.getSchemaTypes=J1;function jw(e){let t=Array.isArray(e)?e:e?[e]:[];if(t.every(Mw.isJSONType))return t;throw Error(\"type must be JSONType or JSONType[]: \"+t.join(\",\"))}Dw.getJSONTypes=jw;function W1(e,t){let{gen:n,data:r,opts:o}=e,s=K1(t,o.coerceTypes),i=t.length>0&&!(s.length===0&&t.length===1&&qw.schemaHasRulesForType(e,t[0]));if(i){let a=wl(t,r,o.strictNumbers,nr.Wrong);n.if(a,()=>{if(s.length)H1(e,t,s);else xl(e)})}return i}Dw.coerceAndCheckDataType=W1;var Nw=new Set([\"string\",\"number\",\"integer\",\"boolean\",\"null\"]);function K1(e,t){return t?e.filter((n)=>Nw.has(n)||t===\"array\"&&n===\"array\"):[]}function H1(e,t,n){let{gen:r,data:o,opts:s}=e,i=r.let(\"dataType\",S._`typeof ${o}`),a=r.let(\"coerced\",S._`undefined`);if(s.coerceTypes===\"array\")r.if(S._`${i} == 'object' && Array.isArray(${o}) && ${o}.length == 1`,()=>r.assign(o,S._`${o}[0]`).assign(i,S._`typeof ${o}`).if(wl(t,o,s.strictNumbers),()=>r.assign(a,o)));r.if(S._`${a} !== undefined`);for(let l of n)if(Nw.has(l)||l===\"array\"&&s.coerceTypes===\"array\")c(l);r.else(),xl(e),r.endIf(),r.if(S._`${a} !== undefined`,()=>{r.assign(o,a),Z1(e,a)});function c(l){switch(l){case\"string\":r.elseIf(S._`${i} == \"number\" || ${i} == \"boolean\"`).assign(a,S._`\"\" + ${o}`).elseIf(S._`${o} === null`).assign(a,S._`\"\"`);return;case\"number\":r.elseIf(S._`${i} == \"boolean\" || ${o} === null\n || (${i} == \"string\" && ${o} && ${o} == +${o})`).assign(a,S._`+${o}`);return;case\"integer\":r.elseIf(S._`${i} === \"boolean\" || ${o} === null\n || (${i} === \"string\" && ${o} && ${o} == +${o} && !(${o} % 1))`).assign(a,S._`+${o}`);return;case\"boolean\":r.elseIf(S._`${o} === \"false\" || ${o} === 0 || ${o} === null`).assign(a,!1).elseIf(S._`${o} === \"true\" || ${o} === 1`).assign(a,!0);return;case\"null\":r.elseIf(S._`${o} === \"\" || ${o} === 0 || ${o} === false`),r.assign(a,null);return;case\"array\":r.elseIf(S._`${i} === \"string\" || ${i} === \"number\"\n || ${i} === \"boolean\" || ${o} === null`).assign(a,S._`[${o}]`)}}}function Z1({gen:e,parentData:t,parentDataProperty:n},r){e.if(S._`${t} !== undefined`,()=>e.assign(S._`${t}[${n}]`,r))}function _l(e,t,n,r=nr.Correct){let o=r===nr.Correct?S.operators.EQ:S.operators.NEQ,s;switch(e){case\"null\":return S._`${t} ${o} null`;case\"array\":s=S._`Array.isArray(${t})`;break;case\"object\":s=S._`${t} && typeof ${t} == \"object\" && !Array.isArray(${t})`;break;case\"integer\":s=i(S._`!(${t} % 1) && !isNaN(${t})`);break;case\"number\":s=i();break;default:return S._`typeof ${t} ${o} ${e}`}return r===nr.Correct?s:S.not(s);function i(a=S.nil){return S.and(S._`typeof ${t} == \"number\"`,a,n?S._`isFinite(${t})`:S.nil)}}Dw.checkDataType=_l;function wl(e,t,n,r){if(e.length===1)return _l(e[0],t,n,r);let o,s=$s.toHash(e);if(s.array&&s.object){let i=S._`typeof ${t} != \"object\"`;o=s.null?i:S._`!${t} || ${i}`,delete s.null,delete s.array,delete s.object}else o=S.nil;if(s.number)delete s.integer;for(let i in s)o=S.and(o,_l(i,t,n,r));return o}Dw.checkDataTypes=wl;var Y1={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>typeof e==\"string\"?S._`{type: ${e}}`:S._`{type: ${t}}`};function xl(e){let t=X1(e);zw.reportError(t,Y1)}Dw.reportTypeError=xl;function X1(e){let{gen:t,data:n,schema:r}=e,o=$s.schemaRefOrVal(e,r,\"type\");return{gen:t,keyword:\"type\",data:n,schema:r.type,schemaCode:o,schemaValue:o,parentSchema:r,params:{},it:e}}});var Fw=g(function(Bw){Object.defineProperty(Bw,\"__esModule\",{value:!0});Bw.assignDefaults=void 0;var Ge=N(),Gw=B();function sM(e,t){let{properties:n,items:r}=e.schema;if(t===\"object\"&&n)for(let o in n)Lw(e,o,n[o].default);else if(t===\"array\"&&Array.isArray(r))r.forEach((o,s)=>Lw(e,s,o.default))}Bw.assignDefaults=sM;function Lw(e,t,n){let{gen:r,compositeRule:o,data:s,opts:i}=e;if(n===void 0)return;let a=Ge._`${s}${Ge.getProperty(t)}`;if(o){Gw.checkStrictMode(e,`default is ignored for: ${a}`);return}let c=Ge._`${a} === undefined`;if(i.useDefaults===\"empty\")c=Ge._`${c} || ${a} === null || ${a} === \"\"`;r.if(c,Ge._`${a} = ${Ge.stringify(n)}`)}});var Be=g(function(Hw){Object.defineProperty(Hw,\"__esModule\",{value:!0});Hw.validateUnion=Hw.validateArray=Hw.usePattern=Hw.callValidateCode=Hw.schemaProperties=Hw.allSchemaProperties=Hw.noPropertyInData=Hw.propertyInData=Hw.isOwnProperty=Hw.hasPropFunc=Hw.reportMissingProp=Hw.checkMissingProp=Hw.checkReportMissingProp=void 0;var q=N(),rr=B(),Lt=Le(),Jw=B();function iM(e,t){let{gen:n,data:r,it:o}=e;n.if(Il(n,r,t,o.opts.ownProperties),()=>{e.setParams({missingProperty:q._`${t}`},!0),e.error()})}Hw.checkReportMissingProp=iM;function aM({gen:e,data:t,it:{opts:n}},r,o){return q.or(...r.map((s)=>q.and(Il(e,t,s,n.ownProperties),q._`${o} = ${s}`)))}Hw.checkMissingProp=aM;function cM(e,t){e.setParams({missingProperty:t},!0),e.error()}Hw.reportMissingProp=cM;function Ww(e){return e.scopeValue(\"func\",{ref:Object.prototype.hasOwnProperty,code:q._`Object.prototype.hasOwnProperty`})}Hw.hasPropFunc=Ww;function Sl(e,t,n){return q._`${Ww(e)}.call(${t}, ${n})`}Hw.isOwnProperty=Sl;function lM(e,t,n,r){let o=q._`${t}${q.getProperty(n)} !== undefined`;return r?q._`${o} && ${Sl(e,t,n)}`:o}Hw.propertyInData=lM;function Il(e,t,n,r){let o=q._`${t}${q.getProperty(n)} === undefined`;return r?q.or(o,q.not(Sl(e,t,n))):o}Hw.noPropertyInData=Il;function Kw(e){return e?Object.keys(e).filter((t)=>t!==\"__proto__\"):[]}Hw.allSchemaProperties=Kw;function uM(e,t){return Kw(t).filter((n)=>!rr.alwaysValidSchema(e,t[n]))}Hw.schemaProperties=uM;function dM({schemaCode:e,data:t,it:{gen:n,topSchemaRef:r,schemaPath:o,errorPath:s},it:i},a,c,l){let u=l?q._`${e}, ${t}, ${r}${o}`:t,p=[[Lt.default.instancePath,q.strConcat(Lt.default.instancePath,s)],[Lt.default.parentData,i.parentData],[Lt.default.parentDataProperty,i.parentDataProperty],[Lt.default.rootData,Lt.default.rootData]];if(i.opts.dynamicRef)p.push([Lt.default.dynamicAnchors,Lt.default.dynamicAnchors]);let m=q._`${u}, ${n.object(...p)}`;return c!==q.nil?q._`${a}.call(${c}, ${m})`:q._`${a}(${m})`}Hw.callValidateCode=dM;var pM=q._`new RegExp`;function mM({gen:e,it:{opts:t}},n){let r=t.unicodeRegExp?\"u\":\"\",{regExp:o}=t.code,s=o(n,r);return e.scopeValue(\"pattern\",{key:s.toString(),ref:s,code:q._`${o.code===\"new RegExp\"?pM:Jw.useFunc(e,o)}(${n}, ${r})`})}Hw.usePattern=mM;function fM(e){let{gen:t,data:n,keyword:r,it:o}=e,s=t.name(\"valid\");if(o.allErrors){let a=t.let(\"valid\",!0);return i(()=>t.assign(a,!1)),a}return t.var(s,!0),i(()=>t.break()),s;function i(a){let c=t.const(\"len\",q._`${n}.length`);t.forRange(\"i\",0,c,(l)=>{e.subschema({keyword:r,dataProp:l,dataPropType:rr.Type.Num},s),t.if(q.not(s),a)})}}Hw.validateArray=fM;function gM(e){let{gen:t,schema:n,keyword:r,it:o}=e;if(!Array.isArray(n))throw Error(\"ajv implementation error\");if(n.some((c)=>rr.alwaysValidSchema(o,c))&&!o.opts.unevaluated)return;let i=t.let(\"valid\",!1),a=t.name(\"_valid\");t.block(()=>n.forEach((c,l)=>{let u=e.subschema({keyword:r,schemaProp:l,compositeRule:!0},a);if(t.assign(i,q._`${i} || ${a}`),!e.mergeValidEvaluated(u,a))t.if(q.not(i))})),e.result(i,()=>e.reset(),()=>e.error(!0))}Hw.validateUnion=gM});var rx=g(function(tx){Object.defineProperty(tx,\"__esModule\",{value:!0});tx.validateKeywordUsage=tx.validSchemaType=tx.funcKeywordCode=tx.macroKeywordCode=void 0;var Y=N(),Sn=Le(),Xw=Be(),Qw=eo();function AM(e,t){let{gen:n,keyword:r,schema:o,parentSchema:s,it:i}=e,a=t.macro.call(i.self,o,s,i),c=ex(n,r,a);if(i.opts.validateSchema!==!1)i.self.validateSchema(a,!0);let l=n.name(\"valid\");e.subschema({schema:a,schemaPath:Y.nil,errSchemaPath:`${i.errSchemaPath}/${r}`,topSchemaRef:c,compositeRule:!0},l),e.pass(l,()=>e.error(!0))}tx.macroKeywordCode=AM;function CM(e,t){var n;let{gen:r,keyword:o,schema:s,parentSchema:i,$data:a,it:c}=e;PM(c,t);let l=!a&&t.compile?t.compile.call(c.self,s,i,c):t.validate,u=ex(r,o,l),p=r.let(\"valid\");e.block$data(p,m),e.ok((n=t.valid)!==null&&n!==void 0?n:p);function m(){if(t.errors===!1){if(h(),t.modifying)Yw(e);y(()=>e.error())}else{let _=t.async?d():f();if(t.modifying)Yw(e);y(()=>EM(e,_))}}function d(){let _=r.let(\"ruleErrs\",null);return r.try(()=>h(Y._`await `),(E)=>r.assign(p,!1).if(Y._`${E} instanceof ${c.ValidationError}`,()=>r.assign(_,Y._`${E}.errors`),()=>r.throw(E))),_}function f(){let _=Y._`${u}.errors`;return r.assign(_,null),h(Y.nil),_}function h(_=t.async?Y._`await `:Y.nil){let E=c.opts.passContext?Sn.default.this:Sn.default.self,T=!((\"compile\"in t)&&!a||t.schema===!1);r.assign(p,Y._`${_}${Xw.callValidateCode(e,u,E,T)}`,t.modifying)}function y(_){var E;r.if(Y.not((E=t.valid)!==null&&E!==void 0?E:p),_)}}tx.funcKeywordCode=CM;function Yw(e){let{gen:t,data:n,it:r}=e;t.if(r.parentData,()=>t.assign(n,Y._`${r.parentData}[${r.parentDataProperty}]`))}function EM(e,t){let{gen:n}=e;n.if(Y._`Array.isArray(${t})`,()=>{n.assign(Sn.default.vErrors,Y._`${Sn.default.vErrors} === null ? ${t} : ${Sn.default.vErrors}.concat(${t})`).assign(Sn.default.errors,Y._`${Sn.default.vErrors}.length`),Qw.extendErrors(e)},()=>e.error())}function PM({schemaEnv:e},t){if(t.async&&!e.$async)throw Error(\"async keyword in sync schema\")}function ex(e,t,n){if(n===void 0)throw Error(`keyword \"${t}\" failed to compile`);return e.scopeValue(\"keyword\",typeof n==\"function\"?{ref:n}:{ref:n,code:Y.stringify(n)})}function OM(e,t,n=!1){return!t.length||t.some((r)=>r===\"array\"?Array.isArray(e):r===\"object\"?e&&typeof e==\"object\"&&!Array.isArray(e):typeof e==r||n&&typeof e>\"u\")}tx.validSchemaType=OM;function $M({schema:e,opts:t,self:n,errSchemaPath:r},o,s){if(Array.isArray(o.keyword)?!o.keyword.includes(s):o.keyword!==s)throw Error(\"ajv implementation error\");let i=o.dependencies;if(i===null||i===void 0?void 0:i.some((a)=>!Object.prototype.hasOwnProperty.call(e,a)))throw Error(`parent schema must have dependencies of ${s}: ${i.join(\",\")}`);if(o.validateSchema){if(!o.validateSchema(e[s])){let c=`keyword \"${s}\" value is invalid at path \"${r}\": `+n.errorsText(o.validateSchema.errors);if(t.validateSchema===\"log\")n.logger.error(c);else throw Error(c)}}}tx.validateKeywordUsage=$M});var ix=g(function(ox){Object.defineProperty(ox,\"__esModule\",{value:!0});ox.extendSubschemaMode=ox.extendSubschemaData=ox.getSubschema=void 0;var he=N(),Ms=B();function jM(e,{keyword:t,schemaProp:n,schema:r,schemaPath:o,errSchemaPath:s,topSchemaRef:i}){if(t!==void 0&&r!==void 0)throw Error('both \"keyword\" and \"schema\" passed, only one allowed');if(t!==void 0){let a=e.schema[t];return n===void 0?{schema:a,schemaPath:he._`${e.schemaPath}${he.getProperty(t)}`,errSchemaPath:`${e.errSchemaPath}/${t}`}:{schema:a[n],schemaPath:he._`${e.schemaPath}${he.getProperty(t)}${he.getProperty(n)}`,errSchemaPath:`${e.errSchemaPath}/${t}/${Ms.escapeFragment(n)}`}}if(r!==void 0){if(o===void 0||s===void 0||i===void 0)throw Error('\"schemaPath\", \"errSchemaPath\" and \"topSchemaRef\" are required with \"schema\"');return{schema:r,schemaPath:o,topSchemaRef:i,errSchemaPath:s}}throw Error('either \"keyword\" or \"schema\" must be passed')}ox.getSubschema=jM;function NM(e,t,{dataProp:n,dataPropType:r,data:o,dataTypes:s,propertyName:i}){if(o!==void 0&&n!==void 0)throw Error('both \"data\" and \"dataProp\" passed, only one allowed');let{gen:a}=t;if(n!==void 0){let{errorPath:l,dataPathArr:u,opts:p}=t,m=a.let(\"data\",he._`${t.data}${he.getProperty(n)}`,!0);c(m),e.errorPath=he.str`${l}${Ms.getErrorPath(n,r,p.jsPropertySyntax)}`,e.parentDataProperty=he._`${n}`,e.dataPathArr=[...u,e.parentDataProperty]}if(o!==void 0){let l=o instanceof he.Name?o:a.let(\"data\",o,!0);if(c(l),i!==void 0)e.propertyName=i}if(s)e.dataTypes=s;function c(l){e.data=l,e.dataLevel=t.dataLevel+1,e.dataTypes=[],t.definedProperties=new Set,e.parentData=t.data,e.dataNames=[...t.dataNames,l]}}ox.extendSubschemaData=NM;function DM(e,{jtdDiscriminator:t,jtdMetadata:n,compositeRule:r,createErrors:o,allErrors:s}){if(r!==void 0)e.compositeRule=r;if(o!==void 0)e.createErrors=o;if(s!==void 0)e.allErrors=s;e.jtdDiscriminator=t,e.jtdMetadata=n}ox.extendSubschemaMode=DM});var kl=g(function(iZ,ax){ax.exports=function e(t,n){if(t===n)return!0;if(t&&n&&typeof t==\"object\"&&typeof n==\"object\"){if(t.constructor!==n.constructor)return!1;var r,o,s;if(Array.isArray(t)){if(r=t.length,r!=n.length)return!1;for(o=r;o--!==0;)if(!e(t[o],n[o]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if(s=Object.keys(t),r=s.length,r!==Object.keys(n).length)return!1;for(o=r;o--!==0;)if(!Object.prototype.hasOwnProperty.call(n,s[o]))return!1;for(o=r;o--!==0;){var i=s[o];if(!e(t[i],n[i]))return!1}return!0}return t!==t&&n!==n}});var lx=g(function(aZ,cx){var Gt=cx.exports=function(e,t,n){if(typeof t==\"function\")n=t,t={};n=t.cb||n;var r=typeof n==\"function\"?n:n.pre||function(){},o=n.post||function(){};qs(t,r,o,e,\"\",e)};Gt.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};Gt.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};Gt.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};Gt.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};function qs(e,t,n,r,o,s,i,a,c,l){if(r&&typeof r==\"object\"&&!Array.isArray(r)){t(r,o,s,i,a,c,l);for(var u in r){var p=r[u];if(Array.isArray(p)){if(u in Gt.arrayKeywords)for(var m=0;m<p.length;m++)qs(e,t,n,p[m],o+\"/\"+u+\"/\"+m,s,o,u,r,m)}else if(u in Gt.propsKeywords){if(p&&typeof p==\"object\")for(var d in p)qs(e,t,n,p[d],o+\"/\"+u+\"/\"+GM(d),s,o,u,r,d)}else if(u in Gt.keywords||e.allKeys&&!(u in Gt.skipKeywords))qs(e,t,n,p,o+\"/\"+u,s,o,u,r)}n(r,o,s,i,a,c,l)}}function GM(e){return e.replace(/~/g,\"~0\").replace(/\\//g,\"~1\")}});var no=g(function(fx){Object.defineProperty(fx,\"__esModule\",{value:!0});fx.getSchemaRefs=fx.resolveUrl=fx.normalizeId=fx._getFullPath=fx.getFullPath=fx.inlineRef=void 0;var ux=B(),BM=kl(),VM=lx(),FM=new Set([\"type\",\"format\",\"pattern\",\"maxLength\",\"minLength\",\"maxProperties\",\"minProperties\",\"maxItems\",\"minItems\",\"maximum\",\"minimum\",\"uniqueItems\",\"multipleOf\",\"required\",\"enum\",\"const\"]);function JM(e,t=!0){if(typeof e==\"boolean\")return!0;if(t===!0)return!Rl(e);if(!t)return!1;return dx(e)<=t}fx.inlineRef=JM;var WM=new Set([\"$ref\",\"$recursiveRef\",\"$recursiveAnchor\",\"$dynamicRef\",\"$dynamicAnchor\"]);function Rl(e){for(let t in e){if(WM.has(t))return!0;let n=e[t];if(Array.isArray(n)&&n.some(Rl))return!0;if(typeof n==\"object\"&&Rl(n))return!0}return!1}function dx(e){let t=0;for(let n in e){if(n===\"$ref\")return 1/0;if(t++,FM.has(n))continue;if(typeof e[n]==\"object\")ux.eachItem(e[n],(r)=>t+=dx(r));if(t===1/0)return 1/0}return t}function px(e,t=\"\",n){if(n!==!1)t=or(t);let r=e.parse(t);return mx(e,r)}fx.getFullPath=px;function mx(e,t){return e.serialize(t).split(\"#\")[0]+\"#\"}fx._getFullPath=mx;var KM=/#\\/?$/;function or(e){return e?e.replace(KM,\"\"):\"\"}fx.normalizeId=or;function HM(e,t,n){return n=or(n),e.resolve(t,n)}fx.resolveUrl=HM;var ZM=/^[a-z_][-a-z0-9._]*$/i;function YM(e,t){if(typeof e==\"boolean\")return{};let{schemaId:n,uriResolver:r}=this.opts,o=or(e[n]||t),s={\"\":o},i=px(r,o,!1),a={},c=new Set;return VM(e,{allKeys:!0},(p,m,d,f)=>{if(f===void 0)return;let h=i+m,y=s[f];if(typeof p[n]==\"string\")y=_.call(this,p[n]);E.call(this,p.$anchor),E.call(this,p.$dynamicAnchor),s[m]=y;function _(T){let A=this.opts.uriResolver.resolve;if(T=or(y?A(y,T):T),c.has(T))throw u(T);c.add(T);let x=this.refs[T];if(typeof x==\"string\")x=this.refs[x];if(typeof x==\"object\")l(p,x.schema,T);else if(T!==or(h))if(T[0]===\"#\")l(p,a[T],T),a[T]=p;else this.refs[T]=h;return T}function E(T){if(typeof T==\"string\"){if(!ZM.test(T))throw Error(`invalid anchor \"${T}\"`);_.call(this,`#${T}`)}}}),a;function l(p,m,d){if(m!==void 0&&!BM(p,m))throw u(d)}function u(p){return Error(`reference \"${p}\" resolves to more than one schema`)}}fx.getSchemaRefs=YM});var In=g(function(Ex){Object.defineProperty(Ex,\"__esModule\",{value:!0});Ex.getData=Ex.KeywordCxt=Ex.validateFunctionCode=void 0;var js=Tw(),zs=to(),ir=vl(),Bt=to(),vx=Fw(),rt=rx(),sr=ix(),v=N(),z=Le(),_x=no(),ve=B(),nt=eo();function rq(e){if(Sx(e)){if(Ix(e),xx(e)){iq(e);return}}wx(e,()=>js.topBoolOrEmptySchema(e))}Ex.validateFunctionCode=rq;function wx({gen:e,validateName:t,schema:n,schemaEnv:r,opts:o},s){if(o.code.es5)e.func(t,v._`${z.default.data}, ${z.default.valCxt}`,r.$async,()=>{e.code(v._`\"use strict\"; ${hx(n,o)}`),sq(e,o),e.code(s)});else e.func(t,v._`${z.default.data}, ${oq(o)}`,r.$async,()=>e.code(hx(n,o)).code(s))}function oq(e){return v._`{${z.default.instancePath}=\"\", ${z.default.parentData}, ${z.default.parentDataProperty}, ${z.default.rootData}=${z.default.data}${e.dynamicRef?v._`, ${z.default.dynamicAnchors}={}`:v.nil}}={}`}function sq(e,t){e.if(z.default.valCxt,()=>{if(e.var(z.default.instancePath,v._`${z.default.valCxt}.${z.default.instancePath}`),e.var(z.default.parentData,v._`${z.default.valCxt}.${z.default.parentData}`),e.var(z.default.parentDataProperty,v._`${z.default.valCxt}.${z.default.parentDataProperty}`),e.var(z.default.rootData,v._`${z.default.valCxt}.${z.default.rootData}`),t.dynamicRef)e.var(z.default.dynamicAnchors,v._`${z.default.valCxt}.${z.default.dynamicAnchors}`)},()=>{if(e.var(z.default.instancePath,v._`\"\"`),e.var(z.default.parentData,v._`undefined`),e.var(z.default.parentDataProperty,v._`undefined`),e.var(z.default.rootData,z.default.data),t.dynamicRef)e.var(z.default.dynamicAnchors,v._`{}`)})}function iq(e){let{schema:t,opts:n,gen:r}=e;wx(e,()=>{if(n.$comment&&t.$comment)Rx(e);if(dq(e),r.let(z.default.vErrors,null),r.let(z.default.errors,0),n.unevaluated)aq(e);kx(e),fq(e)});return}function aq(e){let{gen:t,validateName:n}=e;e.evaluated=t.const(\"evaluated\",v._`${n}.evaluated`),t.if(v._`${e.evaluated}.dynamicProps`,()=>t.assign(v._`${e.evaluated}.props`,v._`undefined`)),t.if(v._`${e.evaluated}.dynamicItems`,()=>t.assign(v._`${e.evaluated}.items`,v._`undefined`))}function hx(e,t){let n=typeof e==\"object\"&&e[t.schemaId];return n&&(t.code.source||t.code.process)?v._`/*# sourceURL=${n} */`:v.nil}function cq(e,t){if(Sx(e)){if(Ix(e),xx(e)){lq(e,t);return}}js.boolOrEmptySchema(e,t)}function xx({schema:e,self:t}){if(typeof e==\"boolean\")return!e;for(let n in e)if(t.RULES.all[n])return!0;return!1}function Sx(e){return typeof e.schema!=\"boolean\"}function lq(e,t){let{schema:n,gen:r,opts:o}=e;if(o.$comment&&n.$comment)Rx(e);pq(e),mq(e);let s=r.const(\"_errs\",z.default.errors);kx(e,s),r.var(t,v._`${s} === ${z.default.errors}`)}function Ix(e){ve.checkUnknownRules(e),uq(e)}function kx(e,t){if(e.opts.jtd)return yx(e,[],!1,t);let n=zs.getSchemaTypes(e.schema),r=zs.coerceAndCheckDataType(e,n);yx(e,n,!r,t)}function uq(e){let{schema:t,errSchemaPath:n,opts:r,self:o}=e;if(t.$ref&&r.ignoreKeywordsWithRef&&ve.schemaHasRulesButRef(t,o.RULES))o.logger.warn(`$ref: keywords ignored in schema at path \"${n}\"`)}function dq(e){let{schema:t,opts:n}=e;if(t.default!==void 0&&n.useDefaults&&n.strictSchema)ve.checkStrictMode(e,\"default is ignored in the schema root\")}function pq(e){let t=e.schema[e.opts.schemaId];if(t)e.baseId=_x.resolveUrl(e.opts.uriResolver,e.baseId,t)}function mq(e){if(e.schema.$async&&!e.schemaEnv.$async)throw Error(\"async schema in sync schema\")}function Rx({gen:e,schemaEnv:t,schema:n,errSchemaPath:r,opts:o}){let s=n.$comment;if(o.$comment===!0)e.code(v._`${z.default.self}.logger.log(${s})`);else if(typeof o.$comment==\"function\"){let i=v.str`${r}/$comment`,a=e.scopeValue(\"root\",{ref:t.root});e.code(v._`${z.default.self}.opts.$comment(${s}, ${i}, ${a}.schema)`)}}function fq(e){let{gen:t,schemaEnv:n,validateName:r,ValidationError:o,opts:s}=e;if(n.$async)t.if(v._`${z.default.errors} === 0`,()=>t.return(z.default.data),()=>t.throw(v._`new ${o}(${z.default.vErrors})`));else{if(t.assign(v._`${r}.errors`,z.default.vErrors),s.unevaluated)gq(e);t.return(v._`${z.default.errors} === 0`)}}function gq({gen:e,evaluated:t,props:n,items:r}){if(n instanceof v.Name)e.assign(v._`${t}.props`,n);if(r instanceof v.Name)e.assign(v._`${t}.items`,r)}function yx(e,t,n,r){let{gen:o,schema:s,data:i,allErrors:a,opts:c,self:l}=e,{RULES:u}=l;if(s.$ref&&(c.ignoreKeywordsWithRef||!ve.schemaHasRulesButRef(s,u))){o.block(()=>Ax(e,\"$ref\",u.all.$ref.definition));return}if(!c.jtd)hq(e,t);o.block(()=>{for(let m of u.rules)p(m);p(u.post)});function p(m){if(!ir.shouldUseGroup(s,m))return;if(m.type){if(o.if(Bt.checkDataType(m.type,i,c.strictNumbers)),bx(e,m),t.length===1&&t[0]===m.type&&n)o.else(),Bt.reportTypeError(e);o.endIf()}else bx(e,m);if(!a)o.if(v._`${z.default.errors} === ${r||0}`)}}function bx(e,t){let{gen:n,schema:r,opts:{useDefaults:o}}=e;if(o)vx.assignDefaults(e,t.type);n.block(()=>{for(let s of t.rules)if(ir.shouldUseRule(r,s))Ax(e,s.keyword,s.definition,t.type)})}function hq(e,t){if(e.schemaEnv.meta||!e.opts.strictTypes)return;if(yq(e,t),!e.opts.allowUnionTypes)bq(e,t);vq(e,e.dataTypes)}function yq(e,t){if(!t.length)return;if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach((n)=>{if(!Tx(e.dataTypes,n))Tl(e,`type \"${n}\" not allowed by context \"${e.dataTypes.join(\",\")}\"`)}),wq(e,t)}function bq(e,t){if(t.length>1&&!(t.length===2&&t.includes(\"null\")))Tl(e,\"use allowUnionTypes to allow union type keyword\")}function vq(e,t){let n=e.self.RULES.all;for(let r in n){let o=n[r];if(typeof o==\"object\"&&ir.shouldUseRule(e.schema,o)){let{type:s}=o.definition;if(s.length&&!s.some((i)=>_q(t,i)))Tl(e,`missing type \"${s.join(\",\")}\" for keyword \"${r}\"`)}}}function _q(e,t){return e.includes(t)||t===\"number\"&&e.includes(\"integer\")}function Tx(e,t){return e.includes(t)||t===\"integer\"&&e.includes(\"number\")}function wq(e,t){let n=[];for(let r of e.dataTypes)if(Tx(t,r))n.push(r);else if(t.includes(\"integer\")&&r===\"number\")n.push(\"integer\");e.dataTypes=n}function Tl(e,t){let n=e.schemaEnv.baseId+e.errSchemaPath;t+=` at \"${n}\" (strictTypes)`,ve.checkStrictMode(e,t,e.opts.strictTypes)}class Al{constructor(e,t,n){if(rt.validateKeywordUsage(e,t,n),this.gen=e.gen,this.allErrors=e.allErrors,this.keyword=n,this.data=e.data,this.schema=e.schema[n],this.$data=t.$data&&e.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=ve.schemaRefOrVal(e,this.schema,n,this.$data),this.schemaType=t.schemaType,this.parentSchema=e.schema,this.params={},this.it=e,this.def=t,this.$data)this.schemaCode=e.gen.const(\"vSchema\",Cx(this.$data,e));else if(this.schemaCode=this.schemaValue,!rt.validSchemaType(this.schema,t.schemaType,t.allowUndefined))throw Error(`${n} value must be ${JSON.stringify(t.schemaType)}`);if(\"code\"in t?t.trackErrors:t.errors!==!1)this.errsCount=e.gen.const(\"_errs\",z.default.errors)}result(e,t,n){this.failResult(v.not(e),t,n)}failResult(e,t,n){if(this.gen.if(e),n)n();else this.error();if(t){if(this.gen.else(),t(),this.allErrors)this.gen.endIf()}else if(this.allErrors)this.gen.endIf();else this.gen.else()}pass(e,t){this.failResult(v.not(e),void 0,t)}fail(e){if(e===void 0){if(this.error(),!this.allErrors)this.gen.if(!1);return}if(this.gen.if(e),this.error(),this.allErrors)this.gen.endIf();else this.gen.else()}fail$data(e){if(!this.$data)return this.fail(e);let{schemaCode:t}=this;this.fail(v._`${t} !== undefined && (${v.or(this.invalid$data(),e)})`)}error(e,t,n){if(t){this.setParams(t),this._error(e,n),this.setParams({});return}this._error(e,n)}_error(e,t){(e?nt.reportExtraError:nt.reportError)(this,this.def.error,t)}$dataError(){nt.reportError(this,this.def.$dataError||nt.keyword$DataError)}reset(){if(this.errsCount===void 0)throw Error('add \"trackErrors\" to keyword definition');nt.resetErrorsCount(this.gen,this.errsCount)}ok(e){if(!this.allErrors)this.gen.if(e)}setParams(e,t){if(t)Object.assign(this.params,e);else this.params=e}block$data(e,t,n=v.nil){this.gen.block(()=>{this.check$data(e,n),t()})}check$data(e=v.nil,t=v.nil){if(!this.$data)return;let{gen:n,schemaCode:r,schemaType:o,def:s}=this;if(n.if(v.or(v._`${r} === undefined`,t)),e!==v.nil)n.assign(e,!0);if(o.length||s.validateSchema){if(n.elseIf(this.invalid$data()),this.$dataError(),e!==v.nil)n.assign(e,!1)}n.else()}invalid$data(){let{gen:e,schemaCode:t,schemaType:n,def:r,it:o}=this;return v.or(s(),i());function s(){if(n.length){if(!(t instanceof v.Name))throw Error(\"ajv implementation error\");let a=Array.isArray(n)?n:[n];return v._`${Bt.checkDataTypes(a,t,o.opts.strictNumbers,Bt.DataType.Wrong)}`}return v.nil}function i(){if(r.validateSchema){let a=e.scopeValue(\"validate$data\",{ref:r.validateSchema});return v._`!${a}(${t})`}return v.nil}}subschema(e,t){let n=sr.getSubschema(this.it,e);sr.extendSubschemaData(n,this.it,e),sr.extendSubschemaMode(n,e);let r={...this.it,...n,items:void 0,props:void 0};return cq(r,t),r}mergeEvaluated(e,t){let{it:n,gen:r}=this;if(!n.opts.unevaluated)return;if(n.props!==!0&&e.props!==void 0)n.props=ve.mergeEvaluated.props(r,e.props,n.props,t);if(n.items!==!0&&e.items!==void 0)n.items=ve.mergeEvaluated.items(r,e.items,n.items,t)}mergeValidEvaluated(e,t){let{it:n,gen:r}=this;if(n.opts.unevaluated&&(n.props!==!0||n.items!==!0))return r.if(t,()=>this.mergeEvaluated(e,v.Name)),!0}}Ex.KeywordCxt=Al;function Ax(e,t,n,r){let o=new Al(e,n,t);if(\"code\"in n)n.code(o,r);else if(o.$data&&n.validate)rt.funcKeywordCode(o,n);else if(\"macro\"in n)rt.macroKeywordCode(o,n);else if(n.compile||n.validate)rt.funcKeywordCode(o,n)}var xq=/^\\/(?:[^~]|~0|~1)*$/,Sq=/^([0-9]+)(#|\\/(?:[^~]|~0|~1)*)?$/;function Cx(e,{dataLevel:t,dataNames:n,dataPathArr:r}){let o,s;if(e===\"\")return z.default.rootData;if(e[0]===\"/\"){if(!xq.test(e))throw Error(`Invalid JSON-pointer: ${e}`);o=e,s=z.default.rootData}else{let l=Sq.exec(e);if(!l)throw Error(`Invalid JSON-pointer: ${e}`);let u=+l[1];if(o=l[2],o===\"#\"){if(u>=t)throw Error(c(\"property/index\",u));return r[t-u]}if(u>t)throw Error(c(\"data\",u));if(s=n[t-u],!o)return s}let i=s,a=o.split(\"/\");for(let l of a)if(l)s=v._`${s}${v.getProperty(ve.unescapeJsonPointer(l))}`,i=v._`${i} && ${s}`;return i;function c(l,u){return`Cannot access ${l} ${u} levels up, current level is ${t}`}}Ex.getData=Cx});var ar=g(function($x){Object.defineProperty($x,\"__esModule\",{value:!0});class Ox extends Error{constructor(e){super(\"validation failed\");this.errors=e,this.ajv=this.validation=!0}}$x.default=Ox});var kn=g(function(qx){Object.defineProperty(qx,\"__esModule\",{value:!0});var cr=no();class Mx extends Error{constructor(e,t,n,r){super(r||`can't resolve reference ${n} from id ${t}`);this.missingRef=cr.resolveUrl(e,t,n),this.missingSchema=cr.normalizeId(cr.getFullPath(e,this.missingRef))}}qx.default=Mx});var oo=g(function(Nx){Object.defineProperty(Nx,\"__esModule\",{value:!0});Nx.resolveSchema=Nx.getCompilingSchema=Nx.resolveRef=Nx.compileSchema=Nx.SchemaEnv=void 0;var de=N(),Aq=ar(),Rn=Le(),pe=no(),Ns=B(),zx=In();class ro{constructor(e){var t;this.refs={},this.dynamicAnchors={};let n;if(typeof e.schema==\"object\")n=e.schema;this.schema=e.schema,this.schemaId=e.schemaId,this.root=e.root||this,this.baseId=(t=e.baseId)!==null&&t!==void 0?t:pe.normalizeId(n===null||n===void 0?void 0:n[e.schemaId||\"$id\"]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=n===null||n===void 0?void 0:n.$async,this.refs={}}}Nx.SchemaEnv=ro;function El(e){let t=jx.call(this,e);if(t)return t;let n=pe.getFullPath(this.opts.uriResolver,e.root.baseId),{es5:r,lines:o}=this.opts.code,{ownProperties:s}=this.opts,i=new de.CodeGen(this.scope,{es5:r,lines:o,ownProperties:s}),a;if(e.$async)a=i.scopeValue(\"Error\",{ref:Aq.default,code:de._`require(\"ajv/dist/runtime/validation_error\").default`});let c=i.scopeName(\"validate\");e.validateName=c;let l={gen:i,allErrors:this.opts.allErrors,data:Rn.default.data,parentData:Rn.default.parentData,parentDataProperty:Rn.default.parentDataProperty,dataNames:[Rn.default.data],dataPathArr:[de.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:i.scopeValue(\"schema\",this.opts.code.source===!0?{ref:e.schema,code:de.stringify(e.schema)}:{ref:e.schema}),validateName:c,ValidationError:a,schema:e.schema,schemaEnv:e,rootId:n,baseId:e.baseId||n,schemaPath:de.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?\"\":\"#\"),errorPath:de._`\"\"`,opts:this.opts,self:this},u;try{this._compilations.add(e),zx.validateFunctionCode(l),i.optimize(this.opts.code.optimize);let p=i.toString();if(u=`${i.scopeRefs(Rn.default.scope)}return ${p}`,this.opts.code.process)u=this.opts.code.process(u,e);let d=Function(`${Rn.default.self}`,`${Rn.default.scope}`,u)(this,this.scope.get());if(this.scope.value(c,{ref:d}),d.errors=null,d.schema=e.schema,d.schemaEnv=e,e.$async)d.$async=!0;if(this.opts.code.source===!0)d.source={validateName:c,validateCode:p,scopeValues:i._values};if(this.opts.unevaluated){let{props:f,items:h}=l;if(d.evaluated={props:f instanceof de.Name?void 0:f,items:h instanceof de.Name?void 0:h,dynamicProps:f instanceof de.Name,dynamicItems:h instanceof de.Name},d.source)d.source.evaluated=de.stringify(d.evaluated)}return e.validate=d,e}catch(p){if(delete e.validate,delete e.validateName,u)this.logger.error(\"Error compiling schema, function code:\",u);throw p}finally{this._compilations.delete(e)}}Nx.compileSchema=El;function Cq(e,t,n){var r;n=pe.resolveUrl(this.opts.uriResolver,t,n);let o=e.refs[n];if(o)return o;let s=Oq.call(this,e,n);if(s===void 0){let i=(r=e.localRefs)===null||r===void 0?void 0:r[n],{schemaId:a}=this.opts;if(i)s=new ro({schema:i,schemaId:a,root:e,baseId:t})}if(s===void 0)return;return e.refs[n]=Eq.call(this,s)}Nx.resolveRef=Cq;function Eq(e){if(pe.inlineRef(e.schema,this.opts.inlineRefs))return e.schema;return e.validate?e:El.call(this,e)}function jx(e){for(let t of this._compilations)if(Pq(t,e))return t}Nx.getCompilingSchema=jx;function Pq(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function Oq(e,t){let n;while(typeof(n=this.refs[t])==\"string\")t=n;return n||this.schemas[t]||Ds.call(this,e,t)}function Ds(e,t){let n=this.opts.uriResolver.parse(t),r=pe._getFullPath(this.opts.uriResolver,n),o=pe.getFullPath(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&r===o)return Cl.call(this,n,e);let s=pe.normalizeId(r),i=this.refs[s]||this.schemas[s];if(typeof i==\"string\"){let a=Ds.call(this,e,i);if(typeof(a===null||a===void 0?void 0:a.schema)!==\"object\")return;return Cl.call(this,n,a)}if(typeof(i===null||i===void 0?void 0:i.schema)!==\"object\")return;if(!i.validate)El.call(this,i);if(s===pe.normalizeId(t)){let{schema:a}=i,{schemaId:c}=this.opts,l=a[c];if(l)o=pe.resolveUrl(this.opts.uriResolver,o,l);return new ro({schema:a,schemaId:c,root:e,baseId:o})}return Cl.call(this,n,i)}Nx.resolveSchema=Ds;var $q=new Set([\"properties\",\"patternProperties\",\"enum\",\"dependencies\",\"definitions\"]);function Cl(e,{baseId:t,schema:n,root:r}){var o;if(((o=e.fragment)===null||o===void 0?void 0:o[0])!==\"/\")return;for(let a of e.fragment.slice(1).split(\"/\")){if(typeof n===\"boolean\")return;let c=n[Ns.unescapeFragment(a)];if(c===void 0)return;n=c;let l=typeof n===\"object\"&&n[this.opts.schemaId];if(!$q.has(a)&&l)t=pe.resolveUrl(this.opts.uriResolver,t,l)}let s;if(typeof n!=\"boolean\"&&n.$ref&&!Ns.schemaHasRulesButRef(n,this.RULES)){let a=pe.resolveUrl(this.opts.uriResolver,t,n.$ref);s=Ds.call(this,r,a)}let{schemaId:i}=this.opts;if(s=s||new ro({schema:n,schemaId:i,root:r,baseId:t}),s.schema!==s.root.schema)return s;return}});var Ux=g(function(mZ,Nq){Nq.exports={$id:\"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#\",description:\"Meta-schema for $data reference (JSON AnySchema extension proposal)\",type:\"object\",required:[\"$data\"],properties:{$data:{type:\"string\",anyOf:[{format:\"relative-json-pointer\"},{format:\"json-pointer\"}]}},additionalProperties:!1}});var $l=g(function(fZ,Jx){var Dq=RegExp.prototype.test.bind(/^[\\da-f]{8}-[\\da-f]{4}-[\\da-f]{4}-[\\da-f]{4}-[\\da-f]{12}$/iu),Gx=RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\\d|1\\d{2}|[1-9]\\d|\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|1\\d{2}|[1-9]\\d|\\d)$/u),Pl=RegExp.prototype.test.bind(/^[\\da-f]{2}$/iu),Bx=RegExp.prototype.test.bind(/^[\\da-z\\-._~]$/iu),Uq=RegExp.prototype.test.bind(/^[\\da-z\\-._~!$&'()*+,;=:@/]$/iu);function Ol(e){let t=\"\",n=0,r=0;for(r=0;r<e.length;r++){if(n=e[r].charCodeAt(0),n===48)continue;if(!(n>=48&&n<=57||n>=65&&n<=70||n>=97&&n<=102))return\"\";t+=e[r];break}for(r+=1;r<e.length;r++){if(n=e[r].charCodeAt(0),!(n>=48&&n<=57||n>=65&&n<=70||n>=97&&n<=102))return\"\";t+=e[r]}return t}var Lq=RegExp.prototype.test.bind(/[^!\"$&'()*+,\\-.;=_`a-z{}~]/u);function Lx(e){return e.length=0,!0}function Gq(e,t,n){if(e.length){let r=Ol(e);if(r!==\"\")t.push(r);else return n.error=!0,!1;e.length=0}return!0}function Bq(e){let t=0,n={error:!1,address:\"\",zone:\"\"},r=[],o=[],s=!1,i=!1,a=Gq;for(let c=0;c<e.length;c++){let l=e[c];if(l===\"[\"||l===\"]\")continue;if(l===\":\"){if(s===!0)i=!0;if(!a(o,r,n))break;if(++t>7){n.error=!0;break}if(c>0&&e[c-1]===\":\")s=!0;r.push(\":\");continue}else if(l===\"%\"){if(!a(o,r,n))break;a=Lx}else{o.push(l);continue}}if(o.length)if(a===Lx)n.zone=o.join(\"\");else if(i)r.push(o.join(\"\"));else r.push(Ol(o));return n.address=r.join(\"\"),n}function Vx(e){if(Vq(e,\":\")<2)return{host:e,isIPV6:!1};let t=Bq(e);if(!t.error){let{address:n,address:r}=t;if(t.zone)n+=\"%\"+t.zone,r+=\"%25\"+t.zone;return{host:n,isIPV6:!0,escapedHost:r}}else return{host:e,isIPV6:!1}}function Vq(e,t){let n=0;for(let r=0;r<e.length;r++)if(e[r]===t)n++;return n}function Fq(e){let t=e,n=[],r=-1,o=0;while(o=t.length){if(o===1)if(t===\".\")break;else if(t===\"/\"){n.push(\"/\");break}else{n.push(t);break}else if(o===2){if(t[0]===\".\"){if(t[1]===\".\")break;else if(t[1]===\"/\"){t=t.slice(2);continue}}else if(t[0]===\"/\"){if(t[1]===\".\"||t[1]===\"/\"){n.push(\"/\");break}}}else if(o===3){if(t===\"/..\"){if(n.length!==0)n.pop();n.push(\"/\");break}}if(t[0]===\".\"){if(t[1]===\".\"){if(t[2]===\"/\"){t=t.slice(3);continue}}else if(t[1]===\"/\"){t=t.slice(2);continue}}else if(t[0]===\"/\"){if(t[1]===\".\"){if(t[2]===\"/\"){t=t.slice(2);continue}else if(t[2]===\".\"){if(t[3]===\"/\"){if(t=t.slice(3),n.length!==0)n.pop();continue}}}}if((r=t.indexOf(\"/\",1))===-1){n.push(t);break}else n.push(t.slice(0,r)),t=t.slice(r)}return n.join(\"\")}var Jq={\"@\":\"%40\",\"/\":\"%2F\",\"?\":\"%3F\",\"#\":\"%23\",\":\":\"%3A\"},Wq=/[@/?#:]/g,Kq=/[@/?#]/g;function Fx(e,t){let n=t?Kq:Wq;return n.lastIndex=0,e.replace(n,(r)=>Jq[r])}function Hq(e,t=!1){if(e.indexOf(\"%\")===-1)return e;let n=\"\";for(let r=0;r<e.length;r++){if(e[r]===\"%\"&&r+2<e.length){let o=e.slice(r+1,r+3);if(Pl(o)){let s=o.toUpperCase(),i=String.fromCharCode(parseInt(s,16));if(t&&Bx(i))n+=i;else n+=\"%\"+s;r+=2;continue}}n+=e[r]}return n}function Zq(e){let t=\"\";for(let n=0;n<e.length;n++){if(e[n]===\"%\"&&n+2<e.length){let r=e.slice(n+1,n+3);if(Pl(r)){let o=r.toUpperCase(),s=String.fromCharCode(parseInt(o,16));if(s!==\".\"&&Bx(s))t+=s;else t+=\"%\"+o;n+=2;continue}}if(Uq(e[n]))t+=e[n];else t+=escape(e[n])}return t}function Yq(e){let t=\"\";for(let n=0;n<e.length;n++){if(e[n]===\"%\"&&n+2<e.length){let r=e.slice(n+1,n+3);if(Pl(r)){t+=\"%\"+r.toUpperCase(),n+=2;continue}}t+=escape(e[n])}return t}function Xq(e){let t=[];if(e.userinfo!==void 0)t.push(e.userinfo),t.push(\"@\");if(e.host!==void 0){let n=unescape(e.host);if(!Gx(n)){let r=Vx(n);if(r.isIPV6===!0)n=`[${r.escapedHost}]`;else n=Fx(n,!1)}t.push(n)}if(typeof e.port===\"number\"||typeof e.port===\"string\")t.push(\":\"),t.push(String(e.port));return t.length?t.join(\"\"):void 0}Jx.exports={nonSimpleDomain:Lq,recomposeAuthority:Xq,reescapeHostDelimiters:Fx,normalizePercentEncoding:Hq,normalizePathEncoding:Zq,escapePreservingEscapes:Yq,removeDotSegments:Fq,isIPv4:Gx,isUUID:Dq,normalizeIPv6:Vx,stringArrayToHexStripped:Ol}});var Yx=g(function(gZ,Zx){var{isUUID:Qq}=$l(),ez=/([\\da-z][\\d\\-a-z]{0,31}):((?:[\\w!$'()*+,\\-.:;=@]|%[\\da-f]{2})+)/iu,tz=[\"http\",\"https\",\"ws\",\"wss\",\"urn\",\"urn:uuid\"];function nz(e){return tz.indexOf(e)!==-1}function Ml(e){if(e.secure===!0)return!0;else if(e.secure===!1)return!1;else if(e.scheme)return e.scheme.length===3&&(e.scheme[0]===\"w\"||e.scheme[0]===\"W\")&&(e.scheme[1]===\"s\"||e.scheme[1]===\"S\")&&(e.scheme[2]===\"s\"||e.scheme[2]===\"S\");else return!1}function Wx(e){if(!e.host)e.error=e.error||\"HTTP URIs must have a host.\";return e}function Kx(e){let t=String(e.scheme).toLowerCase()===\"https\";if(e.port===(t?443:80)||e.port===\"\")e.port=void 0;if(!e.path)e.path=\"/\";return e}function rz(e){return e.secure=Ml(e),e.resourceName=(e.path||\"/\")+(e.query?\"?\"+e.query:\"\"),e.path=void 0,e.query=void 0,e}function oz(e){if(e.port===(Ml(e)?443:80)||e.port===\"\")e.port=void 0;if(typeof e.secure===\"boolean\")e.scheme=e.secure?\"wss\":\"ws\",e.secure=void 0;if(e.resourceName){let[t,n]=e.resourceName.split(\"?\");e.path=t&&t!==\"/\"?t:void 0,e.query=n,e.resourceName=void 0}return e.fragment=void 0,e}function sz(e,t){if(!e.path)return e.error=\"URN can not be parsed\",e;let n=e.path.match(ez);if(n){let r=t.scheme||e.scheme||\"urn\";e.nid=n[1].toLowerCase(),e.nss=n[2];let o=`${r}:${t.nid||e.nid}`,s=ql(o);if(e.path=void 0,s)e=s.parse(e,t)}else e.error=e.error||\"URN can not be parsed.\";return e}function iz(e,t){if(e.nid===void 0)throw Error(\"URN without nid cannot be serialized\");let n=t.scheme||e.scheme||\"urn\",r=e.nid.toLowerCase(),o=`${n}:${t.nid||r}`,s=ql(o);if(s)e=s.serialize(e,t);let i=e,a=e.nss;return i.path=`${r||t.nid}:${a}`,t.skipEscape=!0,i}function az(e,t){let n=e;if(n.uuid=n.nss,n.nss=void 0,!t.tolerant&&(!n.uuid||!Qq(n.uuid)))n.error=n.error||\"UUID is not valid.\";return n}function cz(e){let t=e;return t.nss=(e.uuid||\"\").toLowerCase(),t}var Hx={scheme:\"http\",domainHost:!0,parse:Wx,serialize:Kx},lz={scheme:\"https\",domainHost:Hx.domainHost,parse:Wx,serialize:Kx},Us={scheme:\"ws\",domainHost:!0,parse:rz,serialize:oz},uz={scheme:\"wss\",domainHost:Us.domainHost,parse:Us.parse,serialize:Us.serialize},dz={scheme:\"urn\",parse:sz,serialize:iz,skipNormalize:!0},pz={scheme:\"urn:uuid\",parse:az,serialize:cz,skipNormalize:!0},Ls={http:Hx,https:lz,ws:Us,wss:uz,urn:dz,\"urn:uuid\":pz};Object.setPrototypeOf(Ls,null);function ql(e){return e&&(Ls[e]||Ls[e.toLowerCase()])||void 0}Zx.exports={wsIsSecure:Ml,SCHEMES:Ls,isValidSchemeName:nz,getSchemeHandler:ql}});var nS=g(function(hZ,Vs){var{normalizeIPv6:mz,removeDotSegments:so,recomposeAuthority:fz,normalizePercentEncoding:gz,normalizePathEncoding:hz,escapePreservingEscapes:yz,reescapeHostDelimiters:bz,isIPv4:vz,nonSimpleDomain:_z}=$l(),{SCHEMES:wz,getSchemeHandler:Qx}=Yx();function xz(e,t){if(typeof e===\"string\")e=Cz(e,t);else if(typeof e===\"object\")e=Bs(Tn(e,t),t);return e}function Sz(e,t,n){let r=n?Object.assign({scheme:\"null\"},n):{scheme:\"null\"},{parsed:o,malformedAuthorityOrPort:s}=Gs(e,r),{parsed:i,malformedAuthorityOrPort:a}=Gs(t,r);if(s||a)throw Error(o.error||i.error||\"URI is malformed.\");let c=eS(o,i,r,!0);return r.skipEscape=!0,Tn(c,r)}function eS(e,t,n,r){let o={};if(!r)e=Bs(Tn(e,n),n),t=Bs(Tn(t,n),n);if(n=n||{},!n.tolerant&&t.scheme)o.scheme=t.scheme,o.userinfo=t.userinfo,o.host=t.host,o.port=t.port,o.path=so(t.path||\"\"),o.query=t.query;else{if(t.userinfo!==void 0||t.host!==void 0||t.port!==void 0)o.userinfo=t.userinfo,o.host=t.host,o.port=t.port,o.path=so(t.path||\"\"),o.query=t.query;else{if(!t.path)if(o.path=e.path,t.query!==void 0)o.query=t.query;else o.query=e.query;else{if(t.path[0]===\"/\")o.path=so(t.path);else{if((e.userinfo!==void 0||e.host!==void 0||e.port!==void 0)&&!e.path)o.path=\"/\"+t.path;else if(!e.path)o.path=t.path;else o.path=e.path.slice(0,e.path.lastIndexOf(\"/\")+1)+t.path;o.path=so(o.path)}o.query=t.query}o.userinfo=e.userinfo,o.host=e.host,o.port=e.port}o.scheme=e.scheme}return o.fragment=t.fragment,o}function Iz(e,t,n){let r=Xx(e,n),o=Xx(t,n);return r!==void 0&&o!==void 0&&r.toLowerCase()===o.toLowerCase()}function Tn(e,t){let n={host:e.host,scheme:e.scheme,userinfo:e.userinfo,port:e.port,path:e.path,query:e.query,nid:e.nid,nss:e.nss,uuid:e.uuid,fragment:e.fragment,reference:e.reference,resourceName:e.resourceName,secure:e.secure,error:\"\"},r=Object.assign({},t),o=[],s=Qx(r.scheme||n.scheme);if(s&&s.serialize)s.serialize(n,r);if(n.path!==void 0)if(!r.skipEscape){if(n.path=yz(n.path),n.scheme!==void 0)n.path=n.path.split(\"%3A\").join(\":\")}else n.path=gz(n.path);if(r.reference!==\"suffix\"&&n.scheme)o.push(n.scheme,\":\");let i=fz(n);if(i!==void 0){if(r.reference!==\"suffix\")o.push(\"//\");if(o.push(i),n.path&&n.path[0]!==\"/\")o.push(\"/\")}if(n.path!==void 0){let a=n.path;if(!r.absolutePath&&(!s||!s.absolutePath))a=so(a);if(i===void 0&&a[0]===\"/\"&&a[1]===\"/\")a=\"/%2F\"+a.slice(2);o.push(a)}if(n.query!==void 0)o.push(\"?\",n.query);if(n.fragment!==void 0)o.push(\"#\",n.fragment);return o.join(\"\")}var kz=/^(?:([^#/:?]+):)?(?:\\/\\/((?:([^#/?@]*)@)?(\\[[^#/?\\]]+\\]|[^#/:?]*)(?::(\\d*))?))?([^#?]*)(?:\\?([^#]*))?(?:#((?:.|[\\n\\r])*))?/u,Rz=/^(?:[^#/:?]+:)?\\/\\/([^/?#]*)/,Tz=/^(?:[^#/:?]+:)?([/\\\\\\t\\n\\r]*)/;function Az(e,t){if(t[2]!==void 0&&e.path&&e.path[0]!==\"/\")return'URI path must start with \"/\" when authority is present.';if(typeof e.port===\"number\"&&(e.port<0||e.port>65535))return\"URI port is malformed.\";return}function Gs(e,t){let n=Object.assign({},t),r={scheme:void 0,userinfo:void 0,host:\"\",port:void 0,path:\"\",query:void 0,fragment:void 0},o=!1,s=!1;if(n.reference===\"suffix\")if(n.scheme)e=n.scheme+\":\"+e;else e=\"//\"+e;let i=e.match(Rz);if(i!==null&&i[1].indexOf(\"\\\\\")!==-1)r.error=\"URI authority must not contain a literal backslash.\",o=!0;let a=e.match(Tz);if(a!==null){let l=a[1],u=l.replace(/[\\t\\n\\r]/g,\"\");if(u.length>=2){if(u.slice(0,2)!==\"//\")r.error=r.error||\"URI authority must not contain a literal backslash.\",o=!0;else if(l.length!==u.length)r.error=r.error||\"URI authority introducer must not contain whitespace.\",o=!0}}let c=e.match(kz);if(c){if(r.scheme=c[1],r.userinfo=c[3],r.host=c[4],r.port=parseInt(c[5],10),r.path=c[6]||\"\",r.query=c[7],r.fragment=c[8],isNaN(r.port))r.port=c[5];let l=Az(r,c);if(l!==void 0)r.error=r.error||l,o=!0;if(r.host)if(vz(r.host)===!1){let m=mz(r.host);r.host=m.host.toLowerCase(),s=m.isIPV6}else s=!0;if(r.scheme===void 0&&r.userinfo===void 0&&r.host===void 0&&r.port===void 0&&r.query===void 0&&!r.path)r.reference=\"same-document\";else if(r.scheme===void 0)r.reference=\"relative\";else if(r.fragment===void 0)r.reference=\"absolute\";else r.reference=\"uri\";if(n.reference&&n.reference!==\"suffix\"&&n.reference!==r.reference)r.error=r.error||\"URI is not a \"+n.reference+\" reference.\";let u=Qx(n.scheme||r.scheme);if(!n.unicodeSupport&&(!u||!u.unicodeSupport)){if(r.host&&(n.domainHost||u&&u.domainHost)&&s===!1&&_z(r.host))try{r.host=new URL(\"http://\"+r.host).hostname}catch(p){r.error=r.error||\"Host's domain name can not be converted to ASCII: \"+p}}if(!u||u&&!u.skipNormalize){if(e.indexOf(\"%\")!==-1){if(r.scheme!==void 0)r.scheme=unescape(r.scheme);if(r.host!==void 0)r.host=bz(unescape(r.host),s)}if(r.path)r.path=hz(r.path);if(r.fragment)try{r.fragment=encodeURI(decodeURIComponent(r.fragment))}catch{r.error=r.error||\"URI malformed\"}}if(u&&u.parse)u.parse(r,n)}else r.error=r.error||\"URI can not be parsed.\";return{parsed:r,malformedAuthorityOrPort:o}}function Bs(e,t){return Gs(e,t).parsed}function Cz(e,t){return tS(e,t).normalized}function tS(e,t){let{parsed:n,malformedAuthorityOrPort:r}=Gs(e,t);return{normalized:r?e:Tn(n,t),malformedAuthorityOrPort:r}}function Xx(e,t){if(typeof e===\"string\"){let{normalized:n,malformedAuthorityOrPort:r}=tS(e,t);return r?void 0:n}if(typeof e===\"object\")return Tn(e,t)}var zl={SCHEMES:wz,normalize:xz,resolve:Sz,resolveComponent:eS,equal:Iz,serialize:Tn,parse:Bs};Vs.exports=zl;Vs.exports.default=zl;Vs.exports.fastUri=zl});var sS=g(function(oS){Object.defineProperty(oS,\"__esModule\",{value:!0});var rS=nS();rS.code='require(\"ajv/dist/runtime/uri\").default';oS.default=rS});var Js=g(function(St){Object.defineProperty(St,\"__esModule\",{value:!0});St.CodeGen=St.Name=St.nil=St.stringify=St.str=St._=St.KeywordCxt=void 0;var Pz=In();Object.defineProperty(St,\"KeywordCxt\",{enumerable:!0,get:function(){return Pz.KeywordCxt}});var ur=N();Object.defineProperty(St,\"_\",{enumerable:!0,get:function(){return ur._}});Object.defineProperty(St,\"str\",{enumerable:!0,get:function(){return ur.str}});Object.defineProperty(St,\"stringify\",{enumerable:!0,get:function(){return ur.stringify}});Object.defineProperty(St,\"nil\",{enumerable:!0,get:function(){return ur.nil}});Object.defineProperty(St,\"Name\",{enumerable:!0,get:function(){return ur.Name}});Object.defineProperty(St,\"CodeGen\",{enumerable:!0,get:function(){return ur.CodeGen}});var Oz=ar(),uS=kn(),dS=bl(),ot=oo(),pS=N(),st=no(),Vt=to(),lr=B(),iS=Ux(),$z=sS(),mS=(e,t)=>new RegExp(e,t);mS.code=\"new RegExp\";var Mz=[\"removeAdditional\",\"useDefaults\",\"coerceTypes\"],qz=new Set([\"validate\",\"serialize\",\"parse\",\"wrapper\",\"root\",\"schema\",\"keyword\",\"pattern\",\"formats\",\"validate$data\",\"func\",\"obj\",\"Error\"]),zz={errorDataPath:\"\",format:\"`validateFormats: false` can be used instead.\",nullable:'\"nullable\" keyword is supported by default.',jsonPointers:\"Deprecated jsPropertySyntax can be used instead.\",extendRefs:\"Deprecated ignoreKeywordsWithRef can be used instead.\",missingRefs:\"Pass empty schema with $id that should be ignored to ajv.addSchema.\",processCode:\"Use option `code: {process: (code, schemaEnv: object) => string}`\",sourceCode:\"Use option `code: {source: true}`\",strictDefaults:\"It is default now, see option `strict`.\",strictKeywords:\"It is default now, see option `strict`.\",uniqueItems:'\"uniqueItems\" keyword is always validated.',unknownFormats:\"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).\",cache:\"Map is used as cache, schema object as key.\",serialize:\"Map is used as cache, schema object as key.\",ajvErrors:\"It is default now.\"},jz={ignoreKeywordsWithRef:\"\",jsPropertySyntax:\"\",unicode:'\"minLength\"/\"maxLength\" account for unicode characters by default.'},aS=200;function Nz(e){var t,n,r,o,s,i,a,c,l,u,p,m,d,f,h,y,_,E,T,A,x,K,C,D,V;let L=e.strict,H=(t=e.code)===null||t===void 0?void 0:t.optimize,oe=H===!0||H===void 0?1:H||0,Te=(r=(n=e.code)===null||n===void 0?void 0:n.regExp)!==null&&r!==void 0?r:mS,je=(o=e.uriResolver)!==null&&o!==void 0?o:$z.default;return{strictSchema:(i=(s=e.strictSchema)!==null&&s!==void 0?s:L)!==null&&i!==void 0?i:!0,strictNumbers:(c=(a=e.strictNumbers)!==null&&a!==void 0?a:L)!==null&&c!==void 0?c:!0,strictTypes:(u=(l=e.strictTypes)!==null&&l!==void 0?l:L)!==null&&u!==void 0?u:\"log\",strictTuples:(m=(p=e.strictTuples)!==null&&p!==void 0?p:L)!==null&&m!==void 0?m:\"log\",strictRequired:(f=(d=e.strictRequired)!==null&&d!==void 0?d:L)!==null&&f!==void 0?f:!1,code:e.code?{...e.code,optimize:oe,regExp:Te}:{optimize:oe,regExp:Te},loopRequired:(h=e.loopRequired)!==null&&h!==void 0?h:aS,loopEnum:(y=e.loopEnum)!==null&&y!==void 0?y:aS,meta:(_=e.meta)!==null&&_!==void 0?_:!0,messages:(E=e.messages)!==null&&E!==void 0?E:!0,inlineRefs:(T=e.inlineRefs)!==null&&T!==void 0?T:!0,schemaId:(A=e.schemaId)!==null&&A!==void 0?A:\"$id\",addUsedSchema:(x=e.addUsedSchema)!==null&&x!==void 0?x:!0,validateSchema:(K=e.validateSchema)!==null&&K!==void 0?K:!0,validateFormats:(C=e.validateFormats)!==null&&C!==void 0?C:!0,unicodeRegExp:(D=e.unicodeRegExp)!==null&&D!==void 0?D:!0,int32range:(V=e.int32range)!==null&&V!==void 0?V:!0,uriResolver:je}}class Fs{constructor(e={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=new Set,this._loading={},this._cache=new Map,e=this.opts={...e,...Nz(e)};let{es5:t,lines:n}=this.opts.code;this.scope=new pS.ValueScope({scope:{},prefixes:qz,es5:t,lines:n}),this.logger=Vz(e.logger);let r=e.validateFormats;if(e.validateFormats=!1,this.RULES=dS.getRules(),cS.call(this,zz,e,\"NOT SUPPORTED\"),cS.call(this,jz,e,\"DEPRECATED\",\"warn\"),this._metaOpts=Gz.call(this),e.formats)Uz.call(this);if(this._addVocabularies(),this._addDefaultMetaSchema(),e.keywords)Lz.call(this,e.keywords);if(typeof e.meta==\"object\")this.addMetaSchema(e.meta);Dz.call(this),e.validateFormats=r}_addVocabularies(){this.addKeyword(\"$async\")}_addDefaultMetaSchema(){let{$data:e,meta:t,schemaId:n}=this.opts,r=iS;if(n===\"id\")r={...iS},r.id=r.$id,delete r.$id;if(t&&e)this.addMetaSchema(r,r[n],!1)}defaultMeta(){let{meta:e,schemaId:t}=this.opts;return this.opts.defaultMeta=typeof e==\"object\"?e[t]||e:void 0}validate(e,t){let n;if(typeof e==\"string\"){if(n=this.getSchema(e),!n)throw Error(`no schema with key or ref \"${e}\"`)}else n=this.compile(e);let r=n(t);if(!(\"$async\"in n))this.errors=n.errors;return r}compile(e,t){let n=this._addSchema(e,t);return n.validate||this._compileSchemaEnv(n)}compileAsync(e,t){if(typeof this.opts.loadSchema!=\"function\")throw Error(\"options.loadSchema should be a function\");let{loadSchema:n}=this.opts;return r.call(this,e,t);async function r(l,u){await o.call(this,l.$schema);let p=this._addSchema(l,u);return p.validate||s.call(this,p)}async function o(l){if(l&&!this.getSchema(l))await r.call(this,{$ref:l},!0)}async function s(l){try{return this._compileSchemaEnv(l)}catch(u){if(!(u instanceof uS.default))throw u;return i.call(this,u),await a.call(this,u.missingSchema),s.call(this,l)}}function i({missingSchema:l,missingRef:u}){if(this.refs[l])throw Error(`AnySchema ${l} is loaded but ${u} cannot be resolved`)}async function a(l){let u=await c.call(this,l);if(!this.refs[l])await o.call(this,u.$schema);if(!this.refs[l])this.addSchema(u,l,t)}async function c(l){let u=this._loading[l];if(u)return u;try{return await(this._loading[l]=n(l))}finally{delete this._loading[l]}}}addSchema(e,t,n,r=this.opts.validateSchema){if(Array.isArray(e)){for(let s of e)this.addSchema(s,void 0,n,r);return this}let o;if(typeof e===\"object\"){let{schemaId:s}=this.opts;if(o=e[s],o!==void 0&&typeof o!=\"string\")throw Error(`schema ${s} must be string`)}return t=st.normalizeId(t||o),this._checkUnique(t),this.schemas[t]=this._addSchema(e,n,t,r,!0),this}addMetaSchema(e,t,n=this.opts.validateSchema){return this.addSchema(e,t,!0,n),this}validateSchema(e,t){if(typeof e==\"boolean\")return!0;let n;if(n=e.$schema,n!==void 0&&typeof n!=\"string\")throw Error(\"$schema must be a string\");if(n=n||this.opts.defaultMeta||this.defaultMeta(),!n)return this.logger.warn(\"meta-schema not available\"),this.errors=null,!0;let r=this.validate(n,e);if(!r&&t){let o=\"schema is invalid: \"+this.errorsText();if(this.opts.validateSchema===\"log\")this.logger.error(o);else throw Error(o)}return r}getSchema(e){let t;while(typeof(t=lS.call(this,e))==\"string\")e=t;if(t===void 0){let{schemaId:n}=this.opts,r=new ot.SchemaEnv({schema:{},schemaId:n});if(t=ot.resolveSchema.call(this,r,e),!t)return;this.refs[e]=t}return t.validate||this._compileSchemaEnv(t)}removeSchema(e){if(e instanceof RegExp)return this._removeAllSchemas(this.schemas,e),this._removeAllSchemas(this.refs,e),this;switch(typeof e){case\"undefined\":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case\"string\":{let t=lS.call(this,e);if(typeof t==\"object\")this._cache.delete(t.schema);return delete this.schemas[e],delete this.refs[e],this}case\"object\":{let t=e;this._cache.delete(t);let n=e[this.opts.schemaId];if(n)n=st.normalizeId(n),delete this.schemas[n],delete this.refs[n];return this}default:throw Error(\"ajv.removeSchema: invalid parameter\")}}addVocabulary(e){for(let t of e)this.addKeyword(t);return this}addKeyword(e,t){let n;if(typeof e==\"string\"){if(n=e,typeof t==\"object\")this.logger.warn(\"these parameters are deprecated, see docs for addKeyword\"),t.keyword=n}else if(typeof e==\"object\"&&t===void 0){if(t=e,n=t.keyword,Array.isArray(n)&&!n.length)throw Error(\"addKeywords: keyword must be string or non-empty array\")}else throw Error(\"invalid addKeywords parameters\");if(Jz.call(this,n,t),!t)return lr.eachItem(n,(o)=>jl.call(this,o)),this;Kz.call(this,t);let r={...t,type:Vt.getJSONTypes(t.type),schemaType:Vt.getJSONTypes(t.schemaType)};return lr.eachItem(n,r.type.length===0?(o)=>jl.call(this,o,r):(o)=>r.type.forEach((s)=>jl.call(this,o,r,s))),this}getKeyword(e){let t=this.RULES.all[e];return typeof t==\"object\"?t.definition:!!t}removeKeyword(e){let{RULES:t}=this;delete t.keywords[e],delete t.all[e];for(let n of t.rules){let r=n.rules.findIndex((o)=>o.keyword===e);if(r>=0)n.rules.splice(r,1)}return this}addFormat(e,t){if(typeof t==\"string\")t=new RegExp(t);return this.formats[e]=t,this}errorsText(e=this.errors,{separator:t=\", \",dataVar:n=\"data\"}={}){if(!e||e.length===0)return\"No errors\";return e.map((r)=>`${n}${r.instancePath} ${r.message}`).reduce((r,o)=>r+t+o)}$dataMetaSchema(e,t){let n=this.RULES.all;e=JSON.parse(JSON.stringify(e));for(let r of t){let o=r.split(\"/\").slice(1),s=e;for(let i of o)s=s[i];for(let i in n){let a=n[i];if(typeof a!=\"object\")continue;let{$data:c}=a.definition,l=s[i];if(c&&l)s[i]=fS(l)}}return e}_removeAllSchemas(e,t){for(let n in e){let r=e[n];if(!t||t.test(n)){if(typeof r==\"string\")delete e[n];else if(r&&!r.meta)this._cache.delete(r.schema),delete e[n]}}}_addSchema(e,t,n,r=this.opts.validateSchema,o=this.opts.addUsedSchema){let s,{schemaId:i}=this.opts;if(typeof e==\"object\")s=e[i];else if(this.opts.jtd)throw Error(\"schema must be object\");else if(typeof e!=\"boolean\")throw Error(\"schema must be object or boolean\");let a=this._cache.get(e);if(a!==void 0)return a;n=st.normalizeId(s||n);let c=st.getSchemaRefs.call(this,e,n);if(a=new ot.SchemaEnv({schema:e,schemaId:i,meta:t,baseId:n,localRefs:c}),this._cache.set(a.schema,a),o&&!n.startsWith(\"#\")){if(n)this._checkUnique(n);this.refs[n]=a}if(r)this.validateSchema(e,!0);return a}_checkUnique(e){if(this.schemas[e]||this.refs[e])throw Error(`schema with key or id \"${e}\" already exists`)}_compileSchemaEnv(e){if(e.meta)this._compileMetaSchema(e);else ot.compileSchema.call(this,e);if(!e.validate)throw Error(\"ajv implementation error\");return e.validate}_compileMetaSchema(e){let t=this.opts;this.opts=this._metaOpts;try{ot.compileSchema.call(this,e)}finally{this.opts=t}}}Fs.ValidationError=Oz.default;Fs.MissingRefError=uS.default;St.default=Fs;function cS(e,t,n,r=\"error\"){for(let o in e){let s=o;if(s in t)this.logger[r](`${n}: option ${o}. ${e[s]}`)}}function lS(e){return e=st.normalizeId(e),this.schemas[e]||this.refs[e]}function Dz(){let e=this.opts.schemas;if(!e)return;if(Array.isArray(e))this.addSchema(e);else for(let t in e)this.addSchema(e[t],t)}function Uz(){for(let e in this.opts.formats){let t=this.opts.formats[e];if(t)this.addFormat(e,t)}}function Lz(e){if(Array.isArray(e)){this.addVocabulary(e);return}this.logger.warn(\"keywords option as map is deprecated, pass array\");for(let t in e){let n=e[t];if(!n.keyword)n.keyword=t;this.addKeyword(n)}}function Gz(){let e={...this.opts};for(let t of Mz)delete e[t];return e}var Bz={log(){},warn(){},error(){}};function Vz(e){if(e===!1)return Bz;if(e===void 0)return console;if(e.log&&e.warn&&e.error)return e;throw Error(\"logger must implement log, warn and error methods\")}var Fz=/^[a-z_$][a-z0-9_$:-]*$/i;function Jz(e,t){let{RULES:n}=this;if(lr.eachItem(e,(r)=>{if(n.keywords[r])throw Error(`Keyword ${r} is already defined`);if(!Fz.test(r))throw Error(`Keyword ${r} has invalid name`)}),!t)return;if(t.$data&&!((\"code\"in t)||(\"validate\"in t)))throw Error('$data keyword must have \"code\" or \"validate\" function')}function jl(e,t,n){var r;let o=t===null||t===void 0?void 0:t.post;if(n&&o)throw Error('keyword with \"post\" flag cannot have \"type\"');let{RULES:s}=this,i=o?s.post:s.rules.find(({type:c})=>c===n);if(!i)i={type:n,rules:[]},s.rules.push(i);if(s.keywords[e]=!0,!t)return;let a={keyword:e,definition:{...t,type:Vt.getJSONTypes(t.type),schemaType:Vt.getJSONTypes(t.schemaType)}};if(t.before)Wz.call(this,i,a,t.before);else i.rules.push(a);s.all[e]=a,(r=t.implements)===null||r===void 0||r.forEach((c)=>this.addKeyword(c))}function Wz(e,t,n){let r=e.rules.findIndex((o)=>o.keyword===n);if(r>=0)e.rules.splice(r,0,t);else e.rules.push(t),this.logger.warn(`rule ${n} is not defined`)}function Kz(e){let{metaSchema:t}=e;if(t===void 0)return;if(e.$data&&this.opts.$data)t=fS(t);e.validateSchema=this.compile(t,!0)}var Hz={$ref:\"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#\"};function fS(e){return{anyOf:[e,Hz]}}});var hS=g(function(gS){Object.defineProperty(gS,\"__esModule\",{value:!0});var Xz={keyword:\"id\",code(){throw Error('NOT SUPPORTED: keyword \"id\", use \"$id\" for schema ID')}};gS.default=Xz});var Zs=g(function(bS){Object.defineProperty(bS,\"__esModule\",{value:!0});bS.callRef=bS.getValidate=void 0;var ej=kn(),Ks=Be(),ee=N(),dr=Le(),Hs=oo(),Ft=B(),tj={keyword:\"$ref\",schemaType:\"string\",code(e){let{gen:t,schema:n,it:r}=e,{baseId:o,schemaEnv:s,validateName:i,opts:a,self:c}=r,{root:l}=s;if((n===\"#\"||n===\"#/\")&&o===l.baseId)return p();let u=Hs.resolveRef.call(c,l,o,n);if(u===void 0)throw new ej.default(r.opts.uriResolver,o,n);if(u instanceof Hs.SchemaEnv)return m(u);return d(u);function p(){if(s===l)return Ws(e,i,s,s.$async);let f=t.scopeValue(\"root\",{ref:l});return Ws(e,ee._`${f}.validate`,l,l.$async)}function m(f){let h=yS(e,f);Ws(e,h,f,f.$async)}function d(f){let h=t.scopeValue(\"schema\",a.code.source===!0?{ref:f,code:ee.stringify(f)}:{ref:f}),y=t.name(\"valid\"),_=e.subschema({schema:f,dataTypes:[],schemaPath:ee.nil,topSchemaRef:h,errSchemaPath:n},y);e.mergeEvaluated(_),e.ok(y)}}};function yS(e,t){let{gen:n}=e;return t.validate?n.scopeValue(\"validate\",{ref:t.validate}):ee._`${n.scopeValue(\"wrapper\",{ref:t})}.validate`}bS.getValidate=yS;function Ws(e,t,n,r){let{gen:o,it:s}=e,{allErrors:i,schemaEnv:a,opts:c}=s,l=c.passContext?dr.default.this:ee.nil;if(r)u();else p();function u(){if(!a.$async)throw Error(\"async schema referenced by sync schema\");let f=o.let(\"valid\");o.try(()=>{if(o.code(ee._`await ${Ks.callValidateCode(e,t,l)}`),d(t),!i)o.assign(f,!0)},(h)=>{if(o.if(ee._`!(${h} instanceof ${s.ValidationError})`,()=>o.throw(h)),m(h),!i)o.assign(f,!1)}),e.ok(f)}function p(){e.result(Ks.callValidateCode(e,t,l),()=>d(t),()=>m(t))}function m(f){let h=ee._`${f}.errors`;o.assign(dr.default.vErrors,ee._`${dr.default.vErrors} === null ? ${h} : ${dr.default.vErrors}.concat(${h})`),o.assign(dr.default.errors,ee._`${dr.default.vErrors}.length`)}function d(f){var h;if(!s.opts.unevaluated)return;let y=(h=n===null||n===void 0?void 0:n.validate)===null||h===void 0?void 0:h.evaluated;if(s.props!==!0)if(y&&!y.dynamicProps){if(y.props!==void 0)s.props=Ft.mergeEvaluated.props(o,y.props,s.props)}else{let _=o.var(\"props\",ee._`${f}.evaluated.props`);s.props=Ft.mergeEvaluated.props(o,_,s.props,ee.Name)}if(s.items!==!0)if(y&&!y.dynamicItems){if(y.items!==void 0)s.items=Ft.mergeEvaluated.items(o,y.items,s.items)}else{let _=o.var(\"items\",ee._`${f}.evaluated.items`);s.items=Ft.mergeEvaluated.items(o,_,s.items,ee.Name)}}}bS.callRef=Ws;bS.default=tj});var Nl=g(function(_S){Object.defineProperty(_S,\"__esModule\",{value:!0});var oj=hS(),sj=Zs(),ij=[\"$schema\",\"$id\",\"$defs\",\"$vocabulary\",{keyword:\"$comment\"},\"definitions\",oj.default,sj.default];_S.default=ij});var xS=g(function(wS){Object.defineProperty(wS,\"__esModule\",{value:!0});var Wt=N(),Jt=Wt.operators,Ys={maximum:{okStr:\"<=\",ok:Jt.LTE,fail:Jt.GT},minimum:{okStr:\">=\",ok:Jt.GTE,fail:Jt.LT},exclusiveMaximum:{okStr:\"<\",ok:Jt.LT,fail:Jt.GTE},exclusiveMinimum:{okStr:\">\",ok:Jt.GT,fail:Jt.LTE}},cj={message:({keyword:e,schemaCode:t})=>Wt.str`must be ${Ys[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>Wt._`{comparison: ${Ys[e].okStr}, limit: ${t}}`},lj={keyword:Object.keys(Ys),type:\"number\",schemaType:\"number\",$data:!0,error:cj,code(e){let{keyword:t,data:n,schemaCode:r}=e;e.fail$data(Wt._`${n} ${Ys[t].fail} ${r} || isNaN(${n})`)}};wS.default=lj});var IS=g(function(SS){Object.defineProperty(SS,\"__esModule\",{value:!0});var it=N(),dj={message:({schemaCode:e})=>it.str`must be multiple of ${e}`,params:({schemaCode:e})=>it._`{multipleOf: ${e}}`},pj={keyword:\"multipleOf\",type:\"number\",schemaType:\"number\",$data:!0,error:dj,code(e){let{gen:t,data:n,schemaCode:r,it:o}=e,s=o.opts.multipleOfPrecision,i=t.let(\"res\"),a=s?it._`Math.abs(Math.round(${i}) - ${i}) > 1e-${s}`:it._`${i} !== parseInt(${i})`;e.fail$data(it._`(${r} === 0 || (${i} = ${n}/${r}, ${a}))`)}};SS.default=pj});var TS=g(function(RS){Object.defineProperty(RS,\"__esModule\",{value:!0});function kS(e){let t=e.length,n=0,r=0,o;while(r<t)if(n++,o=e.charCodeAt(r++),o>=55296&&o<=56319&&r<t){if(o=e.charCodeAt(r),(o&64512)===56320)r++}return n}RS.default=kS;kS.code='require(\"ajv/dist/runtime/ucs2length\").default'});var ES=g(function(CS){Object.defineProperty(CS,\"__esModule\",{value:!0});var Ee=N(),AS=B(),gj=TS(),hj={message({keyword:e,schemaCode:t}){return Ee.str`must NOT have ${e===\"maxLength\"?\"more\":\"fewer\"} than ${t} characters`},params:({schemaCode:e})=>Ee._`{limit: ${e}}`},yj={keyword:[\"maxLength\",\"minLength\"],type:\"string\",schemaType:\"number\",$data:!0,error:hj,code(e){let{keyword:t,data:n,schemaCode:r,it:o}=e,s=t===\"maxLength\"?Ee.operators.GT:Ee.operators.LT,i=o.opts.unicode===!1?Ee._`${n}.length`:Ee._`${AS.useFunc(e.gen,gj.default)}(${n})`;e.fail$data(Ee._`${i} ${s} ${r}`)}};CS.default=yj});var MS=g(function($S){Object.defineProperty($S,\"__esModule\",{value:!0});var PS=Be(),OS=B(),Ve=N(),vj={message:({schemaCode:e})=>Ve.str`must match pattern \"${e}\"`,params:({schemaCode:e})=>Ve._`{pattern: ${e}}`},_j={keyword:\"pattern\",type:\"string\",schemaType:\"string\",$data:!0,error:vj,code(e){let{gen:t,data:n,$data:r,schema:o,schemaCode:s,it:i}=e,a=i.opts.unicodeRegExp?\"u\":\"\";if(r){let{regExp:c}=i.opts.code,l=c.code===\"new RegExp\"?Ve._`new RegExp`:OS.useFunc(t,c),u=t.let(\"valid\");t.try(()=>t.assign(u,Ve._`${l}(${s}, ${a}).test(${n})`),()=>t.assign(u,!1)),e.fail$data(Ve._`!${u}`)}else{let c=PS.usePattern(e,o);e.fail$data(Ve._`!${c}.test(${n})`)}}};$S.default=_j});var zS=g(function(qS){Object.defineProperty(qS,\"__esModule\",{value:!0});var at=N(),xj={message({keyword:e,schemaCode:t}){return at.str`must NOT have ${e===\"maxProperties\"?\"more\":\"fewer\"} than ${t} properties`},params:({schemaCode:e})=>at._`{limit: ${e}}`},Sj={keyword:[\"maxProperties\",\"minProperties\"],type:\"object\",schemaType:\"number\",$data:!0,error:xj,code(e){let{keyword:t,data:n,schemaCode:r}=e,o=t===\"maxProperties\"?at.operators.GT:at.operators.LT;e.fail$data(at._`Object.keys(${n}).length ${o} ${r}`)}};qS.default=Sj});var DS=g(function(NS){Object.defineProperty(NS,\"__esModule\",{value:!0});var ct=Be(),lt=N(),jS=B(),kj={message:({params:{missingProperty:e}})=>lt.str`must have required property '${e}'`,params:({params:{missingProperty:e}})=>lt._`{missingProperty: ${e}}`},Rj={keyword:\"required\",type:\"object\",schemaType:\"array\",$data:!0,error:kj,code(e){let{gen:t,schema:n,schemaCode:r,data:o,$data:s,it:i}=e,{opts:a}=i;if(!s&&n.length===0)return;let c=n.length>=a.loopRequired;if(i.allErrors)l();else u();if(a.strictRequired){let d=e.parentSchema.properties,{definedProperties:f}=e.it;for(let h of n)if((d===null||d===void 0?void 0:d[h])===void 0&&!f.has(h)){let y=i.schemaEnv.baseId+i.errSchemaPath,_=`required property \"${h}\" is not defined at \"${y}\" (strictRequired)`;jS.checkStrictMode(i,_,i.opts.strictRequired)}}function l(){if(c||s)e.block$data(lt.nil,p);else for(let d of n)ct.checkReportMissingProp(e,d)}function u(){let d=t.let(\"missing\");if(c||s){let f=t.let(\"valid\",!0);e.block$data(f,()=>m(d,f)),e.ok(f)}else t.if(ct.checkMissingProp(e,n,d)),ct.reportMissingProp(e,d),t.else()}function p(){t.forOf(\"prop\",r,(d)=>{e.setParams({missingProperty:d}),t.if(ct.noPropertyInData(t,o,d,a.ownProperties),()=>e.error())})}function m(d,f){e.setParams({missingProperty:d}),t.forOf(d,r,()=>{t.assign(f,ct.propertyInData(t,o,d,a.ownProperties)),t.if(lt.not(f),()=>{e.error(),t.break()})},lt.nil)}}};NS.default=Rj});var LS=g(function(US){Object.defineProperty(US,\"__esModule\",{value:!0});var ut=N(),Aj={message({keyword:e,schemaCode:t}){return ut.str`must NOT have ${e===\"maxItems\"?\"more\":\"fewer\"} than ${t} items`},params:({schemaCode:e})=>ut._`{limit: ${e}}`},Cj={keyword:[\"maxItems\",\"minItems\"],type:\"array\",schemaType:\"number\",$data:!0,error:Aj,code(e){let{keyword:t,data:n,schemaCode:r}=e,o=t===\"maxItems\"?ut.operators.GT:ut.operators.LT;e.fail$data(ut._`${n}.length ${o} ${r}`)}};US.default=Cj});var Xs=g(function(BS){Object.defineProperty(BS,\"__esModule\",{value:!0});var GS=kl();GS.code='require(\"ajv/dist/runtime/equal\").default';BS.default=GS});var JS=g(function(FS){Object.defineProperty(FS,\"__esModule\",{value:!0});var pr=to(),W=N(),VS=B(),Oj=Xs(),$j={message:({params:{i:e,j:t}})=>W.str`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>W._`{i: ${e}, j: ${t}}`},Mj={keyword:\"uniqueItems\",type:\"array\",schemaType:\"boolean\",$data:!0,error:$j,code(e){let{gen:t,data:n,$data:r,schema:o,parentSchema:s,schemaCode:i,it:a}=e;if(!r&&!o)return;let c=t.let(\"valid\"),l=s.items?pr.getSchemaTypes(s.items):[];e.block$data(c,u,W._`${i} === false`),e.ok(c);function u(){let f=t.let(\"i\",W._`${n}.length`),h=t.let(\"j\");e.setParams({i:f,j:h}),t.assign(c,!0),t.if(W._`${f} > 1`,()=>(p()?m:d)(f,h))}function p(){return l.length>0&&!l.some((f)=>f===\"object\"||f===\"array\")}function m(f,h){let y=t.name(\"item\"),_=pr.checkDataTypes(l,y,a.opts.strictNumbers,pr.DataType.Wrong),E=t.const(\"indices\",W._`{}`);t.for(W._`;${f}--;`,()=>{if(t.let(y,W._`${n}[${f}]`),t.if(_,W._`continue`),l.length>1)t.if(W._`typeof ${y} == \"string\"`,W._`${y} += \"_\"`);t.if(W._`typeof ${E}[${y}] == \"number\"`,()=>{t.assign(h,W._`${E}[${y}]`),e.error(),t.assign(c,!1).break()}).code(W._`${E}[${y}] = ${f}`)})}function d(f,h){let y=VS.useFunc(t,Oj.default),_=t.name(\"outer\");t.label(_).for(W._`;${f}--;`,()=>t.for(W._`${h} = ${f}; ${h}--;`,()=>t.if(W._`${y}(${n}[${f}], ${n}[${h}])`,()=>{e.error(),t.assign(c,!1).break(_)})))}}};FS.default=Mj});var HS=g(function(KS){Object.defineProperty(KS,\"__esModule\",{value:!0});var mr=N(),WS=B(),zj=Xs(),jj={message:\"must be equal to constant\",params:({schemaCode:e})=>mr._`{allowedValue: ${e}}`},Nj={keyword:\"const\",$data:!0,error:jj,code(e){let{gen:t,data:n,$data:r,schemaCode:o,schema:s}=e;if(r||s&&typeof s==\"object\")e.fail$data(mr._`!${WS.useFunc(t,zj.default)}(${n}, ${o})`);else e.fail(mr._`${s} !== ${n}`)}};KS.default=Nj});var XS=g(function(YS){Object.defineProperty(YS,\"__esModule\",{value:!0});var dt=N(),ZS=B(),Uj=Xs(),Lj={message:\"must be equal to one of the allowed values\",params:({schemaCode:e})=>dt._`{allowedValues: ${e}}`},Gj={keyword:\"enum\",schemaType:\"array\",$data:!0,error:Lj,code(e){let{gen:t,data:n,$data:r,schema:o,schemaCode:s,it:i}=e;if(!r&&o.length===0)throw Error(\"enum must have non-empty array\");let a=o.length>=i.opts.loopEnum,c,l=()=>c!==null&&c!==void 0?c:c=ZS.useFunc(t,Uj.default),u;if(a||r)u=t.let(\"valid\"),e.block$data(u,p);else{if(!Array.isArray(o))throw Error(\"ajv implementation error\");let d=t.const(\"vSchema\",s);u=dt.or(...o.map((f,h)=>m(d,h)))}e.pass(u);function p(){t.assign(u,!1),t.forOf(\"v\",s,(d)=>t.if(dt._`${l()}(${n}, ${d})`,()=>t.assign(u,!0).break()))}function m(d,f){let h=o[f];return typeof h===\"object\"&&h!==null?dt._`${l()}(${n}, ${d}[${f}])`:dt._`${n} === ${h}`}}};YS.default=Gj});var Dl=g(function(QS){Object.defineProperty(QS,\"__esModule\",{value:!0});var Vj=xS(),Fj=IS(),Jj=ES(),Wj=MS(),Kj=zS(),Hj=DS(),Zj=LS(),Yj=JS(),Xj=HS(),Qj=XS(),eN=[Vj.default,Fj.default,Jj.default,Wj.default,Kj.default,Hj.default,Zj.default,Yj.default,{keyword:\"type\",schemaType:[\"string\",\"array\"]},{keyword:\"nullable\",schemaType:\"boolean\"},Xj.default,Qj.default];QS.default=eN});var Ul=g(function(tI){Object.defineProperty(tI,\"__esModule\",{value:!0});tI.validateAdditionalItems=void 0;var Pe=N(),fr=B(),nN={message:({params:{len:e}})=>Pe.str`must NOT have more than ${e} items`,params:({params:{len:e}})=>Pe._`{limit: ${e}}`},rN={keyword:\"additionalItems\",type:\"array\",schemaType:[\"boolean\",\"object\"],before:\"uniqueItems\",error:nN,code(e){let{parentSchema:t,it:n}=e,{items:r}=t;if(!Array.isArray(r)){fr.checkStrictMode(n,'\"additionalItems\" is ignored when \"items\" is not an array of schemas');return}eI(e,r)}};function eI(e,t){let{gen:n,schema:r,data:o,keyword:s,it:i}=e;i.items=!0;let a=n.const(\"len\",Pe._`${o}.length`);if(r===!1)e.setParams({len:t.length}),e.pass(Pe._`${a} <= ${t.length}`);else if(typeof r==\"object\"&&!fr.alwaysValidSchema(i,r)){let l=n.var(\"valid\",Pe._`${a} <= ${t.length}`);n.if(Pe.not(l),()=>c(l)),e.ok(l)}function c(l){n.forRange(\"i\",t.length,a,(u)=>{if(e.subschema({keyword:s,dataProp:u,dataPropType:fr.Type.Num},l),!i.allErrors)n.if(Pe.not(l),()=>n.break())})}}tI.validateAdditionalItems=eI;tI.default=rN});var Ll=g(function(sI){Object.defineProperty(sI,\"__esModule\",{value:!0});sI.validateTuple=void 0;var Qs=N(),Kt=B(),rI=Be(),sN={keyword:\"items\",type:\"array\",schemaType:[\"object\",\"array\",\"boolean\"],before:\"uniqueItems\",code(e){let{schema:t,it:n}=e;if(Array.isArray(t))return oI(e,\"additionalItems\",t);if(n.items=!0,Kt.alwaysValidSchema(n,t))return;e.ok(rI.validateArray(e))}};function oI(e,t,n=e.schema){let{gen:r,parentSchema:o,data:s,keyword:i,it:a}=e;if(u(o),a.opts.unevaluated&&n.length&&a.items!==!0)a.items=Kt.mergeEvaluated.items(r,n.length,a.items);let c=r.name(\"valid\"),l=r.const(\"len\",Qs._`${s}.length`);n.forEach((p,m)=>{if(Kt.alwaysValidSchema(a,p))return;r.if(Qs._`${l} > ${m}`,()=>e.subschema({keyword:i,schemaProp:m,dataProp:m},c)),e.ok(c)});function u(p){let{opts:m,errSchemaPath:d}=a,f=n.length,h=f===p.minItems&&(f===p.maxItems||p[t]===!1);if(m.strictTuples&&!h){let y=`\"${i}\" is ${f}-tuple, but minItems or maxItems/${t} are not specified or different at path \"${d}\"`;Kt.checkStrictMode(a,y,m.strictTuples)}}}sI.validateTuple=oI;sI.default=sN});var lI=g(function(cI){Object.defineProperty(cI,\"__esModule\",{value:!0});var aI=Ll(),aN={keyword:\"prefixItems\",type:\"array\",schemaType:[\"array\"],before:\"uniqueItems\",code:(e)=>aI.validateTuple(e,\"items\")};cI.default=aN});var fI=g(function(mI){Object.defineProperty(mI,\"__esModule\",{value:!0});var ei=N(),uI=B(),dI=Be(),pI=Ul(),lN={message:({params:{len:e}})=>ei.str`must NOT have more than ${e} items`,params:({params:{len:e}})=>ei._`{limit: ${e}}`},uN={keyword:\"items\",type:\"array\",schemaType:[\"object\",\"boolean\"],before:\"uniqueItems\",error:lN,code(e){let{schema:t,parentSchema:n,it:r}=e,{prefixItems:o}=n;if(r.items=!0,uI.alwaysValidSchema(r,t))return;if(o)pI.validateAdditionalItems(e,o);else e.ok(dI.validateArray(e))}};mI.default=uN});var hI=g(function(gI){Object.defineProperty(gI,\"__esModule\",{value:!0});var ae=N(),Ht=B(),pN={message:({params:{min:e,max:t}})=>t===void 0?ae.str`must contain at least ${e} valid item(s)`:ae.str`must contain at least ${e} and no more than ${t} valid item(s)`,params:({params:{min:e,max:t}})=>t===void 0?ae._`{minContains: ${e}}`:ae._`{minContains: ${e}, maxContains: ${t}}`},mN={keyword:\"contains\",type:\"array\",schemaType:[\"object\",\"boolean\"],before:\"uniqueItems\",trackErrors:!0,error:pN,code(e){let{gen:t,schema:n,parentSchema:r,data:o,it:s}=e,i,a,{minContains:c,maxContains:l}=r;if(s.opts.next)i=c===void 0?1:c,a=l;else i=1;let u=t.const(\"len\",ae._`${o}.length`);if(e.setParams({min:i,max:a}),a===void 0&&i===0){Ht.checkStrictMode(s,'\"minContains\" == 0 without \"maxContains\": \"contains\" keyword ignored');return}if(a!==void 0&&i>a){Ht.checkStrictMode(s,'\"minContains\" > \"maxContains\" is always invalid'),e.fail();return}if(Ht.alwaysValidSchema(s,n)){let h=ae._`${u} >= ${i}`;if(a!==void 0)h=ae._`${h} && ${u} <= ${a}`;e.pass(h);return}s.items=!0;let p=t.name(\"valid\");if(a===void 0&&i===1)d(p,()=>t.if(p,()=>t.break()));else if(i===0){if(t.let(p,!0),a!==void 0)t.if(ae._`${o}.length > 0`,m)}else t.let(p,!1),m();e.result(p,()=>e.reset());function m(){let h=t.name(\"_valid\"),y=t.let(\"count\",0);d(h,()=>t.if(h,()=>f(y)))}function d(h,y){t.forRange(\"i\",0,u,(_)=>{e.subschema({keyword:\"contains\",dataProp:_,dataPropType:Ht.Type.Num,compositeRule:!0},h),y()})}function f(h){if(t.code(ae._`${h}++`),a===void 0)t.if(ae._`${h} >= ${i}`,()=>t.assign(p,!0).break());else if(t.if(ae._`${h} > ${a}`,()=>t.assign(p,!1).break()),i===1)t.assign(p,!0);else t.if(ae._`${h} >= ${i}`,()=>t.assign(p,!0))}}};gI.default=mN});var ti=g(function(_I){Object.defineProperty(_I,\"__esModule\",{value:!0});_I.validateSchemaDeps=_I.validatePropertyDeps=_I.error=void 0;var gr=N(),yI=B(),pt=Be();_I.error={message:({params:{property:e,depsCount:t,deps:n}})=>gr.str`must have ${t===1?\"property\":\"properties\"} ${n} when property ${e} is present`,params:({params:{property:e,depsCount:t,deps:n,missingProperty:r}})=>gr._`{property: ${e},\n missingProperty: ${r},\n depsCount: ${t},\n deps: ${n}}`};var gN={keyword:\"dependencies\",type:\"object\",schemaType:\"object\",error:_I.error,code(e){let[t,n]=hN(e);bI(e,t),vI(e,n)}};function hN({schema:e}){let t={},n={};for(let r in e){if(r===\"__proto__\")continue;let o=Array.isArray(e[r])?t:n;o[r]=e[r]}return[t,n]}function bI(e,t=e.schema){let{gen:n,data:r,it:o}=e;if(Object.keys(t).length===0)return;let s=n.let(\"missing\");for(let i in t){let a=t[i];if(a.length===0)continue;let c=pt.propertyInData(n,r,i,o.opts.ownProperties);if(e.setParams({property:i,depsCount:a.length,deps:a.join(\", \")}),o.allErrors)n.if(c,()=>{for(let l of a)pt.checkReportMissingProp(e,l)});else n.if(gr._`${c} && (${pt.checkMissingProp(e,a,s)})`),pt.reportMissingProp(e,s),n.else()}}_I.validatePropertyDeps=bI;function vI(e,t=e.schema){let{gen:n,data:r,keyword:o,it:s}=e,i=n.name(\"valid\");for(let a in t){if(yI.alwaysValidSchema(s,t[a]))continue;n.if(pt.propertyInData(n,r,a,s.opts.ownProperties),()=>{let c=e.subschema({keyword:o,schemaProp:a},i);e.mergeValidEvaluated(c,i)},()=>n.var(i,!0)),e.ok(i)}}_I.validateSchemaDeps=vI;_I.default=gN});var kI=g(function(II){Object.defineProperty(II,\"__esModule\",{value:!0});var ni=N(),SI=B(),vN={message:\"property name must be valid\",params:({params:e})=>ni._`{propertyName: ${e.propertyName}}`},_N={keyword:\"propertyNames\",type:\"object\",schemaType:[\"object\",\"boolean\"],error:vN,code(e){let{gen:t,schema:n,data:r,it:o}=e;if(SI.alwaysValidSchema(o,n))return;let s=t.name(\"valid\");t.forIn(\"key\",r,(i)=>{e.setParams({propertyName:i}),e.subschema({keyword:\"propertyNames\",data:i,dataTypes:[\"string\"],propertyName:i,compositeRule:!0},s),t.if(ni.not(s),()=>{if(e.error(!0),!o.allErrors)t.break()})}),e.ok(s)}};II.default=_N});var Gl=g(function(RI){Object.defineProperty(RI,\"__esModule\",{value:!0});var Zt=Be(),me=N(),xN=Le(),Yt=B(),SN={message:\"must NOT have additional properties\",params:({params:e})=>me._`{additionalProperty: ${e.additionalProperty}}`},IN={keyword:\"additionalProperties\",type:[\"object\"],schemaType:[\"boolean\",\"object\"],allowUndefined:!0,trackErrors:!0,error:SN,code(e){let{gen:t,schema:n,parentSchema:r,data:o,errsCount:s,it:i}=e;if(!s)throw Error(\"ajv implementation error\");let{allErrors:a,opts:c}=i;if(i.props=!0,c.removeAdditional!==\"all\"&&Yt.alwaysValidSchema(i,n))return;let l=Zt.allSchemaProperties(r.properties),u=Zt.allSchemaProperties(r.patternProperties);p(),e.ok(me._`${s} === ${xN.default.errors}`);function p(){t.forIn(\"key\",o,(y)=>{if(!l.length&&!u.length)f(y);else t.if(m(y),()=>f(y))})}function m(y){let _;if(l.length>8){let E=Yt.schemaRefOrVal(i,r.properties,\"properties\");_=Zt.isOwnProperty(t,E,y)}else if(l.length)_=me.or(...l.map((E)=>me._`${y} === ${E}`));else _=me.nil;if(u.length)_=me.or(_,...u.map((E)=>me._`${Zt.usePattern(e,E)}.test(${y})`));return me.not(_)}function d(y){t.code(me._`delete ${o}[${y}]`)}function f(y){if(c.removeAdditional===\"all\"||c.removeAdditional&&n===!1){d(y);return}if(n===!1){if(e.setParams({additionalProperty:y}),e.error(),!a)t.break();return}if(typeof n==\"object\"&&!Yt.alwaysValidSchema(i,n)){let _=t.name(\"valid\");if(c.removeAdditional===\"failing\")h(y,_,!1),t.if(me.not(_),()=>{e.reset(),d(y)});else if(h(y,_),!a)t.if(me.not(_),()=>t.break())}}function h(y,_,E){let T={keyword:\"additionalProperties\",dataProp:y,dataPropType:Yt.Type.Str};if(E===!1)Object.assign(T,{compositeRule:!0,createErrors:!1,allErrors:!1});e.subschema(T,_)}}};RI.default=IN});var EI=g(function(CI){Object.defineProperty(CI,\"__esModule\",{value:!0});var AI=In(),ri=Be(),hr=B(),TI=Gl(),RN={keyword:\"properties\",type:\"object\",schemaType:\"object\",code(e){let{gen:t,schema:n,parentSchema:r,data:o,it:s}=e;if(s.opts.removeAdditional===\"all\"&&r.additionalProperties===void 0)TI.default.code(new AI.KeywordCxt(s,TI.default,\"additionalProperties\"));let i=ri.allSchemaProperties(n);for(let p of i)s.definedProperties.add(p);if(s.opts.unevaluated&&i.length&&s.props!==!0)s.props=hr.mergeEvaluated.props(t,hr.toHash(i),s.props);let a=i.filter((p)=>!hr.alwaysValidSchema(s,n[p]));if(a.length===0)return;let c=t.name(\"valid\");for(let p of a){if(l(p))u(p);else{if(t.if(ri.propertyInData(t,o,p,s.opts.ownProperties)),u(p),!s.allErrors)t.else().var(c,!0);t.endIf()}e.it.definedProperties.add(p),e.ok(c)}function l(p){return s.opts.useDefaults&&!s.compositeRule&&n[p].default!==void 0}function u(p){e.subschema({keyword:\"properties\",schemaProp:p,dataProp:p},c)}}};CI.default=RN});var OI=g(function(PI){Object.defineProperty(PI,\"__esModule\",{value:!0});var oi=Be(),Xt=N(),si=B(),ii=B(),AN={keyword:\"patternProperties\",type:\"object\",schemaType:\"object\",code(e){let{gen:t,schema:n,data:r,parentSchema:o,it:s}=e,{opts:i}=s,a=oi.allSchemaProperties(n),c=a.filter((h)=>si.alwaysValidSchema(s,n[h]));if(a.length===0||c.length===a.length&&(!s.opts.unevaluated||s.props===!0))return;let l=i.strictSchema&&!i.allowMatchingProperties&&o.properties,u=t.name(\"valid\");if(s.props!==!0&&!(s.props instanceof Xt.Name))s.props=ii.evaluatedPropsToName(t,s.props);let{props:p}=s;m();function m(){for(let h of a){if(l)d(h);if(s.allErrors)f(h);else t.var(u,!0),f(h),t.if(u)}}function d(h){for(let y in l)if(new RegExp(h).test(y))si.checkStrictMode(s,`property ${y} matches pattern ${h} (use allowMatchingProperties)`)}function f(h){t.forIn(\"key\",r,(y)=>{t.if(Xt._`${oi.usePattern(e,h)}.test(${y})`,()=>{let _=c.includes(h);if(!_)e.subschema({keyword:\"patternProperties\",schemaProp:h,dataProp:y,dataPropType:ii.Type.Str},u);if(s.opts.unevaluated&&p!==!0)t.assign(Xt._`${p}[${y}]`,!0);else if(!_&&!s.allErrors)t.if(Xt.not(u),()=>t.break())})})}}};PI.default=AN});var qI=g(function(MI){Object.defineProperty(MI,\"__esModule\",{value:!0});var $I=B(),EN={keyword:\"not\",schemaType:[\"object\",\"boolean\"],trackErrors:!0,code(e){let{gen:t,schema:n,it:r}=e;if($I.alwaysValidSchema(r,n)){e.fail();return}let o=t.name(\"valid\");e.subschema({keyword:\"not\",compositeRule:!0,createErrors:!1,allErrors:!1},o),e.failResult(o,()=>e.reset(),()=>e.error())},error:{message:\"must NOT be valid\"}};MI.default=EN});var NI=g(function(jI){Object.defineProperty(jI,\"__esModule\",{value:!0});var zI=Be(),ON={keyword:\"anyOf\",schemaType:\"array\",trackErrors:!0,code:zI.validateUnion,error:{message:\"must match a schema in anyOf\"}};jI.default=ON});var LI=g(function(UI){Object.defineProperty(UI,\"__esModule\",{value:!0});var Qt=N(),DI=B(),MN={message:\"must match exactly one schema in oneOf\",params:({params:e})=>Qt._`{passingSchemas: ${e.passing}}`},qN={keyword:\"oneOf\",schemaType:\"array\",trackErrors:!0,error:MN,code(e){let{gen:t,schema:n,parentSchema:r,it:o}=e;if(!Array.isArray(n))throw Error(\"ajv implementation error\");if(o.opts.discriminator&&r.discriminator)return;let s=n,i=t.let(\"valid\",!1),a=t.let(\"passing\",null),c=t.name(\"_valid\");e.setParams({passing:a}),t.block(l),e.result(i,()=>e.reset(),()=>e.error(!0));function l(){s.forEach((u,p)=>{let m;if(DI.alwaysValidSchema(o,u))t.var(c,!0);else m=e.subschema({keyword:\"oneOf\",schemaProp:p,compositeRule:!0},c);if(p>0)t.if(Qt._`${c} && ${i}`).assign(i,!1).assign(a,Qt._`[${a}, ${p}]`).else();t.if(c,()=>{if(t.assign(i,!0),t.assign(a,p),m)e.mergeEvaluated(m,Qt.Name)})})}}};UI.default=qN});var VI=g(function(BI){Object.defineProperty(BI,\"__esModule\",{value:!0});var GI=B(),jN={keyword:\"allOf\",schemaType:\"array\",code(e){let{gen:t,schema:n,it:r}=e;if(!Array.isArray(n))throw Error(\"ajv implementation error\");let o=t.name(\"valid\");n.forEach((s,i)=>{if(GI.alwaysValidSchema(r,s))return;let a=e.subschema({keyword:\"allOf\",schemaProp:i},o);e.ok(o),e.mergeEvaluated(a)})}};BI.default=jN});var WI=g(function(JI){Object.defineProperty(JI,\"__esModule\",{value:!0});var en=N(),ai=B(),DN={message:({params:e})=>en.str`must match \"${e.ifClause}\" schema`,params:({params:e})=>en._`{failingKeyword: ${e.ifClause}}`},UN={keyword:\"if\",schemaType:[\"object\",\"boolean\"],trackErrors:!0,error:DN,code(e){let{gen:t,parentSchema:n,it:r}=e;if(n.then===void 0&&n.else===void 0)ai.checkStrictMode(r,'\"if\" without \"then\" and \"else\" is ignored');let o=FI(r,\"then\"),s=FI(r,\"else\");if(!o&&!s)return;let i=t.let(\"valid\",!0),a=t.name(\"_valid\");if(c(),e.reset(),o&&s){let u=t.let(\"ifClause\");e.setParams({ifClause:u}),t.if(a,l(\"then\",u),l(\"else\",u))}else if(o)t.if(a,l(\"then\"));else t.if(en.not(a),l(\"else\"));e.pass(i,()=>e.error(!0));function c(){let u=e.subschema({keyword:\"if\",compositeRule:!0,createErrors:!1,allErrors:!1},a);e.mergeEvaluated(u)}function l(u,p){return()=>{let m=e.subschema({keyword:u},a);if(t.assign(i,a),e.mergeValidEvaluated(m,i),p)t.assign(p,en._`${u}`);else e.setParams({ifClause:u})}}}};function FI(e,t){let n=e.schema[t];return n!==void 0&&!ai.alwaysValidSchema(e,n)}JI.default=UN});var ZI=g(function(HI){Object.defineProperty(HI,\"__esModule\",{value:!0});var KI=B(),GN={keyword:[\"then\",\"else\"],schemaType:[\"object\",\"boolean\"],code({keyword:e,parentSchema:t,it:n}){if(t.if===void 0)KI.checkStrictMode(n,`\"${e}\" without \"if\" is ignored`)}};HI.default=GN});var Bl=g(function(YI){Object.defineProperty(YI,\"__esModule\",{value:!0});var VN=Ul(),FN=lI(),JN=Ll(),WN=fI(),KN=hI(),HN=ti(),ZN=kI(),YN=Gl(),XN=EI(),QN=OI(),eD=qI(),tD=NI(),nD=LI(),rD=VI(),oD=WI(),sD=ZI();function iD(e=!1){let t=[eD.default,tD.default,nD.default,rD.default,oD.default,sD.default,ZN.default,YN.default,HN.default,XN.default,QN.default];if(e)t.push(FN.default,WN.default);else t.push(VN.default,JN.default);return t.push(KN.default),t}YI.default=iD});var QI=g(function(XI){Object.defineProperty(XI,\"__esModule\",{value:!0});var U=N(),cD={message:({schemaCode:e})=>U.str`must match format \"${e}\"`,params:({schemaCode:e})=>U._`{format: ${e}}`},lD={keyword:\"format\",type:[\"number\",\"string\"],schemaType:\"string\",$data:!0,error:cD,code(e,t){let{gen:n,data:r,$data:o,schema:s,schemaCode:i,it:a}=e,{opts:c,errSchemaPath:l,schemaEnv:u,self:p}=a;if(!c.validateFormats)return;if(o)m();else d();function m(){let f=n.scopeValue(\"formats\",{ref:p.formats,code:c.code.formats}),h=n.const(\"fDef\",U._`${f}[${i}]`),y=n.let(\"fType\"),_=n.let(\"format\");n.if(U._`typeof ${h} == \"object\" && !(${h} instanceof RegExp)`,()=>n.assign(y,U._`${h}.type || \"string\"`).assign(_,U._`${h}.validate`),()=>n.assign(y,U._`\"string\"`).assign(_,h)),e.fail$data(U.or(E(),T()));function E(){if(c.strictSchema===!1)return U.nil;return U._`${i} && !${_}`}function T(){let A=u.$async?U._`(${h}.async ? await ${_}(${r}) : ${_}(${r}))`:U._`${_}(${r})`,x=U._`(typeof ${_} == \"function\" ? ${A} : ${_}.test(${r}))`;return U._`${_} && ${_} !== true && ${y} === ${t} && !${x}`}}function d(){let f=p.formats[s];if(!f){E();return}if(f===!0)return;let[h,y,_]=T(f);if(h===t)e.pass(A());function E(){if(c.strictSchema===!1){p.logger.warn(x());return}throw Error(x());function x(){return`unknown format \"${s}\" ignored in schema at path \"${l}\"`}}function T(x){let K=x instanceof RegExp?U.regexpCode(x):c.code.formats?U._`${c.code.formats}${U.getProperty(s)}`:void 0,C=n.scopeValue(\"formats\",{key:s,ref:x,code:K});if(typeof x==\"object\"&&!(x instanceof RegExp))return[x.type||\"string\",x.validate,U._`${C}.validate`];return[\"string\",x,C]}function A(){if(typeof f==\"object\"&&!(f instanceof RegExp)&&f.async){if(!u.$async)throw Error(\"async format in sync schema\");return U._`await ${_}(${r})`}return typeof y==\"function\"?U._`${_}(${r})`:U._`${_}.test(${r})`}}}};XI.default=lD});var Vl=g(function(ek){Object.defineProperty(ek,\"__esModule\",{value:!0});var dD=QI(),pD=[dD.default];ek.default=pD});var Fl=g(function(tk){Object.defineProperty(tk,\"__esModule\",{value:!0});tk.contentVocabulary=tk.metadataVocabulary=void 0;tk.metadataVocabulary=[\"title\",\"description\",\"default\",\"deprecated\",\"readOnly\",\"writeOnly\",\"examples\"];tk.contentVocabulary=[\"contentMediaType\",\"contentEncoding\",\"contentSchema\"]});var Jl=g(function(rk){Object.defineProperty(rk,\"__esModule\",{value:!0});var gD=Nl(),hD=Dl(),yD=Bl(),bD=Vl(),ci=Fl(),vD=[gD.default,hD.default,(0,yD.default)(),bD.default,ci.metadataVocabulary,ci.contentVocabulary];rk.default=vD});var ak=g(function(sk){Object.defineProperty(sk,\"__esModule\",{value:!0});sk.DiscrError=void 0;var ok;(function(e){e.Tag=\"tag\",e.Mapping=\"mapping\"})(ok||(sk.DiscrError=ok={}))});var ui=g(function(lk){Object.defineProperty(lk,\"__esModule\",{value:!0});var Fe=N(),yr=ak(),li=oo(),wD=kn(),ck=B(),xD={message:({params:{discrError:e,tagName:t}})=>e===yr.DiscrError.Tag?`tag \"${t}\" must be string`:`value of tag \"${t}\" must be in oneOf`,params:({params:{discrError:e,tag:t,tagName:n}})=>Fe._`{error: ${e}, tag: ${n}, tagValue: ${t}}`},SD={keyword:\"discriminator\",type:\"object\",schemaType:\"object\",error:xD,code(e){let{gen:t,data:n,schema:r,parentSchema:o,it:s}=e,{oneOf:i}=o;if(!s.opts.discriminator)throw Error(\"discriminator: requires discriminator option\");let a=r.propertyName;if(typeof a!=\"string\")throw Error(\"discriminator: requires propertyName\");if(r.mapping)throw Error(\"discriminator: mapping is not supported\");if(!i)throw Error(\"discriminator: requires oneOf keyword\");let c=t.let(\"valid\",!1),l=t.const(\"tag\",Fe._`${n}${Fe.getProperty(a)}`);t.if(Fe._`typeof ${l} == \"string\"`,()=>u(),()=>e.error(!1,{discrError:yr.DiscrError.Tag,tag:l,tagName:a})),e.ok(c);function u(){let d=m();t.if(!1);for(let f in d)t.elseIf(Fe._`${l} === ${f}`),t.assign(c,p(d[f]));t.else(),e.error(!1,{discrError:yr.DiscrError.Mapping,tag:l,tagName:a}),t.endIf()}function p(d){let f=t.name(\"valid\"),h=e.subschema({keyword:\"oneOf\",schemaProp:d},f);return e.mergeEvaluated(h,Fe.Name),f}function m(){var d;let f={},h=_(o),y=!0;for(let A=0;A<i.length;A++){let x=i[A];if((x===null||x===void 0?void 0:x.$ref)&&!ck.schemaHasRulesButRef(x,s.self.RULES)){let C=x.$ref;if(x=li.resolveRef.call(s.self,s.schemaEnv.root,s.baseId,C),x instanceof li.SchemaEnv)x=x.schema;if(x===void 0)throw new wD.default(s.opts.uriResolver,s.baseId,C)}let K=(d=x===null||x===void 0?void 0:x.properties)===null||d===void 0?void 0:d[a];if(typeof K!=\"object\")throw Error(`discriminator: oneOf subschemas (or referenced schemas) must have \"properties/${a}\"`);y=y&&(h||_(x)),E(K,A)}if(!y)throw Error(`discriminator: \"${a}\" must be required`);return f;function _({required:A}){return Array.isArray(A)&&A.includes(a)}function E(A,x){if(A.const)T(A.const,x);else if(A.enum)for(let K of A.enum)T(K,x);else throw Error(`discriminator: \"properties/${a}\" must have \"const\" or \"enum\"`)}function T(A,x){if(typeof A!=\"string\"||A in f)throw Error(`discriminator: \"${a}\" values must be unique strings`);f[A]=x}}}};lk.default=SD});var uk=g(function(u6,kD){kD.exports={$schema:\"http://json-schema.org/draft-07/schema#\",$id:\"http://json-schema.org/draft-07/schema#\",title:\"Core schema meta-schema\",definitions:{schemaArray:{type:\"array\",minItems:1,items:{$ref:\"#\"}},nonNegativeInteger:{type:\"integer\",minimum:0},nonNegativeIntegerDefault0:{allOf:[{$ref:\"#/definitions/nonNegativeInteger\"},{default:0}]},simpleTypes:{enum:[\"array\",\"boolean\",\"integer\",\"null\",\"number\",\"object\",\"string\"]},stringArray:{type:\"array\",items:{type:\"string\"},uniqueItems:!0,default:[]}},type:[\"object\",\"boolean\"],properties:{$id:{type:\"string\",format:\"uri-reference\"},$schema:{type:\"string\",format:\"uri\"},$ref:{type:\"string\",format:\"uri-reference\"},$comment:{type:\"string\"},title:{type:\"string\"},description:{type:\"string\"},default:!0,readOnly:{type:\"boolean\",default:!1},examples:{type:\"array\",items:!0},multipleOf:{type:\"number\",exclusiveMinimum:0},maximum:{type:\"number\"},exclusiveMaximum:{type:\"number\"},minimum:{type:\"number\"},exclusiveMinimum:{type:\"number\"},maxLength:{$ref:\"#/definitions/nonNegativeInteger\"},minLength:{$ref:\"#/definitions/nonNegativeIntegerDefault0\"},pattern:{type:\"string\",format:\"regex\"},additionalItems:{$ref:\"#\"},items:{anyOf:[{$ref:\"#\"},{$ref:\"#/definitions/schemaArray\"}],default:!0},maxItems:{$ref:\"#/definitions/nonNegativeInteger\"},minItems:{$ref:\"#/definitions/nonNegativeIntegerDefault0\"},uniqueItems:{type:\"boolean\",default:!1},contains:{$ref:\"#\"},maxProperties:{$ref:\"#/definitions/nonNegativeInteger\"},minProperties:{$ref:\"#/definitions/nonNegativeIntegerDefault0\"},required:{$ref:\"#/definitions/stringArray\"},additionalProperties:{$ref:\"#\"},definitions:{type:\"object\",additionalProperties:{$ref:\"#\"},default:{}},properties:{type:\"object\",additionalProperties:{$ref:\"#\"},default:{}},patternProperties:{type:\"object\",additionalProperties:{$ref:\"#\"},propertyNames:{format:\"regex\"},default:{}},dependencies:{type:\"object\",additionalProperties:{anyOf:[{$ref:\"#\"},{$ref:\"#/definitions/stringArray\"}]}},propertyNames:{$ref:\"#\"},const:!0,enum:{type:\"array\",items:!0,minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:\"#/definitions/simpleTypes\"},{type:\"array\",items:{$ref:\"#/definitions/simpleTypes\"},minItems:1,uniqueItems:!0}]},format:{type:\"string\"},contentMediaType:{type:\"string\"},contentEncoding:{type:\"string\"},if:{$ref:\"#\"},then:{$ref:\"#\"},else:{$ref:\"#\"},allOf:{$ref:\"#/definitions/schemaArray\"},anyOf:{$ref:\"#/definitions/schemaArray\"},oneOf:{$ref:\"#/definitions/schemaArray\"},not:{$ref:\"#\"}},default:!0}});var pk=g(function(Oe,Wl){Object.defineProperty(Oe,\"__esModule\",{value:!0});Oe.MissingRefError=Oe.ValidationError=Oe.CodeGen=Oe.Name=Oe.nil=Oe.stringify=Oe.str=Oe._=Oe.KeywordCxt=Oe.Ajv=void 0;var RD=Js(),TD=Jl(),AD=ui(),dk=uk(),CD=[\"/properties\"],di=\"http://json-schema.org/draft-07/schema\";class io extends RD.default{_addVocabularies(){if(super._addVocabularies(),TD.default.forEach((e)=>this.addVocabulary(e)),this.opts.discriminator)this.addKeyword(AD.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let e=this.opts.$data?this.$dataMetaSchema(dk,CD):dk;this.addMetaSchema(e,di,!1),this.refs[\"http://json-schema.org/schema\"]=di}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(di)?di:void 0)}}Oe.Ajv=io;Wl.exports=Oe=io;Wl.exports.Ajv=io;Object.defineProperty(Oe,\"__esModule\",{value:!0});Oe.default=io;var ED=In();Object.defineProperty(Oe,\"KeywordCxt\",{enumerable:!0,get:function(){return ED.KeywordCxt}});var br=N();Object.defineProperty(Oe,\"_\",{enumerable:!0,get:function(){return br._}});Object.defineProperty(Oe,\"str\",{enumerable:!0,get:function(){return br.str}});Object.defineProperty(Oe,\"stringify\",{enumerable:!0,get:function(){return br.stringify}});Object.defineProperty(Oe,\"nil\",{enumerable:!0,get:function(){return br.nil}});Object.defineProperty(Oe,\"Name\",{enumerable:!0,get:function(){return br.Name}});Object.defineProperty(Oe,\"CodeGen\",{enumerable:!0,get:function(){return br.CodeGen}});var PD=ar();Object.defineProperty(Oe,\"ValidationError\",{enumerable:!0,get:function(){return PD.default}});var OD=kn();Object.defineProperty(Oe,\"MissingRefError\",{enumerable:!0,get:function(){return OD.default}})});var Kl=g(function(gk){Object.defineProperty(gk,\"__esModule\",{value:!0});gk.dynamicAnchor=void 0;var vr=N(),qD=Le(),pi=oo(),mk=Zs(),zD={keyword:\"$dynamicAnchor\",schemaType:\"string\",code:(e)=>fk(e,e.schema)};function fk(e,t){let{gen:n,it:r}=e;r.schemaEnv.root.dynamicAnchors[t]=!0;let o=vr._`${qD.default.dynamicAnchors}${vr.getProperty(t)}`,s=r.errSchemaPath===\"#\"?r.validateName:jD(e);n.if(vr._`!${o}`,()=>n.assign(o,s))}gk.dynamicAnchor=fk;function jD(e){let{schemaEnv:t,schema:n,self:r}=e.it,{root:o,baseId:s,localRefs:i,meta:a}=t.root,{schemaId:c}=r.opts,l=new pi.SchemaEnv({schema:n,schemaId:c,root:o,baseId:s,localRefs:i,meta:a});return pi.compileSchema.call(r,l),mk.getValidate(e,l)}gk.default=zD});var Hl=g(function(bk){Object.defineProperty(bk,\"__esModule\",{value:!0});bk.dynamicRef=void 0;var mi=N(),DD=Le(),fi=Zs(),UD={keyword:\"$dynamicRef\",schemaType:\"string\",code:(e)=>yk(e,e.schema)};function yk(e,t){let{gen:n,keyword:r,it:o}=e;if(t[0]!==\"#\")throw Error(`\"${r}\" only supports hash fragment reference`);let s=t.slice(1);if(o.allErrors)i();else{let c=n.let(\"valid\",!1);i(c),e.ok(c)}function i(c){if(o.schemaEnv.root.dynamicAnchors[s]){let l=n.let(\"_v\",mi._`${DD.default.dynamicAnchors}${mi.getProperty(s)}`);n.if(l,a(l,c),a(o.validateName,c))}else a(o.validateName,c)()}function a(c,l){return l?()=>n.block(()=>{fi.callRef(e,c),n.let(l,!0)}):()=>fi.callRef(e,c)}}bk.dynamicRef=yk;bk.default=UD});var Sk=g(function(xk){Object.defineProperty(xk,\"__esModule\",{value:!0});var _k=Kl(),wk=B(),GD={keyword:\"$recursiveAnchor\",schemaType:\"boolean\",code(e){if(e.schema)_k.dynamicAnchor(e,\"\");else wk.checkStrictMode(e.it,\"$recursiveAnchor: false is ignored\")}};xk.default=GD});var Rk=g(function(kk){Object.defineProperty(kk,\"__esModule\",{value:!0});var Ik=Hl(),VD={keyword:\"$recursiveRef\",schemaType:\"string\",code:(e)=>Ik.dynamicRef(e,e.schema)};kk.default=VD});var Zl=g(function(Tk){Object.defineProperty(Tk,\"__esModule\",{value:!0});var JD=Kl(),WD=Hl(),KD=Sk(),HD=Rk(),ZD=[JD.default,WD.default,KD.default,HD.default];Tk.default=ZD});var Ck=g(function(Ak){Object.defineProperty(Ak,\"__esModule\",{value:!0});var gi=ti(),XD={keyword:\"dependentRequired\",type:\"object\",schemaType:\"object\",error:gi.error,code:(e)=>gi.validatePropertyDeps(e)};Ak.default=XD});var Ok=g(function(Pk){Object.defineProperty(Pk,\"__esModule\",{value:!0});var Ek=ti(),eU={keyword:\"dependentSchemas\",type:\"object\",schemaType:\"object\",code:(e)=>Ek.validateSchemaDeps(e)};Pk.default=eU});var qk=g(function(Mk){Object.defineProperty(Mk,\"__esModule\",{value:!0});var $k=B(),nU={keyword:[\"maxContains\",\"minContains\"],type:\"array\",schemaType:\"number\",code({keyword:e,parentSchema:t,it:n}){if(t.contains===void 0)$k.checkStrictMode(n,`\"${e}\" without \"contains\" is ignored`)}};Mk.default=nU});var Yl=g(function(zk){Object.defineProperty(zk,\"__esModule\",{value:!0});var oU=Ck(),sU=Ok(),iU=qk(),aU=[oU.default,sU.default,iU.default];zk.default=aU});var Nk=g(function(jk){Object.defineProperty(jk,\"__esModule\",{value:!0});var Se=N(),hi=B(),lU=Le(),uU={message:\"must NOT have unevaluated properties\",params:({params:e})=>Se._`{unevaluatedProperty: ${e.unevaluatedProperty}}`},dU={keyword:\"unevaluatedProperties\",type:\"object\",schemaType:[\"boolean\",\"object\"],trackErrors:!0,error:uU,code(e){let{gen:t,schema:n,data:r,errsCount:o,it:s}=e;if(!o)throw Error(\"ajv implementation error\");let{allErrors:i,props:a}=s;if(a instanceof Se.Name)t.if(Se._`${a} !== true`,()=>t.forIn(\"key\",r,(p)=>t.if(l(a,p),()=>c(p))));else if(a!==!0)t.forIn(\"key\",r,(p)=>a===void 0?c(p):t.if(u(a,p),()=>c(p)));s.props=!0,e.ok(Se._`${o} === ${lU.default.errors}`);function c(p){if(n===!1){if(e.setParams({unevaluatedProperty:p}),e.error(),!i)t.break();return}if(!hi.alwaysValidSchema(s,n)){let m=t.name(\"valid\");if(e.subschema({keyword:\"unevaluatedProperties\",dataProp:p,dataPropType:hi.Type.Str},m),!i)t.if(Se.not(m),()=>t.break())}}function l(p,m){return Se._`!${p} || !${p}[${m}]`}function u(p,m){let d=[];for(let f in p)if(p[f]===!0)d.push(Se._`${m} !== ${f}`);return Se.and(...d)}}};jk.default=dU});var Uk=g(function(Dk){Object.defineProperty(Dk,\"__esModule\",{value:!0});var $e=N(),yi=B(),mU={message:({params:{len:e}})=>$e.str`must NOT have more than ${e} items`,params:({params:{len:e}})=>$e._`{limit: ${e}}`},fU={keyword:\"unevaluatedItems\",type:\"array\",schemaType:[\"boolean\",\"object\"],error:mU,code(e){let{gen:t,schema:n,data:r,it:o}=e,s=o.items||0;if(s===!0)return;let i=t.const(\"len\",$e._`${r}.length`);if(n===!1)e.setParams({len:s}),e.fail($e._`${i} > ${s}`);else if(typeof n==\"object\"&&!yi.alwaysValidSchema(o,n)){let c=t.var(\"valid\",$e._`${i} <= ${s}`);t.if($e.not(c),()=>a(c,s)),e.ok(c)}o.items=!0;function a(c,l){t.forRange(\"i\",l,i,(u)=>{if(e.subschema({keyword:\"unevaluatedItems\",dataProp:u,dataPropType:yi.Type.Num},c),!o.allErrors)t.if($e.not(c),()=>t.break())})}}};Dk.default=fU});var Xl=g(function(Lk){Object.defineProperty(Lk,\"__esModule\",{value:!0});var hU=Nk(),yU=Uk(),bU=[hU.default,yU.default];Lk.default=bU});var Gk=g(function(P6,_U){_U.exports={$schema:\"https://json-schema.org/draft/2019-09/schema\",$id:\"https://json-schema.org/draft/2019-09/schema\",$vocabulary:{\"https://json-schema.org/draft/2019-09/vocab/core\":!0,\"https://json-schema.org/draft/2019-09/vocab/applicator\":!0,\"https://json-schema.org/draft/2019-09/vocab/validation\":!0,\"https://json-schema.org/draft/2019-09/vocab/meta-data\":!0,\"https://json-schema.org/draft/2019-09/vocab/format\":!1,\"https://json-schema.org/draft/2019-09/vocab/content\":!0},$recursiveAnchor:!0,title:\"Core and Validation specifications meta-schema\",allOf:[{$ref:\"meta/core\"},{$ref:\"meta/applicator\"},{$ref:\"meta/validation\"},{$ref:\"meta/meta-data\"},{$ref:\"meta/format\"},{$ref:\"meta/content\"}],type:[\"object\",\"boolean\"],properties:{definitions:{$comment:\"While no longer an official keyword as it is replaced by $defs, this keyword is retained in the meta-schema to prevent incompatible extensions as it remains in common use.\",type:\"object\",additionalProperties:{$recursiveRef:\"#\"},default:{}},dependencies:{$comment:'\"dependencies\" is no longer a keyword, but schema authors should avoid redefining it to facilitate a smooth transition to \"dependentSchemas\" and \"dependentRequired\"',type:\"object\",additionalProperties:{anyOf:[{$recursiveRef:\"#\"},{$ref:\"meta/validation#/$defs/stringArray\"}]}}}}});var Bk=g(function(O6,wU){wU.exports={$schema:\"https://json-schema.org/draft/2019-09/schema\",$id:\"https://json-schema.org/draft/2019-09/meta/applicator\",$vocabulary:{\"https://json-schema.org/draft/2019-09/vocab/applicator\":!0},$recursiveAnchor:!0,title:\"Applicator vocabulary meta-schema\",type:[\"object\",\"boolean\"],properties:{additionalItems:{$recursiveRef:\"#\"},unevaluatedItems:{$recursiveRef:\"#\"},items:{anyOf:[{$recursiveRef:\"#\"},{$ref:\"#/$defs/schemaArray\"}]},contains:{$recursiveRef:\"#\"},additionalProperties:{$recursiveRef:\"#\"},unevaluatedProperties:{$recursiveRef:\"#\"},properties:{type:\"object\",additionalProperties:{$recursiveRef:\"#\"},default:{}},patternProperties:{type:\"object\",additionalProperties:{$recursiveRef:\"#\"},propertyNames:{format:\"regex\"},default:{}},dependentSchemas:{type:\"object\",additionalProperties:{$recursiveRef:\"#\"}},propertyNames:{$recursiveRef:\"#\"},if:{$recursiveRef:\"#\"},then:{$recursiveRef:\"#\"},else:{$recursiveRef:\"#\"},allOf:{$ref:\"#/$defs/schemaArray\"},anyOf:{$ref:\"#/$defs/schemaArray\"},oneOf:{$ref:\"#/$defs/schemaArray\"},not:{$recursiveRef:\"#\"}},$defs:{schemaArray:{type:\"array\",minItems:1,items:{$recursiveRef:\"#\"}}}}});var Vk=g(function($6,xU){xU.exports={$schema:\"https://json-schema.org/draft/2019-09/schema\",$id:\"https://json-schema.org/draft/2019-09/meta/content\",$vocabulary:{\"https://json-schema.org/draft/2019-09/vocab/content\":!0},$recursiveAnchor:!0,title:\"Content vocabulary meta-schema\",type:[\"object\",\"boolean\"],properties:{contentMediaType:{type:\"string\"},contentEncoding:{type:\"string\"},contentSchema:{$recursiveRef:\"#\"}}}});var Fk=g(function(M6,SU){SU.exports={$schema:\"https://json-schema.org/draft/2019-09/schema\",$id:\"https://json-schema.org/draft/2019-09/meta/core\",$vocabulary:{\"https://json-schema.org/draft/2019-09/vocab/core\":!0},$recursiveAnchor:!0,title:\"Core vocabulary meta-schema\",type:[\"object\",\"boolean\"],properties:{$id:{type:\"string\",format:\"uri-reference\",$comment:\"Non-empty fragments not allowed.\",pattern:\"^[^#]*#?$\"},$schema:{type:\"string\",format:\"uri\"},$anchor:{type:\"string\",pattern:\"^[A-Za-z][-A-Za-z0-9.:_]*$\"},$ref:{type:\"string\",format:\"uri-reference\"},$recursiveRef:{type:\"string\",format:\"uri-reference\"},$recursiveAnchor:{type:\"boolean\",default:!1},$vocabulary:{type:\"object\",propertyNames:{type:\"string\",format:\"uri\"},additionalProperties:{type:\"boolean\"}},$comment:{type:\"string\"},$defs:{type:\"object\",additionalProperties:{$recursiveRef:\"#\"},default:{}}}}});var Jk=g(function(q6,IU){IU.exports={$schema:\"https://json-schema.org/draft/2019-09/schema\",$id:\"https://json-schema.org/draft/2019-09/meta/format\",$vocabulary:{\"https://json-schema.org/draft/2019-09/vocab/format\":!0},$recursiveAnchor:!0,title:\"Format vocabulary meta-schema\",type:[\"object\",\"boolean\"],properties:{format:{type:\"string\"}}}});var Wk=g(function(z6,kU){kU.exports={$schema:\"https://json-schema.org/draft/2019-09/schema\",$id:\"https://json-schema.org/draft/2019-09/meta/meta-data\",$vocabulary:{\"https://json-schema.org/draft/2019-09/vocab/meta-data\":!0},$recursiveAnchor:!0,title:\"Meta-data vocabulary meta-schema\",type:[\"object\",\"boolean\"],properties:{title:{type:\"string\"},description:{type:\"string\"},default:!0,deprecated:{type:\"boolean\",default:!1},readOnly:{type:\"boolean\",default:!1},writeOnly:{type:\"boolean\",default:!1},examples:{type:\"array\",items:!0}}}});var Kk=g(function(j6,RU){RU.exports={$schema:\"https://json-schema.org/draft/2019-09/schema\",$id:\"https://json-schema.org/draft/2019-09/meta/validation\",$vocabulary:{\"https://json-schema.org/draft/2019-09/vocab/validation\":!0},$recursiveAnchor:!0,title:\"Validation vocabulary meta-schema\",type:[\"object\",\"boolean\"],properties:{multipleOf:{type:\"number\",exclusiveMinimum:0},maximum:{type:\"number\"},exclusiveMaximum:{type:\"number\"},minimum:{type:\"number\"},exclusiveMinimum:{type:\"number\"},maxLength:{$ref:\"#/$defs/nonNegativeInteger\"},minLength:{$ref:\"#/$defs/nonNegativeIntegerDefault0\"},pattern:{type:\"string\",format:\"regex\"},maxItems:{$ref:\"#/$defs/nonNegativeInteger\"},minItems:{$ref:\"#/$defs/nonNegativeIntegerDefault0\"},uniqueItems:{type:\"boolean\",default:!1},maxContains:{$ref:\"#/$defs/nonNegativeInteger\"},minContains:{$ref:\"#/$defs/nonNegativeInteger\",default:1},maxProperties:{$ref:\"#/$defs/nonNegativeInteger\"},minProperties:{$ref:\"#/$defs/nonNegativeIntegerDefault0\"},required:{$ref:\"#/$defs/stringArray\"},dependentRequired:{type:\"object\",additionalProperties:{$ref:\"#/$defs/stringArray\"}},const:!0,enum:{type:\"array\",items:!0},type:{anyOf:[{$ref:\"#/$defs/simpleTypes\"},{type:\"array\",items:{$ref:\"#/$defs/simpleTypes\"},minItems:1,uniqueItems:!0}]}},$defs:{nonNegativeInteger:{type:\"integer\",minimum:0},nonNegativeIntegerDefault0:{$ref:\"#/$defs/nonNegativeInteger\",default:0},simpleTypes:{enum:[\"array\",\"boolean\",\"integer\",\"null\",\"number\",\"object\",\"string\"]},stringArray:{type:\"array\",items:{type:\"string\"},uniqueItems:!0,default:[]}}}});var Zk=g(function(Hk){Object.defineProperty(Hk,\"__esModule\",{value:!0});var TU=Gk(),AU=Bk(),CU=Vk(),EU=Fk(),PU=Jk(),OU=Wk(),$U=Kk(),MU=[\"/properties\"];function qU(e){return[TU,AU,CU,EU,t(this,PU),OU,t(this,$U)].forEach((n)=>this.addMetaSchema(n,void 0,!1)),this;function t(n,r){return e?n.$dataMetaSchema(r,MU):r}}Hk.default=qU});var Yk=g(function(Me,eu){Object.defineProperty(Me,\"__esModule\",{value:!0});Me.MissingRefError=Me.ValidationError=Me.CodeGen=Me.Name=Me.nil=Me.stringify=Me.str=Me._=Me.KeywordCxt=Me.Ajv2019=void 0;var jU=Js(),NU=Jl(),DU=Zl(),UU=Yl(),LU=Xl(),GU=ui(),BU=Zk(),Ql=\"https://json-schema.org/draft/2019-09/schema\";class ao extends jU.default{constructor(e={}){super({...e,dynamicRef:!0,next:!0,unevaluated:!0})}_addVocabularies(){if(super._addVocabularies(),this.addVocabulary(DU.default),NU.default.forEach((e)=>this.addVocabulary(e)),this.addVocabulary(UU.default),this.addVocabulary(LU.default),this.opts.discriminator)this.addKeyword(GU.default)}_addDefaultMetaSchema(){super._addDefaultMetaSchema();let{$data:e,meta:t}=this.opts;if(!t)return;BU.default.call(this,e),this.refs[\"http://json-schema.org/schema\"]=Ql}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(Ql)?Ql:void 0)}}Me.Ajv2019=ao;eu.exports=Me=ao;eu.exports.Ajv2019=ao;Object.defineProperty(Me,\"__esModule\",{value:!0});Me.default=ao;var VU=In();Object.defineProperty(Me,\"KeywordCxt\",{enumerable:!0,get:function(){return VU.KeywordCxt}});var _r=N();Object.defineProperty(Me,\"_\",{enumerable:!0,get:function(){return _r._}});Object.defineProperty(Me,\"str\",{enumerable:!0,get:function(){return _r.str}});Object.defineProperty(Me,\"stringify\",{enumerable:!0,get:function(){return _r.stringify}});Object.defineProperty(Me,\"nil\",{enumerable:!0,get:function(){return _r.nil}});Object.defineProperty(Me,\"Name\",{enumerable:!0,get:function(){return _r.Name}});Object.defineProperty(Me,\"CodeGen\",{enumerable:!0,get:function(){return _r.CodeGen}});var FU=ar();Object.defineProperty(Me,\"ValidationError\",{enumerable:!0,get:function(){return FU.default}});var JU=kn();Object.defineProperty(Me,\"MissingRefError\",{enumerable:!0,get:function(){return JU.default}})});var Qk=g(function(Xk){Object.defineProperty(Xk,\"__esModule\",{value:!0});var HU=Nl(),ZU=Dl(),YU=Bl(),XU=Zl(),QU=Yl(),eL=Xl(),tL=Vl(),bi=Fl(),nL=[XU.default,HU.default,ZU.default,(0,YU.default)(!0),tL.default,bi.metadataVocabulary,bi.contentVocabulary,QU.default,eL.default];Xk.default=nL});var eR=g(function(K6,oL){oL.exports={$schema:\"https://json-schema.org/draft/2020-12/schema\",$id:\"https://json-schema.org/draft/2020-12/schema\",$vocabulary:{\"https://json-schema.org/draft/2020-12/vocab/core\":!0,\"https://json-schema.org/draft/2020-12/vocab/applicator\":!0,\"https://json-schema.org/draft/2020-12/vocab/unevaluated\":!0,\"https://json-schema.org/draft/2020-12/vocab/validation\":!0,\"https://json-schema.org/draft/2020-12/vocab/meta-data\":!0,\"https://json-schema.org/draft/2020-12/vocab/format-annotation\":!0,\"https://json-schema.org/draft/2020-12/vocab/content\":!0},$dynamicAnchor:\"meta\",title:\"Core and Validation specifications meta-schema\",allOf:[{$ref:\"meta/core\"},{$ref:\"meta/applicator\"},{$ref:\"meta/unevaluated\"},{$ref:\"meta/validation\"},{$ref:\"meta/meta-data\"},{$ref:\"meta/format-annotation\"},{$ref:\"meta/content\"}],type:[\"object\",\"boolean\"],$comment:\"This meta-schema also defines keywords that have appeared in previous drafts in order to prevent incompatible extensions as they remain in common use.\",properties:{definitions:{$comment:'\"definitions\" has been replaced by \"$defs\".',type:\"object\",additionalProperties:{$dynamicRef:\"#meta\"},deprecated:!0,default:{}},dependencies:{$comment:'\"dependencies\" has been split and replaced by \"dependentSchemas\" and \"dependentRequired\" in order to serve their differing semantics.',type:\"object\",additionalProperties:{anyOf:[{$dynamicRef:\"#meta\"},{$ref:\"meta/validation#/$defs/stringArray\"}]},deprecated:!0,default:{}},$recursiveAnchor:{$comment:'\"$recursiveAnchor\" has been replaced by \"$dynamicAnchor\".',$ref:\"meta/core#/$defs/anchorString\",deprecated:!0},$recursiveRef:{$comment:'\"$recursiveRef\" has been replaced by \"$dynamicRef\".',$ref:\"meta/core#/$defs/uriReferenceString\",deprecated:!0}}}});var tR=g(function(H6,sL){sL.exports={$schema:\"https://json-schema.org/draft/2020-12/schema\",$id:\"https://json-schema.org/draft/2020-12/meta/applicator\",$vocabulary:{\"https://json-schema.org/draft/2020-12/vocab/applicator\":!0},$dynamicAnchor:\"meta\",title:\"Applicator vocabulary meta-schema\",type:[\"object\",\"boolean\"],properties:{prefixItems:{$ref:\"#/$defs/schemaArray\"},items:{$dynamicRef:\"#meta\"},contains:{$dynamicRef:\"#meta\"},additionalProperties:{$dynamicRef:\"#meta\"},properties:{type:\"object\",additionalProperties:{$dynamicRef:\"#meta\"},default:{}},patternProperties:{type:\"object\",additionalProperties:{$dynamicRef:\"#meta\"},propertyNames:{format:\"regex\"},default:{}},dependentSchemas:{type:\"object\",additionalProperties:{$dynamicRef:\"#meta\"},default:{}},propertyNames:{$dynamicRef:\"#meta\"},if:{$dynamicRef:\"#meta\"},then:{$dynamicRef:\"#meta\"},else:{$dynamicRef:\"#meta\"},allOf:{$ref:\"#/$defs/schemaArray\"},anyOf:{$ref:\"#/$defs/schemaArray\"},oneOf:{$ref:\"#/$defs/schemaArray\"},not:{$dynamicRef:\"#meta\"}},$defs:{schemaArray:{type:\"array\",minItems:1,items:{$dynamicRef:\"#meta\"}}}}});var nR=g(function(Z6,iL){iL.exports={$schema:\"https://json-schema.org/draft/2020-12/schema\",$id:\"https://json-schema.org/draft/2020-12/meta/unevaluated\",$vocabulary:{\"https://json-schema.org/draft/2020-12/vocab/unevaluated\":!0},$dynamicAnchor:\"meta\",title:\"Unevaluated applicator vocabulary meta-schema\",type:[\"object\",\"boolean\"],properties:{unevaluatedItems:{$dynamicRef:\"#meta\"},unevaluatedProperties:{$dynamicRef:\"#meta\"}}}});var rR=g(function(Y6,aL){aL.exports={$schema:\"https://json-schema.org/draft/2020-12/schema\",$id:\"https://json-schema.org/draft/2020-12/meta/content\",$vocabulary:{\"https://json-schema.org/draft/2020-12/vocab/content\":!0},$dynamicAnchor:\"meta\",title:\"Content vocabulary meta-schema\",type:[\"object\",\"boolean\"],properties:{contentEncoding:{type:\"string\"},contentMediaType:{type:\"string\"},contentSchema:{$dynamicRef:\"#meta\"}}}});var oR=g(function(X6,cL){cL.exports={$schema:\"https://json-schema.org/draft/2020-12/schema\",$id:\"https://json-schema.org/draft/2020-12/meta/core\",$vocabulary:{\"https://json-schema.org/draft/2020-12/vocab/core\":!0},$dynamicAnchor:\"meta\",title:\"Core vocabulary meta-schema\",type:[\"object\",\"boolean\"],properties:{$id:{$ref:\"#/$defs/uriReferenceString\",$comment:\"Non-empty fragments not allowed.\",pattern:\"^[^#]*#?$\"},$schema:{$ref:\"#/$defs/uriString\"},$ref:{$ref:\"#/$defs/uriReferenceString\"},$anchor:{$ref:\"#/$defs/anchorString\"},$dynamicRef:{$ref:\"#/$defs/uriReferenceString\"},$dynamicAnchor:{$ref:\"#/$defs/anchorString\"},$vocabulary:{type:\"object\",propertyNames:{$ref:\"#/$defs/uriString\"},additionalProperties:{type:\"boolean\"}},$comment:{type:\"string\"},$defs:{type:\"object\",additionalProperties:{$dynamicRef:\"#meta\"}}},$defs:{anchorString:{type:\"string\",pattern:\"^[A-Za-z_][-A-Za-z0-9._]*$\"},uriString:{type:\"string\",format:\"uri\"},uriReferenceString:{type:\"string\",format:\"uri-reference\"}}}});var sR=g(function(Q6,lL){lL.exports={$schema:\"https://json-schema.org/draft/2020-12/schema\",$id:\"https://json-schema.org/draft/2020-12/meta/format-annotation\",$vocabulary:{\"https://json-schema.org/draft/2020-12/vocab/format-annotation\":!0},$dynamicAnchor:\"meta\",title:\"Format vocabulary meta-schema for annotation results\",type:[\"object\",\"boolean\"],properties:{format:{type:\"string\"}}}});var iR=g(function(e9,uL){uL.exports={$schema:\"https://json-schema.org/draft/2020-12/schema\",$id:\"https://json-schema.org/draft/2020-12/meta/meta-data\",$vocabulary:{\"https://json-schema.org/draft/2020-12/vocab/meta-data\":!0},$dynamicAnchor:\"meta\",title:\"Meta-data vocabulary meta-schema\",type:[\"object\",\"boolean\"],properties:{title:{type:\"string\"},description:{type:\"string\"},default:!0,deprecated:{type:\"boolean\",default:!1},readOnly:{type:\"boolean\",default:!1},writeOnly:{type:\"boolean\",default:!1},examples:{type:\"array\",items:!0}}}});var aR=g(function(t9,dL){dL.exports={$schema:\"https://json-schema.org/draft/2020-12/schema\",$id:\"https://json-schema.org/draft/2020-12/meta/validation\",$vocabulary:{\"https://json-schema.org/draft/2020-12/vocab/validation\":!0},$dynamicAnchor:\"meta\",title:\"Validation vocabulary meta-schema\",type:[\"object\",\"boolean\"],properties:{type:{anyOf:[{$ref:\"#/$defs/simpleTypes\"},{type:\"array\",items:{$ref:\"#/$defs/simpleTypes\"},minItems:1,uniqueItems:!0}]},const:!0,enum:{type:\"array\",items:!0},multipleOf:{type:\"number\",exclusiveMinimum:0},maximum:{type:\"number\"},exclusiveMaximum:{type:\"number\"},minimum:{type:\"number\"},exclusiveMinimum:{type:\"number\"},maxLength:{$ref:\"#/$defs/nonNegativeInteger\"},minLength:{$ref:\"#/$defs/nonNegativeIntegerDefault0\"},pattern:{type:\"string\",format:\"regex\"},maxItems:{$ref:\"#/$defs/nonNegativeInteger\"},minItems:{$ref:\"#/$defs/nonNegativeIntegerDefault0\"},uniqueItems:{type:\"boolean\",default:!1},maxContains:{$ref:\"#/$defs/nonNegativeInteger\"},minContains:{$ref:\"#/$defs/nonNegativeInteger\",default:1},maxProperties:{$ref:\"#/$defs/nonNegativeInteger\"},minProperties:{$ref:\"#/$defs/nonNegativeIntegerDefault0\"},required:{$ref:\"#/$defs/stringArray\"},dependentRequired:{type:\"object\",additionalProperties:{$ref:\"#/$defs/stringArray\"}}},$defs:{nonNegativeInteger:{type:\"integer\",minimum:0},nonNegativeIntegerDefault0:{$ref:\"#/$defs/nonNegativeInteger\",default:0},simpleTypes:{enum:[\"array\",\"boolean\",\"integer\",\"null\",\"number\",\"object\",\"string\"]},stringArray:{type:\"array\",items:{type:\"string\"},uniqueItems:!0,default:[]}}}});var lR=g(function(cR){Object.defineProperty(cR,\"__esModule\",{value:!0});var pL=eR(),mL=tR(),fL=nR(),gL=rR(),hL=oR(),yL=sR(),bL=iR(),vL=aR(),_L=[\"/properties\"];function wL(e){return[pL,mL,fL,gL,hL,t(this,yL),bL,t(this,vL)].forEach((n)=>this.addMetaSchema(n,void 0,!1)),this;function t(n,r){return e?n.$dataMetaSchema(r,_L):r}}cR.default=wL});var uR=g(function(qe,nu){Object.defineProperty(qe,\"__esModule\",{value:!0});qe.MissingRefError=qe.ValidationError=qe.CodeGen=qe.Name=qe.nil=qe.stringify=qe.str=qe._=qe.KeywordCxt=qe.Ajv2020=void 0;var SL=Js(),IL=Qk(),kL=ui(),RL=lR(),tu=\"https://json-schema.org/draft/2020-12/schema\";class co extends SL.default{constructor(e={}){super({...e,dynamicRef:!0,next:!0,unevaluated:!0})}_addVocabularies(){if(super._addVocabularies(),IL.default.forEach((e)=>this.addVocabulary(e)),this.opts.discriminator)this.addKeyword(kL.default)}_addDefaultMetaSchema(){super._addDefaultMetaSchema();let{$data:e,meta:t}=this.opts;if(!t)return;RL.default.call(this,e),this.refs[\"http://json-schema.org/schema\"]=tu}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(tu)?tu:void 0)}}qe.Ajv2020=co;nu.exports=qe=co;nu.exports.Ajv2020=co;Object.defineProperty(qe,\"__esModule\",{value:!0});qe.default=co;var TL=In();Object.defineProperty(qe,\"KeywordCxt\",{enumerable:!0,get:function(){return TL.KeywordCxt}});var wr=N();Object.defineProperty(qe,\"_\",{enumerable:!0,get:function(){return wr._}});Object.defineProperty(qe,\"str\",{enumerable:!0,get:function(){return wr.str}});Object.defineProperty(qe,\"stringify\",{enumerable:!0,get:function(){return wr.stringify}});Object.defineProperty(qe,\"nil\",{enumerable:!0,get:function(){return wr.nil}});Object.defineProperty(qe,\"Name\",{enumerable:!0,get:function(){return wr.Name}});Object.defineProperty(qe,\"CodeGen\",{enumerable:!0,get:function(){return wr.CodeGen}});var AL=ar();Object.defineProperty(qe,\"ValidationError\",{enumerable:!0,get:function(){return AL.default}});var CL=kn();Object.defineProperty(qe,\"MissingRefError\",{enumerable:!0,get:function(){return CL.default}})});import{randomUUID as BG}from\"node:crypto\";function I(e){return e()}var Mu;function b(e,t,n){function r(a,c){if(!a._zod)Object.defineProperty(a,\"_zod\",{value:{def:c,constr:i,traits:new Set},enumerable:!1});if(a._zod.traits.has(e))return;a._zod.traits.add(e),t(a,c);let l=i.prototype,u=Object.keys(l);for(let p=0;p<u.length;p++){let m=u[p];if(!(m in a))a[m]=l[m].bind(a)}}let o=n?.Parent??Object;class s extends o{}Object.defineProperty(s,\"name\",{value:e});function i(a){var c;let l=n?.Parent?new s:this;r(l,a),(c=l._zod).deferred??(c.deferred=[]);for(let u of l._zod.deferred)u();return l}return Object.defineProperty(i,\"init\",{value:r}),Object.defineProperty(i,Symbol.hasInstance,{value:(a)=>{if(n?.Parent&&a instanceof n.Parent)return!0;return a?._zod?.traits?.has(e)}}),Object.defineProperty(i,\"name\",{value:e}),i}var nB=Symbol(\"zod_brand\");class bt extends Error{constructor(){super(\"Encountered Promise during synchronous parse. Use .parseAsync() instead.\")}}class kr extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`);this.name=\"ZodEncodeError\"}}(Mu=globalThis).__zod_globalConfig??(Mu.__zod_globalConfig={});var $n=globalThis.__zod_globalConfig;function We(e){if(e)Object.assign($n,e);return $n}function bo(e){let t=Object.values(e).filter((r)=>typeof r===\"number\");return Object.entries(e).filter(([r,o])=>t.indexOf(+r)===-1).map(([r,o])=>o)}function Rr(e,t){if(typeof t===\"bigint\")return t.toString();return t}function Tr(e){return{get value(){{let n=e();return Object.defineProperty(this,\"value\",{value:n}),n}throw Error(\"cached value already set\")}}}function vo(e){return e===null||e===void 0}function _o(e){let t=e.startsWith(\"^\")?1:0,n=e.endsWith(\"$\")?e.length-1:e.length;return e.slice(t,n)}function zu(e,t){let n=e/t,r=Math.round(n),o=Number.EPSILON*Math.max(Math.abs(n),1);if(Math.abs(n-r)<o)return 0;return n-r}var qu=Symbol(\"evaluating\");function J(e,t,n){let r=void 0;Object.defineProperty(e,t,{get(){if(r===qu)return;if(r===void 0)r=qu,r=n();return r},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function ln(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Rt(...e){let t={};for(let n of e){let r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function Oi(e){return JSON.stringify(e)}function ju(e){return e.toLowerCase().trim().replace(/[^\\w\\s-]/g,\"\").replace(/[\\s_-]+/g,\"-\").replace(/^-+|-+$/g,\"\")}var $i=\"captureStackTrace\"in Error?Error.captureStackTrace:(...e)=>{};function Mn(e){return typeof e===\"object\"&&e!==null&&!Array.isArray(e)}var Nu=Tr(()=>{if($n.jitless)return!1;if(typeof navigator<\"u\"&&navigator?.userAgent?.includes(\"Cloudflare\"))return!1;try{return new Function(\"\"),!0}catch(e){return!1}});function un(e){if(Mn(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;if(typeof t!==\"function\")return!0;let n=t.prototype;if(Mn(n)===!1)return!1;if(Object.prototype.hasOwnProperty.call(n,\"isPrototypeOf\")===!1)return!1;return!0}function Mi(e){if(un(e))return{...e};if(Array.isArray(e))return[...e];if(e instanceof Map)return new Map(e);if(e instanceof Set)return new Set(e);return e}var Du=new Set([\"string\",\"number\",\"symbol\"]);function Tt(e){return e.replace(/[.*+?^${}()|[\\]\\\\]/g,\"\\\\$&\")}function Xe(e,t,n){let r=new e._zod.constr(t??e._zod.def);if(!t||n?.parent)r._zod.parent=e;return r}function P(e){let t=e;if(!t)return{};if(typeof t===\"string\")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error(\"Cannot specify both `message` and `error` params\");t.error=t.message}if(delete t.message,typeof t.error===\"string\")return{...t,error:()=>t.error};return t}function Uu(e){return Object.keys(e).filter((t)=>e[t]._zod.optin===\"optional\"&&e[t]._zod.optout===\"optional\")}var Lu={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-340282346638528860000000000000000000000,340282346638528860000000000000000000000],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function kT(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(\".pick() cannot be used on object schemas containing refinements\");let s=Rt(e._zod.def,{get shape(){let i={};for(let a in t){if(!(a in n.shape))throw Error(`Unrecognized key: \"${a}\"`);if(!t[a])continue;i[a]=n.shape[a]}return ln(this,\"shape\",i),i},checks:[]});return Xe(e,s)}function RT(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(\".omit() cannot be used on object schemas containing refinements\");let s=Rt(e._zod.def,{get shape(){let i={...e._zod.def.shape};for(let a in t){if(!(a in n.shape))throw Error(`Unrecognized key: \"${a}\"`);if(!t[a])continue;delete i[a]}return ln(this,\"shape\",i),i},checks:[]});return Xe(e,s)}function TT(e,t){if(!un(t))throw Error(\"Invalid input to extend: expected a plain object\");let n=e._zod.def.checks;if(n&&n.length>0){let s=e._zod.def.shape;for(let i in t)if(Object.getOwnPropertyDescriptor(s,i)!==void 0)throw Error(\"Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.\")}let o=Rt(e._zod.def,{get shape(){let s={...e._zod.def.shape,...t};return ln(this,\"shape\",s),s}});return Xe(e,o)}function AT(e,t){if(!un(t))throw Error(\"Invalid input to safeExtend: expected a plain object\");let n=Rt(e._zod.def,{get shape(){let r={...e._zod.def.shape,...t};return ln(this,\"shape\",r),r}});return Xe(e,n)}function CT(e,t){if(e._zod.def.checks?.length)throw Error(\".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.\");let n=Rt(e._zod.def,{get shape(){let r={...e._zod.def.shape,...t._zod.def.shape};return ln(this,\"shape\",r),r},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return Xe(e,n)}function ET(e,t,n){let o=t._zod.def.checks;if(o&&o.length>0)throw Error(\".partial() cannot be used on object schemas containing refinements\");let i=Rt(t._zod.def,{get shape(){let a=t._zod.def.shape,c={...a};if(n)for(let l in n){if(!(l in a))throw Error(`Unrecognized key: \"${l}\"`);if(!n[l])continue;c[l]=e?new e({type:\"optional\",innerType:a[l]}):a[l]}else for(let l in a)c[l]=e?new e({type:\"optional\",innerType:a[l]}):a[l];return ln(this,\"shape\",c),c},checks:[]});return Xe(t,i)}function PT(e,t,n){let r=Rt(t._zod.def,{get shape(){let o=t._zod.def.shape,s={...o};if(n)for(let i in n){if(!(i in s))throw Error(`Unrecognized key: \"${i}\"`);if(!n[i])continue;s[i]=new e({type:\"nonoptional\",innerType:o[i]})}else for(let i in o)s[i]=new e({type:\"nonoptional\",innerType:o[i]});return ln(this,\"shape\",s),s}});return Xe(t,r)}function dn(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Gu(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function At(e,t){return t.map((n)=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function yo(e){return typeof e===\"string\"?e:e?.message}function Ke(e,t,n){let r=e.message?e.message:yo(e.inst?._zod.def?.error?.(e))??yo(t?.error?.(e))??yo(n.customError?.(e))??yo(n.localeError?.(e))??\"Invalid input\",{inst:o,continue:s,input:i,...a}=e;if(a.path??(a.path=[]),a.message=r,t?.reportInput)a.input=i;return a}function wo(e){if(Array.isArray(e))return\"array\";if(typeof e===\"string\")return\"string\";return\"unknown\"}function pn(...e){let[t,n,r]=e;if(typeof t===\"string\")return{message:t,code:\"custom\",input:n,inst:r};return{...t}}var Bu=(e,t)=>{e.name=\"$ZodError\",Object.defineProperty(e,\"_zod\",{value:e._zod,enumerable:!1}),Object.defineProperty(e,\"issues\",{value:t,enumerable:!1}),e.message=JSON.stringify(t,Rr,2),Object.defineProperty(e,\"toString\",{value:()=>e.message,enumerable:!1})},xo=b(\"$ZodError\",Bu),qi=b(\"$ZodError\",Bu,{Parent:Error});function Vu(e,t=(n)=>n.message){let n={},r=[];for(let o of e.issues)if(o.path.length>0)n[o.path[0]]=n[o.path[0]]||[],n[o.path[0]].push(t(o));else r.push(t(o));return{formErrors:r,fieldErrors:n}}function Fu(e,t=(n)=>n.message){let n={_errors:[]},r=(o,s=[])=>{for(let i of o.issues)if(i.code===\"invalid_union\"&&i.errors.length)i.errors.map((a)=>r({issues:a},[...s,...i.path]));else if(i.code===\"invalid_key\")r({issues:i.issues},[...s,...i.path]);else if(i.code===\"invalid_element\")r({issues:i.issues},[...s,...i.path]);else{let a=[...s,...i.path];if(a.length===0)n._errors.push(t(i));else{let c=n,l=0;while(l<a.length){let u=a[l];if(l!==a.length-1)c[u]=c[u]||{_errors:[]};else c[u]=c[u]||{_errors:[]},c[u]._errors.push(t(i));c=c[u],l++}}}};return r(e),n}var So=(e)=>(t,n,r,o)=>{let s=r?{...r,async:!1}:{async:!1},i=t._zod.run({value:n,issues:[]},s);if(i instanceof Promise)throw new bt;if(i.issues.length){let a=new(o?.Err??e)(i.issues.map((c)=>Ke(c,s,We())));throw $i(a,o?.callee),a}return i.value};var Io=(e)=>async(t,n,r,o)=>{let s=r?{...r,async:!0}:{async:!0},i=t._zod.run({value:n,issues:[]},s);if(i instanceof Promise)i=await i;if(i.issues.length){let a=new(o?.Err??e)(i.issues.map((c)=>Ke(c,s,We())));throw $i(a,o?.callee),a}return i.value};var Ar=(e)=>(t,n,r)=>{let o=r?{...r,async:!1}:{async:!1},s=t._zod.run({value:n,issues:[]},o);if(s instanceof Promise)throw new bt;return s.issues.length?{success:!1,error:new(e??xo)(s.issues.map((i)=>Ke(i,o,We())))}:{success:!0,data:s.value}},Ju=Ar(qi),Cr=(e)=>async(t,n,r)=>{let o=r?{...r,async:!0}:{async:!0},s=t._zod.run({value:n,issues:[]},o);if(s instanceof Promise)s=await s;return s.issues.length?{success:!1,error:new e(s.issues.map((i)=>Ke(i,o,We())))}:{success:!0,data:s.value}},Wu=Cr(qi),Ku=(e)=>(t,n,r)=>{let o=r?{...r,direction:\"backward\"}:{direction:\"backward\"};return So(e)(t,n,o)};var Hu=(e)=>(t,n,r)=>So(e)(t,n,r);var Zu=(e)=>async(t,n,r)=>{let o=r?{...r,direction:\"backward\"}:{direction:\"backward\"};return Io(e)(t,n,o)};var Yu=(e)=>async(t,n,r)=>Io(e)(t,n,r);var Xu=(e)=>(t,n,r)=>{let o=r?{...r,direction:\"backward\"}:{direction:\"backward\"};return Ar(e)(t,n,o)};var Qu=(e)=>(t,n,r)=>Ar(e)(t,n,r);var ed=(e)=>async(t,n,r)=>{let o=r?{...r,direction:\"backward\"}:{direction:\"backward\"};return Cr(e)(t,n,o)};var td=(e)=>async(t,n,r)=>Cr(e)(t,n,r);var nd=/^[cC][0-9a-z]{6,}$/,rd=/^[0-9a-z]+$/,od=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,sd=/^[0-9a-vA-V]{20}$/,id=/^[A-Za-z0-9]{27}$/,ad=/^[a-zA-Z0-9_-]{21}$/,cd=/^P(?:(\\d+W)|(?!.*W)(?=\\d|T\\d)(\\d+Y)?(\\d+M)?(\\d+D)?(T(?=\\d)(\\d+H)?(\\d+M)?(\\d+([.,]\\d+)?S)?)?)$/;var ld=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,zi=(e)=>{if(!e)return/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`)};var ud=/^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$/;var $T=\"^(\\\\p{Extended_Pictographic}|\\\\p{Emoji_Component})+$\";function dd(){return new RegExp($T,\"u\")}var pd=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,md=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;var fd=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\\/([0-9]|[1-2][0-9]|3[0-2])$/,gd=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,hd=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,ji=/^[A-Za-z0-9_-]*$/;var yd=/^https?$/,bd=/^\\+[1-9]\\d{6,14}$/,vd=\"(?:(?:\\\\d\\\\d[2468][048]|\\\\d\\\\d[13579][26]|\\\\d\\\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\\\d|30)|(?:02)-(?:0[1-9]|1\\\\d|2[0-8])))\",_d=new RegExp(`^${vd}$`);function wd(e){return typeof e.precision===\"number\"?e.precision===-1?\"(?:[01]\\\\d|2[0-3]):[0-5]\\\\d\":e.precision===0?\"(?:[01]\\\\d|2[0-3]):[0-5]\\\\d:[0-5]\\\\d\":`(?:[01]\\\\d|2[0-3]):[0-5]\\\\d:[0-5]\\\\d\\\\.\\\\d{${e.precision}}`:\"(?:[01]\\\\d|2[0-3]):[0-5]\\\\d(?::[0-5]\\\\d(?:\\\\.\\\\d+)?)?\"}function xd(e){return new RegExp(`^${wd(e)}$`)}function Sd(e){let t=wd({precision:e.precision}),n=[\"Z\"];if(e.local)n.push(\"\");if(e.offset)n.push(\"([+-](?:[01]\\\\d|2[0-3]):[0-5]\\\\d)\");let r=`${t}(?:${n.join(\"|\")})`;return new RegExp(`^${vd}T(?:${r})$`)}var Id=(e)=>{let t=e?`[\\\\s\\\\S]{${e?.minimum??0},${e?.maximum??\"\"}}`:\"[\\\\s\\\\S]*\";return new RegExp(`^${t}$`)};var kd=/^-?\\d+$/,Ni=/^-?\\d+(?:\\.\\d+)?$/,Rd=/^(?:true|false)$/i,Td=/^null$/i;var Ad=/^[^A-Z]*$/,Cd=/^[^a-z]*$/;var we=b(\"$ZodCheck\",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Ed={number:\"number\",bigint:\"bigint\",object:\"date\"},Di=b(\"$ZodCheckLessThan\",(e,t)=>{we.init(e,t);let n=Ed[typeof t.value];e._zod.onattach.push((r)=>{let o=r._zod.bag,s=(t.inclusive?o.maximum:o.exclusiveMaximum)??Number.POSITIVE_INFINITY;if(t.value<s)if(t.inclusive)o.maximum=t.value;else o.exclusiveMaximum=t.value}),e._zod.check=(r)=>{if(t.inclusive?r.value<=t.value:r.value<t.value)return;r.issues.push({origin:n,code:\"too_big\",maximum:typeof t.value===\"object\"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Ui=b(\"$ZodCheckGreaterThan\",(e,t)=>{we.init(e,t);let n=Ed[typeof t.value];e._zod.onattach.push((r)=>{let o=r._zod.bag,s=(t.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;if(t.value>s)if(t.inclusive)o.minimum=t.value;else o.exclusiveMinimum=t.value}),e._zod.check=(r)=>{if(t.inclusive?r.value>=t.value:r.value>t.value)return;r.issues.push({origin:n,code:\"too_small\",minimum:typeof t.value===\"object\"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Pd=b(\"$ZodCheckMultipleOf\",(e,t)=>{we.init(e,t),e._zod.onattach.push((n)=>{var r;(r=n._zod.bag).multipleOf??(r.multipleOf=t.value)}),e._zod.check=(n)=>{if(typeof n.value!==typeof t.value)throw Error(\"Cannot mix number and bigint in multiple_of check.\");if(typeof n.value===\"bigint\"?n.value%t.value===BigInt(0):zu(n.value,t.value)===0)return;n.issues.push({origin:typeof n.value,code:\"not_multiple_of\",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Od=b(\"$ZodCheckNumberFormat\",(e,t)=>{we.init(e,t),t.format=t.format||\"float64\";let n=t.format?.includes(\"int\"),r=n?\"int\":\"number\",[o,s]=Lu[t.format];e._zod.onattach.push((i)=>{let a=i._zod.bag;if(a.format=t.format,a.minimum=o,a.maximum=s,n)a.pattern=kd}),e._zod.check=(i)=>{let a=i.value;if(n){if(!Number.isInteger(a)){i.issues.push({expected:r,format:t.format,code:\"invalid_type\",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){if(a>0)i.issues.push({input:a,code:\"too_big\",maximum:Number.MAX_SAFE_INTEGER,note:\"Integers must be within the safe integer range.\",inst:e,origin:r,inclusive:!0,continue:!t.abort});else i.issues.push({input:a,code:\"too_small\",minimum:Number.MIN_SAFE_INTEGER,note:\"Integers must be within the safe integer range.\",inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}if(a<o)i.issues.push({origin:\"number\",input:a,code:\"too_small\",minimum:o,inclusive:!0,inst:e,continue:!t.abort});if(a>s)i.issues.push({origin:\"number\",input:a,code:\"too_big\",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}});var $d=b(\"$ZodCheckMaxLength\",(e,t)=>{var n;we.init(e,t),(n=e._zod.def).when??(n.when=(r)=>{let o=r.value;return!vo(o)&&o.length!==void 0}),e._zod.onattach.push((r)=>{let o=r._zod.bag.maximum??Number.POSITIVE_INFINITY;if(t.maximum<o)r._zod.bag.maximum=t.maximum}),e._zod.check=(r)=>{let o=r.value;if(o.length<=t.maximum)return;let i=wo(o);r.issues.push({origin:i,code:\"too_big\",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Md=b(\"$ZodCheckMinLength\",(e,t)=>{var n;we.init(e,t),(n=e._zod.def).when??(n.when=(r)=>{let o=r.value;return!vo(o)&&o.length!==void 0}),e._zod.onattach.push((r)=>{let o=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;if(t.minimum>o)r._zod.bag.minimum=t.minimum}),e._zod.check=(r)=>{let o=r.value;if(o.length>=t.minimum)return;let i=wo(o);r.issues.push({origin:i,code:\"too_small\",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),qd=b(\"$ZodCheckLengthEquals\",(e,t)=>{var n;we.init(e,t),(n=e._zod.def).when??(n.when=(r)=>{let o=r.value;return!vo(o)&&o.length!==void 0}),e._zod.onattach.push((r)=>{let o=r._zod.bag;o.minimum=t.length,o.maximum=t.length,o.length=t.length}),e._zod.check=(r)=>{let o=r.value,s=o.length;if(s===t.length)return;let i=wo(o),a=s>t.length;r.issues.push({origin:i,...a?{code:\"too_big\",maximum:t.length}:{code:\"too_small\",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),Er=b(\"$ZodCheckStringFormat\",(e,t)=>{var n,r;if(we.init(e,t),e._zod.onattach.push((o)=>{let s=o._zod.bag;if(s.format=t.format,t.pattern)s.patterns??(s.patterns=new Set),s.patterns.add(t.pattern)}),t.pattern)(n=e._zod).check??(n.check=(o)=>{if(t.pattern.lastIndex=0,t.pattern.test(o.value))return;o.issues.push({origin:\"string\",code:\"invalid_format\",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})});else(r=e._zod).check??(r.check=()=>{})}),zd=b(\"$ZodCheckRegex\",(e,t)=>{Er.init(e,t),e._zod.check=(n)=>{if(t.pattern.lastIndex=0,t.pattern.test(n.value))return;n.issues.push({origin:\"string\",code:\"invalid_format\",format:\"regex\",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),jd=b(\"$ZodCheckLowerCase\",(e,t)=>{t.pattern??(t.pattern=Ad),Er.init(e,t)}),Nd=b(\"$ZodCheckUpperCase\",(e,t)=>{t.pattern??(t.pattern=Cd),Er.init(e,t)}),Dd=b(\"$ZodCheckIncludes\",(e,t)=>{we.init(e,t);let n=Tt(t.includes),r=new RegExp(typeof t.position===\"number\"?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push((o)=>{let s=o._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(r)}),e._zod.check=(o)=>{if(o.value.includes(t.includes,t.position))return;o.issues.push({origin:\"string\",code:\"invalid_format\",format:\"includes\",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),Ud=b(\"$ZodCheckStartsWith\",(e,t)=>{we.init(e,t);let n=new RegExp(`^${Tt(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push((r)=>{let o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=(r)=>{if(r.value.startsWith(t.prefix))return;r.issues.push({origin:\"string\",code:\"invalid_format\",format:\"starts_with\",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),Ld=b(\"$ZodCheckEndsWith\",(e,t)=>{we.init(e,t);let n=new RegExp(`.*${Tt(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push((r)=>{let o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=(r)=>{if(r.value.endsWith(t.suffix))return;r.issues.push({origin:\"string\",code:\"invalid_format\",format:\"ends_with\",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}});var Gd=b(\"$ZodCheckOverwrite\",(e,t)=>{we.init(e,t),e._zod.check=(n)=>{n.value=t.tx(n.value)}});class Li{constructor(e=[]){if(this.content=[],this.indent=0,this)this.args=e}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if(typeof e===\"function\"){e(this,{execution:\"sync\"}),e(this,{execution:\"async\"});return}let n=e.split(`\n`).filter((s)=>s),r=Math.min(...n.map((s)=>s.length-s.trimStart().length)),o=n.map((s)=>s.slice(r)).map((s)=>\" \".repeat(this.indent*2)+s);for(let s of o)this.content.push(s)}compile(){let e=Function,t=this?.args,r=[...(this?.content??[\"\"]).map((o)=>` ${o}`)];return new e(...t,r.join(`\n`))}}var Vd={major:4,minor:4,patch:3};var te=b(\"$ZodType\",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Vd;let r=[...e._zod.def.checks??[]];if(e._zod.traits.has(\"$ZodCheck\"))r.unshift(e);for(let o of r)for(let s of o._zod.onattach)s(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let o=(i,a,c)=>{let l=dn(i),u;for(let p of a){if(p._zod.def.when){if(Gu(i))continue;if(!p._zod.def.when(i))continue}else if(l)continue;let m=i.issues.length,d=p._zod.check(i);if(d instanceof Promise&&c?.async===!1)throw new bt;if(u||d instanceof Promise)u=(u??Promise.resolve()).then(async()=>{if(await d,i.issues.length===m)return;if(!l)l=dn(i,m)});else{if(i.issues.length===m)continue;if(!l)l=dn(i,m)}}if(u)return u.then(()=>i);return i},s=(i,a,c)=>{if(dn(i))return i.aborted=!0,i;let l=o(a,r,c);if(l instanceof Promise){if(c.async===!1)throw new bt;return l.then((u)=>e._zod.parse(u,c))}return e._zod.parse(l,c)};e._zod.run=(i,a)=>{if(a.skipChecks)return e._zod.parse(i,a);if(a.direction===\"backward\"){let l=e._zod.parse({value:i.value,issues:[]},{...a,skipChecks:!0});if(l instanceof Promise)return l.then((u)=>s(u,i,a));return s(l,i,a)}let c=e._zod.parse(i,a);if(c instanceof Promise){if(a.async===!1)throw new bt;return c.then((l)=>o(l,r,a))}return o(c,r,a)}}J(e,\"~standard\",()=>({validate:(o)=>{try{let s=Ju(e,o);return s.success?{value:s.data}:{issues:s.error?.issues}}catch(s){return Wu(e,o).then((i)=>i.success?{value:i.data}:{issues:i.error?.issues})}},vendor:\"zod\",version:1}))}),Ao=b(\"$ZodString\",(e,t)=>{te.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Id(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch(o){}if(typeof n.value===\"string\")return n;return n.issues.push({expected:\"string\",code:\"invalid_type\",input:n.value,inst:e}),n}}),ne=b(\"$ZodStringFormat\",(e,t)=>{Er.init(e,t),Ao.init(e,t)}),Qd=b(\"$ZodGUID\",(e,t)=>{t.pattern??(t.pattern=ld),ne.init(e,t)}),ep=b(\"$ZodUUID\",(e,t)=>{if(t.version){let r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(r===void 0)throw Error(`Invalid UUID version: \"${t.version}\"`);t.pattern??(t.pattern=zi(r))}else t.pattern??(t.pattern=zi());ne.init(e,t)}),tp=b(\"$ZodEmail\",(e,t)=>{t.pattern??(t.pattern=ud),ne.init(e,t)}),np=b(\"$ZodURL\",(e,t)=>{ne.init(e,t),e._zod.check=(n)=>{try{let r=n.value.trim();if(!t.normalize&&t.protocol?.source===yd.source){if(!/^https?:\\/\\//i.test(r)){n.issues.push({code:\"invalid_format\",format:\"url\",note:\"Invalid URL format\",input:n.value,inst:e,continue:!t.abort});return}}let o=new URL(r);if(t.hostname){if(t.hostname.lastIndex=0,!t.hostname.test(o.hostname))n.issues.push({code:\"invalid_format\",format:\"url\",note:\"Invalid hostname\",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})}if(t.protocol){if(t.protocol.lastIndex=0,!t.protocol.test(o.protocol.endsWith(\":\")?o.protocol.slice(0,-1):o.protocol))n.issues.push({code:\"invalid_format\",format:\"url\",note:\"Invalid protocol\",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})}if(t.normalize)n.value=o.href;else n.value=r;return}catch(r){n.issues.push({code:\"invalid_format\",format:\"url\",input:n.value,inst:e,continue:!t.abort})}}}),rp=b(\"$ZodEmoji\",(e,t)=>{t.pattern??(t.pattern=dd()),ne.init(e,t)}),op=b(\"$ZodNanoID\",(e,t)=>{t.pattern??(t.pattern=ad),ne.init(e,t)}),sp=b(\"$ZodCUID\",(e,t)=>{t.pattern??(t.pattern=nd),ne.init(e,t)}),ip=b(\"$ZodCUID2\",(e,t)=>{t.pattern??(t.pattern=rd),ne.init(e,t)}),ap=b(\"$ZodULID\",(e,t)=>{t.pattern??(t.pattern=od),ne.init(e,t)}),cp=b(\"$ZodXID\",(e,t)=>{t.pattern??(t.pattern=sd),ne.init(e,t)}),lp=b(\"$ZodKSUID\",(e,t)=>{t.pattern??(t.pattern=id),ne.init(e,t)}),up=b(\"$ZodISODateTime\",(e,t)=>{t.pattern??(t.pattern=Sd(t)),ne.init(e,t)}),dp=b(\"$ZodISODate\",(e,t)=>{t.pattern??(t.pattern=_d),ne.init(e,t)}),pp=b(\"$ZodISOTime\",(e,t)=>{t.pattern??(t.pattern=xd(t)),ne.init(e,t)}),mp=b(\"$ZodISODuration\",(e,t)=>{t.pattern??(t.pattern=cd),ne.init(e,t)}),fp=b(\"$ZodIPv4\",(e,t)=>{t.pattern??(t.pattern=pd),ne.init(e,t),e._zod.bag.format=\"ipv4\"}),gp=b(\"$ZodIPv6\",(e,t)=>{t.pattern??(t.pattern=md),ne.init(e,t),e._zod.bag.format=\"ipv6\",e._zod.check=(n)=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:\"invalid_format\",format:\"ipv6\",input:n.value,inst:e,continue:!t.abort})}}});var hp=b(\"$ZodCIDRv4\",(e,t)=>{t.pattern??(t.pattern=fd),ne.init(e,t)}),yp=b(\"$ZodCIDRv6\",(e,t)=>{t.pattern??(t.pattern=gd),ne.init(e,t),e._zod.check=(n)=>{let r=n.value.split(\"/\");try{if(r.length!==2)throw Error();let[o,s]=r;if(!s)throw Error();let i=Number(s);if(`${i}`!==s)throw Error();if(i<0||i>128)throw Error();new URL(`http://[${o}]`)}catch{n.issues.push({code:\"invalid_format\",format:\"cidrv6\",input:n.value,inst:e,continue:!t.abort})}}});function bp(e){if(e===\"\")return!0;if(/\\s/.test(e))return!1;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var vp=b(\"$ZodBase64\",(e,t)=>{t.pattern??(t.pattern=hd),ne.init(e,t),e._zod.bag.contentEncoding=\"base64\",e._zod.check=(n)=>{if(bp(n.value))return;n.issues.push({code:\"invalid_format\",format:\"base64\",input:n.value,inst:e,continue:!t.abort})}});function MT(e){if(!ji.test(e))return!1;let t=e.replace(/[-_]/g,(r)=>r===\"-\"?\"+\":\"/\"),n=t.padEnd(Math.ceil(t.length/4)*4,\"=\");return bp(n)}var _p=b(\"$ZodBase64URL\",(e,t)=>{t.pattern??(t.pattern=ji),ne.init(e,t),e._zod.bag.contentEncoding=\"base64url\",e._zod.check=(n)=>{if(MT(n.value))return;n.issues.push({code:\"invalid_format\",format:\"base64url\",input:n.value,inst:e,continue:!t.abort})}}),wp=b(\"$ZodE164\",(e,t)=>{t.pattern??(t.pattern=bd),ne.init(e,t)});function qT(e,t=null){try{let n=e.split(\".\");if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let o=JSON.parse(atob(r));if(\"typ\"in o&&o?.typ!==\"JWT\")return!1;if(!o.alg)return!1;if(t&&(!(\"alg\"in o)||o.alg!==t))return!1;return!0}catch{return!1}}var xp=b(\"$ZodJWT\",(e,t)=>{ne.init(e,t),e._zod.check=(n)=>{if(qT(n.value,t.alg))return;n.issues.push({code:\"invalid_format\",format:\"jwt\",input:n.value,inst:e,continue:!t.abort})}});var Bi=b(\"$ZodNumber\",(e,t)=>{te.init(e,t),e._zod.pattern=e._zod.bag.pattern??Ni,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch(i){}let o=n.value;if(typeof o===\"number\"&&!Number.isNaN(o)&&Number.isFinite(o))return n;let s=typeof o===\"number\"?Number.isNaN(o)?\"NaN\":!Number.isFinite(o)?\"Infinity\":void 0:void 0;return n.issues.push({expected:\"number\",code:\"invalid_type\",input:o,inst:e,...s?{received:s}:{}}),n}}),Sp=b(\"$ZodNumberFormat\",(e,t)=>{Od.init(e,t),Bi.init(e,t)}),Ip=b(\"$ZodBoolean\",(e,t)=>{te.init(e,t),e._zod.pattern=Rd,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Boolean(n.value)}catch(s){}let o=n.value;if(typeof o===\"boolean\")return n;return n.issues.push({expected:\"boolean\",code:\"invalid_type\",input:o,inst:e}),n}});var kp=b(\"$ZodNull\",(e,t)=>{te.init(e,t),e._zod.pattern=Td,e._zod.values=new Set([null]),e._zod.parse=(n,r)=>{let o=n.value;if(o===null)return n;return n.issues.push({expected:\"null\",code:\"invalid_type\",input:o,inst:e}),n}});var Rp=b(\"$ZodUnknown\",(e,t)=>{te.init(e,t),e._zod.parse=(n)=>n}),Tp=b(\"$ZodNever\",(e,t)=>{te.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:\"never\",code:\"invalid_type\",input:n.value,inst:e}),n)});function Fd(e,t,n){if(e.issues.length)t.issues.push(...At(n,e.issues));t.value[n]=e.value}var Ap=b(\"$ZodArray\",(e,t)=>{te.init(e,t),e._zod.parse=(n,r)=>{let o=n.value;if(!Array.isArray(o))return n.issues.push({expected:\"array\",code:\"invalid_type\",input:o,inst:e}),n;n.value=Array(o.length);let s=[];for(let i=0;i<o.length;i++){let a=o[i],c=t.element._zod.run({value:a,issues:[]},r);if(c instanceof Promise)s.push(c.then((l)=>Fd(l,n,i)));else Fd(c,n,i)}if(s.length)return Promise.all(s).then(()=>n);return n}});function To(e,t,n,r,o,s){let i=n in r;if(e.issues.length){if(o&&s&&!i)return;t.issues.push(...At(n,e.issues))}if(!i&&!o){if(!e.issues.length)t.issues.push({code:\"invalid_type\",expected:\"nonoptional\",input:void 0,path:[n]});return}if(e.value===void 0){if(i)t.value[n]=void 0}else t.value[n]=e.value}function Cp(e){let t=Object.keys(e.shape);for(let r of t)if(!e.shape?.[r]?._zod?.traits?.has(\"$ZodType\"))throw Error(`Invalid element at key \"${r}\": expected a Zod schema`);let n=Uu(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function Ep(e,t,n,r,o,s){let i=[],a=o.keySet,c=o.catchall._zod,l=c.def.type,u=c.optin===\"optional\",p=c.optout===\"optional\";for(let m in t){if(m===\"__proto__\")continue;if(a.has(m))continue;if(l===\"never\"){i.push(m);continue}let d=c.run({value:t[m],issues:[]},r);if(d instanceof Promise)e.push(d.then((f)=>To(f,n,m,t,u,p)));else To(d,n,m,t,u,p)}if(i.length)n.issues.push({code:\"unrecognized_keys\",keys:i,input:t,inst:s});if(!e.length)return n;return Promise.all(e).then(()=>n)}var zT=b(\"$ZodObject\",(e,t)=>{if(te.init(e,t),!Object.getOwnPropertyDescriptor(t,\"shape\")?.get){let a=t.shape;Object.defineProperty(t,\"shape\",{get:()=>{let c={...a};return Object.defineProperty(t,\"shape\",{value:c}),c}})}let r=Tr(()=>Cp(t));J(e._zod,\"propValues\",()=>{let a=t.shape,c={};for(let l in a){let u=a[l]._zod;if(u.values){c[l]??(c[l]=new Set);for(let p of u.values)c[l].add(p)}}return c});let o=Mn,s=t.catchall,i;e._zod.parse=(a,c)=>{i??(i=r.value);let l=a.value;if(!o(l))return a.issues.push({expected:\"object\",code:\"invalid_type\",input:l,inst:e}),a;a.value={};let u=[],p=i.shape;for(let m of i.keys){let d=p[m],f=d._zod.optin===\"optional\",h=d._zod.optout===\"optional\",y=d._zod.run({value:l[m],issues:[]},c);if(y instanceof Promise)u.push(y.then((_)=>To(_,a,m,l,f,h)));else To(y,a,m,l,f,h)}if(!s)return u.length?Promise.all(u).then(()=>a):a;return Ep(u,l,a,c,r.value,e)}}),Pp=b(\"$ZodObjectJIT\",(e,t)=>{zT.init(e,t);let n=e._zod.parse,r=Tr(()=>Cp(t)),o=(m)=>{let d=new Li([\"shape\",\"payload\",\"ctx\"]),f=r.value,h=(T)=>{let A=Oi(T);return`shape[${A}]._zod.run({ value: input[${A}], issues: [] }, ctx)`};d.write(\"const input = payload.value;\");let y=Object.create(null),_=0;for(let T of f.keys)y[T]=`key_${_++}`;d.write(\"const newResult = {};\");for(let T of f.keys){let A=y[T],x=Oi(T),K=m[T],C=K?._zod?.optin===\"optional\",D=K?._zod?.optout===\"optional\";if(d.write(`const ${A} = ${h(T)};`),C&&D)d.write(`\n if (${A}.issues.length) {\n if (${x} in input) {\n payload.issues = payload.issues.concat(${A}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${x}, ...iss.path] : [${x}]\n })));\n }\n }\n \n if (${A}.value === undefined) {\n if (${x} in input) {\n newResult[${x}] = undefined;\n }\n } else {\n newResult[${x}] = ${A}.value;\n }\n \n `);else if(!C)d.write(`\n const ${A}_present = ${x} in input;\n if (${A}.issues.length) {\n payload.issues = payload.issues.concat(${A}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${x}, ...iss.path] : [${x}]\n })));\n }\n if (!${A}_present && !${A}.issues.length) {\n payload.issues.push({\n code: \"invalid_type\",\n expected: \"nonoptional\",\n input: undefined,\n path: [${x}]\n });\n }\n\n if (${A}_present) {\n if (${A}.value === undefined) {\n newResult[${x}] = undefined;\n } else {\n newResult[${x}] = ${A}.value;\n }\n }\n\n `);else d.write(`\n if (${A}.issues.length) {\n payload.issues = payload.issues.concat(${A}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${x}, ...iss.path] : [${x}]\n })));\n }\n \n if (${A}.value === undefined) {\n if (${x} in input) {\n newResult[${x}] = undefined;\n }\n } else {\n newResult[${x}] = ${A}.value;\n }\n \n `)}d.write(\"payload.value = newResult;\"),d.write(\"return payload;\");let E=d.compile();return(T,A)=>E(m,T,A)},s,i=Mn,a=!$n.jitless,l=a&&Nu.value,u=t.catchall,p;e._zod.parse=(m,d)=>{p??(p=r.value);let f=m.value;if(!i(f))return m.issues.push({expected:\"object\",code:\"invalid_type\",input:f,inst:e}),m;if(a&&l&&d?.async===!1&&d.jitless!==!0){if(!s)s=o(t.shape);if(m=s(m,d),!u)return m;return Ep([],f,m,d,p,e)}return n(m,d)}});function Jd(e,t,n,r){for(let s of e)if(s.issues.length===0)return t.value=s.value,t;let o=e.filter((s)=>!dn(s));if(o.length===1)return t.value=o[0].value,o[0];return t.issues.push({code:\"invalid_union\",input:t.value,inst:n,errors:e.map((s)=>s.issues.map((i)=>Ke(i,r,We())))}),t}var Vi=b(\"$ZodUnion\",(e,t)=>{te.init(e,t),J(e._zod,\"optin\",()=>t.options.some((r)=>r._zod.optin===\"optional\")?\"optional\":void 0),J(e._zod,\"optout\",()=>t.options.some((r)=>r._zod.optout===\"optional\")?\"optional\":void 0),J(e._zod,\"values\",()=>{if(t.options.every((r)=>r._zod.values))return new Set(t.options.flatMap((r)=>Array.from(r._zod.values)));return}),J(e._zod,\"pattern\",()=>{if(t.options.every((r)=>r._zod.pattern)){let r=t.options.map((o)=>o._zod.pattern);return new RegExp(`^(${r.map((o)=>_o(o.source)).join(\"|\")})$`)}return});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,o)=>{if(n)return n(r,o);let s=!1,i=[];for(let a of t.options){let c=a._zod.run({value:r.value,issues:[]},o);if(c instanceof Promise)i.push(c),s=!0;else{if(c.issues.length===0)return c;i.push(c)}}if(!s)return Jd(i,r,e,o);return Promise.all(i).then((a)=>Jd(a,r,e,o))}});var Op=b(\"$ZodDiscriminatedUnion\",(e,t)=>{t.inclusive=!1,Vi.init(e,t);let n=e._zod.parse;J(e._zod,\"propValues\",()=>{let o={};for(let s of t.options){let i=s._zod.propValues;if(!i||Object.keys(i).length===0)throw Error(`Invalid discriminated union option at index \"${t.options.indexOf(s)}\"`);for(let[a,c]of Object.entries(i)){if(!o[a])o[a]=new Set;for(let l of c)o[a].add(l)}}return o});let r=Tr(()=>{let o=t.options,s=new Map;for(let i of o){let a=i._zod.propValues?.[t.discriminator];if(!a||a.size===0)throw Error(`Invalid discriminated union option at index \"${t.options.indexOf(i)}\"`);for(let c of a){if(s.has(c))throw Error(`Duplicate discriminator value \"${String(c)}\"`);s.set(c,i)}}return s});e._zod.parse=(o,s)=>{let i=o.value;if(!Mn(i))return o.issues.push({code:\"invalid_type\",expected:\"object\",input:i,inst:e}),o;let a=r.value.get(i?.[t.discriminator]);if(a)return a._zod.run(o,s);if(t.unionFallback||s.direction===\"backward\")return n(o,s);return o.issues.push({code:\"invalid_union\",errors:[],note:\"No matching discriminator\",discriminator:t.discriminator,options:Array.from(r.value.keys()),input:i,path:[t.discriminator],inst:e}),o}}),$p=b(\"$ZodIntersection\",(e,t)=>{te.init(e,t),e._zod.parse=(n,r)=>{let o=n.value,s=t.left._zod.run({value:o,issues:[]},r),i=t.right._zod.run({value:o,issues:[]},r);if(s instanceof Promise||i instanceof Promise)return Promise.all([s,i]).then(([c,l])=>Wd(n,c,l));return Wd(n,s,i)}});function Gi(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e===+t)return{valid:!0,data:e};if(un(e)&&un(t)){let n=Object.keys(t),r=Object.keys(e).filter((s)=>n.indexOf(s)!==-1),o={...e,...t};for(let s of r){let i=Gi(e[s],t[s]);if(!i.valid)return{valid:!1,mergeErrorPath:[s,...i.mergeErrorPath]};o[s]=i.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let o=e[r],s=t[r],i=Gi(o,s);if(!i.valid)return{valid:!1,mergeErrorPath:[r,...i.mergeErrorPath]};n.push(i.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Wd(e,t,n){let r=new Map,o;for(let a of t.issues)if(a.code===\"unrecognized_keys\"){o??(o=a);for(let c of a.keys){if(!r.has(c))r.set(c,{});r.get(c).l=!0}}else e.issues.push(a);for(let a of n.issues)if(a.code===\"unrecognized_keys\")for(let c of a.keys){if(!r.has(c))r.set(c,{});r.get(c).r=!0}else e.issues.push(a);let s=[...r].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(s.length&&o)e.issues.push({...o,keys:s});if(dn(e))return e;let i=Gi(t.value,n.value);if(!i.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(i.mergeErrorPath)}`);return e.value=i.data,e}var Mp=b(\"$ZodRecord\",(e,t)=>{te.init(e,t),e._zod.parse=(n,r)=>{let o=n.value;if(!un(o))return n.issues.push({expected:\"record\",code:\"invalid_type\",input:o,inst:e}),n;let s=[],i=t.keyType._zod.values;if(i){n.value={};let a=new Set;for(let l of i)if(typeof l===\"string\"||typeof l===\"number\"||typeof l===\"symbol\"){a.add(typeof l===\"number\"?l.toString():l);let u=t.keyType._zod.run({value:l,issues:[]},r);if(u instanceof Promise)throw Error(\"Async schemas not supported in object keys currently\");if(u.issues.length){n.issues.push({code:\"invalid_key\",origin:\"record\",issues:u.issues.map((d)=>Ke(d,r,We())),input:l,path:[l],inst:e});continue}let p=u.value,m=t.valueType._zod.run({value:o[l],issues:[]},r);if(m instanceof Promise)s.push(m.then((d)=>{if(d.issues.length)n.issues.push(...At(l,d.issues));n.value[p]=d.value}));else{if(m.issues.length)n.issues.push(...At(l,m.issues));n.value[p]=m.value}}let c;for(let l in o)if(!a.has(l))c=c??[],c.push(l);if(c&&c.length>0)n.issues.push({code:\"unrecognized_keys\",input:o,inst:e,keys:c})}else{n.value={};for(let a of Reflect.ownKeys(o)){if(a===\"__proto__\")continue;if(!Object.prototype.propertyIsEnumerable.call(o,a))continue;let c=t.keyType._zod.run({value:a,issues:[]},r);if(c instanceof Promise)throw Error(\"Async schemas not supported in object keys currently\");if(typeof a===\"string\"&&Ni.test(a)&&c.issues.length){let p=t.keyType._zod.run({value:Number(a),issues:[]},r);if(p instanceof Promise)throw Error(\"Async schemas not supported in object keys currently\");if(p.issues.length===0)c=p}if(c.issues.length){if(t.mode===\"loose\")n.value[a]=o[a];else n.issues.push({code:\"invalid_key\",origin:\"record\",issues:c.issues.map((p)=>Ke(p,r,We())),input:a,path:[a],inst:e});continue}let u=t.valueType._zod.run({value:o[a],issues:[]},r);if(u instanceof Promise)s.push(u.then((p)=>{if(p.issues.length)n.issues.push(...At(a,p.issues));n.value[c.value]=p.value}));else{if(u.issues.length)n.issues.push(...At(a,u.issues));n.value[c.value]=u.value}}}if(s.length)return Promise.all(s).then(()=>n);return n}});var qp=b(\"$ZodEnum\",(e,t)=>{te.init(e,t);let n=bo(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter((o)=>Du.has(typeof o)).map((o)=>typeof o===\"string\"?Tt(o):o.toString()).join(\"|\")})$`),e._zod.parse=(o,s)=>{let i=o.value;if(r.has(i))return o;return o.issues.push({code:\"invalid_value\",values:n,input:i,inst:e}),o}}),zp=b(\"$ZodLiteral\",(e,t)=>{if(te.init(e,t),t.values.length===0)throw Error(\"Cannot create literal schema with no valid values\");let n=new Set(t.values);e._zod.values=n,e._zod.pattern=new RegExp(`^(${t.values.map((r)=>typeof r===\"string\"?Tt(r):r?Tt(r.toString()):String(r)).join(\"|\")})$`),e._zod.parse=(r,o)=>{let s=r.value;if(n.has(s))return r;return r.issues.push({code:\"invalid_value\",values:t.values,input:s,inst:e}),r}});var jp=b(\"$ZodTransform\",(e,t)=>{te.init(e,t),e._zod.optin=\"optional\",e._zod.parse=(n,r)=>{if(r.direction===\"backward\")throw new kr(e.constructor.name);let o=t.transform(n.value,n);if(r.async)return(o instanceof Promise?o:Promise.resolve(o)).then((i)=>(n.value=i,n.fallback=!0,n));if(o instanceof Promise)throw new bt;return n.value=o,n.fallback=!0,n}});function Kd(e,t){if(t===void 0&&(e.issues.length||e.fallback))return{issues:[],value:void 0};return e}var Fi=b(\"$ZodOptional\",(e,t)=>{te.init(e,t),e._zod.optin=\"optional\",e._zod.optout=\"optional\",J(e._zod,\"values\",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),J(e._zod,\"pattern\",()=>{let n=t.innerType._zod.pattern;return n?new RegExp(`^(${_o(n.source)})?$`):void 0}),e._zod.parse=(n,r)=>{if(t.innerType._zod.optin===\"optional\"){let o=n.value,s=t.innerType._zod.run(n,r);if(s instanceof Promise)return s.then((i)=>Kd(i,o));return Kd(s,o)}if(n.value===void 0)return n;return t.innerType._zod.run(n,r)}}),Np=b(\"$ZodExactOptional\",(e,t)=>{Fi.init(e,t),J(e._zod,\"values\",()=>t.innerType._zod.values),J(e._zod,\"pattern\",()=>t.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),Dp=b(\"$ZodNullable\",(e,t)=>{te.init(e,t),J(e._zod,\"optin\",()=>t.innerType._zod.optin),J(e._zod,\"optout\",()=>t.innerType._zod.optout),J(e._zod,\"pattern\",()=>{let n=t.innerType._zod.pattern;return n?new RegExp(`^(${_o(n.source)}|null)$`):void 0}),J(e._zod,\"values\",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,r)=>{if(n.value===null)return n;return t.innerType._zod.run(n,r)}}),Up=b(\"$ZodDefault\",(e,t)=>{te.init(e,t),e._zod.optin=\"optional\",J(e._zod,\"values\",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction===\"backward\")return t.innerType._zod.run(n,r);if(n.value===void 0)return n.value=t.defaultValue,n;let o=t.innerType._zod.run(n,r);if(o instanceof Promise)return o.then((s)=>Hd(s,t));return Hd(o,t)}});function Hd(e,t){if(e.value===void 0)e.value=t.defaultValue;return e}var Lp=b(\"$ZodPrefault\",(e,t)=>{te.init(e,t),e._zod.optin=\"optional\",J(e._zod,\"values\",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction===\"backward\")return t.innerType._zod.run(n,r);if(n.value===void 0)n.value=t.defaultValue;return t.innerType._zod.run(n,r)}}),Gp=b(\"$ZodNonOptional\",(e,t)=>{te.init(e,t),J(e._zod,\"values\",()=>{let n=t.innerType._zod.values;return n?new Set([...n].filter((r)=>r!==void 0)):void 0}),e._zod.parse=(n,r)=>{let o=t.innerType._zod.run(n,r);if(o instanceof Promise)return o.then((s)=>Zd(s,e));return Zd(o,e)}});function Zd(e,t){if(!e.issues.length&&e.value===void 0)e.issues.push({code:\"invalid_type\",expected:\"nonoptional\",input:e.value,inst:t});return e}var Bp=b(\"$ZodCatch\",(e,t)=>{te.init(e,t),e._zod.optin=\"optional\",J(e._zod,\"optout\",()=>t.innerType._zod.optout),J(e._zod,\"values\",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction===\"backward\")return t.innerType._zod.run(n,r);let o=t.innerType._zod.run(n,r);if(o instanceof Promise)return o.then((s)=>{if(n.value=s.value,s.issues.length)n.value=t.catchValue({...n,error:{issues:s.issues.map((i)=>Ke(i,r,We()))},input:n.value}),n.issues=[],n.fallback=!0;return n});if(n.value=o.value,o.issues.length)n.value=t.catchValue({...n,error:{issues:o.issues.map((s)=>Ke(s,r,We()))},input:n.value}),n.issues=[],n.fallback=!0;return n}});var Ji=b(\"$ZodPipe\",(e,t)=>{te.init(e,t),J(e._zod,\"values\",()=>t.in._zod.values),J(e._zod,\"optin\",()=>t.in._zod.optin),J(e._zod,\"optout\",()=>t.out._zod.optout),J(e._zod,\"propValues\",()=>t.in._zod.propValues),e._zod.parse=(n,r)=>{if(r.direction===\"backward\"){let s=t.out._zod.run(n,r);if(s instanceof Promise)return s.then((i)=>Ro(i,t.in,r));return Ro(s,t.in,r)}let o=t.in._zod.run(n,r);if(o instanceof Promise)return o.then((s)=>Ro(s,t.out,r));return Ro(o,t.out,r)}});function Ro(e,t,n){if(e.issues.length)return e.aborted=!0,e;return t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}var Vp=b(\"$ZodPreprocess\",(e,t)=>{Ji.init(e,t)}),Fp=b(\"$ZodReadonly\",(e,t)=>{te.init(e,t),J(e._zod,\"propValues\",()=>t.innerType._zod.propValues),J(e._zod,\"values\",()=>t.innerType._zod.values),J(e._zod,\"optin\",()=>t.innerType?._zod?.optin),J(e._zod,\"optout\",()=>t.innerType?._zod?.optout),e._zod.parse=(n,r)=>{if(r.direction===\"backward\")return t.innerType._zod.run(n,r);let o=t.innerType._zod.run(n,r);if(o instanceof Promise)return o.then(Yd);return Yd(o)}});function Yd(e){return e.value=Object.freeze(e.value),e}var Jp=b(\"$ZodLazy\",(e,t)=>{te.init(e,t),J(e._zod,\"innerType\",()=>{let n=t;if(!n._cachedInner)n._cachedInner=t.getter();return n._cachedInner}),J(e._zod,\"pattern\",()=>e._zod.innerType?._zod?.pattern),J(e._zod,\"propValues\",()=>e._zod.innerType?._zod?.propValues),J(e._zod,\"optin\",()=>e._zod.innerType?._zod?.optin??void 0),J(e._zod,\"optout\",()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(n,r)=>e._zod.innerType._zod.run(n,r)}),Wp=b(\"$ZodCustom\",(e,t)=>{we.init(e,t),te.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=(n)=>{let r=n.value,o=t.fn(r);if(o instanceof Promise)return o.then((s)=>Xd(s,n,r,e));Xd(o,n,r,e);return}});function Xd(e,t,n,r){if(!e){let o={code:\"custom\",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};if(r._zod.def.params)o.params=r._zod.def.params;t.issues.push(pn(o))}}var Kp,xB=Symbol(\"ZodOutput\"),SB=Symbol(\"ZodInput\");class Hp{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];if(this._map.set(e,n),n&&typeof n===\"object\"&&\"id\"in n)this._idmap.set(n.id,e);return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);if(t&&typeof t===\"object\"&&\"id\"in t)this._idmap.delete(t.id);return this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function jT(){return new Hp}(Kp=globalThis).__zod_globalRegistry??(Kp.__zod_globalRegistry=jT());var mn=globalThis.__zod_globalRegistry;function Zp(e,t){return new e({type:\"string\",...P(t)})}function Yp(e,t){return new e({type:\"string\",format:\"email\",check:\"string_format\",abort:!1,...P(t)})}function Wi(e,t){return new e({type:\"string\",format:\"guid\",check:\"string_format\",abort:!1,...P(t)})}function Xp(e,t){return new e({type:\"string\",format:\"uuid\",check:\"string_format\",abort:!1,...P(t)})}function Qp(e,t){return new e({type:\"string\",format:\"uuid\",check:\"string_format\",abort:!1,version:\"v4\",...P(t)})}function em(e,t){return new e({type:\"string\",format:\"uuid\",check:\"string_format\",abort:!1,version:\"v6\",...P(t)})}function tm(e,t){return new e({type:\"string\",format:\"uuid\",check:\"string_format\",abort:!1,version:\"v7\",...P(t)})}function nm(e,t){return new e({type:\"string\",format:\"url\",check:\"string_format\",abort:!1,...P(t)})}function rm(e,t){return new e({type:\"string\",format:\"emoji\",check:\"string_format\",abort:!1,...P(t)})}function om(e,t){return new e({type:\"string\",format:\"nanoid\",check:\"string_format\",abort:!1,...P(t)})}function sm(e,t){return new e({type:\"string\",format:\"cuid\",check:\"string_format\",abort:!1,...P(t)})}function im(e,t){return new e({type:\"string\",format:\"cuid2\",check:\"string_format\",abort:!1,...P(t)})}function am(e,t){return new e({type:\"string\",format:\"ulid\",check:\"string_format\",abort:!1,...P(t)})}function cm(e,t){return new e({type:\"string\",format:\"xid\",check:\"string_format\",abort:!1,...P(t)})}function lm(e,t){return new e({type:\"string\",format:\"ksuid\",check:\"string_format\",abort:!1,...P(t)})}function um(e,t){return new e({type:\"string\",format:\"ipv4\",check:\"string_format\",abort:!1,...P(t)})}function dm(e,t){return new e({type:\"string\",format:\"ipv6\",check:\"string_format\",abort:!1,...P(t)})}function pm(e,t){return new e({type:\"string\",format:\"cidrv4\",check:\"string_format\",abort:!1,...P(t)})}function mm(e,t){return new e({type:\"string\",format:\"cidrv6\",check:\"string_format\",abort:!1,...P(t)})}function fm(e,t){return new e({type:\"string\",format:\"base64\",check:\"string_format\",abort:!1,...P(t)})}function gm(e,t){return new e({type:\"string\",format:\"base64url\",check:\"string_format\",abort:!1,...P(t)})}function hm(e,t){return new e({type:\"string\",format:\"e164\",check:\"string_format\",abort:!1,...P(t)})}function ym(e,t){return new e({type:\"string\",format:\"jwt\",check:\"string_format\",abort:!1,...P(t)})}function bm(e,t){return new e({type:\"string\",format:\"datetime\",check:\"string_format\",offset:!1,local:!1,precision:null,...P(t)})}function vm(e,t){return new e({type:\"string\",format:\"date\",check:\"string_format\",...P(t)})}function _m(e,t){return new e({type:\"string\",format:\"time\",check:\"string_format\",precision:null,...P(t)})}function wm(e,t){return new e({type:\"string\",format:\"duration\",check:\"string_format\",...P(t)})}function xm(e,t){return new e({type:\"number\",checks:[],...P(t)})}function Sm(e,t){return new e({type:\"number\",check:\"number_format\",abort:!1,format:\"safeint\",...P(t)})}function Im(e,t){return new e({type:\"boolean\",...P(t)})}function km(e,t){return new e({type:\"null\",...P(t)})}function Rm(e){return new e({type:\"unknown\"})}function Tm(e,t){return new e({type:\"never\",...P(t)})}function Co(e,t){return new Di({check:\"less_than\",...P(t),value:e,inclusive:!1})}function Pr(e,t){return new Di({check:\"less_than\",...P(t),value:e,inclusive:!0})}function Eo(e,t){return new Ui({check:\"greater_than\",...P(t),value:e,inclusive:!1})}function Or(e,t){return new Ui({check:\"greater_than\",...P(t),value:e,inclusive:!0})}function Po(e,t){return new Pd({check:\"multiple_of\",...P(t),value:e})}function Oo(e,t){return new $d({check:\"max_length\",...P(t),maximum:e})}function qn(e,t){return new Md({check:\"min_length\",...P(t),minimum:e})}function $o(e,t){return new qd({check:\"length_equals\",...P(t),length:e})}function Ki(e,t){return new zd({check:\"string_format\",format:\"regex\",...P(t),pattern:e})}function Hi(e){return new jd({check:\"string_format\",format:\"lowercase\",...P(e)})}function Zi(e){return new Nd({check:\"string_format\",format:\"uppercase\",...P(e)})}function Yi(e,t){return new Dd({check:\"string_format\",format:\"includes\",...P(t),includes:e})}function Xi(e,t){return new Ud({check:\"string_format\",format:\"starts_with\",...P(t),prefix:e})}function Qi(e,t){return new Ld({check:\"string_format\",format:\"ends_with\",...P(t),suffix:e})}function Et(e){return new Gd({check:\"overwrite\",tx:e})}function ea(e){return Et((t)=>t.normalize(e))}function ta(){return Et((e)=>e.trim())}function na(){return Et((e)=>e.toLowerCase())}function ra(){return Et((e)=>e.toUpperCase())}function oa(){return Et((e)=>ju(e))}function Am(e,t,n){return new e({type:\"array\",element:t,...P(n)})}function Cm(e,t,n){return new e({type:\"custom\",check:\"custom\",fn:t,...P(n)})}function Em(e,t){let n=NT((r)=>(r.addIssue=(o)=>{if(typeof o===\"string\")r.issues.push(pn(o,r.value,n._zod.def));else{let s=o;if(s.fatal)s.continue=!1;s.code??(s.code=\"custom\"),s.input??(s.input=r.value),s.inst??(s.inst=n),s.continue??(s.continue=!n._zod.def.abort),r.issues.push(pn(s))}},e(r.value,r)),t);return n}function NT(e,t){let n=new we({check:\"custom\",...P(t)});return n._zod.check=e,n}function sa(e){let t=e?.target??\"draft-2020-12\";if(t===\"draft-4\")t=\"draft-04\";if(t===\"draft-7\")t=\"draft-07\";return{processors:e.processors??{},metadataRegistry:e?.metadata??mn,target:t,unrepresentable:e?.unrepresentable??\"throw\",override:e?.override??(()=>{}),io:e?.io??\"output\",counter:0,seen:new Map,cycles:e?.cycles??\"ref\",reused:e?.reused??\"inline\",external:e?.external??void 0}}function le(e,t,n={path:[],schemaPath:[]}){var r;let o=e._zod.def,s=t.seen.get(e);if(s){if(s.count++,n.schemaPath.includes(e))s.cycle=n.path;return s.schema}let i={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,i);let a=e._zod.toJSONSchema?.();if(a)i.schema=a;else{let u={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,i.schema,u);else{let m=i.schema,d=t.processors[o.type];if(!d)throw Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);d(e,t,m,u)}let p=e._zod.parent;if(p){if(!i.ref)i.ref=p;le(p,t,u),t.seen.get(p).isParent=!0}}let c=t.metadataRegistry.get(e);if(c)Object.assign(i.schema,c);if(t.io===\"input\"&&ke(e))delete i.schema.examples,delete i.schema.default;if(t.io===\"input\"&&\"_prefault\"in i.schema)(r=i.schema).default??(r.default=i.schema._prefault);return delete i.schema._prefault,t.seen.get(e).schema}function ia(e,t){let n=e.seen.get(t);if(!n)throw Error(\"Unprocessed schema. This is a bug in Zod.\");let r=new Map;for(let i of e.seen.entries()){let a=e.metadataRegistry.get(i[0])?.id;if(a){let c=r.get(a);if(c&&c!==i[0])throw Error(`Duplicate schema id \"${a}\" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(a,i[0])}}let o=(i)=>{let a=e.target===\"draft-2020-12\"?\"$defs\":\"definitions\";if(e.external){let p=e.external.registry.get(i[0])?.id,m=e.external.uri??((f)=>f);if(p)return{ref:m(p)};let d=i[1].defId??i[1].schema.id??`schema${e.counter++}`;return i[1].defId=d,{defId:d,ref:`${m(\"__shared\")}#/${a}/${d}`}}if(i[1]===n)return{ref:\"#\"};let l=`${\"#\"}/${a}/`,u=i[1].schema.id??`__schema${e.counter++}`;return{defId:u,ref:l+u}},s=(i)=>{if(i[1].schema.$ref)return;let a=i[1],{ref:c,defId:l}=o(i);if(a.def={...a.schema},l)a.defId=l;let u=a.schema;for(let p in u)delete u[p];u.$ref=c};if(e.cycles===\"throw\")for(let i of e.seen.entries()){let a=i[1];if(a.cycle)throw Error(`Cycle detected: #/${a.cycle?.join(\"/\")}/<root>\n\nSet the \\`cycles\\` parameter to \\`\"ref\"\\` to resolve cyclical schemas with defs.`)}for(let i of e.seen.entries()){let a=i[1];if(t===i[0]){s(i);continue}if(e.external){let l=e.external.registry.get(i[0])?.id;if(t!==i[0]&&l){s(i);continue}}if(e.metadataRegistry.get(i[0])?.id){s(i);continue}if(a.cycle){s(i);continue}if(a.count>1){if(e.reused===\"ref\"){s(i);continue}}}}function aa(e,t){let n=e.seen.get(t);if(!n)throw Error(\"Unprocessed schema. This is a bug in Zod.\");let r=(a)=>{let c=e.seen.get(a);if(c.ref===null)return;let l=c.def??c.schema,u={...l},p=c.ref;if(c.ref=null,p){r(p);let d=e.seen.get(p),f=d.schema;if(f.$ref&&(e.target===\"draft-07\"||e.target===\"draft-04\"||e.target===\"openapi-3.0\"))l.allOf=l.allOf??[],l.allOf.push(f);else Object.assign(l,f);if(Object.assign(l,u),a._zod.parent===p)for(let y in l){if(y===\"$ref\"||y===\"allOf\")continue;if(!(y in u))delete l[y]}if(f.$ref&&d.def)for(let y in l){if(y===\"$ref\"||y===\"allOf\")continue;if(y in d.def&&JSON.stringify(l[y])===JSON.stringify(d.def[y]))delete l[y]}}let m=a._zod.parent;if(m&&m!==p){r(m);let d=e.seen.get(m);if(d?.schema.$ref){if(l.$ref=d.schema.$ref,d.def)for(let f in l){if(f===\"$ref\"||f===\"allOf\")continue;if(f in d.def&&JSON.stringify(l[f])===JSON.stringify(d.def[f]))delete l[f]}}}e.override({zodSchema:a,jsonSchema:l,path:c.path??[]})};for(let a of[...e.seen.entries()].reverse())r(a[0]);let o={};if(e.target===\"draft-2020-12\")o.$schema=\"https://json-schema.org/draft/2020-12/schema\";else if(e.target===\"draft-07\")o.$schema=\"http://json-schema.org/draft-07/schema#\";else if(e.target===\"draft-04\")o.$schema=\"http://json-schema.org/draft-04/schema#\";else if(e.target===\"openapi-3.0\");if(e.external?.uri){let a=e.external.registry.get(t)?.id;if(!a)throw Error(\"Schema is missing an `id` property\");o.$id=e.external.uri(a)}Object.assign(o,n.def??n.schema);let s=e.metadataRegistry.get(t)?.id;if(s!==void 0&&o.id===s)delete o.id;let i=e.external?.defs??{};for(let a of e.seen.entries()){let c=a[1];if(c.def&&c.defId){if(c.def.id===c.defId)delete c.def.id;i[c.defId]=c.def}}if(e.external);else if(Object.keys(i).length>0)if(e.target===\"draft-2020-12\")o.$defs=i;else o.definitions=i;try{let a=JSON.parse(JSON.stringify(o));return Object.defineProperty(a,\"~standard\",{value:{...t[\"~standard\"],jsonSchema:{input:$r(t,\"input\",e.processors),output:$r(t,\"output\",e.processors)}},enumerable:!1,writable:!1}),a}catch(a){throw Error(\"Error converting schema to JSON.\")}}function ke(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===\"transform\")return!0;if(r.type===\"array\")return ke(r.element,n);if(r.type===\"set\")return ke(r.valueType,n);if(r.type===\"lazy\")return ke(r.getter(),n);if(r.type===\"promise\"||r.type===\"optional\"||r.type===\"nonoptional\"||r.type===\"nullable\"||r.type===\"readonly\"||r.type===\"default\"||r.type===\"prefault\")return ke(r.innerType,n);if(r.type===\"intersection\")return ke(r.left,n)||ke(r.right,n);if(r.type===\"record\"||r.type===\"map\")return ke(r.keyType,n)||ke(r.valueType,n);if(r.type===\"pipe\"){if(e._zod.traits.has(\"$ZodCodec\"))return!0;return ke(r.in,n)||ke(r.out,n)}if(r.type===\"object\"){for(let o in r.shape)if(ke(r.shape[o],n))return!0;return!1}if(r.type===\"union\"){for(let o of r.options)if(ke(o,n))return!0;return!1}if(r.type===\"tuple\"){for(let o of r.items)if(ke(o,n))return!0;if(r.rest&&ke(r.rest,n))return!0;return!1}return!1}var Pm=(e,t={})=>(n)=>{let r=sa({...n,processors:t});return le(e,r),ia(r,e),aa(r,e)},$r=(e,t,n={})=>(r)=>{let{libraryOptions:o,target:s}=r??{},i=sa({...o??{},target:s,io:t,processors:n});return le(e,i),ia(i,e),aa(i,e)};var DT={guid:\"uuid\",url:\"uri\",datetime:\"date-time\",json_string:\"json-string\",regex:\"\"},Om=(e,t,n,r)=>{let o=n;o.type=\"string\";let{minimum:s,maximum:i,format:a,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof s===\"number\")o.minLength=s;if(typeof i===\"number\")o.maxLength=i;if(a){if(o.format=DT[a]??a,o.format===\"\")delete o.format;if(a===\"time\")delete o.format}if(l)o.contentEncoding=l;if(c&&c.size>0){let u=[...c];if(u.length===1)o.pattern=u[0].source;else if(u.length>1)o.allOf=[...u.map((p)=>({...t.target===\"draft-07\"||t.target===\"draft-04\"||t.target===\"openapi-3.0\"?{type:\"string\"}:{},pattern:p.source}))]}},$m=(e,t,n,r)=>{let o=n,{minimum:s,maximum:i,format:a,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;if(typeof a===\"string\"&&a.includes(\"int\"))o.type=\"integer\";else o.type=\"number\";let p=typeof u===\"number\"&&u>=(s??Number.NEGATIVE_INFINITY),m=typeof l===\"number\"&&l<=(i??Number.POSITIVE_INFINITY),d=t.target===\"draft-04\"||t.target===\"openapi-3.0\";if(p)if(d)o.minimum=u,o.exclusiveMinimum=!0;else o.exclusiveMinimum=u;else if(typeof s===\"number\")o.minimum=s;if(m)if(d)o.maximum=l,o.exclusiveMaximum=!0;else o.exclusiveMaximum=l;else if(typeof i===\"number\")o.maximum=i;if(typeof c===\"number\")o.multipleOf=c},Mm=(e,t,n,r)=>{n.type=\"boolean\"};var qm=(e,t,n,r)=>{if(t.target===\"openapi-3.0\")n.type=\"string\",n.nullable=!0,n.enum=[null];else n.type=\"null\"};var zm=(e,t,n,r)=>{n.not={}};var jm=(e,t,n,r)=>{};var Nm=(e,t,n,r)=>{let o=e._zod.def,s=bo(o.entries);if(s.every((i)=>typeof i===\"number\"))n.type=\"number\";if(s.every((i)=>typeof i===\"string\"))n.type=\"string\";n.enum=s},Dm=(e,t,n,r)=>{let o=e._zod.def,s=[];for(let i of o.values)if(i===void 0){if(t.unrepresentable===\"throw\")throw Error(\"Literal `undefined` cannot be represented in JSON Schema\")}else if(typeof i===\"bigint\")if(t.unrepresentable===\"throw\")throw Error(\"BigInt literals cannot be represented in JSON Schema\");else s.push(Number(i));else s.push(i);if(s.length===0);else if(s.length===1){let i=s[0];if(n.type=i===null?\"null\":typeof i,t.target===\"draft-04\"||t.target===\"openapi-3.0\")n.enum=[i];else n.const=i}else{if(s.every((i)=>typeof i===\"number\"))n.type=\"number\";if(s.every((i)=>typeof i===\"string\"))n.type=\"string\";if(s.every((i)=>typeof i===\"boolean\"))n.type=\"boolean\";if(s.every((i)=>i===null))n.type=\"null\";n.enum=s}};var Um=(e,t,n,r)=>{if(t.unrepresentable===\"throw\")throw Error(\"Custom types cannot be represented in JSON Schema\")};var Lm=(e,t,n,r)=>{if(t.unrepresentable===\"throw\")throw Error(\"Transforms cannot be represented in JSON Schema\")};var Gm=(e,t,n,r)=>{let o=n,s=e._zod.def,{minimum:i,maximum:a}=e._zod.bag;if(typeof i===\"number\")o.minItems=i;if(typeof a===\"number\")o.maxItems=a;o.type=\"array\",o.items=le(s.element,t,{...r,path:[...r.path,\"items\"]})},Bm=(e,t,n,r)=>{let o=n,s=e._zod.def;o.type=\"object\",o.properties={};let i=s.shape;for(let l in i)o.properties[l]=le(i[l],t,{...r,path:[...r.path,\"properties\",l]});let a=new Set(Object.keys(i)),c=new Set([...a].filter((l)=>{let u=s.shape[l]._zod;if(t.io===\"input\")return u.optin===void 0;else return u.optout===void 0}));if(c.size>0)o.required=Array.from(c);if(s.catchall?._zod.def.type===\"never\")o.additionalProperties=!1;else if(!s.catchall){if(t.io===\"output\")o.additionalProperties=!1}else if(s.catchall)o.additionalProperties=le(s.catchall,t,{...r,path:[...r.path,\"additionalProperties\"]})},Vm=(e,t,n,r)=>{let o=e._zod.def,s=o.inclusive===!1,i=o.options.map((a,c)=>le(a,t,{...r,path:[...r.path,s?\"oneOf\":\"anyOf\",c]}));if(s)n.oneOf=i;else n.anyOf=i},Fm=(e,t,n,r)=>{let o=e._zod.def,s=le(o.left,t,{...r,path:[...r.path,\"allOf\",0]}),i=le(o.right,t,{...r,path:[...r.path,\"allOf\",1]}),a=(l)=>(\"allOf\"in l)&&Object.keys(l).length===1,c=[...a(s)?s.allOf:[s],...a(i)?i.allOf:[i]];n.allOf=c};var Jm=(e,t,n,r)=>{let o=n,s=e._zod.def;o.type=\"object\";let i=s.keyType,c=i._zod.bag?.patterns;if(s.mode===\"loose\"&&c&&c.size>0){let u=le(s.valueType,t,{...r,path:[...r.path,\"patternProperties\",\"*\"]});o.patternProperties={};for(let p of c)o.patternProperties[p.source]=u}else{if(t.target===\"draft-07\"||t.target===\"draft-2020-12\")o.propertyNames=le(s.keyType,t,{...r,path:[...r.path,\"propertyNames\"]});o.additionalProperties=le(s.valueType,t,{...r,path:[...r.path,\"additionalProperties\"]})}let l=i._zod.values;if(l){let u=[...l].filter((p)=>typeof p===\"string\"||typeof p===\"number\");if(u.length>0)o.required=u}},Wm=(e,t,n,r)=>{let o=e._zod.def,s=le(o.innerType,t,r),i=t.seen.get(e);if(t.target===\"openapi-3.0\")i.ref=o.innerType,n.nullable=!0;else n.anyOf=[s,{type:\"null\"}]},Km=(e,t,n,r)=>{let o=e._zod.def;le(o.innerType,t,r);let s=t.seen.get(e);s.ref=o.innerType},Hm=(e,t,n,r)=>{let o=e._zod.def;le(o.innerType,t,r);let s=t.seen.get(e);s.ref=o.innerType,n.default=JSON.parse(JSON.stringify(o.defaultValue))},Zm=(e,t,n,r)=>{let o=e._zod.def;le(o.innerType,t,r);let s=t.seen.get(e);if(s.ref=o.innerType,t.io===\"input\")n._prefault=JSON.parse(JSON.stringify(o.defaultValue))},Ym=(e,t,n,r)=>{let o=e._zod.def;le(o.innerType,t,r);let s=t.seen.get(e);s.ref=o.innerType;let i;try{i=o.catchValue(void 0)}catch{throw Error(\"Dynamic catch values are not supported in JSON Schema\")}n.default=i},Xm=(e,t,n,r)=>{let o=e._zod.def,s=o.in._zod.traits.has(\"$ZodTransform\"),i=t.io===\"input\"?s?o.out:o.in:o.out;le(i,t,r);let a=t.seen.get(e);a.ref=i},Qm=(e,t,n,r)=>{let o=e._zod.def;le(o.innerType,t,r);let s=t.seen.get(e);s.ref=o.innerType,n.readOnly=!0};var ca=(e,t,n,r)=>{let o=e._zod.def;le(o.innerType,t,r);let s=t.seen.get(e);s.ref=o.innerType},ef=(e,t,n,r)=>{let o=e._zod.innerType;le(o,t,r);let s=t.seen.get(e);s.ref=o};var JT=b(\"ZodISODateTime\",(e,t)=>{up.init(e,t),se.init(e,t)});function tf(e){return bm(JT,e)}var WT=b(\"ZodISODate\",(e,t)=>{dp.init(e,t),se.init(e,t)});function nf(e){return vm(WT,e)}var KT=b(\"ZodISOTime\",(e,t)=>{pp.init(e,t),se.init(e,t)});function rf(e){return _m(KT,e)}var HT=b(\"ZodISODuration\",(e,t)=>{mp.init(e,t),se.init(e,t)});function of(e){return wm(HT,e)}var XT=(e,t)=>{xo.init(e,t),e.name=\"ZodError\",Object.defineProperties(e,{format:{value:(n)=>Fu(e,n)},flatten:{value:(n)=>Vu(e,n)},addIssue:{value:(n)=>{e.issues.push(n),e.message=JSON.stringify(e.issues,Rr,2)}},addIssues:{value:(n)=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,Rr,2)}},isEmpty:{get(){return e.issues.length===0}}})};var ze=b(\"ZodError\",XT,{Parent:Error});var sf=So(ze),af=Io(ze),cf=Ar(ze),lf=Cr(ze),uf=Ku(ze),df=Hu(ze),pf=Zu(ze),mf=Yu(ze),ff=Xu(ze),gf=Qu(ze),hf=ed(ze),yf=td(ze);var bf=new WeakMap;function Mr(e,t,n){let r=Object.getPrototypeOf(e),o=bf.get(r);if(!o)o=new Set,bf.set(r,o);if(o.has(t))return;o.add(t);for(let s in n){let i=n[s];Object.defineProperty(r,s,{configurable:!0,enumerable:!1,get(){let a=i.bind(this);return Object.defineProperty(this,s,{configurable:!0,writable:!0,enumerable:!0,value:a}),a},set(a){Object.defineProperty(this,s,{configurable:!0,writable:!0,enumerable:!0,value:a})}})}}var re=b(\"ZodType\",(e,t)=>(te.init(e,t),Object.assign(e[\"~standard\"],{jsonSchema:{input:$r(e,\"input\"),output:$r(e,\"output\")}}),e.toJSONSchema=Pm(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,\"_def\",{value:t}),e.parse=(n,r)=>sf(e,n,r,{callee:e.parse}),e.safeParse=(n,r)=>cf(e,n,r),e.parseAsync=async(n,r)=>af(e,n,r,{callee:e.parseAsync}),e.safeParseAsync=async(n,r)=>lf(e,n,r),e.spa=e.safeParseAsync,e.encode=(n,r)=>uf(e,n,r),e.decode=(n,r)=>df(e,n,r),e.encodeAsync=async(n,r)=>pf(e,n,r),e.decodeAsync=async(n,r)=>mf(e,n,r),e.safeEncode=(n,r)=>ff(e,n,r),e.safeDecode=(n,r)=>gf(e,n,r),e.safeEncodeAsync=async(n,r)=>hf(e,n,r),e.safeDecodeAsync=async(n,r)=>yf(e,n,r),Mr(e,\"ZodType\",{check(...n){let r=this.def;return this.clone(Rt(r,{checks:[...r.checks??[],...n.map((o)=>typeof o===\"function\"?{_zod:{check:o,def:{check:\"custom\"},onattach:[]}}:o)]}),{parent:!0})},with(...n){return this.check(...n)},clone(n,r){return Xe(this,n,r)},brand(){return this},register(n,r){return n.add(this,r),this},refine(n,r){return this.check(WA(n,r))},superRefine(n,r){return this.check(KA(n,r))},overwrite(n){return this.check(Et(n))},optional(){return xf(this)},exactOptional(){return $A(this)},nullable(){return Sf(this)},nullish(){return xf(Sf(this))},nonoptional(n){return DA(this,n)},array(){return ge(this)},or(n){return zn([this,n])},and(n){return CA(this,n)},transform(n){return If(this,Cf(n))},default(n){return zA(this,n)},prefault(n){return NA(this,n)},catch(n){return LA(this,n)},pipe(n){return If(this,n)},readonly(){return VA(this)},describe(n){let r=this.clone();return mn.add(r,{description:n}),r},meta(...n){if(n.length===0)return mn.get(this);let r=this.clone();return mn.add(r,n[0]),r},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(n){return n(this)}}),Object.defineProperty(e,\"description\",{get(){return mn.get(e)?.description},configurable:!0}),e)),kf=b(\"_ZodString\",(e,t)=>{Ao.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,s)=>Om(e,r,o,s);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,Mr(e,\"_ZodString\",{regex(...r){return this.check(Ki(...r))},includes(...r){return this.check(Yi(...r))},startsWith(...r){return this.check(Xi(...r))},endsWith(...r){return this.check(Qi(...r))},min(...r){return this.check(qn(...r))},max(...r){return this.check(Oo(...r))},length(...r){return this.check($o(...r))},nonempty(...r){return this.check(qn(1,...r))},lowercase(r){return this.check(Hi(r))},uppercase(r){return this.check(Zi(r))},trim(){return this.check(ta())},normalize(...r){return this.check(ea(...r))},toLowerCase(){return this.check(na())},toUpperCase(){return this.check(ra())},slugify(){return this.check(oa())}})}),eA=b(\"ZodString\",(e,t)=>{Ao.init(e,t),kf.init(e,t),e.email=(n)=>e.check(Yp(tA,n)),e.url=(n)=>e.check(nm(nA,n)),e.jwt=(n)=>e.check(ym(yA,n)),e.emoji=(n)=>e.check(rm(rA,n)),e.guid=(n)=>e.check(Wi(vf,n)),e.uuid=(n)=>e.check(Xp(qo,n)),e.uuidv4=(n)=>e.check(Qp(qo,n)),e.uuidv6=(n)=>e.check(em(qo,n)),e.uuidv7=(n)=>e.check(tm(qo,n)),e.nanoid=(n)=>e.check(om(oA,n)),e.guid=(n)=>e.check(Wi(vf,n)),e.cuid=(n)=>e.check(sm(sA,n)),e.cuid2=(n)=>e.check(im(iA,n)),e.ulid=(n)=>e.check(am(aA,n)),e.base64=(n)=>e.check(fm(fA,n)),e.base64url=(n)=>e.check(gm(gA,n)),e.xid=(n)=>e.check(cm(cA,n)),e.ksuid=(n)=>e.check(lm(lA,n)),e.ipv4=(n)=>e.check(um(uA,n)),e.ipv6=(n)=>e.check(dm(dA,n)),e.cidrv4=(n)=>e.check(pm(pA,n)),e.cidrv6=(n)=>e.check(mm(mA,n)),e.e164=(n)=>e.check(hm(hA,n)),e.datetime=(n)=>e.check(tf(n)),e.date=(n)=>e.check(nf(n)),e.time=(n)=>e.check(rf(n)),e.duration=(n)=>e.check(of(n))});function w(e){return Zp(eA,e)}var se=b(\"ZodStringFormat\",(e,t)=>{ne.init(e,t),kf.init(e,t)}),tA=b(\"ZodEmail\",(e,t)=>{tp.init(e,t),se.init(e,t)});var vf=b(\"ZodGUID\",(e,t)=>{Qd.init(e,t),se.init(e,t)});var qo=b(\"ZodUUID\",(e,t)=>{ep.init(e,t),se.init(e,t)});var nA=b(\"ZodURL\",(e,t)=>{np.init(e,t),se.init(e,t)});var rA=b(\"ZodEmoji\",(e,t)=>{rp.init(e,t),se.init(e,t)});var oA=b(\"ZodNanoID\",(e,t)=>{op.init(e,t),se.init(e,t)});var sA=b(\"ZodCUID\",(e,t)=>{sp.init(e,t),se.init(e,t)});var iA=b(\"ZodCUID2\",(e,t)=>{ip.init(e,t),se.init(e,t)});var aA=b(\"ZodULID\",(e,t)=>{ap.init(e,t),se.init(e,t)});var cA=b(\"ZodXID\",(e,t)=>{cp.init(e,t),se.init(e,t)});var lA=b(\"ZodKSUID\",(e,t)=>{lp.init(e,t),se.init(e,t)});var uA=b(\"ZodIPv4\",(e,t)=>{fp.init(e,t),se.init(e,t)});var dA=b(\"ZodIPv6\",(e,t)=>{gp.init(e,t),se.init(e,t)});var pA=b(\"ZodCIDRv4\",(e,t)=>{hp.init(e,t),se.init(e,t)});var mA=b(\"ZodCIDRv6\",(e,t)=>{yp.init(e,t),se.init(e,t)});var fA=b(\"ZodBase64\",(e,t)=>{vp.init(e,t),se.init(e,t)});var gA=b(\"ZodBase64URL\",(e,t)=>{_p.init(e,t),se.init(e,t)});var hA=b(\"ZodE164\",(e,t)=>{wp.init(e,t),se.init(e,t)});var yA=b(\"ZodJWT\",(e,t)=>{xp.init(e,t),se.init(e,t)});var Rf=b(\"ZodNumber\",(e,t)=>{Bi.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,s)=>$m(e,r,o,s),Mr(e,\"ZodNumber\",{gt(r,o){return this.check(Eo(r,o))},gte(r,o){return this.check(Or(r,o))},min(r,o){return this.check(Or(r,o))},lt(r,o){return this.check(Co(r,o))},lte(r,o){return this.check(Pr(r,o))},max(r,o){return this.check(Pr(r,o))},int(r){return this.check(_f(r))},safe(r){return this.check(_f(r))},positive(r){return this.check(Eo(0,r))},nonnegative(r){return this.check(Or(0,r))},negative(r){return this.check(Co(0,r))},nonpositive(r){return this.check(Pr(0,r))},multipleOf(r,o){return this.check(Po(r,o))},step(r,o){return this.check(Po(r,o))},finite(){return this}});let n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??\"\").includes(\"int\")||Number.isSafeInteger(n.multipleOf??0.5),e.isFinite=!0,e.format=n.format??null});function xe(e){return xm(Rf,e)}var bA=b(\"ZodNumberFormat\",(e,t)=>{Sp.init(e,t),Rf.init(e,t)});function _f(e){return Sm(bA,e)}var vA=b(\"ZodBoolean\",(e,t)=>{Ip.init(e,t),re.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Mm(e,n,r,o)});function fe(e){return Im(vA,e)}var _A=b(\"ZodNull\",(e,t)=>{kp.init(e,t),re.init(e,t),e._zod.processJSONSchema=(n,r,o)=>qm(e,n,r,o)});function wA(e){return km(_A,e)}var xA=b(\"ZodUnknown\",(e,t)=>{Rp.init(e,t),re.init(e,t),e._zod.processJSONSchema=(n,r,o)=>jm(e,n,r,o)});function la(){return Rm(xA)}var SA=b(\"ZodNever\",(e,t)=>{Tp.init(e,t),re.init(e,t),e._zod.processJSONSchema=(n,r,o)=>zm(e,n,r,o)});function IA(e){return Tm(SA,e)}var kA=b(\"ZodArray\",(e,t)=>{Ap.init(e,t),re.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Gm(e,n,r,o),e.element=t.element,Mr(e,\"ZodArray\",{min(n,r){return this.check(qn(n,r))},nonempty(n){return this.check(qn(1,n))},max(n,r){return this.check(Oo(n,r))},length(n,r){return this.check($o(n,r))},unwrap(){return this.element}})});function ge(e,t){return Am(kA,e,t)}var RA=b(\"ZodObject\",(e,t)=>{Pp.init(e,t),re.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Bm(e,n,r,o),J(e,\"shape\",()=>t.shape),Mr(e,\"ZodObject\",{keyof(){return ce(Object.keys(this._zod.def.shape))},catchall(n){return this.clone({...this._zod.def,catchall:n})},passthrough(){return this.clone({...this._zod.def,catchall:la()})},loose(){return this.clone({...this._zod.def,catchall:la()})},strict(){return this.clone({...this._zod.def,catchall:IA()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(n){return TT(this,n)},safeExtend(n){return AT(this,n)},merge(n){return CT(this,n)},pick(n){return kT(this,n)},omit(n){return RT(this,n)},partial(...n){return ET(Ef,this,n[0])},required(...n){return PT(Pf,this,n[0])}})});function G(e,t){let n={type:\"object\",shape:e??{},...P(t)};return new RA(n)}var Tf=b(\"ZodUnion\",(e,t)=>{Vi.init(e,t),re.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Vm(e,n,r,o),e.options=t.options});function zn(e,t){return new Tf({type:\"union\",options:e,...P(t)})}var TA=b(\"ZodDiscriminatedUnion\",(e,t)=>{Tf.init(e,t),Op.init(e,t)});function Af(e,t,n){return new TA({type:\"union\",options:t,discriminator:e,...P(n)})}var AA=b(\"ZodIntersection\",(e,t)=>{$p.init(e,t),re.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Fm(e,n,r,o)});function CA(e,t){return new AA({type:\"intersection\",left:e,right:t})}var wf=b(\"ZodRecord\",(e,t)=>{Mp.init(e,t),re.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Jm(e,n,r,o),e.keyType=t.keyType,e.valueType=t.valueType});function qr(e,t,n){if(!t||!t._zod)return new wf({type:\"record\",keyType:w(),valueType:e,...P(t)});return new wf({type:\"record\",keyType:e,valueType:t,...P(n)})}var ua=b(\"ZodEnum\",(e,t)=>{qp.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,s)=>Nm(e,r,o,s),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(r,o)=>{let s={};for(let i of r)if(n.has(i))s[i]=t.entries[i];else throw Error(`Key ${i} not found in enum`);return new ua({...t,checks:[],...P(o),entries:s})},e.exclude=(r,o)=>{let s={...t.entries};for(let i of r)if(n.has(i))delete s[i];else throw Error(`Key ${i} not found in enum`);return new ua({...t,checks:[],...P(o),entries:s})}});function ce(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map((r)=>[r,r])):e;return new ua({type:\"enum\",entries:n,...P(t)})}var EA=b(\"ZodLiteral\",(e,t)=>{zp.init(e,t),re.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Dm(e,n,r,o),e.values=new Set(t.values),Object.defineProperty(e,\"value\",{get(){if(t.values.length>1)throw Error(\"This schema contains multiple valid literal values. Use `.values` instead.\");return t.values[0]}})});function ye(e,t){return new EA({type:\"literal\",values:Array.isArray(e)?e:[e],...P(t)})}var PA=b(\"ZodTransform\",(e,t)=>{jp.init(e,t),re.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Lm(e,n,r,o),e._zod.parse=(n,r)=>{if(r.direction===\"backward\")throw new kr(e.constructor.name);n.addIssue=(s)=>{if(typeof s===\"string\")n.issues.push(pn(s,n.value,t));else{let i=s;if(i.fatal)i.continue=!1;i.code??(i.code=\"custom\"),i.input??(i.input=n.value),i.inst??(i.inst=e),n.issues.push(pn(i))}};let o=t.transform(n.value,n);if(o instanceof Promise)return o.then((s)=>(n.value=s,n.fallback=!0,n));return n.value=o,n.fallback=!0,n}});function Cf(e){return new PA({type:\"transform\",transform:e})}var Ef=b(\"ZodOptional\",(e,t)=>{Fi.init(e,t),re.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ca(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function xf(e){return new Ef({type:\"optional\",innerType:e})}var OA=b(\"ZodExactOptional\",(e,t)=>{Np.init(e,t),re.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ca(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function $A(e){return new OA({type:\"optional\",innerType:e})}var MA=b(\"ZodNullable\",(e,t)=>{Dp.init(e,t),re.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Wm(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Sf(e){return new MA({type:\"nullable\",innerType:e})}var qA=b(\"ZodDefault\",(e,t)=>{Up.init(e,t),re.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Hm(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function zA(e,t){return new qA({type:\"default\",innerType:e,get defaultValue(){return typeof t===\"function\"?t():Mi(t)}})}var jA=b(\"ZodPrefault\",(e,t)=>{Lp.init(e,t),re.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Zm(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function NA(e,t){return new jA({type:\"prefault\",innerType:e,get defaultValue(){return typeof t===\"function\"?t():Mi(t)}})}var Pf=b(\"ZodNonOptional\",(e,t)=>{Gp.init(e,t),re.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Km(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function DA(e,t){return new Pf({type:\"nonoptional\",innerType:e,...P(t)})}var UA=b(\"ZodCatch\",(e,t)=>{Bp.init(e,t),re.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Ym(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function LA(e,t){return new UA({type:\"catch\",innerType:e,catchValue:typeof t===\"function\"?t:()=>t})}var Of=b(\"ZodPipe\",(e,t)=>{Ji.init(e,t),re.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Xm(e,n,r,o),e.in=t.in,e.out=t.out});function If(e,t){return new Of({type:\"pipe\",in:e,out:t})}var GA=b(\"ZodPreprocess\",(e,t)=>{Of.init(e,t),Vp.init(e,t)}),BA=b(\"ZodReadonly\",(e,t)=>{Fp.init(e,t),re.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Qm(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function VA(e){return new BA({type:\"readonly\",innerType:e})}var FA=b(\"ZodLazy\",(e,t)=>{Jp.init(e,t),re.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ef(e,n,r,o),e.unwrap=()=>e._zod.def.getter()});function $f(e){return new FA({type:\"lazy\",getter:e})}var JA=b(\"ZodCustom\",(e,t)=>{Wp.init(e,t),re.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Um(e,n,r,o)});function WA(e,t={}){return Cm(JA,e,t)}function KA(e,t){return Em(e,t)}function da(e){let t=$f(()=>zn([w(e),xe(),fe(),wA(),ge(t),qr(w(),t)]));return t}function HA(e,t){return new GA({type:\"pipe\",in:Cf(e),out:t})}var Qe={invalid_type:\"invalid_type\",too_big:\"too_big\",too_small:\"too_small\",invalid_format:\"invalid_format\",not_multiple_of:\"not_multiple_of\",unrecognized_keys:\"unrecognized_keys\",invalid_union:\"invalid_union\",invalid_key:\"invalid_key\",invalid_element:\"invalid_element\",invalid_value:\"invalid_value\",custom:\"custom\"};var Mf;(function(e){})(Mf||(Mf={}));var zo=I(()=>ce([\"account:read\",\"account:admin\",\"members:manage\",\"workspace:create\",\"billing:read\",\"billing:manage\",\"workspace:read\",\"workspace:admin\",\"sessions:create\",\"sessions:read\",\"sessions:control\",\"stream:view\",\"stream:control\",\"stream:acknowledge\",\"files:upload\",\"files:read\",\"files:write\",\"terminal:attach\",\"documents:manage\",\"documents:search\",\"scheduled_tasks:manage\",\"scheduled_tasks:run\",\"github:manage\",\"github:use\",\"api_keys:manage\",\"usage_allowances:manage\",\"connections:read\",\"connections:write\",\"capabilities:manage\",\"environments:manage\",\"environments:use\",\"variable-sets:list\",\"variable-sets:read\",\"variable-sets:write\",\"variable-sets:manage\",\"variable-sets:attach\",\"variable-sets:use\",\"secrets:list\",\"secrets:read\",\"secrets:write\",\"secrets:use\",\"mcp_servers:attach\",\"codemode:call\",\"goals:manage\",\"enrollments:read\",\"enrollments:manage\",\"rigs:use\",\"rigs:manage\",\"artifacts:read\",\"artifacts:publish\"]));var pa=1;var ZA=4096,zf=16777216,YA=8,XA=1024,ma=1;var fn=I(()=>w().regex(/^[0-9a-f]{64}$/u)),QA=I(()=>w().min(1).max(256).regex(/^[A-Za-z0-9_-]+$/u)),jf=I(()=>w().min(1).max(512).regex(/^[^\\u0000-\\u001f\\u007f]+$/u)),Nf=I(()=>w().min(1).max(128).regex(/^[A-Za-z_$][A-Za-z0-9_$]*$/u).refine((e)=>![\"__proto__\",\"prototype\",\"constructor\"].includes(e),{message:\"unsafe Codemode namespace segment\"})),jn=I(()=>qr(w().max(512),da())),jo=I(()=>G({serverId:QA,toolName:jf}).strict()),Df=jo,Uf=I(()=>G({src:w().min(1).max(8192),mimeType:w().min(1).max(128).optional(),sizes:ge(w().min(1).max(64)).max(16).optional(),theme:ce([\"light\",\"dark\"]).optional()}).strict()),eC=I(()=>G({title:w().max(512).optional(),readOnlyHint:fe().optional(),destructiveHint:fe().optional(),idempotentHint:fe().optional(),openWorldHint:fe().optional()}).loose()),qf=jn;var Lf=I(()=>G({identity:jo,modelName:jf,codemodePath:ge(Nf).min(2).max(YA),title:w().min(1).max(512).optional(),description:w().max(32768).optional(),inputSchema:qf,outputSchema:qf.optional(),annotations:eC.optional(),icons:ge(Uf).max(16).optional(),source:ce([\"opengeni\",\"files\",\"docs\",\"mcp\",\"codex_apps\",\"interaction\"]),approval:ce([\"none\",\"human\",\"policy\"])}).strict()),Gf=Lf;var Bf=I(()=>G({version:ye(pa),accountId:w().uuid(),workspaceId:w().uuid(),sessionId:w().uuid(),turnId:w().uuid(),attemptId:w().uuid(),executionGeneration:xe().int().positive(),generation:xe().int().positive(),digest:fn,createdAt:w().datetime({offset:!0}),firstPartyMcpPermissions:ge(zo).max(128).optional(),entries:ge(Lf).max(ZA)}).strict().superRefine((e,t)=>{let n=new Set,r=new Set,o=new Set;for(let[s,i]of e.entries.entries()){let a=`${i.identity.serverId}\\x00${i.identity.toolName}`,c=i.codemodePath.join(\".\");if(n.has(a))t.addIssue({code:\"custom\",path:[\"entries\",s,\"identity\"],message:\"duplicate tool identity\"});if(r.has(i.modelName))t.addIssue({code:\"custom\",path:[\"entries\",s,\"modelName\"],message:\"duplicate model tool name\"});if(o.has(c))t.addIssue({code:\"custom\",path:[\"entries\",s,\"codemodePath\"],message:\"duplicate Codemode tool path\"});n.add(a),r.add(i.modelName),o.add(c)}})),No=I(()=>G({kind:ce([\"model\",\"codemode\"]),subjectId:w().min(1).max(1024)}).strict()),fa=I(()=>G({operationId:w().uuid(),catalogDigest:fn,identity:jo,arguments:jn,caller:No}).strict()),zr=I(()=>qr(w().max(256),da()).optional()),Pt=I(()=>qr(w().max(512),da()).optional()),tC=I(()=>G({type:ye(\"text\"),text:w(),annotations:zr,_meta:Pt}).loose()),nC=I(()=>G({type:ye(\"image\"),data:w(),mimeType:w().min(1).max(128),annotations:zr,_meta:Pt}).loose()),rC=I(()=>G({type:ye(\"audio\"),data:w(),mimeType:w().min(1).max(128),annotations:zr,_meta:Pt}).loose()),oC=I(()=>G({type:ye(\"resource_link\"),name:w().min(1).max(1024),title:w().max(1024).optional(),uri:w().min(1).max(16384),description:w().max(32768).optional(),mimeType:w().max(128).optional(),size:xe().int().nonnegative().optional(),icons:ge(Uf).max(16).optional(),annotations:zr,_meta:Pt}).loose()),sC=I(()=>G({uri:w().min(1).max(16384),mimeType:w().max(128).optional(),text:w(),_meta:Pt}).loose()),iC=I(()=>G({uri:w().min(1).max(16384),mimeType:w().max(128).optional(),blob:w(),_meta:Pt}).loose()),aC=I(()=>G({type:ye(\"resource\"),resource:zn([sC,iC]),annotations:zr,_meta:Pt}).loose()),cC=I(()=>Af(\"type\",[tC,nC,rC,oC,aC])),jr=I(()=>G({content:ge(cC).max(XA),structuredContent:jn.optional(),isError:fe().optional(),_meta:Pt}).loose()),Vf=jr,Ff=I(()=>G({operationId:w().uuid().optional(),catalogDigest:fn,identity:Df,arguments:jn,siteArtifactId:w().uuid().optional(),siteVersionId:w().uuid().optional(),approvalToken:w().regex(/^ogta_[A-Za-z0-9_-]{43}$/u).optional()}).strict().superRefine(ha));var Jf=I(()=>zn([G({identity:Df}).strict(),G({path:ge(Nf).min(2).max(8)}).strict()])),Wf={siteArtifactId:w().uuid().optional(),siteVersionId:w().uuid().optional()},Kf=I(()=>G({target:Jf,...Wf}).strict().superRefine(ha));var ga=I(()=>G({target:Jf,operationId:w().uuid(),arguments:jn,expectedDefinitionDigest:fn.optional(),approvalToken:w().regex(/^ogta_[A-Za-z0-9_-]{43}$/u).optional(),...Wf}).strict().superRefine(ha));function ha(e,t){if(e.siteArtifactId===void 0===(e.siteVersionId===void 0))return;t.addIssue({code:\"custom\",message:\"siteArtifactId and siteVersionId must be provided together\",path:[e.siteArtifactId===void 0?\"siteArtifactId\":\"siteVersionId\"]})}var lC=I(()=>ce([\"queued\",\"waiting_for_approval\",\"running\",\"completed\",\"failed\",\"outcome_unknown\",\"cancelled\"])),ya=I(()=>G({version:ye(ma),operationId:w().uuid(),accountId:w().uuid(),workspaceId:w().uuid(),sessionId:w().uuid(),turnId:w().uuid(),attemptId:w().uuid(),executionGeneration:xe().int().positive(),catalogDigest:fn,requestDigest:fn,identity:jo,arguments:jn,caller:No.refine((e)=>e.kind===\"codemode\",{message:\"Codemode operation caller must be codemode\"}),state:lC,durableApproval:ye(!0).optional(),approvalRequestId:w().uuid().optional(),result:jr.nullable(),errorCode:w().min(1).max(128).nullable(),errorMessage:w().min(1).max(4096).nullable(),createdAt:w().datetime({offset:!0}),claimedAt:w().datetime({offset:!0}).nullable(),executionStartedAt:w().datetime({offset:!0}).nullable(),completedAt:w().datetime({offset:!0}).nullable(),updatedAt:w().datetime({offset:!0})}).strict());var Hf=I(()=>G({operation:ya,dispatch:ce([\"accepted\",\"already_running\",\"terminal\",\"unavailable\",\"rejected\"])}).strict()),ba=I(()=>G({version:ye(ma),operationId:w().uuid(),catalogDigest:fn}).strict()),va=I(()=>G({version:ye(ma),operationId:w().uuid(),status:ce([\"accepted\",\"already_running\",\"terminal\",\"unavailable\",\"rejected\"])}).strict());var uC=Object.freeze([{id:\"config.client\",method:\"GET\",pattern:/^\\/v1\\/config\\/client$/u},{id:\"workspace.get\",method:\"GET\",pattern:/^$/u},{id:\"site.config\",method:\"GET\",pattern:/^\\/site\\/config$/u},{id:\"models.list\",method:\"GET\",pattern:/^\\/model-catalog$/u},{id:\"sessions.list\",method:\"GET\",pattern:/^\\/sessions$/u},{id:\"sessions.create\",method:\"POST\",pattern:/^\\/sessions$/u,agent:!0},{id:\"sessions.get\",method:\"GET\",pattern:new RegExp(\"^/sessions/[A-Za-z0-9_-]{1,128}$\",\"u\")},{id:\"sessions.events\",method:\"GET\",pattern:new RegExp(\"^/sessions/[A-Za-z0-9_-]{1,128}/events$\",\"u\")},{id:\"sessions.stream\",method:\"GET\",pattern:new RegExp(\"^/sessions/[A-Za-z0-9_-]{1,128}/events/stream$\",\"u\"),stream:!0},{id:\"sessions.send\",method:\"POST\",pattern:new RegExp(\"^/sessions/[A-Za-z0-9_-]{1,128}/events$\",\"u\"),agent:!0},{id:\"sessions.steer\",method:\"POST\",pattern:new RegExp(\"^/sessions/[A-Za-z0-9_-]{1,128}/steer$\",\"u\"),agent:!0},{id:\"sessions.control\",method:\"POST\",pattern:new RegExp(\"^/sessions/[A-Za-z0-9_-]{1,128}/control$\",\"u\"),agent:!0},{id:\"sessions.queue\",method:\"GET\",pattern:new RegExp(\"^/sessions/[A-Za-z0-9_-]{1,128}/queue$\",\"u\")},{id:\"sessions.queue.item\",method:\"POST\",pattern:new RegExp(\"^/sessions/[A-Za-z0-9_-]{1,128}/queue/[A-Za-z0-9_-]{1,128}/(?:move|edit|steer|delete)$\",\"u\"),agent:!0},{id:\"sessions.composerDraft.get\",method:\"GET\",pattern:new RegExp(\"^/sessions/[A-Za-z0-9_-]{1,128}/composer-draft$\",\"u\")},{id:\"sessions.composerDraft.put\",method:\"PUT\",pattern:new RegExp(\"^/sessions/[A-Za-z0-9_-]{1,128}/composer-draft$\",\"u\")},{id:\"sessions.composerDraft.submit\",method:\"POST\",pattern:new RegExp(\"^/sessions/[A-Za-z0-9_-]{1,128}/composer-draft/submit$\",\"u\"),agent:!0},{id:\"sessions.humanInput\",method:\"GET\",pattern:new RegExp(\"^/sessions/[A-Za-z0-9_-]{1,128}/human-input-requests$\",\"u\")},{id:\"sessions.humanInput.get\",method:\"GET\",pattern:new RegExp(\"^/sessions/[A-Za-z0-9_-]{1,128}/human-input-requests/[A-Za-z0-9_-]{1,128}$\",\"u\")},{id:\"data.read\",method:\"GET\",pattern:new RegExp(\"^/published-artifacts/current/(?:data|files)(?:/[A-Za-z0-9._~:@!$&'()*+,;=-]+)*$\",\"u\")},{id:\"data.write\",method:\"POST\",pattern:new RegExp(\"^/published-artifacts/current/(?:data|files)(?:/[A-Za-z0-9._~:@!$&'()*+,;=-]+)*$\",\"u\")},{id:\"data.put\",method:\"PUT\",pattern:new RegExp(\"^/published-artifacts/current/(?:data|files)(?:/[A-Za-z0-9._~:@!$&'()*+,;=-]+)*$\",\"u\")},{id:\"data.patch\",method:\"PATCH\",pattern:new RegExp(\"^/published-artifacts/current/(?:data|files)(?:/[A-Za-z0-9._~:@!$&'()*+,;=-]+)*$\",\"u\")},{id:\"data.delete\",method:\"DELETE\",pattern:new RegExp(\"^/published-artifacts/current/(?:data|files)(?:/[A-Za-z0-9._~:@!$&'()*+,;=-]+)*$\",\"u\")},{id:\"sql.run\",method:\"POST\",pattern:/^\\/published-artifacts\\/current\\/sql\\/queries\\/[A-Za-z][A-Za-z0-9_-]{0,63}$/u},{id:\"site.report\",method:\"POST\",pattern:/^\\/site\\/reports$/u}]),gV=Object.freeze([\"catalog\",\"declarations\",\"call\",\"resolve\",\"invoke\"]);function Zf(e,t){if(/[%\\\\#\\u0000-\\u0020\\u007f]/u.test(t))return null;if(t.split(\"/\").some((s)=>s===\".\"||s===\"..\"))return null;let n=e.toUpperCase(),r;if(t===\"/v1/config/client\")r=t;else if(t===\"/v1/workspaces/site-host\")r=\"\";else if(t.startsWith(\"/v1/workspaces/site-host/\"))r=t.slice(24);else return null;let o=uC.find((s)=>s.method===n&&s.pattern.test(r));return o?{operation:o,suffix:r}:null}var dC=I(()=>G({id:w().max(64).describe(\"Stable report requirement identifier, at most 64 ASCII characters; not a title or status.\").regex(/^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/),title:w().trim().min(1).max(512).describe(\"Short human-readable report title, at most 512 UTF-8 bytes. Keep normal spaces; do not put the report or a progress transcript here.\").refine((e)=>new TextEncoder().encode(e).byteLength<=512,\"Report title exceeds 512 UTF-8 bytes\")}).strict()),Yf=I(()=>ge(dC).max(16).superRefine((e,t)=>{if(new Set(e.map((n)=>n.id)).size!==e.length)t.addIssue({code:\"custom\",message:\"Duplicate report requirement IDs\"})}));var _a=I(()=>ce([\"automatic\",\"review_first\",\"off\"]));var pC=I(()=>G({knowledge:_a,instructions:_a,skills:_a}).strict()),xV=Object.freeze({knowledge:\"automatic\",instructions:\"automatic\",skills:\"automatic\"}),Xf=I(()=>pC.partial());var mC={vaultsPerOwnerScope:200,itemsPerVault:2000,fieldsPerItem:50,versionsPerField:10,nameMaxChars:120,descriptionMaxChars:2000,websitesPerItem:20,websiteMaxChars:2048,textValueMaxBytes:65536,fileValueMaxBytes:262144,referenceMaxChars:300,execEnvMaxBytes:262144,execValueMaxBytes:102400,policyVaultIdsMax:200,searchResultsMax:50,searchScanMax:1000,searchCursorMaxChars:1024,providerReadsPerAttempt:50,providerValueCacheMs:60000};var Qf=I(()=>Af(\"mode\",[G({mode:ye(\"all\")}).strict(),G({mode:ye(\"selected\"),vaultIds:ge(w().uuid()).max(mC.policyVaultIdsMax)}).strict()])),RV=Object.freeze({mode:\"all\"});var fC=[\"webSearch\",\"humanInput\",\"skills\",\"goals\",\"subagents\",\"knowledge\",\"schedules\",\"artifacts\",\"browser\",\"secrets\",\"media\",\"workspaceFiles\",\"workspaceConnectors\",\"workspaceAdmin\"];var PV=fC.filter((e)=>e!==\"skills\"),gC=I(()=>zn([ye(\"read\"),ye(\"manage\"),ye(!1)])),hC=I(()=>ce([\"all\",\"none\"])),yC=I(()=>G({webSearch:fe().optional(),humanInput:fe().optional(),skills:gC.optional(),goals:fe().optional(),subagents:fe().optional(),knowledge:fe().optional(),schedules:fe().optional(),artifacts:fe().optional(),browser:fe().optional(),secrets:fe().optional(),media:fe().optional(),workspaceFiles:fe().optional(),workspaceConnectors:fe().optional(),workspaceAdmin:fe().optional()}).strict()),bC=I(()=>zn([ye(\"all\"),ye(\"none\"),yC.extend({from:hC}).strict()])),vC=I(()=>ce([\"opengeni\",\"markdown\"])),_C=8000,eg=65536,wC=I(()=>w().trim().min(1).max(_C)),tg=I(()=>G({capabilities:bC.optional(),identity:wC.nullable().optional(),instructions:w().trim().min(1).max(eg).optional(),renderer:vC.optional(),vaultPolicy:Qf.optional()}).strict());var xC=[\"web\",\"slack\",\"api_key\",\"embedded\",\"scheduled\",\"agent\",\"voice\",\"site\",\"automation\",\"mcp\",\"system\"],ng=I(()=>ce(xC));var rg=[\"openai\",\"azure\",\"codex-subscription\",\"supergrok-subscription\",\"opengeni-gateway\",\"workspace-gateway\",\"organization-gateway\",\"openrouter\",\"workspace-openrouter\",\"organization-openrouter\",\"opper\",\"workspace-opper\",\"organization-opper\",\"organization-openai\",\"organization-azure-openai\",\"registry\"],og=I(()=>ce(rg)),qV=new Set(rg.filter((e)=>e!==\"registry\"));var SC=[\"github.com\",\"gitlab.com\",\"dev.azure.com\",\"slack.com\",\"chatgpt.com\",\"x.com\",\"reddit.com\",\"fiken.no\",\"api.atlassian.com\",\"googleapis.com\",\"gmailmcp.googleapis.com\",\"drivemcp.googleapis.com\",\"mcp.slack.com\",\"api.mobbin.com\",\"mcp.linear.app\",\"mcp.asana.com\",\"mcp.stripe.com\",\"mcp.figma.com\",\"mcp.canva.com\",\"mcp.sentry.dev\",\"mcp.vercel.com\",\"bindings.mcp.cloudflare.com\",\"mcp.paypal.com\",\"mcp.monday.com\",\"mcp.airtable.com\",\"mcp.zapier.com\",\"mcp.webflow.com\",\"mcp.supabase.com\",\"mcp.clickup.com\",\"mcp.calendly.com\",\"mcp.box.com\",\"mcp.dropbox.com\",\"mcp.amplitude.com\",\"mcp.posthog.com\",\"mcp.pagerduty.com\",\"mcp.apollo.io\",\"api.ahrefs.com\",\"mcp.semrush.com\",\"mcp.frontapp.com\",\"mcp.otter.ai\",\"mcp.notion.com\",\"mcp.hubspot.com\",\"mcp.atlassian.com\",\"mcp.intercom.com\"],zV=new Set(SC);var sg=[\"exec_command\",\"write_stdin\",\"view_image\",\"apply_patch\",\"skill_read\",\"repository_skill_read\",\"request_human_input\",\"list_models\",\"code_search\",\"tool_search\",\"tool_list\",\"tool_invoke\",\"generate_image\",\"generate_video\",\"get_video_generation_capabilities\",\"computer_screenshot\",\"web_search_call\",\"image_generation_call\",\"code_interpreter_call\",\"file_search_call\",\"computer_call\",\"local_shell_call\",\"shell_call\",\"apply_patch_call\"],ig=[\"skill_checkout\",\"skill_publish\",\"skill_install\",\"skill_remove\",\"skill_save\",\"skill_search\",\"operation_read\",\"knowledge_source_fetch\",\"knowledge_source_read\",\"files_get_download_url\"];var ag=\"/v1/workspaces/site-host\",lg=/^\\/v1\\/workspaces\\/site-host\\/published-artifacts\\/([^/]+)\\/(?:data|files|sql)(?:\\/|$)/u,ug=\"00000000-0000-0000-0000-000000000000\",dg=\"x-opengeni-site-frame\",pg=\"preview\",mg=\"x-opengeni-site-frame-id\";class Ot extends Error{code=\"site_session_path_unsupported\";constructor(){super(\"Unsupported Site session API path\");this.name=\"SiteSessionPathError\"}}class Do extends Error{code=\"site_data_unsupported\";constructor(){super(\"This Site host does not provide Site Data\");this.name=\"SiteDataUnsupportedError\"}}function IC(e){return/[%\\\\#\\u0000-\\u0020\\u007f]/u.test(e)||e.split(\"/\").some((t)=>t===\".\"||t===\"..\")}function fg(e,t){let n=new URL(e,\"http://site.invalid\");if(n.pathname===\"/v1/config/client\"){let r=n.searchParams.getAll(\"workspaceId\");if(r.length>1||r.length===1&&r[0]!==\"site-host\"&&r[0]!==t)throw new Ot;if(t!==\"site-host\")n.searchParams.set(\"workspaceId\",t);return n.pathname+n.search}return e.replace(\"/workspaces/site-host\",`/workspaces/${encodeURIComponent(t)}`)}function gg(e,t,n,r){if(n===\"site-host\")return e;if(!r)throw new Do;return t.replace(\"/published-artifacts/current/\",`/published-artifacts/${encodeURIComponent(r)}/`)}function hg(e,t,n=\"GET\",r){let o=e.split(\"?\")[0],s=Zf(n,o);if(!s)throw new Ot;let i=fg(e,t);if(lg.test(o))return gg(e,i,t,r);if(s.operation.id!==\"sessions.list\")return i;let a=new URL(i,\"http://site.invalid\"),c=a.searchParams.getAll(\"originSiteId\"),l=a.searchParams.getAll(\"siteAccessId\"),u=a.searchParams.getAll(\"view\");if(u.length>1||u.length===1&&u[0]!==\"page\"||c.length+l.length!==1||(c[0]??l[0])!==\"current\")throw new Ot;if(t===\"site-host\")return e;return a.searchParams.set(l.length?\"siteAccessId\":\"originSiteId\",r??ug),a.pathname+a.search}function yg(e,t){let n=e.split(\"?\")[0];if(!(n===ag||n.startsWith(`${ag}/`))&&n!==\"/v1/config/client\"||IC(n))throw new Ot;let o=fg(e,t),s=lg.exec(n);if(s){if(s[1]!==\"current\")throw new Ot;return gg(e,o,t)}let i=new URL(o,\"http://site.invalid\");if(i.searchParams.get(\"originSiteId\")===\"current\"&&t!==\"site-host\")return i.searchParams.set(\"originSiteId\",ug),i.pathname+i.search;return o}function bg(e){let t=new Headers(e),n=(t.get(\"connection\")??\"\").split(\",\").map((r)=>r.trim().toLowerCase());for(let r of[...t.keys()])if(n.includes(r)||/^(authorization|proxy-authorization|cookie|cookie2|host|origin|referer|connection|keep-alive|proxy-connection|te|trailer|transfer-encoding|upgrade|content-length|accept-encoding|forwarded|x-api-key)$/i.test(r)||/^(sec-|x-forwarded-|x-opengeni-(access-key|external-actor|site-|managed-actor))/i.test(r))t.delete(r);return t}var cg=[\"text\",\"annotations\",\"model\",\"reasoningEffort\",\"latencyMode\",\"controlEtag\",\"expectedDraftRevision\"],DV=Object.freeze({\"sessions.send\":[\"type\",\"payload\",\"clientEventId\"],\"sessions.steer\":[...cg,\"clientEventId\"],\"sessions.control\":[\"action\",\"reason\",\"clientEventId\",\"expectedControlEtag\"],\"sessions.composerDraft.put\":[\"text\",\"annotations\",\"resources\",\"model\",\"reasoningEffort\",\"latencyMode\",\"expectedRevision\"],\"sessions.composerDraft.submit\":[...cg,\"resources\",\"connectionAccounts\",\"clientEventId\",\"delivery\"],\"sessions.queue.move\":[\"clientEventId\",\"expectedQueueVersion\",\"beforeTurnId\"],\"sessions.queue.edit\":[\"clientEventId\",\"expectedTurnVersion\",\"expectedDraftRevision\",\"replaceDraft\"],\"sessions.queue.steer\":[\"clientEventId\",\"expectedTurnVersion\",\"controlEtag\"],\"sessions.queue.delete\":[\"clientEventId\",\"expectedTurnVersion\",\"reason\"]});var UV=Object.freeze([\"initialMessage\",\"requestedSessionId\",\"idempotencyKey\",\"clientEventId\",\"model\",\"reasoningEffort\",\"latencyMode\",\"startMode\",\"metadata\"]);var kC=\"tool_result_spilled\",RC=\"application/json\";var TC=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/,AC=I(()=>G({type:ye(kC),sandboxPath:w().min(1).max(4096).nullable(),fileId:w().regex(TC),byteSize:xe().int().positive().safe(),mediaType:ye(RC)}).strict());function vg(e){return AC.safeParse(e).success}function gn(e){if(!e||typeof e!==\"object\"||Array.isArray(e))return e;let t=new Set([\"title\",\"description\",\"examples\",\"$comment\"]),n=new Set([\"properties\",\"patternProperties\",\"$defs\",\"definitions\",\"dependentSchemas\"]),r=new Set([\"allOf\",\"anyOf\",\"oneOf\",\"prefixItems\"]),o=new Set([\"items\",\"contains\",\"additionalProperties\",\"unevaluatedProperties\",\"unevaluatedItems\",\"propertyNames\",\"not\",\"if\",\"then\",\"else\"]);return Object.fromEntries(Object.entries(e).flatMap(([s,i])=>{if(t.has(s))return[];if(n.has(s)&&i&&typeof i===\"object\"&&!Array.isArray(i))return[[s,Object.fromEntries(Object.entries(i).map(([a,c])=>[a,gn(c)]))]];if(r.has(s)&&Array.isArray(i))return[[s,i.map(gn)]];if(o.has(s))return[[s,gn(i)]];return[[s,i]]}))}var wa=I(()=>ce([\"docker\",\"modal\",\"local\",\"none\",\"daytona\",\"runloop\",\"e2b\",\"blaxel\",\"cloudflare\",\"vercel\",\"selfhosted\",\"opensandbox\",\"compute\"]));var Uo=[\"set_session_title\",\"notify_user\",\"notification_withdraw\",\"inbox_tidy\",\"goal_set\",\"goal_update\",\"goal_progress\",\"wait_for_input\",\"goal_complete\",\"goal_pause\",\"goal_resume\",\"knowledge_search\",\"knowledge_prepare_save\",\"knowledge_get\",\"knowledge_browse\",\"knowledge_save\",\"knowledge_retain_file\",\"knowledge_retain_message\",\"knowledge_archive\",\"instruction_policy_save\",\"instruction_policy_get\",\"memory_search\",\"memory_save\",\"memory_correct\",\"preference_registry_summary\",\"preference_registry_get\",\"task_notes_list\",\"task_note_save\",\"task_note_archive\",\"task_note_replace\",\"work_claim_upsert\",\"work_claim_release\",\"knowledge_propose\",\"knowledge_correct\",\"task_note_promote_knowledge\",\"task_note_promote_instruction_policy\",\"task_note_promote_preference\",\"instruction_policy_propose\",\"preference_propose\",\"remember\",\"remember_confirm\",\"company_profile_propose\",\"company_profile_confirm\",\"sandboxes_list\",\"sandbox_attach\",\"sandbox_swap\",\"run_on\",\"sandbox_provision\",\"connected_machine_remove\",\"connected_machine_enroll_token\",\"connected_machine_enable_screen_control\",\"project_list\",\"project_get\",\"project_create\",\"project_update\",\"project_reorder\",\"project_delete\",\"session_set_project\",\"admin_actions_search\",\"admin_action_describe\",\"admin_action_call\",\"rig_list\",\"rig_get\",\"rig_propose_change\",\"rig_verify\",\"rig_promote\",\"sessions_list\",\"session_get\",\"session_set_model\",\"session_events\",\"session_wait\",\"command_wait\",\"command_read\",\"session_create\",\"session_send_message\",\"session_message_status\",\"session_target_get\",\"session_target_set\",\"session_pause\",\"session_resume\",\"session_steer\",\"session_human_input_respond\",\"set_other_session_title\",\"interaction_discover\",\"browser_open\",\"browser_tabs\",\"browser_observe\",\"browser_read\",\"browser_screenshot\",\"browser_act\",\"browser_clipboard\",\"browser_debug\",\"browser_downloads\",\"browser_download_save\",\"browser_record\",\"browser_auth\",\"interaction_request_human\",\"browser_identity\",\"browser_publish\",\"browser_lifecycle\",\"computer_open\",\"computer_targets\",\"computer_observe\",\"computer_clipboard\",\"computer_act\",\"computer_lifecycle\",\"excel_run\",\"secret_search\",\"secret_save\",\"secret_get\",\"secret_move\",\"secret_delete\",\"variable_set_list\",\"environment_list\",\"variable_set_get_variable\",\"variable_set_set_variable\",\"environment_set_variable\",\"capability_catalog_search\",\"capability_authorization_request\",\"custom_mcp_setup_request\",\"github_connect_link\",\"github_repositories_list\",\"social_connections_list\",\"social_posts_recent\",\"social_daily_analysis_context\",\"social_search_live\",\"social_mentions_live\",\"social_thread_fetch\",\"social_posts_sync\",\"social_post_reply\",\"x_accounts_list\",\"x_search_live\",\"x_mentions_live\",\"x_thread_fetch\",\"x_posts_sync\",\"x_post_reply\",\"reddit_accounts_list\",\"reddit_search_live\",\"reddit_mentions_live\",\"reddit_thread_fetch\",\"reddit_posts_sync\",\"reddit_post_reply\",\"scheduled_tasks_list\",\"scheduled_tasks_get\",\"scheduled_tasks_create\",\"scheduled_tasks_update\",\"scheduled_tasks_pause\",\"scheduled_tasks_resume\",\"scheduled_tasks_trigger\",\"scheduled_tasks_delete\",\"scheduled_task_runs_list\",\"slack_bot_list_channels\",\"slack_bot_search\",\"slack_bot_channel_history\",\"slack_bot_thread_replies\",\"slack_bot_list_users\",\"slack_bot_list_files\",\"slack_bot_file_info\",\"slack_bot_file_content\",\"slack_bot_upload_file\",\"slack_bot_post_message\",\"slack_bot_delete_message\",\"slack_bot_prepare_message\",\"slack_bot_send_prepared_message\",\"fiken_companies_list\",\"fiken_contacts_list\",\"fiken_contact_create\",\"fiken_products_list\",\"fiken_invoices_list\",\"fiken_invoice_get\",\"fiken_invoice_draft_create\",\"fiken_bank_accounts_list\",\"fiken_purchases_list\",\"fiken_sales_list\",\"atlassian_sources_list\",\"atlassian_search\",\"atlassian_get\",\"artifacts_list\",\"artifacts_get_source\",\"artifacts_prepare_upload\",\"artifacts_create\",\"artifacts_publish\",\"artifacts_rollback\",\"artifacts_archive\",\"artifacts_restore\",\"site_data_describe\",\"site_data_define_collection\",\"site_data_query\",\"site_data_write\",\"site_data_import\",\"site_data_export\",\"site_data_reset\",\"site_files_list\",\"site_files_upload\",\"site_files_delete\",\"site_publication_get\",\"site_publication_update\",\"site_publication_apply_fix\",\"site_hostname_check\",\"site_sql_inspect\",\"site_sql_enable\",\"site_sql_migrate\",\"site_sql_define_query\",\"site_sql_query\",\"site_sql_run\",\"site_sql_execute\",\"site_sql_export\",\"site_sql_import\",\"site_sql_reset\",\"sandbox_file_publish\",\"editable_artifact_list\",\"editable_artifact_create\",\"editable_artifact_import\",\"editable_artifact_get\",\"editable_artifact_inspect\",\"editable_artifact_apply\",\"editable_artifact_export\",\"editable_artifact_export_status\"],CC=I(()=>ce(Uo)),EC=[\"interaction_discover\",\"browser_open\",\"browser_tabs\",\"browser_observe\",\"browser_read\",\"browser_screenshot\",\"browser_act\",\"browser_clipboard\",\"browser_debug\",\"browser_downloads\",\"browser_download_save\",\"browser_record\",\"browser_auth\",\"interaction_request_human\",\"browser_identity\",\"browser_publish\",\"browser_lifecycle\",\"computer_open\",\"computer_targets\",\"computer_observe\",\"computer_clipboard\",\"computer_act\",\"computer_lifecycle\"],PC=new Set(EC),Sg=[\"memory_search\",\"memory_save\",\"memory_correct\",\"knowledge_propose\",\"knowledge_correct\",\"task_note_promote_instruction_policy\",\"task_note_promote_preference\",\"instruction_policy_propose\",\"preference_propose\",\"remember\",\"remember_confirm\"],OC=new Set(Sg),Ig=[\"variable_set_list\",\"environment_list\",\"variable_set_get_variable\",\"variable_set_set_variable\",\"environment_set_variable\"],$C=new Set(Ig);var MC=[\"slack_bot_post_message\",\"atlassian_sources_list\",\"atlassian_search\",\"atlassian_get\",...Sg,...Ig],qC=new Set(MC),sF=Uo.filter((e)=>!PC.has(e)&&!qC.has(e)),iF=new Set([...Uo,...ig,...sg]);var zC=[\"admin_actions_search\",\"admin_action_describe\",\"admin_action_call\"],jC=new Set(zC),aF=Uo.filter((e)=>!OC.has(e)&&!$C.has(e)&&!e.startsWith(\"social_\")&&!e.startsWith(\"x_\")&&!e.startsWith(\"reddit_\")&&(!e.startsWith(\"slack_bot_\")||e===\"slack_bot_list_channels\"||e===\"slack_bot_prepare_message\"||e===\"slack_bot_send_prepared_message\")&&!e.startsWith(\"fiken_\")&&!e.startsWith(\"atlassian_\")&&!jC.has(e));var NC=I(()=>ce([\"private\",\"workspace\"]));var DC=256,kg=25;var cF=Object.freeze({sessionDefaults:null,allowedProviders:null,allowedModels:null,modelCompactionThresholds:Object.freeze({}),realtimeVoice:Object.freeze({}),realtimeDefaultModel:null,updatedAt:null});var UC={subjectId:w().min(1),label:w().min(1).optional()};var LC=I(()=>qr(w(),la()));var GC=\"https://chromewebstore.google.com/detail/opengeni-browser/phpmmcbeelfkcinjfbbggegjdcdmnnch\",lF=[{code:\"attached_browser_unavailable\",capabilityId:\"api:connected-machine\",purpose:\"chrome\",problem:\"No Chrome profile is connected through the browser extension.\",rationale:\"Connect your Chrome so the agent can use it.\",nextStep:`connect their computer as a Connected Machine, then add the browser extension to Chrome: ${GC}`},{code:\"personal_machine_permission_required\",capabilityId:\"api:connected-machine\",problem:\"This is a personal (Only me) machine, and its owner has not allowed this chat to use it yet.\",rationale:\"Allow this chat to use your computer.\",nextStep:\"open this chat in Opengeni and allow it to use their machine\"}];var BC=I(()=>w().regex(/^[A-Za-z0-9_-]{16,128}$/)),uF={workspaceId:w().uuid(),accountId:w().uuid(),allowScreenControl:fe(),iat:xe().int().nonnegative(),exp:xe().int().positive(),jti:BC.optional()};var VC=/^[A-Za-z0-9_-]+$/,FC=I(()=>w().min(1).regex(VC)),JC=I(()=>ge(FC.max(200)).max(64));var WC=I(()=>ce([\"user\",\"scheduled_task\",\"api\",\"goal\",\"system\",\"compaction\"]));var KC=I(()=>ce([\"review_changes\",\"preserve_intent\",\"autonomous_adaptation\"]));var HC=8192,ZC=8192,YC=2048;var XC=512,_g=4096,QC=16;function Rg(e){return new TextEncoder().encode(e).byteLength}function Lo(e,t){return w().min(1).max(e).describe(`${t}: at most ${e} UTF-8 bytes. Write concise, human-readable text with normal spacing; summarize instead of compressing words.`).refine((n)=>Rg(n)<=e,{message:`${t} exceeds ${e} UTF-8 bytes`})}function eE(e,t){let n=new TextEncoder,r=n.encode(e),o=n.encode(t),s=Math.min(r.length,o.length);for(let i=0;i<s;i+=1){let a=r[i]-o[i];if(a!==0)return a}return r.length-o.length}function tE(e){return[...new Set(e.map((t)=>t.replace(/^ +| +$/g,\"\")))].sort(eE)}var nE=I(()=>ge(Lo(XC,\"goal root constraint\")).transform(tE).pipe(ge(w().min(1)).max(QC).refine((e)=>e.reduce((t,n)=>t+Rg(n),0)<=_g,{message:`goal root constraints exceed ${_g} aggregate UTF-8 bytes`}))),rE=Lo(HC,\"goal text\"),oE=Lo(ZC,\"goal success criteria\"),dF=Lo(YC,\"goal rationale\");var sE=I(()=>G({text:rE,successCriteria:oE.optional(),rootConstraints:nE.optional(),reportRequirements:Yf.optional(),maxAutoContinuations:xe().int().positive().optional(),mutationPolicy:KC.optional()}));var iE=\"$opengeniCleared\",pF=JSON.stringify({[iE]:!0});var aE=\"$opengeniOpenSuffix\",mF=JSON.stringify({[aE]:!0});var cE=I(()=>G({kind:ce([\"subject\",\"service\"]),...UC}));var Tg=16384,Ag=2048,wg=512,lE=256,xg=1048576,uE=I(()=>ce([\"user_message\",\"assistant_message\",\"tool_output\"])),dE=I(()=>ce([\"user.message\",\"agent.message.completed\",\"agent.toolCall.output\"]));function Cg(e){return new TextEncoder().encode(e).byteLength}function hn(e,t){return w().superRefine((n,r)=>{if(Cg(n)>e)r.addIssue({code:Qe.custom,message:`${t} must be at most ${e} UTF-8 bytes`})})}var Eg=I(()=>G({kind:uE,eventId:w().uuid(),eventType:dE,sequence:xe().int().positive(),turnId:w().uuid().nullable(),startOffset:xe().int().nonnegative(),endOffset:xe().int().nonnegative(),contextBefore:hn(wg,\"annotation source contextBefore\"),contextAfter:hn(wg,\"annotation source contextAfter\"),label:hn(lE,\"annotation source label\").optional()}).strict().superRefine((e,t)=>{if(e.endOffset<e.startOffset)t.addIssue({code:Qe.custom,path:[\"endOffset\"],message:\"annotation source endOffset must not precede startOffset\"});let n=e.eventType===\"user.message\"?\"user_message\":e.eventType===\"agent.message.completed\"?\"assistant_message\":\"tool_output\";if(e.kind!==n)t.addIssue({code:Qe.custom,path:[\"kind\"],message:\"annotation source kind does not match eventType\"})})),Pg=I(()=>G({id:w().uuid(),source:Eg,quote:hn(Tg,\"annotation quote\"),note:hn(Ag,\"annotation note\")}).strict().superRefine((e,t)=>{if(!e.quote.trim())t.addIssue({code:Qe.custom,path:[\"quote\"],message:\"annotation quote must contain non-whitespace text\"})})),pE=I(()=>Pg.superRefine((e,t)=>{if(!e.note.trim())t.addIssue({code:Qe.custom,path:[\"note\"],message:\"annotation note must contain non-whitespace text\"})})),mE=I(()=>G({id:w().uuid(),source:Eg,quote:hn(Tg,\"annotation quote\"),note:hn(Ag,\"annotation note\").refine((e)=>e.trim().length>0,{message:\"annotation note must contain non-whitespace text\"}),ordinal:xe().int().positive()}).strict());function xa(e){return ge(e).superRefine((t,n)=>{let r=new Set;for(let o=0;o<t.length;o+=1){let s=t[o].id;if(typeof s===\"string\"&&r.has(s))n.addIssue({code:Qe.custom,path:[o,\"id\"],message:\"annotation ids must be unique\"});if(typeof s===\"string\")r.add(s)}if(Cg(JSON.stringify(t))>xg)n.addIssue({code:Qe.custom,message:`annotations must be at most ${xg} UTF-8 bytes`})})}var fF=xa(Pg),gF=xa(pE),hF=xa(mE).superRefine((e,t)=>{for(let n=0;n<e.length;n+=1)if(e[n].ordinal!==n+1)t.addIssue({code:Qe.custom,path:[n,\"ordinal\"],message:\"annotation ordinals must be contiguous and match array order\"})});var fE=\"[Session goal frozen when this turn was accepted]\";var yF=hE({agentLearning:Xf.optional(),excludedMcpServerIds:JC.optional(),visibility:NC.optional(),sandboxBackend:wa.optional(),targetSandboxId:w().uuid().optional(),workingDir:w().min(1).optional(),variableSetId:w().uuid().optional(),variableSetIds:ge(w().uuid()).max(kg).optional(),rigId:w().uuid().optional(),goal:sE.optional(),firstPartyMcpPermissions:ge(zo).optional(),firstPartyMcpTools:ge(CC).optional(),agent:tg.optional()});var gE=[\"child_terminal_result\",\"child_requires_action\",\"child_requires_action_resolved\",\"child_paused\",\"child_waiting_capacity\",\"child_progress\"],bF=new Set(gE);var vF=`${fE}\n`;function hE(e,t={}){return HA((n)=>{if(!n||typeof n!==\"object\"||Array.isArray(n))return n;let r=n;if(t.rejectKeys?.some((s)=>Object.hasOwn(r,s)))return null;let o=r.variableSetId!==void 0||r.environmentId===void 0?r:{...r,variableSetId:r.environmentId};if(o.variableSetIds===void 0&&o.variableSetId!==void 0)return{...o,variableSetIds:o.variableSetId===null?[]:[o.variableSetId]};return o},G(e).superRefine((n,r)=>{let o=n;if(!Array.isArray(o.variableSetIds))return;if(new Set(o.variableSetIds).size!==o.variableSetIds.length)r.addIssue({code:Qe.custom,path:[\"variableSetIds\"],message:\"variableSetIds must not contain duplicates\"});if(o.variableSetId===void 0)return;let s=o.variableSetIds.length>0?o.variableSetIds[o.variableSetIds.length-1]:null;if(o.variableSetId!==s)r.addIssue({code:Qe.custom,path:[\"variableSetId\"],message:\"variableSetId must match the last variableSetIds entry\"})}))}var _F=kg*2;var yE=I(()=>ce([\"file\",\"dir\",\"symlink\",\"other\"]));var bE=$f(()=>G({name:w(),path:w(),type:yE,sizeBytes:xe().int().nonnegative().nullable(),mtimeMs:xe().int().nonnegative().nullable(),mode:xe().int().nullable(),children:ge(bE).optional(),truncated:fe().default(!1)}));var vE=I(()=>cE.extend({subjectId:w().min(1).max(1024),label:w().min(1).max(256).optional()})),_E=I(()=>LC.refine((e)=>{try{return new TextEncoder().encode(JSON.stringify(e)).byteLength<=4096}catch{return!1}},{message:\"Host export initiator context exceeds 4096 UTF-8 bytes\"})),wF={initiator:vE.nullable(),initiatorContext:_E,origin:WC.nullable(),surface:ng.nullable().optional(),modelProvider:og.nullable().optional()};var xF=DC*4;var wE=[\"id\",\"workspaceId\",\"sessionId\",\"sequence\",\"coveredThrough\",\"type\",\"payload\",\"occurredAt\",\"clientEventId\",\"turnId\",\"turnGeneration\",\"turnAttemptId\",\"turnAssociation\",\"duplicateOfEventId\",\"duplicateReason\"],SF=new Set([...wE,\"toJSON\"]);import{createHash as rG,randomUUID as oG}from\"node:crypto\";var Zr=ho(M_(),1);import{createHash as m4,randomUUID as p$}from\"node:crypto\";import{AsyncLocalStorage as c$}from\"node:async_hooks\";var q_=new c$;function _s(e,t){if(typeof e!==\"object\"||e===null)return;try{let n=Object.getOwnPropertyDescriptor(e,t);return n&&\"value\"in n?n.value:void 0}catch{return}}function nl(e){let t=_s(e,\"traceId\"),n=_s(e,\"spanId\"),r=_s(e,\"traceFlags\");if(typeof t!==\"string\"||typeof n!==\"string\")return;if(!/^[0-9a-f]{32}$/.test(t)||/^0+$/.test(t))return;if(!/^[0-9a-f]{16}$/.test(n)||/^0+$/.test(n))return;if(r!==void 0&&(typeof r!==\"string\"||!/^[0-9a-f]{2}$/.test(r)))return;return{traceId:t,spanId:n,...r===void 0?{}:{traceFlags:r}}}function Kr(){return nl(q_.getStore())}function ws(e,t){let n=nl(e),r=_s(e,\"addLink\");return q_.run(n?{...n,addLink:typeof r===\"function\"?r:void 0}:void 0,t)}import{AsyncLocalStorage as l$}from\"node:async_hooks\";import{createHash as u$}from\"node:crypto\";var Hr=new l$;function rl(e){let t=Hr.getStore(),n=Kr();return(...r)=>Hr.run(t,()=>ws(n,()=>e(...r)))}function ol(e,t){let n=Hr.getStore();if(!n||typeof e!==\"string\")return t();let r;try{r=`mcp_${u$(\"sha256\").update(\"opengeni:mcp-call:v1\\x00\").update(n.scope).update(\"\\x00\").update(e).digest(\"hex\").slice(0,32)}`}catch{return t()}if(n.callKey===r)return t();return Hr.run({...n,callKey:r,nextRequest:0},t)}function j_(e){let t=Hr.getStore(),n=performance.now(),r=t?.callKey?{mcpCallKey:t.callKey}:{},o=e===\"network_headers\"&&t?++t.nextRequest:void 0,s;try{s=t?.observer.startSpan(`mcp.phase.${e}`,{...r,...o===void 0?{}:{attempt:o}})}catch{}let i=s??Kr(),a=!1;return{traceContext:i,run:(c)=>ws(i,c),end:(c=\"completed\")=>{if(a)return;a=!0;let l=Math.max(0,performance.now()-n);try{s?.end({attributes:{outcome:c,\"opengeni.duration_ms\":l},...c===\"completed\"?{}:{error:Error(`MCP phase ${c}`)}})}catch{}try{t?.observer.observeHistogram({name:\"opengeni_mcp_phase_duration_seconds\",help:\"MCP execution phase duration; nested phases are not additive.\",labels:{phase:e,outcome:c},value:l/1000})}catch{}}}}async function tt(e,t,n){let r=j_(e);try{let o=await r.run(t),s=\"completed\";try{s=n?.(o)??s}catch{}return r.end(s),o}catch(o){throw r.end(\"failed\"),o}}var w4=p$();var x4=new Set([...wa.options,\"unprovisioned\"]);var m$=[\"workspace_writer_unattributed\"],S4=new Set(m$);var f$=new Set([\"agent_command_wake_failed\",\"api_startup_failed\",\"api_uncaught_exception\",\"api_unhandled_rejection\",\"artifact_materializer_native_input_framing_failed\",\"artifact_materializer_native_snapshot_open_failed\",\"artifact_materializer_native_state_mismatch\",\"artifact_materializer_source_content_type_mismatch\",\"artifact_materializer_source_open_failed\",\"artifact_materializer_source_revalidation_failed\",\"artifact_materializer_source_stream_identity_mismatch\",\"cleared_goal_live_publish_failed\",\"codex_failover_checkpoint_failed\",\"codex_fleet_shadow_failed\",\"codex_lease_loss_checkpoint_failed\",\"codex_active_credential_read_failed\",\"command_yield_timeout\",\"conflict\",\"control_wake_dispatch_failed\",\"fenced_event_live_publish_failed\",\"forbidden\",\"host_export_batch_delivery_failed\",\"host_export_failure_settlement_stale\",\"host_export_pump_iteration_failed\",\"host_export_retention_prune_failed\",\"idempotency_conflict\",\"incompatible_exposed_ports\",\"internal_error\",\"knowledge_index_defer_failed\",\"knowledge_index_embedding_failed\",\"knowledge_index_failed\",\"knowledge_index_persistence_failed\",\"knowledge_index_usage_limit_reached\",\"limit_exceeded\",\"mcp_close_failed\",\"mcp_connect_failed\",\"mcp_tool_call_failed\",\"mcp_tools_list_failed\",\"mcp_transport_failed\",\"memory_edit_embedding_failed\",\"memory_hybrid_vector_failed\",\"memory_save_embedding_failed\",\"nats_auth_callout_start_failed\",\"nested_agent_depth_exceeded\",\"nested_agent_depth_override_forbidden\",\"not_found\",\"oauth_operation_failed\",\"otlp_export_failed\",\"parallel_session_title_generation_failed\",\"parallel_session_title_persistence_failed\",\"payment_required\",\"provider_verification_failed\",\"sandbox_channel_a_cancelled\",\"sandbox_channel_a_lifecycle_conflict\",\"sandbox_channel_a_operation_failed\",\"sandbox_channel_a_provider_busy\",\"sandbox_channel_a_provider_unavailable\",\"screenshot_capture_failed\",\"session_event_live_publish_failed\",\"session_archive_failed\",\"session_archive_hash_mismatch\",\"session_archive_object_missing\",\"session_archive_storage_failed\",\"session_workflow_wake_failed\",\"snapshot_operation_failed\",\"startup_dependency_retry\",\"temporal_sdk_failure_logged\",\"tool_list_too_large\",\"tool_result_too_large\",\"codemode_operation_failed\",\"unauthenticated\",\"upstream_unavailable\",\"validation_failed\",\"worker_draining\",\"worker_operation_failed\",\"worker_shutdown_request_failed\",\"worker_cleanup_drain_exhausted\",\"workspace_control_live_publish_failed\"]),I4=new Map([...f$].map((e)=>[e,e.replaceAll(\"_\",\" \")]));var ht=ho(pk(),1),ER=ho(Yk(),1),PR=ho(uR(),1);var OL={test:()=>!0};function ru(e,t){try{return new RegExp(e,t)}catch{}if(t.includes(\"u\"))try{return new RegExp(e,t.replaceAll(\"u\",\"\"))}catch{}return OL}var dR=Object.assign((e,t)=>ru(e,t),{code:\"compileSchemaPattern\"});var $L=/^-?(?:0|[1-9]\\d*)$/u,ML=/^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?$/u;function pR(e,t){let n=e,r=!1;for(let o=0;o<4;o+=1){if(t(n))break;let s=new Map;for(let a of t.errors??[]){let c=qL(n,a);if(c===It)continue;s.set(a.instancePath,c)}if(s.size===0)break;let i=structuredClone(n);for(let[a,c]of s)if(!DL(i,a,c))return;n=i,r=!0}return r?n:void 0}var It=Symbol(\"no replacement\");function qL(e,t){if(t.keyword!==\"type\"||t.instancePath===\"\")return It;let n=String(t.params.type??\"\").split(\",\"),r=NL(e,t.instancePath);if(typeof r!==\"string\")return It;let o=zL(r,n);if(o!==void 0)return o;if(n.includes(\"boolean\")&&(r===\"true\"||r===\"false\"))return r===\"true\";return jL(r,n)}function zL(e,t){let n=t.includes(\"integer\"),r=t.includes(\"number\");if(!n&&!r)return;if(r?!ML.test(e):!$L.test(e))return;let o=Number(e);if(!Number.isFinite(o))return;if(!r&&!Number.isSafeInteger(o))return;return o}function jL(e,t){let n=t.includes(\"object\"),r=t.includes(\"array\");if(!n&&!r)return It;let o=e.trim();if(!(n&&o.startsWith(\"{\"))&&!(r&&o.startsWith(\"[\")))return It;let s;try{s=JSON.parse(o)}catch{return It}if(Array.isArray(s))return r?s:It;if(s!==null&&typeof s===\"object\")return n?s:It;return It}function mR(e){return e.split(\"/\").slice(1).map((t)=>t.replace(/~1/gu,\"/\").replace(/~0/gu,\"~\"))}function NL(e,t){let n=e;for(let r of mR(t)){if(n===null||typeof n!==\"object\")return;if(!Object.hasOwn(n,r))return;n=n[r]}return n}function DL(e,t,n){let r=mR(t),o=r.pop();if(o===void 0)return!1;let s=e;for(let i of r){if(s===null||typeof s!==\"object\"||!Object.hasOwn(s,i))return!1;s=s[i]}if(s===null||typeof s!==\"object\"||!Object.hasOwn(s,o))return!1;return s[o]=n,!0}import{createHash as WL}from\"node:crypto\";var UL=8,fR=120,gR=160,wi=10,LL=60;function yR(e,t){let n=[],r=new Set,o=0,s=GL(e??[]);if(t)try{s=BL(e??[],t)}catch{}for(let i of s){if(r.has(i.message))continue;if(r.add(i.message),n.length<UL)n.push(i);else o+=1}return{issues:n,omittedIssueCount:o}}function GL(e){let t=e.find((r)=>r.keyword===\"anyOf\"||r.keyword===\"oneOf\");if(!t)return e.map(au);let n=Ie(kt(t.instancePath));return[{path:n,keyword:t.keyword,message:`${lo(n)} must match ${t.keyword===\"oneOf\"?\"exactly one\":\"one\"} declared alternative input format`}]}function BL(e,t){if(!e.some((d)=>d.keyword===\"anyOf\"||d.keyword===\"oneOf\"))return e.map(au);let n=[],r=new Map(e.map((d,f)=>[d,f])),o=JL(t.schema,t.arguments,e),s=vi(o.uncertain,(d)=>d.instancePath,!1),i=(d)=>!o.sites.has(An(d.schemaPath,d.instancePath))&&ou(d.instancePath).some((f)=>(s.get(f)??[]).some((h)=>d.schemaPath===h.prefix||d.schemaPath.startsWith(`${h.prefix}/`))),a=(d,f,h)=>r.get(d)<r.get(f)&&!o.sites.has(An(d.schemaPath,d.instancePath))&&!i(d)&&VL(d,f,h);for(let d of e){if(d.keyword!==\"anyOf\"&&d.keyword!==\"oneOf\")continue;let f=An(d.schemaPath,d.instancePath),h=o.ambiguous.has(f)?void 0:o.schemas.has(f)?o.schemas.get(f):uo(t.schema,d.schemaPath);if(!Array.isArray(h)||h.some((C)=>!F(C)&&typeof C!==\"boolean\")){n.push({error:d,branchPrefixes:[],selected:void 0,unresolved:!0,replacement:{path:Ie(kt(d.instancePath)),keyword:d.keyword,message:`${lo(Ie(kt(d.instancePath)))} must match ${d.keyword===\"oneOf\"?\"exactly one\":\"one\"} declared alternative input format`}});continue}let y=h,_=y.map((C,D)=>F(C)?vR(C,`${d.schemaPath}/${D}`,t.schema):[`${d.schemaPath}/${D}`]),E=y.map((C)=>F(C)?_R(C,t.schema):[]),T=_i(t.arguments,kt(d.instancePath)),A=E.flatMap((C,D)=>y[D]===!1||C.some((V)=>{let L=_i(T.value,V.path);return L.present&&!V.values.some((H)=>H===L.value)})?[]:[D]),x=A.length===1&&A.length<y.length?A[0]:void 0,K;if(x===void 0){let C=E[0]?.find((oe)=>E.every((Te)=>Te.some((je)=>iu(je.path,oe.path)))),D=C&&_i(T.value,C.path),V=C&&E.map((oe)=>oe.find((Te)=>iu(Te.path,C.path))),L=V?.flatMap((oe)=>oe.values),H=L&&[...new Set(L)];if(C&&D&&V&&H?.length&&(D.present&&!H.some((oe)=>oe===D.value)||!D.present&&V.every((oe)=>oe.required))){let oe=Ie([...kt(d.instancePath),...C.path]),Te=xR(H),je=!D.present&&V.every((yT)=>yT.required);K={path:oe,keyword:je?\"required\":d.keyword,message:je?`missing required property \"${oe}\" (selects one of ${Te})`:`${lo(oe)} must be one of ${Te}`}}}n.push({error:d,branchPrefixes:_,selected:x,replacement:K})}let c=new Map,l=vi(e,(d)=>d.instancePath,!0),u=vi(n,(d)=>d.error.instancePath,!0),p=new WeakMap,m=(d,f)=>{let h=p.get(f);if(!h)h=vi(f,(x)=>x.error.instancePath,!1),p.set(f,h);let y=ou(d.instancePath).flatMap((x)=>h.get(x)??[]);for(let x of y){if(d===x.error)continue;if(x.unresolved&&r.get(d)<r.get(x.error)&&!o.sites.has(An(d.schemaPath,d.instancePath))&&!i(d)&&(d.instancePath===x.error.instancePath||d.instancePath.startsWith(`${x.error.instancePath}/`)))return[];let K=x.branchPrefixes.flatMap((C,D)=>a(d,x.error,C)?[D]:[]);if(K.length&&(x.selected===void 0||!K.includes(x.selected)))return[]}let _=y.find((x)=>x.error===d);if(!_){let x=au(d);return[i(d)?{...x,message:`an independent constraint or alternative reports: ${x.message}`}:x]}if(_.selected!==void 0)return[];if(_.replacement)return[_.replacement];let E=c.get(_);if(E)return[E];let T=_.branchPrefixes.slice(0,wi).map((x,K)=>{let C=(u.get(_.error.instancePath)??[]).filter((H)=>r.get(H.error)<r.get(_.error)&&a(H.error,_.error,x)),D=(l.get(_.error.instancePath)??[]).filter((H)=>H!==_.error&&a(H,_.error,x)).flatMap((H)=>m(H,C)).map((H)=>H.message),V=[...new Set(D)],L=V.slice(0,2);if(V.length>L.length)L.push(\"other declared requirements\");return`alternative ${K+1}${L.length?` (${L.join(\"; \")})`:\"\"}`});if(_.branchPrefixes.length>wi)T.push(\"other declared alternatives\");let A={path:Ie(kt(d.instancePath)),keyword:d.keyword,message:xr(`${lo(Ie(kt(d.instancePath)))} must match ${d.keyword===\"oneOf\"?\"exactly one\":\"one\"} declared input format: ${T.join(\" or \")}`,640)};return c.set(_,A),[A]};return e.flatMap((d)=>m(d,n))}function vi(e,t,n){let r=new Map;for(let o of e){let s=n?ou(t(o)):[t(o)];for(let i of s){let a=r.get(i);if(a)a.push(o);else r.set(i,[o])}}return r}function ou(e){let t=[e],n=e;while(n)n=n.slice(0,n.lastIndexOf(\"/\")),t.push(n);return t}function VL(e,t,n){return(e.instancePath===t.instancePath||e.instancePath.startsWith(`${t.instancePath}/`))&&n.some((r)=>e.schemaPath===r||e.schemaPath.startsWith(`${r}/`))}function F(e){return e!==null&&typeof e===\"object\"&&!Array.isArray(e)}var hR=new WeakMap,su=new WeakMap,bR=new WeakMap;function uo(e,t,n){let r=hR.get(e);if(!r){r=new Map([[\"#\",e]]);let a=new Set,c=new WeakMap,l=new WeakMap,u=new Set,p=(d,f)=>{if(a.has(d))return;let h=r.get(d);if(h&&h!==f)r.delete(d),a.add(d);else r.set(d,f)},m=(d,f,h,y)=>{if(u.has(d))return;u.add(d),p(f,d);let _=h;if(typeof d.$id===\"string\"){_=d.$id;try{if(h)_=new URL(_,h).href}catch{}p(_,d),p(`${_}#`,d),y=\"#\"}if(c.set(d,_),l.set(d,y),typeof d.$anchor===\"string\"){if(p(`#${d.$anchor}`,d),_)p(`${_}#${d.$anchor}`,d)}for(let[E,T]of FL(d))m(T,`${f}/${E}`,_,`${y}/${E}`);u.delete(d)};m(e,\"#\",\"\",\"#\"),hR.set(e,r),su.set(e,c),bR.set(e,l)}let o=n&&su.get(e)?.get(n);if(o)if(t.startsWith(\"#\"))t=`${o}${t}`;else try{t=new URL(t,o).href}catch{}let s=r.get(t);if(s)return s;let i=t.lastIndexOf(\"/\");while(i>=0){let a=r.get(t.slice(0,i));if(a){let c=a;for(let l of kt(t.slice(i))){if(!c||typeof c!==\"object\")return;c=c[l]}return c}i=i===0?-1:t.lastIndexOf(\"/\",i-1)}return}function FL(e){let t=[];for(let n of[\"$defs\",\"definitions\",\"properties\",\"patternProperties\",\"dependentSchemas\",\"dependencies\"]){let r=e[n];if(F(r)){for(let[o,s]of Object.entries(r))if(F(s))t.push([`${n}/${tn(o)}`,s])}}for(let n of[\"anyOf\",\"oneOf\",\"allOf\",\"prefixItems\",\"items\"]){let r=e[n];if(Array.isArray(r))r.forEach((o,s)=>{if(F(o))t.push([`${n}/${s}`,o])})}for(let n of[\"items\",\"additionalItems\",\"additionalProperties\",\"unevaluatedProperties\",\"not\",\"if\",\"then\",\"else\",\"contains\",\"propertyNames\"]){let r=e[n];if(F(r))t.push([n,r])}return t}function tn(e){return e.replace(/~/gu,\"~0\").replace(/\\//gu,\"~1\")}function An(e,t){return JSON.stringify([e,t])}function JL(e,t,n){let r=new Set,o=new Map,s=[],i=new Set,a=new Map(n.filter((m)=>m.keyword===\"if\").map((m)=>[An(m.schemaPath,m.instancePath),m.params.failingKeyword])),c=new Set,l=new WeakMap,u=0,p=(m,d,f,h,y)=>{let _=l.get(m);if(_===void 0)_=u++,l.set(m,_);let E=JSON.stringify([_,d,h,y]);if(c.has(E))return;c.add(E);let T=su.get(e)?.get(m),A=T&&bR.get(e)?.get(m),x=[...new Set([d,...A?[A,`${T}${A}`]:[]])];for(let C of x)for(let[D,V]of Object.entries(m)){let L=An(`${C}/${D}`,h);if(y)r.add(L);if(i.has(L))continue;if(o.has(L)&&o.get(L)!==V)o.delete(L),i.add(L);else o.set(L,V)}if(typeof m.$ref===\"string\"){let C=uo(e,m.$ref,m);if(F(C))p(C,m.$ref,f,h,y)}if(Array.isArray(m.allOf))m.allOf.forEach((C,D)=>{if(F(C))p(C,`${d}/allOf/${D}`,f,h,y)});for(let C of[\"anyOf\",\"oneOf\"]){let D=m[C];if(!Array.isArray(D))continue;let V=D.flatMap((H,oe)=>{if(H===!1)return[];if(!F(H))return[oe];return _R(H,e).some((Te)=>{let je=_i(f,Te.path);return je.present&&!Te.values.includes(je.value)})?[]:[oe]}),L=V.length===1&&V.length<D.length?V[0]:void 0;D.forEach((H,oe)=>{if(F(H))p(H,`${d}/${C}/${oe}`,f,h,y&&oe===L)})}if(f&&typeof f===\"object\"&&!Array.isArray(f)){if(F(m.properties)){for(let[C,D]of Object.entries(m.properties))if(F(D)&&Object.hasOwn(f,C))p(D,`${d}/properties/${tn(C)}`,f[C],`${h}/${tn(C)}`,y)}if(F(m.dependentSchemas)){for(let[C,D]of Object.entries(m.dependentSchemas))if(F(D)&&Object.hasOwn(f,C))p(D,`${d}/dependentSchemas/${tn(C)}`,f,h,y)}}if(f&&typeof f===\"object\"&&!Array.isArray(f)){let C=F(m.properties)?m.properties:{},D=F(m.patternProperties)?Object.entries(m.patternProperties).map(([V,L])=>[V,ru(V,\"u\"),L]):[];for(let[V,L]of Object.entries(f)){let H=!1;for(let[oe,Te,je]of D)if(Te.test(V)){if(H=!0,F(je))p(je,`${d}/patternProperties/${tn(oe)}`,L,`${h}/${tn(V)}`,y)}if(!Object.hasOwn(C,V)&&!H&&F(m.additionalProperties))p(m.additionalProperties,`${d}/additionalProperties`,L,`${h}/${tn(V)}`,y)}if(F(m.dependencies)){for(let[V,L]of Object.entries(m.dependencies))if(F(L)&&Object.hasOwn(f,V))p(L,`${d}/dependencies/${tn(V)}`,f,h,y)}}if(Array.isArray(f)){let C=Array.isArray(m.prefixItems)?m.prefixItems:Array.isArray(m.items)?m.items:[],D=Array.isArray(m.prefixItems)?\"prefixItems\":\"items\";f.forEach((V,L)=>{let H=C[L]??(F(m.items)?m.items:m.additionalItems);if(F(H))p(H,C[L]?`${d}/${D}/${L}`:`${d}/${F(m.items)?\"items\":\"additionalItems\"}`,V,`${h}/${L}`,y)})}for(let C of[\"contains\",\"propertyNames\",\"unevaluatedProperties\",\"unevaluatedItems\"]){let D=m[C];if(F(D))for(let V of vR(D,`${d}/${C}`,e).slice(1))s.push({prefix:V,instancePath:h})}let K=a.get(An(`${d}/if`,h));if((K===\"then\"||K===\"else\")&&F(m[K]))p(m[K],`${d}/${K}`,f,h,y);c.delete(E)};return uo(e,\"#\"),p(e,\"#\",t,\"\",!0),{sites:r,schemas:o,ambiguous:i,uncertain:s}}function vR(e,t,n){let r=[t],o=new Set,s=(i)=>{if(o.has(i))return;if(o.add(i),typeof i.$ref===\"string\"){let a=uo(n,i.$ref,i);if(F(a))r.push(i.$ref),s(a)}for(let a of[\"properties\",\"patternProperties\",\"dependentSchemas\"]){let c=i[a];if(F(c)){for(let l of Object.values(c))if(F(l))s(l)}}for(let a of[\"anyOf\",\"oneOf\",\"allOf\",\"prefixItems\"]){let c=i[a];if(Array.isArray(c)){for(let l of c)if(F(l))s(l)}}for(let a of[\"items\",\"additionalItems\",\"additionalProperties\",\"unevaluatedProperties\",\"not\",\"if\",\"then\",\"else\",\"contains\",\"propertyNames\"]){let c=i[a];if(F(c))s(c);else if(a===\"items\"&&Array.isArray(c)){for(let l of c)if(F(l))s(l)}}};return s(e),r}function _R(e,t){let n=[],r=new Set,o=(i,a,c)=>{if(r.has(i))return;if(r.add(i),typeof i.$ref===\"string\"){let u=uo(t,i.$ref,i);if(F(u))o(u,a,c)}let l=\"const\"in i?[i.const]:Array.isArray(i.enum)?i.enum:[];if(l.length&&l.every((u)=>u===null||[\"string\",\"number\",\"boolean\"].includes(typeof u)))n.push({path:a,values:l,required:c});if(Array.isArray(i.allOf)){for(let u of i.allOf)if(F(u))o(u,a,c)}if(F(i.properties)){for(let[u,p]of Object.entries(i.properties))if(F(p))o(p,[...a,u],c&&Array.isArray(i.required)&&i.required.includes(u))}r.delete(i)};o(e,[],!0);let s=[];for(let i of n){let a=s.findIndex((c)=>iu(c.path,i.path));if(a<0)s.push(i);else{let c=s[a];s[a]={path:i.path,values:c.values.filter((l)=>i.values.includes(l)),required:c.required||i.required}}}return s}function _i(e,t){let n=e;for(let r of t){if(n===null||typeof n!==\"object\"||!Object.hasOwn(n,r))return{present:!1,value:void 0};n=n[r]}return{present:!0,value:n}}function iu(e,t){return e.length===t.length&&e.every((n,r)=>n===t[r])}function wR(e,t=0){let n=e.map((r)=>r.message);if(t>0)n.push(`and ${t} more ${t===1?\"problem\":\"problems\"}`);return n.join(\"; \")}function au(e){let t=e.params??{},n=kt(e.instancePath),r=lo(Ie(n)),o=e.propertyName!==void 0?\"propertyNames\":e.keyword;switch(o){case\"required\":{let s=Ie([...n,String(t.missingProperty)]);return{path:s,keyword:e.keyword,message:`missing required property \"${s}\"`}}case\"dependentRequired\":case\"dependencies\":{let s=Ie([...n,String(t.missingProperty)]),i=Ie([...n,String(t.property)]);return{path:s,keyword:e.keyword,message:`missing required property \"${s}\" (required when \"${i}\" is present)`}}case\"additionalProperties\":case\"unevaluatedProperties\":{let s=t.additionalProperty??t.unevaluatedProperty,i=Ie([...n,String(s)]);return{path:i,keyword:e.keyword,message:`property \"${i}\" is not allowed`}}case\"type\":{let s=Array.isArray(t.type)?t.type.join(\" or \"):String(t.type);return{path:Ie(n),keyword:e.keyword,message:`${r} must be ${xr(s,gR)}`}}case\"enum\":{let s=Array.isArray(t.allowedValues)?xR(t.allowedValues):null;return{path:Ie(n),keyword:e.keyword,message:s?`${r} must be one of ${s}`:`${r} must be one of the allowed values`}}case\"const\":return{path:Ie(n),keyword:e.keyword,message:`${r} must equal ${SR(t.allowedValue)}`};case\"propertyNames\":return{path:Ie(n),keyword:o,message:`${r} has a property name the schema does not allow`};default:return{path:Ie(n),keyword:xr(e.keyword,64),message:`${r} ${xr(cu(e.message??\"is invalid\"),gR)}`}}}function lo(e){return e?`\"${e}\"`:\"arguments\"}function kt(e){if(!e)return[];return e.slice(1).split(\"/\").map((t)=>t.replace(/~1/gu,\"/\").replace(/~0/gu,\"~\"))}function Ie(e){let t=\"\";for(let n of e){if(/^(?:0|[1-9][0-9]*)$/u.test(n))t+=`[${n}]`;else if(!t)t=cu(n);else if(/^[A-Za-z_$][A-Za-z0-9_$-]*$/u.test(n))t+=`.${n}`;else t+=`[${JSON.stringify(n)}]`;if(t.length>fR)break}return xr(t,fR)}function xR(e){if(e.length===0)return null;let t=e.slice(0,wi).map(SR);if(e.length>wi)t.push(\"...\");return t.join(\", \")}function SR(e){let t;try{t=JSON.stringify(e)??String(e)}catch{t=\"the schema constant\"}return xr(cu(t),LL)}function cu(e){return e.replace(/[\\u0000-\\u001f\\u007f]+/gu,\" \").trim()}function xr(e,t){return e.length<=t?e:`${e.slice(0,t-3)}...`}class xi extends Error{code=\"catalog_stale\";constructor(){super(\"Tool catalog is stale for the active gateway\");this.name=\"ToolGatewayCatalogStaleError\"}}class mt extends Error{code=\"tool_not_found\";constructor(){super(\"Tool is not present in the active gateway catalog\");this.name=\"ToolGatewayToolNotFoundError\"}}class Cn extends Error{code=\"approval_required\";constructor(){super(\"Tool requires human approval\");this.name=\"ToolGatewayApprovalRequiredError\"}}class lu extends Error{code=\"tool_blocked\";constructor(){super(\"This action is blocked by your tool permissions\");this.name=\"ToolGatewayBlockedError\"}}class uu extends Error{code=\"catalog_integrity_failed\";constructor(){super(\"Tool catalog digest does not match its authoritative content\");this.name=\"ToolGatewayCatalogIntegrityError\"}}class du extends Error{code=\"catalog_too_large\";constructor(){super(\"Tool catalog exceeds the maximum serialized size\");this.name=\"ToolGatewayCatalogTooLargeError\"}}class nn extends Error{code=\"tool_path_collision\";constructor(e,t){super(t===\"extends_leaf\"?`Tool path ${e.join(\".\")} extends a tool leaf`:`Tool path ${e.join(\".\")} collides`);this.name=\"ToolGatewayPathCollisionError\"}}class pu extends Error{code=\"tool_schema_invalid\";constructor(e){super(\"Tool is unavailable because its input or output schema is invalid\",{cause:e});this.name=\"ToolGatewaySchemaCompilationError\"}}class Si extends Error{code=\"invalid_tool_arguments\";issues;omittedIssueCount;summary;constructor(e=[],t=0){let n=wR(e,t);super(n?`Tool arguments do not match the tool's input schema: ${n}`:\"Tool arguments do not match the tool's input schema\");this.name=\"ToolGatewayInputValidationError\",this.issues=e,this.omittedIssueCount=t,this.summary=n}}class Ii extends Error{code=\"invalid_tool_result\";constructor(){super(\"Tool result does not match the gateway catalog output schema\");this.name=\"ToolGatewayOutputValidationError\"}}function ft(e){return WL(\"sha256\").update(JSON.stringify(mu(e)),\"utf8\").digest(\"hex\")}function po(e,t){return ft({domain:\"opengeni.tool-definition\",version:1,accountId:e.accountId,workspaceId:e.workspaceId,entry:t})}function rn(e,t){return e<t?-1:e>t?1:0}function mu(e){if(Array.isArray(e))return e.map(mu);if(e!==null&&typeof e===\"object\")return Object.fromEntries(Object.entries(e).sort(([t],[n])=>rn(t,n)).map(([t,n])=>[t,mu(n)]));return e}function Ri(e,t){let n=kR();for(let r of e.entries)KL(n,r);return[`// Generated by ${t.generatedBy}. Do not edit.`,`// ${t.catalogDigestLabel??\"Tool catalog digest\"}: ${e.digest}`,...t.typedResultWrapperType?[\"// Typed calls normally return their structured output. If image blocks are present,\",\"// they return CodemodeMultimodalValue<T> with local image paths and original content.\"]:[],`import type { ${[t.callOptionsType,t.fallbackResultType,...t.typedResultWrapperType?[t.typedResultWrapperType]:[]].join(\", \")} } from ${JSON.stringify(t.moduleSpecifier)};`,\"\",`declare module ${JSON.stringify(t.moduleSpecifier)} {`,` interface ${t.interfaceName} {`,...RR(n,4,t),\" }\",\"}\",\"\",\"export {};\",\"\"].join(`\n`)}function fu(e){return gt(e,e,new Set,0)}function kR(){return{children:new Map,entry:null}}function KL(e,t){let n=e;for(let[r,o]of t.codemodePath.entries()){if(n.entry)throw new nn(t.codemodePath,\"extends_leaf\");let s=n.children.get(o);if(!s)s=kR(),n.children.set(o,s);if(n=s,r===t.codemodePath.length-1){if(n.entry||n.children.size>0)throw new nn(t.codemodePath,\"collision\");n.entry=t}}}function RR(e,t,n){let r=[];for(let[o,s]of[...e.children].sort(([i],[a])=>rn(i,a))){if(s.entry){let i=s.entry,a=fu(i.inputSchema),c=i.outputSchema?fu(i.outputSchema):null,l=c?n.typedResultWrapperType?`${c} | ${n.typedResultWrapperType}<${c}>`:c:n.fallbackResultType,u=tG(i.description??i.title);if(u)r.push(...nG(u,t));r.push(`${En(t)}readonly ${o}: (`),r.push(`${En(t+2)}argumentsValue${HL(i.inputSchema)?\"?\":\"\"}: ${a},`),r.push(`${En(t+2)}options?: ${n.callOptionsType},`),r.push(`${En(t)}) => Promise<${l}>;`);continue}r.push(`${En(t)}readonly ${o}: {`),r.push(...RR(s,t+2,n)),r.push(`${En(t)}};`)}return r}function HL(e){if(!Pn(e))return!1;return(Array.isArray(e.required)?e.required.filter((n)=>typeof n===\"string\"):[]).length===0&&(e.type===\"object\"||Pn(e.properties))}function gt(e,t,n,r){if(r>48||e===!0)return\"unknown\";if(e===!1)return\"never\";if(!Pn(e))return\"unknown\";if(typeof e.$ref===\"string\"){if(!e.$ref.startsWith(\"#/\")||n.has(e.$ref))return\"unknown\";let a=eG(t,e.$ref);if(a===void 0)return\"unknown\";let c=new Set(n);return c.add(e.$ref),gt(a,t,c,r+1)}if(Object.hasOwn(e,\"const\"))return ki(e.const);if(Array.isArray(e.enum))return mo(e.enum.map(ki));let o=[];if(Array.isArray(e.oneOf))o.push(mo(e.oneOf.map((a)=>gt(a,t,n,r+1))));if(Array.isArray(e.anyOf))o.push(mo(e.anyOf.map((a)=>gt(a,t,n,r+1))));if(Array.isArray(e.allOf))o.push(IR(e.allOf.map((a)=>gt(a,t,n,r+1))));if(o.length>0){let a=IR(o);return e.nullable===!0?mo([a,\"null\"]):a}let i=(Array.isArray(e.type)?e.type.filter((a)=>typeof a===\"string\"):typeof e.type===\"string\"?[e.type]:QL(e)).map((a)=>ZL(a,e,t,n,r+1));if(e.nullable===!0)i.push(\"null\");return mo(i.length>0?i:[\"unknown\"])}function ZL(e,t,n,r,o){if(e===\"null\"||e===\"boolean\"||e===\"string\")return e;if(e===\"integer\"||e===\"number\")return\"number\";if(e===\"array\")return YL(t,n,r,o);if(e!==\"object\")return\"unknown\";return XL(t,n,r,o)}function YL(e,t,n,r){if(Array.isArray(e.prefixItems)){let s=e.prefixItems.map((a)=>gt(a,t,n,r+1));if(e.items===!1)return`readonly [${s.join(\", \")}]`;let i=e.items===void 0||e.items===!0?\"unknown\":gt(e.items,t,n,r+1);return`readonly [${s.join(\", \")}${s.length>0?\", \":\"\"}...${i}[]]`}return`readonly (${e.items===void 0||e.items===!0?\"unknown\":gt(e.items,t,n,r+1)})[]`}function XL(e,t,n,r){let o=Pn(e.properties)?e.properties:{},s=new Set(Array.isArray(e.required)?e.required.filter((c)=>typeof c===\"string\"):[]),i=Object.entries(o).sort(([c],[l])=>rn(c,l)),a=i.map(([c,l])=>`readonly ${gu(c)}${s.has(c)?\"\":\"?\"}: ${gt(l,t,n,r+1)}`);for(let c of[...s].filter((l)=>!Object.hasOwn(o,l)).sort(rn))a.push(`readonly ${gu(c)}: unknown`);if(e.additionalProperties!==!1){if(i.length===0&&e.additionalProperties!==void 0&&e.additionalProperties!==!0)return`Readonly<Record<string, ${gt(e.additionalProperties,t,n,r+1)}>>`;a.push(\"readonly [key: string]: unknown\")}return a.length===0?\"Record<string, never>\":`{ ${a.join(\"; \")} }`}function QL(e){if(Pn(e.properties)||Object.hasOwn(e,\"additionalProperties\"))return[\"object\"];if(Object.hasOwn(e,\"items\")||Array.isArray(e.prefixItems))return[\"array\"];return[]}function eG(e,t){let n=e;for(let r of t.slice(2).split(\"/\")){if(!Pn(n))return;let o=r.replace(/~1/gu,\"/\").replace(/~0/gu,\"~\");if(!Object.hasOwn(n,o))return;n=n[o]}return n}function ki(e){if(e===null||typeof e===\"string\"||typeof e===\"number\"||typeof e===\"boolean\")return JSON.stringify(e);if(Array.isArray(e))return`readonly [${e.map(ki).join(\", \")}]`;if(Pn(e))return`{ ${Object.entries(e).sort(([t],[n])=>rn(t,n)).map(([t,n])=>`readonly ${gu(t)}: ${ki(n)}`).join(\"; \")} }`;return\"unknown\"}function mo(e){let t=[...new Set(e)];if(t.includes(\"unknown\"))return\"unknown\";if(t.length===0)return\"never\";return t.length===1?t[0]:t.map(TR).join(\" | \")}function IR(e){let t=[...new Set(e.filter((n)=>n!==\"unknown\"))];return t.length===0?\"unknown\":t.length===1?t[0]:t.map(TR).join(\" & \")}function TR(e){return/[|&]/u.test(e)?`(${e})`:e}function gu(e){return/^[A-Za-z_$][A-Za-z0-9_$]*$/u.test(e)?e:JSON.stringify(e)}function tG(e){if(!e)return null;let t=e.replace(/\\s+/gu,\" \").trim().replace(/\\*\\//gu,\"*\\\\/\");if(!t)return null;return t.length<=512?t:`${t.slice(0,509)}...`}function nG(e,t){return[`${En(t)}/** ${e} */`]}function En(e){return\" \".repeat(e)}function Pn(e){return e!==null&&typeof e===\"object\"&&!Array.isArray(e)}class OR{definitions;entries;constructor(e){this.definitions=e;this.entries=e.map(({entry:t})=>t)}create(e){return new $R(e.catalogDigest,this.definitions,e.authorize,e.requireApproval,e.confirmModelApproval,e.resolveApproval,e.resolveArguments)}}class $R{catalogDigest;authorize;requireApproval;confirmModelApproval;resolveApproval;resolveArguments;byIdentity=new Map;byModelName=new Map;constructor(e,t,n,r,o,s,i){this.catalogDigest=e;this.authorize=n;this.requireApproval=r;this.confirmModelApproval=o;this.resolveApproval=s;this.resolveArguments=i;for(let a of t)this.byIdentity.set(Ti(a.entry.identity),a),this.byModelName.set(a.entry.modelName,a)}async call(e,t={}){return await(await this.prepareCallWithModelApproval(e,t,!1)).execute()}async prepareCall(e,t={}){return await this.prepareCallWithModelApproval(e,t,!1)}async prepareCallWithModelApproval(e,t,n){return ol(t.sourceCallId??e.operationId,async()=>{let r=await tt(\"gateway_policy\",()=>this.prepareCallCore(e,t,n));return{...r,execute:rl(r.execute)}})}async prepareCallCore(e,t,n){let r=Ff.parse({operationId:e.operationId,catalogDigest:e.catalogDigest,identity:e.identity,arguments:e.arguments}),o=r.operationId??e.operationId,s=e.caller;if(r.catalogDigest!==this.catalogDigest)throw new xi;let i=this.byIdentity.get(Ti(r.identity));if(!i)throw new mt;if(!this.resolveApproval&&this.requireApproval?.(i.entry,s,t))throw new Cn;let a=r.arguments;if(!i.validateInput(a)){let p=iG(a)?pR(a,i.diagnoseInput()):void 0;if(!p)throw CR(i,a);if(!i.validateInput(p))throw CR(i,p);a=p}if(s.kind===\"model\"&&!this.resolveApproval&&i.entry.approval===\"human\"&&!n)throw new Cn;let c={operationId:o,catalogDigest:r.catalogDigest,identity:r.identity,arguments:a,caller:s};await tt(\"provider_authorization\",()=>this.authorize?.({call:c,entry:i.entry}));let l=this.resolveApproval?await this.resolveApproval({call:c,entry:i.entry}):i.entry.approval===\"human\"?\"ask\":\"allow\";if(l===\"block\")throw new lu;if(this.resolveApproval&&l===\"ask\"&&(s.kind===\"model\"?!n:t.transportMeta?.approvalConfirmed!==!0))throw new Cn;if(l===\"ask\")await tt(\"preflight\",()=>i.preflightCall?.({call:c,entry:i.entry,context:t}));let u=await tt(\"lifecycle_prepare\",()=>i.lifecycle?.prepare({call:c,entry:i.entry,context:t}));return{call:c,entry:i.entry,approvalDecision:l,...u?.waitingForApproval?{waitingForApproval:u.waitingForApproval}:{},effectDigest:this.effectDigest(r.identity),approvalAuthorityDigest:i.approvalAuthorityDigest??ft({version:1,catalogDigest:this.catalogDigest,identity:i.entry.identity}),execute:async()=>tt(\"execution\",async()=>{if(u?.waitingForApproval)throw new Cn;let p=this.resolveArguments?await this.resolveArguments({call:c,entry:i.entry,arguments:structuredClone(a),context:t}):a;await tt(\"lifecycle_begin\",()=>u?.begin?.());let m;try{if(m=Vf.parse(await i.execute(p,{operationId:o,caller:s,...t.sourceCallId===void 0?{}:{sourceCallId:t.sourceCallId},...t.transportMeta===void 0?{}:{transportMeta:t.transportMeta},...t.signal===void 0?{}:{signal:t.signal}})),!m.isError&&i.validateOutput){if(!(m.structuredContent!==void 0&&i.validateOutput(m.structuredContent))&&!vg(m.structuredContent))throw new Ii}}catch(d){throw await tt(\"lifecycle_complete\",()=>u?.complete?.({outcome:\"failed\",error:d})),d}return await tt(\"lifecycle_complete\",()=>u?.complete?.({outcome:\"completed\",result:m})),m},(p)=>p.isError?\"rejected\":\"completed\")}}effectDigest(e){let t=this.byIdentity.get(Ti(e));if(!t)throw new mt;let{entry:n}=t;return ft({version:1,identity:n.identity,source:n.source,inputSchema:gn(n.inputSchema),outputSchema:gn(n.outputSchema??null),readOnly:n.annotations?.readOnlyHint??null,destructive:n.annotations?.destructiveHint??null,idempotent:n.annotations?.idempotentHint??null,authority:t.effectAuthorityDigest??t.approvalAuthorityDigest??null})}async callModel(e){let t=this.byModelName.get(e.modelName);if(!t)throw new mt;let n={operationId:e.operationId??oG(),catalogDigest:this.catalogDigest,identity:t.entry.identity,arguments:e.arguments,caller:{kind:\"model\",subjectId:e.subjectId}},r={...e.sourceCallId===void 0?{}:{sourceCallId:e.sourceCallId},...e.transportMeta===void 0?{}:{transportMeta:e.transportMeta},...e.signal===void 0?{}:{signal:e.signal}},o=t.entry.approval===\"human\"&&this.confirmModelApproval?.({entry:t.entry,modelName:e.modelName,subjectId:e.subjectId})===!0;return await(await this.prepareCallWithModelApproval(n,r,o)).execute()}}function MR(e){let t=lG(e),n,r,o=e.map((s,i)=>{let{execute:a,approvalAuthorityDigest:c,effectAuthorityDigest:l,requiresProviderPreflight:u,preflightCall:p,lifecycle:m,codemodePath:d,...f}=s;if(c!==void 0&&!/^[0-9a-f]{64}$/u.test(c))throw Error(\"Tool gateway approval authority digest must be lowercase SHA-256 hex\");if(l!==void 0&&!/^[0-9a-f]{64}$/u.test(l))throw Error(\"Tool gateway effect authority digest must be lowercase SHA-256 hex\");let h=Gf.parse({...f,codemodePath:t[i]}),y=structuredClone(h.inputSchema),_=h.outputSchema?structuredClone(h.outputSchema):null,E,T,A=()=>{if(E)return E;if(T)throw T;try{let K=n??=AR(\"first_error\");return E={input:hu(K,y),output:_?hu(K,_):null},E}catch(K){throw T=new pu(K),T}},x;return{entry:h,execute:a,approvalAuthorityDigest:c,effectAuthorityDigest:l,preflightCall:p,lifecycle:m,get validateInput(){return A().input},diagnoseInput:()=>x??=hu(r??=AR(\"all_errors\"),y),get validateOutput(){return A().output}}});return new OR(o)}var sG=512,On=new Map,qR=65536;function AR(e){let t={allErrors:e===\"all_errors\",coerceTypes:!1,strict:!1,useDefaults:!1,validateFormats:!1,code:{regExp:dR}},n={draft7:new ht.default(t),draft2019:new ER.default(t),draft2020:new PR.default(t)};if(e===\"all_errors\")for(let r of Object.values(n))r.removeKeyword(\"pattern\").addKeyword(cG);return{mode:e,...n}}function iG(e){try{let t=JSON.stringify(e);return t!==void 0&&t.length<=qR}catch{return!1}}function aG(e){let t=0;for(let n of e)t+=1;return t}var cG={keyword:\"pattern\",type:\"string\",schemaType:\"string\",error:{message:({schemaCode:e})=>ht.str`must match pattern \"${e}\"`,params:({schemaCode:e})=>ht._`{pattern: ${e}}`},code(e){let{gen:t,data:n,schema:r,parentSchema:o,it:s}=e,i=s.opts.unicodeRegExp?\"u\":\"\",a=t.scopeValue(\"pattern\",{key:`${r}/${i}`,ref:s.opts.code.regExp(r,i)}),c=o.maxLength;if(typeof c!==\"number\"){e.fail(ht._`!${a}.test(${n})`);return}let l=s.opts.unicode===!1?ht._`${n}.length`:ht._`${t.scopeValue(\"func\",{ref:aG})}(${n})`;e.fail(ht._`${l} <= ${c} && !${a}.test(${n})`)}};function CR(e,t){let n=e.validateInput.errors,r;try{let i=JSON.stringify(t);if(i!==void 0&&i.length<=qR){r={schema:e.entry.inputSchema,arguments:t};let a=e.diagnoseInput();if(!a(t)&&a.errors?.length)n=a.errors}}catch{}let{issues:o,omittedIssueCount:s}=yR(n,r);return new Si(o,s)}function hu(e,t){let n=typeof t.$schema===\"string\"?t.$schema:\"\",r=n.includes(\"2020-12\")?\"2020-12\":n.includes(\"2019-09\")?\"2019-09\":\"draft7\",o=`${e.mode}:${r}:${ft(t)}`,s=On.get(o);if(s)return On.delete(o),On.set(o,s),s;let i=r===\"2020-12\"?e.draft2020.compile(t):r===\"2019-09\"?e.draft2019.compile(t):e.draft7.compile(t);while(On.size>=sG){let a=On.keys().next().value;if(a===void 0)break;On.delete(a)}return On.set(o,i),i}function lG(e){let t=e.map(uG);return dG(t),t}function uG(e){let t=e.codemodePath?.length?[...e.codemodePath]:[e.identity.serverId,e.identity.toolName],n=t.map(mG);if(t.every((s,i)=>s===n[i]))return n;let r=`_${fG(e.identity)}`,o=n.at(-1);return[...n.slice(0,-1),`${o.slice(0,128-r.length)}${r}`]}function dG(e){let t={children:new Map,leaf:!1},n=[...e].sort(pG);for(let r of n){let o=t;for(let[s,i]of r.entries()){if(o.leaf)throw new nn(r,\"extends_leaf\");let a=o.children.get(i);if(!a)a={children:new Map,leaf:!1},o.children.set(i,a);if(o=a,s===r.length-1){if(o.leaf||o.children.size>0)throw new nn(r,\"collision\");o.leaf=!0}}}}function pG(e,t){let n=Math.min(e.length,t.length);for(let r=0;r<n;r+=1){let o=rn(e[r],t[r]);if(o!==0)return o}return e.length-t.length}function mG(e){let t=e.replace(/[^A-Za-z0-9_$]/gu,\"_\");if(!/^[A-Za-z_$]/u.test(t))t=`_${t}`;if([\"__proto__\",\"prototype\",\"constructor\"].includes(t))t=`_${t}`;return t.slice(0,128)||\"_\"}function fG(e){return rG(\"sha256\").update(Ti(e),\"utf8\").digest(\"hex\").slice(0,10)}function Ti(e){return`${e.serverId}\\x00${e.toolName}`}import{lstat as gG,mkdir as hG,mkdtemp as yG,readdir as bG,rm as DR,writeFile as vG}from\"node:fs/promises\";import{tmpdir as yu}from\"node:os\";import{dirname as _G,join as bu,resolve as zR}from\"node:path\";var jR=16777216,wG=\"opengeni-codemode-image-\",xG=86400000,SG=3600000,NR=0;async function Ai(e,t={}){let n=e.content.filter((a)=>a.type===\"image\");if(t.requireOne&&n.length!==1)throw Error(\"Codemode browser screenshot must return exactly one image block\");if(n.length===0)return[];if(t.saveTo!==void 0&&n.length!==1)throw Error(\"An explicit image path requires exactly one image block\");let r=0,o=n.map((a)=>{let c=kG(a.mimeType);if(r+=a.data.length,a.data.length===0||a.data.length>jR||r>jR)throw Error(\"Codemode image exceeds the Code Mode result limit\");let l=Buffer.from(a.data,\"base64\");if(l.length===0||l.toString(\"base64\")!==a.data||!RG(l,c))throw Error(\"Codemode image bytes are invalid\");return{bytes:l,mimeType:c}}),s;if(t.saveTo===void 0)await IG(),s=await yG(bu(yu(),wG));else{if(t.saveTo.length===0)throw TypeError(\"Image saveTo must be a nonempty path\");await hG(_G(zR(t.saveTo)),{recursive:!0})}let i=[];try{for(let[a,c]of o.entries()){let l=c.mimeType===\"image/jpeg\"?\"jpg\":c.mimeType.split(\"/\")[1],u=t.saveTo===void 0?bu(s,o.length===1?`frame.${l}`:`image-${a+1}.${l}`):zR(t.saveTo);await vG(u,c.bytes,{flag:\"wx\",mode:384}),i.push({path:u,mimeType:c.mimeType,sizeBytes:c.bytes.length})}}catch(a){if(s)await DR(s,{recursive:!0,force:!0});throw a}return i}async function IG(){let e=Date.now();if(e-NR<SG)return;if(NR=e,typeof process.getuid!==\"function\")return;try{let t=0;for(let n of await bG(yu(),{withFileTypes:!0})){if(!n.isDirectory()||!/^opengeni-codemode-image-[A-Za-z0-9]{6}$/u.test(n.name))continue;let r=bu(yu(),n.name),o=await gG(r);if(!o.isDirectory()||o.uid!==process.getuid()||(o.mode&63)!==0||e-o.mtimeMs<xG)continue;if(await DR(r,{recursive:!0,force:!0}),++t>=64)break}}catch{}}function kG(e){if(e===\"image/png\"||e===\"image/jpeg\"||e===\"image/webp\")return e;throw Error(`Codemode image has unsupported type: ${e}`)}function RG(e,t){switch(t){case\"image/png\":return e.length>=8&&e.subarray(0,8).equals(Buffer.from(\"89504e470d0a1a0a\",\"hex\"));case\"image/jpeg\":return e.length>=3&&e[0]===255&&e[1]===216&&e[2]===255;case\"image/webp\":return e.length>=12&&e.toString(\"ascii\",0,4)===\"RIFF\"&&e.toString(\"ascii\",8,12)===\"WEBP\"}}import{readFile as TG}from\"node:fs/promises\";var Sr={url:\"OPENGENI_CODEMODE_URL\",token:\"OPENGENI_CODEMODE_TOKEN\",tokenFile:\"OPENGENI_CODEMODE_TOKEN_FILE\"},vu=null;function on(e=process.env){let t=_u(e,Sr.url),n=e[Sr.token]!==void 0,r=n?void 0:_u(e,Sr.tokenFile),o=`${t}\\x00${n?\"direct\":`file:${r}`}`;if(e===process.env&&vu?.key===o)return vu.client;let s=new wu({baseUrl:t,token:n?async()=>_u(e,Sr.token):async()=>await CG(r)});if(e===process.env)vu={key:o,client:s};return s}function AG(e=()=>on()){let t=(n)=>new Proxy(async(r={},o={})=>await(await e()).callPathValue(n,r,o),{get(r,o){if(o===\"then\")return;if(o===Symbol.toStringTag)return\"CodemodeTool\";if(typeof o!==\"string\")return;return t([...n,o])},set(){return!1}});return new Proxy(Object.create(null),{get(n,r){if(r===\"then\")return;if(r===Symbol.toStringTag)return\"CodemodeTools\";if(typeof r!==\"string\")return;return t([r])},set(){return!1}})}var J9=AG();async function CG(e){let t;try{t=(await TG(e,\"utf8\")).trim()}catch{throw Error(`${Sr.tokenFile} is not readable`)}if(!t)throw Error(`${Sr.tokenFile} is empty`);return t}function _u(e,t){let n=e[t]?.trim();if(!n)throw Error(`${t} is required`);return n}import{randomBytes as LR}from\"node:crypto\";class fo extends Error{result;code;retryable;constructor(e){let t=EG(e);super(t.message);this.result=e;this.name=\"CodemodeToolExecutionError\",this.code=t.code,this.retryable=t.retryable}}function UR(e=()=>on()){return typeof e===\"function\"?e:()=>e}async function O(e,t,n,r){let o=await(await e()).callPath(t,n,r);if(o.isError)throw new fo(o);if(!o.structuredContent)throw Error(`Codemode tool ${t.join(\".\")} returned no structured content`);return o.structuredContent}function EG(e){let n=e.structuredContent?.error;return{code:typeof n?.code===\"string\"?n.code:\"tool_error\",message:typeof n?.message===\"string\"?n.message:\"Codemode tool failed\",retryable:n?.retryable===!0}}var sn={list:[\"artifacts\",\"list\"],create:[\"artifacts\",\"create\"],import:[\"artifacts\",\"import\"],get:[\"artifacts\",\"get\"],inspect:[\"artifacts\",\"inspect\"],apply:[\"artifacts\",\"apply\"],export:[\"artifacts\",\"export\"],exportStatus:[\"artifacts\",\"exportStatus\"]},PG=Object.freeze({stable:qG,document:zG});class xu{client;ids=PG;constructor(e){this.client=e}async list(e={},t={}){return(await O(this.client,sn.list,e,t)).artifacts}async create(e,t,n={}){let r=await O(this.client,sn.create,{modality:e,title:t},n);return new go(this.client,r.id,r)}async import(e,t,n,r={}){let o=await O(this.client,sn.import,{fileId:e,modality:t,title:n},r);return new go(this.client,o.id,o)}use(e){return typeof e===\"string\"?new go(this.client,e):new go(this.client,e.id,e)}}var OG=Object.freeze({paragraph:\"p\",table:\"dt\",\"page-break\":\"pb\",section:\"sec\",header:\"hdr\",footer:\"ftr\",comment:\"dc\",\"tracked-change\":\"chg\"}),$G=0xffffffffffffffffn,MG=BigInt(Number.MAX_SAFE_INTEGER)-1n;function qG(){let e=LR(16);if(e.subarray(0,8).every((t)=>t===0))e[0]=1;if(e.subarray(8,16).every((t)=>t===0))e[8]=1;return e.toString(\"hex\")}function zG(e,t){let n=jG(t),r=LR(7);r[0]=(r[0]??0)&31;let o=0n;for(let s of r)o=o<<8n|BigInt(s);if(o===0n)o=1n;if(o>MG)throw Error(\"Generated document id counter exceeds the canonical limit\");return`${OG[e]}/${n.toString(16).padStart(16,\"0\")}${o.toString(16).padStart(16,\"0\")}`}function jG(e){if(typeof e===\"number\"&&(!Number.isSafeInteger(e)||e<0)||typeof e===\"string\"&&!/^(?:0|[1-9][0-9]*)$/u.test(e))throw TypeError(\"Document id namespace must be an unsigned decimal integer\");let t=BigInt(e);if(t<0n||t>$G)throw RangeError(\"Document id namespace is outside the uint64 range\");return t}class go{client;id;metadata;constructor(e,t,n=null){this.client=e;this.id=t;this.metadata=n}async get(e={}){let t=await O(this.client,sn.get,{artifactId:this.id},e);return this.metadata=t,t}async inspect(e,t={}){let n=(await this.currentMetadata(t)).modality,r=await O(this.client,sn.inspect,{artifactId:this.id,modality:n,request:e},t);return this.metadata=r.artifact,r}async apply(e,t={}){let n=await this.currentMetadata(t),r=await O(this.client,sn.apply,{artifactId:this.id,modality:n.modality,expectedHeadSequence:n.headSequence,expectedStateHash:n.stateHash,commands:e},t);return this.metadata=r.artifact,r}async export(e,t={},n={}){let r=await O(this.client,sn.export,{artifactId:this.id,format:e,options:t},n);return this.metadata=r.artifact,new GR(this.client,r.artifact.id,r.versionId,r.jobId,r.sourceHeadSequence,r.sourceStateHash)}async currentMetadata(e){return this.metadata??await this.get(e)}}class GR{client;artifactId;versionId;jobId;sourceHeadSequence;sourceStateHash;constructor(e,t,n,r,o,s){this.client=e;this.artifactId=t;this.versionId=n;this.jobId=r;this.sourceHeadSequence=o;this.sourceStateHash=s}async status(e={}){return await O(this.client,sn.exportStatus,{artifactId:this.artifactId,versionId:this.versionId,jobId:this.jobId},e)}}var j={discover:[\"interaction\",\"discover\"],browserOpen:[\"interaction\",\"browser\",\"open\"],browserTabs:[\"interaction\",\"browser\",\"tabs\"],browserObserve:[\"interaction\",\"browser\",\"observe\"],browserRead:[\"interaction\",\"browser\",\"read\"],browserScreenshot:[\"interaction\",\"browser\",\"screenshot\"],browserAct:[\"interaction\",\"browser\",\"act\"],browserClipboard:[\"interaction\",\"browser\",\"clipboard\"],browserDebug:[\"interaction\",\"browser\",\"debug\"],browserDownloads:[\"interaction\",\"browser\",\"downloads\"],browserDownloadSave:[\"interaction\",\"browser\",\"downloadSave\"],browserAuth:[\"interaction\",\"browser\",\"auth\"],requestHuman:[\"interaction\",\"requestHuman\"],browserIdentity:[\"interaction\",\"browser\",\"identity\"],browserPublish:[\"interaction\",\"browser\",\"publish\"],browserLifecycle:[\"interaction\",\"browser\",\"lifecycle\"],computerOpen:[\"interaction\",\"computer\",\"open\"],computerTargets:[\"interaction\",\"computer\",\"targets\"],computerObserve:[\"interaction\",\"computer\",\"observe\"],computerClipboard:[\"interaction\",\"computer\",\"clipboard\"],computerAct:[\"interaction\",\"computer\",\"act\"],computerLifecycle:[\"interaction\",\"computer\",\"lifecycle\"]};class BR{browsers;computers;artifacts;auth;constructor(e=()=>on()){let t=UR(e);this.browsers=new VR(t),this.computers=new QR(t),this.artifacts=new xu(t),this.auth=new YR(t)}async discover(e={},t={}){return await O(this.browsers.client,j.discover,e,t)}async requestHuman(e,t={}){return await O(this.browsers.client,j.requestHuman,e,t)}}class VR{client;identities;constructor(e){this.client=e;this.identities=new FR(e)}async list(e={},t={}){return(await O(this.client,j.discover,e,t)).browsers}async open(e={},t={}){let n=await O(this.client,j.browserOpen,e,t);return new Su(this.client,n.session.id)}use(e){return new Su(this.client,e)}}class FR{client;constructor(e){this.client=e}async list(e={},t={}){return(await O(this.client,j.browserIdentity,{operation:\"list\",...e},t)).result}async get(e,t={}){return(await O(this.client,j.browserIdentity,{operation:\"get\",identityId:e},t)).result}async create(e,t={}){return(await O(this.client,j.browserIdentity,{operation:\"create\",name:e},t)).result}async revisions(e,t={}){return(await O(this.client,j.browserIdentity,{operation:\"revisions\",identityId:e},t)).result}async update(e,t,n={}){return(await O(this.client,j.browserIdentity,{operation:\"update\",identityId:e,...t},n)).result}}class Su{client;id;tabs;auth;clipboard;downloads;constructor(e,t){this.client=e;this.id=t;this.tabs=new HR(e,t),this.auth=new XR(e,t),this.clipboard=new KR(e,t,this.tabs),this.downloads=new JR(e,t)}async refresh(e={}){return(await O(this.client,j.browserOpen,{browserSessionId:this.id},e)).session}async observe(e,t={}){return await this.tabs.use(await this.tabs.resolveId(e,t)).observe(t)}async observeFull(e,t={}){return await this.tabs.use(await this.tabs.resolveId(e,t)).observeFull(t)}async read(e={},t={}){let{targetId:n,...r}=e;return await this.tabs.use(await this.tabs.resolveId(n,t)).read(r,t)}async screenshot(e={},t={}){return await this.tabs.use(await this.tabs.resolveId(e.targetId,t)).screenshot(e,t)}async act(e,t={},n={}){let r=await this.tabs.resolveId(t.targetId,n);return await this.tabs.use(r).act(e,t,n)}async diagnostics(e,t={},n={}){return await O(this.client,j.browserDebug,{browserSessionId:this.id,targetId:await this.tabs.resolveId(e,n),...t},n)}async publish(e,t={}){return await O(this.client,j.browserPublish,{browserSessionId:this.id,...e},t)}async suspend(e={}){return await this.lifecycle(\"suspend\",e)}async resume(e={}){return await this.lifecycle(\"resume\",e)}async end(e={}){return await this.lifecycle(\"end\",e)}async lifecycle(e,t){return await O(this.client,j.browserLifecycle,{browserSessionId:this.id,action:e},t)}}class JR{client;browserSessionId;constructor(e,t){this.client=e;this.browserSessionId=t}async list(e={}){return await O(this.client,j.browserDownloads,{browserSessionId:this.browserSessionId,operation:\"list\"},e)}download(e){return new WR(this.client,this.browserSessionId,e)}}class WR{client;browserSessionId;id;constructor(e,t,n){this.client=e;this.browserSessionId=t;this.id=n}async get(e={}){return await O(this.client,j.browserDownloads,{browserSessionId:this.browserSessionId,operation:\"get\",downloadId:this.id},e)}async saveToWorkspace(e,t={},n={}){return await O(this.client,j.browserDownloadSave,{browserSessionId:this.browserSessionId,downloadId:this.id,destinationPath:e,...t.overwrite===void 0?{}:{overwrite:t.overwrite}},n)}}class KR{client;browserSessionId;tabs;constructor(e,t,n){this.client=e;this.browserSessionId=t;this.tabs=n}async read(e={}){return await O(this.client,j.browserClipboard,{browserSessionId:this.browserSessionId},e)}async write(e,t={},n={}){return await this.act({type:\"clipboard\",operation:\"write\",text:e},t,n)}async clear(e={},t={}){return await this.act({type:\"clipboard\",operation:\"clear\"},e,t)}async copy(e={},t={}){let{targetId:n,expectedTargetGeneration:r,expectedDocumentGeneration:o,expectedFrameId:s,...i}=e;return await this.act({type:\"clipboard\",operation:\"copy\",...i},{targetId:n,expectedTargetGeneration:r,expectedDocumentGeneration:o,expectedFrameId:s},t)}async paste(e={},t={}){let{targetId:n,expectedTargetGeneration:r,expectedDocumentGeneration:o,expectedFrameId:s,...i}=e;return await this.act({type:\"clipboard\",operation:\"paste\",...i},{targetId:n,expectedTargetGeneration:r,expectedDocumentGeneration:o,expectedFrameId:s},t)}async act(e,t,n){let{targetId:r,...o}=t;return await this.tabs.use(await this.tabs.resolveId(r,n)).act(e,o,n)}}class HR{client;browserSessionId;constructor(e,t){this.client=e;this.browserSessionId=t}async list(e={}){return await O(this.client,j.browserTabs,{operation:\"list\",browserSessionId:this.browserSessionId},e)}async selected(e={}){return this.use(await this.resolveId(void 0,e))}use(e){return new ZR(this.client,this.browserSessionId,e)}async open(e,t={}){let n=await this.list(t),r=await O(this.client,j.browserTabs,{operation:\"open\",browserSessionId:this.browserSessionId,...e?{url:e}:{}},t),o=new Set(n.targets.map((i)=>i.id)),s=r.targets.find((i)=>!o.has(i.id))??r.targets.find((i)=>i.selected);if(!s)throw Error(\"Browser opened no discoverable tab\");return this.use(s.id)}async select(e,t={}){if(!(await O(this.client,j.browserTabs,{operation:\"select\",browserSessionId:this.browserSessionId,targetId:e},t)).targets.some((r)=>r.id===e&&r.selected))throw Error(\"Browser did not select the requested tab\");return this.use(e)}async close(e,t={}){return await O(this.client,j.browserTabs,{operation:\"close\",browserSessionId:this.browserSessionId,targetId:e},t)}async resolveId(e,t){let n=await this.list(t);if(e){if(!n.targets.some((o)=>o.id===e))throw Error(`Browser tab is unavailable: ${e}`);return e}let r=n.targets.filter((o)=>o.selected);if(r.length===1)return r[0].id;if(n.targets.length===1)return n.targets[0].id;if(n.targets.length===0)throw Error(\"Browser has no tabs\");throw Error(\"Browser target is ambiguous; select an exact tab\")}}class ZR{client;browserSessionId;id;constructor(e,t,n){this.client=e;this.browserSessionId=t;this.id=n}async observe(e={}){return await O(this.client,j.browserObserve,{browserSessionId:this.browserSessionId,targetId:this.id},e)}async observeFull(e={}){return await O(this.client,j.browserObserve,{browserSessionId:this.browserSessionId,targetId:this.id,view:\"full\"},e)}async read(e={},t={}){return await O(this.client,j.browserRead,{browserSessionId:this.browserSessionId,targetId:this.id,...e},t)}async screenshot(e={},t={}){let n=await(await this.client()).callPath(j.browserScreenshot,{browserSessionId:this.browserSessionId,targetId:this.id,...e.fullPage===void 0?{}:{fullPage:e.fullPage},...e.quality===void 0?{}:{quality:e.quality}},t);return await NG(n,e.saveTo)}async act(e,t={},n={}){return await O(this.client,j.browserAct,{browserSessionId:this.browserSessionId,targetId:this.id,action:e,...t},n)}async navigate(e,t={}){let{waitUntil:n,...r}=t,o=n?{type:\"navigate\",url:e,waitUntil:n}:{type:\"navigate\",url:e};return await this.act(o,{},r)}async setPermission(e,t,n={},r={}){return await this.act({type:\"permission\",permission:e,setting:t},n,r)}async requestHuman(e,t={},n={}){let r=await this.observe(n);return await O(this.client,j.requestHuman,{operation:\"request\",resourceKind:\"browser_session\",resourceId:this.browserSessionId,targetId:this.id,expectedControllerGeneration:r.target.controllerGeneration,expectedTargetGeneration:r.target.targetGeneration,expectedDocumentGeneration:r.target.documentGeneration,kind:t.kind??\"other\",reason:e,...t.authRunId?{authRunId:t.authRunId}:{},...t.expiresInSeconds===void 0?{}:{expiresInSeconds:t.expiresInSeconds}},n)}getByRole(e,t={}){return new an(this,{kind:\"role\",role:e,...t})}getByText(e){return new an(this,{kind:\"text\",text:e})}getByLabel(e){return new an(this,{kind:\"label\",text:e})}getByPlaceholder(e){return new an(this,{kind:\"placeholder\",text:e})}getByTestId(e){return new an(this,{kind:\"test_id\",value:e})}locator(e){return new an(this,{kind:\"css\",selector:e})}ref(e){return new an(this,{kind:\"ref\",ref:e})}}class an{tab;locator;constructor(e,t){this.tab=e;this.locator=t}async click(e={},t={}){return await this.tab.act({type:\"click\",locator:this.locator,...e},{},t)}async doubleClick(e={}){return await this.tab.act({type:\"double_click\",locator:this.locator},{},e)}async hover(e={}){return await this.tab.act({type:\"hover\",locator:this.locator},{},e)}async fill(e,t={}){return await this.tab.act({type:\"fill\",locator:this.locator,value:e},{},t)}async type(e,t={}){return await this.tab.act({type:\"type\",locator:this.locator,text:e},{},t)}async press(e,t={}){return await this.tab.act({type:\"press\",locator:this.locator,key:e},{},t)}async select(e,t={}){return await this.tab.act({type:\"select\",locator:this.locator,values:e},{},t)}async check(e=!0,t={}){return await this.tab.act({type:\"check\",locator:this.locator,checked:e},{},t)}}class YR{client;constructor(e){this.client=e}async listConnections(e={},t={}){return(await O(this.client,j.browserAuth,{operation:\"list_connections\",...e},t)).result}async getConnection(e,t={}){return(await O(this.client,j.browserAuth,{operation:\"get_connection\",siteAuthConnectionId:e},t)).result}async listRuns(e={},t={}){return(await O(this.client,j.browserAuth,{operation:\"list_runs\",...e},t)).result}async getRun(e,t={}){return(await O(this.client,j.browserAuth,{operation:\"get_run\",authRunId:e},t)).result}use(e,t){return new ku(this.client,e,t)}}class XR{client;browserSessionId;constructor(e,t){this.client=e;this.browserSessionId=t}async listRuns(e={},t={}){return(await O(this.client,j.browserAuth,{operation:\"list_runs\",browserSessionId:this.browserSessionId,...e},t)).result}async start(e,t={}){let n=await O(this.client,j.browserAuth,{operation:\"start\",browserSessionId:this.browserSessionId,...e},t);return this.use(n.result.run.id)}use(e){return new ku(this.client,this.browserSessionId,e)}}class ku{client;browserSessionId;id;constructor(e,t,n){this.client=e;this.browserSessionId=t;this.id=n}async get(e={}){let t=await O(this.client,j.browserAuth,{operation:\"get_run\",authRunId:this.id},e);if(t.result.browserSessionId!==this.browserSessionId)throw Error(\"Auth run belongs to another BrowserSession\");return t.result}async report(e,t={}){return(await O(this.client,j.browserAuth,{operation:\"report\",browserSessionId:this.browserSessionId,authRunId:this.id,...e},t)).result}async advanceExternal(e,t={}){return(await O(this.client,j.browserAuth,{operation:\"advance_external\",browserSessionId:this.browserSessionId,authRunId:this.id,...e},t)).result}async verify(e,t={}){return(await O(this.client,j.browserAuth,{operation:\"verify\",browserSessionId:this.browserSessionId,authRunId:this.id,...e},t)).result}}class QR{client;constructor(e){this.client=e}async list(e={},t={}){return(await O(this.client,j.discover,e,t)).computers}async open(e={},t={}){let n=await O(this.client,j.computerOpen,e,t);return new Iu(this.client,n.session.id)}use(e){return new Iu(this.client,e)}}class Iu{client;id;targets;apps;clipboard;constructor(e,t){this.client=e;this.id=t;this.targets=new tT(e,t),this.apps=this.targets,this.clipboard=new eT(e,t,this.targets)}async refresh(e={}){return(await O(this.client,j.computerOpen,{computerSessionId:this.id},e)).session}async observe(e,t={}){return await this.targets.use(await this.targets.resolveId(e,t)).observe(t)}async act(e,t={},n={}){return await this.targets.use(await this.targets.resolveId(t.targetId,n)).act(e,t,n)}async launch(e,t={}){let n=await this.targets.resolveId(void 0,t);return await this.targets.use(n).act({type:\"launch\",applicationId:e},{},t),await this.targets.list(t)}async end(e={}){return await O(this.client,j.computerLifecycle,{computerSessionId:this.id,action:\"end\"},e)}}class eT{client;computerSessionId;targets;constructor(e,t,n){this.client=e;this.computerSessionId=t;this.targets=n}async read(e={}){return await O(this.client,j.computerClipboard,{computerSessionId:this.computerSessionId},e)}async write(e,t={},n={}){return await this.mutate({type:\"clipboard\",operation:\"write\",text:e},t,n)}async clear(e={},t={}){return await this.mutate({type:\"clipboard\",operation:\"clear\"},e,t)}async copy(e={},t={}){return await this.mutate({type:\"clipboard\",operation:\"copy\"},e,t)}async paste(e={},t={}){return await this.mutate({type:\"clipboard\",operation:\"paste\"},e,t)}async mutate(e,t,n){let r=await this.targets.resolveSeatId(t.targetId,n);return await this.targets.use(r).act(e,{},n)}}class tT{client;computerSessionId;constructor(e,t){this.client=e;this.computerSessionId=t}async list(e={}){return await O(this.client,j.computerTargets,{computerSessionId:this.computerSessionId},e)}use(e){return new nT(this.client,this.computerSessionId,e)}async focused(e={}){return this.use(await this.resolveId(void 0,e))}async resolveId(e,t){let n=await this.list(t);if(e){if(!n.targets.some((o)=>o.id===e))throw Error(`Computer target is unavailable: ${e}`);return e}let r=n.targets.filter((o)=>o.focused);if(r.length===1)return r[0].id;if(n.targets.length===1)return n.targets[0].id;if(n.targets.length===0)throw Error(\"Computer has no app, window, or screen targets\");throw Error(\"Computer target is ambiguous; select an exact app or window\")}async resolveSeatId(e,t){if(e)return await this.resolveId(e,t);let r=(await this.list(t)).targets.filter((o)=>o.kind===\"screen\");if(r.length===1)return r[0].id;return await this.resolveId(void 0,t)}}class nT{client;computerSessionId;id;constructor(e,t,n){this.client=e;this.computerSessionId=t;this.id=n}async observe(e={}){return await O(this.client,j.computerObserve,{computerSessionId:this.computerSessionId,targetId:this.id},e)}async act(e,t={},n={}){return await O(this.client,j.computerAct,{computerSessionId:this.computerSessionId,targetId:this.id,action:e,...t},n)}async requestHuman(e,t={},n={}){let r=await this.observe(n);return await O(this.client,j.requestHuman,{operation:\"request\",resourceKind:\"computer_session\",resourceId:this.computerSessionId,targetId:this.id,expectedControllerGeneration:r.target.controllerGeneration,expectedTargetGeneration:r.target.targetGeneration,expectedDocumentGeneration:null,kind:t.kind??\"other\",reason:e,...t.expiresInSeconds===void 0?{}:{expiresInSeconds:t.expiresInSeconds}},n)}getByRole(e,t={}){return new Ir(this,{kind:\"role\",role:e,...t})}getByText(e,t){return new Ir(this,{kind:\"text\",text:e,...t?{exact:t}:{}})}getByLabel(e,t){return new Ir(this,{kind:\"label\",text:e,...t?{exact:t}:{}})}getByIdentifier(e){return new Ir(this,{kind:\"identifier\",value:e})}ref(e){return new Ir(this,{kind:\"ref\",ref:e})}}class Ir{target;locator;constructor(e,t){this.target=e;this.locator=t}async invoke(e={}){return await this.semantic(\"invoke\",void 0,e)}async focus(e={}){return await this.semantic(\"focus\",void 0,e)}async setValue(e,t={}){return await this.semantic(\"set_value\",e,t)}async select(e={}){return await this.semantic(\"select\",void 0,e)}async expand(e={}){return await this.semantic(\"expand\",void 0,e)}async collapse(e={}){return await this.semantic(\"collapse\",void 0,e)}async semantic(e,t,n){return await this.target.act({type:\"semantic\",locator:this.locator,action:e,...t===void 0?{}:{value:t}},{},n)}}async function NG(e,t){if(e.isError)throw new fo(e);if(!e.structuredContent)throw Error(\"Codemode tool interaction.browser.screenshot returned no structured content\");let n=e.content.find((o)=>o.type===\"image\");if(typeof e.structuredContent.mediaType===\"string\"&&n&&e.structuredContent.mediaType!==n.mimeType)throw Error(\"Codemode browser screenshot image type differs from frame metadata\");return{...(await Ai(e,{...t===void 0?{}:{saveTo:t},requireOne:!0}))[0],metadata:e.structuredContent}}function DG(e=()=>on()){return new BR(e)}var r5=DG();function c5(e,t={}){let n=Ci(e);return Ri({digest:n.digest,entries:n.entries},{moduleSpecifier:t.moduleSpecifier??\"@opengeni/codemode\",interfaceName:\"CodemodeGeneratedTools\",callOptionsType:\"CodemodeCallOptions\",fallbackResultType:\"CodemodeToolResult\",typedResultWrapperType:\"CodemodeMultimodalValue\",generatedBy:\"@opengeni/codemode via @opengeni/tool-gateway\",catalogDigestLabel:\"Attempt catalog digest\"})}import{randomUUID as oT}from\"node:crypto\";var Ru='(()=>{var Z=(e,t,n)=>()=>{if(e)try{t=e(e=0)}catch(s){n=[s]}if(n)throw n[0];return t};function Le(e){return e!==null&&typeof e===\"object\"&&!Array.isArray(e)?e:null}function dt(e,t=Number.MAX_SAFE_INTEGER){return typeof e===\"number\"&&Number.isSafeInteger(e)&&e>=0&&e<=t}function Ss(e){let t=e.slice(0,2048).replace(/[\\\\u0000-\\\\u001f\\\\u007f]+/g,\" \").trim(),n=new TextEncoder().encode(t),s=Math.min(n.length,1024);while(s>0&&s<n.length&&(n[s]&192)===128)s-=1;return new TextDecoder().decode(n.slice(0,s)).trim()}function gt(e){let t=Le(e);if(!t)return null;let n=Le(t.sessionUsageLimit)??t;if(n.code!==\"session_usage_limit_reached\")return null;let s=Le(n.details)??n;if(s.basis!==\"model_api_equivalent_v1\"||typeof s.rootSessionId!==\"string\"||!bs.test(s.rootSessionId)||!dt(s.limitMicros,10000000000000)||!dt(s.usedMicros))return null;let i={code:\"session_usage_limit_reached\",basis:\"model_api_equivalent_v1\",rootSessionId:s.rootSessionId.toLowerCase(),limitMicros:s.limitMicros,usedMicros:s.usedMicros,message:\"\"},r=typeof n.message===\"string\"?Ss(n.message):\"\";return{...i,message:r||ws(i)}}function pt(e){if(e>0&&e<1e4)return\"<$0.01\";return`$${(e/1e6).toLocaleString(\"en-US\",{minimumFractionDigits:2,maximumFractionDigits:2})}`}function ws(e){return`This task\\'s usage limit is reached (${pt(e.usedMicros)} of ${pt(e.limitMicros)} API-equivalent model usage). A person can raise or remove the limit to continue.`}var bs;var mt=Z(()=>{bs=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i});function yt(e){if(e.status!==400&&e.status!==422)return!1;let t;try{t=JSON.parse(e.body)}catch{return!1}if(!t||typeof t!==\"object\")return!1;let n=t,s=n.error&&typeof n.error===\"object\"?n.error:n,i=typeof s.message===\"string\"?s.message:\"\",r=/^Invalid session create request: (.+) failed schema validation$/.exec(i);if(s.code===\"INVALID_SESSION_CREATE_REQUEST\"&&r?.[1]?.split(/,\\\\s*/).includes(\"startMode\"))return!0;let o=s.details&&typeof s.details===\"object\"?s.details:null;return(Array.isArray(o?.issues)?o.issues:[]).some((c)=>{if(!c||typeof c!==\"object\")return!1;let u=c.path;return u===\"startMode\"||Array.isArray(u)&&u.length===1&&u[0]===\"startMode\"})}function ft(e){return new pe(\"The server did not confirm the requested usage limit; it may not support usage limits. Read the limit again before relying on it.\",{sessionId:e})}function Je(e){try{let t=JSON.parse(e);if(!t||typeof t!==\"object\"||Array.isArray(t))return null;let n=t;return gt(n.error&&typeof n.error===\"object\"&&!Array.isArray(n.error)?n.error:n)}catch{return null}}function Ve(e){try{let t=JSON.parse(e);if(!t||typeof t!==\"object\"||Array.isArray(t))return null;let n=t,s=n.error&&typeof n.error===\"object\"&&!Array.isArray(n.error)?n.error:n;if(s.code!==\"allowance_exhausted\")return null;let i=s.details&&typeof s.details===\"object\"&&!Array.isArray(s.details)?s.details:s;if(i.scope!==\"workspace\"&&i.scope!==\"member\")return null;if(i.resetsAt!==null&&typeof i.resetsAt!==\"string\")return null;return{scope:i.scope,resetsAt:i.resetsAt,...typeof i.subjectId===\"string\"?{subjectId:i.subjectId}:{}}}catch{return null}}function vs(e){if(!e)return null;try{let t=JSON.parse(e);if(!t||typeof t!==\"object\"||Array.isArray(t))return null;let n=t,s=n.error&&typeof n.error===\"object\"&&!Array.isArray(n.error)?n.error:n,i=We(s.code),r=We(s.message),o=ht(s.requestId),a=typeof s.retryable===\"boolean\"?s.retryable:void 0,c=typeof s.outcomeUnknown===\"boolean\"?s.outcomeUnknown:void 0,u=ks(s.details);if(!i&&!r&&!o&&a===void 0&&c===void 0&&!u)return null;return{code:i,message:r,requestId:o,retryable:a,outcomeUnknown:c,details:u}}catch{return null}}function ks(e){if(!e||typeof e!==\"object\"||Array.isArray(e))return;let t=Object.entries(e).slice(0,16),n={};for(let[s,i]of t){if(!/^[a-zA-Z][\\\\w.-]{0,63}$/.test(s))continue;if(typeof i===\"string\"){let r=We(i);if(r!==void 0)n[s]=r}else if(typeof i===\"number\"||typeof i===\"boolean\"||i===null)n[s]=i;else if(s===\"action\"&&typeof i===\"object\"&&!Array.isArray(i)&&i.type===\"upgrade\"&&i.href===\"/billing\")n.action={type:\"upgrade\",href:\"/billing\"}}return Object.keys(n).length>0?n:void 0}function We(e){if(typeof e!==\"string\")return;let t=new TextEncoder().encode(e);return t.byteLength<=512?e:new TextDecoder().decode(t.slice(0,512))}function Is(e){return e===408||e===409||e===425||e===429||e>=500}function ht(e){if(typeof e!==\"string\"||e.length>128||!/^[\\\\w.:-]+$/.test(e))return;return e}function K(e){return e instanceof DOMException&&e.name===\"AbortError\"||e instanceof Error&&e.name===\"AbortError\"}function j(e){if(e instanceof P)return e.retryable;return e instanceof TypeError}var P,ze,Ne,Fe,pe,we,He,ve,L;var V=Z(()=>{mt();P=class P extends Error{status;code;retryable;correlationId;outcomeUnknown;body;details;constructor(e,t,n={}){let s=vs(t),i=s?.requestId??ht(n.correlationId),r=e>=502&&e<=504,o=n.mutation!==void 0,a=s?.message??(o?\"Request failed.\":t||\"(empty body)\"),c=n.displayMessage??(r&&o?s?.message??\"The workspace is temporarily unavailable — retry.\":`API ${e}: ${a}`);super(i?`${c} Reference: ${i}.`:c);this.name=\"OpenGeniApiError\",this.status=e,this.code=n.code??s?.code??(r&&o?\"upstream_unavailable\":void 0),this.retryable=n.retryable??s?.retryable??Is(e),this.correlationId=i,this.outcomeUnknown=n.outcomeUnknown??s?.outcomeUnknown??(r&&!!n.mutation&&!s),this.body=!o||s?t:\"\",this.details=s?.details}};ze=class ze extends P{constructor(e){super(e.status,e.body,{code:\"OPENGENI_SETUP_REQUIRED\",retryable:!1,correlationId:e.correlationId,displayMessage:\"Private chats require organization_private_session_settings.enabled (migration 0323). An organization owner or admin can enable Only me chats in the web app under Organization settings > Security & data, or use updateOrganizationPrivateSessionSettings from @opengeni/sdk/organization-private-session-settings with enabled: true, the current expectedVersion and a stable operationId (PATCH /v1/organizations/:organizationId/private-session-settings; an organization key needs workspace:admin). If platform readiness is unavailable, ask the deployment operator to activate session tenancy first.\"});this.name=\"OpenGeniSetupError\"}};Ne=class Ne extends P{scope;resetsAt;subjectId;constructor(e,t,n={}){super(e,t,{...n,code:\"allowance_exhausted\",retryable:!1,outcomeUnknown:!1});this.name=\"OpenGeniAllowanceExhaustedError\";let s=Ve(t);this.scope=s?.scope??\"workspace\",this.resetsAt=s?.resetsAt??null,this.subjectId=s?.subjectId}};Fe=class Fe extends P{rootSessionId;limitMicros;usedMicros;constructor(e,t,n={}){super(e,t,{...n,code:\"session_usage_limit_reached\",retryable:!1,outcomeUnknown:!1});this.name=\"OpenGeniSessionUsageLimitReachedError\";let s=Je(t);this.rootSessionId=s?.rootSessionId,this.limitMicros=s?.limitMicros,this.usedMicros=s?.usedMicros}};pe=class pe extends Error{code=\"session_usage_limit_unsupported\";sessionId;constructor(e,t={}){super(e,t.cause===void 0?void 0:{cause:t.cause});this.name=\"OpenGeniSessionUsageLimitUnsupportedError\",this.sessionId=t.sessionId??null}};we=class we extends Error{code=\"secure_context_required\";retryable=!1;reason;constructor(e){super(e===\"insecure_context\"?\"Couldn’t attach this file because this page is open over HTTP. Attachments require a secure HTTPS connection. Open the secure site or configure HTTPS for this deployment.\":\"Couldn’t attach this file because secure browser cryptography is unavailable. Attachments require HTTPS and Web Crypto support. Open a secure site in a supported browser or configure HTTPS for this deployment.\");this.name=\"OpenGeniSecureContextRequiredError\",this.reason=e}};He=class He extends P{};ve=class ve extends Error{expected;actual;constructor(e,t){super(`API contract mismatch: client expects ${e}, API serves ${t}`);this.name=\"OpenGeniApiContractMismatchError\",this.expected=e,this.actual=t}};L=class L extends Error{constructor(e){super(e);this.name=\"OpenGeniStreamError\"}}});function ke(e){let t=null,n=0,s=!1,i=null,r=null,o=()=>{if(i&&i.epoch===n)return i;let l=s,p={epoch:n,controller:new AbortController,waiters:0,settled:!1};return i=p,p.promise=(async()=>{try{let d=await e(l,p.controller.signal);if(p.epoch===n&&!p.controller.signal.aborted)t=d,s=!1;return d}finally{if(p.settled=!0,i===p)i=null}})(),p.promise.catch(()=>{return}),p},a=(l,p)=>{if(i===l)i=null;if(r?.load===l)r=null;l.controller.abort(p)},c=(l,p)=>{if(p?.aborted)return Promise.reject(Rt(p));return l.waiters+=1,new Promise((d,m)=>{let y=!1,R=()=>{if(y)return!1;return y=!0,l.waiters-=1,p?.removeEventListener(\"abort\",w),!0},w=()=>{if(!R())return;let S=Rt(p);if(m(S),l.waiters===0&&!l.settled)a(l,S)};p?.addEventListener(\"abort\",w,{once:!0}),l.promise.then((S)=>{if(R())d(S)},(S)=>{if(R())m(S)})})},u=()=>{t=null,n+=1,s=!0};return{async load(l={}){if(l.signal?.throwIfAborted(),l.refresh)u();if(t)return t;return await c(o(),l.signal)},async reloadAfterStale(l,p){p?.throwIfAborted();let d=r;if(d?.staleDigest===l&&(d.settled===null?d.load.epoch===n:d.settled===t))return await c(d.load,p);u();let m=o(),y={staleDigest:l,load:m,settled:null};return r=y,m.promise.then((R)=>{if(r!==y)return;if(R.digest===l)r=null;else y.settled=R},()=>{if(r===y)r=null}),await c(m,p)},invalidate(l){if(t?.digest===l)u()}}}function Rt(e){return e.reason??new DOMException(\"The operation was aborted.\",\"AbortError\")}function St(e,t,n){let s=`/v1/workspaces/${encodeURIComponent(t)}/tools`,i,r=()=>i??=n(),o=new Set,a=new Map,c=new Map,u=new Map,l=0,p=(b)=>{if(!u.has(b)&&u.size>=256)u.delete(u.keys().next().value);let h=++l;return u.set(b,h),h},d=new Map,m=(b)=>{let h=me(b),f=a.get(h);if(!f){if(f=ke(async(T,C)=>{let v=await e.requestJson(\"POST\",`${s}/resolve`,{target:b},{},{signal:C});return{...v,digest:v.definitionDigest}}),a.size>=256)a.delete(a.keys().next().value);a.set(h,f)}return f},y=(b,h,f)=>{let T=me(b);if(u.get(T)!==f)return;if(c.size>=256)c.delete(c.keys().next().value);c.set(T,h)},R=async(b,h={})=>{if(h.siteArtifactId||h.siteVersionId)return await e.requestJson(\"POST\",`${s}/resolve`,{target:b,siteArtifactId:h.siteArtifactId,siteVersionId:h.siteVersionId},{},h.signal?{signal:h.signal}:{});let f=me(b),T=p(f);if(h.refresh)c.delete(f);let C=await m(b).load(h);return y(b,C,T),C},w=(b,h={})=>e.requestJson(\"POST\",`${s}/invoke`,b,{},h),S=async(b,h={},f={})=>{if(f.approvalToken&&(f.approvalBinding===\"catalog\"||o.has(f.approvalToken))){if(\"identity\"in b)return await r().$call(b.identity,h,f);let N=r();for(let gs of b.path)N=N[gs];return await N(h,f)}if(f.approvalToken&&!f.operationId)throw TypeError(\"operationId is required when using an approval token\");f.signal?.throwIfAborted();let T=f.operationId??crypto.randomUUID(),C=me(b),v=p(C);if(f.refreshCatalog)c.delete(C);let k=f.refreshCatalog?await m(b).load({refresh:!0,...f.signal?{signal:f.signal}:{}}):c.get(C),q=f.approvalToken?d.get(f.approvalToken):void 0,H=f.expectedDefinitionDigest!==void 0?f.expectedDefinitionDigest:f.approvalToken?void 0:k?.definitionDigest;if(q&&(q.operationId!==T||(\"identity\"in b)&&me({identity:q.tool.entry.identity})!==C))throw new ie(T,q.tool.definitionDigest,H??\"\",q.tool.entry.identity);let Q=(N)=>w({operationId:T,target:b,arguments:h,...N===void 0?{}:{expectedDefinitionDigest:N},...f.approvalToken?{approvalToken:f.approvalToken}:{}},f.signal?{signal:f.signal}:{}),J;try{J=await Q(H)}catch(N){if(!Ps(N)||H===void 0)throw N;if(u.get(C)===v)c.delete(C);if(f.expectedDefinitionDigest!==void 0&&!f.approvalToken)throw N;if(k=await m(b).reloadAfterStale(H,f.signal),y(b,k,v),f.approvalToken||f.expectedDefinitionDigest!==void 0)throw new ie(T,H,k.definitionDigest,k.entry.identity);J=await Q(k.definitionDigest)}if(f.approvalToken)d.delete(f.approvalToken);if(y(b,J.tool,v),J.result.isError)throw new Ie(J.result);return J.tool.entry.outputSchema&&J.result.structuredContent!==void 0?J.result.structuredContent:J.result},I=async(b,h={},f={})=>{let T=await R({identity:b},{...f.signal?{signal:f.signal}:{}}),C=await e.requestJson(\"POST\",`${s}/target-approvals`,{identity:b,arguments:h,operationId:f.operationId??crypto.randomUUID(),expectedDefinitionDigest:f.expectedDefinitionDigest===void 0?T.definitionDigest:f.expectedDefinitionDigest},{},f.signal?{signal:f.signal}:{});if(d.size>=256)d.delete(d.keys().next().value);return d.set(C.approvalToken,C),C},x=(b)=>new Proxy(async(h={},f={})=>S({path:b},h,f),{get:(h,f)=>f===\"then\"||typeof f!==\"string\"?void 0:x([...b,f])});return new Proxy(Object.create(null),{get:(b,h)=>{if(h===\"then\"||typeof h!==\"string\")return;if(h===\"$targetProtocol\")return 1;if(h===\"$resolve\")return R;if(h===\"$invoke\")return w;if(h===\"$manifest\")return(f,T={})=>e.requestJson(\"POST\",`${s}/manifest`,f,{},T);if(h===\"$call\")return(f,T,C)=>S({identity:f},T,C);if(h===\"$approveTarget\")return I;if(h===\"$approve\")return async(...f)=>{let T=await r().$approve(...f);if(o.size>=256)o.delete(o.values().next().value);return o.add(T.approvalToken),T};if(h===\"$catalog\")return r().$catalog;if(h===\"$declarations\")return r().$declarations;return x([h])}})}var me=(e)=>(\"identity\"in e)?JSON.stringify([\"identity\",e.identity.serverId,e.identity.toolName]):JSON.stringify([\"path\",...e.path]),Ps=(e)=>{if(typeof e!==\"object\"||e===null)return!1;if(\"outcomeUnknown\"in e&&e.outcomeUnknown===!0||\"retryable\"in e&&e.retryable===!1)return!1;return e instanceof P?e.status===409&&e.details?.code===\"tool_definition_stale\":typeof e===\"object\"&&e!==null&&(\"code\"in e)&&e.code===\"tool_definition_stale\"};var wt=Z(()=>{V();Ae()});class re{transport;constructor(e){this.transport=e}forWorkspace(e){let t=Os(e,\"workspaceId\");if(this.transport.toolGatewayMode!==\"catalog\")return St(this.transport,t,()=>new re({toolGatewayMode:\"catalog\",requestJson:this.transport.requestJson.bind(this.transport)}).forWorkspace(t));let n=`/v1/workspaces/${encodeURIComponent(t)}/tools/catalog`,s=ke(async(d,m)=>await this.transport.requestJson(\"GET\",n,void 0,{},{signal:m})),i=new Map,r=async(d={})=>await s.load({...d.refresh?{refresh:!0}:{},...d.signal?{signal:d.signal}:{}}),o=async(d,m)=>await s.reloadAfterStale(d,m),a=async(d,m,y)=>{if(y.approvalToken&&!y.operationId)throw TypeError(\"operationId is required when using an approval token\");let R=y.operationId??crypto.randomUUID(),w=await r({...y.refreshCatalog===void 0?{}:{refresh:y.refreshCatalog},...y.signal?{signal:y.signal}:{}}),S=async(b)=>{let h=d(b),f=y.approvalToken?i.get(y.approvalToken):void 0;if(f&&(f.operationId!==R||f.catalogDigest!==b.digest||!xs(f.identity,h)))throw new ie(R,f.catalogDigest,b.digest,h);let T={operationId:R,catalogDigest:b.digest,identity:h,arguments:m,...y.approvalToken?{approvalToken:y.approvalToken}:{}},C;try{C=await this.transport.requestJson(\"POST\",`/v1/workspaces/${encodeURIComponent(t)}/tools/calls`,T,{},y.signal?{signal:y.signal}:{})}catch(k){if(Ce(k))s.invalidate(b.digest);else if(y.approvalToken)i.delete(y.approvalToken);throw k}if(y.approvalToken)i.delete(y.approvalToken);if(C.catalogDigest!==b.digest)s.invalidate(b.digest);if(C.result.isError)throw new Ie(C.result);return kt(b,h)?.outputSchema&&C.result.structuredContent!==void 0?C.result.structuredContent:C.result};try{return await S(w)}catch(b){if(!Ce(b))throw b}let I=await o(w.digest,y.signal),x=d(I);if(y.approvalToken&&I.digest!==w.digest)throw new ie(R,w.digest,I.digest,x);return await S(I)},c=async(d,m={},y={})=>await a((R)=>vt(R,d),m,y),u=async(d,m={},y={})=>{let R=y.operationId??crypto.randomUUID(),w=async(x)=>{let b={operationId:R,catalogDigest:x.digest,identity:vt(x,d),arguments:m};try{let h=await this.transport.requestJson(\"POST\",`/v1/workspaces/${encodeURIComponent(t)}/tools/approvals`,b,{},y.signal?{signal:y.signal}:{});return i.set(h.approvalToken,{operationId:h.operationId,catalogDigest:h.catalogDigest,identity:h.identity}),h}catch(h){if(Ce(h))s.invalidate(x.digest);throw h}},S=await r(y.signal?{signal:y.signal}:{});try{return await w(S)}catch(x){if(!Ce(x))throw x}let I=await o(S.digest,y.signal);return await w(I)},l=async(d,m={},y={})=>await a((R)=>Ts(R,d).identity,m,y),p=(d)=>new Proxy(async(m={},y={})=>await l(d,m,y),{get:(m,y)=>{if(y===\"then\")return;if(typeof y!==\"string\")return;return p([...d,y])}});return new Proxy(Object.create(null),{get:(d,m)=>{if(m===\"then\")return;if(m===\"$catalog\")return r;if(m===\"$call\")return c;if(m===\"$approve\")return u;if(m===\"$declarations\")return async(y={})=>await this.transport.requestJson(\"GET\",`/v1/workspaces/${encodeURIComponent(t)}/tools/declarations`,void 0,{},y.signal?{signal:y.signal}:{});if(typeof m!==\"string\")return;return p([m])}})}}function kt(e,t){return e.entries.find((n)=>n.identity.serverId===t.serverId&&n.identity.toolName===t.toolName)}function xs(e,t){return e.serverId===t.serverId&&e.toolName===t.toolName}function vt(e,t){let n=kt(e,t);if(!n)throw Error(`Tool is not present in the workspace catalog: ${t.serverId}/${t.toolName}`);return n.identity}function Ts(e,t){let n=e.entries.find((s)=>s.codemodePath.length===t.length&&s.codemodePath.every((i,r)=>i===t[r]));if(!n)throw Error(`Tool is not present in the workspace catalog: ${t.join(\".\")}`);return n}function Ce(e){if(typeof e!==\"object\"||e===null||\"outcomeUnknown\"in e&&e.outcomeUnknown===!0||\"retryable\"in e&&e.retryable===!1)return!1;return e instanceof P&&e.status===409&&e.details?.code===\"catalog_stale\"||typeof e===\"object\"&&e!==null&&\"code\"in e&&e.code===\"catalog_stale\"}function Os(e,t){let n=e.trim();if(!n)throw TypeError(`${t} is required`);return n}var Ie,ie;var Ae=Z(()=>{wt();V();Ie=class Ie extends Error{result;code;retryable;outcomeUnknown;constructor(e){let t=e.structuredContent;super(typeof t?.error?.message===\"string\"?t.error.message:\"Tool call failed\");this.result=e;this.name=\"OpenGeniToolCallError\",this.code=typeof t?.error?.code===\"string\"?t.error.code:\"tool_error\",this.retryable=t?.error?.retryable===!0,this.outcomeUnknown=t?.error?.outcomeUnknown===!0}};ie=class ie extends Error{operationId;previousCatalogDigest;catalogDigest;identity;code=\"tool_reapproval_required\";retryable=!1;constructor(e,t,n,s){super(\"The workspace tool catalog changed after approval. Request a new approval for the refreshed tool identity and retry with the same operation ID.\");this.operationId=e;this.previousCatalogDigest=t;this.catalogDigest=n;this.identity=s;this.name=\"OpenGeniToolReapprovalRequiredError\"}}});function bi(e,t){if(e.length<t.length)return!1;let n=e.length-t.length;return t.every((s,i)=>e[n+i]===s)}function Si(e){for(let t of e.matchAll(mi)){let n=t[2]??t[3];if(!n)continue;let s=n.replace(/([a-z0-9])([A-Z])/g,\"$1 $2\").replace(/([A-Z]+)([A-Z][a-z])/g,\"$1 $2\").toLowerCase().split(/[^a-z0-9]+/).filter(Boolean),i=s.at(-1);if(i&&fi.has(i))return!0;if(i&&hi.some((r)=>i.endsWith(r)))return!0;if(Ri.some((r)=>bi(s,r)))return!0}return!1}function wi(e){for(let t of e.matchAll(ci))if(!ui.test(t[0]))return!0;return!1}function vi(e){if(/[?:#]/u.test(e))return!1;let[t,...n]=e.split(\"/\");if(!t||n.length===0||n.some((s)=>!s))return!1;if(!gi.has(t)||n.some((s)=>!/^[A-Z][A-Za-z0-9_-]*$/u.test(s)))return!1;return!0}function ki(e){if(di.some((t)=>t.test(e)))return!0;for(let t of e.matchAll(li)){let n=t[0];if(n.toLowerCase().startsWith(\"www.\"))return!0;if(!/[/?#]/u.test(n))continue;let r=(n.split(/[/?#]/u,1)[0]??\"\").replace(/:\\\\d{1,5}$/u,\"\").split(\".\").at(-1)?.toLowerCase();if(r&&pi.has(r))continue;if(vi(n))continue;return!0}return!1}function Pi(e){return e.normalize(\"NFKC\").replace(Ai,\"\").replace(Ci,\"\")}function xi(e){let t=Pi(e);if(ai.some((n)=>n.test(t)))return!0;if(wi(t))return!0;if(ki(t))return!0;if(yi.test(t))return!0;if(Si(t))return!0;if(Ii.test(t))return!0;return!1}function Ti(e){if(Ge===void 0)Ge=typeof Intl.Segmenter===\"function\"?new Intl.Segmenter(void 0,{granularity:\"grapheme\"}):null;if(Ge)return Array.from(Ge.segment(e),(n)=>n.segment);let t=[];for(let n of e){let s=t.at(-1);if(s&&(/^[\\\\p{Mark}\\\\u{FE0E}\\\\u{FE0F}\\\\p{Emoji_Modifier}]$/u.test(n)||n===\"‍\"||s.endsWith(\"‍\")))t[t.length-1]=`${s}${n}`;else t.push(n)}return t}function qi(e){return e.replace(Oi,`\\n`)}function Ei(e,t){if(e===null||e===void 0)return null;if(t===\"user\")return e;let n=qi(e);if(n===e)return e;return n.split(`\\n`).map((s)=>s.trim()).find(Boolean)??null}function _i(e){let t=e.split(/\\\\s+/u),n=t.length>10?t.slice(0,10).join(\" \"):e,s=Ti(n);if(s.length<=80)return n;let i=s.slice(0,80).join(\"\"),r=i.search(/\\\\s+\\\\S*$/u);return(r>=16?i.slice(0,r):i).trimEnd()}function et(e){if(typeof e!==\"string\")return null;let t=e.slice(0,4096).replace(/[\\\\u0000-\\\\u001f\\\\u007f-\\\\u009f]+/gu,`\\n`).split(/\\\\n+/u);for(let n of t){let s=n.trim();if(!s||xi(s))continue;let i=_i(s.replace(/\\\\s+/gu,\" \")).replace(/[\\\\s.!?,;:\\\\-–—]+$/u,\"\").trim();if(i)return i}return null}function $n(e){let t=typeof e===\"string\"?e.trim():\"\";return oi.test(t)?`Conversation ${t.slice(0,13)}`:\"New conversation\"}function tt(e){let t=e.title?.trim()??\"\";return e.titleSource!==\"user\"&&(!t||t===\"New conversation\")}function Bn(e,t={}){let n=e.title?.trim()??\"\";if(e.titleSource===\"user\")return n||$n(e.id);if(n&&!tt(e)){let s=Ei(n,e.titleSource)?.trim();if(s)return s}for(let s of t.metadataKeys??[]){let i=e.metadata?.[s];if(typeof i===\"string\"&&i.trim().length>0)return i.trim()}return et(e.initialMessage)??$n(e.id)}var oi,Ge,ai,ci,ui,li,di,pi,gi,mi,yi,fi,hi,Ri,Ii,Ai,Ci,Oi;var Ln=Z(()=>{oi=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu,ai=[/-----BEGIN [A-Z ]*PRIVATE KEY-----/iu,/\\\\bBearer\\\\s+[A-Za-z0-9._~+/=-]{8,}/iu,/\\\\b(?:sk-(?:proj-)?|gh[oprsu]_|github_pat_|glpat-|xox[baprs]-)[A-Za-z0-9_-]{8,}/iu,/\\\\bAKIA[0-9A-Z]{16}\\\\b/u,/\\\\bAIza[0-9A-Za-z_-]{20,}\\\\b/u,/\\\\beyJ[A-Za-z0-9_-]+\\\\.eyJ[A-Za-z0-9_-]+\\\\.[A-Za-z0-9_-]+\\\\b/u,/[?&](?:access_token|api_key|apikey|password|secret|token)=[^\\\\s&#]+/iu],ci=/\\\\b[a-z][a-z0-9+.-]*:\\\\S+/giu,ui=/^[a-z]:[\\\\\\\\/](?![\\\\\\\\/])[^:]*$/iu,li=/\\\\b(?:www\\\\.)?(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\\\\.)+[a-z](?:[a-z0-9-]{0,61}[a-z0-9])?(?::\\\\d{1,5})?(?:[/?#][^\\\\s]*)?/giu,di=[/\\\\blocalhost(?:(?::\\\\d{1,5})(?:[/?#][^\\\\s]*)?|[/?#][^\\\\s]*)/iu,/\\\\b(?:(?:25[0-5]|2[0-4]\\\\d|1?\\\\d?\\\\d)\\\\.){3}(?:25[0-5]|2[0-4]\\\\d|1?\\\\d?\\\\d)(?:(?::\\\\d{1,5})(?:[/?#][^\\\\s]*)?|[/?#][^\\\\s]*)/u,/\\\\[(?=[0-9a-f:.]*:[0-9a-f:.]*\\\\])[0-9a-f:.]+\\\\](?:(?::\\\\d{1,5})(?:[/?#][^\\\\s]*)?|[/?#][^\\\\s]*)/iu],pi=new Set([\"css\",\"html\",\"js\",\"json\",\"jsx\",\"lock\",\"md\",\"sql\",\"toml\",\"ts\",\"tsx\",\"xml\",\"yaml\",\"yml\"]),gi=new Set([\"ASP.NET\",\"AWS.SDK\",\"Microsoft.Extensions\",\"System.IO\"]),mi=/(?:^|[^A-Za-z0-9])(?:([\\'\"])([A-Za-z][A-Za-z0-9_. -]*)\\\\1|([A-Za-z][A-Za-z0-9_.-]*))\\\\s*[=:]\\\\s*[^\\\\s,;]+/gu,yi=/\\\\b(?:api[ _-]?key|access[ _-]?token|auth[ _-]?token|credential|credentials|password|passwd|private[ _-]?key|secret|token)\\\\b\\\\s*[=:]\\\\s*[^\\\\s,;]+/iu,fi=new Set([\"credential\",\"credentials\",\"password\",\"passwd\",\"secret\",\"token\"]),hi=[\"apikey\",\"accesskey\",\"accesskeyid\",\"accesstoken\",\"authtoken\",\"credential\",\"credentials\",\"password\",\"passwd\",\"privatekey\",\"secret\",\"secretkey\",\"token\"],Ri=[[\"api\",\"key\"],[\"access\",\"key\"],[\"access\",\"key\",\"id\"],[\"auth\",\"key\"],[\"private\",\"key\"],[\"secret\",\"key\"]];Ii=/\\\\b(?=[A-Za-z0-9_-]{32,}\\\\b)(?=[A-Za-z0-9_-]*[A-Za-z])(?=[A-Za-z0-9_-]*\\\\d)[A-Za-z0-9_-]+\\\\b/u,Ai=/\\\\p{Default_Ignorable_Code_Point}+/gu,Ci=/\\\\\\\\+(?=[\"\\'])/gu;Oi=/<[||][^<>||\\\\s]{1,64}[||]>/gu});function Me(e){let t=e.metadata._opengeniSiteOrigin,n=t&&typeof t.siteId===\"string\"&&/^[\\\\da-f]{8}-[\\\\da-f]{4}-[\\\\da-f]{4}-[\\\\da-f]{4}-[\\\\da-f]{12}$/i.test(t.siteId)&&typeof t.title===\"string\"?{siteId:t.siteId,title:t.title}:null,s=e.metadata.scheduledTaskId;return{id:e.id,workspaceId:e.workspaceId,accountId:e.accountId,status:e.status,backgroundCommandActivity:e.backgroundCommandActivity,hasSchedules:e.hasSchedules,hasUpcomingSchedules:e.hasUpcomingSchedules,title:e.title,titleSource:e.titleSource,displayTitle:Bn(e),renameSeed:tt(e)?et(e.initialMessage)??\"\":e.title?.trim()??\"\",scheduledTaskId:typeof s===\"string\"&&s.length>0?s:null,siteOrigin:n,...e.model?{model:e.model}:{},...e.reasoningEffort?{reasoningEffort:e.reasoningEffort}:{},createdBy:e.createdBy,channelId:e.channelId,parentSessionId:e.parentSessionId,rootSessionId:e.rootSessionId,effectiveControl:e.effectiveControl,inputWait:e.inputWait,lastSequence:e.lastSequence,pinned:e.pinned??!1,pinnedAt:e.pinnedAt??null,pinVersion:e.pinVersion??0,unread:e.unread??!1,activelyWorking:e.activelyWorking??!1,attentionVersion:e.attentionVersion??0,archived:e.archived??!1,archivedAt:e.archivedAt??null,importedArchive:e.importedArchive,...e.retention?{retention:e.retention}:{},archiveVersion:e.archiveVersion??0,treeStats:e.treeStats,requiresActionSince:e.requiresActionSince,...e.admissionBlock!==void 0?{admissionBlock:e.admissionBlock}:{},createdAt:e.createdAt,updatedAt:e.updatedAt}}var Wn=Z(()=>{Ln()});var zn=Z(()=>{Wn()});var ms=Object.freeze([{id:\"config.client\",method:\"GET\",pattern:/^\\\\/v1\\\\/config\\\\/client$/u},{id:\"workspace.get\",method:\"GET\",pattern:/^$/u},{id:\"site.config\",method:\"GET\",pattern:/^\\\\/site\\\\/config$/u},{id:\"models.list\",method:\"GET\",pattern:/^\\\\/model-catalog$/u},{id:\"sessions.list\",method:\"GET\",pattern:/^\\\\/sessions$/u},{id:\"sessions.create\",method:\"POST\",pattern:/^\\\\/sessions$/u,agent:!0},{id:\"sessions.get\",method:\"GET\",pattern:new RegExp(\"^/sessions/[A-Za-z0-9_-]{1,128}$\",\"u\")},{id:\"sessions.events\",method:\"GET\",pattern:new RegExp(\"^/sessions/[A-Za-z0-9_-]{1,128}/events$\",\"u\")},{id:\"sessions.stream\",method:\"GET\",pattern:new RegExp(\"^/sessions/[A-Za-z0-9_-]{1,128}/events/stream$\",\"u\"),stream:!0},{id:\"sessions.send\",method:\"POST\",pattern:new RegExp(\"^/sessions/[A-Za-z0-9_-]{1,128}/events$\",\"u\"),agent:!0},{id:\"sessions.steer\",method:\"POST\",pattern:new RegExp(\"^/sessions/[A-Za-z0-9_-]{1,128}/steer$\",\"u\"),agent:!0},{id:\"sessions.control\",method:\"POST\",pattern:new RegExp(\"^/sessions/[A-Za-z0-9_-]{1,128}/control$\",\"u\"),agent:!0},{id:\"sessions.queue\",method:\"GET\",pattern:new RegExp(\"^/sessions/[A-Za-z0-9_-]{1,128}/queue$\",\"u\")},{id:\"sessions.queue.item\",method:\"POST\",pattern:new RegExp(\"^/sessions/[A-Za-z0-9_-]{1,128}/queue/[A-Za-z0-9_-]{1,128}/(?:move|edit|steer|delete)$\",\"u\"),agent:!0},{id:\"sessions.composerDraft.get\",method:\"GET\",pattern:new RegExp(\"^/sessions/[A-Za-z0-9_-]{1,128}/composer-draft$\",\"u\")},{id:\"sessions.composerDraft.put\",method:\"PUT\",pattern:new RegExp(\"^/sessions/[A-Za-z0-9_-]{1,128}/composer-draft$\",\"u\")},{id:\"sessions.composerDraft.submit\",method:\"POST\",pattern:new RegExp(\"^/sessions/[A-Za-z0-9_-]{1,128}/composer-draft/submit$\",\"u\"),agent:!0},{id:\"sessions.humanInput\",method:\"GET\",pattern:new RegExp(\"^/sessions/[A-Za-z0-9_-]{1,128}/human-input-requests$\",\"u\")},{id:\"sessions.humanInput.get\",method:\"GET\",pattern:new RegExp(\"^/sessions/[A-Za-z0-9_-]{1,128}/human-input-requests/[A-Za-z0-9_-]{1,128}$\",\"u\")},{id:\"data.read\",method:\"GET\",pattern:new RegExp(\"^/published-artifacts/current/(?:data|files)(?:/[A-Za-z0-9._~:@!$&\\'()*+,;=-]+)*$\",\"u\")},{id:\"data.write\",method:\"POST\",pattern:new RegExp(\"^/published-artifacts/current/(?:data|files)(?:/[A-Za-z0-9._~:@!$&\\'()*+,;=-]+)*$\",\"u\")},{id:\"data.put\",method:\"PUT\",pattern:new RegExp(\"^/published-artifacts/current/(?:data|files)(?:/[A-Za-z0-9._~:@!$&\\'()*+,;=-]+)*$\",\"u\")},{id:\"data.patch\",method:\"PATCH\",pattern:new RegExp(\"^/published-artifacts/current/(?:data|files)(?:/[A-Za-z0-9._~:@!$&\\'()*+,;=-]+)*$\",\"u\")},{id:\"data.delete\",method:\"DELETE\",pattern:new RegExp(\"^/published-artifacts/current/(?:data|files)(?:/[A-Za-z0-9._~:@!$&\\'()*+,;=-]+)*$\",\"u\")},{id:\"sql.run\",method:\"POST\",pattern:/^\\\\/published-artifacts\\\\/current\\\\/sql\\\\/queries\\\\/[A-Za-z][A-Za-z0-9_-]{0,63}$/u},{id:\"site.report\",method:\"POST\",pattern:/^\\\\/site\\\\/reports$/u}]),Cr=Object.freeze([\"catalog\",\"declarations\",\"call\",\"resolve\",\"invoke\"]);function ct(e,t){if(/[%\\\\\\\\#\\\\u0000-\\\\u0020\\\\u007f]/u.test(t))return null;if(t.split(\"/\").some((r)=>r===\".\"||r===\"..\"))return null;let n=e.toUpperCase(),s;if(t===\"/v1/config/client\")s=t;else if(t===\"/v1/workspaces/site-host\")s=\"\";else if(t.startsWith(\"/v1/workspaces/site-host/\"))s=t.slice(24);else return null;let i=ms.find((r)=>r.method===n&&r.pattern.test(s));return i?{operation:i,suffix:s}:null}var ys=/^\\\\/v1\\\\/workspaces\\\\/site-host\\\\/published-artifacts\\\\/([^/]+)\\\\/(?:data|files|sql)(?:\\\\/|$)/u,fs=\"00000000-0000-0000-0000-000000000000\";class Se extends Error{code=\"site_session_path_unsupported\";constructor(){super(\"Unsupported Site session API path\");this.name=\"SiteSessionPathError\"}}class lt extends Error{code=\"site_data_unsupported\";constructor(){super(\"This Site host does not provide Site Data\");this.name=\"SiteDataUnsupportedError\"}}function hs(e,t){let n=new URL(e,\"http://site.invalid\");if(n.pathname===\"/v1/config/client\"){let s=n.searchParams.getAll(\"workspaceId\");if(s.length>1||s.length===1&&s[0]!==\"site-host\"&&s[0]!==t)throw new Se;if(t!==\"site-host\")n.searchParams.set(\"workspaceId\",t);return n.pathname+n.search}return e.replace(\"/workspaces/site-host\",`/workspaces/${encodeURIComponent(t)}`)}function Rs(e,t,n,s){if(n===\"site-host\")return e;if(!s)throw new lt;return t.replace(\"/published-artifacts/current/\",`/published-artifacts/${encodeURIComponent(s)}/`)}function de(e,t,n=\"GET\",s){let i=e.split(\"?\")[0],r=ct(n,i);if(!r)throw new Se;let o=hs(e,t);if(ys.test(i))return Rs(e,o,t,s);if(r.operation.id!==\"sessions.list\")return o;let a=new URL(o,\"http://site.invalid\"),c=a.searchParams.getAll(\"originSiteId\"),u=a.searchParams.getAll(\"siteAccessId\"),l=a.searchParams.getAll(\"view\");if(l.length>1||l.length===1&&l[0]!==\"page\"||c.length+u.length!==1||(c[0]??u[0])!==\"current\")throw new Se;if(t===\"site-host\")return e;return a.searchParams.set(u.length?\"siteAccessId\":\"originSiteId\",s??fs),a.pathname+a.search}var ut=[\"text\",\"annotations\",\"model\",\"reasoningEffort\",\"latencyMode\",\"controlEtag\",\"expectedDraftRevision\"],Tr=Object.freeze({\"sessions.send\":[\"type\",\"payload\",\"clientEventId\"],\"sessions.steer\":[...ut,\"clientEventId\"],\"sessions.control\":[\"action\",\"reason\",\"clientEventId\",\"expectedControlEtag\"],\"sessions.composerDraft.put\":[\"text\",\"annotations\",\"resources\",\"model\",\"reasoningEffort\",\"latencyMode\",\"expectedRevision\"],\"sessions.composerDraft.submit\":[...ut,\"resources\",\"connectionAccounts\",\"clientEventId\",\"delivery\"],\"sessions.queue.move\":[\"clientEventId\",\"expectedQueueVersion\",\"beforeTurnId\"],\"sessions.queue.edit\":[\"clientEventId\",\"expectedTurnVersion\",\"expectedDraftRevision\",\"replaceDraft\"],\"sessions.queue.steer\":[\"clientEventId\",\"expectedTurnVersion\",\"controlEtag\"],\"sessions.queue.delete\":[\"clientEventId\",\"expectedTurnVersion\",\"reason\"]});var Or=Object.freeze([\"initialMessage\",\"requestedSessionId\",\"idempotencyKey\",\"clientEventId\",\"model\",\"reasoningEffort\",\"latencyMode\",\"startMode\",\"metadata\"]);var Cs=\"opengeni.site.http\",ge=\"site-host\";async function bt(e,t,n){let s=new Request(t,n),i=new URL(s.url),r=`${i.pathname}${i.search}`;de(r,ge,s.method);let o=new MessageChannel,a=crypto.randomUUID(),c=n?.body instanceof ArrayBuffer||ArrayBuffer.isView(n?.body)||typeof Blob<\"u\"&&n?.body instanceof Blob,u=s.body?c?await s.arrayBuffer():await s.text():void 0;return await new Promise((l,p)=>{let d,m=!1,y=()=>{m=!0,s.signal.removeEventListener(\"abort\",R),o.port1.close()},R=()=>{if(m)return;e.postMessage({type:\"opengeni.site.cancel\",version:2,requestId:a});let w=s.signal.reason??new DOMException(\"Cancelled\",\"AbortError\");d?.error(w),p(w),y()};if(o.port1.onmessage=(w)=>{let S=w.data;if(S.error){let I=Error(S.error);d?.error(I),p(I),y()}else if(S.status){let I=S.body?new ReadableStream({start(x){d=x},pull(){o.port1.postMessage(\"pull\")},cancel(){d=void 0,R()}}):null;if(l(new Response(I,{status:S.status,headers:S.headers})),!S.body)y()}else if(S.done)d?.close(),y();else if(S.chunk)d?.enqueue(S.chunk)},s.signal.aborted){R();return}s.signal.addEventListener(\"abort\",R,{once:!0}),e.postMessage({type:Cs,requestId:a,path:r,method:s.method,headers:[...s.headers],...u===void 0?{}:{body:u}},[o.port2])})}Ae();var It=\"X-OpenGeni-Session-Sequence\",Ke=new WeakMap;function At(e,t){if(t===null||typeof e!==\"object\"||e===null)return;let n=Number(t);if(Number.isSafeInteger(n)&&n>=0)Ke.set(e,n)}function Ct(e,t){if(typeof e!==\"object\"||e===null||typeof t!==\"object\"||t===null)return;let n=Ke.get(e);if(n!==void 0)Ke.set(t,n)}var qs=[\"agent.toolCall.created\",\"agent.toolCall.output\",\"agent.reasoning.delta\",\"sandbox.command.output.delta\",\"terminal.pty.output.delta\"],Es=[\"agent.model.request\",\"agent.model.usage\"],Kr=[...qs,...Es];var Pt=\"X-OpenGeni-Conversation-Filter\";function Pe(e){let t=new URLSearchParams;for(let[s,i]of Object.entries(e)){if(i===void 0)continue;for(let r of Array.isArray(i)?i:[i])t.append(s,String(r))}let n=t.toString();return n?`?${n}`:\"\"}V();var G=encodeURIComponent;function _s(e){let t={};if(e.q)t.q=e.q;if(e.type)t.type=e.type;if(e.includeArchived)t.includeArchived=\"true\";if(e.cursor)t.cursor=e.cursor;if(e.limit)t.limit=String(e.limit);return t}function xt(e,t){let n=`/v1/workspaces/${G(t)}`,s=(a)=>`${n}/vaults/${G(a)}`,i=(a,c)=>`${s(a)}/items/${G(c)}`,r=(a,c,u)=>`${i(a,c)}/fields/${G(u)}`,o=(a,c,u,l,p)=>e.requestJson(a,c,u,l??{},p?{signal:p}:{});return{listVaults:async(a)=>(await o(\"GET\",`${n}/vaults`,void 0,{},a)).vaults,getVault:(a,c)=>o(\"GET\",s(a),void 0,{},c),createVault:(a)=>o(\"POST\",`${n}/vaults`,a),updateVault:(a,c)=>o(\"PATCH\",s(a),c),deleteVault:(a,c)=>e.requestJson(\"DELETE\",s(a),{confirmName:c},{},{responseType:\"void\"}),syncVault:(a)=>o(\"POST\",`${s(a)}/sync`,{}),listItems:(a,c={},u)=>o(\"GET\",`${s(a)}/items`,void 0,_s(c),u),getItem:(a,c,u)=>o(\"GET\",i(a,c),void 0,{},u),createItem:(a,c)=>o(\"POST\",`${s(a)}/items`,c),updateItem:(a,c,u)=>o(\"PATCH\",i(a,c),u),deleteItem:(a,c,u=!1)=>e.requestJson(\"DELETE\",i(a,c),void 0,u?{permanent:\"true\"}:{},{responseType:\"void\"}),restoreItem:(a,c)=>o(\"POST\",`${i(a,c)}/restore`,{}),moveItem:(a,c,u)=>o(\"POST\",`${i(a,c)}/move`,u),revealField:(a,c,u,l)=>o(\"POST\",`${r(a,c,u)}/reveal`,l===void 0?{}:{version:l}),listFieldVersions:async(a,c,u,l)=>(await o(\"GET\",`${r(a,c,u)}/versions`,void 0,{},l)).versions,restoreFieldVersion:(a,c,u,l)=>o(\"POST\",`${r(a,c,u)}/restore`,{version:l}),getSessionSecrets:(a,c)=>o(\"GET\",`${n}/sessions/${G(a)}/secrets`,void 0,{},c),setSessionVaultPolicy:(a,c)=>o(\"PUT\",`${n}/sessions/${G(a)}/vault-policy`,{policy:c}),installOnePassword:(a)=>o(\"POST\",`${n}/connections/1password/install`,a),listOnePasswordConnections:async(a)=>(await o(\"GET\",`${n}/connections/1password/service-accounts`,void 0,{},a)).connections,replaceOnePasswordToken:(a,c)=>o(\"PUT\",`${n}/connections/${G(a)}/1password/token`,c),disconnectOnePassword:(a)=>o(\"DELETE\",`${n}/connections/${G(a)}/1password`),listProviderVaults:async(a,c)=>(await o(\"GET\",`${n}/connections/${G(a)}/provider-vaults`,void 0,{},c)).vaults,installVaultProvider:(a)=>o(\"POST\",`${n}/vault-providers/connections`,a),getVaultProviderCatalog:(a)=>o(\"GET\",`${n}/vault-providers/connections`,void 0,{},a),listVaultProviderConnections:async(a)=>(await o(\"GET\",`${n}/vault-providers/connections`,void 0,{},a)).connections,replaceVaultProviderCredentials:(a,c)=>o(\"PUT\",`${n}/vault-providers/connections/${G(a)}/credentials`,c),disconnectVaultProvider:(a)=>o(\"DELETE\",`${n}/vault-providers/connections/${G(a)}`),verifyVaultProviderConnection:(a)=>o(\"POST\",`${n}/vault-providers/connections/${G(a)}/verify`,{}),linkProviderVault:(a)=>o(\"POST\",`${n}/vaults/link`,a),createManagedProviderVault:(a,c)=>o(\"POST\",`${n}/connections/${G(a)}/managed-vaults`,c)}}V();async function*Y(e){let t=e.getReader(),n=new TextDecoder,s=\"\",i,r,o=null,a=()=>{let u=o===null?null:{...i!==void 0?{id:i}:{},...r!==void 0?{event:r}:{},data:o.join(`\\n`)};return i=void 0,r=void 0,o=null,u},c=(u)=>{if(u===\"\")return a();if(u.startsWith(\":\"))return null;let l=u.indexOf(\":\"),p=l===-1?u:u.slice(0,l),d=l===-1?\"\":u.slice(l+1);if(d.startsWith(\" \"))d=d.slice(1);if(p===\"data\")(o??=[]).push(d);else if(p===\"event\")r=d;else if(p===\"id\")i=d;return null};try{while(!0){let{done:u,value:l}=await t.read();if(u)break;s+=n.decode(l,{stream:!0});let p=s.indexOf(`\\n`);while(p!==-1){let d=s.slice(0,p);if(s=s.slice(p+1),d.endsWith(\"\\\\r\"))d=d.slice(0,-1);let m=c(d);if(m)yield m;p=s.indexOf(`\\n`)}}}finally{t.cancel().catch(()=>{});try{t.releaseLock()}catch{}}}var Ot=Symbol.for(\"@opengeni/sdk/session-event-stream-covered-through\");async function*qt(e,t={}){let n=t.signal,s=t.reconnect??!0,i=t.reconnectDelayMs??500,r=t.maxReconnectDelayMs??1e4,o=t.reconnectJitterRatio??0.2,a=t.beforeLiveTimeoutMs??15000,c=t.heartbeatTimeoutMs??45000,u=t.maxReconnectAttempts??Number.POSITIVE_INFINITY,l=t.after??0,p=0,d=i,m=!1,y=!1;while(!0){if(n?.aborted)break;t.onStateChange?.(m||p>0?\"reconnecting\":\"connecting\");let R=l;try{if(y&&t.beforeReconnect){let S=await Gs(t.beforeReconnect,l,n);if(n?.aborted)return;if(typeof S===\"number\"&&Number.isSafeInteger(S))l=Math.max(l,S);R=l}y=!0;let w=await e.openStream(l,n);m=!0,p=0,d=i;try{t.onOpen?.()}catch{}await ee(t.beforeLive,a,n),t.onStateChange?.(\"live\");for await(let S of Y(te(w,c,n))){if(n?.aborted)return;let I=Us(S.data);if(!I)continue;let x=Ds(S.id,I.sequence);if($s(I,x),x<=l)continue;if(I.sequence>l+1){for await(let b of Ms(e,l,I.sequence-1))if(l=b.sequence,yield b,n?.aborted)return}l=x,yield I}if(!s)return;if(l===R)await Tt(W(i,o),n);continue}catch(w){if(n?.aborted||K(w))return;if(!s||!j(w))throw w;if(p+=1,p>u)throw new L(`event stream gave up after ${u} consecutive failed reconnect attempts: ${w instanceof Error?w.message:String(w)}`)}await Tt(W(d,o),n),d=Math.min(Math.max(d*2,i),r)}}async function ee(e,t,n){if(!e)return;let s,i,r=new Promise((o,a)=>{if(s=setTimeout(()=>a(TypeError(`stream reconciliation timed out after ${t}ms`)),t),n)i=()=>a(new DOMException(\"Aborted\",\"AbortError\")),n.addEventListener(\"abort\",i,{once:!0})});try{await Promise.race([Promise.resolve().then(e),r])}finally{if(s!==void 0)clearTimeout(s);if(n&&i)n.removeEventListener(\"abort\",i)}}async function Gs(e,t,n){if(!n)return await e(t);if(n.aborted)throw new DOMException(\"Aborted\",\"AbortError\");let s,i=new Promise((r,o)=>{s=()=>o(new DOMException(\"Aborted\",\"AbortError\")),n.addEventListener(\"abort\",s,{once:!0})});try{return await Promise.race([Promise.resolve().then(()=>e(t)),i])}finally{if(s)n.removeEventListener(\"abort\",s)}}function W(e,t){if(e<=0||t<=0)return e;let n=Math.min(t,1),s=e*n;return Math.max(0,e-s+Math.random()*s*2)}function te(e,t,n){if(!Number.isSafeInteger(t)||t<=0)throw RangeError(\"stream heartbeat timeout must be a positive safe integer\");let s=e.getReader();return new ReadableStream({pull:async(i)=>{let r,o;try{let a=await Promise.race([s.read(),new Promise((c,u)=>{if(r=setTimeout(()=>u(TypeError(`event stream heartbeat timed out after ${t}ms`)),t),n)o=()=>u(new DOMException(\"Aborted\",\"AbortError\")),n.addEventListener(\"abort\",o,{once:!0})})]);if(a.done)i.close();else i.enqueue(a.value)}catch(a){s.cancel(a).catch(()=>{}),i.error(a)}finally{if(r!==void 0)clearTimeout(r);if(n&&o)n.removeEventListener(\"abort\",o)}},cancel:(i)=>{s.cancel(i).catch(()=>{})}})}async function*Ms(e,t,n){let s=t;while(s<n){let r=(await e.listEvents(s,Math.min(500,n-s))).filter((o)=>o.sequence>s&&o.sequence<=n).sort((o,a)=>o.sequence-a.sequence);if(r.length===0)throw new L(`event replay backfill stalled: expected sequences ${s+1}..${n} but the replay endpoint returned none of them`);for(let o of r){if(o.sequence!==s+1)throw new L(`event replay backfill is missing sequence ${s+1} (replay endpoint skipped to ${o.sequence}); refusing to deliver with a gap`);s=o.sequence,yield o}}}function Us(e){let t;try{t=JSON.parse(e)}catch{return null}if(typeof t!==\"object\"||t===null||typeof t.sequence!==\"number\"||typeof t.type!==\"string\"||typeof t.id!==\"string\")return null;return t}function Et(e){let t=e[Ot];return typeof t===\"number\"&&Number.isSafeInteger(t)&&t>=e.sequence?t:null}function Ds(e,t){if(e===void 0||!/^\\\\d+$/.test(e))return t;let n=Number(e);return Number.isSafeInteger(n)&&n>=t?n:t}function $s(e,t){Object.defineProperty(e,Ot,{value:t,enumerable:!1,configurable:!1,writable:!1})}async function Tt(e,t){if(t?.aborted||e<=0)return;await new Promise((n)=>{let s=setTimeout(i,e);function i(){clearTimeout(s),t?.removeEventListener(\"abort\",i),n()}t?.addEventListener(\"abort\",i,{once:!0})})}var Bs=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}|\\\\d+|[A-Za-z0-9_-]{20,})$/i;function Ls(e){return e.split(\"/\").map((t)=>Bs.test(t)?\":id\":t).join(\"/\")}function Ws(e){let t=e.trim(),n=/^@(-?\\\\d+)$/.exec(t);if(n)return new Date(Number(n[1])*1000);let s=Date.parse(t);return Number.isNaN(s)?null:new Date(s)}function zs(e){let t=new Map;if(!e)return t;for(let n of e.matchAll(/<([^>]*)>\\\\s*((?:;\\\\s*[^;,]+)*)/g)){let s=/;\\\\s*rel=\"?([^\";,]+)\"?/i.exec(n[2]??\"\")?.[1];if(!s)continue;for(let i of s.toLowerCase().split(/\\\\s+/))if(!t.has(i))t.set(i,n[1])}return t}function Ns(e,t,n){let s=n.get(\"deprecation\"),i=n.get(\"sunset\");if(!s&&!i)return null;let r=t;try{r=new URL(t,\"http://opengeni.invalid\").pathname}catch{}let o=i?Date.parse(i):Number.NaN,a=zs(n.get(\"link\"));return{method:e.toUpperCase(),route:Ls(r),path:r,deprecatedAt:s?Ws(s):null,sunset:Number.isNaN(o)?null:new Date(o),link:a.get(\"deprecation\")??a.get(\"sunset\")??null,successor:a.get(\"successor-version\")??null}}var _t=new Set;function Fs(e){let t=`${e.method} ${e.route}`;if(_t.has(t))return;_t.add(t);let n=e.sunset?` and will be removed after ${e.sunset.toISOString()}`:\"\",s=e.link?` Migration notes: ${e.link}.`:\"\";console.warn(`[@opengeni/sdk] ${t} is deprecated${n}.${s} Upgrade @opengeni/sdk, or pass onDeprecation to handle this notice.`)}function Gt(e,t){if(t===!1)return e;let n=t??Fs,s=new Set;return async(i,r)=>{let o=await e(i,r);try{let a=o.headers;if(a&&(a.get(\"deprecation\")||a.get(\"sunset\"))){let c=r?.method??(typeof Request<\"u\"&&i instanceof Request?i.method:\"GET\"),u=typeof i===\"string\"?i:i instanceof URL?i.href:i.url,l=Ns(c,u,a);if(l){let p=`${l.method} ${l.route}`;if(!s.has(p))s.add(p),n(l)}}}catch{}return o}}V();var xe=Object.freeze({maxAttempts:4,initialDelayMs:250,maxDelayMs:2000,maxElapsedMs:5000}),Js=10,Mt=60000;function Te(e,t,n,s){if(typeof e!==\"number\"||!Number.isFinite(e))return t;return Math.min(Math.max(e,n),s)}function Ut(e){if(e===!1)return null;let t=e&&typeof e===\"object\"?e:{},n=Math.floor(Te(t.maxAttempts,xe.maxAttempts,1,Js));if(n<=1)return null;let s=Te(t.maxElapsedMs,xe.maxElapsedMs,0,Mt),i=Te(t.maxDelayMs,xe.maxDelayMs,0,Mt),r=Te(t.initialDelayMs,xe.initialDelayMs,0,i);return{maxAttempts:n,initialDelayMs:r,maxDelayMs:i,maxElapsedMs:s}}function Dt(e){let t=e.toUpperCase();return t===\"GET\"||t===\"HEAD\"}function je(e){return e===502||e===503||e===504}var $t=new WeakSet;function Ye(e){if(e instanceof TypeError)$t.add(e)}var Bt=new WeakSet;function A(e,t){let n=new P(502,e,t);return Bt.add(n),n}var Vs=/failed to fetch|fetch failed|networkerror|network error|load failed|network request failed|network connection was lost|terminated|err_http2|econnreset|socket hang up/iu;function Lt(e){if(e instanceof P)return!Bt.has(e)&&je(e.status)&&e.retryable;if(!(e instanceof TypeError))return!1;return $t.has(e)||Vs.test(e.message)}function Wt(e,t=Date.now()){if(e===null||e===void 0)return null;let n=e.trim();if(!n)return null;if(/^\\\\d+$/.test(n)){let i=Number(n);return Number.isSafeInteger(i)?i*1000:null}if(!/[A-Za-z]/.test(n))return null;let s=Date.parse(n);if(!Number.isFinite(s))return null;return Math.max(0,s-t)}function zt(e,t,n,s,i=Math.random){if(t>=e.maxAttempts)return null;let r;if(s!==null)r=s*(1+0.2*Math.min(Math.max(i(),0),1));else{let o=Math.min(e.maxDelayMs,e.initialDelayMs*2**(t-1));r=o/2+o/2*Math.min(Math.max(i(),0),1)}if(n+r>e.maxElapsedMs)return null;return Math.round(r)}function Nt(e,t){if(t?.aborted)return Promise.reject(t.reason??new DOMException(\"Request aborted\",\"AbortError\"));return new Promise((n,s)=>{let i=()=>{clearTimeout(r),s(t?.reason??new DOMException(\"Request aborted\",\"AbortError\"))},r=setTimeout(()=>{t?.removeEventListener(\"abort\",i),n()},e);t?.addEventListener(\"abort\",i,{once:!0})})}V();async function*Jt(e,t={}){let n=t.signal,s=t.reconnect??!0,i=t.reconnectDelayMs??500,r=t.maxReconnectDelayMs??1e4,o=t.reconnectJitterRatio??0.2,a=t.beforeLiveTimeoutMs??15000,c=t.heartbeatTimeoutMs??45000,u=t.maxReconnectAttempts??Number.POSITIVE_INFINITY,l=t.after??0,p=0,d=i,m=!1;for(;;){if(n?.aborted)return;t.onStateChange?.(m||p>0?\"reconnecting\":\"connecting\");let y=l;try{let R=await e.openStream(l,n);m=!0,p=0,d=i,await ee(t.beforeLive,a,n),t.onStateChange?.(\"live\");for await(let w of Y(te(R,c,n))){if(n?.aborted)return;let S=Hs(w.data);if(!S||S.sequence<=l)continue;l=S.sequence,yield S}if(!s)return;if(l===y)await Ft(W(i,o),n);continue}catch(R){if(n?.aborted||K(R))return;if(!s||!j(R))throw R;if(p+=1,p>u)throw new L(`workspace control stream gave up after ${u} reconnect attempts: ${R instanceof Error?R.message:String(R)}`)}await Ft(W(d,o),n),d=Math.min(Math.max(d*2,i),r)}}function Hs(e){let t;try{t=JSON.parse(e)}catch{return null}if(typeof t!==\"object\"||t===null||t.type!==\"workspace.control.changed\"||typeof t.id!==\"string\"||typeof t.sequence!==\"number\")return null;return t}async function Ft(e,t){if(t?.aborted||e<=0)return;await new Promise((n)=>{let s=setTimeout(i,e);function i(){clearTimeout(s),t?.removeEventListener(\"abort\",i),n()}t?.addEventListener(\"abort\",i,{once:!0})})}V();async function*Ht(e,t={}){let n=t.signal,s=t.reconnect??!0,i=t.reconnectDelayMs??500,r=t.maxReconnectDelayMs??1e4,o=t.reconnectJitterRatio??0.2,a=t.beforeLiveTimeoutMs??15000,c=t.heartbeatTimeoutMs??45000,u=t.maxReconnectAttempts??Number.POSITIVE_INFINITY,l=t.after??0,p=0,d=i,m=!1;for(;;){if(n?.aborted)return;t.onStateChange?.(m||p>0?\"reconnecting\":\"connecting\");let y=l;try{let R=await e.openStream(l,n);m=!0,p=0,d=i,await ee(t.beforeLive,a,n),t.onStateChange?.(\"live\");for await(let w of Y(te(R,c,n))){if(n?.aborted)return;let S=Ks(w.data);if(!S||S.sequence<=l)continue;l=S.sequence,yield S}if(!s)return;if(l===y)await Vt(W(i,o),n);continue}catch(R){if(n?.aborted||K(R))return;if(!s||!j(R))throw R;if(p+=1,p>u)throw new L(`workspace interaction stream gave up after ${u} reconnect attempts: ${R instanceof Error?R.message:String(R)}`)}await Vt(W(d,o),n),d=Math.min(Math.max(d*2,i),r)}}function Ks(e){let t;try{t=JSON.parse(e)}catch{return null}if(!js(t)||t.type!==\"workspace.interaction.changed\"||typeof t.workspaceId!==\"string\"||typeof t.sequence!==\"number\"||!Number.isSafeInteger(t.sequence)||t.sequence<0||t.revision!==t.sequence||typeof t.occurredAt!==\"string\")return null;return t}function js(e){return typeof e===\"object\"&&e!==null&&!Array.isArray(e)}async function Vt(e,t){if(t?.aborted||e<=0)return;await new Promise((n)=>{let s=setTimeout(i,e);function i(){clearTimeout(s),t?.removeEventListener(\"abort\",i),n()}t?.addEventListener(\"abort\",i,{once:!0})})}V();async function*jt(e,t={}){let n=t.signal,s=t.reconnect??!0,i=t.reconnectDelayMs??500,r=t.maxReconnectDelayMs??1e4,o=t.reconnectJitterRatio??0.2,a=t.beforeLiveTimeoutMs??15000,c=t.heartbeatTimeoutMs??45000,u=t.maxReconnectAttempts??Number.POSITIVE_INFINITY,l=t.controlAfter??0,p=t.interactionAfter??0,d=0,m=i,y=!1;for(;;){if(n?.aborted)return;t.onStateChange?.(y||d>0?\"reconnecting\":\"connecting\");let R=`${l}:${p}`;try{let w=await e.openStream(l,p,n);y=!0,d=0,m=i,await ee(t.beforeLive,a,n),t.onStateChange?.(\"live\");for await(let S of Y(te(w,c,n))){if(n?.aborted)return;let I=Ys(S.data);if(!I)continue;if(I.type===\"workspace.control.changed\"){if(I.sequence<=l)continue;l=I.sequence}else if(I.type===\"workspace.interaction.changed\"){if(I.sequence<=p)continue;p=I.sequence}yield I}if(!s)return;if(`${l}:${p}`===R)await Kt(W(i,o),n);continue}catch(w){if(n?.aborted||K(w))return;if(!s||!j(w))throw w;if(d+=1,d>u)throw new L(`workspace live stream gave up after ${u} reconnect attempts: ${w instanceof Error?w.message:String(w)}`)}await Kt(W(m,o),n),m=Math.min(Math.max(m*2,i),r)}}function Ys(e){let t;try{t=JSON.parse(e)}catch{return null}if(!Xs(t))return null;if(t.type===\"workspace.sessions.changed\"&&typeof t.workspaceId===\"string\"&&typeof t.available===\"boolean\"&&(t.sessionIds===null||Array.isArray(t.sessionIds)&&t.sessionIds.every((n)=>typeof n===\"string\"))){let{siteSessionIds:n,...s}=t;return Array.isArray(n)&&n.every((i)=>typeof i===\"string\")?{...s,siteSessionIds:n}:s}if(typeof t.sequence!==\"number\")return null;if(t.type===\"workspace.control.changed\"&&typeof t.id===\"string\"&&Number.isSafeInteger(t.sequence))return t;if(t.type===\"workspace.interaction.changed\"&&typeof t.workspaceId===\"string\"&&Number.isSafeInteger(t.sequence)&&t.sequence>=0&&t.revision===t.sequence&&typeof t.occurredAt===\"string\")return t;return null}function Xs(e){return typeof e===\"object\"&&e!==null&&!Array.isArray(e)}async function Kt(e,t){if(t?.aborted||e<=0)return;await new Promise((n)=>{let s=setTimeout(i,e);function i(){clearTimeout(s),t?.removeEventListener(\"abort\",i),n()}t?.addEventListener(\"abort\",i,{once:!0})})}function Yt(e){return e.driverId===\"opengeni.cdp.ephemeral-context.v1\"?\"ephemeral_context\":\"private_profile\"}var Xt=32768,Qs=1e8;class Xe{attachedBrowsers;authRuns;browsers;computers;identities;interventions;networkRoutes;siteAuthConnections;constructor(e){this.attachedBrowsers=new un(e),this.authRuns=new rn(e),this.browsers=new gn(e),this.computers=new bn(e),this.identities=new dn(e),this.interventions=new an(e),this.networkRoutes=new en(e),this.siteAuthConnections=new nn(e)}}class en{transport;constructor(e){this.transport=e}async list(e,t={}){return await this.transport.listNetworkRoutes(e,t)}route(e,t){return new tn(this.transport,e,t)}async create(e,t,n={}){let s=await this.transport.createNetworkRoute(e,t,n);return this.route(e,s.route.id)}}class tn{transport;workspaceId;id;constructor(e,t,n){this.transport=e;this.workspaceId=t;this.id=n}async get(e={}){return await this.transport.getNetworkRoute(this.workspaceId,this.id,e)}async update(e,t={}){return await this.transport.updateNetworkRoute(this.workspaceId,this.id,e,t)}}class nn{transport;constructor(e){this.transport=e}async list(e,t={}){return await this.transport.listSiteAuthConnections(e,t)}connection(e,t){return new sn(this.transport,e,t)}async create(e,t,n={}){let s=await this.transport.createSiteAuthConnection(e,t,n);return this.connection(e,s.connection.id)}}class sn{transport;workspaceId;id;constructor(e,t,n){this.transport=e;this.workspaceId=t;this.id=n}async get(e={}){return await this.transport.getSiteAuthConnection(this.workspaceId,this.id,e)}async update(e,t={}){return await this.transport.updateSiteAuthConnection(this.workspaceId,this.id,e,t)}}class rn{transport;constructor(e){this.transport=e}async list(e,t={}){return await this.transport.listAuthRuns(e,t)}async get(e,t,n={}){return await this.transport.getAuthRun(e,t,n)}run(e,t,n){return new Qe(this.transport,e,t,n)}}class on{transport;workspaceId;browserSessionId;constructor(e,t,n){this.transport=e;this.workspaceId=t;this.browserSessionId=n}async list(e={}){return await this.transport.listAuthRuns(this.workspaceId,{...e,browserSessionId:this.browserSessionId})}run(e){return new Qe(this.transport,this.workspaceId,this.browserSessionId,e)}async start(e,t={}){let n=await this.transport.startBrowserAuthRun(this.workspaceId,this.browserSessionId,e,t);return this.run(n.run.id)}}class Qe{transport;workspaceId;browserSessionId;id;constructor(e,t,n,s){this.transport=e;this.workspaceId=t;this.browserSessionId=n;this.id=s}async get(e={}){let t=await this.transport.getAuthRun(this.workspaceId,this.id,e);if(t.browserSessionId!==this.browserSessionId)throw Error(\"AuthRun belongs to another BrowserSession\");return t}async report(e,t={}){return await this.transport.reportBrowserAuthRun(this.workspaceId,this.browserSessionId,this.id,e,t)}async advanceExternal(e,t={}){return await this.transport.advanceExternalBrowserAuthRun(this.workspaceId,this.browserSessionId,this.id,e,t)}async openExternalFlow(e,t={}){return await this.transport.openExternalBrowserAuthFlow(this.workspaceId,this.browserSessionId,this.id,e,t)}async verify(e,t={}){return await this.transport.verifyBrowserAuthRun(this.workspaceId,this.browserSessionId,this.id,e,t)}}class an{transport;constructor(e){this.transport=e}async list(e,t={}){return await this.transport.listInteractionInterventions(e,t)}intervention(e,t){return new cn(this.transport,e,t)}async create(e,t,n={}){let s=await this.transport.createInteractionIntervention(e,t,n);return this.intervention(e,s.intervention.id)}}class cn{transport;workspaceId;id;constructor(e,t,n){this.transport=e;this.workspaceId=t;this.id=n}async get(e={}){return await this.transport.getInteractionIntervention(this.workspaceId,this.id,e)}async resolve(e,t={}){return await this.transport.resolveInteractionIntervention(this.workspaceId,this.id,e,t)}}class un{transport;constructor(e){this.transport=e}async list(e,t={}){return await this.transport.listAttachedBrowsers(e,t)}device(e,t){return new ln(this.transport,e,t)}}class ln{transport;workspaceId;id;constructor(e,t,n){this.transport=e;this.workspaceId=t;this.id=n}async get(e={}){return await this.transport.getAttachedBrowser(this.workspaceId,this.id,e)}}class dn{transport;constructor(e){this.transport=e}async list(e,t={}){return await this.transport.listBrowserIdentities(e,t)}identity(e,t){return new pn(this.transport,e,t)}async create(e,t,n={}){let s=await this.transport.createBrowserIdentity(e,t,n);return this.identity(e,s.identity.id)}}class pn{transport;workspaceId;id;constructor(e,t,n){this.transport=e;this.workspaceId=t;this.id=n}async get(e={}){return await this.transport.getBrowserIdentity(this.workspaceId,this.id,e)}async revisions(e={}){return await this.transport.listBrowserRevisions(this.workspaceId,this.id,e)}async update(e,t={}){return await this.transport.updateBrowserIdentity(this.workspaceId,this.id,e,t)}}class gn{transport;constructor(e){this.transport=e}async list(e,t={}){return await this.transport.listBrowserSessions(e,t)}session(e,t){return new mn(this.transport,e,t)}async open(e,t,n={}){let s=await this.transport.createBrowserSession(e,t,n);return this.session(e,s.session.id)}async currentOrOpen(e){let t=e.signal?{signal:e.signal}:{},n=await this.list(e.workspaceId,t),s=ei(n.sessions.filter((i)=>Yt(i)===(e.storageMode??\"private_profile\")),e.associationSessionId);if(s){let i=this.session(e.workspaceId,s.id);if(s.lifecycle===\"suspended\")await i.resume({operationId:e.operationId??crypto.randomUUID()},t);return i}return await this.open(e.workspaceId,{operationId:e.operationId??crypto.randomUUID(),sessionId:e.associationSessionId,...e.name!==void 0?{name:e.name}:{},...e.initialUrl!==void 0?{initialUrl:e.initialUrl}:{},...e.headless!==void 0?{headless:e.headless}:{},...e.storageMode!==void 0?{storageMode:e.storageMode}:{},...e.placement!==void 0?{placement:e.placement}:{},...e.identityId!==void 0?{identityId:e.identityId}:{},...e.baseRevisionId!==void 0?{baseRevisionId:e.baseRevisionId}:{},...e.networkRouteId!==void 0?{networkRouteId:e.networkRouteId}:{},...e.linkedComputerSessionId!==void 0?{linkedComputerSessionId:e.linkedComputerSessionId}:{}},t)}}class mn{transport;workspaceId;id;auth;clipboard;downloads;tabs;targets;constructor(e,t,n){this.transport=e;this.workspaceId=t;this.id=n;this.auth=new on(e,t,n),this.clipboard=new yn(e,t,n),this.downloads=new fn(e,t,n),this.tabs=new Rn(e,t,n),this.targets=this.tabs}async get(e={}){return await this.transport.getBrowserSession(this.workspaceId,this.id,e)}async observe(e,t={}){return await this.transport.observeBrowserTarget(this.workspaceId,this.id,e,t)}async targetState(e,t={}){return await this.transport.getBrowserTargetState(this.workspaceId,this.id,e,t)}async readDom(e,t,n={}){return await this.transport.readBrowserDom(this.workspaceId,this.id,e,t,n)}async capture(e,t={},n={}){return await this.transport.captureBrowserTarget(this.workspaceId,this.id,e,t,n)}async screenshot(e,t={},n={}){return await this.capture(e,n,t)}async act(e,t={}){return await this.transport.actInBrowser(this.workspaceId,this.id,e,t)}async receipt(e,t={}){return await this.transport.getBrowserActionReceipt(this.workspaceId,this.id,e,t)}async diagnostics(e,t={}){return await this.transport.listBrowserDiagnostics(this.workspaceId,this.id,e,t)}async attach(e,t={}){return await this.transport.attachBrowserSession(this.workspaceId,this.id,e,t)}async heartbeat(e={}){return await this.transport.heartbeatBrowserSession(this.workspaceId,this.id,e)}async publishRevision(e,t={}){return await this.transport.publishBrowserRevision(this.workspaceId,this.id,e,t)}async suspend(e={operationId:crypto.randomUUID()},t={}){return await this.transport.suspendBrowserSession(this.workspaceId,this.id,e,t)}async resume(e={operationId:crypto.randomUUID()},t={}){return await this.transport.resumeBrowserSession(this.workspaceId,this.id,e,t)}async end(e={operationId:crypto.randomUUID()},t={}){return await this.transport.endBrowserSession(this.workspaceId,this.id,e,t)}}class yn{transport;workspaceId;browserSessionId;constructor(e,t,n){this.transport=e;this.workspaceId=t;this.browserSessionId=n}async read(e={}){let t=await this.transport.readBrowserClipboard(this.workspaceId,this.browserSessionId,e);if(t.browserSessionId!==this.browserSessionId)throw Error(\"Browser clipboard belongs to another BrowserSession\");return t}}class fn{transport;workspaceId;browserSessionId;constructor(e,t,n){this.transport=e;this.workspaceId=t;this.browserSessionId=n}async list(e={}){return await this.transport.listBrowserDownloads(this.workspaceId,this.browserSessionId,e)}download(e){return new hn(this.transport,this.workspaceId,this.browserSessionId,e)}}class hn{transport;workspaceId;browserSessionId;id;constructor(e,t,n,s){this.transport=e;this.workspaceId=t;this.browserSessionId=n;this.id=s}async get(e={}){let t=await this.transport.getBrowserDownload(this.workspaceId,this.browserSessionId,this.id,e);if(t.browserSessionId!==this.browserSessionId)throw Error(\"BrowserDownload belongs to another BrowserSession\");return t}async saveToWorkspace(e,t={}){let{operationId:n=crypto.randomUUID(),overwrite:s=!1,...i}=t,r=await this.transport.saveBrowserDownload(this.workspaceId,this.browserSessionId,this.id,{operationId:n,destinationPath:e,overwrite:s},i);if(r.download.id!==this.id||r.download.browserSessionId!==this.browserSessionId)throw Error(\"BrowserDownload save returned another resource\");return r}}class Rn{transport;workspaceId;browserSessionId;constructor(e,t,n){this.transport=e;this.workspaceId=t;this.browserSessionId=n}async list(e={}){return await this.transport.listBrowserTargets(this.workspaceId,this.browserSessionId,e)}async open(e,t={}){return await this.transport.openBrowserTarget(this.workspaceId,this.browserSessionId,e===void 0?{}:{url:e},t)}async select(e,t={}){return await this.transport.selectBrowserTarget(this.workspaceId,this.browserSessionId,e,t)}async close(e,t={}){return await this.transport.closeBrowserTarget(this.workspaceId,this.browserSessionId,e,t)}}class bn{transport;constructor(e){this.transport=e}async list(e,t={}){return await this.transport.listComputerSessions(e,t)}session(e,t){return new Sn(this.transport,e,t)}async open(e,t,n={}){let s=await this.transport.createComputerSession(e,t,n);return this.session(e,s.session.id)}async currentOrOpen(e){let t=e.signal?{signal:e.signal}:{},n=await this.list(e.workspaceId,t),s=ti(n.sessions,e.associationSessionId);if(s)return this.session(e.workspaceId,s.id);return await this.open(e.workspaceId,{operationId:e.operationId??crypto.randomUUID(),sessionId:e.associationSessionId,...e.name!==void 0?{name:e.name}:{},...e.placement!==void 0?{placement:e.placement}:{}},t)}}class Sn{transport;workspaceId;id;targets;apps;clipboard;constructor(e,t,n){this.transport=e;this.workspaceId=t;this.id=n;this.targets=new vn(e,t,n),this.apps=this.targets,this.clipboard=new wn(e,t,n)}async get(e={}){return await this.transport.getComputerSession(this.workspaceId,this.id,e)}async observe(e,t={}){return await this.transport.observeComputerTarget(this.workspaceId,this.id,e,t)}async capture(e,t={}){return await this.transport.captureComputerTarget(this.workspaceId,this.id,e,t)}async callNativeTool(e,t={}){if(!this.transport.callNativeComputerTool)throw Error(\"Native CUA tools require a current interaction transport\");return await this.transport.callNativeComputerTool(this.workspaceId,this.id,e,t)}async act(e,t={}){return await this.transport.actInComputer(this.workspaceId,this.id,e,t)}async nativeReceipt(e,t={}){if(!this.transport.getNativeComputerToolReceipt)throw Error(\"Native CUA receipts require a current interaction transport\");return await this.transport.getNativeComputerToolReceipt(this.workspaceId,this.id,e,t)}async receipt(e,t={}){return await this.transport.getComputerActionReceipt(this.workspaceId,this.id,e,t)}async attach(e,t={}){return await this.transport.attachComputerSession(this.workspaceId,this.id,e,t)}async inputPosture(e={}){if(!this.transport.getComputerInputPosture)throw Error(\"Computer input posture requires a current interaction transport.\");return await this.transport.getComputerInputPosture(this.workspaceId,this.id,e)}async heartbeat(e={}){return await this.transport.heartbeatComputerSession(this.workspaceId,this.id,e)}async end(e={operationId:crypto.randomUUID()},t={}){return await this.transport.endComputerSession(this.workspaceId,this.id,e,t)}}class wn{transport;workspaceId;computerSessionId;constructor(e,t,n){this.transport=e;this.workspaceId=t;this.computerSessionId=n}async read(e={}){let t=await this.transport.readComputerClipboard(this.workspaceId,this.computerSessionId,e);if(t.computerSessionId!==this.computerSessionId)throw Error(\"Computer clipboard belongs to another ComputerSession\");return t}}class vn{transport;workspaceId;computerSessionId;constructor(e,t,n){this.transport=e;this.workspaceId=t;this.computerSessionId=n}async list(e={}){return await this.transport.listComputerTargets(this.workspaceId,this.computerSessionId,e)}}function kn(e){if(!xn(e))throw Error(\"browser frame metadata is invalid\");let t=new Set([\"frameId\",\"browserSessionId\",\"controllerGeneration\",\"targetId\",\"targetGeneration\",\"documentGeneration\",\"sequence\",\"mediaType\",\"width\",\"height\",\"deviceScaleFactor\",\"scrollX\",\"scrollY\",\"capturedAt\"]);if(Object.keys(e).some((r)=>!t.has(r)))throw Error(\"browser frame metadata contains unknown fields\");let n=[\"frameId\",\"browserSessionId\",\"controllerGeneration\",\"targetId\",\"targetGeneration\",\"documentGeneration\",\"mediaType\",\"capturedAt\"];for(let r of n){let o=e[r],a=r===\"targetId\"?512:r===\"capturedAt\"?128:256;if(typeof o!==\"string\"||o.length<1||Cn(o)>a)throw Error(\"browser frame metadata is invalid\")}let s=[\"sequence\",\"width\",\"height\",\"deviceScaleFactor\",\"scrollX\",\"scrollY\"];for(let r of s)if(typeof e[r]!==\"number\"||!Number.isFinite(e[r]))throw Error(\"browser frame metadata is invalid\");let i=e;if(!Number.isSafeInteger(i.sequence)||i.sequence<0||!Number.isSafeInteger(i.width)||!Number.isSafeInteger(i.height))throw Error(\"browser frame metadata integers are invalid\");if(An(i.width,i.height),i.deviceScaleFactor<=0||i.deviceScaleFactor>16||Math.abs(i.scrollX)>1e9||Math.abs(i.scrollY)>1e9)throw Error(\"browser frame geometry metadata is invalid\");if(i.mediaType!==\"image/jpeg\"&&i.mediaType!==\"image/png\")throw Error(\"browser frame media type is invalid\");if(!Pn(i.browserSessionId))throw Error(\"browser frame session id is invalid\");if(!/^[A-Za-z0-9][A-Za-z0-9._:-]*$/u.test(i.controllerGeneration))throw Error(\"browser frame controller generation is invalid\");if(!Number.isFinite(new Date(i.capturedAt).valueOf()))throw Error(\"browser frame timestamp is invalid\");return i}function Zs(e){if(!xn(e))throw Error(\"computer frame metadata is invalid\");let t=new Set([\"frameId\",\"computerSessionId\",\"controllerGeneration\",\"targetId\",\"targetGeneration\",\"sequence\",\"mediaType\",\"width\",\"height\",\"capturedAt\",\"sha256\"]);if(Object.keys(e).some((i)=>!t.has(i)))throw Error(\"computer frame metadata contains unknown fields\");let n=[\"frameId\",\"computerSessionId\",\"controllerGeneration\",\"targetId\",\"targetGeneration\",\"mediaType\",\"capturedAt\",\"sha256\"];for(let i of n){let r=e[i],o=i===\"targetId\"?512:i===\"capturedAt\"?128:256;if(typeof r!==\"string\"||r.length<1||Cn(r)>o)throw Error(\"computer frame metadata is invalid\")}let s=e;if(!Number.isSafeInteger(s.sequence)||s.sequence<0||!Number.isSafeInteger(s.width)||!Number.isSafeInteger(s.height))throw Error(\"computer frame metadata integers are invalid\");if(An(s.width,s.height),s.mediaType!==\"image/jpeg\"&&s.mediaType!==\"image/png\")throw Error(\"computer frame media type is invalid\");if(!Pn(s.computerSessionId))throw Error(\"computer frame session id is invalid\");if(!/^[A-Za-z0-9][A-Za-z0-9._:-]*$/u.test(s.controllerGeneration))throw Error(\"computer frame controller generation is invalid\");if(!Number.isFinite(new Date(s.capturedAt).valueOf()))throw Error(\"computer frame timestamp is invalid\");if(!/^[0-9a-f]{64}$/u.test(s.sha256))throw Error(\"computer frame digest is invalid\");return s}function In(e){if(!e||e.length>32768||!/^[A-Za-z0-9_-]+$/u.test(e))throw Error(\"computer frame metadata header is invalid\");let t=e.replace(/-/gu,\"+\").replace(/_/gu,\"/\"),n=t.padEnd(Math.ceil(t.length/4)*4,\"=\"),s;try{s=atob(n)}catch{throw Error(\"computer frame metadata header is invalid\")}let i=Uint8Array.from(s,(o)=>o.charCodeAt(0)),r;try{r=JSON.parse(new TextDecoder(\"utf-8\",{fatal:!0}).decode(i))}catch{throw Error(\"computer frame metadata header is invalid\")}return Zs(r)}function ei(e,t){let n=e.filter((s)=>![\"ending\",\"ended\",\"failed\",\"lost\"].includes(s.lifecycle)&&s.associations.some((i)=>i.sessionId===t));return n.sort((s,i)=>Qt(i,t)-Qt(s,t)),n[0]??null}function ti(e,t){let n=e.filter((s)=>[\"starting\",\"active\",\"restoring\"].includes(s.lifecycle)&&s.associations.some((i)=>i.sessionId===t));return n.sort((s,i)=>Zt(i,t)-Zt(s,t)),n[0]??null}function Qt(e,t){let n=e.associations.filter((i)=>i.sessionId===t).map((i)=>Date.parse(i.lastUsedAt)).filter(Number.isFinite).reduce((i,r)=>Math.max(i,r),0),s=Date.parse(e.lastUsedAt);return Math.max(n,Number.isFinite(s)?s:0)}function Zt(e,t){let n=e.associations.filter((i)=>i.sessionId===t).map((i)=>Date.parse(i.lastUsedAt)).filter(Number.isFinite).reduce((i,r)=>Math.max(i,r),0),s=Date.parse(e.lastUsedAt);return Math.max(n,Number.isFinite(s)?s:0)}function An(e,t){if(!Number.isSafeInteger(e)||!Number.isSafeInteger(t)||e<1||t<1||e>Xt||t>Xt||e*t>Qs)throw Error(\"browser image dimensions exceed their bounded envelope\")}function Cn(e){return new TextEncoder().encode(e).byteLength}function Pn(e){return/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu.test(e)}function xn(e){return typeof e===\"object\"&&e!==null&&!Array.isArray(e)}var oe=\"2026-09-plugins-and-skills-v1\",Ze=\"x-opengeni-api-contract\",Oe=\"x-opengeni-correlation-id\";var qe=1048576,Tn=33554432;var On=536870912;var _e=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/,qn=/^[0-9a-f]{64}$/,En=/^\\\\d{4}-\\\\d{2}-\\\\d{2}T\\\\d{2}:\\\\d{2}:\\\\d{2}(?:\\\\.\\\\d+)?(?:Z|[+-]\\\\d{2}:\\\\d{2})$/,_n=/^\\\\/v1\\\\/workspaces\\\\/([0-9a-f-]+)\\\\/artifacts\\\\/([0-9a-f-]+)\\\\/content$/;function Gn(e,t){if(!ne(e,si))return null;let n=e;if(n.available!==!0||n.kind!==\"file\"||typeof n.artifactId!==\"string\"||!_e.test(n.artifactId)||typeof n.contentType!==\"string\"||!/^[a-z0-9][a-z0-9!#$&^_.+-]{0,62}\\\\/[a-z0-9][a-z0-9!#$&^_.+-]{0,62}$/.test(n.contentType)||!Ee(n.originalBytes,1,5000000000)||typeof n.sha256!==\"string\"||!qn.test(n.sha256)||typeof n.retainedAt!==\"string\"||n.retainedAt.length>64||!En.test(n.retainedAt)||!Number.isFinite(Date.parse(n.retainedAt))||!ne(n.retention,Un)||!ne(n.retrieval,Dn))return null;let s=n.retention;if(s.policy!==\"workspace_file\"||s.expiresAt!==null)return null;let i=n.retrieval;if(i.method!==\"GET\"||i.acceptRanges!==\"bytes\"||i.maxRangeBytes!==1048576||typeof i.path!==\"string\"||i.path.length>256)return null;let r=_n.exec(i.path);if(!r||!_e.test(r[1]??\"\")||r[2]!==n.artifactId||t!==void 0&&r[1]!==t)return null;return e}function Mn(e,t){if(!ne(e,ni))return null;let n=e;if(n.available!==!0||n.kind!==\"generated_image\"||typeof n.artifactId!==\"string\"||!_e.test(n.artifactId)||![\"image/png\",\"image/jpeg\",\"image/webp\"].includes(String(n.contentType))||!Ee(n.originalBytes,1,67108864)||typeof n.sha256!==\"string\"||!qn.test(n.sha256)||typeof n.retainedAt!==\"string\"||n.retainedAt.length>64||!En.test(n.retainedAt)||!Number.isFinite(Date.parse(n.retainedAt))||!ne(n.dimensions,ii)||!ne(n.retention,Un)||!ne(n.retrieval,Dn))return null;let s=n.dimensions;if(!Ee(s.width,1,16384)||!Ee(s.height,1,16384)||Number(s.width)*Number(s.height)>67108864)return null;let i=n.retention;if(i.policy!==\"workspace_file\"||i.expiresAt!==null)return null;let r=n.retrieval;if(r.method!==\"GET\"||r.acceptRanges!==\"bytes\"||r.maxRangeBytes!==1048576||typeof r.path!==\"string\"||r.path.length>256)return null;let o=_n.exec(r.path);if(!o||!_e.test(o[1]??\"\")||o[2]!==n.artifactId||t!==void 0&&o[1]!==t)return null;return e}var ni=new Set([\"available\",\"artifactId\",\"kind\",\"contentType\",\"originalBytes\",\"sha256\",\"retainedAt\",\"dimensions\",\"retention\",\"retrieval\"]),si=new Set([\"available\",\"artifactId\",\"kind\",\"contentType\",\"originalBytes\",\"sha256\",\"retainedAt\",\"retention\",\"retrieval\"]),ii=new Set([\"width\",\"height\"]),Un=new Set([\"policy\",\"expiresAt\"]),Dn=new Set([\"method\",\"path\",\"acceptRanges\",\"maxRangeBytes\"]);var ri=new Set([\"type\",\"sandboxPath\",\"filename\",\"artifact\"]),vo=new Set([...ri,\"access\"]);function ne(e,t){return e!==null&&typeof e===\"object\"&&!Array.isArray(e)&&Object.keys(e).length===t.size&&Object.keys(e).every((n)=>t.has(n))}function Ee(e,t,n){return Number.isSafeInteger(e)&&Number(e)>=t&&Number(e)<=n}function nt(e){let{limit:t,parentSessionId:n,scopeSubjectId:s}=e,i={};if(e.originSiteId)i.originSiteId=e.originSiteId;if(e.siteAccessId)i.siteAccessId=e.siteAccessId;if(t!==void 0)i.limit=String(t);if(n!==void 0)i.parentSessionId=n??\"null\";if(s!==void 0)i.scopeSubjectId=s;return i}var Gi=[\"siteAccessId\",\"originSiteId\",\"channelId\",\"createdBy\",\"updatedFrom\",\"updatedBefore\",\"createdFrom\",\"createdBefore\"],Mi=[\"updatedFrom\",\"updatedBefore\",\"createdFrom\",\"createdBefore\",\"sortBy\",\"archiveStatus\"];function Ui(e){return Boolean(e.needsYouOnly)||Boolean(e.contentArchivedOnly)||Boolean(e.mineOnly)||Gi.some((t)=>e[t]!==void 0)}function F(e){return Error(`The connected API does not support ${e}`)}function g(e,t){return`/v1/workspaces/${e}/sessions/${t}`}function Di(e){if(e.apiContract)return e.apiContract;return typeof window<\"u\"&&typeof document<\"u\"&&!e.apiKey?\"strict\":\"compatible\"}function Nn(e){let{associatedSessionId:t,includeTerminal:n,...s}=e;return{query:{...t?{associatedSessionId:t}:{},...n!==void 0?{includeTerminal:String(n)}:{}},request:s}}function Fn(e,t){let n,s,i=new Promise((r,o)=>{n=r,s=o});return{controller:new AbortController,consumers:0,generation:e,promise:i,resolve:n,reject:s,started:!1,listeners:new Set(t?[t]:[])}}function Jn(e){if(Object.prototype.hasOwnProperty.call(e,\"tools\"))throw TypeError(\"Message-level tools are not supported; update the session tool policy before sending.\")}function Vn(e){if(!(\"agentConfig\"in e)||!e.agentConfig?.machineTarget)return e;let{workingDir:t,...n}=e.agentConfig.machineTarget;if(t===void 0)return e;let s=t.trim();return{...e,agentConfig:{...e.agentConfig,machineTarget:{...n,...s?{workingDir:s}:{}}}}}function $i(e){return{forWorkspace(t){let n=t.trim();if(!n)throw TypeError(\"workspaceId is required\");let s,i=()=>s??=Promise.resolve().then(() => (Ae(),{})).then(({})=>new re(e).forWorkspace(n)),r=(o)=>new Proxy(async(...a)=>{let c=await i();for(let u of o)c=c[u];if(typeof c!==\"function\")throw TypeError(\"Tool path is not callable\");return await Reflect.apply(c,void 0,a)},{get:(a,c)=>{if(c===\"then\")return;if(typeof c!==\"string\")return;return r([...o,c])}});return new Proxy(Object.create(null),{get:(o,a)=>{if(a===\"$targetProtocol\")return e.toolGatewayMode===\"catalog\"?void 0:1;if(a===\"then\")return;if(typeof a!==\"string\")return;return r([a])}})}}}class st{get toolGatewayMode(){return this.options.toolGatewayMode??\"target\"}externalActorHeader;serviceInitiatorHeader;serviceContextHeader;baseUrl;options;fetchImpl;sessionCommandTimeoutMs;apiContractStrict;readRetryPolicy;active=new Map;generations=new Map;queued=new Map;interaction;tools;constructor(e){this.baseUrl=e.baseUrl.replace(/\\\\/+$/,\"\"),this.options=e,this.fetchImpl=Gt(e.fetch??((n,s)=>fetch(n,s)),e.onDeprecation);let t=e.sessionCommandTimeoutMs??15000;if(!Number.isFinite(t)||t<=0)throw RangeError(\"sessionCommandTimeoutMs must be a finite positive number\");this.sessionCommandTimeoutMs=t,this.apiContractStrict=Di(e)===\"strict\",this.readRetryPolicy=Ut(e.readRetry),this.interaction=new Xe(this),this.tools=$i(this)}async transcribeAudio(e,t){let n=crypto.randomUUID(),s=new FormData,i=zi(t.mimeType),r=t.audio instanceof File?t.audio:t.audio instanceof Uint8Array?new File([Uint8Array.from(t.audio)],i,{type:t.mimeType}):new File([t.audio],i,{type:t.mimeType||t.audio.type});if(s.append(\"audio\",r,i),s.append(\"mimeType\",t.mimeType),t.durationSeconds!==void 0)s.append(\"durationSeconds\",String(t.durationSeconds));let o;try{o=await this.fetchImpl(this.url(`/v1/workspaces/${e}/transcriptions`),{method:\"POST\",headers:{...this.headers(n),Accept:\"application/json\"},body:s,...t.signal?{signal:t.signal}:{}})}catch(c){if(t.signal?.aborted)throw c;throw ce(n)}if(D(o,this.apiContractStrict),!o.ok)throw await M(o,{method:\"POST\",correlationId:n});await fe(o,{method:\"POST\",correlationId:n});let a;try{a=await o.json()}catch{throw new P(o.status,\"Invalid transcription response.\",{code:\"invalid_response\",mutation:!0,correlationId:n})}if(!Bi(a))throw new P(o.status,\"Invalid transcription response.\",{code:\"invalid_response\",mutation:!0,correlationId:n});return a}async createTranscriptionRecording(e,t){return ye(await this.requestJson(\"POST\",`/v1/workspaces/${e}/transcription-recordings`,{recordingId:t.recordingId,mimeType:t.mimeType},{},t.signal?{signal:t.signal}:{}))}async getTranscriptionRecording(e,t,n={}){return ye(await this.requestJson(\"GET\",`/v1/workspaces/${e}/transcription-recordings/${t}`,void 0,{},n.signal?{signal:n.signal}:{}))}async listTranscriptionRecordings(e,t={}){let n=await this.requestJson(\"GET\",`/v1/workspaces/${e}/transcription-recordings`,void 0,{},t.signal?{signal:t.signal}:{});if(!Wi(n))throw A(\"Invalid transcription recording list response.\",{code:\"invalid_response\"});return n}async uploadTranscriptionRecordingChunk(e,t,n,s){let i=crypto.randomUUID(),r;try{r=await this.fetchImpl(this.url(`/v1/workspaces/${e}/transcription-recordings/${t}/chunks/${n}`),{method:\"PUT\",headers:{...this.headers(i),Accept:\"application/json\",\"Content-Type\":s.mimeType,\"x-opengeni-chunk-sha256\":s.sha256,\"x-opengeni-chunk-start-milliseconds\":String(s.startMilliseconds),\"x-opengeni-chunk-duration-milliseconds\":String(s.durationMilliseconds)},body:s.audio instanceof Uint8Array?Uint8Array.from(s.audio):s.audio,...s.signal?{signal:s.signal}:{}})}catch(a){if(s.signal?.aborted)throw a;throw ce(i)}if(D(r,this.apiContractStrict),!r.ok)throw await M(r,{method:\"PUT\",correlationId:i});await fe(r,{method:\"PUT\",correlationId:i});let o=await r.json().catch(()=>null);if(!Li(o))throw new P(r.status,\"Invalid transcription chunk response.\",{code:\"invalid_response\",mutation:!0,correlationId:i});return o}async finalizeTranscriptionRecording(e,t,n){return ye(await this.requestJson(\"POST\",`/v1/workspaces/${e}/transcription-recordings/${t}/finalize`,{chunkCount:n.chunkCount,totalBytes:n.totalBytes,totalDurationMilliseconds:n.totalDurationMilliseconds},{},n.signal?{signal:n.signal}:{}))}async processNextTranscriptionRecordingSegment(e,t,n={}){return ye(await this.requestJson(\"POST\",`/v1/workspaces/${e}/transcription-recordings/${t}/process-next`,{},{},n.signal?{signal:n.signal}:{}))}async discardTranscriptionRecording(e,t,n={}){return ye(await this.requestJson(\"DELETE\",`/v1/workspaces/${e}/transcription-recordings/${t}`,void 0,{},n.signal?{signal:n.signal}:{}))}async createSession(e,t){let n=t.usageLimitMicros!==void 0&&t.usageLimitMicros!==null,s=n&&t.startMode===void 0?{...t,startMode:\"standard\"}:t,i;try{i=await this.requestJson(\"POST\",`/v1/workspaces/${encodeURIComponent(e)}/sessions`,s)}catch(r){if(n&&s.startMode===\"standard\"&&r instanceof P&&yt(r))throw new pe(\"This server does not support task usage limits, so the session was not created. Create it without a usage limit, or upgrade the server.\",{sessionId:null,cause:r});throw r}return Fi(t.usageLimitMicros,i),i}async getSessionUsageLimit(e,t,n={}){return await this.requestJson(\"GET\",`/v1/workspaces/${encodeURIComponent(e)}/sessions/${encodeURIComponent(t)}/usage-limit`,void 0,{},n)}async setSessionUsageLimit(e,t,n){let s=await this.requestJson(\"PUT\",`/v1/workspaces/${encodeURIComponent(e)}/sessions/${encodeURIComponent(t)}/usage-limit`,n);if(s.limitMicros!==n.limitMicros)throw ft(t);return s}async getNewSessionDraft(e,t={}){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/new-session-draft`,void 0,{},t)}async saveNewSessionDraft(e,t){return await this.requestJson(\"PUT\",`/v1/workspaces/${e}/new-session-draft`,t)}async getWorkspaceCredentialProvider(e){return this.requestJson(\"GET\",`/v1/workspaces/${e}/credential-provider`)}async putWorkspaceCredentialProvider(e,t){return this.requestJson(\"PUT\",`/v1/workspaces/${e}/credential-provider`,t)}async deleteWorkspaceCredentialProvider(e){await this.requestVoid(\"DELETE\",`/v1/workspaces/${e}/credential-provider`)}async listWorkspaceWebhooks(e){return this.requestJson(\"GET\",`/v1/workspaces/${e}/webhooks`)}async createWorkspaceWebhook(e,t){return this.requestJson(\"POST\",`/v1/workspaces/${e}/webhooks`,t)}async updateWorkspaceWebhook(e,t,n){return this.requestJson(\"PATCH\",`/v1/workspaces/${e}/webhooks/${t}`,n)}async deleteWorkspaceWebhook(e,t){await this.requestVoid(\"DELETE\",`/v1/workspaces/${e}/webhooks/${t}`)}async listWorkspaceWebhookDeliveries(e,t,n={}){return this.requestJson(\"GET\",`/v1/workspaces/${e}/webhooks/${t}/deliveries`,void 0,n.limit!==void 0?{limit:String(n.limit)}:{})}async redeliverWorkspaceWebhookDelivery(e,t,n){return this.requestJson(\"POST\",`/v1/workspaces/${e}/webhooks/${t}/deliveries/${n}/redeliver`)}async listWorkspaceSandboxImages(e){return this.requestJson(\"GET\",`/v1/workspaces/${e}/sandbox-images`)}async createFeedback(e,t){return this.requestJson(\"POST\",`/v1/workspaces/${e}/feedback`,t)}async listOwnFeedback(e,t={}){let n=new URLSearchParams;if(t.sessionId)n.set(\"sessionId\",t.sessionId);if(t.limit!==void 0)n.set(\"limit\",String(t.limit));if(t.includeTurns!==void 0)n.set(\"includeTurns\",String(t.includeTurns));return this.requestJson(\"GET\",`/v1/workspaces/${e}/feedback${n.size?`?${n}`:\"\"}`)}async getSession(e,t,n={}){let s=g(e,t);return await this.sharedRead(s,(i)=>this.requestJson(\"GET\",s,void 0,{},{signal:i}),n)}async getToolActionReview(e,t,n){return await this.requestJson(\"GET\",`${g(e,t)}/tool-reviews/${encodeURIComponent(n)}`)}async getToolReviewDetails(e,t,n,s){let i=new URLSearchParams({actionDigest:s.actionDigest,path:s.path??\"\",offset:String(s.offset??0)});return await this.requestJson(\"GET\",`${g(e,t)}/tool-reviews/${encodeURIComponent(n)}/details?${i}`)}async getSessionModelContext(e,t){return await this.requestJson(\"GET\",`${g(e,t)}/model-context`)}async updateSession(e,t,n){return await this.requestJson(\"PATCH\",g(e,t),n)}async getSessionTenancyCreateCapabilities(e){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/session-tenancy/capabilities`)}async updateSessionVisibility(e,t,n){return await this.requestJson(\"PUT\",`${g(e,t)}/visibility`,n)}async previewSessionVisibilityChange(e,t,n){return await this.requestJson(\"GET\",`${g(e,t)}/visibility/preview?visibility=${encodeURIComponent(n)}`)}async forkSession(e,t,n){return await this.requestJson(\"POST\",`${g(e,t)}/forks`,n)}async updateSessionToolPolicy(e,t,n){return await this.requestJson(\"PUT\",`${g(e,t)}/tool-policy`,n)}async updateSessionAgent(e,t,n){return await this.requestJson(\"PUT\",`${g(e,t)}/agent`,n)}async updateSessionSkills(e,t,n){return await this.requestJson(\"PUT\",`${g(e,t)}/skills`,n)}async updateSessionMcpApprovalPolicy(e,t,n,s){return await this.requestJson(\"PATCH\",`${g(e,t)}/mcp-servers/${encodeURIComponent(n)}/approval-policy`,s)}async searchSessionMessages(e,t,n={}){return this.requestJson(\"GET\",`/v1/workspaces/${e}/session-message-search`,void 0,{query:t.query,...t.sessionId!==void 0?{sessionId:t.sessionId}:{},...t.groupBy!==void 0?{groupBy:t.groupBy}:{},...t.archiveStatus!==void 0?{archiveStatus:t.archiveStatus}:{},...t.limit!==void 0?{limit:String(t.limit)}:{},...t.cursor!==void 0?{cursor:t.cursor}:{}},n)}async getSessionMessagePreview(e,t,n,s={}){return this.requestJson(\"GET\",`/v1/workspaces/${encodeURIComponent(e)}/sessions/${encodeURIComponent(t)}/events/${encodeURIComponent(n.eventId)}/message-preview`,void 0,{sequence:String(n.sequence)},s)}async listSessions(e,t={}){if(t.search?.trim()||t.originSiteId){let n=await this.listSessionPage(e,t);return[...n.pinned,...n.sessions]}return await this.requestJson(\"GET\",`/v1/workspaces/${e}/sessions`,void 0,nt(t))}async listSessionBackgroundCommands(e,t,n={}){return await this.requestJson(\"GET\",`${g(e,t)}/background-commands`,void 0,{},n)}async listWorkspaceBackgroundCommands(e,t={}){let n=await this.requestJson(\"GET\",`/v1/workspaces/${encodeURIComponent(e)}/sessions`,void 0,{view:\"running_commands\",...t.cursor?{cursor:t.cursor}:{}},t);if(!n||!Array.isArray(n.commands)||!(\"nextCursor\"in n))throw Error(\"This server does not support the workspace running commands view.\");return n}async cancelSessionBackgroundCommand(e,t,n){return await this.requestJson(\"DELETE\",`${g(e,t)}/background-commands/${n}`)}async listSessionPage(e,t={}){let n=await this.requestSessionPage(`/v1/workspaces/${e}/sessions`,t);if(\"projection\"in n)throw F(\"full session details\");return n}async listSessionSummaryPage(e,t={}){let n=await this.requestSessionPage(`/v1/workspaces/${e}/sessions`,t,!0);if(\"projection\"in n)return n;await Promise.resolve().then(() => zn());return{...n,projection:\"summary\",pinned:n.pinned.map(Me),sessions:n.sessions.map(Me)}}async requestSessionPage(e,t,n=!1){let s=t.search?.trim(),i;try{let c={view:\"page\",...nt(t)};if(n)c.projection=\"summary\";if(t.cursor!==void 0)c.cursor=t.cursor;if(s)c.search=s;if(t.channelId!==void 0)c.channelId=t.channelId??\"null\";if(t.createdBy)c.createdByKind=t.createdBy.kind,c.createdBySubjectId=t.createdBy.subjectId;for(let u of Mi){let l=t[u];if(l)c[u]=l}if(t.pinsOnly)c.pinsOnly=\"true\";if(t.includeTotals)c.includeTotals=\"true\";if(t.needsYouOnly)c.needsYouOnly=\"true\";if(t.contentArchivedOnly)c.contentArchivedOnly=\"true\";if(t.mineOnly)c.mineOnly=\"true\";if(t.includePinned===!1)c.includePinned=\"false\";if(t.archivedOnly)c.archivedOnly=\"true\";if(t.siteConversations)c.siteConversations=t.siteConversations;i=await this.requestJson(\"GET\",e,void 0,c,{signal:t.signal})}catch(c){if(c instanceof P&&c.status===410)throw new He(c.status,c.body,{...c.code?{code:c.code}:{},retryable:c.retryable,...c.correlationId?{correlationId:c.correlationId}:{},outcomeUnknown:c.outcomeUnknown,displayMessage:\"The session list changed — refresh and try again.\"});throw c}let r=i,o=Array.isArray(r),a=Ui(t);if(t.sortBy!==void 0&&(o||r.sortBy!==t.sortBy)||t.archiveStatus!==void 0&&(o||r.archiveStatus!==t.archiveStatus))throw F(\"the requested session sorting/archive filter\");if(o){let c=t.includeTotals?\"complete session totals\":t.cursor?\"stable session-page cursors\":s?\"session search\":t.pinsOnly?\"pins-only session lists\":t.archivedOnly?\"archived session lists\":a?\"filtered session lists\":null;if(c)throw F(c);return{pinned:[],sessions:r,nextCursor:null}}if(t.includeTotals&&r.totals===void 0)throw F(\"complete session totals\");if(t.needsYouOnly&&r.needsYouOnly!==!0)throw F(\"attention session filtering\");if(t.contentArchivedOnly&&r.contentArchivedOnly!==!0)throw F(\"read-only session filtering\");if(t.mineOnly&&r.mineOnly!==!0)throw F(\"your-sessions filtering\");if(a&&r.filtersApplied!==!0)throw F(\"filtered session lists\");if(t.originSiteId&&(!r.originSiteId||t.originSiteId!==\"current\"&&r.originSiteId!==t.originSiteId))throw F(\"Site-filtered session lists\");if(t.siteAccessId&&(!r.siteAccessId||t.siteAccessId!==\"current\"&&t.siteAccessId!==r.siteAccessId))throw F(\"Site access-filtered session lists\");return r}async recordSiteOpened(e,t){return this.requestJson(\"POST\",`/v1/workspaces/${encodeURIComponent(e)}/published-artifacts/${encodeURIComponent(t)}/opened`)}async listSiteSessionAccess(e,t){return this.requestJson(\"GET\",`/v1/workspaces/${encodeURIComponent(e)}/published-artifacts/${encodeURIComponent(t)}/session-access`)}async setSiteSessionAccess(e,t,n,s){return this.requestJson(s?\"PUT\":\"DELETE\",`/v1/workspaces/${encodeURIComponent(e)}/published-artifacts/${encodeURIComponent(t)}/session-access/${encodeURIComponent(n)}`)}async listAgentTopology(e,t={}){let n=t.query?.trim()||t.search?.trim();if(n&&t.subject)throw TypeError(\"listAgentTopology query cannot be combined with an exact subject\");let s=nt(t);if(t.rootSessionId)s.rootSessionId=t.rootSessionId;if(t.cursor)s.cursor=t.cursor;if(n)s.query=n;if(t.statuses?.length)s.statuses=t.statuses.join(\",\");if(t.activeOnly!==void 0)s.activeOnly=t.activeOnly?\"true\":\"false\";if(t.recentHours!==void 0)s.recentHours=String(t.recentHours);if(t.subject)s.subjectNamespace=t.subject.namespace,s.subjectType=t.subject.type,s.subjectKey=t.subject.canonicalKey;if(t.claimLimit!==void 0)s.claimLimit=String(t.claimLimit);return await this.requestJson(\"GET\",`/v1/workspaces/${e}/agent-topology`,void 0,s)}async updateSessionPin(e,t,n){return await this.requestJson(\"PUT\",`${g(e,t)}/pin`,n)}async updateSessionAttention(e,t,n){return await this.requestJson(\"PUT\",`${g(e,t)}/attention`,n)}async updateSessionArchive(e,t,n){return await this.requestJson(\"PUT\",`${g(e,t)}/archive`,n)}async updateSessionRetention(e,t,n){return await this.requestJson(\"PUT\",`${g(e,t)}/retention`,n)}async deleteSession(e,t){return await this.requestJson(\"DELETE\",g(e,t))}async getSessionLineage(e,t,n={}){let s=`${g(e,t)}/lineage`;return await this.sharedRead(s,(i)=>this.requestJson(\"GET\",s,void 0,{},{signal:i}),n)}sharedRead(e,t,n={}){if(n.signal?.aborted)return Promise.reject(n.signal.reason??new DOMException(\"Request aborted\",\"AbortError\"));let s=this.active.get(e);if(s){if(!n.fresh)return this.observeRead(s,n.onRequestStart),this.consumeSharedRead(e,s,n.signal);let c=s.generation+1,u=this.queued.get(e);if(u&&u.generation>=c)return this.observeRead(u,n.onRequestStart),this.consumeSharedRead(e,u,n.signal);let l=u?.promise??s.promise;return this.queueRead(e,l,c,t,n)}let i=this.queued.get(e);if(i&&(!n.fresh||!i.started))return this.observeRead(i,n.onRequestStart),this.consumeSharedRead(e,i,n.signal);if(i)return this.queueRead(e,i.promise,i.generation+1,t,n);let r=(this.generations.get(e)??0)+1,o=Fn(r,n.onRequestStart),a=this.consumeSharedRead(e,o,n.signal);return this.launchRead(e,o,t),a}queueRead(e,t,n,s,i){let r=Fn(n,i.onRequestStart),o=this.consumeSharedRead(e,r,i.signal);this.queued.set(e,r);let a=()=>this.launchRead(e,r,s);t.then(a,a);let c=()=>{if(this.queued.get(e)!==r)return;if(this.queued.delete(e),!this.active.has(e))this.generations.delete(e)};return r.promise.then(c,c),o}launchRead(e,t,n){if(t.controller.signal.aborted)return;t.started=!0,this.generations.set(e,t.generation),this.active.set(e,t);try{t.stamp=this.options.beginSharedRead?.()}catch{}for(let r of t.listeners)try{r(t.stamp)}catch{}t.listeners.clear();let s=()=>{if(this.active.get(e)!==t)return;if(this.active.delete(e),!this.queued.has(e))this.generations.delete(e)},i;try{i=n(t.controller.signal)}catch(r){s(),t.reject(r);return}i.then((r)=>{s(),t.resolve(r)},(r)=>{s(),t.reject(r)})}consumeSharedRead(e,t,n){t.consumers+=1;let s=!1,i=()=>{if(s)return;if(s=!0,t.consumers-=1,!n?.aborted||t.consumers>0)return;let o=n.reason;if(t.controller.abort(o),this.active.get(e)===t)this.active.delete(e);if(this.queued.get(e)===t)this.queued.delete(e);if(!this.active.has(e)&&!this.queued.has(e))this.generations.delete(e);t.reject(o)};return n?.addEventListener(\"abort\",i,{once:!0}),ae(t.promise,n).finally(()=>{n?.removeEventListener(\"abort\",i),i()})}observeRead(e,t){if(!t)return;if(!e.started){e.listeners.add(t);return}if(e.stamp===void 0)return;try{t(e.stamp)}catch{}}async negotiateCodexRealtimeWebrtc(e,t,n,s={}){return await this.requestJson(\"POST\",`${g(e,t)}/realtime/webrtc`,n,{},{signal:s.signal})}async negotiateRealtimeWebsocket(e,t,n,s={}){return await this.requestJson(\"POST\",`${g(e,t)}/realtime/websocket`,n,{},{signal:s.signal})}async negotiateGatewayRealtime(e,t,n,s={}){return await this.requestJson(\"POST\",`${g(e,t)}/realtime/gateway`,n,{},{signal:s.signal})}async negotiateXaiSubscriptionRealtime(e,t,n,s={}){return await this.requestJson(\"POST\",`${g(e,t)}/realtime/supergrok`,n,{},{signal:s.signal})}async activateCodexRealtimeConnection(e,t,n,s,i,r={}){return await this.requestJson(\"POST\",`${g(e,t)}/realtime/${n}/connections/${s}/activate`,i,{},{signal:r.signal})}async beginSessionRealtime(e,t,n){return await this.requestJson(\"POST\",`${g(e,t)}/realtime`,n)}async heartbeatSessionRealtime(e,t,n,s){return await this.requestJson(\"PATCH\",`${g(e,t)}/realtime/${n}/heartbeat`,s)}async syncSessionRealtimeLedger(e,t,n,s){return await this.requestJson(\"POST\",`${g(e,t)}/realtime/${n}/sync`,s)}async endSessionRealtime(e,t,n,s){return await this.requestJson(\"DELETE\",`${g(e,t)}/realtime/${n}`,s)}async listTurns(e,t,n={}){return await this.requestJson(\"GET\",`${g(e,t)}/turns`,void 0,{...n.limit!==void 0?{limit:String(n.limit)}:{},...n.latestStarted?{latestStarted:\"1\"}:{}},{signal:n.signal})}async getLatestStartedTurn(e,t,n={}){return(await this.listTurns(e,t,{latestStarted:!0,signal:n.signal}))[0]??null}async listMachines(e,t={}){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/machines`,void 0,{...t.sessionId!==void 0?{sessionId:t.sessionId}:{}},{signal:t.signal})}async updateMachineAgent(e,t){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/machines/${t}/update`)}async enableMachineScreenControl(e,t){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/machines/${t}/screen-control`,{})}async openMachinePrivacySettings(e,t,n){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/machines/${t}/privacy-settings`,n)}async previewMachineAudience(e,t,n){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/machines/${t}/audience/preview`,n)}async changeMachineAudience(e,t,n){return await this.requestJson(\"PUT\",`/v1/workspaces/${e}/machines/${t}/audience`,n)}async updateMachineOperationPolicy(e,t,n){return await this.requestJson(\"PATCH\",`/v1/workspaces/${e}/machines/${t}/operation-policy`,n)}async machineMetricsSeries(e,t,n={}){return(await this.requestJson(\"GET\",`/v1/workspaces/${e}/machines/${t}/metrics/series`,void 0,{...n.window!==void 0?{window:n.window}:{}})).samples}async removeEnrollment(e,t,n={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/enrollments/${t}/revoke`,n)}async lookupDeviceEnrollment(e){return await this.requestJson(\"POST\",\"/v1/enrollments/device/lookup\",{userCode:e})}async approveDeviceEnrollment(e,t){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/enrollments/device/approve`,{userCode:t.userCode,allowScreenControl:t.allowScreenControl??!1,...t.scope?{scope:t.scope}:{}})}async denyDeviceEnrollment(e,t){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/enrollments/device/deny`,{userCode:t.userCode})}async mintEnrollToken(e,t={}){let n=\"scope\"in t?t.scope:void 0;return await this.requestJson(\"POST\",`/v1/workspaces/${e}/enrollments/token`,{allowScreenControl:t.allowScreenControl??!1,...n?{scope:n}:{}})}async swapActiveSandbox(e,t,n){return await this.requestJson(\"POST\",`${g(e,t)}/active-sandbox`,n)}async listScheduledTasks(e,t={}){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/scheduled-tasks`,void 0,{...t.offset!==void 0?{offset:String(t.offset)}:{},...t.sessionId?{sessionId:t.sessionId}:{},...t.limit!==void 0?{limit:String(t.limit)}:{}})}async getScheduledTask(e,t){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/scheduled-tasks/${t}`)}async listScheduledTaskSlackChannels(e,t,n){let s=new URLSearchParams({connectionId:t});if(n)s.set(\"cursor\",n);return await this.requestJson(\"GET\",`/v1/workspaces/${e}/scheduled-task-slack-channels?${s}`)}async listEvents(e,t,n={}){return(await this.listEventPage(e,t,n)).events}async listEventPage(e,t,n={}){if(n.latest&&[\"includeTypes\",\"excludeTypes\",\"includeClasses\",\"excludeClasses\"].some((x)=>Object.prototype.hasOwnProperty.call(n,x)))throw TypeError(\"latest cannot be combined with event filters\");if(n.resultMode===\"compact\"&&!n.latest)throw TypeError(\"resultMode=compact requires latest\");let s=n.resultMode===\"compact\"?null:n,i=crypto.randomUUID(),r=await this.fetchImpl(this.url(`${g(e,t)}/events`,{...s?.after!==void 0?{after:String(s.after)}:{},...s?.before!==void 0?{before:String(s.before)}:{},...s?.limit!==void 0?{limit:String(s.limit)}:{},...s?.compact?{compact:\"1\"}:{},...n.mode?{mode:n.mode}:{},...s?.direction?{direction:s.direction}:{},...n.payloadMode?{payloadMode:n.payloadMode}:{},...n.resultMode?{resultMode:n.resultMode}:{},...s?.includeTypes?.length?{includeTypes:s.includeTypes.join(\",\")}:{},...s?.excludeTypes?.length?{excludeTypes:s.excludeTypes.join(\",\")}:{},...s?.includeClasses?.length?{includeClasses:s.includeClasses.join(\",\")}:{},...s?.excludeClasses?.length?{excludeClasses:s.excludeClasses.join(\",\")}:{},...s?.presentedToolCalls===\"include\"?{presentedToolCalls:\"include\"}:{},...s?.toolOutputs===\"preview\"?{toolOutputs:\"preview\"}:{},...n.latest?{latest:n.latest}:{}}),{method:\"GET\",headers:{...this.headers(i),Accept:\"application/json\"}});if(D(r,this.apiContractStrict),!r.ok)throw await M(r,{method:\"GET\",correlationId:i});await fe(r,{method:\"GET\",correlationId:i});let o=await r.json();if(n.resultMode===\"compact\")return o;let a=o,c=(x)=>{let b=r.headers.get(x);if(b===null)return null;let h=Number(b);return Number.isSafeInteger(h)&&h>=0?h:null},u=r.headers.get(\"X-OpenGeni-Event-Mode\")===\"forensic\"?\"forensic\":\"monitoring\",l=r.headers.get(\"X-OpenGeni-Event-Direction\")===\"after\"?\"after\":\"before\",p=r.headers.get(\"X-OpenGeni-Payload-Mode\"),d=p===\"none\"||p===\"full\"?p:\"summary\",m=c(\"X-OpenGeni-Covered-First\"),y=c(\"X-OpenGeni-Covered-Last\"),R=c(\"X-OpenGeni-Page-Bytes\")??new TextEncoder().encode(JSON.stringify(a)).byteLength,w=c(\"X-OpenGeni-Page-Max-Bytes\")??1048576,S=r.headers.get(\"X-OpenGeni-Truncated-By\"),I=S===\"count\"||S===\"bytes\"||S===\"http_bytes\"?S:null;return{events:a,mode:u,payloadMode:d,direction:l,bytes:R,maxBytes:w,truncated:r.headers.get(\"X-OpenGeni-Page-Truncated\")===\"true\",hasMore:r.headers.get(\"X-OpenGeni-Has-More\")===\"true\",truncatedBy:I,coveredSequence:m===null||y===null?null:{first:m,last:y},nextAfter:c(\"X-OpenGeni-Next-After\"),nextBefore:c(\"X-OpenGeni-Next-Before\"),forensicExact:r.headers.get(\"X-OpenGeni-Forensic-Exact\")===\"true\",conversationFilter:c(Pt)}}async getLatestEventResult(e,t,n={latest:\"terminal\"}){return await this.listEventPage(e,t,{...n,resultMode:\"compact\"})}async sendEvent(e,t,n){return await this.requestSessionCommand(\"POST\",`${g(e,t)}/events`,n)}async sendMessage(e,t,n){let s=typeof n===\"string\"?{text:n}:n;Jn(s);let{clientEventId:i,...r}=s;return await this.sendEvent(e,t,{type:\"user.message\",...i!==void 0?{clientEventId:i}:{},payload:r})}async pauseSession(e,t,n={}){return await this.controlSession(e,t,{action:\"pause\",clientEventId:n.clientEventId??crypto.randomUUID(),...n.reason?{reason:n.reason}:{},...n.expectedControlEtag?{expectedControlEtag:n.expectedControlEtag}:{}})}async sendApprovalDecision(e,t,n){let{clientEventId:s,...i}=n;return await this.sendEvent(e,t,{type:\"user.approvalDecision\",...s!==void 0?{clientEventId:s}:{},payload:i})}async listHumanInputRequests(e,t,n={}){let s=await this.requestJson(\"GET\",`${g(e,t)}/human-input-requests`,void 0,n.status?{status:n.status}:void 0);return Ct(s,s.requests),s.requests}async getHumanInputRequest(e,t,n){return await this.requestJson(\"GET\",`${g(e,t)}/human-input-requests/${n}`)}async submitHumanInputResponse(e,t,n,s,i={}){return await this.sendEvent(e,t,{type:\"user.humanInputResponse\",...i.clientEventId?{clientEventId:i.clientEventId}:{},payload:{requestId:n,response:s}})}streamEvents(e,t,n={}){return qt(this.eventStreamTransport(e,t),n)}eventStreamTransport(e,t){return{openStream:async(n,s)=>await this.openEventStream(e,t,{after:n,...s?{signal:s}:{}}),listEvents:async(n,s)=>await this.listEvents(e,t,{after:n,limit:s})}}async openEventStream(e,t,n={}){let s=this.url(`${g(e,t)}/events/stream`,{after:String(n.after??0)}),i=crypto.randomUUID(),r=await this.fetchImpl(s,{method:\"GET\",headers:{...this.headers(i),Accept:\"text/event-stream\"},...n.signal?{signal:n.signal}:{}});if(D(r,this.apiContractStrict),!r.ok)throw await M(r,{method:\"GET\",correlationId:i});if(!r.body)throw new P(r.status,\"SSE response did not include a readable body\");return r.body}async getQueue(e,t){let n=`${g(e,t)}/queue`;return await this.sharedRead(n,()=>this.requestSessionCommand(\"GET\",n))}async moveQueueItem(e,t,n,s){return await this.requestSessionCommand(\"POST\",`${g(e,t)}/queue/${n}/move`,s)}async editQueueItem(e,t,n,s){return await this.requestSessionCommand(\"POST\",`${g(e,t)}/queue/${n}/edit`,s)}async steerQueueItem(e,t,n,s){return await this.requestSessionCommand(\"POST\",`${g(e,t)}/queue/${n}/steer`,s)}async deleteQueueItem(e,t,n,s){return await this.requestSessionCommand(\"POST\",`${g(e,t)}/queue/${n}/delete`,s)}async getComposerDraft(e,t,n={}){return await this.requestSessionCommand(\"GET\",`${g(e,t)}/composer-draft`,void 0,n)}async saveComposerDraft(e,t,n){return await this.requestSessionCommand(\"PUT\",`${g(e,t)}/composer-draft`,n)}async submitComposerDraft(e,t,n){return await this.requestSessionCommand(\"POST\",`${g(e,t)}/composer-draft/submit`,n)}async getSandboxRecovery(e,t){return this.requestJson(\"GET\",`${g(e,t)}/sandbox-recovery`)}async recoverSandbox(e,t,n){return this.requestSessionCommand(\"POST\",`${g(e,t)}/sandbox-recovery`,n)}async retrySession(e,t,n){return await this.requestSessionCommand(\"POST\",`${g(e,t)}/retry`,n)}async controlSession(e,t,n){return await this.requestSessionCommand(\"POST\",`${g(e,t)}/control`,n)}async resumeSession(e,t,n={}){return await this.controlSession(e,t,{action:\"resume\",clientEventId:n.clientEventId??crypto.randomUUID(),...n.reason?{reason:n.reason}:{},...n.expectedControlEtag?{expectedControlEtag:n.expectedControlEtag}:{}})}async cancelSession(e,t,n={}){return await this.controlSession(e,t,{action:\"cancel\",clientEventId:n.clientEventId??crypto.randomUUID(),...n.reason?{reason:n.reason}:{},...n.expectedControlEtag?{expectedControlEtag:n.expectedControlEtag}:{}})}async setWorkspacePauseTimer(e,t){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/pause-timer`,t)}async setWorkspaceInferenceState(e,t){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/inference-control`,t)}async listWorkspaceControlEvents(e,t={}){return(await this.listWorkspaceControlEventPage(e,t)).events}async listWorkspaceControlEventPage(e,t={}){let n=crypto.randomUUID(),s=await this.fetchImpl(this.url(`/v1/workspaces/${e}/control-events`,{...t.after!==void 0?{after:String(t.after)}:{},...t.limit!==void 0?{limit:String(t.limit)}:{}}),{method:\"GET\",headers:{...this.headers(n),Accept:\"application/json\"}});if(D(s,this.apiContractStrict),!s.ok)throw await M(s,{method:\"GET\",correlationId:n});await fe(s,{method:\"GET\",correlationId:n});let i=await s.json(),r=s.headers.get(\"X-OpenGeni-Page-Bytes\"),o=s.headers.get(\"X-OpenGeni-Next-After\"),a=r===null?Number.NaN:Number(r),c=o===null?null:Number(o);return{events:i,bytes:Number.isSafeInteger(a)&&a>=0?a:new TextEncoder().encode(JSON.stringify(i)).byteLength,truncated:s.headers.get(\"X-OpenGeni-Page-Truncated\")===\"true\",nextAfter:c!==null&&Number.isSafeInteger(c)&&c>=0?c:null}}streamWorkspaceControlEvents(e,t={}){return Jt(this.workspaceControlStreamTransport(e),t)}streamWorkspaceLiveEvents(e,t={}){return jt(this.workspaceLiveStreamTransport(e),t)}workspaceLiveStreamTransport(e){return{openStream:async(t,n,s)=>await this.openWorkspaceLiveEventStream(e,{controlAfter:t,interactionAfter:n,...s?{signal:s}:{}})}}async openWorkspaceLiveEventStream(e,t={}){let n=crypto.randomUUID(),s=await this.fetchImpl(this.url(`/v1/workspaces/${e}/live-events/stream`,{controlAfter:String(t.controlAfter??0),interactionAfter:String(t.interactionAfter??0)}),{method:\"GET\",headers:{...this.headers(n),Accept:\"text/event-stream\"},...t.signal?{signal:t.signal}:{}});if(D(s,this.apiContractStrict),!s.ok)throw await M(s,{method:\"GET\",correlationId:n});if(!s.body)throw new P(s.status,\"SSE response did not include a readable body\");return s.body}workspaceControlStreamTransport(e){return{openStream:async(t,n)=>await this.openWorkspaceControlEventStream(e,{after:t,...n?{signal:n}:{}})}}async openWorkspaceControlEventStream(e,t={}){let n=crypto.randomUUID(),s=await this.fetchImpl(this.url(`/v1/workspaces/${e}/control-events/stream`,{after:String(t.after??0)}),{method:\"GET\",headers:{...this.headers(n),Accept:\"text/event-stream\"},...t.signal?{signal:t.signal}:{}});if(D(s,this.apiContractStrict),!s.ok)throw await M(s,{method:\"GET\",correlationId:n});if(!s.body)throw new P(s.status,\"SSE response did not include a readable body\");return s.body}async steerMessage(e,t,n){let s=typeof n===\"string\"?{text:n}:n;return Jn(s),await this.requestSessionCommand(\"POST\",`${g(e,t)}/steer`,s)}async getGoal(e,t,n={}){let s=`${g(e,t)}/goal`;return await this.sharedRead(s,(i)=>this.requestJson(\"GET\",s,void 0,{},{signal:i}),n)}async findGoal(e,t,n={}){let s=`${g(e,t)}/goal`,i={absent:\"null\"};return await this.sharedRead(`${s}?absent=null`,(r)=>this.requestJson(\"GET\",s,void 0,i,{signal:r}),n)}async updateGoal(e,t,n){return await this.requestJson(\"PATCH\",`${g(e,t)}/goal`,n)}async listGoalRevisions(e,t){return await this.requestJson(\"GET\",`${g(e,t)}/goal/revisions`)}async listGoalRevisionPage(e,t,n={}){let s=new URLSearchParams;if(n.limit!==void 0)s.set(\"limit\",String(n.limit));if(n.before!==void 0)s.set(\"before\",n.before);let i=s.size>0?`?${s.toString()}`:\"\";return await this.requestJson(\"GET\",`${g(e,t)}/goal/revisions/page${i}`)}async rejectGoalRevision(e,t,n,s){return await this.requestJson(\"POST\",`${g(e,t)}/goal/revisions/${n}/reject`,s)}async rollbackGoalRevision(e,t,n,s){return await this.requestJson(\"POST\",`${g(e,t)}/goal/revisions/${n}/rollback`,s)}async applyGoalRevision(e,t,n,s){return await this.requestJson(\"POST\",`${g(e,t)}/goal/revisions/${n}/apply`,s)}async deleteGoal(e,t){await this.requestVoid(\"DELETE\",`${g(e,t)}/goal`)}async pauseGoal(e,t,n={}){return await this.updateGoal(e,t,{status:\"paused\",...n.rationale!==void 0?{rationale:n.rationale}:{}})}async resumeGoal(e,t){return await this.updateGoal(e,t,{status:\"active\"})}async clearSessionContext(e,t){await this.requestVoid(\"POST\",`${g(e,t)}/context/clear`,{confirm:!0})}async compactSessionContext(e,t){return await this.requestJson(\"POST\",`${g(e,t)}/context/compact`,{})}async fsList(e,t,n={},s={}){return await this.requestJson(\"POST\",`${g(e,t)}/fs/list`,n,{},s)}async fsListBatch(e,t,n,s={}){return await this.requestJson(\"POST\",`${g(e,t)}/fs/list-batch`,n,{},s)}async fsRead(e,t,n,s={}){return await this.requestJson(\"POST\",n.workspaceOnly?`${g(e,t)}/fs/read-workspace`:`${g(e,t)}/fs/read`,n,{},s)}async publishSandboxFileArtifact(e,t,n,s={}){return await this.requestJson(\"POST\",`${g(e,t)}/artifacts/publish`,n,{},s)}async fsWrite(e,t,n){return await this.requestJson(\"POST\",`${g(e,t)}/fs/write`,n)}async fsDelete(e,t,n){return await this.requestJson(\"POST\",`${g(e,t)}/fs/delete`,n)}async fsMove(e,t,n){return await this.requestJson(\"POST\",`${g(e,t)}/fs/move`,n)}async fsMkdir(e,t,n){return await this.requestJson(\"POST\",`${g(e,t)}/fs/mkdir`,n)}async gitStatus(e,t,n={},s={}){return await this.requestJson(\"POST\",`${g(e,t)}/git/status`,n,{},s)}async gitDiff(e,t,n={},s={}){return await this.requestJson(\"POST\",`${g(e,t)}/git/diff`,n,{},s)}async gitReadBatch(e,t,n,s={}){return await this.requestJson(\"POST\",`${g(e,t)}/git/read-batch`,n,{},s)}async gitLog(e,t,n={}){return await this.requestJson(\"POST\",`${g(e,t)}/git/log`,n)}async gitShow(e,t,n){return await this.requestJson(\"POST\",`${g(e,t)}/git/show`,n)}async getWorkspaceCapture(e,t,n={}){return await this.requestJson(\"GET\",`${g(e,t)}/workspace/capture`,void 0,{},n)}async getWorkspaceCaptureFile(e,t,n,s,i={}){let r={path:n};if(s!==void 0)r.revision=String(s);return await this.requestJson(\"GET\",`${g(e,t)}/workspace/capture/file`,void 0,r,i)}async terminalExec(e,t,n){return await this.requestJson(\"POST\",`${g(e,t)}/terminal/exec`,n)}async terminalPtyOpen(e,t,n={}){return await this.requestJson(\"POST\",`${g(e,t)}/terminal/pty`,n)}async terminalPtyWrite(e,t,n){await this.requestVoid(\"POST\",`${g(e,t)}/terminal/pty/write`,n)}async terminalPtyResize(e,t,n){await this.requestVoid(\"POST\",`${g(e,t)}/terminal/pty/resize`,n)}async terminalPtyClose(e,t,n){await this.requestVoid(\"POST\",`${g(e,t)}/terminal/pty/close`,n)}async getStreamCapabilities(e,t,n={}){return await this.requestJson(\"GET\",`${g(e,t)}/stream-capabilities`,void 0,{},n)}async acknowledgeStream(e,t,n={}){return await this.requestJson(\"POST\",`${g(e,t)}/stream-capabilities/acknowledge`,n)}async attachViewer(e,t,n={}){return await this.requestJson(\"POST\",`${g(e,t)}/viewers`,n)}async heartbeatViewer(e,t,n,s){return await this.requestJson(\"POST\",`${g(e,t)}/viewers/${n}/heartbeat`,s)}async detachViewer(e,t,n){await this.requestVoid(\"DELETE\",`${g(e,t)}/viewers/${n}`)}streamWorkspaceInteractionRevisions(e,t={}){return Ht(this.workspaceInteractionRevisionStreamTransport(e),t)}workspaceInteractionRevisionStreamTransport(e){return{openStream:async(t,n)=>await this.openWorkspaceInteractionRevisionStream(e,{after:t,...n?{signal:n}:{}})}}async openWorkspaceInteractionRevisionStream(e,t={}){let n=crypto.randomUUID(),s=await this.fetchImpl(this.url(`/v1/workspaces/${e}/interaction-events/stream`,{after:String(t.after??0)}),{method:\"GET\",headers:{...this.headers(n),Accept:\"text/event-stream\"},...t.signal?{signal:t.signal}:{}});if(D(s,this.apiContractStrict),!s.ok)throw await M(s,{method:\"GET\",correlationId:n});if(!s.body)throw new P(s.status,\"SSE response did not include a readable body\");return s.body}async listNetworkRoutes(e,t={}){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/network-routes`,void 0,t.includeArchived?{includeArchived:\"true\"}:{},t)}async getNetworkRoute(e,t,n={}){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/network-routes/${encodeURIComponent(t)}`,void 0,{},n)}async createNetworkRoute(e,t,n={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/network-routes`,t,{},n)}async updateNetworkRoute(e,t,n,s={}){return await this.requestJson(\"PATCH\",`/v1/workspaces/${e}/network-routes/${encodeURIComponent(t)}`,n,{},s)}async listSiteAuthConnections(e,t={}){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/site-auth-connections`,void 0,t.includeArchived?{includeArchived:\"true\"}:{},t)}async getSiteAuthConnection(e,t,n={}){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/site-auth-connections/${encodeURIComponent(t)}`,void 0,{},n)}async createSiteAuthConnection(e,t,n={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/site-auth-connections`,t,{},n)}async updateSiteAuthConnection(e,t,n,s={}){return await this.requestJson(\"PATCH\",`/v1/workspaces/${e}/site-auth-connections/${encodeURIComponent(t)}`,n,{},s)}async listAuthRuns(e,t={}){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/auth-runs`,void 0,{...t.browserSessionId?{browserSessionId:t.browserSessionId}:{},...t.siteAuthConnectionId?{siteAuthConnectionId:t.siteAuthConnectionId}:{},...t.includeSettled?{includeSettled:\"true\"}:{}},t)}async getAuthRun(e,t,n={}){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/auth-runs/${encodeURIComponent(t)}`,void 0,{},n)}async startBrowserAuthRun(e,t,n,s={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/browser-sessions/${encodeURIComponent(t)}/auth-runs`,n,{},s)}async reportBrowserAuthRun(e,t,n,s,i={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/browser-sessions/${encodeURIComponent(t)}/auth-runs/${encodeURIComponent(n)}/report`,s,{},i)}async advanceExternalBrowserAuthRun(e,t,n,s,i={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/browser-sessions/${encodeURIComponent(t)}/auth-runs/${encodeURIComponent(n)}/external-auth`,s,{},i)}async openExternalBrowserAuthFlow(e,t,n,s,i={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/browser-sessions/${encodeURIComponent(t)}/auth-runs/${encodeURIComponent(n)}/external-auth/interactive`,s,{},i)}async verifyBrowserAuthRun(e,t,n,s,i={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/browser-sessions/${encodeURIComponent(t)}/auth-runs/${encodeURIComponent(n)}/verify`,s,{},i)}async listInteractionInterventions(e,t={}){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/interaction-interventions`,void 0,{...t.resourceKind?{resourceKind:t.resourceKind}:{},...t.resourceId?{resourceId:t.resourceId}:{},...t.includeSettled?{includeSettled:\"true\"}:{}},t)}async getInteractionIntervention(e,t,n={}){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/interaction-interventions/${encodeURIComponent(t)}`,void 0,{},n)}async createInteractionIntervention(e,t,n={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/interaction-interventions`,t,{},n)}async resolveInteractionIntervention(e,t,n,s={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/interaction-interventions/${encodeURIComponent(t)}/resolve`,n,{},s)}async listAttachedBrowsers(e,t={}){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/attached-browsers`,void 0,t.includeDisconnected?{includeDisconnected:\"true\"}:{},t)}async getAttachedBrowser(e,t,n={}){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/attached-browsers/${encodeURIComponent(t)}`,void 0,{},n)}async listBrowserIdentities(e,t={}){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/browser-identities`,void 0,t.includeArchived?{includeArchived:\"true\"}:{},t)}async getBrowserIdentity(e,t,n={}){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/browser-identities/${encodeURIComponent(t)}`,void 0,{},n)}async createBrowserIdentity(e,t,n={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/browser-identities`,t,{},n)}async updateBrowserIdentity(e,t,n,s={}){return await this.requestJson(\"PATCH\",`/v1/workspaces/${e}/browser-identities/${encodeURIComponent(t)}`,n,{},s)}async listBrowserRevisions(e,t,n={}){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/browser-identities/${encodeURIComponent(t)}/revisions`,void 0,{},n)}async listBrowserSessions(e,t={}){let{query:n,request:s}=Nn(t);return await this.requestJson(\"GET\",`/v1/workspaces/${e}/browser-sessions`,void 0,n,s)}async getBrowserSession(e,t,n={}){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/browser-sessions/${encodeURIComponent(t)}`,void 0,{},n)}async readBrowserClipboard(e,t,n={}){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/browser-sessions/${encodeURIComponent(t)}/clipboard`,void 0,{},n)}async listBrowserDownloads(e,t,n={}){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/browser-sessions/${encodeURIComponent(t)}/downloads`,void 0,{},n)}async getBrowserDownload(e,t,n,s={}){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/browser-sessions/${encodeURIComponent(t)}/downloads/${encodeURIComponent(n)}`,void 0,{},s)}async saveBrowserDownload(e,t,n,s,i={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/browser-sessions/${encodeURIComponent(t)}/downloads/${encodeURIComponent(n)}/save`,s,{},i)}async startBrowserRecording(e,t,n,s={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/browser-sessions/${encodeURIComponent(t)}/recordings`,{targetId:n},{},s)}async getBrowserRecording(e,t,n,s={}){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/browser-sessions/${encodeURIComponent(t)}/recordings/${encodeURIComponent(n)}`,void 0,{},s)}async saveBrowserRecording(e,t,n,s,i={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/browser-sessions/${encodeURIComponent(t)}/recordings/${encodeURIComponent(n)}/save`,s,{},i)}async createBrowserSession(e,t,n={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/browser-sessions`,t,{},n)}async listBrowserTargets(e,t,n={}){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/browser-sessions/${encodeURIComponent(t)}/targets`,void 0,{},n)}async openBrowserTarget(e,t,n={},s={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/browser-sessions/${encodeURIComponent(t)}/targets`,n,{},s)}async openBrowserTargetWithInventory(e,t,n={},s={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/browser-sessions/${encodeURIComponent(t)}/targets/open-with-inventory`,n,{},s)}async selectBrowserTarget(e,t,n,s={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/browser-sessions/${encodeURIComponent(t)}/targets/${encodeURIComponent(n)}/select`,{},{},s)}async captureBrowserTarget(e,t,n,s={},i={}){let r=new URLSearchParams;if(i.fullPage!==void 0){if(typeof i.fullPage!==\"boolean\")throw TypeError(\"browser screenshot fullPage must be a boolean\");r.set(\"fullPage\",String(i.fullPage))}if(i.format!==void 0){if(i.format!==\"jpeg\"&&i.format!==\"png\")throw TypeError(\"browser screenshot format must be jpeg or png\");r.set(\"format\",i.format)}if(i.quality!==void 0){if(!Number.isSafeInteger(i.quality)||i.quality<1||i.quality>100)throw RangeError(\"browser screenshot quality must be an integer from 1 to 100\");r.set(\"quality\",String(i.quality))}let o=r.size>0?`?${r}`:\"\",a=await this.requestResponse(\"GET\",`/v1/workspaces/${e}/browser-sessions/${encodeURIComponent(t)}/targets/${encodeURIComponent(n)}/screenshot${o}`,{},s),c=a.headers.get(\"content-type\")?.split(\";\",1)[0]?.trim().toLowerCase(),u=a.headers.get(\"x-opengeni-browser-frame\");if(c!==\"image/jpeg\"&&c!==\"image/png\"||!u||u.length>65536)throw await U(a,\"browser frame metadata is invalid\"),A(\"browser frame metadata is invalid\");let l;try{l=kn(JSON.parse(atob(u.replace(/-/gu,\"+\").replace(/_/gu,\"/\"))))}catch{throw await U(a,\"browser frame metadata is invalid\"),A(\"browser frame metadata is invalid\")}let p=await he(a,25165824,null);if(l.browserSessionId!==t||l.targetId!==n||l.mediaType!==c)throw A(\"browser frame evidence does not match its request\");return{...l,data:p}}async closeBrowserTarget(e,t,n,s={}){return await this.requestJson(\"DELETE\",`/v1/workspaces/${e}/browser-sessions/${encodeURIComponent(t)}/targets/${encodeURIComponent(n)}`,void 0,{},s)}async observeBrowserTarget(e,t,n,s={}){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/browser-sessions/${encodeURIComponent(t)}/targets/${encodeURIComponent(n)}/observation`,void 0,{},s)}async getBrowserTargetState(e,t,n,s={}){let i=await this.requestJson(\"GET\",`/v1/workspaces/${e}/browser-sessions/${encodeURIComponent(t)}/targets/${encodeURIComponent(n)}/state`,void 0,{},s);if(i.browserSessionId!==t||i.targetId!==n)throw A(\"browser target state belongs to another binding\");return i}async readBrowserDom(e,t,n,s,i={}){let r=await this.requestJson(\"POST\",`/v1/workspaces/${e}/browser-sessions/${encodeURIComponent(t)}/targets/${encodeURIComponent(n)}/dom-read`,s,{},i);if(r.browserSessionId!==t||r.targetId!==n||r.kind!==s.kind||r.targetGeneration!==s.expectedTargetGeneration||r.documentGeneration!==s.expectedDocumentGeneration||r.frameId!==s.expectedFrameId)throw A(\"browser DOM read belongs to another binding\");return r}async actInBrowser(e,t,n,s={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/browser-sessions/${encodeURIComponent(t)}/actions`,n,{},s)}async getBrowserActionReceipt(e,t,n,s={}){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/browser-sessions/${encodeURIComponent(t)}/operations/${encodeURIComponent(n)}`,void 0,{},s)}async listBrowserDiagnostics(e,t,n,s={}){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/browser-sessions/${encodeURIComponent(t)}/targets/${encodeURIComponent(n)}/diagnostics`,void 0,{...s.kinds?.length?{kinds:s.kinds.join(\",\")}:{},...s.after!==void 0?{after:String(s.after)}:{},...s.limit!==void 0?{limit:String(s.limit)}:{}},s.signal?{signal:s.signal}:{})}async attachBrowserSession(e,t,n,s={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/browser-sessions/${encodeURIComponent(t)}/attachments`,n,{},s)}async heartbeatBrowserSession(e,t,n={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/browser-sessions/${encodeURIComponent(t)}/heartbeat`,{},{},n)}async publishBrowserRevision(e,t,n,s={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/browser-sessions/${encodeURIComponent(t)}/revisions`,n,{},s)}async suspendBrowserSession(e,t,n,s={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/browser-sessions/${encodeURIComponent(t)}/suspend`,n,{},s)}async resumeBrowserSession(e,t,n,s={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/browser-sessions/${encodeURIComponent(t)}/resume`,n,{},s)}async endBrowserSession(e,t,n,s={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/browser-sessions/${encodeURIComponent(t)}/end`,n,{},s)}async inspectBrowserSessionWorkingCopy(e,t,n={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/browser-sessions/${encodeURIComponent(t)}/working-copy/inspection`,{},{},n)}async adoptBrowserSessionWorkingCopy(e,t,n,s={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/browser-sessions/${encodeURIComponent(t)}/working-copy/adoptions`,n,{},s)}async getBrowserSessionWorkingCopyAdoption(e,t,n,s={}){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/browser-sessions/${encodeURIComponent(t)}/working-copy/adoptions/${encodeURIComponent(n)}`,void 0,{},s)}async revertBrowserSessionWorkingCopyAdoption(e,t,n,s={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/browser-sessions/${encodeURIComponent(t)}/working-copy/adoptions/${encodeURIComponent(n)}/revert`,{},{},s)}async listComputerSessions(e,t={}){let{query:n,request:s}=Nn(t);return await this.requestJson(\"GET\",`/v1/workspaces/${e}/computer-sessions`,void 0,n,s)}async getComputerSession(e,t,n={}){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/computer-sessions/${encodeURIComponent(t)}`,void 0,{},n)}async readComputerClipboard(e,t,n={}){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/computer-sessions/${encodeURIComponent(t)}/clipboard`,void 0,{},n)}async getComputerInputPosture(e,t,n={}){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/computer-sessions/${encodeURIComponent(t)}/input-posture`,void 0,{},n)}async createComputerSession(e,t,n={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/computer-sessions`,t,{},n)}async listComputerTargets(e,t,n={}){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/computer-sessions/${encodeURIComponent(t)}/targets`,void 0,{},n)}async observeComputerTarget(e,t,n,s={}){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/computer-sessions/${encodeURIComponent(t)}/targets/${encodeURIComponent(n)}/observation`,void 0,{},s)}async captureComputerTarget(e,t,n,s={}){let i=await this.requestResponse(\"GET\",`/v1/workspaces/${e}/computer-sessions/${encodeURIComponent(t)}/targets/${encodeURIComponent(n)}/screenshot`,{},s),r=i.headers.get(\"content-type\")?.split(\";\",1)[0]?.trim().toLowerCase();if(r!==\"image/jpeg\"&&r!==\"image/png\")throw await U(i,\"computer frame media type is invalid\"),A(\"computer frame media type is invalid\");let o=i.headers.get(\"x-opengeni-computer-frame\");if(!o||o.length>32768)throw await U(i,\"computer frame metadata is invalid\"),A(\"computer frame metadata is invalid\");let a;try{a=In(o)}catch{throw await U(i,\"computer frame metadata is invalid\"),A(\"computer frame metadata is invalid\")}let c=await he(i,262144,null);if(Ki(a,{computerSessionId:t,targetId:n,mediaType:r,sha256:await Kn(c)}))throw A(\"computer frame evidence does not match its request\");return{...a,data:c}}async callNativeComputerTool(e,t,n,s={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/computer-sessions/${encodeURIComponent(t)}/native-calls`,n,{},s)}async actInComputer(e,t,n,s={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/computer-sessions/${encodeURIComponent(t)}/actions`,n,{},s)}async getNativeComputerToolReceipt(e,t,n,s={}){let i=await this.requestJson(\"GET\",`/v1/workspaces/${e}/computer-sessions/${encodeURIComponent(t)}/operations/${encodeURIComponent(n)}`,void 0,{},s);if(i?.targetId!==null)throw Error(\"Expected a native computer receipt\");return i}async getComputerActionReceipt(e,t,n,s={}){let i=await this.requestJson(\"GET\",`/v1/workspaces/${e}/computer-sessions/${encodeURIComponent(t)}/operations/${encodeURIComponent(n)}`,void 0,{},s);if(typeof i?.targetId!==\"string\")throw Error(\"Expected a computer action receipt\");return i}async attachComputerSession(e,t,n,s={}){let i=await this.requestJson(\"POST\",`/v1/workspaces/${e}/computer-sessions/${encodeURIComponent(t)}/attachments`,n,{},s);if(i.stream.kind===\"direct_rfb\")return{...i,stream:{...i.stream,inputAllowed:i.stream.inputAllowed===!0}};return i}async heartbeatComputerSession(e,t,n={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/computer-sessions/${encodeURIComponent(t)}/heartbeat`,{},{},n)}async endComputerSession(e,t,n,s={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/computer-sessions/${encodeURIComponent(t)}/end`,n,{},s)}async getClientConfig(e={}){let t=await this.requestJson(\"GET\",\"/v1/config/client\",void 0,e.workspaceId===void 0?{}:{workspaceId:e.workspaceId},e);if(this.apiContractStrict&&t.apiContractRevision!==oe)throw new ve(oe,String(t.apiContractRevision||\"(missing)\"));return t}async getWorkspaceModelCatalog(e,t={}){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/model-catalog`,void 0,{},t)}async listWorkspaceGatewayCustomModels(e){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/gateway-custom-models`)}async createWorkspaceGatewayCustomModel(e,t){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/gateway-custom-models`,t)}async deleteWorkspaceGatewayCustomModel(e,t,n){if(!/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu.test(t))throw TypeError(\"customModelId must be a UUID\");await this.requestVoid(\"DELETE\",`/v1/workspaces/${e}/gateway-custom-models/${encodeURIComponent(t)}`,n)}async listWorkspaceOpenRouterCustomModels(e){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/openrouter-custom-models`)}async createWorkspaceOpenRouterCustomModel(e,t){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/openrouter-custom-models`,t)}async deleteWorkspaceOpenRouterCustomModel(e,t,n){if(!/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu.test(t))throw TypeError(\"customModelId must be a UUID\");await this.requestVoid(\"DELETE\",`/v1/workspaces/${e}/openrouter-custom-models/${encodeURIComponent(t)}`,n)}async listWorkspaceOpperCustomModels(e){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/opper-custom-models`)}async createWorkspaceOpperCustomModel(e,t){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/opper-custom-models`,t)}async deleteWorkspaceOpperCustomModel(e,t,n){if(!/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu.test(t))throw TypeError(\"customModelId must be a UUID\");await this.requestVoid(\"DELETE\",`/v1/workspaces/${e}/opper-custom-models/${encodeURIComponent(t)}`,n)}async getWorkspaceClaudeSubscriptionUsage(e){return this.requestJson(\"GET\",`/v1/workspaces/${e}/model-providers/claude_subscription/usage`)}async getWorkspaceSubscriptionUsagePools(e){return this.requestJson(\"GET\",`/v1/workspaces/${e}/subscription-usage-pools`)}async getOrganizationSubscriptionUsagePools(e){return this.requestJson(\"GET\",`/v1/organizations/${e}/subscription-usage-pools`)}async listClaudeSubscriptionAccounts(e){return this.requestJson(\"GET\",`/v1/workspaces/${e}/claude/accounts`)}async activateClaudeSubscriptionAccount(e,t){return this.requestJson(\"POST\",`/v1/workspaces/${e}/claude/accounts/${encodeURIComponent(t)}/activate`,{})}async setClaudeSubscriptionRotationSettings(e,t){return this.requestJson(\"PATCH\",`/v1/workspaces/${e}/claude/settings`,t)}async setClaudeSubscriptionAccountAllocator(e,t,n){return this.requestJson(\"PATCH\",`/v1/workspaces/${e}/claude/accounts/${encodeURIComponent(t)}/allocator`,n)}async renameClaudeSubscriptionAccount(e,t,n){return this.requestJson(\"PATCH\",`/v1/workspaces/${e}/claude/accounts/${encodeURIComponent(t)}`,{label:n})}async disconnectClaudeSubscriptionAccount(e,t){return this.requestJson(\"DELETE\",`/v1/workspaces/${e}/claude/accounts/${encodeURIComponent(t)}`,{})}async getClaudeSubscriptionAccountUsage(e,t){return this.requestJson(\"GET\",`/v1/workspaces/${e}/claude/accounts/${encodeURIComponent(t)}/usage`)}async refreshClaudeSubscriptionAccountUsage(e,t){return this.requestJson(\"POST\",`/v1/workspaces/${e}/claude/accounts/${encodeURIComponent(t)}/usage/refresh`,{})}async listOrganizationClaudeSubscriptionAccounts(e){return this.requestJson(\"GET\",`/v1/organizations/${e}/claude/accounts`)}async activateOrganizationClaudeSubscriptionAccount(e,t){return this.requestJson(\"POST\",`/v1/organizations/${e}/claude/accounts/${encodeURIComponent(t)}/activate`,{})}async setOrganizationClaudeSubscriptionRotationSettings(e,t){return this.requestJson(\"PATCH\",`/v1/organizations/${e}/claude/settings`,t)}async setOrganizationClaudeSubscriptionAccountAllocator(e,t,n){return this.requestJson(\"PATCH\",`/v1/organizations/${e}/claude/accounts/${encodeURIComponent(t)}/allocator`,n)}async renameOrganizationClaudeSubscriptionAccount(e,t,n){return this.requestJson(\"PATCH\",`/v1/organizations/${e}/claude/accounts/${encodeURIComponent(t)}`,{label:n})}async disconnectOrganizationClaudeSubscriptionAccount(e,t){return this.requestJson(\"DELETE\",`/v1/organizations/${e}/claude/accounts/${encodeURIComponent(t)}`,{})}async getOrganizationClaudeSubscriptionAccountUsage(e,t){return this.requestJson(\"GET\",`/v1/organizations/${e}/claude/accounts/${encodeURIComponent(t)}/usage`)}async refreshOrganizationClaudeSubscriptionAccountUsage(e,t){return this.requestJson(\"POST\",`/v1/organizations/${e}/claude/accounts/${encodeURIComponent(t)}/usage/refresh`,{})}async connectClaudeSubscriptionSetupToken(e,t){return this.requestJson(\"POST\",`/v1/workspaces/${e}/claude/accounts/setup-token`,t)}async connectOrganizationClaudeSubscriptionSetupToken(e,t){return this.requestJson(\"POST\",`/v1/organizations/${e}/claude/accounts/setup-token`,t)}async startWorkspaceClaudeSubscriptionOAuth(e,t={}){return this.requestJson(\"POST\",`/v1/workspaces/${e}/model-providers/claude_subscription/oauth/start`,t)}async completeWorkspaceClaudeSubscriptionOAuth(e,t){return this.requestJson(\"POST\",`/v1/workspaces/${e}/model-providers/claude_subscription/oauth/complete`,t)}async startOrganizationClaudeSubscriptionOAuth(e,t={}){return this.requestJson(\"POST\",`/v1/organizations/${e}/model-providers/claude_subscription/oauth/start`,t)}async completeOrganizationClaudeSubscriptionOAuth(e,t){return this.requestJson(\"POST\",`/v1/organizations/${e}/model-providers/claude_subscription/oauth/complete`,t)}async refreshWorkspaceClaudeSubscriptionUsage(e){return this.requestJson(\"POST\",`/v1/workspaces/${e}/model-providers/claude_subscription/usage/refresh`,{})}async getOrganizationClaudeSubscriptionUsage(e){return this.requestJson(\"GET\",`/v1/organizations/${e}/model-providers/claude_subscription/usage`)}async refreshOrganizationClaudeSubscriptionUsage(e){return this.requestJson(\"POST\",`/v1/organizations/${e}/model-providers/claude_subscription/usage/refresh`,{})}async getOrganizationModelProviderConnection(e,t){return await this.requestJson(\"GET\",`/v1/organizations/${e}/model-providers/${t}`)}async upsertOrganizationModelProviderConnection(e,t,n){return await this.requestJson(\"PUT\",`/v1/organizations/${e}/model-providers/${t}`,n)}async revokeOrganizationModelProviderConnection(e,t,n){return await this.requestJson(\"DELETE\",`/v1/organizations/${e}/model-providers/${t}`,n)}async listWorkspaceClaudeCustomModels(e,t){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/model-providers/${t}/custom-models`)}async createWorkspaceClaudeCustomModel(e,t,n){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/model-providers/${t}/custom-models`,n)}async deleteWorkspaceClaudeCustomModel(e,t,n,s){if(!/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu.test(n))throw TypeError(\"customModelId must be a UUID\");await this.requestVoid(\"DELETE\",`/v1/workspaces/${e}/model-providers/${t}/custom-models/${encodeURIComponent(n)}`,s)}async listOrganizationProviderCustomModels(e,t){return await this.requestJson(\"GET\",`/v1/organizations/${e}/model-providers/${t}/custom-models`)}async createOrganizationProviderCustomModel(e,t,n){return await this.requestJson(\"POST\",`/v1/organizations/${e}/model-providers/${t}/custom-models`,n)}async deleteOrganizationProviderCustomModel(e,t,n,s){if(!/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu.test(n))throw TypeError(\"customModelId must be a UUID\");return await this.requestJson(\"DELETE\",`/v1/organizations/${e}/model-providers/${t}/custom-models/${encodeURIComponent(n)}`,s)}async getWorkspaceModelAccessPolicy(e){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/model-policy`)}async deleteWorkspaceModelAccessPolicy(e){return await this.requestJson(\"DELETE\",`/v1/workspaces/${e}/model-policy`)}async getOrganizationModelDefaults(e){return await this.requestJson(\"GET\",`/v1/organizations/${e}/model-defaults`)}async updateOrganizationModelDefaults(e,t){return await this.requestJson(\"PATCH\",`/v1/organizations/${e}/model-defaults`,t)}async getOrganizationModelAccountSettings(e){return await this.requestJson(\"GET\",`/v1/organizations/${e}/model-account-settings`)}async updateOrganizationModelAccountSettings(e,t){return await this.requestJson(\"PATCH\",`/v1/organizations/${e}/model-account-settings`,t)}async getModelAccountSettingsOverview(e,t={}){let n=new URLSearchParams;if(t.after!==void 0)n.set(\"after\",t.after);if(t.limit!==void 0)n.set(\"limit\",String(t.limit));return await this.requestJson(\"GET\",`/v1/organizations/${e}/model-account-settings/overview${n.size?`?${n}`:\"\"}`)}async getWorkspaceModelAccountSettings(e){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/model-account-settings`)}async updateWorkspaceModelAccountSettings(e,t){return await this.requestJson(\"PATCH\",`/v1/workspaces/${e}/model-account-settings`,t)}async getSessionModelAccount(e,t){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/sessions/${t}/model-account`)}async setSessionModelAccount(e,t,n){return await this.requestJson(\"PUT\",`/v1/workspaces/${e}/sessions/${t}/model-account`,n)}async getModelAccountPreferences(e){return await this.requestJson(\"GET\",`/v1/organizations/${e}/me/model-account-preferences`)}async updateModelAccountPreferences(e,t){return await this.requestJson(\"PATCH\",`/v1/organizations/${e}/me/model-account-preferences`,t)}async getOrganizationAgentAdminAccess(e){return await this.requestJson(\"GET\",`/v1/organizations/${e}/agent-admin-access`)}async updateOrganizationAgentAdminAccess(e,t){return await this.requestJson(\"PATCH\",`/v1/organizations/${e}/agent-admin-access`,t)}async getOrganizationPrivacySettings(e){return await this.requestJson(\"GET\",`/v1/organizations/${e}/privacy-settings`)}async updateOrganizationPrivacySettings(e,t){return await this.requestJson(\"PATCH\",`/v1/organizations/${e}/privacy-settings`,t)}async updateWorkspaceModelAccessPolicy(e,t){return await this.requestJson(\"PUT\",`/v1/workspaces/${e}/model-policy`,t)}async getWorkspaceRealtimeModelCatalog(e,t={}){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/realtime-model-catalog`,void 0,{},t)}async getAccessContext(){return await this.requestJson(\"GET\",\"/v1/access/me\")}async listOrganizationMemberships(){return await this.requestJson(\"GET\",\"/v1/organization-memberships\")}async listUserResourceAuthorities(e,t){let n=new URLSearchParams({scope:\"user\",resourceKind:t.resourceKind});if(t.cursor)n.set(\"cursor\",t.cursor);if(t.limit!==void 0)n.set(\"limit\",String(t.limit));return await this.requestJson(\"GET\",`/v1/workspaces/${e}/user-resource-authorities?${n.toString()}`)}async revokeUserResourceGrant(e,t){return await this.requestJson(\"DELETE\",`/v1/workspaces/${e}/user-resource-authorities/grants/${t}?scope=user`)}async createOrganization(e){return await this.requestJson(\"POST\",\"/v1/organizations\",e)}async createAdditionalOrganization(e){return await this.requestJson(\"POST\",\"/v1/organizations/additional\",e)}async listOrganizationInvitations(e={}){let t=new URLSearchParams;if(e.cursor)t.set(\"cursor\",e.cursor);if(e.limit!==void 0)t.set(\"limit\",String(e.limit));let n=t.size>0?`?${t.toString()}`:\"\";return await this.requestJson(\"GET\",`/v1/organization-invitations${n}`)}async listOrganizationInvitationsForOrganization(e,t={}){let n=new URLSearchParams;if(t.cursor)n.set(\"cursor\",t.cursor);if(t.limit!==void 0)n.set(\"limit\",String(t.limit));let s=n.size>0?`?${n.toString()}`:\"\";return await this.requestJson(\"GET\",`/v1/organizations/${e}/invitations${s}`)}async createOrganizationInvitation(e,t){return await this.requestJson(\"POST\",`/v1/organizations/${e}/invitations`,t)}async acceptOrganizationInvitation(e,t){return await this.requestJson(\"POST\",`/v1/organization-invitations/${e}/accept`,t)}async revokeOrganizationInvitation(e,t,n){return await this.requestJson(\"POST\",`/v1/organizations/${e}/invitations/${t}/revoke`,n)}async listOrganizationAdministrationMembers(e){return await this.requestJson(\"GET\",`/v1/organizations/${e}/members`)}async listOrganizationMembers(e){return await this.listOrganizationAdministrationMembers(e)}async getOrganizationAdministrationOverview(e){return await this.requestJson(\"GET\",`/v1/organizations/${e}/overview`)}async createOrganizationWorkspace(e,t){return await this.requestJson(\"POST\",`/v1/organizations/${e}/workspaces`,t)}async updateOrganizationWorkspace(e,t,n){return await this.requestJson(\"PATCH\",`/v1/organizations/${e}/workspaces/${t}`,n)}async updateOrganizationWorkspaceSettings(e,t,n){return await this.requestJson(\"PATCH\",`/v1/organizations/${e}/workspaces/${t}/settings`,n)}async deleteOrganizationWorkspace(e,t){await this.requestVoid(\"DELETE\",`/v1/organizations/${e}/workspaces/${t}`)}async putOrganizationWorkspaceMember(e,t,n,s){return await this.requestJson(\"PUT\",`/v1/organizations/${e}/workspaces/${t}/members/${n}`,s)}async revokeOrganizationWorkspaceMember(e,t,n,s){return await this.requestJson(\"POST\",`/v1/organizations/${e}/workspaces/${t}/members/${n}/revoke`,s)}async updateOrganizationName(e,t){return await this.requestJson(\"PATCH\",`/v1/organizations/${e}`,t)}async updateOrganizationMember(e,t,n){return await this.requestJson(\"PATCH\",`/v1/organizations/${e}/members/${t}`,n)}async getOrganizationRetentionPolicy(e){return await this.requestJson(\"GET\",`/v1/organizations/${e}/retention-policy`)}async updateOrganizationRetentionPolicy(e,t){return await this.requestJson(\"PATCH\",`/v1/organizations/${e}/retention-policy`,t)}async getOrganizationRecovery(e){return await this.requestJson(\"GET\",`/v1/organizations/${e}/recovery`)}async configureOrganizationRecoveryPolicy(e,t){return await this.requestJson(\"PUT\",`/v1/organizations/${e}/recovery/policy`,t)}async acceptOrganizationRecoveryCustody(e,t){return await this.requestJson(\"POST\",`/v1/organizations/${e}/recovery/policy/accept`,t)}async disableOrganizationRecoveryPolicy(e,t){return await this.requestJson(\"POST\",`/v1/organizations/${e}/recovery/policy/disable`,t)}async startOrganizationRecoveryOperation(e,t){return await this.requestJson(\"POST\",`/v1/organizations/${e}/recovery/operations`,t)}async approveOrganizationRecoveryOperation(e,t,n){return await this.requestJson(\"POST\",`/v1/organizations/${e}/recovery/operations/${t}/approve`,n)}async cancelOrganizationRecoveryOperation(e,t,n){return await this.requestJson(\"POST\",`/v1/organizations/${e}/recovery/operations/${t}/cancel`,n)}async executeOrganizationRecoveryOperation(e,t,n){return await this.requestJson(\"POST\",`/v1/organizations/${e}/recovery/operations/${t}/execute`,n)}async searchPublicSkills(e,t){return this.requestJson(\"GET\",`/v1/workspaces/${encodeURIComponent(e)}/skills/search?q=${encodeURIComponent(t)}`)}async listWorkspaces(){return await this.requestJson(\"GET\",\"/v1/workspaces\")}connectTransport(){let e=(t)=>`/v1/workspaces/${encodeURIComponent(t)}/connect`;return{catalog:(t,n)=>this.requestJson(\"GET\",`${e(t)}/catalog`,void 0,void 0,n),accounts:(t,n)=>this.requestJson(\"GET\",`${e(t)}/accounts`,void 0,void 0,n),pending:(t,n)=>this.requestJson(\"GET\",`${e(t)}/attempts`,void 0,void 0,n),begin:(t,n,s)=>this.requestJson(\"POST\",`${e(t)}/attempts`,n,void 0,s),get:(t,n,s)=>this.requestJson(\"GET\",`${e(t)}/attempts/${encodeURIComponent(n)}`,void 0,void 0,s),advance:(t,n,s,i)=>this.requestJson(\"POST\",`${e(t)}/attempts/${encodeURIComponent(n)}/advance`,s,void 0,i),cancel:(t,n,s,i)=>this.requestJson(\"POST\",`${e(t)}/attempts/${encodeURIComponent(n)}/cancel`,s,void 0,i),disconnect:async(t,n,s)=>{if(n.startsWith(\"social:\")){let o=n.slice(7);if(!/^[0-9a-f-]{36}$/i.test(o))throw Error(\"Invalid social account ID\");await this.disconnectSocialConnection(t,o);return}if(n.startsWith(\"lens-registration:\")){let o=n.slice(18);if(!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(o))throw Error(\"Invalid Lens registration ID\");await this.requestJson(\"DELETE\",`/v1/workspaces/${encodeURIComponent(t)}/pr-review/registrations/${o}`,void 0,void 0,s);return}if(n.startsWith(\"github-installation:\")){let o=n.slice(20);if(!/^[1-9][0-9]*$/.test(o)||!Number.isSafeInteger(Number(o)))throw Error(\"Invalid GitHub installation ID\");await this.requestJson(\"DELETE\",`/v1/workspaces/${encodeURIComponent(t)}/github/installations/${o}`,void 0,void 0,s);return}let i=s?.expectedVersion;if(i!==void 0&&(!Number.isSafeInteger(i)||i<1))throw Error(\"invalid expected connection version\");let r=i===void 0?\"\":`?expectedVersion=${i}`;await this.requestJson(\"DELETE\",`/v1/workspaces/${encodeURIComponent(t)}/connections/${encodeURIComponent(n)}${r}`,void 0,void 0,s)}}}async browseAtlassianSources(e,t){return this.requestJson(\"GET\",`/v1/workspaces/${e}/connections/atlassian/${t}/browse`)}async saveAtlassianSources(e,t,n){return this.requestJson(\"POST\",`/v1/workspaces/${e}/connections/atlassian/${t}/source`,n)}async setAtlassianLifecycle(e,t,n){return this.requestJson(\"PATCH\",`/v1/workspaces/${e}/connections/atlassian/${t}/lifecycle`,n)}async beginConnect(e,t){return this.requestJson(\"POST\",`/v1/workspaces/${e}/connect/attempts`,t)}async createWorkspace(e){return await this.requestJson(\"POST\",\"/v1/workspaces\",e)}async ensureWorkspace(e){return await this.requestJson(\"PUT\",\"/v1/workspaces/external\",e)}async getWorkspace(e){return await this.requestJson(\"GET\",`/v1/workspaces/${e}`)}async getWorkspaceState(e,t={}){let n=new URLSearchParams;if(t.attemptId)n.set(\"attemptId\",t.attemptId);let s=n.size>0?`?${n.toString()}`:\"\";return await this.requestJson(\"GET\",`/v1/workspaces/${e}/workspace-state${s}`)}async exportWorkspaceState(e,t={}){let n=new URLSearchParams;if(t.attemptId)n.set(\"attemptId\",t.attemptId);let s=n.size>0?`?${n.toString()}`:\"\";return await this.requestJson(\"GET\",`/v1/workspaces/${e}/workspace-state/export${s}`)}async updateWorkspace(e,t){return await this.requestJson(\"PATCH\",`/v1/workspaces/${e}`,t)}async listWorkspaceInstructionPolicies(e,t={}){let n=new URLSearchParams;if(t.kind!==void 0)n.set(\"kind\",t.kind);if(t.scope!==void 0)n.set(\"scope\",t.scope);if(t.roleKey!==void 0)n.set(\"roleKey\",t.roleKey);if(t.afterRevision!==void 0)n.set(\"afterRevision\",String(t.afterRevision));if(t.limit!==void 0)n.set(\"limit\",String(t.limit));let s=n.toString();return await this.requestJson(\"GET\",`/v1/workspaces/${e}/instruction-policies${s?`?${s}`:\"\"}`)}async getWorkspaceLearningHistory(e,t={}){let n=new URLSearchParams;if(t.limit!==void 0)n.set(\"limit\",String(t.limit));let s=n.toString();return await this.requestJson(\"GET\",`/v1/workspaces/${e}/learning${s?`?${s}`:\"\"}`)}async undoGovernedLearningActivation(e,t,n={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/learning/activations/${encodeURIComponent(t)}/undo`,n)}async getWorkspaceInstructionPolicyRevision(e,t){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/instruction-policies/${encodeURIComponent(t)}`)}async createWorkspaceInstructionPolicyDraft(e,t,n={}){return await this.requestSessionCommand(\"POST\",`/v1/workspaces/${e}/instruction-policies/drafts`,t,n)}async listWorkspaceInstructionPolicyOnboardingProposals(e,t={}){let n=new URLSearchParams;if(t.limit!==void 0)n.set(\"limit\",String(t.limit));let s=n.toString();return await this.requestJson(\"GET\",`/v1/workspaces/${e}/instruction-policies/onboarding-proposals${s?`?${s}`:\"\"}`)}async createWorkspaceInstructionPolicyOnboardingProposal(e,t){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/instruction-policies/onboarding-proposals`,t)}async importLegacyWorkspaceInstructionPolicyDraft(e,t={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/instruction-policies/import-legacy`,t)}async diffWorkspaceInstructionPolicyRevisions(e,t){let n=new URLSearchParams({fromRevisionId:t.fromRevisionId,toRevisionId:t.toRevisionId});return await this.requestJson(\"GET\",`/v1/workspaces/${e}/instruction-policies/diff?${n}`)}async activateWorkspaceInstructionPolicyRevision(e,t,n,s={}){return await this.requestSessionCommand(\"POST\",`/v1/workspaces/${e}/instruction-policies/${encodeURIComponent(t)}/activate`,n,s)}async rollbackWorkspaceInstructionPolicyRevision(e,t){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/instruction-policies/rollback`,t)}async listCompanyProfile(e,t={}){let n=new URLSearchParams;if(t.afterRevision!==void 0)n.set(\"afterRevision\",String(t.afterRevision));if(t.limit!==void 0)n.set(\"limit\",String(t.limit));let s=n.toString();return await this.requestJson(\"GET\",`/v1/workspaces/${e}/company-profile${s?`?${s}`:\"\"}`)}async getCompanyProfileRevision(e,t){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/company-profile/revisions/${encodeURIComponent(t)}`)}async getCompanyProfileAgentPolicy(e){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/company-profile/agent-policy`)}async updateCompanyProfileAgentPolicy(e,t){return await this.requestJson(\"PATCH\",`/v1/workspaces/${e}/company-profile/agent-policy`,t)}async updateCompanyProfile(e,t){return await this.requestJson(\"PUT\",`/v1/workspaces/${e}/company-profile`,t)}async diffCompanyProfileRevisions(e,t){let n=new URLSearchParams(t);return await this.requestJson(\"GET\",`/v1/workspaces/${e}/company-profile/diff?${n}`)}async activateCompanyProfileRevision(e,t,n){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/company-profile/revisions/${encodeURIComponent(t)}/activate`,n)}async rollbackCompanyProfile(e,t){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/company-profile/rollback`,t)}async listPreferenceRegistry(e,t={}){let n=new URLSearchParams;if(t.scope)n.set(\"scope\",t.scope);if(t.status)n.set(\"status\",t.status);if(t.limit!==void 0)n.set(\"limit\",String(t.limit));let s=n.toString();return await this.requestJson(\"GET\",`/v1/workspaces/${e}/preferences${s?`?${s}`:\"\"}`)}async getPreferenceRegistry(e,t){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/preferences/${encodeURIComponent(t)}`)}async createPreferenceRegistryProposal(e,t){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/preferences/proposals`,t)}async activatePreferenceRegistryRevision(e,t,n){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/preferences/${encodeURIComponent(t)}/activate`,n)}async correctPreferenceRegistry(e,t,n){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/preferences/${encodeURIComponent(t)}/correct`,n)}async changePreferenceRegistryScope(e,t,n){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/preferences/${encodeURIComponent(t)}/scope`,n)}async deactivatePreferenceRegistry(e,t,n){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/preferences/${encodeURIComponent(t)}/deactivate`,n)}async supersedePreferenceRegistry(e,t,n){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/preferences/${encodeURIComponent(t)}/supersede`,n)}async rejectPreferenceRegistryProposal(e,t,n){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/preferences/${encodeURIComponent(t)}/reject`,n)}async getPreferenceRegistrySummary(e){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/preferences/summary`)}async getPreferenceRegistryFullContent(e,t){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/preferences/full-content`,{retrievalHandle:t})}async deleteWorkspace(e){await this.requestVoid(\"DELETE\",`/v1/workspaces/${e}`)}async listWorkspaceMembers(e){return(await this.requestJson(\"GET\",`/v1/workspaces/${e}/members`)).members}async listWorkspaceMemberCandidates(e){return(await this.requestJson(\"GET\",`/v1/workspaces/${e}/member-candidates`)).members}async addWorkspaceMember(e,t){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/members`,t)}async updateWorkspaceMember(e,t,n){return await this.requestJson(\"PATCH\",`/v1/workspaces/${e}/members/${encodeURIComponent(t)}`,n)}async removeWorkspaceMember(e,t){await this.requestVoid(\"DELETE\",`/v1/workspaces/${e}/members/${encodeURIComponent(t)}`)}async prepareSlackUserLinkAccess(e,t){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/integrations/slack/user-link-intents`,t)}async getSlackUserLinkAccess(e,t){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/integrations/slack/user-link-intents/${t}`)}async requestSlackUserLinkWorkspaceAccess(e,t,n){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/integrations/slack/user-link-intents/${t}/request-access`,n)}async cancelSlackUserLinkAccess(e,t,n){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/integrations/slack/user-link-intents/${t}/cancel`,n)}async listSlackUserLinkAccessRequests(e){return(await this.requestJson(\"GET\",`/v1/workspaces/${e}/members/access-requests/slack`)).requests}async approveSlackUserLinkAccessRequest(e,t,n){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/members/access-requests/slack/${t}/approve`,n)}async denySlackUserLinkAccessRequest(e,t,n){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/members/access-requests/slack/${t}/deny`,n)}async createScheduledTask(e,t){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/scheduled-tasks`,Vn(t))}async updateScheduledTask(e,t,n){return await this.requestJson(\"PATCH\",`/v1/workspaces/${e}/scheduled-tasks/${t}`,Vn(n))}async pauseScheduledTask(e,t){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/scheduled-tasks/${t}/pause`)}async listPrivateScheduledTaskSummaries(e){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/scheduled-tasks/private-summaries`)}async pausePrivateScheduledTask(e,t){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/scheduled-tasks/private-summaries/${t}/pause`)}async resumeScheduledTask(e,t){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/scheduled-tasks/${t}/resume`)}async triggerScheduledTask(e,t,n={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/scheduled-tasks/${t}/trigger`,n.triggerId?{triggerId:n.triggerId}:void 0)}async deleteScheduledTask(e,t){await this.requestJson(\"DELETE\",`/v1/workspaces/${e}/scheduled-tasks/${t}`)}async listScheduledTaskRuns(e,t,n={}){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/scheduled-tasks/${t}/runs`,void 0,{...n.limit!==void 0?{limit:String(n.limit)}:{}})}async refreshScheduledTaskAccess(e,t,n){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/scheduled-tasks/${t}/refresh-access`,n)}async listScheduledTaskAccessAttention(e){return(await this.requestJson(\"GET\",`/v1/workspaces/${e}/scheduled-tasks/attention`)).tasks}vaults(e){return xt(this,e)}async listChannels(e){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/channels`)}async createChannel(e,t){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/channels`,t)}async updateChannel(e,t,n){return await this.requestJson(\"PATCH\",`/v1/workspaces/${e}/channels/${t}`,n)}async reorderChannels(e,t){return await this.requestJson(\"PUT\",`/v1/workspaces/${e}/channels/order`,t)}async deleteChannel(e,t){await this.requestJson(\"DELETE\",`/v1/workspaces/${e}/channels/${t}`)}async updateSessionChannel(e,t,n){return await this.requestJson(\"PUT\",`${g(e,t)}/channel`,n)}async listRigs(e){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/rigs`)}async createRig(e,t){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/rigs`,t)}async getRig(e,t){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/rigs/${t}`)}async updateRig(e,t,n){return await this.requestJson(\"PATCH\",`/v1/workspaces/${e}/rigs/${t}`,n)}async deleteRig(e,t){await this.requestJson(\"DELETE\",`/v1/workspaces/${e}/rigs/${t}`)}async listRigVersions(e,t){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/rigs/${t}/versions`)}async activateRigVersion(e,t,n){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/rigs/${t}/versions/${n}/activate`)}async listRigChanges(e,t){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/rigs/${t}/changes`)}async proposeRigChange(e,t,n){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/rigs/${t}/changes`,n)}async getRigChange(e,t,n){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/rigs/${t}/changes/${n}`)}async verifyRigChange(e,t,n){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/rigs/${t}/changes/${n}/verify`)}async promoteRigChange(e,t,n){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/rigs/${t}/changes/${n}/promote`)}async verifyRig(e,t){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/rigs/${t}/verify`)}async beginFileUpload(e,t,n={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/files/uploads`,t,{},n)}async completeFileUpload(e,t,n={}){return(await this.requestJson(\"POST\",`/v1/workspaces/${e}/files/uploads/${t}/complete`,void 0,{},n)).file}async uploadFile(e,t){if(t.timeoutMs!==void 0&&(!Number.isFinite(t.timeoutMs)||t.timeoutMs<=0))throw Error(\"File upload timeout must be a positive number\");Vi();let n=async(u,l)=>{let p=new AbortController,d,m=new Promise((y,R)=>{d=setTimeout(()=>{p.abort(),R(Error(\"File upload timed out. Retry the upload.\"))},u)});try{return await Promise.race([l(p.signal),m])}finally{if(d!==void 0)clearTimeout(d)}},s=t.data instanceof Uint8Array?new Blob([t.data.slice()]):t.data instanceof ArrayBuffer?t.data.slice(0):t.data,i=typeof s===\"string\"?new TextEncoder().encode(s).byteLength:s instanceof Blob?s.size:s.byteLength,r=t.sha256??await Hi(s),o=await n(30000,async(u)=>await this.beginFileUpload(e,{filename:t.filename,contentType:t.contentType,...t.scope?{scope:t.scope}:{},sizeBytes:i,sha256:r,...t.appShot?{appShot:t.appShot}:{}},{signal:u})),a=t.timeoutMs??Math.max(120000,Math.ceil(i/262144)*1000),c=await n(a,async(u)=>await this.fetchImpl(o.putUrl,{method:\"PUT\",credentials:\"omit\",headers:{...o.requiredHeaders},body:s,signal:u}));if(!c.ok)throw await M(c,{method:\"PUT\"});return await n(30000,async(u)=>await this.completeFileUpload(e,o.uploadId,{signal:u}))}async listFiles(e,t={}){let n=new URLSearchParams;if(t.scope)n.set(\"scope\",t.scope);if(t.limit!==void 0)n.set(\"limit\",String(t.limit));if(t.cursor)n.set(\"cursor\",t.cursor);return this.requestJson(\"GET\",`/v1/workspaces/${e}/files${n.size?`?${n}`:\"\"}`)}async updateFileVisibility(e,t,n,s={}){return await this.requestJson(\"PUT\",`/v1/workspaces/${encodeURIComponent(e)}/files/${encodeURIComponent(t)}/visibility`,n,void 0,s)}async getFile(e,t,n={}){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/files/${t}${n.sessionId?`?sessionId=${encodeURIComponent(n.sessionId)}`:\"\"}`,void 0,{},n)}async getRetainedArtifact(e,t){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/artifacts/${t}`)}async getRetainedArtifactContent(e,t,n={}){return await this.getRetainedArtifactContentAtPath(`/v1/workspaces/${e}/artifacts/${t}/content`,n)}async getSessionRetainedArtifact(e,t,n){return await this.requestJson(\"GET\",`${g(e,t)}/artifacts/${n}`)}async getSessionRetainedArtifactContent(e,t,n,s={}){return await this.getRetainedArtifactContentAtPath(`${g(e,t)}/artifacts/${n}/content`,s)}async downloadRetainedArtifact(e,t,n={}){jn(e,t);let s=await this.downloadRetainedArtifactBytes(t,n);return{artifact:t,bytes:s}}async createRetainedArtifactDownloadUrl(e,t,n={}){jn(e,t);let s=await this.createFileDownloadUrl(e,t.artifactId,n);return Xn(s),s}async downloadRetainedScreenshot(e,t,n,s={}){let i=await this.getSessionRetainedArtifact(e,t,n);if(!i.available)return{metadata:i,bytes:null};if(!((i.kind===\"computer_screenshot\"||i.kind===\"browser_screenshot\")&&[\"image/png\",\"image/jpeg\",\"image/webp\"].includes(i.contentType))||!i.dimensions||i.originalBytes<=0||i.originalBytes>Tn)throw A(\"retained screenshot metadata is invalid\");let o=await this.downloadRetainedArtifactBytes(i,s);return{metadata:i,bytes:o}}async downloadRetainedArtifactBytes(e,t){let n=t.maxRetries??2;if(!Number.isInteger(n)||n<0||n>3)throw RangeError(\"retained artifact maxRetries must be an integer from 0 to 3\");let s=new Uint8Array(e.originalBytes),i=Math.min(e.retrieval.maxRangeBytes,qe);if(!Number.isSafeInteger(i)||i<=0)throw A(\"retained artifact range metadata is invalid\");for(let r=0;r<s.byteLength;r+=i){t.signal?.throwIfAborted();let o=Math.min(r+i,s.byteLength)-1,a=null;for(let u=0;u<=n;u+=1)try{a=await this.getRetainedArtifactContentAtPath(e.retrieval.path,{range:`bytes=${r}-${o}`,...t.signal?{signal:t.signal}:{}});break}catch(l){if(t.signal?.throwIfAborted(),u>=n||l instanceof P&&l.status>=400&&l.status<500)throw l}if(!a)throw A(\"retained artifact range retry exhausted\");let c=o-r+1;if(a.status!==206||a.contentType!==e.contentType||a.contentLength!==c||a.contentRange!==`bytes ${r}-${o}/${e.originalBytes}`)throw A(\"retained artifact range response is invalid\");s.set(a.bytes,r)}if(await Kn(s)!==e.sha256)throw A(\"retained artifact checksum mismatch\");return s}async getRetainedArtifactContentAtPath(e,t){if(t.range&&(t.range.length>128||/[^\\\\x20-\\\\x7e]/.test(t.range)))throw RangeError(\"retained artifact range must be at most 128 printable ASCII bytes\");let n=crypto.randomUUID(),s=await this.fetchImpl(this.url(e),{method:\"GET\",headers:{...this.headers(n),Accept:\"application/octet-stream\",...t.range?{Range:t.range}:{}},...t.signal?{signal:t.signal}:{}});try{D(s,this.apiContractStrict)}catch(o){throw await U(s,\"retained artifact API contract mismatch\"),o}if(!s.ok)throw await M(s,{method:\"GET\",correlationId:n});if(s.status!==200&&s.status!==206)throw await U(s,\"unexpected retained artifact response status\"),new P(s.status,\"unexpected retained artifact response status\");if(s.headers.get(\"accept-ranges\")!==\"bytes\")throw await U(s,\"retained artifact response omitted byte-range support\"),A(\"retained artifact response omitted byte-range support\");let i;try{i=Yi(s.headers.get(\"content-length\"))}catch(o){throw await U(s,\"invalid retained artifact content-length\"),o}let r=await he(s,qe,i);return{bytes:r,status:s.status,contentType:s.headers.get(\"content-type\")??\"application/octet-stream\",contentLength:r.byteLength,contentRange:s.headers.get(\"content-range\"),acceptRanges:\"bytes\"}}async createFileDownloadUrl(e,t,n={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/files/${t}/download-url${n.sessionId?`?sessionId=${encodeURIComponent(n.sessionId)}`:\"\"}`,void 0,{},n)}async getVideoGenerationSettings(e,t={}){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/video-generation`,void 0,{},t)}async updateVideoGenerationPolicy(e,t,n={}){return await this.requestJson(\"PUT\",`/v1/workspaces/${e}/video-generation/policy`,t,{},n)}async getVideoGenerationOperation(e,t,n={}){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/video-generation/operations/${t}`,void 0,{},n)}async createVideoArtifactPlaybackSource(e,t,n={}){let s=await this.requestJson(\"POST\",`/v1/workspaces/${e}/artifacts/${t}/playback-source`,void 0,{},n);return ji(s,t),s}async createDocumentBase(e,t){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/document-bases`,t)}async getDocumentBase(e,t){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/document-bases/${t}`)}async addDocument(e,t,n){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/document-bases/${t}/documents`,n)}async listDocuments(e,t){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/document-bases/${t}/documents`)}async getDocumentOriginalFile(e,t){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/documents/${t}/original-file`)}async createKnowledgeDrop(e,t){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/knowledge/drops`,t)}async moveDocument(e,t,n={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/documents/${t}/move`,n)}async deleteDocument(e,t,n){await this.requestVoid(\"DELETE\",`/v1/workspaces/${e}/document-bases/${t}/documents/${n}`)}async listKnowledgeEntries(e,t={}){return this.requestJson(\"POST\",`/v1/workspaces/${e}/knowledge/entries/search`,t)}async getKnowledgeEntry(e,t,n={}){let s=new URLSearchParams;if(n.revisionId!==void 0)s.set(\"revisionId\",n.revisionId);if(n.view!==void 0)s.set(\"view\",n.view);let i=s.toString();return this.requestJson(\"GET\",`/v1/workspaces/${e}/knowledge/entries/${t}${i?`?${i}`:\"\"}`)}async createKnowledgeFileDownloadUrl(e,t,n){return this.requestJson(\"POST\",`/v1/workspaces/${e}/knowledge/entries/${t}/file/download-url`,n?{revisionId:n}:{})}async saveKnowledgeEntry(e,t){return this.requestJson(\"POST\",`/v1/workspaces/${e}/knowledge/entries`,t)}async reviewKnowledgeEntry(e,t){let{entryId:n,...s}=t;return this.requestJson(\"POST\",`/v1/workspaces/${e}/knowledge/entries/${n}/review`,s)}async listKnowledgeReviewBatches(e,t={}){let n=new URLSearchParams;for(let[s,i]of Object.entries(t))if(i!==void 0)n.set(s,String(i));return this.requestJson(\"GET\",`/v1/workspaces/${e}/knowledge/review-groups?${n}`)}async reviewKnowledgeEntries(e,t){return this.requestJson(\"POST\",`/v1/workspaces/${e}/knowledge/entries/review`,t)}async listKnowledgeEntryHistory(e,t,n){return this.requestJson(\"GET\",`/v1/workspaces/${e}/knowledge/entries/${t}/history${n?`?beforeRevision=${n}`:\"\"}`)}async restoreKnowledgeEntry(e,t){let{entryId:n,...s}=t;return this.requestJson(\"POST\",`/v1/workspaces/${e}/knowledge/entries/${n}/restore`,s)}async archiveKnowledgeEntry(e,t,n){return this.requestJson(\"POST\",`/v1/workspaces/${e}/knowledge/entries/${t}/archive`,n)}async getAgentLearningSettings(e,t,n){return this.requestJson(\"POST\",`/v1/workspaces/${e}/agent-learning/read`,{scope:t,source:n})}async saveAgentLearningSettings(e,t){return this.requestJson(\"POST\",`/v1/workspaces/${e}/agent-learning`,t)}async listAgentLearningOverrides(e,t){return this.requestJson(\"GET\",`/v1/workspaces/${e}/agent-learning/overrides?scope=${t}`)}async reviewAgentInstruction(e,t){return this.requestJson(\"POST\",`/v1/workspaces/${e}/agent-learning/instructions/review`,t)}async listAgentInstructionReviews(e,t){return this.requestJson(\"GET\",`/v1/workspaces/${e}/agent-learning/instructions/reviews${t?`?cursor=${encodeURIComponent(t)}`:\"\"}`)}async updateWorkspaceSettings(e,t){return await this.requestJson(\"PATCH\",`/v1/workspaces/${e}/settings`,t)}async setWorkspaceDefaultRig(e,t){return await this.requestJson(\"PUT\",`/v1/workspaces/${e}/default-rig`,t)}async listCapabilities(e){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/capabilities`)}async createCapability(e,t){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/capabilities`,t)}async getConnectorToolPermissions(e,t,n={}){let s=new URLSearchParams;if(n.connectionId)s.set(\"connectionId\",n.connectionId);if(n.instanceKey)s.set(\"instanceKey\",n.instanceKey);return await this.requestJson(\"GET\",`/v1/workspaces/${e}/capabilities/${encodeURIComponent(t)}/tool-permissions${s.size?`?${s}`:\"\"}`,void 0,{},n)}async updateConnectorToolPermissions(e,t,n,s={}){return await this.requestJson(\"PATCH\",`/v1/workspaces/${e}/capabilities/${encodeURIComponent(t)}/tool-permissions`,n,{},s)}async getSessionMcpToolPermissions(e,t,n={}){let s=new URLSearchParams({serverId:t.serverId,url:t.url});return await this.requestJson(\"GET\",`/v1/workspaces/${e}/session-mcp-tool-permissions?${s}`,void 0,{},n)}async updateSessionMcpToolPermissions(e,t,n={}){return await this.requestJson(\"PATCH\",`/v1/workspaces/${e}/session-mcp-tool-permissions`,t,{},n)}async enableCapability(e,t,n={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/capabilities/${encodeURIComponent(t)}/enable`,n)}async disableCapability(e,t){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/capabilities/${encodeURIComponent(t)}/disable`)}async listArtifactCatalog(e,t={}){let n=new URLSearchParams;for(let i of[\"sourceSessionId\",\"q\",\"kind\",\"sort\",\"status\",\"limit\",\"cursor\"])if(t[i]!==void 0)n.set(i,String(t[i]));let s=n.size?`?${n.toString()}`:\"\";return this.requestJson(\"GET\",`/v1/workspaces/${encodeURIComponent(e)}/artifact-catalog${s}`,void 0,void 0,t)}async updateArtifactPin(e,t,n,s,i={}){return this.requestJson(\"PUT\",`/v1/workspaces/${encodeURIComponent(e)}/artifact-catalog/${encodeURIComponent(t)}/${encodeURIComponent(n)}/pin`,{pinned:s},void 0,i)}async listWorkspaceArtifacts(e,t={}){let n=new URLSearchParams;if(t.limit!==void 0)n.set(\"limit\",String(t.limit));if(t.cursor)n.set(\"cursor\",t.cursor);if(t.status)n.set(\"status\",t.status);if(t.sourceSessionId)n.set(\"sourceSessionId\",t.sourceSessionId);let s=n.size>0?`?${n.toString()}`:\"\";return await this.requestJson(\"GET\",`/v1/workspaces/${encodeURIComponent(e)}/published-artifacts${s}`,void 0,void 0,t)}async getWorkspaceArtifact(e,t,n={}){return await this.requestJson(\"GET\",`/v1/workspaces/${encodeURIComponent(e)}/published-artifacts/${encodeURIComponent(t)}`,void 0,void 0,n)}async getWorkspaceArtifactHtml(e,t,n){return(await this.requestResponse(\"GET\",`/v1/workspaces/${encodeURIComponent(e)}/published-artifacts/${encodeURIComponent(t)}/html`,{versionId:n.versionId},n)).text()}async rollbackWorkspaceArtifact(e,t,n,s={}){return await this.requestJson(\"POST\",`/v1/workspaces/${encodeURIComponent(e)}/published-artifacts/${encodeURIComponent(t)}/rollback`,n,void 0,s)}async duplicateWorkspaceArtifact(e,t,n,s={}){return await this.requestJson(\"POST\",`/v1/workspaces/${encodeURIComponent(e)}/published-artifacts/${encodeURIComponent(t)}/duplicate`,n,void 0,s)}async setWorkspaceArtifactStatus(e,t,n,s={}){return await this.requestJson(\"PATCH\",`/v1/workspaces/${encodeURIComponent(e)}/published-artifacts/${encodeURIComponent(t)}/status`,n,void 0,s)}async updateWorkspaceArtifactVisibility(e,t,n,s={}){return await this.requestJson(\"PUT\",`/v1/workspaces/${encodeURIComponent(e)}/published-artifacts/${encodeURIComponent(t)}/visibility`,n,void 0,s)}async getSiteData(e,t,n={}){return await this.requestJson(\"GET\",`${O(e,t)}/data`,void 0,void 0,n)}async defineSiteDataCollection(e,t,n,s,i={}){return await this.requestJson(\"PUT\",`${O(e,t)}/data/collections/${encodeURIComponent(n)}`,s,void 0,i)}async deleteSiteDataCollection(e,t,n,s={}){return await this.requestJson(\"DELETE\",`${O(e,t)}/data/collections/${encodeURIComponent(n)}`,void 0,{confirm:\"true\"},s)}async resetSiteDataCollection(e,t,n,s={}){return await this.requestJson(\"POST\",`${O(e,t)}/data/collections/${encodeURIComponent(n)}/reset`,{confirm:!0},void 0,s)}async querySiteData(e,t,n,s={}){return await this.requestJson(\"POST\",`${O(e,t)}/data/query`,n,void 0,s)}async writeSiteData(e,t,n,s={}){return await this.requestJson(\"POST\",`${O(e,t)}/data/write`,n,void 0,s)}async importSiteData(e,t,n,s,i={}){return await this.requestJson(\"POST\",`${O(e,t)}/data/collections/${encodeURIComponent(n)}/import`,s,void 0,i)}async exportSiteData(e,t,n,s={}){let i=s.format??\"json\",r=await this.requestResponse(\"GET\",`${O(e,t)}/data/collections/${encodeURIComponent(n)}/export`,{format:i},{...s,accept:i===\"csv\"?\"text/csv\":\"application/json\"});return{content:await r.text(),contentType:r.headers.get(\"content-type\")??\"\",truncated:r.headers.get(\"x-opengeni-export-truncated\")===\"true\"}}async listSiteDataFiles(e,t,n={}){return await this.requestJson(\"GET\",`${O(e,t)}/files`,void 0,{...n.limit===void 0?{}:{limit:String(n.limit)},...n.cursor?{cursor:n.cursor}:{}},n)}async getSiteDataFileUrl(e,t,n,s={}){return await this.requestJson(\"GET\",`${O(e,t)}/files/${encodeURIComponent(n)}`,void 0,void 0,s)}async deleteSiteDataFile(e,t,n,s={}){return await this.requestJson(\"DELETE\",`${O(e,t)}/files/${encodeURIComponent(n)}`,void 0,void 0,s)}async getSiteSql(e,t,n={}){return await this.requestJson(\"GET\",`${O(e,t)}/sql`,void 0,void 0,n)}async updateSiteSqlSettings(e,t,n,s={}){return await this.requestJson(\"PUT\",`${O(e,t)}/sql/settings`,n,void 0,s)}async migrateSiteSql(e,t,n,s={}){return await this.requestJson(\"POST\",`${O(e,t)}/sql/migrations`,n,void 0,s)}async defineSiteSqlQuery(e,t,n,s,i={}){return await this.requestJson(\"PUT\",`${O(e,t)}/sql/queries/${encodeURIComponent(n)}`,s,void 0,i)}async deleteSiteSqlQuery(e,t,n,s={}){return await this.requestJson(\"DELETE\",`${O(e,t)}/sql/queries/${encodeURIComponent(n)}`,void 0,void 0,s)}async runSiteSqlQuery(e,t,n,s={},i={}){return await this.requestJson(\"POST\",`${O(e,t)}/sql/queries/${encodeURIComponent(n)}`,s,void 0,i)}async querySiteSql(e,t,n,s={}){return await this.requestJson(\"POST\",`${O(e,t)}/sql/query`,n,void 0,s)}async executeSiteSql(e,t,n,s={}){return await this.requestJson(\"POST\",`${O(e,t)}/sql/execute`,n,void 0,s)}async inspectSiteSql(e,t,n={}){return await this.requestJson(\"GET\",`${O(e,t)}/sql/inspect`,void 0,void 0,n)}async exportSiteSql(e,t,n={}){let s=n.format??\"sql\",i=await this.requestResponse(\"GET\",`${O(e,t)}/sql/export`,{format:s,...n.table?{table:n.table}:{},...n.cursor?{cursor:n.cursor}:{},...n.maxBytes!==void 0?{maxBytes:String(n.maxBytes)}:{}},{...n,accept:s===\"json\"?\"application/json\":\"*/*\"});return{content:await i.text(),contentType:i.headers.get(\"content-type\")??\"\",truncated:i.headers.get(\"x-opengeni-export-truncated\")===\"true\",nextCursor:i.headers.get(\"x-opengeni-export-next-cursor\")||null}}async importSiteSql(e,t,n,s={}){return await this.requestJson(\"POST\",`${O(e,t)}/sql/import`,n,void 0,s)}async resetSiteSql(e,t,n={},s={}){return await this.requestJson(\"POST\",`${O(e,t)}/sql/reset`,{confirm:!0,...n},void 0,s)}async getSitePublication(e,t,n={}){return await this.requestJson(\"GET\",X(e,t),void 0,void 0,n)}async updateSitePublication(e,t,n,s={}){return await this.requestJson(\"PUT\",X(e,t),n,void 0,s)}async unpublishSite(e,t,n={}){return await this.requestJson(\"DELETE\",X(e,t),void 0,void 0,n)}async applySitePublicationFix(e,t,n,s={}){return await this.requestJson(\"POST\",`${X(e,t)}/fixes`,n,void 0,s)}async getSitePlatformUsage(e,t={}){return await this.requestJson(\"GET\",`/v1/workspaces/${encodeURIComponent(e)}/site-platform-usage`,void 0,void 0,t)}async checkSiteHostname(e,t,n={}){return await this.requestJson(\"GET\",`/v1/workspaces/${encodeURIComponent(e)}/site-hostnames/${encodeURIComponent(t)}`,void 0,void 0,n)}async takeDownSite(e,t,n,s={}){return await this.requestJson(\"POST\",`${X(e,t)}/takedown`,n,void 0,s)}async restoreSite(e,t,n={}){return await this.requestJson(\"POST\",`${X(e,t)}/restore`,{},void 0,n)}async listSiteAbuseReports(e,t,n={}){return await this.requestJson(\"GET\",`${X(e,t)}/reports`,void 0,void 0,n)}async updateSiteAbuseReport(e,t,n,s,i={}){return await this.requestJson(\"PATCH\",`${X(e,t)}/reports/${encodeURIComponent(n)}`,s,void 0,i)}async getSiteLimitProfile(e,t={}){return await this.requestJson(\"GET\",`/v1/workspaces/${encodeURIComponent(e)}/site-limit-profile`,void 0,void 0,t)}async updateSiteLimitProfile(e,t,n={}){return await this.requestJson(\"PUT\",`/v1/workspaces/${encodeURIComponent(e)}/site-limit-profile`,t,void 0,n)}async authorizeSiteViewer(e,t={}){return await this.requestJson(\"POST\",\"/v1/site-auth/authorize\",e,void 0,t)}async discoverMcpCapabilities(e,t={}){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/capabilities/discovery/mcp-registry`,void 0,{...t.query!==void 0?{query:t.query}:{},...t.limit!==void 0?{limit:String(t.limit)}:{}})}async discoverPlugins(e,t={}){return this.requestJson(\"GET\",`/v1/workspaces/${e}/capabilities/discovery/plugins`,void 0,{...t.id?{id:t.id}:{},...t.query?{query:t.query}:{},...t.provider?{provider:t.provider}:{},...t.offset!==void 0?{offset:String(t.offset)}:{}})}async inspectMcpAuthentication(e,t){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/capabilities/discovery/mcp-auth`,{url:t})}async listApiIntegrations(e){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/integrations`)}async listIntegrationDefinitions(e){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/integrations/definitions`)}async previewApiIntegration(e,t){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/integrations/preview`,t)}async startApiIntegrationOAuth(e,t){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/integrations/oauth/start`,t)}async installApiIntegration(e,t){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/integrations/install`,t)}async previewApiIntegrationUninstall(e,t,n){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/integrations/${encodeURIComponent(t)}/instances/${encodeURIComponent(n)}/uninstall-preview`)}async uninstallApiIntegration(e,t,n,s){return await this.requestJson(\"DELETE\",`/v1/workspaces/${e}/integrations/${encodeURIComponent(t)}/instances/${encodeURIComponent(n)}`,s)}async listIntegrationFacets(e,t,n){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/integrations/${encodeURIComponent(t)}/instances/${encodeURIComponent(n)}/facets`)}async configureIntegrationFacet(e,t,n,s,i){return await this.requestJson(\"PUT\",`/v1/workspaces/${e}/integrations/${encodeURIComponent(t)}/instances/${encodeURIComponent(n)}/facets/${encodeURIComponent(s)}`,i)}async browseGoogleDriveFacetSource(e,t,n,s,i={}){let r=new URLSearchParams;if(i.parentId)r.set(\"parentId\",i.parentId);if(i.pageToken)r.set(\"pageToken\",i.pageToken);let o=r.size>0?`?${r}`:\"\";return await this.requestJson(\"GET\",`/v1/workspaces/${e}/integrations/${encodeURIComponent(t)}/instances/${encodeURIComponent(n)}/facets/${encodeURIComponent(s)}/browse${o}`)}async saveGoogleDriveFacetSource(e,t,n,s,i){return await this.requestJson(\"PUT\",`/v1/workspaces/${e}/integrations/${encodeURIComponent(t)}/instances/${encodeURIComponent(n)}/facets/${encodeURIComponent(s)}/source`,i)}async pauseIntegrationFacet(e,t,n,s,i){return await this.mutateIntegrationFacetLifecycle(e,t,n,s,\"pause\",i)}async resumeIntegrationFacet(e,t,n,s,i){return await this.mutateIntegrationFacetLifecycle(e,t,n,s,\"resume\",i)}async removeIntegrationFacet(e,t,n,s,i){return await this.requestJson(\"DELETE\",`/v1/workspaces/${e}/integrations/${encodeURIComponent(t)}/instances/${encodeURIComponent(n)}/facets/${encodeURIComponent(s)}`,i)}async mutateIntegrationFacetLifecycle(e,t,n,s,i,r){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/integrations/${encodeURIComponent(t)}/instances/${encodeURIComponent(n)}/facets/${encodeURIComponent(s)}/${i}`,r)}async previewPlugin(e,t){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/plugins/preview`,t)}async getInstalledPluginDetails(e,t){return this.requestJson(\"GET\",`/v1/workspaces/${e}/plugins/details`,void 0,{pluginKey:t})}async listInstalledPlugins(e){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/plugins`)}async installPlugin(e,t){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/plugins/install`,t)}async previewPluginUninstall(e,t){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/plugins/${encodeURIComponent(t)}/uninstall-preview`)}async uninstallPlugin(e,t,n){return await this.requestJson(\"DELETE\",`/v1/workspaces/${e}/plugins/${encodeURIComponent(t)}`,n)}async previewSkillImport(e,t){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/skills/preview`,t)}async installSkill(e,t){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/skills/install`,t)}async listInstalledSkills(e){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/skills`)}async listWorkspaceSkills(e,t={}){let n=new URLSearchParams;if(t.cursor!==void 0)n.set(\"cursor\",t.cursor);if(t.limit!==void 0)n.set(\"limit\",String(t.limit));if(t.sessionId!==void 0)n.set(\"sessionId\",t.sessionId);let s=n.size?`?${n.toString()}`:\"\";return this.requestJson(\"GET\",`/v1/workspaces/${e}/skills/content${s}`)}async readWorkspaceSkill(e,t,n){let s=n?`?revisionId=${encodeURIComponent(n)}`:\"\";return this.requestJson(\"GET\",`/v1/workspaces/${e}/skills/content/${encodeURIComponent(t)}${s}`)}async saveWorkspaceSkill(e,t){return this.requestJson(\"POST\",`/v1/workspaces/${e}/skills/content/save`,t)}async removeWorkspaceSkill(e,t,n){return this.requestJson(\"POST\",`/v1/workspaces/${e}/skills/content/${encodeURIComponent(t)}/remove`,n)}async approveWorkspaceSkill(e,t,n){return this.requestJson(\"POST\",`/v1/workspaces/${e}/skills/content/${encodeURIComponent(t)}/approve`,n)}async restoreWorkspaceSkill(e,t,n){return this.requestJson(\"POST\",`/v1/workspaces/${e}/skills/content/${encodeURIComponent(t)}/restore`,n)}async rejectWorkspaceSkill(e,t,n){return this.requestJson(\"POST\",`/v1/workspaces/${e}/skills/content/${encodeURIComponent(t)}/reject`,n)}async installLibrarySkill(e,t,n){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/skills/library/${encodeURIComponent(t)}/install`,n)}async previewSkillUninstall(e,t){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/skills/${encodeURIComponent(t)}/uninstall-preview`)}async uninstallSkill(e,t,n){return await this.requestJson(\"DELETE\",`/v1/workspaces/${e}/skills/${encodeURIComponent(t)}`,n)}async listOwnConnectionAccounts(e,t={}){return(await this.requestJson(\"GET\",`/v1/workspaces/${e}/connections/accounts`,void 0,t.includeInactive===!0?{includeInactive:\"true\"}:{})).connections}async listConnections(e){return(await this.requestJson(\"GET\",`/v1/workspaces/${e}/connections`)).connections}async personalGitHubStatus(e){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/connections/github`)}async startPersonalGitHubOAuth(e,t={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/connections/github/oauth/start`,t)}async reconnectPersonalGitHub(e,t,n={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/connections/${t}/github/reconnect`,n)}async disconnectPersonalGitHub(e,t,n){return(await this.requestJson(\"DELETE\",`/v1/workspaces/${e}/connections/${t}`,n)).connection}async listPersonalGitHubRepositories(e,t,n={}){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/connections/${t}/github/repositories`,void 0,{...n.cursor!==void 0?{cursor:String(n.cursor)}:{},...n.limit!==void 0?{limit:String(n.limit)}:{}})}async replacePersonalGitHubRepositorySelections(e,t,n){return await this.requestJson(\"PUT\",`/v1/workspaces/${e}/connections/${t}/github/repositories`,n)}async verifyPersonalGitHubRepositorySelections(e,t,n){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/connections/${t}/github/repositories/verify`,n)}async listSlackInstallationBindings(e){return(await this.requestJson(\"GET\",`/v1/workspaces/${e}/connections/slack-bot/bindings`)).bindings}async createConnection(e,t){return(await this.requestJson(\"POST\",`/v1/workspaces/${e}/connections`,t)).connection}async installFikenConnection(e,t){return(await this.requestJson(\"POST\",`/v1/workspaces/${e}/connections/fiken/install`,t)).connection}async startFikenOAuth(e,t={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/connections/fiken/oauth/start`,t)}async listAvailableOpenGeniSlackBots(e){return this.requestJson(\"GET\",`/v1/workspaces/${e}/connections/slack-bot/available`)}async getOpenGeniSlackBotOrganizationAccess(e,t){return this.requestJson(\"GET\",`/v1/workspaces/${e}/connections/${t}/slack-bot/organization-access`)}async setOpenGeniSlackBotOrganizationAccess(e,t,n){return this.requestJson(\"PUT\",`/v1/workspaces/${e}/connections/${t}/slack-bot/organization-access`,n)}async startOpenGeniSlackBotInstall(e,t={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/connections/slack-bot/install`,t)}async listOpenGeniSlackReactionChannels(e,t,n){let s=new URLSearchParams({connectionId:t});if(n)s.set(\"cursor\",n);return await this.requestJson(\"GET\",`/v1/workspaces/${e}/integrations/slack/reaction-channels?${s}`)}async listOpenGeniSlackChannelRoutes(e,t){let n=new URLSearchParams({connectionId:t});return await this.requestJson(\"GET\",`/v1/workspaces/${e}/integrations/slack/channel-routes?${n}`)}async updateOpenGeniSlackChannelRoutes(e,t){await this.requestJson(\"PUT\",`/v1/workspaces/${e}/integrations/slack/channel-routes`,t)}async updateConnection(e,t,n){return(await this.requestJson(\"PATCH\",`/v1/workspaces/${e}/connections/${t}`,n)).connection}async deleteConnection(e,t){return(await this.requestJson(\"DELETE\",`/v1/workspaces/${e}/connections/${t}`)).connection}async disconnectGoogleDriveConnection(e,t,n){return(await this.requestJson(\"DELETE\",`/v1/workspaces/${e}/connections/${t}`,n)).connection}async transitionGoogleDriveLifecycle(e,t,n){return(await this.requestJson(\"PATCH\",`/v1/workspaces/${e}/connections/google-drive/${t}/lifecycle`,n)).connection}async startConnectionOAuth(e,t,n={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/connections/oauth/start`,t,{},n)}async startSocialOAuth(e,t){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/social/oauth/start`,t)}async listSocialConnections(e){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/social/connections`)}async disconnectSocialConnection(e,t){return await this.requestJson(\"DELETE\",`/v1/workspaces/${e}/social/connections/${t}`)}catalogAssetUrl(e){return e?`${this.baseUrl}/v1/${e}`:null}async downloadCatalogAsset(e,t={}){if(!/^catalog-assets\\\\/[a-zA-Z0-9_./-]+$/.test(e)||e.split(\"/\").some((r)=>!r||r===\".\"||r===\"..\"))throw TypeError(\"A catalog asset path is required\");let n=await this.requestResponse(\"GET\",`/v1/${e}`,{},t),s=n.headers.get(\"content-type\")?.split(\";\")[0]??\"\";if(!s.startsWith(\"image/\"))throw await n.body?.cancel(),Error(\"The catalog asset is not an image\");let i=await he(n,2000000,null);return new Blob([Uint8Array.from(i)],{type:s})}async getGitHubApp(e,t={}){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/github/app`,void 0,t.returnPath?{returnPath:t.returnPath}:void 0)}githubConnectUrl(e,t){return this.url(`/v1/workspaces/${e}/github/connect`,{state:t})}async listGitHubRepositories(e){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/github/repositories`)}async getGitHubActionPolicies(e){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/github/action-policies`)}async updateGitHubActionPolicy(e,t){return await this.requestJson(\"PATCH\",`/v1/workspaces/${e}/github/action-policies`,t)}async syncGitHubRepositories(e){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/github/repositories/sync`)}async unlinkGitHubInstallation(e,t){await this.requestVoid(\"DELETE\",`/v1/workspaces/${e}/github/installations/${t}`)}async createGitHubAppManifest(e,t={}){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/github/app-manifest`,t)}async listApiKeys(e){return(await this.requestJson(\"GET\",`/v1/workspaces/${e}/api-keys`)).apiKeys}async createApiKey(e,t){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/api-keys`,t)}async deleteApiKey(e,t){return await this.requestJson(\"DELETE\",`/v1/workspaces/${e}/api-keys/${t}`)}async listOrganizationApiKeys(e){return(await this.requestJson(\"GET\",`/v1/organizations/${e}/api-keys`)).apiKeys}async createOrganizationApiKey(e,t){return await this.requestJson(\"POST\",`/v1/organizations/${e}/api-keys`,t)}async deleteOrganizationApiKey(e,t){return await this.requestJson(\"DELETE\",`/v1/organizations/${e}/api-keys/${t}`)}async listOrganizationMcpConnections(e){return await this.requestJson(\"GET\",`/v1/organizations/${e}/mcp-connections`)}async updateOrganizationMcpConnection(e,t,n){return await this.requestJson(\"PATCH\",`/v1/organizations/${e}/mcp-connections/${t}`,n)}async deleteOrganizationMcpConnection(e,t){await this.requestVoid(\"DELETE\",`/v1/organizations/${e}/mcp-connections/${t}`,{})}async listPersonalApiKeys(e){return await this.requestJson(\"GET\",`/v1/organizations/${e}/personal-api-keys`)}async createPersonalApiKey(e,t){return await this.requestJson(\"POST\",`/v1/organizations/${e}/personal-api-keys`,t)}async revokePersonalApiKey(e,t){await this.requestVoid(\"DELETE\",`/v1/organizations/${e}/personal-api-keys/${t}`,{})}async listOrganizationServiceAccounts(e){return await this.requestJson(\"GET\",`/v1/organizations/${e}/service-accounts`)}async getOrganizationServiceAccount(e,t){return await this.requestJson(\"GET\",`/v1/organizations/${e}/service-accounts/${t}`)}async createOrganizationServiceAccount(e,t){return await this.requestJson(\"POST\",`/v1/organizations/${e}/service-accounts`,t)}async updateOrganizationServiceAccount(e,t,n){return await this.requestJson(\"PATCH\",`/v1/organizations/${e}/service-accounts/${t}`,n)}async deleteOrganizationServiceAccount(e,t){await this.requestVoid(\"DELETE\",`/v1/organizations/${e}/service-accounts/${t}`)}async getMcpConnectionRequest(e){return await this.requestJson(\"GET\",`/v1/mcp-connections/requests/${encodeURIComponent(e)}`)}async answerMcpConnectionRequest(e,t){return await this.requestJson(\"POST\",`/v1/mcp-connections/requests/${encodeURIComponent(e)}`,t)}async listInbox(e={}){let t=e.workspaceId?`?workspaceId=${encodeURIComponent(e.workspaceId)}`:\"\";return await this.requestJson(\"GET\",`/v1/inbox${t}`)}async updateInboxItem(e,t){await this.requestJson(\"PATCH\",`/v1/inbox/items/${encodeURIComponent(e)}`,t)}async getInboxSettings(){return await this.requestJson(\"GET\",\"/v1/inbox/settings\")}async updateInboxSettings(e){return await this.requestJson(\"PUT\",\"/v1/inbox/settings\",e)}async getMemberNotifications(e){return await this.requestJson(\"GET\",`/v1/workspaces/${encodeURIComponent(e)}/inbox/member-notifications`)}async updateMemberNotifications(e,t){return await this.requestJson(\"PUT\",`/v1/workspaces/${encodeURIComponent(e)}/inbox/member-notifications`,t)}async getSessionInboxMute(e,t){return await this.requestJson(\"GET\",`${g(e,t)}/inbox-mute`)}async setSessionInboxMute(e,t,n){return await this.requestJson(\"PUT\",`${g(e,t)}/inbox-mute`,n)}async getSessionAdminAccess(e,t){return await this.requestJson(\"GET\",`${g(e,t)}/admin-access`)}async grantSessionAdminAccess(e,t,n={}){return await this.requestJson(\"PUT\",`${g(e,t)}/admin-access`,n)}async revokeSessionAdminAccess(e,t){return await this.requestJson(\"DELETE\",`${g(e,t)}/admin-access`)}async authorizeNativeApp(e){return await this.requestJson(\"POST\",\"/v1/native-app/authorize\",e)}async exchangeNativeAppCode(e){return await this.requestJson(\"POST\",\"/v1/native-app/token\",e)}async createOfficeWorkbookTicket(e){return await this.requestJson(\"POST\",`/v1/workspaces/${encodeURIComponent(e)}/office/workbook-tickets`,{})}async listOfficeWorkbooks(e){let{workbooks:t}=await this.requestJson(\"GET\",`/v1/workspaces/${encodeURIComponent(e)}/office/workbooks`);return t}async signOutNativeApp(){await this.requestJson(\"POST\",\"/v1/native-app/sign-out\",{})}async getNativePushDevice(){let{device:e}=await this.requestJson(\"GET\",\"/v1/native-app/push-device\");return e}async registerNativePushDevice(e){let{device:t}=await this.requestJson(\"PUT\",\"/v1/native-app/push-device\",e);return t}async unregisterNativePushDevice(){await this.requestJson(\"DELETE\",\"/v1/native-app/push-device\")}async listOrganizationSessions(e,t={}){return await this.requestJson(\"GET\",`/v1/organizations/${e}/sessions`,void 0,{...t.limit===void 0?{}:{limit:String(t.limit)},...t.cursor===void 0?{}:{cursor:t.cursor},...t.scopeSubjectId?{scopeSubjectId:t.scopeSubjectId}:{},...t.status===void 0?{}:{status:t.status}},{signal:t.signal})}async*iterateOrganizationSessions(e,t={}){let n;do{let s=await this.listOrganizationSessions(e,{...t,...n===void 0?{}:{cursor:n}});for(let i of s.sessions)yield i;n=s.nextCursor??void 0}while(n!==void 0)}async getBilling(e={}){return await this.requestJson(\"GET\",\"/v1/billing\",void 0,{...e.accountId!==void 0?{accountId:e.accountId}:{}})}async getOrganizationUsageSummary(e,t={}){return await this.requestJson(\"GET\",\"/v1/billing/usage-summary\",void 0,{accountId:e.accountId,period:e.period??\"month\"},t)}async getOrganizationModelUsage(e,t={}){return await this.requestJson(\"GET\",\"/v1/billing/usage-models\",void 0,{accountId:e.accountId,period:e.period??\"month\",...e.afterWorkspaceId?{afterWorkspaceId:e.afterWorkspaceId}:{}},t)}async getOrganizationUsageWorkspacePage(e,t={}){return await this.requestJson(\"GET\",\"/v1/billing/usage-workspaces\",void 0,{accountId:e.accountId,period:e.period??\"month\",until:e.until,...e.afterWorkspaceId?{afterWorkspaceId:e.afterWorkspaceId}:{}},t)}async getBillingUsage(e={}){return await this.requestJson(\"GET\",\"/v1/billing/usage\",void 0,{...e.accountId!==void 0?{accountId:e.accountId}:{},...e.workspaceId!==void 0?{workspaceId:e.workspaceId}:{}})}async getWorkspaceInsights(e,t={}){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/insights`,void 0,{range:t.range??\"week\",...t.provider!==void 0?{provider:t.provider}:{},...t.model!==void 0?{model:t.model}:{},...t.rootSessionId!==void 0?{rootSessionId:t.rootSessionId}:{},...t.sessionId!==void 0?{sessionId:t.sessionId}:{}},{signal:t.signal})}async getWorkspaceInsightsSiteUsage(e,t={},n={}){return this.requestJson(\"GET\",`/v1/workspaces/${encodeURIComponent(e)}/insights/sites`,void 0,{range:t.range??\"month\"},n)}async getWorkspaceInsightsUsage(e,t={},n={}){return await this.requestJson(\"GET\",`/v1/workspaces/${encodeURIComponent(e)}/insights/usage${Pe(t)}`,void 0,{},n)}async getOrganizationInsightsUsage(e,t={},n={}){return await this.requestJson(\"GET\",`/v1/organizations/${encodeURIComponent(e)}/insights/usage${Pe(t)}`,void 0,{},n)}async listInsightsCalls(e,t={},n={}){let s=e.kind===\"workspace\"?`/v1/workspaces/${encodeURIComponent(e.workspaceId)}/insights/calls`:`/v1/organizations/${encodeURIComponent(e.accountId)}/insights/calls`;return await this.requestJson(\"GET\",`${s}${Pe(t)}`,void 0,{},n)}async getBillingEntitlements(e={}){return await this.requestJson(\"GET\",\"/v1/billing/entitlements\",void 0,{...e.accountId!==void 0?{accountId:e.accountId}:{}})}async createBillingCheckout(e){return await this.requestJson(\"POST\",\"/v1/billing/checkout\",e)}async getBillingCheckout(e,t={}){return await this.requestJson(\"GET\",`/v1/billing/checkout/${encodeURIComponent(e)}`,void 0,{...t.accountId!==void 0?{accountId:t.accountId}:{}})}async createBillingPortalSession(e={}){return await this.requestJson(\"POST\",\"/v1/billing/portal\",e)}async getBillingSubscriptionPlans(e={}){return await this.requestJson(\"GET\",\"/v1/billing/subscription/plans\",void 0,e)}async createSubscriptionCheckout(e){return await this.requestJson(\"POST\",\"/v1/billing/subscription/checkout\",e)}async upgradeBillingSubscription(e){return await this.requestJson(\"POST\",\"/v1/billing/subscription/upgrade\",e)}async changeBillingSubscription(e){return await this.requestJson(\"POST\",\"/v1/billing/subscription/change\",e)}async cancelBillingSubscription(e){return await this.requestJson(\"POST\",\"/v1/billing/subscription/cancel\",e)}async createSubscriptionPortalSession(e={}){return await this.requestJson(\"POST\",\"/v1/billing/subscription/portal\",e)}apiUrl(e){if(!e.startsWith(\"/\"))throw TypeError(\"API path must start with /\");return`${this.baseUrl}${e}`}withHeaders(e){let t={...e},n=this.options.headers,i=new this.constructor({...this.options,headers:()=>({...typeof n===\"function\"?n():n,...t})});if(this.externalActorHeader!==void 0)i.externalActorHeader=this.externalActorHeader;return i.serviceInitiatorHeader=this.serviceInitiatorHeader,i.serviceContextHeader=this.serviceContextHeader,i}async fetchApi(e,t={}){let n=typeof globalThis.location?.href===\"string\"?globalThis.location.href:void 0,s=new URL(this.baseUrl.endsWith(\"/\")?this.baseUrl:`${this.baseUrl}/`,n),i=new URL(e,s);if(i.origin!==s.origin||!`${i.pathname}/`.startsWith(s.pathname))throw TypeError(\"fetchApi only reaches this client\\'s API base URL\");let r=new Headers(t.headers);for(let[o,a]of Object.entries(this.headers()))if(!r.has(o))r.set(o,a);return await this.fetchImpl(i.href,{...t,headers:r})}headers(e){let t=typeof this.options.headers===\"function\"?this.options.headers():this.options.headers,n={...this.options.apiKey?{Authorization:`Bearer ${this.options.apiKey}`}:{},...t,[Ze]:oe,...e?{[Oe]:e}:{}},s=Object.keys(n).map((o)=>o.toLowerCase()),i=this.externalActorHeader!==void 0||s.includes(\"x-opengeni-external-actor\"),r=this.serviceInitiatorHeader!==void 0||s.includes(\"x-opengeni-service-initiator\")||s.includes(\"x-opengeni-service-context\");if(i&&r)throw Error(\"asUser and asService attribution headers are mutually exclusive\");if(this.externalActorHeader){for(let o of Object.keys(n))if(o.toLowerCase()===\"x-opengeni-external-actor\")delete n[o];n[\"x-opengeni-external-actor\"]=this.externalActorHeader}if(this.serviceInitiatorHeader!==void 0){for(let o of Object.keys(n)){let a=o.toLowerCase();if(a===\"x-opengeni-service-initiator\"||a===\"x-opengeni-service-context\")delete n[o]}if(n[\"x-opengeni-service-initiator\"]=this.serviceInitiatorHeader,this.serviceContextHeader!==void 0)n[\"x-opengeni-service-context\"]=this.serviceContextHeader}return n}url(e,t={}){let n=new URLSearchParams(t).toString();return`${this.baseUrl}${e}${n?`?${n}`:\"\"}`}async codexStatus(e){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/codex/status`)}async codexConnectStart(e){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/codex/connect/start`,{})}async codexConnectPoll(e,t){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/codex/connect/poll`,{state:t})}async codexUsage(e){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/codex/usage`)}async codexAccountUsage(e,t){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/codex/accounts/${t}/usage`)}async organizationCodexAccountUsage(e,t){return await this.requestJson(\"GET\",`/v1/organizations/${e}/codex/accounts/${encodeURIComponent(t)}/usage`)}async refreshCodexUsage(e){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/codex/usage/refresh`)}async codexOverview(e){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/codex/overview`)}async codexDisconnect(e){return await this.requestJson(\"DELETE\",`/v1/workspaces/${e}/codex`)}async listCodexAccounts(e){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/codex/accounts`)}async listSessionCodexAccounts(e,t){return await this.requestJson(\"GET\",`${g(e,t)}/codex-accounts`)}async activateCodexAccount(e,t){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/codex/accounts/${t}/activate`)}async designateCodexAppsAccount(e,t,n){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/codex/apps`,{accountId:t,expectedVersion:n})}async clearCodexAppsAccount(e,t){return await this.requestJson(\"DELETE\",`/v1/workspaces/${e}/codex/apps`,{expectedVersion:t})}async setCodexRotationSettings(e,t){return await this.requestJson(\"PATCH\",`/v1/workspaces/${e}/codex/settings`,t)}async setCodexAccountAllocator(e,t,n){return await this.requestJson(\"PATCH\",`/v1/workspaces/${e}/codex/accounts/${t}/allocator`,n)}async disconnectCodexAccount(e,t){return await this.requestJson(\"DELETE\",`/v1/workspaces/${e}/codex/accounts/${t}`)}async renameCodexAccount(e,t,n){return await this.requestJson(\"PATCH\",`/v1/workspaces/${e}/codex/accounts/${t}`,{label:n})}async pinSessionCodexAccount(e,t,n){return await this.requestJson(\"POST\",`${g(e,t)}/codex-account`,{target:n})}async getModelConnectionAccess(e){return await this.requestJson(\"GET\",`/v1/${e.scope}/${encodeURIComponent(e.scopeId)}/model-connections/${e.kind}/${encodeURIComponent(e.connectionId)}/access`)}async updateModelConnectionAccess(e,t){return await this.requestJson(\"PUT\",`/v1/${e.scope}/${encodeURIComponent(e.scopeId)}/model-connections/${e.kind}/${encodeURIComponent(e.connectionId)}/access`,t)}async listOrganizationSuperGrokAccounts(e){return await this.requestJson(\"GET\",`/v1/organizations/${e}/supergrok/accounts`)}async organizationSupergrokConnectStart(e){return await this.requestJson(\"POST\",`/v1/organizations/${e}/supergrok/connect/start`,{})}async organizationSupergrokConnectPoll(e,t){return await this.requestJson(\"POST\",`/v1/organizations/${e}/supergrok/connect/poll`,{state:t})}async activateOrganizationSuperGrokAccount(e,t){return await this.requestJson(\"POST\",`/v1/organizations/${e}/supergrok/accounts/${t}/activate`,{})}async setOrganizationSuperGrokRotationSettings(e,t){return await this.requestJson(\"PATCH\",`/v1/organizations/${e}/supergrok/settings`,t)}async setOrganizationSuperGrokAccountAllocator(e,t,n){return await this.requestJson(\"PATCH\",`/v1/organizations/${e}/supergrok/accounts/${t}/allocator`,n)}async renameOrganizationSuperGrokAccount(e,t,n){return await this.requestJson(\"PATCH\",`/v1/organizations/${e}/supergrok/accounts/${t}`,{label:n})}async disconnectOrganizationSuperGrokAccount(e,t){return await this.requestJson(\"DELETE\",`/v1/organizations/${e}/supergrok/accounts/${t}`,{})}async supergrokStatus(e){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/supergrok/status`)}async supergrokConnectStart(e,t=\"workspace\"){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/supergrok/connect/start`,{scope:t})}async supergrokConnectPoll(e,t){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/supergrok/connect/poll`,{state:t})}async listSuperGrokAccounts(e){return await this.requestJson(\"GET\",`/v1/workspaces/${e}/supergrok/accounts`)}async activateSuperGrokAccount(e,t){return await this.requestJson(\"POST\",`/v1/workspaces/${e}/supergrok/accounts/${t}/activate`,{})}async setSuperGrokRotationSettings(e,t){return await this.requestJson(\"PATCH\",`/v1/workspaces/${e}/supergrok/settings`,t)}async setSuperGrokAccountAllocator(e,t,n){return await this.requestJson(\"PATCH\",`/v1/workspaces/${e}/supergrok/accounts/${t}/allocator`,n)}async renameSuperGrokAccount(e,t,n){return await this.requestJson(\"PATCH\",`/v1/workspaces/${e}/supergrok/accounts/${t}`,{label:n})}async disconnectSuperGrokAccount(e,t){return await this.requestJson(\"DELETE\",`/v1/workspaces/${e}/supergrok/accounts/${t}`,{})}async requestSessionCommand(e,t,n,s={}){return await this.requestJson(e,t,n,{},{signal:s.signal,timeoutMs:s.timeoutMs??this.sessionCommandTimeoutMs})}async requestJson(e,t,n,s={},i={}){let r=crypto.randomUUID(),o=Ni(i);try{let a=Dt(e)?this.readRetryPolicy:null;if(!a)return await this.requestJsonAttempt(e,t,n,s,i,o.signal,r,null);let c=Date.now();for(let u=1;;u+=1){let l={transportFailure:!1,gatewayFailure:!1,retryAfterMs:null};try{return await this.requestJsonAttempt(e,t,n,s,i,o.signal,r,l)}catch(p){let d=l.transportFailure||l.gatewayFailure&&Lt(p);if(o.signal?.aborted||!d)throw p;let m=zt(a,u,Date.now()-c,l.retryAfterMs);if(m===null)throw p;await Nt(m,o.signal)}}}finally{o.dispose()}}async requestJsonAttempt(e,t,n,s,i,r,o,a){if(r?.aborted)throw r.reason??new DOMException(\"Request aborted\",\"AbortError\");let c=this.headers(o),u;try{u=await ae(this.fetchImpl(this.url(t,s),{method:e,headers:{...c,Accept:\"application/json\",...n!==void 0?{\"Content-Type\":\"application/json\"}:{}},...n!==void 0?{body:JSON.stringify(n)}:{},...r?{signal:r}:{}}),r)}catch(l){if(i.signal?.aborted)throw l;if(ue(e))throw ce(o);if(l instanceof TypeError&&a)a.transportFailure=!0;throw Ye(l),l}D(u,this.apiContractStrict);try{if(!u.ok){if(a&&je(u.status))a.gatewayFailure=!0,a.retryAfterMs=Wt(u.headers.get(\"retry-after\"));throw await ae(M(u,{method:e,correlationId:o}),r)}if(i.responseType===\"void\"){await ae(U(u,\"discarding void API response\"),r);return}await ae(fe(u,{method:e,correlationId:o}),r);let l=await ae(u.json(),r);return At(l,u.headers.get(It)),l}catch(l){if(i.signal?.aborted)throw l;if(l instanceof P)throw l;if(ue(e))throw ce(o);if(l instanceof TypeError&&a)a.transportFailure=!0;throw Ye(l),l}}async requestResponse(e,t,n={},s={}){let i=crypto.randomUUID(),r=this.headers(i),o;try{o=await this.fetchImpl(this.url(t,n),{method:e,headers:{...r,Accept:s.accept??\"application/octet-stream\"},...s.signal?{signal:s.signal}:{}})}catch(a){if(ue(e))throw ce(i);throw a}if(D(o,this.apiContractStrict),!o.ok)throw await M(o,{method:e,correlationId:i});return o}async requestVoid(e,t,n){let s=crypto.randomUUID(),i=this.headers(s),r;try{r=await this.fetchImpl(this.url(t),{method:e,headers:{...i,Accept:\"application/json\",...n!==void 0?{\"Content-Type\":\"application/json\"}:{}},...n!==void 0?{body:JSON.stringify(n)}:{}})}catch(o){if(ue(e))throw ce(s);throw o}if(D(r,this.apiContractStrict),!r.ok)throw await M(r,{method:e,correlationId:s})}}function D(e,t){if(!t)return;let n=e.headers.get(Ze);if(n&&n!==oe)throw new ve(oe,n)}function Bi(e){if(!e||typeof e!==\"object\"||Array.isArray(e))return!1;let t=e;return typeof t.text===\"string\"&&Array.isArray(t.languages)&&t.languages.every((n)=>typeof n===\"string\")}function Li(e){if(!e||typeof e!==\"object\"||Array.isArray(e))return!1;let t=e;if(!it({recording:t.recording,segments:[]}))return!1;if(!t.chunk||typeof t.chunk!==\"object\"||Array.isArray(t.chunk))return!1;let n=t.chunk;return typeof n.chunkNumber===\"number\"&&typeof n.byteLength===\"number\"&&typeof n.sha256===\"string\"&&typeof n.startMilliseconds===\"number\"&&typeof n.durationMilliseconds===\"number\"&&typeof n.deduplicated===\"boolean\"}function it(e){if(!e||typeof e!==\"object\"||Array.isArray(e))return!1;let t=e;if(!t.recording||typeof t.recording!==\"object\"||Array.isArray(t.recording))return!1;let n=t.recording;return typeof n.id===\"string\"&&typeof n.workspaceId===\"string\"&&typeof n.mimeType===\"string\"&&typeof n.state===\"string\"&&typeof n.nextChunkNumber===\"number\"&&typeof n.chunkCount===\"number\"&&typeof n.totalBytes===\"number\"&&typeof n.totalDurationMilliseconds===\"number\"&&typeof n.segmentCount===\"number\"&&typeof n.completedSegmentCount===\"number\"&&(n.transcriptText===null||typeof n.transcriptText===\"string\")&&Array.isArray(n.languages)&&(n.errorCode===null||typeof n.errorCode===\"string\")&&typeof n.retryable===\"boolean\"&&typeof n.objectsCleaned===\"boolean\"&&typeof n.createdAt===\"string\"&&typeof n.updatedAt===\"string\"&&typeof n.expiresAt===\"string\"&&(t.retryAfterMilliseconds===void 0||typeof t.retryAfterMilliseconds===\"number\"&&Number.isInteger(t.retryAfterMilliseconds)&&t.retryAfterMilliseconds>0&&t.retryAfterMilliseconds<=60000)&&Array.isArray(t.segments)}function ye(e){if(it(e))return e;throw A(\"Invalid transcription recording response.\",{code:\"invalid_response\"})}function Wi(e){if(!e||typeof e!==\"object\"||Array.isArray(e))return!1;let t=e.recordings;return Array.isArray(t)&&t.length<=50&&t.every((n)=>it({recording:n,segments:[]}))}function zi(e){switch(e.trim().toLowerCase().split(\";\")[0]??\"audio/webm\"){case\"audio/mp4\":case\"audio/m4a\":return\"audio.mp4\";case\"audio/ogg\":return\"audio.ogg\";case\"audio/mpeg\":case\"audio/mp3\":return\"audio.mp3\";case\"audio/wav\":case\"audio/x-wav\":return\"audio.wav\";case\"audio/webm\":default:return\"audio.webm\"}}var Hn=16384;function Ni(e){let t=e.timeoutMs??0;if(t<=0)return{signal:e.signal,dispose:()=>{return}};let n=new AbortController,s=()=>n.abort(e.signal?.reason);if(e.signal?.aborted)s();else e.signal?.addEventListener(\"abort\",s,{once:!0});let i=setTimeout(()=>n.abort(new DOMException(\"Request timed out\",\"TimeoutError\")),t);return{signal:n.signal,dispose:()=>{clearTimeout(i),e.signal?.removeEventListener(\"abort\",s)}}}async function ae(e,t){if(!t)return await e;if(t.aborted)throw t.reason??new DOMException(\"Request aborted\",\"AbortError\");return await new Promise((n,s)=>{let i=()=>{r(),s(t.reason??new DOMException(\"Request aborted\",\"AbortError\"))},r=()=>t.removeEventListener(\"abort\",i);t.addEventListener(\"abort\",i,{once:!0}),e.then((o)=>{r(),n(o)},(o)=>{r(),s(o)})})}function Fi(e,t){if(e===void 0||e===null)return;if(t.usageLimit?.limitMicros===e)return;throw new pe(`The session ${t.id} was created, but the server did not confirm its usage limit; it may not support usage limits. Set the limit with setSessionUsageLimit before sending work, or treat the task as unlimited.`,{sessionId:t.id})}async function M(e,t){let n=await Ji(e),i=new((Ve(n))?Ne:(Je(n))?Fe:P)(e.status,n,{correlationId:e.headers.get(Oe)??t.correlationId,mutation:ue(t.method)});return i.status>=400&&i.status<500&&(i.code===\"SESSION_TENANCY_NOT_ACTIVATED\"||i.code===\"OPENGENI_SETUP_REQUIRED\")?new ze(i):i}async function fe(e,t){if(Yn(e.headers.get(\"content-type\")))return;throw await U(e,\"unexpected non-JSON API response\"),A(\"\",{code:\"upstream_unavailable\",retryable:!0,correlationId:e.headers.get(Oe)??t.correlationId,outcomeUnknown:ue(t.method),displayMessage:\"The workspace is temporarily unavailable — retry.\"})}async function Ji(e){if(!Yn(e.headers.get(\"content-type\")))return await U(e,\"discarding API error body\"),\"\";if(Number(e.headers.get(\"content-length\"))>Hn)return await U(e,\"discarding API error body\"),\"\";try{return new TextDecoder().decode(await he(e,Hn,null))}catch{return\"\"}}function Yn(e){return/^(application\\\\/json|[^;]+\\\\+json)\\\\s*(;|$)/i.test(e??\"\")}function ue(e){return e!==\"GET\"&&e!==\"HEAD\"&&e!==\"OPTIONS\"}function ce(e){return new P(0,\"\",{code:\"network_error\",retryable:!0,correlationId:e,outcomeUnknown:!0,mutation:!0,displayMessage:\"The request could not be confirmed — reconcile before retrying.\"})}function Vi(){let e=typeof window<\"u\"?window.isSecureContext:typeof globalThis.isSecureContext===\"boolean\"?globalThis.isSecureContext:void 0;if(e===void 0)return;if(!e)throw new we(\"insecure_context\");if(typeof globalThis.crypto>\"u\"||typeof globalThis.crypto.subtle?.digest!==\"function\")throw new we(\"web_crypto_unavailable\")}async function Hi(e){let t=typeof e===\"string\"?new TextEncoder().encode(e):e instanceof Blob?new Uint8Array(await e.arrayBuffer()):new Uint8Array(e),n=await globalThis.crypto.subtle.digest(\"SHA-256\",t);return[...new Uint8Array(n)].map((s)=>s.toString(16).padStart(2,\"0\")).join(\"\")}async function Kn(e){let t=Uint8Array.from(e),n=await globalThis.crypto.subtle.digest(\"SHA-256\",t.buffer);return[...new Uint8Array(n)].map((s)=>s.toString(16).padStart(2,\"0\")).join(\"\")}function Ki(e,t){if(e.computerSessionId!==t.computerSessionId)return\"frame_session_mismatch\";if(e.targetId!==t.targetId)return\"frame_target_mismatch\";if(e.mediaType!==t.mediaType)return\"frame_media_mismatch\";if(e.sha256!==t.sha256)return\"frame_digest_mismatch\";return null}async function U(e,t){await e.body?.cancel(t).catch(()=>{return})}function jn(e,t){if(!Mn(t,e)&&!Gn(t,e))throw A(\"retained workspace artifact receipt is invalid\")}function Xn(e){if(!e||typeof e.url!==\"string\"||typeof e.expiresAt!==\"string\"||!Number.isFinite(Date.parse(e.expiresAt)))throw A(\"retained artifact download URL is invalid\");let t;try{t=new URL(e.url)}catch{throw A(\"retained artifact download URL is invalid\")}if(![\"http:\",\"https:\"].includes(t.protocol)||t.username||t.password)throw A(\"retained artifact download URL is unsafe\")}function ji(e,t){if(!e||e.schemaVersion!==1||e.artifactId!==t||e.contentType!==\"video/mp4\"||e.acceptRanges!==\"bytes\"||!Number.isSafeInteger(e.sizeBytes)||e.sizeBytes<=0||e.sizeBytes>On||!/^[0-9a-f]{64}$/.test(e.sha256))throw A(\"generated-video playback source is invalid\");Xn({url:e.url,expiresAt:e.expiresAt})}function Yi(e){if(e===null)return null;if(!/^\\\\d+$/.test(e))throw A(\"invalid retained artifact content-length\");let t=Number(e);if(!Number.isSafeInteger(t)||t>qe)throw A(\"retained artifact response exceeds the SDK byte limit\");return t}async function he(e,t,n){if(!e.body){if(n!==null&&n!==0)throw A(\"retained artifact response length mismatch\");return new Uint8Array}let s=e.body.getReader(),i=[],r=0;try{while(!0){let{done:c,value:u}=await s.read();if(c)break;if(r+=u.byteLength,r>t)throw await s.cancel(\"retained artifact response exceeded the SDK byte limit\").catch(()=>{return}),A(\"retained artifact response exceeds the SDK byte limit\");i.push(u)}}finally{s.releaseLock()}if(n!==null&&r!==n)throw A(\"retained artifact response length mismatch\");let o=new Uint8Array(r),a=0;for(let c of i)o.set(c,a),a+=c.byteLength;return o}function O(e,t){return`/v1/workspaces/${encodeURIComponent(e)}/published-artifacts/${encodeURIComponent(t)}`}function X(e,t){return`${O(e,t)}/publication`}class Re extends Error{code;status;details;constructor(e,t,n,s={}){super(t);this.code=e;this.status=n;this.details=s;this.name=\"OpenGeniSiteDataError\"}}var rt=\"/v1/workspaces/site-host/published-artifacts/current\";function Qn(e,t){let n=async(u,l={})=>{if(!await t())throw new Re(\"site_data_unsupported\",\"This Site host does not provide Site Data\",0);let p=await e(`${rt}${u}`,l),d=await p.text(),m=null;try{m=d?JSON.parse(d):null}catch{m=null}if(p.ok)return m;throw Qi(p.status,m)},s=(u)=>({method:\"POST\",headers:{\"content-type\":\"application/json\"},body:JSON.stringify(u)}),i=async(u)=>(await n(\"/data/write\",s({operations:u}))).results,r=async(u)=>{let[l]=await i([u]);if(!l||!(\"record\"in l))throw new Re(\"request_failed\",\"Unexpected Site Data response\",200);return l.record},o=async(u,l,p)=>(await n(\"/data/query\",s({collection:u,limit:1,count:!0,...l?{where:l}:{},...p?{scope:p}:{}}))).count??0;return{data:{collection(u){return{name:u,list:async(p={})=>await n(\"/data/query\",s({collection:u,...p})),get:async(p)=>{try{return(await n(\"/data/get\",s({collection:u,...Ue(p)}))).record}catch(d){if(d instanceof Re&&d.code===\"not_found\")return null;throw d}},insert:async(p,d={})=>await r({op:\"insert\",collection:u,data:p,...d.key===void 0?{}:{key:d.key}}),put:async(p,d,m={})=>await r({op:\"put\",collection:u,key:p,data:d,...m}),patch:async(p,d,m={})=>await r({op:\"patch\",collection:u,...Ue(p),data:d,...m}),delete:async(p,d={})=>{await i([{op:\"delete\",collection:u,...Ue(p),...d}])},increment:async(p,d,m)=>await r({op:\"increment\",collection:u,...Ue(p),field:d,...m===void 0?{}:{by:m}}),count:async(p,d={})=>await o(u,p,d.scope)}},batch:i,count:async(u,l)=>await o(u,l)},files:{upload:async(u,l={})=>{let p=u instanceof Blob?u:new Blob([u instanceof Uint8Array?u.slice():u],{type:l.contentType??\"application/octet-stream\"}),d=l.name??(typeof File<\"u\"&&u instanceof File?u.name:\"file\"),m=new URLSearchParams({name:d,scope:l.scope??\"shared\"});return await n(`/files?${m}`,{method:\"POST\",headers:{\"content-type\":l.contentType??(p.type||\"application/octet-stream\")},body:await p.arrayBuffer()})},list:async(u={})=>{let l=new URLSearchParams;if(u.limit!==void 0)l.set(\"limit\",String(u.limit));if(u.cursor)l.set(\"cursor\",u.cursor);let p=l.size?`?${l}`:\"\";return await n(`/files${p}`,{method:\"GET\"})},url:async(u)=>await n(`/files/${encodeURIComponent(u)}`,{method:\"GET\"}),delete:async(u)=>{await n(`/files/${encodeURIComponent(u)}`,{method:\"DELETE\"})}}}}function Ue(e){if(typeof e===\"string\")return{key:e};if(\"id\"in e)return{id:e.id};return{key:e.key}}var Xi=new Set([\"validation\",\"conflict\",\"not_found\",\"forbidden\",\"not_available_for_viewer\",\"quota_exceeded\",\"rate_limited\"]);function Qi(e,t){let n=typeof t===\"object\"&&t!==null&&\"error\"in t?t.error:null,s=typeof n===\"object\"&&n!==null?n:{},i=typeof s.details===\"object\"&&s.details!==null?s.details:{},r=i.code,o=r&&Xi.has(r)?r:e===404?\"not_found\":e===403?\"forbidden\":e===413?\"quota_exceeded\":e===429?\"rate_limited\":\"request_failed\",a=typeof s.message===\"string\"&&s.message?s.message:`Site Data request failed with HTTP ${e}`;return new Re(o,a,e,i)}class be extends Error{code;status;details;constructor(e,t,n,s={}){super(t);this.code=e;this.status=n;this.details=s;this.name=\"OpenGeniSiteSqlError\"}}var Zi=/^[A-Za-z][A-Za-z0-9_-]{0,63}$/u,er=new Set([\"validation\",\"not_found\",\"forbidden\",\"not_available_for_viewer\",\"conflict\",\"quota_exceeded\",\"rate_limited\",\"sql_error\",\"unavailable\",\"disabled\"]);function Zn(e,t){return{async run(n,s={}){if(!Zi.test(n))throw new be(\"validation\",\"Invalid query name\",0);if(Object.keys(s).some((a)=>a===\"viewer\"||a.startsWith(\"viewer_\")))throw new be(\"validation\",\"viewer parameters are bound by the host, not the Site\",0);if(!await t())throw new be(\"site_sql_unsupported\",\"This Site host does not provide Site SQL\",0);let i=await e(`${rt}/sql/queries/${encodeURIComponent(n)}`,{method:\"POST\",headers:{\"content-type\":\"application/json\"},body:JSON.stringify({params:s})}),r=await i.text(),o=null;try{o=r?JSON.parse(r):null}catch{o=null}if(i.ok)return o;throw tr(i.status,o)}}}function tr(e,t){let n=typeof t===\"object\"&&t!==null&&\"error\"in t?t.error:null,s=typeof n===\"object\"&&n!==null?n:{},i=typeof s.details===\"object\"&&s.details!==null?s.details:{},r=typeof i.code===\"string\"?i.code:void 0,o=r&&er.has(r)?r:e===404?\"not_found\":e===403?\"forbidden\":e===413?\"quota_exceeded\":e===429?\"rate_limited\":\"request_failed\",a=typeof s.message===\"string\"&&s.message?s.message:`Site SQL request failed with HTTP ${e}`;return new be(o,a,e,i)}var es=\"The model returned no final reply after a reply reminder. Completed work is preserved; the goal and later updates are unaffected.\";function ts(e){return e!==null&&typeof e===\"object\"&&!Array.isArray(e)&&e.emptyFinalReply===!0}class ot extends Error{code;event;constructor(e,t,n=null){super(t);this.name=\"OpenGeniChatError\",this.code=e,this.event=n}}function z(){return{chunks:[],terminal:null}}class $e{workspaceId;sessionId;events=[];turnId;pending=null;failure=null;emptyFinalReply=!1;segments=[];openTools=new Map;constructor(e,t,n){this.workspaceId=e;this.sessionId=t;this.turnId=n}get text(){return this.segments.filter((e)=>!e.commentary).map((e)=>e.text).filter((e)=>e.length>0).join(`\\n\\n`)}push(e){let t=typeof e.turnId===\"string\"?e.turnId:null;if(this.turnId&&t&&t!==this.turnId)return{chunks:[],terminal:null};if(!this.turnId&&t&&nr(e.type))this.turnId=t;this.events.push(e);let n=se(e.payload);switch(e.type){case\"agent.message.delta\":{let s=E(n.text);if(!s)return z();let i=E(n.messageId)||null;if(i)return this.messageDelta(i,s,De(n));let r=this.segments.at(-1);if(De(n)){if(r?.open&&r.commentary)r.text+=s;else this.closeSegments(),this.segments.push({text:s,open:!0,commentary:!0,messageId:null});return z()}if(r?.open&&!r.commentary)r.text+=s;else return this.closeSegments(),{chunks:[this.startSegment(s,!0,null)],terminal:null};return{chunks:[{type:\"text\",text:s}],terminal:null}}case\"agent.message.completed\":{let s=E(n.text)??\"\",i=E(n.messageId)||null;if(i)return this.messageCompleted(i,s,De(n));let r=this.segments.at(-1);if(De(n)){if(r?.commentary&&(r.open||s.startsWith(r.text))){if(r.open=!1,s)r.text=s;return z()}if(!(r&&!r.commentary&&r.open&&s.startsWith(r.text))){if(s)this.closeSegments(),this.segments.push({text:s,open:!1,commentary:!0,messageId:null});return z()}}let o=r?.commentary?void 0:r;if(!o||!o.open&&o.text&&!s.startsWith(o.text)){if(!s)return z();if(n.phase===void 0&&this.latestAnswer()?.text===s)return z();return this.closeSegments(),{chunks:[this.startSegment(s,!1,null)],terminal:null}}return o.open=!1,{chunks:this.extendAnswer(o,s),terminal:null}}case\"agent.toolCall.created\":{this.closeSegments();let s=E(n.name)??\"tool\",i=E(n.id);if(i)this.openTools.set(i,s);return{chunks:[{type:\"tool\",name:s,status:\"started\",...i?{callId:i}:{},...\"arguments\"in n?{input:n.arguments}:{}}],terminal:null}}case\"agent.toolCall.output\":{let s=E(n.id),i=(s?this.openTools.get(s):void 0)??\"tool\";if(s)this.openTools.delete(s);return{chunks:[{type:\"tool\",name:i,status:rr(n)?\"failed\":\"completed\",...s?{callId:s}:{}}],terminal:null}}case\"session.requiresAction\":{let s=sr(n);if(!s)return{chunks:[],terminal:null};return this.pending=s,{chunks:[...this.settleSegments(),{type:\"pending\",pending:s}],terminal:\"pending\"}}case\"session.humanInput.requested\":{let s=ir(n);if(!s)return{chunks:[],terminal:null};return this.pending=s,{chunks:[...this.settleSegments(),{type:\"pending\",pending:s}],terminal:\"pending\"}}case\"turn.completed\":return this.emptyFinalReply=ts(n),{chunks:this.settleSegments(),terminal:\"completed\"};case\"turn.failed\":return this.failure=e,{chunks:this.settleSegments(),terminal:\"failed\"};case\"turn.cancelled\":return{chunks:this.settleSegments(),terminal:\"cancelled\"};default:return{chunks:[],terminal:null}}}reply(e){let t=this.text;return{text:t,sessionId:this.sessionId,workspaceId:this.workspaceId,turnId:this.turnId,status:e===\"pending\"?\"pending\":e===\"cancelled\"?\"cancelled\":\"completed\",pending:this.pending,...this.emptyFinalReply?{emptyFinalReply:!0,notice:es}:{},events:[...this.events],toString:()=>t}}failureError(){let e=se(this.failure?.payload),t=E(e.code)??\"turn_failed\",n=E(e.error)??E(e.message)??\"The turn failed.\";return new ot(t,n,this.failure)}messageDelta(e,t,n){let s=this.segmentOf(e);if(s?.open)return s.text+=t,s.commentary?z():{chunks:[{type:\"text\",text:t}],terminal:null};if(this.closeSegments(),n)return this.segments.push({text:t,open:!0,commentary:!0,messageId:e}),z();return{chunks:[this.startSegment(t,!0,e)],terminal:null}}messageCompleted(e,t,n){let s=this.segmentOf(e)??this.unidentifiedStreamingSegment(t);if(s){if(s.messageId=e,s.open=!1,s.commentary){if(t)s.text=t;return z()}return{chunks:this.extendAnswer(s,t),terminal:null}}if(!t)return z();if(n)return this.segments.push({text:t,open:!1,commentary:!0,messageId:e}),z();return{chunks:[this.startSegment(t,!1,e)],terminal:null}}segmentOf(e){return this.findLastSegment((t)=>t.messageId===e)}unidentifiedStreamingSegment(e){let t=this.segments.at(-1);return t?.open&&t.messageId===null&&e.startsWith(t.text)?t:void 0}latestAnswer(){return this.findLastSegment((e)=>!e.commentary)}findLastSegment(e){for(let t=this.segments.length-1;t>=0;t-=1){let n=this.segments[t];if(e(n))return n}return}extendAnswer(e,t){if(t.length<=e.text.length||!t.startsWith(e.text))return[];if(e!==this.latestAnswer())return[];let n=t.slice(e.text.length);return e.text=t,[{type:\"text\",text:n}]}closeSegments(){for(let e of this.segments)e.open=!1}settleSegments(){if(this.closeSegments(),this.emptyFinalReply)return[];if(this.segments.some((t)=>!t.commentary))return[];let e=[...this.segments].reverse().find((t)=>t.commentary&&t.text);if(!e)return[];return e.commentary=!1,[{type:\"text\",text:e.text}]}startSegment(e,t,n){let s=this.segments.some((i)=>!i.commentary)?`\\n\\n`:\"\";return this.segments.push({text:e,open:t,commentary:!1,messageId:n}),{type:\"text\",text:s+e}}}function De(e){return e.phase===\"commentary\"}function nr(e){return e.startsWith(\"turn.\")||e.startsWith(\"agent.\")||e===\"user.message\"}function sr(e){let n=(Array.isArray(e.approvals)?e.approvals:[])[0];if(!n)return null;let s=se(n),i=se(s.rawItem),r=E(i.callId)??E(i.id)??E(s.id)??E(s.callId);if(!r)return null;return{kind:\"approval\",requestId:r,name:E(s.name)??E(s.toolName)??E(i.name)??null,payload:n}}function ir(e){let t=se(e.request),n=E(t.id);if(!n||!Array.isArray(t.questions))return null;return{kind:\"human_input\",requestId:n,name:null,payload:e.request}}function se(e){return e&&typeof e===\"object\"&&!Array.isArray(e)?e:{}}function E(e){return typeof e===\"string\"?e:void 0}function rr(e){if(e.error===!0||e.failed===!0)return!0;let t=e.output;return!!t&&typeof t===\"object\"&&t.isError===!0}function is(e,t){let n=async(s,i={})=>{i.signal?.throwIfAborted();let r=new AbortController,o=()=>r.abort(i.signal?.reason);i.signal?.addEventListener(\"abort\",o,{once:!0});let a=i.after??0,c=0,u=\"\",l=i.turnId||a===0?new $e(t,s,i.turnId??null):null,p=[],d=null,m={event:null},y,R,w=()=>{if(R?.abort(),y)Promise.resolve(y.return(void 0)).catch(()=>{return});y=void 0,R=void 0},S=()=>R?.abort(r.signal.reason);r.signal.addEventListener(\"abort\",S);let I=(v)=>{for(let k of v)if(k.type===\"text\")r.signal.throwIfAborted(),u+=k.text,i.onText?.(k.text)},x=(v)=>{l=new $e(t,s,v);for(let k of p){let q=l.push(k);if(q.terminal&&q.terminal!==\"pending\")d=q.terminal}p=[]},b=(v)=>{let k=ss(v);if(k<=c)return;if(c=k,!l){if(k<=a){p.push(v);return}if(!rs(v)&&!Be(v))return;x(v.turnId??ns(p))}let q=l;if((!v.turnId||!q.turnId||v.turnId===q.turnId)&&Be(v)){if(!q.turnId&&v.turnId)q.turnId=v.turnId;if(v.type!==\"session.status.changed\")m.event=v;if(k>a)return}let Q=q.push(v);if(k>a)I(Q.chunks);if(Q.terminal&&Q.terminal!==\"pending\")d=Q.terminal},h=(v)=>{if(r.signal.throwIfAborted(),v===\"failed\")throw l.failureError();return{sessionId:s,turnId:l?.turnId??null,text:u,status:v===\"pending\"?\"pending\":v===\"cancelled\"?\"cancelled\":\"completed\",after:Math.max(a,c)}},f=()=>at(()=>e.getSession(t,s,{fresh:!0,signal:r.signal}),r.signal),T=async(v)=>{while(c<v){let k=c,q=await at(()=>e.listEventPage(t,s,{after:c,before:v+1,direction:\"after\",limit:200,mode:\"forensic\",payloadMode:\"full\"}),r.signal);for(let H of q.events)if(b(H),d&&c>a)return;if(c=Math.max(c,q.nextAfter??q.coveredSequence?.last??0),c<=k)throw Error(\"The Site AI event replay did not reach the session cursor.\")}},C=(v)=>v.status===\"requires_action\"&&(!v.activeTurnId||!l?.turnId||v.activeTurnId===l.turnId);try{let v=await f();if(await T(Math.min(a,v.lastSequence)),d)return h(d);for(;;){if(await T(v.lastSequence),d)return h(d);if(C(v)){let k=await f();if(k.lastSequence>c){v=k;continue}if(C(k)){if(!l)x(k.activeTurnId??ns(p));else if(!l.turnId)l.turnId=k.activeTurnId??null;if(m.event&&ss(m.event)>a)I(l.push(m.event).chunks);return h(\"pending\")}v=k}R=new AbortController,y=e.streamEvents(t,s,{after:Math.max(a,c),signal:R.signal});for(;;){let k=await at(()=>y.next(),r.signal);if(k.done)throw Error(\"The Site AI event stream ended before the turn settled.\");if(b(k.value),d)return h(d);if(Be(k.value)&&(!k.value.turnId||k.value.turnId===l?.turnId)){w(),v=await f();break}}}}finally{i.signal?.removeEventListener(\"abort\",o),r.abort(),w(),r.signal.removeEventListener(\"abort\",S)}};return{async run(s,i={}){i.signal?.throwIfAborted();let r=await e.createSession(t,{initialMessage:s.initialMessage,idempotencyKey:s.idempotencyKey??crypto.randomUUID(),...s.model===void 0?{}:{model:s.model},...s.reasoningEffort===void 0?{}:{reasoningEffort:s.reasoningEffort},...s.latencyMode===void 0?{}:{latencyMode:s.latencyMode}});return i.onSession?.(r.id),await n(r.id,i)},result:n}}function Be(e){return e.type===\"session.requiresAction\"||e.type===\"session.humanInput.requested\"||e.type===\"session.status.changed\"&&se(e.payload).status===\"requires_action\"}function rs(e){return e.type.startsWith(\"turn.\")||e.type.startsWith(\"agent.\")||e.type===\"user.message\"}function ns(e){for(let t=e.length-1;t>=0;t-=1){let n=e[t];if(n.turnId&&(rs(n)||Be(n)))return n.turnId}return null}function ss(e){return Math.max(e.sequence,e.coveredThrough??0,Et(e)??0)}async function at(e,t){t.throwIfAborted();let n=()=>{},s=new Promise((i,r)=>{n=()=>r(t.reason),t.addEventListener(\"abort\",n,{once:!0})});try{let i=await Promise.race([e(),s]);return t.throwIfAborted(),i}finally{t.removeEventListener(\"abort\",n)}}var le=2,or=\"opengeni.site.connect\",cs=\"opengeni.site.ready\",ar=\"opengeni.site.request\",cr=\"opengeni.site.response\",ur=\"opengeni.site.cancel\",us=\"__opengeniSiteBridgeBootstrapV2\",lr=\"/__opengeni/site-tools\",dr=\"viewer\",pr=\"auth.signIn\";class _ extends Error{code;retryable;outcomeUnknown;constructor(e,t,n=!1,s=!1){super(t);this.code=e;this.retryable=n;this.outcomeUnknown=s;this.name=\"OpenGeniSiteBridgeError\"}}function ls(e={}){let t=gr(e)?new ds(e):new ps(e),n=Qn((a,c)=>t.fetch(`https://site.opengeni.invalid${a}`,c),()=>t.siteDataSupported()),s=Zn((a,c)=>t.fetch(`https://site.opengeni.invalid${a}`,c),()=>t.siteDataSupported()),i=null,r=null,o=new st({baseUrl:\"https://site.opengeni.invalid\",toolGatewayMode:e.toolGatewayMode??\"target\",fetch:(a,c)=>t.fetch(a,c)});return{client:o,ai:is(o,ge),workspaceId:ge,tools:new re(t).forWorkspace(\"site-host\"),data:n.data,files:n.files,sql:s,get viewer(){if(!i){let a=t.viewer();i=a,a.catch(()=>{if(i===a)i=null})}return i},get capabilities(){return r??=vr(t),r},auth:{signIn:()=>t.signIn()},close:()=>t.close()}}class ds{toolGatewayMode;fetchImpl;basePath;constructor(e){this.toolGatewayMode=e.toolGatewayMode??\"target\",this.fetchImpl=e.fetch??globalThis.fetch.bind(globalThis);let t=e.localCodemodePath;this.basePath=(typeof t===\"string\"?t:lr).replace(/\\\\/+$/u,\"\")}close(){}async siteDataSupported(){return!1}async viewer(){return null}async signIn(){return{started:!1}}async fetch(e,t){let n=new Request(e,t),s=new URL(n.url),i=`${s.pathname}${s.search}`;return de(i,ge,n.method),this.fetchImpl(`${this.basePath}/sdk${i}`,{method:n.method,headers:n.headers,signal:n.signal,...n.body?{body:await n.text()}:{}})}async requestJson(e,t,n,s,i={}){let r=mr(e,t),o=await this.fetchImpl(`${this.basePath}${r}`,{method:e,...i.signal?{signal:i.signal}:{},...n===void 0?{}:{headers:{\"content-type\":\"application/json\"},body:JSON.stringify(n)}}),a=await o.json();if(o.ok)return a;let c=B(a)&&B(a.error)?a.error:{};throw new _(typeof c.code===\"string\"?c.code:\"local_codemode_error\",typeof c.message===\"string\"?c.message:`Local Site tool request failed with HTTP ${o.status}`,c.retryable===!0,c.outcomeUnknown===!0)}}function gr(e){if(e.localCodemodePath===!1||e.bootstrapPort)return!1;if(typeof e.localCodemodePath===\"string\")return!0;let t=e.siteWindow??globalThis.window;return Boolean(t&&t.parent===t)}function mr(e,t){if(e===\"GET\"&&t.endsWith(\"/tools/catalog\"))return\"/catalog\";if(e===\"GET\"&&t.endsWith(\"/tools/declarations\"))return\"/declarations\";if(e===\"POST\"&&t.endsWith(\"/tools/calls\"))return\"/calls\";if(e===\"POST\"&&t.endsWith(\"/tools/resolve\"))return\"/resolve\";if(e===\"POST\"&&t.endsWith(\"/tools/invoke\"))return\"/invoke\";throw new _(\"unsupported_request\",\"Unsupported Site tool request\")}function yr(e){return{...e.operationId===void 0?{}:{operationId:e.operationId},catalogDigest:e.catalogDigest,identity:e.identity,arguments:e.arguments}}function fr(e){return{target:e.target,operationId:e.operationId,arguments:e.arguments,...e.expectedDefinitionDigest===void 0?{}:{expectedDefinitionDigest:e.expectedDefinitionDigest}}}class ps{toolGatewayMode;targetTools=!1;siteData=!1;viewerSupported=!1;options;bootstrap;port=null;connecting=null;closed=!1;constructor(e){this.toolGatewayMode=e.toolGatewayMode??\"target\",this.options=e,this.bootstrap=hr(e)}async fetch(e,t){return bt(await this.connect(),e,t)}async siteDataSupported(){return await this.connect(),this.siteData}async viewer(){if(await this.connect(),!this.viewerSupported)return null;let e=await this.request({method:dr},{});if(!Ir(e))throw new _(\"invalid_viewer\",\"The Site host returned an invalid viewer\");return e}async signIn(){if(await this.connect(),!this.viewerSupported)return{started:!1};let e=await this.request({method:pr},{});return{started:B(e)&&e.started===!0}}async requestJson(e,t,n,s,i={}){if(e===\"POST\"&&(t.endsWith(\"/tools/resolve\")||t.endsWith(\"/tools/invoke\"))){if(await this.connect(),!this.targetTools)throw new _(\"target_tools_unsupported\",\"Upgrade the Site host to use targeted tools\");if(!B(n))throw TypeError(\"Site target payload is required\");let r=n;return await this.request(t.endsWith(\"/tools/resolve\")?{method:\"resolve\",payload:{target:r.target}}:{method:\"invoke\",payload:fr(r)},i)}if(e===\"GET\"&&t.endsWith(\"/tools/catalog\"))return await this.request({method:\"catalog\"},i);if(e===\"GET\"&&t.endsWith(\"/tools/declarations\"))return await this.request({method:\"declarations\"},i);if(e===\"POST\"&&t.endsWith(\"/tools/calls\")){if(!B(n))throw TypeError(\"Site tool call payload is required\");return await this.request({method:\"call\",payload:yr(n)},i)}throw new _(\"unsupported_request\",\"Unsupported Site bridge request\")}close(){if(this.closed)return;this.closed=!0,this.bootstrap.close(),this.port?.close(),this.port=null}async request(e,t){let n=await this.connect(),s=crypto.randomUUID(),i=as(t.timeoutMs??this.options.requestTimeoutMs??120000,\"requestTimeoutMs\");return await new Promise((r,o)=>{let a=setTimeout(()=>{l(),os(n,s),o(e.method===\"call\"||e.method===\"invoke\"?new _(\"timeout\",\"Site tool request timed out after execution may have started\",!1,!0):new _(\"timeout\",\"Site tool request timed out\",!0))},i),c=()=>{l(),os(n,s),o(t.signal?.reason??new DOMException(\"Request aborted\",\"AbortError\"))},u=(p)=>{let d=p.data;if(!B(d)||d.type!==cr||d.version!==le||d.requestId!==s||typeof d.ok!==\"boolean\")return;if(l(),d.ok){r(d.value);return}let m=B(d.error)?d.error:{};o(new _(typeof m.code===\"string\"?m.code:\"bridge_error\",typeof m.message===\"string\"?m.message:\"Site tool request failed\",m.retryable===!0,m.outcomeUnknown===!0))},l=()=>{clearTimeout(a),t.signal?.removeEventListener(\"abort\",c),n.removeEventListener(\"message\",u)};if(t.signal?.aborted){c();return}t.signal?.addEventListener(\"abort\",c,{once:!0}),n.addEventListener(\"message\",u),n.postMessage({type:ar,version:le,requestId:s,...e})})}async connect(){if(this.closed)throw new _(\"closed\",\"Site bridge is closed\");if(this.port)return this.port;if(this.connecting)return await this.connecting;let e=(this.options.createMessageChannel??(()=>new MessageChannel))(),t=as(this.options.connectTimeoutMs??1e4,\"connectTimeoutMs\");return this.connecting=new Promise((n,s)=>{let i=!0,r=setTimeout(()=>{a(),e.port1.close(),s(new _(\"host_timeout\",\"The Site host did not respond\"))},t),o=(c)=>{let u=c.data;if(!B(u)||u.type!==cs||u.version!==le)return;a(),this.targetTools=u.targetTools===1,this.siteData=u.siteData===1,this.viewerSupported=u.viewer===1,this.port=e.port1,n(e.port1)},a=()=>{i=!1,clearTimeout(r),e.port1.removeEventListener(\"message\",o)};e.port1.addEventListener(\"message\",o),e.port1.start(),this.bootstrap.port().then((c)=>{if(!i)return;if(this.closed)throw new _(\"closed\",\"Site bridge is closed\");c.postMessage({type:or,version:le},[e.port2])}).catch((c)=>{a(),e.port1.close(),s(c)})}).finally(()=>{this.connecting=null}),await this.connecting}}function hr(e){if(e.bootstrapPort)return{port:async()=>e.bootstrapPort,close:()=>e.bootstrapPort?.close()};let t=e.siteWindow??globalThis.window,n=e.parentWindow??t?.parent;if(!t||!n||n===t)return{port:async()=>{throw new _(\"host_unavailable\",\"The Site client must run inside a hosted iframe\")},close:()=>{return}};let s=Rr(t);if(s)return{port:async()=>s,close:()=>{return}};let i=null,r=null,o=(l)=>{if(l.source!==n||!Sr(l.data)||l.ports.length!==1)return;c(),i=l.ports[0],i.start(),br(t,i),a?.(i)},a=null,c=()=>t.removeEventListener(\"message\",o),u=new Promise((l,p)=>{a=l,r=p,t.addEventListener(\"message\",o)});return u.catch(()=>{return}),{port:async()=>await u,close:()=>{c(),r?.(new _(\"closed\",\"Site bridge is closed\")),a=null,r=null}}}function Rr(e){let t=e[us];if(!B(t))return null;let n=t.port;return n&&typeof n.postMessage===\"function\"&&typeof n.addEventListener===\"function\"&&typeof n.start===\"function\"?n:null}function br(e,t){try{Object.defineProperty(e,us,{configurable:!0,value:{port:t}})}catch{}}function Sr(e){return B(e)&&e.type===cs&&e.version===le}var wr=[\"member\",\"invited\",\"user\",\"guest\"];async function vr(e){try{if(!await e.siteDataSupported())return null;let t=await e.fetch(\"https://site.opengeni.invalid/v1/workspaces/site-host/site/config\",{method:\"GET\",headers:{accept:\"application/json\"}});if(!t.ok)return await t.body?.cancel(),null;let n=(await t.json())?.capabilities;return kr(n)?n:null}catch{return null}}function kr(e){return B(e)&&typeof e.agent===\"boolean\"&&typeof e.workspaceTools===\"boolean\"&&(e.siteData===\"viewer\"||e.siteData===\"guest\")&&Array.isArray(e.sqlQueryAudiences)&&e.sqlQueryAudiences.every((t)=>t===\"everyone\"||t===\"signed_in\")&&(e.viewAs===null||e.viewAs===\"invited\"||e.viewAs===\"public\")}function Ir(e){return B(e)&&wr.includes(String(e.kind))&&typeof e.id===\"string\"&&e.id.length>0&&(e.name===null||typeof e.name===\"string\")&&(e.email===null||typeof e.email===\"string\")&&typeof e.signedIn===\"boolean\"}function os(e,t){e.postMessage({type:ur,version:le,requestId:t})}function as(e,t){if(!Number.isFinite(e)||e<=0)throw RangeError(`${t} must be positive`);return e}function B(e){return typeof e===\"object\"&&e!==null&&!Array.isArray(e)}Object.defineProperty(globalThis,\"createOpenGeniSiteClient\",{configurable:!0,value:ls});})();\\n';var rT=\"/__opengeni/site-tools/client.js\";var cn=\"/__opengeni/site-tools\";function w5(e=()=>on()){let t=typeof e===\"function\"?e:()=>e,n=oT();return async(r)=>{try{let o=new URL(r.url).pathname;if(o===rT){if(r.method!==\"GET\"&&r.method!==\"HEAD\")return new Response(\"Method not allowed\",{status:405,headers:{allow:\"GET, HEAD\"}});return new Response(r.method===\"HEAD\"?null:Ru,{headers:{\"content-type\":\"text/javascript; charset=utf-8\",\"cache-control\":\"no-cache\"}})}let s=await t();if(r.method===\"POST\"&&(o===`${cn}/resolve`||o===`${cn}/invoke`)){let i=o.endsWith(\"/invoke\"),a=await r.json().catch(()=>null),c=(i?ga:Kf).safeParse(a);if(!c.success||c.data.siteArtifactId||c.data.siteVersionId||\"approvalToken\"in c.data&&c.data.approvalToken)return yt(400,\"invalid_request\",\"Invalid Site target request\");let l=await s.catalog({signal:r.signal}),u=c.data.target,p=l.entries.filter((y)=>(\"identity\"in u)?y.identity.serverId===u.identity.serverId&&y.identity.toolName===u.identity.toolName:y.codemodePath.length===u.path.length&&y.codemodePath.every((_,E)=>_===u.path[E]));if(p.length!==1)return yt(404,\"tool_unavailable\",\"Tool unavailable\");let m=p[0],d={version:1,entry:m,definitionDigest:po(l,m)};if(!i)return Response.json(d);let f=ga.parse(a);if(f.expectedDefinitionDigest!==void 0&&f.expectedDefinitionDigest!==d.definitionDigest)return yt(409,\"tool_definition_stale\",\"The tool definition changed\",!0);r.signal.throwIfAborted();let h=await s.call(m.identity,f.arguments,{operationId:f.operationId,expectedDefinitionDigest:d.definitionDigest,signal:r.signal});return Response.json({operationId:f.operationId,tool:d,result:h})}if(o.startsWith(`${cn}/sdk/`)){let i=o.slice(`${cn}/sdk`.length)+new URL(r.url).search;try{hg(i,\"preview\",r.method)}catch(u){if(u instanceof Ot||u instanceof Do)return yt(404,u.code,u.message);throw u}let a=bg(r.headers);a.set(dg,pg),a.set(mg,n);let c=await s.sessionRequest(i,{method:r.method,signal:r.signal,headers:a,...r.body?{body:await r.text()}:{}}),l=new Headers(c.headers);return l.delete(\"content-encoding\"),l.delete(\"content-length\"),l.delete(\"transfer-encoding\"),new Response(c.body,{status:c.status,statusText:c.statusText,headers:l})}if(r.method===\"GET\"&&o===`${cn}/catalog`){let i=await s.catalog({signal:r.signal});return Response.json(UG(i))}if(r.method===\"GET\"&&o===`${cn}/declarations`){let i=await s.catalog({signal:r.signal});return Response.json({catalogDigest:i.digest,moduleSpecifier:\"@opengeni/sdk\",source:Ri({digest:i.digest,entries:i.entries},{moduleSpecifier:\"@opengeni/sdk\",interfaceName:\"OpenGeniGeneratedTools\",callOptionsType:\"OpenGeniToolCallOptions\",fallbackResultType:\"ToolGatewayResult\",generatedBy:\"@opengeni/codemode local Site preview\",catalogDigestLabel:\"Attempt catalog digest\"})})}if(r.method===\"POST\"&&o===`${cn}/calls`){let i=await r.json();if(!LG(i))return yt(400,\"invalid_request\",\"Invalid Site tool call\");let a=await s.catalog({signal:r.signal});if(i.catalogDigest!==a.digest)return yt(409,\"catalog_stale\",\"The local Site tool catalog changed\",!0);let c=i.operationId??oT(),l=a.entries.find((p)=>p.identity.serverId===i.identity.serverId&&p.identity.toolName===i.identity.toolName);if(!l)return yt(404,\"tool_unavailable\",\"Tool unavailable\");let u=await s.call(i.identity,i.arguments,{operationId:c,expectedDefinitionDigest:po(a,l),signal:r.signal});return Response.json({operationId:c,catalogDigest:a.digest,result:u})}return yt(404,\"not_found\",\"Local Site tool endpoint not found\")}catch(o){if(o instanceof Je){let s=new URL(r.url).pathname===`${cn}/calls`&&o.remoteCode===\"tool_definition_stale\"&&o.retryable===!0&&o.outcomeUnknown===!1;return yt(o.status&&o.status>=400&&o.status<=599?o.status:502,s?\"catalog_stale\":o.remoteCode??o.code,o.message,o.retryable===!0,o.outcomeUnknown===!0)}return yt(500,\"local_codemode_error\",o instanceof Error?o.message:\"Local Site tool request failed\")}}}function UG(e){return{version:e.version,generation:e.generation,digest:e.digest,createdAt:e.createdAt,entries:e.entries}}function LG(e){if(!Tu(e)||typeof e.catalogDigest!==\"string\")return!1;if(e.operationId!==void 0&&typeof e.operationId!==\"string\")return!1;return Tu(e.identity)&&typeof e.identity.serverId===\"string\"&&typeof e.identity.toolName===\"string\"&&Tu(e.arguments)}function yt(e,t,n,r=!1,o=!1){return Response.json({error:{code:t,message:n,retryable:r,...o?{outcomeUnknown:!0}:{}}},{status:e})}function Tu(e){return typeof e===\"object\"&&e!==null&&!Array.isArray(e)}import{createHash as GG,randomUUID as sT}from\"node:crypto\";async function I5(e,t={}){let n=t.maxItems??1e4,r=t.maxPages??200;if(!Number.isSafeInteger(n)||n<1||n>50000||!Number.isSafeInteger(r)||r<1||r>1000)throw Error(\"Invalid selection limit\");let o=new Set,s=new Set,i;for(let a=0;a<r;a++){t.signal?.throwIfAborted();let c=await e(i,t.signal);if(t.signal?.throwIfAborted(),!Array.isArray(c?.ids)||c.ids.length>50000)throw Error(\"Invalid selection page\");for(let l of c.ids){if(typeof l!==\"string\"||!l||l.length>256)throw Error(\"Invalid selection ID\");if(o.add(l),o.size>n)throw Error(\"Selection exceeds item limit; no complete selection returned\")}if(!c.nextPageToken)return Object.freeze([...o]);if(typeof c.nextPageToken!==\"string\"||c.nextPageToken.length>4096)throw Error(\"Invalid page token\");if(!c.ids.length||s.has(c.nextPageToken))throw Error(\"Pagination did not progress; no complete selection returned\");s.add(c.nextPageToken),i=c.nextPageToken}throw Error(\"Selection exceeds page limit; no complete selection returned\")}function k5(e,t=1000){if(!Number.isSafeInteger(t)||t<1||t>1000||e.length>50000)throw Error(\"Invalid batch limit\");if(e.some((o)=>typeof o!==\"string\"||!o||o.length>256))throw Error(\"Invalid selection ID\");let n=[...new Set(e)],r=Array.from({length:Math.ceil(n.length/t)},(o,s)=>Object.freeze({operationId:sT(),ids:Object.freeze(n.slice(s*t,(s+1)*t))}));return Object.freeze({id:sT(),selectionDigest:GG(\"sha256\").update(JSON.stringify(n)).digest(\"hex\"),count:n.length,batches:Object.freeze(r)})}function R5(e,t){let n=new Map,r=new Set(e.batches.map((s)=>s.operationId));for(let s of t){if(![\"acknowledged\",\"failed_before_effect\",\"unknown\",\"waiting\"].includes(s.outcome))throw Error(\"Invalid batch outcome\");if(!r.has(s.operationId)||n.has(s.operationId))throw Error(\"Receipt does not uniquely identify a planned batch\");n.set(s.operationId,s.outcome)}let o={acknowledged:0,failed_before_effect:0,unknown:0,waiting:0,unstarted:0};for(let s of e.batches)o[n.get(s.operationId)??\"unstarted\"]+=s.ids.length;return{selected:e.count,...o,individualStateVerified:!1}}class Je extends Error{status;code=\"codemode_transport_error\";remoteCode;retryable;outcomeUnknown;details;constructor(e,t=null,n={}){super(e);this.status=t;this.name=\"CodemodeTransportError\",this.remoteCode=n.code??null,this.retryable=n.retryable??null,this.outcomeUnknown=n.outcomeUnknown??null,this.details=n.details??null}}class Au extends Error{operation;code;constructor(e,t){super(e.errorMessage??`Codemode operation ${e.state}`);this.operation=e;this.code=t;this.name=\"CodemodeOperationError\",Object.defineProperty(this,\"operation\",{value:e,enumerable:!1})}}class Cu extends Error{operationId;approvalRequestId;code=\"codemode_approval_pending\";state=\"waiting_for_approval\";constructor(e,t){super(`Operation ${e} is waiting for approval. After review, read or resume this handle; do not submit its arguments again.`);this.operationId=e;this.approvalRequestId=t;this.name=\"CodemodeApprovalPendingError\"}}class lT extends Error{result;code;retryable;constructor(e){let t=HG(e);super(t.message);this.result=e;this.name=\"CodemodeToolCallError\",this.code=t.code,this.retryable=t.retryable}}class uT extends Error{code=\"invalid_tool_result\";constructor(e){super(e);this.name=\"CodemodeToolContractError\"}}class wu{options;baseUrl;fetchImpl;pollIntervalMs;timeoutMs;catalogSnapshot=null;constructor(e){this.options=e;if(this.baseUrl=e.baseUrl.replace(/\\/+$/u,\"\"),!/^https?:\\/\\//u.test(this.baseUrl))throw Error(\"Codemode baseUrl must be an absolute HTTP(S) URL\");this.fetchImpl=e.fetch??globalThis.fetch.bind(globalThis),this.pollIntervalMs=Ei(e.pollIntervalMs??500,50,30000),this.timeoutMs=Ei(e.timeoutMs??600000,1000,3600000)}async catalog(e={}){if(this.catalogSnapshot&&!e.refresh)return this.catalogSnapshot;let t=await this.request(\"/catalog\",{method:\"GET\",...e.signal?{signal:e.signal}:{}}),n=Ci(await t.json());return this.catalogSnapshot=n,n}async tools(e={}){return JG(await this.catalog(e),this)}async call(e,t={},n={}){return(await this.callResolved((r)=>r.entries.find((o)=>o.identity.serverId===e.serverId&&o.identity.toolName===e.toolName)??null,t,n)).result}async callResolved(e,t,n){let r=await this.catalog(n.signal?{signal:n.signal}:{}),o=e(r);if(!o)throw new mt;let s=()=>{if(n.expectedDefinitionDigest!==void 0&&n.expectedDefinitionDigest!==po(r,o))throw new Je(\"The tool definition changed before execution\",409,{code:\"tool_definition_stale\",retryable:!0,outcomeUnknown:!1})};s();let i=n.operationId??BG(),a=Date.now()+Ei(n.timeoutMs??this.timeoutMs,1000,3600000),c=!1,l=!1,u=null,p=0;while(!0){if(Eu(n.signal),Date.now()>=a)throw new Je(`Codemode operation ${i} did not settle before the client deadline`);if(!c||(u?.state===\"queued\"||u?.state===\"running\")&&Date.now()>=p){c=!0,p=Date.now()+2000;try{u=await this.submit(i,r.digest,o.identity,t,n.signal)}catch(d){if(u===null&&!l&&d instanceof Je&&d.outcomeUnknown!==!0&&d.retryable!==!1&&d.remoteCode===\"codemode_catalog_stale\"){if(l=!0,r=await this.catalog({refresh:!0,...n.signal?{signal:n.signal}:{}}),o=e(r),!o)throw new mt;s(),c=!1,p=0;continue}if(n.signal?.aborted)throw d;if(u===null&&!VG(d))throw d;let f;try{f=await this.read(i,n.signal)}catch(h){if(n.signal?.aborted)throw h;throw new Je(`Codemode operation ${i} could not be reconciled after its submission response failed`,null,{code:\"codemode_operation_recovery_unavailable\",retryable:!0,outcomeUnknown:!0,details:{operationId:i}})}FG(f,{operationId:i,catalog:r,identity:o.identity,arguments:t}),u=f}}else u=await this.read(i,n.signal);if(u.state===\"waiting_for_approval\")throw new Cu(u.operationId,u.approvalRequestId);if(u.state===\"completed\")return{result:jr.parse(u.result),entry:o};if([\"failed\",\"outcome_unknown\",\"cancelled\"].includes(u.state))throw new Au(u,u.errorCode??`codemode_${u.state}`);await Pu(this.pollIntervalMs,n.signal)}}async callPath(e,t={},n={}){if(e.length<2||e.some((r)=>r.length===0))throw new mt;return(await this.callResolved((r)=>aT(r,e),t,n)).result}async callPathValue(e,t={},n={}){if(e.length<2||e.some((i)=>i.length===0))throw new mt;let{result:r,entry:o}=await this.callResolved((i)=>aT(i,e),t,n);if(!o.outputSchema)return r;if(r.isError)throw new lT(r);if(!r.structuredContent)throw new uT(`Codemode tool ${e.join(\".\")} declared outputSchema but returned no structured content`);if(!r.content.some((i)=>i.type===\"image\"))return r.structuredContent;let s=await Ai(r);return{structuredContent:r.structuredContent,images:s,otherContent:r.content.filter((i)=>i.type!==\"image\")}}async submit(e,t,n,r,o){return await cT(o,async()=>{let s=await this.request(\"/calls\",{method:\"POST\",...o?{signal:o}:{},headers:{\"content-type\":\"application/json\"},body:JSON.stringify({operationId:e,catalogDigest:t,identity:n,arguments:r,durableApproval:!0})});return Hf.parse(await s.json()).operation})}async status(e,t){let n=await this.read(e,t);return{operationId:n.operationId,state:n.state,approvalRequestId:n.approvalRequestId,result:n.result,errorCode:n.errorCode,errorMessage:n.errorMessage}}async resume(e,t={}){let n=Date.now()+Ei(t.timeoutMs??this.timeoutMs,1000,3600000);while(!0){Eu(t.signal);let r=await this.read(e,t.signal);if(r.state===\"waiting_for_approval\")throw new Cu(r.operationId,r.approvalRequestId);if(r.state===\"completed\")return jr.parse(r.result);if([\"failed\",\"outcome_unknown\",\"cancelled\"].includes(r.state))throw new Au(r,r.errorCode??`codemode_${r.state}`);if(Date.now()>=n)throw new Je(`Codemode operation ${e} did not settle before the client deadline`);await Pu(this.pollIntervalMs,t.signal)}}async read(e,t){return await cT(t,async()=>{let n=await this.request(`/calls/${e}`,{method:\"GET\",...t?{signal:t}:{}});return ya.parse(await n.json())})}async sessionRequest(e,t){return yg(e,\"site-host\"),this.request(`/sdk${e}`,t,!1)}async request(e,t,n=!0){let r=typeof this.options.token===\"function\"?await this.options.token():this.options.token,o=await this.fetchImpl(`${this.baseUrl}${e}`,{...t,headers:{...Object.fromEntries(new Headers(t.headers).entries()),authorization:`Bearer ${r}`,\"x-opengeni-codemode-capabilities\":\"durable-approval-v1\"}});if(!o.ok&&n){let s=`Codemode request failed with HTTP ${o.status}`,i={};try{let a=ZG(await o.json());if(a?.message)s=a.message;if(a)i={...a.code?{code:a.code}:{},...a.retryable===void 0?{}:{retryable:a.retryable},...a.outcomeUnknown===void 0?{}:{outcomeUnknown:a.outcomeUnknown},...a.details?{details:a.details}:{}}}catch{}throw new Je(s,o.status,i)}return o}}function VG(e){return!(e instanceof Je)||e.outcomeUnknown===!0}function FG(e,t){if(e.operationId===t.operationId&&e.accountId===t.catalog.accountId&&e.workspaceId===t.catalog.workspaceId&&e.sessionId===t.catalog.sessionId&&e.turnId===t.catalog.turnId&&e.attemptId===t.catalog.attemptId&&e.executionGeneration===t.catalog.executionGeneration&&e.catalogDigest===t.catalog.digest&&e.identity.serverId===t.identity.serverId&&e.identity.toolName===t.identity.toolName&&ft(e.arguments)===ft(t.arguments))return;throw new Je(\"Codemode operation id is already bound to a different request\",409,{code:\"codemode_operation_conflict\",retryable:!1,outcomeUnknown:!1})}function JG(e,t){let n=Ci(e),r=Object.create(null);for(let o of n.entries){let s=r;for(let c of o.codemodePath.slice(0,-1)){let l=s[c];if(typeof l===\"function\")throw Error(\"Codemode path collides with a tool\");if(!l)l=Object.create(null),s[c]=l;s=l}let i=o.codemodePath.at(-1),a=async(c={},l={})=>await t.callPathValue(o.codemodePath,c,l);Object.defineProperty(a,\"entry\",{value:o,enumerable:!1}),s[i]=a}return r}class dT{catalog;gateway;constructor(e,t){this.catalog=e;this.gateway=t}async call(e,t={}){return await(await this.prepareCall(e,t)).execute()}async prepareCall(e,t={}){let n=fa.parse(e);return await this.gateway.prepareCall(n,t)}effectDigest(e){return this.gateway.effectDigest(e)}async callModel(e){return await this.gateway.callModel(e)}}function M5(e){let t=(e.createdAt??new Date).toISOString(),n=MR(e.definitions.map((s)=>({...s,execute:async(i,a)=>await s.execute(i,{...a,caller:No.parse(a.caller)})}))),r={version:pa,...e.scope,generation:e.generation,createdAt:t,...e.firstPartyMcpPermissions!==void 0?{firstPartyMcpPermissions:[...e.firstPartyMcpPermissions]}:{},entries:[...n.entries]},o=WG({...r,digest:pT(r)});return new dT(o,n.create({catalogDigest:o.digest,requireApproval:(s,i)=>i.kind===\"codemode\"&&s.approval===\"human\",...e.confirmModelApproval?{confirmModelApproval:({entry:s,subjectId:i})=>e.confirmModelApproval({modelName:s.modelName,subjectId:i})}:{},...e.authorize?{authorize:async({call:s,entry:i})=>await e.authorize({call:fa.parse(s),entry:i})}:{},...e.resolveArguments?{resolveArguments:e.resolveArguments}:{}}))}function pT(e){let{createdAt:t,...n}=e;return ft(n)}function q5(e){return ft(e)}function z5(e,t){if(!iT.test(e)||!iT.test(t))throw Error(\"Codemode dispatch subject requires UUID workspace and attempt ids\");return`codemode.${e}.${t}.dispatch`}function j5(e){return new TextEncoder().encode(JSON.stringify(ba.parse(e)))}function N5(e){return ba.parse(JSON.parse(new TextDecoder().decode(e)))}function D5(e){return new TextEncoder().encode(JSON.stringify(va.parse(e)))}function U5(e){return va.parse(JSON.parse(new TextDecoder().decode(e)))}function Ci(e){return hT(e).catalog}var mT=new WeakMap;function WG(e){let t=hT(structuredClone(e));if(fT(t.catalog))gT(t.catalog),mT.set(t.catalog,t);return t.catalog}function fT(e){if(e===null||typeof e!==\"object\")return!0;let t=Object.getPrototypeOf(e);if(!Array.isArray(e)&&t!==Object.prototype&&t!==null)return!1;for(let n of Object.values(e))if(!fT(n))return!1;return!0}function gT(e){if(e===null||typeof e!==\"object\")return;for(let t of Object.values(e))gT(t);Object.freeze(e)}function hT(e){if(e!==null&&typeof e===\"object\"){let s=mT.get(e);if(s)return{...s}}let t=Bf.parse(e),n=KG(t),{digest:r,...o}=t;if(pT(o)!==r)throw new uu;return{catalog:t,byteLength:n}}function KG(e){let t=new TextEncoder().encode(JSON.stringify(e)).byteLength;if(t>zf)throw new du;return t}var iT=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu;function Ei(e,t,n){if(!Number.isFinite(e))return t;return Math.max(t,Math.min(n,Math.floor(e)))}function Eu(e){if(e?.aborted)throw e.reason??new DOMException(\"Aborted\",\"AbortError\")}function HG(e){let n=e.structuredContent?.error;return{code:typeof n?.code===\"string\"?n.code:\"tool_error\",message:typeof n?.message===\"string\"?n.message:\"Codemode tool failed\",retryable:n?.retryable===!0}}function aT(e,t){let n=e.entries.filter((r)=>r.codemodePath.length===t.length&&r.codemodePath.every((o,s)=>o===t[s]));return n.length===1?n[0]:null}function ZG(e){if(!e||typeof e!==\"object\"||Array.isArray(e))return null;let t=e,n=t.error&&typeof t.error===\"object\"&&!Array.isArray(t.error)?t.error:t,r=n.details&&typeof n.details===\"object\"&&!Array.isArray(n.details)?n.details:void 0,o=r?.code,s=typeof o===\"string\"&&/^[a-z0-9_]{1,128}$/u.test(o)?o:void 0,i=typeof n.message===\"string\"?n.message:void 0,a=typeof n.retryable===\"boolean\"?n.retryable:void 0,c=typeof n.outcomeUnknown===\"boolean\"?n.outcomeUnknown:void 0;return i||s||a!==void 0||c!==void 0||r?{...i?{message:i}:{},...s?{code:s}:{},...a===void 0?{}:{retryable:a},...c===void 0?{}:{outcomeUnknown:c},...r?{details:r}:{}}:null}var YG=[100,250,500,1000,2000];function XG(e){return e instanceof Je&&e.status!==null&&e.status>=500&&e.retryable===!0&&e.outcomeUnknown!==!0}async function cT(e,t){for(let n=0;;n+=1)try{return await t()}catch(r){let o=YG[n];if(o===void 0||e?.aborted||!XG(r))throw r;await Pu(o+Math.floor(Math.random()*o),e)}}async function Pu(e,t){if(!t){await new Promise((n)=>setTimeout(n,e));return}Eu(t),await new Promise((n,r)=>{let o=setTimeout(()=>{t.removeEventListener(\"abort\",s),n()},e),s=()=>{clearTimeout(o),r(t.reason??new DOMException(\"Aborted\",\"AbortError\"))};t.addEventListener(\"abort\",s,{once:!0})})}export{Cn as AttemptToolApprovalRequiredError,uu as AttemptToolCatalogIntegrityError,xi as AttemptToolCatalogStaleError,du as AttemptToolCatalogTooLargeError,dT as AttemptToolEnvironment,Si as AttemptToolInputValidationError,mt as AttemptToolNotFoundError,Ii as AttemptToolOutputValidationError,nn as AttemptToolPathCollisionError,Sr as CODEMODE_ENVIRONMENT,cn as CODEMODE_SITE_LOCAL_PATH,Cu as CodemodeApprovalPendingError,go as CodemodeArtifact,xu as CodemodeArtifactCollection,GR as CodemodeArtifactExport,YR as CodemodeAuth,ku as CodemodeAuthRun,Su as CodemodeBrowser,XR as CodemodeBrowserAuth,KR as CodemodeBrowserClipboard,VR as CodemodeBrowserCollection,WR as CodemodeBrowserDownload,JR as CodemodeBrowserDownloadCollection,FR as CodemodeBrowserIdentityCollection,an as CodemodeBrowserLocator,ZR as CodemodeBrowserTab,HR as CodemodeBrowserTabCollection,wu as CodemodeClient,Iu as CodemodeComputer,eT as CodemodeComputerClipboard,QR as CodemodeComputerCollection,Ir as CodemodeComputerLocator,nT as CodemodeComputerTarget,tT as CodemodeComputerTargetCollection,Au as CodemodeOperationError,lT as CodemodeToolCallError,uT as CodemodeToolContractError,fo as CodemodeToolExecutionError,Je as CodemodeTransportError,BR as OpenGeniCodemode,O as callStructured,PG as codemodeArtifactIds,UR as codemodeClientProvider,z5 as codemodeDispatchSubject,I5 as collectIdPages,JG as compileCodemodeTools,M5 as createAttemptToolEnvironment,w5 as createCodemodeSiteRequestHandler,AG as createCodemodeTools,DG as createOpenGeniCodemode,U5 as decodeCodemodeDispatchAck,N5 as decodeCodemodeDispatchRequest,pT as digestAttemptToolCatalog,q5 as digestCodemodeOperationRequest,D5 as encodeCodemodeDispatchAck,j5 as encodeCodemodeDispatchRequest,on as environmentCodemodeClient,c5 as generateCodemodeDeclarations,XG as isTransientCodemodeTransportError,fu as jsonSchemaToTypeScript,Ai as materializeCodemodeImages,r5 as openGeni,Ci as parseVerifiedAttemptToolCatalog,k5 as planIdBatches,R5 as summarizeIdBatches,J9 as tools,hT as verifyAttemptToolCatalog};\n","package.json":"{\"type\":\"commonjs\"}\n"}}