@cline/shared 0.0.93 → 0.0.94-nightly.1792204233

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
- function pt(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 Ln(e,t="|"){return e.map((n)=>Un(n)).join(t)}function mt(e,t){if(typeof t==="bigint")return t.toString();return t}class vi{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;if(e!==void 0)this._value=e(),this._getter=void 0;return this._value}}function ft(e){return new vi(e)}function Ti(e){return e===null||e===void 0}function Bt(e){let t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function Ci(e,t){let n=e/t,r=Math.round(n),o=4*Number.EPSILON*Math.max(Math.abs(n),1);if(Math.abs(n-r)<o)return 0;return n-r}function te(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function gt(e){let t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function be(e){return gt(e._zod.def)??e._zod.def.shape}function ki(e,t,n){Object.defineProperty(e,t,{get(){let r=n();return te(this,t,r),r},enumerable:!0,configurable:!0})}function Ei(e,t,n){if(t in e)te(e,t,n);else e[t]=n}function Oe(e,t,n,r){let o=be(t);for(let i of n){let s=Object.getOwnPropertyDescriptor(o,i);if(!s.enumerable)continue;if(s.get)ki(e,i,()=>{let a=t._zod.def.shape[i];return r?r(a,i):a});else Ei(e,i,r?r(s.value,i):s.value)}}function _p(e,t){for(let n of Reflect.ownKeys(t)){let r=Object.getOwnPropertyDescriptor(t,n);if(!r.enumerable)continue;if(r.get)ki(e,n,()=>t[n]);else Ei(e,n,r.value)}}function ne(...e){let t={};for(let n of e){let r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function Ri(e){return JSON.stringify(e)}function Ai(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var Dn="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Ue(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}var Ii=ft(()=>{if(Y.jitless)return!1;if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function ze(e){if(Ue(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(Ue(n)===!1)return!1;if(Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)return!1;return!0}function Bn(e){if(ze(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 wi=new Set(["string","number","symbol"]);function Ee(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ue(e,t,n){let r=new e._zod.constr(t??e._zod.def);if(!t||n?.parent)r._zod.parent=e;return r}function _(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 Un(e){if(typeof e==="bigint")return e.toString()+"n";if(typeof e==="string")return`"${e}"`;return`${e}`}function Pi(e){return Object.keys(e).filter((t)=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}var Ut=(()=>({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]}))(),Zn={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function vp(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 i={};return Oe(i,e,Zt(e,t)),ue(e,ne(n,{shape:i,checks:[]}))}function Zt(e,t){let n=be(e),r=[];for(let o of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,o)?.enumerable)throw Error(`Unrecognized key: "${String(o)}"`);if(t[o])r.push(o)}return r}function Tp(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 i=new Set(Zt(e,t)),s={};return Oe(s,e,Reflect.ownKeys(be(e)).filter((a)=>!i.has(a))),ue(e,ne(n,{shape:s,checks:[]}))}function Cp(e,t){if(!ze(t))throw Error("Invalid input to extend: expected a plain object");let n=e._zod.def.checks;if(n&&n.length>0){let o=be(e);for(let i of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(o,i)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return ue(e,ne(e._zod.def,{shape:Mi(e,t)}))}function Mi(e,t){let n={};return Oe(n,e,Reflect.ownKeys(be(e))),_p(n,t),n}function kp(e,t){if(!ze(t))throw Error("Invalid input to safeExtend: expected a plain object");return ue(e,ne(e._zod.def,{shape:Mi(e,t)}))}function Ep(e,t){if(!t?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let n={};Oe(n,e,Reflect.ownKeys(be(e))),Oe(n,t,Reflect.ownKeys(be(t)));let r=ne(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return ue(e,r)}function Oi(e,t,n,r="partial"){let i=t._zod.def.checks;if(i&&i.length>0)throw Error(`.${r}() cannot be used on object schemas containing refinements`);let a=n?new Set(Zt(t,n)):void 0,c={};return Oe(c,t,Reflect.ownKeys(be(t)),e&&((u,l)=>a&&!a.has(l)?u:new e({type:"optional",innerType:u}))),ue(t,ne(t._zod.def,{shape:c,checks:[]}))}function Rp(e,t,n){let r=n?new Set(Zt(t,n)):void 0,o={};return Oe(o,t,Reflect.ownKeys(be(t)),(i,s)=>r&&!r.has(s)?i:new e({type:"nonoptional",innerType:i})),ue(t,ne(t._zod.def,{shape:o}))}function oe(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 zi(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 de(e,t){return t.map((n)=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function dt(e){return typeof e==="string"?e:e?.message}function Fn(e){let t=[];for(let n of e??[]){let r=n._zod.def;if(!/_(length|size)$|_equals$/.test(r.check))break;let o=r.maximum??r.length??r.size;if(o>=0)t.push([o,n])}return t}function Ft(e,t,n){var r;for(let o=t;o<e.length;o++)(r=e[o]).schema??(r.schema=n)}function pe(e,t,n){var r;let o=e.inst?._zod?.traits;if(o?.has("$ZodType"))if(o.has("$ZodCheck"))(r=e).schema??(r.schema=e.inst);else e.schema=e.inst;let i=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,s=e.message?e.message:dt(e.inst?._zod.def?.error?.(e))??dt(i?.(e))??dt(t?.error?.(e))??dt(n.customError?.(e))??dt(n.localeError?.(e))??"Invalid input",a={};for(let c of Object.keys(e)){if(c==="inst"||c==="schema"||c==="continue"||c==="input"||c==="__proto__")continue;a[c]=e[c]}if(a.path??(a.path=[]),a.message=s,t?.reportInput)a.input=e.input;return a}var Ap=/[\uD800-\uDBFF]/;function Ht(e){let t=e.length;if(!Ap.test(e))return t;let n=t;for(let r=0;r<t-1;r++)if((e.charCodeAt(r)&64512)===55296&&(e.charCodeAt(r+1)&64512)===56320)n--,r++;return n}function jt(e){if(Array.isArray(e))return"array";if(typeof e==="string")return"string";return"unknown"}function Ni(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";let n=e;if(n&&Object.getPrototypeOf(n)!==Object.prototype&&"constructor"in n&&n.constructor)return n.constructor.name}}return t}function Ne(...e){let[t,n,r]=e;if(typeof t==="string")return{message:t,code:"custom",input:n,inst:r};return{...t}}function $i(e,t){for(let n in t){let r=Object.getOwnPropertyDescriptor(t,n);if(r.get)Object.defineProperty(e,n,{...r,enumerable:!1});else Ip(e,n,r.value)}}function xe(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function Vt(e,t,n){return xe(e,t,n,!1)}function Hn(e,t){for(let n in e){let r=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return xe(this,n,r(this))},set(o){xe(this,n,o)}})}return t}function Ip(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:xe(this,t,n.bind(this))},set(r){xe(this,t,r)}})}function wp(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}var $n,ke=!1,Pp={configurable:!0,get(){ke=!0;return}};function P(e,t,n){let r=Object.getPrototypeOf(e._zod);if(t in r&&$n!==e._zod){$n=void 0;return}$n=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,Pp);let o=ke;ke=!1;try{let i=n(this);if(ke)delete this[t];else Object.defineProperty(this,t,{configurable:!0,writable:!0,value:i});return ke=ke||o,i}catch(i){throw delete this[t],ke=ke||o,i}},set(o){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:o})}})}function Mp(e,t,n,r){let o=wp(e,t);if(!o)return;Object.defineProperty(o,t,{configurable:!0,get(){let i={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,i),i.value=n(this),Object.defineProperty(this,t,i),i.value},set(i){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:i})}})}var Op="~constantCatch";function Li(e){let t=()=>e;return t[Op]=!0,t}var Di;var jn={value:void 0,enumerable:!1},Bi="captureStackTrace"in Error?Error:null;function zp(e){let t=Bi;if(t){let n=t.stackTraceLimit;if(typeof n==="number"){try{t.stackTraceLimit=0}catch{return Bi=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function h(e,t,n,r){let o={};function i(m){this.def=m,this.constr=p,this.traits=new Set}i.prototype=o;let s=n,a=s&&new WeakSet;function c(m,f){if(!m._zod){jn.value=new i(f);try{Object.defineProperty(m,"_zod",jn)}finally{jn.value=void 0}}else if(m._zod.traits.has(e))return;if(m._zod.traits.add(e),t(m,f),a){let y=Object.getPrototypeOf(m),S=m._zod.constr.prototype,v=y;while(v&&v!==S)v=Object.getPrototypeOf(v);let k=v??y;if(!a.has(k))a.add(k),$i(k,s)}let g=p.prototype;for(let y in g){if(!Object.prototype.hasOwnProperty.call(g,y))continue;if(!(y in m))m[y]=g[y].bind(m)}}let u=r?.Parent??Object;class l extends u{}Object.defineProperty(l,"name",{value:e});function p(m){let f=r?.Parent?zp(l):this;c(f,m);let g=f._zod.deferred;if(g){for(let S of g)S();f._zod.deferred=void 0}let y=globalThis.__zod_globalConfig?.postProcessor;if(y)y(f);return f}return Object.defineProperty(p,"init",{value:c}),Object.defineProperty(p,Symbol.hasInstance,{value:(m)=>{if(r?.Parent&&m instanceof r.Parent)return!0;return m?._zod?.traits?.has(e)}}),Object.defineProperty(p,"name",{value:e}),p}class me extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class ht extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`);this.name="ZodEncodeError"}}(Di=globalThis).__zod_globalConfig??(Di.__zod_globalConfig={});var Y=globalThis.__zod_globalConfig;function Q(e){if(e)Object.assign(Y,e);return Y}function Np(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,mt,2)),e.message}function $p(e){this._zod.message=e}var Lp={get:Np,set:$p,enumerable:!0,configurable:!0},qn={value:void 0,enumerable:!1},Ui=new WeakSet([Object.prototype,Error.prototype]),Zi=(e,t)=>{e.name="$ZodError",qn.value=t,Object.defineProperty(e,"issues",qn),qn.value=void 0,Object.defineProperty(e,"message",Lp);let n=Object.getPrototypeOf(e);if(!Ui.has(n))Ui.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){let r=()=>this.message;return Object.defineProperty(this,"toString",{value:r,configurable:!0,writable:!0}),r},set(r){Object.defineProperty(this,"toString",{value:r,configurable:!0,writable:!0})}})},Fi=h("$ZodError",Zi),Gn=h("$ZodError",Zi,void 0,{Parent:Error});function Dp(e,t,n){if(!Object.prototype.hasOwnProperty.call(e,t))if(t==="__proto__")Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0});else e[t]=n();return e[t]}function Kn(e,t=(n)=>n.message){let n={},r=[];for(let o of e.issues)if(o.path.length>0)Dp(n,o.path[0],()=>[]).push(t(o));else r.push(t(o));return{formErrors:r,fieldErrors:n}}function Wn(e,t=(n)=>n.message){let n={_errors:[]},r=(o,i=[])=>{for(let s of o.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)n._errors.push(t(s));else{let c=n,u=0;while(u<a.length){let l=a[u],p=u===a.length-1;if(l==="_errors"){if(p)c._errors.push(t(s));u++;continue}if(!Object.prototype.hasOwnProperty.call(c,l))Object.defineProperty(c,l,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let m=c[l];if(p)m._errors.push(t(s));c=m,u++}}}};return r(e),n}function Bp(e){let t=[],n=e.map((r)=>typeof r==="object"?r.key:r);for(let r of n)if(typeof r==="number")t.push(`[${r}]`);else if(typeof r==="symbol")t.push(`[${JSON.stringify(String(r))}]`);else if(/[^\w$]/.test(r))t.push(`[${JSON.stringify(r)}]`);else{if(t.length)t.push(".");t.push(r)}return t.join("")}function Hi(e){let t=[],n=[...e.issues].sort((r,o)=>(r.path??[]).length-(o.path??[]).length);for(let r of n)if(t.push(`✖ ${r.message}`),r.path?.length)t.push(` → at ${Bp(r.path)}`);return t.join(`
2
- `)}function qt(e,t){return{callee:t?.callee??e,Err:t?.Err}}var yt=(e)=>{let t=(n,r,o,i)=>{let s=o?{...o,async:!1}:{async:!1},a=n._zod.run({value:r,issues:[]},s);if(a instanceof Promise)throw new me;if(a.issues.length){let c=new(i?.Err??e)(a.issues.map((u)=>pe(u,s,Q())));throw Dn(c,i?.callee??t),c}return a.value};return t},Jn=yt(Gn),bt=(e)=>{let t=async(n,r,o,i)=>{let s=o?{...o,async:!0}:{async:!0},a=n._zod.run({value:r,issues:[]},s);if(a instanceof Promise)a=await a;if(a.issues.length){let c=new(i?.Err??e)(a.issues.map((u)=>pe(u,s,Q())));throw Dn(c,i?.callee??t),c}return a.value};return t},Yn=bt(Gn),Gt=(e)=>(t,n,r)=>{let o=r?{...r,async:!1}:{async:!1},i=t._zod.run({value:n,issues:[]},o);if(i instanceof Promise)throw new me;return i.issues.length?ji(e,i.issues,o):{success:!0,data:i.value}};function ji(e,t,n){let r;return{success:!1,get error(){if(!r)r=new e(t.map((o)=>pe(o,n,Q()))),t=void 0,n=void 0;return r},set error(o){r=o,t=void 0,n=void 0}}}var Kt=(e)=>async(t,n,r)=>{let o=r?{...r,async:!0}:{async:!0},i=t._zod.run({value:n,issues:[]},o);if(i instanceof Promise)i=await i;return i.issues.length?ji(e,i.issues,o):{success:!0,data:i.value}};var Zp=Symbol.for("zod.compile.invalid"),Fp=Symbol.for("zod.compile.fallback"),Xn=(e,t,n)=>{let r=e._zod.bag.validator;if(r!==void 0){if(r(t)!==Zp)return!0;if(r.definite===!0&&n===void 0)return!1}return Hp(e,t,n)};function Hp(e,t,n){let r=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},o=e._zod.bag.fallbackRun,i;if(o)r[Fp]=!0,i=o({value:t,issues:[]},r);else i=e._zod.run({value:t,issues:[]},r);if(i instanceof Promise)throw new me;return i.issues.length===0}var Qn=async(e,t,n)=>{let r=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},o=e._zod.run({value:t,issues:[]},r);if(o instanceof Promise)o=await o;return o.issues.length===0},Vi=(e)=>{let t=yt(e),n=(r,o,i,s)=>{let a=i?{...i,direction:"backward"}:{direction:"backward"};return t(r,o,a,qt(n,s))};return n};var qi=(e)=>{let t=yt(e),n=(r,o,i,s)=>t(r,o,i,qt(n,s));return n};var Gi=(e)=>{let t=bt(e),n=async(r,o,i,s)=>{let a=i?{...i,direction:"backward"}:{direction:"backward"};return await t(r,o,a,qt(n,s))};return n};var Ki=(e)=>{let t=bt(e),n=async(r,o,i,s)=>await t(r,o,i,qt(n,s));return n};var Wi=(e)=>(t,n,r)=>{let o=r?{...r,direction:"backward"}:{direction:"backward"};return Gt(e)(t,n,o)};var Ji=(e)=>(t,n,r)=>Gt(e)(t,n,r);var Yi=(e)=>async(t,n,r)=>{let o=r?{...r,direction:"backward"}:{direction:"backward"};return Kt(e)(t,n,o)};var Xi=(e)=>async(t,n,r)=>Kt(e)(t,n,r);var Qi=/^[cC][0-9a-z]{6,}$/,es=/^[0-9a-z]+$/,ts=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,ns=/^[0-9a-vA-V]{20}$/,rs=/^[A-Za-z0-9]{27}$/,os=/^[a-zA-Z0-9_-]{21}$/;function is(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var ss=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var as=/^([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})$/,tr=(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 cs=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var jp="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function us(){return new RegExp(jp,"u")}var ls=/^(?:(?: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])$/,ds=/^(([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 ps=/^((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])$/,ms=/^(([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}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,fs=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,gs=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;var hs=/^https?$/,ys=/^\+[1-9]\d{6,14}$/;var bs="(?:(?:\\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])))";function Vp(e){return new RegExp(`^${e}$`)}var xs=Vp(bs);function er(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}}`:e.seconds?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?":"(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?"}function Ss(e){return new RegExp(`^${er(e)}$`)}function _s(e){let t=["Z"];if(e.offset)t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let n=`${er({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,r=e.local?`${n}|${er({precision:e.precision})}`:n;return new RegExp(`^${bs}T(?:${r})$`)}var vs=/^[\s\S]{0,}$/;var nr=/^-?\d+$/,xt=/^-?\d+(?:\.\d+)?$/,Ts=/^(?:true|false)$/i;var Cs=/^[^A-Z]*$/,ks=/^[^a-z]*$/;var G=h("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])});var rr=(e)=>{let t=e.value;return!Ti(t)&&t.length!==void 0},Wt={number:"number",bigint:"bigint",object:"date"},or=h("$ZodCheckLessThan",(e,t)=>{G.init(e,t);let n=Wt[typeof t.value];e._zod.check=(r)=>{if(t.inclusive?r.value<=t.value:r.value<t.value)return;r.issues.push({origin:Wt[typeof r.value]??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})}}),ir=h("$ZodCheckGreaterThan",(e,t)=>{G.init(e,t);let n=Wt[typeof t.value];e._zod.check=(r)=>{if(t.inclusive?r.value>=t.value:r.value>t.value)return;r.issues.push({origin:Wt[typeof r.value]??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})}}),Es=h("$ZodCheckMultipleOf",(e,t)=>{G.init(e,t),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"?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):Ci(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})}}),Rs=h("$ZodCheckNumberFormat",(e,t)=>{G.init(e,t),t.format=t.format||"float64";let n=t.format?.includes("int"),r=n?"int":"number",[o,i]=Ut[t.format];e._zod.check=(s)=>{let a=s.value;if(n){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<o)s.issues.push({origin:"number",input:a,code:"too_small",minimum:o,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 As=h("$ZodCheckMaxLength",(e,t)=>{var n;G.init(e,t),(n=e._zod.def).when??(n.when=rr),e._zod.check=(r)=>{let o=r.value,i=o.length;if((typeof o==="string"&&i>t.maximum?Ht(o):i)<=t.maximum)return;let a=jt(o);r.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Is=h("$ZodCheckMinLength",(e,t)=>{var n;G.init(e,t),(n=e._zod.def).when??(n.when=rr),e._zod.check=(r)=>{let o=r.value,i=o.length;if((typeof o==="string"&&i>=t.minimum&&i<t.minimum*2?Ht(o):i)>=t.minimum)return;let a=jt(o);r.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),ws=h("$ZodCheckLengthEquals",(e,t)=>{var n;G.init(e,t),(n=e._zod.def).when??(n.when=rr),e._zod.check=(r)=>{let o=r.value,i=o.length,s=typeof o==="string"&&i>=t.length&&i<=t.length*2?Ht(o):i;if(s===t.length)return;let a=jt(o),c=s>t.length;r.issues.push({origin:a,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),St=h("$ZodCheckStringFormat",(e,t)=>{var n,r;if(G.init(e,t),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=()=>{})}),Ps=h("$ZodCheckRegex",(e,t)=>{St.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})}}),Ms=h("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Cs),St.init(e,t)}),Os=h("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=ks),St.init(e,t)}),zs=h("$ZodCheckIncludes",(e,t)=>{G.init(e,t);let n=Ee(t.includes),r=new RegExp(typeof t.position==="number"?`^.{${t.position},}${n}`:n);t.pattern=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})}}),Ns=h("$ZodCheckStartsWith",(e,t)=>{G.init(e,t);let n=new RegExp(`^${Ee(t.prefix)}.*`);t.pattern??(t.pattern=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})}}),$s=h("$ZodCheckEndsWith",(e,t)=>{G.init(e,t);let n=new RegExp(`.*${Ee(t.suffix)}$`);t.pattern??(t.pattern=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 Ls=h("$ZodCheckOverwrite",(e,t)=>{G.init(e,t),e._zod.check=(n)=>{n.value=t.tx(n.value)}});class sr{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{this.indent-=1}}write(e){if(typeof e==="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let n=e.split(`
1
+ function pt(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 Ln(e,t="|"){return e.map((n)=>Un(n)).join(t)}function mt(e,t){if(typeof t==="bigint")return t.toString();return t}class vi{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;if(e!==void 0)this._value=e(),this._getter=void 0;return this._value}}function ft(e){return new vi(e)}function Ci(e){return e===null||e===void 0}function Bt(e){let t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function Ti(e,t){let n=e/t,r=Math.round(n),o=4*Number.EPSILON*Math.max(Math.abs(n),1);if(Math.abs(n-r)<o)return 0;return n-r}function te(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function gt(e){let t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function be(e){return gt(e._zod.def)??e._zod.def.shape}function ki(e,t,n){Object.defineProperty(e,t,{get(){let r=n();return te(this,t,r),r},enumerable:!0,configurable:!0})}function Ei(e,t,n){if(t in e)te(e,t,n);else e[t]=n}function Oe(e,t,n,r){let o=be(t);for(let i of n){let s=Object.getOwnPropertyDescriptor(o,i);if(!s.enumerable)continue;if(s.get)ki(e,i,()=>{let a=t._zod.def.shape[i];return r?r(a,i):a});else Ei(e,i,r?r(s.value,i):s.value)}}function Tp(e,t){for(let n of Reflect.ownKeys(t)){let r=Object.getOwnPropertyDescriptor(t,n);if(!r.enumerable)continue;if(r.get)ki(e,n,()=>t[n]);else Ei(e,n,r.value)}}function ne(...e){let t={};for(let n of e){let r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function Ri(e){return JSON.stringify(e)}function Ai(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var Dn="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Ue(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}var Ii=ft(()=>{if(Y.jitless)return!1;if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function Ne(e){if(Ue(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(Ue(n)===!1)return!1;if(Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)return!1;return!0}function Bn(e){if(Ne(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 wi=new Set(["string","number","symbol"]);function Ee(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ue(e,t,n){let r=new e._zod.constr(t??e._zod.def);if(!t||n?.parent)r._zod.parent=e;return r}function S(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 Un(e){if(typeof e==="bigint")return e.toString()+"n";if(typeof e==="string")return`"${e}"`;return`${e}`}function Pi(e){return Object.keys(e).filter((t)=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}var Ut=(()=>({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]}))(),Zn={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function kp(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 i={};return Oe(i,e,Zt(e,t)),ue(e,ne(n,{shape:i,checks:[]}))}function Zt(e,t){let n=be(e),r=[];for(let o of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,o)?.enumerable)throw Error(`Unrecognized key: "${String(o)}"`);if(t[o])r.push(o)}return r}function Ep(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 i=new Set(Zt(e,t)),s={};return Oe(s,e,Reflect.ownKeys(be(e)).filter((a)=>!i.has(a))),ue(e,ne(n,{shape:s,checks:[]}))}function Rp(e,t){if(!Ne(t))throw Error("Invalid input to extend: expected a plain object");let n=e._zod.def.checks;if(n&&n.length>0){let o=be(e);for(let i of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(o,i)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return ue(e,ne(e._zod.def,{shape:Mi(e,t)}))}function Mi(e,t){let n={};return Oe(n,e,Reflect.ownKeys(be(e))),Tp(n,t),n}function Ap(e,t){if(!Ne(t))throw Error("Invalid input to safeExtend: expected a plain object");return ue(e,ne(e._zod.def,{shape:Mi(e,t)}))}function Ip(e,t){if(!t?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let n={};Oe(n,e,Reflect.ownKeys(be(e))),Oe(n,t,Reflect.ownKeys(be(t)));let r=ne(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return ue(e,r)}function Oi(e,t,n,r="partial"){let i=t._zod.def.checks;if(i&&i.length>0)throw Error(`.${r}() cannot be used on object schemas containing refinements`);let a=n?new Set(Zt(t,n)):void 0,c={};return Oe(c,t,Reflect.ownKeys(be(t)),e&&((u,l)=>a&&!a.has(l)?u:new e({type:"optional",innerType:u}))),ue(t,ne(t._zod.def,{shape:c,checks:[]}))}function wp(e,t,n){let r=n?new Set(Zt(t,n)):void 0,o={};return Oe(o,t,Reflect.ownKeys(be(t)),(i,s)=>r&&!r.has(s)?i:new e({type:"nonoptional",innerType:i})),ue(t,ne(t._zod.def,{shape:o}))}function oe(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 Ni(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 de(e,t){return t.map((n)=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function dt(e){return typeof e==="string"?e:e?.message}function Fn(e){let t=[];for(let n of e??[]){let r=n._zod.def;if(!/_(length|size)$|_equals$/.test(r.check))break;let o=r.maximum??r.length??r.size;if(o>=0)t.push([o,n])}return t}function Ft(e,t,n){var r;for(let o=t;o<e.length;o++)(r=e[o]).schema??(r.schema=n)}function pe(e,t,n){var r;let o=e.inst?._zod?.traits;if(o?.has("$ZodType"))if(o.has("$ZodCheck"))(r=e).schema??(r.schema=e.inst);else e.schema=e.inst;let i=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,s=e.message?e.message:dt(e.inst?._zod.def?.error?.(e))??dt(i?.(e))??dt(t?.error?.(e))??dt(n.customError?.(e))??dt(n.localeError?.(e))??"Invalid input",a={};for(let c of Object.keys(e)){if(c==="inst"||c==="schema"||c==="continue"||c==="input"||c==="__proto__")continue;a[c]=e[c]}if(a.path??(a.path=[]),a.message=s,t?.reportInput)a.input=e.input;return a}var Pp=/[\uD800-\uDBFF]/;function Ht(e){let t=e.length;if(!Pp.test(e))return t;let n=t;for(let r=0;r<t-1;r++)if((e.charCodeAt(r)&64512)===55296&&(e.charCodeAt(r+1)&64512)===56320)n--,r++;return n}function jt(e){if(Array.isArray(e))return"array";if(typeof e==="string")return"string";return"unknown"}function zi(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";let n=e;if(n&&Object.getPrototypeOf(n)!==Object.prototype&&"constructor"in n&&n.constructor)return n.constructor.name}}return t}function ze(...e){let[t,n,r]=e;if(typeof t==="string")return{message:t,code:"custom",input:n,inst:r};return{...t}}function $i(e,t){for(let n in t){let r=Object.getOwnPropertyDescriptor(t,n);if(r.get)Object.defineProperty(e,n,{...r,enumerable:!1});else Mp(e,n,r.value)}}function xe(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function Vt(e,t,n){return xe(e,t,n,!1)}function Hn(e,t){for(let n in e){let r=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return xe(this,n,r(this))},set(o){xe(this,n,o)}})}return t}function Mp(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:xe(this,t,n.bind(this))},set(r){xe(this,t,r)}})}function Op(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}var $n,ke=!1,Np={configurable:!0,get(){ke=!0;return}};function P(e,t,n){let r=Object.getPrototypeOf(e._zod);if(t in r&&$n!==e._zod){$n=void 0;return}$n=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,Np);let o=ke;ke=!1;try{let i=n(this);if(ke)delete this[t];else Object.defineProperty(this,t,{configurable:!0,writable:!0,value:i});return ke=ke||o,i}catch(i){throw delete this[t],ke=ke||o,i}},set(o){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:o})}})}function zp(e,t,n,r){let o=Op(e,t);if(!o)return;Object.defineProperty(o,t,{configurable:!0,get(){let i={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,i),i.value=n(this),Object.defineProperty(this,t,i),i.value},set(i){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:i})}})}var $p="~constantCatch";function Li(e){let t=()=>e;return t[$p]=!0,t}var Di;var jn={value:void 0,enumerable:!1},Bi="captureStackTrace"in Error?Error:null;function Lp(e){let t=Bi;if(t){let n=t.stackTraceLimit;if(typeof n==="number"){try{t.stackTraceLimit=0}catch{return Bi=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function h(e,t,n,r){let o={};function i(m){this.def=m,this.constr=p,this.traits=new Set}i.prototype=o;let s=n,a=s&&new WeakSet;function c(m,f){if(!m._zod){jn.value=new i(f);try{Object.defineProperty(m,"_zod",jn)}finally{jn.value=void 0}}else if(m._zod.traits.has(e))return;if(m._zod.traits.add(e),t(m,f),a){let y=Object.getPrototypeOf(m),_=m._zod.constr.prototype,v=y;while(v&&v!==_)v=Object.getPrototypeOf(v);let k=v??y;if(!a.has(k))a.add(k),$i(k,s)}let g=p.prototype;for(let y in g){if(!Object.prototype.hasOwnProperty.call(g,y))continue;if(!(y in m))m[y]=g[y].bind(m)}}let u=r?.Parent??Object;class l extends u{}Object.defineProperty(l,"name",{value:e});function p(m){let f=r?.Parent?Lp(l):this;c(f,m);let g=f._zod.deferred;if(g){for(let _ of g)_();f._zod.deferred=void 0}let y=globalThis.__zod_globalConfig?.postProcessor;if(y)y(f);return f}return Object.defineProperty(p,"init",{value:c}),Object.defineProperty(p,Symbol.hasInstance,{value:(m)=>{if(r?.Parent&&m instanceof r.Parent)return!0;return m?._zod?.traits?.has(e)}}),Object.defineProperty(p,"name",{value:e}),p}class me extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class ht extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`);this.name="ZodEncodeError"}}(Di=globalThis).__zod_globalConfig??(Di.__zod_globalConfig={});var Y=globalThis.__zod_globalConfig;function Q(e){if(e)Object.assign(Y,e);return Y}function Dp(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,mt,2)),e.message}function Bp(e){this._zod.message=e}var Up={get:Dp,set:Bp,enumerable:!0,configurable:!0},qn={value:void 0,enumerable:!1},Ui=new WeakSet([Object.prototype,Error.prototype]),Zi=(e,t)=>{e.name="$ZodError",qn.value=t,Object.defineProperty(e,"issues",qn),qn.value=void 0,Object.defineProperty(e,"message",Up);let n=Object.getPrototypeOf(e);if(!Ui.has(n))Ui.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){let r=()=>this.message;return Object.defineProperty(this,"toString",{value:r,configurable:!0,writable:!0}),r},set(r){Object.defineProperty(this,"toString",{value:r,configurable:!0,writable:!0})}})},Fi=h("$ZodError",Zi),Gn=h("$ZodError",Zi,void 0,{Parent:Error});function Zp(e,t,n){if(!Object.prototype.hasOwnProperty.call(e,t))if(t==="__proto__")Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0});else e[t]=n();return e[t]}function Kn(e,t=(n)=>n.message){let n={},r=[];for(let o of e.issues)if(o.path.length>0)Zp(n,o.path[0],()=>[]).push(t(o));else r.push(t(o));return{formErrors:r,fieldErrors:n}}function Wn(e,t=(n)=>n.message){let n={_errors:[]},r=(o,i=[])=>{for(let s of o.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)n._errors.push(t(s));else{let c=n,u=0;while(u<a.length){let l=a[u],p=u===a.length-1;if(l==="_errors"){if(p)c._errors.push(t(s));u++;continue}if(!Object.prototype.hasOwnProperty.call(c,l))Object.defineProperty(c,l,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let m=c[l];if(p)m._errors.push(t(s));c=m,u++}}}};return r(e),n}function Fp(e){let t=[],n=e.map((r)=>typeof r==="object"?r.key:r);for(let r of n)if(typeof r==="number")t.push(`[${r}]`);else if(typeof r==="symbol")t.push(`[${JSON.stringify(String(r))}]`);else if(/[^\w$]/.test(r))t.push(`[${JSON.stringify(r)}]`);else{if(t.length)t.push(".");t.push(r)}return t.join("")}function Hi(e){let t=[],n=[...e.issues].sort((r,o)=>(r.path??[]).length-(o.path??[]).length);for(let r of n)if(t.push(`✖ ${r.message}`),r.path?.length)t.push(` → at ${Fp(r.path)}`);return t.join(`
2
+ `)}function qt(e,t){return{callee:t?.callee??e,Err:t?.Err}}var yt=(e)=>{let t=(n,r,o,i)=>{let s=o?{...o,async:!1}:{async:!1},a=n._zod.run({value:r,issues:[]},s);if(a instanceof Promise)throw new me;if(a.issues.length){let c=new(i?.Err??e)(a.issues.map((u)=>pe(u,s,Q())));throw Dn(c,i?.callee??t),c}return a.value};return t},Jn=yt(Gn),bt=(e)=>{let t=async(n,r,o,i)=>{let s=o?{...o,async:!0}:{async:!0},a=n._zod.run({value:r,issues:[]},s);if(a instanceof Promise)a=await a;if(a.issues.length){let c=new(i?.Err??e)(a.issues.map((u)=>pe(u,s,Q())));throw Dn(c,i?.callee??t),c}return a.value};return t},Yn=bt(Gn),Gt=(e)=>(t,n,r)=>{let o=r?{...r,async:!1}:{async:!1},i=t._zod.run({value:n,issues:[]},o);if(i instanceof Promise)throw new me;return i.issues.length?ji(e,i.issues,o):{success:!0,data:i.value}};function ji(e,t,n){let r;return{success:!1,get error(){if(!r)r=new e(t.map((o)=>pe(o,n,Q()))),t=void 0,n=void 0;return r},set error(o){r=o,t=void 0,n=void 0}}}var Kt=(e)=>async(t,n,r)=>{let o=r?{...r,async:!0}:{async:!0},i=t._zod.run({value:n,issues:[]},o);if(i instanceof Promise)i=await i;return i.issues.length?ji(e,i.issues,o):{success:!0,data:i.value}};var jp=Symbol.for("zod.compile.invalid"),Vp=Symbol.for("zod.compile.fallback"),Xn=(e,t,n)=>{let r=e._zod.bag.validator;if(r!==void 0){if(r(t)!==jp)return!0;if(r.definite===!0&&n===void 0)return!1}return qp(e,t,n)};function qp(e,t,n){let r=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},o=e._zod.bag.fallbackRun,i;if(o)r[Vp]=!0,i=o({value:t,issues:[]},r);else i=e._zod.run({value:t,issues:[]},r);if(i instanceof Promise)throw new me;return i.issues.length===0}var Qn=async(e,t,n)=>{let r=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},o=e._zod.run({value:t,issues:[]},r);if(o instanceof Promise)o=await o;return o.issues.length===0},Vi=(e)=>{let t=yt(e),n=(r,o,i,s)=>{let a=i?{...i,direction:"backward"}:{direction:"backward"};return t(r,o,a,qt(n,s))};return n};var qi=(e)=>{let t=yt(e),n=(r,o,i,s)=>t(r,o,i,qt(n,s));return n};var Gi=(e)=>{let t=bt(e),n=async(r,o,i,s)=>{let a=i?{...i,direction:"backward"}:{direction:"backward"};return await t(r,o,a,qt(n,s))};return n};var Ki=(e)=>{let t=bt(e),n=async(r,o,i,s)=>await t(r,o,i,qt(n,s));return n};var Wi=(e)=>(t,n,r)=>{let o=r?{...r,direction:"backward"}:{direction:"backward"};return Gt(e)(t,n,o)};var Ji=(e)=>(t,n,r)=>Gt(e)(t,n,r);var Yi=(e)=>async(t,n,r)=>{let o=r?{...r,direction:"backward"}:{direction:"backward"};return Kt(e)(t,n,o)};var Xi=(e)=>async(t,n,r)=>Kt(e)(t,n,r);var Qi=/^[cC][0-9a-z]{6,}$/,es=/^[0-9a-z]+$/,ts=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,ns=/^[0-9a-vA-V]{20}$/,rs=/^[A-Za-z0-9]{27}$/,os=/^[a-zA-Z0-9_-]{21}$/;function is(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var ss=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var as=/^([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})$/,tr=(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 cs=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var Gp="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function us(){return new RegExp(Gp,"u")}var ls=/^(?:(?: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])$/,ds=/^(([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 ps=/^((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])$/,ms=/^(([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}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,fs=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,gs=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;var hs=/^https?$/,ys=/^\+[1-9]\d{6,14}$/;var bs="(?:(?:\\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])))";function Kp(e){return new RegExp(`^${e}$`)}var xs=Kp(bs);function er(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}}`:e.seconds?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?":"(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?"}function _s(e){return new RegExp(`^${er(e)}$`)}function Ss(e){let t=["Z"];if(e.offset)t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let n=`${er({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,r=e.local?`${n}|${er({precision:e.precision})}`:n;return new RegExp(`^${bs}T(?:${r})$`)}var vs=/^[\s\S]{0,}$/;var nr=/^-?\d+$/,xt=/^-?\d+(?:\.\d+)?$/,Cs=/^(?:true|false)$/i;var Ts=/^[^A-Z]*$/,ks=/^[^a-z]*$/;var G=h("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])});var rr=(e)=>{let t=e.value;return!Ci(t)&&t.length!==void 0},Wt={number:"number",bigint:"bigint",object:"date"},or=h("$ZodCheckLessThan",(e,t)=>{G.init(e,t);let n=Wt[typeof t.value];e._zod.check=(r)=>{if(t.inclusive?r.value<=t.value:r.value<t.value)return;r.issues.push({origin:Wt[typeof r.value]??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})}}),ir=h("$ZodCheckGreaterThan",(e,t)=>{G.init(e,t);let n=Wt[typeof t.value];e._zod.check=(r)=>{if(t.inclusive?r.value>=t.value:r.value>t.value)return;r.issues.push({origin:Wt[typeof r.value]??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})}}),Es=h("$ZodCheckMultipleOf",(e,t)=>{G.init(e,t),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"?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):Ti(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})}}),Rs=h("$ZodCheckNumberFormat",(e,t)=>{G.init(e,t),t.format=t.format||"float64";let n=t.format?.includes("int"),r=n?"int":"number",[o,i]=Ut[t.format];e._zod.check=(s)=>{let a=s.value;if(n){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<o)s.issues.push({origin:"number",input:a,code:"too_small",minimum:o,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 As=h("$ZodCheckMaxLength",(e,t)=>{var n;G.init(e,t),(n=e._zod.def).when??(n.when=rr),e._zod.check=(r)=>{let o=r.value,i=o.length;if((typeof o==="string"&&i>t.maximum?Ht(o):i)<=t.maximum)return;let a=jt(o);r.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Is=h("$ZodCheckMinLength",(e,t)=>{var n;G.init(e,t),(n=e._zod.def).when??(n.when=rr),e._zod.check=(r)=>{let o=r.value,i=o.length;if((typeof o==="string"&&i>=t.minimum&&i<t.minimum*2?Ht(o):i)>=t.minimum)return;let a=jt(o);r.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),ws=h("$ZodCheckLengthEquals",(e,t)=>{var n;G.init(e,t),(n=e._zod.def).when??(n.when=rr),e._zod.check=(r)=>{let o=r.value,i=o.length,s=typeof o==="string"&&i>=t.length&&i<=t.length*2?Ht(o):i;if(s===t.length)return;let a=jt(o),c=s>t.length;r.issues.push({origin:a,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),_t=h("$ZodCheckStringFormat",(e,t)=>{var n,r;if(G.init(e,t),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=()=>{})}),Ps=h("$ZodCheckRegex",(e,t)=>{_t.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})}}),Ms=h("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Ts),_t.init(e,t)}),Os=h("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=ks),_t.init(e,t)}),Ns=h("$ZodCheckIncludes",(e,t)=>{G.init(e,t);let n=Ee(t.includes),r=new RegExp(typeof t.position==="number"?`^.{${t.position},}${n}`:n);t.pattern=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})}}),zs=h("$ZodCheckStartsWith",(e,t)=>{G.init(e,t);let n=new RegExp(`^${Ee(t.prefix)}.*`);t.pattern??(t.pattern=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})}}),$s=h("$ZodCheckEndsWith",(e,t)=>{G.init(e,t);let n=new RegExp(`.*${Ee(t.suffix)}$`);t.pattern??(t.pattern=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 Ls=h("$ZodCheckOverwrite",(e,t)=>{G.init(e,t),e._zod.check=(n)=>{n.value=t.tx(n.value)}});class sr{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{this.indent-=1}}write(e){if(typeof e==="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let n=e.split(`
3
3
  `).filter((i)=>i),r=Math.min(...n.map((i)=>i.length-i.trimStart().length)),o=n.map((i)=>i.slice(r)).map((i)=>" ".repeat(this.indent*2)+i);for(let i of o)this.content.push(i)}compile(){let e=Function,t=this?.content??[""];return new e(...Object.keys(this.closed),`return function (${this.args.join(", ")}) {
4
4
  ${t.join(`
5
5
  `)}
6
- };`)(...Object.values(this.closed))}}var Bs={major:4,minor:6,patch:7};var z=h("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Bs;let r=e._zod.def.checks,o=e._zod.traits.has("$ZodCheck")?[e,...r??[]]:r?.length?[...r]:[];for(let i of o)for(let s of i._zod.onattach)s(e);if(o.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let i=(a,c,u)=>{if(a.memo)return a;let l=oe(a),p;for(let m of c){if(m._zod.def.when){if(zi(a))continue;if(!m._zod.def.when(a))continue}else if(l)continue;let f=a.issues.length,g=m._zod.check(a);if(g instanceof Promise&&u?.async===!1)throw new me;if(p||g instanceof Promise)p=(p??Promise.resolve()).then(async()=>{if(await g,a.issues.length===f)return;if(Ft(a.issues,f,e),!l)l=oe(a,f)});else{if(a.issues.length===f)continue;if(Ft(a.issues,f,e),!l)l=oe(a,f)}}if(p)return p.then(()=>a);return a},s=(a,c,u)=>{if(oe(a))return a.aborted=!0,a;let l=i(c,o,u);if(l instanceof Promise){if(u.async===!1)throw new me;return l.then((p)=>e._zod.parse(p,u))}return e._zod.parse(l,u)};e._zod.run=(a,c)=>{if(c.skipChecks)return e._zod.parse(a,c);if(c.direction==="backward"){let l=e._zod.parse({value:a.value,issues:[]},{...c,skipChecks:!0});if(l instanceof Promise)return l.then((p)=>s(p,a,c));return s(l,a,c)}let u=e._zod.parse(a,c);if(u instanceof Promise){if(c.async===!1)throw new me;return u.then((l)=>i(l,o,c))}return i(u,o,c)}}},{get "~standard"(){return Vt(this,"~standard",cr(this))},set "~standard"(e){xe(this,"~standard",e)}}),Qs=(e,t)=>e.issues.length?{issues:e.issues.map((n)=>pe(n,t,Q()))}:{value:e.value};async function qp(e,t){let n={async:!0};return Qs(await e._zod.run({value:t,issues:[]},n),n)}function cr(e){return{validate:(t)=>{let n={async:!1};try{let r=e._zod.run({value:t,issues:[]},n);if(!(r instanceof Promise))return Qs(r,n)}catch(r){}return qp(e,t)},vendor:"zod",version:1}}var Qt=h("$ZodString",(e,t)=>{z.init(e,t),e._zod.pattern=t.pattern??vs,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}}),U=h("$ZodStringFormat",(e,t)=>{St.init(e,t),Qt.init(e,t)}),ea=h("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=as),U.init(e,t)}),ta=h("$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=tr(r))}else t.pattern??(t.pattern=tr());U.init(e,t)}),na=h("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=cs),U.init(e,t)}),ra=1,Yt=2;function oa(e){try{if(typeof URL<"u"&&typeof URL.canParse==="function")return URL.canParse(e);return new URL(e),!0}catch{return!1}}function Gp(e,t){if(!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t))return oa(e)||Yt;return Kp(e,t)}function Kp(e,t){if(!t.normalize&&t.protocol?.source===hs.source&&!/^https?:\/\//i.test(e))return ra;try{if(typeof URL<"u"){let n=URL;if(typeof n.parse==="function")return n.parse(e)??Yt}return new URL(e)}catch{return Yt}}var Wp=/[\t\n\r]/g;function Us(e){return e.replace(Wp,"")}function Jp(e,t){return t.lastIndex=0,t.test(e.hostname)}function Yp(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}var ia=h("$ZodURL",(e,t)=>{U.init(e,t),e._zod.check=(n)=>{try{let r=n.value.trim(),o=Gp(r,t);if(o===ra){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}if(o===Yt){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort});return}if(o===!0){n.value=Us(r);return}if(t.hostname&&!Jp(o,t.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&&!Yp(o,t.protocol))n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort});n.value=t.normalize?o.href:Us(r);return}catch(r){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),sa=h("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=us()),U.init(e,t)}),aa=h("$ZodNanoID",(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??(t.pattern=t.length===void 0?os:is(t.length)),U.init(e,t)}),ca=h("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Qi),U.init(e,t)}),ua=h("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=es),U.init(e,t)}),la=h("$ZodULID",(e,t)=>{t.pattern??(t.pattern=ts),U.init(e,t)}),da=h("$ZodXID",(e,t)=>{t.pattern??(t.pattern=ns),U.init(e,t)}),pa=h("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=rs),U.init(e,t)}),ma=h("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=_s(t)),U.init(e,t)}),fa=h("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=xs),U.init(e,t)}),ga=h("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Ss(t)),U.init(e,t)}),ha=h("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=ss),U.init(e,t)}),ya=h("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=ls),U.init(e,t)}),Xp=/^[0-9a-fA-F:.]+$/;function ba(e){if(!Xp.test(e))return!1;return oa(`http://[${e}]`)}var xa=h("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=ds),U.init(e,t),e._zod.check=(n)=>{if(!ba(n.value))n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}});var Sa=h("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=ps),U.init(e,t)});function Qp(e){let t=e.split("/");if(t.length!==2)return!1;let[n,r]=t;if(!r)return!1;let o=Number(r);if(`${o}`!==r)return!1;if(o<0||o>128)return!1;return ba(n)}var _a=h("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=ms),U.init(e,t),e._zod.check=(n)=>{if(!Qp(n.value))n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}});function va(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 ur=/^[0-9a-zA-Z+/]*={0,2}$/,Ta=h("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=ur),U.init(e,t),e._zod.check=(n)=>{if(va(n.value))return;n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}}),en=/^[A-Za-z0-9_-]*$/;function em(e){if(!en.test(e))return!1;let t=e.replace(/[-_]/g,(r)=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return va(n)}var Ca=h("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=en),U.init(e,t),e._zod.check=(n)=>{if(em(n.value))return;n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),ka=h("$ZodE164",(e,t)=>{t.pattern??(t.pattern=ys),U.init(e,t)});function tm(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 Ea=h("$ZodJWT",(e,t)=>{U.init(e,t),e._zod.check=(n)=>{if(tm(n.value,t.alg))return;n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}});var lr=h("$ZodNumber",(e,t)=>{z.init(e,t),e._zod.pattern=xt,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch(s){}let o=n.value;if(typeof o==="number"&&!Number.isNaN(o)&&Number.isFinite(o))return n;let i=typeof o==="number"?Number.isNaN(o)?"NaN":!Number.isFinite(o)?String(o):void 0:void 0;return n.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...i?{received:i}:{}}),n}}),Ra=h("$ZodNumberFormat",(e,t)=>{Rs.init(e,t),lr.init(e,t)}),Aa=h("$ZodBoolean",(e,t)=>{z.init(e,t),e._zod.pattern=Ts,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Boolean(n.value)}catch(i){}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 Ia=h("$ZodUnknown",(e,t)=>{z.init(e,t),e._zod.parse=(n)=>n}),wa=h("$ZodNever",(e,t)=>{z.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)}),Pa=h("$ZodVoid",(e,t)=>{z.init(e,t),e._zod.parse=(n,r)=>{let o=n.value;if(typeof o>"u")return n;return n.issues.push({expected:"void",code:"invalid_type",input:o,inst:e}),n}}),Ma=h("$ZodDate",(e,t)=>{z.init(e,t),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=new Date(n.value)}catch(a){}let o=n.value,i=o instanceof Date;if(i&&!Number.isNaN(o.getTime()))return n;return n.issues.push({expected:"date",code:"invalid_type",input:o,...i?{received:"Invalid Date"}:{},inst:e}),n}});function nm(e,t){let n=Fn(e._zod.def.checks);if(!n.length)return;let r=Math.min(...n.map((i)=>i[0])),o=e._zod.parse;e._zod.parse=(i,s)=>{let a=t(i.value);if(a>r&&!s?.skipChecks&&s?.direction!=="backward"){for(let[c,u]of Fn(e._zod.def.checks))if(a>c&&u._zod.def.when(i)){let l=i.issues.length;return u._zod.check(i),i.issues[l].continue=!1,Ft(i.issues,l,e),i}}return o(i,s)}}var rm=(e)=>Array.isArray(e)?e.length:-1;function Zs(e,t,n){if(e.issues.length)t.issues.push(...de(n,e.issues));t.value[n]=e.value}var Oa=h("$ZodArray",(e,t)=>{z.init(e,t);let n=Y.memoizer;n?.attach(e),e._zod.parse=(r,o)=>{let i=r.value;if(!Array.isArray(i))return r.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),r;r.value=n?n.alloc(e,r,Array(i.length),o):Array(i.length);let s=[],a=o?.abortEarly;for(let c=0;c<i.length;c++){let u=i[c],l=t.element._zod.run({value:u,issues:[]},o);if(l instanceof Promise)s.push(l.then((p)=>Zs(p,r,c)));else if(Zs(l,r,c),a&&l.issues.length!==0&&oe(l))break}if(s.length)return Promise.all(s).then(()=>r);return r},nm(e,rm)});function Xt(e,t,n,r,o,i){let s=n in r,a=i==="optional";if(!s&&a&&o==="optional")return;if(e.issues.length){if(o!==void 0&&a&&!s)return;t.issues.push(...de(n,e.issues))}if(!s&&o===void 0){if(!e.issues.length)t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]});return}if(e.value===void 0){if(s||o==="defaulted"&&!a)t.value[n]=void 0}else t.value[n]=e.value}var om=[];function za(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:om,o=r.length?[...t,...r]:t;for(let s of o)if(!e.shape?.[s]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${String(s)}": expected a Zod schema`);let i=Pi(e.shape);return{...e,allKeys:o,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(i)}}function Na(e,t,n,r,o,i,s){let a=[],c=o.keySet,u=o.catchall._zod,l=u.def.type,{optin:p,optout:m}=u,f=0;for(let g in t){if(s&&n.issues.length!==f){if(oe(n,f))break;f=n.issues.length}if(c.has(g))continue;if(g==="__proto__"){if(l==="never")a.push(g);continue}if(l==="never"){a.push(g);continue}let y=u.run({value:t[g],issues:[]},r);if(y instanceof Promise)e.push(y.then((S)=>Xt(S,n,g,t,p,m)));else Xt(y,n,g,t,p,m)}if(a.length)n.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:i,continue:!0});if(!e.length)return n;return Promise.all(e).then(()=>n)}var im=h("$ZodObject",(e,t)=>{z.init(e,t);let n=Object.getOwnPropertyDescriptor(t,"shape"),r=n?.get?n.get.raw:t.shape??{};if(r){let u=()=>{let l={...r};return Object.defineProperty(t,"shape",{value:l}),u.raw=l,l};u.raw=r,Object.defineProperty(t,"shape",{get:u})}let o=ft(()=>za(t));P(e,"propValues",(u)=>{let l=u.def.shape,p={};for(let m in l){let f=l[m]._zod;if(f.values){if(!Object.prototype.hasOwnProperty.call(p,m))te(p,m,new Set);for(let g of f.values)p[m].add(g);if(f.optin!==void 0)p[m].add(void 0)}}return p});let i=Ue,s=t.catchall,a,c=Y.memoizer;c?.attach(e),e._zod.parse=(u,l)=>{a??(a=o.value);let p=u.value;if(!i(p))return u.issues.push({expected:"object",code:"invalid_type",input:p,inst:e}),u;u.value=c?c.alloc(e,u,{},l):{};let m=[],f=a.shape,g=l?.abortEarly,y=u.issues.length;for(let S of a.allKeys){if(g&&u.issues.length!==y){if(oe(u,y))break;y=u.issues.length}if(S==="__proto__")continue;let v=f[S],k=v._zod.optin,M=v._zod.optout,R=v._zod.run({value:p[S],issues:[]},l);if(R instanceof Promise)m.push(R.then((B)=>Xt(B,u,S,p,k,M)));else Xt(R,u,S,p,k,M)}if(!s)return m.length?Promise.all(m).then(()=>u):u;return Na(m,p,u,l,o.value,e,g===!0)}}),$a=h("$ZodObjectJIT",(e,t)=>{im.init(e,t);let n=e._zod.parse,r=ft(()=>za(t)),o=Y.memoizer,i=(f)=>{let g=r.value,y=g.symbolKeys,S=new sr(["payload","ctx"],{shape:f,inst:e,memo:o,syms:y}),v=(B)=>`shape[${B}]._zod.run({ value: input[${B}], issues: [] }, ctx)`,k=(B,A)=>`
6
+ };`)(...Object.values(this.closed))}}var Bs={major:4,minor:6,patch:7};var N=h("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Bs;let r=e._zod.def.checks,o=e._zod.traits.has("$ZodCheck")?[e,...r??[]]:r?.length?[...r]:[];for(let i of o)for(let s of i._zod.onattach)s(e);if(o.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let i=(a,c,u)=>{if(a.memo)return a;let l=oe(a),p;for(let m of c){if(m._zod.def.when){if(Ni(a))continue;if(!m._zod.def.when(a))continue}else if(l)continue;let f=a.issues.length,g=m._zod.check(a);if(g instanceof Promise&&u?.async===!1)throw new me;if(p||g instanceof Promise)p=(p??Promise.resolve()).then(async()=>{if(await g,a.issues.length===f)return;if(Ft(a.issues,f,e),!l)l=oe(a,f)});else{if(a.issues.length===f)continue;if(Ft(a.issues,f,e),!l)l=oe(a,f)}}if(p)return p.then(()=>a);return a},s=(a,c,u)=>{if(oe(a))return a.aborted=!0,a;let l=i(c,o,u);if(l instanceof Promise){if(u.async===!1)throw new me;return l.then((p)=>e._zod.parse(p,u))}return e._zod.parse(l,u)};e._zod.run=(a,c)=>{if(c.skipChecks)return e._zod.parse(a,c);if(c.direction==="backward"){let l=e._zod.parse({value:a.value,issues:[]},{...c,skipChecks:!0});if(l instanceof Promise)return l.then((p)=>s(p,a,c));return s(l,a,c)}let u=e._zod.parse(a,c);if(u instanceof Promise){if(c.async===!1)throw new me;return u.then((l)=>i(l,o,c))}return i(u,o,c)}}},{get "~standard"(){return Vt(this,"~standard",cr(this))},set "~standard"(e){xe(this,"~standard",e)}}),Qs=(e,t)=>e.issues.length?{issues:e.issues.map((n)=>pe(n,t,Q()))}:{value:e.value};async function Wp(e,t){let n={async:!0};return Qs(await e._zod.run({value:t,issues:[]},n),n)}function cr(e){return{validate:(t)=>{let n={async:!1};try{let r=e._zod.run({value:t,issues:[]},n);if(!(r instanceof Promise))return Qs(r,n)}catch(r){}return Wp(e,t)},vendor:"zod",version:1}}var Qt=h("$ZodString",(e,t)=>{N.init(e,t),e._zod.pattern=t.pattern??vs,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}}),U=h("$ZodStringFormat",(e,t)=>{_t.init(e,t),Qt.init(e,t)}),ea=h("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=as),U.init(e,t)}),ta=h("$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=tr(r))}else t.pattern??(t.pattern=tr());U.init(e,t)}),na=h("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=cs),U.init(e,t)}),ra=1,Yt=2;function oa(e){try{if(typeof URL<"u"&&typeof URL.canParse==="function")return URL.canParse(e);return new URL(e),!0}catch{return!1}}function Jp(e,t){if(!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t))return oa(e)||Yt;return Yp(e,t)}function Yp(e,t){if(!t.normalize&&t.protocol?.source===hs.source&&!/^https?:\/\//i.test(e))return ra;try{if(typeof URL<"u"){let n=URL;if(typeof n.parse==="function")return n.parse(e)??Yt}return new URL(e)}catch{return Yt}}var Xp=/[\t\n\r]/g;function Us(e){return e.replace(Xp,"")}function Qp(e,t){return t.lastIndex=0,t.test(e.hostname)}function em(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}var ia=h("$ZodURL",(e,t)=>{U.init(e,t),e._zod.check=(n)=>{try{let r=n.value.trim(),o=Jp(r,t);if(o===ra){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}if(o===Yt){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort});return}if(o===!0){n.value=Us(r);return}if(t.hostname&&!Qp(o,t.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&&!em(o,t.protocol))n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort});n.value=t.normalize?o.href:Us(r);return}catch(r){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),sa=h("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=us()),U.init(e,t)}),aa=h("$ZodNanoID",(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??(t.pattern=t.length===void 0?os:is(t.length)),U.init(e,t)}),ca=h("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Qi),U.init(e,t)}),ua=h("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=es),U.init(e,t)}),la=h("$ZodULID",(e,t)=>{t.pattern??(t.pattern=ts),U.init(e,t)}),da=h("$ZodXID",(e,t)=>{t.pattern??(t.pattern=ns),U.init(e,t)}),pa=h("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=rs),U.init(e,t)}),ma=h("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Ss(t)),U.init(e,t)}),fa=h("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=xs),U.init(e,t)}),ga=h("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=_s(t)),U.init(e,t)}),ha=h("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=ss),U.init(e,t)}),ya=h("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=ls),U.init(e,t)}),tm=/^[0-9a-fA-F:.]+$/;function ba(e){if(!tm.test(e))return!1;return oa(`http://[${e}]`)}var xa=h("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=ds),U.init(e,t),e._zod.check=(n)=>{if(!ba(n.value))n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}});var _a=h("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=ps),U.init(e,t)});function nm(e){let t=e.split("/");if(t.length!==2)return!1;let[n,r]=t;if(!r)return!1;let o=Number(r);if(`${o}`!==r)return!1;if(o<0||o>128)return!1;return ba(n)}var Sa=h("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=ms),U.init(e,t),e._zod.check=(n)=>{if(!nm(n.value))n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}});function va(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 ur=/^[0-9a-zA-Z+/]*={0,2}$/,Ca=h("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=ur),U.init(e,t),e._zod.check=(n)=>{if(va(n.value))return;n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}}),en=/^[A-Za-z0-9_-]*$/;function rm(e){if(!en.test(e))return!1;let t=e.replace(/[-_]/g,(r)=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return va(n)}var Ta=h("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=en),U.init(e,t),e._zod.check=(n)=>{if(rm(n.value))return;n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),ka=h("$ZodE164",(e,t)=>{t.pattern??(t.pattern=ys),U.init(e,t)});function om(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 Ea=h("$ZodJWT",(e,t)=>{U.init(e,t),e._zod.check=(n)=>{if(om(n.value,t.alg))return;n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}});var lr=h("$ZodNumber",(e,t)=>{N.init(e,t),e._zod.pattern=xt,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch(s){}let o=n.value;if(typeof o==="number"&&!Number.isNaN(o)&&Number.isFinite(o))return n;let i=typeof o==="number"?Number.isNaN(o)?"NaN":!Number.isFinite(o)?String(o):void 0:void 0;return n.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...i?{received:i}:{}}),n}}),Ra=h("$ZodNumberFormat",(e,t)=>{Rs.init(e,t),lr.init(e,t)}),Aa=h("$ZodBoolean",(e,t)=>{N.init(e,t),e._zod.pattern=Cs,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Boolean(n.value)}catch(i){}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 Ia=h("$ZodUnknown",(e,t)=>{N.init(e,t),e._zod.parse=(n)=>n}),wa=h("$ZodNever",(e,t)=>{N.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)}),Pa=h("$ZodVoid",(e,t)=>{N.init(e,t),e._zod.parse=(n,r)=>{let o=n.value;if(typeof o>"u")return n;return n.issues.push({expected:"void",code:"invalid_type",input:o,inst:e}),n}}),Ma=h("$ZodDate",(e,t)=>{N.init(e,t),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=new Date(n.value)}catch(a){}let o=n.value,i=o instanceof Date;if(i&&!Number.isNaN(o.getTime()))return n;return n.issues.push({expected:"date",code:"invalid_type",input:o,...i?{received:"Invalid Date"}:{},inst:e}),n}});function im(e,t){let n=Fn(e._zod.def.checks);if(!n.length)return;let r=Math.min(...n.map((i)=>i[0])),o=e._zod.parse;e._zod.parse=(i,s)=>{let a=t(i.value);if(a>r&&!s?.skipChecks&&s?.direction!=="backward"){for(let[c,u]of Fn(e._zod.def.checks))if(a>c&&u._zod.def.when(i)){let l=i.issues.length;return u._zod.check(i),i.issues[l].continue=!1,Ft(i.issues,l,e),i}}return o(i,s)}}var sm=(e)=>Array.isArray(e)?e.length:-1;function Zs(e,t,n){if(e.issues.length)t.issues.push(...de(n,e.issues));t.value[n]=e.value}var Oa=h("$ZodArray",(e,t)=>{N.init(e,t);let n=Y.memoizer;n?.attach(e),e._zod.parse=(r,o)=>{let i=r.value;if(!Array.isArray(i))return r.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),r;r.value=n?n.alloc(e,r,Array(i.length),o):Array(i.length);let s=[],a=o?.abortEarly;for(let c=0;c<i.length;c++){let u=i[c],l=t.element._zod.run({value:u,issues:[]},o);if(l instanceof Promise)s.push(l.then((p)=>Zs(p,r,c)));else if(Zs(l,r,c),a&&l.issues.length!==0&&oe(l))break}if(s.length)return Promise.all(s).then(()=>r);return r},im(e,sm)});function Xt(e,t,n,r,o,i){let s=n in r,a=i==="optional";if(!s&&a&&o==="optional")return;if(e.issues.length){if(o!==void 0&&a&&!s)return;t.issues.push(...de(n,e.issues))}if(!s&&o===void 0){if(!e.issues.length)t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]});return}if(e.value===void 0){if(s||o==="defaulted"&&!a)t.value[n]=void 0}else t.value[n]=e.value}var am=[];function Na(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:am,o=r.length?[...t,...r]:t;for(let s of o)if(!e.shape?.[s]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${String(s)}": expected a Zod schema`);let i=Pi(e.shape);return{...e,allKeys:o,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(i)}}function za(e,t,n,r,o,i,s){let a=[],c=o.keySet,u=o.catchall._zod,l=u.def.type,{optin:p,optout:m}=u,f=0;for(let g in t){if(s&&n.issues.length!==f){if(oe(n,f))break;f=n.issues.length}if(c.has(g))continue;if(g==="__proto__"){if(l==="never")a.push(g);continue}if(l==="never"){a.push(g);continue}let y=u.run({value:t[g],issues:[]},r);if(y instanceof Promise)e.push(y.then((_)=>Xt(_,n,g,t,p,m)));else Xt(y,n,g,t,p,m)}if(a.length)n.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:i,continue:!0});if(!e.length)return n;return Promise.all(e).then(()=>n)}var cm=h("$ZodObject",(e,t)=>{N.init(e,t);let n=Object.getOwnPropertyDescriptor(t,"shape"),r=n?.get?n.get.raw:t.shape??{};if(r){let u=()=>{let l={...r};return Object.defineProperty(t,"shape",{value:l}),u.raw=l,l};u.raw=r,Object.defineProperty(t,"shape",{get:u})}let o=ft(()=>Na(t));P(e,"propValues",(u)=>{let l=u.def.shape,p={};for(let m in l){let f=l[m]._zod;if(f.values){if(!Object.prototype.hasOwnProperty.call(p,m))te(p,m,new Set);for(let g of f.values)p[m].add(g);if(f.optin!==void 0)p[m].add(void 0)}}return p});let i=Ue,s=t.catchall,a,c=Y.memoizer;c?.attach(e),e._zod.parse=(u,l)=>{a??(a=o.value);let p=u.value;if(!i(p))return u.issues.push({expected:"object",code:"invalid_type",input:p,inst:e}),u;u.value=c?c.alloc(e,u,{},l):{};let m=[],f=a.shape,g=l?.abortEarly,y=u.issues.length;for(let _ of a.allKeys){if(g&&u.issues.length!==y){if(oe(u,y))break;y=u.issues.length}if(_==="__proto__")continue;let v=f[_],k=v._zod.optin,M=v._zod.optout,R=v._zod.run({value:p[_],issues:[]},l);if(R instanceof Promise)m.push(R.then((B)=>Xt(B,u,_,p,k,M)));else Xt(R,u,_,p,k,M)}if(!s)return m.length?Promise.all(m).then(()=>u):u;return za(m,p,u,l,o.value,e,g===!0)}}),$a=h("$ZodObjectJIT",(e,t)=>{cm.init(e,t);let n=e._zod.parse,r=ft(()=>Na(t)),o=Y.memoizer,i=(f)=>{let g=r.value,y=g.symbolKeys,_=new sr(["payload","ctx"],{shape:f,inst:e,memo:o,syms:y}),v=(B)=>`shape[${B}]._zod.run({ value: input[${B}], issues: [] }, ctx)`,k=(B,A)=>`
7
7
  let ${B}_ab = false;
8
8
  for (let i = 0; i < ${B}.issues.length; i++) {
9
9
  const iss = ${B}.issues[i];
@@ -14,8 +14,8 @@ ${t.join(`
14
14
  if (${B}_ab && ctx && ctx.abortEarly) {
15
15
  payload.value = newResult;
16
16
  return payload;
17
- }`;S.write("const input = payload.value;");let M=Object.create(null),R=0;for(let B of g.allKeys)M[B]=`key_${R++}`;S.write(o?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(let B of g.allKeys){if(B==="__proto__")continue;let A=M[B],J=typeof B==="symbol"?`syms[${y.indexOf(B)}]`:Ri(B),Te=`${J} in input`,Me=f[B],ct=Me?._zod?.optin,ut=ct!==void 0,zn=Me?._zod?.optout==="optional";if(S.write(`const ${A} = ${v(J)};`),ut&&zn){let lt=ct==="optional"?`${A}_present`:`${A}.value !== undefined || ${A}_present`;S.write(`
18
- const ${A}_present = ${Te};
17
+ }`;_.write("const input = payload.value;");let M=Object.create(null),R=0;for(let B of g.allKeys)M[B]=`key_${R++}`;_.write(o?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(let B of g.allKeys){if(B==="__proto__")continue;let A=M[B],J=typeof B==="symbol"?`syms[${y.indexOf(B)}]`:Ri(B),Ce=`${J} in input`,Me=f[B],ct=Me?._zod?.optin,ut=ct!==void 0,Nn=Me?._zod?.optout==="optional";if(_.write(`const ${A} = ${v(J)};`),ut&&Nn){let lt=ct==="optional"?`${A}_present`:`${A}.value !== undefined || ${A}_present`;_.write(`
18
+ const ${A}_present = ${Ce};
19
19
  if (!${A}.issues.length || ${A}_present) {
20
20
  if (${A}.issues.length) {${k(A,J)}
21
21
  }
@@ -25,8 +25,8 @@ ${t.join(`
25
25
  }
26
26
  }
27
27
 
28
- `)}else if(!ut)S.write(`
29
- const ${A}_present = ${Te};
28
+ `)}else if(!ut)_.write(`
29
+ const ${A}_present = ${Ce};
30
30
  if (${A}.issues.length) {${k(A,J)}
31
31
  }
32
32
  if (!${A}_present && !${A}.issues.length) {
@@ -46,28 +46,28 @@ ${t.join(`
46
46
  newResult[${J}] = ${A}.value;
47
47
  }
48
48
 
49
- `);else if(S.write(`
49
+ `);else if(_.write(`
50
50
  if (${A}.issues.length) {${k(A,J)}
51
51
  }
52
- `),ct==="defaulted")S.write(`newResult[${J}] = ${A}.value;`);else S.write(`
53
- if (${A}.value !== undefined || ${Te}) {
52
+ `),ct==="defaulted")_.write(`newResult[${J}] = ${A}.value;`);else _.write(`
53
+ if (${A}.value !== undefined || ${Ce}) {
54
54
  newResult[${J}] = ${A}.value;
55
55
  }
56
- `)}return S.write("payload.value = newResult;"),S.write("return payload;"),S.compile()},s,a=Ue,c=!Y.jitless,l=c&&Ii.value,p=t.catchall,m;e._zod.parse=(f,g)=>{m??(m=r.value);let y=f.value;if(!a(y))return f.issues.push({expected:"object",code:"invalid_type",input:y,inst:e}),f;if(c&&l&&g?.async===!1&&g.jitless!==!0){if(!s)s=i(t.shape);if(f=s(f,g),!p)return f;return Na([],y,f,g,m,e,g?.abortEarly===!0)}return n(f,g)}});function Fs(e,t,n,r){for(let i of e)if(i.issues.length===0)return t.value=i.value,t;let o=e.filter((i)=>!oe(i));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((i)=>i.issues.map((s)=>pe(s,r,Q())))}),t}var dr=h("$ZodUnion",(e,t)=>{z.init(e,t),P(e,"optin",(r)=>r.def.options.some((o)=>o._zod.optin==="defaulted")?"defaulted":r.def.options.some((o)=>o._zod.optin!==void 0)?"optional":void 0),P(e,"optout",(r)=>r.def.options.some((o)=>o._zod.optout==="optional")?"optional":void 0),P(e,"values",(r)=>{if(r.def.options.every((o)=>o._zod.values))return new Set(r.def.options.flatMap((o)=>Array.from(o._zod.values)));return}),P(e,"pattern",(r)=>{if(r.def.options.every((o)=>o._zod.pattern)){let o=r.def.options.map((i)=>i._zod.pattern);return new RegExp(`^(${o.map((i)=>Bt(i.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 i=!1,s=[];for(let a of t.options){let c=a._zod.run({value:r.value,issues:[]},o);if(c instanceof Promise)s.push(c),i=!0;else{if(c.issues.length===0)return c;s.push(c)}}if(!i)return Fs(s,r,e,o);return Promise.all(s).then((a)=>Fs(a,r,e,o))}});function sm(e){let t=new Map;for(let n of e.options){let r=n._zod.propValues?.[e.discriminator];if(!r||r.size===0)throw Error(`Invalid discriminated union option at index "${e.options.indexOf(n)}"`);for(let o of r)if(t.has(o)){if(o!==void 0)throw Error(`Duplicate discriminator value "${String(o)}"`);t.set(o,null)}else t.set(o,n)}return t}var La=h("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,dr.init(e,t);let n=e._zod.parse;P(e,"propValues",(o)=>{let i={},s=0;for(let a of o.def.options){let c=a._zod.propValues;if(!c||Object.keys(c).length===0)throw Error(`Invalid discriminated union option at index "${o.def.options.indexOf(a)}"`);if(c[o.def.discriminator]?.has(void 0))s++;for(let[u,l]of Object.entries(c)){if(!Object.prototype.hasOwnProperty.call(i,u))te(i,u,new Set);for(let p of l)i[u].add(p)}}if(!o.def.unionFallback&&s>1)i[o.def.discriminator]?.delete(void 0);return i}),t.options.forEach((o,i)=>{let s=gt(o._zod.def);if(s&&!Object.prototype.hasOwnProperty.call(s,t.discriminator))throw Error(`Invalid discriminated union option at index "${i}"`)});let r=ft(()=>sm(t));e._zod.parse=(o,i)=>{let s=o.value;if(!Ue(s))return o.issues.push({code:"invalid_type",expected:"object",input:s,inst:e}),o;let a=s?.[t.discriminator],c=r.value.get(a);if(c&&(a!==void 0||i.direction!=="backward"))return c._zod.run(o,i);if(t.unionFallback||i.direction==="backward")return n(o,i);return o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(r.value.keys()).filter((u)=>r.value.get(u)!==null),input:s,path:[t.discriminator],inst:e}),o}}),Da=h("$ZodIntersection",(e,t)=>{z.init(e,t),e._zod.parse=(n,r)=>{let o=n.value,i=t.left._zod.run({value:o,issues:[]},r),s=t.right._zod.run({value:o,issues:[]},r);if(i instanceof Promise||s instanceof Promise)return Promise.all([i,s]).then(([c,u])=>Hs(n,c,u));return Hs(n,i,s)}});function ar(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(ze(e)&&ze(t)){let n=Object.keys(t),r=Object.keys(e).filter((i)=>n.indexOf(i)!==-1),o={...e,...t};if(Object.prototype.hasOwnProperty.call(o,"__proto__"))delete o.__proto__;for(let i of r){if(i==="__proto__")continue;let s=ar(e[i],t[i]);if(!s.valid)return{valid:!1,mergeErrorPath:[i,...s.mergeErrorPath]};o[i]=s.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],i=t[r],s=ar(o,i);if(!s.valid)return{valid:!1,mergeErrorPath:[r,...s.mergeErrorPath]};n.push(s.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Hs(e,t,n){let r=new Map,o,i=new Map,s=(u,l)=>{let p;if(u.code==="unrecognized_keys"&&!u.path?.length)o??(o=u),p=u.keys;else if(u.code==="invalid_key"&&u.origin==="record"&&u.path?.length===1){let m=String(u.path[0]);if(!i.has(m))i.set(m,u);p=[m]}else return!1;for(let m of p){if(!r.has(m))r.set(m,{});r.get(m)[l]=!0}return!0};for(let u of t.issues)if(!s(u,"l"))e.issues.push(u);for(let u of n.issues)if(!s(u,"r"))e.issues.push(u);let a=[...r].filter(([,u])=>u.l&&u.r).map(([u])=>u);if(a.length){let u=o?a.filter((l)=>o.keys.includes(l)):[];if(u.length)e.issues.push({...o,keys:u});for(let l of a)if(!u.includes(l)&&i.has(l))e.issues.push(i.get(l))}let c=ar(t.value,n.value);if(!c.valid){if(oe(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var pr=h("$ZodTuple",(e,t)=>{z.init(e,t);let n=t.items,r=Y.memoizer;r?.attach(e),e._zod.parse=(o,i)=>{let s=o.value;if(!Array.isArray(s))return o.issues.push({input:s,inst:e,expected:"tuple",code:"invalid_type"}),o;o.value=r?r.alloc(e,o,[],i):[];let a=[],c=js(n,"optin"),u=js(n,"optout");if(!t.rest){if(s.length<c)return o.issues.push({code:"too_small",minimum:c,inclusive:!0,input:s,inst:e,origin:"array"}),o;if(s.length>n.length)o.issues.push({code:"too_big",maximum:n.length,inclusive:!0,input:s,inst:e,origin:"array"})}let l=Array(n.length),p=t.rest?i?.abortEarly:void 0,m=!1;for(let f=0;f<n.length;f++){let g=n[f]._zod.run({value:s[f],issues:[]},i);if(g instanceof Promise)a.push(g.then((y)=>{l[f]=y}));else if(l[f]=g,p&&!m&&g.issues.length)m=oe(g)}if(t.rest&&!m){let f=n.length-1,g=s.slice(n.length),y=o.issues.length;for(let S of g){if(p&&o.issues.length!==y){if(oe(o,y))break;y=o.issues.length}f++;let v=t.rest._zod.run({value:S,issues:[]},i);if(v instanceof Promise)a.push(v.then((k)=>Vs(k,o,f)));else Vs(v,o,f)}}if(a.length)return Promise.all(a).then(()=>qs(l,o,n,s,u));return qs(l,o,n,s,u)}});function js(e,t){for(let n=e.length-1;n>=0;n--)if(!(t==="optin"?e[n]._zod.optin!==void 0:e[n]._zod.optout==="optional"))return n+1;return 0}function Vs(e,t,n){if(e.issues.length)t.issues.push(...de(n,e.issues));t.value[n]=e.value}function qs(e,t,n,r,o){for(let i=0;i<n.length;i++){let s=e[i],a=i<r.length;if(!a&&i>=o&&n[i]._zod.optin==="optional"){t.value.length=i;break}if(s.issues.length){if(!a&&i>=o){t.value.length=i;break}t.issues.push(...de(i,s.issues))}t.value[i]=s.value}for(let i=t.value.length-1;i>=r.length;i--)if(n[i]._zod.optout==="optional"&&t.value[i]===void 0)t.value.length=i;else break;return t}var Ba=h("$ZodRecord",(e,t)=>{z.init(e,t);let n=Y.memoizer;n?.attach(e),e._zod.parse=(r,o)=>{let i=r.value;if(!ze(i))return r.issues.push({expected:"record",code:"invalid_type",input:i,inst:e}),r;let s=[],a=t.keyType._zod.values;if(a&&!t.partial){r.value=n?n.alloc(e,r,{},o):{};let c=new Set;for(let l of a)if(typeof l==="string"||typeof l==="number"||typeof l==="symbol"){if(c.add(typeof l==="number"?l.toString():l),l==="__proto__")continue;let p=t.keyType._zod.run({value:l,issues:[]},o);if(p instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(p.issues.length){r.issues.push({code:"invalid_key",origin:"record",issues:p.issues.map((g)=>pe(g,o,Q())),input:l,path:[l],inst:e});continue}let m=p.value;if(m==="__proto__")continue;let f=t.valueType._zod.run({value:i[l],issues:[]},o);if(f instanceof Promise)s.push(f.then((g)=>{if(g.issues.length)r.issues.push(...de(l,g.issues));r.value[m]=g.value}));else{if(f.issues.length)r.issues.push(...de(l,f.issues));r.value[m]=f.value}}let u;for(let l in i)if(!c.has(l))if(t.mode==="loose"){if(l==="__proto__")continue;r.value[l]=i[l]}else u=u??[],u.push(l);if(u&&u.length>0)r.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:u,continue:!0})}else{r.value=n?n.alloc(e,r,{},o):{};let c;for(let u of Reflect.ownKeys(i)){if(u==="__proto__")continue;if(!Object.prototype.propertyIsEnumerable.call(i,u))continue;let l=t.keyType._zod.run({value:u,issues:[]},o);if(l instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(typeof u==="string"&&xt.test(u)&&l.issues.length){let g=t.keyType._zod.run({value:Number(u),issues:[]},o);if(g instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(g.issues.length===0)l=g}if(l.issues.length){if(t.mode==="loose")r.value[u]=i[u];else if(a)c=c??[],c.push(u);else r.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map((g)=>pe(g,o,Q())),input:u,path:[u],inst:e});continue}let m=l.value;if(m==="__proto__")continue;let f=t.valueType._zod.run({value:i[u],issues:[]},o);if(f instanceof Promise)s.push(f.then((g)=>{if(g.issues.length)r.issues.push(...de(u,g.issues));r.value[m]=g.value}));else{if(f.issues.length)r.issues.push(...de(u,f.issues));r.value[m]=f.value}}if(c&&c.length>0)r.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:c,continue:!0})}if(s.length)return Promise.all(s).then(()=>r);return r}});var Ua=h("$ZodEnum",(e,t)=>{z.init(e,t);let n=pt(t.entries),r=new Set(n);e._zod.values=r,P(e,"pattern",(o)=>{let i=pt(o.def.entries).filter((s)=>wi.has(typeof s));return new RegExp(i.length?`^(${i.map((s)=>Ee(s.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(o,i)=>{let s=o.value;if(r.has(s))return o;return o.issues.push({code:"invalid_value",values:n,input:s,inst:e}),o}}),Za=h("$ZodLiteral",(e,t)=>{z.init(e,t);let n=new Set(t.values);e._zod.values=n,P(e,"pattern",(r)=>{let o=r.def.values;return new RegExp(o.length?`^(${o.map((i)=>typeof i==="string"?Ee(i):i?Ee(i.toString()):String(i)).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(r,o)=>{let i=r.value;if(n.has(i))return r;return r.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),r}});var Fa=h("$ZodTransform",(e,t)=>{z.init(e,t),e._zod.optin="optional",Y.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new ht(e.constructor.name);let o=t.transform(n.value,n);if(r.async)return(o instanceof Promise?o:Promise.resolve(o)).then((s)=>(n.value=s,n));if(o instanceof Promise)throw new me;return n.value=o,n}});function Gs(e,t){return e.value=t.issues.length?void 0:t.value,e}var mr=h("$ZodOptional",(e,t)=>{z.init(e,t),P(e,"optin",(n)=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",P(e,"values",(n)=>{let r=n.def.innerType._zod.values;return r?new Set([...r,void 0]):void 0}),P(e,"pattern",(n)=>{let r=n.def.innerType._zod.pattern;return r?new RegExp(`^(${Bt(r.source)})?$`):void 0}),e._zod.parse=(n,r)=>{if(n.value===void 0){if(t.innerType._zod.optin!=="defaulted")return n;let o=t.innerType._zod.run({value:n.value,issues:[]},r);if(o instanceof Promise)return o.then((i)=>Gs(n,i));return Gs(n,o)}return t.innerType._zod.run(n,r)}}),Ha=h("$ZodExactOptional",(e,t)=>{mr.init(e,t),P(e,"values",(n)=>n.def.innerType._zod.values),P(e,"pattern",(n)=>n.def.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),ja=h("$ZodNullable",(e,t)=>{z.init(e,t),P(e,"optin",(n)=>n.def.innerType._zod.optin),P(e,"optout",(n)=>n.def.innerType._zod.optout),P(e,"pattern",(n)=>{let r=n.def.innerType._zod.pattern;return r?new RegExp(`^(${Bt(r.source)}|null)$`):void 0}),P(e,"values",(n)=>n.def.innerType._zod.values?new Set([...n.def.innerType._zod.values,null]):void 0),e._zod.parse=(n,r)=>{if(n.value===null)return n;return t.innerType._zod.run(n,r)}}),Va=h("$ZodDefault",(e,t)=>{z.init(e,t),e._zod.optin="defaulted",P(e,"values",(n)=>n.def.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((i)=>Ks(i,t));return Ks(o,t)}});function Ks(e,t){if(e.value===void 0)e.value=t.defaultValue;return e}var qa=h("$ZodPrefault",(e,t)=>{z.init(e,t),e._zod.optin="defaulted",P(e,"values",(n)=>n.def.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)}}),Ga=h("$ZodNonOptional",(e,t)=>{z.init(e,t),P(e,"values",(n)=>{let r=n.def.innerType._zod.values;return r?new Set([...r].filter((o)=>o!==void 0)):void 0}),e._zod.parse=(n,r)=>{let o=t.innerType._zod.run(n,r);if(o instanceof Promise)return o.then((i)=>Ws(i,e));return Ws(o,e)}});function Ws(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}function Js(e,t,n,r){if(!t.issues.length){if(e.value=t.value,t.memo)e.memo=!0;return e}return e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map((o)=>pe(o,r,Q()))},input:e.value}),e}var Ka=h("$ZodCatch",(e,t)=>{z.init(e,t),P(e,"optin",(n)=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),P(e,"optout",(n)=>n.def.innerType._zod.optout),P(e,"values",(n)=>n.def.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({value:n.value,issues:[]},r);if(o instanceof Promise)return o.then((i)=>Js(n,i,t,r));return Js(n,o,t,r)}});var fr=h("$ZodPipe",(e,t)=>{z.init(e,t),P(e,"values",(n)=>n.def.in._zod.values),P(e,"optin",(n)=>n.def.in._zod.optin),P(e,"optout",(n)=>n.def.out._zod.optout),P(e,"propValues",(n)=>n.def.in._zod.propValues),e._zod.parse=(n,r)=>{if(r.direction==="backward"){let i=t.out._zod.run(n,r);if(i instanceof Promise)return i.then((s)=>Jt(s,t.in,r));return Jt(i,t.in,r)}let o=t.in._zod.run(n,r);if(o instanceof Promise)return o.then((i)=>Jt(i,t.out,r));return Jt(o,t.out,r)}});function Jt(e,t,n){if(e.issues.some((r)=>r.code!=="unrecognized_keys"))return e.aborted=!0,e;return t._zod.run({value:e.value,issues:e.issues},n)}var Wa=h("$ZodPreprocess",(e,t)=>{fr.init(e,t)}),Ja=h("$ZodReadonly",(e,t)=>{z.init(e,t),P(e,"propValues",(n)=>n.def.innerType._zod.propValues),P(e,"values",(n)=>n.def.innerType._zod.values),P(e,"optin",(n)=>n.def.innerType?._zod?.optin),P(e,"optout",(n)=>n.def.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(Ys);return Ys(o)}});function Ys(e){if(!e.memo)e.value=Object.freeze(e.value);return e}var Ya=h("$ZodFunction",(e,t)=>(z.init(e,t),Object.defineProperty(e,"_def",{value:t}),e._zod.def=t,e.implement=(n)=>{if(typeof n!=="function")throw Error("implement() must be called with a function");return Object.defineProperty(function(...r){let o=e._def.input?Jn(e._def.input,r):r,i=Reflect.apply(n,this,o);if(e._def.output)return Jn(e._def.output,i);return i},"_zod",{value:e._zod,enumerable:!1})},e.implementAsync=(n)=>{if(typeof n!=="function")throw Error("implementAsync() must be called with a function");return Object.defineProperty(async function(...r){let o=e._def.input?await Yn(e._def.input,r):r,i=await Reflect.apply(n,this,o);if(e._def.output)return await Yn(e._def.output,i);return i},"_zod",{value:e._zod,enumerable:!1})},e._zod.parse=(n,r)=>{if(typeof n.value!=="function")return n.issues.push({code:"invalid_type",expected:"function",input:n.value,inst:e}),n;if(e._def.output&&e._def.output._zod.def.type==="promise")n.value=e.implementAsync(n.value);else n.value=e.implement(n.value);return n},e.input=(...n)=>{let r=e.constructor;if(Array.isArray(n[0]))return new r({type:"function",input:new pr({type:"tuple",items:n[0],rest:n[1]}),output:e._def.output});return new r({type:"function",input:n[0],output:e._def.output})},e.output=(n)=>new e.constructor({type:"function",input:e._def.input,output:n}),e)),Xa=h("$ZodPromise",(e,t)=>{z.init(e,t),e._zod.parse=(n,r)=>Promise.resolve(n.value).then((o)=>t.innerType._zod.run({value:o,issues:[]},r))});var Qa=h("$ZodCustom",(e,t)=>{G.init(e,t),z.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((i)=>Xs(i,n,r,e));Xs(o,n,r,e);return}});function Xs(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(Ne(o))}}class tc extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform");this.name="ZodCyclicError"}}var hr="~memo",ec=[];function nc(e){return e!==null&&typeof e==="object"}function gr(e){return e.map((t)=>t.path?{...t,path:t.path.slice()}:{...t})}var rc=new WeakMap,_t=0,rn=1,vt=2;function on(e,t,n){let r=rc.get(e);if(r!==void 0)return r?vt:_t;if(t.has(e))return vt;t.add(e);let o=_t,i=(l)=>{if(o!==vt&&l?._zod){let p=on(l,t,n);if(p>o)o=p}},s=(l,p)=>{let m=_t;for(let f of Reflect.ownKeys(l)){let g=Object.getOwnPropertyDescriptor(l,f);if(p&&!g.enumerable)continue;let y=g.get?rn:g.value?._zod?on(g.value,t,n):_t;if(y>m)m=y}return m},a=(l)=>{if(l>o)o=l},c=e._zod.def,u=c.type;switch(u){case"object":{let l=gt(c);a(l?s(l,!0):rn),i(c.catchall);break}case"array":i(c.element);break;case"tuple":for(let l of c.items)i(l);i(c.rest);break;case"record":case"map":i(c.keyType),i(c.valueType);break;case"set":i(c.valueType);break;case"union":for(let l of c.options)i(l);break;case"intersection":i(c.left),i(c.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":i(c.innerType);break;case"pipe":i(c.in),i(c.out);break;case"function":i(c.input),i(c.output);break;case"lazy":{let l=c._cachedInner??(n?e._zod.innerType:void 0);a(l?on(l,t,!1):rn);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(let l in c){let p=Object.getOwnPropertyDescriptor(c,l);if(!p||p.get)continue;let m=p.value;if(!m||typeof m!=="object")continue;if(m._zod)i(m);else if(Array.isArray(m))for(let f of m)i(f)}}return t.delete(e),am(e,o)}function am(e,t){if(t!==rn)rc.set(e,t===vt);return t}function cm(e,t){let n=e.buckets.get(t);if(!n)n=new WeakMap,e.buckets.set(t,n);return n}var tn,nn=[],um={alloc(e,t,n){let r=tn;if(!r)return n;tn=void 0;let o={value:n,issues:null};return r.set(t.value,o),nn.push(o),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let n=e._zod.parse,r=(o,i)=>{if(i.direction!=="backward"&&lm(i,o.value))throw new tc;return n(o,i)};if(e._zod.parse=r,e._zod.run===n)e._zod.run=r})},attach(e){var t;let n,r=!1,o,i;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let s=e._zod.parse,a=(c,u)=>{if(n===void 0){let v=on(e,new Set,!1);if(v===_t){if(e._zod.parse=s,e._zod.run===a)e._zod.run=s;return s(c,u)}if(v===vt||r)n=!0;else r=!0}let l=c.value;if(!nc(l))return s(c,u);let p=u[hr];if(!p)p={buckets:new WeakMap,backEdges:void 0},u[hr]=p;let m;if(o===u)m=i;else m=cm(p,e),o=u,i=m;let f=m.get(l);if(f){if(c.value=f.value,f.issues){if(f.issues.length)c.issues.push(...gr(f.issues))}else c.memo=!0,p.backEdges??(p.backEdges=new WeakSet),p.backEdges.add(f.value);return c}tn=m;let g=nn.length,y=s(c,u);tn=void 0;let S=nn.length>g?nn.pop():void 0;if(y instanceof Promise)return y.then((v)=>{if(S)S.issues=v.issues.length?gr(v.issues):ec;return v});if(S)S.issues=y.issues.length?gr(y.issues):ec;return y};if(e._zod.parse=a,e._zod.run===s)e._zod.run=a})}};function yr(){return um}function lm(e,t){let n=e[hr]?.backEdges;return n!==void 0&&nc(t)&&n.has(t)}var dm=()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function t(i){return e[i]??null}let n={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},r={nan:"NaN"};function o(i,s){if(i==="number"&&typeof s==="number"&&!Number.isFinite(s))return String(s);return r[i]??i}return(i)=>{switch(i.code){case"invalid_type":{let s=o(i.expected),a=Ni(i.input),c=o(a,i.input);return`Invalid input: expected ${s}, received ${c}`}case"invalid_value":if(i.values.length===1)return`Invalid input: expected ${Un(i.values[0])}`;return`Invalid option: expected one of ${Ln(i.values,"|")}`;case"too_big":{let s=i.exact?"exactly ":i.inclusive?"<=":"<",a=t(i.origin);if(a)return`Too big: expected ${i.origin??"value"} to have ${s}${i.maximum.toString()} ${a.unit??"elements"}`;return`Too big: expected ${i.origin??"value"} to be ${s}${i.maximum.toString()}`}case"too_small":{let s=i.exact?"exactly ":i.inclusive?">=":">",a=t(i.origin);if(a)return`Too small: expected ${i.origin} to have ${s}${i.minimum.toString()} ${a.unit}`;return`Too small: expected ${i.origin} to be ${s}${i.minimum.toString()}`}case"invalid_format":{let s=i;if(s.format==="starts_with")return`Invalid string: must start with "${s.prefix}"`;if(s.format==="ends_with")return`Invalid string: must end with "${s.suffix}"`;if(s.format==="includes")return`Invalid string: must include "${s.includes}"`;if(s.format==="regex")return`Invalid string: must match pattern ${s.pattern}`;return`Invalid ${n[s.format]??i.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${i.divisor}`;case"unrecognized_keys":return`Unrecognized key${i.keys.length>1?"s":""}: ${Ln(i.keys,", ")}`;case"invalid_key":return`Invalid key in ${i.origin}`;case"invalid_union":if(i.options&&Array.isArray(i.options)&&i.options.length>0)return`Invalid discriminator value. Expected ${i.options.map((a)=>`'${a}'`).join(" | ")}`;if(i.inclusive===!1)return"Invalid input: more than one option matched";return"Invalid input";case"invalid_element":return`Invalid value in ${i.origin}`;default:return"Invalid input"}}};function br(){return{localeError:dm()}}var oc;class ic{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 sc(){return new ic}(oc=globalThis).__zod_globalRegistry??(oc.__zod_globalRegistry=sc());var Re=globalThis.__zod_globalRegistry;function ac(e){if(e.checks)e.checks=[...e.checks];return e}function cc(e,t){return new e(ac({type:"string",..._(t)}))}function uc(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,..._(t)})}function lc(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,..._(t)})}function dc(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,..._(t)})}function pc(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",..._(t)})}function mc(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",..._(t)})}function fc(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",..._(t)})}function gc(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,..._(t)})}function hc(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,..._(t)})}function yc(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,..._(t)})}function bc(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,..._(t)})}function xc(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,..._(t)})}function Sc(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,..._(t)})}function _c(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,..._(t)})}function vc(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,..._(t)})}function Tc(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,..._(t)})}function Cc(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,..._(t)})}function kc(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,..._(t)})}function Ec(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,..._(t)})}function Rc(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,..._(t)})}function Ac(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,..._(t)})}function Ic(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,..._(t)})}function wc(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,..._(t)})}function Pc(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,..._(t)})}function Mc(e,t){return new e({type:"string",format:"date",check:"string_format",..._(t)})}function Oc(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,..._(t)})}function zc(e,t){return new e({type:"string",format:"duration",check:"string_format",..._(t)})}function Nc(e,t){return new e(ac({type:"number",checks:[],..._(t)}))}function $c(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",..._(t)})}function Lc(e,t){return new e({type:"boolean",..._(t)})}function Dc(e){return new e({type:"unknown"})}function Bc(e,t){return new e({type:"never",..._(t)})}function Uc(e,t){return new e({type:"void",..._(t)})}function Zc(e,t){return new e({type:"date",..._(t)})}function sn(e,t){return new or({check:"less_than",..._(t),value:e,inclusive:!1})}function Fe(e,t){return new or({check:"less_than",..._(t),value:e,inclusive:!0})}function an(e,t){return new ir({check:"greater_than",..._(t),value:e,inclusive:!1})}function He(e,t){return new ir({check:"greater_than",..._(t),value:e,inclusive:!0})}function cn(e,t){return new Es({check:"multiple_of",..._(t),value:e})}function un(e,t){return new As({check:"max_length",..._(t),maximum:e})}function je(e,t){return new Is({check:"min_length",..._(t),minimum:e})}function ln(e,t){return new ws({check:"length_equals",..._(t),length:e})}function xr(e,t){return new Ps({check:"string_format",format:"regex",..._(t),pattern:e})}function Sr(e){return new Ms({check:"string_format",format:"lowercase",..._(e)})}function _r(e){return new Os({check:"string_format",format:"uppercase",..._(e)})}function vr(e,t){return new zs({check:"string_format",format:"includes",..._(t),includes:e})}function Tr(e,t){return new Ns({check:"string_format",format:"starts_with",..._(t),prefix:e})}function Cr(e,t){return new $s({check:"string_format",format:"ends_with",..._(t),suffix:e})}function Ae(e){return new Ls({check:"overwrite",tx:e})}function kr(e){return Ae((t)=>t.normalize(e))}function Er(){return Ae((e)=>e.trim())}function Rr(){return Ae((e)=>e.toLowerCase())}function Ar(){return Ae((e)=>e.toUpperCase())}function Ir(){return Ae((e)=>Ai(e))}function Fc(e,t,n){return new e({type:"array",element:t,..._(n)})}function Hc(e,t,n){let r=_(n);return r.abort??(r.abort=!0),new e({type:"custom",check:"custom",fn:t,...r})}function jc(e,t,n){return new e({type:"custom",check:"custom",fn:t,..._(n)})}function Vc(e,t){let n=pm((r)=>(r.addIssue=(o)=>{if(typeof o==="string")r.issues.push(Ne(o,r.value,n._zod.def));else{let i=o;if(i.fatal)i.continue=!1;if(i.code??(i.code="custom"),!("input"in i))i.input=r.value;i.inst??(i.inst=n),i.continue??(i.continue=!n._zod.def.abort),r.issues.push(Ne(i))}},e(r.value,r)),t);return n}function pm(e,t){let n=new G({check:"custom",..._(t)});return n._zod.check=e,n}function Tt(e,...t){for(let n of t)for(let r of Reflect.ownKeys(n))if(Object.prototype.propertyIsEnumerable.call(n,r))te(e,r,n[r]);return e}function kt(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,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??"ref",reused:e?.reused??"inline",intersections:[],deferred:[],external:e?.external??void 0}}function q(e,t,n,r,o){let i=typeof t.unrepresentable==="function"?t.unrepresentable({zodSchema:e,path:r.path,message:o}):t.unrepresentable;if(i==="any")return!1;if(i===void 0||i==="throw")throw Error(o);return Object.assign(n,i),!0}function D(e,t,n={path:[],schemaPath:[]}){var r;let o=e._zod.def,i=t.seen.get(e);if(i){if(i.count++,n.schemaPath.includes(e))i.cycle=n.path;return i.schema}let s={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,s),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let a=e._zod.toJSONSchema?.();if(a)s.schema=a;else{let l={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,s.schema,l);else{let m=s.schema,f=t.processors[o.type];if(!f)throw Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);f(e,t,m,l)}let p=e._zod.parent;if(p){if(!s.ref)s.ref=p;D(p,t,l),t.seen.get(p).isParent=!0}}let c=t.metadataRegistry.get(e);if(c)Tt(s.schema,c);if(t.io==="input"&&X(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 qc(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function Et(e,t){let n=e.seen.get(t);if(!n)throw Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;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 o=(s)=>{let a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let p=e.external.registry.get(s[0])?.id,m=e.external.uri??((g)=>g);if(p)return{ref:m(p)};let f=s[1].defId??s[1].schema.id??`schema${e.counter++}`;return s[1].defId=f,{defId:f,ref:`${m("__shared")}#/${a}/${qc(f)}`}}let c="#",u=`${c}/${a}/`;if(s[1]===n&&!s[1].schema.id)return{ref:c};let l=s[1].schema.id??`__schema${e.counter++}`;return{defId:l,ref:u+qc(l)}},i=(s)=>{if(s[1].schema.$ref)return;let a=s[1],{ref:c,defId:u}=o(s);if(a.def={...a.schema},u)a.defId=u;let l=a.schema;for(let p in l)delete l[p];l.$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>
56
+ `)}return _.write("payload.value = newResult;"),_.write("return payload;"),_.compile()},s,a=Ue,c=!Y.jitless,l=c&&Ii.value,p=t.catchall,m;e._zod.parse=(f,g)=>{m??(m=r.value);let y=f.value;if(!a(y))return f.issues.push({expected:"object",code:"invalid_type",input:y,inst:e}),f;if(c&&l&&g?.async===!1&&g.jitless!==!0){if(!s)s=i(t.shape);if(f=s(f,g),!p)return f;return za([],y,f,g,m,e,g?.abortEarly===!0)}return n(f,g)}});function Fs(e,t,n,r){for(let i of e)if(i.issues.length===0)return t.value=i.value,t;let o=e.filter((i)=>!oe(i));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((i)=>i.issues.map((s)=>pe(s,r,Q())))}),t}var dr=h("$ZodUnion",(e,t)=>{N.init(e,t),P(e,"optin",(r)=>r.def.options.some((o)=>o._zod.optin==="defaulted")?"defaulted":r.def.options.some((o)=>o._zod.optin!==void 0)?"optional":void 0),P(e,"optout",(r)=>r.def.options.some((o)=>o._zod.optout==="optional")?"optional":void 0),P(e,"values",(r)=>{if(r.def.options.every((o)=>o._zod.values))return new Set(r.def.options.flatMap((o)=>Array.from(o._zod.values)));return}),P(e,"pattern",(r)=>{if(r.def.options.every((o)=>o._zod.pattern)){let o=r.def.options.map((i)=>i._zod.pattern);return new RegExp(`^(${o.map((i)=>Bt(i.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 i=!1,s=[];for(let a of t.options){let c=a._zod.run({value:r.value,issues:[]},o);if(c instanceof Promise)s.push(c),i=!0;else{if(c.issues.length===0)return c;s.push(c)}}if(!i)return Fs(s,r,e,o);return Promise.all(s).then((a)=>Fs(a,r,e,o))}});function um(e){let t=new Map;for(let n of e.options){let r=n._zod.propValues?.[e.discriminator];if(!r||r.size===0)throw Error(`Invalid discriminated union option at index "${e.options.indexOf(n)}"`);for(let o of r)if(t.has(o)){if(o!==void 0)throw Error(`Duplicate discriminator value "${String(o)}"`);t.set(o,null)}else t.set(o,n)}return t}var La=h("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,dr.init(e,t);let n=e._zod.parse;P(e,"propValues",(o)=>{let i={},s=0;for(let a of o.def.options){let c=a._zod.propValues;if(!c||Object.keys(c).length===0)throw Error(`Invalid discriminated union option at index "${o.def.options.indexOf(a)}"`);if(c[o.def.discriminator]?.has(void 0))s++;for(let[u,l]of Object.entries(c)){if(!Object.prototype.hasOwnProperty.call(i,u))te(i,u,new Set);for(let p of l)i[u].add(p)}}if(!o.def.unionFallback&&s>1)i[o.def.discriminator]?.delete(void 0);return i}),t.options.forEach((o,i)=>{let s=gt(o._zod.def);if(s&&!Object.prototype.hasOwnProperty.call(s,t.discriminator))throw Error(`Invalid discriminated union option at index "${i}"`)});let r=ft(()=>um(t));e._zod.parse=(o,i)=>{let s=o.value;if(!Ue(s))return o.issues.push({code:"invalid_type",expected:"object",input:s,inst:e}),o;let a=s?.[t.discriminator],c=r.value.get(a);if(c&&(a!==void 0||i.direction!=="backward"))return c._zod.run(o,i);if(t.unionFallback||i.direction==="backward")return n(o,i);return o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(r.value.keys()).filter((u)=>r.value.get(u)!==null),input:s,path:[t.discriminator],inst:e}),o}}),Da=h("$ZodIntersection",(e,t)=>{N.init(e,t),e._zod.parse=(n,r)=>{let o=n.value,i=t.left._zod.run({value:o,issues:[]},r),s=t.right._zod.run({value:o,issues:[]},r);if(i instanceof Promise||s instanceof Promise)return Promise.all([i,s]).then(([c,u])=>Hs(n,c,u));return Hs(n,i,s)}});function ar(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(Ne(e)&&Ne(t)){let n=Object.keys(t),r=Object.keys(e).filter((i)=>n.indexOf(i)!==-1),o={...e,...t};if(Object.prototype.hasOwnProperty.call(o,"__proto__"))delete o.__proto__;for(let i of r){if(i==="__proto__")continue;let s=ar(e[i],t[i]);if(!s.valid)return{valid:!1,mergeErrorPath:[i,...s.mergeErrorPath]};o[i]=s.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],i=t[r],s=ar(o,i);if(!s.valid)return{valid:!1,mergeErrorPath:[r,...s.mergeErrorPath]};n.push(s.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Hs(e,t,n){let r=new Map,o,i=new Map,s=(u,l)=>{let p;if(u.code==="unrecognized_keys"&&!u.path?.length)o??(o=u),p=u.keys;else if(u.code==="invalid_key"&&u.origin==="record"&&u.path?.length===1){let m=String(u.path[0]);if(!i.has(m))i.set(m,u);p=[m]}else return!1;for(let m of p){if(!r.has(m))r.set(m,{});r.get(m)[l]=!0}return!0};for(let u of t.issues)if(!s(u,"l"))e.issues.push(u);for(let u of n.issues)if(!s(u,"r"))e.issues.push(u);let a=[...r].filter(([,u])=>u.l&&u.r).map(([u])=>u);if(a.length){let u=o?a.filter((l)=>o.keys.includes(l)):[];if(u.length)e.issues.push({...o,keys:u});for(let l of a)if(!u.includes(l)&&i.has(l))e.issues.push(i.get(l))}let c=ar(t.value,n.value);if(!c.valid){if(oe(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var pr=h("$ZodTuple",(e,t)=>{N.init(e,t);let n=t.items,r=Y.memoizer;r?.attach(e),e._zod.parse=(o,i)=>{let s=o.value;if(!Array.isArray(s))return o.issues.push({input:s,inst:e,expected:"tuple",code:"invalid_type"}),o;o.value=r?r.alloc(e,o,[],i):[];let a=[],c=js(n,"optin"),u=js(n,"optout");if(!t.rest){if(s.length<c)return o.issues.push({code:"too_small",minimum:c,inclusive:!0,input:s,inst:e,origin:"array"}),o;if(s.length>n.length)o.issues.push({code:"too_big",maximum:n.length,inclusive:!0,input:s,inst:e,origin:"array"})}let l=Array(n.length),p=t.rest?i?.abortEarly:void 0,m=!1;for(let f=0;f<n.length;f++){let g=n[f]._zod.run({value:s[f],issues:[]},i);if(g instanceof Promise)a.push(g.then((y)=>{l[f]=y}));else if(l[f]=g,p&&!m&&g.issues.length)m=oe(g)}if(t.rest&&!m){let f=n.length-1,g=s.slice(n.length),y=o.issues.length;for(let _ of g){if(p&&o.issues.length!==y){if(oe(o,y))break;y=o.issues.length}f++;let v=t.rest._zod.run({value:_,issues:[]},i);if(v instanceof Promise)a.push(v.then((k)=>Vs(k,o,f)));else Vs(v,o,f)}}if(a.length)return Promise.all(a).then(()=>qs(l,o,n,s,u));return qs(l,o,n,s,u)}});function js(e,t){for(let n=e.length-1;n>=0;n--)if(!(t==="optin"?e[n]._zod.optin!==void 0:e[n]._zod.optout==="optional"))return n+1;return 0}function Vs(e,t,n){if(e.issues.length)t.issues.push(...de(n,e.issues));t.value[n]=e.value}function qs(e,t,n,r,o){for(let i=0;i<n.length;i++){let s=e[i],a=i<r.length;if(!a&&i>=o&&n[i]._zod.optin==="optional"){t.value.length=i;break}if(s.issues.length){if(!a&&i>=o){t.value.length=i;break}t.issues.push(...de(i,s.issues))}t.value[i]=s.value}for(let i=t.value.length-1;i>=r.length;i--)if(n[i]._zod.optout==="optional"&&t.value[i]===void 0)t.value.length=i;else break;return t}var Ba=h("$ZodRecord",(e,t)=>{N.init(e,t);let n=Y.memoizer;n?.attach(e),e._zod.parse=(r,o)=>{let i=r.value;if(!Ne(i))return r.issues.push({expected:"record",code:"invalid_type",input:i,inst:e}),r;let s=[],a=t.keyType._zod.values;if(a&&!t.partial){r.value=n?n.alloc(e,r,{},o):{};let c=new Set;for(let l of a)if(typeof l==="string"||typeof l==="number"||typeof l==="symbol"){if(c.add(typeof l==="number"?l.toString():l),l==="__proto__")continue;let p=t.keyType._zod.run({value:l,issues:[]},o);if(p instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(p.issues.length){r.issues.push({code:"invalid_key",origin:"record",issues:p.issues.map((g)=>pe(g,o,Q())),input:l,path:[l],inst:e});continue}let m=p.value;if(m==="__proto__")continue;let f=t.valueType._zod.run({value:i[l],issues:[]},o);if(f instanceof Promise)s.push(f.then((g)=>{if(g.issues.length)r.issues.push(...de(l,g.issues));r.value[m]=g.value}));else{if(f.issues.length)r.issues.push(...de(l,f.issues));r.value[m]=f.value}}let u;for(let l in i)if(!c.has(l))if(t.mode==="loose"){if(l==="__proto__")continue;r.value[l]=i[l]}else u=u??[],u.push(l);if(u&&u.length>0)r.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:u,continue:!0})}else{r.value=n?n.alloc(e,r,{},o):{};let c;for(let u of Reflect.ownKeys(i)){if(u==="__proto__")continue;if(!Object.prototype.propertyIsEnumerable.call(i,u))continue;let l=t.keyType._zod.run({value:u,issues:[]},o);if(l instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(typeof u==="string"&&xt.test(u)&&l.issues.length){let g=t.keyType._zod.run({value:Number(u),issues:[]},o);if(g instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(g.issues.length===0)l=g}if(l.issues.length){if(t.mode==="loose")r.value[u]=i[u];else if(a)c=c??[],c.push(u);else r.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map((g)=>pe(g,o,Q())),input:u,path:[u],inst:e});continue}let m=l.value;if(m==="__proto__")continue;let f=t.valueType._zod.run({value:i[u],issues:[]},o);if(f instanceof Promise)s.push(f.then((g)=>{if(g.issues.length)r.issues.push(...de(u,g.issues));r.value[m]=g.value}));else{if(f.issues.length)r.issues.push(...de(u,f.issues));r.value[m]=f.value}}if(c&&c.length>0)r.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:c,continue:!0})}if(s.length)return Promise.all(s).then(()=>r);return r}});var Ua=h("$ZodEnum",(e,t)=>{N.init(e,t);let n=pt(t.entries),r=new Set(n);e._zod.values=r,P(e,"pattern",(o)=>{let i=pt(o.def.entries).filter((s)=>wi.has(typeof s));return new RegExp(i.length?`^(${i.map((s)=>Ee(s.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(o,i)=>{let s=o.value;if(r.has(s))return o;return o.issues.push({code:"invalid_value",values:n,input:s,inst:e}),o}}),Za=h("$ZodLiteral",(e,t)=>{N.init(e,t);let n=new Set(t.values);e._zod.values=n,P(e,"pattern",(r)=>{let o=r.def.values;return new RegExp(o.length?`^(${o.map((i)=>typeof i==="string"?Ee(i):i?Ee(i.toString()):String(i)).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(r,o)=>{let i=r.value;if(n.has(i))return r;return r.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),r}});var Fa=h("$ZodTransform",(e,t)=>{N.init(e,t),e._zod.optin="optional",Y.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new ht(e.constructor.name);let o=t.transform(n.value,n);if(r.async)return(o instanceof Promise?o:Promise.resolve(o)).then((s)=>(n.value=s,n));if(o instanceof Promise)throw new me;return n.value=o,n}});function Gs(e,t){return e.value=t.issues.length?void 0:t.value,e}var mr=h("$ZodOptional",(e,t)=>{N.init(e,t),P(e,"optin",(n)=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",P(e,"values",(n)=>{let r=n.def.innerType._zod.values;return r?new Set([...r,void 0]):void 0}),P(e,"pattern",(n)=>{let r=n.def.innerType._zod.pattern;return r?new RegExp(`^(${Bt(r.source)})?$`):void 0}),e._zod.parse=(n,r)=>{if(n.value===void 0){if(t.innerType._zod.optin!=="defaulted")return n;let o=t.innerType._zod.run({value:n.value,issues:[]},r);if(o instanceof Promise)return o.then((i)=>Gs(n,i));return Gs(n,o)}return t.innerType._zod.run(n,r)}}),Ha=h("$ZodExactOptional",(e,t)=>{mr.init(e,t),P(e,"values",(n)=>n.def.innerType._zod.values),P(e,"pattern",(n)=>n.def.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),ja=h("$ZodNullable",(e,t)=>{N.init(e,t),P(e,"optin",(n)=>n.def.innerType._zod.optin),P(e,"optout",(n)=>n.def.innerType._zod.optout),P(e,"pattern",(n)=>{let r=n.def.innerType._zod.pattern;return r?new RegExp(`^(${Bt(r.source)}|null)$`):void 0}),P(e,"values",(n)=>n.def.innerType._zod.values?new Set([...n.def.innerType._zod.values,null]):void 0),e._zod.parse=(n,r)=>{if(n.value===null)return n;return t.innerType._zod.run(n,r)}}),Va=h("$ZodDefault",(e,t)=>{N.init(e,t),e._zod.optin="defaulted",P(e,"values",(n)=>n.def.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((i)=>Ks(i,t));return Ks(o,t)}});function Ks(e,t){if(e.value===void 0)e.value=t.defaultValue;return e}var qa=h("$ZodPrefault",(e,t)=>{N.init(e,t),e._zod.optin="defaulted",P(e,"values",(n)=>n.def.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)}}),Ga=h("$ZodNonOptional",(e,t)=>{N.init(e,t),P(e,"values",(n)=>{let r=n.def.innerType._zod.values;return r?new Set([...r].filter((o)=>o!==void 0)):void 0}),e._zod.parse=(n,r)=>{let o=t.innerType._zod.run(n,r);if(o instanceof Promise)return o.then((i)=>Ws(i,e));return Ws(o,e)}});function Ws(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}function Js(e,t,n,r){if(!t.issues.length){if(e.value=t.value,t.memo)e.memo=!0;return e}return e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map((o)=>pe(o,r,Q()))},input:e.value}),e}var Ka=h("$ZodCatch",(e,t)=>{N.init(e,t),P(e,"optin",(n)=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),P(e,"optout",(n)=>n.def.innerType._zod.optout),P(e,"values",(n)=>n.def.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({value:n.value,issues:[]},r);if(o instanceof Promise)return o.then((i)=>Js(n,i,t,r));return Js(n,o,t,r)}});var fr=h("$ZodPipe",(e,t)=>{N.init(e,t),P(e,"values",(n)=>n.def.in._zod.values),P(e,"optin",(n)=>n.def.in._zod.optin),P(e,"optout",(n)=>n.def.out._zod.optout),P(e,"propValues",(n)=>n.def.in._zod.propValues),e._zod.parse=(n,r)=>{if(r.direction==="backward"){let i=t.out._zod.run(n,r);if(i instanceof Promise)return i.then((s)=>Jt(s,t.in,r));return Jt(i,t.in,r)}let o=t.in._zod.run(n,r);if(o instanceof Promise)return o.then((i)=>Jt(i,t.out,r));return Jt(o,t.out,r)}});function Jt(e,t,n){if(e.issues.some((r)=>r.code!=="unrecognized_keys"))return e.aborted=!0,e;return t._zod.run({value:e.value,issues:e.issues},n)}var Wa=h("$ZodPreprocess",(e,t)=>{fr.init(e,t)}),Ja=h("$ZodReadonly",(e,t)=>{N.init(e,t),P(e,"propValues",(n)=>n.def.innerType._zod.propValues),P(e,"values",(n)=>n.def.innerType._zod.values),P(e,"optin",(n)=>n.def.innerType?._zod?.optin),P(e,"optout",(n)=>n.def.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(Ys);return Ys(o)}});function Ys(e){if(!e.memo)e.value=Object.freeze(e.value);return e}var Ya=h("$ZodFunction",(e,t)=>(N.init(e,t),Object.defineProperty(e,"_def",{value:t}),e._zod.def=t,e.implement=(n)=>{if(typeof n!=="function")throw Error("implement() must be called with a function");return Object.defineProperty(function(...r){let o=e._def.input?Jn(e._def.input,r):r,i=Reflect.apply(n,this,o);if(e._def.output)return Jn(e._def.output,i);return i},"_zod",{value:e._zod,enumerable:!1})},e.implementAsync=(n)=>{if(typeof n!=="function")throw Error("implementAsync() must be called with a function");return Object.defineProperty(async function(...r){let o=e._def.input?await Yn(e._def.input,r):r,i=await Reflect.apply(n,this,o);if(e._def.output)return await Yn(e._def.output,i);return i},"_zod",{value:e._zod,enumerable:!1})},e._zod.parse=(n,r)=>{if(typeof n.value!=="function")return n.issues.push({code:"invalid_type",expected:"function",input:n.value,inst:e}),n;if(e._def.output&&e._def.output._zod.def.type==="promise")n.value=e.implementAsync(n.value);else n.value=e.implement(n.value);return n},e.input=(...n)=>{let r=e.constructor;if(Array.isArray(n[0]))return new r({type:"function",input:new pr({type:"tuple",items:n[0],rest:n[1]}),output:e._def.output});return new r({type:"function",input:n[0],output:e._def.output})},e.output=(n)=>new e.constructor({type:"function",input:e._def.input,output:n}),e)),Xa=h("$ZodPromise",(e,t)=>{N.init(e,t),e._zod.parse=(n,r)=>Promise.resolve(n.value).then((o)=>t.innerType._zod.run({value:o,issues:[]},r))});var Qa=h("$ZodCustom",(e,t)=>{G.init(e,t),N.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((i)=>Xs(i,n,r,e));Xs(o,n,r,e);return}});function Xs(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(ze(o))}}class tc extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform");this.name="ZodCyclicError"}}var hr="~memo",ec=[];function nc(e){return e!==null&&typeof e==="object"}function gr(e){return e.map((t)=>t.path?{...t,path:t.path.slice()}:{...t})}var rc=new WeakMap,St=0,rn=1,vt=2;function on(e,t,n){let r=rc.get(e);if(r!==void 0)return r?vt:St;if(t.has(e))return vt;t.add(e);let o=St,i=(l)=>{if(o!==vt&&l?._zod){let p=on(l,t,n);if(p>o)o=p}},s=(l,p)=>{let m=St;for(let f of Reflect.ownKeys(l)){let g=Object.getOwnPropertyDescriptor(l,f);if(p&&!g.enumerable)continue;let y=g.get?rn:g.value?._zod?on(g.value,t,n):St;if(y>m)m=y}return m},a=(l)=>{if(l>o)o=l},c=e._zod.def,u=c.type;switch(u){case"object":{let l=gt(c);a(l?s(l,!0):rn),i(c.catchall);break}case"array":i(c.element);break;case"tuple":for(let l of c.items)i(l);i(c.rest);break;case"record":case"map":i(c.keyType),i(c.valueType);break;case"set":i(c.valueType);break;case"union":for(let l of c.options)i(l);break;case"intersection":i(c.left),i(c.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":i(c.innerType);break;case"pipe":i(c.in),i(c.out);break;case"function":i(c.input),i(c.output);break;case"lazy":{let l=c._cachedInner??(n?e._zod.innerType:void 0);a(l?on(l,t,!1):rn);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(let l in c){let p=Object.getOwnPropertyDescriptor(c,l);if(!p||p.get)continue;let m=p.value;if(!m||typeof m!=="object")continue;if(m._zod)i(m);else if(Array.isArray(m))for(let f of m)i(f)}}return t.delete(e),lm(e,o)}function lm(e,t){if(t!==rn)rc.set(e,t===vt);return t}function dm(e,t){let n=e.buckets.get(t);if(!n)n=new WeakMap,e.buckets.set(t,n);return n}var tn,nn=[],pm={alloc(e,t,n){let r=tn;if(!r)return n;tn=void 0;let o={value:n,issues:null};return r.set(t.value,o),nn.push(o),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let n=e._zod.parse,r=(o,i)=>{if(i.direction!=="backward"&&mm(i,o.value))throw new tc;return n(o,i)};if(e._zod.parse=r,e._zod.run===n)e._zod.run=r})},attach(e){var t;let n,r=!1,o,i;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let s=e._zod.parse,a=(c,u)=>{if(n===void 0){let v=on(e,new Set,!1);if(v===St){if(e._zod.parse=s,e._zod.run===a)e._zod.run=s;return s(c,u)}if(v===vt||r)n=!0;else r=!0}let l=c.value;if(!nc(l))return s(c,u);let p=u[hr];if(!p)p={buckets:new WeakMap,backEdges:void 0},u[hr]=p;let m;if(o===u)m=i;else m=dm(p,e),o=u,i=m;let f=m.get(l);if(f){if(c.value=f.value,f.issues){if(f.issues.length)c.issues.push(...gr(f.issues))}else c.memo=!0,p.backEdges??(p.backEdges=new WeakSet),p.backEdges.add(f.value);return c}tn=m;let g=nn.length,y=s(c,u);tn=void 0;let _=nn.length>g?nn.pop():void 0;if(y instanceof Promise)return y.then((v)=>{if(_)_.issues=v.issues.length?gr(v.issues):ec;return v});if(_)_.issues=y.issues.length?gr(y.issues):ec;return y};if(e._zod.parse=a,e._zod.run===s)e._zod.run=a})}};function yr(){return pm}function mm(e,t){let n=e[hr]?.backEdges;return n!==void 0&&nc(t)&&n.has(t)}var fm=()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function t(i){return e[i]??null}let n={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},r={nan:"NaN"};function o(i,s){if(i==="number"&&typeof s==="number"&&!Number.isFinite(s))return String(s);return r[i]??i}return(i)=>{switch(i.code){case"invalid_type":{let s=o(i.expected),a=zi(i.input),c=o(a,i.input);return`Invalid input: expected ${s}, received ${c}`}case"invalid_value":if(i.values.length===1)return`Invalid input: expected ${Un(i.values[0])}`;return`Invalid option: expected one of ${Ln(i.values,"|")}`;case"too_big":{let s=i.exact?"exactly ":i.inclusive?"<=":"<",a=t(i.origin);if(a)return`Too big: expected ${i.origin??"value"} to have ${s}${i.maximum.toString()} ${a.unit??"elements"}`;return`Too big: expected ${i.origin??"value"} to be ${s}${i.maximum.toString()}`}case"too_small":{let s=i.exact?"exactly ":i.inclusive?">=":">",a=t(i.origin);if(a)return`Too small: expected ${i.origin} to have ${s}${i.minimum.toString()} ${a.unit}`;return`Too small: expected ${i.origin} to be ${s}${i.minimum.toString()}`}case"invalid_format":{let s=i;if(s.format==="starts_with")return`Invalid string: must start with "${s.prefix}"`;if(s.format==="ends_with")return`Invalid string: must end with "${s.suffix}"`;if(s.format==="includes")return`Invalid string: must include "${s.includes}"`;if(s.format==="regex")return`Invalid string: must match pattern ${s.pattern}`;return`Invalid ${n[s.format]??i.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${i.divisor}`;case"unrecognized_keys":return`Unrecognized key${i.keys.length>1?"s":""}: ${Ln(i.keys,", ")}`;case"invalid_key":return`Invalid key in ${i.origin}`;case"invalid_union":if(i.options&&Array.isArray(i.options)&&i.options.length>0)return`Invalid discriminator value. Expected ${i.options.map((a)=>`'${a}'`).join(" | ")}`;if(i.inclusive===!1)return"Invalid input: more than one option matched";return"Invalid input";case"invalid_element":return`Invalid value in ${i.origin}`;default:return"Invalid input"}}};function br(){return{localeError:fm()}}var oc;class ic{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 sc(){return new ic}(oc=globalThis).__zod_globalRegistry??(oc.__zod_globalRegistry=sc());var Re=globalThis.__zod_globalRegistry;function ac(e){if(e.checks)e.checks=[...e.checks];return e}function cc(e,t){return new e(ac({type:"string",...S(t)}))}function uc(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...S(t)})}function lc(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...S(t)})}function dc(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...S(t)})}function pc(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...S(t)})}function mc(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...S(t)})}function fc(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...S(t)})}function gc(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...S(t)})}function hc(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...S(t)})}function yc(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...S(t)})}function bc(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...S(t)})}function xc(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...S(t)})}function _c(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...S(t)})}function Sc(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...S(t)})}function vc(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...S(t)})}function Cc(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...S(t)})}function Tc(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...S(t)})}function kc(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...S(t)})}function Ec(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...S(t)})}function Rc(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...S(t)})}function Ac(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...S(t)})}function Ic(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...S(t)})}function wc(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...S(t)})}function Pc(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...S(t)})}function Mc(e,t){return new e({type:"string",format:"date",check:"string_format",...S(t)})}function Oc(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...S(t)})}function Nc(e,t){return new e({type:"string",format:"duration",check:"string_format",...S(t)})}function zc(e,t){return new e(ac({type:"number",checks:[],...S(t)}))}function $c(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...S(t)})}function Lc(e,t){return new e({type:"boolean",...S(t)})}function Dc(e){return new e({type:"unknown"})}function Bc(e,t){return new e({type:"never",...S(t)})}function Uc(e,t){return new e({type:"void",...S(t)})}function Zc(e,t){return new e({type:"date",...S(t)})}function sn(e,t){return new or({check:"less_than",...S(t),value:e,inclusive:!1})}function Fe(e,t){return new or({check:"less_than",...S(t),value:e,inclusive:!0})}function an(e,t){return new ir({check:"greater_than",...S(t),value:e,inclusive:!1})}function He(e,t){return new ir({check:"greater_than",...S(t),value:e,inclusive:!0})}function cn(e,t){return new Es({check:"multiple_of",...S(t),value:e})}function un(e,t){return new As({check:"max_length",...S(t),maximum:e})}function je(e,t){return new Is({check:"min_length",...S(t),minimum:e})}function ln(e,t){return new ws({check:"length_equals",...S(t),length:e})}function xr(e,t){return new Ps({check:"string_format",format:"regex",...S(t),pattern:e})}function _r(e){return new Ms({check:"string_format",format:"lowercase",...S(e)})}function Sr(e){return new Os({check:"string_format",format:"uppercase",...S(e)})}function vr(e,t){return new Ns({check:"string_format",format:"includes",...S(t),includes:e})}function Cr(e,t){return new zs({check:"string_format",format:"starts_with",...S(t),prefix:e})}function Tr(e,t){return new $s({check:"string_format",format:"ends_with",...S(t),suffix:e})}function Ae(e){return new Ls({check:"overwrite",tx:e})}function kr(e){return Ae((t)=>t.normalize(e))}function Er(){return Ae((e)=>e.trim())}function Rr(){return Ae((e)=>e.toLowerCase())}function Ar(){return Ae((e)=>e.toUpperCase())}function Ir(){return Ae((e)=>Ai(e))}function Fc(e,t,n){return new e({type:"array",element:t,...S(n)})}function Hc(e,t,n){let r=S(n);return r.abort??(r.abort=!0),new e({type:"custom",check:"custom",fn:t,...r})}function jc(e,t,n){return new e({type:"custom",check:"custom",fn:t,...S(n)})}function Vc(e,t){let n=gm((r)=>(r.addIssue=(o)=>{if(typeof o==="string")r.issues.push(ze(o,r.value,n._zod.def));else{let i=o;if(i.fatal)i.continue=!1;if(i.code??(i.code="custom"),!("input"in i))i.input=r.value;i.inst??(i.inst=n),i.continue??(i.continue=!n._zod.def.abort),r.issues.push(ze(i))}},e(r.value,r)),t);return n}function gm(e,t){let n=new G({check:"custom",...S(t)});return n._zod.check=e,n}function Ct(e,...t){for(let n of t)for(let r of Reflect.ownKeys(n))if(Object.prototype.propertyIsEnumerable.call(n,r))te(e,r,n[r]);return e}function kt(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,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??"ref",reused:e?.reused??"inline",intersections:[],deferred:[],external:e?.external??void 0}}function q(e,t,n,r,o){let i=typeof t.unrepresentable==="function"?t.unrepresentable({zodSchema:e,path:r.path,message:o}):t.unrepresentable;if(i==="any")return!1;if(i===void 0||i==="throw")throw Error(o);return Object.assign(n,i),!0}function D(e,t,n={path:[],schemaPath:[]}){var r;let o=e._zod.def,i=t.seen.get(e);if(i){if(i.count++,n.schemaPath.includes(e))i.cycle=n.path;return i.schema}let s={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,s),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let a=e._zod.toJSONSchema?.();if(a)s.schema=a;else{let l={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,s.schema,l);else{let m=s.schema,f=t.processors[o.type];if(!f)throw Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);f(e,t,m,l)}let p=e._zod.parent;if(p){if(!s.ref)s.ref=p;D(p,t,l),t.seen.get(p).isParent=!0}}let c=t.metadataRegistry.get(e);if(c)Ct(s.schema,c);if(t.io==="input"&&X(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 qc(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function Et(e,t){let n=e.seen.get(t);if(!n)throw Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;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 o=(s)=>{let a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let p=e.external.registry.get(s[0])?.id,m=e.external.uri??((g)=>g);if(p)return{ref:m(p)};let f=s[1].defId??s[1].schema.id??`schema${e.counter++}`;return s[1].defId=f,{defId:f,ref:`${m("__shared")}#/${a}/${qc(f)}`}}let c="#",u=`${c}/${a}/`;if(s[1]===n&&!s[1].schema.id)return{ref:c};let l=s[1].schema.id??`__schema${e.counter++}`;return{defId:l,ref:u+qc(l)}},i=(s)=>{if(s[1].schema.$ref)return;let a=s[1],{ref:c,defId:u}=o(s);if(a.def={...a.schema},u)a.defId=u;let l=a.schema;for(let p in l)delete l[p];l.$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>
57
57
 
58
- Set 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)}}if(e.external)e.sharedDefsExtractedFor=e.external}function Wc(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let r of t){if(!r||typeof r!=="object")return;Wc(r);let o=Object.keys(r);if(o.length!==1||o[0]!=="type")return;let i=r.type;for(let s of Array.isArray(i)?i:[i]){if(typeof s!=="string")return;if(!n.includes(s))n.push(s)}}delete e.anyOf,e.type=n.length===1?n[0]:n}var Jc=new Set(["type","properties","required","additionalProperties"]),Gc=["oneOf","anyOf"];function Kc(e){let t=e.additionalProperties;if(t===void 0||t===!1||typeof t!=="object"||t===null)return null;return Object.keys(t).length?t:null}function wr(e){let t=[];for(let i of e){if(typeof i!=="object"||i.type!=="object")return null;for(let s in i)if(!Jc.has(s))return null;t.push(i)}let n={},r=new Set;for(let i of t){for(let s in i.properties){if(Object.prototype.hasOwnProperty.call(n,s))continue;let a=[];for(let u of t){let l=u.properties?.[s]??Kc(u);if(l===null||l===void 0)continue;if(!a.some((p)=>JSON.stringify(p)===JSON.stringify(l)))a.push(l)}let c=a.length===1?a[0]:wr(a)??{allOf:a};te(n,s,c)}for(let s of i.required??[])r.add(s)}let o={type:"object",properties:n};if(r.size)o.required=[...r];if(t.every((i)=>i.additionalProperties===!1))o.additionalProperties=!1;else{let i=[];for(let s of t){let a=Kc(s);if(a&&!i.some((c)=>JSON.stringify(c)===JSON.stringify(a)))i.push(a)}if(i.length===1)o.additionalProperties=i[0];else if(i.length>1)o.additionalProperties={allOf:i}}return o}function mm(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let o of Jc)if(o in e)return;let n=t.filter((o)=>Gc.some((i)=>Array.isArray(o[i]))),r=null;if(!n.length)r=wr(t);else{let o=n[0],i=Gc.find((c)=>Array.isArray(o[c]));if(Object.keys(o).length!==1)return;let s=t.filter((c)=>c!==o),a=o[i].map((c)=>wr([...s,c]));if(a.some((c)=>!c))return;r={[i]:a}}if(!r)return;delete e.allOf,Tt(e,r)}function Rt(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 u=c.def??c.schema,l={...u},p=c.ref;if(c.ref=null,p){r(p);let f=e.seen.get(p),g=f.schema;if(g.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"))u.allOf=u.allOf??[],u.allOf.push(g);else Tt(u,g);if(Tt(u,l),a._zod.parent===p)for(let S in u){if(S==="$ref"||S==="allOf")continue;if(!(S in l))delete u[S]}if(g.$ref&&f.def)for(let S in u){if(S==="$ref"||S==="allOf")continue;if(S in f.def&&JSON.stringify(u[S])===JSON.stringify(f.def[S]))delete u[S]}}let m=a._zod.parent;if(m&&m!==p){r(m);let f=e.seen.get(m);if(f?.schema.$ref){if(u.$ref=f.schema.$ref,f.def)for(let g in u){if(g==="$ref"||g==="allOf")continue;if(g in f.def&&JSON.stringify(u[g])===JSON.stringify(f.def[g]))delete u[g]}}}e.override({zodSchema:a,jsonSchema:u,path:c.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let a of[...e.seen.entries()].reverse())r(a[0]);if(e.target!=="openapi-3.0")for(let a of e.seen.entries())Wc(a[1].def??a[1].schema);for(let a of e.deferred)a();if(e.intersections.length){let a=new Map;for(let c of e.seen.values())for(let u of[c.schema,c.def]){let l=u?.allOf;if(!Array.isArray(l))continue;let p=a.get(l);if(p)p.push(u);else a.set(l,[u])}for(let c of e.intersections)for(let u of a.get(c)??[])mm(u)}}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)}Tt(o,n.defId?n.schema:n.def??n.schema);let i=e.metadataRegistry.get(t)?.id;if(i!==void 0&&o.id===i)delete o.id;let s=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)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;te(s,c.defId,c.def)}}if(e.external)e.sharedEmitDoneFor=e.external;if(e.external);else if(Object.keys(s).length>0)if(e.target==="draft-2020-12")o.$defs=s;else o.definitions=s;try{let a=JSON.parse(JSON.stringify(o));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:Ct(t,"input",e.processors),output:Ct(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch(a){throw Error("Error converting schema to JSON.")}}function X(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 X(r.element,n);if(r.type==="set")return X(r.valueType,n);if(r.type==="lazy")return X(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"||r.type==="catch")return X(r.innerType,n);if(r.type==="intersection")return X(r.left,n)||X(r.right,n);if(r.type==="record"||r.type==="map")return X(r.keyType,n)||X(r.valueType,n);if(r.type==="pipe"){if(e._zod.traits.has("$ZodCodec"))return!0;return X(r.in,n)||X(r.out,n)}if(r.type==="object"){for(let o in r.shape)if(X(r.shape[o],n))return!0;return!1}if(r.type==="union"){for(let o of r.options)if(X(o,n))return!0;return!1}if(r.type==="tuple"){for(let o of r.items)if(X(o,n))return!0;if(r.rest&&X(r.rest,n))return!0;return!1}return!1}var Yc=(e,t={})=>(n)=>{let r=kt({...n,processors:t});return D(e,r),Et(r,e),Rt(r,e)},Ct=(e,t,n={})=>(r)=>{let{libraryOptions:o,target:i}=r??{},s=kt({...o??{},target:i,io:t,processors:n});return D(e,s),Et(s,e),Rt(s,e)};var Ve=(e,t,n)=>{if(e[t]===void 0||n>e[t])e[t]=n},qe=(e,t,n)=>{if(e[t]===void 0||n<e[t])e[t]=n},Xc=(e,t)=>{Ve(e,"minimum",t),qe(e,"maximum",t)},ru=(e,t)=>{if(e.multipleOf??(e.multipleOf=[]),!e.multipleOf.includes(t))e.multipleOf.push(t)},ou=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},iu=(e,t)=>{e.mime=e.mime?e.mime.filter((n)=>t.includes(n)):[...t]},su=(e,t)=>{if(e.format=t,t.includes("int"))e.isInt=!0},Qc=(e,t)=>Ve(e,"minimum",t.minimum),eu=(e,t)=>qe(e,"maximum",t.maximum),tu=(e)=>(t,n)=>{su(t,n.format);let[r,o]=e[n.format];Ve(t,"minimum",r),qe(t,"maximum",o)},fm={greater_than:(e,t)=>Ve(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>qe(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>ru(e,t.value),number_format:tu(Ut),bigint_format:tu(Zn),min_length:Qc,max_length:eu,length_equals:(e,t)=>Xc(e,t.length),min_size:Qc,max_size:eu,size_equals:(e,t)=>Xc(e,t.size),string_format:(e,t)=>{if(su(e,t.format),t.pattern)ou(e,t.pattern);if(t.format==="base64"||t.format==="base64url")e.contentEncoding=t.format;if(t.local||t.precision===-1)e.laxFormat=!0},mime_type:(e,t)=>iu(e,t.mime)};function W(e){let t={},n=e._zod.def,r=e._zod.traits.has("$ZodCheck")?[e,...n.checks??[]]:n.checks??[];for(let i of r)fm[i._zod.def.check]?.(t,i._zod.def);let o=e._zod.bag;if(o.minimum!==void 0)Ve(t,"minimum",o.minimum);if(o.exclusiveMinimum!==void 0)Ve(t,"exclusiveMinimum",o.exclusiveMinimum);if(o.maximum!==void 0)qe(t,"maximum",o.maximum);if(o.exclusiveMaximum!==void 0)qe(t,"exclusiveMaximum",o.exclusiveMaximum);if(o.multipleOf!==void 0)ru(t,o.multipleOf);if(o.format!==void 0){if(t.format??(t.format=o.format),o.format.includes("int"))t.isInt=!0}if(o.mime)iu(t,o.mime);for(let i of o.patterns??[])ou(t,i);return t}var gm={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},hm=new Map([[ur,fs],[en,gs]]),au=(e)=>hm.get(e)??e,Or=(e,t,n,r)=>{let o=n;o.type="string";let{minimum:i,maximum:s,format:a,patterns:c,contentEncoding:u,laxFormat:l}=W(e);if(typeof i==="number")o.minLength=i;if(typeof s==="number")o.maxLength=s;if(a){if(o.format=gm[a]??a,o.format==="")delete o.format;if(a==="time"||l)delete o.format}if(u)o.contentEncoding=u;if(c&&c.size>0){let p=[...c].map(au);if(p.length===1)o.pattern=p[0].source;else if(p.length>1)o.allOf=[...p.map((m)=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:m.source}))]}},zr=(e,t,n,r)=>{let o=n,{minimum:i,maximum:s,multipleOf:a,exclusiveMaximum:c,exclusiveMinimum:u,isInt:l}=W(e);o.type=l?"integer":"number";let p=typeof u==="number"&&u>=(i??Number.NEGATIVE_INFINITY),m=typeof c==="number"&&c<=(s??Number.POSITIVE_INFINITY),f=t.target==="draft-04"||t.target==="openapi-3.0";if(p)if(f)o.minimum=u,o.exclusiveMinimum=!0;else o.exclusiveMinimum=u;else if(typeof i==="number")o.minimum=i;if(m)if(f)o.maximum=c,o.exclusiveMaximum=!0;else o.exclusiveMaximum=c;else if(typeof s==="number")o.maximum=s;if(a){let g=new Set;for(let v of a)if(Number.isFinite(v)&&v!==0)g.add(Math.abs(v));else q(e,t,o,r,`A multipleOf divisor of ${v} cannot be represented in JSON Schema`);let[y,...S]=g;if(y!==void 0)o.multipleOf=y;if(S.length)o.allOf=[...o.allOf??[],...S.map((v)=>({multipleOf:v}))]}},Nr=(e,t,n,r)=>{n.type="boolean"},cu=(e,t,n,r)=>{q(e,t,n,r,"BigInt cannot be represented in JSON Schema")},uu=(e,t,n,r)=>{q(e,t,n,r,"Symbols cannot be represented in JSON Schema")},lu=(e,t,n,r)=>{if(t.target==="openapi-3.0")n.type="string",n.nullable=!0,n.enum=[null];else n.type="null"},du=(e,t,n,r)=>{q(e,t,n,r,"Undefined cannot be represented in JSON Schema")},$r=(e,t,n,r)=>{q(e,t,n,r,"Void cannot be represented in JSON Schema")},Lr=(e,t,n,r)=>{n.not={}},pu=(e,t,n,r)=>{},Dr=(e,t,n,r)=>{},Br=(e,t,n,r)=>{q(e,t,n,r,"Date cannot be represented in JSON Schema")},Ur=(e,t,n,r)=>{let o=e._zod.def,i=pt(o.entries);if(i.length===0){n.not={};return}if(i.every((s)=>typeof s==="number"))n.type="number";if(i.every((s)=>typeof s==="string"))n.type="string";n.enum=i},Zr=(e,t,n,r)=>{let o=e._zod.def;if(o.values.length===0){n.not={};return}let i=[];for(let s of o.values)if(s===void 0){if(q(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof s==="bigint"){if(q(e,t,n,r,"BigInt literals cannot be represented in JSON Schema"))return;i.push(Number(s))}else i.push(s);if(i.length===0);else if(i.length===1){let s=i[0];if(n.type=s===null?"null":typeof s,t.target==="draft-04"||t.target==="openapi-3.0")n.enum=[s];else n.const=s}else{if(i.every((s)=>typeof s==="number"))n.type="number";if(i.every((s)=>typeof s==="string"))n.type="string";if(i.every((s)=>typeof s==="boolean"))n.type="boolean";if(i.every((s)=>s===null))n.type="null";n.enum=i}},mu=(e,t,n,r)=>{q(e,t,n,r,"NaN cannot be represented in JSON Schema")},fu=(e,t,n,r)=>{let o=n,i=e._zod.pattern;if(!i)throw Error("Pattern not found in template literal");o.type="string",o.pattern=i.source},gu=(e,t,n,r)=>{let o=n;o.type="string",o.format="binary",o.contentEncoding="binary";let{minimum:i,maximum:s,mime:a}=W(e);if(i!==void 0)o.minLength=i;if(s!==void 0)o.maxLength=s;if(!a)return;if(a.length===0)o.not={};else if(a.length===1)o.contentMediaType=a[0];else o.anyOf=a.map((c)=>({contentMediaType:c}))},hu=(e,t,n,r)=>{n.type="boolean"},Fr=(e,t,n,r)=>{q(e,t,n,r,"Custom types cannot be represented in JSON Schema")},Hr=(e,t,n,r)=>{q(e,t,n,r,"Function types cannot be represented in JSON Schema")},jr=(e,t,n,r)=>{q(e,t,n,r,"Transforms cannot be represented in JSON Schema")},yu=(e,t,n,r)=>{q(e,t,n,r,"Map cannot be represented in JSON Schema")},bu=(e,t,n,r)=>{q(e,t,n,r,"Set cannot be represented in JSON Schema")},Vr=(e,t,n,r)=>{let o=n,i=e._zod.def,{minimum:s,maximum:a}=W(e);if(typeof s==="number")o.minItems=s;if(typeof a==="number")o.maxItems=a;o.type="array",o.items=D(i.element,t,{...r,path:[...r.path,"items"]})};function At(e){let t=e._zod.def;if(t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform"))return At(t.out);if(t.type==="catch")return At(t.innerType);return e._zod.optin}var qr=(e,t,n,r)=>{let o=n,i=e._zod.def,s=i.shape;if(Object.getOwnPropertySymbols(s).length&&q(e,t,o,r,"Symbol keys cannot be represented in JSON Schema"))return;o.type="object",o.properties={};for(let u in s)te(o.properties,u,D(s[u],t,{...r,path:[...r.path,"properties",u]}));let c=[];for(let u of Object.keys(s)){let l=i.shape[u];if(t.io==="input"?At(l)===void 0:l._zod.optout===void 0)c.push(u)}if(c.length>0)o.required=c;if(i.catchall?._zod.def.type==="never")o.additionalProperties=!1;else if(!i.catchall){if(t.io==="output")o.additionalProperties=!1}else if(i.catchall)o.additionalProperties=D(i.catchall,t,{...r,path:[...r.path,"additionalProperties"]})},Gr=(e,t,n,r)=>{let o=e._zod.def,i=o.inclusive===!1,s=o.options.map((a,c)=>D(a,t,{...r,path:[...r.path,i?"oneOf":"anyOf",c]}));if(i)n.oneOf=s;else n.anyOf=s},Kr=(e,t,n,r)=>{let o=e._zod.def,i=D(o.left,t,{...r,path:[...r.path,"allOf",0]}),s=D(o.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]];n.allOf=c,t.intersections.push(c)},Wr=(e,t,n,r)=>{let o=n,i=e._zod.def;o.type="array";let s=t.target==="draft-2020-12"?"prefixItems":"items",a=t.target==="draft-2020-12"?"items":t.target==="openapi-3.0"?"items":"additionalItems",c=i.items.map((y,S)=>D(y,t,{...r,path:[...r.path,s,S]})),u=i.rest?D(i.rest,t,{...r,path:[...r.path,a,...t.target==="openapi-3.0"?[i.items.length]:[]]}):null,l=i.items.length;while(l>0){let y=i.items[l-1];if(!(t.io==="input"?At(y)!==void 0:y._zod.optout==="optional"))break;l--}let p=i.items.length,m=!i.rest;if(t.target==="draft-2020-12"){if(o.prefixItems=c,m)o.items=!1;else if(u)o.items=u;if(l>0)o.minItems=l;if(m)o.maxItems=p}else if(t.target==="openapi-3.0"){if(o.items={anyOf:c},u)o.items.anyOf.push(u);if(l>0)o.minItems=l;if(m)o.maxItems=p}else{if(o.items=c,m)o.additionalItems=!1;else if(u)o.additionalItems=u;if(l>0)o.minItems=l;if(m)o.maxItems=p}let{minimum:f,maximum:g}=W(e);if(typeof f==="number")o.minItems=f;if(typeof g==="number")o.maxItems=g};function Pr(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);let g=e.get(t)?.def;if(!g)return t;let y=Pr(e,g,n);return y===g?t:y}for(let g of["anyOf","oneOf"]){let y=t[g];if(!Array.isArray(y))continue;let S=y.map((v)=>Pr(e,v,n));if(S.some((v,k)=>v!==y[k]))t={...t,[g]:S}}let r=Array.isArray(t.type)?t.type:[t.type],o=!r.includes("string")&&r.some((g)=>g==="number"||g==="integer"),i=t.enum??(t.const!==void 0?[t.const]:void 0);if(!o&&!i?.some((g)=>typeof g==="number"))return t;let{minimum:s,maximum:a,exclusiveMinimum:c,exclusiveMaximum:u,multipleOf:l,format:p,id:m,...f}=t;if(f.enum)f.enum=f.enum.map((g)=>typeof g==="number"?String(g):g);else if(typeof f.const==="number")f.const=String(f.const);if(!o)return f;if(f.type="string",!i)f.pattern=(r.includes("number")?xt:nr).source;return f}var Mr=new WeakMap;function ym(e){let t=new Map;for(let r of e.seen.values())if(r.def&&!t.has(r.schema))t.set(r.schema,r);let n=new Map;for(let r of Mr.get(e)??[]){let o=e.seen.get(r),i=(o?.def??o?.schema)?.propertyNames;if(!i||i===!0||n.has(i))continue;let s=Pr(t,i,new Set);if(s!==i)n.set(i,s)}if(!n.size)return;for(let r of e.seen.values())for(let o of[r.schema,r.def]){let i=o&&n.get(o.propertyNames);if(i)o.propertyNames=i}}var Jr=(e,t,n,r)=>{let o=n,i=e._zod.def;o.type="object";let s=i.keyType,a=W(s).patterns;if(i.mode==="loose"&&a&&a.size>0){let l=D(i.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});o.patternProperties={};for(let p of a)te(o.patternProperties,au(p).source,l)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){o.propertyNames=D(i.keyType,t,{...r,path:[...r.path,"propertyNames"]});let l=Mr.get(t);if(!l)l=[],Mr.set(t,l),t.deferred.push(()=>ym(t));l.push(e)}o.additionalProperties=D(i.valueType,t,{...r,path:[...r.path,"additionalProperties"]})}let c=s._zod.values,u=t.io==="input"&&At(i.valueType)!==void 0;if(c&&!i.partial&&!u){let l=[...c].filter((p)=>typeof p==="string"||typeof p==="number");if(l.length>0)o.required=l.map(String)}},Yr=(e,t,n,r)=>{let o=e._zod.def,i=D(o.innerType,t,r),s=t.seen.get(e);if(t.target==="openapi-3.0")s.ref=o.innerType,n.nullable=!0;else n.anyOf=[i,{type:"null"}]},Xr=(e,t,n,r)=>{let o=e._zod.def;D(o.innerType,t,r);let i=t.seen.get(e);i.ref=o.innerType},Qr=Symbol();function xu(e,t,n,r,o){let i=!1,s=JSON.stringify(e,(a,c)=>{if(typeof c!=="bigint")return c;return i=!0,null});if(!i)return JSON.parse(s);return q(t,n,r,o,"BigInt defaults cannot be represented in JSON Schema"),Qr}var eo=(e,t,n,r)=>{let o=e._zod.def;D(o.innerType,t,r);let i=t.seen.get(e);i.ref=o.innerType;let s=xu(o.defaultValue,e,t,n,r);if(s!==Qr)n.default=s},to=(e,t,n,r)=>{let o=e._zod.def;D(o.innerType,t,r);let i=t.seen.get(e);if(i.ref=o.innerType,t.io!=="input")return;let s=xu(o.defaultValue,e,t,n,r);if(s!==Qr)n._prefault=s},no=(e,t,n,r)=>{let o=e._zod.def;D(o.innerType,t,r);let i=t.seen.get(e);i.ref=o.innerType;let s;try{s=o.catchValue(void 0)}catch{q(e,t,n,r,"Dynamic catch values are not supported in JSON Schema");return}n.default=s},ro=(e,t,n,r)=>{let o=e._zod.def,i=o.in._zod.traits.has("$ZodTransform"),s=t.io==="input"?i?o.out:o.in:o.out;D(s,t,r);let a=t.seen.get(e);a.ref=s},oo=(e,t,n,r)=>{let o=e._zod.def;D(o.innerType,t,r);let i=t.seen.get(e);i.ref=o.innerType,n.readOnly=!0},io=(e,t,n,r)=>{let o=e._zod.def;D(o.innerType,t,r);let i=t.seen.get(e);i.ref=o.innerType},dn=(e,t,n,r)=>{let o=e._zod.def;D(o.innerType,t,r);let i=t.seen.get(e);i.ref=o.innerType},Su=(e,t,n,r)=>{let o=e._zod.innerType;D(o,t,r);let i=t.seen.get(e);i.ref=o},nu={string:Or,number:zr,boolean:Nr,bigint:cu,symbol:uu,null:lu,undefined:du,void:$r,never:Lr,any:pu,unknown:Dr,date:Br,enum:Ur,literal:Zr,nan:mu,template_literal:fu,file:gu,success:hu,custom:Fr,function:Hr,transform:jr,map:yu,set:bu,array:Vr,object:qr,union:Gr,intersection:Kr,tuple:Wr,record:Jr,nullable:Yr,nonoptional:Xr,default:eo,prefault:to,catch:no,pipe:ro,readonly:oo,promise:io,optional:dn,lazy:Su};function _u(e,t){if("_idmap"in e){let r=e,o=kt({...t,processors:nu}),i={};for(let c of r._idmap.entries()){let[u,l]=c;D(l,o)}let s={},a={registry:r,uri:t?.uri,defs:i};o.external=a;for(let c of r._idmap.entries()){let[u,l]=c;Et(o,l),te(s,u,Rt(o,l))}if(Object.keys(i).length>0){let c=o.target==="draft-2020-12"?"$defs":"definitions";s.__shared={[c]:i}}return{schemas:s}}let n=kt({...t,processors:nu});return D(e,n),Et(n,e),Rt(n,e)}var vu=new WeakSet([Object.prototype,Error.prototype]);function mn(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let r=n(this);return Object.defineProperty(this,t,{value:r,configurable:!0,writable:!0}),r},set(r){Object.defineProperty(this,t,{value:r,configurable:!0,writable:!0})}})}var Em=(e,t)=>{Fi.init(e,t),e.name="ZodError";let n=Object.getPrototypeOf(e);if(vu.has(n))return;vu.add(n),mn(n,"format",(r)=>(o)=>Wn(r,o)),mn(n,"flatten",(r)=>(o)=>Kn(r,o)),mn(n,"addIssue",(r)=>(o)=>{r.issues.push(o),r.message=JSON.stringify(r.issues,mt,2)}),mn(n,"addIssues",(r)=>(o)=>{r.issues.push(...o),r.message=JSON.stringify(r.issues,mt,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}})};var re=h("ZodError",Em,void 0,{Parent:Error});var Tu=yt(re),Cu=bt(re),ku=Gt(re),Eu=Kt(re),Ru=Vi(re),Au=qi(re),Iu=Gi(re),wu=Ki(re),Pu=Wi(re),Mu=Ji(re),Ou=Yi(re),zu=Xi(re);function Am(){if(!Y.localeError)Q(br())}function It(){if(!Y.memoizer)Q({memoizer:yr()})}var N=h("ZodType",(e,t)=>(Am(),z.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(ne(t,{checks:[...t.checks??[],...e.map((n)=>typeof n==="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return ue(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(wf(e,t))},superRefine(e,t){return this.check(Pf(e,t))},overwrite(e){return this.check(Ae(e))},optional(){return Lu(this)},exactOptional(){return hf(this)},nullable(){return Du(this)},nullish(){return Lu(Du(this))},nonoptional(e){return vf(this,e)},array(){return E(this)},or(e){return Ge([this,e])},and(e){return df(this,e)},transform(e){return Bu(this,Hu(e))},default(e){return xf(this,e)},prefault(e){return _f(this,e)},catch(e){return Cf(this,e)},pipe(e){return Bu(this,e)},readonly(){return Rf(this)},describe(e){let t=this.clone();return Re.add(t,{description:e}),t},meta(...e){if(e.length===0)return Re.get(this);let t=this.clone();return Re.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get "~standard"(){return Vt(this,"~standard",{...cr(this),jsonSchema:{input:Ct(this,"input"),output:Ct(this,"output")}})},set "~standard"(e){xe(this,"~standard",e)},parse:function e(t,n){return Tu(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await Cu(this,t,n,{callee:e})},safeParse(e,t){return ku(this,e,t)},async safeParseAsync(e,t){return Eu(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){xe(this,"spa",e)},validate(e,t){return Xn(this,e,t)},validateAsync(e,t){return Qn(this,e,t)},encode:function e(t,n){return Ru(this,t,n,{callee:e})},decode:function e(t,n){return Au(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await Iu(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await wu(this,t,n,{callee:e})},safeEncode(e,t){return Pu(this,e,t)},safeDecode(e,t){return Mu(this,e,t)},async safeEncodeAsync(e,t){return Ou(this,e,t)},async safeDecodeAsync(e,t){return zu(this,e,t)},toJSONSchema(e){return Yc(this,{})(e)},get description(){return Re.get(this)?.description},get _def(){return this._zod.def}}),Uu=h("_ZodString",(e,t)=>{Qt.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Or(e,n,r,o)},Hn({format:(e)=>W(e).format??null,minLength:(e)=>W(e).minimum??null,maxLength:(e)=>W(e).maximum??null},{regex(...e){return this.check(xr(...e))},includes(...e){return this.check(vr(...e))},startsWith(...e){return this.check(Tr(...e))},endsWith(...e){return this.check(Cr(...e))},min(...e){return this.check(je(...e))},max(...e){return this.check(un(...e))},length(...e){return this.check(ln(...e))},nonempty(...e){return this.check(je(1,...e))},lowercase(e){return this.check(Sr(e))},uppercase(e){return this.check(_r(e))},trim(){return this.check(Er())},normalize(...e){return this.check(kr(...e))},toLowerCase(){return this.check(Rr())},toUpperCase(){return this.check(Ar())},slugify(){return this.check(Ir())}})),Im=h("ZodString",(e,t)=>{Qt.init(e,t),Uu.init(e,t)},{email(e){return this.check(uc(zm,e))},url(e){return this.check(gc($m,e))},jwt(e){return this.check(wc(Ym,e))},emoji(e){return this.check(hc(Lm,e))},guid(e){return this.check(lc(Nm,e))},uuid(e){return this.check(dc(fn,e))},uuidv4(e){return this.check(pc(fn,e))},uuidv6(e){return this.check(mc(fn,e))},uuidv7(e){return this.check(fc(fn,e))},nanoid(e){return this.check(yc(Dm,e))},cuid(e){return this.check(bc(Bm,e))},cuid2(e){return this.check(xc(Um,e))},ulid(e){return this.check(Sc(Zm,e))},base64(e){return this.check(Rc(Km,e))},base64url(e){return this.check(Ac(Wm,e))},xid(e){return this.check(_c(Fm,e))},ksuid(e){return this.check(vc(Hm,e))},ipv4(e){return this.check(Tc(jm,e))},ipv6(e){return this.check(Cc(Vm,e))},cidrv4(e){return this.check(kc(qm,e))},cidrv6(e){return this.check(Ec(Gm,e))},e164(e){return this.check(Ic(Jm,e))},datetime(e){return this.check(Pc(wm,e))},date(e){return this.check(Mc(Pm,e))},time(e){return this.check(Oc(Mm,e))},duration(e){return this.check(zc(Om,e))}});function d(e){return cc(Im,e)}var F=h("ZodStringFormat",(e,t)=>{U.init(e,t),Uu.init(e,t)}),wm=h("ZodISODateTime",(e,t)=>{ma.init(e,t),F.init(e,t)}),Pm=h("ZodISODate",(e,t)=>{fa.init(e,t),F.init(e,t)}),Mm=h("ZodISOTime",(e,t)=>{ga.init(e,t),F.init(e,t)}),Om=h("ZodISODuration",(e,t)=>{ha.init(e,t),F.init(e,t)}),zm=h("ZodEmail",(e,t)=>{na.init(e,t),F.init(e,t)});var Nm=h("ZodGUID",(e,t)=>{ea.init(e,t),F.init(e,t)});var fn=h("ZodUUID",(e,t)=>{ta.init(e,t),F.init(e,t)});var $m=h("ZodURL",(e,t)=>{ia.init(e,t),F.init(e,t)});var Lm=h("ZodEmoji",(e,t)=>{sa.init(e,t),F.init(e,t)});var Dm=h("ZodNanoID",(e,t)=>{aa.init(e,t),F.init(e,t)});var Bm=h("ZodCUID",(e,t)=>{ca.init(e,t),F.init(e,t)});var Um=h("ZodCUID2",(e,t)=>{ua.init(e,t),F.init(e,t)});var Zm=h("ZodULID",(e,t)=>{la.init(e,t),F.init(e,t)});var Fm=h("ZodXID",(e,t)=>{da.init(e,t),F.init(e,t)});var Hm=h("ZodKSUID",(e,t)=>{pa.init(e,t),F.init(e,t)});var jm=h("ZodIPv4",(e,t)=>{ya.init(e,t),F.init(e,t)});var Vm=h("ZodIPv6",(e,t)=>{xa.init(e,t),F.init(e,t)});var qm=h("ZodCIDRv4",(e,t)=>{Sa.init(e,t),F.init(e,t)});var Gm=h("ZodCIDRv6",(e,t)=>{_a.init(e,t),F.init(e,t)});var Km=h("ZodBase64",(e,t)=>{Ta.init(e,t),F.init(e,t)});var Wm=h("ZodBase64URL",(e,t)=>{Ca.init(e,t),F.init(e,t)});var Jm=h("ZodE164",(e,t)=>{ka.init(e,t),F.init(e,t)});var Ym=h("ZodJWT",(e,t)=>{Ea.init(e,t),F.init(e,t)});var Zu=h("ZodNumber",(e,t)=>{lr.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,r,o)=>zr(e,n,r,o),e.isFinite=!0},Hn({minValue:(e)=>{let{minimum:t,exclusiveMinimum:n}=W(e);return Math.max(t??Number.NEGATIVE_INFINITY,n??Number.NEGATIVE_INFINITY)},maxValue:(e)=>{let{maximum:t,exclusiveMaximum:n}=W(e);return Math.min(t??Number.POSITIVE_INFINITY,n??Number.POSITIVE_INFINITY)},isInt:(e)=>{let{isInt:t,multipleOf:n}=W(e);return!!t||!!n?.some(Number.isSafeInteger)},format:(e)=>W(e).format??null},{gt(e,t){return this.check(an(e,t))},gte(e,t){return this.check(He(e,t))},min(e,t){return this.check(He(e,t))},lt(e,t){return this.check(sn(e,t))},lte(e,t){return this.check(Fe(e,t))},max(e,t){return this.check(Fe(e,t))},int(e){return this.check(Nu(e))},safe(e){return this.check(Nu(e))},positive(e){return this.check(an(0,e))},nonnegative(e){return this.check(He(0,e))},negative(e){return this.check(sn(0,e))},nonpositive(e){return this.check(Fe(0,e))},multipleOf(e,t){return this.check(cn(e,t))},step(e,t){return this.check(cn(e,t))},finite(){return this}}));function x(e){return Nc(Zu,e)}var Xm=h("ZodNumberFormat",(e,t)=>{Ra.init(e,t),Zu.init(e,t)});function Nu(e){return $c(Xm,e)}var Qm=h("ZodBoolean",(e,t)=>{Aa.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Nr(e,n,r,o)});function w(e){return Lc(Qm,e)}var ef=h("ZodUnknown",(e,t)=>{Ia.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Dr(e,n,r,o)});function K(){return Dc(ef)}var tf=h("ZodNever",(e,t)=>{wa.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Lr(e,n,r,o)});function nf(e){return Bc(tf,e)}var rf=h("ZodVoid",(e,t)=>{Pa.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,r,o)=>$r(e,n,r,o)});function of(e){return Uc(rf,e)}var sf=h("ZodDate",(e,t)=>{Ma.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Br(e,n,r,o),e.min=(n,r)=>e.check(He(n,r)),e.max=(n,r)=>e.check(Fe(n,r))},Hn({minDate:(e)=>{let{minimum:t}=W(e);return t?new Date(t):null},maxDate:(e)=>{let{maximum:t}=W(e);return t?new Date(t):null}},{}));function gn(e){return Zc(sf,e)}var af=h("ZodArray",(e,t)=>{It(),Oa.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Vr(e,n,r,o),e.element=t.element},{min(e,t){return this.check(je(e,t))},nonempty(e){return this.check(je(1,e))},max(e,t){return this.check(un(e,t))},length(e,t){return this.check(ln(e,t))},unwrap(){return this.element}});function E(e,t){return Fc(af,e,t)}var cf=h("ZodObject",(e,t)=>{It(),$a.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,r,o)=>qr(e,n,r,o),Mp(e,"shape",(n)=>n._zod.def.shape,!1)},{keyof(){return I(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(ne(this._zod.def,{catchall:e}))},passthrough(){return this.clone(ne(this._zod.def,{catchall:K()}))},loose(){return this.clone(ne(this._zod.def,{catchall:K()}))},strict(){return this.clone(ne(this._zod.def,{catchall:nf()}))},strip(){return this.clone(ne(this._zod.def,{catchall:void 0}))},extend(e){return Cp(this,e)},safeExtend(e){return kp(this,e)},merge(e){return Ep(this,e)},pick(e){return vp(this,e)},omit(e){return Tp(this,e)},partial(...e){return Oi(co,this,e[0])},exactPartial(...e){return Oi(ju,this,e[0],"exactPartial")},required(...e){return Rp(Vu,this,e[0])}});function b(e,t){let n={type:"object",shape:e??{},..._(t)};return new cf(n)}var Fu=h("ZodUnion",(e,t)=>{dr.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Gr(e,n,r,o),e.options=t.options});function Ge(e,t){return new Fu({type:"union",options:e,..._(t)})}var uf=h("ZodDiscriminatedUnion",(e,t)=>{Fu.init(e,t),La.init(e,t)});function ao(e,t,n){return new uf({type:"union",options:t,discriminator:e,..._(n)})}var lf=h("ZodIntersection",(e,t)=>{Da.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Kr(e,n,r,o)});function df(e,t){return new lf({type:"intersection",left:e,right:t})}var pf=h("ZodTuple",(e,t)=>{It(),pr.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Wr(e,n,r,o)},{rest(e){return this.clone({...this._zod.def,rest:e})},partial(){let e=this._zod.def;if(e.checks?.length)throw Error(".partial() cannot be used on tuple schemas containing refinements");return this.clone({...e,items:e.items.map((t)=>new co({type:"optional",innerType:t}))})}});function mf(e,t,n){let r=t instanceof z,o=r?n:t;return new pf({type:"tuple",items:e,rest:r?t:null,..._(o)})}var $u=h("ZodRecord",(e,t)=>{It(),Ba.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Jr(e,n,r,o),e.keyType=t.keyType,e.valueType=t.valueType});function j(e,t,n){if(!t||!t._zod)return new $u({type:"record",keyType:d(),valueType:e,..._(t)});return new $u({type:"record",keyType:e,valueType:t,..._(n)})}var so=h("ZodEnum",(e,t)=>{Ua.init(e,t),N.init(e,t),e._zod.processJSONSchema=(r,o,i)=>Ur(e,r,o,i),e.enum=t.entries,e.options=[...e._zod.values];let n=new Set(Object.keys(t.entries));e.extract=(r,o)=>{let i={};for(let s of r)if(n.has(s))i[s]=t.entries[s];else throw Error(`Key ${s} not found in enum`);return new so({...t,checks:[],..._(o),entries:i})},e.exclude=(r,o)=>{let i={...t.entries};for(let s of r)if(n.has(s))delete i[s];else throw Error(`Key ${s} not found in enum`);return new so({...t,checks:[],..._(o),entries:i})}});function I(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map((r)=>[r,r])):e;return new so({type:"enum",entries:n,..._(t)})}var ff=h("ZodLiteral",(e,t)=>{Za.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Zr(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 V(e,t){return new ff({type:"literal",values:Array.isArray(e)?e:[e],..._(t)})}var gf=h("ZodTransform",(e,t)=>{It(),Fa.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,r,o)=>jr(e,n,r,o),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new ht(e.constructor.name);n.addIssue=(i)=>{if(typeof i==="string")n.issues.push(Ne(i,n.value,t));else{let s=i;if(s.fatal)s.continue=!1;if(s.code??(s.code="custom"),!("input"in s))s.input=n.value;s.inst??(s.inst=e),n.issues.push(Ne(s))}};let o=t.transform(n.value,n);if(o instanceof Promise)return o.then((i)=>(n.value=i,n));return n.value=o,n}});function Hu(e){return new gf({type:"transform",transform:e})}var co=h("ZodOptional",(e,t)=>{mr.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,r,o)=>dn(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Lu(e){return new co({type:"optional",innerType:e})}var ju=h("ZodExactOptional",(e,t)=>{Ha.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,r,o)=>dn(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function hf(e){return new ju({type:"optional",innerType:e})}var yf=h("ZodNullable",(e,t)=>{ja.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Yr(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Du(e){return new yf({type:"nullable",innerType:e})}var bf=h("ZodDefault",(e,t)=>{Va.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,r,o)=>eo(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function xf(e,t){return new bf({type:"default",innerType:e,get defaultValue(){return typeof t==="function"?t():Bn(t)}})}var Sf=h("ZodPrefault",(e,t)=>{qa.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,r,o)=>to(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function _f(e,t){return new Sf({type:"prefault",innerType:e,get defaultValue(){return typeof t==="function"?t():Bn(t)}})}var Vu=h("ZodNonOptional",(e,t)=>{Ga.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Xr(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function vf(e,t){return new Vu({type:"nonoptional",innerType:e,..._(t)})}var Tf=h("ZodCatch",(e,t)=>{Ka.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,r,o)=>no(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Cf(e,t){return new Tf({type:"catch",innerType:e,catchValue:typeof t==="function"?t:Li(t)})}var qu=h("ZodPipe",(e,t)=>{fr.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ro(e,n,r,o),e.in=t.in,e.out=t.out});function Bu(e,t){return new qu({type:"pipe",in:e,out:t})}var kf=h("ZodPreprocess",(e,t)=>{qu.init(e,t),Wa.init(e,t)}),Ef=h("ZodReadonly",(e,t)=>{Ja.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,r,o)=>oo(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Rf(e){return new Ef({type:"readonly",innerType:e})}var Af=h("ZodPromise",(e,t)=>{Xa.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,r,o)=>io(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function uo(e){return new Af({type:"promise",innerType:e})}var If=h("ZodFunction",(e,t)=>{Ya.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Hr(e,n,r,o)});function hn(e){return new If({type:"function",input:Array.isArray(e?.input)?mf(e?.input):e?.input??E(K()),output:e?.output??K()})}var Gu=h("ZodCustom",(e,t)=>{Qa.init(e,t),N.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Fr(e,n,r,o)});function se(e,t){return Hc(Gu,e??(()=>!0),t)}function wf(e,t={}){return jc(Gu,e,t)}function Pf(e,t){return Vc(e,t)}function Ku(e,t){return new kf({type:"pipe",in:Hu(e),out:t})}var yn=["none","minimal","low","medium","high","xhigh","max"],lo=I(yn),bn=lo.exclude(["none"]),Mf=I([...yn,"default"]).nullable(),po=ao("type",[b({type:V("toggle")}).strict(),b({type:V("effort"),values:E(Mf)}).strict(),b({type:V("budget_tokens"),min:x().min(-1).optional(),max:x().min(0).optional()}).strict().refine((e)=>e.min===void 0||e.max===void 0||e.min<=e.max,{message:"Minimum reasoning budget cannot exceed maximum",path:["min"]})]);var Wu=I(["default","openai-responses","r1"]),Of={DEFAULT:"default",OPENAI_RESPONSES:"openai-responses",R1:"r1"},Ju=I(["images","video","tools","streaming","prompt-cache","reasoning","reasoning-effort","computer-use","global-endpoint","structured_output","temperature","files"]),Yu=I(["active","preview","deprecated","legacy"]),Xu=b({input:x().optional(),output:x().optional(),cacheWrite:x().optional(),cacheRead:x().optional()}),Qu=b({maxBudget:x().optional(),outputPrice:x().optional(),thinkingLevel:I(["low","high"]).optional()}),el=b({reasoningDefaultOn:w().optional(),apiProtocol:I(["openai-chat","openai-responses","anthropic","gemini"]).optional()}).catchall(K()),mo=I(["text","image","audio","video","pdf"]),tl=b({input:E(mo),output:E(mo)});function nl(e){return(e?.input===void 0||e.input.includes("text"))&&(e?.output===void 0||e.output.includes("text"))}var rl=I(["language","image-generation","speech-generation","video-generation","transcription","realtime"]);function zf(e){let t=e.modalities?.input,n=e.modalities?.output;return t?.length===1&&t[0]==="audio"&&n?.length===1&&n[0]==="text"}function Nf(e){return(e.operation===void 0||e.operation==="language")&&nl(e.modalities)}var ol=I(["batch","streaming"]);function $f(e){return e.modalities?.input.includes("text")===!0&&e.modalities.output.includes("image")}function Lf(e){return e.operation==="image-generation"}function fo(e,t,n){let r=e.capabilities;if(r===void 0||r.length===0)return n?.assumeWhenUnspecified??!1;return r.includes(t)}function Df(e){return fo(e,"tools",{assumeWhenUnspecified:!0})}function Bf(e){return fo(e,"images",{assumeWhenUnspecified:!0})}var xn=b({id:d(),name:d().optional(),description:d().optional(),maxTokens:x().optional(),contextWindow:x().optional(),maxInputTokens:x().optional(),capabilities:E(Ju).optional(),operation:rl.optional(),operationModes:E(ol).optional(),modalities:tl.optional(),reasoningOptions:E(po).optional(),apiFormat:Wu.optional(),systemRole:I(["system","developer"]).optional(),temperature:x().optional(),pricing:Xu.optional(),thinkingConfig:Qu.optional(),status:Yu.optional(),deprecationNotice:d().optional(),replacedBy:d().optional(),releaseDate:d().optional(),deprecationDate:d().optional(),family:d().optional(),metadata:el.optional()});var Uf="This tool call was rejected by the user and not executed.",Zf="NOT a tool or system failure. Clarify with user before proceeding.",go=b({id:d(),name:d(),execution:I(["client","provider"]).optional(),input:K(),output:K(),error:d().optional(),durationMs:x(),startedAt:gn(),endedAt:gn()});var Ff=I(["completed","max_iterations","aborted","mistake_limit","error"]),Hf=b({inputTokens:x(),outputTokens:x(),cacheReadTokens:x().optional(),cacheWriteTokens:x().optional(),totalCost:x().optional()}),dv=b({text:d(),usage:Hf,messages:E(se()),toolCalls:E(go),iterations:x(),finishReason:Ff,model:b({id:d(),provider:d(),info:xn.optional()}),startedAt:gn(),endedAt:gn(),durationMs:x()}),pv=b({distinctId:d().optional(),sessionId:d().optional(),providerId:d(),modelId:d(),apiKey:d().optional(),baseUrl:d().url().optional(),headers:j(d(),d()).optional(),knownModels:j(d(),xn).optional(),providerConfig:K().optional(),initialMessages:E(se()).optional(),systemPrompt:d(),tools:E(se()),modelTools:E(se()).optional(),maxIterations:x().positive().optional(),maxParallelToolCalls:x().int().positive().default(8),maxTokensPerTurn:x().positive().optional(),temperature:x().nonnegative().optional(),apiTimeoutMs:x().positive().default(180000),userFileContentLoader:hn().input([d()]).output(uo(d())).optional(),toolContextMetadata:j(d(),K()).optional(),execution:b({maxConsecutiveMistakes:x().int().positive().optional(),reminderAfterIterations:x().nonnegative().optional(),reminderText:d().optional(),loopDetection:Ge([V(!1),b({softThreshold:x().int().positive().optional(),hardThreshold:x().int().positive().optional()})]).optional()}).optional(),reasoningEffort:bn.optional(),thinkingBudgetTokens:x().positive().optional(),thinking:w().optional(),onEvent:hn().input([se()]).output(of()).optional(),hooks:se().optional(),parentAgentId:d().optional(),extensions:E(se()).optional(),hookErrorMode:I(["ignore","throw"]).default("ignore"),toolPolicies:j(d(),b({enabled:w().optional(),autoApprove:w().optional()})).optional(),requestToolApproval:hn().input([b({sessionId:d(),agentId:d(),conversationId:d(),iteration:x(),toolCallId:d(),toolName:d(),input:K(),policy:b({enabled:w().optional(),autoApprove:w().optional()}).default({})})]).output(Ge([b({approved:w(),reason:d().optional()}),uo(b({approved:w(),reason:d().optional()}))])).optional(),onConsecutiveMistakeLimitReached:hn().input([b({iteration:x().int().positive(),consecutiveMistakes:x().int().positive(),maxConsecutiveMistakes:x().int().positive(),reason:I(["api_error","invalid_tool_call","tool_execution_failed"]),details:d().optional()})]).output(Ge([b({action:V("continue"),guidance:d().optional()}),b({action:V("stop"),reason:d().optional()}),uo(Ge([b({action:V("continue"),guidance:d().optional()}),b({action:V("stop"),reason:d().optional()})]))])).optional(),logger:se().optional(),extensionContext:se().optional(),abortSignal:se().optional()});var il=I(["connector.started","connector.stopping","session.authorize","message.received","message.denied","message.completed","message.failed","session.started","session.reused","session.reset","schedule.delivery.started","schedule.delivery.sent","schedule.delivery.failed"]),sl=b({id:d().optional(),label:d().optional(),role:d().optional(),participantKey:d().optional(),participantLabel:d().optional(),platformUserId:d().optional(),metadata:j(d(),K()).optional()}),al=b({source:d(),sourceEvent:d(),threadId:d(),channelId:d(),isDM:w(),sessionId:d().optional(),workspaceRoot:d().optional(),metadata:j(d(),K()).optional()}),jf=b({actor:sl,context:al,payload:j(d(),K()).optional()}),Vf=b({action:I(["allow","deny"]).default("allow"),message:d().optional(),reason:d().optional(),metadata:j(d(),K()).optional()}),qf=b({adapter:d(),botUserName:d().optional(),event:il,payload:j(d(),K()),ts:d()});var cl=[{name:"discord",description:"Discord interactions and gateway bridge backed by RPC runtime sessions"},{name:"gchat",description:"Google Chat webhook bridge backed by RPC runtime sessions"},{name:"linear",description:"Linear webhook bridge backed by RPC runtime sessions"},{name:"slack",description:"Slack webhook/socket bridge backed by RPC runtime sessions"},{name:"telegram",description:"Bridge Telegram bot messages into RPC chat sessions"},{name:"whatsapp",description:"Bridge WhatsApp webhook messages into RPC chat sessions"}];function ul(){return cl.map((e)=>({...e}))}function ll(e,t){let n=e.includeWhen;if(!n)return!0;let r=t[n.flag]??"";if(n.equals!==void 0&&r!==n.equals)return!1;if(n.notEquals!==void 0&&r===n.notEquals)return!1;return!0}function Gf(e,t,n){let r={};for(let i of e.fields){let s=t[i.flag];r[i.flag]=typeof s==="string"?s.trim():i.initialValue??""}let o=[];for(let i of e.fields){if(!ll(i,r))continue;let s=r[i.flag]??"";if(!s){if(i.required)throw Error(`${i.label} is required`);continue}o.push(i.flag,s)}if(n?.enabled===!0&&e.security){let i={};for(let s of e.security.fields){let a=n.values[s.key]?.trim();if(!a)throw Error(s.requiredMessage);let c=s.validate?.(a);if(c)throw Error(c);i[s.key]=a}o.push(...e.security.buildArgs(i))}return o}function Kf(e,t){if(t.has(e))return{managed:!0,consumesNext:!0};for(let n of t)if(e.startsWith(`${n}=`))return{managed:!0,consumesNext:!1};return{managed:!1,consumesNext:!1}}function Wf(e,t,n,r){let o=new Set([...e.fields.flatMap((s)=>[s.flag,...s.aliases??[]]),...e.derivedReconnectFlags??[]]);if(r.replaceSecurityArgs)for(let s of e.security?.argumentFlags??[])o.add(s);let i=[];for(let s=0;s<t.length;s+=1){let a=t[s]??"",c=Kf(a,o);if(!c.managed){i.push(a);continue}if(c.consumesNext)s+=1}return[...i,...n]}function Jf(e=dl){let t=new Set(ul().map((n)=>n.name));return e.filter((n)=>t.has(n.id)).map((n)=>({id:n.id,name:n.name,type:n.type,hint:n.hint,fields:n.fields.map((r)=>({flag:r.flag,label:r.label,placeholder:r.placeholder,required:r.required,help:r.help,initialValue:r.initialValue,options:r.options,includeWhen:r.includeWhen})),security:n.security?{prompt:n.security.prompt,fields:n.security.fields.map((r)=>({key:r.key,label:r.label,placeholder:r.placeholder,help:r.help,requiredMessage:r.requiredMessage}))}:void 0}))}function Yf(e){return/^\d+$/.test(e)?void 0:"Telegram user ID must contain digits only"}function Xf(e){return/^T[A-Z0-9]+$/.test(e)?void 0:"Slack workspace ID must start with T and contain uppercase letters or digits only"}function Qf(e){return/^[UW][A-Z0-9]+$/.test(e)?void 0:"Slack member ID must start with U or W and contain uppercase letters or digits only"}var dl=[{id:"telegram",name:"Telegram",type:"polling",hint:"Easiest to set up. No public URL needed.",derivedReconnectFlags:["-m","--bot-username"],fields:[{flag:"-k",aliases:["--bot-token"],label:"Bot token",placeholder:"7123456789:AAH...",required:!0,help:["Open Telegram and start a chat with @BotFather","Send /newbot and follow the prompts","BotFather gives you this after creating the bot","It looks like 7123456789:AAHxxx..."]}],security:{prompt:"By default, anyone who finds your bot can message it and run tasks on your machine. Restrict access to your Telegram user ID?",fields:[{key:"userId",label:"Your Telegram user ID",placeholder:"123456789",help:["Message @userinfobot on Telegram","It will reply with your numeric user ID"],requiredMessage:"User ID is required to restrict access",validate:Yf}],argumentFlags:["--allowed-user-id","--hook-command"],buildArgs:({userId:e})=>["--allowed-user-id",e??""]}},{id:"slack",name:"Slack",type:"hybrid",hint:"Public URL for webhook mode; leave blank for socket mode.",fields:[{flag:"--bot-token",label:"Bot token",placeholder:"xoxb-...",required:!0,help:["Go to api.slack.com/apps and create a new app","Add Bot Token Scopes: chat:write, app_mentions:read, channels:history, channels:read, im:history, im:read, im:write, users:read","Install to workspace and copy the Bot Token"]},{flag:"--base-url",label:"Public base URL",placeholder:"leave blank for socket mode",help:["Enter a publicly accessible URL for webhook mode","Leave blank to use Slack socket mode instead"]},{flag:"--signing-secret",label:"Signing secret",required:!0,help:["Found in your app's Basic Information page"],includeWhen:{flag:"--base-url",notEquals:""}},{flag:"--app-token",label:"App-level token",placeholder:"xapp-...",required:!0,help:["Enable Socket Mode in the Slack app","Generate an app-level token with the connections:write scope"],includeWhen:{flag:"--base-url",equals:""}}],security:{prompt:"Restrict which Slack users can interact with the bot?",fields:[{key:"teamId",label:"Allowed Slack workspace ID",placeholder:"T01ABC123",help:["Open your Slack workspace URL in a browser","The workspace ID is the segment after /client/, for example T01ABC123"],requiredMessage:"Workspace ID is required to restrict access",validate:Xf},{key:"userId",label:"Allowed Slack member ID",placeholder:"U01ABC123",help:["Click a user's name in Slack, then View full profile","Click ... and Copy member ID"],requiredMessage:"Member ID is required to restrict access",validate:Qf}],argumentFlags:["--hook-command"],buildArgs:({teamId:e,userId:t})=>["--hook-command",`jq -r ".payload.actor.participantKey" | grep -qx "slack:team:${e}:user:${t}" && echo '{"action":"allow"}' || echo '{"action":"deny"}'`]}},{id:"discord",name:"Discord",type:"webhook",hint:"Requires a Discord app and public URL.",fields:[{flag:"--application-id",aliases:["--app-id"],label:"Application ID",required:!0,help:["Go to discord.com/developers/applications","Create a new app, copy the Application ID"]},{flag:"--bot-token",aliases:["--token"],label:"Bot token",required:!0,help:["Go to Bot section, create a bot, copy the token"]},{flag:"--public-key",label:"Public key",required:!0,help:["Found in General Information of your app"]},{flag:"--base-url",label:"Public base URL",placeholder:"https://example.com",required:!0,help:["Base URL for the connector","For Discord, set the Interactions Endpoint URL to <base-url>/api/webhooks/discord"]}]},{id:"whatsapp",name:"WhatsApp",type:"webhook",hint:"Requires Meta developer account and public URL.",fields:[{flag:"--phone-number-id",label:"Phone number ID",required:!0,help:["From your WhatsApp Business account in Meta Developer portal"]},{flag:"--access-token",label:"Access token",required:!0,help:["Generate a permanent token in Meta Developer portal"]},{flag:"--app-secret",label:"App secret",required:!0,help:["Found in App Settings > Basic"]},{flag:"--verify-token",label:"Webhook verify token",placeholder:"my-verify-token",required:!0,help:["Any string you choose, used to verify webhook setup"]},{flag:"--base-url",label:"Public base URL",placeholder:"https://example.com",required:!0}]},{id:"gchat",name:"Google Chat",type:"webhook",hint:"Requires Google Cloud project and public URL.",fields:[{flag:"--credentials-json",label:"Service account credentials JSON",required:!0,help:["Create a service account in Google Cloud Console","Download the credentials JSON file","Paste the JSON content here"]},{flag:"--base-url",label:"Public base URL",placeholder:"https://example.com",required:!0}]},{id:"linear",name:"Linear",type:"webhook",hint:"React to Linear issues and comments.",fields:[{flag:"--api-key",label:"API key",required:!0,help:["Go to Linear Settings > API > Personal API keys"]},{flag:"--webhook-secret",label:"Webhook signing secret",required:!0,help:["Go to Settings > API > Webhooks, create one","Copy the signing secret"]},{flag:"--base-url",label:"Public base URL",placeholder:"https://example.com",required:!0}]}];var pl=[];function ho(e){pl.push(e)}async function eg(){let e=pl.splice(0);await Promise.all(e.map((t)=>{try{return(typeof t==="function"?t():t.dispose())??Promise.resolve()}catch{return Promise.resolve()}}))}var tg=["hooks","tools","commands","rules","skills","messageBuilders","providers","automationEvents","mcp"],ng=new Set(tg);function gl(e,t){return e.name||`extension_${String(t).padStart(4,"0")}`}function ml(e){return Array.isArray(e)&&e.every((t)=>typeof t==="string")}function fl(e){if(!Array.isArray(e))return;let t=e.filter((n)=>typeof n==="string").map((n)=>n.trim()).filter((n)=>n.length>0);return t.length>0?t:void 0}function hl(e){let t=fl(e.providerIds),n=fl(e.modelIds);return{...e,...t?{providerIds:t}:{},...n?{modelIds:n}:{}}}function rg(e,t){let n=gl(e,t),r=e.manifest;if(!r||typeof r!=="object")throw Error(`Invalid manifest for extension "${n}": manifest is required`);if(!Array.isArray(r.capabilities)||r.capabilities.length===0)throw Error(`Invalid manifest for extension "${n}": capabilities must be a non-empty array`);let o=new Set;for(let a of r.capabilities){if(!ng.has(a))throw Error(`Invalid manifest for extension "${n}": unsupported capability "${String(a)}"`);o.add(a)}if(Object.hasOwn(r,"providerIds")&&!ml(r.providerIds))throw Error(`Invalid manifest for extension "${n}": providerIds must be a string array when provided`);if(Object.hasOwn(r,"modelIds")&&!ml(r.modelIds))throw Error(`Invalid manifest for extension "${n}": modelIds must be a string array when provided`);let i=o.has("hooks");if(e.hooks!==void 0&&!i)throw Error(`Invalid manifest for extension "${n}": runtime hooks require the "hooks" capability`);return{capabilities:o,raw:hl(r)}}function og(e,t){if(!e||typeof e!=="object")throw Error(`Invalid automation event contribution for extension "${t}": expected object`);let n=typeof e.eventType==="string"?e.eventType.trim():"",r=typeof e.source==="string"?e.source.trim():"";if(!n)throw Error(`Invalid automation event contribution for extension "${t}": eventType is required`);if(!r)throw Error(`Invalid automation event contribution for extension "${t}": source is required`);return{...e,eventType:n,source:r,examples:e.examples?[...e.examples]:void 0,metadata:e.metadata?{...e.metadata}:void 0}}class yo{extensions;registry={tools:[],commands:[],rules:[],messageBuilder:[],providers:[],automationEventTypes:[],mcpServers:[]};normalized=[];phase="resolve";setupContext;constructor(e={}){this.extensions=e.extensions??[],this.setupContext=e.setupContext??{}}resolve(){if(this.phase!=="resolve")return;this.normalized=this.extensions.map((e,t)=>({extension:e,order:t,manifest:{capabilities:new Set,raw:e.manifest}})),this.phase="validate"}validate(){if(this.phase==="resolve")this.resolve();if(this.phase!=="validate")return;this.normalized=this.normalized.map((e)=>({...e,manifest:rg(e.extension,e.order)})),this.phase="setup"}async setup(e={}){if(this.phase==="resolve")this.resolve();if(this.phase==="validate")this.validate();if(this.phase!=="setup")return;let t,n=[];for(let r of this.normalized){let{extension:o}=r;if(o.disabled)continue;let i=gl(o,r.order),s={tools:[],commands:[],rules:[],messageBuilder:[],providers:[],automationEventTypes:[],mcpServers:[]},a={registerTool:(u)=>s.tools.push(u),registerCommand:(u)=>s.commands.push(u),registerRule:(u)=>{if(!r.manifest.capabilities.has("rules"))throw Error(`Invalid setup for extension "${i}": registerRule requires the "rules" capability`);s.rules.push(u)},registerMessageBuilder:(u)=>s.messageBuilder.push(u),registerProvider:(u)=>s.providers.push(u),registerAutomationEventType:(u)=>{if(!r.manifest.capabilities.has("automationEvents"))throw Error(`Invalid setup for extension "${i}": registerAutomationEventType requires the "automationEvents" capability`);s.automationEventTypes.push(og(u,i))},registerMcpServer:(u)=>{if(!r.manifest.capabilities.has("mcp"))throw Error(`Invalid setup for extension "${i}": registerMcpServer requires the "mcp" capability`);s.mcpServers.push({...u,metadata:{...u.metadata??{},source:"plugin",plugin:i}})}},c=r.manifest.capabilities.has("automationEvents")?this.setupContext:{...this.setupContext,automation:void 0};try{await o.setup?.(a,c),n.push(s)}catch(u){if(e.tolerateSetupErrors!==!0)throw u;t??=u}}if(t&&e.tolerateSetupErrors!==!0)throw t;for(let r of n)this.registry.tools.push(...r.tools),this.registry.commands.push(...r.commands),this.registry.rules.push(...r.rules),this.registry.messageBuilder.push(...r.messageBuilder),this.registry.providers.push(...r.providers),this.registry.automationEventTypes.push(...r.automationEventTypes),this.registry.mcpServers.push(...r.mcpServers);if(this.phase="activate",t)throw t}activate(){if(this.phase==="resolve")this.resolve();if(this.phase==="validate")this.validate();if(this.phase==="setup")throw Error("Contribution registry setup must complete before activation");if(this.phase!=="activate")return;this.phase="run"}async initialize(e={}){this.resolve(),this.validate();try{await this.setup(e)}finally{if(this.phase==="activate")this.activate()}}isActivated(){return this.phase==="run"}getRegistrySnapshot(){return{tools:[...this.registry.tools],commands:[...this.registry.commands],rules:[...this.registry.rules],messageBuilder:[...this.registry.messageBuilder],providers:[...this.registry.providers],automationEventTypes:[...this.registry.automationEventTypes],mcpServers:[...this.registry.mcpServers]}}getRegisteredTools(){return[...this.registry.tools]}getRegisteredRules(){return[...this.registry.rules]}getRegisteredAutomationEventTypes(){return[...this.registry.automationEventTypes]}getRegisteredMcpServers(){return[...this.registry.mcpServers]}getValidatedExtensions(){if(this.phase==="resolve")this.resolve();if(this.phase==="validate")this.validate();return this.normalized.slice().sort((e,t)=>e.order-t.order).map(({extension:e})=>e)}}function ig(e={}){return new yo(e)}var sg=[".js",".ts"];var Ke={CLINE_PASS:"ext-cline-pass",CODE_CLOUD_AGENTS:"code-cloud-agents",CODE_ONBOARDING_GITHUB:"code-onboarding-github",CLINE_COMPOSIO_BETA:"CLINE_COMPOSIO_BETA"},ag={[Ke.CLINE_PASS]:!1,[Ke.CODE_CLOUD_AGENTS]:!1,[Ke.CODE_ONBOARDING_GITHUB]:!1,[Ke.CLINE_COMPOSIO_BETA]:!1},cg=Object.values(Ke);var yl=I(["agent_start","agent_resume","agent_abort","agent_end","agent_error","tool_call","tool_result","prompt_submit","pre_compact","session_shutdown"]),$e=j(d(),d()),ug=b({toolName:d(),parameters:$e}),lg=b({toolName:d(),parameters:$e,result:d(),success:w(),executionTimeMs:x()}),dg=b({prompt:d(),attachments:E(d())}),pg=b({taskMetadata:$e}),mg=b({taskMetadata:$e,previousState:$e}),fg=b({taskMetadata:$e}),gg=b({taskMetadata:$e}),hg=b({taskId:d(),ulid:d(),contextSize:x(),compactionStrategy:d(),previousApiReqIndex:x(),tokensIn:x(),tokensOut:x(),tokensInCache:x(),tokensOutCache:x(),deletedRangeStart:x(),deletedRangeEnd:x(),contextJsonPath:d(),contextRawPath:d()}),bl=b({clineVersion:d(),hookName:yl,timestamp:d(),taskId:d(),sessionContext:b({rootSessionId:d().optional(),hookLogPath:d().optional()}).optional(),workspaceRoots:E(d()),workspaceInfo:se().optional(),userId:d(),agent_id:d(),parent_agent_id:d().nullable(),iteration:x().optional(),reason:d().optional(),tool_call:b({id:d(),name:d(),input:K()}).optional(),tool_result:se().optional(),turn:K().optional(),error:b({name:d(),message:d(),stack:d().optional()}).optional(),preToolUse:ug.optional(),postToolUse:lg.optional(),userPromptSubmit:dg.optional(),taskStart:pg.optional(),taskResume:mg.optional(),taskCancel:fg.optional(),taskComplete:gg.optional(),preCompact:hg.optional()}).passthrough();function yg(e){let t=bl.safeParse(e);if(!t.success)return;return t.data}var Ev="v1",Rv="v1",Av="v1",Iv=["client.register","client.list","session.create","session.list","session.get","session.run","session.abort","schedule.create","schedule.list","task.create","task.list","task.get","task.update","task.approve","task.cancel","task.run","task.automation.get","task.automation.set","settings.get","settings.set","connector.start","connector.stop","connector.supervised","run.enqueue","run.list","hub.drain","hub.status","plugins.list","plugins.status","plugins.reload","stream.replay"];function Sn(e){let t=/^v(\d+)$/.exec(e?.trim()??"");if(!t)return;return Number.parseInt(t[1]??"",10)}function wv(e,t="v1"){let n=Sn(e.protocolVersion),r=Sn(t);if(n===void 0||r===void 0)return{compatible:!1,reason:"missing_protocol"};let o=Sn(e.minClientProtocolVersion)??n,i=Sn(e.maxClientProtocolVersion)??n;return r>=o&&r<=i?{compatible:!0}:{compatible:!1,reason:"unsupported_protocol"}}var Pv="approval.respond",Mv="0",Ov="__hubScheduleRunAt",xl=["act","plan","yolo"];function bg(e){return xl.some((t)=>t===e)}function zv(e,t){if(!e||!Object.hasOwn(e,"mode"))return t;let n=e.mode;if(bg(n))return n;throw Error(`mode must be one of: ${xl.join(", ")}`)}var xg=30000,Nv=5000;function Sg(e){switch(e){case"run.start":case"session.send_input":return null;default:return xg}}function $v(e,t){return t===void 0?Sg(e):t}var _g=["readFile","search","bash","webFetch","editor","applyPatch","skills","askQuestion","submit"],vg=new Set(_g);function Lv(e){return typeof e==="string"&&vg.has(e)}var Dv="tool_executor.",Bv="custom_tool.",Uv="hook.",Zv="compaction.compact",Fv="checkpoint.create",Hv="mistake_limit.decide",jv="user_instructions.snapshot";function Vv(e){let t=e.activeSessionCount;if(typeof t!=="number"||t<=0)return"active sessions from other Cline clients";let n=`${t} active session${t===1?"":"s"}`,r=e.participantClientCount;if(typeof r!=="number"||r<=0)return n;return`${n} from ${r} connected Cline client${r===1?"":"s"}`}function bo(e,t){return`<file_content path="${e}">
58
+ Set 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)}}if(e.external)e.sharedDefsExtractedFor=e.external}function Wc(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let r of t){if(!r||typeof r!=="object")return;Wc(r);let o=Object.keys(r);if(o.length!==1||o[0]!=="type")return;let i=r.type;for(let s of Array.isArray(i)?i:[i]){if(typeof s!=="string")return;if(!n.includes(s))n.push(s)}}delete e.anyOf,e.type=n.length===1?n[0]:n}var Jc=new Set(["type","properties","required","additionalProperties"]),Gc=["oneOf","anyOf"];function Kc(e){let t=e.additionalProperties;if(t===void 0||t===!1||typeof t!=="object"||t===null)return null;return Object.keys(t).length?t:null}function wr(e){let t=[];for(let i of e){if(typeof i!=="object"||i.type!=="object")return null;for(let s in i)if(!Jc.has(s))return null;t.push(i)}let n={},r=new Set;for(let i of t){for(let s in i.properties){if(Object.prototype.hasOwnProperty.call(n,s))continue;let a=[];for(let u of t){let l=u.properties?.[s]??Kc(u);if(l===null||l===void 0)continue;if(!a.some((p)=>JSON.stringify(p)===JSON.stringify(l)))a.push(l)}let c=a.length===1?a[0]:wr(a)??{allOf:a};te(n,s,c)}for(let s of i.required??[])r.add(s)}let o={type:"object",properties:n};if(r.size)o.required=[...r];if(t.every((i)=>i.additionalProperties===!1))o.additionalProperties=!1;else{let i=[];for(let s of t){let a=Kc(s);if(a&&!i.some((c)=>JSON.stringify(c)===JSON.stringify(a)))i.push(a)}if(i.length===1)o.additionalProperties=i[0];else if(i.length>1)o.additionalProperties={allOf:i}}return o}function hm(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let o of Jc)if(o in e)return;let n=t.filter((o)=>Gc.some((i)=>Array.isArray(o[i]))),r=null;if(!n.length)r=wr(t);else{let o=n[0],i=Gc.find((c)=>Array.isArray(o[c]));if(Object.keys(o).length!==1)return;let s=t.filter((c)=>c!==o),a=o[i].map((c)=>wr([...s,c]));if(a.some((c)=>!c))return;r={[i]:a}}if(!r)return;delete e.allOf,Ct(e,r)}function Rt(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 u=c.def??c.schema,l={...u},p=c.ref;if(c.ref=null,p){r(p);let f=e.seen.get(p),g=f.schema;if(g.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"))u.allOf=u.allOf??[],u.allOf.push(g);else Ct(u,g);if(Ct(u,l),a._zod.parent===p)for(let _ in u){if(_==="$ref"||_==="allOf")continue;if(!(_ in l))delete u[_]}if(g.$ref&&f.def)for(let _ in u){if(_==="$ref"||_==="allOf")continue;if(_ in f.def&&JSON.stringify(u[_])===JSON.stringify(f.def[_]))delete u[_]}}let m=a._zod.parent;if(m&&m!==p){r(m);let f=e.seen.get(m);if(f?.schema.$ref){if(u.$ref=f.schema.$ref,f.def)for(let g in u){if(g==="$ref"||g==="allOf")continue;if(g in f.def&&JSON.stringify(u[g])===JSON.stringify(f.def[g]))delete u[g]}}}e.override({zodSchema:a,jsonSchema:u,path:c.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let a of[...e.seen.entries()].reverse())r(a[0]);if(e.target!=="openapi-3.0")for(let a of e.seen.entries())Wc(a[1].def??a[1].schema);for(let a of e.deferred)a();if(e.intersections.length){let a=new Map;for(let c of e.seen.values())for(let u of[c.schema,c.def]){let l=u?.allOf;if(!Array.isArray(l))continue;let p=a.get(l);if(p)p.push(u);else a.set(l,[u])}for(let c of e.intersections)for(let u of a.get(c)??[])hm(u)}}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)}Ct(o,n.defId?n.schema:n.def??n.schema);let i=e.metadataRegistry.get(t)?.id;if(i!==void 0&&o.id===i)delete o.id;let s=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)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;te(s,c.defId,c.def)}}if(e.external)e.sharedEmitDoneFor=e.external;if(e.external);else if(Object.keys(s).length>0)if(e.target==="draft-2020-12")o.$defs=s;else o.definitions=s;try{let a=JSON.parse(JSON.stringify(o));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:Tt(t,"input",e.processors),output:Tt(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch(a){throw Error("Error converting schema to JSON.")}}function X(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 X(r.element,n);if(r.type==="set")return X(r.valueType,n);if(r.type==="lazy")return X(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"||r.type==="catch")return X(r.innerType,n);if(r.type==="intersection")return X(r.left,n)||X(r.right,n);if(r.type==="record"||r.type==="map")return X(r.keyType,n)||X(r.valueType,n);if(r.type==="pipe"){if(e._zod.traits.has("$ZodCodec"))return!0;return X(r.in,n)||X(r.out,n)}if(r.type==="object"){for(let o in r.shape)if(X(r.shape[o],n))return!0;return!1}if(r.type==="union"){for(let o of r.options)if(X(o,n))return!0;return!1}if(r.type==="tuple"){for(let o of r.items)if(X(o,n))return!0;if(r.rest&&X(r.rest,n))return!0;return!1}return!1}var Yc=(e,t={})=>(n)=>{let r=kt({...n,processors:t});return D(e,r),Et(r,e),Rt(r,e)},Tt=(e,t,n={})=>(r)=>{let{libraryOptions:o,target:i}=r??{},s=kt({...o??{},target:i,io:t,processors:n});return D(e,s),Et(s,e),Rt(s,e)};var Ve=(e,t,n)=>{if(e[t]===void 0||n>e[t])e[t]=n},qe=(e,t,n)=>{if(e[t]===void 0||n<e[t])e[t]=n},Xc=(e,t)=>{Ve(e,"minimum",t),qe(e,"maximum",t)},ru=(e,t)=>{if(e.multipleOf??(e.multipleOf=[]),!e.multipleOf.includes(t))e.multipleOf.push(t)},ou=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},iu=(e,t)=>{e.mime=e.mime?e.mime.filter((n)=>t.includes(n)):[...t]},su=(e,t)=>{if(e.format=t,t.includes("int"))e.isInt=!0},Qc=(e,t)=>Ve(e,"minimum",t.minimum),eu=(e,t)=>qe(e,"maximum",t.maximum),tu=(e)=>(t,n)=>{su(t,n.format);let[r,o]=e[n.format];Ve(t,"minimum",r),qe(t,"maximum",o)},ym={greater_than:(e,t)=>Ve(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>qe(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>ru(e,t.value),number_format:tu(Ut),bigint_format:tu(Zn),min_length:Qc,max_length:eu,length_equals:(e,t)=>Xc(e,t.length),min_size:Qc,max_size:eu,size_equals:(e,t)=>Xc(e,t.size),string_format:(e,t)=>{if(su(e,t.format),t.pattern)ou(e,t.pattern);if(t.format==="base64"||t.format==="base64url")e.contentEncoding=t.format;if(t.local||t.precision===-1)e.laxFormat=!0},mime_type:(e,t)=>iu(e,t.mime)};function W(e){let t={},n=e._zod.def,r=e._zod.traits.has("$ZodCheck")?[e,...n.checks??[]]:n.checks??[];for(let i of r)ym[i._zod.def.check]?.(t,i._zod.def);let o=e._zod.bag;if(o.minimum!==void 0)Ve(t,"minimum",o.minimum);if(o.exclusiveMinimum!==void 0)Ve(t,"exclusiveMinimum",o.exclusiveMinimum);if(o.maximum!==void 0)qe(t,"maximum",o.maximum);if(o.exclusiveMaximum!==void 0)qe(t,"exclusiveMaximum",o.exclusiveMaximum);if(o.multipleOf!==void 0)ru(t,o.multipleOf);if(o.format!==void 0){if(t.format??(t.format=o.format),o.format.includes("int"))t.isInt=!0}if(o.mime)iu(t,o.mime);for(let i of o.patterns??[])ou(t,i);return t}var bm={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},xm=new Map([[ur,fs],[en,gs]]),au=(e)=>xm.get(e)??e,Or=(e,t,n,r)=>{let o=n;o.type="string";let{minimum:i,maximum:s,format:a,patterns:c,contentEncoding:u,laxFormat:l}=W(e);if(typeof i==="number")o.minLength=i;if(typeof s==="number")o.maxLength=s;if(a){if(o.format=bm[a]??a,o.format==="")delete o.format;if(a==="time"||l)delete o.format}if(u)o.contentEncoding=u;if(c&&c.size>0){let p=[...c].map(au);if(p.length===1)o.pattern=p[0].source;else if(p.length>1)o.allOf=[...p.map((m)=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:m.source}))]}},Nr=(e,t,n,r)=>{let o=n,{minimum:i,maximum:s,multipleOf:a,exclusiveMaximum:c,exclusiveMinimum:u,isInt:l}=W(e);o.type=l?"integer":"number";let p=typeof u==="number"&&u>=(i??Number.NEGATIVE_INFINITY),m=typeof c==="number"&&c<=(s??Number.POSITIVE_INFINITY),f=t.target==="draft-04"||t.target==="openapi-3.0";if(p)if(f)o.minimum=u,o.exclusiveMinimum=!0;else o.exclusiveMinimum=u;else if(typeof i==="number")o.minimum=i;if(m)if(f)o.maximum=c,o.exclusiveMaximum=!0;else o.exclusiveMaximum=c;else if(typeof s==="number")o.maximum=s;if(a){let g=new Set;for(let v of a)if(Number.isFinite(v)&&v!==0)g.add(Math.abs(v));else q(e,t,o,r,`A multipleOf divisor of ${v} cannot be represented in JSON Schema`);let[y,..._]=g;if(y!==void 0)o.multipleOf=y;if(_.length)o.allOf=[...o.allOf??[],..._.map((v)=>({multipleOf:v}))]}},zr=(e,t,n,r)=>{n.type="boolean"},cu=(e,t,n,r)=>{q(e,t,n,r,"BigInt cannot be represented in JSON Schema")},uu=(e,t,n,r)=>{q(e,t,n,r,"Symbols cannot be represented in JSON Schema")},lu=(e,t,n,r)=>{if(t.target==="openapi-3.0")n.type="string",n.nullable=!0,n.enum=[null];else n.type="null"},du=(e,t,n,r)=>{q(e,t,n,r,"Undefined cannot be represented in JSON Schema")},$r=(e,t,n,r)=>{q(e,t,n,r,"Void cannot be represented in JSON Schema")},Lr=(e,t,n,r)=>{n.not={}},pu=(e,t,n,r)=>{},Dr=(e,t,n,r)=>{},Br=(e,t,n,r)=>{q(e,t,n,r,"Date cannot be represented in JSON Schema")},Ur=(e,t,n,r)=>{let o=e._zod.def,i=pt(o.entries);if(i.length===0){n.not={};return}if(i.every((s)=>typeof s==="number"))n.type="number";if(i.every((s)=>typeof s==="string"))n.type="string";n.enum=i},Zr=(e,t,n,r)=>{let o=e._zod.def;if(o.values.length===0){n.not={};return}let i=[];for(let s of o.values)if(s===void 0){if(q(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof s==="bigint"){if(q(e,t,n,r,"BigInt literals cannot be represented in JSON Schema"))return;i.push(Number(s))}else i.push(s);if(i.length===0);else if(i.length===1){let s=i[0];if(n.type=s===null?"null":typeof s,t.target==="draft-04"||t.target==="openapi-3.0")n.enum=[s];else n.const=s}else{if(i.every((s)=>typeof s==="number"))n.type="number";if(i.every((s)=>typeof s==="string"))n.type="string";if(i.every((s)=>typeof s==="boolean"))n.type="boolean";if(i.every((s)=>s===null))n.type="null";n.enum=i}},mu=(e,t,n,r)=>{q(e,t,n,r,"NaN cannot be represented in JSON Schema")},fu=(e,t,n,r)=>{let o=n,i=e._zod.pattern;if(!i)throw Error("Pattern not found in template literal");o.type="string",o.pattern=i.source},gu=(e,t,n,r)=>{let o=n;o.type="string",o.format="binary",o.contentEncoding="binary";let{minimum:i,maximum:s,mime:a}=W(e);if(i!==void 0)o.minLength=i;if(s!==void 0)o.maxLength=s;if(!a)return;if(a.length===0)o.not={};else if(a.length===1)o.contentMediaType=a[0];else o.anyOf=a.map((c)=>({contentMediaType:c}))},hu=(e,t,n,r)=>{n.type="boolean"},Fr=(e,t,n,r)=>{q(e,t,n,r,"Custom types cannot be represented in JSON Schema")},Hr=(e,t,n,r)=>{q(e,t,n,r,"Function types cannot be represented in JSON Schema")},jr=(e,t,n,r)=>{q(e,t,n,r,"Transforms cannot be represented in JSON Schema")},yu=(e,t,n,r)=>{q(e,t,n,r,"Map cannot be represented in JSON Schema")},bu=(e,t,n,r)=>{q(e,t,n,r,"Set cannot be represented in JSON Schema")},Vr=(e,t,n,r)=>{let o=n,i=e._zod.def,{minimum:s,maximum:a}=W(e);if(typeof s==="number")o.minItems=s;if(typeof a==="number")o.maxItems=a;o.type="array",o.items=D(i.element,t,{...r,path:[...r.path,"items"]})};function At(e){let t=e._zod.def;if(t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform"))return At(t.out);if(t.type==="catch")return At(t.innerType);return e._zod.optin}var qr=(e,t,n,r)=>{let o=n,i=e._zod.def,s=i.shape;if(Object.getOwnPropertySymbols(s).length&&q(e,t,o,r,"Symbol keys cannot be represented in JSON Schema"))return;o.type="object",o.properties={};for(let u in s)te(o.properties,u,D(s[u],t,{...r,path:[...r.path,"properties",u]}));let c=[];for(let u of Object.keys(s)){let l=i.shape[u];if(t.io==="input"?At(l)===void 0:l._zod.optout===void 0)c.push(u)}if(c.length>0)o.required=c;if(i.catchall?._zod.def.type==="never")o.additionalProperties=!1;else if(!i.catchall){if(t.io==="output")o.additionalProperties=!1}else if(i.catchall)o.additionalProperties=D(i.catchall,t,{...r,path:[...r.path,"additionalProperties"]})},Gr=(e,t,n,r)=>{let o=e._zod.def,i=o.inclusive===!1,s=o.options.map((a,c)=>D(a,t,{...r,path:[...r.path,i?"oneOf":"anyOf",c]}));if(i)n.oneOf=s;else n.anyOf=s},Kr=(e,t,n,r)=>{let o=e._zod.def,i=D(o.left,t,{...r,path:[...r.path,"allOf",0]}),s=D(o.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]];n.allOf=c,t.intersections.push(c)},Wr=(e,t,n,r)=>{let o=n,i=e._zod.def;o.type="array";let s=t.target==="draft-2020-12"?"prefixItems":"items",a=t.target==="draft-2020-12"?"items":t.target==="openapi-3.0"?"items":"additionalItems",c=i.items.map((y,_)=>D(y,t,{...r,path:[...r.path,s,_]})),u=i.rest?D(i.rest,t,{...r,path:[...r.path,a,...t.target==="openapi-3.0"?[i.items.length]:[]]}):null,l=i.items.length;while(l>0){let y=i.items[l-1];if(!(t.io==="input"?At(y)!==void 0:y._zod.optout==="optional"))break;l--}let p=i.items.length,m=!i.rest;if(t.target==="draft-2020-12"){if(o.prefixItems=c,m)o.items=!1;else if(u)o.items=u;if(l>0)o.minItems=l;if(m)o.maxItems=p}else if(t.target==="openapi-3.0"){if(o.items={anyOf:c},u)o.items.anyOf.push(u);if(l>0)o.minItems=l;if(m)o.maxItems=p}else{if(o.items=c,m)o.additionalItems=!1;else if(u)o.additionalItems=u;if(l>0)o.minItems=l;if(m)o.maxItems=p}let{minimum:f,maximum:g}=W(e);if(typeof f==="number")o.minItems=f;if(typeof g==="number")o.maxItems=g};function Pr(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);let g=e.get(t)?.def;if(!g)return t;let y=Pr(e,g,n);return y===g?t:y}for(let g of["anyOf","oneOf"]){let y=t[g];if(!Array.isArray(y))continue;let _=y.map((v)=>Pr(e,v,n));if(_.some((v,k)=>v!==y[k]))t={...t,[g]:_}}let r=Array.isArray(t.type)?t.type:[t.type],o=!r.includes("string")&&r.some((g)=>g==="number"||g==="integer"),i=t.enum??(t.const!==void 0?[t.const]:void 0);if(!o&&!i?.some((g)=>typeof g==="number"))return t;let{minimum:s,maximum:a,exclusiveMinimum:c,exclusiveMaximum:u,multipleOf:l,format:p,id:m,...f}=t;if(f.enum)f.enum=f.enum.map((g)=>typeof g==="number"?String(g):g);else if(typeof f.const==="number")f.const=String(f.const);if(!o)return f;if(f.type="string",!i)f.pattern=(r.includes("number")?xt:nr).source;return f}var Mr=new WeakMap;function _m(e){let t=new Map;for(let r of e.seen.values())if(r.def&&!t.has(r.schema))t.set(r.schema,r);let n=new Map;for(let r of Mr.get(e)??[]){let o=e.seen.get(r),i=(o?.def??o?.schema)?.propertyNames;if(!i||i===!0||n.has(i))continue;let s=Pr(t,i,new Set);if(s!==i)n.set(i,s)}if(!n.size)return;for(let r of e.seen.values())for(let o of[r.schema,r.def]){let i=o&&n.get(o.propertyNames);if(i)o.propertyNames=i}}var Jr=(e,t,n,r)=>{let o=n,i=e._zod.def;o.type="object";let s=i.keyType,a=W(s).patterns;if(i.mode==="loose"&&a&&a.size>0){let l=D(i.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});o.patternProperties={};for(let p of a)te(o.patternProperties,au(p).source,l)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){o.propertyNames=D(i.keyType,t,{...r,path:[...r.path,"propertyNames"]});let l=Mr.get(t);if(!l)l=[],Mr.set(t,l),t.deferred.push(()=>_m(t));l.push(e)}o.additionalProperties=D(i.valueType,t,{...r,path:[...r.path,"additionalProperties"]})}let c=s._zod.values,u=t.io==="input"&&At(i.valueType)!==void 0;if(c&&!i.partial&&!u){let l=[...c].filter((p)=>typeof p==="string"||typeof p==="number");if(l.length>0)o.required=l.map(String)}},Yr=(e,t,n,r)=>{let o=e._zod.def,i=D(o.innerType,t,r),s=t.seen.get(e);if(t.target==="openapi-3.0")s.ref=o.innerType,n.nullable=!0;else n.anyOf=[i,{type:"null"}]},Xr=(e,t,n,r)=>{let o=e._zod.def;D(o.innerType,t,r);let i=t.seen.get(e);i.ref=o.innerType},Qr=Symbol();function xu(e,t,n,r,o){let i=!1,s=JSON.stringify(e,(a,c)=>{if(typeof c!=="bigint")return c;return i=!0,null});if(!i)return JSON.parse(s);return q(t,n,r,o,"BigInt defaults cannot be represented in JSON Schema"),Qr}var eo=(e,t,n,r)=>{let o=e._zod.def;D(o.innerType,t,r);let i=t.seen.get(e);i.ref=o.innerType;let s=xu(o.defaultValue,e,t,n,r);if(s!==Qr)n.default=s},to=(e,t,n,r)=>{let o=e._zod.def;D(o.innerType,t,r);let i=t.seen.get(e);if(i.ref=o.innerType,t.io!=="input")return;let s=xu(o.defaultValue,e,t,n,r);if(s!==Qr)n._prefault=s},no=(e,t,n,r)=>{let o=e._zod.def;D(o.innerType,t,r);let i=t.seen.get(e);i.ref=o.innerType;let s;try{s=o.catchValue(void 0)}catch{q(e,t,n,r,"Dynamic catch values are not supported in JSON Schema");return}n.default=s},ro=(e,t,n,r)=>{let o=e._zod.def,i=o.in._zod.traits.has("$ZodTransform"),s=t.io==="input"?i?o.out:o.in:o.out;D(s,t,r);let a=t.seen.get(e);a.ref=s},oo=(e,t,n,r)=>{let o=e._zod.def;D(o.innerType,t,r);let i=t.seen.get(e);i.ref=o.innerType,n.readOnly=!0},io=(e,t,n,r)=>{let o=e._zod.def;D(o.innerType,t,r);let i=t.seen.get(e);i.ref=o.innerType},dn=(e,t,n,r)=>{let o=e._zod.def;D(o.innerType,t,r);let i=t.seen.get(e);i.ref=o.innerType},_u=(e,t,n,r)=>{let o=e._zod.innerType;D(o,t,r);let i=t.seen.get(e);i.ref=o},nu={string:Or,number:Nr,boolean:zr,bigint:cu,symbol:uu,null:lu,undefined:du,void:$r,never:Lr,any:pu,unknown:Dr,date:Br,enum:Ur,literal:Zr,nan:mu,template_literal:fu,file:gu,success:hu,custom:Fr,function:Hr,transform:jr,map:yu,set:bu,array:Vr,object:qr,union:Gr,intersection:Kr,tuple:Wr,record:Jr,nullable:Yr,nonoptional:Xr,default:eo,prefault:to,catch:no,pipe:ro,readonly:oo,promise:io,optional:dn,lazy:_u};function Su(e,t){if("_idmap"in e){let r=e,o=kt({...t,processors:nu}),i={};for(let c of r._idmap.entries()){let[u,l]=c;D(l,o)}let s={},a={registry:r,uri:t?.uri,defs:i};o.external=a;for(let c of r._idmap.entries()){let[u,l]=c;Et(o,l),te(s,u,Rt(o,l))}if(Object.keys(i).length>0){let c=o.target==="draft-2020-12"?"$defs":"definitions";s.__shared={[c]:i}}return{schemas:s}}let n=kt({...t,processors:nu});return D(e,n),Et(n,e),Rt(n,e)}var vu=new WeakSet([Object.prototype,Error.prototype]);function mn(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let r=n(this);return Object.defineProperty(this,t,{value:r,configurable:!0,writable:!0}),r},set(r){Object.defineProperty(this,t,{value:r,configurable:!0,writable:!0})}})}var Im=(e,t)=>{Fi.init(e,t),e.name="ZodError";let n=Object.getPrototypeOf(e);if(vu.has(n))return;vu.add(n),mn(n,"format",(r)=>(o)=>Wn(r,o)),mn(n,"flatten",(r)=>(o)=>Kn(r,o)),mn(n,"addIssue",(r)=>(o)=>{r.issues.push(o),r.message=JSON.stringify(r.issues,mt,2)}),mn(n,"addIssues",(r)=>(o)=>{r.issues.push(...o),r.message=JSON.stringify(r.issues,mt,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}})};var re=h("ZodError",Im,void 0,{Parent:Error});var Cu=yt(re),Tu=bt(re),ku=Gt(re),Eu=Kt(re),Ru=Vi(re),Au=qi(re),Iu=Gi(re),wu=Ki(re),Pu=Wi(re),Mu=Ji(re),Ou=Yi(re),Nu=Xi(re);function Pm(){if(!Y.localeError)Q(br())}function It(){if(!Y.memoizer)Q({memoizer:yr()})}var z=h("ZodType",(e,t)=>(Pm(),N.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(ne(t,{checks:[...t.checks??[],...e.map((n)=>typeof n==="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return ue(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Of(e,t))},superRefine(e,t){return this.check(Nf(e,t))},overwrite(e){return this.check(Ae(e))},optional(){return Lu(this)},exactOptional(){return xf(this)},nullable(){return Du(this)},nullish(){return Lu(Du(this))},nonoptional(e){return kf(this,e)},array(){return E(this)},or(e){return Ge([this,e])},and(e){return ff(this,e)},transform(e){return Bu(this,Hu(e))},default(e){return vf(this,e)},prefault(e){return Tf(this,e)},catch(e){return Rf(this,e)},pipe(e){return Bu(this,e)},readonly(){return wf(this)},describe(e){let t=this.clone();return Re.add(t,{description:e}),t},meta(...e){if(e.length===0)return Re.get(this);let t=this.clone();return Re.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get "~standard"(){return Vt(this,"~standard",{...cr(this),jsonSchema:{input:Tt(this,"input"),output:Tt(this,"output")}})},set "~standard"(e){xe(this,"~standard",e)},parse:function e(t,n){return Cu(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await Tu(this,t,n,{callee:e})},safeParse(e,t){return ku(this,e,t)},async safeParseAsync(e,t){return Eu(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){xe(this,"spa",e)},validate(e,t){return Xn(this,e,t)},validateAsync(e,t){return Qn(this,e,t)},encode:function e(t,n){return Ru(this,t,n,{callee:e})},decode:function e(t,n){return Au(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await Iu(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await wu(this,t,n,{callee:e})},safeEncode(e,t){return Pu(this,e,t)},safeDecode(e,t){return Mu(this,e,t)},async safeEncodeAsync(e,t){return Ou(this,e,t)},async safeDecodeAsync(e,t){return Nu(this,e,t)},toJSONSchema(e){return Yc(this,{})(e)},get description(){return Re.get(this)?.description},get _def(){return this._zod.def}}),Uu=h("_ZodString",(e,t)=>{Qt.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Or(e,n,r,o)},Hn({format:(e)=>W(e).format??null,minLength:(e)=>W(e).minimum??null,maxLength:(e)=>W(e).maximum??null},{regex(...e){return this.check(xr(...e))},includes(...e){return this.check(vr(...e))},startsWith(...e){return this.check(Cr(...e))},endsWith(...e){return this.check(Tr(...e))},min(...e){return this.check(je(...e))},max(...e){return this.check(un(...e))},length(...e){return this.check(ln(...e))},nonempty(...e){return this.check(je(1,...e))},lowercase(e){return this.check(_r(e))},uppercase(e){return this.check(Sr(e))},trim(){return this.check(Er())},normalize(...e){return this.check(kr(...e))},toLowerCase(){return this.check(Rr())},toUpperCase(){return this.check(Ar())},slugify(){return this.check(Ir())}})),Mm=h("ZodString",(e,t)=>{Qt.init(e,t),Uu.init(e,t)},{email(e){return this.check(uc(Lm,e))},url(e){return this.check(gc(Bm,e))},jwt(e){return this.check(wc(ef,e))},emoji(e){return this.check(hc(Um,e))},guid(e){return this.check(lc(Dm,e))},uuid(e){return this.check(dc(fn,e))},uuidv4(e){return this.check(pc(fn,e))},uuidv6(e){return this.check(mc(fn,e))},uuidv7(e){return this.check(fc(fn,e))},nanoid(e){return this.check(yc(Zm,e))},cuid(e){return this.check(bc(Fm,e))},cuid2(e){return this.check(xc(Hm,e))},ulid(e){return this.check(_c(jm,e))},base64(e){return this.check(Rc(Ym,e))},base64url(e){return this.check(Ac(Xm,e))},xid(e){return this.check(Sc(Vm,e))},ksuid(e){return this.check(vc(qm,e))},ipv4(e){return this.check(Cc(Gm,e))},ipv6(e){return this.check(Tc(Km,e))},cidrv4(e){return this.check(kc(Wm,e))},cidrv6(e){return this.check(Ec(Jm,e))},e164(e){return this.check(Ic(Qm,e))},datetime(e){return this.check(Pc(Om,e))},date(e){return this.check(Mc(Nm,e))},time(e){return this.check(Oc(zm,e))},duration(e){return this.check(Nc($m,e))}});function d(e){return cc(Mm,e)}var F=h("ZodStringFormat",(e,t)=>{U.init(e,t),Uu.init(e,t)}),Om=h("ZodISODateTime",(e,t)=>{ma.init(e,t),F.init(e,t)}),Nm=h("ZodISODate",(e,t)=>{fa.init(e,t),F.init(e,t)}),zm=h("ZodISOTime",(e,t)=>{ga.init(e,t),F.init(e,t)}),$m=h("ZodISODuration",(e,t)=>{ha.init(e,t),F.init(e,t)}),Lm=h("ZodEmail",(e,t)=>{na.init(e,t),F.init(e,t)});var Dm=h("ZodGUID",(e,t)=>{ea.init(e,t),F.init(e,t)});var fn=h("ZodUUID",(e,t)=>{ta.init(e,t),F.init(e,t)});var Bm=h("ZodURL",(e,t)=>{ia.init(e,t),F.init(e,t)});var Um=h("ZodEmoji",(e,t)=>{sa.init(e,t),F.init(e,t)});var Zm=h("ZodNanoID",(e,t)=>{aa.init(e,t),F.init(e,t)});var Fm=h("ZodCUID",(e,t)=>{ca.init(e,t),F.init(e,t)});var Hm=h("ZodCUID2",(e,t)=>{ua.init(e,t),F.init(e,t)});var jm=h("ZodULID",(e,t)=>{la.init(e,t),F.init(e,t)});var Vm=h("ZodXID",(e,t)=>{da.init(e,t),F.init(e,t)});var qm=h("ZodKSUID",(e,t)=>{pa.init(e,t),F.init(e,t)});var Gm=h("ZodIPv4",(e,t)=>{ya.init(e,t),F.init(e,t)});var Km=h("ZodIPv6",(e,t)=>{xa.init(e,t),F.init(e,t)});var Wm=h("ZodCIDRv4",(e,t)=>{_a.init(e,t),F.init(e,t)});var Jm=h("ZodCIDRv6",(e,t)=>{Sa.init(e,t),F.init(e,t)});var Ym=h("ZodBase64",(e,t)=>{Ca.init(e,t),F.init(e,t)});var Xm=h("ZodBase64URL",(e,t)=>{Ta.init(e,t),F.init(e,t)});var Qm=h("ZodE164",(e,t)=>{ka.init(e,t),F.init(e,t)});var ef=h("ZodJWT",(e,t)=>{Ea.init(e,t),F.init(e,t)});var Zu=h("ZodNumber",(e,t)=>{lr.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Nr(e,n,r,o),e.isFinite=!0},Hn({minValue:(e)=>{let{minimum:t,exclusiveMinimum:n}=W(e);return Math.max(t??Number.NEGATIVE_INFINITY,n??Number.NEGATIVE_INFINITY)},maxValue:(e)=>{let{maximum:t,exclusiveMaximum:n}=W(e);return Math.min(t??Number.POSITIVE_INFINITY,n??Number.POSITIVE_INFINITY)},isInt:(e)=>{let{isInt:t,multipleOf:n}=W(e);return!!t||!!n?.some(Number.isSafeInteger)},format:(e)=>W(e).format??null},{gt(e,t){return this.check(an(e,t))},gte(e,t){return this.check(He(e,t))},min(e,t){return this.check(He(e,t))},lt(e,t){return this.check(sn(e,t))},lte(e,t){return this.check(Fe(e,t))},max(e,t){return this.check(Fe(e,t))},int(e){return this.check(zu(e))},safe(e){return this.check(zu(e))},positive(e){return this.check(an(0,e))},nonnegative(e){return this.check(He(0,e))},negative(e){return this.check(sn(0,e))},nonpositive(e){return this.check(Fe(0,e))},multipleOf(e,t){return this.check(cn(e,t))},step(e,t){return this.check(cn(e,t))},finite(){return this}}));function x(e){return zc(Zu,e)}var tf=h("ZodNumberFormat",(e,t)=>{Ra.init(e,t),Zu.init(e,t)});function zu(e){return $c(tf,e)}var nf=h("ZodBoolean",(e,t)=>{Aa.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,r,o)=>zr(e,n,r,o)});function w(e){return Lc(nf,e)}var rf=h("ZodUnknown",(e,t)=>{Ia.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Dr(e,n,r,o)});function K(){return Dc(rf)}var of=h("ZodNever",(e,t)=>{wa.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Lr(e,n,r,o)});function sf(e){return Bc(of,e)}var af=h("ZodVoid",(e,t)=>{Pa.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,r,o)=>$r(e,n,r,o)});function cf(e){return Uc(af,e)}var uf=h("ZodDate",(e,t)=>{Ma.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Br(e,n,r,o),e.min=(n,r)=>e.check(He(n,r)),e.max=(n,r)=>e.check(Fe(n,r))},Hn({minDate:(e)=>{let{minimum:t}=W(e);return t?new Date(t):null},maxDate:(e)=>{let{maximum:t}=W(e);return t?new Date(t):null}},{}));function gn(e){return Zc(uf,e)}var lf=h("ZodArray",(e,t)=>{It(),Oa.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Vr(e,n,r,o),e.element=t.element},{min(e,t){return this.check(je(e,t))},nonempty(e){return this.check(je(1,e))},max(e,t){return this.check(un(e,t))},length(e,t){return this.check(ln(e,t))},unwrap(){return this.element}});function E(e,t){return Fc(lf,e,t)}var df=h("ZodObject",(e,t)=>{It(),$a.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,r,o)=>qr(e,n,r,o),zp(e,"shape",(n)=>n._zod.def.shape,!1)},{keyof(){return I(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(ne(this._zod.def,{catchall:e}))},passthrough(){return this.clone(ne(this._zod.def,{catchall:K()}))},loose(){return this.clone(ne(this._zod.def,{catchall:K()}))},strict(){return this.clone(ne(this._zod.def,{catchall:sf()}))},strip(){return this.clone(ne(this._zod.def,{catchall:void 0}))},extend(e){return Rp(this,e)},safeExtend(e){return Ap(this,e)},merge(e){return Ip(this,e)},pick(e){return kp(this,e)},omit(e){return Ep(this,e)},partial(...e){return Oi(co,this,e[0])},exactPartial(...e){return Oi(ju,this,e[0],"exactPartial")},required(...e){return wp(Vu,this,e[0])}});function b(e,t){let n={type:"object",shape:e??{},...S(t)};return new df(n)}var Fu=h("ZodUnion",(e,t)=>{dr.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Gr(e,n,r,o),e.options=t.options});function Ge(e,t){return new Fu({type:"union",options:e,...S(t)})}var pf=h("ZodDiscriminatedUnion",(e,t)=>{Fu.init(e,t),La.init(e,t)});function ao(e,t,n){return new pf({type:"union",options:t,discriminator:e,...S(n)})}var mf=h("ZodIntersection",(e,t)=>{Da.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Kr(e,n,r,o)});function ff(e,t){return new mf({type:"intersection",left:e,right:t})}var gf=h("ZodTuple",(e,t)=>{It(),pr.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Wr(e,n,r,o)},{rest(e){return this.clone({...this._zod.def,rest:e})},partial(){let e=this._zod.def;if(e.checks?.length)throw Error(".partial() cannot be used on tuple schemas containing refinements");return this.clone({...e,items:e.items.map((t)=>new co({type:"optional",innerType:t}))})}});function hf(e,t,n){let r=t instanceof N,o=r?n:t;return new gf({type:"tuple",items:e,rest:r?t:null,...S(o)})}var $u=h("ZodRecord",(e,t)=>{It(),Ba.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Jr(e,n,r,o),e.keyType=t.keyType,e.valueType=t.valueType});function j(e,t,n){if(!t||!t._zod)return new $u({type:"record",keyType:d(),valueType:e,...S(t)});return new $u({type:"record",keyType:e,valueType:t,...S(n)})}var so=h("ZodEnum",(e,t)=>{Ua.init(e,t),z.init(e,t),e._zod.processJSONSchema=(r,o,i)=>Ur(e,r,o,i),e.enum=t.entries,e.options=[...e._zod.values];let n=new Set(Object.keys(t.entries));e.extract=(r,o)=>{let i={};for(let s of r)if(n.has(s))i[s]=t.entries[s];else throw Error(`Key ${s} not found in enum`);return new so({...t,checks:[],...S(o),entries:i})},e.exclude=(r,o)=>{let i={...t.entries};for(let s of r)if(n.has(s))delete i[s];else throw Error(`Key ${s} not found in enum`);return new so({...t,checks:[],...S(o),entries:i})}});function I(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map((r)=>[r,r])):e;return new so({type:"enum",entries:n,...S(t)})}var yf=h("ZodLiteral",(e,t)=>{Za.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Zr(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 V(e,t){return new yf({type:"literal",values:Array.isArray(e)?e:[e],...S(t)})}var bf=h("ZodTransform",(e,t)=>{It(),Fa.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,r,o)=>jr(e,n,r,o),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new ht(e.constructor.name);n.addIssue=(i)=>{if(typeof i==="string")n.issues.push(ze(i,n.value,t));else{let s=i;if(s.fatal)s.continue=!1;if(s.code??(s.code="custom"),!("input"in s))s.input=n.value;s.inst??(s.inst=e),n.issues.push(ze(s))}};let o=t.transform(n.value,n);if(o instanceof Promise)return o.then((i)=>(n.value=i,n));return n.value=o,n}});function Hu(e){return new bf({type:"transform",transform:e})}var co=h("ZodOptional",(e,t)=>{mr.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,r,o)=>dn(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Lu(e){return new co({type:"optional",innerType:e})}var ju=h("ZodExactOptional",(e,t)=>{Ha.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,r,o)=>dn(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function xf(e){return new ju({type:"optional",innerType:e})}var _f=h("ZodNullable",(e,t)=>{ja.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Yr(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Du(e){return new _f({type:"nullable",innerType:e})}var Sf=h("ZodDefault",(e,t)=>{Va.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,r,o)=>eo(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function vf(e,t){return new Sf({type:"default",innerType:e,get defaultValue(){return typeof t==="function"?t():Bn(t)}})}var Cf=h("ZodPrefault",(e,t)=>{qa.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,r,o)=>to(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Tf(e,t){return new Cf({type:"prefault",innerType:e,get defaultValue(){return typeof t==="function"?t():Bn(t)}})}var Vu=h("ZodNonOptional",(e,t)=>{Ga.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Xr(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function kf(e,t){return new Vu({type:"nonoptional",innerType:e,...S(t)})}var Ef=h("ZodCatch",(e,t)=>{Ka.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,r,o)=>no(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Rf(e,t){return new Ef({type:"catch",innerType:e,catchValue:typeof t==="function"?t:Li(t)})}var qu=h("ZodPipe",(e,t)=>{fr.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ro(e,n,r,o),e.in=t.in,e.out=t.out});function Bu(e,t){return new qu({type:"pipe",in:e,out:t})}var Af=h("ZodPreprocess",(e,t)=>{qu.init(e,t),Wa.init(e,t)}),If=h("ZodReadonly",(e,t)=>{Ja.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,r,o)=>oo(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function wf(e){return new If({type:"readonly",innerType:e})}var Pf=h("ZodPromise",(e,t)=>{Xa.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,r,o)=>io(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function uo(e){return new Pf({type:"promise",innerType:e})}var Mf=h("ZodFunction",(e,t)=>{Ya.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Hr(e,n,r,o)});function hn(e){return new Mf({type:"function",input:Array.isArray(e?.input)?hf(e?.input):e?.input??E(K()),output:e?.output??K()})}var Gu=h("ZodCustom",(e,t)=>{Qa.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Fr(e,n,r,o)});function se(e,t){return Hc(Gu,e??(()=>!0),t)}function Of(e,t={}){return jc(Gu,e,t)}function Nf(e,t){return Vc(e,t)}function Ku(e,t){return new Af({type:"pipe",in:Hu(e),out:t})}var yn=["none","minimal","low","medium","high","xhigh","max"],lo=I(yn),bn=lo.exclude(["none"]),zf=I([...yn,"default"]).nullable(),po=ao("type",[b({type:V("toggle")}).strict(),b({type:V("effort"),values:E(zf)}).strict(),b({type:V("budget_tokens"),min:x().min(-1).optional(),max:x().min(0).optional()}).strict().refine((e)=>e.min===void 0||e.max===void 0||e.min<=e.max,{message:"Minimum reasoning budget cannot exceed maximum",path:["min"]})]);var Wu=I(["default","openai-responses","r1"]),$f={DEFAULT:"default",OPENAI_RESPONSES:"openai-responses",R1:"r1"},Ju=I(["images","video","tools","streaming","prompt-cache","reasoning","reasoning-effort","computer-use","global-endpoint","structured_output","temperature","files"]),Yu=I(["active","preview","deprecated","legacy"]),Xu=b({input:x().optional(),output:x().optional(),cacheWrite:x().optional(),cacheRead:x().optional()}),Qu=b({maxBudget:x().optional(),outputPrice:x().optional(),thinkingLevel:I(["low","high"]).optional()}),el=b({reasoningDefaultOn:w().optional(),apiProtocol:I(["openai-chat","openai-responses","anthropic","gemini"]).optional()}).catchall(K()),mo=I(["text","image","audio","video","pdf"]),tl=b({input:E(mo),output:E(mo)});function nl(e){return(e?.input===void 0||e.input.includes("text"))&&(e?.output===void 0||e.output.includes("text"))}var rl=I(["language","image-generation","speech-generation","video-generation","transcription","realtime"]);function Lf(e){let t=e.modalities?.input,n=e.modalities?.output;return t?.length===1&&t[0]==="audio"&&n?.length===1&&n[0]==="text"}function Df(e){return(e.operation===void 0||e.operation==="language")&&nl(e.modalities)}var ol=I(["batch","streaming"]);function Bf(e){return e.modalities?.input.includes("text")===!0&&e.modalities.output.includes("image")}function Uf(e){return e.operation==="image-generation"}function fo(e,t,n){let r=e.capabilities;if(r===void 0||r.length===0)return n?.assumeWhenUnspecified??!1;return r.includes(t)}function Zf(e){return fo(e,"tools",{assumeWhenUnspecified:!0})}function Ff(e){return fo(e,"images",{assumeWhenUnspecified:!0})}var xn=b({id:d(),name:d().optional(),description:d().optional(),maxTokens:x().optional(),contextWindow:x().optional(),maxInputTokens:x().optional(),capabilities:E(Ju).optional(),operation:rl.optional(),operationModes:E(ol).optional(),modalities:tl.optional(),reasoningOptions:E(po).optional(),apiFormat:Wu.optional(),systemRole:I(["system","developer"]).optional(),temperature:x().optional(),pricing:Xu.optional(),thinkingConfig:Qu.optional(),status:Yu.optional(),deprecationNotice:d().optional(),replacedBy:d().optional(),releaseDate:d().optional(),deprecationDate:d().optional(),family:d().optional(),metadata:el.optional()});var Hf="This tool call was rejected by the user and not executed.",jf="NOT a tool or system failure. Clarify with user before proceeding.",go=b({id:d(),name:d(),execution:I(["client","provider"]).optional(),input:K(),output:K(),error:d().optional(),durationMs:x(),startedAt:gn(),endedAt:gn()});var Vf=I(["completed","max_iterations","aborted","mistake_limit","error"]),qf=b({inputTokens:x(),outputTokens:x(),cacheReadTokens:x().optional(),cacheWriteTokens:x().optional(),totalCost:x().optional()}),_v=b({text:d(),usage:qf,messages:E(se()),toolCalls:E(go),iterations:x(),finishReason:Vf,model:b({id:d(),provider:d(),info:xn.optional()}),startedAt:gn(),endedAt:gn(),durationMs:x()}),Sv=b({distinctId:d().optional(),sessionId:d().optional(),providerId:d(),modelId:d(),apiKey:d().optional(),baseUrl:d().url().optional(),headers:j(d(),d()).optional(),knownModels:j(d(),xn).optional(),providerConfig:K().optional(),initialMessages:E(se()).optional(),systemPrompt:d(),tools:E(se()),modelTools:E(se()).optional(),maxIterations:x().positive().optional(),maxParallelToolCalls:x().int().positive().default(8),maxTokensPerTurn:x().positive().optional(),temperature:x().nonnegative().optional(),apiTimeoutMs:x().positive().default(180000),userFileContentLoader:hn().input([d()]).output(uo(d())).optional(),toolContextMetadata:j(d(),K()).optional(),execution:b({maxConsecutiveMistakes:x().int().positive().optional(),reminderAfterIterations:x().nonnegative().optional(),reminderText:d().optional(),loopDetection:Ge([V(!1),b({softThreshold:x().int().positive().optional(),hardThreshold:x().int().positive().optional()})]).optional()}).optional(),reasoningEffort:bn.optional(),thinkingBudgetTokens:x().positive().optional(),thinking:w().optional(),onEvent:hn().input([se()]).output(cf()).optional(),hooks:se().optional(),parentAgentId:d().optional(),extensions:E(se()).optional(),hookErrorMode:I(["ignore","throw"]).default("ignore"),toolPolicies:j(d(),b({enabled:w().optional(),autoApprove:w().optional()})).optional(),requestToolApproval:hn().input([b({sessionId:d(),agentId:d(),conversationId:d(),iteration:x(),toolCallId:d(),toolName:d(),input:K(),policy:b({enabled:w().optional(),autoApprove:w().optional()}).default({})})]).output(Ge([b({approved:w(),reason:d().optional()}),uo(b({approved:w(),reason:d().optional()}))])).optional(),onConsecutiveMistakeLimitReached:hn().input([b({iteration:x().int().positive(),consecutiveMistakes:x().int().positive(),maxConsecutiveMistakes:x().int().positive(),reason:I(["api_error","invalid_tool_call","tool_execution_failed"]),details:d().optional()})]).output(Ge([b({action:V("continue"),guidance:d().optional()}),b({action:V("stop"),reason:d().optional()}),uo(Ge([b({action:V("continue"),guidance:d().optional()}),b({action:V("stop"),reason:d().optional()})]))])).optional(),logger:se().optional(),extensionContext:se().optional(),abortSignal:se().optional()});var il=I(["connector.started","connector.stopping","session.authorize","message.received","message.denied","message.completed","message.failed","session.started","session.reused","session.reset","schedule.delivery.started","schedule.delivery.sent","schedule.delivery.failed"]),sl=b({id:d().optional(),label:d().optional(),role:d().optional(),participantKey:d().optional(),participantLabel:d().optional(),platformUserId:d().optional(),metadata:j(d(),K()).optional()}),al=b({source:d(),sourceEvent:d(),threadId:d(),channelId:d(),isDM:w(),sessionId:d().optional(),workspaceRoot:d().optional(),metadata:j(d(),K()).optional()}),Gf=b({actor:sl,context:al,payload:j(d(),K()).optional()}),Kf=b({action:I(["allow","deny"]).default("allow"),message:d().optional(),reason:d().optional(),metadata:j(d(),K()).optional()}),Wf=b({adapter:d(),botUserName:d().optional(),event:il,payload:j(d(),K()),ts:d()});var cl=[{name:"discord",description:"Discord interactions and gateway bridge backed by RPC runtime sessions"},{name:"gchat",description:"Google Chat webhook bridge backed by RPC runtime sessions"},{name:"linear",description:"Linear webhook bridge backed by RPC runtime sessions"},{name:"slack",description:"Slack webhook/socket bridge backed by RPC runtime sessions"},{name:"telegram",description:"Bridge Telegram bot messages into RPC chat sessions"},{name:"whatsapp",description:"Bridge WhatsApp webhook messages into RPC chat sessions"}];function ul(){return cl.map((e)=>({...e}))}function ll(e,t){let n=e.includeWhen;if(!n)return!0;let r=t[n.flag]??"";if(n.equals!==void 0&&r!==n.equals)return!1;if(n.notEquals!==void 0&&r===n.notEquals)return!1;return!0}function Jf(e,t,n){let r={};for(let i of e.fields){let s=t[i.flag];r[i.flag]=typeof s==="string"?s.trim():i.initialValue??""}let o=[];for(let i of e.fields){if(!ll(i,r))continue;let s=r[i.flag]??"";if(!s){if(i.required)throw Error(`${i.label} is required`);continue}o.push(i.flag,s)}if(n?.enabled===!0&&e.security){let i={};for(let s of e.security.fields){let a=n.values[s.key]?.trim();if(!a)throw Error(s.requiredMessage);let c=s.validate?.(a);if(c)throw Error(c);i[s.key]=a}o.push(...e.security.buildArgs(i))}return o}function Yf(e,t){if(t.has(e))return{managed:!0,consumesNext:!0};for(let n of t)if(e.startsWith(`${n}=`))return{managed:!0,consumesNext:!1};return{managed:!1,consumesNext:!1}}function Xf(e,t,n,r){let o=new Set([...e.fields.flatMap((s)=>[s.flag,...s.aliases??[]]),...e.derivedReconnectFlags??[]]);if(r.replaceSecurityArgs)for(let s of e.security?.argumentFlags??[])o.add(s);let i=[];for(let s=0;s<t.length;s+=1){let a=t[s]??"",c=Yf(a,o);if(!c.managed){i.push(a);continue}if(c.consumesNext)s+=1}return[...i,...n]}function Qf(e=dl){let t=new Set(ul().map((n)=>n.name));return e.filter((n)=>t.has(n.id)).map((n)=>({id:n.id,name:n.name,type:n.type,hint:n.hint,fields:n.fields.map((r)=>({flag:r.flag,label:r.label,placeholder:r.placeholder,required:r.required,help:r.help,initialValue:r.initialValue,options:r.options,includeWhen:r.includeWhen})),security:n.security?{prompt:n.security.prompt,fields:n.security.fields.map((r)=>({key:r.key,label:r.label,placeholder:r.placeholder,help:r.help,requiredMessage:r.requiredMessage}))}:void 0}))}function eg(e){return/^\d+$/.test(e)?void 0:"Telegram user ID must contain digits only"}function tg(e){return/^T[A-Z0-9]+$/.test(e)?void 0:"Slack workspace ID must start with T and contain uppercase letters or digits only"}function ng(e){return/^[UW][A-Z0-9]+$/.test(e)?void 0:"Slack member ID must start with U or W and contain uppercase letters or digits only"}var dl=[{id:"telegram",name:"Telegram",type:"polling",hint:"Easiest to set up. No public URL needed.",derivedReconnectFlags:["-m","--bot-username"],fields:[{flag:"-k",aliases:["--bot-token"],label:"Bot token",placeholder:"7123456789:AAH...",required:!0,help:["Open Telegram and start a chat with @BotFather","Send /newbot and follow the prompts","BotFather gives you this after creating the bot","It looks like 7123456789:AAHxxx..."]}],security:{prompt:"By default, anyone who finds your bot can message it and run tasks on your machine. Restrict access to your Telegram user ID?",fields:[{key:"userId",label:"Your Telegram user ID",placeholder:"123456789",help:["Message @userinfobot on Telegram","It will reply with your numeric user ID"],requiredMessage:"User ID is required to restrict access",validate:eg}],argumentFlags:["--allowed-user-id","--hook-command"],buildArgs:({userId:e})=>["--allowed-user-id",e??""]}},{id:"slack",name:"Slack",type:"hybrid",hint:"Public URL for webhook mode; leave blank for socket mode.",fields:[{flag:"--bot-token",label:"Bot token",placeholder:"xoxb-...",required:!0,help:["Go to api.slack.com/apps and create a new app","Add Bot Token Scopes: chat:write, app_mentions:read, channels:history, channels:read, im:history, im:read, im:write, users:read","Install to workspace and copy the Bot Token"]},{flag:"--base-url",label:"Public base URL",placeholder:"leave blank for socket mode",help:["Enter a publicly accessible URL for webhook mode","Leave blank to use Slack socket mode instead"]},{flag:"--signing-secret",label:"Signing secret",required:!0,help:["Found in your app's Basic Information page"],includeWhen:{flag:"--base-url",notEquals:""}},{flag:"--app-token",label:"App-level token",placeholder:"xapp-...",required:!0,help:["Enable Socket Mode in the Slack app","Generate an app-level token with the connections:write scope"],includeWhen:{flag:"--base-url",equals:""}}],security:{prompt:"Restrict which Slack users can interact with the bot?",fields:[{key:"teamId",label:"Allowed Slack workspace ID",placeholder:"T01ABC123",help:["Open your Slack workspace URL in a browser","The workspace ID is the segment after /client/, for example T01ABC123"],requiredMessage:"Workspace ID is required to restrict access",validate:tg},{key:"userId",label:"Allowed Slack member ID",placeholder:"U01ABC123",help:["Click a user's name in Slack, then View full profile","Click ... and Copy member ID"],requiredMessage:"Member ID is required to restrict access",validate:ng}],argumentFlags:["--hook-command"],buildArgs:({teamId:e,userId:t})=>["--hook-command",`jq -r ".payload.actor.participantKey" | grep -qx "slack:team:${e}:user:${t}" && echo '{"action":"allow"}' || echo '{"action":"deny"}'`]}},{id:"discord",name:"Discord",type:"webhook",hint:"Requires a Discord app and public URL.",fields:[{flag:"--application-id",aliases:["--app-id"],label:"Application ID",required:!0,help:["Go to discord.com/developers/applications","Create a new app, copy the Application ID"]},{flag:"--bot-token",aliases:["--token"],label:"Bot token",required:!0,help:["Go to Bot section, create a bot, copy the token"]},{flag:"--public-key",label:"Public key",required:!0,help:["Found in General Information of your app"]},{flag:"--base-url",label:"Public base URL",placeholder:"https://example.com",required:!0,help:["Base URL for the connector","For Discord, set the Interactions Endpoint URL to <base-url>/api/webhooks/discord"]}]},{id:"whatsapp",name:"WhatsApp",type:"webhook",hint:"Requires Meta developer account and public URL.",fields:[{flag:"--phone-number-id",label:"Phone number ID",required:!0,help:["From your WhatsApp Business account in Meta Developer portal"]},{flag:"--access-token",label:"Access token",required:!0,help:["Generate a permanent token in Meta Developer portal"]},{flag:"--app-secret",label:"App secret",required:!0,help:["Found in App Settings > Basic"]},{flag:"--verify-token",label:"Webhook verify token",placeholder:"my-verify-token",required:!0,help:["Any string you choose, used to verify webhook setup"]},{flag:"--base-url",label:"Public base URL",placeholder:"https://example.com",required:!0}]},{id:"gchat",name:"Google Chat",type:"webhook",hint:"Requires Google Cloud project and public URL.",fields:[{flag:"--credentials-json",label:"Service account credentials JSON",required:!0,help:["Create a service account in Google Cloud Console","Download the credentials JSON file","Paste the JSON content here"]},{flag:"--base-url",label:"Public base URL",placeholder:"https://example.com",required:!0}]},{id:"linear",name:"Linear",type:"webhook",hint:"React to Linear issues and comments.",fields:[{flag:"--api-key",label:"API key",required:!0,help:["Go to Linear Settings > API > Personal API keys"]},{flag:"--webhook-secret",label:"Webhook signing secret",required:!0,help:["Go to Settings > API > Webhooks, create one","Copy the signing secret"]},{flag:"--base-url",label:"Public base URL",placeholder:"https://example.com",required:!0}]}];var pl=[];function ho(e){pl.push(e)}async function rg(){let e=pl.splice(0);await Promise.all(e.map((t)=>{try{return(typeof t==="function"?t():t.dispose())??Promise.resolve()}catch{return Promise.resolve()}}))}var og=["hooks","tools","commands","rules","skills","messageBuilders","providers","automationEvents","mcp"],ig=new Set(og);function gl(e,t){return e.name||`extension_${String(t).padStart(4,"0")}`}function ml(e){return Array.isArray(e)&&e.every((t)=>typeof t==="string")}function fl(e){if(!Array.isArray(e))return;let t=e.filter((n)=>typeof n==="string").map((n)=>n.trim()).filter((n)=>n.length>0);return t.length>0?t:void 0}function hl(e){let t=fl(e.providerIds),n=fl(e.modelIds);return{...e,...t?{providerIds:t}:{},...n?{modelIds:n}:{}}}function sg(e,t){let n=gl(e,t),r=e.manifest;if(!r||typeof r!=="object")throw Error(`Invalid manifest for extension "${n}": manifest is required`);if(!Array.isArray(r.capabilities)||r.capabilities.length===0)throw Error(`Invalid manifest for extension "${n}": capabilities must be a non-empty array`);let o=new Set;for(let a of r.capabilities){if(!ig.has(a))throw Error(`Invalid manifest for extension "${n}": unsupported capability "${String(a)}"`);o.add(a)}if(Object.hasOwn(r,"providerIds")&&!ml(r.providerIds))throw Error(`Invalid manifest for extension "${n}": providerIds must be a string array when provided`);if(Object.hasOwn(r,"modelIds")&&!ml(r.modelIds))throw Error(`Invalid manifest for extension "${n}": modelIds must be a string array when provided`);let i=o.has("hooks");if(e.hooks!==void 0&&!i)throw Error(`Invalid manifest for extension "${n}": runtime hooks require the "hooks" capability`);return{capabilities:o,raw:hl(r)}}function ag(e,t){if(!e||typeof e!=="object")throw Error(`Invalid automation event contribution for extension "${t}": expected object`);let n=typeof e.eventType==="string"?e.eventType.trim():"",r=typeof e.source==="string"?e.source.trim():"";if(!n)throw Error(`Invalid automation event contribution for extension "${t}": eventType is required`);if(!r)throw Error(`Invalid automation event contribution for extension "${t}": source is required`);return{...e,eventType:n,source:r,examples:e.examples?[...e.examples]:void 0,metadata:e.metadata?{...e.metadata}:void 0}}class yo{extensions;registry={tools:[],commands:[],rules:[],messageBuilder:[],providers:[],automationEventTypes:[],mcpServers:[]};normalized=[];phase="resolve";setupContext;constructor(e={}){this.extensions=e.extensions??[],this.setupContext=e.setupContext??{}}resolve(){if(this.phase!=="resolve")return;this.normalized=this.extensions.map((e,t)=>({extension:e,order:t,manifest:{capabilities:new Set,raw:e.manifest}})),this.phase="validate"}validate(){if(this.phase==="resolve")this.resolve();if(this.phase!=="validate")return;this.normalized=this.normalized.map((e)=>({...e,manifest:sg(e.extension,e.order)})),this.phase="setup"}async setup(e={}){if(this.phase==="resolve")this.resolve();if(this.phase==="validate")this.validate();if(this.phase!=="setup")return;let t,n=[];for(let r of this.normalized){let{extension:o}=r;if(o.disabled)continue;let i=gl(o,r.order),s={tools:[],commands:[],rules:[],messageBuilder:[],providers:[],automationEventTypes:[],mcpServers:[]},a={registerTool:(u)=>s.tools.push(u),registerCommand:(u)=>s.commands.push(u),registerRule:(u)=>{if(!r.manifest.capabilities.has("rules"))throw Error(`Invalid setup for extension "${i}": registerRule requires the "rules" capability`);s.rules.push(u)},registerMessageBuilder:(u)=>s.messageBuilder.push(u),registerProvider:(u)=>s.providers.push(u),registerAutomationEventType:(u)=>{if(!r.manifest.capabilities.has("automationEvents"))throw Error(`Invalid setup for extension "${i}": registerAutomationEventType requires the "automationEvents" capability`);s.automationEventTypes.push(ag(u,i))},registerMcpServer:(u)=>{if(!r.manifest.capabilities.has("mcp"))throw Error(`Invalid setup for extension "${i}": registerMcpServer requires the "mcp" capability`);s.mcpServers.push({...u,metadata:{...u.metadata??{},source:"plugin",plugin:i}})}},c=r.manifest.capabilities.has("automationEvents")?this.setupContext:{...this.setupContext,automation:void 0};try{await o.setup?.(a,c),n.push(s)}catch(u){if(e.tolerateSetupErrors!==!0)throw u;t??=u}}if(t&&e.tolerateSetupErrors!==!0)throw t;for(let r of n)this.registry.tools.push(...r.tools),this.registry.commands.push(...r.commands),this.registry.rules.push(...r.rules),this.registry.messageBuilder.push(...r.messageBuilder),this.registry.providers.push(...r.providers),this.registry.automationEventTypes.push(...r.automationEventTypes),this.registry.mcpServers.push(...r.mcpServers);if(this.phase="activate",t)throw t}activate(){if(this.phase==="resolve")this.resolve();if(this.phase==="validate")this.validate();if(this.phase==="setup")throw Error("Contribution registry setup must complete before activation");if(this.phase!=="activate")return;this.phase="run"}async initialize(e={}){this.resolve(),this.validate();try{await this.setup(e)}finally{if(this.phase==="activate")this.activate()}}isActivated(){return this.phase==="run"}getRegistrySnapshot(){return{tools:[...this.registry.tools],commands:[...this.registry.commands],rules:[...this.registry.rules],messageBuilder:[...this.registry.messageBuilder],providers:[...this.registry.providers],automationEventTypes:[...this.registry.automationEventTypes],mcpServers:[...this.registry.mcpServers]}}getRegisteredTools(){return[...this.registry.tools]}getRegisteredRules(){return[...this.registry.rules]}getRegisteredAutomationEventTypes(){return[...this.registry.automationEventTypes]}getRegisteredMcpServers(){return[...this.registry.mcpServers]}getValidatedExtensions(){if(this.phase==="resolve")this.resolve();if(this.phase==="validate")this.validate();return this.normalized.slice().sort((e,t)=>e.order-t.order).map(({extension:e})=>e)}}function cg(e={}){return new yo(e)}var ug=[".js",".ts"];var Ke={CLINE_PASS:"ext-cline-pass",CODE_CLOUD_AGENTS:"code-cloud-agents",CODE_ONBOARDING_GITHUB:"code-onboarding-github",CLINE_COMPOSIO_BETA:"CLINE_COMPOSIO_BETA"},lg={[Ke.CLINE_PASS]:!1,[Ke.CODE_CLOUD_AGENTS]:!1,[Ke.CODE_ONBOARDING_GITHUB]:!1,[Ke.CLINE_COMPOSIO_BETA]:!1},dg=Object.values(Ke);var yl=I(["agent_start","agent_resume","agent_abort","agent_end","agent_error","tool_call","tool_result","prompt_submit","pre_compact","session_shutdown"]),$e=j(d(),d()),pg=b({toolName:d(),parameters:$e}),mg=b({toolName:d(),parameters:$e,result:d(),success:w(),executionTimeMs:x()}),fg=b({prompt:d(),attachments:E(d())}),gg=b({taskMetadata:$e}),hg=b({taskMetadata:$e,previousState:$e}),yg=b({taskMetadata:$e}),bg=b({taskMetadata:$e}),xg=b({taskId:d(),ulid:d(),contextSize:x(),compactionStrategy:d(),previousApiReqIndex:x(),tokensIn:x(),tokensOut:x(),tokensInCache:x(),tokensOutCache:x(),deletedRangeStart:x(),deletedRangeEnd:x(),contextJsonPath:d(),contextRawPath:d()}),bl=b({clineVersion:d(),hookName:yl,timestamp:d(),taskId:d(),sessionContext:b({rootSessionId:d().optional(),hookLogPath:d().optional()}).optional(),workspaceRoots:E(d()),workspaceInfo:se().optional(),userId:d(),agent_id:d(),parent_agent_id:d().nullable(),iteration:x().optional(),reason:d().optional(),tool_call:b({id:d(),name:d(),input:K()}).optional(),tool_result:se().optional(),turn:K().optional(),error:b({name:d(),message:d(),stack:d().optional()}).optional(),preToolUse:pg.optional(),postToolUse:mg.optional(),userPromptSubmit:fg.optional(),taskStart:gg.optional(),taskResume:hg.optional(),taskCancel:yg.optional(),taskComplete:bg.optional(),preCompact:xg.optional()}).passthrough();function _g(e){let t=bl.safeParse(e);if(!t.success)return;return t.data}var zv="v1",$v="v1",Lv="v1",Dv=["client.register","client.list","session.create","session.list","session.get","session.run","session.abort","schedule.create","schedule.list","task.create","task.list","task.get","task.update","task.approve","task.cancel","task.run","task.automation.get","task.automation.set","settings.get","settings.set","connector.start","connector.stop","connector.supervised","run.enqueue","run.list","hub.drain","hub.status","plugins.list","plugins.status","plugins.reload","stream.replay"];function _n(e){let t=/^v(\d+)$/.exec(e?.trim()??"");if(!t)return;return Number.parseInt(t[1]??"",10)}function Bv(e,t="v1"){let n=_n(e.protocolVersion),r=_n(t);if(n===void 0||r===void 0)return{compatible:!1,reason:"missing_protocol"};let o=_n(e.minClientProtocolVersion)??n,i=_n(e.maxClientProtocolVersion)??n;return r>=o&&r<=i?{compatible:!0}:{compatible:!1,reason:"unsupported_protocol"}}var Uv="approval.respond",Zv="0",Fv="__hubScheduleRunAt",xl=["act","plan","yolo"];function Sg(e){return xl.some((t)=>t===e)}function Hv(e,t){if(!e||!Object.hasOwn(e,"mode"))return t;let n=e.mode;if(Sg(n))return n;throw Error(`mode must be one of: ${xl.join(", ")}`)}var vg=30000,jv=5000;function Cg(e){switch(e){case"run.start":case"session.send_input":return null;default:return vg}}function Vv(e,t){return t===void 0?Cg(e):t}var Tg=["readFile","search","bash","webFetch","editor","applyPatch","skills","askQuestion","submit"],kg=new Set(Tg);function qv(e){return typeof e==="string"&&kg.has(e)}var Gv="tool_executor.",Kv="custom_tool.",Wv="hook.",Jv="compaction.compact",Yv="checkpoint.create",Xv="mistake_limit.decide",Qv="user_instructions.snapshot";function eC(e){let t=e.activeSessionCount;if(typeof t!=="number"||t<=0)return"active sessions from other Cline clients";let n=`${t} active session${t===1?"":"s"}`,r=e.participantClientCount;if(typeof r!=="number"||r<=0)return n;return`${n} from ${r} connected Cline client${r===1?"":"s"}`}function bo(e,t){return`<file_content path="${e}">
59
59
  ${t}
60
- </file_content>`}function Tg(e,t="act"){return`<user_input mode="${t}">${e}</user_input>`}function Cg(e,t){return`<user_command slash="${t}">${e}</user_command>`}var kg=/<user_input\b[^>]*\bmode="(act|plan|yolo)"/;function Eg(e){let t=kg.exec(e??"");return t?t[1]:void 0}function Rg(e,t){return`<mode_notice>The user switched from ${e} mode to ${t} mode before sending this message.</mode_notice>`}function Ag(){let e=null;return{record(t,n){if(t===n)return;if(e){e=e.from===n?null:{from:e.from,to:n};return}e={from:t,to:n}},consume(){let t=e;return e=null,t}}}function Ig(e,t){let n=e.trim(),r=new RegExp(`^<${t}\\b([^>]*)>([\\s\\S]*?)<\\/${t}>$`,"i").exec(n);if(!r)return;return{attrs:r[1]??"",content:r[2]??""}}function wg(e,t){return new RegExp(`${t}="([^"]+)"`,"i").exec(e)?.[1]?.trim()||void 0}function Sl(e){if(!e?.trim())return;let t=Ig(e,"user_command");if(!t)return;let n=wg(t.attrs,"slash");if(!n)return;return{slash:n,content:t.content.trim()}}function _l(e){if(!e?.trim())return"";let t=e.trim();for(let n of["user_input","user_command"]){let r=El(t,n);t=(r!==t?r:t.replace(new RegExp(`<${n}[^>]*>`,"g"),"")).trim()}return t}function vl(e){if(!e?.trim())return"";return Pg(e,"mode_notice").trim()}function Pg(e,t){let n=`<${t}>`,r=`</${t}>`,o=e,i=o.indexOf(n);while(i!==-1){let s=o.indexOf(r,i+n.length);if(s===-1)break;o=o.slice(0,i)+o.slice(s+r.length),i=o.indexOf(n,i)}return o}function xo(e){let t=vl(_l(e)),n=Sl(e);if(!n)return t;if(n.slash.toLowerCase()==="team"){let o=t.toLowerCase().startsWith("spawn a team of agents for the following task:")?t.slice(46).trim():t;return o?`/team ${o}`:"/team"}return t?`/${n.slash} ${t}`:`/${n.slash}`}var Tl=240,Cl=480;function kl(e,t){let n=e.replace(/\s+/gu," ").trim();if(n.length<=t)return n;return`${n.slice(0,t-1).trimEnd()}…`}function Mg(e){return kl(xo(e),Tl)}function Og(e,t){let n=t?.trim()??"",r=e.toLowerCase(),o=r==="user"||r==="session"?xo(n):n;return kl(o,Cl)}function El(e,t){if(!e?.trim())return"";if(!t)return e;let n=new RegExp(`<${t}\\b[^>]*>([\\s\\S]*?)</${t}>`,"g");return e.replace(n,"$1")}var We="[media omitted: invalid or exceeds size limit]",Je="[Image attached — this model cannot view images]",Rl=I(["image","audio","video","file"]),Al=ao("type",[b({type:V("base64"),data:d().min(1)}),b({type:V("url"),url:d().url().refine((e)=>{let t=new URL(e).protocol;return t==="http:"||t==="https:"},"Generated media URLs must use HTTP or HTTPS")}),b({type:V("artifact"),artifactId:d().min(1)})]);function Il(e){if(e.startsWith("image/"))return"image";if(e.startsWith("audio/"))return"audio";if(e.startsWith("video/"))return"video";return"file"}var wl=b({id:d().min(1),modality:Rl,mediaType:d().min(1),source:Al,name:d().min(1).optional(),sizeBytes:x().int().nonnegative().optional()}).refine((e)=>Il(e.mediaType)===e.modality,{message:"Generated media modality must match its media type",path:["modality"]});function zg(e){return wl.safeParse(e).success}function Ng(e){return Il(e)}var vn=["image/png","image/jpeg","image/gif","image/webp"],So=5242880,fe=So,Se=6291456,Pl=8388608;function $g(e){return e.length}function _o(e){let t=e.endsWith("==")?2:e.endsWith("=")?1:0;return Math.floor(e.length*3/4)-t}function Lg(e=So){return Math.floor(e*3/4)}function vo(e){return Math.ceil(e/3)*4}function To(e={}){return{maxImageEncodedBytes:e.maxImageEncodedBytes??fe,maxImageDecodedBytes:e.maxImageDecodedBytes??Se,maxTotalMediaBytes:e.maxTotalMediaBytes??Pl}}function Tn(){return{totalEncodedBytes:0,keptImages:0,omittedImages:0,omittedReasons:{}}}function _n(e,t){e.omittedImages+=1,e.omittedReasons[t]=(e.omittedReasons[t]??0)+1}function wt(e,t,n,r){let o=To(n);if(e>o.maxImageEncodedBytes){let i={ok:!1,reason:"encoded_limit",message:`Image media exceeds the ${o.maxImageEncodedBytes} byte encoded limit`};return _n(r,i.reason),i}if(t>o.maxImageDecodedBytes){let i={ok:!1,reason:"decoded_limit",message:`Image media exceeds the ${o.maxImageDecodedBytes} byte decoded limit`};return _n(r,i.reason),i}if(r.totalEncodedBytes+e>o.maxTotalMediaBytes){let i={ok:!1,reason:"total_limit",message:`Image media exceeds the ${o.maxTotalMediaBytes} byte total media limit`};return _n(r,i.reason),i}return r.totalEncodedBytes+=e,r.keptImages+=1,null}function Ml(e){return e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57||e===43||e===47}function Dg(e){return e.length>0&&Co(e,0,e.length)}function Bg(e,t,n){let r=Ol(e),o=r.end-r.start;if(o===0)return{ok:!1,reason:"invalid_base64",message:"Generated media must contain valid base64"};let i=To(t);if(n.totalEncodedBytes+o>i.maxTotalMediaBytes)return{ok:!1,reason:"total_limit",message:`Generated media exceeds the ${i.maxTotalMediaBytes} byte total media limit`};if(!Co(e,r.start,r.end))return{ok:!1,reason:"invalid_base64",message:"Generated media must contain valid base64"};let s=e.slice(r.start,r.end);return n.totalEncodedBytes+=o,{ok:!0,base64:s,encodedBytes:o,decodedBytes:_o(s)}}function Co(e,t,n){let r=n-t;if(r%4!==0)return!1;let o=n;if(r>=2&&e.charCodeAt(n-2)===61&&e.charCodeAt(n-1)===61)o-=2;else if(r>=1&&e.charCodeAt(n-1)===61)o-=1;for(let i=t;i<o;i++)if(!Ml(e.charCodeAt(i)))return!1;for(let i=o;i<n;i++)if(e.charCodeAt(i)!==61)return!1;return!0}function Ug(e,t,n){return n-t>=5&&(e.charCodeAt(t)|32)===100&&(e.charCodeAt(t+1)|32)===97&&(e.charCodeAt(t+2)|32)===116&&(e.charCodeAt(t+3)|32)===97&&e.charCodeAt(t+4)===58}function Ol(e){let t=0,n=e.length;while(t<n&&/\s/.test(e[t]??""))t+=1;while(n>t&&/\s/.test(e[n-1]??""))n-=1;return{start:t,end:n}}function Zg(e,t,n){if(!Ug(e,t,n))return;let r=t+5,o=e.indexOf(",",r);if(o===-1||o>=n)return;if(o-r>128)return;let i=e.slice(r,o).toLowerCase(),s=";base64";if(!i.endsWith(s))return;let a=i.slice(0,-s.length);if(!a||a.includes(";"))return;return{mediaType:a,base64Start:o+1,base64End:n}}function zl(e,t,n={}){let r=n.maxEncodedBytes??fe,o=n.maxDecodedBytes??Se,i=new Set(n.supportedMediaTypes??vn),s=e?.toLowerCase(),a=Ol(t),{start:c,end:u}=a,l=Zg(t,a.start,a.end);if(l){if(s&&s!==l.mediaType)return{ok:!1,reason:"media_type_mismatch",message:`Image media type ${e} does not match data URL type ${l.mediaType}`};s=l.mediaType,c=l.base64Start,u=l.base64End}if(!s||!i.has(s))return{ok:!1,reason:"unsupported_media_type",message:`Unsupported image media type: ${e??"unknown"}`};let p=u-c;if(p===0)return{ok:!1,reason:"invalid_base64",message:"Image media must contain valid base64"};if(p>r)return{ok:!1,reason:"encoded_limit",message:`Image media exceeds the ${r} byte encoded limit`};if(!Co(t,c,u))return{ok:!1,reason:"invalid_base64",message:"Image media must contain valid base64"};let m=t.slice(c,u),f=_o(m);if(f>o)return{ok:!1,reason:"decoded_limit",message:`Image media exceeds the ${o} byte decoded limit`};return{ok:!0,mediaType:s,base64:m,encodedBytes:p,decodedBytes:f}}function Pt(e,t,n,r){let o=zl(e,t,{maxEncodedBytes:n.maxImageEncodedBytes,maxDecodedBytes:n.maxImageDecodedBytes});if(!o.ok)return _n(r,o.reason),o;let i=wt(o.encodedBytes,o.decodedBytes,n,r);if(i)return i;return o}function ae(e){return e.replace(/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g,"�")}var Mt="ERROR: EMPTY CONTENT",Fg="[image attached]",Hg="[generated image]";function jg(e){return`[generated ${e}]`}function Cn(e){return{type:"text",text:`[generated ${e.modality} unavailable to this model]`}}function ko(e,t){let n=e[e.length-1];if(t.role==="tool"&&n?.role==="tool"&&Array.isArray(n.content)&&Array.isArray(t.content)){n.content.push(...t.content);return}e.push(t)}function Vg(e){if(!Array.isArray(e)||e.length===0)return!1;return e.every((t)=>{if(!t||typeof t!=="object")return!1;let n=t;if(n.type==="text")return typeof n.text==="string";if(n.type==="image")return typeof n.data==="string"&&typeof n.mediaType==="string";return!1})}function Le(){return{type:"text",text:We}}function Nl(e){return wt(fe,0,{maxImageEncodedBytes:fe,maxImageDecodedBytes:Se},e)===null}function Ll(e){try{return new URL(e).protocol}catch{return}}function Eo(e,t){let n=Pt(e.mediaType,e.data,{maxImageEncodedBytes:fe,maxImageDecodedBytes:Se},t);if(!n.ok)return Le();return Dl(n.base64,n.mediaType)}function Dl(e,t){return{type:"file",data:{type:"data",data:e},mediaType:t}}function Ye(e,t){return{type:"file",data:e,mediaType:t??"image"}}function Ro(e,t){if(e.image instanceof URL){if(e.image.protocol==="data:"){let s=Pt(e.mediaType,e.image.href,{maxImageEncodedBytes:fe,maxImageDecodedBytes:Se},t);if(!s.ok)return Le();return Ye(`data:${s.mediaType};base64,${s.base64}`,s.mediaType)}if(e.image.protocol!=="http:"&&e.image.protocol!=="https:")return Le();if(!Nl(t))return Le();return Ye(e.image,e.mediaType)}if(typeof e.image==="string"){let s=Ll(e.image);if(s==="http:"||s==="https:"){if(!Nl(t))return Le();return Ye(e.image,e.mediaType)}let a=s==="data:",c=Pt(e.mediaType??(a?void 0:"image/png"),e.image,{maxImageEncodedBytes:fe,maxImageDecodedBytes:Se},t);if(!c.ok)return Le();return Ye(a?`data:${c.mediaType};base64,${c.base64}`:c.base64,c.mediaType)}let n=e.image.byteLength,r=vo(n),o=e.mediaType?.toLowerCase()??"image/png";if(!vn.includes(o)||wt(r,n,{maxImageEncodedBytes:fe,maxImageDecodedBytes:Se},t))return Le();return Ye(e.image,o)}function qg(e,t){if(!t)return!0;if(e.modality==="file")return e.mediaType==="application/pdf"&&t.includes("pdf");return t.includes(e.modality)}function $l(e,t,n){if(!qg(e,n))return Cn(e);if(e.modality==="image"){if(e.source.type==="artifact")return Cn(e);return Ro({type:"image",image:e.source.type==="url"?e.source.url:e.source.data,mediaType:e.mediaType},t)}if(e.source.type==="artifact")return Cn(e);if(e.source.type==="url"){let r=Ll(e.source.url);if(r!=="http:"&&r!=="https:"&&r!=="data:")return Cn(e)}return Ye(e.source.type==="url"?e.source.url:e.source.data,e.mediaType)}function Ao(e,t,n,r){let{hoistImages:o,inlineImagePlaceholder:i}=r;if(e==null||typeof e!=="object")return{value:e,changed:!1,mediaChanged:!1};if(Array.isArray(e)){let l=[],p=!1,m=!1;for(let f of e){if(f&&typeof f==="object"){let y=f;if(y.type==="image"&&typeof y.data==="string"&&typeof y.mediaType==="string"){if(!o){l.push(i),p=!0,m=!0;continue}let S={type:"image",data:y.data,mediaType:y.mediaType},v=Eo(S,n);if(v.type==="file")t.push({type:"image",data:v.data.data,mediaType:v.mediaType});else l.push(v.text);p=!0,m=!0;continue}if(y.type==="image"){l.push(We),p=!0,m=!0;continue}if(y.type==="text"&&typeof y.text==="string"){l.push(y.text),p=!0;continue}}let g=Ao(f,t,n,r);l.push(g.value),p||=g.changed,m||=g.mediaChanged}return{value:p?l:e,changed:p,mediaChanged:m}}let s=e;if(s.type==="image"){if(typeof s.data==="string"&&typeof s.mediaType==="string"){if(!o)return{value:i,changed:!0,mediaChanged:!0};let l={type:"image",data:s.data,mediaType:s.mediaType},p=Eo(l,n);if(p.type==="file")return t.push({type:"image",data:p.data.data,mediaType:p.mediaType}),{value:Fg,changed:!0,mediaChanged:!0};return{value:p.text,changed:!0,mediaChanged:!0}}return{value:We,changed:!0,mediaChanged:!0}}let a={},c=!1,u=!1;for(let[l,p]of Object.entries(s)){let m=Ao(p,t,n,r);a[l]=m.value,c||=m.changed,u||=m.mediaChanged}return{value:c?a:e,changed:c,mediaChanged:u}}function Ot(e){if(typeof e==="string")return ae(e);if(Array.isArray(e))return e.map((t)=>Ot(t));if(e!==null&&typeof e==="object"){let t=e,n={};for(let[r,o]of Object.entries(t))n[r]=Ot(o);return n}return e}function Bl(e,t=!1,n=Tn(),r){let o=r?.supportsImages??!0;if(typeof e==="string")return{type:t?"error-text":"text",value:ae(e)};if(!t&&Vg(e))return{type:"content",value:e.map((i)=>i.type==="image"?o?Eo(i,n):{type:"text",text:Je}:{type:"text",text:ae(i.text)})};if(e!==null&&typeof e==="object"){let i=[],s=Ao(e,i,n,{hoistImages:!t&&o,inlineImagePlaceholder:o?We:Je});if(!t&&i.length>0)return{type:"content",value:[{type:"text",text:typeof s.value==="string"?ae(s.value):JSON.stringify(Ot(s.value))},...i.map((c)=>Dl(c.data,c.mediaType))]};if(s.mediaChanged)return{type:t?"error-json":"json",value:Ot(s.value)}}if(e===null||typeof e==="boolean"||typeof e==="number"||typeof e==="object")return{type:t?"error-json":"json",value:Ot(e)};return{type:t?"error-text":"text",value:ae(String(e))}}function Gg(e,t,n){let r=n?.assistantToolCallArgKey??"input",o=n?.supportedInputModalities,i=!o||o.includes("image"),s=[],a=Tn(),c=[],u=()=>c.splice(0).map((p)=>p.type==="image"?i?Ro(p,a):{type:"text",text:Je}:$l(p.media,a,o));if(typeof e==="string"&&e.trim().length>0||Array.isArray(e)&&e.length>0)s.push({role:"system",content:typeof e==="string"?ae(e):e});for(let l of t){let p=l.content;if(typeof p==="string"){let y=l.role==="user"&&c.length>0?u():[];if(y.length>0){s.push({role:l.role,content:[{type:"text",text:p.trim().length>0?ae(p):Mt},...y]});continue}if(p.trim().length===0){s.push({role:l.role,content:[{type:"text",text:Mt}]});continue}s.push({role:l.role,content:ae(p)});continue}let m=[],f=[];if(p.length===0){s.push({role:l.role,content:[{type:"text",text:Mt}]});continue}for(let y of p)switch(y.type){case"text":m.push({type:"text",text:ae(y.text),...y.providerOptions?{providerOptions:y.providerOptions}:{}});break;case"reasoning":m.push({type:"reasoning",text:ae(y.text),...y.providerOptions?{providerOptions:y.providerOptions}:{}});break;case"image":if(l.role==="assistant")c.push(y),m.push({type:"text",text:Hg});else m.push(i?Ro(y,a):{type:"text",text:Je});break;case"media":if(l.role==="assistant")c.push(y),m.push({type:"text",text:jg(y.media.modality)});else m.push($l(y.media,a,o));break;case"file":m.push({type:"text",text:bo(y.path,ae(y.content))});break;case"tool-call":if(l.role==="assistant")m.push({type:"tool-call",toolCallId:y.toolCallId,toolName:y.toolName,[r]:y.input,...y.providerOptions?{providerOptions:y.providerOptions}:{}});break;case"tool-result":{f.push({type:"tool-result",toolCallId:y.toolCallId,toolName:y.toolName,output:Bl(y.output,y.isError??!1,a,{supportsImages:i})});break}}let g=f.length>0;if(l.role==="user"&&!g&&c.length>0)m.push(...u());if(m.length>0&&m.every((y)=>y.type==="text"&&typeof y.text==="string"&&y.text.trim().length===0))m.splice(0,m.length,{type:"text",text:Mt});if(m.length>0)ko(s,{role:l.role,content:m});if(g)ko(s,{role:"tool",content:f})}if(c.length>0)ko(s,{role:"user",content:u()});return s}var Qv=["show","hide","subscription"];function Ul(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function Kg(e,t){if(!e&&!t)return;let n=e?.metadata,r=t?.metadata,o={...e??{},...t??{}};if(Ul(n)&&Ul(r))o.metadata={...n,...r};return o}var nT=["web_search","image_generation"],rT=["web_search"];var zt={max:1,xhigh:0.95,high:0.8,medium:0.5,low:0.2,minimal:0.1,none:0},Wg=void 0;function Jg(e,t){if(typeof e==="string"&&e.toLowerCase()in zt)return e.toLowerCase();return t?void 0:void 0}function Zl(e,t){let n=typeof e==="string"?e.toLowerCase():void 0;if(n&&n in zt)return zt[n];if(t?.fallbackEffort)return zt[t.fallbackEffort];return}function Yg(e){let t=Zl(e.effort,{fallbackEffort:e.fallbackEffort});if(t===void 0)return;if(t<=0)return 0;let n=e.minimumBudget??1;if(e.maxBudget<n)return;let r=e.scaleTokens??e.maxBudget;return Math.min(Math.max(Math.floor(r*t),n),e.maxBudget)}function Xg(e){return e instanceof Error?{name:e.name,message:e.message}:e}var Qg=3;function Fl(e){return Math.max(1,Math.ceil(e/3))}var Hl=1600;function jl(){let e=0;return{replacer:(n,r)=>{if(r===null||typeof r!=="object"||r.type!=="image")return r;let o=r;if(typeof o.data==="string")return e+=1,{...o,data:""};if("image"in o)return e+=1,{...o,image:""};return r},imageCount:()=>e}}function Io(e){let t=new WeakSet;try{return JSON.stringify(e,(n,r)=>{if(typeof r==="bigint")return r.toString();if(typeof r!=="object"||r===null)return r;if(t.has(r))return"[Circular]";return t.add(r),r})??""}catch{return String(e??"")}}function eh(e){let{replacer:t,imageCount:n}=jl(),r,o=0;try{r=JSON.stringify({systemPrompt:e.systemPrompt,messages:e.messages,tools:e.tools},t),o=n()}catch{r=[Io(e.systemPrompt),Io(e.messages),Io(e.tools)].join(`
61
- `)}return Fl(r.length)+o*Hl}var th={debug:()=>{},log:()=>{},error:()=>{}};var uT=60,lT=1,dT=3600;function nh(e){return typeof e==="number"&&Number.isFinite(e)}function rh(e){return Math.min(Math.max(e,1),3600)}function pT(e){if(!nh(e))return 60;return rh(e)}function mT(e,t,n){let r=n?` (${n})`:"",o=Math.round(t/100)/10;return`MCP request to "${e}"${r} timed out after ${o}s. Increase the "timeout" field (in seconds) for this server in cline_mcp_settings.json.`}function oh(e){if(e instanceof Error)return e.message;return String(e)}function ih(e){if(e&&typeof e==="object"&&"code"in e&&typeof e.code==="string")return e.code;return""}class Ie extends Error{constructor(e,t){super(`${e} at position ${t}`);this.position=t}}function Vl(e){return/^[0-9A-Fa-f]$/.test(e)}function ve(e){return e>="0"&&e<="9"}function ql(e){return e>=" "}function Qe(e){return`,:[]/{}()
60
+ </file_content>`}function Eg(e,t="act"){return`<user_input mode="${t}">${e}</user_input>`}function Rg(e,t){return`<user_command slash="${t}">${e}</user_command>`}var Ag=/<user_input\b[^>]*\bmode="(act|plan|yolo)"/;function Ig(e){let t=Ag.exec(e??"");return t?t[1]:void 0}function wg(e,t){return`<mode_notice>The user switched from ${e} mode to ${t} mode before sending this message.</mode_notice>`}function Pg(){let e=null;return{record(t,n){if(t===n)return;if(e){e=e.from===n?null:{from:e.from,to:n};return}e={from:t,to:n}},consume(){let t=e;return e=null,t}}}function Mg(e,t){let n=e.trim(),r=new RegExp(`^<${t}\\b([^>]*)>([\\s\\S]*?)<\\/${t}>$`,"i").exec(n);if(!r)return;return{attrs:r[1]??"",content:r[2]??""}}function Og(e,t){return new RegExp(`${t}="([^"]+)"`,"i").exec(e)?.[1]?.trim()||void 0}function _l(e){if(!e?.trim())return;let t=Mg(e,"user_command");if(!t)return;let n=Og(t.attrs,"slash");if(!n)return;return{slash:n,content:t.content.trim()}}function Sl(e){if(!e?.trim())return"";let t=e.trim();for(let n of["user_input","user_command"]){let r=El(t,n);t=(r!==t?r:t.replace(new RegExp(`<${n}[^>]*>`,"g"),"")).trim()}return t}function vl(e){if(!e?.trim())return"";return Ng(e,"mode_notice").trim()}function Ng(e,t){let n=`<${t}>`,r=`</${t}>`,o=e,i=o.indexOf(n);while(i!==-1){let s=o.indexOf(r,i+n.length);if(s===-1)break;o=o.slice(0,i)+o.slice(s+r.length),i=o.indexOf(n,i)}return o}function xo(e){let t=vl(Sl(e)),n=_l(e);if(!n)return t;if(n.slash.toLowerCase()==="team"){let o=t.toLowerCase().startsWith("spawn a team of agents for the following task:")?t.slice(46).trim():t;return o?`/team ${o}`:"/team"}return t?`/${n.slash} ${t}`:`/${n.slash}`}var Cl=240,Tl=480;function kl(e,t){let n=e.replace(/\s+/gu," ").trim();if(n.length<=t)return n;return`${n.slice(0,t-1).trimEnd()}…`}function zg(e){return kl(xo(e),Cl)}function $g(e,t){let n=t?.trim()??"",r=e.toLowerCase(),o=r==="user"||r==="session"?xo(n):n;return kl(o,Tl)}function El(e,t){if(!e?.trim())return"";if(!t)return e;let n=new RegExp(`<${t}\\b[^>]*>([\\s\\S]*?)</${t}>`,"g");return e.replace(n,"$1")}var We="[media omitted: invalid or exceeds size limit]",Je="[Image attached — this model cannot view images]",Rl=I(["image","audio","video","file"]),Al=ao("type",[b({type:V("base64"),data:d().min(1)}),b({type:V("url"),url:d().url().refine((e)=>{let t=new URL(e).protocol;return t==="http:"||t==="https:"},"Generated media URLs must use HTTP or HTTPS")}),b({type:V("artifact"),artifactId:d().min(1)})]);function Il(e){if(e.startsWith("image/"))return"image";if(e.startsWith("audio/"))return"audio";if(e.startsWith("video/"))return"video";return"file"}var wl=b({id:d().min(1),modality:Rl,mediaType:d().min(1),source:Al,name:d().min(1).optional(),sizeBytes:x().int().nonnegative().optional()}).refine((e)=>Il(e.mediaType)===e.modality,{message:"Generated media modality must match its media type",path:["modality"]});function Lg(e){return wl.safeParse(e).success}function Dg(e){return Il(e)}var vn=["image/png","image/jpeg","image/gif","image/webp"],_o=5242880,fe=_o,_e=6291456,Pl=8388608;function Bg(e){return e.length}function So(e){let t=e.endsWith("==")?2:e.endsWith("=")?1:0;return Math.floor(e.length*3/4)-t}function Ug(e=_o){return Math.floor(e*3/4)}function vo(e){return Math.ceil(e/3)*4}function Co(e={}){return{maxImageEncodedBytes:e.maxImageEncodedBytes??fe,maxImageDecodedBytes:e.maxImageDecodedBytes??_e,maxTotalMediaBytes:e.maxTotalMediaBytes??Pl}}function Cn(){return{totalEncodedBytes:0,keptImages:0,omittedImages:0,omittedReasons:{}}}function Sn(e,t){e.omittedImages+=1,e.omittedReasons[t]=(e.omittedReasons[t]??0)+1}function wt(e,t,n,r){let o=Co(n);if(e>o.maxImageEncodedBytes){let i={ok:!1,reason:"encoded_limit",message:`Image media exceeds the ${o.maxImageEncodedBytes} byte encoded limit`};return Sn(r,i.reason),i}if(t>o.maxImageDecodedBytes){let i={ok:!1,reason:"decoded_limit",message:`Image media exceeds the ${o.maxImageDecodedBytes} byte decoded limit`};return Sn(r,i.reason),i}if(r.totalEncodedBytes+e>o.maxTotalMediaBytes){let i={ok:!1,reason:"total_limit",message:`Image media exceeds the ${o.maxTotalMediaBytes} byte total media limit`};return Sn(r,i.reason),i}return r.totalEncodedBytes+=e,r.keptImages+=1,null}function Ml(e){return e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57||e===43||e===47}function Zg(e){return e.length>0&&To(e,0,e.length)}function Fg(e,t,n){let r=Ol(e),o=r.end-r.start;if(o===0)return{ok:!1,reason:"invalid_base64",message:"Generated media must contain valid base64"};let i=Co(t);if(n.totalEncodedBytes+o>i.maxTotalMediaBytes)return{ok:!1,reason:"total_limit",message:`Generated media exceeds the ${i.maxTotalMediaBytes} byte total media limit`};if(!To(e,r.start,r.end))return{ok:!1,reason:"invalid_base64",message:"Generated media must contain valid base64"};let s=e.slice(r.start,r.end);return n.totalEncodedBytes+=o,{ok:!0,base64:s,encodedBytes:o,decodedBytes:So(s)}}function To(e,t,n){let r=n-t;if(r%4!==0)return!1;let o=n;if(r>=2&&e.charCodeAt(n-2)===61&&e.charCodeAt(n-1)===61)o-=2;else if(r>=1&&e.charCodeAt(n-1)===61)o-=1;for(let i=t;i<o;i++)if(!Ml(e.charCodeAt(i)))return!1;for(let i=o;i<n;i++)if(e.charCodeAt(i)!==61)return!1;return!0}function Hg(e,t,n){return n-t>=5&&(e.charCodeAt(t)|32)===100&&(e.charCodeAt(t+1)|32)===97&&(e.charCodeAt(t+2)|32)===116&&(e.charCodeAt(t+3)|32)===97&&e.charCodeAt(t+4)===58}function Ol(e){let t=0,n=e.length;while(t<n&&/\s/.test(e[t]??""))t+=1;while(n>t&&/\s/.test(e[n-1]??""))n-=1;return{start:t,end:n}}function jg(e,t,n){if(!Hg(e,t,n))return;let r=t+5,o=e.indexOf(",",r);if(o===-1||o>=n)return;if(o-r>128)return;let i=e.slice(r,o).toLowerCase(),s=";base64";if(!i.endsWith(s))return;let a=i.slice(0,-s.length);if(!a||a.includes(";"))return;return{mediaType:a,base64Start:o+1,base64End:n}}function Nl(e,t,n={}){let r=n.maxEncodedBytes??fe,o=n.maxDecodedBytes??_e,i=new Set(n.supportedMediaTypes??vn),s=e?.toLowerCase(),a=Ol(t),{start:c,end:u}=a,l=jg(t,a.start,a.end);if(l){if(s&&s!==l.mediaType)return{ok:!1,reason:"media_type_mismatch",message:`Image media type ${e} does not match data URL type ${l.mediaType}`};s=l.mediaType,c=l.base64Start,u=l.base64End}if(!s||!i.has(s))return{ok:!1,reason:"unsupported_media_type",message:`Unsupported image media type: ${e??"unknown"}`};let p=u-c;if(p===0)return{ok:!1,reason:"invalid_base64",message:"Image media must contain valid base64"};if(p>r)return{ok:!1,reason:"encoded_limit",message:`Image media exceeds the ${r} byte encoded limit`};if(!To(t,c,u))return{ok:!1,reason:"invalid_base64",message:"Image media must contain valid base64"};let m=t.slice(c,u),f=So(m);if(f>o)return{ok:!1,reason:"decoded_limit",message:`Image media exceeds the ${o} byte decoded limit`};return{ok:!0,mediaType:s,base64:m,encodedBytes:p,decodedBytes:f}}function Pt(e,t,n,r){let o=Nl(e,t,{maxEncodedBytes:n.maxImageEncodedBytes,maxDecodedBytes:n.maxImageDecodedBytes});if(!o.ok)return Sn(r,o.reason),o;let i=wt(o.encodedBytes,o.decodedBytes,n,r);if(i)return i;return o}function ae(e){return e.replace(/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g,"�")}var Mt="ERROR: EMPTY CONTENT",Vg="[image attached]",qg="[generated image]";function Gg(e){return`[generated ${e}]`}function Tn(e){return{type:"text",text:`[generated ${e.modality} unavailable to this model]`}}function ko(e,t){let n=e[e.length-1];if(t.role==="tool"&&n?.role==="tool"&&Array.isArray(n.content)&&Array.isArray(t.content)){n.content.push(...t.content);return}e.push(t)}function Kg(e){if(!Array.isArray(e)||e.length===0)return!1;return e.every((t)=>{if(!t||typeof t!=="object")return!1;let n=t;if(n.type==="text")return typeof n.text==="string";if(n.type==="image")return typeof n.data==="string"&&typeof n.mediaType==="string";return!1})}function Le(){return{type:"text",text:We}}function zl(e){return wt(fe,0,{maxImageEncodedBytes:fe,maxImageDecodedBytes:_e},e)===null}function Ll(e){try{return new URL(e).protocol}catch{return}}function Eo(e,t){let n=Pt(e.mediaType,e.data,{maxImageEncodedBytes:fe,maxImageDecodedBytes:_e},t);if(!n.ok)return Le();return Dl(n.base64,n.mediaType)}function Dl(e,t){return{type:"file",data:{type:"data",data:e},mediaType:t}}function Ye(e,t){return{type:"file",data:e,mediaType:t??"image"}}function Ro(e,t){if(e.image instanceof URL){if(e.image.protocol==="data:"){let s=Pt(e.mediaType,e.image.href,{maxImageEncodedBytes:fe,maxImageDecodedBytes:_e},t);if(!s.ok)return Le();return Ye(`data:${s.mediaType};base64,${s.base64}`,s.mediaType)}if(e.image.protocol!=="http:"&&e.image.protocol!=="https:")return Le();if(!zl(t))return Le();return Ye(e.image,e.mediaType)}if(typeof e.image==="string"){let s=Ll(e.image);if(s==="http:"||s==="https:"){if(!zl(t))return Le();return Ye(e.image,e.mediaType)}let a=s==="data:",c=Pt(e.mediaType??(a?void 0:"image/png"),e.image,{maxImageEncodedBytes:fe,maxImageDecodedBytes:_e},t);if(!c.ok)return Le();return Ye(a?`data:${c.mediaType};base64,${c.base64}`:c.base64,c.mediaType)}let n=e.image.byteLength,r=vo(n),o=e.mediaType?.toLowerCase()??"image/png";if(!vn.includes(o)||wt(r,n,{maxImageEncodedBytes:fe,maxImageDecodedBytes:_e},t))return Le();return Ye(e.image,o)}function Wg(e,t){if(!t)return!0;if(e.modality==="file")return e.mediaType==="application/pdf"&&t.includes("pdf");return t.includes(e.modality)}function $l(e,t,n){if(!Wg(e,n))return Tn(e);if(e.modality==="image"){if(e.source.type==="artifact")return Tn(e);return Ro({type:"image",image:e.source.type==="url"?e.source.url:e.source.data,mediaType:e.mediaType},t)}if(e.source.type==="artifact")return Tn(e);if(e.source.type==="url"){let r=Ll(e.source.url);if(r!=="http:"&&r!=="https:"&&r!=="data:")return Tn(e)}return Ye(e.source.type==="url"?e.source.url:e.source.data,e.mediaType)}function Ao(e,t,n,r){let{hoistImages:o,inlineImagePlaceholder:i}=r;if(e==null||typeof e!=="object")return{value:e,changed:!1,mediaChanged:!1};if(Array.isArray(e)){let l=[],p=!1,m=!1;for(let f of e){if(f&&typeof f==="object"){let y=f;if(y.type==="image"&&typeof y.data==="string"&&typeof y.mediaType==="string"){if(!o){l.push(i),p=!0,m=!0;continue}let _={type:"image",data:y.data,mediaType:y.mediaType},v=Eo(_,n);if(v.type==="file")t.push({type:"image",data:v.data.data,mediaType:v.mediaType});else l.push(v.text);p=!0,m=!0;continue}if(y.type==="image"){l.push(We),p=!0,m=!0;continue}if(y.type==="text"&&typeof y.text==="string"){l.push(y.text),p=!0;continue}}let g=Ao(f,t,n,r);l.push(g.value),p||=g.changed,m||=g.mediaChanged}return{value:p?l:e,changed:p,mediaChanged:m}}let s=e;if(s.type==="image"){if(typeof s.data==="string"&&typeof s.mediaType==="string"){if(!o)return{value:i,changed:!0,mediaChanged:!0};let l={type:"image",data:s.data,mediaType:s.mediaType},p=Eo(l,n);if(p.type==="file")return t.push({type:"image",data:p.data.data,mediaType:p.mediaType}),{value:Vg,changed:!0,mediaChanged:!0};return{value:p.text,changed:!0,mediaChanged:!0}}return{value:We,changed:!0,mediaChanged:!0}}let a={},c=!1,u=!1;for(let[l,p]of Object.entries(s)){let m=Ao(p,t,n,r);a[l]=m.value,c||=m.changed,u||=m.mediaChanged}return{value:c?a:e,changed:c,mediaChanged:u}}function Ot(e){if(typeof e==="string")return ae(e);if(Array.isArray(e))return e.map((t)=>Ot(t));if(e!==null&&typeof e==="object"){let t=e,n={};for(let[r,o]of Object.entries(t))n[r]=Ot(o);return n}return e}function Bl(e,t=!1,n=Cn(),r){let o=r?.supportsImages??!0;if(typeof e==="string")return{type:t?"error-text":"text",value:ae(e)};if(!t&&Kg(e))return{type:"content",value:e.map((i)=>i.type==="image"?o?Eo(i,n):{type:"text",text:Je}:{type:"text",text:ae(i.text)})};if(e!==null&&typeof e==="object"){let i=[],s=Ao(e,i,n,{hoistImages:!t&&o,inlineImagePlaceholder:o?We:Je});if(!t&&i.length>0)return{type:"content",value:[{type:"text",text:typeof s.value==="string"?ae(s.value):JSON.stringify(Ot(s.value))},...i.map((c)=>Dl(c.data,c.mediaType))]};if(s.mediaChanged)return{type:t?"error-json":"json",value:Ot(s.value)}}if(e===null||typeof e==="boolean"||typeof e==="number"||typeof e==="object")return{type:t?"error-json":"json",value:Ot(e)};return{type:t?"error-text":"text",value:ae(String(e))}}function Jg(e,t,n){let r=n?.assistantToolCallArgKey??"input",o=n?.supportedInputModalities,i=!o||o.includes("image"),s=[],a=Cn(),c=[],u=()=>c.splice(0).map((p)=>p.type==="image"?i?Ro(p,a):{type:"text",text:Je}:$l(p.media,a,o));if(typeof e==="string"&&e.trim().length>0||Array.isArray(e)&&e.length>0)s.push({role:"system",content:typeof e==="string"?ae(e):e});for(let l of t){let p=l.content;if(typeof p==="string"){let y=l.role==="user"&&c.length>0?u():[];if(y.length>0){s.push({role:l.role,content:[{type:"text",text:p.trim().length>0?ae(p):Mt},...y]});continue}if(p.trim().length===0){s.push({role:l.role,content:[{type:"text",text:Mt}]});continue}s.push({role:l.role,content:ae(p)});continue}let m=[],f=[];if(p.length===0){s.push({role:l.role,content:[{type:"text",text:Mt}]});continue}for(let y of p)switch(y.type){case"text":m.push({type:"text",text:ae(y.text),...y.providerOptions?{providerOptions:y.providerOptions}:{}});break;case"reasoning":m.push({type:"reasoning",text:ae(y.text),...y.providerOptions?{providerOptions:y.providerOptions}:{}});break;case"image":if(l.role==="assistant")c.push(y),m.push({type:"text",text:qg});else m.push(i?Ro(y,a):{type:"text",text:Je});break;case"media":if(l.role==="assistant")c.push(y),m.push({type:"text",text:Gg(y.media.modality)});else m.push($l(y.media,a,o));break;case"file":m.push({type:"text",text:bo(y.path,ae(y.content))});break;case"tool-call":if(l.role==="assistant")m.push({type:"tool-call",toolCallId:y.toolCallId,toolName:y.toolName,[r]:y.input,...y.providerOptions?{providerOptions:y.providerOptions}:{}});break;case"tool-result":{f.push({type:"tool-result",toolCallId:y.toolCallId,toolName:y.toolName,output:Bl(y.output,y.isError??!1,a,{supportsImages:i})});break}}let g=f.length>0;if(l.role==="user"&&!g&&c.length>0)m.push(...u());if(m.length>0&&m.every((y)=>y.type==="text"&&typeof y.text==="string"&&y.text.trim().length===0))m.splice(0,m.length,{type:"text",text:Mt});if(m.length>0)ko(s,{role:l.role,content:m});if(g)ko(s,{role:"tool",content:f})}if(c.length>0)ko(s,{role:"user",content:u()});return s}var cC=["show","hide","subscription"];function Ul(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function Yg(e,t){if(!e&&!t)return;let n=e?.metadata,r=t?.metadata,o={...e??{},...t??{}};if(Ul(n)&&Ul(r))o.metadata={...n,...r};return o}var dC=["web_search","image_generation"],pC=["web_search"];var Nt={max:1,xhigh:0.95,high:0.8,medium:0.5,low:0.2,minimal:0.1,none:0},Xg=void 0;function Qg(e,t){if(typeof e==="string"&&e.toLowerCase()in Nt)return e.toLowerCase();return t?void 0:void 0}function Zl(e,t){let n=typeof e==="string"?e.toLowerCase():void 0;if(n&&n in Nt)return Nt[n];if(t?.fallbackEffort)return Nt[t.fallbackEffort];return}function eh(e){let t=Zl(e.effort,{fallbackEffort:e.fallbackEffort});if(t===void 0)return;if(t<=0)return 0;let n=e.minimumBudget??1;if(e.maxBudget<n)return;let r=e.scaleTokens??e.maxBudget;return Math.min(Math.max(Math.floor(r*t),n),e.maxBudget)}function th(e){return e instanceof Error?{name:e.name,message:e.message}:e}var nh=3;function Fl(e){return Math.max(1,Math.ceil(e/3))}var Hl=1600;function jl(){let e=0;return{replacer:(n,r)=>{if(r===null||typeof r!=="object"||r.type!=="image")return r;let o=r;if(typeof o.data==="string")return e+=1,{...o,data:""};if("image"in o)return e+=1,{...o,image:""};return r},imageCount:()=>e}}function Io(e){let t=new WeakSet;try{return JSON.stringify(e,(n,r)=>{if(typeof r==="bigint")return r.toString();if(typeof r!=="object"||r===null)return r;if(t.has(r))return"[Circular]";return t.add(r),r})??""}catch{return String(e??"")}}function rh(e){let{replacer:t,imageCount:n}=jl(),r,o=0;try{r=JSON.stringify({systemPrompt:e.systemPrompt,messages:e.messages,tools:e.tools},t),o=n()}catch{r=[Io(e.systemPrompt),Io(e.messages),Io(e.tools)].join(`
61
+ `)}return Fl(r.length)+o*Hl}var oh={debug:()=>{},log:()=>{},error:()=>{}};var bC=60,xC=1,_C=3600;function ih(e){return typeof e==="number"&&Number.isFinite(e)}function sh(e){return Math.min(Math.max(e,1),3600)}function SC(e){if(!ih(e))return 60;return sh(e)}function vC(e,t,n){let r=n?` (${n})`:"",o=Math.round(t/100)/10;return`MCP request to "${e}"${r} timed out after ${o}s. Increase the "timeout" field (in seconds) for this server in cline_mcp_settings.json.`}function ah(e){if(e instanceof Error)return e.message;return String(e)}function ch(e){if(e&&typeof e==="object"&&"code"in e&&typeof e.code==="string")return e.code;return""}class Ie extends Error{constructor(e,t){super(`${e} at position ${t}`);this.position=t}}function Vl(e){return/^[0-9A-Fa-f]$/.test(e)}function ve(e){return e>="0"&&e<="9"}function ql(e){return e>=" "}function Qe(e){return`,:[]/{}()
62
62
  +`.includes(e)}function wo(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"||e==="_"||e==="$"}function kn(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"||e==="_"||e==="$"||e>="0"&&e<="9"}var Po=/^(http|https|ftp|mailto|file|data|irc):\/\/$/,Mo=/^[A-Za-z0-9-._~:/?#@!$&'()*+;=]$/;function Oo(e){return`,[]/{}
63
- +`.includes(e)}function zo(e){return et(e)||sh.test(e)}var sh=/^[[{\w-]$/;function No(e){return e===`
64
- `||e==="\r"||e==="\t"||e==="\b"||e==="\f"}function _e(e,t){let n=e.charCodeAt(t);return n===32||n===10||n===9||n===13}function Gl(e,t){let n=e.charCodeAt(t);return n===32||n===9||n===13}function Kl(e,t){let n=e.charCodeAt(t);return n===160||n===6158||n>=8192&&n<=8203||n===8239||n===8287||n===12288||n===65279}function et(e){return $o(e)||En(e)}function $o(e){return e==='"'||e==="“"||e==="”"}function Lo(e){return e==='"'}function En(e){return e==="'"||e==="‘"||e==="’"||e==="`"||e==="´"}function Do(e){return e==="'"}function tt(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,r=e.lastIndexOf(t);return r!==-1?e.substring(0,r)+(n?"":e.substring(r+1)):e}function ce(e,t){let n=e.length;if(!_e(e,n-1))return e+t;while(_e(e,n-1))n--;return e.substring(0,n)+t+e.substring(n)}function Wl(e,t,n){return e.substring(0,t)+e.substring(t+n)}function Jl(e){return/[,\n][ \t\r]*$/.test(e)}var ah={"&quot;":'"',"&amp;":"&","&lt;":"<","&gt;":">","&apos;":"'"},Bo=12;function Uo(e){if(e.charAt(0)!=="&")return null;let t=e.indexOf(";");if(t===-1)return null;let n=e.substring(0,t+1),r=ah[n];if(r!==void 0)return{char:r,length:n.length};if(e.charAt(1)==="#"){let o=e.substring(2,t),i=o.charAt(0)==="x"||o.charAt(0)==="X",s=i?o.substring(1):o;if(s.length>0){let a=Number.parseInt(s,i?16:10);if(!Number.isNaN(a)&&a>=0&&a<=1114111)return{char:String.fromCodePoint(a),length:n.length}}}return null}function Yl(e){return e!==null&&e.char==='"'}function Xl(e){return e!==null&&e.char==="'"}function Xe(e,t){let n=0;for(let r=0;r<e.length;r++)if(e.charAt(r)===t)n++;return n}function Ql(e,t){switch(t){case")":return Xe(e,"(")>Xe(e,")");case"]":return Xe(e,"[")>Xe(e,"]");case"}":return Xe(e,"{")>Xe(e,"}");default:return!1}}var ed={"\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t"},ch={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:`
65
- `,r:"\r",t:"\t"};function Zo(e){let t=0,n="";if(u(["```","[```","{```"]),!i())bp();u(["```","```]","```}"]);let o=p(",");if(o)s();if(zo(e[t])&&Jl(n)){if(!o)n=ce(n,",");v()}else if(o)n=tt(n,",");while(e[t]==="}"||e[t]==="]")t++,s();if(t>=e.length)return n;lt();function i(){s();let T=y()||S()||k()||R()||B()||J(!1)||Te();return s(),T}function s(){let T=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0,C=t,O=a(T);do if(O=c(),O)O=a(T);while(O);return t>C}function a(T){let C=T?_e:Gl,O="";while(!0)if(C(e,t))O+=e[t],t++;else if(Kl(e,t))O+=" ",t++;else break;if(O.length>0)return n+=O,!0;return!1}function c(){if(e[t]==="/"&&e[t+1]==="*"){while(t<e.length&&!uh(e,t))t++;return t+=2,!0}if(e[t]==="/"&&e[t+1]==="/"){while(t<e.length&&e[t]!==`
66
- `)t++;return!0}return!1}function u(T){if(l(T)){if(wo(e[t]))while(t<e.length&&kn(e[t]))t++;return s(),!0}return!1}function l(T){a(!0);for(let C of T){let O=t+C.length;if(e.slice(t,O)===C)return t=O,!0}return!1}function p(T){if(e[t]===T)return n+=e[t],t++,!0;return!1}function m(T){if(e[t]===T)return t++,!0;return!1}function f(){return m("\\")}function g(){if(s(),e[t]==="."&&e[t+1]==="."&&e[t+2]===".")return t+=3,s(),m(","),!0;return!1}function y(){if(e[t]==="{"){if(n+="{",t++,s(),m(","))s();let T=!0;while(t<e.length&&e[t]!=="}"){let C;if(!T){if(C=p(","),!C)n=ce(n,",");s()}else C=!0;if(g(),!(k()||J(!0))){if(e[t]==="}"||e[t]==="{"||e[t]==="]"||e[t]==="["||e[t]===void 0){if(!T)n=tt(n,",")}else xp();break}s();let he=p(":"),Be=t>=e.length;if(!he)if(zo(e[t])||Be)n=ce(n,":");else xi();if(!i())if(he||Be)n+="null";else xi();T=!1}if(e[t]==="}")n+="}",t++;else n=ce(n,"}");return!0}return!1}function S(){if(e[t]==="["){if(n+="[",t++,s(),m(","))s();let T=!0;while(t<e.length&&e[t]!=="]"){if(!T){if(!p(","))n=ce(n,",")}if(g(),!i()){if(!T)n=tt(n,",");break}T=!1}if(e[t]==="]")n+="]",t++;else n=ce(n,"]");return!0}return!1}function v(){let T=!0,C=!0;while(C){if(!T){if(!p(","))n=ce(n,",")}else T=!1;C=i()}if(!C)n=tt(n,",");n=`[
63
+ +`.includes(e)}function No(e){return et(e)||uh.test(e)}var uh=/^[[{\w-]$/;function zo(e){return e===`
64
+ `||e==="\r"||e==="\t"||e==="\b"||e==="\f"}function Se(e,t){let n=e.charCodeAt(t);return n===32||n===10||n===9||n===13}function Gl(e,t){let n=e.charCodeAt(t);return n===32||n===9||n===13}function Kl(e,t){let n=e.charCodeAt(t);return n===160||n===6158||n>=8192&&n<=8203||n===8239||n===8287||n===12288||n===65279}function et(e){return $o(e)||En(e)}function $o(e){return e==='"'||e==="“"||e==="”"}function Lo(e){return e==='"'}function En(e){return e==="'"||e==="‘"||e==="’"||e==="`"||e==="´"}function Do(e){return e==="'"}function tt(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,r=e.lastIndexOf(t);return r!==-1?e.substring(0,r)+(n?"":e.substring(r+1)):e}function ce(e,t){let n=e.length;if(!Se(e,n-1))return e+t;while(Se(e,n-1))n--;return e.substring(0,n)+t+e.substring(n)}function Wl(e,t,n){return e.substring(0,t)+e.substring(t+n)}function Jl(e){return/[,\n][ \t\r]*$/.test(e)}var lh={"&quot;":'"',"&amp;":"&","&lt;":"<","&gt;":">","&apos;":"'"},Bo=12;function Uo(e){if(e.charAt(0)!=="&")return null;let t=e.indexOf(";");if(t===-1)return null;let n=e.substring(0,t+1),r=lh[n];if(r!==void 0)return{char:r,length:n.length};if(e.charAt(1)==="#"){let o=e.substring(2,t),i=o.charAt(0)==="x"||o.charAt(0)==="X",s=i?o.substring(1):o;if(s.length>0){let a=Number.parseInt(s,i?16:10);if(!Number.isNaN(a)&&a>=0&&a<=1114111)return{char:String.fromCodePoint(a),length:n.length}}}return null}function Yl(e){return e!==null&&e.char==='"'}function Xl(e){return e!==null&&e.char==="'"}function Xe(e,t){let n=0;for(let r=0;r<e.length;r++)if(e.charAt(r)===t)n++;return n}function Ql(e,t){switch(t){case")":return Xe(e,"(")>Xe(e,")");case"]":return Xe(e,"[")>Xe(e,"]");case"}":return Xe(e,"{")>Xe(e,"}");default:return!1}}var ed={"\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t"},dh={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:`
65
+ `,r:"\r",t:"\t"};function Zo(e){let t=0,n="";if(u(["```","[```","{```"]),!i())Sp();u(["```","```]","```}"]);let o=p(",");if(o)s();if(No(e[t])&&Jl(n)){if(!o)n=ce(n,",");v()}else if(o)n=tt(n,",");while(e[t]==="}"||e[t]==="]")t++,s();if(t>=e.length)return n;lt();function i(){s();let C=y()||_()||k()||R()||B()||J(!1)||Ce();return s(),C}function s(){let C=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0,T=t,O=a(C);do if(O=c(),O)O=a(C);while(O);return t>T}function a(C){let T=C?Se:Gl,O="";while(!0)if(T(e,t))O+=e[t],t++;else if(Kl(e,t))O+=" ",t++;else break;if(O.length>0)return n+=O,!0;return!1}function c(){if(e[t]==="/"&&e[t+1]==="*"){while(t<e.length&&!ph(e,t))t++;return t+=2,!0}if(e[t]==="/"&&e[t+1]==="/"){while(t<e.length&&e[t]!==`
66
+ `)t++;return!0}return!1}function u(C){if(l(C)){if(wo(e[t]))while(t<e.length&&kn(e[t]))t++;return s(),!0}return!1}function l(C){a(!0);for(let T of C){let O=t+T.length;if(e.slice(t,O)===T)return t=O,!0}return!1}function p(C){if(e[t]===C)return n+=e[t],t++,!0;return!1}function m(C){if(e[t]===C)return t++,!0;return!1}function f(){return m("\\")}function g(){if(s(),e[t]==="."&&e[t+1]==="."&&e[t+2]===".")return t+=3,s(),m(","),!0;return!1}function y(){if(e[t]==="{"){if(n+="{",t++,s(),m(","))s();let C=!0;while(t<e.length&&e[t]!=="}"){let T;if(!C){if(T=p(","),!T)n=ce(n,",");s()}else T=!0;if(g(),!(k()||J(!0))){if(e[t]==="}"||e[t]==="{"||e[t]==="]"||e[t]==="["||e[t]===void 0){if(!C)n=tt(n,",")}else vp();break}s();let he=p(":"),Be=t>=e.length;if(!he)if(No(e[t])||Be)n=ce(n,":");else xi();if(!i())if(he||Be)n+="null";else xi();C=!1}if(e[t]==="}")n+="}",t++;else n=ce(n,"}");return!0}return!1}function _(){if(e[t]==="["){if(n+="[",t++,s(),m(","))s();let C=!0;while(t<e.length&&e[t]!=="]"){if(!C){if(!p(","))n=ce(n,",")}if(g(),!i()){if(!C)n=tt(n,",");break}C=!1}if(e[t]==="]")n+="]",t++;else n=ce(n,"]");return!0}return!1}function v(){let C=!0,T=!0;while(T){if(!C){if(!p(","))n=ce(n,",")}else C=!1;T=i()}if(!T)n=tt(n,",");n=`[
67
67
  ${n}
68
- ]`}function k(){let T=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,C=arguments.length>1&&arguments[1]!==void 0?arguments[1]:-1,O=e[t]==="\\";if(O){if(t++,!et(e[t]))lt()}let he=e[t]==="&"?Uo(e.slice(t,t+Bo)):null,Be=Yl(he)||Xl(he);if(et(e[t])||Be){let Si=Lo(e[t])?Lo:Do(e[t])?Do:En(e[t])?En:$o,Lt=t,Dt=n.length,L='"';t+=Be&&he?he.length:1;while(!0){if(t>=e.length){let H=Me(t-1);if(!T&&Qe(e.charAt(H)))return t=Lt,n=n.substring(0,Dt),k(!0);return L=ce(L,'"'),n+=L,!0}if(t===C)return L=ce(L,'"'),n+=L,!0;let ye=Be&&e[t]==="&"?Uo(e.slice(t,t+Bo)):null;if(ye&&he?ye.char===he.char:Si(e[t])){let H=t,Nn=L.length;if(L+='"',t+=ye?ye.length:1,n+=L,s(!1),T||t>=e.length||Qe(e[t])&&!Ql(L,e[t])||et(e[t])&&!ct(t)||ve(e[t]))return M(),!0;if(e[t]==="\\")lt();let Ce=Me(H-1),_i=e.charAt(Ce);if(_i===",")return t=Lt,n=n.substring(0,Dt),k(!1,Ce);if(Qe(_i))return t=Lt,n=n.substring(0,Dt),k(!0);n=n.substring(0,Dt),t=H+(ye?ye.length:1),L=`${L.substring(0,Nn)}\\${L.substring(Nn)}`}else if(T&&Oo(e[t])){if(e[t-1]===":"&&Po.test(e.substring(Lt+1,t+2)))while(t<e.length&&Mo.test(e[t]))L+=e[t],t++;return L=ce(L,'"'),n+=L,M(),!0}else if(ye){let H=ye.char;if(H==='"')L+="\\\"";else if(No(H))L+=ed[H];else L+=H;t+=ye.length}else if(e[t]==="\\"){let H=e.charAt(t+1);if(ch[H]!==void 0)L+=e.slice(t,t+2),t+=2;else if(H==="u"){let Ce=2;while(Ce<6&&Vl(e[t+Ce]))Ce++;if(Ce===6)L+=e.slice(t,t+6),t+=6;else if(t+Ce>=e.length)t=e.length;else Sp()}else if(H===`
69
- `)L+="\\n",t+=2;else L+=H,t+=2}else{let H=e.charAt(t);if(H==='"'&&e[t-1]!=="\\")L+=`\\${H}`,t++;else if(No(H))L+=ed[H],t++;else{if(!ql(H))zn(H);L+=H,t++}}if(O)f()}}return!1}function M(){let T=!1;s();while(e[t]==="+"){T=!0,t++,s(),n=tt(n,'"',!0);let C=n.length;if(k())n=Wl(n,C,1);else n=ce(n,'"')}return T}function R(){let T=t,C="",O=!1;if(e[t]==="-"){if(C+=e[t],t++,!ve(e[t])&&ut())C+="0"}if(e[t]==="0"&&ve(e[t+1]))O=!0;while(ve(e[t]))C+=e[t],t++;if(e[t]==="."){if(C===""||C==="-")C+="0";if(C+=e[t],t++,!ve(e[t]))C+="0";while(ve(e[t]))C+=e[t],t++}if(t>T){if(e[t]==="e"||e[t]==="E"){if(C==="-")O=!0;if(C+=e[t],t++,e[t]==="-"||e[t]==="+")C+=e[t],t++;if(!ve(e[t]))C+="0";while(ve(e[t]))C+=e[t],t++}if(!ut())return t=T,!1;return n+=O?`"${e.substring(T,t)}"`:C,!0}return!1}function B(){return A("true","true")||A("false","false")||A("null","null")||A("True","true")||A("False","false")||A("None","null")}function A(T,C){if(e.slice(t,t+T.length)===T&&!kn(e[t+T.length]))return n+=C,t+=T.length,!0;return!1}function J(T){let C=t;if(wo(e[t])){while(t<e.length&&kn(e[t]))t++;let O=t;while(_e(e,O))O++;if(e[O]==="("){if(t=O+1,i(),e[t]===")"){if(t++,e[t]===";")t++}return!0}}while(t<e.length&&!Oo(e[t])&&!et(e[t])&&(!T||e[t]!==":"))t++;if(e[t-1]===":"&&Po.test(e.substring(C,t+2)))while(t<e.length&&Mo.test(e[t]))t++;if(t>C){while(_e(e,t-1)&&t>0)t--;let O=e.slice(C,t);if(n+=O==="undefined"?"null":JSON.stringify(O),e[t]==='"')t++;return!0}}function Te(){if(e[t]==="/"){let T=t;t++;while(t<e.length&&(e[t]!=="/"||e[t-1]==="\\"))t++;return t++,n+=JSON.stringify(e.substring(T,t)),!0}}function Me(T){let C=T;while(C>0&&_e(e,C))C--;return C}function ct(T){let C=T+1;while(C<e.length&&_e(e,C))C++;return C>=e.length||Qe(e[C])}function ut(){return t>=e.length||Qe(e[t])||_e(e,t)}function zn(T){throw new Ie(`Invalid character ${JSON.stringify(T)}`,t)}function lt(){throw new Ie(`Unexpected character ${JSON.stringify(e[t])}`,t)}function bp(){throw new Ie("Unexpected end of json string",e.length)}function xp(){throw new Ie("Object key expected",t)}function xi(){throw new Ie("Colon expected",t)}function Sp(){let T=e.slice(t,t+6);throw new Ie(`Invalid unicode character "${T}"`,t)}}function uh(e,t){return e[t]==="*"&&e[t+1]==="/"}function lh(e){let t=!1,n=!1,r=!1;for(let o=0;o<e.length;o+=1){let i=e[o];if(r){r=!1;continue}if(i==="\\"){r=!0;continue}if(!n&&i==='"')t=!t;else if(!t&&i==="'")n=!n}return t||n}var dh=/^\{\s*"([A-Za-z0-9_.$-]+)"\s*:\s*([\s\S]+?)\s*\}$/;function ph(e){let t=e.match(dh);if(!t)return;let[,n,r]=t,o=r.trim();if(!o)return;let i=o[0];if(i==='"'||i==="{"||i==="["||o==="true"||o==="false"||o==="null"||Number.isFinite(Number(o)))return;return JSON.parse(`{"${n}":${JSON.stringify(o)}}`)}function mh(e){if(typeof e!=="string")return e;let t=e.trimStart();if(t[0]!=="{"&&t[0]!=="[")return e;try{return JSON.parse(t)}catch{}if(!lh(t))try{return JSON.parse(Zo(t))}catch{}return ph(t)??e}function fh(e){let t=new WeakSet;try{return JSON.stringify(e,(r,o)=>{if(typeof o==="bigint")return o.toString();if(o&&typeof o==="object"){if(t.has(o))return"[Circular]";t.add(o)}return o})??"null"}catch{return String(e)}}function gh(e){try{return JSON.parse(e)}catch{return}}function nt(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function hh(e){let t=e.type;if(typeof t==="string")return[t];return Array.isArray(t)?t.filter((n)=>typeof n==="string"):[]}function Fo(e,t){if(hh(e).includes(t))return!0;for(let r of["anyOf","oneOf","allOf"]){let o=e[r];if(Array.isArray(o)&&o.some((i)=>nt(i)&&Fo(i,t)))return!0}return!1}function yh(e,t){if(typeof e!=="string")return e;let n=e.trim(),r=Fo(t,"array"),o=Fo(t,"object");if((!r||!n.startsWith("["))&&(!o||!n.startsWith("{")))return e;try{let i=JSON.parse(n);if(Array.isArray(i))return r?i:e;if(nt(i))return o?i:e;return e}catch{return e}}function Ho(e,t){let n=yh(e,t);if(Array.isArray(n)){let s=t.items;if(!nt(s))return n;let a=!1,c=n.map((u)=>{let l=Ho(u,s);return a||=l!==u,l});return a?c:n}if(!nt(n))return n;let r=t.properties;if(!nt(r))return n;let o=!1,i={...n};for(let[s,a]of Object.entries(r)){if(!(s in n)||!nt(a))continue;let c=Ho(n[s],a);if(c!==n[s])i[s]=c,o=!0}return o?i:n}function bh(e){if(typeof globalThis.atob==="function")try{let t=globalThis.atob(e),n=Uint8Array.from(t,(r)=>r.charCodeAt(0));return new TextDecoder().decode(n)}catch{return null}if(typeof Buffer<"u")try{return Buffer.from(e,"base64").toString("utf8")}catch{return null}return null}function xh(e){let t=e?.trim();if(!t)return null;try{let n=t.split(".");if(n.length!==3)return null;let r=n[1];if(!r)return null;let o=r.replace(/-/g,"+").replace(/_/g,"/"),i=o.padEnd(o.length+(4-o.length%4)%4,"="),s=bh(i);return s?JSON.parse(s):null}catch{return null}}function Sh(e){return Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0))}import _h from"node:path";function vh(e){return e.split(_h.sep).join("/")}function td(e){let t=e.replaceAll("\\","/"),n=t.lastIndexOf("/");return(n>=0?t.slice(n+1):t).toLowerCase()}function Th(e){return e==="win32"?"powershell":"/bin/bash"}function jo(e){let t=td(e);if(rt(e)!==void 0)return"powershell";if(t==="cmd"||t==="cmd.exe")return"cmd";if(t==="wsl"||t==="wsl.exe")return"wsl";return"posix"}var Ch=new Set(["-nologo","-noninteractive","-noprofile"]),kh="-noprofile";function Eh(e,t){let n="";for(let r=0;r<e.length;r++){let o=e[r];if(o==="`"&&r+1<e.length){let i=e[r+1];if(i==="u"&&t==="core"&&e[r+2]==="{"){let s=e.indexOf("}",r+3),a=s>r+3?e.slice(r+3,s):"",c=Number.parseInt(a,16);if(a.length<=6&&/^[0-9a-fA-F]+$/.test(a)&&c<=1114111){n+=String.fromCodePoint(c),r=s;continue}}switch(i){case"n":n+=`
70
- `;break;case"r":n+="\r";break;case"t":n+="\t";break;case"b":n+="\b";break;case"f":n+="\f";break;case"v":n+="\v";break;case"0":n+="\x00";break;case"a":n+="\x07";break;case"e":n+=t==="core"?"\x1B":"e";break;default:n+=i}r++;continue}if(o==='"'&&e[r+1]==='"'){n+='"',r++;continue}n+=o}return n}function Rh(e){let t=e[0];if(t!=="'"&&t!=='"')return;for(let n=1;n<e.length;n++){let r=e[n];if(t==='"'&&r==="`"){n++;continue}if(r===t){if(e[n+1]===t){n++;continue}if(e.slice(n+1).trim()!=="")return;return{quote:t,body:e.slice(1,n)}}}return}function rt(e){let t=td(e);if(t==="powershell"||t==="powershell.exe")return"windows";if(t==="pwsh"||t==="pwsh.exe")return"core";return}function Ah(e,t){let n=Rh(e);if(!n)return;let r=(n.quote==="'"?n.body.replaceAll("''","'"):Eh(n.body,t)).trim();return r.length>0?r:void 0}function Ih(e,t){let n=/^[ \t]*(?:&[ \t]*(?:"([^"$`]*)"|'((?:[^']|'')*)')|(?:&[ \t]*)?([^\s$`"';&|<>(){}#@,]+))[ \t]+([\S\s]*)$/.exec(e);if(!n)return;let r=n[1]??n[2]?.replaceAll("''","'")??n[3],o=rt(t);if(!o||!rt(r))return;let i=n[4],s=!1;for(;;){let a=/^(-[^\s=]+)[ \t]*([\S\s]*)$/.exec(i);if(!a)return;let c=a[1].toLowerCase();if(c==="-command"){let u=s?Ah(a[2],o):void 0;return u===void 0?void 0:{executable:r,script:u}}if(!Ch.has(c))return;if(c===kh)s=!0;i=a[2]}}function wh(e,t){if(!/[\\/:]/.test(t)&&rt(t)===rt(e))return e;return t}function nd(e,t){switch(jo(e)){case"powershell":{let n={executable:e,script:t};for(;;){let r=Ih(n.script,n.executable);if(!r)break;n={executable:wh(e,r.executable),script:r.script}}return{executable:n.executable,args:["-NoProfile","-NonInteractive","-Command","[Console]::InputEncoding=[Text.UTF8Encoding]::new();[Console]::OutputEncoding=[Text.UTF8Encoding]::new();$ErrorActionPreference='Stop';$c=[Console]::In.ReadToEnd();$c+=[Environment]::NewLine+'if(-not $?){exit 1}';& ([ScriptBlock]::Create($c))"],input:n.script}}case"cmd":return{executable:e,args:["/d","/s","/c",t]};case"wsl":return{executable:e,args:["bash","-c",t]};case"posix":return{executable:e,args:["-c",t]}}}function Ph(e,t){if(jo(e)==="powershell")return["-NoProfile","-NonInteractive","-Command",t];return nd(e,t).args}function Mh(e){return e.toLowerCase().replace(/[^\w.-]+/g,"_")}function Oh(e){let t=e?.trim();return t?t:void 0}function rd(e,t){if(e.length<=t)return e;return`${e.slice(0,t-1)}…`}function zh(e,t="/",n=100){if(!e||e.length<=n)return e||"";let r=e.split(t)?.shift()?.trim()?.slice(0,n-1);return r?`${r}…`:rd(e,n)}function Nh(e){if(e.length<=8)return"****";return`${e.slice(0,4)}...${e.slice(-4)}`}function $h(e){return e.charCodeAt(0)===65279?e.slice(1):e}function Lh(e){if(!e)return"(unknown-date)";let t=new Date(e);if(Number.isNaN(t.getTime()))return e;return t.toLocaleString("en-US",{year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric",hour12:!0})}function Dh(e){let t=Math.max(0,Math.floor(e/1000)),n=Math.floor(t/86400),r=Math.floor(t%86400/3600),o=Math.floor(t%3600/60),i=t%60;if(n>0)return`${n}d ${r}h`;if(r>0)return`${r}h ${o}m`;if(o>0)return`${o}m ${i}s`;return`${i}s`}function Bh(e,t){let n=e.safeParse(t);if(!n.success)throw Error(Hi(n.error));return n.data}function Vo(e){return _u(e)}function qo(e){return e==="cline"||e==="cline-pass"}var od=`You are Cline, an AI coding agent. Your primary goal is to assist users with various coding tasks by leveraging your knowledge and the tools at your disposal. Given the user's prompt, you should use the tools available to you to answer user's question.
68
+ ]`}function k(){let C=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,T=arguments.length>1&&arguments[1]!==void 0?arguments[1]:-1,O=e[t]==="\\";if(O){if(t++,!et(e[t]))lt()}let he=e[t]==="&"?Uo(e.slice(t,t+Bo)):null,Be=Yl(he)||Xl(he);if(et(e[t])||Be){let _i=Lo(e[t])?Lo:Do(e[t])?Do:En(e[t])?En:$o,Lt=t,Dt=n.length,L='"';t+=Be&&he?he.length:1;while(!0){if(t>=e.length){let H=Me(t-1);if(!C&&Qe(e.charAt(H)))return t=Lt,n=n.substring(0,Dt),k(!0);return L=ce(L,'"'),n+=L,!0}if(t===T)return L=ce(L,'"'),n+=L,!0;let ye=Be&&e[t]==="&"?Uo(e.slice(t,t+Bo)):null;if(ye&&he?ye.char===he.char:_i(e[t])){let H=t,zn=L.length;if(L+='"',t+=ye?ye.length:1,n+=L,s(!1),C||t>=e.length||Qe(e[t])&&!Ql(L,e[t])||et(e[t])&&!ct(t)||ve(e[t]))return M(),!0;if(e[t]==="\\")lt();let Te=Me(H-1),Si=e.charAt(Te);if(Si===",")return t=Lt,n=n.substring(0,Dt),k(!1,Te);if(Qe(Si))return t=Lt,n=n.substring(0,Dt),k(!0);n=n.substring(0,Dt),t=H+(ye?ye.length:1),L=`${L.substring(0,zn)}\\${L.substring(zn)}`}else if(C&&Oo(e[t])){if(e[t-1]===":"&&Po.test(e.substring(Lt+1,t+2)))while(t<e.length&&Mo.test(e[t]))L+=e[t],t++;return L=ce(L,'"'),n+=L,M(),!0}else if(ye){let H=ye.char;if(H==='"')L+="\\\"";else if(zo(H))L+=ed[H];else L+=H;t+=ye.length}else if(e[t]==="\\"){let H=e.charAt(t+1);if(dh[H]!==void 0)L+=e.slice(t,t+2),t+=2;else if(H==="u"){let Te=2;while(Te<6&&Vl(e[t+Te]))Te++;if(Te===6)L+=e.slice(t,t+6),t+=6;else if(t+Te>=e.length)t=e.length;else Cp()}else if(H===`
69
+ `)L+="\\n",t+=2;else L+=H,t+=2}else{let H=e.charAt(t);if(H==='"'&&e[t-1]!=="\\")L+=`\\${H}`,t++;else if(zo(H))L+=ed[H],t++;else{if(!ql(H))Nn(H);L+=H,t++}}if(O)f()}}return!1}function M(){let C=!1;s();while(e[t]==="+"){C=!0,t++,s(),n=tt(n,'"',!0);let T=n.length;if(k())n=Wl(n,T,1);else n=ce(n,'"')}return C}function R(){let C=t,T="",O=!1;if(e[t]==="-"){if(T+=e[t],t++,!ve(e[t])&&ut())T+="0"}if(e[t]==="0"&&ve(e[t+1]))O=!0;while(ve(e[t]))T+=e[t],t++;if(e[t]==="."){if(T===""||T==="-")T+="0";if(T+=e[t],t++,!ve(e[t]))T+="0";while(ve(e[t]))T+=e[t],t++}if(t>C){if(e[t]==="e"||e[t]==="E"){if(T==="-")O=!0;if(T+=e[t],t++,e[t]==="-"||e[t]==="+")T+=e[t],t++;if(!ve(e[t]))T+="0";while(ve(e[t]))T+=e[t],t++}if(!ut())return t=C,!1;return n+=O?`"${e.substring(C,t)}"`:T,!0}return!1}function B(){return A("true","true")||A("false","false")||A("null","null")||A("True","true")||A("False","false")||A("None","null")}function A(C,T){if(e.slice(t,t+C.length)===C&&!kn(e[t+C.length]))return n+=T,t+=C.length,!0;return!1}function J(C){let T=t;if(wo(e[t])){while(t<e.length&&kn(e[t]))t++;let O=t;while(Se(e,O))O++;if(e[O]==="("){if(t=O+1,i(),e[t]===")"){if(t++,e[t]===";")t++}return!0}}while(t<e.length&&!Oo(e[t])&&!et(e[t])&&(!C||e[t]!==":"))t++;if(e[t-1]===":"&&Po.test(e.substring(T,t+2)))while(t<e.length&&Mo.test(e[t]))t++;if(t>T){while(Se(e,t-1)&&t>0)t--;let O=e.slice(T,t);if(n+=O==="undefined"?"null":JSON.stringify(O),e[t]==='"')t++;return!0}}function Ce(){if(e[t]==="/"){let C=t;t++;while(t<e.length&&(e[t]!=="/"||e[t-1]==="\\"))t++;return t++,n+=JSON.stringify(e.substring(C,t)),!0}}function Me(C){let T=C;while(T>0&&Se(e,T))T--;return T}function ct(C){let T=C+1;while(T<e.length&&Se(e,T))T++;return T>=e.length||Qe(e[T])}function ut(){return t>=e.length||Qe(e[t])||Se(e,t)}function Nn(C){throw new Ie(`Invalid character ${JSON.stringify(C)}`,t)}function lt(){throw new Ie(`Unexpected character ${JSON.stringify(e[t])}`,t)}function Sp(){throw new Ie("Unexpected end of json string",e.length)}function vp(){throw new Ie("Object key expected",t)}function xi(){throw new Ie("Colon expected",t)}function Cp(){let C=e.slice(t,t+6);throw new Ie(`Invalid unicode character "${C}"`,t)}}function ph(e,t){return e[t]==="*"&&e[t+1]==="/"}function mh(e){let t=!1,n=!1,r=!1;for(let o=0;o<e.length;o+=1){let i=e[o];if(r){r=!1;continue}if(i==="\\"){r=!0;continue}if(!n&&i==='"')t=!t;else if(!t&&i==="'")n=!n}return t||n}var fh=/^\{\s*"([A-Za-z0-9_.$-]+)"\s*:\s*([\s\S]+?)\s*\}$/;function gh(e){let t=e.match(fh);if(!t)return;let[,n,r]=t,o=r.trim();if(!o)return;let i=o[0];if(i==='"'||i==="{"||i==="["||o==="true"||o==="false"||o==="null"||Number.isFinite(Number(o)))return;return JSON.parse(`{"${n}":${JSON.stringify(o)}}`)}function hh(e){if(typeof e!=="string")return e;let t=e.trimStart();if(t[0]!=="{"&&t[0]!=="[")return e;try{return JSON.parse(t)}catch{}if(!mh(t))try{return JSON.parse(Zo(t))}catch{}return gh(t)??e}function yh(e){let t=new WeakSet;try{return JSON.stringify(e,(r,o)=>{if(typeof o==="bigint")return o.toString();if(o&&typeof o==="object"){if(t.has(o))return"[Circular]";t.add(o)}return o})??"null"}catch{return String(e)}}function bh(e){try{return JSON.parse(e)}catch{return}}function nt(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function xh(e){let t=e.type;if(typeof t==="string")return[t];return Array.isArray(t)?t.filter((n)=>typeof n==="string"):[]}function Fo(e,t){if(xh(e).includes(t))return!0;for(let r of["anyOf","oneOf","allOf"]){let o=e[r];if(Array.isArray(o)&&o.some((i)=>nt(i)&&Fo(i,t)))return!0}return!1}function _h(e,t){if(typeof e!=="string")return e;let n=e.trim(),r=Fo(t,"array"),o=Fo(t,"object");if((!r||!n.startsWith("["))&&(!o||!n.startsWith("{")))return e;try{let i=JSON.parse(n);if(Array.isArray(i))return r?i:e;if(nt(i))return o?i:e;return e}catch{return e}}function Ho(e,t){let n=_h(e,t);if(Array.isArray(n)){let s=t.items;if(!nt(s))return n;let a=!1,c=n.map((u)=>{let l=Ho(u,s);return a||=l!==u,l});return a?c:n}if(!nt(n))return n;let r=t.properties;if(!nt(r))return n;let o=!1,i={...n};for(let[s,a]of Object.entries(r)){if(!(s in n)||!nt(a))continue;let c=Ho(n[s],a);if(c!==n[s])i[s]=c,o=!0}return o?i:n}function Sh(e){if(typeof globalThis.atob==="function")try{let t=globalThis.atob(e),n=Uint8Array.from(t,(r)=>r.charCodeAt(0));return new TextDecoder().decode(n)}catch{return null}if(typeof Buffer<"u")try{return Buffer.from(e,"base64").toString("utf8")}catch{return null}return null}function vh(e){let t=e?.trim();if(!t)return null;try{let n=t.split(".");if(n.length!==3)return null;let r=n[1];if(!r)return null;let o=r.replace(/-/g,"+").replace(/_/g,"/"),i=o.padEnd(o.length+(4-o.length%4)%4,"="),s=Sh(i);return s?JSON.parse(s):null}catch{return null}}function Ch(e){return Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0))}import Th from"node:path";function kh(e){return e.split(Th.sep).join("/")}function td(e){let t=e.replaceAll("\\","/"),n=t.lastIndexOf("/");return(n>=0?t.slice(n+1):t).toLowerCase()}function Eh(e){return e==="win32"?"powershell":"/bin/bash"}function jo(e){let t=td(e);if(rt(e)!==void 0)return"powershell";if(t==="cmd"||t==="cmd.exe")return"cmd";if(t==="wsl"||t==="wsl.exe")return"wsl";return"posix"}var Rh=new Set(["-nologo","-noninteractive","-noprofile"]),Ah="-noprofile";function Ih(e,t){let n="";for(let r=0;r<e.length;r++){let o=e[r];if(o==="`"&&r+1<e.length){let i=e[r+1];if(i==="u"&&t==="core"&&e[r+2]==="{"){let s=e.indexOf("}",r+3),a=s>r+3?e.slice(r+3,s):"",c=Number.parseInt(a,16);if(a.length<=6&&/^[0-9a-fA-F]+$/.test(a)&&c<=1114111){n+=String.fromCodePoint(c),r=s;continue}}switch(i){case"n":n+=`
70
+ `;break;case"r":n+="\r";break;case"t":n+="\t";break;case"b":n+="\b";break;case"f":n+="\f";break;case"v":n+="\v";break;case"0":n+="\x00";break;case"a":n+="\x07";break;case"e":n+=t==="core"?"\x1B":"e";break;default:n+=i}r++;continue}if(o==='"'&&e[r+1]==='"'){n+='"',r++;continue}n+=o}return n}function wh(e){let t=e[0];if(t!=="'"&&t!=='"')return;for(let n=1;n<e.length;n++){let r=e[n];if(t==='"'&&r==="`"){n++;continue}if(r===t){if(e[n+1]===t){n++;continue}if(e.slice(n+1).trim()!=="")return;return{quote:t,body:e.slice(1,n)}}}return}function rt(e){let t=td(e);if(t==="powershell"||t==="powershell.exe")return"windows";if(t==="pwsh"||t==="pwsh.exe")return"core";return}function Ph(e,t){let n=wh(e);if(!n)return;let r=(n.quote==="'"?n.body.replaceAll("''","'"):Ih(n.body,t)).trim();return r.length>0?r:void 0}function Mh(e,t){let n=/^[ \t]*(?:&[ \t]*(?:"([^"$`]*)"|'((?:[^']|'')*)')|(?:&[ \t]*)?([^\s$`"';&|<>(){}#@,]+))[ \t]+([\S\s]*)$/.exec(e);if(!n)return;let r=n[1]??n[2]?.replaceAll("''","'")??n[3],o=rt(t);if(!o||!rt(r))return;let i=n[4],s=!1;for(;;){let a=/^(-[^\s=]+)[ \t]*([\S\s]*)$/.exec(i);if(!a)return;let c=a[1].toLowerCase();if(c==="-command"){let u=s?Ph(a[2],o):void 0;return u===void 0?void 0:{executable:r,script:u}}if(!Rh.has(c))return;if(c===Ah)s=!0;i=a[2]}}function Oh(e,t){if(!/[\\/:]/.test(t)&&rt(t)===rt(e))return e;return t}function nd(e,t){switch(jo(e)){case"powershell":{let n={executable:e,script:t};for(;;){let r=Mh(n.script,n.executable);if(!r)break;n={executable:Oh(e,r.executable),script:r.script}}return{executable:n.executable,args:["-NoProfile","-NonInteractive","-Command","[Console]::InputEncoding=[Text.UTF8Encoding]::new();[Console]::OutputEncoding=[Text.UTF8Encoding]::new();$ErrorActionPreference='Stop';$c=[Console]::In.ReadToEnd();$c+=[Environment]::NewLine+'if(-not $?){exit 1}';& ([ScriptBlock]::Create($c))"],input:n.script}}case"cmd":return{executable:e,args:["/d","/s","/c",t]};case"wsl":return{executable:e,args:["bash","-c",t]};case"posix":return{executable:e,args:["-c",t]}}}function Nh(e,t){if(jo(e)==="powershell")return["-NoProfile","-NonInteractive","-Command",t];return nd(e,t).args}function zh(e){return e.toLowerCase().replace(/[^\w.-]+/g,"_")}function $h(e){let t=e?.trim();return t?t:void 0}function rd(e,t){if(e.length<=t)return e;return`${e.slice(0,t-1)}…`}function Lh(e,t="/",n=100){if(!e||e.length<=n)return e||"";let r=e.split(t)?.shift()?.trim()?.slice(0,n-1);return r?`${r}…`:rd(e,n)}function Dh(e){if(e.length<=8)return"****";return`${e.slice(0,4)}...${e.slice(-4)}`}function Bh(e){return e.charCodeAt(0)===65279?e.slice(1):e}function Uh(e){if(!e)return"(unknown-date)";let t=new Date(e);if(Number.isNaN(t.getTime()))return e;return t.toLocaleString("en-US",{year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric",hour12:!0})}function Zh(e){let t=Math.max(0,Math.floor(e/1000)),n=Math.floor(t/86400),r=Math.floor(t%86400/3600),o=Math.floor(t%3600/60),i=t%60;if(n>0)return`${n}d ${r}h`;if(r>0)return`${r}h ${o}m`;if(o>0)return`${o}m ${i}s`;return`${i}s`}function Fh(e,t){let n=e.safeParse(t);if(!n.success)throw Error(Hi(n.error));return n.data}function Vo(e){return Su(e)}function qo(e){return e==="cline"||e==="cline-pass"}var od=`You are Cline, an AI coding agent. Your primary goal is to assist users with various coding tasks by leveraging your knowledge and the tools at your disposal. Given the user's prompt, you should use the tools available to you to answer user's question.
71
71
 
72
72
  Always gather all the necessary context before starting to work on a task. For example, if you are generating a unit test or new code, make sure you understand the requirement, the naming conventions, frameworks and libraries used and aligned in the current codebase, and the environment and commands used to run and test the code etc. Always validate the new unit test at the end including running the code if possible for live feedback.
73
73
  Review each question carefully and answer it with detailed, accurate information.
@@ -158,33 +158,33 @@ The run_commands tool remains available in plan mode strictly for read-only insp
158
158
 
159
159
  Once the user has reviewed your plan and explicitly approved it in a follow-up message, use the switch_to_act_mode tool to switch to act mode and begin implementation. Calling switch_to_act_mode immediately starts execution, so never call it in the same turn you present a plan and never treat the original task request as approval -- end your turn after presenting the plan and wait for the user's response.`,ld=`${cd}
160
160
 
161
- Once you have presented your plan, end your turn and wait for the user's response. You do NOT have the ability to switch to act mode yourself -- the user must do it manually with the Plan/Act toggle once they are satisfied with the plan. If the task requires tools that are only available in act mode, ask the user to "toggle to Act mode" (use those words).`;function Uh(e){let t=e.indexOf("://");if(t<1)return e;let n=t+3,r=n;while(r<e.length){let i=e[r];if(i==="/"||i==="?"||i==="#"||i.charCodeAt(0)<=32)break;r++}let o=e.lastIndexOf("@",r-1);if(o<n)return e;return e.slice(0,n)+e.slice(o+1)}function Zh(e){return JSON.stringify({workspaces:{[e.rootPath]:{hint:e.hint,associatedRemoteUrls:e.associatedRemoteUrls?.map(Uh),latestGitCommitHash:e.latestGitCommitHash,latestGitBranchName:e.latestGitBranchName}}},null,2)}function sd(e,t,n){if(n?.trim()?.includes(Ko))return n.trim();let r=n||JSON.stringify({workspaces:{[e]:{hint:t||e.split("/").at(-1)||e}}},null,2);return`
161
+ Once you have presented your plan, end your turn and wait for the user's response. You do NOT have the ability to switch to act mode yourself -- the user must do it manually with the Plan/Act toggle once they are satisfied with the plan. If the task requires tools that are only available in act mode, ask the user to "toggle to Act mode" (use those words).`;function Hh(e){let t=e.indexOf("://");if(t<1)return e;let n=t+3,r=n;while(r<e.length){let i=e[r];if(i==="/"||i==="?"||i==="#"||i.charCodeAt(0)<=32)break;r++}let o=e.lastIndexOf("@",r-1);if(o<n)return e;return e.slice(0,n)+e.slice(o+1)}function jh(e){return JSON.stringify({workspaces:{[e.rootPath]:{hint:e.hint,associatedRemoteUrls:e.associatedRemoteUrls?.map(Hh),latestGitCommitHash:e.latestGitCommitHash,latestGitBranchName:e.latestGitBranchName}}},null,2)}function sd(e,t,n){if(n?.trim()?.includes(Ko))return n.trim();let r=n||JSON.stringify({workspaces:{[e]:{hint:t||e.split("/").at(-1)||e}}},null,2);return`
162
162
  ${Ko}
163
- ${r}`}function Fh(e){let{ide:t="Terminal Shell",mode:n,platform:r="unknown",workspaceName:o,metadata:i,rules:s,overridePrompt:a,providerId:c,planModeSwitchTool:u=!0}=e,l=e.workspaceRoot??e.rootPath??"",p=qo(c||"");if(a?.trim()){let g=a.trim();if(p&&i?.trim()&&!g.includes(Ko))return`${g}
163
+ ${r}`}function Vh(e){let{ide:t="Terminal Shell",mode:n,platform:r="unknown",workspaceName:o,metadata:i,rules:s,overridePrompt:a,providerId:c,planModeSwitchTool:u=!0}=e,l=e.workspaceRoot??e.rootPath??"",p=qo(c||"");if(a?.trim()){let g=a.trim();if(p&&i?.trim()&&!g.includes(Ko))return`${g}
164
164
 
165
165
  ${sd(l,o,i)}`.trim();return g}let m=n==="yolo"?Go.YOLO:Go.ACT,f=[s,n==="yolo"?void 0:ad,n==="plan"?u?ud:ld:void 0].filter(Boolean).join(`
166
166
 
167
- `);return m.replace("{{PLATFORM_NAME}}",r).replace("{{CWD}}",l).replace("{{CURRENT_DATE}}",new Date().toLocaleDateString()).replace("{{IDE_NAME}}",t).replace("{{CLINE_METADATA}}",p?sd(l,o,i):"").replace("{{CLINE_RULES}}",f).trim()}function Hh(e){return e?.metadata?.apiKeyOptional===!0}function jh(e){let t=e?.metadata?.localCliCommand;if(typeof t!=="string"||!t.trim())return;return{command:t.trim(),docsUrl:e?.docsUrl}}var Vh="anthropic/claude-sonnet-5.5";import ge from"node:fs/promises";import Wo from"node:path";async function qh(e){try{return await ge.access(e),!0}catch{return!1}}class Jo{filePath;constructor(e){this.filePath=e}async read(){try{return JSON.parse(await ge.readFile(this.filePath,"utf8"))}catch(e){if(e.code==="ENOENT")return;throw e}}async write(e){await ge.mkdir(Wo.dirname(this.filePath),{recursive:!0}),await ge.writeFile(this.filePath,JSON.stringify(e,null,2),"utf8")}async clear(){await ge.rm(this.filePath,{force:!0})}}class Rn{async writeText(e,t){await ge.mkdir(Wo.dirname(e),{recursive:!0}),await ge.writeFile(e,t,"utf8")}async remove(e){await ge.rm(e,{recursive:!0,force:!0})}async removeChildren(e){if(!await qh(e))return;let t=await ge.readdir(e);await Promise.all(t.map((n)=>ge.rm(Wo.join(e,n),{recursive:!0,force:!0})))}}import{createHmac as Jh}from"node:crypto";import{basename as Yh}from"node:path";var Xo=new TextEncoder,Gh={appstream2:"appstream",cloudhsmv2:"cloudhsm",email:"ses",marketplace:"aws-marketplace",mobile:"AWSMobileHubService",pinpoint:"mobiletargeting",queue:"sqs","git-codecommit":"codecommit","mturk-requester-sandbox":"mturk-requester","personalize-runtime":"personalize"},Kh=new Set(["authorization","content-type","content-length","user-agent","presigned-expires","expect","x-amzn-trace-id","range","connection"]);class An{constructor({accessKeyId:e,secretAccessKey:t,sessionToken:n,service:r,region:o,cache:i,retries:s,initRetryMs:a}){if(e==null)throw TypeError("accessKeyId is a required option");if(t==null)throw TypeError("secretAccessKey is a required option");this.accessKeyId=e,this.secretAccessKey=t,this.sessionToken=n,this.service=r,this.region=o,this.cache=i||new Map,this.retries=s!=null?s:10,this.initRetryMs=a||50}async sign(e,t){if(e instanceof Request){let{method:o,url:i,headers:s,body:a}=e;if(t=Object.assign({method:o,url:i,headers:s},t),t.body==null&&s.has("Content-Type"))t.body=a!=null&&s.has("X-Amz-Content-Sha256")?a:await e.clone().arrayBuffer();e=i}let n=new fd(Object.assign({url:e.toString()},t,this,t&&t.aws)),r=Object.assign({},t,await n.sign());delete r.aws;try{return new Request(r.url.toString(),r)}catch(o){if(o instanceof TypeError)return new Request(r.url.toString(),Object.assign({duplex:"half"},r));throw o}}async fetch(e,t){for(let n=0;n<=this.retries;n++){let r=fetch(await this.sign(e,t));if(n===this.retries)return r;let o=await r;if(o.status<500&&o.status!==429)return o;await new Promise((i)=>setTimeout(i,Math.random()*this.initRetryMs*Math.pow(2,n)))}throw Error("An unknown error occurred, ensure retries is not negative")}}class fd{constructor({method:e,url:t,headers:n,body:r,accessKeyId:o,secretAccessKey:i,sessionToken:s,service:a,region:c,cache:u,datetime:l,signQuery:p,appendSessionToken:m,allHeaders:f,singleEncode:g}){if(t==null)throw TypeError("url is a required option");if(o==null)throw TypeError("accessKeyId is a required option");if(i==null)throw TypeError("secretAccessKey is a required option");this.method=e||(r?"POST":"GET"),this.url=new URL(t),this.headers=new Headers(n||{}),this.body=r,this.accessKeyId=o,this.secretAccessKey=i,this.sessionToken=s;let y,S;if(!a||!c)[y,S]=Wh(this.url,this.headers);if(this.service=a||y||"",this.region=c||S||"us-east-1",this.cache=u||new Map,this.datetime=l||new Date().toISOString().replace(/[:-]|\.\d{3}/g,""),this.signQuery=p,this.appendSessionToken=m||this.service==="iotdevicegateway",this.headers.delete("Host"),this.service==="s3"&&!this.signQuery&&!this.headers.has("X-Amz-Content-Sha256"))this.headers.set("X-Amz-Content-Sha256","UNSIGNED-PAYLOAD");let v=this.signQuery?this.url.searchParams:this.headers;if(v.set("X-Amz-Date",this.datetime),this.sessionToken&&!this.appendSessionToken)v.set("X-Amz-Security-Token",this.sessionToken);if(this.signableHeaders=["host",...this.headers.keys()].filter((M)=>f||!Kh.has(M)).sort(),this.signedHeaders=this.signableHeaders.join(";"),this.canonicalHeaders=this.signableHeaders.map((M)=>M+":"+(M==="host"?this.url.host:(this.headers.get(M)||"").replace(/\s+/g," "))).join(`
168
- `),this.credentialString=[this.datetime.slice(0,8),this.region,this.service,"aws4_request"].join("/"),this.signQuery){if(this.service==="s3"&&!v.has("X-Amz-Expires"))v.set("X-Amz-Expires","86400");v.set("X-Amz-Algorithm","AWS4-HMAC-SHA256"),v.set("X-Amz-Credential",this.accessKeyId+"/"+this.credentialString),v.set("X-Amz-SignedHeaders",this.signedHeaders)}if(this.service==="s3")try{this.encodedPath=decodeURIComponent(this.url.pathname.replace(/\+/g," "))}catch(M){this.encodedPath=this.url.pathname}else this.encodedPath=this.url.pathname.replace(/\/+/g,"/");if(!g)this.encodedPath=encodeURIComponent(this.encodedPath).replace(/%2F/g,"/");this.encodedPath=md(this.encodedPath);let k=new Set;this.encodedSearch=[...this.url.searchParams].filter(([M])=>{if(!M)return!1;if(this.service==="s3"){if(k.has(M))return!1;k.add(M)}return!0}).map((M)=>M.map((R)=>md(encodeURIComponent(R)))).sort(([M,R],[B,A])=>M<B?-1:M>B?1:R<A?-1:R>A?1:0).map((M)=>M.join("=")).join("&")}async sign(){if(this.signQuery){if(this.url.searchParams.set("X-Amz-Signature",await this.signature()),this.sessionToken&&this.appendSessionToken)this.url.searchParams.set("X-Amz-Security-Token",this.sessionToken)}else this.headers.set("Authorization",await this.authHeader());return{method:this.method,url:this.url,headers:this.headers,body:this.body}}async authHeader(){return["AWS4-HMAC-SHA256 Credential="+this.accessKeyId+"/"+this.credentialString,"SignedHeaders="+this.signedHeaders,"Signature="+await this.signature()].join(", ")}async signature(){let e=this.datetime.slice(0,8),t=[this.secretAccessKey,e,this.region,this.service].join(),n=this.cache.get(t);if(!n){let r=await Nt("AWS4"+this.secretAccessKey,e),o=await Nt(r,this.region),i=await Nt(o,this.service);n=await Nt(i,"aws4_request"),this.cache.set(t,n)}return Yo(await Nt(n,await this.stringToSign()))}async stringToSign(){return["AWS4-HMAC-SHA256",this.datetime,this.credentialString,Yo(await dd(await this.canonicalString()))].join(`
167
+ `);return m.replace("{{PLATFORM_NAME}}",r).replace("{{CWD}}",l).replace("{{CURRENT_DATE}}",new Date().toLocaleDateString()).replace("{{IDE_NAME}}",t).replace("{{CLINE_METADATA}}",p?sd(l,o,i):"").replace("{{CLINE_RULES}}",f).trim()}function qh(e){return e?.metadata?.apiKeyOptional===!0}function Gh(e){let t=e?.metadata?.localCliCommand;if(typeof t!=="string"||!t.trim())return;return{command:t.trim(),docsUrl:e?.docsUrl}}var Kh="anthropic/claude-sonnet-5.5";import ge from"node:fs/promises";import Wo from"node:path";async function Wh(e){try{return await ge.access(e),!0}catch{return!1}}class Jo{filePath;constructor(e){this.filePath=e}async read(){try{return JSON.parse(await ge.readFile(this.filePath,"utf8"))}catch(e){if(e.code==="ENOENT")return;throw e}}async write(e){await ge.mkdir(Wo.dirname(this.filePath),{recursive:!0}),await ge.writeFile(this.filePath,JSON.stringify(e,null,2),"utf8")}async clear(){await ge.rm(this.filePath,{force:!0})}}class Rn{async writeText(e,t){await ge.mkdir(Wo.dirname(e),{recursive:!0}),await ge.writeFile(e,t,"utf8")}async remove(e){await ge.rm(e,{recursive:!0,force:!0})}async removeChildren(e){if(!await Wh(e))return;let t=await ge.readdir(e);await Promise.all(t.map((n)=>ge.rm(Wo.join(e,n),{recursive:!0,force:!0})))}}import{createHmac as Qh}from"node:crypto";import{basename as ey}from"node:path";var Xo=new TextEncoder,Jh={appstream2:"appstream",cloudhsmv2:"cloudhsm",email:"ses",marketplace:"aws-marketplace",mobile:"AWSMobileHubService",pinpoint:"mobiletargeting",queue:"sqs","git-codecommit":"codecommit","mturk-requester-sandbox":"mturk-requester","personalize-runtime":"personalize"},Yh=new Set(["authorization","content-type","content-length","user-agent","presigned-expires","expect","x-amzn-trace-id","range","connection"]);class An{constructor({accessKeyId:e,secretAccessKey:t,sessionToken:n,service:r,region:o,cache:i,retries:s,initRetryMs:a}){if(e==null)throw TypeError("accessKeyId is a required option");if(t==null)throw TypeError("secretAccessKey is a required option");this.accessKeyId=e,this.secretAccessKey=t,this.sessionToken=n,this.service=r,this.region=o,this.cache=i||new Map,this.retries=s!=null?s:10,this.initRetryMs=a||50}async sign(e,t){if(e instanceof Request){let{method:o,url:i,headers:s,body:a}=e;if(t=Object.assign({method:o,url:i,headers:s},t),t.body==null&&s.has("Content-Type"))t.body=a!=null&&s.has("X-Amz-Content-Sha256")?a:await e.clone().arrayBuffer();e=i}let n=new fd(Object.assign({url:e.toString()},t,this,t&&t.aws)),r=Object.assign({},t,await n.sign());delete r.aws;try{return new Request(r.url.toString(),r)}catch(o){if(o instanceof TypeError)return new Request(r.url.toString(),Object.assign({duplex:"half"},r));throw o}}async fetch(e,t){for(let n=0;n<=this.retries;n++){let r=fetch(await this.sign(e,t));if(n===this.retries)return r;let o=await r;if(o.status<500&&o.status!==429)return o;await new Promise((i)=>setTimeout(i,Math.random()*this.initRetryMs*Math.pow(2,n)))}throw Error("An unknown error occurred, ensure retries is not negative")}}class fd{constructor({method:e,url:t,headers:n,body:r,accessKeyId:o,secretAccessKey:i,sessionToken:s,service:a,region:c,cache:u,datetime:l,signQuery:p,appendSessionToken:m,allHeaders:f,singleEncode:g}){if(t==null)throw TypeError("url is a required option");if(o==null)throw TypeError("accessKeyId is a required option");if(i==null)throw TypeError("secretAccessKey is a required option");this.method=e||(r?"POST":"GET"),this.url=new URL(t),this.headers=new Headers(n||{}),this.body=r,this.accessKeyId=o,this.secretAccessKey=i,this.sessionToken=s;let y,_;if(!a||!c)[y,_]=Xh(this.url,this.headers);if(this.service=a||y||"",this.region=c||_||"us-east-1",this.cache=u||new Map,this.datetime=l||new Date().toISOString().replace(/[:-]|\.\d{3}/g,""),this.signQuery=p,this.appendSessionToken=m||this.service==="iotdevicegateway",this.headers.delete("Host"),this.service==="s3"&&!this.signQuery&&!this.headers.has("X-Amz-Content-Sha256"))this.headers.set("X-Amz-Content-Sha256","UNSIGNED-PAYLOAD");let v=this.signQuery?this.url.searchParams:this.headers;if(v.set("X-Amz-Date",this.datetime),this.sessionToken&&!this.appendSessionToken)v.set("X-Amz-Security-Token",this.sessionToken);if(this.signableHeaders=["host",...this.headers.keys()].filter((M)=>f||!Yh.has(M)).sort(),this.signedHeaders=this.signableHeaders.join(";"),this.canonicalHeaders=this.signableHeaders.map((M)=>M+":"+(M==="host"?this.url.host:(this.headers.get(M)||"").replace(/\s+/g," "))).join(`
168
+ `),this.credentialString=[this.datetime.slice(0,8),this.region,this.service,"aws4_request"].join("/"),this.signQuery){if(this.service==="s3"&&!v.has("X-Amz-Expires"))v.set("X-Amz-Expires","86400");v.set("X-Amz-Algorithm","AWS4-HMAC-SHA256"),v.set("X-Amz-Credential",this.accessKeyId+"/"+this.credentialString),v.set("X-Amz-SignedHeaders",this.signedHeaders)}if(this.service==="s3")try{this.encodedPath=decodeURIComponent(this.url.pathname.replace(/\+/g," "))}catch(M){this.encodedPath=this.url.pathname}else this.encodedPath=this.url.pathname.replace(/\/+/g,"/");if(!g)this.encodedPath=encodeURIComponent(this.encodedPath).replace(/%2F/g,"/");this.encodedPath=md(this.encodedPath);let k=new Set;this.encodedSearch=[...this.url.searchParams].filter(([M])=>{if(!M)return!1;if(this.service==="s3"){if(k.has(M))return!1;k.add(M)}return!0}).map((M)=>M.map((R)=>md(encodeURIComponent(R)))).sort(([M,R],[B,A])=>M<B?-1:M>B?1:R<A?-1:R>A?1:0).map((M)=>M.join("=")).join("&")}async sign(){if(this.signQuery){if(this.url.searchParams.set("X-Amz-Signature",await this.signature()),this.sessionToken&&this.appendSessionToken)this.url.searchParams.set("X-Amz-Security-Token",this.sessionToken)}else this.headers.set("Authorization",await this.authHeader());return{method:this.method,url:this.url,headers:this.headers,body:this.body}}async authHeader(){return["AWS4-HMAC-SHA256 Credential="+this.accessKeyId+"/"+this.credentialString,"SignedHeaders="+this.signedHeaders,"Signature="+await this.signature()].join(", ")}async signature(){let e=this.datetime.slice(0,8),t=[this.secretAccessKey,e,this.region,this.service].join(),n=this.cache.get(t);if(!n){let r=await zt("AWS4"+this.secretAccessKey,e),o=await zt(r,this.region),i=await zt(o,this.service);n=await zt(i,"aws4_request"),this.cache.set(t,n)}return Yo(await zt(n,await this.stringToSign()))}async stringToSign(){return["AWS4-HMAC-SHA256",this.datetime,this.credentialString,Yo(await dd(await this.canonicalString()))].join(`
169
169
  `)}async canonicalString(){return[this.method.toUpperCase(),this.encodedPath,this.encodedSearch,this.canonicalHeaders+`
170
170
  `,this.signedHeaders,await this.hexBodyHash()].join(`
171
- `)}async hexBodyHash(){let e=this.headers.get("X-Amz-Content-Sha256")||(this.service==="s3"&&this.signQuery?"UNSIGNED-PAYLOAD":null);if(e==null){if(this.body&&typeof this.body!=="string"&&!("byteLength"in this.body))throw Error("body must be a string, ArrayBuffer or ArrayBufferView, unless you include the X-Amz-Content-Sha256 header");e=Yo(await dd(this.body||""))}return e}}async function Nt(e,t){let n=await crypto.subtle.importKey("raw",typeof e==="string"?Xo.encode(e):e,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]);return crypto.subtle.sign("HMAC",n,Xo.encode(t))}async function dd(e){return crypto.subtle.digest("SHA-256",typeof e==="string"?Xo.encode(e):e)}var pd=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];function Yo(e){let t=new Uint8Array(e),n="";for(let r=0;r<t.length;r++){let o=t[r];n+=pd[o>>>4&15],n+=pd[o&15]}return n}function md(e){return e.replace(/[!'()*]/g,(t)=>"%"+t.charCodeAt(0).toString(16).toUpperCase())}function Wh(e,t){let{hostname:n,pathname:r}=e;if(n.endsWith(".on.aws")){let a=n.match(/^[^.]{1,63}\.lambda-url\.([^.]{1,63})\.on\.aws$/);return a!=null?["lambda",a[1]||""]:["",""]}if(n.endsWith(".r2.cloudflarestorage.com"))return["s3","auto"];if(n.endsWith(".backblazeb2.com")){let a=n.match(/^(?:[^.]{1,63}\.)?s3\.([^.]{1,63})\.backblazeb2\.com$/);return a!=null?["s3",a[1]||""]:["",""]}let o=n.replace("dualstack.","").match(/([^.]{1,63})\.(?:([^.]{0,63})\.)?amazonaws\.com(?:\.cn)?$/),i=o&&o[1]||"",s=o&&o[2];if(s==="us-gov")s="us-gov-west-1";else if(s==="s3"||s==="s3-accelerate")s="us-east-1",i="s3";else if(i==="iot")if(n.startsWith("iot."))i="execute-api";else if(n.startsWith("data.jobs.iot."))i="iot-jobs-data";else i=r==="/mqtt"?"iotdevicegateway":"iotdata";else if(i==="autoscaling"){let a=(t.get("X-Amz-Target")||"").split(".")[0];if(a==="AnyScaleFrontendService")i="application-autoscaling";else if(a==="AnyScaleScalingPlannerFrontendService")i="autoscaling-plans"}else if(s==null&&i.startsWith("s3-"))s=i.slice(3).replace(/^fips-|^external-1/,""),i="s3";else if(i.endsWith("-fips"))i=i.slice(0,-5);else if(s&&/-\d$/.test(i)&&!/-\d$/.test(s))[i,s]=[s,i];return[Gh[i]||i,s||""]}var hd="enterprise.blobUpload",In=new Map;function Qo(e,t){return{adapterType:e,accessKeyId:t.accessKeyId,secretAccessKey:t.secretAccessKey,region:t.region,bucket:t.bucket,endpoint:t.endpoint,accountId:t.accountId}}function yd(e){return{adapterType:e.adapterType,bucket:e.bucket,region:e.region,endpoint:e.endpoint,accountId:e.accountId}}function Xh(e){if(!e||e.enabled!==!0)return;if(e.type==="s3_access_keys"&&e.s3AccessSettings)return Qo("s3",e.s3AccessSettings);if(e.type==="r2_access_keys"&&e.r2AccessSettings)return Qo("r2",e.r2AccessSettings);if(e.type==="azure_access_keys"&&e.azureAccessSettings)return Qo("azure",e.azureAccessSettings);return}function bd(e){return Xh(e?.enterpriseTelemetry?.promptUploading)}function Qh(e,t){let n=bd(e);if(!n)return;return{version:1,storage:yd(n),userDistinctId:t}}function ey(e,t,n){let r=bd(t);if(!r){In.delete(e);return}return In.set(e,r),{version:1,storage:yd(r),userDistinctId:n}}function ty(e){In.delete(e)}function xd(e,t,n){let r=`${t}/${n}`;return{async write(o,i){let s=await e.fetch(`${r}/${o}`,{method:"PUT",body:i,headers:{"Content-Type":"application/json; charset=utf-8"}});if(!s.ok)throw Error(`Failed to write ${o}: ${s.status}`)}}}function ny(e){let{bucket:t,accessKeyId:n,secretAccessKey:r}=e;if(!t||!n||!r)return;let o=e.region||"us-east-1",i=e.endpoint||`https://s3.${o}.amazonaws.com`;return xd(new An({region:o,accessKeyId:n,secretAccessKey:r}),i,t)}function ry(e){let{accountId:t,endpoint:n,bucket:r,accessKeyId:o,secretAccessKey:i}=e;if(!n&&!t||!r||!o||!i)return;return xd(new An({accessKeyId:o,secretAccessKey:i}),e.endpoint??`https://${t}.r2.cloudflarestorage.com`,r)}function oy(e,t,n,r,o){let i=o["Content-Length"]||"",s=o["Content-Type"]||"",a=Object.entries(o).filter(([m])=>m.toLowerCase().startsWith("x-ms-")).sort(([m],[f])=>m.toLowerCase().localeCompare(f.toLowerCase())).map(([m,f])=>`${m.toLowerCase()}:${f}`).join(`
171
+ `)}async hexBodyHash(){let e=this.headers.get("X-Amz-Content-Sha256")||(this.service==="s3"&&this.signQuery?"UNSIGNED-PAYLOAD":null);if(e==null){if(this.body&&typeof this.body!=="string"&&!("byteLength"in this.body))throw Error("body must be a string, ArrayBuffer or ArrayBufferView, unless you include the X-Amz-Content-Sha256 header");e=Yo(await dd(this.body||""))}return e}}async function zt(e,t){let n=await crypto.subtle.importKey("raw",typeof e==="string"?Xo.encode(e):e,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]);return crypto.subtle.sign("HMAC",n,Xo.encode(t))}async function dd(e){return crypto.subtle.digest("SHA-256",typeof e==="string"?Xo.encode(e):e)}var pd=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];function Yo(e){let t=new Uint8Array(e),n="";for(let r=0;r<t.length;r++){let o=t[r];n+=pd[o>>>4&15],n+=pd[o&15]}return n}function md(e){return e.replace(/[!'()*]/g,(t)=>"%"+t.charCodeAt(0).toString(16).toUpperCase())}function Xh(e,t){let{hostname:n,pathname:r}=e;if(n.endsWith(".on.aws")){let a=n.match(/^[^.]{1,63}\.lambda-url\.([^.]{1,63})\.on\.aws$/);return a!=null?["lambda",a[1]||""]:["",""]}if(n.endsWith(".r2.cloudflarestorage.com"))return["s3","auto"];if(n.endsWith(".backblazeb2.com")){let a=n.match(/^(?:[^.]{1,63}\.)?s3\.([^.]{1,63})\.backblazeb2\.com$/);return a!=null?["s3",a[1]||""]:["",""]}let o=n.replace("dualstack.","").match(/([^.]{1,63})\.(?:([^.]{0,63})\.)?amazonaws\.com(?:\.cn)?$/),i=o&&o[1]||"",s=o&&o[2];if(s==="us-gov")s="us-gov-west-1";else if(s==="s3"||s==="s3-accelerate")s="us-east-1",i="s3";else if(i==="iot")if(n.startsWith("iot."))i="execute-api";else if(n.startsWith("data.jobs.iot."))i="iot-jobs-data";else i=r==="/mqtt"?"iotdevicegateway":"iotdata";else if(i==="autoscaling"){let a=(t.get("X-Amz-Target")||"").split(".")[0];if(a==="AnyScaleFrontendService")i="application-autoscaling";else if(a==="AnyScaleScalingPlannerFrontendService")i="autoscaling-plans"}else if(s==null&&i.startsWith("s3-"))s=i.slice(3).replace(/^fips-|^external-1/,""),i="s3";else if(i.endsWith("-fips"))i=i.slice(0,-5);else if(s&&/-\d$/.test(i)&&!/-\d$/.test(s))[i,s]=[s,i];return[Jh[i]||i,s||""]}var hd="enterprise.blobUpload",In=new Map;function Qo(e,t){return{adapterType:e,accessKeyId:t.accessKeyId,secretAccessKey:t.secretAccessKey,region:t.region,bucket:t.bucket,endpoint:t.endpoint,accountId:t.accountId}}function yd(e){return{adapterType:e.adapterType,bucket:e.bucket,region:e.region,endpoint:e.endpoint,accountId:e.accountId}}function ty(e){if(!e||e.enabled!==!0)return;if(e.type==="s3_access_keys"&&e.s3AccessSettings)return Qo("s3",e.s3AccessSettings);if(e.type==="r2_access_keys"&&e.r2AccessSettings)return Qo("r2",e.r2AccessSettings);if(e.type==="azure_access_keys"&&e.azureAccessSettings)return Qo("azure",e.azureAccessSettings);return}function bd(e){return ty(e?.enterpriseTelemetry?.promptUploading)}function ny(e,t){let n=bd(e);if(!n)return;return{version:1,storage:yd(n),userDistinctId:t}}function ry(e,t,n){let r=bd(t);if(!r){In.delete(e);return}return In.set(e,r),{version:1,storage:yd(r),userDistinctId:n}}function oy(e){In.delete(e)}function xd(e,t,n){let r=`${t}/${n}`;return{async write(o,i){let s=await e.fetch(`${r}/${o}`,{method:"PUT",body:i,headers:{"Content-Type":"application/json; charset=utf-8"}});if(!s.ok)throw Error(`Failed to write ${o}: ${s.status}`)}}}function iy(e){let{bucket:t,accessKeyId:n,secretAccessKey:r}=e;if(!t||!n||!r)return;let o=e.region||"us-east-1",i=e.endpoint||`https://s3.${o}.amazonaws.com`;return xd(new An({region:o,accessKeyId:n,secretAccessKey:r}),i,t)}function sy(e){let{accountId:t,endpoint:n,bucket:r,accessKeyId:o,secretAccessKey:i}=e;if(!n&&!t||!r||!o||!i)return;return xd(new An({accessKeyId:o,secretAccessKey:i}),e.endpoint??`https://${t}.r2.cloudflarestorage.com`,r)}function ay(e,t,n,r,o){let i=o["Content-Length"]||"",s=o["Content-Type"]||"",a=Object.entries(o).filter(([m])=>m.toLowerCase().startsWith("x-ms-")).sort(([m],[f])=>m.toLowerCase().localeCompare(f.toLowerCase())).map(([m,f])=>`${m.toLowerCase()}:${f}`).join(`
172
172
  `),c=`/${e}${r}`,u=[n,"","",i,"",s,"","","","","","",a,c].join(`
173
- `),l=Buffer.from(t,"base64"),p=Jh("sha256",l).update(u,"utf8").digest("base64");return`SharedKey ${e}:${p}`}function iy(e){let{accessKeyId:t,secretAccessKey:n,bucket:r}=e;if(!t||!n||!r)return;let o=e.endpoint||`https://${t}.blob.core.windows.net`;return{async write(i,s){let a=`/${r}/${i}`,c=new Date().toUTCString(),u=Buffer.from(s,"utf8"),l={"x-ms-date":c,"x-ms-version":"2024-11-04","x-ms-blob-type":"BlockBlob","Content-Type":"application/json; charset=utf-8","Content-Length":u.byteLength.toString()};l.Authorization=oy(t,n,"PUT",a,l);let p=await fetch(`${o}${a}`,{method:"PUT",body:u,headers:l});if(!p.ok){let m=await p.text().catch(()=>"");throw Error(`Failed to write ${i}: ${p.status} ${m}`.trim())}}}}function sy(e){if(e.adapterType==="s3")return ny(e);if(e.adapterType==="r2")return ry(e);if(e.adapterType==="azure")return iy(e);return}function gd(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function Sd(e){let t=e?.metadata?.[hd];if(!gd(t))return;let n=t.storage;if(!gd(n))return;let r=n.adapterType;if(r!=="s3"&&r!=="r2"&&r!=="azure")return;if(typeof n.bucket!=="string")return;return{version:1,storage:{adapterType:r,bucket:n.bucket,region:typeof n.region==="string"?n.region:void 0,endpoint:typeof n.endpoint==="string"?n.endpoint:void 0,accountId:typeof n.accountId==="string"?n.accountId:void 0},keyPrefix:typeof t.keyPrefix==="string"?t.keyPrefix:void 0,userDistinctId:typeof t.userDistinctId==="string"?t.userDistinctId:void 0}}function ay(e,t,n){return["sessions",n.userDistinctId?.trim()||"unknown",e,t?.endsWith("messages.json")?"messages.json":Yh(t)].filter((i)=>Boolean(i?.trim())).join("/")}function cy(){let e=new Map;return{async uploadMessagesFile({sessionId:t,path:n,contents:r,row:o}){let i=Sd(o);if(!i)return;let s=In.get(t);if(!s)return;let a=JSON.stringify(s),c=e.get(a);if(!c){if(c=sy(s),!c)return;e.set(a,c)}await c.write(ay(t,n,i),r)}}}function ei(e,t,n){return{id:`remote-config:${e}:${n}:${t.name}`,name:t.name,kind:e,contents:t.contents,alwaysEnabled:t.alwaysEnabled}}var uy="remote://";function _d(e){let t="",n=!1;for(let r of e.trim().toLowerCase()){let o=r.charCodeAt(0);if(o>=97&&o<=122||o>=48&&o<=57||r==="."||r==="_"||r==="-"){if(n&&t&&t[t.length-1]!=="-")t+="-";n=!1,t+=r}else n=!0;if(t.length>=80)break}while(t.endsWith("-"))t=t.slice(0,-1);while(t.startsWith("-"))t=t.slice(1);return t||"item"}function ly(e){let t=e?.globalRules?.map((r,o)=>ei("rule",r,`${o}`))??[],n=e?.globalWorkflows?.map((r,o)=>ei("workflow",r,`${o}`))??[];return[...t,...n]}function dy(e){return[...ly(e.remoteConfig),...e.managedInstructions??[]]}function py(e){return e.map((t)=>{let n=`## ${t.name}`,r=t.alwaysEnabled?`_Always enabled_
173
+ `),l=Buffer.from(t,"base64"),p=Qh("sha256",l).update(u,"utf8").digest("base64");return`SharedKey ${e}:${p}`}function cy(e){let{accessKeyId:t,secretAccessKey:n,bucket:r}=e;if(!t||!n||!r)return;let o=e.endpoint||`https://${t}.blob.core.windows.net`;return{async write(i,s){let a=`/${r}/${i}`,c=new Date().toUTCString(),u=Buffer.from(s,"utf8"),l={"x-ms-date":c,"x-ms-version":"2024-11-04","x-ms-blob-type":"BlockBlob","Content-Type":"application/json; charset=utf-8","Content-Length":u.byteLength.toString()};l.Authorization=ay(t,n,"PUT",a,l);let p=await fetch(`${o}${a}`,{method:"PUT",body:u,headers:l});if(!p.ok){let m=await p.text().catch(()=>"");throw Error(`Failed to write ${i}: ${p.status} ${m}`.trim())}}}}function uy(e){if(e.adapterType==="s3")return iy(e);if(e.adapterType==="r2")return sy(e);if(e.adapterType==="azure")return cy(e);return}function gd(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function _d(e){let t=e?.metadata?.[hd];if(!gd(t))return;let n=t.storage;if(!gd(n))return;let r=n.adapterType;if(r!=="s3"&&r!=="r2"&&r!=="azure")return;if(typeof n.bucket!=="string")return;return{version:1,storage:{adapterType:r,bucket:n.bucket,region:typeof n.region==="string"?n.region:void 0,endpoint:typeof n.endpoint==="string"?n.endpoint:void 0,accountId:typeof n.accountId==="string"?n.accountId:void 0},keyPrefix:typeof t.keyPrefix==="string"?t.keyPrefix:void 0,userDistinctId:typeof t.userDistinctId==="string"?t.userDistinctId:void 0}}function ly(e,t,n){return["sessions",n.userDistinctId?.trim()||"unknown",e,t?.endsWith("messages.json")?"messages.json":ey(t)].filter((i)=>Boolean(i?.trim())).join("/")}function dy(){let e=new Map;return{async uploadMessagesFile({sessionId:t,path:n,contents:r,row:o}){let i=_d(o);if(!i)return;let s=In.get(t);if(!s)return;let a=JSON.stringify(s),c=e.get(a);if(!c){if(c=uy(s),!c)return;e.set(a,c)}await c.write(ly(t,n,i),r)}}}function ei(e,t,n){return{id:`remote-config:${e}:${n}:${t.name}`,name:t.name,kind:e,contents:t.contents,alwaysEnabled:t.alwaysEnabled}}var py="remote://";function Sd(e){let t="",n=!1;for(let r of e.trim().toLowerCase()){let o=r.charCodeAt(0);if(o>=97&&o<=122||o>=48&&o<=57||r==="."||r==="_"||r==="-"){if(n&&t&&t[t.length-1]!=="-")t+="-";n=!1,t+=r}else n=!0;if(t.length>=80)break}while(t.endsWith("-"))t=t.slice(0,-1);while(t.startsWith("-"))t=t.slice(1);return t||"item"}function my(e){let t=e?.globalRules?.map((r,o)=>ei("rule",r,`${o}`))??[],n=e?.globalWorkflows?.map((r,o)=>ei("workflow",r,`${o}`))??[];return[...t,...n]}function fy(e){return[...my(e.remoteConfig),...e.managedInstructions??[]]}function gy(e){return e.map((t)=>{let n=`## ${t.name}`,r=t.alwaysEnabled?`_Always enabled_
174
174
  `:"";return`${n}
175
175
 
176
176
  ${r}${t.contents.trim()}`}).join(`
177
177
 
178
- `)}function ti(e,t){return e.filter((n)=>n.kind===t)}class ni{async materialize(e){let t=dy(e.bundle),n=ti(t,"rule"),r=ti(t,"workflow"),o=ti(t,"skill");await e.artifactStore.removeChildren(e.paths.workflowsPath),await e.artifactStore.removeChildren(e.paths.skillsPath);let i=[];if(n.length>0)await e.artifactStore.writeText(e.paths.rulesFilePath,py(n)),i.push(...n.map((s)=>({kind:s.kind,filePath:e.paths.rulesFilePath,id:s.id,name:s.name})));else await e.artifactStore.remove(e.paths.rulesFilePath);for(let s of r){let a=`${e.paths.workflowsPath}/${_d(s.name.replace(/\.(md|markdown|txt)$/i,""))}.md`;await e.artifactStore.writeText(a,s.contents),i.push({kind:s.kind,filePath:a,id:s.id,name:s.name})}for(let s of o){let a=`${e.paths.skillsPath}/${_d(s.name)}/SKILL.md`;await e.artifactStore.writeText(a,s.contents),i.push({kind:s.kind,filePath:a,id:s.id,name:s.name})}return await e.artifactStore.writeText(e.paths.manifestPath,JSON.stringify({source:e.bundle.source,version:e.bundle.version,files:i},null,2)),{paths:e.paths,rulesFilePath:n.length>0?e.paths.rulesFilePath:void 0,files:i}}}import ot from"node:path";var my="remote-config";function ri(e){let t=e.pluginName??my,n=ot.join(e.workspacePath,".cline",t);return{pluginName:t,pluginPath:n,workflowsPath:ot.join(n,"workflows"),skillsPath:ot.join(n,"skills"),bundleCachePath:ot.join(n,"cache","bundle.json"),manifestPath:ot.join(n,"managed.json"),rulesFilePath:ot.join(n,"rules.md")}}function vd(e){return{workflowsDirectories:[e.workflowsPath],skillsDirectories:[e.skillsPath]}}function fy(e){if(!e)return;return{enabled:e.openTelemetryEnabled??!1,metricsExporter:e.openTelemetryMetricsExporter,logsExporter:e.openTelemetryLogsExporter,otlpProtocol:e.openTelemetryOtlpProtocol,otlpEndpoint:e.openTelemetryOtlpEndpoint,otlpHeaders:e.openTelemetryOtlpHeaders,otlpMetricsProtocol:e.openTelemetryOtlpMetricsProtocol,otlpMetricsEndpoint:e.openTelemetryOtlpMetricsEndpoint,otlpMetricsHeaders:e.openTelemetryOtlpMetricsHeaders,otlpLogsProtocol:e.openTelemetryOtlpLogsProtocol,otlpLogsEndpoint:e.openTelemetryOtlpLogsEndpoint,otlpLogsHeaders:e.openTelemetryOtlpLogsHeaders,metricExportInterval:e.openTelemetryMetricExportInterval,otlpInsecure:e.openTelemetryOtlpInsecure,logBatchSize:e.openTelemetryLogBatchSize,logBatchTimeout:e.openTelemetryLogBatchTimeout,logMaxQueueSize:e.openTelemetryLogMaxQueueSize}}function Cd(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function we(e,t){let n=e[t];return typeof n==="string"?n:void 0}function Td(e,t){let n=e[t];return typeof n==="boolean"?n:void 0}function wn(e,t){let n=e[t];return typeof n==="number"&&Number.isFinite(n)?n:void 0}function oi(e,t){let n=e[t];if(!Cd(n))return;let r=Object.entries(n).filter((o)=>typeof o[1]==="string");return r.length>0?Object.fromEntries(r):void 0}function gy(e){if(!Cd(e))return;let t={enabled:Td(e,"enabled"),metricsExporter:we(e,"metricsExporter"),logsExporter:we(e,"logsExporter"),otlpProtocol:we(e,"otlpProtocol"),otlpEndpoint:we(e,"otlpEndpoint"),otlpHeaders:oi(e,"otlpHeaders"),otlpMetricsProtocol:we(e,"otlpMetricsProtocol"),otlpMetricsEndpoint:we(e,"otlpMetricsEndpoint"),otlpMetricsHeaders:oi(e,"otlpMetricsHeaders"),otlpLogsProtocol:we(e,"otlpLogsProtocol"),otlpLogsEndpoint:we(e,"otlpLogsEndpoint"),otlpLogsHeaders:oi(e,"otlpLogsHeaders"),metricExportInterval:wn(e,"metricExportInterval"),otlpInsecure:Td(e,"otlpInsecure"),logBatchSize:wn(e,"logBatchSize"),logBatchTimeout:wn(e,"logBatchTimeout"),logMaxQueueSize:wn(e,"logMaxQueueSize")};return Object.values(t).some((n)=>n!==void 0)?t:void 0}class ii{name="remote-config";resolveTelemetry(e,t){return{...fy(e.remoteConfig),...gy(e.telemetry)}}}async function hy(e){let t=ri(e),n=e.artifactStore??new Rn;await n.removeChildren(t.workflowsPath),await n.removeChildren(t.skillsPath),await n.remove(t.rulesFilePath),await n.remove(t.manifestPath),await n.remove(t.bundleCachePath)}function kd(e){return e?.claims}function Ed(e,t){if(!e)return[];if(t.claimsMapper)return t.claimsMapper.mapClaimsToRoles(e);return e.roles??[]}function yy(e,t){return{...e,metadata:{...e.metadata??{},paths:t}}}class Rd{options;constructor(e){this.options=e}async sync(e){let t=await this.options.controlPlane.fetchBundle({workspacePath:e.workspacePath,rootPath:e.rootPath,context:e.context,signal:e.signal,now:e.now,logger:this.options.logger});if(!t)throw Error("Remote config control plane returned no bundle");await this.options.bundleStore.write(t);let n=await this.options.materializer.materialize({bundle:t,paths:e.paths,artifactStore:this.options.artifactStore}),r=this.options.telemetryAdapter?await this.options.telemetryAdapter.resolveTelemetry(t,{workspacePath:e.workspacePath,rootPath:e.rootPath,context:e.context,signal:e.signal,now:e.now,logger:this.options.logger}):void 0,o=kd(t),i=Ed(o,this.options);return{bundle:t,materialized:n,telemetry:r,roles:i,claims:o}}}function by(e){let t=e?.name??"remote-config";return{name:t,manifest:{capabilities:["providers"]},async setup(n,r){n.registerProvider?.({name:t,description:"Remote-config managed runtime integration"}),await e?.setup?.(n,r)}}}async function xy(e){let t=ri({workspacePath:e.workspacePath,pluginName:e.pluginName}),n=e.bundleStore??new Jo(t.bundleCachePath),r=e.artifactStore??new Rn,o=e.materializer??new ni,i=e.telemetryAdapter??new ii,s,a,c=[],u,l=!1,p=!1;if(e.controlPlane){let f=new Rd({controlPlane:e.controlPlane,bundleStore:n,artifactStore:r,materializer:o,telemetryAdapter:i,claimsMapper:e.claimsMapper,logger:e.logger});try{let g=await f.sync({workspacePath:e.workspacePath,rootPath:e.rootPath,context:e.context,paths:t,signal:e.signal,now:e.now});s=g.bundle,a=g.telemetry,c=g.roles,u=g.claims,p=!0}catch(g){if(e.useCachedBundle!==!1)s=await n.read(),l=Boolean(s);if(!s)throw g}}else if(e.useCachedBundle!==!1)s=await n.read(),l=Boolean(s);if(!s&&e.requireBundle)throw Error("Remote config runtime preparation requires a bundle");if(s){let f=yy(s,t);if(await n.write(f),!p)await o.materialize({bundle:f,paths:t,artifactStore:r});u??=kd(f),c=c.length>0?c:Ed(u,e),a??=await i.resolveTelemetry(f,{workspacePath:e.workspacePath,rootPath:e.rootPath,context:e.context,signal:e.signal,now:e.now,logger:e.logger}),s=f}let m=vd(t);return{pluginName:t.pluginName,pluginDefinition:by({name:t.pluginName}),paths:t,bundle:s,telemetry:a,roles:c,claims:u,usedCachedBundle:l,workflowsDirectories:m.workflowsDirectories,skillsDirectories:m.skillsDirectories}}var Ad=b({id:d(),temperature:x().optional(),maxTokens:x().optional(),contextWindow:x().optional(),inputPrice:x().optional(),outputPrice:x().optional(),supportsImages:w().optional()}),Id=b({models:E(Ad).optional(),openAiBaseUrl:d().optional(),openAiHeaders:j(d(),d()).optional(),azureApiVersion:d().optional(),azureIdentity:w().optional()}),wd=b({id:d(),thinkingBudgetTokens:x().optional()}),Pd=b({name:d(),baseModelId:d(),thinkingBudgetTokens:x().optional()}),Md=b({models:E(wd).optional(),customModels:E(Pd).optional(),awsRegion:d().optional(),awsUseCrossRegionInference:w().optional(),awsUseGlobalInference:w().optional(),awsBedrockUsePromptCache:w().optional(),awsBedrockEndpoint:d().optional()}),Od=b({id:d()}),zd=b({models:E(Od).optional()}),Nd=b({id:d(),thinkingBudgetTokens:x().optional()}),$d=b({models:E(Nd).optional(),vertexProjectId:d().optional(),vertexRegion:d().optional()}),Ld=b({id:d(),thinkingBudgetTokens:x().optional(),promptCachingEnabled:w().optional()}),Dd=b({models:E(Ld).optional(),baseUrl:d().optional()}),Bd=b({id:d(),thinkingBudgetTokens:x().optional()}),Ud=b({models:E(Bd).optional(),baseUrl:d().optional()}),Sy=b({OpenAiCompatible:Id.optional(),AwsBedrock:Md.optional(),Cline:zd.optional(),Vertex:$d.optional(),LiteLLM:Dd.optional(),Anthropic:Ud.optional()}),Zd=b({id:d()}),Fd=b({name:d(),url:d(),alwaysEnabled:w().optional(),headers:j(d(),d()).optional()}),si=b({alwaysEnabled:w(),name:d(),contents:d()}),Pn=b({bucket:d(),accessKeyId:d(),secretAccessKey:d(),region:d().optional(),endpoint:d().optional(),accountId:d().optional()}),Hd=b({enabled:w().optional(),type:Ge([V("s3_access_keys"),V("r2_access_keys"),V("azure_access_keys")]).optional(),s3AccessSettings:Pn.optional(),r2AccessSettings:Pn.optional(),azureAccessSettings:Pn.optional()}),jd=b({promptUploading:Hd.optional()}),_y=b({version:d(),providerSettings:Sy.optional(),telemetryEnabled:w().optional(),kanbanEnabled:w().optional(),mcpMarketplaceEnabled:w().optional(),allowedMCPServers:E(Zd).optional(),remoteMCPServers:E(Fd).optional(),blockPersonalRemoteMCPServers:w().optional(),yoloModeAllowed:w().optional(),openTelemetryEnabled:w().optional(),openTelemetryMetricsExporter:d().optional(),openTelemetryLogsExporter:d().optional(),openTelemetryOtlpProtocol:d().optional(),openTelemetryOtlpEndpoint:d().optional(),openTelemetryOtlpHeaders:j(d(),d()).optional(),openTelemetryOtlpMetricsProtocol:d().optional(),openTelemetryOtlpMetricsEndpoint:d().optional(),openTelemetryOtlpMetricsHeaders:j(d(),d()).optional(),openTelemetryOtlpLogsProtocol:d().optional(),openTelemetryOtlpLogsEndpoint:d().optional(),openTelemetryOtlpLogsHeaders:j(d(),d()).optional(),openTelemetryMetricExportInterval:x().optional(),openTelemetryOtlpInsecure:w().optional(),openTelemetryLogBatchSize:x().optional(),openTelemetryLogBatchTimeout:x().optional(),openTelemetryLogMaxQueueSize:x().optional(),enterpriseTelemetry:jd.optional(),globalRules:E(si).optional(),globalWorkflows:E(si).optional()}),vy=j(d(),d());var Ty=25463,Cy=25466,ky=4317;var Ey="127.0.0.1:4317";var Ry=I(["reasoning","prompt-cache","tools","provider-tools","oauth","temperature","files","streaming","vision","computer-use","local-auth","popular"]),Ay=I(["anthropic","gemini","openai-chat","openai-responses","openai-r1","ai-sdk"]),Iy=I(["anthropic","ai-sdk","ai-sdk-community","openai","openai-compatible","openai-r1","gemini","bedrock","custom","fetch","vertex"]);var wy="runtime.team.progress.v1",Py="runtime.team.lifecycle.v1";import{basename as My}from"node:path";var Mn="CLINE_BUILD_ENV",Vd="CLINE_DEBUG_HOST",qd="CLINE_DEBUG_PORT_BASE";function Gd(e){let t=e?.trim().toLowerCase();if(t==="development"||t==="production")return t;return}function Oy(e){for(let t=0;t<e.length;t+=1){let n=e[t]?.trim();if(!n)continue;if(n==="--conditions"&&e[t+1]?.trim()==="development")return!0;if(n.startsWith("--conditions=")&&n.slice(13).split(",").map((r)=>r.trim()).includes("development"))return!0}return!1}function zy(e){if(!e?.trim())return!1;let t=My(e).toLowerCase();return t==="node"||t==="node.exe"||t==="bun"||t==="bun.exe"}function Ny(e){return e.some((t)=>t==="--inspect"||t.startsWith("--inspect=")||t==="--inspect-brk"||t.startsWith("--inspect-brk="))}function $y(e){return e.some((t)=>t==="--enable-source-maps")}function Ly(e){return e[Vd]?.trim()||"127.0.0.1"}function Dy(e){let t=e[qd]?.trim();if(!t)return;let n=Number.parseInt(t,10);return Number.isInteger(n)&&n>0?n:void 0}function By(e){switch(e){case"rpc":return 0;case"hook":return 1;case"plugin-sandbox":return 2;case"connector":return 3;case"sandbox":return 4;default:return 9}}function ai(e={}){let t=e.env??process.env,n=e.execArgv??process.execArgv,r=Gd(t[Mn]);if(r)return r;let o=t.NODE_ENV?.trim().toLowerCase();if(o==="production")return"production";if(o==="development")return"development";return Oy(n)?"development":"production"}function Uy(e=process.env,t={}){if(Gd(e[Mn]))return e;return{...e,[Mn]:ai({env:e,execArgv:t.execArgv})}}function Zy(e,t={}){if(e.length===0||!zy(e[0]))return[...e];if(ai(t)!=="development")return[...e];let n=t.env??process.env,r=[...n.NODE_OPTIONS?.split(/\s+/).filter(Boolean)??[],...e.slice(1)],o=[];if(!Ny(r)){let i=Ly(n),s=Dy(n),a=s===void 0?0:s+By(t.debugRole);o.push(`--inspect=${i}:${a}`)}if(!$y(r))o.push("--enable-source-maps");return[e[0],...o,...e.slice(1)]}function Fy(e){let t=e?.trim();if(!t)return!1;if(t.startsWith("/$bunfs/"))return!0;return t.replace(/\\/g,"/").toLowerCase().startsWith("b:/~bun/")}function Kd(){return globalThis}function Hy(e){Kd().__clineClientIdentity=e}function jy(){return Kd().__clineClientIdentity}var Vy="CLINE_ENVIRONMENT",qy="CLINE_ENVIRONMENT_OVERRIDE",ci={production:{environment:"production",appBaseUrl:"https://app.cline.bot",apiBaseUrl:"https://api.cline.bot",mcpBaseUrl:"https://api.cline.bot/v1/mcp",workOsClientId:"client_01K3A541FN8TA3EPPHTD2325AR"},staging:{environment:"staging",appBaseUrl:"https://staging-app.cline.bot",apiBaseUrl:"https://core-api.staging.int.cline.bot",mcpBaseUrl:"https://core-api.staging.int.cline.bot/v1/mcp",workOsClientId:"client_01K3A5415VF6QBQBG3XYCW91G6"},local:{environment:"local",appBaseUrl:"http://localhost:3000",apiBaseUrl:"http://localhost:7777",mcpBaseUrl:"http://localhost:7777/v1/mcp",workOsClientId:"client_01K6XQAY7JK6T5HXVSZW2S5VYK"}},Gy="production";function Wd(e){let t=e?.trim().toLowerCase();if(t==="production"||t==="staging"||t==="local")return t;return}function Jd(){if(typeof process>"u"||!process?.env)return{};return process.env}function Yd(){let e=Jd();return Wd(e.CLINE_ENVIRONMENT_OVERRIDE)??Wd(e.CLINE_ENVIRONMENT)??"production"}function Ky(e){if(typeof e==="string")return ci[e];return ci[Yd()]}function Wy(e,t){if(t.CLINE_API_BASE_URL)e={...e,apiBaseUrl:t.CLINE_API_BASE_URL,mcpBaseUrl:`${t.CLINE_API_BASE_URL}/v1/mcp`};return e}function Jy(e){let t=Ky(e);return Wy(t,Jd())}var Yy="CLINE_RUN_AS_HUB_DAEMON",Xy="CLINE_CONNECTOR_CLI_LAUNCH",Qy="CLINE_CONNECTOR_STARTING_INSTANCE",eb="CLINE_CONNECTOR_SUPERVISED",ui;function tb(e=process.env){return ui=e.CLINE_RUN_AS_HUB_DAEMON==="1",delete e.CLINE_RUN_AS_HUB_DAEMON,ui}function nb(e){if(e)return e.CLINE_RUN_AS_HUB_DAEMON==="1";return ui??process.env.CLINE_RUN_AS_HUB_DAEMON==="1"}function rb(e,t=process.env){t.CLINE_CONNECTOR_CLI_LAUNCH=JSON.stringify(e)}var li;function ob(e=process.env){return li=e.CLINE_CONNECTOR_SUPERVISED==="1",delete e.CLINE_CONNECTOR_SUPERVISED,li}function ib(e){if(e)return e.CLINE_CONNECTOR_SUPERVISED==="1";return li??process.env.CLINE_CONNECTOR_SUPERVISED==="1"}function sb(e,t=process.env){t.CLINE_CONNECTOR_STARTING_INSTANCE=JSON.stringify(e)}function ab(e=process.env){let t=e.CLINE_CONNECTOR_STARTING_INSTANCE;if(!t)return;try{let n=JSON.parse(t);if(typeof n.channel!=="string"||!n.channel.trim()||typeof n.instanceId!=="string"||!n.instanceId.trim())return;return{channel:n.channel,instanceId:n.instanceId}}catch{return}}function cb(e=process.env){let t=e.CLINE_CONNECTOR_CLI_LAUNCH;if(!t)return;try{let n=JSON.parse(t);if(typeof n.launcher!=="string"||!n.launcher.trim()||!Array.isArray(n.connectArgsPrefix)||!n.connectArgsPrefix.every((r)=>typeof r==="string")||typeof n.cwd!=="string"||!n.cwd.trim())return;return{launcher:n.launcher,connectArgsPrefix:n.connectArgsPrefix,cwd:n.cwd}}catch{return}}var ub=["HTTP_PROXY","http_proxy","HTTPS_PROXY","https_proxy","ALL_PROXY","all_proxy"],Qd=["localhost","127.0.0.1","::1","[::1]"];function lb(e){for(let t of ub){let n=e[t]?.trim();if(n)return n}return}function di(e){return(e??"").split(",").map((t)=>t.trim()).filter((t)=>t.length>0)}function db(e,t){let n=[],r=new Set;for(let o of[...di(e),...di(t),...Qd]){let i=o.toLowerCase();if(i!=="*"&&!r.has(i))r.add(i),n.push(o)}return n.join(",")}function Xd(e){return di(e).includes("*")}function pb(e=process.env){if(!lb(e))return;let t=Xd(e.NO_PROXY),n=Xd(e.no_proxy);if(t&&n)return;let r=db(e.NO_PROXY,e.no_proxy);if(!t)e.NO_PROXY=r;if(!n)e.no_proxy=r}var mb="NoDefaultCurrentDirectoryInExePath";function fb(e={}){let{env:t=process.env,platform:n=process.platform}=e;if(n!=="win32")return;t.NoDefaultCurrentDirectoryInExePath="1"}var gb="agent.reasoning.unexpected_tokens",hb="task.provider_request_started",yb="task.provider_stream_started",bb="task.first_chunk_received",xb="task.provider_stream_failed",Sb="task.cancelled",_b="task.max_tokens_recovery",vb=["initial","crash_restart","rollout_fallback","rollout_demotion","user_restart"],Tb="sdk.error";var De=new Map;function Cb(){De.clear()}function kb(e,t){let n=typeof t.error_message==="string"?t.error_message:"";return[e,t.component,t.operation,t.error_type,t.error_code??"",t.error_status??"",n.replace(/\d+/g,"#").replace(/\s+/g," ").trim().toLowerCase().slice(0,256)].join("\x00")}function Eb(e){let t=Date.now(),n=De.get(e);if(n&&t-n.startMs<3600000){if(n.emitted<5)return n.emitted+=1,{emit:!0,suppressed:0};return n.suppressed+=1,{emit:!1,suppressed:n.suppressed}}let r=n?.suppressed??0;if(De.delete(e),De.size>=512){let o=De.keys().next();if(!o.done)De.delete(o.value)}return De.set(e,{startMs:t,emitted:1,suppressed:0}),{emit:!0,suppressed:r}}function Rb(e,t){e?.capture({event:"agent.reasoning.unexpected_tokens",properties:mi({sessionId:t.sessionId,agentId:t.agentId,runId:t.runId,iteration:t.iteration,providerId:t.providerId,modelId:t.modelId,requestedThinking:t.requestedThinking,reasoningTokenCount:t.reasoningTokenCount})})}function Ab(e,t){if(!e)return;e.capture({event:t.event,properties:mi({sessionId:t.sessionId,ulid:t.ulid??t.sessionId,agentId:t.agentId,conversationId:t.conversationId,runId:t.runId,iteration:t.iteration,provider:t.providerId,providerId:t.providerId,model:t.modelId,modelId:t.modelId,phase:t.phase,durationMs:t.durationMs,eventType:t.eventType,...t.error===void 0?{}:fi(t.error,t.messageLimit),error_class:t.errorClass})})}function Ib(e,t){if(!e)return!1;let n=t.event??"sdk.error",r=ep(t),o=0;try{let i=Eb(kb(n,r));if(!i.emit)return!0;o=i.suppressed}catch{}return e.capture({event:n,properties:o>0?{...r,suppressed_count:o}:r}),!0}function ep(e){return mi({...e.context??{},component:e.component,operation:e.operation,severity:e.severity??"error",handled:e.handled??!0,...fi(e.error,e.messageLimit,e.errorMessage)})}function mi(e){let t={};for(let[n,r]of Object.entries(e))if(r!==void 0)t[n]=r;return t}function fi(e,t=500,n){let r=Mb(e)?e:void 0,o=e instanceof Error?e:void 0,i=$t(n)??$t(o?.message)??$t(r?.message)??Ob(e)??"Unknown error",s=zb(r?.code),a=pi(r?.status)??pi(r?.statusCode)??pi(r?.responseStatus);return{error_type:o?.name?.trim()||$t(r?.name)||o?.constructor?.name||"Error",error_message:Pb(wb(i),t),...s!==void 0?{error_code:s}:{},...a!==void 0?{error_status:a}:{}}}function wb(e){return e.replace(/(authorization=Bearer\s+)[^&\s]+/gi,"$1[redacted]").replace(/(api[_-]?key|access[_-]?token|refresh[_-]?token|authorization|password|secret)=([^&\s]+)/gi,"$1=[redacted]").replace(/(Bearer\s+)[A-Za-z0-9._~+/-]+=*/gi,"$1[redacted]").replace(/\/Users\/[^/\s]+/g,"/Users/[redacted]").replace(/\/home\/[^/\s]+/g,"/home/[redacted]").replace(/([A-Za-z]:[\\/]+Users[\\/]+)[^\\/\s]+/g,"$1[redacted]")}function Pb(e,t){let n=Math.max(1,Math.floor(t));return e.length>n?e.substring(0,n):e}function Mb(e){return typeof e==="object"&&e!==null}function $t(e){return typeof e==="string"&&e.trim().length>0?e:void 0}function Ob(e){if(e instanceof Error)return;let t=typeof e==="string"?e:String(e);return t==="[object Object]"?void 0:$t(t)}function zb(e){if(typeof e==="string"&&e.trim().length>0)return e;if(typeof e==="number"&&Number.isFinite(e))return e;return}function pi(e){return typeof e==="number"&&Number.isFinite(e)?e:void 0}var gi="_clineOtlpTraceRelay";function Nb(e){e[gi]=!0}function $b(e){return!!e&&typeof e==="object"&&e[gi]===!0}function tp(e){let t={};if(!e)return t;return e.split(",").forEach((n)=>{let r=n.indexOf("=");if(r<=0)return;try{let o=decodeURIComponent(n.substring(0,r).trim()),i=decodeURIComponent(n.substring(r+1).trim());if(!o||!i)return;t[o]=i}catch{}}),t}function Lb(){if(!process.env)return{enabled:!1};return{enabled:process.env.OTEL_TELEMETRY_ENABLED==="1"||process.env.OTEL_TELEMETRY_ENABLED==="true",metricsExporter:process.env.OTEL_METRICS_EXPORTER||"otlp",logsExporter:process.env.OTEL_LOGS_EXPORTER||"otlp",tracesExporter:process.env.OTEL_TRACES_EXPORTER,otlpProtocol:process.env.OTEL_EXPORTER_OTLP_PROTOCOL||"http/json",otlpEndpoint:process.env.OTEL_EXPORTER_OTLP_ENDPOINT,metricExportInterval:process.env.OTEL_METRIC_EXPORT_INTERVAL?Number.parseInt(process.env.OTEL_METRIC_EXPORT_INTERVAL,10):void 0,otlpHeaders:process.env.OTEL_EXPORTER_OTLP_HEADERS?tp(process.env.OTEL_EXPORTER_OTLP_HEADERS):void 0}}function np(e={}){return{extension_version:"unknown",cline_type:"unknown",platform:"terminal",platform_version:process?.version||"unknown",os_type:process?.platform||"unknown",os_version:process?.platform==="win32"?process?.env?.OS??"unknown":"unknown",...e}}function Db(e={}){return{...Lb(),...e,metadata:np(e.metadata)}}function rp(e){let t=e?.trim();return t?t:void 0}function Bb(e,t){if(!e)return;let n=typeof e==="function"?e(t):e;if(!n)return;let r=rp(n.rootSessionId);if(!r)return;return{rootSessionId:r}}function Ub(e){return rp(e?.rootSessionId)}import{webcrypto as op}from"node:crypto";var Zb=128,Pe,it;function Fb(e){if(e<0)throw RangeError("Wrong ID size");try{if(!Pe||Pe.length<e)Pe=Buffer.allocUnsafe(e*Zb),op.getRandomValues(Pe),it=0;else if(it+e>Pe.length)op.getRandomValues(Pe),it=0}catch(t){throw Pe=void 0,t}it+=e}function Hb(e){return Fb(e|=0),Pe.subarray(it-e,it)}function jb(e,t,n){let r=256-256%e.length;if(r===256){let i=e.length-1;return(s=t)=>{if(!s)return"";let a="";while(!0){let c=n(s),u=s;while(u--)if(a+=e[c[u]&i],a.length>=s)return a}}}let o=Math.ceil(409.6*t/r);return(i=t)=>{if(!i)return"";let s="";while(!0){let a=n(o),c=o;while(c--)if(a[c]<r){if(s+=e[a[c]%e.length],s.length>=i)return s}}}}function ip(e,t=21){return jb(e,t,Hb)}function Vb(e="",t=""){let n=ip("1234567890abcdefghijklmnopqrstuvwxyz",10);return`${e}${Date.now()}_${n(5)}${t}`}var qb=["idle","running","pending","completed","failed","cancelled"];var hi=["rules","skills","workflows","plugins","hooks"],sp=hi,Gb=new Set(hi);function ap(e){return typeof e==="string"&&Gb.has(e)}function Kb(e){if(!Array.isArray(e))return;let t=e.map((n)=>typeof n==="string"?n.trim():"").filter(ap);return[...new Set(t)]}function Wb(e,t){return new Set(e??sp).has(t)}var Jb=b({rootPath:d().min(1),hint:d().min(1).optional(),associatedRemoteUrls:E(d().min(1)).optional(),latestGitCommitHash:d().min(1).optional(),latestGitBranchName:d().min(1).optional()}),Yb=b({currentWorkspacePath:d().min(1).optional(),workspaces:j(d().min(1),Jb)});function WC(){return{workspaces:{}}}function JC(e,t){let n={...e,workspaces:{...e.workspaces,[t.rootPath]:t}};if(!n.currentWorkspacePath)n.currentWorkspacePath=t.rootPath;return Yb.parse(n)}var Xb="workspaces",Qb="chat";function ex(e){let t=e.trim(),n=/^[A-Za-z]:[\\/]/.test(t)||t.startsWith("\\\\"),r=t.startsWith("/");if(!n&&!r)return!1;let o=t.split(n?/[\\/]+/:/\/+/).filter(Boolean),i=o.at(-1)??"",s=o.at(-2)??"",a=o.at(-3)??"";return(o.at(-4)??"")===".cline"&&a==="data"&&s==="workspaces"&&i==="chat"}var tx=["current_state","boundary_analysis","interface_proposal"],ek=3600000,tk=240,nk=400,le=Ku((e)=>e instanceof Date?e.toISOString():e,d().datetime()),st=I(["pending","in_progress","blocked","completed"]),cp=I(["queued","running","completed","failed","cancelled","interrupted"]),On=I(["draft","in_review","finalized"]),nx=b({agentId:d(),role:I(["lead","teammate"]),description:d().optional(),status:I(["idle","running","stopped"])}),rk=b({agentId:d(),rolePrompt:d(),modelId:d().optional(),maxIterations:x().optional()});function Z(e){return Ku((t)=>t===null?void 0:t,e.optional())}var ok=b({agentId:d().min(1).describe("Teammate identifier"),rolePrompt:d().min(1).describe("System prompt describing teammate role")}).strict(),ik=b({agentId:d().min(1).describe("Teammate identifier"),reason:Z(d().min(1)).describe("Optional shutdown reason")}),sk=b({}),rx={create:["title","description"],list:[],claim:["taskId"],complete:["taskId","summary"],block:["taskId","reason"]},ak={create:["status","taskId","summary","reason"]},ck=b({action:I(["create","list","claim","complete","block"]),title:Z(d().min(1)).describe("Task title"),description:Z(d().min(1)).describe("Task details"),dependsOn:Z(E(d().describe("Dependency task ID"))).describe("Array of dependency task IDs"),assignee:Z(d().min(1)).describe("Optional assignee"),status:Z(I(["pending","in_progress","blocked","completed"])).describe("Optional task status filter"),taskId:Z(d()).describe("Task ID"),summary:Z(d().min(1)).describe("Completion summary"),reason:Z(d().min(1)).describe("Blocking reason")}).superRefine((e,t)=>{for(let n of rx[e.action]){if(e[n]!==void 0)continue;t.addIssue({code:"custom",path:[n],message:`Field "${n}" is required when action=${e.action}`})}}),uk=b({agentId:d().describe("Teammate agent ID"),task:d().min(1).describe("Task instructions for the teammate"),taskId:Z(d()).describe("Optional shared task list ID"),runMode:Z(I(["sync","async"])).describe("Execution mode: 'sync' blocks until the teammate finishes and returns the result (default if omitted); 'async' queues the run and returns a runId immediately — use team_await_runs to collect results later."),continueConversation:Z(w()).describe("If true, continue the teammate conversation; otherwise start fresh")}),lk=b({status:Z(I(["queued","running","completed","failed","cancelled","interrupted"])).describe("Optional run status filter. Omit to include all statuses."),agentId:Z(d().min(1)).describe("Optional teammate ID filter. Omit to include all teammates."),includeCompleted:Z(w()).describe("Include completed/failed runs (default true)")}),dk=b({runId:d().min(1).describe("Run ID"),reason:Z(d().min(1)).describe("Optional cancellation reason")}),pk=b({runId:Z(d().min(1)).describe("Optional async run ID to await. Omit to wait for all active async runs.")}).strict(),mk=b({toAgentId:d().min(1).describe("Recipient agent ID"),subject:d().min(1).describe("Message subject"),body:d().min(1).describe("Message body"),taskId:Z(d().min(1)).describe("Optional task ID context")}),fk=b({subject:d().min(1).describe("Message subject"),body:d().min(1).describe("Message body"),taskId:Z(d().min(1)).describe("Optional task ID context")}),gk=b({unreadOnly:Z(w()).describe("Only unread messages for read action (default true)")}),hk=b({kind:I(["progress","handoff","blocked","decision","done","error"]),summary:d().min(1).describe("Update summary"),taskId:Z(d().min(1)).describe("Optional task ID context"),evidence:Z(E(d().min(1))).describe("Optional evidence links/snippets"),nextAction:Z(d().min(1)).describe("Planned next step")}),yk=b({}),bk=b({title:d().describe("Outcome title"),requiredSections:E(d()).default(tx).describe("Required sections for finalization gate (defaults to current_state,boundary_analysis,interface_proposal)")}),xk=b({outcomeId:d().describe("Outcome ID"),section:d().describe("Section name"),sourceRunId:Z(d()).describe("Optional source run ID"),content:d().describe("Section fragment content")}),Sk=b({fragmentId:d().describe("Fragment ID"),approved:w().describe("Review decision")}),_k=b({outcomeId:d().describe("Outcome ID")}),vk=b({}),Tk=b({teamId:d(),teamName:d(),members:E(nx),taskCounts:j(st,x()),unreadMessages:x(),missionLogEntries:x(),activeRuns:x(),queuedRuns:x(),outcomeCounts:j(On,x())}),ox=b({id:d(),title:d(),description:d(),status:st,createdAt:le,updatedAt:le,createdBy:d(),assignee:d().optional(),dependsOn:E(d()),summary:d().optional(),isReady:w(),blockedBy:E(d())}),Ck=ao("action",[b({action:V("create"),taskId:d(),status:st,ignoredFields:E(d()).optional(),note:d().optional()}),b({action:V("list"),tasks:E(ox)}),b({action:V("claim"),taskId:d(),status:st,nextStep:d()}),b({action:V("complete"),taskId:d(),status:st}),b({action:V("block"),taskId:d(),status:st})]),kk=b({agentId:d(),mode:I(["sync","async"]),status:I(["dispatched","running","queued","joined"]),dispatched:w(),message:d(),deduped:w().optional(),runId:d().optional(),text:d().optional(),iterations:x().optional()}),ix=b({textPreview:d(),iterations:x(),finishReason:d(),durationMs:x(),usage:b({inputTokens:x(),outputTokens:x(),cacheReadTokens:x().optional(),cacheWriteTokens:x().optional(),totalCost:x().optional()})}),Ek=b({id:d(),agentId:d(),taskId:d().optional(),status:cp,messagePreview:d(),priority:x(),retryCount:x(),maxRetries:x(),nextAttemptAt:le.optional(),continueConversation:w().optional(),startedAt:le,endedAt:le.optional(),leaseOwner:d().optional(),heartbeatAt:le.optional(),lastProgressAt:le.optional(),lastProgressMessage:d().optional(),currentActivity:d().optional(),error:d().optional(),resultSummary:ix.optional()}),Rk=b({id:d(),teamId:d(),fromAgentId:d(),toAgentId:d(),subject:d(),body:d(),taskId:d().optional(),sentAt:le,readAt:le.optional()}),Ak=b({id:d(),teamId:d(),title:d(),status:On,requiredSections:E(d()),createdBy:d(),createdAt:le,finalizedAt:le.optional()}),Ik=b({outcomeId:d(),status:On,requiredSections:E(d())}),wk=b({agentId:d(),status:d()}),Pk=b({runId:d(),status:cp}),Mk=b({id:d(),toAgentId:d()}),Ok=b({delivered:x()}),zk=b({id:d()}),Nk=b({status:d()}),$k=b({fragmentId:d(),status:d()}),Lk=b({outcomeId:d(),status:On});var sx;((R)=>{R.TaskStart="task_start";R.TaskEnd="task_end";R.AgentEvent="agent_event";R.TeammateSpawned="teammate_spawned";R.TeammateShutdown="teammate_shutdown";R.TeamTaskUpdated="team_task_updated";R.TeamMessage="team_message";R.TeamMissionLog="team_mission_log";R.TeamTaskCompleted="team_task_completed";R.RunStarted="run_started";R.RunQueued="run_queued";R.RunProgress="run_progress";R.RunCompleted="run_completed";R.RunFailed="run_failed";R.RunCancelled="run_cancelled";R.RunInterrupted="run_interrupted";R.OutcomeCreated="outcome_created";R.OutcomeFragmentAttached="outcome_fragment_attached";R.OutcomeFragmentReviewed="outcome_fragment_reviewed";R.OutcomeFinalized="outcome_finalized"})(sx||={});function ax(e){let{$schema:t,...n}=e;if(typeof n.type==="string")return n;if("properties"in n||"required"in n||"additionalProperties"in n)return{type:"object",...n};for(let r of["oneOf","anyOf","allOf"]){let o=n[r];if(!Array.isArray(o)||o.length===0)continue;if(r==="allOf"){if(o.some((a)=>a&&typeof a==="object"&&a.type==="object"))return{type:"object",...n};throw Error('Tool inputSchema must describe an object at the top level, but the schema has a top-level "allOf" with no branch that asserts type: "object". Add type: "object" to at least one allOf branch to make the object constraint explicit.')}if(o.every((s)=>s&&typeof s==="object"&&s.type==="object"))return{type:"object",...n};throw Error(`Tool inputSchema must describe an object at the top level, but the schema has a top-level "${r}" whose branches include non-object types. Pass the strict object schema as inputSchema and reserve union/coercion schemas for use inside execute().`)}return n}function cx(e){let t=ax(e.inputSchema instanceof N?Vo(e.inputSchema):e.inputSchema);return{name:e.name,resultPolicy:e.resultPolicy,description:e.description,inputSchema:t,lifecycle:e.lifecycle,executionMode:e.executionMode,timeoutMs:e.timeoutMs??30000,retryable:e.retryable??!0,maxRetries:e.maxRetries??3,execute:e.execute}}var up=["401","403","unauthorized","forbidden","invalid token","expired token","authentication"];function ux(e){let t=(e instanceof Error?e.message:String(e)).toLowerCase();return up.some((n)=>t.includes(n))}import{existsSync as lx,mkdirSync as dx,readFileSync as px,writeFileSync as mx}from"node:fs";import{dirname as fx,resolve as gx}from"node:path";var hx=new Set(["accesskeyid","secretaccesskey","idtoken","refreshtoken","accesstoken","access_token","refresh_token","apikey","api_key","authorization","password","secret","token","email","displayname","display_name","userinfo"]),yx=["id","balance","cost","secret"];function bx(e){let t=e.toLowerCase();if(hx.has(t))return!0;for(let n of yx){if(t===n)return!0;if(t.endsWith(n)&&t.length>n.length){let r=t[t.length-n.length-1];if(r==="_"||r==="-")return!0;let o=e[e.length-n.length];if(o&&o===o.toUpperCase()&&o!==o.toLowerCase())return!0}if(t.endsWith(`_${n}`))return!0}return!1}var xx=[{pattern:/AKIA[A-Z0-9]{16}/g,replacement:"AKIA_REDACTED"},{pattern:/\/Users\/[A-Za-z0-9._-]+/g,replacement:"/Users/REDACTED_USER"},{pattern:/\/home\/[A-Za-z0-9._-]+/g,replacement:"/home/REDACTED_USER"}];function dp(e){let t=e;for(let{pattern:n,replacement:r}of xx)t=t.replace(n,r);return t}function yi(e){if(Array.isArray(e))return e.map(yi);if(!e||typeof e!=="object")return e;return Object.fromEntries(Object.entries(e).sort(([t],[n])=>Sx(t,n)).map(([t,n])=>[t,yi(n)]))}function Sx(e,t){if(e<t)return-1;if(e>t)return 1;return 0}function lp(e){return JSON.stringify(yi(e))}var _x=[{pattern:/tasks\/[A-Za-z0-9._-]+\/[A-Za-z0-9._-]+\/api_conversation_history/g,replacement:"tasks/usr-test/taskid/api_conversation_history"},{pattern:/\/(org|usr|mbr|ses|gen|req|msg|tsk|sch|exe|srv|cli|wkr|evt|sub|tkn)-[A-Za-z0-9]{10,}(?=[/?#]|$)/g,replacement:"/$1-REDACTED"}];function bi(e){let t=e;for(let{pattern:n,replacement:r}of _x)t=t.replace(n,r);return t}function at(e){if(e===null||e===void 0)return e;if(typeof e==="string"){try{let t=JSON.parse(e);if(typeof t==="object"&&t!==null)return JSON.stringify(at(t))}catch{}return dp(e)}if(Array.isArray(e))return e.map(at);if(typeof e==="object"){let t={};for(let[n,r]of Object.entries(e))if(bx(n)&&(typeof r==="string"||typeof r==="number"))t[n]="REDACTED";else t[n]=at(r);return t}return e}function vx(e){let t=new URLSearchParams(e),n=Array.from(t.entries());if(n.length===0||n.some(([o])=>o.length===0))return;let r={};for(let[o,i]of n){let s=r[o];if(s===void 0)r[o]=i;else if(Array.isArray(s))s.push(i);else r[o]=[s,i]}return r}function Tx(e){return e?.toLowerCase().split(";")[0]?.trim()==="application/x-www-form-urlencoded"}function pp(e,t){try{return lp(at(JSON.parse(e)))}catch{if(Tx(t)){let n=vx(e);if(n)return lp(at(n))}return dp(e)}}function Cx(e,t){let n={...e},r=t&&e.body!==void 0?pp(e.body,e.requestContentType):void 0;if(delete n.body,delete n.requestContentType,r!==void 0)n.requestBody=r;if(typeof n.path==="string")n.path=bi(n.path);if(n.response!==void 0)n.response=at(n.response);return n}function mp(e){try{let t=new URL(e),n=`${t.protocol}//${t.host}`,r=t.pathname+t.search;return{scope:n,path:r}}catch{return{scope:"",path:e}}}function fp(e){if(typeof e==="string")return e;if(e instanceof URL)return e.toString();if(e&&typeof e.url==="string")return e.url;return String(e)}function gp(e,t){if(t?.method)return t.method.toUpperCase();if(e&&typeof e.method==="string")return e.method.toUpperCase();return"GET"}function kx(e){if(!e)return;return new Headers(e).get("content-type")??void 0}function hp(e,t){let n=kx(t?.headers);if(n)return n;if(t?.body instanceof URLSearchParams)return"application/x-www-form-urlencoded;charset=UTF-8";if(e instanceof Request)return e.headers.get("content-type")??void 0;return}async function yp(e,t){if(t?.body){if(typeof t.body==="string")return t.body;if(t.body instanceof URLSearchParams)return t.body.toString();if(t.body instanceof ArrayBuffer)return new TextDecoder().decode(t.body);if(ArrayBuffer.isView(t.body))return new TextDecoder().decode(new Uint8Array(t.body.buffer,t.body.byteOffset,t.body.byteLength));return}if(e instanceof Request)try{return await e.clone().text()}catch{return}return}function Ex(e){if(!e)return null;if(!process.env.CLINE_VCR_CASSETTE)return process.stderr.write(`[VCR] No CLINE_VCR_CASSETTE: requests will not be recorded or played back.
178
+ `)}function ti(e,t){return e.filter((n)=>n.kind===t)}class ni{async materialize(e){let t=fy(e.bundle),n=ti(t,"rule"),r=ti(t,"workflow"),o=ti(t,"skill");await e.artifactStore.removeChildren(e.paths.workflowsPath),await e.artifactStore.removeChildren(e.paths.skillsPath);let i=[];if(n.length>0)await e.artifactStore.writeText(e.paths.rulesFilePath,gy(n)),i.push(...n.map((s)=>({kind:s.kind,filePath:e.paths.rulesFilePath,id:s.id,name:s.name})));else await e.artifactStore.remove(e.paths.rulesFilePath);for(let s of r){let a=`${e.paths.workflowsPath}/${Sd(s.name.replace(/\.(md|markdown|txt)$/i,""))}.md`;await e.artifactStore.writeText(a,s.contents),i.push({kind:s.kind,filePath:a,id:s.id,name:s.name})}for(let s of o){let a=`${e.paths.skillsPath}/${Sd(s.name)}/SKILL.md`;await e.artifactStore.writeText(a,s.contents),i.push({kind:s.kind,filePath:a,id:s.id,name:s.name})}return await e.artifactStore.writeText(e.paths.manifestPath,JSON.stringify({source:e.bundle.source,version:e.bundle.version,files:i},null,2)),{paths:e.paths,rulesFilePath:n.length>0?e.paths.rulesFilePath:void 0,files:i}}}import ot from"node:path";var hy="remote-config";function ri(e){let t=e.pluginName??hy,n=ot.join(e.workspacePath,".cline",t);return{pluginName:t,pluginPath:n,workflowsPath:ot.join(n,"workflows"),skillsPath:ot.join(n,"skills"),bundleCachePath:ot.join(n,"cache","bundle.json"),manifestPath:ot.join(n,"managed.json"),rulesFilePath:ot.join(n,"rules.md")}}function vd(e){return{workflowsDirectories:[e.workflowsPath],skillsDirectories:[e.skillsPath]}}function yy(e){if(!e)return;return{enabled:e.openTelemetryEnabled??!1,metricsExporter:e.openTelemetryMetricsExporter,logsExporter:e.openTelemetryLogsExporter,otlpProtocol:e.openTelemetryOtlpProtocol,otlpEndpoint:e.openTelemetryOtlpEndpoint,otlpHeaders:e.openTelemetryOtlpHeaders,otlpMetricsProtocol:e.openTelemetryOtlpMetricsProtocol,otlpMetricsEndpoint:e.openTelemetryOtlpMetricsEndpoint,otlpMetricsHeaders:e.openTelemetryOtlpMetricsHeaders,otlpLogsProtocol:e.openTelemetryOtlpLogsProtocol,otlpLogsEndpoint:e.openTelemetryOtlpLogsEndpoint,otlpLogsHeaders:e.openTelemetryOtlpLogsHeaders,metricExportInterval:e.openTelemetryMetricExportInterval,otlpInsecure:e.openTelemetryOtlpInsecure,logBatchSize:e.openTelemetryLogBatchSize,logBatchTimeout:e.openTelemetryLogBatchTimeout,logMaxQueueSize:e.openTelemetryLogMaxQueueSize}}function Td(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function we(e,t){let n=e[t];return typeof n==="string"?n:void 0}function Cd(e,t){let n=e[t];return typeof n==="boolean"?n:void 0}function wn(e,t){let n=e[t];return typeof n==="number"&&Number.isFinite(n)?n:void 0}function oi(e,t){let n=e[t];if(!Td(n))return;let r=Object.entries(n).filter((o)=>typeof o[1]==="string");return r.length>0?Object.fromEntries(r):void 0}function by(e){if(!Td(e))return;let t={enabled:Cd(e,"enabled"),metricsExporter:we(e,"metricsExporter"),logsExporter:we(e,"logsExporter"),otlpProtocol:we(e,"otlpProtocol"),otlpEndpoint:we(e,"otlpEndpoint"),otlpHeaders:oi(e,"otlpHeaders"),otlpMetricsProtocol:we(e,"otlpMetricsProtocol"),otlpMetricsEndpoint:we(e,"otlpMetricsEndpoint"),otlpMetricsHeaders:oi(e,"otlpMetricsHeaders"),otlpLogsProtocol:we(e,"otlpLogsProtocol"),otlpLogsEndpoint:we(e,"otlpLogsEndpoint"),otlpLogsHeaders:oi(e,"otlpLogsHeaders"),metricExportInterval:wn(e,"metricExportInterval"),otlpInsecure:Cd(e,"otlpInsecure"),logBatchSize:wn(e,"logBatchSize"),logBatchTimeout:wn(e,"logBatchTimeout"),logMaxQueueSize:wn(e,"logMaxQueueSize")};return Object.values(t).some((n)=>n!==void 0)?t:void 0}class ii{name="remote-config";resolveTelemetry(e,t){return{...yy(e.remoteConfig),...by(e.telemetry)}}}async function xy(e){let t=ri(e),n=e.artifactStore??new Rn;await n.removeChildren(t.workflowsPath),await n.removeChildren(t.skillsPath),await n.remove(t.rulesFilePath),await n.remove(t.manifestPath),await n.remove(t.bundleCachePath)}function kd(e){return e?.claims}function Ed(e,t){if(!e)return[];if(t.claimsMapper)return t.claimsMapper.mapClaimsToRoles(e);return e.roles??[]}function _y(e,t){return{...e,metadata:{...e.metadata??{},paths:t}}}class Rd{options;constructor(e){this.options=e}async sync(e){let t=await this.options.controlPlane.fetchBundle({workspacePath:e.workspacePath,rootPath:e.rootPath,context:e.context,signal:e.signal,now:e.now,logger:this.options.logger});if(!t)throw Error("Remote config control plane returned no bundle");await this.options.bundleStore.write(t);let n=await this.options.materializer.materialize({bundle:t,paths:e.paths,artifactStore:this.options.artifactStore}),r=this.options.telemetryAdapter?await this.options.telemetryAdapter.resolveTelemetry(t,{workspacePath:e.workspacePath,rootPath:e.rootPath,context:e.context,signal:e.signal,now:e.now,logger:this.options.logger}):void 0,o=kd(t),i=Ed(o,this.options);return{bundle:t,materialized:n,telemetry:r,roles:i,claims:o}}}function Sy(e){let t=e?.name??"remote-config";return{name:t,manifest:{capabilities:["providers"]},async setup(n,r){n.registerProvider?.({name:t,description:"Remote-config managed runtime integration"}),await e?.setup?.(n,r)}}}async function vy(e){let t=ri({workspacePath:e.workspacePath,pluginName:e.pluginName}),n=e.bundleStore??new Jo(t.bundleCachePath),r=e.artifactStore??new Rn,o=e.materializer??new ni,i=e.telemetryAdapter??new ii,s,a,c=[],u,l=!1,p=!1;if(e.controlPlane){let f=new Rd({controlPlane:e.controlPlane,bundleStore:n,artifactStore:r,materializer:o,telemetryAdapter:i,claimsMapper:e.claimsMapper,logger:e.logger});try{let g=await f.sync({workspacePath:e.workspacePath,rootPath:e.rootPath,context:e.context,paths:t,signal:e.signal,now:e.now});s=g.bundle,a=g.telemetry,c=g.roles,u=g.claims,p=!0}catch(g){if(e.useCachedBundle!==!1)s=await n.read(),l=Boolean(s);if(!s)throw g}}else if(e.useCachedBundle!==!1)s=await n.read(),l=Boolean(s);if(!s&&e.requireBundle)throw Error("Remote config runtime preparation requires a bundle");if(s){let f=_y(s,t);if(await n.write(f),!p)await o.materialize({bundle:f,paths:t,artifactStore:r});u??=kd(f),c=c.length>0?c:Ed(u,e),a??=await i.resolveTelemetry(f,{workspacePath:e.workspacePath,rootPath:e.rootPath,context:e.context,signal:e.signal,now:e.now,logger:e.logger}),s=f}let m=vd(t);return{pluginName:t.pluginName,pluginDefinition:Sy({name:t.pluginName}),paths:t,bundle:s,telemetry:a,roles:c,claims:u,usedCachedBundle:l,workflowsDirectories:m.workflowsDirectories,skillsDirectories:m.skillsDirectories}}var Ad=b({id:d(),temperature:x().optional(),maxTokens:x().optional(),contextWindow:x().optional(),inputPrice:x().optional(),outputPrice:x().optional(),supportsImages:w().optional()}),Id=b({models:E(Ad).optional(),openAiBaseUrl:d().optional(),openAiHeaders:j(d(),d()).optional(),azureApiVersion:d().optional(),azureIdentity:w().optional()}),wd=b({id:d(),thinkingBudgetTokens:x().optional()}),Pd=b({name:d(),baseModelId:d(),thinkingBudgetTokens:x().optional()}),Md=b({models:E(wd).optional(),customModels:E(Pd).optional(),awsRegion:d().optional(),awsUseCrossRegionInference:w().optional(),awsUseGlobalInference:w().optional(),awsBedrockUsePromptCache:w().optional(),awsBedrockEndpoint:d().optional()}),Od=b({id:d()}),Nd=b({models:E(Od).optional()}),zd=b({id:d(),thinkingBudgetTokens:x().optional()}),$d=b({models:E(zd).optional(),vertexProjectId:d().optional(),vertexRegion:d().optional()}),Ld=b({id:d(),thinkingBudgetTokens:x().optional(),promptCachingEnabled:w().optional()}),Dd=b({models:E(Ld).optional(),baseUrl:d().optional()}),Bd=b({id:d(),thinkingBudgetTokens:x().optional()}),Ud=b({models:E(Bd).optional(),baseUrl:d().optional()}),Cy=b({OpenAiCompatible:Id.optional(),AwsBedrock:Md.optional(),Cline:Nd.optional(),Vertex:$d.optional(),LiteLLM:Dd.optional(),Anthropic:Ud.optional()}),Zd=b({id:d()}),Fd=b({name:d(),url:d(),alwaysEnabled:w().optional(),headers:j(d(),d()).optional()}),si=b({alwaysEnabled:w(),name:d(),contents:d()}),Pn=b({bucket:d(),accessKeyId:d(),secretAccessKey:d(),region:d().optional(),endpoint:d().optional(),accountId:d().optional()}),Hd=b({enabled:w().optional(),type:Ge([V("s3_access_keys"),V("r2_access_keys"),V("azure_access_keys")]).optional(),s3AccessSettings:Pn.optional(),r2AccessSettings:Pn.optional(),azureAccessSettings:Pn.optional()}),jd=b({promptUploading:Hd.optional()}),Ty=b({version:d(),providerSettings:Cy.optional(),telemetryEnabled:w().optional(),kanbanEnabled:w().optional(),mcpMarketplaceEnabled:w().optional(),allowedMCPServers:E(Zd).optional(),remoteMCPServers:E(Fd).optional(),blockPersonalRemoteMCPServers:w().optional(),yoloModeAllowed:w().optional(),openTelemetryEnabled:w().optional(),openTelemetryMetricsExporter:d().optional(),openTelemetryLogsExporter:d().optional(),openTelemetryOtlpProtocol:d().optional(),openTelemetryOtlpEndpoint:d().optional(),openTelemetryOtlpHeaders:j(d(),d()).optional(),openTelemetryOtlpMetricsProtocol:d().optional(),openTelemetryOtlpMetricsEndpoint:d().optional(),openTelemetryOtlpMetricsHeaders:j(d(),d()).optional(),openTelemetryOtlpLogsProtocol:d().optional(),openTelemetryOtlpLogsEndpoint:d().optional(),openTelemetryOtlpLogsHeaders:j(d(),d()).optional(),openTelemetryMetricExportInterval:x().optional(),openTelemetryOtlpInsecure:w().optional(),openTelemetryLogBatchSize:x().optional(),openTelemetryLogBatchTimeout:x().optional(),openTelemetryLogMaxQueueSize:x().optional(),enterpriseTelemetry:jd.optional(),globalRules:E(si).optional(),globalWorkflows:E(si).optional()}),ky=j(d(),d());var Ey=25463,Ry=25466,Ay=4317;var Iy="127.0.0.1:4317";var wy=I(["reasoning","prompt-cache","tools","provider-tools","oauth","temperature","files","streaming","vision","computer-use","local-auth","popular"]),Py=I(["anthropic","gemini","openai-chat","openai-responses","openai-r1","ai-sdk"]),My=I(["anthropic","ai-sdk","ai-sdk-community","openai","openai-compatible","openai-r1","gemini","bedrock","custom","fetch","vertex"]);var Oy="runtime.team.progress.v1",Ny="runtime.team.lifecycle.v1";import{basename as zy}from"node:path";var Mn="CLINE_BUILD_ENV",Vd="CLINE_DEBUG_HOST",qd="CLINE_DEBUG_PORT_BASE";function Gd(e){let t=e?.trim().toLowerCase();if(t==="development"||t==="production")return t;return}function $y(e){for(let t=0;t<e.length;t+=1){let n=e[t]?.trim();if(!n)continue;if(n==="--conditions"&&e[t+1]?.trim()==="development")return!0;if(n.startsWith("--conditions=")&&n.slice(13).split(",").map((r)=>r.trim()).includes("development"))return!0}return!1}function Ly(e){if(!e?.trim())return!1;let t=zy(e).toLowerCase();return t==="node"||t==="node.exe"||t==="bun"||t==="bun.exe"}function Dy(e){return e.some((t)=>t==="--inspect"||t.startsWith("--inspect=")||t==="--inspect-brk"||t.startsWith("--inspect-brk="))}function By(e){return e.some((t)=>t==="--enable-source-maps")}function Uy(e){return e[Vd]?.trim()||"127.0.0.1"}function Zy(e){let t=e[qd]?.trim();if(!t)return;let n=Number.parseInt(t,10);return Number.isInteger(n)&&n>0?n:void 0}function Fy(e){switch(e){case"rpc":return 0;case"hook":return 1;case"plugin-sandbox":return 2;case"connector":return 3;case"sandbox":return 4;default:return 9}}function ai(e={}){let t=e.env??process.env,n=e.execArgv??process.execArgv,r=Gd(t[Mn]);if(r)return r;let o=t.NODE_ENV?.trim().toLowerCase();if(o==="production")return"production";if(o==="development")return"development";return $y(n)?"development":"production"}function Hy(e=process.env,t={}){if(Gd(e[Mn]))return e;return{...e,[Mn]:ai({env:e,execArgv:t.execArgv})}}function jy(e,t={}){if(e.length===0||!Ly(e[0]))return[...e];if(ai(t)!=="development")return[...e];let n=t.env??process.env,r=[...n.NODE_OPTIONS?.split(/\s+/).filter(Boolean)??[],...e.slice(1)],o=[];if(!Dy(r)){let i=Uy(n),s=Zy(n),a=s===void 0?0:s+Fy(t.debugRole);o.push(`--inspect=${i}:${a}`)}if(!By(r))o.push("--enable-source-maps");return[e[0],...o,...e.slice(1)]}function Vy(e){let t=e?.trim();if(!t)return!1;if(t.startsWith("/$bunfs/"))return!0;return t.replace(/\\/g,"/").toLowerCase().startsWith("b:/~bun/")}function Kd(){return globalThis}function qy(e){Kd().__clineClientIdentity=e}function Gy(){return Kd().__clineClientIdentity}var Ky="CLINE_ENVIRONMENT",Wy="CLINE_ENVIRONMENT_OVERRIDE",ci={production:{environment:"production",appBaseUrl:"https://app.cline.bot",apiBaseUrl:"https://api.cline.bot",mcpBaseUrl:"https://api.cline.bot/v1/mcp",workOsClientId:"client_01K3A541FN8TA3EPPHTD2325AR"},staging:{environment:"staging",appBaseUrl:"https://staging-app.cline.bot",apiBaseUrl:"https://core-api.staging.int.cline.bot",mcpBaseUrl:"https://core-api.staging.int.cline.bot/v1/mcp",workOsClientId:"client_01K3A5415VF6QBQBG3XYCW91G6"},local:{environment:"local",appBaseUrl:"http://localhost:3000",apiBaseUrl:"http://localhost:7777",mcpBaseUrl:"http://localhost:7777/v1/mcp",workOsClientId:"client_01K6XQAY7JK6T5HXVSZW2S5VYK"}},Jy="production";function Wd(e){let t=e?.trim().toLowerCase();if(t==="production"||t==="staging"||t==="local")return t;return}function Jd(){if(typeof process>"u"||!process?.env)return{};return process.env}function Yd(){let e=Jd();return Wd(e.CLINE_ENVIRONMENT_OVERRIDE)??Wd(e.CLINE_ENVIRONMENT)??"production"}function Yy(e){if(typeof e==="string")return ci[e];return ci[Yd()]}function Xy(e,t){if(t.CLINE_API_BASE_URL)e={...e,apiBaseUrl:t.CLINE_API_BASE_URL,mcpBaseUrl:`${t.CLINE_API_BASE_URL}/v1/mcp`};return e}function Qy(e){let t=Yy(e);return Xy(t,Jd())}var eb="CLINE_RUN_AS_HUB_DAEMON",tb="CLINE_CONNECTOR_CLI_LAUNCH",nb="CLINE_CONNECTOR_STARTING_INSTANCE",rb="CLINE_CONNECTOR_SUPERVISED",ob="CLINE_HUB_LAUNCHER_CLIENT",ib="CLINE_HUB_LAUNCHER_VERSION",sb="CLINE_HUB_LAUNCHER_TRANSPORT";function ab(e,t){if(e.CLINE_HUB_LAUNCHER_CLIENT?.trim())return e;let n=t?.client?.trim();if(!n)return e;let r=t?.version?.trim();return{...e,["CLINE_HUB_LAUNCHER_CLIENT"]:n,...r?{["CLINE_HUB_LAUNCHER_VERSION"]:r}:{},["CLINE_HUB_LAUNCHER_TRANSPORT"]:t?.transport??"local"}}function cb(e=process.env){let t=Xd(e);return delete e.CLINE_HUB_LAUNCHER_CLIENT,delete e.CLINE_HUB_LAUNCHER_VERSION,delete e.CLINE_HUB_LAUNCHER_TRANSPORT,t}function Xd(e=process.env){let t=e.CLINE_HUB_LAUNCHER_CLIENT?.trim();if(!t)return;let n=e.CLINE_HUB_LAUNCHER_VERSION?.trim(),r=e.CLINE_HUB_LAUNCHER_TRANSPORT?.trim();return{client:t,...n?{version:n}:{},...r==="ssh"||r==="local"?{transport:r}:{}}}var ui;function ub(e=process.env){return ui=e.CLINE_RUN_AS_HUB_DAEMON==="1",delete e.CLINE_RUN_AS_HUB_DAEMON,ui}function lb(e){if(e)return e.CLINE_RUN_AS_HUB_DAEMON==="1";return ui??process.env.CLINE_RUN_AS_HUB_DAEMON==="1"}function db(e,t=process.env){t.CLINE_CONNECTOR_CLI_LAUNCH=JSON.stringify(e)}var li;function pb(e=process.env){return li=e.CLINE_CONNECTOR_SUPERVISED==="1",delete e.CLINE_CONNECTOR_SUPERVISED,li}function mb(e){if(e)return e.CLINE_CONNECTOR_SUPERVISED==="1";return li??process.env.CLINE_CONNECTOR_SUPERVISED==="1"}function fb(e,t=process.env){t.CLINE_CONNECTOR_STARTING_INSTANCE=JSON.stringify(e)}function gb(e=process.env){let t=e.CLINE_CONNECTOR_STARTING_INSTANCE;if(!t)return;try{let n=JSON.parse(t);if(typeof n.channel!=="string"||!n.channel.trim()||typeof n.instanceId!=="string"||!n.instanceId.trim())return;return{channel:n.channel,instanceId:n.instanceId}}catch{return}}function hb(e=process.env){let t=e.CLINE_CONNECTOR_CLI_LAUNCH;if(!t)return;try{let n=JSON.parse(t);if(typeof n.launcher!=="string"||!n.launcher.trim()||!Array.isArray(n.connectArgsPrefix)||!n.connectArgsPrefix.every((r)=>typeof r==="string")||typeof n.cwd!=="string"||!n.cwd.trim())return;return{launcher:n.launcher,connectArgsPrefix:n.connectArgsPrefix,cwd:n.cwd}}catch{return}}var yb=["HTTP_PROXY","http_proxy","HTTPS_PROXY","https_proxy","ALL_PROXY","all_proxy"],ep=["localhost","127.0.0.1","::1","[::1]"];function bb(e){for(let t of yb){let n=e[t]?.trim();if(n)return n}return}function di(e){return(e??"").split(",").map((t)=>t.trim()).filter((t)=>t.length>0)}function xb(e,t){let n=[],r=new Set;for(let o of[...di(e),...di(t),...ep]){let i=o.toLowerCase();if(i!=="*"&&!r.has(i))r.add(i),n.push(o)}return n.join(",")}function Qd(e){return di(e).includes("*")}function _b(e=process.env){if(!bb(e))return;let t=Qd(e.NO_PROXY),n=Qd(e.no_proxy);if(t&&n)return;let r=xb(e.NO_PROXY,e.no_proxy);if(!t)e.NO_PROXY=r;if(!n)e.no_proxy=r}var Sb="NoDefaultCurrentDirectoryInExePath";function vb(e={}){let{env:t=process.env,platform:n=process.platform}=e;if(n!=="win32")return;t.NoDefaultCurrentDirectoryInExePath="1"}var Cb="agent.reasoning.unexpected_tokens",Tb="task.provider_request_started",kb="task.provider_stream_started",Eb="task.first_chunk_received",Rb="task.provider_stream_failed",Ab="task.cancelled",Ib="task.max_tokens_recovery",wb=["initial","crash_restart","rollout_fallback","rollout_demotion","user_restart"],Pb="sdk.error";var De=new Map;function Mb(){De.clear()}function Ob(e,t){let n=typeof t.error_message==="string"?t.error_message:"";return[e,t.component,t.operation,t.error_type,t.error_code??"",t.error_status??"",n.replace(/\d+/g,"#").replace(/\s+/g," ").trim().toLowerCase().slice(0,256)].join("\x00")}function Nb(e){let t=Date.now(),n=De.get(e);if(n&&t-n.startMs<3600000){if(n.emitted<5)return n.emitted+=1,{emit:!0,suppressed:0};return n.suppressed+=1,{emit:!1,suppressed:n.suppressed}}let r=n?.suppressed??0;if(De.delete(e),De.size>=512){let o=De.keys().next();if(!o.done)De.delete(o.value)}return De.set(e,{startMs:t,emitted:1,suppressed:0}),{emit:!0,suppressed:r}}function zb(e,t){e?.capture({event:"agent.reasoning.unexpected_tokens",properties:mi({sessionId:t.sessionId,agentId:t.agentId,runId:t.runId,iteration:t.iteration,providerId:t.providerId,modelId:t.modelId,requestedThinking:t.requestedThinking,reasoningTokenCount:t.reasoningTokenCount})})}function $b(e,t){if(!e)return;e.capture({event:t.event,properties:mi({sessionId:t.sessionId,modelRequestId:t.modelRequestId,ulid:t.ulid??t.sessionId,agentId:t.agentId,conversationId:t.conversationId,runId:t.runId,iteration:t.iteration,provider:t.providerId,providerId:t.providerId,model:t.modelId,modelId:t.modelId,phase:t.phase,durationMs:t.durationMs,eventType:t.eventType,...t.error===void 0?{}:fi(t.error,t.messageLimit),error_class:t.errorClass})})}function Lb(e,t){if(!e)return!1;let n=t.event??"sdk.error",r=rp(t),o=0;try{let i=Nb(Ob(n,r));if(!i.emit)return!0;o=i.suppressed}catch{}return e.capture({event:n,properties:o>0?{...r,suppressed_count:o}:r}),!0}function rp(e){return mi({...e.context??{},component:e.component,operation:e.operation,severity:e.severity??"error",handled:e.handled??!0,...fi(e.error,e.messageLimit,e.errorMessage)})}function mi(e){let t={};for(let[n,r]of Object.entries(e))if(r!==void 0)t[n]=r;return t}function fi(e,t=500,n){let r=tp(e)?e:void 0,o=e instanceof Error?e:void 0,i=$t(n)??$t(o?.message)??$t(r?.message)??Ub(e)??"Unknown error",s=np(r?.code),a=[],c=new Set([e]),u=r?.cause;while(tp(u)&&!c.has(u)&&a.length<8)c.add(u),a.push(u),u=u.cause;let l=a.map((m)=>np(m.code)).find((m)=>m!==void 0),p=pi(r?.status)??pi(r?.statusCode)??pi(r?.responseStatus);return{error_type:o?.name?.trim()||$t(r?.name)||o?.constructor?.name||"Error",error_message:Bb(Db(i),t),...s!==void 0?{error_code:s}:{},...l!==void 0?{error_cause_code:l}:{},...typeof r?.isRetryable==="boolean"?{error_retryable:r.isRetryable}:{},...p!==void 0?{error_status:p}:{}}}function Db(e){return e.replace(/(authorization=Bearer\s+)[^&\s]+/gi,"$1[redacted]").replace(/(api[_-]?key|access[_-]?token|refresh[_-]?token|authorization|password|secret)=([^&\s]+)/gi,"$1=[redacted]").replace(/(Bearer\s+)[A-Za-z0-9._~+/-]+=*/gi,"$1[redacted]").replace(/\/Users\/[^/\s]+/g,"/Users/[redacted]").replace(/\/home\/[^/\s]+/g,"/home/[redacted]").replace(/([A-Za-z]:[\\/]+Users[\\/]+)[^\\/\s]+/g,"$1[redacted]")}function Bb(e,t){let n=Math.max(1,Math.floor(t));return e.length>n?e.substring(0,n):e}function tp(e){return typeof e==="object"&&e!==null}function $t(e){return typeof e==="string"&&e.trim().length>0?e:void 0}function Ub(e){if(e instanceof Error)return;let t=typeof e==="string"?e:String(e);return t==="[object Object]"?void 0:$t(t)}function np(e){if(typeof e==="string"&&e.trim().length>0)return e;if(typeof e==="number"&&Number.isFinite(e))return e;return}function pi(e){return typeof e==="number"&&Number.isFinite(e)?e:void 0}var gi="_clineOtlpTraceRelay";function Zb(e){e[gi]=!0}function Fb(e){return!!e&&typeof e==="object"&&e[gi]===!0}function op(e){let t={};if(!e)return t;return e.split(",").forEach((n)=>{let r=n.indexOf("=");if(r<=0)return;try{let o=decodeURIComponent(n.substring(0,r).trim()),i=decodeURIComponent(n.substring(r+1).trim());if(!o||!i)return;t[o]=i}catch{}}),t}function Hb(){if(!process.env)return{enabled:!1};return{enabled:process.env.OTEL_TELEMETRY_ENABLED==="1"||process.env.OTEL_TELEMETRY_ENABLED==="true",metricsExporter:process.env.OTEL_METRICS_EXPORTER||"otlp",logsExporter:process.env.OTEL_LOGS_EXPORTER||"otlp",tracesExporter:process.env.OTEL_TRACES_EXPORTER,otlpProtocol:process.env.OTEL_EXPORTER_OTLP_PROTOCOL||"http/json",otlpEndpoint:process.env.OTEL_EXPORTER_OTLP_ENDPOINT,metricExportInterval:process.env.OTEL_METRIC_EXPORT_INTERVAL?Number.parseInt(process.env.OTEL_METRIC_EXPORT_INTERVAL,10):void 0,otlpHeaders:process.env.OTEL_EXPORTER_OTLP_HEADERS?op(process.env.OTEL_EXPORTER_OTLP_HEADERS):void 0}}function ip(e={}){return{extension_version:"unknown",cline_type:"unknown",platform:"terminal",platform_version:process?.version||"unknown",os_type:process?.platform||"unknown",os_version:process?.platform==="win32"?process?.env?.OS??"unknown":"unknown",...e}}function jb(e={}){return{...Hb(),...e,metadata:ip(e.metadata)}}var Vb=new Set(["http:","https:"]);function qb(e){if(!e)return"";try{let t=new URL(e);return Vb.has(t.protocol)&&t.host?t.host:"invalid-endpoint-url"}catch{return"invalid-endpoint-url"}}function Gb(e){return{telemetry_selfcheck:!0,enabled:e.enabled===!0,otlp_endpoint_host:qb(e.otlpEndpoint),logs_exporter:e.logsExporter??"",metrics_exporter:e.metricsExporter??"",traces_exporter:e.tracesExporter??""}}function sp(e){let t=e?.trim();return t?t:void 0}function Kb(e,t){if(!e)return;let n=typeof e==="function"?e(t):e;if(!n)return;let r=sp(n.rootSessionId);if(!r)return;return{rootSessionId:r}}function Wb(e){return sp(e?.rootSessionId)}import{webcrypto as ap}from"node:crypto";var Jb=128,Pe,it;function Yb(e){if(e<0)throw RangeError("Wrong ID size");try{if(!Pe||Pe.length<e)Pe=Buffer.allocUnsafe(e*Jb),ap.getRandomValues(Pe),it=0;else if(it+e>Pe.length)ap.getRandomValues(Pe),it=0}catch(t){throw Pe=void 0,t}it+=e}function Xb(e){return Yb(e|=0),Pe.subarray(it-e,it)}function Qb(e,t,n){let r=256-256%e.length;if(r===256){let i=e.length-1;return(s=t)=>{if(!s)return"";let a="";while(!0){let c=n(s),u=s;while(u--)if(a+=e[c[u]&i],a.length>=s)return a}}}let o=Math.ceil(409.6*t/r);return(i=t)=>{if(!i)return"";let s="";while(!0){let a=n(o),c=o;while(c--)if(a[c]<r){if(s+=e[a[c]%e.length],s.length>=i)return s}}}}function cp(e,t=21){return Qb(e,t,Xb)}function ex(e="",t=""){let n=cp("1234567890abcdefghijklmnopqrstuvwxyz",10);return`${e}${Date.now()}_${n(5)}${t}`}var tx=["idle","running","pending","completed","failed","cancelled"];var hi=["rules","skills","workflows","plugins","hooks"],up=hi,nx=new Set(hi);function lp(e){return typeof e==="string"&&nx.has(e)}function rx(e){if(!Array.isArray(e))return;let t=e.map((n)=>typeof n==="string"?n.trim():"").filter(lp);return[...new Set(t)]}function ox(e,t){return new Set(e??up).has(t)}var ix=b({rootPath:d().min(1),hint:d().min(1).optional(),associatedRemoteUrls:E(d().min(1)).optional(),latestGitCommitHash:d().min(1).optional(),latestGitBranchName:d().min(1).optional()}),sx=b({currentWorkspacePath:d().min(1).optional(),workspaces:j(d().min(1),ix)});function ik(){return{workspaces:{}}}function sk(e,t){let n={...e,workspaces:{...e.workspaces,[t.rootPath]:t}};if(!n.currentWorkspacePath)n.currentWorkspacePath=t.rootPath;return sx.parse(n)}var ax="workspaces",cx="chat";function ux(e){let t=e.trim(),n=/^[A-Za-z]:[\\/]/.test(t)||t.startsWith("\\\\"),r=t.startsWith("/");if(!n&&!r)return!1;let o=t.split(n?/[\\/]+/:/\/+/).filter(Boolean),i=o.at(-1)??"",s=o.at(-2)??"",a=o.at(-3)??"";return(o.at(-4)??"")===".cline"&&a==="data"&&s==="workspaces"&&i==="chat"}var lx=["current_state","boundary_analysis","interface_proposal"],lk=3600000,dk=240,pk=400,le=Ku((e)=>e instanceof Date?e.toISOString():e,d().datetime()),st=I(["pending","in_progress","blocked","completed"]),dp=I(["queued","running","completed","failed","cancelled","interrupted"]),On=I(["draft","in_review","finalized"]),dx=b({agentId:d(),role:I(["lead","teammate"]),description:d().optional(),status:I(["idle","running","stopped"])}),mk=b({agentId:d(),rolePrompt:d(),modelId:d().optional(),maxIterations:x().optional()});function Z(e){return Ku((t)=>t===null?void 0:t,e.optional())}var fk=b({agentId:d().min(1).describe("Teammate identifier"),rolePrompt:d().min(1).describe("System prompt describing teammate role")}).strict(),gk=b({agentId:d().min(1).describe("Teammate identifier"),reason:Z(d().min(1)).describe("Optional shutdown reason")}),hk=b({}),px={create:["title","description"],list:[],claim:["taskId"],complete:["taskId","summary"],block:["taskId","reason"]},yk={create:["status","taskId","summary","reason"]},bk=b({action:I(["create","list","claim","complete","block"]),title:Z(d().min(1)).describe("Task title"),description:Z(d().min(1)).describe("Task details"),dependsOn:Z(E(d().describe("Dependency task ID"))).describe("Array of dependency task IDs"),assignee:Z(d().min(1)).describe("Optional assignee"),status:Z(I(["pending","in_progress","blocked","completed"])).describe("Optional task status filter"),taskId:Z(d()).describe("Task ID"),summary:Z(d().min(1)).describe("Completion summary"),reason:Z(d().min(1)).describe("Blocking reason")}).superRefine((e,t)=>{for(let n of px[e.action]){if(e[n]!==void 0)continue;t.addIssue({code:"custom",path:[n],message:`Field "${n}" is required when action=${e.action}`})}}),xk=b({agentId:d().describe("Teammate agent ID"),task:d().min(1).describe("Task instructions for the teammate"),taskId:Z(d()).describe("Optional shared task list ID"),runMode:Z(I(["sync","async"])).describe("Execution mode: 'sync' blocks until the teammate finishes and returns the result (default if omitted); 'async' queues the run and returns a runId immediately — use team_await_runs to collect results later."),continueConversation:Z(w()).describe("If true, continue the teammate conversation; otherwise start fresh")}),_k=b({status:Z(I(["queued","running","completed","failed","cancelled","interrupted"])).describe("Optional run status filter. Omit to include all statuses."),agentId:Z(d().min(1)).describe("Optional teammate ID filter. Omit to include all teammates."),includeCompleted:Z(w()).describe("Include completed/failed runs (default true)")}),Sk=b({runId:d().min(1).describe("Run ID"),reason:Z(d().min(1)).describe("Optional cancellation reason")}),vk=b({runId:Z(d().min(1)).describe("Optional async run ID to await. Omit to wait for all active async runs.")}).strict(),Ck=b({toAgentId:d().min(1).describe("Recipient agent ID"),subject:d().min(1).describe("Message subject"),body:d().min(1).describe("Message body"),taskId:Z(d().min(1)).describe("Optional task ID context")}),Tk=b({subject:d().min(1).describe("Message subject"),body:d().min(1).describe("Message body"),taskId:Z(d().min(1)).describe("Optional task ID context")}),kk=b({unreadOnly:Z(w()).describe("Only unread messages for read action (default true)")}),Ek=b({kind:I(["progress","handoff","blocked","decision","done","error"]),summary:d().min(1).describe("Update summary"),taskId:Z(d().min(1)).describe("Optional task ID context"),evidence:Z(E(d().min(1))).describe("Optional evidence links/snippets"),nextAction:Z(d().min(1)).describe("Planned next step")}),Rk=b({}),Ak=b({title:d().describe("Outcome title"),requiredSections:E(d()).default(lx).describe("Required sections for finalization gate (defaults to current_state,boundary_analysis,interface_proposal)")}),Ik=b({outcomeId:d().describe("Outcome ID"),section:d().describe("Section name"),sourceRunId:Z(d()).describe("Optional source run ID"),content:d().describe("Section fragment content")}),wk=b({fragmentId:d().describe("Fragment ID"),approved:w().describe("Review decision")}),Pk=b({outcomeId:d().describe("Outcome ID")}),Mk=b({}),Ok=b({teamId:d(),teamName:d(),members:E(dx),taskCounts:j(st,x()),unreadMessages:x(),missionLogEntries:x(),activeRuns:x(),queuedRuns:x(),outcomeCounts:j(On,x())}),mx=b({id:d(),title:d(),description:d(),status:st,createdAt:le,updatedAt:le,createdBy:d(),assignee:d().optional(),dependsOn:E(d()),summary:d().optional(),isReady:w(),blockedBy:E(d())}),Nk=ao("action",[b({action:V("create"),taskId:d(),status:st,ignoredFields:E(d()).optional(),note:d().optional()}),b({action:V("list"),tasks:E(mx)}),b({action:V("claim"),taskId:d(),status:st,nextStep:d()}),b({action:V("complete"),taskId:d(),status:st}),b({action:V("block"),taskId:d(),status:st})]),zk=b({agentId:d(),mode:I(["sync","async"]),status:I(["dispatched","running","queued","joined"]),dispatched:w(),message:d(),deduped:w().optional(),runId:d().optional(),text:d().optional(),iterations:x().optional()}),fx=b({textPreview:d(),iterations:x(),finishReason:d(),durationMs:x(),usage:b({inputTokens:x(),outputTokens:x(),cacheReadTokens:x().optional(),cacheWriteTokens:x().optional(),totalCost:x().optional()})}),$k=b({id:d(),agentId:d(),taskId:d().optional(),status:dp,messagePreview:d(),priority:x(),retryCount:x(),maxRetries:x(),nextAttemptAt:le.optional(),continueConversation:w().optional(),startedAt:le,endedAt:le.optional(),leaseOwner:d().optional(),heartbeatAt:le.optional(),lastProgressAt:le.optional(),lastProgressMessage:d().optional(),currentActivity:d().optional(),error:d().optional(),resultSummary:fx.optional()}),Lk=b({id:d(),teamId:d(),fromAgentId:d(),toAgentId:d(),subject:d(),body:d(),taskId:d().optional(),sentAt:le,readAt:le.optional()}),Dk=b({id:d(),teamId:d(),title:d(),status:On,requiredSections:E(d()),createdBy:d(),createdAt:le,finalizedAt:le.optional()}),Bk=b({outcomeId:d(),status:On,requiredSections:E(d())}),Uk=b({agentId:d(),status:d()}),Zk=b({runId:d(),status:dp}),Fk=b({id:d(),toAgentId:d()}),Hk=b({delivered:x()}),jk=b({id:d()}),Vk=b({status:d()}),qk=b({fragmentId:d(),status:d()}),Gk=b({outcomeId:d(),status:On});var gx;((R)=>{R.TaskStart="task_start";R.TaskEnd="task_end";R.AgentEvent="agent_event";R.TeammateSpawned="teammate_spawned";R.TeammateShutdown="teammate_shutdown";R.TeamTaskUpdated="team_task_updated";R.TeamMessage="team_message";R.TeamMissionLog="team_mission_log";R.TeamTaskCompleted="team_task_completed";R.RunStarted="run_started";R.RunQueued="run_queued";R.RunProgress="run_progress";R.RunCompleted="run_completed";R.RunFailed="run_failed";R.RunCancelled="run_cancelled";R.RunInterrupted="run_interrupted";R.OutcomeCreated="outcome_created";R.OutcomeFragmentAttached="outcome_fragment_attached";R.OutcomeFragmentReviewed="outcome_fragment_reviewed";R.OutcomeFinalized="outcome_finalized"})(gx||={});function hx(e){let{$schema:t,...n}=e;if(typeof n.type==="string")return n;if("properties"in n||"required"in n||"additionalProperties"in n)return{type:"object",...n};for(let r of["oneOf","anyOf","allOf"]){let o=n[r];if(!Array.isArray(o)||o.length===0)continue;if(r==="allOf"){if(o.some((a)=>a&&typeof a==="object"&&a.type==="object"))return{type:"object",...n};throw Error('Tool inputSchema must describe an object at the top level, but the schema has a top-level "allOf" with no branch that asserts type: "object". Add type: "object" to at least one allOf branch to make the object constraint explicit.')}if(o.every((s)=>s&&typeof s==="object"&&s.type==="object"))return{type:"object",...n};throw Error(`Tool inputSchema must describe an object at the top level, but the schema has a top-level "${r}" whose branches include non-object types. Pass the strict object schema as inputSchema and reserve union/coercion schemas for use inside execute().`)}return n}function yx(e){let t=hx(e.inputSchema instanceof z?Vo(e.inputSchema):e.inputSchema);return{name:e.name,resultPolicy:e.resultPolicy,description:e.description,inputSchema:t,lifecycle:e.lifecycle,executionMode:e.executionMode,timeoutMs:e.timeoutMs??30000,retryable:e.retryable??!0,maxRetries:e.maxRetries??3,execute:e.execute}}var pp=["401","403","unauthorized","forbidden","invalid token","expired token","authentication"];function bx(e){let t=(e instanceof Error?e.message:String(e)).toLowerCase();return pp.some((n)=>t.includes(n))}import{existsSync as xx,mkdirSync as _x,readFileSync as Sx,writeFileSync as vx}from"node:fs";import{dirname as Cx,resolve as Tx}from"node:path";var kx=new Set(["accesskeyid","secretaccesskey","idtoken","refreshtoken","accesstoken","access_token","refresh_token","apikey","api_key","authorization","password","secret","token","email","displayname","display_name","userinfo"]),Ex=["id","balance","cost","secret"];function Rx(e){let t=e.toLowerCase();if(kx.has(t))return!0;for(let n of Ex){if(t===n)return!0;if(t.endsWith(n)&&t.length>n.length){let r=t[t.length-n.length-1];if(r==="_"||r==="-")return!0;let o=e[e.length-n.length];if(o&&o===o.toUpperCase()&&o!==o.toLowerCase())return!0}if(t.endsWith(`_${n}`))return!0}return!1}var Ax=[{pattern:/AKIA[A-Z0-9]{16}/g,replacement:"AKIA_REDACTED"},{pattern:/\/Users\/[A-Za-z0-9._-]+/g,replacement:"/Users/REDACTED_USER"},{pattern:/\/home\/[A-Za-z0-9._-]+/g,replacement:"/home/REDACTED_USER"}];function fp(e){let t=e;for(let{pattern:n,replacement:r}of Ax)t=t.replace(n,r);return t}function yi(e){if(Array.isArray(e))return e.map(yi);if(!e||typeof e!=="object")return e;return Object.fromEntries(Object.entries(e).sort(([t],[n])=>Ix(t,n)).map(([t,n])=>[t,yi(n)]))}function Ix(e,t){if(e<t)return-1;if(e>t)return 1;return 0}function mp(e){return JSON.stringify(yi(e))}var wx=[{pattern:/tasks\/[A-Za-z0-9._-]+\/[A-Za-z0-9._-]+\/api_conversation_history/g,replacement:"tasks/usr-test/taskid/api_conversation_history"},{pattern:/\/(org|usr|mbr|ses|gen|req|msg|tsk|sch|exe|srv|cli|wkr|evt|sub|tkn)-[A-Za-z0-9]{10,}(?=[/?#]|$)/g,replacement:"/$1-REDACTED"}];function bi(e){let t=e;for(let{pattern:n,replacement:r}of wx)t=t.replace(n,r);return t}function at(e){if(e===null||e===void 0)return e;if(typeof e==="string"){try{let t=JSON.parse(e);if(typeof t==="object"&&t!==null)return JSON.stringify(at(t))}catch{}return fp(e)}if(Array.isArray(e))return e.map(at);if(typeof e==="object"){let t={};for(let[n,r]of Object.entries(e))if(Rx(n)&&(typeof r==="string"||typeof r==="number"))t[n]="REDACTED";else t[n]=at(r);return t}return e}function Px(e){let t=new URLSearchParams(e),n=Array.from(t.entries());if(n.length===0||n.some(([o])=>o.length===0))return;let r={};for(let[o,i]of n){let s=r[o];if(s===void 0)r[o]=i;else if(Array.isArray(s))s.push(i);else r[o]=[s,i]}return r}function Mx(e){return e?.toLowerCase().split(";")[0]?.trim()==="application/x-www-form-urlencoded"}function gp(e,t){try{return mp(at(JSON.parse(e)))}catch{if(Mx(t)){let n=Px(e);if(n)return mp(at(n))}return fp(e)}}function Ox(e,t){let n={...e},r=t&&e.body!==void 0?gp(e.body,e.requestContentType):void 0;if(delete n.body,delete n.requestContentType,r!==void 0)n.requestBody=r;if(typeof n.path==="string")n.path=bi(n.path);if(n.response!==void 0)n.response=at(n.response);return n}function hp(e){try{let t=new URL(e),n=`${t.protocol}//${t.host}`,r=t.pathname+t.search;return{scope:n,path:r}}catch{return{scope:"",path:e}}}function yp(e){if(typeof e==="string")return e;if(e instanceof URL)return e.toString();if(e&&typeof e.url==="string")return e.url;return String(e)}function bp(e,t){if(t?.method)return t.method.toUpperCase();if(e&&typeof e.method==="string")return e.method.toUpperCase();return"GET"}function Nx(e){if(!e)return;return new Headers(e).get("content-type")??void 0}function xp(e,t){let n=Nx(t?.headers);if(n)return n;if(t?.body instanceof URLSearchParams)return"application/x-www-form-urlencoded;charset=UTF-8";if(e instanceof Request)return e.headers.get("content-type")??void 0;return}async function _p(e,t){if(t?.body){if(typeof t.body==="string")return t.body;if(t.body instanceof URLSearchParams)return t.body.toString();if(t.body instanceof ArrayBuffer)return new TextDecoder().decode(t.body);if(ArrayBuffer.isView(t.body))return new TextDecoder().decode(new Uint8Array(t.body.buffer,t.body.byteOffset,t.body.byteLength));return}if(e instanceof Request)try{return await e.clone().text()}catch{return}return}function zx(e){if(!e)return null;if(!process.env.CLINE_VCR_CASSETTE)return process.stderr.write(`[VCR] No CLINE_VCR_CASSETTE: requests will not be recorded or played back.
179
179
  `),null;if(e!=="record"&&e!=="playback")process.stderr.write(`[VCR] Invalid CLINE_VCR value: "${e}". Expected "record" or "playback".
180
- `),process.exit(1);let t=gx(process.env.CLINE_VCR_CASSETTE),n=process.env.CLINE_VCR_FILTER??"",r=process.env.CLINE_VCR_INCLUDE_REQUEST_BODY==="1"||process.env.CLINE_VCR_INCLUDE_REQUEST_BODY==="true";return{mode:e,cassettePath:t,filter:n,includeRequestBody:r}}function Rx(e,t,n){let r=[],o=[],i=globalThis.fetch;function s(l){if(l.finalized)return;l.finalized=!0;let p=new TextDecoder,m=l.chunks.map((g)=>p.decode(g,{stream:!0})).join("")+p.decode(),f;try{f=JSON.parse(m)}catch{f=m}r.push({scope:l.scope,method:l.method,path:l.path,body:l.body,requestContentType:l.requestContentType,status:l.status,response:f,responseIsBinary:!1,contentType:l.contentType})}globalThis.fetch=Object.assign(async(l,p)=>{let m=fp(l),f=gp(l,p),{scope:g,path:y}=mp(m),S=await yp(l,p),v=hp(l,p),k=await i(l,p);if(t&&!y.includes(t))return k;let M=k.headers.get("content-type")??void 0;if(!k.body)return r.push({scope:g,method:f,path:y,body:S??"",requestContentType:v,status:k.status,response:"",responseIsBinary:!1,contentType:M}),k;let R={scope:g,method:f,path:y,body:S??"",requestContentType:v,status:k.status,contentType:M,chunks:[],finalized:!1};o.push(R);let B=k.body,A=new TransformStream({transform(Te,Me){R.chunks.push(Te),Me.enqueue(Te)},flush(){s(R)}}),J=B.pipeThrough(A);return new Response(J,{status:k.status,statusText:k.statusText,headers:k.headers})},{preconnect:(l)=>{}});let a=t?`matching path "*${t}*"`:"all paths";process.stderr.write(`[VCR] Recording HTTP requests (${a}). Cassette will be saved to: ${e}
180
+ `),process.exit(1);let t=Tx(process.env.CLINE_VCR_CASSETTE),n=process.env.CLINE_VCR_FILTER??"",r=process.env.CLINE_VCR_INCLUDE_REQUEST_BODY==="1"||process.env.CLINE_VCR_INCLUDE_REQUEST_BODY==="true";return{mode:e,cassettePath:t,filter:n,includeRequestBody:r}}function $x(e,t,n){let r=[],o=[],i=globalThis.fetch;function s(l){if(l.finalized)return;l.finalized=!0;let p=new TextDecoder,m=l.chunks.map((g)=>p.decode(g,{stream:!0})).join("")+p.decode(),f;try{f=JSON.parse(m)}catch{f=m}r.push({scope:l.scope,method:l.method,path:l.path,body:l.body,requestContentType:l.requestContentType,status:l.status,response:f,responseIsBinary:!1,contentType:l.contentType})}globalThis.fetch=Object.assign(async(l,p)=>{let m=yp(l),f=bp(l,p),{scope:g,path:y}=hp(m),_=await _p(l,p),v=xp(l,p),k=await i(l,p);if(t&&!y.includes(t))return k;let M=k.headers.get("content-type")??void 0;if(!k.body)return r.push({scope:g,method:f,path:y,body:_??"",requestContentType:v,status:k.status,response:"",responseIsBinary:!1,contentType:M}),k;let R={scope:g,method:f,path:y,body:_??"",requestContentType:v,status:k.status,contentType:M,chunks:[],finalized:!1};o.push(R);let B=k.body,A=new TransformStream({transform(Ce,Me){R.chunks.push(Ce),Me.enqueue(Ce)},flush(){s(R)}}),J=B.pipeThrough(A);return new Response(J,{status:k.status,statusText:k.statusText,headers:k.headers})},{preconnect:(l)=>{}});let a=t?`matching path "*${t}*"`:"all paths";process.stderr.write(`[VCR] Recording HTTP requests (${a}). Cassette will be saved to: ${e}
181
181
  `);let c=!1;ho(()=>{if(c)return;c=!0,globalThis.fetch=i;for(let m of o)s(m);if(r.length===0){process.stderr.write(`[VCR] No HTTP requests${t?` matching "${t}"`:""} were recorded.
182
- `);return}let l=fx(e);dx(l,{recursive:!0});let p=r.map((m)=>Cx(m,n));mx(e,JSON.stringify(p,null,2)),process.stderr.write(`[VCR] Saved ${p.length} recorded HTTP interaction(s) to ${e}
183
- `)})}function Ax(e){let t=[],n=e.split(/\n\n/);for(let r of n){let o=r.trim();if(o)t.push(`${o}
182
+ `);return}let l=Cx(e);_x(l,{recursive:!0});let p=r.map((m)=>Ox(m,n));vx(e,JSON.stringify(p,null,2)),process.stderr.write(`[VCR] Saved ${p.length} recorded HTTP interaction(s) to ${e}
183
+ `)})}function Lx(e){let t=[],n=e.split(/\n\n/);for(let r of n){let o=r.trim();if(o)t.push(`${o}
184
184
 
185
- `)}return t}function Ix(e,t){let n=new TextEncoder,r=0;return new ReadableStream({async pull(o){if(r>=e.length){o.close();return}if(r>0&&t>0)await new Promise((s)=>setTimeout(s,t));let i=e[r];if(i===void 0){o.close();return}o.enqueue(n.encode(i)),r+=1}})}async function wx(e){if(e.recording.requestBody===void 0)return;let t=await yp(e.requestInput,e.requestInit),n=hp(e.requestInput,e.requestInit),r=pp(t??"",n);if(r!==e.recording.requestBody)throw Error(`[VCR] Request body mismatch for ${e.method} ${e.path}.
185
+ `)}return t}function Dx(e,t){let n=new TextEncoder,r=0;return new ReadableStream({async pull(o){if(r>=e.length){o.close();return}if(r>0&&t>0)await new Promise((s)=>setTimeout(s,t));let i=e[r];if(i===void 0){o.close();return}o.enqueue(n.encode(i)),r+=1}})}async function Bx(e){if(e.recording.requestBody===void 0)return;let t=await _p(e.requestInput,e.requestInit),n=xp(e.requestInput,e.requestInit),r=gp(t??"",n);if(r!==e.recording.requestBody)throw Error(`[VCR] Request body mismatch for ${e.method} ${e.path}.
186
186
  expected: ${e.recording.requestBody}
187
187
  actual: ${r}
188
- Re-record the cassette if the request change is intentional.`)}function Px(e,t){if(!lx(e))process.stderr.write(`[VCR] Cassette file not found: ${e}
189
- `),process.exit(1);let n=JSON.parse(px(e,"utf-8")),r=Number.parseInt(process.env.CLINE_VCR_SSE_DELAY??"100",10),o=Array(n.length).fill(!1),i=globalThis.fetch;globalThis.fetch=Object.assign(async(a,c)=>{let u=fp(a),l=gp(a,c),{path:p}=mp(u),m=bi(p);if(t&&!p.includes(t))return i(a,c);let f=n.findIndex((g,y)=>{if(o[y])return!1;let S=bi(g.path);return g.method.toUpperCase()===l&&S===m});if(f>=0){let g=n[f];if(!g)return i(a,c);await wx({recording:g,requestInput:a,requestInit:c,method:l,path:m}),o[f]=!0;let y=typeof g.response==="string"?g.response:JSON.stringify(g.response),S=new Headers;if(g.contentType)S.set("content-type",g.contentType);else if(typeof g.response==="string"&&g.response.trimStart().startsWith("data:"))S.set("content-type","text/event-stream");else if(typeof g.response==="object")S.set("content-type","application/json");let v=S.get("content-type")?.includes("text/event-stream")??!1;if(v)S.set("cache-control","no-cache"),S.set("connection","keep-alive");if(v&&typeof g.response==="string"){let k=Ax(g.response);if(k.length>1){let M=Ix(k,r);return new Response(M,{status:g.status,headers:S})}}return new Response(y,{status:g.status,headers:S})}if(!t)throw Error(`[VCR] No matching recording for ${l} ${u} (path: ${m}). ${n.length} recording(s) loaded from ${e}.`);return i(a,c)},{preconnect:(a)=>{}});let s=t?`(only paths matching "*${t}*", all other requests go through normally)`:"(all requests intercepted)";process.stderr.write(`[VCR] Playing back ${n.length} recorded HTTP interaction(s) from ${e} ${s}
190
- `)}function Mx(e){let t=Ex(e);if(!t)return;if(t.mode==="record")Rx(t.cassettePath,t.filter,t.includeRequestBody);else Px(t.cassettePath,t.filter)}export{gb as AGENT_UNEXPECTED_REASONING_TOKENS_EVENT,vy as APIKeySchema,up as AUTH_ERROR_PATTERNS,pv as AgentConfigSchema,Ff as AgentFinishReasonSchema,dv as AgentResultSchema,Hf as AgentUsageSchema,Zd as AllowedMCPServerSchema,Bd as AnthropicModelSchema,Ud as AnthropicSchema,Of as ApiFormat,Wu as ApiFormatSchema,Pd as AwsBedrockCustomModelSchema,wd as AwsBedrockModelSchema,Md as AwsBedrockSettingsSchema,Qg as CHARS_PER_TOKEN,Mn as CLINE_BUILD_ENV_ENV,Qb as CLINE_CHAT_WORKSPACE_DIRECTORY_NAME,Xy as CLINE_CONNECTOR_CLI_LAUNCH_ENV,Qy as CLINE_CONNECTOR_STARTING_INSTANCE_ENV,eb as CLINE_CONNECTOR_SUPERVISED_ENV,Vd as CLINE_DEBUG_HOST_ENV,qd as CLINE_DEBUG_PORT_BASE_ENV,Vh as CLINE_DEFAULT_MODEL_ID,Ey as CLINE_DEFAULT_RPC_ADDRESS,ky as CLINE_DEFAULT_RPC_PORT,ci as CLINE_ENVIRONMENTS,Vy as CLINE_ENVIRONMENT_ENV,qy as CLINE_ENVIRONMENT_OVERRIDE_ENV,Cy as CLINE_HUB_DEV_PORT,Ty as CLINE_HUB_PORT,Yy as CLINE_RUN_AS_HUB_DAEMON_ENV,Xb as CLINE_WORKSPACES_DIRECTORY_NAME,rT as CONFIGURABLE_MODEL_TOOL_NAMES,cl as CONNECTOR_CATALOG,dl as CONNECTOR_PLATFORMS,vb as CORE_SPAWN_REASONS,Ev as CURRENT_HUB_PROTOCOL_VERSION,Od as ClineModelSchema,zd as ClineSettingsSchema,Vf as ConnectorAuthorizationDecisionSchema,jf as ConnectorAuthorizationRequestSchema,sl as ConnectorEventActorSchema,al as ConnectorEventContextSchema,il as ConnectorHookEventNameSchema,qf as ConnectorHookEventSchema,yo as ContributionRegistry,Gy as DEFAULT_CLINE_ENVIRONMENT,So as DEFAULT_MAX_IMAGE_BASE64_BYTES,Se as DEFAULT_MAX_IMAGE_DECODED_BYTES,fe as DEFAULT_MAX_IMAGE_ENCODED_BYTES,Pl as DEFAULT_MAX_TOTAL_MEDIA_BYTES,uT as DEFAULT_MCP_TIMEOUT_SECONDS,tx as DEFAULT_OUTCOME_REQUIRED_SECTIONS,Wg as DEFAULT_REASONING_EFFORT,sp as DEFAULT_RUNTIME_CONFIG_EXTENSIONS,Mt as EMPTY_CONTENT_TEXT,Hl as ESTIMATED_TOKENS_PER_IMAGE,jd as EnterpriseTelemetrySchema,cg as FEATURE_FLAGS,Ke as FeatureFlag,ag as FeatureFlagDefaultValue,Rl as GeneratedMediaModalitySchema,wl as GeneratedMediaSchema,Al as GeneratedMediaSourceSchema,si as GlobalInstructionsFileSchema,Iv as HUB_CAPABILITIES,Fv as HUB_CHECKPOINT_CAPABILITY,Pv as HUB_CLIENT_TOOL_APPROVAL_CAPABILITY,Nv as HUB_COMMAND_SLOW_LOG_MS,Zv as HUB_COMPACTION_CAPABILITY,Bv as HUB_CUSTOM_TOOL_CAPABILITY_PREFIX,xg as HUB_DEFAULT_COMMAND_TIMEOUT_MS,Uv as HUB_HOOK_CAPABILITY_PREFIX,Hv as HUB_MISTAKE_LIMIT_CAPABILITY,xl as HUB_SCHEDULE_MODES,Dv as HUB_TOOL_EXECUTOR_CAPABILITY_PREFIX,_g as HUB_TOOL_EXECUTOR_NAMES,jv as HUB_USER_INSTRUCTIONS_SNAPSHOT_CAPABILITY,yl as HookEventNameSchema,bl as HookEventPayloadSchema,We as IMAGE_OMITTED_PLACEHOLDER,Je as IMAGE_UNSUPPORTED_PLACEHOLDER,Qd as LOOPBACK_NO_PROXY_HOSTS,Ld as LiteLLMModelSchema,Dd as LiteLLMSchema,Av as MAX_CLIENT_HUB_PROTOCOL_VERSION,dT as MAX_MCP_TIMEOUT_SECONDS,Rv as MIN_CLIENT_HUB_PROTOCOL_VERSION,lT as MIN_MCP_TIMEOUT_SECONDS,nT as MODEL_TOOL_NAMES,ad as MODE_TAG_INSTRUCTIONS,Ju as ModelCapabilitySchema,xn as ModelInfoSchema,el as ModelMetadataSchema,tl as ModelModalitiesSchema,mo as ModelModalitySchema,ol as ModelOperationModeSchema,rl as ModelOperationSchema,Xu as ModelPricingSchema,po as ModelReasoningOptionSchema,Yu as ModelStatusSchema,mb as NO_DEFAULT_CURRENT_DIRECTORY_IN_EXE_PATH_ENV,Mv as ONE_TIME_SCHEDULE_CRON_PATTERN,Ov as ONE_TIME_SCHEDULE_RUN_AT_METADATA_KEY,gi as OTLP_TRACE_RELAY_MARKER,Ad as OpenAiCompatibleModelSchema,Id as OpenAiCompatibleSchema,ud as PLAN_MODE_INSTRUCTIONS,ld as PLAN_MODE_INSTRUCTIONS_MANUAL_SWITCH,sg as PLUGIN_FILE_EXTENSIONS,Hd as PromptUploadingSchema,Ry as ProviderCapabilitySchema,Iy as ProviderClientSchema,Ay as ProviderProtocolSchema,zt as REASONING_EFFORT_RATIOS,yn as REASONING_LEVELS,hd as REMOTE_CONFIG_SESSION_BLOB_UPLOAD_METADATA_KEY,uy as REMOTE_URI_SCHEME,hi as RUNTIME_CONFIG_EXTENSION_KINDS,bn as ReasoningEffortSchema,lo as ReasoningLevelSchema,_y as RemoteConfigSchema,Fd as RemoteMCPServerSchema,Pn as S3AccessKeySettingsSchema,Tb as SDK_ERROR_TELEMETRY_EVENT,Cl as SESSION_SEARCH_PREVIEW_MAX_LENGTH,Tl as SESSION_SEARCH_TITLE_MAX_LENGTH,qb as SESSION_STATUS_VALUES,vn as SUPPORTED_IMAGE_MEDIA_TYPES,Sb as TASK_CANCELLED_EVENT,bb as TASK_FIRST_CHUNK_RECEIVED_EVENT,_b as TASK_MAX_TOKENS_RECOVERY_EVENT,hb as TASK_PROVIDER_REQUEST_STARTED_EVENT,xb as TASK_PROVIDER_STREAM_FAILED_EVENT,yb as TASK_PROVIDER_STREAM_STARTED_EVENT,ek as TEAM_AWAIT_TIMEOUT_MS,Py as TEAM_LIFECYCLE_EVENT_TYPE,wy as TEAM_PROGRESS_EVENT_TYPE,tk as TEAM_RUN_MESSAGE_PREVIEW_LIMIT,nk as TEAM_RUN_TEXT_PREVIEW_LIMIT,ak as TEAM_TASK_IGNORED_FIELDS_BY_ACTION,Zf as TOOL_REJECTION_SUFFIX,xk as TeamAttachOutcomeFragmentInputSchema,pk as TeamAwaitRunsInputSchema,fk as TeamBroadcastInputSchema,Ok as TeamBroadcastToolResultSchema,dk as TeamCancelRunInputSchema,Pk as TeamCancelRunToolResultSchema,yk as TeamCleanupInputSchema,Nk as TeamCleanupToolResultSchema,bk as TeamCreateOutcomeInputSchema,Ik as TeamCreateOutcomeToolResultSchema,_k as TeamFinalizeOutcomeInputSchema,Lk as TeamFinalizeOutcomeToolResultSchema,vk as TeamListOutcomesInputSchema,lk as TeamListRunsInputSchema,Rk as TeamMailboxMessageToolResultSchema,sx as TeamMessageType,hk as TeamMissionLogInputSchema,zk as TeamMissionLogToolResultSchema,$k as TeamOutcomeFragmentToolResultSchema,Ak as TeamOutcomeToolResultSchema,gk as TeamReadMailboxInputSchema,Sk as TeamReviewOutcomeFragmentInputSchema,ix as TeamRunResultSummarySchema,uk as TeamRunTaskInputSchema,kk as TeamRunTaskToolResultSchema,Ek as TeamRunToolSummarySchema,mk as TeamSendMessageInputSchema,Mk as TeamSendMessageToolResultSchema,ik as TeamShutdownTeammateInputSchema,wk as TeamSimpleAgentStatusToolResultSchema,ok as TeamSpawnTeammateInputSchema,sk as TeamStatusInputSchema,Tk as TeamStatusToolResultSchema,ck as TeamTaskInputSchema,ox as TeamTaskListItemToolResultSchema,Ck as TeamTaskToolResultSchema,rk as TeamTeammateSpecSchema,Qu as ThinkingConfigSchema,go as ToolCallRecordSchema,Qv as USAGE_COST_DISPLAYS,Uf as USER_REJECTED_TOOL_REASON,Nd as VertexModelSchema,$d as VertexSettingsSchema,Jb as WorkspaceInfoSchema,Yb as WorkspaceManifestSchema,Zy as augmentNodeCommandForDebug,Fh as buildClineSystemPrompt,Gf as buildConnectorConnectArgs,Qh as buildRemoteConfigSessionBlobUploadMetadata,ep as buildSdkErrorProperties,Rb as captureAgentUnexpectedReasoningTokens,Ib as captureSdkError,Ab as captureTaskLifecycleEvent,tb as claimHubDaemonProcess,ob as claimSupervisedConnectorProcess,rh as clampMcpTimeoutSeconds,hy as clearMaterializedRemoteConfigRuntime,ty as clearRemoteConfigSessionBlobUpload,Jf as connectorChannelsFromPlatforms,Db as createClineTelemetryServiceConfig,np as createClineTelemetryServiceMetadata,ig as createContributionRegistry,jl as createImageAwareReplacer,Tn as createMediaBudgetState,Ag as createModeSwitchNoticeTracker,cy as createRemoteConfigSessionMessagesArtifactUploader,Vb as createSessionId,cx as createTool,xh as decodeJwtPayload,Vv as describeOutdatedHubSessions,fb as disableCurrentDirectoryExecutableSearch,eg as disposeAll,WC as emptyWorkspaceManifest,pb as ensureLoopbackProxyBypass,eh as estimateRequestInputTokens,Fl as estimateTokens,xo as formatDisplayUserInput,bo as formatFileContentBlock,Lh as formatHumanReadableDate,mT as formatMcpTimeoutErrorMessage,Gg as formatMessagesForAiSdk,Rg as formatModeSwitchNotice,Og as formatSessionSearchPreview,Mg as formatSessionSearchTitle,Dh as formatUptime,Cg as formatUserCommandBlock,Tg as formatUserInputBlock,Ng as generatedMediaModalityFromMediaType,jy as getClineClientIdentity,Jy as getClineEnvironmentConfig,Sg as getDefaultHubCommandTimeoutMs,Th as getDefaultShell,ih as getErrorCode,oh as getErrorMessage,rt as getPowerShellEdition,Ph as getShellArgs,nd as getShellInvocation,jo as getShellKind,Wb as hasRuntimeConfigExtension,_o as imageBase64DecodedByteLength,$g as imageBase64EncodedByteLength,vo as imageBase64LengthForDecodedBytes,Lg as imageFileMaxDecodedBytesForBase64Limit,Mx as initVcr,Ml as isBase64Char,Fy as isBunEmbeddedModulePath,Dg as isCanonicalBase64,Nf as isChatCompatibleModel,ex as isChatWorkspacePath,qo as isClineProvider,zg as isGeneratedMedia,nb as isHubDaemonProcess,wv as isHubProtocolCompatible,bg as isHubScheduleMode,Lv as isHubToolExecutorName,ux as isLikelyAuthError,nh as isMcpTimeoutConfigured,$b as isOtlpTraceRelayProvider,ap as isRuntimeConfigExtensionKind,ib as isSupervisedConnectorProcess,zf as isTranscriptionModel,ul as listConnectorCatalog,Nb as markOtlpTraceRelayProvider,Nh as maskSecret,Wf as mergeConnectorConnectArgs,Kg as mergeModelOptions,fo as modelHasCapability,$f as modelProducesImages,Bf as modelSupportsImageInput,Df as modelSupportsToolCalling,th as noopBasicLogger,Ho as normalizeJsonLikeStringsForSchema,hl as normalizePluginManifest,fi as normalizeSdkError,_l as normalizeUserInput,Sh as omitUndefinedValues,yg as parseHookEventPayload,mh as parseJsonStream,Kb as parseRuntimeConfigExtensions,Sl as parseUserCommandEnvelope,Eg as parseUserInputMode,xy as prepareRemoteConfigRuntime,Zh as processWorkspaceInfo,cb as readConnectorCliLaunchSpec,zv as readHubScheduleMode,Sd as readRemoteConfigSessionBlobUploadMetadata,ab as readStartingConnectorInstance,ho as registerDisposable,ey as registerRemoteConfigSessionBlobUpload,wt as reserveImageMediaBytes,Cb as resetSdkErrorRateLimiterForTests,ai as resolveClineBuildEnv,Yd as resolveClineEnvironment,Jg as resolveEffectiveReasoningEffort,Bb as resolveHookSessionContext,$v as resolveHubCommandTimeoutMs,pT as resolveMcpTimeoutSeconds,To as resolveMediaBudget,Hh as resolveProviderApiKeyOptional,jh as resolveProviderLocalCli,Yg as resolveReasoningBudgetFromRatio,Zl as resolveReasoningEffortRatio,Ub as resolveRootSessionId,gh as safeJsonParse,fh as safeJsonStringify,Mh as sanitizeFileName,ae as sanitizeSurrogates,Xg as serializeAbortReason,Hy as setClineClientIdentity,rb as setConnectorCliLaunchSpec,sb as setStartingConnectorInstance,ll as shouldIncludeConnectorField,vl as stripModeNotices,$h as stripUtf8Bom,nl as supportsChatModalities,Bl as toAiSdkToolResultOutput,vh as toPosixSeparators,Oh as trimNonEmpty,zh as truncateSplit,rd as truncateStr,JC as upsertWorkspaceInfo,Lf as usesImageGenerationOperation,Bg as validateAndReserveBase64Media,Pt as validateAndReserveImageMedia,zl as validateImageMedia,Bh as validateWithZod,Uy as withResolvedClineBuildEnv,El as xmlTagsRemoval,Vo as zodToJsonSchema};
188
+ Re-record the cassette if the request change is intentional.`)}function Ux(e,t){if(!xx(e))process.stderr.write(`[VCR] Cassette file not found: ${e}
189
+ `),process.exit(1);let n=JSON.parse(Sx(e,"utf-8")),r=Number.parseInt(process.env.CLINE_VCR_SSE_DELAY??"100",10),o=Array(n.length).fill(!1),i=globalThis.fetch;globalThis.fetch=Object.assign(async(a,c)=>{let u=yp(a),l=bp(a,c),{path:p}=hp(u),m=bi(p);if(t&&!p.includes(t))return i(a,c);let f=n.findIndex((g,y)=>{if(o[y])return!1;let _=bi(g.path);return g.method.toUpperCase()===l&&_===m});if(f>=0){let g=n[f];if(!g)return i(a,c);await Bx({recording:g,requestInput:a,requestInit:c,method:l,path:m}),o[f]=!0;let y=typeof g.response==="string"?g.response:JSON.stringify(g.response),_=new Headers;if(g.contentType)_.set("content-type",g.contentType);else if(typeof g.response==="string"&&g.response.trimStart().startsWith("data:"))_.set("content-type","text/event-stream");else if(typeof g.response==="object")_.set("content-type","application/json");let v=_.get("content-type")?.includes("text/event-stream")??!1;if(v)_.set("cache-control","no-cache"),_.set("connection","keep-alive");if(v&&typeof g.response==="string"){let k=Lx(g.response);if(k.length>1){let M=Dx(k,r);return new Response(M,{status:g.status,headers:_})}}return new Response(y,{status:g.status,headers:_})}if(!t)throw Error(`[VCR] No matching recording for ${l} ${u} (path: ${m}). ${n.length} recording(s) loaded from ${e}.`);return i(a,c)},{preconnect:(a)=>{}});let s=t?`(only paths matching "*${t}*", all other requests go through normally)`:"(all requests intercepted)";process.stderr.write(`[VCR] Playing back ${n.length} recorded HTTP interaction(s) from ${e} ${s}
190
+ `)}function Zx(e){let t=zx(e);if(!t)return;if(t.mode==="record")$x(t.cassettePath,t.filter,t.includeRequestBody);else Ux(t.cassettePath,t.filter)}export{Cb as AGENT_UNEXPECTED_REASONING_TOKENS_EVENT,ky as APIKeySchema,pp as AUTH_ERROR_PATTERNS,Sv as AgentConfigSchema,Vf as AgentFinishReasonSchema,_v as AgentResultSchema,qf as AgentUsageSchema,Zd as AllowedMCPServerSchema,Bd as AnthropicModelSchema,Ud as AnthropicSchema,$f as ApiFormat,Wu as ApiFormatSchema,Pd as AwsBedrockCustomModelSchema,wd as AwsBedrockModelSchema,Md as AwsBedrockSettingsSchema,nh as CHARS_PER_TOKEN,Mn as CLINE_BUILD_ENV_ENV,cx as CLINE_CHAT_WORKSPACE_DIRECTORY_NAME,tb as CLINE_CONNECTOR_CLI_LAUNCH_ENV,nb as CLINE_CONNECTOR_STARTING_INSTANCE_ENV,rb as CLINE_CONNECTOR_SUPERVISED_ENV,Vd as CLINE_DEBUG_HOST_ENV,qd as CLINE_DEBUG_PORT_BASE_ENV,Kh as CLINE_DEFAULT_MODEL_ID,Iy as CLINE_DEFAULT_RPC_ADDRESS,Ay as CLINE_DEFAULT_RPC_PORT,ci as CLINE_ENVIRONMENTS,Ky as CLINE_ENVIRONMENT_ENV,Wy as CLINE_ENVIRONMENT_OVERRIDE_ENV,Ry as CLINE_HUB_DEV_PORT,ob as CLINE_HUB_LAUNCHER_CLIENT_ENV,sb as CLINE_HUB_LAUNCHER_TRANSPORT_ENV,ib as CLINE_HUB_LAUNCHER_VERSION_ENV,Ey as CLINE_HUB_PORT,eb as CLINE_RUN_AS_HUB_DAEMON_ENV,ax as CLINE_WORKSPACES_DIRECTORY_NAME,pC as CONFIGURABLE_MODEL_TOOL_NAMES,cl as CONNECTOR_CATALOG,dl as CONNECTOR_PLATFORMS,wb as CORE_SPAWN_REASONS,zv as CURRENT_HUB_PROTOCOL_VERSION,Od as ClineModelSchema,Nd as ClineSettingsSchema,Kf as ConnectorAuthorizationDecisionSchema,Gf as ConnectorAuthorizationRequestSchema,sl as ConnectorEventActorSchema,al as ConnectorEventContextSchema,il as ConnectorHookEventNameSchema,Wf as ConnectorHookEventSchema,yo as ContributionRegistry,Jy as DEFAULT_CLINE_ENVIRONMENT,_o as DEFAULT_MAX_IMAGE_BASE64_BYTES,_e as DEFAULT_MAX_IMAGE_DECODED_BYTES,fe as DEFAULT_MAX_IMAGE_ENCODED_BYTES,Pl as DEFAULT_MAX_TOTAL_MEDIA_BYTES,bC as DEFAULT_MCP_TIMEOUT_SECONDS,lx as DEFAULT_OUTCOME_REQUIRED_SECTIONS,Xg as DEFAULT_REASONING_EFFORT,up as DEFAULT_RUNTIME_CONFIG_EXTENSIONS,Mt as EMPTY_CONTENT_TEXT,Hl as ESTIMATED_TOKENS_PER_IMAGE,jd as EnterpriseTelemetrySchema,dg as FEATURE_FLAGS,Ke as FeatureFlag,lg as FeatureFlagDefaultValue,Rl as GeneratedMediaModalitySchema,wl as GeneratedMediaSchema,Al as GeneratedMediaSourceSchema,si as GlobalInstructionsFileSchema,Dv as HUB_CAPABILITIES,Yv as HUB_CHECKPOINT_CAPABILITY,Uv as HUB_CLIENT_TOOL_APPROVAL_CAPABILITY,jv as HUB_COMMAND_SLOW_LOG_MS,Jv as HUB_COMPACTION_CAPABILITY,Kv as HUB_CUSTOM_TOOL_CAPABILITY_PREFIX,vg as HUB_DEFAULT_COMMAND_TIMEOUT_MS,Wv as HUB_HOOK_CAPABILITY_PREFIX,Xv as HUB_MISTAKE_LIMIT_CAPABILITY,xl as HUB_SCHEDULE_MODES,Gv as HUB_TOOL_EXECUTOR_CAPABILITY_PREFIX,Tg as HUB_TOOL_EXECUTOR_NAMES,Qv as HUB_USER_INSTRUCTIONS_SNAPSHOT_CAPABILITY,yl as HookEventNameSchema,bl as HookEventPayloadSchema,We as IMAGE_OMITTED_PLACEHOLDER,Je as IMAGE_UNSUPPORTED_PLACEHOLDER,ep as LOOPBACK_NO_PROXY_HOSTS,Ld as LiteLLMModelSchema,Dd as LiteLLMSchema,Lv as MAX_CLIENT_HUB_PROTOCOL_VERSION,_C as MAX_MCP_TIMEOUT_SECONDS,$v as MIN_CLIENT_HUB_PROTOCOL_VERSION,xC as MIN_MCP_TIMEOUT_SECONDS,dC as MODEL_TOOL_NAMES,ad as MODE_TAG_INSTRUCTIONS,Ju as ModelCapabilitySchema,xn as ModelInfoSchema,el as ModelMetadataSchema,tl as ModelModalitiesSchema,mo as ModelModalitySchema,ol as ModelOperationModeSchema,rl as ModelOperationSchema,Xu as ModelPricingSchema,po as ModelReasoningOptionSchema,Yu as ModelStatusSchema,Sb as NO_DEFAULT_CURRENT_DIRECTORY_IN_EXE_PATH_ENV,Zv as ONE_TIME_SCHEDULE_CRON_PATTERN,Fv as ONE_TIME_SCHEDULE_RUN_AT_METADATA_KEY,gi as OTLP_TRACE_RELAY_MARKER,Ad as OpenAiCompatibleModelSchema,Id as OpenAiCompatibleSchema,ud as PLAN_MODE_INSTRUCTIONS,ld as PLAN_MODE_INSTRUCTIONS_MANUAL_SWITCH,ug as PLUGIN_FILE_EXTENSIONS,Hd as PromptUploadingSchema,wy as ProviderCapabilitySchema,My as ProviderClientSchema,Py as ProviderProtocolSchema,Nt as REASONING_EFFORT_RATIOS,yn as REASONING_LEVELS,hd as REMOTE_CONFIG_SESSION_BLOB_UPLOAD_METADATA_KEY,py as REMOTE_URI_SCHEME,hi as RUNTIME_CONFIG_EXTENSION_KINDS,bn as ReasoningEffortSchema,lo as ReasoningLevelSchema,Ty as RemoteConfigSchema,Fd as RemoteMCPServerSchema,Pn as S3AccessKeySettingsSchema,Pb as SDK_ERROR_TELEMETRY_EVENT,Tl as SESSION_SEARCH_PREVIEW_MAX_LENGTH,Cl as SESSION_SEARCH_TITLE_MAX_LENGTH,tx as SESSION_STATUS_VALUES,vn as SUPPORTED_IMAGE_MEDIA_TYPES,Ab as TASK_CANCELLED_EVENT,Eb as TASK_FIRST_CHUNK_RECEIVED_EVENT,Ib as TASK_MAX_TOKENS_RECOVERY_EVENT,Tb as TASK_PROVIDER_REQUEST_STARTED_EVENT,Rb as TASK_PROVIDER_STREAM_FAILED_EVENT,kb as TASK_PROVIDER_STREAM_STARTED_EVENT,lk as TEAM_AWAIT_TIMEOUT_MS,Ny as TEAM_LIFECYCLE_EVENT_TYPE,Oy as TEAM_PROGRESS_EVENT_TYPE,dk as TEAM_RUN_MESSAGE_PREVIEW_LIMIT,pk as TEAM_RUN_TEXT_PREVIEW_LIMIT,yk as TEAM_TASK_IGNORED_FIELDS_BY_ACTION,jf as TOOL_REJECTION_SUFFIX,Ik as TeamAttachOutcomeFragmentInputSchema,vk as TeamAwaitRunsInputSchema,Tk as TeamBroadcastInputSchema,Hk as TeamBroadcastToolResultSchema,Sk as TeamCancelRunInputSchema,Zk as TeamCancelRunToolResultSchema,Rk as TeamCleanupInputSchema,Vk as TeamCleanupToolResultSchema,Ak as TeamCreateOutcomeInputSchema,Bk as TeamCreateOutcomeToolResultSchema,Pk as TeamFinalizeOutcomeInputSchema,Gk as TeamFinalizeOutcomeToolResultSchema,Mk as TeamListOutcomesInputSchema,_k as TeamListRunsInputSchema,Lk as TeamMailboxMessageToolResultSchema,gx as TeamMessageType,Ek as TeamMissionLogInputSchema,jk as TeamMissionLogToolResultSchema,qk as TeamOutcomeFragmentToolResultSchema,Dk as TeamOutcomeToolResultSchema,kk as TeamReadMailboxInputSchema,wk as TeamReviewOutcomeFragmentInputSchema,fx as TeamRunResultSummarySchema,xk as TeamRunTaskInputSchema,zk as TeamRunTaskToolResultSchema,$k as TeamRunToolSummarySchema,Ck as TeamSendMessageInputSchema,Fk as TeamSendMessageToolResultSchema,gk as TeamShutdownTeammateInputSchema,Uk as TeamSimpleAgentStatusToolResultSchema,fk as TeamSpawnTeammateInputSchema,hk as TeamStatusInputSchema,Ok as TeamStatusToolResultSchema,bk as TeamTaskInputSchema,mx as TeamTaskListItemToolResultSchema,Nk as TeamTaskToolResultSchema,mk as TeamTeammateSpecSchema,Qu as ThinkingConfigSchema,go as ToolCallRecordSchema,cC as USAGE_COST_DISPLAYS,Hf as USER_REJECTED_TOOL_REASON,zd as VertexModelSchema,$d as VertexSettingsSchema,ix as WorkspaceInfoSchema,sx as WorkspaceManifestSchema,jy as augmentNodeCommandForDebug,Vh as buildClineSystemPrompt,Jf as buildConnectorConnectArgs,ny as buildRemoteConfigSessionBlobUploadMetadata,rp as buildSdkErrorProperties,Gb as buildTelemetrySelfcheckReport,zb as captureAgentUnexpectedReasoningTokens,Lb as captureSdkError,$b as captureTaskLifecycleEvent,ub as claimHubDaemonProcess,cb as claimHubLauncherIdentity,pb as claimSupervisedConnectorProcess,sh as clampMcpTimeoutSeconds,xy as clearMaterializedRemoteConfigRuntime,oy as clearRemoteConfigSessionBlobUpload,Qf as connectorChannelsFromPlatforms,jb as createClineTelemetryServiceConfig,ip as createClineTelemetryServiceMetadata,cg as createContributionRegistry,jl as createImageAwareReplacer,Cn as createMediaBudgetState,Pg as createModeSwitchNoticeTracker,dy as createRemoteConfigSessionMessagesArtifactUploader,ex as createSessionId,yx as createTool,vh as decodeJwtPayload,eC as describeOutdatedHubSessions,vb as disableCurrentDirectoryExecutableSearch,rg as disposeAll,ik as emptyWorkspaceManifest,_b as ensureLoopbackProxyBypass,rh as estimateRequestInputTokens,Fl as estimateTokens,xo as formatDisplayUserInput,bo as formatFileContentBlock,Uh as formatHumanReadableDate,vC as formatMcpTimeoutErrorMessage,Jg as formatMessagesForAiSdk,wg as formatModeSwitchNotice,$g as formatSessionSearchPreview,zg as formatSessionSearchTitle,Zh as formatUptime,Rg as formatUserCommandBlock,Eg as formatUserInputBlock,Dg as generatedMediaModalityFromMediaType,Gy as getClineClientIdentity,Qy as getClineEnvironmentConfig,Cg as getDefaultHubCommandTimeoutMs,Eh as getDefaultShell,ch as getErrorCode,ah as getErrorMessage,rt as getPowerShellEdition,Nh as getShellArgs,nd as getShellInvocation,jo as getShellKind,ox as hasRuntimeConfigExtension,So as imageBase64DecodedByteLength,Bg as imageBase64EncodedByteLength,vo as imageBase64LengthForDecodedBytes,Ug as imageFileMaxDecodedBytesForBase64Limit,Zx as initVcr,Ml as isBase64Char,Vy as isBunEmbeddedModulePath,Zg as isCanonicalBase64,Df as isChatCompatibleModel,ux as isChatWorkspacePath,qo as isClineProvider,Lg as isGeneratedMedia,lb as isHubDaemonProcess,Bv as isHubProtocolCompatible,Sg as isHubScheduleMode,qv as isHubToolExecutorName,bx as isLikelyAuthError,ih as isMcpTimeoutConfigured,Fb as isOtlpTraceRelayProvider,lp as isRuntimeConfigExtensionKind,mb as isSupervisedConnectorProcess,Lf as isTranscriptionModel,ul as listConnectorCatalog,Zb as markOtlpTraceRelayProvider,Dh as maskSecret,Xf as mergeConnectorConnectArgs,Yg as mergeModelOptions,fo as modelHasCapability,Bf as modelProducesImages,Ff as modelSupportsImageInput,Zf as modelSupportsToolCalling,oh as noopBasicLogger,Ho as normalizeJsonLikeStringsForSchema,hl as normalizePluginManifest,fi as normalizeSdkError,Sl as normalizeUserInput,Ch as omitUndefinedValues,_g as parseHookEventPayload,hh as parseJsonStream,rx as parseRuntimeConfigExtensions,_l as parseUserCommandEnvelope,Ig as parseUserInputMode,vy as prepareRemoteConfigRuntime,jh as processWorkspaceInfo,hb as readConnectorCliLaunchSpec,Xd as readHubLauncherIdentity,Hv as readHubScheduleMode,_d as readRemoteConfigSessionBlobUploadMetadata,gb as readStartingConnectorInstance,ho as registerDisposable,ry as registerRemoteConfigSessionBlobUpload,wt as reserveImageMediaBytes,Mb as resetSdkErrorRateLimiterForTests,ai as resolveClineBuildEnv,Yd as resolveClineEnvironment,Qg as resolveEffectiveReasoningEffort,Kb as resolveHookSessionContext,Vv as resolveHubCommandTimeoutMs,SC as resolveMcpTimeoutSeconds,Co as resolveMediaBudget,qh as resolveProviderApiKeyOptional,Gh as resolveProviderLocalCli,eh as resolveReasoningBudgetFromRatio,Zl as resolveReasoningEffortRatio,Wb as resolveRootSessionId,bh as safeJsonParse,yh as safeJsonStringify,zh as sanitizeFileName,ae as sanitizeSurrogates,th as serializeAbortReason,qy as setClineClientIdentity,db as setConnectorCliLaunchSpec,fb as setStartingConnectorInstance,ll as shouldIncludeConnectorField,vl as stripModeNotices,Bh as stripUtf8Bom,nl as supportsChatModalities,Bl as toAiSdkToolResultOutput,kh as toPosixSeparators,$h as trimNonEmpty,Lh as truncateSplit,rd as truncateStr,sk as upsertWorkspaceInfo,Uf as usesImageGenerationOperation,Fg as validateAndReserveBase64Media,Pt as validateAndReserveImageMedia,Nl as validateImageMedia,Fh as validateWithZod,ab as withHubLauncherIdentity,Hy as withResolvedClineBuildEnv,El as xmlTagsRemoval,Vo as zodToJsonSchema};