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