@pi-oxide/extension-js 0.2.3 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/content-script.d.ts +6 -43
- package/content-script.js +2 -2
- package/extension_js.d.ts +306 -224
- package/extension_js.js +61685 -60860
- package/generated.d.ts +45 -2
- package/index.d.ts +5 -91
- package/index.js +3678 -3914
- package/package.json +1 -1
- package/runner.d.ts +2 -1
- package/schemas.d.ts +209 -20
- package/tool-registry.d.ts +60 -3
- package/worker.js +401 -121
package/content-script.d.ts
CHANGED
|
@@ -1,44 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
};
|
|
8
|
-
declare let __logLevel: number;
|
|
9
|
-
declare function __formatMeta(meta: Record<string, unknown> | undefined): string;
|
|
10
|
-
declare function __log(level: number, event: string, meta?: Record<string, unknown>): void;
|
|
11
|
-
declare const logger: {
|
|
12
|
-
debug: (event: string, meta?: Record<string, unknown>) => void;
|
|
13
|
-
info: (event: string, meta?: Record<string, unknown>) => void;
|
|
14
|
-
warn: (event: string, meta?: Record<string, unknown>) => void;
|
|
15
|
-
error: (event: string, meta?: Record<string, unknown>) => void;
|
|
16
|
-
};
|
|
17
|
-
declare function getElementByRefId(refId: string | number): Element | null;
|
|
18
|
-
declare function findElementByLabel(query: string): Element | null;
|
|
19
|
-
declare function findCandidateLabels(query: string): string[];
|
|
20
|
-
declare function asRecord(obj: unknown): Record<string, unknown>;
|
|
21
|
-
declare function getStringParam(params: unknown, key: string): string;
|
|
22
|
-
declare function getNumberParam(params: unknown, key: string, fallback: number): number;
|
|
23
|
-
declare function getAccessibleRole(el: Element): string;
|
|
24
|
-
declare function getAccessibleName(el: Element): string;
|
|
25
|
-
declare function shouldInclude(el: Element): boolean;
|
|
26
|
-
interface SnapshotNode {
|
|
27
|
-
refId: number;
|
|
28
|
-
role: string;
|
|
29
|
-
tag: string;
|
|
30
|
-
name?: string;
|
|
1
|
+
export {};
|
|
2
|
+
declare global {
|
|
3
|
+
interface Window {
|
|
4
|
+
__jsNotebookSetLogLevel?: (level: string) => void;
|
|
5
|
+
__jsNotebookContentScriptInjected?: boolean;
|
|
6
|
+
}
|
|
31
7
|
}
|
|
32
|
-
interface SnapshotResult {
|
|
33
|
-
text: string;
|
|
34
|
-
nodes: SnapshotNode[];
|
|
35
|
-
url: string;
|
|
36
|
-
title: string;
|
|
37
|
-
viewport: {
|
|
38
|
-
width: number;
|
|
39
|
-
height: number;
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
declare function inlineSnapshot(maxNodes: number): SnapshotResult;
|
|
43
|
-
type Handler<T = unknown, R = unknown> = (params: T) => R | Promise<R>;
|
|
44
|
-
declare const handlers: Record<string, Handler>;
|
package/content-script.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(){"use strict";const C={debug:0,info:1,warn:2,error:3,none:4};let k=3;function $(e){if(!e)return"";const t=[];for(const[r,n]of Object.entries(e)){let o;if(n===null)o="null";else if(n===void 0)o="undefined";else if(typeof n=="string")o=n;else if(typeof n=="number"||typeof n=="boolean")o=String(n);else try{o=JSON.stringify(n)}catch{o="[Circular]"}t.push(`${r}=${o}`)}return t.length>0?` ${t.join(" ")}`:""}function g(e,t,r){if(e<k)return;const n=$(r),o=`[extension-js][content-script] ${t}${n}`;e>=3?console.error(o):e===2?console.warn(o):console.log(o)}const b={debug:(e,t)=>{g(0,e,t)},info:(e,t)=>{g(1,e,t)},warn:(e,t)=>{g(2,e,t)},error:(e,t)=>{g(3,e,t)}};if(window.__jsNotebookSetLogLevel=e=>{k=C[e]??3},window.__jsNotebookContentScriptInjected)throw new Error("Content script already injected");window.__jsNotebookContentScriptInjected=!0;function f(e){return document.querySelector(`[data-ref-id='${CSS.escape(String(e))}']`)}function y(e){var n,o,i;const t=e.toLowerCase().trim();if(!t)return null;const r=Array.from(document.querySelectorAll('input, textarea, select, button, a, [role="button"], [role="link"]'));for(const l of r){const u=l.getAttribute("aria-label");if(u&&u.toLowerCase().trim()===t)return l;const c=l.placeholder;if(c&&c.toLowerCase().trim()===t)return l;const d=l.id;if(d){const w=document.querySelector(`label[for='${CSS.escape(d)}']`);if(w&&((n=w.textContent)==null?void 0:n.trim().toLowerCase())===t)return l}const a=l.closest("label");if(a&&((o=a.textContent)==null?void 0:o.trim().toLowerCase())===t||(((i=l.textContent)==null?void 0:i.trim().toLowerCase())||"")===t)return l}return null}function p(e){var o;const t=e.toLowerCase().trim(),r=new Set,n=Array.from(document.querySelectorAll('input, textarea, select, button, a, [role="button"], [role="link"]'));for(const i of n){const l=i.getAttribute("aria-label");l&&r.add(l.trim());const u=i.placeholder;u&&r.add(u.trim());const c=((o=i.textContent)==null?void 0:o.trim())||"";c&&r.add(c)}return Array.from(r).filter(i=>i.toLowerCase().includes(t)).slice(0,5)}function h(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:{}}function s(e,t){const r=h(e)[t];return typeof r=="string"?r:""}function I(e,t,r){const n=h(e)[t];return typeof n=="number"?n:r}function v(e){const t=e.tagName.toLowerCase(),r=e.getAttribute("role");if(r)return r;if(t==="button"||t==="input"&&e.type==="submit")return"button";if(t==="a")return"link";if(t==="input"){const n=e.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 t==="textarea"?"textbox":t==="select"?"combobox":t==="img"?"img":t==="h1"||t==="h2"||t==="h3"||t==="h4"||t==="h5"||t==="h6"?"heading":t==="li"?"listitem":t==="ul"||t==="ol"?"list":t==="table"?"table":t==="tr"?"row":t==="td"||t==="th"?"cell":t==="nav"?"navigation":t==="main"?"main":t==="article"?"article":t==="section"?"region":t==="aside"?"complementary":t==="form"?"form":t==="dialog"||t==="modal"?"dialog":t==="figure"?"figure":t==="figcaption"?"caption":e.getAttribute("onclick")||e.onclick?"button":"generic"}function S(e){var l,u;const t=e.getAttribute("aria-label");if(t)return t;const r=e.getAttribute("aria-labelledby");if(r){const c=document.getElementById(r);if(c)return((l=c.textContent)==null?void 0:l.slice(0,60))||""}if(e.tagName.toLowerCase()==="img"){const c=e.getAttribute("alt");if(c)return c}const o=e.title;if(o)return o;const i=v(e);return i!=="generic"&&i!=="list"&&i!=="table"&&i!=="row"&&i!=="region"&&i!=="navigation"&&i!=="main"&&((u=e.textContent)==null?void 0:u.trim().slice(0,60))||""}function _(e){const t=v(e);if(t==="generic"||t==="presentation"||t==="none"||e.hidden)return!1;const r=window.getComputedStyle(e);return!(r.display==="none"||r.visibility==="hidden")}function A(e){let t=1;const r=[],n=[];function o(l,u){if(r.length>=e)return;const c=l.tagName.toLowerCase();if(c==="script"||c==="style"||c==="noscript"||c==="template")return;const d=_(l);let a=u;if(d){const m=t++;l.setAttribute("data-ref-id",String(m));const w=v(l),E=S(l),L={refId:m,role:w,tag:c};E&&(L.name=E),r.push(L);const x=[`${" ".repeat(u)}- ${w}`];E&&x.push(`"${E.replace(/"/g,'\\"')}"`),x.push(`[ref=${m}]`),n.push(x.join(" ")),a=u+1}for(const m of l.children)o(m,a)}return document.body&&o(document.body,0),{text:[`URL: ${window.location.href}`,`Title: ${document.title}`,""].concat(n).join(`
|
|
2
|
-
`),nodes:
|
|
1
|
+
(function(){"use strict";function ie(r){return r==null?{}:r instanceof Map?Object.fromEntries([...r.entries()].map(([e,t])=>[e,ie(t)])):Array.isArray(r)?r.map(ie):r}async function et(r,e,t,n,s){const a=r.safeParse(ie(n));if(!a.success){const i=a.error.issues.map(o=>`invalid value for field '${o.path.join(".")}' (${o.message})`);return{ok:!1,error:{message:`Invalid parameters for ${s}: ${i.join("; ")}`,code:"E_INVALID_PARAMS",category:"validation"}}}try{const i=await t(a.data),o=e.safeParse(i);if(!o.success){const d=o.error.issues.map(m=>{const b=m.path.join(".");return`invalid return value${b?` at '${b}'`:""} (${m.message})`});return{ok:!1,error:{message:`Invalid return value for ${s}: ${d.join("; ")}`,code:"E_INVALID_RETURN",category:"validation"}}}return{ok:!0,value:o.data}}catch(i){const o=i instanceof Error?i.message:String(i),d=typeof i=="object"&&i!==null&&"code"in i&&typeof i.code=="string"?i.code:"E_HANDLER";return{ok:!1,error:{message:o,code:d}}}}const Re=new Map,oe=new Map;function tt(r){Re.set(r.registryAction,r)}function ve(r){return Re.get(r)}function rt(r){for(const e of r)tt(e);try{chrome.runtime.sendMessage({type:"contentScriptReady"})}catch{}}function nt(r){const e=oe.get(r);return e?(e.abort(),oe.delete(r),!0):!1}async function st(r,e,t,n,s){const a=ve(r);if(!a)return{ok:!1,error:{message:`No schema registered for content-script action: ${r}`,code:"E_INTERNAL"}};const i=new AbortController;s&&oe.set(s,i);try{return await et(a.params,a.returns,async o=>t(o,i.signal),ie(n),r)}finally{s&&oe.delete(s)}}var w;(function(r){r.assertEqual=s=>{};function e(s){}r.assertIs=e;function t(s){throw new Error}r.assertNever=t,r.arrayToEnum=s=>{const a={};for(const i of s)a[i]=i;return a},r.getValidEnumValues=s=>{const a=r.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),i={};for(const o of a)i[o]=s[o];return r.objectValues(i)},r.objectValues=s=>r.objectKeys(s).map(function(a){return s[a]}),r.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const a=[];for(const i in s)Object.prototype.hasOwnProperty.call(s,i)&&a.push(i);return a},r.find=(s,a)=>{for(const i of s)if(a(i))return i},r.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function n(s,a=" | "){return s.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}r.joinValues=n,r.jsonStringifyReplacer=(s,a)=>typeof a=="bigint"?a.toString():a})(w||(w={}));var je;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(je||(je={}));const p=w.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),U=r=>{switch(typeof r){case"undefined":return p.undefined;case"string":return p.string;case"number":return Number.isNaN(r)?p.nan:p.number;case"boolean":return p.boolean;case"function":return p.function;case"bigint":return p.bigint;case"symbol":return p.symbol;case"object":return Array.isArray(r)?p.array:r===null?p.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?p.promise:typeof Map<"u"&&r instanceof Map?p.map:typeof Set<"u"&&r instanceof Set?p.set:typeof Date<"u"&&r instanceof Date?p.date:p.object;default:return p.unknown}},u=w.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class M 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 t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){const t=e||function(a){return a.message},n={_errors:[]},s=a=>{for(const i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(s);else if(i.code==="invalid_return_type")s(i.returnTypeError);else if(i.code==="invalid_arguments")s(i.argumentsError);else if(i.path.length===0)n._errors.push(t(i));else{let o=n,d=0;for(;d<i.path.length;){const m=i.path[d];d===i.path.length-1?(o[m]=o[m]||{_errors:[]},o[m]._errors.push(t(i))):o[m]=o[m]||{_errors:[]},o=o[m],d++}}};return s(this),n}static assert(e){if(!(e instanceof M))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,w.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},n=[];for(const s of this.issues)if(s.path.length>0){const a=s.path[0];t[a]=t[a]||[],t[a].push(e(s))}else n.push(e(s));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}}M.create=r=>new M(r);const be=(r,e)=>{let t;switch(r.code){case u.invalid_type:r.received===p.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case u.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,w.jsonStringifyReplacer)}`;break;case u.unrecognized_keys:t=`Unrecognized key(s) in object: ${w.joinValues(r.keys,", ")}`;break;case u.invalid_union:t="Invalid input";break;case u.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${w.joinValues(r.options)}`;break;case u.invalid_enum_value:t=`Invalid enum value. Expected ${w.joinValues(r.options)}, received '${r.received}'`;break;case u.invalid_arguments:t="Invalid function arguments";break;case u.invalid_return_type:t="Invalid function return type";break;case u.invalid_date:t="Invalid date";break;case u.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:w.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case u.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="bigint"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case u.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case u.custom:t="Invalid input";break;case u.invalid_intersection_types:t="Intersection results could not be merged";break;case u.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case u.not_finite:t="Number must be finite";break;default:t=e.defaultError,w.assertNever(r)}return{message:t}};let at=be;function it(){return at}const ot=r=>{const{data:e,path:t,errorMaps:n,issueData:s}=r,a=[...t,...s.path||[]],i={...s,path:a};if(s.message!==void 0)return{...s,path:a,message:s.message};let o="";const d=n.filter(m=>!!m).slice().reverse();for(const m of d)o=m(i,{data:e,defaultError:o}).message;return{...s,path:a,message:o}};function f(r,e){const t=it(),n=ot({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===be?void 0:be].filter(s=>!!s)});r.common.issues.push(n)}class O{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const n=[];for(const s of t){if(s.status==="aborted")return v;s.status==="dirty"&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const s of t){const a=await s.key,i=await s.value;n.push({key:a,value:i})}return O.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const s of t){const{key:a,value:i}=s;if(a.status==="aborted"||i.status==="aborted")return v;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||s.alwaysSet)&&(n[a.value]=i.value)}return{status:e.value,value:n}}}const v=Object.freeze({status:"aborted"}),ne=r=>({status:"dirty",value:r}),R=r=>({status:"valid",value:r}),$e=r=>r.status==="aborted",Ze=r=>r.status==="dirty",G=r=>r.status==="valid",ce=r=>typeof Promise<"u"&&r instanceof Promise;var g;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(g||(g={}));class P{constructor(e,t,n,s){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=s}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Pe=(r,e)=>{if(G(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new M(r.common.issues);return this._error=t,this._error}}};function k(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:s}=r;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(i,o)=>{const{message:d}=r;return i.code==="invalid_enum_value"?{message:d??o.defaultError}:typeof o.data>"u"?{message:d??n??o.defaultError}:i.code!=="invalid_type"?{message:o.defaultError}:{message:d??t??o.defaultError}},description:s}}class x{get description(){return this._def.description}_getType(e){return U(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:U(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new O,ctx:{common:e.parent.common,data:e.data,parsedType:U(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(ce(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){const n={common:{issues:[],async:(t==null?void 0:t.async)??!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:U(e)},s=this._parseSync({data:e,path:n.path,parent:n});return Pe(n,s)}"~validate"(e){var n,s;const t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:U(e)};if(!this["~standard"].async)try{const a=this._parseSync({data:e,path:[],parent:t});return G(a)?{value:a.value}:{issues:t.common.issues}}catch(a){(s=(n=a==null?void 0:a.message)==null?void 0:n.toLowerCase())!=null&&s.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(a=>G(a)?{value:a.value}:{issues:t.common.issues})}async parseAsync(e,t){const n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){const n={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:U(e)},s=this._parse({data:e,path:n.path,parent:n}),a=await(ce(s)?s:Promise.resolve(s));return Pe(n,a)}refine(e,t){const n=s=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(s):t;return this._refinement((s,a)=>{const i=e(s),o=()=>a.addIssue({code:u.custom,...n(s)});return typeof Promise<"u"&&i instanceof Promise?i.then(d=>d?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,t){return this._refinement((n,s)=>e(n)?!0:(s.addIssue(typeof t=="function"?t(n,s):t),!1))}_refinement(e){return new ee({schema:this,typeName:_.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:t=>this["~validate"](t)}}optional(){return F.create(this,this._def)}nullable(){return te.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return L.create(this)}promise(){return he.create(this,this._def)}or(e){return ue.create([this,e],this._def)}and(e){return de.create(this,e,this._def)}transform(e){return new ee({...k(this._def),schema:this,typeName:_.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new Ce({...k(this._def),innerType:this,defaultValue:t,typeName:_.ZodDefault})}brand(){return new Nt({typeName:_.ZodBranded,type:this,...k(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new Ee({...k(this._def),innerType:this,catchValue:t,typeName:_.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Ie.create(this,e)}readonly(){return Ae.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const ct=/^c[^\s-]{8,}$/i,lt=/^[0-9a-z]+$/,ut=/^[0-9A-HJKMNP-TV-Z]{26}$/i,dt=/^[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,ft=/^[a-z0-9_-]{21}$/i,ht=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,mt=/^[-+]?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)?)??$/,pt=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,gt="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let ke;const yt=/^(?:(?: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])$/,_t=/^(?:(?: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])$/,vt=/^(([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]))$/,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]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,kt=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,xt=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Le="((\\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])))",wt=new RegExp(`^${Le}$`);function Me(r){let e="[0-5]\\d";r.precision?e=`${e}\\.\\d{${r.precision}}`:r.precision==null&&(e=`${e}(\\.\\d+)?`);const t=r.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${t}`}function St(r){return new RegExp(`^${Me(r)}$`)}function Tt(r){let e=`${Le}T${Me(r)}`;const t=[];return t.push(r.local?"Z?":"Z"),r.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function Ct(r,e){return!!((e==="v4"||!e)&&yt.test(r)||(e==="v6"||!e)&&vt.test(r))}function Et(r,e){if(!ht.test(r))return!1;try{const[t]=r.split(".");if(!t)return!1;const n=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),s=JSON.parse(atob(n));return!(typeof s!="object"||s===null||"typ"in s&&(s==null?void 0:s.typ)!=="JWT"||!s.alg||e&&s.alg!==e)}catch{return!1}}function It(r,e){return!!((e==="v4"||!e)&&_t.test(r)||(e==="v6"||!e)&&bt.test(r))}class V extends x{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==p.string){const a=this._getOrReturnCtx(e);return f(a,{code:u.invalid_type,expected:p.string,received:a.parsedType}),v}const n=new O;let s;for(const a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(s=this._getOrReturnCtx(e,s),f(s,{code:u.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="max")e.data.length>a.value&&(s=this._getOrReturnCtx(e,s),f(s,{code:u.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="length"){const i=e.data.length>a.value,o=e.data.length<a.value;(i||o)&&(s=this._getOrReturnCtx(e,s),i?f(s,{code:u.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):o&&f(s,{code:u.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),n.dirty())}else if(a.kind==="email")pt.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"email",code:u.invalid_string,message:a.message}),n.dirty());else if(a.kind==="emoji")ke||(ke=new RegExp(gt,"u")),ke.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"emoji",code:u.invalid_string,message:a.message}),n.dirty());else if(a.kind==="uuid")dt.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"uuid",code:u.invalid_string,message:a.message}),n.dirty());else if(a.kind==="nanoid")ft.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"nanoid",code:u.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid")ct.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"cuid",code:u.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid2")lt.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"cuid2",code:u.invalid_string,message:a.message}),n.dirty());else if(a.kind==="ulid")ut.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"ulid",code:u.invalid_string,message:a.message}),n.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),f(s,{validation:"url",code:u.invalid_string,message:a.message}),n.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"regex",code:u.invalid_string,message:a.message}),n.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(s=this._getOrReturnCtx(e,s),f(s,{code:u.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),n.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(s=this._getOrReturnCtx(e,s),f(s,{code:u.invalid_string,validation:{startsWith:a.value},message:a.message}),n.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(s=this._getOrReturnCtx(e,s),f(s,{code:u.invalid_string,validation:{endsWith:a.value},message:a.message}),n.dirty()):a.kind==="datetime"?Tt(a).test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{code:u.invalid_string,validation:"datetime",message:a.message}),n.dirty()):a.kind==="date"?wt.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{code:u.invalid_string,validation:"date",message:a.message}),n.dirty()):a.kind==="time"?St(a).test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{code:u.invalid_string,validation:"time",message:a.message}),n.dirty()):a.kind==="duration"?mt.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"duration",code:u.invalid_string,message:a.message}),n.dirty()):a.kind==="ip"?Ct(e.data,a.version)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"ip",code:u.invalid_string,message:a.message}),n.dirty()):a.kind==="jwt"?Et(e.data,a.alg)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"jwt",code:u.invalid_string,message:a.message}),n.dirty()):a.kind==="cidr"?It(e.data,a.version)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"cidr",code:u.invalid_string,message:a.message}),n.dirty()):a.kind==="base64"?kt.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"base64",code:u.invalid_string,message:a.message}),n.dirty()):a.kind==="base64url"?xt.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"base64url",code:u.invalid_string,message:a.message}),n.dirty()):w.assertNever(a);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(s=>e.test(s),{validation:t,code:u.invalid_string,...g.errToObj(n)})}_addCheck(e){return new V({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...g.errToObj(e)})}url(e){return this._addCheck({kind:"url",...g.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...g.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...g.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...g.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...g.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...g.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...g.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...g.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...g.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...g.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...g.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...g.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!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,...g.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,...g.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...g.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...g.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...g.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...g.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...g.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...g.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...g.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...g.errToObj(t)})}nonempty(e){return this.min(1,g.errToObj(e))}trim(){return new V({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new V({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new V({...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 t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}V.create=r=>new V({checks:[],typeName:_.ZodString,coerce:(r==null?void 0:r.coerce)??!1,...k(r)});function At(r,e){const t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=t>n?t:n,a=Number.parseInt(r.toFixed(s).replace(".","")),i=Number.parseInt(e.toFixed(s).replace(".",""));return a%i/10**s}class Y extends x{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)!==p.number){const a=this._getOrReturnCtx(e);return f(a,{code:u.invalid_type,expected:p.number,received:a.parsedType}),v}let n;const s=new O;for(const a of this._def.checks)a.kind==="int"?w.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),f(n,{code:u.invalid_type,expected:"integer",received:"float",message:a.message}),s.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),f(n,{code:u.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),f(n,{code:u.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="multipleOf"?At(e.data,a.value)!==0&&(n=this._getOrReturnCtx(e,n),f(n,{code:u.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),f(n,{code:u.not_finite,message:a.message}),s.dirty()):w.assertNever(a);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,g.toString(t))}gt(e,t){return this.setLimit("min",e,!1,g.toString(t))}lte(e,t){return this.setLimit("max",e,!0,g.toString(t))}lt(e,t){return this.setLimit("max",e,!1,g.toString(t))}setLimit(e,t,n,s){return new Y({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:g.toString(s)}]})}_addCheck(e){return new Y({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:g.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:g.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:g.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:g.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:g.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:g.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:g.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:g.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:g.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&w.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}}Y.create=r=>new Y({checks:[],typeName:_.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...k(r)});class K extends x{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)!==p.bigint)return this._getInvalidInput(e);let n;const s=new O;for(const a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),f(n,{code:u.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),f(n,{code:u.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),f(n,{code:u.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):w.assertNever(a);return{status:s.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return f(t,{code:u.invalid_type,expected:p.bigint,received:t.parsedType}),v}gte(e,t){return this.setLimit("min",e,!0,g.toString(t))}gt(e,t){return this.setLimit("min",e,!1,g.toString(t))}lte(e,t){return this.setLimit("max",e,!0,g.toString(t))}lt(e,t){return this.setLimit("max",e,!1,g.toString(t))}setLimit(e,t,n,s){return new K({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:g.toString(s)}]})}_addCheck(e){return new K({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:g.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:g.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:g.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:g.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:g.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}K.create=r=>new K({checks:[],typeName:_.ZodBigInt,coerce:(r==null?void 0:r.coerce)??!1,...k(r)});class xe extends x{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==p.boolean){const n=this._getOrReturnCtx(e);return f(n,{code:u.invalid_type,expected:p.boolean,received:n.parsedType}),v}return R(e.data)}}xe.create=r=>new xe({typeName:_.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...k(r)});class le extends x{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==p.date){const a=this._getOrReturnCtx(e);return f(a,{code:u.invalid_type,expected:p.date,received:a.parsedType}),v}if(Number.isNaN(e.data.getTime())){const a=this._getOrReturnCtx(e);return f(a,{code:u.invalid_date}),v}const n=new O;let s;for(const a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(s=this._getOrReturnCtx(e,s),f(s,{code:u.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),n.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(s=this._getOrReturnCtx(e,s),f(s,{code:u.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),n.dirty()):w.assertNever(a);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new le({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:g.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:g.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}le.create=r=>new le({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:_.ZodDate,...k(r)});class Ve extends x{_parse(e){if(this._getType(e)!==p.symbol){const n=this._getOrReturnCtx(e);return f(n,{code:u.invalid_type,expected:p.symbol,received:n.parsedType}),v}return R(e.data)}}Ve.create=r=>new Ve({typeName:_.ZodSymbol,...k(r)});class De extends x{_parse(e){if(this._getType(e)!==p.undefined){const n=this._getOrReturnCtx(e);return f(n,{code:u.invalid_type,expected:p.undefined,received:n.parsedType}),v}return R(e.data)}}De.create=r=>new De({typeName:_.ZodUndefined,...k(r)});class we extends x{_parse(e){if(this._getType(e)!==p.null){const n=this._getOrReturnCtx(e);return f(n,{code:u.invalid_type,expected:p.null,received:n.parsedType}),v}return R(e.data)}}we.create=r=>new we({typeName:_.ZodNull,...k(r)});class ze extends x{constructor(){super(...arguments),this._any=!0}_parse(e){return R(e.data)}}ze.create=r=>new ze({typeName:_.ZodAny,...k(r)});class Se extends x{constructor(){super(...arguments),this._unknown=!0}_parse(e){return R(e.data)}}Se.create=r=>new Se({typeName:_.ZodUnknown,...k(r)});class B extends x{_parse(e){const t=this._getOrReturnCtx(e);return f(t,{code:u.invalid_type,expected:p.never,received:t.parsedType}),v}}B.create=r=>new B({typeName:_.ZodNever,...k(r)});class Ue extends x{_parse(e){if(this._getType(e)!==p.undefined){const n=this._getOrReturnCtx(e);return f(n,{code:u.invalid_type,expected:p.void,received:n.parsedType}),v}return R(e.data)}}Ue.create=r=>new Ue({typeName:_.ZodVoid,...k(r)});class L extends x{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),s=this._def;if(t.parsedType!==p.array)return f(t,{code:u.invalid_type,expected:p.array,received:t.parsedType}),v;if(s.exactLength!==null){const i=t.data.length>s.exactLength.value,o=t.data.length<s.exactLength.value;(i||o)&&(f(t,{code:i?u.too_big:u.too_small,minimum:o?s.exactLength.value:void 0,maximum:i?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(s.minLength!==null&&t.data.length<s.minLength.value&&(f(t,{code:u.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&t.data.length>s.maxLength.value&&(f(t,{code:u.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((i,o)=>s.type._parseAsync(new P(t,i,t.path,o)))).then(i=>O.mergeArray(n,i));const a=[...t.data].map((i,o)=>s.type._parseSync(new P(t,i,t.path,o)));return O.mergeArray(n,a)}get element(){return this._def.type}min(e,t){return new L({...this._def,minLength:{value:e,message:g.toString(t)}})}max(e,t){return new L({...this._def,maxLength:{value:e,message:g.toString(t)}})}length(e,t){return new L({...this._def,exactLength:{value:e,message:g.toString(t)}})}nonempty(e){return this.min(1,e)}}L.create=(r,e)=>new L({type:r,minLength:null,maxLength:null,exactLength:null,typeName:_.ZodArray,...k(e)});function Q(r){if(r instanceof E){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=F.create(Q(n))}return new E({...r._def,shape:()=>e})}else return r instanceof L?new L({...r._def,type:Q(r.element)}):r instanceof F?F.create(Q(r.unwrap())):r instanceof te?te.create(Q(r.unwrap())):r instanceof W?W.create(r.items.map(e=>Q(e))):r}class E extends x{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(),t=w.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==p.object){const m=this._getOrReturnCtx(e);return f(m,{code:u.invalid_type,expected:p.object,received:m.parsedType}),v}const{status:n,ctx:s}=this._processInputParams(e),{shape:a,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof B&&this._def.unknownKeys==="strip"))for(const m in s.data)i.includes(m)||o.push(m);const d=[];for(const m of i){const b=a[m],N=s.data[m];d.push({key:{status:"valid",value:m},value:b._parse(new P(s,N,s.path,m)),alwaysSet:m in s.data})}if(this._def.catchall instanceof B){const m=this._def.unknownKeys;if(m==="passthrough")for(const b of o)d.push({key:{status:"valid",value:b},value:{status:"valid",value:s.data[b]}});else if(m==="strict")o.length>0&&(f(s,{code:u.unrecognized_keys,keys:o}),n.dirty());else if(m!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const m=this._def.catchall;for(const b of o){const N=s.data[b];d.push({key:{status:"valid",value:b},value:m._parse(new P(s,N,s.path,b)),alwaysSet:b in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const m=[];for(const b of d){const N=await b.key,j=await b.value;m.push({key:N,value:j,alwaysSet:b.alwaysSet})}return m}).then(m=>O.mergeObjectSync(n,m)):O.mergeObjectSync(n,d)}get shape(){return this._def.shape()}strict(e){return g.errToObj,new E({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var a,i;const s=((i=(a=this._def).errorMap)==null?void 0:i.call(a,t,n).message)??n.defaultError;return t.code==="unrecognized_keys"?{message:g.errToObj(e).message??s}:{message:s}}}:{}})}strip(){return new E({...this._def,unknownKeys:"strip"})}passthrough(){return new E({...this._def,unknownKeys:"passthrough"})}extend(e){return new E({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new E({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:_.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new E({...this._def,catchall:e})}pick(e){const t={};for(const n of w.objectKeys(e))e[n]&&this.shape[n]&&(t[n]=this.shape[n]);return new E({...this._def,shape:()=>t})}omit(e){const t={};for(const n of w.objectKeys(this.shape))e[n]||(t[n]=this.shape[n]);return new E({...this._def,shape:()=>t})}deepPartial(){return Q(this)}partial(e){const t={};for(const n of w.objectKeys(this.shape)){const s=this.shape[n];e&&!e[n]?t[n]=s:t[n]=s.optional()}return new E({...this._def,shape:()=>t})}required(e){const t={};for(const n of w.objectKeys(this.shape))if(e&&!e[n])t[n]=this.shape[n];else{let a=this.shape[n];for(;a instanceof F;)a=a._def.innerType;t[n]=a}return new E({...this._def,shape:()=>t})}keyof(){return We(w.objectKeys(this.shape))}}E.create=(r,e)=>new E({shape:()=>r,unknownKeys:"strip",catchall:B.create(),typeName:_.ZodObject,...k(e)}),E.strictCreate=(r,e)=>new E({shape:()=>r,unknownKeys:"strict",catchall:B.create(),typeName:_.ZodObject,...k(e)}),E.lazycreate=(r,e)=>new E({shape:r,unknownKeys:"strip",catchall:B.create(),typeName:_.ZodObject,...k(e)});class ue extends x{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;function s(a){for(const o of a)if(o.result.status==="valid")return o.result;for(const o of a)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const i=a.map(o=>new M(o.ctx.common.issues));return f(t,{code:u.invalid_union,unionErrors:i}),v}if(t.common.async)return Promise.all(n.map(async a=>{const i={...t,common:{...t.common,issues:[]},parent:null};return{result:await a._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}})).then(s);{let a;const i=[];for(const d of n){const m={...t,common:{...t.common,issues:[]},parent:null},b=d._parseSync({data:t.data,path:t.path,parent:m});if(b.status==="valid")return b;b.status==="dirty"&&!a&&(a={result:b,ctx:m}),m.common.issues.length&&i.push(m.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(d=>new M(d));return f(t,{code:u.invalid_union,unionErrors:o}),v}}get options(){return this._def.options}}ue.create=(r,e)=>new ue({options:r,typeName:_.ZodUnion,...k(e)});function Te(r,e){const t=U(r),n=U(e);if(r===e)return{valid:!0,data:r};if(t===p.object&&n===p.object){const s=w.objectKeys(e),a=w.objectKeys(r).filter(o=>s.indexOf(o)!==-1),i={...r,...e};for(const o of a){const d=Te(r[o],e[o]);if(!d.valid)return{valid:!1};i[o]=d.data}return{valid:!0,data:i}}else if(t===p.array&&n===p.array){if(r.length!==e.length)return{valid:!1};const s=[];for(let a=0;a<r.length;a++){const i=r[a],o=e[a],d=Te(i,o);if(!d.valid)return{valid:!1};s.push(d.data)}return{valid:!0,data:s}}else return t===p.date&&n===p.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class de extends x{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=(a,i)=>{if($e(a)||$e(i))return v;const o=Te(a.value,i.value);return o.valid?((Ze(a)||Ze(i))&&t.dirty(),{status:t.value,value:o.data}):(f(n,{code:u.invalid_intersection_types}),v)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([a,i])=>s(a,i)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}de.create=(r,e,t)=>new de({left:r,right:e,typeName:_.ZodIntersection,...k(t)});class W extends x{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==p.array)return f(n,{code:u.invalid_type,expected:p.array,received:n.parsedType}),v;if(n.data.length<this._def.items.length)return f(n,{code:u.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),v;!this._def.rest&&n.data.length>this._def.items.length&&(f(n,{code:u.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const a=[...n.data].map((i,o)=>{const d=this._def.items[o]||this._def.rest;return d?d._parse(new P(n,i,n.path,o)):null}).filter(i=>!!i);return n.common.async?Promise.all(a).then(i=>O.mergeArray(t,i)):O.mergeArray(t,a)}get items(){return this._def.items}rest(e){return new W({...this._def,rest:e})}}W.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new W({items:r,typeName:_.ZodTuple,rest:null,...k(e)})};class fe extends x{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==p.object)return f(n,{code:u.invalid_type,expected:p.object,received:n.parsedType}),v;const s=[],a=this._def.keyType,i=this._def.valueType;for(const o in n.data)s.push({key:a._parse(new P(n,o,n.path,o)),value:i._parse(new P(n,n.data[o],n.path,o)),alwaysSet:o in n.data});return n.common.async?O.mergeObjectAsync(t,s):O.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof x?new fe({keyType:e,valueType:t,typeName:_.ZodRecord,...k(n)}):new fe({keyType:V.create(),valueType:e,typeName:_.ZodRecord,...k(t)})}}class Be extends x{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==p.map)return f(n,{code:u.invalid_type,expected:p.map,received:n.parsedType}),v;const s=this._def.keyType,a=this._def.valueType,i=[...n.data.entries()].map(([o,d],m)=>({key:s._parse(new P(n,o,n.path,[m,"key"])),value:a._parse(new P(n,d,n.path,[m,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const d of i){const m=await d.key,b=await d.value;if(m.status==="aborted"||b.status==="aborted")return v;(m.status==="dirty"||b.status==="dirty")&&t.dirty(),o.set(m.value,b.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const d of i){const m=d.key,b=d.value;if(m.status==="aborted"||b.status==="aborted")return v;(m.status==="dirty"||b.status==="dirty")&&t.dirty(),o.set(m.value,b.value)}return{status:t.value,value:o}}}}Be.create=(r,e,t)=>new Be({valueType:e,keyType:r,typeName:_.ZodMap,...k(t)});class se extends x{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==p.set)return f(n,{code:u.invalid_type,expected:p.set,received:n.parsedType}),v;const s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(f(n,{code:u.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(f(n,{code:u.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());const a=this._def.valueType;function i(d){const m=new Set;for(const b of d){if(b.status==="aborted")return v;b.status==="dirty"&&t.dirty(),m.add(b.value)}return{status:t.value,value:m}}const o=[...n.data.values()].map((d,m)=>a._parse(new P(n,d,n.path,m)));return n.common.async?Promise.all(o).then(d=>i(d)):i(o)}min(e,t){return new se({...this._def,minSize:{value:e,message:g.toString(t)}})}max(e,t){return new se({...this._def,maxSize:{value:e,message:g.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}se.create=(r,e)=>new se({valueType:r,minSize:null,maxSize:null,typeName:_.ZodSet,...k(e)});class Fe extends x{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}Fe.create=(r,e)=>new Fe({getter:r,typeName:_.ZodLazy,...k(e)});class qe extends x{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return f(t,{received:t.data,code:u.invalid_literal,expected:this._def.value}),v}return{status:"valid",value:e.data}}get value(){return this._def.value}}qe.create=(r,e)=>new qe({value:r,typeName:_.ZodLiteral,...k(e)});function We(r,e){return new X({values:r,typeName:_.ZodEnum,...k(e)})}class X extends x{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return f(t,{expected:w.joinValues(n),received:t.parsedType,code:u.invalid_type}),v}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return f(t,{received:t.data,code:u.invalid_enum_value,options:n}),v}return R(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return X.create(e,{...this._def,...t})}exclude(e,t=this._def){return X.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}}X.create=We;class He extends x{_parse(e){const t=w.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==p.string&&n.parsedType!==p.number){const s=w.objectValues(t);return f(n,{expected:w.joinValues(s),received:n.parsedType,code:u.invalid_type}),v}if(this._cache||(this._cache=new Set(w.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const s=w.objectValues(t);return f(n,{received:n.data,code:u.invalid_enum_value,options:s}),v}return R(e.data)}get enum(){return this._def.values}}He.create=(r,e)=>new He({values:r,typeName:_.ZodNativeEnum,...k(e)});class he extends x{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==p.promise&&t.common.async===!1)return f(t,{code:u.invalid_type,expected:p.promise,received:t.parsedType}),v;const n=t.parsedType===p.promise?t.data:Promise.resolve(t.data);return R(n.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}}he.create=(r,e)=>new he({type:r,typeName:_.ZodPromise,...k(e)});class ee extends x{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===_.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=this._def.effect||null,a={addIssue:i=>{f(n,i),i.fatal?t.abort():t.dirty()},get path(){return n.path}};if(a.addIssue=a.addIssue.bind(a),s.type==="preprocess"){const i=s.transform(n.data,a);if(n.common.async)return Promise.resolve(i).then(async o=>{if(t.value==="aborted")return v;const d=await this._def.schema._parseAsync({data:o,path:n.path,parent:n});return d.status==="aborted"?v:d.status==="dirty"||t.value==="dirty"?ne(d.value):d});{if(t.value==="aborted")return v;const o=this._def.schema._parseSync({data:i,path:n.path,parent:n});return o.status==="aborted"?v:o.status==="dirty"||t.value==="dirty"?ne(o.value):o}}if(s.type==="refinement"){const i=o=>{const d=s.refinement(o,a);if(n.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(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?v:(o.status==="dirty"&&t.dirty(),i(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?v:(o.status==="dirty"&&t.dirty(),i(o.value).then(()=>({status:t.value,value:o.value}))))}if(s.type==="transform")if(n.common.async===!1){const i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!G(i))return v;const o=s.transform(i.value,a);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(i=>G(i)?Promise.resolve(s.transform(i.value,a)).then(o=>({status:t.value,value:o})):v);w.assertNever(s)}}ee.create=(r,e,t)=>new ee({schema:r,typeName:_.ZodEffects,effect:e,...k(t)}),ee.createWithPreprocess=(r,e,t)=>new ee({schema:e,effect:{type:"preprocess",transform:r},typeName:_.ZodEffects,...k(t)});class F extends x{_parse(e){return this._getType(e)===p.undefined?R(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}F.create=(r,e)=>new F({innerType:r,typeName:_.ZodOptional,...k(e)});class te extends x{_parse(e){return this._getType(e)===p.null?R(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}te.create=(r,e)=>new te({innerType:r,typeName:_.ZodNullable,...k(e)});class Ce extends x{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===p.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}Ce.create=(r,e)=>new Ce({innerType:r,typeName:_.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...k(e)});class Ee extends x{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},s=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return ce(s)?s.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new M(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new M(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}Ee.create=(r,e)=>new Ee({innerType:r,typeName:_.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...k(e)});class Je extends x{_parse(e){if(this._getType(e)!==p.nan){const n=this._getOrReturnCtx(e);return f(n,{code:u.invalid_type,expected:p.nan,received:n.parsedType}),v}return{status:"valid",value:e.data}}}Je.create=r=>new Je({typeName:_.ZodNaN,...k(r)});class Nt extends x{_parse(e){const{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}}class Ie extends x{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const a=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?v:a.status==="dirty"?(t.dirty(),ne(a.value)):this._def.out._parseAsync({data:a.value,path:n.path,parent:n})})();{const s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?v:s.status==="dirty"?(t.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,t){return new Ie({in:e,out:t,typeName:_.ZodPipeline})}}class Ae extends x{_parse(e){const t=this._def.innerType._parse(e),n=s=>(G(s)&&(s.value=Object.freeze(s.value)),s);return ce(t)?t.then(s=>n(s)):n(t)}unwrap(){return this._def.innerType}}Ae.create=(r,e)=>new Ae({innerType:r,typeName:_.ZodReadonly,...k(e)});var _;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(_||(_={}));const h=V.create,S=Y.create,Ge=K.create,$=xe.create,Ot=we.create,c=Se.create;B.create;const I=L.create,y=E.create,T=ue.create;de.create;const Rt=W.create,l=fe.create;X.create,he.create,F.create,te.create;const Z=()=>T([Ge(),S().finite()]).transform(r=>BigInt(r));y({key:h()}),y({key:h(),value:h()}),y({key:h()}),y({}),y({items:l(c())}),y({keys:I(h()),defaults:l(c()).optional()}),y({}),y({keys:I(h())}),y({}),y({}),T([Rt([T([y({text:h()}),h()])]),y({text:h().optional(),value:h().optional()})]),y({url:h(),method:h().default("GET"),headers:l(h()).default({}),body:h().nullable().default(null),timeout:Z().default(30000n)}),y({duration:Z()});const jt=(r,e)=>{!r.refId&&!r.label&&e.addIssue({code:u.custom,message:"Either refId or label is required"})},me=r=>y({refId:h().optional(),label:h().optional(),...r}).superRefine(jt),ae=r=>y({refId:h(),...r}),pe={tabId:T([S(),Ge()]).optional()},q=r=>y({...pe,refId:h(),...r}),$t=y({}),Zt=y({});y({url:h()});const Pt=y({});y({}),y({}),y({duration:Z().default(1000n)});const Lt=me(),Mt=me({value:h()}),Vt=me({text:h()}),Dt=me({text:h()}),zt=y({key:h()}),Ut=ae({value:h()}),Bt=ae({checked:$().optional()}),Ft=ae(),qt=y({}),Wt=y({direction:h().default("down"),amount:S().default(300)}),Ht=ae({x:S().optional(),y:S().optional()}),Jt=ae();y({selector:h()}),y({selector:h(),timeout:Z().default(30000n)}),y({fields:I(h())}),T([S(),I(c()),l(c())]),y({}),l(c()),l(c()),T([S(),I(c()),l(c())]),T([S(),I(c()),l(c())]),l(c());const Gt=q(),Yt=q({value:h()}),Kt=q({x:S().optional(),y:S().optional()}),Qt=q({text:h()}),Xt=y({...pe,key:h()}),er=q({value:h()}),tr=q({checked:$().optional()}),rr=q(),nr=y({...pe}),sr=y({...pe,direction:h().default("down"),amount:S().default(300)}),ar=q();l(c());const ir=l(c());l(c()),l(c()),l(c()),l(c()),l(c()),T([h(),l(c())]),T([h(),l(c())]),l(c()),l(c()),l(c()),l(c()),l(c()),T([h(),l(c())]),T([h(),l(c())]),l(c()),T([h(),l(c())]),l(c()),y({}),y({}),y({duration:Z().default(1000n)}),y({interactive_only:$().default(!1),max_nodes:Z().default(500n)}),y({interactive_only:$().default(!1),max_nodes:Z().default(500n)}),y({interactive_only:$().default(!1),max_nodes:Z().default(500n)}),y({interactive_only:$().default(!1),max_nodes:Z().default(500n)}),y({snapshot:c(),format:h().optional()});const or=l(c());l(c()),l(c()),y({path:h()}),y({from:h(),to:h()}),y({path:h(),data:h()}),y({path:h(),offset:Z(),len:S()}),y({path:h(),offset:Z(),data:h()}),y({path:h(),algo:h().default("sha256")}),l(c()),l(c()),l(c()),l(c()),T([S(),l(c())]),T([S(),l(c())]),l(c()),l(c()),l(c()),T([h(),l(c())]),l(c()),l(c()),l(c()),l(c()),l(c()),T([h(),S(),l(c())]),l(c()),l(c()),l(c()),T([S(),l(c())]),l(c()),l(c()),l(c()),l(c()),l(c()),I(c()),T([h(),l(c())]),l(c()),T([h(),l(c())]),l(c()),T([h(),l(c())]),l(c()),T([h(),l(c())]),l(c()),l(c()),T([S(),l(c())]),l(c()),l(c()),T([S(),l(c())]),l(c()),T([h(),S(),l(c())]),l(c()),l(c()),l(c()),l(c()),T([S(),l(c())]),T([S(),l(c())]),T([S(),l(c())]),T([S(),l(c())]),T([S(),l(c())]),l(c()),l(c()),l(c()),l(c()),y({status:S(),ok:$(),headers:l(h()),body:h()}),y({data:c(),text:h()});const cr=y({refId:S(),role:h(),tag:h(),name:h().optional()}),lr=y({text:h(),nodes:I(cr),url:h(),title:h(),viewport:y({width:S(),height:S()})}),ur=l(c());I(ur);const dr=l(c());I(dr),l(c()).nullable(),I(l(c())),I(l(c())),I(l(c())),I(l(c())),h(),$(),T([h(),S()]),$();const fr=l(c());I(fr),I(l(c())),I(l(c()));const hr=l(c());I(hr),S(),l(c()),l(c()),I(l(c()));const mr=new Set(["page_url","page_title","page_click","page_fill","page_type","page_append","page_press","page_select","page_check","page_hover","page_unhover","page_scroll","page_scroll_to","page_dblclick","page_back","tab_click","tab_fill","tab_type","tab_press","tab_select","tab_check","tab_hover","tab_unhover","tab_scroll","tab_scroll_to","tab_dblclick","tab_back"]);function pr(r){if(r.startsWith("page_")||r.startsWith("tab_")){const e=r.indexOf("_");if(e>=0)return r.slice(e+1)}return r}const C={string:h(),null:Ot(),boolean:$()},gr={page_url:{params:$t,returns:C.string},page_title:{params:Zt,returns:C.string},page_click:{params:Lt,returns:C.null},page_fill:{params:Mt,returns:C.null},page_type:{params:Vt,returns:C.null},page_append:{params:Dt,returns:C.null},page_press:{params:zt,returns:C.null},page_select:{params:Ut,returns:C.null},page_check:{params:Bt,returns:C.null},page_hover:{params:Ft,returns:C.null},page_unhover:{params:qt,returns:C.null},page_scroll:{params:Wt,returns:C.boolean},page_scroll_to:{params:Ht,returns:C.boolean},page_dblclick:{params:Jt,returns:C.null},page_back:{params:Pt,returns:C.boolean},tab_click:{params:Gt,returns:C.null},tab_fill:{params:Yt,returns:C.null},tab_type:{params:Qt,returns:C.null},tab_press:{params:Xt,returns:C.null},tab_select:{params:er,returns:C.null},tab_check:{params:tr,returns:C.null},tab_hover:{params:rr,returns:C.null},tab_unhover:{params:nr,returns:C.null},tab_scroll:{params:sr,returns:C.boolean},tab_scroll_to:{params:Kt,returns:C.boolean},tab_dblclick:{params:ar,returns:C.null},tab_back:{params:ir,returns:C.boolean}};function yr(){return[{registryAction:"ping",handlerKey:"ping",params:y({}),returns:y({ok:$()})},{registryAction:"snapshot",handlerKey:"snapshot",params:or,returns:lr}]}function _r(){const r=[];for(const e of mr){const t=gr[e];if(!t)throw new Error(`Missing content-script schemas for action: ${e}`);const n=e.indexOf("_"),s=n>=0?e.slice(n+1):e;r.push({registryAction:e,handlerKey:s,params:t.params,returns:t.returns})}return r}const D={debug:0,info:1,warn:2,error:3,none:4};let Ye=D.error;function vr(r){if(!r)return"";const e=[];for(const[t,n]of Object.entries(r)){let s;if(n===null)s="null";else if(n===void 0)s="undefined";else if(typeof n=="string")s=n;else if(typeof n=="number"||typeof n=="boolean")s=String(n);else try{s=JSON.stringify(n)}catch{s="[Circular]"}e.push(`${t}=${s}`)}return e.length>0?` ${e.join(" ")}`:""}function ge(r,e,t){if(r<Ye)return;const n=vr(t),s=`[extension-js][content-script] ${e}${n}`;r>=D.error?console.error(s):r===D.warn?console.warn(s):console.log(s)}const H={debug:(r,e)=>{ge(D.debug,r,e)},info:(r,e)=>{ge(D.info,r,e)},warn:(r,e)=>{ge(D.warn,r,e)},error:(r,e)=>{ge(D.error,r,e)}};function br(){window.__jsNotebookSetLogLevel=r=>{Ye=D[r]??D.error}}function z(r){return document.querySelector(`[data-ref-id='${CSS.escape(String(r))}']`)}function ye(r){var n,s,a;const e=r.toLowerCase().trim();if(!e)return null;const t=Array.from(document.querySelectorAll('input, textarea, select, button, a, [role="button"], [role="link"]'));for(const i of t){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 m=i.id;if(m){const j=document.querySelector(`label[for='${CSS.escape(m)}']`);if(j&&((n=j.textContent)==null?void 0:n.trim().toLowerCase())===e)return i}const b=i.closest("label");if(b&&((s=b.textContent)==null?void 0:s.trim().toLowerCase())===e||(((a=i.textContent)==null?void 0:a.trim().toLowerCase())||"")===e)return i}return null}function _e(r){var s;const e=r.toLowerCase().trim(),t=new Set,n=Array.from(document.querySelectorAll('input, textarea, select, button, a, [role="button"], [role="link"]'));for(const a of n){const i=a.getAttribute("aria-label");i&&t.add(i.trim());const o=a.placeholder;o&&t.add(o.trim());const d=((s=a.textContent)==null?void 0:s.trim())||"";d&&t.add(d)}return Array.from(t).filter(a=>a.toLowerCase().includes(e)).slice(0,5)}function J(r){return typeof r=="object"&&r!==null&&!Array.isArray(r)?r:{}}function A(r,e){const t=J(r)[e];return typeof t=="string"?t:""}function Ke(r,e,t){const n=J(r)[e];return typeof n=="number"?n:t}function Ne(r){const e=r.tagName.toLowerCase(),t=r.getAttribute("role");if(t)return t;if(e==="button"||e==="input"&&r.type==="submit")return"button";if(e==="a")return"link";if(e==="input"){const n=r.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":r.getAttribute("onclick")||r.onclick?"button":"generic"}function kr(r){var i,o;const e=r.getAttribute("aria-label");if(e)return e;const t=r.getAttribute("aria-labelledby");if(t){const d=document.getElementById(t);if(d)return((i=d.textContent)==null?void 0:i.slice(0,60))||""}if(r.tagName.toLowerCase()==="img"){const d=r.getAttribute("alt");if(d)return d}const s=r.title;if(s)return s;const a=Ne(r);return a!=="generic"&&a!=="list"&&a!=="table"&&a!=="row"&&a!=="region"&&a!=="navigation"&&a!=="main"&&((o=r.textContent)==null?void 0:o.trim().slice(0,60))||""}function xr(r){const e=Ne(r);if(e==="generic"||e==="presentation"||e==="none"||r.hidden)return!1;const t=window.getComputedStyle(r);return!(t.display==="none"||t.visibility==="hidden")}function wr(r){let e=1;const t=[],n=[];function s(i,o){if(t.length>=r)return;const d=i.tagName.toLowerCase();if(d==="script"||d==="style"||d==="noscript"||d==="template")return;const m=xr(i);let b=o;if(m){const N=e++;i.setAttribute("data-ref-id",String(N));const j=Ne(i),re=kr(i),Xe={refId:N,role:j,tag:d};re&&(Xe.name=re),t.push(Xe);const Oe=[`${" ".repeat(o)}- ${j}`];re&&Oe.push(`"${re.replace(/"/g,'\\"')}"`),Oe.push(`[ref=${N}]`),n.push(Oe.join(" ")),b=o+1}for(const N of i.children)s(N,b)}return document.body&&s(document.body,0),{text:[`URL: ${window.location.href}`,`Title: ${document.title}`,""].concat(n).join(`
|
|
2
|
+
`),nodes:t,url:window.location.href,title:document.title,viewport:{width:window.innerWidth,height:window.innerHeight}}}const Sr=3e4,Tr={click:r=>{const e=A(r,"refId"),t=A(r,"label");let n=e?z(e):null;if(!n&&t&&(n=ye(t)),!n){const s=t||e,a=s?_e(s):[];throw new Error(`Element not found${s?` by label: "${s}"`:""}. Candidates: ${a.join(", ")||"none"}`)}return n.click(),null},fill:r=>{const e=A(r,"refId"),t=A(r,"label"),n=A(r,"value");let s=e?z(e):null;if(!s&&t&&(s=ye(t)),!s){const a=t||e,i=a?_e(a):[];throw new Error(`Element not found${a?` by label: "${a}"`:""}. Candidates: ${i.join(", ")||"none"}`)}if(s instanceof HTMLInputElement||s instanceof HTMLTextAreaElement){s.value=n;const a=new InputEvent("input",{bubbles:!0});return s.dispatchEvent(a),null}throw new Error("Element is not an input")},type:r=>{const e=A(r,"refId"),t=A(r,"label"),n=A(r,"text");let s=e?z(e):null;if(!s&&t&&(s=ye(t)),!s){const a=t||e,i=a?_e(a):[];throw new Error(`Element not found${a?` by label: "${a}"`:""}. Candidates: ${i.join(", ")||"none"}`)}if(s instanceof HTMLInputElement||s instanceof HTMLTextAreaElement){s.value=n;const a=new InputEvent("input",{bubbles:!0});return s.dispatchEvent(a),null}throw new Error("Element is not an input")},append:r=>{const e=A(r,"refId"),t=A(r,"label"),n=A(r,"text");let s=e?z(e):null;if(!s&&t&&(s=ye(t)),!s){const a=t||e,i=a?_e(a):[];throw new Error(`Element not found${a?` by label: "${a}"`:""}. Candidates: ${i.join(", ")||"none"}`)}if(s instanceof HTMLInputElement||s instanceof HTMLTextAreaElement){s.value+=n;const a=new InputEvent("input",{bubbles:!0});return s.dispatchEvent(a),null}throw new Error("Element is not an input")},press:r=>{const e=A(r,"key"),t=new KeyboardEvent("keydown",{key:e,bubbles:!0});document.dispatchEvent(t);const n=new KeyboardEvent("keyup",{key:e,bubbles:!0});return document.dispatchEvent(n),null},select:r=>{const e=A(r,"refId"),t=A(r,"value"),n=e?z(e):null;if(!n)throw new Error(`Element ${e} not found`);if(n instanceof HTMLSelectElement)return n.value=t,null;throw new Error("Element is not a select")},check:r=>{const e=A(r,"refId"),t=(()=>{const s=J(r);return typeof s.checked=="boolean"?s.checked:!0})(),n=e?z(e):null;if(!n)throw new Error(`Element ${e} not found`);if(n instanceof HTMLInputElement&&n.type==="checkbox")return n.checked=t,null;throw new Error("Element is not a checkbox")},hover:r=>{const e=A(r,"refId"),t=e?z(e):null;if(!t)throw new Error(`Element ${e} not found`);const n=new MouseEvent("mouseenter",{bubbles:!0});return t.dispatchEvent(n),null},unhover:()=>{const r=new MouseEvent("mouseleave",{bubbles:!0});return document.body.dispatchEvent(r),null},scroll:r=>{const e=J(r),t=e.direction??"down",n=typeof e.amount=="number"?e.amount:300;return window.scrollBy({top:t==="down"?n:-n,behavior:"smooth"}),!0},dblclick:r=>{const e=A(r,"refId"),t=e?z(e):null;if(!t)throw new Error(`Element ${e} not found`);const n=new MouseEvent("dblclick",{bubbles:!0});return t.dispatchEvent(n),null},forward:()=>(window.history.forward(),!0),reload:()=>(window.location.reload(),!0),scrollTo:r=>{const e=A(r,"refId"),t=Ke(r,"x",0),n=Ke(r,"y",0);if(e){const s=z(e);if(s)return s.scrollIntoView({behavior:"smooth"}),!0;throw new Error(`Element ${e} not found`)}return window.scrollTo({top:n,left:t,behavior:"smooth"}),!0},evaluate:r=>{const e=A(r,"code");if(typeof e!="string")throw new Error("evaluate requires a string argument");return new Function(e)()},back:()=>(window.history.back(),!0),url:()=>window.location.href,title:()=>document.title,ping:()=>({ok:!0}),snapshot:async r=>{const e=J(r),t=typeof e.max_nodes=="number"?e.max_nodes:500;H.debug("snapshot",{maxNodes:t,hasBody:!!document.body});const n=wr(t);return H.debug("snapshot_result",{nodeCount:n.nodes.length}),n},fetch:async(r,e)=>{const t=J(r),n=t.url,s=(t.method||"GET").toString().toUpperCase(),a=t.headers||{},i=t.body??null,o=typeof t.timeout=="number"?t.timeout:Sr,d=new AbortController,m=()=>d.abort();if(e){if(e.aborted)throw new DOMException("Aborted","AbortError");e.addEventListener("abort",m,{once:!0})}const b=setTimeout(()=>d.abort(),o);try{const N={method:s,headers:typeof a=="object"&&a!==null?a:{},signal:d.signal};i!=null&&(N.body=typeof i=="string"?i:String(i));const j=await fetch(n,N),re=await j.text();return{status:j.status,ok:j.ok,headers:Object.fromEntries(j.headers.entries()),body:re}}catch(N){throw N}finally{clearTimeout(b),e==null||e.removeEventListener("abort",m)}}};function Cr(r,e){if(ve(r))return r;const t=`page_${e}`;return ve(t)?t:r}function Qe(r,e,t,n,s){const a=Cr(r,e),i=Tr[e];return i?(st(a,e,i,t,s).then(d=>{H.debug("dispatch_response",{registryAction:r,handlerAction:e,ok:d.ok}),n(d)}).catch(d=>{const m=d instanceof Error?d.message:String(d);H.debug("dispatch_error",{registryAction:r,handlerAction:e,error:m}),n({ok:!1,error:m||String(d)})}),!0):(H.debug("no_handler",{action:e,registryAction:r}),n({ok:!1,error:`Unknown content script action: ${e}`}),!1)}function Er(){chrome.runtime.onMessage.addListener((r,e,t)=>{if(e.id!==chrome.runtime.id)return H.warn("unauthorized_sender",{senderId:e.id,expected:chrome.runtime.id}),t({ok:!1,error:"Unauthorized sender"}),!1;const n=J(r),s=String(n.type??""),a=String(n.action??"");if(H.debug("received",{messageType:s,action:a,hasParams:!!n.params}),s==="registryCallCancel"){const i=String(n.id??"");return nt(i),t({ok:!0}),!1}if(s==="registryCall"){const i=pr(a),o=typeof n.id=="string"?n.id:void 0;return Qe(a,i,n.params,t,o)}return!a&&s==="contract-ping"?(t({ok:!0}),!1):a?Qe(a,a,n.params,t):(t({ok:!1,error:"Missing action"}),!1)})}if(br(),window.__jsNotebookContentScriptInjected)throw new Error("Content script already injected");window.__jsNotebookContentScriptInjected=!0,rt([..._r(),...yr()]),Er()})();
|