page-agent 1.3.0 β†’ 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -9,26 +9,33 @@
9
9
 
10
10
  The GUI Agent Living in Your Webpage. Control web interfaces with natural language.
11
11
 
12
- 🌐 **English** | [δΈ­ζ–‡](./README-zh.md)
12
+ 🌐 **English** | [δΈ­ζ–‡](./docs/README-zh.md)
13
13
 
14
- πŸ‘‰ <a href="https://alibaba.github.io/page-agent/" target="_blank"><b>πŸš€ Demo</b></a> | <a href="https://alibaba.github.io/page-agent/#/docs/introduction/overview" target="_blank"><b>πŸ“– Documentation</b></a>
14
+ πŸ‘‰ <a href="https://alibaba.github.io/page-agent/" target="_blank"><b>πŸš€ Demo</b></a> | <a href="https://alibaba.github.io/page-agent/docs/introduction/overview" target="_blank"><b>πŸ“– Documentation</b></a>
15
15
 
16
- <video id="demo-video" src="https://github.com/user-attachments/assets/34d8444d-cbfb-44a3-a24e-fd5c167bb0bf" controls crossorigin muted></video>
16
+ <video id="demo-video" src="https://github.com/user-attachments/assets/11aed429-b69c-49d5-8982-fa99b4a0e9a8" controls crossorigin muted></video>
17
17
 
18
18
  ---
19
19
 
20
20
  ## ✨ Features
21
21
 
22
- - **🎯 Easy integration**
23
- - No need for `browser extension` / `python` / `headless browser`.
24
- - Just in-page javascript. Everything happens in your web page.
25
- - The best tool for your agent to control web pages.
22
+ - **🎯 Easy integration**
23
+ - No need for `browser extension` / `python` / `headless browser`.
24
+ - Just in-page javascript. Everything happens in your web page.
25
+ - The best tool for your agent to control web pages.
26
26
  - **πŸ“– Text-based DOM manipulation**
27
- - No screenshots. No OCR or multi-modal LLMs needed.
28
- - No special permissions required.
27
+ - No screenshots. No OCR or multi-modal LLMs needed.
28
+ - No special permissions required.
29
29
  - **🧠 Bring your own LLMs**
30
30
  - **🎨 Pretty UI with human-in-the-loop**
31
- - **πŸ™ Optional [chrome extension](https://alibaba.github.io/page-agent/#/docs/features/chrome-extension) for multi-page tasks.**
31
+ - **πŸ™ Optional [chrome extension](https://alibaba.github.io/page-agent/docs/features/chrome-extension) for multi-page tasks.**
32
+
33
+ ## πŸ’‘ Use Cases
34
+
35
+ - **SaaS AI Copilot** β€” Ship an AI copilot in your product in lines of code. No backend rewrite needed.
36
+ - **Smart Form Filling** β€” Turn 20-click workflows into one sentence. Perfect for ERP, CRM, and admin systems.
37
+ - **Accessibility** β€” Make any web app accessible through natural language. Voice commands, screen readers, zero barrier.
38
+ - **Multi-page Agent** β€” Extend your agent's reach across browser tabs with the optional [chrome extension](https://alibaba.github.io/page-agent/docs/features/chrome-extension).
32
39
 
33
40
  ## πŸš€ Quick Start
34
41
 
@@ -42,10 +49,10 @@ Fastest way to try PageAgent with our free Demo LLM:
42
49
 
43
50
  | Mirrors | URL |
44
51
  | ------- | ---------------------------------------------------------------------------------- |
45
- | Global | https://cdn.jsdelivr.net/npm/page-agent@1.3.0/dist/iife/page-agent.demo.js |
46
- | China | https://registry.npmmirror.com/page-agent/1.3.0/files/dist/iife/page-agent.demo.js |
52
+ | Global | https://cdn.jsdelivr.net/npm/page-agent@1.4.0/dist/iife/page-agent.demo.js |
53
+ | China | https://registry.npmmirror.com/page-agent/1.4.0/files/dist/iife/page-agent.demo.js |
47
54
 
48
- > **⚠️ For technical evaluation only.** Demo LLM has rate limits and usage restrictions. Slow. May change without notice.
55
+ > **⚠️ For technical evaluation only.** This demo CDN uses our free [testing LLM API](https://alibaba.github.io/page-agent/docs/features/models#free-testing-api). By using it, you agree to its [terms](https://github.com/alibaba/page-agent/blob/main/docs/terms-and-privacy.md).
49
56
 
50
57
  ### NPM Installation
51
58
 
@@ -57,8 +64,8 @@ npm install page-agent
57
64
  import { PageAgent } from 'page-agent'
58
65
 
59
66
  const agent = new PageAgent({
60
- model: 'deepseek-chat',
61
- baseURL: 'https://api.deepseek.com',
67
+ model: 'qwen3.5-plus',
68
+ baseURL: 'https://dashscope.aliyuncs.com/compatible-mode/v1',
62
69
  apiKey: 'YOUR_API_KEY',
63
70
  language: 'en-US',
64
71
  })
@@ -66,28 +73,13 @@ const agent = new PageAgent({
66
73
  await agent.execute('Click the login button')
67
74
  ```
68
75
 
69
- For more programmatic usage, see [πŸ“– Documentations](https://alibaba.github.io/page-agent/#/docs/introduction/overview).
70
-
71
- ## πŸ—οΈ Structure
72
-
73
- PageAgent adopts a simplified monorepo structure:
74
-
75
- ```
76
- packages/
77
- β”œβ”€β”€ core/ # ** Core agent logic (npm: @page-agent/core) **
78
- β”œβ”€β”€ llms/ # LLM client (npm: @page-agent/llms)
79
- β”œβ”€β”€ page-controller/ # DOM operations (npm: @page-agent/page-controller)
80
- β”œβ”€β”€ ui/ # Panel UI (npm: @page-agent/ui)
81
- β”œβ”€β”€ page-agent/ # Entry class and iife builds(npm: page-agent)
82
- β”œβ”€β”€ extension/ # Chrome extension for multi-page tasks
83
- └── website/ # Website & Documentation site
84
- ```
76
+ For more programmatic usage, see [πŸ“– Documentations](https://alibaba.github.io/page-agent/docs/introduction/overview).
85
77
 
86
78
  ## 🀝 Contributing
87
79
 
88
80
  We welcome contributions from the community! Follow our instructions in [CONTRIBUTING.md](CONTRIBUTING.md) for environment setup and local development.
89
81
 
90
- Please read [Code of Conduct](CODE_OF_CONDUCT.md) before contributing.
82
+ Please read [Code of Conduct](docs/CODE_OF_CONDUCT.md) before contributing.
91
83
 
92
84
  ## πŸ‘ Acknowledgments
93
85
 
@@ -1,11 +1,8 @@
1
- var $t=Object.defineProperty;var xt=L=>{throw TypeError(L)};var qt=(L,M,V)=>M in L?$t(L,M,{enumerable:!0,configurable:!0,writable:!0,value:V}):L[M]=V;var a=(L,M)=>$t(L,"name",{value:M,configurable:!0});var ne=(L,M,V)=>qt(L,typeof M!="symbol"?M+"":M,V),mt=(L,M,V)=>M.has(L)||xt("Cannot "+V);var p=(L,M,V)=>(mt(L,M,"read from private field"),V?V.call(L):M.get(L)),Z=(L,M,V)=>M.has(L)?xt("Cannot add the same private member more than once"):M instanceof WeakSet?M.add(L):M.set(L,V),T=(L,M,V,Ue)=>(mt(L,M,"write to private field"),Ue?Ue.call(L,V):M.set(L,V),V),b=(L,M,V)=>(mt(L,M,"access private method"),V);(function(){"use strict";var je,Pe,ie,Oe,Q,C,St,Ae,Fe,_t,Tt,It,zt,At,Pt,st,re,Be,ae,ye,Re,be,Ce,we,W,Ze,Ee,j,$e,ve,Ne,ee,We,He,Je,Ye,qe,_,Ot,Rt,Ct,Zt,yt,Nt,Lt,Mt,tt,bt,Ft,Dt,Ut,wt,ot,it,jt,Bt,Wt,Vt,De,vt,kt,Gt,Ht,Jt,Y,ce,le,xe,Se,Le,Yt,Et;var __vite_style__=document.createElement("style");__vite_style__.textContent=`._wrapper_gtdpc_1{position:fixed;bottom:100px;left:50%;transform:translate(-50%) translateY(20px);opacity:0;z-index:2147483642;box-sizing:border-box;overflow:visible;--width: 360px;--height: 40px;--border-radius: 12px;--side-space: 12px;--history-width: calc(var(--width) - var(--side-space) * 2);--color-1: rgb(57, 182, 255);--color-2: rgb(189, 69, 251);--color-3: rgb(255, 87, 51);--color-4: rgb(255, 214, 0);width:var(--width);height:var(--height);transition:all .3s ease-in-out}._wrapper_gtdpc_1 *{box-sizing:border-box}@media(max-width:480px){._wrapper_gtdpc_1{width:calc(100vw - 40px);--width: calc(100vw - 40px) }}._wrapper_gtdpc_1 ._background_gtdpc_39{position:absolute;inset:-2px -8px;border-radius:calc(var(--border-radius) + 4px);filter:blur(16px);overflow:hidden}._wrapper_gtdpc_1 ._background_gtdpc_39:before{content:"";z-index:-1;pointer-events:none;position:absolute;width:100%;height:100%;left:0;top:0;background-image:linear-gradient(to bottom left,var(--color-1),var(--color-2),var(--color-1));animation:_mask-running_gtdpc_1 2s linear infinite}._wrapper_gtdpc_1 ._background_gtdpc_39:after{content:"";z-index:-1;pointer-events:none;position:absolute;width:100%;height:100%;left:0;top:0;background-image:linear-gradient(to bottom left,var(--color-2),var(--color-1),var(--color-2));animation:_mask-running_gtdpc_1 2s linear infinite;animation-delay:1s}@keyframes _mask-running_gtdpc_1{0%{transform:translate(-100%)}to{transform:translate(100%)}}._header_gtdpc_99{display:flex;align-items:center;justify-content:space-between;padding:8px 12px;-webkit-user-select:none;user-select:none;position:absolute;inset:0;cursor:pointer;flex-shrink:0;background:#00000080;-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);border-radius:var(--border-radius);background-clip:padding-box;box-shadow:0 0 0 2px #fff6,0 0 5px 1px #ffffff4d}._header_gtdpc_99 ._statusSection_gtdpc_121{display:flex;align-items:center;gap:8px;flex:1;min-height:24px}._header_gtdpc_99 ._statusSection_gtdpc_121 ._indicator_gtdpc_128{width:6px;height:6px;border-radius:50%;background:#ffffff80;flex-shrink:0;animation:none}._header_gtdpc_99 ._statusSection_gtdpc_121 ._indicator_gtdpc_128._thinking_gtdpc_137{background:#39b6ff;animation:_pulse_gtdpc_1 .8s ease-in-out infinite}._header_gtdpc_99 ._statusSection_gtdpc_121 ._indicator_gtdpc_128._tool_executing_gtdpc_142{background:#bd45fb;animation:_pulse_gtdpc_1 .6s ease-in-out infinite}._header_gtdpc_99 ._statusSection_gtdpc_121 ._indicator_gtdpc_128._retry_gtdpc_147{background:#ffd600;animation:_retryPulse_gtdpc_1 1s ease-in-out infinite}._header_gtdpc_99 ._statusSection_gtdpc_121 ._indicator_gtdpc_128._completed_gtdpc_153,._header_gtdpc_99 ._statusSection_gtdpc_121 ._indicator_gtdpc_128._input_gtdpc_154,._header_gtdpc_99 ._statusSection_gtdpc_121 ._indicator_gtdpc_128._output_gtdpc_155{background:#22c55e;animation:none}._header_gtdpc_99 ._statusSection_gtdpc_121 ._indicator_gtdpc_128._error_gtdpc_160{background:#ef4444;animation:none}._header_gtdpc_99 ._statusSection_gtdpc_121 ._statusText_gtdpc_166{color:#fff;font-size:12px;line-height:1;font-weight:500;transition:all .3s ease-in-out;position:relative;overflow:hidden;display:flex;align-items:center;min-height:24px}._header_gtdpc_99 ._statusSection_gtdpc_121 ._statusText_gtdpc_166._fadeOut_gtdpc_178{animation:_statusTextFadeOut_gtdpc_1 .3s ease forwards}._header_gtdpc_99 ._statusSection_gtdpc_121 ._statusText_gtdpc_166._fadeIn_gtdpc_182{animation:_statusTextFadeIn_gtdpc_1 .3s ease forwards}._header_gtdpc_99 ._controls_gtdpc_188{display:flex;align-items:center;gap:4px}._header_gtdpc_99 ._controls_gtdpc_188 ._controlButton_gtdpc_193{width:24px;height:24px;border:none;border-radius:4px;background:#ffffff1a;color:#fff;cursor:pointer;display:flex;align-items:center;justify-content:center;font-size:12px;line-height:1}._header_gtdpc_99 ._controls_gtdpc_188 ._controlButton_gtdpc_193:hover{background:#fff3}._header_gtdpc_99 ._controls_gtdpc_188 ._stopButton_gtdpc_212{background:#ef444433;color:#ff2929;font-weight:600}._header_gtdpc_99 ._controls_gtdpc_188 ._stopButton_gtdpc_212:hover{background:#ef44444d}@keyframes _statusTextFadeIn_gtdpc_1{0%{opacity:0;transform:translateY(5px)}to{opacity:1;transform:translateY(0)}}@keyframes _statusTextFadeOut_gtdpc_1{0%{opacity:1;transform:translateY(0)}to{opacity:0;transform:translateY(-5px)}}._historySectionWrapper_gtdpc_246{position:absolute;width:var(--history-width);bottom:var(--height);left:var(--side-space);z-index:-2;padding-top:0;visibility:collapse;overflow:hidden;transition:all .2s;background:#02001480;-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);text-shadow:0 0 1px rgba(0,0,0,.2);border-top-left-radius:calc(var(--border-radius) + 4px);border-top-right-radius:calc(var(--border-radius) + 4px);border:2px solid rgba(255,255,255,.4);box-shadow:0 4px 16px #0009}._expanded_gtdpc_278 ._historySectionWrapper_gtdpc_246{padding-top:8px;visibility:visible}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246{position:relative;overflow-y:auto;overscroll-behavior:contain;scrollbar-width:none;max-height:0;padding-inline:8px;transition:max-height .2s}._expanded_gtdpc_278 :is(._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246){max-height:400px}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297{padding:8px 10px;margin-bottom:6px;background:linear-gradient(135deg,#ffffff14,#ffffff08);border-radius:8px;border-left:2px solid rgba(57,182,255,.5);font-size:12px;color:#fff;line-height:1.3;position:relative;overflow:hidden;box-shadow:inset 0 1px #ffffff1a,0 1px 3px #0000001a}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297:before{content:"";position:absolute;top:0;left:0;right:0;height:1px;background:linear-gradient(90deg,transparent,rgba(255,255,255,.2),transparent)}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297:hover{background:linear-gradient(135deg,#ffffff1f,#ffffff0f);box-shadow:inset 0 1px #ffffff26,0 2px 4px #00000026}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297:last-child{margin-bottom:10px}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297._completed_gtdpc_153,._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297._input_gtdpc_154,._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297._output_gtdpc_155{border-left-color:#22c55e;background:linear-gradient(135deg,#22c55e1a,#22c55e0d)}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297._error_gtdpc_160{border-left-color:#ef4444;background:linear-gradient(135deg,#ef44441a,#ef44440d)}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297._retry_gtdpc_147{border-left-color:#ffd600;background:linear-gradient(135deg,#ffd6001a,#ffd6000d)}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297._observation_gtdpc_355{border-left-color:#9333ea;background:linear-gradient(135deg,#9333ea1a,#9333ea0d)}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297._question_gtdpc_360{border-left-color:#ff9f43;background:linear-gradient(135deg,#ff9f4326,#ff9f4314)}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297._doneSuccess_gtdpc_366{background:linear-gradient(135deg,#22c55e40,#22c55e26,#22c55e14);border:none;border-left:4px solid rgb(34,197,94);box-shadow:0 4px 12px #22c55e4d,inset 0 1px #fff3,0 0 20px #22c55e1a;font-weight:600;color:#dcfce7;padding:10px 12px;margin-bottom:8px;border-radius:8px;position:relative;overflow:hidden}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297._doneSuccess_gtdpc_366:before{background:linear-gradient(90deg,transparent,rgba(34,197,94,.4),transparent)}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297._doneSuccess_gtdpc_366:after{content:"";position:absolute;top:0;left:-100%;width:100%;height:100%;background:linear-gradient(90deg,transparent,rgba(255,255,255,.1),transparent);animation:_shimmer_gtdpc_1 2s ease-in-out infinite}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297._doneSuccess_gtdpc_366 ._historyContent_gtdpc_402 ._statusIcon_gtdpc_403{font-size:16px;animation:_celebrate_gtdpc_1 .8s ease-in-out;filter:drop-shadow(0 2px 4px rgba(34,197,94,.5))}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297._doneError_gtdpc_412{background:linear-gradient(135deg,#ef444440,#ef444426,#ef444414);border:none;border-left:4px solid rgb(239,68,68);box-shadow:0 4px 12px #ef44444d,inset 0 1px #fff3,0 0 20px #ef44441a;font-weight:600;color:#fee2e2;padding:10px 12px;margin-bottom:8px;border-radius:8px;position:relative;overflow:hidden}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297._doneError_gtdpc_412:before{background:linear-gradient(90deg,transparent,rgba(239,68,68,.4),transparent)}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297._doneError_gtdpc_412 ._historyContent_gtdpc_402 ._statusIcon_gtdpc_403{font-size:16px;filter:drop-shadow(0 2px 4px rgba(239,68,68,.5))}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297 ._historyContent_gtdpc_402{display:flex;align-items:flex-start;gap:8px;word-break:break-all;white-space:pre-wrap}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297 ._historyContent_gtdpc_402 ._statusIcon_gtdpc_403{font-size:12px;flex-shrink:0;line-height:1;transition:all .3s ease}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297 ._historyContent_gtdpc_402 ._reflectionLines_gtdpc_462{display:flex;flex-direction:column;gap:4px}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297 ._historyMeta_gtdpc_469{font-size:10px;color:#fff9;margin-top:8px;line-height:1}@keyframes _pulse_gtdpc_1{0%,to{opacity:1;transform:scale(1)}50%{opacity:.4;transform:scale(1.3)}}@keyframes _retryPulse_gtdpc_1{0%,to{opacity:1;transform:scale(1) rotate(0)}25%{opacity:.6;transform:scale(1.2) rotate(90deg)}50%{opacity:.8;transform:scale(1.1) rotate(180deg)}75%{opacity:.6;transform:scale(1.2) rotate(270deg)}}@keyframes _celebrate_gtdpc_1{0%,to{transform:scale(1)}25%{transform:scale(1.2) rotate(-5deg)}75%{transform:scale(1.2) rotate(5deg)}}@keyframes _shimmer_gtdpc_1{0%{left:-100%}to{left:100%}}._inputSectionWrapper_gtdpc_539{position:absolute;width:var(--history-width);top:var(--height);left:var(--side-space);z-index:-1;visibility:visible;overflow:hidden;height:48px;transition:all .2s;background:#bababa33;-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);border-bottom-left-radius:calc(var(--border-radius) + 4px);border-bottom-right-radius:calc(var(--border-radius) + 4px);border:2px solid rgba(255,255,255,.3);box-shadow:0 1px 16px #0006}._inputSectionWrapper_gtdpc_539._hidden_gtdpc_562{visibility:collapse;height:0}._inputSectionWrapper_gtdpc_539 ._inputSection_gtdpc_539{display:flex;align-items:center;gap:4px;padding:8px}._inputSectionWrapper_gtdpc_539 ._inputSection_gtdpc_539 ._taskInput_gtdpc_573{flex:1;background:#fff6;border:1px solid rgba(255,255,255,.3);border-radius:10px;padding-inline:10px;color:#141414;font-size:12px;height:28px;line-height:1;outline:none;transition:all .2s ease}._inputSectionWrapper_gtdpc_539 ._inputSection_gtdpc_539 ._taskInput_gtdpc_573::placeholder{color:#353535}._inputSectionWrapper_gtdpc_539 ._inputSection_gtdpc_539 ._taskInput_gtdpc_573:focus{background:#fffc;border-color:#39b6ff99;box-shadow:0 0 0 2px #39b6ff33}._wrapper_gf8tz_1{position:fixed;inset:0;z-index:2147483641;cursor:wait;overflow:hidden;display:none}._cursor_1dgwb_2{position:absolute;width:var(--cursor-size, 75px);height:var(--cursor-size, 75px);pointer-events:none;z-index:10000}._cursorBorder_1dgwb_10{position:absolute;width:100%;height:100%;background:linear-gradient(45deg,#39b6ff,#bd45fb);-webkit-mask-image:url("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20100%20100'%20fill='none'%3e%3cg%3e%3cpath%20d='M%2015%2042%20L%2015%2036.99%20Q%2015%2031.99%2023.7%2031.99%20L%2028.05%2031.99%20Q%2032.41%2031.99%2032.41%2021.99%20L%2032.41%2017%20Q%2032.41%2012%2041.09%2016.95%20L%2076.31%2037.05%20Q%2085%2042%2076.31%2046.95%20L%2041.09%2067.05%20Q%2032.41%2072%2032.41%2062.01%20L%2032.41%2057.01%20Q%2032.41%2052.01%2023.7%2052.01%20L%2019.35%2052.01%20Q%2015%2052.01%2015%2047.01%20Z'%20fill='none'%20stroke='%23000000'%20stroke-width='6'%20stroke-miterlimit='10'%20style='stroke:%20light-dark(rgb(0,%200,%200),%20rgb(255,%20255,%20255));'/%3e%3c/g%3e%3c/svg%3e");mask-image:url("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20100%20100'%20fill='none'%3e%3cg%3e%3cpath%20d='M%2015%2042%20L%2015%2036.99%20Q%2015%2031.99%2023.7%2031.99%20L%2028.05%2031.99%20Q%2032.41%2031.99%2032.41%2021.99%20L%2032.41%2017%20Q%2032.41%2012%2041.09%2016.95%20L%2076.31%2037.05%20Q%2085%2042%2076.31%2046.95%20L%2041.09%2067.05%20Q%2032.41%2072%2032.41%2062.01%20L%2032.41%2057.01%20Q%2032.41%2052.01%2023.7%2052.01%20L%2019.35%2052.01%20Q%2015%2052.01%2015%2047.01%20Z'%20fill='none'%20stroke='%23000000'%20stroke-width='6'%20stroke-miterlimit='10'%20style='stroke:%20light-dark(rgb(0,%200,%200),%20rgb(255,%20255,%20255));'/%3e%3c/g%3e%3c/svg%3e");-webkit-mask-size:100% 100%;mask-size:100% 100%;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;transform-origin:center;transform:rotate(-135deg) scale(1.2);margin-left:-10px;margin-top:-18px}._cursorFilling_1dgwb_25{position:absolute;width:100%;height:100%;background:url("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20100%20100'%3e%3cdefs%3e%3c/defs%3e%3cg%20xmlns='http://www.w3.org/2000/svg'%20style='filter:%20drop-shadow(light-dark(rgba(0,%200,%200,%200.4),%20rgba(237,%20237,%20237,%200.4))%203px%204px%204px);'%3e%3cpath%20d='M%2015%2042%20L%2015%2036.99%20Q%2015%2031.99%2023.7%2031.99%20L%2028.05%2031.99%20Q%2032.41%2031.99%2032.41%2021.99%20L%2032.41%2017%20Q%2032.41%2012%2041.09%2016.95%20L%2076.31%2037.05%20Q%2085%2042%2076.31%2046.95%20L%2041.09%2067.05%20Q%2032.41%2072%2032.41%2062.01%20L%2032.41%2057.01%20Q%2032.41%2052.01%2023.7%2052.01%20L%2019.35%2052.01%20Q%2015%2052.01%2015%2047.01%20Z'%20fill='%23ffffff'%20stroke='none'%20style='fill:%20%23ffffff;'/%3e%3c/g%3e%3c/svg%3e");background-size:100% 100%;background-repeat:no-repeat;transform-origin:center;transform:rotate(-135deg) scale(1.2);margin-left:-10px;margin-top:-18px}._cursorRipple_1dgwb_39{position:absolute;width:100%;height:100%;pointer-events:none;margin-left:-50%;margin-top:-50%}._cursorRipple_1dgwb_39:after{content:"";opacity:0;position:absolute;inset:0;border:4px solid rgba(57,182,255,1);border-radius:50%}._cursor_1dgwb_2._clicking_1dgwb_57 ._cursorRipple_1dgwb_39:after{animation:_cursor-ripple_1dgwb_1 .3s ease-out forwards}@keyframes _cursor-ripple_1dgwb_1{0%{transform:scale(0);opacity:1}to{transform:scale(2);opacity:0}}
2
- /*$vite$:1*/`,document.head.appendChild(__vite_style__);const InvokeErrorType={NETWORK_ERROR:"network_error",RATE_LIMIT:"rate_limit",SERVER_ERROR:"server_error",NO_TOOL_CALL:"no_tool_call",INVALID_TOOL_ARGS:"invalid_tool_args",TOOL_EXECUTION_ERROR:"tool_execution_error",UNKNOWN:"unknown",AUTH_ERROR:"auth_error",CONTEXT_LENGTH:"context_length",CONTENT_FILTER:"content_filter"},L=class L extends Error{type;retryable;statusCode;rawError;rawResponse;constructor(t,o,n,r){super(o),this.name="InvokeError",this.type=t,this.retryable=this.isRetryable(t,n),this.rawError=n,this.rawResponse=r}isRetryable(t,o){return o?.name==="AbortError"?!1:[InvokeErrorType.NETWORK_ERROR,InvokeErrorType.RATE_LIMIT,InvokeErrorType.SERVER_ERROR,InvokeErrorType.NO_TOOL_CALL,InvokeErrorType.INVALID_TOOL_ARGS,InvokeErrorType.TOOL_EXECUTION_ERROR,InvokeErrorType.UNKNOWN].includes(t)}};a(L,"InvokeError");let InvokeError=L;const ANSI_BACKGROUND_OFFSET=10,wrapAnsi16=a((e=0)=>t=>`\x1B[${t+e}m`,"wrapAnsi16"),wrapAnsi256=a((e=0)=>t=>`\x1B[${38+e};5;${t}m`,"wrapAnsi256"),wrapAnsi16m=a((e=0)=>(t,o,n)=>`\x1B[${38+e};2;${t};${o};${n}m`,"wrapAnsi16m"),styles$3={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};Object.keys(styles$3.modifier);const foregroundColorNames=Object.keys(styles$3.color),backgroundColorNames=Object.keys(styles$3.bgColor);[...foregroundColorNames,...backgroundColorNames];function assembleStyles(){const e=new Map;for(const[t,o]of Object.entries(styles$3)){for(const[n,r]of Object.entries(o))styles$3[n]={open:`\x1B[${r[0]}m`,close:`\x1B[${r[1]}m`},o[n]=styles$3[n],e.set(r[0],r[1]);Object.defineProperty(styles$3,t,{value:o,enumerable:!1})}return Object.defineProperty(styles$3,"codes",{value:e,enumerable:!1}),styles$3.color.close="\x1B[39m",styles$3.bgColor.close="\x1B[49m",styles$3.color.ansi=wrapAnsi16(),styles$3.color.ansi256=wrapAnsi256(),styles$3.color.ansi16m=wrapAnsi16m(),styles$3.bgColor.ansi=wrapAnsi16(ANSI_BACKGROUND_OFFSET),styles$3.bgColor.ansi256=wrapAnsi256(ANSI_BACKGROUND_OFFSET),styles$3.bgColor.ansi16m=wrapAnsi16m(ANSI_BACKGROUND_OFFSET),Object.defineProperties(styles$3,{rgbToAnsi256:{value(t,o,n){return t===o&&o===n?t<8?16:t>248?231:Math.round((t-8)/247*24)+232:16+36*Math.round(t/255*5)+6*Math.round(o/255*5)+Math.round(n/255*5)},enumerable:!1},hexToRgb:{value(t){const o=/[a-f\d]{6}|[a-f\d]{3}/i.exec(t.toString(16));if(!o)return[0,0,0];let[n]=o;n.length===3&&(n=[...n].map(i=>i+i).join(""));const r=Number.parseInt(n,16);return[r>>16&255,r>>8&255,r&255]},enumerable:!1},hexToAnsi256:{value:a(t=>styles$3.rgbToAnsi256(...styles$3.hexToRgb(t)),"value"),enumerable:!1},ansi256ToAnsi:{value(t){if(t<8)return 30+t;if(t<16)return 90+(t-8);let o,n,r;if(t>=232)o=((t-232)*10+8)/255,n=o,r=o;else{t-=16;const c=t%36;o=Math.floor(t/36)/5,n=Math.floor(c/6)/5,r=c%6/5}const i=Math.max(o,n,r)*2;if(i===0)return 30;let s=30+(Math.round(r)<<2|Math.round(n)<<1|Math.round(o));return i===2&&(s+=60),s},enumerable:!1},rgbToAnsi:{value:a((t,o,n)=>styles$3.ansi256ToAnsi(styles$3.rgbToAnsi256(t,o,n)),"value"),enumerable:!1},hexToAnsi:{value:a(t=>styles$3.ansi256ToAnsi(styles$3.hexToAnsi256(t)),"value"),enumerable:!1}}),styles$3}a(assembleStyles,"assembleStyles");const ansiStyles=assembleStyles(),level=(()=>{if(!("navigator"in globalThis))return 0;if(globalThis.navigator.userAgentData){const e=navigator.userAgentData.brands.find(({brand:t})=>t==="Chromium");if(e&&e.version>93)return 3}return/\b(Chrome|Chromium)\//.test(globalThis.navigator.userAgent)?1:0})(),colorSupport=level!==0&&{level},supportsColor={stdout:colorSupport,stderr:colorSupport};function stringReplaceAll(e,t,o){let n=e.indexOf(t);if(n===-1)return e;const r=t.length;let i=0,s="";do s+=e.slice(i,n)+t+o,i=n+r,n=e.indexOf(t,i);while(n!==-1);return s+=e.slice(i),s}a(stringReplaceAll,"stringReplaceAll");function stringEncaseCRLFWithFirstIndex(e,t,o,n){let r=0,i="";do{const s=e[n-1]==="\r";i+=e.slice(r,s?n-1:n)+t+(s?`\r
3
- `:`
4
- `)+o,r=n+1,n=e.indexOf(`
5
- `,r)}while(n!==-1);return i+=e.slice(r),i}a(stringEncaseCRLFWithFirstIndex,"stringEncaseCRLFWithFirstIndex");const{stdout:stdoutColor,stderr:stderrColor}=supportsColor,GENERATOR=Symbol("GENERATOR"),STYLER=Symbol("STYLER"),IS_EMPTY=Symbol("IS_EMPTY"),levelMapping=["ansi","ansi","ansi256","ansi16m"],styles$2=Object.create(null),applyOptions=a((e,t={})=>{if(t.level&&!(Number.isInteger(t.level)&&t.level>=0&&t.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");const o=stdoutColor?stdoutColor.level:0;e.level=t.level===void 0?o:t.level},"applyOptions"),chalkFactory=a(e=>{const t=a((...o)=>o.join(" "),"chalk");return applyOptions(t,e),Object.setPrototypeOf(t,createChalk.prototype),t},"chalkFactory");function createChalk(e){return chalkFactory(e)}a(createChalk,"createChalk"),Object.setPrototypeOf(createChalk.prototype,Function.prototype);for(const[e,t]of Object.entries(ansiStyles))styles$2[e]={get(){const o=createBuilder(this,createStyler(t.open,t.close,this[STYLER]),this[IS_EMPTY]);return Object.defineProperty(this,e,{value:o}),o}};styles$2.visible={get(){const e=createBuilder(this,this[STYLER],!0);return Object.defineProperty(this,"visible",{value:e}),e}};const getModelAnsi=a((e,t,o,...n)=>e==="rgb"?t==="ansi16m"?ansiStyles[o].ansi16m(...n):t==="ansi256"?ansiStyles[o].ansi256(ansiStyles.rgbToAnsi256(...n)):ansiStyles[o].ansi(ansiStyles.rgbToAnsi(...n)):e==="hex"?getModelAnsi("rgb",t,o,...ansiStyles.hexToRgb(...n)):ansiStyles[o][e](...n),"getModelAnsi"),usedModels=["rgb","hex","ansi256"];for(const e of usedModels){styles$2[e]={get(){const{level:o}=this;return function(...n){const r=createStyler(getModelAnsi(e,levelMapping[o],"color",...n),ansiStyles.color.close,this[STYLER]);return createBuilder(this,r,this[IS_EMPTY])}}};const t="bg"+e[0].toUpperCase()+e.slice(1);styles$2[t]={get(){const{level:o}=this;return function(...n){const r=createStyler(getModelAnsi(e,levelMapping[o],"bgColor",...n),ansiStyles.bgColor.close,this[STYLER]);return createBuilder(this,r,this[IS_EMPTY])}}}}const proto=Object.defineProperties(()=>{},{...styles$2,level:{enumerable:!0,get(){return this[GENERATOR].level},set(e){this[GENERATOR].level=e}}}),createStyler=a((e,t,o)=>{let n,r;return o===void 0?(n=e,r=t):(n=o.openAll+e,r=t+o.closeAll),{open:e,close:t,openAll:n,closeAll:r,parent:o}},"createStyler"),createBuilder=a((e,t,o)=>{const n=a((...r)=>applyStyle(n,r.length===1?""+r[0]:r.join(" ")),"builder");return Object.setPrototypeOf(n,proto),n[GENERATOR]=e,n[STYLER]=t,n[IS_EMPTY]=o,n},"createBuilder"),applyStyle=a((e,t)=>{if(e.level<=0||!t)return e[IS_EMPTY]?"":t;let o=e[STYLER];if(o===void 0)return t;const{openAll:n,closeAll:r}=o;if(t.includes("\x1B"))for(;o!==void 0;)t=stringReplaceAll(t,o.close,o.open),o=o.parent;const i=t.indexOf(`
6
- `);return i!==-1&&(t=stringEncaseCRLFWithFirstIndex(t,r,n,i)),n+t+r},"applyStyle");Object.defineProperties(createChalk.prototype,styles$2);const chalk=createChalk();createChalk({level:stderrColor?stderrColor.level:0});function $constructor(e,t,o){function n(l,d){if(l._zod||Object.defineProperty(l,"_zod",{value:{def:d,constr:s,traits:new Set},enumerable:!1}),l._zod.traits.has(e))return;l._zod.traits.add(e),t(l,d);const h=s.prototype,f=Object.keys(h);for(let g=0;g<f.length;g++){const m=f[g];m in l||(l[m]=h[m].bind(l))}}a(n,"init");const r=o?.Parent??Object,c=class c extends r{};a(c,"Definition");let i=c;Object.defineProperty(i,"name",{value:e});function s(l){var d;const h=o?.Parent?new i:this;n(h,l),(d=h._zod).deferred??(d.deferred=[]);for(const f of h._zod.deferred)f();return h}return a(s,"_"),Object.defineProperty(s,"init",{value:n}),Object.defineProperty(s,Symbol.hasInstance,{value:a(l=>o?.Parent&&l instanceof o.Parent?!0:l?._zod?.traits?.has(e),"value")}),Object.defineProperty(s,"name",{value:e}),s}a($constructor,"$constructor");const M=class M extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}};a(M,"$ZodAsyncError");let $ZodAsyncError=M;const V=class V extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}};a(V,"$ZodEncodeError");let $ZodEncodeError=V;const globalConfig={};function config(e){return globalConfig}a(config,"config");function getEnumValues(e){const t=Object.values(e).filter(n=>typeof n=="number");return Object.entries(e).filter(([n,r])=>t.indexOf(+n)===-1).map(([n,r])=>r)}a(getEnumValues,"getEnumValues");function jsonStringifyReplacer(e,t){return typeof t=="bigint"?t.toString():t}a(jsonStringifyReplacer,"jsonStringifyReplacer");function cached(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}a(cached,"cached");function nullish(e){return e==null}a(nullish,"nullish");function cleanRegex(e){const t=e.startsWith("^")?1:0,o=e.endsWith("$")?e.length-1:e.length;return e.slice(t,o)}a(cleanRegex,"cleanRegex");function floatSafeRemainder(e,t){const o=(e.toString().split(".")[1]||"").length,n=t.toString();let r=(n.split(".")[1]||"").length;if(r===0&&/\d?e-\d?/.test(n)){const l=n.match(/\d?e-(\d?)/);l?.[1]&&(r=Number.parseInt(l[1]))}const i=o>r?o:r,s=Number.parseInt(e.toFixed(i).replace(".","")),c=Number.parseInt(t.toFixed(i).replace(".",""));return s%c/10**i}a(floatSafeRemainder,"floatSafeRemainder");const EVALUATING=Symbol("evaluating");function defineLazy(e,t,o){let n;Object.defineProperty(e,t,{get(){if(n!==EVALUATING)return n===void 0&&(n=EVALUATING,n=o()),n},set(r){Object.defineProperty(e,t,{value:r})},configurable:!0})}a(defineLazy,"defineLazy");function assignProp(e,t,o){Object.defineProperty(e,t,{value:o,writable:!0,enumerable:!0,configurable:!0})}a(assignProp,"assignProp");function mergeDefs(...e){const t={};for(const o of e){const n=Object.getOwnPropertyDescriptors(o);Object.assign(t,n)}return Object.defineProperties({},t)}a(mergeDefs,"mergeDefs");function esc(e){return JSON.stringify(e)}a(esc,"esc");function slugify(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}a(slugify,"slugify");const captureStackTrace="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function isObject(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}a(isObject,"isObject");const allowsEval=cached(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function isPlainObject(e){if(isObject(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const o=t.prototype;return!(isObject(o)===!1||Object.prototype.hasOwnProperty.call(o,"isPrototypeOf")===!1)}a(isPlainObject,"isPlainObject");function shallowClone(e){return isPlainObject(e)?{...e}:Array.isArray(e)?[...e]:e}a(shallowClone,"shallowClone");const propertyKeyTypes=new Set(["string","number","symbol"]);function escapeRegex(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}a(escapeRegex,"escapeRegex");function clone(e,t,o){const n=new e._zod.constr(t??e._zod.def);return(!t||o?.parent)&&(n._zod.parent=e),n}a(clone,"clone");function normalizeParams(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:a(()=>t,"error")};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:a(()=>t.error,"error")}:t}a(normalizeParams,"normalizeParams");function optionalKeys(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}a(optionalKeys,"optionalKeys");const NUMBER_FORMAT_RANGES={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function pick(e,t){const o=e._zod.def,n=o.checks;if(n&&n.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const i=mergeDefs(e._zod.def,{get shape(){const s={};for(const c in t){if(!(c in o.shape))throw new Error(`Unrecognized key: "${c}"`);t[c]&&(s[c]=o.shape[c])}return assignProp(this,"shape",s),s},checks:[]});return clone(e,i)}a(pick,"pick");function omit(e,t){const o=e._zod.def,n=o.checks;if(n&&n.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const i=mergeDefs(e._zod.def,{get shape(){const s={...e._zod.def.shape};for(const c in t){if(!(c in o.shape))throw new Error(`Unrecognized key: "${c}"`);t[c]&&delete s[c]}return assignProp(this,"shape",s),s},checks:[]});return clone(e,i)}a(omit,"omit");function extend(e,t){if(!isPlainObject(t))throw new Error("Invalid input to extend: expected a plain object");const o=e._zod.def.checks;if(o&&o.length>0){const i=e._zod.def.shape;for(const s in t)if(Object.getOwnPropertyDescriptor(i,s)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const r=mergeDefs(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t};return assignProp(this,"shape",i),i}});return clone(e,r)}a(extend,"extend");function safeExtend(e,t){if(!isPlainObject(t))throw new Error("Invalid input to safeExtend: expected a plain object");const o=mergeDefs(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return assignProp(this,"shape",n),n}});return clone(e,o)}a(safeExtend,"safeExtend");function merge(e,t){const o=mergeDefs(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t._zod.def.shape};return assignProp(this,"shape",n),n},get catchall(){return t._zod.def.catchall},checks:[]});return clone(e,o)}a(merge,"merge");function partial(e,t,o){const r=t._zod.def.checks;if(r&&r.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const s=mergeDefs(t._zod.def,{get shape(){const c=t._zod.def.shape,l={...c};if(o)for(const d in o){if(!(d in c))throw new Error(`Unrecognized key: "${d}"`);o[d]&&(l[d]=e?new e({type:"optional",innerType:c[d]}):c[d])}else for(const d in c)l[d]=e?new e({type:"optional",innerType:c[d]}):c[d];return assignProp(this,"shape",l),l},checks:[]});return clone(t,s)}a(partial,"partial");function required(e,t,o){const n=mergeDefs(t._zod.def,{get shape(){const r=t._zod.def.shape,i={...r};if(o)for(const s in o){if(!(s in i))throw new Error(`Unrecognized key: "${s}"`);o[s]&&(i[s]=new e({type:"nonoptional",innerType:r[s]}))}else for(const s in r)i[s]=new e({type:"nonoptional",innerType:r[s]});return assignProp(this,"shape",i),i}});return clone(t,n)}a(required,"required");function aborted(e,t=0){if(e.aborted===!0)return!0;for(let o=t;o<e.issues.length;o++)if(e.issues[o]?.continue!==!0)return!0;return!1}a(aborted,"aborted");function prefixIssues(e,t){return t.map(o=>{var n;return(n=o).path??(n.path=[]),o.path.unshift(e),o})}a(prefixIssues,"prefixIssues");function unwrapMessage(e){return typeof e=="string"?e:e?.message}a(unwrapMessage,"unwrapMessage");function finalizeIssue(e,t,o){const n={...e,path:e.path??[]};if(!e.message){const r=unwrapMessage(e.inst?._zod.def?.error?.(e))??unwrapMessage(t?.error?.(e))??unwrapMessage(o.customError?.(e))??unwrapMessage(o.localeError?.(e))??"Invalid input";n.message=r}return delete n.inst,delete n.continue,t?.reportInput||delete n.input,n}a(finalizeIssue,"finalizeIssue");function getLengthableOrigin(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}a(getLengthableOrigin,"getLengthableOrigin");function issue(...e){const[t,o,n]=e;return typeof t=="string"?{message:t,code:"custom",input:o,inst:n}:{...t}}a(issue,"issue");const initializer$1=a((e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,jsonStringifyReplacer,2),Object.defineProperty(e,"toString",{value:a(()=>e.message,"value"),enumerable:!1})},"initializer$1"),$ZodError=$constructor("$ZodError",initializer$1),$ZodRealError=$constructor("$ZodError",initializer$1,{Parent:Error});function flattenError(e,t=o=>o.message){const o={},n=[];for(const r of e.issues)r.path.length>0?(o[r.path[0]]=o[r.path[0]]||[],o[r.path[0]].push(t(r))):n.push(t(r));return{formErrors:n,fieldErrors:o}}a(flattenError,"flattenError");function formatError(e,t=o=>o.message){const o={_errors:[]},n=a(r=>{for(const i of r.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(s=>n({issues:s}));else if(i.code==="invalid_key")n({issues:i.issues});else if(i.code==="invalid_element")n({issues:i.issues});else if(i.path.length===0)o._errors.push(t(i));else{let s=o,c=0;for(;c<i.path.length;){const l=i.path[c];c===i.path.length-1?(s[l]=s[l]||{_errors:[]},s[l]._errors.push(t(i))):s[l]=s[l]||{_errors:[]},s=s[l],c++}}},"processError");return n(e),o}a(formatError,"formatError");const _parse=a(e=>(t,o,n,r)=>{const i=n?Object.assign(n,{async:!1}):{async:!1},s=t._zod.run({value:o,issues:[]},i);if(s instanceof Promise)throw new $ZodAsyncError;if(s.issues.length){const c=new(r?.Err??e)(s.issues.map(l=>finalizeIssue(l,i,config())));throw captureStackTrace(c,r?.callee),c}return s.value},"_parse"),_parseAsync=a(e=>async(t,o,n,r)=>{const i=n?Object.assign(n,{async:!0}):{async:!0};let s=t._zod.run({value:o,issues:[]},i);if(s instanceof Promise&&(s=await s),s.issues.length){const c=new(r?.Err??e)(s.issues.map(l=>finalizeIssue(l,i,config())));throw captureStackTrace(c,r?.callee),c}return s.value},"_parseAsync"),_safeParse=a(e=>(t,o,n)=>{const r=n?{...n,async:!1}:{async:!1},i=t._zod.run({value:o,issues:[]},r);if(i instanceof Promise)throw new $ZodAsyncError;return i.issues.length?{success:!1,error:new(e??$ZodError)(i.issues.map(s=>finalizeIssue(s,r,config())))}:{success:!0,data:i.value}},"_safeParse"),safeParse$1=_safeParse($ZodRealError),_safeParseAsync=a(e=>async(t,o,n)=>{const r=n?Object.assign(n,{async:!0}):{async:!0};let i=t._zod.run({value:o,issues:[]},r);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(s=>finalizeIssue(s,r,config())))}:{success:!0,data:i.value}},"_safeParseAsync"),safeParseAsync$1=_safeParseAsync($ZodRealError),_encode=a(e=>(t,o,n)=>{const r=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return _parse(e)(t,o,r)},"_encode"),_decode=a(e=>(t,o,n)=>_parse(e)(t,o,n),"_decode"),_encodeAsync=a(e=>async(t,o,n)=>{const r=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return _parseAsync(e)(t,o,r)},"_encodeAsync"),_decodeAsync=a(e=>async(t,o,n)=>_parseAsync(e)(t,o,n),"_decodeAsync"),_safeEncode=a(e=>(t,o,n)=>{const r=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return _safeParse(e)(t,o,r)},"_safeEncode"),_safeDecode=a(e=>(t,o,n)=>_safeParse(e)(t,o,n),"_safeDecode"),_safeEncodeAsync=a(e=>async(t,o,n)=>{const r=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return _safeParseAsync(e)(t,o,r)},"_safeEncodeAsync"),_safeDecodeAsync=a(e=>async(t,o,n)=>_safeParseAsync(e)(t,o,n),"_safeDecodeAsync"),cuid=/^[cC][^\s-]{8,}$/,cuid2=/^[0-9a-z]+$/,ulid=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,xid=/^[0-9a-vA-V]{20}$/,ksuid=/^[A-Za-z0-9]{27}$/,nanoid=/^[a-zA-Z0-9_-]{21}$/,duration$1=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,guid=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,uuid=a(e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,"uuid"),email=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,_emoji$1="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function emoji(){return new RegExp(_emoji$1,"u")}a(emoji,"emoji");const ipv4=/^(?:(?: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])$/,ipv6=/^(([0-9a-fA-F]{1,4}:){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}|:))$/,cidrv4=/^((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])\/([0-9]|[1-2][0-9]|3[0-2])$/,cidrv6=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,base64url=/^[A-Za-z0-9_-]*$/,e164=/^\+[1-9]\d{6,14}$/,dateSource="(?:(?:\\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])))",date$1=new RegExp(`^${dateSource}$`);function timeSource(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}a(timeSource,"timeSource");function time$1(e){return new RegExp(`^${timeSource(e)}$`)}a(time$1,"time$1");function datetime$1(e){const t=timeSource({precision:e.precision}),o=["Z"];e.local&&o.push(""),e.offset&&o.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const n=`${t}(?:${o.join("|")})`;return new RegExp(`^${dateSource}T(?:${n})$`)}a(datetime$1,"datetime$1");const string$1=a(e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},"string$1"),integer=/^-?\d+$/,number$1=/^-?\d+(?:\.\d+)?$/,boolean$1=/^(?:true|false)$/i,lowercase=/^[^A-Z]*$/,uppercase=/^[^a-z]*$/,$ZodCheck=$constructor("$ZodCheck",(e,t)=>{var o;e._zod??(e._zod={}),e._zod.def=t,(o=e._zod).onattach??(o.onattach=[])}),numericOriginMap={number:"number",bigint:"bigint",object:"date"},$ZodCheckLessThan=$constructor("$ZodCheckLessThan",(e,t)=>{$ZodCheck.init(e,t);const o=numericOriginMap[typeof t.value];e._zod.onattach.push(n=>{const r=n._zod.bag,i=(t.inclusive?r.maximum:r.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<i&&(t.inclusive?r.maximum=t.value:r.exclusiveMaximum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value<=t.value:n.value<t.value)||n.issues.push({origin:o,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),$ZodCheckGreaterThan=$constructor("$ZodCheckGreaterThan",(e,t)=>{$ZodCheck.init(e,t);const o=numericOriginMap[typeof t.value];e._zod.onattach.push(n=>{const r=n._zod.bag,i=(t.inclusive?r.minimum:r.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>i&&(t.inclusive?r.minimum=t.value:r.exclusiveMinimum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:o,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),$ZodCheckMultipleOf=$constructor("$ZodCheckMultipleOf",(e,t)=>{$ZodCheck.init(e,t),e._zod.onattach.push(o=>{var n;(n=o._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=o=>{if(typeof o.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof o.value=="bigint"?o.value%t.value===BigInt(0):floatSafeRemainder(o.value,t.value)===0)||o.issues.push({origin:typeof o.value,code:"not_multiple_of",divisor:t.value,input:o.value,inst:e,continue:!t.abort})}}),$ZodCheckNumberFormat=$constructor("$ZodCheckNumberFormat",(e,t)=>{$ZodCheck.init(e,t),t.format=t.format||"float64";const o=t.format?.includes("int"),n=o?"int":"number",[r,i]=NUMBER_FORMAT_RANGES[t.format];e._zod.onattach.push(s=>{const c=s._zod.bag;c.format=t.format,c.minimum=r,c.maximum=i,o&&(c.pattern=integer)}),e._zod.check=s=>{const c=s.value;if(o){if(!Number.isInteger(c)){s.issues.push({expected:n,format:t.format,code:"invalid_type",continue:!1,input:c,inst:e});return}if(!Number.isSafeInteger(c)){c>0?s.issues.push({input:c,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort}):s.issues.push({input:c,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort});return}}c<r&&s.issues.push({origin:"number",input:c,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort}),c>i&&s.issues.push({origin:"number",input:c,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}}),$ZodCheckMaxLength=$constructor("$ZodCheckMaxLength",(e,t)=>{var o;$ZodCheck.init(e,t),(o=e._zod.def).when??(o.when=n=>{const r=n.value;return!nullish(r)&&r.length!==void 0}),e._zod.onattach.push(n=>{const r=n._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<r&&(n._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{const r=n.value;if(r.length<=t.maximum)return;const s=getLengthableOrigin(r);n.issues.push({origin:s,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),$ZodCheckMinLength=$constructor("$ZodCheckMinLength",(e,t)=>{var o;$ZodCheck.init(e,t),(o=e._zod.def).when??(o.when=n=>{const r=n.value;return!nullish(r)&&r.length!==void 0}),e._zod.onattach.push(n=>{const r=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>r&&(n._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{const r=n.value;if(r.length>=t.minimum)return;const s=getLengthableOrigin(r);n.issues.push({origin:s,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),$ZodCheckLengthEquals=$constructor("$ZodCheckLengthEquals",(e,t)=>{var o;$ZodCheck.init(e,t),(o=e._zod.def).when??(o.when=n=>{const r=n.value;return!nullish(r)&&r.length!==void 0}),e._zod.onattach.push(n=>{const r=n._zod.bag;r.minimum=t.length,r.maximum=t.length,r.length=t.length}),e._zod.check=n=>{const r=n.value,i=r.length;if(i===t.length)return;const s=getLengthableOrigin(r),c=i>t.length;n.issues.push({origin:s,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),$ZodCheckStringFormat=$constructor("$ZodCheckStringFormat",(e,t)=>{var o,n;$ZodCheck.init(e,t),e._zod.onattach.push(r=>{const i=r._zod.bag;i.format=t.format,t.pattern&&(i.patterns??(i.patterns=new Set),i.patterns.add(t.pattern))}),t.pattern?(o=e._zod).check??(o.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:t.format,input:r.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),$ZodCheckRegex=$constructor("$ZodCheckRegex",(e,t)=>{$ZodCheckStringFormat.init(e,t),e._zod.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:"regex",input:o.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),$ZodCheckLowerCase=$constructor("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=lowercase),$ZodCheckStringFormat.init(e,t)}),$ZodCheckUpperCase=$constructor("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=uppercase),$ZodCheckStringFormat.init(e,t)}),$ZodCheckIncludes=$constructor("$ZodCheckIncludes",(e,t)=>{$ZodCheck.init(e,t);const o=escapeRegex(t.includes),n=new RegExp(typeof t.position=="number"?`^.{${t.position}}${o}`:o);t.pattern=n,e._zod.onattach.push(r=>{const i=r._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(n)}),e._zod.check=r=>{r.value.includes(t.includes,t.position)||r.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:r.value,inst:e,continue:!t.abort})}}),$ZodCheckStartsWith=$constructor("$ZodCheckStartsWith",(e,t)=>{$ZodCheck.init(e,t);const o=new RegExp(`^${escapeRegex(t.prefix)}.*`);t.pattern??(t.pattern=o),e._zod.onattach.push(n=>{const r=n._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(o)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),$ZodCheckEndsWith=$constructor("$ZodCheckEndsWith",(e,t)=>{$ZodCheck.init(e,t);const o=new RegExp(`.*${escapeRegex(t.suffix)}$`);t.pattern??(t.pattern=o),e._zod.onattach.push(n=>{const r=n._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(o)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),$ZodCheckOverwrite=$constructor("$ZodCheckOverwrite",(e,t)=>{$ZodCheck.init(e,t),e._zod.check=o=>{o.value=t.tx(o.value)}}),Ue=class Ue{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const n=t.split(`
1
+ var $t=Object.defineProperty;var xt=L=>{throw TypeError(L)};var qt=(L,M,V)=>M in L?$t(L,M,{enumerable:!0,configurable:!0,writable:!0,value:V}):L[M]=V;var a=(L,M)=>$t(L,"name",{value:M,configurable:!0});var ne=(L,M,V)=>qt(L,typeof M!="symbol"?M+"":M,V),mt=(L,M,V)=>M.has(L)||xt("Cannot "+V);var p=(L,M,V)=>(mt(L,M,"read from private field"),V?V.call(L):M.get(L)),Z=(L,M,V)=>M.has(L)?xt("Cannot add the same private member more than once"):M instanceof WeakSet?M.add(L):M.set(L,V),T=(L,M,V,Ue)=>(mt(L,M,"write to private field"),Ue?Ue.call(L,V):M.set(L,V),V),b=(L,M,V)=>(mt(L,M,"access private method"),V);(function(){"use strict";var je,Pe,ie,Oe,Q,C,St,Ae,De,_t,Tt,It,zt,At,Pt,st,re,Be,ae,ye,Re,be,Ce,we,W,Ze,Ee,j,$e,ve,Ne,ee,We,He,Je,Ye,qe,_,Ot,Rt,Ct,Zt,yt,Nt,Lt,Mt,tt,bt,Dt,Ft,Ut,wt,ot,it,jt,Bt,Wt,Vt,Fe,vt,kt,Gt,Ht,Jt,Y,ce,le,xe,Se,Le,Yt,Et;var __vite_style__=document.createElement("style");__vite_style__.textContent=`._wrapper_gtdpc_1{position:fixed;bottom:100px;left:50%;transform:translate(-50%) translateY(20px);opacity:0;z-index:2147483642;box-sizing:border-box;overflow:visible;--width: 360px;--height: 40px;--border-radius: 12px;--side-space: 12px;--history-width: calc(var(--width) - var(--side-space) * 2);--color-1: rgb(57, 182, 255);--color-2: rgb(189, 69, 251);--color-3: rgb(255, 87, 51);--color-4: rgb(255, 214, 0);width:var(--width);height:var(--height);transition:all .3s ease-in-out}._wrapper_gtdpc_1 *{box-sizing:border-box}@media(max-width:480px){._wrapper_gtdpc_1{width:calc(100vw - 40px);--width: calc(100vw - 40px) }}._wrapper_gtdpc_1 ._background_gtdpc_39{position:absolute;inset:-2px -8px;border-radius:calc(var(--border-radius) + 4px);filter:blur(16px);overflow:hidden}._wrapper_gtdpc_1 ._background_gtdpc_39:before{content:"";z-index:-1;pointer-events:none;position:absolute;width:100%;height:100%;left:0;top:0;background-image:linear-gradient(to bottom left,var(--color-1),var(--color-2),var(--color-1));animation:_mask-running_gtdpc_1 2s linear infinite}._wrapper_gtdpc_1 ._background_gtdpc_39:after{content:"";z-index:-1;pointer-events:none;position:absolute;width:100%;height:100%;left:0;top:0;background-image:linear-gradient(to bottom left,var(--color-2),var(--color-1),var(--color-2));animation:_mask-running_gtdpc_1 2s linear infinite;animation-delay:1s}@keyframes _mask-running_gtdpc_1{0%{transform:translate(-100%)}to{transform:translate(100%)}}._header_gtdpc_99{display:flex;align-items:center;justify-content:space-between;padding:8px 12px;-webkit-user-select:none;user-select:none;position:absolute;inset:0;cursor:pointer;flex-shrink:0;background:#00000080;-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);border-radius:var(--border-radius);background-clip:padding-box;box-shadow:0 0 0 2px #fff6,0 0 5px 1px #ffffff4d}._header_gtdpc_99 ._statusSection_gtdpc_121{display:flex;align-items:center;gap:8px;flex:1;min-height:24px}._header_gtdpc_99 ._statusSection_gtdpc_121 ._indicator_gtdpc_128{width:6px;height:6px;border-radius:50%;background:#ffffff80;flex-shrink:0;animation:none}._header_gtdpc_99 ._statusSection_gtdpc_121 ._indicator_gtdpc_128._thinking_gtdpc_137{background:#39b6ff;animation:_pulse_gtdpc_1 .8s ease-in-out infinite}._header_gtdpc_99 ._statusSection_gtdpc_121 ._indicator_gtdpc_128._tool_executing_gtdpc_142{background:#bd45fb;animation:_pulse_gtdpc_1 .6s ease-in-out infinite}._header_gtdpc_99 ._statusSection_gtdpc_121 ._indicator_gtdpc_128._retry_gtdpc_147{background:#ffd600;animation:_retryPulse_gtdpc_1 1s ease-in-out infinite}._header_gtdpc_99 ._statusSection_gtdpc_121 ._indicator_gtdpc_128._completed_gtdpc_153,._header_gtdpc_99 ._statusSection_gtdpc_121 ._indicator_gtdpc_128._input_gtdpc_154,._header_gtdpc_99 ._statusSection_gtdpc_121 ._indicator_gtdpc_128._output_gtdpc_155{background:#22c55e;animation:none}._header_gtdpc_99 ._statusSection_gtdpc_121 ._indicator_gtdpc_128._error_gtdpc_160{background:#ef4444;animation:none}._header_gtdpc_99 ._statusSection_gtdpc_121 ._statusText_gtdpc_166{color:#fff;font-size:12px;line-height:1;font-weight:500;transition:all .3s ease-in-out;position:relative;overflow:hidden;display:flex;align-items:center;min-height:24px}._header_gtdpc_99 ._statusSection_gtdpc_121 ._statusText_gtdpc_166._fadeOut_gtdpc_178{animation:_statusTextFadeOut_gtdpc_1 .3s ease forwards}._header_gtdpc_99 ._statusSection_gtdpc_121 ._statusText_gtdpc_166._fadeIn_gtdpc_182{animation:_statusTextFadeIn_gtdpc_1 .3s ease forwards}._header_gtdpc_99 ._controls_gtdpc_188{display:flex;align-items:center;gap:4px}._header_gtdpc_99 ._controls_gtdpc_188 ._controlButton_gtdpc_193{width:24px;height:24px;border:none;border-radius:4px;background:#ffffff1a;color:#fff;cursor:pointer;display:flex;align-items:center;justify-content:center;font-size:12px;line-height:1}._header_gtdpc_99 ._controls_gtdpc_188 ._controlButton_gtdpc_193:hover{background:#fff3}._header_gtdpc_99 ._controls_gtdpc_188 ._stopButton_gtdpc_212{background:#ef444433;color:#ff2929;font-weight:600}._header_gtdpc_99 ._controls_gtdpc_188 ._stopButton_gtdpc_212:hover{background:#ef44444d}@keyframes _statusTextFadeIn_gtdpc_1{0%{opacity:0;transform:translateY(5px)}to{opacity:1;transform:translateY(0)}}@keyframes _statusTextFadeOut_gtdpc_1{0%{opacity:1;transform:translateY(0)}to{opacity:0;transform:translateY(-5px)}}._historySectionWrapper_gtdpc_246{position:absolute;width:var(--history-width);bottom:var(--height);left:var(--side-space);z-index:-2;padding-top:0;visibility:collapse;overflow:hidden;transition:all .2s;background:#02001480;-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);text-shadow:0 0 1px rgba(0,0,0,.2);border-top-left-radius:calc(var(--border-radius) + 4px);border-top-right-radius:calc(var(--border-radius) + 4px);border:2px solid rgba(255,255,255,.4);box-shadow:0 4px 16px #0009}._expanded_gtdpc_278 ._historySectionWrapper_gtdpc_246{padding-top:8px;visibility:visible}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246{position:relative;overflow-y:auto;overscroll-behavior:contain;scrollbar-width:none;max-height:0;padding-inline:8px;transition:max-height .2s}._expanded_gtdpc_278 :is(._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246){max-height:400px}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297{padding:8px 10px;margin-bottom:6px;background:linear-gradient(135deg,#ffffff14,#ffffff08);border-radius:8px;border-left:2px solid rgba(57,182,255,.5);font-size:12px;color:#fff;line-height:1.3;position:relative;overflow:hidden;box-shadow:inset 0 1px #ffffff1a,0 1px 3px #0000001a}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297:before{content:"";position:absolute;top:0;left:0;right:0;height:1px;background:linear-gradient(90deg,transparent,rgba(255,255,255,.2),transparent)}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297:hover{background:linear-gradient(135deg,#ffffff1f,#ffffff0f);box-shadow:inset 0 1px #ffffff26,0 2px 4px #00000026}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297:last-child{margin-bottom:10px}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297._completed_gtdpc_153,._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297._input_gtdpc_154,._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297._output_gtdpc_155{border-left-color:#22c55e;background:linear-gradient(135deg,#22c55e1a,#22c55e0d)}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297._error_gtdpc_160{border-left-color:#ef4444;background:linear-gradient(135deg,#ef44441a,#ef44440d)}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297._retry_gtdpc_147{border-left-color:#ffd600;background:linear-gradient(135deg,#ffd6001a,#ffd6000d)}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297._observation_gtdpc_355{border-left-color:#9333ea;background:linear-gradient(135deg,#9333ea1a,#9333ea0d)}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297._question_gtdpc_360{border-left-color:#ff9f43;background:linear-gradient(135deg,#ff9f4326,#ff9f4314)}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297._doneSuccess_gtdpc_366{background:linear-gradient(135deg,#22c55e40,#22c55e26,#22c55e14);border:none;border-left:4px solid rgb(34,197,94);box-shadow:0 4px 12px #22c55e4d,inset 0 1px #fff3,0 0 20px #22c55e1a;font-weight:600;color:#dcfce7;padding:10px 12px;margin-bottom:8px;border-radius:8px;position:relative;overflow:hidden}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297._doneSuccess_gtdpc_366:before{background:linear-gradient(90deg,transparent,rgba(34,197,94,.4),transparent)}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297._doneSuccess_gtdpc_366:after{content:"";position:absolute;top:0;left:-100%;width:100%;height:100%;background:linear-gradient(90deg,transparent,rgba(255,255,255,.1),transparent);animation:_shimmer_gtdpc_1 2s ease-in-out infinite}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297._doneSuccess_gtdpc_366 ._historyContent_gtdpc_402 ._statusIcon_gtdpc_403{font-size:16px;animation:_celebrate_gtdpc_1 .8s ease-in-out;filter:drop-shadow(0 2px 4px rgba(34,197,94,.5))}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297._doneError_gtdpc_412{background:linear-gradient(135deg,#ef444440,#ef444426,#ef444414);border:none;border-left:4px solid rgb(239,68,68);box-shadow:0 4px 12px #ef44444d,inset 0 1px #fff3,0 0 20px #ef44441a;font-weight:600;color:#fee2e2;padding:10px 12px;margin-bottom:8px;border-radius:8px;position:relative;overflow:hidden}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297._doneError_gtdpc_412:before{background:linear-gradient(90deg,transparent,rgba(239,68,68,.4),transparent)}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297._doneError_gtdpc_412 ._historyContent_gtdpc_402 ._statusIcon_gtdpc_403{font-size:16px;filter:drop-shadow(0 2px 4px rgba(239,68,68,.5))}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297 ._historyContent_gtdpc_402{display:flex;align-items:flex-start;gap:8px;word-break:break-all;white-space:pre-wrap}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297 ._historyContent_gtdpc_402 ._statusIcon_gtdpc_403{font-size:12px;flex-shrink:0;line-height:1;transition:all .3s ease}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297 ._historyContent_gtdpc_402 ._reflectionLines_gtdpc_462{display:flex;flex-direction:column;gap:4px}._historySectionWrapper_gtdpc_246 ._historySection_gtdpc_246 ._historyItem_gtdpc_297 ._historyMeta_gtdpc_469{font-size:10px;color:#fff9;margin-top:8px;line-height:1}@keyframes _pulse_gtdpc_1{0%,to{opacity:1;transform:scale(1)}50%{opacity:.4;transform:scale(1.3)}}@keyframes _retryPulse_gtdpc_1{0%,to{opacity:1;transform:scale(1) rotate(0)}25%{opacity:.6;transform:scale(1.2) rotate(90deg)}50%{opacity:.8;transform:scale(1.1) rotate(180deg)}75%{opacity:.6;transform:scale(1.2) rotate(270deg)}}@keyframes _celebrate_gtdpc_1{0%,to{transform:scale(1)}25%{transform:scale(1.2) rotate(-5deg)}75%{transform:scale(1.2) rotate(5deg)}}@keyframes _shimmer_gtdpc_1{0%{left:-100%}to{left:100%}}._inputSectionWrapper_gtdpc_539{position:absolute;width:var(--history-width);top:var(--height);left:var(--side-space);z-index:-1;visibility:visible;overflow:hidden;height:48px;transition:all .2s;background:#bababa33;-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);border-bottom-left-radius:calc(var(--border-radius) + 4px);border-bottom-right-radius:calc(var(--border-radius) + 4px);border:2px solid rgba(255,255,255,.3);box-shadow:0 1px 16px #0006}._inputSectionWrapper_gtdpc_539._hidden_gtdpc_562{visibility:collapse;height:0}._inputSectionWrapper_gtdpc_539 ._inputSection_gtdpc_539{display:flex;align-items:center;gap:4px;padding:8px}._inputSectionWrapper_gtdpc_539 ._inputSection_gtdpc_539 ._taskInput_gtdpc_573{flex:1;background:#fff6;border:1px solid rgba(255,255,255,.3);border-radius:10px;padding-inline:10px;color:#141414;font-size:12px;height:28px;line-height:1;outline:none;transition:all .2s ease}._inputSectionWrapper_gtdpc_539 ._inputSection_gtdpc_539 ._taskInput_gtdpc_573::placeholder{color:#353535}._inputSectionWrapper_gtdpc_539 ._inputSection_gtdpc_539 ._taskInput_gtdpc_573:focus{background:#fffc;border-color:#39b6ff99;box-shadow:0 0 0 2px #39b6ff33}._wrapper_gf8tz_1{position:fixed;inset:0;z-index:2147483641;cursor:wait;overflow:hidden;display:none}._cursor_1dgwb_2{position:absolute;width:var(--cursor-size, 75px);height:var(--cursor-size, 75px);pointer-events:none;z-index:10000}._cursorBorder_1dgwb_10{position:absolute;width:100%;height:100%;background:linear-gradient(45deg,#39b6ff,#bd45fb);-webkit-mask-image:url("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20100%20100'%20fill='none'%3e%3cg%3e%3cpath%20d='M%2015%2042%20L%2015%2036.99%20Q%2015%2031.99%2023.7%2031.99%20L%2028.05%2031.99%20Q%2032.41%2031.99%2032.41%2021.99%20L%2032.41%2017%20Q%2032.41%2012%2041.09%2016.95%20L%2076.31%2037.05%20Q%2085%2042%2076.31%2046.95%20L%2041.09%2067.05%20Q%2032.41%2072%2032.41%2062.01%20L%2032.41%2057.01%20Q%2032.41%2052.01%2023.7%2052.01%20L%2019.35%2052.01%20Q%2015%2052.01%2015%2047.01%20Z'%20fill='none'%20stroke='%23000000'%20stroke-width='6'%20stroke-miterlimit='10'%20style='stroke:%20light-dark(rgb(0,%200,%200),%20rgb(255,%20255,%20255));'/%3e%3c/g%3e%3c/svg%3e");mask-image:url("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20100%20100'%20fill='none'%3e%3cg%3e%3cpath%20d='M%2015%2042%20L%2015%2036.99%20Q%2015%2031.99%2023.7%2031.99%20L%2028.05%2031.99%20Q%2032.41%2031.99%2032.41%2021.99%20L%2032.41%2017%20Q%2032.41%2012%2041.09%2016.95%20L%2076.31%2037.05%20Q%2085%2042%2076.31%2046.95%20L%2041.09%2067.05%20Q%2032.41%2072%2032.41%2062.01%20L%2032.41%2057.01%20Q%2032.41%2052.01%2023.7%2052.01%20L%2019.35%2052.01%20Q%2015%2052.01%2015%2047.01%20Z'%20fill='none'%20stroke='%23000000'%20stroke-width='6'%20stroke-miterlimit='10'%20style='stroke:%20light-dark(rgb(0,%200,%200),%20rgb(255,%20255,%20255));'/%3e%3c/g%3e%3c/svg%3e");-webkit-mask-size:100% 100%;mask-size:100% 100%;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;transform-origin:center;transform:rotate(-135deg) scale(1.2);margin-left:-10px;margin-top:-18px}._cursorFilling_1dgwb_25{position:absolute;width:100%;height:100%;background:url("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20100%20100'%3e%3cdefs%3e%3c/defs%3e%3cg%20xmlns='http://www.w3.org/2000/svg'%20style='filter:%20drop-shadow(light-dark(rgba(0,%200,%200,%200.4),%20rgba(237,%20237,%20237,%200.4))%203px%204px%204px);'%3e%3cpath%20d='M%2015%2042%20L%2015%2036.99%20Q%2015%2031.99%2023.7%2031.99%20L%2028.05%2031.99%20Q%2032.41%2031.99%2032.41%2021.99%20L%2032.41%2017%20Q%2032.41%2012%2041.09%2016.95%20L%2076.31%2037.05%20Q%2085%2042%2076.31%2046.95%20L%2041.09%2067.05%20Q%2032.41%2072%2032.41%2062.01%20L%2032.41%2057.01%20Q%2032.41%2052.01%2023.7%2052.01%20L%2019.35%2052.01%20Q%2015%2052.01%2015%2047.01%20Z'%20fill='%23ffffff'%20stroke='none'%20style='fill:%20%23ffffff;'/%3e%3c/g%3e%3c/svg%3e");background-size:100% 100%;background-repeat:no-repeat;transform-origin:center;transform:rotate(-135deg) scale(1.2);margin-left:-10px;margin-top:-18px}._cursorRipple_1dgwb_39{position:absolute;width:100%;height:100%;pointer-events:none;margin-left:-50%;margin-top:-50%}._cursorRipple_1dgwb_39:after{content:"";opacity:0;position:absolute;inset:0;border:4px solid rgba(57,182,255,1);border-radius:50%}._cursor_1dgwb_2._clicking_1dgwb_57 ._cursorRipple_1dgwb_39:after{animation:_cursor-ripple_1dgwb_1 .3s ease-out forwards}@keyframes _cursor-ripple_1dgwb_1{0%{transform:scale(0);opacity:1}to{transform:scale(2);opacity:0}}
2
+ /*$vite$:1*/`,document.head.appendChild(__vite_style__);function $constructor(e,t,o){function n(l,d){if(l._zod||Object.defineProperty(l,"_zod",{value:{def:d,constr:s,traits:new Set},enumerable:!1}),l._zod.traits.has(e))return;l._zod.traits.add(e),t(l,d);const h=s.prototype,f=Object.keys(h);for(let g=0;g<f.length;g++){const m=f[g];m in l||(l[m]=h[m].bind(l))}}a(n,"init");const r=o?.Parent??Object,c=class c extends r{};a(c,"Definition");let i=c;Object.defineProperty(i,"name",{value:e});function s(l){var d;const h=o?.Parent?new i:this;n(h,l),(d=h._zod).deferred??(d.deferred=[]);for(const f of h._zod.deferred)f();return h}return a(s,"_"),Object.defineProperty(s,"init",{value:n}),Object.defineProperty(s,Symbol.hasInstance,{value:a(l=>o?.Parent&&l instanceof o.Parent?!0:l?._zod?.traits?.has(e),"value")}),Object.defineProperty(s,"name",{value:e}),s}a($constructor,"$constructor");const L=class L extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}};a(L,"$ZodAsyncError");let $ZodAsyncError=L;const M=class M extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}};a(M,"$ZodEncodeError");let $ZodEncodeError=M;const globalConfig={};function config(e){return globalConfig}a(config,"config");function getEnumValues(e){const t=Object.values(e).filter(n=>typeof n=="number");return Object.entries(e).filter(([n,r])=>t.indexOf(+n)===-1).map(([n,r])=>r)}a(getEnumValues,"getEnumValues");function jsonStringifyReplacer(e,t){return typeof t=="bigint"?t.toString():t}a(jsonStringifyReplacer,"jsonStringifyReplacer");function cached(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}a(cached,"cached");function nullish(e){return e==null}a(nullish,"nullish");function cleanRegex(e){const t=e.startsWith("^")?1:0,o=e.endsWith("$")?e.length-1:e.length;return e.slice(t,o)}a(cleanRegex,"cleanRegex");function floatSafeRemainder(e,t){const o=(e.toString().split(".")[1]||"").length,n=t.toString();let r=(n.split(".")[1]||"").length;if(r===0&&/\d?e-\d?/.test(n)){const l=n.match(/\d?e-(\d?)/);l?.[1]&&(r=Number.parseInt(l[1]))}const i=o>r?o:r,s=Number.parseInt(e.toFixed(i).replace(".","")),c=Number.parseInt(t.toFixed(i).replace(".",""));return s%c/10**i}a(floatSafeRemainder,"floatSafeRemainder");const EVALUATING=Symbol("evaluating");function defineLazy(e,t,o){let n;Object.defineProperty(e,t,{get(){if(n!==EVALUATING)return n===void 0&&(n=EVALUATING,n=o()),n},set(r){Object.defineProperty(e,t,{value:r})},configurable:!0})}a(defineLazy,"defineLazy");function assignProp(e,t,o){Object.defineProperty(e,t,{value:o,writable:!0,enumerable:!0,configurable:!0})}a(assignProp,"assignProp");function mergeDefs(...e){const t={};for(const o of e){const n=Object.getOwnPropertyDescriptors(o);Object.assign(t,n)}return Object.defineProperties({},t)}a(mergeDefs,"mergeDefs");function esc(e){return JSON.stringify(e)}a(esc,"esc");function slugify(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}a(slugify,"slugify");const captureStackTrace="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function isObject(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}a(isObject,"isObject");const allowsEval=cached(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function isPlainObject(e){if(isObject(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const o=t.prototype;return!(isObject(o)===!1||Object.prototype.hasOwnProperty.call(o,"isPrototypeOf")===!1)}a(isPlainObject,"isPlainObject");function shallowClone(e){return isPlainObject(e)?{...e}:Array.isArray(e)?[...e]:e}a(shallowClone,"shallowClone");const propertyKeyTypes=new Set(["string","number","symbol"]);function escapeRegex(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}a(escapeRegex,"escapeRegex");function clone(e,t,o){const n=new e._zod.constr(t??e._zod.def);return(!t||o?.parent)&&(n._zod.parent=e),n}a(clone,"clone");function normalizeParams(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:a(()=>t,"error")};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:a(()=>t.error,"error")}:t}a(normalizeParams,"normalizeParams");function optionalKeys(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}a(optionalKeys,"optionalKeys");const NUMBER_FORMAT_RANGES={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function pick(e,t){const o=e._zod.def,n=o.checks;if(n&&n.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const i=mergeDefs(e._zod.def,{get shape(){const s={};for(const c in t){if(!(c in o.shape))throw new Error(`Unrecognized key: "${c}"`);t[c]&&(s[c]=o.shape[c])}return assignProp(this,"shape",s),s},checks:[]});return clone(e,i)}a(pick,"pick");function omit(e,t){const o=e._zod.def,n=o.checks;if(n&&n.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const i=mergeDefs(e._zod.def,{get shape(){const s={...e._zod.def.shape};for(const c in t){if(!(c in o.shape))throw new Error(`Unrecognized key: "${c}"`);t[c]&&delete s[c]}return assignProp(this,"shape",s),s},checks:[]});return clone(e,i)}a(omit,"omit");function extend(e,t){if(!isPlainObject(t))throw new Error("Invalid input to extend: expected a plain object");const o=e._zod.def.checks;if(o&&o.length>0){const i=e._zod.def.shape;for(const s in t)if(Object.getOwnPropertyDescriptor(i,s)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const r=mergeDefs(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t};return assignProp(this,"shape",i),i}});return clone(e,r)}a(extend,"extend");function safeExtend(e,t){if(!isPlainObject(t))throw new Error("Invalid input to safeExtend: expected a plain object");const o=mergeDefs(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return assignProp(this,"shape",n),n}});return clone(e,o)}a(safeExtend,"safeExtend");function merge(e,t){const o=mergeDefs(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t._zod.def.shape};return assignProp(this,"shape",n),n},get catchall(){return t._zod.def.catchall},checks:[]});return clone(e,o)}a(merge,"merge");function partial(e,t,o){const r=t._zod.def.checks;if(r&&r.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const s=mergeDefs(t._zod.def,{get shape(){const c=t._zod.def.shape,l={...c};if(o)for(const d in o){if(!(d in c))throw new Error(`Unrecognized key: "${d}"`);o[d]&&(l[d]=e?new e({type:"optional",innerType:c[d]}):c[d])}else for(const d in c)l[d]=e?new e({type:"optional",innerType:c[d]}):c[d];return assignProp(this,"shape",l),l},checks:[]});return clone(t,s)}a(partial,"partial");function required(e,t,o){const n=mergeDefs(t._zod.def,{get shape(){const r=t._zod.def.shape,i={...r};if(o)for(const s in o){if(!(s in i))throw new Error(`Unrecognized key: "${s}"`);o[s]&&(i[s]=new e({type:"nonoptional",innerType:r[s]}))}else for(const s in r)i[s]=new e({type:"nonoptional",innerType:r[s]});return assignProp(this,"shape",i),i}});return clone(t,n)}a(required,"required");function aborted(e,t=0){if(e.aborted===!0)return!0;for(let o=t;o<e.issues.length;o++)if(e.issues[o]?.continue!==!0)return!0;return!1}a(aborted,"aborted");function prefixIssues(e,t){return t.map(o=>{var n;return(n=o).path??(n.path=[]),o.path.unshift(e),o})}a(prefixIssues,"prefixIssues");function unwrapMessage(e){return typeof e=="string"?e:e?.message}a(unwrapMessage,"unwrapMessage");function finalizeIssue(e,t,o){const n={...e,path:e.path??[]};if(!e.message){const r=unwrapMessage(e.inst?._zod.def?.error?.(e))??unwrapMessage(t?.error?.(e))??unwrapMessage(o.customError?.(e))??unwrapMessage(o.localeError?.(e))??"Invalid input";n.message=r}return delete n.inst,delete n.continue,t?.reportInput||delete n.input,n}a(finalizeIssue,"finalizeIssue");function getLengthableOrigin(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}a(getLengthableOrigin,"getLengthableOrigin");function issue(...e){const[t,o,n]=e;return typeof t=="string"?{message:t,code:"custom",input:o,inst:n}:{...t}}a(issue,"issue");const initializer$1=a((e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,jsonStringifyReplacer,2),Object.defineProperty(e,"toString",{value:a(()=>e.message,"value"),enumerable:!1})},"initializer$1"),$ZodError=$constructor("$ZodError",initializer$1),$ZodRealError=$constructor("$ZodError",initializer$1,{Parent:Error});function flattenError(e,t=o=>o.message){const o={},n=[];for(const r of e.issues)r.path.length>0?(o[r.path[0]]=o[r.path[0]]||[],o[r.path[0]].push(t(r))):n.push(t(r));return{formErrors:n,fieldErrors:o}}a(flattenError,"flattenError");function formatError(e,t=o=>o.message){const o={_errors:[]},n=a(r=>{for(const i of r.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(s=>n({issues:s}));else if(i.code==="invalid_key")n({issues:i.issues});else if(i.code==="invalid_element")n({issues:i.issues});else if(i.path.length===0)o._errors.push(t(i));else{let s=o,c=0;for(;c<i.path.length;){const l=i.path[c];c===i.path.length-1?(s[l]=s[l]||{_errors:[]},s[l]._errors.push(t(i))):s[l]=s[l]||{_errors:[]},s=s[l],c++}}},"processError");return n(e),o}a(formatError,"formatError");function toDotPath(e){const t=[],o=e.map(n=>typeof n=="object"?n.key:n);for(const n of o)typeof n=="number"?t.push(`[${n}]`):typeof n=="symbol"?t.push(`[${JSON.stringify(String(n))}]`):/[^\w$]/.test(n)?t.push(`[${JSON.stringify(n)}]`):(t.length&&t.push("."),t.push(n));return t.join("")}a(toDotPath,"toDotPath");function prettifyError(e){const t=[],o=[...e.issues].sort((n,r)=>(n.path??[]).length-(r.path??[]).length);for(const n of o)t.push(`βœ– ${n.message}`),n.path?.length&&t.push(` β†’ at ${toDotPath(n.path)}`);return t.join(`
3
+ `)}a(prettifyError,"prettifyError");const _parse=a(e=>(t,o,n,r)=>{const i=n?Object.assign(n,{async:!1}):{async:!1},s=t._zod.run({value:o,issues:[]},i);if(s instanceof Promise)throw new $ZodAsyncError;if(s.issues.length){const c=new(r?.Err??e)(s.issues.map(l=>finalizeIssue(l,i,config())));throw captureStackTrace(c,r?.callee),c}return s.value},"_parse"),_parseAsync=a(e=>async(t,o,n,r)=>{const i=n?Object.assign(n,{async:!0}):{async:!0};let s=t._zod.run({value:o,issues:[]},i);if(s instanceof Promise&&(s=await s),s.issues.length){const c=new(r?.Err??e)(s.issues.map(l=>finalizeIssue(l,i,config())));throw captureStackTrace(c,r?.callee),c}return s.value},"_parseAsync"),_safeParse=a(e=>(t,o,n)=>{const r=n?{...n,async:!1}:{async:!1},i=t._zod.run({value:o,issues:[]},r);if(i instanceof Promise)throw new $ZodAsyncError;return i.issues.length?{success:!1,error:new(e??$ZodError)(i.issues.map(s=>finalizeIssue(s,r,config())))}:{success:!0,data:i.value}},"_safeParse"),safeParse$1=_safeParse($ZodRealError),_safeParseAsync=a(e=>async(t,o,n)=>{const r=n?Object.assign(n,{async:!0}):{async:!0};let i=t._zod.run({value:o,issues:[]},r);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(s=>finalizeIssue(s,r,config())))}:{success:!0,data:i.value}},"_safeParseAsync"),safeParseAsync$1=_safeParseAsync($ZodRealError),_encode=a(e=>(t,o,n)=>{const r=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return _parse(e)(t,o,r)},"_encode"),_decode=a(e=>(t,o,n)=>_parse(e)(t,o,n),"_decode"),_encodeAsync=a(e=>async(t,o,n)=>{const r=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return _parseAsync(e)(t,o,r)},"_encodeAsync"),_decodeAsync=a(e=>async(t,o,n)=>_parseAsync(e)(t,o,n),"_decodeAsync"),_safeEncode=a(e=>(t,o,n)=>{const r=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return _safeParse(e)(t,o,r)},"_safeEncode"),_safeDecode=a(e=>(t,o,n)=>_safeParse(e)(t,o,n),"_safeDecode"),_safeEncodeAsync=a(e=>async(t,o,n)=>{const r=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return _safeParseAsync(e)(t,o,r)},"_safeEncodeAsync"),_safeDecodeAsync=a(e=>async(t,o,n)=>_safeParseAsync(e)(t,o,n),"_safeDecodeAsync"),cuid=/^[cC][^\s-]{8,}$/,cuid2=/^[0-9a-z]+$/,ulid=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,xid=/^[0-9a-vA-V]{20}$/,ksuid=/^[A-Za-z0-9]{27}$/,nanoid=/^[a-zA-Z0-9_-]{21}$/,duration$1=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,guid=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,uuid=a(e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,"uuid"),email=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,_emoji$1="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function emoji(){return new RegExp(_emoji$1,"u")}a(emoji,"emoji");const ipv4=/^(?:(?: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])$/,ipv6=/^(([0-9a-fA-F]{1,4}:){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}|:))$/,cidrv4=/^((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])\/([0-9]|[1-2][0-9]|3[0-2])$/,cidrv6=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,base64url=/^[A-Za-z0-9_-]*$/,e164=/^\+[1-9]\d{6,14}$/,dateSource="(?:(?:\\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])))",date$1=new RegExp(`^${dateSource}$`);function timeSource(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}a(timeSource,"timeSource");function time$1(e){return new RegExp(`^${timeSource(e)}$`)}a(time$1,"time$1");function datetime$1(e){const t=timeSource({precision:e.precision}),o=["Z"];e.local&&o.push(""),e.offset&&o.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const n=`${t}(?:${o.join("|")})`;return new RegExp(`^${dateSource}T(?:${n})$`)}a(datetime$1,"datetime$1");const string$1=a(e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},"string$1"),integer=/^-?\d+$/,number$1=/^-?\d+(?:\.\d+)?$/,boolean$1=/^(?:true|false)$/i,lowercase=/^[^A-Z]*$/,uppercase=/^[^a-z]*$/,$ZodCheck=$constructor("$ZodCheck",(e,t)=>{var o;e._zod??(e._zod={}),e._zod.def=t,(o=e._zod).onattach??(o.onattach=[])}),numericOriginMap={number:"number",bigint:"bigint",object:"date"},$ZodCheckLessThan=$constructor("$ZodCheckLessThan",(e,t)=>{$ZodCheck.init(e,t);const o=numericOriginMap[typeof t.value];e._zod.onattach.push(n=>{const r=n._zod.bag,i=(t.inclusive?r.maximum:r.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<i&&(t.inclusive?r.maximum=t.value:r.exclusiveMaximum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value<=t.value:n.value<t.value)||n.issues.push({origin:o,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),$ZodCheckGreaterThan=$constructor("$ZodCheckGreaterThan",(e,t)=>{$ZodCheck.init(e,t);const o=numericOriginMap[typeof t.value];e._zod.onattach.push(n=>{const r=n._zod.bag,i=(t.inclusive?r.minimum:r.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>i&&(t.inclusive?r.minimum=t.value:r.exclusiveMinimum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:o,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),$ZodCheckMultipleOf=$constructor("$ZodCheckMultipleOf",(e,t)=>{$ZodCheck.init(e,t),e._zod.onattach.push(o=>{var n;(n=o._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=o=>{if(typeof o.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof o.value=="bigint"?o.value%t.value===BigInt(0):floatSafeRemainder(o.value,t.value)===0)||o.issues.push({origin:typeof o.value,code:"not_multiple_of",divisor:t.value,input:o.value,inst:e,continue:!t.abort})}}),$ZodCheckNumberFormat=$constructor("$ZodCheckNumberFormat",(e,t)=>{$ZodCheck.init(e,t),t.format=t.format||"float64";const o=t.format?.includes("int"),n=o?"int":"number",[r,i]=NUMBER_FORMAT_RANGES[t.format];e._zod.onattach.push(s=>{const c=s._zod.bag;c.format=t.format,c.minimum=r,c.maximum=i,o&&(c.pattern=integer)}),e._zod.check=s=>{const c=s.value;if(o){if(!Number.isInteger(c)){s.issues.push({expected:n,format:t.format,code:"invalid_type",continue:!1,input:c,inst:e});return}if(!Number.isSafeInteger(c)){c>0?s.issues.push({input:c,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort}):s.issues.push({input:c,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort});return}}c<r&&s.issues.push({origin:"number",input:c,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort}),c>i&&s.issues.push({origin:"number",input:c,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}}),$ZodCheckMaxLength=$constructor("$ZodCheckMaxLength",(e,t)=>{var o;$ZodCheck.init(e,t),(o=e._zod.def).when??(o.when=n=>{const r=n.value;return!nullish(r)&&r.length!==void 0}),e._zod.onattach.push(n=>{const r=n._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<r&&(n._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{const r=n.value;if(r.length<=t.maximum)return;const s=getLengthableOrigin(r);n.issues.push({origin:s,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),$ZodCheckMinLength=$constructor("$ZodCheckMinLength",(e,t)=>{var o;$ZodCheck.init(e,t),(o=e._zod.def).when??(o.when=n=>{const r=n.value;return!nullish(r)&&r.length!==void 0}),e._zod.onattach.push(n=>{const r=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>r&&(n._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{const r=n.value;if(r.length>=t.minimum)return;const s=getLengthableOrigin(r);n.issues.push({origin:s,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),$ZodCheckLengthEquals=$constructor("$ZodCheckLengthEquals",(e,t)=>{var o;$ZodCheck.init(e,t),(o=e._zod.def).when??(o.when=n=>{const r=n.value;return!nullish(r)&&r.length!==void 0}),e._zod.onattach.push(n=>{const r=n._zod.bag;r.minimum=t.length,r.maximum=t.length,r.length=t.length}),e._zod.check=n=>{const r=n.value,i=r.length;if(i===t.length)return;const s=getLengthableOrigin(r),c=i>t.length;n.issues.push({origin:s,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),$ZodCheckStringFormat=$constructor("$ZodCheckStringFormat",(e,t)=>{var o,n;$ZodCheck.init(e,t),e._zod.onattach.push(r=>{const i=r._zod.bag;i.format=t.format,t.pattern&&(i.patterns??(i.patterns=new Set),i.patterns.add(t.pattern))}),t.pattern?(o=e._zod).check??(o.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:t.format,input:r.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),$ZodCheckRegex=$constructor("$ZodCheckRegex",(e,t)=>{$ZodCheckStringFormat.init(e,t),e._zod.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:"regex",input:o.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),$ZodCheckLowerCase=$constructor("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=lowercase),$ZodCheckStringFormat.init(e,t)}),$ZodCheckUpperCase=$constructor("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=uppercase),$ZodCheckStringFormat.init(e,t)}),$ZodCheckIncludes=$constructor("$ZodCheckIncludes",(e,t)=>{$ZodCheck.init(e,t);const o=escapeRegex(t.includes),n=new RegExp(typeof t.position=="number"?`^.{${t.position}}${o}`:o);t.pattern=n,e._zod.onattach.push(r=>{const i=r._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(n)}),e._zod.check=r=>{r.value.includes(t.includes,t.position)||r.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:r.value,inst:e,continue:!t.abort})}}),$ZodCheckStartsWith=$constructor("$ZodCheckStartsWith",(e,t)=>{$ZodCheck.init(e,t);const o=new RegExp(`^${escapeRegex(t.prefix)}.*`);t.pattern??(t.pattern=o),e._zod.onattach.push(n=>{const r=n._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(o)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),$ZodCheckEndsWith=$constructor("$ZodCheckEndsWith",(e,t)=>{$ZodCheck.init(e,t);const o=new RegExp(`.*${escapeRegex(t.suffix)}$`);t.pattern??(t.pattern=o),e._zod.onattach.push(n=>{const r=n._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(o)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),$ZodCheckOverwrite=$constructor("$ZodCheckOverwrite",(e,t)=>{$ZodCheck.init(e,t),e._zod.check=o=>{o.value=t.tx(o.value)}}),V=class V{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const n=t.split(`
7
4
  `).filter(s=>s),r=Math.min(...n.map(s=>s.length-s.trimStart().length)),i=n.map(s=>s.slice(r)).map(s=>" ".repeat(this.indent*2)+s);for(const s of i)this.content.push(s)}compile(){const t=Function,o=this?.args,r=[...(this?.content??[""]).map(i=>` ${i}`)];return new t(...o,r.join(`
8
- `))}};a(Ue,"Doc");let Doc=Ue;const version={major:4,minor:3,patch:6},$ZodType=$constructor("$ZodType",(e,t)=>{var o;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=version;const n=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&n.unshift(e);for(const r of n)for(const i of r._zod.onattach)i(e);if(n.length===0)(o=e._zod).deferred??(o.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const r=a((s,c,l)=>{let d=aborted(s),h;for(const f of c){if(f._zod.def.when){if(!f._zod.def.when(s))continue}else if(d)continue;const g=s.issues.length,m=f._zod.check(s);if(m instanceof Promise&&l?.async===!1)throw new $ZodAsyncError;if(h||m instanceof Promise)h=(h??Promise.resolve()).then(async()=>{await m,s.issues.length!==g&&(d||(d=aborted(s,g)))});else{if(s.issues.length===g)continue;d||(d=aborted(s,g))}}return h?h.then(()=>s):s},"runChecks"),i=a((s,c,l)=>{if(aborted(s))return s.aborted=!0,s;const d=r(c,n,l);if(d instanceof Promise){if(l.async===!1)throw new $ZodAsyncError;return d.then(h=>e._zod.parse(h,l))}return e._zod.parse(d,l)},"handleCanaryResult");e._zod.run=(s,c)=>{if(c.skipChecks)return e._zod.parse(s,c);if(c.direction==="backward"){const d=e._zod.parse({value:s.value,issues:[]},{...c,skipChecks:!0});return d instanceof Promise?d.then(h=>i(h,s,c)):i(d,s,c)}const l=e._zod.parse(s,c);if(l instanceof Promise){if(c.async===!1)throw new $ZodAsyncError;return l.then(d=>r(d,n,c))}return r(l,n,c)}}defineLazy(e,"~standard",()=>({validate:a(r=>{try{const i=safeParse$1(e,r);return i.success?{value:i.data}:{issues:i.error?.issues}}catch{return safeParseAsync$1(e,r).then(s=>s.success?{value:s.data}:{issues:s.error?.issues})}},"validate"),vendor:"zod",version:1}))}),$ZodString=$constructor("$ZodString",(e,t)=>{$ZodType.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??string$1(e._zod.bag),e._zod.parse=(o,n)=>{if(t.coerce)try{o.value=String(o.value)}catch{}return typeof o.value=="string"||o.issues.push({expected:"string",code:"invalid_type",input:o.value,inst:e}),o}}),$ZodStringFormat=$constructor("$ZodStringFormat",(e,t)=>{$ZodCheckStringFormat.init(e,t),$ZodString.init(e,t)}),$ZodGUID=$constructor("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=guid),$ZodStringFormat.init(e,t)}),$ZodUUID=$constructor("$ZodUUID",(e,t)=>{if(t.version){const n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(n===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=uuid(n))}else t.pattern??(t.pattern=uuid());$ZodStringFormat.init(e,t)}),$ZodEmail=$constructor("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=email),$ZodStringFormat.init(e,t)}),$ZodURL=$constructor("$ZodURL",(e,t)=>{$ZodStringFormat.init(e,t),e._zod.check=o=>{try{const n=o.value.trim(),r=new URL(n);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(r.hostname)||o.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:o.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(r.protocol.endsWith(":")?r.protocol.slice(0,-1):r.protocol)||o.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:o.value,inst:e,continue:!t.abort})),t.normalize?o.value=r.href:o.value=n;return}catch{o.issues.push({code:"invalid_format",format:"url",input:o.value,inst:e,continue:!t.abort})}}}),$ZodEmoji=$constructor("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=emoji()),$ZodStringFormat.init(e,t)}),$ZodNanoID=$constructor("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=nanoid),$ZodStringFormat.init(e,t)}),$ZodCUID=$constructor("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=cuid),$ZodStringFormat.init(e,t)}),$ZodCUID2=$constructor("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=cuid2),$ZodStringFormat.init(e,t)}),$ZodULID=$constructor("$ZodULID",(e,t)=>{t.pattern??(t.pattern=ulid),$ZodStringFormat.init(e,t)}),$ZodXID=$constructor("$ZodXID",(e,t)=>{t.pattern??(t.pattern=xid),$ZodStringFormat.init(e,t)}),$ZodKSUID=$constructor("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=ksuid),$ZodStringFormat.init(e,t)}),$ZodISODateTime=$constructor("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=datetime$1(t)),$ZodStringFormat.init(e,t)}),$ZodISODate=$constructor("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=date$1),$ZodStringFormat.init(e,t)}),$ZodISOTime=$constructor("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=time$1(t)),$ZodStringFormat.init(e,t)}),$ZodISODuration=$constructor("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=duration$1),$ZodStringFormat.init(e,t)}),$ZodIPv4=$constructor("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=ipv4),$ZodStringFormat.init(e,t),e._zod.bag.format="ipv4"}),$ZodIPv6=$constructor("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=ipv6),$ZodStringFormat.init(e,t),e._zod.bag.format="ipv6",e._zod.check=o=>{try{new URL(`http://[${o.value}]`)}catch{o.issues.push({code:"invalid_format",format:"ipv6",input:o.value,inst:e,continue:!t.abort})}}}),$ZodCIDRv4=$constructor("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=cidrv4),$ZodStringFormat.init(e,t)}),$ZodCIDRv6=$constructor("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=cidrv6),$ZodStringFormat.init(e,t),e._zod.check=o=>{const n=o.value.split("/");try{if(n.length!==2)throw new Error;const[r,i]=n;if(!i)throw new Error;const s=Number(i);if(`${s}`!==i)throw new Error;if(s<0||s>128)throw new Error;new URL(`http://[${r}]`)}catch{o.issues.push({code:"invalid_format",format:"cidrv6",input:o.value,inst:e,continue:!t.abort})}}});function isValidBase64(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}a(isValidBase64,"isValidBase64");const $ZodBase64=$constructor("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=base64),$ZodStringFormat.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=o=>{isValidBase64(o.value)||o.issues.push({code:"invalid_format",format:"base64",input:o.value,inst:e,continue:!t.abort})}});function isValidBase64URL(e){if(!base64url.test(e))return!1;const t=e.replace(/[-_]/g,n=>n==="-"?"+":"/"),o=t.padEnd(Math.ceil(t.length/4)*4,"=");return isValidBase64(o)}a(isValidBase64URL,"isValidBase64URL");const $ZodBase64URL=$constructor("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=base64url),$ZodStringFormat.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=o=>{isValidBase64URL(o.value)||o.issues.push({code:"invalid_format",format:"base64url",input:o.value,inst:e,continue:!t.abort})}}),$ZodE164=$constructor("$ZodE164",(e,t)=>{t.pattern??(t.pattern=e164),$ZodStringFormat.init(e,t)});function isValidJWT(e,t=null){try{const o=e.split(".");if(o.length!==3)return!1;const[n]=o;if(!n)return!1;const r=JSON.parse(atob(n));return!("typ"in r&&r?.typ!=="JWT"||!r.alg||t&&(!("alg"in r)||r.alg!==t))}catch{return!1}}a(isValidJWT,"isValidJWT");const $ZodJWT=$constructor("$ZodJWT",(e,t)=>{$ZodStringFormat.init(e,t),e._zod.check=o=>{isValidJWT(o.value,t.alg)||o.issues.push({code:"invalid_format",format:"jwt",input:o.value,inst:e,continue:!t.abort})}}),$ZodNumber=$constructor("$ZodNumber",(e,t)=>{$ZodType.init(e,t),e._zod.pattern=e._zod.bag.pattern??number$1,e._zod.parse=(o,n)=>{if(t.coerce)try{o.value=Number(o.value)}catch{}const r=o.value;if(typeof r=="number"&&!Number.isNaN(r)&&Number.isFinite(r))return o;const i=typeof r=="number"?Number.isNaN(r)?"NaN":Number.isFinite(r)?void 0:"Infinity":void 0;return o.issues.push({expected:"number",code:"invalid_type",input:r,inst:e,...i?{received:i}:{}}),o}}),$ZodNumberFormat=$constructor("$ZodNumberFormat",(e,t)=>{$ZodCheckNumberFormat.init(e,t),$ZodNumber.init(e,t)}),$ZodBoolean=$constructor("$ZodBoolean",(e,t)=>{$ZodType.init(e,t),e._zod.pattern=boolean$1,e._zod.parse=(o,n)=>{if(t.coerce)try{o.value=!!o.value}catch{}const r=o.value;return typeof r=="boolean"||o.issues.push({expected:"boolean",code:"invalid_type",input:r,inst:e}),o}}),$ZodUnknown=$constructor("$ZodUnknown",(e,t)=>{$ZodType.init(e,t),e._zod.parse=o=>o}),$ZodNever=$constructor("$ZodNever",(e,t)=>{$ZodType.init(e,t),e._zod.parse=(o,n)=>(o.issues.push({expected:"never",code:"invalid_type",input:o.value,inst:e}),o)});function handleArrayResult(e,t,o){e.issues.length&&t.issues.push(...prefixIssues(o,e.issues)),t.value[o]=e.value}a(handleArrayResult,"handleArrayResult");const $ZodArray=$constructor("$ZodArray",(e,t)=>{$ZodType.init(e,t),e._zod.parse=(o,n)=>{const r=o.value;if(!Array.isArray(r))return o.issues.push({expected:"array",code:"invalid_type",input:r,inst:e}),o;o.value=Array(r.length);const i=[];for(let s=0;s<r.length;s++){const c=r[s],l=t.element._zod.run({value:c,issues:[]},n);l instanceof Promise?i.push(l.then(d=>handleArrayResult(d,o,s))):handleArrayResult(l,o,s)}return i.length?Promise.all(i).then(()=>o):o}});function handlePropertyResult(e,t,o,n,r){if(e.issues.length){if(r&&!(o in n))return;t.issues.push(...prefixIssues(o,e.issues))}e.value===void 0?o in n&&(t.value[o]=void 0):t.value[o]=e.value}a(handlePropertyResult,"handlePropertyResult");function normalizeDef(e){const t=Object.keys(e.shape);for(const n of t)if(!e.shape?.[n]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${n}": expected a Zod schema`);const o=optionalKeys(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(o)}}a(normalizeDef,"normalizeDef");function handleCatchall(e,t,o,n,r,i){const s=[],c=r.keySet,l=r.catchall._zod,d=l.def.type,h=l.optout==="optional";for(const f in t){if(c.has(f))continue;if(d==="never"){s.push(f);continue}const g=l.run({value:t[f],issues:[]},n);g instanceof Promise?e.push(g.then(m=>handlePropertyResult(m,o,f,t,h))):handlePropertyResult(g,o,f,t,h)}return s.length&&o.issues.push({code:"unrecognized_keys",keys:s,input:t,inst:i}),e.length?Promise.all(e).then(()=>o):o}a(handleCatchall,"handleCatchall");const $ZodObject=$constructor("$ZodObject",(e,t)=>{if($ZodType.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){const c=t.shape;Object.defineProperty(t,"shape",{get:a(()=>{const l={...c};return Object.defineProperty(t,"shape",{value:l}),l},"get")})}const n=cached(()=>normalizeDef(t));defineLazy(e._zod,"propValues",()=>{const c=t.shape,l={};for(const d in c){const h=c[d]._zod;if(h.values){l[d]??(l[d]=new Set);for(const f of h.values)l[d].add(f)}}return l});const r=isObject,i=t.catchall;let s;e._zod.parse=(c,l)=>{s??(s=n.value);const d=c.value;if(!r(d))return c.issues.push({expected:"object",code:"invalid_type",input:d,inst:e}),c;c.value={};const h=[],f=s.shape;for(const g of s.keys){const m=f[g],I=m._zod.optout==="optional",S=m._zod.run({value:d[g],issues:[]},l);S instanceof Promise?h.push(S.then(P=>handlePropertyResult(P,c,g,d,I))):handlePropertyResult(S,c,g,d,I)}return i?handleCatchall(h,d,c,l,n.value,e):h.length?Promise.all(h).then(()=>c):c}}),$ZodObjectJIT=$constructor("$ZodObjectJIT",(e,t)=>{$ZodObject.init(e,t);const o=e._zod.parse,n=cached(()=>normalizeDef(t)),r=a(g=>{const m=new Doc(["shape","payload","ctx"]),I=n.value,S=a(k=>{const w=esc(k);return`shape[${w}]._zod.run({ value: input[${w}], issues: [] }, ctx)`},"parseStr");m.write("const input = payload.value;");const P=Object.create(null);let R=0;for(const k of I.keys)P[k]=`key_${R++}`;m.write("const newResult = {};");for(const k of I.keys){const w=P[k],A=esc(k),B=g[k]?._zod?.optout==="optional";m.write(`const ${w} = ${S(k)};`),B?m.write(`
5
+ `))}};a(V,"Doc");let Doc=V;const version={major:4,minor:3,patch:6},$ZodType=$constructor("$ZodType",(e,t)=>{var o;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=version;const n=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&n.unshift(e);for(const r of n)for(const i of r._zod.onattach)i(e);if(n.length===0)(o=e._zod).deferred??(o.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const r=a((s,c,l)=>{let d=aborted(s),h;for(const f of c){if(f._zod.def.when){if(!f._zod.def.when(s))continue}else if(d)continue;const g=s.issues.length,m=f._zod.check(s);if(m instanceof Promise&&l?.async===!1)throw new $ZodAsyncError;if(h||m instanceof Promise)h=(h??Promise.resolve()).then(async()=>{await m,s.issues.length!==g&&(d||(d=aborted(s,g)))});else{if(s.issues.length===g)continue;d||(d=aborted(s,g))}}return h?h.then(()=>s):s},"runChecks"),i=a((s,c,l)=>{if(aborted(s))return s.aborted=!0,s;const d=r(c,n,l);if(d instanceof Promise){if(l.async===!1)throw new $ZodAsyncError;return d.then(h=>e._zod.parse(h,l))}return e._zod.parse(d,l)},"handleCanaryResult");e._zod.run=(s,c)=>{if(c.skipChecks)return e._zod.parse(s,c);if(c.direction==="backward"){const d=e._zod.parse({value:s.value,issues:[]},{...c,skipChecks:!0});return d instanceof Promise?d.then(h=>i(h,s,c)):i(d,s,c)}const l=e._zod.parse(s,c);if(l instanceof Promise){if(c.async===!1)throw new $ZodAsyncError;return l.then(d=>r(d,n,c))}return r(l,n,c)}}defineLazy(e,"~standard",()=>({validate:a(r=>{try{const i=safeParse$1(e,r);return i.success?{value:i.data}:{issues:i.error?.issues}}catch{return safeParseAsync$1(e,r).then(s=>s.success?{value:s.data}:{issues:s.error?.issues})}},"validate"),vendor:"zod",version:1}))}),$ZodString=$constructor("$ZodString",(e,t)=>{$ZodType.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??string$1(e._zod.bag),e._zod.parse=(o,n)=>{if(t.coerce)try{o.value=String(o.value)}catch{}return typeof o.value=="string"||o.issues.push({expected:"string",code:"invalid_type",input:o.value,inst:e}),o}}),$ZodStringFormat=$constructor("$ZodStringFormat",(e,t)=>{$ZodCheckStringFormat.init(e,t),$ZodString.init(e,t)}),$ZodGUID=$constructor("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=guid),$ZodStringFormat.init(e,t)}),$ZodUUID=$constructor("$ZodUUID",(e,t)=>{if(t.version){const n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(n===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=uuid(n))}else t.pattern??(t.pattern=uuid());$ZodStringFormat.init(e,t)}),$ZodEmail=$constructor("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=email),$ZodStringFormat.init(e,t)}),$ZodURL=$constructor("$ZodURL",(e,t)=>{$ZodStringFormat.init(e,t),e._zod.check=o=>{try{const n=o.value.trim(),r=new URL(n);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(r.hostname)||o.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:o.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(r.protocol.endsWith(":")?r.protocol.slice(0,-1):r.protocol)||o.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:o.value,inst:e,continue:!t.abort})),t.normalize?o.value=r.href:o.value=n;return}catch{o.issues.push({code:"invalid_format",format:"url",input:o.value,inst:e,continue:!t.abort})}}}),$ZodEmoji=$constructor("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=emoji()),$ZodStringFormat.init(e,t)}),$ZodNanoID=$constructor("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=nanoid),$ZodStringFormat.init(e,t)}),$ZodCUID=$constructor("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=cuid),$ZodStringFormat.init(e,t)}),$ZodCUID2=$constructor("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=cuid2),$ZodStringFormat.init(e,t)}),$ZodULID=$constructor("$ZodULID",(e,t)=>{t.pattern??(t.pattern=ulid),$ZodStringFormat.init(e,t)}),$ZodXID=$constructor("$ZodXID",(e,t)=>{t.pattern??(t.pattern=xid),$ZodStringFormat.init(e,t)}),$ZodKSUID=$constructor("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=ksuid),$ZodStringFormat.init(e,t)}),$ZodISODateTime=$constructor("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=datetime$1(t)),$ZodStringFormat.init(e,t)}),$ZodISODate=$constructor("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=date$1),$ZodStringFormat.init(e,t)}),$ZodISOTime=$constructor("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=time$1(t)),$ZodStringFormat.init(e,t)}),$ZodISODuration=$constructor("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=duration$1),$ZodStringFormat.init(e,t)}),$ZodIPv4=$constructor("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=ipv4),$ZodStringFormat.init(e,t),e._zod.bag.format="ipv4"}),$ZodIPv6=$constructor("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=ipv6),$ZodStringFormat.init(e,t),e._zod.bag.format="ipv6",e._zod.check=o=>{try{new URL(`http://[${o.value}]`)}catch{o.issues.push({code:"invalid_format",format:"ipv6",input:o.value,inst:e,continue:!t.abort})}}}),$ZodCIDRv4=$constructor("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=cidrv4),$ZodStringFormat.init(e,t)}),$ZodCIDRv6=$constructor("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=cidrv6),$ZodStringFormat.init(e,t),e._zod.check=o=>{const n=o.value.split("/");try{if(n.length!==2)throw new Error;const[r,i]=n;if(!i)throw new Error;const s=Number(i);if(`${s}`!==i)throw new Error;if(s<0||s>128)throw new Error;new URL(`http://[${r}]`)}catch{o.issues.push({code:"invalid_format",format:"cidrv6",input:o.value,inst:e,continue:!t.abort})}}});function isValidBase64(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}a(isValidBase64,"isValidBase64");const $ZodBase64=$constructor("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=base64),$ZodStringFormat.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=o=>{isValidBase64(o.value)||o.issues.push({code:"invalid_format",format:"base64",input:o.value,inst:e,continue:!t.abort})}});function isValidBase64URL(e){if(!base64url.test(e))return!1;const t=e.replace(/[-_]/g,n=>n==="-"?"+":"/"),o=t.padEnd(Math.ceil(t.length/4)*4,"=");return isValidBase64(o)}a(isValidBase64URL,"isValidBase64URL");const $ZodBase64URL=$constructor("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=base64url),$ZodStringFormat.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=o=>{isValidBase64URL(o.value)||o.issues.push({code:"invalid_format",format:"base64url",input:o.value,inst:e,continue:!t.abort})}}),$ZodE164=$constructor("$ZodE164",(e,t)=>{t.pattern??(t.pattern=e164),$ZodStringFormat.init(e,t)});function isValidJWT(e,t=null){try{const o=e.split(".");if(o.length!==3)return!1;const[n]=o;if(!n)return!1;const r=JSON.parse(atob(n));return!("typ"in r&&r?.typ!=="JWT"||!r.alg||t&&(!("alg"in r)||r.alg!==t))}catch{return!1}}a(isValidJWT,"isValidJWT");const $ZodJWT=$constructor("$ZodJWT",(e,t)=>{$ZodStringFormat.init(e,t),e._zod.check=o=>{isValidJWT(o.value,t.alg)||o.issues.push({code:"invalid_format",format:"jwt",input:o.value,inst:e,continue:!t.abort})}}),$ZodNumber=$constructor("$ZodNumber",(e,t)=>{$ZodType.init(e,t),e._zod.pattern=e._zod.bag.pattern??number$1,e._zod.parse=(o,n)=>{if(t.coerce)try{o.value=Number(o.value)}catch{}const r=o.value;if(typeof r=="number"&&!Number.isNaN(r)&&Number.isFinite(r))return o;const i=typeof r=="number"?Number.isNaN(r)?"NaN":Number.isFinite(r)?void 0:"Infinity":void 0;return o.issues.push({expected:"number",code:"invalid_type",input:r,inst:e,...i?{received:i}:{}}),o}}),$ZodNumberFormat=$constructor("$ZodNumberFormat",(e,t)=>{$ZodCheckNumberFormat.init(e,t),$ZodNumber.init(e,t)}),$ZodBoolean=$constructor("$ZodBoolean",(e,t)=>{$ZodType.init(e,t),e._zod.pattern=boolean$1,e._zod.parse=(o,n)=>{if(t.coerce)try{o.value=!!o.value}catch{}const r=o.value;return typeof r=="boolean"||o.issues.push({expected:"boolean",code:"invalid_type",input:r,inst:e}),o}}),$ZodUnknown=$constructor("$ZodUnknown",(e,t)=>{$ZodType.init(e,t),e._zod.parse=o=>o}),$ZodNever=$constructor("$ZodNever",(e,t)=>{$ZodType.init(e,t),e._zod.parse=(o,n)=>(o.issues.push({expected:"never",code:"invalid_type",input:o.value,inst:e}),o)});function handleArrayResult(e,t,o){e.issues.length&&t.issues.push(...prefixIssues(o,e.issues)),t.value[o]=e.value}a(handleArrayResult,"handleArrayResult");const $ZodArray=$constructor("$ZodArray",(e,t)=>{$ZodType.init(e,t),e._zod.parse=(o,n)=>{const r=o.value;if(!Array.isArray(r))return o.issues.push({expected:"array",code:"invalid_type",input:r,inst:e}),o;o.value=Array(r.length);const i=[];for(let s=0;s<r.length;s++){const c=r[s],l=t.element._zod.run({value:c,issues:[]},n);l instanceof Promise?i.push(l.then(d=>handleArrayResult(d,o,s))):handleArrayResult(l,o,s)}return i.length?Promise.all(i).then(()=>o):o}});function handlePropertyResult(e,t,o,n,r){if(e.issues.length){if(r&&!(o in n))return;t.issues.push(...prefixIssues(o,e.issues))}e.value===void 0?o in n&&(t.value[o]=void 0):t.value[o]=e.value}a(handlePropertyResult,"handlePropertyResult");function normalizeDef(e){const t=Object.keys(e.shape);for(const n of t)if(!e.shape?.[n]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${n}": expected a Zod schema`);const o=optionalKeys(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(o)}}a(normalizeDef,"normalizeDef");function handleCatchall(e,t,o,n,r,i){const s=[],c=r.keySet,l=r.catchall._zod,d=l.def.type,h=l.optout==="optional";for(const f in t){if(c.has(f))continue;if(d==="never"){s.push(f);continue}const g=l.run({value:t[f],issues:[]},n);g instanceof Promise?e.push(g.then(m=>handlePropertyResult(m,o,f,t,h))):handlePropertyResult(g,o,f,t,h)}return s.length&&o.issues.push({code:"unrecognized_keys",keys:s,input:t,inst:i}),e.length?Promise.all(e).then(()=>o):o}a(handleCatchall,"handleCatchall");const $ZodObject=$constructor("$ZodObject",(e,t)=>{if($ZodType.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){const c=t.shape;Object.defineProperty(t,"shape",{get:a(()=>{const l={...c};return Object.defineProperty(t,"shape",{value:l}),l},"get")})}const n=cached(()=>normalizeDef(t));defineLazy(e._zod,"propValues",()=>{const c=t.shape,l={};for(const d in c){const h=c[d]._zod;if(h.values){l[d]??(l[d]=new Set);for(const f of h.values)l[d].add(f)}}return l});const r=isObject,i=t.catchall;let s;e._zod.parse=(c,l)=>{s??(s=n.value);const d=c.value;if(!r(d))return c.issues.push({expected:"object",code:"invalid_type",input:d,inst:e}),c;c.value={};const h=[],f=s.shape;for(const g of s.keys){const m=f[g],I=m._zod.optout==="optional",S=m._zod.run({value:d[g],issues:[]},l);S instanceof Promise?h.push(S.then(P=>handlePropertyResult(P,c,g,d,I))):handlePropertyResult(S,c,g,d,I)}return i?handleCatchall(h,d,c,l,n.value,e):h.length?Promise.all(h).then(()=>c):c}}),$ZodObjectJIT=$constructor("$ZodObjectJIT",(e,t)=>{$ZodObject.init(e,t);const o=e._zod.parse,n=cached(()=>normalizeDef(t)),r=a(g=>{const m=new Doc(["shape","payload","ctx"]),I=n.value,S=a(k=>{const w=esc(k);return`shape[${w}]._zod.run({ value: input[${w}], issues: [] }, ctx)`},"parseStr");m.write("const input = payload.value;");const P=Object.create(null);let R=0;for(const k of I.keys)P[k]=`key_${R++}`;m.write("const newResult = {};");for(const k of I.keys){const w=P[k],A=esc(k),B=g[k]?._zod?.optout==="optional";m.write(`const ${w} = ${S(k)};`),B?m.write(`
9
6
  if (${w}.issues.length) {
10
7
  if (${A} in input) {
11
8
  payload.issues = payload.issues.concat(${w}.issues.map(iss => ({
@@ -39,9 +36,13 @@ var $t=Object.defineProperty;var xt=L=>{throw TypeError(L)};var qt=(L,M,V)=>M in
39
36
  newResult[${A}] = ${w}.value;
40
37
  }
41
38
 
42
- `)}m.write("payload.value = newResult;"),m.write("return payload;");const D=m.compile();return(k,w)=>D(g,k,w)},"generateFastpass");let i;const s=isObject,c=!globalConfig.jitless,d=c&&allowsEval.value,h=t.catchall;let f;e._zod.parse=(g,m)=>{f??(f=n.value);const I=g.value;return s(I)?c&&d&&m?.async===!1&&m.jitless!==!0?(i||(i=r(t.shape)),g=i(g,m),h?handleCatchall([],I,g,m,f,e):g):o(g,m):(g.issues.push({expected:"object",code:"invalid_type",input:I,inst:e}),g)}});function handleUnionResults(e,t,o,n){for(const i of e)if(i.issues.length===0)return t.value=i.value,t;const r=e.filter(i=>!aborted(i));return r.length===1?(t.value=r[0].value,r[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:o,errors:e.map(i=>i.issues.map(s=>finalizeIssue(s,n,config())))}),t)}a(handleUnionResults,"handleUnionResults");const $ZodUnion=$constructor("$ZodUnion",(e,t)=>{$ZodType.init(e,t),defineLazy(e._zod,"optin",()=>t.options.some(r=>r._zod.optin==="optional")?"optional":void 0),defineLazy(e._zod,"optout",()=>t.options.some(r=>r._zod.optout==="optional")?"optional":void 0),defineLazy(e._zod,"values",()=>{if(t.options.every(r=>r._zod.values))return new Set(t.options.flatMap(r=>Array.from(r._zod.values)))}),defineLazy(e._zod,"pattern",()=>{if(t.options.every(r=>r._zod.pattern)){const r=t.options.map(i=>i._zod.pattern);return new RegExp(`^(${r.map(i=>cleanRegex(i.source)).join("|")})$`)}});const o=t.options.length===1,n=t.options[0]._zod.run;e._zod.parse=(r,i)=>{if(o)return n(r,i);let s=!1;const c=[];for(const l of t.options){const d=l._zod.run({value:r.value,issues:[]},i);if(d instanceof Promise)c.push(d),s=!0;else{if(d.issues.length===0)return d;c.push(d)}}return s?Promise.all(c).then(l=>handleUnionResults(l,r,e,i)):handleUnionResults(c,r,e,i)}}),$ZodIntersection=$constructor("$ZodIntersection",(e,t)=>{$ZodType.init(e,t),e._zod.parse=(o,n)=>{const r=o.value,i=t.left._zod.run({value:r,issues:[]},n),s=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||s instanceof Promise?Promise.all([i,s]).then(([l,d])=>handleIntersectionResults(o,l,d)):handleIntersectionResults(o,i,s)}});function mergeValues(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(isPlainObject(e)&&isPlainObject(t)){const o=Object.keys(t),n=Object.keys(e).filter(i=>o.indexOf(i)!==-1),r={...e,...t};for(const i of n){const s=mergeValues(e[i],t[i]);if(!s.valid)return{valid:!1,mergeErrorPath:[i,...s.mergeErrorPath]};r[i]=s.data}return{valid:!0,data:r}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const o=[];for(let n=0;n<e.length;n++){const r=e[n],i=t[n],s=mergeValues(r,i);if(!s.valid)return{valid:!1,mergeErrorPath:[n,...s.mergeErrorPath]};o.push(s.data)}return{valid:!0,data:o}}return{valid:!1,mergeErrorPath:[]}}a(mergeValues,"mergeValues");function handleIntersectionResults(e,t,o){const n=new Map;let r;for(const c of t.issues)if(c.code==="unrecognized_keys"){r??(r=c);for(const l of c.keys)n.has(l)||n.set(l,{}),n.get(l).l=!0}else e.issues.push(c);for(const c of o.issues)if(c.code==="unrecognized_keys")for(const l of c.keys)n.has(l)||n.set(l,{}),n.get(l).r=!0;else e.issues.push(c);const i=[...n].filter(([,c])=>c.l&&c.r).map(([c])=>c);if(i.length&&r&&e.issues.push({...r,keys:i}),aborted(e))return e;const s=mergeValues(t.value,o.value);if(!s.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(s.mergeErrorPath)}`);return e.value=s.data,e}a(handleIntersectionResults,"handleIntersectionResults");const $ZodEnum=$constructor("$ZodEnum",(e,t)=>{$ZodType.init(e,t);const o=getEnumValues(t.entries),n=new Set(o);e._zod.values=n,e._zod.pattern=new RegExp(`^(${o.filter(r=>propertyKeyTypes.has(typeof r)).map(r=>typeof r=="string"?escapeRegex(r):r.toString()).join("|")})$`),e._zod.parse=(r,i)=>{const s=r.value;return n.has(s)||r.issues.push({code:"invalid_value",values:o,input:s,inst:e}),r}}),$ZodTransform=$constructor("$ZodTransform",(e,t)=>{$ZodType.init(e,t),e._zod.parse=(o,n)=>{if(n.direction==="backward")throw new $ZodEncodeError(e.constructor.name);const r=t.transform(o.value,o);if(n.async)return(r instanceof Promise?r:Promise.resolve(r)).then(s=>(o.value=s,o));if(r instanceof Promise)throw new $ZodAsyncError;return o.value=r,o}});function handleOptionalResult(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}a(handleOptionalResult,"handleOptionalResult");const $ZodOptional=$constructor("$ZodOptional",(e,t)=>{$ZodType.init(e,t),e._zod.optin="optional",e._zod.optout="optional",defineLazy(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),defineLazy(e._zod,"pattern",()=>{const o=t.innerType._zod.pattern;return o?new RegExp(`^(${cleanRegex(o.source)})?$`):void 0}),e._zod.parse=(o,n)=>{if(t.innerType._zod.optin==="optional"){const r=t.innerType._zod.run(o,n);return r instanceof Promise?r.then(i=>handleOptionalResult(i,o.value)):handleOptionalResult(r,o.value)}return o.value===void 0?o:t.innerType._zod.run(o,n)}}),$ZodExactOptional=$constructor("$ZodExactOptional",(e,t)=>{$ZodOptional.init(e,t),defineLazy(e._zod,"values",()=>t.innerType._zod.values),defineLazy(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(o,n)=>t.innerType._zod.run(o,n)}),$ZodNullable=$constructor("$ZodNullable",(e,t)=>{$ZodType.init(e,t),defineLazy(e._zod,"optin",()=>t.innerType._zod.optin),defineLazy(e._zod,"optout",()=>t.innerType._zod.optout),defineLazy(e._zod,"pattern",()=>{const o=t.innerType._zod.pattern;return o?new RegExp(`^(${cleanRegex(o.source)}|null)$`):void 0}),defineLazy(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(o,n)=>o.value===null?o:t.innerType._zod.run(o,n)}),$ZodDefault=$constructor("$ZodDefault",(e,t)=>{$ZodType.init(e,t),e._zod.optin="optional",defineLazy(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(o,n)=>{if(n.direction==="backward")return t.innerType._zod.run(o,n);if(o.value===void 0)return o.value=t.defaultValue,o;const r=t.innerType._zod.run(o,n);return r instanceof Promise?r.then(i=>handleDefaultResult(i,t)):handleDefaultResult(r,t)}});function handleDefaultResult(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}a(handleDefaultResult,"handleDefaultResult");const $ZodPrefault=$constructor("$ZodPrefault",(e,t)=>{$ZodType.init(e,t),e._zod.optin="optional",defineLazy(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(o,n)=>(n.direction==="backward"||o.value===void 0&&(o.value=t.defaultValue),t.innerType._zod.run(o,n))}),$ZodNonOptional=$constructor("$ZodNonOptional",(e,t)=>{$ZodType.init(e,t),defineLazy(e._zod,"values",()=>{const o=t.innerType._zod.values;return o?new Set([...o].filter(n=>n!==void 0)):void 0}),e._zod.parse=(o,n)=>{const r=t.innerType._zod.run(o,n);return r instanceof Promise?r.then(i=>handleNonOptionalResult(i,e)):handleNonOptionalResult(r,e)}});function handleNonOptionalResult(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}a(handleNonOptionalResult,"handleNonOptionalResult");const $ZodCatch=$constructor("$ZodCatch",(e,t)=>{$ZodType.init(e,t),defineLazy(e._zod,"optin",()=>t.innerType._zod.optin),defineLazy(e._zod,"optout",()=>t.innerType._zod.optout),defineLazy(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(o,n)=>{if(n.direction==="backward")return t.innerType._zod.run(o,n);const r=t.innerType._zod.run(o,n);return r instanceof Promise?r.then(i=>(o.value=i.value,i.issues.length&&(o.value=t.catchValue({...o,error:{issues:i.issues.map(s=>finalizeIssue(s,n,config()))},input:o.value}),o.issues=[]),o)):(o.value=r.value,r.issues.length&&(o.value=t.catchValue({...o,error:{issues:r.issues.map(i=>finalizeIssue(i,n,config()))},input:o.value}),o.issues=[]),o)}}),$ZodPipe=$constructor("$ZodPipe",(e,t)=>{$ZodType.init(e,t),defineLazy(e._zod,"values",()=>t.in._zod.values),defineLazy(e._zod,"optin",()=>t.in._zod.optin),defineLazy(e._zod,"optout",()=>t.out._zod.optout),defineLazy(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(o,n)=>{if(n.direction==="backward"){const i=t.out._zod.run(o,n);return i instanceof Promise?i.then(s=>handlePipeResult(s,t.in,n)):handlePipeResult(i,t.in,n)}const r=t.in._zod.run(o,n);return r instanceof Promise?r.then(i=>handlePipeResult(i,t.out,n)):handlePipeResult(r,t.out,n)}});function handlePipeResult(e,t,o){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},o)}a(handlePipeResult,"handlePipeResult");const $ZodReadonly=$constructor("$ZodReadonly",(e,t)=>{$ZodType.init(e,t),defineLazy(e._zod,"propValues",()=>t.innerType._zod.propValues),defineLazy(e._zod,"values",()=>t.innerType._zod.values),defineLazy(e._zod,"optin",()=>t.innerType?._zod?.optin),defineLazy(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(o,n)=>{if(n.direction==="backward")return t.innerType._zod.run(o,n);const r=t.innerType._zod.run(o,n);return r instanceof Promise?r.then(handleReadonlyResult):handleReadonlyResult(r)}});function handleReadonlyResult(e){return e.value=Object.freeze(e.value),e}a(handleReadonlyResult,"handleReadonlyResult");const $ZodCustom=$constructor("$ZodCustom",(e,t)=>{$ZodCheck.init(e,t),$ZodType.init(e,t),e._zod.parse=(o,n)=>o,e._zod.check=o=>{const n=o.value,r=t.fn(n);if(r instanceof Promise)return r.then(i=>handleRefineResult(i,o,n,e));handleRefineResult(r,o,n,e)}});function handleRefineResult(e,t,o,n){if(!e){const r={code:"custom",input:o,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(r.params=n._zod.def.params),t.issues.push(issue(r))}}a(handleRefineResult,"handleRefineResult");var _a;const at=class at{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...o){const n=o[0];return this._map.set(t,n),n&&typeof n=="object"&&"id"in n&&this._idmap.set(n.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const o=this._map.get(t);return o&&typeof o=="object"&&"id"in o&&this._idmap.delete(o.id),this._map.delete(t),this}get(t){const o=t._zod.parent;if(o){const n={...this.get(o)??{}};delete n.id;const r={...n,...this._map.get(t)};return Object.keys(r).length?r:void 0}return this._map.get(t)}has(t){return this._map.has(t)}};a(at,"$ZodRegistry");let $ZodRegistry=at;function registry(){return new $ZodRegistry}a(registry,"registry"),(_a=globalThis).__zod_globalRegistry??(_a.__zod_globalRegistry=registry());const globalRegistry=globalThis.__zod_globalRegistry;function _string(e,t){return new e({type:"string",...normalizeParams(t)})}a(_string,"_string");function _email(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...normalizeParams(t)})}a(_email,"_email");function _guid(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...normalizeParams(t)})}a(_guid,"_guid");function _uuid(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...normalizeParams(t)})}a(_uuid,"_uuid");function _uuidv4(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...normalizeParams(t)})}a(_uuidv4,"_uuidv4");function _uuidv6(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...normalizeParams(t)})}a(_uuidv6,"_uuidv6");function _uuidv7(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...normalizeParams(t)})}a(_uuidv7,"_uuidv7");function _url(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...normalizeParams(t)})}a(_url,"_url");function _emoji(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...normalizeParams(t)})}a(_emoji,"_emoji");function _nanoid(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...normalizeParams(t)})}a(_nanoid,"_nanoid");function _cuid(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...normalizeParams(t)})}a(_cuid,"_cuid");function _cuid2(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...normalizeParams(t)})}a(_cuid2,"_cuid2");function _ulid(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...normalizeParams(t)})}a(_ulid,"_ulid");function _xid(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...normalizeParams(t)})}a(_xid,"_xid");function _ksuid(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...normalizeParams(t)})}a(_ksuid,"_ksuid");function _ipv4(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...normalizeParams(t)})}a(_ipv4,"_ipv4");function _ipv6(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...normalizeParams(t)})}a(_ipv6,"_ipv6");function _cidrv4(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...normalizeParams(t)})}a(_cidrv4,"_cidrv4");function _cidrv6(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...normalizeParams(t)})}a(_cidrv6,"_cidrv6");function _base64(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...normalizeParams(t)})}a(_base64,"_base64");function _base64url(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...normalizeParams(t)})}a(_base64url,"_base64url");function _e164(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...normalizeParams(t)})}a(_e164,"_e164");function _jwt(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...normalizeParams(t)})}a(_jwt,"_jwt");function _isoDateTime(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...normalizeParams(t)})}a(_isoDateTime,"_isoDateTime");function _isoDate(e,t){return new e({type:"string",format:"date",check:"string_format",...normalizeParams(t)})}a(_isoDate,"_isoDate");function _isoTime(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...normalizeParams(t)})}a(_isoTime,"_isoTime");function _isoDuration(e,t){return new e({type:"string",format:"duration",check:"string_format",...normalizeParams(t)})}a(_isoDuration,"_isoDuration");function _number(e,t){return new e({type:"number",checks:[],...normalizeParams(t)})}a(_number,"_number");function _int(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...normalizeParams(t)})}a(_int,"_int");function _boolean(e,t){return new e({type:"boolean",...normalizeParams(t)})}a(_boolean,"_boolean");function _unknown(e){return new e({type:"unknown"})}a(_unknown,"_unknown");function _never(e,t){return new e({type:"never",...normalizeParams(t)})}a(_never,"_never");function _lt(e,t){return new $ZodCheckLessThan({check:"less_than",...normalizeParams(t),value:e,inclusive:!1})}a(_lt,"_lt");function _lte(e,t){return new $ZodCheckLessThan({check:"less_than",...normalizeParams(t),value:e,inclusive:!0})}a(_lte,"_lte");function _gt(e,t){return new $ZodCheckGreaterThan({check:"greater_than",...normalizeParams(t),value:e,inclusive:!1})}a(_gt,"_gt");function _gte(e,t){return new $ZodCheckGreaterThan({check:"greater_than",...normalizeParams(t),value:e,inclusive:!0})}a(_gte,"_gte");function _multipleOf(e,t){return new $ZodCheckMultipleOf({check:"multiple_of",...normalizeParams(t),value:e})}a(_multipleOf,"_multipleOf");function _maxLength(e,t){return new $ZodCheckMaxLength({check:"max_length",...normalizeParams(t),maximum:e})}a(_maxLength,"_maxLength");function _minLength(e,t){return new $ZodCheckMinLength({check:"min_length",...normalizeParams(t),minimum:e})}a(_minLength,"_minLength");function _length(e,t){return new $ZodCheckLengthEquals({check:"length_equals",...normalizeParams(t),length:e})}a(_length,"_length");function _regex(e,t){return new $ZodCheckRegex({check:"string_format",format:"regex",...normalizeParams(t),pattern:e})}a(_regex,"_regex");function _lowercase(e){return new $ZodCheckLowerCase({check:"string_format",format:"lowercase",...normalizeParams(e)})}a(_lowercase,"_lowercase");function _uppercase(e){return new $ZodCheckUpperCase({check:"string_format",format:"uppercase",...normalizeParams(e)})}a(_uppercase,"_uppercase");function _includes(e,t){return new $ZodCheckIncludes({check:"string_format",format:"includes",...normalizeParams(t),includes:e})}a(_includes,"_includes");function _startsWith(e,t){return new $ZodCheckStartsWith({check:"string_format",format:"starts_with",...normalizeParams(t),prefix:e})}a(_startsWith,"_startsWith");function _endsWith(e,t){return new $ZodCheckEndsWith({check:"string_format",format:"ends_with",...normalizeParams(t),suffix:e})}a(_endsWith,"_endsWith");function _overwrite(e){return new $ZodCheckOverwrite({check:"overwrite",tx:e})}a(_overwrite,"_overwrite");function _normalize(e){return _overwrite(t=>t.normalize(e))}a(_normalize,"_normalize");function _trim(){return _overwrite(e=>e.trim())}a(_trim,"_trim");function _toLowerCase(){return _overwrite(e=>e.toLowerCase())}a(_toLowerCase,"_toLowerCase");function _toUpperCase(){return _overwrite(e=>e.toUpperCase())}a(_toUpperCase,"_toUpperCase");function _slugify(){return _overwrite(e=>slugify(e))}a(_slugify,"_slugify");function _array(e,t,o){return new e({type:"array",element:t,...normalizeParams(o)})}a(_array,"_array");function _refine(e,t,o){return new e({type:"custom",check:"custom",fn:t,...normalizeParams(o)})}a(_refine,"_refine");function _superRefine(e){const t=_check(o=>(o.addIssue=n=>{if(typeof n=="string")o.issues.push(issue(n,o.value,t._zod.def));else{const r=n;r.fatal&&(r.continue=!1),r.code??(r.code="custom"),r.input??(r.input=o.value),r.inst??(r.inst=t),r.continue??(r.continue=!t._zod.def.abort),o.issues.push(issue(r))}},e(o.value,o)));return t}a(_superRefine,"_superRefine");function _check(e,t){const o=new $ZodCheck({check:"custom",...normalizeParams(t)});return o._zod.check=e,o}a(_check,"_check");function initializeContext(e){let t=e?.target??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??globalRegistry,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}a(initializeContext,"initializeContext");function process(e,t,o={path:[],schemaPath:[]}){var n;const r=e._zod.def,i=t.seen.get(e);if(i)return i.count++,o.schemaPath.includes(e)&&(i.cycle=o.path),i.schema;const s={schema:{},count:1,cycle:void 0,path:o.path};t.seen.set(e,s);const c=e._zod.toJSONSchema?.();if(c)s.schema=c;else{const h={...o,schemaPath:[...o.schemaPath,e],path:o.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,s.schema,h);else{const g=s.schema,m=t.processors[r.type];if(!m)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${r.type}`);m(e,t,g,h)}const f=e._zod.parent;f&&(s.ref||(s.ref=f),process(f,t,h),t.seen.get(f).isParent=!0)}const l=t.metadataRegistry.get(e);return l&&Object.assign(s.schema,l),t.io==="input"&&isTransforming(e)&&(delete s.schema.examples,delete s.schema.default),t.io==="input"&&s.schema._prefault&&((n=s.schema).default??(n.default=s.schema._prefault)),delete s.schema._prefault,t.seen.get(e).schema}a(process,"process");function extractDefs(e,t){const o=e.seen.get(t);if(!o)throw new Error("Unprocessed schema. This is a bug in Zod.");const n=new Map;for(const s of e.seen.entries()){const c=e.metadataRegistry.get(s[0])?.id;if(c){const l=n.get(c);if(l&&l!==s[0])throw new Error(`Duplicate schema id "${c}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);n.set(c,s[0])}}const r=a(s=>{const c=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const f=e.external.registry.get(s[0])?.id,g=e.external.uri??(I=>I);if(f)return{ref:g(f)};const m=s[1].defId??s[1].schema.id??`schema${e.counter++}`;return s[1].defId=m,{defId:m,ref:`${g("__shared")}#/${c}/${m}`}}if(s[1]===o)return{ref:"#"};const d=`#/${c}/`,h=s[1].schema.id??`__schema${e.counter++}`;return{defId:h,ref:d+h}},"makeURI"),i=a(s=>{if(s[1].schema.$ref)return;const c=s[1],{ref:l,defId:d}=r(s);c.def={...c.schema},d&&(c.defId=d);const h=c.schema;for(const f in h)delete h[f];h.$ref=l},"extractToDef");if(e.cycles==="throw")for(const s of e.seen.entries()){const c=s[1];if(c.cycle)throw new Error(`Cycle detected: #/${c.cycle?.join("/")}/<root>
39
+ `)}m.write("payload.value = newResult;"),m.write("return payload;");const F=m.compile();return(k,w)=>F(g,k,w)},"generateFastpass");let i;const s=isObject,c=!globalConfig.jitless,d=c&&allowsEval.value,h=t.catchall;let f;e._zod.parse=(g,m)=>{f??(f=n.value);const I=g.value;return s(I)?c&&d&&m?.async===!1&&m.jitless!==!0?(i||(i=r(t.shape)),g=i(g,m),h?handleCatchall([],I,g,m,f,e):g):o(g,m):(g.issues.push({expected:"object",code:"invalid_type",input:I,inst:e}),g)}});function handleUnionResults(e,t,o,n){for(const i of e)if(i.issues.length===0)return t.value=i.value,t;const r=e.filter(i=>!aborted(i));return r.length===1?(t.value=r[0].value,r[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:o,errors:e.map(i=>i.issues.map(s=>finalizeIssue(s,n,config())))}),t)}a(handleUnionResults,"handleUnionResults");const $ZodUnion=$constructor("$ZodUnion",(e,t)=>{$ZodType.init(e,t),defineLazy(e._zod,"optin",()=>t.options.some(r=>r._zod.optin==="optional")?"optional":void 0),defineLazy(e._zod,"optout",()=>t.options.some(r=>r._zod.optout==="optional")?"optional":void 0),defineLazy(e._zod,"values",()=>{if(t.options.every(r=>r._zod.values))return new Set(t.options.flatMap(r=>Array.from(r._zod.values)))}),defineLazy(e._zod,"pattern",()=>{if(t.options.every(r=>r._zod.pattern)){const r=t.options.map(i=>i._zod.pattern);return new RegExp(`^(${r.map(i=>cleanRegex(i.source)).join("|")})$`)}});const o=t.options.length===1,n=t.options[0]._zod.run;e._zod.parse=(r,i)=>{if(o)return n(r,i);let s=!1;const c=[];for(const l of t.options){const d=l._zod.run({value:r.value,issues:[]},i);if(d instanceof Promise)c.push(d),s=!0;else{if(d.issues.length===0)return d;c.push(d)}}return s?Promise.all(c).then(l=>handleUnionResults(l,r,e,i)):handleUnionResults(c,r,e,i)}}),$ZodIntersection=$constructor("$ZodIntersection",(e,t)=>{$ZodType.init(e,t),e._zod.parse=(o,n)=>{const r=o.value,i=t.left._zod.run({value:r,issues:[]},n),s=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||s instanceof Promise?Promise.all([i,s]).then(([l,d])=>handleIntersectionResults(o,l,d)):handleIntersectionResults(o,i,s)}});function mergeValues(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(isPlainObject(e)&&isPlainObject(t)){const o=Object.keys(t),n=Object.keys(e).filter(i=>o.indexOf(i)!==-1),r={...e,...t};for(const i of n){const s=mergeValues(e[i],t[i]);if(!s.valid)return{valid:!1,mergeErrorPath:[i,...s.mergeErrorPath]};r[i]=s.data}return{valid:!0,data:r}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const o=[];for(let n=0;n<e.length;n++){const r=e[n],i=t[n],s=mergeValues(r,i);if(!s.valid)return{valid:!1,mergeErrorPath:[n,...s.mergeErrorPath]};o.push(s.data)}return{valid:!0,data:o}}return{valid:!1,mergeErrorPath:[]}}a(mergeValues,"mergeValues");function handleIntersectionResults(e,t,o){const n=new Map;let r;for(const c of t.issues)if(c.code==="unrecognized_keys"){r??(r=c);for(const l of c.keys)n.has(l)||n.set(l,{}),n.get(l).l=!0}else e.issues.push(c);for(const c of o.issues)if(c.code==="unrecognized_keys")for(const l of c.keys)n.has(l)||n.set(l,{}),n.get(l).r=!0;else e.issues.push(c);const i=[...n].filter(([,c])=>c.l&&c.r).map(([c])=>c);if(i.length&&r&&e.issues.push({...r,keys:i}),aborted(e))return e;const s=mergeValues(t.value,o.value);if(!s.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(s.mergeErrorPath)}`);return e.value=s.data,e}a(handleIntersectionResults,"handleIntersectionResults");const $ZodEnum=$constructor("$ZodEnum",(e,t)=>{$ZodType.init(e,t);const o=getEnumValues(t.entries),n=new Set(o);e._zod.values=n,e._zod.pattern=new RegExp(`^(${o.filter(r=>propertyKeyTypes.has(typeof r)).map(r=>typeof r=="string"?escapeRegex(r):r.toString()).join("|")})$`),e._zod.parse=(r,i)=>{const s=r.value;return n.has(s)||r.issues.push({code:"invalid_value",values:o,input:s,inst:e}),r}}),$ZodTransform=$constructor("$ZodTransform",(e,t)=>{$ZodType.init(e,t),e._zod.parse=(o,n)=>{if(n.direction==="backward")throw new $ZodEncodeError(e.constructor.name);const r=t.transform(o.value,o);if(n.async)return(r instanceof Promise?r:Promise.resolve(r)).then(s=>(o.value=s,o));if(r instanceof Promise)throw new $ZodAsyncError;return o.value=r,o}});function handleOptionalResult(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}a(handleOptionalResult,"handleOptionalResult");const $ZodOptional=$constructor("$ZodOptional",(e,t)=>{$ZodType.init(e,t),e._zod.optin="optional",e._zod.optout="optional",defineLazy(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),defineLazy(e._zod,"pattern",()=>{const o=t.innerType._zod.pattern;return o?new RegExp(`^(${cleanRegex(o.source)})?$`):void 0}),e._zod.parse=(o,n)=>{if(t.innerType._zod.optin==="optional"){const r=t.innerType._zod.run(o,n);return r instanceof Promise?r.then(i=>handleOptionalResult(i,o.value)):handleOptionalResult(r,o.value)}return o.value===void 0?o:t.innerType._zod.run(o,n)}}),$ZodExactOptional=$constructor("$ZodExactOptional",(e,t)=>{$ZodOptional.init(e,t),defineLazy(e._zod,"values",()=>t.innerType._zod.values),defineLazy(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(o,n)=>t.innerType._zod.run(o,n)}),$ZodNullable=$constructor("$ZodNullable",(e,t)=>{$ZodType.init(e,t),defineLazy(e._zod,"optin",()=>t.innerType._zod.optin),defineLazy(e._zod,"optout",()=>t.innerType._zod.optout),defineLazy(e._zod,"pattern",()=>{const o=t.innerType._zod.pattern;return o?new RegExp(`^(${cleanRegex(o.source)}|null)$`):void 0}),defineLazy(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(o,n)=>o.value===null?o:t.innerType._zod.run(o,n)}),$ZodDefault=$constructor("$ZodDefault",(e,t)=>{$ZodType.init(e,t),e._zod.optin="optional",defineLazy(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(o,n)=>{if(n.direction==="backward")return t.innerType._zod.run(o,n);if(o.value===void 0)return o.value=t.defaultValue,o;const r=t.innerType._zod.run(o,n);return r instanceof Promise?r.then(i=>handleDefaultResult(i,t)):handleDefaultResult(r,t)}});function handleDefaultResult(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}a(handleDefaultResult,"handleDefaultResult");const $ZodPrefault=$constructor("$ZodPrefault",(e,t)=>{$ZodType.init(e,t),e._zod.optin="optional",defineLazy(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(o,n)=>(n.direction==="backward"||o.value===void 0&&(o.value=t.defaultValue),t.innerType._zod.run(o,n))}),$ZodNonOptional=$constructor("$ZodNonOptional",(e,t)=>{$ZodType.init(e,t),defineLazy(e._zod,"values",()=>{const o=t.innerType._zod.values;return o?new Set([...o].filter(n=>n!==void 0)):void 0}),e._zod.parse=(o,n)=>{const r=t.innerType._zod.run(o,n);return r instanceof Promise?r.then(i=>handleNonOptionalResult(i,e)):handleNonOptionalResult(r,e)}});function handleNonOptionalResult(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}a(handleNonOptionalResult,"handleNonOptionalResult");const $ZodCatch=$constructor("$ZodCatch",(e,t)=>{$ZodType.init(e,t),defineLazy(e._zod,"optin",()=>t.innerType._zod.optin),defineLazy(e._zod,"optout",()=>t.innerType._zod.optout),defineLazy(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(o,n)=>{if(n.direction==="backward")return t.innerType._zod.run(o,n);const r=t.innerType._zod.run(o,n);return r instanceof Promise?r.then(i=>(o.value=i.value,i.issues.length&&(o.value=t.catchValue({...o,error:{issues:i.issues.map(s=>finalizeIssue(s,n,config()))},input:o.value}),o.issues=[]),o)):(o.value=r.value,r.issues.length&&(o.value=t.catchValue({...o,error:{issues:r.issues.map(i=>finalizeIssue(i,n,config()))},input:o.value}),o.issues=[]),o)}}),$ZodPipe=$constructor("$ZodPipe",(e,t)=>{$ZodType.init(e,t),defineLazy(e._zod,"values",()=>t.in._zod.values),defineLazy(e._zod,"optin",()=>t.in._zod.optin),defineLazy(e._zod,"optout",()=>t.out._zod.optout),defineLazy(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(o,n)=>{if(n.direction==="backward"){const i=t.out._zod.run(o,n);return i instanceof Promise?i.then(s=>handlePipeResult(s,t.in,n)):handlePipeResult(i,t.in,n)}const r=t.in._zod.run(o,n);return r instanceof Promise?r.then(i=>handlePipeResult(i,t.out,n)):handlePipeResult(r,t.out,n)}});function handlePipeResult(e,t,o){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},o)}a(handlePipeResult,"handlePipeResult");const $ZodReadonly=$constructor("$ZodReadonly",(e,t)=>{$ZodType.init(e,t),defineLazy(e._zod,"propValues",()=>t.innerType._zod.propValues),defineLazy(e._zod,"values",()=>t.innerType._zod.values),defineLazy(e._zod,"optin",()=>t.innerType?._zod?.optin),defineLazy(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(o,n)=>{if(n.direction==="backward")return t.innerType._zod.run(o,n);const r=t.innerType._zod.run(o,n);return r instanceof Promise?r.then(handleReadonlyResult):handleReadonlyResult(r)}});function handleReadonlyResult(e){return e.value=Object.freeze(e.value),e}a(handleReadonlyResult,"handleReadonlyResult");const $ZodCustom=$constructor("$ZodCustom",(e,t)=>{$ZodCheck.init(e,t),$ZodType.init(e,t),e._zod.parse=(o,n)=>o,e._zod.check=o=>{const n=o.value,r=t.fn(n);if(r instanceof Promise)return r.then(i=>handleRefineResult(i,o,n,e));handleRefineResult(r,o,n,e)}});function handleRefineResult(e,t,o,n){if(!e){const r={code:"custom",input:o,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(r.params=n._zod.def.params),t.issues.push(issue(r))}}a(handleRefineResult,"handleRefineResult");var _a;const Ue=class Ue{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...o){const n=o[0];return this._map.set(t,n),n&&typeof n=="object"&&"id"in n&&this._idmap.set(n.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const o=this._map.get(t);return o&&typeof o=="object"&&"id"in o&&this._idmap.delete(o.id),this._map.delete(t),this}get(t){const o=t._zod.parent;if(o){const n={...this.get(o)??{}};delete n.id;const r={...n,...this._map.get(t)};return Object.keys(r).length?r:void 0}return this._map.get(t)}has(t){return this._map.has(t)}};a(Ue,"$ZodRegistry");let $ZodRegistry=Ue;function registry(){return new $ZodRegistry}a(registry,"registry"),(_a=globalThis).__zod_globalRegistry??(_a.__zod_globalRegistry=registry());const globalRegistry=globalThis.__zod_globalRegistry;function _string(e,t){return new e({type:"string",...normalizeParams(t)})}a(_string,"_string");function _email(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...normalizeParams(t)})}a(_email,"_email");function _guid(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...normalizeParams(t)})}a(_guid,"_guid");function _uuid(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...normalizeParams(t)})}a(_uuid,"_uuid");function _uuidv4(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...normalizeParams(t)})}a(_uuidv4,"_uuidv4");function _uuidv6(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...normalizeParams(t)})}a(_uuidv6,"_uuidv6");function _uuidv7(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...normalizeParams(t)})}a(_uuidv7,"_uuidv7");function _url(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...normalizeParams(t)})}a(_url,"_url");function _emoji(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...normalizeParams(t)})}a(_emoji,"_emoji");function _nanoid(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...normalizeParams(t)})}a(_nanoid,"_nanoid");function _cuid(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...normalizeParams(t)})}a(_cuid,"_cuid");function _cuid2(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...normalizeParams(t)})}a(_cuid2,"_cuid2");function _ulid(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...normalizeParams(t)})}a(_ulid,"_ulid");function _xid(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...normalizeParams(t)})}a(_xid,"_xid");function _ksuid(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...normalizeParams(t)})}a(_ksuid,"_ksuid");function _ipv4(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...normalizeParams(t)})}a(_ipv4,"_ipv4");function _ipv6(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...normalizeParams(t)})}a(_ipv6,"_ipv6");function _cidrv4(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...normalizeParams(t)})}a(_cidrv4,"_cidrv4");function _cidrv6(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...normalizeParams(t)})}a(_cidrv6,"_cidrv6");function _base64(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...normalizeParams(t)})}a(_base64,"_base64");function _base64url(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...normalizeParams(t)})}a(_base64url,"_base64url");function _e164(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...normalizeParams(t)})}a(_e164,"_e164");function _jwt(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...normalizeParams(t)})}a(_jwt,"_jwt");function _isoDateTime(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...normalizeParams(t)})}a(_isoDateTime,"_isoDateTime");function _isoDate(e,t){return new e({type:"string",format:"date",check:"string_format",...normalizeParams(t)})}a(_isoDate,"_isoDate");function _isoTime(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...normalizeParams(t)})}a(_isoTime,"_isoTime");function _isoDuration(e,t){return new e({type:"string",format:"duration",check:"string_format",...normalizeParams(t)})}a(_isoDuration,"_isoDuration");function _number(e,t){return new e({type:"number",checks:[],...normalizeParams(t)})}a(_number,"_number");function _int(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...normalizeParams(t)})}a(_int,"_int");function _boolean(e,t){return new e({type:"boolean",...normalizeParams(t)})}a(_boolean,"_boolean");function _unknown(e){return new e({type:"unknown"})}a(_unknown,"_unknown");function _never(e,t){return new e({type:"never",...normalizeParams(t)})}a(_never,"_never");function _lt(e,t){return new $ZodCheckLessThan({check:"less_than",...normalizeParams(t),value:e,inclusive:!1})}a(_lt,"_lt");function _lte(e,t){return new $ZodCheckLessThan({check:"less_than",...normalizeParams(t),value:e,inclusive:!0})}a(_lte,"_lte");function _gt(e,t){return new $ZodCheckGreaterThan({check:"greater_than",...normalizeParams(t),value:e,inclusive:!1})}a(_gt,"_gt");function _gte(e,t){return new $ZodCheckGreaterThan({check:"greater_than",...normalizeParams(t),value:e,inclusive:!0})}a(_gte,"_gte");function _multipleOf(e,t){return new $ZodCheckMultipleOf({check:"multiple_of",...normalizeParams(t),value:e})}a(_multipleOf,"_multipleOf");function _maxLength(e,t){return new $ZodCheckMaxLength({check:"max_length",...normalizeParams(t),maximum:e})}a(_maxLength,"_maxLength");function _minLength(e,t){return new $ZodCheckMinLength({check:"min_length",...normalizeParams(t),minimum:e})}a(_minLength,"_minLength");function _length(e,t){return new $ZodCheckLengthEquals({check:"length_equals",...normalizeParams(t),length:e})}a(_length,"_length");function _regex(e,t){return new $ZodCheckRegex({check:"string_format",format:"regex",...normalizeParams(t),pattern:e})}a(_regex,"_regex");function _lowercase(e){return new $ZodCheckLowerCase({check:"string_format",format:"lowercase",...normalizeParams(e)})}a(_lowercase,"_lowercase");function _uppercase(e){return new $ZodCheckUpperCase({check:"string_format",format:"uppercase",...normalizeParams(e)})}a(_uppercase,"_uppercase");function _includes(e,t){return new $ZodCheckIncludes({check:"string_format",format:"includes",...normalizeParams(t),includes:e})}a(_includes,"_includes");function _startsWith(e,t){return new $ZodCheckStartsWith({check:"string_format",format:"starts_with",...normalizeParams(t),prefix:e})}a(_startsWith,"_startsWith");function _endsWith(e,t){return new $ZodCheckEndsWith({check:"string_format",format:"ends_with",...normalizeParams(t),suffix:e})}a(_endsWith,"_endsWith");function _overwrite(e){return new $ZodCheckOverwrite({check:"overwrite",tx:e})}a(_overwrite,"_overwrite");function _normalize(e){return _overwrite(t=>t.normalize(e))}a(_normalize,"_normalize");function _trim(){return _overwrite(e=>e.trim())}a(_trim,"_trim");function _toLowerCase(){return _overwrite(e=>e.toLowerCase())}a(_toLowerCase,"_toLowerCase");function _toUpperCase(){return _overwrite(e=>e.toUpperCase())}a(_toUpperCase,"_toUpperCase");function _slugify(){return _overwrite(e=>slugify(e))}a(_slugify,"_slugify");function _array(e,t,o){return new e({type:"array",element:t,...normalizeParams(o)})}a(_array,"_array");function _refine(e,t,o){return new e({type:"custom",check:"custom",fn:t,...normalizeParams(o)})}a(_refine,"_refine");function _superRefine(e){const t=_check(o=>(o.addIssue=n=>{if(typeof n=="string")o.issues.push(issue(n,o.value,t._zod.def));else{const r=n;r.fatal&&(r.continue=!1),r.code??(r.code="custom"),r.input??(r.input=o.value),r.inst??(r.inst=t),r.continue??(r.continue=!t._zod.def.abort),o.issues.push(issue(r))}},e(o.value,o)));return t}a(_superRefine,"_superRefine");function _check(e,t){const o=new $ZodCheck({check:"custom",...normalizeParams(t)});return o._zod.check=e,o}a(_check,"_check");function initializeContext(e){let t=e?.target??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??globalRegistry,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}a(initializeContext,"initializeContext");function process(e,t,o={path:[],schemaPath:[]}){var n;const r=e._zod.def,i=t.seen.get(e);if(i)return i.count++,o.schemaPath.includes(e)&&(i.cycle=o.path),i.schema;const s={schema:{},count:1,cycle:void 0,path:o.path};t.seen.set(e,s);const c=e._zod.toJSONSchema?.();if(c)s.schema=c;else{const h={...o,schemaPath:[...o.schemaPath,e],path:o.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,s.schema,h);else{const g=s.schema,m=t.processors[r.type];if(!m)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${r.type}`);m(e,t,g,h)}const f=e._zod.parent;f&&(s.ref||(s.ref=f),process(f,t,h),t.seen.get(f).isParent=!0)}const l=t.metadataRegistry.get(e);return l&&Object.assign(s.schema,l),t.io==="input"&&isTransforming(e)&&(delete s.schema.examples,delete s.schema.default),t.io==="input"&&s.schema._prefault&&((n=s.schema).default??(n.default=s.schema._prefault)),delete s.schema._prefault,t.seen.get(e).schema}a(process,"process");function extractDefs(e,t){const o=e.seen.get(t);if(!o)throw new Error("Unprocessed schema. This is a bug in Zod.");const n=new Map;for(const s of e.seen.entries()){const c=e.metadataRegistry.get(s[0])?.id;if(c){const l=n.get(c);if(l&&l!==s[0])throw new Error(`Duplicate schema id "${c}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);n.set(c,s[0])}}const r=a(s=>{const c=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const f=e.external.registry.get(s[0])?.id,g=e.external.uri??(I=>I);if(f)return{ref:g(f)};const m=s[1].defId??s[1].schema.id??`schema${e.counter++}`;return s[1].defId=m,{defId:m,ref:`${g("__shared")}#/${c}/${m}`}}if(s[1]===o)return{ref:"#"};const d=`#/${c}/`,h=s[1].schema.id??`__schema${e.counter++}`;return{defId:h,ref:d+h}},"makeURI"),i=a(s=>{if(s[1].schema.$ref)return;const c=s[1],{ref:l,defId:d}=r(s);c.def={...c.schema},d&&(c.defId=d);const h=c.schema;for(const f in h)delete h[f];h.$ref=l},"extractToDef");if(e.cycles==="throw")for(const s of e.seen.entries()){const c=s[1];if(c.cycle)throw new Error(`Cycle detected: #/${c.cycle?.join("/")}/<root>
43
40
 
44
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const s of e.seen.entries()){const c=s[1];if(t===s[0]){i(s);continue}if(e.external){const d=e.external.registry.get(s[0])?.id;if(t!==s[0]&&d){i(s);continue}}if(e.metadataRegistry.get(s[0])?.id){i(s);continue}if(c.cycle){i(s);continue}if(c.count>1&&e.reused==="ref"){i(s);continue}}}a(extractDefs,"extractDefs");function finalize(e,t){const o=e.seen.get(t);if(!o)throw new Error("Unprocessed schema. This is a bug in Zod.");const n=a(s=>{const c=e.seen.get(s);if(c.ref===null)return;const l=c.def??c.schema,d={...l},h=c.ref;if(c.ref=null,h){n(h);const g=e.seen.get(h),m=g.schema;if(m.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(l.allOf=l.allOf??[],l.allOf.push(m)):Object.assign(l,m),Object.assign(l,d),s._zod.parent===h)for(const S in l)S==="$ref"||S==="allOf"||S in d||delete l[S];if(m.$ref&&g.def)for(const S in l)S==="$ref"||S==="allOf"||S in g.def&&JSON.stringify(l[S])===JSON.stringify(g.def[S])&&delete l[S]}const f=s._zod.parent;if(f&&f!==h){n(f);const g=e.seen.get(f);if(g?.schema.$ref&&(l.$ref=g.schema.$ref,g.def))for(const m in l)m==="$ref"||m==="allOf"||m in g.def&&JSON.stringify(l[m])===JSON.stringify(g.def[m])&&delete l[m]}e.override({zodSchema:s,jsonSchema:l,path:c.path??[]})},"flattenRef");for(const s of[...e.seen.entries()].reverse())n(s[0]);const r={};if(e.target==="draft-2020-12"?r.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?r.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?r.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const s=e.external.registry.get(t)?.id;if(!s)throw new Error("Schema is missing an `id` property");r.$id=e.external.uri(s)}Object.assign(r,o.def??o.schema);const i=e.external?.defs??{};for(const s of e.seen.entries()){const c=s[1];c.def&&c.defId&&(i[c.defId]=c.def)}e.external||Object.keys(i).length>0&&(e.target==="draft-2020-12"?r.$defs=i:r.definitions=i);try{const s=JSON.parse(JSON.stringify(r));return Object.defineProperty(s,"~standard",{value:{...t["~standard"],jsonSchema:{input:createStandardJSONSchemaMethod(t,"input",e.processors),output:createStandardJSONSchemaMethod(t,"output",e.processors)}},enumerable:!1,writable:!1}),s}catch{throw new Error("Error converting schema to JSON.")}}a(finalize,"finalize");function isTransforming(e,t){const o=t??{seen:new Set};if(o.seen.has(e))return!1;o.seen.add(e);const n=e._zod.def;if(n.type==="transform")return!0;if(n.type==="array")return isTransforming(n.element,o);if(n.type==="set")return isTransforming(n.valueType,o);if(n.type==="lazy")return isTransforming(n.getter(),o);if(n.type==="promise"||n.type==="optional"||n.type==="nonoptional"||n.type==="nullable"||n.type==="readonly"||n.type==="default"||n.type==="prefault")return isTransforming(n.innerType,o);if(n.type==="intersection")return isTransforming(n.left,o)||isTransforming(n.right,o);if(n.type==="record"||n.type==="map")return isTransforming(n.keyType,o)||isTransforming(n.valueType,o);if(n.type==="pipe")return isTransforming(n.in,o)||isTransforming(n.out,o);if(n.type==="object"){for(const r in n.shape)if(isTransforming(n.shape[r],o))return!0;return!1}if(n.type==="union"){for(const r of n.options)if(isTransforming(r,o))return!0;return!1}if(n.type==="tuple"){for(const r of n.items)if(isTransforming(r,o))return!0;return!!(n.rest&&isTransforming(n.rest,o))}return!1}a(isTransforming,"isTransforming");const createToJSONSchemaMethod=a((e,t={})=>o=>{const n=initializeContext({...o,processors:t});return process(e,n),extractDefs(n,e),finalize(n,e)},"createToJSONSchemaMethod"),createStandardJSONSchemaMethod=a((e,t,o={})=>n=>{const{libraryOptions:r,target:i}=n??{},s=initializeContext({...r??{},target:i,io:t,processors:o});return process(e,s),extractDefs(s,e),finalize(s,e)},"createStandardJSONSchemaMethod"),formatMap={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},stringProcessor=a((e,t,o,n)=>{const r=o;r.type="string";const{minimum:i,maximum:s,format:c,patterns:l,contentEncoding:d}=e._zod.bag;if(typeof i=="number"&&(r.minLength=i),typeof s=="number"&&(r.maxLength=s),c&&(r.format=formatMap[c]??c,r.format===""&&delete r.format,c==="time"&&delete r.format),d&&(r.contentEncoding=d),l&&l.size>0){const h=[...l];h.length===1?r.pattern=h[0].source:h.length>1&&(r.allOf=[...h.map(f=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:f.source}))])}},"stringProcessor"),numberProcessor=a((e,t,o,n)=>{const r=o,{minimum:i,maximum:s,format:c,multipleOf:l,exclusiveMaximum:d,exclusiveMinimum:h}=e._zod.bag;typeof c=="string"&&c.includes("int")?r.type="integer":r.type="number",typeof h=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(r.minimum=h,r.exclusiveMinimum=!0):r.exclusiveMinimum=h),typeof i=="number"&&(r.minimum=i,typeof h=="number"&&t.target!=="draft-04"&&(h>=i?delete r.minimum:delete r.exclusiveMinimum)),typeof d=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(r.maximum=d,r.exclusiveMaximum=!0):r.exclusiveMaximum=d),typeof s=="number"&&(r.maximum=s,typeof d=="number"&&t.target!=="draft-04"&&(d<=s?delete r.maximum:delete r.exclusiveMaximum)),typeof l=="number"&&(r.multipleOf=l)},"numberProcessor"),booleanProcessor=a((e,t,o,n)=>{o.type="boolean"},"booleanProcessor"),bigintProcessor=a((e,t,o,n)=>{if(t.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema")},"bigintProcessor"),symbolProcessor=a((e,t,o,n)=>{if(t.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema")},"symbolProcessor"),nullProcessor=a((e,t,o,n)=>{t.target==="openapi-3.0"?(o.type="string",o.nullable=!0,o.enum=[null]):o.type="null"},"nullProcessor"),undefinedProcessor=a((e,t,o,n)=>{if(t.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema")},"undefinedProcessor"),voidProcessor=a((e,t,o,n)=>{if(t.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema")},"voidProcessor"),neverProcessor=a((e,t,o,n)=>{o.not={}},"neverProcessor"),anyProcessor=a((e,t,o,n)=>{},"anyProcessor"),unknownProcessor=a((e,t,o,n)=>{},"unknownProcessor"),dateProcessor=a((e,t,o,n)=>{if(t.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema")},"dateProcessor"),enumProcessor=a((e,t,o,n)=>{const r=e._zod.def,i=getEnumValues(r.entries);i.every(s=>typeof s=="number")&&(o.type="number"),i.every(s=>typeof s=="string")&&(o.type="string"),o.enum=i},"enumProcessor"),literalProcessor=a((e,t,o,n)=>{const r=e._zod.def,i=[];for(const s of r.values)if(s===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof s=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");i.push(Number(s))}else i.push(s);if(i.length!==0)if(i.length===1){const s=i[0];o.type=s===null?"null":typeof s,t.target==="draft-04"||t.target==="openapi-3.0"?o.enum=[s]:o.const=s}else i.every(s=>typeof s=="number")&&(o.type="number"),i.every(s=>typeof s=="string")&&(o.type="string"),i.every(s=>typeof s=="boolean")&&(o.type="boolean"),i.every(s=>s===null)&&(o.type="null"),o.enum=i},"literalProcessor"),nanProcessor=a((e,t,o,n)=>{if(t.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema")},"nanProcessor"),templateLiteralProcessor=a((e,t,o,n)=>{const r=o,i=e._zod.pattern;if(!i)throw new Error("Pattern not found in template literal");r.type="string",r.pattern=i.source},"templateLiteralProcessor"),fileProcessor=a((e,t,o,n)=>{const r=o,i={type:"string",format:"binary",contentEncoding:"binary"},{minimum:s,maximum:c,mime:l}=e._zod.bag;s!==void 0&&(i.minLength=s),c!==void 0&&(i.maxLength=c),l?l.length===1?(i.contentMediaType=l[0],Object.assign(r,i)):(Object.assign(r,i),r.anyOf=l.map(d=>({contentMediaType:d}))):Object.assign(r,i)},"fileProcessor"),successProcessor=a((e,t,o,n)=>{o.type="boolean"},"successProcessor"),customProcessor=a((e,t,o,n)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},"customProcessor"),functionProcessor=a((e,t,o,n)=>{if(t.unrepresentable==="throw")throw new Error("Function types cannot be represented in JSON Schema")},"functionProcessor"),transformProcessor=a((e,t,o,n)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},"transformProcessor"),mapProcessor=a((e,t,o,n)=>{if(t.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema")},"mapProcessor"),setProcessor=a((e,t,o,n)=>{if(t.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema")},"setProcessor"),arrayProcessor=a((e,t,o,n)=>{const r=o,i=e._zod.def,{minimum:s,maximum:c}=e._zod.bag;typeof s=="number"&&(r.minItems=s),typeof c=="number"&&(r.maxItems=c),r.type="array",r.items=process(i.element,t,{...n,path:[...n.path,"items"]})},"arrayProcessor"),objectProcessor=a((e,t,o,n)=>{const r=o,i=e._zod.def;r.type="object",r.properties={};const s=i.shape;for(const d in s)r.properties[d]=process(s[d],t,{...n,path:[...n.path,"properties",d]});const c=new Set(Object.keys(s)),l=new Set([...c].filter(d=>{const h=i.shape[d]._zod;return t.io==="input"?h.optin===void 0:h.optout===void 0}));l.size>0&&(r.required=Array.from(l)),i.catchall?._zod.def.type==="never"?r.additionalProperties=!1:i.catchall?i.catchall&&(r.additionalProperties=process(i.catchall,t,{...n,path:[...n.path,"additionalProperties"]})):t.io==="output"&&(r.additionalProperties=!1)},"objectProcessor"),unionProcessor=a((e,t,o,n)=>{const r=e._zod.def,i=r.inclusive===!1,s=r.options.map((c,l)=>process(c,t,{...n,path:[...n.path,i?"oneOf":"anyOf",l]}));i?o.oneOf=s:o.anyOf=s},"unionProcessor"),intersectionProcessor=a((e,t,o,n)=>{const r=e._zod.def,i=process(r.left,t,{...n,path:[...n.path,"allOf",0]}),s=process(r.right,t,{...n,path:[...n.path,"allOf",1]}),c=a(d=>"allOf"in d&&Object.keys(d).length===1,"isSimpleIntersection"),l=[...c(i)?i.allOf:[i],...c(s)?s.allOf:[s]];o.allOf=l},"intersectionProcessor"),tupleProcessor=a((e,t,o,n)=>{const r=o,i=e._zod.def;r.type="array";const s=t.target==="draft-2020-12"?"prefixItems":"items",c=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",l=i.items.map((g,m)=>process(g,t,{...n,path:[...n.path,s,m]})),d=i.rest?process(i.rest,t,{...n,path:[...n.path,c,...t.target==="openapi-3.0"?[i.items.length]:[]]}):null;t.target==="draft-2020-12"?(r.prefixItems=l,d&&(r.items=d)):t.target==="openapi-3.0"?(r.items={anyOf:l},d&&r.items.anyOf.push(d),r.minItems=l.length,d||(r.maxItems=l.length)):(r.items=l,d&&(r.additionalItems=d));const{minimum:h,maximum:f}=e._zod.bag;typeof h=="number"&&(r.minItems=h),typeof f=="number"&&(r.maxItems=f)},"tupleProcessor"),recordProcessor=a((e,t,o,n)=>{const r=o,i=e._zod.def;r.type="object";const s=i.keyType,l=s._zod.bag?.patterns;if(i.mode==="loose"&&l&&l.size>0){const h=process(i.valueType,t,{...n,path:[...n.path,"patternProperties","*"]});r.patternProperties={};for(const f of l)r.patternProperties[f.source]=h}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(r.propertyNames=process(i.keyType,t,{...n,path:[...n.path,"propertyNames"]})),r.additionalProperties=process(i.valueType,t,{...n,path:[...n.path,"additionalProperties"]});const d=s._zod.values;if(d){const h=[...d].filter(f=>typeof f=="string"||typeof f=="number");h.length>0&&(r.required=h)}},"recordProcessor"),nullableProcessor=a((e,t,o,n)=>{const r=e._zod.def,i=process(r.innerType,t,n),s=t.seen.get(e);t.target==="openapi-3.0"?(s.ref=r.innerType,o.nullable=!0):o.anyOf=[i,{type:"null"}]},"nullableProcessor"),nonoptionalProcessor=a((e,t,o,n)=>{const r=e._zod.def;process(r.innerType,t,n);const i=t.seen.get(e);i.ref=r.innerType},"nonoptionalProcessor"),defaultProcessor=a((e,t,o,n)=>{const r=e._zod.def;process(r.innerType,t,n);const i=t.seen.get(e);i.ref=r.innerType,o.default=JSON.parse(JSON.stringify(r.defaultValue))},"defaultProcessor"),prefaultProcessor=a((e,t,o,n)=>{const r=e._zod.def;process(r.innerType,t,n);const i=t.seen.get(e);i.ref=r.innerType,t.io==="input"&&(o._prefault=JSON.parse(JSON.stringify(r.defaultValue)))},"prefaultProcessor"),catchProcessor=a((e,t,o,n)=>{const r=e._zod.def;process(r.innerType,t,n);const i=t.seen.get(e);i.ref=r.innerType;let s;try{s=r.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}o.default=s},"catchProcessor"),pipeProcessor=a((e,t,o,n)=>{const r=e._zod.def,i=t.io==="input"?r.in._zod.def.type==="transform"?r.out:r.in:r.out;process(i,t,n);const s=t.seen.get(e);s.ref=i},"pipeProcessor"),readonlyProcessor=a((e,t,o,n)=>{const r=e._zod.def;process(r.innerType,t,n);const i=t.seen.get(e);i.ref=r.innerType,o.readOnly=!0},"readonlyProcessor"),promiseProcessor=a((e,t,o,n)=>{const r=e._zod.def;process(r.innerType,t,n);const i=t.seen.get(e);i.ref=r.innerType},"promiseProcessor"),optionalProcessor=a((e,t,o,n)=>{const r=e._zod.def;process(r.innerType,t,n);const i=t.seen.get(e);i.ref=r.innerType},"optionalProcessor"),lazyProcessor=a((e,t,o,n)=>{const r=e._zod.innerType;process(r,t,n);const i=t.seen.get(e);i.ref=r},"lazyProcessor"),allProcessors={string:stringProcessor,number:numberProcessor,boolean:booleanProcessor,bigint:bigintProcessor,symbol:symbolProcessor,null:nullProcessor,undefined:undefinedProcessor,void:voidProcessor,never:neverProcessor,any:anyProcessor,unknown:unknownProcessor,date:dateProcessor,enum:enumProcessor,literal:literalProcessor,nan:nanProcessor,template_literal:templateLiteralProcessor,file:fileProcessor,success:successProcessor,custom:customProcessor,function:functionProcessor,transform:transformProcessor,map:mapProcessor,set:setProcessor,array:arrayProcessor,object:objectProcessor,union:unionProcessor,intersection:intersectionProcessor,tuple:tupleProcessor,record:recordProcessor,nullable:nullableProcessor,nonoptional:nonoptionalProcessor,default:defaultProcessor,prefault:prefaultProcessor,catch:catchProcessor,pipe:pipeProcessor,readonly:readonlyProcessor,promise:promiseProcessor,optional:optionalProcessor,lazy:lazyProcessor};function toJSONSchema(e,t){if("_idmap"in e){const n=e,r=initializeContext({...t,processors:allProcessors}),i={};for(const l of n._idmap.entries()){const[d,h]=l;process(h,r)}const s={},c={registry:n,uri:t?.uri,defs:i};r.external=c;for(const l of n._idmap.entries()){const[d,h]=l;extractDefs(r,h),s[d]=finalize(r,h)}if(Object.keys(i).length>0){const l=r.target==="draft-2020-12"?"$defs":"definitions";s.__shared={[l]:i}}return{schemas:s}}const o=initializeContext({...t,processors:allProcessors});return process(e,o),extractDefs(o,e),finalize(o,e)}a(toJSONSchema,"toJSONSchema");const ZodISODateTime=$constructor("ZodISODateTime",(e,t)=>{$ZodISODateTime.init(e,t),ZodStringFormat.init(e,t)});function datetime(e){return _isoDateTime(ZodISODateTime,e)}a(datetime,"datetime");const ZodISODate=$constructor("ZodISODate",(e,t)=>{$ZodISODate.init(e,t),ZodStringFormat.init(e,t)});function date(e){return _isoDate(ZodISODate,e)}a(date,"date");const ZodISOTime=$constructor("ZodISOTime",(e,t)=>{$ZodISOTime.init(e,t),ZodStringFormat.init(e,t)});function time(e){return _isoTime(ZodISOTime,e)}a(time,"time");const ZodISODuration=$constructor("ZodISODuration",(e,t)=>{$ZodISODuration.init(e,t),ZodStringFormat.init(e,t)});function duration(e){return _isoDuration(ZodISODuration,e)}a(duration,"duration");const initializer=a((e,t)=>{$ZodError.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:a(o=>formatError(e,o),"value")},flatten:{value:a(o=>flattenError(e,o),"value")},addIssue:{value:a(o=>{e.issues.push(o),e.message=JSON.stringify(e.issues,jsonStringifyReplacer,2)},"value")},addIssues:{value:a(o=>{e.issues.push(...o),e.message=JSON.stringify(e.issues,jsonStringifyReplacer,2)},"value")},isEmpty:{get(){return e.issues.length===0}}})},"initializer"),ZodRealError=$constructor("ZodError",initializer,{Parent:Error}),parse=_parse(ZodRealError),parseAsync=_parseAsync(ZodRealError),safeParse=_safeParse(ZodRealError),safeParseAsync=_safeParseAsync(ZodRealError),encode=_encode(ZodRealError),decode=_decode(ZodRealError),encodeAsync=_encodeAsync(ZodRealError),decodeAsync=_decodeAsync(ZodRealError),safeEncode=_safeEncode(ZodRealError),safeDecode=_safeDecode(ZodRealError),safeEncodeAsync=_safeEncodeAsync(ZodRealError),safeDecodeAsync=_safeDecodeAsync(ZodRealError),ZodType=$constructor("ZodType",(e,t)=>($ZodType.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:createStandardJSONSchemaMethod(e,"input"),output:createStandardJSONSchemaMethod(e,"output")}}),e.toJSONSchema=createToJSONSchemaMethod(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...o)=>e.clone(mergeDefs(t,{checks:[...t.checks??[],...o.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0}),e.with=e.check,e.clone=(o,n)=>clone(e,o,n),e.brand=()=>e,e.register=((o,n)=>(o.add(e,n),e)),e.parse=(o,n)=>parse(e,o,n,{callee:e.parse}),e.safeParse=(o,n)=>safeParse(e,o,n),e.parseAsync=async(o,n)=>parseAsync(e,o,n,{callee:e.parseAsync}),e.safeParseAsync=async(o,n)=>safeParseAsync(e,o,n),e.spa=e.safeParseAsync,e.encode=(o,n)=>encode(e,o,n),e.decode=(o,n)=>decode(e,o,n),e.encodeAsync=async(o,n)=>encodeAsync(e,o,n),e.decodeAsync=async(o,n)=>decodeAsync(e,o,n),e.safeEncode=(o,n)=>safeEncode(e,o,n),e.safeDecode=(o,n)=>safeDecode(e,o,n),e.safeEncodeAsync=async(o,n)=>safeEncodeAsync(e,o,n),e.safeDecodeAsync=async(o,n)=>safeDecodeAsync(e,o,n),e.refine=(o,n)=>e.check(refine(o,n)),e.superRefine=o=>e.check(superRefine(o)),e.overwrite=o=>e.check(_overwrite(o)),e.optional=()=>optional(e),e.exactOptional=()=>exactOptional(e),e.nullable=()=>nullable(e),e.nullish=()=>optional(nullable(e)),e.nonoptional=o=>nonoptional(e,o),e.array=()=>array(e),e.or=o=>union([e,o]),e.and=o=>intersection(e,o),e.transform=o=>pipe(e,transform(o)),e.default=o=>_default(e,o),e.prefault=o=>prefault(e,o),e.catch=o=>_catch(e,o),e.pipe=o=>pipe(e,o),e.readonly=()=>readonly(e),e.describe=o=>{const n=e.clone();return globalRegistry.add(n,{description:o}),n},Object.defineProperty(e,"description",{get(){return globalRegistry.get(e)?.description},configurable:!0}),e.meta=(...o)=>{if(o.length===0)return globalRegistry.get(e);const n=e.clone();return globalRegistry.add(n,o[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=o=>o(e),e)),_ZodString=$constructor("_ZodString",(e,t)=>{$ZodString.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(n,r,i)=>stringProcessor(e,n,r);const o=e._zod.bag;e.format=o.format??null,e.minLength=o.minimum??null,e.maxLength=o.maximum??null,e.regex=(...n)=>e.check(_regex(...n)),e.includes=(...n)=>e.check(_includes(...n)),e.startsWith=(...n)=>e.check(_startsWith(...n)),e.endsWith=(...n)=>e.check(_endsWith(...n)),e.min=(...n)=>e.check(_minLength(...n)),e.max=(...n)=>e.check(_maxLength(...n)),e.length=(...n)=>e.check(_length(...n)),e.nonempty=(...n)=>e.check(_minLength(1,...n)),e.lowercase=n=>e.check(_lowercase(n)),e.uppercase=n=>e.check(_uppercase(n)),e.trim=()=>e.check(_trim()),e.normalize=(...n)=>e.check(_normalize(...n)),e.toLowerCase=()=>e.check(_toLowerCase()),e.toUpperCase=()=>e.check(_toUpperCase()),e.slugify=()=>e.check(_slugify())}),ZodString=$constructor("ZodString",(e,t)=>{$ZodString.init(e,t),_ZodString.init(e,t),e.email=o=>e.check(_email(ZodEmail,o)),e.url=o=>e.check(_url(ZodURL,o)),e.jwt=o=>e.check(_jwt(ZodJWT,o)),e.emoji=o=>e.check(_emoji(ZodEmoji,o)),e.guid=o=>e.check(_guid(ZodGUID,o)),e.uuid=o=>e.check(_uuid(ZodUUID,o)),e.uuidv4=o=>e.check(_uuidv4(ZodUUID,o)),e.uuidv6=o=>e.check(_uuidv6(ZodUUID,o)),e.uuidv7=o=>e.check(_uuidv7(ZodUUID,o)),e.nanoid=o=>e.check(_nanoid(ZodNanoID,o)),e.guid=o=>e.check(_guid(ZodGUID,o)),e.cuid=o=>e.check(_cuid(ZodCUID,o)),e.cuid2=o=>e.check(_cuid2(ZodCUID2,o)),e.ulid=o=>e.check(_ulid(ZodULID,o)),e.base64=o=>e.check(_base64(ZodBase64,o)),e.base64url=o=>e.check(_base64url(ZodBase64URL,o)),e.xid=o=>e.check(_xid(ZodXID,o)),e.ksuid=o=>e.check(_ksuid(ZodKSUID,o)),e.ipv4=o=>e.check(_ipv4(ZodIPv4,o)),e.ipv6=o=>e.check(_ipv6(ZodIPv6,o)),e.cidrv4=o=>e.check(_cidrv4(ZodCIDRv4,o)),e.cidrv6=o=>e.check(_cidrv6(ZodCIDRv6,o)),e.e164=o=>e.check(_e164(ZodE164,o)),e.datetime=o=>e.check(datetime(o)),e.date=o=>e.check(date(o)),e.time=o=>e.check(time(o)),e.duration=o=>e.check(duration(o))});function string(e){return _string(ZodString,e)}a(string,"string");const ZodStringFormat=$constructor("ZodStringFormat",(e,t)=>{$ZodStringFormat.init(e,t),_ZodString.init(e,t)}),ZodEmail=$constructor("ZodEmail",(e,t)=>{$ZodEmail.init(e,t),ZodStringFormat.init(e,t)}),ZodGUID=$constructor("ZodGUID",(e,t)=>{$ZodGUID.init(e,t),ZodStringFormat.init(e,t)}),ZodUUID=$constructor("ZodUUID",(e,t)=>{$ZodUUID.init(e,t),ZodStringFormat.init(e,t)}),ZodURL=$constructor("ZodURL",(e,t)=>{$ZodURL.init(e,t),ZodStringFormat.init(e,t)}),ZodEmoji=$constructor("ZodEmoji",(e,t)=>{$ZodEmoji.init(e,t),ZodStringFormat.init(e,t)}),ZodNanoID=$constructor("ZodNanoID",(e,t)=>{$ZodNanoID.init(e,t),ZodStringFormat.init(e,t)}),ZodCUID=$constructor("ZodCUID",(e,t)=>{$ZodCUID.init(e,t),ZodStringFormat.init(e,t)}),ZodCUID2=$constructor("ZodCUID2",(e,t)=>{$ZodCUID2.init(e,t),ZodStringFormat.init(e,t)}),ZodULID=$constructor("ZodULID",(e,t)=>{$ZodULID.init(e,t),ZodStringFormat.init(e,t)}),ZodXID=$constructor("ZodXID",(e,t)=>{$ZodXID.init(e,t),ZodStringFormat.init(e,t)}),ZodKSUID=$constructor("ZodKSUID",(e,t)=>{$ZodKSUID.init(e,t),ZodStringFormat.init(e,t)}),ZodIPv4=$constructor("ZodIPv4",(e,t)=>{$ZodIPv4.init(e,t),ZodStringFormat.init(e,t)}),ZodIPv6=$constructor("ZodIPv6",(e,t)=>{$ZodIPv6.init(e,t),ZodStringFormat.init(e,t)}),ZodCIDRv4=$constructor("ZodCIDRv4",(e,t)=>{$ZodCIDRv4.init(e,t),ZodStringFormat.init(e,t)}),ZodCIDRv6=$constructor("ZodCIDRv6",(e,t)=>{$ZodCIDRv6.init(e,t),ZodStringFormat.init(e,t)}),ZodBase64=$constructor("ZodBase64",(e,t)=>{$ZodBase64.init(e,t),ZodStringFormat.init(e,t)}),ZodBase64URL=$constructor("ZodBase64URL",(e,t)=>{$ZodBase64URL.init(e,t),ZodStringFormat.init(e,t)}),ZodE164=$constructor("ZodE164",(e,t)=>{$ZodE164.init(e,t),ZodStringFormat.init(e,t)}),ZodJWT=$constructor("ZodJWT",(e,t)=>{$ZodJWT.init(e,t),ZodStringFormat.init(e,t)}),ZodNumber=$constructor("ZodNumber",(e,t)=>{$ZodNumber.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(n,r,i)=>numberProcessor(e,n,r),e.gt=(n,r)=>e.check(_gt(n,r)),e.gte=(n,r)=>e.check(_gte(n,r)),e.min=(n,r)=>e.check(_gte(n,r)),e.lt=(n,r)=>e.check(_lt(n,r)),e.lte=(n,r)=>e.check(_lte(n,r)),e.max=(n,r)=>e.check(_lte(n,r)),e.int=n=>e.check(int(n)),e.safe=n=>e.check(int(n)),e.positive=n=>e.check(_gt(0,n)),e.nonnegative=n=>e.check(_gte(0,n)),e.negative=n=>e.check(_lt(0,n)),e.nonpositive=n=>e.check(_lte(0,n)),e.multipleOf=(n,r)=>e.check(_multipleOf(n,r)),e.step=(n,r)=>e.check(_multipleOf(n,r)),e.finite=()=>e;const o=e._zod.bag;e.minValue=Math.max(o.minimum??Number.NEGATIVE_INFINITY,o.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(o.maximum??Number.POSITIVE_INFINITY,o.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(o.format??"").includes("int")||Number.isSafeInteger(o.multipleOf??.5),e.isFinite=!0,e.format=o.format??null});function number(e){return _number(ZodNumber,e)}a(number,"number");const ZodNumberFormat=$constructor("ZodNumberFormat",(e,t)=>{$ZodNumberFormat.init(e,t),ZodNumber.init(e,t)});function int(e){return _int(ZodNumberFormat,e)}a(int,"int");const ZodBoolean=$constructor("ZodBoolean",(e,t)=>{$ZodBoolean.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(o,n,r)=>booleanProcessor(e,o,n)});function boolean(e){return _boolean(ZodBoolean,e)}a(boolean,"boolean");const ZodUnknown=$constructor("ZodUnknown",(e,t)=>{$ZodUnknown.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(o,n,r)=>unknownProcessor()});function unknown(){return _unknown(ZodUnknown)}a(unknown,"unknown");const ZodNever=$constructor("ZodNever",(e,t)=>{$ZodNever.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(o,n,r)=>neverProcessor(e,o,n)});function never(e){return _never(ZodNever,e)}a(never,"never");const ZodArray=$constructor("ZodArray",(e,t)=>{$ZodArray.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(o,n,r)=>arrayProcessor(e,o,n,r),e.element=t.element,e.min=(o,n)=>e.check(_minLength(o,n)),e.nonempty=o=>e.check(_minLength(1,o)),e.max=(o,n)=>e.check(_maxLength(o,n)),e.length=(o,n)=>e.check(_length(o,n)),e.unwrap=()=>e.element});function array(e,t){return _array(ZodArray,e,t)}a(array,"array");const ZodObject=$constructor("ZodObject",(e,t)=>{$ZodObjectJIT.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(o,n,r)=>objectProcessor(e,o,n,r),defineLazy(e,"shape",()=>t.shape),e.keyof=()=>_enum(Object.keys(e._zod.def.shape)),e.catchall=o=>e.clone({...e._zod.def,catchall:o}),e.passthrough=()=>e.clone({...e._zod.def,catchall:unknown()}),e.loose=()=>e.clone({...e._zod.def,catchall:unknown()}),e.strict=()=>e.clone({...e._zod.def,catchall:never()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=o=>extend(e,o),e.safeExtend=o=>safeExtend(e,o),e.merge=o=>merge(e,o),e.pick=o=>pick(e,o),e.omit=o=>omit(e,o),e.partial=(...o)=>partial(ZodOptional,e,o[0]),e.required=(...o)=>required(ZodNonOptional,e,o[0])});function object(e,t){const o={type:"object",shape:e??{},...normalizeParams(t)};return new ZodObject(o)}a(object,"object");const ZodUnion=$constructor("ZodUnion",(e,t)=>{$ZodUnion.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(o,n,r)=>unionProcessor(e,o,n,r),e.options=t.options});function union(e,t){return new ZodUnion({type:"union",options:e,...normalizeParams(t)})}a(union,"union");const ZodIntersection=$constructor("ZodIntersection",(e,t)=>{$ZodIntersection.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(o,n,r)=>intersectionProcessor(e,o,n,r)});function intersection(e,t){return new ZodIntersection({type:"intersection",left:e,right:t})}a(intersection,"intersection");const ZodEnum=$constructor("ZodEnum",(e,t)=>{$ZodEnum.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(n,r,i)=>enumProcessor(e,n,r),e.enum=t.entries,e.options=Object.values(t.entries);const o=new Set(Object.keys(t.entries));e.extract=(n,r)=>{const i={};for(const s of n)if(o.has(s))i[s]=t.entries[s];else throw new Error(`Key ${s} not found in enum`);return new ZodEnum({...t,checks:[],...normalizeParams(r),entries:i})},e.exclude=(n,r)=>{const i={...t.entries};for(const s of n)if(o.has(s))delete i[s];else throw new Error(`Key ${s} not found in enum`);return new ZodEnum({...t,checks:[],...normalizeParams(r),entries:i})}});function _enum(e,t){const o=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new ZodEnum({type:"enum",entries:o,...normalizeParams(t)})}a(_enum,"_enum");const ZodTransform=$constructor("ZodTransform",(e,t)=>{$ZodTransform.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(o,n,r)=>transformProcessor(e,o),e._zod.parse=(o,n)=>{if(n.direction==="backward")throw new $ZodEncodeError(e.constructor.name);o.addIssue=i=>{if(typeof i=="string")o.issues.push(issue(i,o.value,t));else{const s=i;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),s.input??(s.input=o.value),s.inst??(s.inst=e),o.issues.push(issue(s))}};const r=t.transform(o.value,o);return r instanceof Promise?r.then(i=>(o.value=i,o)):(o.value=r,o)}});function transform(e){return new ZodTransform({type:"transform",transform:e})}a(transform,"transform");const ZodOptional=$constructor("ZodOptional",(e,t)=>{$ZodOptional.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(o,n,r)=>optionalProcessor(e,o,n,r),e.unwrap=()=>e._zod.def.innerType});function optional(e){return new ZodOptional({type:"optional",innerType:e})}a(optional,"optional");const ZodExactOptional=$constructor("ZodExactOptional",(e,t)=>{$ZodExactOptional.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(o,n,r)=>optionalProcessor(e,o,n,r),e.unwrap=()=>e._zod.def.innerType});function exactOptional(e){return new ZodExactOptional({type:"optional",innerType:e})}a(exactOptional,"exactOptional");const ZodNullable=$constructor("ZodNullable",(e,t)=>{$ZodNullable.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(o,n,r)=>nullableProcessor(e,o,n,r),e.unwrap=()=>e._zod.def.innerType});function nullable(e){return new ZodNullable({type:"nullable",innerType:e})}a(nullable,"nullable");const ZodDefault=$constructor("ZodDefault",(e,t)=>{$ZodDefault.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(o,n,r)=>defaultProcessor(e,o,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function _default(e,t){return new ZodDefault({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():shallowClone(t)}})}a(_default,"_default");const ZodPrefault=$constructor("ZodPrefault",(e,t)=>{$ZodPrefault.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(o,n,r)=>prefaultProcessor(e,o,n,r),e.unwrap=()=>e._zod.def.innerType});function prefault(e,t){return new ZodPrefault({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():shallowClone(t)}})}a(prefault,"prefault");const ZodNonOptional=$constructor("ZodNonOptional",(e,t)=>{$ZodNonOptional.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(o,n,r)=>nonoptionalProcessor(e,o,n,r),e.unwrap=()=>e._zod.def.innerType});function nonoptional(e,t){return new ZodNonOptional({type:"nonoptional",innerType:e,...normalizeParams(t)})}a(nonoptional,"nonoptional");const ZodCatch=$constructor("ZodCatch",(e,t)=>{$ZodCatch.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(o,n,r)=>catchProcessor(e,o,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function _catch(e,t){return new ZodCatch({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}a(_catch,"_catch");const ZodPipe=$constructor("ZodPipe",(e,t)=>{$ZodPipe.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(o,n,r)=>pipeProcessor(e,o,n,r),e.in=t.in,e.out=t.out});function pipe(e,t){return new ZodPipe({type:"pipe",in:e,out:t})}a(pipe,"pipe");const ZodReadonly=$constructor("ZodReadonly",(e,t)=>{$ZodReadonly.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(o,n,r)=>readonlyProcessor(e,o,n,r),e.unwrap=()=>e._zod.def.innerType});function readonly(e){return new ZodReadonly({type:"readonly",innerType:e})}a(readonly,"readonly");const ZodCustom=$constructor("ZodCustom",(e,t)=>{$ZodCustom.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(o,n,r)=>customProcessor(e,o)});function refine(e,t={}){return _refine(ZodCustom,e,t)}a(refine,"refine");function superRefine(e){return _superRefine(e)}a(superRefine,"superRefine");function debug(e){console.debug(chalk.gray("[LLM]"),e)}a(debug,"debug");function zodToOpenAITool(e,t){return{type:"function",function:{name:e,description:t.description,parameters:toJSONSchema(t.inputSchema,{target:"openapi-3.0"})}}}a(zodToOpenAITool,"zodToOpenAITool");function modelPatch(e){const t=e.model||"";if(!t)return e;const o=normalizeModelName(t);return o.startsWith("qwen")&&(debug("Applying Qwen patch: use higher temperature for auto fixing"),e.temperature=Math.max(e.temperature||0,1)),o.startsWith("claude")&&(debug("Applying Claude patch: disable thinking"),e.thinking={type:"disabled"},e.tool_choice==="required"?(debug('Applying Claude patch: convert tool_choice "required" to { type: "any" }'),e.tool_choice={type:"any"}):e.tool_choice?.function?.name&&(debug("Applying Claude patch: convert tool_choice format"),e.tool_choice={type:"tool",name:e.tool_choice.function.name})),o.startsWith("grok")&&(debug("Applying Grok patch: removing tool_choice"),delete e.tool_choice,debug("Applying Grok patch: disable reasoning and thinking"),e.thinking={type:"disabled",effort:"minimal"},e.reasoning={enabled:!1,effort:"low"}),o.startsWith("gpt")&&(debug("Applying GPT patch: set verbosity to low"),e.verbosity="low",o.startsWith("gpt-52")?(debug("Applying GPT-52 patch: disable reasoning"),e.reasoning_effort="none"):o.startsWith("gpt-51")?(debug("Applying GPT-51 patch: disable reasoning"),e.reasoning_effort="none"):o.startsWith("gpt-5-mini")?(debug("Applying GPT-5-mini patch: set reasoning effort to low, temperature to 1"),e.reasoning_effort="low",e.temperature=1):o.startsWith("gpt-5")&&(debug("Applying GPT-5 patch: set reasoning effort to low"),e.reasoning_effort="low")),o.startsWith("gemini")&&(debug("Applying Gemini patch: set reasoning effort to minimal"),e.reasoning_effort="minimal"),e}a(modelPatch,"modelPatch");function normalizeModelName(e){let t=e.toLowerCase();return t.includes("/")&&(t=t.split("/")[1]),t=t.replace(/_/g,""),t=t.replace(/\./g,""),t}a(normalizeModelName,"normalizeModelName");const ct=class ct{config;fetch;constructor(t){this.config=t,this.fetch=t.customFetch}async invoke(t,o,n,r){const i=Object.entries(o).map(([k,w])=>zodToOpenAITool(k,w)),s={model:this.config.model,temperature:this.config.temperature,messages:t,tools:i,parallel_tool_calls:!1,tool_choice:r?.toolChoiceName?{type:"function",function:{name:r.toolChoiceName}}:"required"};modelPatch(s);let c;try{c=await this.fetch(`${this.config.baseURL}/chat/completions`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.config.apiKey}`},body:JSON.stringify(s),signal:n})}catch(k){const w=k?.name==="AbortError",A=w?"Network request aborted":"Network request failed";throw w||console.error(k),new InvokeError(InvokeErrorType.NETWORK_ERROR,A,k)}if(!c.ok){const k=await c.json().catch(),w=k.error?.message||c.statusText;throw c.status===401||c.status===403?new InvokeError(InvokeErrorType.AUTH_ERROR,`Authentication failed: ${w}`,k):c.status===429?new InvokeError(InvokeErrorType.RATE_LIMIT,`Rate limit exceeded: ${w}`,k):c.status>=500?new InvokeError(InvokeErrorType.SERVER_ERROR,`Server error: ${w}`,k):new InvokeError(InvokeErrorType.UNKNOWN,`HTTP ${c.status}: ${w}`,k)}const l=await c.json(),d=l.choices?.[0];if(!d)throw new InvokeError(InvokeErrorType.UNKNOWN,"No choices in response",l);switch(d.finish_reason){case"tool_calls":case"function_call":case"stop":break;case"length":throw new InvokeError(InvokeErrorType.CONTEXT_LENGTH,"Response truncated: max tokens reached",void 0,l);case"content_filter":throw new InvokeError(InvokeErrorType.CONTENT_FILTER,"Content filtered by safety system",void 0,l);default:throw new InvokeError(InvokeErrorType.UNKNOWN,`Unexpected finish_reason: ${d.finish_reason}`,void 0,l)}const f=(r?.normalizeResponse?r.normalizeResponse(l):l).choices?.[0],g=f?.message?.tool_calls?.[0]?.function?.name;if(!g)throw new InvokeError(InvokeErrorType.NO_TOOL_CALL,"No tool call found in response",void 0,l);const m=o[g];if(!m)throw new InvokeError(InvokeErrorType.UNKNOWN,`Tool "${g}" not found in tools`,void 0,l);const I=f.message?.tool_calls?.[0]?.function?.arguments;if(!I)throw new InvokeError(InvokeErrorType.INVALID_TOOL_ARGS,"No tool call arguments found",void 0,l);let S;try{S=JSON.parse(I)}catch(k){throw new InvokeError(InvokeErrorType.INVALID_TOOL_ARGS,"Failed to parse tool arguments as JSON",k,l)}const P=m.inputSchema.safeParse(S);if(!P.success)throw console.error(P.error),new InvokeError(InvokeErrorType.INVALID_TOOL_ARGS,"Tool arguments validation failed",P.error,l);const R=P.data;let D;try{D=await m.execute(R)}catch(k){throw new InvokeError(InvokeErrorType.TOOL_EXECUTION_ERROR,`Tool execution failed: ${k.message}`,k,l)}return{toolCall:{name:g,args:R},toolResult:D,usage:{promptTokens:l.usage?.prompt_tokens??0,completionTokens:l.usage?.completion_tokens??0,totalTokens:l.usage?.total_tokens??0,cachedTokens:l.usage?.prompt_tokens_details?.cached_tokens,reasoningTokens:l.usage?.completion_tokens_details?.reasoning_tokens},rawResponse:l,rawRequest:s}}};a(ct,"OpenAIClient");let OpenAIClient=ct;const LLM_MAX_RETRIES=2,DEFAULT_TEMPERATURE=.7;function parseLLMConfig(e){if(!e.baseURL||!e.apiKey||!e.model)throw new Error("[PageAgent] LLM configuration required. Please provide: baseURL, apiKey, model. See: https://alibaba.github.io/page-agent/#/docs/features/models");return{baseURL:e.baseURL,apiKey:e.apiKey,model:e.model,temperature:e.temperature??DEFAULT_TEMPERATURE,maxRetries:e.maxRetries??LLM_MAX_RETRIES,customFetch:(e.customFetch??fetch).bind(globalThis)}}a(parseLLMConfig,"parseLLMConfig");const lt=class lt extends EventTarget{config;client;constructor(t){super(),this.config=parseLLMConfig(t),this.client=new OpenAIClient(this.config)}async invoke(t,o,n,r){return await withRetry(async()=>{if(n.aborted)throw new Error("AbortError");return await this.client.invoke(t,o,n,r)},{maxRetries:this.config.maxRetries,onRetry:a(i=>{this.dispatchEvent(new CustomEvent("retry",{detail:{attempt:i,maxAttempts:this.config.maxRetries}}))},"onRetry"),onError:a(i=>{this.dispatchEvent(new CustomEvent("error",{detail:{error:i}}))},"onError")})}};a(lt,"LLM");let LLM=lt;async function withRetry(e,t){let o=0,n=null;for(;o<=t.maxRetries;){o>0&&(t.onRetry(o),await new Promise(r=>setTimeout(r,100)));try{return await e()}catch(r){if(r?.rawError?.name==="AbortError"||(console.error(r),t.onError(r),r instanceof InvokeError&&!r.retryable))throw r;n=r,o++,await new Promise(i=>setTimeout(i,100))}}throw n}a(withRetry,"withRetry");const DEFAULT_MAX_STEPS=20,SYSTEM_PROMPT=`You are an AI agent designed to operate in an iterative loop to automate browser tasks. Your ultimate goal is accomplishing the task provided in <user_request>.
41
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const s of e.seen.entries()){const c=s[1];if(t===s[0]){i(s);continue}if(e.external){const d=e.external.registry.get(s[0])?.id;if(t!==s[0]&&d){i(s);continue}}if(e.metadataRegistry.get(s[0])?.id){i(s);continue}if(c.cycle){i(s);continue}if(c.count>1&&e.reused==="ref"){i(s);continue}}}a(extractDefs,"extractDefs");function finalize(e,t){const o=e.seen.get(t);if(!o)throw new Error("Unprocessed schema. This is a bug in Zod.");const n=a(s=>{const c=e.seen.get(s);if(c.ref===null)return;const l=c.def??c.schema,d={...l},h=c.ref;if(c.ref=null,h){n(h);const g=e.seen.get(h),m=g.schema;if(m.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(l.allOf=l.allOf??[],l.allOf.push(m)):Object.assign(l,m),Object.assign(l,d),s._zod.parent===h)for(const S in l)S==="$ref"||S==="allOf"||S in d||delete l[S];if(m.$ref&&g.def)for(const S in l)S==="$ref"||S==="allOf"||S in g.def&&JSON.stringify(l[S])===JSON.stringify(g.def[S])&&delete l[S]}const f=s._zod.parent;if(f&&f!==h){n(f);const g=e.seen.get(f);if(g?.schema.$ref&&(l.$ref=g.schema.$ref,g.def))for(const m in l)m==="$ref"||m==="allOf"||m in g.def&&JSON.stringify(l[m])===JSON.stringify(g.def[m])&&delete l[m]}e.override({zodSchema:s,jsonSchema:l,path:c.path??[]})},"flattenRef");for(const s of[...e.seen.entries()].reverse())n(s[0]);const r={};if(e.target==="draft-2020-12"?r.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?r.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?r.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const s=e.external.registry.get(t)?.id;if(!s)throw new Error("Schema is missing an `id` property");r.$id=e.external.uri(s)}Object.assign(r,o.def??o.schema);const i=e.external?.defs??{};for(const s of e.seen.entries()){const c=s[1];c.def&&c.defId&&(i[c.defId]=c.def)}e.external||Object.keys(i).length>0&&(e.target==="draft-2020-12"?r.$defs=i:r.definitions=i);try{const s=JSON.parse(JSON.stringify(r));return Object.defineProperty(s,"~standard",{value:{...t["~standard"],jsonSchema:{input:createStandardJSONSchemaMethod(t,"input",e.processors),output:createStandardJSONSchemaMethod(t,"output",e.processors)}},enumerable:!1,writable:!1}),s}catch{throw new Error("Error converting schema to JSON.")}}a(finalize,"finalize");function isTransforming(e,t){const o=t??{seen:new Set};if(o.seen.has(e))return!1;o.seen.add(e);const n=e._zod.def;if(n.type==="transform")return!0;if(n.type==="array")return isTransforming(n.element,o);if(n.type==="set")return isTransforming(n.valueType,o);if(n.type==="lazy")return isTransforming(n.getter(),o);if(n.type==="promise"||n.type==="optional"||n.type==="nonoptional"||n.type==="nullable"||n.type==="readonly"||n.type==="default"||n.type==="prefault")return isTransforming(n.innerType,o);if(n.type==="intersection")return isTransforming(n.left,o)||isTransforming(n.right,o);if(n.type==="record"||n.type==="map")return isTransforming(n.keyType,o)||isTransforming(n.valueType,o);if(n.type==="pipe")return isTransforming(n.in,o)||isTransforming(n.out,o);if(n.type==="object"){for(const r in n.shape)if(isTransforming(n.shape[r],o))return!0;return!1}if(n.type==="union"){for(const r of n.options)if(isTransforming(r,o))return!0;return!1}if(n.type==="tuple"){for(const r of n.items)if(isTransforming(r,o))return!0;return!!(n.rest&&isTransforming(n.rest,o))}return!1}a(isTransforming,"isTransforming");const createToJSONSchemaMethod=a((e,t={})=>o=>{const n=initializeContext({...o,processors:t});return process(e,n),extractDefs(n,e),finalize(n,e)},"createToJSONSchemaMethod"),createStandardJSONSchemaMethod=a((e,t,o={})=>n=>{const{libraryOptions:r,target:i}=n??{},s=initializeContext({...r??{},target:i,io:t,processors:o});return process(e,s),extractDefs(s,e),finalize(s,e)},"createStandardJSONSchemaMethod"),formatMap={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},stringProcessor=a((e,t,o,n)=>{const r=o;r.type="string";const{minimum:i,maximum:s,format:c,patterns:l,contentEncoding:d}=e._zod.bag;if(typeof i=="number"&&(r.minLength=i),typeof s=="number"&&(r.maxLength=s),c&&(r.format=formatMap[c]??c,r.format===""&&delete r.format,c==="time"&&delete r.format),d&&(r.contentEncoding=d),l&&l.size>0){const h=[...l];h.length===1?r.pattern=h[0].source:h.length>1&&(r.allOf=[...h.map(f=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:f.source}))])}},"stringProcessor"),numberProcessor=a((e,t,o,n)=>{const r=o,{minimum:i,maximum:s,format:c,multipleOf:l,exclusiveMaximum:d,exclusiveMinimum:h}=e._zod.bag;typeof c=="string"&&c.includes("int")?r.type="integer":r.type="number",typeof h=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(r.minimum=h,r.exclusiveMinimum=!0):r.exclusiveMinimum=h),typeof i=="number"&&(r.minimum=i,typeof h=="number"&&t.target!=="draft-04"&&(h>=i?delete r.minimum:delete r.exclusiveMinimum)),typeof d=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(r.maximum=d,r.exclusiveMaximum=!0):r.exclusiveMaximum=d),typeof s=="number"&&(r.maximum=s,typeof d=="number"&&t.target!=="draft-04"&&(d<=s?delete r.maximum:delete r.exclusiveMaximum)),typeof l=="number"&&(r.multipleOf=l)},"numberProcessor"),booleanProcessor=a((e,t,o,n)=>{o.type="boolean"},"booleanProcessor"),bigintProcessor=a((e,t,o,n)=>{if(t.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema")},"bigintProcessor"),symbolProcessor=a((e,t,o,n)=>{if(t.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema")},"symbolProcessor"),nullProcessor=a((e,t,o,n)=>{t.target==="openapi-3.0"?(o.type="string",o.nullable=!0,o.enum=[null]):o.type="null"},"nullProcessor"),undefinedProcessor=a((e,t,o,n)=>{if(t.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema")},"undefinedProcessor"),voidProcessor=a((e,t,o,n)=>{if(t.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema")},"voidProcessor"),neverProcessor=a((e,t,o,n)=>{o.not={}},"neverProcessor"),anyProcessor=a((e,t,o,n)=>{},"anyProcessor"),unknownProcessor=a((e,t,o,n)=>{},"unknownProcessor"),dateProcessor=a((e,t,o,n)=>{if(t.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema")},"dateProcessor"),enumProcessor=a((e,t,o,n)=>{const r=e._zod.def,i=getEnumValues(r.entries);i.every(s=>typeof s=="number")&&(o.type="number"),i.every(s=>typeof s=="string")&&(o.type="string"),o.enum=i},"enumProcessor"),literalProcessor=a((e,t,o,n)=>{const r=e._zod.def,i=[];for(const s of r.values)if(s===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof s=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");i.push(Number(s))}else i.push(s);if(i.length!==0)if(i.length===1){const s=i[0];o.type=s===null?"null":typeof s,t.target==="draft-04"||t.target==="openapi-3.0"?o.enum=[s]:o.const=s}else i.every(s=>typeof s=="number")&&(o.type="number"),i.every(s=>typeof s=="string")&&(o.type="string"),i.every(s=>typeof s=="boolean")&&(o.type="boolean"),i.every(s=>s===null)&&(o.type="null"),o.enum=i},"literalProcessor"),nanProcessor=a((e,t,o,n)=>{if(t.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema")},"nanProcessor"),templateLiteralProcessor=a((e,t,o,n)=>{const r=o,i=e._zod.pattern;if(!i)throw new Error("Pattern not found in template literal");r.type="string",r.pattern=i.source},"templateLiteralProcessor"),fileProcessor=a((e,t,o,n)=>{const r=o,i={type:"string",format:"binary",contentEncoding:"binary"},{minimum:s,maximum:c,mime:l}=e._zod.bag;s!==void 0&&(i.minLength=s),c!==void 0&&(i.maxLength=c),l?l.length===1?(i.contentMediaType=l[0],Object.assign(r,i)):(Object.assign(r,i),r.anyOf=l.map(d=>({contentMediaType:d}))):Object.assign(r,i)},"fileProcessor"),successProcessor=a((e,t,o,n)=>{o.type="boolean"},"successProcessor"),customProcessor=a((e,t,o,n)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},"customProcessor"),functionProcessor=a((e,t,o,n)=>{if(t.unrepresentable==="throw")throw new Error("Function types cannot be represented in JSON Schema")},"functionProcessor"),transformProcessor=a((e,t,o,n)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},"transformProcessor"),mapProcessor=a((e,t,o,n)=>{if(t.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema")},"mapProcessor"),setProcessor=a((e,t,o,n)=>{if(t.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema")},"setProcessor"),arrayProcessor=a((e,t,o,n)=>{const r=o,i=e._zod.def,{minimum:s,maximum:c}=e._zod.bag;typeof s=="number"&&(r.minItems=s),typeof c=="number"&&(r.maxItems=c),r.type="array",r.items=process(i.element,t,{...n,path:[...n.path,"items"]})},"arrayProcessor"),objectProcessor=a((e,t,o,n)=>{const r=o,i=e._zod.def;r.type="object",r.properties={};const s=i.shape;for(const d in s)r.properties[d]=process(s[d],t,{...n,path:[...n.path,"properties",d]});const c=new Set(Object.keys(s)),l=new Set([...c].filter(d=>{const h=i.shape[d]._zod;return t.io==="input"?h.optin===void 0:h.optout===void 0}));l.size>0&&(r.required=Array.from(l)),i.catchall?._zod.def.type==="never"?r.additionalProperties=!1:i.catchall?i.catchall&&(r.additionalProperties=process(i.catchall,t,{...n,path:[...n.path,"additionalProperties"]})):t.io==="output"&&(r.additionalProperties=!1)},"objectProcessor"),unionProcessor=a((e,t,o,n)=>{const r=e._zod.def,i=r.inclusive===!1,s=r.options.map((c,l)=>process(c,t,{...n,path:[...n.path,i?"oneOf":"anyOf",l]}));i?o.oneOf=s:o.anyOf=s},"unionProcessor"),intersectionProcessor=a((e,t,o,n)=>{const r=e._zod.def,i=process(r.left,t,{...n,path:[...n.path,"allOf",0]}),s=process(r.right,t,{...n,path:[...n.path,"allOf",1]}),c=a(d=>"allOf"in d&&Object.keys(d).length===1,"isSimpleIntersection"),l=[...c(i)?i.allOf:[i],...c(s)?s.allOf:[s]];o.allOf=l},"intersectionProcessor"),tupleProcessor=a((e,t,o,n)=>{const r=o,i=e._zod.def;r.type="array";const s=t.target==="draft-2020-12"?"prefixItems":"items",c=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",l=i.items.map((g,m)=>process(g,t,{...n,path:[...n.path,s,m]})),d=i.rest?process(i.rest,t,{...n,path:[...n.path,c,...t.target==="openapi-3.0"?[i.items.length]:[]]}):null;t.target==="draft-2020-12"?(r.prefixItems=l,d&&(r.items=d)):t.target==="openapi-3.0"?(r.items={anyOf:l},d&&r.items.anyOf.push(d),r.minItems=l.length,d||(r.maxItems=l.length)):(r.items=l,d&&(r.additionalItems=d));const{minimum:h,maximum:f}=e._zod.bag;typeof h=="number"&&(r.minItems=h),typeof f=="number"&&(r.maxItems=f)},"tupleProcessor"),recordProcessor=a((e,t,o,n)=>{const r=o,i=e._zod.def;r.type="object";const s=i.keyType,l=s._zod.bag?.patterns;if(i.mode==="loose"&&l&&l.size>0){const h=process(i.valueType,t,{...n,path:[...n.path,"patternProperties","*"]});r.patternProperties={};for(const f of l)r.patternProperties[f.source]=h}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(r.propertyNames=process(i.keyType,t,{...n,path:[...n.path,"propertyNames"]})),r.additionalProperties=process(i.valueType,t,{...n,path:[...n.path,"additionalProperties"]});const d=s._zod.values;if(d){const h=[...d].filter(f=>typeof f=="string"||typeof f=="number");h.length>0&&(r.required=h)}},"recordProcessor"),nullableProcessor=a((e,t,o,n)=>{const r=e._zod.def,i=process(r.innerType,t,n),s=t.seen.get(e);t.target==="openapi-3.0"?(s.ref=r.innerType,o.nullable=!0):o.anyOf=[i,{type:"null"}]},"nullableProcessor"),nonoptionalProcessor=a((e,t,o,n)=>{const r=e._zod.def;process(r.innerType,t,n);const i=t.seen.get(e);i.ref=r.innerType},"nonoptionalProcessor"),defaultProcessor=a((e,t,o,n)=>{const r=e._zod.def;process(r.innerType,t,n);const i=t.seen.get(e);i.ref=r.innerType,o.default=JSON.parse(JSON.stringify(r.defaultValue))},"defaultProcessor"),prefaultProcessor=a((e,t,o,n)=>{const r=e._zod.def;process(r.innerType,t,n);const i=t.seen.get(e);i.ref=r.innerType,t.io==="input"&&(o._prefault=JSON.parse(JSON.stringify(r.defaultValue)))},"prefaultProcessor"),catchProcessor=a((e,t,o,n)=>{const r=e._zod.def;process(r.innerType,t,n);const i=t.seen.get(e);i.ref=r.innerType;let s;try{s=r.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}o.default=s},"catchProcessor"),pipeProcessor=a((e,t,o,n)=>{const r=e._zod.def,i=t.io==="input"?r.in._zod.def.type==="transform"?r.out:r.in:r.out;process(i,t,n);const s=t.seen.get(e);s.ref=i},"pipeProcessor"),readonlyProcessor=a((e,t,o,n)=>{const r=e._zod.def;process(r.innerType,t,n);const i=t.seen.get(e);i.ref=r.innerType,o.readOnly=!0},"readonlyProcessor"),promiseProcessor=a((e,t,o,n)=>{const r=e._zod.def;process(r.innerType,t,n);const i=t.seen.get(e);i.ref=r.innerType},"promiseProcessor"),optionalProcessor=a((e,t,o,n)=>{const r=e._zod.def;process(r.innerType,t,n);const i=t.seen.get(e);i.ref=r.innerType},"optionalProcessor"),lazyProcessor=a((e,t,o,n)=>{const r=e._zod.innerType;process(r,t,n);const i=t.seen.get(e);i.ref=r},"lazyProcessor"),allProcessors={string:stringProcessor,number:numberProcessor,boolean:booleanProcessor,bigint:bigintProcessor,symbol:symbolProcessor,null:nullProcessor,undefined:undefinedProcessor,void:voidProcessor,never:neverProcessor,any:anyProcessor,unknown:unknownProcessor,date:dateProcessor,enum:enumProcessor,literal:literalProcessor,nan:nanProcessor,template_literal:templateLiteralProcessor,file:fileProcessor,success:successProcessor,custom:customProcessor,function:functionProcessor,transform:transformProcessor,map:mapProcessor,set:setProcessor,array:arrayProcessor,object:objectProcessor,union:unionProcessor,intersection:intersectionProcessor,tuple:tupleProcessor,record:recordProcessor,nullable:nullableProcessor,nonoptional:nonoptionalProcessor,default:defaultProcessor,prefault:prefaultProcessor,catch:catchProcessor,pipe:pipeProcessor,readonly:readonlyProcessor,promise:promiseProcessor,optional:optionalProcessor,lazy:lazyProcessor};function toJSONSchema(e,t){if("_idmap"in e){const n=e,r=initializeContext({...t,processors:allProcessors}),i={};for(const l of n._idmap.entries()){const[d,h]=l;process(h,r)}const s={},c={registry:n,uri:t?.uri,defs:i};r.external=c;for(const l of n._idmap.entries()){const[d,h]=l;extractDefs(r,h),s[d]=finalize(r,h)}if(Object.keys(i).length>0){const l=r.target==="draft-2020-12"?"$defs":"definitions";s.__shared={[l]:i}}return{schemas:s}}const o=initializeContext({...t,processors:allProcessors});return process(e,o),extractDefs(o,e),finalize(o,e)}a(toJSONSchema,"toJSONSchema");const ZodISODateTime=$constructor("ZodISODateTime",(e,t)=>{$ZodISODateTime.init(e,t),ZodStringFormat.init(e,t)});function datetime(e){return _isoDateTime(ZodISODateTime,e)}a(datetime,"datetime");const ZodISODate=$constructor("ZodISODate",(e,t)=>{$ZodISODate.init(e,t),ZodStringFormat.init(e,t)});function date(e){return _isoDate(ZodISODate,e)}a(date,"date");const ZodISOTime=$constructor("ZodISOTime",(e,t)=>{$ZodISOTime.init(e,t),ZodStringFormat.init(e,t)});function time(e){return _isoTime(ZodISOTime,e)}a(time,"time");const ZodISODuration=$constructor("ZodISODuration",(e,t)=>{$ZodISODuration.init(e,t),ZodStringFormat.init(e,t)});function duration(e){return _isoDuration(ZodISODuration,e)}a(duration,"duration");const initializer=a((e,t)=>{$ZodError.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:a(o=>formatError(e,o),"value")},flatten:{value:a(o=>flattenError(e,o),"value")},addIssue:{value:a(o=>{e.issues.push(o),e.message=JSON.stringify(e.issues,jsonStringifyReplacer,2)},"value")},addIssues:{value:a(o=>{e.issues.push(...o),e.message=JSON.stringify(e.issues,jsonStringifyReplacer,2)},"value")},isEmpty:{get(){return e.issues.length===0}}})},"initializer"),ZodRealError=$constructor("ZodError",initializer,{Parent:Error}),parse=_parse(ZodRealError),parseAsync=_parseAsync(ZodRealError),safeParse=_safeParse(ZodRealError),safeParseAsync=_safeParseAsync(ZodRealError),encode=_encode(ZodRealError),decode=_decode(ZodRealError),encodeAsync=_encodeAsync(ZodRealError),decodeAsync=_decodeAsync(ZodRealError),safeEncode=_safeEncode(ZodRealError),safeDecode=_safeDecode(ZodRealError),safeEncodeAsync=_safeEncodeAsync(ZodRealError),safeDecodeAsync=_safeDecodeAsync(ZodRealError),ZodType=$constructor("ZodType",(e,t)=>($ZodType.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:createStandardJSONSchemaMethod(e,"input"),output:createStandardJSONSchemaMethod(e,"output")}}),e.toJSONSchema=createToJSONSchemaMethod(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...o)=>e.clone(mergeDefs(t,{checks:[...t.checks??[],...o.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0}),e.with=e.check,e.clone=(o,n)=>clone(e,o,n),e.brand=()=>e,e.register=((o,n)=>(o.add(e,n),e)),e.parse=(o,n)=>parse(e,o,n,{callee:e.parse}),e.safeParse=(o,n)=>safeParse(e,o,n),e.parseAsync=async(o,n)=>parseAsync(e,o,n,{callee:e.parseAsync}),e.safeParseAsync=async(o,n)=>safeParseAsync(e,o,n),e.spa=e.safeParseAsync,e.encode=(o,n)=>encode(e,o,n),e.decode=(o,n)=>decode(e,o,n),e.encodeAsync=async(o,n)=>encodeAsync(e,o,n),e.decodeAsync=async(o,n)=>decodeAsync(e,o,n),e.safeEncode=(o,n)=>safeEncode(e,o,n),e.safeDecode=(o,n)=>safeDecode(e,o,n),e.safeEncodeAsync=async(o,n)=>safeEncodeAsync(e,o,n),e.safeDecodeAsync=async(o,n)=>safeDecodeAsync(e,o,n),e.refine=(o,n)=>e.check(refine(o,n)),e.superRefine=o=>e.check(superRefine(o)),e.overwrite=o=>e.check(_overwrite(o)),e.optional=()=>optional(e),e.exactOptional=()=>exactOptional(e),e.nullable=()=>nullable(e),e.nullish=()=>optional(nullable(e)),e.nonoptional=o=>nonoptional(e,o),e.array=()=>array(e),e.or=o=>union([e,o]),e.and=o=>intersection(e,o),e.transform=o=>pipe(e,transform(o)),e.default=o=>_default(e,o),e.prefault=o=>prefault(e,o),e.catch=o=>_catch(e,o),e.pipe=o=>pipe(e,o),e.readonly=()=>readonly(e),e.describe=o=>{const n=e.clone();return globalRegistry.add(n,{description:o}),n},Object.defineProperty(e,"description",{get(){return globalRegistry.get(e)?.description},configurable:!0}),e.meta=(...o)=>{if(o.length===0)return globalRegistry.get(e);const n=e.clone();return globalRegistry.add(n,o[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=o=>o(e),e)),_ZodString=$constructor("_ZodString",(e,t)=>{$ZodString.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(n,r,i)=>stringProcessor(e,n,r);const o=e._zod.bag;e.format=o.format??null,e.minLength=o.minimum??null,e.maxLength=o.maximum??null,e.regex=(...n)=>e.check(_regex(...n)),e.includes=(...n)=>e.check(_includes(...n)),e.startsWith=(...n)=>e.check(_startsWith(...n)),e.endsWith=(...n)=>e.check(_endsWith(...n)),e.min=(...n)=>e.check(_minLength(...n)),e.max=(...n)=>e.check(_maxLength(...n)),e.length=(...n)=>e.check(_length(...n)),e.nonempty=(...n)=>e.check(_minLength(1,...n)),e.lowercase=n=>e.check(_lowercase(n)),e.uppercase=n=>e.check(_uppercase(n)),e.trim=()=>e.check(_trim()),e.normalize=(...n)=>e.check(_normalize(...n)),e.toLowerCase=()=>e.check(_toLowerCase()),e.toUpperCase=()=>e.check(_toUpperCase()),e.slugify=()=>e.check(_slugify())}),ZodString=$constructor("ZodString",(e,t)=>{$ZodString.init(e,t),_ZodString.init(e,t),e.email=o=>e.check(_email(ZodEmail,o)),e.url=o=>e.check(_url(ZodURL,o)),e.jwt=o=>e.check(_jwt(ZodJWT,o)),e.emoji=o=>e.check(_emoji(ZodEmoji,o)),e.guid=o=>e.check(_guid(ZodGUID,o)),e.uuid=o=>e.check(_uuid(ZodUUID,o)),e.uuidv4=o=>e.check(_uuidv4(ZodUUID,o)),e.uuidv6=o=>e.check(_uuidv6(ZodUUID,o)),e.uuidv7=o=>e.check(_uuidv7(ZodUUID,o)),e.nanoid=o=>e.check(_nanoid(ZodNanoID,o)),e.guid=o=>e.check(_guid(ZodGUID,o)),e.cuid=o=>e.check(_cuid(ZodCUID,o)),e.cuid2=o=>e.check(_cuid2(ZodCUID2,o)),e.ulid=o=>e.check(_ulid(ZodULID,o)),e.base64=o=>e.check(_base64(ZodBase64,o)),e.base64url=o=>e.check(_base64url(ZodBase64URL,o)),e.xid=o=>e.check(_xid(ZodXID,o)),e.ksuid=o=>e.check(_ksuid(ZodKSUID,o)),e.ipv4=o=>e.check(_ipv4(ZodIPv4,o)),e.ipv6=o=>e.check(_ipv6(ZodIPv6,o)),e.cidrv4=o=>e.check(_cidrv4(ZodCIDRv4,o)),e.cidrv6=o=>e.check(_cidrv6(ZodCIDRv6,o)),e.e164=o=>e.check(_e164(ZodE164,o)),e.datetime=o=>e.check(datetime(o)),e.date=o=>e.check(date(o)),e.time=o=>e.check(time(o)),e.duration=o=>e.check(duration(o))});function string(e){return _string(ZodString,e)}a(string,"string");const ZodStringFormat=$constructor("ZodStringFormat",(e,t)=>{$ZodStringFormat.init(e,t),_ZodString.init(e,t)}),ZodEmail=$constructor("ZodEmail",(e,t)=>{$ZodEmail.init(e,t),ZodStringFormat.init(e,t)}),ZodGUID=$constructor("ZodGUID",(e,t)=>{$ZodGUID.init(e,t),ZodStringFormat.init(e,t)}),ZodUUID=$constructor("ZodUUID",(e,t)=>{$ZodUUID.init(e,t),ZodStringFormat.init(e,t)}),ZodURL=$constructor("ZodURL",(e,t)=>{$ZodURL.init(e,t),ZodStringFormat.init(e,t)}),ZodEmoji=$constructor("ZodEmoji",(e,t)=>{$ZodEmoji.init(e,t),ZodStringFormat.init(e,t)}),ZodNanoID=$constructor("ZodNanoID",(e,t)=>{$ZodNanoID.init(e,t),ZodStringFormat.init(e,t)}),ZodCUID=$constructor("ZodCUID",(e,t)=>{$ZodCUID.init(e,t),ZodStringFormat.init(e,t)}),ZodCUID2=$constructor("ZodCUID2",(e,t)=>{$ZodCUID2.init(e,t),ZodStringFormat.init(e,t)}),ZodULID=$constructor("ZodULID",(e,t)=>{$ZodULID.init(e,t),ZodStringFormat.init(e,t)}),ZodXID=$constructor("ZodXID",(e,t)=>{$ZodXID.init(e,t),ZodStringFormat.init(e,t)}),ZodKSUID=$constructor("ZodKSUID",(e,t)=>{$ZodKSUID.init(e,t),ZodStringFormat.init(e,t)}),ZodIPv4=$constructor("ZodIPv4",(e,t)=>{$ZodIPv4.init(e,t),ZodStringFormat.init(e,t)}),ZodIPv6=$constructor("ZodIPv6",(e,t)=>{$ZodIPv6.init(e,t),ZodStringFormat.init(e,t)}),ZodCIDRv4=$constructor("ZodCIDRv4",(e,t)=>{$ZodCIDRv4.init(e,t),ZodStringFormat.init(e,t)}),ZodCIDRv6=$constructor("ZodCIDRv6",(e,t)=>{$ZodCIDRv6.init(e,t),ZodStringFormat.init(e,t)}),ZodBase64=$constructor("ZodBase64",(e,t)=>{$ZodBase64.init(e,t),ZodStringFormat.init(e,t)}),ZodBase64URL=$constructor("ZodBase64URL",(e,t)=>{$ZodBase64URL.init(e,t),ZodStringFormat.init(e,t)}),ZodE164=$constructor("ZodE164",(e,t)=>{$ZodE164.init(e,t),ZodStringFormat.init(e,t)}),ZodJWT=$constructor("ZodJWT",(e,t)=>{$ZodJWT.init(e,t),ZodStringFormat.init(e,t)}),ZodNumber=$constructor("ZodNumber",(e,t)=>{$ZodNumber.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(n,r,i)=>numberProcessor(e,n,r),e.gt=(n,r)=>e.check(_gt(n,r)),e.gte=(n,r)=>e.check(_gte(n,r)),e.min=(n,r)=>e.check(_gte(n,r)),e.lt=(n,r)=>e.check(_lt(n,r)),e.lte=(n,r)=>e.check(_lte(n,r)),e.max=(n,r)=>e.check(_lte(n,r)),e.int=n=>e.check(int(n)),e.safe=n=>e.check(int(n)),e.positive=n=>e.check(_gt(0,n)),e.nonnegative=n=>e.check(_gte(0,n)),e.negative=n=>e.check(_lt(0,n)),e.nonpositive=n=>e.check(_lte(0,n)),e.multipleOf=(n,r)=>e.check(_multipleOf(n,r)),e.step=(n,r)=>e.check(_multipleOf(n,r)),e.finite=()=>e;const o=e._zod.bag;e.minValue=Math.max(o.minimum??Number.NEGATIVE_INFINITY,o.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(o.maximum??Number.POSITIVE_INFINITY,o.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(o.format??"").includes("int")||Number.isSafeInteger(o.multipleOf??.5),e.isFinite=!0,e.format=o.format??null});function number(e){return _number(ZodNumber,e)}a(number,"number");const ZodNumberFormat=$constructor("ZodNumberFormat",(e,t)=>{$ZodNumberFormat.init(e,t),ZodNumber.init(e,t)});function int(e){return _int(ZodNumberFormat,e)}a(int,"int");const ZodBoolean=$constructor("ZodBoolean",(e,t)=>{$ZodBoolean.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(o,n,r)=>booleanProcessor(e,o,n)});function boolean(e){return _boolean(ZodBoolean,e)}a(boolean,"boolean");const ZodUnknown=$constructor("ZodUnknown",(e,t)=>{$ZodUnknown.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(o,n,r)=>unknownProcessor()});function unknown(){return _unknown(ZodUnknown)}a(unknown,"unknown");const ZodNever=$constructor("ZodNever",(e,t)=>{$ZodNever.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(o,n,r)=>neverProcessor(e,o,n)});function never(e){return _never(ZodNever,e)}a(never,"never");const ZodArray=$constructor("ZodArray",(e,t)=>{$ZodArray.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(o,n,r)=>arrayProcessor(e,o,n,r),e.element=t.element,e.min=(o,n)=>e.check(_minLength(o,n)),e.nonempty=o=>e.check(_minLength(1,o)),e.max=(o,n)=>e.check(_maxLength(o,n)),e.length=(o,n)=>e.check(_length(o,n)),e.unwrap=()=>e.element});function array(e,t){return _array(ZodArray,e,t)}a(array,"array");const ZodObject=$constructor("ZodObject",(e,t)=>{$ZodObjectJIT.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(o,n,r)=>objectProcessor(e,o,n,r),defineLazy(e,"shape",()=>t.shape),e.keyof=()=>_enum(Object.keys(e._zod.def.shape)),e.catchall=o=>e.clone({...e._zod.def,catchall:o}),e.passthrough=()=>e.clone({...e._zod.def,catchall:unknown()}),e.loose=()=>e.clone({...e._zod.def,catchall:unknown()}),e.strict=()=>e.clone({...e._zod.def,catchall:never()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=o=>extend(e,o),e.safeExtend=o=>safeExtend(e,o),e.merge=o=>merge(e,o),e.pick=o=>pick(e,o),e.omit=o=>omit(e,o),e.partial=(...o)=>partial(ZodOptional,e,o[0]),e.required=(...o)=>required(ZodNonOptional,e,o[0])});function object(e,t){const o={type:"object",shape:e??{},...normalizeParams(t)};return new ZodObject(o)}a(object,"object");const ZodUnion=$constructor("ZodUnion",(e,t)=>{$ZodUnion.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(o,n,r)=>unionProcessor(e,o,n,r),e.options=t.options});function union(e,t){return new ZodUnion({type:"union",options:e,...normalizeParams(t)})}a(union,"union");const ZodIntersection=$constructor("ZodIntersection",(e,t)=>{$ZodIntersection.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(o,n,r)=>intersectionProcessor(e,o,n,r)});function intersection(e,t){return new ZodIntersection({type:"intersection",left:e,right:t})}a(intersection,"intersection");const ZodEnum=$constructor("ZodEnum",(e,t)=>{$ZodEnum.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(n,r,i)=>enumProcessor(e,n,r),e.enum=t.entries,e.options=Object.values(t.entries);const o=new Set(Object.keys(t.entries));e.extract=(n,r)=>{const i={};for(const s of n)if(o.has(s))i[s]=t.entries[s];else throw new Error(`Key ${s} not found in enum`);return new ZodEnum({...t,checks:[],...normalizeParams(r),entries:i})},e.exclude=(n,r)=>{const i={...t.entries};for(const s of n)if(o.has(s))delete i[s];else throw new Error(`Key ${s} not found in enum`);return new ZodEnum({...t,checks:[],...normalizeParams(r),entries:i})}});function _enum(e,t){const o=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new ZodEnum({type:"enum",entries:o,...normalizeParams(t)})}a(_enum,"_enum");const ZodTransform=$constructor("ZodTransform",(e,t)=>{$ZodTransform.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(o,n,r)=>transformProcessor(e,o),e._zod.parse=(o,n)=>{if(n.direction==="backward")throw new $ZodEncodeError(e.constructor.name);o.addIssue=i=>{if(typeof i=="string")o.issues.push(issue(i,o.value,t));else{const s=i;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),s.input??(s.input=o.value),s.inst??(s.inst=e),o.issues.push(issue(s))}};const r=t.transform(o.value,o);return r instanceof Promise?r.then(i=>(o.value=i,o)):(o.value=r,o)}});function transform(e){return new ZodTransform({type:"transform",transform:e})}a(transform,"transform");const ZodOptional=$constructor("ZodOptional",(e,t)=>{$ZodOptional.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(o,n,r)=>optionalProcessor(e,o,n,r),e.unwrap=()=>e._zod.def.innerType});function optional(e){return new ZodOptional({type:"optional",innerType:e})}a(optional,"optional");const ZodExactOptional=$constructor("ZodExactOptional",(e,t)=>{$ZodExactOptional.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(o,n,r)=>optionalProcessor(e,o,n,r),e.unwrap=()=>e._zod.def.innerType});function exactOptional(e){return new ZodExactOptional({type:"optional",innerType:e})}a(exactOptional,"exactOptional");const ZodNullable=$constructor("ZodNullable",(e,t)=>{$ZodNullable.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(o,n,r)=>nullableProcessor(e,o,n,r),e.unwrap=()=>e._zod.def.innerType});function nullable(e){return new ZodNullable({type:"nullable",innerType:e})}a(nullable,"nullable");const ZodDefault=$constructor("ZodDefault",(e,t)=>{$ZodDefault.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(o,n,r)=>defaultProcessor(e,o,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function _default(e,t){return new ZodDefault({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():shallowClone(t)}})}a(_default,"_default");const ZodPrefault=$constructor("ZodPrefault",(e,t)=>{$ZodPrefault.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(o,n,r)=>prefaultProcessor(e,o,n,r),e.unwrap=()=>e._zod.def.innerType});function prefault(e,t){return new ZodPrefault({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():shallowClone(t)}})}a(prefault,"prefault");const ZodNonOptional=$constructor("ZodNonOptional",(e,t)=>{$ZodNonOptional.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(o,n,r)=>nonoptionalProcessor(e,o,n,r),e.unwrap=()=>e._zod.def.innerType});function nonoptional(e,t){return new ZodNonOptional({type:"nonoptional",innerType:e,...normalizeParams(t)})}a(nonoptional,"nonoptional");const ZodCatch=$constructor("ZodCatch",(e,t)=>{$ZodCatch.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(o,n,r)=>catchProcessor(e,o,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function _catch(e,t){return new ZodCatch({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}a(_catch,"_catch");const ZodPipe=$constructor("ZodPipe",(e,t)=>{$ZodPipe.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(o,n,r)=>pipeProcessor(e,o,n,r),e.in=t.in,e.out=t.out});function pipe(e,t){return new ZodPipe({type:"pipe",in:e,out:t})}a(pipe,"pipe");const ZodReadonly=$constructor("ZodReadonly",(e,t)=>{$ZodReadonly.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(o,n,r)=>readonlyProcessor(e,o,n,r),e.unwrap=()=>e._zod.def.innerType});function readonly(e){return new ZodReadonly({type:"readonly",innerType:e})}a(readonly,"readonly");const ZodCustom=$constructor("ZodCustom",(e,t)=>{$ZodCustom.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(o,n,r)=>customProcessor(e,o)});function refine(e,t={}){return _refine(ZodCustom,e,t)}a(refine,"refine");function superRefine(e){return _superRefine(e)}a(superRefine,"superRefine");const InvokeErrorType={NETWORK_ERROR:"network_error",RATE_LIMIT:"rate_limit",SERVER_ERROR:"server_error",NO_TOOL_CALL:"no_tool_call",INVALID_TOOL_ARGS:"invalid_tool_args",TOOL_EXECUTION_ERROR:"tool_execution_error",UNKNOWN:"unknown",AUTH_ERROR:"auth_error",CONTEXT_LENGTH:"context_length",CONTENT_FILTER:"content_filter"},at=class at extends Error{type;retryable;statusCode;rawError;rawResponse;constructor(t,o,n,r){super(o),this.name="InvokeError",this.type=t,this.retryable=this.isRetryable(t,n),this.rawError=n,this.rawResponse=r}isRetryable(t,o){return o?.name==="AbortError"?!1:[InvokeErrorType.NETWORK_ERROR,InvokeErrorType.RATE_LIMIT,InvokeErrorType.SERVER_ERROR,InvokeErrorType.NO_TOOL_CALL,InvokeErrorType.INVALID_TOOL_ARGS,InvokeErrorType.TOOL_EXECUTION_ERROR,InvokeErrorType.UNKNOWN].includes(t)}};a(at,"InvokeError");let InvokeError=at;const ANSI_BACKGROUND_OFFSET=10,wrapAnsi16=a((e=0)=>t=>`\x1B[${t+e}m`,"wrapAnsi16"),wrapAnsi256=a((e=0)=>t=>`\x1B[${38+e};5;${t}m`,"wrapAnsi256"),wrapAnsi16m=a((e=0)=>(t,o,n)=>`\x1B[${38+e};2;${t};${o};${n}m`,"wrapAnsi16m"),styles$3={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};Object.keys(styles$3.modifier);const foregroundColorNames=Object.keys(styles$3.color),backgroundColorNames=Object.keys(styles$3.bgColor);[...foregroundColorNames,...backgroundColorNames];function assembleStyles(){const e=new Map;for(const[t,o]of Object.entries(styles$3)){for(const[n,r]of Object.entries(o))styles$3[n]={open:`\x1B[${r[0]}m`,close:`\x1B[${r[1]}m`},o[n]=styles$3[n],e.set(r[0],r[1]);Object.defineProperty(styles$3,t,{value:o,enumerable:!1})}return Object.defineProperty(styles$3,"codes",{value:e,enumerable:!1}),styles$3.color.close="\x1B[39m",styles$3.bgColor.close="\x1B[49m",styles$3.color.ansi=wrapAnsi16(),styles$3.color.ansi256=wrapAnsi256(),styles$3.color.ansi16m=wrapAnsi16m(),styles$3.bgColor.ansi=wrapAnsi16(ANSI_BACKGROUND_OFFSET),styles$3.bgColor.ansi256=wrapAnsi256(ANSI_BACKGROUND_OFFSET),styles$3.bgColor.ansi16m=wrapAnsi16m(ANSI_BACKGROUND_OFFSET),Object.defineProperties(styles$3,{rgbToAnsi256:{value(t,o,n){return t===o&&o===n?t<8?16:t>248?231:Math.round((t-8)/247*24)+232:16+36*Math.round(t/255*5)+6*Math.round(o/255*5)+Math.round(n/255*5)},enumerable:!1},hexToRgb:{value(t){const o=/[a-f\d]{6}|[a-f\d]{3}/i.exec(t.toString(16));if(!o)return[0,0,0];let[n]=o;n.length===3&&(n=[...n].map(i=>i+i).join(""));const r=Number.parseInt(n,16);return[r>>16&255,r>>8&255,r&255]},enumerable:!1},hexToAnsi256:{value:a(t=>styles$3.rgbToAnsi256(...styles$3.hexToRgb(t)),"value"),enumerable:!1},ansi256ToAnsi:{value(t){if(t<8)return 30+t;if(t<16)return 90+(t-8);let o,n,r;if(t>=232)o=((t-232)*10+8)/255,n=o,r=o;else{t-=16;const c=t%36;o=Math.floor(t/36)/5,n=Math.floor(c/6)/5,r=c%6/5}const i=Math.max(o,n,r)*2;if(i===0)return 30;let s=30+(Math.round(r)<<2|Math.round(n)<<1|Math.round(o));return i===2&&(s+=60),s},enumerable:!1},rgbToAnsi:{value:a((t,o,n)=>styles$3.ansi256ToAnsi(styles$3.rgbToAnsi256(t,o,n)),"value"),enumerable:!1},hexToAnsi:{value:a(t=>styles$3.ansi256ToAnsi(styles$3.hexToAnsi256(t)),"value"),enumerable:!1}}),styles$3}a(assembleStyles,"assembleStyles");const ansiStyles=assembleStyles(),level=(()=>{if(!("navigator"in globalThis))return 0;if(globalThis.navigator.userAgentData){const e=navigator.userAgentData.brands.find(({brand:t})=>t==="Chromium");if(e&&e.version>93)return 3}return/\b(Chrome|Chromium)\//.test(globalThis.navigator.userAgent)?1:0})(),colorSupport=level!==0&&{level},supportsColor={stdout:colorSupport,stderr:colorSupport};function stringReplaceAll(e,t,o){let n=e.indexOf(t);if(n===-1)return e;const r=t.length;let i=0,s="";do s+=e.slice(i,n)+t+o,i=n+r,n=e.indexOf(t,i);while(n!==-1);return s+=e.slice(i),s}a(stringReplaceAll,"stringReplaceAll");function stringEncaseCRLFWithFirstIndex(e,t,o,n){let r=0,i="";do{const s=e[n-1]==="\r";i+=e.slice(r,s?n-1:n)+t+(s?`\r
42
+ `:`
43
+ `)+o,r=n+1,n=e.indexOf(`
44
+ `,r)}while(n!==-1);return i+=e.slice(r),i}a(stringEncaseCRLFWithFirstIndex,"stringEncaseCRLFWithFirstIndex");const{stdout:stdoutColor,stderr:stderrColor}=supportsColor,GENERATOR=Symbol("GENERATOR"),STYLER=Symbol("STYLER"),IS_EMPTY=Symbol("IS_EMPTY"),levelMapping=["ansi","ansi","ansi256","ansi16m"],styles$2=Object.create(null),applyOptions=a((e,t={})=>{if(t.level&&!(Number.isInteger(t.level)&&t.level>=0&&t.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");const o=stdoutColor?stdoutColor.level:0;e.level=t.level===void 0?o:t.level},"applyOptions"),chalkFactory=a(e=>{const t=a((...o)=>o.join(" "),"chalk");return applyOptions(t,e),Object.setPrototypeOf(t,createChalk.prototype),t},"chalkFactory");function createChalk(e){return chalkFactory(e)}a(createChalk,"createChalk"),Object.setPrototypeOf(createChalk.prototype,Function.prototype);for(const[e,t]of Object.entries(ansiStyles))styles$2[e]={get(){const o=createBuilder(this,createStyler(t.open,t.close,this[STYLER]),this[IS_EMPTY]);return Object.defineProperty(this,e,{value:o}),o}};styles$2.visible={get(){const e=createBuilder(this,this[STYLER],!0);return Object.defineProperty(this,"visible",{value:e}),e}};const getModelAnsi=a((e,t,o,...n)=>e==="rgb"?t==="ansi16m"?ansiStyles[o].ansi16m(...n):t==="ansi256"?ansiStyles[o].ansi256(ansiStyles.rgbToAnsi256(...n)):ansiStyles[o].ansi(ansiStyles.rgbToAnsi(...n)):e==="hex"?getModelAnsi("rgb",t,o,...ansiStyles.hexToRgb(...n)):ansiStyles[o][e](...n),"getModelAnsi"),usedModels=["rgb","hex","ansi256"];for(const e of usedModels){styles$2[e]={get(){const{level:o}=this;return function(...n){const r=createStyler(getModelAnsi(e,levelMapping[o],"color",...n),ansiStyles.color.close,this[STYLER]);return createBuilder(this,r,this[IS_EMPTY])}}};const t="bg"+e[0].toUpperCase()+e.slice(1);styles$2[t]={get(){const{level:o}=this;return function(...n){const r=createStyler(getModelAnsi(e,levelMapping[o],"bgColor",...n),ansiStyles.bgColor.close,this[STYLER]);return createBuilder(this,r,this[IS_EMPTY])}}}}const proto=Object.defineProperties(()=>{},{...styles$2,level:{enumerable:!0,get(){return this[GENERATOR].level},set(e){this[GENERATOR].level=e}}}),createStyler=a((e,t,o)=>{let n,r;return o===void 0?(n=e,r=t):(n=o.openAll+e,r=t+o.closeAll),{open:e,close:t,openAll:n,closeAll:r,parent:o}},"createStyler"),createBuilder=a((e,t,o)=>{const n=a((...r)=>applyStyle(n,r.length===1?""+r[0]:r.join(" ")),"builder");return Object.setPrototypeOf(n,proto),n[GENERATOR]=e,n[STYLER]=t,n[IS_EMPTY]=o,n},"createBuilder"),applyStyle=a((e,t)=>{if(e.level<=0||!t)return e[IS_EMPTY]?"":t;let o=e[STYLER];if(o===void 0)return t;const{openAll:n,closeAll:r}=o;if(t.includes("\x1B"))for(;o!==void 0;)t=stringReplaceAll(t,o.close,o.open),o=o.parent;const i=t.indexOf(`
45
+ `);return i!==-1&&(t=stringEncaseCRLFWithFirstIndex(t,r,n,i)),n+t+r},"applyStyle");Object.defineProperties(createChalk.prototype,styles$2);const chalk=createChalk();createChalk({level:stderrColor?stderrColor.level:0});function debug(e){console.debug(chalk.gray("[LLM]"),e)}a(debug,"debug");function zodToOpenAITool(e,t){return{type:"function",function:{name:e,description:t.description,parameters:toJSONSchema(t.inputSchema,{target:"openapi-3.0"})}}}a(zodToOpenAITool,"zodToOpenAITool");function modelPatch(e){const t=e.model||"";if(!t)return e;const o=normalizeModelName(t);return o.startsWith("qwen")&&(debug("Applying Qwen patch: use higher temperature for auto fixing"),e.temperature=Math.max(e.temperature||0,1),e.enable_thinking=!1),o.startsWith("claude")&&(debug("Applying Claude patch: disable thinking"),e.thinking={type:"disabled"},e.tool_choice==="required"?(debug('Applying Claude patch: convert tool_choice "required" to { type: "any" }'),e.tool_choice={type:"any"}):e.tool_choice?.function?.name&&(debug("Applying Claude patch: convert tool_choice format"),e.tool_choice={type:"tool",name:e.tool_choice.function.name})),o.startsWith("grok")&&(debug("Applying Grok patch: removing tool_choice"),delete e.tool_choice,debug("Applying Grok patch: disable reasoning and thinking"),e.thinking={type:"disabled",effort:"minimal"},e.reasoning={enabled:!1,effort:"low"}),o.startsWith("gpt")&&(debug("Applying GPT patch: set verbosity to low"),e.verbosity="low",o.startsWith("gpt-52")?(debug("Applying GPT-52 patch: disable reasoning"),e.reasoning_effort="none"):o.startsWith("gpt-51")?(debug("Applying GPT-51 patch: disable reasoning"),e.reasoning_effort="none"):o.startsWith("gpt-5-mini")?(debug("Applying GPT-5-mini patch: set reasoning effort to low, temperature to 1"),e.reasoning_effort="low",e.temperature=1):o.startsWith("gpt-5")&&(debug("Applying GPT-5 patch: set reasoning effort to low"),e.reasoning_effort="low")),o.startsWith("gemini")&&(debug("Applying Gemini patch: set reasoning effort to minimal"),e.reasoning_effort="minimal"),e}a(modelPatch,"modelPatch");function normalizeModelName(e){let t=e.toLowerCase();return t.includes("/")&&(t=t.split("/")[1]),t=t.replace(/_/g,""),t=t.replace(/\./g,""),t}a(normalizeModelName,"normalizeModelName");const ct=class ct{config;fetch;constructor(t){this.config=t,this.fetch=t.customFetch}async invoke(t,o,n,r){const i=Object.entries(o).map(([k,w])=>zodToOpenAITool(k,w)),s={model:this.config.model,temperature:this.config.temperature,messages:t,tools:i,parallel_tool_calls:!1,tool_choice:r?.toolChoiceName?{type:"function",function:{name:r.toolChoiceName}}:"required"};modelPatch(s);let c;try{c=await this.fetch(`${this.config.baseURL}/chat/completions`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.config.apiKey}`},body:JSON.stringify(s),signal:n})}catch(k){const w=k?.name==="AbortError",A=w?"Network request aborted":"Network request failed";throw w||console.error(k),new InvokeError(InvokeErrorType.NETWORK_ERROR,A,k)}if(!c.ok){const k=await c.json().catch(),w=k.error?.message||c.statusText;throw c.status===401||c.status===403?new InvokeError(InvokeErrorType.AUTH_ERROR,`Authentication failed: ${w}`,k):c.status===429?new InvokeError(InvokeErrorType.RATE_LIMIT,`Rate limit exceeded: ${w}`,k):c.status>=500?new InvokeError(InvokeErrorType.SERVER_ERROR,`Server error: ${w}`,k):new InvokeError(InvokeErrorType.UNKNOWN,`HTTP ${c.status}: ${w}`,k)}const l=await c.json(),d=l.choices?.[0];if(!d)throw new InvokeError(InvokeErrorType.UNKNOWN,"No choices in response",l);switch(d.finish_reason){case"tool_calls":case"function_call":case"stop":break;case"length":throw new InvokeError(InvokeErrorType.CONTEXT_LENGTH,"Response truncated: max tokens reached",void 0,l);case"content_filter":throw new InvokeError(InvokeErrorType.CONTENT_FILTER,"Content filtered by safety system",void 0,l);default:throw new InvokeError(InvokeErrorType.UNKNOWN,`Unexpected finish_reason: ${d.finish_reason}`,void 0,l)}const f=(r?.normalizeResponse?r.normalizeResponse(l):l).choices?.[0],g=f?.message?.tool_calls?.[0]?.function?.name;if(!g)throw new InvokeError(InvokeErrorType.NO_TOOL_CALL,"No tool call found in response",void 0,l);const m=o[g];if(!m)throw new InvokeError(InvokeErrorType.UNKNOWN,`Tool "${g}" not found in tools`,void 0,l);const I=f.message?.tool_calls?.[0]?.function?.arguments;if(!I)throw new InvokeError(InvokeErrorType.INVALID_TOOL_ARGS,"No tool call arguments found",void 0,l);let S;try{S=JSON.parse(I)}catch(k){throw new InvokeError(InvokeErrorType.INVALID_TOOL_ARGS,"Failed to parse tool arguments as JSON",k,l)}const P=m.inputSchema.safeParse(S);if(!P.success)throw console.error(prettifyError(P.error)),new InvokeError(InvokeErrorType.INVALID_TOOL_ARGS,"Tool arguments validation failed",P.error,l);const R=P.data;let F;try{F=await m.execute(R)}catch(k){throw new InvokeError(InvokeErrorType.TOOL_EXECUTION_ERROR,`Tool execution failed: ${k.message}`,k,l)}return{toolCall:{name:g,args:R},toolResult:F,usage:{promptTokens:l.usage?.prompt_tokens??0,completionTokens:l.usage?.completion_tokens??0,totalTokens:l.usage?.total_tokens??0,cachedTokens:l.usage?.prompt_tokens_details?.cached_tokens,reasoningTokens:l.usage?.completion_tokens_details?.reasoning_tokens},rawResponse:l,rawRequest:s}}};a(ct,"OpenAIClient");let OpenAIClient=ct;const LLM_MAX_RETRIES=2,DEFAULT_TEMPERATURE=.7;function parseLLMConfig(e){if(!e.baseURL||!e.apiKey||!e.model)throw new Error("[PageAgent] LLM configuration required. Please provide: baseURL, apiKey, model. See: https://alibaba.github.io/page-agent/docs/features/models");return{baseURL:e.baseURL,apiKey:e.apiKey,model:e.model,temperature:e.temperature??DEFAULT_TEMPERATURE,maxRetries:e.maxRetries??LLM_MAX_RETRIES,customFetch:(e.customFetch??fetch).bind(globalThis)}}a(parseLLMConfig,"parseLLMConfig");const lt=class lt extends EventTarget{config;client;constructor(t){super(),this.config=parseLLMConfig(t),this.client=new OpenAIClient(this.config)}async invoke(t,o,n,r){return await withRetry(async()=>{if(n.aborted)throw new Error("AbortError");return await this.client.invoke(t,o,n,r)},{maxRetries:this.config.maxRetries,onRetry:a(i=>{this.dispatchEvent(new CustomEvent("retry",{detail:{attempt:i,maxAttempts:this.config.maxRetries}}))},"onRetry"),onError:a(i=>{this.dispatchEvent(new CustomEvent("error",{detail:{error:i}}))},"onError")})}};a(lt,"LLM");let LLM=lt;async function withRetry(e,t){let o=0,n=null;for(;o<=t.maxRetries;){o>0&&(t.onRetry(o),await new Promise(r=>setTimeout(r,100)));try{return await e()}catch(r){if(r?.rawError?.name==="AbortError"||(console.error(r),t.onError(r),r instanceof InvokeError&&!r.retryable))throw r;n=r,o++,await new Promise(i=>setTimeout(i,100))}}throw n}a(withRetry,"withRetry");const DEFAULT_MAX_STEPS=20,SYSTEM_PROMPT=`You are an AI agent designed to operate in an iterative loop to automate browser tasks. Your ultimate goal is accomplishing the task provided in <user_request>.
45
46
 
46
47
  <intro>
47
48
  You excel at following tasks:
@@ -194,8 +195,8 @@ Here are examples of good output patterns. Use them as reference but never copy
194
195
  }
195
196
  }
196
197
  </output>
197
- `;function normalizeResponse(e){let t=null;const o=e.choices?.[0];if(!o)throw new Error("No choices in response");const n=o.message;if(!n)throw new Error("No message in choice");const r=n.tool_calls?.[0];if(r?.function?.arguments)t=safeJsonParse(r.function.arguments),r.function.name&&r.function.name!=="AgentOutput"&&(console.log(chalk.yellow("[normalizeResponse] #1: fixing tool_call")),t={action:safeJsonParse(t)});else if(n.content){const i=n.content.trim(),s=retrieveJsonFromString(i);if(s)t=safeJsonParse(s),t?.name==="AgentOutput"&&(console.log(chalk.yellow("[normalizeResponse] #2: fixing tool_call")),t=safeJsonParse(t.arguments)),t?.type==="function"&&(console.log(chalk.yellow("[normalizeResponse] #3: fixing tool_call")),t=safeJsonParse(t.function.arguments)),!t?.action&&!t?.evaluation_previous_goal&&!t?.memory&&!t?.next_goal&&!t?.thinking&&(console.log(chalk.yellow("[normalizeResponse] #4: fixing tool_call")),t={action:safeJsonParse(t)});else throw new Error("No tool_call and the message content does not contain valid JSON")}else throw new Error("No tool_call nor message content is present");return t=safeJsonParse(t),t.action&&(t.action=safeJsonParse(t.action)),t.action||(console.log(chalk.yellow("[normalizeResponse] #5: fixing tool_call")),t.action={name:"wait",input:{seconds:1}}),{...e,choices:[{...o,message:{...n,tool_calls:[{...r||{},function:{...r?.function||{},name:"AgentOutput",arguments:JSON.stringify(t)}}]}}]}}a(normalizeResponse,"normalizeResponse");function safeJsonParse(e){if(typeof e=="string")try{return JSON.parse(e.trim())}catch{return e}return e}a(safeJsonParse,"safeJsonParse");function retrieveJsonFromString(e){try{const t=/({[\s\S]*})/.exec(e)??[];return t.length===0?null:JSON.parse(t[0])}catch{return null}}a(retrieveJsonFromString,"retrieveJsonFromString");async function waitFor$1(e){await new Promise(t=>setTimeout(t,e*1e3))}a(waitFor$1,"waitFor$1");function randomID(e){let t=Math.random().toString(36).substring(2,11);if(!e)return t;const o=1e3;let n=0;for(;e.includes(t);)if(t=Math.random().toString(36).substring(2,11),n++,n>o)throw new Error("randomID: too many try");return t}a(randomID,"randomID");const _global=globalThis;_global.__PAGE_AGENT_IDS__||(_global.__PAGE_AGENT_IDS__=[]);const ids=_global.__PAGE_AGENT_IDS__;function uid(){const e=randomID(ids);return ids.push(e),e}a(uid,"uid");function assert(e,t,o){if(!e){const n=t??"Assertion failed";throw console.error(chalk.red(`❌ assert: ${n}`)),new Error(n)}}a(assert,"assert");function tool(e){return e}a(tool,"tool");const tools=new Map;tools.set("done",{description:"Complete task. Text is your final response to the user β€” keep it concise unless the user explicitly asks for detail.",inputSchema:object({text:string(),success:boolean().default(!0)}),execute:a(async function(e){return Promise.resolve("Task completed")},"execute")}),tools.set("wait",{description:"Wait for x seconds. Can be used to wait until the page or data is fully loaded.",inputSchema:object({seconds:number().min(1).max(10).default(1)}),execute:a(async function(e){const t=await this.pageController.getLastUpdateTime(),o=Math.max(0,e.seconds-(Date.now()-t)/1e3);return console.log(`actualWaitTime: ${o} seconds`),await waitFor$1(o),`βœ… Waited for ${e.seconds} seconds.`},"execute")}),tools.set("ask_user",{description:"Ask the user a question and wait for their answer. Use this if you need more information or clarification.",inputSchema:object({question:string()}),execute:a(async function(e){if(!this.onAskUser)throw new Error("ask_user tool requires onAskUser callback to be set");return`User answered: ${await this.onAskUser(e.question)}`},"execute")}),tools.set("click_element_by_index",{description:"Click element by index",inputSchema:object({index:int().min(0)}),execute:a(async function(e){return(await this.pageController.clickElement(e.index)).message},"execute")}),tools.set("input_text",{description:"Click and type text into an interactive input element",inputSchema:object({index:int().min(0),text:string()}),execute:a(async function(e){return(await this.pageController.inputText(e.index,e.text)).message},"execute")}),tools.set("select_dropdown_option",{description:"Select dropdown option for interactive element index by the text of the option you want to select",inputSchema:object({index:int().min(0),text:string()}),execute:a(async function(e){return(await this.pageController.selectOption(e.index,e.text)).message},"execute")}),tools.set("scroll",{description:"Scroll the page vertically. Use index for scroll elements (dropdowns/custom UI).",inputSchema:object({down:boolean().default(!0),num_pages:number().min(0).max(10).optional().default(.1),pixels:number().int().min(0).optional(),index:number().int().min(0).optional()}),execute:a(async function(e){return(await this.pageController.scroll({...e,numPages:e.num_pages})).message},"execute")}),tools.set("scroll_horizontally",{description:"Scroll the page horizontally, or within a specific element by index. Useful for wide tables.",inputSchema:object({right:boolean().default(!0),pixels:number().int().min(0),index:number().int().min(0).optional()}),execute:a(async function(e){return(await this.pageController.scrollHorizontally(e)).message},"execute")}),tools.set("execute_javascript",{description:"Execute JavaScript code on the current page. Supports async/await syntax. Use with caution!",inputSchema:object({script:string()}),execute:a(async function(e){return(await this.pageController.executeJavascript(e.script)).message},"execute")});const ut=class ut extends EventTarget{constructor(o){super();Z(this,C);ne(this,"id",uid());ne(this,"config");ne(this,"tools");ne(this,"pageController");ne(this,"task","");ne(this,"taskId","");ne(this,"history",[]);ne(this,"disposed",!1);ne(this,"onAskUser");Z(this,je,"idle");Z(this,Pe);Z(this,ie,new AbortController);Z(this,Oe,[]);Z(this,Q,{totalWaitTime:0,lastURL:"",browserState:null});if(this.config={...o,maxSteps:o.maxSteps||DEFAULT_MAX_STEPS},T(this,Pe,new LLM(this.config)),this.tools=new Map(tools),this.pageController=o.pageController,p(this,Pe).addEventListener("retry",n=>{const{attempt:r,maxAttempts:i}=n.detail;b(this,C,Fe).call(this,{type:"retrying",attempt:r,maxAttempts:i}),this.history.push({type:"retry",message:`LLM retry attempt ${r} of ${i}`,attempt:r,maxAttempts:i}),b(this,C,Ae).call(this)}),p(this,Pe).addEventListener("error",n=>{const r=n.detail.error;if(r?.rawError?.name==="AbortError")return;const i=String(r);b(this,C,Fe).call(this,{type:"error",message:i}),this.history.push({type:"error",message:i,rawResponse:r.rawResponse}),b(this,C,Ae).call(this)}),this.config.customTools)for(const[n,r]of Object.entries(this.config.customTools)){if(r===null){this.tools.delete(n);continue}this.tools.set(n,r)}this.config.experimentalScriptExecutionTool||this.tools.delete("execute_javascript")}get status(){return p(this,je)}pushObservation(o){p(this,Oe).push(o)}stop(){this.pageController.cleanUpHighlights(),this.pageController.hideMask(),p(this,ie).abort()}async execute(o){if(this.disposed)throw new Error("PageAgent has been disposed. Create a new instance.");if(!o)throw new Error("Task is required");this.task=o,this.taskId=uid(),this.onAskUser||this.tools.delete("ask_user");const n=this.config.onBeforeStep,r=this.config.onAfterStep,i=this.config.onBeforeTask,s=this.config.onAfterTask;await i?.(this),await this.pageController.showMask(),p(this,ie)&&(p(this,ie).abort(),T(this,ie,new AbortController)),this.history=[],b(this,C,_t).call(this,"running"),b(this,C,Ae).call(this),T(this,Q,{totalWaitTime:0,lastURL:"",browserState:null});let c=0;for(;;){try{console.group(`step: ${c}`),await n?.(this,c),console.log(chalk.blue.bold("πŸ‘€ Observing...")),p(this,Q).browserState=await this.pageController.getBrowserState(),await b(this,C,At).call(this,c);const l=[{role:"system",content:b(this,C,It).call(this)},{role:"user",content:await b(this,C,Pt).call(this)}],d={AgentOutput:b(this,C,Tt).call(this)};console.log(chalk.blue.bold("🧠 Thinking...")),b(this,C,Fe).call(this,{type:"thinking"});const h=await p(this,Pe).invoke(l,d,p(this,ie).signal,{toolChoiceName:"AgentOutput",normalizeResponse}),f=h.toolResult,g=f.input,m=f.output,I={evaluation_previous_goal:g.evaluation_previous_goal,memory:g.memory,next_goal:g.next_goal},S=Object.keys(g.action)[0],P={name:S,input:g.action[S],output:m};if(this.history.push({type:"step",stepIndex:c,reflection:I,action:P,usage:h.usage,rawResponse:h.rawResponse,rawRequest:h.rawRequest}),b(this,C,Ae).call(this),await r?.(this,this.history),console.groupEnd(),S==="done"){const R=P.input?.success??!1,D=P.input?.text||"no text provided";console.log(chalk.green.bold("Task completed"),R,D),b(this,C,st).call(this,R);const k={success:R,data:D,history:this.history};return await s?.(this,k),k}}catch(l){console.groupEnd();const d=l?.rawError?.name==="AbortError";console.error("Task failed",l);const h=d?"Task stopped":String(l);b(this,C,Fe).call(this,{type:"error",message:h}),this.history.push({type:"error",message:h,rawResponse:l}),b(this,C,Ae).call(this),b(this,C,st).call(this,!1);const f={success:!1,data:h,history:this.history};return await s?.(this,f),f}if(c++,c>this.config.maxSteps){const l="Step count exceeded maximum limit";this.history.push({type:"error",message:l}),b(this,C,Ae).call(this),b(this,C,st).call(this,!1);const d={success:!1,data:l,history:this.history};return await s?.(this,d),d}}}dispose(){console.log("Disposing PageAgent..."),this.disposed=!0,this.pageController.dispose(),p(this,ie).abort(),this.dispatchEvent(new Event("dispose")),this.config.onDispose?.(this)}};je=new WeakMap,Pe=new WeakMap,ie=new WeakMap,Oe=new WeakMap,Q=new WeakMap,C=new WeakSet,St=a(function(){this.dispatchEvent(new Event("statuschange"))},"#emitStatusChange"),Ae=a(function(){this.dispatchEvent(new Event("historychange"))},"#emitHistoryChange"),Fe=a(function(o){this.dispatchEvent(new CustomEvent("activity",{detail:o}))},"#emitActivity"),_t=a(function(o){p(this,je)!==o&&(T(this,je,o),b(this,C,St).call(this))},"#setStatus"),Tt=a(function(){const o=this.tools,n=Array.from(o.entries()).map(([s,c])=>object({[s]:c.inputSchema}).describe(c.description)),r=union(n);return{description:"You MUST call this tool every step!",inputSchema:object({evaluation_previous_goal:string().optional(),memory:string().optional(),next_goal:string().optional(),action:r}),execute:a(async s=>{if(p(this,ie).signal.aborted)throw new Error("AbortError");console.log(chalk.blue.bold("MacroTool input"),s);const c=s.action,l=Object.keys(c)[0],d=c[l],h=[];s.evaluation_previous_goal&&h.push(`βœ…: ${s.evaluation_previous_goal}`),s.memory&&h.push(`πŸ’Ύ: ${s.memory}`),s.next_goal&&h.push(`🎯: ${s.next_goal}`);const f=h.length>0?h.join(`
198
- `):"";f&&console.log(f);const g=o.get(l);assert(g,`Tool ${l} not found`),console.log(chalk.blue.bold(`Executing tool: ${l}`),d),b(this,C,Fe).call(this,{type:"executing",tool:l,input:d});const m=Date.now(),I=await g.execute.bind(this)(d),S=Date.now()-m;return console.log(chalk.green.bold(`Tool (${l}) executed for ${S}ms`),I),b(this,C,Fe).call(this,{type:"executed",tool:l,input:d,output:I,duration:S}),l==="wait"?p(this,Q).totalWaitTime+=d?.seconds||0:p(this,Q).totalWaitTime=0,{input:s,output:I}},"execute")}},"#packMacroTool"),It=a(function(){if(this.config.customSystemPrompt)return this.config.customSystemPrompt;const o=this.config.language==="zh-CN"?"δΈ­ζ–‡":"English";return SYSTEM_PROMPT.replace(/Default working language: \*\*.*?\*\*/,`Default working language: **${o}**`)},"#getSystemPrompt"),zt=a(async function(){const{instructions:o}=this.config;if(!o)return"";const n=o.system?.trim();let r;const i=p(this,Q).browserState?.url||"";if(o.getPageInstructions&&i)try{r=o.getPageInstructions(i)?.trim()}catch(c){console.error(chalk.red("[PageAgent] Failed to execute getPageInstructions callback:"),c)}if(!n&&!r)return"";let s=`<instructions>
198
+ `;function normalizeResponse(e,t){let o=null;const n=e.choices?.[0];if(!n)throw new Error("No choices in response");const r=n.message;if(!r)throw new Error("No message in choice");const i=r.tool_calls?.[0];if(i?.function?.arguments)o=safeJsonParse(i.function.arguments),i.function.name&&i.function.name!=="AgentOutput"&&(console.log(chalk.yellow("[normalizeResponse] #1: fixing tool_call")),o={action:safeJsonParse(o)});else if(r.content){const s=r.content.trim(),c=retrieveJsonFromString(s);if(c)o=safeJsonParse(c),o?.name==="AgentOutput"&&(console.log(chalk.yellow("[normalizeResponse] #2: fixing tool_call")),o=safeJsonParse(o.arguments)),o?.type==="function"&&(console.log(chalk.yellow("[normalizeResponse] #3: fixing tool_call")),o=safeJsonParse(o.function.arguments)),!o?.action&&!o?.evaluation_previous_goal&&!o?.memory&&!o?.next_goal&&!o?.thinking&&(console.log(chalk.yellow("[normalizeResponse] #4: fixing tool_call")),o={action:safeJsonParse(o)});else throw new Error("No tool_call and the message content does not contain valid JSON")}else throw new Error("No tool_call nor message content is present");return o=safeJsonParse(o),o.action&&(o.action=safeJsonParse(o.action)),o.action&&t&&(o.action=validateAction(o.action,t)),o.action||(console.log(chalk.yellow("[normalizeResponse] #5: fixing tool_call")),o.action={name:"wait",input:{seconds:1}}),{...e,choices:[{...n,message:{...r,tool_calls:[{...i||{},function:{...i?.function||{},name:"AgentOutput",arguments:JSON.stringify(o)}}]}}]}}a(normalizeResponse,"normalizeResponse");function validateAction(e,t){if(typeof e!="object"||e===null)return e;const o=Object.keys(e)[0];if(!o)return e;const n=t.get(o);if(!n){const c=Array.from(t.keys()).join(", ");throw new InvokeError(InvokeErrorType.INVALID_TOOL_ARGS,`Unknown action "${o}". Available: ${c}`)}let r=e[o];const i=n.inputSchema;if(i instanceof ZodObject&&r!==null&&typeof r!="object"){const c=Object.keys(i.shape).find(l=>!i.shape[l].safeParse(void 0).success);c&&(console.log(chalk.yellow(`[normalizeResponse] coercing primitive action input for "${o}"`)),r={[c]:r})}const s=i.safeParse(r);if(!s.success)throw new InvokeError(InvokeErrorType.INVALID_TOOL_ARGS,`Invalid input for action "${o}": ${prettifyError(s.error)}`);return{[o]:s.data}}a(validateAction,"validateAction");function safeJsonParse(e){if(typeof e=="string")try{return JSON.parse(e.trim())}catch{return e}return e}a(safeJsonParse,"safeJsonParse");function retrieveJsonFromString(e){try{const t=/({[\s\S]*})/.exec(e)??[];return t.length===0?null:JSON.parse(t[0])}catch{return null}}a(retrieveJsonFromString,"retrieveJsonFromString");async function waitFor$1(e){await new Promise(t=>setTimeout(t,e*1e3))}a(waitFor$1,"waitFor$1");function randomID(e){let t=Math.random().toString(36).substring(2,11);if(!e)return t;const o=1e3;let n=0;for(;e.includes(t);)if(t=Math.random().toString(36).substring(2,11),n++,n>o)throw new Error("randomID: too many try");return t}a(randomID,"randomID");const _global=globalThis;_global.__PAGE_AGENT_IDS__||(_global.__PAGE_AGENT_IDS__=[]);const ids=_global.__PAGE_AGENT_IDS__;function uid(){const e=randomID(ids);return ids.push(e),e}a(uid,"uid");function assert(e,t,o){if(!e){const n=t??"Assertion failed";throw console.error(chalk.red(`❌ assert: ${n}`)),new Error(n)}}a(assert,"assert");function tool(e){return e}a(tool,"tool");const tools=new Map;tools.set("done",{description:"Complete task. Text is your final response to the user β€” keep it concise unless the user explicitly asks for detail.",inputSchema:object({text:string(),success:boolean().default(!0)}),execute:a(async function(e){return Promise.resolve("Task completed")},"execute")}),tools.set("wait",{description:"Wait for x seconds. Can be used to wait until the page or data is fully loaded.",inputSchema:object({seconds:number().min(1).max(10).default(1)}),execute:a(async function(e){const t=await this.pageController.getLastUpdateTime(),o=Math.max(0,e.seconds-(Date.now()-t)/1e3);return console.log(`actualWaitTime: ${o} seconds`),await waitFor$1(o),`βœ… Waited for ${e.seconds} seconds.`},"execute")}),tools.set("ask_user",{description:"Ask the user a question and wait for their answer. Use this if you need more information or clarification.",inputSchema:object({question:string()}),execute:a(async function(e){if(!this.onAskUser)throw new Error("ask_user tool requires onAskUser callback to be set");return`User answered: ${await this.onAskUser(e.question)}`},"execute")}),tools.set("click_element_by_index",{description:"Click element by index",inputSchema:object({index:int().min(0)}),execute:a(async function(e){return(await this.pageController.clickElement(e.index)).message},"execute")}),tools.set("input_text",{description:"Click and type text into an interactive input element",inputSchema:object({index:int().min(0),text:string()}),execute:a(async function(e){return(await this.pageController.inputText(e.index,e.text)).message},"execute")}),tools.set("select_dropdown_option",{description:"Select dropdown option for interactive element index by the text of the option you want to select",inputSchema:object({index:int().min(0),text:string()}),execute:a(async function(e){return(await this.pageController.selectOption(e.index,e.text)).message},"execute")}),tools.set("scroll",{description:"Scroll the page vertically. Use index for scroll elements (dropdowns/custom UI).",inputSchema:object({down:boolean().default(!0),num_pages:number().min(0).max(10).optional().default(.1),pixels:number().int().min(0).optional(),index:number().int().min(0).optional()}),execute:a(async function(e){return(await this.pageController.scroll({...e,numPages:e.num_pages})).message},"execute")}),tools.set("scroll_horizontally",{description:"Scroll the page horizontally, or within a specific element by index. Useful for wide tables.",inputSchema:object({right:boolean().default(!0),pixels:number().int().min(0),index:number().int().min(0).optional()}),execute:a(async function(e){return(await this.pageController.scrollHorizontally(e)).message},"execute")}),tools.set("execute_javascript",{description:"Execute JavaScript code on the current page. Supports async/await syntax. Use with caution!",inputSchema:object({script:string()}),execute:a(async function(e){return(await this.pageController.executeJavascript(e.script)).message},"execute")});const ut=class ut extends EventTarget{constructor(o){super();Z(this,C);ne(this,"id",uid());ne(this,"config");ne(this,"tools");ne(this,"pageController");ne(this,"task","");ne(this,"taskId","");ne(this,"history",[]);ne(this,"disposed",!1);ne(this,"onAskUser");Z(this,je,"idle");Z(this,Pe);Z(this,ie,new AbortController);Z(this,Oe,[]);Z(this,Q,{totalWaitTime:0,lastURL:"",browserState:null});if(this.config={...o,maxSteps:o.maxSteps||DEFAULT_MAX_STEPS},T(this,Pe,new LLM(this.config)),this.tools=new Map(tools),this.pageController=o.pageController,p(this,Pe).addEventListener("retry",n=>{const{attempt:r,maxAttempts:i}=n.detail;b(this,C,De).call(this,{type:"retrying",attempt:r,maxAttempts:i}),this.history.push({type:"retry",message:`LLM retry attempt ${r} of ${i}`,attempt:r,maxAttempts:i}),b(this,C,Ae).call(this)}),p(this,Pe).addEventListener("error",n=>{const r=n.detail.error;if(r?.rawError?.name==="AbortError")return;const i=String(r);b(this,C,De).call(this,{type:"error",message:i}),this.history.push({type:"error",message:i,rawResponse:r.rawResponse}),b(this,C,Ae).call(this)}),this.config.customTools)for(const[n,r]of Object.entries(this.config.customTools)){if(r===null){this.tools.delete(n);continue}this.tools.set(n,r)}this.config.experimentalScriptExecutionTool||this.tools.delete("execute_javascript")}get status(){return p(this,je)}pushObservation(o){p(this,Oe).push(o)}stop(){this.pageController.cleanUpHighlights(),this.pageController.hideMask(),p(this,ie).abort()}async execute(o){if(this.disposed)throw new Error("PageAgent has been disposed. Create a new instance.");if(!o)throw new Error("Task is required");this.task=o,this.taskId=uid(),this.onAskUser||this.tools.delete("ask_user");const n=this.config.onBeforeStep,r=this.config.onAfterStep,i=this.config.onBeforeTask,s=this.config.onAfterTask;await i?.(this),await this.pageController.showMask(),p(this,ie)&&(p(this,ie).abort(),T(this,ie,new AbortController)),this.history=[],b(this,C,_t).call(this,"running"),b(this,C,Ae).call(this),T(this,Q,{totalWaitTime:0,lastURL:"",browserState:null});let c=0;for(;;){try{console.group(`step: ${c}`),await n?.(this,c),console.log(chalk.blue.bold("πŸ‘€ Observing...")),p(this,Q).browserState=await this.pageController.getBrowserState(),await b(this,C,At).call(this,c);const l=[{role:"system",content:b(this,C,It).call(this)},{role:"user",content:await b(this,C,Pt).call(this)}],d={AgentOutput:b(this,C,Tt).call(this)};console.log(chalk.blue.bold("🧠 Thinking...")),b(this,C,De).call(this,{type:"thinking"});const h=await p(this,Pe).invoke(l,d,p(this,ie).signal,{toolChoiceName:"AgentOutput",normalizeResponse:a(R=>normalizeResponse(R,this.tools),"normalizeResponse")}),f=h.toolResult,g=f.input,m=f.output,I={evaluation_previous_goal:g.evaluation_previous_goal,memory:g.memory,next_goal:g.next_goal},S=Object.keys(g.action)[0],P={name:S,input:g.action[S],output:m};if(this.history.push({type:"step",stepIndex:c,reflection:I,action:P,usage:h.usage,rawResponse:h.rawResponse,rawRequest:h.rawRequest}),b(this,C,Ae).call(this),await r?.(this,this.history),console.groupEnd(),S==="done"){const R=P.input?.success??!1,F=P.input?.text||"no text provided";console.log(chalk.green.bold("Task completed"),R,F),b(this,C,st).call(this,R);const k={success:R,data:F,history:this.history};return await s?.(this,k),k}}catch(l){console.groupEnd();const d=l?.rawError?.name==="AbortError";console.error("Task failed",l);const h=d?"Task stopped":String(l);b(this,C,De).call(this,{type:"error",message:h}),this.history.push({type:"error",message:h,rawResponse:l}),b(this,C,Ae).call(this),b(this,C,st).call(this,!1);const f={success:!1,data:h,history:this.history};return await s?.(this,f),f}if(c++,c>this.config.maxSteps){const l="Step count exceeded maximum limit";this.history.push({type:"error",message:l}),b(this,C,Ae).call(this),b(this,C,st).call(this,!1);const d={success:!1,data:l,history:this.history};return await s?.(this,d),d}}}dispose(){console.log("Disposing PageAgent..."),this.disposed=!0,this.pageController.dispose(),p(this,ie).abort(),this.dispatchEvent(new Event("dispose")),this.config.onDispose?.(this)}};je=new WeakMap,Pe=new WeakMap,ie=new WeakMap,Oe=new WeakMap,Q=new WeakMap,C=new WeakSet,St=a(function(){this.dispatchEvent(new Event("statuschange"))},"#emitStatusChange"),Ae=a(function(){this.dispatchEvent(new Event("historychange"))},"#emitHistoryChange"),De=a(function(o){this.dispatchEvent(new CustomEvent("activity",{detail:o}))},"#emitActivity"),_t=a(function(o){p(this,je)!==o&&(T(this,je,o),b(this,C,St).call(this))},"#setStatus"),Tt=a(function(){const o=this.tools,n=Array.from(o.entries()).map(([s,c])=>object({[s]:c.inputSchema}).describe(c.description)),r=union(n);return{description:"You MUST call this tool every step!",inputSchema:object({evaluation_previous_goal:string().optional(),memory:string().optional(),next_goal:string().optional(),action:r}),execute:a(async s=>{if(p(this,ie).signal.aborted)throw new Error("AbortError");console.log(chalk.blue.bold("MacroTool input"),s);const c=s.action,l=Object.keys(c)[0],d=c[l],h=[];s.evaluation_previous_goal&&h.push(`βœ…: ${s.evaluation_previous_goal}`),s.memory&&h.push(`πŸ’Ύ: ${s.memory}`),s.next_goal&&h.push(`🎯: ${s.next_goal}`);const f=h.length>0?h.join(`
199
+ `):"";f&&console.log(f);const g=o.get(l);assert(g,`Tool ${l} not found`),console.log(chalk.blue.bold(`Executing tool: ${l}`),d),b(this,C,De).call(this,{type:"executing",tool:l,input:d});const m=Date.now(),I=await g.execute.bind(this)(d),S=Date.now()-m;return console.log(chalk.green.bold(`Tool (${l}) executed for ${S}ms`),I),b(this,C,De).call(this,{type:"executed",tool:l,input:d,output:I,duration:S}),l==="wait"?p(this,Q).totalWaitTime+=d?.seconds||0:p(this,Q).totalWaitTime=0,{input:s,output:I}},"execute")}},"#packMacroTool"),It=a(function(){if(this.config.customSystemPrompt)return this.config.customSystemPrompt;const o=this.config.language==="zh-CN"?"δΈ­ζ–‡":"English";return SYSTEM_PROMPT.replace(/Default working language: \*\*.*?\*\*/,`Default working language: **${o}**`)},"#getSystemPrompt"),zt=a(async function(){const{instructions:o}=this.config;if(!o)return"";const n=o.system?.trim();let r;const i=p(this,Q).browserState?.url||"";if(o.getPageInstructions&&i)try{r=o.getPageInstructions(i)?.trim()}catch(c){console.error(chalk.red("[PageAgent] Failed to execute getPageInstructions callback:"),c)}if(!n&&!r)return"";let s=`<instructions>
199
200
  `;return n&&(s+=`<system_instructions>
200
201
  ${n}
201
202
  </system_instructions>
@@ -232,7 +233,7 @@ ${r}
232
233
 
233
234
  `,n+=`</browser_state>
234
235
 
235
- `,n},"#assembleUserPrompt"),st=a(function(o=!0){this.pageController.cleanUpHighlights(),this.pageController.hideMask(),b(this,C,_t).call(this,o?"completed":"error"),p(this,ie).abort()},"#onDone"),a(ut,"PageAgentCore");let PageAgentCore=ut;async function waitFor(e){await new Promise(t=>setTimeout(t,e*1e3))}a(waitFor,"waitFor");async function movePointerToElement(e){const t=e.getBoundingClientRect(),o=t.left+t.width/2,n=t.top+t.height/2;window.dispatchEvent(new CustomEvent("PageAgent::MovePointerTo",{detail:{x:o,y:n}})),await waitFor(.3)}a(movePointerToElement,"movePointerToElement");function getElementByIndex(e,t){const o=e.get(t);if(!o)throw new Error(`No interactive element found at index ${t}`);const n=o.ref;if(!n)throw new Error(`Element at index ${t} does not have a reference`);if(!(n instanceof HTMLElement))throw new Error(`Element at index ${t} is not an HTMLElement`);return n}a(getElementByIndex,"getElementByIndex");let lastClickedElement=null;function blurLastClickedElement(){lastClickedElement&&(lastClickedElement.blur(),lastClickedElement.dispatchEvent(new MouseEvent("mouseout",{bubbles:!0,cancelable:!0})),lastClickedElement=null)}a(blurLastClickedElement,"blurLastClickedElement");async function clickElement(e){blurLastClickedElement(),lastClickedElement=e,await scrollIntoViewIfNeeded(e),await movePointerToElement(e),window.dispatchEvent(new CustomEvent("PageAgent::ClickPointer")),await waitFor(.1),e.dispatchEvent(new MouseEvent("mouseenter",{bubbles:!0,cancelable:!0})),e.dispatchEvent(new MouseEvent("mouseover",{bubbles:!0,cancelable:!0})),e.dispatchEvent(new MouseEvent("mousedown",{bubbles:!0,cancelable:!0})),e.focus(),e.dispatchEvent(new MouseEvent("mouseup",{bubbles:!0,cancelable:!0})),e.dispatchEvent(new MouseEvent("click",{bubbles:!0,cancelable:!0})),await waitFor(.1)}a(clickElement,"clickElement");const nativeInputValueSetter=Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype,"value").set,nativeTextAreaValueSetter=Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype,"value").set;async function inputTextElement(e,t){if(!(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement))throw new Error("Element is not an input or textarea");await clickElement(e),e instanceof HTMLTextAreaElement?nativeTextAreaValueSetter.call(e,t):nativeInputValueSetter.call(e,t);const o=new Event("input",{bubbles:!0});e.dispatchEvent(o),await waitFor(.1),blurLastClickedElement()}a(inputTextElement,"inputTextElement");async function selectOptionElement(e,t){if(!(e instanceof HTMLSelectElement))throw new Error("Element is not a select element");const n=Array.from(e.options).find(r=>r.textContent?.trim()===t.trim());if(!n)throw new Error(`Option with text "${t}" not found in select element`);e.value=n.value,e.dispatchEvent(new Event("change",{bubbles:!0})),await waitFor(.1)}a(selectOptionElement,"selectOptionElement");async function scrollIntoViewIfNeeded(e){const t=e;t.scrollIntoViewIfNeeded?t.scrollIntoViewIfNeeded():t.scrollIntoView({behavior:"auto",block:"center",inline:"nearest"})}a(scrollIntoViewIfNeeded,"scrollIntoViewIfNeeded");async function scrollVertically(e,t,o){if(o){const c=o;console.log("[SCROLL DEBUG] Starting direct container scroll for element:",c.tagName);let l=c,d=!1,h=null,f=0,g=0;const m=t;for(;l&&g<10;){const I=window.getComputedStyle(l),S=/(auto|scroll|overlay)/.test(I.overflowY),P=l.scrollHeight>l.clientHeight;if(console.log("[SCROLL DEBUG] Checking element:",l.tagName,"hasScrollableY:",S,"canScrollVertically:",P,"scrollHeight:",l.scrollHeight,"clientHeight:",l.clientHeight),S&&P){const R=l.scrollTop,D=l.scrollHeight-l.clientHeight;let k=m/3;k>0?k=Math.min(k,D-R):k=Math.max(k,-R),l.scrollTop=R+k;const w=l.scrollTop,A=w-R;if(console.log("[SCROLL DEBUG] Scroll attempt:",l.tagName,"before:",R,"after:",w,"delta:",A),Math.abs(A)>.5){d=!0,h=l,f=A,console.log("[SCROLL DEBUG] Successfully scrolled container:",l.tagName,"delta:",A);break}}if(l===document.body||l===document.documentElement)break;l=l.parentElement,g++}return d?`Scrolled container (${h?.tagName}) by ${f}px`:`No scrollable container found for element (${c.tagName})`}const n=t,r=a(c=>c.clientHeight>=window.innerHeight*.5,"bigEnough"),i=a(c=>c&&/(auto|scroll|overlay)/.test(getComputedStyle(c).overflowY)&&c.scrollHeight>c.clientHeight&&r(c),"canScroll");let s=document.activeElement;for(;s&&!i(s)&&s!==document.body;)s=s.parentElement;if(s=i(s)?s:Array.from(document.querySelectorAll("*")).find(i)||document.scrollingElement||document.documentElement,s===document.scrollingElement||s===document.documentElement||s===document.body){const c=window.scrollY,l=document.documentElement.scrollHeight-window.innerHeight;window.scrollBy(0,n);const d=window.scrollY,h=d-c;if(Math.abs(h)<1)return n>0?"⚠️ Already at the bottom of the page, cannot scroll down further.":"⚠️ Already at the top of the page, cannot scroll up further.";const f=n>0&&d>=l-1,g=n<0&&d<=1;return f?`βœ… Scrolled page by ${h}px. Reached the bottom of the page.`:g?`βœ… Scrolled page by ${h}px. Reached the top of the page.`:`βœ… Scrolled page by ${h}px.`}else{const c=s.scrollTop,l=s.scrollHeight-s.clientHeight;s.scrollBy({top:n,behavior:"smooth"}),await waitFor(.1);const d=s.scrollTop,h=d-c;if(Math.abs(h)<1)return n>0?`⚠️ Already at the bottom of container (${s.tagName}), cannot scroll down further.`:`⚠️ Already at the top of container (${s.tagName}), cannot scroll up further.`;const f=n>0&&d>=l-1,g=n<0&&d<=1;return f?`βœ… Scrolled container (${s.tagName}) by ${h}px. Reached the bottom.`:g?`βœ… Scrolled container (${s.tagName}) by ${h}px. Reached the top.`:`βœ… Scrolled container (${s.tagName}) by ${h}px.`}}a(scrollVertically,"scrollVertically");async function scrollHorizontally(e,t,o){if(o){const c=o;console.log("[SCROLL DEBUG] Starting direct container scroll for element:",c.tagName);let l=c,d=!1,h=null,f=0,g=0;const m=e?t:-t;for(;l&&g<10;){const I=window.getComputedStyle(l),S=/(auto|scroll|overlay)/.test(I.overflowX),P=l.scrollWidth>l.clientWidth;if(console.log("[SCROLL DEBUG] Checking element:",l.tagName,"hasScrollableX:",S,"canScrollHorizontally:",P,"scrollWidth:",l.scrollWidth,"clientWidth:",l.clientWidth),S&&P){const R=l.scrollLeft,D=l.scrollWidth-l.clientWidth;let k=m/3;k>0?k=Math.min(k,D-R):k=Math.max(k,-R),l.scrollLeft=R+k;const w=l.scrollLeft,A=w-R;if(console.log("[SCROLL DEBUG] Scroll attempt:",l.tagName,"before:",R,"after:",w,"delta:",A),Math.abs(A)>.5){d=!0,h=l,f=A,console.log("[SCROLL DEBUG] Successfully scrolled container:",l.tagName,"delta:",A);break}}if(l===document.body||l===document.documentElement)break;l=l.parentElement,g++}return d?`Scrolled container (${h?.tagName}) horizontally by ${f}px`:`No horizontally scrollable container found for element (${c.tagName})`}const n=e?t:-t,r=a(c=>c.clientWidth>=window.innerWidth*.5,"bigEnough"),i=a(c=>c&&/(auto|scroll|overlay)/.test(getComputedStyle(c).overflowX)&&c.scrollWidth>c.clientWidth&&r(c),"canScroll");let s=document.activeElement;for(;s&&!i(s)&&s!==document.body;)s=s.parentElement;if(s=i(s)?s:Array.from(document.querySelectorAll("*")).find(i)||document.scrollingElement||document.documentElement,s===document.scrollingElement||s===document.documentElement||s===document.body){const c=window.scrollX,l=document.documentElement.scrollWidth-window.innerWidth;window.scrollBy(n,0);const d=window.scrollX,h=d-c;if(Math.abs(h)<1)return n>0?"⚠️ Already at the right edge of the page, cannot scroll right further.":"⚠️ Already at the left edge of the page, cannot scroll left further.";const f=n>0&&d>=l-1,g=n<0&&d<=1;return f?`βœ… Scrolled page by ${h}px. Reached the right edge of the page.`:g?`βœ… Scrolled page by ${h}px. Reached the left edge of the page.`:`βœ… Scrolled page horizontally by ${h}px.`}else{const c=s.scrollLeft,l=s.scrollWidth-s.clientWidth;s.scrollBy({left:n,behavior:"smooth"}),await waitFor(.1);const d=s.scrollLeft,h=d-c;if(Math.abs(h)<1)return n>0?`⚠️ Already at the right edge of container (${s.tagName}), cannot scroll right further.`:`⚠️ Already at the left edge of container (${s.tagName}), cannot scroll left further.`;const f=n>0&&d>=l-1,g=n<0&&d<=1;return f?`βœ… Scrolled container (${s.tagName}) by ${h}px. Reached the right edge.`:g?`βœ… Scrolled container (${s.tagName}) by ${h}px. Reached the left edge.`:`βœ… Scrolled container (${s.tagName}) horizontally by ${h}px.`}}a(scrollHorizontally,"scrollHorizontally");const VIEWPORT_EXPANSION=-1,domTree=a((e={doHighlightElements:!0,focusHighlightIndex:-1,viewportExpansion:0,debugMode:!1,interactiveBlacklist:[],interactiveWhitelist:[],highlightOpacity:.1,highlightLabelOpacity:.5})=>{const{interactiveBlacklist:t,interactiveWhitelist:o,highlightOpacity:n,highlightLabelOpacity:r}=e,{doHighlightElements:i,focusHighlightIndex:s,viewportExpansion:c,debugMode:l}=e;let d=0;const h=new WeakMap;function f(u,y){!u||u.nodeType!==Node.ELEMENT_NODE||h.set(u,{...h.get(u),...y})}a(f,"addExtraData");const g={boundingRects:new WeakMap,clientRects:new WeakMap,computedStyles:new WeakMap,clearCache:a(()=>{g.boundingRects=new WeakMap,g.clientRects=new WeakMap,g.computedStyles=new WeakMap},"clearCache")};function m(u){if(!u)return null;if(g.boundingRects.has(u))return g.boundingRects.get(u);const y=u.getBoundingClientRect();return y&&g.boundingRects.set(u,y),y}a(m,"getCachedBoundingRect");function I(u){if(!u)return null;if(g.computedStyles.has(u))return g.computedStyles.get(u);const y=window.getComputedStyle(u);return y&&g.computedStyles.set(u,y),y}a(I,"getCachedComputedStyle");function S(u){if(!u)return null;if(g.clientRects.has(u))return g.clientRects.get(u);const y=u.getClientRects();return y&&g.clientRects.set(u,y),y}a(S,"getCachedClientRects");const P={},R={current:0},D="playwright-highlight-container";function k(u,y,O=null){if(!u)return y;const v=[];let E=null,N=20,$=16,z=null;try{let x=document.getElementById(D);x||(x=document.createElement("div"),x.id=D,x.style.position="fixed",x.style.pointerEvents="none",x.style.top="0",x.style.left="0",x.style.width="100%",x.style.height="100%",x.style.zIndex="2147483640",x.style.backgroundColor="transparent",document.body.appendChild(x));const F=u.getClientRects();if(!F||F.length===0)return y;const K=["#FF0000","#00FF00","#0000FF","#FFA500","#800080","#008080","#FF69B4","#4B0082","#FF4500","#2E8B57","#DC143C","#4682B4"],J=y%K.length;let Ie=K[J];const te=Ie+Math.floor(n*255).toString(16).padStart(2,"0");Ie=Ie+Math.floor(r*255).toString(16).padStart(2,"0");let se={x:0,y:0};if(O){const G=O.getBoundingClientRect();se.x=G.left,se.y=G.top}const ge=document.createDocumentFragment();for(const G of F){if(G.width===0||G.height===0)continue;const H=document.createElement("div");H.style.position="fixed",H.style.border=`2px solid ${Ie}`,H.style.backgroundColor=te,H.style.pointerEvents="none",H.style.boxSizing="border-box";const U=G.top+se.y,ke=G.left+se.x;H.style.top=`${U}px`,H.style.left=`${ke}px`,H.style.width=`${G.width}px`,H.style.height=`${G.height}px`,ge.appendChild(H),v.push({element:H,initialRect:G})}const me=F[0];E=document.createElement("div"),E.className="playwright-highlight-label",E.style.position="fixed",E.style.background=Ie,E.style.color="white",E.style.padding="1px 4px",E.style.borderRadius="4px",E.style.fontSize=`${Math.min(12,Math.max(8,me.height/2))}px`,E.textContent=y.toString(),N=E.offsetWidth>0?E.offsetWidth:N,$=E.offsetHeight>0?E.offsetHeight:$;const Me=me.top+se.y,et=me.left+se.x;let nt=Me+2,Ve=et+me.width-N-2;(me.width<N+4||me.height<$+4)&&(nt=Me-$-2,Ve=et+me.width-N,Ve<se.x&&(Ve=et)),nt=Math.max(0,Math.min(nt,window.innerHeight-$)),Ve=Math.max(0,Math.min(Ve,window.innerWidth-N)),E.style.top=`${nt}px`,E.style.left=`${Ve}px`,ge.appendChild(E);const rt=a((G,H)=>{let U=0;return(...ke)=>{const oe=performance.now();if(!(oe-U<H))return U=oe,G(...ke)}},"throttleFunction")(a(()=>{const G=u.getClientRects();let H={x:0,y:0};if(O){const U=O.getBoundingClientRect();H.x=U.left,H.y=U.top}if(v.forEach((U,ke)=>{if(ke<G.length){const oe=G[ke],Ge=oe.top+H.y,ze=oe.left+H.x;U.element.style.top=`${Ge}px`,U.element.style.left=`${ze}px`,U.element.style.width=`${oe.width}px`,U.element.style.height=`${oe.height}px`,U.element.style.display=oe.width===0||oe.height===0?"none":"block"}else U.element.style.display="none"}),G.length<v.length)for(let U=G.length;U<v.length;U++)v[U].element.style.display="none";if(E&&G.length>0){const U=G[0],ke=U.top+H.y,oe=U.left+H.x;let Ge=ke+2,ze=oe+U.width-N-2;(U.width<N+4||U.height<$+4)&&(Ge=ke-$-2,ze=oe+U.width-N,ze<H.x&&(ze=oe)),Ge=Math.max(0,Math.min(Ge,window.innerHeight-$)),ze=Math.max(0,Math.min(ze,window.innerWidth-N)),E.style.top=`${Ge}px`,E.style.left=`${ze}px`,E.style.display="block"}else E&&(E.style.display="none")},"updatePositions"),16);return window.addEventListener("scroll",rt,!0),window.addEventListener("resize",rt),z=a(()=>{window.removeEventListener("scroll",rt,!0),window.removeEventListener("resize",rt),v.forEach(G=>G.element.remove()),E&&E.remove()},"cleanupFn"),x.appendChild(ge),y+1}finally{z&&(window._highlightCleanupFunctions=window._highlightCleanupFunctions||[]).push(z)}}a(k,"highlightElement");function w(u){if(!u||u.nodeType!==Node.ELEMENT_NODE)return null;const y=I(u);if(!y)return null;const O=y.display;if(O==="inline"||O==="inline-block")return null;const v=y.overflowX,E=y.overflowY,N=v==="auto"||v==="scroll",$=E==="auto"||E==="scroll";if(!N&&!$)return null;const z=u.scrollWidth-u.clientWidth,x=u.scrollHeight-u.clientHeight,F=4;if(z<F&&x<F||!$&&z<F||!N&&x<F)return null;const K=u.scrollTop,J=u.scrollLeft,Ie=u.scrollWidth-u.clientWidth-u.scrollLeft,te=u.scrollHeight-u.clientHeight-u.scrollTop,se={top:K,right:Ie,bottom:te,left:J};return f(u,{scrollable:!0,scrollData:se}),se}a(w,"isScrollableElement");function A(u){try{if(c===-1){const $=u.parentElement;if(!$)return!1;try{return $.checkVisibility({checkOpacity:!0,checkVisibilityCSS:!0})}catch{const x=window.getComputedStyle($);return x.display!=="none"&&x.visibility!=="hidden"&&x.opacity!=="0"}}const y=document.createRange();y.selectNodeContents(u);const O=y.getClientRects();if(!O||O.length===0)return!1;let v=!1,E=!1;for(const $ of O)if($.width>0&&$.height>0&&(v=!0,!($.bottom<-c||$.top>window.innerHeight+c||$.right<-c||$.left>window.innerWidth+c))){E=!0;break}if(!v||!E)return!1;const N=u.parentElement;if(!N)return!1;try{return N.checkVisibility({checkOpacity:!0,checkVisibilityCSS:!0})}catch{const z=window.getComputedStyle(N);return z.display!=="none"&&z.visibility!=="hidden"&&z.opacity!=="0"}}catch(y){return console.warn("Error checking text node visibility:",y),!1}}a(A,"isTextNodeVisible");function Te(u){if(!u||!u.tagName)return!1;const y=new Set(["body","div","main","article","section","nav","header","footer"]),O=u.tagName.toLowerCase();return y.has(O)?!0:!new Set(["svg","script","style","link","meta","noscript","template"]).has(O)}a(Te,"isElementAccepted");function B(u){const y=I(u);return u.offsetWidth>0&&u.offsetHeight>0&&y?.visibility!=="hidden"&&y?.display!=="none"}a(B,"isElementVisible");function q(u){if(!u||u.nodeType!==Node.ELEMENT_NODE||t.includes(u))return!1;if(o.includes(u))return!0;const y=u.tagName.toLowerCase(),O=I(u),v=new Set(["pointer","move","text","grab","grabbing","cell","copy","alias","all-scroll","col-resize","context-menu","crosshair","e-resize","ew-resize","help","n-resize","ne-resize","nesw-resize","ns-resize","nw-resize","nwse-resize","row-resize","s-resize","se-resize","sw-resize","vertical-text","w-resize","zoom-in","zoom-out"]),E=new Set(["not-allowed","no-drop","wait","progress","initial","inherit"]);function N(te){return te.tagName.toLowerCase()==="html"?!1:!!(O?.cursor&&v.has(O.cursor))}if(a(N,"doesElementHaveInteractivePointer"),N(u))return!0;const z=new Set(["a","button","input","select","textarea","details","summary","label","option","optgroup","fieldset","legend"]),x=new Set(["disabled","readonly"]);if(z.has(y)){if(O?.cursor&&E.has(O.cursor))return!1;for(const te of x)if(u.hasAttribute(te)||u.getAttribute(te)==="true"||u.getAttribute(te)==="")return!1;return!(u.disabled||u.readOnly||u.inert)}const F=u.getAttribute("role"),K=u.getAttribute("aria-role");if(u.getAttribute("contenteditable")==="true"||u.isContentEditable||u.classList&&(u.classList.contains("button")||u.classList.contains("dropdown-toggle")||u.getAttribute("data-index")||u.getAttribute("data-toggle")==="dropdown"||u.getAttribute("aria-haspopup")==="true"))return!0;const J=new Set(["button","menu","menubar","menuitem","menuitemradio","menuitemcheckbox","radio","checkbox","tab","switch","slider","spinbutton","combobox","searchbox","textbox","listbox","option","scrollbar"]);if(z.has(y)||F&&J.has(F)||K&&J.has(K))return!0;try{if(typeof getEventListeners=="function"){const ge=getEventListeners(u),me=["click","mousedown","mouseup","dblclick"];for(const Me of me)if(ge[Me]&&ge[Me].length>0)return!0}const te=u?.ownerDocument?.defaultView?.getEventListenersForNode||window.getEventListenersForNode;if(typeof te=="function"){const ge=te(u),me=["click","mousedown","mouseup","keydown","keyup","submit","change","input","focus","blur"];for(const Me of me)for(const et of ge)if(et.type===Me)return!0}const se=["onclick","onmousedown","onmouseup","ondblclick"];for(const ge of se)if(u.hasAttribute(ge)||typeof u[ge]=="function")return!0}catch{}return!!w(u)}a(q,"isInteractiveElement");function ue(u){if(c===-1)return!0;const y=S(u);if(!y||y.length===0)return!1;let O=!1;for(const x of y)if(x.width>0&&x.height>0&&!(x.bottom<-c||x.top>window.innerHeight+c||x.right<-c||x.left>window.innerWidth+c)){O=!0;break}if(!O)return!1;if(u.ownerDocument!==window.document)return!0;let E=Array.from(y).find(x=>x.width>0&&x.height>0);if(!E)return!1;const N=u.getRootNode();if(N instanceof ShadowRoot){const x=E.left+E.width/2,F=E.top+E.height/2;try{const K=N.elementFromPoint(x,F);if(!K)return!1;let J=K;for(;J&&J!==N;){if(J===u)return!0;J=J.parentElement}return!1}catch{return!0}}const $=5;return[{x:E.left+E.width/2,y:E.top+E.height/2},{x:E.left+$,y:E.top+$},{x:E.right-$,y:E.bottom-$}].some(({x,y:F})=>{try{const K=document.elementFromPoint(x,F);if(!K)return!1;let J=K;for(;J&&J!==document.documentElement;){if(J===u)return!0;J=J.parentElement}return!1}catch{return!0}})}a(ue,"isTopElement");function X(u,y){if(y===-1)return!0;const O=u.getClientRects();if(!O||O.length===0){const v=m(u);return!v||v.width===0||v.height===0?!1:!(v.bottom<-y||v.top>window.innerHeight+y||v.right<-y||v.left>window.innerWidth+y)}for(const v of O)if(!(v.width===0||v.height===0)&&!(v.bottom<-y||v.top>window.innerHeight+y||v.right<-y||v.left>window.innerWidth+y))return!0;return!1}a(X,"isInExpandedViewport");function de(u){if(!u||u.nodeType!==Node.ELEMENT_NODE)return!1;const y=u.tagName.toLowerCase();return new Set(["a","button","input","select","textarea","details","summary","label"]).has(y)?!0:u.hasAttribute("onclick")||u.hasAttribute("role")||u.hasAttribute("tabindex")||u.hasAttribute("aria-")||u.hasAttribute("data-action")||u.getAttribute("contenteditable")==="true"}a(de,"isInteractiveCandidate");const pe=new Set(["a","button","input","select","textarea","summary","details","label","option"]),Xe=new Set(["button","link","menuitem","menuitemradio","menuitemcheckbox","radio","checkbox","tab","switch","slider","spinbutton","combobox","searchbox","textbox","listbox","option","scrollbar"]);function he(u){if(!u||u.nodeType!==Node.ELEMENT_NODE||!B(u))return!1;const y=u.hasAttribute("role")||u.hasAttribute("tabindex")||u.hasAttribute("onclick")||typeof u.onclick=="function",O=/\b(btn|clickable|menu|item|entry|link)\b/i.test(u.className||""),v=!!u.closest('button,a,[role="button"],.menu,.dropdown,.list,.toolbar'),E=[...u.children].some(B),N=u.parentElement&&u.parentElement.isSameNode(document.body);return(q(u)||y||O)&&E&&v&&!N}a(he,"isHeuristicallyInteractive");function Ke(u){if(!u||u.nodeType!==Node.ELEMENT_NODE)return!1;const y=u.tagName.toLowerCase(),O=u.getAttribute("role");if(y==="iframe"||pe.has(y)||O&&Xe.has(O)||u.isContentEditable||u.getAttribute("contenteditable")==="true"||u.hasAttribute("data-testid")||u.hasAttribute("data-cy")||u.hasAttribute("data-test")||u.hasAttribute("onclick")||typeof u.onclick=="function")return!0;try{const v=u?.ownerDocument?.defaultView?.getEventListenersForNode||window.getEventListenersForNode;if(typeof v=="function"){const N=v(u),$=["click","mousedown","mouseup","keydown","keyup","submit","change","input","focus","blur"];for(const z of $)for(const x of N)if(x.type===z)return!0}if(["onmousedown","onmouseup","onkeydown","onkeyup","onsubmit","onchange","oninput","onfocus","onblur"].some(N=>u.hasAttribute(N)))return!0}catch{}return!!he(u)}a(Ke,"isElementDistinctInteraction");function Qe(u,y,O,v){if(!u.isInteractive)return!1;let E=!1;return v?Ke(y)?E=!0:E=!1:E=!0,E&&(u.isInViewport=X(y,c),(u.isInViewport||c===-1)&&(u.highlightIndex=d++,i))?(s>=0?s===u.highlightIndex&&k(y,u.highlightIndex,O):k(y,u.highlightIndex,O),!0):!1}a(Qe,"handleHighlighting");function _e(u,y=null,O=!1){if(!u||u.id===D||u.nodeType!==Node.ELEMENT_NODE&&u.nodeType!==Node.TEXT_NODE||!u||u.id===D||u.dataset?.browserUseIgnore==="true"||u.getAttribute&&u.getAttribute("aria-hidden")==="true")return null;if(u===document.body){const $={tagName:"body",attributes:{},xpath:"/body",children:[]};for(const x of u.childNodes){const F=_e(x,y,!1);F&&$.children.push(F)}const z=`${R.current++}`;return P[z]=$,z}if(u.nodeType!==Node.ELEMENT_NODE&&u.nodeType!==Node.TEXT_NODE)return null;if(u.nodeType===Node.TEXT_NODE){const $=u.textContent?.trim();if(!$)return null;const z=u.parentElement;if(!z||z.tagName.toLowerCase()==="script")return null;const x=`${R.current++}`;return P[x]={type:"TEXT_NODE",text:$,isVisible:A(u)},x}if(u.nodeType===Node.ELEMENT_NODE&&!Te(u))return null;if(c!==-1&&!u.shadowRoot){const $=m(u),z=I(u),x=z&&(z.position==="fixed"||z.position==="sticky"),F=u.offsetWidth>0||u.offsetHeight>0;if(!$||!x&&!F&&($.bottom<-c||$.top>window.innerHeight+c||$.right<-c||$.left>window.innerWidth+c))return null}const v={tagName:u.tagName.toLowerCase(),attributes:{},children:[]};if(de(u)||u.tagName.toLowerCase()==="iframe"||u.tagName.toLowerCase()==="body"){const $=u.getAttributeNames?.()||[];for(const z of $){const x=u.getAttribute(z);v.attributes[z]=x}u.tagName.toLowerCase()==="input"&&(u.type==="checkbox"||u.type==="radio")&&(v.attributes.checked=u.checked?"true":"false")}let E=!1;if(u.nodeType===Node.ELEMENT_NODE&&(v.isVisible=B(u),v.isVisible)){v.isTopElement=ue(u);const $=u.getAttribute("role"),z=$==="menu"||$==="menubar"||$==="listbox";(v.isTopElement||z)&&(v.isInteractive=q(u),E=Qe(v,u,y,O),v.ref=u)}if(u.tagName){const $=u.tagName.toLowerCase();if($==="iframe")try{const z=u.contentDocument||u.contentWindow?.document;if(z)for(const x of z.childNodes){const F=_e(x,u,!1);F&&v.children.push(F)}}catch(z){console.warn("Unable to access iframe:",z)}else if(u.isContentEditable||u.getAttribute("contenteditable")==="true"||u.id==="tinymce"||u.classList.contains("mce-content-body")||$==="body"&&u.getAttribute("data-id")?.startsWith("mce_"))for(const z of u.childNodes){const x=_e(z,y,E);x&&v.children.push(x)}else{if(u.shadowRoot){v.shadowRoot=!0;for(const z of u.shadowRoot.childNodes){const x=_e(z,y,E);x&&v.children.push(x)}}for(const z of u.childNodes){const F=_e(z,y,E||O);F&&v.children.push(F)}}}if(v.tagName==="a"&&v.children.length===0&&!v.attributes.href){const $=m(u);if(!($&&$.width>0&&$.height>0||u.offsetWidth>0||u.offsetHeight>0))return null}v.extra=h.get(u)||null;const N=`${R.current++}`;return P[N]=v,N}a(_e,"buildDomTree");const fe=_e(document.body);return g.clearCache(),{rootId:fe,map:P}},"domTree"),newElementsCache=new WeakMap;function getFlatTree(e){const t=[];for(const i of e.interactiveBlacklist||[])typeof i=="function"?t.push(i()):t.push(i);const o=[];for(const i of e.interactiveWhitelist||[])typeof i=="function"?o.push(i()):o.push(i);const n=domTree({doHighlightElements:!0,debugMode:!0,focusHighlightIndex:-1,viewportExpansion:VIEWPORT_EXPANSION,interactiveBlacklist:t,interactiveWhitelist:o,highlightOpacity:e.highlightOpacity??0,highlightLabelOpacity:e.highlightLabelOpacity??.1}),r=window.location.href;for(const i in n.map){const s=n.map[i];if(s.isInteractive&&s.ref){const c=s.ref;newElementsCache.has(c)||(newElementsCache.set(c,r),s.isNew=!0)}}return n}a(getFlatTree,"getFlatTree");function flatTreeToString(e,t){const o=["title","type","checked","name","role","value","placeholder","data-date-format","alt","aria-label","aria-expanded","data-state","aria-checked","id","for","target","aria-haspopup","aria-controls","aria-owns"],n=[...t||[],...o],r=a((f,g)=>f.length>g?f.substring(0,g)+"...":f,"capTextLength"),i=a(f=>{const g=e.map[f];if(!g)return null;if(g.type==="TEXT_NODE"){const m=g;return{type:"text",text:m.text,isVisible:m.isVisible,parent:null,children:[]}}else{const m=g,I=[];if(m.children)for(const S of m.children){const P=i(S);P&&(P.parent=null,I.push(P))}return{type:"element",tagName:m.tagName,attributes:m.attributes??{},isVisible:m.isVisible??!1,isInteractive:m.isInteractive??!1,isTopElement:m.isTopElement??!1,isNew:m.isNew??!1,highlightIndex:m.highlightIndex,parent:null,children:I,extra:m.extra??{}}}},"buildTreeNode"),s=a((f,g=null)=>{f.parent=g;for(const m of f.children)s(m,f)},"setParentReferences"),c=i(e.rootId);if(!c)return"";s(c);const l=a(f=>{let g=f.parent;for(;g;){if(g.type==="element"&&g.highlightIndex!==void 0)return!0;g=g.parent}return!1},"hasParentWithHighlightIndex"),d=a((f,g,m)=>{let I=g;const S=" ".repeat(g);if(f.type==="element"){if(f.highlightIndex!==void 0){I+=1;const P=getAllTextTillNextClickableElement(f);let R="";if(n.length>0&&f.attributes){const w={};for(const B of n){const q=f.attributes[B];q&&q.trim()!==""&&(w[B]=q.trim())}const A=n.filter(B=>B in w);if(A.length>1){const B=new Set,q={};for(const ue of A){const X=w[ue];X.length>5&&(X in q?B.add(ue):q[X]=ue)}for(const ue of B)delete w[ue]}w.role===f.tagName&&delete w.role;const Te=["aria-label","placeholder","title"];for(const B of Te)w[B]&&w[B].toLowerCase().trim()===P.toLowerCase().trim()&&delete w[B];Object.keys(w).length>0&&(R=Object.entries(w).map(([B,q])=>`${B}=${r(q,20)}`).join(" "))}const D=f.isNew?`*[${f.highlightIndex}]`:`[${f.highlightIndex}]`;let k=`${S}${D}<${f.tagName??""}`;if(R&&(k+=` ${R}`),f.extra&&f.extra.scrollable){let w="";f.extra.scrollData?.left&&(w+=`left=${f.extra.scrollData.left}, `),f.extra.scrollData?.top&&(w+=`top=${f.extra.scrollData.top}, `),f.extra.scrollData?.right&&(w+=`right=${f.extra.scrollData.right}, `),f.extra.scrollData?.bottom&&(w+=`bottom=${f.extra.scrollData.bottom}`),k+=` data-scrollable="${w}"`}if(P){const w=P.trim();R||(k+=" "),k+=`>${w}`}else R||(k+=" ");k+=" />",m.push(k)}for(const P of f.children)d(P,I,m)}else if(f.type==="text"){if(l(f))return;f.parent&&f.parent.type==="element"&&f.parent.isVisible&&f.parent.isTopElement&&m.push(`${S}${f.text??""}`)}},"processNode"),h=[];return d(c,0,h),h.join(`
236
+ `,n},"#assembleUserPrompt"),st=a(function(o=!0){this.pageController.cleanUpHighlights(),this.pageController.hideMask(),b(this,C,_t).call(this,o?"completed":"error"),p(this,ie).abort()},"#onDone"),a(ut,"PageAgentCore");let PageAgentCore=ut;async function waitFor(e){await new Promise(t=>setTimeout(t,e*1e3))}a(waitFor,"waitFor");async function movePointerToElement(e){const t=e.getBoundingClientRect(),o=t.left+t.width/2,n=t.top+t.height/2;window.dispatchEvent(new CustomEvent("PageAgent::MovePointerTo",{detail:{x:o,y:n}})),await waitFor(.3)}a(movePointerToElement,"movePointerToElement");function getElementByIndex(e,t){const o=e.get(t);if(!o)throw new Error(`No interactive element found at index ${t}`);const n=o.ref;if(!n)throw new Error(`Element at index ${t} does not have a reference`);if(!(n instanceof HTMLElement))throw new Error(`Element at index ${t} is not an HTMLElement`);return n}a(getElementByIndex,"getElementByIndex");let lastClickedElement=null;function blurLastClickedElement(){lastClickedElement&&(lastClickedElement.blur(),lastClickedElement.dispatchEvent(new MouseEvent("mouseout",{bubbles:!0,cancelable:!0})),lastClickedElement=null)}a(blurLastClickedElement,"blurLastClickedElement");async function clickElement(e){blurLastClickedElement(),lastClickedElement=e,await scrollIntoViewIfNeeded(e),await movePointerToElement(e),window.dispatchEvent(new CustomEvent("PageAgent::ClickPointer")),await waitFor(.1),e.dispatchEvent(new MouseEvent("mouseenter",{bubbles:!0,cancelable:!0})),e.dispatchEvent(new MouseEvent("mouseover",{bubbles:!0,cancelable:!0})),e.dispatchEvent(new MouseEvent("mousedown",{bubbles:!0,cancelable:!0})),e.focus(),e.dispatchEvent(new MouseEvent("mouseup",{bubbles:!0,cancelable:!0})),e.dispatchEvent(new MouseEvent("click",{bubbles:!0,cancelable:!0})),await waitFor(.1)}a(clickElement,"clickElement");const nativeInputValueSetter=Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype,"value").set,nativeTextAreaValueSetter=Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype,"value").set;async function inputTextElement(e,t){if(!(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement))throw new Error("Element is not an input or textarea");await clickElement(e),e instanceof HTMLTextAreaElement?nativeTextAreaValueSetter.call(e,t):nativeInputValueSetter.call(e,t);const o=new Event("input",{bubbles:!0});e.dispatchEvent(o),await waitFor(.1),blurLastClickedElement()}a(inputTextElement,"inputTextElement");async function selectOptionElement(e,t){if(!(e instanceof HTMLSelectElement))throw new Error("Element is not a select element");const n=Array.from(e.options).find(r=>r.textContent?.trim()===t.trim());if(!n)throw new Error(`Option with text "${t}" not found in select element`);e.value=n.value,e.dispatchEvent(new Event("change",{bubbles:!0})),await waitFor(.1)}a(selectOptionElement,"selectOptionElement");async function scrollIntoViewIfNeeded(e){const t=e;t.scrollIntoViewIfNeeded?t.scrollIntoViewIfNeeded():t.scrollIntoView({behavior:"auto",block:"center",inline:"nearest"})}a(scrollIntoViewIfNeeded,"scrollIntoViewIfNeeded");async function scrollVertically(e,t,o){if(o){const c=o;console.log("[SCROLL DEBUG] Starting direct container scroll for element:",c.tagName);let l=c,d=!1,h=null,f=0,g=0;const m=t;for(;l&&g<10;){const I=window.getComputedStyle(l),S=/(auto|scroll|overlay)/.test(I.overflowY),P=l.scrollHeight>l.clientHeight;if(console.log("[SCROLL DEBUG] Checking element:",l.tagName,"hasScrollableY:",S,"canScrollVertically:",P,"scrollHeight:",l.scrollHeight,"clientHeight:",l.clientHeight),S&&P){const R=l.scrollTop,F=l.scrollHeight-l.clientHeight;let k=m/3;k>0?k=Math.min(k,F-R):k=Math.max(k,-R),l.scrollTop=R+k;const w=l.scrollTop,A=w-R;if(console.log("[SCROLL DEBUG] Scroll attempt:",l.tagName,"before:",R,"after:",w,"delta:",A),Math.abs(A)>.5){d=!0,h=l,f=A,console.log("[SCROLL DEBUG] Successfully scrolled container:",l.tagName,"delta:",A);break}}if(l===document.body||l===document.documentElement)break;l=l.parentElement,g++}return d?`Scrolled container (${h?.tagName}) by ${f}px`:`No scrollable container found for element (${c.tagName})`}const n=t,r=a(c=>c.clientHeight>=window.innerHeight*.5,"bigEnough"),i=a(c=>c&&/(auto|scroll|overlay)/.test(getComputedStyle(c).overflowY)&&c.scrollHeight>c.clientHeight&&r(c),"canScroll");let s=document.activeElement;for(;s&&!i(s)&&s!==document.body;)s=s.parentElement;if(s=i(s)?s:Array.from(document.querySelectorAll("*")).find(i)||document.scrollingElement||document.documentElement,s===document.scrollingElement||s===document.documentElement||s===document.body){const c=window.scrollY,l=document.documentElement.scrollHeight-window.innerHeight;window.scrollBy(0,n);const d=window.scrollY,h=d-c;if(Math.abs(h)<1)return n>0?"⚠️ Already at the bottom of the page, cannot scroll down further.":"⚠️ Already at the top of the page, cannot scroll up further.";const f=n>0&&d>=l-1,g=n<0&&d<=1;return f?`βœ… Scrolled page by ${h}px. Reached the bottom of the page.`:g?`βœ… Scrolled page by ${h}px. Reached the top of the page.`:`βœ… Scrolled page by ${h}px.`}else{const c=s.scrollTop,l=s.scrollHeight-s.clientHeight;s.scrollBy({top:n,behavior:"smooth"}),await waitFor(.1);const d=s.scrollTop,h=d-c;if(Math.abs(h)<1)return n>0?`⚠️ Already at the bottom of container (${s.tagName}), cannot scroll down further.`:`⚠️ Already at the top of container (${s.tagName}), cannot scroll up further.`;const f=n>0&&d>=l-1,g=n<0&&d<=1;return f?`βœ… Scrolled container (${s.tagName}) by ${h}px. Reached the bottom.`:g?`βœ… Scrolled container (${s.tagName}) by ${h}px. Reached the top.`:`βœ… Scrolled container (${s.tagName}) by ${h}px.`}}a(scrollVertically,"scrollVertically");async function scrollHorizontally(e,t,o){if(o){const c=o;console.log("[SCROLL DEBUG] Starting direct container scroll for element:",c.tagName);let l=c,d=!1,h=null,f=0,g=0;const m=e?t:-t;for(;l&&g<10;){const I=window.getComputedStyle(l),S=/(auto|scroll|overlay)/.test(I.overflowX),P=l.scrollWidth>l.clientWidth;if(console.log("[SCROLL DEBUG] Checking element:",l.tagName,"hasScrollableX:",S,"canScrollHorizontally:",P,"scrollWidth:",l.scrollWidth,"clientWidth:",l.clientWidth),S&&P){const R=l.scrollLeft,F=l.scrollWidth-l.clientWidth;let k=m/3;k>0?k=Math.min(k,F-R):k=Math.max(k,-R),l.scrollLeft=R+k;const w=l.scrollLeft,A=w-R;if(console.log("[SCROLL DEBUG] Scroll attempt:",l.tagName,"before:",R,"after:",w,"delta:",A),Math.abs(A)>.5){d=!0,h=l,f=A,console.log("[SCROLL DEBUG] Successfully scrolled container:",l.tagName,"delta:",A);break}}if(l===document.body||l===document.documentElement)break;l=l.parentElement,g++}return d?`Scrolled container (${h?.tagName}) horizontally by ${f}px`:`No horizontally scrollable container found for element (${c.tagName})`}const n=e?t:-t,r=a(c=>c.clientWidth>=window.innerWidth*.5,"bigEnough"),i=a(c=>c&&/(auto|scroll|overlay)/.test(getComputedStyle(c).overflowX)&&c.scrollWidth>c.clientWidth&&r(c),"canScroll");let s=document.activeElement;for(;s&&!i(s)&&s!==document.body;)s=s.parentElement;if(s=i(s)?s:Array.from(document.querySelectorAll("*")).find(i)||document.scrollingElement||document.documentElement,s===document.scrollingElement||s===document.documentElement||s===document.body){const c=window.scrollX,l=document.documentElement.scrollWidth-window.innerWidth;window.scrollBy(n,0);const d=window.scrollX,h=d-c;if(Math.abs(h)<1)return n>0?"⚠️ Already at the right edge of the page, cannot scroll right further.":"⚠️ Already at the left edge of the page, cannot scroll left further.";const f=n>0&&d>=l-1,g=n<0&&d<=1;return f?`βœ… Scrolled page by ${h}px. Reached the right edge of the page.`:g?`βœ… Scrolled page by ${h}px. Reached the left edge of the page.`:`βœ… Scrolled page horizontally by ${h}px.`}else{const c=s.scrollLeft,l=s.scrollWidth-s.clientWidth;s.scrollBy({left:n,behavior:"smooth"}),await waitFor(.1);const d=s.scrollLeft,h=d-c;if(Math.abs(h)<1)return n>0?`⚠️ Already at the right edge of container (${s.tagName}), cannot scroll right further.`:`⚠️ Already at the left edge of container (${s.tagName}), cannot scroll left further.`;const f=n>0&&d>=l-1,g=n<0&&d<=1;return f?`βœ… Scrolled container (${s.tagName}) by ${h}px. Reached the right edge.`:g?`βœ… Scrolled container (${s.tagName}) by ${h}px. Reached the left edge.`:`βœ… Scrolled container (${s.tagName}) horizontally by ${h}px.`}}a(scrollHorizontally,"scrollHorizontally");const VIEWPORT_EXPANSION=-1,domTree=a((e={doHighlightElements:!0,focusHighlightIndex:-1,viewportExpansion:0,debugMode:!1,interactiveBlacklist:[],interactiveWhitelist:[],highlightOpacity:.1,highlightLabelOpacity:.5})=>{const{interactiveBlacklist:t,interactiveWhitelist:o,highlightOpacity:n,highlightLabelOpacity:r}=e,{doHighlightElements:i,focusHighlightIndex:s,viewportExpansion:c,debugMode:l}=e;let d=0;const h=new WeakMap;function f(u,y){!u||u.nodeType!==Node.ELEMENT_NODE||h.set(u,{...h.get(u),...y})}a(f,"addExtraData");const g={boundingRects:new WeakMap,clientRects:new WeakMap,computedStyles:new WeakMap,clearCache:a(()=>{g.boundingRects=new WeakMap,g.clientRects=new WeakMap,g.computedStyles=new WeakMap},"clearCache")};function m(u){if(!u)return null;if(g.boundingRects.has(u))return g.boundingRects.get(u);const y=u.getBoundingClientRect();return y&&g.boundingRects.set(u,y),y}a(m,"getCachedBoundingRect");function I(u){if(!u)return null;if(g.computedStyles.has(u))return g.computedStyles.get(u);const y=window.getComputedStyle(u);return y&&g.computedStyles.set(u,y),y}a(I,"getCachedComputedStyle");function S(u){if(!u)return null;if(g.clientRects.has(u))return g.clientRects.get(u);const y=u.getClientRects();return y&&g.clientRects.set(u,y),y}a(S,"getCachedClientRects");const P={},R={current:0},F="playwright-highlight-container";function k(u,y,O=null){if(!u)return y;const v=[];let E=null,N=20,$=16,z=null;try{let x=document.getElementById(F);x||(x=document.createElement("div"),x.id=F,x.style.position="fixed",x.style.pointerEvents="none",x.style.top="0",x.style.left="0",x.style.width="100%",x.style.height="100%",x.style.zIndex="2147483640",x.style.backgroundColor="transparent",document.body.appendChild(x));const D=u.getClientRects();if(!D||D.length===0)return y;const K=["#FF0000","#00FF00","#0000FF","#FFA500","#800080","#008080","#FF69B4","#4B0082","#FF4500","#2E8B57","#DC143C","#4682B4"],J=y%K.length;let Ie=K[J];const te=Ie+Math.floor(n*255).toString(16).padStart(2,"0");Ie=Ie+Math.floor(r*255).toString(16).padStart(2,"0");let se={x:0,y:0};if(O){const G=O.getBoundingClientRect();se.x=G.left,se.y=G.top}const ge=document.createDocumentFragment();for(const G of D){if(G.width===0||G.height===0)continue;const H=document.createElement("div");H.style.position="fixed",H.style.border=`2px solid ${Ie}`,H.style.backgroundColor=te,H.style.pointerEvents="none",H.style.boxSizing="border-box";const U=G.top+se.y,ke=G.left+se.x;H.style.top=`${U}px`,H.style.left=`${ke}px`,H.style.width=`${G.width}px`,H.style.height=`${G.height}px`,ge.appendChild(H),v.push({element:H,initialRect:G})}const me=D[0];E=document.createElement("div"),E.className="playwright-highlight-label",E.style.position="fixed",E.style.background=Ie,E.style.color="white",E.style.padding="1px 4px",E.style.borderRadius="4px",E.style.fontSize=`${Math.min(12,Math.max(8,me.height/2))}px`,E.textContent=y.toString(),N=E.offsetWidth>0?E.offsetWidth:N,$=E.offsetHeight>0?E.offsetHeight:$;const Me=me.top+se.y,et=me.left+se.x;let nt=Me+2,Ve=et+me.width-N-2;(me.width<N+4||me.height<$+4)&&(nt=Me-$-2,Ve=et+me.width-N,Ve<se.x&&(Ve=et)),nt=Math.max(0,Math.min(nt,window.innerHeight-$)),Ve=Math.max(0,Math.min(Ve,window.innerWidth-N)),E.style.top=`${nt}px`,E.style.left=`${Ve}px`,ge.appendChild(E);const rt=a((G,H)=>{let U=0;return(...ke)=>{const oe=performance.now();if(!(oe-U<H))return U=oe,G(...ke)}},"throttleFunction")(a(()=>{const G=u.getClientRects();let H={x:0,y:0};if(O){const U=O.getBoundingClientRect();H.x=U.left,H.y=U.top}if(v.forEach((U,ke)=>{if(ke<G.length){const oe=G[ke],Ge=oe.top+H.y,ze=oe.left+H.x;U.element.style.top=`${Ge}px`,U.element.style.left=`${ze}px`,U.element.style.width=`${oe.width}px`,U.element.style.height=`${oe.height}px`,U.element.style.display=oe.width===0||oe.height===0?"none":"block"}else U.element.style.display="none"}),G.length<v.length)for(let U=G.length;U<v.length;U++)v[U].element.style.display="none";if(E&&G.length>0){const U=G[0],ke=U.top+H.y,oe=U.left+H.x;let Ge=ke+2,ze=oe+U.width-N-2;(U.width<N+4||U.height<$+4)&&(Ge=ke-$-2,ze=oe+U.width-N,ze<H.x&&(ze=oe)),Ge=Math.max(0,Math.min(Ge,window.innerHeight-$)),ze=Math.max(0,Math.min(ze,window.innerWidth-N)),E.style.top=`${Ge}px`,E.style.left=`${ze}px`,E.style.display="block"}else E&&(E.style.display="none")},"updatePositions"),16);return window.addEventListener("scroll",rt,!0),window.addEventListener("resize",rt),z=a(()=>{window.removeEventListener("scroll",rt,!0),window.removeEventListener("resize",rt),v.forEach(G=>G.element.remove()),E&&E.remove()},"cleanupFn"),x.appendChild(ge),y+1}finally{z&&(window._highlightCleanupFunctions=window._highlightCleanupFunctions||[]).push(z)}}a(k,"highlightElement");function w(u){if(!u||u.nodeType!==Node.ELEMENT_NODE)return null;const y=I(u);if(!y)return null;const O=y.display;if(O==="inline"||O==="inline-block")return null;const v=y.overflowX,E=y.overflowY,N=v==="auto"||v==="scroll",$=E==="auto"||E==="scroll";if(!N&&!$)return null;const z=u.scrollWidth-u.clientWidth,x=u.scrollHeight-u.clientHeight,D=4;if(z<D&&x<D||!$&&z<D||!N&&x<D)return null;const K=u.scrollTop,J=u.scrollLeft,Ie=u.scrollWidth-u.clientWidth-u.scrollLeft,te=u.scrollHeight-u.clientHeight-u.scrollTop,se={top:K,right:Ie,bottom:te,left:J};return f(u,{scrollable:!0,scrollData:se}),se}a(w,"isScrollableElement");function A(u){try{if(c===-1){const $=u.parentElement;if(!$)return!1;try{return $.checkVisibility({checkOpacity:!0,checkVisibilityCSS:!0})}catch{const x=window.getComputedStyle($);return x.display!=="none"&&x.visibility!=="hidden"&&x.opacity!=="0"}}const y=document.createRange();y.selectNodeContents(u);const O=y.getClientRects();if(!O||O.length===0)return!1;let v=!1,E=!1;for(const $ of O)if($.width>0&&$.height>0&&(v=!0,!($.bottom<-c||$.top>window.innerHeight+c||$.right<-c||$.left>window.innerWidth+c))){E=!0;break}if(!v||!E)return!1;const N=u.parentElement;if(!N)return!1;try{return N.checkVisibility({checkOpacity:!0,checkVisibilityCSS:!0})}catch{const z=window.getComputedStyle(N);return z.display!=="none"&&z.visibility!=="hidden"&&z.opacity!=="0"}}catch(y){return console.warn("Error checking text node visibility:",y),!1}}a(A,"isTextNodeVisible");function Te(u){if(!u||!u.tagName)return!1;const y=new Set(["body","div","main","article","section","nav","header","footer"]),O=u.tagName.toLowerCase();return y.has(O)?!0:!new Set(["svg","script","style","link","meta","noscript","template"]).has(O)}a(Te,"isElementAccepted");function B(u){const y=I(u);return u.offsetWidth>0&&u.offsetHeight>0&&y?.visibility!=="hidden"&&y?.display!=="none"}a(B,"isElementVisible");function q(u){if(!u||u.nodeType!==Node.ELEMENT_NODE||t.includes(u))return!1;if(o.includes(u))return!0;const y=u.tagName.toLowerCase(),O=I(u),v=new Set(["pointer","move","text","grab","grabbing","cell","copy","alias","all-scroll","col-resize","context-menu","crosshair","e-resize","ew-resize","help","n-resize","ne-resize","nesw-resize","ns-resize","nw-resize","nwse-resize","row-resize","s-resize","se-resize","sw-resize","vertical-text","w-resize","zoom-in","zoom-out"]),E=new Set(["not-allowed","no-drop","wait","progress","initial","inherit"]);function N(te){return te.tagName.toLowerCase()==="html"?!1:!!(O?.cursor&&v.has(O.cursor))}if(a(N,"doesElementHaveInteractivePointer"),N(u))return!0;const z=new Set(["a","button","input","select","textarea","details","summary","label","option","optgroup","fieldset","legend"]),x=new Set(["disabled","readonly"]);if(z.has(y)){if(O?.cursor&&E.has(O.cursor))return!1;for(const te of x)if(u.hasAttribute(te)||u.getAttribute(te)==="true"||u.getAttribute(te)==="")return!1;return!(u.disabled||u.readOnly||u.inert)}const D=u.getAttribute("role"),K=u.getAttribute("aria-role");if(u.getAttribute("contenteditable")==="true"||u.isContentEditable||u.classList&&(u.classList.contains("button")||u.classList.contains("dropdown-toggle")||u.getAttribute("data-index")||u.getAttribute("data-toggle")==="dropdown"||u.getAttribute("aria-haspopup")==="true"))return!0;const J=new Set(["button","menu","menubar","menuitem","menuitemradio","menuitemcheckbox","radio","checkbox","tab","switch","slider","spinbutton","combobox","searchbox","textbox","listbox","option","scrollbar"]);if(z.has(y)||D&&J.has(D)||K&&J.has(K))return!0;try{if(typeof getEventListeners=="function"){const ge=getEventListeners(u),me=["click","mousedown","mouseup","dblclick"];for(const Me of me)if(ge[Me]&&ge[Me].length>0)return!0}const te=u?.ownerDocument?.defaultView?.getEventListenersForNode||window.getEventListenersForNode;if(typeof te=="function"){const ge=te(u),me=["click","mousedown","mouseup","keydown","keyup","submit","change","input","focus","blur"];for(const Me of me)for(const et of ge)if(et.type===Me)return!0}const se=["onclick","onmousedown","onmouseup","ondblclick"];for(const ge of se)if(u.hasAttribute(ge)||typeof u[ge]=="function")return!0}catch{}return!!w(u)}a(q,"isInteractiveElement");function ue(u){if(c===-1)return!0;const y=S(u);if(!y||y.length===0)return!1;let O=!1;for(const x of y)if(x.width>0&&x.height>0&&!(x.bottom<-c||x.top>window.innerHeight+c||x.right<-c||x.left>window.innerWidth+c)){O=!0;break}if(!O)return!1;if(u.ownerDocument!==window.document)return!0;let E=Array.from(y).find(x=>x.width>0&&x.height>0);if(!E)return!1;const N=u.getRootNode();if(N instanceof ShadowRoot){const x=E.left+E.width/2,D=E.top+E.height/2;try{const K=N.elementFromPoint(x,D);if(!K)return!1;let J=K;for(;J&&J!==N;){if(J===u)return!0;J=J.parentElement}return!1}catch{return!0}}const $=5;return[{x:E.left+E.width/2,y:E.top+E.height/2},{x:E.left+$,y:E.top+$},{x:E.right-$,y:E.bottom-$}].some(({x,y:D})=>{try{const K=document.elementFromPoint(x,D);if(!K)return!1;let J=K;for(;J&&J!==document.documentElement;){if(J===u)return!0;J=J.parentElement}return!1}catch{return!0}})}a(ue,"isTopElement");function X(u,y){if(y===-1)return!0;const O=u.getClientRects();if(!O||O.length===0){const v=m(u);return!v||v.width===0||v.height===0?!1:!(v.bottom<-y||v.top>window.innerHeight+y||v.right<-y||v.left>window.innerWidth+y)}for(const v of O)if(!(v.width===0||v.height===0)&&!(v.bottom<-y||v.top>window.innerHeight+y||v.right<-y||v.left>window.innerWidth+y))return!0;return!1}a(X,"isInExpandedViewport");function de(u){if(!u||u.nodeType!==Node.ELEMENT_NODE)return!1;const y=u.tagName.toLowerCase();return new Set(["a","button","input","select","textarea","details","summary","label"]).has(y)?!0:u.hasAttribute("onclick")||u.hasAttribute("role")||u.hasAttribute("tabindex")||u.hasAttribute("aria-")||u.hasAttribute("data-action")||u.getAttribute("contenteditable")==="true"}a(de,"isInteractiveCandidate");const pe=new Set(["a","button","input","select","textarea","summary","details","label","option"]),Xe=new Set(["button","link","menuitem","menuitemradio","menuitemcheckbox","radio","checkbox","tab","switch","slider","spinbutton","combobox","searchbox","textbox","listbox","option","scrollbar"]);function he(u){if(!u||u.nodeType!==Node.ELEMENT_NODE||!B(u))return!1;const y=u.hasAttribute("role")||u.hasAttribute("tabindex")||u.hasAttribute("onclick")||typeof u.onclick=="function",O=/\b(btn|clickable|menu|item|entry|link)\b/i.test(u.className||""),v=!!u.closest('button,a,[role="button"],.menu,.dropdown,.list,.toolbar'),E=[...u.children].some(B),N=u.parentElement&&u.parentElement.isSameNode(document.body);return(q(u)||y||O)&&E&&v&&!N}a(he,"isHeuristicallyInteractive");function Ke(u){if(!u||u.nodeType!==Node.ELEMENT_NODE)return!1;const y=u.tagName.toLowerCase(),O=u.getAttribute("role");if(y==="iframe"||pe.has(y)||O&&Xe.has(O)||u.isContentEditable||u.getAttribute("contenteditable")==="true"||u.hasAttribute("data-testid")||u.hasAttribute("data-cy")||u.hasAttribute("data-test")||u.hasAttribute("onclick")||typeof u.onclick=="function")return!0;try{const v=u?.ownerDocument?.defaultView?.getEventListenersForNode||window.getEventListenersForNode;if(typeof v=="function"){const N=v(u),$=["click","mousedown","mouseup","keydown","keyup","submit","change","input","focus","blur"];for(const z of $)for(const x of N)if(x.type===z)return!0}if(["onmousedown","onmouseup","onkeydown","onkeyup","onsubmit","onchange","oninput","onfocus","onblur"].some(N=>u.hasAttribute(N)))return!0}catch{}return!!he(u)}a(Ke,"isElementDistinctInteraction");function Qe(u,y,O,v){if(!u.isInteractive)return!1;let E=!1;return v?Ke(y)?E=!0:E=!1:E=!0,E&&(u.isInViewport=X(y,c),(u.isInViewport||c===-1)&&(u.highlightIndex=d++,i))?(s>=0?s===u.highlightIndex&&k(y,u.highlightIndex,O):k(y,u.highlightIndex,O),!0):!1}a(Qe,"handleHighlighting");function _e(u,y=null,O=!1){if(!u||u.id===F||u.nodeType!==Node.ELEMENT_NODE&&u.nodeType!==Node.TEXT_NODE||!u||u.id===F||u.dataset?.browserUseIgnore==="true"||u.getAttribute&&u.getAttribute("aria-hidden")==="true")return null;if(u===document.body){const $={tagName:"body",attributes:{},xpath:"/body",children:[]};for(const x of u.childNodes){const D=_e(x,y,!1);D&&$.children.push(D)}const z=`${R.current++}`;return P[z]=$,z}if(u.nodeType!==Node.ELEMENT_NODE&&u.nodeType!==Node.TEXT_NODE)return null;if(u.nodeType===Node.TEXT_NODE){const $=u.textContent?.trim();if(!$)return null;const z=u.parentElement;if(!z||z.tagName.toLowerCase()==="script")return null;const x=`${R.current++}`;return P[x]={type:"TEXT_NODE",text:$,isVisible:A(u)},x}if(u.nodeType===Node.ELEMENT_NODE&&!Te(u))return null;if(c!==-1&&!u.shadowRoot){const $=m(u),z=I(u),x=z&&(z.position==="fixed"||z.position==="sticky"),D=u.offsetWidth>0||u.offsetHeight>0;if(!$||!x&&!D&&($.bottom<-c||$.top>window.innerHeight+c||$.right<-c||$.left>window.innerWidth+c))return null}const v={tagName:u.tagName.toLowerCase(),attributes:{},children:[]};if(de(u)||u.tagName.toLowerCase()==="iframe"||u.tagName.toLowerCase()==="body"){const $=u.getAttributeNames?.()||[];for(const z of $){const x=u.getAttribute(z);v.attributes[z]=x}u.tagName.toLowerCase()==="input"&&(u.type==="checkbox"||u.type==="radio")&&(v.attributes.checked=u.checked?"true":"false")}let E=!1;if(u.nodeType===Node.ELEMENT_NODE&&(v.isVisible=B(u),v.isVisible)){v.isTopElement=ue(u);const $=u.getAttribute("role"),z=$==="menu"||$==="menubar"||$==="listbox";(v.isTopElement||z)&&(v.isInteractive=q(u),E=Qe(v,u,y,O),v.ref=u)}if(u.tagName){const $=u.tagName.toLowerCase();if($==="iframe")try{const z=u.contentDocument||u.contentWindow?.document;if(z)for(const x of z.childNodes){const D=_e(x,u,!1);D&&v.children.push(D)}}catch(z){console.warn("Unable to access iframe:",z)}else if(u.isContentEditable||u.getAttribute("contenteditable")==="true"||u.id==="tinymce"||u.classList.contains("mce-content-body")||$==="body"&&u.getAttribute("data-id")?.startsWith("mce_"))for(const z of u.childNodes){const x=_e(z,y,E);x&&v.children.push(x)}else{if(u.shadowRoot){v.shadowRoot=!0;for(const z of u.shadowRoot.childNodes){const x=_e(z,y,E);x&&v.children.push(x)}}for(const z of u.childNodes){const D=_e(z,y,E||O);D&&v.children.push(D)}}}if(v.tagName==="a"&&v.children.length===0&&!v.attributes.href){const $=m(u);if(!($&&$.width>0&&$.height>0||u.offsetWidth>0||u.offsetHeight>0))return null}v.extra=h.get(u)||null;const N=`${R.current++}`;return P[N]=v,N}a(_e,"buildDomTree");const fe=_e(document.body);return g.clearCache(),{rootId:fe,map:P}},"domTree"),newElementsCache=new WeakMap;function getFlatTree(e){const t=[];for(const i of e.interactiveBlacklist||[])typeof i=="function"?t.push(i()):t.push(i);const o=[];for(const i of e.interactiveWhitelist||[])typeof i=="function"?o.push(i()):o.push(i);const n=domTree({doHighlightElements:!0,debugMode:!0,focusHighlightIndex:-1,viewportExpansion:VIEWPORT_EXPANSION,interactiveBlacklist:t,interactiveWhitelist:o,highlightOpacity:e.highlightOpacity??0,highlightLabelOpacity:e.highlightLabelOpacity??.1}),r=window.location.href;for(const i in n.map){const s=n.map[i];if(s.isInteractive&&s.ref){const c=s.ref;newElementsCache.has(c)||(newElementsCache.set(c,r),s.isNew=!0)}}return n}a(getFlatTree,"getFlatTree");function flatTreeToString(e,t){const o=["title","type","checked","name","role","value","placeholder","data-date-format","alt","aria-label","aria-expanded","data-state","aria-checked","id","for","target","aria-haspopup","aria-controls","aria-owns"],n=[...t||[],...o],r=a((f,g)=>f.length>g?f.substring(0,g)+"...":f,"capTextLength"),i=a(f=>{const g=e.map[f];if(!g)return null;if(g.type==="TEXT_NODE"){const m=g;return{type:"text",text:m.text,isVisible:m.isVisible,parent:null,children:[]}}else{const m=g,I=[];if(m.children)for(const S of m.children){const P=i(S);P&&(P.parent=null,I.push(P))}return{type:"element",tagName:m.tagName,attributes:m.attributes??{},isVisible:m.isVisible??!1,isInteractive:m.isInteractive??!1,isTopElement:m.isTopElement??!1,isNew:m.isNew??!1,highlightIndex:m.highlightIndex,parent:null,children:I,extra:m.extra??{}}}},"buildTreeNode"),s=a((f,g=null)=>{f.parent=g;for(const m of f.children)s(m,f)},"setParentReferences"),c=i(e.rootId);if(!c)return"";s(c);const l=a(f=>{let g=f.parent;for(;g;){if(g.type==="element"&&g.highlightIndex!==void 0)return!0;g=g.parent}return!1},"hasParentWithHighlightIndex"),d=a((f,g,m)=>{let I=g;const S=" ".repeat(g);if(f.type==="element"){if(f.highlightIndex!==void 0){I+=1;const P=getAllTextTillNextClickableElement(f);let R="";if(n.length>0&&f.attributes){const w={};for(const B of n){const q=f.attributes[B];q&&q.trim()!==""&&(w[B]=q.trim())}const A=n.filter(B=>B in w);if(A.length>1){const B=new Set,q={};for(const ue of A){const X=w[ue];X.length>5&&(X in q?B.add(ue):q[X]=ue)}for(const ue of B)delete w[ue]}w.role===f.tagName&&delete w.role;const Te=["aria-label","placeholder","title"];for(const B of Te)w[B]&&w[B].toLowerCase().trim()===P.toLowerCase().trim()&&delete w[B];Object.keys(w).length>0&&(R=Object.entries(w).map(([B,q])=>`${B}=${r(q,20)}`).join(" "))}const F=f.isNew?`*[${f.highlightIndex}]`:`[${f.highlightIndex}]`;let k=`${S}${F}<${f.tagName??""}`;if(R&&(k+=` ${R}`),f.extra&&f.extra.scrollable){let w="";f.extra.scrollData?.left&&(w+=`left=${f.extra.scrollData.left}, `),f.extra.scrollData?.top&&(w+=`top=${f.extra.scrollData.top}, `),f.extra.scrollData?.right&&(w+=`right=${f.extra.scrollData.right}, `),f.extra.scrollData?.bottom&&(w+=`bottom=${f.extra.scrollData.bottom}`),k+=` data-scrollable="${w}"`}if(P){const w=P.trim();R||(k+=" "),k+=`>${w}`}else R||(k+=" ");k+=" />",m.push(k)}for(const P of f.children)d(P,I,m)}else if(f.type==="text"){if(l(f))return;f.parent&&f.parent.type==="element"&&f.parent.isVisible&&f.parent.isTopElement&&m.push(`${S}${f.text??""}`)}},"processNode"),h=[];return d(c,0,h),h.join(`
236
237
  `)}a(flatTreeToString,"flatTreeToString");const getAllTextTillNextClickableElement=a((e,t=-1)=>{const o=[],n=a((r,i)=>{if(!(t!==-1&&i>t)&&!(r.type==="element"&&r!==e&&r.highlightIndex!==void 0)){if(r.type==="text"&&r.text)o.push(r.text);else if(r.type==="element")for(const s of r.children)n(s,i+1)}},"collectText");return n(e,0),o.join(`
237
238
  `).trim()},"getAllTextTillNextClickableElement");function getSelectorMap(e){const t=new Map,o=Object.keys(e.map);for(const n of o){const r=e.map[n];r.isInteractive&&typeof r.highlightIndex=="number"&&t.set(r.highlightIndex,r)}return t}a(getSelectorMap,"getSelectorMap");function getElementTextMap(e){const t=e.split(`
238
239
  `).map(n=>n.trim()).filter(n=>n.length>0),o=new Map;for(const n of t){const i=/^\[(\d+)\]<[^>]+>([^<]*)/.exec(n);if(i){const s=parseInt(i[1],10);o.set(s,n)}}return o}a(getElementTextMap,"getElementTextMap");function cleanUpHighlights(){const e=window._highlightCleanupFunctions||[];for(const t of e)typeof t=="function"&&t();window._highlightCleanupFunctions=[]}a(cleanUpHighlights,"cleanUpHighlights"),window.addEventListener("popstate",()=>{cleanUpHighlights()}),window.addEventListener("hashchange",()=>{cleanUpHighlights()}),window.addEventListener("beforeunload",()=>{cleanUpHighlights()});const navigation=window.navigation;if(navigation&&typeof navigation.addEventListener=="function")navigation.addEventListener("navigate",()=>{cleanUpHighlights()});else{let e=window.location.href;setInterval(()=>{window.location.href!==e&&(e=window.location.href,cleanUpHighlights())},500)}function getPageInfo(){const e=window.innerWidth,t=window.innerHeight,o=Math.max(document.documentElement.scrollWidth,document.body.scrollWidth||0),n=Math.max(document.documentElement.scrollHeight,document.body.scrollHeight||0),r=window.scrollX||window.pageXOffset||document.documentElement.scrollLeft||0,i=window.scrollY||window.pageYOffset||document.documentElement.scrollTop||0,s=Math.max(0,n-(window.innerHeight+i)),c=Math.max(0,o-(window.innerWidth+r));return{viewport_width:e,viewport_height:t,page_width:o,page_height:n,scroll_x:r,scroll_y:i,pixels_above:i,pixels_below:s,pages_above:t>0?i/t:0,pages_below:t>0?s/t:0,total_pages:t>0?n/t:0,current_page_position:i/Math.max(1,n-t),pixels_left:r,pixels_right:c}}a(getPageInfo,"getPageInfo");function patchReact(e){const t=document.querySelectorAll('[data-reactroot], [data-reactid], [data-react-checksum], #root, #app, [id^="root-"], [id^="app-"], #adex-wrapper, #adex-root');for(const o of t)o.setAttribute("data-page-agent-not-interactive","true")}a(patchReact,"patchReact");const _PageController=class _PageController extends EventTarget{config;flatTree=null;selectorMap=new Map;elementTextMap=new Map;simplifiedHTML="<EMPTY>";lastTimeUpdate=0;isIndexed=!1;mask=null;maskReady=null;constructor(e={}){super(),this.config=e,patchReact(),e.enableMask&&this.initMask()}initMask(){this.maskReady===null&&(this.maskReady=(async()=>{const{SimulatorMask:e}=await Promise.resolve().then(()=>SimulatorMask$1);this.mask=new e})())}async getCurrentUrl(){return window.location.href}async getLastUpdateTime(){return this.lastTimeUpdate}async getBrowserState(){const e=window.location.href,t=document.title,o=getPageInfo(),n=this.config.viewportExpansion??VIEWPORT_EXPANSION;await this.updateTree();const r=this.simplifiedHTML,i=`Current Page: [${t}](${e})`,s=`Page info: ${o.viewport_width}x${o.viewport_height}px viewport, ${o.page_width}x${o.page_height}px total page size, ${o.pages_above.toFixed(1)} pages above, ${o.pages_below.toFixed(1)} pages below, ${o.total_pages.toFixed(1)} total pages, at ${(o.current_page_position*100).toFixed(0)}% of page`,c=n===-1?"Interactive elements from top layer of the current page (full page):":"Interactive elements from top layer of the current page inside the viewport:",d=o.pixels_above>4&&n!==-1?`... ${o.pixels_above} pixels above (${o.pages_above.toFixed(1)} pages) - scroll to see more ...`:"[Start of page]",h=`${i}
@@ -248,7 +249,7 @@ ${d}`,g=o.pixels_below>4&&n!==-1?`... ${o.pixels_below} pixels below (${o.pages_
248
249
  </div>
249
250
  ${o?`<div class="${styles$1.historyMeta}">${o}</div>`:""}
250
251
  </div>
251
- `}a(createCard,"createCard");function formatTime(e="en-US"){return new Date().toLocaleTimeString(e,{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"})}a(formatTime,"formatTime");function createReflectionLines(e){const t=[];return e.evaluation_previous_goal&&t.push(`<div>πŸ” ${escapeHtml(e.evaluation_previous_goal)}</div>`),e.memory&&t.push(`<div>πŸ’Ύ ${escapeHtml(e.memory)}</div>`),e.next_goal&&t.push(`<div>🎯 ${escapeHtml(e.next_goal)}</div>`),t}a(createReflectionLines,"createReflectionLines");const pt=class pt{constructor(t,o={}){Z(this,_);Z(this,re);Z(this,Be);Z(this,ae);Z(this,ye);Z(this,Re);Z(this,be);Z(this,Ce);Z(this,we);Z(this,W);Z(this,Ze);Z(this,Ee,!1);Z(this,j);Z(this,$e,null);Z(this,ve,!1);Z(this,Ne,null);Z(this,ee,null);Z(this,We,!1);Z(this,He,a(()=>b(this,_,Ot).call(this),"#onStatusChange"));Z(this,Je,a(()=>b(this,_,Rt).call(this),"#onHistoryChange"));Z(this,Ye,a(t=>b(this,_,Ct).call(this,t.detail),"#onActivity"));Z(this,qe,a(()=>this.dispose(),"#onAgentDispose"));T(this,W,t),T(this,Ze,o),T(this,j,new I18n(o.language??"en-US")),p(this,W).onAskUser=n=>b(this,_,Zt).call(this,n),T(this,re,b(this,_,Dt).call(this)),T(this,Be,p(this,re).querySelector(`.${styles$1.indicator}`)),T(this,ae,p(this,re).querySelector(`.${styles$1.statusText}`)),T(this,ye,p(this,re).querySelector(`.${styles$1.historySection}`)),T(this,Re,p(this,re).querySelector(`.${styles$1.expandButton}`)),T(this,be,p(this,re).querySelector(`.${styles$1.stopButton}`)),T(this,Ce,p(this,re).querySelector(`.${styles$1.inputSectionWrapper}`)),T(this,we,p(this,re).querySelector(`.${styles$1.taskInput}`)),p(this,W).addEventListener("statuschange",p(this,He)),p(this,W).addEventListener("historychange",p(this,Je)),p(this,W).addEventListener("activity",p(this,Ye)),p(this,W).addEventListener("dispose",p(this,qe)),b(this,_,Ut).call(this),b(this,_,jt).call(this),b(this,_,tt).call(this),this.hide()}get wrapper(){return p(this,re)}show(){this.wrapper.style.display="block",this.wrapper.offsetHeight,this.wrapper.style.opacity="1",this.wrapper.style.transform="translateX(-50%) translateY(0)"}hide(){this.wrapper.style.opacity="0",this.wrapper.style.transform="translateX(-50%) translateY(20px)",this.wrapper.style.display="none"}reset(){p(this,ae).textContent=p(this,j).t("ui.panel.ready"),b(this,_,De).call(this,"thinking"),b(this,_,kt).call(this),b(this,_,it).call(this),T(this,ve,!1),T(this,$e,null),b(this,_,tt).call(this)}expand(){b(this,_,ot).call(this)}collapse(){b(this,_,it).call(this)}dispose(){p(this,W).removeEventListener("statuschange",p(this,He)),p(this,W).removeEventListener("historychange",p(this,Je)),p(this,W).removeEventListener("activity",p(this,Ye)),p(this,W).removeEventListener("dispose",p(this,qe)),T(this,ve,!1),b(this,_,Bt).call(this),this.wrapper.remove()}};re=new WeakMap,Be=new WeakMap,ae=new WeakMap,ye=new WeakMap,Re=new WeakMap,be=new WeakMap,Ce=new WeakMap,we=new WeakMap,W=new WeakMap,Ze=new WeakMap,Ee=new WeakMap,j=new WeakMap,$e=new WeakMap,ve=new WeakMap,Ne=new WeakMap,ee=new WeakMap,We=new WeakMap,He=new WeakMap,Je=new WeakMap,Ye=new WeakMap,qe=new WeakMap,_=new WeakSet,Ot=a(function(){const t=p(this,W).status,o=t==="running"||t==="idle"?"thinking":t;b(this,_,De).call(this,o),t==="running"?(p(this,be).textContent="β– ",p(this,be).title=p(this,j).t("ui.panel.stop")):(p(this,be).textContent="X",p(this,be).title=p(this,j).t("ui.panel.close")),t==="running"&&(this.show(),b(this,_,bt).call(this)),(t==="completed"||t==="error")&&(p(this,Ee)||b(this,_,ot).call(this),b(this,_,Ft).call(this)&&b(this,_,tt).call(this))},"#handleStatusChange"),Rt=a(function(){b(this,_,kt).call(this)},"#handleHistoryChange"),Ct=a(function(t){switch(t.type){case"thinking":T(this,ee,p(this,j).t("ui.panel.thinking")),b(this,_,De).call(this,"thinking");break;case"executing":T(this,ee,b(this,_,yt).call(this,t.tool,t.input)),b(this,_,De).call(this,"executing");break;case"executed":T(this,ee,truncate(t.output,50));break;case"retrying":T(this,ee,`Retrying (${t.attempt}/${t.maxAttempts})`),b(this,_,De).call(this,"retrying");break;case"error":T(this,ee,truncate(t.message,50)),b(this,_,De).call(this,"error");break}},"#handleActivity"),Zt=a(function(t){return new Promise(o=>{T(this,ve,!0),T(this,$e,o),p(this,Ee)||b(this,_,ot).call(this);const n=document.createElement("div");n.innerHTML=createCard({icon:"❓",content:`Question: ${t}`,meta:formatTime(p(this,Ze).language??"en-US"),type:"question"});const r=n.firstElementChild;r.setAttribute("data-temp-card","true"),p(this,ye).appendChild(r),b(this,_,vt).call(this),b(this,_,tt).call(this,p(this,j).t("ui.panel.userAnswerPrompt"))})},"#askUser"),yt=a(function(t,o){const n=o;switch(t){case"click_element_by_index":return p(this,j).t("ui.tools.clicking",{index:n.index});case"input_text":return p(this,j).t("ui.tools.inputting",{index:n.index});case"select_dropdown_option":return p(this,j).t("ui.tools.selecting",{text:n.text});case"scroll":return p(this,j).t("ui.tools.scrolling");case"wait":return p(this,j).t("ui.tools.waiting",{seconds:n.seconds});case"ask_user":return p(this,j).t("ui.tools.askingUser");case"done":return p(this,j).t("ui.tools.done");default:return p(this,j).t("ui.tools.executing",{toolName:t})}},"#getToolExecutingText"),Nt=a(function(){p(this,W).status==="running"?p(this,W).stop():p(this,W).dispose()},"#handleActionButton"),Lt=a(function(){const t=p(this,we).value.trim();t&&(b(this,_,bt).call(this),p(this,ve)?b(this,_,Mt).call(this,t):p(this,W).execute(t))},"#submitTask"),Mt=a(function(t){Array.from(p(this,ye).children).forEach(o=>{o.getAttribute("data-temp-card")==="true"&&o.remove()}),T(this,ve,!1),p(this,$e)&&(p(this,$e).call(this,t),T(this,$e,null))},"#handleUserAnswer"),tt=a(function(t){p(this,we).value="",p(this,we).placeholder=t||p(this,j).t("ui.panel.taskInput"),p(this,Ce).classList.remove(styles$1.hidden),setTimeout(()=>{p(this,we).focus()},100)},"#showInputArea"),bt=a(function(){p(this,Ce).classList.add(styles$1.hidden)},"#hideInputArea"),Ft=a(function(){if(p(this,ve)||p(this,W).history.length===0)return!0;const o=p(this,W).status;return o==="completed"||o==="error"?p(this,Ze).promptForNextTask??!0:!1},"#shouldShowInputArea"),Dt=a(function(){const t=document.createElement("div");return t.id="page-agent-runtime_agent-panel",t.className=styles$1.wrapper,t.setAttribute("data-browser-use-ignore","true"),t.innerHTML=`
252
+ `}a(createCard,"createCard");function formatTime(e="en-US"){return new Date().toLocaleTimeString(e,{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"})}a(formatTime,"formatTime");function createReflectionLines(e){const t=[];return e.evaluation_previous_goal&&t.push(`<div>πŸ” ${escapeHtml(e.evaluation_previous_goal)}</div>`),e.memory&&t.push(`<div>πŸ’Ύ ${escapeHtml(e.memory)}</div>`),e.next_goal&&t.push(`<div>🎯 ${escapeHtml(e.next_goal)}</div>`),t}a(createReflectionLines,"createReflectionLines");const pt=class pt{constructor(t,o={}){Z(this,_);Z(this,re);Z(this,Be);Z(this,ae);Z(this,ye);Z(this,Re);Z(this,be);Z(this,Ce);Z(this,we);Z(this,W);Z(this,Ze);Z(this,Ee,!1);Z(this,j);Z(this,$e,null);Z(this,ve,!1);Z(this,Ne,null);Z(this,ee,null);Z(this,We,!1);Z(this,He,a(()=>b(this,_,Ot).call(this),"#onStatusChange"));Z(this,Je,a(()=>b(this,_,Rt).call(this),"#onHistoryChange"));Z(this,Ye,a(t=>b(this,_,Ct).call(this,t.detail),"#onActivity"));Z(this,qe,a(()=>this.dispose(),"#onAgentDispose"));T(this,W,t),T(this,Ze,o),T(this,j,new I18n(o.language??"en-US")),p(this,W).onAskUser=n=>b(this,_,Zt).call(this,n),T(this,re,b(this,_,Ft).call(this)),T(this,Be,p(this,re).querySelector(`.${styles$1.indicator}`)),T(this,ae,p(this,re).querySelector(`.${styles$1.statusText}`)),T(this,ye,p(this,re).querySelector(`.${styles$1.historySection}`)),T(this,Re,p(this,re).querySelector(`.${styles$1.expandButton}`)),T(this,be,p(this,re).querySelector(`.${styles$1.stopButton}`)),T(this,Ce,p(this,re).querySelector(`.${styles$1.inputSectionWrapper}`)),T(this,we,p(this,re).querySelector(`.${styles$1.taskInput}`)),p(this,W).addEventListener("statuschange",p(this,He)),p(this,W).addEventListener("historychange",p(this,Je)),p(this,W).addEventListener("activity",p(this,Ye)),p(this,W).addEventListener("dispose",p(this,qe)),b(this,_,Ut).call(this),b(this,_,jt).call(this),b(this,_,tt).call(this),this.hide()}get wrapper(){return p(this,re)}show(){this.wrapper.style.display="block",this.wrapper.offsetHeight,this.wrapper.style.opacity="1",this.wrapper.style.transform="translateX(-50%) translateY(0)"}hide(){this.wrapper.style.opacity="0",this.wrapper.style.transform="translateX(-50%) translateY(20px)",this.wrapper.style.display="none"}reset(){p(this,ae).textContent=p(this,j).t("ui.panel.ready"),b(this,_,Fe).call(this,"thinking"),b(this,_,kt).call(this),b(this,_,it).call(this),T(this,ve,!1),T(this,$e,null),b(this,_,tt).call(this)}expand(){b(this,_,ot).call(this)}collapse(){b(this,_,it).call(this)}dispose(){p(this,W).removeEventListener("statuschange",p(this,He)),p(this,W).removeEventListener("historychange",p(this,Je)),p(this,W).removeEventListener("activity",p(this,Ye)),p(this,W).removeEventListener("dispose",p(this,qe)),T(this,ve,!1),b(this,_,Bt).call(this),this.wrapper.remove()}};re=new WeakMap,Be=new WeakMap,ae=new WeakMap,ye=new WeakMap,Re=new WeakMap,be=new WeakMap,Ce=new WeakMap,we=new WeakMap,W=new WeakMap,Ze=new WeakMap,Ee=new WeakMap,j=new WeakMap,$e=new WeakMap,ve=new WeakMap,Ne=new WeakMap,ee=new WeakMap,We=new WeakMap,He=new WeakMap,Je=new WeakMap,Ye=new WeakMap,qe=new WeakMap,_=new WeakSet,Ot=a(function(){const t=p(this,W).status,o=t==="running"||t==="idle"?"thinking":t;b(this,_,Fe).call(this,o),t==="running"?(p(this,be).textContent="β– ",p(this,be).title=p(this,j).t("ui.panel.stop")):(p(this,be).textContent="X",p(this,be).title=p(this,j).t("ui.panel.close")),t==="running"&&(this.show(),b(this,_,bt).call(this)),(t==="completed"||t==="error")&&(p(this,Ee)||b(this,_,ot).call(this),b(this,_,Dt).call(this)&&b(this,_,tt).call(this))},"#handleStatusChange"),Rt=a(function(){b(this,_,kt).call(this)},"#handleHistoryChange"),Ct=a(function(t){switch(t.type){case"thinking":T(this,ee,p(this,j).t("ui.panel.thinking")),b(this,_,Fe).call(this,"thinking");break;case"executing":T(this,ee,b(this,_,yt).call(this,t.tool,t.input)),b(this,_,Fe).call(this,"executing");break;case"executed":T(this,ee,truncate(t.output,50));break;case"retrying":T(this,ee,`Retrying (${t.attempt}/${t.maxAttempts})`),b(this,_,Fe).call(this,"retrying");break;case"error":T(this,ee,truncate(t.message,50)),b(this,_,Fe).call(this,"error");break}},"#handleActivity"),Zt=a(function(t){return new Promise(o=>{T(this,ve,!0),T(this,$e,o),p(this,Ee)||b(this,_,ot).call(this);const n=document.createElement("div");n.innerHTML=createCard({icon:"❓",content:`Question: ${t}`,meta:formatTime(p(this,Ze).language??"en-US"),type:"question"});const r=n.firstElementChild;r.setAttribute("data-temp-card","true"),p(this,ye).appendChild(r),b(this,_,vt).call(this),b(this,_,tt).call(this,p(this,j).t("ui.panel.userAnswerPrompt"))})},"#askUser"),yt=a(function(t,o){const n=o;switch(t){case"click_element_by_index":return p(this,j).t("ui.tools.clicking",{index:n.index});case"input_text":return p(this,j).t("ui.tools.inputting",{index:n.index});case"select_dropdown_option":return p(this,j).t("ui.tools.selecting",{text:n.text});case"scroll":return p(this,j).t("ui.tools.scrolling");case"wait":return p(this,j).t("ui.tools.waiting",{seconds:n.seconds});case"ask_user":return p(this,j).t("ui.tools.askingUser");case"done":return p(this,j).t("ui.tools.done");default:return p(this,j).t("ui.tools.executing",{toolName:t})}},"#getToolExecutingText"),Nt=a(function(){p(this,W).status==="running"?p(this,W).stop():p(this,W).dispose()},"#handleActionButton"),Lt=a(function(){const t=p(this,we).value.trim();t&&(b(this,_,bt).call(this),p(this,ve)?b(this,_,Mt).call(this,t):p(this,W).execute(t))},"#submitTask"),Mt=a(function(t){Array.from(p(this,ye).children).forEach(o=>{o.getAttribute("data-temp-card")==="true"&&o.remove()}),T(this,ve,!1),p(this,$e)&&(p(this,$e).call(this,t),T(this,$e,null))},"#handleUserAnswer"),tt=a(function(t){p(this,we).value="",p(this,we).placeholder=t||p(this,j).t("ui.panel.taskInput"),p(this,Ce).classList.remove(styles$1.hidden),setTimeout(()=>{p(this,we).focus()},100)},"#showInputArea"),bt=a(function(){p(this,Ce).classList.add(styles$1.hidden)},"#hideInputArea"),Dt=a(function(){if(p(this,ve)||p(this,W).history.length===0)return!0;const o=p(this,W).status;return o==="completed"||o==="error"?p(this,Ze).promptForNextTask??!0:!1},"#shouldShowInputArea"),Ft=a(function(){const t=document.createElement("div");return t.id="page-agent-runtime_agent-panel",t.className=styles$1.wrapper,t.setAttribute("data-browser-use-ignore","true"),t.innerHTML=`
252
253
  <div class="${styles$1.background}"></div>
253
254
  <div class="${styles$1.historySectionWrapper}">
254
255
  <div class="${styles$1.historySection}">
@@ -283,7 +284,7 @@ ${d}`,g=o.pixels_below>4&&n!==-1?`... ${o.pixels_below} pixels below (${o.pages_
283
284
  />
284
285
  </div>
285
286
  </div>
286
- `,document.body.appendChild(t),t},"#createWrapper"),Ut=a(function(){this.wrapper.querySelector(`.${styles$1.header}`).addEventListener("click",o=>{o.target.closest(`.${styles$1.controlButton}`)||b(this,_,wt).call(this)}),p(this,Re).addEventListener("click",o=>{o.stopPropagation(),b(this,_,wt).call(this)}),p(this,be).addEventListener("click",o=>{o.stopPropagation(),b(this,_,Nt).call(this)}),p(this,we).addEventListener("keydown",o=>{o.isComposing||o.key==="Enter"&&(o.preventDefault(),b(this,_,Lt).call(this))}),p(this,Ce).addEventListener("click",o=>{o.stopPropagation()})},"#setupEventListeners"),wt=a(function(){p(this,Ee)?b(this,_,it).call(this):b(this,_,ot).call(this)},"#toggle"),ot=a(function(){T(this,Ee,!0),this.wrapper.classList.add(styles$1.expanded),p(this,Re).textContent="β–²"},"#expand"),it=a(function(){T(this,Ee,!1),this.wrapper.classList.remove(styles$1.expanded),p(this,Re).textContent="β–Ό"},"#collapse"),jt=a(function(){T(this,Ne,setInterval(()=>{b(this,_,Wt).call(this)},450))},"#startHeaderUpdateLoop"),Bt=a(function(){p(this,Ne)&&(clearInterval(p(this,Ne)),T(this,Ne,null))},"#stopHeaderUpdateLoop"),Wt=a(function(){if(!p(this,ee)||p(this,We))return;if(p(this,ae).textContent===p(this,ee)){T(this,ee,null);return}const t=p(this,ee);T(this,ee,null),b(this,_,Vt).call(this,t)},"#checkAndUpdateHeader"),Vt=a(function(t){T(this,We,!0),p(this,ae).classList.add(styles$1.fadeOut),setTimeout(()=>{p(this,ae).textContent=t,p(this,ae).classList.remove(styles$1.fadeOut),p(this,ae).classList.add(styles$1.fadeIn),setTimeout(()=>{p(this,ae).classList.remove(styles$1.fadeIn),T(this,We,!1)},300)},150)},"#animateTextChange"),De=a(function(t){p(this,Be).className=styles$1.indicator,p(this,Be).classList.add(styles$1[t])},"#updateStatusIndicator"),vt=a(function(){setTimeout(()=>{p(this,ye).scrollTop=p(this,ye).scrollHeight},0)},"#scrollToBottom"),kt=a(function(){const t=[],o=p(this,W).task;o&&t.push(b(this,_,Gt).call(this,o));const n=p(this,W).history;for(const r of n)t.push(...b(this,_,Ht).call(this,r));p(this,ye).innerHTML=t.join(""),b(this,_,vt).call(this)},"#renderHistory"),Gt=a(function(t){return createCard({icon:"🎯",content:t,type:"input"})},"#createTaskCard"),Ht=a(function(t){const o=[],n=formatTime(p(this,Ze).language??"en-US"),r=t.type==="step"&&t.stepIndex!==void 0?p(this,j).t("ui.panel.step",{number:(t.stepIndex+1).toString(),time:n,duration:""}):n;if(t.type==="step"){if(t.reflection){const s=createReflectionLines(t.reflection);s.length>0&&o.push(createCard({icon:"🧠",content:s,meta:r}))}const i=t.action;i&&o.push(...b(this,_,Jt).call(this,i,r))}else if(t.type==="observation")o.push(createCard({icon:"πŸ‘οΈ",content:t.content||"",meta:r,type:"observation"}));else if(t.type==="user_takeover")o.push(createCard({icon:"πŸ‘€",content:"User takeover",meta:r,type:"input"}));else if(t.type==="retry"){const i=`${t.message||"Retrying"} (${t.attempt}/${t.maxAttempts})`;o.push(createCard({icon:"πŸ”„",content:i,meta:r,type:"observation"}))}else t.type==="error"&&o.push(createCard({icon:"❌",content:t.message||"Error",meta:r,type:"observation"}));return o},"#createHistoryCards"),Jt=a(function(t,o){const n=[];if(t.name==="done"){const i=t.input.text||t.output||"";i&&n.push(createCard({icon:"πŸ€–",content:i,meta:o,type:"output"}))}else if(t.name==="ask_user"){const r=t.input,i=t.output.replace(/^User answered:\s*/i,"");n.push(createCard({icon:"❓",content:`Question: ${r.question||""}`,meta:o,type:"question"})),n.push(createCard({icon:"πŸ’¬",content:`Answer: ${i}`,meta:o,type:"input"}))}else{const r=b(this,_,yt).call(this,t.name,t.input);n.push(createCard({icon:"πŸ”¨",content:r,meta:o})),t.output?.length>0&&n.push(createCard({icon:"πŸ”¨",content:t.output,meta:o,type:"output"}))}return n},"#createActionCards"),a(pt,"Panel");let Panel=pt;const ht=class ht extends PageAgentCore{panel;constructor(t){const o=new PageController({...t,enableMask:t.enableMask??!0});super({...t,pageController:o}),this.panel=new Panel(this,{language:t.language})}};a(ht,"PageAgent");let PageAgent=ht;window.pageAgent&&window.pageAgent.dispose(),window.PageAgent=PageAgent,console.log("πŸš€ page-agent.js loaded!");const DEMO_MODEL="PAGE-AGENT-FREE-TESTING-RANDOM",DEMO_BASE_URL="https://hwcxiuzfylggtcktqgij.supabase.co/functions/v1/llm-testing-proxy",DEMO_API_KEY="PAGE-AGENT-FREE-TESTING-RANDOM";setTimeout(()=>{const e=document.currentScript;let t;if(e){console.log("πŸš€ page-agent.js detected current script:",e.src);const o=new URL(e.src),n=o.searchParams.get("model")||DEMO_MODEL,r=o.searchParams.get("baseURL")||DEMO_BASE_URL,i=o.searchParams.get("apiKey")||DEMO_API_KEY,s=o.searchParams.get("lang")||"zh-CN";t={model:n,baseURL:r,apiKey:i,language:s}}else console.log("πŸš€ page-agent.js no current script detected, using default demo config"),t={model:DEMO_MODEL,baseURL:DEMO_BASE_URL,apiKey:DEMO_API_KEY};window.pageAgent=new PageAgent(t),window.pageAgent.panel.show(),console.log("πŸš€ page-agent.js initialized with config:",window.pageAgent.config)});function computeBorderGeometry(e,t,o,n){const r=Math.max(1,Math.min(e,t)),i=Math.min(o,20),c=Math.min(i+n,r),l=Math.min(c,Math.floor(e/2)),d=Math.min(c,Math.floor(t/2)),h=a(v=>v/e*2-1,"toClipX"),f=a(v=>v/t*2-1,"toClipY"),g=0,m=e,I=0,S=t,P=l,R=e-l,D=d,k=t-d,w=h(g),A=h(m),Te=f(I),B=f(S),q=h(P),ue=h(R),X=f(D),de=f(k),pe=0,Xe=0,he=1,Ke=1,Qe=l/e,_e=1-l/e,fe=d/t,u=1-d/t,y=new Float32Array([w,Te,A,Te,w,X,w,X,A,Te,A,X,w,de,A,de,w,B,w,B,A,de,A,B,w,X,q,X,w,de,w,de,q,X,q,de,ue,X,A,X,ue,de,ue,de,A,X,A,de]),O=new Float32Array([pe,Xe,he,Xe,pe,fe,pe,fe,he,Xe,he,fe,pe,u,he,u,pe,Ke,pe,Ke,he,u,he,Ke,pe,fe,Qe,fe,pe,u,pe,u,Qe,fe,Qe,u,_e,fe,he,fe,_e,u,_e,u,he,fe,he,u]);return{positions:y,uvs:O}}a(computeBorderGeometry,"computeBorderGeometry");function compileShader(e,t,o){const n=e.createShader(t);if(!n)throw new Error("Failed to create shader");if(e.shaderSource(n,o),e.compileShader(n),!e.getShaderParameter(n,e.COMPILE_STATUS)){const r=e.getShaderInfoLog(n)||"Unknown shader error";throw e.deleteShader(n),new Error(r)}return n}a(compileShader,"compileShader");function createProgram(e,t,o){const n=compileShader(e,e.VERTEX_SHADER,t),r=compileShader(e,e.FRAGMENT_SHADER,o),i=e.createProgram();if(!i)throw new Error("Failed to create program");if(e.attachShader(i,n),e.attachShader(i,r),e.linkProgram(i),!e.getProgramParameter(i,e.LINK_STATUS)){const s=e.getProgramInfoLog(i)||"Unknown link error";throw e.deleteProgram(i),e.deleteShader(n),e.deleteShader(r),new Error(s)}return e.deleteShader(n),e.deleteShader(r),i}a(createProgram,"createProgram");const fragmentShaderSource=`#version 300 es
287
+ `,document.body.appendChild(t),t},"#createWrapper"),Ut=a(function(){this.wrapper.querySelector(`.${styles$1.header}`).addEventListener("click",o=>{o.target.closest(`.${styles$1.controlButton}`)||b(this,_,wt).call(this)}),p(this,Re).addEventListener("click",o=>{o.stopPropagation(),b(this,_,wt).call(this)}),p(this,be).addEventListener("click",o=>{o.stopPropagation(),b(this,_,Nt).call(this)}),p(this,we).addEventListener("keydown",o=>{o.isComposing||o.key==="Enter"&&(o.preventDefault(),b(this,_,Lt).call(this))}),p(this,Ce).addEventListener("click",o=>{o.stopPropagation()})},"#setupEventListeners"),wt=a(function(){p(this,Ee)?b(this,_,it).call(this):b(this,_,ot).call(this)},"#toggle"),ot=a(function(){T(this,Ee,!0),this.wrapper.classList.add(styles$1.expanded),p(this,Re).textContent="β–²"},"#expand"),it=a(function(){T(this,Ee,!1),this.wrapper.classList.remove(styles$1.expanded),p(this,Re).textContent="β–Ό"},"#collapse"),jt=a(function(){T(this,Ne,setInterval(()=>{b(this,_,Wt).call(this)},450))},"#startHeaderUpdateLoop"),Bt=a(function(){p(this,Ne)&&(clearInterval(p(this,Ne)),T(this,Ne,null))},"#stopHeaderUpdateLoop"),Wt=a(function(){if(!p(this,ee)||p(this,We))return;if(p(this,ae).textContent===p(this,ee)){T(this,ee,null);return}const t=p(this,ee);T(this,ee,null),b(this,_,Vt).call(this,t)},"#checkAndUpdateHeader"),Vt=a(function(t){T(this,We,!0),p(this,ae).classList.add(styles$1.fadeOut),setTimeout(()=>{p(this,ae).textContent=t,p(this,ae).classList.remove(styles$1.fadeOut),p(this,ae).classList.add(styles$1.fadeIn),setTimeout(()=>{p(this,ae).classList.remove(styles$1.fadeIn),T(this,We,!1)},300)},150)},"#animateTextChange"),Fe=a(function(t){p(this,Be).className=styles$1.indicator,p(this,Be).classList.add(styles$1[t])},"#updateStatusIndicator"),vt=a(function(){setTimeout(()=>{p(this,ye).scrollTop=p(this,ye).scrollHeight},0)},"#scrollToBottom"),kt=a(function(){const t=[],o=p(this,W).task;o&&t.push(b(this,_,Gt).call(this,o));const n=p(this,W).history;for(const r of n)t.push(...b(this,_,Ht).call(this,r));p(this,ye).innerHTML=t.join(""),b(this,_,vt).call(this)},"#renderHistory"),Gt=a(function(t){return createCard({icon:"🎯",content:t,type:"input"})},"#createTaskCard"),Ht=a(function(t){const o=[],n=formatTime(p(this,Ze).language??"en-US"),r=t.type==="step"&&t.stepIndex!==void 0?p(this,j).t("ui.panel.step",{number:(t.stepIndex+1).toString(),time:n,duration:""}):n;if(t.type==="step"){if(t.reflection){const s=createReflectionLines(t.reflection);s.length>0&&o.push(createCard({icon:"🧠",content:s,meta:r}))}const i=t.action;i&&o.push(...b(this,_,Jt).call(this,i,r))}else if(t.type==="observation")o.push(createCard({icon:"πŸ‘οΈ",content:t.content||"",meta:r,type:"observation"}));else if(t.type==="user_takeover")o.push(createCard({icon:"πŸ‘€",content:"User takeover",meta:r,type:"input"}));else if(t.type==="retry"){const i=`${t.message||"Retrying"} (${t.attempt}/${t.maxAttempts})`;o.push(createCard({icon:"πŸ”„",content:i,meta:r,type:"observation"}))}else t.type==="error"&&o.push(createCard({icon:"❌",content:t.message||"Error",meta:r,type:"observation"}));return o},"#createHistoryCards"),Jt=a(function(t,o){const n=[];if(t.name==="done"){const i=t.input.text||t.output||"";i&&n.push(createCard({icon:"πŸ€–",content:i,meta:o,type:"output"}))}else if(t.name==="ask_user"){const r=t.input,i=t.output.replace(/^User answered:\s*/i,"");n.push(createCard({icon:"❓",content:`Question: ${r.question||""}`,meta:o,type:"question"})),n.push(createCard({icon:"πŸ’¬",content:`Answer: ${i}`,meta:o,type:"input"}))}else{const r=b(this,_,yt).call(this,t.name,t.input);n.push(createCard({icon:"πŸ”¨",content:r,meta:o})),t.output?.length>0&&n.push(createCard({icon:"πŸ”¨",content:t.output,meta:o,type:"output"}))}return n},"#createActionCards"),a(pt,"Panel");let Panel=pt;const ht=class ht extends PageAgentCore{panel;constructor(t){const o=new PageController({...t,enableMask:t.enableMask??!0});super({...t,pageController:o}),this.panel=new Panel(this,{language:t.language})}};a(ht,"PageAgent");let PageAgent=ht;window.pageAgent&&window.pageAgent.dispose(),window.PageAgent=PageAgent,console.log("πŸš€ page-agent.js loaded!");const DEMO_MODEL="qwen3.5-plus",DEMO_BASE_URL="https://page-ag-testing-ohftxirgbn.cn-shanghai.fcapp.run",DEMO_API_KEY="NA";setTimeout(()=>{const e=document.currentScript;let t;if(e){console.log("πŸš€ page-agent.js detected current script:",e.src);const o=new URL(e.src),n=o.searchParams.get("model")||DEMO_MODEL,r=o.searchParams.get("baseURL")||DEMO_BASE_URL,i=o.searchParams.get("apiKey")||DEMO_API_KEY,s=o.searchParams.get("lang")||"zh-CN";t={model:n,baseURL:r,apiKey:i,language:s}}else console.log("πŸš€ page-agent.js no current script detected, using default demo config"),t={model:DEMO_MODEL,baseURL:DEMO_BASE_URL,apiKey:DEMO_API_KEY};window.pageAgent=new PageAgent(t),window.pageAgent.panel.show(),console.log("πŸš€ page-agent.js initialized with config:",window.pageAgent.config)});function computeBorderGeometry(e,t,o,n){const r=Math.max(1,Math.min(e,t)),i=Math.min(o,20),c=Math.min(i+n,r),l=Math.min(c,Math.floor(e/2)),d=Math.min(c,Math.floor(t/2)),h=a(v=>v/e*2-1,"toClipX"),f=a(v=>v/t*2-1,"toClipY"),g=0,m=e,I=0,S=t,P=l,R=e-l,F=d,k=t-d,w=h(g),A=h(m),Te=f(I),B=f(S),q=h(P),ue=h(R),X=f(F),de=f(k),pe=0,Xe=0,he=1,Ke=1,Qe=l/e,_e=1-l/e,fe=d/t,u=1-d/t,y=new Float32Array([w,Te,A,Te,w,X,w,X,A,Te,A,X,w,de,A,de,w,B,w,B,A,de,A,B,w,X,q,X,w,de,w,de,q,X,q,de,ue,X,A,X,ue,de,ue,de,A,X,A,de]),O=new Float32Array([pe,Xe,he,Xe,pe,fe,pe,fe,he,Xe,he,fe,pe,u,he,u,pe,Ke,pe,Ke,he,u,he,Ke,pe,fe,Qe,fe,pe,u,pe,u,Qe,fe,Qe,u,_e,fe,he,fe,_e,u,_e,u,he,fe,he,u]);return{positions:y,uvs:O}}a(computeBorderGeometry,"computeBorderGeometry");function compileShader(e,t,o){const n=e.createShader(t);if(!n)throw new Error("Failed to create shader");if(e.shaderSource(n,o),e.compileShader(n),!e.getShaderParameter(n,e.COMPILE_STATUS)){const r=e.getShaderInfoLog(n)||"Unknown shader error";throw e.deleteShader(n),new Error(r)}return n}a(compileShader,"compileShader");function createProgram(e,t,o){const n=compileShader(e,e.VERTEX_SHADER,t),r=compileShader(e,e.FRAGMENT_SHADER,o),i=e.createProgram();if(!i)throw new Error("Failed to create program");if(e.attachShader(i,n),e.attachShader(i,r),e.linkProgram(i),!e.getProgramParameter(i,e.LINK_STATUS)){const s=e.getProgramInfoLog(i)||"Unknown link error";throw e.deleteProgram(i),e.deleteShader(n),e.deleteShader(r),new Error(s)}return e.deleteShader(n),e.deleteShader(r),i}a(createProgram,"createProgram");const fragmentShaderSource=`#version 300 es
287
288
  precision lowp float;
288
289
  in vec2 vUV;
289
290
  out vec4 outColor;
@@ -393,4 +394,4 @@ out vec2 vUV;
393
394
  void main() {
394
395
  vUV = aUV;
395
396
  gl_Position = vec4(aPosition, 0.0, 1.0);
396
- }`;const DEFAULT_COLORS=["rgb(57, 182, 255)","rgb(189, 69, 251)","rgb(255, 87, 51)","rgb(255, 214, 0)"];function parseColor(e){const t=e.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(!t)throw new Error(`Invalid color format: ${e}`);const[,o,n,r]=t;return[parseInt(o)/255,parseInt(n)/255,parseInt(r)/255]}a(parseColor,"parseColor");const ft=class ft{element;canvas;options;running=!1;disposed=!1;startTime=0;lastTime=0;rafId=null;glr;observer;constructor(t={}){this.options={width:t.width??600,height:t.height??600,ratio:t.ratio??window.devicePixelRatio??1,borderWidth:t.borderWidth??8,glowWidth:t.glowWidth??200,borderRadius:t.borderRadius??8,mode:t.mode??"light",...t},this.canvas=document.createElement("canvas"),this.options.classNames&&(this.canvas.className=this.options.classNames),this.options.styles&&Object.assign(this.canvas.style,this.options.styles),this.canvas.style.display="block",this.canvas.style.transformOrigin="center",this.canvas.style.pointerEvents="none",this.element=this.canvas,this.setupGL(),this.options.skipGreeting||this.greet()}start(){if(this.disposed)throw new Error("Motion instance has been disposed.");if(this.running)return;if(!this.glr){console.error("WebGL resources are not initialized.");return}this.running=!0,this.startTime=performance.now(),this.resize(this.options.width??600,this.options.height??600,this.options.ratio),this.glr.gl.viewport(0,0,this.canvas.width,this.canvas.height),this.glr.gl.useProgram(this.glr.program),this.glr.gl.uniform2f(this.glr.uResolution,this.canvas.width,this.canvas.height),this.checkGLError(this.glr.gl,"start: after initial setup");const t=a(()=>{if(!this.running||!this.glr)return;this.rafId=requestAnimationFrame(t);const o=performance.now();if(o-this.lastTime<1e3/32)return;this.lastTime=o;const r=(o-this.startTime)*.001;this.render(r)},"loop");this.rafId=requestAnimationFrame(t)}pause(){if(this.disposed)throw new Error("Motion instance has been disposed.");this.running=!1,this.rafId!==null&&cancelAnimationFrame(this.rafId)}dispose(){if(this.disposed)return;this.disposed=!0,this.running=!1,this.rafId!==null&&cancelAnimationFrame(this.rafId);const{gl:t,vao:o,positionBuffer:n,uvBuffer:r,program:i}=this.glr;o&&t.deleteVertexArray(o),n&&t.deleteBuffer(n),r&&t.deleteBuffer(r),t.deleteProgram(i),this.observer&&this.observer.disconnect(),this.canvas.remove()}resize(t,o,n){if(this.disposed)throw new Error("Motion instance has been disposed.");if(this.options.width=t,this.options.height=o,n&&(this.options.ratio=n),!this.running)return;const{gl:r,program:i,vao:s,positionBuffer:c,uvBuffer:l,uResolution:d}=this.glr,h=n??this.options.ratio??window.devicePixelRatio??1,f=Math.max(1,Math.floor(t*h)),g=Math.max(1,Math.floor(o*h));this.canvas.style.width=`${t}px`,this.canvas.style.height=`${o}px`,(this.canvas.width!==f||this.canvas.height!==g)&&(this.canvas.width=f,this.canvas.height=g),r.viewport(0,0,this.canvas.width,this.canvas.height),this.checkGLError(r,"resize: after viewport setup");const{positions:m,uvs:I}=computeBorderGeometry(this.canvas.width,this.canvas.height,this.options.borderWidth*h,this.options.glowWidth*h);r.bindVertexArray(s),r.bindBuffer(r.ARRAY_BUFFER,c),r.bufferData(r.ARRAY_BUFFER,m,r.STATIC_DRAW);const S=r.getAttribLocation(i,"aPosition");r.enableVertexAttribArray(S),r.vertexAttribPointer(S,2,r.FLOAT,!1,0,0),this.checkGLError(r,"resize: after position buffer update"),r.bindBuffer(r.ARRAY_BUFFER,l),r.bufferData(r.ARRAY_BUFFER,I,r.STATIC_DRAW);const P=r.getAttribLocation(i,"aUV");r.enableVertexAttribArray(P),r.vertexAttribPointer(P,2,r.FLOAT,!1,0,0),this.checkGLError(r,"resize: after UV buffer update"),r.useProgram(i),r.uniform2f(d,this.canvas.width,this.canvas.height),r.uniform1f(this.glr.uBorderWidth,this.options.borderWidth*h),r.uniform1f(this.glr.uGlowWidth,this.options.glowWidth*h),r.uniform1f(this.glr.uBorderRadius,this.options.borderRadius*h),this.checkGLError(r,"resize: after uniform updates");const R=performance.now();this.lastTime=R;const D=(R-this.startTime)*.001;this.render(D)}autoResize(t){this.observer&&this.observer.disconnect(),this.observer=new ResizeObserver(()=>{const o=t.getBoundingClientRect();this.resize(o.width,o.height)}),this.observer.observe(t)}fadeIn(){if(this.disposed)throw new Error("Motion instance has been disposed.");return new Promise((t,o)=>{const n=this.canvas.animate([{opacity:0,transform:"scale(1.2)"},{opacity:1,transform:"scale(1)"}],{duration:300,easing:"ease-out",fill:"forwards"});n.onfinish=()=>t(),n.oncancel=()=>o("canceled")})}fadeOut(){if(this.disposed)throw new Error("Motion instance has been disposed.");return new Promise((t,o)=>{const n=this.canvas.animate([{opacity:1,transform:"scale(1)"},{opacity:0,transform:"scale(1.2)"}],{duration:300,easing:"ease-in",fill:"forwards"});n.onfinish=()=>t(),n.oncancel=()=>o("canceled")})}checkGLError(t,o){let n=t.getError();if(n!==t.NO_ERROR){for(console.group(`πŸ”΄ WebGL Error in ${o}`);n!==t.NO_ERROR;){const r=this.getGLErrorName(t,n);console.error(`${r} (0x${n.toString(16)})`),n=t.getError()}console.groupEnd()}}getGLErrorName(t,o){switch(o){case t.INVALID_ENUM:return"INVALID_ENUM";case t.INVALID_VALUE:return"INVALID_VALUE";case t.INVALID_OPERATION:return"INVALID_OPERATION";case t.INVALID_FRAMEBUFFER_OPERATION:return"INVALID_FRAMEBUFFER_OPERATION";case t.OUT_OF_MEMORY:return"OUT_OF_MEMORY";case t.CONTEXT_LOST_WEBGL:return"CONTEXT_LOST_WEBGL";default:return"UNKNOWN_ERROR"}}setupGL(){const t=this.canvas.getContext("webgl2",{antialias:!1,alpha:!0});if(!t)throw new Error("WebGL2 is required but not available.");const o=createProgram(t,vertexShaderSource,fragmentShaderSource);this.checkGLError(t,"setupGL: after createProgram");const n=t.createVertexArray();t.bindVertexArray(n),this.checkGLError(t,"setupGL: after VAO creation");const r=this.canvas.width||2,i=this.canvas.height||2,{positions:s,uvs:c}=computeBorderGeometry(r,i,this.options.borderWidth,this.options.glowWidth),l=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,l),t.bufferData(t.ARRAY_BUFFER,s,t.STATIC_DRAW);const d=t.getAttribLocation(o,"aPosition");t.enableVertexAttribArray(d),t.vertexAttribPointer(d,2,t.FLOAT,!1,0,0),this.checkGLError(t,"setupGL: after position buffer setup");const h=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,h),t.bufferData(t.ARRAY_BUFFER,c,t.STATIC_DRAW);const f=t.getAttribLocation(o,"aUV");t.enableVertexAttribArray(f),t.vertexAttribPointer(f,2,t.FLOAT,!1,0,0),this.checkGLError(t,"setupGL: after UV buffer setup");const g=t.getUniformLocation(o,"uResolution"),m=t.getUniformLocation(o,"uTime"),I=t.getUniformLocation(o,"uBorderWidth"),S=t.getUniformLocation(o,"uGlowWidth"),P=t.getUniformLocation(o,"uBorderRadius"),R=t.getUniformLocation(o,"uColors"),D=t.getUniformLocation(o,"uGlowExponent"),k=t.getUniformLocation(o,"uGlowFactor");t.useProgram(o),t.uniform1f(I,this.options.borderWidth),t.uniform1f(S,this.options.glowWidth),t.uniform1f(P,this.options.borderRadius),this.options.mode==="dark"?(t.uniform1f(D,2),t.uniform1f(k,1.8)):(t.uniform1f(D,1),t.uniform1f(k,1));const w=(this.options.colors||DEFAULT_COLORS).map(parseColor);for(let A=0;A<w.length;A++)t.uniform3f(t.getUniformLocation(o,`uColors[${A}]`),...w[A]);this.checkGLError(t,"setupGL: after uniform setup"),t.bindVertexArray(null),t.bindBuffer(t.ARRAY_BUFFER,null),this.glr={gl:t,program:o,vao:n,positionBuffer:l,uvBuffer:h,uResolution:g,uTime:m,uBorderWidth:I,uGlowWidth:S,uBorderRadius:P,uColors:R}}render(t){if(!this.glr)return;const{gl:o,program:n,vao:r,uTime:i}=this.glr;o.useProgram(n),o.bindVertexArray(r),o.uniform1f(i,t),o.disable(o.DEPTH_TEST),o.disable(o.CULL_FACE),o.disable(o.BLEND),o.clearColor(0,0,0,0),o.clear(o.COLOR_BUFFER_BIT),o.drawArrays(o.TRIANGLES,0,24),this.checkGLError(o,"render: after draw call"),o.bindVertexArray(null)}greet(){console.log("%c🌈 ai-motion 0.4.8 🌈","background: linear-gradient(90deg, #39b6ff, #bd45fb, #ff5733, #ffd600); color: white; text-shadow: 0 0 2px rgba(0, 0, 0, 0.2); font-weight: bold; font-size: 1em; padding: 2px 12px; border-radius: 6px;")}};a(ft,"Motion");let Motion=ft;function hasDarkModeClass(){const e=["dark","dark-mode","theme-dark","night","night-mode"],t=document.documentElement,o=document.body||document.documentElement;for(const r of e)if(t.classList.contains(r)||o?.classList.contains(r))return!0;return!!t.getAttribute("data-theme")?.toLowerCase().includes("dark")}a(hasDarkModeClass,"hasDarkModeClass");function parseRgbColor(e){const t=/rgba?\((\d+),\s*(\d+),\s*(\d+)/.exec(e);return t?{r:parseInt(t[1]),g:parseInt(t[2]),b:parseInt(t[3])}:null}a(parseRgbColor,"parseRgbColor");function isColorDark(e,t=128){if(!e||e==="transparent"||e.startsWith("rgba(0, 0, 0, 0)"))return!1;const o=parseRgbColor(e);return o?.299*o.r+.587*o.g+.114*o.b<t:!1}a(isColorDark,"isColorDark");function isBackgroundDark(){const e=window.getComputedStyle(document.documentElement),t=window.getComputedStyle(document.body||document.documentElement),o=e.backgroundColor,n=t.backgroundColor;return isColorDark(n)?!0:n==="transparent"||n.startsWith("rgba(0, 0, 0, 0)")?isColorDark(o):!1}a(isBackgroundDark,"isBackgroundDark");function isPageDark(){try{return!!(hasDarkModeClass()||isBackgroundDark())}catch(e){return console.warn("Error determining if page is dark:",e),!1}}a(isPageDark,"isPageDark");const wrapper="_wrapper_gf8tz_1",styles={wrapper},cursor="_cursor_1dgwb_2",cursorBorder="_cursorBorder_1dgwb_10",cursorFilling="_cursorFilling_1dgwb_25",cursorRipple="_cursorRipple_1dgwb_39",clicking="_clicking_1dgwb_57",cursorStyles={cursor,cursorBorder,cursorFilling,cursorRipple,clicking},gt=class gt{constructor(){Z(this,Le);ne(this,"shown",!1);ne(this,"wrapper",document.createElement("div"));ne(this,"motion",new Motion({mode:isPageDark()?"dark":"light",styles:{position:"absolute",inset:"0"}}));Z(this,Y,document.createElement("div"));Z(this,ce,0);Z(this,le,0);Z(this,xe,0);Z(this,Se,0);this.wrapper.id="page-agent-runtime_simulator-mask",this.wrapper.className=styles.wrapper,this.wrapper.setAttribute("data-browser-use-ignore","true"),this.wrapper.appendChild(this.motion.element),this.motion.autoResize(this.wrapper),this.wrapper.addEventListener("click",t=>{t.stopPropagation(),t.preventDefault()}),this.wrapper.addEventListener("mousedown",t=>{t.stopPropagation(),t.preventDefault()}),this.wrapper.addEventListener("mouseup",t=>{t.stopPropagation(),t.preventDefault()}),this.wrapper.addEventListener("mousemove",t=>{t.stopPropagation(),t.preventDefault()}),this.wrapper.addEventListener("wheel",t=>{t.stopPropagation(),t.preventDefault()}),this.wrapper.addEventListener("keydown",t=>{t.stopPropagation(),t.preventDefault()}),this.wrapper.addEventListener("keyup",t=>{t.stopPropagation(),t.preventDefault()}),b(this,Le,Yt).call(this),document.body.appendChild(this.wrapper),b(this,Le,Et).call(this),window.addEventListener("PageAgent::MovePointerTo",t=>{const{x:o,y:n}=t.detail;this.setCursorPosition(o,n)}),window.addEventListener("PageAgent::ClickPointer",t=>{this.triggerClickAnimation()})}setCursorPosition(t,o){T(this,xe,t),T(this,Se,o)}triggerClickAnimation(){p(this,Y).classList.remove(cursorStyles.clicking),p(this,Y).offsetHeight,p(this,Y).classList.add(cursorStyles.clicking)}show(){this.shown||(this.shown=!0,this.motion.start(),this.motion.fadeIn(),this.wrapper.style.display="block",T(this,ce,window.innerWidth/2),T(this,le,window.innerHeight/2),T(this,xe,p(this,ce)),T(this,Se,p(this,le)),p(this,Y).style.left=`${p(this,ce)}px`,p(this,Y).style.top=`${p(this,le)}px`)}hide(){this.shown&&(this.shown=!1,this.motion.fadeOut(),this.motion.pause(),p(this,Y).classList.remove(cursorStyles.clicking),setTimeout(()=>{this.wrapper.style.display="none"},800))}dispose(){this.motion.dispose(),this.wrapper.remove()}};Y=new WeakMap,ce=new WeakMap,le=new WeakMap,xe=new WeakMap,Se=new WeakMap,Le=new WeakSet,Yt=a(function(){p(this,Y).className=cursorStyles.cursor;const t=document.createElement("div");t.className=cursorStyles.cursorRipple,p(this,Y).appendChild(t);const o=document.createElement("div");o.className=cursorStyles.cursorFilling,p(this,Y).appendChild(o);const n=document.createElement("div");n.className=cursorStyles.cursorBorder,p(this,Y).appendChild(n),this.wrapper.appendChild(p(this,Y))},"#createCursor"),Et=a(function(){const t=p(this,ce)+(p(this,xe)-p(this,ce))*.2,o=p(this,le)+(p(this,Se)-p(this,le))*.2,n=Math.abs(t-p(this,xe));n>0&&(n<2?T(this,ce,p(this,xe)):T(this,ce,t),p(this,Y).style.left=`${p(this,ce)}px`);const r=Math.abs(o-p(this,Se));r>0&&(r<2?T(this,le,p(this,Se)):T(this,le,o),p(this,Y).style.top=`${p(this,le)}px`),requestAnimationFrame(()=>b(this,Le,Et).call(this))},"#moveCursorToTarget"),a(gt,"SimulatorMask");let SimulatorMask=gt;const SimulatorMask$1=Object.freeze(Object.defineProperty({__proto__:null,SimulatorMask},Symbol.toStringTag,{value:"Module"}))})();
397
+ }`;const DEFAULT_COLORS=["rgb(57, 182, 255)","rgb(189, 69, 251)","rgb(255, 87, 51)","rgb(255, 214, 0)"];function parseColor(e){const t=e.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(!t)throw new Error(`Invalid color format: ${e}`);const[,o,n,r]=t;return[parseInt(o)/255,parseInt(n)/255,parseInt(r)/255]}a(parseColor,"parseColor");const ft=class ft{element;canvas;options;running=!1;disposed=!1;startTime=0;lastTime=0;rafId=null;glr;observer;constructor(t={}){this.options={width:t.width??600,height:t.height??600,ratio:t.ratio??window.devicePixelRatio??1,borderWidth:t.borderWidth??8,glowWidth:t.glowWidth??200,borderRadius:t.borderRadius??8,mode:t.mode??"light",...t},this.canvas=document.createElement("canvas"),this.options.classNames&&(this.canvas.className=this.options.classNames),this.options.styles&&Object.assign(this.canvas.style,this.options.styles),this.canvas.style.display="block",this.canvas.style.transformOrigin="center",this.canvas.style.pointerEvents="none",this.element=this.canvas,this.setupGL(),this.options.skipGreeting||this.greet()}start(){if(this.disposed)throw new Error("Motion instance has been disposed.");if(this.running)return;if(!this.glr){console.error("WebGL resources are not initialized.");return}this.running=!0,this.startTime=performance.now(),this.resize(this.options.width??600,this.options.height??600,this.options.ratio),this.glr.gl.viewport(0,0,this.canvas.width,this.canvas.height),this.glr.gl.useProgram(this.glr.program),this.glr.gl.uniform2f(this.glr.uResolution,this.canvas.width,this.canvas.height),this.checkGLError(this.glr.gl,"start: after initial setup");const t=a(()=>{if(!this.running||!this.glr)return;this.rafId=requestAnimationFrame(t);const o=performance.now();if(o-this.lastTime<1e3/32)return;this.lastTime=o;const r=(o-this.startTime)*.001;this.render(r)},"loop");this.rafId=requestAnimationFrame(t)}pause(){if(this.disposed)throw new Error("Motion instance has been disposed.");this.running=!1,this.rafId!==null&&cancelAnimationFrame(this.rafId)}dispose(){if(this.disposed)return;this.disposed=!0,this.running=!1,this.rafId!==null&&cancelAnimationFrame(this.rafId);const{gl:t,vao:o,positionBuffer:n,uvBuffer:r,program:i}=this.glr;o&&t.deleteVertexArray(o),n&&t.deleteBuffer(n),r&&t.deleteBuffer(r),t.deleteProgram(i),this.observer&&this.observer.disconnect(),this.canvas.remove()}resize(t,o,n){if(this.disposed)throw new Error("Motion instance has been disposed.");if(this.options.width=t,this.options.height=o,n&&(this.options.ratio=n),!this.running)return;const{gl:r,program:i,vao:s,positionBuffer:c,uvBuffer:l,uResolution:d}=this.glr,h=n??this.options.ratio??window.devicePixelRatio??1,f=Math.max(1,Math.floor(t*h)),g=Math.max(1,Math.floor(o*h));this.canvas.style.width=`${t}px`,this.canvas.style.height=`${o}px`,(this.canvas.width!==f||this.canvas.height!==g)&&(this.canvas.width=f,this.canvas.height=g),r.viewport(0,0,this.canvas.width,this.canvas.height),this.checkGLError(r,"resize: after viewport setup");const{positions:m,uvs:I}=computeBorderGeometry(this.canvas.width,this.canvas.height,this.options.borderWidth*h,this.options.glowWidth*h);r.bindVertexArray(s),r.bindBuffer(r.ARRAY_BUFFER,c),r.bufferData(r.ARRAY_BUFFER,m,r.STATIC_DRAW);const S=r.getAttribLocation(i,"aPosition");r.enableVertexAttribArray(S),r.vertexAttribPointer(S,2,r.FLOAT,!1,0,0),this.checkGLError(r,"resize: after position buffer update"),r.bindBuffer(r.ARRAY_BUFFER,l),r.bufferData(r.ARRAY_BUFFER,I,r.STATIC_DRAW);const P=r.getAttribLocation(i,"aUV");r.enableVertexAttribArray(P),r.vertexAttribPointer(P,2,r.FLOAT,!1,0,0),this.checkGLError(r,"resize: after UV buffer update"),r.useProgram(i),r.uniform2f(d,this.canvas.width,this.canvas.height),r.uniform1f(this.glr.uBorderWidth,this.options.borderWidth*h),r.uniform1f(this.glr.uGlowWidth,this.options.glowWidth*h),r.uniform1f(this.glr.uBorderRadius,this.options.borderRadius*h),this.checkGLError(r,"resize: after uniform updates");const R=performance.now();this.lastTime=R;const F=(R-this.startTime)*.001;this.render(F)}autoResize(t){this.observer&&this.observer.disconnect(),this.observer=new ResizeObserver(()=>{const o=t.getBoundingClientRect();this.resize(o.width,o.height)}),this.observer.observe(t)}fadeIn(){if(this.disposed)throw new Error("Motion instance has been disposed.");return new Promise((t,o)=>{const n=this.canvas.animate([{opacity:0,transform:"scale(1.2)"},{opacity:1,transform:"scale(1)"}],{duration:300,easing:"ease-out",fill:"forwards"});n.onfinish=()=>t(),n.oncancel=()=>o("canceled")})}fadeOut(){if(this.disposed)throw new Error("Motion instance has been disposed.");return new Promise((t,o)=>{const n=this.canvas.animate([{opacity:1,transform:"scale(1)"},{opacity:0,transform:"scale(1.2)"}],{duration:300,easing:"ease-in",fill:"forwards"});n.onfinish=()=>t(),n.oncancel=()=>o("canceled")})}checkGLError(t,o){let n=t.getError();if(n!==t.NO_ERROR){for(console.group(`πŸ”΄ WebGL Error in ${o}`);n!==t.NO_ERROR;){const r=this.getGLErrorName(t,n);console.error(`${r} (0x${n.toString(16)})`),n=t.getError()}console.groupEnd()}}getGLErrorName(t,o){switch(o){case t.INVALID_ENUM:return"INVALID_ENUM";case t.INVALID_VALUE:return"INVALID_VALUE";case t.INVALID_OPERATION:return"INVALID_OPERATION";case t.INVALID_FRAMEBUFFER_OPERATION:return"INVALID_FRAMEBUFFER_OPERATION";case t.OUT_OF_MEMORY:return"OUT_OF_MEMORY";case t.CONTEXT_LOST_WEBGL:return"CONTEXT_LOST_WEBGL";default:return"UNKNOWN_ERROR"}}setupGL(){const t=this.canvas.getContext("webgl2",{antialias:!1,alpha:!0});if(!t)throw new Error("WebGL2 is required but not available.");const o=createProgram(t,vertexShaderSource,fragmentShaderSource);this.checkGLError(t,"setupGL: after createProgram");const n=t.createVertexArray();t.bindVertexArray(n),this.checkGLError(t,"setupGL: after VAO creation");const r=this.canvas.width||2,i=this.canvas.height||2,{positions:s,uvs:c}=computeBorderGeometry(r,i,this.options.borderWidth,this.options.glowWidth),l=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,l),t.bufferData(t.ARRAY_BUFFER,s,t.STATIC_DRAW);const d=t.getAttribLocation(o,"aPosition");t.enableVertexAttribArray(d),t.vertexAttribPointer(d,2,t.FLOAT,!1,0,0),this.checkGLError(t,"setupGL: after position buffer setup");const h=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,h),t.bufferData(t.ARRAY_BUFFER,c,t.STATIC_DRAW);const f=t.getAttribLocation(o,"aUV");t.enableVertexAttribArray(f),t.vertexAttribPointer(f,2,t.FLOAT,!1,0,0),this.checkGLError(t,"setupGL: after UV buffer setup");const g=t.getUniformLocation(o,"uResolution"),m=t.getUniformLocation(o,"uTime"),I=t.getUniformLocation(o,"uBorderWidth"),S=t.getUniformLocation(o,"uGlowWidth"),P=t.getUniformLocation(o,"uBorderRadius"),R=t.getUniformLocation(o,"uColors"),F=t.getUniformLocation(o,"uGlowExponent"),k=t.getUniformLocation(o,"uGlowFactor");t.useProgram(o),t.uniform1f(I,this.options.borderWidth),t.uniform1f(S,this.options.glowWidth),t.uniform1f(P,this.options.borderRadius),this.options.mode==="dark"?(t.uniform1f(F,2),t.uniform1f(k,1.8)):(t.uniform1f(F,1),t.uniform1f(k,1));const w=(this.options.colors||DEFAULT_COLORS).map(parseColor);for(let A=0;A<w.length;A++)t.uniform3f(t.getUniformLocation(o,`uColors[${A}]`),...w[A]);this.checkGLError(t,"setupGL: after uniform setup"),t.bindVertexArray(null),t.bindBuffer(t.ARRAY_BUFFER,null),this.glr={gl:t,program:o,vao:n,positionBuffer:l,uvBuffer:h,uResolution:g,uTime:m,uBorderWidth:I,uGlowWidth:S,uBorderRadius:P,uColors:R}}render(t){if(!this.glr)return;const{gl:o,program:n,vao:r,uTime:i}=this.glr;o.useProgram(n),o.bindVertexArray(r),o.uniform1f(i,t),o.disable(o.DEPTH_TEST),o.disable(o.CULL_FACE),o.disable(o.BLEND),o.clearColor(0,0,0,0),o.clear(o.COLOR_BUFFER_BIT),o.drawArrays(o.TRIANGLES,0,24),this.checkGLError(o,"render: after draw call"),o.bindVertexArray(null)}greet(){console.log("%c🌈 ai-motion 0.4.8 🌈","background: linear-gradient(90deg, #39b6ff, #bd45fb, #ff5733, #ffd600); color: white; text-shadow: 0 0 2px rgba(0, 0, 0, 0.2); font-weight: bold; font-size: 1em; padding: 2px 12px; border-radius: 6px;")}};a(ft,"Motion");let Motion=ft;function hasDarkModeClass(){const e=["dark","dark-mode","theme-dark","night","night-mode"],t=document.documentElement,o=document.body||document.documentElement;for(const r of e)if(t.classList.contains(r)||o?.classList.contains(r))return!0;return!!t.getAttribute("data-theme")?.toLowerCase().includes("dark")}a(hasDarkModeClass,"hasDarkModeClass");function parseRgbColor(e){const t=/rgba?\((\d+),\s*(\d+),\s*(\d+)/.exec(e);return t?{r:parseInt(t[1]),g:parseInt(t[2]),b:parseInt(t[3])}:null}a(parseRgbColor,"parseRgbColor");function isColorDark(e,t=128){if(!e||e==="transparent"||e.startsWith("rgba(0, 0, 0, 0)"))return!1;const o=parseRgbColor(e);return o?.299*o.r+.587*o.g+.114*o.b<t:!1}a(isColorDark,"isColorDark");function isBackgroundDark(){const e=window.getComputedStyle(document.documentElement),t=window.getComputedStyle(document.body||document.documentElement),o=e.backgroundColor,n=t.backgroundColor;return isColorDark(n)?!0:n==="transparent"||n.startsWith("rgba(0, 0, 0, 0)")?isColorDark(o):!1}a(isBackgroundDark,"isBackgroundDark");function isPageDark(){try{return!!(hasDarkModeClass()||isBackgroundDark())}catch(e){return console.warn("Error determining if page is dark:",e),!1}}a(isPageDark,"isPageDark");const wrapper="_wrapper_gf8tz_1",styles={wrapper},cursor="_cursor_1dgwb_2",cursorBorder="_cursorBorder_1dgwb_10",cursorFilling="_cursorFilling_1dgwb_25",cursorRipple="_cursorRipple_1dgwb_39",clicking="_clicking_1dgwb_57",cursorStyles={cursor,cursorBorder,cursorFilling,cursorRipple,clicking},gt=class gt{constructor(){Z(this,Le);ne(this,"shown",!1);ne(this,"wrapper",document.createElement("div"));ne(this,"motion",new Motion({mode:isPageDark()?"dark":"light",styles:{position:"absolute",inset:"0"}}));Z(this,Y,document.createElement("div"));Z(this,ce,0);Z(this,le,0);Z(this,xe,0);Z(this,Se,0);this.wrapper.id="page-agent-runtime_simulator-mask",this.wrapper.className=styles.wrapper,this.wrapper.setAttribute("data-browser-use-ignore","true"),this.wrapper.appendChild(this.motion.element),this.motion.autoResize(this.wrapper),this.wrapper.addEventListener("click",t=>{t.stopPropagation(),t.preventDefault()}),this.wrapper.addEventListener("mousedown",t=>{t.stopPropagation(),t.preventDefault()}),this.wrapper.addEventListener("mouseup",t=>{t.stopPropagation(),t.preventDefault()}),this.wrapper.addEventListener("mousemove",t=>{t.stopPropagation(),t.preventDefault()}),this.wrapper.addEventListener("wheel",t=>{t.stopPropagation(),t.preventDefault()}),this.wrapper.addEventListener("keydown",t=>{t.stopPropagation(),t.preventDefault()}),this.wrapper.addEventListener("keyup",t=>{t.stopPropagation(),t.preventDefault()}),b(this,Le,Yt).call(this),document.body.appendChild(this.wrapper),b(this,Le,Et).call(this),window.addEventListener("PageAgent::MovePointerTo",t=>{const{x:o,y:n}=t.detail;this.setCursorPosition(o,n)}),window.addEventListener("PageAgent::ClickPointer",t=>{this.triggerClickAnimation()})}setCursorPosition(t,o){T(this,xe,t),T(this,Se,o)}triggerClickAnimation(){p(this,Y).classList.remove(cursorStyles.clicking),p(this,Y).offsetHeight,p(this,Y).classList.add(cursorStyles.clicking)}show(){this.shown||(this.shown=!0,this.motion.start(),this.motion.fadeIn(),this.wrapper.style.display="block",T(this,ce,window.innerWidth/2),T(this,le,window.innerHeight/2),T(this,xe,p(this,ce)),T(this,Se,p(this,le)),p(this,Y).style.left=`${p(this,ce)}px`,p(this,Y).style.top=`${p(this,le)}px`)}hide(){this.shown&&(this.shown=!1,this.motion.fadeOut(),this.motion.pause(),p(this,Y).classList.remove(cursorStyles.clicking),setTimeout(()=>{this.wrapper.style.display="none"},800))}dispose(){this.motion.dispose(),this.wrapper.remove()}};Y=new WeakMap,ce=new WeakMap,le=new WeakMap,xe=new WeakMap,Se=new WeakMap,Le=new WeakSet,Yt=a(function(){p(this,Y).className=cursorStyles.cursor;const t=document.createElement("div");t.className=cursorStyles.cursorRipple,p(this,Y).appendChild(t);const o=document.createElement("div");o.className=cursorStyles.cursorFilling,p(this,Y).appendChild(o);const n=document.createElement("div");n.className=cursorStyles.cursorBorder,p(this,Y).appendChild(n),this.wrapper.appendChild(p(this,Y))},"#createCursor"),Et=a(function(){const t=p(this,ce)+(p(this,xe)-p(this,ce))*.2,o=p(this,le)+(p(this,Se)-p(this,le))*.2,n=Math.abs(t-p(this,xe));n>0&&(n<2?T(this,ce,p(this,xe)):T(this,ce,t),p(this,Y).style.left=`${p(this,ce)}px`);const r=Math.abs(o-p(this,Se));r>0&&(r<2?T(this,le,p(this,Se)):T(this,le,o),p(this,Y).style.top=`${p(this,le)}px`),requestAnimationFrame(()=>b(this,Le,Et).call(this))},"#moveCursorToTarget"),a(gt,"SimulatorMask");let SimulatorMask=gt;const SimulatorMask$1=Object.freeze(Object.defineProperty({__proto__:null,SimulatorMask},Symbol.toStringTag,{value:"Module"}))})();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "page-agent",
3
3
  "private": false,
4
- "version": "1.3.0",
4
+ "version": "1.4.0",
5
5
  "type": "module",
6
6
  "main": "./dist/esm/page-agent.js",
7
7
  "module": "./dist/esm/page-agent.js",
@@ -44,10 +44,10 @@
44
44
  "postpublish": "node -e \"['README.md','LICENSE'].forEach(f=>{try{require('fs').unlinkSync(f)}catch{}})\""
45
45
  },
46
46
  "dependencies": {
47
- "@page-agent/core": "1.3.0",
48
- "@page-agent/llms": "1.3.0",
49
- "@page-agent/page-controller": "1.3.0",
50
- "@page-agent/ui": "1.3.0",
47
+ "@page-agent/core": "1.4.0",
48
+ "@page-agent/llms": "1.4.0",
49
+ "@page-agent/page-controller": "1.4.0",
50
+ "@page-agent/ui": "1.4.0",
51
51
  "chalk": "^5.6.2",
52
52
  "zod": "^4.3.5"
53
53
  }