page-agent 1.5.6 β†’ 1.5.8

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/LICENSE CHANGED
@@ -1,7 +1,7 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2026 Alibaba
4
- Copyright (c) 2026 Simon
3
+ Copyright (c) 2026 SimonLuvRamen
4
+ Copyright (c) 2026 Alibaba Group Holding Limited
5
5
 
6
6
  Permission is hereby granted, free of charge, to any person obtaining a copy
7
7
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -5,13 +5,13 @@
5
5
  <img alt="Page Agent Banner" src="https://img.alicdn.com/imgextra/i1/O1CN01NCMKXj1Gn4tkFTsxf_!!6000000000666-2-tps-1280-256.png">
6
6
  </picture>
7
7
 
8
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![TypeScript](https://img.shields.io/badge/%3C%2F%3E-TypeScript-%230074c1.svg)](http://www.typescriptlang.org/) [![Downloads](https://img.shields.io/npm/dt/page-agent.svg)](https://www.npmjs.com/package/page-agent) [![Bundle Size](https://img.shields.io/bundlephobia/minzip/page-agent)](https://bundlephobia.com/package/page-agent) [![GitHub stars](https://img.shields.io/github/stars/alibaba/page-agent.svg)](https://github.com/alibaba/page-agent)
8
+ [![License: MIT](https://img.shields.io/badge/License-MIT-auto.svg)](https://opensource.org/licenses/MIT) [![TypeScript](https://img.shields.io/badge/%3C%2F%3E-TypeScript-%230074c1.svg)](http://www.typescriptlang.org/) [![Bundle Size](https://img.shields.io/bundlephobia/minzip/page-agent)](https://bundlephobia.com/package/page-agent) [![Downloads](https://img.shields.io/npm/dt/page-agent.svg)](https://www.npmjs.com/package/page-agent) [![GitHub stars](https://img.shields.io/github/stars/alibaba/page-agent.svg)](https://github.com/alibaba/page-agent)
9
9
 
10
10
  The GUI Agent Living in Your Webpage. Control web interfaces with natural language.
11
11
 
12
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> | <a href="https://news.ycombinator.com/item?id=47264138" target="_blank">πŸ“’ Join HN Discussion</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>πŸ“– Docs</b></a> | <a href="https://news.ycombinator.com/item?id=47264138" target="_blank"><b>πŸ“’ HN Discussion</b></a> | <a href="https://x.com/simonluvramen" target="_blank"><b>𝕏 Follow on X</b></a>
15
15
 
16
16
  <video id="demo-video" src="https://github.com/user-attachments/assets/a1f2eae2-13fb-4aae-98cf-a3fc1620a6c2" controls crossorigin muted></video>
17
17
 
@@ -22,20 +22,18 @@ The GUI Agent Living in Your Webpage. Control web interfaces with natural langua
22
22
  - **🎯 Easy integration**
23
23
  - No need for `browser extension` / `python` / `headless browser`.
24
24
  - Just in-page javascript. Everything happens in your web page.
25
- - The best tool for your agent to control web pages.
26
25
  - **πŸ“– Text-based DOM manipulation**
27
- - No screenshots. No OCR or multi-modal LLMs needed.
28
- - No special permissions required.
26
+ - No screenshots. No multi-modal LLMs or special permissions needed.
29
27
  - **🧠 Bring your own LLMs**
30
28
  - **🎨 Pretty UI with human-in-the-loop**
31
29
  - **πŸ™ Optional [chrome extension](https://alibaba.github.io/page-agent/docs/features/chrome-extension) for multi-page tasks.**
32
30
 
33
31
  ## πŸ’‘ Use Cases
34
32
 
35
- - **SaaS AI Copilot** β€” Ship an AI copilot in your product in lines of code. No backend rewrite needed.
33
+ - **SaaS AI Copilot** β€” Ship an AI copilot in your product in lines of code. No backend rewrite.
36
34
  - **Smart Form Filling** β€” Turn 20-click workflows into one sentence. Perfect for ERP, CRM, and admin systems.
37
35
  - **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).
36
+ - **Multi-page Agent** β€” Extend your own agent's reach across browser tabs with the optional [chrome extension](https://alibaba.github.io/page-agent/docs/features/chrome-extension).
39
37
 
40
38
  ## πŸš€ Quick Start
41
39
 
@@ -47,12 +45,12 @@ Fastest way to try PageAgent with our free Demo LLM:
47
45
  <script src="{URL}" crossorigin="true"></script>
48
46
  ```
49
47
 
48
+ > **⚠️ 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
+
50
50
  | Mirrors | URL |
51
51
  | ------- | ---------------------------------------------------------------------------------- |
52
- | Global | https://cdn.jsdelivr.net/npm/page-agent@1.5.6/dist/iife/page-agent.demo.js |
53
- | China | https://registry.npmmirror.com/page-agent/1.5.6/files/dist/iife/page-agent.demo.js |
54
-
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).
52
+ | Global | https://cdn.jsdelivr.net/npm/page-agent@1.5.8/dist/iife/page-agent.demo.js |
53
+ | China | https://registry.npmmirror.com/page-agent/1.5.8/files/dist/iife/page-agent.demo.js |
56
54
 
57
55
  ### NPM Installation
58
56
 
@@ -77,10 +75,12 @@ For more programmatic usage, see [πŸ“– Documentations](https://alibaba.github.io
77
75
 
78
76
  ## 🀝 Contributing
79
77
 
80
- We welcome contributions from the community! Follow our instructions in [CONTRIBUTING.md](CONTRIBUTING.md) for environment setup and local development.
78
+ We welcome contributions from the community! Follow our instructions in [CONTRIBUTING.md](CONTRIBUTING.md) for setup and guidelines.
81
79
 
82
80
  Please read [Code of Conduct](docs/CODE_OF_CONDUCT.md) before contributing.
83
81
 
82
+ Contributions generated entirely by bots or agents without substantial human involvement will not be accepted, and bot accounts may be blocked.
83
+
84
84
  ## πŸ‘ Acknowledgments
85
85
 
86
86
  This project builds upon the excellent work of **[`browser-use`](https://github.com/browser-use/browser-use)**.
@@ -90,12 +90,10 @@ This project builds upon the excellent work of **[`browser-use`](https://github.
90
90
  ```
91
91
  DOM processing components and prompt are derived from browser-use:
92
92
 
93
- Browser Use
93
+ Browser Use <https://github.com/browser-use/browser-use>
94
94
  Copyright (c) 2024 Gregor Zunic
95
95
  Licensed under the MIT License
96
96
 
97
- Original browser-use project: <https://github.com/browser-use/browser-use>
98
-
99
97
  We gratefully acknowledge the browser-use project and its contributors for their
100
98
  excellent work on web automation and DOM interaction patterns that helped make
101
99
  this project possible.
@@ -114,8 +112,8 @@ file and in the node_modules directory after installation.
114
112
 
115
113
  <a href="https://www.star-history.com/?repos=alibaba%2Fpage-agent&type=date">
116
114
  <picture>
117
- <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/image?repos=alibaba/page-agent&type=date&theme=dark&legend=top-left&v=2" />
118
- <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/image?repos=alibaba/page-agent&type=date&legend=top-left&v=2" />
119
- <img alt="Star History Chart" src="https://api.star-history.com/image?repos=alibaba/page-agent&type=date&legend=top-left&v=2" />
115
+ <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/image?repos=alibaba/page-agent&type=date&theme=dark&legend=top-left&v=7" />
116
+ <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/image?repos=alibaba/page-agent&type=date&legend=top-left&v=7" />
117
+ <img alt="Star History Chart" src="https://api.star-history.com/image?repos=alibaba/page-agent&type=date&legend=top-left&v=7" />
120
118
  </picture>
121
119
  </a>
@@ -1,5 +1,5 @@
1
- var $t=Object.defineProperty;var xt=L=>{throw TypeError(L)};var qt=(L,M,W)=>M in L?$t(L,M,{enumerable:!0,configurable:!0,writable:!0,value:W}):L[M]=W;var a=(L,M)=>$t(L,"name",{value:M,configurable:!0});var oe=(L,M,W)=>qt(L,typeof M!="symbol"?M+"":M,W),mt=(L,M,W)=>M.has(L)||xt("Cannot "+W);var p=(L,M,W)=>(mt(L,M,"read from private field"),W?W.call(L):M.get(L)),Z=(L,M,W)=>M.has(L)?xt("Cannot add the same private member more than once"):M instanceof WeakSet?M.add(L):M.set(L,W),S=(L,M,W,De)=>(mt(L,M,"write to private field"),De?De.call(L,W):M.set(L,W),W),b=(L,M,W)=>(mt(L,M,"access private method"),W);(function(){"use strict";var Ue,Oe,se,Ee,X,R,St,Pe,Me,_t,Tt,It,zt,At,Pt,st,ne,je,ie,ye,Ce,be,Re,we,B,Ge,$e,j,xe,ve,Ze,Q,Be,He,Je,Ye,qe,_,Ot,Ct,Rt,Zt,yt,Nt,Lt,Mt,tt,bt,Ft,Dt,Ut,wt,ot,it,jt,Bt,Wt,Vt,Fe,vt,kt,Gt,Ht,Jt,Y,ae,ce,Se,Te,Ne,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(`
1
+ var $t=Object.defineProperty;var xt=M=>{throw TypeError(M)};var qt=(M,F,W)=>F in M?$t(M,F,{enumerable:!0,configurable:!0,writable:!0,value:W}):M[F]=W;var a=(M,F)=>$t(M,"name",{value:F,configurable:!0});var oe=(M,F,W)=>qt(M,typeof F!="symbol"?F+"":F,W),mt=(M,F,W)=>F.has(M)||xt("Cannot "+W);var p=(M,F,W)=>(mt(M,F,"read from private field"),W?W.call(M):F.get(M)),Z=(M,F,W)=>F.has(M)?xt("Cannot add the same private member more than once"):F instanceof WeakSet?F.add(M):F.set(M,W),S=(M,F,W,De)=>(mt(M,F,"write to private field"),De?De.call(M,W):F.set(M,W),W),b=(M,F,W)=>(mt(M,F,"access private method"),W);(function(){"use strict";var Ue,Oe,se,Ee,X,R,St,Pe,Me,_t,Tt,It,zt,At,Pt,st,ne,je,ie,ye,Ce,be,Re,we,B,Ge,$e,j,xe,ve,Ze,Q,Be,He,Je,Ye,qe,_,Ot,Ct,Rt,Zt,yt,Nt,Lt,Mt,tt,bt,Ft,Dt,Ut,wt,ot,it,jt,Bt,Wt,Vt,Fe,vt,kt,Gt,Ht,Jt,q,ae,ce,Se,Te,Ne,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_1ooyb_1{position:fixed;inset:0;z-index:2147483641;cursor:wait;overflow:hidden;display:none}._wrapper_1ooyb_1._visible_1ooyb_11{display:block}._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 M=class M extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}};a(M,"$ZodAsyncError");let $ZodAsyncError=M;const F=class F extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}};a(F,"$ZodEncodeError");let $ZodEncodeError=F;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
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)}}),W=class W{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(`
4
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(`
5
5
  `))}};a(W,"Doc");let Doc=W;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],T=m._zod.optout==="optional",I=m._zod.run({value:d[g],issues:[]},l);I instanceof Promise?h.push(I.then(A=>handlePropertyResult(A,c,g,d,T))):handlePropertyResult(I,c,g,d,T)}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"]),T=n.value,I=a(v=>{const k=esc(v);return`shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`},"parseStr");m.write("const input = payload.value;");const A=Object.create(null);let C=0;for(const v of T.keys)A[v]=`key_${C++}`;m.write("const newResult = {};");for(const v of T.keys){const k=A[v],O=esc(v),H=g[v]?._zod?.optout==="optional";m.write(`const ${k} = ${I(v)};`),H?m.write(`
@@ -113,7 +113,7 @@ Strictly follow these rules while using the browser and navigating the web:
113
113
  - By default, only elements in the visible viewport are listed. Use scrolling actions if you suspect relevant content is offscreen which you need to interact with. Scroll ONLY if there are more pixels below or above the page.
114
114
  - You can scroll by a specific number of pages using the num_pages parameter (e.g., 0.5 for half page, 2.0 for two pages).
115
115
  - All the elements that are scrollable are marked with \`data-scrollable\` attribute. Including the scrollable distance in every directions. You can scroll *the element* in case some area are overflowed.
116
- - If a captcha appears, tell user you can not solve captcha. finished the task and ask user to solve it.
116
+ - If a captcha appears, tell user you can not solve captcha. Finish the task and ask user to solve it.
117
117
  - If expected elements are missing, try scrolling, or navigating back.
118
118
  - If the page is not fully loaded, use the \`wait\` action.
119
119
  - Do not repeat one action for more than 3 times unless some conditions changed.
@@ -131,11 +131,11 @@ Strictly follow these rules while using the browser and navigating the web:
131
131
 
132
132
  <capability>
133
133
  - You can only handle single page app. Do not jump out of current page.
134
- - Do not click on link if it will open in a new page (etc. <a target="_blank">)
134
+ - Do not click on link if it will open in a new page (e.g., <a target="_blank">)
135
135
  - It is ok to fail the task.
136
136
  - User can be wrong. If the request of user is not achievable, inappropriate or you do not have enough information or tools to achieve it. Tell user to make a better request.
137
137
  - Webpage can be broken. All webpages or apps have bugs. Some bug will make it hard for your job. It's encouraged to tell user the problem of current page. Your feedbacks (including failing) are valuable for user.
138
- - Trying to hard can be harmful. Repeating some action back and forth or pushing for a complex procedure with little knowledge can cause unwanted result and harmful side-effects. User would rather you to complete the task with a fail.
138
+ - Trying too hard can be harmful. Repeating some action back and forth or pushing for a complex procedure with little knowledge can cause unwanted results and harmful side-effects. User would rather you complete the task with a fail.
139
139
  - If you do not have knowledge for the current webpage or task. You must require user to give specific instructions and detailed steps.
140
140
  </capability>
141
141
 
@@ -195,7 +195,7 @@ Here are examples of good output patterns. Use them as reference but never copy
195
195
  }
196
196
  }
197
197
  </output>
198
- `,log=console.log.bind(console,chalk.yellow("[autoFixer]"));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"&&(log("#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"&&(log("#2: fixing tool_call"),o=safeJsonParse(o.arguments)),o?.type==="function"&&(log("#3: fixing tool_call"),o=safeJsonParse(o.function.arguments)),!o?.action&&!o?.evaluation_previous_goal&&!o?.memory&&!o?.next_goal&&!o?.thinking&&(log("#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||(log("#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&&(log(`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 truncate$1(e,t){return e.length>t?e.substring(0,t)+"...":e}a(truncate$1,"truncate$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");const llmsTxtCache=new Map;async function fetchLlmsTxt(e){const t=new URL(e).origin;if(llmsTxtCache.has(t))return llmsTxtCache.get(t);const o=`${t}/llms.txt`;let n=null;try{console.log(chalk.gray(`[llms.txt] Fetching ${o}`));const r=await fetch(o,{signal:AbortSignal.timeout(3e3)});r.ok?(n=await r.text(),console.log(chalk.green(`[llms.txt] Found (${n.length} chars)`)),n.length>1e3&&(console.log(chalk.yellow("[llms.txt] Truncating to 1000 chars")),n=truncate$1(n,1e3))):console.debug(chalk.gray(`[llms.txt] ${r.status} for ${o}`))}catch(r){console.debug(chalk.gray(`[llms.txt] not found for ${o}`),r)}return llmsTxtCache.set(t,n),n}a(fetchLlmsTxt,"fetchLlmsTxt");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,R);oe(this,"id",uid());oe(this,"config");oe(this,"tools");oe(this,"pageController");oe(this,"task","");oe(this,"taskId","");oe(this,"history",[]);oe(this,"disposed",!1);oe(this,"onAskUser");Z(this,Ue,"idle");Z(this,Oe);Z(this,se,new AbortController);Z(this,Ee,[]);Z(this,X,{totalWaitTime:0,lastURL:"",browserState:null});if(this.config={...o,maxSteps:o.maxSteps??40},S(this,Oe,new LLM(this.config)),this.tools=new Map(tools),this.pageController=o.pageController,p(this,Oe).addEventListener("retry",n=>{const{attempt:r,maxAttempts:i}=n.detail;b(this,R,Me).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,R,Pe).call(this)}),p(this,Oe).addEventListener("error",n=>{const r=n.detail.error;if(r?.rawError?.name==="AbortError")return;const i=String(r);b(this,R,Me).call(this,{type:"error",message:i}),this.history.push({type:"error",message:i,rawResponse:r.rawResponse}),b(this,R,Pe).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,Ue)}pushObservation(o){p(this,Ee).push(o)}stop(){this.pageController.cleanUpHighlights(),this.pageController.hideMask(),p(this,se).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,se)&&(p(this,se).abort(),S(this,se,new AbortController)),this.history=[],b(this,R,_t).call(this,"running"),b(this,R,Pe).call(this),S(this,Ee,[]),S(this,X,{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,X).browserState=await this.pageController.getBrowserState(),await b(this,R,At).call(this,c);const l=[{role:"system",content:b(this,R,It).call(this)},{role:"user",content:await b(this,R,Pt).call(this)}],d={AgentOutput:b(this,R,Tt).call(this)};console.log(chalk.blue.bold("🧠 Thinking...")),b(this,R,Me).call(this,{type:"thinking"});const h=await p(this,Oe).invoke(l,d,p(this,se).signal,{toolChoiceName:"AgentOutput",normalizeResponse:a(C=>normalizeResponse(C,this.tools),"normalizeResponse")}),f=h.toolResult,g=f.input,m=f.output,T={evaluation_previous_goal:g.evaluation_previous_goal,memory:g.memory,next_goal:g.next_goal},I=Object.keys(g.action)[0],A={name:I,input:g.action[I],output:m};if(this.history.push({type:"step",stepIndex:c,reflection:T,action:A,usage:h.usage,rawResponse:h.rawResponse,rawRequest:h.rawRequest}),b(this,R,Pe).call(this),await r?.(this,this.history),console.groupEnd(),I==="done"){const C=A.input?.success??!1,D=A.input?.text||"no text provided";console.log(chalk.green.bold("Task completed"),C,D),b(this,R,st).call(this,C);const v={success:C,data:D,history:this.history};return await s?.(this,v),v}}catch(l){console.groupEnd();const d=l?.rawError?.name==="AbortError";console.error("Task failed",l);const h=d?"Task stopped":String(l);b(this,R,Me).call(this,{type:"error",message:h}),this.history.push({type:"error",message:h,rawResponse:l}),b(this,R,Pe).call(this),b(this,R,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,R,Pe).call(this),b(this,R,st).call(this,!1);const d={success:!1,data:l,history:this.history};return await s?.(this,d),d}await waitFor$1(.4)}}dispose(){console.log("Disposing PageAgent..."),this.disposed=!0,this.pageController.dispose(),p(this,se).abort(),this.dispatchEvent(new Event("dispose")),this.config.onDispose?.(this)}};Ue=new WeakMap,Oe=new WeakMap,se=new WeakMap,Ee=new WeakMap,X=new WeakMap,R=new WeakSet,St=a(function(){this.dispatchEvent(new Event("statuschange"))},"#emitStatusChange"),Pe=a(function(){this.dispatchEvent(new Event("historychange"))},"#emitHistoryChange"),Me=a(function(o){this.dispatchEvent(new CustomEvent("activity",{detail:o}))},"#emitActivity"),_t=a(function(o){p(this,Ue)!==o&&(S(this,Ue,o),b(this,R,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,se).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
+ `,log=console.log.bind(console,chalk.yellow("[autoFixer]"));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"&&(log("#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"&&(log("#2: fixing tool_call"),o=safeJsonParse(o.arguments)),o?.type==="function"&&(log("#3: fixing tool_call"),o=safeJsonParse(o.function.arguments)),!o?.action&&!o?.evaluation_previous_goal&&!o?.memory&&!o?.next_goal&&!o?.thinking&&(log("#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||(log("#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&&(log(`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 truncate$1(e,t){return e.length>t?e.substring(0,t)+"...":e}a(truncate$1,"truncate$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 tries");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");const llmsTxtCache=new Map;async function fetchLlmsTxt(e){let t;try{t=new URL(e).origin}catch{return null}if(t==="null")return null;if(llmsTxtCache.has(t))return llmsTxtCache.get(t);const o=`${t}/llms.txt`;let n=null;try{console.log(chalk.gray(`[llms.txt] Fetching ${o}`));const r=await fetch(o,{signal:AbortSignal.timeout(3e3)});r.ok?(n=await r.text(),console.log(chalk.green(`[llms.txt] Found (${n.length} chars)`)),n.length>1e3&&(console.log(chalk.yellow("[llms.txt] Truncating to 1000 chars")),n=truncate$1(n,1e3))):console.debug(chalk.gray(`[llms.txt] ${r.status} for ${o}`))}catch(r){console.debug(chalk.gray(`[llms.txt] not found for ${o}`),r)}return llmsTxtCache.set(t,n),n}a(fetchLlmsTxt,"fetchLlmsTxt");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,R);oe(this,"id",uid());oe(this,"config");oe(this,"tools");oe(this,"pageController");oe(this,"task","");oe(this,"taskId","");oe(this,"history",[]);oe(this,"disposed",!1);oe(this,"onAskUser");Z(this,Ue,"idle");Z(this,Oe);Z(this,se,new AbortController);Z(this,Ee,[]);Z(this,X,{totalWaitTime:0,lastURL:"",browserState:null});if(this.config={...o,maxSteps:o.maxSteps??40},S(this,Oe,new LLM(this.config)),this.tools=new Map(tools),this.pageController=o.pageController,p(this,Oe).addEventListener("retry",n=>{const{attempt:r,maxAttempts:i}=n.detail;b(this,R,Me).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,R,Pe).call(this)}),p(this,Oe).addEventListener("error",n=>{const r=n.detail.error;if(r?.rawError?.name==="AbortError")return;const i=String(r);b(this,R,Me).call(this,{type:"error",message:i}),this.history.push({type:"error",message:i,rawResponse:r.rawResponse}),b(this,R,Pe).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,Ue)}pushObservation(o){p(this,Ee).push(o)}stop(){this.pageController.cleanUpHighlights(),this.pageController.hideMask(),p(this,se).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,se)&&(p(this,se).abort(),S(this,se,new AbortController)),this.history=[],b(this,R,_t).call(this,"running"),b(this,R,Pe).call(this),S(this,Ee,[]),S(this,X,{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,X).browserState=await this.pageController.getBrowserState(),await b(this,R,At).call(this,c);const l=[{role:"system",content:b(this,R,It).call(this)},{role:"user",content:await b(this,R,Pt).call(this)}],d={AgentOutput:b(this,R,Tt).call(this)};console.log(chalk.blue.bold("🧠 Thinking...")),b(this,R,Me).call(this,{type:"thinking"});const h=await p(this,Oe).invoke(l,d,p(this,se).signal,{toolChoiceName:"AgentOutput",normalizeResponse:a(C=>normalizeResponse(C,this.tools),"normalizeResponse")}),f=h.toolResult,g=f.input,m=f.output,T={evaluation_previous_goal:g.evaluation_previous_goal,memory:g.memory,next_goal:g.next_goal},I=Object.keys(g.action)[0],A={name:I,input:g.action[I],output:m};if(this.history.push({type:"step",stepIndex:c,reflection:T,action:A,usage:h.usage,rawResponse:h.rawResponse,rawRequest:h.rawRequest}),b(this,R,Pe).call(this),await r?.(this,this.history),console.groupEnd(),I==="done"){const C=A.input?.success??!1,D=A.input?.text||"no text provided";console.log(chalk.green.bold("Task completed"),C,D),b(this,R,st).call(this,C);const v={success:C,data:D,history:this.history};return await s?.(this,v),v}}catch(l){console.groupEnd();const d=l?.rawError?.name==="AbortError";console.error("Task failed",l);const h=d?"Task stopped":String(l);b(this,R,Me).call(this,{type:"error",message:h}),this.history.push({type:"error",message:h,rawResponse:l}),b(this,R,Pe).call(this),b(this,R,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,R,Pe).call(this),b(this,R,st).call(this,!1);const d={success:!1,data:l,history:this.history};return await s?.(this,d),d}await waitFor$1(this.config.stepDelay??.4)}}dispose(){console.log("Disposing PageAgent..."),this.disposed=!0,this.pageController.dispose(),p(this,se).abort(),this.dispatchEvent(new Event("dispose")),this.config.onDispose?.(this)}};Ue=new WeakMap,Oe=new WeakMap,se=new WeakMap,Ee=new WeakMap,X=new WeakMap,R=new WeakSet,St=a(function(){this.dispatchEvent(new Event("statuschange"))},"#emitStatusChange"),Pe=a(function(){this.dispatchEvent(new Event("historychange"))},"#emitHistoryChange"),Me=a(function(o){this.dispatchEvent(new CustomEvent("activity",{detail:o}))},"#emitActivity"),_t=a(function(o){p(this,Ue)!==o&&(S(this,Ue,o),b(this,R,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,se).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
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,R,Me).call(this,{type:"executing",tool:l,input:d});const m=Date.now(),T=await g.execute.bind(this)(d),I=Date.now()-m;return console.log(chalk.green.bold(`Tool (${l}) executed for ${I}ms`),T),b(this,R,Me).call(this,{type:"executed",tool:l,input:d,output:T,duration:I}),l==="wait"?p(this,X).totalWaitTime+=d?.seconds||0:p(this,X).totalWaitTime=0,{input:s,output:T}},"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,experimentalLlmsTxt:n}=this.config,r=o?.system?.trim();let i;const s=p(this,X).browserState?.url||"";if(o?.getPageInstructions&&s)try{i=o.getPageInstructions(s)?.trim()}catch(d){console.error(chalk.red("[PageAgent] Failed to execute getPageInstructions callback:"),d)}const c=n&&s?await fetchLlmsTxt(s):void 0;if(!r&&!i&&!c)return"";let l=`<instructions>
200
200
  `;return r&&(l+=`<system_instructions>
