toyon 0.1.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/README.md +62 -39
  2. package/dist/bridge.js +1 -1
  3. package/dist/cli.js +255 -68
  4. package/dist/daemon.js +2404 -516
  5. package/dist/shell/assets/{Editor-Cn-KsoFr.js → Editor-Lle8R8mY.js} +148 -148
  6. package/dist/shell/assets/{XTerm-DSSGYyFZ.js → XTerm-DcWpV1FL.js} +13 -13
  7. package/dist/shell/assets/{cssMode-BU_otbjh.js → cssMode-Ck0mAapo.js} +1 -1
  8. package/dist/shell/assets/{freemarker2-C-NGmKSC.js → freemarker2-B5OkSZOW.js} +1 -1
  9. package/dist/shell/assets/{handlebars-BWvVdY_e.js → handlebars-C6vrFwYj.js} +1 -1
  10. package/dist/shell/assets/{html-CBO-8nU2.js → html-CE92cnIr.js} +1 -1
  11. package/dist/shell/assets/{htmlMode-Dwz6npQ-.js → htmlMode-CfM52A9Q.js} +1 -1
  12. package/dist/shell/assets/index-DOf1M9v5.js +233 -0
  13. package/dist/shell/assets/index-b4LMTPcs.css +1 -0
  14. package/dist/shell/assets/{javascript-__evPE7m.js → javascript-C7Q1bCJn.js} +1 -1
  15. package/dist/shell/assets/{jsonMode-DpbQTbP6.js → jsonMode-Cq43R9DW.js} +1 -1
  16. package/dist/shell/assets/{liquid-CgOzfjEh.js → liquid-CnxQAGJm.js} +1 -1
  17. package/dist/shell/assets/{lspLanguageFeatures-DM57zeAM.js → lspLanguageFeatures-BtjVqb14.js} +1 -1
  18. package/dist/shell/assets/{mdx-DxN7Bq5u.js → mdx-ycMLgnto.js} +1 -1
  19. package/dist/shell/assets/{python-C3rGYQJF.js → python-se_0lOPN.js} +1 -1
  20. package/dist/shell/assets/{razor-C5rkTP_6.js → razor-DjByizBq.js} +1 -1
  21. package/dist/shell/assets/{tsMode-DDCDv-RH.js → tsMode-D1mOZbLC.js} +1 -1
  22. package/dist/shell/assets/{typescript-CyHgeKIZ.js → typescript-B-dZdvXG.js} +1 -1
  23. package/dist/shell/assets/{workers-C7XbwGBM.js → workers-DXwGNRtC.js} +1 -1
  24. package/dist/shell/assets/{xml-Dmw92JAf.js → xml-CoqNFco9.js} +1 -1
  25. package/dist/shell/assets/{yaml-Bj_aHuSs.js → yaml-D5Qru8sI.js} +1 -1
  26. package/dist/shell/index.html +2 -2
  27. package/dist/shell/manifest.json +1 -1
  28. package/package.json +2 -2
  29. package/dist/shell/assets/index-B61fMQI2.css +0 -1
  30. package/dist/shell/assets/index-Mb4zTZaD.js +0 -230
package/README.md CHANGED
@@ -1,16 +1,20 @@
1
1
  # Toyon
2
2
 
3
- Checking an agent's work means running it. Toyon gives every chat its own copy of your web app, with a live preview.
3
+ Toyon is where you ask for changes to your web app and try them as they happen. Every chat gets its own running copy with a live preview.
4
4
 
