@agentronics/sdk 0.7.1 → 0.7.2
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/{chunk-BPDWJCPY.js → chunk-DYCRZCCT.js} +2 -2
- package/dist/chunk-DYCRZCCT.js.map +1 -0
- package/dist/chunk-JR5YRLTH.js +18 -0
- package/dist/chunk-JR5YRLTH.js.map +1 -0
- package/dist/index.cjs +4 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.global.js +4 -4
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/{init-only-C80qhujz.d.ts → init-only-CRvqRvNI.d.ts} +8 -1
- package/dist/{init-only-s9E9bVC0.d.cts → init-only-Cif87Qbc.d.cts} +8 -1
- package/dist/init-only.cjs +4 -4
- package/dist/init-only.cjs.map +1 -1
- package/dist/init-only.d.cts +2 -2
- package/dist/init-only.d.ts +2 -2
- package/dist/init-only.global.js +4 -4
- package/dist/init-only.global.js.map +1 -1
- package/dist/init-only.js +1 -1
- package/dist/lite.d.cts +2 -2
- package/dist/lite.d.ts +2 -2
- package/dist/lite.js +1 -1
- package/dist/{webmcp-BgKzHeQ3.d.cts → webmcp-C5uwNbnJ.d.cts} +2 -1
- package/dist/{webmcp-BgKzHeQ3.d.ts → webmcp-C5uwNbnJ.d.ts} +2 -1
- package/package.json +3 -3
- package/dist/chunk-4FLZQPCO.js +0 -18
- package/dist/chunk-4FLZQPCO.js.map +0 -1
- package/dist/chunk-BPDWJCPY.js.map +0 -1
package/dist/init-only.global.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var Agentronics=(function(exports){'use strict';var vr=Object.defineProperty;var xr=(t,e)=>{for(var n in e)vr(t,n,{get:e[n],enumerable:true});};var l={};xr(l,{BRAND:()=>Fr,DIRTY:()=>me,EMPTY_PATH:()=>_r,INVALID:()=>k,NEVER:()=>Co,OK:()=>$,ParseStatus:()=>j,Schema:()=>R,ZodAny:()=>le,ZodArray:()=>se,ZodBigInt:()=>ye,ZodBoolean:()=>he,ZodBranded:()=>Fe,ZodCatch:()=>Re,ZodDate:()=>ve,ZodDefault:()=>Ie,ZodDiscriminatedUnion:()=>nt,ZodEffects:()=>Z,ZodEnum:()=>Se,ZodError:()=>W,ZodFirstPartyTypeKind:()=>T,ZodFunction:()=>ot,ZodIntersection:()=>ke,ZodIssueCode:()=>f,ZodLazy:()=>_e,ZodLiteral:()=>Te,ZodMap:()=>$e,ZodNaN:()=>We,ZodNativeEnum:()=>Ae,ZodNever:()=>J,ZodNull:()=>be,ZodNullable:()=>Q,ZodNumber:()=>ge,ZodObject:()=>B,ZodOptional:()=>F,ZodParsedType:()=>y,ZodPipeline:()=>Ke,ZodPromise:()=>de,ZodReadonly:()=>Ee,ZodRecord:()=>rt,ZodSchema:()=>R,ZodSet:()=>Le,ZodString:()=>ce,ZodSymbol:()=>je,ZodTransformer:()=>Z,ZodTuple:()=>X,ZodType:()=>R,ZodUndefined:()=>xe,ZodUnion:()=>we,ZodUnknown:()=>oe,ZodVoid:()=>Ne,addIssueToContext:()=>g,any:()=>eo,array:()=>oo,bigint:()=>Jr,boolean:()=>sn,coerce:()=>Eo,custom:()=>nn,date:()=>qr,datetimeRegex:()=>en,defaultErrorMap:()=>ne,discriminatedUnion:()=>co,effect:()=>wo,enum:()=>vo,function:()=>go,getErrorMap:()=>Oe,getParsedType:()=>Y,instanceof:()=>Zr,intersection:()=>lo,isAborted:()=>et,isAsync:()=>Pe,isDirty:()=>tt,isValid:()=>ae,late:()=>Kr,lazy:()=>yo,literal:()=>ho,makeIssue:()=>Ge,map:()=>fo,nan:()=>Hr,nativeEnum:()=>xo,never:()=>no,null:()=>Qr,nullable:()=>_o,number:()=>on,object:()=>so,objectUtil:()=>mt,oboolean:()=>Ro,onumber:()=>Io,optional:()=>ko,ostring:()=>Ao,pipeline:()=>So,preprocess:()=>To,promise:()=>bo,quotelessJson:()=>br,record:()=>po,set:()=>mo,setErrorMap:()=>kr,strictObject:()=>io,string:()=>rn,symbol:()=>Yr,transformer:()=>wo,tuple:()=>uo,undefined:()=>Xr,union:()=>ao,unknown:()=>to,util:()=>E,void:()=>ro});var E;(function(t){t.assertEqual=o=>{};function e(o){}t.assertIs=e;function n(o){throw new Error}t.assertNever=n,t.arrayToEnum=o=>{let s={};for(let i of o)s[i]=i;return s},t.getValidEnumValues=o=>{let s=t.objectKeys(o).filter(a=>typeof o[o[a]]!="number"),i={};for(let a of s)i[a]=o[a];return t.objectValues(i)},t.objectValues=o=>t.objectKeys(o).map(function(s){return o[s]}),t.objectKeys=typeof Object.keys=="function"?o=>Object.keys(o):o=>{let s=[];for(let i in o)Object.prototype.hasOwnProperty.call(o,i)&&s.push(i);return s},t.find=(o,s)=>{for(let i of o)if(s(i))return i},t.isInteger=typeof Number.isInteger=="function"?o=>Number.isInteger(o):o=>typeof o=="number"&&Number.isFinite(o)&&Math.floor(o)===o;function r(o,s=" | "){return o.map(i=>typeof i=="string"?`'${i}'`:i).join(s)}t.joinValues=r,t.jsonStringifyReplacer=(o,s)=>typeof s=="bigint"?s.toString():s;})(E||(E={}));var mt;(function(t){t.mergeShapes=(e,n)=>({...e,...n});})(mt||(mt={}));var y=E.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Y=t=>{switch(typeof t){case "undefined":return y.undefined;case "string":return y.string;case "number":return Number.isNaN(t)?y.nan:y.number;case "boolean":return y.boolean;case "function":return y.function;case "bigint":return y.bigint;case "symbol":return y.symbol;case "object":return Array.isArray(t)?y.array:t===null?y.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?y.promise:typeof Map<"u"&&t instanceof Map?y.map:typeof Set<"u"&&t instanceof Set?y.set:typeof Date<"u"&&t instanceof Date?y.date:y.object;default:return y.unknown}};var f=E.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),br=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),W=class t extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r];},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r];};let n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=e;}format(e){let n=e||function(s){return s.message},r={_errors:[]},o=s=>{for(let i of s.issues)if(i.code==="invalid_union")i.unionErrors.map(o);else if(i.code==="invalid_return_type")o(i.returnTypeError);else if(i.code==="invalid_arguments")o(i.argumentsError);else if(i.path.length===0)r._errors.push(n(i));else {let a=r,d=0;for(;d<i.path.length;){let c=i.path[d];d===i.path.length-1?(a[c]=a[c]||{_errors:[]},a[c]._errors.push(n(i))):a[c]=a[c]||{_errors:[]},a=a[c],d++;}}};return o(this),r}static assert(e){if(!(e instanceof t))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,E.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=n=>n.message){let n={},r=[];for(let o of this.issues)if(o.path.length>0){let s=o.path[0];n[s]=n[s]||[],n[s].push(e(o));}else r.push(e(o));return {formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}};W.create=t=>new W(t);var wr=(t,e)=>{let n;switch(t.code){case f.invalid_type:t.received===y.undefined?n="Required":n=`Expected ${t.expected}, received ${t.received}`;break;case f.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(t.expected,E.jsonStringifyReplacer)}`;break;case f.unrecognized_keys:n=`Unrecognized key(s) in object: ${E.joinValues(t.keys,", ")}`;break;case f.invalid_union:n="Invalid input";break;case f.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${E.joinValues(t.options)}`;break;case f.invalid_enum_value:n=`Invalid enum value. Expected ${E.joinValues(t.options)}, received '${t.received}'`;break;case f.invalid_arguments:n="Invalid function arguments";break;case f.invalid_return_type:n="Invalid function return type";break;case f.invalid_date:n="Invalid date";break;case f.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(n=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?n=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?n=`Invalid input: must end with "${t.validation.endsWith}"`:E.assertNever(t.validation):t.validation!=="regex"?n=`Invalid ${t.validation}`:n="Invalid";break;case f.too_small:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:n="Invalid input";break;case f.too_big:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?n=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:n="Invalid input";break;case f.custom:n="Invalid input";break;case f.invalid_intersection_types:n="Intersection results could not be merged";break;case f.not_multiple_of:n=`Number must be a multiple of ${t.multipleOf}`;break;case f.not_finite:n="Number must be finite";break;default:n=e.defaultError,E.assertNever(t);}return {message:n}},ne=wr;var Jt=ne;function kr(t){Jt=t;}function Oe(){return Jt}var Ge=t=>{let{data:e,path:n,errorMaps:r,issueData:o}=t,s=[...n,...o.path||[]],i={...o,path:s};if(o.message!==void 0)return {...o,path:s,message:o.message};let a="",d=r.filter(c=>!!c).slice().reverse();for(let c of d)a=c(i,{data:e,defaultError:a}).message;return {...o,path:s,message:a}},_r=[];function g(t,e){let n=Oe(),r=Ge({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n,n===ne?void 0:ne].filter(o=>!!o)});t.common.issues.push(r);}var j=class t{constructor(){this.value="valid";}dirty(){this.value==="valid"&&(this.value="dirty");}abort(){this.value!=="aborted"&&(this.value="aborted");}static mergeArray(e,n){let r=[];for(let o of n){if(o.status==="aborted")return k;o.status==="dirty"&&e.dirty(),r.push(o.value);}return {status:e.value,value:r}}static async mergeObjectAsync(e,n){let r=[];for(let o of n){let s=await o.key,i=await o.value;r.push({key:s,value:i});}return t.mergeObjectSync(e,r)}static mergeObjectSync(e,n){let r={};for(let o of n){let{key:s,value:i}=o;if(s.status==="aborted"||i.status==="aborted")return k;s.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),s.value!=="__proto__"&&(typeof i.value<"u"||o.alwaysSet)&&(r[s.value]=i.value);}return {status:e.value,value:r}}},k=Object.freeze({status:"aborted"}),me=t=>({status:"dirty",value:t}),$=t=>({status:"valid",value:t}),et=t=>t.status==="aborted",tt=t=>t.status==="dirty",ae=t=>t.status==="valid",Pe=t=>typeof Promise<"u"&&t instanceof Promise;var w;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message;})(w||(w={}));var K=class{constructor(e,n,r,o){this._cachedPath=[],this.parent=e,this.data=n,this._path=r,this._key=o;}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},qt=(t,e)=>{if(ae(e))return {success:true,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return {success:false,get error(){if(this._error)return this._error;let n=new W(t.common.issues);return this._error=n,this._error}}};function I(t){if(!t)return {};let{errorMap:e,invalid_type_error:n,required_error:r,description:o}=t;if(e&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:o}:{errorMap:(i,a)=>{let{message:d}=t;return i.code==="invalid_enum_value"?{message:d??a.defaultError}:typeof a.data>"u"?{message:d??r??a.defaultError}:i.code!=="invalid_type"?{message:a.defaultError}:{message:d??n??a.defaultError}},description:o}}var R=class{get description(){return this._def.description}_getType(e){return Y(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:Y(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return {status:new j,ctx:{common:e.parent.common,data:e.data,parsedType:Y(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let n=this._parse(e);if(Pe(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(e){let n=this._parse(e);return Promise.resolve(n)}parse(e,n){let r=this.safeParse(e,n);if(r.success)return r.data;throw r.error}safeParse(e,n){let r={common:{issues:[],async:n?.async??false,contextualErrorMap:n?.errorMap},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Y(e)},o=this._parseSync({data:e,path:r.path,parent:r});return qt(r,o)}"~validate"(e){let n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Y(e)};if(!this["~standard"].async)try{let r=this._parseSync({data:e,path:[],parent:n});return ae(r)?{value:r.value}:{issues:n.common.issues}}catch(r){r?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=true),n.common={issues:[],async:true};}return this._parseAsync({data:e,path:[],parent:n}).then(r=>ae(r)?{value:r.value}:{issues:n.common.issues})}async parseAsync(e,n){let r=await this.safeParseAsync(e,n);if(r.success)return r.data;throw r.error}async safeParseAsync(e,n){let r={common:{issues:[],contextualErrorMap:n?.errorMap,async:true},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Y(e)},o=this._parse({data:e,path:r.path,parent:r}),s=await(Pe(o)?o:Promise.resolve(o));return qt(r,s)}refine(e,n){let r=o=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(o):n;return this._refinement((o,s)=>{let i=e(o),a=()=>s.addIssue({code:f.custom,...r(o)});return typeof Promise<"u"&&i instanceof Promise?i.then(d=>d?true:(a(),false)):i?true:(a(),false)})}refinement(e,n){return this._refinement((r,o)=>e(r)?true:(o.addIssue(typeof n=="function"?n(r,o):n),false))}_refinement(e){return new Z({schema:this,typeName:T.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:n=>this["~validate"](n)};}optional(){return F.create(this,this._def)}nullable(){return Q.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return se.create(this)}promise(){return de.create(this,this._def)}or(e){return we.create([this,e],this._def)}and(e){return ke.create(this,e,this._def)}transform(e){return new Z({...I(this._def),schema:this,typeName:T.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let n=typeof e=="function"?e:()=>e;return new Ie({...I(this._def),innerType:this,defaultValue:n,typeName:T.ZodDefault})}brand(){return new Fe({typeName:T.ZodBranded,type:this,...I(this._def)})}catch(e){let n=typeof e=="function"?e:()=>e;return new Re({...I(this._def),innerType:this,catchValue:n,typeName:T.ZodCatch})}describe(e){let n=this.constructor;return new n({...this._def,description:e})}pipe(e){return Ke.create(this,e)}readonly(){return Ee.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Tr=/^c[^\s-]{8,}$/i,Sr=/^[0-9a-z]+$/,Ar=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Ir=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Rr=/^[a-z0-9_-]{21}$/i,Er=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Cr=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Mr=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Or="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",gt,Pr=/^(?:(?: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])$/,Dr=/^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/,jr=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Nr=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,$r=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Lr=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Xt="((\\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])))",Wr=new RegExp(`^${Xt}$`);function Qt(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);let n=t.precision?"+":"?";return `([01]\\d|2[0-3]):[0-5]\\d(:${e})${n}`}function Br(t){return new RegExp(`^${Qt(t)}$`)}function en(t){let e=`${Xt}T${Qt(t)}`,n=[];return n.push(t.local?"Z?":"Z"),t.offset&&n.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${n.join("|")})`,new RegExp(`^${e}$`)}function Vr(t,e){return !!((e==="v4"||!e)&&Pr.test(t)||(e==="v6"||!e)&&jr.test(t))}function Ur(t,e){if(!Er.test(t))return false;try{let[n]=t.split(".");if(!n)return !1;let r=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),o=JSON.parse(atob(r));return !(typeof o!="object"||o===null||"typ"in o&&o?.typ!=="JWT"||!o.alg||e&&o.alg!==e)}catch{return false}}function zr(t,e){return !!((e==="v4"||!e)&&Dr.test(t)||(e==="v6"||!e)&&Nr.test(t))}var ce=class t extends R{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==y.string){let s=this._getOrReturnCtx(e);return g(s,{code:f.invalid_type,expected:y.string,received:s.parsedType}),k}let r=new j,o;for(let s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(o=this._getOrReturnCtx(e,o),g(o,{code:f.too_small,minimum:s.value,type:"string",inclusive:true,exact:false,message:s.message}),r.dirty());else if(s.kind==="max")e.data.length>s.value&&(o=this._getOrReturnCtx(e,o),g(o,{code:f.too_big,maximum:s.value,type:"string",inclusive:true,exact:false,message:s.message}),r.dirty());else if(s.kind==="length"){let i=e.data.length>s.value,a=e.data.length<s.value;(i||a)&&(o=this._getOrReturnCtx(e,o),i?g(o,{code:f.too_big,maximum:s.value,type:"string",inclusive:true,exact:true,message:s.message}):a&&g(o,{code:f.too_small,minimum:s.value,type:"string",inclusive:true,exact:true,message:s.message}),r.dirty());}else if(s.kind==="email")Mr.test(e.data)||(o=this._getOrReturnCtx(e,o),g(o,{validation:"email",code:f.invalid_string,message:s.message}),r.dirty());else if(s.kind==="emoji")gt||(gt=new RegExp(Or,"u")),gt.test(e.data)||(o=this._getOrReturnCtx(e,o),g(o,{validation:"emoji",code:f.invalid_string,message:s.message}),r.dirty());else if(s.kind==="uuid")Ir.test(e.data)||(o=this._getOrReturnCtx(e,o),g(o,{validation:"uuid",code:f.invalid_string,message:s.message}),r.dirty());else if(s.kind==="nanoid")Rr.test(e.data)||(o=this._getOrReturnCtx(e,o),g(o,{validation:"nanoid",code:f.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid")Tr.test(e.data)||(o=this._getOrReturnCtx(e,o),g(o,{validation:"cuid",code:f.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid2")Sr.test(e.data)||(o=this._getOrReturnCtx(e,o),g(o,{validation:"cuid2",code:f.invalid_string,message:s.message}),r.dirty());else if(s.kind==="ulid")Ar.test(e.data)||(o=this._getOrReturnCtx(e,o),g(o,{validation:"ulid",code:f.invalid_string,message:s.message}),r.dirty());else if(s.kind==="url")try{new URL(e.data);}catch{o=this._getOrReturnCtx(e,o),g(o,{validation:"url",code:f.invalid_string,message:s.message}),r.dirty();}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(o=this._getOrReturnCtx(e,o),g(o,{validation:"regex",code:f.invalid_string,message:s.message}),r.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(o=this._getOrReturnCtx(e,o),g(o,{code:f.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),r.dirty()):s.kind==="toLowerCase"?e.data=e.data.toLowerCase():s.kind==="toUpperCase"?e.data=e.data.toUpperCase():s.kind==="startsWith"?e.data.startsWith(s.value)||(o=this._getOrReturnCtx(e,o),g(o,{code:f.invalid_string,validation:{startsWith:s.value},message:s.message}),r.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(o=this._getOrReturnCtx(e,o),g(o,{code:f.invalid_string,validation:{endsWith:s.value},message:s.message}),r.dirty()):s.kind==="datetime"?en(s).test(e.data)||(o=this._getOrReturnCtx(e,o),g(o,{code:f.invalid_string,validation:"datetime",message:s.message}),r.dirty()):s.kind==="date"?Wr.test(e.data)||(o=this._getOrReturnCtx(e,o),g(o,{code:f.invalid_string,validation:"date",message:s.message}),r.dirty()):s.kind==="time"?Br(s).test(e.data)||(o=this._getOrReturnCtx(e,o),g(o,{code:f.invalid_string,validation:"time",message:s.message}),r.dirty()):s.kind==="duration"?Cr.test(e.data)||(o=this._getOrReturnCtx(e,o),g(o,{validation:"duration",code:f.invalid_string,message:s.message}),r.dirty()):s.kind==="ip"?Vr(e.data,s.version)||(o=this._getOrReturnCtx(e,o),g(o,{validation:"ip",code:f.invalid_string,message:s.message}),r.dirty()):s.kind==="jwt"?Ur(e.data,s.alg)||(o=this._getOrReturnCtx(e,o),g(o,{validation:"jwt",code:f.invalid_string,message:s.message}),r.dirty()):s.kind==="cidr"?zr(e.data,s.version)||(o=this._getOrReturnCtx(e,o),g(o,{validation:"cidr",code:f.invalid_string,message:s.message}),r.dirty()):s.kind==="base64"?$r.test(e.data)||(o=this._getOrReturnCtx(e,o),g(o,{validation:"base64",code:f.invalid_string,message:s.message}),r.dirty()):s.kind==="base64url"?Lr.test(e.data)||(o=this._getOrReturnCtx(e,o),g(o,{validation:"base64url",code:f.invalid_string,message:s.message}),r.dirty()):E.assertNever(s);return {status:r.value,value:e.data}}_regex(e,n,r){return this.refinement(o=>e.test(o),{validation:n,code:f.invalid_string,...w.errToObj(r)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...w.errToObj(e)})}url(e){return this._addCheck({kind:"url",...w.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...w.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...w.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...w.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...w.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...w.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...w.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...w.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...w.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...w.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...w.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...w.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:false,local:false,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??false,local:e?.local??false,...w.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...w.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...w.errToObj(e)})}regex(e,n){return this._addCheck({kind:"regex",regex:e,...w.errToObj(n)})}includes(e,n){return this._addCheck({kind:"includes",value:e,position:n?.position,...w.errToObj(n?.message)})}startsWith(e,n){return this._addCheck({kind:"startsWith",value:e,...w.errToObj(n)})}endsWith(e,n){return this._addCheck({kind:"endsWith",value:e,...w.errToObj(n)})}min(e,n){return this._addCheck({kind:"min",value:e,...w.errToObj(n)})}max(e,n){return this._addCheck({kind:"max",value:e,...w.errToObj(n)})}length(e,n){return this._addCheck({kind:"length",value:e,...w.errToObj(n)})}nonempty(e){return this.min(1,w.errToObj(e))}trim(){return new t({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return !!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return !!this._def.checks.find(e=>e.kind==="date")}get isTime(){return !!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return !!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return !!this._def.checks.find(e=>e.kind==="email")}get isURL(){return !!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return !!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return !!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return !!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return !!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return !!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return !!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return !!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return !!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return !!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return !!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxLength(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}};ce.create=t=>new ce({checks:[],typeName:T.ZodString,coerce:t?.coerce??false,...I(t)});function Gr(t,e){let n=(t.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,o=n>r?n:r,s=Number.parseInt(t.toFixed(o).replace(".","")),i=Number.parseInt(e.toFixed(o).replace(".",""));return s%i/10**o}var ge=class t extends R{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf;}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==y.number){let s=this._getOrReturnCtx(e);return g(s,{code:f.invalid_type,expected:y.number,received:s.parsedType}),k}let r,o=new j;for(let s of this._def.checks)s.kind==="int"?E.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),g(r,{code:f.invalid_type,expected:"integer",received:"float",message:s.message}),o.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(r=this._getOrReturnCtx(e,r),g(r,{code:f.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:false,message:s.message}),o.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(r=this._getOrReturnCtx(e,r),g(r,{code:f.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:false,message:s.message}),o.dirty()):s.kind==="multipleOf"?Gr(e.data,s.value)!==0&&(r=this._getOrReturnCtx(e,r),g(r,{code:f.not_multiple_of,multipleOf:s.value,message:s.message}),o.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),g(r,{code:f.not_finite,message:s.message}),o.dirty()):E.assertNever(s);return {status:o.value,value:e.data}}gte(e,n){return this.setLimit("min",e,true,w.toString(n))}gt(e,n){return this.setLimit("min",e,false,w.toString(n))}lte(e,n){return this.setLimit("max",e,true,w.toString(n))}lt(e,n){return this.setLimit("max",e,false,w.toString(n))}setLimit(e,n,r,o){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:w.toString(o)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:w.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:false,message:w.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:false,message:w.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:true,message:w.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:true,message:w.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:w.toString(n)})}finite(e){return this._addCheck({kind:"finite",message:w.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:true,value:Number.MIN_SAFE_INTEGER,message:w.toString(e)})._addCheck({kind:"max",inclusive:true,value:Number.MAX_SAFE_INTEGER,message:w.toString(e)})}get minValue(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}get isInt(){return !!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&E.isInteger(e.value))}get isFinite(){let e=null,n=null;for(let r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return true;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);}return Number.isFinite(n)&&Number.isFinite(e)}};ge.create=t=>new ge({checks:[],typeName:T.ZodNumber,coerce:t?.coerce||false,...I(t)});var ye=class t extends R{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte;}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data);}catch{return this._getInvalidInput(e)}if(this._getType(e)!==y.bigint)return this._getInvalidInput(e);let r,o=new j;for(let s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(r=this._getOrReturnCtx(e,r),g(r,{code:f.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),o.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(r=this._getOrReturnCtx(e,r),g(r,{code:f.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),o.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),g(r,{code:f.not_multiple_of,multipleOf:s.value,message:s.message}),o.dirty()):E.assertNever(s);return {status:o.value,value:e.data}}_getInvalidInput(e){let n=this._getOrReturnCtx(e);return g(n,{code:f.invalid_type,expected:y.bigint,received:n.parsedType}),k}gte(e,n){return this.setLimit("min",e,true,w.toString(n))}gt(e,n){return this.setLimit("min",e,false,w.toString(n))}lte(e,n){return this.setLimit("max",e,true,w.toString(n))}lt(e,n){return this.setLimit("max",e,false,w.toString(n))}setLimit(e,n,r,o){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:w.toString(o)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:false,message:w.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:false,message:w.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:true,message:w.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:true,message:w.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:w.toString(n)})}get minValue(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}};ye.create=t=>new ye({checks:[],typeName:T.ZodBigInt,coerce:t?.coerce??false,...I(t)});var he=class extends R{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==y.boolean){let r=this._getOrReturnCtx(e);return g(r,{code:f.invalid_type,expected:y.boolean,received:r.parsedType}),k}return $(e.data)}};he.create=t=>new he({typeName:T.ZodBoolean,coerce:t?.coerce||false,...I(t)});var ve=class t extends R{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==y.date){let s=this._getOrReturnCtx(e);return g(s,{code:f.invalid_type,expected:y.date,received:s.parsedType}),k}if(Number.isNaN(e.data.getTime())){let s=this._getOrReturnCtx(e);return g(s,{code:f.invalid_date}),k}let r=new j,o;for(let s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(o=this._getOrReturnCtx(e,o),g(o,{code:f.too_small,message:s.message,inclusive:true,exact:false,minimum:s.value,type:"date"}),r.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(o=this._getOrReturnCtx(e,o),g(o,{code:f.too_big,message:s.message,inclusive:true,exact:false,maximum:s.value,type:"date"}),r.dirty()):E.assertNever(s);return {status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,n){return this._addCheck({kind:"min",value:e.getTime(),message:w.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:w.toString(n)})}get minDate(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e!=null?new Date(e):null}};ve.create=t=>new ve({checks:[],coerce:t?.coerce||false,typeName:T.ZodDate,...I(t)});var je=class extends R{_parse(e){if(this._getType(e)!==y.symbol){let r=this._getOrReturnCtx(e);return g(r,{code:f.invalid_type,expected:y.symbol,received:r.parsedType}),k}return $(e.data)}};je.create=t=>new je({typeName:T.ZodSymbol,...I(t)});var xe=class extends R{_parse(e){if(this._getType(e)!==y.undefined){let r=this._getOrReturnCtx(e);return g(r,{code:f.invalid_type,expected:y.undefined,received:r.parsedType}),k}return $(e.data)}};xe.create=t=>new xe({typeName:T.ZodUndefined,...I(t)});var be=class extends R{_parse(e){if(this._getType(e)!==y.null){let r=this._getOrReturnCtx(e);return g(r,{code:f.invalid_type,expected:y.null,received:r.parsedType}),k}return $(e.data)}};be.create=t=>new be({typeName:T.ZodNull,...I(t)});var le=class extends R{constructor(){super(...arguments),this._any=true;}_parse(e){return $(e.data)}};le.create=t=>new le({typeName:T.ZodAny,...I(t)});var oe=class extends R{constructor(){super(...arguments),this._unknown=true;}_parse(e){return $(e.data)}};oe.create=t=>new oe({typeName:T.ZodUnknown,...I(t)});var J=class extends R{_parse(e){let n=this._getOrReturnCtx(e);return g(n,{code:f.invalid_type,expected:y.never,received:n.parsedType}),k}};J.create=t=>new J({typeName:T.ZodNever,...I(t)});var Ne=class extends R{_parse(e){if(this._getType(e)!==y.undefined){let r=this._getOrReturnCtx(e);return g(r,{code:f.invalid_type,expected:y.void,received:r.parsedType}),k}return $(e.data)}};Ne.create=t=>new Ne({typeName:T.ZodVoid,...I(t)});var se=class t extends R{_parse(e){let{ctx:n,status:r}=this._processInputParams(e),o=this._def;if(n.parsedType!==y.array)return g(n,{code:f.invalid_type,expected:y.array,received:n.parsedType}),k;if(o.exactLength!==null){let i=n.data.length>o.exactLength.value,a=n.data.length<o.exactLength.value;(i||a)&&(g(n,{code:i?f.too_big:f.too_small,minimum:a?o.exactLength.value:void 0,maximum:i?o.exactLength.value:void 0,type:"array",inclusive:true,exact:true,message:o.exactLength.message}),r.dirty());}if(o.minLength!==null&&n.data.length<o.minLength.value&&(g(n,{code:f.too_small,minimum:o.minLength.value,type:"array",inclusive:true,exact:false,message:o.minLength.message}),r.dirty()),o.maxLength!==null&&n.data.length>o.maxLength.value&&(g(n,{code:f.too_big,maximum:o.maxLength.value,type:"array",inclusive:true,exact:false,message:o.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((i,a)=>o.type._parseAsync(new K(n,i,n.path,a)))).then(i=>j.mergeArray(r,i));let s=[...n.data].map((i,a)=>o.type._parseSync(new K(n,i,n.path,a)));return j.mergeArray(r,s)}get element(){return this._def.type}min(e,n){return new t({...this._def,minLength:{value:e,message:w.toString(n)}})}max(e,n){return new t({...this._def,maxLength:{value:e,message:w.toString(n)}})}length(e,n){return new t({...this._def,exactLength:{value:e,message:w.toString(n)}})}nonempty(e){return this.min(1,e)}};se.create=(t,e)=>new se({type:t,minLength:null,maxLength:null,exactLength:null,typeName:T.ZodArray,...I(e)});function De(t){if(t instanceof B){let e={};for(let n in t.shape){let r=t.shape[n];e[n]=F.create(De(r));}return new B({...t._def,shape:()=>e})}else return t instanceof se?new se({...t._def,type:De(t.element)}):t instanceof F?F.create(De(t.unwrap())):t instanceof Q?Q.create(De(t.unwrap())):t instanceof X?X.create(t.items.map(e=>De(e))):t}var B=class t extends R{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend;}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),n=E.objectKeys(e);return this._cached={shape:e,keys:n},this._cached}_parse(e){if(this._getType(e)!==y.object){let c=this._getOrReturnCtx(e);return g(c,{code:f.invalid_type,expected:y.object,received:c.parsedType}),k}let{status:r,ctx:o}=this._processInputParams(e),{shape:s,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof J&&this._def.unknownKeys==="strip"))for(let c in o.data)i.includes(c)||a.push(c);let d=[];for(let c of i){let p=s[c],h=o.data[c];d.push({key:{status:"valid",value:c},value:p._parse(new K(o,h,o.path,c)),alwaysSet:c in o.data});}if(this._def.catchall instanceof J){let c=this._def.unknownKeys;if(c==="passthrough")for(let p of a)d.push({key:{status:"valid",value:p},value:{status:"valid",value:o.data[p]}});else if(c==="strict")a.length>0&&(g(o,{code:f.unrecognized_keys,keys:a}),r.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else {let c=this._def.catchall;for(let p of a){let h=o.data[p];d.push({key:{status:"valid",value:p},value:c._parse(new K(o,h,o.path,p)),alwaysSet:p in o.data});}}return o.common.async?Promise.resolve().then(async()=>{let c=[];for(let p of d){let h=await p.key,v=await p.value;c.push({key:h,value:v,alwaysSet:p.alwaysSet});}return c}).then(c=>j.mergeObjectSync(r,c)):j.mergeObjectSync(r,d)}get shape(){return this._def.shape()}strict(e){return w.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(n,r)=>{let o=this._def.errorMap?.(n,r).message??r.defaultError;return n.code==="unrecognized_keys"?{message:w.errToObj(e).message??o}:{message:o}}}:{}})}strip(){return new t({...this._def,unknownKeys:"strip"})}passthrough(){return new t({...this._def,unknownKeys:"passthrough"})}extend(e){return new t({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:T.ZodObject})}setKey(e,n){return this.augment({[e]:n})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let n={};for(let r of E.objectKeys(e))e[r]&&this.shape[r]&&(n[r]=this.shape[r]);return new t({...this._def,shape:()=>n})}omit(e){let n={};for(let r of E.objectKeys(this.shape))e[r]||(n[r]=this.shape[r]);return new t({...this._def,shape:()=>n})}deepPartial(){return De(this)}partial(e){let n={};for(let r of E.objectKeys(this.shape)){let o=this.shape[r];e&&!e[r]?n[r]=o:n[r]=o.optional();}return new t({...this._def,shape:()=>n})}required(e){let n={};for(let r of E.objectKeys(this.shape))if(e&&!e[r])n[r]=this.shape[r];else {let s=this.shape[r];for(;s instanceof F;)s=s._def.innerType;n[r]=s;}return new t({...this._def,shape:()=>n})}keyof(){return tn(E.objectKeys(this.shape))}};B.create=(t,e)=>new B({shape:()=>t,unknownKeys:"strip",catchall:J.create(),typeName:T.ZodObject,...I(e)});B.strictCreate=(t,e)=>new B({shape:()=>t,unknownKeys:"strict",catchall:J.create(),typeName:T.ZodObject,...I(e)});B.lazycreate=(t,e)=>new B({shape:t,unknownKeys:"strip",catchall:J.create(),typeName:T.ZodObject,...I(e)});var we=class extends R{_parse(e){let{ctx:n}=this._processInputParams(e),r=this._def.options;function o(s){for(let a of s)if(a.result.status==="valid")return a.result;for(let a of s)if(a.result.status==="dirty")return n.common.issues.push(...a.ctx.common.issues),a.result;let i=s.map(a=>new W(a.ctx.common.issues));return g(n,{code:f.invalid_union,unionErrors:i}),k}if(n.common.async)return Promise.all(r.map(async s=>{let i={...n,common:{...n.common,issues:[]},parent:null};return {result:await s._parseAsync({data:n.data,path:n.path,parent:i}),ctx:i}})).then(o);{let s,i=[];for(let d of r){let c={...n,common:{...n.common,issues:[]},parent:null},p=d._parseSync({data:n.data,path:n.path,parent:c});if(p.status==="valid")return p;p.status==="dirty"&&!s&&(s={result:p,ctx:c}),c.common.issues.length&&i.push(c.common.issues);}if(s)return n.common.issues.push(...s.ctx.common.issues),s.result;let a=i.map(d=>new W(d));return g(n,{code:f.invalid_union,unionErrors:a}),k}}get options(){return this._def.options}};we.create=(t,e)=>new we({options:t,typeName:T.ZodUnion,...I(e)});var re=t=>t instanceof _e?re(t.schema):t instanceof Z?re(t.innerType()):t instanceof Te?[t.value]:t instanceof Se?t.options:t instanceof Ae?E.objectValues(t.enum):t instanceof Ie?re(t._def.innerType):t instanceof xe?[void 0]:t instanceof be?[null]:t instanceof F?[void 0,...re(t.unwrap())]:t instanceof Q?[null,...re(t.unwrap())]:t instanceof Fe||t instanceof Ee?re(t.unwrap()):t instanceof Re?re(t._def.innerType):[],nt=class t extends R{_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==y.object)return g(n,{code:f.invalid_type,expected:y.object,received:n.parsedType}),k;let r=this.discriminator,o=n.data[r],s=this.optionsMap.get(o);return s?n.common.async?s._parseAsync({data:n.data,path:n.path,parent:n}):s._parseSync({data:n.data,path:n.path,parent:n}):(g(n,{code:f.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),k)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,n,r){let o=new Map;for(let s of n){let i=re(s.shape[e]);if(!i.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let a of i){if(o.has(a))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);o.set(a,s);}}return new t({typeName:T.ZodDiscriminatedUnion,discriminator:e,options:n,optionsMap:o,...I(r)})}};function yt(t,e){let n=Y(t),r=Y(e);if(t===e)return {valid:true,data:t};if(n===y.object&&r===y.object){let o=E.objectKeys(e),s=E.objectKeys(t).filter(a=>o.indexOf(a)!==-1),i={...t,...e};for(let a of s){let d=yt(t[a],e[a]);if(!d.valid)return {valid:false};i[a]=d.data;}return {valid:true,data:i}}else if(n===y.array&&r===y.array){if(t.length!==e.length)return {valid:false};let o=[];for(let s=0;s<t.length;s++){let i=t[s],a=e[s],d=yt(i,a);if(!d.valid)return {valid:false};o.push(d.data);}return {valid:true,data:o}}else return n===y.date&&r===y.date&&+t==+e?{valid:true,data:t}:{valid:false}}var ke=class extends R{_parse(e){let{status:n,ctx:r}=this._processInputParams(e),o=(s,i)=>{if(et(s)||et(i))return k;let a=yt(s.value,i.value);return a.valid?((tt(s)||tt(i))&&n.dirty(),{status:n.value,value:a.data}):(g(r,{code:f.invalid_intersection_types}),k)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([s,i])=>o(s,i)):o(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}};ke.create=(t,e,n)=>new ke({left:t,right:e,typeName:T.ZodIntersection,...I(n)});var X=class t extends R{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==y.array)return g(r,{code:f.invalid_type,expected:y.array,received:r.parsedType}),k;if(r.data.length<this._def.items.length)return g(r,{code:f.too_small,minimum:this._def.items.length,inclusive:true,exact:false,type:"array"}),k;!this._def.rest&&r.data.length>this._def.items.length&&(g(r,{code:f.too_big,maximum:this._def.items.length,inclusive:true,exact:false,type:"array"}),n.dirty());let s=[...r.data].map((i,a)=>{let d=this._def.items[a]||this._def.rest;return d?d._parse(new K(r,i,r.path,a)):null}).filter(i=>!!i);return r.common.async?Promise.all(s).then(i=>j.mergeArray(n,i)):j.mergeArray(n,s)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};X.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new X({items:t,typeName:T.ZodTuple,rest:null,...I(e)})};var rt=class t extends R{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==y.object)return g(r,{code:f.invalid_type,expected:y.object,received:r.parsedType}),k;let o=[],s=this._def.keyType,i=this._def.valueType;for(let a in r.data)o.push({key:s._parse(new K(r,a,r.path,a)),value:i._parse(new K(r,r.data[a],r.path,a)),alwaysSet:a in r.data});return r.common.async?j.mergeObjectAsync(n,o):j.mergeObjectSync(n,o)}get element(){return this._def.valueType}static create(e,n,r){return n instanceof R?new t({keyType:e,valueType:n,typeName:T.ZodRecord,...I(r)}):new t({keyType:ce.create(),valueType:e,typeName:T.ZodRecord,...I(n)})}},$e=class extends R{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==y.map)return g(r,{code:f.invalid_type,expected:y.map,received:r.parsedType}),k;let o=this._def.keyType,s=this._def.valueType,i=[...r.data.entries()].map(([a,d],c)=>({key:o._parse(new K(r,a,r.path,[c,"key"])),value:s._parse(new K(r,d,r.path,[c,"value"]))}));if(r.common.async){let a=new Map;return Promise.resolve().then(async()=>{for(let d of i){let c=await d.key,p=await d.value;if(c.status==="aborted"||p.status==="aborted")return k;(c.status==="dirty"||p.status==="dirty")&&n.dirty(),a.set(c.value,p.value);}return {status:n.value,value:a}})}else {let a=new Map;for(let d of i){let c=d.key,p=d.value;if(c.status==="aborted"||p.status==="aborted")return k;(c.status==="dirty"||p.status==="dirty")&&n.dirty(),a.set(c.value,p.value);}return {status:n.value,value:a}}}};$e.create=(t,e,n)=>new $e({valueType:e,keyType:t,typeName:T.ZodMap,...I(n)});var Le=class t extends R{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==y.set)return g(r,{code:f.invalid_type,expected:y.set,received:r.parsedType}),k;let o=this._def;o.minSize!==null&&r.data.size<o.minSize.value&&(g(r,{code:f.too_small,minimum:o.minSize.value,type:"set",inclusive:true,exact:false,message:o.minSize.message}),n.dirty()),o.maxSize!==null&&r.data.size>o.maxSize.value&&(g(r,{code:f.too_big,maximum:o.maxSize.value,type:"set",inclusive:true,exact:false,message:o.maxSize.message}),n.dirty());let s=this._def.valueType;function i(d){let c=new Set;for(let p of d){if(p.status==="aborted")return k;p.status==="dirty"&&n.dirty(),c.add(p.value);}return {status:n.value,value:c}}let a=[...r.data.values()].map((d,c)=>s._parse(new K(r,d,r.path,c)));return r.common.async?Promise.all(a).then(d=>i(d)):i(a)}min(e,n){return new t({...this._def,minSize:{value:e,message:w.toString(n)}})}max(e,n){return new t({...this._def,maxSize:{value:e,message:w.toString(n)}})}size(e,n){return this.min(e,n).max(e,n)}nonempty(e){return this.min(1,e)}};Le.create=(t,e)=>new Le({valueType:t,minSize:null,maxSize:null,typeName:T.ZodSet,...I(e)});var ot=class t extends R{constructor(){super(...arguments),this.validate=this.implement;}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==y.function)return g(n,{code:f.invalid_type,expected:y.function,received:n.parsedType}),k;function r(a,d){return Ge({data:a,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,Oe(),ne].filter(c=>!!c),issueData:{code:f.invalid_arguments,argumentsError:d}})}function o(a,d){return Ge({data:a,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,Oe(),ne].filter(c=>!!c),issueData:{code:f.invalid_return_type,returnTypeError:d}})}let s={errorMap:n.common.contextualErrorMap},i=n.data;if(this._def.returns instanceof de){let a=this;return $(async function(...d){let c=new W([]),p=await a._def.args.parseAsync(d,s).catch(_=>{throw c.addIssue(r(d,_)),c}),h=await Reflect.apply(i,this,p);return await a._def.returns._def.type.parseAsync(h,s).catch(_=>{throw c.addIssue(o(h,_)),c})})}else {let a=this;return $(function(...d){let c=a._def.args.safeParse(d,s);if(!c.success)throw new W([r(d,c.error)]);let p=Reflect.apply(i,this,c.data),h=a._def.returns.safeParse(p,s);if(!h.success)throw new W([o(p,h.error)]);return h.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:X.create(e).rest(oe.create())})}returns(e){return new t({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,n,r){return new t({args:e||X.create([]).rest(oe.create()),returns:n||oe.create(),typeName:T.ZodFunction,...I(r)})}},_e=class extends R{get schema(){return this._def.getter()}_parse(e){let{ctx:n}=this._processInputParams(e);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}};_e.create=(t,e)=>new _e({getter:t,typeName:T.ZodLazy,...I(e)});var Te=class extends R{_parse(e){if(e.data!==this._def.value){let n=this._getOrReturnCtx(e);return g(n,{received:n.data,code:f.invalid_literal,expected:this._def.value}),k}return {status:"valid",value:e.data}}get value(){return this._def.value}};Te.create=(t,e)=>new Te({value:t,typeName:T.ZodLiteral,...I(e)});function tn(t,e){return new Se({values:t,typeName:T.ZodEnum,...I(e)})}var Se=class t extends R{_parse(e){if(typeof e.data!="string"){let n=this._getOrReturnCtx(e),r=this._def.values;return g(n,{expected:E.joinValues(r),received:n.parsedType,code:f.invalid_type}),k}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let n=this._getOrReturnCtx(e),r=this._def.values;return g(n,{received:n.data,code:f.invalid_enum_value,options:r}),k}return $(e.data)}get options(){return this._def.values}get enum(){let e={};for(let n of this._def.values)e[n]=n;return e}get Values(){let e={};for(let n of this._def.values)e[n]=n;return e}get Enum(){let e={};for(let n of this._def.values)e[n]=n;return e}extract(e,n=this._def){return t.create(e,{...this._def,...n})}exclude(e,n=this._def){return t.create(this.options.filter(r=>!e.includes(r)),{...this._def,...n})}};Se.create=tn;var Ae=class extends R{_parse(e){let n=E.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==y.string&&r.parsedType!==y.number){let o=E.objectValues(n);return g(r,{expected:E.joinValues(o),received:r.parsedType,code:f.invalid_type}),k}if(this._cache||(this._cache=new Set(E.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let o=E.objectValues(n);return g(r,{received:r.data,code:f.invalid_enum_value,options:o}),k}return $(e.data)}get enum(){return this._def.values}};Ae.create=(t,e)=>new Ae({values:t,typeName:T.ZodNativeEnum,...I(e)});var de=class extends R{unwrap(){return this._def.type}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==y.promise&&n.common.async===false)return g(n,{code:f.invalid_type,expected:y.promise,received:n.parsedType}),k;let r=n.parsedType===y.promise?n.data:Promise.resolve(n.data);return $(r.then(o=>this._def.type.parseAsync(o,{path:n.path,errorMap:n.common.contextualErrorMap})))}};de.create=(t,e)=>new de({type:t,typeName:T.ZodPromise,...I(e)});var Z=class extends R{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===T.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:n,ctx:r}=this._processInputParams(e),o=this._def.effect||null,s={addIssue:i=>{g(r,i),i.fatal?n.abort():n.dirty();},get path(){return r.path}};if(s.addIssue=s.addIssue.bind(s),o.type==="preprocess"){let i=o.transform(r.data,s);if(r.common.async)return Promise.resolve(i).then(async a=>{if(n.value==="aborted")return k;let d=await this._def.schema._parseAsync({data:a,path:r.path,parent:r});return d.status==="aborted"?k:d.status==="dirty"?me(d.value):n.value==="dirty"?me(d.value):d});{if(n.value==="aborted")return k;let a=this._def.schema._parseSync({data:i,path:r.path,parent:r});return a.status==="aborted"?k:a.status==="dirty"?me(a.value):n.value==="dirty"?me(a.value):a}}if(o.type==="refinement"){let i=a=>{let d=o.refinement(a,s);if(r.common.async)return Promise.resolve(d);if(d instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(r.common.async===false){let a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?k:(a.status==="dirty"&&n.dirty(),i(a.value),{status:n.value,value:a.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>a.status==="aborted"?k:(a.status==="dirty"&&n.dirty(),i(a.value).then(()=>({status:n.value,value:a.value}))))}if(o.type==="transform")if(r.common.async===false){let i=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!ae(i))return k;let a=o.transform(i.value,s);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return {status:n.value,value:a}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(i=>ae(i)?Promise.resolve(o.transform(i.value,s)).then(a=>({status:n.value,value:a})):k);E.assertNever(o);}};Z.create=(t,e,n)=>new Z({schema:t,typeName:T.ZodEffects,effect:e,...I(n)});Z.createWithPreprocess=(t,e,n)=>new Z({schema:e,effect:{type:"preprocess",transform:t},typeName:T.ZodEffects,...I(n)});var F=class extends R{_parse(e){return this._getType(e)===y.undefined?$(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};F.create=(t,e)=>new F({innerType:t,typeName:T.ZodOptional,...I(e)});var Q=class extends R{_parse(e){return this._getType(e)===y.null?$(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Q.create=(t,e)=>new Q({innerType:t,typeName:T.ZodNullable,...I(e)});var Ie=class extends R{_parse(e){let{ctx:n}=this._processInputParams(e),r=n.data;return n.parsedType===y.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}};Ie.create=(t,e)=>new Ie({innerType:t,typeName:T.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...I(e)});var Re=class extends R{_parse(e){let{ctx:n}=this._processInputParams(e),r={...n,common:{...n.common,issues:[]}},o=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return Pe(o)?o.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new W(r.common.issues)},input:r.data})})):{status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new W(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}};Re.create=(t,e)=>new Re({innerType:t,typeName:T.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...I(e)});var We=class extends R{_parse(e){if(this._getType(e)!==y.nan){let r=this._getOrReturnCtx(e);return g(r,{code:f.invalid_type,expected:y.nan,received:r.parsedType}),k}return {status:"valid",value:e.data}}};We.create=t=>new We({typeName:T.ZodNaN,...I(t)});var Fr=Symbol("zod_brand"),Fe=class extends R{_parse(e){let{ctx:n}=this._processInputParams(e),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}},Ke=class t extends R{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.common.async)return (async()=>{let s=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?k:s.status==="dirty"?(n.dirty(),me(s.value)):this._def.out._parseAsync({data:s.value,path:r.path,parent:r})})();{let o=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return o.status==="aborted"?k:o.status==="dirty"?(n.dirty(),{status:"dirty",value:o.value}):this._def.out._parseSync({data:o.value,path:r.path,parent:r})}}static create(e,n){return new t({in:e,out:n,typeName:T.ZodPipeline})}},Ee=class extends R{_parse(e){let n=this._def.innerType._parse(e),r=o=>(ae(o)&&(o.value=Object.freeze(o.value)),o);return Pe(n)?n.then(o=>r(o)):r(n)}unwrap(){return this._def.innerType}};Ee.create=(t,e)=>new Ee({innerType:t,typeName:T.ZodReadonly,...I(e)});function Yt(t,e){let n=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof n=="string"?{message:n}:n}function nn(t,e={},n){return t?le.create().superRefine((r,o)=>{let s=t(r);if(s instanceof Promise)return s.then(i=>{if(!i){let a=Yt(e,r),d=a.fatal??n??true;o.addIssue({code:"custom",...a,fatal:d});}});if(!s){let i=Yt(e,r),a=i.fatal??n??true;o.addIssue({code:"custom",...i,fatal:a});}}):le.create()}var Kr={object:B.lazycreate},T;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly";})(T||(T={}));var Zr=(t,e={message:`Input not instance of ${t.name}`})=>nn(n=>n instanceof t,e),rn=ce.create,on=ge.create,Hr=We.create,Jr=ye.create,sn=he.create,qr=ve.create,Yr=je.create,Xr=xe.create,Qr=be.create,eo=le.create,to=oe.create,no=J.create,ro=Ne.create,oo=se.create,so=B.create,io=B.strictCreate,ao=we.create,co=nt.create,lo=ke.create,uo=X.create,po=rt.create,fo=$e.create,mo=Le.create,go=ot.create,yo=_e.create,ho=Te.create,vo=Se.create,xo=Ae.create,bo=de.create,wo=Z.create,ko=F.create,_o=Q.create,To=Z.createWithPreprocess,So=Ke.create,Ao=()=>rn().optional(),Io=()=>on().optional(),Ro=()=>sn().optional(),Eo={string:(t=>ce.create({...t,coerce:true})),number:(t=>ge.create({...t,coerce:true})),boolean:(t=>he.create({...t,coerce:true})),bigint:(t=>ye.create({...t,coerce:true})),date:(t=>ve.create({...t,coerce:true}))};var Co=k;var Be="agtx_pk_",st="agtx_sk_";l.string().min(Be.length+8).startsWith(Be,{message:`Publishable keys must start with "${Be}".`});l.string().min(st.length+8).startsWith(st,{message:`Secret keys must start with "${st}".`});var an=t=>t.startsWith(Be)?"publishable":t.startsWith(st)?"secret":"unknown",Ve=l.enum(["webmcp","dom","screenshot","crawler"]),ht=l.enum(["detected","declared","verified","linked"]),Mo=l.object({class:Ve,trust:ht,confidence:l.number().min(0).max(1).default(1),vendor:l.string().nullable(),userAgent:l.string().nullable(),detectionVersion:l.string().default("2026.04"),signals:l.record(l.unknown()).default({})}),Oo=l.enum(["bearer","oauth2","sso","spiffe","google-agent","mtls","detection","declaration","extension","session-link","x-agent-header","web-bot-auth","api-key","verified-crawler"]),Ze=l.object({class:Ve,vendor:l.string().min(1),token:l.string().min(8),expiresAt:l.string().datetime().optional()});l.object({publishableKey:l.string(),claim:Ze,nonce:l.string().min(8),origin:l.string().url()});l.object({trust:ht,vendor:l.string(),validUntil:l.string().datetime(),reason:l.string().optional(),subject:l.string().optional(),protocol:Oo.optional(),signals:l.record(l.unknown()).optional()});l.object({issuer:l.string().url(),audiences:l.array(l.string().min(1)).min(1)});l.object({trustDomain:l.string().min(1),bundleEndpoint:l.string().url(),audiences:l.array(l.string().min(1)).min(1),googleTrustDomains:l.array(l.string().min(1)).optional()});l.object({rootCerts:l.array(l.string().min(20)).min(1),spiffeTrustDomain:l.string().min(1).optional(),xfccEntryPolicy:l.enum(["last","first","only"]).default("last")});l.enum(["sso","spiffe","mtls"]);l.object({siteId:l.string().min(1),token:l.string().min(8).optional(),xfcc:l.string().min(1).optional(),headers:l.record(l.string()).optional(),origin:l.string().url().optional()});var q={detected:0,declared:1,verified:2,linked:3},cn=(t,e)=>q[t]>q[e],ln=l.enum(["allow","deny","review"]),Ce=l.object({id:l.string(),tool:l.string(),minTrust:ht,allowedClasses:l.array(Ve).default([]),decision:ln,rateLimit:l.object({max:l.number().int().positive(),windowSeconds:l.number().int().positive()}).optional()}),Po=l.object({decision:ln,ruleId:l.string().nullable(),reason:l.string()}),Do=l.enum(["session","user","org"]),vt=l.object({key:l.string().min(1),value:l.unknown(),scope:Do.default("session"),ttlSeconds:l.number().int().positive().nullable().default(null),updatedAt:l.string().datetime().optional()}),jo=l.object({path:l.string().min(1),name:l.string().optional(),purpose:l.string().optional(),availableActions:l.array(l.string()).optional(),prerequisites:l.array(l.string()).optional(),queryParams:l.record(l.string()).optional(),notes:l.string().optional()}),No=l.object({pattern:l.string().optional(),flow:l.string().optional()}),$o=l.object({pages:l.array(jo).default([]),navigation:No.optional()}),Lo=l.object({step:l.number().int().positive(),action:l.string().min(1)}),Wo=l.object({steps:l.array(Lo).default([]),notes:l.string().optional(),policy:l.string().optional()}),Bo=l.object({selector:l.string().min(1),behavior:l.string().optional(),location:l.string().optional(),showsCount:l.boolean().optional()}),Vo=l.object({categories:l.array(l.string()).optional(),productSchema:l.object({fields:l.array(l.string()).optional(),idFormat:l.string().optional()}).optional(),searchBehavior:l.string().optional()}),xt=l.object({path:l.string().min(1),payload:l.record(l.unknown()).default({}),updatedAt:l.string().datetime().optional()}).strict(),V=l.object({version:l.string().default("1"),siteMap:$o.optional(),workflows:l.record(Wo).default({}),policies:l.record(l.union([l.string(),l.array(l.string())])).default({}),catalog:Vo.optional(),uiGuidance:l.record(Bo).default({}),pageContexts:l.record(xt).default({}),updatedAt:l.string().datetime().optional()}),dn=V.parse({}),Uo=l.object({name:l.string().min(1),title:l.string().optional(),group:l.string().optional(),page:l.string().optional(),description:l.string().default(""),inputSchema:l.record(l.unknown()).default({}),outputSchema:l.record(l.unknown()).optional(),annotations:l.record(l.boolean()).optional(),tokens:l.number().int().nonnegative().default(0)}),zo=l.object({tools:l.array(Uo).default([])});zo.parse({});var Go=l.enum(["agent.detected","agent.missed","auth.identity_presented","auth.identity_cleared","authz.policies_set","authz.evaluated","memory.accessed","memory.updated","tool.registered","tool.executed","tool.surfaced","tool.progressed","sdk.error"]),bt=l.object({id:l.string(),siteId:l.string(),sessionId:l.string(),occurredAt:l.string().datetime(),type:Go,tool:l.string().optional(),agent:Mo.nullable().optional(),policy:Po.optional(),durationMs:l.number().int().nonnegative().optional(),outcome:l.enum(["success","error","blocked"]),error:l.string().optional(),metadata:l.record(l.unknown()).default({})});l.object({publishableKey:l.string().optional(),events:l.array(bt).min(1).max(100)});var He=class extends Error{code;constructor(t,e){super(e),this.name="AgentronicsError",this.code=t;}};var M="0.1.2";var wt=(t,e)=>typeof t=="object"&&t!==null&&typeof t[e]=="function",it=t=>{let e=t??(typeof globalThis>"u"?null:globalThis);if(!e)return null;let n=e.document?.modelContext;if(wt(n,"registerTool"))return {source:"document",context:n};let r=e.navigator?.modelContext;return wt(r,"registerTool")?{source:"navigator",context:r}:wt(r,"provideContext")?{source:"legacy",context:r}:null},kt=null,_t=new Set,Tt=(t,e)=>{kt={type:t,toolName:e,at:Date.now()},_t.forEach(n=>n(kt));},un=()=>kt,pn=t=>(_t.add(t),()=>{_t.delete(t);});var Fo=()=>{if(typeof navigator>"u")return null;let t=navigator.modelContext;return !t||typeof t!="object"?null:t.vendor||t.client?t:null},Ko=()=>it()?.source??null,Je=async(t={})=>{let{pollMs:e=500}=t,n=Date.now();for(;;){let r=un();if(r)return Zo(r);let o=Fo();if(o)return Ho(o);if(Date.now()-n>=e)return null;await new Promise(s=>setTimeout(s,50));}},fn=()=>({class:"webmcp",trust:"detected",confidence:1,userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:M}),Zo=t=>({...fn(),vendor:null,signals:{webmcp:true,source:Ko(),event:t.type,tool:t.toolName}}),Ho=t=>({...fn(),vendor:t.vendor??t.client??null,signals:{webmcp:true,source:"legacy-extension",toolCount:Array.isArray(t.tools)?t.tools.length:0}});var mn=[{name:"GPTBot",category:"ai",pattern:/GPTBot/i},{name:"OAI-SearchBot",category:"ai",pattern:/OAI-SearchBot/i},{name:"ChatGPT-User",category:"ai",pattern:/ChatGPT-User/i},{name:"Claude-User",category:"ai",pattern:/Claude-User/i},{name:"Claude-SearchBot",category:"ai",pattern:/Claude-SearchBot/i},{name:"ClaudeBot",category:"ai",pattern:/ClaudeBot/i},{name:"Claude-Web",category:"ai",pattern:/Claude-Web/i},{name:"anthropic-ai",category:"ai",pattern:/anthropic-ai/i},{name:"Perplexity-User",category:"ai",pattern:/Perplexity-User/i},{name:"PerplexityBot",category:"ai",pattern:/PerplexityBot/i},{name:"Google-Extended",category:"ai",pattern:/Google-Extended/i},{name:"Applebot-Extended",category:"ai",pattern:/Applebot-Extended/i},{name:"Amazonbot",category:"ai",pattern:/Amazonbot/i},{name:"Bytespider",category:"ai",pattern:/Bytespider/i},{name:"CCBot",category:"ai",pattern:/CCBot/i},{name:"Meta-ExternalAgent",category:"ai",pattern:/Meta-ExternalAgent/i},{name:"cohere-ai",category:"ai",pattern:/cohere-ai/i},{name:"Googlebot",category:"search",pattern:/Googlebot/i},{name:"Bingbot",category:"search",pattern:/bingbot/i},{name:"DuckDuckBot",category:"search",pattern:/DuckDuckBot/i},{name:"YandexBot",category:"search",pattern:/YandexBot/i},{name:"Baiduspider",category:"search",pattern:/Baiduspider/i},{name:"Applebot",category:"search",pattern:/Applebot/i}],qe=(t={})=>{let{signatures:e=mn,disable:n=false,confidence:r=.9}=t;if(n||typeof navigator>"u")return null;let o=navigator.userAgent??"";if(!o)return null;for(let s of e)if(s.pattern.test(o))return {class:"crawler",trust:"detected",confidence:r,vendor:s.name,userAgent:o,detectionVersion:M,signals:{matched:s.name,category:s.category,ua:o}};return null};var Jo=[/HeadlessChrome/i,/Headless/i,/PhantomJS/i,/SlimerJS/i],qo=()=>({hit:(typeof navigator<"u"&&navigator.webdriver)===true,weight:.6,detail:"navigator.webdriver === true"}),Yo=()=>{if(typeof window>"u")return {hit:false,weight:.5};let t=Object.keys(window).filter(e=>e.startsWith("cdc_"));return {hit:t.length>0,weight:.5,detail:`window.${t[0]??"cdc_*"}`}},Xo=["__playwright__binding__","__pwInitScripts","__puppeteer_evaluation_script__","_phantom","callPhantom","__nightmare","domAutomation","domAutomationController","__selenium_unwrapped","__webdriver_evaluate","__driver_evaluate","__fxdriver_unwrapped"],Qo=()=>{if(typeof window>"u")return {hit:false,weight:.6};let t=Xo.find(e=>e in window);return t?{hit:true,weight:.6,detail:`window.${t}`}:{hit:false,weight:.6}},es=()=>{if(typeof navigator>"u"||!navigator.plugins)return {hit:false,weight:.2};let t=/Win|Mac|Linux/.test(navigator.userAgent??""),e=navigator.plugins.length===0;return {hit:t&&e,weight:.2,detail:"desktop UA with no plugins"}},ts=()=>{if(typeof navigator>"u")return {hit:false,weight:.7};let t=navigator.userAgent??"",e=Jo.some(n=>n.test(t));return e?{hit:e,weight:.7,detail:`headless UA: ${t}`}:{hit:e,weight:.7}},ns=()=>{if(typeof navigator>"u")return {hit:false,weight:.15};let t=navigator.languages;return {hit:!t||t.length===0,weight:.15,detail:"navigator.languages empty"}},rs=()=>{if(typeof navigator>"u")return {hit:false,weight:.1};let t="chrome"in window,e=navigator.userAgent??"";return {hit:/Chrome\//.test(e)&&!/Edg\//.test(e)&&!t,weight:.2,detail:"Chrome UA without window.chrome"}},os={webdriver:qo,chromedriver:Yo,automationGlobals:Qo,headlessUa:ts,languages:ns,permissions:rs,plugins:es},Ye=(t={})=>{let{threshold:e=.4}=t,n={},r=0,o=0;for(let[i,a]of Object.entries(os)){let d=a();r+=d.weight,n[i]={hit:d.hit,weight:d.weight,detail:d.detail},d.hit&&(o+=d.weight);}let s=r===0?0:o/r;return s<e?null:{class:"dom",trust:"detected",confidence:s,vendor:null,userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:M,signals:n}};var gn=()=>[{id:"webmcp.model-context",status:"stable",detect:()=>Je({pollMs:0})},{id:"crawler.user-agent",status:"beta",detect:()=>qe()},{id:"dom.automation-heuristics",status:"beta",detect:()=>Ye()}],St=(t=gn())=>{let e=new Map(t.map(n=>[n.id,n]));return {register(n){e.set(n.id,n);},list(n){let r=[...e.values()];return n?r.filter(o=>o.status===n):r},async detectAll(n=false){for(let r of e.values()){if(r.status==="research"&&!n)continue;let o=await r.detect();if(o)return o}return null}}};var yn=async(t={})=>{if(t.customDetectors?.length){let e=await St(t.customDetectors).detectAll(!!t.experimental);if(e)return e}if(t.webmcp!==false){let e=await Je(t.webmcp??{});if(e)return e}if(t.crawler!==false){let e=qe(t.crawler??{});if(e)return e}if(t.dom!==false){let e=Ye(t.dom??{});if(e)return e}return null};var ss=new Set(["1024x768","1280x800","1280x720","1280x1024","1440x900","1920x1080"]),is=t=>{if(t.length<6)return null;let e=t.reduce((r,o)=>r+o,0)/t.length;if(e<=0)return null;let n=t.reduce((r,o)=>r+(o-e)**2,0)/t.length;return Math.sqrt(n)/e},hn=t=>{let e=0;return t.clicks>=2&&(e+=.35*(t.teleportClicks/t.clicks),e+=.25*(t.centreClicks/t.clicks),t.pointerMoves===0&&(e+=.15)),t.keyIntervalCv!==null&&t.keyIntervalCv<.15&&(e+=.2),t.insertWithoutKeys>0&&(e+=.15),t.wheelEvents===0&&t.clicks>=3&&(e+=.05),t.vmViewport&&(e+=.1),Math.min(1,e)},vn=(t={})=>{let{threshold:e=.6,minInteractions:n=3,onDetect:r,acceptUntrustedEvents:o=false}=t,s=C=>C.isTrusted||o,i=t.documentRef??(typeof document>"u"?void 0:document),a={clicks:0,teleportClicks:0,centreClicks:0,keyIntervals:0,keyIntervalCv:null,insertWithoutKeys:0,pointerMoves:0,wheelEvents:0,vmViewport:false},d=Number.NEGATIVE_INFINITY,c=0,p=0,h=[],v=0,_=null,x=i?.defaultView;x&&(a.vmViewport=ss.has(`${x.innerWidth}x${x.innerHeight}`));let m=C=>({class:"screenshot",trust:"detected",confidence:Number(C.toFixed(2)),vendor:null,userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:M,signals:{vision:true,...a}}),A=()=>{if(_||a.clicks+v<n)return;let C=hn(a);C>=e&&(_=m(C),r?.(_));},S=C=>{s(C)&&(a.pointerMoves+=1,d=C.timeStamp);},Qe=[["pointermove",S],["mousemove",S],["wheel",C=>{s(C)&&(a.wheelEvents+=1);}],["click",C=>{if(!s(C))return;let P=C;a.clicks+=1,C.timeStamp-d>400&&(a.teleportClicks+=1);let Ue=P.target instanceof Element?P.target:null;if(Ue&&typeof Ue.getBoundingClientRect=="function"){let ee=Ue.getBoundingClientRect();if(ee.width>8&&ee.height>8){let te=Math.abs(P.clientX-(ee.left+ee.width/2)),ie=Math.abs(P.clientY-(ee.top+ee.height/2));te<=1.5&&ie<=1.5&&(a.centreClicks+=1);}}A();}],["keydown",C=>{if(!s(C))return;let P=C.timeStamp;c&&P-c<1500?(h.push(P-c),h.length>60&&h.shift(),a.keyIntervals=h.length,a.keyIntervalCv=is(h)):v+=1,c=P,p=P;}],["keyup",()=>A()],["input",C=>{if(!s(C))return;let P=C;P.inputType==="insertText"&&P.data&&P.data.length>1&&C.timeStamp-p>200&&(a.insertWithoutKeys+=1,v+=1,A());}]];for(let[C,P]of Qe)i?.addEventListener(C,P,{capture:true,passive:true});return {signals:()=>({...a}),score:()=>hn(a),detected:()=>_,stop:()=>{for(let[C,P]of Qe)i?.removeEventListener(C,P,{capture:true});}}};var as=t=>({class:t.class,trust:"declared",confidence:1,vendor:t.vendor,userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:M,signals:{declared:true,hasToken:true,tokenExpiresAt:t.expiresAt??null}}),xn=()=>{let t=null;return {present(e){let n=Ze.safeParse(e);if(!n.success)throw new He("invalid_api_key",`Invalid identity claim: ${n.error.issues[0]?.message??"unknown"}`);let r={claim:n.data,identity:as(n.data)};return t=r,r},clear(){t=null;},preferOver(e){return t?e?cn(t.identity.trust,e.trust)?t.identity:e:t.identity:e},snapshot(){return t}}};var bn=t=>{let e=null;for(let n of t)(!e||q[n.trust]>q[e.trust])&&(e=n);return e};var wn=()=>({name:"bearer",async authenticate(t,e){if(!t.bearerToken)return null;let n=await e.verifyToken?.("bearer",t.bearerToken);return {class:t.classHint??"dom",trust:n?.trust??"declared",confidence:1,vendor:n?.vendor??t.vendorHint??"bearer",userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:M,signals:{bearer:true,verifiedRemotely:!!n}}}});var kn=()=>({name:"detection",async authenticate(t){return t.detected??null}});var _n=()=>({name:"extensionToken",async authenticate(t,e){if(!t.extensionToken)return null;let n=await e.verifyToken?.("extensionToken",t.extensionToken);return {class:"dom",trust:n?.trust??"declared",confidence:1,vendor:n?.vendor??t.vendorHint??"browser-extension",userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:M,signals:{extensionToken:true,verifiedRemotely:!!n}}}});var Tn=()=>({name:"mtls",async authenticate(t,e){if(!t.xfccHeader)return null;let n=await e.verifyToken?.("mtls",t.xfccHeader);return {class:t.classHint??"webmcp",trust:n?.trust??"declared",confidence:1,vendor:n?.vendor??t.vendorHint??"mtls",userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:M,signals:{mtls:true,subject:n?.subject??null,verifiedRemotely:!!n,...n?.signals??{}}}}});var Sn=()=>({name:"oauth2",async authenticate(t,e){if(!t.oauth2AccessToken)return null;let n=await e.verifyToken?.("oauth2",t.oauth2AccessToken);return {class:t.classHint??"webmcp",trust:n?t.oauth2Subject&&n.trust!=="detected"&&n.trust!=="declared"?"linked":n.trust:"declared",confidence:1,vendor:n?.vendor??t.vendorHint??"oauth2",userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:M,signals:{oauth2:true,subject:t.oauth2Subject??null,verifiedRemotely:!!n}}}});var cs=t=>({class:t.class,trust:"declared",confidence:1,vendor:t.vendor,userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:M,signals:{declared:true,hasToken:true,tokenExpiresAt:t.expiresAt??null}}),An=()=>({name:"selfDeclaration",async authenticate(t){return t.declaration?cs(Ze.parse(t.declaration)):null}});var In=()=>({name:"sessionLink",async authenticate(t,e){if(!t.sessionLinkToken)return null;let n=await e.verifyToken?.("sessionLink",t.sessionLinkToken);return {class:t.classHint??"screenshot",trust:n?t.linkedUserId&&n.trust!=="detected"&&n.trust!=="declared"?"linked":n.trust:"declared",confidence:1,vendor:n?.vendor??t.vendorHint??"session-link",userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:M,signals:{sessionLink:true,linkedUserId:t.linkedUserId??null,verifiedRemotely:!!n}}}});var Rn=()=>({name:"sso",async authenticate(t,e){if(!t.ssoIdToken)return null;let n=await e.verifyToken?.("sso",t.ssoIdToken);return {class:t.classHint??"dom",trust:n?.trust??"declared",confidence:1,vendor:n?.vendor??t.vendorHint??"sso",userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:M,signals:{sso:true,subject:n?.subject??null,verifiedRemotely:!!n,...n?.signals??{}}}}});var En=()=>({name:"spiffe",async authenticate(t,e){if(!t.spiffeJwt)return null;let n=await e.verifyToken?.("spiffe",t.spiffeJwt),r=n?.vendor==="google";return {class:t.classHint??"webmcp",trust:n?.trust??"declared",confidence:1,vendor:n?.vendor??t.vendorHint??"spiffe",userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:M,signals:{spiffe:true,spiffeId:n?.subject??null,subject:n?.subject??null,verifiedRemotely:!!n,...r?{googleAgent:true}:{},...n?.signals??{}}}}});var Cn=()=>({name:"xAgentHeader",async authenticate(t){if(!t.xAgentHeader)return null;let[e="x-agent",n="dom",r]=t.xAgentHeader.split(";"),o=Ve.safeParse(n);return {class:o.success?o.data:"dom",trust:"declared",confidence:r?1:.8,vendor:e,userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:M,signals:{xAgentHeader:true,hasProof:!!r}}}});var On=new Set(["bearer","extensionToken","sessionLink","oauth2","sso","spiffe","mtls"]),ls=(t,e,n)=>{if(On.has(t)&&e.signals?.verifiedRemotely===false){let r=t==="oauth2"&&n.oauth2Subject||t==="sessionLink"&&n.linkedUserId;return {...e,trust:r?"linked":"verified",signals:{...e.signals,compat:"0.6"}}}return t==="xAgentHeader"&&e.signals?.hasProof===true?{...e,trust:"verified",confidence:1,signals:{...e.signals,compat:"0.6"}}:e},Mn=()=>[kn(),An(),wn(),Cn(),_n(),In(),Sn()],ds=()=>[Rn(),En(),Tn()],us={detection:"detection",selfDeclaration:"declaration",bearer:"bearer",xAgentHeader:"x-agent-header",extensionToken:"extension",sessionLink:"session-link",oauth2:"oauth2",sso:"sso",spiffe:"spiffe",mtls:"mtls"},ps=(t,e)=>t==="spiffe"&&e.signals?.googleAgent===true?"google-agent":us[t],Pn=({compat:t,methods:e=t==="0.6"?[...Mn(),...ds()]:Mn(),context:n={},onTrace:r,onUnverifiedToken:o}={})=>{let s=false;return {async authenticate(i){let a=[],d={};for(let x of e){let m=await x.authenticate(i,n);d[x.name]=!!m,m&&(On.has(x.name)&&m.signals?.verifiedRemotely===false&&!n.verifyToken&&!s&&(s=true,o?.(x.name)),t==="0.6"&&(m=ls(x.name,m,i)),a.push({method:x.name,identity:m}));}let c=bn(a.map(x=>x.identity)),p=c?a.find(x=>x.identity===c):void 0,h=p?ps(p.method,p.identity):void 0,v=typeof c?.signals?.subject=="string"?c.signals.subject:void 0,_={type:c?"auth.identity_presented":"sdk.error",agent:c,outcome:c?"success":"error",metadata:{methods:d,...h?{protocol:h}:{},...v?{subject:v}:{}}};return c||(_.error="No auth method produced an identity."),r?.(_),c},methods(){return e.map(i=>i.name)}}};var fs={identity:null,source:"initial",updatedAt:null},Dn=()=>{let t=fs,e=new Set,n=()=>{e.size!==0&&e.forEach(r=>r(t));};return {snapshot(){return t},set(r,o){t={identity:r,source:o,updatedAt:new Date().toISOString()},n();},subscribe(r){return e.add(r),()=>{e.delete(r);}}}};var ms=()=>{let t=new Map;return {read:e=>t.get(e)??null,write:(e,n)=>{t.set(e,n);}}},gs=()=>typeof window>"u"||!window.localStorage?ms():{read:t=>{try{return window.localStorage.getItem(t)}catch{return null}},write:(t,e)=>{try{window.localStorage.setItem(t,e);}catch{}}},ys=t=>{if(!t)return null;try{let e=JSON.parse(t);if(typeof e=="object"&&e!==null&&Number.isFinite(e.count)&&Number.isFinite(e.resetAt))return e}catch{return null}return null},jn=(t=gs())=>({consume(e,n,r=Date.now()){let o=`agtx:rate:${e}`,s=ys(t.read(o)),i=s&&s.resetAt>r?s.resetAt:r+n.windowSeconds*1e3,a=s&&s.resetAt>r?s.count+1:1;return t.write(o,JSON.stringify({count:a,resetAt:i})),{allowed:a<=n.max,remaining:Math.max(0,n.max-a),resetAt:i}}});var hs=(t,e)=>t==="*"||t===e?true:t.includes("*")?new RegExp("^"+t.replace(/[.+?^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*")+"$").test(e):false,vs=(t,e)=>{let n=t?q[t.trust]:-1,r=q[e.minTrust];return n>=r},xs=(t,e)=>e.allowedClasses.length===0?true:t?e.allowedClasses.includes(t.class):false,Nn="allow",bs=(t,e)=>{let n=e?.class??"unknown",r=e?.vendor??"unknown",o=e?.trust??"none";return `${t}:${n}:${r}:${o}`},$n=(t=[],e={})=>{let n=t.map(o=>Ce.parse(o)),r=e.rateLimiter??jn();return {set(o){n=o.map(s=>Ce.parse(s));},list(){return [...n]},evaluate({tool:o,identity:s}){for(let i of n)if(hs(i.tool,o)){if(!vs(s,i))return {decision:"deny",ruleId:i.id,reason:`Rule "${i.id}" requires trust >= ${i.minTrust}.`};if(!xs(s,i))return {decision:"deny",ruleId:i.id,reason:`Rule "${i.id}" restricts to classes: ${i.allowedClasses.join(", ")}.`};if(i.rateLimit){let a=r.consume(bs(o,s),i.rateLimit);if(!a.allowed)return {decision:"deny",ruleId:i.id,reason:`Rule "${i.id}" rate limit exceeded. Resets at ${new Date(a.resetAt).toISOString()}.`}}return {decision:i.decision,ruleId:i.id,reason:`Matched rule "${i.id}".`}}return {decision:Nn,ruleId:null,reason:`No rule matched tool "${o}". Falling back to "${Nn}".`}}}};var Ln=({gatewayUrl:t,siteId:e,publishableKey:n,fetcher:r=fetch})=>{let o={policies:[],etag:null};return {snapshot(){return {policies:[...o.policies],etag:o.etag}},async sync(){let s=await r(`${t.replace(/\/$/,"")}/v1/pub/sites/${encodeURIComponent(e)}/policies`,{headers:{authorization:`Bearer ${n}`,...o.etag?{"if-none-match":o.etag}:{}}});if(s.status===304)return this.snapshot();if(!s.ok)throw new Error(`Policy sync failed with status ${s.status}.`);let i=await s.json();return o={policies:Ce.array().parse(i.policies??[]),etag:s.headers.get("etag")},this.snapshot()}}};var Wn=({message:t="Agent action blocked by site policy.",durationMs:e=2400,documentRef:n=typeof document>"u"?void 0:document}={})=>{if(!n?.body)return null;let r=n.createElement("div");return r.setAttribute("role","status"),r.setAttribute("data-agentronics-deny-overlay","true"),r.textContent=t,Object.assign(r.style,{position:"fixed",zIndex:"2147483647",left:"50%",bottom:"24px",transform:"translateX(-50%)",maxWidth:"min(520px, calc(100vw - 32px))",padding:"12px 16px",borderRadius:"12px",background:"#0B0B0C",color:"#FFFFFF",border:"2px solid #FF4D1F",font:"13px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace"}),n.body.appendChild(r),window.setTimeout(()=>r.remove(),e),r};var Bn=({policyEngine:t,getIdentity:e,documentRef:n=typeof document>"u"?void 0:document,selector:r="[data-agentronics-tool]"})=>{if(!n)return {uninstall:()=>{}};let o=s=>{let i=s.target instanceof Element?s.target.closest(r):null;if(!(i instanceof HTMLElement))return;let a=i.dataset.agentronicsTool;a&&Promise.resolve(e()).then(d=>{let c=t.evaluate({tool:a,identity:d});c.decision==="deny"&&(s.preventDefault(),s.stopPropagation(),Wn({message:c.reason,documentRef:n}));});};return n.addEventListener("click",o,true),{uninstall:()=>n.removeEventListener("click",o,true)}};var At=()=>{let t=new Map;return {read:e=>t.get(e)??null,write:(e,n)=>{t.set(e,n);},remove:e=>{t.delete(e);},keys:()=>[...t.keys()]}},Vn=(t,e)=>({read:n=>{try{return t.getItem(e+n)}catch{return null}},write:(n,r)=>{try{t.setItem(e+n,r);}catch{}},remove:n=>{try{t.removeItem(e+n);}catch{}},keys:()=>{let n=[];try{for(let r=0;r<t.length;r++){let o=t.key(r);o&&o.startsWith(e)&&n.push(o.slice(e.length));}}catch{}return n}}),Un="agtx:",zn=()=>{let t=typeof window<"u",e=t&&typeof window.sessionStorage<"u"?Vn(window.sessionStorage,Un+"session:"):At(),n=t&&typeof window.localStorage<"u"?Vn(window.localStorage,Un+"user:"):At();return {session:e,user:n,org:At()}};var Gn=(t,e)=>t.expiresAt!==null&&t.expiresAt<=e,Fn=t=>{if(!t)return null;try{let e=JSON.parse(t);return typeof e!="object"||e===null?null:e}catch{return null}},ws=t=>JSON.stringify(t),Kn=(t={})=>{let e=zn(),n=d=>{t.onTrace?.(d);};return {get:(d,c={})=>{let p=c.scope??"session",h=e[p],v=Fn(h.read(d));if(!v){n({type:"memory.accessed",metadata:{operation:"get",key:d,scope:p,hit:false}});return}if(Gn(v,Date.now())){h.remove(d),n({type:"memory.accessed",metadata:{operation:"get",key:d,scope:p,hit:false,expired:true}});return}return n({type:"memory.accessed",metadata:{operation:"get",key:d,scope:p,hit:true}}),v.value},set:(d,c,p={})=>{let h=p.scope??"session",v=p.ttlSeconds??null,_=Date.now(),x={value:c,expiresAt:v===null?null:_+v*1e3,updatedAt:new Date(_).toISOString()};return e[h].write(d,ws(x)),n({type:"memory.updated",metadata:{operation:"set",key:d,scope:h,ttlSeconds:v}}),vt.parse({key:d,value:c,scope:h,ttlSeconds:v,updatedAt:x.updatedAt})},remove:(d,c={})=>{let p=c.scope??"session";e[p].remove(d),n({type:"memory.updated",metadata:{operation:"remove",key:d,scope:p}});},list:(d={})=>{let c=d.scope??"session",p=e[c],h=Date.now(),v=[];for(let _ of p.keys()){let x=Fn(p.read(_));if(x){if(Gn(x,h)){p.remove(_);continue}v.push(vt.parse({key:_,value:x.value,scope:c,ttlSeconds:x.expiresAt===null?null:Math.max(0,Math.round((x.expiresAt-h)/1e3)),updatedAt:x.updatedAt}));}}return n({type:"memory.accessed",metadata:{operation:"list",scope:c,count:v.length}}),v},clear:(d={})=>{let c=d.scope??"session",p=e[c],h=p.keys().length;for(let v of p.keys())p.remove(v);n({type:"memory.updated",metadata:{operation:"clear",scope:c,count:h}});}}};var It=t=>V.parse(JSON.parse(JSON.stringify(t))),at=t=>({...t,updatedAt:new Date().toISOString()}),Zn=(t={})=>{let e=V.parse({...dn,...t.initial??{}}),n=null,r=new Set,o=m=>{t.onTrace?.(m);},s=()=>{n=null;},i=()=>{if(r.size===0)return;let m=It(e);n=m,r.forEach(A=>A(m));},a=m=>{let A=V.parse({...e,...m,workflows:{...e.workflows,...m.workflows??{}},policies:{...e.policies,...m.policies??{}},uiGuidance:{...e.uiGuidance,...m.uiGuidance??{}},pageContexts:{...e.pageContexts,...m.pageContexts??{}}});return e=at(A),s(),o({type:"memory.updated",metadata:{kind:"site",operation:"provide",keys:Object.keys(m)}}),i(),p()},d=(m,A)=>{let S=m.split(".").filter(Boolean);if(S.length===0)throw new Error("siteMemory.update() requires a non-empty dot-path.");let D=JSON.parse(JSON.stringify(e)),U=D;for(let z=0;z<S.length-1;z++){let N=S[z],G=U[N];(typeof G!="object"||G===null||Array.isArray(G))&&(U[N]={}),U=U[N];}return U[S[S.length-1]]=A,e=at(V.parse(D)),s(),o({type:"memory.updated",metadata:{kind:"site",operation:"update",path:m}}),i(),p()},c=m=>{let A=xt.parse({path:m.path,payload:m.payload,updatedAt:new Date().toISOString()});return e=at({...e,pageContexts:{...e.pageContexts,[m.path]:A}}),s(),o({type:"memory.updated",metadata:{kind:"site",operation:"provideForPage",path:m.path}}),i(),{...A,payload:{...A.payload}}},p=()=>(n||(n=It(e)),n);return {provide:a,update:d,provideForPage:c,snapshot:p,get:m=>{if(o({type:"memory.accessed",metadata:{kind:"site",operation:m?"get":"snapshot",path:m??null}}),!m)return It(e);let A=m.split(".").filter(Boolean),S=e;for(let D of A){if(typeof S!="object"||S===null)return;S=S[D];}return S},getForPage:m=>{o({type:"memory.accessed",metadata:{kind:"site",operation:"getForPage",path:m}});let A=e.pageContexts[m];return A?{...A,payload:{...A.payload}}:null},replace:m=>(e=at(V.parse(m)),s(),i(),p()),subscribe:m=>(r.add(m),()=>{r.delete(m);})}};var Hn=({gatewayUrl:t,siteId:e,publishableKey:n,fetcher:r=fetch})=>{let o={memory:null,etag:null};return {snapshot(){return {memory:o.memory?V.parse(o.memory):null,etag:o.etag}},async sync(){let s=await r(`${t.replace(/\/$/,"")}/v1/pub/sites/${encodeURIComponent(e)}/memory`,{headers:{authorization:`Bearer ${n}`,...o.etag?{"if-none-match":o.etag}:{}}});if(s.status===304)return this.snapshot();if(!s.ok)throw new Error(`Memory sync failed with status ${s.status}.`);let i=await s.json();return o={memory:V.parse(i.memory??{}),etag:s.headers.get("etag")},this.snapshot()}}};var ue="agent-context-",Rt="agentronics-site-context",ks=t=>{try{return JSON.stringify(t)}catch{return "{}"}},ct=(t,e,n)=>{let r=t.querySelector(`meta[name="${e}"]`);r||(r=t.createElement("meta"),r.setAttribute("name",e),t.head.appendChild(r)),r.setAttribute("content",n);},lt=(t,e)=>{t.querySelectorAll(`meta[name="${e}"]`).forEach(n=>n.remove());},Et=({doc:t=typeof document>"u"?null:document,snapshot:e,schemaType:n="WebSite"})=>{if(!t)return {uninstall:()=>{}};ct(t,`${ue}version`,e.version),ct(t,`${ue}updated-at`,e.updatedAt??new Date().toISOString()),e.siteMap?.navigation?.flow&&ct(t,`${ue}flow`,e.siteMap.navigation.flow),ct(t,`${ue}workflows`,Object.keys(e.workflows).join(","));let r=t.getElementById(Rt);return r||(r=t.createElement("script"),r.type="application/ld+json",r.id=Rt,t.head.appendChild(r)),r.textContent=ks({"@context":"https://schema.org","@type":n,name:"Agentronics Site Memory",agentronics:e}),{uninstall:()=>{lt(t,`${ue}version`),lt(t,`${ue}updated-at`),lt(t,`${ue}flow`),lt(t,`${ue}workflows`),t.getElementById(Rt)?.remove();}}};var Jn="agentronics-memory-overlay",_s=t=>`
|
|
1
|
+
var Agentronics=(function(exports){'use strict';var br=Object.defineProperty;var wr=(t,e)=>{for(var n in e)br(t,n,{get:e[n],enumerable:true});};var l={};wr(l,{BRAND:()=>Zr,DIRTY:()=>me,EMPTY_PATH:()=>Sr,INVALID:()=>_,NEVER:()=>Oo,OK:()=>$,ParseStatus:()=>j,Schema:()=>R,ZodAny:()=>le,ZodArray:()=>se,ZodBigInt:()=>ye,ZodBoolean:()=>he,ZodBranded:()=>Fe,ZodCatch:()=>Re,ZodDate:()=>ve,ZodDefault:()=>Ie,ZodDiscriminatedUnion:()=>nt,ZodEffects:()=>Z,ZodEnum:()=>Se,ZodError:()=>B,ZodFirstPartyTypeKind:()=>S,ZodFunction:()=>ot,ZodIntersection:()=>ke,ZodIssueCode:()=>f,ZodLazy:()=>_e,ZodLiteral:()=>Te,ZodMap:()=>$e,ZodNaN:()=>We,ZodNativeEnum:()=>Ae,ZodNever:()=>J,ZodNull:()=>be,ZodNullable:()=>Q,ZodNumber:()=>ge,ZodObject:()=>V,ZodOptional:()=>F,ZodParsedType:()=>h,ZodPipeline:()=>Ke,ZodPromise:()=>ue,ZodReadonly:()=>Ee,ZodRecord:()=>rt,ZodSchema:()=>R,ZodSet:()=>Le,ZodString:()=>ce,ZodSymbol:()=>je,ZodTransformer:()=>Z,ZodTuple:()=>X,ZodType:()=>R,ZodUndefined:()=>xe,ZodUnion:()=>we,ZodUnknown:()=>oe,ZodVoid:()=>Ne,addIssueToContext:()=>g,any:()=>no,array:()=>io,bigint:()=>Yr,boolean:()=>an,coerce:()=>Mo,custom:()=>rn,date:()=>Xr,datetimeRegex:()=>tn,defaultErrorMap:()=>ne,discriminatedUnion:()=>uo,effect:()=>_o,enum:()=>bo,function:()=>ho,getErrorMap:()=>Oe,getParsedType:()=>Y,instanceof:()=>Jr,intersection:()=>po,isAborted:()=>et,isAsync:()=>Pe,isDirty:()=>tt,isValid:()=>ae,late:()=>Hr,lazy:()=>vo,literal:()=>xo,makeIssue:()=>Ge,map:()=>go,nan:()=>qr,nativeEnum:()=>wo,never:()=>oo,null:()=>to,nullable:()=>So,number:()=>sn,object:()=>ao,objectUtil:()=>mt,oboolean:()=>Co,onumber:()=>Eo,optional:()=>To,ostring:()=>Ro,pipeline:()=>Io,preprocess:()=>Ao,promise:()=>ko,quotelessJson:()=>kr,record:()=>mo,set:()=>yo,setErrorMap:()=>Tr,strictObject:()=>co,string:()=>on,symbol:()=>Qr,transformer:()=>_o,tuple:()=>fo,undefined:()=>eo,union:()=>lo,unknown:()=>ro,util:()=>E,void:()=>so});var E;(function(t){t.assertEqual=o=>{};function e(o){}t.assertIs=e;function n(o){throw new Error}t.assertNever=n,t.arrayToEnum=o=>{let s={};for(let i of o)s[i]=i;return s},t.getValidEnumValues=o=>{let s=t.objectKeys(o).filter(a=>typeof o[o[a]]!="number"),i={};for(let a of s)i[a]=o[a];return t.objectValues(i)},t.objectValues=o=>t.objectKeys(o).map(function(s){return o[s]}),t.objectKeys=typeof Object.keys=="function"?o=>Object.keys(o):o=>{let s=[];for(let i in o)Object.prototype.hasOwnProperty.call(o,i)&&s.push(i);return s},t.find=(o,s)=>{for(let i of o)if(s(i))return i},t.isInteger=typeof Number.isInteger=="function"?o=>Number.isInteger(o):o=>typeof o=="number"&&Number.isFinite(o)&&Math.floor(o)===o;function r(o,s=" | "){return o.map(i=>typeof i=="string"?`'${i}'`:i).join(s)}t.joinValues=r,t.jsonStringifyReplacer=(o,s)=>typeof s=="bigint"?s.toString():s;})(E||(E={}));var mt;(function(t){t.mergeShapes=(e,n)=>({...e,...n});})(mt||(mt={}));var h=E.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Y=t=>{switch(typeof t){case "undefined":return h.undefined;case "string":return h.string;case "number":return Number.isNaN(t)?h.nan:h.number;case "boolean":return h.boolean;case "function":return h.function;case "bigint":return h.bigint;case "symbol":return h.symbol;case "object":return Array.isArray(t)?h.array:t===null?h.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?h.promise:typeof Map<"u"&&t instanceof Map?h.map:typeof Set<"u"&&t instanceof Set?h.set:typeof Date<"u"&&t instanceof Date?h.date:h.object;default:return h.unknown}};var f=E.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),kr=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),B=class t extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r];},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r];};let n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=e;}format(e){let n=e||function(s){return s.message},r={_errors:[]},o=s=>{for(let i of s.issues)if(i.code==="invalid_union")i.unionErrors.map(o);else if(i.code==="invalid_return_type")o(i.returnTypeError);else if(i.code==="invalid_arguments")o(i.argumentsError);else if(i.path.length===0)r._errors.push(n(i));else {let a=r,u=0;for(;u<i.path.length;){let c=i.path[u];u===i.path.length-1?(a[c]=a[c]||{_errors:[]},a[c]._errors.push(n(i))):a[c]=a[c]||{_errors:[]},a=a[c],u++;}}};return o(this),r}static assert(e){if(!(e instanceof t))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,E.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=n=>n.message){let n={},r=[];for(let o of this.issues)if(o.path.length>0){let s=o.path[0];n[s]=n[s]||[],n[s].push(e(o));}else r.push(e(o));return {formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}};B.create=t=>new B(t);var _r=(t,e)=>{let n;switch(t.code){case f.invalid_type:t.received===h.undefined?n="Required":n=`Expected ${t.expected}, received ${t.received}`;break;case f.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(t.expected,E.jsonStringifyReplacer)}`;break;case f.unrecognized_keys:n=`Unrecognized key(s) in object: ${E.joinValues(t.keys,", ")}`;break;case f.invalid_union:n="Invalid input";break;case f.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${E.joinValues(t.options)}`;break;case f.invalid_enum_value:n=`Invalid enum value. Expected ${E.joinValues(t.options)}, received '${t.received}'`;break;case f.invalid_arguments:n="Invalid function arguments";break;case f.invalid_return_type:n="Invalid function return type";break;case f.invalid_date:n="Invalid date";break;case f.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(n=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?n=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?n=`Invalid input: must end with "${t.validation.endsWith}"`:E.assertNever(t.validation):t.validation!=="regex"?n=`Invalid ${t.validation}`:n="Invalid";break;case f.too_small:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:n="Invalid input";break;case f.too_big:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?n=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:n="Invalid input";break;case f.custom:n="Invalid input";break;case f.invalid_intersection_types:n="Intersection results could not be merged";break;case f.not_multiple_of:n=`Number must be a multiple of ${t.multipleOf}`;break;case f.not_finite:n="Number must be finite";break;default:n=e.defaultError,E.assertNever(t);}return {message:n}},ne=_r;var qt=ne;function Tr(t){qt=t;}function Oe(){return qt}var Ge=t=>{let{data:e,path:n,errorMaps:r,issueData:o}=t,s=[...n,...o.path||[]],i={...o,path:s};if(o.message!==void 0)return {...o,path:s,message:o.message};let a="",u=r.filter(c=>!!c).slice().reverse();for(let c of u)a=c(i,{data:e,defaultError:a}).message;return {...o,path:s,message:a}},Sr=[];function g(t,e){let n=Oe(),r=Ge({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n,n===ne?void 0:ne].filter(o=>!!o)});t.common.issues.push(r);}var j=class t{constructor(){this.value="valid";}dirty(){this.value==="valid"&&(this.value="dirty");}abort(){this.value!=="aborted"&&(this.value="aborted");}static mergeArray(e,n){let r=[];for(let o of n){if(o.status==="aborted")return _;o.status==="dirty"&&e.dirty(),r.push(o.value);}return {status:e.value,value:r}}static async mergeObjectAsync(e,n){let r=[];for(let o of n){let s=await o.key,i=await o.value;r.push({key:s,value:i});}return t.mergeObjectSync(e,r)}static mergeObjectSync(e,n){let r={};for(let o of n){let{key:s,value:i}=o;if(s.status==="aborted"||i.status==="aborted")return _;s.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),s.value!=="__proto__"&&(typeof i.value<"u"||o.alwaysSet)&&(r[s.value]=i.value);}return {status:e.value,value:r}}},_=Object.freeze({status:"aborted"}),me=t=>({status:"dirty",value:t}),$=t=>({status:"valid",value:t}),et=t=>t.status==="aborted",tt=t=>t.status==="dirty",ae=t=>t.status==="valid",Pe=t=>typeof Promise<"u"&&t instanceof Promise;var b;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message;})(b||(b={}));var K=class{constructor(e,n,r,o){this._cachedPath=[],this.parent=e,this.data=n,this._path=r,this._key=o;}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},Yt=(t,e)=>{if(ae(e))return {success:true,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return {success:false,get error(){if(this._error)return this._error;let n=new B(t.common.issues);return this._error=n,this._error}}};function I(t){if(!t)return {};let{errorMap:e,invalid_type_error:n,required_error:r,description:o}=t;if(e&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:o}:{errorMap:(i,a)=>{let{message:u}=t;return i.code==="invalid_enum_value"?{message:u??a.defaultError}:typeof a.data>"u"?{message:u??r??a.defaultError}:i.code!=="invalid_type"?{message:a.defaultError}:{message:u??n??a.defaultError}},description:o}}var R=class{get description(){return this._def.description}_getType(e){return Y(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:Y(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return {status:new j,ctx:{common:e.parent.common,data:e.data,parsedType:Y(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let n=this._parse(e);if(Pe(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(e){let n=this._parse(e);return Promise.resolve(n)}parse(e,n){let r=this.safeParse(e,n);if(r.success)return r.data;throw r.error}safeParse(e,n){let r={common:{issues:[],async:n?.async??false,contextualErrorMap:n?.errorMap},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Y(e)},o=this._parseSync({data:e,path:r.path,parent:r});return Yt(r,o)}"~validate"(e){let n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Y(e)};if(!this["~standard"].async)try{let r=this._parseSync({data:e,path:[],parent:n});return ae(r)?{value:r.value}:{issues:n.common.issues}}catch(r){r?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=true),n.common={issues:[],async:true};}return this._parseAsync({data:e,path:[],parent:n}).then(r=>ae(r)?{value:r.value}:{issues:n.common.issues})}async parseAsync(e,n){let r=await this.safeParseAsync(e,n);if(r.success)return r.data;throw r.error}async safeParseAsync(e,n){let r={common:{issues:[],contextualErrorMap:n?.errorMap,async:true},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Y(e)},o=this._parse({data:e,path:r.path,parent:r}),s=await(Pe(o)?o:Promise.resolve(o));return Yt(r,s)}refine(e,n){let r=o=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(o):n;return this._refinement((o,s)=>{let i=e(o),a=()=>s.addIssue({code:f.custom,...r(o)});return typeof Promise<"u"&&i instanceof Promise?i.then(u=>u?true:(a(),false)):i?true:(a(),false)})}refinement(e,n){return this._refinement((r,o)=>e(r)?true:(o.addIssue(typeof n=="function"?n(r,o):n),false))}_refinement(e){return new Z({schema:this,typeName:S.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:n=>this["~validate"](n)};}optional(){return F.create(this,this._def)}nullable(){return Q.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return se.create(this)}promise(){return ue.create(this,this._def)}or(e){return we.create([this,e],this._def)}and(e){return ke.create(this,e,this._def)}transform(e){return new Z({...I(this._def),schema:this,typeName:S.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let n=typeof e=="function"?e:()=>e;return new Ie({...I(this._def),innerType:this,defaultValue:n,typeName:S.ZodDefault})}brand(){return new Fe({typeName:S.ZodBranded,type:this,...I(this._def)})}catch(e){let n=typeof e=="function"?e:()=>e;return new Re({...I(this._def),innerType:this,catchValue:n,typeName:S.ZodCatch})}describe(e){let n=this.constructor;return new n({...this._def,description:e})}pipe(e){return Ke.create(this,e)}readonly(){return Ee.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Ar=/^c[^\s-]{8,}$/i,Ir=/^[0-9a-z]+$/,Rr=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Er=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Cr=/^[a-z0-9_-]{21}$/i,Mr=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Or=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Pr=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Dr="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",gt,jr=/^(?:(?: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])$/,Nr=/^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/,$r=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Lr=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Wr=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Br=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Qt="((\\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])))",Vr=new RegExp(`^${Qt}$`);function en(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);let n=t.precision?"+":"?";return `([01]\\d|2[0-3]):[0-5]\\d(:${e})${n}`}function Ur(t){return new RegExp(`^${en(t)}$`)}function tn(t){let e=`${Qt}T${en(t)}`,n=[];return n.push(t.local?"Z?":"Z"),t.offset&&n.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${n.join("|")})`,new RegExp(`^${e}$`)}function zr(t,e){return !!((e==="v4"||!e)&&jr.test(t)||(e==="v6"||!e)&&$r.test(t))}function Gr(t,e){if(!Mr.test(t))return false;try{let[n]=t.split(".");if(!n)return !1;let r=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),o=JSON.parse(atob(r));return !(typeof o!="object"||o===null||"typ"in o&&o?.typ!=="JWT"||!o.alg||e&&o.alg!==e)}catch{return false}}function Fr(t,e){return !!((e==="v4"||!e)&&Nr.test(t)||(e==="v6"||!e)&&Lr.test(t))}var ce=class t extends R{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==h.string){let s=this._getOrReturnCtx(e);return g(s,{code:f.invalid_type,expected:h.string,received:s.parsedType}),_}let r=new j,o;for(let s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(o=this._getOrReturnCtx(e,o),g(o,{code:f.too_small,minimum:s.value,type:"string",inclusive:true,exact:false,message:s.message}),r.dirty());else if(s.kind==="max")e.data.length>s.value&&(o=this._getOrReturnCtx(e,o),g(o,{code:f.too_big,maximum:s.value,type:"string",inclusive:true,exact:false,message:s.message}),r.dirty());else if(s.kind==="length"){let i=e.data.length>s.value,a=e.data.length<s.value;(i||a)&&(o=this._getOrReturnCtx(e,o),i?g(o,{code:f.too_big,maximum:s.value,type:"string",inclusive:true,exact:true,message:s.message}):a&&g(o,{code:f.too_small,minimum:s.value,type:"string",inclusive:true,exact:true,message:s.message}),r.dirty());}else if(s.kind==="email")Pr.test(e.data)||(o=this._getOrReturnCtx(e,o),g(o,{validation:"email",code:f.invalid_string,message:s.message}),r.dirty());else if(s.kind==="emoji")gt||(gt=new RegExp(Dr,"u")),gt.test(e.data)||(o=this._getOrReturnCtx(e,o),g(o,{validation:"emoji",code:f.invalid_string,message:s.message}),r.dirty());else if(s.kind==="uuid")Er.test(e.data)||(o=this._getOrReturnCtx(e,o),g(o,{validation:"uuid",code:f.invalid_string,message:s.message}),r.dirty());else if(s.kind==="nanoid")Cr.test(e.data)||(o=this._getOrReturnCtx(e,o),g(o,{validation:"nanoid",code:f.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid")Ar.test(e.data)||(o=this._getOrReturnCtx(e,o),g(o,{validation:"cuid",code:f.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid2")Ir.test(e.data)||(o=this._getOrReturnCtx(e,o),g(o,{validation:"cuid2",code:f.invalid_string,message:s.message}),r.dirty());else if(s.kind==="ulid")Rr.test(e.data)||(o=this._getOrReturnCtx(e,o),g(o,{validation:"ulid",code:f.invalid_string,message:s.message}),r.dirty());else if(s.kind==="url")try{new URL(e.data);}catch{o=this._getOrReturnCtx(e,o),g(o,{validation:"url",code:f.invalid_string,message:s.message}),r.dirty();}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(o=this._getOrReturnCtx(e,o),g(o,{validation:"regex",code:f.invalid_string,message:s.message}),r.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(o=this._getOrReturnCtx(e,o),g(o,{code:f.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),r.dirty()):s.kind==="toLowerCase"?e.data=e.data.toLowerCase():s.kind==="toUpperCase"?e.data=e.data.toUpperCase():s.kind==="startsWith"?e.data.startsWith(s.value)||(o=this._getOrReturnCtx(e,o),g(o,{code:f.invalid_string,validation:{startsWith:s.value},message:s.message}),r.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(o=this._getOrReturnCtx(e,o),g(o,{code:f.invalid_string,validation:{endsWith:s.value},message:s.message}),r.dirty()):s.kind==="datetime"?tn(s).test(e.data)||(o=this._getOrReturnCtx(e,o),g(o,{code:f.invalid_string,validation:"datetime",message:s.message}),r.dirty()):s.kind==="date"?Vr.test(e.data)||(o=this._getOrReturnCtx(e,o),g(o,{code:f.invalid_string,validation:"date",message:s.message}),r.dirty()):s.kind==="time"?Ur(s).test(e.data)||(o=this._getOrReturnCtx(e,o),g(o,{code:f.invalid_string,validation:"time",message:s.message}),r.dirty()):s.kind==="duration"?Or.test(e.data)||(o=this._getOrReturnCtx(e,o),g(o,{validation:"duration",code:f.invalid_string,message:s.message}),r.dirty()):s.kind==="ip"?zr(e.data,s.version)||(o=this._getOrReturnCtx(e,o),g(o,{validation:"ip",code:f.invalid_string,message:s.message}),r.dirty()):s.kind==="jwt"?Gr(e.data,s.alg)||(o=this._getOrReturnCtx(e,o),g(o,{validation:"jwt",code:f.invalid_string,message:s.message}),r.dirty()):s.kind==="cidr"?Fr(e.data,s.version)||(o=this._getOrReturnCtx(e,o),g(o,{validation:"cidr",code:f.invalid_string,message:s.message}),r.dirty()):s.kind==="base64"?Wr.test(e.data)||(o=this._getOrReturnCtx(e,o),g(o,{validation:"base64",code:f.invalid_string,message:s.message}),r.dirty()):s.kind==="base64url"?Br.test(e.data)||(o=this._getOrReturnCtx(e,o),g(o,{validation:"base64url",code:f.invalid_string,message:s.message}),r.dirty()):E.assertNever(s);return {status:r.value,value:e.data}}_regex(e,n,r){return this.refinement(o=>e.test(o),{validation:n,code:f.invalid_string,...b.errToObj(r)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...b.errToObj(e)})}url(e){return this._addCheck({kind:"url",...b.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...b.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...b.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...b.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...b.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...b.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...b.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...b.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...b.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...b.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...b.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...b.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:false,local:false,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??false,local:e?.local??false,...b.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...b.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...b.errToObj(e)})}regex(e,n){return this._addCheck({kind:"regex",regex:e,...b.errToObj(n)})}includes(e,n){return this._addCheck({kind:"includes",value:e,position:n?.position,...b.errToObj(n?.message)})}startsWith(e,n){return this._addCheck({kind:"startsWith",value:e,...b.errToObj(n)})}endsWith(e,n){return this._addCheck({kind:"endsWith",value:e,...b.errToObj(n)})}min(e,n){return this._addCheck({kind:"min",value:e,...b.errToObj(n)})}max(e,n){return this._addCheck({kind:"max",value:e,...b.errToObj(n)})}length(e,n){return this._addCheck({kind:"length",value:e,...b.errToObj(n)})}nonempty(e){return this.min(1,b.errToObj(e))}trim(){return new t({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return !!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return !!this._def.checks.find(e=>e.kind==="date")}get isTime(){return !!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return !!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return !!this._def.checks.find(e=>e.kind==="email")}get isURL(){return !!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return !!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return !!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return !!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return !!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return !!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return !!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return !!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return !!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return !!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return !!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxLength(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}};ce.create=t=>new ce({checks:[],typeName:S.ZodString,coerce:t?.coerce??false,...I(t)});function Kr(t,e){let n=(t.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,o=n>r?n:r,s=Number.parseInt(t.toFixed(o).replace(".","")),i=Number.parseInt(e.toFixed(o).replace(".",""));return s%i/10**o}var ge=class t extends R{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf;}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==h.number){let s=this._getOrReturnCtx(e);return g(s,{code:f.invalid_type,expected:h.number,received:s.parsedType}),_}let r,o=new j;for(let s of this._def.checks)s.kind==="int"?E.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),g(r,{code:f.invalid_type,expected:"integer",received:"float",message:s.message}),o.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(r=this._getOrReturnCtx(e,r),g(r,{code:f.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:false,message:s.message}),o.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(r=this._getOrReturnCtx(e,r),g(r,{code:f.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:false,message:s.message}),o.dirty()):s.kind==="multipleOf"?Kr(e.data,s.value)!==0&&(r=this._getOrReturnCtx(e,r),g(r,{code:f.not_multiple_of,multipleOf:s.value,message:s.message}),o.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),g(r,{code:f.not_finite,message:s.message}),o.dirty()):E.assertNever(s);return {status:o.value,value:e.data}}gte(e,n){return this.setLimit("min",e,true,b.toString(n))}gt(e,n){return this.setLimit("min",e,false,b.toString(n))}lte(e,n){return this.setLimit("max",e,true,b.toString(n))}lt(e,n){return this.setLimit("max",e,false,b.toString(n))}setLimit(e,n,r,o){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:b.toString(o)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:b.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:false,message:b.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:false,message:b.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:true,message:b.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:true,message:b.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:b.toString(n)})}finite(e){return this._addCheck({kind:"finite",message:b.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:true,value:Number.MIN_SAFE_INTEGER,message:b.toString(e)})._addCheck({kind:"max",inclusive:true,value:Number.MAX_SAFE_INTEGER,message:b.toString(e)})}get minValue(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}get isInt(){return !!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&E.isInteger(e.value))}get isFinite(){let e=null,n=null;for(let r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return true;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);}return Number.isFinite(n)&&Number.isFinite(e)}};ge.create=t=>new ge({checks:[],typeName:S.ZodNumber,coerce:t?.coerce||false,...I(t)});var ye=class t extends R{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte;}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data);}catch{return this._getInvalidInput(e)}if(this._getType(e)!==h.bigint)return this._getInvalidInput(e);let r,o=new j;for(let s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(r=this._getOrReturnCtx(e,r),g(r,{code:f.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),o.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(r=this._getOrReturnCtx(e,r),g(r,{code:f.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),o.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),g(r,{code:f.not_multiple_of,multipleOf:s.value,message:s.message}),o.dirty()):E.assertNever(s);return {status:o.value,value:e.data}}_getInvalidInput(e){let n=this._getOrReturnCtx(e);return g(n,{code:f.invalid_type,expected:h.bigint,received:n.parsedType}),_}gte(e,n){return this.setLimit("min",e,true,b.toString(n))}gt(e,n){return this.setLimit("min",e,false,b.toString(n))}lte(e,n){return this.setLimit("max",e,true,b.toString(n))}lt(e,n){return this.setLimit("max",e,false,b.toString(n))}setLimit(e,n,r,o){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:b.toString(o)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:false,message:b.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:false,message:b.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:true,message:b.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:true,message:b.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:b.toString(n)})}get minValue(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}};ye.create=t=>new ye({checks:[],typeName:S.ZodBigInt,coerce:t?.coerce??false,...I(t)});var he=class extends R{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==h.boolean){let r=this._getOrReturnCtx(e);return g(r,{code:f.invalid_type,expected:h.boolean,received:r.parsedType}),_}return $(e.data)}};he.create=t=>new he({typeName:S.ZodBoolean,coerce:t?.coerce||false,...I(t)});var ve=class t extends R{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==h.date){let s=this._getOrReturnCtx(e);return g(s,{code:f.invalid_type,expected:h.date,received:s.parsedType}),_}if(Number.isNaN(e.data.getTime())){let s=this._getOrReturnCtx(e);return g(s,{code:f.invalid_date}),_}let r=new j,o;for(let s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(o=this._getOrReturnCtx(e,o),g(o,{code:f.too_small,message:s.message,inclusive:true,exact:false,minimum:s.value,type:"date"}),r.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(o=this._getOrReturnCtx(e,o),g(o,{code:f.too_big,message:s.message,inclusive:true,exact:false,maximum:s.value,type:"date"}),r.dirty()):E.assertNever(s);return {status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,n){return this._addCheck({kind:"min",value:e.getTime(),message:b.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:b.toString(n)})}get minDate(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e!=null?new Date(e):null}};ve.create=t=>new ve({checks:[],coerce:t?.coerce||false,typeName:S.ZodDate,...I(t)});var je=class extends R{_parse(e){if(this._getType(e)!==h.symbol){let r=this._getOrReturnCtx(e);return g(r,{code:f.invalid_type,expected:h.symbol,received:r.parsedType}),_}return $(e.data)}};je.create=t=>new je({typeName:S.ZodSymbol,...I(t)});var xe=class extends R{_parse(e){if(this._getType(e)!==h.undefined){let r=this._getOrReturnCtx(e);return g(r,{code:f.invalid_type,expected:h.undefined,received:r.parsedType}),_}return $(e.data)}};xe.create=t=>new xe({typeName:S.ZodUndefined,...I(t)});var be=class extends R{_parse(e){if(this._getType(e)!==h.null){let r=this._getOrReturnCtx(e);return g(r,{code:f.invalid_type,expected:h.null,received:r.parsedType}),_}return $(e.data)}};be.create=t=>new be({typeName:S.ZodNull,...I(t)});var le=class extends R{constructor(){super(...arguments),this._any=true;}_parse(e){return $(e.data)}};le.create=t=>new le({typeName:S.ZodAny,...I(t)});var oe=class extends R{constructor(){super(...arguments),this._unknown=true;}_parse(e){return $(e.data)}};oe.create=t=>new oe({typeName:S.ZodUnknown,...I(t)});var J=class extends R{_parse(e){let n=this._getOrReturnCtx(e);return g(n,{code:f.invalid_type,expected:h.never,received:n.parsedType}),_}};J.create=t=>new J({typeName:S.ZodNever,...I(t)});var Ne=class extends R{_parse(e){if(this._getType(e)!==h.undefined){let r=this._getOrReturnCtx(e);return g(r,{code:f.invalid_type,expected:h.void,received:r.parsedType}),_}return $(e.data)}};Ne.create=t=>new Ne({typeName:S.ZodVoid,...I(t)});var se=class t extends R{_parse(e){let{ctx:n,status:r}=this._processInputParams(e),o=this._def;if(n.parsedType!==h.array)return g(n,{code:f.invalid_type,expected:h.array,received:n.parsedType}),_;if(o.exactLength!==null){let i=n.data.length>o.exactLength.value,a=n.data.length<o.exactLength.value;(i||a)&&(g(n,{code:i?f.too_big:f.too_small,minimum:a?o.exactLength.value:void 0,maximum:i?o.exactLength.value:void 0,type:"array",inclusive:true,exact:true,message:o.exactLength.message}),r.dirty());}if(o.minLength!==null&&n.data.length<o.minLength.value&&(g(n,{code:f.too_small,minimum:o.minLength.value,type:"array",inclusive:true,exact:false,message:o.minLength.message}),r.dirty()),o.maxLength!==null&&n.data.length>o.maxLength.value&&(g(n,{code:f.too_big,maximum:o.maxLength.value,type:"array",inclusive:true,exact:false,message:o.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((i,a)=>o.type._parseAsync(new K(n,i,n.path,a)))).then(i=>j.mergeArray(r,i));let s=[...n.data].map((i,a)=>o.type._parseSync(new K(n,i,n.path,a)));return j.mergeArray(r,s)}get element(){return this._def.type}min(e,n){return new t({...this._def,minLength:{value:e,message:b.toString(n)}})}max(e,n){return new t({...this._def,maxLength:{value:e,message:b.toString(n)}})}length(e,n){return new t({...this._def,exactLength:{value:e,message:b.toString(n)}})}nonempty(e){return this.min(1,e)}};se.create=(t,e)=>new se({type:t,minLength:null,maxLength:null,exactLength:null,typeName:S.ZodArray,...I(e)});function De(t){if(t instanceof V){let e={};for(let n in t.shape){let r=t.shape[n];e[n]=F.create(De(r));}return new V({...t._def,shape:()=>e})}else return t instanceof se?new se({...t._def,type:De(t.element)}):t instanceof F?F.create(De(t.unwrap())):t instanceof Q?Q.create(De(t.unwrap())):t instanceof X?X.create(t.items.map(e=>De(e))):t}var V=class t extends R{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend;}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),n=E.objectKeys(e);return this._cached={shape:e,keys:n},this._cached}_parse(e){if(this._getType(e)!==h.object){let c=this._getOrReturnCtx(e);return g(c,{code:f.invalid_type,expected:h.object,received:c.parsedType}),_}let{status:r,ctx:o}=this._processInputParams(e),{shape:s,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof J&&this._def.unknownKeys==="strip"))for(let c in o.data)i.includes(c)||a.push(c);let u=[];for(let c of i){let d=s[c],y=o.data[c];u.push({key:{status:"valid",value:c},value:d._parse(new K(o,y,o.path,c)),alwaysSet:c in o.data});}if(this._def.catchall instanceof J){let c=this._def.unknownKeys;if(c==="passthrough")for(let d of a)u.push({key:{status:"valid",value:d},value:{status:"valid",value:o.data[d]}});else if(c==="strict")a.length>0&&(g(o,{code:f.unrecognized_keys,keys:a}),r.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else {let c=this._def.catchall;for(let d of a){let y=o.data[d];u.push({key:{status:"valid",value:d},value:c._parse(new K(o,y,o.path,d)),alwaysSet:d in o.data});}}return o.common.async?Promise.resolve().then(async()=>{let c=[];for(let d of u){let y=await d.key,v=await d.value;c.push({key:y,value:v,alwaysSet:d.alwaysSet});}return c}).then(c=>j.mergeObjectSync(r,c)):j.mergeObjectSync(r,u)}get shape(){return this._def.shape()}strict(e){return b.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(n,r)=>{let o=this._def.errorMap?.(n,r).message??r.defaultError;return n.code==="unrecognized_keys"?{message:b.errToObj(e).message??o}:{message:o}}}:{}})}strip(){return new t({...this._def,unknownKeys:"strip"})}passthrough(){return new t({...this._def,unknownKeys:"passthrough"})}extend(e){return new t({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:S.ZodObject})}setKey(e,n){return this.augment({[e]:n})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let n={};for(let r of E.objectKeys(e))e[r]&&this.shape[r]&&(n[r]=this.shape[r]);return new t({...this._def,shape:()=>n})}omit(e){let n={};for(let r of E.objectKeys(this.shape))e[r]||(n[r]=this.shape[r]);return new t({...this._def,shape:()=>n})}deepPartial(){return De(this)}partial(e){let n={};for(let r of E.objectKeys(this.shape)){let o=this.shape[r];e&&!e[r]?n[r]=o:n[r]=o.optional();}return new t({...this._def,shape:()=>n})}required(e){let n={};for(let r of E.objectKeys(this.shape))if(e&&!e[r])n[r]=this.shape[r];else {let s=this.shape[r];for(;s instanceof F;)s=s._def.innerType;n[r]=s;}return new t({...this._def,shape:()=>n})}keyof(){return nn(E.objectKeys(this.shape))}};V.create=(t,e)=>new V({shape:()=>t,unknownKeys:"strip",catchall:J.create(),typeName:S.ZodObject,...I(e)});V.strictCreate=(t,e)=>new V({shape:()=>t,unknownKeys:"strict",catchall:J.create(),typeName:S.ZodObject,...I(e)});V.lazycreate=(t,e)=>new V({shape:t,unknownKeys:"strip",catchall:J.create(),typeName:S.ZodObject,...I(e)});var we=class extends R{_parse(e){let{ctx:n}=this._processInputParams(e),r=this._def.options;function o(s){for(let a of s)if(a.result.status==="valid")return a.result;for(let a of s)if(a.result.status==="dirty")return n.common.issues.push(...a.ctx.common.issues),a.result;let i=s.map(a=>new B(a.ctx.common.issues));return g(n,{code:f.invalid_union,unionErrors:i}),_}if(n.common.async)return Promise.all(r.map(async s=>{let i={...n,common:{...n.common,issues:[]},parent:null};return {result:await s._parseAsync({data:n.data,path:n.path,parent:i}),ctx:i}})).then(o);{let s,i=[];for(let u of r){let c={...n,common:{...n.common,issues:[]},parent:null},d=u._parseSync({data:n.data,path:n.path,parent:c});if(d.status==="valid")return d;d.status==="dirty"&&!s&&(s={result:d,ctx:c}),c.common.issues.length&&i.push(c.common.issues);}if(s)return n.common.issues.push(...s.ctx.common.issues),s.result;let a=i.map(u=>new B(u));return g(n,{code:f.invalid_union,unionErrors:a}),_}}get options(){return this._def.options}};we.create=(t,e)=>new we({options:t,typeName:S.ZodUnion,...I(e)});var re=t=>t instanceof _e?re(t.schema):t instanceof Z?re(t.innerType()):t instanceof Te?[t.value]:t instanceof Se?t.options:t instanceof Ae?E.objectValues(t.enum):t instanceof Ie?re(t._def.innerType):t instanceof xe?[void 0]:t instanceof be?[null]:t instanceof F?[void 0,...re(t.unwrap())]:t instanceof Q?[null,...re(t.unwrap())]:t instanceof Fe||t instanceof Ee?re(t.unwrap()):t instanceof Re?re(t._def.innerType):[],nt=class t extends R{_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==h.object)return g(n,{code:f.invalid_type,expected:h.object,received:n.parsedType}),_;let r=this.discriminator,o=n.data[r],s=this.optionsMap.get(o);return s?n.common.async?s._parseAsync({data:n.data,path:n.path,parent:n}):s._parseSync({data:n.data,path:n.path,parent:n}):(g(n,{code:f.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),_)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,n,r){let o=new Map;for(let s of n){let i=re(s.shape[e]);if(!i.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let a of i){if(o.has(a))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);o.set(a,s);}}return new t({typeName:S.ZodDiscriminatedUnion,discriminator:e,options:n,optionsMap:o,...I(r)})}};function yt(t,e){let n=Y(t),r=Y(e);if(t===e)return {valid:true,data:t};if(n===h.object&&r===h.object){let o=E.objectKeys(e),s=E.objectKeys(t).filter(a=>o.indexOf(a)!==-1),i={...t,...e};for(let a of s){let u=yt(t[a],e[a]);if(!u.valid)return {valid:false};i[a]=u.data;}return {valid:true,data:i}}else if(n===h.array&&r===h.array){if(t.length!==e.length)return {valid:false};let o=[];for(let s=0;s<t.length;s++){let i=t[s],a=e[s],u=yt(i,a);if(!u.valid)return {valid:false};o.push(u.data);}return {valid:true,data:o}}else return n===h.date&&r===h.date&&+t==+e?{valid:true,data:t}:{valid:false}}var ke=class extends R{_parse(e){let{status:n,ctx:r}=this._processInputParams(e),o=(s,i)=>{if(et(s)||et(i))return _;let a=yt(s.value,i.value);return a.valid?((tt(s)||tt(i))&&n.dirty(),{status:n.value,value:a.data}):(g(r,{code:f.invalid_intersection_types}),_)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([s,i])=>o(s,i)):o(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}};ke.create=(t,e,n)=>new ke({left:t,right:e,typeName:S.ZodIntersection,...I(n)});var X=class t extends R{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==h.array)return g(r,{code:f.invalid_type,expected:h.array,received:r.parsedType}),_;if(r.data.length<this._def.items.length)return g(r,{code:f.too_small,minimum:this._def.items.length,inclusive:true,exact:false,type:"array"}),_;!this._def.rest&&r.data.length>this._def.items.length&&(g(r,{code:f.too_big,maximum:this._def.items.length,inclusive:true,exact:false,type:"array"}),n.dirty());let s=[...r.data].map((i,a)=>{let u=this._def.items[a]||this._def.rest;return u?u._parse(new K(r,i,r.path,a)):null}).filter(i=>!!i);return r.common.async?Promise.all(s).then(i=>j.mergeArray(n,i)):j.mergeArray(n,s)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};X.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new X({items:t,typeName:S.ZodTuple,rest:null,...I(e)})};var rt=class t extends R{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==h.object)return g(r,{code:f.invalid_type,expected:h.object,received:r.parsedType}),_;let o=[],s=this._def.keyType,i=this._def.valueType;for(let a in r.data)o.push({key:s._parse(new K(r,a,r.path,a)),value:i._parse(new K(r,r.data[a],r.path,a)),alwaysSet:a in r.data});return r.common.async?j.mergeObjectAsync(n,o):j.mergeObjectSync(n,o)}get element(){return this._def.valueType}static create(e,n,r){return n instanceof R?new t({keyType:e,valueType:n,typeName:S.ZodRecord,...I(r)}):new t({keyType:ce.create(),valueType:e,typeName:S.ZodRecord,...I(n)})}},$e=class extends R{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==h.map)return g(r,{code:f.invalid_type,expected:h.map,received:r.parsedType}),_;let o=this._def.keyType,s=this._def.valueType,i=[...r.data.entries()].map(([a,u],c)=>({key:o._parse(new K(r,a,r.path,[c,"key"])),value:s._parse(new K(r,u,r.path,[c,"value"]))}));if(r.common.async){let a=new Map;return Promise.resolve().then(async()=>{for(let u of i){let c=await u.key,d=await u.value;if(c.status==="aborted"||d.status==="aborted")return _;(c.status==="dirty"||d.status==="dirty")&&n.dirty(),a.set(c.value,d.value);}return {status:n.value,value:a}})}else {let a=new Map;for(let u of i){let c=u.key,d=u.value;if(c.status==="aborted"||d.status==="aborted")return _;(c.status==="dirty"||d.status==="dirty")&&n.dirty(),a.set(c.value,d.value);}return {status:n.value,value:a}}}};$e.create=(t,e,n)=>new $e({valueType:e,keyType:t,typeName:S.ZodMap,...I(n)});var Le=class t extends R{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==h.set)return g(r,{code:f.invalid_type,expected:h.set,received:r.parsedType}),_;let o=this._def;o.minSize!==null&&r.data.size<o.minSize.value&&(g(r,{code:f.too_small,minimum:o.minSize.value,type:"set",inclusive:true,exact:false,message:o.minSize.message}),n.dirty()),o.maxSize!==null&&r.data.size>o.maxSize.value&&(g(r,{code:f.too_big,maximum:o.maxSize.value,type:"set",inclusive:true,exact:false,message:o.maxSize.message}),n.dirty());let s=this._def.valueType;function i(u){let c=new Set;for(let d of u){if(d.status==="aborted")return _;d.status==="dirty"&&n.dirty(),c.add(d.value);}return {status:n.value,value:c}}let a=[...r.data.values()].map((u,c)=>s._parse(new K(r,u,r.path,c)));return r.common.async?Promise.all(a).then(u=>i(u)):i(a)}min(e,n){return new t({...this._def,minSize:{value:e,message:b.toString(n)}})}max(e,n){return new t({...this._def,maxSize:{value:e,message:b.toString(n)}})}size(e,n){return this.min(e,n).max(e,n)}nonempty(e){return this.min(1,e)}};Le.create=(t,e)=>new Le({valueType:t,minSize:null,maxSize:null,typeName:S.ZodSet,...I(e)});var ot=class t extends R{constructor(){super(...arguments),this.validate=this.implement;}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==h.function)return g(n,{code:f.invalid_type,expected:h.function,received:n.parsedType}),_;function r(a,u){return Ge({data:a,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,Oe(),ne].filter(c=>!!c),issueData:{code:f.invalid_arguments,argumentsError:u}})}function o(a,u){return Ge({data:a,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,Oe(),ne].filter(c=>!!c),issueData:{code:f.invalid_return_type,returnTypeError:u}})}let s={errorMap:n.common.contextualErrorMap},i=n.data;if(this._def.returns instanceof ue){let a=this;return $(async function(...u){let c=new B([]),d=await a._def.args.parseAsync(u,s).catch(w=>{throw c.addIssue(r(u,w)),c}),y=await Reflect.apply(i,this,d);return await a._def.returns._def.type.parseAsync(y,s).catch(w=>{throw c.addIssue(o(y,w)),c})})}else {let a=this;return $(function(...u){let c=a._def.args.safeParse(u,s);if(!c.success)throw new B([r(u,c.error)]);let d=Reflect.apply(i,this,c.data),y=a._def.returns.safeParse(d,s);if(!y.success)throw new B([o(d,y.error)]);return y.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:X.create(e).rest(oe.create())})}returns(e){return new t({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,n,r){return new t({args:e||X.create([]).rest(oe.create()),returns:n||oe.create(),typeName:S.ZodFunction,...I(r)})}},_e=class extends R{get schema(){return this._def.getter()}_parse(e){let{ctx:n}=this._processInputParams(e);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}};_e.create=(t,e)=>new _e({getter:t,typeName:S.ZodLazy,...I(e)});var Te=class extends R{_parse(e){if(e.data!==this._def.value){let n=this._getOrReturnCtx(e);return g(n,{received:n.data,code:f.invalid_literal,expected:this._def.value}),_}return {status:"valid",value:e.data}}get value(){return this._def.value}};Te.create=(t,e)=>new Te({value:t,typeName:S.ZodLiteral,...I(e)});function nn(t,e){return new Se({values:t,typeName:S.ZodEnum,...I(e)})}var Se=class t extends R{_parse(e){if(typeof e.data!="string"){let n=this._getOrReturnCtx(e),r=this._def.values;return g(n,{expected:E.joinValues(r),received:n.parsedType,code:f.invalid_type}),_}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let n=this._getOrReturnCtx(e),r=this._def.values;return g(n,{received:n.data,code:f.invalid_enum_value,options:r}),_}return $(e.data)}get options(){return this._def.values}get enum(){let e={};for(let n of this._def.values)e[n]=n;return e}get Values(){let e={};for(let n of this._def.values)e[n]=n;return e}get Enum(){let e={};for(let n of this._def.values)e[n]=n;return e}extract(e,n=this._def){return t.create(e,{...this._def,...n})}exclude(e,n=this._def){return t.create(this.options.filter(r=>!e.includes(r)),{...this._def,...n})}};Se.create=nn;var Ae=class extends R{_parse(e){let n=E.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==h.string&&r.parsedType!==h.number){let o=E.objectValues(n);return g(r,{expected:E.joinValues(o),received:r.parsedType,code:f.invalid_type}),_}if(this._cache||(this._cache=new Set(E.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let o=E.objectValues(n);return g(r,{received:r.data,code:f.invalid_enum_value,options:o}),_}return $(e.data)}get enum(){return this._def.values}};Ae.create=(t,e)=>new Ae({values:t,typeName:S.ZodNativeEnum,...I(e)});var ue=class extends R{unwrap(){return this._def.type}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==h.promise&&n.common.async===false)return g(n,{code:f.invalid_type,expected:h.promise,received:n.parsedType}),_;let r=n.parsedType===h.promise?n.data:Promise.resolve(n.data);return $(r.then(o=>this._def.type.parseAsync(o,{path:n.path,errorMap:n.common.contextualErrorMap})))}};ue.create=(t,e)=>new ue({type:t,typeName:S.ZodPromise,...I(e)});var Z=class extends R{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===S.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:n,ctx:r}=this._processInputParams(e),o=this._def.effect||null,s={addIssue:i=>{g(r,i),i.fatal?n.abort():n.dirty();},get path(){return r.path}};if(s.addIssue=s.addIssue.bind(s),o.type==="preprocess"){let i=o.transform(r.data,s);if(r.common.async)return Promise.resolve(i).then(async a=>{if(n.value==="aborted")return _;let u=await this._def.schema._parseAsync({data:a,path:r.path,parent:r});return u.status==="aborted"?_:u.status==="dirty"?me(u.value):n.value==="dirty"?me(u.value):u});{if(n.value==="aborted")return _;let a=this._def.schema._parseSync({data:i,path:r.path,parent:r});return a.status==="aborted"?_:a.status==="dirty"?me(a.value):n.value==="dirty"?me(a.value):a}}if(o.type==="refinement"){let i=a=>{let u=o.refinement(a,s);if(r.common.async)return Promise.resolve(u);if(u instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(r.common.async===false){let a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?_:(a.status==="dirty"&&n.dirty(),i(a.value),{status:n.value,value:a.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>a.status==="aborted"?_:(a.status==="dirty"&&n.dirty(),i(a.value).then(()=>({status:n.value,value:a.value}))))}if(o.type==="transform")if(r.common.async===false){let i=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!ae(i))return _;let a=o.transform(i.value,s);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return {status:n.value,value:a}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(i=>ae(i)?Promise.resolve(o.transform(i.value,s)).then(a=>({status:n.value,value:a})):_);E.assertNever(o);}};Z.create=(t,e,n)=>new Z({schema:t,typeName:S.ZodEffects,effect:e,...I(n)});Z.createWithPreprocess=(t,e,n)=>new Z({schema:e,effect:{type:"preprocess",transform:t},typeName:S.ZodEffects,...I(n)});var F=class extends R{_parse(e){return this._getType(e)===h.undefined?$(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};F.create=(t,e)=>new F({innerType:t,typeName:S.ZodOptional,...I(e)});var Q=class extends R{_parse(e){return this._getType(e)===h.null?$(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Q.create=(t,e)=>new Q({innerType:t,typeName:S.ZodNullable,...I(e)});var Ie=class extends R{_parse(e){let{ctx:n}=this._processInputParams(e),r=n.data;return n.parsedType===h.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}};Ie.create=(t,e)=>new Ie({innerType:t,typeName:S.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...I(e)});var Re=class extends R{_parse(e){let{ctx:n}=this._processInputParams(e),r={...n,common:{...n.common,issues:[]}},o=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return Pe(o)?o.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new B(r.common.issues)},input:r.data})})):{status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new B(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}};Re.create=(t,e)=>new Re({innerType:t,typeName:S.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...I(e)});var We=class extends R{_parse(e){if(this._getType(e)!==h.nan){let r=this._getOrReturnCtx(e);return g(r,{code:f.invalid_type,expected:h.nan,received:r.parsedType}),_}return {status:"valid",value:e.data}}};We.create=t=>new We({typeName:S.ZodNaN,...I(t)});var Zr=Symbol("zod_brand"),Fe=class extends R{_parse(e){let{ctx:n}=this._processInputParams(e),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}},Ke=class t extends R{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.common.async)return (async()=>{let s=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?_:s.status==="dirty"?(n.dirty(),me(s.value)):this._def.out._parseAsync({data:s.value,path:r.path,parent:r})})();{let o=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return o.status==="aborted"?_:o.status==="dirty"?(n.dirty(),{status:"dirty",value:o.value}):this._def.out._parseSync({data:o.value,path:r.path,parent:r})}}static create(e,n){return new t({in:e,out:n,typeName:S.ZodPipeline})}},Ee=class extends R{_parse(e){let n=this._def.innerType._parse(e),r=o=>(ae(o)&&(o.value=Object.freeze(o.value)),o);return Pe(n)?n.then(o=>r(o)):r(n)}unwrap(){return this._def.innerType}};Ee.create=(t,e)=>new Ee({innerType:t,typeName:S.ZodReadonly,...I(e)});function Xt(t,e){let n=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof n=="string"?{message:n}:n}function rn(t,e={},n){return t?le.create().superRefine((r,o)=>{let s=t(r);if(s instanceof Promise)return s.then(i=>{if(!i){let a=Xt(e,r),u=a.fatal??n??true;o.addIssue({code:"custom",...a,fatal:u});}});if(!s){let i=Xt(e,r),a=i.fatal??n??true;o.addIssue({code:"custom",...i,fatal:a});}}):le.create()}var Hr={object:V.lazycreate},S;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly";})(S||(S={}));var Jr=(t,e={message:`Input not instance of ${t.name}`})=>rn(n=>n instanceof t,e),on=ce.create,sn=ge.create,qr=We.create,Yr=ye.create,an=he.create,Xr=ve.create,Qr=je.create,eo=xe.create,to=be.create,no=le.create,ro=oe.create,oo=J.create,so=Ne.create,io=se.create,ao=V.create,co=V.strictCreate,lo=we.create,uo=nt.create,po=ke.create,fo=X.create,mo=rt.create,go=$e.create,yo=Le.create,ho=ot.create,vo=_e.create,xo=Te.create,bo=Se.create,wo=Ae.create,ko=ue.create,_o=Z.create,To=F.create,So=Q.create,Ao=Z.createWithPreprocess,Io=Ke.create,Ro=()=>on().optional(),Eo=()=>sn().optional(),Co=()=>an().optional(),Mo={string:(t=>ce.create({...t,coerce:true})),number:(t=>ge.create({...t,coerce:true})),boolean:(t=>he.create({...t,coerce:true})),bigint:(t=>ye.create({...t,coerce:true})),date:(t=>ve.create({...t,coerce:true}))};var Oo=_;var Be="agtx_pk_",st="agtx_sk_";l.string().min(Be.length+8).startsWith(Be,{message:`Publishable keys must start with "${Be}".`});l.string().min(st.length+8).startsWith(st,{message:`Secret keys must start with "${st}".`});var cn=t=>t.startsWith(Be)?"publishable":t.startsWith(st)?"secret":"unknown",Ve=l.enum(["webmcp","dom","screenshot","crawler"]),ht=l.enum(["detected","declared","verified","linked"]),Po=l.object({class:Ve,trust:ht,confidence:l.number().min(0).max(1).default(1),vendor:l.string().nullable(),userAgent:l.string().nullable(),detectionVersion:l.string().default("2026.04"),signals:l.record(l.unknown()).default({})}),Do=l.enum(["bearer","oauth2","sso","spiffe","google-agent","mtls","detection","declaration","extension","session-link","x-agent-header","web-bot-auth","api-key","verified-crawler"]),Ze=l.object({class:Ve,vendor:l.string().min(1),token:l.string().min(8),expiresAt:l.string().datetime().optional()});l.object({publishableKey:l.string(),claim:Ze,nonce:l.string().min(8),origin:l.string().url()});l.object({trust:ht,vendor:l.string(),validUntil:l.string().datetime(),reason:l.string().optional(),subject:l.string().optional(),protocol:Do.optional(),signals:l.record(l.unknown()).optional()});l.object({issuer:l.string().url(),audiences:l.array(l.string().min(1)).min(1)});l.object({trustDomain:l.string().min(1),bundleEndpoint:l.string().url(),audiences:l.array(l.string().min(1)).min(1),googleTrustDomains:l.array(l.string().min(1)).optional()});l.object({rootCerts:l.array(l.string().min(20)).min(1),spiffeTrustDomain:l.string().min(1).optional(),xfccEntryPolicy:l.enum(["last","first","only"]).default("last")});l.enum(["sso","spiffe","mtls"]);l.object({siteId:l.string().min(1),token:l.string().min(8).optional(),xfcc:l.string().min(1).optional(),headers:l.record(l.string()).optional(),origin:l.string().url().optional()});var q={detected:0,declared:1,verified:2,linked:3},ln=(t,e)=>q[t]>q[e],un=l.enum(["allow","deny","review"]),Ce=l.object({id:l.string(),tool:l.string(),minTrust:ht,allowedClasses:l.array(Ve).default([]),decision:un,rateLimit:l.object({max:l.number().int().positive(),windowSeconds:l.number().int().positive()}).optional()}),jo=l.object({decision:un,ruleId:l.string().nullable(),reason:l.string()}),No=l.enum(["session","user","org"]),vt=l.object({key:l.string().min(1),value:l.unknown(),scope:No.default("session"),ttlSeconds:l.number().int().positive().nullable().default(null),updatedAt:l.string().datetime().optional()}),$o=l.object({path:l.string().min(1),name:l.string().optional(),purpose:l.string().optional(),availableActions:l.array(l.string()).optional(),prerequisites:l.array(l.string()).optional(),queryParams:l.record(l.string()).optional(),notes:l.string().optional()}),Lo=l.object({pattern:l.string().optional(),flow:l.string().optional()}),Wo=l.object({pages:l.array($o).default([]),navigation:Lo.optional()}),Bo=l.object({step:l.number().int().positive(),action:l.string().min(1)}),Vo=l.object({steps:l.array(Bo).default([]),notes:l.string().optional(),policy:l.string().optional()}),Uo=l.object({selector:l.string().min(1),behavior:l.string().optional(),location:l.string().optional(),showsCount:l.boolean().optional()}),zo=l.object({categories:l.array(l.string()).optional(),productSchema:l.object({fields:l.array(l.string()).optional(),idFormat:l.string().optional()}).optional(),searchBehavior:l.string().optional()}),xt=l.object({path:l.string().min(1),payload:l.record(l.unknown()).default({}),updatedAt:l.string().datetime().optional()}).strict(),U=l.object({version:l.string().default("1"),siteMap:Wo.optional(),workflows:l.record(Vo).default({}),policies:l.record(l.union([l.string(),l.array(l.string())])).default({}),catalog:zo.optional(),uiGuidance:l.record(Uo).default({}),pageContexts:l.record(xt).default({}),updatedAt:l.string().datetime().optional()}),dn=U.parse({}),Go=l.object({name:l.string().min(1),title:l.string().optional(),group:l.string().optional(),page:l.string().optional(),description:l.string().default(""),inputSchema:l.record(l.unknown()).default({}),outputSchema:l.record(l.unknown()).optional(),annotations:l.record(l.boolean()).optional(),tokens:l.number().int().nonnegative().default(0)}),Fo=l.object({tools:l.array(Go).default([])});Fo.parse({});var Ko=l.enum(["agent.detected","agent.missed","auth.identity_presented","auth.identity_cleared","authz.policies_set","authz.evaluated","memory.accessed","memory.updated","tool.registered","tool.executed","tool.surfaced","tool.progressed","sdk.error"]),bt=l.object({id:l.string(),siteId:l.string(),sessionId:l.string(),occurredAt:l.string().datetime(),type:Ko,tool:l.string().optional(),agent:Po.nullable().optional(),policy:jo.optional(),durationMs:l.number().int().nonnegative().optional(),outcome:l.enum(["success","error","blocked"]),error:l.string().optional(),metadata:l.record(l.unknown()).default({})});l.object({publishableKey:l.string().optional(),events:l.array(bt).min(1).max(100)});var He=class extends Error{code;constructor(t,e){super(e),this.name="AgentronicsError",this.code=t;}};var M="0.1.2";var wt=(t,e)=>typeof t=="object"&&t!==null&&typeof t[e]=="function",it=t=>{let e=t??(typeof globalThis>"u"?null:globalThis);if(!e)return null;let n=e.document?.modelContext;if(wt(n,"registerTool"))return {source:"document",context:n};let r=e.navigator?.modelContext;return wt(r,"registerTool")?{source:"navigator",context:r}:wt(r,"provideContext")?{source:"legacy",context:r}:null},kt=null,_t=new Set,Tt=(t,e)=>{kt={type:t,toolName:e,at:Date.now()},_t.forEach(n=>n(kt));},pn=()=>kt,fn=t=>(_t.add(t),()=>{_t.delete(t);});var Zo=()=>{if(typeof navigator>"u")return null;let t=navigator.modelContext;return !t||typeof t!="object"?null:t.vendor||t.client?t:null},Ho=()=>it()?.source??null,Je=async(t={})=>{let{pollMs:e=500}=t,n=Date.now();for(;;){let r=pn();if(r)return Jo(r);let o=Zo();if(o)return qo(o);if(Date.now()-n>=e)return null;await new Promise(s=>setTimeout(s,50));}},mn=()=>({class:"webmcp",trust:"detected",confidence:1,userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:M}),Jo=t=>({...mn(),vendor:null,signals:{webmcp:true,source:Ho(),event:t.type,tool:t.toolName}}),qo=t=>({...mn(),vendor:t.vendor??t.client??null,signals:{webmcp:true,source:"legacy-extension",toolCount:Array.isArray(t.tools)?t.tools.length:0}});var gn=[{name:"GPTBot",category:"ai",pattern:/GPTBot/i},{name:"OAI-SearchBot",category:"ai",pattern:/OAI-SearchBot/i},{name:"ChatGPT-User",category:"ai",pattern:/ChatGPT-User/i},{name:"Claude-User",category:"ai",pattern:/Claude-User/i},{name:"Claude-SearchBot",category:"ai",pattern:/Claude-SearchBot/i},{name:"ClaudeBot",category:"ai",pattern:/ClaudeBot/i},{name:"Claude-Web",category:"ai",pattern:/Claude-Web/i},{name:"anthropic-ai",category:"ai",pattern:/anthropic-ai/i},{name:"Perplexity-User",category:"ai",pattern:/Perplexity-User/i},{name:"PerplexityBot",category:"ai",pattern:/PerplexityBot/i},{name:"Google-Extended",category:"ai",pattern:/Google-Extended/i},{name:"Applebot-Extended",category:"ai",pattern:/Applebot-Extended/i},{name:"Amazonbot",category:"ai",pattern:/Amazonbot/i},{name:"Bytespider",category:"ai",pattern:/Bytespider/i},{name:"CCBot",category:"ai",pattern:/CCBot/i},{name:"Meta-ExternalAgent",category:"ai",pattern:/Meta-ExternalAgent/i},{name:"cohere-ai",category:"ai",pattern:/cohere-ai/i},{name:"Googlebot",category:"search",pattern:/Googlebot/i},{name:"Bingbot",category:"search",pattern:/bingbot/i},{name:"DuckDuckBot",category:"search",pattern:/DuckDuckBot/i},{name:"YandexBot",category:"search",pattern:/YandexBot/i},{name:"Baiduspider",category:"search",pattern:/Baiduspider/i},{name:"Applebot",category:"search",pattern:/Applebot/i}],qe=(t={})=>{let{signatures:e=gn,disable:n=false,confidence:r=.9}=t;if(n||typeof navigator>"u")return null;let o=navigator.userAgent??"";if(!o)return null;for(let s of e)if(s.pattern.test(o))return {class:"crawler",trust:"detected",confidence:r,vendor:s.name,userAgent:o,detectionVersion:M,signals:{matched:s.name,category:s.category,ua:o}};return null};var Yo=[/HeadlessChrome/i,/Headless/i,/PhantomJS/i,/SlimerJS/i],Xo=()=>({hit:(typeof navigator<"u"&&navigator.webdriver)===true,weight:.6,detail:"navigator.webdriver === true"}),Qo=()=>{if(typeof window>"u")return {hit:false,weight:.5};let t=Object.keys(window).filter(e=>e.startsWith("cdc_"));return {hit:t.length>0,weight:.5,detail:`window.${t[0]??"cdc_*"}`}},es=["__playwright__binding__","__pwInitScripts","__puppeteer_evaluation_script__","_phantom","callPhantom","__nightmare","domAutomation","domAutomationController","__selenium_unwrapped","__webdriver_evaluate","__driver_evaluate","__fxdriver_unwrapped"],ts=()=>{if(typeof window>"u")return {hit:false,weight:.6};let t=es.find(e=>e in window);return t?{hit:true,weight:.6,detail:`window.${t}`}:{hit:false,weight:.6}},ns=()=>{if(typeof navigator>"u"||!navigator.plugins)return {hit:false,weight:.2};let t=/Win|Mac|Linux/.test(navigator.userAgent??""),e=navigator.plugins.length===0;return {hit:t&&e,weight:.2,detail:"desktop UA with no plugins"}},rs=()=>{if(typeof navigator>"u")return {hit:false,weight:.7};let t=navigator.userAgent??"",e=Yo.some(n=>n.test(t));return e?{hit:e,weight:.7,detail:`headless UA: ${t}`}:{hit:e,weight:.7}},os=()=>{if(typeof navigator>"u")return {hit:false,weight:.15};let t=navigator.languages;return {hit:!t||t.length===0,weight:.15,detail:"navigator.languages empty"}},ss=()=>{if(typeof navigator>"u")return {hit:false,weight:.1};let t="chrome"in window,e=navigator.userAgent??"";return {hit:/Chrome\//.test(e)&&!/Edg\//.test(e)&&!t,weight:.2,detail:"Chrome UA without window.chrome"}},is={webdriver:Xo,chromedriver:Qo,automationGlobals:ts,headlessUa:rs,languages:os,permissions:ss,plugins:ns},Ye=(t={})=>{let{threshold:e=.4}=t,n={},r=0,o=0;for(let[i,a]of Object.entries(is)){let u=a();r+=u.weight,n[i]={hit:u.hit,weight:u.weight,detail:u.detail},u.hit&&(o+=u.weight);}let s=r===0?0:o/r;return s<e?null:{class:"dom",trust:"detected",confidence:s,vendor:null,userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:M,signals:n}};var yn=()=>[{id:"webmcp.model-context",status:"stable",detect:()=>Je({pollMs:0})},{id:"crawler.user-agent",status:"beta",detect:()=>qe()},{id:"dom.automation-heuristics",status:"beta",detect:()=>Ye()}],St=(t=yn())=>{let e=new Map(t.map(n=>[n.id,n]));return {register(n){e.set(n.id,n);},list(n){let r=[...e.values()];return n?r.filter(o=>o.status===n):r},async detectAll(n=false){for(let r of e.values()){if(r.status==="research"&&!n)continue;let o=await r.detect();if(o)return o}return null}}};var hn=async(t={})=>{if(t.customDetectors?.length){let e=await St(t.customDetectors).detectAll(!!t.experimental);if(e)return e}if(t.webmcp!==false){let e=await Je(t.webmcp??{});if(e)return e}if(t.crawler!==false){let e=qe(t.crawler??{});if(e)return e}if(t.dom!==false){let e=Ye(t.dom??{});if(e)return e}return null};var as=new Set(["1024x768","1280x800","1280x720","1280x1024","1440x900","1920x1080"]),cs=t=>{if(t.length<6)return null;let e=t.reduce((r,o)=>r+o,0)/t.length;if(e<=0)return null;let n=t.reduce((r,o)=>r+(o-e)**2,0)/t.length;return Math.sqrt(n)/e},vn=t=>{let e=0;return t.clicks>=2&&(e+=.35*(t.teleportClicks/t.clicks),e+=.25*(t.centreClicks/t.clicks),t.pointerMoves===0&&(e+=.15)),t.keyIntervalCv!==null&&t.keyIntervalCv<.15&&(e+=.2),t.insertWithoutKeys>0&&(e+=.15),t.wheelEvents===0&&t.clicks>=3&&(e+=.05),t.vmViewport&&(e+=.1),Math.min(1,e)},xn=(t={})=>{let{threshold:e=.6,minInteractions:n=3,onDetect:r,acceptUntrustedEvents:o=false}=t,s=C=>C.isTrusted||o,i=t.documentRef??(typeof document>"u"?void 0:document),a={clicks:0,teleportClicks:0,centreClicks:0,keyIntervals:0,keyIntervalCv:null,insertWithoutKeys:0,pointerMoves:0,wheelEvents:0,vmViewport:false},u=Number.NEGATIVE_INFINITY,c=0,d=0,y=[],v=0,w=null,T=i?.defaultView;T&&(a.vmViewport=as.has(`${T.innerWidth}x${T.innerHeight}`));let m=C=>({class:"screenshot",trust:"detected",confidence:Number(C.toFixed(2)),vendor:null,userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:M,signals:{vision:true,...a}}),k=()=>{if(w||a.clicks+v<n)return;let C=vn(a);C>=e&&(w=m(C),r?.(w));},A=C=>{s(C)&&(a.pointerMoves+=1,u=C.timeStamp);},Qe=[["pointermove",A],["mousemove",A],["wheel",C=>{s(C)&&(a.wheelEvents+=1);}],["click",C=>{if(!s(C))return;let P=C;a.clicks+=1,C.timeStamp-u>400&&(a.teleportClicks+=1);let Ue=P.target instanceof Element?P.target:null;if(Ue&&typeof Ue.getBoundingClientRect=="function"){let ee=Ue.getBoundingClientRect();if(ee.width>8&&ee.height>8){let te=Math.abs(P.clientX-(ee.left+ee.width/2)),ie=Math.abs(P.clientY-(ee.top+ee.height/2));te<=1.5&&ie<=1.5&&(a.centreClicks+=1);}}k();}],["keydown",C=>{if(!s(C))return;let P=C.timeStamp;c&&P-c<1500?(y.push(P-c),y.length>60&&y.shift(),a.keyIntervals=y.length,a.keyIntervalCv=cs(y)):v+=1,c=P,d=P;}],["keyup",()=>k()],["input",C=>{if(!s(C))return;let P=C;P.inputType==="insertText"&&P.data&&P.data.length>1&&C.timeStamp-d>200&&(a.insertWithoutKeys+=1,v+=1,k());}]];for(let[C,P]of Qe)i?.addEventListener(C,P,{capture:true,passive:true});return {signals:()=>({...a}),score:()=>vn(a),detected:()=>w,stop:()=>{for(let[C,P]of Qe)i?.removeEventListener(C,P,{capture:true});}}};var ls=t=>({class:t.class,trust:"declared",confidence:1,vendor:t.vendor,userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:M,signals:{declared:true,hasToken:true,tokenExpiresAt:t.expiresAt??null}}),bn=()=>{let t=null;return {present(e){let n=Ze.safeParse(e);if(!n.success)throw new He("invalid_api_key",`Invalid identity claim: ${n.error.issues[0]?.message??"unknown"}`);let r={claim:n.data,identity:ls(n.data)};return t=r,r},clear(){t=null;},preferOver(e){return t?e?ln(t.identity.trust,e.trust)?t.identity:e:t.identity:e},snapshot(){return t}}};var wn=t=>{let e=null;for(let n of t)(!e||q[n.trust]>q[e.trust])&&(e=n);return e};var kn=()=>({name:"bearer",async authenticate(t,e){if(!t.bearerToken)return null;let n=await e.verifyToken?.("bearer",t.bearerToken);return {class:t.classHint??"dom",trust:n?.trust??"declared",confidence:1,vendor:n?.vendor??t.vendorHint??"bearer",userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:M,signals:{bearer:true,verifiedRemotely:!!n}}}});var _n=()=>({name:"detection",async authenticate(t){return t.detected??null}});var Tn=()=>({name:"extensionToken",async authenticate(t,e){if(!t.extensionToken)return null;let n=await e.verifyToken?.("extensionToken",t.extensionToken);return {class:"dom",trust:n?.trust??"declared",confidence:1,vendor:n?.vendor??t.vendorHint??"browser-extension",userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:M,signals:{extensionToken:true,verifiedRemotely:!!n}}}});var Sn=()=>({name:"mtls",async authenticate(t,e){if(!t.xfccHeader)return null;let n=await e.verifyToken?.("mtls",t.xfccHeader);return {class:t.classHint??"webmcp",trust:n?.trust??"declared",confidence:1,vendor:n?.vendor??t.vendorHint??"mtls",userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:M,signals:{mtls:true,subject:n?.subject??null,verifiedRemotely:!!n,...n?.signals??{}}}}});var An=()=>({name:"oauth2",async authenticate(t,e){if(!t.oauth2AccessToken)return null;let n=await e.verifyToken?.("oauth2",t.oauth2AccessToken);return {class:t.classHint??"webmcp",trust:n?t.oauth2Subject&&n.trust!=="detected"&&n.trust!=="declared"?"linked":n.trust:"declared",confidence:1,vendor:n?.vendor??t.vendorHint??"oauth2",userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:M,signals:{oauth2:true,subject:t.oauth2Subject??null,verifiedRemotely:!!n}}}});var us=t=>({class:t.class,trust:"declared",confidence:1,vendor:t.vendor,userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:M,signals:{declared:true,hasToken:true,tokenExpiresAt:t.expiresAt??null}}),In=()=>({name:"selfDeclaration",async authenticate(t){return t.declaration?us(Ze.parse(t.declaration)):null}});var Rn=()=>({name:"sessionLink",async authenticate(t,e){if(!t.sessionLinkToken)return null;let n=await e.verifyToken?.("sessionLink",t.sessionLinkToken);return {class:t.classHint??"screenshot",trust:n?t.linkedUserId&&n.trust!=="detected"&&n.trust!=="declared"?"linked":n.trust:"declared",confidence:1,vendor:n?.vendor??t.vendorHint??"session-link",userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:M,signals:{sessionLink:true,linkedUserId:t.linkedUserId??null,verifiedRemotely:!!n}}}});var En=()=>({name:"sso",async authenticate(t,e){if(!t.ssoIdToken)return null;let n=await e.verifyToken?.("sso",t.ssoIdToken);return {class:t.classHint??"dom",trust:n?.trust??"declared",confidence:1,vendor:n?.vendor??t.vendorHint??"sso",userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:M,signals:{sso:true,subject:n?.subject??null,verifiedRemotely:!!n,...n?.signals??{}}}}});var Cn=()=>({name:"spiffe",async authenticate(t,e){if(!t.spiffeJwt)return null;let n=await e.verifyToken?.("spiffe",t.spiffeJwt),r=n?.vendor==="google";return {class:t.classHint??"webmcp",trust:n?.trust??"declared",confidence:1,vendor:n?.vendor??t.vendorHint??"spiffe",userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:M,signals:{spiffe:true,spiffeId:n?.subject??null,subject:n?.subject??null,verifiedRemotely:!!n,...r?{googleAgent:true}:{},...n?.signals??{}}}}});var Mn=()=>({name:"xAgentHeader",async authenticate(t){if(!t.xAgentHeader)return null;let[e="x-agent",n="dom",r]=t.xAgentHeader.split(";"),o=Ve.safeParse(n);return {class:o.success?o.data:"dom",trust:"declared",confidence:r?1:.8,vendor:e,userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:M,signals:{xAgentHeader:true,hasProof:!!r}}}});var Pn=new Set(["bearer","extensionToken","sessionLink","oauth2","sso","spiffe","mtls"]),ds=(t,e,n)=>{if(Pn.has(t)&&e.signals?.verifiedRemotely===false){let r=t==="oauth2"&&n.oauth2Subject||t==="sessionLink"&&n.linkedUserId;return {...e,trust:r?"linked":"verified",signals:{...e.signals,compat:"0.6"}}}return t==="xAgentHeader"&&e.signals?.hasProof===true?{...e,trust:"verified",confidence:1,signals:{...e.signals,compat:"0.6"}}:e},On=()=>[_n(),In(),kn(),Mn(),Tn(),Rn(),An()],ps=()=>[En(),Cn(),Sn()],fs={detection:"detection",selfDeclaration:"declaration",bearer:"bearer",xAgentHeader:"x-agent-header",extensionToken:"extension",sessionLink:"session-link",oauth2:"oauth2",sso:"sso",spiffe:"spiffe",mtls:"mtls"},ms=(t,e)=>t==="spiffe"&&e.signals?.googleAgent===true?"google-agent":fs[t],Dn=({compat:t,methods:e=t==="0.6"?[...On(),...ps()]:On(),context:n={},onTrace:r,onUnverifiedToken:o}={})=>{let s=false;return {async authenticate(i){let a=[],u={};for(let T of e){let m=await T.authenticate(i,n);u[T.name]=!!m,m&&(Pn.has(T.name)&&m.signals?.verifiedRemotely===false&&!n.verifyToken&&!s&&(s=true,o?.(T.name)),t==="0.6"&&(m=ds(T.name,m,i)),a.push({method:T.name,identity:m}));}let c=wn(a.map(T=>T.identity)),d=c?a.find(T=>T.identity===c):void 0,y=d?ms(d.method,d.identity):void 0,v=typeof c?.signals?.subject=="string"?c.signals.subject:void 0,w={type:c?"auth.identity_presented":"sdk.error",agent:c,outcome:c?"success":"error",metadata:{methods:u,...y?{protocol:y}:{},...v?{subject:v}:{}}};return c||(w.error="No auth method produced an identity."),r?.(w),c},methods(){return e.map(i=>i.name)}}};var gs={identity:null,source:"initial",updatedAt:null},jn=()=>{let t=gs,e=new Set,n=()=>{e.size!==0&&e.forEach(r=>r(t));};return {snapshot(){return t},set(r,o){t={identity:r,source:o,updatedAt:new Date().toISOString()},n();},subscribe(r){return e.add(r),()=>{e.delete(r);}}}};var ys=()=>{let t=new Map;return {read:e=>t.get(e)??null,write:(e,n)=>{t.set(e,n);}}},hs=()=>typeof window>"u"||!window.localStorage?ys():{read:t=>{try{return window.localStorage.getItem(t)}catch{return null}},write:(t,e)=>{try{window.localStorage.setItem(t,e);}catch{}}},vs=t=>{if(!t)return null;try{let e=JSON.parse(t);if(typeof e=="object"&&e!==null&&Number.isFinite(e.count)&&Number.isFinite(e.resetAt))return e}catch{return null}return null},Nn=(t=hs())=>({consume(e,n,r=Date.now()){let o=`agtx:rate:${e}`,s=vs(t.read(o)),i=s&&s.resetAt>r?s.resetAt:r+n.windowSeconds*1e3,a=s&&s.resetAt>r?s.count+1:1;return t.write(o,JSON.stringify({count:a,resetAt:i})),{allowed:a<=n.max,remaining:Math.max(0,n.max-a),resetAt:i}}});var xs=(t,e)=>t==="*"||t===e?true:t.includes("*")?new RegExp("^"+t.replace(/[.+?^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*")+"$").test(e):false,bs=(t,e)=>{let n=t?q[t.trust]:-1,r=q[e.minTrust];return n>=r},ws=(t,e)=>e.allowedClasses.length===0?true:t?e.allowedClasses.includes(t.class):false,$n="allow",ks=(t,e)=>{let n=e?.class??"unknown",r=e?.vendor??"unknown",o=e?.trust??"none";return `${t}:${n}:${r}:${o}`},Ln=(t=[],e={})=>{let n=t.map(o=>Ce.parse(o)),r=e.rateLimiter??Nn();return {set(o){n=o.map(s=>Ce.parse(s));},list(){return [...n]},evaluate({tool:o,identity:s}){for(let i of n)if(xs(i.tool,o)){if(!bs(s,i))return {decision:"deny",ruleId:i.id,reason:`Rule "${i.id}" requires trust >= ${i.minTrust}.`};if(!ws(s,i))return {decision:"deny",ruleId:i.id,reason:`Rule "${i.id}" restricts to classes: ${i.allowedClasses.join(", ")}.`};if(i.rateLimit){let a=r.consume(ks(o,s),i.rateLimit);if(!a.allowed)return {decision:"deny",ruleId:i.id,reason:`Rule "${i.id}" rate limit exceeded. Resets at ${new Date(a.resetAt).toISOString()}.`}}return {decision:i.decision,ruleId:i.id,reason:`Matched rule "${i.id}".`}}return {decision:$n,ruleId:null,reason:`No rule matched tool "${o}". Falling back to "${$n}".`}}}};var Wn=({gatewayUrl:t,siteId:e,publishableKey:n,fetcher:r=fetch})=>{let o={policies:[],etag:null};return {snapshot(){return {policies:[...o.policies],etag:o.etag}},async sync(){let s=await r(`${t.replace(/\/$/,"")}/v1/pub/sites/${encodeURIComponent(e)}/policies`,{headers:{authorization:`Bearer ${n}`,...o.etag?{"if-none-match":o.etag}:{}}});if(s.status===304)return this.snapshot();if(!s.ok)throw new Error(`Policy sync failed with status ${s.status}.`);let i=await s.json();return o={policies:Ce.array().parse(i.policies??[]),etag:s.headers.get("etag")},this.snapshot()}}};var Bn=({message:t="Agent action blocked by site policy.",durationMs:e=2400,documentRef:n=typeof document>"u"?void 0:document}={})=>{if(!n?.body)return null;let r=n.createElement("div");return r.setAttribute("role","status"),r.setAttribute("data-agentronics-deny-overlay","true"),r.textContent=t,Object.assign(r.style,{position:"fixed",zIndex:"2147483647",left:"50%",bottom:"24px",transform:"translateX(-50%)",maxWidth:"min(520px, calc(100vw - 32px))",padding:"12px 16px",borderRadius:"12px",background:"#0B0B0C",color:"#FFFFFF",border:"2px solid #FF4D1F",font:"13px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace"}),n.body.appendChild(r),window.setTimeout(()=>r.remove(),e),r};var Vn=({policyEngine:t,getIdentity:e,documentRef:n=typeof document>"u"?void 0:document,selector:r="[data-agentronics-tool]"})=>{if(!n)return {uninstall:()=>{}};let o=s=>{let i=s.target instanceof Element?s.target.closest(r):null;if(!(i instanceof HTMLElement))return;let a=i.dataset.agentronicsTool;a&&Promise.resolve(e()).then(u=>{let c=t.evaluate({tool:a,identity:u});c.decision==="deny"&&(s.preventDefault(),s.stopPropagation(),Bn({message:c.reason,documentRef:n}));});};return n.addEventListener("click",o,true),{uninstall:()=>n.removeEventListener("click",o,true)}};var At=()=>{let t=new Map;return {read:e=>t.get(e)??null,write:(e,n)=>{t.set(e,n);},remove:e=>{t.delete(e);},keys:()=>[...t.keys()]}},Un=(t,e)=>({read:n=>{try{return t.getItem(e+n)}catch{return null}},write:(n,r)=>{try{t.setItem(e+n,r);}catch{}},remove:n=>{try{t.removeItem(e+n);}catch{}},keys:()=>{let n=[];try{for(let r=0;r<t.length;r++){let o=t.key(r);o&&o.startsWith(e)&&n.push(o.slice(e.length));}}catch{}return n}}),zn="agtx:",Gn=()=>{let t=typeof window<"u",e=t&&typeof window.sessionStorage<"u"?Un(window.sessionStorage,zn+"session:"):At(),n=t&&typeof window.localStorage<"u"?Un(window.localStorage,zn+"user:"):At();return {session:e,user:n,org:At()}};var Fn=(t,e)=>t.expiresAt!==null&&t.expiresAt<=e,Kn=t=>{if(!t)return null;try{let e=JSON.parse(t);return typeof e!="object"||e===null?null:e}catch{return null}},_s=t=>JSON.stringify(t),Zn=(t={})=>{let e=Gn(),n=u=>{t.onTrace?.(u);};return {get:(u,c={})=>{let d=c.scope??"session",y=e[d],v=Kn(y.read(u));if(!v){n({type:"memory.accessed",metadata:{operation:"get",key:u,scope:d,hit:false}});return}if(Fn(v,Date.now())){y.remove(u),n({type:"memory.accessed",metadata:{operation:"get",key:u,scope:d,hit:false,expired:true}});return}return n({type:"memory.accessed",metadata:{operation:"get",key:u,scope:d,hit:true}}),v.value},set:(u,c,d={})=>{let y=d.scope??"session",v=d.ttlSeconds??null,w=Date.now(),T={value:c,expiresAt:v===null?null:w+v*1e3,updatedAt:new Date(w).toISOString()};return e[y].write(u,_s(T)),n({type:"memory.updated",metadata:{operation:"set",key:u,scope:y,ttlSeconds:v}}),vt.parse({key:u,value:c,scope:y,ttlSeconds:v,updatedAt:T.updatedAt})},remove:(u,c={})=>{let d=c.scope??"session";e[d].remove(u),n({type:"memory.updated",metadata:{operation:"remove",key:u,scope:d}});},list:(u={})=>{let c=u.scope??"session",d=e[c],y=Date.now(),v=[];for(let w of d.keys()){let T=Kn(d.read(w));if(T){if(Fn(T,y)){d.remove(w);continue}v.push(vt.parse({key:w,value:T.value,scope:c,ttlSeconds:T.expiresAt===null?null:Math.max(0,Math.round((T.expiresAt-y)/1e3)),updatedAt:T.updatedAt}));}}return n({type:"memory.accessed",metadata:{operation:"list",scope:c,count:v.length}}),v},clear:(u={})=>{let c=u.scope??"session",d=e[c],y=d.keys().length;for(let v of d.keys())d.remove(v);n({type:"memory.updated",metadata:{operation:"clear",scope:c,count:y}});}}};var It=t=>U.parse(JSON.parse(JSON.stringify(t))),at=t=>({...t,updatedAt:new Date().toISOString()}),Hn=(t={})=>{let e=U.parse({...dn,...t.initial??{}}),n=null,r=new Set,o=m=>{t.onTrace?.(m);},s=()=>{n=null;},i=()=>{if(r.size===0)return;let m=It(e);n=m,r.forEach(k=>k(m));},a=m=>{let k=U.parse({...e,...m,workflows:{...e.workflows,...m.workflows??{}},policies:{...e.policies,...m.policies??{}},uiGuidance:{...e.uiGuidance,...m.uiGuidance??{}},pageContexts:{...e.pageContexts,...m.pageContexts??{}}});return e=at(k),s(),o({type:"memory.updated",metadata:{kind:"site",operation:"provide",keys:Object.keys(m)}}),i(),d()},u=(m,k)=>{let A=m.split(".").filter(Boolean);if(A.length===0)throw new Error("siteMemory.update() requires a non-empty dot-path.");let D=JSON.parse(JSON.stringify(e)),L=D;for(let z=0;z<A.length-1;z++){let N=A[z],G=L[N];(typeof G!="object"||G===null||Array.isArray(G))&&(L[N]={}),L=L[N];}return L[A[A.length-1]]=k,e=at(U.parse(D)),s(),o({type:"memory.updated",metadata:{kind:"site",operation:"update",path:m}}),i(),d()},c=m=>{let k=xt.parse({path:m.path,payload:m.payload,updatedAt:new Date().toISOString()});return e=at({...e,pageContexts:{...e.pageContexts,[m.path]:k}}),s(),o({type:"memory.updated",metadata:{kind:"site",operation:"provideForPage",path:m.path}}),i(),{...k,payload:{...k.payload}}},d=()=>(n||(n=It(e)),n);return {provide:a,update:u,provideForPage:c,snapshot:d,get:m=>{if(o({type:"memory.accessed",metadata:{kind:"site",operation:m?"get":"snapshot",path:m??null}}),!m)return It(e);let k=m.split(".").filter(Boolean),A=e;for(let D of k){if(typeof A!="object"||A===null)return;A=A[D];}return A},getForPage:m=>{o({type:"memory.accessed",metadata:{kind:"site",operation:"getForPage",path:m}});let k=e.pageContexts[m];return k?{...k,payload:{...k.payload}}:null},replace:m=>(e=at(U.parse(m)),s(),i(),d()),subscribe:m=>(r.add(m),()=>{r.delete(m);})}};var Jn=({gatewayUrl:t,siteId:e,publishableKey:n,fetcher:r=fetch})=>{let o={memory:null,etag:null};return {snapshot(){return {memory:o.memory?U.parse(o.memory):null,etag:o.etag}},async sync(){let s=await r(`${t.replace(/\/$/,"")}/v1/pub/sites/${encodeURIComponent(e)}/memory`,{headers:{authorization:`Bearer ${n}`,...o.etag?{"if-none-match":o.etag}:{}}});if(s.status===304)return this.snapshot();if(!s.ok)throw new Error(`Memory sync failed with status ${s.status}.`);let i=await s.json();return o={memory:U.parse(i.memory??{}),etag:s.headers.get("etag")},this.snapshot()}}};var de="agent-context-",Rt="agentronics-site-context",Ts=t=>{try{return JSON.stringify(t)}catch{return "{}"}},ct=(t,e,n)=>{let r=t.querySelector(`meta[name="${e}"]`);r||(r=t.createElement("meta"),r.setAttribute("name",e),t.head.appendChild(r)),r.setAttribute("content",n);},lt=(t,e)=>{t.querySelectorAll(`meta[name="${e}"]`).forEach(n=>n.remove());},Et=({doc:t=typeof document>"u"?null:document,snapshot:e,schemaType:n="WebSite"})=>{if(!t)return {uninstall:()=>{}};ct(t,`${de}version`,e.version),ct(t,`${de}updated-at`,e.updatedAt??new Date().toISOString()),e.siteMap?.navigation?.flow&&ct(t,`${de}flow`,e.siteMap.navigation.flow),ct(t,`${de}workflows`,Object.keys(e.workflows).join(","));let r=t.getElementById(Rt);return r||(r=t.createElement("script"),r.type="application/ld+json",r.id=Rt,t.head.appendChild(r)),r.textContent=Ts({"@context":"https://schema.org","@type":n,name:"Agentronics Site Memory",agentronics:e}),{uninstall:()=>{lt(t,`${de}version`),lt(t,`${de}updated-at`),lt(t,`${de}flow`),lt(t,`${de}workflows`),t.getElementById(Rt)?.remove();}}};var qn="agentronics-memory-overlay",Ss=t=>`
|
|
2
2
|
position: fixed;
|
|
3
3
|
bottom: 16px;
|
|
4
4
|
right: 16px;
|
|
@@ -12,7 +12,7 @@ border-radius: 10px;
|
|
|
12
12
|
z-index: 2147483647;
|
|
13
13
|
opacity: ${t?"0":"1"};
|
|
14
14
|
pointer-events: ${t?"none":"auto"};
|
|
15
|
-
`,qn=t=>{let e=t.siteMap?.pages?.length??0,n=Object.keys(t.workflows).length,r=Object.keys(t.uiGuidance).length;return `Agentronics site memory \xB7 pages:${e} \xB7 workflows:${n} \xB7 ui-hints:${r}`},Ct=({doc:t=typeof document>"u"?null:document,snapshot:e,hidden:n=false})=>{if(!t)return {uninstall:()=>{},refresh:()=>{}};let r=t.getElementById(Jn);return r||(r=t.createElement("div"),r.id=Jn,r.setAttribute("role","note"),r.setAttribute("aria-label","Agentronics site memory summary"),r.setAttribute("data-agent-context","overlay"),t.body.appendChild(r)),r.setAttribute("style",_s(n)),r.textContent=qn(e),{uninstall:()=>{r?.remove();},refresh:o=>{r&&(r.textContent=qn(o));}}};var Yn="/.well-known/agent-context.json",Mt=async({origin:t,fetcher:e=fetch,signal:n}={})=>{let r=(t?t.replace(/\/$/,""):typeof window<"u"?window.location.origin:"")+Yn;if(!r.startsWith("http"))return null;let o={headers:{accept:"application/json"}};n!==void 0&&(o.signal=n);let s=await e(r,o);if(!s.ok){if(s.status===404)return null;throw new Error(`well-known agent-context fetch failed with status ${s.status}.`)}let i=await s.json();return V.parse(i)};var Xn=({evaluate:t,setPolicies:e,listPolicies:n,onTrace:r,identityResolver:o,reviewer:s})=>{let i=new Map,a=new Set,d=c=>{if(!c.authz||!e||!n)return;let p={id:`tool:${c.name}`,tool:c.name,...c.authz,rateLimit:c.rateLimit??c.authz.rateLimit};e([...n().filter(h=>h.id!==p.id),p]);};return {register(c){return i.set(c.name,c),a.delete(c.name),d(c),r?.({type:"tool.registered",tool:c.name,metadata:{version:c.version??null,group:c.group??null,stage:c.stage??null}}),()=>{i.delete(c.name),a.delete(c.name);}},unregister(c){i.delete(c),a.delete(c);},enable(c){!i.has(c)||!a.has(c)||(a.delete(c),r?.({type:"tool.surfaced",tool:c,metadata:{state:"enabled"}}));},disable(c){!i.has(c)||a.has(c)||(a.add(c),r?.({type:"tool.surfaced",tool:c,metadata:{state:"disabled"}}));},isEnabled:c=>i.has(c)&&!a.has(c),list({includeDisabled:c=false}={}){let p=[...i.values()];return c?p:p.filter(h=>!a.has(h.name))},get:c=>i.get(c),async execute(c,p,h,v={}){let _=h===void 0?o?.()??null:h,x=i.get(c);if(!x)throw new Error(`Tool "${c}" is not registered.`);if(a.has(c)){let S={decision:"deny",ruleId:`tool:${c}`,reason:"Tool is disabled."};throw r?.({type:"tool.executed",tool:c,agent:_,policy:S,outcome:"blocked"}),new Error(S.reason)}let m=await t(c,{identity:_});if(m.decision==="deny")throw r?.({type:"tool.executed",tool:c,agent:_,policy:m,outcome:"blocked"}),new Error(m.reason);if(m.decision==="review"){let S={tool:c,input:p,identity:_,reason:m.reason};x.title!==void 0&&(S.title=x.title),x.description!==void 0&&(S.description=x.description);let D=s?await s(S).catch(()=>false):false;if(r?.({type:"authz.evaluated",tool:c,agent:_,policy:m,outcome:D?"success":"blocked",metadata:{review:true,approved:D,reviewer:s?"configured":"none"}}),!D){let U={...m,decision:"deny",reason:s?"The person on the page did not approve this action.":"This action needs review and no reviewer is configured."};throw r?.({type:"tool.executed",tool:c,agent:_,policy:U,outcome:"blocked"}),new Error(U.reason)}m={...m,reason:`${m.reason} Approved by the person on the page.`};}let A=Date.now();try{let S={identity:_};v.signal&&(S.signal=v.signal);let D=await x.execute(p,S);return r?.({type:"tool.executed",tool:c,agent:_,policy:m,outcome:"success",durationMs:Date.now()-A}),D}catch(S){throw r?.({type:"tool.executed",tool:c,agent:_,policy:m,outcome:"error",durationMs:Date.now()-A,error:S instanceof Error?S.message:String(S)}),S}}}};var dt=t=>t===null||typeof t!="object"?JSON.stringify(t):Array.isArray(t)?`[${t.map(dt).join(",")}]`:`{${Object.keys(t).sort().map(n=>`${JSON.stringify(n)}:${dt(t[n])}`).join(",")}}`,Qn=t=>({name:t.name,...t.title?{title:t.title}:{},description:t.description??t.name,...t.inputSchema?{inputSchema:t.inputSchema}:{},...t.annotations?{annotations:t.annotations}:{}}),er=t=>Math.ceil(dt(Qn(t)).length/4),Ts=t=>{let e=dt(Qn(t)).length;return {name:t.name,characters:e,tokens:Math.ceil(e/4)}},tr=t=>{let e=t.map(Ts);return {total:e.reduce((r,o)=>r+o.tokens,0),perTool:e}};var nr=t=>{let e={name:t.name,description:t.description??"",inputSchema:t.inputSchema??{},tokens:0};return t.title&&(e.title=t.title),t.annotations&&(e.annotations={...t.annotations}),t.group&&(e.group=t.group),t.stage&&(e.page=t.stage),t.outputSchema&&(e.outputSchema=t.outputSchema),e.tokens=er(t),e},rr=({gatewayUrl:t,siteId:e,publishableKey:n,fetcher:r=fetch})=>({async push(o){let s=o.map(nr),i=await r(`${t.replace(/\/$/,"")}/v1/pub/sites/${encodeURIComponent(e)}/tools`,{method:"PUT",headers:{authorization:`Bearer ${n}`,"content-type":"application/json"},body:JSON.stringify({registry:{tools:s}})});if(!i.ok)throw new Error(`Tool sync failed with status ${i.status}.`);return s.length}});var or=(t,e={})=>{let n=new Map;for(let i of t.stages)n.set(i.name,i);if(!n.has(t.initial))throw new Error(`Initial stage "${t.initial}" is not declared in progression stages.`);let r=t.initial,o=()=>{let i=n.get(r);return i?.enables?[r,...i.enables]:[r]},s=(i,a)=>{let d=r;if(!n.has(i))throw new Error(`Cannot transition to unknown stage "${i}".`);return i===r?{changed:false,from:d,to:i}:(r=i,e.onTrace?.({type:"tool.progressed",metadata:{from:d,to:i,trigger:a}}),{changed:true,from:d,to:i})};return {current:()=>r,enabledStages:()=>o(),notify(i){let d=n.get(r)?.transitions?.find(c=>c.on===i);return d?s(d.to,i):{changed:false,from:r,to:r}},set(i){return s(i,"manual")},reset(){let i=r;r=t.initial,i!==r&&e.onTrace?.({type:"tool.progressed",metadata:{from:i,to:r,trigger:"reset"}});},snapshot:()=>({current:r,enabled:o()})}};var Ss=(t,e)=>{let n=t.authz?.minTrust;return n?e?q[e.trust]<q[n]?{ok:false,reason:`trust-too-low:${e.trust}<${n}`}:{ok:true,reason:"trust-ok"}:{ok:false,reason:`requires-trust:${n}`}:{ok:true,reason:"no-trust-floor"}},As=(t,e)=>{let n=t.authz?.allowedClasses??[];return n.length===0?{ok:true,reason:"no-class-restriction"}:e?n.includes(e.class)?{ok:true,reason:"class-ok"}:{ok:false,reason:`class-not-allowed:${e.class}`}:{ok:false,reason:`requires-class:${n.join("|")}`}},Is=(t,e)=>t.stage?e.enabledStages&&e.enabledStages.includes(t.stage)?{ok:true,reason:`stage-enabled:${t.stage}`}:e.stage===t.stage?{ok:true,reason:`stage-active:${t.stage}`}:{ok:false,reason:`stage-locked:${t.stage}`}:{ok:true,reason:"no-stage"},sr=(t,e)=>{let n=Ss(t,e.identity);if(!n.ok)return {tool:t,visible:false,reason:n.reason};let r=As(t,e.identity);if(!r.ok)return {tool:t,visible:false,reason:r.reason};let o=Is(t,e);return o.ok?t.authz?.decision==="deny"?{tool:t,visible:false,reason:"authz-deny"}:{tool:t,visible:true,reason:"visible"}:{tool:t,visible:false,reason:o.reason}},ir=(t,e)=>t.filter(n=>sr(n,e).visible),ar=(t,e)=>t.map(n=>sr(n,e));var Rs="default",cr=t=>{let e=new Map;for(let n of t){let r=n.group??Rs,o=e.get(r)??[];o.push(n),e.set(r,o);}return [...e.entries()].sort(([n],[r])=>n.localeCompare(r)).map(([n,r])=>({name:n,tools:r}))};var Es=(t,e)=>t==="legacy",Cs=(t,e)=>{let n={name:t.name,description:t.description??t.name,execute:(r,{signal:o})=>e(t,r??{},o)};return t.title!==void 0&&(n.title=t.title),t.inputSchema!==void 0&&(n.inputSchema=t.inputSchema),t.annotations!==void 0&&(n.annotations={...t.annotations}),n},lr=(t={})=>{let e=t.invoke??(async(c,p)=>c.execute(p,{identity:null})),n=null,r=null,o=null,s=[],i=()=>{let c=t.modelContext??t.provider;return c?{source:typeof c.registerTool=="function"?"document":"legacy",context:c}:it(t.host)},a=()=>{n?.abort(),n=null,r?.revoke(),r=null;},d=c=>{if(o||typeof c.addEventListener!="function")return;let p=v=>Tt("activated",v.toolName??""),h=v=>Tt("cancelled",v.toolName??"");c.addEventListener("toolactivated",p),c.addEventListener("toolcancel",h),o=()=>{c.removeEventListener?.("toolactivated",p),c.removeEventListener?.("toolcancel",h),o=null;};};return {publish(c){let p=i();if(!p)return {revoked:false,registrations:Promise.resolve([])};if(a(),Es(p.source,p.context))return r=p.context.provideContext({tools:c.map(x=>{let m={name:x.name,invoke:A=>e(x,A)};return x.description!==void 0&&(m.description=x.description),x.inputSchema!==void 0&&(m.inputSchema=x.inputSchema),m})}),s=c.map(x=>({name:x.name,status:"callable"})),{revoked:true,registrations:Promise.resolve(s)};let h=p.context;d(h);let v=new AbortController;return n=v,{revoked:true,registrations:Promise.all(c.map(async x=>{try{let m={signal:v.signal};return x.exposedTo?.length&&(m.exposedTo=x.exposedTo),await h.registerTool(Cs(x,e),m),{name:x.name,status:"callable"}}catch(m){return {name:x.name,status:"failed",error:m instanceof Error?`${m.name}: ${m.message}`:String(m)}}})).then(x=>(n===v&&(s=x),x))}},revoke(){a(),o?.(),s=[];},available:()=>!!i(),source:()=>i()?.source??null,status:()=>[...s]}};var Ms=t=>t===null||typeof t!="object"?"":Object.entries(t).slice(0,6).map(([n,r])=>`${n}: ${typeof r=="string"?r:JSON.stringify(r)}`.slice(0,90)).join(`
|
|
16
|
-
`),
|
|
17
|
-
`),
|
|
15
|
+
`,Yn=t=>{let e=t.siteMap?.pages?.length??0,n=Object.keys(t.workflows).length,r=Object.keys(t.uiGuidance).length;return `Agentronics site memory \xB7 pages:${e} \xB7 workflows:${n} \xB7 ui-hints:${r}`},Ct=({doc:t=typeof document>"u"?null:document,snapshot:e,hidden:n=false})=>{if(!t)return {uninstall:()=>{},refresh:()=>{}};let r=t.getElementById(qn);return r||(r=t.createElement("div"),r.id=qn,r.setAttribute("role","note"),r.setAttribute("aria-label","Agentronics site memory summary"),r.setAttribute("data-agent-context","overlay"),t.body.appendChild(r)),r.setAttribute("style",Ss(n)),r.textContent=Yn(e),{uninstall:()=>{r?.remove();},refresh:o=>{r&&(r.textContent=Yn(o));}}};var Xn="/.well-known/agent-context.json",Mt=async({origin:t,fetcher:e=fetch,signal:n}={})=>{let r=(t?t.replace(/\/$/,""):typeof window<"u"?window.location.origin:"")+Xn;if(!r.startsWith("http"))return null;let o={headers:{accept:"application/json"}};n!==void 0&&(o.signal=n);let s=await e(r,o);if(!s.ok){if(s.status===404)return null;throw new Error(`well-known agent-context fetch failed with status ${s.status}.`)}let i=await s.json();return U.parse(i)};var Qn=({evaluate:t,setPolicies:e,listPolicies:n,onTrace:r,identityResolver:o,reviewer:s})=>{let i=new Map,a=new Set,u=c=>{if(!c.authz||!e||!n)return;let d={id:`tool:${c.name}`,tool:c.name,...c.authz,rateLimit:c.rateLimit??c.authz.rateLimit};e([...n().filter(y=>y.id!==d.id),d]);};return {register(c){return i.set(c.name,c),a.delete(c.name),u(c),r?.({type:"tool.registered",tool:c.name,metadata:{version:c.version??null,group:c.group??null,stage:c.stage??null}}),()=>{i.delete(c.name),a.delete(c.name);}},unregister(c){i.delete(c),a.delete(c);},enable(c){!i.has(c)||!a.has(c)||(a.delete(c),r?.({type:"tool.surfaced",tool:c,metadata:{state:"enabled"}}));},disable(c){!i.has(c)||a.has(c)||(a.add(c),r?.({type:"tool.surfaced",tool:c,metadata:{state:"disabled"}}));},isEnabled:c=>i.has(c)&&!a.has(c),list({includeDisabled:c=false}={}){let d=[...i.values()];return c?d:d.filter(y=>!a.has(y.name))},get:c=>i.get(c),async execute(c,d,y,v={}){let w=y===void 0?o?.()??null:y,T=i.get(c);if(!T)throw new Error(`Tool "${c}" is not registered.`);if(a.has(c)){let A={decision:"deny",ruleId:`tool:${c}`,reason:"Tool is disabled."};throw r?.({type:"tool.executed",tool:c,agent:w,policy:A,outcome:"blocked"}),new Error(A.reason)}let m=await t(c,{identity:w});if(m.decision==="deny")throw r?.({type:"tool.executed",tool:c,agent:w,policy:m,outcome:"blocked"}),new Error(m.reason);if(m.decision==="review"){let A={tool:c,input:d,identity:w,reason:m.reason};T.title!==void 0&&(A.title=T.title),T.description!==void 0&&(A.description=T.description);let D=s?await s(A).catch(()=>false):false;if(r?.({type:"authz.evaluated",tool:c,agent:w,policy:m,outcome:D?"success":"blocked",metadata:{review:true,approved:D,reviewer:s?"configured":"none"}}),!D){let L={...m,decision:"deny",reason:s?"The person on the page did not approve this action.":"This action needs review and no reviewer is configured."};throw r?.({type:"tool.executed",tool:c,agent:w,policy:L,outcome:"blocked"}),new Error(L.reason)}m={...m,reason:`${m.reason} Approved by the person on the page.`};}let k=Date.now();try{let A={identity:w};v.signal&&(A.signal=v.signal);let D=await T.execute(d,A);return r?.({type:"tool.executed",tool:c,agent:w,policy:m,outcome:"success",durationMs:Date.now()-k}),D}catch(A){throw r?.({type:"tool.executed",tool:c,agent:w,policy:m,outcome:"error",durationMs:Date.now()-k,error:A instanceof Error?A.message:String(A)}),A}}}};var ut=t=>t===null||typeof t!="object"?JSON.stringify(t):Array.isArray(t)?`[${t.map(ut).join(",")}]`:`{${Object.keys(t).sort().map(n=>`${JSON.stringify(n)}:${ut(t[n])}`).join(",")}}`,er=t=>({name:t.name,...t.title?{title:t.title}:{},description:t.description??t.name,...t.inputSchema?{inputSchema:t.inputSchema}:{},...t.annotations?{annotations:t.annotations}:{}}),tr=t=>Math.ceil(ut(er(t)).length/4),As=t=>{let e=ut(er(t)).length;return {name:t.name,characters:e,tokens:Math.ceil(e/4)}},nr=t=>{let e=t.map(As);return {total:e.reduce((r,o)=>r+o.tokens,0),perTool:e}};var rr=t=>{let e={name:t.name,description:t.description??"",inputSchema:t.inputSchema??{},tokens:0};return t.title&&(e.title=t.title),t.annotations&&(e.annotations={...t.annotations}),t.group&&(e.group=t.group),t.stage&&(e.page=t.stage),t.outputSchema&&(e.outputSchema=t.outputSchema),e.tokens=tr(t),e},or=({gatewayUrl:t,siteId:e,publishableKey:n,fetcher:r=fetch})=>({async push(o){let s=o.map(rr),i=await r(`${t.replace(/\/$/,"")}/v1/pub/sites/${encodeURIComponent(e)}/tools`,{method:"PUT",headers:{authorization:`Bearer ${n}`,"content-type":"application/json"},body:JSON.stringify({registry:{tools:s}})});if(!i.ok)throw new Error(`Tool sync failed with status ${i.status}.`);return s.length}});var sr=(t,e={})=>{let n=new Map;for(let i of t.stages)n.set(i.name,i);if(!n.has(t.initial))throw new Error(`Initial stage "${t.initial}" is not declared in progression stages.`);let r=t.initial,o=()=>{let i=n.get(r);return i?.enables?[r,...i.enables]:[r]},s=(i,a)=>{let u=r;if(!n.has(i))throw new Error(`Cannot transition to unknown stage "${i}".`);return i===r?{changed:false,from:u,to:i}:(r=i,e.onTrace?.({type:"tool.progressed",metadata:{from:u,to:i,trigger:a}}),{changed:true,from:u,to:i})};return {current:()=>r,enabledStages:()=>o(),notify(i){let u=n.get(r)?.transitions?.find(c=>c.on===i);return u?s(u.to,i):{changed:false,from:r,to:r}},set(i){return s(i,"manual")},reset(){let i=r;r=t.initial,i!==r&&e.onTrace?.({type:"tool.progressed",metadata:{from:i,to:r,trigger:"reset"}});},snapshot:()=>({current:r,enabled:o()})}};var Is=(t,e)=>{let n=t.authz?.minTrust;return n?e?q[e.trust]<q[n]?{ok:false,reason:`trust-too-low:${e.trust}<${n}`}:{ok:true,reason:"trust-ok"}:{ok:false,reason:`requires-trust:${n}`}:{ok:true,reason:"no-trust-floor"}},Rs=(t,e)=>{let n=t.authz?.allowedClasses??[];return n.length===0?{ok:true,reason:"no-class-restriction"}:e?n.includes(e.class)?{ok:true,reason:"class-ok"}:{ok:false,reason:`class-not-allowed:${e.class}`}:{ok:false,reason:`requires-class:${n.join("|")}`}},Es=(t,e)=>t.stage?e.enabledStages&&e.enabledStages.includes(t.stage)?{ok:true,reason:`stage-enabled:${t.stage}`}:e.stage===t.stage?{ok:true,reason:`stage-active:${t.stage}`}:{ok:false,reason:`stage-locked:${t.stage}`}:{ok:true,reason:"no-stage"},ir=(t,e)=>{let n=Is(t,e.identity);if(!n.ok)return {tool:t,visible:false,reason:n.reason};let r=Rs(t,e.identity);if(!r.ok)return {tool:t,visible:false,reason:r.reason};let o=Es(t,e);return o.ok?t.authz?.decision==="deny"?{tool:t,visible:false,reason:"authz-deny"}:{tool:t,visible:true,reason:"visible"}:{tool:t,visible:false,reason:o.reason}},ar=(t,e)=>t.filter(n=>ir(n,e).visible),cr=(t,e)=>t.map(n=>ir(n,e));var Cs="default",lr=t=>{let e=new Map;for(let n of t){let r=n.group??Cs,o=e.get(r)??[];o.push(n),e.set(r,o);}return [...e.entries()].sort(([n],[r])=>n.localeCompare(r)).map(([n,r])=>({name:n,tools:r}))};var Ms=(t,e)=>t==="legacy",Ot=3e4,Os=t=>{let e=t;if(typeof e=="string")try{e=JSON.parse(e);}catch{return {}}return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:{}},Ps=async t=>{if(t===void 0)return {ok:true};if(typeof Response<"u"&&t instanceof Response){let e=await t.text().catch(()=>""),n=e;try{n=JSON.parse(e);}catch{}return t.ok?n:{error:`Request failed (${t.status})`,detail:typeof n=="string"?n.slice(0,2e3):n}}try{return JSON.parse(JSON.stringify(t))??null}catch{return String(t)}},ur=async(t,e,n,r=Ot)=>{let o=new AbortController,s=false,i,a=()=>o.abort(n?.reason),u=new Promise((c,d)=>{a=()=>{o.abort(n?.reason),d(n?.reason??new DOMException("The agent cancelled the call.","AbortError"));},n?.aborted?a():n?.addEventListener?.("abort",a,{once:true}),r>0&&(i=setTimeout(()=>{s=true,o.abort(),d(new Error("timeout"));},r));});try{let c=await Promise.race([(async()=>t(Os(e),o.signal))(),u]);return await Ps(c)}catch(c){if(s)return {error:`The tool didn't finish within ${Math.round(r/1e3)} s.`,hint:"Try again, or with narrower arguments."};if(n?.aborted)throw c;return {error:c instanceof Error?c.message:String(c)}}finally{i!==void 0&&clearTimeout(i),n?.removeEventListener?.("abort",a);}},Ds=(t,e,n=Ot)=>{let r={name:t.name,description:t.description||t.name,execute:(o,s)=>ur((i,a)=>e(t,i,a),o,s?.signal,n)};return t.title!==void 0&&(r.title=t.title),t.inputSchema!==void 0&&(r.inputSchema=t.inputSchema),t.annotations!==void 0&&(r.annotations={...t.annotations}),r},dr=(t={})=>{let e=t.invoke??(async(d,y,v)=>d.execute(y,v?{identity:null,signal:v}:{identity:null})),n=t.toolTimeoutMs??Ot,r=null,o=null,s=null,i=[],a=()=>{let d=t.modelContext??t.provider;return d?{source:typeof d.registerTool=="function"?"document":"legacy",context:d}:it(t.host)},u=()=>{r?.abort(),r=null,o?.revoke(),o=null;},c=d=>{if(s||typeof d.addEventListener!="function")return;let y=w=>Tt("activated",w.toolName??""),v=w=>Tt("cancelled",w.toolName??"");d.addEventListener("toolactivated",y),d.addEventListener("toolcancel",v),s=()=>{d.removeEventListener?.("toolactivated",y),d.removeEventListener?.("toolcancel",v),s=null;};};return {publish(d){let y=a();if(!y)return {revoked:false,registrations:Promise.resolve([])};if(u(),Ms(y.source,y.context))return o=y.context.provideContext({tools:d.map(m=>{let k={name:m.name,invoke:A=>ur((D,L)=>e(m,D,L),A,void 0,n)};return m.description!==void 0&&(k.description=m.description),m.inputSchema!==void 0&&(k.inputSchema=m.inputSchema),k})}),i=d.map(m=>({name:m.name,status:"callable"})),{revoked:true,registrations:Promise.resolve(i)};let v=y.context;c(v);let w=new AbortController;return r=w,{revoked:true,registrations:Promise.all(d.map(async m=>{try{let k={signal:w.signal};return m.exposedTo?.length&&(k.exposedTo=m.exposedTo),await v.registerTool(Ds(m,e,n),k),{name:m.name,status:"callable"}}catch(k){return {name:m.name,status:"failed",error:k instanceof Error?`${k.name}: ${k.message}`:String(k)}}})).then(m=>(r===w&&(i=m),m))}},revoke(){u(),s?.(),i=[];},available:()=>!!a(),source:()=>a()?.source??null,status:()=>[...i]}};var js=t=>t===null||typeof t!="object"?"":Object.entries(t).slice(0,6).map(([n,r])=>`${n}: ${typeof r=="string"?r:JSON.stringify(r)}`.slice(0,90)).join(`
|
|
16
|
+
`),pr=({documentRef:t=typeof document>"u"?void 0:document,timeoutMs:e=12e4}={})=>n=>new Promise(r=>{if(!t?.body)return r(false);let o=t,s=o.createElement("div");s.setAttribute("data-agentronics-review","true"),Object.assign(s.style,{position:"fixed",inset:"0",zIndex:"2147483647",background:"rgba(11,11,12,0.45)",display:"flex",alignItems:"center",justifyContent:"center",padding:"16px"});let i=o.createElement("div");i.setAttribute("role","dialog"),i.setAttribute("aria-modal","true"),i.setAttribute("aria-label","Approve agent action"),Object.assign(i.style,{width:"min(440px, 100%)",background:"#FFFFFF",color:"#0B0B0C",border:"2px solid #0B0B0C",borderRadius:"16px",padding:"20px",boxShadow:"8px 8px 0 #0B0B0C",font:"14px/1.5 system-ui, -apple-system, 'Segoe UI', sans-serif"});let a=o.createElement("div");a.style.fontWeight="700",a.style.fontSize="16px";let u=n.identity?.vendor??"An AI agent";a.textContent=`${u} wants to ${n.title??n.tool}`;let c=o.createElement("div");c.style.margin="8px 0 0",c.style.color="rgba(11,11,12,0.65)",c.textContent=n.description??"Allow this action on your behalf?";let d=o.createElement("pre"),y=js(n.input);Object.assign(d.style,{display:y?"block":"none",margin:"12px 0 0",padding:"10px 12px",background:"rgba(11,11,12,0.06)",borderRadius:"10px",fontSize:"12px",fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",whiteSpace:"pre-wrap",overflowWrap:"anywhere"}),d.textContent=y;let v=o.createElement("div");Object.assign(v.style,{display:"flex",gap:"8px",justifyContent:"flex-end",marginTop:"16px"});let w=(z,N)=>{let G=o.createElement("button");return G.type="button",G.textContent=z,Object.assign(G.style,{padding:"9px 16px",borderRadius:"10px",border:"2px solid #0B0B0C",background:N?"#D4FF3A":"#FFFFFF",color:"#0B0B0C",boxShadow:N?"3px 3px 0 #0B0B0C":"none",font:"inherit",fontWeight:"650",cursor:"pointer"}),G},T=w("Not now",false),m=w("Allow",true);v.append(T,m),i.append(a,c,d,v),s.append(i);let k=false,A=z=>{k||(k=true,clearTimeout(L),o.removeEventListener("keydown",D,true),s.remove(),r(z));},D=z=>{z.key==="Escape"&&A(false);},L=setTimeout(()=>A(false),e);m.addEventListener("click",()=>A(true)),T.addEventListener("click",()=>A(false)),o.addEventListener("keydown",D,true),o.body.appendChild(s),m.focus();});var Pt=(t=500)=>{let e=[];return {add(n){e.push(n),e.length>t&&e.splice(0,e.length-t);},list(){return [...e]},clear(){e.length=0;}}};var fr=(t,e)=>t===void 0?e:Math.max(0,Math.min(1,t)),Dt=(t={})=>{let e=fr(t.traceRate,1),n=fr(t.errorRate,1),r=t.random??Math.random;return {shouldKeep(o){let s=o.outcome==="error"?n:e;return r()<s}}};var Ns="[REDACTED]",$s=t=>{if(t!==void 0)return JSON.parse(JSON.stringify(t))},jt=(t,e)=>{if(e.length===0||typeof t!="object"||t===null)return;let[n,...r]=e;if(!n)return;if(Array.isArray(t)){for(let s of t)jt(s,e);return}let o=t;if(n in o){if(r.length===0){o[n]=Ns;return}jt(o[n],r);}},Nt=(t,e=[])=>{if(e.length===0)return t;let n=$s(t);for(let r of e)jt(n,r.split(".").filter(Boolean));return n},$t=["metadata.password","metadata.token","metadata.authorization","metadata.cookie"];var Ls=()=>typeof location<"u"&&typeof location.pathname=="string"?location.pathname:void 0,mr=t=>{let e=globalThis.crypto;return e&&"randomUUID"in e?`${t}_${e.randomUUID()}`:`${t}_${Date.now().toString(36)}_${Math.random().toString(36).slice(2)}`},Lt=({siteId:t,bufferSize:e,sessionId:n=mr("ses"),scrubPaths:r=$t,exporters:o=[],onExporterError:s,pageProvider:i=Ls,...a})=>{let u=Pt(e),c=Dt(a),d=()=>{try{return i()}catch{return}};return {sessionId:n,async emit(y){let v={...y.metadata};if(v.page===void 0){let T=d();T!==void 0&&(v.page=T);}let w=bt.parse(Nt({id:mr("trc"),siteId:t,sessionId:n,occurredAt:new Date().toISOString(),outcome:y.outcome??"success",...y,metadata:v},r));return c.shouldKeep(w)?(u.add(w),await Promise.all(o.map(async T=>{try{await T.export([w]);}catch(m){s?.(m,T,w);}})),w):null},list:()=>u.list(),clear:()=>u.clear()}};var Wt=()=>({name:"console",export(t){for(let e of t)console.info("[agentronics:trace]",e.type,e);}});var Bt=({gatewayUrl:t,publishableKey:e,fetcher:n,flushMs:r=2e3,maxBatch:o=50,maxQueue:s=500})=>{let i=`${t.replace(/\/$/,"")}/v1/pub/traces`,a=Math.max(1,Math.min(100,o)),u=[],c=null,d=(v,w)=>{let T=n??(typeof fetch=="function"?fetch:null);if(!T)return Promise.resolve();let m={publishableKey:e,events:v};try{return Promise.resolve(T(i,{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${e}`},body:JSON.stringify(m),...w?{keepalive:!0}:{}})).then(()=>{},()=>{})}catch{return Promise.resolve()}},y=(v=false)=>{c!==null&&(clearTimeout(c),c=null);let w=[];for(;u.length;)w.push(d(u.splice(0,a),v));return Promise.all(w).then(()=>{})};return typeof document<"u"&&typeof document.addEventListener=="function"&&document.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&y(true);}),typeof addEventListener=="function"&&addEventListener("pagehide",()=>{y(true);}),{name:"gateway",export(v){u.push(...v),u.length>s&&(u=u.slice(u.length-s)),u.length>=a?y():c===null&&(c=setTimeout(()=>{y();},r));},flush:y}};var Ws=t=>new Promise(e=>setTimeout(e,t)),Ut=({url:t,fetcher:e=fetch,maxRetries:n=2,queueLimit:r=500})=>({name:"webhook",async export(o){let i=[...Bs(t),...o].slice(-r),a=0;for(;;){let u=await e(t,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({events:i})});if(u.ok){gr(t,[]);return}if(a>=n)throw gr(t,i),new Error(`Webhook exporter failed with status ${u.status}.`);a+=1,await Ws(100*a);}}}),Vt=t=>`agtx:webhook:${t}`,Bs=t=>{if(typeof window>"u"||!window.localStorage)return [];try{let e=window.localStorage.getItem(Vt(t));return e?JSON.parse(e):[]}catch{return []}},gr=(t,e)=>{if(!(typeof window>"u"||!window.localStorage))try{if(e.length===0){window.localStorage.removeItem(Vt(t));return}window.localStorage.setItem(Vt(t),JSON.stringify(e));}catch{}};var Xe="https://api.agentronics.dev",Vs="https://gateway.agentronics.dev",Us=t=>{if(t===void 0||t.replace(/\/$/,"")===Xe||t.replace(/\/$/,"")===Vs)return Xe;let e;try{e=new URL(t);}catch{throw new Error(`Agentronics SDK: \`gatewayUrl\` is not a valid URL: ${t}`)}if(e.hostname==="localhost"||e.hostname==="127.0.0.1")return t;throw new Error(`Agentronics SDK does not support custom API URLs. Omit \`gatewayUrl\` to use the canonical ${Xe}. The only accepted override is a localhost / 127.0.0.1 URL for local development. Got: ${t}`)},zs=t=>{let{publishableKey:e,siteId:n="default",debug:r=false,policies:o=[],trace:s={}}=t,i=Us(t.gatewayUrl),a=cn(e);if(a==="secret")throw new He("wrong_key_kind","A secret key was passed to Agentronics.init(). Browser code must use a publishable key (agtx_pk_*).");if(a!=="publishable")throw new He("invalid_api_key",`Agentronics.init() expected a key starting with "${Be}".`);let u=s.enabled??true,c=[...r?[Wt()]:[],...s.gateway?[Bt({gatewayUrl:i,publishableKey:e})]:[],...s.webhookUrl?[Ut({url:s.webhookUrl})]:[],...s.exporters??[]],d={siteId:n,exporters:u?c:[],onExporterError:(p,x)=>{r&&console.warn(`[agentronics] trace exporter "${x.name}" failed`,p);}};s.bufferSize!==void 0&&(d.bufferSize=s.bufferSize),s.traceRate!==void 0&&(d.traceRate=s.traceRate),s.errorRate!==void 0&&(d.errorRate=s.errorRate),s.scrubPaths!==void 0&&(d.scrubPaths=s.scrubPaths);let y=Lt(d),v=p=>{u&&y.emit(p);},w=bn(),T={onTrace:v};t.auth!==void 0&&(T.context=t.auth),t.compat==="0.6"&&(T.compat="0.6",console.warn("[agentronics] compat: '0.6' is on \u2014 unverified tokens are trusted and review rules run without asking. Remove it once you have upgraded: https://agentronics.dev/docs/guides/upgrade-0-7")),T.onUnverifiedToken=p=>{t.compat!=="0.6"&&console.warn(`[agentronics] A ${p} credential was presented but nothing verifies it, so the agent is 'declared', not 'verified'. Wire auth.verifyToken to your backend: https://agentronics.dev/docs/auth/overview#in-the-browser`);};let m=Dn(T),k=jn(),A=Ln(o),D=Wn({gatewayUrl:i,siteId:n,publishableKey:e}),L=Zn({onTrace:v}),z={onTrace:v};t.siteMemory!==void 0&&(z.initial=t.siteMemory);let N=Hn(z),G=Jn({gatewayUrl:i,siteId:n,publishableKey:e}),Qe=or({gatewayUrl:i,siteId:n,publishableKey:e}),C=async p=>{let x=Date.now(),O=await hn(p),W=w.preferOver(O);return u&&await y.emit({type:W?"agent.detected":"agent.missed",agent:W,durationMs:Date.now()-x,metadata:{detectedClass:O?.class??null,presented:w.snapshot()!==null}}),k.set(W,"detect"),W},P=async(p,x={})=>{let O=Date.now(),W=x.identity!==void 0?x.identity:await C(),H=A.evaluate({tool:p,identity:W});return u&&await y.emit({type:"authz.evaluated",tool:p,agent:W,policy:H,outcome:H.decision==="deny"?"blocked":"success",durationMs:Date.now()-O}),H},Ue=async()=>true,ee=t.review===false?void 0:t.review??(t.compat==="0.6"?Ue:typeof document>"u"?void 0:pr()),te=Qn({evaluate:P,...ee?{reviewer:ee}:{},setPolicies:p=>A.set(p),listPolicies:()=>A.list(),onTrace:v,identityResolver:()=>k.snapshot().identity});for(let p of t.tools??[])te.register(p);let ie=t.progression?sr(t.progression,{onTrace:v}):null,zt=p=>{let x={identity:p};return ie&&(x.stage=ie.current(),x.enabledStages=ie.enabledStages()),x},Gt={...t.toolDescriptions??{}},yr=p=>p.map(x=>{let O=Gt[x.name];return O?{...x,description:O}:x}),pe=p=>yr(ar(te.list(),zt(p))),Ft=p=>{Gt={...p},fe!==null&&(fe=null,dt(pe(k.snapshot().identity)));},fe=null,Kt=p=>p.map(x=>x.name).sort().join(`
|
|
17
|
+
`),dt=p=>{let x=Kt(p);return x===fe?null:(fe=x,Me.publish(p))},Zt=p=>{if(!ie)return;ie.notify(p).changed&&fe!==null&&dt(pe(k.snapshot().identity));},Ht={class:"webmcp",trust:"detected",confidence:1,vendor:null,userAgent:typeof navigator<"u"?navigator.userAgent:null,detectionVersion:M,signals:{source:"navigator.modelContext"}},Me=dr({...t.toolTimeoutMs!==void 0?{toolTimeoutMs:t.toolTimeoutMs}:{},invoke:async(p,x,O)=>{hr(p.name);let W=k.snapshot().identity??Ht,H=await te.execute(p.name,x,W,O?{signal:O}:{});return Zt(p.name),H}}),Jt=p=>{let x=k.snapshot().identity;if(x&&x.trust!=="detected"||x?.class==="webmcp")return;let O={...Ht,signals:{source:Me.source()??"document",tool:p}};k.set(O,"detect"),v({type:"agent.detected",agent:O,metadata:{detectedClass:"webmcp",via:"webmcp-activity"}});},hr=p=>Jt(p);fn(p=>{p.type==="activated"&&Jt(p.toolName);}),k.subscribe(p=>{fe===null||!Me.available()||dt(pe(p.identity));});let pt=t.visionDetection??t.autoDetect!==false,vr=pt===false||typeof document>"u"?null:xn({...pt===true?{}:pt,onDetect:p=>{let x=k.snapshot().identity;x&&(x.trust!=="detected"||x.class==="webmcp")||(k.set(p,"detect"),v({type:"agent.detected",agent:p,metadata:{detectedClass:"screenshot",via:"vision-behaviour"}}));}}),ft=t.autoDetect??true,xr=ft===false?Promise.resolve(null):(async()=>{let p=ft===true?{}:ft;try{return await C(p)}catch(x){return r&&console.warn("[agentronics] autoDetect failed:",x),null}})();return Object.freeze({publishableKey:e,siteId:n,gatewayUrl:i,debug:r,memory:L,siteMemory:N,memoryCache:G,tracer:y,auth:m,agentContext:k,authz:A,policyCache:D,tools:te,progression:ie,webmcp:Me,vision:vr,ready:xr,detect:C,authenticate:async p=>{let x=await m.authenticate(p);return k.set(x,"authenticate"),x},presentIdentity:p=>{let x=w.present(p);return v({type:"auth.identity_presented",agent:x.identity,metadata:{vendor:x.identity.vendor,class:x.identity.class}}),k.set(x.identity,"declare"),x},clearIdentity:()=>{w.clear(),v({type:"auth.identity_cleared"}),k.set(null,"cleared");},presentedIdentity:()=>w.snapshot(),setPolicies:p=>{A.set(p),v({type:"authz.policies_set",metadata:{count:p.length}});},listPolicies:()=>A.list(),syncPolicies:async()=>{let p=await D.sync();return A.set(p.policies),v({type:"authz.policies_set",metadata:{count:p.policies.length,synced:true}}),p.policies},syncSiteMemory:async()=>{let p=await G.sync();return p.memory&&(N.replace(p.memory),v({type:"memory.updated",metadata:{kind:"site",operation:"sync",etag:p.etag}})),p.memory},syncConfig:async()=>{let p=await fetch(`${i.replace(/\/$/,"")}/v1/pub/sites/${encodeURIComponent(n)}/config`,{headers:{authorization:`Bearer ${e}`}});if(!p.ok)throw new Error(`Config sync failed with status ${p.status}.`);let x=await p.json(),O=Ce.array().parse(x.policies??[]);A.set(O),v({type:"authz.policies_set",metadata:{count:O.length,synced:true}});let W=x.siteMemory&&typeof x.siteMemory=="object"&&Object.keys(x.siteMemory).length?N.replace(U.parse(x.siteMemory)):null,H=x.toolDescriptions&&typeof x.toolDescriptions=="object"?x.toolDescriptions:{};return Ft(H),{policies:O,toolDescriptions:H,siteMemory:W}},provideSiteMemory:p=>N.provide(p),provideForPage:p=>{N.provideForPage(p);},installMemoryDelivery:({metaTags:p=true,overlay:x=false}={})=>{let O=[];return p&&O.push(Et({snapshot:N.snapshot()})),x&&O.push(Ct({snapshot:N.snapshot()})),{uninstall:()=>{O.forEach(W=>W.uninstall());}}},fetchWellKnown:async p=>{let x={};p!==void 0&&(x.origin=p);let O=await Mt(x);return O&&(N.replace(O),v({type:"memory.updated",metadata:{kind:"site",operation:"wellKnown",origin:p??null}})),O},installDomEnforcer:()=>Vn({policyEngine:A,getIdentity:()=>C({webmcp:{pollMs:0}})}),registerTool:p=>te.register(p),setToolDescriptions:p=>Ft(p),syncTools:async()=>{let p=te.list({includeDisabled:true}),x=await Qe.push(p);return v({type:"tool.registered",metadata:{operation:"sync",count:x}}),x},surfaceTools:({identity:p=null}={})=>pe(p),explainSurfacing:({identity:p=null}={})=>cr(te.list(),zt(p)),groupedTools:({identity:p=null}={})=>lr(pe(p)),estimateTokens:({identity:p=null}={})=>nr(pe(p)),publishToWebMcp:({identity:p=null}={})=>{let x=pe(p);fe=Kt(x);let O=Me.publish(x),W=O.registrations.then(H=>(H.forEach(ze=>{v({type:"tool.surfaced",tool:ze.name,outcome:ze.status==="callable"?"success":"error",...ze.error?{error:ze.error}:{},metadata:{state:ze.status==="callable"?"published":"failed",source:Me.source(),trust:p?.trust??null}});}),H));return {revoked:O.revoked,surfaced:x.length,registrations:W}},notifyToolInvoked:p=>Zt(p),evaluate:P,traces:()=>y.list(),clearTraces:()=>y.clear(),async ping(){try{let p=await fetch(`${i.replace(/\/$/,"")}/v1/pub/health`,{method:"GET",headers:{authorization:`Bearer ${e}`}});if(!p.ok)return {ok:!1,status:p.status,error:`gateway returned ${p.status}`};let x=await p.json().catch(()=>null)??{};return {ok:!0,status:p.status,body:x}}catch(p){return {ok:false,status:0,error:p instanceof Error?p.message:String(p)}}}})};exports.init=zs;return exports;})({});//# sourceMappingURL=init-only.global.js.map
|
|
18
18
|
//# sourceMappingURL=init-only.global.js.map
|