201
201
  ${r}
@@ -236,7 +236,7 @@ ${c}
236
236
 
237
237
  `,n+=`</browser_state>
238
238
 
239
- `,n},"#assembleUserPrompt"),st=a(function(o=!0){this.pageController.cleanUpHighlights(),this.pageController.hideMask(),b(this,R,_t).call(this,o?"completed":"error"),p(this,se).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(.2)}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){const o=e.isContentEditable;if(!(e instanceof HTMLInputElement)&&!(e instanceof HTMLTextAreaElement)&&!o)throw new Error("Element is not an input, textarea, or contenteditable");await clickElement(e),o?(e.dispatchEvent(new InputEvent("beforeinput",{bubbles:!0,cancelable:!0,inputType:"deleteContent"}))&&(e.innerText="",e.dispatchEvent(new InputEvent("input",{bubbles:!0,inputType:"deleteContent"}))),e.dispatchEvent(new InputEvent("beforeinput",{bubbles:!0,cancelable:!0,inputType:"insertText",data:t}))&&(e.innerText=t,e.dispatchEvent(new InputEvent("input",{bubbles:!0,inputType:"insertText",data:t}))),e.dispatchEvent(new Event("change",{bubbles:!0})),e.blur()):e instanceof HTMLTextAreaElement?nativeTextAreaValueSetter.call(e,t):nativeInputValueSetter.call(e,t),o||e.dispatchEvent(new Event("input",{bubbles:!0})),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;let l=c,d=!1,h=null,f=0,g=0;const m=t;for(;l&&g<10;){const T=window.getComputedStyle(l),I=/(auto|scroll|overlay)/.test(T.overflowY),A=l.scrollHeight>l.clientHeight;if(I&&A){const C=l.scrollTop,D=l.scrollHeight-l.clientHeight;let v=m/3;v>0?v=Math.min(v,D-C):v=Math.max(v,-C),l.scrollTop=C+v;const O=l.scrollTop-C;if(Math.abs(O)>.5){d=!0,h=l,f=O;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;let l=c,d=!1,h=null,f=0,g=0;const m=e?t:-t;for(;l&&g<10;){const T=window.getComputedStyle(l),I=/(auto|scroll|overlay)/.test(T.overflowX),A=l.scrollWidth>l.clientWidth;if(I&&A){const C=l.scrollLeft,D=l.scrollWidth-l.clientWidth;let v=m/3;v>0?v=Math.min(v,D-C):v=Math.max(v,-C),l.scrollLeft=C+v;const O=l.scrollLeft-C;if(Math.abs(O)>.5){d=!0,h=l,f=O;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 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 T(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(T,"getCachedComputedStyle");function I(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(I,"getCachedClientRects");const A={},C={current:0},D="playwright-highlight-container";function v(u,y,P=null){if(!u)return y;const w=[];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 ze=K[J];const ee=ze+Math.floor(n*255).toString(16).padStart(2,"0");ze=ze+Math.floor(r*255).toString(16).padStart(2,"0");let re={x:0,y:0};if(P){const V=P.getBoundingClientRect();re.x=V.left,re.y=V.top}const ge=document.createDocumentFragment();for(const V of F){if(V.width===0||V.height===0)continue;const G=document.createElement("div");G.style.position="fixed",G.style.border=`2px solid ${ze}`,G.style.backgroundColor=ee,G.style.pointerEvents="none",G.style.boxSizing="border-box";const U=V.top+re.y,ke=V.left+re.x;G.style.top=`${U}px`,G.style.left=`${ke}px`,G.style.width=`${V.width}px`,G.style.height=`${V.height}px`,ge.appendChild(G),w.push({element:G,initialRect:V})}const me=F[0];E=document.createElement("div"),E.className="playwright-highlight-label",E.style.position="fixed",E.style.background=ze,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 Le=me.top+re.y,et=me.left+re.x;let nt=Le+2,We=et+me.width-N-2;(me.width<N+4||me.height<$+4)&&(nt=Le-$-2,We=et+me.width-N,We<re.x&&(We=et)),nt=Math.max(0,Math.min(nt,window.innerHeight-$)),We=Math.max(0,Math.min(We,window.innerWidth-N)),E.style.top=`${nt}px`,E.style.left=`${We}px`,ge.appendChild(E);const rt=a((V,G)=>{let U=0;return(...ke)=>{const te=performance.now();if(!(te-U<G))return U=te,V(...ke)}},"throttleFunction")(a(()=>{const V=u.getClientRects();let G={x:0,y:0};if(P){const U=P.getBoundingClientRect();G.x=U.left,G.y=U.top}if(w.forEach((U,ke)=>{if(ke<V.length){const te=V[ke],Ve=te.top+G.y,Ae=te.left+G.x;U.element.style.top=`${Ve}px`,U.element.style.left=`${Ae}px`,U.element.style.width=`${te.width}px`,U.element.style.height=`${te.height}px`,U.element.style.display=te.width===0||te.height===0?"none":"block"}else U.element.style.display="none"}),V.length<w.length)for(let U=V.length;U<w.length;U++)w[U].element.style.display="none";if(E&&V.length>0){const U=V[0],ke=U.top+G.y,te=U.left+G.x;let Ve=ke+2,Ae=te+U.width-N-2;(U.width<N+4||U.height<$+4)&&(Ve=ke-$-2,Ae=te+U.width-N,Ae<G.x&&(Ae=te)),Ve=Math.max(0,Math.min(Ve,window.innerHeight-$)),Ae=Math.max(0,Math.min(Ae,window.innerWidth-N)),E.style.top=`${Ve}px`,E.style.left=`${Ae}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),w.forEach(V=>V.element.remove()),E&&E.remove()},"cleanupFn"),x.appendChild(ge),y+1}finally{z&&(window._highlightCleanupFunctions=window._highlightCleanupFunctions||[]).push(z)}}a(v,"highlightElement");function k(u){if(!u||u.nodeType!==Node.ELEMENT_NODE)return null;const y=T(u);if(!y)return null;const P=y.display;if(P==="inline"||P==="inline-block")return null;const w=y.overflowX,E=y.overflowY,N=w==="auto"||w==="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,ze=u.scrollWidth-u.clientWidth-u.scrollLeft,ee=u.scrollHeight-u.clientHeight-u.scrollTop,re={top:K,right:ze,bottom:ee,left:J};return f(u,{scrollable:!0,scrollData:re}),re}a(k,"isScrollableElement");function O(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 P=y.getClientRects();if(!P||P.length===0)return!1;let w=!1,E=!1;for(const $ of P)if($.width>0&&$.height>0&&(w=!0,!($.bottom<-c||$.top>window.innerHeight+c||$.right<-c||$.left>window.innerWidth+c))){E=!0;break}if(!w||!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(O,"isTextNodeVisible");function Ie(u){if(!u||!u.tagName)return!1;const y=new Set(["body","div","main","article","section","nav","header","footer"]),P=u.tagName.toLowerCase();return y.has(P)?!0:!new Set(["svg","script","style","link","meta","noscript","template"]).has(P)}a(Ie,"isElementAccepted");function H(u){const y=T(u);return u.offsetWidth>0&&u.offsetHeight>0&&y?.visibility!=="hidden"&&y?.display!=="none"}a(H,"isElementVisible");function le(u){if(!u||u.nodeType!==Node.ELEMENT_NODE||t.includes(u))return!1;if(o.includes(u))return!0;const y=u.tagName.toLowerCase(),P=T(u),w=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(ee){return ee.tagName.toLowerCase()==="html"?!1:!!(P?.cursor&&w.has(P.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(P?.cursor&&E.has(P.cursor))return!1;for(const ee of x)if(u.hasAttribute(ee)||u.getAttribute(ee)==="true"||u.getAttribute(ee)==="")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 Le of me)if(ge[Le]&&ge[Le].length>0)return!0}const ee=u?.ownerDocument?.defaultView?.getEventListenersForNode||window.getEventListenersForNode;if(typeof ee=="function"){const ge=ee(u),me=["click","mousedown","mouseup","keydown","keyup","submit","change","input","focus","blur"];for(const Le of me)for(const et of ge)if(et.type===Le)return!0}const re=["onclick","onmousedown","onmouseup","ondblclick"];for(const ge of re)if(u.hasAttribute(ge)||typeof u[ge]=="function")return!0}catch{}return!!k(u)}a(le,"isInteractiveElement");function ue(u){if(c===-1)return!0;const y=I(u);if(!y||y.length===0)return!1;let P=!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)){P=!0;break}if(!P)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 q(u,y){if(y===-1)return!0;const P=u.getClientRects();if(!P||P.length===0){const w=m(u);return!w||w.width===0||w.height===0?!1:!(w.bottom<-y||w.top>window.innerHeight+y||w.right<-y||w.left>window.innerWidth+y)}for(const w of P)if(!(w.width===0||w.height===0)&&!(w.bottom<-y||w.top>window.innerHeight+y||w.right<-y||w.left>window.innerWidth+y))return!0;return!1}a(q,"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"]),Ke=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||!H(u))return!1;const y=u.hasAttribute("role")||u.hasAttribute("tabindex")||u.hasAttribute("onclick")||typeof u.onclick=="function",P=/\b(btn|clickable|menu|item|entry|link)\b/i.test(u.className||""),w=!!u.closest('button,a,[role="button"],.menu,.dropdown,.list,.toolbar'),E=[...u.children].some(H),N=u.parentElement&&u.parentElement.isSameNode(document.body);return(le(u)||y||P)&&E&&w&&!N}a(he,"isHeuristicallyInteractive");function Xe(u){if(!u||u.nodeType!==Node.ELEMENT_NODE)return!1;const y=u.tagName.toLowerCase(),P=u.getAttribute("role");if(y==="iframe"||pe.has(y)||P&&Ke.has(P)||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 w=u?.ownerDocument?.defaultView?.getEventListenersForNode||window.getEventListenersForNode;if(typeof w=="function"){const N=w(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(Xe,"isElementDistinctInteraction");function Qe(u,y,P,w){if(!u.isInteractive)return!1;let E=!1;return w?Xe(y)?E=!0:E=!1:E=!0,E&&(u.isInViewport=q(y,c),(u.isInViewport||c===-1)&&(u.highlightIndex=d++,i))?(s>=0?s===u.highlightIndex&&v(y,u.highlightIndex,P):v(y,u.highlightIndex,P),!0):!1}a(Qe,"handleHighlighting");function _e(u,y=null,P=!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.dataset?.pageAgentIgnore==="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=`${C.current++}`;return A[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=`${C.current++}`;return A[x]={type:"TEXT_NODE",text:$,isVisible:O(u)},x}if(u.nodeType===Node.ELEMENT_NODE&&!Ie(u))return null;if(c!==-1&&!u.shadowRoot){const $=m(u),z=T(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 w={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);w.attributes[z]=x}u.tagName.toLowerCase()==="input"&&(u.type==="checkbox"||u.type==="radio")&&(w.attributes.checked=u.checked?"true":"false")}let E=!1;if(u.nodeType===Node.ELEMENT_NODE&&(w.isVisible=H(u),w.isVisible)){w.isTopElement=ue(u);const $=u.getAttribute("role"),z=$==="menu"||$==="menubar"||$==="listbox";(w.isTopElement||z)&&(w.isInteractive=le(u),E=Qe(w,u,y,P),w.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&&w.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&&w.children.push(x)}else{if(u.shadowRoot){w.shadowRoot=!0;for(const z of u.shadowRoot.childNodes){const x=_e(z,y,E);x&&w.children.push(x)}}for(const z of u.childNodes){const F=_e(z,y,E||P);F&&w.children.push(F)}}}if(w.tagName==="a"&&w.children.length===0&&!w.attributes.href){const $=m(u);if(!($&&$.width>0&&$.height>0||u.offsetWidth>0||u.offsetHeight>0))return null}w.extra=h.get(u)||null;const N=`${C.current++}`;return A[N]=w,N}a(_e,"buildDomTree");const fe=_e(document.body);return g.clearCache(),{rootId:fe,map:A}},"domTree"),DEFAULT_VIEWPORT_EXPANSION=-1;function resolveViewportExpansion(e){return e??DEFAULT_VIEWPORT_EXPANSION}a(resolveViewportExpansion,"resolveViewportExpansion");const newElementsCache=new WeakMap;function getFlatTree(e){const t=resolveViewportExpansion(e.viewportExpansion),o=[];for(const s of e.interactiveBlacklist||[])typeof s=="function"?o.push(s()):o.push(s);const n=[];for(const s of e.interactiveWhitelist||[])typeof s=="function"?n.push(s()):n.push(s);const r=domTree({doHighlightElements:!0,debugMode:!0,focusHighlightIndex:-1,viewportExpansion:t,interactiveBlacklist:o,interactiveWhitelist:n,highlightOpacity:e.highlightOpacity??0,highlightLabelOpacity:e.highlightLabelOpacity??.1}),i=window.location.href;for(const s in r.map){const c=r.map[s];if(c.isInteractive&&c.ref){const l=c.ref;newElementsCache.has(l)||(newElementsCache.set(l,i),c.isNew=!0)}}return r}a(getFlatTree,"getFlatTree");const globRegexCache=new Map;function globToRegex(e){let t=globRegexCache.get(e);if(!t){const o=e.replace(/[.+^${}()|[\]\\]/g,"\\$&");t=new RegExp(`^${o.replace(/\*/g,".*")}$`),globRegexCache.set(e,t)}return t}a(globToRegex,"globToRegex");function matchAttributes(e,t){const o={};for(const n of t)if(n.includes("*")){const r=globToRegex(n);for(const i of Object.keys(e))r.test(i)&&e[i].trim()&&(o[i]=e[i].trim())}else{const r=e[n];r&&r.trim()&&(o[n]=r.trim())}return o}a(matchAttributes,"matchAttributes");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","contenteditable"],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,T=[];if(m.children)for(const I of m.children){const A=i(I);A&&(A.parent=null,T.push(A))}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:T,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 T=g;const I=" ".repeat(g);if(f.type==="element"){if(f.highlightIndex!==void 0){T+=1;const A=getAllTextTillNextClickableElement(f);let C="";if(n.length>0&&f.attributes){const k=matchAttributes(f.attributes,n),O=Object.keys(k);if(O.length>1){const H=new Set,le={};for(const ue of O){const q=k[ue];q.length>5&&(q in le?H.add(ue):le[q]=ue)}for(const ue of H)delete k[ue]}k.role===f.tagName&&delete k.role;const Ie=["aria-label","placeholder","title"];for(const H of Ie)k[H]&&k[H].toLowerCase().trim()===A.toLowerCase().trim()&&delete k[H];Object.keys(k).length>0&&(C=Object.entries(k).map(([H,le])=>`${H}=${r(le,20)}`).join(" "))}const D=f.isNew?`*[${f.highlightIndex}]`:`[${f.highlightIndex}]`;let v=`${I}${D}<${f.tagName??""}`;if(C&&(v+=` ${C}`),f.extra&&f.extra.scrollable){let k="";f.extra.scrollData?.left&&(k+=`left=${f.extra.scrollData.left}, `),f.extra.scrollData?.top&&(k+=`top=${f.extra.scrollData.top}, `),f.extra.scrollData?.right&&(k+=`right=${f.extra.scrollData.right}, `),f.extra.scrollData?.bottom&&(k+=`bottom=${f.extra.scrollData.bottom}`),v+=` data-scrollable="${k}"`}if(A){const k=A.trim();C||(v+=" "),v+=`>${k}`}else C||(v+=" ");v+=" />",m.push(v)}for(const A of f.children)d(A,T,m)}else if(f.type==="text"){if(l(f))return;f.parent&&f.parent.type==="element"&&f.parent.isVisible&&f.parent.isTopElement&&m.push(`${I}${f.text??""}`)}},"processNode"),h=[];return d(c,0,h),h.join(`
239
+ `,n},"#assembleUserPrompt"),st=a(function(o=!0){this.pageController.cleanUpHighlights(),this.pageController.hideMask(),b(this,R,_t).call(this,o?"completed":"error"),p(this,se).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(.2)}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){const o=e.isContentEditable;if(!(e instanceof HTMLInputElement)&&!(e instanceof HTMLTextAreaElement)&&!o)throw new Error("Element is not an input, textarea, or contenteditable");await clickElement(e),o?(e.dispatchEvent(new InputEvent("beforeinput",{bubbles:!0,cancelable:!0,inputType:"deleteContent"}))&&(e.innerText="",e.dispatchEvent(new InputEvent("input",{bubbles:!0,inputType:"deleteContent"}))),e.dispatchEvent(new InputEvent("beforeinput",{bubbles:!0,cancelable:!0,inputType:"insertText",data:t}))&&(e.innerText=t,e.dispatchEvent(new InputEvent("input",{bubbles:!0,inputType:"insertText",data:t}))),e.dispatchEvent(new Event("change",{bubbles:!0})),e.blur()):e instanceof HTMLTextAreaElement?nativeTextAreaValueSetter.call(e,t):nativeInputValueSetter.call(e,t),o||e.dispatchEvent(new Event("input",{bubbles:!0})),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;typeof t.scrollIntoViewIfNeeded=="function"?t.scrollIntoViewIfNeeded():e.scrollIntoView({behavior:"auto",block:"center",inline:"nearest"})}a(scrollIntoViewIfNeeded,"scrollIntoViewIfNeeded");async function scrollVertically(e,t,o){if(o){const c=o;let l=c,d=!1,h=null,f=0,g=0;const m=t;for(;l&&g<10;){const T=window.getComputedStyle(l),I=/(auto|scroll|overlay)/.test(T.overflowY),A=l.scrollHeight>l.clientHeight;if(I&&A){const C=l.scrollTop,D=l.scrollHeight-l.clientHeight;let v=m/3;v>0?v=Math.min(v,D-C):v=Math.max(v,-C),l.scrollTop=C+v;const O=l.scrollTop-C;if(Math.abs(O)>.5){d=!0,h=l,f=O;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;let l=c,d=!1,h=null,f=0,g=0;const m=e?t:-t;for(;l&&g<10;){const T=window.getComputedStyle(l),I=/(auto|scroll|overlay)/.test(T.overflowX),A=l.scrollWidth>l.clientWidth;if(I&&A){const C=l.scrollLeft,D=l.scrollWidth-l.clientWidth;let v=m/3;v>0?v=Math.min(v,D-C):v=Math.max(v,-C),l.scrollLeft=C+v;const O=l.scrollLeft-C;if(Math.abs(O)>.5){d=!0,h=l,f=O;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 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 T(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(T,"getCachedComputedStyle");function I(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(I,"getCachedClientRects");const A={},C={current:0},D="playwright-highlight-container";function v(u,y,P=null){if(!u)return y;const w=[];let E=null,N=20,x=16,z=null;try{let $=document.getElementById(D);$||($=document.createElement("div"),$.id=D,$.style.position="fixed",$.style.pointerEvents="none",$.style.top="0",$.style.left="0",$.style.width="100%",$.style.height="100%",$.style.zIndex="2147483640",$.style.backgroundColor="transparent",document.body.appendChild($));const L=u.getClientRects();if(!L||L.length===0)return y;const Y=["#FF0000","#00FF00","#0000FF","#FFA500","#800080","#008080","#FF69B4","#4B0082","#FF4500","#2E8B57","#DC143C","#4682B4"],J=y%Y.length;let ze=Y[J];const ee=ze+Math.floor(n*255).toString(16).padStart(2,"0");ze=ze+Math.floor(r*255).toString(16).padStart(2,"0");let re={x:0,y:0};if(P){const V=P.getBoundingClientRect();re.x=V.left,re.y=V.top}const ge=document.createDocumentFragment();for(const V of L){if(V.width===0||V.height===0)continue;const G=document.createElement("div");G.style.position="fixed",G.style.border=`2px solid ${ze}`,G.style.backgroundColor=ee,G.style.pointerEvents="none",G.style.boxSizing="border-box";const U=V.top+re.y,ke=V.left+re.x;G.style.top=`${U}px`,G.style.left=`${ke}px`,G.style.width=`${V.width}px`,G.style.height=`${V.height}px`,ge.appendChild(G),w.push({element:G,initialRect:V})}const me=L[0];E=document.createElement("div"),E.className="playwright-highlight-label",E.style.position="fixed",E.style.background=ze,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,x=E.offsetHeight>0?E.offsetHeight:x;const Le=me.top+re.y,et=me.left+re.x;let nt=Le+2,We=et+me.width-N-2;(me.width<N+4||me.height<x+4)&&(nt=Le-x-2,We=et+me.width-N,We<re.x&&(We=et)),nt=Math.max(0,Math.min(nt,window.innerHeight-x)),We=Math.max(0,Math.min(We,window.innerWidth-N)),E.style.top=`${nt}px`,E.style.left=`${We}px`,ge.appendChild(E);const rt=a((V,G)=>{let U=0;return(...ke)=>{const te=performance.now();if(!(te-U<G))return U=te,V(...ke)}},"throttleFunction")(a(()=>{const V=u.getClientRects();let G={x:0,y:0};if(P){const U=P.getBoundingClientRect();G.x=U.left,G.y=U.top}if(w.forEach((U,ke)=>{if(ke<V.length){const te=V[ke],Ve=te.top+G.y,Ae=te.left+G.x;U.element.style.top=`${Ve}px`,U.element.style.left=`${Ae}px`,U.element.style.width=`${te.width}px`,U.element.style.height=`${te.height}px`,U.element.style.display=te.width===0||te.height===0?"none":"block"}else U.element.style.display="none"}),V.length<w.length)for(let U=V.length;U<w.length;U++)w[U].element.style.display="none";if(E&&V.length>0){const U=V[0],ke=U.top+G.y,te=U.left+G.x;let Ve=ke+2,Ae=te+U.width-N-2;(U.width<N+4||U.height<x+4)&&(Ve=ke-x-2,Ae=te+U.width-N,Ae<G.x&&(Ae=te)),Ve=Math.max(0,Math.min(Ve,window.innerHeight-x)),Ae=Math.max(0,Math.min(Ae,window.innerWidth-N)),E.style.top=`${Ve}px`,E.style.left=`${Ae}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),w.forEach(V=>V.element.remove()),E&&E.remove()},"cleanupFn"),$.appendChild(ge),y+1}finally{z&&(window._highlightCleanupFunctions=window._highlightCleanupFunctions||[]).push(z)}}a(v,"highlightElement");function k(u){if(!u||u.nodeType!==Node.ELEMENT_NODE)return null;const y=T(u);if(!y)return null;const P=y.display;if(P==="inline"||P==="inline-block")return null;const w=y.overflowX,E=y.overflowY,N=w==="auto"||w==="scroll",x=E==="auto"||E==="scroll";if(!N&&!x)return null;const z=u.scrollWidth-u.clientWidth,$=u.scrollHeight-u.clientHeight,L=4;if(z<L&&$<L||!x&&z<L||!N&&$<L)return null;const Y=u.scrollTop,J=u.scrollLeft,ze=u.scrollWidth-u.clientWidth-u.scrollLeft,ee=u.scrollHeight-u.clientHeight-u.scrollTop,re={top:Y,right:ze,bottom:ee,left:J};return f(u,{scrollable:!0,scrollData:re}),re}a(k,"isScrollableElement");function O(u){try{if(c===-1){const x=u.parentElement;if(!x)return!1;try{return x.checkVisibility({checkOpacity:!0,checkVisibilityCSS:!0})}catch{const $=window.getComputedStyle(x);return $.display!=="none"&&$.visibility!=="hidden"&&$.opacity!=="0"}}const y=document.createRange();y.selectNodeContents(u);const P=y.getClientRects();if(!P||P.length===0)return!1;let w=!1,E=!1;for(const x of P)if(x.width>0&&x.height>0&&(w=!0,!(x.bottom<-c||x.top>window.innerHeight+c||x.right<-c||x.left>window.innerWidth+c))){E=!0;break}if(!w||!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(O,"isTextNodeVisible");function Ie(u){if(!u||!u.tagName)return!1;const y=new Set(["body","div","main","article","section","nav","header","footer"]),P=u.tagName.toLowerCase();return y.has(P)?!0:!new Set(["svg","script","style","link","meta","noscript","template"]).has(P)}a(Ie,"isElementAccepted");function H(u){const y=T(u);return u.offsetWidth>0&&u.offsetHeight>0&&y?.visibility!=="hidden"&&y?.display!=="none"}a(H,"isElementVisible");function le(u){if(!u||u.nodeType!==Node.ELEMENT_NODE||t.includes(u))return!1;if(o.includes(u))return!0;const y=u.tagName.toLowerCase(),P=T(u),w=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(ee){return ee.tagName.toLowerCase()==="html"?!1:!!(P?.cursor&&w.has(P.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"]),$=new Set(["disabled","readonly"]);if(z.has(y)){if(P?.cursor&&E.has(P.cursor))return!1;for(const ee of $)if(u.hasAttribute(ee)||u.getAttribute(ee)==="true"||u.getAttribute(ee)==="")return!1;return!(u.disabled||u.readOnly||u.inert)}const L=u.getAttribute("role"),Y=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)||L&&J.has(L)||Y&&J.has(Y))return!0;try{if(typeof getEventListeners=="function"){const ge=getEventListeners(u),me=["click","mousedown","mouseup","dblclick"];for(const Le of me)if(ge[Le]&&ge[Le].length>0)return!0}const ee=u?.ownerDocument?.defaultView?.getEventListenersForNode||window.getEventListenersForNode;if(typeof ee=="function"){const ge=ee(u),me=["click","mousedown","mouseup","keydown","keyup","submit","change","input","focus","blur"];for(const Le of me)for(const et of ge)if(et.type===Le)return!0}const re=["onclick","onmousedown","onmouseup","ondblclick"];for(const ge of re)if(u.hasAttribute(ge)||typeof u[ge]=="function")return!0}catch{}return!!k(u)}a(le,"isInteractiveElement");function ue(u){if(c===-1)return!0;const y=I(u);if(!y||y.length===0)return!1;let P=!1;for(const $ of y)if($.width>0&&$.height>0&&!($.bottom<-c||$.top>window.innerHeight+c||$.right<-c||$.left>window.innerWidth+c)){P=!0;break}if(!P)return!1;if(u.ownerDocument!==window.document)return!0;let E=Array.from(y).find($=>$.width>0&&$.height>0);if(!E)return!1;const N=u.getRootNode();if(N instanceof ShadowRoot){const $=E.left+E.width/2,L=E.top+E.height/2;try{const Y=N.elementFromPoint($,L);if(!Y)return!1;let J=Y;for(;J&&J!==N;){if(J===u)return!0;J=J.parentElement}return!1}catch{return!0}}const x=5;return[{x:E.left+E.width/2,y:E.top+E.height/2},{x:E.left+x,y:E.top+x},{x:E.right-x,y:E.bottom-x}].some(({x:$,y:L})=>{try{const Y=document.elementFromPoint($,L);if(!Y)return!1;let J=Y;for(;J&&J!==document.documentElement;){if(J===u)return!0;J=J.parentElement}return!1}catch{return!0}})}a(ue,"isTopElement");function K(u,y){if(y===-1)return!0;const P=u.getClientRects();if(!P||P.length===0){const w=m(u);return!w||w.width===0||w.height===0?!1:!(w.bottom<-y||w.top>window.innerHeight+y||w.right<-y||w.left>window.innerWidth+y)}for(const w of P)if(!(w.width===0||w.height===0)&&!(w.bottom<-y||w.top>window.innerHeight+y||w.right<-y||w.left>window.innerWidth+y))return!0;return!1}a(K,"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"]),Ke=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||!H(u))return!1;const y=u.hasAttribute("role")||u.hasAttribute("tabindex")||u.hasAttribute("onclick")||typeof u.onclick=="function",P=/\b(btn|clickable|menu|item|entry|link)\b/i.test(u.className||""),w=!!u.closest('button,a,[role="button"],.menu,.dropdown,.list,.toolbar'),E=[...u.children].some(H),N=u.parentElement&&u.parentElement.isSameNode(document.body);return(le(u)||y||P)&&E&&w&&!N}a(he,"isHeuristicallyInteractive");function Xe(u){if(!u||u.nodeType!==Node.ELEMENT_NODE)return!1;const y=u.tagName.toLowerCase(),P=u.getAttribute("role");if(y==="iframe"||pe.has(y)||P&&Ke.has(P)||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 w=u?.ownerDocument?.defaultView?.getEventListenersForNode||window.getEventListenersForNode;if(typeof w=="function"){const N=w(u),x=["click","mousedown","mouseup","keydown","keyup","submit","change","input","focus","blur"];for(const z of x)for(const $ of N)if($.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(Xe,"isElementDistinctInteraction");function Qe(u,y,P,w){if(!u.isInteractive)return!1;let E=!1;return w?Xe(y)?E=!0:E=!1:E=!0,E&&(u.isInViewport=K(y,c),(u.isInViewport||c===-1)&&(u.highlightIndex=d++,i))?(s>=0?s===u.highlightIndex&&v(y,u.highlightIndex,P):v(y,u.highlightIndex,P),!0):!1}a(Qe,"handleHighlighting");function _e(u,y=null,P=!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.dataset?.pageAgentIgnore==="true"||u.getAttribute&&u.getAttribute("aria-hidden")==="true")return null;if(u===document.body){const x={tagName:"body",attributes:{},xpath:"/body",children:[]};for(const $ of u.childNodes){const L=_e($,y,!1);L&&x.children.push(L)}const z=`${C.current++}`;return A[z]=x,z}if(u.nodeType!==Node.ELEMENT_NODE&&u.nodeType!==Node.TEXT_NODE)return null;if(u.nodeType===Node.TEXT_NODE){const x=u.textContent?.trim();if(!x)return null;const z=u.parentElement;if(!z||z.tagName.toLowerCase()==="script")return null;const $=`${C.current++}`;return A[$]={type:"TEXT_NODE",text:x,isVisible:O(u)},$}if(u.nodeType===Node.ELEMENT_NODE&&!Ie(u))return null;if(c!==-1&&!u.shadowRoot){const x=m(u),z=T(u),$=z&&(z.position==="fixed"||z.position==="sticky"),L=u.offsetWidth>0||u.offsetHeight>0;if(!x||!$&&!L&&(x.bottom<-c||x.top>window.innerHeight+c||x.right<-c||x.left>window.innerWidth+c))return null}const w={tagName:u.tagName.toLowerCase(),attributes:{},children:[]};if(de(u)||u.tagName.toLowerCase()==="iframe"||u.tagName.toLowerCase()==="body"){const x=u.getAttributeNames?.()||[];for(const z of x){const $=u.getAttribute(z);w.attributes[z]=$}u.tagName.toLowerCase()==="input"&&(u.type==="checkbox"||u.type==="radio")&&(w.attributes.checked=u.checked?"true":"false")}let E=!1;if(u.nodeType===Node.ELEMENT_NODE&&(w.isVisible=H(u),w.isVisible)){w.isTopElement=ue(u);const x=u.getAttribute("role"),z=x==="menu"||x==="menubar"||x==="listbox";if((w.isTopElement||z)&&(w.isInteractive=le(u),E=Qe(w,u,y,P),w.ref=u,w.isInteractive&&Object.keys(w.attributes).length===0)){const $=u.getAttributeNames?.()||[];for(const L of $){const Y=u.getAttribute(L);w.attributes[L]=Y}}}if(u.tagName){const x=u.tagName.toLowerCase();if(x==="iframe")try{const z=u.contentDocument||u.contentWindow?.document;if(z)for(const $ of z.childNodes){const L=_e($,u,!1);L&&w.children.push(L)}}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")||x==="body"&&u.getAttribute("data-id")?.startsWith("mce_"))for(const z of u.childNodes){const $=_e(z,y,E);$&&w.children.push($)}else{if(u.shadowRoot){w.shadowRoot=!0;for(const z of u.shadowRoot.childNodes){const $=_e(z,y,E);$&&w.children.push($)}}for(const z of u.childNodes){const L=_e(z,y,E||P);L&&w.children.push(L)}}}if(w.tagName==="a"&&w.children.length===0&&!w.attributes.href){const x=m(u);if(!(x&&x.width>0&&x.height>0||u.offsetWidth>0||u.offsetHeight>0))return null}w.extra=h.get(u)||null;const N=`${C.current++}`;return A[N]=w,N}a(_e,"buildDomTree");const fe=_e(document.body);return g.clearCache(),{rootId:fe,map:A}},"domTree"),DEFAULT_VIEWPORT_EXPANSION=-1;function resolveViewportExpansion(e){return e??DEFAULT_VIEWPORT_EXPANSION}a(resolveViewportExpansion,"resolveViewportExpansion");const newElementsCache=new WeakMap;function getFlatTree(e){const t=resolveViewportExpansion(e.viewportExpansion),o=[];for(const s of e.interactiveBlacklist||[])typeof s=="function"?o.push(s()):o.push(s);const n=[];for(const s of e.interactiveWhitelist||[])typeof s=="function"?n.push(s()):n.push(s);const r=domTree({doHighlightElements:!0,debugMode:!0,focusHighlightIndex:-1,viewportExpansion:t,interactiveBlacklist:o,interactiveWhitelist:n,highlightOpacity:e.highlightOpacity??0,highlightLabelOpacity:e.highlightLabelOpacity??.1}),i=window.location.href;for(const s in r.map){const c=r.map[s];if(c.isInteractive&&c.ref){const l=c.ref;newElementsCache.has(l)||(newElementsCache.set(l,i),c.isNew=!0)}}return r}a(getFlatTree,"getFlatTree");const globRegexCache=new Map;function globToRegex(e){let t=globRegexCache.get(e);if(!t){const o=e.replace(/[.+^${}()|[\]\\]/g,"\\$&");t=new RegExp(`^${o.replace(/\*/g,".*")}$`),globRegexCache.set(e,t)}return t}a(globToRegex,"globToRegex");function matchAttributes(e,t){const o={};for(const n of t)if(n.includes("*")){const r=globToRegex(n);for(const i of Object.keys(e))r.test(i)&&e[i].trim()&&(o[i]=e[i].trim())}else{const r=e[n];r&&r.trim()&&(o[n]=r.trim())}return o}a(matchAttributes,"matchAttributes");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","contenteditable"],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,T=[];if(m.children)for(const I of m.children){const A=i(I);A&&(A.parent=null,T.push(A))}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:T,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 T=g;const I=" ".repeat(g);if(f.type==="element"){if(f.highlightIndex!==void 0){T+=1;const A=getAllTextTillNextClickableElement(f);let C="";if(n.length>0&&f.attributes){const k=matchAttributes(f.attributes,n),O=Object.keys(k);if(O.length>1){const H=new Set,le={};for(const ue of O){const K=k[ue];K.length>5&&(K in le?H.add(ue):le[K]=ue)}for(const ue of H)delete k[ue]}k.role===f.tagName&&delete k.role;const Ie=["aria-label","placeholder","title"];for(const H of Ie)k[H]&&k[H].toLowerCase().trim()===A.toLowerCase().trim()&&delete k[H];Object.keys(k).length>0&&(C=Object.entries(k).map(([H,le])=>`${H}=${r(le,20)}`).join(" "))}const D=f.isNew?`*[${f.highlightIndex}]`:`[${f.highlightIndex}]`;let v=`${I}${D}<${f.tagName??""}`;if(C&&(v+=` ${C}`),f.extra&&f.extra.scrollable){let k="";f.extra.scrollData?.left&&(k+=`left=${f.extra.scrollData.left}, `),f.extra.scrollData?.top&&(k+=`top=${f.extra.scrollData.top}, `),f.extra.scrollData?.right&&(k+=`right=${f.extra.scrollData.right}, `),f.extra.scrollData?.bottom&&(k+=`bottom=${f.extra.scrollData.bottom}`),v+=` data-scrollable="${k}"`}if(A){const k=A.trim();C||(v+=" "),v+=`>${k}`}else C||(v+=" ");v+=" />",m.push(v)}for(const A of f.children)d(A,T,m)}else if(f.type==="text"){if(l(f))return;f.parent&&f.parent.type==="element"&&f.parent.isVisible&&f.parent.isTopElement&&m.push(`${I}${f.text??""}`)}},"processNode"),h=[];return d(c,0,h),h.join(`
240
240
  `)}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(`
241
241
  `).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(`
242
242
  `).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=resolveViewportExpansion(this.config.viewportExpansion);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}
@@ -287,7 +287,7 @@ ${d}`,g=o.pixels_below>4&&n!==-1?`... ${o.pixels_below} pixels below (${o.pages_
287
287
  />
288
288
  </div>
289
289
  </div>
290
- `,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,Ce).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,Re).addEventListener("click",o=>{o.stopPropagation()})},"#setupEventListeners"),wt=a(function(){p(this,$e)?b(this,_,it).call(this):b(this,_,ot).call(this)},"#toggle"),ot=a(function(){S(this,$e,!0),this.wrapper.classList.add(styles$1.expanded),p(this,Ce).textContent="β–²"},"#expand"),it=a(function(){S(this,$e,!1),this.wrapper.classList.remove(styles$1.expanded),p(this,Ce).textContent="β–Ό"},"#collapse"),jt=a(function(){S(this,Ze,setInterval(()=>{b(this,_,Wt).call(this)},450))},"#startHeaderUpdateLoop"),Bt=a(function(){p(this,Ze)&&(clearInterval(p(this,Ze)),S(this,Ze,null))},"#stopHeaderUpdateLoop"),Wt=a(function(){if(!p(this,Q)||p(this,Be))return;if(p(this,ie).textContent===p(this,Q)){S(this,Q,null);return}const t=p(this,Q);S(this,Q,null),b(this,_,Vt).call(this,t)},"#checkAndUpdateHeader"),Vt=a(function(t){S(this,Be,!0),p(this,ie).classList.add(styles$1.fadeOut),setTimeout(()=>{p(this,ie).textContent=t,p(this,ie).classList.remove(styles$1.fadeOut),p(this,ie).classList.add(styles$1.fadeIn),setTimeout(()=>{p(this,ie).classList.remove(styles$1.fadeIn),S(this,Be,!1)},300)},150)},"#animateTextChange"),Fe=a(function(t){p(this,je).className=styles$1.indicator,p(this,je).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,B).task;o&&t.push(b(this,_,Gt).call(this,o));const n=p(this,B).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=t.type==="step"&&t.stepIndex!==void 0?p(this,j).t("ui.panel.step",{number:(t.stepIndex+1).toString()}):void 0;if(t.type==="step"){if(t.reflection){const i=createReflectionLines(t.reflection);i.length>0&&o.push(createCard({icon:"🧠",content:i,meta:n}))}const r=t.action;r&&o.push(...b(this,_,Jt).call(this,r,n))}else if(t.type==="observation")o.push(createCard({icon:"πŸ‘οΈ",content:t.content||"",meta:n,type:"observation"}));else if(t.type==="user_takeover")o.push(createCard({icon:"πŸ‘€",content:"User takeover",meta:n,type:"input"}));else if(t.type==="retry"){const r=`${t.message||"Retrying"} (${t.attempt}/${t.maxAttempts})`;o.push(createCard({icon:"πŸ”„",content:r,meta:n,type:"observation"}))}else t.type==="error"&&o.push(createCard({icon:"❌",content:t.message||"Error",meta:n,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(w=>w/e*2-1,"toClipX"),f=a(w=>w/t*2-1,"toClipY"),g=0,m=e,T=0,I=t,A=l,C=e-l,D=d,v=t-d,k=h(g),O=h(m),Ie=f(T),H=f(I),le=h(A),ue=h(C),q=f(D),de=f(v),pe=0,Ke=0,he=1,Xe=1,Qe=l/e,_e=1-l/e,fe=d/t,u=1-d/t,y=new Float32Array([k,Ie,O,Ie,k,q,k,q,O,Ie,O,q,k,de,O,de,k,H,k,H,O,de,O,H,k,q,le,q,k,de,k,de,le,q,le,de,ue,q,O,q,ue,de,ue,de,O,q,O,de]),P=new Float32Array([pe,Ke,he,Ke,pe,fe,pe,fe,he,Ke,he,fe,pe,u,he,u,pe,Xe,pe,Xe,he,u,he,Xe,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:P}}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
290
+ `,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,Ce).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,Re).addEventListener("click",o=>{o.stopPropagation()})},"#setupEventListeners"),wt=a(function(){p(this,$e)?b(this,_,it).call(this):b(this,_,ot).call(this)},"#toggle"),ot=a(function(){S(this,$e,!0),this.wrapper.classList.add(styles$1.expanded),p(this,Ce).textContent="β–²"},"#expand"),it=a(function(){S(this,$e,!1),this.wrapper.classList.remove(styles$1.expanded),p(this,Ce).textContent="β–Ό"},"#collapse"),jt=a(function(){S(this,Ze,setInterval(()=>{b(this,_,Wt).call(this)},450))},"#startHeaderUpdateLoop"),Bt=a(function(){p(this,Ze)&&(clearInterval(p(this,Ze)),S(this,Ze,null))},"#stopHeaderUpdateLoop"),Wt=a(function(){if(!p(this,Q)||p(this,Be))return;if(p(this,ie).textContent===p(this,Q)){S(this,Q,null);return}const t=p(this,Q);S(this,Q,null),b(this,_,Vt).call(this,t)},"#checkAndUpdateHeader"),Vt=a(function(t){S(this,Be,!0),p(this,ie).classList.add(styles$1.fadeOut),setTimeout(()=>{p(this,ie).textContent=t,p(this,ie).classList.remove(styles$1.fadeOut),p(this,ie).classList.add(styles$1.fadeIn),setTimeout(()=>{p(this,ie).classList.remove(styles$1.fadeIn),S(this,Be,!1)},300)},150)},"#animateTextChange"),Fe=a(function(t){p(this,je).className=styles$1.indicator,p(this,je).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,B).task;o&&t.push(b(this,_,Gt).call(this,o));const n=p(this,B).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=t.type==="step"&&t.stepIndex!==void 0?p(this,j).t("ui.panel.step",{number:(t.stepIndex+1).toString()}):void 0;if(t.type==="step"){if(t.reflection){const i=createReflectionLines(t.reflection);i.length>0&&o.push(createCard({icon:"🧠",content:i,meta:n}))}const r=t.action;r&&o.push(...b(this,_,Jt).call(this,r,n))}else if(t.type==="observation")o.push(createCard({icon:"πŸ‘οΈ",content:t.content||"",meta:n,type:"observation"}));else if(t.type==="user_takeover")o.push(createCard({icon:"πŸ‘€",content:"User takeover",meta:n,type:"input"}));else if(t.type==="retry"){const r=`${t.message||"Retrying"} (${t.attempt}/${t.maxAttempts})`;o.push(createCard({icon:"πŸ”„",content:r,meta:n,type:"observation"}))}else t.type==="error"&&o.push(createCard({icon:"❌",content:t.message||"Error",meta:n,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(w=>w/e*2-1,"toClipX"),f=a(w=>w/t*2-1,"toClipY"),g=0,m=e,T=0,I=t,A=l,C=e-l,D=d,v=t-d,k=h(g),O=h(m),Ie=f(T),H=f(I),le=h(A),ue=h(C),K=f(D),de=f(v),pe=0,Ke=0,he=1,Xe=1,Qe=l/e,_e=1-l/e,fe=d/t,u=1-d/t,y=new Float32Array([k,Ie,O,Ie,k,K,k,K,O,Ie,O,K,k,de,O,de,k,H,k,H,O,de,O,H,k,K,le,K,k,de,k,de,le,K,le,de,ue,K,O,K,ue,de,ue,de,O,K,O,de]),P=new Float32Array([pe,Ke,he,Ke,pe,fe,pe,fe,he,Ke,he,fe,pe,u,he,u,pe,Xe,pe,Xe,he,u,he,Xe,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:P}}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
291
291
  precision lowp float;
292
292
  in vec2 vUV;
293
293
  out vec4 outColor;
@@ -397,4 +397,4 @@ out vec2 vUV;
397
397
  void main() {
398
398
  vUV = aUV;
399
399
  gl_Position = vec4(aPosition, 0.0, 1.0);
400
- }`;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:T}=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 I=r.getAttribLocation(i,"aPosition");r.enableVertexAttribArray(I),r.vertexAttribPointer(I,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,T,r.STATIC_DRAW);const A=r.getAttribLocation(i,"aUV");r.enableVertexAttribArray(A),r.vertexAttribPointer(A,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 C=performance.now();this.lastTime=C;const D=(C-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"),T=t.getUniformLocation(o,"uBorderWidth"),I=t.getUniformLocation(o,"uGlowWidth"),A=t.getUniformLocation(o,"uBorderRadius"),C=t.getUniformLocation(o,"uColors"),D=t.getUniformLocation(o,"uGlowExponent"),v=t.getUniformLocation(o,"uGlowFactor");t.useProgram(o),t.uniform1f(T,this.options.borderWidth),t.uniform1f(I,this.options.glowWidth),t.uniform1f(A,this.options.borderRadius),this.options.mode==="dark"?(t.uniform1f(D,2),t.uniform1f(v,1.8)):(t.uniform1f(D,1),t.uniform1f(v,1));const k=(this.options.colors||DEFAULT_COLORS).map(parseColor);for(let O=0;O<k.length;O++)t.uniform3f(t.getUniformLocation(o,`uColors[${O}]`),...k[O]);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:T,uGlowWidth:I,uBorderRadius:A,uColors:C}}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,Ne);oe(this,"shown",!1);oe(this,"wrapper",document.createElement("div"));oe(this,"motion",null);Z(this,Y,document.createElement("div"));Z(this,ae,0);Z(this,ce,0);Z(this,Se,0);Z(this,Te,0);this.wrapper.id="page-agent-runtime_simulator-mask",this.wrapper.className=styles.wrapper,this.wrapper.setAttribute("data-browser-use-ignore","true"),this.wrapper.setAttribute("data-page-agent-ignore","true");try{const t=new Motion({mode:isPageDark()?"dark":"light",styles:{position:"absolute",inset:"0"}});this.motion=t,this.wrapper.appendChild(t.element),t.autoResize(this.wrapper)}catch(t){console.warn("[SimulatorMask] Motion overlay unavailable:",t)}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,Ne,Yt).call(this),document.body.appendChild(this.wrapper),b(this,Ne,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){S(this,Se,t),S(this,Te,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",S(this,ae,window.innerWidth/2),S(this,ce,window.innerHeight/2),S(this,Se,p(this,ae)),S(this,Te,p(this,ce)),p(this,Y).style.left=`${p(this,ae)}px`,p(this,Y).style.top=`${p(this,ce)}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,ae=new WeakMap,ce=new WeakMap,Se=new WeakMap,Te=new WeakMap,Ne=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,ae)+(p(this,Se)-p(this,ae))*.2,o=p(this,ce)+(p(this,Te)-p(this,ce))*.2,n=Math.abs(t-p(this,Se));n>0&&(n<2?S(this,ae,p(this,Se)):S(this,ae,t),p(this,Y).style.left=`${p(this,ae)}px`);const r=Math.abs(o-p(this,Te));r>0&&(r<2?S(this,ce,p(this,Te)):S(this,ce,o),p(this,Y).style.top=`${p(this,ce)}px`),requestAnimationFrame(()=>b(this,Ne,Et).call(this))},"#moveCursorToTarget"),a(gt,"SimulatorMask");let SimulatorMask=gt;const SimulatorMask$1=Object.freeze(Object.defineProperty({__proto__:null,SimulatorMask},Symbol.toStringTag,{value:"Module"}))})();
400
+ }`;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:T}=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 I=r.getAttribLocation(i,"aPosition");r.enableVertexAttribArray(I),r.vertexAttribPointer(I,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,T,r.STATIC_DRAW);const A=r.getAttribLocation(i,"aUV");r.enableVertexAttribArray(A),r.vertexAttribPointer(A,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 C=performance.now();this.lastTime=C;const D=(C-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"),T=t.getUniformLocation(o,"uBorderWidth"),I=t.getUniformLocation(o,"uGlowWidth"),A=t.getUniformLocation(o,"uBorderRadius"),C=t.getUniformLocation(o,"uColors"),D=t.getUniformLocation(o,"uGlowExponent"),v=t.getUniformLocation(o,"uGlowFactor");t.useProgram(o),t.uniform1f(T,this.options.borderWidth),t.uniform1f(I,this.options.glowWidth),t.uniform1f(A,this.options.borderRadius),this.options.mode==="dark"?(t.uniform1f(D,2),t.uniform1f(v,1.8)):(t.uniform1f(D,1),t.uniform1f(v,1));const k=(this.options.colors||DEFAULT_COLORS).map(parseColor);for(let O=0;O<k.length;O++)t.uniform3f(t.getUniformLocation(o,`uColors[${O}]`),...k[O]);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:T,uGlowWidth:I,uBorderRadius:A,uColors:C}}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_1ooyb_1",visible="_visible_1ooyb_11",styles={wrapper,visible},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,Ne);oe(this,"shown",!1);oe(this,"wrapper",document.createElement("div"));oe(this,"motion",null);Z(this,q,document.createElement("div"));Z(this,ae,0);Z(this,ce,0);Z(this,Se,0);Z(this,Te,0);this.wrapper.id="page-agent-runtime_simulator-mask",this.wrapper.className=styles.wrapper,this.wrapper.setAttribute("data-browser-use-ignore","true"),this.wrapper.setAttribute("data-page-agent-ignore","true");try{const t=new Motion({mode:isPageDark()?"dark":"light",styles:{position:"absolute",inset:"0"}});this.motion=t,this.wrapper.appendChild(t.element),t.autoResize(this.wrapper)}catch(t){console.warn("[SimulatorMask] Motion overlay unavailable:",t)}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,Ne,Yt).call(this),document.body.appendChild(this.wrapper),b(this,Ne,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){S(this,Se,t),S(this,Te,o)}triggerClickAnimation(){p(this,q).classList.remove(cursorStyles.clicking),p(this,q).offsetHeight,p(this,q).classList.add(cursorStyles.clicking)}show(){this.shown||(this.shown=!0,this.motion?.start(),this.motion?.fadeIn(),this.wrapper.classList.add(styles.visible),S(this,ae,window.innerWidth/2),S(this,ce,window.innerHeight/2),S(this,Se,p(this,ae)),S(this,Te,p(this,ce)),p(this,q).style.left=`${p(this,ae)}px`,p(this,q).style.top=`${p(this,ce)}px`)}hide(){this.shown&&(this.shown=!1,this.motion?.fadeOut(),this.motion?.pause(),p(this,q).classList.remove(cursorStyles.clicking),setTimeout(()=>{this.wrapper.classList.remove(styles.visible)},800))}dispose(){this.motion?.dispose(),this.wrapper.remove()}};q=new WeakMap,ae=new WeakMap,ce=new WeakMap,Se=new WeakMap,Te=new WeakMap,Ne=new WeakSet,Yt=a(function(){p(this,q).className=cursorStyles.cursor;const t=document.createElement("div");t.className=cursorStyles.cursorRipple,p(this,q).appendChild(t);const o=document.createElement("div");o.className=cursorStyles.cursorFilling,p(this,q).appendChild(o);const n=document.createElement("div");n.className=cursorStyles.cursorBorder,p(this,q).appendChild(n),this.wrapper.appendChild(p(this,q))},"#createCursor"),Et=a(function(){const t=p(this,ae)+(p(this,Se)-p(this,ae))*.2,o=p(this,ce)+(p(this,Te)-p(this,ce))*.2,n=Math.abs(t-p(this,Se));n>0&&(n<2?S(this,ae,p(this,Se)):S(this,ae,t),p(this,q).style.left=`${p(this,ae)}px`);const r=Math.abs(o-p(this,Te));r>0&&(r<2?S(this,ce,p(this,Te)):S(this,ce,o),p(this,q).style.top=`${p(this,ce)}px`),requestAnimationFrame(()=>b(this,Ne,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.5.6",
4
+ "version": "1.5.8",
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.5.6",
48
- "@page-agent/llms": "1.5.6",
49
- "@page-agent/page-controller": "1.5.6",
50
- "@page-agent/ui": "1.5.6",
47
+ "@page-agent/core": "1.5.8",
48
+ "@page-agent/llms": "1.5.8",
49
+ "@page-agent/page-controller": "1.5.8",
50
+ "@page-agent/ui": "1.5.8",
51
51
  "chalk": "^5.6.2"
52
52
  },
53
53
  "peerDependencies": {