5
- Each copy runs on your own machine, and the next one is pre-warmed. Works with Claude Code, Codex and OpenCode.
5
+ Each copy runs on your own machine, and the next one is pre-warmed. Works with Claude Code, Codex and OpenCode over the Agent Client Protocol (ACP).
6
+
7
+ ![Toyon with three chats on a plant shop: the open one is adding a dark mode, and the shop beside it has already turned dark while the agent works](https://raw.githubusercontent.com/toyon-dev/toyon/main/docs/images/toyon.jpg)
6
8
 
7
9
  **Status: pre-alpha, built in the open.** Runs on macOS and Linux. Windows through WSL2 is next. Expect rough edges, and say so in an issue.
8
10
 
11
+ [How it works](#how-it-works) · [Install](#install) · [Under the hood](#under-the-hood) · [Trust](#trust) · [Uninstall](#uninstall)
12
+
9
13
  ## Why
10
14
 
11
15
  A diff says what changed, not whether the page still looks right. A preview link at the end of a run shows you the result after the agent has stopped, too late to steer it. And with more than one agent going it gets worse: terminal splits, copies of the repo made by hand, dev servers fighting over a port.
12
16
 
13
- In Toyon you type what you want, and the chat opens with your app already running in the middle of the window. Point at a button in the page and ask for it to be bigger; watch it change while the agent works; keep the change when it looks right.
17
+ In Toyon you point at a button in the page and ask for it to be bigger, watch it change while the agent works, and keep the change when it looks right.
14
18
 
15
19
  ## How it works
16
20
 
@@ -22,78 +26,97 @@ In Toyon you type what you want, and the chat opens with your app already runnin
22
26
  - Nothing is kept until you say so.
23
27
  - Your editor stays yours.
24
28
 
29
+ Each copy is a branch and a git worktree with your dependencies and `.env` files; one spare per project is kept warm.
30
+
31
+ Point at anything on the page to talk about it or open the line that draws it, and the design pane maps it to your tokens and components.
32
+
33
+ One Toyon holds every project you open, and the list of chats shows which one needs you.
34
+
35
+ When your check passes, land merges into main on your machine by default, or pushes, or opens a pull request.
36
+
37
+ Built for web apps. A project without a page still works; the chat takes the middle instead of the preview.
38
+
25
39
  ## Install
26
40
 
41
+ Try it in a project:
42
+
27
43
  ```sh
28
44
  cd your-project
29
45
  npx toyon
30
46
  ```
31
47
 
32
- Needs git and Node 18 or newer; bun comes with the package. On Linux the agents' sandbox also needs bubblewrap and socat (`sudo apt install bubblewrap socat`), and `toyon doctor` checks both and prints the AppArmor profile Ubuntu 24.04 and later ask for. `npm i -g toyon` puts `toyon` on your PATH for good, after which `toyon`, `toyon .` and `toyon ~/projects/app` all open a project, and anywhere else opens Toyon without one, ready to start a new one. `toyon --help` lists the rest.
48
+ Or install it globally:
33
49
 
34
- Each agent signs in with its own login, from the chat, and MCP servers run as each agent runs them, outside Toyon's sandbox.
50
+ ```sh
51
+ npm i -g toyon
52
+ toyon ~/projects/app
53
+ ```
35
54
 
36
- - **Claude Code** is installed on first start. It loads your user, project and local settings, so permission rules, hooks, slash commands, plugins and MCP servers work as they do in the terminal.
37
- - **Codex** is installed on first start and reads its own config file.
38
- - **OpenCode** is a larger download, installed from its row's menu. It signs in with `opencode auth login` in the chat's terminal and uses whichever providers you have signed it into. It runs on a config Toyon writes, so a repository's `opencode.json` cannot loosen it, and with less than the other two: no subagents, no effort levels, and no steering mid-turn.
55
+ `toyon .` opens the folder you are in and `toyon --help` lists the rest. A global install keeps itself updated; `TOYON_UPDATES=off` stops it. Run outside a project, Toyon opens with none: describe a new one in a sentence, or give the project picker a git URL to clone.
39
56
 
40
- ## What you get
57
+ You need:
41
58
 
42
- - **A copy of your project per chat.** Type what you want; Toyon makes a branch and a git worktree, clones the dependencies, starts your dev servers and opens the agent in it. One spare per project is kept warm, so the next chat's app is usually already running. A second chat right after, or several at once, waits for its own setup.
43
- - **Your app at the centre.** Each copy runs its own servers behind its own preview address. Switch between chats like tabs; each keeps its page state while hidden.
44
- - **Connected to its code.** Point at anything on the page to talk about it or open the line that draws it. Hover a change and it is outlined in the page. A design pane maps the page back to your tokens and components.
45
- - **More than one version.** Send one prompt to several copies and compare the results in the app.
46
- - **Keep it your way.** When a turn is done and your check passes, the composer offers to land it: merged into main on your machine, pushed, or opened as a pull request, whichever your project's settings name. Nothing is committed or pushed until you press it.
47
- - **The rest of the loop.** A terminal per chat, quick-open and search, a diff you can edit, themes including your VS Code ones, and an installable app window.
59
+ - git and Node 18 or newer. Bun comes with the package.
60
+ - An account for the agent you pick: a Claude plan or an Anthropic API key for Claude Code, a ChatGPT plan or an OpenAI API key for Codex, or any provider OpenCode signs into.
61
+ - On Linux, bubblewrap and socat for the agents' sandbox (`sudo apt install bubblewrap socat`). `toyon doctor` checks both and prints the AppArmor profile Ubuntu 24.04 and later ask for.
48
62
 
49
- Built for web apps. A project without a page still works; the chat takes the middle instead of the preview.
63
+ Each agent signs in from the chat. Claude Code and Codex install on first start; OpenCode is a larger download with no subagents, effort levels or steering mid-turn. What each one reads and can do is in [docs/agents.md](https://github.com/toyon-dev/toyon/blob/main/docs/agents.md).
50
64
 
51
- ## How is this different from Conductor or Superset?
65
+ ## How is this different from what you use now?
52
66
 
53
- They are good tools for running many agents at once, built for teams on GitHub. Toyon is built around the app instead of the agents: every chat opens with your app running at the centre, connected to its code, so you see each change before you keep it. It is MIT licensed, needs no account, sends no telemetry, runs in your browser on macOS or Linux, and can land work on your own machine without GitHub.
67
+ - **Claude Code or Codex in a terminal.** Toyon runs that same agent under your own login and config; for Claude Code that includes your permission rules, hooks, slash commands and MCP servers. What changes is around it: each chat gets its own copy of the project with the app running, and nothing lands until you press.
68
+ - **Cursor, Zed or VS Code.** Toyon sits beside your editor, not in place of it. Their agent panels and worktrees live in the editor, with a browser you open when you want it; in Toyon the running app is the centre of every chat, wired to its source. Your checkout stays yours, and any file opens back in your editor from its menu.
69
+ - **Conductor or Superset.** They are good tools for running many agents at once. Toyon is built around the app instead of the agents: every chat opens with your app running at the centre, connected to its code, so you see each change before you keep it. It is MIT licensed, needs no account, sends no telemetry, runs in your browser on macOS or Linux, and lands work as a pull request on GitHub or on your own machine without it.
54
70
 
55
71
  ## Under the hood
56
72
 
57
- ```
58
- browser (shell UI) ──HTTP/WS──> daemon (one per machine)
59
- ├─ worktree manager (git worktree add/prune, CoW dep clone)
60
- ├─ process supervisor (per-worktree dev servers, $PORT contract)
61
- ├─ per-worktree reverse proxy (live preview iframe, HMR passthrough)
62
- ├─ agent sessions (Claude Code, Codex or OpenCode over ACP, one per worktree)
63
- └─ git ops (status/diff, ref watcher, land)
73
+ The contract for anything Toyon runs: *stay in the foreground, listen on `$PORT`, reload yourself however you like.* A `.toyon/settings.json` in the project names the setup commands, the commands to `run`, an optional `check` and how work lands. The first open guesses one from `package.json`, asks you to confirm it, and writes it into the project; other stacks start from an empty guess the agent can fill in. If a server comes up on some other port anyway, the preview follows it there and says which flag to add.
74
+
75
+ A project with a page and an API behind it:
76
+
77
+ ```json
78
+ {
79
+ "setup": ["npm install"],
80
+ "run": {
81
+ "web": "vite --port $PORT",
82
+ "api": "node --watch server.js"
83
+ },
84
+ "check": "npm test",
85
+ "land": { "route": "pr" }
86
+ }
64
87
  ```
65
88
 
66
- The contract for anything Toyon runs: *stay in the foreground, listen on `$PORT`, reload yourself however you like.* A `.toyon/settings.json` in the project names the setup commands, the commands to `run`, an optional `check` and how work lands. The first open guesses one from `package.json` and asks you to confirm it; other stacks start from an empty guess the agent can fill in. A tool that takes its port from a flag, Vite among them, gets the flag added by the guess. If a server still comes up on some other port, Toyon follows it there and says which flag to add, and if it never listens at all the preview says so instead of waiting.
89
+ Each command gets its own `$PORT`, and the addresses of the others as `<NAME>_URL` (`API_URL` here), so the page can proxy to its API. The preview shows `web`.
67
90
 
68
- Copies start when you open them, not when the daemon boots. `toyon stop` stops the daemon and everything it runs. `toyon doctor` says what is running and why a page cannot connect.
91
+ Copies start when you open them, and stop their servers when nobody has looked at them for a while; the chat and the agent keep going. `toyon stop` stops the daemon and everything it runs. `toyon doctor` says what is running and why a page cannot connect. Every setting, the port rules and the sleep delay are in [docs/settings.md](https://github.com/toyon-dev/toyon/blob/main/docs/settings.md).
69
92
 
70
93
  ## What it does not do
71
94
 
72
- - It is not an editor. There is no file tree, no multi-file editing, no debugger, no extensions, no inline completion. The diff is editable and there is a one-keystroke jump to the editor you already use.
73
- - It does not commit, push or open pull requests on its own. The agent is told not to push or delete branches.
95
+ - It is not an editor. You can browse the files, read and edit a diff and run a terminal, but there is no multi-file editing, no debugger, no extensions, no inline completion.
96
+ - Only land pushes, when you press it. The agent is told not to push or delete branches.
74
97
  - It works on git repositories, and the product uses git's words for what it does. A new project starts one for you.
75
- - It does not keep copies apart from services they share. Each copy runs your setup and your commands on its own, so a database or a compose stack they all point at is shared, migrations included. `TOYON_WORKTREE` is in the environment of every command and terminal so a project can keep them apart (`app_$TOYON_WORKTREE` as the database name), and `TOYON_ROOT` is the main checkout, so a setup step can copy over what git leaves behind and Toyon does not already copy (`cp "$TOYON_ROOT/data/dev.db" data/`; `node_modules` and the `.env` files come along on their own).
98
+ - It does not keep copies apart from services they share. Each copy runs your setup and your commands on its own, so a database or a compose stack they all point at is shared, migrations included. `TOYON_WORKTREE` in every command's environment lets a project give each copy its own (`app_$TOYON_WORKTREE` as the database name); [docs/settings.md](https://github.com/toyon-dev/toyon/blob/main/docs/settings.md#keeping-copies-apart) has the recipes.
76
99
  - It does not carry a login between copies. Each preview has its own cookies, so a new chat's app starts signed out, and an OAuth provider cannot redirect into a preview at all.
77
100
 
78
- ## Disk
79
-
80
- Each copy is a real `git worktree` under `~/.toyon/worktrees.noindex` with its own `node_modules`, cloned from the main checkout with copy-on-write where the filesystem has it: `cp -c` on APFS, `--reflink=auto` on btrfs and XFS. A new copy then costs seconds and almost no space until files diverge. On ext4 and other filesystems without reflinks it is a plain copy, and each one costs a full `node_modules`. The setup log says which path ran. Nothing is deleted without you.
81
-
82
101
  ## Somewhere other than your laptop
83
102
 
84
- Toyon can also run on a box you open from your phone, or on your own Fly account with the laptop closed. None of it passes through a Toyon server; there is none. `toyon remote` puts a box on your own domain or your tailnet, `toyon deploy fly up` builds a machine on your Fly account and prints the link, and the Dockerfile in the package runs on any host with a disk and a port range. [toyon.cloud](https://toyon.cloud) keeps a list of your machines in your browser, and nothing else.
103
+ Toyon can also run on a box you open from your phone, or on your own Fly account with the laptop closed. This moves Toyon and its copies off your laptop; it does not publish your app. None of it passes through a Toyon server; there is none. `toyon remote` puts a box on your own domain behind Caddy or on your Tailscale tailnet, `toyon deploy fly up` builds a machine on your Fly account and prints the link, and the Dockerfile in the package runs on any host with a disk and a port range. A Fly machine measured about $4-6 a month in ordinary use, plus whatever your agents spend, and its first chat can sign in with your Claude plan. [toyon.cloud](https://toyon.cloud) keeps a list of your machines in your browser, and nothing else.
85
104
 
86
105
  These routes are new, and the shell has no phone layout yet. How to set each one up, and what it has been checked with, is in [docs/remote.md](https://github.com/toyon-dev/toyon/blob/main/docs/remote.md).
87
106
 
107
+ ## Disk
108
+
109
+ Each copy is a real `git worktree` under `~/.toyon/worktrees.noindex` with its own `node_modules`, cloned from the main checkout with copy-on-write where the filesystem has it: `cp -c` on APFS, `--reflink=auto` on btrfs and XFS. A new copy then costs seconds and almost no space until files diverge. On ext4 and other filesystems without reflinks it is a plain copy, and each one costs a full `node_modules`. The setup log says which path ran. Nothing is deleted without you.
110
+
88
111
  ## Trust
89
112
 
90
113
  The daemon listens on loopback only and every request carries a per-machine token. Nothing is exposed to your network, and turning on remote access admits one name over https and nothing else.
91
114
 
92
- Agents run confined. Everything a shell command spawns runs inside an OS sandbox (Seatbelt on macOS, bubblewrap on Linux) that can write to the worktree, the temp directories and package-manager caches, and nothing else, and the file tools are held to the same boundary. An agent cannot widen its own sandbox or another's. Opening a repository runs its setup, its dev server and whatever it configures for the agents, so open the ones you trust.
115
+ Agents run confined. Everything a shell command spawns runs inside an OS sandbox (Seatbelt on macOS, bubblewrap on Linux) that can write to the worktree, the temp directories and package-manager caches, and nothing else, and the file tools are held to the same boundary. An agent cannot widen its own sandbox or another's. MCP servers run as each agent runs them, outside Toyon's sandbox. Opening a repository runs its setup, its dev server and whatever it configures for the agents, so open the ones you trust.
93
116
 
94
117
  Each chat has a permission mode, shown next to the prompt. **auto**, the default, lets edits and sandboxed commands run and asks only when the agent proposes a plan. **ask** turns every edit and every command into a card in the chat before it runs. **plan** puts the agent in its read-only mode, and approving its plan chooses whether the work runs in auto or ask.
95
118
 
96
- One limit worth knowing: the sandbox cannot tell a commit from a push. `git push`, branch deletion and `gh pr` are refused by rules in the configuration Toyon gives Claude Code and OpenCode, Codex has no equivalent list, and every agent is told not to push. That is a command filter, not a wall: if your credentials are on the machine, a determined agent could still find a spelling that pushes. The whole boundary, per agent, is in [docs/trust.md](https://github.com/toyon-dev/toyon/blob/main/docs/trust.md).
119
+ One limit worth knowing: the sandbox cannot tell a commit from a push. `git push`, branch deletion and `gh pr` are refused by rules in the configuration Toyon gives Claude Code and OpenCode, and every agent is told not to push. Codex has no equivalent list, and its shell commands can read Toyon's token. That is a command filter, not a wall: if your credentials are on the machine, a determined agent could still find a spelling that pushes. The whole boundary, per agent, is in [docs/trust.md](https://github.com/toyon-dev/toyon/blob/main/docs/trust.md).
97
120
 
98
121
  ## Uninstall
99
122
 
@@ -102,11 +125,11 @@ toyon uninstall
102
125
  npm uninstall -g toyon
103
126
  ```
104
127
 
105
- The first command lists what it will remove and asks before doing it: the daemon, everything under `~/.toyon` (state, transcripts, the agent adapters, and the worktree directories, removed through git so each repository's worktree list stays clean), and `~/Applications/Toyon.app` if you installed it. It keeps your projects, every branch Toyon made under `toyon/`, and Toyon's settings in each project. `--yes` skips the question. It does not delete a machine you deployed to Fly; `toyon deploy fly destroy <name>` does, and should run first.
128
+ The first command lists what it will remove from `~/.toyon` and asks before doing it. It keeps your projects, every branch Toyon made under `toyon/`, and Toyon's settings in each project. It does not delete a machine you deployed to Fly; run `toyon deploy fly destroy <name>` first.
106
129
 
107
130
  ## Telemetry
108
131
 
109
- None. Toyon makes no network calls of its own. The only traffic is to the agents you sign into, to npm on first start to fetch the Claude Code and Codex adapters and again when you first pick OpenCode, to Fly when you deploy there, and to whatever your own dev servers and `git push` talk to.
132
+ None: nothing about you or your work is sent anywhere. Toyon's one call of its own is an update check every six hours against the registry npm is set up for, and `TOYON_UPDATES=off` stops it. The rest of the traffic is to the agents you sign into, to npm on first start to fetch the Claude Code and Codex adapters and again when you first pick OpenCode, to Fly when you deploy there, and to whatever your own dev servers, `git fetch` and `git push` talk to.
110
133
 
111
134
  ## Help build it
112
135
 
package/dist/bridge.js CHANGED
@@ -1 +1 @@
1
- var B=[{id:"quick-open",key:"p"},{id:"commands",key:"p",shift:!0,aliases:["e"]},{id:"search",key:"f",shift:!0},{id:"left",key:"b"},{id:"composer",key:"l"},{id:"rail",key:"k",shift:!0,aliases:["l"]},{id:"keys",key:","},{id:"terminal",key:"j",ctrlAlias:{key:"`"}},{id:"design",key:"d"},{id:"term-tab",key:"`",ctrl:!0,shift:!0},{id:"pick",key:"e"},{id:"inspect",key:"i"},{id:"zen",key:"."},{id:"new",key:"k",aliases:["n"]},{id:"worktree",key:"1-9"},{id:"wt-prev",key:"ArrowUp",alt:!0,ctrlAlias:{key:"Tab",shift:!0},cmdShiftAlias:["[","{"]},{id:"wt-next",key:"ArrowDown",alt:!0,ctrlAlias:{key:"Tab"},cmdShiftAlias:["]","}"]},{id:"wt-unseen-prev",key:"ArrowUp",alt:!0,shift:!0},{id:"wt-unseen-next",key:"ArrowDown",alt:!0,shift:!0},{id:"mark-unread",key:"u",shift:!0},{id:"project",key:"o",ctrlAlias:{key:"r",hostOnly:!0},cmdShiftAlias:["o"]},{id:"refs",key:"g",shift:!0},{id:"routes",key:"g"}];function H(e,{guest:t=!1}={}){if(e.altKey){if(e.metaKey||e.ctrlKey)return null;let r=B.find((i)=>i.alt&&i.key===e.key&&!!i.shift===e.shiftKey);return r&&r.id!=="worktree"?{id:r.id}:null}if(!!e.ctrlKey===e.metaKey)return null;let n=e.key.length===1?e.key.toLowerCase():e.key;if(e.metaKey&&!e.shiftKey&&n>="1"&&n<="9")return{id:"worktree",digit:Number(n)};for(let r of B){if(r.id==="worktree")continue;let i=r.ctrlAlias;if(i&&e.ctrlKey&&i.key===n&&!!i.shift===e.shiftKey&&!(t&&i.hostOnly))return{id:r.id};if(e.metaKey&&e.shiftKey&&r.cmdShiftAlias?.includes(n))return{id:r.id};if(r.alt)continue;if(e.ctrlKey&&!r.ctrl||!!r.shift!==e.shiftKey)continue;if(r.key===n||r.aliases?.includes(n))return{id:r.id}}return null}var G=Symbol.for("react.forward_ref"),V=Symbol.for("react.memo");function R(e){if(e._debugSource?.fileName)return{file:e._debugSource.fileName,line:e._debugSource.lineNumber};let t=e._debugStack?.stack;if(t){let n=t.match(/https?:\/\/[^/]+(\/src\/[^)\s?]+)(?:\?[^:)\s]*)?:(\d+):\d+/);if(n?.[1])return{file:n[1],line:Number(n[2])||void 0}}return null}function A(e){for(let t=e;t;t=t.return){let n=R(t);if(n)return n}return null}function C(e){if(typeof e==="function")return e.displayName||e.name||null;let t=e;if(t?.$$typeof===G)return t.displayName||C(t.render);if(t?.$$typeof===V)return t.displayName||C(t.type);return null}var J=(e)=>typeof e.type==="string"||e.tag===6,Q=(e,t)=>!!e&&(e===t||!!e.stateNode&&e.stateNode===t.stateNode);function Z(e){let t=null,n=(r)=>{for(let i=r.child??null;i;i=i.sibling??null)if(J(i)){if(t)return!1;t=i}else if(!n(i))return!1;return!0};return n(e)?t:null}function ee(e){for(let t=e;t;t=t.return){let n=R(t);if(n)return t._debugOwner===null?null:n}return null}function _(e){let t=A(e),n=null,r=null,i=!1;for(let o=e;o;o=o.return){let s=C(o.type);if(!s)continue;let l=!!e&&Q(Z(o),e),a=ee(o);if(n&&!(l&&a))break;if(n=s,r=a,i=l,!l)break}if(r&&t&&r.file===t.file&&r.line===t.line)r=null;return{src:t,comp:n,call:r,wraps:i}}function L({src:e,call:t,wraps:n},r){let i=n?t:e,o=n?e:t;return(r?o??i:i??o)??null}if(window.__toyonBridge)throw Error("Toyon bridge already installed");window.__toyonBridge=!0;var b=window.__toyonShellOrigins??[],M=null,c=(e)=>{try{let t=M?[M]:b.length?b:["*"];for(let n of t)window.parent.postMessage({__toyon:!0,...e},n)}catch{}};c({type:"loaded",url:location.href,title:document.title});var w="#ff4929",W="#1d2021";window.addEventListener("vite:afterUpdate",()=>c({type:"hmr"}));window.addEventListener("error",(e)=>{c({type:"page-error",message:String(e.message),source:e.filename,line:e.lineno})});window.addEventListener("unhandledrejection",(e)=>{c({type:"page-error",message:`unhandled rejection: ${String(e.reason)}`})});var S=()=>c({type:"navigated",url:location.href,title:document.title}),te=history.pushState.bind(history);history.pushState=(...e)=>{te(...e),S()};var ne=history.replaceState.bind(history);history.replaceState=(...e)=>{ne(...e),S()};window.addEventListener("popstate",S);window.addEventListener("hashchange",S);var K=document.title;if(document.head)new MutationObserver(()=>{if(document.title===K)return;K=document.title,c({type:"title",title:K})}).observe(document.head,{childList:!0,subtree:!0,characterData:!0});var j=!1;window.addEventListener("keydown",(e)=>{if(window.__toyonShell)return;let t=H(e,{guest:!0});if(j){if(t?.id!=="zen")return}else if(e.key==="Escape"){c({type:"key",key:"Escape",meta:!1});return}else if(!t)return;e.preventDefault(),e.stopPropagation(),c({type:"key",key:e.key,meta:e.metaKey,ctrl:e.ctrlKey,shift:e.shiftKey,alt:e.altKey})},!0);var q=(e)=>!e.defaultPrevented&&!!e.dataTransfer?.types.includes("Files");window.addEventListener("dragover",(e)=>{if(!q(e))return;if(e.preventDefault(),e.dataTransfer)e.dataTransfer.dropEffect="none";c({type:"drag-files"})});window.addEventListener("drop",(e)=>{if(!q(e))return;e.preventDefault(),c({type:"drop-files"})});function O(e){for(let t of Object.keys(e))if(t.startsWith("__reactFiber$"))return e[t]??null;return null}var p=null;function re(){if(p?.isConnected)return p;return p=document.createElement("div"),p.style.cssText="position:fixed;inset:0;pointer-events:none;z-index:2147483647;",document.documentElement.appendChild(p),p}function y(){if(p)p.innerHTML=""}var F=20;function E(e,t,n=!0){let r=document.createElement("div");if(r.style.cssText=`position:fixed;left:${e.left}px;top:${e.top}px;width:${e.width}px;height:${e.height}px;outline:2px solid ${w};outline-offset:-1px;${n?`background:${w}14;`:""}border-radius:2px;`,t){let i=e.top>=F,o=e.bottom+F<=window.innerHeight;if(t.style.top=i?`${-F}px`:o?`${e.height+4}px`:"2px",!i&&!o)t.style.left="2px";r.appendChild(t)}if(re().appendChild(r),t){let i=t.getBoundingClientRect(),o=i.right-(window.innerWidth-2);if(o>0){let s=Number.parseFloat(t.style.left||"0");t.style.left=`${s-Math.min(o,Math.max(0,i.left-2))}px`}}}function g(e,t){let n=document.createElement("div");if(n.textContent=e,n.style.cssText=`position:absolute;left:0;background:${w};color:${W};font:11px -apple-system,sans-serif;padding:1px 6px;border-radius:3px;white-space:nowrap;`,t){let r=document.createElement("span");r.textContent=` ${t}`,r.style.opacity="0.55",n.appendChild(r)}return n}var x=!1,d=null,h=!1,f=!1,m=!1,N=(e)=>`${U(e.file)}${e.line?`:${e.line}`:""}`;function T(e){d=e,y();let t=_(O(e)),{src:n,comp:r,call:i}=t,o=L(t,f),s=o===n?i:n,l=h!==m,a=(...k)=>k.filter(Boolean).join(" ")||void 0,u=l?o?g(`open ${N(o)}`,a(s&&`⇧ ${N(s)}`,m&&"⌥ chat")):g(`find ${I(e)}`,a(m&&"⌥ chat")):g(r?`<${r} />${o?` · ${N(o)}`:""}`:I(e),a(!m&&"⌥ code"));E(e.getBoundingClientRect(),u,l)}function I(e){let t=e.tagName.toLowerCase(),n=e.classList[0];return(e.id?`${t}#${e.id}`:n?`${t}.${n}`:t).slice(0,48)}var ie=new Set(["name","placeholder","aria-label","title","alt","for","href","type","role","src"]);function oe(e){let t="";for(let r of Array.from(e.childNodes))if(r.nodeType===Node.TEXT_NODE)t+=r.textContent??"";let n=[];for(let r of Array.from(e.attributes)){if(n.length===12)break;if(r.value&&(ie.has(r.name)||r.name.startsWith("data-")))n.push([r.name.slice(0,40),r.value.slice(0,200)])}return{tag:e.tagName.toLowerCase().slice(0,40),id:e.id.slice(0,200),classes:Array.from(e.classList).slice(0,16).map((r)=>r.slice(0,120)),text:t.replace(/\s+/g," ").trim().slice(0,200),attrs:n}}function z(e){let t=document.elementFromPoint(e.clientX,e.clientY);if(!t)return;let n=t!==d||e.altKey!==h||e.shiftKey!==f;if(h=e.altKey,f=e.shiftKey,n)T(t)}function X(e){e.preventDefault(),e.stopPropagation();let t=d??document.elementFromPoint(e.clientX,e.clientY),n=_(t?O(t):null),{src:r,comp:i,call:o}=n;f=e.shiftKey;let s=L(n,f),l=e.altKey!==m;if(P(),!t)return;c({type:"picked",verb:l?"code":"chat",site:s&&s===o?"call":"source",component:i,file:r?.file??null,line:r?.line??null,callFile:o?.file??null,callLine:o?.line??null,selector:se(t),tag:t.tagName.toLowerCase(),classes:t.className?.toString?.().slice(0,200)??"",text:t.textContent?.trim().slice(0,120)??"",html:t.outerHTML.slice(0,600),route:location.pathname+location.search,element:oe(t)})}function v(e){if(e.key==="Escape"&&e.type==="keydown"){e.preventDefault(),e.stopPropagation(),P(),c({type:"pick-cancel"});return}if((e.key==="Alt"||e.key==="Shift")&&(h!==e.altKey||f!==e.shiftKey)){if(h=e.altKey,f=e.shiftKey,d)T(d)}}function le(e){if(m=e,x){if(d)T(d);return}x=!0,d=null,h=!1,f=!1,document.addEventListener("mousemove",z,!0),document.addEventListener("click",X,!0),document.addEventListener("keydown",v,!0),document.addEventListener("keyup",v,!0),document.documentElement.style.cursor="crosshair"}function P(){x=!1,m=!1,d=null,h=!1,f=!1,y(),document.removeEventListener("mousemove",z,!0),document.removeEventListener("click",X,!0),document.removeEventListener("keydown",v,!0),document.removeEventListener("keyup",v,!0),document.documentElement.style.cursor=""}function se(e){let t=[],n=e;for(let r=0;n&&n!==document.documentElement&&r<6;r++){if(n.id){t.unshift(`#${CSS.escape(n.id)}`);break}let i=n.parentElement,o=i?Array.from(i.children).indexOf(n)+1:1;t.unshift(`${n.tagName.toLowerCase()}:nth-child(${o})`),n=i}return t.join(" > ")}function U(e){let t=e.lastIndexOf("/src/");return t>=0?e.slice(t+1):e.split("/").slice(-2).join("/")}function ae(e,t){return e.endsWith(t)||t.endsWith(U(e))}function ce(e,t){let n=[],r=0;for(let s of Array.from(document.querySelectorAll("*"))){let l=A(O(s));if(l)r++;if(!l||!ae(l.file,e))continue;n.push({el:s,line:l.line??-1})}if(!t||t.length===0)return{matched:n,fromFile:n,withSource:r};if(t.length===1&&t[0][0]===t[0][1]){let s=t[0][0],l=n.filter((u)=>u.line===s);if(l.length>0)return{matched:l,fromFile:n,withSource:r};let a=n.filter((u)=>u.line>0&&u.line<s);return a.sort((u,k)=>k.line-u.line),{matched:a.slice(0,1),fromFile:n,withSource:r}}return{matched:n.filter((s)=>t.some(([l,a])=>s.line>=l-8&&s.line<=a+1)),fromFile:n,withSource:r}}function ue(e,t){y();let{matched:n,fromFile:r,withSource:i}=ce(e,t),o=0;for(let{el:s}of n){if(o>=40)break;let l=s.getBoundingClientRect();if(l.width>0&&l.height>0)E(l),o++}if(o===0)c({type:"highlight-miss",path:e,fileMatched:r.length,withSource:i,ranges:t})}window.addEventListener("message",(e)=>{if(e.source!==window.parent)return;if(b.length&&!b.includes(e.origin))return;let t=e.data;if(!t?.__toyon)return;M=e.origin;let n=t;switch(n.type){case"reload":location.reload();break;case"navigate":if(/^[/?#]/.test(n.path))location.assign(n.path);break;case"back":history.back();break;case"forward":history.forward();break;case"links":{let r=new Set,i=[];for(let o of Array.from(document.querySelectorAll("a[href]"))){if(o.origin!==location.origin||o.target==="_blank"||o.hasAttribute("download"))continue;let s=o.pathname+(o.hash.startsWith("#/")?o.hash:"");if(s.startsWith("/__toyon")||r.has(s))continue;r.add(s);let l=(o.textContent||o.getAttribute("aria-label")||"").replace(/\s+/g," ").trim();if(i.push({path:s,text:l.slice(0,80)}),i.length>=200)break}c({type:"links",links:i});break}case"pick-start":le(n.verb==="code");break;case"pick-mods":if(x&&(h!==n.alt||f!==n.shift)){if(h=n.alt,f=n.shift,d)T(d)}break;case"pick-cancel":P();break;case"highlight-file":ue(n.path,n.ranges??null);break;case"highlight-computed":{y();let r=/^(color|font|line-height|letter-|text-|word-)/,i=(l)=>{if(/^(INPUT|TEXTAREA|SELECT)$/.test(l.tagName))return!0;for(let a=l.firstChild;a;a=a.nextSibling)if(a.nodeType===3&&a.textContent&&a.textContent.trim())return!0;return!1},o=document.querySelectorAll("*"),s=!0;for(let l=0;l<o.length;l++){let a=getComputedStyle(o[l]),u=([D,Y])=>a.getPropertyValue(D)===Y&&(!r.test(D)||i(o[l]));if(n.match==="any"?n.props.some(u):n.props.every(u))E(o[l].getBoundingClientRect(),s&&n.label?g(n.label):void 0),s=!1}break}case"highlight-selector":{y();try{let r=document.querySelectorAll(n.selector);for(let i=0;i<r.length;i++)E(r[i].getBoundingClientRect(),i===0&&n.label?g(n.label):void 0)}catch{}break}case"highlight-clear":y();break;case"zen":j=n.on;break;case"theme":if(/^#[0-9a-f]{3,8}$/i.test(n.accent))w=n.accent;if(/^#[0-9a-f]{3,8}$/i.test(n.accentFg))W=n.accentFg;break}});
1
+ var T=[{id:"quick-open",key:"p"},{id:"commands",key:"p",shift:!0,bareAlias:"F1"},{id:"search",key:"f",shift:!0},{id:"chats",key:"g"},{id:"changes",key:"b",ctrlAlias:{key:"g",shift:!0}},{id:"files",key:"e",shift:!0},{id:"composer",key:"l"},{id:"rail",key:"k",shift:!0},{id:"keys",key:","},{id:"terminal",key:"j",ctrlAlias:{key:"`"}},{id:"design",key:"d"},{id:"term-tab",key:"`",ctrl:!0,shift:!0},{id:"pick",key:"e"},{id:"inspect",key:"i"},{id:"zen",key:"."},{id:"new",key:"k",aliases:["n"]},{id:"worktree",key:"1-9"},{id:"wt-prev",key:"ArrowUp",alt:!0,ctrlAlias:{key:"Tab",shift:!0},cmdShiftAlias:["[","{"]},{id:"wt-next",key:"ArrowDown",alt:!0,ctrlAlias:{key:"Tab"},cmdShiftAlias:["]","}"]},{id:"wt-unseen-prev",key:"ArrowUp",alt:!0,shift:!0},{id:"wt-unseen-next",key:"ArrowDown",alt:!0,shift:!0},{id:"mark-unread",key:"u",shift:!0},{id:"project",key:"o",ctrlAlias:{key:"r",hostOnly:!0},cmdShiftAlias:["o"]},{id:"refs",key:"g",shift:!0},{id:"routes",key:"u"},{id:"reload",key:"r"}];function H(e,{guest:t=!1}={}){if(e.altKey){if(e.metaKey||e.ctrlKey)return null;let r=T.find((i)=>i.alt&&i.key===e.key&&!!i.shift===e.shiftKey);return r&&r.id!=="worktree"?{id:r.id}:null}if(!e.metaKey&&!e.ctrlKey){if(e.shiftKey||t)return null;let r=T.find((i)=>i.bareAlias===e.key);return r&&r.id!=="worktree"?{id:r.id}:null}if(!!e.ctrlKey===e.metaKey)return null;let n=e.key.length===1?e.key.toLowerCase():e.key;if(e.metaKey&&!e.shiftKey&&n>="1"&&n<="9")return{id:"worktree",digit:Number(n)};for(let r of T){if(r.id==="worktree")continue;let i=r.ctrlAlias;if(i&&e.ctrlKey&&i.key===n&&!!i.shift===e.shiftKey&&!(t&&i.hostOnly))return{id:r.id};if(e.metaKey&&e.shiftKey&&r.cmdShiftAlias?.includes(n))return{id:r.id};if(r.alt)continue;if(e.ctrlKey&&!r.ctrl||!!r.shift!==e.shiftKey)continue;if(r.key===n||r.aliases?.includes(n))return{id:r.id}}return null}var G=Symbol.for("react.forward_ref"),V=Symbol.for("react.memo");function R(e){if(e._debugSource?.fileName)return{file:e._debugSource.fileName,line:e._debugSource.lineNumber};let t=e._debugStack?.stack;if(t){let n=t.match(/https?:\/\/[^/]+(\/src\/[^)\s?]+)(?:\?[^:)\s]*)?:(\d+):\d+/);if(n?.[1])return{file:n[1],line:Number(n[2])||void 0}}return null}function _(e){for(let t=e;t;t=t.return){let n=R(t);if(n)return n}return null}function C(e){if(typeof e==="function")return e.displayName||e.name||null;let t=e;if(t?.$$typeof===G)return t.displayName||C(t.render);if(t?.$$typeof===V)return t.displayName||C(t.type);return null}var J=(e)=>typeof e.type==="string"||e.tag===6,Q=(e,t)=>!!e&&(e===t||!!e.stateNode&&e.stateNode===t.stateNode);function Z(e){let t=null,n=(r)=>{for(let i=r.child??null;i;i=i.sibling??null)if(J(i)){if(t)return!1;t=i}else if(!n(i))return!1;return!0};return n(e)?t:null}function ee(e){for(let t=e;t;t=t.return){let n=R(t);if(n)return t._debugOwner===null?null:n}return null}function K(e){let t=_(e),n=null,r=null,i=!1;for(let o=e;o;o=o.return){let s=C(o.type);if(!s)continue;let l=!!e&&Q(Z(o),e),a=ee(o);if(n&&!(l&&a))break;if(n=s,r=a,i=l,!l)break}if(r&&t&&r.file===t.file&&r.line===t.line)r=null;return{src:t,comp:n,call:r,wraps:i}}function L({src:e,call:t,wraps:n},r){let i=n?t:e,o=n?e:t;return(r?o??i:i??o)??null}if(window.__toyonBridge)throw Error("Toyon bridge already installed");window.__toyonBridge=!0;var b=window.__toyonShellOrigins??[],O=null,c=(e)=>{try{let t=O?[O]:b.length?b:["*"];for(let n of t)window.parent.postMessage({__toyon:!0,...e},n)}catch{}};c({type:"loaded",url:location.href,title:document.title});var w="#ff4929",W="#1d2021";window.addEventListener("vite:afterUpdate",()=>c({type:"hmr"}));window.addEventListener("error",(e)=>{c({type:"page-error",message:String(e.message),source:e.filename,line:e.lineno})});window.addEventListener("unhandledrejection",(e)=>{c({type:"page-error",message:`unhandled rejection: ${String(e.reason)}`})});var S=()=>c({type:"navigated",url:location.href,title:document.title}),te=history.pushState.bind(history);history.pushState=(...e)=>{te(...e),S()};var ne=history.replaceState.bind(history);history.replaceState=(...e)=>{ne(...e),S()};window.addEventListener("popstate",S);window.addEventListener("hashchange",S);var F=document.title;if(document.head)new MutationObserver(()=>{if(document.title===F)return;F=document.title,c({type:"title",title:F})}).observe(document.head,{childList:!0,subtree:!0,characterData:!0});var j=!1;window.addEventListener("keydown",(e)=>{if(window.__toyonShell)return;let t=H(e,{guest:!0});if(j){if(t?.id!=="zen")return}else if(e.key==="Escape"){c({type:"key",key:"Escape",meta:!1});return}else if(!t)return;e.preventDefault(),e.stopPropagation(),c({type:"key",key:e.key,meta:e.metaKey,ctrl:e.ctrlKey,shift:e.shiftKey,alt:e.altKey})},!0);var q=(e)=>!e.defaultPrevented&&!!e.dataTransfer?.types.includes("Files");window.addEventListener("dragover",(e)=>{if(!q(e))return;if(e.preventDefault(),e.dataTransfer)e.dataTransfer.dropEffect="none";c({type:"drag-files"})});window.addEventListener("drop",(e)=>{if(!q(e))return;e.preventDefault(),c({type:"drop-files"})});function P(e){for(let t of Object.keys(e))if(t.startsWith("__reactFiber$"))return e[t]??null;return null}var p=null;function re(){if(p?.isConnected)return p;return p=document.createElement("div"),p.style.cssText="position:fixed;inset:0;pointer-events:none;z-index:2147483647;",document.documentElement.appendChild(p),p}function m(){if(p)p.innerHTML=""}var N=20;function E(e,t,n=!0){let r=document.createElement("div");if(r.style.cssText=`position:fixed;left:${e.left}px;top:${e.top}px;width:${e.width}px;height:${e.height}px;outline:2px solid ${w};outline-offset:-1px;${n?`background:${w}14;`:""}border-radius:2px;`,t){let i=e.top>=N,o=e.bottom+N<=window.innerHeight;if(t.style.top=i?`${-N}px`:o?`${e.height+4}px`:"2px",!i&&!o)t.style.left="2px";r.appendChild(t)}if(re().appendChild(r),t){let i=t.getBoundingClientRect(),o=i.right-(window.innerWidth-2);if(o>0){let s=Number.parseFloat(t.style.left||"0");t.style.left=`${s-Math.min(o,Math.max(0,i.left-2))}px`}}}function g(e,t){let n=document.createElement("div");if(n.textContent=e,n.style.cssText=`position:absolute;left:0;background:${w};color:${W};font:11px -apple-system,sans-serif;padding:1px 6px;border-radius:3px;white-space:nowrap;`,t){let r=document.createElement("span");r.textContent=` ${t}`,r.style.opacity="0.55",n.appendChild(r)}return n}var x=!1,d=null,h=!1,f=!1,y=!1,M=(e)=>`${U(e.file)}${e.line?`:${e.line}`:""}`;function A(e){d=e,m();let t=K(P(e)),{src:n,comp:r,call:i}=t,o=L(t,f),s=o===n?i:n,l=h!==y,a=(...k)=>k.filter(Boolean).join(" ")||void 0,u=l?o?g(`open ${M(o)}`,a(s&&`⇧ ${M(s)}`,y&&"⌥ chat")):g(`find ${I(e)}`,a(y&&"⌥ chat")):g(r?`<${r} />${o?` · ${M(o)}`:""}`:I(e),a(!y&&"⌥ code"));E(e.getBoundingClientRect(),u,l)}function I(e){let t=e.tagName.toLowerCase(),n=e.classList[0];return(e.id?`${t}#${e.id}`:n?`${t}.${n}`:t).slice(0,48)}var ie=new Set(["name","placeholder","aria-label","title","alt","for","href","type","role","src"]);function oe(e){let t="";for(let r of Array.from(e.childNodes))if(r.nodeType===Node.TEXT_NODE)t+=r.textContent??"";let n=[];for(let r of Array.from(e.attributes)){if(n.length===12)break;if(r.value&&(ie.has(r.name)||r.name.startsWith("data-")))n.push([r.name.slice(0,40),r.value.slice(0,200)])}return{tag:e.tagName.toLowerCase().slice(0,40),id:e.id.slice(0,200),classes:Array.from(e.classList).slice(0,16).map((r)=>r.slice(0,120)),text:t.replace(/\s+/g," ").trim().slice(0,200),attrs:n}}function z(e){let t=document.elementFromPoint(e.clientX,e.clientY);if(!t)return;let n=t!==d||e.altKey!==h||e.shiftKey!==f;if(h=e.altKey,f=e.shiftKey,n)A(t)}function X(e){e.preventDefault(),e.stopPropagation();let t=d??document.elementFromPoint(e.clientX,e.clientY),n=K(t?P(t):null),{src:r,comp:i,call:o}=n;f=e.shiftKey;let s=L(n,f),l=e.altKey!==y;if(D(),!t)return;c({type:"picked",verb:l?"code":"chat",site:s&&s===o?"call":"source",component:i,file:r?.file??null,line:r?.line??null,callFile:o?.file??null,callLine:o?.line??null,selector:se(t),tag:t.tagName.toLowerCase(),classes:t.className?.toString?.().slice(0,200)??"",text:t.textContent?.trim().slice(0,120)??"",html:t.outerHTML.slice(0,600),route:location.pathname+location.search,element:oe(t)})}function v(e){if(e.key==="Escape"&&e.type==="keydown"){e.preventDefault(),e.stopPropagation(),D(),c({type:"pick-cancel"});return}if((e.key==="Alt"||e.key==="Shift")&&(h!==e.altKey||f!==e.shiftKey)){if(h=e.altKey,f=e.shiftKey,d)A(d)}}function le(e){if(y=e,x){if(d)A(d);return}x=!0,d=null,h=!1,f=!1,document.addEventListener("mousemove",z,!0),document.addEventListener("click",X,!0),document.addEventListener("keydown",v,!0),document.addEventListener("keyup",v,!0),document.documentElement.style.cursor="crosshair"}function D(){x=!1,y=!1,d=null,h=!1,f=!1,m(),document.removeEventListener("mousemove",z,!0),document.removeEventListener("click",X,!0),document.removeEventListener("keydown",v,!0),document.removeEventListener("keyup",v,!0),document.documentElement.style.cursor=""}function se(e){let t=[],n=e;for(let r=0;n&&n!==document.documentElement&&r<6;r++){if(n.id){t.unshift(`#${CSS.escape(n.id)}`);break}let i=n.parentElement,o=i?Array.from(i.children).indexOf(n)+1:1;t.unshift(`${n.tagName.toLowerCase()}:nth-child(${o})`),n=i}return t.join(" > ")}function U(e){let t=e.lastIndexOf("/src/");return t>=0?e.slice(t+1):e.split("/").slice(-2).join("/")}function ae(e,t){return e.endsWith(t)||t.endsWith(U(e))}function ce(e,t){let n=[],r=0;for(let s of Array.from(document.querySelectorAll("*"))){let l=_(P(s));if(l)r++;if(!l||!ae(l.file,e))continue;n.push({el:s,line:l.line??-1})}if(!t||t.length===0)return{matched:n,fromFile:n,withSource:r};if(t.length===1&&t[0][0]===t[0][1]){let s=t[0][0],l=n.filter((u)=>u.line===s);if(l.length>0)return{matched:l,fromFile:n,withSource:r};let a=n.filter((u)=>u.line>0&&u.line<s);return a.sort((u,k)=>k.line-u.line),{matched:a.slice(0,1),fromFile:n,withSource:r}}return{matched:n.filter((s)=>t.some(([l,a])=>s.line>=l-8&&s.line<=a+1)),fromFile:n,withSource:r}}function ue(e,t){m();let{matched:n,fromFile:r,withSource:i}=ce(e,t),o=0;for(let{el:s}of n){if(o>=40)break;let l=s.getBoundingClientRect();if(l.width>0&&l.height>0)E(l),o++}if(o===0)c({type:"highlight-miss",path:e,fileMatched:r.length,withSource:i,ranges:t})}window.addEventListener("message",(e)=>{if(e.source!==window.parent)return;if(b.length&&!b.includes(e.origin))return;let t=e.data;if(!t?.__toyon)return;O=e.origin;let n=t;switch(n.type){case"reload":location.reload();break;case"navigate":if(/^[/?#]/.test(n.path))location.assign(n.path);break;case"back":history.back();break;case"forward":history.forward();break;case"links":{let r=new Set,i=[];for(let o of Array.from(document.querySelectorAll("a[href]"))){if(o.origin!==location.origin||o.target==="_blank"||o.hasAttribute("download"))continue;let s=o.pathname+(o.hash.startsWith("#/")?o.hash:"");if(s.startsWith("/__toyon")||r.has(s))continue;r.add(s);let l=(o.textContent||o.getAttribute("aria-label")||"").replace(/\s+/g," ").trim();if(i.push({path:s,text:l.slice(0,80)}),i.length>=200)break}c({type:"links",links:i});break}case"pick-start":le(n.verb==="code");break;case"pick-mods":if(x&&(h!==n.alt||f!==n.shift)){if(h=n.alt,f=n.shift,d)A(d)}break;case"pick-cancel":D();break;case"highlight-file":ue(n.path,n.ranges??null);break;case"highlight-computed":{m();let r=/^(color|font|line-height|letter-|text-|word-)/,i=(l)=>{if(/^(INPUT|TEXTAREA|SELECT)$/.test(l.tagName))return!0;for(let a=l.firstChild;a;a=a.nextSibling)if(a.nodeType===3&&a.textContent&&a.textContent.trim())return!0;return!1},o=document.querySelectorAll("*"),s=!0;for(let l=0;l<o.length;l++){let a=getComputedStyle(o[l]),u=([B,Y])=>a.getPropertyValue(B)===Y&&(!r.test(B)||i(o[l]));if(n.match==="any"?n.props.some(u):n.props.every(u))E(o[l].getBoundingClientRect(),s&&n.label?g(n.label):void 0),s=!1}break}case"highlight-selector":{m();try{let r=document.querySelectorAll(n.selector);for(let i=0;i<r.length;i++)E(r[i].getBoundingClientRect(),i===0&&n.label?g(n.label):void 0)}catch{}break}case"highlight-clear":m();break;case"zen":j=n.on;break;case"theme":if(/^#[0-9a-f]{3,8}$/i.test(n.accent))w=n.accent;if(/^#[0-9a-f]{3,8}$/i.test(n.accentFg))W=n.accentFg;break}});