@agentronics/sdk 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,3 @@
1
- export { A as AgentronicsClient, I as InitOptions, ac as init } from './init-only-6SWFNqud.cjs';
1
+ export { A as AgentronicsClient, I as InitOptions, ac as init } from './init-only-hn-ea3qP.cjs';
2
2
  import '@agentronics/protocol';
3
3
  import './webmcp-C4ikhM4g.cjs';
@@ -1,3 +1,3 @@
1
- export { A as AgentronicsClient, I as InitOptions, ac as init } from './init-only-DrZymcuA.js';
1
+ export { A as AgentronicsClient, I as InitOptions, ac as init } from './init-only-Dm_CIjHa.js';
2
2
  import '@agentronics/protocol';
3
3
  import './webmcp-C4ikhM4g.js';
@@ -1,4 +1,4 @@
1
- var Agentronics=(function(exports){'use strict';var Or=Object.defineProperty;var Pr=(t,e)=>{for(var r in e)Or(t,r,{get:e[r],enumerable:true});};var l={};Pr(l,{BRAND:()=>on,DIRTY:()=>ne,EMPTY_PATH:()=>Nr,INVALID:()=>y,NEVER:()=>Zn,OK:()=>C,ParseStatus:()=>M,Schema:()=>_,ZodAny:()=>X,ZodArray:()=>q,ZodBigInt:()=>oe,ZodBoolean:()=>ae,ZodBranded:()=>De,ZodCatch:()=>ye,ZodDate:()=>ie,ZodDefault:()=>ge,ZodDiscriminatedUnion:()=>Ze,ZodEffects:()=>L,ZodEnum:()=>me,ZodError:()=>O,ZodFirstPartyTypeKind:()=>v,ZodFunction:()=>Fe,ZodIntersection:()=>de,ZodIssueCode:()=>d,ZodLazy:()=>pe,ZodLiteral:()=>fe,ZodMap:()=>Re,ZodNaN:()=>Ee,ZodNativeEnum:()=>he,ZodNever:()=>B,ZodNull:()=>le,ZodNullable:()=>G,ZodNumber:()=>se,ZodObject:()=>P,ZodOptional:()=>$,ZodParsedType:()=>h,ZodPipeline:()=>$e,ZodPromise:()=>Q,ZodReadonly:()=>ve,ZodRecord:()=>Ge,ZodSchema:()=>_,ZodSet:()=>Me,ZodString:()=>Y,ZodSymbol:()=>Ae,ZodTransformer:()=>L,ZodTuple:()=>Z,ZodType:()=>_,ZodUndefined:()=>ce,ZodUnion:()=>ue,ZodUnknown:()=>K,ZodVoid:()=>Ie,addIssueToContext:()=>p,any:()=>hn,array:()=>xn,bigint:()=>un,boolean:()=>Lt,coerce:()=>Vn,custom:()=>Dt,date:()=>dn,datetimeRegex:()=>Pt,defaultErrorMap:()=>F,discriminatedUnion:()=>wn,effect:()=>Dn,enum:()=>On,function:()=>Mn,getErrorMap:()=>we,getParsedType:()=>V,instanceof:()=>cn,intersection:()=>Tn,isAborted:()=>Ue,isAsync:()=>Te,isDirty:()=>Ve,isValid:()=>J,late:()=>an,lazy:()=>En,literal:()=>Cn,makeIssue:()=>je,map:()=>In,nan:()=>ln,nativeEnum:()=>Pn,never:()=>yn,null:()=>mn,nullable:()=>Nn,number:()=>Nt,object:()=>bn,objectUtil:()=>et,oboolean:()=>Un,onumber:()=>Bn,optional:()=>$n,ostring:()=>zn,pipeline:()=>Wn,preprocess:()=>Ln,promise:()=>jn,quotelessJson:()=>jr,record:()=>An,set:()=>Rn,setErrorMap:()=>$r,strictObject:()=>_n,string:()=>$t,symbol:()=>pn,transformer:()=>Dn,tuple:()=>Sn,undefined:()=>fn,union:()=>kn,unknown:()=>gn,util:()=>k,void:()=>vn});var k;(function(t){t.assertEqual=s=>{};function e(s){}t.assertIs=e;function r(s){throw new Error}t.assertNever=r,t.arrayToEnum=s=>{let o={};for(let i of s)o[i]=i;return o},t.getValidEnumValues=s=>{let o=t.objectKeys(s).filter(a=>typeof s[s[a]]!="number"),i={};for(let a of o)i[a]=s[a];return t.objectValues(i)},t.objectValues=s=>t.objectKeys(s).map(function(o){return s[o]}),t.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{let o=[];for(let i in s)Object.prototype.hasOwnProperty.call(s,i)&&o.push(i);return o},t.find=(s,o)=>{for(let i of s)if(o(i))return i},t.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function n(s,o=" | "){return s.map(i=>typeof i=="string"?`'${i}'`:i).join(o)}t.joinValues=n,t.jsonStringifyReplacer=(s,o)=>typeof o=="bigint"?o.toString():o;})(k||(k={}));var et;(function(t){t.mergeShapes=(e,r)=>({...e,...r});})(et||(et={}));var h=k.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),V=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 d=k.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"]),jr=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),O=class t extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n];},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n];};let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e;}format(e){let r=e||function(o){return o.message},n={_errors:[]},s=o=>{for(let i of o.issues)if(i.code==="invalid_union")i.unionErrors.map(s);else if(i.code==="invalid_return_type")s(i.returnTypeError);else if(i.code==="invalid_arguments")s(i.argumentsError);else if(i.path.length===0)n._errors.push(r(i));else {let a=n,c=0;for(;c<i.path.length;){let u=i.path[c];c===i.path.length-1?(a[u]=a[u]||{_errors:[]},a[u]._errors.push(r(i))):a[u]=a[u]||{_errors:[]},a=a[u],c++;}}};return s(this),n}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,k.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){let r={},n=[];for(let s of this.issues)if(s.path.length>0){let o=s.path[0];r[o]=r[o]||[],r[o].push(e(s));}else n.push(e(s));return {formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};O.create=t=>new O(t);var Dr=(t,e)=>{let r;switch(t.code){case d.invalid_type:t.received===h.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case d.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,k.jsonStringifyReplacer)}`;break;case d.unrecognized_keys:r=`Unrecognized key(s) in object: ${k.joinValues(t.keys,", ")}`;break;case d.invalid_union:r="Invalid input";break;case d.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${k.joinValues(t.options)}`;break;case d.invalid_enum_value:r=`Invalid enum value. Expected ${k.joinValues(t.options)}, received '${t.received}'`;break;case d.invalid_arguments:r="Invalid function arguments";break;case d.invalid_return_type:r="Invalid function return type";break;case d.invalid_date:r="Invalid date";break;case d.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:k.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case d.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case d.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case d.custom:r="Invalid input";break;case d.invalid_intersection_types:r="Intersection results could not be merged";break;case d.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case d.not_finite:r="Number must be finite";break;default:r=e.defaultError,k.assertNever(t);}return {message:r}},F=Dr;var Rt=F;function $r(t){Rt=t;}function we(){return Rt}var je=t=>{let{data:e,path:r,errorMaps:n,issueData:s}=t,o=[...r,...s.path||[]],i={...s,path:o};if(s.message!==void 0)return {...s,path:o,message:s.message};let a="",c=n.filter(u=>!!u).slice().reverse();for(let u of c)a=u(i,{data:e,defaultError:a}).message;return {...s,path:o,message:a}},Nr=[];function p(t,e){let r=we(),n=je({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===F?void 0:F].filter(s=>!!s)});t.common.issues.push(n);}var M=class t{constructor(){this.value="valid";}dirty(){this.value==="valid"&&(this.value="dirty");}abort(){this.value!=="aborted"&&(this.value="aborted");}static mergeArray(e,r){let n=[];for(let s of r){if(s.status==="aborted")return y;s.status==="dirty"&&e.dirty(),n.push(s.value);}return {status:e.value,value:n}}static async mergeObjectAsync(e,r){let n=[];for(let s of r){let o=await s.key,i=await s.value;n.push({key:o,value:i});}return t.mergeObjectSync(e,n)}static mergeObjectSync(e,r){let n={};for(let s of r){let{key:o,value:i}=s;if(o.status==="aborted"||i.status==="aborted")return y;o.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),o.value!=="__proto__"&&(typeof i.value<"u"||s.alwaysSet)&&(n[o.value]=i.value);}return {status:e.value,value:n}}},y=Object.freeze({status:"aborted"}),ne=t=>({status:"dirty",value:t}),C=t=>({status:"valid",value:t}),Ue=t=>t.status==="aborted",Ve=t=>t.status==="dirty",J=t=>t.status==="valid",Te=t=>typeof Promise<"u"&&t instanceof Promise;var g;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message;})(g||(g={}));var N=class{constructor(e,r,n,s){this._cachedPath=[],this.parent=e,this.data=r,this._path=n,this._key=s;}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}},Mt=(t,e)=>{if(J(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 r=new O(t.common.issues);return this._error=r,this._error}}};function x(t){if(!t)return {};let{errorMap:e,invalid_type_error:r,required_error:n,description:s}=t;if(e&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(i,a)=>{let{message:c}=t;return i.code==="invalid_enum_value"?{message:c??a.defaultError}:typeof a.data>"u"?{message:c??n??a.defaultError}:i.code!=="invalid_type"?{message:a.defaultError}:{message:c??r??a.defaultError}},description:s}}var _=class{get description(){return this._def.description}_getType(e){return V(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:V(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return {status:new M,ctx:{common:e.parent.common,data:e.data,parsedType:V(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let r=this._parse(e);if(Te(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(e){let r=this._parse(e);return Promise.resolve(r)}parse(e,r){let n=this.safeParse(e,r);if(n.success)return n.data;throw n.error}safeParse(e,r){let n={common:{issues:[],async:r?.async??false,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:V(e)},s=this._parseSync({data:e,path:n.path,parent:n});return Mt(n,s)}"~validate"(e){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:V(e)};if(!this["~standard"].async)try{let n=this._parseSync({data:e,path:[],parent:r});return J(n)?{value:n.value}:{issues:r.common.issues}}catch(n){n?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=true),r.common={issues:[],async:true};}return this._parseAsync({data:e,path:[],parent:r}).then(n=>J(n)?{value:n.value}:{issues:r.common.issues})}async parseAsync(e,r){let n=await this.safeParseAsync(e,r);if(n.success)return n.data;throw n.error}async safeParseAsync(e,r){let n={common:{issues:[],contextualErrorMap:r?.errorMap,async:true},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:V(e)},s=this._parse({data:e,path:n.path,parent:n}),o=await(Te(s)?s:Promise.resolve(s));return Mt(n,o)}refine(e,r){let n=s=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(s):r;return this._refinement((s,o)=>{let i=e(s),a=()=>o.addIssue({code:d.custom,...n(s)});return typeof Promise<"u"&&i instanceof Promise?i.then(c=>c?true:(a(),false)):i?true:(a(),false)})}refinement(e,r){return this._refinement((n,s)=>e(n)?true:(s.addIssue(typeof r=="function"?r(n,s):r),false))}_refinement(e){return new L({schema:this,typeName:v.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:r=>this["~validate"](r)};}optional(){return $.create(this,this._def)}nullable(){return G.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return q.create(this)}promise(){return Q.create(this,this._def)}or(e){return ue.create([this,e],this._def)}and(e){return de.create(this,e,this._def)}transform(e){return new L({...x(this._def),schema:this,typeName:v.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let r=typeof e=="function"?e:()=>e;return new ge({...x(this._def),innerType:this,defaultValue:r,typeName:v.ZodDefault})}brand(){return new De({typeName:v.ZodBranded,type:this,...x(this._def)})}catch(e){let r=typeof e=="function"?e:()=>e;return new ye({...x(this._def),innerType:this,catchValue:r,typeName:v.ZodCatch})}describe(e){let r=this.constructor;return new r({...this._def,description:e})}pipe(e){return $e.create(this,e)}readonly(){return ve.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Lr=/^c[^\s-]{8,}$/i,Wr=/^[0-9a-z]+$/,zr=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Br=/^[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,Ur=/^[a-z0-9_-]{21}$/i,Vr=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Zr=/^[-+]?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)?)??$/,Gr=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Fr="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",tt,Hr=/^(?:(?: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])$/,Kr=/^(?:(?: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])$/,qr=/^(([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]))$/,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]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Yr=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Xr=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Ct="((\\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])))",Qr=new RegExp(`^${Ct}$`);function Ot(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);let r=t.precision?"+":"?";return `([01]\\d|2[0-3]):[0-5]\\d(:${e})${r}`}function en(t){return new RegExp(`^${Ot(t)}$`)}function Pt(t){let e=`${Ct}T${Ot(t)}`,r=[];return r.push(t.local?"Z?":"Z"),t.offset&&r.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${r.join("|")})`,new RegExp(`^${e}$`)}function tn(t,e){return !!((e==="v4"||!e)&&Hr.test(t)||(e==="v6"||!e)&&qr.test(t))}function rn(t,e){if(!Vr.test(t))return false;try{let[r]=t.split(".");if(!r)return !1;let n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),s=JSON.parse(atob(n));return !(typeof s!="object"||s===null||"typ"in s&&s?.typ!=="JWT"||!s.alg||e&&s.alg!==e)}catch{return false}}function nn(t,e){return !!((e==="v4"||!e)&&Kr.test(t)||(e==="v6"||!e)&&Jr.test(t))}var Y=class t extends _{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==h.string){let o=this._getOrReturnCtx(e);return p(o,{code:d.invalid_type,expected:h.string,received:o.parsedType}),y}let n=new M,s;for(let o of this._def.checks)if(o.kind==="min")e.data.length<o.value&&(s=this._getOrReturnCtx(e,s),p(s,{code:d.too_small,minimum:o.value,type:"string",inclusive:true,exact:false,message:o.message}),n.dirty());else if(o.kind==="max")e.data.length>o.value&&(s=this._getOrReturnCtx(e,s),p(s,{code:d.too_big,maximum:o.value,type:"string",inclusive:true,exact:false,message:o.message}),n.dirty());else if(o.kind==="length"){let i=e.data.length>o.value,a=e.data.length<o.value;(i||a)&&(s=this._getOrReturnCtx(e,s),i?p(s,{code:d.too_big,maximum:o.value,type:"string",inclusive:true,exact:true,message:o.message}):a&&p(s,{code:d.too_small,minimum:o.value,type:"string",inclusive:true,exact:true,message:o.message}),n.dirty());}else if(o.kind==="email")Gr.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"email",code:d.invalid_string,message:o.message}),n.dirty());else if(o.kind==="emoji")tt||(tt=new RegExp(Fr,"u")),tt.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"emoji",code:d.invalid_string,message:o.message}),n.dirty());else if(o.kind==="uuid")Br.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"uuid",code:d.invalid_string,message:o.message}),n.dirty());else if(o.kind==="nanoid")Ur.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"nanoid",code:d.invalid_string,message:o.message}),n.dirty());else if(o.kind==="cuid")Lr.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"cuid",code:d.invalid_string,message:o.message}),n.dirty());else if(o.kind==="cuid2")Wr.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"cuid2",code:d.invalid_string,message:o.message}),n.dirty());else if(o.kind==="ulid")zr.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"ulid",code:d.invalid_string,message:o.message}),n.dirty());else if(o.kind==="url")try{new URL(e.data);}catch{s=this._getOrReturnCtx(e,s),p(s,{validation:"url",code:d.invalid_string,message:o.message}),n.dirty();}else o.kind==="regex"?(o.regex.lastIndex=0,o.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"regex",code:d.invalid_string,message:o.message}),n.dirty())):o.kind==="trim"?e.data=e.data.trim():o.kind==="includes"?e.data.includes(o.value,o.position)||(s=this._getOrReturnCtx(e,s),p(s,{code:d.invalid_string,validation:{includes:o.value,position:o.position},message:o.message}),n.dirty()):o.kind==="toLowerCase"?e.data=e.data.toLowerCase():o.kind==="toUpperCase"?e.data=e.data.toUpperCase():o.kind==="startsWith"?e.data.startsWith(o.value)||(s=this._getOrReturnCtx(e,s),p(s,{code:d.invalid_string,validation:{startsWith:o.value},message:o.message}),n.dirty()):o.kind==="endsWith"?e.data.endsWith(o.value)||(s=this._getOrReturnCtx(e,s),p(s,{code:d.invalid_string,validation:{endsWith:o.value},message:o.message}),n.dirty()):o.kind==="datetime"?Pt(o).test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{code:d.invalid_string,validation:"datetime",message:o.message}),n.dirty()):o.kind==="date"?Qr.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{code:d.invalid_string,validation:"date",message:o.message}),n.dirty()):o.kind==="time"?en(o).test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{code:d.invalid_string,validation:"time",message:o.message}),n.dirty()):o.kind==="duration"?Zr.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"duration",code:d.invalid_string,message:o.message}),n.dirty()):o.kind==="ip"?tn(e.data,o.version)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"ip",code:d.invalid_string,message:o.message}),n.dirty()):o.kind==="jwt"?rn(e.data,o.alg)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"jwt",code:d.invalid_string,message:o.message}),n.dirty()):o.kind==="cidr"?nn(e.data,o.version)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"cidr",code:d.invalid_string,message:o.message}),n.dirty()):o.kind==="base64"?Yr.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"base64",code:d.invalid_string,message:o.message}),n.dirty()):o.kind==="base64url"?Xr.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"base64url",code:d.invalid_string,message:o.message}),n.dirty()):k.assertNever(o);return {status:n.value,value:e.data}}_regex(e,r,n){return this.refinement(s=>e.test(s),{validation:r,code:d.invalid_string,...g.errToObj(n)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...g.errToObj(e)})}url(e){return this._addCheck({kind:"url",...g.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...g.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...g.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...g.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...g.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...g.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...g.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...g.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...g.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...g.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...g.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...g.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,...g.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,...g.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...g.errToObj(e)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...g.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r?.position,...g.errToObj(r?.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...g.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...g.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...g.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...g.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...g.errToObj(r)})}nonempty(e){return this.min(1,g.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 r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};Y.create=t=>new Y({checks:[],typeName:v.ZodString,coerce:t?.coerce??false,...x(t)});function sn(t,e){let r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=r>n?r:n,o=Number.parseInt(t.toFixed(s).replace(".","")),i=Number.parseInt(e.toFixed(s).replace(".",""));return o%i/10**s}var se=class t extends _{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 o=this._getOrReturnCtx(e);return p(o,{code:d.invalid_type,expected:h.number,received:o.parsedType}),y}let n,s=new M;for(let o of this._def.checks)o.kind==="int"?k.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),p(n,{code:d.invalid_type,expected:"integer",received:"float",message:o.message}),s.dirty()):o.kind==="min"?(o.inclusive?e.data<o.value:e.data<=o.value)&&(n=this._getOrReturnCtx(e,n),p(n,{code:d.too_small,minimum:o.value,type:"number",inclusive:o.inclusive,exact:false,message:o.message}),s.dirty()):o.kind==="max"?(o.inclusive?e.data>o.value:e.data>=o.value)&&(n=this._getOrReturnCtx(e,n),p(n,{code:d.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:false,message:o.message}),s.dirty()):o.kind==="multipleOf"?sn(e.data,o.value)!==0&&(n=this._getOrReturnCtx(e,n),p(n,{code:d.not_multiple_of,multipleOf:o.value,message:o.message}),s.dirty()):o.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),p(n,{code:d.not_finite,message:o.message}),s.dirty()):k.assertNever(o);return {status:s.value,value:e.data}}gte(e,r){return this.setLimit("min",e,true,g.toString(r))}gt(e,r){return this.setLimit("min",e,false,g.toString(r))}lte(e,r){return this.setLimit("max",e,true,g.toString(r))}lt(e,r){return this.setLimit("max",e,false,g.toString(r))}setLimit(e,r,n,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:g.toString(s)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:g.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:false,message:g.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:false,message:g.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:true,message:g.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:true,message:g.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:g.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:g.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:true,value:Number.MIN_SAFE_INTEGER,message:g.toString(e)})._addCheck({kind:"max",inclusive:true,value:Number.MAX_SAFE_INTEGER,message:g.toString(e)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}get isInt(){return !!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&k.isInteger(e.value))}get isFinite(){let e=null,r=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return true;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);}return Number.isFinite(r)&&Number.isFinite(e)}};se.create=t=>new se({checks:[],typeName:v.ZodNumber,coerce:t?.coerce||false,...x(t)});var oe=class t extends _{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 n,s=new M;for(let o of this._def.checks)o.kind==="min"?(o.inclusive?e.data<o.value:e.data<=o.value)&&(n=this._getOrReturnCtx(e,n),p(n,{code:d.too_small,type:"bigint",minimum:o.value,inclusive:o.inclusive,message:o.message}),s.dirty()):o.kind==="max"?(o.inclusive?e.data>o.value:e.data>=o.value)&&(n=this._getOrReturnCtx(e,n),p(n,{code:d.too_big,type:"bigint",maximum:o.value,inclusive:o.inclusive,message:o.message}),s.dirty()):o.kind==="multipleOf"?e.data%o.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),p(n,{code:d.not_multiple_of,multipleOf:o.value,message:o.message}),s.dirty()):k.assertNever(o);return {status:s.value,value:e.data}}_getInvalidInput(e){let r=this._getOrReturnCtx(e);return p(r,{code:d.invalid_type,expected:h.bigint,received:r.parsedType}),y}gte(e,r){return this.setLimit("min",e,true,g.toString(r))}gt(e,r){return this.setLimit("min",e,false,g.toString(r))}lte(e,r){return this.setLimit("max",e,true,g.toString(r))}lt(e,r){return this.setLimit("max",e,false,g.toString(r))}setLimit(e,r,n,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:g.toString(s)}]})}_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:g.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:false,message:g.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:true,message:g.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:true,message:g.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:g.toString(r)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};oe.create=t=>new oe({checks:[],typeName:v.ZodBigInt,coerce:t?.coerce??false,...x(t)});var ae=class extends _{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==h.boolean){let n=this._getOrReturnCtx(e);return p(n,{code:d.invalid_type,expected:h.boolean,received:n.parsedType}),y}return C(e.data)}};ae.create=t=>new ae({typeName:v.ZodBoolean,coerce:t?.coerce||false,...x(t)});var ie=class t extends _{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==h.date){let o=this._getOrReturnCtx(e);return p(o,{code:d.invalid_type,expected:h.date,received:o.parsedType}),y}if(Number.isNaN(e.data.getTime())){let o=this._getOrReturnCtx(e);return p(o,{code:d.invalid_date}),y}let n=new M,s;for(let o of this._def.checks)o.kind==="min"?e.data.getTime()<o.value&&(s=this._getOrReturnCtx(e,s),p(s,{code:d.too_small,message:o.message,inclusive:true,exact:false,minimum:o.value,type:"date"}),n.dirty()):o.kind==="max"?e.data.getTime()>o.value&&(s=this._getOrReturnCtx(e,s),p(s,{code:d.too_big,message:o.message,inclusive:true,exact:false,maximum:o.value,type:"date"}),n.dirty()):k.assertNever(o);return {status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:g.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:g.toString(r)})}get minDate(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e!=null?new Date(e):null}};ie.create=t=>new ie({checks:[],coerce:t?.coerce||false,typeName:v.ZodDate,...x(t)});var Ae=class extends _{_parse(e){if(this._getType(e)!==h.symbol){let n=this._getOrReturnCtx(e);return p(n,{code:d.invalid_type,expected:h.symbol,received:n.parsedType}),y}return C(e.data)}};Ae.create=t=>new Ae({typeName:v.ZodSymbol,...x(t)});var ce=class extends _{_parse(e){if(this._getType(e)!==h.undefined){let n=this._getOrReturnCtx(e);return p(n,{code:d.invalid_type,expected:h.undefined,received:n.parsedType}),y}return C(e.data)}};ce.create=t=>new ce({typeName:v.ZodUndefined,...x(t)});var le=class extends _{_parse(e){if(this._getType(e)!==h.null){let n=this._getOrReturnCtx(e);return p(n,{code:d.invalid_type,expected:h.null,received:n.parsedType}),y}return C(e.data)}};le.create=t=>new le({typeName:v.ZodNull,...x(t)});var X=class extends _{constructor(){super(...arguments),this._any=true;}_parse(e){return C(e.data)}};X.create=t=>new X({typeName:v.ZodAny,...x(t)});var K=class extends _{constructor(){super(...arguments),this._unknown=true;}_parse(e){return C(e.data)}};K.create=t=>new K({typeName:v.ZodUnknown,...x(t)});var B=class extends _{_parse(e){let r=this._getOrReturnCtx(e);return p(r,{code:d.invalid_type,expected:h.never,received:r.parsedType}),y}};B.create=t=>new B({typeName:v.ZodNever,...x(t)});var Ie=class extends _{_parse(e){if(this._getType(e)!==h.undefined){let n=this._getOrReturnCtx(e);return p(n,{code:d.invalid_type,expected:h.void,received:n.parsedType}),y}return C(e.data)}};Ie.create=t=>new Ie({typeName:v.ZodVoid,...x(t)});var q=class t extends _{_parse(e){let{ctx:r,status:n}=this._processInputParams(e),s=this._def;if(r.parsedType!==h.array)return p(r,{code:d.invalid_type,expected:h.array,received:r.parsedType}),y;if(s.exactLength!==null){let i=r.data.length>s.exactLength.value,a=r.data.length<s.exactLength.value;(i||a)&&(p(r,{code:i?d.too_big:d.too_small,minimum:a?s.exactLength.value:void 0,maximum:i?s.exactLength.value:void 0,type:"array",inclusive:true,exact:true,message:s.exactLength.message}),n.dirty());}if(s.minLength!==null&&r.data.length<s.minLength.value&&(p(r,{code:d.too_small,minimum:s.minLength.value,type:"array",inclusive:true,exact:false,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&r.data.length>s.maxLength.value&&(p(r,{code:d.too_big,maximum:s.maxLength.value,type:"array",inclusive:true,exact:false,message:s.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((i,a)=>s.type._parseAsync(new N(r,i,r.path,a)))).then(i=>M.mergeArray(n,i));let o=[...r.data].map((i,a)=>s.type._parseSync(new N(r,i,r.path,a)));return M.mergeArray(n,o)}get element(){return this._def.type}min(e,r){return new t({...this._def,minLength:{value:e,message:g.toString(r)}})}max(e,r){return new t({...this._def,maxLength:{value:e,message:g.toString(r)}})}length(e,r){return new t({...this._def,exactLength:{value:e,message:g.toString(r)}})}nonempty(e){return this.min(1,e)}};q.create=(t,e)=>new q({type:t,minLength:null,maxLength:null,exactLength:null,typeName:v.ZodArray,...x(e)});function Se(t){if(t instanceof P){let e={};for(let r in t.shape){let n=t.shape[r];e[r]=$.create(Se(n));}return new P({...t._def,shape:()=>e})}else return t instanceof q?new q({...t._def,type:Se(t.element)}):t instanceof $?$.create(Se(t.unwrap())):t instanceof G?G.create(Se(t.unwrap())):t instanceof Z?Z.create(t.items.map(e=>Se(e))):t}var P=class t extends _{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(),r=k.objectKeys(e);return this._cached={shape:e,keys:r},this._cached}_parse(e){if(this._getType(e)!==h.object){let u=this._getOrReturnCtx(e);return p(u,{code:d.invalid_type,expected:h.object,received:u.parsedType}),y}let{status:n,ctx:s}=this._processInputParams(e),{shape:o,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof B&&this._def.unknownKeys==="strip"))for(let u in s.data)i.includes(u)||a.push(u);let c=[];for(let u of i){let f=o[u],b=s.data[u];c.push({key:{status:"valid",value:u},value:f._parse(new N(s,b,s.path,u)),alwaysSet:u in s.data});}if(this._def.catchall instanceof B){let u=this._def.unknownKeys;if(u==="passthrough")for(let f of a)c.push({key:{status:"valid",value:f},value:{status:"valid",value:s.data[f]}});else if(u==="strict")a.length>0&&(p(s,{code:d.unrecognized_keys,keys:a}),n.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else {let u=this._def.catchall;for(let f of a){let b=s.data[f];c.push({key:{status:"valid",value:f},value:u._parse(new N(s,b,s.path,f)),alwaysSet:f in s.data});}}return s.common.async?Promise.resolve().then(async()=>{let u=[];for(let f of c){let b=await f.key,w=await f.value;u.push({key:b,value:w,alwaysSet:f.alwaysSet});}return u}).then(u=>M.mergeObjectSync(n,u)):M.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(e){return g.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(r,n)=>{let s=this._def.errorMap?.(r,n).message??n.defaultError;return r.code==="unrecognized_keys"?{message:g.errToObj(e).message??s}:{message:s}}}:{}})}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:v.ZodObject})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let r={};for(let n of k.objectKeys(e))e[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new t({...this._def,shape:()=>r})}omit(e){let r={};for(let n of k.objectKeys(this.shape))e[n]||(r[n]=this.shape[n]);return new t({...this._def,shape:()=>r})}deepPartial(){return Se(this)}partial(e){let r={};for(let n of k.objectKeys(this.shape)){let s=this.shape[n];e&&!e[n]?r[n]=s:r[n]=s.optional();}return new t({...this._def,shape:()=>r})}required(e){let r={};for(let n of k.objectKeys(this.shape))if(e&&!e[n])r[n]=this.shape[n];else {let o=this.shape[n];for(;o instanceof $;)o=o._def.innerType;r[n]=o;}return new t({...this._def,shape:()=>r})}keyof(){return jt(k.objectKeys(this.shape))}};P.create=(t,e)=>new P({shape:()=>t,unknownKeys:"strip",catchall:B.create(),typeName:v.ZodObject,...x(e)});P.strictCreate=(t,e)=>new P({shape:()=>t,unknownKeys:"strict",catchall:B.create(),typeName:v.ZodObject,...x(e)});P.lazycreate=(t,e)=>new P({shape:t,unknownKeys:"strip",catchall:B.create(),typeName:v.ZodObject,...x(e)});var ue=class extends _{_parse(e){let{ctx:r}=this._processInputParams(e),n=this._def.options;function s(o){for(let a of o)if(a.result.status==="valid")return a.result;for(let a of o)if(a.result.status==="dirty")return r.common.issues.push(...a.ctx.common.issues),a.result;let i=o.map(a=>new O(a.ctx.common.issues));return p(r,{code:d.invalid_union,unionErrors:i}),y}if(r.common.async)return Promise.all(n.map(async o=>{let i={...r,common:{...r.common,issues:[]},parent:null};return {result:await o._parseAsync({data:r.data,path:r.path,parent:i}),ctx:i}})).then(s);{let o,i=[];for(let c of n){let u={...r,common:{...r.common,issues:[]},parent:null},f=c._parseSync({data:r.data,path:r.path,parent:u});if(f.status==="valid")return f;f.status==="dirty"&&!o&&(o={result:f,ctx:u}),u.common.issues.length&&i.push(u.common.issues);}if(o)return r.common.issues.push(...o.ctx.common.issues),o.result;let a=i.map(c=>new O(c));return p(r,{code:d.invalid_union,unionErrors:a}),y}}get options(){return this._def.options}};ue.create=(t,e)=>new ue({options:t,typeName:v.ZodUnion,...x(e)});var H=t=>t instanceof pe?H(t.schema):t instanceof L?H(t.innerType()):t instanceof fe?[t.value]:t instanceof me?t.options:t instanceof he?k.objectValues(t.enum):t instanceof ge?H(t._def.innerType):t instanceof ce?[void 0]:t instanceof le?[null]:t instanceof $?[void 0,...H(t.unwrap())]:t instanceof G?[null,...H(t.unwrap())]:t instanceof De||t instanceof ve?H(t.unwrap()):t instanceof ye?H(t._def.innerType):[],Ze=class t extends _{_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==h.object)return p(r,{code:d.invalid_type,expected:h.object,received:r.parsedType}),y;let n=this.discriminator,s=r.data[n],o=this.optionsMap.get(s);return o?r.common.async?o._parseAsync({data:r.data,path:r.path,parent:r}):o._parseSync({data:r.data,path:r.path,parent:r}):(p(r,{code:d.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),y)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,n){let s=new Map;for(let o of r){let i=H(o.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(s.has(a))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);s.set(a,o);}}return new t({typeName:v.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:s,...x(n)})}};function rt(t,e){let r=V(t),n=V(e);if(t===e)return {valid:true,data:t};if(r===h.object&&n===h.object){let s=k.objectKeys(e),o=k.objectKeys(t).filter(a=>s.indexOf(a)!==-1),i={...t,...e};for(let a of o){let c=rt(t[a],e[a]);if(!c.valid)return {valid:false};i[a]=c.data;}return {valid:true,data:i}}else if(r===h.array&&n===h.array){if(t.length!==e.length)return {valid:false};let s=[];for(let o=0;o<t.length;o++){let i=t[o],a=e[o],c=rt(i,a);if(!c.valid)return {valid:false};s.push(c.data);}return {valid:true,data:s}}else return r===h.date&&n===h.date&&+t==+e?{valid:true,data:t}:{valid:false}}var de=class extends _{_parse(e){let{status:r,ctx:n}=this._processInputParams(e),s=(o,i)=>{if(Ue(o)||Ue(i))return y;let a=rt(o.value,i.value);return a.valid?((Ve(o)||Ve(i))&&r.dirty(),{status:r.value,value:a.data}):(p(n,{code:d.invalid_intersection_types}),y)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([o,i])=>s(o,i)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};de.create=(t,e,r)=>new de({left:t,right:e,typeName:v.ZodIntersection,...x(r)});var Z=class t extends _{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==h.array)return p(n,{code:d.invalid_type,expected:h.array,received:n.parsedType}),y;if(n.data.length<this._def.items.length)return p(n,{code:d.too_small,minimum:this._def.items.length,inclusive:true,exact:false,type:"array"}),y;!this._def.rest&&n.data.length>this._def.items.length&&(p(n,{code:d.too_big,maximum:this._def.items.length,inclusive:true,exact:false,type:"array"}),r.dirty());let o=[...n.data].map((i,a)=>{let c=this._def.items[a]||this._def.rest;return c?c._parse(new N(n,i,n.path,a)):null}).filter(i=>!!i);return n.common.async?Promise.all(o).then(i=>M.mergeArray(r,i)):M.mergeArray(r,o)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};Z.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Z({items:t,typeName:v.ZodTuple,rest:null,...x(e)})};var Ge=class t extends _{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==h.object)return p(n,{code:d.invalid_type,expected:h.object,received:n.parsedType}),y;let s=[],o=this._def.keyType,i=this._def.valueType;for(let a in n.data)s.push({key:o._parse(new N(n,a,n.path,a)),value:i._parse(new N(n,n.data[a],n.path,a)),alwaysSet:a in n.data});return n.common.async?M.mergeObjectAsync(r,s):M.mergeObjectSync(r,s)}get element(){return this._def.valueType}static create(e,r,n){return r instanceof _?new t({keyType:e,valueType:r,typeName:v.ZodRecord,...x(n)}):new t({keyType:Y.create(),valueType:e,typeName:v.ZodRecord,...x(r)})}},Re=class extends _{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==h.map)return p(n,{code:d.invalid_type,expected:h.map,received:n.parsedType}),y;let s=this._def.keyType,o=this._def.valueType,i=[...n.data.entries()].map(([a,c],u)=>({key:s._parse(new N(n,a,n.path,[u,"key"])),value:o._parse(new N(n,c,n.path,[u,"value"]))}));if(n.common.async){let a=new Map;return Promise.resolve().then(async()=>{for(let c of i){let u=await c.key,f=await c.value;if(u.status==="aborted"||f.status==="aborted")return y;(u.status==="dirty"||f.status==="dirty")&&r.dirty(),a.set(u.value,f.value);}return {status:r.value,value:a}})}else {let a=new Map;for(let c of i){let u=c.key,f=c.value;if(u.status==="aborted"||f.status==="aborted")return y;(u.status==="dirty"||f.status==="dirty")&&r.dirty(),a.set(u.value,f.value);}return {status:r.value,value:a}}}};Re.create=(t,e,r)=>new Re({valueType:e,keyType:t,typeName:v.ZodMap,...x(r)});var Me=class t extends _{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==h.set)return p(n,{code:d.invalid_type,expected:h.set,received:n.parsedType}),y;let s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(p(n,{code:d.too_small,minimum:s.minSize.value,type:"set",inclusive:true,exact:false,message:s.minSize.message}),r.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(p(n,{code:d.too_big,maximum:s.maxSize.value,type:"set",inclusive:true,exact:false,message:s.maxSize.message}),r.dirty());let o=this._def.valueType;function i(c){let u=new Set;for(let f of c){if(f.status==="aborted")return y;f.status==="dirty"&&r.dirty(),u.add(f.value);}return {status:r.value,value:u}}let a=[...n.data.values()].map((c,u)=>o._parse(new N(n,c,n.path,u)));return n.common.async?Promise.all(a).then(c=>i(c)):i(a)}min(e,r){return new t({...this._def,minSize:{value:e,message:g.toString(r)}})}max(e,r){return new t({...this._def,maxSize:{value:e,message:g.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}};Me.create=(t,e)=>new Me({valueType:t,minSize:null,maxSize:null,typeName:v.ZodSet,...x(e)});var Fe=class t extends _{constructor(){super(...arguments),this.validate=this.implement;}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==h.function)return p(r,{code:d.invalid_type,expected:h.function,received:r.parsedType}),y;function n(a,c){return je({data:a,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,we(),F].filter(u=>!!u),issueData:{code:d.invalid_arguments,argumentsError:c}})}function s(a,c){return je({data:a,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,we(),F].filter(u=>!!u),issueData:{code:d.invalid_return_type,returnTypeError:c}})}let o={errorMap:r.common.contextualErrorMap},i=r.data;if(this._def.returns instanceof Q){let a=this;return C(async function(...c){let u=new O([]),f=await a._def.args.parseAsync(c,o).catch(I=>{throw u.addIssue(n(c,I)),u}),b=await Reflect.apply(i,this,f);return await a._def.returns._def.type.parseAsync(b,o).catch(I=>{throw u.addIssue(s(b,I)),u})})}else {let a=this;return C(function(...c){let u=a._def.args.safeParse(c,o);if(!u.success)throw new O([n(c,u.error)]);let f=Reflect.apply(i,this,u.data),b=a._def.returns.safeParse(f,o);if(!b.success)throw new O([s(f,b.error)]);return b.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:Z.create(e).rest(K.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,r,n){return new t({args:e||Z.create([]).rest(K.create()),returns:r||K.create(),typeName:v.ZodFunction,...x(n)})}},pe=class extends _{get schema(){return this._def.getter()}_parse(e){let{ctx:r}=this._processInputParams(e);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}};pe.create=(t,e)=>new pe({getter:t,typeName:v.ZodLazy,...x(e)});var fe=class extends _{_parse(e){if(e.data!==this._def.value){let r=this._getOrReturnCtx(e);return p(r,{received:r.data,code:d.invalid_literal,expected:this._def.value}),y}return {status:"valid",value:e.data}}get value(){return this._def.value}};fe.create=(t,e)=>new fe({value:t,typeName:v.ZodLiteral,...x(e)});function jt(t,e){return new me({values:t,typeName:v.ZodEnum,...x(e)})}var me=class t extends _{_parse(e){if(typeof e.data!="string"){let r=this._getOrReturnCtx(e),n=this._def.values;return p(r,{expected:k.joinValues(n),received:r.parsedType,code:d.invalid_type}),y}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let r=this._getOrReturnCtx(e),n=this._def.values;return p(r,{received:r.data,code:d.invalid_enum_value,options:n}),y}return C(e.data)}get options(){return this._def.values}get enum(){let e={};for(let r of this._def.values)e[r]=r;return e}get Values(){let e={};for(let r of this._def.values)e[r]=r;return e}get Enum(){let e={};for(let r of this._def.values)e[r]=r;return e}extract(e,r=this._def){return t.create(e,{...this._def,...r})}exclude(e,r=this._def){return t.create(this.options.filter(n=>!e.includes(n)),{...this._def,...r})}};me.create=jt;var he=class extends _{_parse(e){let r=k.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==h.string&&n.parsedType!==h.number){let s=k.objectValues(r);return p(n,{expected:k.joinValues(s),received:n.parsedType,code:d.invalid_type}),y}if(this._cache||(this._cache=new Set(k.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let s=k.objectValues(r);return p(n,{received:n.data,code:d.invalid_enum_value,options:s}),y}return C(e.data)}get enum(){return this._def.values}};he.create=(t,e)=>new he({values:t,typeName:v.ZodNativeEnum,...x(e)});var Q=class extends _{unwrap(){return this._def.type}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==h.promise&&r.common.async===false)return p(r,{code:d.invalid_type,expected:h.promise,received:r.parsedType}),y;let n=r.parsedType===h.promise?r.data:Promise.resolve(r.data);return C(n.then(s=>this._def.type.parseAsync(s,{path:r.path,errorMap:r.common.contextualErrorMap})))}};Q.create=(t,e)=>new Q({type:t,typeName:v.ZodPromise,...x(e)});var L=class extends _{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===v.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:r,ctx:n}=this._processInputParams(e),s=this._def.effect||null,o={addIssue:i=>{p(n,i),i.fatal?r.abort():r.dirty();},get path(){return n.path}};if(o.addIssue=o.addIssue.bind(o),s.type==="preprocess"){let i=s.transform(n.data,o);if(n.common.async)return Promise.resolve(i).then(async a=>{if(r.value==="aborted")return y;let c=await this._def.schema._parseAsync({data:a,path:n.path,parent:n});return c.status==="aborted"?y:c.status==="dirty"?ne(c.value):r.value==="dirty"?ne(c.value):c});{if(r.value==="aborted")return y;let a=this._def.schema._parseSync({data:i,path:n.path,parent:n});return a.status==="aborted"?y:a.status==="dirty"?ne(a.value):r.value==="dirty"?ne(a.value):a}}if(s.type==="refinement"){let i=a=>{let c=s.refinement(a,o);if(n.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(n.common.async===false){let a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?y:(a.status==="dirty"&&r.dirty(),i(a.value),{status:r.value,value:a.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(a=>a.status==="aborted"?y:(a.status==="dirty"&&r.dirty(),i(a.value).then(()=>({status:r.value,value:a.value}))))}if(s.type==="transform")if(n.common.async===false){let i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!J(i))return y;let a=s.transform(i.value,o);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return {status:r.value,value:a}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(i=>J(i)?Promise.resolve(s.transform(i.value,o)).then(a=>({status:r.value,value:a})):y);k.assertNever(s);}};L.create=(t,e,r)=>new L({schema:t,typeName:v.ZodEffects,effect:e,...x(r)});L.createWithPreprocess=(t,e,r)=>new L({schema:e,effect:{type:"preprocess",transform:t},typeName:v.ZodEffects,...x(r)});var $=class extends _{_parse(e){return this._getType(e)===h.undefined?C(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};$.create=(t,e)=>new $({innerType:t,typeName:v.ZodOptional,...x(e)});var G=class extends _{_parse(e){return this._getType(e)===h.null?C(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};G.create=(t,e)=>new G({innerType:t,typeName:v.ZodNullable,...x(e)});var ge=class extends _{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return r.parsedType===h.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};ge.create=(t,e)=>new ge({innerType:t,typeName:v.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...x(e)});var ye=class extends _{_parse(e){let{ctx:r}=this._processInputParams(e),n={...r,common:{...r.common,issues:[]}},s=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Te(s)?s.then(o=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new O(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new O(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};ye.create=(t,e)=>new ye({innerType:t,typeName:v.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...x(e)});var Ee=class extends _{_parse(e){if(this._getType(e)!==h.nan){let n=this._getOrReturnCtx(e);return p(n,{code:d.invalid_type,expected:h.nan,received:n.parsedType}),y}return {status:"valid",value:e.data}}};Ee.create=t=>new Ee({typeName:v.ZodNaN,...x(t)});var on=Symbol("zod_brand"),De=class extends _{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}},$e=class t extends _{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.common.async)return (async()=>{let o=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?y:o.status==="dirty"?(r.dirty(),ne(o.value)):this._def.out._parseAsync({data:o.value,path:n.path,parent:n})})();{let s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?y:s.status==="dirty"?(r.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,r){return new t({in:e,out:r,typeName:v.ZodPipeline})}},ve=class extends _{_parse(e){let r=this._def.innerType._parse(e),n=s=>(J(s)&&(s.value=Object.freeze(s.value)),s);return Te(r)?r.then(s=>n(s)):n(r)}unwrap(){return this._def.innerType}};ve.create=(t,e)=>new ve({innerType:t,typeName:v.ZodReadonly,...x(e)});function Et(t,e){let r=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof r=="string"?{message:r}:r}function Dt(t,e={},r){return t?X.create().superRefine((n,s)=>{let o=t(n);if(o instanceof Promise)return o.then(i=>{if(!i){let a=Et(e,n),c=a.fatal??r??true;s.addIssue({code:"custom",...a,fatal:c});}});if(!o){let i=Et(e,n),a=i.fatal??r??true;s.addIssue({code:"custom",...i,fatal:a});}}):X.create()}var an={object:P.lazycreate},v;(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";})(v||(v={}));var cn=(t,e={message:`Input not instance of ${t.name}`})=>Dt(r=>r instanceof t,e),$t=Y.create,Nt=se.create,ln=Ee.create,un=oe.create,Lt=ae.create,dn=ie.create,pn=Ae.create,fn=ce.create,mn=le.create,hn=X.create,gn=K.create,yn=B.create,vn=Ie.create,xn=q.create,bn=P.create,_n=P.strictCreate,kn=ue.create,wn=Ze.create,Tn=de.create,Sn=Z.create,An=Ge.create,In=Re.create,Rn=Me.create,Mn=Fe.create,En=pe.create,Cn=fe.create,On=me.create,Pn=he.create,jn=Q.create,Dn=L.create,$n=$.create,Nn=G.create,Ln=L.createWithPreprocess,Wn=$e.create,zn=()=>$t().optional(),Bn=()=>Nt().optional(),Un=()=>Lt().optional(),Vn={string:(t=>Y.create({...t,coerce:true})),number:(t=>se.create({...t,coerce:true})),boolean:(t=>ae.create({...t,coerce:true})),bigint:(t=>oe.create({...t,coerce:true})),date:(t=>ie.create({...t,coerce:true}))};var Zn=y;var Ce="agtx_pk_",He="agtx_sk_";l.string().min(Ce.length+8).startsWith(Ce,{message:`Publishable keys must start with "${Ce}".`});l.string().min(He.length+8).startsWith(He,{message:`Secret keys must start with "${He}".`});var Wt=t=>t.startsWith(Ce)?"publishable":t.startsWith(He)?"secret":"unknown",Oe=l.enum(["webmcp","dom","screenshot"]),nt=l.enum(["detected","declared","verified","linked"]),Gn=l.object({class:Oe,trust:nt,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({})}),Ne=l.object({class:Oe,vendor:l.string().min(1),token:l.string().min(8),expiresAt:l.string().datetime().optional()});l.object({publishableKey:l.string(),claim:Ne,nonce:l.string().min(8),origin:l.string().url()});l.object({trust:nt,vendor:l.string(),validUntil:l.string().datetime(),reason:l.string().optional()});var U={detected:0,declared:1,verified:2,linked:3},zt=(t,e)=>U[t]>U[e],Bt=l.enum(["allow","deny","review"]),Le=l.object({id:l.string(),tool:l.string(),minTrust:nt,allowedClasses:l.array(Oe).default([]),decision:Bt,rateLimit:l.object({max:l.number().int().positive(),windowSeconds:l.number().int().positive()}).optional()}),Fn=l.object({decision:Bt,ruleId:l.string().nullable(),reason:l.string()}),Hn=l.enum(["session","user","org"]),st=l.object({key:l.string().min(1),value:l.unknown(),scope:Hn.default("session"),ttlSeconds:l.number().int().positive().nullable().default(null),updatedAt:l.string().datetime().optional()}),Kn=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()}),qn=l.object({pattern:l.string().optional(),flow:l.string().optional()}),Jn=l.object({pages:l.array(Kn).default([]),navigation:qn.optional()}),Yn=l.object({step:l.number().int().positive(),action:l.string().min(1)}),Xn=l.object({steps:l.array(Yn).default([]),notes:l.string().optional(),policy:l.string().optional()}),Qn=l.object({selector:l.string().min(1),behavior:l.string().optional(),location:l.string().optional(),showsCount:l.boolean().optional()}),es=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()}),ot=l.object({path:l.string().min(1),payload:l.record(l.unknown()).default({}),updatedAt:l.string().datetime().optional()}).strict(),W=l.object({version:l.string().default("1"),siteMap:Jn.optional(),workflows:l.record(Xn).default({}),policies:l.record(l.union([l.string(),l.array(l.string())])).default({}),catalog:es.optional(),uiGuidance:l.record(Qn).default({}),pageContexts:l.record(ot).default({}),updatedAt:l.string().datetime().optional()}),Ut=W.parse({}),ts=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"]),at=l.object({id:l.string(),siteId:l.string(),sessionId:l.string(),occurredAt:l.string().datetime(),type:ts,tool:l.string().optional(),agent:Gn.nullable().optional(),policy:Fn.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(),events:l.array(at).min(1).max(100)});var We=class extends Error{code;constructor(t,e){super(e),this.name="AgentronicsError",this.code=t;}};var rs=()=>{if(typeof navigator>"u")return null;let t=navigator.modelContext;return t&&typeof t=="object"?t:null},ze=async(t={})=>{let{pollMs:e=500}=t,r=Date.now();for(;;){let n=rs();if(n)return ns(n);if(Date.now()-r>=e)return null;await new Promise(s=>setTimeout(s,50));}},ns=t=>({class:"webmcp",trust:"detected",confidence:1,vendor:t.vendor??t.client??null,userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:"2026.04",signals:{webmcp:true,toolCount:Array.isArray(t.tools)?t.tools.length:0}});var ss=[/HeadlessChrome/i,/Headless/i,/PhantomJS/i,/SlimerJS/i],os=()=>({hit:(typeof navigator<"u"&&navigator.webdriver)===true,weight:.6,detail:"navigator.webdriver === true"}),as=()=>{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_*"}`}},is=()=>{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"}},cs=()=>{if(typeof navigator>"u")return {hit:false,weight:.7};let t=navigator.userAgent??"",e=ss.some(r=>r.test(t));return e?{hit:e,weight:.7,detail:`headless UA: ${t}`}:{hit:e,weight:.7}},ls=()=>{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"}},us=()=>{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"}},ds={webdriver:os,chromedriver:as,headlessUa:cs,languages:ls,permissions:us,plugins:is},Be=(t={})=>{let{threshold:e=.4}=t,r={},n=0,s=0;for(let[i,a]of Object.entries(ds)){let c=a();n+=c.weight,r[i]={hit:c.hit,weight:c.weight,detail:c.detail},c.hit&&(s+=c.weight);}let o=n===0?0:s/n;return o<e?null:{class:"dom",trust:"detected",confidence:o,vendor:null,userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:"2026.04",signals:r}};var Vt=()=>[{id:"webmcp.model-context",status:"stable",detect:()=>ze({pollMs:0})},{id:"dom.automation-heuristics",status:"beta",detect:()=>Be()}],it=(t=Vt())=>{let e=new Map(t.map(r=>[r.id,r]));return {register(r){e.set(r.id,r);},list(r){let n=[...e.values()];return r?n.filter(s=>s.status===r):n},async detectAll(r=false){for(let n of e.values()){if(n.status==="research"&&!r)continue;let s=await n.detect();if(s)return s}return null}}};var Zt=async(t={})=>{if(t.customDetectors?.length){let e=await it(t.customDetectors).detectAll(!!t.experimental);if(e)return e}if(t.webmcp!==false){let e=await ze(t.webmcp??{});if(e)return e}if(t.dom!==false){let e=Be(t.dom??{});if(e)return e}return null};var ps=t=>({class:t.class,trust:"declared",confidence:1,vendor:t.vendor,userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:"2026.04",signals:{declared:true,hasToken:true,tokenExpiresAt:t.expiresAt??null}}),Gt=()=>{let t=null;return {present(e){let r=Ne.safeParse(e);if(!r.success)throw new We("invalid_api_key",`Invalid identity claim: ${r.error.issues[0]?.message??"unknown"}`);let n={claim:r.data,identity:ps(r.data)};return t=n,n},clear(){t=null;},preferOver(e){return t?e?zt(t.identity.trust,e.trust)?t.identity:e:t.identity:e},snapshot(){return t}}};var Ft=t=>{let e=null;for(let r of t)(!e||U[r.trust]>U[e.trust])&&(e=r);return e};var Ht=()=>({name:"bearer",async authenticate(t,e){if(!t.bearerToken)return null;let r=await e.verifyToken?.("bearer",t.bearerToken);return {class:t.classHint??"dom",trust:r?.trust??"verified",confidence:1,vendor:r?.vendor??t.vendorHint??"bearer",userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:"2026.04",signals:{bearer:true,verifiedRemotely:!!r}}}});var Kt=()=>({name:"detection",async authenticate(t){return t.detected??null}});var qt=()=>({name:"extensionToken",async authenticate(t,e){if(!t.extensionToken)return null;let r=await e.verifyToken?.("extensionToken",t.extensionToken);return {class:"dom",trust:r?.trust??"verified",confidence:1,vendor:r?.vendor??t.vendorHint??"browser-extension",userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:"2026.04",signals:{extensionToken:true,verifiedRemotely:!!r}}}});var Jt=()=>({name:"oauth2",async authenticate(t,e){if(!t.oauth2AccessToken)return null;let r=await e.verifyToken?.("oauth2",t.oauth2AccessToken);return {class:t.classHint??"webmcp",trust:t.oauth2Subject?"linked":r?.trust??"verified",confidence:1,vendor:r?.vendor??t.vendorHint??"oauth2",userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:"2026.04",signals:{oauth2:true,subject:t.oauth2Subject??null,verifiedRemotely:!!r}}}});var fs=t=>({class:t.class,trust:"declared",confidence:1,vendor:t.vendor,userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:"2026.04",signals:{declared:true,hasToken:true,tokenExpiresAt:t.expiresAt??null}}),Yt=()=>({name:"selfDeclaration",async authenticate(t){return t.declaration?fs(Ne.parse(t.declaration)):null}});var Xt=()=>({name:"sessionLink",async authenticate(t,e){if(!t.sessionLinkToken)return null;let r=await e.verifyToken?.("sessionLink",t.sessionLinkToken);return {class:t.classHint??"screenshot",trust:t.linkedUserId?"linked":r?.trust??"verified",confidence:1,vendor:r?.vendor??t.vendorHint??"session-link",userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:"2026.04",signals:{sessionLink:true,linkedUserId:t.linkedUserId??null,verifiedRemotely:!!r}}}});var Qt=()=>({name:"xAgentHeader",async authenticate(t){if(!t.xAgentHeader)return null;let[e="x-agent",r="dom",n]=t.xAgentHeader.split(";"),s=Oe.safeParse(r);return {class:s.success?s.data:"dom",trust:n?"verified":"declared",confidence:n?1:.8,vendor:e,userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:"2026.04",signals:{xAgentHeader:true,hasProof:!!n}}}});var ms=()=>[Kt(),Yt(),Ht(),Qt(),qt(),Xt(),Jt()],er=({methods:t=ms(),context:e={},onTrace:r}={})=>({async authenticate(n){let s=[],o={};for(let c of t){let u=await c.authenticate(n,e);o[c.name]=!!u,u&&s.push(u);}let i=Ft(s),a={type:i?"auth.identity_presented":"sdk.error",agent:i,outcome:i?"success":"error",metadata:{methods:o}};return i||(a.error="No auth method produced an identity."),r?.(a),i},methods(){return t.map(n=>n.name)}});var hs={identity:null,source:"initial",updatedAt:null},tr=()=>{let t=hs,e=new Set,r=()=>{e.size!==0&&e.forEach(n=>n(t));};return {snapshot(){return t},set(n,s){t={identity:n,source:s,updatedAt:new Date().toISOString()},r();},subscribe(n){return e.add(n),()=>{e.delete(n);}}}};var gs=()=>{let t=new Map;return {read:e=>t.get(e)??null,write:(e,r)=>{t.set(e,r);}}},ys=()=>typeof window>"u"||!window.localStorage?gs():{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},rr=(t=ys())=>({consume(e,r,n=Date.now()){let s=`agtx:rate:${e}`,o=vs(t.read(s)),i=o&&o.resetAt>n?o.resetAt:n+r.windowSeconds*1e3,a=o&&o.resetAt>n?o.count+1:1;return t.write(s,JSON.stringify({count:a,resetAt:i})),{allowed:a<=r.max,remaining:Math.max(0,r.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 r=t?U[t.trust]:-1,n=U[e.minTrust];return r>=n},_s=(t,e)=>e.allowedClasses.length===0?true:t?e.allowedClasses.includes(t.class):false,nr="review",ks=(t,e)=>{let r=e?.class??"unknown",n=e?.vendor??"unknown",s=e?.trust??"none";return `${t}:${r}:${n}:${s}`},sr=(t=[],e={})=>{let r=t.map(s=>Le.parse(s)),n=e.rateLimiter??rr();return {set(s){r=s.map(o=>Le.parse(o));},list(){return [...r]},evaluate({tool:s,identity:o}){for(let i of r)if(xs(i.tool,s)){if(!bs(o,i))return {decision:"deny",ruleId:i.id,reason:`Rule "${i.id}" requires trust >= ${i.minTrust}.`};if(!_s(o,i))return {decision:"deny",ruleId:i.id,reason:`Rule "${i.id}" restricts to classes: ${i.allowedClasses.join(", ")}.`};if(i.rateLimit){let a=n.consume(ks(s,o),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:nr,ruleId:null,reason:`No rule matched tool "${s}". Falling back to "${nr}".`}}}};var or=({gatewayUrl:t,siteId:e,publishableKey:r,fetcher:n=fetch})=>{let s={policies:[],etag:null};return {snapshot(){return {policies:[...s.policies],etag:s.etag}},async sync(){let o=await n(`${t.replace(/\/$/,"")}/v1/sites/${encodeURIComponent(e)}/policies`,{headers:{authorization:`Bearer ${r}`,...s.etag?{"if-none-match":s.etag}:{}}});if(o.status===304)return this.snapshot();if(!o.ok)throw new Error(`Policy sync failed with status ${o.status}.`);let i=await o.json();return s={policies:Le.array().parse(i.policies??[]),etag:o.headers.get("etag")},this.snapshot()}}};var ar=({message:t="Agent action blocked by site policy.",durationMs:e=2400,documentRef:r=typeof document>"u"?void 0:document}={})=>{if(!r?.body)return null;let n=r.createElement("div");return n.setAttribute("role","status"),n.setAttribute("data-agentronics-deny-overlay","true"),n.textContent=t,Object.assign(n.style,{position:"fixed",zIndex:"2147483647",left:"50%",bottom:"24px",transform:"translateX(-50%)",maxWidth:"min(520px, calc(100vw - 32px))",padding:"12px 16px",borderRadius:"8px",background:"#07091A",color:"#F4F4F5",border:"1px solid #6366F1",boxShadow:"0 20px 48px -16px rgba(7,9,26,0.55)",font:"13px/1.45 'Space Mono', ui-monospace, SFMono-Regular, Menlo, monospace"}),r.body.appendChild(n),window.setTimeout(()=>n.remove(),e),n};var ir=({policyEngine:t,getIdentity:e,documentRef:r=typeof document>"u"?void 0:document,selector:n="[data-agentronics-tool]"})=>{if(!r)return {uninstall:()=>{}};let s=o=>{let i=o.target instanceof Element?o.target.closest(n):null;if(!(i instanceof HTMLElement))return;let a=i.dataset.agentronicsTool;a&&Promise.resolve(e()).then(c=>{let u=t.evaluate({tool:a,identity:c});u.decision==="deny"&&(o.preventDefault(),o.stopPropagation(),ar({message:u.reason,documentRef:r}));});};return r.addEventListener("click",s,true),{uninstall:()=>r.removeEventListener("click",s,true)}};var ct=()=>{let t=new Map;return {read:e=>t.get(e)??null,write:(e,r)=>{t.set(e,r);},remove:e=>{t.delete(e);},keys:()=>[...t.keys()]}},cr=(t,e)=>({read:r=>{try{return t.getItem(e+r)}catch{return null}},write:(r,n)=>{try{t.setItem(e+r,n);}catch{}},remove:r=>{try{t.removeItem(e+r);}catch{}},keys:()=>{let r=[];try{for(let n=0;n<t.length;n++){let s=t.key(n);s&&s.startsWith(e)&&r.push(s.slice(e.length));}}catch{}return r}}),lr="agtx:",ur=()=>{let t=typeof window<"u",e=t&&typeof window.sessionStorage<"u"?cr(window.sessionStorage,lr+"session:"):ct(),r=t&&typeof window.localStorage<"u"?cr(window.localStorage,lr+"user:"):ct();return {session:e,user:r,org:ct()}};var dr=(t,e)=>t.expiresAt!==null&&t.expiresAt<=e,pr=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),fr=(t={})=>{let e=ur(),r=c=>{t.onTrace?.(c);};return {get:(c,u={})=>{let f=u.scope??"session",b=e[f],w=pr(b.read(c));if(!w){r({type:"memory.accessed",metadata:{operation:"get",key:c,scope:f,hit:false}});return}if(dr(w,Date.now())){b.remove(c),r({type:"memory.accessed",metadata:{operation:"get",key:c,scope:f,hit:false,expired:true}});return}return r({type:"memory.accessed",metadata:{operation:"get",key:c,scope:f,hit:true}}),w.value},set:(c,u,f={})=>{let b=f.scope??"session",w=f.ttlSeconds??null,I=Date.now(),j={value:u,expiresAt:w===null?null:I+w*1e3,updatedAt:new Date(I).toISOString()};return e[b].write(c,ws(j)),r({type:"memory.updated",metadata:{operation:"set",key:c,scope:b,ttlSeconds:w}}),st.parse({key:c,value:u,scope:b,ttlSeconds:w,updatedAt:j.updatedAt})},remove:(c,u={})=>{let f=u.scope??"session";e[f].remove(c),r({type:"memory.updated",metadata:{operation:"remove",key:c,scope:f}});},list:(c={})=>{let u=c.scope??"session",f=e[u],b=Date.now(),w=[];for(let I of f.keys()){let j=pr(f.read(I));if(j){if(dr(j,b)){f.remove(I);continue}w.push(st.parse({key:I,value:j.value,scope:u,ttlSeconds:j.expiresAt===null?null:Math.max(0,Math.round((j.expiresAt-b)/1e3)),updatedAt:j.updatedAt}));}}return r({type:"memory.accessed",metadata:{operation:"list",scope:u,count:w.length}}),w},clear:(c={})=>{let u=c.scope??"session",f=e[u],b=f.keys().length;for(let w of f.keys())f.remove(w);r({type:"memory.updated",metadata:{operation:"clear",scope:u,count:b}});}}};var lt=t=>W.parse(JSON.parse(JSON.stringify(t))),Ke=t=>({...t,updatedAt:new Date().toISOString()}),mr=(t={})=>{let e=W.parse({...Ut,...t.initial??{}}),r=null,n=new Set,s=T=>{t.onTrace?.(T);},o=()=>{r=null;},i=()=>{if(n.size===0)return;let T=lt(e);r=T,n.forEach(A=>A(T));},a=T=>{let A=W.parse({...e,...T,workflows:{...e.workflows,...T.workflows??{}},policies:{...e.policies,...T.policies??{}},uiGuidance:{...e.uiGuidance,...T.uiGuidance??{}},pageContexts:{...e.pageContexts,...T.pageContexts??{}}});return e=Ke(A),o(),s({type:"memory.updated",metadata:{kind:"site",operation:"provide",keys:Object.keys(T)}}),i(),f()},c=(T,A)=>{let R=T.split(".").filter(Boolean);if(R.length===0)throw new Error("siteMemory.update() requires a non-empty dot-path.");let te=JSON.parse(JSON.stringify(e)),re=te;for(let xe=0;xe<R.length-1;xe++){let z=R[xe],be=re[z];(typeof be!="object"||be===null||Array.isArray(be))&&(re[z]={}),re=re[z];}return re[R[R.length-1]]=A,e=Ke(W.parse(te)),o(),s({type:"memory.updated",metadata:{kind:"site",operation:"update",path:T}}),i(),f()},u=T=>{let A=ot.parse({path:T.path,payload:T.payload,updatedAt:new Date().toISOString()});return e=Ke({...e,pageContexts:{...e.pageContexts,[T.path]:A}}),o(),s({type:"memory.updated",metadata:{kind:"site",operation:"provideForPage",path:T.path}}),i(),{...A,payload:{...A.payload}}},f=()=>(r||(r=lt(e)),r);return {provide:a,update:c,provideForPage:u,snapshot:f,get:T=>{if(s({type:"memory.accessed",metadata:{kind:"site",operation:T?"get":"snapshot",path:T??null}}),!T)return lt(e);let A=T.split(".").filter(Boolean),R=e;for(let te of A){if(typeof R!="object"||R===null)return;R=R[te];}return R},getForPage:T=>{s({type:"memory.accessed",metadata:{kind:"site",operation:"getForPage",path:T}});let A=e.pageContexts[T];return A?{...A,payload:{...A.payload}}:null},replace:T=>(e=Ke(W.parse(T)),o(),i(),f()),subscribe:T=>(n.add(T),()=>{n.delete(T);})}};var hr=({gatewayUrl:t,siteId:e,publishableKey:r,fetcher:n=fetch})=>{let s={memory:null,etag:null};return {snapshot(){return {memory:s.memory?W.parse(s.memory):null,etag:s.etag}},async sync(){let o=await n(`${t.replace(/\/$/,"")}/v1/sites/${encodeURIComponent(e)}/memory`,{headers:{authorization:`Bearer ${r}`,...s.etag?{"if-none-match":s.etag}:{}}});if(o.status===304)return this.snapshot();if(!o.ok)throw new Error(`Memory sync failed with status ${o.status}.`);let i=await o.json();return s={memory:W.parse(i.memory??{}),etag:o.headers.get("etag")},this.snapshot()}}};var ee="agent-context-",ut="agentronics-site-context",Ts=t=>{try{return JSON.stringify(t)}catch{return "{}"}},qe=(t,e,r)=>{let n=t.querySelector(`meta[name="${e}"]`);n||(n=t.createElement("meta"),n.setAttribute("name",e),t.head.appendChild(n)),n.setAttribute("content",r);},Je=(t,e)=>{t.querySelectorAll(`meta[name="${e}"]`).forEach(r=>r.remove());},dt=({doc:t=typeof document>"u"?null:document,snapshot:e,schemaType:r="WebSite"})=>{if(!t)return {uninstall:()=>{}};qe(t,`${ee}version`,e.version),qe(t,`${ee}updated-at`,e.updatedAt??new Date().toISOString()),e.siteMap?.navigation?.flow&&qe(t,`${ee}flow`,e.siteMap.navigation.flow),qe(t,`${ee}workflows`,Object.keys(e.workflows).join(","));let n=t.getElementById(ut);return n||(n=t.createElement("script"),n.type="application/ld+json",n.id=ut,t.head.appendChild(n)),n.textContent=Ts({"@context":"https://schema.org","@type":r,name:"Agentronics Site Memory",agentronics:e}),{uninstall:()=>{Je(t,`${ee}version`),Je(t,`${ee}updated-at`),Je(t,`${ee}flow`),Je(t,`${ee}workflows`),t.getElementById(ut)?.remove();}}};var gr="agentronics-memory-overlay",Ss=t=>`
1
+ var Agentronics=(function(exports){'use strict';var Dr=Object.defineProperty;var $r=(t,e)=>{for(var r in e)Dr(t,r,{get:e[r],enumerable:true});};var c={};$r(c,{BRAND:()=>ln,DIRTY:()=>ne,EMPTY_PATH:()=>Br,INVALID:()=>y,NEVER:()=>Hn,OK:()=>C,ParseStatus:()=>R,Schema:()=>_,ZodAny:()=>X,ZodArray:()=>J,ZodBigInt:()=>oe,ZodBoolean:()=>ae,ZodBranded:()=>De,ZodCatch:()=>ye,ZodDate:()=>ie,ZodDefault:()=>ge,ZodDiscriminatedUnion:()=>Ze,ZodEffects:()=>L,ZodEnum:()=>me,ZodError:()=>O,ZodFirstPartyTypeKind:()=>v,ZodFunction:()=>Ge,ZodIntersection:()=>de,ZodIssueCode:()=>d,ZodLazy:()=>pe,ZodLiteral:()=>fe,ZodMap:()=>Me,ZodNaN:()=>Ee,ZodNativeEnum:()=>he,ZodNever:()=>z,ZodNull:()=>le,ZodNullable:()=>F,ZodNumber:()=>se,ZodObject:()=>P,ZodOptional:()=>$,ZodParsedType:()=>h,ZodPipeline:()=>$e,ZodPromise:()=>Q,ZodReadonly:()=>ve,ZodRecord:()=>Fe,ZodSchema:()=>_,ZodSet:()=>Re,ZodString:()=>Y,ZodSymbol:()=>Ae,ZodTransformer:()=>L,ZodTuple:()=>Z,ZodType:()=>_,ZodUndefined:()=>ce,ZodUnion:()=>ue,ZodUnknown:()=>K,ZodVoid:()=>Ie,addIssueToContext:()=>f,any:()=>vn,array:()=>kn,bigint:()=>fn,boolean:()=>Lt,coerce:()=>Gn,custom:()=>Dt,date:()=>mn,datetimeRegex:()=>Pt,defaultErrorMap:()=>G,discriminatedUnion:()=>An,effect:()=>Ln,enum:()=>Dn,function:()=>On,getErrorMap:()=>we,getParsedType:()=>U,instanceof:()=>dn,intersection:()=>In,isAborted:()=>Ve,isAsync:()=>Te,isDirty:()=>Ue,isValid:()=>q,late:()=>un,lazy:()=>Pn,literal:()=>jn,makeIssue:()=>je,map:()=>En,nan:()=>pn,nativeEnum:()=>$n,never:()=>bn,null:()=>yn,nullable:()=>Bn,number:()=>Nt,object:()=>wn,objectUtil:()=>et,oboolean:()=>Fn,onumber:()=>Zn,optional:()=>Wn,ostring:()=>Un,pipeline:()=>Vn,preprocess:()=>zn,promise:()=>Nn,quotelessJson:()=>Nr,record:()=>Rn,set:()=>Cn,setErrorMap:()=>Wr,strictObject:()=>Tn,string:()=>$t,symbol:()=>hn,transformer:()=>Ln,tuple:()=>Mn,undefined:()=>gn,union:()=>Sn,unknown:()=>xn,util:()=>w,void:()=>_n});var w;(function(t){t.assertEqual=s=>{};function e(s){}t.assertIs=e;function r(s){throw new Error}t.assertNever=r,t.arrayToEnum=s=>{let o={};for(let a of s)o[a]=a;return o},t.getValidEnumValues=s=>{let o=t.objectKeys(s).filter(i=>typeof s[s[i]]!="number"),a={};for(let i of o)a[i]=s[i];return t.objectValues(a)},t.objectValues=s=>t.objectKeys(s).map(function(o){return s[o]}),t.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{let o=[];for(let a in s)Object.prototype.hasOwnProperty.call(s,a)&&o.push(a);return o},t.find=(s,o)=>{for(let a of s)if(o(a))return a},t.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function n(s,o=" | "){return s.map(a=>typeof a=="string"?`'${a}'`:a).join(o)}t.joinValues=n,t.jsonStringifyReplacer=(s,o)=>typeof o=="bigint"?o.toString():o;})(w||(w={}));var et;(function(t){t.mergeShapes=(e,r)=>({...e,...r});})(et||(et={}));var h=w.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),U=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 d=w.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"]),Nr=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),O=class t extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n];},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n];};let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e;}format(e){let r=e||function(o){return o.message},n={_errors:[]},s=o=>{for(let a of o.issues)if(a.code==="invalid_union")a.unionErrors.map(s);else if(a.code==="invalid_return_type")s(a.returnTypeError);else if(a.code==="invalid_arguments")s(a.argumentsError);else if(a.path.length===0)n._errors.push(r(a));else {let i=n,l=0;for(;l<a.path.length;){let u=a.path[l];l===a.path.length-1?(i[u]=i[u]||{_errors:[]},i[u]._errors.push(r(a))):i[u]=i[u]||{_errors:[]},i=i[u],l++;}}};return s(this),n}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,w.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){let r={},n=[];for(let s of this.issues)if(s.path.length>0){let o=s.path[0];r[o]=r[o]||[],r[o].push(e(s));}else n.push(e(s));return {formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};O.create=t=>new O(t);var Lr=(t,e)=>{let r;switch(t.code){case d.invalid_type:t.received===h.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case d.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,w.jsonStringifyReplacer)}`;break;case d.unrecognized_keys:r=`Unrecognized key(s) in object: ${w.joinValues(t.keys,", ")}`;break;case d.invalid_union:r="Invalid input";break;case d.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${w.joinValues(t.options)}`;break;case d.invalid_enum_value:r=`Invalid enum value. Expected ${w.joinValues(t.options)}, received '${t.received}'`;break;case d.invalid_arguments:r="Invalid function arguments";break;case d.invalid_return_type:r="Invalid function return type";break;case d.invalid_date:r="Invalid date";break;case d.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:w.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case d.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case d.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case d.custom:r="Invalid input";break;case d.invalid_intersection_types:r="Intersection results could not be merged";break;case d.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case d.not_finite:r="Number must be finite";break;default:r=e.defaultError,w.assertNever(t);}return {message:r}},G=Lr;var Mt=G;function Wr(t){Mt=t;}function we(){return Mt}var je=t=>{let{data:e,path:r,errorMaps:n,issueData:s}=t,o=[...r,...s.path||[]],a={...s,path:o};if(s.message!==void 0)return {...s,path:o,message:s.message};let i="",l=n.filter(u=>!!u).slice().reverse();for(let u of l)i=u(a,{data:e,defaultError:i}).message;return {...s,path:o,message:i}},Br=[];function f(t,e){let r=we(),n=je({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===G?void 0:G].filter(s=>!!s)});t.common.issues.push(n);}var R=class t{constructor(){this.value="valid";}dirty(){this.value==="valid"&&(this.value="dirty");}abort(){this.value!=="aborted"&&(this.value="aborted");}static mergeArray(e,r){let n=[];for(let s of r){if(s.status==="aborted")return y;s.status==="dirty"&&e.dirty(),n.push(s.value);}return {status:e.value,value:n}}static async mergeObjectAsync(e,r){let n=[];for(let s of r){let o=await s.key,a=await s.value;n.push({key:o,value:a});}return t.mergeObjectSync(e,n)}static mergeObjectSync(e,r){let n={};for(let s of r){let{key:o,value:a}=s;if(o.status==="aborted"||a.status==="aborted")return y;o.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),o.value!=="__proto__"&&(typeof a.value<"u"||s.alwaysSet)&&(n[o.value]=a.value);}return {status:e.value,value:n}}},y=Object.freeze({status:"aborted"}),ne=t=>({status:"dirty",value:t}),C=t=>({status:"valid",value:t}),Ve=t=>t.status==="aborted",Ue=t=>t.status==="dirty",q=t=>t.status==="valid",Te=t=>typeof Promise<"u"&&t instanceof Promise;var g;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message;})(g||(g={}));var N=class{constructor(e,r,n,s){this._cachedPath=[],this.parent=e,this.data=r,this._path=n,this._key=s;}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}},Rt=(t,e)=>{if(q(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 r=new O(t.common.issues);return this._error=r,this._error}}};function b(t){if(!t)return {};let{errorMap:e,invalid_type_error:r,required_error:n,description:s}=t;if(e&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(a,i)=>{let{message:l}=t;return a.code==="invalid_enum_value"?{message:l??i.defaultError}:typeof i.data>"u"?{message:l??n??i.defaultError}:a.code!=="invalid_type"?{message:i.defaultError}:{message:l??r??i.defaultError}},description:s}}var _=class{get description(){return this._def.description}_getType(e){return U(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:U(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return {status:new R,ctx:{common:e.parent.common,data:e.data,parsedType:U(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let r=this._parse(e);if(Te(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(e){let r=this._parse(e);return Promise.resolve(r)}parse(e,r){let n=this.safeParse(e,r);if(n.success)return n.data;throw n.error}safeParse(e,r){let n={common:{issues:[],async:r?.async??false,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:U(e)},s=this._parseSync({data:e,path:n.path,parent:n});return Rt(n,s)}"~validate"(e){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:U(e)};if(!this["~standard"].async)try{let n=this._parseSync({data:e,path:[],parent:r});return q(n)?{value:n.value}:{issues:r.common.issues}}catch(n){n?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=true),r.common={issues:[],async:true};}return this._parseAsync({data:e,path:[],parent:r}).then(n=>q(n)?{value:n.value}:{issues:r.common.issues})}async parseAsync(e,r){let n=await this.safeParseAsync(e,r);if(n.success)return n.data;throw n.error}async safeParseAsync(e,r){let n={common:{issues:[],contextualErrorMap:r?.errorMap,async:true},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:U(e)},s=this._parse({data:e,path:n.path,parent:n}),o=await(Te(s)?s:Promise.resolve(s));return Rt(n,o)}refine(e,r){let n=s=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(s):r;return this._refinement((s,o)=>{let a=e(s),i=()=>o.addIssue({code:d.custom,...n(s)});return typeof Promise<"u"&&a instanceof Promise?a.then(l=>l?true:(i(),false)):a?true:(i(),false)})}refinement(e,r){return this._refinement((n,s)=>e(n)?true:(s.addIssue(typeof r=="function"?r(n,s):r),false))}_refinement(e){return new L({schema:this,typeName:v.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:r=>this["~validate"](r)};}optional(){return $.create(this,this._def)}nullable(){return F.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return J.create(this)}promise(){return Q.create(this,this._def)}or(e){return ue.create([this,e],this._def)}and(e){return de.create(this,e,this._def)}transform(e){return new L({...b(this._def),schema:this,typeName:v.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let r=typeof e=="function"?e:()=>e;return new ge({...b(this._def),innerType:this,defaultValue:r,typeName:v.ZodDefault})}brand(){return new De({typeName:v.ZodBranded,type:this,...b(this._def)})}catch(e){let r=typeof e=="function"?e:()=>e;return new ye({...b(this._def),innerType:this,catchValue:r,typeName:v.ZodCatch})}describe(e){let r=this.constructor;return new r({...this._def,description:e})}pipe(e){return $e.create(this,e)}readonly(){return ve.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},zr=/^c[^\s-]{8,}$/i,Vr=/^[0-9a-z]+$/,Ur=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Zr=/^[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,Fr=/^[a-z0-9_-]{21}$/i,Gr=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Hr=/^[-+]?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)?)??$/,Kr=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Jr="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",tt,qr=/^(?:(?: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])$/,Yr=/^(?:(?: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])$/,Xr=/^(([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]))$/,Qr=/^(([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])$/,en=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,tn=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Ct="((\\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])))",rn=new RegExp(`^${Ct}$`);function Ot(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);let r=t.precision?"+":"?";return `([01]\\d|2[0-3]):[0-5]\\d(:${e})${r}`}function nn(t){return new RegExp(`^${Ot(t)}$`)}function Pt(t){let e=`${Ct}T${Ot(t)}`,r=[];return r.push(t.local?"Z?":"Z"),t.offset&&r.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${r.join("|")})`,new RegExp(`^${e}$`)}function sn(t,e){return !!((e==="v4"||!e)&&qr.test(t)||(e==="v6"||!e)&&Xr.test(t))}function on(t,e){if(!Gr.test(t))return false;try{let[r]=t.split(".");if(!r)return !1;let n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),s=JSON.parse(atob(n));return !(typeof s!="object"||s===null||"typ"in s&&s?.typ!=="JWT"||!s.alg||e&&s.alg!==e)}catch{return false}}function an(t,e){return !!((e==="v4"||!e)&&Yr.test(t)||(e==="v6"||!e)&&Qr.test(t))}var Y=class t extends _{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==h.string){let o=this._getOrReturnCtx(e);return f(o,{code:d.invalid_type,expected:h.string,received:o.parsedType}),y}let n=new R,s;for(let o of this._def.checks)if(o.kind==="min")e.data.length<o.value&&(s=this._getOrReturnCtx(e,s),f(s,{code:d.too_small,minimum:o.value,type:"string",inclusive:true,exact:false,message:o.message}),n.dirty());else if(o.kind==="max")e.data.length>o.value&&(s=this._getOrReturnCtx(e,s),f(s,{code:d.too_big,maximum:o.value,type:"string",inclusive:true,exact:false,message:o.message}),n.dirty());else if(o.kind==="length"){let a=e.data.length>o.value,i=e.data.length<o.value;(a||i)&&(s=this._getOrReturnCtx(e,s),a?f(s,{code:d.too_big,maximum:o.value,type:"string",inclusive:true,exact:true,message:o.message}):i&&f(s,{code:d.too_small,minimum:o.value,type:"string",inclusive:true,exact:true,message:o.message}),n.dirty());}else if(o.kind==="email")Kr.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"email",code:d.invalid_string,message:o.message}),n.dirty());else if(o.kind==="emoji")tt||(tt=new RegExp(Jr,"u")),tt.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"emoji",code:d.invalid_string,message:o.message}),n.dirty());else if(o.kind==="uuid")Zr.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"uuid",code:d.invalid_string,message:o.message}),n.dirty());else if(o.kind==="nanoid")Fr.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"nanoid",code:d.invalid_string,message:o.message}),n.dirty());else if(o.kind==="cuid")zr.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"cuid",code:d.invalid_string,message:o.message}),n.dirty());else if(o.kind==="cuid2")Vr.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"cuid2",code:d.invalid_string,message:o.message}),n.dirty());else if(o.kind==="ulid")Ur.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"ulid",code:d.invalid_string,message:o.message}),n.dirty());else if(o.kind==="url")try{new URL(e.data);}catch{s=this._getOrReturnCtx(e,s),f(s,{validation:"url",code:d.invalid_string,message:o.message}),n.dirty();}else o.kind==="regex"?(o.regex.lastIndex=0,o.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"regex",code:d.invalid_string,message:o.message}),n.dirty())):o.kind==="trim"?e.data=e.data.trim():o.kind==="includes"?e.data.includes(o.value,o.position)||(s=this._getOrReturnCtx(e,s),f(s,{code:d.invalid_string,validation:{includes:o.value,position:o.position},message:o.message}),n.dirty()):o.kind==="toLowerCase"?e.data=e.data.toLowerCase():o.kind==="toUpperCase"?e.data=e.data.toUpperCase():o.kind==="startsWith"?e.data.startsWith(o.value)||(s=this._getOrReturnCtx(e,s),f(s,{code:d.invalid_string,validation:{startsWith:o.value},message:o.message}),n.dirty()):o.kind==="endsWith"?e.data.endsWith(o.value)||(s=this._getOrReturnCtx(e,s),f(s,{code:d.invalid_string,validation:{endsWith:o.value},message:o.message}),n.dirty()):o.kind==="datetime"?Pt(o).test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{code:d.invalid_string,validation:"datetime",message:o.message}),n.dirty()):o.kind==="date"?rn.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{code:d.invalid_string,validation:"date",message:o.message}),n.dirty()):o.kind==="time"?nn(o).test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{code:d.invalid_string,validation:"time",message:o.message}),n.dirty()):o.kind==="duration"?Hr.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"duration",code:d.invalid_string,message:o.message}),n.dirty()):o.kind==="ip"?sn(e.data,o.version)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"ip",code:d.invalid_string,message:o.message}),n.dirty()):o.kind==="jwt"?on(e.data,o.alg)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"jwt",code:d.invalid_string,message:o.message}),n.dirty()):o.kind==="cidr"?an(e.data,o.version)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"cidr",code:d.invalid_string,message:o.message}),n.dirty()):o.kind==="base64"?en.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"base64",code:d.invalid_string,message:o.message}),n.dirty()):o.kind==="base64url"?tn.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"base64url",code:d.invalid_string,message:o.message}),n.dirty()):w.assertNever(o);return {status:n.value,value:e.data}}_regex(e,r,n){return this.refinement(s=>e.test(s),{validation:r,code:d.invalid_string,...g.errToObj(n)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...g.errToObj(e)})}url(e){return this._addCheck({kind:"url",...g.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...g.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...g.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...g.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...g.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...g.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...g.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...g.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...g.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...g.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...g.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...g.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,...g.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,...g.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...g.errToObj(e)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...g.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r?.position,...g.errToObj(r?.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...g.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...g.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...g.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...g.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...g.errToObj(r)})}nonempty(e){return this.min(1,g.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 r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};Y.create=t=>new Y({checks:[],typeName:v.ZodString,coerce:t?.coerce??false,...b(t)});function cn(t,e){let r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=r>n?r:n,o=Number.parseInt(t.toFixed(s).replace(".","")),a=Number.parseInt(e.toFixed(s).replace(".",""));return o%a/10**s}var se=class t extends _{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 o=this._getOrReturnCtx(e);return f(o,{code:d.invalid_type,expected:h.number,received:o.parsedType}),y}let n,s=new R;for(let o of this._def.checks)o.kind==="int"?w.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),f(n,{code:d.invalid_type,expected:"integer",received:"float",message:o.message}),s.dirty()):o.kind==="min"?(o.inclusive?e.data<o.value:e.data<=o.value)&&(n=this._getOrReturnCtx(e,n),f(n,{code:d.too_small,minimum:o.value,type:"number",inclusive:o.inclusive,exact:false,message:o.message}),s.dirty()):o.kind==="max"?(o.inclusive?e.data>o.value:e.data>=o.value)&&(n=this._getOrReturnCtx(e,n),f(n,{code:d.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:false,message:o.message}),s.dirty()):o.kind==="multipleOf"?cn(e.data,o.value)!==0&&(n=this._getOrReturnCtx(e,n),f(n,{code:d.not_multiple_of,multipleOf:o.value,message:o.message}),s.dirty()):o.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),f(n,{code:d.not_finite,message:o.message}),s.dirty()):w.assertNever(o);return {status:s.value,value:e.data}}gte(e,r){return this.setLimit("min",e,true,g.toString(r))}gt(e,r){return this.setLimit("min",e,false,g.toString(r))}lte(e,r){return this.setLimit("max",e,true,g.toString(r))}lt(e,r){return this.setLimit("max",e,false,g.toString(r))}setLimit(e,r,n,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:g.toString(s)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:g.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:false,message:g.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:false,message:g.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:true,message:g.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:true,message:g.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:g.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:g.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:true,value:Number.MIN_SAFE_INTEGER,message:g.toString(e)})._addCheck({kind:"max",inclusive:true,value:Number.MAX_SAFE_INTEGER,message:g.toString(e)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}get isInt(){return !!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&w.isInteger(e.value))}get isFinite(){let e=null,r=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return true;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);}return Number.isFinite(r)&&Number.isFinite(e)}};se.create=t=>new se({checks:[],typeName:v.ZodNumber,coerce:t?.coerce||false,...b(t)});var oe=class t extends _{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 n,s=new R;for(let o of this._def.checks)o.kind==="min"?(o.inclusive?e.data<o.value:e.data<=o.value)&&(n=this._getOrReturnCtx(e,n),f(n,{code:d.too_small,type:"bigint",minimum:o.value,inclusive:o.inclusive,message:o.message}),s.dirty()):o.kind==="max"?(o.inclusive?e.data>o.value:e.data>=o.value)&&(n=this._getOrReturnCtx(e,n),f(n,{code:d.too_big,type:"bigint",maximum:o.value,inclusive:o.inclusive,message:o.message}),s.dirty()):o.kind==="multipleOf"?e.data%o.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),f(n,{code:d.not_multiple_of,multipleOf:o.value,message:o.message}),s.dirty()):w.assertNever(o);return {status:s.value,value:e.data}}_getInvalidInput(e){let r=this._getOrReturnCtx(e);return f(r,{code:d.invalid_type,expected:h.bigint,received:r.parsedType}),y}gte(e,r){return this.setLimit("min",e,true,g.toString(r))}gt(e,r){return this.setLimit("min",e,false,g.toString(r))}lte(e,r){return this.setLimit("max",e,true,g.toString(r))}lt(e,r){return this.setLimit("max",e,false,g.toString(r))}setLimit(e,r,n,s){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:g.toString(s)}]})}_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:g.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:false,message:g.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:true,message:g.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:true,message:g.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:g.toString(r)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};oe.create=t=>new oe({checks:[],typeName:v.ZodBigInt,coerce:t?.coerce??false,...b(t)});var ae=class extends _{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==h.boolean){let n=this._getOrReturnCtx(e);return f(n,{code:d.invalid_type,expected:h.boolean,received:n.parsedType}),y}return C(e.data)}};ae.create=t=>new ae({typeName:v.ZodBoolean,coerce:t?.coerce||false,...b(t)});var ie=class t extends _{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==h.date){let o=this._getOrReturnCtx(e);return f(o,{code:d.invalid_type,expected:h.date,received:o.parsedType}),y}if(Number.isNaN(e.data.getTime())){let o=this._getOrReturnCtx(e);return f(o,{code:d.invalid_date}),y}let n=new R,s;for(let o of this._def.checks)o.kind==="min"?e.data.getTime()<o.value&&(s=this._getOrReturnCtx(e,s),f(s,{code:d.too_small,message:o.message,inclusive:true,exact:false,minimum:o.value,type:"date"}),n.dirty()):o.kind==="max"?e.data.getTime()>o.value&&(s=this._getOrReturnCtx(e,s),f(s,{code:d.too_big,message:o.message,inclusive:true,exact:false,maximum:o.value,type:"date"}),n.dirty()):w.assertNever(o);return {status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:g.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:g.toString(r)})}get minDate(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e!=null?new Date(e):null}};ie.create=t=>new ie({checks:[],coerce:t?.coerce||false,typeName:v.ZodDate,...b(t)});var Ae=class extends _{_parse(e){if(this._getType(e)!==h.symbol){let n=this._getOrReturnCtx(e);return f(n,{code:d.invalid_type,expected:h.symbol,received:n.parsedType}),y}return C(e.data)}};Ae.create=t=>new Ae({typeName:v.ZodSymbol,...b(t)});var ce=class extends _{_parse(e){if(this._getType(e)!==h.undefined){let n=this._getOrReturnCtx(e);return f(n,{code:d.invalid_type,expected:h.undefined,received:n.parsedType}),y}return C(e.data)}};ce.create=t=>new ce({typeName:v.ZodUndefined,...b(t)});var le=class extends _{_parse(e){if(this._getType(e)!==h.null){let n=this._getOrReturnCtx(e);return f(n,{code:d.invalid_type,expected:h.null,received:n.parsedType}),y}return C(e.data)}};le.create=t=>new le({typeName:v.ZodNull,...b(t)});var X=class extends _{constructor(){super(...arguments),this._any=true;}_parse(e){return C(e.data)}};X.create=t=>new X({typeName:v.ZodAny,...b(t)});var K=class extends _{constructor(){super(...arguments),this._unknown=true;}_parse(e){return C(e.data)}};K.create=t=>new K({typeName:v.ZodUnknown,...b(t)});var z=class extends _{_parse(e){let r=this._getOrReturnCtx(e);return f(r,{code:d.invalid_type,expected:h.never,received:r.parsedType}),y}};z.create=t=>new z({typeName:v.ZodNever,...b(t)});var Ie=class extends _{_parse(e){if(this._getType(e)!==h.undefined){let n=this._getOrReturnCtx(e);return f(n,{code:d.invalid_type,expected:h.void,received:n.parsedType}),y}return C(e.data)}};Ie.create=t=>new Ie({typeName:v.ZodVoid,...b(t)});var J=class t extends _{_parse(e){let{ctx:r,status:n}=this._processInputParams(e),s=this._def;if(r.parsedType!==h.array)return f(r,{code:d.invalid_type,expected:h.array,received:r.parsedType}),y;if(s.exactLength!==null){let a=r.data.length>s.exactLength.value,i=r.data.length<s.exactLength.value;(a||i)&&(f(r,{code:a?d.too_big:d.too_small,minimum:i?s.exactLength.value:void 0,maximum:a?s.exactLength.value:void 0,type:"array",inclusive:true,exact:true,message:s.exactLength.message}),n.dirty());}if(s.minLength!==null&&r.data.length<s.minLength.value&&(f(r,{code:d.too_small,minimum:s.minLength.value,type:"array",inclusive:true,exact:false,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&r.data.length>s.maxLength.value&&(f(r,{code:d.too_big,maximum:s.maxLength.value,type:"array",inclusive:true,exact:false,message:s.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((a,i)=>s.type._parseAsync(new N(r,a,r.path,i)))).then(a=>R.mergeArray(n,a));let o=[...r.data].map((a,i)=>s.type._parseSync(new N(r,a,r.path,i)));return R.mergeArray(n,o)}get element(){return this._def.type}min(e,r){return new t({...this._def,minLength:{value:e,message:g.toString(r)}})}max(e,r){return new t({...this._def,maxLength:{value:e,message:g.toString(r)}})}length(e,r){return new t({...this._def,exactLength:{value:e,message:g.toString(r)}})}nonempty(e){return this.min(1,e)}};J.create=(t,e)=>new J({type:t,minLength:null,maxLength:null,exactLength:null,typeName:v.ZodArray,...b(e)});function Se(t){if(t instanceof P){let e={};for(let r in t.shape){let n=t.shape[r];e[r]=$.create(Se(n));}return new P({...t._def,shape:()=>e})}else return t instanceof J?new J({...t._def,type:Se(t.element)}):t instanceof $?$.create(Se(t.unwrap())):t instanceof F?F.create(Se(t.unwrap())):t instanceof Z?Z.create(t.items.map(e=>Se(e))):t}var P=class t extends _{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(),r=w.objectKeys(e);return this._cached={shape:e,keys:r},this._cached}_parse(e){if(this._getType(e)!==h.object){let u=this._getOrReturnCtx(e);return f(u,{code:d.invalid_type,expected:h.object,received:u.parsedType}),y}let{status:n,ctx:s}=this._processInputParams(e),{shape:o,keys:a}=this._getCached(),i=[];if(!(this._def.catchall instanceof z&&this._def.unknownKeys==="strip"))for(let u in s.data)a.includes(u)||i.push(u);let l=[];for(let u of a){let p=o[u],x=s.data[u];l.push({key:{status:"valid",value:u},value:p._parse(new N(s,x,s.path,u)),alwaysSet:u in s.data});}if(this._def.catchall instanceof z){let u=this._def.unknownKeys;if(u==="passthrough")for(let p of i)l.push({key:{status:"valid",value:p},value:{status:"valid",value:s.data[p]}});else if(u==="strict")i.length>0&&(f(s,{code:d.unrecognized_keys,keys:i}),n.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else {let u=this._def.catchall;for(let p of i){let x=s.data[p];l.push({key:{status:"valid",value:p},value:u._parse(new N(s,x,s.path,p)),alwaysSet:p in s.data});}}return s.common.async?Promise.resolve().then(async()=>{let u=[];for(let p of l){let x=await p.key,k=await p.value;u.push({key:x,value:k,alwaysSet:p.alwaysSet});}return u}).then(u=>R.mergeObjectSync(n,u)):R.mergeObjectSync(n,l)}get shape(){return this._def.shape()}strict(e){return g.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(r,n)=>{let s=this._def.errorMap?.(r,n).message??n.defaultError;return r.code==="unrecognized_keys"?{message:g.errToObj(e).message??s}:{message:s}}}:{}})}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:v.ZodObject})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let r={};for(let n of w.objectKeys(e))e[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new t({...this._def,shape:()=>r})}omit(e){let r={};for(let n of w.objectKeys(this.shape))e[n]||(r[n]=this.shape[n]);return new t({...this._def,shape:()=>r})}deepPartial(){return Se(this)}partial(e){let r={};for(let n of w.objectKeys(this.shape)){let s=this.shape[n];e&&!e[n]?r[n]=s:r[n]=s.optional();}return new t({...this._def,shape:()=>r})}required(e){let r={};for(let n of w.objectKeys(this.shape))if(e&&!e[n])r[n]=this.shape[n];else {let o=this.shape[n];for(;o instanceof $;)o=o._def.innerType;r[n]=o;}return new t({...this._def,shape:()=>r})}keyof(){return jt(w.objectKeys(this.shape))}};P.create=(t,e)=>new P({shape:()=>t,unknownKeys:"strip",catchall:z.create(),typeName:v.ZodObject,...b(e)});P.strictCreate=(t,e)=>new P({shape:()=>t,unknownKeys:"strict",catchall:z.create(),typeName:v.ZodObject,...b(e)});P.lazycreate=(t,e)=>new P({shape:t,unknownKeys:"strip",catchall:z.create(),typeName:v.ZodObject,...b(e)});var ue=class extends _{_parse(e){let{ctx:r}=this._processInputParams(e),n=this._def.options;function s(o){for(let i of o)if(i.result.status==="valid")return i.result;for(let i of o)if(i.result.status==="dirty")return r.common.issues.push(...i.ctx.common.issues),i.result;let a=o.map(i=>new O(i.ctx.common.issues));return f(r,{code:d.invalid_union,unionErrors:a}),y}if(r.common.async)return Promise.all(n.map(async o=>{let a={...r,common:{...r.common,issues:[]},parent:null};return {result:await o._parseAsync({data:r.data,path:r.path,parent:a}),ctx:a}})).then(s);{let o,a=[];for(let l of n){let u={...r,common:{...r.common,issues:[]},parent:null},p=l._parseSync({data:r.data,path:r.path,parent:u});if(p.status==="valid")return p;p.status==="dirty"&&!o&&(o={result:p,ctx:u}),u.common.issues.length&&a.push(u.common.issues);}if(o)return r.common.issues.push(...o.ctx.common.issues),o.result;let i=a.map(l=>new O(l));return f(r,{code:d.invalid_union,unionErrors:i}),y}}get options(){return this._def.options}};ue.create=(t,e)=>new ue({options:t,typeName:v.ZodUnion,...b(e)});var H=t=>t instanceof pe?H(t.schema):t instanceof L?H(t.innerType()):t instanceof fe?[t.value]:t instanceof me?t.options:t instanceof he?w.objectValues(t.enum):t instanceof ge?H(t._def.innerType):t instanceof ce?[void 0]:t instanceof le?[null]:t instanceof $?[void 0,...H(t.unwrap())]:t instanceof F?[null,...H(t.unwrap())]:t instanceof De||t instanceof ve?H(t.unwrap()):t instanceof ye?H(t._def.innerType):[],Ze=class t extends _{_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==h.object)return f(r,{code:d.invalid_type,expected:h.object,received:r.parsedType}),y;let n=this.discriminator,s=r.data[n],o=this.optionsMap.get(s);return o?r.common.async?o._parseAsync({data:r.data,path:r.path,parent:r}):o._parseSync({data:r.data,path:r.path,parent:r}):(f(r,{code:d.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),y)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,n){let s=new Map;for(let o of r){let a=H(o.shape[e]);if(!a.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let i of a){if(s.has(i))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(i)}`);s.set(i,o);}}return new t({typeName:v.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:s,...b(n)})}};function rt(t,e){let r=U(t),n=U(e);if(t===e)return {valid:true,data:t};if(r===h.object&&n===h.object){let s=w.objectKeys(e),o=w.objectKeys(t).filter(i=>s.indexOf(i)!==-1),a={...t,...e};for(let i of o){let l=rt(t[i],e[i]);if(!l.valid)return {valid:false};a[i]=l.data;}return {valid:true,data:a}}else if(r===h.array&&n===h.array){if(t.length!==e.length)return {valid:false};let s=[];for(let o=0;o<t.length;o++){let a=t[o],i=e[o],l=rt(a,i);if(!l.valid)return {valid:false};s.push(l.data);}return {valid:true,data:s}}else return r===h.date&&n===h.date&&+t==+e?{valid:true,data:t}:{valid:false}}var de=class extends _{_parse(e){let{status:r,ctx:n}=this._processInputParams(e),s=(o,a)=>{if(Ve(o)||Ve(a))return y;let i=rt(o.value,a.value);return i.valid?((Ue(o)||Ue(a))&&r.dirty(),{status:r.value,value:i.data}):(f(n,{code:d.invalid_intersection_types}),y)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([o,a])=>s(o,a)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};de.create=(t,e,r)=>new de({left:t,right:e,typeName:v.ZodIntersection,...b(r)});var Z=class t extends _{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==h.array)return f(n,{code:d.invalid_type,expected:h.array,received:n.parsedType}),y;if(n.data.length<this._def.items.length)return f(n,{code:d.too_small,minimum:this._def.items.length,inclusive:true,exact:false,type:"array"}),y;!this._def.rest&&n.data.length>this._def.items.length&&(f(n,{code:d.too_big,maximum:this._def.items.length,inclusive:true,exact:false,type:"array"}),r.dirty());let o=[...n.data].map((a,i)=>{let l=this._def.items[i]||this._def.rest;return l?l._parse(new N(n,a,n.path,i)):null}).filter(a=>!!a);return n.common.async?Promise.all(o).then(a=>R.mergeArray(r,a)):R.mergeArray(r,o)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};Z.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Z({items:t,typeName:v.ZodTuple,rest:null,...b(e)})};var Fe=class t extends _{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==h.object)return f(n,{code:d.invalid_type,expected:h.object,received:n.parsedType}),y;let s=[],o=this._def.keyType,a=this._def.valueType;for(let i in n.data)s.push({key:o._parse(new N(n,i,n.path,i)),value:a._parse(new N(n,n.data[i],n.path,i)),alwaysSet:i in n.data});return n.common.async?R.mergeObjectAsync(r,s):R.mergeObjectSync(r,s)}get element(){return this._def.valueType}static create(e,r,n){return r instanceof _?new t({keyType:e,valueType:r,typeName:v.ZodRecord,...b(n)}):new t({keyType:Y.create(),valueType:e,typeName:v.ZodRecord,...b(r)})}},Me=class extends _{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==h.map)return f(n,{code:d.invalid_type,expected:h.map,received:n.parsedType}),y;let s=this._def.keyType,o=this._def.valueType,a=[...n.data.entries()].map(([i,l],u)=>({key:s._parse(new N(n,i,n.path,[u,"key"])),value:o._parse(new N(n,l,n.path,[u,"value"]))}));if(n.common.async){let i=new Map;return Promise.resolve().then(async()=>{for(let l of a){let u=await l.key,p=await l.value;if(u.status==="aborted"||p.status==="aborted")return y;(u.status==="dirty"||p.status==="dirty")&&r.dirty(),i.set(u.value,p.value);}return {status:r.value,value:i}})}else {let i=new Map;for(let l of a){let u=l.key,p=l.value;if(u.status==="aborted"||p.status==="aborted")return y;(u.status==="dirty"||p.status==="dirty")&&r.dirty(),i.set(u.value,p.value);}return {status:r.value,value:i}}}};Me.create=(t,e,r)=>new Me({valueType:e,keyType:t,typeName:v.ZodMap,...b(r)});var Re=class t extends _{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==h.set)return f(n,{code:d.invalid_type,expected:h.set,received:n.parsedType}),y;let s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(f(n,{code:d.too_small,minimum:s.minSize.value,type:"set",inclusive:true,exact:false,message:s.minSize.message}),r.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(f(n,{code:d.too_big,maximum:s.maxSize.value,type:"set",inclusive:true,exact:false,message:s.maxSize.message}),r.dirty());let o=this._def.valueType;function a(l){let u=new Set;for(let p of l){if(p.status==="aborted")return y;p.status==="dirty"&&r.dirty(),u.add(p.value);}return {status:r.value,value:u}}let i=[...n.data.values()].map((l,u)=>o._parse(new N(n,l,n.path,u)));return n.common.async?Promise.all(i).then(l=>a(l)):a(i)}min(e,r){return new t({...this._def,minSize:{value:e,message:g.toString(r)}})}max(e,r){return new t({...this._def,maxSize:{value:e,message:g.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}};Re.create=(t,e)=>new Re({valueType:t,minSize:null,maxSize:null,typeName:v.ZodSet,...b(e)});var Ge=class t extends _{constructor(){super(...arguments),this.validate=this.implement;}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==h.function)return f(r,{code:d.invalid_type,expected:h.function,received:r.parsedType}),y;function n(i,l){return je({data:i,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,we(),G].filter(u=>!!u),issueData:{code:d.invalid_arguments,argumentsError:l}})}function s(i,l){return je({data:i,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,we(),G].filter(u=>!!u),issueData:{code:d.invalid_return_type,returnTypeError:l}})}let o={errorMap:r.common.contextualErrorMap},a=r.data;if(this._def.returns instanceof Q){let i=this;return C(async function(...l){let u=new O([]),p=await i._def.args.parseAsync(l,o).catch(I=>{throw u.addIssue(n(l,I)),u}),x=await Reflect.apply(a,this,p);return await i._def.returns._def.type.parseAsync(x,o).catch(I=>{throw u.addIssue(s(x,I)),u})})}else {let i=this;return C(function(...l){let u=i._def.args.safeParse(l,o);if(!u.success)throw new O([n(l,u.error)]);let p=Reflect.apply(a,this,u.data),x=i._def.returns.safeParse(p,o);if(!x.success)throw new O([s(p,x.error)]);return x.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:Z.create(e).rest(K.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,r,n){return new t({args:e||Z.create([]).rest(K.create()),returns:r||K.create(),typeName:v.ZodFunction,...b(n)})}},pe=class extends _{get schema(){return this._def.getter()}_parse(e){let{ctx:r}=this._processInputParams(e);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}};pe.create=(t,e)=>new pe({getter:t,typeName:v.ZodLazy,...b(e)});var fe=class extends _{_parse(e){if(e.data!==this._def.value){let r=this._getOrReturnCtx(e);return f(r,{received:r.data,code:d.invalid_literal,expected:this._def.value}),y}return {status:"valid",value:e.data}}get value(){return this._def.value}};fe.create=(t,e)=>new fe({value:t,typeName:v.ZodLiteral,...b(e)});function jt(t,e){return new me({values:t,typeName:v.ZodEnum,...b(e)})}var me=class t extends _{_parse(e){if(typeof e.data!="string"){let r=this._getOrReturnCtx(e),n=this._def.values;return f(r,{expected:w.joinValues(n),received:r.parsedType,code:d.invalid_type}),y}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let r=this._getOrReturnCtx(e),n=this._def.values;return f(r,{received:r.data,code:d.invalid_enum_value,options:n}),y}return C(e.data)}get options(){return this._def.values}get enum(){let e={};for(let r of this._def.values)e[r]=r;return e}get Values(){let e={};for(let r of this._def.values)e[r]=r;return e}get Enum(){let e={};for(let r of this._def.values)e[r]=r;return e}extract(e,r=this._def){return t.create(e,{...this._def,...r})}exclude(e,r=this._def){return t.create(this.options.filter(n=>!e.includes(n)),{...this._def,...r})}};me.create=jt;var he=class extends _{_parse(e){let r=w.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==h.string&&n.parsedType!==h.number){let s=w.objectValues(r);return f(n,{expected:w.joinValues(s),received:n.parsedType,code:d.invalid_type}),y}if(this._cache||(this._cache=new Set(w.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let s=w.objectValues(r);return f(n,{received:n.data,code:d.invalid_enum_value,options:s}),y}return C(e.data)}get enum(){return this._def.values}};he.create=(t,e)=>new he({values:t,typeName:v.ZodNativeEnum,...b(e)});var Q=class extends _{unwrap(){return this._def.type}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==h.promise&&r.common.async===false)return f(r,{code:d.invalid_type,expected:h.promise,received:r.parsedType}),y;let n=r.parsedType===h.promise?r.data:Promise.resolve(r.data);return C(n.then(s=>this._def.type.parseAsync(s,{path:r.path,errorMap:r.common.contextualErrorMap})))}};Q.create=(t,e)=>new Q({type:t,typeName:v.ZodPromise,...b(e)});var L=class extends _{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===v.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:r,ctx:n}=this._processInputParams(e),s=this._def.effect||null,o={addIssue:a=>{f(n,a),a.fatal?r.abort():r.dirty();},get path(){return n.path}};if(o.addIssue=o.addIssue.bind(o),s.type==="preprocess"){let a=s.transform(n.data,o);if(n.common.async)return Promise.resolve(a).then(async i=>{if(r.value==="aborted")return y;let l=await this._def.schema._parseAsync({data:i,path:n.path,parent:n});return l.status==="aborted"?y:l.status==="dirty"?ne(l.value):r.value==="dirty"?ne(l.value):l});{if(r.value==="aborted")return y;let i=this._def.schema._parseSync({data:a,path:n.path,parent:n});return i.status==="aborted"?y:i.status==="dirty"?ne(i.value):r.value==="dirty"?ne(i.value):i}}if(s.type==="refinement"){let a=i=>{let l=s.refinement(i,o);if(n.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return i};if(n.common.async===false){let i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?y:(i.status==="dirty"&&r.dirty(),a(i.value),{status:r.value,value:i.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(i=>i.status==="aborted"?y:(i.status==="dirty"&&r.dirty(),a(i.value).then(()=>({status:r.value,value:i.value}))))}if(s.type==="transform")if(n.common.async===false){let a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!q(a))return y;let i=s.transform(a.value,o);if(i instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return {status:r.value,value:i}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(a=>q(a)?Promise.resolve(s.transform(a.value,o)).then(i=>({status:r.value,value:i})):y);w.assertNever(s);}};L.create=(t,e,r)=>new L({schema:t,typeName:v.ZodEffects,effect:e,...b(r)});L.createWithPreprocess=(t,e,r)=>new L({schema:e,effect:{type:"preprocess",transform:t},typeName:v.ZodEffects,...b(r)});var $=class extends _{_parse(e){return this._getType(e)===h.undefined?C(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};$.create=(t,e)=>new $({innerType:t,typeName:v.ZodOptional,...b(e)});var F=class extends _{_parse(e){return this._getType(e)===h.null?C(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};F.create=(t,e)=>new F({innerType:t,typeName:v.ZodNullable,...b(e)});var ge=class extends _{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return r.parsedType===h.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};ge.create=(t,e)=>new ge({innerType:t,typeName:v.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...b(e)});var ye=class extends _{_parse(e){let{ctx:r}=this._processInputParams(e),n={...r,common:{...r.common,issues:[]}},s=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Te(s)?s.then(o=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new O(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new O(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};ye.create=(t,e)=>new ye({innerType:t,typeName:v.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...b(e)});var Ee=class extends _{_parse(e){if(this._getType(e)!==h.nan){let n=this._getOrReturnCtx(e);return f(n,{code:d.invalid_type,expected:h.nan,received:n.parsedType}),y}return {status:"valid",value:e.data}}};Ee.create=t=>new Ee({typeName:v.ZodNaN,...b(t)});var ln=Symbol("zod_brand"),De=class extends _{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}},$e=class t extends _{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.common.async)return (async()=>{let o=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?y:o.status==="dirty"?(r.dirty(),ne(o.value)):this._def.out._parseAsync({data:o.value,path:n.path,parent:n})})();{let s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?y:s.status==="dirty"?(r.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,r){return new t({in:e,out:r,typeName:v.ZodPipeline})}},ve=class extends _{_parse(e){let r=this._def.innerType._parse(e),n=s=>(q(s)&&(s.value=Object.freeze(s.value)),s);return Te(r)?r.then(s=>n(s)):n(r)}unwrap(){return this._def.innerType}};ve.create=(t,e)=>new ve({innerType:t,typeName:v.ZodReadonly,...b(e)});function Et(t,e){let r=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof r=="string"?{message:r}:r}function Dt(t,e={},r){return t?X.create().superRefine((n,s)=>{let o=t(n);if(o instanceof Promise)return o.then(a=>{if(!a){let i=Et(e,n),l=i.fatal??r??true;s.addIssue({code:"custom",...i,fatal:l});}});if(!o){let a=Et(e,n),i=a.fatal??r??true;s.addIssue({code:"custom",...a,fatal:i});}}):X.create()}var un={object:P.lazycreate},v;(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";})(v||(v={}));var dn=(t,e={message:`Input not instance of ${t.name}`})=>Dt(r=>r instanceof t,e),$t=Y.create,Nt=se.create,pn=Ee.create,fn=oe.create,Lt=ae.create,mn=ie.create,hn=Ae.create,gn=ce.create,yn=le.create,vn=X.create,xn=K.create,bn=z.create,_n=Ie.create,kn=J.create,wn=P.create,Tn=P.strictCreate,Sn=ue.create,An=Ze.create,In=de.create,Mn=Z.create,Rn=Fe.create,En=Me.create,Cn=Re.create,On=Ge.create,Pn=pe.create,jn=fe.create,Dn=me.create,$n=he.create,Nn=Q.create,Ln=L.create,Wn=$.create,Bn=F.create,zn=L.createWithPreprocess,Vn=$e.create,Un=()=>$t().optional(),Zn=()=>Nt().optional(),Fn=()=>Lt().optional(),Gn={string:(t=>Y.create({...t,coerce:true})),number:(t=>se.create({...t,coerce:true})),boolean:(t=>ae.create({...t,coerce:true})),bigint:(t=>oe.create({...t,coerce:true})),date:(t=>ie.create({...t,coerce:true}))};var Hn=y;var Ce="agtx_pk_",He="agtx_sk_";c.string().min(Ce.length+8).startsWith(Ce,{message:`Publishable keys must start with "${Ce}".`});c.string().min(He.length+8).startsWith(He,{message:`Secret keys must start with "${He}".`});var Wt=t=>t.startsWith(Ce)?"publishable":t.startsWith(He)?"secret":"unknown",Oe=c.enum(["webmcp","dom","screenshot"]),nt=c.enum(["detected","declared","verified","linked"]),Kn=c.object({class:Oe,trust:nt,confidence:c.number().min(0).max(1).default(1),vendor:c.string().nullable(),userAgent:c.string().nullable(),detectionVersion:c.string().default("2026.04"),signals:c.record(c.unknown()).default({})}),Jn=c.enum(["bearer","oauth2","sso","spiffe","google-agent","mtls","detection","declaration","extension","session-link","x-agent-header"]),Ne=c.object({class:Oe,vendor:c.string().min(1),token:c.string().min(8),expiresAt:c.string().datetime().optional()});c.object({publishableKey:c.string(),claim:Ne,nonce:c.string().min(8),origin:c.string().url()});c.object({trust:nt,vendor:c.string(),validUntil:c.string().datetime(),reason:c.string().optional(),subject:c.string().optional(),protocol:Jn.optional(),signals:c.record(c.unknown()).optional()});c.object({issuer:c.string().url(),audiences:c.array(c.string().min(1)).min(1)});c.object({trustDomain:c.string().min(1),bundleEndpoint:c.string().url(),audiences:c.array(c.string().min(1)).min(1),googleTrustDomains:c.array(c.string().min(1)).optional()});c.object({rootCerts:c.array(c.string().min(20)).min(1),spiffeTrustDomain:c.string().min(1).optional(),xfccEntryPolicy:c.enum(["last","first","only"]).default("last")});c.enum(["sso","spiffe","mtls"]);c.object({siteId:c.string().min(1),token:c.string().min(8).optional(),xfcc:c.string().min(1).optional(),headers:c.record(c.string()).optional(),origin:c.string().url().optional()});var V={detected:0,declared:1,verified:2,linked:3},Bt=(t,e)=>V[t]>V[e],zt=c.enum(["allow","deny","review"]),Le=c.object({id:c.string(),tool:c.string(),minTrust:nt,allowedClasses:c.array(Oe).default([]),decision:zt,rateLimit:c.object({max:c.number().int().positive(),windowSeconds:c.number().int().positive()}).optional()}),qn=c.object({decision:zt,ruleId:c.string().nullable(),reason:c.string()}),Yn=c.enum(["session","user","org"]),st=c.object({key:c.string().min(1),value:c.unknown(),scope:Yn.default("session"),ttlSeconds:c.number().int().positive().nullable().default(null),updatedAt:c.string().datetime().optional()}),Xn=c.object({path:c.string().min(1),name:c.string().optional(),purpose:c.string().optional(),availableActions:c.array(c.string()).optional(),prerequisites:c.array(c.string()).optional(),queryParams:c.record(c.string()).optional(),notes:c.string().optional()}),Qn=c.object({pattern:c.string().optional(),flow:c.string().optional()}),es=c.object({pages:c.array(Xn).default([]),navigation:Qn.optional()}),ts=c.object({step:c.number().int().positive(),action:c.string().min(1)}),rs=c.object({steps:c.array(ts).default([]),notes:c.string().optional(),policy:c.string().optional()}),ns=c.object({selector:c.string().min(1),behavior:c.string().optional(),location:c.string().optional(),showsCount:c.boolean().optional()}),ss=c.object({categories:c.array(c.string()).optional(),productSchema:c.object({fields:c.array(c.string()).optional(),idFormat:c.string().optional()}).optional(),searchBehavior:c.string().optional()}),ot=c.object({path:c.string().min(1),payload:c.record(c.unknown()).default({}),updatedAt:c.string().datetime().optional()}).strict(),W=c.object({version:c.string().default("1"),siteMap:es.optional(),workflows:c.record(rs).default({}),policies:c.record(c.union([c.string(),c.array(c.string())])).default({}),catalog:ss.optional(),uiGuidance:c.record(ns).default({}),pageContexts:c.record(ot).default({}),updatedAt:c.string().datetime().optional()}),Vt=W.parse({}),os=c.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"]),at=c.object({id:c.string(),siteId:c.string(),sessionId:c.string(),occurredAt:c.string().datetime(),type:os,tool:c.string().optional(),agent:Kn.nullable().optional(),policy:qn.optional(),durationMs:c.number().int().nonnegative().optional(),outcome:c.enum(["success","error","blocked"]),error:c.string().optional(),metadata:c.record(c.unknown()).default({})});c.object({publishableKey:c.string(),events:c.array(at).min(1).max(100)});var We=class extends Error{code;constructor(t,e){super(e),this.name="AgentronicsError",this.code=t;}};var as=()=>{if(typeof navigator>"u")return null;let t=navigator.modelContext;return t&&typeof t=="object"?t:null},Be=async(t={})=>{let{pollMs:e=500}=t,r=Date.now();for(;;){let n=as();if(n)return is(n);if(Date.now()-r>=e)return null;await new Promise(s=>setTimeout(s,50));}},is=t=>({class:"webmcp",trust:"detected",confidence:1,vendor:t.vendor??t.client??null,userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:"2026.04",signals:{webmcp:true,toolCount:Array.isArray(t.tools)?t.tools.length:0}});var cs=[/HeadlessChrome/i,/Headless/i,/PhantomJS/i,/SlimerJS/i],ls=()=>({hit:(typeof navigator<"u"&&navigator.webdriver)===true,weight:.6,detail:"navigator.webdriver === true"}),us=()=>{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_*"}`}},ds=()=>{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"}},ps=()=>{if(typeof navigator>"u")return {hit:false,weight:.7};let t=navigator.userAgent??"",e=cs.some(r=>r.test(t));return e?{hit:e,weight:.7,detail:`headless UA: ${t}`}:{hit:e,weight:.7}},fs=()=>{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"}},ms=()=>{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"}},hs={webdriver:ls,chromedriver:us,headlessUa:ps,languages:fs,permissions:ms,plugins:ds},ze=(t={})=>{let{threshold:e=.4}=t,r={},n=0,s=0;for(let[a,i]of Object.entries(hs)){let l=i();n+=l.weight,r[a]={hit:l.hit,weight:l.weight,detail:l.detail},l.hit&&(s+=l.weight);}let o=n===0?0:s/n;return o<e?null:{class:"dom",trust:"detected",confidence:o,vendor:null,userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:"2026.04",signals:r}};var Ut=()=>[{id:"webmcp.model-context",status:"stable",detect:()=>Be({pollMs:0})},{id:"dom.automation-heuristics",status:"beta",detect:()=>ze()}],it=(t=Ut())=>{let e=new Map(t.map(r=>[r.id,r]));return {register(r){e.set(r.id,r);},list(r){let n=[...e.values()];return r?n.filter(s=>s.status===r):n},async detectAll(r=false){for(let n of e.values()){if(n.status==="research"&&!r)continue;let s=await n.detect();if(s)return s}return null}}};var Zt=async(t={})=>{if(t.customDetectors?.length){let e=await it(t.customDetectors).detectAll(!!t.experimental);if(e)return e}if(t.webmcp!==false){let e=await Be(t.webmcp??{});if(e)return e}if(t.dom!==false){let e=ze(t.dom??{});if(e)return e}return null};var gs=t=>({class:t.class,trust:"declared",confidence:1,vendor:t.vendor,userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:"2026.04",signals:{declared:true,hasToken:true,tokenExpiresAt:t.expiresAt??null}}),Ft=()=>{let t=null;return {present(e){let r=Ne.safeParse(e);if(!r.success)throw new We("invalid_api_key",`Invalid identity claim: ${r.error.issues[0]?.message??"unknown"}`);let n={claim:r.data,identity:gs(r.data)};return t=n,n},clear(){t=null;},preferOver(e){return t?e?Bt(t.identity.trust,e.trust)?t.identity:e:t.identity:e},snapshot(){return t}}};var Gt=t=>{let e=null;for(let r of t)(!e||V[r.trust]>V[e.trust])&&(e=r);return e};var Ht=()=>({name:"bearer",async authenticate(t,e){if(!t.bearerToken)return null;let r=await e.verifyToken?.("bearer",t.bearerToken);return {class:t.classHint??"dom",trust:r?.trust??"verified",confidence:1,vendor:r?.vendor??t.vendorHint??"bearer",userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:"2026.04",signals:{bearer:true,verifiedRemotely:!!r}}}});var Kt=()=>({name:"detection",async authenticate(t){return t.detected??null}});var Jt=()=>({name:"extensionToken",async authenticate(t,e){if(!t.extensionToken)return null;let r=await e.verifyToken?.("extensionToken",t.extensionToken);return {class:"dom",trust:r?.trust??"verified",confidence:1,vendor:r?.vendor??t.vendorHint??"browser-extension",userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:"2026.04",signals:{extensionToken:true,verifiedRemotely:!!r}}}});var qt=()=>({name:"mtls",async authenticate(t,e){if(!t.xfccHeader)return null;let r=await e.verifyToken?.("mtls",t.xfccHeader);return {class:t.classHint??"webmcp",trust:r?.trust??"verified",confidence:1,vendor:r?.vendor??t.vendorHint??"mtls",userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:"2026.04",signals:{mtls:true,subject:r?.subject??null,verifiedRemotely:!!r,...r?.signals??{}}}}});var Yt=()=>({name:"oauth2",async authenticate(t,e){if(!t.oauth2AccessToken)return null;let r=await e.verifyToken?.("oauth2",t.oauth2AccessToken);return {class:t.classHint??"webmcp",trust:t.oauth2Subject?"linked":r?.trust??"verified",confidence:1,vendor:r?.vendor??t.vendorHint??"oauth2",userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:"2026.04",signals:{oauth2:true,subject:t.oauth2Subject??null,verifiedRemotely:!!r}}}});var ys=t=>({class:t.class,trust:"declared",confidence:1,vendor:t.vendor,userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:"2026.04",signals:{declared:true,hasToken:true,tokenExpiresAt:t.expiresAt??null}}),Xt=()=>({name:"selfDeclaration",async authenticate(t){return t.declaration?ys(Ne.parse(t.declaration)):null}});var Qt=()=>({name:"sessionLink",async authenticate(t,e){if(!t.sessionLinkToken)return null;let r=await e.verifyToken?.("sessionLink",t.sessionLinkToken);return {class:t.classHint??"screenshot",trust:t.linkedUserId?"linked":r?.trust??"verified",confidence:1,vendor:r?.vendor??t.vendorHint??"session-link",userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:"2026.04",signals:{sessionLink:true,linkedUserId:t.linkedUserId??null,verifiedRemotely:!!r}}}});var er=()=>({name:"sso",async authenticate(t,e){if(!t.ssoIdToken)return null;let r=await e.verifyToken?.("sso",t.ssoIdToken);return {class:t.classHint??"dom",trust:r?.trust??"verified",confidence:1,vendor:r?.vendor??t.vendorHint??"sso",userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:"2026.04",signals:{sso:true,subject:r?.subject??null,verifiedRemotely:!!r,...r?.signals??{}}}}});var tr=()=>({name:"spiffe",async authenticate(t,e){if(!t.spiffeJwt)return null;let r=await e.verifyToken?.("spiffe",t.spiffeJwt),n=r?.vendor==="google";return {class:t.classHint??"webmcp",trust:r?.trust??"verified",confidence:1,vendor:r?.vendor??t.vendorHint??"spiffe",userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:"2026.04",signals:{spiffe:true,spiffeId:r?.subject??null,subject:r?.subject??null,verifiedRemotely:!!r,...n?{googleAgent:true}:{},...r?.signals??{}}}}});var rr=()=>({name:"xAgentHeader",async authenticate(t){if(!t.xAgentHeader)return null;let[e="x-agent",r="dom",n]=t.xAgentHeader.split(";"),s=Oe.safeParse(r);return {class:s.success?s.data:"dom",trust:n?"verified":"declared",confidence:n?1:.8,vendor:e,userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:"2026.04",signals:{xAgentHeader:true,hasProof:!!n}}}});var vs=()=>[Kt(),Xt(),Ht(),rr(),Jt(),Qt(),Yt(),er(),tr(),qt()],xs={detection:"detection",selfDeclaration:"declaration",bearer:"bearer",xAgentHeader:"x-agent-header",extensionToken:"extension",sessionLink:"session-link",oauth2:"oauth2",sso:"sso",spiffe:"spiffe",mtls:"mtls"},bs=(t,e)=>t==="spiffe"&&e.signals?.googleAgent===true?"google-agent":xs[t],nr=({methods:t=vs(),context:e={},onTrace:r}={})=>({async authenticate(n){let s=[],o={};for(let x of t){let k=await x.authenticate(n,e);o[x.name]=!!k,k&&s.push({method:x.name,identity:k});}let a=Gt(s.map(x=>x.identity)),i=a?s.find(x=>x.identity===a):void 0,l=i?bs(i.method,i.identity):void 0,u=typeof a?.signals?.subject=="string"?a.signals.subject:void 0,p={type:a?"auth.identity_presented":"sdk.error",agent:a,outcome:a?"success":"error",metadata:{methods:o,...l?{protocol:l}:{},...u?{subject:u}:{}}};return a||(p.error="No auth method produced an identity."),r?.(p),a},methods(){return t.map(n=>n.name)}});var _s={identity:null,source:"initial",updatedAt:null},sr=()=>{let t=_s,e=new Set,r=()=>{e.size!==0&&e.forEach(n=>n(t));};return {snapshot(){return t},set(n,s){t={identity:n,source:s,updatedAt:new Date().toISOString()},r();},subscribe(n){return e.add(n),()=>{e.delete(n);}}}};var ks=()=>{let t=new Map;return {read:e=>t.get(e)??null,write:(e,r)=>{t.set(e,r);}}},ws=()=>typeof window>"u"||!window.localStorage?ks():{read:t=>{try{return window.localStorage.getItem(t)}catch{return null}},write:(t,e)=>{try{window.localStorage.setItem(t,e);}catch{}}},Ts=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},or=(t=ws())=>({consume(e,r,n=Date.now()){let s=`agtx:rate:${e}`,o=Ts(t.read(s)),a=o&&o.resetAt>n?o.resetAt:n+r.windowSeconds*1e3,i=o&&o.resetAt>n?o.count+1:1;return t.write(s,JSON.stringify({count:i,resetAt:a})),{allowed:i<=r.max,remaining:Math.max(0,r.max-i),resetAt:a}}});var Ss=(t,e)=>t==="*"||t===e?true:t.includes("*")?new RegExp("^"+t.replace(/[.+?^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*")+"$").test(e):false,As=(t,e)=>{let r=t?V[t.trust]:-1,n=V[e.minTrust];return r>=n},Is=(t,e)=>e.allowedClasses.length===0?true:t?e.allowedClasses.includes(t.class):false,ar="review",Ms=(t,e)=>{let r=e?.class??"unknown",n=e?.vendor??"unknown",s=e?.trust??"none";return `${t}:${r}:${n}:${s}`},ir=(t=[],e={})=>{let r=t.map(s=>Le.parse(s)),n=e.rateLimiter??or();return {set(s){r=s.map(o=>Le.parse(o));},list(){return [...r]},evaluate({tool:s,identity:o}){for(let a of r)if(Ss(a.tool,s)){if(!As(o,a))return {decision:"deny",ruleId:a.id,reason:`Rule "${a.id}" requires trust >= ${a.minTrust}.`};if(!Is(o,a))return {decision:"deny",ruleId:a.id,reason:`Rule "${a.id}" restricts to classes: ${a.allowedClasses.join(", ")}.`};if(a.rateLimit){let i=n.consume(Ms(s,o),a.rateLimit);if(!i.allowed)return {decision:"deny",ruleId:a.id,reason:`Rule "${a.id}" rate limit exceeded. Resets at ${new Date(i.resetAt).toISOString()}.`}}return {decision:a.decision,ruleId:a.id,reason:`Matched rule "${a.id}".`}}return {decision:ar,ruleId:null,reason:`No rule matched tool "${s}". Falling back to "${ar}".`}}}};var cr=({gatewayUrl:t,siteId:e,publishableKey:r,fetcher:n=fetch})=>{let s={policies:[],etag:null};return {snapshot(){return {policies:[...s.policies],etag:s.etag}},async sync(){let o=await n(`${t.replace(/\/$/,"")}/v1/sites/${encodeURIComponent(e)}/policies`,{headers:{authorization:`Bearer ${r}`,...s.etag?{"if-none-match":s.etag}:{}}});if(o.status===304)return this.snapshot();if(!o.ok)throw new Error(`Policy sync failed with status ${o.status}.`);let a=await o.json();return s={policies:Le.array().parse(a.policies??[]),etag:o.headers.get("etag")},this.snapshot()}}};var lr=({message:t="Agent action blocked by site policy.",durationMs:e=2400,documentRef:r=typeof document>"u"?void 0:document}={})=>{if(!r?.body)return null;let n=r.createElement("div");return n.setAttribute("role","status"),n.setAttribute("data-agentronics-deny-overlay","true"),n.textContent=t,Object.assign(n.style,{position:"fixed",zIndex:"2147483647",left:"50%",bottom:"24px",transform:"translateX(-50%)",maxWidth:"min(520px, calc(100vw - 32px))",padding:"12px 16px",borderRadius:"8px",background:"#07091A",color:"#F4F4F5",border:"1px solid #6366F1",boxShadow:"0 20px 48px -16px rgba(7,9,26,0.55)",font:"13px/1.45 'Space Mono', ui-monospace, SFMono-Regular, Menlo, monospace"}),r.body.appendChild(n),window.setTimeout(()=>n.remove(),e),n};var ur=({policyEngine:t,getIdentity:e,documentRef:r=typeof document>"u"?void 0:document,selector:n="[data-agentronics-tool]"})=>{if(!r)return {uninstall:()=>{}};let s=o=>{let a=o.target instanceof Element?o.target.closest(n):null;if(!(a instanceof HTMLElement))return;let i=a.dataset.agentronicsTool;i&&Promise.resolve(e()).then(l=>{let u=t.evaluate({tool:i,identity:l});u.decision==="deny"&&(o.preventDefault(),o.stopPropagation(),lr({message:u.reason,documentRef:r}));});};return r.addEventListener("click",s,true),{uninstall:()=>r.removeEventListener("click",s,true)}};var ct=()=>{let t=new Map;return {read:e=>t.get(e)??null,write:(e,r)=>{t.set(e,r);},remove:e=>{t.delete(e);},keys:()=>[...t.keys()]}},dr=(t,e)=>({read:r=>{try{return t.getItem(e+r)}catch{return null}},write:(r,n)=>{try{t.setItem(e+r,n);}catch{}},remove:r=>{try{t.removeItem(e+r);}catch{}},keys:()=>{let r=[];try{for(let n=0;n<t.length;n++){let s=t.key(n);s&&s.startsWith(e)&&r.push(s.slice(e.length));}}catch{}return r}}),pr="agtx:",fr=()=>{let t=typeof window<"u",e=t&&typeof window.sessionStorage<"u"?dr(window.sessionStorage,pr+"session:"):ct(),r=t&&typeof window.localStorage<"u"?dr(window.localStorage,pr+"user:"):ct();return {session:e,user:r,org:ct()}};var mr=(t,e)=>t.expiresAt!==null&&t.expiresAt<=e,hr=t=>{if(!t)return null;try{let e=JSON.parse(t);return typeof e!="object"||e===null?null:e}catch{return null}},Rs=t=>JSON.stringify(t),gr=(t={})=>{let e=fr(),r=l=>{t.onTrace?.(l);};return {get:(l,u={})=>{let p=u.scope??"session",x=e[p],k=hr(x.read(l));if(!k){r({type:"memory.accessed",metadata:{operation:"get",key:l,scope:p,hit:false}});return}if(mr(k,Date.now())){x.remove(l),r({type:"memory.accessed",metadata:{operation:"get",key:l,scope:p,hit:false,expired:true}});return}return r({type:"memory.accessed",metadata:{operation:"get",key:l,scope:p,hit:true}}),k.value},set:(l,u,p={})=>{let x=p.scope??"session",k=p.ttlSeconds??null,I=Date.now(),j={value:u,expiresAt:k===null?null:I+k*1e3,updatedAt:new Date(I).toISOString()};return e[x].write(l,Rs(j)),r({type:"memory.updated",metadata:{operation:"set",key:l,scope:x,ttlSeconds:k}}),st.parse({key:l,value:u,scope:x,ttlSeconds:k,updatedAt:j.updatedAt})},remove:(l,u={})=>{let p=u.scope??"session";e[p].remove(l),r({type:"memory.updated",metadata:{operation:"remove",key:l,scope:p}});},list:(l={})=>{let u=l.scope??"session",p=e[u],x=Date.now(),k=[];for(let I of p.keys()){let j=hr(p.read(I));if(j){if(mr(j,x)){p.remove(I);continue}k.push(st.parse({key:I,value:j.value,scope:u,ttlSeconds:j.expiresAt===null?null:Math.max(0,Math.round((j.expiresAt-x)/1e3)),updatedAt:j.updatedAt}));}}return r({type:"memory.accessed",metadata:{operation:"list",scope:u,count:k.length}}),k},clear:(l={})=>{let u=l.scope??"session",p=e[u],x=p.keys().length;for(let k of p.keys())p.remove(k);r({type:"memory.updated",metadata:{operation:"clear",scope:u,count:x}});}}};var lt=t=>W.parse(JSON.parse(JSON.stringify(t))),Ke=t=>({...t,updatedAt:new Date().toISOString()}),yr=(t={})=>{let e=W.parse({...Vt,...t.initial??{}}),r=null,n=new Set,s=T=>{t.onTrace?.(T);},o=()=>{r=null;},a=()=>{if(n.size===0)return;let T=lt(e);r=T,n.forEach(A=>A(T));},i=T=>{let A=W.parse({...e,...T,workflows:{...e.workflows,...T.workflows??{}},policies:{...e.policies,...T.policies??{}},uiGuidance:{...e.uiGuidance,...T.uiGuidance??{}},pageContexts:{...e.pageContexts,...T.pageContexts??{}}});return e=Ke(A),o(),s({type:"memory.updated",metadata:{kind:"site",operation:"provide",keys:Object.keys(T)}}),a(),p()},l=(T,A)=>{let M=T.split(".").filter(Boolean);if(M.length===0)throw new Error("siteMemory.update() requires a non-empty dot-path.");let te=JSON.parse(JSON.stringify(e)),re=te;for(let xe=0;xe<M.length-1;xe++){let B=M[xe],be=re[B];(typeof be!="object"||be===null||Array.isArray(be))&&(re[B]={}),re=re[B];}return re[M[M.length-1]]=A,e=Ke(W.parse(te)),o(),s({type:"memory.updated",metadata:{kind:"site",operation:"update",path:T}}),a(),p()},u=T=>{let A=ot.parse({path:T.path,payload:T.payload,updatedAt:new Date().toISOString()});return e=Ke({...e,pageContexts:{...e.pageContexts,[T.path]:A}}),o(),s({type:"memory.updated",metadata:{kind:"site",operation:"provideForPage",path:T.path}}),a(),{...A,payload:{...A.payload}}},p=()=>(r||(r=lt(e)),r);return {provide:i,update:l,provideForPage:u,snapshot:p,get:T=>{if(s({type:"memory.accessed",metadata:{kind:"site",operation:T?"get":"snapshot",path:T??null}}),!T)return lt(e);let A=T.split(".").filter(Boolean),M=e;for(let te of A){if(typeof M!="object"||M===null)return;M=M[te];}return M},getForPage:T=>{s({type:"memory.accessed",metadata:{kind:"site",operation:"getForPage",path:T}});let A=e.pageContexts[T];return A?{...A,payload:{...A.payload}}:null},replace:T=>(e=Ke(W.parse(T)),o(),a(),p()),subscribe:T=>(n.add(T),()=>{n.delete(T);})}};var vr=({gatewayUrl:t,siteId:e,publishableKey:r,fetcher:n=fetch})=>{let s={memory:null,etag:null};return {snapshot(){return {memory:s.memory?W.parse(s.memory):null,etag:s.etag}},async sync(){let o=await n(`${t.replace(/\/$/,"")}/v1/sites/${encodeURIComponent(e)}/memory`,{headers:{authorization:`Bearer ${r}`,...s.etag?{"if-none-match":s.etag}:{}}});if(o.status===304)return this.snapshot();if(!o.ok)throw new Error(`Memory sync failed with status ${o.status}.`);let a=await o.json();return s={memory:W.parse(a.memory??{}),etag:o.headers.get("etag")},this.snapshot()}}};var ee="agent-context-",ut="agentronics-site-context",Es=t=>{try{return JSON.stringify(t)}catch{return "{}"}},Je=(t,e,r)=>{let n=t.querySelector(`meta[name="${e}"]`);n||(n=t.createElement("meta"),n.setAttribute("name",e),t.head.appendChild(n)),n.setAttribute("content",r);},qe=(t,e)=>{t.querySelectorAll(`meta[name="${e}"]`).forEach(r=>r.remove());},dt=({doc:t=typeof document>"u"?null:document,snapshot:e,schemaType:r="WebSite"})=>{if(!t)return {uninstall:()=>{}};Je(t,`${ee}version`,e.version),Je(t,`${ee}updated-at`,e.updatedAt??new Date().toISOString()),e.siteMap?.navigation?.flow&&Je(t,`${ee}flow`,e.siteMap.navigation.flow),Je(t,`${ee}workflows`,Object.keys(e.workflows).join(","));let n=t.getElementById(ut);return n||(n=t.createElement("script"),n.type="application/ld+json",n.id=ut,t.head.appendChild(n)),n.textContent=Es({"@context":"https://schema.org","@type":r,name:"Agentronics Site Memory",agentronics:e}),{uninstall:()=>{qe(t,`${ee}version`),qe(t,`${ee}updated-at`),qe(t,`${ee}flow`),qe(t,`${ee}workflows`),t.getElementById(ut)?.remove();}}};var xr="agentronics-memory-overlay",Cs=t=>`
2
2
  position: fixed;
