@agentronics/sdk 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-77VJ65X2.js +17 -0
- package/dist/chunk-77VJ65X2.js.map +1 -0
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +25 -3
- package/dist/index.d.ts +25 -3
- package/dist/index.global.js +3 -3
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/init-only.cjs +3 -3
- package/dist/init-only.global.js +2 -2
- package/dist/init-only.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-YNRQTQM4.js +0 -17
- package/dist/chunk-YNRQTQM4.js.map +0 -1
package/dist/index.global.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var Agentronics=(function(exports){'use strict';var Xr=Object.defineProperty;var Qr=(t,e)=>{for(var r in e)Xr(t,r,{get:e[r],enumerable:true});};var l={};Qr(l,{BRAND:()=>An,DIRTY:()=>se,EMPTY_PATH:()=>nn,INVALID:()=>v,NEVER:()=>uo,OK:()=>P,ParseStatus:()=>M,Schema:()=>k,ZodAny:()=>Q,ZodArray:()=>q,ZodBigInt:()=>ie,ZodBoolean:()=>ce,ZodBranded:()=>Be,ZodCatch:()=>xe,ZodDate:()=>le,ZodDefault:()=>ve,ZodDiscriminatedUnion:()=>He,ZodEffects:()=>B,ZodEnum:()=>ye,ZodError:()=>j,ZodFirstPartyTypeKind:()=>x,ZodFunction:()=>qe,ZodIntersection:()=>fe,ZodIssueCode:()=>d,ZodLazy:()=>me,ZodLiteral:()=>ge,ZodMap:()=>Me,ZodNaN:()=>Pe,ZodNativeEnum:()=>he,ZodNever:()=>U,ZodNull:()=>de,ZodNullable:()=>F,ZodNumber:()=>ae,ZodObject:()=>N,ZodOptional:()=>L,ZodParsedType:()=>g,ZodPipeline:()=>Ve,ZodPromise:()=>ee,ZodReadonly:()=>be,ZodRecord:()=>Je,ZodSchema:()=>k,ZodSet:()=>Oe,ZodString:()=>X,ZodSymbol:()=>Ee,ZodTransformer:()=>B,ZodTuple:()=>Z,ZodType:()=>k,ZodUndefined:()=>ue,ZodUnion:()=>pe,ZodUnknown:()=>J,ZodVoid:()=>Re,addIssueToContext:()=>m,any:()=>jn,array:()=>Wn,bigint:()=>Rn,boolean:()=>fr,coerce:()=>lo,custom:()=>ur,date:()=>Mn,datetimeRegex:()=>cr,defaultErrorMap:()=>K,discriminatedUnion:()=>zn,effect:()=>to,enum:()=>Xn,function:()=>Jn,getErrorMap:()=>Ae,getParsedType:()=>G,instanceof:()=>Cn,intersection:()=>Gn,isAborted:()=>Fe,isAsync:()=>Ie,isDirty:()=>Ke,isValid:()=>Y,late:()=>In,lazy:()=>qn,literal:()=>Yn,makeIssue:()=>We,map:()=>Kn,nan:()=>En,nativeEnum:()=>Qn,never:()=>$n,null:()=>Dn,nullable:()=>no,number:()=>pr,object:()=>Bn,objectUtil:()=>ft,oboolean:()=>co,onumber:()=>io,optional:()=>ro,ostring:()=>ao,pipeline:()=>so,preprocess:()=>oo,promise:()=>eo,quotelessJson:()=>en,record:()=>Fn,set:()=>Hn,setErrorMap:()=>rn,strictObject:()=>Vn,string:()=>dr,symbol:()=>On,transformer:()=>to,tuple:()=>Zn,undefined:()=>Pn,union:()=>Un,unknown:()=>Nn,util:()=>S,void:()=>Ln});var S;(function(t){t.assertEqual=o=>{};function e(o){}t.assertIs=e;function r(o){throw new Error}t.assertNever=r,t.arrayToEnum=o=>{let s={};for(let a of o)s[a]=a;return s},t.getValidEnumValues=o=>{let s=t.objectKeys(o).filter(c=>typeof o[o[c]]!="number"),a={};for(let c of s)a[c]=o[c];return t.objectValues(a)},t.objectValues=o=>t.objectKeys(o).map(function(s){return o[s]}),t.objectKeys=typeof Object.keys=="function"?o=>Object.keys(o):o=>{let s=[];for(let a in o)Object.prototype.hasOwnProperty.call(o,a)&&s.push(a);return s},t.find=(o,s)=>{for(let a of o)if(s(a))return a},t.isInteger=typeof Number.isInteger=="function"?o=>Number.isInteger(o):o=>typeof o=="number"&&Number.isFinite(o)&&Math.floor(o)===o;function n(o,s=" | "){return o.map(a=>typeof a=="string"?`'${a}'`:a).join(s)}t.joinValues=n,t.jsonStringifyReplacer=(o,s)=>typeof s=="bigint"?s.toString():s;})(S||(S={}));var ft;(function(t){t.mergeShapes=(e,r)=>({...e,...r});})(ft||(ft={}));var g=S.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),G=t=>{switch(typeof t){case "undefined":return g.undefined;case "string":return g.string;case "number":return Number.isNaN(t)?g.nan:g.number;case "boolean":return g.boolean;case "function":return g.function;case "bigint":return g.bigint;case "symbol":return g.symbol;case "object":return Array.isArray(t)?g.array:t===null?g.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?g.promise:typeof Map<"u"&&t instanceof Map?g.map:typeof Set<"u"&&t instanceof Set?g.set:typeof Date<"u"&&t instanceof Date?g.date:g.object;default:return g.unknown}};var d=S.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"]),en=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),j=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(s){return s.message},n={_errors:[]},o=s=>{for(let a of s.issues)if(a.code==="invalid_union")a.unionErrors.map(o);else if(a.code==="invalid_return_type")o(a.returnTypeError);else if(a.code==="invalid_arguments")o(a.argumentsError);else if(a.path.length===0)n._errors.push(r(a));else {let c=n,i=0;for(;i<a.path.length;){let u=a.path[i];i===a.path.length-1?(c[u]=c[u]||{_errors:[]},c[u]._errors.push(r(a))):c[u]=c[u]||{_errors:[]},c=c[u],i++;}}};return o(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,S.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){let r={},n=[];for(let o of this.issues)if(o.path.length>0){let s=o.path[0];r[s]=r[s]||[],r[s].push(e(o));}else n.push(e(o));return {formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};j.create=t=>new j(t);var tn=(t,e)=>{let r;switch(t.code){case d.invalid_type:t.received===g.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case d.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,S.jsonStringifyReplacer)}`;break;case d.unrecognized_keys:r=`Unrecognized key(s) in object: ${S.joinValues(t.keys,", ")}`;break;case d.invalid_union:r="Invalid input";break;case d.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${S.joinValues(t.options)}`;break;case d.invalid_enum_value:r=`Invalid enum value. Expected ${S.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}"`:S.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,S.assertNever(t);}return {message:r}},K=tn;var nr=K;function rn(t){nr=t;}function Ae(){return nr}var We=t=>{let{data:e,path:r,errorMaps:n,issueData:o}=t,s=[...r,...o.path||[]],a={...o,path:s};if(o.message!==void 0)return {...o,path:s,message:o.message};let c="",i=n.filter(u=>!!u).slice().reverse();for(let u of i)c=u(a,{data:e,defaultError:c}).message;return {...o,path:s,message:c}},nn=[];function m(t,e){let r=Ae(),n=We({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===K?void 0:K].filter(o=>!!o)});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 o of r){if(o.status==="aborted")return v;o.status==="dirty"&&e.dirty(),n.push(o.value);}return {status:e.value,value:n}}static async mergeObjectAsync(e,r){let n=[];for(let o of r){let s=await o.key,a=await o.value;n.push({key:s,value:a});}return t.mergeObjectSync(e,n)}static mergeObjectSync(e,r){let n={};for(let o of r){let{key:s,value:a}=o;if(s.status==="aborted"||a.status==="aborted")return v;s.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),s.value!=="__proto__"&&(typeof a.value<"u"||o.alwaysSet)&&(n[s.value]=a.value);}return {status:e.value,value:n}}},v=Object.freeze({status:"aborted"}),se=t=>({status:"dirty",value:t}),P=t=>({status:"valid",value:t}),Fe=t=>t.status==="aborted",Ke=t=>t.status==="dirty",Y=t=>t.status==="valid",Ie=t=>typeof Promise<"u"&&t instanceof Promise;var y;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message;})(y||(y={}));var W=class{constructor(e,r,n,o){this._cachedPath=[],this.parent=e,this.data=r,this._path=n,this._key=o;}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},or=(t,e)=>{if(Y(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 j(t.common.issues);return this._error=r,this._error}}};function w(t){if(!t)return {};let{errorMap:e,invalid_type_error:r,required_error:n,description:o}=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:o}:{errorMap:(a,c)=>{let{message:i}=t;return a.code==="invalid_enum_value"?{message:i??c.defaultError}:typeof c.data>"u"?{message:i??n??c.defaultError}:a.code!=="invalid_type"?{message:c.defaultError}:{message:i??r??c.defaultError}},description:o}}var k=class{get description(){return this._def.description}_getType(e){return G(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:G(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:G(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let r=this._parse(e);if(Ie(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:G(e)},o=this._parseSync({data:e,path:n.path,parent:n});return or(n,o)}"~validate"(e){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:G(e)};if(!this["~standard"].async)try{let n=this._parseSync({data:e,path:[],parent:r});return Y(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=>Y(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:G(e)},o=this._parse({data:e,path:n.path,parent:n}),s=await(Ie(o)?o:Promise.resolve(o));return or(n,s)}refine(e,r){let n=o=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(o):r;return this._refinement((o,s)=>{let a=e(o),c=()=>s.addIssue({code:d.custom,...n(o)});return typeof Promise<"u"&&a instanceof Promise?a.then(i=>i?true:(c(),false)):a?true:(c(),false)})}refinement(e,r){return this._refinement((n,o)=>e(n)?true:(o.addIssue(typeof r=="function"?r(n,o):r),false))}_refinement(e){return new B({schema:this,typeName:x.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 L.create(this,this._def)}nullable(){return F.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return q.create(this)}promise(){return ee.create(this,this._def)}or(e){return pe.create([this,e],this._def)}and(e){return fe.create(this,e,this._def)}transform(e){return new B({...w(this._def),schema:this,typeName:x.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let r=typeof e=="function"?e:()=>e;return new ve({...w(this._def),innerType:this,defaultValue:r,typeName:x.ZodDefault})}brand(){return new Be({typeName:x.ZodBranded,type:this,...w(this._def)})}catch(e){let r=typeof e=="function"?e:()=>e;return new xe({...w(this._def),innerType:this,catchValue:r,typeName:x.ZodCatch})}describe(e){let r=this.constructor;return new r({...this._def,description:e})}pipe(e){return Ve.create(this,e)}readonly(){return be.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},on=/^c[^\s-]{8,}$/i,sn=/^[0-9a-z]+$/,an=/^[0-9A-HJKMNP-TV-Z]{26}$/i,cn=/^[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,ln=/^[a-z0-9_-]{21}$/i,un=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,dn=/^[-+]?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)?)??$/,pn=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,fn="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",mt,mn=/^(?:(?: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])$/,gn=/^(?:(?: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])$/,yn=/^(([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]))$/,hn=/^(([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])$/,vn=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,xn=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,ar="((\\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])))",bn=new RegExp(`^${ar}$`);function ir(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 _n(t){return new RegExp(`^${ir(t)}$`)}function cr(t){let e=`${ar}T${ir(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 wn(t,e){return !!((e==="v4"||!e)&&mn.test(t)||(e==="v6"||!e)&&yn.test(t))}function kn(t,e){if(!un.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,"="),o=JSON.parse(atob(n));return !(typeof o!="object"||o===null||"typ"in o&&o?.typ!=="JWT"||!o.alg||e&&o.alg!==e)}catch{return false}}function Tn(t,e){return !!((e==="v4"||!e)&&gn.test(t)||(e==="v6"||!e)&&hn.test(t))}var X=class t extends k{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==g.string){let s=this._getOrReturnCtx(e);return m(s,{code:d.invalid_type,expected:g.string,received:s.parsedType}),v}let n=new M,o;for(let s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(o=this._getOrReturnCtx(e,o),m(o,{code:d.too_small,minimum:s.value,type:"string",inclusive:true,exact:false,message:s.message}),n.dirty());else if(s.kind==="max")e.data.length>s.value&&(o=this._getOrReturnCtx(e,o),m(o,{code:d.too_big,maximum:s.value,type:"string",inclusive:true,exact:false,message:s.message}),n.dirty());else if(s.kind==="length"){let a=e.data.length>s.value,c=e.data.length<s.value;(a||c)&&(o=this._getOrReturnCtx(e,o),a?m(o,{code:d.too_big,maximum:s.value,type:"string",inclusive:true,exact:true,message:s.message}):c&&m(o,{code:d.too_small,minimum:s.value,type:"string",inclusive:true,exact:true,message:s.message}),n.dirty());}else if(s.kind==="email")pn.test(e.data)||(o=this._getOrReturnCtx(e,o),m(o,{validation:"email",code:d.invalid_string,message:s.message}),n.dirty());else if(s.kind==="emoji")mt||(mt=new RegExp(fn,"u")),mt.test(e.data)||(o=this._getOrReturnCtx(e,o),m(o,{validation:"emoji",code:d.invalid_string,message:s.message}),n.dirty());else if(s.kind==="uuid")cn.test(e.data)||(o=this._getOrReturnCtx(e,o),m(o,{validation:"uuid",code:d.invalid_string,message:s.message}),n.dirty());else if(s.kind==="nanoid")ln.test(e.data)||(o=this._getOrReturnCtx(e,o),m(o,{validation:"nanoid",code:d.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid")on.test(e.data)||(o=this._getOrReturnCtx(e,o),m(o,{validation:"cuid",code:d.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid2")sn.test(e.data)||(o=this._getOrReturnCtx(e,o),m(o,{validation:"cuid2",code:d.invalid_string,message:s.message}),n.dirty());else if(s.kind==="ulid")an.test(e.data)||(o=this._getOrReturnCtx(e,o),m(o,{validation:"ulid",code:d.invalid_string,message:s.message}),n.dirty());else if(s.kind==="url")try{new URL(e.data);}catch{o=this._getOrReturnCtx(e,o),m(o,{validation:"url",code:d.invalid_string,message:s.message}),n.dirty();}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(o=this._getOrReturnCtx(e,o),m(o,{validation:"regex",code:d.invalid_string,message:s.message}),n.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(o=this._getOrReturnCtx(e,o),m(o,{code:d.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),n.dirty()):s.kind==="toLowerCase"?e.data=e.data.toLowerCase():s.kind==="toUpperCase"?e.data=e.data.toUpperCase():s.kind==="startsWith"?e.data.startsWith(s.value)||(o=this._getOrReturnCtx(e,o),m(o,{code:d.invalid_string,validation:{startsWith:s.value},message:s.message}),n.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(o=this._getOrReturnCtx(e,o),m(o,{code:d.invalid_string,validation:{endsWith:s.value},message:s.message}),n.dirty()):s.kind==="datetime"?cr(s).test(e.data)||(o=this._getOrReturnCtx(e,o),m(o,{code:d.invalid_string,validation:"datetime",message:s.message}),n.dirty()):s.kind==="date"?bn.test(e.data)||(o=this._getOrReturnCtx(e,o),m(o,{code:d.invalid_string,validation:"date",message:s.message}),n.dirty()):s.kind==="time"?_n(s).test(e.data)||(o=this._getOrReturnCtx(e,o),m(o,{code:d.invalid_string,validation:"time",message:s.message}),n.dirty()):s.kind==="duration"?dn.test(e.data)||(o=this._getOrReturnCtx(e,o),m(o,{validation:"duration",code:d.invalid_string,message:s.message}),n.dirty()):s.kind==="ip"?wn(e.data,s.version)||(o=this._getOrReturnCtx(e,o),m(o,{validation:"ip",code:d.invalid_string,message:s.message}),n.dirty()):s.kind==="jwt"?kn(e.data,s.alg)||(o=this._getOrReturnCtx(e,o),m(o,{validation:"jwt",code:d.invalid_string,message:s.message}),n.dirty()):s.kind==="cidr"?Tn(e.data,s.version)||(o=this._getOrReturnCtx(e,o),m(o,{validation:"cidr",code:d.invalid_string,message:s.message}),n.dirty()):s.kind==="base64"?vn.test(e.data)||(o=this._getOrReturnCtx(e,o),m(o,{validation:"base64",code:d.invalid_string,message:s.message}),n.dirty()):s.kind==="base64url"?xn.test(e.data)||(o=this._getOrReturnCtx(e,o),m(o,{validation:"base64url",code:d.invalid_string,message:s.message}),n.dirty()):S.assertNever(s);return {status:n.value,value:e.data}}_regex(e,r,n){return this.refinement(o=>e.test(o),{validation:r,code:d.invalid_string,...y.errToObj(n)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...y.errToObj(e)})}url(e){return this._addCheck({kind:"url",...y.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...y.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...y.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...y.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...y.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...y.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...y.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...y.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...y.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...y.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...y.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...y.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,...y.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,...y.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...y.errToObj(e)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...y.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r?.position,...y.errToObj(r?.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...y.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...y.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...y.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...y.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...y.errToObj(r)})}nonempty(e){return this.min(1,y.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}};X.create=t=>new X({checks:[],typeName:x.ZodString,coerce:t?.coerce??false,...w(t)});function Sn(t,e){let r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,o=r>n?r:n,s=Number.parseInt(t.toFixed(o).replace(".","")),a=Number.parseInt(e.toFixed(o).replace(".",""));return s%a/10**o}var ae=class t extends k{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)!==g.number){let s=this._getOrReturnCtx(e);return m(s,{code:d.invalid_type,expected:g.number,received:s.parsedType}),v}let n,o=new M;for(let s of this._def.checks)s.kind==="int"?S.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),m(n,{code:d.invalid_type,expected:"integer",received:"float",message:s.message}),o.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(n=this._getOrReturnCtx(e,n),m(n,{code:d.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:false,message:s.message}),o.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),m(n,{code:d.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:false,message:s.message}),o.dirty()):s.kind==="multipleOf"?Sn(e.data,s.value)!==0&&(n=this._getOrReturnCtx(e,n),m(n,{code:d.not_multiple_of,multipleOf:s.value,message:s.message}),o.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),m(n,{code:d.not_finite,message:s.message}),o.dirty()):S.assertNever(s);return {status:o.value,value:e.data}}gte(e,r){return this.setLimit("min",e,true,y.toString(r))}gt(e,r){return this.setLimit("min",e,false,y.toString(r))}lte(e,r){return this.setLimit("max",e,true,y.toString(r))}lt(e,r){return this.setLimit("max",e,false,y.toString(r))}setLimit(e,r,n,o){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:y.toString(o)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:y.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:false,message:y.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:false,message:y.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:true,message:y.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:true,message:y.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:y.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:y.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:true,value:Number.MIN_SAFE_INTEGER,message:y.toString(e)})._addCheck({kind:"max",inclusive:true,value:Number.MAX_SAFE_INTEGER,message:y.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"&&S.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)}};ae.create=t=>new ae({checks:[],typeName:x.ZodNumber,coerce:t?.coerce||false,...w(t)});var ie=class t extends k{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)!==g.bigint)return this._getInvalidInput(e);let n,o=new M;for(let s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(n=this._getOrReturnCtx(e,n),m(n,{code:d.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),o.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),m(n,{code:d.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),o.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),m(n,{code:d.not_multiple_of,multipleOf:s.value,message:s.message}),o.dirty()):S.assertNever(s);return {status:o.value,value:e.data}}_getInvalidInput(e){let r=this._getOrReturnCtx(e);return m(r,{code:d.invalid_type,expected:g.bigint,received:r.parsedType}),v}gte(e,r){return this.setLimit("min",e,true,y.toString(r))}gt(e,r){return this.setLimit("min",e,false,y.toString(r))}lte(e,r){return this.setLimit("max",e,true,y.toString(r))}lt(e,r){return this.setLimit("max",e,false,y.toString(r))}setLimit(e,r,n,o){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:y.toString(o)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:false,message:y.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:false,message:y.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:true,message:y.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:true,message:y.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:y.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}};ie.create=t=>new ie({checks:[],typeName:x.ZodBigInt,coerce:t?.coerce??false,...w(t)});var ce=class extends k{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==g.boolean){let n=this._getOrReturnCtx(e);return m(n,{code:d.invalid_type,expected:g.boolean,received:n.parsedType}),v}return P(e.data)}};ce.create=t=>new ce({typeName:x.ZodBoolean,coerce:t?.coerce||false,...w(t)});var le=class t extends k{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==g.date){let s=this._getOrReturnCtx(e);return m(s,{code:d.invalid_type,expected:g.date,received:s.parsedType}),v}if(Number.isNaN(e.data.getTime())){let s=this._getOrReturnCtx(e);return m(s,{code:d.invalid_date}),v}let n=new M,o;for(let s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(o=this._getOrReturnCtx(e,o),m(o,{code:d.too_small,message:s.message,inclusive:true,exact:false,minimum:s.value,type:"date"}),n.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(o=this._getOrReturnCtx(e,o),m(o,{code:d.too_big,message:s.message,inclusive:true,exact:false,maximum:s.value,type:"date"}),n.dirty()):S.assertNever(s);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:y.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:y.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}};le.create=t=>new le({checks:[],coerce:t?.coerce||false,typeName:x.ZodDate,...w(t)});var Ee=class extends k{_parse(e){if(this._getType(e)!==g.symbol){let n=this._getOrReturnCtx(e);return m(n,{code:d.invalid_type,expected:g.symbol,received:n.parsedType}),v}return P(e.data)}};Ee.create=t=>new Ee({typeName:x.ZodSymbol,...w(t)});var ue=class extends k{_parse(e){if(this._getType(e)!==g.undefined){let n=this._getOrReturnCtx(e);return m(n,{code:d.invalid_type,expected:g.undefined,received:n.parsedType}),v}return P(e.data)}};ue.create=t=>new ue({typeName:x.ZodUndefined,...w(t)});var de=class extends k{_parse(e){if(this._getType(e)!==g.null){let n=this._getOrReturnCtx(e);return m(n,{code:d.invalid_type,expected:g.null,received:n.parsedType}),v}return P(e.data)}};de.create=t=>new de({typeName:x.ZodNull,...w(t)});var Q=class extends k{constructor(){super(...arguments),this._any=true;}_parse(e){return P(e.data)}};Q.create=t=>new Q({typeName:x.ZodAny,...w(t)});var J=class extends k{constructor(){super(...arguments),this._unknown=true;}_parse(e){return P(e.data)}};J.create=t=>new J({typeName:x.ZodUnknown,...w(t)});var U=class extends k{_parse(e){let r=this._getOrReturnCtx(e);return m(r,{code:d.invalid_type,expected:g.never,received:r.parsedType}),v}};U.create=t=>new U({typeName:x.ZodNever,...w(t)});var Re=class extends k{_parse(e){if(this._getType(e)!==g.undefined){let n=this._getOrReturnCtx(e);return m(n,{code:d.invalid_type,expected:g.void,received:n.parsedType}),v}return P(e.data)}};Re.create=t=>new Re({typeName:x.ZodVoid,...w(t)});var q=class t extends k{_parse(e){let{ctx:r,status:n}=this._processInputParams(e),o=this._def;if(r.parsedType!==g.array)return m(r,{code:d.invalid_type,expected:g.array,received:r.parsedType}),v;if(o.exactLength!==null){let a=r.data.length>o.exactLength.value,c=r.data.length<o.exactLength.value;(a||c)&&(m(r,{code:a?d.too_big:d.too_small,minimum:c?o.exactLength.value:void 0,maximum:a?o.exactLength.value:void 0,type:"array",inclusive:true,exact:true,message:o.exactLength.message}),n.dirty());}if(o.minLength!==null&&r.data.length<o.minLength.value&&(m(r,{code:d.too_small,minimum:o.minLength.value,type:"array",inclusive:true,exact:false,message:o.minLength.message}),n.dirty()),o.maxLength!==null&&r.data.length>o.maxLength.value&&(m(r,{code:d.too_big,maximum:o.maxLength.value,type:"array",inclusive:true,exact:false,message:o.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((a,c)=>o.type._parseAsync(new W(r,a,r.path,c)))).then(a=>M.mergeArray(n,a));let s=[...r.data].map((a,c)=>o.type._parseSync(new W(r,a,r.path,c)));return M.mergeArray(n,s)}get element(){return this._def.type}min(e,r){return new t({...this._def,minLength:{value:e,message:y.toString(r)}})}max(e,r){return new t({...this._def,maxLength:{value:e,message:y.toString(r)}})}length(e,r){return new t({...this._def,exactLength:{value:e,message:y.toString(r)}})}nonempty(e){return this.min(1,e)}};q.create=(t,e)=>new q({type:t,minLength:null,maxLength:null,exactLength:null,typeName:x.ZodArray,...w(e)});function Ce(t){if(t instanceof N){let e={};for(let r in t.shape){let n=t.shape[r];e[r]=L.create(Ce(n));}return new N({...t._def,shape:()=>e})}else return t instanceof q?new q({...t._def,type:Ce(t.element)}):t instanceof L?L.create(Ce(t.unwrap())):t instanceof F?F.create(Ce(t.unwrap())):t instanceof Z?Z.create(t.items.map(e=>Ce(e))):t}var N=class t extends k{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=S.objectKeys(e);return this._cached={shape:e,keys:r},this._cached}_parse(e){if(this._getType(e)!==g.object){let u=this._getOrReturnCtx(e);return m(u,{code:d.invalid_type,expected:g.object,received:u.parsedType}),v}let{status:n,ctx:o}=this._processInputParams(e),{shape:s,keys:a}=this._getCached(),c=[];if(!(this._def.catchall instanceof U&&this._def.unknownKeys==="strip"))for(let u in o.data)a.includes(u)||c.push(u);let i=[];for(let u of a){let p=s[u],h=o.data[u];i.push({key:{status:"valid",value:u},value:p._parse(new W(o,h,o.path,u)),alwaysSet:u in o.data});}if(this._def.catchall instanceof U){let u=this._def.unknownKeys;if(u==="passthrough")for(let p of c)i.push({key:{status:"valid",value:p},value:{status:"valid",value:o.data[p]}});else if(u==="strict")c.length>0&&(m(o,{code:d.unrecognized_keys,keys:c}),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 c){let h=o.data[p];i.push({key:{status:"valid",value:p},value:u._parse(new W(o,h,o.path,p)),alwaysSet:p in o.data});}}return o.common.async?Promise.resolve().then(async()=>{let u=[];for(let p of i){let h=await p.key,_=await p.value;u.push({key:h,value:_,alwaysSet:p.alwaysSet});}return u}).then(u=>M.mergeObjectSync(n,u)):M.mergeObjectSync(n,i)}get shape(){return this._def.shape()}strict(e){return y.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(r,n)=>{let o=this._def.errorMap?.(r,n).message??n.defaultError;return r.code==="unrecognized_keys"?{message:y.errToObj(e).message??o}:{message:o}}}:{}})}strip(){return new t({...this._def,unknownKeys:"strip"})}passthrough(){return new t({...this._def,unknownKeys:"passthrough"})}extend(e){return new t({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:x.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 S.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 S.objectKeys(this.shape))e[n]||(r[n]=this.shape[n]);return new t({...this._def,shape:()=>r})}deepPartial(){return Ce(this)}partial(e){let r={};for(let n of S.objectKeys(this.shape)){let o=this.shape[n];e&&!e[n]?r[n]=o:r[n]=o.optional();}return new t({...this._def,shape:()=>r})}required(e){let r={};for(let n of S.objectKeys(this.shape))if(e&&!e[n])r[n]=this.shape[n];else {let s=this.shape[n];for(;s instanceof L;)s=s._def.innerType;r[n]=s;}return new t({...this._def,shape:()=>r})}keyof(){return lr(S.objectKeys(this.shape))}};N.create=(t,e)=>new N({shape:()=>t,unknownKeys:"strip",catchall:U.create(),typeName:x.ZodObject,...w(e)});N.strictCreate=(t,e)=>new N({shape:()=>t,unknownKeys:"strict",catchall:U.create(),typeName:x.ZodObject,...w(e)});N.lazycreate=(t,e)=>new N({shape:t,unknownKeys:"strip",catchall:U.create(),typeName:x.ZodObject,...w(e)});var pe=class extends k{_parse(e){let{ctx:r}=this._processInputParams(e),n=this._def.options;function o(s){for(let c of s)if(c.result.status==="valid")return c.result;for(let c of s)if(c.result.status==="dirty")return r.common.issues.push(...c.ctx.common.issues),c.result;let a=s.map(c=>new j(c.ctx.common.issues));return m(r,{code:d.invalid_union,unionErrors:a}),v}if(r.common.async)return Promise.all(n.map(async s=>{let a={...r,common:{...r.common,issues:[]},parent:null};return {result:await s._parseAsync({data:r.data,path:r.path,parent:a}),ctx:a}})).then(o);{let s,a=[];for(let i of n){let u={...r,common:{...r.common,issues:[]},parent:null},p=i._parseSync({data:r.data,path:r.path,parent:u});if(p.status==="valid")return p;p.status==="dirty"&&!s&&(s={result:p,ctx:u}),u.common.issues.length&&a.push(u.common.issues);}if(s)return r.common.issues.push(...s.ctx.common.issues),s.result;let c=a.map(i=>new j(i));return m(r,{code:d.invalid_union,unionErrors:c}),v}}get options(){return this._def.options}};pe.create=(t,e)=>new pe({options:t,typeName:x.ZodUnion,...w(e)});var H=t=>t instanceof me?H(t.schema):t instanceof B?H(t.innerType()):t instanceof ge?[t.value]:t instanceof ye?t.options:t instanceof he?S.objectValues(t.enum):t instanceof ve?H(t._def.innerType):t instanceof ue?[void 0]:t instanceof de?[null]:t instanceof L?[void 0,...H(t.unwrap())]:t instanceof F?[null,...H(t.unwrap())]:t instanceof Be||t instanceof be?H(t.unwrap()):t instanceof xe?H(t._def.innerType):[],He=class t extends k{_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==g.object)return m(r,{code:d.invalid_type,expected:g.object,received:r.parsedType}),v;let n=this.discriminator,o=r.data[n],s=this.optionsMap.get(o);return s?r.common.async?s._parseAsync({data:r.data,path:r.path,parent:r}):s._parseSync({data:r.data,path:r.path,parent:r}):(m(r,{code:d.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),v)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,n){let o=new Map;for(let s of r){let a=H(s.shape[e]);if(!a.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let c of a){if(o.has(c))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(c)}`);o.set(c,s);}}return new t({typeName:x.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:o,...w(n)})}};function gt(t,e){let r=G(t),n=G(e);if(t===e)return {valid:true,data:t};if(r===g.object&&n===g.object){let o=S.objectKeys(e),s=S.objectKeys(t).filter(c=>o.indexOf(c)!==-1),a={...t,...e};for(let c of s){let i=gt(t[c],e[c]);if(!i.valid)return {valid:false};a[c]=i.data;}return {valid:true,data:a}}else if(r===g.array&&n===g.array){if(t.length!==e.length)return {valid:false};let o=[];for(let s=0;s<t.length;s++){let a=t[s],c=e[s],i=gt(a,c);if(!i.valid)return {valid:false};o.push(i.data);}return {valid:true,data:o}}else return r===g.date&&n===g.date&&+t==+e?{valid:true,data:t}:{valid:false}}var fe=class extends k{_parse(e){let{status:r,ctx:n}=this._processInputParams(e),o=(s,a)=>{if(Fe(s)||Fe(a))return v;let c=gt(s.value,a.value);return c.valid?((Ke(s)||Ke(a))&&r.dirty(),{status:r.value,value:c.data}):(m(n,{code:d.invalid_intersection_types}),v)};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(([s,a])=>o(s,a)):o(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};fe.create=(t,e,r)=>new fe({left:t,right:e,typeName:x.ZodIntersection,...w(r)});var Z=class t extends k{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==g.array)return m(n,{code:d.invalid_type,expected:g.array,received:n.parsedType}),v;if(n.data.length<this._def.items.length)return m(n,{code:d.too_small,minimum:this._def.items.length,inclusive:true,exact:false,type:"array"}),v;!this._def.rest&&n.data.length>this._def.items.length&&(m(n,{code:d.too_big,maximum:this._def.items.length,inclusive:true,exact:false,type:"array"}),r.dirty());let s=[...n.data].map((a,c)=>{let i=this._def.items[c]||this._def.rest;return i?i._parse(new W(n,a,n.path,c)):null}).filter(a=>!!a);return n.common.async?Promise.all(s).then(a=>M.mergeArray(r,a)):M.mergeArray(r,s)}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:x.ZodTuple,rest:null,...w(e)})};var Je=class t extends k{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!==g.object)return m(n,{code:d.invalid_type,expected:g.object,received:n.parsedType}),v;let o=[],s=this._def.keyType,a=this._def.valueType;for(let c in n.data)o.push({key:s._parse(new W(n,c,n.path,c)),value:a._parse(new W(n,n.data[c],n.path,c)),alwaysSet:c in n.data});return n.common.async?M.mergeObjectAsync(r,o):M.mergeObjectSync(r,o)}get element(){return this._def.valueType}static create(e,r,n){return r instanceof k?new t({keyType:e,valueType:r,typeName:x.ZodRecord,...w(n)}):new t({keyType:X.create(),valueType:e,typeName:x.ZodRecord,...w(r)})}},Me=class extends k{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!==g.map)return m(n,{code:d.invalid_type,expected:g.map,received:n.parsedType}),v;let o=this._def.keyType,s=this._def.valueType,a=[...n.data.entries()].map(([c,i],u)=>({key:o._parse(new W(n,c,n.path,[u,"key"])),value:s._parse(new W(n,i,n.path,[u,"value"]))}));if(n.common.async){let c=new Map;return Promise.resolve().then(async()=>{for(let i of a){let u=await i.key,p=await i.value;if(u.status==="aborted"||p.status==="aborted")return v;(u.status==="dirty"||p.status==="dirty")&&r.dirty(),c.set(u.value,p.value);}return {status:r.value,value:c}})}else {let c=new Map;for(let i of a){let u=i.key,p=i.value;if(u.status==="aborted"||p.status==="aborted")return v;(u.status==="dirty"||p.status==="dirty")&&r.dirty(),c.set(u.value,p.value);}return {status:r.value,value:c}}}};Me.create=(t,e,r)=>new Me({valueType:e,keyType:t,typeName:x.ZodMap,...w(r)});var Oe=class t extends k{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==g.set)return m(n,{code:d.invalid_type,expected:g.set,received:n.parsedType}),v;let o=this._def;o.minSize!==null&&n.data.size<o.minSize.value&&(m(n,{code:d.too_small,minimum:o.minSize.value,type:"set",inclusive:true,exact:false,message:o.minSize.message}),r.dirty()),o.maxSize!==null&&n.data.size>o.maxSize.value&&(m(n,{code:d.too_big,maximum:o.maxSize.value,type:"set",inclusive:true,exact:false,message:o.maxSize.message}),r.dirty());let s=this._def.valueType;function a(i){let u=new Set;for(let p of i){if(p.status==="aborted")return v;p.status==="dirty"&&r.dirty(),u.add(p.value);}return {status:r.value,value:u}}let c=[...n.data.values()].map((i,u)=>s._parse(new W(n,i,n.path,u)));return n.common.async?Promise.all(c).then(i=>a(i)):a(c)}min(e,r){return new t({...this._def,minSize:{value:e,message:y.toString(r)}})}max(e,r){return new t({...this._def,maxSize:{value:e,message:y.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}};Oe.create=(t,e)=>new Oe({valueType:t,minSize:null,maxSize:null,typeName:x.ZodSet,...w(e)});var qe=class t extends k{constructor(){super(...arguments),this.validate=this.implement;}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==g.function)return m(r,{code:d.invalid_type,expected:g.function,received:r.parsedType}),v;function n(c,i){return We({data:c,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Ae(),K].filter(u=>!!u),issueData:{code:d.invalid_arguments,argumentsError:i}})}function o(c,i){return We({data:c,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Ae(),K].filter(u=>!!u),issueData:{code:d.invalid_return_type,returnTypeError:i}})}let s={errorMap:r.common.contextualErrorMap},a=r.data;if(this._def.returns instanceof ee){let c=this;return P(async function(...i){let u=new j([]),p=await c._def.args.parseAsync(i,s).catch(I=>{throw u.addIssue(n(i,I)),u}),h=await Reflect.apply(a,this,p);return await c._def.returns._def.type.parseAsync(h,s).catch(I=>{throw u.addIssue(o(h,I)),u})})}else {let c=this;return P(function(...i){let u=c._def.args.safeParse(i,s);if(!u.success)throw new j([n(i,u.error)]);let p=Reflect.apply(a,this,u.data),h=c._def.returns.safeParse(p,s);if(!h.success)throw new j([o(p,h.error)]);return h.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:Z.create(e).rest(J.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(J.create()),returns:r||J.create(),typeName:x.ZodFunction,...w(n)})}},me=class extends k{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})}};me.create=(t,e)=>new me({getter:t,typeName:x.ZodLazy,...w(e)});var ge=class extends k{_parse(e){if(e.data!==this._def.value){let r=this._getOrReturnCtx(e);return m(r,{received:r.data,code:d.invalid_literal,expected:this._def.value}),v}return {status:"valid",value:e.data}}get value(){return this._def.value}};ge.create=(t,e)=>new ge({value:t,typeName:x.ZodLiteral,...w(e)});function lr(t,e){return new ye({values:t,typeName:x.ZodEnum,...w(e)})}var ye=class t extends k{_parse(e){if(typeof e.data!="string"){let r=this._getOrReturnCtx(e),n=this._def.values;return m(r,{expected:S.joinValues(n),received:r.parsedType,code:d.invalid_type}),v}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 m(r,{received:r.data,code:d.invalid_enum_value,options:n}),v}return P(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})}};ye.create=lr;var he=class extends k{_parse(e){let r=S.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==g.string&&n.parsedType!==g.number){let o=S.objectValues(r);return m(n,{expected:S.joinValues(o),received:n.parsedType,code:d.invalid_type}),v}if(this._cache||(this._cache=new Set(S.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let o=S.objectValues(r);return m(n,{received:n.data,code:d.invalid_enum_value,options:o}),v}return P(e.data)}get enum(){return this._def.values}};he.create=(t,e)=>new he({values:t,typeName:x.ZodNativeEnum,...w(e)});var ee=class extends k{unwrap(){return this._def.type}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==g.promise&&r.common.async===false)return m(r,{code:d.invalid_type,expected:g.promise,received:r.parsedType}),v;let n=r.parsedType===g.promise?r.data:Promise.resolve(r.data);return P(n.then(o=>this._def.type.parseAsync(o,{path:r.path,errorMap:r.common.contextualErrorMap})))}};ee.create=(t,e)=>new ee({type:t,typeName:x.ZodPromise,...w(e)});var B=class extends k{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===x.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:r,ctx:n}=this._processInputParams(e),o=this._def.effect||null,s={addIssue:a=>{m(n,a),a.fatal?r.abort():r.dirty();},get path(){return n.path}};if(s.addIssue=s.addIssue.bind(s),o.type==="preprocess"){let a=o.transform(n.data,s);if(n.common.async)return Promise.resolve(a).then(async c=>{if(r.value==="aborted")return v;let i=await this._def.schema._parseAsync({data:c,path:n.path,parent:n});return i.status==="aborted"?v:i.status==="dirty"?se(i.value):r.value==="dirty"?se(i.value):i});{if(r.value==="aborted")return v;let c=this._def.schema._parseSync({data:a,path:n.path,parent:n});return c.status==="aborted"?v:c.status==="dirty"?se(c.value):r.value==="dirty"?se(c.value):c}}if(o.type==="refinement"){let a=c=>{let i=o.refinement(c,s);if(n.common.async)return Promise.resolve(i);if(i instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return c};if(n.common.async===false){let c=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return c.status==="aborted"?v:(c.status==="dirty"&&r.dirty(),a(c.value),{status:r.value,value:c.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(c=>c.status==="aborted"?v:(c.status==="dirty"&&r.dirty(),a(c.value).then(()=>({status:r.value,value:c.value}))))}if(o.type==="transform")if(n.common.async===false){let a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!Y(a))return v;let c=o.transform(a.value,s);if(c instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return {status:r.value,value:c}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(a=>Y(a)?Promise.resolve(o.transform(a.value,s)).then(c=>({status:r.value,value:c})):v);S.assertNever(o);}};B.create=(t,e,r)=>new B({schema:t,typeName:x.ZodEffects,effect:e,...w(r)});B.createWithPreprocess=(t,e,r)=>new B({schema:e,effect:{type:"preprocess",transform:t},typeName:x.ZodEffects,...w(r)});var L=class extends k{_parse(e){return this._getType(e)===g.undefined?P(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};L.create=(t,e)=>new L({innerType:t,typeName:x.ZodOptional,...w(e)});var F=class extends k{_parse(e){return this._getType(e)===g.null?P(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};F.create=(t,e)=>new F({innerType:t,typeName:x.ZodNullable,...w(e)});var ve=class extends k{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return r.parsedType===g.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};ve.create=(t,e)=>new ve({innerType:t,typeName:x.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...w(e)});var xe=class extends k{_parse(e){let{ctx:r}=this._processInputParams(e),n={...r,common:{...r.common,issues:[]}},o=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Ie(o)?o.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new j(n.common.issues)},input:n.data})})):{status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new j(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};xe.create=(t,e)=>new xe({innerType:t,typeName:x.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...w(e)});var Pe=class extends k{_parse(e){if(this._getType(e)!==g.nan){let n=this._getOrReturnCtx(e);return m(n,{code:d.invalid_type,expected:g.nan,received:n.parsedType}),v}return {status:"valid",value:e.data}}};Pe.create=t=>new Pe({typeName:x.ZodNaN,...w(t)});var An=Symbol("zod_brand"),Be=class extends k{_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}},Ve=class t extends k{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.common.async)return (async()=>{let s=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?v:s.status==="dirty"?(r.dirty(),se(s.value)):this._def.out._parseAsync({data:s.value,path:n.path,parent:n})})();{let o=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?v:o.status==="dirty"?(r.dirty(),{status:"dirty",value:o.value}):this._def.out._parseSync({data:o.value,path:n.path,parent:n})}}static create(e,r){return new t({in:e,out:r,typeName:x.ZodPipeline})}},be=class extends k{_parse(e){let r=this._def.innerType._parse(e),n=o=>(Y(o)&&(o.value=Object.freeze(o.value)),o);return Ie(r)?r.then(o=>n(o)):n(r)}unwrap(){return this._def.innerType}};be.create=(t,e)=>new be({innerType:t,typeName:x.ZodReadonly,...w(e)});function sr(t,e){let r=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof r=="string"?{message:r}:r}function ur(t,e={},r){return t?Q.create().superRefine((n,o)=>{let s=t(n);if(s instanceof Promise)return s.then(a=>{if(!a){let c=sr(e,n),i=c.fatal??r??true;o.addIssue({code:"custom",...c,fatal:i});}});if(!s){let a=sr(e,n),c=a.fatal??r??true;o.addIssue({code:"custom",...a,fatal:c});}}):Q.create()}var In={object:N.lazycreate},x;(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";})(x||(x={}));var Cn=(t,e={message:`Input not instance of ${t.name}`})=>ur(r=>r instanceof t,e),dr=X.create,pr=ae.create,En=Pe.create,Rn=ie.create,fr=ce.create,Mn=le.create,On=Ee.create,Pn=ue.create,Dn=de.create,jn=Q.create,Nn=J.create,$n=U.create,Ln=Re.create,Wn=q.create,Bn=N.create,Vn=N.strictCreate,Un=pe.create,zn=He.create,Gn=fe.create,Zn=Z.create,Fn=Je.create,Kn=Me.create,Hn=Oe.create,Jn=qe.create,qn=me.create,Yn=ge.create,Xn=ye.create,Qn=he.create,eo=ee.create,to=B.create,ro=L.create,no=F.create,oo=B.createWithPreprocess,so=Ve.create,ao=()=>dr().optional(),io=()=>pr().optional(),co=()=>fr().optional(),lo={string:(t=>X.create({...t,coerce:true})),number:(t=>ae.create({...t,coerce:true})),boolean:(t=>ce.create({...t,coerce:true})),bigint:(t=>ie.create({...t,coerce:true})),date:(t=>le.create({...t,coerce:true}))};var uo=v;var De="agtx_pk_",Ye="agtx_sk_";l.string().min(De.length+8).startsWith(De,{message:`Publishable keys must start with "${De}".`});l.string().min(Ye.length+8).startsWith(Ye,{message:`Secret keys must start with "${Ye}".`});var mr=t=>t.startsWith(De)?"publishable":t.startsWith(Ye)?"secret":"unknown",_e=l.enum(["webmcp","dom","screenshot","crawler"]),yt=l.enum(["detected","declared","verified","linked"]),po=l.object({class:_e,trust:yt,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({})}),fo=l.enum(["bearer","oauth2","sso","spiffe","google-agent","mtls","detection","declaration","extension","session-link","x-agent-header"]),Ue=l.object({class:_e,vendor:l.string().min(1),token:l.string().min(8),expiresAt:l.string().datetime().optional()});l.object({publishableKey:l.string(),claim:Ue,nonce:l.string().min(8),origin:l.string().url()});l.object({trust:yt,vendor:l.string(),validUntil:l.string().datetime(),reason:l.string().optional(),subject:l.string().optional(),protocol:fo.optional(),signals:l.record(l.unknown()).optional()});l.object({issuer:l.string().url(),audiences:l.array(l.string().min(1)).min(1)});l.object({trustDomain:l.string().min(1),bundleEndpoint:l.string().url(),audiences:l.array(l.string().min(1)).min(1),googleTrustDomains:l.array(l.string().min(1)).optional()});l.object({rootCerts:l.array(l.string().min(20)).min(1),spiffeTrustDomain:l.string().min(1).optional(),xfccEntryPolicy:l.enum(["last","first","only"]).default("last")});l.enum(["sso","spiffe","mtls"]);l.object({siteId:l.string().min(1),token:l.string().min(8).optional(),xfcc:l.string().min(1).optional(),headers:l.record(l.string()).optional(),origin:l.string().url().optional()});var z={detected:0,declared:1,verified:2,linked:3},gr=(t,e)=>z[t]>z[e],yr=l.enum(["allow","deny","review"]),ze=l.object({id:l.string(),tool:l.string(),minTrust:yt,allowedClasses:l.array(_e).default([]),decision:yr,rateLimit:l.object({max:l.number().int().positive(),windowSeconds:l.number().int().positive()}).optional()}),mo=l.object({decision:yr,ruleId:l.string().nullable(),reason:l.string()}),go=l.enum(["session","user","org"]),ht=l.object({key:l.string().min(1),value:l.unknown(),scope:go.default("session"),ttlSeconds:l.number().int().positive().nullable().default(null),updatedAt:l.string().datetime().optional()}),yo=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()}),ho=l.object({pattern:l.string().optional(),flow:l.string().optional()}),vo=l.object({pages:l.array(yo).default([]),navigation:ho.optional()}),xo=l.object({step:l.number().int().positive(),action:l.string().min(1)}),bo=l.object({steps:l.array(xo).default([]),notes:l.string().optional(),policy:l.string().optional()}),_o=l.object({selector:l.string().min(1),behavior:l.string().optional(),location:l.string().optional(),showsCount:l.boolean().optional()}),wo=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()}),vt=l.object({path:l.string().min(1),payload:l.record(l.unknown()).default({}),updatedAt:l.string().datetime().optional()}).strict(),$=l.object({version:l.string().default("1"),siteMap:vo.optional(),workflows:l.record(bo).default({}),policies:l.record(l.union([l.string(),l.array(l.string())])).default({}),catalog:wo.optional(),uiGuidance:l.record(_o).default({}),pageContexts:l.record(vt).default({}),updatedAt:l.string().datetime().optional()}),hr=$.parse({}),ko=l.object({name:l.string().min(1),group:l.string().optional(),page:l.string().optional(),description:l.string().default(""),inputSchema:l.record(l.unknown()).default({}),outputSchema:l.record(l.unknown()).optional(),tokens:l.number().int().nonnegative().default(0)}),To=l.object({tools:l.array(ko).default([])});To.parse({});var So=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"]),xt=l.object({id:l.string(),siteId:l.string(),sessionId:l.string(),occurredAt:l.string().datetime(),type:So,tool:l.string().optional(),agent:po.nullable().optional(),policy:mo.optional(),durationMs:l.number().int().nonnegative().optional(),outcome:l.enum(["success","error","blocked"]),error:l.string().optional(),metadata:l.record(l.unknown()).default({})});l.object({publishableKey:l.string().optional(),events:l.array(xt).min(1).max(100)});var Ge=class extends Error{code;constructor(t,e){super(e),this.name="AgentronicsError",this.code=t;}};var A="0.1.2";var Ao=()=>{if(typeof navigator>"u")return null;let t=navigator.modelContext;return t&&typeof t=="object"?t:null},je=async(t={})=>{let{pollMs:e=500}=t,r=Date.now();for(;;){let n=Ao();if(n)return Io(n);if(Date.now()-r>=e)return null;await new Promise(o=>setTimeout(o,50));}},Io=t=>({class:"webmcp",trust:"detected",confidence:1,vendor:t.vendor??t.client??null,userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:A,signals:{webmcp:true,toolCount:Array.isArray(t.tools)?t.tools.length:0}});var bt=[{name:"GPTBot",category:"ai",pattern:/GPTBot/i},{name:"OAI-SearchBot",category:"ai",pattern:/OAI-SearchBot/i},{name:"ChatGPT-User",category:"ai",pattern:/ChatGPT-User/i},{name:"ClaudeBot",category:"ai",pattern:/ClaudeBot/i},{name:"Claude-Web",category:"ai",pattern:/Claude-Web/i},{name:"anthropic-ai",category:"ai",pattern:/anthropic-ai/i},{name:"PerplexityBot",category:"ai",pattern:/PerplexityBot/i},{name:"Google-Extended",category:"ai",pattern:/Google-Extended/i},{name:"Applebot-Extended",category:"ai",pattern:/Applebot-Extended/i},{name:"Amazonbot",category:"ai",pattern:/Amazonbot/i},{name:"Bytespider",category:"ai",pattern:/Bytespider/i},{name:"CCBot",category:"ai",pattern:/CCBot/i},{name:"Meta-ExternalAgent",category:"ai",pattern:/Meta-ExternalAgent/i},{name:"cohere-ai",category:"ai",pattern:/cohere-ai/i},{name:"Googlebot",category:"search",pattern:/Googlebot/i},{name:"Bingbot",category:"search",pattern:/bingbot/i},{name:"DuckDuckBot",category:"search",pattern:/DuckDuckBot/i},{name:"YandexBot",category:"search",pattern:/YandexBot/i},{name:"Baiduspider",category:"search",pattern:/Baiduspider/i},{name:"Applebot",category:"search",pattern:/Applebot/i}],Ne=(t={})=>{let{signatures:e=bt,disable:r=false,confidence:n=.9}=t;if(r||typeof navigator>"u")return null;let o=navigator.userAgent??"";if(!o)return null;for(let s of e)if(s.pattern.test(o))return {class:"crawler",trust:"detected",confidence:n,vendor:s.name,userAgent:o,detectionVersion:A,signals:{matched:s.name,category:s.category,ua:o}};return null};var Co=[/HeadlessChrome/i,/Headless/i,/PhantomJS/i,/SlimerJS/i],Eo=()=>({hit:(typeof navigator<"u"&&navigator.webdriver)===true,weight:.6,detail:"navigator.webdriver === true"}),Ro=()=>{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_*"}`}},Mo=()=>{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"}},Oo=()=>{if(typeof navigator>"u")return {hit:false,weight:.7};let t=navigator.userAgent??"",e=Co.some(r=>r.test(t));return e?{hit:e,weight:.7,detail:`headless UA: ${t}`}:{hit:e,weight:.7}},Po=()=>{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"}},Do=()=>{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"}},jo={webdriver:Eo,chromedriver:Ro,headlessUa:Oo,languages:Po,permissions:Do,plugins:Mo},$e=(t={})=>{let{threshold:e=.4}=t,r={},n=0,o=0;for(let[a,c]of Object.entries(jo)){let i=c();n+=i.weight,r[a]={hit:i.hit,weight:i.weight,detail:i.detail},i.hit&&(o+=i.weight);}let s=n===0?0:o/n;return s<e?null:{class:"dom",trust:"detected",confidence:s,vendor:null,userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:A,signals:r}};var _t=()=>[{id:"webmcp.model-context",status:"stable",detect:()=>je({pollMs:0})},{id:"crawler.user-agent",status:"beta",detect:()=>Ne()},{id:"dom.automation-heuristics",status:"beta",detect:()=>$e()}],Xe=(t=_t())=>{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(o=>o.status===r):n},async detectAll(r=false){for(let n of e.values()){if(n.status==="research"&&!r)continue;let o=await n.detect();if(o)return o}return null}}};var wt=t=>{let e=_e.parse(t.class),r=t.verificationToken?"verified":"declared";return {class:e,trust:r,confidence:1,vendor:t.vendor,userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:A,signals:{declared:true,hasVerificationToken:!!t.verificationToken}}};var vr=({gatewayUrl:t,fetcher:e=fetch})=>{let r=null,n=[];return {snapshot(){return [...n]},async sync(){let o=await e(`${t.replace(/\/$/,"")}/v1/detector-signatures`,{headers:r?{"if-none-match":r}:{}});if(o.status===304)return this.snapshot();if(!o.ok)throw new Error(`Detector signature sync failed with status ${o.status}.`);return n=(await o.json()).signatures??[],r=o.headers.get("etag"),this.snapshot()}}};var Qe=async(t={})=>{if(t.customDetectors?.length){let e=await Xe(t.customDetectors).detectAll(!!t.experimental);if(e)return e}if(t.webmcp!==false){let e=await je(t.webmcp??{});if(e)return e}if(t.crawler!==false){let e=Ne(t.crawler??{});if(e)return e}if(t.dom!==false){let e=$e(t.dom??{});if(e)return e}return null};var No=t=>({class:t.class,trust:"declared",confidence:1,vendor:t.vendor,userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:A,signals:{declared:true,hasToken:true,tokenExpiresAt:t.expiresAt??null}}),kt=()=>{let t=null;return {present(e){let r=Ue.safeParse(e);if(!r.success)throw new Ge("invalid_api_key",`Invalid identity claim: ${r.error.issues[0]?.message??"unknown"}`);let n={claim:r.data,identity:No(r.data)};return t=n,n},clear(){t=null;},preferOver(e){return t?e?gr(t.identity.trust,e.trust)?t.identity:e:t.identity:e},snapshot(){return t}}};var $o=({detected:t,declared:e,verified:r,linked:n})=>n?"linked":r?"verified":e?"declared":"detected",Tt=t=>{let e=null;for(let r of t)(!e||z[r.trust]>z[e.trust])&&(e=r);return e};var xr=()=>({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:A,signals:{bearer:true,verifiedRemotely:!!r}}}});var br=()=>({name:"detection",async authenticate(t){return t.detected??null}});var _r=()=>({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:A,signals:{extensionToken:true,verifiedRemotely:!!r}}}});var wr=()=>({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:A,signals:{mtls:true,subject:r?.subject??null,verifiedRemotely:!!r,...r?.signals??{}}}}});var kr=()=>({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:A,signals:{oauth2:true,subject:t.oauth2Subject??null,verifiedRemotely:!!r}}}});var Lo=t=>({class:t.class,trust:"declared",confidence:1,vendor:t.vendor,userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:A,signals:{declared:true,hasToken:true,tokenExpiresAt:t.expiresAt??null}}),Tr=()=>({name:"selfDeclaration",async authenticate(t){return t.declaration?Lo(Ue.parse(t.declaration)):null}});var Sr=()=>({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:A,signals:{sessionLink:true,linkedUserId:t.linkedUserId??null,verifiedRemotely:!!r}}}});var Ar=()=>({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:A,signals:{sso:true,subject:r?.subject??null,verifiedRemotely:!!r,...r?.signals??{}}}}});var Ir=()=>({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:A,signals:{spiffe:true,spiffeId:r?.subject??null,subject:r?.subject??null,verifiedRemotely:!!r,...n?{googleAgent:true}:{},...r?.signals??{}}}}});var Cr=()=>({name:"xAgentHeader",async authenticate(t){if(!t.xAgentHeader)return null;let[e="x-agent",r="dom",n]=t.xAgentHeader.split(";"),o=_e.safeParse(r);return {class:o.success?o.data:"dom",trust:n?"verified":"declared",confidence:n?1:.8,vendor:e,userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:A,signals:{xAgentHeader:true,hasProof:!!n}}}});var Wo=()=>[br(),Tr(),xr(),Cr(),_r(),Sr(),kr(),Ar(),Ir(),wr()],Bo={detection:"detection",selfDeclaration:"declaration",bearer:"bearer",xAgentHeader:"x-agent-header",extensionToken:"extension",sessionLink:"session-link",oauth2:"oauth2",sso:"sso",spiffe:"spiffe",mtls:"mtls"},Vo=(t,e)=>t==="spiffe"&&e.signals?.googleAgent===true?"google-agent":Bo[t],St=({methods:t=Wo(),context:e={},onTrace:r}={})=>({async authenticate(n){let o=[],s={};for(let h of t){let _=await h.authenticate(n,e);s[h.name]=!!_,_&&o.push({method:h.name,identity:_});}let a=Tt(o.map(h=>h.identity)),c=a?o.find(h=>h.identity===a):void 0,i=c?Vo(c.method,c.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:s,...i?{protocol:i}:{},...u?{subject:u}:{}}};return a||(p.error="No auth method produced an identity."),r?.(p),a},methods(){return t.map(n=>n.name)}});var Uo={identity:null,source:"initial",updatedAt:null},At=()=>{let t=Uo,e=new Set,r=()=>{e.size!==0&&e.forEach(n=>n(t));};return {snapshot(){return t},set(n,o){t={identity:n,source:o,updatedAt:new Date().toISOString()},r();},subscribe(n){return e.add(n),()=>{e.delete(n);}}}};var zo=()=>{let t=new Map;return {read:e=>t.get(e)??null,write:(e,r)=>{t.set(e,r);}}},Go=()=>typeof window>"u"||!window.localStorage?zo():{read:t=>{try{return window.localStorage.getItem(t)}catch{return null}},write:(t,e)=>{try{window.localStorage.setItem(t,e);}catch{}}},Zo=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},It=(t=Go())=>({consume(e,r,n=Date.now()){let o=`agtx:rate:${e}`,s=Zo(t.read(o)),a=s&&s.resetAt>n?s.resetAt:n+r.windowSeconds*1e3,c=s&&s.resetAt>n?s.count+1:1;return t.write(o,JSON.stringify({count:c,resetAt:a})),{allowed:c<=r.max,remaining:Math.max(0,r.max-c),resetAt:a}}});var Fo=(t,e)=>t==="*"||t===e?true:t.includes("*")?new RegExp("^"+t.replace(/[.+?^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*")+"$").test(e):false,Ko=(t,e)=>{let r=t?z[t.trust]:-1,n=z[e.minTrust];return r>=n},Ho=(t,e)=>e.allowedClasses.length===0?true:t?e.allowedClasses.includes(t.class):false,Er="review",Jo=(t,e)=>{let r=e?.class??"unknown",n=e?.vendor??"unknown",o=e?.trust??"none";return `${t}:${r}:${n}:${o}`},Ct=(t=[],e={})=>{let r=t.map(o=>ze.parse(o)),n=e.rateLimiter??It();return {set(o){r=o.map(s=>ze.parse(s));},list(){return [...r]},evaluate({tool:o,identity:s}){for(let a of r)if(Fo(a.tool,o)){if(!Ko(s,a))return {decision:"deny",ruleId:a.id,reason:`Rule "${a.id}" requires trust >= ${a.minTrust}.`};if(!Ho(s,a))return {decision:"deny",ruleId:a.id,reason:`Rule "${a.id}" restricts to classes: ${a.allowedClasses.join(", ")}.`};if(a.rateLimit){let c=n.consume(Jo(o,s),a.rateLimit);if(!c.allowed)return {decision:"deny",ruleId:a.id,reason:`Rule "${a.id}" rate limit exceeded. Resets at ${new Date(c.resetAt).toISOString()}.`}}return {decision:a.decision,ruleId:a.id,reason:`Matched rule "${a.id}".`}}return {decision:Er,ruleId:null,reason:`No rule matched tool "${o}". Falling back to "${Er}".`}}}};var Et=({gatewayUrl:t,siteId:e,publishableKey:r,fetcher:n=fetch})=>{let o={policies:[],etag:null};return {snapshot(){return {policies:[...o.policies],etag:o.etag}},async sync(){let s=await n(`${t.replace(/\/$/,"")}/v1/sites/${encodeURIComponent(e)}/policies`,{headers:{authorization:`Bearer ${r}`,...o.etag?{"if-none-match":o.etag}:{}}});if(s.status===304)return this.snapshot();if(!s.ok)throw new Error(`Policy sync failed with status ${s.status}.`);let a=await s.json();return o={policies:ze.array().parse(a.policies??[]),etag:s.headers.get("etag")},this.snapshot()}}};var Rt=({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 Mt=({policyEngine:t,getIdentity:e,documentRef:r=typeof document>"u"?void 0:document,selector:n="[data-agentronics-tool]"})=>{if(!r)return {uninstall:()=>{}};let o=s=>{let a=s.target instanceof Element?s.target.closest(n):null;if(!(a instanceof HTMLElement))return;let c=a.dataset.agentronicsTool;c&&Promise.resolve(e()).then(i=>{let u=t.evaluate({tool:c,identity:i});u.decision==="deny"&&(s.preventDefault(),s.stopPropagation(),Rt({message:u.reason,documentRef:r}));});};return r.addEventListener("click",o,true),{uninstall:()=>r.removeEventListener("click",o,true)}};var Ot=()=>{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()]}},Rr=(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 o=t.key(n);o&&o.startsWith(e)&&r.push(o.slice(e.length));}}catch{}return r}}),Mr="agtx:",Or=()=>{let t=typeof window<"u",e=t&&typeof window.sessionStorage<"u"?Rr(window.sessionStorage,Mr+"session:"):Ot(),r=t&&typeof window.localStorage<"u"?Rr(window.localStorage,Mr+"user:"):Ot();return {session:e,user:r,org:Ot()}};var Pr=(t,e)=>t.expiresAt!==null&&t.expiresAt<=e,Dr=t=>{if(!t)return null;try{let e=JSON.parse(t);return typeof e!="object"||e===null?null:e}catch{return null}},qo=t=>JSON.stringify(t),Pt=(t={})=>{let e=Or(),r=i=>{t.onTrace?.(i);};return {get:(i,u={})=>{let p=u.scope??"session",h=e[p],_=Dr(h.read(i));if(!_){r({type:"memory.accessed",metadata:{operation:"get",key:i,scope:p,hit:false}});return}if(Pr(_,Date.now())){h.remove(i),r({type:"memory.accessed",metadata:{operation:"get",key:i,scope:p,hit:false,expired:true}});return}return r({type:"memory.accessed",metadata:{operation:"get",key:i,scope:p,hit:true}}),_.value},set:(i,u,p={})=>{let h=p.scope??"session",_=p.ttlSeconds??null,I=Date.now(),E={value:u,expiresAt:_===null?null:I+_*1e3,updatedAt:new Date(I).toISOString()};return e[h].write(i,qo(E)),r({type:"memory.updated",metadata:{operation:"set",key:i,scope:h,ttlSeconds:_}}),ht.parse({key:i,value:u,scope:h,ttlSeconds:_,updatedAt:E.updatedAt})},remove:(i,u={})=>{let p=u.scope??"session";e[p].remove(i),r({type:"memory.updated",metadata:{operation:"remove",key:i,scope:p}});},list:(i={})=>{let u=i.scope??"session",p=e[u],h=Date.now(),_=[];for(let I of p.keys()){let E=Dr(p.read(I));if(E){if(Pr(E,h)){p.remove(I);continue}_.push(ht.parse({key:I,value:E.value,scope:u,ttlSeconds:E.expiresAt===null?null:Math.max(0,Math.round((E.expiresAt-h)/1e3)),updatedAt:E.updatedAt}));}}return r({type:"memory.accessed",metadata:{operation:"list",scope:u,count:_.length}}),_},clear:(i={})=>{let u=i.scope??"session",p=e[u],h=p.keys().length;for(let _ of p.keys())p.remove(_);r({type:"memory.updated",metadata:{operation:"clear",scope:u,count:h}});}}};var Dt=t=>$.parse(JSON.parse(JSON.stringify(t))),et=t=>({...t,updatedAt:new Date().toISOString()}),jt=(t={})=>{let e=$.parse({...hr,...t.initial??{}}),r=null,n=new Set,o=b=>{t.onTrace?.(b);},s=()=>{r=null;},a=()=>{if(n.size===0)return;let b=Dt(e);r=b,n.forEach(C=>C(b));},c=b=>{let C=$.parse({...e,...b,workflows:{...e.workflows,...b.workflows??{}},policies:{...e.policies,...b.policies??{}},uiGuidance:{...e.uiGuidance,...b.uiGuidance??{}},pageContexts:{...e.pageContexts,...b.pageContexts??{}}});return e=et(C),s(),o({type:"memory.updated",metadata:{kind:"site",operation:"provide",keys:Object.keys(b)}}),a(),p()},i=(b,C)=>{let R=b.split(".").filter(Boolean);if(R.length===0)throw new Error("siteMemory.update() requires a non-empty dot-path.");let re=JSON.parse(JSON.stringify(e)),ne=re;for(let we=0;we<R.length-1;we++){let V=R[we],ke=ne[V];(typeof ke!="object"||ke===null||Array.isArray(ke))&&(ne[V]={}),ne=ne[V];}return ne[R[R.length-1]]=C,e=et($.parse(re)),s(),o({type:"memory.updated",metadata:{kind:"site",operation:"update",path:b}}),a(),p()},u=b=>{let C=vt.parse({path:b.path,payload:b.payload,updatedAt:new Date().toISOString()});return e=et({...e,pageContexts:{...e.pageContexts,[b.path]:C}}),s(),o({type:"memory.updated",metadata:{kind:"site",operation:"provideForPage",path:b.path}}),a(),{...C,payload:{...C.payload}}},p=()=>(r||(r=Dt(e)),r);return {provide:c,update:i,provideForPage:u,snapshot:p,get:b=>{if(o({type:"memory.accessed",metadata:{kind:"site",operation:b?"get":"snapshot",path:b??null}}),!b)return Dt(e);let C=b.split(".").filter(Boolean),R=e;for(let re of C){if(typeof R!="object"||R===null)return;R=R[re];}return R},getForPage:b=>{o({type:"memory.accessed",metadata:{kind:"site",operation:"getForPage",path:b}});let C=e.pageContexts[b];return C?{...C,payload:{...C.payload}}:null},replace:b=>(e=et($.parse(b)),s(),a(),p()),subscribe:b=>(n.add(b),()=>{n.delete(b);})}};var Nt=({gatewayUrl:t,siteId:e,publishableKey:r,fetcher:n=fetch})=>{let o={memory:null,etag:null};return {snapshot(){return {memory:o.memory?$.parse(o.memory):null,etag:o.etag}},async sync(){let s=await n(`${t.replace(/\/$/,"")}/v1/sites/${encodeURIComponent(e)}/memory`,{headers:{authorization:`Bearer ${r}`,...o.etag?{"if-none-match":o.etag}:{}}});if(s.status===304)return this.snapshot();if(!s.ok)throw new Error(`Memory sync failed with status ${s.status}.`);let a=await s.json();return o={memory:$.parse(a.memory??{}),etag:s.headers.get("etag")},this.snapshot()}}};var jr=({toolName:t="getSiteContext",description:e="Returns Agentronics site memory: page map, workflows, policies, UI guidance.",getSnapshot:r,onAccess:n})=>({name:t,description:e,inputSchema:{type:"object",properties:{path:{type:"string",description:'Optional dot-path into the site memory (e.g. "workflows.purchase").'}},required:[]},invoke(o={}){let s=r(),a=o.path??null;if(n?.(a),!a)return {content:s};let c=a.split(".").filter(Boolean),i=s;for(let u of c){if(typeof i!="object"||i===null)return {content:void 0};i=i[u];}return {content:i}}});var te="agent-context-",$t="agentronics-site-context",Yo=t=>{try{return JSON.stringify(t)}catch{return "{}"}},tt=(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);},rt=(t,e)=>{t.querySelectorAll(`meta[name="${e}"]`).forEach(r=>r.remove());},nt=({doc:t=typeof document>"u"?null:document,snapshot:e,schemaType:r="WebSite"})=>{if(!t)return {uninstall:()=>{}};tt(t,`${te}version`,e.version),tt(t,`${te}updated-at`,e.updatedAt??new Date().toISOString()),e.siteMap?.navigation?.flow&&tt(t,`${te}flow`,e.siteMap.navigation.flow),tt(t,`${te}workflows`,Object.keys(e.workflows).join(","));let n=t.getElementById($t);return n||(n=t.createElement("script"),n.type="application/ld+json",n.id=$t,t.head.appendChild(n)),n.textContent=Yo({"@context":"https://schema.org","@type":r,name:"Agentronics Site Memory",agentronics:e}),{uninstall:()=>{rt(t,`${te}version`),rt(t,`${te}updated-at`),rt(t,`${te}flow`),rt(t,`${te}workflows`),t.getElementById($t)?.remove();}}};var Nr="agentronics-memory-overlay",Xo=t=>`
|
|
1
|
+
var Agentronics=(function(exports){'use strict';var en=Object.defineProperty;var tn=(t,e)=>{for(var r in e)en(t,r,{get:e[r],enumerable:true});};var l={};tn(l,{BRAND:()=>Cn,DIRTY:()=>se,EMPTY_PATH:()=>sn,INVALID:()=>v,NEVER:()=>fo,OK:()=>P,ParseStatus:()=>M,Schema:()=>k,ZodAny:()=>Q,ZodArray:()=>q,ZodBigInt:()=>ie,ZodBoolean:()=>ce,ZodBranded:()=>Be,ZodCatch:()=>xe,ZodDate:()=>le,ZodDefault:()=>ve,ZodDiscriminatedUnion:()=>He,ZodEffects:()=>B,ZodEnum:()=>ge,ZodError:()=>j,ZodFirstPartyTypeKind:()=>x,ZodFunction:()=>qe,ZodIntersection:()=>fe,ZodIssueCode:()=>d,ZodLazy:()=>me,ZodLiteral:()=>ye,ZodMap:()=>Me,ZodNaN:()=>Pe,ZodNativeEnum:()=>he,ZodNever:()=>U,ZodNull:()=>de,ZodNullable:()=>F,ZodNumber:()=>ae,ZodObject:()=>N,ZodOptional:()=>L,ZodParsedType:()=>y,ZodPipeline:()=>Ve,ZodPromise:()=>ee,ZodReadonly:()=>be,ZodRecord:()=>Je,ZodSchema:()=>k,ZodSet:()=>Oe,ZodString:()=>X,ZodSymbol:()=>Ee,ZodTransformer:()=>B,ZodTuple:()=>Z,ZodType:()=>k,ZodUndefined:()=>ue,ZodUnion:()=>pe,ZodUnknown:()=>J,ZodVoid:()=>Re,addIssueToContext:()=>m,any:()=>$n,array:()=>Vn,bigint:()=>On,boolean:()=>mr,coerce:()=>po,custom:()=>dr,date:()=>Pn,datetimeRegex:()=>lr,defaultErrorMap:()=>K,discriminatedUnion:()=>Zn,effect:()=>no,enum:()=>eo,function:()=>Yn,getErrorMap:()=>Ae,getParsedType:()=>z,instanceof:()=>Rn,intersection:()=>Fn,isAborted:()=>Fe,isAsync:()=>Ie,isDirty:()=>Ke,isValid:()=>Y,late:()=>En,lazy:()=>Xn,literal:()=>Qn,makeIssue:()=>We,map:()=>Jn,nan:()=>Mn,nativeEnum:()=>to,never:()=>Wn,null:()=>Nn,nullable:()=>so,number:()=>fr,object:()=>Un,objectUtil:()=>ft,oboolean:()=>uo,onumber:()=>lo,optional:()=>oo,ostring:()=>co,pipeline:()=>io,preprocess:()=>ao,promise:()=>ro,quotelessJson:()=>rn,record:()=>Hn,set:()=>qn,setErrorMap:()=>on,strictObject:()=>Gn,string:()=>pr,symbol:()=>Dn,transformer:()=>no,tuple:()=>Kn,undefined:()=>jn,union:()=>zn,unknown:()=>Ln,util:()=>S,void:()=>Bn});var S;(function(t){t.assertEqual=o=>{};function e(o){}t.assertIs=e;function r(o){throw new Error}t.assertNever=r,t.arrayToEnum=o=>{let s={};for(let a of o)s[a]=a;return s},t.getValidEnumValues=o=>{let s=t.objectKeys(o).filter(i=>typeof o[o[i]]!="number"),a={};for(let i of s)a[i]=o[i];return t.objectValues(a)},t.objectValues=o=>t.objectKeys(o).map(function(s){return o[s]}),t.objectKeys=typeof Object.keys=="function"?o=>Object.keys(o):o=>{let s=[];for(let a in o)Object.prototype.hasOwnProperty.call(o,a)&&s.push(a);return s},t.find=(o,s)=>{for(let a of o)if(s(a))return a},t.isInteger=typeof Number.isInteger=="function"?o=>Number.isInteger(o):o=>typeof o=="number"&&Number.isFinite(o)&&Math.floor(o)===o;function n(o,s=" | "){return o.map(a=>typeof a=="string"?`'${a}'`:a).join(s)}t.joinValues=n,t.jsonStringifyReplacer=(o,s)=>typeof s=="bigint"?s.toString():s;})(S||(S={}));var ft;(function(t){t.mergeShapes=(e,r)=>({...e,...r});})(ft||(ft={}));var y=S.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),z=t=>{switch(typeof t){case "undefined":return y.undefined;case "string":return y.string;case "number":return Number.isNaN(t)?y.nan:y.number;case "boolean":return y.boolean;case "function":return y.function;case "bigint":return y.bigint;case "symbol":return y.symbol;case "object":return Array.isArray(t)?y.array:t===null?y.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?y.promise:typeof Map<"u"&&t instanceof Map?y.map:typeof Set<"u"&&t instanceof Set?y.set:typeof Date<"u"&&t instanceof Date?y.date:y.object;default:return y.unknown}};var d=S.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"]),rn=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),j=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(s){return s.message},n={_errors:[]},o=s=>{for(let a of s.issues)if(a.code==="invalid_union")a.unionErrors.map(o);else if(a.code==="invalid_return_type")o(a.returnTypeError);else if(a.code==="invalid_arguments")o(a.argumentsError);else if(a.path.length===0)n._errors.push(r(a));else {let i=n,c=0;for(;c<a.path.length;){let u=a.path[c];c===a.path.length-1?(i[u]=i[u]||{_errors:[]},i[u]._errors.push(r(a))):i[u]=i[u]||{_errors:[]},i=i[u],c++;}}};return o(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,S.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){let r={},n=[];for(let o of this.issues)if(o.path.length>0){let s=o.path[0];r[s]=r[s]||[],r[s].push(e(o));}else n.push(e(o));return {formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};j.create=t=>new j(t);var nn=(t,e)=>{let r;switch(t.code){case d.invalid_type:t.received===y.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case d.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,S.jsonStringifyReplacer)}`;break;case d.unrecognized_keys:r=`Unrecognized key(s) in object: ${S.joinValues(t.keys,", ")}`;break;case d.invalid_union:r="Invalid input";break;case d.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${S.joinValues(t.options)}`;break;case d.invalid_enum_value:r=`Invalid enum value. Expected ${S.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}"`:S.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,S.assertNever(t);}return {message:r}},K=nn;var or=K;function on(t){or=t;}function Ae(){return or}var We=t=>{let{data:e,path:r,errorMaps:n,issueData:o}=t,s=[...r,...o.path||[]],a={...o,path:s};if(o.message!==void 0)return {...o,path:s,message:o.message};let i="",c=n.filter(u=>!!u).slice().reverse();for(let u of c)i=u(a,{data:e,defaultError:i}).message;return {...o,path:s,message:i}},sn=[];function m(t,e){let r=Ae(),n=We({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===K?void 0:K].filter(o=>!!o)});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 o of r){if(o.status==="aborted")return v;o.status==="dirty"&&e.dirty(),n.push(o.value);}return {status:e.value,value:n}}static async mergeObjectAsync(e,r){let n=[];for(let o of r){let s=await o.key,a=await o.value;n.push({key:s,value:a});}return t.mergeObjectSync(e,n)}static mergeObjectSync(e,r){let n={};for(let o of r){let{key:s,value:a}=o;if(s.status==="aborted"||a.status==="aborted")return v;s.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),s.value!=="__proto__"&&(typeof a.value<"u"||o.alwaysSet)&&(n[s.value]=a.value);}return {status:e.value,value:n}}},v=Object.freeze({status:"aborted"}),se=t=>({status:"dirty",value:t}),P=t=>({status:"valid",value:t}),Fe=t=>t.status==="aborted",Ke=t=>t.status==="dirty",Y=t=>t.status==="valid",Ie=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 W=class{constructor(e,r,n,o){this._cachedPath=[],this.parent=e,this.data=r,this._path=n,this._key=o;}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},sr=(t,e)=>{if(Y(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 j(t.common.issues);return this._error=r,this._error}}};function _(t){if(!t)return {};let{errorMap:e,invalid_type_error:r,required_error:n,description:o}=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:o}:{errorMap:(a,i)=>{let{message:c}=t;return a.code==="invalid_enum_value"?{message:c??i.defaultError}:typeof i.data>"u"?{message:c??n??i.defaultError}:a.code!=="invalid_type"?{message:i.defaultError}:{message:c??r??i.defaultError}},description:o}}var k=class{get description(){return this._def.description}_getType(e){return z(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:z(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:z(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let r=this._parse(e);if(Ie(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:z(e)},o=this._parseSync({data:e,path:n.path,parent:n});return sr(n,o)}"~validate"(e){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:z(e)};if(!this["~standard"].async)try{let n=this._parseSync({data:e,path:[],parent:r});return Y(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=>Y(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:z(e)},o=this._parse({data:e,path:n.path,parent:n}),s=await(Ie(o)?o:Promise.resolve(o));return sr(n,s)}refine(e,r){let n=o=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(o):r;return this._refinement((o,s)=>{let a=e(o),i=()=>s.addIssue({code:d.custom,...n(o)});return typeof Promise<"u"&&a instanceof Promise?a.then(c=>c?true:(i(),false)):a?true:(i(),false)})}refinement(e,r){return this._refinement((n,o)=>e(n)?true:(o.addIssue(typeof r=="function"?r(n,o):r),false))}_refinement(e){return new B({schema:this,typeName:x.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 L.create(this,this._def)}nullable(){return F.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return q.create(this)}promise(){return ee.create(this,this._def)}or(e){return pe.create([this,e],this._def)}and(e){return fe.create(this,e,this._def)}transform(e){return new B({..._(this._def),schema:this,typeName:x.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let r=typeof e=="function"?e:()=>e;return new ve({..._(this._def),innerType:this,defaultValue:r,typeName:x.ZodDefault})}brand(){return new Be({typeName:x.ZodBranded,type:this,..._(this._def)})}catch(e){let r=typeof e=="function"?e:()=>e;return new xe({..._(this._def),innerType:this,catchValue:r,typeName:x.ZodCatch})}describe(e){let r=this.constructor;return new r({...this._def,description:e})}pipe(e){return Ve.create(this,e)}readonly(){return be.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},an=/^c[^\s-]{8,}$/i,cn=/^[0-9a-z]+$/,ln=/^[0-9A-HJKMNP-TV-Z]{26}$/i,un=/^[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,dn=/^[a-z0-9_-]{21}$/i,pn=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,fn=/^[-+]?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)?)??$/,mn=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,yn="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",mt,gn=/^(?:(?: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])$/,hn=/^(?:(?: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])$/,vn=/^(([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]))$/,xn=/^(([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])$/,bn=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,wn=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,ir="((\\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])))",_n=new RegExp(`^${ir}$`);function cr(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 kn(t){return new RegExp(`^${cr(t)}$`)}function lr(t){let e=`${ir}T${cr(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)&&gn.test(t)||(e==="v6"||!e)&&vn.test(t))}function Sn(t,e){if(!pn.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,"="),o=JSON.parse(atob(n));return !(typeof o!="object"||o===null||"typ"in o&&o?.typ!=="JWT"||!o.alg||e&&o.alg!==e)}catch{return false}}function An(t,e){return !!((e==="v4"||!e)&&hn.test(t)||(e==="v6"||!e)&&xn.test(t))}var X=class t extends k{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==y.string){let s=this._getOrReturnCtx(e);return m(s,{code:d.invalid_type,expected:y.string,received:s.parsedType}),v}let n=new M,o;for(let s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(o=this._getOrReturnCtx(e,o),m(o,{code:d.too_small,minimum:s.value,type:"string",inclusive:true,exact:false,message:s.message}),n.dirty());else if(s.kind==="max")e.data.length>s.value&&(o=this._getOrReturnCtx(e,o),m(o,{code:d.too_big,maximum:s.value,type:"string",inclusive:true,exact:false,message:s.message}),n.dirty());else if(s.kind==="length"){let a=e.data.length>s.value,i=e.data.length<s.value;(a||i)&&(o=this._getOrReturnCtx(e,o),a?m(o,{code:d.too_big,maximum:s.value,type:"string",inclusive:true,exact:true,message:s.message}):i&&m(o,{code:d.too_small,minimum:s.value,type:"string",inclusive:true,exact:true,message:s.message}),n.dirty());}else if(s.kind==="email")mn.test(e.data)||(o=this._getOrReturnCtx(e,o),m(o,{validation:"email",code:d.invalid_string,message:s.message}),n.dirty());else if(s.kind==="emoji")mt||(mt=new RegExp(yn,"u")),mt.test(e.data)||(o=this._getOrReturnCtx(e,o),m(o,{validation:"emoji",code:d.invalid_string,message:s.message}),n.dirty());else if(s.kind==="uuid")un.test(e.data)||(o=this._getOrReturnCtx(e,o),m(o,{validation:"uuid",code:d.invalid_string,message:s.message}),n.dirty());else if(s.kind==="nanoid")dn.test(e.data)||(o=this._getOrReturnCtx(e,o),m(o,{validation:"nanoid",code:d.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid")an.test(e.data)||(o=this._getOrReturnCtx(e,o),m(o,{validation:"cuid",code:d.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid2")cn.test(e.data)||(o=this._getOrReturnCtx(e,o),m(o,{validation:"cuid2",code:d.invalid_string,message:s.message}),n.dirty());else if(s.kind==="ulid")ln.test(e.data)||(o=this._getOrReturnCtx(e,o),m(o,{validation:"ulid",code:d.invalid_string,message:s.message}),n.dirty());else if(s.kind==="url")try{new URL(e.data);}catch{o=this._getOrReturnCtx(e,o),m(o,{validation:"url",code:d.invalid_string,message:s.message}),n.dirty();}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(o=this._getOrReturnCtx(e,o),m(o,{validation:"regex",code:d.invalid_string,message:s.message}),n.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(o=this._getOrReturnCtx(e,o),m(o,{code:d.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),n.dirty()):s.kind==="toLowerCase"?e.data=e.data.toLowerCase():s.kind==="toUpperCase"?e.data=e.data.toUpperCase():s.kind==="startsWith"?e.data.startsWith(s.value)||(o=this._getOrReturnCtx(e,o),m(o,{code:d.invalid_string,validation:{startsWith:s.value},message:s.message}),n.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(o=this._getOrReturnCtx(e,o),m(o,{code:d.invalid_string,validation:{endsWith:s.value},message:s.message}),n.dirty()):s.kind==="datetime"?lr(s).test(e.data)||(o=this._getOrReturnCtx(e,o),m(o,{code:d.invalid_string,validation:"datetime",message:s.message}),n.dirty()):s.kind==="date"?_n.test(e.data)||(o=this._getOrReturnCtx(e,o),m(o,{code:d.invalid_string,validation:"date",message:s.message}),n.dirty()):s.kind==="time"?kn(s).test(e.data)||(o=this._getOrReturnCtx(e,o),m(o,{code:d.invalid_string,validation:"time",message:s.message}),n.dirty()):s.kind==="duration"?fn.test(e.data)||(o=this._getOrReturnCtx(e,o),m(o,{validation:"duration",code:d.invalid_string,message:s.message}),n.dirty()):s.kind==="ip"?Tn(e.data,s.version)||(o=this._getOrReturnCtx(e,o),m(o,{validation:"ip",code:d.invalid_string,message:s.message}),n.dirty()):s.kind==="jwt"?Sn(e.data,s.alg)||(o=this._getOrReturnCtx(e,o),m(o,{validation:"jwt",code:d.invalid_string,message:s.message}),n.dirty()):s.kind==="cidr"?An(e.data,s.version)||(o=this._getOrReturnCtx(e,o),m(o,{validation:"cidr",code:d.invalid_string,message:s.message}),n.dirty()):s.kind==="base64"?bn.test(e.data)||(o=this._getOrReturnCtx(e,o),m(o,{validation:"base64",code:d.invalid_string,message:s.message}),n.dirty()):s.kind==="base64url"?wn.test(e.data)||(o=this._getOrReturnCtx(e,o),m(o,{validation:"base64url",code:d.invalid_string,message:s.message}),n.dirty()):S.assertNever(s);return {status:n.value,value:e.data}}_regex(e,r,n){return this.refinement(o=>e.test(o),{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}};X.create=t=>new X({checks:[],typeName:x.ZodString,coerce:t?.coerce??false,..._(t)});function In(t,e){let r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,o=r>n?r:n,s=Number.parseInt(t.toFixed(o).replace(".","")),a=Number.parseInt(e.toFixed(o).replace(".",""));return s%a/10**o}var ae=class t extends k{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf;}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==y.number){let s=this._getOrReturnCtx(e);return m(s,{code:d.invalid_type,expected:y.number,received:s.parsedType}),v}let n,o=new M;for(let s of this._def.checks)s.kind==="int"?S.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),m(n,{code:d.invalid_type,expected:"integer",received:"float",message:s.message}),o.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(n=this._getOrReturnCtx(e,n),m(n,{code:d.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:false,message:s.message}),o.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),m(n,{code:d.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:false,message:s.message}),o.dirty()):s.kind==="multipleOf"?In(e.data,s.value)!==0&&(n=this._getOrReturnCtx(e,n),m(n,{code:d.not_multiple_of,multipleOf:s.value,message:s.message}),o.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),m(n,{code:d.not_finite,message:s.message}),o.dirty()):S.assertNever(s);return {status:o.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,o){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:g.toString(o)}]})}_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"&&S.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)}};ae.create=t=>new ae({checks:[],typeName:x.ZodNumber,coerce:t?.coerce||false,..._(t)});var ie=class t extends k{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte;}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data);}catch{return this._getInvalidInput(e)}if(this._getType(e)!==y.bigint)return this._getInvalidInput(e);let n,o=new M;for(let s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(n=this._getOrReturnCtx(e,n),m(n,{code:d.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),o.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),m(n,{code:d.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),o.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),m(n,{code:d.not_multiple_of,multipleOf:s.value,message:s.message}),o.dirty()):S.assertNever(s);return {status:o.value,value:e.data}}_getInvalidInput(e){let r=this._getOrReturnCtx(e);return m(r,{code:d.invalid_type,expected:y.bigint,received:r.parsedType}),v}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,o){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:g.toString(o)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:false,message: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}};ie.create=t=>new ie({checks:[],typeName:x.ZodBigInt,coerce:t?.coerce??false,..._(t)});var ce=class extends k{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==y.boolean){let n=this._getOrReturnCtx(e);return m(n,{code:d.invalid_type,expected:y.boolean,received:n.parsedType}),v}return P(e.data)}};ce.create=t=>new ce({typeName:x.ZodBoolean,coerce:t?.coerce||false,..._(t)});var le=class t extends k{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==y.date){let s=this._getOrReturnCtx(e);return m(s,{code:d.invalid_type,expected:y.date,received:s.parsedType}),v}if(Number.isNaN(e.data.getTime())){let s=this._getOrReturnCtx(e);return m(s,{code:d.invalid_date}),v}let n=new M,o;for(let s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(o=this._getOrReturnCtx(e,o),m(o,{code:d.too_small,message:s.message,inclusive:true,exact:false,minimum:s.value,type:"date"}),n.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(o=this._getOrReturnCtx(e,o),m(o,{code:d.too_big,message:s.message,inclusive:true,exact:false,maximum:s.value,type:"date"}),n.dirty()):S.assertNever(s);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}};le.create=t=>new le({checks:[],coerce:t?.coerce||false,typeName:x.ZodDate,..._(t)});var Ee=class extends k{_parse(e){if(this._getType(e)!==y.symbol){let n=this._getOrReturnCtx(e);return m(n,{code:d.invalid_type,expected:y.symbol,received:n.parsedType}),v}return P(e.data)}};Ee.create=t=>new Ee({typeName:x.ZodSymbol,..._(t)});var ue=class extends k{_parse(e){if(this._getType(e)!==y.undefined){let n=this._getOrReturnCtx(e);return m(n,{code:d.invalid_type,expected:y.undefined,received:n.parsedType}),v}return P(e.data)}};ue.create=t=>new ue({typeName:x.ZodUndefined,..._(t)});var de=class extends k{_parse(e){if(this._getType(e)!==y.null){let n=this._getOrReturnCtx(e);return m(n,{code:d.invalid_type,expected:y.null,received:n.parsedType}),v}return P(e.data)}};de.create=t=>new de({typeName:x.ZodNull,..._(t)});var Q=class extends k{constructor(){super(...arguments),this._any=true;}_parse(e){return P(e.data)}};Q.create=t=>new Q({typeName:x.ZodAny,..._(t)});var J=class extends k{constructor(){super(...arguments),this._unknown=true;}_parse(e){return P(e.data)}};J.create=t=>new J({typeName:x.ZodUnknown,..._(t)});var U=class extends k{_parse(e){let r=this._getOrReturnCtx(e);return m(r,{code:d.invalid_type,expected:y.never,received:r.parsedType}),v}};U.create=t=>new U({typeName:x.ZodNever,..._(t)});var Re=class extends k{_parse(e){if(this._getType(e)!==y.undefined){let n=this._getOrReturnCtx(e);return m(n,{code:d.invalid_type,expected:y.void,received:n.parsedType}),v}return P(e.data)}};Re.create=t=>new Re({typeName:x.ZodVoid,..._(t)});var q=class t extends k{_parse(e){let{ctx:r,status:n}=this._processInputParams(e),o=this._def;if(r.parsedType!==y.array)return m(r,{code:d.invalid_type,expected:y.array,received:r.parsedType}),v;if(o.exactLength!==null){let a=r.data.length>o.exactLength.value,i=r.data.length<o.exactLength.value;(a||i)&&(m(r,{code:a?d.too_big:d.too_small,minimum:i?o.exactLength.value:void 0,maximum:a?o.exactLength.value:void 0,type:"array",inclusive:true,exact:true,message:o.exactLength.message}),n.dirty());}if(o.minLength!==null&&r.data.length<o.minLength.value&&(m(r,{code:d.too_small,minimum:o.minLength.value,type:"array",inclusive:true,exact:false,message:o.minLength.message}),n.dirty()),o.maxLength!==null&&r.data.length>o.maxLength.value&&(m(r,{code:d.too_big,maximum:o.maxLength.value,type:"array",inclusive:true,exact:false,message:o.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((a,i)=>o.type._parseAsync(new W(r,a,r.path,i)))).then(a=>M.mergeArray(n,a));let s=[...r.data].map((a,i)=>o.type._parseSync(new W(r,a,r.path,i)));return M.mergeArray(n,s)}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:x.ZodArray,..._(e)});function Ce(t){if(t instanceof N){let e={};for(let r in t.shape){let n=t.shape[r];e[r]=L.create(Ce(n));}return new N({...t._def,shape:()=>e})}else return t instanceof q?new q({...t._def,type:Ce(t.element)}):t instanceof L?L.create(Ce(t.unwrap())):t instanceof F?F.create(Ce(t.unwrap())):t instanceof Z?Z.create(t.items.map(e=>Ce(e))):t}var N=class t extends k{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=S.objectKeys(e);return this._cached={shape:e,keys:r},this._cached}_parse(e){if(this._getType(e)!==y.object){let u=this._getOrReturnCtx(e);return m(u,{code:d.invalid_type,expected:y.object,received:u.parsedType}),v}let{status:n,ctx:o}=this._processInputParams(e),{shape:s,keys:a}=this._getCached(),i=[];if(!(this._def.catchall instanceof U&&this._def.unknownKeys==="strip"))for(let u in o.data)a.includes(u)||i.push(u);let c=[];for(let u of a){let p=s[u],h=o.data[u];c.push({key:{status:"valid",value:u},value:p._parse(new W(o,h,o.path,u)),alwaysSet:u in o.data});}if(this._def.catchall instanceof U){let u=this._def.unknownKeys;if(u==="passthrough")for(let p of i)c.push({key:{status:"valid",value:p},value:{status:"valid",value:o.data[p]}});else if(u==="strict")i.length>0&&(m(o,{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 h=o.data[p];c.push({key:{status:"valid",value:p},value:u._parse(new W(o,h,o.path,p)),alwaysSet:p in o.data});}}return o.common.async?Promise.resolve().then(async()=>{let u=[];for(let p of c){let h=await p.key,w=await p.value;u.push({key:h,value:w,alwaysSet:p.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 o=this._def.errorMap?.(r,n).message??n.defaultError;return r.code==="unrecognized_keys"?{message:g.errToObj(e).message??o}:{message:o}}}:{}})}strip(){return new t({...this._def,unknownKeys:"strip"})}passthrough(){return new t({...this._def,unknownKeys:"passthrough"})}extend(e){return new t({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:x.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 S.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 S.objectKeys(this.shape))e[n]||(r[n]=this.shape[n]);return new t({...this._def,shape:()=>r})}deepPartial(){return Ce(this)}partial(e){let r={};for(let n of S.objectKeys(this.shape)){let o=this.shape[n];e&&!e[n]?r[n]=o:r[n]=o.optional();}return new t({...this._def,shape:()=>r})}required(e){let r={};for(let n of S.objectKeys(this.shape))if(e&&!e[n])r[n]=this.shape[n];else {let s=this.shape[n];for(;s instanceof L;)s=s._def.innerType;r[n]=s;}return new t({...this._def,shape:()=>r})}keyof(){return ur(S.objectKeys(this.shape))}};N.create=(t,e)=>new N({shape:()=>t,unknownKeys:"strip",catchall:U.create(),typeName:x.ZodObject,..._(e)});N.strictCreate=(t,e)=>new N({shape:()=>t,unknownKeys:"strict",catchall:U.create(),typeName:x.ZodObject,..._(e)});N.lazycreate=(t,e)=>new N({shape:t,unknownKeys:"strip",catchall:U.create(),typeName:x.ZodObject,..._(e)});var pe=class extends k{_parse(e){let{ctx:r}=this._processInputParams(e),n=this._def.options;function o(s){for(let i of s)if(i.result.status==="valid")return i.result;for(let i of s)if(i.result.status==="dirty")return r.common.issues.push(...i.ctx.common.issues),i.result;let a=s.map(i=>new j(i.ctx.common.issues));return m(r,{code:d.invalid_union,unionErrors:a}),v}if(r.common.async)return Promise.all(n.map(async s=>{let a={...r,common:{...r.common,issues:[]},parent:null};return {result:await s._parseAsync({data:r.data,path:r.path,parent:a}),ctx:a}})).then(o);{let s,a=[];for(let c of n){let u={...r,common:{...r.common,issues:[]},parent:null},p=c._parseSync({data:r.data,path:r.path,parent:u});if(p.status==="valid")return p;p.status==="dirty"&&!s&&(s={result:p,ctx:u}),u.common.issues.length&&a.push(u.common.issues);}if(s)return r.common.issues.push(...s.ctx.common.issues),s.result;let i=a.map(c=>new j(c));return m(r,{code:d.invalid_union,unionErrors:i}),v}}get options(){return this._def.options}};pe.create=(t,e)=>new pe({options:t,typeName:x.ZodUnion,..._(e)});var H=t=>t instanceof me?H(t.schema):t instanceof B?H(t.innerType()):t instanceof ye?[t.value]:t instanceof ge?t.options:t instanceof he?S.objectValues(t.enum):t instanceof ve?H(t._def.innerType):t instanceof ue?[void 0]:t instanceof de?[null]:t instanceof L?[void 0,...H(t.unwrap())]:t instanceof F?[null,...H(t.unwrap())]:t instanceof Be||t instanceof be?H(t.unwrap()):t instanceof xe?H(t._def.innerType):[],He=class t extends k{_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==y.object)return m(r,{code:d.invalid_type,expected:y.object,received:r.parsedType}),v;let n=this.discriminator,o=r.data[n],s=this.optionsMap.get(o);return s?r.common.async?s._parseAsync({data:r.data,path:r.path,parent:r}):s._parseSync({data:r.data,path:r.path,parent:r}):(m(r,{code:d.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),v)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,n){let o=new Map;for(let s of r){let a=H(s.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(o.has(i))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(i)}`);o.set(i,s);}}return new t({typeName:x.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:o,..._(n)})}};function yt(t,e){let r=z(t),n=z(e);if(t===e)return {valid:true,data:t};if(r===y.object&&n===y.object){let o=S.objectKeys(e),s=S.objectKeys(t).filter(i=>o.indexOf(i)!==-1),a={...t,...e};for(let i of s){let c=yt(t[i],e[i]);if(!c.valid)return {valid:false};a[i]=c.data;}return {valid:true,data:a}}else if(r===y.array&&n===y.array){if(t.length!==e.length)return {valid:false};let o=[];for(let s=0;s<t.length;s++){let a=t[s],i=e[s],c=yt(a,i);if(!c.valid)return {valid:false};o.push(c.data);}return {valid:true,data:o}}else return r===y.date&&n===y.date&&+t==+e?{valid:true,data:t}:{valid:false}}var fe=class extends k{_parse(e){let{status:r,ctx:n}=this._processInputParams(e),o=(s,a)=>{if(Fe(s)||Fe(a))return v;let i=yt(s.value,a.value);return i.valid?((Ke(s)||Ke(a))&&r.dirty(),{status:r.value,value:i.data}):(m(n,{code:d.invalid_intersection_types}),v)};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(([s,a])=>o(s,a)):o(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};fe.create=(t,e,r)=>new fe({left:t,right:e,typeName:x.ZodIntersection,..._(r)});var Z=class t extends k{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==y.array)return m(n,{code:d.invalid_type,expected:y.array,received:n.parsedType}),v;if(n.data.length<this._def.items.length)return m(n,{code:d.too_small,minimum:this._def.items.length,inclusive:true,exact:false,type:"array"}),v;!this._def.rest&&n.data.length>this._def.items.length&&(m(n,{code:d.too_big,maximum:this._def.items.length,inclusive:true,exact:false,type:"array"}),r.dirty());let s=[...n.data].map((a,i)=>{let c=this._def.items[i]||this._def.rest;return c?c._parse(new W(n,a,n.path,i)):null}).filter(a=>!!a);return n.common.async?Promise.all(s).then(a=>M.mergeArray(r,a)):M.mergeArray(r,s)}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:x.ZodTuple,rest:null,..._(e)})};var Je=class t extends k{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!==y.object)return m(n,{code:d.invalid_type,expected:y.object,received:n.parsedType}),v;let o=[],s=this._def.keyType,a=this._def.valueType;for(let i in n.data)o.push({key:s._parse(new W(n,i,n.path,i)),value:a._parse(new W(n,n.data[i],n.path,i)),alwaysSet:i in n.data});return n.common.async?M.mergeObjectAsync(r,o):M.mergeObjectSync(r,o)}get element(){return this._def.valueType}static create(e,r,n){return r instanceof k?new t({keyType:e,valueType:r,typeName:x.ZodRecord,..._(n)}):new t({keyType:X.create(),valueType:e,typeName:x.ZodRecord,..._(r)})}},Me=class extends k{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!==y.map)return m(n,{code:d.invalid_type,expected:y.map,received:n.parsedType}),v;let o=this._def.keyType,s=this._def.valueType,a=[...n.data.entries()].map(([i,c],u)=>({key:o._parse(new W(n,i,n.path,[u,"key"])),value:s._parse(new W(n,c,n.path,[u,"value"]))}));if(n.common.async){let i=new Map;return Promise.resolve().then(async()=>{for(let c of a){let u=await c.key,p=await c.value;if(u.status==="aborted"||p.status==="aborted")return v;(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 c of a){let u=c.key,p=c.value;if(u.status==="aborted"||p.status==="aborted")return v;(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:x.ZodMap,..._(r)});var Oe=class t extends k{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==y.set)return m(n,{code:d.invalid_type,expected:y.set,received:n.parsedType}),v;let o=this._def;o.minSize!==null&&n.data.size<o.minSize.value&&(m(n,{code:d.too_small,minimum:o.minSize.value,type:"set",inclusive:true,exact:false,message:o.minSize.message}),r.dirty()),o.maxSize!==null&&n.data.size>o.maxSize.value&&(m(n,{code:d.too_big,maximum:o.maxSize.value,type:"set",inclusive:true,exact:false,message:o.maxSize.message}),r.dirty());let s=this._def.valueType;function a(c){let u=new Set;for(let p of c){if(p.status==="aborted")return v;p.status==="dirty"&&r.dirty(),u.add(p.value);}return {status:r.value,value:u}}let i=[...n.data.values()].map((c,u)=>s._parse(new W(n,c,n.path,u)));return n.common.async?Promise.all(i).then(c=>a(c)):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)}};Oe.create=(t,e)=>new Oe({valueType:t,minSize:null,maxSize:null,typeName:x.ZodSet,..._(e)});var qe=class t extends k{constructor(){super(...arguments),this.validate=this.implement;}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==y.function)return m(r,{code:d.invalid_type,expected:y.function,received:r.parsedType}),v;function n(i,c){return We({data:i,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Ae(),K].filter(u=>!!u),issueData:{code:d.invalid_arguments,argumentsError:c}})}function o(i,c){return We({data:i,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Ae(),K].filter(u=>!!u),issueData:{code:d.invalid_return_type,returnTypeError:c}})}let s={errorMap:r.common.contextualErrorMap},a=r.data;if(this._def.returns instanceof ee){let i=this;return P(async function(...c){let u=new j([]),p=await i._def.args.parseAsync(c,s).catch(I=>{throw u.addIssue(n(c,I)),u}),h=await Reflect.apply(a,this,p);return await i._def.returns._def.type.parseAsync(h,s).catch(I=>{throw u.addIssue(o(h,I)),u})})}else {let i=this;return P(function(...c){let u=i._def.args.safeParse(c,s);if(!u.success)throw new j([n(c,u.error)]);let p=Reflect.apply(a,this,u.data),h=i._def.returns.safeParse(p,s);if(!h.success)throw new j([o(p,h.error)]);return h.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:Z.create(e).rest(J.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(J.create()),returns:r||J.create(),typeName:x.ZodFunction,..._(n)})}},me=class extends k{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})}};me.create=(t,e)=>new me({getter:t,typeName:x.ZodLazy,..._(e)});var ye=class extends k{_parse(e){if(e.data!==this._def.value){let r=this._getOrReturnCtx(e);return m(r,{received:r.data,code:d.invalid_literal,expected:this._def.value}),v}return {status:"valid",value:e.data}}get value(){return this._def.value}};ye.create=(t,e)=>new ye({value:t,typeName:x.ZodLiteral,..._(e)});function ur(t,e){return new ge({values:t,typeName:x.ZodEnum,..._(e)})}var ge=class t extends k{_parse(e){if(typeof e.data!="string"){let r=this._getOrReturnCtx(e),n=this._def.values;return m(r,{expected:S.joinValues(n),received:r.parsedType,code:d.invalid_type}),v}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 m(r,{received:r.data,code:d.invalid_enum_value,options:n}),v}return P(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})}};ge.create=ur;var he=class extends k{_parse(e){let r=S.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==y.string&&n.parsedType!==y.number){let o=S.objectValues(r);return m(n,{expected:S.joinValues(o),received:n.parsedType,code:d.invalid_type}),v}if(this._cache||(this._cache=new Set(S.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let o=S.objectValues(r);return m(n,{received:n.data,code:d.invalid_enum_value,options:o}),v}return P(e.data)}get enum(){return this._def.values}};he.create=(t,e)=>new he({values:t,typeName:x.ZodNativeEnum,..._(e)});var ee=class extends k{unwrap(){return this._def.type}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==y.promise&&r.common.async===false)return m(r,{code:d.invalid_type,expected:y.promise,received:r.parsedType}),v;let n=r.parsedType===y.promise?r.data:Promise.resolve(r.data);return P(n.then(o=>this._def.type.parseAsync(o,{path:r.path,errorMap:r.common.contextualErrorMap})))}};ee.create=(t,e)=>new ee({type:t,typeName:x.ZodPromise,..._(e)});var B=class extends k{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===x.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:r,ctx:n}=this._processInputParams(e),o=this._def.effect||null,s={addIssue:a=>{m(n,a),a.fatal?r.abort():r.dirty();},get path(){return n.path}};if(s.addIssue=s.addIssue.bind(s),o.type==="preprocess"){let a=o.transform(n.data,s);if(n.common.async)return Promise.resolve(a).then(async i=>{if(r.value==="aborted")return v;let c=await this._def.schema._parseAsync({data:i,path:n.path,parent:n});return c.status==="aborted"?v:c.status==="dirty"?se(c.value):r.value==="dirty"?se(c.value):c});{if(r.value==="aborted")return v;let i=this._def.schema._parseSync({data:a,path:n.path,parent:n});return i.status==="aborted"?v:i.status==="dirty"?se(i.value):r.value==="dirty"?se(i.value):i}}if(o.type==="refinement"){let a=i=>{let c=o.refinement(i,s);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 i};if(n.common.async===false){let i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?v:(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"?v:(i.status==="dirty"&&r.dirty(),a(i.value).then(()=>({status:r.value,value:i.value}))))}if(o.type==="transform")if(n.common.async===false){let a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!Y(a))return v;let i=o.transform(a.value,s);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=>Y(a)?Promise.resolve(o.transform(a.value,s)).then(i=>({status:r.value,value:i})):v);S.assertNever(o);}};B.create=(t,e,r)=>new B({schema:t,typeName:x.ZodEffects,effect:e,..._(r)});B.createWithPreprocess=(t,e,r)=>new B({schema:e,effect:{type:"preprocess",transform:t},typeName:x.ZodEffects,..._(r)});var L=class extends k{_parse(e){return this._getType(e)===y.undefined?P(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};L.create=(t,e)=>new L({innerType:t,typeName:x.ZodOptional,..._(e)});var F=class extends k{_parse(e){return this._getType(e)===y.null?P(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};F.create=(t,e)=>new F({innerType:t,typeName:x.ZodNullable,..._(e)});var ve=class extends k{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return r.parsedType===y.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};ve.create=(t,e)=>new ve({innerType:t,typeName:x.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,..._(e)});var xe=class extends k{_parse(e){let{ctx:r}=this._processInputParams(e),n={...r,common:{...r.common,issues:[]}},o=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Ie(o)?o.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new j(n.common.issues)},input:n.data})})):{status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new j(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};xe.create=(t,e)=>new xe({innerType:t,typeName:x.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,..._(e)});var Pe=class extends k{_parse(e){if(this._getType(e)!==y.nan){let n=this._getOrReturnCtx(e);return m(n,{code:d.invalid_type,expected:y.nan,received:n.parsedType}),v}return {status:"valid",value:e.data}}};Pe.create=t=>new Pe({typeName:x.ZodNaN,..._(t)});var Cn=Symbol("zod_brand"),Be=class extends k{_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}},Ve=class t extends k{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.common.async)return (async()=>{let s=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?v:s.status==="dirty"?(r.dirty(),se(s.value)):this._def.out._parseAsync({data:s.value,path:n.path,parent:n})})();{let o=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?v:o.status==="dirty"?(r.dirty(),{status:"dirty",value:o.value}):this._def.out._parseSync({data:o.value,path:n.path,parent:n})}}static create(e,r){return new t({in:e,out:r,typeName:x.ZodPipeline})}},be=class extends k{_parse(e){let r=this._def.innerType._parse(e),n=o=>(Y(o)&&(o.value=Object.freeze(o.value)),o);return Ie(r)?r.then(o=>n(o)):n(r)}unwrap(){return this._def.innerType}};be.create=(t,e)=>new be({innerType:t,typeName:x.ZodReadonly,..._(e)});function ar(t,e){let r=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof r=="string"?{message:r}:r}function dr(t,e={},r){return t?Q.create().superRefine((n,o)=>{let s=t(n);if(s instanceof Promise)return s.then(a=>{if(!a){let i=ar(e,n),c=i.fatal??r??true;o.addIssue({code:"custom",...i,fatal:c});}});if(!s){let a=ar(e,n),i=a.fatal??r??true;o.addIssue({code:"custom",...a,fatal:i});}}):Q.create()}var En={object:N.lazycreate},x;(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";})(x||(x={}));var Rn=(t,e={message:`Input not instance of ${t.name}`})=>dr(r=>r instanceof t,e),pr=X.create,fr=ae.create,Mn=Pe.create,On=ie.create,mr=ce.create,Pn=le.create,Dn=Ee.create,jn=ue.create,Nn=de.create,$n=Q.create,Ln=J.create,Wn=U.create,Bn=Re.create,Vn=q.create,Un=N.create,Gn=N.strictCreate,zn=pe.create,Zn=He.create,Fn=fe.create,Kn=Z.create,Hn=Je.create,Jn=Me.create,qn=Oe.create,Yn=qe.create,Xn=me.create,Qn=ye.create,eo=ge.create,to=he.create,ro=ee.create,no=B.create,oo=L.create,so=F.create,ao=B.createWithPreprocess,io=Ve.create,co=()=>pr().optional(),lo=()=>fr().optional(),uo=()=>mr().optional(),po={string:(t=>X.create({...t,coerce:true})),number:(t=>ae.create({...t,coerce:true})),boolean:(t=>ce.create({...t,coerce:true})),bigint:(t=>ie.create({...t,coerce:true})),date:(t=>le.create({...t,coerce:true}))};var fo=v;var De="agtx_pk_",Ye="agtx_sk_";l.string().min(De.length+8).startsWith(De,{message:`Publishable keys must start with "${De}".`});l.string().min(Ye.length+8).startsWith(Ye,{message:`Secret keys must start with "${Ye}".`});var yr=t=>t.startsWith(De)?"publishable":t.startsWith(Ye)?"secret":"unknown",we=l.enum(["webmcp","dom","screenshot","crawler"]),gt=l.enum(["detected","declared","verified","linked"]),mo=l.object({class:we,trust:gt,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({})}),yo=l.enum(["bearer","oauth2","sso","spiffe","google-agent","mtls","detection","declaration","extension","session-link","x-agent-header"]),Ue=l.object({class:we,vendor:l.string().min(1),token:l.string().min(8),expiresAt:l.string().datetime().optional()});l.object({publishableKey:l.string(),claim:Ue,nonce:l.string().min(8),origin:l.string().url()});l.object({trust:gt,vendor:l.string(),validUntil:l.string().datetime(),reason:l.string().optional(),subject:l.string().optional(),protocol:yo.optional(),signals:l.record(l.unknown()).optional()});l.object({issuer:l.string().url(),audiences:l.array(l.string().min(1)).min(1)});l.object({trustDomain:l.string().min(1),bundleEndpoint:l.string().url(),audiences:l.array(l.string().min(1)).min(1),googleTrustDomains:l.array(l.string().min(1)).optional()});l.object({rootCerts:l.array(l.string().min(20)).min(1),spiffeTrustDomain:l.string().min(1).optional(),xfccEntryPolicy:l.enum(["last","first","only"]).default("last")});l.enum(["sso","spiffe","mtls"]);l.object({siteId:l.string().min(1),token:l.string().min(8).optional(),xfcc:l.string().min(1).optional(),headers:l.record(l.string()).optional(),origin:l.string().url().optional()});var G={detected:0,declared:1,verified:2,linked:3},gr=(t,e)=>G[t]>G[e],hr=l.enum(["allow","deny","review"]),Ge=l.object({id:l.string(),tool:l.string(),minTrust:gt,allowedClasses:l.array(we).default([]),decision:hr,rateLimit:l.object({max:l.number().int().positive(),windowSeconds:l.number().int().positive()}).optional()}),go=l.object({decision:hr,ruleId:l.string().nullable(),reason:l.string()}),ho=l.enum(["session","user","org"]),ht=l.object({key:l.string().min(1),value:l.unknown(),scope:ho.default("session"),ttlSeconds:l.number().int().positive().nullable().default(null),updatedAt:l.string().datetime().optional()}),vo=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()}),xo=l.object({pattern:l.string().optional(),flow:l.string().optional()}),bo=l.object({pages:l.array(vo).default([]),navigation:xo.optional()}),wo=l.object({step:l.number().int().positive(),action:l.string().min(1)}),_o=l.object({steps:l.array(wo).default([]),notes:l.string().optional(),policy:l.string().optional()}),ko=l.object({selector:l.string().min(1),behavior:l.string().optional(),location:l.string().optional(),showsCount:l.boolean().optional()}),To=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()}),vt=l.object({path:l.string().min(1),payload:l.record(l.unknown()).default({}),updatedAt:l.string().datetime().optional()}).strict(),$=l.object({version:l.string().default("1"),siteMap:bo.optional(),workflows:l.record(_o).default({}),policies:l.record(l.union([l.string(),l.array(l.string())])).default({}),catalog:To.optional(),uiGuidance:l.record(ko).default({}),pageContexts:l.record(vt).default({}),updatedAt:l.string().datetime().optional()}),vr=$.parse({}),So=l.object({name:l.string().min(1),group:l.string().optional(),page:l.string().optional(),description:l.string().default(""),inputSchema:l.record(l.unknown()).default({}),outputSchema:l.record(l.unknown()).optional(),tokens:l.number().int().nonnegative().default(0)}),Ao=l.object({tools:l.array(So).default([])});Ao.parse({});var Io=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"]),xt=l.object({id:l.string(),siteId:l.string(),sessionId:l.string(),occurredAt:l.string().datetime(),type:Io,tool:l.string().optional(),agent:mo.nullable().optional(),policy:go.optional(),durationMs:l.number().int().nonnegative().optional(),outcome:l.enum(["success","error","blocked"]),error:l.string().optional(),metadata:l.record(l.unknown()).default({})});l.object({publishableKey:l.string().optional(),events:l.array(xt).min(1).max(100)});var ze=class extends Error{code;constructor(t,e){super(e),this.name="AgentronicsError",this.code=t;}};var A="0.1.2";var Co=()=>{if(typeof navigator>"u")return null;let t=navigator.modelContext;return t&&typeof t=="object"?t:null},je=async(t={})=>{let{pollMs:e=500}=t,r=Date.now();for(;;){let n=Co();if(n)return Eo(n);if(Date.now()-r>=e)return null;await new Promise(o=>setTimeout(o,50));}},Eo=t=>({class:"webmcp",trust:"detected",confidence:1,vendor:t.vendor??t.client??null,userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:A,signals:{webmcp:true,toolCount:Array.isArray(t.tools)?t.tools.length:0}});var bt=[{name:"GPTBot",category:"ai",pattern:/GPTBot/i},{name:"OAI-SearchBot",category:"ai",pattern:/OAI-SearchBot/i},{name:"ChatGPT-User",category:"ai",pattern:/ChatGPT-User/i},{name:"ClaudeBot",category:"ai",pattern:/ClaudeBot/i},{name:"Claude-Web",category:"ai",pattern:/Claude-Web/i},{name:"anthropic-ai",category:"ai",pattern:/anthropic-ai/i},{name:"PerplexityBot",category:"ai",pattern:/PerplexityBot/i},{name:"Google-Extended",category:"ai",pattern:/Google-Extended/i},{name:"Applebot-Extended",category:"ai",pattern:/Applebot-Extended/i},{name:"Amazonbot",category:"ai",pattern:/Amazonbot/i},{name:"Bytespider",category:"ai",pattern:/Bytespider/i},{name:"CCBot",category:"ai",pattern:/CCBot/i},{name:"Meta-ExternalAgent",category:"ai",pattern:/Meta-ExternalAgent/i},{name:"cohere-ai",category:"ai",pattern:/cohere-ai/i},{name:"Googlebot",category:"search",pattern:/Googlebot/i},{name:"Bingbot",category:"search",pattern:/bingbot/i},{name:"DuckDuckBot",category:"search",pattern:/DuckDuckBot/i},{name:"YandexBot",category:"search",pattern:/YandexBot/i},{name:"Baiduspider",category:"search",pattern:/Baiduspider/i},{name:"Applebot",category:"search",pattern:/Applebot/i}],Ne=(t={})=>{let{signatures:e=bt,disable:r=false,confidence:n=.9}=t;if(r||typeof navigator>"u")return null;let o=navigator.userAgent??"";if(!o)return null;for(let s of e)if(s.pattern.test(o))return {class:"crawler",trust:"detected",confidence:n,vendor:s.name,userAgent:o,detectionVersion:A,signals:{matched:s.name,category:s.category,ua:o}};return null};var Ro=[/HeadlessChrome/i,/Headless/i,/PhantomJS/i,/SlimerJS/i],Mo=()=>({hit:(typeof navigator<"u"&&navigator.webdriver)===true,weight:.6,detail:"navigator.webdriver === true"}),Oo=()=>{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_*"}`}},Po=()=>{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"}},Do=()=>{if(typeof navigator>"u")return {hit:false,weight:.7};let t=navigator.userAgent??"",e=Ro.some(r=>r.test(t));return e?{hit:e,weight:.7,detail:`headless UA: ${t}`}:{hit:e,weight:.7}},jo=()=>{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"}},No=()=>{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"}},$o={webdriver:Mo,chromedriver:Oo,headlessUa:Do,languages:jo,permissions:No,plugins:Po},$e=(t={})=>{let{threshold:e=.4}=t,r={},n=0,o=0;for(let[a,i]of Object.entries($o)){let c=i();n+=c.weight,r[a]={hit:c.hit,weight:c.weight,detail:c.detail},c.hit&&(o+=c.weight);}let s=n===0?0:o/n;return s<e?null:{class:"dom",trust:"detected",confidence:s,vendor:null,userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:A,signals:r}};var wt=()=>[{id:"webmcp.model-context",status:"stable",detect:()=>je({pollMs:0})},{id:"crawler.user-agent",status:"beta",detect:()=>Ne()},{id:"dom.automation-heuristics",status:"beta",detect:()=>$e()}],Xe=(t=wt())=>{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(o=>o.status===r):n},async detectAll(r=false){for(let n of e.values()){if(n.status==="research"&&!r)continue;let o=await n.detect();if(o)return o}return null}}};var _t=t=>{let e=we.parse(t.class),r=t.verificationToken?"verified":"declared";return {class:e,trust:r,confidence:1,vendor:t.vendor,userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:A,signals:{declared:true,hasVerificationToken:!!t.verificationToken}}};var xr=({gatewayUrl:t,fetcher:e=fetch})=>{let r=null,n=[];return {snapshot(){return [...n]},async sync(){let o=await e(`${t.replace(/\/$/,"")}/v1/detector-signatures`,{headers:r?{"if-none-match":r}:{}});if(o.status===304)return this.snapshot();if(!o.ok)throw new Error(`Detector signature sync failed with status ${o.status}.`);return n=(await o.json()).signatures??[],r=o.headers.get("etag"),this.snapshot()}}};var Qe=async(t={})=>{if(t.customDetectors?.length){let e=await Xe(t.customDetectors).detectAll(!!t.experimental);if(e)return e}if(t.webmcp!==false){let e=await je(t.webmcp??{});if(e)return e}if(t.crawler!==false){let e=Ne(t.crawler??{});if(e)return e}if(t.dom!==false){let e=$e(t.dom??{});if(e)return e}return null};var Lo=t=>({class:t.class,trust:"declared",confidence:1,vendor:t.vendor,userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:A,signals:{declared:true,hasToken:true,tokenExpiresAt:t.expiresAt??null}}),kt=()=>{let t=null;return {present(e){let r=Ue.safeParse(e);if(!r.success)throw new ze("invalid_api_key",`Invalid identity claim: ${r.error.issues[0]?.message??"unknown"}`);let n={claim:r.data,identity:Lo(r.data)};return t=n,n},clear(){t=null;},preferOver(e){return t?e?gr(t.identity.trust,e.trust)?t.identity:e:t.identity:e},snapshot(){return t}}};var Wo=({detected:t,declared:e,verified:r,linked:n})=>n?"linked":r?"verified":e?"declared":"detected",Tt=t=>{let e=null;for(let r of t)(!e||G[r.trust]>G[e.trust])&&(e=r);return e};var br=()=>({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:A,signals:{bearer:true,verifiedRemotely:!!r}}}});var wr=()=>({name:"detection",async authenticate(t){return t.detected??null}});var _r=()=>({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:A,signals:{extensionToken:true,verifiedRemotely:!!r}}}});var kr=()=>({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:A,signals:{mtls:true,subject:r?.subject??null,verifiedRemotely:!!r,...r?.signals??{}}}}});var Tr=()=>({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:A,signals:{oauth2:true,subject:t.oauth2Subject??null,verifiedRemotely:!!r}}}});var Bo=t=>({class:t.class,trust:"declared",confidence:1,vendor:t.vendor,userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:A,signals:{declared:true,hasToken:true,tokenExpiresAt:t.expiresAt??null}}),Sr=()=>({name:"selfDeclaration",async authenticate(t){return t.declaration?Bo(Ue.parse(t.declaration)):null}});var Ar=()=>({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:A,signals:{sessionLink:true,linkedUserId:t.linkedUserId??null,verifiedRemotely:!!r}}}});var Ir=()=>({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:A,signals:{sso:true,subject:r?.subject??null,verifiedRemotely:!!r,...r?.signals??{}}}}});var Cr=()=>({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:A,signals:{spiffe:true,spiffeId:r?.subject??null,subject:r?.subject??null,verifiedRemotely:!!r,...n?{googleAgent:true}:{},...r?.signals??{}}}}});var Er=()=>({name:"xAgentHeader",async authenticate(t){if(!t.xAgentHeader)return null;let[e="x-agent",r="dom",n]=t.xAgentHeader.split(";"),o=we.safeParse(r);return {class:o.success?o.data:"dom",trust:n?"verified":"declared",confidence:n?1:.8,vendor:e,userAgent:typeof navigator>"u"?null:navigator.userAgent,detectionVersion:A,signals:{xAgentHeader:true,hasProof:!!n}}}});var Vo=()=>[wr(),Sr(),br(),Er(),_r(),Ar(),Tr(),Ir(),Cr(),kr()],Uo={detection:"detection",selfDeclaration:"declaration",bearer:"bearer",xAgentHeader:"x-agent-header",extensionToken:"extension",sessionLink:"session-link",oauth2:"oauth2",sso:"sso",spiffe:"spiffe",mtls:"mtls"},Go=(t,e)=>t==="spiffe"&&e.signals?.googleAgent===true?"google-agent":Uo[t],St=({methods:t=Vo(),context:e={},onTrace:r}={})=>({async authenticate(n){let o=[],s={};for(let h of t){let w=await h.authenticate(n,e);s[h.name]=!!w,w&&o.push({method:h.name,identity:w});}let a=Tt(o.map(h=>h.identity)),i=a?o.find(h=>h.identity===a):void 0,c=i?Go(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:s,...c?{protocol:c}:{},...u?{subject:u}:{}}};return a||(p.error="No auth method produced an identity."),r?.(p),a},methods(){return t.map(n=>n.name)}});var zo={identity:null,source:"initial",updatedAt:null},At=()=>{let t=zo,e=new Set,r=()=>{e.size!==0&&e.forEach(n=>n(t));};return {snapshot(){return t},set(n,o){t={identity:n,source:o,updatedAt:new Date().toISOString()},r();},subscribe(n){return e.add(n),()=>{e.delete(n);}}}};var Zo=()=>{let t=new Map;return {read:e=>t.get(e)??null,write:(e,r)=>{t.set(e,r);}}},Fo=()=>typeof window>"u"||!window.localStorage?Zo():{read:t=>{try{return window.localStorage.getItem(t)}catch{return null}},write:(t,e)=>{try{window.localStorage.setItem(t,e);}catch{}}},Ko=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},It=(t=Fo())=>({consume(e,r,n=Date.now()){let o=`agtx:rate:${e}`,s=Ko(t.read(o)),a=s&&s.resetAt>n?s.resetAt:n+r.windowSeconds*1e3,i=s&&s.resetAt>n?s.count+1:1;return t.write(o,JSON.stringify({count:i,resetAt:a})),{allowed:i<=r.max,remaining:Math.max(0,r.max-i),resetAt:a}}});var Ho=(t,e)=>t==="*"||t===e?true:t.includes("*")?new RegExp("^"+t.replace(/[.+?^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*")+"$").test(e):false,Jo=(t,e)=>{let r=t?G[t.trust]:-1,n=G[e.minTrust];return r>=n},qo=(t,e)=>e.allowedClasses.length===0?true:t?e.allowedClasses.includes(t.class):false,Rr="review",Yo=(t,e)=>{let r=e?.class??"unknown",n=e?.vendor??"unknown",o=e?.trust??"none";return `${t}:${r}:${n}:${o}`},Ct=(t=[],e={})=>{let r=t.map(o=>Ge.parse(o)),n=e.rateLimiter??It();return {set(o){r=o.map(s=>Ge.parse(s));},list(){return [...r]},evaluate({tool:o,identity:s}){for(let a of r)if(Ho(a.tool,o)){if(!Jo(s,a))return {decision:"deny",ruleId:a.id,reason:`Rule "${a.id}" requires trust >= ${a.minTrust}.`};if(!qo(s,a))return {decision:"deny",ruleId:a.id,reason:`Rule "${a.id}" restricts to classes: ${a.allowedClasses.join(", ")}.`};if(a.rateLimit){let i=n.consume(Yo(o,s),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:Rr,ruleId:null,reason:`No rule matched tool "${o}". Falling back to "${Rr}".`}}}};var Et=({gatewayUrl:t,siteId:e,publishableKey:r,fetcher:n=fetch})=>{let o={policies:[],etag:null};return {snapshot(){return {policies:[...o.policies],etag:o.etag}},async sync(){let s=await n(`${t.replace(/\/$/,"")}/v1/sites/${encodeURIComponent(e)}/policies`,{headers:{authorization:`Bearer ${r}`,...o.etag?{"if-none-match":o.etag}:{}}});if(s.status===304)return this.snapshot();if(!s.ok)throw new Error(`Policy sync failed with status ${s.status}.`);let a=await s.json();return o={policies:Ge.array().parse(a.policies??[]),etag:s.headers.get("etag")},this.snapshot()}}};var Rt=({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 Mt=({policyEngine:t,getIdentity:e,documentRef:r=typeof document>"u"?void 0:document,selector:n="[data-agentronics-tool]"})=>{if(!r)return {uninstall:()=>{}};let o=s=>{let a=s.target instanceof Element?s.target.closest(n):null;if(!(a instanceof HTMLElement))return;let i=a.dataset.agentronicsTool;i&&Promise.resolve(e()).then(c=>{let u=t.evaluate({tool:i,identity:c});u.decision==="deny"&&(s.preventDefault(),s.stopPropagation(),Rt({message:u.reason,documentRef:r}));});};return r.addEventListener("click",o,true),{uninstall:()=>r.removeEventListener("click",o,true)}};var Ot=()=>{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()]}},Mr=(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 o=t.key(n);o&&o.startsWith(e)&&r.push(o.slice(e.length));}}catch{}return r}}),Or="agtx:",Pr=()=>{let t=typeof window<"u",e=t&&typeof window.sessionStorage<"u"?Mr(window.sessionStorage,Or+"session:"):Ot(),r=t&&typeof window.localStorage<"u"?Mr(window.localStorage,Or+"user:"):Ot();return {session:e,user:r,org:Ot()}};var Dr=(t,e)=>t.expiresAt!==null&&t.expiresAt<=e,jr=t=>{if(!t)return null;try{let e=JSON.parse(t);return typeof e!="object"||e===null?null:e}catch{return null}},Xo=t=>JSON.stringify(t),Pt=(t={})=>{let e=Pr(),r=c=>{t.onTrace?.(c);};return {get:(c,u={})=>{let p=u.scope??"session",h=e[p],w=jr(h.read(c));if(!w){r({type:"memory.accessed",metadata:{operation:"get",key:c,scope:p,hit:false}});return}if(Dr(w,Date.now())){h.remove(c),r({type:"memory.accessed",metadata:{operation:"get",key:c,scope:p,hit:false,expired:true}});return}return r({type:"memory.accessed",metadata:{operation:"get",key:c,scope:p,hit:true}}),w.value},set:(c,u,p={})=>{let h=p.scope??"session",w=p.ttlSeconds??null,I=Date.now(),E={value:u,expiresAt:w===null?null:I+w*1e3,updatedAt:new Date(I).toISOString()};return e[h].write(c,Xo(E)),r({type:"memory.updated",metadata:{operation:"set",key:c,scope:h,ttlSeconds:w}}),ht.parse({key:c,value:u,scope:h,ttlSeconds:w,updatedAt:E.updatedAt})},remove:(c,u={})=>{let p=u.scope??"session";e[p].remove(c),r({type:"memory.updated",metadata:{operation:"remove",key:c,scope:p}});},list:(c={})=>{let u=c.scope??"session",p=e[u],h=Date.now(),w=[];for(let I of p.keys()){let E=jr(p.read(I));if(E){if(Dr(E,h)){p.remove(I);continue}w.push(ht.parse({key:I,value:E.value,scope:u,ttlSeconds:E.expiresAt===null?null:Math.max(0,Math.round((E.expiresAt-h)/1e3)),updatedAt:E.updatedAt}));}}return r({type:"memory.accessed",metadata:{operation:"list",scope:u,count:w.length}}),w},clear:(c={})=>{let u=c.scope??"session",p=e[u],h=p.keys().length;for(let w of p.keys())p.remove(w);r({type:"memory.updated",metadata:{operation:"clear",scope:u,count:h}});}}};var Dt=t=>$.parse(JSON.parse(JSON.stringify(t))),et=t=>({...t,updatedAt:new Date().toISOString()}),jt=(t={})=>{let e=$.parse({...vr,...t.initial??{}}),r=null,n=new Set,o=b=>{t.onTrace?.(b);},s=()=>{r=null;},a=()=>{if(n.size===0)return;let b=Dt(e);r=b,n.forEach(C=>C(b));},i=b=>{let C=$.parse({...e,...b,workflows:{...e.workflows,...b.workflows??{}},policies:{...e.policies,...b.policies??{}},uiGuidance:{...e.uiGuidance,...b.uiGuidance??{}},pageContexts:{...e.pageContexts,...b.pageContexts??{}}});return e=et(C),s(),o({type:"memory.updated",metadata:{kind:"site",operation:"provide",keys:Object.keys(b)}}),a(),p()},c=(b,C)=>{let R=b.split(".").filter(Boolean);if(R.length===0)throw new Error("siteMemory.update() requires a non-empty dot-path.");let re=JSON.parse(JSON.stringify(e)),ne=re;for(let _e=0;_e<R.length-1;_e++){let V=R[_e],ke=ne[V];(typeof ke!="object"||ke===null||Array.isArray(ke))&&(ne[V]={}),ne=ne[V];}return ne[R[R.length-1]]=C,e=et($.parse(re)),s(),o({type:"memory.updated",metadata:{kind:"site",operation:"update",path:b}}),a(),p()},u=b=>{let C=vt.parse({path:b.path,payload:b.payload,updatedAt:new Date().toISOString()});return e=et({...e,pageContexts:{...e.pageContexts,[b.path]:C}}),s(),o({type:"memory.updated",metadata:{kind:"site",operation:"provideForPage",path:b.path}}),a(),{...C,payload:{...C.payload}}},p=()=>(r||(r=Dt(e)),r);return {provide:i,update:c,provideForPage:u,snapshot:p,get:b=>{if(o({type:"memory.accessed",metadata:{kind:"site",operation:b?"get":"snapshot",path:b??null}}),!b)return Dt(e);let C=b.split(".").filter(Boolean),R=e;for(let re of C){if(typeof R!="object"||R===null)return;R=R[re];}return R},getForPage:b=>{o({type:"memory.accessed",metadata:{kind:"site",operation:"getForPage",path:b}});let C=e.pageContexts[b];return C?{...C,payload:{...C.payload}}:null},replace:b=>(e=et($.parse(b)),s(),a(),p()),subscribe:b=>(n.add(b),()=>{n.delete(b);})}};var Nt=({gatewayUrl:t,siteId:e,publishableKey:r,fetcher:n=fetch})=>{let o={memory:null,etag:null};return {snapshot(){return {memory:o.memory?$.parse(o.memory):null,etag:o.etag}},async sync(){let s=await n(`${t.replace(/\/$/,"")}/v1/sites/${encodeURIComponent(e)}/memory`,{headers:{authorization:`Bearer ${r}`,...o.etag?{"if-none-match":o.etag}:{}}});if(s.status===304)return this.snapshot();if(!s.ok)throw new Error(`Memory sync failed with status ${s.status}.`);let a=await s.json();return o={memory:$.parse(a.memory??{}),etag:s.headers.get("etag")},this.snapshot()}}};var Nr=({toolName:t="getSiteContext",description:e="Returns Agentronics site memory: page map, workflows, policies, UI guidance.",getSnapshot:r,onAccess:n})=>({name:t,description:e,inputSchema:{type:"object",properties:{path:{type:"string",description:'Optional dot-path into the site memory (e.g. "workflows.purchase").'}},required:[]},invoke(o={}){let s=r(),a=o.path??null;if(n?.(a),!a)return {content:s};let i=a.split(".").filter(Boolean),c=s;for(let u of i){if(typeof c!="object"||c===null)return {content:void 0};c=c[u];}return {content:c}}});var te="agent-context-",$t="agentronics-site-context",Qo=t=>{try{return JSON.stringify(t)}catch{return "{}"}},tt=(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);},rt=(t,e)=>{t.querySelectorAll(`meta[name="${e}"]`).forEach(r=>r.remove());},nt=({doc:t=typeof document>"u"?null:document,snapshot:e,schemaType:r="WebSite"})=>{if(!t)return {uninstall:()=>{}};tt(t,`${te}version`,e.version),tt(t,`${te}updated-at`,e.updatedAt??new Date().toISOString()),e.siteMap?.navigation?.flow&&tt(t,`${te}flow`,e.siteMap.navigation.flow),tt(t,`${te}workflows`,Object.keys(e.workflows).join(","));let n=t.getElementById($t);return n||(n=t.createElement("script"),n.type="application/ld+json",n.id=$t,t.head.appendChild(n)),n.textContent=Qo({"@context":"https://schema.org","@type":r,name:"Agentronics Site Memory",agentronics:e}),{uninstall:()=>{rt(t,`${te}version`),rt(t,`${te}updated-at`),rt(t,`${te}flow`),rt(t,`${te}workflows`),t.getElementById($t)?.remove();}}};var $r="agentronics-memory-overlay",es=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
|
-
`,$r=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}`},ot=({doc:t=typeof document>"u"?null:document,snapshot:e,hidden:r=false})=>{if(!t)return {uninstall:()=>{},refresh:()=>{}};let n=t.getElementById(Nr);return n||(n=t.createElement("div"),n.id=Nr,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",Xo(r)),n.textContent=$r(e),{uninstall:()=>{n?.remove();},refresh:o=>{n&&(n.textContent=$r(o));}}};var Lt="/.well-known/agent-context.json",st=async({origin:t,fetcher:e=fetch,signal:r}={})=>{let n=(t?t.replace(/\/$/,""):typeof window<"u"?window.location.origin:"")+Lt;if(!n.startsWith("http"))return null;let o={headers:{accept:"application/json"}};r!==void 0&&(o.signal=r);let s=await e(n,o);if(!s.ok){if(s.status===404)return null;throw new Error(`well-known agent-context fetch failed with status ${s.status}.`)}let a=await s.json();return $.parse(a)},Lr=({snapshot:t})=>JSON.stringify($.parse(t));var Wt=({evaluate:t,setPolicies:e,listPolicies:r,onTrace:n,identityResolver:o})=>{let s=new Map,a=new Set,c=i=>{if(!i.authz||!e||!r)return;let u={id:`tool:${i.name}`,tool:i.name,...i.authz,rateLimit:i.rateLimit??i.authz.rateLimit};e([...r().filter(p=>p.id!==u.id),u]);};return {register(i){return s.set(i.name,i),a.delete(i.name),c(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),a.delete(i.name);}},unregister(i){s.delete(i),a.delete(i);},enable(i){!s.has(i)||!a.has(i)||(a.delete(i),n?.({type:"tool.surfaced",tool:i,metadata:{state:"enabled"}}));},disable(i){!s.has(i)||a.has(i)||(a.add(i),n?.({type:"tool.surfaced",tool:i,metadata:{state:"disabled"}}));},isEnabled:i=>s.has(i)&&!a.has(i),list({includeDisabled:i=false}={}){let u=[...s.values()];return i?u:u.filter(p=>!a.has(p.name))},get:i=>s.get(i),async execute(i,u,p){let h=p===void 0?o?.()??null:p,_=s.get(i);if(!_)throw new Error(`Tool "${i}" is not registered.`);if(a.has(i)){let b={decision:"deny",ruleId:`tool:${i}`,reason:"Tool is disabled."};throw n?.({type:"tool.executed",tool:i,agent:h,policy:b,outcome:"blocked"}),new Error(b.reason)}let I=await t(i,{identity:h});if(I.decision==="deny")throw n?.({type:"tool.executed",tool:i,agent:h,policy:I,outcome:"blocked"}),new Error(I.reason);let E=Date.now();try{let b=await _.execute(u,{identity:h});return n?.({type:"tool.executed",tool:i,agent:h,policy:I,outcome:"success",durationMs:Date.now()-E}),b}catch(b){throw n?.({type:"tool.executed",tool:i,agent:h,policy:I,outcome:"error",durationMs:Date.now()-E,error:b instanceof Error?b.message:String(b)}),b}}}};var Qo=t=>{let e={name:t.name,description:t.description??"",inputSchema:t.inputSchema??{},tokens:0};return t.group&&(e.group=t.group),t.stage&&(e.page=t.stage),t.outputSchema&&(e.outputSchema=t.outputSchema),e.tokens=Math.ceil(JSON.stringify({name:e.name,description:e.description,inputSchema:e.inputSchema,...e.outputSchema?{outputSchema:e.outputSchema}:{}}).length/4),e},Wr=({gatewayUrl:t,siteId:e,publishableKey:r,fetcher:n=fetch})=>({async push(o){let s=o.map(Qo),a=await n(`${t.replace(/\/$/,"")}/v1/sites/${encodeURIComponent(e)}/tools`,{method:"PUT",headers:{authorization:`Bearer ${r}`,"content-type":"application/json"},body:JSON.stringify({registry:{tools:s}})});if(!a.ok)throw new Error(`Tool sync failed with status ${a.status}.`);return s.length}});var Bt=(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,o=()=>{let a=r.get(n);return a?.enables?[n,...a.enables]:[n]},s=(a,c)=>{let i=n;if(!r.has(a))throw new Error(`Cannot transition to unknown stage "${a}".`);return a===n?{changed:false,from:i,to:a}:(n=a,e.onTrace?.({type:"tool.progressed",metadata:{from:i,to:a,trigger:c}}),{changed:true,from:i,to:a})};return {current:()=>n,enabledStages:()=>o(),notify(a){let i=r.get(n)?.transitions?.find(u=>u.on===a);return i?s(i.to,a):{changed:false,from:n,to:n}},set(a){return s(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:o()})}};var es=(t,e)=>{let r=t.authz?.minTrust;return r?e?z[e.trust]<z[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"}},ts=(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"},Vt=(t,e)=>{let r=es(t,e.identity);if(!r.ok)return {tool:t,visible:false,reason:r.reason};let n=ts(t,e.identity);if(!n.ok)return {tool:t,visible:false,reason:n.reason};let o=rs(t,e);return o.ok?t.authz?.decision==="deny"?{tool:t,visible:false,reason:"authz-deny"}:{tool:t,visible:true,reason:"visible"}:{tool:t,visible:false,reason:o.reason}},Ut=(t,e)=>t.filter(r=>Vt(r,e).visible),zt=(t,e)=>t.map(r=>Vt(r,e));var Gt="default",Zt=t=>{let e=new Map;for(let r of t){let n=r.group??Gt,o=e.get(n)??[];o.push(r),e.set(n,o);}return [...e.entries()].sort(([r],[n])=>r.localeCompare(n)).map(([r,n])=>({name:r,tools:n}))},ns=t=>[...new Set(t.map(e=>e.group??Gt))].sort();var Ft=t=>t===null||typeof t!="object"?JSON.stringify(t):Array.isArray(t)?`[${t.map(Ft).join(",")}]`:`{${Object.keys(t).sort().map(r=>`${JSON.stringify(r)}:${Ft(t[r])}`).join(",")}}`,Br=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=Ft(e).length;return {name:t.name,characters:r,tokens:Math.ceil(r/4)}},Kt=t=>{let e=t.map(Br);return {total:e.reduce((n,o)=>n+o.tokens,0),perTool:e}};var Vr=t=>{if(t.provider)return t.provider;let r=(t.doc?.defaultView??(typeof globalThis<"u"?globalThis:null))?.navigator?.modelContext;return !r||typeof r.provideContext!="function"?null:r},os=(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},Ht=(t={})=>{let e=t.invoke??(async(n,o)=>n.execute(o,{identity:null})),r=null;return {publish(n){let o=Vr(t);return o?(r?.revoke(),r=o.provideContext({tools:n.map(s=>os(s,e))}),{revoked:true}):{revoked:false}},revoke(){r?.revoke(),r=null;},available:()=>!!Vr(t)}};var at=(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 Ur=(t,e)=>t===void 0?e:Math.max(0,Math.min(1,t)),Jt=(t={})=>{let e=Ur(t.traceRate,1),r=Ur(t.errorRate,1),n=t.random??Math.random;return {shouldKeep(o){let s=o.outcome==="error"?r:e;return n()<s}}};var ss="[REDACTED]",as=t=>{if(t!==void 0)return JSON.parse(JSON.stringify(t))},qt=(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 s of t)qt(s,e);return}let o=t;if(r in o){if(n.length===0){o[r]=ss;return}qt(o[r],n);}},Yt=(t,e=[])=>{if(e.length===0)return t;let r=as(t);for(let n of e)qt(r,n.split(".").filter(Boolean));return r},Xt=["metadata.password","metadata.token","metadata.authorization","metadata.cookie"];var is=()=>typeof location<"u"&&typeof location.pathname=="string"?location.pathname:void 0,zr=t=>{let e=globalThis.crypto;return e&&"randomUUID"in e?`${t}_${e.randomUUID()}`:`${t}_${Date.now().toString(36)}_${Math.random().toString(36).slice(2)}`},it=({siteId:t,bufferSize:e,sessionId:r=zr("ses"),scrubPaths:n=Xt,exporters:o=[],onExporterError:s,pageProvider:a=is,...c})=>{let i=at(e),u=Jt(c),p=()=>{try{return a()}catch{return}};return {sessionId:r,async emit(h){let _={...h.metadata};if(_.page===void 0){let E=p();E!==void 0&&(_.page=E);}let I=xt.parse(Yt({id:zr("trc"),siteId:t,sessionId:r,occurredAt:new Date().toISOString(),outcome:h.outcome??"success",...h,metadata:_},n));return u.shouldKeep(I)?(i.add(I),await Promise.all(o.map(async E=>{try{await E.export([I]);}catch(b){s?.(b,E,I);}})),I):null},list:()=>i.list(),clear:()=>i.clear()}};var ct=()=>({name:"console",export(t){for(let e of t)console.info("[agentronics:trace]",e.type,e);}});var lt=({gatewayUrl:t,publishableKey:e,fetcher:r=fetch})=>({name:"gateway",async export(n){let o={publishableKey:e,events:n};await r(`${t.replace(/\/$/,"")}/v1/traces`,{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${e}`},body:JSON.stringify(o)});}});var cs=t=>new Promise(e=>setTimeout(e,t)),ut=({url:t,fetcher:e=fetch,maxRetries:r=2,queueLimit:n=500})=>({name:"webhook",async export(o){let a=[...ls(t),...o].slice(-n),c=0;for(;;){let i=await e(t,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({events:a})});if(i.ok){Gr(t,[]);return}if(c>=r)throw Gr(t,a),new Error(`Webhook exporter failed with status ${i.status}.`);c+=1,await cs(100*c);}}}),Qt=t=>`agtx:webhook:${t}`,ls=t=>{if(typeof window>"u"||!window.localStorage)return [];try{let e=window.localStorage.getItem(Qt(t));return e?JSON.parse(e):[]}catch{return []}},Gr=(t,e)=>{if(!(typeof window>"u"||!window.localStorage))try{if(e.length===0){window.localStorage.removeItem(Qt(t));return}window.localStorage.setItem(Qt(t),JSON.stringify(e));}catch{}};var Zr="/v1/sdk/events",Fr=({url:t,ingestKey:e,fetcher:r=fetch})=>{let n=t.replace(/\/$/,""),o=n.endsWith(Zr)?n:`${n}${Zr}`;return {name:"intel",async export(s){let a={events:s},c=await r(o,{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${e}`},body:JSON.stringify(a)});if(!c.ok)throw new Error(`Intel exporter failed with status ${c.status}.`)}}};var Kr="https://gateway.agentronics.dev",us=t=>{if(t===void 0)return Kr;if(t===Kr)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}`)},Hr=t=>{let{publishableKey:e,siteId:r="default",debug:n=false,policies:o=[],trace:s={}}=t,a=us(t.gatewayUrl),c=mr(e);if(c==="secret")throw new Ge("wrong_key_kind","A secret key was passed to Agentronics.init(). Browser code must use a publishable key (agtx_pk_*).");if(c!=="publishable")throw new Ge("invalid_api_key",`Agentronics.init() expected a key starting with "${De}".`);let i=s.enabled??true,u=[...n?[ct()]:[],...s.gateway?[lt({gatewayUrl:a,publishableKey:e})]:[],...s.webhookUrl?[ut({url:s.webhookUrl})]:[],...s.exporters??[]],p={siteId:r,exporters:i?u:[],onExporterError:(f,T)=>{n&&console.warn(`[agentronics] trace exporter "${T.name}" failed`,f);}};s.bufferSize!==void 0&&(p.bufferSize=s.bufferSize),s.traceRate!==void 0&&(p.traceRate=s.traceRate),s.errorRate!==void 0&&(p.errorRate=s.errorRate),s.scrubPaths!==void 0&&(p.scrubPaths=s.scrubPaths);let h=it(p),_=f=>{i&&h.emit(f);},I=kt(),E={onTrace:_};t.auth!==void 0&&(E.context=t.auth);let b=St(E),C=At(),R=Ct(o),re=Et({gatewayUrl:a,siteId:r,publishableKey:e}),ne=Pt({onTrace:_}),we={onTrace:_};t.siteMemory!==void 0&&(we.initial=t.siteMemory);let V=jt(we),ke=Nt({gatewayUrl:a,siteId:r,publishableKey:e}),Jr=Wr({gatewayUrl:a,siteId:r,publishableKey:e}),Ze=async f=>{let T=Date.now(),O=await Qe(f),D=I.preferOver(O);return i&&await h.emit({type:D?"agent.detected":"agent.missed",agent:D,durationMs:Date.now()-T,metadata:{detectedClass:O?.class??null,presented:I.snapshot()!==null}}),C.set(D,"detect"),D},er=async(f,T={})=>{let O=Date.now(),D=T.identity!==void 0?T.identity:await Ze(),pt=R.evaluate({tool:f,identity:D});return i&&await h.emit({type:"authz.evaluated",tool:f,agent:D,policy:pt,outcome:pt.decision==="deny"?"blocked":"success",durationMs:Date.now()-O}),pt},oe=Wt({evaluate:er,setPolicies:f=>R.set(f),listPolicies:()=>R.list(),onTrace:_,identityResolver:()=>C.snapshot().identity});for(let f of t.tools??[])oe.register(f);let Te=t.progression?Bt(t.progression,{onTrace:_}):null,tr=f=>{let T={identity:f};return Te&&(T.stage=Te.current(),T.enabledStages=Te.enabledStages()),T},Se=f=>Ut(oe.list(),tr(f)),rr=f=>{if(!Te)return;Te.notify(f).changed&&Le.publish(Se(C.snapshot().identity));},qr={class:"webmcp",trust:"detected",confidence:1,vendor:null,userAgent:typeof navigator<"u"?navigator.userAgent:null,detectionVersion:A,signals:{source:"navigator.modelContext"}},Le=Ht({invoke:async(f,T)=>{let O=C.snapshot().identity??qr,D=await oe.execute(f.name,T,O);return rr(f.name),D}});C.subscribe(f=>{Le.available()&&Le.publish(Se(f.identity));});let dt=t.autoDetect??true,Yr=dt===false?Promise.resolve(null):(async()=>{let f=dt===true?{}:dt;try{return await Ze(f)}catch(T){return n&&console.warn("[agentronics] autoDetect failed:",T),null}})();return Object.freeze({publishableKey:e,siteId:r,gatewayUrl:a,debug:n,memory:ne,siteMemory:V,memoryCache:ke,tracer:h,auth:b,agentContext:C,authz:R,policyCache:re,tools:oe,progression:Te,webmcp:Le,ready:Yr,detect:Ze,authenticate:async f=>{let T=await b.authenticate(f);return C.set(T,"authenticate"),T},presentIdentity:f=>{let T=I.present(f);return _({type:"auth.identity_presented",agent:T.identity,metadata:{vendor:T.identity.vendor,class:T.identity.class}}),C.set(T.identity,"declare"),T},clearIdentity:()=>{I.clear(),_({type:"auth.identity_cleared"}),C.set(null,"cleared");},presentedIdentity:()=>I.snapshot(),setPolicies:f=>{R.set(f),_({type:"authz.policies_set",metadata:{count:f.length}});},listPolicies:()=>R.list(),syncPolicies:async()=>{let f=await re.sync();return R.set(f.policies),_({type:"authz.policies_set",metadata:{count:f.policies.length,synced:true}}),f.policies},syncSiteMemory:async()=>{let f=await ke.sync();return f.memory&&(V.replace(f.memory),_({type:"memory.updated",metadata:{kind:"site",operation:"sync",etag:f.etag}})),f.memory},provideSiteMemory:f=>V.provide(f),provideForPage:f=>{V.provideForPage(f);},installMemoryDelivery:({metaTags:f=true,overlay:T=false}={})=>{let O=[];return f&&O.push(nt({snapshot:V.snapshot()})),T&&O.push(ot({snapshot:V.snapshot()})),{uninstall:()=>{O.forEach(D=>D.uninstall());}}},fetchWellKnown:async f=>{let T={};f!==void 0&&(T.origin=f);let O=await st(T);return O&&(V.replace(O),_({type:"memory.updated",metadata:{kind:"site",operation:"wellKnown",origin:f??null}})),O},installDomEnforcer:()=>Mt({policyEngine:R,getIdentity:()=>Ze({webmcp:{pollMs:0}})}),registerTool:f=>oe.register(f),syncTools:async()=>{let f=oe.list({includeDisabled:true}),T=await Jr.push(f);return _({type:"tool.registered",metadata:{operation:"sync",count:T}}),T},surfaceTools:({identity:f=null}={})=>Se(f),explainSurfacing:({identity:f=null}={})=>zt(oe.list(),tr(f)),groupedTools:({identity:f=null}={})=>Zt(Se(f)),estimateTokens:({identity:f=null}={})=>Kt(Se(f)),publishToWebMcp:({identity:f=null}={})=>{let T=Se(f),O=Le.publish(T);return T.forEach(D=>{_({type:"tool.surfaced",tool:D.name,metadata:{state:"published",trust:f?.trust??null,group:D.group??null}});}),{revoked:O.revoked,surfaced:T.length}},notifyToolInvoked:f=>rr(f),evaluate:er,traces:()=>h.list(),clearTraces:()=>h.clear(),async ping(){try{let f=await fetch(`${a.replace(/\/$/,"")}/v1/health`,{method:"GET",headers:{authorization:`Bearer ${e}`}});if(!f.ok)return {ok:!1,status:f.status,error:`gateway returned ${f.status}`};let T=await f.json().catch(()=>null)??{};return {ok:!0,status:f.status,body:T}}catch(f){return {ok:false,status:0,error:f instanceof Error?f.message:String(f)}}}})};var tl={init:Hr,declareAgent:wt,detectAgent:Qe},rl="0.1.0";
|
|
16
|
-
exports.Agentronics=
|
|
15
|
+
`,Lr=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}`},ot=({doc:t=typeof document>"u"?null:document,snapshot:e,hidden:r=false})=>{if(!t)return {uninstall:()=>{},refresh:()=>{}};let n=t.getElementById($r);return n||(n=t.createElement("div"),n.id=$r,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",es(r)),n.textContent=Lr(e),{uninstall:()=>{n?.remove();},refresh:o=>{n&&(n.textContent=Lr(o));}}};var Lt="/.well-known/agent-context.json",st=async({origin:t,fetcher:e=fetch,signal:r}={})=>{let n=(t?t.replace(/\/$/,""):typeof window<"u"?window.location.origin:"")+Lt;if(!n.startsWith("http"))return null;let o={headers:{accept:"application/json"}};r!==void 0&&(o.signal=r);let s=await e(n,o);if(!s.ok){if(s.status===404)return null;throw new Error(`well-known agent-context fetch failed with status ${s.status}.`)}let a=await s.json();return $.parse(a)},Wr=({snapshot:t})=>JSON.stringify($.parse(t));var Wt=({evaluate:t,setPolicies:e,listPolicies:r,onTrace:n,identityResolver:o})=>{let s=new Map,a=new Set,i=c=>{if(!c.authz||!e||!r)return;let u={id:`tool:${c.name}`,tool:c.name,...c.authz,rateLimit:c.rateLimit??c.authz.rateLimit};e([...r().filter(p=>p.id!==u.id),u]);};return {register(c){return s.set(c.name,c),a.delete(c.name),i(c),n?.({type:"tool.registered",tool:c.name,metadata:{version:c.version??null,group:c.group??null,stage:c.stage??null}}),()=>{s.delete(c.name),a.delete(c.name);}},unregister(c){s.delete(c),a.delete(c);},enable(c){!s.has(c)||!a.has(c)||(a.delete(c),n?.({type:"tool.surfaced",tool:c,metadata:{state:"enabled"}}));},disable(c){!s.has(c)||a.has(c)||(a.add(c),n?.({type:"tool.surfaced",tool:c,metadata:{state:"disabled"}}));},isEnabled:c=>s.has(c)&&!a.has(c),list({includeDisabled:c=false}={}){let u=[...s.values()];return c?u:u.filter(p=>!a.has(p.name))},get:c=>s.get(c),async execute(c,u,p){let h=p===void 0?o?.()??null:p,w=s.get(c);if(!w)throw new Error(`Tool "${c}" is not registered.`);if(a.has(c)){let b={decision:"deny",ruleId:`tool:${c}`,reason:"Tool is disabled."};throw n?.({type:"tool.executed",tool:c,agent:h,policy:b,outcome:"blocked"}),new Error(b.reason)}let I=await t(c,{identity:h});if(I.decision==="deny")throw n?.({type:"tool.executed",tool:c,agent:h,policy:I,outcome:"blocked"}),new Error(I.reason);let E=Date.now();try{let b=await w.execute(u,{identity:h});return n?.({type:"tool.executed",tool:c,agent:h,policy:I,outcome:"success",durationMs:Date.now()-E}),b}catch(b){throw n?.({type:"tool.executed",tool:c,agent:h,policy:I,outcome:"error",durationMs:Date.now()-E,error:b instanceof Error?b.message:String(b)}),b}}}};var Bt=t=>{let e={name:t.name,description:t.description??"",inputSchema:t.inputSchema??{},tokens:0};return t.group&&(e.group=t.group),t.stage&&(e.page=t.stage),t.outputSchema&&(e.outputSchema=t.outputSchema),e.tokens=Math.ceil(JSON.stringify({name:e.name,description:e.description,inputSchema:e.inputSchema,...e.outputSchema?{outputSchema:e.outputSchema}:{}}).length/4),e},Br=({gatewayUrl:t,siteId:e,publishableKey:r,fetcher:n=fetch})=>({async push(o){let s=o.map(Bt),a=await n(`${t.replace(/\/$/,"")}/v1/sites/${encodeURIComponent(e)}/tools`,{method:"PUT",headers:{authorization:`Bearer ${r}`,"content-type":"application/json"},body:JSON.stringify({registry:{tools:s}})});if(!a.ok)throw new Error(`Tool sync failed with status ${a.status}.`);return s.length}});var Vt=(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,o=()=>{let a=r.get(n);return a?.enables?[n,...a.enables]:[n]},s=(a,i)=>{let c=n;if(!r.has(a))throw new Error(`Cannot transition to unknown stage "${a}".`);return a===n?{changed:false,from:c,to:a}:(n=a,e.onTrace?.({type:"tool.progressed",metadata:{from:c,to:a,trigger:i}}),{changed:true,from:c,to:a})};return {current:()=>n,enabledStages:()=>o(),notify(a){let c=r.get(n)?.transitions?.find(u=>u.on===a);return c?s(c.to,a):{changed:false,from:n,to:n}},set(a){return s(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:o()})}};var ts=(t,e)=>{let r=t.authz?.minTrust;return r?e?G[e.trust]<G[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"}},rs=(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("|")}`}},ns=(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"},Ut=(t,e)=>{let r=ts(t,e.identity);if(!r.ok)return {tool:t,visible:false,reason:r.reason};let n=rs(t,e.identity);if(!n.ok)return {tool:t,visible:false,reason:n.reason};let o=ns(t,e);return o.ok?t.authz?.decision==="deny"?{tool:t,visible:false,reason:"authz-deny"}:{tool:t,visible:true,reason:"visible"}:{tool:t,visible:false,reason:o.reason}},Gt=(t,e)=>t.filter(r=>Ut(r,e).visible),zt=(t,e)=>t.map(r=>Ut(r,e));var Zt="default",Ft=t=>{let e=new Map;for(let r of t){let n=r.group??Zt,o=e.get(n)??[];o.push(r),e.set(n,o);}return [...e.entries()].sort(([r],[n])=>r.localeCompare(n)).map(([r,n])=>({name:r,tools:n}))},os=t=>[...new Set(t.map(e=>e.group??Zt))].sort();var Kt=t=>t===null||typeof t!="object"?JSON.stringify(t):Array.isArray(t)?`[${t.map(Kt).join(",")}]`:`{${Object.keys(t).sort().map(r=>`${JSON.stringify(r)}:${Kt(t[r])}`).join(",")}}`,Vr=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=Kt(e).length;return {name:t.name,characters:r,tokens:Math.ceil(r/4)}},Ht=t=>{let e=t.map(Vr);return {total:e.reduce((n,o)=>n+o.tokens,0),perTool:e}};var Ur=t=>{if(t.provider)return t.provider;let r=(t.doc?.defaultView??(typeof globalThis<"u"?globalThis:null))?.navigator?.modelContext;return !r||typeof r.provideContext!="function"?null:r},ss=(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},Jt=(t={})=>{let e=t.invoke??(async(n,o)=>n.execute(o,{identity:null})),r=null;return {publish(n){let o=Ur(t);return o?(r?.revoke(),r=o.provideContext({tools:n.map(s=>ss(s,e))}),{revoked:true}):{revoked:false}},revoke(){r?.revoke(),r=null;},available:()=>!!Ur(t)}};var at=(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 Gr=(t,e)=>t===void 0?e:Math.max(0,Math.min(1,t)),qt=(t={})=>{let e=Gr(t.traceRate,1),r=Gr(t.errorRate,1),n=t.random??Math.random;return {shouldKeep(o){let s=o.outcome==="error"?r:e;return n()<s}}};var as="[REDACTED]",is=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 s of t)Yt(s,e);return}let o=t;if(r in o){if(n.length===0){o[r]=as;return}Yt(o[r],n);}},Xt=(t,e=[])=>{if(e.length===0)return t;let r=is(t);for(let n of e)Yt(r,n.split(".").filter(Boolean));return r},Qt=["metadata.password","metadata.token","metadata.authorization","metadata.cookie"];var cs=()=>typeof location<"u"&&typeof location.pathname=="string"?location.pathname:void 0,zr=t=>{let e=globalThis.crypto;return e&&"randomUUID"in e?`${t}_${e.randomUUID()}`:`${t}_${Date.now().toString(36)}_${Math.random().toString(36).slice(2)}`},it=({siteId:t,bufferSize:e,sessionId:r=zr("ses"),scrubPaths:n=Qt,exporters:o=[],onExporterError:s,pageProvider:a=cs,...i})=>{let c=at(e),u=qt(i),p=()=>{try{return a()}catch{return}};return {sessionId:r,async emit(h){let w={...h.metadata};if(w.page===void 0){let E=p();E!==void 0&&(w.page=E);}let I=xt.parse(Xt({id:zr("trc"),siteId:t,sessionId:r,occurredAt:new Date().toISOString(),outcome:h.outcome??"success",...h,metadata:w},n));return u.shouldKeep(I)?(c.add(I),await Promise.all(o.map(async E=>{try{await E.export([I]);}catch(b){s?.(b,E,I);}})),I):null},list:()=>c.list(),clear:()=>c.clear()}};var ct=()=>({name:"console",export(t){for(let e of t)console.info("[agentronics:trace]",e.type,e);}});var lt=({gatewayUrl:t,publishableKey:e,fetcher:r=fetch})=>({name:"gateway",async export(n){let o={publishableKey:e,events:n};await r(`${t.replace(/\/$/,"")}/v1/traces`,{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${e}`},body:JSON.stringify(o)});}});var ls=t=>new Promise(e=>setTimeout(e,t)),ut=({url:t,fetcher:e=fetch,maxRetries:r=2,queueLimit:n=500})=>({name:"webhook",async export(o){let a=[...us(t),...o].slice(-n),i=0;for(;;){let c=await e(t,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({events:a})});if(c.ok){Zr(t,[]);return}if(i>=r)throw Zr(t,a),new Error(`Webhook exporter failed with status ${c.status}.`);i+=1,await ls(100*i);}}}),er=t=>`agtx:webhook:${t}`,us=t=>{if(typeof window>"u"||!window.localStorage)return [];try{let e=window.localStorage.getItem(er(t));return e?JSON.parse(e):[]}catch{return []}},Zr=(t,e)=>{if(!(typeof window>"u"||!window.localStorage))try{if(e.length===0){window.localStorage.removeItem(er(t));return}window.localStorage.setItem(er(t),JSON.stringify(e));}catch{}};var Fr="/v1/sdk/events",Kr=({url:t,ingestKey:e,fetcher:r=fetch})=>{let n=t.replace(/\/$/,""),o=n.endsWith(Fr)?n:`${n}${Fr}`;return {name:"intel",async export(s){let a={events:s},i=await r(o,{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${e}`},body:JSON.stringify(a)});if(!i.ok)throw new Error(`Intel exporter failed with status ${i.status}.`)}}},Hr=({url:t,ingestKey:e,siteId:r,fetcher:n=fetch})=>{let o=t.replace(/\/$/,""),s=async(a,i)=>{let c=await n(`${o}${a}`,{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${e}`},body:JSON.stringify(i)});if(!c.ok)throw new Error(`Intel sync ${a} failed with status ${c.status}.`)};return {async pushTools(a){let i=a.map(Bt);return await s("/v1/sdk/tools",{siteId:r,tools:i}),i.length},async pushMemory(a,i){await s("/v1/sdk/memory",{siteId:r,snapshot:a,...typeof i=="number"?{score:i}:{}});}}};var Jr="https://gateway.agentronics.dev",ds=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}`)},qr=t=>{let{publishableKey:e,siteId:r="default",debug:n=false,policies:o=[],trace:s={}}=t,a=ds(t.gatewayUrl),i=yr(e);if(i==="secret")throw new ze("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 ze("invalid_api_key",`Agentronics.init() expected a key starting with "${De}".`);let c=s.enabled??true,u=[...n?[ct()]:[],...s.gateway?[lt({gatewayUrl:a,publishableKey:e})]:[],...s.webhookUrl?[ut({url:s.webhookUrl})]:[],...s.exporters??[]],p={siteId:r,exporters:c?u:[],onExporterError:(f,T)=>{n&&console.warn(`[agentronics] trace exporter "${T.name}" failed`,f);}};s.bufferSize!==void 0&&(p.bufferSize=s.bufferSize),s.traceRate!==void 0&&(p.traceRate=s.traceRate),s.errorRate!==void 0&&(p.errorRate=s.errorRate),s.scrubPaths!==void 0&&(p.scrubPaths=s.scrubPaths);let h=it(p),w=f=>{c&&h.emit(f);},I=kt(),E={onTrace:w};t.auth!==void 0&&(E.context=t.auth);let b=St(E),C=At(),R=Ct(o),re=Et({gatewayUrl:a,siteId:r,publishableKey:e}),ne=Pt({onTrace:w}),_e={onTrace:w};t.siteMemory!==void 0&&(_e.initial=t.siteMemory);let V=jt(_e),ke=Nt({gatewayUrl:a,siteId:r,publishableKey:e}),Yr=Br({gatewayUrl:a,siteId:r,publishableKey:e}),Ze=async f=>{let T=Date.now(),O=await Qe(f),D=I.preferOver(O);return c&&await h.emit({type:D?"agent.detected":"agent.missed",agent:D,durationMs:Date.now()-T,metadata:{detectedClass:O?.class??null,presented:I.snapshot()!==null}}),C.set(D,"detect"),D},tr=async(f,T={})=>{let O=Date.now(),D=T.identity!==void 0?T.identity:await Ze(),pt=R.evaluate({tool:f,identity:D});return c&&await h.emit({type:"authz.evaluated",tool:f,agent:D,policy:pt,outcome:pt.decision==="deny"?"blocked":"success",durationMs:Date.now()-O}),pt},oe=Wt({evaluate:tr,setPolicies:f=>R.set(f),listPolicies:()=>R.list(),onTrace:w,identityResolver:()=>C.snapshot().identity});for(let f of t.tools??[])oe.register(f);let Te=t.progression?Vt(t.progression,{onTrace:w}):null,rr=f=>{let T={identity:f};return Te&&(T.stage=Te.current(),T.enabledStages=Te.enabledStages()),T},Se=f=>Gt(oe.list(),rr(f)),nr=f=>{if(!Te)return;Te.notify(f).changed&&Le.publish(Se(C.snapshot().identity));},Xr={class:"webmcp",trust:"detected",confidence:1,vendor:null,userAgent:typeof navigator<"u"?navigator.userAgent:null,detectionVersion:A,signals:{source:"navigator.modelContext"}},Le=Jt({invoke:async(f,T)=>{let O=C.snapshot().identity??Xr,D=await oe.execute(f.name,T,O);return nr(f.name),D}});C.subscribe(f=>{Le.available()&&Le.publish(Se(f.identity));});let dt=t.autoDetect??true,Qr=dt===false?Promise.resolve(null):(async()=>{let f=dt===true?{}:dt;try{return await Ze(f)}catch(T){return n&&console.warn("[agentronics] autoDetect failed:",T),null}})();return Object.freeze({publishableKey:e,siteId:r,gatewayUrl:a,debug:n,memory:ne,siteMemory:V,memoryCache:ke,tracer:h,auth:b,agentContext:C,authz:R,policyCache:re,tools:oe,progression:Te,webmcp:Le,ready:Qr,detect:Ze,authenticate:async f=>{let T=await b.authenticate(f);return C.set(T,"authenticate"),T},presentIdentity:f=>{let T=I.present(f);return w({type:"auth.identity_presented",agent:T.identity,metadata:{vendor:T.identity.vendor,class:T.identity.class}}),C.set(T.identity,"declare"),T},clearIdentity:()=>{I.clear(),w({type:"auth.identity_cleared"}),C.set(null,"cleared");},presentedIdentity:()=>I.snapshot(),setPolicies:f=>{R.set(f),w({type:"authz.policies_set",metadata:{count:f.length}});},listPolicies:()=>R.list(),syncPolicies:async()=>{let f=await re.sync();return R.set(f.policies),w({type:"authz.policies_set",metadata:{count:f.policies.length,synced:true}}),f.policies},syncSiteMemory:async()=>{let f=await ke.sync();return f.memory&&(V.replace(f.memory),w({type:"memory.updated",metadata:{kind:"site",operation:"sync",etag:f.etag}})),f.memory},provideSiteMemory:f=>V.provide(f),provideForPage:f=>{V.provideForPage(f);},installMemoryDelivery:({metaTags:f=true,overlay:T=false}={})=>{let O=[];return f&&O.push(nt({snapshot:V.snapshot()})),T&&O.push(ot({snapshot:V.snapshot()})),{uninstall:()=>{O.forEach(D=>D.uninstall());}}},fetchWellKnown:async f=>{let T={};f!==void 0&&(T.origin=f);let O=await st(T);return O&&(V.replace(O),w({type:"memory.updated",metadata:{kind:"site",operation:"wellKnown",origin:f??null}})),O},installDomEnforcer:()=>Mt({policyEngine:R,getIdentity:()=>Ze({webmcp:{pollMs:0}})}),registerTool:f=>oe.register(f),syncTools:async()=>{let f=oe.list({includeDisabled:true}),T=await Yr.push(f);return w({type:"tool.registered",metadata:{operation:"sync",count:T}}),T},surfaceTools:({identity:f=null}={})=>Se(f),explainSurfacing:({identity:f=null}={})=>zt(oe.list(),rr(f)),groupedTools:({identity:f=null}={})=>Ft(Se(f)),estimateTokens:({identity:f=null}={})=>Ht(Se(f)),publishToWebMcp:({identity:f=null}={})=>{let T=Se(f),O=Le.publish(T);return T.forEach(D=>{w({type:"tool.surfaced",tool:D.name,metadata:{state:"published",trust:f?.trust??null,group:D.group??null}});}),{revoked:O.revoked,surfaced:T.length}},notifyToolInvoked:f=>nr(f),evaluate:tr,traces:()=>h.list(),clearTraces:()=>h.clear(),async ping(){try{let f=await fetch(`${a.replace(/\/$/,"")}/v1/health`,{method:"GET",headers:{authorization:`Bearer ${e}`}});if(!f.ok)return {ok:!1,status:f.status,error:`gateway returned ${f.status}`};let T=await f.json().catch(()=>null)??{};return {ok:!0,status:f.status,body:T}}catch(f){return {ok:false,status:0,error:f instanceof Error?f.message:String(f)}}}})};var nl={init:qr,declareAgent:_t,detectAgent:Qe},ol="0.1.0";
|
|
16
|
+
exports.Agentronics=nl;exports.CRAWLER_SIGNATURES=bt;exports.DEFAULT_GROUP=Zt;exports.VERSION=ol;exports.WELL_KNOWN_PATH=Lt;exports.bundledDetectors=wt;exports.createAgentContextStore=At;exports.createAuthEngine=St;exports.createConsoleExporter=ct;exports.createDetectorRegistry=Xe;exports.createGatewayExporter=lt;exports.createIdentityStore=kt;exports.createIntelExporter=Kr;exports.createIntelSync=Hr;exports.createMemoryCache=Nt;exports.createMemoryStore=Pt;exports.createPolicyCache=Et;exports.createPolicyEngine=Ct;exports.createProgressionStore=Vt;exports.createRateLimiter=It;exports.createSignatureLoader=xr;exports.createSiteMemoryStore=jt;exports.createToolRegistry=Wt;exports.createTraceBuffer=at;exports.createTracer=it;exports.createWebMcpAdapter=Jt;exports.createWebMcpContextTool=Nr;exports.createWebhookExporter=ut;exports.decideSurfacing=Ut;exports.declareAgent=_t;exports.deriveTrustLevel=Wo;exports.detectAgent=Qe;exports.detectCrawler=Ne;exports.detectDom=$e;exports.detectWebMcp=je;exports.estimateBudget=Ht;exports.estimateToolTokens=Vr;exports.explainSurfacing=zt;exports.fetchWellKnownContext=st;exports.groupTools=Ft;exports.highestTrust=Tt;exports.init=qr;exports.installDomEnforcer=Mt;exports.installMemoryOverlay=ot;exports.installMetaTags=nt;exports.listGroupNames=os;exports.serializeWellKnownContext=Wr;exports.showDenyOverlay=Rt;exports.surfaceTools=Gt;return exports;})({});//# sourceMappingURL=index.global.js.map
|
|
17
17
|
//# sourceMappingURL=index.global.js.map
|