@pi-oxide/extension-js 0.9.1 → 0.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (5) hide show
  1. package/content-script.js +2 -2
  2. package/extension_js.js +63532 -63088
  3. package/index.js +1536 -1439
  4. package/package.json +1 -1
  5. package/worker.js +189 -172
package/content-script.js CHANGED
@@ -1,2 +1,2 @@
1
- (function(){"use strict";const Y={debug:0,info:1,warn:2,error:3,none:4};let yt=Y.error;function tr(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 Le(t,e,r){if(t<yt)return;const n=tr(r),a=`[extension-js][content-script] ${e}${n}`;t>=Y.error?console.error(a):t===Y.warn?console.warn(a):console.log(a)}const ue={debug:(t,e)=>{Le(Y.debug,t,e)},info:(t,e)=>{Le(Y.info,t,e)},warn:(t,e)=>{Le(Y.warn,t,e)},error:(t,e)=>{Le(Y.error,t,e)}};function rr(){window.__jsNotebookSetLogLevel=t=>{yt=Y[t]??Y.error}}function nr(t){if(t.startsWith("page_")||t.startsWith("tab_")){const e=t.indexOf("_");if(e>=0)return t.slice(e+1)}return t}const ar="Content script is not connected on this tab. This tab was likely open before the extension loaded (MV3 does not retro-inject).";function ir(t){return[`await page.goto(${JSON.stringify(t||"")})`,"Or ask the user to refresh the target tab, then retry fill/click"]}function _t(t,e){const r=e||"unknown url",n={message:t!==void 0?`Content script is not connected on tab ${t} (${r}).`:`Content script is not connected on this tab (${r}).`,code:"E_CONTENT_SCRIPT",category:"content-script",hint:ar,recovery:ir(e)};return t!==void 0&&(n.details={tabId:t,url:r}),n}function sr(t,e){var s,o;const r=t?"refId":e!=null&&e.label?"label":null,n=t||(e==null?void 0:e.label)||"";let a=`Element not found${r?` by ${r} "${n}"`:""}`;if(e!=null&&e.label&&((s=e.candidates)!=null&&s.length)){const l=e.candidates.map(d=>d.name||d.refId).filter(Boolean).slice(0,5);l.length>0?a+=`. Candidates: ${l.join(", ")}`:a+=". Candidates: none"}const i={message: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}};return(o=e==null?void 0:e.candidates)!=null&&o.length&&(i.details={...i.details,candidates:e.candidates}),i}function je(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 or(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")||t.includes("message port closed before a response was received")}function R(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 cr(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 lr(t){if(!(t instanceof Error))return{};const e=t.name!=="Error"?t.name:void 0,r=t.stack;let n;if(r){const a=r.match(/:(\d+):\d+\)?$/m);a&&(n=parseInt(a[1],10))}return{name:e,stack:r,line:n}}function vt(t,e){if(typeof t=="object"&&t!==null&&"code"in t&&typeof t.code=="string"&&"message"in t&&typeof t.message=="string"){const o=t;return o.hint||o.recovery?o:o.code==="E_CONTENT_SCRIPT"?_t(e==null?void 0:e.tabId,e==null?void 0:e.url):o}const r=(t instanceof Error?t.message:String(t))||"",{name:n,stack:a,line:i}=lr(t);if(or(r))return _t(e==null?void 0:e.tabId,e==null?void 0:e.url);if(r.includes("permission")||r.includes("Permission")){const o={message:r,code:"E_PERMISSION",category:"permission"};return(n||a||i)&&(o.details={name:n,stack:a,line:i}),o}if(r.includes("not found")||r.includes("No tab")||r.includes("No active tab")){const o={message:r,code:"E_NOT_FOUND",category:"resource"};return(n||a||i)&&(o.details={name:n,stack:a,line:i}),o}const s={message:r,code:"E_EXTENSION",category:"extension"};return(n||a||i)&&(s.details={name:n,stack:a,line:i}),s}const dr=/^e\d+$/;let wt=0;function xt(){let t=0;for(const e of document.querySelectorAll("[data-ref-id]")){const r=e.getAttribute("data-ref-id");if(!r)continue;const n=parseInt(r.replace(/^e/,""),10);!Number.isNaN(n)&&n>t&&(t=n)}wt=t}function Ye(t){const e=t.getAttribute("data-ref-id");if(e&&dr.test(e))return e;const r=`e${++wt}`;return t.setAttribute("data-ref-id",r),r}const et='input, textarea, select, button, a, [role="button"], [role="link"]',ur=new Set(["script","style","noscript","template"]),kt=new Set(["p","span","label","footer","header","blockquote","pre","code","figcaption","td","th","li","em","strong","small","cite","q","mark","time","abbr","dfn","kbd","samp","var","sub","sup"]);function tt(t){const e={};return t instanceof HTMLInputElement?(t.type!=="password"&&t.type!=="hidden"&&(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 fr(t,e){const r=t.tagName.toLowerCase();r!=="input"&&r!=="textarea"&&r!=="select"||Object.assign(e,tt(t))}const pr=new Set(["http:","https:","file:"]);function be(t){if(t)try{const e=new URL(t,window.location.href);return pr.has(e.protocol)?e.href:void 0}catch{return}}function It(t){const e=t.closest("article[data-post-id], [data-post-id]");if(e)return Ye(e)}function hr(t){const e=t.querySelector(":scope > h2 a[href], a[data-permalink], a[rel='permalink']");if(e instanceof HTMLAnchorElement)return e;const r=t.querySelector("a[href]");return r instanceof HTMLAnchorElement?r:null}function ie(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 mr(t){var e;for(const r of t.childNodes)if(r.nodeType===Node.TEXT_NODE&&((e=r.textContent)==null?void 0:e.trim()))return!0;return!1}function Tt(t,e=60){var a,i;const r=[];for(const s of t.childNodes)if(s.nodeType===Node.TEXT_NODE){const o=(a=s.textContent)==null?void 0:a.trim();o&&r.push(o)}if(r.length>0)return r.join(" ").slice(0,e);const n=(i=t.textContent)==null?void 0:i.trim();return n?n.slice(0,e):""}function br(t){if(t.hidden||t.getAttribute("aria-hidden")==="true"||t.inert)return!0;const e=window.getComputedStyle(t);return e.display==="none"||e.visibility==="hidden"}function St(t){var s;const e=t.tagName.toLowerCase();if(ur.has(e)||br(t))return!1;const r=ie(t);if(r==="presentation"||r==="none")return!1;if(r!=="generic")return!0;const n=t.getAttribute("aria-live");if(n&&n!=="off")return!0;const a=t.getAttribute("role");return a==="status"||a==="alert"?!0:((s=t.textContent)==null?void 0:s.trim())||""?!!(kt.has(e)||mr(t)):!1}function $e(t){var s,o,l;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((s=d.textContent)==null?void 0:s.slice(0,60))||""}if(t.tagName.toLowerCase()==="img"){const d=t.getAttribute("alt");if(d)return d}const a=t.title;if(a)return a;const i=ie(t);if(i!=="generic"&&i!=="list"&&i!=="table"&&i!=="row"&&i!=="region"&&i!=="navigation"&&i!=="main")return((o=t.textContent)==null?void 0:o.trim().slice(0,60))||"";if(i==="generic"&&St(t)){const d=Tt(t);if(d)return d;const m=t.tagName.toLowerCase();if(kt.has(m)||t.childElementCount===0)return((l=t.textContent)==null?void 0:l.trim().slice(0,60))||""}return""}function gr(t){return St(t)}function W(t){return document.querySelector(`[data-ref-id='${CSS.escape(t)}']`)}function se(t,e){if(t.hasAttribute("disabled")||t.getAttribute("aria-disabled")==="true"){const r=t.getAttribute("data-ref-id")||void 0;R(je(e,r??"",{reason:"disabled"}))}}function H(t){var n,a,i;const e=t.toLowerCase().trim();if(!e)return null;const r=Array.from(document.querySelectorAll(et));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 d=s.id;if(d){const me=document.querySelector(`label[for='${CSS.escape(d)}']`);if(me&&((n=me.textContent)==null?void 0:n.trim().toLowerCase())===e)return s}const m=s.closest("label");if(m&&((a=m.textContent)==null?void 0:a.trim().toLowerCase())===e||(((i=s.textContent)==null?void 0:i.trim().toLowerCase())||"")===e)return s}return null}function yr(t){var a;const e=t.toLowerCase().trim();if(!e)return[];const r=Array.from(document.querySelectorAll(et)),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(A=>A.toLowerCase().includes(e)))continue;const m=i.getAttribute("data-ref-id");if(m&&(n.push({refId:m,role:ie(i),name:$e(i)||void 0}),n.length>=5))break}return n}function q(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)?t:{}}function N(t,e){const r=q(t)[e];return typeof r=="string"?r:""}function Et(t,e,r){const n=q(t)[e];return typeof n=="number"?n:r}function _r(t){const e=document.querySelector(`[data-ref-id='${CSS.escape(t)}']`);let r,n;e&&(r=e.tagName.toLowerCase(),n=ie(e));const a=Array.from(document.querySelectorAll(et)),i=[];for(const s of a){const o=s.getAttribute("data-ref-id");if(o){if(r||n){const l=s.tagName.toLowerCase(),d=ie(s);if(l!==r&&d!==n)continue}if(i.push({refId:o,role:ie(s),name:$e(s)||void 0}),i.length>=5)break}}return i}function K(t,e,r=!1){if(t){const n=r?_r(t):[];R(sr(t,{candidates:n}))}if(e){const n=r?yr(e):[];R(cr(e,n))}R({message:"Element not found",code:"E_NOT_FOUND",category:"resource"})}const At=8*1024;function vr(t){const e=atob(t),r=new Uint8Array(e.length);for(let n=0;n<e.length;n++)r[n]=e.charCodeAt(n);return r}function wr(t){let e="";for(let r=0;r<t.length;r+=At){const n=t.subarray(r,r+At);for(let a=0;a<n.length;a++)e+=String.fromCharCode(n[a])}return btoa(e)}function xr(t){return t.toLowerCase().split(";")[0].trim()}function kr(t){return t.startsWith("image/")||t.startsWith("audio/")||t.startsWith("video/")||t==="application/octet-stream"||t==="application/pdf"||t==="application/zip"||t==="application/gzip"||t==="application/x-gzip"||t==="application/x-zip-compressed"?!0:t.startsWith("application/vnd.")}function Ir(t){for(let e=0;e<t.length;e++)if(t[e]===0)return!0;return!1}function Ct(t){return Object.fromEntries(t.headers.entries())}function Nt(t,e,r){return{status:t.status,ok:t.ok,headers:Ct(t),body:wr(e),bodyEncoding:"base64",byteLength:e.length,contentType:r,finalUrl:t.url}}function Ot(t,e,r){return{status:t.status,ok:t.ok,headers:Ct(t),body:e,bodyEncoding:"text",byteLength:new TextEncoder().encode(e).length,contentType:r,finalUrl:t.url}}async function Tr(t){const e=t.headers.get("content-type")||"",r=xr(e);if(kr(r)){const a=new Uint8Array(await t.arrayBuffer());return Nt(t,a,e)}if(!r||r.startsWith("text/")){const a=new Uint8Array(await t.arrayBuffer());if(Ir(a))return Nt(t,a,e);const i=new TextDecoder().decode(a);return Ot(t,i,e)}const n=await t.text();return Ot(t,n,e)}const Sr=new Set(["button","link","textbox","checkbox","radio","combobox","searchbox","switch","menuitem","tab","treeitem"]),Er=new Set(["a","button","input","textarea","select","details","summary"]);function Fe(t){if(t instanceof RegExp)return r=>t.test(r);if(typeof t!="string")return()=>!1;const e=t.toLowerCase();return r=>r.toLowerCase().includes(e)}function Rt(t){return Array.isArray(t)?new Set(t.filter(e=>typeof e=="string").map(e=>e.toLowerCase())):typeof t!="string"?new Set:new Set([t.toLowerCase()])}function Ar(t,e){let r=t;if(e.role){const n=Rt(e.role);r=r.filter(a=>n.has(a.role.toLowerCase()))}if(e.tag){const n=Rt(e.tag);r=r.filter(a=>n.has(a.tag.toLowerCase()))}if(e.text){const n=Fe(e.text);r=r.filter(a=>a.text!==void 0&&n(a.text))}if(e.name){const n=Fe(e.name);r=r.filter(a=>a.name!==void 0&&n(a.name))}if(e.href){const n=Fe(e.href);r=r.filter(a=>a.href!==void 0&&n(a.href))}if(e.src){const n=Fe(e.src);r=r.filter(a=>a.src!==void 0&&n(a.src))}return e.interactiveOnly&&(r=r.filter(n=>Sr.has(n.role.toLowerCase())||Er.has(n.tag.toLowerCase()))),e.limit!==void 0&&e.limit>0&&(r=r.slice(0,e.limit)),r}function L(t,e,r){const n=(e==null?void 0:e.getAttribute("data-ref-id"))??void 0;return{ok:!0,action:t,...n?{refId:n}:{},...e?tt(e):{},...r}}function rt(t,e,r,n){(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)&&e.value!==n&&R(je(t,r,{requested:n,actual:e.value}))}function nt(t){xt();const e=[],r=[];let n=!1,a=!1;const i=typeof MutationObserver<"u"&&document.body?new MutationObserver(()=>{a=!0}):null;i&&document.body&&i.observe(document.body,{childList:!0,subtree:!0});try{let o=function(l,d,m){if(n)return;if(e.length>=t){n=!0;return}const A=l.tagName.toLowerCase();if(A==="script"||A==="style"||A==="noscript"||A==="template")return;const me=gr(l);let we=d,Xt=m;if(me){const qe=Ye(l),Qt=ie(l),Qe=$e(l),F={refId:qe,role:Qt,tag:A};if(Qe&&(F.name=Qe),F.text=Tt(l,100),fr(l,F),A==="a"){const P=be(l.getAttribute("href"));P&&(F.href=P)}if(A==="img"){const P=be(l.getAttribute("src"));P&&(F.src=P),F.alt=l.getAttribute("alt")||""}if(A==="input"){const P=l.getAttribute("title");P&&(F.title=P)}if(A==="img"||A==="a"){const P=It(l);P?F.parentRefId=P:m&&(F.parentRefId=m)}const Yt=l.getAttribute("data-post-id");if(Yt&&(F.postId=Yt),A!=="a"){const P=hr(l);if(P){const xe=be(P.getAttribute("href"));xe&&(F.permalink=xe)}}if(A!=="img"){const P=l.querySelectorAll("img");if(P.length>0){const xe=[];for(const qa of P){const er=be(qa.getAttribute("src"));er&&xe.push(er)}xe.length>0&&(F.imageUrls=xe)}}e.push(F),Xt=qe;const gt=[`${" ".repeat(d)}- ${Qt}`];Qe&&gt.push(`"${Qe.replace(/"/g,'\\"')}"`),gt.push(`[${qe}]`),r.push(gt.join(" ")),we=d+1}for(const qe of l.children){if(n)break;o(qe,we,Xt)}};document.body&&o(document.body,0)}finally{i&&(i.takeRecords().length>0&&(a=!0),i.disconnect())}return a&&R({message:"DOM mutated during snapshot collection",code:"E_SNAPSHOT",category:"resource",details:{cause:"dom_mutated_during_snapshot",nodesCollected:e.length},recovery:["Wait for the page to finish rendering before snapshot","Retry with a smaller max_nodes bound","Use page.snapshot_data() after navigation settles"]}),{text:[`URL: ${window.location.href}`,`Title: ${document.title}`,""].concat(r).join(`
2
- `),nodes:e,url:window.location.href,title:document.title,viewport:{width:window.innerWidth,height:window.innerHeight}}}const Cr=3e4,Nr=3e4,Or=100;function at(t){const e=q(t),n=q(e.options??e).max_nodes??e.max_nodes;let a=500;return typeof n=="number"&&Number.isFinite(n)?a=n:typeof n=="bigint"&&(a=Number(n)),Math.max(1,Math.min(1e4,Math.floor(a)))}function Rr(t){const e=q(t),r=q(e.options??{}),n=String(e.url??""),a=String(r.method??e.method??"GET").toUpperCase(),i=r.headers??e.headers??{},s=typeof i=="object"&&i!==null?i:{},o=r.body??e.body??null,l=o==null?null:typeof o=="string"?o:String(o),d=e.timeout??r.timeout,m=typeof d=="number"?d:typeof d=="bigint"?Number(d):Cr;return{url:n,method:a,headers:s,body:l,timeout:m}}function Dr(t,e){return e!=null&&e.aborted?Promise.reject(new DOMException("Aborted","AbortError")):new Promise((r,n)=>{const a=setTimeout(()=>{e==null||e.removeEventListener("abort",i),r()},t),i=()=>{clearTimeout(a),e==null||e.removeEventListener("abort",i),n(new DOMException("Aborted","AbortError"))};e==null||e.addEventListener("abort",i,{once:!0})})}function Mr(t){const r=q(t).files;(!Array.isArray(r)||r.length===0)&&R({message:"setFiles requires a non-empty files array",code:"E_INVALID_PARAMS",category:"validation"});const n=[];for(const a of r){const i=q(a),s=i.kind;if(s==="bytes"){const o=typeof i.name=="string"?i.name.trim():"",l=typeof i.data=="string"?i.data:"";(!o||!l)&&R({message:"Resolved bytes file requires name and data",code:"E_INVALID_PARAMS",category:"validation"}),n.push({kind:"bytes",name:o,data:l,mimeType:typeof i.mimeType=="string"&&i.mimeType.length>0?i.mimeType:void 0});continue}if(s==="url"){const o=typeof i.url=="string"?i.url:"",l=typeof i.name=="string"?i.name.trim():"";(!o||!l)&&R({message:"Resolved url file requires url and name",code:"E_INVALID_PARAMS",category:"validation"}),n.push({kind:"url",url:o,name:l,mimeType:typeof i.mimeType=="string"&&i.mimeType.length>0?i.mimeType:void 0})}}return n.length!==r.length&&R({message:"setFiles files must be worker-resolved (kind: bytes or url)",code:"E_INVALID_PARAMS",category:"validation"}),n}function Pr(t){try{const e=vr(t.data);return new File([e.slice()],t.name,{type:t.mimeType??"application/octet-stream"})}catch{R({message:`Invalid base64 data for file ${t.name}`,code:"E_INVALID_PARAMS",category:"validation"})}}async function qr(t){try{const e=await fetch(t.url);e.ok||R({message:`Failed to fetch file URL ${t.url}: HTTP ${e.status}`,code:"E_NETWORK",category:"network"});const r=new Uint8Array(await e.arrayBuffer()),n=t.mimeType||e.headers.get("content-type")||"application/octet-stream";return new File([r.slice()],t.name,{type:n})}catch(e){if(typeof e=="object"&&e!==null&&"code"in e&&typeof e.code=="string")throw e;const r=e instanceof Error?e.message:String(e);R({message:`Failed to fetch file URL ${t.url}: ${r}`,code:"E_NETWORK",category:"network"})}}function Lr(t,e,r){var a;const n=Array.from(t.files??[]).map(i=>i.name);((((a=t.files)==null?void 0:a.length)??0)!==r.length||!r.every((i,s)=>n[s]===i))&&R(je("setFiles",e,{expectedNames:r,actualNames:n}))}function jr(t){const e=q(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 $r={click:t=>{const e=N(t,"refId"),r=N(t,"label");let n=e?W(e):null;return!n&&r&&(n=H(r)),n||K(e,r,!0),se(n,"click"),n.click(),L("click",n)},fill:t=>{const e=N(t,"refId"),r=N(t,"label"),n=N(t,"value");let a=e?W(e):null;if(!a&&r&&(a=H(r)),a||K(e,r,!0),se(a,"fill"),a instanceof HTMLInputElement||a instanceof HTMLTextAreaElement){a.value=n;const i=new InputEvent("input",{bubbles:!0});a.dispatchEvent(i);const s=e||a.getAttribute("data-ref-id")||"";return rt("fill",a,s,n),L("fill",a,{value:a.value})}throw new Error("Element is not an input")},set_files:async t=>{const e=N(t,"refId"),r=N(t,"label"),n=Mr(t);let a=e?W(e):null;if(!a&&r&&(a=H(r)),a||K(e,r,!0),se(a,"setFiles"),!(a instanceof HTMLInputElement)||a.type!=="file"){const l=e||a.getAttribute("data-ref-id")||"";R(je("setFiles",l,{reason:"not_file_input"}))}const i=new DataTransfer,s=[];for(const l of n){const d=l.kind==="bytes"?Pr(l):await qr(l);i.items.add(d),s.push(d.name)}a.files=i.files,a.dispatchEvent(new Event("change",{bubbles:!0}));const o=e||a.getAttribute("data-ref-id")||"";return Lr(a,o,s),L("setFiles",a,{fileCount:s.length,fileNames:s})},type:t=>{const e=N(t,"refId"),r=N(t,"label"),n=N(t,"text");let a=e?W(e):null;if(!a&&r&&(a=H(r)),a||K(e,r,!0),se(a,"type"),a instanceof HTMLInputElement||a instanceof HTMLTextAreaElement){a.value=n;const i=new InputEvent("input",{bubbles:!0});a.dispatchEvent(i);const s=e||a.getAttribute("data-ref-id")||"";return rt("type",a,s,n),L("type",a,{text:a.value})}throw new Error("Element is not an input")},append:t=>{const e=N(t,"refId"),r=N(t,"label"),n=N(t,"text");let a=e?W(e):null;if(!a&&r&&(a=H(r)),a||K(e,r,!0),se(a,"append"),a instanceof HTMLInputElement||a instanceof HTMLTextAreaElement){const s=a.value+n;a.value+=n;const o=new InputEvent("input",{bubbles:!0});a.dispatchEvent(o);const l=e||a.getAttribute("data-ref-id")||"";return rt("append",a,l,s),L("append",a,{text:a.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 n=new KeyboardEvent("keyup",{key:e,bubbles:!0});return document.dispatchEvent(n),L("press",null,{key:e})},select:t=>{const e=N(t,"refId"),r=N(t,"label"),n=N(t,"value");let a=e?W(e):null;if(!a&&r&&(a=H(r)),a||K(e,r,!0),se(a,"select"),a instanceof HTMLSelectElement)return a.value=n,a.dispatchEvent(new Event("change",{bubbles:!0})),L("select",a,{value:a.value});throw new Error("Element is not a select")},check:t=>{const e=N(t,"refId"),r=N(t,"label"),n=(()=>{const i=q(t);return typeof i.checked=="boolean"?i.checked:!0})();let a=e?W(e):null;if(!a&&r&&(a=H(r)),a||K(e,r,!0),se(a,"check"),a instanceof HTMLInputElement&&(a.type==="checkbox"||a.type==="radio"))return a.checked=n,a.dispatchEvent(new Event("change",{bubbles:!0})),L("check",a,{checked:a.checked});throw new Error("Element is not a checkbox or radio")},hover:t=>{const e=N(t,"refId"),r=N(t,"label");let n=e?W(e):null;!n&&r&&(n=H(r)),n||K(e,r,!0),se(n,"hover");const a=new MouseEvent("mouseenter",{bubbles:!0});return n.dispatchEvent(a),L("hover",n)},unhover:()=>{const t=new MouseEvent("mouseleave",{bubbles:!0});return document.body.dispatchEvent(t),L("unhover",null)},scroll:t=>{const e=q(t),r=e.direction??"down",n=typeof e.amount=="number"?e.amount:300,a=r==="down"?n:r==="up"?-n:0,i=r==="right"?n:r==="left"?-n:0;return window.scrollBy({top:a,left:i,behavior:"smooth"}),L("scroll",null,{direction:r,amount:n})},dblclick:t=>{const e=N(t,"refId"),r=N(t,"label");let n=e?W(e):null;!n&&r&&(n=H(r)),n||K(e,r,!0);const a=n;return a.click(),a.click(),a.dispatchEvent(new MouseEvent("dblclick",{bubbles:!0,cancelable:!0})),L("dblclick",n)},forward:()=>(window.history.forward(),L("forward",null)),scroll_to:t=>{const e=N(t,"refId"),r=N(t,"label"),n=Et(t,"x",0),a=Et(t,"y",0);if(e||r){let i=e?W(e):null;if(!i&&r&&(i=H(r)),i)return i.scrollIntoView({behavior:"smooth"}),L("scroll_to",i);K(e,r,!0)}return window.scrollTo({top:a,left:n,behavior:"smooth"}),L("scroll_to",null,{amount:a})},evaluate:t=>{const e=jr(t);return new Function(e)()},back:()=>(window.history.back(),L("back",null)),ping:()=>({ok:!0}),snapshot:async t=>{document.body||R({message:"Document body not available for snapshot",code:"E_SNAPSHOT",category:"resource",details:{cause:"document.body is null"},recovery:["Wait for the page to load fully before taking a snapshot."]});const e=at(t);ue.debug("snapshot",{maxNodes:e,hasBody:!!document.body});const r=nt(e);return ue.debug("snapshot_result",{nodeCount:r.nodes.length}),r},snapshot_text:async t=>{document.body||R({message:"Document body not available for snapshot",code:"E_SNAPSHOT",category:"resource",details:{cause:"document.body is null"},recovery:["Wait for the page to load fully before taking a snapshot."]});const e=at(t);return nt(e).text},snapshot_query:async t=>{document.body||R({message:"Document body not available for snapshot",code:"E_SNAPSHOT",category:"resource",details:{cause:"document.body is null"},recovery:["Wait for the page to load fully before taking a snapshot."]});const e=at(t),r=nt(e),n=q(t),a=n.filter?q(n.filter):{};return{text:"",nodes:Ar(r.nodes,a),url:r.url,title:r.title,viewport:r.viewport}},find:t=>{xt();const e=N(t,"selector");return Array.from(document.querySelectorAll(e)).map(n=>{var d;const a=Ye(n),i=ie(n),s=$e(n),o={tag:n.tagName.toLowerCase(),refId:a,role:i,text:((d=n.textContent)==null?void 0:d.slice(0,100))||"",...tt(n)};s&&(o.name=s);const l=n.tagName.toLowerCase();if(l==="a"){const m=be(n.getAttribute("href"));m&&(o.href=m)}if(l==="img"){const m=be(n.getAttribute("src"));m&&(o.src=m),o.alt=n.getAttribute("alt")||""}if(l==="input"){const m=n.getAttribute("title");m&&(o.title=m)}if(l==="img"||l==="a"){const m=It(n);m&&(o.parentRefId=m)}return o})},wait_for:async(t,e)=>{const r=N(t,"selector"),n=q(t),a=typeof n.timeout=="number"?n.timeout:typeof n.timeout=="bigint"?Number(n.timeout):Nr,i=Date.now();for(;;){if(e!=null&&e.aborted)throw new DOMException("Aborted","AbortError");if(document.querySelector(r))return!0;Date.now()-i>=a&&R({message:`Timeout waiting for selector: ${r}`,code:"E_TIMEOUT",category:"timeout"}),await Dr(Or,e)}},extract:t=>{var a,i;const e=q(t),r=Array.isArray(e.fields)?e.fields:[],n={};for(const s of r)if(s==="title")n.title=document.title;else if(s==="url")n.url=window.location.href;else if(s==="headings"){const o=Array.from(document.querySelectorAll("h1, h2, h3, h4, h5, h6"));n.headings=o.map(l=>{var d;return{tag:l.tagName,text:((d=l.textContent)==null?void 0:d.trim().slice(0,200))||""}})}else if(s==="links"){const o=Array.from(document.querySelectorAll("a[href]"));n.links=o.map(l=>{var d;return{href:l.getAttribute("href"),text:((d=l.textContent)==null?void 0:d.trim().slice(0,100))||""}})}else s==="text"&&(n.text=((i=(a=document.body)==null?void 0:a.textContent)==null?void 0:i.trim().slice(0,500))||"");return n},fetch:async(t,e)=>{const{url:r,method:n,headers:a,body:i,timeout:s}=Rr(t);if(!r)throw new Error("fetch requires a url");const o=new AbortController,l=()=>o.abort();if(e){if(e.aborted)throw new DOMException("Aborted","AbortError");e.addEventListener("abort",l,{once:!0})}const d=setTimeout(()=>o.abort(),s);try{const m={method:n,headers:a,signal:o.signal};i!==null&&(m.body=i);const A=await fetch(r,m);return Tr(A)}finally{clearTimeout(d),e==null||e.removeEventListener("abort",l)}}};function Ze(t){return t==null?{}:t instanceof Map?Object.fromEntries([...t.entries()].map(([e,r])=>[e,Ze(r)])):Array.isArray(t)?t.map(Ze):t}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 Dt;(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(Dt||(Dt={}));const b=S.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),oe=t=>{switch(typeof t){case"undefined":return b.undefined;case"string":return b.string;case"number":return Number.isNaN(t)?b.nan:b.number;case"boolean":return b.boolean;case"function":return b.function;case"bigint":return b.bigint;case"symbol":return b.symbol;case"object":return Array.isArray(t)?b.array:t===null?b.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?b.promise:typeof Map<"u"&&t instanceof Map?b.map:typeof Set<"u"&&t instanceof Set?b.set:typeof Date<"u"&&t instanceof Date?b.date:b.object;default:return b.unknown}},f=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 Z 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 d=s.path[l];l===s.path.length-1?(o[d]=o[d]||{_errors:[]},o[d]._errors.push(r(s))):o[d]=o[d]||{_errors:[]},o=o[d],l++}}};return a(this),n}static assert(e){if(!(e instanceof Z))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()}}Z.create=t=>new Z(t);const ke=(t,e)=>{let r;switch(t.code){case f.invalid_type:t.received===b.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case f.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,S.jsonStringifyReplacer)}`;break;case f.unrecognized_keys:r=`Unrecognized key(s) in object: ${S.joinValues(t.keys,", ")}`;break;case f.invalid_union:r="Invalid input";break;case f.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${S.joinValues(t.options)}`;break;case f.invalid_enum_value:r=`Invalid enum value. Expected ${S.joinValues(t.options)}, received '${t.received}'`;break;case f.invalid_arguments:r="Invalid function arguments";break;case f.invalid_return_type:r="Invalid function return type";break;case f.invalid_date:r="Invalid date";break;case f.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 f.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 f.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 f.custom:r="Invalid input";break;case f.invalid_intersection_types:r="Intersection results could not be merged";break;case f.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case f.not_finite:r="Number must be finite";break;default:r=e.defaultError,S.assertNever(t)}return{message:r}};let Fr=ke;function it(){return Fr}const st=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(d=>!!d).slice().reverse();for(const d of l)o=d(s,{data:e,defaultError:o}).message;return{...a,path:i,message:o}};function h(t,e){const r=it(),n=st({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===ke?void 0:ke].filter(a=>!!a)});t.common.issues.push(n)}class j{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 v;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 j.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 v;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 v=Object.freeze({status:"aborted"}),Ie=t=>({status:"dirty",value:t}),$=t=>({status:"valid",value:t}),Mt=t=>t.status==="aborted",Pt=t=>t.status==="dirty",ge=t=>t.status==="valid",Ue=t=>typeof Promise<"u"&&t instanceof Promise;var g;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(g||(g={}));class z{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 qt=(t,e)=>{if(ge(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 Z(t.common.issues);return this._error=r,this._error}}};function k(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 oe(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:oe(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new j,ctx:{common:e.parent.common,data:e.data,parsedType:oe(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const r=this._parse(e);if(Ue(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:oe(e)},a=this._parseSync({data:e,path:n.path,parent:n});return qt(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:oe(e)};if(!this["~standard"].async)try{const i=this._parseSync({data:e,path:[],parent:r});return ge(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=>ge(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:oe(e)},a=this._parse({data:e,path:n.path,parent:n}),i=await(Ue(a)?a:Promise.resolve(a));return qt(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:f.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 te({schema:this,typeName:w.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 B.create(this,this._def)}nullable(){return de.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return V.create(this)}promise(){return ve.create(this,this._def)}or(e){return Ee.create([this,e],this._def)}and(e){return Ae.create(this,e,this._def)}transform(e){return new te({...k(this._def),schema:this,typeName:w.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const r=typeof e=="function"?e:()=>e;return new Re({...k(this._def),innerType:this,defaultValue:r,typeName:w.ZodDefault})}brand(){return new ht({typeName:w.ZodBranded,type:this,...k(this._def)})}catch(e){const r=typeof e=="function"?e:()=>e;return new De({...k(this._def),innerType:this,catchValue:r,typeName:w.ZodCatch})}describe(e){const r=this.constructor;return new r({...this._def,description:e})}pipe(e){return Ke.create(this,e)}readonly(){return Me.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Zr=/^c[^\s-]{8,}$/i,Ur=/^[0-9a-z]+$/,Vr=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Br=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Wr=/^[a-z0-9_-]{21}$/i,Hr=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Kr=/^[-+]?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)?)??$/,zr=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Gr="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let ot;const Jr=/^(?:(?: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])$/,Xr=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,Qr=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Yr=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,en=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,tn=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Lt="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",rn=new RegExp(`^${Lt}$`);function jt(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 nn(t){return new RegExp(`^${jt(t)}$`)}function an(t){let e=`${Lt}T${jt(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 sn(t,e){return!!((e==="v4"||!e)&&Jr.test(t)||(e==="v6"||!e)&&Qr.test(t))}function on(t,e){if(!Hr.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 cn(t,e){return!!((e==="v4"||!e)&&Xr.test(t)||(e==="v6"||!e)&&Yr.test(t))}class G extends T{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==b.string){const i=this._getOrReturnCtx(e);return h(i,{code:f.invalid_type,expected:b.string,received:i.parsedType}),v}const n=new j;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:f.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:f.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:f.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):o&&h(a,{code:f.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),n.dirty())}else if(i.kind==="email")zr.test(e.data)||(a=this._getOrReturnCtx(e,a),h(a,{validation:"email",code:f.invalid_string,message:i.message}),n.dirty());else if(i.kind==="emoji")ot||(ot=new RegExp(Gr,"u")),ot.test(e.data)||(a=this._getOrReturnCtx(e,a),h(a,{validation:"emoji",code:f.invalid_string,message:i.message}),n.dirty());else if(i.kind==="uuid")Br.test(e.data)||(a=this._getOrReturnCtx(e,a),h(a,{validation:"uuid",code:f.invalid_string,message:i.message}),n.dirty());else if(i.kind==="nanoid")Wr.test(e.data)||(a=this._getOrReturnCtx(e,a),h(a,{validation:"nanoid",code:f.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid")Zr.test(e.data)||(a=this._getOrReturnCtx(e,a),h(a,{validation:"cuid",code:f.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid2")Ur.test(e.data)||(a=this._getOrReturnCtx(e,a),h(a,{validation:"cuid2",code:f.invalid_string,message:i.message}),n.dirty());else if(i.kind==="ulid")Vr.test(e.data)||(a=this._getOrReturnCtx(e,a),h(a,{validation:"ulid",code:f.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:f.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:f.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:f.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:f.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:f.invalid_string,validation:{endsWith:i.value},message:i.message}),n.dirty()):i.kind==="datetime"?an(i).test(e.data)||(a=this._getOrReturnCtx(e,a),h(a,{code:f.invalid_string,validation:"datetime",message:i.message}),n.dirty()):i.kind==="date"?rn.test(e.data)||(a=this._getOrReturnCtx(e,a),h(a,{code:f.invalid_string,validation:"date",message:i.message}),n.dirty()):i.kind==="time"?nn(i).test(e.data)||(a=this._getOrReturnCtx(e,a),h(a,{code:f.invalid_string,validation:"time",message:i.message}),n.dirty()):i.kind==="duration"?Kr.test(e.data)||(a=this._getOrReturnCtx(e,a),h(a,{validation:"duration",code:f.invalid_string,message:i.message}),n.dirty()):i.kind==="ip"?sn(e.data,i.version)||(a=this._getOrReturnCtx(e,a),h(a,{validation:"ip",code:f.invalid_string,message:i.message}),n.dirty()):i.kind==="jwt"?on(e.data,i.alg)||(a=this._getOrReturnCtx(e,a),h(a,{validation:"jwt",code:f.invalid_string,message:i.message}),n.dirty()):i.kind==="cidr"?cn(e.data,i.version)||(a=this._getOrReturnCtx(e,a),h(a,{validation:"cidr",code:f.invalid_string,message:i.message}),n.dirty()):i.kind==="base64"?en.test(e.data)||(a=this._getOrReturnCtx(e,a),h(a,{validation:"base64",code:f.invalid_string,message:i.message}),n.dirty()):i.kind==="base64url"?tn.test(e.data)||(a=this._getOrReturnCtx(e,a),h(a,{validation:"base64url",code:f.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:f.invalid_string,...g.errToObj(n)})}_addCheck(e){return new G({...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,r){return this._addCheck({kind:"regex",regex:e,...g.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r==null?void 0:r.position,...g.errToObj(r==null?void 0:r.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...g.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...g.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...g.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...g.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...g.errToObj(r)})}nonempty(e){return this.min(1,g.errToObj(e))}trim(){return new G({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new G({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new G({...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}}G.create=t=>new G({checks:[],typeName:w.ZodString,coerce:(t==null?void 0:t.coerce)??!1,...k(t)});function ln(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 fe 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)!==b.number){const i=this._getOrReturnCtx(e);return h(i,{code:f.invalid_type,expected:b.number,received:i.parsedType}),v}let n;const a=new j;for(const i of this._def.checks)i.kind==="int"?S.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),h(n,{code:f.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:f.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:f.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),a.dirty()):i.kind==="multipleOf"?ln(e.data,i.value)!==0&&(n=this._getOrReturnCtx(e,n),h(n,{code:f.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:f.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,g.toString(r))}gt(e,r){return this.setLimit("min",e,!1,g.toString(r))}lte(e,r){return this.setLimit("max",e,!0,g.toString(r))}lt(e,r){return this.setLimit("max",e,!1,g.toString(r))}setLimit(e,r,n,a){return new fe({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:g.toString(a)}]})}_addCheck(e){return new fe({...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,r){return this._addCheck({kind:"multipleOf",value:e,message:g.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:g.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!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 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)}}fe.create=t=>new fe({checks:[],typeName:w.ZodNumber,coerce:(t==null?void 0:t.coerce)||!1,...k(t)});class pe 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)!==b.bigint)return this._getInvalidInput(e);let n;const a=new j;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:f.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:f.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:f.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:f.invalid_type,expected:b.bigint,received:r.parsedType}),v}gte(e,r){return this.setLimit("min",e,!0,g.toString(r))}gt(e,r){return this.setLimit("min",e,!1,g.toString(r))}lte(e,r){return this.setLimit("max",e,!0,g.toString(r))}lt(e,r){return this.setLimit("max",e,!1,g.toString(r))}setLimit(e,r,n,a){return new pe({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:g.toString(a)}]})}_addCheck(e){return new pe({...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,r){return this._addCheck({kind:"multipleOf",value:e,message:g.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}}pe.create=t=>new pe({checks:[],typeName:w.ZodBigInt,coerce:(t==null?void 0:t.coerce)??!1,...k(t)});class Ve extends T{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==b.boolean){const n=this._getOrReturnCtx(e);return h(n,{code:f.invalid_type,expected:b.boolean,received:n.parsedType}),v}return $(e.data)}}Ve.create=t=>new Ve({typeName:w.ZodBoolean,coerce:(t==null?void 0:t.coerce)||!1,...k(t)});class Te extends T{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==b.date){const i=this._getOrReturnCtx(e);return h(i,{code:f.invalid_type,expected:b.date,received:i.parsedType}),v}if(Number.isNaN(e.data.getTime())){const i=this._getOrReturnCtx(e);return h(i,{code:f.invalid_date}),v}const n=new j;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:f.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:f.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 Te({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:g.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:g.toString(r)})}get minDate(){let e=null;for(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}}Te.create=t=>new Te({checks:[],coerce:(t==null?void 0:t.coerce)||!1,typeName:w.ZodDate,...k(t)});class $t extends T{_parse(e){if(this._getType(e)!==b.symbol){const n=this._getOrReturnCtx(e);return h(n,{code:f.invalid_type,expected:b.symbol,received:n.parsedType}),v}return $(e.data)}}$t.create=t=>new $t({typeName:w.ZodSymbol,...k(t)});class Be extends T{_parse(e){if(this._getType(e)!==b.undefined){const n=this._getOrReturnCtx(e);return h(n,{code:f.invalid_type,expected:b.undefined,received:n.parsedType}),v}return $(e.data)}}Be.create=t=>new Be({typeName:w.ZodUndefined,...k(t)});class Se extends T{_parse(e){if(this._getType(e)!==b.null){const n=this._getOrReturnCtx(e);return h(n,{code:f.invalid_type,expected:b.null,received:n.parsedType}),v}return $(e.data)}}Se.create=t=>new Se({typeName:w.ZodNull,...k(t)});class ct extends T{constructor(){super(...arguments),this._any=!0}_parse(e){return $(e.data)}}ct.create=t=>new ct({typeName:w.ZodAny,...k(t)});class he extends T{constructor(){super(...arguments),this._unknown=!0}_parse(e){return $(e.data)}}he.create=t=>new he({typeName:w.ZodUnknown,...k(t)});class ce extends T{_parse(e){const r=this._getOrReturnCtx(e);return h(r,{code:f.invalid_type,expected:b.never,received:r.parsedType}),v}}ce.create=t=>new ce({typeName:w.ZodNever,...k(t)});class lt extends T{_parse(e){if(this._getType(e)!==b.undefined){const n=this._getOrReturnCtx(e);return h(n,{code:f.invalid_type,expected:b.void,received:n.parsedType}),v}return $(e.data)}}lt.create=t=>new lt({typeName:w.ZodVoid,...k(t)});class V extends T{_parse(e){const{ctx:r,status:n}=this._processInputParams(e),a=this._def;if(r.parsedType!==b.array)return h(r,{code:f.invalid_type,expected:b.array,received:r.parsedType}),v;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?f.too_big:f.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:f.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:f.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 z(r,s,r.path,o)))).then(s=>j.mergeArray(n,s));const i=[...r.data].map((s,o)=>a.type._parseSync(new z(r,s,r.path,o)));return j.mergeArray(n,i)}get element(){return this._def.type}min(e,r){return new V({...this._def,minLength:{value:e,message:g.toString(r)}})}max(e,r){return new V({...this._def,maxLength:{value:e,message:g.toString(r)}})}length(e,r){return new V({...this._def,exactLength:{value:e,message:g.toString(r)}})}nonempty(e){return this.min(1,e)}}V.create=(t,e)=>new V({type:t,minLength:null,maxLength:null,exactLength:null,typeName:w.ZodArray,...k(e)});function ye(t){if(t instanceof O){const e={};for(const r in t.shape){const n=t.shape[r];e[r]=B.create(ye(n))}return new O({...t._def,shape:()=>e})}else return t instanceof V?new V({...t._def,type:ye(t.element)}):t instanceof B?B.create(ye(t.unwrap())):t instanceof de?de.create(ye(t.unwrap())):t instanceof J?J.create(t.items.map(e=>ye(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)!==b.object){const d=this._getOrReturnCtx(e);return h(d,{code:f.invalid_type,expected:b.object,received:d.parsedType}),v}const{status:n,ctx:a}=this._processInputParams(e),{shape:i,keys:s}=this._getCached(),o=[];if(!(this._def.catchall instanceof ce&&this._def.unknownKeys==="strip"))for(const d in a.data)s.includes(d)||o.push(d);const l=[];for(const d of s){const m=i[d],A=a.data[d];l.push({key:{status:"valid",value:d},value:m._parse(new z(a,A,a.path,d)),alwaysSet:d in a.data})}if(this._def.catchall instanceof ce){const d=this._def.unknownKeys;if(d==="passthrough")for(const m of o)l.push({key:{status:"valid",value:m},value:{status:"valid",value:a.data[m]}});else if(d==="strict")o.length>0&&(h(a,{code:f.unrecognized_keys,keys:o}),n.dirty());else if(d!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const d=this._def.catchall;for(const m of o){const A=a.data[m];l.push({key:{status:"valid",value:m},value:d._parse(new z(a,A,a.path,m)),alwaysSet:m in a.data})}}return a.common.async?Promise.resolve().then(async()=>{const d=[];for(const m of l){const A=await m.key,me=await m.value;d.push({key:A,value:me,alwaysSet:m.alwaysSet})}return d}).then(d=>j.mergeObjectSync(n,d)):j.mergeObjectSync(n,l)}get shape(){return this._def.shape()}strict(e){return g.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:g.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:w.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 ye(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 B;)i=i._def.innerType;r[n]=i}return new O({...this._def,shape:()=>r})}keyof(){return Ft(S.objectKeys(this.shape))}}O.create=(t,e)=>new O({shape:()=>t,unknownKeys:"strip",catchall:ce.create(),typeName:w.ZodObject,...k(e)}),O.strictCreate=(t,e)=>new O({shape:()=>t,unknownKeys:"strict",catchall:ce.create(),typeName:w.ZodObject,...k(e)}),O.lazycreate=(t,e)=>new O({shape:t,unknownKeys:"strip",catchall:ce.create(),typeName:w.ZodObject,...k(e)});class Ee 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 Z(o.ctx.common.issues));return h(r,{code:f.invalid_union,unionErrors:s}),v}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 d={...r,common:{...r.common,issues:[]},parent:null},m=l._parseSync({data:r.data,path:r.path,parent:d});if(m.status==="valid")return m;m.status==="dirty"&&!i&&(i={result:m,ctx:d}),d.common.issues.length&&s.push(d.common.issues)}if(i)return r.common.issues.push(...i.ctx.common.issues),i.result;const o=s.map(l=>new Z(l));return h(r,{code:f.invalid_union,unionErrors:o}),v}}get options(){return this._def.options}}Ee.create=(t,e)=>new Ee({options:t,typeName:w.ZodUnion,...k(e)});const ee=t=>t instanceof He?ee(t.schema):t instanceof te?ee(t.innerType()):t instanceof Oe?[t.value]:t instanceof le?t.options:t instanceof ft?S.objectValues(t.enum):t instanceof Re?ee(t._def.innerType):t instanceof Be?[void 0]:t instanceof Se?[null]:t instanceof B?[void 0,...ee(t.unwrap())]:t instanceof de?[null,...ee(t.unwrap())]:t instanceof ht||t instanceof Me?ee(t.unwrap()):t instanceof De?ee(t._def.innerType):[];class We extends T{_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==b.object)return h(r,{code:f.invalid_type,expected:b.object,received:r.parsedType}),v;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:f.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),v)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,n){const a=new Map;for(const i of r){const s=ee(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 We({typeName:w.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:a,...k(n)})}}function dt(t,e){const r=oe(t),n=oe(e);if(t===e)return{valid:!0,data:t};if(r===b.object&&n===b.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=dt(t[o],e[o]);if(!l.valid)return{valid:!1};s[o]=l.data}return{valid:!0,data:s}}else if(r===b.array&&n===b.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=dt(s,o);if(!l.valid)return{valid:!1};a.push(l.data)}return{valid:!0,data:a}}else return r===b.date&&n===b.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}class Ae extends T{_parse(e){const{status:r,ctx:n}=this._processInputParams(e),a=(i,s)=>{if(Mt(i)||Mt(s))return v;const o=dt(i.value,s.value);return o.valid?((Pt(i)||Pt(s))&&r.dirty(),{status:r.value,value:o.data}):(h(n,{code:f.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(([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}))}}Ae.create=(t,e,r)=>new Ae({left:t,right:e,typeName:w.ZodIntersection,...k(r)});class J extends T{_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==b.array)return h(n,{code:f.invalid_type,expected:b.array,received:n.parsedType}),v;if(n.data.length<this._def.items.length)return h(n,{code:f.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),v;!this._def.rest&&n.data.length>this._def.items.length&&(h(n,{code:f.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 z(n,s,n.path,o)):null}).filter(s=>!!s);return n.common.async?Promise.all(i).then(s=>j.mergeArray(r,s)):j.mergeArray(r,i)}get items(){return this._def.items}rest(e){return new J({...this._def,rest:e})}}J.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new J({items:t,typeName:w.ZodTuple,rest:null,...k(e)})};class Ce 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!==b.object)return h(n,{code:f.invalid_type,expected:b.object,received:n.parsedType}),v;const a=[],i=this._def.keyType,s=this._def.valueType;for(const o in n.data)a.push({key:i._parse(new z(n,o,n.path,o)),value:s._parse(new z(n,n.data[o],n.path,o)),alwaysSet:o in n.data});return n.common.async?j.mergeObjectAsync(r,a):j.mergeObjectSync(r,a)}get element(){return this._def.valueType}static create(e,r,n){return r instanceof T?new Ce({keyType:e,valueType:r,typeName:w.ZodRecord,...k(n)}):new Ce({keyType:G.create(),valueType:e,typeName:w.ZodRecord,...k(r)})}}class ut 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!==b.map)return h(n,{code:f.invalid_type,expected:b.map,received:n.parsedType}),v;const a=this._def.keyType,i=this._def.valueType,s=[...n.data.entries()].map(([o,l],d)=>({key:a._parse(new z(n,o,n.path,[d,"key"])),value:i._parse(new z(n,l,n.path,[d,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const l of s){const d=await l.key,m=await l.value;if(d.status==="aborted"||m.status==="aborted")return v;(d.status==="dirty"||m.status==="dirty")&&r.dirty(),o.set(d.value,m.value)}return{status:r.value,value:o}})}else{const o=new Map;for(const l of s){const d=l.key,m=l.value;if(d.status==="aborted"||m.status==="aborted")return v;(d.status==="dirty"||m.status==="dirty")&&r.dirty(),o.set(d.value,m.value)}return{status:r.value,value:o}}}}ut.create=(t,e,r)=>new ut({valueType:e,keyType:t,typeName:w.ZodMap,...k(r)});class _e extends T{_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==b.set)return h(n,{code:f.invalid_type,expected:b.set,received:n.parsedType}),v;const a=this._def;a.minSize!==null&&n.data.size<a.minSize.value&&(h(n,{code:f.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:f.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 d=new Set;for(const m of l){if(m.status==="aborted")return v;m.status==="dirty"&&r.dirty(),d.add(m.value)}return{status:r.value,value:d}}const o=[...n.data.values()].map((l,d)=>i._parse(new z(n,l,n.path,d)));return n.common.async?Promise.all(o).then(l=>s(l)):s(o)}min(e,r){return new _e({...this._def,minSize:{value:e,message:g.toString(r)}})}max(e,r){return new _e({...this._def,maxSize:{value:e,message:g.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}}_e.create=(t,e)=>new _e({valueType:t,minSize:null,maxSize:null,typeName:w.ZodSet,...k(e)});class Ne extends T{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==b.function)return h(r,{code:f.invalid_type,expected:b.function,received:r.parsedType}),v;function n(o,l){return st({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,it(),ke].filter(d=>!!d),issueData:{code:f.invalid_arguments,argumentsError:l}})}function a(o,l){return st({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,it(),ke].filter(d=>!!d),issueData:{code:f.invalid_return_type,returnTypeError:l}})}const i={errorMap:r.common.contextualErrorMap},s=r.data;if(this._def.returns instanceof ve){const o=this;return $(async function(...l){const d=new Z([]),m=await o._def.args.parseAsync(l,i).catch(we=>{throw d.addIssue(n(l,we)),d}),A=await Reflect.apply(s,this,m);return await o._def.returns._def.type.parseAsync(A,i).catch(we=>{throw d.addIssue(a(A,we)),d})})}else{const o=this;return $(function(...l){const d=o._def.args.safeParse(l,i);if(!d.success)throw new Z([n(l,d.error)]);const m=Reflect.apply(s,this,d.data),A=o._def.returns.safeParse(m,i);if(!A.success)throw new Z([a(m,A.error)]);return A.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Ne({...this._def,args:J.create(e).rest(he.create())})}returns(e){return new Ne({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,r,n){return new Ne({args:e||J.create([]).rest(he.create()),returns:r||he.create(),typeName:w.ZodFunction,...k(n)})}}class He 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})}}He.create=(t,e)=>new He({getter:t,typeName:w.ZodLazy,...k(e)});class Oe extends T{_parse(e){if(e.data!==this._def.value){const r=this._getOrReturnCtx(e);return h(r,{received:r.data,code:f.invalid_literal,expected:this._def.value}),v}return{status:"valid",value:e.data}}get value(){return this._def.value}}Oe.create=(t,e)=>new Oe({value:t,typeName:w.ZodLiteral,...k(e)});function Ft(t,e){return new le({values:t,typeName:w.ZodEnum,...k(e)})}class le 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:f.invalid_type}),v}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:f.invalid_enum_value,options:n}),v}return $(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 le.create(e,{...this._def,...r})}exclude(e,r=this._def){return le.create(this.options.filter(n=>!e.includes(n)),{...this._def,...r})}}le.create=Ft;class ft extends T{_parse(e){const r=S.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==b.string&&n.parsedType!==b.number){const a=S.objectValues(r);return h(n,{expected:S.joinValues(a),received:n.parsedType,code:f.invalid_type}),v}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:f.invalid_enum_value,options:a}),v}return $(e.data)}get enum(){return this._def.values}}ft.create=(t,e)=>new ft({values:t,typeName:w.ZodNativeEnum,...k(e)});class ve extends T{unwrap(){return this._def.type}_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==b.promise&&r.common.async===!1)return h(r,{code:f.invalid_type,expected:b.promise,received:r.parsedType}),v;const n=r.parsedType===b.promise?r.data:Promise.resolve(r.data);return $(n.then(a=>this._def.type.parseAsync(a,{path:r.path,errorMap:r.common.contextualErrorMap})))}}ve.create=(t,e)=>new ve({type:t,typeName:w.ZodPromise,...k(e)});class te extends T{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===w.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 v;const l=await this._def.schema._parseAsync({data:o,path:n.path,parent:n});return l.status==="aborted"?v:l.status==="dirty"||r.value==="dirty"?Ie(l.value):l});{if(r.value==="aborted")return v;const o=this._def.schema._parseSync({data:s,path:n.path,parent:n});return o.status==="aborted"?v:o.status==="dirty"||r.value==="dirty"?Ie(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"?v:(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"?v:(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(!ge(s))return v;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=>ge(s)?Promise.resolve(a.transform(s.value,i)).then(o=>({status:r.value,value:o})):v);S.assertNever(a)}}te.create=(t,e,r)=>new te({schema:t,typeName:w.ZodEffects,effect:e,...k(r)}),te.createWithPreprocess=(t,e,r)=>new te({schema:e,effect:{type:"preprocess",transform:t},typeName:w.ZodEffects,...k(r)});class B extends T{_parse(e){return this._getType(e)===b.undefined?$(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}B.create=(t,e)=>new B({innerType:t,typeName:w.ZodOptional,...k(e)});class de extends T{_parse(e){return this._getType(e)===b.null?$(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}de.create=(t,e)=>new de({innerType:t,typeName:w.ZodNullable,...k(e)});class Re extends T{_parse(e){const{ctx:r}=this._processInputParams(e);let n=r.data;return r.parsedType===b.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}}Re.create=(t,e)=>new Re({innerType:t,typeName:w.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...k(e)});class De 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 Ue(a)?a.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Z(n.common.issues)},input:n.data})})):{status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new Z(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}De.create=(t,e)=>new De({innerType:t,typeName:w.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...k(e)});class pt extends T{_parse(e){if(this._getType(e)!==b.nan){const n=this._getOrReturnCtx(e);return h(n,{code:f.invalid_type,expected:b.nan,received:n.parsedType}),v}return{status:"valid",value:e.data}}}pt.create=t=>new pt({typeName:w.ZodNaN,...k(t)});class ht 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 Ke 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"?v:i.status==="dirty"?(r.dirty(),Ie(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"?v: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 Ke({in:e,out:r,typeName:w.ZodPipeline})}}class Me extends T{_parse(e){const r=this._def.innerType._parse(e),n=a=>(ge(a)&&(a.value=Object.freeze(a.value)),a);return Ue(r)?r.then(a=>n(a)):n(r)}unwrap(){return this._def.innerType}}Me.create=(t,e)=>new Me({innerType:t,typeName:w.ZodReadonly,...k(e)});var w;(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"})(w||(w={}));const c=G.create,p=fe.create,X=pe.create,x=Ve.create,Zt=Se.create,_=he.create;ce.create;const E=V.create,u=O.create,I=Ee.create,dn=We.create;Ae.create;const un=J.create,y=Ce.create,mt=Oe.create,ze=le.create;ve.create,B.create,de.create;const re=te.createWithPreprocess;function D(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 B,d=D(l?o.unwrap():o,e+1,r);return`${s}${l?"?":""}: ${d}`}).join(", ")} }`}if(t instanceof Ee)return t.options.map(n=>D(n,e,r)).join(" or ");if(t instanceof G)return"string";if(t instanceof fe)return"number";if(t instanceof Ve)return"boolean";if(t instanceof pe)return"bigint";if(t instanceof Se)return"null";if(t instanceof V){const n=D(t.element,e+1,r);return n==="unknown"||n==="any"?"array":`${n}[]`}if(t instanceof J)return`[${t.items.map(n=>D(n,e+1,r)).join(", ")}]`;if(t instanceof Ce){const n=D(t._def.valueType,e+1,r);return n==="unknown"||n==="any"?"{ [key: string]: unknown }":`{ [key: string]: ${n} }`}return t instanceof B?`${D(t.unwrap(),e,r)}?`:t instanceof Oe?JSON.stringify(t.value):t instanceof le?t.options.map(n=>`"${n}"`).join(" | "):t instanceof ct?"any":t instanceof he?"unknown":t instanceof lt?"void":t instanceof Be?"undefined":t instanceof te?D(t.innerType(),e,r):t instanceof Re?D(t.removeDefault(),e,r):t instanceof de?`${D(t.unwrap(),e,r)} | null`:t instanceof He?"lazy":t instanceof ve?`Promise<${D(t.unwrap(),e+1,r)}>`:t instanceof Ne?"function":t instanceof Te?"Date":t instanceof ut?"Map":t instanceof _e?"Set":t instanceof Ae?`${D(t._def.left,e,r)} & ${D(t._def.right,e,r)}`:t instanceof We?t.options.map(n=>D(n,e,r)).join(" or "):t instanceof ht?D(t.unwrap(),e,r):t instanceof pt?"NaN":t instanceof De?D(t.removeCatch(),e,r):t instanceof Ke?D(t._def.in,e,r):t instanceof Me?`readonly ${D(t.unwrap(),e,r)}`:"unknown"}function fn(t){return t===null?"null":t===void 0?"undefined":Array.isArray(t)?"array":typeof t}function pn(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(d=>d.code==="custom"),l=a.some(d=>d.code!=="invalid_type"&&d.code!=="invalid_literal"&&d.code!=="invalid_union");if(!o&&!l){const d=D(e),m=fn(n);return`Invalid parameters for ${t}: expected ${d}${d==="{ }"?" or no args":""}, received ${m}`}}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 hn(t,e,r,n,a){const i=t.safeParse(Ze(n));if(!i.success)return{ok:!1,error:{message:pn(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(d=>{const m=d.path.join(".");return`invalid return value${m?` at '${m}'`:""} (${d.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=vt(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 Ut=new Map,Ge=new Map;function mn(t){Ut.set(t.registryAction,t)}function Je(t){return Ut.get(t)}function bn(t){for(const e of t)mn(e);try{chrome.runtime.sendMessage({type:"contentScriptReady"})}catch{}}function gn(t){const e=Ge.get(t);return e?(e.abort(),Ge.delete(t),!0):!1}async function yn(t,e,r,n,a){const i=Je(t);if(!i)return{ok:!1,error:{message:`No schema registered for content-script action: ${t}`,code:"E_INTERNAL"}};const s=new AbortController;a&&Ge.set(a,s);try{return await hn(i.params,i.returns,async o=>r(o,s.signal),Ze(n),t)}finally{a&&Ge.delete(a)}}function _n(t,e){if(Je(t))return t;const r=`page_${e}`;return Je(r)?r:t}function vn(t,e){const r=Je(t);return(r==null?void 0:r.handlerKey)??e}function Vt(t,e,r,n,a){const i=_n(t,e),s=vn(i,e),o=$r[s];return o?(yn(i,s,o,r,a).then(d=>{ue.debug("dispatch_response",{registryAction:t,handlerAction:s,ok:d.ok}),n(d)}).catch(d=>{const m=vt(d,{});ue.debug("dispatch_error",{registryAction:t,handlerAction:s,error:m.message}),n({ok:!1,error:m})}),!0):(ue.debug("no_handler",{action:s,registryAction:t}),n({ok:!1,error:`Unknown content script action: ${s}`}),!1)}function wn(){chrome.runtime.onMessage.addListener((t,e,r)=>{if(e.id!==chrome.runtime.id)return ue.warn("unauthorized_sender",{senderId:e.id,expected:chrome.runtime.id}),r({ok:!1,error:"Unauthorized sender"}),!1;const n=q(t),a=String(n.type??""),i=String(n.action??"");if(ue.debug("received",{messageType:a,action:i,hasParams:!!n.params}),a==="registryCallCancel"){const s=String(n.id??"");return gn(s),r({ok:!0}),!1}if(a==="registryCall"){const s=nr(i),o=typeof n.id=="string"?n.id:void 0;return Vt(i,s,n.params,r,o)}return!i&&a==="contract-ping"?(r({ok:!0}),!1):i?i==="ping"?Vt("ping","ping",n.params,r):(r({ok:!1,error:"Use registryCall for content-script actions"}),!1):(r({ok:!1,error:"Missing action"}),!1)})}const U=()=>I([X(),p().finite()]).transform(t=>BigInt(t));u({key:c().describe("Storage key to retrieve")}),u({key:c().describe("Storage key to set"),value:c().describe("Value to store")}),u({key:c().describe("Storage key to delete")}),u({});const xn=u({items:y(c()).describe("Record of key-value string pairs to store")});re(t=>t!==null&&typeof t=="object"&&!Array.isArray(t)&&!("items"in t)?{items:t}:t,xn);const kn=u({keys:E(c()).describe("Array of storage keys to retrieve"),defaults:y(c()).optional().describe("Default string values for missing keys")});re(t=>Array.isArray(t)?{keys:t}:t,kn),u({});const In=u({keys:E(c()).describe("Array of storage keys to delete")});re(t=>Array.isArray(t)?{keys:t}:t,In),u({}),u({}),I([un([I([u({text:c()}),c()])]),u({text:c().optional(),value:c().optional()})]);const Tn=u({url:c().describe("URL to fetch"),method:c().default("GET").describe("HTTP method (GET, POST, PUT, DELETE, etc.)"),headers:y(c()).default({}).describe("Request headers as key-value pairs"),body:c().nullable().default(null).describe("Request body string"),timeout:U().default(30000n).describe("Timeout in milliseconds"),store:x().optional().describe("When true, store binary responses as a handle instead of returning body bytes"),options:u({}).passthrough().optional().describe("Fetch options")}).passthrough();u({duration:U().describe("Duration to sleep in milliseconds")});const ne=()=>c().regex(/^e\d+$/),Sn='use { refId: "e2" } or { label: "..." } object form, not positional arguments',bt=(t,e)=>{if(t.__invalidPositional!==void 0){e.addIssue({code:f.custom,message:Sn});return}!t.refId&&!t.label&&e.addIssue({code:f.custom,message:"Either refId or label is required"})},Bt=(t,e)=>{t.x!==void 0||t.y!==void 0||bt(t,e)},M=t=>re(e=>typeof e=="string"||typeof e=="number"?{__invalidPositional:e}:e,u({__invalidPositional:I([c(),p()]).optional().describe("Internal flag for positional argument rejection"),refId:ne().optional().describe("Element reference ID (e.g. e2)"),label:c().optional().describe("Human-readable element label"),...t}).superRefine(bt)),Pe={tabId:I([p(),X()]).optional().describe("Target tab ID")},ae=t=>re(e=>typeof e=="string"||typeof e=="number"?{__invalidPositional:e}:e,u({__invalidPositional:I([c(),p()]).optional().describe("Internal flag for positional argument rejection"),...Pe,refId:ne().optional().describe("Element reference ID (e.g. e2)"),label:c().optional().describe("Human-readable element label"),...t}).superRefine(bt));u({}),u({}),u({url:c().describe("URL to navigate to"),timeout:U().optional().describe("Navigation timeout in milliseconds"),waitUntil:ze(["load","networkidle"]).optional().describe("When to consider navigation complete: 'load' (tab status complete) or 'networkidle' (no in-flight requests for 500ms)")});const En=u({}),An=u({});u({}),u({duration:U().default(1000n).describe("Duration to wait in milliseconds")});const Cn=M(),Nn=(t,e)=>{[t.url,t.path,t.handle].filter(n=>typeof n=="string"&&n.length>0).length!==1&&e.addIssue({code:f.custom,message:"Each file entry requires exactly one of url, path, or handle"})},Wt=u({name:c().optional().describe("File name including extension"),mimeType:c().optional().describe("MIME type (defaults to application/octet-stream)"),url:c().url().optional().describe("HTTP(S) URL to fetch in the target tab"),path:c().min(1).optional().describe("Virtual filesystem path (resolved in worker)"),handle:c().min(1).optional().describe("Binary handle from page.fetch({ store: true })")}).superRefine(Nn),Ht=dn("kind",[u({kind:mt("bytes"),name:c().min(1),data:c().min(1),mimeType:c().optional()}),u({kind:mt("url"),url:c().url(),name:c().min(1),mimeType:c().optional()})]),On=M({value:c().describe("Value to fill into the element")}),Rn=M({files:E(Wt).min(1).describe("Files to attach to the input")}),Dn=M({files:E(Ht).min(1).describe("Resolved files for content-script application")}),Mn=M({text:c().describe("Text to type into the element")}),Pn=M({text:c().describe("Text to append into the element")}),qn=u({key:c().describe("Key to press (e.g. Enter, Escape, ArrowDown)")}),Ln=M({value:c().describe("Value to select in the dropdown")}),jn=M({checked:x().optional().describe("Desired checked state (true to check, false to uncheck)")}),$n=M(),Fn=u({}),Zn=u({direction:c().default("down").describe("Scroll direction: up, down, left, or right"),amount:p().default(300).describe("Pixels to scroll")}),Un=re(t=>typeof t=="string"||typeof t=="number"?{__invalidPositional:t}:t,u({__invalidPositional:I([c(),p()]).optional().describe("Internal flag for positional argument rejection"),refId:ne().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(Bt)),Vn=M(),Bn=u({selector:c().describe("CSS selector to find elements")}),Wn=u({selector:c().describe("CSS selector to wait for"),timeout:U().default(30000n).describe("Timeout in milliseconds")}),Hn=u({fields:E(c()).describe("Array of field names to extract")}),Kn=re(t=>Array.isArray(t)?{fields:t}:t,Hn);I([p(),E(u({}).passthrough()),u({}).passthrough()]),u({}),u({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(),re(t=>typeof t=="string"?{url:t}:t,u({url:c().optional().describe("URL to open in the new tab"),active:x().optional().describe("Whether to focus the new tab")})),I([p(),E(u({id:p().optional(),tabId:p().optional(),tab_id:p().optional()}).passthrough()),u({id:p().optional(),tabId:p().optional(),tab_id:p().optional()}).passthrough()]);const zn=ae(),Gn=ae({value:c().describe("Value to fill into the element")}),Jn=ae({files:E(Wt).min(1).describe("Files to attach to the input")}),Xn=ae({files:E(Ht).min(1).describe("Resolved files for content-script application")}),Qn=re(t=>typeof t=="string"||typeof t=="number"?{__invalidPositional:t}:t,u({__invalidPositional:I([c(),p()]).optional().describe("Internal flag for positional argument rejection"),...Pe,refId:ne().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(Bt)),Yn=ae({text:c().describe("Text to type into the element")}),ea=u({...Pe,key:c().describe("Key to press (e.g. Enter, Escape, ArrowDown)")}),ta=ae({value:c().describe("Value to select in the dropdown")}),ra=ae({checked:x().optional().describe("Desired checked state (true to check, false to uncheck)")}),na=ae(),aa=u({...Pe}),ia=u({...Pe,direction:c().default("down").describe("Scroll direction: up, down, left, or right"),amount:p().default(300).describe("Pixels to scroll")}),sa=ae(),oa=u({tabId:I([p(),X()]).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(),ca=u({tabId:I([p(),X()]).optional().describe("Target tab ID")}).passthrough(),la=u({tabId:I([p(),X()]).optional().describe("Target tab ID")}).passthrough();u({tabId:I([p(),X()]).optional().describe("Target tab ID"),timeout:p().optional().describe("Timeout in milliseconds")}).passthrough();const da=u({tabId:I([p(),X()]).optional().describe("Target tab ID"),url:c().optional().describe("URL to fetch"),options:u({}).passthrough().optional().describe("Fetch options")}).passthrough(),ua=u({tabId:I([p(),X()]).optional().describe("Target tab ID"),max_nodes:p().optional().describe("Maximum nodes to include"),options:u({}).passthrough().optional().describe("Snapshot options")}).passthrough(),fa=u({tabId:I([p(),X()]).optional().describe("Target tab ID"),max_nodes:p().optional().describe("Maximum nodes to include"),options:u({}).passthrough().optional().describe("Snapshot options")}).passthrough(),pa=u({tabId:I([p(),X()]).optional().describe("Target tab ID"),max_nodes:p().optional().describe("Maximum nodes to include"),options:u({}).passthrough().optional().describe("Snapshot options")}).passthrough();M(),M(),M({value:c().optional().describe("Value to fill into the element")}),M({text:c().optional().describe("Text to type into the element")}),u({key:c().optional().describe("Key to press (e.g. Enter, Escape, ArrowDown)")}),M({value:c().optional().describe("Value to select in the dropdown")}),M({checked:x().optional().describe("Desired checked state (true to check, false to uncheck)")}),M(),u({}),u({direction:c().optional().describe("Scroll direction: up, down, left, or right"),amount:p().optional().describe("Pixels to scroll")}),M(),M({text:c().optional().describe("Text to append into the element")}),u({}),u({}),u({duration:U().default(1000n).describe("Duration to wait in milliseconds")}),u({interactive_only:x().default(!1).describe("Only include interactive elements"),max_nodes:U().default(500n).describe("Maximum number of nodes to include in snapshot")}),u({interactive_only:x().default(!1).describe("Only include interactive elements"),max_nodes:U().default(500n).describe("Maximum number of nodes to include in snapshot")}),u({interactive_only:x().default(!1).describe("Only include interactive elements"),max_nodes:U().default(500n).describe("Maximum number of nodes to include in snapshot")}),u({interactive_only:x().default(!1).describe("Only include interactive elements"),max_nodes:U().default(500n).describe("Maximum number of nodes to include in snapshot")}),u({snapshot:u({}).passthrough().describe("Raw DOM snapshot data to format"),format:c().optional().describe("Output format (e.g. markdown, html)")});const ha=u({max_nodes:p().optional().describe("Maximum nodes to include"),options:u({}).passthrough().optional().describe("Snapshot options")}).passthrough(),ma=u({max_nodes:p().optional().describe("Maximum nodes to include"),options:u({}).passthrough().optional().describe("Snapshot options")}).passthrough(),ba=u({max_nodes:p().optional().describe("Maximum nodes to include"),options:u({}).passthrough().optional().describe("Snapshot options")}).passthrough(),ga=u({role:I([c(),E(c())]).optional().describe("Filter by ARIA role"),tag:I([c(),E(c())]).optional().describe("Filter by HTML tag"),text:c().optional().describe("Filter by text content (case-insensitive substring)"),name:c().optional().describe("Filter by accessible name (case-insensitive substring)"),interactiveOnly:x().optional().describe("Only include interactive elements"),href:c().optional().describe("Filter by href pattern (case-insensitive substring)"),src:c().optional().describe("Filter by src pattern (case-insensitive substring)"),limit:p().positive().optional().describe("Maximum filtered nodes to return")}).passthrough(),Kt=u({filter:ga.optional().describe("Semantic filter criteria"),max_nodes:p().optional().describe("Maximum nodes to collect before filtering")}).passthrough(),ya=Kt.extend({tabId:p().describe("Tab ID")});u({path:c().describe("File or directory path")}),u({from:c().describe("Source path"),to:c().describe("Destination path")}),u({path:c().describe("File path to write to"),data:c().describe("Data to write")}),u({path:c().describe("File path to read from"),offset:U().describe("Byte offset to start reading"),len:p().describe("Number of bytes to read")}),u({path:c().describe("File path to update"),offset:U().describe("Byte offset to start writing"),data:c().describe("Data to write")}),u({path:c().describe("File path to hash"),algo:c().default("sha256").describe("Hash algorithm (e.g. sha256, md5)")}),y(_()),y(_()),y(_()),y(_()),I([p(),y(_())]),I([p(),y(_())]),y(_()),y(_()),y(_()),I([c(),y(_())]),y(_()),y(_()),y(_()),y(_()),y(_()),I([c(),p(),y(_())]),y(_()),y(_()),y(_()),I([p(),y(_())]),y(_()),y(_()),y(_()),y(_()),y(_()),E(_()),I([c(),y(_())]),y(_()),I([c(),y(_())]),y(_()),I([c(),y(_())]),y(_()),I([c(),y(_())]),y(_()),y(_()),I([p(),y(_())]),y(_()),y(_()),I([p(),y(_())]),y(_()),I([c(),p(),y(_())]),y(_()),y(_()),y(_()),y(_()),I([p(),y(_())]),I([p(),y(_())]),I([p(),y(_())]),I([p(),y(_())]),I([p(),y(_())]),y(_()),y(_()),y(_()),u({action:c().describe("Host action name"),params:u({}).passthrough().optional().describe("Parameters for the host action")}).passthrough();const _a=I([c(),p(),x(),Zt(),E(_()),y(_())]),C=u({ok:mt(!0).describe("Whether the action succeeded"),action:c().describe("Action identifier (e.g. 'page_fill')"),refId:ne().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)"),fileCount:p().optional().describe("Number of files attached (for setFiles actions)"),fileNames:E(c()).optional().describe("Names of attached files (for setFiles actions)")});I([C,Zt()]);const zt=u({status:p().describe("HTTP response status code"),ok:x().describe("Whether the response status is 2xx"),headers:y(c()).describe("Response headers as key-value pairs"),body:c().optional().describe("Response body (omitted when bodyEncoding is handle)"),bodyEncoding:ze(["text","base64","handle"]).describe("Encoding of the body field"),handle:c().optional().describe("Binary handle when bodyEncoding is handle"),byteLength:p().describe("Length of the body in bytes"),contentType:c().describe("Response Content-Type header"),finalUrl:c().describe("Final URL after redirects")});u({data:u({}).passthrough().describe("Structured snapshot data"),text:c().describe("Plain text representation of the snapshot")}),u({}),u({tabId:p(),url:c(),title:c(),contentScript:ze(["connected","missing"]),domApis:ze(["ok","blocked"]),mutationsReady:x(),hint:c().optional(),recovery:E(c()).optional()});const va=_a,wa=u({refId:ne().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"),text:c().optional().describe("Visible text content 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"),href:c().optional().describe("Absolute URL for link elements"),src:c().optional().describe("Absolute URL for image elements"),alt:c().optional().describe("Alternative text for image elements"),title:c().optional().describe("Title attribute"),parentRefId:ne().optional().describe("Reference ID of the parent container element"),postId:c().optional().describe("Stable post identifier from data-post-id attribute"),permalink:c().optional().describe("Stable permalink URL from anchor element"),imageUrls:E(c()).optional().describe("Image URLs contained within this element")}),Xe=u({text:c().describe("Plain text representation of the page"),nodes:E(wa).describe("Array of interactive nodes"),url:c().describe("Current page URL"),title:c().describe("Current page title"),viewport:u({width:p().describe("Viewport width in pixels"),height:p().describe("Viewport height in pixels")}).describe("Viewport dimensions")}),Gt=u({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(),xa=E(Gt),Jt=u({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:xa.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();E(Jt);const ka=u({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();E(ka.nullable().unwrap());const Ia=u({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:E(u({id:c()}).passthrough()).optional().describe("Child bookmarks")}).passthrough();E(Ia);const Ta=u({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();E(Ta);const Sa=u({frameId:p().describe("Frame ID"),result:_().optional().describe("Script result")});E(Sa),c(),x(),I([c(),p()]),x();const Ea=u({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();E(Ea);const Aa=u({lastModified:p().optional().describe("Last modified time"),tab:Gt.optional().describe("Tab info"),window:Jt.optional().describe("Window info")}).passthrough(),Ca=E(Aa),Na=u({deviceName:c().optional().describe("Device name"),sessions:Ca.optional().describe("Sessions")}).passthrough();E(Na);const Oa=u({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();E(Oa),p(),u({archName:c().describe("CPU architecture"),modelName:c().describe("CPU model"),numOfProcessors:p().describe("Number of processors"),features:E(c()).describe("CPU features")}),u({capacity:p().describe("Total memory capacity"),availableCapacity:p().describe("Available memory capacity")}),E(u({id:c().describe("Storage ID"),name:c().describe("Storage name"),type:c().describe("Storage type"),capacity:p().describe("Storage capacity")}));const Q="Returns a Promise; await before reading the result. For a cell's last line, use `page.snapshot()` without a leading await so the cell returns the settled value.",Ra=[{action:"page_back",namespace:"page",name:"back",description:"Go back in the active tab",params:En,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:Cn,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:[Q,"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:On,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:[Q,"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_set_files",namespace:"page",name:"setFiles",description:"Attach files to a file input in the active tab",params:Rn,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:"files",type:"{ name?: string, url?: string, path?: string, handle?: string, mimeType?: string }[]",required:!0,description:"Each entry uses exactly one of url, path (vfs), or handle (from page.fetch store:true)"}],returnDoc:"{ ok: true, action: 'setFiles', refId?, fileCount?, fileNames? }",errorCode:"E_MISSING_PARAM",example:'page.setFiles({ refId: "e3", files: [{ url: "https://example.com/photo.jpg", name: "photo.jpg" }] })',agentMeta:{prerequisites:["Ensure the target tab is active and the content script is ready before mutating"],notes:[Q,"Target must be input[type=file]; prefer url, vfs path, or fetch handle — bytes are not passed through QuickJS","Use page.fetch({ url, store: true }) then setFiles({ files: [{ handle }] }) for downloaded binaries","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.setFiles","page.fetch","fs.writeBase64"]},handlerKey:"set_files"},{action:"page_type",namespace:"page",name:"type",description:"Type into an element in the active tab",params:Mn,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:[Q,"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:Pn,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:qn,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:Ln,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:jn,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:$n,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:Fn,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:Zn,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:Un,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:Vn,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:zn,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:Gn,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_set_files",namespace:"web.tab",name:"setFiles",description:"Attach files to a file input in a tab",params:Jn,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:"files",type:"{ name?: string, url?: string, path?: string, handle?: string, mimeType?: string }[]",required:!0,description:"Each entry uses exactly one of url, path (vfs), or handle"}],returnDoc:"{ ok: true, action: 'setFiles', refId?, fileCount?, fileNames? }",errorCode:"E_NO_TAB",example:'web.tab.setFiles({ tabId: 123, refId: "e3", files: [{ url: "https://example.com/photo.jpg" }] })',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.setFiles"]},handlerKey:"set_files"},{action:"tab_scroll_to",namespace:"web.tab",name:"scroll_to",description:"Scroll to position in a tab",params:Qn,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:Yn,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:ea,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:ta,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:ra,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:na,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:aa,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:ia,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:sa,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:ca,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"},{action:"page_forward",namespace:"page",name:"forward",description:"Go forward in the active tab",params:An,returns:C,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:ha,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:[Q,"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:ma,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:ba,returns:Xe,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:[Q,"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_snapshot_query",namespace:"page",name:"snapshot_query",description:"Query page snapshot with semantic filtering by role, tag, text, name, etc.",params:Kt,returns:Xe,paramTypes:[{name:"filter",type:"{ role?: string | string[], tag?: string | string[], text?: string, name?: string, interactiveOnly?: boolean, href?: string, src?: string, limit?: number }",required:!1,description:"Semantic filter criteria (literal)"},{name:"max_nodes",type:"number",required:!1,description:"Maximum nodes to collect before filtering (literal)"}],returnDoc:"{ text, nodes (filtered), url, title, viewport }",errorCode:"E_SNAPSHOT",example:'page.snapshot_query({ filter: { role: "button" } })',agentMeta:{notes:[Q,"Content-script path; filters nodes by role, tag, text, name, interactiveOnly, href, src","More efficient than page.snapshot_data() when only specific elements are needed"],tags:["snapshot","read"],relatedApis:["page.snapshot_data","page.find"]},handlerKey:"snapshot_query"},{action:"page_find",namespace:"page",name:"find",description:"Find elements in the active tab using a CSS selector",params:Bn,returns:E(u({refId:ne(),role:c(),tag:c(),name:c().optional(),text:c().optional(),value:c().optional(),checked:x().optional(),disabled:x().optional(),readOnly:x().optional(),href:c().optional(),src:c().optional(),alt:c().optional(),title:c().optional(),parentRefId:ne().optional()})),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 with refId, role, name, href/src, alt, and parentRefId",errorCode:"E_NO_TAB",example:'page.find("h1")',agentMeta:{notes:["Assigns data-ref-id on matched elements when missing so results include actionable refIds"],tags:["read"]},handlerKey:"find"},{action:"page_wait_for",namespace:"page",name:"wait_for",description:"Wait for a selector in the active tab",params:Wn,returns:x(),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)',agentMeta:{notes:[Q],tags:["read"]},handlerKey:"wait_for"},{action:"page_extract",namespace:"page",name:"extract",description:"Extract data from the active tab",params:Kn,returns:u({title:c().optional(),url:c().optional(),headings:E(u({tag:c(),text:c()})).optional(),links:E(u({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:{notes:[Q],tags:["read"]},handlerKey:"extract"},{action:"page_fetch",namespace:"page",name:"fetch",description:"Fetch in the active tab",params:Tn,returns:zt,fields:["url","options"],paramTypes:[{name:"url",type:"string",required:!1,description:"URL to fetch (url)"},{name:"options",type:"{ method?: string, headers?: { [key: string]: string }, 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:{notes:[Q,"Runtime binary globals available: Uint8Array, ArrayBuffer, TextEncoder, TextDecoder, atob, btoa","For binary responses bodyEncoding is 'base64'; use atob() or fs.writeBase64 to handle bytes"],tags:["read"]},handlerKey:"fetch"},{action:"tab_forward",namespace:"web.tab",name:"forward",description:"Go forward in a tab",params:la,returns:C,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:ua,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:fa,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:pa,returns:Xe,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_snapshot_query",namespace:"web.tab",name:"snapshot_query",description:"Query tab snapshot with semantic filtering by role, tag, text, name, etc.",params:ya,returns:Xe,fields:["tabId"],paramTypes:[{name:"tabId",type:"number",required:!0,description:"Tab ID (literal)"},{name:"filter",type:"{ role?: string | string[], tag?: string | string[], text?: string, name?: string, interactiveOnly?: boolean, href?: string, src?: string, limit?: number }",required:!1,description:"Semantic filter criteria (literal)"},{name:"max_nodes",type:"number",required:!1,description:"Maximum nodes to collect before filtering (literal)"}],returnDoc:"{ text, nodes (filtered), url, title, viewport }",errorCode:"E_SNAPSHOT",example:'web.tab.snapshot_query({ tabId: 123, filter: { role: "button" } })',agentMeta:{notes:["Explicit tabId required; same handler as page.snapshot_query","Filters nodes by role, tag, text, name, interactiveOnly, href, src"],tags:["snapshot","read"],relatedApis:["page.snapshot_query"]},handlerKey:"snapshot_query"},{action:"tab_fetch",namespace:"web.tab",name:"fetch",description:"Fetch in a tab",params:da,returns:zt,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:oa,returns:va,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 Da(){return[{registryAction:"ping",handlerKey:"ping",params:u({}),returns:u({ok:x()})}]}const Ma=new Set(["page_set_files","tab_set_files"]);function Pa(){return Ra.map(t=>({registryAction:t.action,handlerKey:t.handlerKey,params:Ma.has(t.action)?t.action==="tab_set_files"?Xn:Dn:t.params,returns:t.returns}))}if(rr(),window.__jsNotebookContentScriptInjected)throw new Error("Content script already injected");window.__jsNotebookContentScriptInjected=!0,bn([...Pa(),...Da()]),wn()})();
1
+ (function(){"use strict";const Q={debug:0,info:1,warn:2,error:3,none:4};let Tt=Q.error;function hr(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 Ve(t,e,r){if(t<Tt)return;const n=hr(r),a=`[extension-js][content-script] ${e}${n}`;t>=Q.error?console.error(a):t===Q.warn?console.warn(a):console.log(a)}const me={debug:(t,e)=>{Ve(Q.debug,t,e)},info:(t,e)=>{Ve(Q.info,t,e)},warn:(t,e)=>{Ve(Q.warn,t,e)},error:(t,e)=>{Ve(Q.error,t,e)}};function mr(){window.__jsNotebookSetLogLevel=t=>{Tt=Q[t]??Q.error}}function br(t){if(t.startsWith("page_")||t.startsWith("tab_")){const e=t.indexOf("_");if(e>=0)return t.slice(e+1)}return t}const gr="Content script is not connected on this tab. This tab was likely open before the extension loaded (MV3 does not retro-inject).";function yr(t){return[`await page.goto(${JSON.stringify(t||"")})`,"Or ask the user to refresh the target tab, then retry fill/click"]}function St(t,e){const r=e||"unknown url",n={message:t!==void 0?`Content script is not connected on tab ${t} (${r}).`:`Content script is not connected on this tab (${r}).`,code:"E_CONTENT_SCRIPT",category:"content-script",hint:gr,recovery:yr(e)};return t!==void 0&&(n.details={tabId:t,url:r}),n}function vr(t,e){var s,o;const r=t?"refId":e!=null&&e.label?"label":null,n=t||(e==null?void 0:e.label)||"";let a=`Element not found${r?` by ${r} "${n}"`:""}`;if(e!=null&&e.label&&((s=e.candidates)!=null&&s.length)){const l=e.candidates.map(d=>d.name||d.refId).filter(Boolean).slice(0,5);l.length>0?a+=`. Candidates: ${l.join(", ")}`:a+=". Candidates: none"}const i={message: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}};return(o=e==null?void 0:e.candidates)!=null&&o.length&&(i.details={...i.details,candidates:e.candidates}),i}function Ie(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 _r(t){return{message:`${t} requires a fresh observation before acting.`,code:"E_OBSERVATION_REQUIRED",category:"observation",hint:"Element refIds are only valid after a snapshot. Take a fresh observation and select a refId from its returned nodes.",recovery:["const d = await page.snapshot_data(); find the target in d.nodes","Use a refId from that snapshot only"],details:{action:t}}}function wr(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")||t.includes("message port closed before a response was received")}function O(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 kr(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 xr(t){if(!(t instanceof Error))return{};const e=t.name!=="Error"?t.name:void 0,r=t.stack;let n;if(r){const a=r.match(/:(\d+):\d+\)?$/m);a&&(n=parseInt(a[1],10))}return{name:e,stack:r,line:n}}function Et(t,e){if(typeof t=="object"&&t!==null&&"code"in t&&typeof t.code=="string"&&"message"in t&&typeof t.message=="string"){const o=t;return o.hint||o.recovery?o:o.code==="E_CONTENT_SCRIPT"?St(e==null?void 0:e.tabId,e==null?void 0:e.url):o}const r=(t instanceof Error?t.message:String(t))||"",{name:n,stack:a,line:i}=xr(t);if(wr(r))return St(e==null?void 0:e.tabId,e==null?void 0:e.url);if(r.includes("permission")||r.includes("Permission")){const o={message:r,code:"E_PERMISSION",category:"permission"};return(n||a||i)&&(o.details={name:n,stack:a,line:i}),o}if(r.includes("not found")||r.includes("No tab")||r.includes("No active tab")){const o={message:r,code:"E_NOT_FOUND",category:"resource"};return(n||a||i)&&(o.details={name:n,stack:a,line:i}),o}const s={message:r,code:"E_EXTENSION",category:"extension"};return(n||a||i)&&(s.details={name:n,stack:a,line:i}),s}const Ir=/^e\d+$/;let At=0;function Ct(){let t=0;for(const e of document.querySelectorAll("[data-ref-id]")){const r=e.getAttribute("data-ref-id");if(!r)continue;const n=parseInt(r.replace(/^e/,""),10);!Number.isNaN(n)&&n>t&&(t=n)}At=t}function st(t){const e=t.getAttribute("data-ref-id");if(e&&Ir.test(e))return e;const r=`e${++At}`;return t.setAttribute("data-ref-id",r),r}const ot='input, textarea, select, button, a, [role="button"], [role="link"]',Tr=new Set(["script","style","noscript","template"]),Nt=new Set(["p","span","label","footer","header","blockquote","pre","code","figcaption","td","th","li","em","strong","small","cite","q","mark","time","abbr","dfn","kbd","samp","var","sub","sup"]);function ct(t){const e={};return t instanceof HTMLInputElement?(t.type!=="password"&&t.type!=="hidden"&&(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 Sr(t,e){const r=t.tagName.toLowerCase();r!=="input"&&r!=="textarea"&&r!=="select"||Object.assign(e,ct(t))}const Er=new Set(["http:","https:","file:"]);function be(t){if(t)try{const e=new URL(t,window.location.href);return Er.has(e.protocol)?e.href:void 0}catch{return}}function Ot(t){const e=t.closest("article[data-post-id], [data-post-id]");if(e)return st(e)}function Ar(t){const e=t.querySelector(":scope > h2 a[href], a[data-permalink], a[rel='permalink']");if(e instanceof HTMLAnchorElement)return e;const r=t.querySelector("a[href]");return r instanceof HTMLAnchorElement?r:null}function X(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 Cr(t){var e;for(const r of t.childNodes)if(r.nodeType===Node.TEXT_NODE&&((e=r.textContent)==null?void 0:e.trim()))return!0;return!1}function Rt(t,e=60){var a,i;const r=[];for(const s of t.childNodes)if(s.nodeType===Node.TEXT_NODE){const o=(a=s.textContent)==null?void 0:a.trim();o&&r.push(o)}if(r.length>0)return r.join(" ").slice(0,e);const n=(i=t.textContent)==null?void 0:i.trim();return n?n.slice(0,e):""}function Dt(t){let e=t;for(;e;){if(e.hidden||e.getAttribute("aria-hidden")==="true"||e.inert)return!0;const r=window.getComputedStyle(e);if(r.display==="none"||r.visibility==="hidden")return!0;e=e.parentElement}return!1}function Nr(t){return Dt(t)}function Mt(t){var s;const e=t.tagName.toLowerCase();if(Tr.has(e)||Nr(t))return!1;const r=X(t);if(r==="presentation"||r==="none")return!1;if(r!=="generic")return!0;const n=t.getAttribute("aria-live");if(n&&n!=="off")return!0;const a=t.getAttribute("role");return a==="status"||a==="alert"?!0:((s=t.textContent)==null?void 0:s.trim())||""?!!(Nt.has(e)||Cr(t)):!1}function ge(t){var s,o,l;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((s=d.textContent)==null?void 0:s.slice(0,60))||""}if(t.tagName.toLowerCase()==="img"){const d=t.getAttribute("alt");if(d)return d}const a=t.title;if(a)return a;const i=X(t);if(i!=="generic"&&i!=="list"&&i!=="table"&&i!=="row"&&i!=="region"&&i!=="navigation"&&i!=="main")return((o=t.textContent)==null?void 0:o.trim().slice(0,60))||"";if(i==="generic"&&Mt(t)){const d=Rt(t);if(d)return d;const m=t.tagName.toLowerCase();if(Nt.has(m)||t.childElementCount===0)return((l=t.textContent)==null?void 0:l.trim().slice(0,60))||""}return""}function Or(t){return Mt(t)}function Y(t){return document.querySelector(`[data-ref-id='${CSS.escape(t)}']`)}function se(t,e){if(t.hasAttribute("disabled")||t.getAttribute("aria-disabled")==="true"){const r=t.getAttribute("data-ref-id")||void 0;O(Ie(e,r??"",{reason:"disabled"}))}if(Dt(t)){const r=t.getAttribute("data-ref-id")||void 0;O(Ie(e,r??"",{reason:"hidden"}))}}function ee(t){var n,a,i;const e=t.toLowerCase().trim();if(!e)return null;const r=Array.from(document.querySelectorAll(ot));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 d=s.id;if(d){const he=document.querySelector(`label[for='${CSS.escape(d)}']`);if(he&&((n=he.textContent)==null?void 0:n.trim().toLowerCase())===e)return s}const m=s.closest("label");if(m&&((a=m.textContent)==null?void 0:a.trim().toLowerCase())===e||(((i=s.textContent)==null?void 0:i.trim().toLowerCase())||"")===e)return s}return null}function Rr(t){var a;const e=t.toLowerCase().trim();if(!e)return[];const r=Array.from(document.querySelectorAll(ot)),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(A=>A.toLowerCase().includes(e)))continue;const m=i.getAttribute("data-ref-id");if(m&&(n.push({refId:m,role:X(i),name:ge(i)||void 0}),n.length>=5))break}return n}function q(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)?t:{}}function N(t,e){const r=q(t)[e];return typeof r=="string"?r:""}function Pt(t,e,r){const n=q(t)[e];return typeof n=="number"?n:r}function Dr(t){const e=document.querySelector(`[data-ref-id='${CSS.escape(t)}']`);let r,n;e&&(r=e.tagName.toLowerCase(),n=X(e));const a=Array.from(document.querySelectorAll(ot)),i=[];for(const s of a){const o=s.getAttribute("data-ref-id");if(o){if(r||n){const l=s.tagName.toLowerCase(),d=X(s);if(l!==r&&d!==n)continue}if(i.push({refId:o,role:X(s),name:ge(s)||void 0}),i.length>=5)break}}return i}function V(t,e,r=!1){if(t){const n=r?Dr(t):[];O(vr(t,{candidates:n}))}if(e){const n=r?Rr(e):[];O(kr(e,n))}O({message:"Element not found",code:"E_NOT_FOUND",category:"resource"})}const qt=8*1024;function Mr(t){const e=atob(t),r=new Uint8Array(e.length);for(let n=0;n<e.length;n++)r[n]=e.charCodeAt(n);return r}function Pr(t){let e="";for(let r=0;r<t.length;r+=qt){const n=t.subarray(r,r+qt);for(let a=0;a<n.length;a++)e+=String.fromCharCode(n[a])}return btoa(e)}function qr(t){return t.toLowerCase().split(";")[0].trim()}function Lr(t){return t.startsWith("image/")||t.startsWith("audio/")||t.startsWith("video/")||t==="application/octet-stream"||t==="application/pdf"||t==="application/zip"||t==="application/gzip"||t==="application/x-gzip"||t==="application/x-zip-compressed"?!0:t.startsWith("application/vnd.")}function $r(t){for(let e=0;e<t.length;e++)if(t[e]===0)return!0;return!1}function Lt(t){return Object.fromEntries(t.headers.entries())}function $t(t,e,r){return{status:t.status,ok:t.ok,headers:Lt(t),body:Pr(e),bodyEncoding:"base64",byteLength:e.length,contentType:r,finalUrl:t.url}}function jt(t,e,r){return{status:t.status,ok:t.ok,headers:Lt(t),body:e,bodyEncoding:"text",byteLength:new TextEncoder().encode(e).length,contentType:r,finalUrl:t.url}}async function jr(t){const e=t.headers.get("content-type")||"",r=qr(e);if(Lr(r)){const a=new Uint8Array(await t.arrayBuffer());return $t(t,a,e)}if(!r||r.startsWith("text/")){const a=new Uint8Array(await t.arrayBuffer());if($r(a))return $t(t,a,e);const i=new TextDecoder().decode(a);return jt(t,i,e)}const n=await t.text();return jt(t,n,e)}const Fr=new Set(["button","link","textbox","checkbox","radio","combobox","searchbox","switch","menuitem","tab","treeitem"]),Ur=new Set(["a","button","input","textarea","select","details","summary"]);function Be(t){if(t instanceof RegExp)return r=>t.test(r);if(typeof t!="string")return()=>!1;const e=t.toLowerCase();return r=>r.toLowerCase().includes(e)}function Ft(t){return Array.isArray(t)?new Set(t.filter(e=>typeof e=="string").map(e=>e.toLowerCase())):typeof t!="string"?new Set:new Set([t.toLowerCase()])}function Zr(t,e){let r=t;if(e.role){const n=Ft(e.role);r=r.filter(a=>n.has(a.role.toLowerCase()))}if(e.tag){const n=Ft(e.tag);r=r.filter(a=>n.has(a.tag.toLowerCase()))}if(e.text){const n=Be(e.text);r=r.filter(a=>a.text!==void 0&&n(a.text))}if(e.name){const n=Be(e.name);r=r.filter(a=>a.name!==void 0&&n(a.name))}if(e.href){const n=Be(e.href);r=r.filter(a=>a.href!==void 0&&n(a.href))}if(e.src){const n=Be(e.src);r=r.filter(a=>a.src!==void 0&&n(a.src))}return e.interactiveOnly&&(r=r.filter(n=>Fr.has(n.role.toLowerCase())||Ur.has(n.tag.toLowerCase()))),e.limit!==void 0&&e.limit>0&&(r=r.slice(0,e.limit)),r}function Ut(t){return{tag:t.tagName.toLowerCase(),role:X(t),name:ge(t)}}function Vr(t,e){return t.tag===e.tag&&t.role===e.role&&t.name===e.name}let Te=!1,Zt=0,We,Se=null,Ee=new Map;function Br(){Vt(),!(typeof MutationObserver>"u"||!document.body)&&(Se=new MutationObserver(()=>{He()}),Se.observe(document.body,{childList:!0,subtree:!0}))}function Vt(){Se&&(Se.disconnect(),Se=null)}function Wr(t=[]){Zt+=1,We=`obs${Zt}`,Te=!0,Ee=new Map;for(const e of t)Ee.set(e.refId,{element:e.element,fingerprint:Ut(e.element)});return Br(),We}function He(){Vt(),Te=!1,We=void 0,Ee=new Map}function Hr(){return Te}function lt(){return We}function Bt(t,e){Te||Wt(e);const r=Ee.get(t);r||Ke(t,"not_in_latest_observation");const{element:n,fingerprint:a}=r;n.isConnected||Ke(t,"disconnected");const i=Ut(n);return Vr(i,a)||Ke(t,"fingerprint_changed"),n}function Wt(t){const e=new Error(`${t} requires a fresh observation before acting.`);throw e.code="E_OBSERVATION_REQUIRED",e.category="observation",e.hint="Element refIds are only valid after a snapshot. Take a fresh observation and select a refId from its returned nodes.",e.recovery=["const d = await page.snapshot_data(); find the target in d.nodes","Use a refId from that snapshot only"],e.details={action:t},e}function Ke(t,e){const r=new Error(`Element refId "${t}" is stale (${e}).`);throw r.code="E_STALE",r.category="observation",r.hint="The element changed or was removed after the last observation.",r.recovery=["const d = await page.snapshot_data(); find the target in d.nodes","Use a fresh refId from that snapshot only"],r.details={staleRefId:t,reason:e},r}function Kr(t,e){Te||Wt(e);const r=t.toLowerCase().trim(),n=[];for(const i of Ee.values())ge(i.element).toLowerCase().trim()===r&&n.push(i.element);if(n.length===0)throw new Error(`Element not found by label "${t}"`);n.length>1&&zr(t);const a=n[0];return a.isConnected||Ke(a.getAttribute("data-ref-id")||"","disconnected"),a}function zr(t){const e=new Error(`Multiple elements match label "${t}". The target is ambiguous.`);throw e.code="E_AMBIGUOUS_TARGET",e.category="observation",e.hint="Use a refId from the latest snapshot_data instead of a label, or narrow the label.",e.recovery=["const d = await page.snapshot_data(); find the target in d.nodes","Use the refId from that snapshot"],e.details={label:t},e}function L(t,e,r){const n=(e==null?void 0:e.getAttribute("data-ref-id"))??void 0;return{ok:!0,action:t,...n?{refId:n}:{},...e?ct(e):{},...r}}function dt(t,e,r,n){(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)&&e.value!==n&&O(Ie(t,r,{requested:n,actual:e.value}))}function ut(t){Ct();const e=[],r=[];let n=!1,a=!1;const i=typeof MutationObserver<"u"&&document.body?new MutationObserver(()=>{a=!0}):null;i&&document.body&&i.observe(document.body,{childList:!0,subtree:!0});try{let o=function(l,d,m){if(n)return;if(e.length>=t){n=!0;return}const A=l.tagName.toLowerCase();if(A==="script"||A==="style"||A==="noscript"||A==="template")return;const he=Or(l);let ke=d,dr=m;if(he){const Ze=st(l),ur=X(l),it=ge(l),F={refId:Ze,role:ur,tag:A};if(it&&(F.name=it),F.text=Rt(l,100),Sr(l,F),A==="a"){const P=be(l.getAttribute("href"));P&&(F.href=P)}if(A==="img"){const P=be(l.getAttribute("src"));P&&(F.src=P),F.alt=l.getAttribute("alt")||""}if(A==="input"){const P=l.getAttribute("title");P&&(F.title=P)}if(A==="img"||A==="a"){const P=Ot(l);P?F.parentRefId=P:m&&(F.parentRefId=m)}const fr=l.getAttribute("data-post-id");if(fr&&(F.postId=fr),A!=="a"){const P=Ar(l);if(P){const xe=be(P.getAttribute("href"));xe&&(F.permalink=xe)}}if(A!=="img"){const P=l.querySelectorAll("img");if(P.length>0){const xe=[];for(const ri of P){const pr=be(ri.getAttribute("src"));pr&&xe.push(pr)}xe.length>0&&(F.imageUrls=xe)}}e.push(F),dr=Ze;const It=[`${" ".repeat(d)}- ${ur}`];it&&It.push(`"${it.replace(/"/g,'\\"')}"`),It.push(`[${Ze}]`),r.push(It.join(" ")),ke=d+1}for(const Ze of l.children){if(n)break;o(Ze,ke,dr)}};document.body&&o(document.body,0)}finally{i&&(i.takeRecords().length>0&&(a=!0),i.disconnect())}return a&&O({message:"DOM mutated during snapshot collection",code:"E_SNAPSHOT",category:"resource",details:{cause:"dom_mutated_during_snapshot",nodesCollected:e.length},recovery:["Wait for the page to finish rendering before snapshot","Retry with a smaller max_nodes bound","Use page.snapshot_data() after navigation settles"]}),{text:[`URL: ${window.location.href}`,`Title: ${document.title}`,""].concat(r).join(`
2
+ `),nodes:e,url:window.location.href,title:document.title,viewport:{width:window.innerWidth,height:window.innerHeight}}}const Gr=3e4,Jr=3e4,Qr=100;function ft(t){const e=q(t),n=q(e.options??e).max_nodes??e.max_nodes;let a=500;return typeof n=="number"&&Number.isFinite(n)?a=n:typeof n=="bigint"&&(a=Number(n)),Math.max(1,Math.min(1e4,Math.floor(a)))}function Xr(t){const e=q(t),r=q(e.options??{}),n=String(e.url??""),a=String(r.method??e.method??"GET").toUpperCase(),i=r.headers??e.headers??{},s=typeof i=="object"&&i!==null?i:{},o=r.body??e.body??null,l=o==null?null:typeof o=="string"?o:String(o),d=e.timeout??r.timeout,m=typeof d=="number"?d:typeof d=="bigint"?Number(d):Gr;return{url:n,method:a,headers:s,body:l,timeout:m}}function Yr(t,e){return e!=null&&e.aborted?Promise.reject(new DOMException("Aborted","AbortError")):new Promise((r,n)=>{const a=setTimeout(()=>{e==null||e.removeEventListener("abort",i),r()},t),i=()=>{clearTimeout(a),e==null||e.removeEventListener("abort",i),n(new DOMException("Aborted","AbortError"))};e==null||e.addEventListener("abort",i,{once:!0})})}function en(t){const r=q(t).files;(!Array.isArray(r)||r.length===0)&&O({message:"setFiles requires a non-empty files array",code:"E_INVALID_PARAMS",category:"validation"});const n=[];for(const a of r){const i=q(a),s=i.kind;if(s==="bytes"){const o=typeof i.name=="string"?i.name.trim():"",l=typeof i.data=="string"?i.data:"";(!o||!l)&&O({message:"Resolved bytes file requires name and data",code:"E_INVALID_PARAMS",category:"validation"}),n.push({kind:"bytes",name:o,data:l,mimeType:typeof i.mimeType=="string"&&i.mimeType.length>0?i.mimeType:void 0});continue}if(s==="url"){const o=typeof i.url=="string"?i.url:"",l=typeof i.name=="string"?i.name.trim():"";(!o||!l)&&O({message:"Resolved url file requires url and name",code:"E_INVALID_PARAMS",category:"validation"}),n.push({kind:"url",url:o,name:l,mimeType:typeof i.mimeType=="string"&&i.mimeType.length>0?i.mimeType:void 0})}}return n.length!==r.length&&O({message:"setFiles files must be worker-resolved (kind: bytes or url)",code:"E_INVALID_PARAMS",category:"validation"}),n}function tn(t){try{const e=Mr(t.data);return new File([e.slice()],t.name,{type:t.mimeType??"application/octet-stream"})}catch{O({message:`Invalid base64 data for file ${t.name}`,code:"E_INVALID_PARAMS",category:"validation"})}}async function rn(t){try{const e=await fetch(t.url);e.ok||O({message:`Failed to fetch file URL ${t.url}: HTTP ${e.status}`,code:"E_NETWORK",category:"network"});const r=new Uint8Array(await e.arrayBuffer()),n=t.mimeType||e.headers.get("content-type")||"application/octet-stream";return new File([r.slice()],t.name,{type:n})}catch(e){if(typeof e=="object"&&e!==null&&"code"in e&&typeof e.code=="string")throw e;const r=e instanceof Error?e.message:String(e);O({message:`Failed to fetch file URL ${t.url}: ${r}`,code:"E_NETWORK",category:"network"})}}function nn(t,e,r){var a;const n=Array.from(t.files??[]).map(i=>i.name);((((a=t.files)==null?void 0:a.length)??0)!==r.length||!r.every((i,s)=>n[s]===i))&&O(Ie("setFiles",e,{expectedNames:r,actualNames:n}))}function an(t){const e=q(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 sn={click:t=>{const e=N(t,"refId"),r=N(t,"label");let n;return e?n=Bt(e,"click"):r?n=Kr(r,"click"):V(e,r,!0),se(n,"click"),n.click(),L("click",n,{observationId:lt(),dispatched:!0,verification:"required"})},fill:t=>{const e=N(t,"refId"),r=N(t,"label"),n=N(t,"value");let a;if(e?a=Bt(e,"fill"):r?(a=ee(r),a||V(e,r,!0)):V(e,r,!0),se(a,"fill"),a instanceof HTMLInputElement||a instanceof HTMLTextAreaElement){a.value=n;const i=new InputEvent("input",{bubbles:!0});a.dispatchEvent(i);const s=e||a.getAttribute("data-ref-id")||"";return dt("fill",a,s,n),L("fill",a,{value:a.value,observationId:lt(),dispatched:!0,verification:"required"})}throw new Error("Element is not an input")},set_files:async t=>{const e=N(t,"refId"),r=N(t,"label"),n=en(t);let a=e?Y(e):null;if(!a&&r&&(a=ee(r)),a||V(e,r,!0),se(a,"setFiles"),!(a instanceof HTMLInputElement)||a.type!=="file"){const l=e||a.getAttribute("data-ref-id")||"";O(Ie("setFiles",l,{reason:"not_file_input"}))}const i=new DataTransfer,s=[];for(const l of n){const d=l.kind==="bytes"?tn(l):await rn(l);i.items.add(d),s.push(d.name)}a.files=i.files,a.dispatchEvent(new Event("change",{bubbles:!0}));const o=e||a.getAttribute("data-ref-id")||"";return nn(a,o,s),L("setFiles",a,{fileCount:s.length,fileNames:s})},type:t=>{const e=N(t,"refId"),r=N(t,"label"),n=N(t,"text");let a=e?Y(e):null;if(!a&&r&&(a=ee(r)),a||V(e,r,!0),se(a,"type"),a instanceof HTMLInputElement||a instanceof HTMLTextAreaElement){a.value=n;const i=new InputEvent("input",{bubbles:!0});a.dispatchEvent(i);const s=e||a.getAttribute("data-ref-id")||"";return dt("type",a,s,n),L("type",a,{text:a.value})}throw new Error("Element is not an input")},append:t=>{const e=N(t,"refId"),r=N(t,"label"),n=N(t,"text");let a=e?Y(e):null;if(!a&&r&&(a=ee(r)),a||V(e,r,!0),se(a,"append"),a instanceof HTMLInputElement||a instanceof HTMLTextAreaElement){const s=a.value+n;a.value+=n;const o=new InputEvent("input",{bubbles:!0});a.dispatchEvent(o);const l=e||a.getAttribute("data-ref-id")||"";return dt("append",a,l,s),L("append",a,{text:a.value})}throw new Error("Element is not an input")},press:t=>{Hr()||O(_r("press"));const e=N(t,"key"),r=new KeyboardEvent("keydown",{key:e,bubbles:!0});document.dispatchEvent(r);const n=new KeyboardEvent("keyup",{key:e,bubbles:!0});return document.dispatchEvent(n),L("press",null,{key:e,observationId:lt(),dispatched:!0,verification:"required"})},select:t=>{const e=N(t,"refId"),r=N(t,"label"),n=N(t,"value");let a=e?Y(e):null;if(!a&&r&&(a=ee(r)),a||V(e,r,!0),se(a,"select"),a instanceof HTMLSelectElement)return a.value=n,a.dispatchEvent(new Event("change",{bubbles:!0})),L("select",a,{value:a.value});throw new Error("Element is not a select")},check:t=>{const e=N(t,"refId"),r=N(t,"label"),n=(()=>{const i=q(t);return typeof i.checked=="boolean"?i.checked:!0})();let a=e?Y(e):null;if(!a&&r&&(a=ee(r)),a||V(e,r,!0),se(a,"check"),a instanceof HTMLInputElement&&(a.type==="checkbox"||a.type==="radio"))return a.checked=n,a.dispatchEvent(new Event("change",{bubbles:!0})),L("check",a,{checked:a.checked});throw new Error("Element is not a checkbox or radio")},hover:t=>{const e=N(t,"refId"),r=N(t,"label");let n=e?Y(e):null;!n&&r&&(n=ee(r)),n||V(e,r,!0),se(n,"hover");const a=new MouseEvent("mouseenter",{bubbles:!0});return n.dispatchEvent(a),L("hover",n)},unhover:()=>{const t=new MouseEvent("mouseleave",{bubbles:!0});return document.body.dispatchEvent(t),L("unhover",null)},scroll:t=>{He();const e=q(t),r=e.direction??"down",n=typeof e.amount=="number"?e.amount:300,a=r==="down"?n:r==="up"?-n:0,i=r==="right"?n:r==="left"?-n:0;return window.scrollBy({top:a,left:i,behavior:"smooth"}),L("scroll",null,{direction:r,amount:n})},dblclick:t=>{const e=N(t,"refId"),r=N(t,"label");let n=e?Y(e):null;!n&&r&&(n=ee(r)),n||V(e,r,!0);const a=n;return a.click(),a.click(),a.dispatchEvent(new MouseEvent("dblclick",{bubbles:!0,cancelable:!0})),L("dblclick",n)},forward:()=>(He(),window.history.forward(),L("forward",null)),scroll_to:t=>{const e=N(t,"refId"),r=N(t,"label"),n=Pt(t,"x",0),a=Pt(t,"y",0);if(e||r){let i=e?Y(e):null;if(!i&&r&&(i=ee(r)),i)return i.scrollIntoView({behavior:"smooth"}),L("scroll_to",i);V(e,r,!0)}return window.scrollTo({top:a,left:n,behavior:"smooth"}),L("scroll_to",null,{amount:a})},evaluate:t=>{const e=an(t);return new Function(e)()},back:()=>(He(),window.history.back(),L("back",null)),ping:()=>({ok:!0}),snapshot:async t=>{document.body||O({message:"Document body not available for snapshot",code:"E_SNAPSHOT",category:"resource",details:{cause:"document.body is null"},recovery:["Wait for the page to load fully before taking a snapshot."]});const e=ft(t);me.debug("snapshot",{maxNodes:e,hasBody:!!document.body});const r=ut(e),n=r.nodes.map(i=>{const s=Y(i.refId);return s?{refId:i.refId,element:s}:null}).filter(i=>i!==null),a=Wr(n);return{...r,observationId:a}},snapshot_text:async t=>{document.body||O({message:"Document body not available for snapshot",code:"E_SNAPSHOT",category:"resource",details:{cause:"document.body is null"},recovery:["Wait for the page to load fully before taking a snapshot."]});const e=ft(t);return ut(e).text},snapshot_query:async t=>{document.body||O({message:"Document body not available for snapshot",code:"E_SNAPSHOT",category:"resource",details:{cause:"document.body is null"},recovery:["Wait for the page to load fully before taking a snapshot."]});const e=ft(t),r=ut(e),n=q(t),a=n.filter?q(n.filter):{};return{text:"",nodes:Zr(r.nodes,a),url:r.url,title:r.title,viewport:r.viewport}},find:t=>{Ct();const e=N(t,"selector");return Array.from(document.querySelectorAll(e)).map(n=>{var d;const a=st(n),i=X(n),s=ge(n),o={tag:n.tagName.toLowerCase(),refId:a,role:i,text:((d=n.textContent)==null?void 0:d.slice(0,100))||"",...ct(n)};s&&(o.name=s);const l=n.tagName.toLowerCase();if(l==="a"){const m=be(n.getAttribute("href"));m&&(o.href=m)}if(l==="img"){const m=be(n.getAttribute("src"));m&&(o.src=m),o.alt=n.getAttribute("alt")||""}if(l==="input"){const m=n.getAttribute("title");m&&(o.title=m)}if(l==="img"||l==="a"){const m=Ot(n);m&&(o.parentRefId=m)}return o})},wait_for:async(t,e)=>{const r=N(t,"selector"),n=q(t),a=typeof n.timeout=="number"?n.timeout:typeof n.timeout=="bigint"?Number(n.timeout):Jr,i=Date.now();for(;;){if(e!=null&&e.aborted)throw new DOMException("Aborted","AbortError");if(document.querySelector(r))return!0;Date.now()-i>=a&&O({message:`Timeout waiting for selector: ${r}`,code:"E_TIMEOUT",category:"timeout"}),await Yr(Qr,e)}},extract:t=>{var a,i;const e=q(t),r=Array.isArray(e.fields)?e.fields:[],n={};for(const s of r)if(s==="title")n.title=document.title;else if(s==="url")n.url=window.location.href;else if(s==="headings"){const o=Array.from(document.querySelectorAll("h1, h2, h3, h4, h5, h6"));n.headings=o.map(l=>{var d;return{tag:l.tagName,text:((d=l.textContent)==null?void 0:d.trim().slice(0,200))||""}})}else if(s==="links"){const o=Array.from(document.querySelectorAll("a[href]"));n.links=o.map(l=>{var d;return{href:l.getAttribute("href"),text:((d=l.textContent)==null?void 0:d.trim().slice(0,100))||""}})}else s==="text"&&(n.text=((i=(a=document.body)==null?void 0:a.textContent)==null?void 0:i.trim().slice(0,500))||"");return n},fetch:async(t,e)=>{const{url:r,method:n,headers:a,body:i,timeout:s}=Xr(t);if(!r)throw new Error("fetch requires a url");const o=new AbortController,l=()=>o.abort();if(e){if(e.aborted)throw new DOMException("Aborted","AbortError");e.addEventListener("abort",l,{once:!0})}const d=setTimeout(()=>o.abort(),s);try{const m={method:n,headers:a,signal:o.signal};i!==null&&(m.body=i);const A=await fetch(r,m);return jr(A)}finally{clearTimeout(d),e==null||e.removeEventListener("abort",l)}}};function ze(t){return t==null?{}:t instanceof Map?Object.fromEntries([...t.entries()].map(([e,r])=>[e,ze(r)])):Array.isArray(t)?t.map(ze):t}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 Ht;(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(Ht||(Ht={}));const b=S.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),oe=t=>{switch(typeof t){case"undefined":return b.undefined;case"string":return b.string;case"number":return Number.isNaN(t)?b.nan:b.number;case"boolean":return b.boolean;case"function":return b.function;case"bigint":return b.bigint;case"symbol":return b.symbol;case"object":return Array.isArray(t)?b.array:t===null?b.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?b.promise:typeof Map<"u"&&t instanceof Map?b.map:typeof Set<"u"&&t instanceof Set?b.set:typeof Date<"u"&&t instanceof Date?b.date:b.object;default:return b.unknown}},f=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 U 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 d=s.path[l];l===s.path.length-1?(o[d]=o[d]||{_errors:[]},o[d]._errors.push(r(s))):o[d]=o[d]||{_errors:[]},o=o[d],l++}}};return a(this),n}static assert(e){if(!(e instanceof U))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()}}U.create=t=>new U(t);const Ae=(t,e)=>{let r;switch(t.code){case f.invalid_type:t.received===b.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case f.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,S.jsonStringifyReplacer)}`;break;case f.unrecognized_keys:r=`Unrecognized key(s) in object: ${S.joinValues(t.keys,", ")}`;break;case f.invalid_union:r="Invalid input";break;case f.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${S.joinValues(t.options)}`;break;case f.invalid_enum_value:r=`Invalid enum value. Expected ${S.joinValues(t.options)}, received '${t.received}'`;break;case f.invalid_arguments:r="Invalid function arguments";break;case f.invalid_return_type:r="Invalid function return type";break;case f.invalid_date:r="Invalid date";break;case f.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 f.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 f.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 f.custom:r="Invalid input";break;case f.invalid_intersection_types:r="Intersection results could not be merged";break;case f.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case f.not_finite:r="Number must be finite";break;default:r=e.defaultError,S.assertNever(t)}return{message:r}};let on=Ae;function pt(){return on}const ht=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(d=>!!d).slice().reverse();for(const d of l)o=d(s,{data:e,defaultError:o}).message;return{...a,path:i,message:o}};function h(t,e){const r=pt(),n=ht({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===Ae?void 0:Ae].filter(a=>!!a)});t.common.issues.push(n)}class ${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 $.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"}),Ce=t=>({status:"dirty",value:t}),j=t=>({status:"valid",value:t}),Kt=t=>t.status==="aborted",zt=t=>t.status==="dirty",ye=t=>t.status==="valid",Ge=t=>typeof Promise<"u"&&t instanceof Promise;var g;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(g||(g={}));class H{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 Gt=(t,e)=>{if(ye(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 U(t.common.issues);return this._error=r,this._error}}};function x(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 oe(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:oe(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new $,ctx:{common:e.parent.common,data:e.data,parsedType:oe(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const r=this._parse(e);if(Ge(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:oe(e)},a=this._parseSync({data:e,path:n.path,parent:n});return Gt(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:oe(e)};if(!this["~standard"].async)try{const i=this._parseSync({data:e,path:[],parent:r});return ye(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=>ye(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:oe(e)},a=this._parse({data:e,path:n.path,parent:n}),i=await(Ge(a)?a:Promise.resolve(a));return Gt(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:f.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 re({schema:this,typeName:w.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 W.create(this,this._def)}nullable(){return de.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return B.create(this)}promise(){return we.create(this,this._def)}or(e){return Re.create([this,e],this._def)}and(e){return De.create(this,e,this._def)}transform(e){return new re({...x(this._def),schema:this,typeName:w.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const r=typeof e=="function"?e:()=>e;return new Le({...x(this._def),innerType:this,defaultValue:r,typeName:w.ZodDefault})}brand(){return new kt({typeName:w.ZodBranded,type:this,...x(this._def)})}catch(e){const r=typeof e=="function"?e:()=>e;return new $e({...x(this._def),innerType:this,catchValue:r,typeName:w.ZodCatch})}describe(e){const r=this.constructor;return new r({...this._def,description:e})}pipe(e){return et.create(this,e)}readonly(){return je.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const cn=/^c[^\s-]{8,}$/i,ln=/^[0-9a-z]+$/,dn=/^[0-9A-HJKMNP-TV-Z]{26}$/i,un=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,fn=/^[a-z0-9_-]{21}$/i,pn=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,hn=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,mn=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,bn="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let mt;const gn=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,yn=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,vn=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,_n=/^(([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])$/,wn=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,kn=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Jt="((\\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])))",xn=new RegExp(`^${Jt}$`);function Qt(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 In(t){return new RegExp(`^${Qt(t)}$`)}function Tn(t){let e=`${Jt}T${Qt(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 Sn(t,e){return!!((e==="v4"||!e)&&gn.test(t)||(e==="v6"||!e)&&vn.test(t))}function En(t,e){if(!pn.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 An(t,e){return!!((e==="v4"||!e)&&yn.test(t)||(e==="v6"||!e)&&_n.test(t))}class K extends T{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==b.string){const i=this._getOrReturnCtx(e);return h(i,{code:f.invalid_type,expected:b.string,received:i.parsedType}),_}const n=new $;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:f.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:f.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:f.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):o&&h(a,{code:f.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),n.dirty())}else if(i.kind==="email")mn.test(e.data)||(a=this._getOrReturnCtx(e,a),h(a,{validation:"email",code:f.invalid_string,message:i.message}),n.dirty());else if(i.kind==="emoji")mt||(mt=new RegExp(bn,"u")),mt.test(e.data)||(a=this._getOrReturnCtx(e,a),h(a,{validation:"emoji",code:f.invalid_string,message:i.message}),n.dirty());else if(i.kind==="uuid")un.test(e.data)||(a=this._getOrReturnCtx(e,a),h(a,{validation:"uuid",code:f.invalid_string,message:i.message}),n.dirty());else if(i.kind==="nanoid")fn.test(e.data)||(a=this._getOrReturnCtx(e,a),h(a,{validation:"nanoid",code:f.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid")cn.test(e.data)||(a=this._getOrReturnCtx(e,a),h(a,{validation:"cuid",code:f.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid2")ln.test(e.data)||(a=this._getOrReturnCtx(e,a),h(a,{validation:"cuid2",code:f.invalid_string,message:i.message}),n.dirty());else if(i.kind==="ulid")dn.test(e.data)||(a=this._getOrReturnCtx(e,a),h(a,{validation:"ulid",code:f.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:f.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:f.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:f.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:f.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:f.invalid_string,validation:{endsWith:i.value},message:i.message}),n.dirty()):i.kind==="datetime"?Tn(i).test(e.data)||(a=this._getOrReturnCtx(e,a),h(a,{code:f.invalid_string,validation:"datetime",message:i.message}),n.dirty()):i.kind==="date"?xn.test(e.data)||(a=this._getOrReturnCtx(e,a),h(a,{code:f.invalid_string,validation:"date",message:i.message}),n.dirty()):i.kind==="time"?In(i).test(e.data)||(a=this._getOrReturnCtx(e,a),h(a,{code:f.invalid_string,validation:"time",message:i.message}),n.dirty()):i.kind==="duration"?hn.test(e.data)||(a=this._getOrReturnCtx(e,a),h(a,{validation:"duration",code:f.invalid_string,message:i.message}),n.dirty()):i.kind==="ip"?Sn(e.data,i.version)||(a=this._getOrReturnCtx(e,a),h(a,{validation:"ip",code:f.invalid_string,message:i.message}),n.dirty()):i.kind==="jwt"?En(e.data,i.alg)||(a=this._getOrReturnCtx(e,a),h(a,{validation:"jwt",code:f.invalid_string,message:i.message}),n.dirty()):i.kind==="cidr"?An(e.data,i.version)||(a=this._getOrReturnCtx(e,a),h(a,{validation:"cidr",code:f.invalid_string,message:i.message}),n.dirty()):i.kind==="base64"?wn.test(e.data)||(a=this._getOrReturnCtx(e,a),h(a,{validation:"base64",code:f.invalid_string,message:i.message}),n.dirty()):i.kind==="base64url"?kn.test(e.data)||(a=this._getOrReturnCtx(e,a),h(a,{validation:"base64url",code:f.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:f.invalid_string,...g.errToObj(n)})}_addCheck(e){return new K({...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,r){return this._addCheck({kind:"regex",regex:e,...g.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r==null?void 0:r.position,...g.errToObj(r==null?void 0:r.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...g.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...g.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...g.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...g.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...g.errToObj(r)})}nonempty(e){return this.min(1,g.errToObj(e))}trim(){return new K({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new K({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new K({...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}}K.create=t=>new K({checks:[],typeName:w.ZodString,coerce:(t==null?void 0:t.coerce)??!1,...x(t)});function Cn(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 ue 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)!==b.number){const i=this._getOrReturnCtx(e);return h(i,{code:f.invalid_type,expected:b.number,received:i.parsedType}),_}let n;const a=new $;for(const i of this._def.checks)i.kind==="int"?S.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),h(n,{code:f.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:f.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:f.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),a.dirty()):i.kind==="multipleOf"?Cn(e.data,i.value)!==0&&(n=this._getOrReturnCtx(e,n),h(n,{code:f.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:f.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,g.toString(r))}gt(e,r){return this.setLimit("min",e,!1,g.toString(r))}lte(e,r){return this.setLimit("max",e,!0,g.toString(r))}lt(e,r){return this.setLimit("max",e,!1,g.toString(r))}setLimit(e,r,n,a){return new ue({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:g.toString(a)}]})}_addCheck(e){return new ue({...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,r){return this._addCheck({kind:"multipleOf",value:e,message:g.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:g.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!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 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)}}ue.create=t=>new ue({checks:[],typeName:w.ZodNumber,coerce:(t==null?void 0:t.coerce)||!1,...x(t)});class fe 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)!==b.bigint)return this._getInvalidInput(e);let n;const a=new $;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:f.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:f.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:f.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:f.invalid_type,expected:b.bigint,received:r.parsedType}),_}gte(e,r){return this.setLimit("min",e,!0,g.toString(r))}gt(e,r){return this.setLimit("min",e,!1,g.toString(r))}lte(e,r){return this.setLimit("max",e,!0,g.toString(r))}lt(e,r){return this.setLimit("max",e,!1,g.toString(r))}setLimit(e,r,n,a){return new fe({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:g.toString(a)}]})}_addCheck(e){return new fe({...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,r){return this._addCheck({kind:"multipleOf",value:e,message:g.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}}fe.create=t=>new fe({checks:[],typeName:w.ZodBigInt,coerce:(t==null?void 0:t.coerce)??!1,...x(t)});class Je extends T{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==b.boolean){const n=this._getOrReturnCtx(e);return h(n,{code:f.invalid_type,expected:b.boolean,received:n.parsedType}),_}return j(e.data)}}Je.create=t=>new Je({typeName:w.ZodBoolean,coerce:(t==null?void 0:t.coerce)||!1,...x(t)});class Ne extends T{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==b.date){const i=this._getOrReturnCtx(e);return h(i,{code:f.invalid_type,expected:b.date,received:i.parsedType}),_}if(Number.isNaN(e.data.getTime())){const i=this._getOrReturnCtx(e);return h(i,{code:f.invalid_date}),_}const n=new $;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:f.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:f.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 Ne({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:g.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:g.toString(r)})}get minDate(){let e=null;for(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}}Ne.create=t=>new Ne({checks:[],coerce:(t==null?void 0:t.coerce)||!1,typeName:w.ZodDate,...x(t)});class Xt extends T{_parse(e){if(this._getType(e)!==b.symbol){const n=this._getOrReturnCtx(e);return h(n,{code:f.invalid_type,expected:b.symbol,received:n.parsedType}),_}return j(e.data)}}Xt.create=t=>new Xt({typeName:w.ZodSymbol,...x(t)});class Qe extends T{_parse(e){if(this._getType(e)!==b.undefined){const n=this._getOrReturnCtx(e);return h(n,{code:f.invalid_type,expected:b.undefined,received:n.parsedType}),_}return j(e.data)}}Qe.create=t=>new Qe({typeName:w.ZodUndefined,...x(t)});class Oe extends T{_parse(e){if(this._getType(e)!==b.null){const n=this._getOrReturnCtx(e);return h(n,{code:f.invalid_type,expected:b.null,received:n.parsedType}),_}return j(e.data)}}Oe.create=t=>new Oe({typeName:w.ZodNull,...x(t)});class bt extends T{constructor(){super(...arguments),this._any=!0}_parse(e){return j(e.data)}}bt.create=t=>new bt({typeName:w.ZodAny,...x(t)});class pe extends T{constructor(){super(...arguments),this._unknown=!0}_parse(e){return j(e.data)}}pe.create=t=>new pe({typeName:w.ZodUnknown,...x(t)});class ce extends T{_parse(e){const r=this._getOrReturnCtx(e);return h(r,{code:f.invalid_type,expected:b.never,received:r.parsedType}),_}}ce.create=t=>new ce({typeName:w.ZodNever,...x(t)});class gt extends T{_parse(e){if(this._getType(e)!==b.undefined){const n=this._getOrReturnCtx(e);return h(n,{code:f.invalid_type,expected:b.void,received:n.parsedType}),_}return j(e.data)}}gt.create=t=>new gt({typeName:w.ZodVoid,...x(t)});class B extends T{_parse(e){const{ctx:r,status:n}=this._processInputParams(e),a=this._def;if(r.parsedType!==b.array)return h(r,{code:f.invalid_type,expected:b.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?f.too_big:f.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:f.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:f.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 H(r,s,r.path,o)))).then(s=>$.mergeArray(n,s));const i=[...r.data].map((s,o)=>a.type._parseSync(new H(r,s,r.path,o)));return $.mergeArray(n,i)}get element(){return this._def.type}min(e,r){return new B({...this._def,minLength:{value:e,message:g.toString(r)}})}max(e,r){return new B({...this._def,maxLength:{value:e,message:g.toString(r)}})}length(e,r){return new B({...this._def,exactLength:{value:e,message:g.toString(r)}})}nonempty(e){return this.min(1,e)}}B.create=(t,e)=>new B({type:t,minLength:null,maxLength:null,exactLength:null,typeName:w.ZodArray,...x(e)});function ve(t){if(t instanceof R){const e={};for(const r in t.shape){const n=t.shape[r];e[r]=W.create(ve(n))}return new R({...t._def,shape:()=>e})}else return t instanceof B?new B({...t._def,type:ve(t.element)}):t instanceof W?W.create(ve(t.unwrap())):t instanceof de?de.create(ve(t.unwrap())):t instanceof z?z.create(t.items.map(e=>ve(e))):t}class R 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)!==b.object){const d=this._getOrReturnCtx(e);return h(d,{code:f.invalid_type,expected:b.object,received:d.parsedType}),_}const{status:n,ctx:a}=this._processInputParams(e),{shape:i,keys:s}=this._getCached(),o=[];if(!(this._def.catchall instanceof ce&&this._def.unknownKeys==="strip"))for(const d in a.data)s.includes(d)||o.push(d);const l=[];for(const d of s){const m=i[d],A=a.data[d];l.push({key:{status:"valid",value:d},value:m._parse(new H(a,A,a.path,d)),alwaysSet:d in a.data})}if(this._def.catchall instanceof ce){const d=this._def.unknownKeys;if(d==="passthrough")for(const m of o)l.push({key:{status:"valid",value:m},value:{status:"valid",value:a.data[m]}});else if(d==="strict")o.length>0&&(h(a,{code:f.unrecognized_keys,keys:o}),n.dirty());else if(d!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const d=this._def.catchall;for(const m of o){const A=a.data[m];l.push({key:{status:"valid",value:m},value:d._parse(new H(a,A,a.path,m)),alwaysSet:m in a.data})}}return a.common.async?Promise.resolve().then(async()=>{const d=[];for(const m of l){const A=await m.key,he=await m.value;d.push({key:A,value:he,alwaysSet:m.alwaysSet})}return d}).then(d=>$.mergeObjectSync(n,d)):$.mergeObjectSync(n,l)}get shape(){return this._def.shape()}strict(e){return g.errToObj,new R({...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:g.errToObj(e).message??a}:{message:a}}}:{}})}strip(){return new R({...this._def,unknownKeys:"strip"})}passthrough(){return new R({...this._def,unknownKeys:"passthrough"})}extend(e){return new R({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new R({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:w.ZodObject})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new R({...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 R({...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 R({...this._def,shape:()=>r})}deepPartial(){return ve(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 R({...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 W;)i=i._def.innerType;r[n]=i}return new R({...this._def,shape:()=>r})}keyof(){return Yt(S.objectKeys(this.shape))}}R.create=(t,e)=>new R({shape:()=>t,unknownKeys:"strip",catchall:ce.create(),typeName:w.ZodObject,...x(e)}),R.strictCreate=(t,e)=>new R({shape:()=>t,unknownKeys:"strict",catchall:ce.create(),typeName:w.ZodObject,...x(e)}),R.lazycreate=(t,e)=>new R({shape:t,unknownKeys:"strip",catchall:ce.create(),typeName:w.ZodObject,...x(e)});class Re 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 U(o.ctx.common.issues));return h(r,{code:f.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 d={...r,common:{...r.common,issues:[]},parent:null},m=l._parseSync({data:r.data,path:r.path,parent:d});if(m.status==="valid")return m;m.status==="dirty"&&!i&&(i={result:m,ctx:d}),d.common.issues.length&&s.push(d.common.issues)}if(i)return r.common.issues.push(...i.ctx.common.issues),i.result;const o=s.map(l=>new U(l));return h(r,{code:f.invalid_union,unionErrors:o}),_}}get options(){return this._def.options}}Re.create=(t,e)=>new Re({options:t,typeName:w.ZodUnion,...x(e)});const te=t=>t instanceof Ye?te(t.schema):t instanceof re?te(t.innerType()):t instanceof qe?[t.value]:t instanceof le?t.options:t instanceof _t?S.objectValues(t.enum):t instanceof Le?te(t._def.innerType):t instanceof Qe?[void 0]:t instanceof Oe?[null]:t instanceof W?[void 0,...te(t.unwrap())]:t instanceof de?[null,...te(t.unwrap())]:t instanceof kt||t instanceof je?te(t.unwrap()):t instanceof $e?te(t._def.innerType):[];class Xe extends T{_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==b.object)return h(r,{code:f.invalid_type,expected:b.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:f.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=te(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 Xe({typeName:w.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:a,...x(n)})}}function yt(t,e){const r=oe(t),n=oe(e);if(t===e)return{valid:!0,data:t};if(r===b.object&&n===b.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=yt(t[o],e[o]);if(!l.valid)return{valid:!1};s[o]=l.data}return{valid:!0,data:s}}else if(r===b.array&&n===b.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=yt(s,o);if(!l.valid)return{valid:!1};a.push(l.data)}return{valid:!0,data:a}}else return r===b.date&&n===b.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}class De extends T{_parse(e){const{status:r,ctx:n}=this._processInputParams(e),a=(i,s)=>{if(Kt(i)||Kt(s))return _;const o=yt(i.value,s.value);return o.valid?((zt(i)||zt(s))&&r.dirty(),{status:r.value,value:o.data}):(h(n,{code:f.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}))}}De.create=(t,e,r)=>new De({left:t,right:e,typeName:w.ZodIntersection,...x(r)});class z extends T{_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==b.array)return h(n,{code:f.invalid_type,expected:b.array,received:n.parsedType}),_;if(n.data.length<this._def.items.length)return h(n,{code:f.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:f.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 H(n,s,n.path,o)):null}).filter(s=>!!s);return n.common.async?Promise.all(i).then(s=>$.mergeArray(r,s)):$.mergeArray(r,i)}get items(){return this._def.items}rest(e){return new z({...this._def,rest:e})}}z.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new z({items:t,typeName:w.ZodTuple,rest:null,...x(e)})};class Me 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!==b.object)return h(n,{code:f.invalid_type,expected:b.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 H(n,o,n.path,o)),value:s._parse(new H(n,n.data[o],n.path,o)),alwaysSet:o in n.data});return n.common.async?$.mergeObjectAsync(r,a):$.mergeObjectSync(r,a)}get element(){return this._def.valueType}static create(e,r,n){return r instanceof T?new Me({keyType:e,valueType:r,typeName:w.ZodRecord,...x(n)}):new Me({keyType:K.create(),valueType:e,typeName:w.ZodRecord,...x(r)})}}class vt 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!==b.map)return h(n,{code:f.invalid_type,expected:b.map,received:n.parsedType}),_;const a=this._def.keyType,i=this._def.valueType,s=[...n.data.entries()].map(([o,l],d)=>({key:a._parse(new H(n,o,n.path,[d,"key"])),value:i._parse(new H(n,l,n.path,[d,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const l of s){const d=await l.key,m=await l.value;if(d.status==="aborted"||m.status==="aborted")return _;(d.status==="dirty"||m.status==="dirty")&&r.dirty(),o.set(d.value,m.value)}return{status:r.value,value:o}})}else{const o=new Map;for(const l of s){const d=l.key,m=l.value;if(d.status==="aborted"||m.status==="aborted")return _;(d.status==="dirty"||m.status==="dirty")&&r.dirty(),o.set(d.value,m.value)}return{status:r.value,value:o}}}}vt.create=(t,e,r)=>new vt({valueType:e,keyType:t,typeName:w.ZodMap,...x(r)});class _e extends T{_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==b.set)return h(n,{code:f.invalid_type,expected:b.set,received:n.parsedType}),_;const a=this._def;a.minSize!==null&&n.data.size<a.minSize.value&&(h(n,{code:f.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:f.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 d=new Set;for(const m of l){if(m.status==="aborted")return _;m.status==="dirty"&&r.dirty(),d.add(m.value)}return{status:r.value,value:d}}const o=[...n.data.values()].map((l,d)=>i._parse(new H(n,l,n.path,d)));return n.common.async?Promise.all(o).then(l=>s(l)):s(o)}min(e,r){return new _e({...this._def,minSize:{value:e,message:g.toString(r)}})}max(e,r){return new _e({...this._def,maxSize:{value:e,message:g.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}}_e.create=(t,e)=>new _e({valueType:t,minSize:null,maxSize:null,typeName:w.ZodSet,...x(e)});class Pe extends T{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==b.function)return h(r,{code:f.invalid_type,expected:b.function,received:r.parsedType}),_;function n(o,l){return ht({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,pt(),Ae].filter(d=>!!d),issueData:{code:f.invalid_arguments,argumentsError:l}})}function a(o,l){return ht({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,pt(),Ae].filter(d=>!!d),issueData:{code:f.invalid_return_type,returnTypeError:l}})}const i={errorMap:r.common.contextualErrorMap},s=r.data;if(this._def.returns instanceof we){const o=this;return j(async function(...l){const d=new U([]),m=await o._def.args.parseAsync(l,i).catch(ke=>{throw d.addIssue(n(l,ke)),d}),A=await Reflect.apply(s,this,m);return await o._def.returns._def.type.parseAsync(A,i).catch(ke=>{throw d.addIssue(a(A,ke)),d})})}else{const o=this;return j(function(...l){const d=o._def.args.safeParse(l,i);if(!d.success)throw new U([n(l,d.error)]);const m=Reflect.apply(s,this,d.data),A=o._def.returns.safeParse(m,i);if(!A.success)throw new U([a(m,A.error)]);return A.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Pe({...this._def,args:z.create(e).rest(pe.create())})}returns(e){return new Pe({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,r,n){return new Pe({args:e||z.create([]).rest(pe.create()),returns:r||pe.create(),typeName:w.ZodFunction,...x(n)})}}class Ye 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})}}Ye.create=(t,e)=>new Ye({getter:t,typeName:w.ZodLazy,...x(e)});class qe extends T{_parse(e){if(e.data!==this._def.value){const r=this._getOrReturnCtx(e);return h(r,{received:r.data,code:f.invalid_literal,expected:this._def.value}),_}return{status:"valid",value:e.data}}get value(){return this._def.value}}qe.create=(t,e)=>new qe({value:t,typeName:w.ZodLiteral,...x(e)});function Yt(t,e){return new le({values:t,typeName:w.ZodEnum,...x(e)})}class le 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:f.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:f.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 le.create(e,{...this._def,...r})}exclude(e,r=this._def){return le.create(this.options.filter(n=>!e.includes(n)),{...this._def,...r})}}le.create=Yt;class _t extends T{_parse(e){const r=S.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==b.string&&n.parsedType!==b.number){const a=S.objectValues(r);return h(n,{expected:S.joinValues(a),received:n.parsedType,code:f.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:f.invalid_enum_value,options:a}),_}return j(e.data)}get enum(){return this._def.values}}_t.create=(t,e)=>new _t({values:t,typeName:w.ZodNativeEnum,...x(e)});class we extends T{unwrap(){return this._def.type}_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==b.promise&&r.common.async===!1)return h(r,{code:f.invalid_type,expected:b.promise,received:r.parsedType}),_;const n=r.parsedType===b.promise?r.data:Promise.resolve(r.data);return j(n.then(a=>this._def.type.parseAsync(a,{path:r.path,errorMap:r.common.contextualErrorMap})))}}we.create=(t,e)=>new we({type:t,typeName:w.ZodPromise,...x(e)});class re extends T{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===w.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"?Ce(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"?Ce(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(!ye(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=>ye(s)?Promise.resolve(a.transform(s.value,i)).then(o=>({status:r.value,value:o})):_);S.assertNever(a)}}re.create=(t,e,r)=>new re({schema:t,typeName:w.ZodEffects,effect:e,...x(r)}),re.createWithPreprocess=(t,e,r)=>new re({schema:e,effect:{type:"preprocess",transform:t},typeName:w.ZodEffects,...x(r)});class W extends T{_parse(e){return this._getType(e)===b.undefined?j(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}W.create=(t,e)=>new W({innerType:t,typeName:w.ZodOptional,...x(e)});class de extends T{_parse(e){return this._getType(e)===b.null?j(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}de.create=(t,e)=>new de({innerType:t,typeName:w.ZodNullable,...x(e)});class Le extends T{_parse(e){const{ctx:r}=this._processInputParams(e);let n=r.data;return r.parsedType===b.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}}Le.create=(t,e)=>new Le({innerType:t,typeName:w.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...x(e)});class $e 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 Ge(a)?a.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new U(n.common.issues)},input:n.data})})):{status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new U(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}$e.create=(t,e)=>new $e({innerType:t,typeName:w.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...x(e)});class wt extends T{_parse(e){if(this._getType(e)!==b.nan){const n=this._getOrReturnCtx(e);return h(n,{code:f.invalid_type,expected:b.nan,received:n.parsedType}),_}return{status:"valid",value:e.data}}}wt.create=t=>new wt({typeName:w.ZodNaN,...x(t)});class kt 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 et 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(),Ce(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 et({in:e,out:r,typeName:w.ZodPipeline})}}class je extends T{_parse(e){const r=this._def.innerType._parse(e),n=a=>(ye(a)&&(a.value=Object.freeze(a.value)),a);return Ge(r)?r.then(a=>n(a)):n(r)}unwrap(){return this._def.innerType}}je.create=(t,e)=>new je({innerType:t,typeName:w.ZodReadonly,...x(e)});var w;(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"})(w||(w={}));const c=K.create,p=ue.create,G=fe.create,k=Je.create,er=Oe.create,v=pe.create;ce.create;const E=B.create,u=R.create,I=Re.create,Nn=Xe.create;De.create;const On=z.create,y=Me.create,Fe=qe.create,tt=le.create;we.create,W.create,de.create;const ne=re.createWithPreprocess;function D(t,e=0,r=2){if(e>r)return"...";if(t instanceof R){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 W,d=D(l?o.unwrap():o,e+1,r);return`${s}${l?"?":""}: ${d}`}).join(", ")} }`}if(t instanceof Re)return t.options.map(n=>D(n,e,r)).join(" or ");if(t instanceof K)return"string";if(t instanceof ue)return"number";if(t instanceof Je)return"boolean";if(t instanceof fe)return"bigint";if(t instanceof Oe)return"null";if(t instanceof B){const n=D(t.element,e+1,r);return n==="unknown"||n==="any"?"array":`${n}[]`}if(t instanceof z)return`[${t.items.map(n=>D(n,e+1,r)).join(", ")}]`;if(t instanceof Me){const n=D(t._def.valueType,e+1,r);return n==="unknown"||n==="any"?"{ [key: string]: unknown }":`{ [key: string]: ${n} }`}return t instanceof W?`${D(t.unwrap(),e,r)}?`:t instanceof qe?JSON.stringify(t.value):t instanceof le?t.options.map(n=>`"${n}"`).join(" | "):t instanceof bt?"any":t instanceof pe?"unknown":t instanceof gt?"void":t instanceof Qe?"undefined":t instanceof re?D(t.innerType(),e,r):t instanceof Le?D(t.removeDefault(),e,r):t instanceof de?`${D(t.unwrap(),e,r)} | null`:t instanceof Ye?"lazy":t instanceof we?`Promise<${D(t.unwrap(),e+1,r)}>`:t instanceof Pe?"function":t instanceof Ne?"Date":t instanceof vt?"Map":t instanceof _e?"Set":t instanceof De?`${D(t._def.left,e,r)} & ${D(t._def.right,e,r)}`:t instanceof Xe?t.options.map(n=>D(n,e,r)).join(" or "):t instanceof kt?D(t.unwrap(),e,r):t instanceof wt?"NaN":t instanceof $e?D(t.removeCatch(),e,r):t instanceof et?D(t._def.in,e,r):t instanceof je?`readonly ${D(t.unwrap(),e,r)}`:"unknown"}function Rn(t){return t===null?"null":t===void 0?"undefined":Array.isArray(t)?"array":typeof t}function Dn(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(d=>d.code==="custom"),l=a.some(d=>d.code!=="invalid_type"&&d.code!=="invalid_literal"&&d.code!=="invalid_union");if(!o&&!l){const d=D(e),m=Rn(n);return`Invalid parameters for ${t}: expected ${d}${d==="{ }"?" or no args":""}, received ${m}`}}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 Mn(t,e,r,n,a){const i=t.safeParse(ze(n));if(!i.success)return{ok:!1,error:{message:Dn(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(d=>{const m=d.path.join(".");return`invalid return value${m?` at '${m}'`:""} (${d.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=Et(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 tr=new Map,rt=new Map;function Pn(t){tr.set(t.registryAction,t)}function nt(t){return tr.get(t)}function qn(t){for(const e of t)Pn(e);try{chrome.runtime.sendMessage({type:"contentScriptReady"})}catch{}}function Ln(t){const e=rt.get(t);return e?(e.abort(),rt.delete(t),!0):!1}async function $n(t,e,r,n,a){const i=nt(t);if(!i)return{ok:!1,error:{message:`No schema registered for content-script action: ${t}`,code:"E_INTERNAL"}};const s=new AbortController;a&&rt.set(a,s);try{return await Mn(i.params,i.returns,async o=>r(o,s.signal),ze(n),t)}finally{a&&rt.delete(a)}}function jn(t,e){if(nt(t))return t;const r=`page_${e}`;return nt(r)?r:t}function Fn(t,e){const r=nt(t);return(r==null?void 0:r.handlerKey)??e}function rr(t,e,r,n,a){const i=jn(t,e),s=Fn(i,e),o=sn[s];return o?($n(i,s,o,r,a).then(d=>{me.debug("dispatch_response",{registryAction:t,handlerAction:s,ok:d.ok}),n(d)}).catch(d=>{const m=Et(d,{});me.debug("dispatch_error",{registryAction:t,handlerAction:s,error:m.message}),n({ok:!1,error:m})}),!0):(me.debug("no_handler",{action:s,registryAction:t}),n({ok:!1,error:`Unknown content script action: ${s}`}),!1)}function Un(){chrome.runtime.onMessage.addListener((t,e,r)=>{if(e.id!==chrome.runtime.id)return me.warn("unauthorized_sender",{senderId:e.id,expected:chrome.runtime.id}),r({ok:!1,error:"Unauthorized sender"}),!1;const n=q(t),a=String(n.type??""),i=String(n.action??"");if(me.debug("received",{messageType:a,action:i,hasParams:!!n.params}),a==="registryCallCancel"){const s=String(n.id??"");return Ln(s),r({ok:!0}),!1}if(a==="registryCall"){const s=br(i),o=typeof n.id=="string"?n.id:void 0;return rr(i,s,n.params,r,o)}return!i&&a==="contract-ping"?(r({ok:!0}),!1):i?i==="ping"?rr("ping","ping",n.params,r):(r({ok:!1,error:"Use registryCall for content-script actions"}),!1):(r({ok:!1,error:"Missing action"}),!1)})}const Z=()=>I([G(),p().finite()]).transform(t=>BigInt(t));u({key:c().describe("Storage key to retrieve")}),u({key:c().describe("Storage key to set"),value:c().describe("Value to store")}),u({key:c().describe("Storage key to delete")}),u({});const Zn=u({items:y(c()).describe("Record of key-value string pairs to store")});ne(t=>t!==null&&typeof t=="object"&&!Array.isArray(t)&&!("items"in t)?{items:t}:t,Zn);const Vn=u({keys:E(c()).describe("Array of storage keys to retrieve"),defaults:y(c()).optional().describe("Default string values for missing keys")});ne(t=>Array.isArray(t)?{keys:t}:t,Vn),u({});const Bn=u({keys:E(c()).describe("Array of storage keys to delete")});ne(t=>Array.isArray(t)?{keys:t}:t,Bn),u({}),u({}),I([On([I([u({text:c()}),c()])]),u({text:c().optional(),value:c().optional()})]);const Wn=u({url:c().describe("URL to fetch"),method:c().default("GET").describe("HTTP method (GET, POST, PUT, DELETE, etc.)"),headers:y(c()).default({}).describe("Request headers as key-value pairs"),body:c().nullable().default(null).describe("Request body string"),timeout:Z().default(30000n).describe("Timeout in milliseconds"),store:k().optional().describe("When true, store binary responses as a handle instead of returning body bytes"),options:u({}).passthrough().optional().describe("Fetch options")}).passthrough();u({duration:Z().describe("Duration to sleep in milliseconds")});const ae=()=>c().regex(/^e\d+$/),Hn='use { refId: "e2" } or { label: "..." } object form, not positional arguments',xt=(t,e)=>{if(t.__invalidPositional!==void 0){e.addIssue({code:f.custom,message:Hn});return}!t.refId&&!t.label&&e.addIssue({code:f.custom,message:"Either refId or label is required"})},nr=(t,e)=>{t.x!==void 0||t.y!==void 0||xt(t,e)},M=t=>ne(e=>typeof e=="string"||typeof e=="number"?{__invalidPositional:e}:e,u({__invalidPositional:I([c(),p()]).optional().describe("Internal flag for positional argument rejection"),refId:ae().optional().describe("Element reference ID (e.g. e2)"),label:c().optional().describe("Human-readable element label"),...t}).superRefine(xt)),Ue={tabId:I([p(),G()]).optional().describe("Target tab ID")},ie=t=>ne(e=>typeof e=="string"||typeof e=="number"?{__invalidPositional:e}:e,u({__invalidPositional:I([c(),p()]).optional().describe("Internal flag for positional argument rejection"),...Ue,refId:ae().optional().describe("Element reference ID (e.g. e2)"),label:c().optional().describe("Human-readable element label"),...t}).superRefine(xt));u({}),u({}),u({url:c().describe("URL to navigate to"),timeout:Z().optional().describe("Navigation timeout in milliseconds"),waitUntil:tt(["load","networkidle"]).optional().describe("When to consider navigation complete: 'load' (tab status complete) or 'networkidle' (no in-flight requests for 500ms)")});const Kn=u({}),zn=u({});u({}),u({duration:Z().default(1000n).describe("Duration to wait in milliseconds")});const Gn=M(),Jn=(t,e)=>{[t.url,t.path,t.handle].filter(n=>typeof n=="string"&&n.length>0).length!==1&&e.addIssue({code:f.custom,message:"Each file entry requires exactly one of url, path, or handle"})},ar=u({name:c().optional().describe("File name including extension"),mimeType:c().optional().describe("MIME type (defaults to application/octet-stream)"),url:c().url().optional().describe("HTTP(S) URL to fetch in the target tab"),path:c().min(1).optional().describe("Virtual filesystem path (resolved in worker)"),handle:c().min(1).optional().describe("Binary handle from page.fetch({ store: true })")}).superRefine(Jn),ir=Nn("kind",[u({kind:Fe("bytes"),name:c().min(1),data:c().min(1),mimeType:c().optional()}),u({kind:Fe("url"),url:c().url(),name:c().min(1),mimeType:c().optional()})]),Qn=M({value:c().describe("Value to fill into the element")}),Xn=M({files:E(ar).min(1).describe("Files to attach to the input")}),Yn=M({files:E(ir).min(1).describe("Resolved files for content-script application")}),ea=M({text:c().describe("Text to type into the element")}),ta=M({text:c().describe("Text to append into the element")}),ra=u({key:c().describe("Key to press (e.g. Enter, Escape, ArrowDown)")}),na=M({value:c().describe("Value to select in the dropdown")}),aa=M({checked:k().optional().describe("Desired checked state (true to check, false to uncheck)")}),ia=M(),sa=u({}),oa=u({direction:c().default("down").describe("Scroll direction: up, down, left, or right"),amount:p().default(300).describe("Pixels to scroll")}),ca=ne(t=>typeof t=="string"||typeof t=="number"?{__invalidPositional:t}:t,u({__invalidPositional:I([c(),p()]).optional().describe("Internal flag for positional argument rejection"),refId:ae().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(nr)),la=M(),da=u({selector:c().describe("CSS selector to find elements")}),ua=u({selector:c().describe("CSS selector to wait for"),timeout:Z().default(30000n).describe("Timeout in milliseconds")}),fa=u({fields:E(c()).describe("Array of field names to extract")}),pa=ne(t=>Array.isArray(t)?{fields:t}:t,fa);I([p(),E(u({}).passthrough()),u({}).passthrough()]),u({}),u({active:k().optional().describe("Whether the tabs are active"),currentWindow:k().optional().describe("Whether the tabs are in the current window"),url:c().optional().describe("URL pattern to match tabs against")}).passthrough(),ne(t=>typeof t=="string"?{url:t}:t,u({url:c().optional().describe("URL to open in the new tab"),active:k().optional().describe("Whether to focus the new tab")})),I([p(),E(u({id:p().optional(),tabId:p().optional(),tab_id:p().optional()}).passthrough()),u({id:p().optional(),tabId:p().optional(),tab_id:p().optional()}).passthrough()]);const ha=ie(),ma=ie({value:c().describe("Value to fill into the element")}),ba=ie({files:E(ar).min(1).describe("Files to attach to the input")}),ga=ie({files:E(ir).min(1).describe("Resolved files for content-script application")}),ya=ne(t=>typeof t=="string"||typeof t=="number"?{__invalidPositional:t}:t,u({__invalidPositional:I([c(),p()]).optional().describe("Internal flag for positional argument rejection"),...Ue,refId:ae().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(nr)),va=ie({text:c().describe("Text to type into the element")}),_a=u({...Ue,key:c().describe("Key to press (e.g. Enter, Escape, ArrowDown)")}),wa=ie({value:c().describe("Value to select in the dropdown")}),ka=ie({checked:k().optional().describe("Desired checked state (true to check, false to uncheck)")}),xa=ie(),Ia=u({...Ue}),Ta=u({...Ue,direction:c().default("down").describe("Scroll direction: up, down, left, or right"),amount:p().default(300).describe("Pixels to scroll")}),Sa=ie(),Ea=u({tabId:I([p(),G()]).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(),Aa=u({tabId:I([p(),G()]).optional().describe("Target tab ID")}).passthrough(),Ca=u({tabId:I([p(),G()]).optional().describe("Target tab ID")}).passthrough();u({tabId:I([p(),G()]).optional().describe("Target tab ID"),timeout:p().optional().describe("Timeout in milliseconds")}).passthrough();const Na=u({tabId:I([p(),G()]).optional().describe("Target tab ID"),url:c().optional().describe("URL to fetch"),options:u({}).passthrough().optional().describe("Fetch options")}).passthrough(),Oa=u({tabId:I([p(),G()]).optional().describe("Target tab ID"),max_nodes:p().optional().describe("Maximum nodes to include"),options:u({}).passthrough().optional().describe("Snapshot options")}).passthrough(),Ra=u({tabId:I([p(),G()]).optional().describe("Target tab ID"),max_nodes:p().optional().describe("Maximum nodes to include"),options:u({}).passthrough().optional().describe("Snapshot options")}).passthrough(),Da=u({tabId:I([p(),G()]).optional().describe("Target tab ID"),max_nodes:p().optional().describe("Maximum nodes to include"),options:u({}).passthrough().optional().describe("Snapshot options")}).passthrough();M(),M(),M({value:c().optional().describe("Value to fill into the element")}),M({text:c().optional().describe("Text to type into the element")}),u({key:c().optional().describe("Key to press (e.g. Enter, Escape, ArrowDown)")}),M({value:c().optional().describe("Value to select in the dropdown")}),M({checked:k().optional().describe("Desired checked state (true to check, false to uncheck)")}),M(),u({}),u({direction:c().optional().describe("Scroll direction: up, down, left, or right"),amount:p().optional().describe("Pixels to scroll")}),M(),M({text:c().optional().describe("Text to append into the element")}),u({}),u({}),u({duration:Z().default(1000n).describe("Duration to wait in milliseconds")}),u({interactive_only:k().default(!1).describe("Only include interactive elements"),max_nodes:Z().default(500n).describe("Maximum number of nodes to include in snapshot")}),u({interactive_only:k().default(!1).describe("Only include interactive elements"),max_nodes:Z().default(500n).describe("Maximum number of nodes to include in snapshot")}),u({interactive_only:k().default(!1).describe("Only include interactive elements"),max_nodes:Z().default(500n).describe("Maximum number of nodes to include in snapshot")}),u({interactive_only:k().default(!1).describe("Only include interactive elements"),max_nodes:Z().default(500n).describe("Maximum number of nodes to include in snapshot")}),u({snapshot:u({}).passthrough().describe("Raw DOM snapshot data to format"),format:c().optional().describe("Output format (e.g. markdown, html)")});const Ma=u({max_nodes:p().optional().describe("Maximum nodes to include"),options:u({}).passthrough().optional().describe("Snapshot options")}).passthrough(),Pa=u({max_nodes:p().optional().describe("Maximum nodes to include"),options:u({}).passthrough().optional().describe("Snapshot options")}).passthrough(),qa=u({max_nodes:p().optional().describe("Maximum nodes to include"),options:u({}).passthrough().optional().describe("Snapshot options")}).passthrough(),La=u({role:I([c(),E(c())]).optional().describe("Filter by ARIA role"),tag:I([c(),E(c())]).optional().describe("Filter by HTML tag"),text:c().optional().describe("Filter by text content (case-insensitive substring)"),name:c().optional().describe("Filter by accessible name (case-insensitive substring)"),interactiveOnly:k().optional().describe("Only include interactive elements"),href:c().optional().describe("Filter by href pattern (case-insensitive substring)"),src:c().optional().describe("Filter by src pattern (case-insensitive substring)"),limit:p().positive().optional().describe("Maximum filtered nodes to return")}).passthrough(),sr=u({filter:La.optional().describe("Semantic filter criteria"),max_nodes:p().optional().describe("Maximum nodes to collect before filtering")}).passthrough(),$a=sr.extend({tabId:p().describe("Tab ID")});u({path:c().describe("File or directory path")}),u({from:c().describe("Source path"),to:c().describe("Destination path")}),u({path:c().describe("File path to write to"),data:c().describe("Data to write")}),u({path:c().describe("File path to read from"),offset:Z().describe("Byte offset to start reading"),len:p().describe("Number of bytes to read")}),u({path:c().describe("File path to update"),offset:Z().describe("Byte offset to start writing"),data:c().describe("Data to write")}),u({path:c().describe("File path to hash"),algo:c().default("sha256").describe("Hash algorithm (e.g. sha256, md5)")}),y(v()),y(v()),y(v()),y(v()),I([p(),y(v())]),I([p(),y(v())]),y(v()),y(v()),y(v()),I([c(),y(v())]),y(v()),y(v()),y(v()),y(v()),y(v()),I([c(),p(),y(v())]),y(v()),y(v()),y(v()),I([p(),y(v())]),y(v()),y(v()),y(v()),y(v()),y(v()),E(v()),I([c(),y(v())]),y(v()),I([c(),y(v())]),y(v()),I([c(),y(v())]),y(v()),I([c(),y(v())]),y(v()),y(v()),I([p(),y(v())]),y(v()),y(v()),I([p(),y(v())]),y(v()),I([c(),p(),y(v())]),y(v()),y(v()),y(v()),y(v()),I([p(),y(v())]),I([p(),y(v())]),I([p(),y(v())]),I([p(),y(v())]),I([p(),y(v())]),y(v()),y(v()),y(v()),u({action:c().describe("Host action name"),params:u({}).passthrough().optional().describe("Parameters for the host action")}).passthrough();const ja=I([c(),p(),k(),er(),E(v()),y(v())]),C=u({ok:Fe(!0).describe("Whether the action succeeded"),action:c().describe("Action identifier (e.g. 'page_fill')"),refId:ae().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:k().optional().describe("Checked state after the action"),disabled:k().optional().describe("Whether the element is disabled"),readOnly:k().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)"),fileCount:p().optional().describe("Number of files attached (for setFiles actions)"),fileNames:E(c()).optional().describe("Names of attached files (for setFiles actions)"),observationId:c().optional().describe("Opaque ID of the observation lease authorizing this action (snapshot-scoped)"),dispatched:Fe(!0).optional().describe("True if the action was dispatched to the DOM. Does NOT prove the application accepted it."),verification:Fe("required").optional().describe("Always 'required': a fresh observation is required to verify the effect.")});I([C,er()]);const or=u({status:p().describe("HTTP response status code"),ok:k().describe("Whether the response status is 2xx"),headers:y(c()).describe("Response headers as key-value pairs"),body:c().optional().describe("Response body (omitted when bodyEncoding is handle)"),bodyEncoding:tt(["text","base64","handle"]).describe("Encoding of the body field"),handle:c().optional().describe("Binary handle when bodyEncoding is handle"),byteLength:p().describe("Length of the body in bytes"),contentType:c().describe("Response Content-Type header"),finalUrl:c().describe("Final URL after redirects")});u({data:u({}).passthrough().describe("Structured snapshot data"),text:c().describe("Plain text representation of the snapshot")}),u({}),u({tabId:p(),url:c(),title:c(),contentScript:tt(["connected","missing"]),domApis:tt(["ok","blocked"]),mutationsReady:k(),hint:c().optional(),recovery:E(c()).optional()});const Fa=ja,Ua=u({refId:ae().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"),text:c().optional().describe("Visible text content of the element"),value:c().optional().describe("Element value"),checked:k().optional().describe("Checked state"),disabled:k().optional().describe("Whether the element is disabled"),readOnly:k().optional().describe("Whether the element is read-only"),href:c().optional().describe("Absolute URL for link elements"),src:c().optional().describe("Absolute URL for image elements"),alt:c().optional().describe("Alternative text for image elements"),title:c().optional().describe("Title attribute"),parentRefId:ae().optional().describe("Reference ID of the parent container element"),postId:c().optional().describe("Stable post identifier from data-post-id attribute"),permalink:c().optional().describe("Stable permalink URL from anchor element"),imageUrls:E(c()).optional().describe("Image URLs contained within this element")}),at=u({text:c().describe("Plain text representation of the page"),nodes:E(Ua).describe("Array of interactive nodes"),url:c().describe("Current page URL"),title:c().describe("Current page title"),viewport:u({width:p().describe("Viewport width in pixels"),height:p().describe("Viewport height in pixels")}).describe("Viewport dimensions"),observationId:c().optional().describe("Opaque ID of the observation lease granted by this snapshot. Pass to subsequent actions to prove they act on fresh observations.")}),cr=u({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:k().optional().describe("Whether the tab is active"),pinned:k().optional().describe("Whether the tab is pinned"),highlighted:k().optional().describe("Whether the tab is highlighted"),incognito:k().optional().describe("Whether the tab is incognito"),favIconUrl:c().optional().describe("Favicon URL"),audible:k().optional().describe("Whether the tab is audible"),groupId:p().optional().describe("Group ID"),openerTabId:p().optional().describe("Opener tab ID"),discarded:k().optional().describe("Whether the tab is discarded"),autoDiscardable:k().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(),Za=E(cr),lr=u({id:p().optional().describe("Window ID"),focused:k().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:Za.optional().describe("Array of tabs in the window"),incognito:k().optional().describe("Whether the window is incognito"),type:c().optional().describe("Window type"),state:c().optional().describe("Window state"),alwaysOnTop:k().optional().describe("Whether the window is always on top"),sessionId:c().optional().describe("Session ID")}).passthrough();E(lr);const Va=u({name:c().describe("Cookie name"),value:c().describe("Cookie value"),domain:c().optional().describe("Cookie domain"),hostOnly:k().optional().describe("Whether the cookie is host-only"),path:c().optional().describe("Cookie path"),secure:k().optional().describe("Whether the cookie is secure"),httpOnly:k().optional().describe("Whether the cookie is HTTP-only"),sameSite:c().optional().describe("SameSite policy"),session:k().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();E(Va.nullable().unwrap());const Ba=u({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:E(u({id:c()}).passthrough()).optional().describe("Child bookmarks")}).passthrough();E(Ba);const Wa=u({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();E(Wa);const Ha=u({frameId:p().describe("Frame ID"),result:v().optional().describe("Script result")});E(Ha),c(),k(),I([c(),p()]),k();const Ka=u({id:p().optional().describe("Group ID"),collapsed:k().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();E(Ka);const za=u({lastModified:p().optional().describe("Last modified time"),tab:cr.optional().describe("Tab info"),window:lr.optional().describe("Window info")}).passthrough(),Ga=E(za),Ja=u({deviceName:c().optional().describe("Device name"),sessions:Ga.optional().describe("Sessions")}).passthrough();E(Ja);const Qa=u({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:k().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:k().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();E(Qa),p(),u({archName:c().describe("CPU architecture"),modelName:c().describe("CPU model"),numOfProcessors:p().describe("Number of processors"),features:E(c()).describe("CPU features")}),u({capacity:p().describe("Total memory capacity"),availableCapacity:p().describe("Available memory capacity")}),E(u({id:c().describe("Storage ID"),name:c().describe("Storage name"),type:c().describe("Storage type"),capacity:p().describe("Storage capacity")}));const J="Returns a Promise; await before reading the result. For a cell's last line, use `page.snapshot()` without a leading await so the cell returns the settled value.",Xa=[{action:"page_back",namespace:"page",name:"back",description:"Go back in the active tab",params:Kn,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:Gn,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:[J,"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:Qn,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:[J,"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_set_files",namespace:"page",name:"setFiles",description:"Attach files to a file input in the active tab",params:Xn,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:"files",type:"{ name?: string, url?: string, path?: string, handle?: string, mimeType?: string }[]",required:!0,description:"Each entry uses exactly one of url, path (vfs), or handle (from page.fetch store:true)"}],returnDoc:"{ ok: true, action: 'setFiles', refId?, fileCount?, fileNames? }",errorCode:"E_MISSING_PARAM",example:'page.setFiles({ refId: "e3", files: [{ url: "https://example.com/photo.jpg", name: "photo.jpg" }] })',agentMeta:{prerequisites:["Ensure the target tab is active and the content script is ready before mutating"],notes:[J,"Target must be input[type=file]; prefer url, vfs path, or fetch handle — bytes are not passed through QuickJS","Use page.fetch({ url, store: true }) then setFiles({ files: [{ handle }] }) for downloaded binaries","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.setFiles","page.fetch","fs.writeBase64"]},handlerKey:"set_files"},{action:"page_type",namespace:"page",name:"type",description:"Type into an element in the active tab",params:ea,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:[J,"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:ta,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:ra,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:na,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:aa,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:ia,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:sa,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:oa,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:ca,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:la,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:ha,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:ma,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_set_files",namespace:"web.tab",name:"setFiles",description:"Attach files to a file input in a tab",params:ba,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:"files",type:"{ name?: string, url?: string, path?: string, handle?: string, mimeType?: string }[]",required:!0,description:"Each entry uses exactly one of url, path (vfs), or handle"}],returnDoc:"{ ok: true, action: 'setFiles', refId?, fileCount?, fileNames? }",errorCode:"E_NO_TAB",example:'web.tab.setFiles({ tabId: 123, refId: "e3", files: [{ url: "https://example.com/photo.jpg" }] })',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.setFiles"]},handlerKey:"set_files"},{action:"tab_scroll_to",namespace:"web.tab",name:"scroll_to",description:"Scroll to position in a tab",params:ya,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:va,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:_a,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:wa,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:ka,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:xa,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:Ia,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:Ta,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:Sa,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:Aa,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"},{action:"page_forward",namespace:"page",name:"forward",description:"Go forward in the active tab",params:zn,returns:C,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:Ma,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:[J,"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:Pa,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:qa,returns:at,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:[J,"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_snapshot_query",namespace:"page",name:"snapshot_query",description:"Query page snapshot with semantic filtering by role, tag, text, name, etc.",params:sr,returns:at,paramTypes:[{name:"filter",type:"{ role?: string | string[], tag?: string | string[], text?: string, name?: string, interactiveOnly?: boolean, href?: string, src?: string, limit?: number }",required:!1,description:"Semantic filter criteria (literal)"},{name:"max_nodes",type:"number",required:!1,description:"Maximum nodes to collect before filtering (literal)"}],returnDoc:"{ text, nodes (filtered), url, title, viewport }",errorCode:"E_SNAPSHOT",example:'page.snapshot_query({ filter: { role: "button" } })',agentMeta:{notes:[J,"Content-script path; filters nodes by role, tag, text, name, interactiveOnly, href, src","More efficient than page.snapshot_data() when only specific elements are needed"],tags:["snapshot","read"],relatedApis:["page.snapshot_data","page.find"]},handlerKey:"snapshot_query"},{action:"page_find",namespace:"page",name:"find",description:"Find elements in the active tab using a CSS selector",params:da,returns:E(u({refId:ae(),role:c(),tag:c(),name:c().optional(),text:c().optional(),value:c().optional(),checked:k().optional(),disabled:k().optional(),readOnly:k().optional(),href:c().optional(),src:c().optional(),alt:c().optional(),title:c().optional(),parentRefId:ae().optional()})),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 with refId, role, name, href/src, alt, and parentRefId",errorCode:"E_NO_TAB",example:'page.find("h1")',agentMeta:{notes:["Assigns data-ref-id on matched elements when missing so results include actionable refIds"],tags:["read"]},handlerKey:"find"},{action:"page_wait_for",namespace:"page",name:"wait_for",description:"Wait for a selector in the active tab",params:ua,returns:k(),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)',agentMeta:{notes:[J],tags:["read"]},handlerKey:"wait_for"},{action:"page_extract",namespace:"page",name:"extract",description:"Extract data from the active tab",params:pa,returns:u({title:c().optional(),url:c().optional(),headings:E(u({tag:c(),text:c()})).optional(),links:E(u({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:{notes:[J],tags:["read"]},handlerKey:"extract"},{action:"page_fetch",namespace:"page",name:"fetch",description:"Fetch in the active tab",params:Wn,returns:or,fields:["url","options"],paramTypes:[{name:"url",type:"string",required:!1,description:"URL to fetch (url)"},{name:"options",type:"{ method?: string, headers?: { [key: string]: string }, 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:{notes:[J,"Runtime binary globals available: Uint8Array, ArrayBuffer, TextEncoder, TextDecoder, atob, btoa","For binary responses bodyEncoding is 'base64'; use atob() or fs.writeBase64 to handle bytes"],tags:["read"]},handlerKey:"fetch"},{action:"tab_forward",namespace:"web.tab",name:"forward",description:"Go forward in a tab",params:Ca,returns:C,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:Oa,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:Ra,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:Da,returns:at,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_snapshot_query",namespace:"web.tab",name:"snapshot_query",description:"Query tab snapshot with semantic filtering by role, tag, text, name, etc.",params:$a,returns:at,fields:["tabId"],paramTypes:[{name:"tabId",type:"number",required:!0,description:"Tab ID (literal)"},{name:"filter",type:"{ role?: string | string[], tag?: string | string[], text?: string, name?: string, interactiveOnly?: boolean, href?: string, src?: string, limit?: number }",required:!1,description:"Semantic filter criteria (literal)"},{name:"max_nodes",type:"number",required:!1,description:"Maximum nodes to collect before filtering (literal)"}],returnDoc:"{ text, nodes (filtered), url, title, viewport }",errorCode:"E_SNAPSHOT",example:'web.tab.snapshot_query({ tabId: 123, filter: { role: "button" } })',agentMeta:{notes:["Explicit tabId required; same handler as page.snapshot_query","Filters nodes by role, tag, text, name, interactiveOnly, href, src"],tags:["snapshot","read"],relatedApis:["page.snapshot_query"]},handlerKey:"snapshot_query"},{action:"tab_fetch",namespace:"web.tab",name:"fetch",description:"Fetch in a tab",params:Na,returns:or,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:Ea,returns:Fa,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 Ya(){return[{registryAction:"ping",handlerKey:"ping",params:u({}),returns:u({ok:k()})}]}const ei=new Set(["page_set_files","tab_set_files"]);function ti(){return Xa.map(t=>({registryAction:t.action,handlerKey:t.handlerKey,params:ei.has(t.action)?t.action==="tab_set_files"?ga:Yn:t.params,returns:t.returns}))}if(mr(),window.__jsNotebookContentScriptInjected)throw new Error("Content script already injected");window.__jsNotebookContentScriptInjected=!0,qn([...ti(),...Ya()]),Un()})();