browsentic 0.7.0 → 0.7.4
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/dist/cli.js +782 -160
- package/dist/daemon-main.js +1570 -360
- package/extension/chrome-mv3/background.js +20 -19
- package/extension/chrome-mv3/chunks/{popup-BREcsp_I.js → popup-D_jEQFBQ.js} +1 -1
- package/extension/chrome-mv3/chunks/sidepanel-Dx3hYTrY.js +11 -0
- package/extension/chrome-mv3/chunks/{use-voice-composer-CD53o6gA.js → use-voice-composer-DfBR4M8I.js} +4 -4
- package/extension/chrome-mv3/content-scripts/content.js +14 -14
- package/extension/chrome-mv3/manifest.json +1 -1
- package/extension/chrome-mv3/popup.html +2 -2
- package/extension/chrome-mv3/sidepanel.html +2 -2
- package/package.json +1 -1
- package/skills/browser-control.md +1 -1
- package/skills/captcha.md +23 -26
- package/extension/chrome-mv3/chunks/sidepanel-CI14ARqL.js +0 -11
|
@@ -1 +1 @@
|
|
|
1
|
-
{"manifest_version":3,"name":"Browsentic","description":"Reimagine browsing as agentic — driven by the AI agent you already run, in your own logged-in browser.","version":"0.7.
|
|
1
|
+
{"manifest_version":3,"name":"Browsentic","description":"Reimagine browsing as agentic — driven by the AI agent you already run, in your own logged-in browser.","version":"0.7.4","icons":{"16":"icon/16.png","32":"icon/32.png","48":"icon/48.png","96":"icon/96.png","128":"icon/128.png"},"permissions":["storage","unlimitedStorage","activeTab","contextMenus","alarms","scripting","notifications","downloads","sidePanel","debugger"],"host_permissions":["<all_urls>"],"background":{"service_worker":"background.js"},"action":{"default_title":"Browsentic","default_popup":"popup.html"},"side_panel":{"default_path":"sidepanel.html"},"content_scripts":[{"matches":["*://*/*"],"js":["content-scripts/content.js"]}]}
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
<meta name="color-scheme" content="dark">
|
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
7
7
|
<title>Browsentic</title>
|
|
8
|
-
<script type="module" crossorigin src="/chunks/popup-
|
|
8
|
+
<script type="module" crossorigin src="/chunks/popup-D_jEQFBQ.js"></script>
|
|
9
9
|
<link rel="modulepreload" crossorigin href="/chunks/globals-Bis7MDt7.js">
|
|
10
|
-
<link rel="modulepreload" crossorigin href="/chunks/use-voice-composer-
|
|
10
|
+
<link rel="modulepreload" crossorigin href="/chunks/use-voice-composer-DfBR4M8I.js">
|
|
11
11
|
<link rel="stylesheet" crossorigin href="/assets/globals-Drv30qJX.css">
|
|
12
12
|
</head>
|
|
13
13
|
<body>
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
<meta name="color-scheme" content="dark">
|
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
7
7
|
<title>Browsentic Chat</title>
|
|
8
|
-
<script type="module" crossorigin src="/chunks/sidepanel-
|
|
8
|
+
<script type="module" crossorigin src="/chunks/sidepanel-Dx3hYTrY.js"></script>
|
|
9
9
|
<link rel="modulepreload" crossorigin href="/chunks/globals-Bis7MDt7.js">
|
|
10
|
-
<link rel="modulepreload" crossorigin href="/chunks/use-voice-composer-
|
|
10
|
+
<link rel="modulepreload" crossorigin href="/chunks/use-voice-composer-DfBR4M8I.js">
|
|
11
11
|
<link rel="stylesheet" crossorigin href="/assets/globals-Drv30qJX.css">
|
|
12
12
|
</head>
|
|
13
13
|
<body>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "browsentic",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.4",
|
|
4
4
|
"description": "A browser extension with an AI side panel that hands your real, logged-in browser to the AI agent you already run. Installs the extension, runs the local daemon, and optionally speaks MCP.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -32,7 +32,7 @@ After anything that changes the page, check that it landed. `page_waitForElement
|
|
|
32
32
|
|
|
33
33
|
When a click verifiably did nothing — the dialog never opened, the file picker never appeared, the page has a handler that checks `event.isTrusted` — `page_trustedClick` is the fallback, when it is in your tool list (a Firefox build has no such tool; say so and ask the user to make that click). It sends a real browser-level mouse event through Chrome's debugger, so the browser shows a "Browsentic is debugging this browser" bar while it runs and it refuses on a tab with DevTools open (`DEBUGGER_UNAVAILABLE` — say so and fall back). It takes the same `target`, plus `button` for a right-click, `clickCount: 2` for a double click and `modifiers` like `["meta"]`. The pointer travels to the target and dwells before pressing, so widgets that only react after real pointer movement get the sequence they wait for. It is slower and visibly intrusive, so `page_clickElement` stays the default: reach for the trusted one only after an ordinary click has already failed.
|
|
34
34
|
|
|
35
|
-
A
|
|
35
|
+
A captcha is a different problem and neither click tool solves it — the checkbox is inside a closed shadow root inside a cross-origin iframe, so no selector reaches it. The moment `page_getPageInfo` reports a `captcha` (or a page stalls on "verifying you are human"), call `page_solveCaptcha {}` — do not hunt for the checkbox, do not stop to ask. It ticks the box and sees an image challenge through; when it hands one back as `state: "challenge"`, look at the image it returns and answer with `tiles` or `points`, repeating until `solved`. The **captcha** skill covers the whole path.
|
|
36
36
|
|
|
37
37
|
Navigation has two shapes and they behave differently. `page_navigate` takes **either** a `url` **or** an `action` (`back` / `forward` / `reload`) — never both, never neither. From a tab with no content script the URL must be absolute. The result tells you which path ran: `navigatingTo` pushed a history entry so `back` works afterwards; `navigatedTo` replaced it. `loaded: true` means the load actually finished.
|
|
38
38
|
|
package/skills/captcha.md
CHANGED
|
@@ -1,47 +1,44 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: captcha
|
|
3
|
-
description: Get past a “verify you are human” block —
|
|
3
|
+
description: Get past a “verify you are human” block — tick the checkbox, see an image challenge through, hand over only the puzzles nothing can answer.
|
|
4
4
|
triggers: [captcha, recaptcha, hcaptcha, turnstile, cloudflare, verify you are human, prove you are human, i am not a robot, checking your browser, just a moment, are you a robot, human verification, challenge, bot check, blocked by, security check]
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
A captcha is the one thing on a page that ordinary targeting cannot
|
|
7
|
+
A captcha is the one thing on a page that ordinary targeting cannot reach. The widget sits in a closed shadow root inside a cross-origin iframe, often several frames deep, so `page_clickElement` has nothing to aim at. `page_solveCaptcha` reaches it wherever it is. When a captcha is in the way, getting past it is part of the task — do it, do not stop to report it.
|
|
8
8
|
|
|
9
|
-
## 1. Notice
|
|
9
|
+
## 1. Notice it — then act at once
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
`page_getPageInfo` carries a `captcha` field whenever a page holds one that needs answering: the vendor, whether it is already `solved`, and a `next` step. Other signs: a page that never finishes ("Checking your browser", "Just a moment…"), a form that refuses without saying why, a checkbox you can see in a screenshot but no snapshot lists.
|
|
12
12
|
|
|
13
|
-
Do not
|
|
13
|
+
**Call `page_solveCaptcha {}` straight away.** Do not look for the checkbox with selectors, do not screenshot it first, do not ask the user whether to try. It is gated for approval, so the user decides there; one yes covers every round of the same captcha in this run. If it comes back `DECLINED`, that is their answer — say so and stop.
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
If `captcha.solved` is true, the widget is satisfied already — carry on with the task.
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
## 2. Read the state it returns
|
|
18
18
|
|
|
19
|
-
- **`solved`** —
|
|
20
|
-
- **`
|
|
21
|
-
- **`
|
|
22
|
-
- **`
|
|
23
|
-
- **`
|
|
19
|
+
- **`solved`** — done. Re-snapshot and continue the task; a form may now need submitting.
|
|
20
|
+
- **`challenge`** — an image challenge is open and waiting on you. §3.
|
|
21
|
+
- **`pending`** — the widget took the click but had not settled. Wait a few seconds, then `page_findCaptcha {}` to re-check; call `page_solveCaptcha {}` again only if it is back to `idle`.
|
|
22
|
+
- **`invisible`** — a scoring captcha (reCAPTCHA v3 and the like) with nothing to click. If the page still refuses you, the site has judged the session; say so and stop.
|
|
23
|
+
- **`needsHuman`** — a puzzle Browsentic does not answer (Arkose, AWS WAF, a drag-to-fit). §4.
|
|
24
|
+
- **`CAPTCHA_NOT_FOUND`** — no captcha on the page, so the block is something else.
|
|
24
25
|
|
|
25
|
-
## 3.
|
|
26
|
+
## 3. An image challenge
|
|
26
27
|
|
|
27
|
-
|
|
28
|
+
Browsentic's own vision analyst answers reCAPTCHA and hCaptcha challenges inside the call — a fresh one-shot session per round, stopped as soon as it has answered — so most of the time `page_solveCaptcha {}` returns `solved` without you seeing a grid. When it cannot finish, the result has state `challenge`, a note saying so, and the challenge as an **image** beside its description. Answer it yourself:
|
|
28
29
|
|
|
29
|
-
|
|
30
|
+
- **`kind: "tiles"`** — a grid with each tile's number painted in its corner (1 top-left, counting along each row). Call `page_solveCaptcha {"tiles": [...]}` with every tile that matches `prompt`. It is the whole selection, not a change to it; `[]` means none match. When `dynamic` is true, each tile you pick is swapped for a new picture and the result comes back with the grid again — keep answering; `[]` verifies it once no tile matches. For a 4×4 slice of one photo, include every tile showing any part of the object.
|
|
31
|
+
- **`kind: "points"`** — a picture to tap on. Call `page_solveCaptcha {"points": [{"x": …, "y": …}]}` with pixel positions on that image (it is `imageWidth` × `imageHeight`), aiming for the centre of each thing to tap.
|
|
32
|
+
- **Cannot make it out?** `page_solveCaptcha {"reload": true}` swaps it for another.
|
|
30
33
|
|
|
31
|
-
|
|
34
|
+
Repeat with each new result until `solved`. `errors` on a result means the last answer was refused — look again more carefully. Vendors often want several rounds; that is normal, not a failure.
|
|
32
35
|
|
|
33
|
-
## 4. When it needs the user
|
|
36
|
+
## 4. When it needs the user
|
|
34
37
|
|
|
35
|
-
`needsHuman`
|
|
36
|
-
|
|
37
|
-
What to do instead, in order: `page_screenshot {}` so you can see the challenge and describe it, then tell the user plainly that this one needs them and that they can solve it in the browser window already in front of them. Do not pass `save: true` — they are looking at the real thing, and a file of it helps nobody. Then wait: poll `page_findCaptcha {}` every several seconds until `state` becomes `solved`, and continue the task from there. If they do not solve it within a reasonable spell, report that you are still waiting rather than looping forever in silence.
|
|
38
|
-
|
|
39
|
-
The user is sitting at this browser. Handing them ten seconds of clicking is a normal step in a task, not a failure to report apologetically.
|
|
38
|
+
`needsHuman` is the one case to hand over. `page_screenshot {}` to see it, tell the user plainly this one needs them and that they can solve it in the browser window in front of them, then poll `page_findCaptcha {}` every several seconds until `solved` and carry on. If they have not solved it after a reasonable while, say you are still waiting rather than looping in silence.
|
|
40
39
|
|
|
41
40
|
## 5. When the tools cannot run
|
|
42
41
|
|
|
43
|
-
`DEBUGGER_UNAVAILABLE` means Chrome's debugger could not attach — almost always DevTools
|
|
44
|
-
|
|
45
|
-
A Firefox build has neither tool: it exposes no debugger to extensions, so they are left off its tool list rather than offered to fail. If they are not in your list, do not go looking for them — say so and ask the user to deal with the captcha themselves. `UNSUPPORTED` means the same thing when an older instruction or recording still names one.
|
|
42
|
+
`DEBUGGER_UNAVAILABLE` means Chrome's debugger could not attach — almost always DevTools open on that tab. Ask the user to close DevTools, then retry.
|
|
46
43
|
|
|
47
|
-
|
|
44
|
+
A Firefox build has neither tool; if they are not in your list, ask the user to solve the captcha themselves. `UNSUPPORTED` means the same when an older instruction names them.
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import{S as e,_ as t,a as n,b as r,c as i,d as a,f as o,g as s,h as c,i as l,m as u,n as d,o as f,p,r as m,s as h,t as g,u as _,v,x as y,y as b}from"./globals-Bis7MDt7.js";import{A as x,B as S,C,D as ee,E as w,F as T,G as te,H as E,I as D,J as O,K as k,L as A,M as j,N as M,O as N,P,R as F,S as I,T as ne,U as re,V as ie,W as L,X as R,Y as ae,_ as oe,a as se,b as ce,c as le,d as ue,f as de,g as fe,h as pe,i as me,j as z,k as he,l as ge,m as _e,n as ve,o as ye,q as be,r as xe,s as Se,t as Ce,u as we,v as Te,w as Ee,x as De,y as Oe,z as ke}from"./use-voice-composer-CD53o6gA.js";var Ae=t(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),je=t(`book-open`,[[`path`,{d:`M12 5v16`,key:`1f6ucr`}],[`path`,{d:`M20.001 19A2 2 0 0022 17V5a2 2 0 00-1.999-2L16 3.002A5 5 0 0012 5a5 5 0 00-4-2H4a2 2 0 00-2 2v12a2 2 0 001.999 2H8a5 5 0 014 2 5 5 0 014-2z`,key:`1fyvmf`}]]),Me=t(`braces`,[[`path`,{d:`M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1`,key:`ezmyqa`}],[`path`,{d:`M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1`,key:`e1hn23`}]]),Ne=t(`camera`,[[`path`,{d:`M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z`,key:`18u6gg`}],[`circle`,{cx:`12`,cy:`13`,r:`3`,key:`1vg3eu`}]]),Pe=t(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),B=t(`clapperboard`,[[`path`,{d:`m12.296 3.464 3.02 3.956`,key:`qash78`}],[`path`,{d:`M20.2 6 3 11l-.9-2.4c-.3-1.1.3-2.2 1.3-2.5l13.5-4c1.1-.3 2.2.3 2.5 1.3z`,key:`1h7j8b`}],[`path`,{d:`M3 11h18v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z`,key:`4lm6w1`}],[`path`,{d:`m6.18 5.276 3.1 3.899`,key:`zjj9t3`}]]),Fe=t(`code-xml`,[[`path`,{d:`m18 16 4-4-4-4`,key:`1inbqp`}],[`path`,{d:`m6 8-4 4 4 4`,key:`15zrgr`}],[`path`,{d:`m14.5 4-5 16`,key:`e7oirm`}]]),Ie=t(`compass`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z`,key:`9ktpf1`}]]),Le=t(`corner-down-left`,[[`path`,{d:`M20 4v7a4 4 0 0 1-4 4H4`,key:`6o5b7l`}],[`path`,{d:`m9 10-5 5 5 5`,key:`1kshq7`}]]),Re=t(`cpu`,[[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M17 20v2`,key:`1rnc9c`}],[`path`,{d:`M17 2v2`,key:`11trls`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M2 17h2`,key:`7oei6x`}],[`path`,{d:`M2 7h2`,key:`asdhe0`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`M20 17h2`,key:`1fpfkl`}],[`path`,{d:`M20 7h2`,key:`1o8tra`}],[`path`,{d:`M7 20v2`,key:`4gnj0m`}],[`path`,{d:`M7 2v2`,key:`1i4yhu`}],[`rect`,{x:`4`,y:`4`,width:`16`,height:`16`,rx:`2`,key:`1vbyd7`}],[`rect`,{x:`8`,y:`8`,width:`8`,height:`8`,rx:`1`,key:`z9xiuo`}]]),ze=t(`external-link`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]),Be=t(`eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),Ve=t(`file-text`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),He=t(`file-up`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M12 12v6`,key:`3ahymv`}],[`path`,{d:`m15 15-3-3-3 3`,key:`15xj92`}]]),Ue=t(`folder-open`,[[`path`,{d:`m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`,key:`usdka0`}]]),V=t(`globe`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]),We=t(`highlighter`,[[`path`,{d:`m9 11-6 6v3h9l3-3`,key:`1a3l36`}],[`path`,{d:`m22 12-4.6 4.6a2 2 0 0 1-2.8 0l-5.2-5.2a2 2 0 0 1 0-2.8L14 4`,key:`14a9rk`}]]),Ge=t(`hourglass`,[[`path`,{d:`M5 22h14`,key:`ehvnwv`}],[`path`,{d:`M5 2h14`,key:`pdyrp9`}],[`path`,{d:`M17 22v-4.172a2 2 0 0 0-.586-1.414L12 12l-4.414 4.414A2 2 0 0 0 7 17.828V22`,key:`1d314k`}],[`path`,{d:`M7 2v4.172a2 2 0 0 0 .586 1.414L12 12l4.414-4.414A2 2 0 0 0 17 6.172V2`,key:`1vvvr6`}]]),Ke=t(`images`,[[`path`,{d:`m22 11-1.296-1.296a2.4 2.4 0 0 0-3.408 0L11 16`,key:`9kzy35`}],[`path`,{d:`M4 8a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2`,key:`1t0f0t`}],[`circle`,{cx:`13`,cy:`7`,r:`1`,fill:`currentColor`,key:`1obus6`}],[`rect`,{x:`8`,y:`2`,width:`14`,height:`14`,rx:`2`,key:`1gvhby`}]]),qe=t(`info`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 16v-4`,key:`1dtifu`}],[`path`,{d:`M12 8h.01`,key:`e9boi3`}]]),Je=t(`key-round`,[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]),Ye=t(`keyboard`,[[`path`,{d:`M10 8h.01`,key:`1r9ogq`}],[`path`,{d:`M12 12h.01`,key:`1mp3jc`}],[`path`,{d:`M14 8h.01`,key:`1primd`}],[`path`,{d:`M16 12h.01`,key:`1l6xoz`}],[`path`,{d:`M18 8h.01`,key:`emo2bl`}],[`path`,{d:`M6 8h.01`,key:`x9i8wu`}],[`path`,{d:`M7 16h10`,key:`wp8him`}],[`path`,{d:`M8 12h.01`,key:`czm47f`}],[`rect`,{width:`20`,height:`16`,x:`2`,y:`4`,rx:`2`,key:`18n3k1`}]]),Xe=t(`layers`,[[`path`,{d:`M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z`,key:`zw3jo`}],[`path`,{d:`M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12`,key:`1wduqc`}],[`path`,{d:`M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17`,key:`kqbvx6`}]]),Ze=t(`list-checks`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`path`,{d:`m3 7 2 2 4-4`,key:`1obspn`}]]),Qe=t(`lock`,[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 10 0v4`,key:`fwvmzm`}]]),$e=t(`messages-square`,[[`path`,{d:`M16 10a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 14.286V4a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2z`,key:`1n2ejm`}],[`path`,{d:`M20 9a2 2 0 0 1 2 2v10.286a.71.71 0 0 1-1.212.502l-2.202-2.202A2 2 0 0 0 17.172 19H10a2 2 0 0 1-2-2v-1`,key:`1qfcsi`}]]),et=t(`mouse-pointer-click`,[[`path`,{d:`M14 4.1 12 6`,key:`ita8i4`}],[`path`,{d:`m5.1 8-2.9-.8`,key:`1go3kf`}],[`path`,{d:`m6 12-1.9 2`,key:`mnht97`}],[`path`,{d:`M7.2 2.2 8 5.1`,key:`1cfko1`}],[`path`,{d:`M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z`,key:`s0h3yz`}]]),tt=t(`move-vertical`,[[`path`,{d:`M12 2v20`,key:`t6zp3m`}],[`path`,{d:`m8 18 4 4 4-4`,key:`bh5tu3`}],[`path`,{d:`m8 6 4-4 4 4`,key:`ybng9g`}]]),nt=t(`panel-right-close`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}],[`path`,{d:`m8 9 3 3-3 3`,key:`12hl5m`}]]),rt=t(`paperclip`,[[`path`,{d:`m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551`,key:`1miecu`}]]),it=t(`pencil`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]),at=t(`play`,[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`,key:`10ikf1`}]]),H=t(`radar`,[[`path`,{d:`M19.07 4.93A10 10 0 0 0 6.99 3.34`,key:`z3du51`}],[`path`,{d:`M4 6h.01`,key:`oypzma`}],[`path`,{d:`M2.29 9.62A10 10 0 1 0 21.31 8.35`,key:`qzzz0`}],[`path`,{d:`M16.24 7.76A6 6 0 1 0 8.23 16.67`,key:`1yjesh`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}],[`path`,{d:`M17.99 11.66A6 6 0 0 1 15.77 16.67`,key:`1u2y91`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}],[`path`,{d:`m13.41 10.59 5.66-5.66`,key:`mhq4k0`}]]),ot=t(`rotate-ccw-clock`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]),U=t(`scan-eye`,[[`path`,{d:`M3 7V5a2 2 0 0 1 2-2h2`,key:`aa7l1z`}],[`path`,{d:`M17 3h2a2 2 0 0 1 2 2v2`,key:`4qcy5o`}],[`path`,{d:`M21 17v2a2 2 0 0 1-2 2h-2`,key:`6vwrx8`}],[`path`,{d:`M7 21H5a2 2 0 0 1-2-2v-2`,key:`ioqczr`}],[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`path`,{d:`M18.944 12.33a1 1 0 0 0 0-.66 7.5 7.5 0 0 0-13.888 0 1 1 0 0 0 0 .66 7.5 7.5 0 0 0 13.888 0`,key:`11ak4c`}]]),st=t(`settings-2`,[[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`path`,{d:`M19 7h-9`,key:`6i9tg`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),ct=t(`shield-alert`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),lt=t(`sliders-horizontal`,[[`path`,{d:`M10 5H3`,key:`1qgfaw`}],[`path`,{d:`M12 19H3`,key:`yhmn1j`}],[`path`,{d:`M14 3v4`,key:`1sua03`}],[`path`,{d:`M16 17v4`,key:`1q0r14`}],[`path`,{d:`M21 12h-9`,key:`1o4lsq`}],[`path`,{d:`M21 19h-5`,key:`1rlt1p`}],[`path`,{d:`M21 5h-7`,key:`1oszz2`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M8 12H3`,key:`a7s4jb`}]]),ut=t(`sparkles`,[[`path`,{d:`M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z`,key:`1s2grr`}],[`path`,{d:`M20 2v4`,key:`1rf3ol`}],[`path`,{d:`M22 4h-4`,key:`gwowj6`}],[`circle`,{cx:`4`,cy:`20`,r:`2`,key:`6kqj1y`}]]),dt=t(`square-pen`,[[`path`,{d:`M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7`,key:`1m0v6g`}],[`path`,{d:`M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z`,key:`ohrbg2`}]]),ft=t(`square-slash`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`line`,{x1:`9`,x2:`15`,y1:`15`,y2:`9`,key:`1dfufj`}]]),pt=t(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),mt=t(`terminal`,[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]),ht=t(`text-cursor-input`,[[`path`,{d:`M12 20h-1a2 2 0 0 1-2-2 2 2 0 0 1-2 2H6`,key:`1528k5`}],[`path`,{d:`M13 8h7a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-7`,key:`13ksps`}],[`path`,{d:`M5 16H4a2 2 0 0 1-2-2v-4a2 2 0 0 1 2-2h1`,key:`1n9rhb`}],[`path`,{d:`M6 4h1a2 2 0 0 1 2 2 2 2 0 0 1 2-2h1`,key:`1mj8rg`}],[`path`,{d:`M9 6v12`,key:`velyjx`}]]),gt=t(`trash-2`,[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]]),_t=t(`type`,[[`path`,{d:`M12 4v16`,key:`1654pz`}],[`path`,{d:`M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2`,key:`e0r10z`}],[`path`,{d:`M9 20h6`,key:`s66wpe`}]]),vt=t(`unplug`,[[`path`,{d:`m19 5 3-3`,key:`yk6iyv`}],[`path`,{d:`m2 22 3-3`,key:`19mgm9`}],[`path`,{d:`M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z`,key:`goz73y`}],[`path`,{d:`M7.5 13.5 10 11`,key:`7xgeeb`}],[`path`,{d:`M10.5 16.5 13 14`,key:`10btkg`}],[`path`,{d:`m12 6 6 6 2.3-2.3a2.4 2.4 0 0 0 0-3.4l-2.6-2.6a2.4 2.4 0 0 0-3.4 0Z`,key:`1snsnr`}]]),yt=t(`upload`,[[`path`,{d:`M12 3v12`,key:`1x0j5s`}],[`path`,{d:`m17 8-5-5-5 5`,key:`7q97r8`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}]]),bt=t(`wrench`,[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z`,key:`1ngwbx`}]]),W=t(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]),xt=t(`zap`,[[`path`,{d:`M15.914 4a1.5 1.5 0 00-2.474-1.561l-9 9A1.5 1.5 0 005.5 14h4.002a.5.5 0 01.471.666L8.086 20a1.5 1.5 0 002.475 1.56l9-9A1.5 1.5 0 0018.5 10h-3.997a.5.5 0 01-.472-.667z`,key:`1v7up4`}]]),G=e(y(),1),St=e(b(),1),Ct=[`general`,`site-exploration`],wt=/^[a-z0-9][a-z0-9-]{0,47}$/,Tt=32*1024,Et=/^[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)+$/,Dt=300,Ot=3,kt=60;function At(e){let t=/^---[ \t]*\r?\n([\s\S]*?)\r?\n---[ \t]*\r?\n?/.exec(e);if(!t)return{fields:{},body:e};let n={};for(let e of t[1].split(/\r?\n/)){let t=e.indexOf(`:`);t>0&&(n[e.slice(0,t).trim()]=e.slice(t+1).trim())}return{fields:n,body:e.slice(t[0].length)}}function jt(e){return e?e.replace(/^\[|\]$/g,``).split(`,`).map(e=>e.trim().replace(/^['"]|['"]$/g,``)).filter(Boolean):[]}function Mt(e){return e?.trim()===`site-exploration`?`site-exploration`:`general`}function Nt(e){return e.replace(/[\r\n]+/g,` `).replace(/\s+/g,` `).trim()}function Pt(e){try{return new URL(e).hostname.toLowerCase()}catch{return``}}function Ft(e){let t=e.trim().toLowerCase();return t?(t.includes(`://`)?Pt(t):t).replace(/^\/+|\/+$/g,``).split(`/`)[0].split(`:`)[0].replace(/^\.+|\.+$/g,``):``}function It(e){return e===`localhost`||e.length<=253&&Et.test(e)}function Lt(e,t){return Rt(e,t).length>0}function Rt(e,t){let n=e.toLowerCase();return n?t.filter(e=>n===e||n.endsWith(`.${e}`)).sort((e,t)=>t.length-e.length):[]}function zt(e,t={}){let n=e.name.trim().toLowerCase();if(!n)return K(`Give the skill a name.`);if(!wt.test(n))return K(`Names use lowercase letters, digits and hyphens only, starting with a letter or digit (max 48).`);if(t.reservedNames?.some(e=>e.toLowerCase()===n))return K(`"${n}" is the name of a built-in skill. Pick another.`);let r=Nt(e.description).slice(0,Dt),i=e.category;if(!Ct.includes(i))return K(`Unknown category "${String(i)}".`);let a=Ht(e.domains.map(Ft).filter(Boolean));if(i===`site-exploration`){if(!a.length)return K(`A site-exploration skill needs at least one domain, like acme.com.`);if(a.length>20)return K(`At most 20 domains.`);for(let e of a){if(e.includes(`*`))return K(`"${e}" — wildcards are not supported; subdomains match automatically.`);if(!It(e))return K(`"${e}" is not a domain. Use something like acme.com.`)}}let o=i===`site-exploration`?[]:Ht(e.triggers.map(e=>Nt(e).toLowerCase()).filter(Boolean));if(o.length>30)return K(`At most 30 triggers.`);for(let e of o)if(e.length<Ot||e.length>kt)return K(`Trigger "${e}" must be ${Ot}–${kt} characters.`);let s=At(e.body.replace(/\r\n/g,`
|
|
2
|
-
`)).body.trim();return s?Bt(s)>32768?K(`The skill is larger than ${Math.round(Tt/1024)} KB. Trim it down.`):{ok:!0,draft:{name:n,description:r,category:i,domains:a,triggers:o,body:s}}:K(`The skill has no instructions — add some markdown below the front matter.`)}function Bt(e){let t=0;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);r<128?t+=1:r<2048?t+=2:r>=55296&&r<=56319?(t+=4,n++):t+=3}return t}function Vt(e,t){let{fields:n,body:r}=At(e.replace(/\r\n/g,`
|
|
3
|
-
`)),i=Ft(t.replace(/\.(md|markdown)$/i,``)).replace(/[^a-z0-9-]+/g,`-`).replace(/^-+|-+$/g,``);return{name:(n.name||i).toLowerCase(),description:n.description??``,category:Mt(n.category),domains:jt(n.domains).map(Ft).filter(Boolean),triggers:jt(n.triggers).map(e=>e.toLowerCase()),body:r.trim()}}function Ht(e){return[...new Set(e)]}function K(e){return{ok:!1,message:e}}var Ut=48;function Wt(e){let t;try{t=new URL(e)}catch{return null}if(t.protocol!==`http:`&&t.protocol!==`https:`)return null;let n=t.hostname.toLowerCase().replace(/^www\./,``);if(!n)return null;let[r=``]=t.pathname.split(`/`).filter(Boolean);return{host:n,segment:qt(r)||`root`}}function Gt(e,t){return`${e.host}:${e.segment}:${t}`}function Kt(e,t){let n=Wt(t);return!!n&&n.host===e.host&&n.segment===e.segment}function qt(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,Ut).replace(/-+$/,``)}var Jt=`/context`,Yt=`/remove-tools`,Xt=`Review the tools you saved, and delete any you are done with.`,Zt=e=>e.trim().toLowerCase()===Yt,Qt=`See what this conversation carries — messages, files, recordings, tabs.`,q=p(),$t={tool:0,command:1,site:2,general:3,agent:4,"other-site":5};function en(e,t,n,r=[]){let i=Pt(t),a=[{key:`command:context`,group:`command`,name:`context`,description:Qt,command:Jt}];r.length&&a.push({key:`command:remove-tools`,group:`command`,name:`remove-tools`,description:Xt,command:Yt});for(let e of r)Kt(e.scope,t)&&a.push({key:`tool:${e.id}`,group:`tool`,name:e.name,description:e.description,savedToolId:e.id});for(let t of e?.skills??[]){let e=t.category===`site-exploration`?i&&Lt(i,t.domains)?`site`:`other-site`:`general`;a.push({key:`${e}:${t.name}`,group:e,name:t.name,description:t.description})}for(let t of e?.agentSkills??[])a.push({key:`agent:${t.id}`,group:`agent`,name:t.name,description:t.description,agentSkillId:t.id});let o=n.trim().toLowerCase();return(o?a.filter(e=>e.name.toLowerCase().includes(o)||e.description.toLowerCase().includes(o)):a).sort((e,t)=>$t[e.group]-$t[t.group]||e.name.localeCompare(t.name))}function tn({items:e,agent:t,highlight:n,onHover:r,onSelect:i}){let a={tool:`Your tools`,command:`Commands`,site:`On this site`,general:`Browsentic skills`,agent:`${t?E[t].label:`Agent`} skills`,"other-site":`Other sites`};return(0,q.jsx)(`div`,{role:`listbox`,"aria-label":`Skills and commands`,className:`enters absolute inset-x-0 bottom-full z-20 mb-2 max-h-64 overflow-y-auto rounded-xl border border-line bg-surface shadow-lg`,children:e.length===0?(0,q.jsx)(`p`,{className:`px-3 py-2.5 text-[11px] text-ink-faint`,children:`Nothing matches — keep typing, or press Escape.`}):e.map((t,o)=>(0,q.jsxs)(`div`,{children:[(o===0||e[o-1].group!==t.group)&&(0,q.jsx)(`p`,{className:`px-3 pt-2 pb-1 font-mono text-[10px] tracking-[0.14em] text-ink-faint uppercase`,children:a[t.group]}),(0,q.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":o===n,onMouseEnter:()=>r(o),onMouseDown:e=>{e.preventDefault(),i(t)},className:u(`flex w-full items-start gap-2 px-3 py-1.5 text-left transition-colors`,o===n?`bg-brand/12`:`hover:bg-ground/40`),children:[t.group===`tool`?(0,q.jsx)(xt,{className:`mt-0.5 size-3 shrink-0 text-lime`}):t.group===`command`?(0,q.jsx)(ft,{className:`mt-0.5 size-3 shrink-0 text-amber`}):t.group===`agent`?(0,q.jsx)(ut,{className:`mt-0.5 size-3 shrink-0 text-brand`}):t.group===`general`?(0,q.jsx)(je,{className:`mt-0.5 size-3 shrink-0 text-ink-faint`}):(0,q.jsx)(V,{className:`mt-0.5 size-3 shrink-0 text-ink-faint`}),(0,q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,q.jsx)(`span`,{className:`block truncate text-xs font-medium text-ink`,children:t.name}),t.description&&(0,q.jsx)(`span`,{className:`block truncate text-[11px] text-ink-dim`,children:t.description})]})]})]},t.key))})}function nn({className:e,...t}){return(0,q.jsx)(`textarea`,{"data-slot":`textarea`,className:u(`field-sizing-content flex min-h-16 w-full rounded-lg border border-line-strong bg-ground/60 px-3 py-2 text-sm text-ink outline-none transition-colors`,`placeholder:text-ink-faint selection:bg-brand/30 selection:text-ink`,`focus-visible:border-brand/55`,`disabled:cursor-not-allowed disabled:opacity-45`,e),...t})}async function rn(){let[e]=await v.tabs.query({active:!0,currentWindow:!0});if(e?.id==null)return{error:`No active tab to point at`};let t=await Te({id:e.id,windowId:e.windowId});if(!t.ok)return t.error.code===`PICK_CANCELLED`?{cancelled:!0}:{error:t.error.message};let{element:n,content:r,truncated:i,url:a,title:o,shot:s}=t.data;return{focus:{tag:n.tag,role:n.role,selector:n.selector,label:n.text,content:r,truncated:i,url:a,title:o,shot:s?.dataUrl}}}var an=e=>e.label?.trim()||e.role||e.tag;function on({voice:e,voiceEnabled:t,connected:n,running:r,files:i,attachError:a,catalog:o,tabUrl:l,attachedSkill:d,focus:p,picking:m,liveTools:h,onToggleLiveTools:g,onAttachSkill:_,onCommand:v,tools:y,onRunTool:b,onSend:x,onStop:S,onToggleVoice:C,onPick:ee,onClearFocus:w,onAttachPage:T,onAttachFile:te,onRemoveFile:E}){let D=(0,G.useRef)(null),O=(0,G.useRef)(null),A=e.input.startsWith(`/`)?e.input.slice(1):null,j=A!==null&&n,[M,N]=(0,G.useState)(0),P=(0,G.useMemo)(()=>j?en(o,l,A??``,y):[],[j,o,l,A,y]);(0,G.useEffect)(()=>N(0),[A]);let{cancelPending:F}=e;(0,G.useEffect)(()=>{j&&F()},[j,F]);function I(t){t.savedToolId?(e.setInput(``),b(t.savedToolId)):t.command?(e.setInput(``),v(t.command)):t.agentSkillId?(_({id:t.agentSkillId,name:t.name}),e.setInput(``)):e.setInput(`@${t.name} `),O.current?.focus()}function ne(e){e.target.closest(`button, textarea`)||O.current?.focus()}return(0,q.jsxs)(q.Fragment,{children:[a&&(0,q.jsx)(`p`,{className:`mb-2 rounded-lg border border-amber/40 bg-amber/10 px-2.5 py-1.5 text-[11px] text-amber`,children:a}),(0,q.jsx)(sn,{focus:p,picking:m,onClear:w}),d&&(0,q.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 rounded-xl border border-brand/35 bg-brand/8 px-2.5 py-1.5 text-xs`,children:[(0,q.jsx)(ut,{className:`size-3.5 shrink-0 text-brand`}),(0,q.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-ink`,children:[`Skill attached: `,(0,q.jsx)(`span`,{className:`font-medium`,children:d.name})]}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>_(null),"aria-label":`Detach ${d.name}`,className:`shrink-0 rounded-full p-1 text-ink-faint transition-colors hover:bg-surface hover:text-ink`,children:(0,q.jsx)(W,{className:`size-3`})})]}),h&&(0,q.jsxs)(`div`,{className:`enters mb-2 flex items-center gap-2 rounded-xl border border-ember/40 bg-ember/8 px-2.5 py-1.5 text-xs`,children:[(0,q.jsx)(Fe,{className:`size-3.5 shrink-0 text-ember`}),(0,q.jsxs)(`span`,{className:`min-w-0 flex-1 text-ink-dim`,children:[(0,q.jsx)(`span`,{className:`font-medium text-ink`,children:`Live tool on`}),` — the agent may write a script for this page. You approve the code first.`]}),(0,q.jsx)(`button`,{type:`button`,onClick:g,"aria-label":`Turn live tools off`,className:`shrink-0 rounded-full p-1 text-ink-faint transition-colors hover:bg-surface hover:text-ink`,children:(0,q.jsx)(W,{className:`size-3`})})]}),(0,q.jsx)(ln,{files:i,onRemove:E}),(0,q.jsx)(cn,{voice:e,voiceEnabled:t}),(0,q.jsxs)(`div`,{onClick:ne,className:u(`panel-card relative flex flex-col rounded-2xl transition-colors has-[textarea:focus]:border-brand/50`,n&&`cursor-text`),children:[j&&(0,q.jsx)(tn,{items:P,agent:o?.agent,highlight:M,onHover:N,onSelect:I}),(0,q.jsx)(nn,{ref:O,value:e.input,onChange:t=>e.setInput(t.target.value),onKeyDown:t=>{if(j){if(t.key===`Escape`){t.preventDefault(),e.setInput(``);return}if(P.length>0){if(t.key===`ArrowDown`){t.preventDefault(),N(e=>(e+1)%P.length);return}if(t.key===`ArrowUp`){t.preventDefault(),N(e=>(e-1+P.length)%P.length);return}if(t.key===`Enter`||t.key===`Tab`){t.preventDefault(),I(P[Math.min(M,P.length-1)]);return}}}t.key===`Enter`&&!t.shiftKey&&(t.preventDefault(),x())},placeholder:n?`Tell me what to do on this page…`:`Pair the browser to get started`,disabled:!n,rows:2,className:`max-h-48 min-h-14 resize-none rounded-none border-0 bg-transparent px-3 pt-2.5 pb-0 focus-visible:border-0`}),(0,q.jsxs)(`div`,{className:`flex items-center gap-0.5 px-1.5 pb-1.5`,children:[(0,q.jsx)(f,{variant:p||m?`subtle`:`ghost`,size:`icon-sm`,title:`A-Eye — point at an element on the page and send it with your next message`,"aria-label":`Point at an element with A-Eye`,onClick:ee,disabled:!n||m,className:u(p||m?`text-ember`:void 0),children:(0,q.jsx)(U,{className:u(`size-3.5`,m&&`animate-pulse`)})}),(0,q.jsx)(f,{variant:`ghost`,size:`icon-sm`,title:`Add this page’s title, URL and selection to the message`,"aria-label":`Attach page context`,onClick:T,disabled:!n,children:(0,q.jsx)(rt,{className:`size-3.5`})}),(0,q.jsx)(f,{variant:`ghost`,size:`icon-sm`,title:`Attach a file for the agent to read`,"aria-label":`Attach a file`,onClick:()=>D.current?.click(),disabled:!n,children:(0,q.jsx)(He,{className:`size-3.5`})}),(0,q.jsx)(f,{variant:h?`subtle`:`ghost`,size:`icon-sm`,role:`switch`,"aria-checked":h,"aria-label":h?`Turn live tools off`:`Turn live tools on`,title:h?`Live tool is on — the agent may write a small script for this page and ask you to approve it. Turn it off to keep to the built-in tools.`:`Live tool — let the agent write a small script for repetitive work or for something no tool covers. You review and approve the code before it runs.`,onClick:g,disabled:!n,className:u(h?`text-ember`:void 0),children:(0,q.jsx)(Fe,{className:`size-3.5`})}),(0,q.jsxs)(f,{variant:t&&!e.error?`subtle`:`ghost`,size:`icon-sm`,"aria-label":t?`Turn voice off`:`Turn voice on`,title:e.supported?`Speak instead of typing`:`Voice input is not available in this browser`,onClick:C,disabled:!e.supported,className:`relative`,children:[t&&e.listening&&(0,q.jsx)(`span`,{className:`absolute inset-0 animate-ping rounded-full bg-magenta/30`}),t&&!e.error?(0,q.jsx)(c,{className:`size-3.5`}):(0,q.jsx)(s,{className:`size-3.5`})]}),r?(0,q.jsx)(f,{size:`icon-sm`,variant:`destructive`,className:`ml-auto`,"aria-label":`Stop the agent`,onClick:S,children:(0,q.jsx)(pt,{className:`size-3 fill-current`})}):(0,q.jsx)(f,{size:`icon-sm`,className:`ml-auto`,"aria-label":`Send message`,onClick:x,disabled:!e.input.trim()||!n,children:(0,q.jsx)(k,{className:`size-3.5`})})]})]}),(0,q.jsx)(`input`,{ref:D,type:`file`,className:`hidden`,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&te(t)}}),(0,q.jsx)(`p`,{className:`mt-2 text-center font-mono text-[10px] text-ink-faint`,children:t&&e.supported?`Speak and pause to send · Enter sends now`:`Enter to send · Shift + Enter for a new line · / for skills and commands`})]})}function sn({focus:e,picking:t,onClear:n}){return!t&&!e?null:(0,q.jsxs)(`div`,{className:`enters mb-2 flex items-center gap-2 rounded-xl border border-ember/40 bg-ember/8 px-2.5 py-1.5 text-xs`,children:[(0,q.jsx)(U,{className:u(`size-3.5 shrink-0 text-ember`,t&&`animate-pulse`)}),t||!e?(0,q.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-ink-dim`,children:[`Point at anything on the page — `,(0,q.jsx)(`span`,{className:`text-ink-faint`,children:`Esc cancels`})]}):(0,q.jsxs)(q.Fragment,{children:[e.shot&&(0,q.jsx)(`img`,{src:e.shot,alt:`The element you picked`,className:`max-h-7 max-w-14 shrink-0 rounded border border-ember/40 object-cover`}),(0,q.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-ink`,children:[`A-Eye: `,(0,q.jsx)(`span`,{className:`font-medium`,children:an(e)})]}),(0,q.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] text-ink-faint`,children:e.tag}),(0,q.jsx)(`button`,{type:`button`,onClick:n,"aria-label":`Drop the A-Eye selection`,className:`shrink-0 rounded-full p-1 text-ink-faint transition-colors hover:bg-surface hover:text-ink`,children:(0,q.jsx)(W,{className:`size-3`})})]})]})}function cn({voice:e,voiceEnabled:t}){return t&&e.error?(0,q.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 rounded-lg border border-amber/40 bg-amber/10 px-2.5 py-1.5 text-[11px] text-amber`,children:[(0,q.jsx)(`span`,{className:`flex-1`,children:e.error}),e.needsGrant&&(0,q.jsx)(`button`,{type:`button`,onClick:e.grant,className:`shrink-0 rounded-full border border-amber/50 px-2 py-0.5 transition-colors hover:bg-amber/15`,children:`Allow microphone`})]}):e.pendingSend?(0,q.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 rounded-lg bg-brand/10 px-2.5 py-1.5 text-[11px] text-brand`,children:[(0,q.jsx)(`span`,{className:`relative flex-1 overflow-hidden rounded-full bg-brand/20`,children:(0,q.jsx)(`span`,{className:`block h-1 rounded-full bg-brand`,style:{animation:`browsentic-countdown ${e.autoSendMs}ms linear forwards`}})}),(0,q.jsx)(`span`,{className:`shrink-0`,children:`Sending…`}),(0,q.jsxs)(`button`,{type:`button`,onClick:e.cancelPending,className:`flex shrink-0 items-center gap-0.5 rounded-full px-1.5 py-0.5 transition-colors hover:bg-brand/15`,"aria-label":`Cancel sending`,children:[(0,q.jsx)(W,{className:`size-3`}),` Edit`]})]}):t&&e.listening?(0,q.jsxs)(`p`,{className:`mb-2 flex items-center gap-1.5 px-1 text-[11px] text-ink-dim`,children:[(0,q.jsx)(`span`,{className:`glow-dot inline-flex size-1.5 shrink-0 animate-pulse rounded-full bg-magenta text-magenta`}),e.interim?(0,q.jsx)(`span`,{className:`truncate italic`,children:e.interim}):(0,q.jsx)(`span`,{children:`Listening…`})]}):t&&!e.supported?(0,q.jsx)(`p`,{className:`mb-2 px-1 text-[11px] text-ink-faint`,children:`Voice input isn’t available in this browser.`}):null}function ln({files:e,onRemove:t}){return e.length===0?null:(0,q.jsx)(`div`,{className:`mb-2 flex max-h-40 flex-col gap-1.5 overflow-y-auto`,children:e.map(e=>(0,q.jsxs)(`div`,{className:`flex items-start gap-2 rounded-xl border border-line bg-ground/40 px-2.5 py-1.5 text-xs`,children:[(0,q.jsx)(Ve,{className:`mt-0.5 size-3.5 shrink-0 text-ink-faint`}),(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,q.jsx)(`span`,{className:`truncate font-medium text-ink`,children:e.name}),(0,q.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] text-ink-faint`,children:un(e.size)})]}),e.status===`pending`&&(0,q.jsxs)(`span`,{className:`mt-0.5 flex items-center gap-1 text-[11px] text-ink-faint`,children:[(0,q.jsx)(O,{className:`size-3 animate-spin`}),` Analyzing…`]}),e.status===`ready`&&e.summary&&(0,q.jsx)(`p`,{className:`mt-0.5 line-clamp-2 text-[11px] text-ink-dim`,children:e.summary}),e.status===`error`&&(0,q.jsx)(`span`,{className:`mt-0.5 block text-[11px] text-destructive`,children:e.error??`Analysis failed`})]}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>t(e.id),"aria-label":`Remove ${e.name}`,className:`mt-0.5 shrink-0 rounded-full p-1 text-ink-faint transition-colors hover:bg-surface hover:text-ink`,children:(0,q.jsx)(W,{className:`size-3`})})]},e.id))})}function un(e){return e<1024?`${e} B`:e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function dn({onClose:e}){return(0,q.jsxs)(`div`,{className:`enters max-h-[60%] shrink-0 overflow-y-auto border-b border-line bg-ground-2/80 px-3 py-3 backdrop-blur`,children:[(0,q.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-2`,children:[(0,q.jsx)(`p`,{className:`text-xs font-medium text-ink`,children:`Connection`}),(0,q.jsx)(f,{variant:`ghost`,size:`icon-sm`,"aria-label":`Close connection settings`,onClick:e,children:(0,q.jsx)(W,{className:`size-3.5`})})]}),(0,q.jsxs)(`div`,{className:`space-y-4`,children:[(0,q.jsx)(_e,{}),(0,q.jsx)(fe,{})]})]})}function fn({connected:e,maxBytes:t}){return(0,q.jsx)(`div`,{className:`enters pointer-events-none absolute inset-0 z-50 flex items-center justify-center bg-ground/85 p-4 backdrop-blur-[2px]`,children:(0,q.jsxs)(`div`,{className:u(`flex w-full flex-col items-center gap-2 rounded-2xl border-2 border-dashed px-4 py-8 text-center`,e?`border-brand/55 bg-brand/8`:`border-line-strong bg-surface/40`),children:[e?(0,q.jsx)(He,{className:`neon-text size-7 text-brand`}):(0,q.jsx)(vt,{className:`size-7 text-ink-faint`}),(0,q.jsx)(`p`,{className:`text-sm font-medium text-ink`,children:e?`Drop to attach`:`Not connected`}),(0,q.jsx)(`p`,{className:`text-[11px] leading-relaxed text-ink-dim`,children:e?`Release anywhere in the panel and I’ll read it with your next message — up to ${t/1024/1024} MB each.`:`Pair the browser before attaching a file.`})]})})}var pn=[`Summarise what this page says`,`Fill this form in with my details`,`Find the unpaid invoices and open the newest`],mn={unpaired:`This browser isn’t paired yet, so nothing can drive it. Pairing takes one command and one code.`,offline:`Paired, but the daemon isn’t answering. Start browsentic and this reconnects on its own.`,agent:`The chosen agent can’t run on this machine. Pick another one, or let Browsentic fix it.`};function hn({blocker:e,voiceOn:t,onGo:n,onFix:r,onUse:i}){return(0,q.jsxs)(`div`,{className:`dot-grid fade-bottom flex flex-col gap-4 p-4`,children:[(0,q.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[(0,q.jsx)(a,{className:`mt-0.5 size-7 shrink-0 text-brand`}),(0,q.jsx)(`div`,{className:`panel-card min-w-0 rounded-2xl rounded-tl-md px-3 py-2.5 text-sm leading-relaxed text-ink`,children:e?mn[e]:(0,q.jsxs)(q.Fragment,{children:[t?`Just talk`:`Tell me`,` what to do on this page — read it, fill something in, click through a flow — and every action shows up here as I take it.`]})})]}),e?(0,q.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:(0,q.jsx)(gn,{icon:st,label:e===`agent`?`Choose an agent`:`Set up the link`,onClick:r})}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:pn.map(e=>(0,q.jsx)(`button`,{type:`button`,onClick:()=>i(e),className:`rounded-xl border border-line bg-ground/40 px-3 py-2 text-left text-xs text-ink-dim transition-colors hover:border-brand/40 hover:bg-surface/60 hover:text-ink`,children:e},e))}),(0,q.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,q.jsx)(gn,{icon:je,label:`Teach it this site`,onClick:()=>n(`skills`)}),(0,q.jsx)(gn,{icon:B,label:`Record a flow`,onClick:()=>n(`recordings`)}),(0,q.jsx)(gn,{icon:ot,label:`Past chats`,onClick:()=>n(`history`)})]})]})]})}function gn({icon:e,label:t,onClick:n}){return(0,q.jsxs)(`button`,{type:`button`,onClick:n,className:`inline-flex items-center gap-1.5 rounded-full border border-line bg-ground-2/70 px-2.5 py-1 text-[11px] text-ink-dim transition-colors hover:border-brand/40 hover:text-ink`,children:[(0,q.jsx)(e,{className:`size-3`}),t]})}function _n({state:e,onStop:t}){let n=yn(e.startedAt),r=Math.max(0,e.timeoutMs-n),i=e.percent==null?null:Math.round(e.percent);return(0,q.jsxs)(`div`,{className:`enters mb-2 rounded-xl border border-magenta/35 bg-magenta/8 p-2.5`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(H,{className:`size-3.5 shrink-0 animate-pulse text-magenta`}),(0,q.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-xs font-medium text-ink`,children:[`Watching `,e.label??e.host]}),(0,q.jsxs)(`span`,{className:`shrink-0 font-mono text-[11px] tabular-nums text-ink-faint`,children:[bn(n),i!=null&&` · ${i}%`]}),(0,q.jsxs)(f,{size:`sm`,variant:`ghost`,className:`shrink-0 text-magenta hover:text-magenta`,onClick:t,children:[(0,q.jsx)(pt,{className:`size-3 fill-current`}),` Stop`]})]}),i!=null&&(0,q.jsx)(`div`,{className:`mt-2 h-1 overflow-hidden rounded-full bg-magenta/15`,children:(0,q.jsx)(`div`,{className:`glow-dot h-full rounded-full bg-magenta text-magenta transition-[width] duration-500`,style:{width:`${i}%`}})}),(0,q.jsx)(`p`,{className:`mt-1.5 text-[11px] leading-relaxed text-ink-faint`,children:vn(e,r)})]})}function vn(e,t){return e.stalledForMs==null?e.percent!=null&&e.etaMs!=null?`${Math.round(e.percent)}% · ${x(e.etaMs)} left`:e.logs.at(-1)?.text??`Stops automatically in ${bn(t)}.`:`No change for ${bn(e.stalledForMs)}.`}function yn(e){let[t,n]=(0,G.useState)(()=>Date.now());return(0,G.useEffect)(()=>{let e=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(e)},[]),Math.max(0,t-e)}function bn(e){let t=Math.floor(e/1e3);return`${Math.floor(t/60)}:${String(t%60).padStart(2,`0`)}`}var xn=[{id:`chat`,label:`Chat`,icon:$e},{id:`history`,label:`History`,icon:ot},{id:`skills`,label:`Skills`,icon:je},{id:`recordings`,label:`Recordings`,icon:B},{id:`settings`,label:`Settings`,icon:lt}];function Sn({tab:e,counts:t,onSelect:n}){let r=(0,G.useRef)(null),[i,a]=(0,G.useState)(`full`),o=(0,G.useRef)({full:0,active:0});return(0,G.useLayoutEffect)(()=>{let e=r.current;if(!e)return;let t=!0,n=()=>{if(!t)return;let n=e.clientWidth;i!==`icons`&&(o.current[i]=Cn(e));let{full:r,active:s}=o.current;a(r>0&&n>=r?`full`:i===`full`||n>=s?`active`:`icons`)};n();let s=new ResizeObserver(n);return s.observe(e),document.fonts.ready.then(n),()=>{t=!1,s.disconnect()}},[i,e,xn.map(({id:e})=>t[e]??0).join(`·`)]),(0,q.jsx)(`nav`,{ref:r,"aria-label":`Panel sections`,className:`flex shrink-0 items-center gap-0.5 overflow-x-auto border-b border-line px-2 pb-2 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden`,children:xn.map(({id:r,label:a,icon:o})=>{let s=e===r,c=t[r]??0,l=i===`full`||i===`active`&&s;return(0,q.jsxs)(`button`,{type:`button`,onClick:()=>n(r),title:l?void 0:a,"aria-label":a,"aria-current":s?`page`:void 0,className:u(`relative inline-flex shrink-0 items-center gap-1.5 rounded-full px-2.5 py-1.5 text-[11px] font-medium transition-colors`,s?`bg-brand/12 text-brand`:`text-ink-faint hover:bg-surface/60 hover:text-ink-dim`),children:[(0,q.jsx)(o,{className:`size-3.5`}),l&&a,c>0&&(l?(0,q.jsx)(`span`,{className:u(`rounded-full px-1 font-mono text-[9px] tabular-nums`,s?`bg-brand/20`:`bg-surface text-ink-faint`),children:c}):(0,q.jsx)(`span`,{className:u(`absolute top-1 right-1 size-1.5 rounded-full`,s?`bg-brand/70`:`bg-ink-faint/60`)}))]},r)})})}function Cn(e){let t=getComputedStyle(e),n=parseFloat(t.columnGap)||0,r=parseFloat(t.paddingLeft)+parseFloat(t.paddingRight),i=Array.from(e.children);return i.reduce((e,t)=>e+t.getBoundingClientRect().width,0)+n*Math.max(0,i.length-1)+r}function wn({state:e,onStop:t}){let n=Tn(e.startedAt),r=Math.max(0,w-n);return(0,q.jsxs)(`div`,{className:`enters mb-2 rounded-xl border border-destructive/40 bg-destructive/8 p-2.5`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(`span`,{className:`glow-dot size-2 shrink-0 animate-pulse rounded-full bg-destructive text-destructive`}),(0,q.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-xs font-medium text-ink`,children:[`Recording `,e.host]}),(0,q.jsxs)(`span`,{className:`shrink-0 font-mono text-[11px] tabular-nums text-ink-faint`,children:[En(n),` · `,e.events,` `,e.events===1?`step`:`steps`]}),(0,q.jsxs)(f,{size:`sm`,variant:`ghost`,className:`shrink-0 text-destructive hover:text-destructive`,onClick:t,children:[(0,q.jsx)(pt,{className:`size-3 fill-current`}),` Stop`]})]}),(0,q.jsxs)(`p`,{className:`mt-1.5 text-[11px] leading-relaxed text-ink-faint`,children:[e.warning??`Stops automatically in ${En(r)}.`,!e.captureValues&&` Typed values are not being saved.`]})]})}function Tn(e){let[t,n]=(0,G.useState)(()=>Date.now());return(0,G.useEffect)(()=>{let e=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(e)},[]),Math.max(0,t-e)}function En(e){let t=Math.floor(e/1e3);return`${Math.floor(t/60)}:${String(t%60).padStart(2,`0`)}`}var Dn=h(`inline-flex w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-full border px-2 py-0.5 font-mono text-[10px] tracking-[0.08em] whitespace-nowrap uppercase [&>svg]:pointer-events-none [&>svg]:size-2.5`,{variants:{variant:{default:`border-brand/35 bg-brand/12 text-brand`,secondary:`border-line-strong bg-surface/70 text-ink-dim`,destructive:`border-destructive/40 bg-destructive/12 text-destructive`,warning:`border-amber/40 bg-amber/12 text-amber`,outline:`border-line text-ink-faint`}},defaultVariants:{variant:`default`}});function On({className:e,variant:t,asChild:n=!1,...r}){return(0,q.jsx)(n?i:`span`,{"data-slot":`badge`,className:u(Dn({variant:t}),e),...r})}function kn({recordings:e,busy:t,onReplay:n,onRemove:r}){return e.length===0?(0,q.jsxs)(`div`,{className:`dot-grid fade-bottom rounded-xl border border-line px-3 py-6 text-center`,children:[(0,q.jsx)(B,{className:`mx-auto size-5 text-ink-faint`}),(0,q.jsx)(`p`,{className:`mt-2 text-[11px] leading-relaxed text-ink-faint`,children:`No recordings yet. Press Record above and walk through the flow you want repeated.`})]}):(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1.5`,children:[t&&(0,q.jsx)(`p`,{className:`px-1 pb-1 text-[11px] text-ink-faint`,children:`Waiting on the current run — stop it to replay a recording.`}),e.map(e=>(0,q.jsx)(An,{recording:e,busy:t===!0,onReplay:n,onRemove:r},e.id))]})}function An({recording:e,busy:t,onReplay:n,onRemove:r}){let[i,a]=(0,G.useState)(null),o=e.status===`ready`;return(0,q.jsxs)(`div`,{className:`flex items-start gap-2 rounded-xl border border-line bg-ground/40 px-2.5 py-2 text-xs`,children:[(0,q.jsx)(B,{className:`mt-0.5 size-3.5 shrink-0 text-ink-faint`}),(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[i===null?(0,q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,q.jsx)(`span`,{className:`truncate font-medium text-ink`,children:e.name}),e.capturedValues&&(0,q.jsxs)(On,{variant:`warning`,children:[(0,q.jsx)(Je,{}),` values`]})]}):(0,q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,q.jsx)(pe,{value:i,autoFocus:!0,onChange:e=>a(e.target.value),onKeyDown:t=>{t.key===`Escape`&&a(null),t.key===`Enter`&&(I(e.id,i),a(null))},"aria-label":`Recording name`,className:`h-7 text-xs`}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>{I(e.id,i),a(null)},"aria-label":`Save name`,className:`shrink-0 rounded-full p-1 text-ink-faint transition-colors hover:bg-surface hover:text-ink`,children:(0,q.jsx)(R,{className:`size-3`})})]}),(0,q.jsxs)(`span`,{className:`mt-0.5 flex items-center gap-1 font-mono text-[10px] text-ink-faint`,children:[(0,q.jsx)(V,{className:`size-2.5 shrink-0`}),(0,q.jsx)(`span`,{className:`truncate`,children:e.host})]}),e.goal&&e.goal!==e.name&&(0,q.jsx)(`p`,{className:`mt-0.5 line-clamp-2 text-[11px] text-ink-dim`,children:e.goal}),(0,q.jsx)(`span`,{className:`mt-0.5 flex items-center gap-1 text-[11px] text-ink-faint`,children:e.status===`analyzing`?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(O,{className:`size-3 animate-spin`}),` Splitting into steps…`]}):e.status===`error`?(0,q.jsx)(`span`,{className:`text-destructive`,children:e.error??`Could not read this recording`}):(0,q.jsxs)(q.Fragment,{children:[e.steps??0,` `,e.steps===1?`step`:`steps`,` · `,Pn(e.durationMs),` ·`,` `,Fn(e.updatedAt)]})}),o&&(0,q.jsxs)(`button`,{type:`button`,onClick:()=>n(e),disabled:t,className:`mt-1.5 inline-flex items-center gap-1 rounded-full bg-brand/12 px-2 py-0.5 text-[11px] text-brand transition-colors hover:bg-brand/20 disabled:opacity-50`,children:[(0,q.jsx)(at,{className:`size-3`}),` Do this again`]})]}),(0,q.jsxs)(`div`,{className:`mt-0.5 flex shrink-0 gap-0.5`,children:[(0,q.jsx)(`button`,{type:`button`,onClick:()=>a(e.name),"aria-label":`Rename ${e.name}`,className:`rounded-full p-1 text-ink-faint transition-colors hover:bg-surface hover:text-ink`,children:(0,q.jsx)(it,{className:`size-3`})}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>r(e.id),"aria-label":`Delete ${e.name}`,className:`rounded-full p-1 text-ink-faint transition-colors hover:bg-surface hover:text-ink`,children:(0,q.jsx)(W,{className:`size-3`})})]})]})}var jn=6e4,Mn=60*jn,Nn=24*Mn;function Pn(e){let t=Math.round(e/1e3);return t<60?`${t}s`:`${Math.floor(t/60)}m ${String(t%60).padStart(2,`0`)}s`}function Fn(e){let t=Date.now()-e;return t<jn?`just now`:t<Mn?`${Math.floor(t/jn)}m ago`:t<Nn?`${Math.floor(t/Mn)}h ago`:t<7*Nn?`${Math.floor(t/Nn)}d ago`:new Date(e).toLocaleDateString(void 0,{month:`short`,day:`numeric`})}function In({tabUrl:e,recordings:t,recording:n,busy:r,onStart:i,onStop:a,onReplay:o,onRemove:s}){let[c,l]=(0,G.useState)(!1),u=Pt(e),d=!r&&!n&&/^https?:/.test(e);return(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3 p-3`,children:[(0,q.jsx)(`p`,{className:`text-[11px] leading-relaxed text-ink-dim`,children:`Capture what you do on a site — the clicks, the fields you fill, the pages you move through — and the agent can repeat it later. A recording runs for at most 15 minutes.`}),n?(0,q.jsxs)(f,{variant:`destructive`,onClick:a,children:[(0,q.jsx)(pt,{className:`fill-current`}),` Stop recording`]}):(0,q.jsxs)(f,{variant:`destructive`,onClick:()=>i(c),disabled:!d,title:d?`Record what you do on ${u}`:`Open an http(s) page, with nothing else running`,children:[(0,q.jsx)(Pe,{className:`fill-current`}),(0,q.jsxs)(`span`,{className:`truncate`,children:[`Record `,u||`this page`]})]}),!n&&(0,q.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 rounded-xl border border-line bg-ground/40 px-2.5 py-2 text-[11px] leading-relaxed text-ink-dim`,children:[(0,q.jsx)(`input`,{type:`checkbox`,checked:c,onChange:e=>l(e.target.checked),className:`mt-0.5 size-3 shrink-0 accent-destructive`}),(0,q.jsxs)(`span`,{children:[(0,q.jsx)(`span`,{className:`font-medium text-ink`,children:`Save what I type.`}),` Off by default — every field becomes a placeholder the agent asks you to fill. Passwords and card numbers are never saved either way.`]})]}),(0,q.jsx)(kn,{recordings:t,busy:r,onReplay:o,onRemove:s})]})}var Ln=e(r(),1);function Rn({purpose:e,code:t,site:n,onAllow:r,onDeny:i,onClose:a}){return(0,G.useEffect)(()=>{let e=e=>{e.key===`Escape`&&a()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[a]),(0,Ln.createPortal)((0,q.jsxs)(`div`,{className:`enters fixed inset-0 z-50 flex flex-col bg-ground/96 backdrop-blur`,children:[(0,q.jsxs)(`div`,{className:`flex items-start gap-2 border-b border-ember/30 bg-ember/8 px-3 py-2.5`,children:[(0,q.jsx)(ct,{className:`mt-0.5 size-3.5 shrink-0 text-ember`}),(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsx)(`p`,{className:`text-xs font-medium text-ink`,children:`Code the agent wrote`}),(0,q.jsx)(`p`,{className:`mt-0.5 text-[11px] leading-relaxed text-ink-dim`,children:e})]}),(0,q.jsx)(`button`,{type:`button`,onClick:a,title:`Close without deciding`,className:`mt-0.5 shrink-0 rounded p-0.5 text-ink-faint transition-colors hover:text-ink`,children:(0,q.jsx)(W,{className:`size-3.5`})})]}),(0,q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto bg-ground/70`,children:(0,q.jsx)(`pre`,{className:`min-w-full p-3 font-mono text-[11px] leading-relaxed whitespace-pre text-ink-dim`,children:(0,q.jsx)(`code`,{children:t})})}),(0,q.jsxs)(`div`,{className:`border-t border-line px-3 py-2.5`,children:[(0,q.jsxs)(`p`,{className:`mb-2 text-[11px] leading-relaxed text-ink-faint`,children:[`This runs in `,n?(0,q.jsx)(`span`,{className:`font-mono text-ink`,children:n}):`the page`,` with your logged-in session, and can do anything you could do there. Later calls reuse these functions without asking again.`]}),(0,q.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,q.jsxs)(f,{variant:`ghost`,size:`sm`,className:`flex-1`,onClick:i,children:[(0,q.jsx)(W,{className:`size-3`}),` Deny`]}),(0,q.jsxs)(f,{size:`sm`,className:`flex-1`,onClick:r,children:[(0,q.jsx)(R,{className:`size-3`}),` Allow`]})]})]})]}),document.body)}var zn=[{key:`user`,label:`you`,color:`bg-brand`},{key:`assistant`,label:`replies`,color:`bg-magenta`},{key:`tools`,label:`tools`,color:`bg-amber`},{key:`notices`,label:`notices`,color:`bg-ink-faint`}];function Bn({breakdown:e}){let{messages:t,files:n,recordings:r,filesOmitted:i,recordingsOmitted:a}=e,o=zn.reduce((e,n)=>e+t[n.key],0),s=o===0&&n.length===0&&r.length===0;return(0,q.jsxs)(`div`,{className:`enters panel-card min-w-0 rounded-2xl px-3 py-2.5`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(Xe,{className:`size-3.5 shrink-0 text-brand`}),(0,q.jsx)(`span`,{className:`flex-1 truncate font-mono text-[10px] tracking-[0.14em] text-ink uppercase`,children:`Session context`}),(0,q.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1 rounded-full bg-ground/60 px-2 py-0.5 font-mono text-[9px] tracking-[0.1em] text-ink-faint uppercase`,children:[e.agent&&(0,q.jsx)(re,{kind:e.agent,className:`size-2.5`}),Hn(e)]})]}),s?(0,q.jsx)(`p`,{className:`mt-2 text-[11px] text-ink-dim`,children:`This conversation is empty — nothing rides along yet.`}):(0,q.jsxs)(q.Fragment,{children:[o>0&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`div`,{className:`mt-2.5 flex h-1.5 gap-px overflow-hidden rounded-full`,children:zn.filter(e=>t[e.key]>0).map(e=>(0,q.jsx)(`span`,{className:e.color,style:{flexGrow:t[e.key]}},e.key))}),(0,q.jsx)(`div`,{className:`mt-1.5 flex flex-wrap gap-x-3 gap-y-0.5`,children:zn.map(e=>(0,q.jsxs)(`span`,{className:`flex items-center gap-1 text-[10px] text-ink-dim`,children:[(0,q.jsx)(`span`,{className:u(`size-1.5 shrink-0 rounded-full`,e.color)}),(0,q.jsx)(`span`,{className:`font-mono`,children:t[e.key]}),` `,e.label]},e.key))})]}),(0,q.jsxs)(`div`,{className:`mt-2.5 flex flex-col gap-1 border-t border-line pt-2`,children:[(0,q.jsxs)(Vn,{icon:V,children:[e.tabCount===1?`1 tab`:`${e.tabCount} tabs`,e.host&&(0,q.jsxs)(q.Fragment,{children:[` · `,e.host]}),` · turn`,` `,(0,q.jsx)(`span`,{className:`font-mono text-[10px]`,children:e.turns}),` ·`,` `,(0,q.jsx)(`span`,{className:`font-mono text-[10px]`,children:Un(t.chars)}),` characters`]}),(0,q.jsx)(Vn,{icon:Re,children:e.usage?(0,q.jsxs)(q.Fragment,{children:[`Agent window ≈ `,(0,q.jsx)(`span`,{className:`font-mono text-[10px]`,children:Un(e.usage.contextTokens)}),` `,`tokens · `,(0,q.jsx)(`span`,{className:`font-mono text-[10px]`,children:Un(e.usage.outputTokens)}),` `,`generated last run`]}):e.agent===`antigravity`?`Antigravity does not report token counts.`:e.agent===`vibe`?`Mistral Vibe does not report token counts.`:`Token counts appear after the agent’s first reply.`}),n.map((e,t)=>(0,q.jsxs)(Vn,{icon:Ve,children:[(0,q.jsx)(`span`,{className:`text-ink`,children:e.name}),(0,q.jsxs)(`span`,{className:`font-mono text-[10px] text-ink-faint`,children:[` · `,Wn(e.size)]}),e.status===`pending`&&(0,q.jsx)(`span`,{className:`text-ink-faint`,children:` · analyzing`}),e.status===`error`&&(0,q.jsx)(`span`,{className:`text-destructive`,children:` · analysis failed`})]},t)),i>0&&(0,q.jsxs)(`p`,{className:`pl-[18px] text-[10px] text-ink-faint`,children:[i,` more `,i===1?`file stays`:`files stay`,` behind — only the first`,` `,n.length,` ride along.`]}),r.map((e,t)=>(0,q.jsxs)(Vn,{icon:B,children:[(0,q.jsx)(`span`,{className:`text-ink`,children:e.name}),e.steps!==void 0&&(0,q.jsxs)(`span`,{className:`font-mono text-[10px] text-ink-faint`,children:[` · `,e.steps,` steps`]})]},t)),a>0&&(0,q.jsxs)(`p`,{className:`pl-[18px] text-[10px] text-ink-faint`,children:[a,` more `,a===1?`recording stays`:`recordings stay`,` behind — only the first `,r.length,` ride along.`]})]})]}),(0,q.jsx)(`p`,{className:`mt-2 text-[10px] leading-relaxed text-ink-faint`,children:`Held in this browser — files and ready recordings ride along with your next message.`})]})}function Vn({icon:e,children:t}){return(0,q.jsxs)(`div`,{className:`flex min-w-0 items-start gap-1.5 text-[11px] text-ink-dim`,children:[(0,q.jsx)(e,{className:`mt-0.5 size-3 shrink-0 text-ink-faint`}),(0,q.jsx)(`span`,{className:`min-w-0 flex-1 break-words`,children:t})]})}function Hn(e){return e.agent?`${E[e.agent].label}${e.resumes?` · resumes`:``}`:`no agent yet`}function Un(e){return e<1e3?String(e):`${(e/1e3).toFixed(+(e<1e4))} k`}function Wn(e){return e<1024?`${e} B`:e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function Gn({text:e,streaming:t,className:n}){let r=(0,G.useRef)(!1);t&&(r.current=!0);let i=(0,G.useMemo)(()=>nr(e).map(e=>({block:e,sig:JSON.stringify(e)})),[e]);return(0,q.jsx)(`div`,{"data-stream":t?`live`:r.current?`done`:void 0,className:u(`flex min-w-0 flex-col gap-2`,n),children:i.map(({block:e,sig:t},n)=>(0,q.jsx)(Kn,{block:e,sig:t},n))})}var Kn=(0,G.memo)(({block:e})=>dr(e,`0`),(e,t)=>e.sig===t.sig),qn=/^ {0,3}(`{3,}|~{3,})[^\n]*$/,Jn=/^ {0,3}(?:`{3,}|~{3,})[ \t]*([^\s`~]*)/,Yn=/^ {0,3}(`{3,}|~{3,})[ \t]*$/,Xn=/^ {0,3}(#{1,6})[ \t]+(.*?)[ \t]*#*[ \t]*$/,Zn=/^ {0,3}([-*_])[ \t]*(?:\1[ \t]*){2,}$/,Qn=/^ {0,3}>[ \t]?/,$n=/^([ \t]*)(?:([-*+])|(\d{1,9})[.)])[ \t]+(.*)$/,er=/^ {0,3}\|?[ \t]*:?-+:?[ \t]*(?:\|[ \t]*:?-+:?[ \t]*)+\|?[ \t]*$/,tr=12;function nr(e,t=0){let n=e.replace(/\r\n?/g,`
|
|
4
|
-
`).split(`
|
|
5
|
-
`);if(t>=tr){let e=n.filter(e=>e.trim()).join(`
|
|
6
|
-
`);return e?[{kind:`paragraph`,text:e}]:[]}let r=[];for(let e=0;e<n.length;){let i=n[e];if(!i.trim()){e++;continue}if(qn.test(i)){let t=/^ {0,3}(`{3,}|~{3,})/.exec(i)[1],a=[];for(e++;e<n.length;){let r=Yn.exec(n[e]);if(r&&r[1][0]===t[0]&&r[1].length>=t.length){e++;break}a.push(n[e]),e++}r.push({kind:`code`,lang:Jn.exec(i)?.[1]||void 0,text:a.join(`
|
|
7
|
-
`)});continue}let a=Xn.exec(i);if(a){r.push({kind:`heading`,level:a[1].length,text:a[2]}),e++;continue}if(Zn.test(i)){r.push({kind:`rule`}),e++;continue}if(Qn.test(i)){let i=[];for(;e<n.length&&(Qn.test(n[e])||i.length>0&&n[e].trim());)i.push(n[e].replace(Qn,``)),e++;r.push({kind:`quote`,blocks:nr(i.join(`
|
|
8
|
-
`),t+1)});continue}let o=$n.exec(i);if(o){let[i,a]=ir(n,e,o,t);r.push(i),e=a;continue}if(ar(n,e)){let[t,i]=or(n,e);r.push(t),e=i;continue}let s=[];for(;e<n.length&&n[e].trim()&&!rr(n,e);)s.push(n[e].trim()),e++;r.push({kind:`paragraph`,text:s.join(`
|
|
9
|
-
`)})}return r}function rr(e,t){let n=e[t];return qn.test(n)||Xn.test(n)||Zn.test(n)||Qn.test(n)||$n.test(n)||ar(e,t)}function ir(e,t,n,r){let i=cr(n[1]),a=n[3]!==void 0,o=[],s=t;for(;s<e.length;){let t=$n.exec(e[s]);if(!t||t[3]!==void 0!==a)break;let n=cr(t[1]);if(n<i||n>i+1)break;let r=[t[4]];for(s++;s<e.length;){let t=e[s];if(!t.trim()){let t=e[s+1]??``;if(!t.trim()||cr(t)<=i)break;r.push(``),s++;continue}if(cr(t)<=i)break;r.push(lr(t,i+2)),s++}o.push(r)}return[{kind:`list`,ordered:a,start:a?Number.parseInt(n[3],10):1,items:o.map(e=>nr(e.join(`
|
|
10
|
-
`),r+1))},s]}function ar(e,t){return e[t].includes(`|`)&&t+1<e.length&&er.test(e[t+1])}function or(e,t){let n=sr(e[t]),r=sr(e[t+1]).map(e=>e.startsWith(`:`)&&e.endsWith(`:`)?`center`:e.endsWith(`:`)?`right`:`left`),i=[],a=t+2;for(;a<e.length&&e[a].trim()&&e[a].includes(`|`)&&!rr(e,a);)i.push(sr(e[a])),a++;return[{kind:`table`,head:n,align:r,rows:i},a]}function sr(e){let t=[],n=``;for(let r=0;r<e.length;r++){if(e[r]===`\\`&&e[r+1]===`|`){n+=`|`,r++;continue}if(e[r]===`|`){t.push(n),n=``;continue}n+=e[r]}return t.push(n),t[0].trim()||t.shift(),t.length&&!t[t.length-1]?.trim()&&t.pop(),t.map(e=>e.trim())}function cr(e){let t=/^[ \t]*/.exec(e)[0];return t.length+(t.match(/\t/g)?.length??0)}var lr=(e,t)=>e.replace(/^[ \t]+/,e=>e.replace(/\t/g,` `).slice(t)),ur=`rounded bg-surface px-1 py-px font-mono text-[0.85em] text-ink`;function dr(e,t){switch(e.kind){case`heading`:return(0,q.jsx)(`h${Math.min(e.level+1,6)}`,{className:u(`wrap-anywhere font-semibold`,e.level<=2&&`text-[0.95rem]`),children:J(e.text)},t);case`paragraph`:return(0,q.jsx)(`p`,{className:`wrap-anywhere`,children:J(e.text)},t);case`code`:return(0,q.jsx)(`pre`,{className:`max-w-full overflow-x-auto rounded-lg border border-line bg-ground/70 p-2 text-xs whitespace-pre`,children:(0,q.jsx)(`code`,{className:`font-mono`,children:e.text})},t);case`list`:{let n=e.items.map((e,t)=>(0,q.jsx)(`li`,{className:`wrap-anywhere`,children:pr(e)},t));return e.ordered?(0,q.jsx)(`ol`,{start:e.start,className:`list-decimal space-y-1 pl-5`,children:n},t):(0,q.jsx)(`ul`,{className:`list-disc space-y-1 pl-5`,children:n},t)}case`quote`:return(0,q.jsx)(`blockquote`,{className:`flex flex-col gap-2 border-l-2 border-brand/40 pl-2.5 text-ink-dim`,children:e.blocks.map((e,t)=>dr(e,String(t)))},t);case`table`:return(0,q.jsx)(`div`,{className:`max-w-full overflow-x-auto`,children:(0,q.jsxs)(`table`,{className:`w-full border-collapse text-left text-xs`,children:[(0,q.jsx)(`thead`,{children:(0,q.jsx)(`tr`,{children:e.head.map((t,n)=>(0,q.jsx)(`th`,{className:u(`border-b border-line-strong px-1.5 py-1 font-semibold`,fr[e.align[n]??`left`]),children:J(t)},n))})}),(0,q.jsx)(`tbody`,{children:e.rows.map((t,n)=>(0,q.jsx)(`tr`,{children:t.map((t,n)=>(0,q.jsx)(`td`,{className:u(`border-b border-line px-1.5 py-1 align-top`,fr[e.align[n]??`left`]),children:J(t)},n))},n))})]})},t);case`rule`:return(0,q.jsx)(`hr`,{className:`border-line`},t)}}var fr={left:`text-left`,center:`text-center`,right:`text-right`};function pr(e){return e.length===1&&e[0].kind===`paragraph`?J(e[0].text):(0,q.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:e.map((e,t)=>dr(e,String(t)))})}var mr=4,hr="`*_~[!<h",gr=/[\\`*_~[\]()#+\-.!>|]/,_r=512,vr=2048,yr=3080,br=[{re:/(`+)([^`]+?)\1(?!`)/y,node:(e,t)=>(0,q.jsx)(`code`,{className:ur,children:e[2]},t)},{re:/\*\*(?!\s)([^\n]+?)\*\*/y,node:(e,t,n,r)=>(0,q.jsx)(`strong`,{children:J(e[1],n+1,r)},t)},{re:/__(?!\s)([^\n]+?)__/y,node:(e,t,n,r)=>(0,q.jsx)(`strong`,{children:J(e[1],n+1,r)},t)},{re:/~~(?!\s)([^\n]+?)~~/y,node:(e,t,n,r)=>(0,q.jsx)(`del`,{children:J(e[1],n+1,r)},t)},{re:/\*(?!\s)([^*\n]+?)\*/y,node:(e,t,n,r)=>(0,q.jsx)(`em`,{children:J(e[1],n+1,r)},t)},{re:/(?<![\w\\])_(?!\s)([^_\n]+?)_(?!\w)/y,node:(e,t,n,r)=>(0,q.jsx)(`em`,{children:J(e[1],n+1,r)},t)},{re:RegExp(`!\\[([^\\]\\n]{0,${_r}})\\]\\([ \\t]*([^)\\s]{0,${vr}})[^)\\n]{0,${_r}}\\)`,`y`),linking:!0,node:(e,t,n)=>Sr(e[2],e[1]||e[2],t,n)},{re:RegExp(`\\[([^\\]\\n]{0,${_r}})\\]\\([ \\t]*([^)\\s]{0,${vr}})[^)\\n]{0,${_r}}\\)`,`y`),linking:!0,node:(e,t,n)=>Sr(e[2],e[1],t,n)},{re:/<(https?:\/\/[^>\s]+)>/y,linking:!0,node:(e,t,n)=>Sr(e[1],e[1],t,n)},{re:/https?:\/\/[^\s<>"'`]*[^\s<>"'`.,;:!?)\]}]/y,linking:!0,node:(e,t,n)=>Sr(e[0],e[0],t,n)}],xr=/(?<=\s)(?=\S)/;function J(e,t=0,n=!1){let r=[],i=``,a=0,o=0,s=()=>{i&&i.split(xr).forEach((e,t)=>{r.push((0,q.jsx)(`span`,{className:`tok`,children:e},`t${a}.${t}`))}),i=``,a=o+1},c=e.indexOf(`)`);for(;o<e.length;){let a=e[o];if(a===`\\`&&o+1<e.length&&gr.test(e[o+1])){i+=e[o+1],o+=2;continue}if(a===`
|
|
11
|
-
`){s(),r.push((0,q.jsx)(`br`,{},`br${o}`)),o++;continue}if((a===`[`||a===`!`)&&(c!==-1&&c<o&&(c=e.indexOf(`)`,o)),c===-1||c-o>yr)){i+=a,o++;continue}let l=!1;if(t<mr&&hr.includes(a))for(let i of br){if(n&&i.linking)continue;i.re.lastIndex=o;let a=i.re.exec(e),c=i.re.lastIndex;if(!(!a||c<=o)){s(),r.push(i.node(a,`n${o}`,t,n)),o=c,l=!0;break}}l||(i+=a,o++)}return s(),r}function Sr(e,t,n,r){let i=Cr(e),a=J(t,r+1,!0);return i?(0,q.jsx)(`a`,{href:i,target:`_blank`,rel:`noreferrer noopener`,className:`underline decoration-1 underline-offset-2 hover:opacity-80`,children:a},n):(0,q.jsx)(`span`,{children:a},n)}function Cr(e){let t=e.trim();return/^(https?:\/\/|mailto:)/i.test(t)?t:null}function wr({items:e,running:t,onDecide:n}){let r=e.at(-1),i=t&&r?.kind===`assistant`,a=t&&!i;return(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2.5 p-3`,children:[e.map((t,r)=>t.kind===`tool`?(0,q.jsx)(Or,{item:t,onDecide:n},t.id):t.kind===`notice`?(0,q.jsx)(jr,{item:t},t.id):t.kind===`context`?(0,q.jsx)(Bn,{breakdown:t.breakdown},t.id):t.kind===`user`?(0,q.jsx)(Tr,{text:t.text,focus:t.focus},t.id):(0,q.jsx)(Er,{text:t.text,streaming:i&&r===e.length-1},t.id)),a&&(0,q.jsx)(Dr,{})]})}function Tr({text:e,focus:t}){return(0,q.jsxs)(`div`,{className:`enters flex min-w-0 flex-col items-end gap-1`,children:[(0,q.jsx)(`div`,{className:`min-w-0 max-w-[88%] rounded-2xl rounded-br-md border border-brand/30 bg-brand/10 px-3 py-2 text-sm whitespace-pre-wrap wrap-anywhere text-ink`,children:e}),t&&(0,q.jsxs)(`span`,{className:`flex min-w-0 max-w-[88%] items-center gap-1 rounded-full bg-ember/12 px-2 py-0.5 text-[10px] text-ember`,children:[(0,q.jsx)(U,{className:`size-2.5 shrink-0`}),(0,q.jsx)(`span`,{className:`truncate`,children:t})]})]})}function Er({text:e,streaming:t}){return(0,q.jsx)(`div`,{className:`enters min-w-0`,children:(0,q.jsx)(Gn,{text:e,streaming:t,className:`panel-card rounded-2xl rounded-tl-md px-3 py-2.5 text-sm leading-relaxed text-ink`})})}function Dr(){return(0,q.jsxs)(`div`,{className:`flex items-center gap-2 px-1`,children:[(0,q.jsx)(`span`,{className:`flex items-center gap-1`,children:[0,1,2].map(e=>(0,q.jsx)(`span`,{className:`think-dot size-1.5 rounded-full bg-brand`},e))}),(0,q.jsx)(`span`,{className:`font-mono text-[10px] tracking-[0.14em] text-ink-faint uppercase`,children:`Working`})]})}function Or({item:e,onDecide:t}){let n=e.action.replace(/^page\./,``),r=Mr[n]??bt,i=e.ok===void 0&&!e.awaiting,a=e.action===N.name?kr(e.input):null,[o,s]=(0,G.useState)(!1);return(0,G.useEffect)(()=>{e.awaiting||s(!1)},[e.awaiting]),(0,q.jsxs)(`div`,{className:`enters flex min-w-0 flex-col gap-1.5`,children:[(0,q.jsxs)(`div`,{className:u(`relative flex min-w-0 items-start gap-2 overflow-hidden rounded-lg border px-2 py-1.5 transition-colors`,e.awaiting?`border-ember/45 bg-ember/10`:e.ok===!1?`border-destructive/40 bg-destructive/8`:`border-line bg-ground/40`,i&&`sweep`),children:[(0,q.jsx)(r,{className:u(`mt-0.5 size-3 shrink-0`,e.awaiting?`text-ember`:e.ok===!1?`text-destructive`:e.source===`local`?`text-amber`:e.source===`external`?`text-magenta`:`text-brand`)}),(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,q.jsx)(`span`,{className:`truncate font-mono text-[10px] text-ink`,children:n}),e.source===`local`&&(0,q.jsx)(Ar,{tone:`amber`,icon:xt,label:`local`}),e.source===`external`&&(0,q.jsx)(Ar,{tone:`magenta`,icon:mt,label:`mcp`})]}),e.summary&&(0,q.jsx)(`p`,{className:u(`mt-0.5 truncate text-[10px]`,e.ok===!1?`text-destructive`:`text-ink-faint`),children:e.summary})]}),e.ok===!0&&(0,q.jsx)(R,{className:`mt-0.5 size-3 shrink-0 text-lime/80`}),e.ok===!1&&(0,q.jsx)(W,{className:`mt-0.5 size-3 shrink-0 text-destructive`})]}),e.preview&&(0,q.jsx)(`button`,{type:`button`,onClick:()=>void Oe(e.preview),title:`Open the ${e.preview.full?`full-size`:`captured`} screenshot in a new tab`,className:`group max-w-[88%] overflow-hidden rounded-xl border border-line bg-ground/60 transition-colors hover:border-brand/50`,children:(0,q.jsx)(`img`,{src:e.preview.thumbnail,alt:`Screenshot, ${e.preview.width}×${e.preview.height}`,width:e.preview.width,height:e.preview.height,className:`block h-auto w-full transition-opacity group-hover:opacity-85`})}),e.awaiting&&(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 rounded-lg border border-ember/45 bg-ember/10 px-2.5 py-2`,children:[(0,q.jsx)(`p`,{className:`flex-1 text-xs text-ink`,children:a?`Allow this code to run?`:`Allow this action?`}),a&&(0,q.jsx)(f,{size:`sm`,variant:`ghost`,onClick:()=>s(!0),title:`Read the code before deciding`,children:`Review`}),(0,q.jsx)(f,{size:`sm`,variant:`ghost`,onClick:()=>t(e.id,!1),children:`Deny`}),e.site&&!a&&(0,q.jsxs)(f,{size:`sm`,variant:`ghost`,onClick:()=>t(e.id,!0,!0),title:`Stop asking for ${n} on ${e.site}. Undo with “browsentic approvals clear”.`,children:[`Always on `,e.site]}),(0,q.jsx)(f,{size:`sm`,onClick:()=>t(e.id,!0),children:`Allow`})]}),o&&a&&(0,q.jsx)(Rn,{purpose:a.purpose,code:a.code,site:e.site,onAllow:()=>t(e.id,!0),onDeny:()=>t(e.id,!1),onClose:()=>s(!1)})]})}function kr(e){let t=e;return typeof t?.code!=`string`||!t.code?null:{purpose:typeof t.purpose==`string`?t.purpose:`No purpose given.`,code:t.code}}function Ar({tone:e,icon:t,label:n}){return(0,q.jsxs)(`span`,{className:u(`inline-flex shrink-0 items-center gap-0.5 rounded-full px-1.5 py-px font-mono text-[8px] tracking-[0.1em] uppercase`,e===`amber`?`bg-amber/15 text-amber`:`bg-magenta/15 text-magenta`),children:[(0,q.jsx)(t,{className:`size-2`}),n]})}function jr({item:e}){let t=e.tone===`error`;return(0,q.jsxs)(`div`,{className:u(`enters flex items-start gap-2 rounded-lg px-2.5 py-1.5 text-[11px] leading-relaxed`,t?`border border-destructive/35 bg-destructive/8 text-destructive`:`text-ink-faint`),children:[t?(0,q.jsx)(L,{className:`mt-px size-3 shrink-0`}):(0,q.jsx)(qe,{className:`mt-px size-3 shrink-0`}),(0,q.jsx)(`span`,{className:`min-w-0 break-words`,children:e.text})]})}var Mr={getPageInfo:Be,extractText:Be,pickElement:U,"browsentic.focusShot":U,findProgress:Be,clickElement:et,trustedClick:et,hoverElement:et,fillInput:_t,typeText:_t,focusInput:ht,selectText:ht,pressKey:Ye,submitForm:Le,selectOption:Ze,navigate:Ie,openTab:ze,switchTab:ze,closeTab:W,screenshot:Ne,scrollTo:tt,highlightElement:We,waitForElement:Ge,attachFile:rt,listFiles:rt,startMonitor:H,stopMonitor:H,monitorStatus:H,awaitMonitor:H,listRecordings:B,readRecording:B,injectCode:Fe,runCode:Me};function Nr({offer:e,onKeep:t,onDismiss:n}){let[r,i]=(0,G.useState)(e.suggestedSlug);(0,G.useEffect)(()=>i(e.suggestedSlug),[e.suggestedSlug]);let a=qt(r)||e.suggestedSlug,o=e.segment===`root`?e.host:`${e.host}/${e.segment}`;return(0,q.jsxs)(`div`,{className:`enters mb-2 rounded-xl border border-lime/30 bg-lime/8 px-3 py-2.5`,children:[(0,q.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,q.jsx)(xt,{className:`mt-0.5 size-3.5 shrink-0 text-lime`}),(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsxs)(`p`,{className:`text-xs font-medium text-ink`,children:[`Keep this as a tool for `,o,`?`]}),(0,q.jsx)(`p`,{className:`mt-0.5 text-[11px] leading-relaxed text-ink-dim`,children:e.purpose})]})]}),(0,q.jsxs)(`label`,{className:`mt-2.5 block`,children:[(0,q.jsx)(`span`,{className:`sr-only`,children:`Tool name`}),(0,q.jsxs)(`span`,{className:`flex items-center rounded-lg border border-line bg-ground/60 px-2 py-1 font-mono text-[10px]`,children:[(0,q.jsxs)(`span`,{className:`shrink-0 text-ink-faint`,children:[e.host,`:`,e.segment,`:`]}),(0,q.jsx)(`input`,{value:r,onChange:e=>i(e.target.value),spellCheck:!1,"aria-label":`Tool name`,className:`min-w-0 flex-1 bg-transparent text-ink outline-none`})]})]}),(0,q.jsxs)(`p`,{className:`mt-1 font-mono text-[10px] text-ink-faint`,children:[`runs with /`,Gt({host:e.host,segment:e.segment},a)]}),(0,q.jsxs)(`div`,{className:`mt-2.5 flex gap-1.5`,children:[(0,q.jsxs)(f,{variant:`ghost`,size:`sm`,className:`flex-1`,onClick:n,children:[(0,q.jsx)(W,{className:`size-3`}),` No`]}),(0,q.jsxs)(f,{size:`sm`,className:`flex-1`,onClick:()=>t(a),children:[(0,q.jsx)(R,{className:`size-3`}),` Yes, keep it`]})]})]})}function Pr({tools:e,onForget:t,onClose:n}){return(0,G.useEffect)(()=>{let e=e=>{e.key===`Escape`&&n()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n]),(0,Ln.createPortal)((0,q.jsxs)(`div`,{className:`enters fixed inset-0 z-50 flex flex-col bg-ground/96 backdrop-blur`,children:[(0,q.jsxs)(`div`,{className:`flex items-start gap-2 border-b border-line px-3 py-2.5`,children:[(0,q.jsx)(xt,{className:`mt-0.5 size-3.5 shrink-0 text-lime`}),(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsx)(`p`,{className:`text-xs font-medium text-ink`,children:`Your tools`}),(0,q.jsx)(`p`,{className:`mt-0.5 text-[11px] leading-relaxed text-ink-dim`,children:`Removing one deletes its code from the browser and its note from the daemon.`})]}),(0,q.jsx)(`button`,{type:`button`,onClick:n,title:`Close`,className:`mt-0.5 shrink-0 rounded p-0.5 text-ink-faint transition-colors hover:text-ink`,children:(0,q.jsx)(W,{className:`size-3.5`})})]}),(0,q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:e.length===0?(0,q.jsx)(`p`,{className:`px-3 py-4 text-[11px] leading-relaxed text-ink-faint`,children:`Nothing saved yet. Turn the Live tool switch on, ask for something the ordinary tools cannot do, and you will be offered the result to keep.`}):(0,q.jsx)(`ul`,{className:`divide-y divide-line`,children:e.map(e=>(0,q.jsxs)(`li`,{className:`flex items-start gap-2 px-3 py-2.5`,children:[(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsx)(`p`,{className:`truncate font-mono text-[11px] text-ink`,children:e.name}),(0,q.jsx)(`p`,{className:`mt-0.5 text-[11px] leading-relaxed text-ink-dim`,children:e.description})]}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>t(e.id),title:`Remove ${e.name}`,"aria-label":`Remove ${e.name}`,className:`mt-0.5 shrink-0 rounded p-1 text-ink-faint transition-colors hover:bg-ember/10 hover:text-ember`,children:(0,q.jsx)(gt,{className:`size-3.5`})})]},e.id))})})]}),document.body)}function Fr({sessions:e,currentId:t,busy:n,onOpen:r,onRemove:i}){return e.length===0?(0,q.jsx)(`div`,{className:`p-3`,children:(0,q.jsxs)(`div`,{className:`dot-grid fade-bottom rounded-xl border border-line px-3 py-6 text-center`,children:[(0,q.jsx)($e,{className:`mx-auto size-5 text-ink-faint`}),(0,q.jsx)(`p`,{className:`mt-2 text-[11px] leading-relaxed text-ink-faint`,children:`Every conversation lands here on its own. Start one in Chat, and “New chat” in the header closes it out.`})]})}):(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1.5 p-3`,children:[n&&(0,q.jsx)(`p`,{className:`px-1 pb-1 text-[11px] text-ink-faint`,children:`Waiting on the current run — stop it to reopen another conversation.`}),e.map(e=>(0,q.jsx)(Ir,{session:e,current:e.id===t,busy:n===!0,onOpen:r,onRemove:i},e.id))]})}function Ir({session:e,current:t,busy:n,onOpen:r,onRemove:i}){let a=e.title??(e.host?`Conversation on ${e.host}`:`Untitled conversation`);return(0,q.jsxs)(`div`,{className:u(`flex items-start gap-2 rounded-xl border px-2.5 py-2 text-xs transition-colors`,t?`border-brand/35 bg-brand/8`:`border-line bg-ground/40 hover:border-line-strong`),children:[(0,q.jsxs)(`button`,{type:`button`,onClick:()=>r(e.id),disabled:n,className:`flex min-w-0 flex-1 items-start gap-2 text-left disabled:opacity-50`,title:e.url,children:[(0,q.jsx)($e,{className:u(`mt-0.5 size-3.5 shrink-0`,t?`text-brand`:`text-ink-faint`)}),(0,q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,q.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,q.jsx)(`span`,{className:`truncate font-medium text-ink`,children:a}),t&&(0,q.jsx)(On,{children:`open`})]}),e.host&&(0,q.jsxs)(`span`,{className:`mt-0.5 flex items-center gap-1 font-mono text-[10px] text-ink-faint`,children:[(0,q.jsx)(V,{className:`size-2.5 shrink-0`}),(0,q.jsx)(`span`,{className:`truncate`,children:e.host})]}),(0,q.jsx)(`span`,{className:`mt-0.5 flex items-center gap-1 text-[11px] text-ink-faint`,children:we(e)&&!e.title?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(O,{className:`size-3 animate-spin`}),` Naming…`]}):(0,q.jsxs)(q.Fragment,{children:[e.turns,` `,e.turns===1?`message`:`messages`,` · `,Br(e.updatedAt)]})})]})]}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>i(e.id),"aria-label":`Delete ${a}`,className:`mt-0.5 shrink-0 rounded-full p-1 text-ink-faint transition-colors hover:bg-surface hover:text-ink`,children:(0,q.jsx)(W,{className:`size-3`})})]})}var Lr=6e4,Rr=60*Lr,zr=24*Rr;function Br(e){let t=Date.now()-e;return t<Lr?`just now`:t<Rr?`${Math.floor(t/Lr)}m ago`:t<zr?`${Math.floor(t/Rr)}h ago`:t<7*zr?`${Math.floor(t/zr)}d ago`:new Date(e).toLocaleDateString(void 0,{month:`short`,day:`numeric`})}function Vr({sessions:e,activeSessionId:t,onFocus:n,onEnd:r}){let[i,a]=(0,G.useState)(!0);if(!e.length)return null;let o=e.filter(e=>e.runId).length;return(0,q.jsxs)(`div`,{className:`enters shrink-0 border-b border-line px-3 py-2`,children:[(0,q.jsxs)(`button`,{type:`button`,onClick:()=>a(e=>!e),"aria-expanded":i,className:`flex w-full items-center gap-1.5 font-mono text-[10px] tracking-[0.12em] text-ink-faint uppercase transition-colors hover:text-ink`,children:[(0,q.jsx)(Xe,{className:`size-3 shrink-0`}),(0,q.jsxs)(`span`,{className:`flex-1 text-left`,children:[`Sessions · `,e.length,o>0&&(0,q.jsxs)(`span`,{className:`text-brand`,children:[` · `,o,` running`]})]}),(0,q.jsx)(ae,{className:u(`size-3 shrink-0 transition-transform`,i&&`rotate-180`)})]}),i&&(0,q.jsx)(`div`,{className:`mt-1.5 flex flex-col gap-1`,children:e.map(e=>(0,q.jsx)(Hr,{session:e,current:e.sessionId===t,onFocus:n,onEnd:r},e.sessionId))})]})}function Hr({session:e,current:t,onFocus:n,onEnd:r}){let i=e.tabIds.length-1;return(0,q.jsxs)(`div`,{className:u(`flex items-center gap-2 rounded-lg border px-2 py-1.5 text-xs transition-colors`,t?`border-brand/35 bg-brand/8`:`border-line bg-ground/40 hover:border-line-strong`),children:[(0,q.jsxs)(`button`,{type:`button`,onClick:()=>n(e.sessionId),className:`flex min-w-0 flex-1 items-center gap-2 text-left`,title:e.url,children:[(0,q.jsx)(`span`,{className:u(`size-1.5 shrink-0 rounded-full`,e.runId?`glow-dot animate-pulse bg-brand text-brand`:`bg-ink-faint`)}),(0,q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,q.jsx)(`span`,{className:`block truncate text-ink`,children:e.title}),(0,q.jsxs)(`span`,{className:`block font-mono text-[10px] text-ink-faint`,children:[e.turns,` `,e.turns===1?`message`:`messages`,i>0&&` · +${i} tab${i===1?``:`s`}`,e.host&&` · ${e.host}`]})]})]}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>r(e.sessionId),"aria-label":`End the session on ${e.title}`,title:`End this session`,className:`shrink-0 rounded-full p-1 text-ink-faint transition-colors hover:bg-surface hover:text-ink`,children:(0,q.jsx)(W,{className:`size-3`})})]})}var Ur=[`bg-brand`,`bg-ember`,`bg-lime`,`bg-amber`];function Wr({theme:e,onSelect:t}){return(0,q.jsxs)(`section`,{className:`space-y-2`,children:[(0,q.jsx)(`h3`,{className:`font-mono text-[10px] tracking-[0.14em] text-ink-faint uppercase`,children:`Appearance`}),(0,q.jsx)(`p`,{className:`text-[11px] leading-relaxed text-ink-faint`,children:`One click repaints the panel and the popup. Each tile is drawn in the theme it offers, so what you see is what you get.`}),(0,q.jsx)(`div`,{className:`grid grid-cols-2 gap-1.5`,children:g.map(({id:n,name:r,note:i})=>{let a=n===e;return(0,q.jsxs)(`button`,{type:`button`,"data-theme":n,onClick:()=>t(n),"aria-pressed":a,className:u(`rounded-lg border bg-ground p-2 text-left transition-colors`,a?`border-brand/60`:`border-line hover:border-line-strong`),children:[(0,q.jsxs)(`div`,{className:`flex items-start gap-1.5`,children:[(0,q.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1 rounded-md bg-surface px-1.5 py-1.5`,children:[(0,q.jsx)(`div`,{className:`h-1 w-9/12 rounded-full bg-ink/75`}),(0,q.jsx)(`div`,{className:`h-1 w-6/12 rounded-full bg-ink/30`}),(0,q.jsx)(`div`,{className:`flex gap-1 pt-1`,children:Ur.map(e=>(0,q.jsx)(`span`,{className:u(`size-2 rounded-full`,e)},e))})]}),(0,q.jsx)(`span`,{className:u(`mt-0.5 flex size-3.5 shrink-0 items-center justify-center rounded-full`,a?`bg-brand text-ground`:`border border-line-strong`),children:a&&(0,q.jsx)(R,{className:`size-2.5`,strokeWidth:3})})]}),(0,q.jsx)(`p`,{className:`mt-1.5 text-[11px] font-medium text-ink`,children:r}),(0,q.jsx)(`p`,{className:`text-[10px] leading-snug text-ink-faint`,children:i})]},n)})})]})}function Gr({checked:e,disabled:t,label:n,onChange:r,className:i}){return(0,q.jsx)(`button`,{type:`button`,role:`switch`,"data-slot":`switch`,"aria-checked":e,"aria-label":n,disabled:t,onClick:()=>r(!e),className:u(`relative inline-flex h-4 w-7 shrink-0 items-center rounded-full border transition-colors`,`focus-visible:ring-2 focus-visible:ring-brand/50 focus-visible:outline-none`,e?`border-brand/50 bg-brand/70`:`border-line-strong bg-surface`,t&&`cursor-not-allowed opacity-40`,i),children:(0,q.jsx)(`span`,{"data-slot":`switch-thumb`,className:u(`pointer-events-none size-2.5 rounded-full bg-ink shadow-sm transition-transform`,e?`translate-x-3.5`:`translate-x-0.5`)})})}function Kr(){let[e,t]=(0,G.useState)(()=>m(document.documentElement.dataset.theme));return(0,G.useEffect)(()=>{let e=!0;v.storage.local.get(d).then(n=>e&&t(m(n[`browsentic/theme`])));let n=e=>{`browsentic/theme`in e&&t(m(e[d].newValue))};return v.storage.local.onChanged.addListener(n),()=>{e=!1,v.storage.local.onChanged.removeListener(n)}},[]),[e,(0,G.useCallback)(e=>{t(e),n(e)},[])]}var qr=`fence`,Jr=`unattended`,Yr={allow:`Allow`,confirm:`Ask`,deny:`Block`},Xr=[`allow`,`confirm`,`deny`];function Zr(){let[e,t]=Kr();return(0,q.jsxs)(`div`,{className:`space-y-6 px-3 pb-6`,children:[(0,q.jsx)(Wr,{theme:e,onSelect:t}),(0,q.jsx)(Qr,{})]})}function Qr(){let e=oe(),t=e?.connected??!1,[n,r]=(0,G.useState)(null),[i,a]=(0,G.useState)(null),[o,s]=(0,G.useState)(null),c=(0,G.useCallback)(async(e,t)=>{a(t),s(null);let n=await v.runtime.sendMessage({channel:z,...e}).catch(()=>null);a(null),n?.ok?r(n.data):s(n?.error.message??`The daemon did not answer.`)},[]);(0,G.useEffect)(()=>{t&&c({op:`guardrails`},`load`)},[t,c]);let l=(e,t)=>void c({op:`setGuardrail`,setting:e,value:t},e);return e?.paired?t?n?(0,q.jsxs)(`div`,{className:`space-y-5`,children:[(0,q.jsxs)(`header`,{className:`space-y-1.5`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,q.jsx)(`h2`,{className:`font-mono text-[10px] tracking-[0.14em] text-ink-faint uppercase`,children:`Guardrails`}),(0,q.jsxs)(`button`,{type:`button`,onClick:()=>void c({op:`guardrails`},`load`),disabled:i!==null,className:`flex items-center gap-1 font-mono text-[10px] tracking-[0.14em] text-ink-faint uppercase transition-colors hover:text-brand disabled:opacity-40`,children:[(0,q.jsx)(be,{className:u(`size-3`,i===`load`&&`animate-spin`)}),` Reload`]})]}),(0,q.jsxs)(`p`,{className:`text-[11px] leading-relaxed text-ink-faint`,children:[`A row left off uses the default Browsentic ships. Turning one on writes an override to`,` `,(0,q.jsx)(`span`,{className:`font-mono text-[10px] text-ink-dim`,children:n.configPath}),` and nothing else. A run takes its policy when it starts, so a change here applies to the next one.`]})]}),o&&(0,q.jsx)(`p`,{className:`text-[11px] text-destructive`,children:o}),(0,q.jsx)(`section`,{className:`space-y-1.5`,children:n.rules.map(e=>(0,q.jsx)($r,{rule:e,busy:i===e.id,onWrite:l},e.id))}),(0,q.jsxs)(`section`,{className:`space-y-1.5`,children:[(0,q.jsx)(`h3`,{className:`font-mono text-[10px] tracking-[0.14em] text-ink-faint uppercase`,children:`Everything else`}),(0,q.jsx)(ei,{title:`Fence page text`,note:`Wraps every page result in a marker telling the model it is reading data, never instructions.`,state:n.fence.overridden?n.fence.enabled?`On`:`Off`:`On (default)`,on:n.fence.overridden,busy:i===qr,onToggle:e=>l(qr,e?n.fence.enabled:null),children:n.fence.overridden&&(0,q.jsx)(ti,{options:[{value:!0,label:`Fence`},{value:!1,label:`Do not fence`}],value:n.fence.enabled,onSelect:e=>l(`fence`,e)})}),(0,q.jsx)(ei,{title:`Callers with nobody to ask`,note:`An MCP client outside the side panel cannot answer a prompt. This is what its “Ask” decisions become.`,state:n.unattended.overridden?Yr[n.unattended.effect]:`Block (default)`,on:n.unattended.overridden,busy:i===Jr,onToggle:e=>l(Jr,e?n.unattended.effect:null),children:n.unattended.overridden&&(0,q.jsx)(ti,{options:[{value:`deny`,label:`Block`},{value:`allow`,label:`Allow`}],value:n.unattended.effect,onSelect:e=>l(`unattended`,e)})}),(0,q.jsxs)(`div`,{className:`rounded-md border border-line bg-surface/30 px-2.5 py-2`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,q.jsx)(te,{className:`size-3 text-brand`}),(0,q.jsx)(`span`,{className:`text-[11px] font-medium text-ink`,children:`Credential sealing`}),(0,q.jsx)(`span`,{className:`ml-auto font-mono text-[9px] tracking-[0.1em] text-brand uppercase`,children:`Always on`})]}),(0,q.jsx)(`p`,{className:`mt-1 text-[11px] leading-relaxed text-ink-faint`,children:`Passwords, keys, tokens and cookies are replaced by a placeholder before a result leaves the browser. There is no switch: it is what keeps a plaintext credential off the socket in the first place.`})]}),n.hosts.length>0&&(0,q.jsxs)(`div`,{className:`rounded-md border border-line bg-surface/30 px-2.5 py-2`,children:[(0,q.jsx)(`span`,{className:`text-[11px] font-medium text-ink`,children:`Standing host allowlist`}),(0,q.jsx)(`p`,{className:`mt-1 font-mono text-[10px] leading-relaxed break-all text-ink-dim`,children:n.hosts.join(` · `)}),(0,q.jsx)(`p`,{className:`mt-1 text-[11px] text-ink-faint`,children:`Added to every run’s scope. Edited in config.json.`})]})]})]}):(0,q.jsx)(ni,{children:o??`Reading the policy…`}):(0,q.jsx)(ni,{children:`The daemon is offline. Settings live in its config file, so they load when it reconnects.`}):(0,q.jsx)(ni,{children:`Pair a browser to see what this agent is allowed to do.`})}function $r({rule:e,busy:t,onWrite:n}){if(e.locked)return(0,q.jsxs)(`div`,{className:`rounded-md border border-line bg-surface/20 px-2.5 py-2`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,q.jsx)(`span`,{className:`text-[11px] font-medium text-ink-dim`,children:e.title}),(0,q.jsxs)(`span`,{className:`ml-auto flex items-center gap-1 font-mono text-[9px] tracking-[0.1em] text-ink-faint uppercase`,children:[(0,q.jsx)(Qe,{className:`size-2.5`}),Yr[e.fallback]]})]}),(0,q.jsx)(`p`,{className:`mt-1 text-[11px] leading-relaxed text-ink-faint`,children:e.reason})]});let r=e.override??e.fallback;return(0,q.jsx)(ei,{title:e.title,note:e.reason,state:e.override?Yr[e.override]:`${Yr[e.fallback]} (default)`,on:e.override!==void 0,busy:t,onToggle:t=>n(e.id,t?r:null),children:e.override!==void 0&&(0,q.jsx)(ti,{options:Xr.map(e=>({value:e,label:Yr[e]})),value:e.override,onSelect:t=>n(e.id,t)})})}function ei({title:e,note:t,state:n,on:r,busy:i,onToggle:a,children:o}){return(0,q.jsxs)(`div`,{className:u(`rounded-md border px-2.5 py-2 transition-colors`,r?`border-brand/30 bg-brand/5`:`border-line bg-surface/20`),children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(`span`,{className:`text-[11px] font-medium text-ink`,children:e}),(0,q.jsxs)(`span`,{className:`ml-auto flex items-center gap-1.5`,children:[(0,q.jsx)(`span`,{className:`font-mono text-[9px] tracking-[0.1em] text-ink-faint uppercase`,children:n}),i?(0,q.jsx)(O,{className:`size-3 animate-spin text-ink-faint`}):(0,q.jsx)(Gr,{checked:r,label:`Override ${e}`,onChange:a})]})]}),(0,q.jsx)(`p`,{className:`mt-1 text-[11px] leading-relaxed text-ink-faint`,children:t}),o]})}function ti({options:e,value:t,onSelect:n}){return(0,q.jsx)(`div`,{className:`mt-2 flex gap-1`,children:e.map(e=>(0,q.jsx)(`button`,{type:`button`,onClick:()=>n(e.value),"aria-pressed":e.value===t,className:u(`flex-1 rounded px-2 py-1 text-[10px] font-medium transition-colors`,e.value===t?`bg-brand/20 text-brand`:`bg-surface text-ink-faint hover:text-ink-dim`),children:e.label},String(e.value)))})}function ni({children:e}){return(0,q.jsx)(`p`,{className:`px-1 py-6 text-center text-[11px] leading-relaxed text-ink-faint`,children:e})}function ri({draft:e,onActivate:t,onDiscard:n}){let[r,i]=(0,G.useState)(!1),a=r?e.host:e.domain;return(0,q.jsxs)(`div`,{className:`enters mb-2 overflow-hidden rounded-xl border border-amber/40 bg-amber/8`,children:[(0,q.jsxs)(`div`,{className:`flex items-start gap-2 border-b border-amber/25 px-2.5 py-2`,children:[(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsxs)(`p`,{className:`truncate text-xs font-medium text-ink`,children:[`Mapped `,e.host]}),(0,q.jsxs)(`p`,{className:`mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 font-mono text-[10px] text-ink-faint`,children:[(0,q.jsxs)(`span`,{children:[e.pages,` pages`]}),(0,q.jsxs)(`span`,{className:`inline-flex items-center gap-0.5`,children:[(0,q.jsx)(Ke,{className:`size-2.5`}),` `,e.screenshots]}),(0,q.jsx)(`span`,{children:new Date(e.generatedAt).toLocaleString()})]})]}),(0,q.jsx)(On,{variant:`warning`,children:`not active yet`})]}),(0,q.jsxs)(`div`,{className:`px-2.5 py-2`,children:[(0,q.jsxs)(`p`,{className:`mb-2 text-[11px] leading-relaxed text-ink-dim`,children:[`This was written from pages the agent read. Once you activate it, it joins the instructions for every future request on `,(0,q.jsx)(`span`,{className:`font-mono text-ink`,children:a}),`. Read it first.`]}),e.warnings.length>0&&(0,q.jsx)(`div`,{className:`mb-2 space-y-1 rounded-lg bg-amber/12 px-2 py-1.5`,children:e.warnings.map(e=>(0,q.jsxs)(`p`,{className:`flex gap-1.5 text-[11px] leading-snug text-amber`,children:[(0,q.jsx)(L,{className:`mt-0.5 size-3 shrink-0`}),(0,q.jsx)(`span`,{children:e})]},e))}),(0,q.jsx)(`div`,{className:`max-h-56 overflow-x-hidden overflow-y-auto rounded-lg border border-line bg-ground/70`,children:(0,q.jsx)(`pre`,{className:`px-2 py-1.5 font-mono text-[10px] leading-relaxed break-words whitespace-pre-wrap text-ink-dim`,children:e.markdown})}),(0,q.jsxs)(`p`,{className:`mt-1.5 flex items-start gap-1 font-mono text-[10px] break-all text-ink-faint`,children:[(0,q.jsx)(Ue,{className:`mt-0.5 size-2.5 shrink-0`}),e.directory]}),e.screenshots>0&&(0,q.jsx)(`p`,{className:`mt-0.5 text-[10px] text-ink-faint`,children:`Screenshots may show pages you were signed in to. They stay on this machine.`}),(0,q.jsxs)(`label`,{className:`mt-2 flex items-center gap-1.5 text-[11px] text-ink-dim`,children:[(0,q.jsx)(`input`,{type:`checkbox`,checked:r,onChange:e=>i(e.target.checked),className:`size-3 accent-brand`}),`Only on `,(0,q.jsx)(`span`,{className:`font-mono text-ink`,children:e.host}),`, not its subdomains`]}),(0,q.jsxs)(`div`,{className:`mt-2.5 flex gap-1.5`,children:[(0,q.jsxs)(f,{variant:`ghost`,size:`sm`,className:`flex-1`,onClick:n,children:[(0,q.jsx)(gt,{className:`size-3`}),` Discard`]}),(0,q.jsxs)(f,{size:`sm`,className:`flex-1`,onClick:()=>t(r),children:[(0,q.jsx)(R,{className:`size-3`}),` Activate`]})]})]})]})}function ii(){let[e,t]=(0,G.useState)([]);return(0,G.useEffect)(()=>{let e=!0;v.storage.local.get(Se).then(n=>{let r=n[Se];e&&Array.isArray(r)&&t(r)});let n=e=>{if(`browsentic:skills`in e){let n=e[Se].newValue;t(Array.isArray(n)?n:[])}};return v.storage.local.onChanged.addListener(n),()=>{e=!1,v.storage.local.onChanged.removeListener(n)}},[]),e}function ai({tabUrl:e,connected:t,onMapSite:n,mapping:r}){let i=ii(),a=(0,G.useRef)(null),[o,s]=(0,G.useState)(null),[c,l]=(0,G.useState)(``),[u,d]=(0,G.useState)(null),p=Pt(e),m=t&&!r&&/^https?:/.test(e),h=i.some(e=>e.origin===`generated`&&Lt(p,e.domains));async function g(){let e=a.current,t=e?.files?.[0];if(e&&(e.value=``),!t)return;let n=Vt(await t.text(),t.name);s(n),l(n.domains.join(`, `)),d(null)}async function _(){if(!o)return;let e=c.split(`,`).map(Ft).filter(Boolean),t=zt({...o,domains:e});if(!t.ok){d(t.message);return}let n=t.draft,r=crypto.randomUUID();await le({id:r,name:n.name,description:n.description,category:n.category,domains:n.domains,status:`pending`,addedAt:Date.now()},{id:r,body:n.body,triggers:n.triggers}),await v.runtime.sendMessage({channel:z,op:`saveSkill`,skillId:r}),s(null),d(null)}return(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3 p-3`,children:[(0,q.jsx)(`p`,{className:`text-[11px] leading-relaxed text-ink-dim`,children:`Notes about a site — where things are, how its lists load — that join the agent’s instructions only while you are on that site. Let the agent write them for you, or upload your own markdown.`}),!o&&(0,q.jsxs)(`div`,{className:`grid grid-cols-2 gap-1.5`,children:[(0,q.jsxs)(f,{size:`sm`,onClick:n,disabled:!m,title:m?`Map ${p}`:`Open an http(s) page, with no run in progress`,children:[r?(0,q.jsx)(O,{className:`animate-spin`}):(0,q.jsx)(Ie,{}),(0,q.jsxs)(`span`,{className:`truncate`,children:[h?`Re-map`:`Map`,` this site`]})]}),(0,q.jsxs)(f,{variant:`outline`,size:`sm`,onClick:()=>a.current?.click(),children:[(0,q.jsx)(yt,{}),` Upload notes`]})]}),o?(0,q.jsx)(oi,{draft:o,domainText:c,error:u,connected:t,onChange:e=>{s({...o,...e}),d(null)},onDomainText:e=>{l(e),d(null)},onCancel:()=>{s(null),d(null)},onSave:()=>void _()}):(0,q.jsx)(si,{skills:i,host:p}),(0,q.jsx)(`input`,{ref:a,type:`file`,accept:`.md,.markdown,text/markdown`,className:`hidden`,onChange:()=>void g()})]})}function oi({draft:e,domainText:t,error:n,connected:r,onChange:i,onDomainText:a,onCancel:o,onSave:s}){let c=e.category===`site-exploration`;return(0,q.jsxs)(`div`,{className:`panel-card flex flex-col gap-2 rounded-xl p-2.5`,children:[(0,q.jsx)(`p`,{className:`font-mono text-[10px] tracking-[0.14em] text-ink-faint uppercase`,children:`New skill`}),(0,q.jsx)(pe,{value:e.name,onChange:e=>i({name:e.target.value.toLowerCase()}),placeholder:`skill-name`,"aria-label":`Skill name`,className:`h-8 font-mono text-xs`}),(0,q.jsx)(pe,{value:e.description,onChange:e=>i({description:e.target.value}),placeholder:`What is this for?`,"aria-label":`Skill description`,className:`h-8 text-xs`}),(0,q.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,q.jsx)(f,{variant:c?`outline`:`default`,size:`sm`,className:`flex-1`,onClick:()=>i({category:`general`}),children:`General`}),(0,q.jsxs)(f,{variant:c?`default`:`outline`,size:`sm`,className:`flex-1`,onClick:()=>i({category:`site-exploration`}),children:[(0,q.jsx)(V,{}),` Site notes`]})]}),c&&(0,q.jsx)(pe,{value:t,onChange:e=>a(e.target.value),placeholder:`acme.com, admin.acme.com`,"aria-label":`Domains this skill applies to`,className:`h-8 font-mono text-xs`}),(0,q.jsx)(`p`,{className:`line-clamp-3 rounded-lg border border-line bg-ground/70 px-2 py-1.5 text-[11px] leading-relaxed text-ink-faint`,children:e.body||`This file has no instructions in it.`}),n&&(0,q.jsx)(`p`,{className:`rounded-lg border border-amber/40 bg-amber/10 px-2 py-1.5 text-[11px] text-amber`,children:n}),(0,q.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,q.jsx)(f,{variant:`ghost`,size:`sm`,className:`flex-1`,onClick:o,children:`Cancel`}),(0,q.jsxs)(f,{size:`sm`,className:`flex-1`,onClick:s,disabled:!r,children:[(0,q.jsx)(R,{}),` Save skill`]})]}),!r&&(0,q.jsx)(`p`,{className:`text-center text-[10px] text-ink-faint`,children:`Pair the browser to save skills.`})]})}function si({skills:e,host:t}){return e.length===0?(0,q.jsxs)(`div`,{className:`dot-grid fade-bottom rounded-xl border border-line px-3 py-6 text-center`,children:[(0,q.jsx)(je,{className:`mx-auto size-5 text-ink-faint`}),(0,q.jsx)(`p`,{className:`mt-2 text-[11px] leading-relaxed text-ink-faint`,children:`No skills yet. Mapping a site writes one for you; uploading a markdown file adds your own.`})]}):(0,q.jsx)(`div`,{className:`flex min-w-0 flex-col gap-1.5`,children:e.map(e=>(0,q.jsx)(ci,{skill:e,host:t},e.id))})}function ci({skill:e,host:t}){let n=e.category===`site-exploration`&&Lt(t,e.domains),r=e.origin===`generated`,i=r?Ie:je;return(0,q.jsxs)(`div`,{className:u(`flex items-start gap-2 rounded-xl border px-2.5 py-2 text-xs`,n?`border-brand/35 bg-brand/8`:`border-line bg-ground/40`),children:[(0,q.jsx)(i,{className:u(`mt-0.5 size-3.5 shrink-0`,n?`text-brand`:`text-ink-faint`)}),(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,q.jsx)(`span`,{className:`truncate font-medium text-ink`,children:e.name}),r&&(0,q.jsx)(On,{variant:`outline`,children:`mapped`}),n&&(0,q.jsx)(On,{children:`on this site`})]}),e.domains.length>0&&(0,q.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-[10px] text-ink-faint`,children:e.domains.join(`, `)}),e.description&&(0,q.jsx)(`p`,{className:`mt-0.5 line-clamp-2 text-[11px] text-ink-dim`,children:e.description}),e.status===`pending`&&(0,q.jsxs)(`span`,{className:`mt-0.5 flex items-center gap-1 text-[11px] text-ink-faint`,children:[(0,q.jsx)(O,{className:`size-3 animate-spin`}),` Saving…`]}),e.status===`error`&&(0,q.jsx)(`span`,{className:`mt-0.5 block text-[11px] text-destructive`,children:e.error??`Could not save`})]}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>void v.runtime.sendMessage({channel:z,op:`removeSkill`,skillId:e.id}),"aria-label":`Remove ${e.name}`,className:`mt-0.5 shrink-0 rounded-full p-1 text-ink-faint transition-colors hover:bg-surface hover:text-ink`,children:(0,q.jsx)(W,{className:`size-3`})})]})}var li=Object.defineProperty,Y=(e,t)=>li(e,`name`,{value:t,configurable:!0});function ui(e,t){return G.useReducer((e,n)=>t[e][n]??e,e)}Y(ui,`useStateMachine`);var di=`ScrollArea`,[fi,pi]=A(di),[mi,X]=fi(di),hi=G.forwardRef(Y(function(e,t){let{__scopeScrollArea:n,type:r=`hover`,dir:i,scrollHideDelay:a=600,...o}=e,[s,c]=G.useState(null),[l,u]=G.useState(null),[d,f]=G.useState(null),[p,m]=G.useState(null),[h,g]=G.useState(null),[v,y]=G.useState(0),[b,x]=G.useState(0),[S,C]=G.useState(!1),[ee,w]=G.useState(!1),te=_(t,c),E=D(i);return(0,q.jsx)(mi,{scope:n,type:r,dir:E,scrollHideDelay:a,scrollArea:s,viewport:l,onViewportChange:u,content:d,onContentChange:f,scrollbarX:p,onScrollbarXChange:m,scrollbarXEnabled:S,onScrollbarXEnabledChange:C,scrollbarY:h,onScrollbarYChange:g,scrollbarYEnabled:ee,onScrollbarYEnabledChange:w,onCornerWidthChange:y,onCornerHeightChange:x,children:(0,q.jsx)(T.div,{dir:E,...o,ref:te,style:{position:`relative`,"--radix-scroll-area-corner-width":v+`px`,"--radix-scroll-area-corner-height":b+`px`,...e.style}})})},`ScrollArea`)),gi=`ScrollAreaViewport`,_i=G.forwardRef(Y(function(e,t){let{__scopeScrollArea:n,children:r,nonce:i,...a}=e,o=X(gi,n),s=_(t,G.useRef(null),o.onViewportChange);return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(vi,{nonce:i}),(0,q.jsx)(T.div,{"data-radix-scroll-area-viewport":``,...a,ref:s,style:{overflowX:o.scrollbarXEnabled?`scroll`:`hidden`,overflowY:o.scrollbarYEnabled?`scroll`:`hidden`,...e.style},children:(0,q.jsx)(`div`,{ref:o.onContentChange,style:{minWidth:`100%`,display:`table`},children:r})})]})},`ScrollAreaViewport`)),vi=G.memo(Y(function({nonce:e}){return(0,q.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}`},nonce:e})},`ScrollAreaViewportStyle`),(e,t)=>e.nonce===t.nonce),Z=`ScrollAreaScrollbar`,yi=G.forwardRef(Y(function(e,t){let{forceMount:n,...r}=e,i=X(Z,e.__scopeScrollArea),{onScrollbarXEnabledChange:a,onScrollbarYEnabledChange:o}=i,s=e.orientation===`horizontal`;return G.useEffect(()=>(s?a(!0):o(!0),()=>{s?a(!1):o(!1)}),[s,a,o]),i.type===`hover`?(0,q.jsx)(bi,{...r,ref:t,forceMount:n}):i.type===`scroll`?(0,q.jsx)(xi,{...r,ref:t,forceMount:n}):i.type===`auto`?(0,q.jsx)(Si,{...r,ref:t,forceMount:n}):i.type===`always`?(0,q.jsx)(Ci,{...r,ref:t,"data-state":`visible`}):null},`ScrollAreaScrollbar`)),bi=G.forwardRef(Y(function(e,t){let{forceMount:n,...r}=e,i=X(Z,e.__scopeScrollArea),[a,o]=G.useState(!1);return G.useEffect(()=>{let e=i.scrollArea,t=0;if(e){let n=Y(()=>{window.clearTimeout(t),o(!0)},`handlePointerEnter`),r=Y(()=>{t=window.setTimeout(()=>o(!1),i.scrollHideDelay)},`handlePointerLeave`);return e.addEventListener(`pointerenter`,n),e.addEventListener(`pointerleave`,r),()=>{window.clearTimeout(t),e.removeEventListener(`pointerenter`,n),e.removeEventListener(`pointerleave`,r)}}},[i.scrollArea,i.scrollHideDelay]),(0,q.jsx)(j,{present:n||a,children:(0,q.jsx)(Si,{"data-state":a?`visible`:`hidden`,...r,ref:t})})},`ScrollAreaScrollbarHover`)),xi=G.forwardRef(Y(function(e,t){let{forceMount:n,...r}=e,i=X(Z,e.__scopeScrollArea),a=e.orientation===`horizontal`,o=Hi(()=>c(`SCROLL_END`),100),[s,c]=ui(`hidden`,{hidden:{SCROLL:`scrolling`},scrolling:{SCROLL_END:`idle`,POINTER_ENTER:`interacting`},interacting:{SCROLL:`interacting`,POINTER_LEAVE:`idle`},idle:{HIDE:`hidden`,SCROLL:`scrolling`,POINTER_ENTER:`interacting`}});return G.useEffect(()=>{if(s===`idle`){let e=window.setTimeout(()=>c(`HIDE`),i.scrollHideDelay);return()=>window.clearTimeout(e)}},[s,i.scrollHideDelay,c]),G.useEffect(()=>{let e=i.viewport,t=a?`scrollLeft`:`scrollTop`;if(e){let n=e[t],r=Y(()=>{let r=e[t];n!==r&&(c(`SCROLL`),o()),n=r},`handleScroll`);return e.addEventListener(`scroll`,r),()=>e.removeEventListener(`scroll`,r)}},[i.viewport,a,c,o]),(0,q.jsx)(j,{present:n||s!==`hidden`,children:(0,q.jsx)(Ci,{"data-state":s===`hidden`?`hidden`:`visible`,...r,ref:t,onPointerEnter:F(e.onPointerEnter,()=>c(`POINTER_ENTER`)),onPointerLeave:F(e.onPointerLeave,()=>c(`POINTER_LEAVE`))})})},`ScrollAreaScrollbarScroll`)),Si=G.forwardRef(Y(function(e,t){let n=X(Z,e.__scopeScrollArea),{forceMount:r,...i}=e,[a,o]=G.useState(!1),s=e.orientation===`horizontal`,c=Hi(()=>{if(n.viewport){let e=n.viewport.offsetWidth<n.viewport.scrollWidth,t=n.viewport.offsetHeight<n.viewport.scrollHeight;o(s?e:t)}},10);return $(n.viewport,c),$(n.content,c),(0,q.jsx)(j,{present:r||a,children:(0,q.jsx)(Ci,{"data-state":a?`visible`:`hidden`,...i,ref:t})})},`ScrollAreaScrollbarAuto`)),Ci=G.forwardRef(Y(function(e,t){let{orientation:n=`vertical`,...r}=e,i=X(Z,e.__scopeScrollArea),a=G.useRef(null),o=G.useRef(0),[s,c]=G.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),l=Fi(s.viewport,s.content),u={...r,sizes:s,onSizesChange:c,hasThumb:l>0&&l<1,onThumbChange:Y(e=>a.current=e,`onThumbChange`),onThumbPointerUp:Y(()=>o.current=0,`onThumbPointerUp`),onThumbPointerDown:Y(e=>o.current=e,`onThumbPointerDown`)};function d(e,t){return Li(e,o.current,s,t)}return Y(d,`getScrollPosition`),n===`horizontal`?(0,q.jsx)(wi,{...u,ref:t,onThumbPositionChange:()=>{if(i.viewport&&a.current){let e=i.viewport.scrollLeft,t=Ri(e,s,i.dir);a.current.style.transform=`translate3d(${t}px, 0, 0)`}},onWheelScroll:e=>{i.viewport&&(i.viewport.scrollLeft=e)},onDragScroll:e=>{i.viewport&&(i.viewport.scrollLeft=d(e,i.dir))}}):n===`vertical`?(0,q.jsx)(Ti,{...u,ref:t,onThumbPositionChange:()=>{if(i.viewport&&a.current){let e=i.viewport.scrollTop,t=Ri(e,s);a.current.style.transform=`translate3d(0, ${t}px, 0)`}},onWheelScroll:e=>{i.viewport&&(i.viewport.scrollTop=e)},onDragScroll:e=>{i.viewport&&(i.viewport.scrollTop=d(e))}}):null},`ScrollAreaScrollbarVisible`)),wi=G.forwardRef(Y(function(e,t){let{sizes:n,onSizesChange:r,...i}=e,a=X(Z,e.__scopeScrollArea),[o,s]=G.useState(),c=G.useRef(null),l=_(t,c,a.onScrollbarXChange);return G.useEffect(()=>{c.current&&s(getComputedStyle(c.current))},[c]),(0,q.jsx)(Oi,{"data-orientation":`horizontal`,...i,ref:l,sizes:n,style:{bottom:0,left:a.dir===`rtl`?`var(--radix-scroll-area-corner-width)`:0,right:a.dir===`ltr`?`var(--radix-scroll-area-corner-width)`:0,"--radix-scroll-area-thumb-width":Ii(n)+`px`,...e.style},onThumbPointerDown:t=>e.onThumbPointerDown(t.x),onDragScroll:t=>e.onDragScroll(t.x),onWheelScroll:(t,n)=>{if(a.viewport){let r=a.viewport.scrollLeft+t.deltaX;e.onWheelScroll(r),Bi(r,n)&&t.preventDefault()}},onResize:()=>{c.current&&a.viewport&&o&&r({content:a.viewport.scrollWidth,viewport:a.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:Q(o.paddingLeft),paddingEnd:Q(o.paddingRight)}})}})},`ScrollAreaScrollbarX`)),Ti=G.forwardRef(Y(function(e,t){let{sizes:n,onSizesChange:r,...i}=e,a=X(Z,e.__scopeScrollArea),[o,s]=G.useState(),c=G.useRef(null),l=_(t,c,a.onScrollbarYChange);return G.useEffect(()=>{c.current&&s(getComputedStyle(c.current))},[c]),(0,q.jsx)(Oi,{"data-orientation":`vertical`,...i,ref:l,sizes:n,style:{top:0,right:a.dir===`ltr`?0:void 0,left:a.dir===`rtl`?0:void 0,bottom:`var(--radix-scroll-area-corner-height)`,"--radix-scroll-area-thumb-height":Ii(n)+`px`,...e.style},onThumbPointerDown:t=>e.onThumbPointerDown(t.y),onDragScroll:t=>e.onDragScroll(t.y),onWheelScroll:(t,n)=>{if(a.viewport){let r=a.viewport.scrollTop+t.deltaY;e.onWheelScroll(r),Bi(r,n)&&t.preventDefault()}},onResize:()=>{c.current&&a.viewport&&o&&r({content:a.viewport.scrollHeight,viewport:a.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:Q(o.paddingTop),paddingEnd:Q(o.paddingBottom)}})}})},`ScrollAreaScrollbarY`)),[Ei,Di]=fi(Z),Oi=G.forwardRef(Y(function(e,t){let{__scopeScrollArea:n,sizes:r,hasThumb:i,onThumbChange:a,onThumbPointerUp:o,onThumbPointerDown:s,onThumbPositionChange:c,onDragScroll:l,onWheelScroll:u,onResize:d,...f}=e,p=X(Z,n),[m,h]=G.useState(null),g=_(t,h),v=G.useRef(null),y=G.useRef(``),b=p.viewport,x=r.content-r.viewport,S=P(u),C=P(c),ee=Hi(d,10);function w(e){if(v.current){let t=e.clientX-v.current.left,n=e.clientY-v.current.top;l({x:t,y:n})}}return Y(w,`handleDragScroll`),G.useEffect(()=>{let e=Y(e=>{let t=e.target;m?.contains(t)&&S(e,x)},`handleWheel`);return document.addEventListener(`wheel`,e,{passive:!1}),()=>document.removeEventListener(`wheel`,e,{passive:!1})},[b,m,x,S]),G.useEffect(C,[r,C]),$(m,ee),$(p.content,ee),(0,q.jsx)(Ei,{scope:n,scrollbar:m,hasThumb:i,onThumbChange:P(a),onThumbPointerUp:P(o),onThumbPositionChange:C,onThumbPointerDown:P(s),children:(0,q.jsx)(T.div,{...f,ref:g,style:{position:`absolute`,...f.style},onPointerDown:F(e.onPointerDown,e=>{e.button===0&&(e.target.setPointerCapture(e.pointerId),v.current=m.getBoundingClientRect(),y.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect=`none`,p.viewport&&(p.viewport.style.scrollBehavior=`auto`),w(e))}),onPointerMove:F(e.onPointerMove,w),onPointerUp:F(e.onPointerUp,e=>{let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),document.body.style.webkitUserSelect=y.current,p.viewport&&(p.viewport.style.scrollBehavior=``),v.current=null})})})},`ScrollAreaScrollbarImpl`)),ki=`ScrollAreaThumb`,Ai=G.forwardRef(Y(function(e,t){let{forceMount:n,...r}=e,i=Di(ki,e.__scopeScrollArea);return(0,q.jsx)(j,{present:n||i.hasThumb,children:(0,q.jsx)(ji,{ref:t,...r})})},`ScrollAreaThumb`)),ji=G.forwardRef(Y(function(e,t){let{__scopeScrollArea:n,style:r,...i}=e,a=X(ki,n),o=Di(ki,n),{onThumbPositionChange:s}=o,c=_(t,o.onThumbChange),l=G.useRef(void 0),u=Hi(()=>{l.current&&=(l.current(),void 0)},100);return G.useEffect(()=>{let e=a.viewport;if(e){let t=Y(()=>{if(u(),!l.current){let t=Vi(e,s);l.current=t,s()}},`handleScroll`);return s(),e.addEventListener(`scroll`,t),()=>e.removeEventListener(`scroll`,t)}},[a.viewport,u,s]),(0,q.jsx)(T.div,{"data-state":o.hasThumb?`visible`:`hidden`,...i,ref:c,style:{width:`var(--radix-scroll-area-thumb-width)`,height:`var(--radix-scroll-area-thumb-height)`,...r},onPointerDownCapture:F(e.onPointerDownCapture,e=>{let t=e.target.getBoundingClientRect(),n=e.clientX-t.left,r=e.clientY-t.top;o.onThumbPointerDown({x:n,y:r})}),onPointerUp:F(e.onPointerUp,o.onThumbPointerUp)})},`ScrollAreaThumbImpl`)),Mi=`ScrollAreaCorner`,Ni=G.forwardRef(Y(function(e,t){let n=X(Mi,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!==`scroll`&&r?(0,q.jsx)(Pi,{...e,ref:t}):null},`ScrollAreaCorner`)),Pi=G.forwardRef(Y(function(e,t){let{__scopeScrollArea:n,...r}=e,i=X(Mi,n),[a,o]=G.useState(0),[s,c]=G.useState(0),l=!!(a&&s),{onCornerWidthChange:u,onCornerHeightChange:d}=i;return $(i.scrollbarX,()=>{let e=i.scrollbarX?.offsetHeight||0;i.onCornerHeightChange(e),c(e)}),$(i.scrollbarY,()=>{let e=i.scrollbarY?.offsetWidth||0;i.onCornerWidthChange(e),o(e)}),G.useEffect(()=>()=>{u(0),d(0)},[u,d]),l?(0,q.jsx)(T.div,{...r,ref:t,style:{width:a,height:s,position:`absolute`,right:i.dir===`ltr`?0:void 0,left:i.dir===`rtl`?0:void 0,bottom:0,...e.style}}):null},`ScrollAreaCornerImpl`));function Q(e){return e?parseInt(e,10):0}Y(Q,`toInt`);function Fi(e,t){let n=e/t;return isNaN(n)?0:n}Y(Fi,`getThumbRatio`);function Ii(e){let t=Fi(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}Y(Ii,`getThumbSize`);function Li(e,t,n,r=`ltr`){let i=Ii(n),a=i/2,o=t||a,s=i-o,c=n.scrollbar.paddingStart+o,l=n.scrollbar.size-n.scrollbar.paddingEnd-s,u=n.content-n.viewport,d=r===`ltr`?[0,u]:[u*-1,0];return zi([c,l],d)(e)}Y(Li,`getScrollPositionFromPointer`);function Ri(e,t,n=`ltr`){let r=Ii(t),i=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,a=t.scrollbar.size-i,o=t.content-t.viewport,s=a-r,c=ke(e,n===`ltr`?[0,o]:[o*-1,0]);return zi([0,o],[0,s])(c)}Y(Ri,`getThumbOffsetFromScroll`);function zi(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];let r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}Y(zi,`linearScale`);function Bi(e,t){return e>0&&e<t}Y(Bi,`isScrollingWithinScrollbarBounds`);var Vi=Y((e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return Y((function i(){let a={left:e.scrollLeft,top:e.scrollTop},o=n.left!==a.left,s=n.top!==a.top;(o||s)&&t(),n=a,r=window.requestAnimationFrame(i)}),`loop`)(),()=>window.cancelAnimationFrame(r)},`addUnlinkedScrollListener`);function Hi(e,t){let n=P(e),r=G.useRef(0);return G.useEffect(()=>()=>window.clearTimeout(r.current),[]),G.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}Y(Hi,`useDebounceCallback`);function $(e,t){let n=P(t);M(()=>{let t=0;if(e){let r=new ResizeObserver(()=>{cancelAnimationFrame(t),t=window.requestAnimationFrame(n)});return r.observe(e),()=>{window.cancelAnimationFrame(t),r.unobserve(e)}}},[e,n])}Y($,`useResizeObserver`);var Ui=hi,Wi=_i,Gi=Ni;function Ki({className:e,children:t,viewportRef:n,...r}){return(0,q.jsxs)(Ui,{"data-slot":`scroll-area`,className:u(`relative`,e),...r,children:[(0,q.jsx)(Wi,{ref:n,"data-slot":`scroll-area-viewport`,className:`size-full rounded-[inherit] outline-none [&>div]:block!`,children:t}),(0,q.jsx)(qi,{}),(0,q.jsx)(Gi,{})]})}function qi({className:e,orientation:t=`vertical`,...n}){return(0,q.jsx)(yi,{"data-slot":`scroll-area-scrollbar`,orientation:t,className:u(`flex touch-none p-px transition-colors select-none`,t===`vertical`&&`h-full w-2.5 border-l border-l-transparent`,t===`horizontal`&&`h-2.5 flex-col border-t border-t-transparent`,e),...n,children:(0,q.jsx)(Ai,{"data-slot":`scroll-area-thumb`,className:`relative flex-1 rounded-full bg-surface-2 transition-colors hover:bg-brand/40`})})}function Ji(){return me().url}var Yi=e=>e.dataTransfer?.types.includes(`Files`)??!1;function Xi({active:e,onDrop:t}){let[n,r]=(0,G.useState)(!1),i=(0,G.useRef)(0),a=(0,G.useRef)({active:e,onDrop:t});return(0,G.useEffect)(()=>{a.current={active:e,onDrop:t}}),(0,G.useEffect)(()=>{let e=()=>{i.current=0,r(!1)},t=e=>{Yi(e)&&(i.current+=1,r(!0))},n=e=>{Yi(e)&&(e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect=a.current.active?`copy`:`none`))},o=t=>{Yi(t)&&(--i.current,i.current<=0&&e())},s=t=>{if(!Yi(t))return;t.preventDefault(),e();let n=Array.from(t.dataTransfer?.files??[]);a.current.active&&n.length>0&&a.current.onDrop(n)};return window.addEventListener(`dragenter`,t),window.addEventListener(`dragover`,n),window.addEventListener(`dragleave`,o),window.addEventListener(`drop`,s),window.addEventListener(`dragend`,e),()=>{window.removeEventListener(`dragenter`,t),window.removeEventListener(`dragover`,n),window.removeEventListener(`dragleave`,o),window.removeEventListener(`drop`,s),window.removeEventListener(`dragend`,e)}},[]),n}function Zi(){return $i(se,!1,e=>typeof e==`boolean`)}function Qi(){return $i(ye,`chat`,e=>typeof e==`string`)}function $i(e,t,n){let[r,i]=(0,G.useState)(t);return(0,G.useEffect)(()=>{let t=!0;v.storage.local.get(e).then(r=>{t&&n(r[e])&&i(r[e])});let r=t=>{let r=t[e];r&&n(r.newValue)&&i(r.newValue)};return v.storage.local.onChanged.addListener(r),()=>{t=!1,v.storage.local.onChanged.removeListener(r)}},[e]),[r,(0,G.useCallback)(t=>{i(t),v.storage.local.set({[e]:t})},[e])]}function ea(){let[e,t]=(0,G.useState)([]);return(0,G.useEffect)(()=>{let e=!0;v.storage.local.get(C).then(n=>{let r=n[C];e&&Array.isArray(r)&&t(r)});let n=e=>{if(`browsentic:files`in e){let n=e[C].newValue;t(Array.isArray(n)?n:[])}};return v.storage.local.onChanged.addListener(n),()=>{e=!1,v.storage.local.onChanged.removeListener(n)}},[]),e}function ta(){let[e,t]=(0,G.useState)([]);return(0,G.useEffect)(()=>{let e=!0;v.storage.local.get(ce).then(n=>{let r=n[ce];e&&Array.isArray(r)&&t(r)});let n=e=>{if(`browsentic:recordings`in e){let n=e[ce].newValue;t(Array.isArray(n)?n:[])}};return v.storage.local.onChanged.addListener(n),()=>{e=!1,v.storage.local.onChanged.removeListener(n)}},[]),e}function na(){let[e,t]=(0,G.useState)([]);return(0,G.useEffect)(()=>{let e=!0;v.storage.local.get(ge).then(n=>{let r=n[ge];e&&Array.isArray(r)&&t(r)});let n=e=>{if(`browsentic:sessions`in e){let n=e[ge].newValue;t(Array.isArray(n)?n:[])}};return v.storage.local.onChanged.addListener(n),()=>{e=!1,v.storage.local.onChanged.removeListener(n)}},[]),e}var ra=10*1024*1024,ia=56;function aa(){let e=oe(),t=xe(),[n,r]=ve(),i=ea(),a=na(),s=ta(),c=ii(),l=Ji(),[u,d]=(0,G.useState)(null),[p,m]=(0,G.useState)(null),[h,g]=(0,G.useState)(null),[_,y]=(0,G.useState)(!1),[b,x]=(0,G.useState)(!1),[C,w]=(0,G.useState)(!1),[T,te]=Qi(),[E,D]=(0,G.useState)(!1),[,O]=Zi(),k=(0,G.useRef)(null),A=(0,G.useRef)(null),[j,M]=(0,G.useState)(!0),N=e?.connected??!1,P=Xi({active:N,onDrop:e=>{L(`chat`),me(e)}}),F=Ce({active:n&&N&&!t.running,onSubmit:e=>{t.send(e,{agentSkillId:p?.id,focus:h??void 0,liveTools:C}),m(null),g(null)}}),I=ie(e,{running:t.running,listening:F.listening});(0,G.useEffect)(()=>{!N||e?.skillCatalog||v.runtime.sendMessage({channel:z,op:`listSkills`})},[N,e?.skillCatalog]),(0,G.useEffect)(()=>{v.runtime.sendMessage({channel:z,op:`panelOpened`}),v.windows.getCurrent().then(e=>{A.current=e.id??null})},[]),(0,G.useEffect)(()=>{let e=k.current;if(!e)return;let t=()=>{let t=e.scrollHeight-e.scrollTop-e.clientHeight;M(t<ia)};return e.addEventListener(`scroll`,t,{passive:!0}),()=>e.removeEventListener(`scroll`,t)},[]),(0,G.useEffect)(()=>{if(!j||T!==`chat`)return;let e=k.current;e&&(e.scrollTop=e.scrollHeight)},[t.items,t.running,j,T]);function re(){let e=k.current;e&&e.scrollTo({top:e.scrollHeight,behavior:`smooth`}),M(!0)}function L(e){D(!1),e!==T&&(te(e),M(e===`chat`),k.current&&(k.current.scrollTop=0))}function R(){D(!1),O(!0),de(A.current)}function ae(){t.running||!N||(L(`chat`),F.submitNow())}function se(e){L(`chat`),t.restore(e)}function ce(e){L(`chat`),t.send(`Replay my recording “${e.name}” (id ${e.id}).`)}function le(){L(`chat`),t.mapSite()}async function fe(){if(b)return;d(null),x(!0);let e=await rn();x(!1),`focus`in e?g(e.focus):`error`in e&&d(`A-Eye couldn’t read that element: ${e.error}`)}async function pe(){let e=await ee(he,{});if(!e.ok){F.setInput(`${F.input}\n[couldn’t read this page: ${e.error.message}]\n`);return}let{document:t,selection:n}=e.data,r=n?`\nSelection: “${n}”`:``;F.setInput(`${F.input?`${F.input}\n\n`:``}[Page: ${t.title} — ${t.url}${r}]\n`)}async function me(e){let t=e.filter(e=>e.size>ra),n=`${ra/1024/1024} MB`;d(t.length===0?null:t.length===1?`“${t[0].name}” is larger than ${n}.`:`${t.length} of those files are larger than ${n}.`);for(let t of e)t.size<=ra&&await ge(t)}async function ge(e){let t=crypto.randomUUID(),n=await oa(e);await Ee({id:t,name:e.name,mime:e.type||`application/octet-stream`,size:e.size,status:`pending`,addedAt:Date.now()},n),await v.runtime.sendMessage({channel:z,op:`analyzeFile`,fileId:t})}function _e(){if(!n){r(!0);return}if(F.error){F.retry();return}r(!1)}let ye=t.sessions.filter(e=>e.runId).length,be=ye>0&&T!==`chat`,Se=be||!!t.recording||t.monitors.length>0||!!t.draft,we={history:a.length,skills:c.length,recordings:s.length};return(0,q.jsxs)(`div`,{className:`relative flex h-screen flex-col`,children:[(0,q.jsxs)(`header`,{className:`flex shrink-0 items-center gap-2 px-3 py-2.5`,children:[(0,q.jsx)(o,{className:`flex-1`}),(0,q.jsx)(S,{tone:I.tone,expanded:E,onClick:()=>D(e=>!e),children:I.label}),(0,q.jsx)(f,{variant:`ghost`,size:`icon-sm`,title:`New chat`,"aria-label":`Start a new conversation`,onClick:()=>{L(`chat`),t.clear()},children:(0,q.jsx)(dt,{className:`size-3.5`})}),(0,q.jsx)(f,{variant:`ghost`,size:`icon-sm`,title:`Minimize to a rail on the page`,"aria-label":`Minimize to a rail on the page`,onClick:R,children:(0,q.jsx)(nt,{className:`size-3.5`})})]}),E&&(0,q.jsx)(dn,{onClose:()=>D(!1)}),(0,q.jsx)(Sn,{tab:T,counts:we,onSelect:L}),(0,q.jsx)(Vr,{sessions:t.sessions,activeSessionId:t.sessionId,onFocus:e=>{L(`chat`),t.focusSession(e)},onEnd:t.endSession}),Se&&(0,q.jsxs)(`div`,{className:`max-h-[45%] shrink-0 overflow-y-auto px-3 pt-2`,children:[be&&(0,q.jsxs)(`button`,{type:`button`,onClick:()=>L(`chat`),className:`enters mb-2 flex w-full items-center gap-2 rounded-xl border border-brand/35 bg-brand/8 px-2.5 py-2 text-left transition-colors hover:bg-brand/12`,children:[(0,q.jsx)(`span`,{className:`glow-dot size-1.5 shrink-0 animate-pulse rounded-full bg-brand text-brand`}),(0,q.jsx)(`span`,{className:`flex-1 text-xs text-ink`,children:ye===1?`A run is in progress`:`${ye} runs are in progress`}),(0,q.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] tracking-[0.12em] text-brand uppercase`,children:`Watch`})]}),t.recording&&(0,q.jsx)(wn,{state:t.recording,onStop:t.stopRecording}),t.monitors.map(e=>(0,q.jsx)(_n,{state:e,onStop:()=>t.stopMonitor(e.monitorId)},e.monitorId)),t.draft&&(0,q.jsx)(ri,{draft:t.draft,onActivate:t.activateMap,onDiscard:t.discardMap})]}),(0,q.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[(0,q.jsxs)(Ki,{viewportRef:k,className:`h-full`,children:[T===`chat`?t.items.length===0?(0,q.jsx)(hn,{blocker:I.blocker,voiceOn:n&&F.supported,onGo:L,onFix:()=>D(!0),onUse:F.setInput}):(0,q.jsx)(wr,{items:t.items,running:t.running,onDecide:t.decide}):T===`history`?(0,q.jsx)(Fr,{sessions:a,currentId:t.sessionId??void 0,busy:t.running,onOpen:se,onRemove:e=>void ue(e)}):T===`skills`?(0,q.jsx)(ai,{tabUrl:l,connected:N,onMapSite:le,mapping:t.running}):T===`settings`?(0,q.jsx)(Zr,{}):(0,q.jsx)(In,{tabUrl:l,recordings:s,recording:t.recording,busy:t.running,onStart:t.startRecording,onStop:t.stopRecording,onReplay:ce,onRemove:e=>void De(e)}),(0,q.jsx)(`div`,{className:`h-3`})]}),T===`chat`&&!j&&t.items.length>0&&(0,q.jsxs)(f,{size:`sm`,variant:`outline`,className:`enters absolute bottom-3 left-1/2 -translate-x-1/2 backdrop-blur`,onClick:re,children:[(0,q.jsx)(Ae,{className:`size-3`}),` Latest`]})]}),_&&(0,q.jsx)(Pr,{tools:t.tools,onForget:t.forgetTool,onClose:()=>y(!1)}),T===`chat`&&(0,q.jsxs)(`footer`,{className:`shrink-0 border-t border-line p-3`,children:[t.toolOffer&&(0,q.jsx)(Nr,{offer:t.toolOffer,onKeep:t.keepTool,onDismiss:t.dismissTool}),(0,q.jsx)(on,{voice:F,voiceEnabled:n,connected:N,running:t.running,files:i,attachError:u,catalog:e?.skillCatalog,tabUrl:l,attachedSkill:p,focus:h,picking:b,liveTools:C,onToggleLiveTools:()=>w(e=>!e),onAttachSkill:m,onCommand:e=>{if(Zt(e)){y(!0);return}L(`chat`),t.send(e)},tools:t.tools,onRunTool:e=>{L(`chat`),t.runTool(e)},onSend:ae,onStop:t.cancel,onToggleVoice:_e,onPick:()=>void fe(),onClearFocus:()=>g(null),onAttachPage:()=>void pe(),onAttachFile:e=>void me([e]),onRemoveFile:e=>void ne(e)})]}),P&&(0,q.jsx)(fn,{connected:N,maxBytes:ra})]})}function oa(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>{let e=r.result;t(typeof e==`string`?e.slice(e.indexOf(`,`)+1):``)},r.onerror=()=>n(r.error??Error(`Could not read the file`)),r.readAsDataURL(e)})}l(),St.createRoot(document.getElementById(`root`)).render((0,q.jsx)(G.StrictMode,{children:(0,q.jsx)(aa,{})}));
|