3
3
  bottom: 16px;
4
4
  right: 16px;
@@ -12,6 +12,6 @@ z-index: 2147483647;
12
12
  opacity: ${t?"0":"1"};
13
13
  pointer-events: ${t?"none":"auto"};
14
14
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.35);
15
- `,yr=t=>{let e=t.siteMap?.pages?.length??0,r=Object.keys(t.workflows).length,n=Object.keys(t.uiGuidance).length;return `Agentronics site memory \xB7 pages:${e} \xB7 workflows:${r} \xB7 ui-hints:${n}`},pt=({doc:t=typeof document>"u"?null:document,snapshot:e,hidden:r=false})=>{if(!t)return {uninstall:()=>{},refresh:()=>{}};let n=t.getElementById(gr);return n||(n=t.createElement("div"),n.id=gr,n.setAttribute("role","note"),n.setAttribute("aria-label","Agentronics site memory summary"),n.setAttribute("data-agent-context","overlay"),t.body.appendChild(n)),n.setAttribute("style",Ss(r)),n.textContent=yr(e),{uninstall:()=>{n?.remove();},refresh:s=>{n&&(n.textContent=yr(s));}}};var vr="/.well-known/agent-context.json",ft=async({origin:t,fetcher:e=fetch,signal:r}={})=>{let n=(t?t.replace(/\/$/,""):typeof window<"u"?window.location.origin:"")+vr;if(!n.startsWith("http"))return null;let s={headers:{accept:"application/json"}};r!==void 0&&(s.signal=r);let o=await e(n,s);if(!o.ok){if(o.status===404)return null;throw new Error(`well-known agent-context fetch failed with status ${o.status}.`)}let i=await o.json();return W.parse(i)};var xr=({evaluate:t,setPolicies:e,listPolicies:r,onTrace:n})=>{let s=new Map,o=new Set,i=a=>{if(!a.authz||!e||!r)return;let c={id:`tool:${a.name}`,tool:a.name,...a.authz,rateLimit:a.rateLimit??a.authz.rateLimit};e([...r().filter(u=>u.id!==c.id),c]);};return {register(a){return s.set(a.name,a),o.delete(a.name),i(a),n?.({type:"tool.registered",tool:a.name,metadata:{version:a.version??null,group:a.group??null,stage:a.stage??null}}),()=>{s.delete(a.name),o.delete(a.name);}},unregister(a){s.delete(a),o.delete(a);},enable(a){!s.has(a)||!o.has(a)||(o.delete(a),n?.({type:"tool.surfaced",tool:a,metadata:{state:"enabled"}}));},disable(a){!s.has(a)||o.has(a)||(o.add(a),n?.({type:"tool.surfaced",tool:a,metadata:{state:"disabled"}}));},isEnabled:a=>s.has(a)&&!o.has(a),list({includeDisabled:a=false}={}){let c=[...s.values()];return a?c:c.filter(u=>!o.has(u.name))},get:a=>s.get(a),async execute(a,c,u=null){let f=s.get(a);if(!f)throw new Error(`Tool "${a}" is not registered.`);if(o.has(a)){let I={decision:"deny",ruleId:`tool:${a}`,reason:"Tool is disabled."};throw n?.({type:"tool.executed",tool:a,agent:u,policy:I,outcome:"blocked"}),new Error(I.reason)}let b=await t(a,{identity:u});if(b.decision==="deny")throw n?.({type:"tool.executed",tool:a,agent:u,policy:b,outcome:"blocked"}),new Error(b.reason);let w=await f.execute(c,{identity:u});return n?.({type:"tool.executed",tool:a,agent:u,policy:b,outcome:"success"}),w}}};var br=(t,e={})=>{let r=new Map;for(let i of t.stages)r.set(i.name,i);if(!r.has(t.initial))throw new Error(`Initial stage "${t.initial}" is not declared in progression stages.`);let n=t.initial,s=()=>{let i=r.get(n);return i?.enables?[n,...i.enables]:[n]},o=(i,a)=>{let c=n;if(!r.has(i))throw new Error(`Cannot transition to unknown stage "${i}".`);return i===n?{changed:false,from:c,to:i}:(n=i,e.onTrace?.({type:"tool.progressed",metadata:{from:c,to:i,trigger:a}}),{changed:true,from:c,to:i})};return {current:()=>n,enabledStages:()=>s(),notify(i){let c=r.get(n)?.transitions?.find(u=>u.on===i);return c?o(c.to,i):{changed:false,from:n,to:n}},set(i){return o(i,"manual")},reset(){let i=n;n=t.initial,i!==n&&e.onTrace?.({type:"tool.progressed",metadata:{from:i,to:n,trigger:"reset"}});},snapshot:()=>({current:n,enabled:s()})}};var As=(t,e)=>{let r=t.authz?.minTrust;return r?e?U[e.trust]<U[r]?{ok:false,reason:`trust-too-low:${e.trust}<${r}`}:{ok:true,reason:"trust-ok"}:{ok:false,reason:`requires-trust:${r}`}:{ok:true,reason:"no-trust-floor"}},Is=(t,e)=>{let r=t.authz?.allowedClasses??[];return r.length===0?{ok:true,reason:"no-class-restriction"}:e?r.includes(e.class)?{ok:true,reason:"class-ok"}:{ok:false,reason:`class-not-allowed:${e.class}`}:{ok:false,reason:`requires-class:${r.join("|")}`}},Rs=(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"},_r=(t,e)=>{let r=As(t,e.identity);if(!r.ok)return {tool:t,visible:false,reason:r.reason};let n=Is(t,e.identity);if(!n.ok)return {tool:t,visible:false,reason:n.reason};let s=Rs(t,e);return s.ok?t.authz?.decision==="deny"?{tool:t,visible:false,reason:"authz-deny"}:{tool:t,visible:true,reason:"visible"}:{tool:t,visible:false,reason:s.reason}},kr=(t,e)=>t.filter(r=>_r(r,e).visible),wr=(t,e)=>t.map(r=>_r(r,e));var Ms="default",Tr=t=>{let e=new Map;for(let r of t){let n=r.group??Ms,s=e.get(n)??[];s.push(r),e.set(n,s);}return [...e.entries()].sort(([r],[n])=>r.localeCompare(n)).map(([r,n])=>({name:r,tools:n}))};var mt=t=>t===null||typeof t!="object"?JSON.stringify(t):Array.isArray(t)?`[${t.map(mt).join(",")}]`:`{${Object.keys(t).sort().map(r=>`${JSON.stringify(r)}:${mt(t[r])}`).join(",")}}`,Es=t=>{let e={name:t.name,version:t.version??null,group:t.group??null,description:t.description??null,inputSchema:t.inputSchema??null,authz:t.authz??null,rateLimit:t.rateLimit??null},r=mt(e).length;return {name:t.name,characters:r,tokens:Math.ceil(r/4)}},Sr=t=>{let e=t.map(Es);return {total:e.reduce((n,s)=>n+s.tokens,0),perTool:e}};var Ar=t=>t.provider?t.provider:(t.doc?.defaultView??(typeof globalThis<"u"?globalThis:null))?.navigator?.modelContext??null,Cs=(t,e)=>{let r={name:t.name,invoke:n=>e(t,n)};return t.description!==void 0&&(r.description=t.description),t.inputSchema!==void 0&&(r.inputSchema=t.inputSchema),r},Ir=(t={})=>{let e=t.invoke??(async(n,s)=>n.execute(s,{identity:null})),r=null;return {publish(n){let s=Ar(t);return s?(r?.revoke(),r=s.provideContext({tools:n.map(o=>Cs(o,e))}),{revoked:true}):{revoked:false}},revoke(){r?.revoke(),r=null;},available:()=>!!Ar(t)}};var ht=(t=500)=>{let e=[];return {add(r){e.push(r),e.length>t&&e.splice(0,e.length-t);},list(){return [...e]},clear(){e.length=0;}}};var Rr=(t,e)=>t===void 0?e:Math.max(0,Math.min(1,t)),gt=(t={})=>{let e=Rr(t.traceRate,1),r=Rr(t.errorRate,1),n=t.random??Math.random;return {shouldKeep(s){let o=s.outcome==="error"?r:e;return n()<o}}};var Os="[REDACTED]",Ps=t=>{if(t!==void 0)return JSON.parse(JSON.stringify(t))},yt=(t,e)=>{if(e.length===0||typeof t!="object"||t===null)return;let[r,...n]=e;if(!r)return;if(Array.isArray(t)){for(let o of t)yt(o,e);return}let s=t;if(r in s){if(n.length===0){s[r]=Os;return}yt(s[r],n);}},vt=(t,e=[])=>{if(e.length===0)return t;let r=Ps(t);for(let n of e)yt(r,n.split(".").filter(Boolean));return r},xt=["metadata.password","metadata.token","metadata.authorization","metadata.cookie"];var 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)}`},bt=({siteId:t,bufferSize:e,sessionId:r=Mr("ses"),scrubPaths:n=xt,exporters:s=[],onExporterError:o,...i})=>{let a=ht(e),c=gt(i);return {sessionId:r,async emit(u){let f=at.parse(vt({id:Mr("trc"),siteId:t,sessionId:r,occurredAt:new Date().toISOString(),outcome:u.outcome??"success",metadata:{},...u},n));return c.shouldKeep(f)?(a.add(f),await Promise.all(s.map(async b=>{try{await b.export([f]);}catch(w){o?.(w,b,f);}})),f):null},list:()=>a.list(),clear:()=>a.clear()}};var _t=()=>({name:"console",export(t){for(let e of t)console.info("[agentronics:trace]",e.type,e);}});var kt=({gatewayUrl:t,publishableKey:e,fetcher:r=fetch})=>({name:"gateway",async export(n){let s={publishableKey:e,events:n};await r(`${t.replace(/\/$/,"")}/v1/traces`,{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${e}`},body:JSON.stringify(s)});}});var js=t=>new Promise(e=>setTimeout(e,t)),Tt=({url:t,fetcher:e=fetch,maxRetries:r=2,queueLimit:n=500})=>({name:"webhook",async export(s){let i=[...Ds(t),...s].slice(-n),a=0;for(;;){let c=await e(t,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({events:i})});if(c.ok){Er(t,[]);return}if(a>=r)throw Er(t,i),new Error(`Webhook exporter failed with status ${c.status}.`);a+=1,await js(100*a);}}}),wt=t=>`agtx:webhook:${t}`,Ds=t=>{if(typeof window>"u"||!window.localStorage)return [];try{let e=window.localStorage.getItem(wt(t));return e?JSON.parse(e):[]}catch{return []}},Er=(t,e)=>{if(!(typeof window>"u"||!window.localStorage))try{if(e.length===0){window.localStorage.removeItem(wt(t));return}window.localStorage.setItem(wt(t),JSON.stringify(e));}catch{}};var Cr="https://gateway.agentronics.dev",$s=t=>{if(t===void 0)return Cr;if(t===Cr)return t;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 gateway URLs. Omit \`gatewayUrl\` to use the canonical https://gateway.agentronics.dev. The only accepted override is a localhost / 127.0.0.1 URL for local development. Got: ${t}`)},Ns=t=>{let{publishableKey:e,siteId:r="default",debug:n=false,policies:s=[],trace:o={}}=t,i=$s(t.gatewayUrl),a=Wt(e);if(a==="secret")throw new We("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 We("invalid_api_key",`Agentronics.init() expected a key starting with "${Ce}".`);let c=o.enabled??true,u=[...n?[_t()]:[],...o.gateway?[kt({gatewayUrl:i,publishableKey:e})]:[],...o.webhookUrl?[Tt({url:o.webhookUrl})]:[],...o.exporters??[]],f={siteId:r,exporters:c?u:[],onExporterError:(m,S)=>{n&&console.warn(`[agentronics] trace exporter "${S.name}" failed`,m);}};o.bufferSize!==void 0&&(f.bufferSize=o.bufferSize),o.traceRate!==void 0&&(f.traceRate=o.traceRate),o.errorRate!==void 0&&(f.errorRate=o.errorRate),o.scrubPaths!==void 0&&(f.scrubPaths=o.scrubPaths);let b=bt(f),w=m=>{c&&b.emit(m);},I=Gt(),j={onTrace:w};t.auth!==void 0&&(j.context=t.auth);let T=er(j),A=tr(),R=sr(s),te=or({gatewayUrl:i,siteId:r,publishableKey:e}),re=fr({onTrace:w}),xe={onTrace:w};t.siteMemory!==void 0&&(xe.initial=t.siteMemory);let z=mr(xe),be=hr({gatewayUrl:i,siteId:r,publishableKey:e}),Ye=async m=>{let S=Date.now(),E=await Zt(m),D=I.preferOver(E);return c&&await b.emit({type:D?"agent.detected":"agent.missed",agent:D,durationMs:Date.now()-S,metadata:{detectedClass:E?.class??null,presented:I.snapshot()!==null}}),A.set(D,"detect"),D},St=async(m,S={})=>{let E=Date.now(),D=S.identity!==void 0?S.identity:await Ye(),Qe=R.evaluate({tool:m,identity:D});return c&&await b.emit({type:"authz.evaluated",tool:m,agent:D,policy:Qe,outcome:Qe.decision==="deny"?"blocked":"success",durationMs:Date.now()-E}),Qe},_e=xr({evaluate:St,setPolicies:m=>R.set(m),listPolicies:()=>R.list(),onTrace:w});for(let m of t.tools??[])_e.register(m);let ke=t.progression?br(t.progression,{onTrace:w}):null,At=m=>{let S={identity:m};return ke&&(S.stage=ke.current(),S.enabledStages=ke.enabledStages()),S},Pe=m=>kr(_e.list(),At(m)),It=m=>{if(!ke)return;ke.notify(m).changed&&Xe.publish(Pe(null));},Xe=Ir({invoke:async(m,S)=>{let E=await _e.execute(m.name,S,null);return It(m.name),E}});return Object.freeze({publishableKey:e,siteId:r,gatewayUrl:i,debug:n,memory:re,siteMemory:z,memoryCache:be,tracer:b,auth:T,agentContext:A,authz:R,policyCache:te,tools:_e,progression:ke,webmcp:Xe,detect:Ye,authenticate:async m=>{let S=await T.authenticate(m);return A.set(S,"authenticate"),S},presentIdentity:m=>{let S=I.present(m);return w({type:"auth.identity_presented",agent:S.identity,metadata:{vendor:S.identity.vendor,class:S.identity.class}}),A.set(S.identity,"declare"),S},clearIdentity:()=>{I.clear(),w({type:"auth.identity_cleared"}),A.set(null,"cleared");},presentedIdentity:()=>I.snapshot(),setPolicies:m=>{R.set(m),w({type:"authz.policies_set",metadata:{count:m.length}});},listPolicies:()=>R.list(),syncPolicies:async()=>{let m=await te.sync();return R.set(m.policies),w({type:"authz.policies_set",metadata:{count:m.policies.length,synced:true}}),m.policies},syncSiteMemory:async()=>{let m=await be.sync();return m.memory&&(z.replace(m.memory),w({type:"memory.updated",metadata:{kind:"site",operation:"sync",etag:m.etag}})),m.memory},provideSiteMemory:m=>z.provide(m),provideForPage:m=>{z.provideForPage(m);},installMemoryDelivery:({metaTags:m=true,overlay:S=false}={})=>{let E=[];return m&&E.push(dt({snapshot:z.snapshot()})),S&&E.push(pt({snapshot:z.snapshot()})),{uninstall:()=>{E.forEach(D=>D.uninstall());}}},fetchWellKnown:async m=>{let S={};m!==void 0&&(S.origin=m);let E=await ft(S);return E&&(z.replace(E),w({type:"memory.updated",metadata:{kind:"site",operation:"wellKnown",origin:m??null}})),E},installDomEnforcer:()=>ir({policyEngine:R,getIdentity:()=>Ye({webmcp:{pollMs:0}})}),registerTool:m=>_e.register(m),surfaceTools:({identity:m=null}={})=>Pe(m),explainSurfacing:({identity:m=null}={})=>wr(_e.list(),At(m)),groupedTools:({identity:m=null}={})=>Tr(Pe(m)),estimateTokens:({identity:m=null}={})=>Sr(Pe(m)),publishToWebMcp:({identity:m=null}={})=>{let S=Pe(m),E=Xe.publish(S);return S.forEach(D=>{w({type:"tool.surfaced",tool:D.name,metadata:{state:"published",trust:m?.trust??null,group:D.group??null}});}),{revoked:E.revoked,surfaced:S.length}},notifyToolInvoked:m=>It(m),evaluate:St,traces:()=>b.list(),clearTraces:()=>b.clear(),async ping(){try{let m=await fetch(`${i.replace(/\/$/,"")}/v1/health`,{method:"GET",headers:{authorization:`Bearer ${e}`}});if(!m.ok)return {ok:!1,status:m.status,error:`gateway returned ${m.status}`};let S=await m.json().catch(()=>null)??{};return {ok:!0,status:m.status,body:S}}catch(m){return {ok:false,status:0,error:m instanceof Error?m.message:String(m)}}}})};
16
- exports.init=Ns;return exports;})({});//# sourceMappingURL=init-only.global.js.map
15
+ `,br=t=>{let e=t.siteMap?.pages?.length??0,r=Object.keys(t.workflows).length,n=Object.keys(t.uiGuidance).length;return `Agentronics site memory \xB7 pages:${e} \xB7 workflows:${r} \xB7 ui-hints:${n}`},pt=({doc:t=typeof document>"u"?null:document,snapshot:e,hidden:r=false})=>{if(!t)return {uninstall:()=>{},refresh:()=>{}};let n=t.getElementById(xr);return n||(n=t.createElement("div"),n.id=xr,n.setAttribute("role","note"),n.setAttribute("aria-label","Agentronics site memory summary"),n.setAttribute("data-agent-context","overlay"),t.body.appendChild(n)),n.setAttribute("style",Cs(r)),n.textContent=br(e),{uninstall:()=>{n?.remove();},refresh:s=>{n&&(n.textContent=br(s));}}};var _r="/.well-known/agent-context.json",ft=async({origin:t,fetcher:e=fetch,signal:r}={})=>{let n=(t?t.replace(/\/$/,""):typeof window<"u"?window.location.origin:"")+_r;if(!n.startsWith("http"))return null;let s={headers:{accept:"application/json"}};r!==void 0&&(s.signal=r);let o=await e(n,s);if(!o.ok){if(o.status===404)return null;throw new Error(`well-known agent-context fetch failed with status ${o.status}.`)}let a=await o.json();return W.parse(a)};var kr=({evaluate:t,setPolicies:e,listPolicies:r,onTrace:n})=>{let s=new Map,o=new Set,a=i=>{if(!i.authz||!e||!r)return;let l={id:`tool:${i.name}`,tool:i.name,...i.authz,rateLimit:i.rateLimit??i.authz.rateLimit};e([...r().filter(u=>u.id!==l.id),l]);};return {register(i){return s.set(i.name,i),o.delete(i.name),a(i),n?.({type:"tool.registered",tool:i.name,metadata:{version:i.version??null,group:i.group??null,stage:i.stage??null}}),()=>{s.delete(i.name),o.delete(i.name);}},unregister(i){s.delete(i),o.delete(i);},enable(i){!s.has(i)||!o.has(i)||(o.delete(i),n?.({type:"tool.surfaced",tool:i,metadata:{state:"enabled"}}));},disable(i){!s.has(i)||o.has(i)||(o.add(i),n?.({type:"tool.surfaced",tool:i,metadata:{state:"disabled"}}));},isEnabled:i=>s.has(i)&&!o.has(i),list({includeDisabled:i=false}={}){let l=[...s.values()];return i?l:l.filter(u=>!o.has(u.name))},get:i=>s.get(i),async execute(i,l,u=null){let p=s.get(i);if(!p)throw new Error(`Tool "${i}" is not registered.`);if(o.has(i)){let I={decision:"deny",ruleId:`tool:${i}`,reason:"Tool is disabled."};throw n?.({type:"tool.executed",tool:i,agent:u,policy:I,outcome:"blocked"}),new Error(I.reason)}let x=await t(i,{identity:u});if(x.decision==="deny")throw n?.({type:"tool.executed",tool:i,agent:u,policy:x,outcome:"blocked"}),new Error(x.reason);let k=await p.execute(l,{identity:u});return n?.({type:"tool.executed",tool:i,agent:u,policy:x,outcome:"success"}),k}}};var wr=(t,e={})=>{let r=new Map;for(let a of t.stages)r.set(a.name,a);if(!r.has(t.initial))throw new Error(`Initial stage "${t.initial}" is not declared in progression stages.`);let n=t.initial,s=()=>{let a=r.get(n);return a?.enables?[n,...a.enables]:[n]},o=(a,i)=>{let l=n;if(!r.has(a))throw new Error(`Cannot transition to unknown stage "${a}".`);return a===n?{changed:false,from:l,to:a}:(n=a,e.onTrace?.({type:"tool.progressed",metadata:{from:l,to:a,trigger:i}}),{changed:true,from:l,to:a})};return {current:()=>n,enabledStages:()=>s(),notify(a){let l=r.get(n)?.transitions?.find(u=>u.on===a);return l?o(l.to,a):{changed:false,from:n,to:n}},set(a){return o(a,"manual")},reset(){let a=n;n=t.initial,a!==n&&e.onTrace?.({type:"tool.progressed",metadata:{from:a,to:n,trigger:"reset"}});},snapshot:()=>({current:n,enabled:s()})}};var Os=(t,e)=>{let r=t.authz?.minTrust;return r?e?V[e.trust]<V[r]?{ok:false,reason:`trust-too-low:${e.trust}<${r}`}:{ok:true,reason:"trust-ok"}:{ok:false,reason:`requires-trust:${r}`}:{ok:true,reason:"no-trust-floor"}},Ps=(t,e)=>{let r=t.authz?.allowedClasses??[];return r.length===0?{ok:true,reason:"no-class-restriction"}:e?r.includes(e.class)?{ok:true,reason:"class-ok"}:{ok:false,reason:`class-not-allowed:${e.class}`}:{ok:false,reason:`requires-class:${r.join("|")}`}},js=(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"},Tr=(t,e)=>{let r=Os(t,e.identity);if(!r.ok)return {tool:t,visible:false,reason:r.reason};let n=Ps(t,e.identity);if(!n.ok)return {tool:t,visible:false,reason:n.reason};let s=js(t,e);return s.ok?t.authz?.decision==="deny"?{tool:t,visible:false,reason:"authz-deny"}:{tool:t,visible:true,reason:"visible"}:{tool:t,visible:false,reason:s.reason}},Sr=(t,e)=>t.filter(r=>Tr(r,e).visible),Ar=(t,e)=>t.map(r=>Tr(r,e));var Ds="default",Ir=t=>{let e=new Map;for(let r of t){let n=r.group??Ds,s=e.get(n)??[];s.push(r),e.set(n,s);}return [...e.entries()].sort(([r],[n])=>r.localeCompare(n)).map(([r,n])=>({name:r,tools:n}))};var mt=t=>t===null||typeof t!="object"?JSON.stringify(t):Array.isArray(t)?`[${t.map(mt).join(",")}]`:`{${Object.keys(t).sort().map(r=>`${JSON.stringify(r)}:${mt(t[r])}`).join(",")}}`,$s=t=>{let e={name:t.name,version:t.version??null,group:t.group??null,description:t.description??null,inputSchema:t.inputSchema??null,authz:t.authz??null,rateLimit:t.rateLimit??null},r=mt(e).length;return {name:t.name,characters:r,tokens:Math.ceil(r/4)}},Mr=t=>{let e=t.map($s);return {total:e.reduce((n,s)=>n+s.tokens,0),perTool:e}};var Rr=t=>t.provider?t.provider:(t.doc?.defaultView??(typeof globalThis<"u"?globalThis:null))?.navigator?.modelContext??null,Ns=(t,e)=>{let r={name:t.name,invoke:n=>e(t,n)};return t.description!==void 0&&(r.description=t.description),t.inputSchema!==void 0&&(r.inputSchema=t.inputSchema),r},Er=(t={})=>{let e=t.invoke??(async(n,s)=>n.execute(s,{identity:null})),r=null;return {publish(n){let s=Rr(t);return s?(r?.revoke(),r=s.provideContext({tools:n.map(o=>Ns(o,e))}),{revoked:true}):{revoked:false}},revoke(){r?.revoke(),r=null;},available:()=>!!Rr(t)}};var ht=(t=500)=>{let e=[];return {add(r){e.push(r),e.length>t&&e.splice(0,e.length-t);},list(){return [...e]},clear(){e.length=0;}}};var Cr=(t,e)=>t===void 0?e:Math.max(0,Math.min(1,t)),gt=(t={})=>{let e=Cr(t.traceRate,1),r=Cr(t.errorRate,1),n=t.random??Math.random;return {shouldKeep(s){let o=s.outcome==="error"?r:e;return n()<o}}};var Ls="[REDACTED]",Ws=t=>{if(t!==void 0)return JSON.parse(JSON.stringify(t))},yt=(t,e)=>{if(e.length===0||typeof t!="object"||t===null)return;let[r,...n]=e;if(!r)return;if(Array.isArray(t)){for(let o of t)yt(o,e);return}let s=t;if(r in s){if(n.length===0){s[r]=Ls;return}yt(s[r],n);}},vt=(t,e=[])=>{if(e.length===0)return t;let r=Ws(t);for(let n of e)yt(r,n.split(".").filter(Boolean));return r},xt=["metadata.password","metadata.token","metadata.authorization","metadata.cookie"];var Or=t=>{let e=globalThis.crypto;return e&&"randomUUID"in e?`${t}_${e.randomUUID()}`:`${t}_${Date.now().toString(36)}_${Math.random().toString(36).slice(2)}`},bt=({siteId:t,bufferSize:e,sessionId:r=Or("ses"),scrubPaths:n=xt,exporters:s=[],onExporterError:o,...a})=>{let i=ht(e),l=gt(a);return {sessionId:r,async emit(u){let p=at.parse(vt({id:Or("trc"),siteId:t,sessionId:r,occurredAt:new Date().toISOString(),outcome:u.outcome??"success",metadata:{},...u},n));return l.shouldKeep(p)?(i.add(p),await Promise.all(s.map(async x=>{try{await x.export([p]);}catch(k){o?.(k,x,p);}})),p):null},list:()=>i.list(),clear:()=>i.clear()}};var _t=()=>({name:"console",export(t){for(let e of t)console.info("[agentronics:trace]",e.type,e);}});var kt=({gatewayUrl:t,publishableKey:e,fetcher:r=fetch})=>({name:"gateway",async export(n){let s={publishableKey:e,events:n};await r(`${t.replace(/\/$/,"")}/v1/traces`,{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${e}`},body:JSON.stringify(s)});}});var Bs=t=>new Promise(e=>setTimeout(e,t)),Tt=({url:t,fetcher:e=fetch,maxRetries:r=2,queueLimit:n=500})=>({name:"webhook",async export(s){let a=[...zs(t),...s].slice(-n),i=0;for(;;){let l=await e(t,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({events:a})});if(l.ok){Pr(t,[]);return}if(i>=r)throw Pr(t,a),new Error(`Webhook exporter failed with status ${l.status}.`);i+=1,await Bs(100*i);}}}),wt=t=>`agtx:webhook:${t}`,zs=t=>{if(typeof window>"u"||!window.localStorage)return [];try{let e=window.localStorage.getItem(wt(t));return e?JSON.parse(e):[]}catch{return []}},Pr=(t,e)=>{if(!(typeof window>"u"||!window.localStorage))try{if(e.length===0){window.localStorage.removeItem(wt(t));return}window.localStorage.setItem(wt(t),JSON.stringify(e));}catch{}};var jr="https://gateway.agentronics.dev",Vs=t=>{if(t===void 0)return jr;if(t===jr)return t;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 gateway URLs. Omit \`gatewayUrl\` to use the canonical https://gateway.agentronics.dev. The only accepted override is a localhost / 127.0.0.1 URL for local development. Got: ${t}`)},Us=t=>{let{publishableKey:e,siteId:r="default",debug:n=false,policies:s=[],trace:o={}}=t,a=Vs(t.gatewayUrl),i=Wt(e);if(i==="secret")throw new We("wrong_key_kind","A secret key was passed to Agentronics.init(). Browser code must use a publishable key (agtx_pk_*).");if(i!=="publishable")throw new We("invalid_api_key",`Agentronics.init() expected a key starting with "${Ce}".`);let l=o.enabled??true,u=[...n?[_t()]:[],...o.gateway?[kt({gatewayUrl:a,publishableKey:e})]:[],...o.webhookUrl?[Tt({url:o.webhookUrl})]:[],...o.exporters??[]],p={siteId:r,exporters:l?u:[],onExporterError:(m,S)=>{n&&console.warn(`[agentronics] trace exporter "${S.name}" failed`,m);}};o.bufferSize!==void 0&&(p.bufferSize=o.bufferSize),o.traceRate!==void 0&&(p.traceRate=o.traceRate),o.errorRate!==void 0&&(p.errorRate=o.errorRate),o.scrubPaths!==void 0&&(p.scrubPaths=o.scrubPaths);let x=bt(p),k=m=>{l&&x.emit(m);},I=Ft(),j={onTrace:k};t.auth!==void 0&&(j.context=t.auth);let T=nr(j),A=sr(),M=ir(s),te=cr({gatewayUrl:a,siteId:r,publishableKey:e}),re=gr({onTrace:k}),xe={onTrace:k};t.siteMemory!==void 0&&(xe.initial=t.siteMemory);let B=yr(xe),be=vr({gatewayUrl:a,siteId:r,publishableKey:e}),Ye=async m=>{let S=Date.now(),E=await Zt(m),D=I.preferOver(E);return l&&await x.emit({type:D?"agent.detected":"agent.missed",agent:D,durationMs:Date.now()-S,metadata:{detectedClass:E?.class??null,presented:I.snapshot()!==null}}),A.set(D,"detect"),D},St=async(m,S={})=>{let E=Date.now(),D=S.identity!==void 0?S.identity:await Ye(),Qe=M.evaluate({tool:m,identity:D});return l&&await x.emit({type:"authz.evaluated",tool:m,agent:D,policy:Qe,outcome:Qe.decision==="deny"?"blocked":"success",durationMs:Date.now()-E}),Qe},_e=kr({evaluate:St,setPolicies:m=>M.set(m),listPolicies:()=>M.list(),onTrace:k});for(let m of t.tools??[])_e.register(m);let ke=t.progression?wr(t.progression,{onTrace:k}):null,At=m=>{let S={identity:m};return ke&&(S.stage=ke.current(),S.enabledStages=ke.enabledStages()),S},Pe=m=>Sr(_e.list(),At(m)),It=m=>{if(!ke)return;ke.notify(m).changed&&Xe.publish(Pe(null));},Xe=Er({invoke:async(m,S)=>{let E=await _e.execute(m.name,S,null);return It(m.name),E}});return Object.freeze({publishableKey:e,siteId:r,gatewayUrl:a,debug:n,memory:re,siteMemory:B,memoryCache:be,tracer:x,auth:T,agentContext:A,authz:M,policyCache:te,tools:_e,progression:ke,webmcp:Xe,detect:Ye,authenticate:async m=>{let S=await T.authenticate(m);return A.set(S,"authenticate"),S},presentIdentity:m=>{let S=I.present(m);return k({type:"auth.identity_presented",agent:S.identity,metadata:{vendor:S.identity.vendor,class:S.identity.class}}),A.set(S.identity,"declare"),S},clearIdentity:()=>{I.clear(),k({type:"auth.identity_cleared"}),A.set(null,"cleared");},presentedIdentity:()=>I.snapshot(),setPolicies:m=>{M.set(m),k({type:"authz.policies_set",metadata:{count:m.length}});},listPolicies:()=>M.list(),syncPolicies:async()=>{let m=await te.sync();return M.set(m.policies),k({type:"authz.policies_set",metadata:{count:m.policies.length,synced:true}}),m.policies},syncSiteMemory:async()=>{let m=await be.sync();return m.memory&&(B.replace(m.memory),k({type:"memory.updated",metadata:{kind:"site",operation:"sync",etag:m.etag}})),m.memory},provideSiteMemory:m=>B.provide(m),provideForPage:m=>{B.provideForPage(m);},installMemoryDelivery:({metaTags:m=true,overlay:S=false}={})=>{let E=[];return m&&E.push(dt({snapshot:B.snapshot()})),S&&E.push(pt({snapshot:B.snapshot()})),{uninstall:()=>{E.forEach(D=>D.uninstall());}}},fetchWellKnown:async m=>{let S={};m!==void 0&&(S.origin=m);let E=await ft(S);return E&&(B.replace(E),k({type:"memory.updated",metadata:{kind:"site",operation:"wellKnown",origin:m??null}})),E},installDomEnforcer:()=>ur({policyEngine:M,getIdentity:()=>Ye({webmcp:{pollMs:0}})}),registerTool:m=>_e.register(m),surfaceTools:({identity:m=null}={})=>Pe(m),explainSurfacing:({identity:m=null}={})=>Ar(_e.list(),At(m)),groupedTools:({identity:m=null}={})=>Ir(Pe(m)),estimateTokens:({identity:m=null}={})=>Mr(Pe(m)),publishToWebMcp:({identity:m=null}={})=>{let S=Pe(m),E=Xe.publish(S);return S.forEach(D=>{k({type:"tool.surfaced",tool:D.name,metadata:{state:"published",trust:m?.trust??null,group:D.group??null}});}),{revoked:E.revoked,surfaced:S.length}},notifyToolInvoked:m=>It(m),evaluate:St,traces:()=>x.list(),clearTraces:()=>x.clear(),async ping(){try{let m=await fetch(`${a.replace(/\/$/,"")}/v1/health`,{method:"GET",headers:{authorization:`Bearer ${e}`}});if(!m.ok)return {ok:!1,status:m.status,error:`gateway returned ${m.status}`};let S=await m.json().catch(()=>null)??{};return {ok:!0,status:m.status,body:S}}catch(m){return {ok:false,status:0,error:m instanceof Error?m.message:String(m)}}}})};
16
+ exports.init=Us;return exports;})({});//# sourceMappingURL=init-only.global.js.map
17
17
  //# sourceMappingURL=init-only.global.js.map