@pi-oxide/extension-js 0.5.0 → 0.6.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/content-script.js +2 -2
- package/index.js +2536 -2947
- package/package.json +1 -1
package/content-script.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(){"use strict";function Ce(t){return t==null?{}:t instanceof Map?Object.fromEntries([...t.entries()].map(([e,r])=>[e,Ce(r)])):Array.isArray(t)?t.map(Ce):t}function _t(t,e){const r=t?"refId":null,n=t||(e==null?void 0:e.label)||"";return{message:`Element not found${r?` by ${r} "${n}"`:""}`,code:"E_STALE",category:"resource",hint:"RefIds are ephemeral. They are assigned at snapshot time and invalidated when the DOM is replaced (navigation, SPA rerender, autocomplete).",recovery:["const d = await page.snapshot_data(); find the target in d.nodes","Use a fresh refId from that snapshot only","Do not reuse refIds from before press/click/navigation"],details:{staleRefId:t||void 0}}}function kt(t,e,r){return{message:`${t} on ${e} returned no effect.`,code:"E_NOT_INTERACTABLE",category:"resource",hint:"Some sites ignore programmatic value assignment; value may not appear in snapshot_data.",recovery:[`await page.click({ refId: ${JSON.stringify(e)} }) then await page.type({ refId: ${JSON.stringify(e)}, text: "..." })`,'Or await page.press({ key: "Enter" }) after fill',"Re-snapshot and confirm URL or node state changed"],details:{refId:e,...r}}}function wt(t){return t.includes("Could not establish connection")||t.includes("Receiving end does not exist")||t.includes("Timeout waiting for content-script ping")||t.includes("content script not available")}function Ae(t){const e=new Error(t.message);throw e.code=t.code,t.category&&(e.category=t.category),t.hint&&(e.hint=t.hint),t.recovery&&(e.recovery=t.recovery),t.details&&(e.details=t.details),e}function xt(t,e){let r=`Element not found by label "${t}"`;if(e!=null&&e.length){const n=e.map(a=>a.name||a.refId).filter(Boolean).slice(0,5);r+=n.length>0?`. Candidates: ${n.join(", ")}`:". Candidates: none"}return{message:r,code:"E_NOT_FOUND",category:"resource",hint:"No element matched this label. Check candidates or snapshot for visible controls.",recovery:["const d = await page.snapshot_data(); find the target in d.nodes","Try a more specific label or use refId from snapshot"],details:e!=null&&e.length?{label:t,candidates:e}:{label:t}}}function It(t,e){if(typeof t=="object"&&t!==null&&"code"in t&&typeof t.code=="string"&&"message"in t&&typeof t.message=="string"){const n=t;return n.hint||n.recovery||n.code==="E_CONTENT_SCRIPT"&&(e==null?void 0:e.tabId)!=null,n}const r=(t instanceof Error?t.message:String(t))||"";return wt(r)?{message:"Content script is not connected on this tab.",code:"E_CONTENT_SCRIPT",category:"content-script",hint:"page.snapshot() uses script injection and can succeed even when fill/click cannot. This tab was likely open before the extension loaded (MV3 does not retro-inject).",recovery:[`await page.goto(${JSON.stringify("")})`,"Or ask the user to refresh the target tab, then retry fill/click"]}:r.includes("permission")||r.includes("Permission")?{message:r,code:"E_PERMISSION",category:"permission"}:r.includes("not found")||r.includes("No tab")||r.includes("No active tab")?{message:r,code:"E_NOT_FOUND",category:"resource"}:{message:r,code:"E_EXTENSION",category:"extension"}}var S;(function(t){t.assertEqual=a=>{};function e(a){}t.assertIs=e;function r(a){throw new Error}t.assertNever=r,t.arrayToEnum=a=>{const i={};for(const s of a)i[s]=s;return i},t.getValidEnumValues=a=>{const i=t.objectKeys(a).filter(o=>typeof a[a[o]]!="number"),s={};for(const o of i)s[o]=a[o];return t.objectValues(s)},t.objectValues=a=>t.objectKeys(a).map(function(i){return a[i]}),t.objectKeys=typeof Object.keys=="function"?a=>Object.keys(a):a=>{const i=[];for(const s in a)Object.prototype.hasOwnProperty.call(a,s)&&i.push(s);return i},t.find=(a,i)=>{for(const s of a)if(i(s))return s},t.isInteger=typeof Number.isInteger=="function"?a=>Number.isInteger(a):a=>typeof a=="number"&&Number.isFinite(a)&&Math.floor(a)===a;function n(a,i=" | "){return a.map(s=>typeof s=="string"?`'${s}'`:s).join(i)}t.joinValues=n,t.jsonStringifyReplacer=(a,i)=>typeof i=="bigint"?i.toString():i})(S||(S={}));var Qe;(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(Qe||(Qe={}));const m=S.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),ee=t=>{switch(typeof t){case"undefined":return m.undefined;case"string":return m.string;case"number":return Number.isNaN(t)?m.nan:m.number;case"boolean":return m.boolean;case"function":return m.function;case"bigint":return m.bigint;case"symbol":return m.symbol;case"object":return Array.isArray(t)?m.array:t===null?m.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?m.promise:typeof Map<"u"&&t instanceof Map?m.map:typeof Set<"u"&&t instanceof Set?m.set:typeof Date<"u"&&t instanceof Date?m.date:m.object;default:return m.unknown}},u=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"]);class L 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]};const r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}format(e){const r=e||function(i){return i.message},n={_errors:[]},a=i=>{for(const s of i.issues)if(s.code==="invalid_union")s.unionErrors.map(a);else if(s.code==="invalid_return_type")a(s.returnTypeError);else if(s.code==="invalid_arguments")a(s.argumentsError);else if(s.path.length===0)n._errors.push(r(s));else{let o=n,l=0;for(;l<s.path.length;){const f=s.path[l];l===s.path.length-1?(o[f]=o[f]||{_errors:[]},o[f]._errors.push(r(s))):o[f]=o[f]||{_errors:[]},o=o[f],l++}}};return a(this),n}static assert(e){if(!(e instanceof L))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){const r={},n=[];for(const a of this.issues)if(a.path.length>0){const i=a.path[0];r[i]=r[i]||[],r[i].push(e(a))}else n.push(e(a));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}}L.create=t=>new L(t);const me=(t,e)=>{let r;switch(t.code){case u.invalid_type:t.received===m.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case u.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,S.jsonStringifyReplacer)}`;break;case u.unrecognized_keys:r=`Unrecognized key(s) in object: ${S.joinValues(t.keys,", ")}`;break;case u.invalid_union:r="Invalid input";break;case u.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${S.joinValues(t.options)}`;break;case u.invalid_enum_value:r=`Invalid enum value. Expected ${S.joinValues(t.options)}, received '${t.received}'`;break;case u.invalid_arguments:r="Invalid function arguments";break;case u.invalid_return_type:r="Invalid function return type";break;case u.invalid_date:r="Invalid date";break;case u.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 u.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 u.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 u.custom:r="Invalid input";break;case u.invalid_intersection_types:r="Intersection results could not be merged";break;case u.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case u.not_finite:r="Number must be finite";break;default:r=e.defaultError,S.assertNever(t)}return{message:r}};let Tt=me;function Le(){return Tt}const qe=t=>{const{data:e,path:r,errorMaps:n,issueData:a}=t,i=[...r,...a.path||[]],s={...a,path:i};if(a.message!==void 0)return{...a,path:i,message:a.message};let o="";const l=n.filter(f=>!!f).slice().reverse();for(const f of l)o=f(s,{data:e,defaultError:o}).message;return{...a,path:i,message:o}};function h(t,e){const r=Le(),n=qe({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===me?void 0:me].filter(a=>!!a)});t.common.issues.push(n)}class P{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,r){const n=[];for(const a of r){if(a.status==="aborted")return _;a.status==="dirty"&&e.dirty(),n.push(a.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,r){const n=[];for(const a of r){const i=await a.key,s=await a.value;n.push({key:i,value:s})}return P.mergeObjectSync(e,n)}static mergeObjectSync(e,r){const n={};for(const a of r){const{key:i,value:s}=a;if(i.status==="aborted"||s.status==="aborted")return _;i.status==="dirty"&&e.dirty(),s.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof s.value<"u"||a.alwaysSet)&&(n[i.value]=s.value)}return{status:e.value,value:n}}}const _=Object.freeze({status:"aborted"}),be=t=>({status:"dirty",value:t}),j=t=>({status:"valid",value:t}),et=t=>t.status==="aborted",tt=t=>t.status==="dirty",le=t=>t.status==="valid",Ne=t=>typeof Promise<"u"&&t instanceof Promise;var b;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(b||(b={}));class B{constructor(e,r,n,a){this._cachedPath=[],this.parent=e,this.data=r,this._path=n,this._key=a}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}}const rt=(t,e)=>{if(le(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const r=new L(t.common.issues);return this._error=r,this._error}}};function w(t){if(!t)return{};const{errorMap:e,invalid_type_error:r,required_error:n,description:a}=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:a}:{errorMap:(s,o)=>{const{message:l}=t;return s.code==="invalid_enum_value"?{message:l??o.defaultError}:typeof o.data>"u"?{message:l??n??o.defaultError}:s.code!=="invalid_type"?{message:o.defaultError}:{message:l??r??o.defaultError}},description:a}}class T{get description(){return this._def.description}_getType(e){return ee(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:ee(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new P,ctx:{common:e.parent.common,data:e.data,parsedType:ee(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const r=this._parse(e);if(Ne(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(e){const r=this._parse(e);return Promise.resolve(r)}parse(e,r){const n=this.safeParse(e,r);if(n.success)return n.data;throw n.error}safeParse(e,r){const n={common:{issues:[],async:(r==null?void 0:r.async)??!1,contextualErrorMap:r==null?void 0:r.errorMap},path:(r==null?void 0:r.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ee(e)},a=this._parseSync({data:e,path:n.path,parent:n});return rt(n,a)}"~validate"(e){var n,a;const r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ee(e)};if(!this["~standard"].async)try{const i=this._parseSync({data:e,path:[],parent:r});return le(i)?{value:i.value}:{issues:r.common.issues}}catch(i){(a=(n=i==null?void 0:i.message)==null?void 0:n.toLowerCase())!=null&&a.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:r}).then(i=>le(i)?{value:i.value}:{issues:r.common.issues})}async parseAsync(e,r){const n=await this.safeParseAsync(e,r);if(n.success)return n.data;throw n.error}async safeParseAsync(e,r){const n={common:{issues:[],contextualErrorMap:r==null?void 0:r.errorMap,async:!0},path:(r==null?void 0:r.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ee(e)},a=this._parse({data:e,path:n.path,parent:n}),i=await(Ne(a)?a:Promise.resolve(a));return rt(n,i)}refine(e,r){const n=a=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(a):r;return this._refinement((a,i)=>{const s=e(a),o=()=>i.addIssue({code:u.custom,...n(a)});return typeof Promise<"u"&&s instanceof Promise?s.then(l=>l?!0:(o(),!1)):s?!0:(o(),!1)})}refinement(e,r){return this._refinement((n,a)=>e(n)?!0:(a.addIssue(typeof r=="function"?r(n,a):r),!1))}_refinement(e){return new K({schema:this,typeName:k.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 V.create(this,this._def)}nullable(){return ne.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Z.create(this)}promise(){return pe.create(this,this._def)}or(e){return ve.create([this,e],this._def)}and(e){return _e.create(this,e,this._def)}transform(e){return new K({...w(this._def),schema:this,typeName:k.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const r=typeof e=="function"?e:()=>e;return new Ie({...w(this._def),innerType:this,defaultValue:r,typeName:k.ZodDefault})}brand(){return new Ke({typeName:k.ZodBranded,type:this,...w(this._def)})}catch(e){const r=typeof e=="function"?e:()=>e;return new Te({...w(this._def),innerType:this,catchValue:r,typeName:k.ZodCatch})}describe(e){const r=this.constructor;return new r({...this._def,description:e})}pipe(e){return Me.create(this,e)}readonly(){return Se.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const St=/^c[^\s-]{8,}$/i,Et=/^[0-9a-z]+$/,Ct=/^[0-9A-HJKMNP-TV-Z]{26}$/i,At=/^[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,Nt=/^[a-z0-9_-]{21}$/i,Ot=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Rt=/^[-+]?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)?)??$/,Dt=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Mt="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Ze;const Pt=/^(?:(?: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])$/,jt=/^(?:(?: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])$/,$t=/^(([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]))$/,Lt=/^(([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])$/,qt=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Zt=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nt="((\\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])))",Vt=new RegExp(`^${nt}$`);function at(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);const r=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${r}`}function Bt(t){return new RegExp(`^${at(t)}$`)}function Ut(t){let e=`${nt}T${at(t)}`;const r=[];return r.push(t.local?"Z?":"Z"),t.offset&&r.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${r.join("|")})`,new RegExp(`^${e}$`)}function Wt(t,e){return!!((e==="v4"||!e)&&Pt.test(t)||(e==="v6"||!e)&&$t.test(t))}function Ft(t,e){if(!Ot.test(t))return!1;try{const[r]=t.split(".");if(!r)return!1;const n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),a=JSON.parse(atob(n));return!(typeof a!="object"||a===null||"typ"in a&&(a==null?void 0:a.typ)!=="JWT"||!a.alg||e&&a.alg!==e)}catch{return!1}}function zt(t,e){return!!((e==="v4"||!e)&&jt.test(t)||(e==="v6"||!e)&&Lt.test(t))}class U extends T{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==m.string){const i=this._getOrReturnCtx(e);return h(i,{code:u.invalid_type,expected:m.string,received:i.parsedType}),_}const n=new P;let a;for(const i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(a=this._getOrReturnCtx(e,a),h(a,{code:u.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="max")e.data.length>i.value&&(a=this._getOrReturnCtx(e,a),h(a,{code:u.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="length"){const s=e.data.length>i.value,o=e.data.length<i.value;(s||o)&&(a=this._getOrReturnCtx(e,a),s?h(a,{code:u.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):o&&h(a,{code:u.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),n.dirty())}else if(i.kind==="email")Dt.test(e.data)||(a=this._getOrReturnCtx(e,a),h(a,{validation:"email",code:u.invalid_string,message:i.message}),n.dirty());else if(i.kind==="emoji")Ze||(Ze=new RegExp(Mt,"u")),Ze.test(e.data)||(a=this._getOrReturnCtx(e,a),h(a,{validation:"emoji",code:u.invalid_string,message:i.message}),n.dirty());else if(i.kind==="uuid")At.test(e.data)||(a=this._getOrReturnCtx(e,a),h(a,{validation:"uuid",code:u.invalid_string,message:i.message}),n.dirty());else if(i.kind==="nanoid")Nt.test(e.data)||(a=this._getOrReturnCtx(e,a),h(a,{validation:"nanoid",code:u.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid")St.test(e.data)||(a=this._getOrReturnCtx(e,a),h(a,{validation:"cuid",code:u.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid2")Et.test(e.data)||(a=this._getOrReturnCtx(e,a),h(a,{validation:"cuid2",code:u.invalid_string,message:i.message}),n.dirty());else if(i.kind==="ulid")Ct.test(e.data)||(a=this._getOrReturnCtx(e,a),h(a,{validation:"ulid",code:u.invalid_string,message:i.message}),n.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{a=this._getOrReturnCtx(e,a),h(a,{validation:"url",code:u.invalid_string,message:i.message}),n.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(a=this._getOrReturnCtx(e,a),h(a,{validation:"regex",code:u.invalid_string,message:i.message}),n.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(a=this._getOrReturnCtx(e,a),h(a,{code:u.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),n.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(a=this._getOrReturnCtx(e,a),h(a,{code:u.invalid_string,validation:{startsWith:i.value},message:i.message}),n.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(a=this._getOrReturnCtx(e,a),h(a,{code:u.invalid_string,validation:{endsWith:i.value},message:i.message}),n.dirty()):i.kind==="datetime"?Ut(i).test(e.data)||(a=this._getOrReturnCtx(e,a),h(a,{code:u.invalid_string,validation:"datetime",message:i.message}),n.dirty()):i.kind==="date"?Vt.test(e.data)||(a=this._getOrReturnCtx(e,a),h(a,{code:u.invalid_string,validation:"date",message:i.message}),n.dirty()):i.kind==="time"?Bt(i).test(e.data)||(a=this._getOrReturnCtx(e,a),h(a,{code:u.invalid_string,validation:"time",message:i.message}),n.dirty()):i.kind==="duration"?Rt.test(e.data)||(a=this._getOrReturnCtx(e,a),h(a,{validation:"duration",code:u.invalid_string,message:i.message}),n.dirty()):i.kind==="ip"?Wt(e.data,i.version)||(a=this._getOrReturnCtx(e,a),h(a,{validation:"ip",code:u.invalid_string,message:i.message}),n.dirty()):i.kind==="jwt"?Ft(e.data,i.alg)||(a=this._getOrReturnCtx(e,a),h(a,{validation:"jwt",code:u.invalid_string,message:i.message}),n.dirty()):i.kind==="cidr"?zt(e.data,i.version)||(a=this._getOrReturnCtx(e,a),h(a,{validation:"cidr",code:u.invalid_string,message:i.message}),n.dirty()):i.kind==="base64"?qt.test(e.data)||(a=this._getOrReturnCtx(e,a),h(a,{validation:"base64",code:u.invalid_string,message:i.message}),n.dirty()):i.kind==="base64url"?Zt.test(e.data)||(a=this._getOrReturnCtx(e,a),h(a,{validation:"base64url",code:u.invalid_string,message:i.message}),n.dirty()):S.assertNever(i);return{status:n.value,value:e.data}}_regex(e,r,n){return this.refinement(a=>e.test(a),{validation:r,code:u.invalid_string,...b.errToObj(n)})}_addCheck(e){return new U({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...b.errToObj(e)})}url(e){return this._addCheck({kind:"url",...b.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...b.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...b.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...b.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...b.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...b.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...b.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...b.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...b.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...b.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...b.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...b.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(e==null?void 0:e.offset)??!1,local:(e==null?void 0:e.local)??!1,...b.errToObj(e==null?void 0: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==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...b.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...b.errToObj(e)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...b.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r==null?void 0:r.position,...b.errToObj(r==null?void 0:r.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...b.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...b.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...b.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...b.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...b.errToObj(r)})}nonempty(e){return this.min(1,b.errToObj(e))}trim(){return new U({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new U({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new U({...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(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}}U.create=t=>new U({checks:[],typeName:k.ZodString,coerce:(t==null?void 0:t.coerce)??!1,...w(t)});function Ht(t,e){const r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,a=r>n?r:n,i=Number.parseInt(t.toFixed(a).replace(".","")),s=Number.parseInt(e.toFixed(a).replace(".",""));return i%s/10**a}class ae extends T{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)!==m.number){const i=this._getOrReturnCtx(e);return h(i,{code:u.invalid_type,expected:m.number,received:i.parsedType}),_}let n;const a=new P;for(const i of this._def.checks)i.kind==="int"?S.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),h(n,{code:u.invalid_type,expected:"integer",received:"float",message:i.message}),a.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(n=this._getOrReturnCtx(e,n),h(n,{code:u.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),a.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(n=this._getOrReturnCtx(e,n),h(n,{code:u.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),a.dirty()):i.kind==="multipleOf"?Ht(e.data,i.value)!==0&&(n=this._getOrReturnCtx(e,n),h(n,{code:u.not_multiple_of,multipleOf:i.value,message:i.message}),a.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),h(n,{code:u.not_finite,message:i.message}),a.dirty()):S.assertNever(i);return{status:a.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,b.toString(r))}gt(e,r){return this.setLimit("min",e,!1,b.toString(r))}lte(e,r){return this.setLimit("max",e,!0,b.toString(r))}lt(e,r){return this.setLimit("max",e,!1,b.toString(r))}setLimit(e,r,n,a){return new ae({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:b.toString(a)}]})}_addCheck(e){return new ae({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:b.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:b.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:b.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:b.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:b.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:b.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:b.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:b.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:b.toString(e)})}get minValue(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(const 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(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;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:k.ZodNumber,coerce:(t==null?void 0:t.coerce)||!1,...w(t)});class ie extends T{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)!==m.bigint)return this._getInvalidInput(e);let n;const a=new P;for(const i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(n=this._getOrReturnCtx(e,n),h(n,{code:u.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),a.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(n=this._getOrReturnCtx(e,n),h(n,{code:u.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),a.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),h(n,{code:u.not_multiple_of,multipleOf:i.value,message:i.message}),a.dirty()):S.assertNever(i);return{status:a.value,value:e.data}}_getInvalidInput(e){const r=this._getOrReturnCtx(e);return h(r,{code:u.invalid_type,expected:m.bigint,received:r.parsedType}),_}gte(e,r){return this.setLimit("min",e,!0,b.toString(r))}gt(e,r){return this.setLimit("min",e,!1,b.toString(r))}lte(e,r){return this.setLimit("max",e,!0,b.toString(r))}lt(e,r){return this.setLimit("max",e,!1,b.toString(r))}setLimit(e,r,n,a){return new ie({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:b.toString(a)}]})}_addCheck(e){return new ie({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:b.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:b.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:b.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:b.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:b.toString(r)})}get minValue(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(const 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:k.ZodBigInt,coerce:(t==null?void 0:t.coerce)??!1,...w(t)});class Oe extends T{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==m.boolean){const n=this._getOrReturnCtx(e);return h(n,{code:u.invalid_type,expected:m.boolean,received:n.parsedType}),_}return j(e.data)}}Oe.create=t=>new Oe({typeName:k.ZodBoolean,coerce:(t==null?void 0:t.coerce)||!1,...w(t)});class ge extends T{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==m.date){const i=this._getOrReturnCtx(e);return h(i,{code:u.invalid_type,expected:m.date,received:i.parsedType}),_}if(Number.isNaN(e.data.getTime())){const i=this._getOrReturnCtx(e);return h(i,{code:u.invalid_date}),_}const n=new P;let a;for(const i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(a=this._getOrReturnCtx(e,a),h(a,{code:u.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),n.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(a=this._getOrReturnCtx(e,a),h(a,{code:u.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),n.dirty()):S.assertNever(i);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new ge({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:b.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:b.toString(r)})}get minDate(){let e=null;for(const 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(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e!=null?new Date(e):null}}ge.create=t=>new ge({checks:[],coerce:(t==null?void 0:t.coerce)||!1,typeName:k.ZodDate,...w(t)});class it extends T{_parse(e){if(this._getType(e)!==m.symbol){const n=this._getOrReturnCtx(e);return h(n,{code:u.invalid_type,expected:m.symbol,received:n.parsedType}),_}return j(e.data)}}it.create=t=>new it({typeName:k.ZodSymbol,...w(t)});class Re extends T{_parse(e){if(this._getType(e)!==m.undefined){const n=this._getOrReturnCtx(e);return h(n,{code:u.invalid_type,expected:m.undefined,received:n.parsedType}),_}return j(e.data)}}Re.create=t=>new Re({typeName:k.ZodUndefined,...w(t)});class ye extends T{_parse(e){if(this._getType(e)!==m.null){const n=this._getOrReturnCtx(e);return h(n,{code:u.invalid_type,expected:m.null,received:n.parsedType}),_}return j(e.data)}}ye.create=t=>new ye({typeName:k.ZodNull,...w(t)});class Ve extends T{constructor(){super(...arguments),this._any=!0}_parse(e){return j(e.data)}}Ve.create=t=>new Ve({typeName:k.ZodAny,...w(t)});class se extends T{constructor(){super(...arguments),this._unknown=!0}_parse(e){return j(e.data)}}se.create=t=>new se({typeName:k.ZodUnknown,...w(t)});class te extends T{_parse(e){const r=this._getOrReturnCtx(e);return h(r,{code:u.invalid_type,expected:m.never,received:r.parsedType}),_}}te.create=t=>new te({typeName:k.ZodNever,...w(t)});class Be extends T{_parse(e){if(this._getType(e)!==m.undefined){const n=this._getOrReturnCtx(e);return h(n,{code:u.invalid_type,expected:m.void,received:n.parsedType}),_}return j(e.data)}}Be.create=t=>new Be({typeName:k.ZodVoid,...w(t)});class Z extends T{_parse(e){const{ctx:r,status:n}=this._processInputParams(e),a=this._def;if(r.parsedType!==m.array)return h(r,{code:u.invalid_type,expected:m.array,received:r.parsedType}),_;if(a.exactLength!==null){const s=r.data.length>a.exactLength.value,o=r.data.length<a.exactLength.value;(s||o)&&(h(r,{code:s?u.too_big:u.too_small,minimum:o?a.exactLength.value:void 0,maximum:s?a.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:a.exactLength.message}),n.dirty())}if(a.minLength!==null&&r.data.length<a.minLength.value&&(h(r,{code:u.too_small,minimum:a.minLength.value,type:"array",inclusive:!0,exact:!1,message:a.minLength.message}),n.dirty()),a.maxLength!==null&&r.data.length>a.maxLength.value&&(h(r,{code:u.too_big,maximum:a.maxLength.value,type:"array",inclusive:!0,exact:!1,message:a.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((s,o)=>a.type._parseAsync(new B(r,s,r.path,o)))).then(s=>P.mergeArray(n,s));const i=[...r.data].map((s,o)=>a.type._parseSync(new B(r,s,r.path,o)));return P.mergeArray(n,i)}get element(){return this._def.type}min(e,r){return new Z({...this._def,minLength:{value:e,message:b.toString(r)}})}max(e,r){return new Z({...this._def,maxLength:{value:e,message:b.toString(r)}})}length(e,r){return new Z({...this._def,exactLength:{value:e,message:b.toString(r)}})}nonempty(e){return this.min(1,e)}}Z.create=(t,e)=>new Z({type:t,minLength:null,maxLength:null,exactLength:null,typeName:k.ZodArray,...w(e)});function ue(t){if(t instanceof O){const e={};for(const r in t.shape){const n=t.shape[r];e[r]=V.create(ue(n))}return new O({...t._def,shape:()=>e})}else return t instanceof Z?new Z({...t._def,type:ue(t.element)}):t instanceof V?V.create(ue(t.unwrap())):t instanceof ne?ne.create(ue(t.unwrap())):t instanceof W?W.create(t.items.map(e=>ue(e))):t}class O extends T{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),r=S.objectKeys(e);return this._cached={shape:e,keys:r},this._cached}_parse(e){if(this._getType(e)!==m.object){const f=this._getOrReturnCtx(e);return h(f,{code:u.invalid_type,expected:m.object,received:f.parsedType}),_}const{status:n,ctx:a}=this._processInputParams(e),{shape:i,keys:s}=this._getCached(),o=[];if(!(this._def.catchall instanceof te&&this._def.unknownKeys==="strip"))for(const f in a.data)s.includes(f)||o.push(f);const l=[];for(const f of s){const v=i[f],E=a.data[f];l.push({key:{status:"valid",value:f},value:v._parse(new B(a,E,a.path,f)),alwaysSet:f in a.data})}if(this._def.catchall instanceof te){const f=this._def.unknownKeys;if(f==="passthrough")for(const v of o)l.push({key:{status:"valid",value:v},value:{status:"valid",value:a.data[v]}});else if(f==="strict")o.length>0&&(h(a,{code:u.unrecognized_keys,keys:o}),n.dirty());else if(f!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const f=this._def.catchall;for(const v of o){const E=a.data[v];l.push({key:{status:"valid",value:v},value:f._parse(new B(a,E,a.path,v)),alwaysSet:v in a.data})}}return a.common.async?Promise.resolve().then(async()=>{const f=[];for(const v of l){const E=await v.key,$=await v.value;f.push({key:E,value:$,alwaysSet:v.alwaysSet})}return f}).then(f=>P.mergeObjectSync(n,f)):P.mergeObjectSync(n,l)}get shape(){return this._def.shape()}strict(e){return b.errToObj,new O({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(r,n)=>{var i,s;const a=((s=(i=this._def).errorMap)==null?void 0:s.call(i,r,n).message)??n.defaultError;return r.code==="unrecognized_keys"?{message:b.errToObj(e).message??a}:{message:a}}}:{}})}strip(){return new O({...this._def,unknownKeys:"strip"})}passthrough(){return new O({...this._def,unknownKeys:"passthrough"})}extend(e){return new O({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new O({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:k.ZodObject})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new O({...this._def,catchall:e})}pick(e){const r={};for(const n of S.objectKeys(e))e[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new O({...this._def,shape:()=>r})}omit(e){const r={};for(const n of S.objectKeys(this.shape))e[n]||(r[n]=this.shape[n]);return new O({...this._def,shape:()=>r})}deepPartial(){return ue(this)}partial(e){const r={};for(const n of S.objectKeys(this.shape)){const a=this.shape[n];e&&!e[n]?r[n]=a:r[n]=a.optional()}return new O({...this._def,shape:()=>r})}required(e){const r={};for(const n of S.objectKeys(this.shape))if(e&&!e[n])r[n]=this.shape[n];else{let i=this.shape[n];for(;i instanceof V;)i=i._def.innerType;r[n]=i}return new O({...this._def,shape:()=>r})}keyof(){return st(S.objectKeys(this.shape))}}O.create=(t,e)=>new O({shape:()=>t,unknownKeys:"strip",catchall:te.create(),typeName:k.ZodObject,...w(e)}),O.strictCreate=(t,e)=>new O({shape:()=>t,unknownKeys:"strict",catchall:te.create(),typeName:k.ZodObject,...w(e)}),O.lazycreate=(t,e)=>new O({shape:t,unknownKeys:"strip",catchall:te.create(),typeName:k.ZodObject,...w(e)});class ve extends T{_parse(e){const{ctx:r}=this._processInputParams(e),n=this._def.options;function a(i){for(const o of i)if(o.result.status==="valid")return o.result;for(const o of i)if(o.result.status==="dirty")return r.common.issues.push(...o.ctx.common.issues),o.result;const s=i.map(o=>new L(o.ctx.common.issues));return h(r,{code:u.invalid_union,unionErrors:s}),_}if(r.common.async)return Promise.all(n.map(async i=>{const s={...r,common:{...r.common,issues:[]},parent:null};return{result:await i._parseAsync({data:r.data,path:r.path,parent:s}),ctx:s}})).then(a);{let i;const s=[];for(const l of n){const f={...r,common:{...r.common,issues:[]},parent:null},v=l._parseSync({data:r.data,path:r.path,parent:f});if(v.status==="valid")return v;v.status==="dirty"&&!i&&(i={result:v,ctx:f}),f.common.issues.length&&s.push(f.common.issues)}if(i)return r.common.issues.push(...i.ctx.common.issues),i.result;const o=s.map(l=>new L(l));return h(r,{code:u.invalid_union,unionErrors:o}),_}}get options(){return this._def.options}}ve.create=(t,e)=>new ve({options:t,typeName:k.ZodUnion,...w(e)});const H=t=>t instanceof De?H(t.schema):t instanceof K?H(t.innerType()):t instanceof xe?[t.value]:t instanceof re?t.options:t instanceof ze?S.objectValues(t.enum):t instanceof Ie?H(t._def.innerType):t instanceof Re?[void 0]:t instanceof ye?[null]:t instanceof V?[void 0,...H(t.unwrap())]:t instanceof ne?[null,...H(t.unwrap())]:t instanceof Ke||t instanceof Se?H(t.unwrap()):t instanceof Te?H(t._def.innerType):[];class Ue extends T{_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==m.object)return h(r,{code:u.invalid_type,expected:m.object,received:r.parsedType}),_;const n=this.discriminator,a=r.data[n],i=this.optionsMap.get(a);return i?r.common.async?i._parseAsync({data:r.data,path:r.path,parent:r}):i._parseSync({data:r.data,path:r.path,parent:r}):(h(r,{code:u.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),_)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,n){const a=new Map;for(const i of r){const s=H(i.shape[e]);if(!s.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of s){if(a.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);a.set(o,i)}}return new Ue({typeName:k.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:a,...w(n)})}}function We(t,e){const r=ee(t),n=ee(e);if(t===e)return{valid:!0,data:t};if(r===m.object&&n===m.object){const a=S.objectKeys(e),i=S.objectKeys(t).filter(o=>a.indexOf(o)!==-1),s={...t,...e};for(const o of i){const l=We(t[o],e[o]);if(!l.valid)return{valid:!1};s[o]=l.data}return{valid:!0,data:s}}else if(r===m.array&&n===m.array){if(t.length!==e.length)return{valid:!1};const a=[];for(let i=0;i<t.length;i++){const s=t[i],o=e[i],l=We(s,o);if(!l.valid)return{valid:!1};a.push(l.data)}return{valid:!0,data:a}}else return r===m.date&&n===m.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}class _e extends T{_parse(e){const{status:r,ctx:n}=this._processInputParams(e),a=(i,s)=>{if(et(i)||et(s))return _;const o=We(i.value,s.value);return o.valid?((tt(i)||tt(s))&&r.dirty(),{status:r.value,value:o.data}):(h(n,{code:u.invalid_intersection_types}),_)};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(([i,s])=>a(i,s)):a(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}_e.create=(t,e,r)=>new _e({left:t,right:e,typeName:k.ZodIntersection,...w(r)});class W extends T{_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==m.array)return h(n,{code:u.invalid_type,expected:m.array,received:n.parsedType}),_;if(n.data.length<this._def.items.length)return h(n,{code:u.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),_;!this._def.rest&&n.data.length>this._def.items.length&&(h(n,{code:u.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());const i=[...n.data].map((s,o)=>{const l=this._def.items[o]||this._def.rest;return l?l._parse(new B(n,s,n.path,o)):null}).filter(s=>!!s);return n.common.async?Promise.all(i).then(s=>P.mergeArray(r,s)):P.mergeArray(r,i)}get items(){return this._def.items}rest(e){return new W({...this._def,rest:e})}}W.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new W({items:t,typeName:k.ZodTuple,rest:null,...w(e)})};class ke extends T{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==m.object)return h(n,{code:u.invalid_type,expected:m.object,received:n.parsedType}),_;const a=[],i=this._def.keyType,s=this._def.valueType;for(const o in n.data)a.push({key:i._parse(new B(n,o,n.path,o)),value:s._parse(new B(n,n.data[o],n.path,o)),alwaysSet:o in n.data});return n.common.async?P.mergeObjectAsync(r,a):P.mergeObjectSync(r,a)}get element(){return this._def.valueType}static create(e,r,n){return r instanceof T?new ke({keyType:e,valueType:r,typeName:k.ZodRecord,...w(n)}):new ke({keyType:U.create(),valueType:e,typeName:k.ZodRecord,...w(r)})}}class Fe extends T{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==m.map)return h(n,{code:u.invalid_type,expected:m.map,received:n.parsedType}),_;const a=this._def.keyType,i=this._def.valueType,s=[...n.data.entries()].map(([o,l],f)=>({key:a._parse(new B(n,o,n.path,[f,"key"])),value:i._parse(new B(n,l,n.path,[f,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const l of s){const f=await l.key,v=await l.value;if(f.status==="aborted"||v.status==="aborted")return _;(f.status==="dirty"||v.status==="dirty")&&r.dirty(),o.set(f.value,v.value)}return{status:r.value,value:o}})}else{const o=new Map;for(const l of s){const f=l.key,v=l.value;if(f.status==="aborted"||v.status==="aborted")return _;(f.status==="dirty"||v.status==="dirty")&&r.dirty(),o.set(f.value,v.value)}return{status:r.value,value:o}}}}Fe.create=(t,e,r)=>new Fe({valueType:e,keyType:t,typeName:k.ZodMap,...w(r)});class fe extends T{_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==m.set)return h(n,{code:u.invalid_type,expected:m.set,received:n.parsedType}),_;const a=this._def;a.minSize!==null&&n.data.size<a.minSize.value&&(h(n,{code:u.too_small,minimum:a.minSize.value,type:"set",inclusive:!0,exact:!1,message:a.minSize.message}),r.dirty()),a.maxSize!==null&&n.data.size>a.maxSize.value&&(h(n,{code:u.too_big,maximum:a.maxSize.value,type:"set",inclusive:!0,exact:!1,message:a.maxSize.message}),r.dirty());const i=this._def.valueType;function s(l){const f=new Set;for(const v of l){if(v.status==="aborted")return _;v.status==="dirty"&&r.dirty(),f.add(v.value)}return{status:r.value,value:f}}const o=[...n.data.values()].map((l,f)=>i._parse(new B(n,l,n.path,f)));return n.common.async?Promise.all(o).then(l=>s(l)):s(o)}min(e,r){return new fe({...this._def,minSize:{value:e,message:b.toString(r)}})}max(e,r){return new fe({...this._def,maxSize:{value:e,message:b.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}}fe.create=(t,e)=>new fe({valueType:t,minSize:null,maxSize:null,typeName:k.ZodSet,...w(e)});class we extends T{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==m.function)return h(r,{code:u.invalid_type,expected:m.function,received:r.parsedType}),_;function n(o,l){return qe({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Le(),me].filter(f=>!!f),issueData:{code:u.invalid_arguments,argumentsError:l}})}function a(o,l){return qe({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Le(),me].filter(f=>!!f),issueData:{code:u.invalid_return_type,returnTypeError:l}})}const i={errorMap:r.common.contextualErrorMap},s=r.data;if(this._def.returns instanceof pe){const o=this;return j(async function(...l){const f=new L([]),v=await o._def.args.parseAsync(l,i).catch(z=>{throw f.addIssue(n(l,z)),f}),E=await Reflect.apply(s,this,v);return await o._def.returns._def.type.parseAsync(E,i).catch(z=>{throw f.addIssue(a(E,z)),f})})}else{const o=this;return j(function(...l){const f=o._def.args.safeParse(l,i);if(!f.success)throw new L([n(l,f.error)]);const v=Reflect.apply(s,this,f.data),E=o._def.returns.safeParse(v,i);if(!E.success)throw new L([a(v,E.error)]);return E.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new we({...this._def,args:W.create(e).rest(se.create())})}returns(e){return new we({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,r,n){return new we({args:e||W.create([]).rest(se.create()),returns:r||se.create(),typeName:k.ZodFunction,...w(n)})}}class De extends T{get schema(){return this._def.getter()}_parse(e){const{ctx:r}=this._processInputParams(e);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}}De.create=(t,e)=>new De({getter:t,typeName:k.ZodLazy,...w(e)});class xe extends T{_parse(e){if(e.data!==this._def.value){const r=this._getOrReturnCtx(e);return h(r,{received:r.data,code:u.invalid_literal,expected:this._def.value}),_}return{status:"valid",value:e.data}}get value(){return this._def.value}}xe.create=(t,e)=>new xe({value:t,typeName:k.ZodLiteral,...w(e)});function st(t,e){return new re({values:t,typeName:k.ZodEnum,...w(e)})}class re extends T{_parse(e){if(typeof e.data!="string"){const r=this._getOrReturnCtx(e),n=this._def.values;return h(r,{expected:S.joinValues(n),received:r.parsedType,code:u.invalid_type}),_}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const r=this._getOrReturnCtx(e),n=this._def.values;return h(r,{received:r.data,code:u.invalid_enum_value,options:n}),_}return j(e.data)}get options(){return this._def.values}get enum(){const e={};for(const r of this._def.values)e[r]=r;return e}get Values(){const e={};for(const r of this._def.values)e[r]=r;return e}get Enum(){const e={};for(const r of this._def.values)e[r]=r;return e}extract(e,r=this._def){return re.create(e,{...this._def,...r})}exclude(e,r=this._def){return re.create(this.options.filter(n=>!e.includes(n)),{...this._def,...r})}}re.create=st;class ze extends T{_parse(e){const r=S.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==m.string&&n.parsedType!==m.number){const a=S.objectValues(r);return h(n,{expected:S.joinValues(a),received:n.parsedType,code:u.invalid_type}),_}if(this._cache||(this._cache=new Set(S.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const a=S.objectValues(r);return h(n,{received:n.data,code:u.invalid_enum_value,options:a}),_}return j(e.data)}get enum(){return this._def.values}}ze.create=(t,e)=>new ze({values:t,typeName:k.ZodNativeEnum,...w(e)});class pe extends T{unwrap(){return this._def.type}_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==m.promise&&r.common.async===!1)return h(r,{code:u.invalid_type,expected:m.promise,received:r.parsedType}),_;const n=r.parsedType===m.promise?r.data:Promise.resolve(r.data);return j(n.then(a=>this._def.type.parseAsync(a,{path:r.path,errorMap:r.common.contextualErrorMap})))}}pe.create=(t,e)=>new pe({type:t,typeName:k.ZodPromise,...w(e)});class K extends T{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===k.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:r,ctx:n}=this._processInputParams(e),a=this._def.effect||null,i={addIssue:s=>{h(n,s),s.fatal?r.abort():r.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),a.type==="preprocess"){const s=a.transform(n.data,i);if(n.common.async)return Promise.resolve(s).then(async o=>{if(r.value==="aborted")return _;const l=await this._def.schema._parseAsync({data:o,path:n.path,parent:n});return l.status==="aborted"?_:l.status==="dirty"||r.value==="dirty"?be(l.value):l});{if(r.value==="aborted")return _;const o=this._def.schema._parseSync({data:s,path:n.path,parent:n});return o.status==="aborted"?_:o.status==="dirty"||r.value==="dirty"?be(o.value):o}}if(a.type==="refinement"){const s=o=>{const l=a.refinement(o,i);if(n.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?_:(o.status==="dirty"&&r.dirty(),s(o.value),{status:r.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?_:(o.status==="dirty"&&r.dirty(),s(o.value).then(()=>({status:r.value,value:o.value}))))}if(a.type==="transform")if(n.common.async===!1){const s=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!le(s))return _;const o=a.transform(s.value,i);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:o}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(s=>le(s)?Promise.resolve(a.transform(s.value,i)).then(o=>({status:r.value,value:o})):_);S.assertNever(a)}}K.create=(t,e,r)=>new K({schema:t,typeName:k.ZodEffects,effect:e,...w(r)}),K.createWithPreprocess=(t,e,r)=>new K({schema:e,effect:{type:"preprocess",transform:t},typeName:k.ZodEffects,...w(r)});class V extends T{_parse(e){return this._getType(e)===m.undefined?j(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}V.create=(t,e)=>new V({innerType:t,typeName:k.ZodOptional,...w(e)});class ne extends T{_parse(e){return this._getType(e)===m.null?j(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}ne.create=(t,e)=>new ne({innerType:t,typeName:k.ZodNullable,...w(e)});class Ie extends T{_parse(e){const{ctx:r}=this._processInputParams(e);let n=r.data;return r.parsedType===m.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}}Ie.create=(t,e)=>new Ie({innerType:t,typeName:k.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...w(e)});class Te extends T{_parse(e){const{ctx:r}=this._processInputParams(e),n={...r,common:{...r.common,issues:[]}},a=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Ne(a)?a.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new L(n.common.issues)},input:n.data})})):{status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new L(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}Te.create=(t,e)=>new Te({innerType:t,typeName:k.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...w(e)});class He extends T{_parse(e){if(this._getType(e)!==m.nan){const n=this._getOrReturnCtx(e);return h(n,{code:u.invalid_type,expected:m.nan,received:n.parsedType}),_}return{status:"valid",value:e.data}}}He.create=t=>new He({typeName:k.ZodNaN,...w(t)});class Ke extends T{_parse(e){const{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}}class Me extends T{_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const i=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?_:i.status==="dirty"?(r.dirty(),be(i.value)):this._def.out._parseAsync({data:i.value,path:n.path,parent:n})})();{const a=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?_:a.status==="dirty"?(r.dirty(),{status:"dirty",value:a.value}):this._def.out._parseSync({data:a.value,path:n.path,parent:n})}}static create(e,r){return new Me({in:e,out:r,typeName:k.ZodPipeline})}}class Se extends T{_parse(e){const r=this._def.innerType._parse(e),n=a=>(le(a)&&(a.value=Object.freeze(a.value)),a);return Ne(r)?r.then(a=>n(a)):n(r)}unwrap(){return this._def.innerType}}Se.create=(t,e)=>new Se({innerType:t,typeName:k.ZodReadonly,...w(e)});var k;(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"})(k||(k={}));const c=U.create,p=ae.create,F=ie.create,x=Oe.create,ot=ye.create,y=se.create;te.create;const N=Z.create,d=O.create,I=ve.create;_e.create;const Kt=W.create,g=ke.create,Gt=xe.create,ct=re.create;pe.create,V.create,ne.create;const G=K.createWithPreprocess;function R(t,e=0,r=2){if(e>r)return"...";if(t instanceof O){const n=t.shape,a=Object.keys(n).filter(s=>!s.startsWith("__"));return a.length===0?"{ }":e>=r-1?"{ ... }":`{ ${a.map(s=>{const o=n[s],l=o instanceof V,f=R(l?o.unwrap():o,e+1,r);return`${s}${l?"?":""}: ${f}`}).join(", ")} }`}if(t instanceof ve)return t.options.map(n=>R(n,e,r)).join(" or ");if(t instanceof U)return"string";if(t instanceof ae)return"number";if(t instanceof Oe)return"boolean";if(t instanceof ie)return"bigint";if(t instanceof ye)return"null";if(t instanceof Z){const n=R(t.element,e+1,r);return n==="unknown"||n==="any"?"array":`${n}[]`}if(t instanceof W)return`[${t.items.map(n=>R(n,e+1,r)).join(", ")}]`;if(t instanceof ke){const n=R(t._def.valueType,e+1,r);return n==="unknown"||n==="any"?"{ [key: string]: unknown }":`{ [key: string]: ${n} }`}return t instanceof V?`${R(t.unwrap(),e,r)}?`:t instanceof xe?JSON.stringify(t.value):t instanceof re?t.options.map(n=>`"${n}"`).join(" | "):t instanceof Ve?"any":t instanceof se?"unknown":t instanceof Be?"void":t instanceof Re?"undefined":t instanceof K?R(t.innerType(),e,r):t instanceof Ie?R(t.removeDefault(),e,r):t instanceof ne?`${R(t.unwrap(),e,r)} | null`:t instanceof De?"lazy":t instanceof pe?`Promise<${R(t.unwrap(),e+1,r)}>`:t instanceof we?"function":t instanceof ge?"Date":t instanceof Fe?"Map":t instanceof fe?"Set":t instanceof _e?`${R(t._def.left,e,r)} & ${R(t._def.right,e,r)}`:t instanceof Ue?t.options.map(n=>R(n,e,r)).join(" or "):t instanceof Ke?R(t.unwrap(),e,r):t instanceof He?"NaN":t instanceof Te?R(t.removeCatch(),e,r):t instanceof Me?R(t._def.in,e,r):t instanceof Se?`readonly ${R(t.unwrap(),e,r)}`:"unknown"}function Jt(t){return t===null?"null":t===void 0?"undefined":Array.isArray(t)?"array":typeof t}function Yt(t,e,r,n){const a=r.filter(o=>o.path.length===0),i=r.filter(o=>o.path.length>0);if(a.length>0&&i.length===0){const o=a.some(f=>f.code==="custom"),l=a.some(f=>f.code!=="invalid_type"&&f.code!=="invalid_literal"&&f.code!=="invalid_union");if(!o&&!l){const f=R(e),v=Jt(n);return`Invalid parameters for ${t}: expected ${f}${f==="{ }"?" or no args":""}, received ${v}`}}const s=r.map(o=>`at '${o.path.length>0?o.path.join("."):"root"}': ${o.message}`);return`Invalid parameters for ${t}: ${s.join("; ")}`}async function Xt(t,e,r,n,a){const i=t.safeParse(Ce(n));if(!i.success)return{ok:!1,error:{message:Yt(a,t,i.error.issues,n),code:"E_INVALID_PARAMS",category:"validation"}};try{const s=await r(i.data),o=e.safeParse(s);if(!o.success){const l=o.error.issues.map(f=>{const v=f.path.join(".");return`invalid return value${v?` at '${v}'`:""} (${f.message})`});return{ok:!1,error:{message:`Invalid return value for ${a}: ${l.join("; ")}`,code:"E_INVALID_RETURN",category:"validation"}}}return{ok:!0,value:o.data}}catch(s){const o=It(s),l=o.code==="E_EXTENSION"&&(typeof s!="object"||s===null||!("code"in s));return{ok:!1,error:{...o,code:l?"E_HANDLER":o.code,message:`${a}: ${o.message}`}}}}const dt=new Map,Pe=new Map;function Qt(t){dt.set(t.registryAction,t)}function Ge(t){return dt.get(t)}function er(t){for(const e of t)Qt(e);try{chrome.runtime.sendMessage({type:"contentScriptReady"})}catch{}}function tr(t){const e=Pe.get(t);return e?(e.abort(),Pe.delete(t),!0):!1}async function rr(t,e,r,n,a){const i=Ge(t);if(!i)return{ok:!1,error:{message:`No schema registered for content-script action: ${t}`,code:"E_INTERNAL"}};const s=new AbortController;a&&Pe.set(a,s);try{return await Xt(i.params,i.returns,async o=>r(o,s.signal),Ce(n),t)}finally{a&&Pe.delete(a)}}const q=()=>I([F(),p().finite()]).transform(t=>BigInt(t));d({key:c().describe("Storage key to retrieve")}),d({key:c().describe("Storage key to set"),value:c().describe("Value to store")}),d({key:c().describe("Storage key to delete")}),d({});const nr=d({items:g(c()).describe("Record of key-value string pairs to store")});G(t=>t!==null&&typeof t=="object"&&!Array.isArray(t)&&!("items"in t)?{items:t}:t,nr);const ar=d({keys:N(c()).describe("Array of storage keys to retrieve"),defaults:g(c()).optional().describe("Default string values for missing keys")});G(t=>Array.isArray(t)?{keys:t}:t,ar),d({});const ir=d({keys:N(c()).describe("Array of storage keys to delete")});G(t=>Array.isArray(t)?{keys:t}:t,ir),d({}),d({}),I([Kt([I([d({text:c()}),c()])]),d({text:c().optional(),value:c().optional()})]),d({url:c().describe("URL to fetch"),method:c().default("GET").describe("HTTP method (GET, POST, PUT, DELETE, etc.)"),headers:g(c()).default({}).describe("Request headers as key-value pairs"),body:c().nullable().default(null).describe("Request body string"),timeout:q().default(30000n).describe("Timeout in milliseconds")}),d({duration:q().describe("Duration to sleep in milliseconds")});const he=()=>c().regex(/^e\d+$/),sr='use { refId: "e2" } or { label: "..." } object form, not positional arguments',Je=(t,e)=>{if(t.__invalidPositional!==void 0){e.addIssue({code:u.custom,message:sr});return}!t.refId&&!t.label&&e.addIssue({code:u.custom,message:"Either refId or label is required"})},lt=(t,e)=>{t.x!==void 0||t.y!==void 0||Je(t,e)},D=t=>G(e=>typeof e=="string"||typeof e=="number"?{__invalidPositional:e}:e,d({__invalidPositional:I([c(),p()]).optional().describe("Internal flag for positional argument rejection"),refId:he().optional().describe("Element reference ID (e.g. e2)"),label:c().optional().describe("Human-readable element label"),...t}).superRefine(Je)),Ee={tabId:I([p(),F()]).optional().describe("Target tab ID")},oe=t=>G(e=>typeof e=="string"||typeof e=="number"?{__invalidPositional:e}:e,d({__invalidPositional:I([c(),p()]).optional().describe("Internal flag for positional argument rejection"),...Ee,refId:he().optional().describe("Element reference ID (e.g. e2)"),label:c().optional().describe("Human-readable element label"),...t}).superRefine(Je));d({}),d({}),d({url:c().describe("URL to navigate to"),timeout:q().optional().describe("Navigation timeout in milliseconds")});const or=d({});d({}),d({}),d({duration:q().default(1000n).describe("Duration to wait in milliseconds")});const cr=D(),dr=D({value:c().describe("Value to fill into the element")}),lr=D({text:c().describe("Text to type into the element")}),ur=D({text:c().describe("Text to append into the element")}),fr=d({key:c().describe("Key to press (e.g. Enter, Escape, ArrowDown)")}),pr=D({value:c().describe("Value to select in the dropdown")}),hr=D({checked:x().optional().describe("Desired checked state (true to check, false to uncheck)")}),mr=D(),br=d({}),gr=d({direction:c().default("down").describe("Scroll direction: up, down, left, or right"),amount:p().default(300).describe("Pixels to scroll")}),yr=G(t=>typeof t=="string"||typeof t=="number"?{__invalidPositional:t}:t,d({__invalidPositional:I([c(),p()]).optional().describe("Internal flag for positional argument rejection"),refId:he().optional().describe("Element reference ID (e.g. e2)"),label:c().optional().describe("Human-readable element label"),x:p().optional().describe("X coordinate to scroll to"),y:p().optional().describe("Y coordinate to scroll to")}).superRefine(lt)),vr=D();d({selector:c().describe("CSS selector to find elements")}),d({selector:c().describe("CSS selector to wait for"),timeout:q().default(30000n).describe("Timeout in milliseconds")});const _r=d({fields:N(c()).describe("Array of field names to extract")});G(t=>Array.isArray(t)?{fields:t}:t,_r),I([p(),N(d({}).passthrough()),d({}).passthrough()]),d({}),d({active:x().optional().describe("Whether the tabs are active"),currentWindow:x().optional().describe("Whether the tabs are in the current window"),url:c().optional().describe("URL pattern to match tabs against")}).passthrough(),G(t=>typeof t=="string"?{url:t}:t,d({url:c().optional().describe("URL to open in the new tab"),active:x().optional().describe("Whether to focus the new tab")})),I([p(),N(d({id:p().optional(),tabId:p().optional(),tab_id:p().optional()}).passthrough()),d({id:p().optional(),tabId:p().optional(),tab_id:p().optional()}).passthrough()]),d({tabId:I([p(),F()]).optional().describe("Target tab ID"),script:c().optional().describe("Script to execute")}).passthrough();const kr=oe(),wr=oe({value:c().describe("Value to fill into the element")}),xr=G(t=>typeof t=="string"||typeof t=="number"?{__invalidPositional:t}:t,d({__invalidPositional:I([c(),p()]).optional().describe("Internal flag for positional argument rejection"),...Ee,refId:he().optional().describe("Element reference ID (e.g. e2)"),label:c().optional().describe("Human-readable element label"),x:p().optional().describe("X coordinate to scroll to"),y:p().optional().describe("Y coordinate to scroll to")}).superRefine(lt)),Ir=oe({text:c().describe("Text to type into the element")}),Tr=d({...Ee,key:c().describe("Key to press (e.g. Enter, Escape, ArrowDown)")}),Sr=oe({value:c().describe("Value to select in the dropdown")}),Er=oe({checked:x().optional().describe("Desired checked state (true to check, false to uncheck)")}),Cr=oe(),Ar=d({...Ee}),Nr=d({...Ee,direction:c().default("down").describe("Scroll direction: up, down, left, or right"),amount:p().default(300).describe("Pixels to scroll")}),Or=oe();d({tabId:I([p(),F()]).optional().describe("Target tab ID"),script:c().optional().describe("Script to evaluate"),code:c().optional().describe("Alternative script code"),js:c().optional().describe("Alternative JS code")}).passthrough();const Rr=d({tabId:I([p(),F()]).optional().describe("Target tab ID")}).passthrough();d({tabId:I([p(),F()]).optional().describe("Target tab ID"),timeout:p().optional().describe("Timeout in milliseconds")}).passthrough(),d({tabId:I([p(),F()]).optional().describe("Target tab ID"),url:c().optional().describe("URL to fetch"),options:d({}).passthrough().optional().describe("Fetch options")}).passthrough(),d({tabId:I([p(),F()]).optional().describe("Target tab ID"),max_nodes:p().optional().describe("Maximum nodes to include"),options:d({}).passthrough().optional().describe("Snapshot options")}).passthrough(),d({tabId:I([p(),F()]).optional().describe("Target tab ID"),max_nodes:p().optional().describe("Maximum nodes to include"),options:d({}).passthrough().optional().describe("Snapshot options")}).passthrough(),d({tabId:I([p(),F()]).optional().describe("Target tab ID"),max_nodes:p().optional().describe("Maximum nodes to include"),options:d({}).passthrough().optional().describe("Snapshot options")}).passthrough(),D(),D(),D({value:c().optional().describe("Value to fill into the element")}),D({text:c().optional().describe("Text to type into the element")}),d({key:c().optional().describe("Key to press (e.g. Enter, Escape, ArrowDown)")}),D({value:c().optional().describe("Value to select in the dropdown")}),D({checked:x().optional().describe("Desired checked state (true to check, false to uncheck)")}),D(),d({}),d({direction:c().optional().describe("Scroll direction: up, down, left, or right"),amount:p().optional().describe("Pixels to scroll")}),D(),D({text:c().optional().describe("Text to append into the element")}),d({}),d({}),d({duration:q().default(1000n).describe("Duration to wait in milliseconds")}),d({interactive_only:x().default(!1).describe("Only include interactive elements"),max_nodes:q().default(500n).describe("Maximum number of nodes to include in snapshot")}),d({interactive_only:x().default(!1).describe("Only include interactive elements"),max_nodes:q().default(500n).describe("Maximum number of nodes to include in snapshot")}),d({interactive_only:x().default(!1).describe("Only include interactive elements"),max_nodes:q().default(500n).describe("Maximum number of nodes to include in snapshot")}),d({interactive_only:x().default(!1).describe("Only include interactive elements"),max_nodes:q().default(500n).describe("Maximum number of nodes to include in snapshot")}),d({snapshot:d({}).passthrough().describe("Raw DOM snapshot data to format"),format:c().optional().describe("Output format (e.g. markdown, html)")});const Dr=d({max_nodes:p().optional().describe("Maximum nodes to include"),options:d({}).passthrough().optional().describe("Snapshot options")}).passthrough();d({max_nodes:p().optional().describe("Maximum nodes to include"),options:d({}).passthrough().optional().describe("Snapshot options")}).passthrough(),d({max_nodes:p().optional().describe("Maximum nodes to include"),options:d({}).passthrough().optional().describe("Snapshot options")}).passthrough(),d({path:c().describe("File or directory path")}),d({from:c().describe("Source path"),to:c().describe("Destination path")}),d({path:c().describe("File path to write to"),data:c().describe("Data to write")}),d({path:c().describe("File path to read from"),offset:q().describe("Byte offset to start reading"),len:p().describe("Number of bytes to read")}),d({path:c().describe("File path to update"),offset:q().describe("Byte offset to start writing"),data:c().describe("Data to write")}),d({path:c().describe("File path to hash"),algo:c().default("sha256").describe("Hash algorithm (e.g. sha256, md5)")}),g(y()),g(y()),g(y()),g(y()),I([p(),g(y())]),I([p(),g(y())]),g(y()),g(y()),g(y()),I([c(),g(y())]),g(y()),g(y()),g(y()),g(y()),g(y()),I([c(),p(),g(y())]),g(y()),g(y()),g(y()),I([p(),g(y())]),g(y()),g(y()),g(y()),g(y()),g(y()),N(y()),I([c(),g(y())]),g(y()),I([c(),g(y())]),g(y()),I([c(),g(y())]),g(y()),I([c(),g(y())]),g(y()),g(y()),I([p(),g(y())]),g(y()),g(y()),I([p(),g(y())]),g(y()),I([c(),p(),g(y())]),g(y()),g(y()),g(y()),g(y()),I([p(),g(y())]),I([p(),g(y())]),I([p(),g(y())]),I([p(),g(y())]),I([p(),g(y())]),g(y()),g(y()),g(y()),d({action:c().describe("Host action name"),params:d({}).passthrough().optional().describe("Parameters for the host action")}).passthrough(),I([c(),p(),x(),ot(),N(y()),g(y())]);const C=d({ok:Gt(!0).describe("Whether the action succeeded"),action:c().describe("Action identifier (e.g. 'page_fill')"),refId:he().optional().describe("Element reference ID that was acted upon (e.g. e2)"),tag:c().optional().describe("HTML tag name of the element"),role:c().optional().describe("ARIA role of the element"),name:c().optional().describe("Accessible name of the element"),value:c().optional().describe("Final value of the element after the action"),checked:x().optional().describe("Checked state after the action"),disabled:x().optional().describe("Whether the element is disabled"),readOnly:x().optional().describe("Whether the element is read-only"),text:c().optional().describe("Text content of the element"),key:c().optional().describe("Key that was pressed (for press actions)"),direction:c().optional().describe("Scroll direction (for scroll actions)"),amount:p().optional().describe("Scroll amount in pixels (for scroll actions)")});I([C,ot()]),d({status:p().describe("HTTP response status code"),ok:x().describe("Whether the response status is 2xx"),headers:g(c()).describe("Response headers as key-value pairs"),body:c().describe("Response body as string")}),d({data:d({}).passthrough().describe("Structured snapshot data"),text:c().describe("Plain text representation of the snapshot")}),d({}),d({tabId:p(),url:c(),title:c(),contentScript:ct(["connected","missing"]),scripting:ct(["ok","blocked"]),mutationsReady:x(),hint:c().optional(),recovery:N(c()).optional()});const Mr=d({refId:he().describe("Element reference ID (e.g. e2)"),role:c().describe("ARIA role of the element"),tag:c().describe("HTML tag name"),name:c().optional().describe("Accessible name of the element"),value:c().optional().describe("Element value"),checked:x().optional().describe("Checked state"),disabled:x().optional().describe("Whether the element is disabled"),readOnly:x().optional().describe("Whether the element is read-only")}),Pr=d({text:c().describe("Plain text representation of the page"),nodes:N(Mr).describe("Array of interactive nodes"),url:c().describe("Current page URL"),title:c().describe("Current page title"),viewport:d({width:p().describe("Viewport width in pixels"),height:p().describe("Viewport height in pixels")}).describe("Viewport dimensions")}),ut=d({id:p().optional().describe("Tab ID"),tabId:p().optional().describe("Tab ID (added by runner)"),index:p().optional().describe("Tab index in the window"),windowId:p().optional().describe("Window ID"),url:c().optional().describe("Tab URL"),title:c().optional().describe("Tab title"),status:c().optional().describe("Tab status (loading or complete)"),active:x().optional().describe("Whether the tab is active"),pinned:x().optional().describe("Whether the tab is pinned"),highlighted:x().optional().describe("Whether the tab is highlighted"),incognito:x().optional().describe("Whether the tab is incognito"),favIconUrl:c().optional().describe("Favicon URL"),audible:x().optional().describe("Whether the tab is audible"),groupId:p().optional().describe("Group ID"),openerTabId:p().optional().describe("Opener tab ID"),discarded:x().optional().describe("Whether the tab is discarded"),autoDiscardable:x().optional().describe("Whether the tab is auto-discardable"),width:p().optional().describe("Tab width"),height:p().optional().describe("Tab height"),sessionId:c().optional().describe("Session ID")}).passthrough(),jr=N(ut),ft=d({id:p().optional().describe("Window ID"),focused:x().optional().describe("Whether the window is focused"),top:p().optional().describe("Window top position"),left:p().optional().describe("Window left position"),width:p().optional().describe("Window width"),height:p().optional().describe("Window height"),tabs:jr.optional().describe("Array of tabs in the window"),incognito:x().optional().describe("Whether the window is incognito"),type:c().optional().describe("Window type"),state:c().optional().describe("Window state"),alwaysOnTop:x().optional().describe("Whether the window is always on top"),sessionId:c().optional().describe("Session ID")}).passthrough();N(ft);const $r=d({name:c().describe("Cookie name"),value:c().describe("Cookie value"),domain:c().optional().describe("Cookie domain"),hostOnly:x().optional().describe("Whether the cookie is host-only"),path:c().optional().describe("Cookie path"),secure:x().optional().describe("Whether the cookie is secure"),httpOnly:x().optional().describe("Whether the cookie is HTTP-only"),sameSite:c().optional().describe("SameSite policy"),session:x().optional().describe("Whether the cookie is a session cookie"),expirationDate:p().optional().describe("Expiration date as Unix timestamp"),storeId:c().optional().describe("Store ID")}).nullable();N($r.nullable().unwrap());const Lr=d({id:c().describe("Bookmark ID"),parentId:c().optional().describe("Parent folder ID"),index:p().optional().describe("Bookmark index"),url:c().optional().describe("Bookmark URL"),title:c().describe("Bookmark title"),dateAdded:p().optional().describe("Date added"),dateGroupModified:p().optional().describe("Date group modified"),children:N(d({id:c()}).passthrough()).optional().describe("Child bookmarks")}).passthrough();N(Lr);const qr=d({id:c().describe("History item ID"),url:c().optional().describe("URL"),title:c().optional().describe("Title"),lastVisitTime:p().optional().describe("Last visit time"),visitCount:p().optional().describe("Visit count"),typedCount:p().optional().describe("Typed count")}).passthrough();N(qr);const Zr=d({frameId:p().describe("Frame ID"),result:y().optional().describe("Script result")});N(Zr),c(),x(),I([c(),p()]),x();const Vr=d({id:p().optional().describe("Group ID"),collapsed:x().optional().describe("Whether the group is collapsed"),color:c().optional().describe("Group color"),title:c().optional().describe("Group title"),windowId:p().optional().describe("Window ID")}).passthrough();N(Vr);const Br=d({lastModified:p().optional().describe("Last modified time"),tab:ut.optional().describe("Tab info"),window:ft.optional().describe("Window info")}).passthrough(),Ur=N(Br),Wr=d({deviceName:c().optional().describe("Device name"),sessions:Ur.optional().describe("Sessions")}).passthrough();N(Wr);const Fr=d({id:p().optional().describe("Download ID"),url:c().optional().describe("Download URL"),filename:c().optional().describe("Filename"),startTime:c().optional().describe("Start time"),endTime:c().optional().describe("End time"),state:c().optional().describe("Download state"),danger:c().optional().describe("Danger type"),paused:x().optional().describe("Whether the download is paused"),error:c().optional().describe("Error message"),bytesReceived:p().optional().describe("Bytes received"),totalBytes:p().optional().describe("Total bytes"),fileSize:p().optional().describe("File size"),mime:c().optional().describe("MIME type"),incognito:x().optional().describe("Whether the download is incognito"),referrer:c().optional().describe("Referrer URL"),byExtensionId:c().optional().describe("Extension ID"),byExtensionName:c().optional().describe("Extension name")}).passthrough();N(Fr),p(),d({archName:c().describe("CPU architecture"),modelName:c().describe("CPU model"),numOfProcessors:p().describe("Number of processors"),features:N(c()).describe("CPU features")}),d({capacity:p().describe("Total memory capacity"),availableCapacity:p().describe("Available memory capacity")}),N(d({id:c().describe("Storage ID"),name:c().describe("Storage name"),type:c().describe("Storage type"),capacity:p().describe("Storage capacity")}));const zr=[{action:"page_back",namespace:"page",name:"back",description:"Go back in the active tab",params:or,returns:C,paramTypes:[],returnDoc:"Navigation result",errorCode:"E_NO_TAB",example:"page.back()",handlerKey:"back"},{action:"page_click",namespace:"page",name:"click",description:"Click an element in the active tab",params:cr,returns:C,paramTypes:[{name:"refId",type:"string",required:!1,description:"Element reference ID (refId)"},{name:"label",type:"string",required:!1,description:"Element label to click (label)"}],returnDoc:"{ ok: true, action: 'click', refId? }",errorCode:"E_MISSING_PARAM",example:'page.click({ refId: "e2" })',agentMeta:{prerequisites:["Ensure the target tab is active and the content script is ready before mutating"],notes:["Same content-script path as web.tab.*","Always operates on the active tab; use web.tab.* if you need to target a specific tabId"],tags:["mutation","write"],relatedApis:["web.tab.click"]},handlerKey:"click"},{action:"page_fill",namespace:"page",name:"fill",description:"Fill an element in the active tab",params:dr,returns:C,paramTypes:[{name:"refId",type:"string",required:!1,description:"Element reference ID (refId)"},{name:"value",type:"string",required:!1,description:"Value to fill (literal)"},{name:"label",type:"string",required:!1,description:"Element label (label)"}],returnDoc:"{ ok: true, action: 'fill', refId?, value? }",errorCode:"E_MISSING_PARAM",example:'page.fill({ refId: "e2", value: "hello" })',agentMeta:{prerequisites:["Ensure the target tab is active and the content script is ready before mutating"],notes:["Same content-script path as web.tab.*","Always operates on the active tab; use web.tab.* if you need to target a specific tabId"],tags:["mutation","write"],relatedApis:["web.tab.fill"]},handlerKey:"fill"},{action:"page_type",namespace:"page",name:"type",description:"Type into an element in the active tab",params:lr,returns:C,paramTypes:[{name:"refId",type:"string",required:!1,description:"Element reference ID (refId)"},{name:"text",type:"string",required:!1,description:"Text to type (literal)"},{name:"label",type:"string",required:!1,description:"Element label (label)"}],returnDoc:"{ ok: true, action: 'type', refId?, value? }",errorCode:"E_MISSING_PARAM",example:'page.type({ refId: "e2", text: "hello" })',agentMeta:{prerequisites:["Ensure the target tab is active and the content script is ready before mutating"],notes:["Same content-script path as web.tab.*","Always operates on the active tab; use web.tab.* if you need to target a specific tabId"],tags:["mutation","write"],relatedApis:["web.tab.type"]},handlerKey:"type"},{action:"page_append",namespace:"page",name:"append",description:"Append text to an element in the active tab",params:ur,returns:C,paramTypes:[{name:"refId",type:"string",required:!1,description:"Element reference ID (refId)"},{name:"text",type:"string",required:!1,description:"Text to append (literal)"},{name:"label",type:"string",required:!1,description:"Element label (label)"}],returnDoc:"{ ok: true, action: 'append', refId?, value? }",errorCode:"E_MISSING_PARAM",example:'page.append({ refId: "e2", text: " world" })',agentMeta:{prerequisites:["Ensure the target tab is active and the content script is ready before mutating"],notes:["Same content-script path as web.tab.*","Always operates on the active tab; use web.tab.* if you need to target a specific tabId"],tags:["mutation","write"]},handlerKey:"append"},{action:"page_press",namespace:"page",name:"press",description:"Press a key in the active tab",params:fr,returns:C,fields:["key"],paramTypes:[{name:"key",type:"string",required:!0,description:"Key to press (literal)"}],returnDoc:"{ ok: true, action: 'press', key? }",errorCode:"E_NO_TAB",example:'page.press("Enter")',agentMeta:{prerequisites:["Ensure the target tab is active and the content script is ready before mutating"],notes:["Same content-script path as web.tab.*","Always operates on the active tab; use web.tab.* if you need to target a specific tabId"],tags:["mutation","write"],relatedApis:["web.tab.press"]},handlerKey:"press"},{action:"page_select",namespace:"page",name:"select",description:"Select an option in the active tab",params:pr,returns:C,paramTypes:[{name:"refId",type:"string",required:!1,description:"Element reference ID (refId)"},{name:"label",type:"string",required:!1,description:"Element label (label)"},{name:"value",type:"string",required:!1,description:"Option value to select (literal)"}],returnDoc:"{ ok: true, action: 'select', refId?, value? }",errorCode:"E_MISSING_PARAM",example:'page.select({ refId: "e2", value: "option1" })',agentMeta:{prerequisites:["Ensure the target tab is active and the content script is ready before mutating"],notes:["Same content-script path as web.tab.*","Always operates on the active tab; use web.tab.* if you need to target a specific tabId"],tags:["mutation","write"],relatedApis:["web.tab.select"]},handlerKey:"select"},{action:"page_check",namespace:"page",name:"check",description:"Check/uncheck an element in the active tab",params:hr,returns:C,paramTypes:[{name:"refId",type:"string",required:!1,description:"Element reference ID (refId)"},{name:"label",type:"string",required:!1,description:"Element label (label)"},{name:"checked",type:"boolean",required:!1,description:"Whether to check or uncheck (literal)"}],returnDoc:"{ ok: true, action: 'check', refId?, checked? }",errorCode:"E_MISSING_PARAM",example:'page.check({ refId: "e2", checked: true })',agentMeta:{prerequisites:["Ensure the target tab is active and the content script is ready before mutating"],notes:["Same content-script path as web.tab.*","Always operates on the active tab; use web.tab.* if you need to target a specific tabId"],tags:["mutation","write"],relatedApis:["web.tab.check"]},handlerKey:"check"},{action:"page_hover",namespace:"page",name:"hover",description:"Hover over an element in the active tab",params:mr,returns:C,paramTypes:[{name:"refId",type:"string",required:!1,description:"Element reference ID (refId)"},{name:"label",type:"string",required:!1,description:"Element label (label)"}],returnDoc:"{ ok: true, action: 'hover', refId? }",errorCode:"E_MISSING_PARAM",example:'page.hover({ refId: "e2" })',agentMeta:{prerequisites:["Ensure the target tab is active and the content script is ready before mutating"],notes:["Same content-script path as web.tab.*","Always operates on the active tab; use web.tab.* if you need to target a specific tabId"],tags:["mutation","write"],relatedApis:["web.tab.hover"]},handlerKey:"hover"},{action:"page_unhover",namespace:"page",name:"unhover",description:"Unhover in the active tab",params:br,returns:C,paramTypes:[],returnDoc:"{ ok: true, action: 'unhover' }",errorCode:"E_NO_TAB",example:"page.unhover()",agentMeta:{prerequisites:["Ensure the target tab is active and the content script is ready before mutating"],notes:["Same content-script path as web.tab.*","Always operates on the active tab; use web.tab.* if you need to target a specific tabId"],tags:["mutation","write"],relatedApis:["web.tab.unhover"]},handlerKey:"unhover"},{action:"page_scroll",namespace:"page",name:"scroll",description:"Scroll the active tab",params:gr,returns:C,fields:["direction","amount"],paramTypes:[{name:"direction",type:"string",required:!1,description:"Scroll direction (up or down) (literal)"},{name:"amount",type:"number",required:!1,description:"Scroll amount in pixels (literal)"}],returnDoc:"Scroll result",errorCode:"E_NO_TAB",example:'page.scroll("down", 500)',handlerKey:"scroll"},{action:"page_scroll_to",namespace:"page",name:"scroll_to",description:"Scroll to an element in the active tab",params:yr,returns:C,paramTypes:[{name:"refId",type:"string",required:!1,description:"Element reference ID to scroll to (refId)"},{name:"label",type:"string",required:!1,description:"Element label to scroll to (label)"}],returnDoc:"Scroll to result",errorCode:"E_MISSING_PARAM",example:'page.scroll_to({ refId: "e2" })',handlerKey:"scroll_to"},{action:"page_dblclick",namespace:"page",name:"dblclick",description:"Double-click an element in the active tab",params:vr,returns:C,paramTypes:[{name:"refId",type:"string",required:!1,description:"Element reference ID (refId)"},{name:"label",type:"string",required:!1,description:"Element label (label)"}],returnDoc:"{ ok: true, action: 'dblclick', refId? }",errorCode:"E_MISSING_PARAM",example:'page.dblclick({ refId: "e2" })',agentMeta:{prerequisites:["Ensure the target tab is active and the content script is ready before mutating"],notes:["Same content-script path as web.tab.*","Always operates on the active tab; use web.tab.* if you need to target a specific tabId"],tags:["mutation","write"],relatedApis:["web.tab.dblclick"]},handlerKey:"dblclick"},{action:"tab_click",namespace:"web.tab",name:"click",description:"Click in a tab",params:kr,returns:C,paramTypes:[{name:"tabId",type:"number",required:!0,description:"Tab ID (literal)"},{name:"refId",type:"string",required:!1,description:"Element reference ID (refId)"},{name:"label",type:"string",required:!1,description:"Element label (label)"}],returnDoc:"{ ok: true, action: 'click', refId? }",errorCode:"E_NO_TAB",example:'web.tab.click({ tabId: 123, refId: "e2" })',agentMeta:{prerequisites:["Ensure the target tab exists and the content script is ready before mutating"],notes:["Explicit tabId required; same handlers as page.*"],tags:["mutation","write"],relatedApis:["page.click"]},handlerKey:"click"},{action:"tab_fill",namespace:"web.tab",name:"fill",description:"Fill in a tab",params:wr,returns:C,paramTypes:[{name:"tabId",type:"number",required:!0,description:"Tab ID (literal)"},{name:"refId",type:"string",required:!1,description:"Element reference ID (refId)"},{name:"value",type:"string",required:!1,description:"Value to fill (literal)"},{name:"label",type:"string",required:!1,description:"Element label (label)"}],returnDoc:"{ ok: true, action: 'fill', refId?, value? }",errorCode:"E_NO_TAB",example:'web.tab.fill({ tabId: 123, refId: "e2", value: "hello" })',agentMeta:{prerequisites:["Ensure the target tab exists and the content script is ready before mutating"],notes:["Explicit tabId required; same handlers as page.*"],tags:["mutation","write"],relatedApis:["page.fill"]},handlerKey:"fill"},{action:"tab_scroll_to",namespace:"web.tab",name:"scroll_to",description:"Scroll to position in a tab",params:xr,returns:C,paramTypes:[{name:"tabId",type:"number",required:!0,description:"Tab ID (literal)"},{name:"x",type:"number",required:!1,description:"X coordinate (literal)"},{name:"y",type:"number",required:!1,description:"Y coordinate (literal)"},{name:"refId",type:"string",required:!1,description:"Element reference ID (refId)"},{name:"label",type:"string",required:!1,description:"Element label (label)"}],returnDoc:"Scroll to result",errorCode:"E_NO_TAB",example:'web.tab.scroll_to({ tabId: 123, refId: "e2" })',handlerKey:"scroll_to"},{action:"tab_type",namespace:"web.tab",name:"type",description:"Type in a tab",params:Ir,returns:C,paramTypes:[{name:"tabId",type:"number",required:!0,description:"Tab ID (literal)"},{name:"refId",type:"string",required:!1,description:"Element reference ID (refId)"},{name:"text",type:"string",required:!1,description:"Text to type (literal)"},{name:"label",type:"string",required:!1,description:"Element label (label)"}],returnDoc:"{ ok: true, action: 'type', refId?, value? }",errorCode:"E_NO_TAB",example:'web.tab.type({ tabId: 123, refId: "e2", text: "hello" })',agentMeta:{prerequisites:["Ensure the target tab exists and the content script is ready before mutating"],notes:["Explicit tabId required; same handlers as page.*"],tags:["mutation","write"],relatedApis:["page.type"]},handlerKey:"type"},{action:"tab_press",namespace:"web.tab",name:"press",description:"Press a key in a tab",params:Tr,returns:C,paramTypes:[{name:"tabId",type:"number",required:!0,description:"Tab ID (literal)"},{name:"key",type:"string",required:!1,description:"Key to press (literal)"}],returnDoc:"{ ok: true, action: 'press', key? }",errorCode:"E_NO_TAB",example:'web.tab.press({ tabId: 123, key: "Enter" })',agentMeta:{prerequisites:["Ensure the target tab exists and the content script is ready before mutating"],notes:["Explicit tabId required; same handlers as page.*"],tags:["mutation","write"],relatedApis:["page.press"]},handlerKey:"press"},{action:"tab_select",namespace:"web.tab",name:"select",description:"Select an option in a tab",params:Sr,returns:C,paramTypes:[{name:"tabId",type:"number",required:!0,description:"Tab ID (literal)"},{name:"refId",type:"string",required:!1,description:"Element reference ID (refId)"},{name:"label",type:"string",required:!1,description:"Element label (label)"},{name:"value",type:"string",required:!1,description:"Option value to select (literal)"}],returnDoc:"{ ok: true, action: 'select', refId?, value? }",errorCode:"E_NO_TAB",example:'web.tab.select({ tabId: 123, refId: "e2", value: "option1" })',agentMeta:{prerequisites:["Ensure the target tab exists and the content script is ready before mutating"],notes:["Explicit tabId required; same handlers as page.*"],tags:["mutation","write"],relatedApis:["page.select"]},handlerKey:"select"},{action:"tab_check",namespace:"web.tab",name:"check",description:"Check/uncheck in a tab",params:Er,returns:C,paramTypes:[{name:"tabId",type:"number",required:!0,description:"Tab ID (literal)"},{name:"refId",type:"string",required:!1,description:"Element reference ID (refId)"},{name:"label",type:"string",required:!1,description:"Element label (label)"},{name:"checked",type:"boolean",required:!1,description:"Whether to check or uncheck (literal)"}],returnDoc:"{ ok: true, action: 'check', refId?, checked? }",errorCode:"E_NO_TAB",example:'web.tab.check({ tabId: 123, refId: "e2", checked: true })',agentMeta:{prerequisites:["Ensure the target tab exists and the content script is ready before mutating"],notes:["Explicit tabId required; same handlers as page.*"],tags:["mutation","write"],relatedApis:["page.check"]},handlerKey:"check"},{action:"tab_hover",namespace:"web.tab",name:"hover",description:"Hover in a tab",params:Cr,returns:C,paramTypes:[{name:"tabId",type:"number",required:!0,description:"Tab ID (literal)"},{name:"refId",type:"string",required:!1,description:"Element reference ID (refId)"},{name:"label",type:"string",required:!1,description:"Element label (label)"}],returnDoc:"{ ok: true, action: 'hover', refId? }",errorCode:"E_NO_TAB",example:'web.tab.hover({ tabId: 123, refId: "e2" })',agentMeta:{prerequisites:["Ensure the target tab exists and the content script is ready before mutating"],notes:["Explicit tabId required; same handlers as page.*"],tags:["mutation","write"],relatedApis:["page.hover"]},handlerKey:"hover"},{action:"tab_unhover",namespace:"web.tab",name:"unhover",description:"Unhover in a tab",params:Ar,returns:C,paramTypes:[{name:"tabId",type:"number",required:!0,description:"Tab ID (literal)"}],returnDoc:"{ ok: true, action: 'unhover' }",errorCode:"E_NO_TAB",example:"web.tab.unhover({ tabId: 123 })",agentMeta:{prerequisites:["Ensure the target tab exists and the content script is ready before mutating"],notes:["Explicit tabId required; same handlers as page.*"],tags:["mutation","write"],relatedApis:["page.unhover"]},handlerKey:"unhover"},{action:"tab_scroll",namespace:"web.tab",name:"scroll",description:"Scroll in a tab",params:Nr,returns:C,paramTypes:[{name:"tabId",type:"number",required:!0,description:"Tab ID (literal)"},{name:"direction",type:"string",required:!1,description:"Scroll direction (up or down) (literal)"},{name:"amount",type:"number",required:!1,description:"Scroll amount in pixels (literal)"}],returnDoc:"Scroll result",errorCode:"E_NO_TAB",example:'web.tab.scroll({ tabId: 123, direction: "down", amount: 500 })',handlerKey:"scroll"},{action:"tab_dblclick",namespace:"web.tab",name:"dblclick",description:"Double-click in a tab",params:Or,returns:C,paramTypes:[{name:"tabId",type:"number",required:!0,description:"Tab ID (literal)"},{name:"refId",type:"string",required:!1,description:"Element reference ID (refId)"},{name:"label",type:"string",required:!1,description:"Element label (label)"}],returnDoc:"{ ok: true, action: 'dblclick', refId? }",errorCode:"E_NO_TAB",example:'web.tab.dblclick({ tabId: 123, refId: "e2" })',agentMeta:{prerequisites:["Ensure the target tab exists and the content script is ready before mutating"],notes:["Explicit tabId required; same handlers as page.*"],tags:["mutation","write"],relatedApis:["page.dblclick"]},handlerKey:"dblclick"},{action:"tab_back",namespace:"web.tab",name:"back",description:"Go back in a tab",params:Rr,returns:C,paramTypes:[{name:"tabId",type:"number",required:!0,description:"Tab ID (literal)"}],returnDoc:"Back result",errorCode:"E_NO_TAB",example:"web.tab.back({ tabId: 123 })",handlerKey:"back"}];function Hr(){return[{registryAction:"ping",handlerKey:"ping",params:d({}),returns:d({ok:x()})},{registryAction:"snapshot",handlerKey:"snapshot",params:Dr,returns:Pr}]}function Kr(){return zr.map(t=>({registryAction:t.action,handlerKey:t.handlerKey,params:t.params,returns:t.returns}))}const J={debug:0,info:1,warn:2,error:3,none:4};let pt=J.error;function Gr(t){if(!t)return"";const e=[];for(const[r,n]of Object.entries(t)){let a;if(n===null)a="null";else if(n===void 0)a="undefined";else if(typeof n=="string")a=n;else if(typeof n=="number"||typeof n=="boolean")a=String(n);else try{a=JSON.stringify(n)}catch{a="[Circular]"}e.push(`${r}=${a}`)}return e.length>0?` ${e.join(" ")}`:""}function je(t,e,r){if(t<pt)return;const n=Gr(r),a=`[extension-js][content-script] ${e}${n}`;t>=J.error?console.error(a):t===J.warn?console.warn(a):console.log(a)}const ce={debug:(t,e)=>{je(J.debug,t,e)},info:(t,e)=>{je(J.info,t,e)},warn:(t,e)=>{je(J.warn,t,e)},error:(t,e)=>{je(J.error,t,e)}};function Jr(){window.__jsNotebookSetLogLevel=t=>{pt=J[t]??J.error}}function Yr(t){if(t.startsWith("page_")||t.startsWith("tab_")){const e=t.indexOf("_");if(e>=0)return t.slice(e+1)}return t}const ht='input, textarea, select, button, a, [role="button"], [role="link"]';function mt(t){const e={};return t instanceof HTMLInputElement?(e.value=t.value,(t.type==="checkbox"||t.type==="radio")&&(e.checked=t.checked),e.disabled=t.disabled,e.readOnly=t.readOnly):t instanceof HTMLTextAreaElement?(e.value=t.value,e.disabled=t.disabled,e.readOnly=t.readOnly):t instanceof HTMLSelectElement&&(e.value=t.value,e.disabled=t.disabled),e}function Xr(t,e){const r=t.tagName.toLowerCase();r!=="input"&&r!=="textarea"&&r!=="select"||Object.assign(e,mt(t))}function $e(t){const e=t.tagName.toLowerCase(),r=t.getAttribute("role");if(r)return r;if(e==="button"||e==="input"&&t.type==="submit")return"button";if(e==="a")return"link";if(e==="input"){const n=t.type;if(n==="text"||n==="email"||n==="password"||n==="search")return"textbox";if(n==="checkbox")return"checkbox";if(n==="radio")return"radio";if(n==="submit"||n==="button")return"button"}return e==="textarea"?"textbox":e==="select"?"combobox":e==="img"?"img":e==="h1"||e==="h2"||e==="h3"||e==="h4"||e==="h5"||e==="h6"?"heading":e==="li"?"listitem":e==="ul"||e==="ol"?"list":e==="table"?"table":e==="tr"?"row":e==="td"||e==="th"?"cell":e==="nav"?"navigation":e==="main"?"main":e==="article"?"article":e==="section"?"region":e==="aside"?"complementary":e==="form"?"form":e==="dialog"||e==="modal"?"dialog":e==="figure"?"figure":e==="figcaption"?"caption":t.getAttribute("onclick")||t.onclick?"button":"generic"}function bt(t){var s,o;const e=t.getAttribute("aria-label");if(e)return e;const r=t.getAttribute("aria-labelledby");if(r){const l=document.getElementById(r);if(l)return((s=l.textContent)==null?void 0:s.slice(0,60))||""}if(t.tagName.toLowerCase()==="img"){const l=t.getAttribute("alt");if(l)return l}const a=t.title;if(a)return a;const i=$e(t);return i!=="generic"&&i!=="list"&&i!=="table"&&i!=="row"&&i!=="region"&&i!=="navigation"&&i!=="main"&&((o=t.textContent)==null?void 0:o.trim().slice(0,60))||""}function Qr(t){const e=$e(t);if(e==="generic"||e==="presentation"||e==="none"||t.hidden)return!1;const r=window.getComputedStyle(t);return!(r.display==="none"||r.visibility==="hidden")}function Y(t){return document.querySelector(`[data-ref-id='${CSS.escape(t)}']`)}function X(t){var n,a,i;const e=t.toLowerCase().trim();if(!e)return null;const r=Array.from(document.querySelectorAll(ht));for(const s of r){const o=s.getAttribute("aria-label");if(o&&o.toLowerCase().trim()===e)return s;const l=s.placeholder;if(l&&l.toLowerCase().trim()===e)return s;const f=s.id;if(f){const $=document.querySelector(`label[for='${CSS.escape(f)}']`);if($&&((n=$.textContent)==null?void 0:n.trim().toLowerCase())===e)return s}const v=s.closest("label");if(v&&((a=v.textContent)==null?void 0:a.trim().toLowerCase())===e||(((i=s.textContent)==null?void 0:i.trim().toLowerCase())||"")===e)return s}return null}function en(t){var a;const e=t.toLowerCase().trim();if(!e)return[];const r=Array.from(document.querySelectorAll(ht)),n=[];for(const i of r){const s=i.getAttribute("aria-label"),o=i.placeholder,l=((a=i.textContent)==null?void 0:a.trim())||"";if(![s,o,l].filter(Boolean).some(E=>E.toLowerCase().includes(e)))continue;const v=i.getAttribute("data-ref-id");if(v&&(n.push({refId:v,role:$e(i),name:bt(i)||void 0}),n.length>=5))break}return n}function de(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)?t:{}}function A(t,e){const r=de(t)[e];return typeof r=="string"?r:""}function gt(t,e,r){const n=de(t)[e];return typeof n=="number"?n:r}function Q(t,e,r=!1){if(t&&Ae(_t(t)),e){const n=r?en(e):[];Ae(xt(e,n))}Ae({message:"Element not found",code:"E_NOT_FOUND",category:"resource"})}function tn(t){let e=1;const r=[],n=[];function a(s,o){if(r.length>=t)return;const l=s.tagName.toLowerCase();if(l==="script"||l==="style"||l==="noscript"||l==="template")return;const f=Qr(s);let v=o;if(f){const E="e"+e++;s.setAttribute("data-ref-id",E);const $=$e(s),z=bt(s),Ye={refId:E,role:$,tag:l};z&&(Ye.name=z),Xr(s,Ye),r.push(Ye);const Xe=[`${" ".repeat(o)}- ${$}`];z&&Xe.push(`"${z.replace(/"/g,'\\"')}"`),Xe.push(`[${E}]`),n.push(Xe.join(" ")),v=o+1}for(const E of s.children)a(E,v)}return document.body&&a(document.body,0),{text:[`URL: ${window.location.href}`,`Title: ${document.title}`,""].concat(n).join(`
|
|
2
|
-
`),nodes:r,url:window.location.href,title:document.title,viewport:{width:window.innerWidth,height:window.innerHeight}}}function M(t,e,r){const
|
|
1
|
+
(function(){"use strict";function Ae(t){return t==null?{}:t instanceof Map?Object.fromEntries([...t.entries()].map(([e,r])=>[e,Ae(r)])):Array.isArray(t)?t.map(Ae):t}function Tt(t,e){const r=t?"refId":null,a=t||(e==null?void 0:e.label)||"";return{message:`Element not found${r?` by ${r} "${a}"`:""}`,code:"E_STALE",category:"resource",hint:"RefIds are ephemeral. They are assigned at snapshot time and invalidated when the DOM is replaced (navigation, SPA rerender, autocomplete).",recovery:["const d = await page.snapshot_data(); find the target in d.nodes","Use a fresh refId from that snapshot only","Do not reuse refIds from before press/click/navigation"],details:{staleRefId:t||void 0}}}function St(t,e,r){return{message:`${t} on ${e} returned no effect.`,code:"E_NOT_INTERACTABLE",category:"resource",hint:"Some sites ignore programmatic value assignment; value may not appear in snapshot_data.",recovery:[`await page.click({ refId: ${JSON.stringify(e)} }) then await page.type({ refId: ${JSON.stringify(e)}, text: "..." })`,'Or await page.press({ key: "Enter" }) after fill',"Re-snapshot and confirm URL or node state changed"],details:{refId:e,...r}}}function Et(t){return t.includes("Could not establish connection")||t.includes("Receiving end does not exist")||t.includes("Timeout waiting for content-script ping")||t.includes("content script not available")}function Ce(t){const e=new Error(t.message);throw e.code=t.code,t.category&&(e.category=t.category),t.hint&&(e.hint=t.hint),t.recovery&&(e.recovery=t.recovery),t.details&&(e.details=t.details),e}function At(t,e){let r=`Element not found by label "${t}"`;if(e!=null&&e.length){const a=e.map(n=>n.name||n.refId).filter(Boolean).slice(0,5);r+=a.length>0?`. Candidates: ${a.join(", ")}`:". Candidates: none"}return{message:r,code:"E_NOT_FOUND",category:"resource",hint:"No element matched this label. Check candidates or snapshot for visible controls.",recovery:["const d = await page.snapshot_data(); find the target in d.nodes","Try a more specific label or use refId from snapshot"],details:e!=null&&e.length?{label:t,candidates:e}:{label:t}}}function Ct(t,e){if(typeof t=="object"&&t!==null&&"code"in t&&typeof t.code=="string"&&"message"in t&&typeof t.message=="string"){const a=t;return a.hint||a.recovery||a.code==="E_CONTENT_SCRIPT"&&(e==null?void 0:e.tabId)!=null,a}const r=(t instanceof Error?t.message:String(t))||"";return Et(r)?{message:"Content script is not connected on this tab.",code:"E_CONTENT_SCRIPT",category:"content-script",hint:"page.snapshot() uses script injection and can succeed even when fill/click cannot. This tab was likely open before the extension loaded (MV3 does not retro-inject).",recovery:[`await page.goto(${JSON.stringify("")})`,"Or ask the user to refresh the target tab, then retry fill/click"]}:r.includes("permission")||r.includes("Permission")?{message:r,code:"E_PERMISSION",category:"permission"}:r.includes("not found")||r.includes("No tab")||r.includes("No active tab")?{message:r,code:"E_NOT_FOUND",category:"resource"}:{message:r,code:"E_EXTENSION",category:"extension"}}var S;(function(t){t.assertEqual=n=>{};function e(n){}t.assertIs=e;function r(n){throw new Error}t.assertNever=r,t.arrayToEnum=n=>{const s={};for(const i of n)s[i]=i;return s},t.getValidEnumValues=n=>{const s=t.objectKeys(n).filter(o=>typeof n[n[o]]!="number"),i={};for(const o of s)i[o]=n[o];return t.objectValues(i)},t.objectValues=n=>t.objectKeys(n).map(function(s){return n[s]}),t.objectKeys=typeof Object.keys=="function"?n=>Object.keys(n):n=>{const s=[];for(const i in n)Object.prototype.hasOwnProperty.call(n,i)&&s.push(i);return s},t.find=(n,s)=>{for(const i of n)if(s(i))return i},t.isInteger=typeof Number.isInteger=="function"?n=>Number.isInteger(n):n=>typeof n=="number"&&Number.isFinite(n)&&Math.floor(n)===n;function a(n,s=" | "){return n.map(i=>typeof i=="string"?`'${i}'`:i).join(s)}t.joinValues=a,t.jsonStringifyReplacer=(n,s)=>typeof s=="bigint"?s.toString():s})(S||(S={}));var et;(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(et||(et={}));const m=S.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),ee=t=>{switch(typeof t){case"undefined":return m.undefined;case"string":return m.string;case"number":return Number.isNaN(t)?m.nan:m.number;case"boolean":return m.boolean;case"function":return m.function;case"bigint":return m.bigint;case"symbol":return m.symbol;case"object":return Array.isArray(t)?m.array:t===null?m.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?m.promise:typeof Map<"u"&&t instanceof Map?m.map:typeof Set<"u"&&t instanceof Set?m.set:typeof Date<"u"&&t instanceof Date?m.date:m.object;default:return m.unknown}},p=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"]);class j extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=a=>{this.issues=[...this.issues,a]},this.addIssues=(a=[])=>{this.issues=[...this.issues,...a]};const r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}format(e){const r=e||function(s){return s.message},a={_errors:[]},n=s=>{for(const i of s.issues)if(i.code==="invalid_union")i.unionErrors.map(n);else if(i.code==="invalid_return_type")n(i.returnTypeError);else if(i.code==="invalid_arguments")n(i.argumentsError);else if(i.path.length===0)a._errors.push(r(i));else{let o=a,d=0;for(;d<i.path.length;){const u=i.path[d];d===i.path.length-1?(o[u]=o[u]||{_errors:[]},o[u]._errors.push(r(i))):o[u]=o[u]||{_errors:[]},o=o[u],d++}}};return n(this),a}static assert(e){if(!(e instanceof j))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){const r={},a=[];for(const n of this.issues)if(n.path.length>0){const s=n.path[0];r[s]=r[s]||[],r[s].push(e(n))}else a.push(e(n));return{formErrors:a,fieldErrors:r}}get formErrors(){return this.flatten()}}j.create=t=>new j(t);const me=(t,e)=>{let r;switch(t.code){case p.invalid_type:t.received===m.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case p.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,S.jsonStringifyReplacer)}`;break;case p.unrecognized_keys:r=`Unrecognized key(s) in object: ${S.joinValues(t.keys,", ")}`;break;case p.invalid_union:r="Invalid input";break;case p.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${S.joinValues(t.options)}`;break;case p.invalid_enum_value:r=`Invalid enum value. Expected ${S.joinValues(t.options)}, received '${t.received}'`;break;case p.invalid_arguments:r="Invalid function arguments";break;case p.invalid_return_type:r="Invalid function return type";break;case p.invalid_date:r="Invalid date";break;case p.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 p.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 p.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 p.custom:r="Invalid input";break;case p.invalid_intersection_types:r="Intersection results could not be merged";break;case p.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case p.not_finite:r="Number must be finite";break;default:r=e.defaultError,S.assertNever(t)}return{message:r}};let Nt=me;function $e(){return Nt}const Le=t=>{const{data:e,path:r,errorMaps:a,issueData:n}=t,s=[...r,...n.path||[]],i={...n,path:s};if(n.message!==void 0)return{...n,path:s,message:n.message};let o="";const d=a.filter(u=>!!u).slice().reverse();for(const u of d)o=u(i,{data:e,defaultError:o}).message;return{...n,path:s,message:o}};function h(t,e){const r=$e(),a=Le({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===me?void 0:me].filter(n=>!!n)});t.common.issues.push(a)}class P{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,r){const a=[];for(const n of r){if(n.status==="aborted")return v;n.status==="dirty"&&e.dirty(),a.push(n.value)}return{status:e.value,value:a}}static async mergeObjectAsync(e,r){const a=[];for(const n of r){const s=await n.key,i=await n.value;a.push({key:s,value:i})}return P.mergeObjectSync(e,a)}static mergeObjectSync(e,r){const a={};for(const n of r){const{key:s,value:i}=n;if(s.status==="aborted"||i.status==="aborted")return v;s.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),s.value!=="__proto__"&&(typeof i.value<"u"||n.alwaysSet)&&(a[s.value]=i.value)}return{status:e.value,value:a}}}const v=Object.freeze({status:"aborted"}),be=t=>({status:"dirty",value:t}),q=t=>({status:"valid",value:t}),tt=t=>t.status==="aborted",rt=t=>t.status==="dirty",le=t=>t.status==="valid",Ne=t=>typeof Promise<"u"&&t instanceof Promise;var b;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(b||(b={}));class F{constructor(e,r,a,n){this._cachedPath=[],this.parent=e,this.data=r,this._path=a,this._key=n}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}}const at=(t,e)=>{if(le(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const r=new j(t.common.issues);return this._error=r,this._error}}};function k(t){if(!t)return{};const{errorMap:e,invalid_type_error:r,required_error:a,description:n}=t;if(e&&(r||a))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:n}:{errorMap:(i,o)=>{const{message:d}=t;return i.code==="invalid_enum_value"?{message:d??o.defaultError}:typeof o.data>"u"?{message:d??a??o.defaultError}:i.code!=="invalid_type"?{message:o.defaultError}:{message:d??r??o.defaultError}},description:n}}class T{get description(){return this._def.description}_getType(e){return ee(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:ee(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new P,ctx:{common:e.parent.common,data:e.data,parsedType:ee(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const r=this._parse(e);if(Ne(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(e){const r=this._parse(e);return Promise.resolve(r)}parse(e,r){const a=this.safeParse(e,r);if(a.success)return a.data;throw a.error}safeParse(e,r){const a={common:{issues:[],async:(r==null?void 0:r.async)??!1,contextualErrorMap:r==null?void 0:r.errorMap},path:(r==null?void 0:r.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ee(e)},n=this._parseSync({data:e,path:a.path,parent:a});return at(a,n)}"~validate"(e){var a,n;const r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ee(e)};if(!this["~standard"].async)try{const s=this._parseSync({data:e,path:[],parent:r});return le(s)?{value:s.value}:{issues:r.common.issues}}catch(s){(n=(a=s==null?void 0:s.message)==null?void 0:a.toLowerCase())!=null&&n.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:r}).then(s=>le(s)?{value:s.value}:{issues:r.common.issues})}async parseAsync(e,r){const a=await this.safeParseAsync(e,r);if(a.success)return a.data;throw a.error}async safeParseAsync(e,r){const a={common:{issues:[],contextualErrorMap:r==null?void 0:r.errorMap,async:!0},path:(r==null?void 0:r.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ee(e)},n=this._parse({data:e,path:a.path,parent:a}),s=await(Ne(n)?n:Promise.resolve(n));return at(a,s)}refine(e,r){const a=n=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(n):r;return this._refinement((n,s)=>{const i=e(n),o=()=>s.addIssue({code:p.custom,...a(n)});return typeof Promise<"u"&&i instanceof Promise?i.then(d=>d?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,r){return this._refinement((a,n)=>e(a)?!0:(n.addIssue(typeof r=="function"?r(a,n):r),!1))}_refinement(e){return new H({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 V.create(this,this._def)}nullable(){return ae.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Z.create(this)}promise(){return fe.create(this,this._def)}or(e){return _e.create([this,e],this._def)}and(e){return ve.create(this,e,this._def)}transform(e){return new H({...k(this._def),schema:this,typeName:x.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const r=typeof e=="function"?e:()=>e;return new Ie({...k(this._def),innerType:this,defaultValue:r,typeName:x.ZodDefault})}brand(){return new He({typeName:x.ZodBranded,type:this,...k(this._def)})}catch(e){const r=typeof e=="function"?e:()=>e;return new Te({...k(this._def),innerType:this,catchValue:r,typeName:x.ZodCatch})}describe(e){const r=this.constructor;return new r({...this._def,description:e})}pipe(e){return Me.create(this,e)}readonly(){return Se.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Ot=/^c[^\s-]{8,}$/i,Dt=/^[0-9a-z]+$/,Rt=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Mt=/^[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,Pt=/^[a-z0-9_-]{21}$/i,qt=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,jt=/^[-+]?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)?)??$/,$t=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Lt="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Ze;const Zt=/^(?:(?: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])$/,Vt=/^(?:(?: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])$/,Bt=/^(([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]))$/,Ft=/^(([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])$/,Ut=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Wt=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nt="((\\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])))",zt=new RegExp(`^${nt}$`);function st(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);const r=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${r}`}function Kt(t){return new RegExp(`^${st(t)}$`)}function Ht(t){let e=`${nt}T${st(t)}`;const r=[];return r.push(t.local?"Z?":"Z"),t.offset&&r.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${r.join("|")})`,new RegExp(`^${e}$`)}function Gt(t,e){return!!((e==="v4"||!e)&&Zt.test(t)||(e==="v6"||!e)&&Bt.test(t))}function Jt(t,e){if(!qt.test(t))return!1;try{const[r]=t.split(".");if(!r)return!1;const a=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),n=JSON.parse(atob(a));return!(typeof n!="object"||n===null||"typ"in n&&(n==null?void 0:n.typ)!=="JWT"||!n.alg||e&&n.alg!==e)}catch{return!1}}function Yt(t,e){return!!((e==="v4"||!e)&&Vt.test(t)||(e==="v6"||!e)&&Ft.test(t))}class U extends T{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==m.string){const s=this._getOrReturnCtx(e);return h(s,{code:p.invalid_type,expected:m.string,received:s.parsedType}),v}const a=new P;let n;for(const s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(n=this._getOrReturnCtx(e,n),h(n,{code:p.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),a.dirty());else if(s.kind==="max")e.data.length>s.value&&(n=this._getOrReturnCtx(e,n),h(n,{code:p.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),a.dirty());else if(s.kind==="length"){const i=e.data.length>s.value,o=e.data.length<s.value;(i||o)&&(n=this._getOrReturnCtx(e,n),i?h(n,{code:p.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):o&&h(n,{code:p.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),a.dirty())}else if(s.kind==="email")$t.test(e.data)||(n=this._getOrReturnCtx(e,n),h(n,{validation:"email",code:p.invalid_string,message:s.message}),a.dirty());else if(s.kind==="emoji")Ze||(Ze=new RegExp(Lt,"u")),Ze.test(e.data)||(n=this._getOrReturnCtx(e,n),h(n,{validation:"emoji",code:p.invalid_string,message:s.message}),a.dirty());else if(s.kind==="uuid")Mt.test(e.data)||(n=this._getOrReturnCtx(e,n),h(n,{validation:"uuid",code:p.invalid_string,message:s.message}),a.dirty());else if(s.kind==="nanoid")Pt.test(e.data)||(n=this._getOrReturnCtx(e,n),h(n,{validation:"nanoid",code:p.invalid_string,message:s.message}),a.dirty());else if(s.kind==="cuid")Ot.test(e.data)||(n=this._getOrReturnCtx(e,n),h(n,{validation:"cuid",code:p.invalid_string,message:s.message}),a.dirty());else if(s.kind==="cuid2")Dt.test(e.data)||(n=this._getOrReturnCtx(e,n),h(n,{validation:"cuid2",code:p.invalid_string,message:s.message}),a.dirty());else if(s.kind==="ulid")Rt.test(e.data)||(n=this._getOrReturnCtx(e,n),h(n,{validation:"ulid",code:p.invalid_string,message:s.message}),a.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),h(n,{validation:"url",code:p.invalid_string,message:s.message}),a.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),h(n,{validation:"regex",code:p.invalid_string,message:s.message}),a.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(n=this._getOrReturnCtx(e,n),h(n,{code:p.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),a.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)||(n=this._getOrReturnCtx(e,n),h(n,{code:p.invalid_string,validation:{startsWith:s.value},message:s.message}),a.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(n=this._getOrReturnCtx(e,n),h(n,{code:p.invalid_string,validation:{endsWith:s.value},message:s.message}),a.dirty()):s.kind==="datetime"?Ht(s).test(e.data)||(n=this._getOrReturnCtx(e,n),h(n,{code:p.invalid_string,validation:"datetime",message:s.message}),a.dirty()):s.kind==="date"?zt.test(e.data)||(n=this._getOrReturnCtx(e,n),h(n,{code:p.invalid_string,validation:"date",message:s.message}),a.dirty()):s.kind==="time"?Kt(s).test(e.data)||(n=this._getOrReturnCtx(e,n),h(n,{code:p.invalid_string,validation:"time",message:s.message}),a.dirty()):s.kind==="duration"?jt.test(e.data)||(n=this._getOrReturnCtx(e,n),h(n,{validation:"duration",code:p.invalid_string,message:s.message}),a.dirty()):s.kind==="ip"?Gt(e.data,s.version)||(n=this._getOrReturnCtx(e,n),h(n,{validation:"ip",code:p.invalid_string,message:s.message}),a.dirty()):s.kind==="jwt"?Jt(e.data,s.alg)||(n=this._getOrReturnCtx(e,n),h(n,{validation:"jwt",code:p.invalid_string,message:s.message}),a.dirty()):s.kind==="cidr"?Yt(e.data,s.version)||(n=this._getOrReturnCtx(e,n),h(n,{validation:"cidr",code:p.invalid_string,message:s.message}),a.dirty()):s.kind==="base64"?Ut.test(e.data)||(n=this._getOrReturnCtx(e,n),h(n,{validation:"base64",code:p.invalid_string,message:s.message}),a.dirty()):s.kind==="base64url"?Wt.test(e.data)||(n=this._getOrReturnCtx(e,n),h(n,{validation:"base64url",code:p.invalid_string,message:s.message}),a.dirty()):S.assertNever(s);return{status:a.value,value:e.data}}_regex(e,r,a){return this.refinement(n=>e.test(n),{validation:r,code:p.invalid_string,...b.errToObj(a)})}_addCheck(e){return new U({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...b.errToObj(e)})}url(e){return this._addCheck({kind:"url",...b.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...b.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...b.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...b.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...b.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...b.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...b.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...b.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...b.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...b.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...b.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...b.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(e==null?void 0:e.offset)??!1,local:(e==null?void 0:e.local)??!1,...b.errToObj(e==null?void 0: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==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...b.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...b.errToObj(e)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...b.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r==null?void 0:r.position,...b.errToObj(r==null?void 0:r.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...b.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...b.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...b.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...b.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...b.errToObj(r)})}nonempty(e){return this.min(1,b.errToObj(e))}trim(){return new U({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new U({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new U({...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(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}}U.create=t=>new U({checks:[],typeName:x.ZodString,coerce:(t==null?void 0:t.coerce)??!1,...k(t)});function Xt(t,e){const r=(t.toString().split(".")[1]||"").length,a=(e.toString().split(".")[1]||"").length,n=r>a?r:a,s=Number.parseInt(t.toFixed(n).replace(".","")),i=Number.parseInt(e.toFixed(n).replace(".",""));return s%i/10**n}class se extends T{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)!==m.number){const s=this._getOrReturnCtx(e);return h(s,{code:p.invalid_type,expected:m.number,received:s.parsedType}),v}let a;const n=new P;for(const s of this._def.checks)s.kind==="int"?S.isInteger(e.data)||(a=this._getOrReturnCtx(e,a),h(a,{code:p.invalid_type,expected:"integer",received:"float",message:s.message}),n.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(a=this._getOrReturnCtx(e,a),h(a,{code:p.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),n.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(a=this._getOrReturnCtx(e,a),h(a,{code:p.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),n.dirty()):s.kind==="multipleOf"?Xt(e.data,s.value)!==0&&(a=this._getOrReturnCtx(e,a),h(a,{code:p.not_multiple_of,multipleOf:s.value,message:s.message}),n.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(a=this._getOrReturnCtx(e,a),h(a,{code:p.not_finite,message:s.message}),n.dirty()):S.assertNever(s);return{status:n.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,b.toString(r))}gt(e,r){return this.setLimit("min",e,!1,b.toString(r))}lte(e,r){return this.setLimit("max",e,!0,b.toString(r))}lt(e,r){return this.setLimit("max",e,!1,b.toString(r))}setLimit(e,r,a,n){return new se({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:a,message:b.toString(n)}]})}_addCheck(e){return new se({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:b.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:b.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:b.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:b.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:b.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:b.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:b.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:b.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:b.toString(e)})}get minValue(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(const 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(const a of this._def.checks){if(a.kind==="finite"||a.kind==="int"||a.kind==="multipleOf")return!0;a.kind==="min"?(r===null||a.value>r)&&(r=a.value):a.kind==="max"&&(e===null||a.value<e)&&(e=a.value)}return Number.isFinite(r)&&Number.isFinite(e)}}se.create=t=>new se({checks:[],typeName:x.ZodNumber,coerce:(t==null?void 0:t.coerce)||!1,...k(t)});class ie extends T{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)!==m.bigint)return this._getInvalidInput(e);let a;const n=new P;for(const s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(a=this._getOrReturnCtx(e,a),h(a,{code:p.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),n.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(a=this._getOrReturnCtx(e,a),h(a,{code:p.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),n.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(a=this._getOrReturnCtx(e,a),h(a,{code:p.not_multiple_of,multipleOf:s.value,message:s.message}),n.dirty()):S.assertNever(s);return{status:n.value,value:e.data}}_getInvalidInput(e){const r=this._getOrReturnCtx(e);return h(r,{code:p.invalid_type,expected:m.bigint,received:r.parsedType}),v}gte(e,r){return this.setLimit("min",e,!0,b.toString(r))}gt(e,r){return this.setLimit("min",e,!1,b.toString(r))}lte(e,r){return this.setLimit("max",e,!0,b.toString(r))}lt(e,r){return this.setLimit("max",e,!1,b.toString(r))}setLimit(e,r,a,n){return new ie({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:a,message:b.toString(n)}]})}_addCheck(e){return new ie({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:b.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:b.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:b.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:b.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:b.toString(r)})}get minValue(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(const 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==null?void 0:t.coerce)??!1,...k(t)});class Oe extends T{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==m.boolean){const a=this._getOrReturnCtx(e);return h(a,{code:p.invalid_type,expected:m.boolean,received:a.parsedType}),v}return q(e.data)}}Oe.create=t=>new Oe({typeName:x.ZodBoolean,coerce:(t==null?void 0:t.coerce)||!1,...k(t)});class ge extends T{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==m.date){const s=this._getOrReturnCtx(e);return h(s,{code:p.invalid_type,expected:m.date,received:s.parsedType}),v}if(Number.isNaN(e.data.getTime())){const s=this._getOrReturnCtx(e);return h(s,{code:p.invalid_date}),v}const a=new P;let n;for(const s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(n=this._getOrReturnCtx(e,n),h(n,{code:p.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),a.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(n=this._getOrReturnCtx(e,n),h(n,{code:p.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),a.dirty()):S.assertNever(s);return{status:a.value,value:new Date(e.data.getTime())}}_addCheck(e){return new ge({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:b.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:b.toString(r)})}get minDate(){let e=null;for(const 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(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e!=null?new Date(e):null}}ge.create=t=>new ge({checks:[],coerce:(t==null?void 0:t.coerce)||!1,typeName:x.ZodDate,...k(t)});class it extends T{_parse(e){if(this._getType(e)!==m.symbol){const a=this._getOrReturnCtx(e);return h(a,{code:p.invalid_type,expected:m.symbol,received:a.parsedType}),v}return q(e.data)}}it.create=t=>new it({typeName:x.ZodSymbol,...k(t)});class De extends T{_parse(e){if(this._getType(e)!==m.undefined){const a=this._getOrReturnCtx(e);return h(a,{code:p.invalid_type,expected:m.undefined,received:a.parsedType}),v}return q(e.data)}}De.create=t=>new De({typeName:x.ZodUndefined,...k(t)});class ye extends T{_parse(e){if(this._getType(e)!==m.null){const a=this._getOrReturnCtx(e);return h(a,{code:p.invalid_type,expected:m.null,received:a.parsedType}),v}return q(e.data)}}ye.create=t=>new ye({typeName:x.ZodNull,...k(t)});class Ve extends T{constructor(){super(...arguments),this._any=!0}_parse(e){return q(e.data)}}Ve.create=t=>new Ve({typeName:x.ZodAny,...k(t)});class oe extends T{constructor(){super(...arguments),this._unknown=!0}_parse(e){return q(e.data)}}oe.create=t=>new oe({typeName:x.ZodUnknown,...k(t)});class te extends T{_parse(e){const r=this._getOrReturnCtx(e);return h(r,{code:p.invalid_type,expected:m.never,received:r.parsedType}),v}}te.create=t=>new te({typeName:x.ZodNever,...k(t)});class Be extends T{_parse(e){if(this._getType(e)!==m.undefined){const a=this._getOrReturnCtx(e);return h(a,{code:p.invalid_type,expected:m.void,received:a.parsedType}),v}return q(e.data)}}Be.create=t=>new Be({typeName:x.ZodVoid,...k(t)});class Z extends T{_parse(e){const{ctx:r,status:a}=this._processInputParams(e),n=this._def;if(r.parsedType!==m.array)return h(r,{code:p.invalid_type,expected:m.array,received:r.parsedType}),v;if(n.exactLength!==null){const i=r.data.length>n.exactLength.value,o=r.data.length<n.exactLength.value;(i||o)&&(h(r,{code:i?p.too_big:p.too_small,minimum:o?n.exactLength.value:void 0,maximum:i?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),a.dirty())}if(n.minLength!==null&&r.data.length<n.minLength.value&&(h(r,{code:p.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),a.dirty()),n.maxLength!==null&&r.data.length>n.maxLength.value&&(h(r,{code:p.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),a.dirty()),r.common.async)return Promise.all([...r.data].map((i,o)=>n.type._parseAsync(new F(r,i,r.path,o)))).then(i=>P.mergeArray(a,i));const s=[...r.data].map((i,o)=>n.type._parseSync(new F(r,i,r.path,o)));return P.mergeArray(a,s)}get element(){return this._def.type}min(e,r){return new Z({...this._def,minLength:{value:e,message:b.toString(r)}})}max(e,r){return new Z({...this._def,maxLength:{value:e,message:b.toString(r)}})}length(e,r){return new Z({...this._def,exactLength:{value:e,message:b.toString(r)}})}nonempty(e){return this.min(1,e)}}Z.create=(t,e)=>new Z({type:t,minLength:null,maxLength:null,exactLength:null,typeName:x.ZodArray,...k(e)});function ue(t){if(t instanceof O){const e={};for(const r in t.shape){const a=t.shape[r];e[r]=V.create(ue(a))}return new O({...t._def,shape:()=>e})}else return t instanceof Z?new Z({...t._def,type:ue(t.element)}):t instanceof V?V.create(ue(t.unwrap())):t instanceof ae?ae.create(ue(t.unwrap())):t instanceof W?W.create(t.items.map(e=>ue(e))):t}class O extends T{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),r=S.objectKeys(e);return this._cached={shape:e,keys:r},this._cached}_parse(e){if(this._getType(e)!==m.object){const u=this._getOrReturnCtx(e);return h(u,{code:p.invalid_type,expected:m.object,received:u.parsedType}),v}const{status:a,ctx:n}=this._processInputParams(e),{shape:s,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof te&&this._def.unknownKeys==="strip"))for(const u in n.data)i.includes(u)||o.push(u);const d=[];for(const u of i){const _=s[u],A=n.data[u];d.push({key:{status:"valid",value:u},value:_._parse(new F(n,A,n.path,u)),alwaysSet:u in n.data})}if(this._def.catchall instanceof te){const u=this._def.unknownKeys;if(u==="passthrough")for(const _ of o)d.push({key:{status:"valid",value:_},value:{status:"valid",value:n.data[_]}});else if(u==="strict")o.length>0&&(h(n,{code:p.unrecognized_keys,keys:o}),a.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const _ of o){const A=n.data[_];d.push({key:{status:"valid",value:_},value:u._parse(new F(n,A,n.path,_)),alwaysSet:_ in n.data})}}return n.common.async?Promise.resolve().then(async()=>{const u=[];for(const _ of d){const A=await _.key,z=await _.value;u.push({key:A,value:z,alwaysSet:_.alwaysSet})}return u}).then(u=>P.mergeObjectSync(a,u)):P.mergeObjectSync(a,d)}get shape(){return this._def.shape()}strict(e){return b.errToObj,new O({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(r,a)=>{var s,i;const n=((i=(s=this._def).errorMap)==null?void 0:i.call(s,r,a).message)??a.defaultError;return r.code==="unrecognized_keys"?{message:b.errToObj(e).message??n}:{message:n}}}:{}})}strip(){return new O({...this._def,unknownKeys:"strip"})}passthrough(){return new O({...this._def,unknownKeys:"passthrough"})}extend(e){return new O({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new O({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 O({...this._def,catchall:e})}pick(e){const r={};for(const a of S.objectKeys(e))e[a]&&this.shape[a]&&(r[a]=this.shape[a]);return new O({...this._def,shape:()=>r})}omit(e){const r={};for(const a of S.objectKeys(this.shape))e[a]||(r[a]=this.shape[a]);return new O({...this._def,shape:()=>r})}deepPartial(){return ue(this)}partial(e){const r={};for(const a of S.objectKeys(this.shape)){const n=this.shape[a];e&&!e[a]?r[a]=n:r[a]=n.optional()}return new O({...this._def,shape:()=>r})}required(e){const r={};for(const a of S.objectKeys(this.shape))if(e&&!e[a])r[a]=this.shape[a];else{let s=this.shape[a];for(;s instanceof V;)s=s._def.innerType;r[a]=s}return new O({...this._def,shape:()=>r})}keyof(){return ot(S.objectKeys(this.shape))}}O.create=(t,e)=>new O({shape:()=>t,unknownKeys:"strip",catchall:te.create(),typeName:x.ZodObject,...k(e)}),O.strictCreate=(t,e)=>new O({shape:()=>t,unknownKeys:"strict",catchall:te.create(),typeName:x.ZodObject,...k(e)}),O.lazycreate=(t,e)=>new O({shape:t,unknownKeys:"strip",catchall:te.create(),typeName:x.ZodObject,...k(e)});class _e extends T{_parse(e){const{ctx:r}=this._processInputParams(e),a=this._def.options;function n(s){for(const o of s)if(o.result.status==="valid")return o.result;for(const o of s)if(o.result.status==="dirty")return r.common.issues.push(...o.ctx.common.issues),o.result;const i=s.map(o=>new j(o.ctx.common.issues));return h(r,{code:p.invalid_union,unionErrors:i}),v}if(r.common.async)return Promise.all(a.map(async s=>{const i={...r,common:{...r.common,issues:[]},parent:null};return{result:await s._parseAsync({data:r.data,path:r.path,parent:i}),ctx:i}})).then(n);{let s;const i=[];for(const d of a){const u={...r,common:{...r.common,issues:[]},parent:null},_=d._parseSync({data:r.data,path:r.path,parent:u});if(_.status==="valid")return _;_.status==="dirty"&&!s&&(s={result:_,ctx:u}),u.common.issues.length&&i.push(u.common.issues)}if(s)return r.common.issues.push(...s.ctx.common.issues),s.result;const o=i.map(d=>new j(d));return h(r,{code:p.invalid_union,unionErrors:o}),v}}get options(){return this._def.options}}_e.create=(t,e)=>new _e({options:t,typeName:x.ZodUnion,...k(e)});const K=t=>t instanceof Re?K(t.schema):t instanceof H?K(t.innerType()):t instanceof we?[t.value]:t instanceof re?t.options:t instanceof ze?S.objectValues(t.enum):t instanceof Ie?K(t._def.innerType):t instanceof De?[void 0]:t instanceof ye?[null]:t instanceof V?[void 0,...K(t.unwrap())]:t instanceof ae?[null,...K(t.unwrap())]:t instanceof He||t instanceof Se?K(t.unwrap()):t instanceof Te?K(t._def.innerType):[];class Fe extends T{_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==m.object)return h(r,{code:p.invalid_type,expected:m.object,received:r.parsedType}),v;const a=this.discriminator,n=r.data[a],s=this.optionsMap.get(n);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}):(h(r,{code:p.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[a]}),v)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,a){const n=new Map;for(const s of r){const i=K(s.shape[e]);if(!i.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of i){if(n.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);n.set(o,s)}}return new Fe({typeName:x.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:n,...k(a)})}}function Ue(t,e){const r=ee(t),a=ee(e);if(t===e)return{valid:!0,data:t};if(r===m.object&&a===m.object){const n=S.objectKeys(e),s=S.objectKeys(t).filter(o=>n.indexOf(o)!==-1),i={...t,...e};for(const o of s){const d=Ue(t[o],e[o]);if(!d.valid)return{valid:!1};i[o]=d.data}return{valid:!0,data:i}}else if(r===m.array&&a===m.array){if(t.length!==e.length)return{valid:!1};const n=[];for(let s=0;s<t.length;s++){const i=t[s],o=e[s],d=Ue(i,o);if(!d.valid)return{valid:!1};n.push(d.data)}return{valid:!0,data:n}}else return r===m.date&&a===m.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}class ve extends T{_parse(e){const{status:r,ctx:a}=this._processInputParams(e),n=(s,i)=>{if(tt(s)||tt(i))return v;const o=Ue(s.value,i.value);return o.valid?((rt(s)||rt(i))&&r.dirty(),{status:r.value,value:o.data}):(h(a,{code:p.invalid_intersection_types}),v)};return a.common.async?Promise.all([this._def.left._parseAsync({data:a.data,path:a.path,parent:a}),this._def.right._parseAsync({data:a.data,path:a.path,parent:a})]).then(([s,i])=>n(s,i)):n(this._def.left._parseSync({data:a.data,path:a.path,parent:a}),this._def.right._parseSync({data:a.data,path:a.path,parent:a}))}}ve.create=(t,e,r)=>new ve({left:t,right:e,typeName:x.ZodIntersection,...k(r)});class W extends T{_parse(e){const{status:r,ctx:a}=this._processInputParams(e);if(a.parsedType!==m.array)return h(a,{code:p.invalid_type,expected:m.array,received:a.parsedType}),v;if(a.data.length<this._def.items.length)return h(a,{code:p.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),v;!this._def.rest&&a.data.length>this._def.items.length&&(h(a,{code:p.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());const s=[...a.data].map((i,o)=>{const d=this._def.items[o]||this._def.rest;return d?d._parse(new F(a,i,a.path,o)):null}).filter(i=>!!i);return a.common.async?Promise.all(s).then(i=>P.mergeArray(r,i)):P.mergeArray(r,s)}get items(){return this._def.items}rest(e){return new W({...this._def,rest:e})}}W.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new W({items:t,typeName:x.ZodTuple,rest:null,...k(e)})};class xe extends T{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:r,ctx:a}=this._processInputParams(e);if(a.parsedType!==m.object)return h(a,{code:p.invalid_type,expected:m.object,received:a.parsedType}),v;const n=[],s=this._def.keyType,i=this._def.valueType;for(const o in a.data)n.push({key:s._parse(new F(a,o,a.path,o)),value:i._parse(new F(a,a.data[o],a.path,o)),alwaysSet:o in a.data});return a.common.async?P.mergeObjectAsync(r,n):P.mergeObjectSync(r,n)}get element(){return this._def.valueType}static create(e,r,a){return r instanceof T?new xe({keyType:e,valueType:r,typeName:x.ZodRecord,...k(a)}):new xe({keyType:U.create(),valueType:e,typeName:x.ZodRecord,...k(r)})}}class We extends T{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:r,ctx:a}=this._processInputParams(e);if(a.parsedType!==m.map)return h(a,{code:p.invalid_type,expected:m.map,received:a.parsedType}),v;const n=this._def.keyType,s=this._def.valueType,i=[...a.data.entries()].map(([o,d],u)=>({key:n._parse(new F(a,o,a.path,[u,"key"])),value:s._parse(new F(a,d,a.path,[u,"value"]))}));if(a.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const d of i){const u=await d.key,_=await d.value;if(u.status==="aborted"||_.status==="aborted")return v;(u.status==="dirty"||_.status==="dirty")&&r.dirty(),o.set(u.value,_.value)}return{status:r.value,value:o}})}else{const o=new Map;for(const d of i){const u=d.key,_=d.value;if(u.status==="aborted"||_.status==="aborted")return v;(u.status==="dirty"||_.status==="dirty")&&r.dirty(),o.set(u.value,_.value)}return{status:r.value,value:o}}}}We.create=(t,e,r)=>new We({valueType:e,keyType:t,typeName:x.ZodMap,...k(r)});class pe extends T{_parse(e){const{status:r,ctx:a}=this._processInputParams(e);if(a.parsedType!==m.set)return h(a,{code:p.invalid_type,expected:m.set,received:a.parsedType}),v;const n=this._def;n.minSize!==null&&a.data.size<n.minSize.value&&(h(a,{code:p.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),r.dirty()),n.maxSize!==null&&a.data.size>n.maxSize.value&&(h(a,{code:p.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),r.dirty());const s=this._def.valueType;function i(d){const u=new Set;for(const _ of d){if(_.status==="aborted")return v;_.status==="dirty"&&r.dirty(),u.add(_.value)}return{status:r.value,value:u}}const o=[...a.data.values()].map((d,u)=>s._parse(new F(a,d,a.path,u)));return a.common.async?Promise.all(o).then(d=>i(d)):i(o)}min(e,r){return new pe({...this._def,minSize:{value:e,message:b.toString(r)}})}max(e,r){return new pe({...this._def,maxSize:{value:e,message:b.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}}pe.create=(t,e)=>new pe({valueType:t,minSize:null,maxSize:null,typeName:x.ZodSet,...k(e)});class ke extends T{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==m.function)return h(r,{code:p.invalid_type,expected:m.function,received:r.parsedType}),v;function a(o,d){return Le({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,$e(),me].filter(u=>!!u),issueData:{code:p.invalid_arguments,argumentsError:d}})}function n(o,d){return Le({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,$e(),me].filter(u=>!!u),issueData:{code:p.invalid_return_type,returnTypeError:d}})}const s={errorMap:r.common.contextualErrorMap},i=r.data;if(this._def.returns instanceof fe){const o=this;return q(async function(...d){const u=new j([]),_=await o._def.args.parseAsync(d,s).catch(ne=>{throw u.addIssue(a(d,ne)),u}),A=await Reflect.apply(i,this,_);return await o._def.returns._def.type.parseAsync(A,s).catch(ne=>{throw u.addIssue(n(A,ne)),u})})}else{const o=this;return q(function(...d){const u=o._def.args.safeParse(d,s);if(!u.success)throw new j([a(d,u.error)]);const _=Reflect.apply(i,this,u.data),A=o._def.returns.safeParse(_,s);if(!A.success)throw new j([n(_,A.error)]);return A.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new ke({...this._def,args:W.create(e).rest(oe.create())})}returns(e){return new ke({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,r,a){return new ke({args:e||W.create([]).rest(oe.create()),returns:r||oe.create(),typeName:x.ZodFunction,...k(a)})}}class Re extends T{get schema(){return this._def.getter()}_parse(e){const{ctx:r}=this._processInputParams(e);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}}Re.create=(t,e)=>new Re({getter:t,typeName:x.ZodLazy,...k(e)});class we extends T{_parse(e){if(e.data!==this._def.value){const r=this._getOrReturnCtx(e);return h(r,{received:r.data,code:p.invalid_literal,expected:this._def.value}),v}return{status:"valid",value:e.data}}get value(){return this._def.value}}we.create=(t,e)=>new we({value:t,typeName:x.ZodLiteral,...k(e)});function ot(t,e){return new re({values:t,typeName:x.ZodEnum,...k(e)})}class re extends T{_parse(e){if(typeof e.data!="string"){const r=this._getOrReturnCtx(e),a=this._def.values;return h(r,{expected:S.joinValues(a),received:r.parsedType,code:p.invalid_type}),v}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const r=this._getOrReturnCtx(e),a=this._def.values;return h(r,{received:r.data,code:p.invalid_enum_value,options:a}),v}return q(e.data)}get options(){return this._def.values}get enum(){const e={};for(const r of this._def.values)e[r]=r;return e}get Values(){const e={};for(const r of this._def.values)e[r]=r;return e}get Enum(){const e={};for(const r of this._def.values)e[r]=r;return e}extract(e,r=this._def){return re.create(e,{...this._def,...r})}exclude(e,r=this._def){return re.create(this.options.filter(a=>!e.includes(a)),{...this._def,...r})}}re.create=ot;class ze extends T{_parse(e){const r=S.getValidEnumValues(this._def.values),a=this._getOrReturnCtx(e);if(a.parsedType!==m.string&&a.parsedType!==m.number){const n=S.objectValues(r);return h(a,{expected:S.joinValues(n),received:a.parsedType,code:p.invalid_type}),v}if(this._cache||(this._cache=new Set(S.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const n=S.objectValues(r);return h(a,{received:a.data,code:p.invalid_enum_value,options:n}),v}return q(e.data)}get enum(){return this._def.values}}ze.create=(t,e)=>new ze({values:t,typeName:x.ZodNativeEnum,...k(e)});class fe extends T{unwrap(){return this._def.type}_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==m.promise&&r.common.async===!1)return h(r,{code:p.invalid_type,expected:m.promise,received:r.parsedType}),v;const a=r.parsedType===m.promise?r.data:Promise.resolve(r.data);return q(a.then(n=>this._def.type.parseAsync(n,{path:r.path,errorMap:r.common.contextualErrorMap})))}}fe.create=(t,e)=>new fe({type:t,typeName:x.ZodPromise,...k(e)});class H extends T{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===x.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:r,ctx:a}=this._processInputParams(e),n=this._def.effect||null,s={addIssue:i=>{h(a,i),i.fatal?r.abort():r.dirty()},get path(){return a.path}};if(s.addIssue=s.addIssue.bind(s),n.type==="preprocess"){const i=n.transform(a.data,s);if(a.common.async)return Promise.resolve(i).then(async o=>{if(r.value==="aborted")return v;const d=await this._def.schema._parseAsync({data:o,path:a.path,parent:a});return d.status==="aborted"?v:d.status==="dirty"||r.value==="dirty"?be(d.value):d});{if(r.value==="aborted")return v;const o=this._def.schema._parseSync({data:i,path:a.path,parent:a});return o.status==="aborted"?v:o.status==="dirty"||r.value==="dirty"?be(o.value):o}}if(n.type==="refinement"){const i=o=>{const d=n.refinement(o,s);if(a.common.async)return Promise.resolve(d);if(d instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(a.common.async===!1){const o=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});return o.status==="aborted"?v:(o.status==="dirty"&&r.dirty(),i(o.value),{status:r.value,value:o.value})}else return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then(o=>o.status==="aborted"?v:(o.status==="dirty"&&r.dirty(),i(o.value).then(()=>({status:r.value,value:o.value}))))}if(n.type==="transform")if(a.common.async===!1){const i=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});if(!le(i))return v;const o=n.transform(i.value,s);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:o}}else return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then(i=>le(i)?Promise.resolve(n.transform(i.value,s)).then(o=>({status:r.value,value:o})):v);S.assertNever(n)}}H.create=(t,e,r)=>new H({schema:t,typeName:x.ZodEffects,effect:e,...k(r)}),H.createWithPreprocess=(t,e,r)=>new H({schema:e,effect:{type:"preprocess",transform:t},typeName:x.ZodEffects,...k(r)});class V extends T{_parse(e){return this._getType(e)===m.undefined?q(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}V.create=(t,e)=>new V({innerType:t,typeName:x.ZodOptional,...k(e)});class ae extends T{_parse(e){return this._getType(e)===m.null?q(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}ae.create=(t,e)=>new ae({innerType:t,typeName:x.ZodNullable,...k(e)});class Ie extends T{_parse(e){const{ctx:r}=this._processInputParams(e);let a=r.data;return r.parsedType===m.undefined&&(a=this._def.defaultValue()),this._def.innerType._parse({data:a,path:r.path,parent:r})}removeDefault(){return this._def.innerType}}Ie.create=(t,e)=>new Ie({innerType:t,typeName:x.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...k(e)});class Te extends T{_parse(e){const{ctx:r}=this._processInputParams(e),a={...r,common:{...r.common,issues:[]}},n=this._def.innerType._parse({data:a.data,path:a.path,parent:{...a}});return Ne(n)?n.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new j(a.common.issues)},input:a.data})})):{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new j(a.common.issues)},input:a.data})}}removeCatch(){return this._def.innerType}}Te.create=(t,e)=>new Te({innerType:t,typeName:x.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...k(e)});class Ke extends T{_parse(e){if(this._getType(e)!==m.nan){const a=this._getOrReturnCtx(e);return h(a,{code:p.invalid_type,expected:m.nan,received:a.parsedType}),v}return{status:"valid",value:e.data}}}Ke.create=t=>new Ke({typeName:x.ZodNaN,...k(t)});class He extends T{_parse(e){const{ctx:r}=this._processInputParams(e),a=r.data;return this._def.type._parse({data:a,path:r.path,parent:r})}unwrap(){return this._def.type}}class Me extends T{_parse(e){const{status:r,ctx:a}=this._processInputParams(e);if(a.common.async)return(async()=>{const s=await this._def.in._parseAsync({data:a.data,path:a.path,parent:a});return s.status==="aborted"?v:s.status==="dirty"?(r.dirty(),be(s.value)):this._def.out._parseAsync({data:s.value,path:a.path,parent:a})})();{const n=this._def.in._parseSync({data:a.data,path:a.path,parent:a});return n.status==="aborted"?v:n.status==="dirty"?(r.dirty(),{status:"dirty",value:n.value}):this._def.out._parseSync({data:n.value,path:a.path,parent:a})}}static create(e,r){return new Me({in:e,out:r,typeName:x.ZodPipeline})}}class Se extends T{_parse(e){const r=this._def.innerType._parse(e),a=n=>(le(n)&&(n.value=Object.freeze(n.value)),n);return Ne(r)?r.then(n=>a(n)):a(r)}unwrap(){return this._def.innerType}}Se.create=(t,e)=>new Se({innerType:t,typeName:x.ZodReadonly,...k(e)});var 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={}));const c=U.create,f=se.create,B=ie.create,w=Oe.create,ct=ye.create,y=oe.create;te.create;const C=Z.create,l=O.create,I=_e.create;ve.create;const Qt=W.create,g=xe.create,er=we.create,dt=re.create;fe.create,V.create,ae.create;const G=H.createWithPreprocess;function D(t,e=0,r=2){if(e>r)return"...";if(t instanceof O){const a=t.shape,n=Object.keys(a).filter(i=>!i.startsWith("__"));return n.length===0?"{ }":e>=r-1?"{ ... }":`{ ${n.map(i=>{const o=a[i],d=o instanceof V,u=D(d?o.unwrap():o,e+1,r);return`${i}${d?"?":""}: ${u}`}).join(", ")} }`}if(t instanceof _e)return t.options.map(a=>D(a,e,r)).join(" or ");if(t instanceof U)return"string";if(t instanceof se)return"number";if(t instanceof Oe)return"boolean";if(t instanceof ie)return"bigint";if(t instanceof ye)return"null";if(t instanceof Z){const a=D(t.element,e+1,r);return a==="unknown"||a==="any"?"array":`${a}[]`}if(t instanceof W)return`[${t.items.map(a=>D(a,e+1,r)).join(", ")}]`;if(t instanceof xe){const a=D(t._def.valueType,e+1,r);return a==="unknown"||a==="any"?"{ [key: string]: unknown }":`{ [key: string]: ${a} }`}return t instanceof V?`${D(t.unwrap(),e,r)}?`:t instanceof we?JSON.stringify(t.value):t instanceof re?t.options.map(a=>`"${a}"`).join(" | "):t instanceof Ve?"any":t instanceof oe?"unknown":t instanceof Be?"void":t instanceof De?"undefined":t instanceof H?D(t.innerType(),e,r):t instanceof Ie?D(t.removeDefault(),e,r):t instanceof ae?`${D(t.unwrap(),e,r)} | null`:t instanceof Re?"lazy":t instanceof fe?`Promise<${D(t.unwrap(),e+1,r)}>`:t instanceof ke?"function":t instanceof ge?"Date":t instanceof We?"Map":t instanceof pe?"Set":t instanceof ve?`${D(t._def.left,e,r)} & ${D(t._def.right,e,r)}`:t instanceof Fe?t.options.map(a=>D(a,e,r)).join(" or "):t instanceof He?D(t.unwrap(),e,r):t instanceof Ke?"NaN":t instanceof Te?D(t.removeCatch(),e,r):t instanceof Me?D(t._def.in,e,r):t instanceof Se?`readonly ${D(t.unwrap(),e,r)}`:"unknown"}function tr(t){return t===null?"null":t===void 0?"undefined":Array.isArray(t)?"array":typeof t}function rr(t,e,r,a){const n=r.filter(o=>o.path.length===0),s=r.filter(o=>o.path.length>0);if(n.length>0&&s.length===0){const o=n.some(u=>u.code==="custom"),d=n.some(u=>u.code!=="invalid_type"&&u.code!=="invalid_literal"&&u.code!=="invalid_union");if(!o&&!d){const u=D(e),_=tr(a);return`Invalid parameters for ${t}: expected ${u}${u==="{ }"?" or no args":""}, received ${_}`}}const i=r.map(o=>`at '${o.path.length>0?o.path.join("."):"root"}': ${o.message}`);return`Invalid parameters for ${t}: ${i.join("; ")}`}async function ar(t,e,r,a,n){const s=t.safeParse(Ae(a));if(!s.success)return{ok:!1,error:{message:rr(n,t,s.error.issues,a),code:"E_INVALID_PARAMS",category:"validation"}};try{const i=await r(s.data),o=e.safeParse(i);if(!o.success){const d=o.error.issues.map(u=>{const _=u.path.join(".");return`invalid return value${_?` at '${_}'`:""} (${u.message})`});return{ok:!1,error:{message:`Invalid return value for ${n}: ${d.join("; ")}`,code:"E_INVALID_RETURN",category:"validation"}}}return{ok:!0,value:o.data}}catch(i){const o=Ct(i),d=o.code==="E_EXTENSION"&&(typeof i!="object"||i===null||!("code"in i));return{ok:!1,error:{...o,code:d?"E_HANDLER":o.code,message:`${n}: ${o.message}`}}}}const lt=new Map,Pe=new Map;function nr(t){lt.set(t.registryAction,t)}function Ge(t){return lt.get(t)}function sr(t){for(const e of t)nr(e);try{chrome.runtime.sendMessage({type:"contentScriptReady"})}catch{}}function ir(t){const e=Pe.get(t);return e?(e.abort(),Pe.delete(t),!0):!1}async function or(t,e,r,a,n){const s=Ge(t);if(!s)return{ok:!1,error:{message:`No schema registered for content-script action: ${t}`,code:"E_INTERNAL"}};const i=new AbortController;n&&Pe.set(n,i);try{return await ar(s.params,s.returns,async o=>r(o,i.signal),Ae(a),t)}finally{n&&Pe.delete(n)}}const $=()=>I([B(),f().finite()]).transform(t=>BigInt(t));l({key:c().describe("Storage key to retrieve")}),l({key:c().describe("Storage key to set"),value:c().describe("Value to store")}),l({key:c().describe("Storage key to delete")}),l({});const cr=l({items:g(c()).describe("Record of key-value string pairs to store")});G(t=>t!==null&&typeof t=="object"&&!Array.isArray(t)&&!("items"in t)?{items:t}:t,cr);const dr=l({keys:C(c()).describe("Array of storage keys to retrieve"),defaults:g(c()).optional().describe("Default string values for missing keys")});G(t=>Array.isArray(t)?{keys:t}:t,dr),l({});const lr=l({keys:C(c()).describe("Array of storage keys to delete")});G(t=>Array.isArray(t)?{keys:t}:t,lr),l({}),l({}),I([Qt([I([l({text:c()}),c()])]),l({text:c().optional(),value:c().optional()})]),l({url:c().describe("URL to fetch"),method:c().default("GET").describe("HTTP method (GET, POST, PUT, DELETE, etc.)"),headers:g(c()).default({}).describe("Request headers as key-value pairs"),body:c().nullable().default(null).describe("Request body string"),timeout:$().default(30000n).describe("Timeout in milliseconds")}),l({duration:$().describe("Duration to sleep in milliseconds")});const he=()=>c().regex(/^e\d+$/),ur='use { refId: "e2" } or { label: "..." } object form, not positional arguments',Je=(t,e)=>{if(t.__invalidPositional!==void 0){e.addIssue({code:p.custom,message:ur});return}!t.refId&&!t.label&&e.addIssue({code:p.custom,message:"Either refId or label is required"})},ut=(t,e)=>{t.x!==void 0||t.y!==void 0||Je(t,e)},R=t=>G(e=>typeof e=="string"||typeof e=="number"?{__invalidPositional:e}:e,l({__invalidPositional:I([c(),f()]).optional().describe("Internal flag for positional argument rejection"),refId:he().optional().describe("Element reference ID (e.g. e2)"),label:c().optional().describe("Human-readable element label"),...t}).superRefine(Je)),Ee={tabId:I([f(),B()]).optional().describe("Target tab ID")},ce=t=>G(e=>typeof e=="string"||typeof e=="number"?{__invalidPositional:e}:e,l({__invalidPositional:I([c(),f()]).optional().describe("Internal flag for positional argument rejection"),...Ee,refId:he().optional().describe("Element reference ID (e.g. e2)"),label:c().optional().describe("Human-readable element label"),...t}).superRefine(Je));l({}),l({}),l({url:c().describe("URL to navigate to"),timeout:$().optional().describe("Navigation timeout in milliseconds")});const pr=l({}),fr=l({});l({}),l({duration:$().default(1000n).describe("Duration to wait in milliseconds")});const hr=R(),mr=R({value:c().describe("Value to fill into the element")}),br=R({text:c().describe("Text to type into the element")}),gr=R({text:c().describe("Text to append into the element")}),yr=l({key:c().describe("Key to press (e.g. Enter, Escape, ArrowDown)")}),_r=R({value:c().describe("Value to select in the dropdown")}),vr=R({checked:w().optional().describe("Desired checked state (true to check, false to uncheck)")}),xr=R(),kr=l({}),wr=l({direction:c().default("down").describe("Scroll direction: up, down, left, or right"),amount:f().default(300).describe("Pixels to scroll")}),Ir=G(t=>typeof t=="string"||typeof t=="number"?{__invalidPositional:t}:t,l({__invalidPositional:I([c(),f()]).optional().describe("Internal flag for positional argument rejection"),refId:he().optional().describe("Element reference ID (e.g. e2)"),label:c().optional().describe("Human-readable element label"),x:f().optional().describe("X coordinate to scroll to"),y:f().optional().describe("Y coordinate to scroll to")}).superRefine(ut)),Tr=R(),Sr=l({selector:c().describe("CSS selector to find elements")}),Er=l({selector:c().describe("CSS selector to wait for"),timeout:$().default(30000n).describe("Timeout in milliseconds")}),Ar=l({fields:C(c()).describe("Array of field names to extract")}),Cr=G(t=>Array.isArray(t)?{fields:t}:t,Ar);I([f(),C(l({}).passthrough()),l({}).passthrough()]),l({}),l({active:w().optional().describe("Whether the tabs are active"),currentWindow:w().optional().describe("Whether the tabs are in the current window"),url:c().optional().describe("URL pattern to match tabs against")}).passthrough(),G(t=>typeof t=="string"?{url:t}:t,l({url:c().optional().describe("URL to open in the new tab"),active:w().optional().describe("Whether to focus the new tab")})),I([f(),C(l({id:f().optional(),tabId:f().optional(),tab_id:f().optional()}).passthrough()),l({id:f().optional(),tabId:f().optional(),tab_id:f().optional()}).passthrough()]),l({tabId:I([f(),B()]).optional().describe("Target tab ID"),script:c().optional().describe("Script to execute")}).passthrough();const Nr=ce(),Or=ce({value:c().describe("Value to fill into the element")}),Dr=G(t=>typeof t=="string"||typeof t=="number"?{__invalidPositional:t}:t,l({__invalidPositional:I([c(),f()]).optional().describe("Internal flag for positional argument rejection"),...Ee,refId:he().optional().describe("Element reference ID (e.g. e2)"),label:c().optional().describe("Human-readable element label"),x:f().optional().describe("X coordinate to scroll to"),y:f().optional().describe("Y coordinate to scroll to")}).superRefine(ut)),Rr=ce({text:c().describe("Text to type into the element")}),Mr=l({...Ee,key:c().describe("Key to press (e.g. Enter, Escape, ArrowDown)")}),Pr=ce({value:c().describe("Value to select in the dropdown")}),qr=ce({checked:w().optional().describe("Desired checked state (true to check, false to uncheck)")}),jr=ce(),$r=l({...Ee}),Lr=l({...Ee,direction:c().default("down").describe("Scroll direction: up, down, left, or right"),amount:f().default(300).describe("Pixels to scroll")}),Zr=ce(),Vr=l({tabId:I([f(),B()]).optional().describe("Target tab ID"),script:c().optional().describe("Script to evaluate"),code:c().optional().describe("Alternative script code"),js:c().optional().describe("Alternative JS code")}).passthrough(),Br=l({tabId:I([f(),B()]).optional().describe("Target tab ID")}).passthrough(),Fr=l({tabId:I([f(),B()]).optional().describe("Target tab ID")}).passthrough();l({tabId:I([f(),B()]).optional().describe("Target tab ID"),timeout:f().optional().describe("Timeout in milliseconds")}).passthrough();const Ur=l({tabId:I([f(),B()]).optional().describe("Target tab ID"),url:c().optional().describe("URL to fetch"),options:l({}).passthrough().optional().describe("Fetch options")}).passthrough(),Wr=l({tabId:I([f(),B()]).optional().describe("Target tab ID"),max_nodes:f().optional().describe("Maximum nodes to include"),options:l({}).passthrough().optional().describe("Snapshot options")}).passthrough(),zr=l({tabId:I([f(),B()]).optional().describe("Target tab ID"),max_nodes:f().optional().describe("Maximum nodes to include"),options:l({}).passthrough().optional().describe("Snapshot options")}).passthrough(),Kr=l({tabId:I([f(),B()]).optional().describe("Target tab ID"),max_nodes:f().optional().describe("Maximum nodes to include"),options:l({}).passthrough().optional().describe("Snapshot options")}).passthrough();R(),R(),R({value:c().optional().describe("Value to fill into the element")}),R({text:c().optional().describe("Text to type into the element")}),l({key:c().optional().describe("Key to press (e.g. Enter, Escape, ArrowDown)")}),R({value:c().optional().describe("Value to select in the dropdown")}),R({checked:w().optional().describe("Desired checked state (true to check, false to uncheck)")}),R(),l({}),l({direction:c().optional().describe("Scroll direction: up, down, left, or right"),amount:f().optional().describe("Pixels to scroll")}),R(),R({text:c().optional().describe("Text to append into the element")}),l({}),l({}),l({duration:$().default(1000n).describe("Duration to wait in milliseconds")}),l({interactive_only:w().default(!1).describe("Only include interactive elements"),max_nodes:$().default(500n).describe("Maximum number of nodes to include in snapshot")}),l({interactive_only:w().default(!1).describe("Only include interactive elements"),max_nodes:$().default(500n).describe("Maximum number of nodes to include in snapshot")}),l({interactive_only:w().default(!1).describe("Only include interactive elements"),max_nodes:$().default(500n).describe("Maximum number of nodes to include in snapshot")}),l({interactive_only:w().default(!1).describe("Only include interactive elements"),max_nodes:$().default(500n).describe("Maximum number of nodes to include in snapshot")}),l({snapshot:l({}).passthrough().describe("Raw DOM snapshot data to format"),format:c().optional().describe("Output format (e.g. markdown, html)")});const pt=l({max_nodes:f().optional().describe("Maximum nodes to include"),options:l({}).passthrough().optional().describe("Snapshot options")}).passthrough(),Hr=l({max_nodes:f().optional().describe("Maximum nodes to include"),options:l({}).passthrough().optional().describe("Snapshot options")}).passthrough(),Gr=l({max_nodes:f().optional().describe("Maximum nodes to include"),options:l({}).passthrough().optional().describe("Snapshot options")}).passthrough();l({path:c().describe("File or directory path")}),l({from:c().describe("Source path"),to:c().describe("Destination path")}),l({path:c().describe("File path to write to"),data:c().describe("Data to write")}),l({path:c().describe("File path to read from"),offset:$().describe("Byte offset to start reading"),len:f().describe("Number of bytes to read")}),l({path:c().describe("File path to update"),offset:$().describe("Byte offset to start writing"),data:c().describe("Data to write")}),l({path:c().describe("File path to hash"),algo:c().default("sha256").describe("Hash algorithm (e.g. sha256, md5)")}),g(y()),g(y()),g(y()),g(y()),I([f(),g(y())]),I([f(),g(y())]),g(y()),g(y()),g(y()),I([c(),g(y())]),g(y()),g(y()),g(y()),g(y()),g(y()),I([c(),f(),g(y())]),g(y()),g(y()),g(y()),I([f(),g(y())]),g(y()),g(y()),g(y()),g(y()),g(y()),C(y()),I([c(),g(y())]),g(y()),I([c(),g(y())]),g(y()),I([c(),g(y())]),g(y()),I([c(),g(y())]),g(y()),g(y()),I([f(),g(y())]),g(y()),g(y()),I([f(),g(y())]),g(y()),I([c(),f(),g(y())]),g(y()),g(y()),g(y()),g(y()),I([f(),g(y())]),I([f(),g(y())]),I([f(),g(y())]),I([f(),g(y())]),I([f(),g(y())]),g(y()),g(y()),g(y()),l({action:c().describe("Host action name"),params:l({}).passthrough().optional().describe("Parameters for the host action")}).passthrough();const Jr=I([c(),f(),w(),ct(),C(y()),g(y())]),E=l({ok:er(!0).describe("Whether the action succeeded"),action:c().describe("Action identifier (e.g. 'page_fill')"),refId:he().optional().describe("Element reference ID that was acted upon (e.g. e2)"),tag:c().optional().describe("HTML tag name of the element"),role:c().optional().describe("ARIA role of the element"),name:c().optional().describe("Accessible name of the element"),value:c().optional().describe("Final value of the element after the action"),checked:w().optional().describe("Checked state after the action"),disabled:w().optional().describe("Whether the element is disabled"),readOnly:w().optional().describe("Whether the element is read-only"),text:c().optional().describe("Text content of the element"),key:c().optional().describe("Key that was pressed (for press actions)"),direction:c().optional().describe("Scroll direction (for scroll actions)"),amount:f().optional().describe("Scroll amount in pixels (for scroll actions)")});I([E,ct()]);const ft=l({status:f().describe("HTTP response status code"),ok:w().describe("Whether the response status is 2xx"),headers:g(c()).describe("Response headers as key-value pairs"),body:c().describe("Response body as string")});l({data:l({}).passthrough().describe("Structured snapshot data"),text:c().describe("Plain text representation of the snapshot")}),l({}),l({tabId:f(),url:c(),title:c(),contentScript:dt(["connected","missing"]),scripting:dt(["ok","blocked"]),mutationsReady:w(),hint:c().optional(),recovery:C(c()).optional()});const Yr=Jr,Xr=l({refId:he().describe("Element reference ID (e.g. e2)"),role:c().describe("ARIA role of the element"),tag:c().describe("HTML tag name"),name:c().optional().describe("Accessible name of the element"),value:c().optional().describe("Element value"),checked:w().optional().describe("Checked state"),disabled:w().optional().describe("Whether the element is disabled"),readOnly:w().optional().describe("Whether the element is read-only")}),Ye=l({text:c().describe("Plain text representation of the page"),nodes:C(Xr).describe("Array of interactive nodes"),url:c().describe("Current page URL"),title:c().describe("Current page title"),viewport:l({width:f().describe("Viewport width in pixels"),height:f().describe("Viewport height in pixels")}).describe("Viewport dimensions")}),ht=l({id:f().optional().describe("Tab ID"),tabId:f().optional().describe("Tab ID (added by runner)"),index:f().optional().describe("Tab index in the window"),windowId:f().optional().describe("Window ID"),url:c().optional().describe("Tab URL"),title:c().optional().describe("Tab title"),status:c().optional().describe("Tab status (loading or complete)"),active:w().optional().describe("Whether the tab is active"),pinned:w().optional().describe("Whether the tab is pinned"),highlighted:w().optional().describe("Whether the tab is highlighted"),incognito:w().optional().describe("Whether the tab is incognito"),favIconUrl:c().optional().describe("Favicon URL"),audible:w().optional().describe("Whether the tab is audible"),groupId:f().optional().describe("Group ID"),openerTabId:f().optional().describe("Opener tab ID"),discarded:w().optional().describe("Whether the tab is discarded"),autoDiscardable:w().optional().describe("Whether the tab is auto-discardable"),width:f().optional().describe("Tab width"),height:f().optional().describe("Tab height"),sessionId:c().optional().describe("Session ID")}).passthrough(),Qr=C(ht),mt=l({id:f().optional().describe("Window ID"),focused:w().optional().describe("Whether the window is focused"),top:f().optional().describe("Window top position"),left:f().optional().describe("Window left position"),width:f().optional().describe("Window width"),height:f().optional().describe("Window height"),tabs:Qr.optional().describe("Array of tabs in the window"),incognito:w().optional().describe("Whether the window is incognito"),type:c().optional().describe("Window type"),state:c().optional().describe("Window state"),alwaysOnTop:w().optional().describe("Whether the window is always on top"),sessionId:c().optional().describe("Session ID")}).passthrough();C(mt);const ea=l({name:c().describe("Cookie name"),value:c().describe("Cookie value"),domain:c().optional().describe("Cookie domain"),hostOnly:w().optional().describe("Whether the cookie is host-only"),path:c().optional().describe("Cookie path"),secure:w().optional().describe("Whether the cookie is secure"),httpOnly:w().optional().describe("Whether the cookie is HTTP-only"),sameSite:c().optional().describe("SameSite policy"),session:w().optional().describe("Whether the cookie is a session cookie"),expirationDate:f().optional().describe("Expiration date as Unix timestamp"),storeId:c().optional().describe("Store ID")}).nullable();C(ea.nullable().unwrap());const ta=l({id:c().describe("Bookmark ID"),parentId:c().optional().describe("Parent folder ID"),index:f().optional().describe("Bookmark index"),url:c().optional().describe("Bookmark URL"),title:c().describe("Bookmark title"),dateAdded:f().optional().describe("Date added"),dateGroupModified:f().optional().describe("Date group modified"),children:C(l({id:c()}).passthrough()).optional().describe("Child bookmarks")}).passthrough();C(ta);const ra=l({id:c().describe("History item ID"),url:c().optional().describe("URL"),title:c().optional().describe("Title"),lastVisitTime:f().optional().describe("Last visit time"),visitCount:f().optional().describe("Visit count"),typedCount:f().optional().describe("Typed count")}).passthrough();C(ra);const aa=l({frameId:f().describe("Frame ID"),result:y().optional().describe("Script result")});C(aa),c(),w(),I([c(),f()]),w();const na=l({id:f().optional().describe("Group ID"),collapsed:w().optional().describe("Whether the group is collapsed"),color:c().optional().describe("Group color"),title:c().optional().describe("Group title"),windowId:f().optional().describe("Window ID")}).passthrough();C(na);const sa=l({lastModified:f().optional().describe("Last modified time"),tab:ht.optional().describe("Tab info"),window:mt.optional().describe("Window info")}).passthrough(),ia=C(sa),oa=l({deviceName:c().optional().describe("Device name"),sessions:ia.optional().describe("Sessions")}).passthrough();C(oa);const ca=l({id:f().optional().describe("Download ID"),url:c().optional().describe("Download URL"),filename:c().optional().describe("Filename"),startTime:c().optional().describe("Start time"),endTime:c().optional().describe("End time"),state:c().optional().describe("Download state"),danger:c().optional().describe("Danger type"),paused:w().optional().describe("Whether the download is paused"),error:c().optional().describe("Error message"),bytesReceived:f().optional().describe("Bytes received"),totalBytes:f().optional().describe("Total bytes"),fileSize:f().optional().describe("File size"),mime:c().optional().describe("MIME type"),incognito:w().optional().describe("Whether the download is incognito"),referrer:c().optional().describe("Referrer URL"),byExtensionId:c().optional().describe("Extension ID"),byExtensionName:c().optional().describe("Extension name")}).passthrough();C(ca),f(),l({archName:c().describe("CPU architecture"),modelName:c().describe("CPU model"),numOfProcessors:f().describe("Number of processors"),features:C(c()).describe("CPU features")}),l({capacity:f().describe("Total memory capacity"),availableCapacity:f().describe("Available memory capacity")}),C(l({id:c().describe("Storage ID"),name:c().describe("Storage name"),type:c().describe("Storage type"),capacity:f().describe("Storage capacity")}));const da=[{action:"page_back",namespace:"page",name:"back",description:"Go back in the active tab",params:pr,returns:E,paramTypes:[],returnDoc:"Navigation result",errorCode:"E_NO_TAB",example:"page.back()",handlerKey:"back"},{action:"page_click",namespace:"page",name:"click",description:"Click an element in the active tab",params:hr,returns:E,paramTypes:[{name:"refId",type:"string",required:!1,description:"Element reference ID (refId)"},{name:"label",type:"string",required:!1,description:"Element label to click (label)"}],returnDoc:"{ ok: true, action: 'click', refId? }",errorCode:"E_MISSING_PARAM",example:'page.click({ refId: "e2" })',agentMeta:{prerequisites:["Ensure the target tab is active and the content script is ready before mutating"],notes:["Same content-script path as web.tab.*","Always operates on the active tab; use web.tab.* if you need to target a specific tabId"],tags:["mutation","write"],relatedApis:["web.tab.click"]},handlerKey:"click"},{action:"page_fill",namespace:"page",name:"fill",description:"Fill an element in the active tab",params:mr,returns:E,paramTypes:[{name:"refId",type:"string",required:!1,description:"Element reference ID (refId)"},{name:"value",type:"string",required:!1,description:"Value to fill (literal)"},{name:"label",type:"string",required:!1,description:"Element label (label)"}],returnDoc:"{ ok: true, action: 'fill', refId?, value? }",errorCode:"E_MISSING_PARAM",example:'page.fill({ refId: "e2", value: "hello" })',agentMeta:{prerequisites:["Ensure the target tab is active and the content script is ready before mutating"],notes:["Same content-script path as web.tab.*","Always operates on the active tab; use web.tab.* if you need to target a specific tabId"],tags:["mutation","write"],relatedApis:["web.tab.fill"]},handlerKey:"fill"},{action:"page_type",namespace:"page",name:"type",description:"Type into an element in the active tab",params:br,returns:E,paramTypes:[{name:"refId",type:"string",required:!1,description:"Element reference ID (refId)"},{name:"text",type:"string",required:!1,description:"Text to type (literal)"},{name:"label",type:"string",required:!1,description:"Element label (label)"}],returnDoc:"{ ok: true, action: 'type', refId?, value? }",errorCode:"E_MISSING_PARAM",example:'page.type({ refId: "e2", text: "hello" })',agentMeta:{prerequisites:["Ensure the target tab is active and the content script is ready before mutating"],notes:["Same content-script path as web.tab.*","Always operates on the active tab; use web.tab.* if you need to target a specific tabId"],tags:["mutation","write"],relatedApis:["web.tab.type"]},handlerKey:"type"},{action:"page_append",namespace:"page",name:"append",description:"Append text to an element in the active tab",params:gr,returns:E,paramTypes:[{name:"refId",type:"string",required:!1,description:"Element reference ID (refId)"},{name:"text",type:"string",required:!1,description:"Text to append (literal)"},{name:"label",type:"string",required:!1,description:"Element label (label)"}],returnDoc:"{ ok: true, action: 'append', refId?, value? }",errorCode:"E_MISSING_PARAM",example:'page.append({ refId: "e2", text: " world" })',agentMeta:{prerequisites:["Ensure the target tab is active and the content script is ready before mutating"],notes:["Same content-script path as web.tab.*","Always operates on the active tab; use web.tab.* if you need to target a specific tabId"],tags:["mutation","write"]},handlerKey:"append"},{action:"page_press",namespace:"page",name:"press",description:"Press a key in the active tab",params:yr,returns:E,fields:["key"],paramTypes:[{name:"key",type:"string",required:!0,description:"Key to press (literal)"}],returnDoc:"{ ok: true, action: 'press', key? }",errorCode:"E_NO_TAB",example:'page.press("Enter")',agentMeta:{prerequisites:["Ensure the target tab is active and the content script is ready before mutating"],notes:["Same content-script path as web.tab.*","Always operates on the active tab; use web.tab.* if you need to target a specific tabId"],tags:["mutation","write"],relatedApis:["web.tab.press"]},handlerKey:"press"},{action:"page_select",namespace:"page",name:"select",description:"Select an option in the active tab",params:_r,returns:E,paramTypes:[{name:"refId",type:"string",required:!1,description:"Element reference ID (refId)"},{name:"label",type:"string",required:!1,description:"Element label (label)"},{name:"value",type:"string",required:!1,description:"Option value to select (literal)"}],returnDoc:"{ ok: true, action: 'select', refId?, value? }",errorCode:"E_MISSING_PARAM",example:'page.select({ refId: "e2", value: "option1" })',agentMeta:{prerequisites:["Ensure the target tab is active and the content script is ready before mutating"],notes:["Same content-script path as web.tab.*","Always operates on the active tab; use web.tab.* if you need to target a specific tabId"],tags:["mutation","write"],relatedApis:["web.tab.select"]},handlerKey:"select"},{action:"page_check",namespace:"page",name:"check",description:"Check/uncheck an element in the active tab",params:vr,returns:E,paramTypes:[{name:"refId",type:"string",required:!1,description:"Element reference ID (refId)"},{name:"label",type:"string",required:!1,description:"Element label (label)"},{name:"checked",type:"boolean",required:!1,description:"Whether to check or uncheck (literal)"}],returnDoc:"{ ok: true, action: 'check', refId?, checked? }",errorCode:"E_MISSING_PARAM",example:'page.check({ refId: "e2", checked: true })',agentMeta:{prerequisites:["Ensure the target tab is active and the content script is ready before mutating"],notes:["Same content-script path as web.tab.*","Always operates on the active tab; use web.tab.* if you need to target a specific tabId"],tags:["mutation","write"],relatedApis:["web.tab.check"]},handlerKey:"check"},{action:"page_hover",namespace:"page",name:"hover",description:"Hover over an element in the active tab",params:xr,returns:E,paramTypes:[{name:"refId",type:"string",required:!1,description:"Element reference ID (refId)"},{name:"label",type:"string",required:!1,description:"Element label (label)"}],returnDoc:"{ ok: true, action: 'hover', refId? }",errorCode:"E_MISSING_PARAM",example:'page.hover({ refId: "e2" })',agentMeta:{prerequisites:["Ensure the target tab is active and the content script is ready before mutating"],notes:["Same content-script path as web.tab.*","Always operates on the active tab; use web.tab.* if you need to target a specific tabId"],tags:["mutation","write"],relatedApis:["web.tab.hover"]},handlerKey:"hover"},{action:"page_unhover",namespace:"page",name:"unhover",description:"Unhover in the active tab",params:kr,returns:E,paramTypes:[],returnDoc:"{ ok: true, action: 'unhover' }",errorCode:"E_NO_TAB",example:"page.unhover()",agentMeta:{prerequisites:["Ensure the target tab is active and the content script is ready before mutating"],notes:["Same content-script path as web.tab.*","Always operates on the active tab; use web.tab.* if you need to target a specific tabId"],tags:["mutation","write"],relatedApis:["web.tab.unhover"]},handlerKey:"unhover"},{action:"page_scroll",namespace:"page",name:"scroll",description:"Scroll the active tab",params:wr,returns:E,fields:["direction","amount"],paramTypes:[{name:"direction",type:"string",required:!1,description:"Scroll direction (up or down) (literal)"},{name:"amount",type:"number",required:!1,description:"Scroll amount in pixels (literal)"}],returnDoc:"Scroll result",errorCode:"E_NO_TAB",example:'page.scroll("down", 500)',handlerKey:"scroll"},{action:"page_scroll_to",namespace:"page",name:"scroll_to",description:"Scroll to an element in the active tab",params:Ir,returns:E,paramTypes:[{name:"refId",type:"string",required:!1,description:"Element reference ID to scroll to (refId)"},{name:"label",type:"string",required:!1,description:"Element label to scroll to (label)"}],returnDoc:"Scroll to result",errorCode:"E_MISSING_PARAM",example:'page.scroll_to({ refId: "e2" })',handlerKey:"scroll_to"},{action:"page_dblclick",namespace:"page",name:"dblclick",description:"Double-click an element in the active tab",params:Tr,returns:E,paramTypes:[{name:"refId",type:"string",required:!1,description:"Element reference ID (refId)"},{name:"label",type:"string",required:!1,description:"Element label (label)"}],returnDoc:"{ ok: true, action: 'dblclick', refId? }",errorCode:"E_MISSING_PARAM",example:'page.dblclick({ refId: "e2" })',agentMeta:{prerequisites:["Ensure the target tab is active and the content script is ready before mutating"],notes:["Same content-script path as web.tab.*","Always operates on the active tab; use web.tab.* if you need to target a specific tabId"],tags:["mutation","write"],relatedApis:["web.tab.dblclick"]},handlerKey:"dblclick"},{action:"tab_click",namespace:"web.tab",name:"click",description:"Click in a tab",params:Nr,returns:E,paramTypes:[{name:"tabId",type:"number",required:!0,description:"Tab ID (literal)"},{name:"refId",type:"string",required:!1,description:"Element reference ID (refId)"},{name:"label",type:"string",required:!1,description:"Element label (label)"}],returnDoc:"{ ok: true, action: 'click', refId? }",errorCode:"E_NO_TAB",example:'web.tab.click({ tabId: 123, refId: "e2" })',agentMeta:{prerequisites:["Ensure the target tab exists and the content script is ready before mutating"],notes:["Explicit tabId required; same handlers as page.*"],tags:["mutation","write"],relatedApis:["page.click"]},handlerKey:"click"},{action:"tab_fill",namespace:"web.tab",name:"fill",description:"Fill in a tab",params:Or,returns:E,paramTypes:[{name:"tabId",type:"number",required:!0,description:"Tab ID (literal)"},{name:"refId",type:"string",required:!1,description:"Element reference ID (refId)"},{name:"value",type:"string",required:!1,description:"Value to fill (literal)"},{name:"label",type:"string",required:!1,description:"Element label (label)"}],returnDoc:"{ ok: true, action: 'fill', refId?, value? }",errorCode:"E_NO_TAB",example:'web.tab.fill({ tabId: 123, refId: "e2", value: "hello" })',agentMeta:{prerequisites:["Ensure the target tab exists and the content script is ready before mutating"],notes:["Explicit tabId required; same handlers as page.*"],tags:["mutation","write"],relatedApis:["page.fill"]},handlerKey:"fill"},{action:"tab_scroll_to",namespace:"web.tab",name:"scroll_to",description:"Scroll to position in a tab",params:Dr,returns:E,paramTypes:[{name:"tabId",type:"number",required:!0,description:"Tab ID (literal)"},{name:"x",type:"number",required:!1,description:"X coordinate (literal)"},{name:"y",type:"number",required:!1,description:"Y coordinate (literal)"},{name:"refId",type:"string",required:!1,description:"Element reference ID (refId)"},{name:"label",type:"string",required:!1,description:"Element label (label)"}],returnDoc:"Scroll to result",errorCode:"E_NO_TAB",example:'web.tab.scroll_to({ tabId: 123, refId: "e2" })',handlerKey:"scroll_to"},{action:"tab_type",namespace:"web.tab",name:"type",description:"Type in a tab",params:Rr,returns:E,paramTypes:[{name:"tabId",type:"number",required:!0,description:"Tab ID (literal)"},{name:"refId",type:"string",required:!1,description:"Element reference ID (refId)"},{name:"text",type:"string",required:!1,description:"Text to type (literal)"},{name:"label",type:"string",required:!1,description:"Element label (label)"}],returnDoc:"{ ok: true, action: 'type', refId?, value? }",errorCode:"E_NO_TAB",example:'web.tab.type({ tabId: 123, refId: "e2", text: "hello" })',agentMeta:{prerequisites:["Ensure the target tab exists and the content script is ready before mutating"],notes:["Explicit tabId required; same handlers as page.*"],tags:["mutation","write"],relatedApis:["page.type"]},handlerKey:"type"},{action:"tab_press",namespace:"web.tab",name:"press",description:"Press a key in a tab",params:Mr,returns:E,paramTypes:[{name:"tabId",type:"number",required:!0,description:"Tab ID (literal)"},{name:"key",type:"string",required:!1,description:"Key to press (literal)"}],returnDoc:"{ ok: true, action: 'press', key? }",errorCode:"E_NO_TAB",example:'web.tab.press({ tabId: 123, key: "Enter" })',agentMeta:{prerequisites:["Ensure the target tab exists and the content script is ready before mutating"],notes:["Explicit tabId required; same handlers as page.*"],tags:["mutation","write"],relatedApis:["page.press"]},handlerKey:"press"},{action:"tab_select",namespace:"web.tab",name:"select",description:"Select an option in a tab",params:Pr,returns:E,paramTypes:[{name:"tabId",type:"number",required:!0,description:"Tab ID (literal)"},{name:"refId",type:"string",required:!1,description:"Element reference ID (refId)"},{name:"label",type:"string",required:!1,description:"Element label (label)"},{name:"value",type:"string",required:!1,description:"Option value to select (literal)"}],returnDoc:"{ ok: true, action: 'select', refId?, value? }",errorCode:"E_NO_TAB",example:'web.tab.select({ tabId: 123, refId: "e2", value: "option1" })',agentMeta:{prerequisites:["Ensure the target tab exists and the content script is ready before mutating"],notes:["Explicit tabId required; same handlers as page.*"],tags:["mutation","write"],relatedApis:["page.select"]},handlerKey:"select"},{action:"tab_check",namespace:"web.tab",name:"check",description:"Check/uncheck in a tab",params:qr,returns:E,paramTypes:[{name:"tabId",type:"number",required:!0,description:"Tab ID (literal)"},{name:"refId",type:"string",required:!1,description:"Element reference ID (refId)"},{name:"label",type:"string",required:!1,description:"Element label (label)"},{name:"checked",type:"boolean",required:!1,description:"Whether to check or uncheck (literal)"}],returnDoc:"{ ok: true, action: 'check', refId?, checked? }",errorCode:"E_NO_TAB",example:'web.tab.check({ tabId: 123, refId: "e2", checked: true })',agentMeta:{prerequisites:["Ensure the target tab exists and the content script is ready before mutating"],notes:["Explicit tabId required; same handlers as page.*"],tags:["mutation","write"],relatedApis:["page.check"]},handlerKey:"check"},{action:"tab_hover",namespace:"web.tab",name:"hover",description:"Hover in a tab",params:jr,returns:E,paramTypes:[{name:"tabId",type:"number",required:!0,description:"Tab ID (literal)"},{name:"refId",type:"string",required:!1,description:"Element reference ID (refId)"},{name:"label",type:"string",required:!1,description:"Element label (label)"}],returnDoc:"{ ok: true, action: 'hover', refId? }",errorCode:"E_NO_TAB",example:'web.tab.hover({ tabId: 123, refId: "e2" })',agentMeta:{prerequisites:["Ensure the target tab exists and the content script is ready before mutating"],notes:["Explicit tabId required; same handlers as page.*"],tags:["mutation","write"],relatedApis:["page.hover"]},handlerKey:"hover"},{action:"tab_unhover",namespace:"web.tab",name:"unhover",description:"Unhover in a tab",params:$r,returns:E,paramTypes:[{name:"tabId",type:"number",required:!0,description:"Tab ID (literal)"}],returnDoc:"{ ok: true, action: 'unhover' }",errorCode:"E_NO_TAB",example:"web.tab.unhover({ tabId: 123 })",agentMeta:{prerequisites:["Ensure the target tab exists and the content script is ready before mutating"],notes:["Explicit tabId required; same handlers as page.*"],tags:["mutation","write"],relatedApis:["page.unhover"]},handlerKey:"unhover"},{action:"tab_scroll",namespace:"web.tab",name:"scroll",description:"Scroll in a tab",params:Lr,returns:E,paramTypes:[{name:"tabId",type:"number",required:!0,description:"Tab ID (literal)"},{name:"direction",type:"string",required:!1,description:"Scroll direction (up or down) (literal)"},{name:"amount",type:"number",required:!1,description:"Scroll amount in pixels (literal)"}],returnDoc:"Scroll result",errorCode:"E_NO_TAB",example:'web.tab.scroll({ tabId: 123, direction: "down", amount: 500 })',handlerKey:"scroll"},{action:"tab_dblclick",namespace:"web.tab",name:"dblclick",description:"Double-click in a tab",params:Zr,returns:E,paramTypes:[{name:"tabId",type:"number",required:!0,description:"Tab ID (literal)"},{name:"refId",type:"string",required:!1,description:"Element reference ID (refId)"},{name:"label",type:"string",required:!1,description:"Element label (label)"}],returnDoc:"{ ok: true, action: 'dblclick', refId? }",errorCode:"E_NO_TAB",example:'web.tab.dblclick({ tabId: 123, refId: "e2" })',agentMeta:{prerequisites:["Ensure the target tab exists and the content script is ready before mutating"],notes:["Explicit tabId required; same handlers as page.*"],tags:["mutation","write"],relatedApis:["page.dblclick"]},handlerKey:"dblclick"},{action:"tab_back",namespace:"web.tab",name:"back",description:"Go back in a tab",params:Br,returns:E,paramTypes:[{name:"tabId",type:"number",required:!0,description:"Tab ID (literal)"}],returnDoc:"Back result",errorCode:"E_NO_TAB",example:"web.tab.back({ tabId: 123 })",handlerKey:"back"},{action:"page_forward",namespace:"page",name:"forward",description:"Go forward in the active tab",params:fr,returns:E,paramTypes:[],returnDoc:"Navigation result",errorCode:"E_NO_TAB",example:"page.forward()",handlerKey:"forward"},{action:"page_snapshot",namespace:"page",name:"snapshot",description:"Capture full DOM snapshot",params:pt,returns:c(),paramTypes:[{name:"max_nodes",type:"number",required:!1,description:"Maximum nodes to include (literal)"},{name:"options",type:"{ max_nodes?: number }",required:!1,description:"Snapshot options (literal)"}],returnDoc:"Snapshot text",errorCode:"E_SNAPSHOT",example:"page.snapshot()",agentMeta:{notes:["Content-script path; same refIds as mutations"],tags:["snapshot","read"],relatedApis:["page.snapshot_data","web.tab.snapshot"]},handlerKey:"snapshot_text"},{action:"page_snapshot_text",namespace:"page",name:"snapshot_text",description:"Capture DOM snapshot and return text representation",params:Hr,returns:c(),paramTypes:[{name:"max_nodes",type:"number",required:!1,description:"Maximum nodes to include (literal)"}],returnDoc:"Snapshot text",errorCode:"E_SNAPSHOT",example:"page.snapshot_text()",handlerKey:"snapshot_text"},{action:"page_snapshot_data",namespace:"page",name:"snapshot_data",description:"Get page snapshot data",params:Gr,returns:Ye,paramTypes:[{name:"max_nodes",type:"number",required:!1,description:"Maximum nodes to include (literal)"}],returnDoc:"{ text, nodes, url, title, viewport }",errorCode:"E_SNAPSHOT",example:"page.snapshot_data()",agentMeta:{notes:["Content-script path; nodes include refId for targeting","After mutations, call snapshot_data() again to verify state"],tags:["snapshot","read"],relatedApis:["page.click","web.tab.snapshot_data"]},handlerKey:"snapshot"},{action:"page_find",namespace:"page",name:"find",description:"Find elements in the active tab using a CSS selector",params:Sr,returns:C(l({tag:c(),refId:c().nullable(),text:c()})),aliases:[{namespace:"page",name:"query"}],fields:["selector"],paramTypes:[{name:"selector",type:"string",required:!0,description:"CSS selector to find elements (selector)"}],returnDoc:"Array of elements",errorCode:"E_NO_TAB",example:'page.find("h1")',agentMeta:{tags:["read"]},handlerKey:"find"},{action:"page_wait_for",namespace:"page",name:"wait_for",description:"Wait for a selector in the active tab",params:Er,returns:w(),fields:["selector","timeout"],paramTypes:[{name:"selector",type:"string",required:!0,description:"CSS selector to wait for (selector)"},{name:"timeout",type:"number",required:!1,description:"Timeout in milliseconds (literal)"}],returnDoc:"true",errorCode:"E_TIMEOUT",errorCategory:"timeout",example:'page.wait_for("#submit", 5000)',handlerKey:"wait_for"},{action:"page_extract",namespace:"page",name:"extract",description:"Extract data from the active tab",params:Cr,returns:l({title:c().optional(),url:c().optional(),headings:C(l({tag:c(),text:c()})).optional(),links:C(l({href:c().nullable(),text:c()})).optional(),text:c().optional()}).passthrough(),fields:["fields"],paramTypes:[{name:"fields",type:"array",required:!0,description:"Array of fields to extract (title, url, headings, links, text)"}],returnDoc:"Extracted data",errorCode:"E_NO_TAB",example:'page.extract(["title", "url"])',agentMeta:{tags:["read"]},handlerKey:"extract"},{action:"page_fetch",namespace:"page",name:"fetch",description:"Fetch in the active tab",params:g(y()),returns:ft,fields:["url","options"],paramTypes:[{name:"url",type:"string",required:!1,description:"URL to fetch (url)"},{name:"options",type:"{ method?: string, headers?: object, body?: string }",required:!1,description:"Fetch options (literal)"}],returnDoc:"DTO with `{ body, headers, ok, status }`",errorCode:"E_NO_TAB",example:'page.fetch({ url: "https://api.example.com/data" })',agentMeta:{tags:["read"]},handlerKey:"fetch"},{action:"tab_forward",namespace:"web.tab",name:"forward",description:"Go forward in a tab",params:Fr,returns:E,paramTypes:[{name:"tabId",type:"number",required:!0,description:"Tab ID (literal)"}],returnDoc:"Forward result",errorCode:"E_NO_TAB",example:"web.tab.forward({ tabId: 123 })",handlerKey:"forward"},{action:"tab_snapshot",namespace:"web.tab",name:"snapshot",description:"Get tab snapshot",params:Wr,returns:c(),fields:["tabId"],paramTypes:[{name:"tabId",type:"number",required:!0,description:"Tab ID (literal)"},{name:"max_nodes",type:"number",required:!1,description:"Maximum nodes to include (literal)"}],returnDoc:"Snapshot text",errorCode:"E_SNAPSHOT",example:"web.tab.snapshot({ tabId: 123 })",handlerKey:"snapshot_text"},{action:"tab_snapshot_text",namespace:"web.tab",name:"snapshot_text",description:"Get tab snapshot text",params:zr,returns:c(),fields:["tabId"],paramTypes:[{name:"tabId",type:"number",required:!0,description:"Tab ID (literal)"}],returnDoc:"Snapshot text",errorCode:"E_SNAPSHOT",example:"web.tab.snapshot_text({ tabId: 123 })",handlerKey:"snapshot_text"},{action:"tab_snapshot_data",namespace:"web.tab",name:"snapshot_data",description:"Get tab snapshot data",params:Kr,returns:Ye,fields:["tabId"],paramTypes:[{name:"tabId",type:"number",required:!0,description:"Tab ID (literal)"}],returnDoc:"Snapshot data",errorCode:"E_SNAPSHOT",example:"web.tab.snapshot_data({ tabId: 123 })",handlerKey:"snapshot"},{action:"tab_fetch",namespace:"web.tab",name:"fetch",description:"Fetch in a tab",params:Ur,returns:ft,fields:["tabId","url","options"],paramTypes:[{name:"tabId",type:"number",required:!0,description:"Tab ID (literal)"},{name:"url",type:"string",required:!1,description:"URL to fetch"}],returnDoc:"Fetch result DTO",errorCode:"E_NO_TAB",example:'web.tab.fetch({ tabId: 123, url: "https://api.example.com/data" })',handlerKey:"fetch"},{action:"tab_evaluate",namespace:"web.tab",name:"evaluate",description:"Evaluate script in a tab (content-script context)",params:Vr,returns:Yr,fields:["tabId","script"],paramTypes:[{name:"tabId",type:"number",required:!0,description:"Tab ID (literal)"},{name:"script",type:"string",required:!1,description:"Script to evaluate (literal)"}],returnDoc:"Evaluation result",errorCode:"E_NO_TAB",example:'web.tab.evaluate({ tabId: 123, script: "document.title" })',agentMeta:{notes:["Runs in content-script isolated world, not MAIN-world injection","For MAIN-world access use chrome.scripting.executeScript from a cell"],tags:["read"]},handlerKey:"evaluate"}];function la(){return[{registryAction:"ping",handlerKey:"ping",params:l({}),returns:l({ok:w()})},{registryAction:"snapshot",handlerKey:"snapshot",params:pt,returns:Ye}]}function ua(){return da.map(t=>({registryAction:t.action,handlerKey:t.handlerKey,params:t.params,returns:t.returns}))}const J={debug:0,info:1,warn:2,error:3,none:4};let bt=J.error;function pa(t){if(!t)return"";const e=[];for(const[r,a]of Object.entries(t)){let n;if(a===null)n="null";else if(a===void 0)n="undefined";else if(typeof a=="string")n=a;else if(typeof a=="number"||typeof a=="boolean")n=String(a);else try{n=JSON.stringify(a)}catch{n="[Circular]"}e.push(`${r}=${n}`)}return e.length>0?` ${e.join(" ")}`:""}function qe(t,e,r){if(t<bt)return;const a=pa(r),n=`[extension-js][content-script] ${e}${a}`;t>=J.error?console.error(n):t===J.warn?console.warn(n):console.log(n)}const de={debug:(t,e)=>{qe(J.debug,t,e)},info:(t,e)=>{qe(J.info,t,e)},warn:(t,e)=>{qe(J.warn,t,e)},error:(t,e)=>{qe(J.error,t,e)}};function fa(){window.__jsNotebookSetLogLevel=t=>{bt=J[t]??J.error}}function ha(t){if(t.startsWith("page_")||t.startsWith("tab_")){const e=t.indexOf("_");if(e>=0)return t.slice(e+1)}return t}const gt='input, textarea, select, button, a, [role="button"], [role="link"]';function yt(t){const e={};return t instanceof HTMLInputElement?(e.value=t.value,(t.type==="checkbox"||t.type==="radio")&&(e.checked=t.checked),e.disabled=t.disabled,e.readOnly=t.readOnly):t instanceof HTMLTextAreaElement?(e.value=t.value,e.disabled=t.disabled,e.readOnly=t.readOnly):t instanceof HTMLSelectElement&&(e.value=t.value,e.disabled=t.disabled),e}function ma(t,e){const r=t.tagName.toLowerCase();r!=="input"&&r!=="textarea"&&r!=="select"||Object.assign(e,yt(t))}function je(t){const e=t.tagName.toLowerCase(),r=t.getAttribute("role");if(r)return r;if(e==="button"||e==="input"&&t.type==="submit")return"button";if(e==="a")return"link";if(e==="input"){const a=t.type;if(a==="text"||a==="email"||a==="password"||a==="search")return"textbox";if(a==="checkbox")return"checkbox";if(a==="radio")return"radio";if(a==="submit"||a==="button")return"button"}return e==="textarea"?"textbox":e==="select"?"combobox":e==="img"?"img":e==="h1"||e==="h2"||e==="h3"||e==="h4"||e==="h5"||e==="h6"?"heading":e==="li"?"listitem":e==="ul"||e==="ol"?"list":e==="table"?"table":e==="tr"?"row":e==="td"||e==="th"?"cell":e==="nav"?"navigation":e==="main"?"main":e==="article"?"article":e==="section"?"region":e==="aside"?"complementary":e==="form"?"form":e==="dialog"||e==="modal"?"dialog":e==="figure"?"figure":e==="figcaption"?"caption":t.getAttribute("onclick")||t.onclick?"button":"generic"}function _t(t){var i,o;const e=t.getAttribute("aria-label");if(e)return e;const r=t.getAttribute("aria-labelledby");if(r){const d=document.getElementById(r);if(d)return((i=d.textContent)==null?void 0:i.slice(0,60))||""}if(t.tagName.toLowerCase()==="img"){const d=t.getAttribute("alt");if(d)return d}const n=t.title;if(n)return n;const s=je(t);return s!=="generic"&&s!=="list"&&s!=="table"&&s!=="row"&&s!=="region"&&s!=="navigation"&&s!=="main"&&((o=t.textContent)==null?void 0:o.trim().slice(0,60))||""}function ba(t){const e=je(t);if(e==="generic"||e==="presentation"||e==="none"||t.hidden)return!1;const r=window.getComputedStyle(t);return!(r.display==="none"||r.visibility==="hidden")}function Y(t){return document.querySelector(`[data-ref-id='${CSS.escape(t)}']`)}function X(t){var a,n,s;const e=t.toLowerCase().trim();if(!e)return null;const r=Array.from(document.querySelectorAll(gt));for(const i of r){const o=i.getAttribute("aria-label");if(o&&o.toLowerCase().trim()===e)return i;const d=i.placeholder;if(d&&d.toLowerCase().trim()===e)return i;const u=i.id;if(u){const z=document.querySelector(`label[for='${CSS.escape(u)}']`);if(z&&((a=z.textContent)==null?void 0:a.trim().toLowerCase())===e)return i}const _=i.closest("label");if(_&&((n=_.textContent)==null?void 0:n.trim().toLowerCase())===e||(((s=i.textContent)==null?void 0:s.trim().toLowerCase())||"")===e)return i}return null}function ga(t){var n;const e=t.toLowerCase().trim();if(!e)return[];const r=Array.from(document.querySelectorAll(gt)),a=[];for(const s of r){const i=s.getAttribute("aria-label"),o=s.placeholder,d=((n=s.textContent)==null?void 0:n.trim())||"";if(![i,o,d].filter(Boolean).some(A=>A.toLowerCase().includes(e)))continue;const _=s.getAttribute("data-ref-id");if(_&&(a.push({refId:_,role:je(s),name:_t(s)||void 0}),a.length>=5))break}return a}function L(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)?t:{}}function N(t,e){const r=L(t)[e];return typeof r=="string"?r:""}function vt(t,e,r){const a=L(t)[e];return typeof a=="number"?a:r}function Q(t,e,r=!1){if(t&&Ce(Tt(t)),e){const a=r?ga(e):[];Ce(At(e,a))}Ce({message:"Element not found",code:"E_NOT_FOUND",category:"resource"})}function xt(t){let e=1;const r=[],a=[];function n(i,o){if(r.length>=t)return;const d=i.tagName.toLowerCase();if(d==="script"||d==="style"||d==="noscript"||d==="template")return;const u=ba(i);let _=o;if(u){const A="e"+e++;i.setAttribute("data-ref-id",A);const z=je(i),ne=_t(i),Xe={refId:A,role:z,tag:d};ne&&(Xe.name=ne),ma(i,Xe),r.push(Xe);const Qe=[`${" ".repeat(o)}- ${z}`];ne&&Qe.push(`"${ne.replace(/"/g,'\\"')}"`),Qe.push(`[${A}]`),a.push(Qe.join(" ")),_=o+1}for(const A of i.children)n(A,_)}return document.body&&n(document.body,0),{text:[`URL: ${window.location.href}`,`Title: ${document.title}`,""].concat(a).join(`
|
|
2
|
+
`),nodes:r,url:window.location.href,title:document.title,viewport:{width:window.innerWidth,height:window.innerHeight}}}function M(t,e,r){const a=(e==null?void 0:e.getAttribute("data-ref-id"))??void 0;return{ok:!0,action:t,...a?{refId:a}:{},...e?yt(e):{},...r}}function kt(t,e,r,a){(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)&&e.value!==a&&Ce(St(t,r,{requested:a,actual:e.value}))}const ya=3e4,_a=3e4,va=100;function wt(t){const e=L(t),r=L(e.options??e);return typeof r.max_nodes=="number"?r.max_nodes:typeof e.max_nodes=="number"?e.max_nodes:500}function xa(t){const e=L(t),r=L(e.options??{}),a=String(e.url??""),n=String(r.method??e.method??"GET").toUpperCase(),s=r.headers??e.headers??{},i=typeof s=="object"&&s!==null?s:{},o=r.body??e.body??null,d=o==null?null:typeof o=="string"?o:String(o),u=typeof e.timeout=="number"?e.timeout:ya;return{url:a,method:n,headers:i,body:d,timeout:u}}function ka(t){const e=L(t),r=e.script??e.code??e.js??"";if(typeof r!="string"||r.length===0)throw new Error("evaluate requires a string argument");return r}const wa={click:t=>{const e=N(t,"refId"),r=N(t,"label");let a=e?Y(e):null;return!a&&r&&(a=X(r)),a||Q(e,r,!0),a.click(),M("click",a)},fill:t=>{const e=N(t,"refId"),r=N(t,"label"),a=N(t,"value");let n=e?Y(e):null;if(!n&&r&&(n=X(r)),n||Q(e,r,!0),n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement){n.value=a;const s=new InputEvent("input",{bubbles:!0});n.dispatchEvent(s);const i=e||n.getAttribute("data-ref-id")||"";return kt("fill",n,i,a),M("fill",n,{value:n.value})}throw new Error("Element is not an input")},type:t=>{const e=N(t,"refId"),r=N(t,"label"),a=N(t,"text");let n=e?Y(e):null;if(!n&&r&&(n=X(r)),n||Q(e,r,!0),n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement){n.value=a;const s=new InputEvent("input",{bubbles:!0});n.dispatchEvent(s);const i=e||n.getAttribute("data-ref-id")||"";return kt("type",n,i,a),M("type",n,{text:n.value})}throw new Error("Element is not an input")},append:t=>{const e=N(t,"refId"),r=N(t,"label"),a=N(t,"text");let n=e?Y(e):null;if(!n&&r&&(n=X(r)),n||Q(e,r,!0),n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement){n.value+=a;const s=new InputEvent("input",{bubbles:!0});return n.dispatchEvent(s),M("append",n,{text:n.value})}throw new Error("Element is not an input")},press:t=>{const e=N(t,"key"),r=new KeyboardEvent("keydown",{key:e,bubbles:!0});document.dispatchEvent(r);const a=new KeyboardEvent("keyup",{key:e,bubbles:!0});return document.dispatchEvent(a),M("press",null,{key:e})},select:t=>{const e=N(t,"refId"),r=N(t,"label"),a=N(t,"value");let n=e?Y(e):null;if(!n&&r&&(n=X(r)),n||Q(e,r,!0),n instanceof HTMLSelectElement)return n.value=a,n.dispatchEvent(new Event("change",{bubbles:!0})),M("select",n,{value:n.value});throw new Error("Element is not a select")},check:t=>{const e=N(t,"refId"),r=N(t,"label"),a=(()=>{const s=L(t);return typeof s.checked=="boolean"?s.checked:!0})();let n=e?Y(e):null;if(!n&&r&&(n=X(r)),n||Q(e,r,!0),n instanceof HTMLInputElement&&(n.type==="checkbox"||n.type==="radio"))return n.checked=a,n.dispatchEvent(new Event("change",{bubbles:!0})),M("check",n,{checked:n.checked});throw new Error("Element is not a checkbox or radio")},hover:t=>{const e=N(t,"refId"),r=N(t,"label");let a=e?Y(e):null;!a&&r&&(a=X(r)),a||Q(e,r,!0);const n=new MouseEvent("mouseenter",{bubbles:!0});return a.dispatchEvent(n),M("hover",a)},unhover:()=>{const t=new MouseEvent("mouseleave",{bubbles:!0});return document.body.dispatchEvent(t),M("unhover",null)},scroll:t=>{const e=L(t),r=e.direction??"down",a=typeof e.amount=="number"?e.amount:300;return window.scrollBy({top:r==="down"?a:-a,behavior:"smooth"}),M("scroll",null,{direction:r,amount:a})},dblclick:t=>{const e=N(t,"refId"),r=N(t,"label");let a=e?Y(e):null;!a&&r&&(a=X(r)),a||Q(e,r,!0);const n=new MouseEvent("dblclick",{bubbles:!0});return a.dispatchEvent(n),M("dblclick",a)},forward:()=>(window.history.forward(),M("forward",null)),reload:()=>(window.location.reload(),M("reload",null)),scroll_to:t=>{const e=N(t,"refId"),r=N(t,"label"),a=vt(t,"x",0),n=vt(t,"y",0);if(e||r){let s=e?Y(e):null;if(!s&&r&&(s=X(r)),s)return s.scrollIntoView({behavior:"smooth"}),M("scroll_to",s);Q(e,r,!0)}return window.scrollTo({top:n,left:a,behavior:"smooth"}),M("scroll_to",null,{amount:n})},evaluate:t=>{const e=ka(t);try{return new Function(e)()}catch(r){return{error:String(r)}}},back:()=>(window.history.back(),M("back",null)),ping:()=>({ok:!0}),snapshot:async t=>{const e=wt(t);de.debug("snapshot",{maxNodes:e,hasBody:!!document.body});const r=xt(e);return de.debug("snapshot_result",{nodeCount:r.nodes.length}),r},snapshot_text:async t=>{const e=wt(t);return xt(e).text},find:t=>{const e=N(t,"selector");return Array.from(document.querySelectorAll(e)).map(a=>{var n;return{tag:a.tagName,refId:a.getAttribute("data-ref-id"),text:((n=a.textContent)==null?void 0:n.slice(0,100))||""}})},wait_for:async(t,e)=>{const r=N(t,"selector"),a=L(t),n=typeof a.timeout=="number"?a.timeout:typeof a.timeout=="bigint"?Number(a.timeout):_a,s=Date.now();for(;;){if(e!=null&&e.aborted)throw new DOMException("Aborted","AbortError");if(document.querySelector(r))return!0;if(Date.now()-s>=n)throw new Error(`Timeout waiting for selector: ${r}`);await new Promise((i,o)=>{const d=setTimeout(i,va),u=()=>{clearTimeout(d),o(new DOMException("Aborted","AbortError"))};e==null||e.addEventListener("abort",u,{once:!0})})}},extract:t=>{var n,s;const e=L(t),r=Array.isArray(e.fields)?e.fields:[],a={};for(const i of r)if(i==="title")a.title=document.title;else if(i==="url")a.url=window.location.href;else if(i==="headings"){const o=Array.from(document.querySelectorAll("h1, h2, h3, h4, h5, h6"));a.headings=o.map(d=>{var u;return{tag:d.tagName,text:((u=d.textContent)==null?void 0:u.trim().slice(0,200))||""}})}else if(i==="links"){const o=Array.from(document.querySelectorAll("a[href]"));a.links=o.map(d=>{var u;return{href:d.getAttribute("href"),text:((u=d.textContent)==null?void 0:u.trim().slice(0,100))||""}})}else i==="text"&&(a.text=((s=(n=document.body)==null?void 0:n.textContent)==null?void 0:s.trim().slice(0,500))||"");return a},fetch:async(t,e)=>{const{url:r,method:a,headers:n,body:s,timeout:i}=xa(t);if(!r)throw new Error("fetch requires a url");const o=new AbortController,d=()=>o.abort();if(e){if(e.aborted)throw new DOMException("Aborted","AbortError");e.addEventListener("abort",d,{once:!0})}const u=setTimeout(()=>o.abort(),i);try{const _={method:a,headers:n,signal:o.signal};s!==null&&(_.body=s);const A=await fetch(r,_),z=await A.text();return{status:A.status,ok:A.ok,headers:Object.fromEntries(A.headers.entries()),body:z}}finally{clearTimeout(u),e==null||e.removeEventListener("abort",d)}}};function Ia(t,e){if(Ge(t))return t;const r=`page_${e}`;return Ge(r)?r:t}function It(t,e,r,a,n){const s=Ia(t,e),i=wa[e];return i?(or(s,e,i,r,n).then(d=>{de.debug("dispatch_response",{registryAction:t,handlerAction:e,ok:d.ok}),a(d)}).catch(d=>{const u=d instanceof Error?d.message:String(d);de.debug("dispatch_error",{registryAction:t,handlerAction:e,error:u}),a({ok:!1,error:u||String(d)})}),!0):(de.debug("no_handler",{action:e,registryAction:t}),a({ok:!1,error:`Unknown content script action: ${e}`}),!1)}function Ta(){chrome.runtime.onMessage.addListener((t,e,r)=>{if(e.id!==chrome.runtime.id)return de.warn("unauthorized_sender",{senderId:e.id,expected:chrome.runtime.id}),r({ok:!1,error:"Unauthorized sender"}),!1;const a=L(t),n=String(a.type??""),s=String(a.action??"");if(de.debug("received",{messageType:n,action:s,hasParams:!!a.params}),n==="registryCallCancel"){const i=String(a.id??"");return ir(i),r({ok:!0}),!1}if(n==="registryCall"){const i=ha(s),o=typeof a.id=="string"?a.id:void 0;return It(s,i,a.params,r,o)}return!s&&n==="contract-ping"?(r({ok:!0}),!1):s?It(s,s,a.params,r):(r({ok:!1,error:"Missing action"}),!1)})}if(fa(),window.__jsNotebookContentScriptInjected)throw new Error("Content script already injected");window.__jsNotebookContentScriptInjected=!0,sr([...ua(),...la()]),Ta()})();
|