pi-roundtable-web 0.29.2 → 0.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/README.md +3 -3
- package/dist/chunk-account-51nmc9g6.js +1 -0
- package/dist/{chunk-action-menu-37zgbhje.js → chunk-action-menu-mxcvx4a1.js} +1 -1
- package/dist/chunk-agent-x53f7c2h.js +1 -0
- package/dist/chunk-arranged-rooms-1w3zqdtt.js +1 -0
- package/dist/{chunk-attachments-3vbj05g5.js → chunk-attachments-qbv5ar62.js} +2 -2
- package/dist/chunk-bulk-actions-aktwxqc9.js +1 -0
- package/dist/{chunk-character-creator-bg3tdc8p.js → chunk-character-creator-1mfybhjz.js} +2 -2
- package/dist/{chunk-codeeditor-102wa9bj.js → chunk-codeeditor-y2emmmr0.js} +2 -2
- package/dist/chunk-command-menu-sj2kfe4d.js +59 -0
- package/dist/chunk-confirm-ex5kc1st.js +1 -0
- package/dist/{chunk-connectors-0jzzren3.js → chunk-connectors-1nmm8yc3.js} +2 -2
- package/dist/{chunk-conversations-3276jq4q.js → chunk-conversations-ec3aqjxs.js} +1 -1
- package/dist/chunk-council-sheet-hdsg3fes.js +2 -0
- package/dist/chunk-council-view-sba8fs4c.js +1 -0
- package/dist/{chunk-drag-sw692nr3.js → chunk-drag-pkghf4ts.js} +1 -1
- package/dist/{chunk-entry-mb6jd983.js → chunk-entry-e24gjxtd.js} +1 -1
- package/dist/{chunk-folder-list-g7st6p1e.js → chunk-folder-list-kghgyc0x.js} +1 -1
- package/dist/chunk-folds-crd9k375.js +1 -0
- package/dist/chunk-gate-xay9vedw.js +1 -0
- package/dist/chunk-host-icons-y9hd1qqd.js +1 -0
- package/dist/chunk-host-picture-k16n5wm3.js +1 -0
- package/dist/chunk-host-state-1mbsrmhk.js +1 -0
- package/dist/chunk-host-ui-4pymhn6v.js +1 -0
- package/dist/{chunk-index-e8535c4h.js → chunk-index-0dyf2gdm.js} +2 -2
- package/dist/chunk-index-14cxgacv.js +2 -0
- package/dist/{chunk-index-edjyj761.js → chunk-index-37g8ggry.js} +1 -1
- package/dist/chunk-index-39gw0qhr.js +2 -0
- package/dist/chunk-index-4p45h04z.js +2 -0
- package/dist/chunk-index-5e8wn6r3.js +2 -0
- package/dist/chunk-index-65p4hfkr.js +2 -0
- package/dist/{chunk-index-6yfcfcc8.js → chunk-index-6e9nmad3.js} +1 -1
- package/dist/chunk-index-6f4qvp5p.js +2 -0
- package/dist/{chunk-index-yn1vvxj2.js → chunk-index-6hy2fabj.js} +1 -1
- package/dist/{chunk-index-0qzqzp6t.js → chunk-index-6j75embz.js} +2 -2
- package/dist/{chunk-index-1tkzdy4s.js → chunk-index-70pq2k7q.js} +2 -2
- package/dist/{chunk-index-7gk2sdf4.js → chunk-index-726w3145.js} +3 -3
- package/dist/chunk-index-86x6b7dx.js +3 -0
- package/dist/chunk-index-8cxmgzhy.js +2 -0
- package/dist/{chunk-index-gmbk3sra.js → chunk-index-93dr9fh8.js} +1 -1
- package/dist/chunk-index-97238pp8.js +2 -0
- package/dist/{chunk-index-7p31pda8.js → chunk-index-ads1abh1.js} +3 -3
- package/dist/{chunk-index-jrj09r5c.js → chunk-index-awc03q99.js} +2 -2
- package/dist/chunk-index-bh6m0bpm.js +2 -0
- package/dist/chunk-index-br1wechm.js +2 -0
- package/dist/{chunk-index-qedt9szy.js → chunk-index-c8vsw9h8.js} +2 -2
- package/dist/{chunk-index-mey1p7h8.js → chunk-index-cd0ymvtj.js} +2 -2
- package/dist/{chunk-index-50w6yq2d.js → chunk-index-e3encn5p.js} +1 -1
- package/dist/{chunk-index-d941ae7c.js → chunk-index-fw6kawhw.js} +2 -2
- package/dist/{chunk-index-6ycrvwzs.js → chunk-index-g3f1sdw0.js} +2 -2
- package/dist/{chunk-index-6cs1wvhy.js → chunk-index-gae833v6.js} +1 -1
- package/dist/{chunk-index-m8bv51r9.js → chunk-index-gc30hm37.js} +2 -2
- package/dist/{chunk-index-5fyqxh0r.js → chunk-index-gpaychmm.js} +2 -2
- package/dist/chunk-index-hk6aq03d.js +2 -0
- package/dist/chunk-index-k3hj2310.js +2 -0
- package/dist/chunk-index-maf6wr1b.js +2 -0
- package/dist/{chunk-index-eyythjdx.js → chunk-index-mhb8mpg3.js} +2 -2
- package/dist/chunk-index-n92zea3s.js +2 -0
- package/dist/{chunk-index-m7wzrmcd.js → chunk-index-ndhwytvz.js} +2 -2
- package/dist/{chunk-index-qk7rp7fk.js → chunk-index-ne8v2rxx.js} +12 -12
- package/dist/chunk-index-p4rc9swx.js +2 -0
- package/dist/chunk-index-pce4byw4.js +2 -0
- package/dist/{chunk-index-6nja2vd8.js → chunk-index-ptvrkv0r.js} +2 -2
- package/dist/{chunk-index-mzw7nmkc.js → chunk-index-pz6926p5.js} +2 -2
- package/dist/chunk-index-qb41kkt3.js +2 -0
- package/dist/{chunk-index-5x3h176v.js → chunk-index-qqaaxh63.js} +2 -2
- package/dist/chunk-index-qwztcbjz.js +2 -0
- package/dist/chunk-index-r1g24er0.js +2 -0
- package/dist/chunk-index-rvatmx8s.js +50 -0
- package/dist/{chunk-index-qq86fxda.js → chunk-index-tfgd7vr5.js} +2 -2
- package/dist/{chunk-index-qw9a7ken.js → chunk-index-tqrjr37v.js} +2 -2
- package/dist/chunk-index-tvsvtd4q.js +2 -0
- package/dist/chunk-index-vaxytvde.js +2 -0
- package/dist/{chunk-index-n2v2bz8d.js → chunk-index-ve07gdef.js} +1 -1
- package/dist/chunk-index-vw592m3p.js +2 -0
- package/dist/{chunk-index-y1xv3dxs.js → chunk-index-vwd5drzh.js} +4 -4
- package/dist/{chunk-index-0t68az7d.js → chunk-index-vxn4zws9.js} +3 -3
- package/dist/{chunk-index-6m25qpa7.js → chunk-index-wqbcade7.js} +2 -2
- package/dist/chunk-index-x7p6k52w.js +138 -0
- package/dist/{chunk-index-syxwqhry.js → chunk-index-xekytvrr.js} +1 -1
- package/dist/{chunk-index-6q3dx093.js → chunk-index-xkb336kq.js} +2 -2
- package/dist/{chunk-index-sk8cvb4e.js → chunk-index-xv3e4x0j.js} +2 -2
- package/dist/{chunk-index-50syrmaq.js → chunk-index-xvdna54d.js} +2 -2
- package/dist/chunk-index-yzd9cg0s.js +1 -0
- package/dist/{chunk-index-tasbd41t.js → chunk-index-zr2qwzz4.js} +2 -2
- package/dist/chunk-lang-css-6t2q4xw4.js +1 -0
- package/dist/{chunk-lang-dockerfile-e87ssppx.js → chunk-lang-dockerfile-9rc0adjw.js} +1 -1
- package/dist/{chunk-lang-go-kbcbn346.js → chunk-lang-go-t47kg9n0.js} +2 -2
- package/dist/chunk-lang-html-c6p22v5m.js +1 -0
- package/dist/chunk-lang-javascript-m57t19pw.js +1 -0
- package/dist/{chunk-lang-json-4pe1fv7e.js → chunk-lang-json-y33kawwg.js} +1 -1
- package/dist/{chunk-lang-markdown-67cm3tjx.js → chunk-lang-markdown-2c2sqc4z.js} +4 -4
- package/dist/{chunk-lang-python-mnfhcvww.js → chunk-lang-python-ymasvj52.js} +2 -2
- package/dist/{chunk-lang-rust-e4a9s76x.js → chunk-lang-rust-qcg53mkn.js} +1 -1
- package/dist/{chunk-lang-shell-43nea8tq.js → chunk-lang-shell-996wb0dk.js} +1 -1
- package/dist/{chunk-lang-sql-28364npv.js → chunk-lang-sql-60rh2y3y.js} +2 -2
- package/dist/{chunk-lang-toml-a83hr7bw.js → chunk-lang-toml-q1yzt70y.js} +1 -1
- package/dist/chunk-lang-typescript-7gcbrhbd.js +1 -0
- package/dist/{chunk-lang-xml-2hv5xc8n.js → chunk-lang-xml-k2a92cm3.js} +1 -1
- package/dist/{chunk-lang-yaml-vw22drt8.js → chunk-lang-yaml-qp3asq06.js} +1 -1
- package/dist/chunk-layout-actions-yxh77zcz.js +1 -0
- package/dist/chunk-mention-menu-qpksygcf.js +43 -0
- package/dist/chunk-menu-items-95evdhk1.js +1 -0
- package/dist/chunk-mode-toggle-dqwvcr2p.js +1 -0
- package/dist/{chunk-note-row-c0trzayj.js → chunk-note-row-ngzxbdn6.js} +4 -4
- package/dist/chunk-notes-9ykcajzc.js +1 -0
- package/dist/chunk-notice-bell-eryn2k5m.js +1 -0
- package/dist/{chunk-notices-gkaqncqz.js → chunk-notices-jkv1derx.js} +1 -1
- package/dist/{chunk-onboarding-fkq9ptcw.js → chunk-onboarding-ka11bgd0.js} +1 -1
- package/dist/{chunk-overview-yssxbg0d.js → chunk-overview-dgvrjwbc.js} +1 -1
- package/dist/{chunk-palette-w6qbr7zp.js → chunk-palette-wmvynt7n.js} +1 -1
- package/dist/chunk-placement-items-zyqq2mp7.js +1 -0
- package/dist/{chunk-profile-9sjgayrx.js → chunk-profile-sdn7bs08.js} +1 -1
- package/dist/chunk-prompt-history-qfnj4w2y.js +1 -0
- package/dist/chunk-prompts-4hdcvy6t.js +1 -0
- package/dist/chunk-room-confirms-b8gvak47.js +1 -0
- package/dist/chunk-room-menu-18mnqcja.js +1 -0
- package/dist/chunk-rooms-menu-button-hjg4zqjy.js +1 -0
- package/dist/{chunk-schedules-m9mn68gt.js → chunk-schedules-cy2dv8x0.js} +1 -1
- package/dist/{chunk-seat-menu-3tdcr44t.js → chunk-seat-menu-cw3z9560.js} +1 -1
- package/dist/chunk-section-fold-9tc2m103.js +1 -0
- package/dist/{chunk-settings-18qmhcyr.js → chunk-settings-rhdv64p7.js} +1 -1
- package/dist/chunk-sheet-hosts-hhs1e3a8.js +29 -0
- package/dist/chunk-shortcut-help-fv6b6ntc.js +26 -0
- package/dist/{chunk-shortcuts-qee393s5.js → chunk-shortcuts-sjwrv858.js} +1 -1
- package/dist/{chunk-skill-editor-pryntvpr.js → chunk-skill-editor-zzmv9nfq.js} +2 -2
- package/dist/chunk-skills-b2enxk30.js +1 -0
- package/dist/{chunk-start-over-line-azexcxj1.js → chunk-start-over-line-4rwasr8k.js} +2 -2
- package/dist/{chunk-switcher-list-6hacxjfe.js → chunk-switcher-list-dcq91xxa.js} +1 -1
- package/dist/{chunk-tab-dot-h0eskhrt.js → chunk-tab-dot-b3gcgcrq.js} +1 -1
- package/dist/chunk-table-6j64ps89.js +1 -0
- package/dist/{chunk-table2d-vy4w4r5k.js → chunk-table2d-k4z439nt.js} +1 -1
- package/dist/{chunk-table3d-0a62jerb.js → chunk-table3d-mx0afnv8.js} +23 -23
- package/dist/chunk-thread-actions-rs5xpf1r.js +1 -0
- package/dist/{chunk-thread-cards-mwxzy02t.js → chunk-thread-cards-k9m7p5fn.js} +1 -1
- package/dist/{chunk-thread-list-52mx2m9p.js → chunk-thread-list-zz7596zy.js} +2 -2
- package/dist/chunk-transcript-8yjp18cr.js +1 -0
- package/dist/chunk-waiting-9gshhhx0.js +1 -0
- package/dist/{chunk-waiting-chip-wvkbsnw5.js → chunk-waiting-chip-nr9cza2j.js} +2 -2
- package/dist/chunk-where-8mq8azgw.js +1 -0
- package/dist/{chunk-workspace-ne2nkf4h.js → chunk-workspace-hdamnf4r.js} +2 -2
- package/dist/chunk-zh-tw-ama40y87.js +1 -0
- package/dist/index.html +1 -1
- package/dist/sw.js +1 -1
- package/package.json +3 -3
- package/src/api-types.ts +17 -0
- package/src/app/app.ts +3 -0
- package/src/app/command-routes.ts +45 -0
- package/src/app/routes.ts +13 -0
- package/src/i18n/zh-tw.ts +8 -1
- package/src/web-plugin.ts +2 -0
- package/dist/chunk-account-dq0nhfvj.js +0 -1
- package/dist/chunk-agent-yqe6reej.js +0 -1
- package/dist/chunk-arranged-rooms-sx6xg9df.js +0 -1
- package/dist/chunk-bulk-actions-6pehrsgb.js +0 -1
- package/dist/chunk-confirm-ghxga720.js +0 -1
- package/dist/chunk-council-sheet-7m884s44.js +0 -2
- package/dist/chunk-council-view-rkzcxeg8.js +0 -1
- package/dist/chunk-folds-rb1b069h.js +0 -1
- package/dist/chunk-gate-3rxxyfev.js +0 -1
- package/dist/chunk-host-icons-cyj62pwp.js +0 -1
- package/dist/chunk-host-picture-9wnhqckv.js +0 -1
- package/dist/chunk-host-state-b858k3p8.js +0 -1
- package/dist/chunk-host-ui-j6wvj0pe.js +0 -1
- package/dist/chunk-index-2s48qyrs.js +0 -2
- package/dist/chunk-index-33cqx9v2.js +0 -2
- package/dist/chunk-index-36m3knsk.js +0 -2
- package/dist/chunk-index-91wnf1k9.js +0 -1
- package/dist/chunk-index-9ehqccfe.js +0 -2
- package/dist/chunk-index-ar1x9fhw.js +0 -2
- package/dist/chunk-index-axw4wkqq.js +0 -2
- package/dist/chunk-index-b5patef1.js +0 -2
- package/dist/chunk-index-dagc92hw.js +0 -2
- package/dist/chunk-index-ddssgba9.js +0 -2
- package/dist/chunk-index-dpgn7kzp.js +0 -2
- package/dist/chunk-index-eez0kbk4.js +0 -2
- package/dist/chunk-index-ekp5mmvp.js +0 -2
- package/dist/chunk-index-fdg2qd3f.js +0 -2
- package/dist/chunk-index-g0sdxjxr.js +0 -2
- package/dist/chunk-index-hsc9yz2x.js +0 -2
- package/dist/chunk-index-kvztbfqj.js +0 -2
- package/dist/chunk-index-nncy9wxw.js +0 -2
- package/dist/chunk-index-p2e7rwac.js +0 -2
- package/dist/chunk-index-p98tt12y.js +0 -2
- package/dist/chunk-index-qdtmetsy.js +0 -120
- package/dist/chunk-index-s356ybxk.js +0 -50
- package/dist/chunk-index-vxqzavgz.js +0 -2
- package/dist/chunk-index-x5xq9g9a.js +0 -3
- package/dist/chunk-index-xx0kecz9.js +0 -2
- package/dist/chunk-lang-css-rwkzd784.js +0 -1
- package/dist/chunk-lang-html-zhngbs9v.js +0 -1
- package/dist/chunk-lang-javascript-bk2s6a56.js +0 -1
- package/dist/chunk-lang-typescript-r5npc6zf.js +0 -1
- package/dist/chunk-layout-actions-rw5myg2t.js +0 -1
- package/dist/chunk-menu-items-q0hy5kzd.js +0 -1
- package/dist/chunk-mode-toggle-yk2t0tcy.js +0 -1
- package/dist/chunk-notes-0xcmm938.js +0 -1
- package/dist/chunk-notice-bell-f9nhxg71.js +0 -1
- package/dist/chunk-placement-items-wcwy91mp.js +0 -1
- package/dist/chunk-prompt-history-kn42sf8y.js +0 -1
- package/dist/chunk-prompts-824fwgvh.js +0 -1
- package/dist/chunk-room-confirms-hvs9tra4.js +0 -1
- package/dist/chunk-room-menu-pkd0487m.js +0 -1
- package/dist/chunk-rooms-menu-button-w5hfhsfv.js +0 -1
- package/dist/chunk-section-fold-g0tx68cj.js +0 -1
- package/dist/chunk-sheet-hosts-tsppnmvv.js +0 -29
- package/dist/chunk-shortcut-help-wnm0cm8n.js +0 -26
- package/dist/chunk-skills-sap3rysr.js +0 -1
- package/dist/chunk-table-jtn49c2m.js +0 -1
- package/dist/chunk-thread-actions-31scmndt.js +0 -1
- package/dist/chunk-transcript-p5q2m795.js +0 -1
- package/dist/chunk-waiting-s7nm3q0p.js +0 -1
- package/dist/chunk-where-j99f8pb8.js +0 -1
- package/dist/chunk-zh-tw-vm5d0w6j.js +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,22 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
|
|
5
5
|
|
|
6
6
|
## [Unreleased]
|
|
7
7
|
|
|
8
|
+
## [0.30.0] - 2026-11-01
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- `/clear` in the message box of an agent's or group's room starts the room over, as the room menu's Start over does: nothing is posted, the same question comes up first ("Start over <name>?"), and the screen clears to the one start-over line, with the old messages open read-only from it as the archived conversation. `/new` does the same. The text must be the command whole (spaces around it and the case do not matter); `/clear now` or a `/clear` with files waiting is a message like any other. A host's room keeps its own conversation, so `/clear` there answers with a notice instead of being sent.
|
|
13
|
+
- Typing `/` at the start of the message box opens a small menu of commands above it, with a line on each (`/clear` is the first): ↑ and ↓ move, Enter runs the choice, Tab writes its name into the box, Esc closes it until the text changes, and a tap picks on a phone without closing its keyboard. Nothing acts while an input method composes. The menu and its styles are a lazy chunk. `Composer` takes a `commands` list (`SlashCommand`: name, aliases, one-line description, `run`), so a command to come is one more entry in `lib/room-commands.ts`.
|
|
14
|
+
- In a knight's room the same menu also lists the skills the knight carries (`/skill:<name>`, built-in ones included) and the Pi extension commands that plugins declared safe for chat (`chatCommands`, see the core changelog); none of the second kind is listed until a plugin declares it. Picking one writes its name and a space into the box for the arguments, and the message is sent as it is: Pi expands a skill and runs an extension command, and only the owner's message can start either. `GET api/rooms/<room>/commands` (`RoomCommandsView`) lists them; it is an owners-only room route (404 to anyone else), and a group, a thread or a read-only room has none. `AppApiOptions.chatCommands` and `skills.carried` feed it.
|
|
15
|
+
- The `?` shortcut list names `/clear`.
|
|
16
|
+
- Typing `@` at the start of a word in a council's message box (chat mode and the animated scene) opens a list of the council's members over the box, filtered as you type. The arrows move, Enter or Tab pick, Escape closes it, and a tap picks on a phone; it never acts while an input method is composing. A picked member goes in as `@<display name> `. A leading `@AI` still only toggles the agent and never opens the list. The list is a lazy chunk.
|
|
17
|
+
|
|
18
|
+
### Changed
|
|
19
|
+
|
|
20
|
+
- The round table and a group's room share one header (`CouncilHead`): the council's picture, its name with "Group" under it, the reset button where the scene has one, the scene/chat switch, the waiting cards and the room menu. The separate "Council: <name>" chip is gone, and the name no longer shows twice. On the round table the name is the council picker (`<name> ▾` opens the council sheet); in the room it still edits the group, and the room menu has "Edit this council", which opens the same sheet. The header is one row on a 390 px phone.
|
|
21
|
+
- The scene/chat switch shows an icon beside its words on a desktop and the icon alone on a narrow or touch screen; the words stay for a screen reader and as the tooltip.
|
|
22
|
+
- A tap or click on a knight in the animated scene now also puts `@<display name> ` into the room's message box, at the caret or after the text, and focuses the box, as a tap on a podium in the chat-mode strip does. The camera still turns to that knight and the page does not navigate. The camera still follows only a member's own lines.
|
|
23
|
+
|
|
8
24
|
## [0.29.2] - 2026-10-31
|
|
9
25
|
|
|
10
26
|
### Added
|
package/README.md
CHANGED
|
@@ -30,7 +30,7 @@ Then only a person whose principal holds the owner role gets in.
|
|
|
30
30
|
|
|
31
31
|
## Requirements
|
|
32
32
|
|
|
33
|
-
- Bun 1.4.4 or later, and pi-roundtable `>=0.
|
|
33
|
+
- Bun 1.4.4 or later, and pi-roundtable `>=0.30.0 <0.31.0` as a peer dependency.
|
|
34
34
|
- The host must run on the machine that holds its data directory: the console reads `<dataDir>/sessions` from disk, and the app keeps its files and keys under `<dataDir>/web/`.
|
|
35
35
|
- An agent team: `agents` in the configuration, with or without `discord`. Without Discord the host also needs a surface that hosts rooms, and this plugin is one; the start fails otherwise, naming the fix.
|
|
36
36
|
- A way to authenticate the owners (see [Authentication](#authentication)): a password, Cloudflare Access or a verifier of your own in front of the listener, or `none` on a listener only the owner reaches.
|
|
@@ -251,14 +251,14 @@ The table is a **council**: one agent group (the same group as the group chat, w
|
|
|
251
251
|
This section describes the owners' table. A member or an admin is served the table only when the host names it for their tier, and theirs seats host rooms instead of agents: see [What each tier is served](#what-each-tier-is-served).
|
|
252
252
|
|
|
253
253
|
- **Cameras.** The overview stands behind your podium, raised. A drag or swipe turns it round the ring and snaps to a podium; the wheel or a pinch moves in on the podium across the ring and back out. A close-up of a speaker stands low inside the ring, tilted a little, with thin speed lines flashing for 400 ms on a new speaker. A turn follows the ring the shorter way and takes 450 to 650 ms. A swipe never starts within 32 px of the screen's edge. Under `prefers-reduced-motion` the camera cuts, with no speed lines, bob or flicker.
|
|
254
|
-
- **Talking in the scene.** The dialogue box at the bottom is the council's group room: a nameplate tab in the speaker's color with their picture, the line being said (Markdown, typed out while it streams, a tap shows it whole), the cards waiting for an answer, and the room's message box, with its unsent text kept per room. A message sent there starts a round under the group's rules. A tap on a podium (or on its name, a button over the plate) turns the camera to that member until the next line comes; **Reset view** brings it back to the whole ring; holding a seat (a long press, a right click or the Menu key) opens its menu with **Private chat** (the knight's own room) and **Remove from the council**. **Log** opens the room's whole message list as a sheet over the scene. **Collapse dialogue** folds the box to one bar (the speaker's face and name, the start of the newest line, and *Waiting for your answer* while a card waits) and **Expand dialogue**, or a tap anywhere on the bar, opens it again; the choice is kept per device (`roundtable-console:dialogue-folded`). On a phone (a narrow or touch screen) a message sent from the table closes the keyboard, so the answer has the screen; elsewhere the box keeps the focus for the next one. The header's **Animation mode** / **Chat mode** switch shows the council as the scene with its dialogue box, or as its group room's message list with the cards and the same message box (the unsent text carries over); the choice is kept per council (`roundtable-console:council-mode:<room>`) and is the same in the group's room. The header also has the waiting cards and the room menu, as a room's does. The address is `#/table/<group>` (the group's name or the key of its room): without one the table shows the council this device chose last (kept in the browser's storage), or the first group, and an address that names no group goes back to `#/table`.
|
|
254
|
+
- **Talking in the scene.** The dialogue box at the bottom is the council's group room: a nameplate tab in the speaker's color with their picture, the line being said (Markdown, typed out while it streams, a tap shows it whole), the cards waiting for an answer, and the room's message box, with its unsent text kept per room. A message sent there starts a round under the group's rules. A tap on a podium (or on its name, a button over the plate) turns the camera to that member until the next line comes, and puts `@<display name> ` into the room's message box (at the caret, or after the text when the box is not the one being typed in) and focuses it, as a tap on a strip podium does; **Reset view** brings it back to the whole ring; holding a seat (a long press, a right click or the Menu key) opens its menu with **Private chat** (the knight's own room) and **Remove from the council**. **Log** opens the room's whole message list as a sheet over the scene. **Collapse dialogue** folds the box to one bar (the speaker's face and name, the start of the newest line, and *Waiting for your answer* while a card waits) and **Expand dialogue**, or a tap anywhere on the bar, opens it again; the choice is kept per device (`roundtable-console:dialogue-folded`). On a phone (a narrow or touch screen) a message sent from the table closes the keyboard, so the answer has the screen; elsewhere the box keeps the focus for the next one. The header's **Animation mode** / **Chat mode** switch shows the council as the scene with its dialogue box, or as its group room's message list with the cards and the same message box (the unsent text carries over); the choice is kept per council (`roundtable-console:council-mode:<room>`) and is the same in the group's room. The header also has the waiting cards and the room menu, as a room's does. The address is `#/table/<group>` (the group's name or the key of its room): without one the table shows the council this device chose last (kept in the browser's storage), or the first group, and an address that names no group goes back to `#/table`.
|
|
255
255
|
- **Names.** A seat's name is a button laid over its podium's nameplate, at least 12 px on the screen at any distance, in a font stack that carries Chinese (`system-ui`, PingFang TC, Noto Sans TC, Microsoft JhengHei); the podium's own plate is lettered the same way. The seat's full name and state are its accessible name. Where the names stand over each other (many seats on a phone) the agents are also listed as buttons under the scene.
|
|
256
256
|
- **Phones.** Held upright, the scene fills the top 55 % and the dialogue box the rest, and a folded box is only its bar, giving the scene the rest; on its side the scene is whole and the box lies over its bottom third.
|
|
257
257
|
- **Fallback.** Without WebGL (or after a lost context) the same ring is drawn as SVG in the same palette, with the same standees, plates and dialogue box, never a blank pane. `?nogl` in the page address (`/console/?nogl`, or `#/table?nogl`) draws it on a browser that has WebGL, to try that path; `nogl=0` and `nogl=false` leave the choice to the browser.
|
|
258
258
|
- **Performance.** The WebGL scene is a chunk of its own, fetched when the view first opens and cached by the service worker, never precached. It stops drawing while the page is hidden or the table is off screen, draws a few frames a second while nothing moves (so a torch flickers without keeping the GPU busy), and caps the pixel ratio at 2 (1.5 on phones).
|
|
259
259
|
- **The council.** The header's chip (**Council: <name> ▾**) opens a sheet, a bottom sheet on a phone and a dialog elsewhere. It lists the saved councils (the groups, with their members' faces; pressing one puts it on the table, with the same puff, glide and rise as a seat leaving or joining), and a tick list of every knight with a counter (**3 of 8 picked**): the ninth tick is refused and the sheet says *At most 8 knights*. Ticks keep the order they were made in, which is the group's tie order, and the host is chosen among the ticked. **Done** saves the ticks into the council on the table in place (`PATCH api/groups/<name>`); **Save as a new council** asks for a name and makes another group (`POST api/groups`), which opens its Discord channel as every group does. With no group yet the table says *No council yet* and the sheet starts from the knights that were not muted, the coordinator first, at most eight, to be named and saved. Who sits is no longer mute's say: mute only stops a room's push, stays in the knight's sheet and the room menu, and a muted knight sits when the council has it. Owners who used mute to take knights off the table see their first group (or the empty state) after this change.
|
|
260
260
|
- **Leaving and joining.** An agent who leaves goes in a manga-style puff: the standee squashes a little, flat outlined clouds pop up round it and hide it, then drift up and fade with a few sparkles (about 0.7 s). The other seats then glide to their new places with the camera. An agent who sits down is called up out of a small rune circle in the hall's teal that glows on the floor at its new place; the podium rises out of it with a slight bounce, under a column of light (about 0.85 s), once the others have opened the gap. The pictures are drawn on small canvases in the hall's style and given back when the show ends. Under `prefers-reduced-motion` the picture only dips and comes back (0.16 s each way), with no smoke or rise; the 2D fallback fades the seat in over a ring and out inside a puff with CSS.
|
|
261
|
-
- **Group rooms.** The same scene is a group room's: a group room shows the same council view as the table page: its header keeps the room's way back, picture and name, and adds the council chip (picking another council in its sheet opens that group's room), the **Animation mode** / **Chat mode** switch, **Reset view** in the scene, the waiting cards and the room menu. The mode is kept per council, so one chosen in the room shows on the table page and back. A council read for the first time takes the room's old "Table" toggle (`rt-table-mode:<room>`, removed once moved), else the table page's old device mode (`roundtable-console:table-mode`), else the scene. In the scene the whole conversation runs in the dialogue box, the camera turns to whoever replies, and it rests on the whole ring while you speak; a member that starts thinking shows its badge wherever the camera is, and a speaker change never takes the focus from your message box. Under the Camelot look a compact strip of the members stands under the header in chat mode, with the speaker lit. On a phone a message sent in either mode closes the keyboard.
|
|
261
|
+
- **Group rooms.** The same scene is a group room's: a group room shows the same council view as the table page: its header keeps the room's way back, picture and name, and adds the council chip (picking another council in its sheet opens that group's room), the **Animation mode** / **Chat mode** switch, **Reset view** in the scene, the waiting cards and the room menu. The mode is kept per council, so one chosen in the room shows on the table page and back. A council read for the first time takes the room's old "Table" toggle (`rt-table-mode:<room>`, removed once moved), else the table page's old device mode (`roundtable-console:table-mode`), else the scene. In the scene the whole conversation runs in the dialogue box, the camera turns to whoever replies, and it rests on the whole ring while you speak; a member that starts thinking shows its badge wherever the camera is, and a speaker change never takes the focus from your message box. Under the Camelot look a compact strip of the members stands under the header in chat mode, with the speaker lit. On a phone a message sent in either mode closes the keyboard. In either mode, typing `@` at the start of a word in the message box opens a list of the council's members over the box, filtered by what is typed after it (display names and names, those that start with it first). The arrows move, Enter or Tab pick, Escape closes it and a tap picks; nothing acts while an input method is composing, and a picked member goes in as `@<display name> `. A leading `@AI` (the notes switch's shorthand) never opens it. The list is a lazy chunk.
|
|
262
262
|
- **Turn-taking.** A group round is the members' answers to one message, one after another. The server tells the page where it stands in a `round` frame (`{ type: "round", room, round }`, and `RoomView.round` for a page that opens mid-round): `id` (the group message that opened it), `state`, `current`, `next` (the queue, a handoff appended), `spoken`, `replies` and `limit` (8), `ended` (`done`, `limit` or `stopped`) and `queued` (your messages waiting for the next round). An **order strip** on top of the dialogue box shows the faces in that order: those who spoke dimmed with a check, the one speaking larger, those who are next numbered, and a chip, *Reply 3 of 8*, that reads *Limit reached*, *Round stopped* or *n of 8 replies* once it ended; the strip of the last round stays until the next starts. While it runs the seats wear the same signs before their names (a check, or ① to ⑧; a round that ended leaves them bare), the member whose turn runs thinks (its seat bobs with the thinking badge, no light) until its words show, and its seat is lit only while its words are on screen: streaming in, or typed out in the dialogue box until the last of them shows (on a group room's page, while they stream); the camera turns to it as soon as its turn starts, not when its line arrives; a camera you turned by hand stays until the next line or the next speaker. While a message of yours waits, the strip says so. The box's stop button reads **Stop the round**: it stops the member speaking and the ones waiting do not speak, on the web and in Discord alike.
|
|
263
263
|
|
|
264
264
|
### The files pane
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{p,T,b,e,S}from"./chunk-index-rvatmx8s.js";var a={profile:b(()=>(p("sdn7bs08"),import("./chunk-profile-sdn7bs08.js")).then((o)=>({default:o.ProfilePage}))),notices:b(()=>(p("jkv1derx"),import("./chunk-notices-jkv1derx.js")).then((o)=>({default:o.NoticesPage}))),onboarding:b(()=>(p("ka11bgd0"),import("./chunk-onboarding-ka11bgd0.js")).then((o)=>({default:o.OnboardingPage})))};function n({pane:o}){let t=a[o];return t?e(T,{fallback:e(S,{}),children:e(t,{})}):null}export{n as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{o,Se,a,r,g,e,n,s,_t,js}from"./chunk-index-rvatmx8s.js";import{A}from"./chunk-index-0dyf2gdm.js";var L=()=>typeof matchMedia==="function"&&matchMedia("(max-width: 719px)").matches,k={rtMenu:!0},x=()=>Boolean(window.history.state?.rtMenu),w=8,E=(t)=>t?.isConnected?t:null;function M(t){return t.items.map((i)=>n("button",{type:"button",role:i.checked===void 0?"menuitem":"menuitemcheckbox",...i.checked===void 0?{}:{"aria-checked":i.checked},className:"menu-item menu-link","data-tone":i.tone,onClick:()=>t.onChoose(i),children:[i.icon?e("span",{className:"menu-icon","data-tone":i.tone,children:e(s,{name:i.icon,size:18})}):null,e("span",{className:"menu-text",children:e("strong",{children:i.label})}),i.checked?e(s,{name:"check",size:18,className:"menu-check"}):null]},i.id))}function H({menu:t}){let i=a(void 0);if(t)i.current=t;let l=i.current,m=a(!1),h=a(void 0),p=t?.serial;return o(()=>{if(p===void 0)return;return window.history.pushState(k,"",window.location.href),m.current=!0,()=>{if(m.current)m.current=!1,window.history.back()}},[p]),o(()=>{let f=()=>{if(!m.current||x())return;m.current=!1,_t();let y=h.current;h.current=void 0,y?.()};return window.addEventListener("popstate",f),()=>window.removeEventListener("popstate",f)},[]),e(A,{open:t!==void 0,title:l?.title??"",onClose:_t,restoreFocus:()=>E(l?.source??null),children:l?e("div",{className:"menu action-items",role:"menu","aria-label":l.title,children:e(M,{items:l.items,onChoose:(f)=>{if(!m.current){_t(),f.run();return}h.current=f.run,window.history.back()}})}):null})}function T({menu:t}){let i=a(null),[l,m]=r(t.at),{source:h}=t,p=(u)=>{E(h)?.focus(),_t(),u?.()},f=a(p);f.current=p,Se(()=>{let u=i.current;if(!u)return;let d={left:u.style.left,top:u.style.top};u.style.left="0px",u.style.top="0px";let c={width:u.offsetWidth,height:u.offsetHeight};u.style.left=d.left,u.style.top=d.top,m({x:Math.max(w,Math.min(t.at.x,window.innerWidth-c.width-w)),y:Math.max(w,Math.min(t.at.y,window.innerHeight-c.height-w))}),u.querySelector('[role^="menuitem"]')?.focus()},[t.serial]),o(()=>{let u=(c)=>{if(c.target instanceof Node&&i.current?.contains(c.target))return;_t()},d=()=>_t();return document.addEventListener("pointerdown",u,!0),document.addEventListener("wheel",u,{capture:!0,passive:!0}),document.addEventListener("touchmove",u,{capture:!0,passive:!0}),window.addEventListener("resize",d),()=>{document.removeEventListener("pointerdown",u,!0),document.removeEventListener("wheel",u,!0),document.removeEventListener("touchmove",u,!0),window.removeEventListener("resize",d)}},[]);let y=(u)=>{let d=[...i.current?.querySelectorAll('[role^="menuitem"]')??[]],c=d.indexOf(document.activeElement),v=(b)=>{u.preventDefault(),d[(b+d.length)%d.length]?.focus()};switch(u.key){case"Escape":u.preventDefault(),u.stopPropagation(),f.current();return;case"ArrowDown":return v(c+1);case"ArrowUp":return v(c<0?-1:c-1);case"Tab":return v(u.shiftKey?c<0?-1:c-1:c+1);case"Home":return v(0);case"End":return v(-1)}};return e("div",{ref:i,className:"action-popover",role:"menu","aria-label":t.title,tabIndex:-1,style:{left:`${l.x}px`,top:`${l.y}px`},onKeyDown:y,children:e(M,{items:t.items,onChoose:(u)=>p(u.run)})})}function I(){let t=js(),i=a(void 0);if(t&&i.current?.serial!==t.serial)i.current={serial:t.serial,sheet:L()};let l=Boolean(t&&i.current?.sheet);return n(g,{children:[e(H,{menu:l?t:void 0}),t&&!l?e(T,{menu:t},t.serial):null]})}export{I as ActionMenuHost};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{o,e,X,u,S,Ke}from"./chunk-index-rvatmx8s.js";function c({name:r}){let m=u((i)=>i.listed),t=u((i)=>Object.values(i.rooms).find((n)=>n.view?.kind==="agent"&&n.view.name===r)?.view?.key,r);return o(()=>{if(t)X("room",t,{replace:!0}),Ke(r);else if(m)X("rooms",void 0,{replace:!0})},[t,m,r]),e("div",{className:"page",children:e(S,{})})}export{c as AgentPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{p,T,b,ee,C,a,t,g,e,n,s,Xe,u,k,_,Oe,rn,Mn,te,Ae,Cr,qi,bo,Dt,Bi,vo}from"./chunk-index-rvatmx8s.js";import"./chunk-index-e3encn5p.js";import"./chunk-index-tfgd7vr5.js";import{bn,fr}from"./chunk-index-vwd5drzh.js";import{Ue}from"./chunk-index-maf6wr1b.js";import{Ni}from"./chunk-index-vw592m3p.js";import{bi}from"./chunk-index-14cxgacv.js";import{$i}from"./chunk-index-n92zea3s.js";import{Jt}from"./chunk-index-qb41kkt3.js";import"./chunk-index-4p45h04z.js";import"./chunk-index-wqbcade7.js";import{ut}from"./chunk-index-g3f1sdw0.js";bn();var O=b(()=>(p("kghgyc0x"),import("./chunk-folder-list-kghgyc0x.js")).then((o)=>({default:o.FolderList}))),Z=ee(function(m){let{view:i}=m,h=Jt(()=>rn(i.key),i.home?void 0:$i(i.key));return e(bo,{...m,press:h,item:{...i.home?{}:{"data-drop-item":"","data-key":i.key},...m.arranging?{"data-arranging":""}:{}},after:m.arranging?e("button",{type:"button",className:"icon-button row-more","aria-haspopup":"menu","aria-label":t("Room menu"),onClick:(r)=>{let c=r.currentTarget;rn(i.key).then((l)=>{if(!l)return;let N=c.getBoundingClientRect();Oe({...l,at:{x:N.left,y:N.bottom},via:"key",source:c})},()=>{return})},children:e(s,{name:"more",size:18})}):null})});function L(o){let{now:m}=te(),{timeZone:i}=_(),h=Dt(o.rooms);return e("ul",{className:"room-list",children:h.map(({key:r,...c})=>{let l=o.threads[r];return e(Z,{...c,active:r===o.active,now:m,timeZone:i,arranging:o.arranging,...l?{threads:e(Bi,{open:l.open,closed:l.closed,active:o.active,parent:r})}:{}},r)})})}function y(o){let i=Dt(o.rooms).length===0;if(i&&o.zone?.kind!=="pinned")return null;let h=o.zone?{"data-drop-zone":o.zone.kind,"data-zone-id":o.zone.id}:{},r=(c)=>e(L,{rooms:c,threads:o.threads,active:o.active,arranging:o.arranging});if(o.fold&&!i)return e(fr,{id:o.fold,title:o.title,rooms:o.rooms,active:o.active,attrs:h,children:r});return n("section",{className:"stack",...i?{"data-empty":""}:{},...h,children:[e("h2",{className:"section-title",children:o.title}),i?null:r(o.rooms)]})}function le(o){let m=Boolean(_().kinds?.length),i=u((d)=>JSON.stringify({listed:d.listed,...ut(d,(M)=>Xe(d,M))})),h=Ni(),r=a(i);if(!h)r.current=i;let c=r.current,{listed:l,...N}=C(()=>JSON.parse(c),[c]),{home:z,pinned:S,folders:R,restAgents:P,restGroups:D,rest:A,threads:F,orphans:f}=N,w=Cr(),K=z.length+S.length+A.length===0&&R.every((d)=>d.rooms.length===0)&&f.open.length+f.closed.length===0,v={threads:F,active:o.active,arranging:w};return n("div",{className:"page","data-column":o.active?"":void 0,"data-drop-root":"",children:[n("header",{className:"page-head",children:[e("h1",{children:t("Rooms")}),n("div",{className:"actions",children:[n("button",{type:"button",className:"header-button search-button",onClick:o.onSearch,children:[e(s,{name:"search",size:16}),e("span",{children:t("Find a room")}),e("kbd",{children:"⌘K"})]}),l?e("button",{type:"button",className:"header-button icon-button","aria-haspopup":"menu","aria-label":t("Folders and order"),onClick:(d)=>bi(d.currentTarget),children:e(s,{name:"more",size:18})}):null,e("button",{type:"button",className:"header-button icon-button","aria-label":t("Add"),"aria-haspopup":"menu",onClick:(d)=>Mn(d.currentTarget),children:e(s,{name:"plus"})})]})]}),w?n("div",{className:"arrange-bar",children:[n("button",{type:"button",className:"secondary",onClick:()=>Ue({kind:"new"}),children:[e(s,{name:"plus",size:16}),e("span",{children:t("Add a folder")})]}),e("button",{type:"button",onClick:()=>qi(!1),children:t("Done")})]}):null,l&&K&&!m?e(k,{children:t("No rooms yet. Rooms appear when the team has a knight.")}):null,!l?n("div",{className:"stack","aria-busy":"true",children:[e("div",{className:"skeleton"}),e("div",{className:"skeleton"}),e("div",{className:"skeleton"})]}):null,e(y,{title:t("Home"),rooms:z,...v}),e(y,{title:t("Pinned"),rooms:S,zone:{kind:"pinned",id:"pinned"},fold:Ae("pinned"),...v}),R.length>0?e("div",{className:"stack folder-list","data-folder-list":"",children:e(T,{fallback:e("div",{className:"skeleton","aria-busy":"true"}),children:e(O,{folders:R,active:o.active,listed:l,rooms:(d)=>e(L,{rooms:d,threads:F,active:o.active,arranging:w})})})}):null,R.length>0?e(y,{title:t("Ungrouped"),rooms:A,zone:{kind:"rest",id:"rest"},fold:Ae("rest"),...v}):n(g,{children:[e(y,{title:t("Knights"),rooms:P,zone:{kind:"rest",id:"rest-agents"},fold:Ae("agents"),...v}),e(y,{title:t("Groups"),rooms:D,zone:{kind:"rest",id:"rest-groups"},fold:Ae("groups"),...v})]}),f.open.length+f.closed.length>0?n("section",{className:"stack",children:[e("h2",{className:"section-title",children:t("Dispatch threads")}),e(Bi,{open:f.open,closed:f.closed,active:o.active})]}):null,e(vo,{active:o.active})]})}export{le as ArrangedRoomsPage};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{Se,a,r,t,F,e,n,s,_e,en,Zs,Pe,Lt,na}from"./chunk-index-rvatmx8s.js";import{B}from"./chunk-index-fw6kawhw.js";var u=`
|
|
2
2
|
.attachments {
|
|
3
3
|
margin-top: var(--space-3);
|
|
4
4
|
padding: var(--space-2);
|
|
@@ -99,4 +99,4 @@ import{Pe,a,r,t,B,e,n,o,we,Ht,gs,Me,Nt,Ps}from"./chunk-index-s356ybxk.js";import
|
|
|
99
99
|
color: inherit;
|
|
100
100
|
text-decoration: underline;
|
|
101
101
|
}
|
|
102
|
-
`;function h({file:
|
|
102
|
+
`;function h({file:o}){let i=Lt(()=>na(o));return o.type.startsWith("image/")?e("li",{children:e("a",{...i,href:en(o),target:"_blank",rel:"noreferrer noopener",children:e("img",{src:en(o),alt:o.name,loading:"lazy",decoding:"async",className:"file-image"})})}):e("li",{children:n("a",{...i,className:"file-chip",href:en(o),download:o.name,title:o.name,children:[e(s,{name:"file",size:16}),e("span",{className:"file-name",children:o.name}),e("span",{className:"file-size",children:Pe(o.size)})]})})}function f(o){B("attachments",u);let{files:i,message:m}=o;return n("section",{className:"attachments","aria-label":t("Attachments ({count})",{count:i.length}),children:[n("div",{className:"attachments-head",children:[e(s,{name:"attach",size:16}),e("span",{children:t("Attachments ({count})",{count:i.length})}),m&&i.length>=2?n("a",{className:"link-button",href:Zs(m),download:!0,children:[e(s,{name:"download",size:16}),t("Download all")]}):null]}),e("ul",{className:"files",children:i.map((c)=>e(h,{file:c},c.id))})]})}var g=0.9;function A({count:o}){B("attachments",u);let i=a(null),[m,c]=r(!1);return Se(()=>{let l=i.current?.closest(".bubble");if(!l)return;let d=()=>c(l.getBoundingClientRect().height>window.innerHeight*g);d(),window.addEventListener("resize",d);let p=typeof ResizeObserver==="function"?new ResizeObserver(d):void 0;return p?.observe(l),()=>{window.removeEventListener("resize",d),p?.disconnect()}},[]),n("button",{ref:i,type:"button",className:"link-button attachments-jump",hidden:!m,onClick:(l)=>{l.stopPropagation(),i.current?.closest(".bubble")?.querySelector(".attachments")?.scrollIntoView({behavior:_e()?"auto":"smooth",block:"start"})},children:[e(s,{name:"attach",size:14}),F(o,"{count} attachment","{count} attachments")]})}export{A as AttachmentsJump,f as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t,F,O,l,f}from"./chunk-index-rvatmx8s.js";import{an}from"./chunk-index-tfgd7vr5.js";import"./chunk-index-e3encn5p.js";import{Ln,To}from"./chunk-index-c8vsw9h8.js";import{Qo}from"./chunk-index-4p45h04z.js";import{re}from"./chunk-index-xkb336kq.js";import"./chunk-index-wqbcade7.js";var s=500,c=(n)=>{let r=[];for(let e=0;e<n.length;e+=s)r.push(n.slice(e,e+s));return r},i=()=>O.dispatch({type:"changed"});async function w(n){let r=Qo(n),e=Object.keys(r);if(e.length===0)return;let a=[];try{for(let o of c(e))a.push(...(await Ln.readAll(o)).moved)}catch(o){f(l(o),"danger"),i();return}an(Object.fromEntries(e.map((o)=>[o,0]))),f(F(e.length,"Marked {count} room as read","Marked {count} rooms as read"),"info",a.length?{label:t("Undo"),run:()=>void m(a,r)}:void 0)}async function m(n,r){try{for(let e of c(n)){let{restored:a}=await Ln.unreadAll(e);an(Object.fromEntries(a.map((o)=>[o,r[o]??0])))}}catch(e){f(l(e),"danger")}i()}var P=(n)=>To(n);async function d(n){try{await Ln.restoreHelpers(n)}catch(r){f(l(r),"danger")}i()}async function R(n){let r;try{r=(await Ln.archiveFinishedHelpers(n)).archived.flatMap((a)=>a.names)}catch(e){f(l(e),"danger"),i();return}if(i(),r.length===0)return;f(F(r.length,"Archived {count} temp knight","Archived {count} temp knights"),"info",{label:t("Undo"),run:()=>void d(r)})}async function T(n,r){try{await re.archiveAgent(n)}catch(e){f(l(e),"danger"),i();return}i(),f(t("Archived {name}",{name:r}),"info",{label:t("Undo"),run:()=>void d([n])})}export{T as archiveHelper,P as clearAllFinished,R as clearFinishedHelpers,w as markAllRead,d as putBackHelpers};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{Je,
|
|
1
|
+
import{Je,sn,Y,Fi,Nn}from"./chunk-index-xvdna54d.js";import{ee,ao,o,R,C,a,r,t,c,g,e,n,Xi,fe,y,l,f,Re,Rn,he,et}from"./chunk-index-rvatmx8s.js";import{D}from"./chunk-index-gae833v6.js";import{A}from"./chunk-index-0dyf2gdm.js";import{B}from"./chunk-index-fw6kawhw.js";var ue={"hat.none":"No hat","hat.goggcap":"Leather cap","hat.tallcap":"Burgundian felt cap","hat.softcap":"Soft cap","hat.hardhat":"Iron skullcap","hat.fcap":"Hunter's cap","hat.winghelm":"Winged helm","hat.helm":"Helm","hat.mortar":"Biretta","hat.beret":"Chaperon","hat.goggles":"Pointed cap","hat.tricorn":"Pilgrim hat","hat.sailor":"Straw hat","hat.kettle":"Kettle hat","hat.cavalier":"Feathered hat","hat.toque":"Linen cook's cap","hair.none":"No hair","beard.none":"No beard","accessory.none":"No accessory","prop.beads":"Prayer beads","prop.marotte":"Marotte","prop.map":"Chart","prop.flask":"Alchemist's phial","prop.telescope":"Astrolabe","prop.wrench":"Dividers","outfit.surplice":"Surplice","outfit.overalls":"Work jerkin","outfit.armor":"Mail hauberk","outfit.apron":"Smith's apron","outfit.chef":"Cook's tunic","outfit.coat":"Doublet","outfit.vest":"Pourpoint","outfit.sailor":"Mariner's tunic","hair.bob":"Bob","hair.bun":"Bun","hair.ponytail":"Ponytail"},X=(i)=>i.charAt(0).toUpperCase()+i.slice(1);function x(i,d){let h=`character.${i}.${d}`,p=t(h);if(p!==h)return p;if(i==="class")return Y.classes[d]?.label??X(d);return ue[`${i}.${d}`]??X(d)}function Z(i){let d=`character.jobs.${i}`,h=t(d);return h!==d?h:Y.classes[i]?.jobs??""}var ae=`
|
|
2
2
|
.creator {
|
|
3
3
|
display: grid;
|
|
4
4
|
gap: var(--space-5);
|
|
@@ -222,4 +222,4 @@ dialog.sheet dialog.sheet .creator-field > h3 {
|
|
|
222
222
|
.creator-actions {
|
|
223
223
|
flex-wrap: wrap;
|
|
224
224
|
}
|
|
225
|
-
`;var
|
|
225
|
+
`;var M=[{field:"hat",title:c("Hat"),ids:Y.hats},{field:"outfit",title:c("Outfit"),ids:Y.outfits},{field:"prop",title:c("Prop"),ids:Y.props},{field:"hair",title:c("Hair"),ids:Y.hair},{field:"beard",title:c("Beard"),ids:["none",...Y.beards]},{field:"accessory",title:c("Accessory"),ids:["none",...Y.accessories]}],pe=new Set(["class","colors","palette","build","skin","hairColor",...M.map((i)=>i.field)]),oe=Object.keys(Y.palettes),te={idle:c("Idle"),thinking:c("Thinking"),working:c("Working"),waiting:c("Waiting for you"),done:c("Done"),error:c("Error"),sleepy:c("Sleepy")},ge={slim:c("Slim"),regular:c("Regular"),stout:c("Stout")};function _(i){return{class:i.class,outfit:i.outfit,hat:i.hat,prop:i.prop,hair:i.hair,beard:i.beard,accessory:i.accessory,build:i.build,skin:i.skin,hairColor:i.hairColor,colors:{...i.colors}}}var re=(i)=>JSON.stringify(_(i)),k=(i)=>i[Math.floor(Math.random()*i.length)];function be(){return{class:k(Je),outfit:k(Y.outfits),hat:k(Y.hats),prop:k(Y.props),hair:k(Y.hair),beard:k(["none",...Y.beards]),accessory:k(["none",...Y.accessories]),build:k(["slim","regular","stout"]),skin:k([0,1,2,3,4,5]),hairColor:k(Y.hairColors),palette:k(oe)}}var ne=ee(function(d){return n("button",{type:"button",className:"creator-tile","aria-pressed":d.pressed,title:d.hint?`${d.label} — ${d.hint}`:d.label,onClick:d.onPick,...d.data,children:[e(he,{spec:d.spec,size:d.size,live:!1}),e("span",{children:d.label})]})});function ve(i,d,h){let p=JSON.stringify({...i,[d]:0});return C(()=>h.map((m)=>({...i,[d]:m})),[p,d,h])}function ye(){let i=a(null),[d,h]=r();return o(()=>{let p=i.current;if(!p)return;let m=()=>{let S=p.scrollLeft>1,P=p.scrollLeft+p.clientWidth<p.scrollWidth-1;h(S&&P?"both":P?"end":S?"start":void 0)};m(),p.addEventListener("scroll",m,{passive:!0});let b=typeof ResizeObserver>"u"?void 0:new ResizeObserver(m);return b?.observe(p),()=>{p.removeEventListener("scroll",m),b?.disconnect()}},[]),[i,d]}function ke(i){let{part:d}=i,h=ve(i.shown,d.field,d.ids),[p,m]=ye();return e("div",{className:"creator-strip",ref:p,"data-more":m,children:d.ids.map((b,S)=>e(ne,{data:{[`data-${d.field}`]:b},spec:h[S],size:44,label:x(d.field,b),pressed:i.draft[d.field]===b,onPick:()=>i.onPick(b)},b))})}function K(i){return e("button",{type:"button",className:"creator-swatch","aria-pressed":i.pressed,"aria-label":i.label,title:i.label,style:{background:i.background},onClick:i.onPick,...i.data})}function N(i){return n("div",{className:"creator-field","data-field":i.field,children:[i.title?e("h3",{children:i.title}):null,i.children,i.error?e("p",{className:"field-error",role:"alert",children:i.error}):null]})}function _e(i){B("creator",ae);let[d,h]=r(i.character),p=ao(d),[m,b]=r({}),[S,P]=r(!1),[I,se]=r("idle"),[W,T]=r(),[z,j]=r(),U=Re("(max-width: 719px)"),G=a(null),F=R(),le=et(d),ce=Rn(),L=re(d)!==re(i.character);o(()=>h(i.character),[i.character]),o(()=>{if(!L||i.onPick)return;let s=(v)=>v.preventDefault(),u=(v)=>{if(v.button!==0||v.metaKey||v.ctrlKey||v.shiftKey||v.altKey)return;let E=v.target instanceof Element?v.target.closest("a"):null;if(!E||E.target||E.hasAttribute("download"))return;if(G.current?.contains(E))return;v.preventDefault(),v.stopPropagation(),T({kind:"link",anchor:E})},H=Xi((v)=>T({kind:"navigate",proceed:v}));return window.addEventListener("beforeunload",s),document.addEventListener("click",u,!0),()=>{H(),window.removeEventListener("beforeunload",s),document.removeEventListener("click",u,!0)}},[L,i.onPick]);let w=(s)=>{b({}),h((u)=>Fi(s,u))},de=async()=>{if(i.onPick){i.onPick(_(d),d);return}P(!0),b({});try{let s=await y.setCharacter(i.name,_(d));i.onSaved?.(s),f(t("Saved."))}catch(s){let u=s instanceof fe&&s.field?s.field.split(".")[0]:void 0,H=u&&pe.has(u)?u:"*";b({[H]:l(s)})}finally{P(!1)}},me=async()=>{let s=W;if(h(i.character),b({}),s?.kind==="link")setTimeout(()=>s.anchor.click(),0);else if(s?.kind==="navigate")s.proceed()},J=e(N,{field:"class",title:t("Class"),error:m.class,children:e("div",{className:"creator-grid",children:Je.map((s)=>e(Ce,{id:s,base:p,pressed:d.class===s,onPick:()=>w({class:s,colors:d.colors})},s))})}),V=n(N,{field:"colors",title:t("Colors"),error:m.colors??m.palette,children:[n("fieldset",{className:"creator-swatches",children:[e("legend",{className:"visually-hidden",children:t("Palette")}),oe.map((s)=>{let u=Y.palettes[s];return e(K,{data:{"data-palette":s},label:x("palette",s),pressed:d.palette===s,background:`linear-gradient(135deg, ${u.primary} 52%, ${u.trim} 52%)`,onPick:()=>w({palette:s})},s)})]}),e("div",{className:"creator-custom",children:["primary","secondary","trim"].map((s)=>n("label",{children:[e("span",{children:s==="primary"?t("Primary (the accent)"):s==="secondary"?t("Secondary"):t("Trim")}),e("input",{type:"color",value:d.colors[s],onChange:(u)=>w({colors:{[s]:u.target.value}})})]},s))})]}),q=M.map((s)=>e(N,{field:s.field,title:t(s.title),error:m[s.field],children:e(ke,{part:s,draft:d,shown:p,onPick:(u)=>w({[s.field]:u})})},s.field)),Q=n(g,{children:[e(N,{field:"build",title:t("Build"),error:m.build,children:n("fieldset",{className:"segmented",children:[e("legend",{className:"visually-hidden",children:t("Build")}),["slim","regular","stout"].map((s)=>n("label",{"data-checked":d.build===s,children:[e("input",{type:"radio",name:`${F}-build`,checked:d.build===s,onChange:()=>w({build:s})}),ie(s)]},s))]})}),e(N,{field:"skin",title:t("Skin tone"),error:m.skin,children:n("fieldset",{className:"creator-swatches",children:[e("legend",{className:"visually-hidden",children:t("Skin tone")}),(ce??Y.skins).map((s,u)=>e(K,{data:{"data-skin":String(u)},label:t("Skin tone {n}",{n:u+1}),pressed:d.skin===u,background:s,onPick:()=>w({skin:u})},u))]})}),e(N,{field:"hairColor",title:t("Hair color"),error:m.hairColor,children:n("fieldset",{className:"creator-swatches",children:[e("legend",{className:"visually-hidden",children:t("Hair color")}),Y.hairColors.map((s,u)=>e(K,{data:{"data-hair-color":s},label:t("Hair color {n}",{n:u+1}),pressed:d.hairColor===s,background:s,onPick:()=>w({hairColor:s})},s)),e("input",{type:"color","aria-label":t("Hair color"),value:d.hairColor,onChange:(s)=>w({hairColor:s.target.value})})]})})]}),O=[{id:"class",title:t("Class"),summary:x("class",d.class),error:m.class,node:J},{id:"colors",title:t("Colors"),summary:d.palette?x("palette",d.palette):d.colors.primary,error:m.colors??m.palette,node:V},...M.map((s,u)=>({id:s.field,title:t(s.title),summary:x(s.field,d[s.field]),error:m[s.field],node:q[u]})),{id:"body",title:t("Body"),summary:ie(d.build),error:m.build??m.skin??m.hairColor,node:Q}];return n("form",{ref:G,className:"creator",style:le,"aria-labelledby":F,onSubmit:(s)=>{if(s.preventDefault(),(L||i.onPick)&&!S)de()},children:[e("h2",{id:F,className:"visually-hidden",children:t("Character of {name}",{name:i.displayName})}),n("div",{className:"creator-preview",children:[e(he,{spec:d,name:i.name,state:I,size:176,label:t("{name}, {state}",{name:i.displayName,state:t(te[I])})}),e("button",{type:"button",className:"secondary","data-action":"cycle",onClick:()=>se((s)=>sn[(sn.indexOf(s)+1)%sn.length]??"idle"),children:t("Preview states")}),e("span",{className:"meta","aria-live":"polite",children:t(te[I])})]}),n("div",{className:"creator-body",children:[m["*"]?e("p",{className:"field-error",role:"alert","data-field":"*",children:m["*"]}):null,U?e("ul",{className:"creator-sections",children:O.map((s)=>e("li",{children:n("button",{type:"button",className:"creator-section secondary",onClick:()=>j(s.id),children:[e("strong",{children:s.title}),e("span",{className:"meta",children:s.summary}),s.error?e("span",{className:"field-error",role:"alert",children:s.error}):null]})},s.id))}):n(g,{children:[J,V,q,Q]}),n("div",{className:"actions creator-actions",children:[e("button",{type:"button",className:"secondary","data-action":"suggest",onClick:()=>{b({}),h(Nn({name:i.name,displayName:i.displayName,prompt:i.prompt}))},children:t("Suggest from role")}),e("button",{type:"button",className:"secondary","data-action":"randomize",onClick:()=>w(be()),children:t("Randomize")}),e("button",{type:"button",className:"secondary","data-action":"cancel",onClick:()=>{if(i.onCancel)i.onCancel();else if(L)T({kind:"cancel"})},children:t("Cancel")}),e("button",{type:"submit","data-action":"save",disabled:!L&&!i.onPick||S,children:S?t("Saving…"):i.onPick?t("Use this look"):t("Save")})]})]}),e(A,{open:U&&z!==void 0,title:O.find((s)=>s.id===z)?.title??"",onClose:()=>j(void 0),children:e("div",{className:"stack",children:O.find((s)=>s.id===z)?.node})}),e(D,{open:W!==void 0,title:t("Discard your changes?"),confirmLabel:t("Discard"),cancelLabel:t("Keep editing"),tone:"danger",onClose:()=>T(void 0),onConfirm:me,children:e("p",{children:t("The new look for {name} has not been saved.",{name:i.displayName})})})]})}var ie=(i)=>t(ge[i]);function Ce(i){let d=i.base.colors,h=C(()=>Fi({class:i.id,colors:d}),[i.id,d]);return e(ne,{data:{"data-class":i.id},spec:h,size:56,label:x("class",i.id),hint:Z(i.id),pressed:i.pressed,onPick:i.onPick})}export{_e as CharacterCreator};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{F,ye,Gi,Uo,Zi,mt,be,d,w,Ne,Fe,qt,Ge,Z,le,ce,q,vt,xt,Ze,ve,z,se,Ie,b,Tt,Vo,qo,Bo,Wi,ci,Fo,Go,Zo,Wo,Q,i,I,it,Gt,fi,Lr,Ln,Xn,jo,Ko,Ot}from"./chunk-index-qk7rp7fk.js";import{p}from"./chunk-index-s356ybxk.js";var nn=(e)=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=Ce(e.state,n.from);return r.line?rn(e):r.block?ln(e):!1};function ke(e,t){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let o=e(t,n);if(!o)return!1;return r(n.update(o)),!0}}var rn=ke(an,0);var on=ke(je,0);var ln=ke((e,t)=>je(e,t,cn(t)),0);function Ce(e,t){let n=e.languageDataAt("commentTokens",t,1);return n.length?n[0]:{}}var N=50;function sn(e,{open:t,close:n},r,o){let l=e.sliceDoc(r-N,r),s=e.sliceDoc(o,o+N),c=/\s*$/.exec(l)[0].length,a=/^\s*/.exec(s)[0].length,h=l.length-c;if(l.slice(h-t.length,h)==t&&s.slice(a,a+n.length)==n)return{open:{pos:r-c,margin:c&&1},close:{pos:o+a,margin:a&&1}};let u,f;if(o-r<=2*N)u=f=e.sliceDoc(r,o);else u=e.sliceDoc(r,r+N),f=e.sliceDoc(o-N,o);let m=/^\s*/.exec(u)[0].length,L=/\s*$/.exec(f)[0].length,v=f.length-L-n.length;if(u.slice(m,m+t.length)==t&&f.slice(v,v+n.length)==n)return{open:{pos:r+m+t.length,margin:/\s/.test(u.charAt(m+t.length))?1:0},close:{pos:o-L-n.length,margin:/\s/.test(f.charAt(v-1))?1:0}};return null}function cn(e){let t=[];for(let n of e.selection.ranges){let r=e.doc.lineAt(n.from),o=n.to<=r.to?r:e.doc.lineAt(n.to);if(o.from>r.from&&o.from==n.to)o=n.to==r.to+1?r:e.doc.lineAt(n.to-1);let l=t.length-1;if(l>=0&&t[l].to>r.from)t[l].to=o.to;else t.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:o.to})}return t}function je(e,t,n=t.selection.ranges){let r=n.map((l)=>Ce(t,l.from).block);if(!r.every((l)=>l))return null;let o=n.map((l,s)=>sn(t,r[s],l.from,l.to));if(e!=2&&!o.every((l)=>l))return{changes:t.changes(n.map((l,s)=>{if(o[s])return[];return[{from:l.from,insert:r[s].open+" "},{from:l.to,insert:" "+r[s].close}]}))};else if(e!=1&&o.some((l)=>l)){let l=[];for(let s=0,c;s<o.length;s++)if(c=o[s]){let a=r[s],{open:h,close:u}=c;l.push({from:h.pos-a.open.length,to:h.pos+h.margin},{from:u.pos-u.margin,to:u.pos+a.close.length})}return{changes:l}}return null}function an(e,t,n=t.selection.ranges){let r=[],o=-1;e:for(let{from:l,to:s}of n){let c=r.length,a=1e9,h;for(let u=l;u<=s;){let f=t.doc.lineAt(u);if(h==null){if(h=Ce(t,f.from).line,!h)continue e}if(f.from>o&&(l==s||s>f.from)){o=f.from;let m=/^\s*/.exec(f.text)[0].length,L=m==f.length,v=f.text.slice(m,m+h.length)==h?m:-1;if(m<f.text.length&&m<a)a=m;r.push({line:f,comment:v,token:h,indent:m,empty:L,single:!1})}u=f.to+1}if(a<1e9){for(let u=c;u<r.length;u++)if(r[u].indent<r[u].line.text.length)r[u].indent=a}if(r.length==c+1)r[c].single=!0}if(e!=2&&r.some((l)=>l.comment<0&&(!l.empty||l.single))){let l=[];for(let{line:c,token:a,indent:h,empty:u,single:f}of r)if(f||!u)l.push({from:c.from+h,insert:a+" "});let s=t.changes(l);return{changes:s,selection:t.selection.map(s,1)}}else if(e!=1&&r.some((l)=>l.comment>=0)){let l=[];for(let{line:s,comment:c,token:a}of r)if(c>=0){let h=s.from+c,u=h+a.length;if(s.text[u-s.from]==" ")u++;l.push({from:h,to:u})}return{changes:l}}return null}var ge=Ge.define(),un=Ge.define(),hn=w.define(),Xe=w.define({combine(e){return vt(e,{minDepth:100,newGroupDelay:500,joinToEvent:(t,n)=>n},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(t,n)=>(r,o)=>t(r,o)||n(r,o)})}}),Ye=Ne.define({create(){return A.empty},update(e,t){let n=t.state.facet(Xe),r=t.annotation(ge);if(r){let a=y.fromTransaction(t,r.selection),h=r.side,u=h==0?e.undone:e.done;if(a)u=K(u,u.length,n.minDepth,a);else u=nt(u,t.startState.selection);return new A(h==0?r.rest:u,h==0?u:r.rest)}let o=t.annotation(un);if(o=="full"||o=="before")e=e.isolate();if(t.annotation(le.addToHistory)===!1)return!t.changes.empty?e.addMapping(t.changes.desc):e;let l=y.fromTransaction(t),s=t.annotation(le.time),c=t.annotation(le.userEvent);if(l)e=e.addChanges(l,s,c,n,t);else if(t.selection)e=e.addSelection(t.startState.selection,s,c,n.newGroupDelay);if(o=="full"||o=="after")e=e.isolate();return e},toJSON(e){return{done:e.done.map((t)=>t.toJSON()),undone:e.undone.map((t)=>t.toJSON())}},fromJSON(e){return new A(e.done.map(y.fromJSON),e.undone.map(y.fromJSON))}});function et(e={}){return[Ye,Xe.of(e),b.domEventHandlers({beforeinput(t,n){let r=t.inputType=="historyUndo"?j:t.inputType=="historyRedo"?V:null;if(!r)return!1;return t.preventDefault(),r(n)}})]}function H(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let o=n.field(Ye,!1);if(!o)return!1;let l=o.pop(e,n,t);if(!l)return!1;return r(l),!0}}var j=H(0,!1),V=H(1,!1),fn=H(0,!0),dn=H(1,!0);class y{constructor(e,t,n,r,o){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=r,this.selectionsAfter=o}setSelAfter(e){return new y(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,n;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(t=this.mapped)===null||t===void 0?void 0:t.toJSON(),startSelection:(n=this.startSelection)===null||n===void 0?void 0:n.toJSON(),selectionsAfter:this.selectionsAfter.map((r)=>r.toJSON())}}static fromJSON(e){return new y(e.changes&&be.fromJSON(e.changes),[],e.mapped&&mt.fromJSON(e.mapped),e.startSelection&&d.fromJSON(e.startSelection),e.selectionsAfter.map(d.fromJSON))}static fromTransaction(e,t){let n=S;for(let r of e.startState.facet(hn)){let o=r(e);if(o.length)n=n.concat(o)}if(!n.length&&e.changes.empty)return null;return new y(e.changes.invert(e.startState.doc),n,void 0,t||e.startState.selection,S)}static selection(e){return new y(void 0,S,void 0,void 0,e)}}function K(e,t,n,r){let o=t+1>n+20?t-n-1:0,l=e.slice(o,t);return l.push(r),l}function mn(e,t){let n=[],r=!1;return e.iterChangedRanges((o,l)=>n.push(o,l)),t.iterChangedRanges((o,l,s,c)=>{for(let a=0;a<n.length;){let h=n[a++],u=n[a++];if(c>=h&&s<=u)r=!0}}),r}function pn(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((n,r)=>n.empty!=t.ranges[r].empty).length===0}function tt(e,t){return!e.length?t:!t.length?e:e.concat(t)}var S=[],gn=200;function nt(e,t){if(!e.length)return[y.selection([t])];else{let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-gn));if(r.length&&r[r.length-1].eq(t))return e;return r.push(t),K(e,e.length-1,1e9,n.setSelAfter(r))}}function yn(e){let t=e[e.length-1],n=e.slice();return n[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),n}function pe(e,t){if(!e.length)return e;let n=e.length,r=S;while(n){let o=xn(e[n-1],t,r);if(o.changes&&!o.changes.empty||o.effects.length){let l=e.slice(0,n);return l[n-1]=o,l}else t=o.mapped,n--,r=o.selectionsAfter}return r.length?[y.selection(r)]:S}function xn(e,t,n){let r=tt(e.selectionsAfter.length?e.selectionsAfter.map((c)=>c.map(t)):S,n);if(!e.changes)return y.selection(r);let o=e.changes.map(t),l=t.mapDesc(e.changes,!0),s=e.mapped?e.mapped.composeDesc(l):l;return new y(o,Z.mapEffects(e.effects,t),s,e.startSelection.map(l),r)}var Sn=/^(input\.type|delete)($|\.)/;class A{constructor(e,t,n=0,r=void 0){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=r}isolate(){return this.prevTime?new A(this.done,this.undone):this}addChanges(e,t,n,r,o){let l=this.done,s=l[l.length-1];if(s&&s.changes&&!s.changes.empty&&e.changes&&(!n||Sn.test(n))&&(!s.selectionsAfter.length&&t-this.prevTime<r.newGroupDelay&&r.joinToEvent(o,mn(s.changes,e.changes))||n=="input.type.compose"))l=K(l,l.length-1,r.minDepth,new y(e.changes.compose(s.changes),tt(Z.mapEffects(e.effects,s.changes),s.effects),s.mapped,s.startSelection,S));else l=K(l,l.length,r.minDepth,e);return new A(l,S,t,n)}addSelection(e,t,n,r){let o=this.done.length?this.done[this.done.length-1].selectionsAfter:S;if(o.length>0&&t-this.prevTime<r&&n==this.prevUserEvent&&n&&/^select($|\.)/.test(n)&&pn(o[o.length-1],e))return this;return new A(nt(this.done,e),this.undone,t,n)}addMapping(e){return new A(pe(this.done,e),pe(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,t,n){let r=e==0?this.done:this.undone;if(r.length==0)return null;let o=r[r.length-1],l=o.selectionsAfter[0]||(o.startSelection?o.startSelection.map(o.changes.invertedDesc,1):t.selection);if(n&&o.selectionsAfter.length)return t.update({selection:o.selectionsAfter[o.selectionsAfter.length-1],annotations:ge.of({side:e,rest:yn(r),selection:l}),userEvent:e==0?"select.undo":"select.redo",scrollIntoView:!0});else if(!o.changes)return null;else{let s=r.length==1?S:r.slice(0,r.length-1);if(o.mapped)s=pe(s,o.mapped);return t.update({changes:o.changes,selection:o.startSelection,effects:o.effects,annotations:ge.of({side:e,rest:s,selection:l}),filter:!1,userEvent:e==0?"undo":"redo",scrollIntoView:!0})}}}A.empty=new A(S,S);var rt=[{key:"Mod-z",run:j,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:V,preventDefault:!0},{linux:"Ctrl-Shift-z",run:V,preventDefault:!0},{key:"Mod-u",run:fn,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:dn,preventDefault:!0}];function W(e,t){return d.create(e.ranges.map(t),e.mainIndex)}function C(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:"select"})}function M({state:e,dispatch:t},n){let r=W(e.selection,n);if(r.eq(e.selection,!0))return!1;return t(C(e,r)),!0}function X(e,t){return d.cursor(t?e.to:e.from)}function ot(e,t){return M(e,(n)=>n.empty?e.moveByChar(n,t):X(n,t))}function g(e){return e.textDirectionAt(e.state.selection.main.head)==se.LTR}var lt=(e)=>ot(e,!g(e)),st=(e)=>ot(e,g(e));function ct(e,t){return M(e,(n)=>n.empty?e.moveByGroup(n,t):X(n,t))}var kn=(e)=>ct(e,!g(e)),vn=(e)=>ct(e,g(e));var Jr=typeof Intl<"u"&&Intl.Segmenter?new Intl.Segmenter(void 0,{granularity:"word"}):null;function bn(e,t,n){if(t.type.prop(n))return!0;let r=t.to-t.from;return r&&(r>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function Y(e,t,n){let r=I(e).resolveInner(t.head),o=n?Q.closedBy:Q.openedBy;for(let a=t.head;;){let h=n?r.childAfter(a):r.childBefore(a);if(!h)break;if(bn(e,h,o))r=h;else a=n?h.to:h.from}let l=r.type.prop(o),s,c;if(l&&(s=n?Ot(e,r.from,1):Ot(e,r.to,-1))&&s.matched)c=n?s.end.to:s.end.from;else c=n?r.to:r.from;return d.cursor(c,n?-1:1)}var Cn=(e)=>M(e,(t)=>Y(e.state,t,!g(e))),Mn=(e)=>M(e,(t)=>Y(e.state,t,g(e)));function at(e,t){return M(e,(n)=>{if(!n.empty)return X(n,t);let r=e.moveVertically(n,t);return r.head!=n.head?r:e.moveToLineBoundary(n,t)})}var ut=(e)=>at(e,!1),ht=(e)=>at(e,!0);function ft(e){let t=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,n=0,r=0,o;if(t){for(let l of e.state.facet(b.scrollMargins)){let s=l(e);if(s===null||s===void 0?void 0:s.top)n=Math.max(s===null||s===void 0?void 0:s.top,n);if(s===null||s===void 0?void 0:s.bottom)r=Math.max(s===null||s===void 0?void 0:s.bottom,r)}o=e.scrollDOM.clientHeight-n-r}else o=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:r,selfScroll:t,height:Math.max(e.defaultLineHeight,o-5)}}function dt(e,t){let n=ft(e),{state:r}=e,o=W(r.selection,(s)=>s.empty?e.moveVertically(s,t,n.height):X(s,t));if(o.eq(r.selection))return!1;let l;if(n.selfScroll){let s=e.coordsAtPos(r.selection.main.head),c=e.scrollDOM.getBoundingClientRect(),a=c.top+n.marginTop,h=c.bottom-n.marginBottom;if(s&&s.top>a&&s.bottom<h)l=b.scrollIntoView(o.main.head,{y:"start",yMargin:s.top-a})}return e.dispatch(C(r,o),{effects:l}),!0}var Ue=(e)=>dt(e,!1),xe=(e)=>dt(e,!0);function B(e,t,n){let r=e.lineBlockAt(t.head),o=e.moveToLineBoundary(t,n);if(o.head==t.head&&o.head!=(n?r.to:r.from))o=e.moveToLineBoundary(t,n,!1);if(!n&&o.head==r.from&&r.length){let l=/^\s*/.exec(e.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;if(l&&t.head!=r.from+l)o=d.cursor(r.from+l)}return o}var An=(e)=>M(e,(t)=>B(e,t,!0)),Bn=(e)=>M(e,(t)=>B(e,t,!1)),Dn=(e)=>M(e,(t)=>B(e,t,!g(e))),En=(e)=>M(e,(t)=>B(e,t,g(e))),Tn=(e)=>M(e,(t)=>e.moveToLineBoundary(t,!1,!1)),wn=(e)=>M(e,(t)=>e.moveToLineBoundary(t,!0,!1));function Wn(e,t,n){let r=!1,o=W(e.selection,(l)=>{let s=Ot(e,l.head,-1)||Ot(e,l.head,1)||l.head>0&&Ot(e,l.head-1,1)||l.head<e.doc.length&&Ot(e,l.head+1,-1);if(!s||!s.end)return l;r=!0;let c=s.start.from==l.head?s.end.to:s.end.from;return n?d.range(l.anchor,c):d.cursor(c)});if(!r)return!1;return t(C(e,o)),!0}var Rn=({state:e,dispatch:t})=>Wn(e,t,!1);function k(e,t,n){let r=W(e.state.selection,(o)=>{if(o.undirectional&&o.head>=o.anchor!=t)o=d.range(o.head,o.anchor);let l=n(o);return d.range(o.anchor,l.head,l.goalColumn,l.bidiLevel||void 0,l.assoc)});if(r.eq(e.state.selection))return!1;return e.dispatch(C(e.state,r)),!0}function pt(e,t){return k(e,t,(n)=>e.moveByChar(n,t))}var gt=(e)=>pt(e,!g(e)),yt=(e)=>pt(e,g(e));function St(e,t){return k(e,t,(n)=>e.moveByGroup(n,t))}var On=(e)=>St(e,!g(e)),Fn=(e)=>St(e,g(e));var In=(e)=>{let t=!g(e);return k(e,t,(n)=>Y(e.state,n,t))},Pn=(e)=>{let t=g(e);return k(e,t,(n)=>Y(e.state,n,t))};function kt(e,t){return k(e,t,(n)=>e.moveVertically(n,t))}var bt=(e)=>kt(e,!1),Ct=(e)=>kt(e,!0);function Mt(e,t){return k(e,t,(n)=>e.moveVertically(n,t,ft(e).height))}var ze=(e)=>Mt(e,!1),_e=(e)=>Mt(e,!0),Nn=(e)=>k(e,!0,(t)=>B(e,t,!0)),qn=(e)=>k(e,!1,(t)=>B(e,t,!1)),Vn=(e)=>{let t=!g(e);return k(e,t,(n)=>B(e,n,t))},Gn=(e)=>{let t=g(e);return k(e,t,(n)=>B(e,n,t))},Un=(e)=>k(e,!1,(t)=>d.cursor(e.lineBlockAt(t.head).from)),zn=(e)=>k(e,!0,(t)=>d.cursor(e.lineBlockAt(t.head).to)),Je=({state:e,dispatch:t})=>(t(C(e,{anchor:0})),!0),$e=({state:e,dispatch:t})=>(t(C(e,{anchor:e.doc.length})),!0),Ke=({state:e,dispatch:t})=>(t(C(e,{anchor:e.selection.main.anchor,head:0})),!0),He=({state:e,dispatch:t})=>(t(C(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),_n=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:"select"})),!0),Jn=({state:e,dispatch:t})=>{let n=ee(e).map(({from:r,to:o})=>d.undirectionalRange(r,Math.min(o+1,e.doc.length)));return t(e.update({selection:d.create(n),userEvent:"select"})),!0},$n=({state:e,dispatch:t})=>{let n=W(e.selection,(r)=>{let o=I(e),l=o.resolveStack(r.from,1);if(r.empty){let s=o.resolveStack(r.from,-1);if(s.node.from>=l.node.from&&s.node.to<=l.node.to)l=s}for(let s=l;s;s=s.next){let{node:c}=s;if((c.from<r.from&&c.to>=r.to||c.to>r.to&&c.from<=r.from)&&s.next)return d.undirectionalRange(c.from,c.to)}return r});if(n.eq(e.selection))return!1;return t(C(e,n)),!0};function At(e,t){let{state:n}=e,r=n.selection,o=n.selection.ranges.slice();for(let l of n.selection.ranges){let s=n.doc.lineAt(l.head);if(t?s.to<e.state.doc.length:s.from>0)for(let c=l;;){let a=e.moveVertically(c,t);if(a.head<s.from||a.head>s.to){if(!o.some((h)=>h.head==a.head))o.push(a);break}else if(a.head==c.head)break;else c=a}}if(o.length==r.ranges.length)return!1;return e.dispatch(C(n,d.create(o,o.length-1))),!0}var Kn=(e)=>At(e,!1),Hn=(e)=>At(e,!0),Qn=({state:e,dispatch:t})=>{let n=e.selection,r=null;if(n.ranges.length>1)r=d.create([n.main]);else if(!n.main.empty)r=d.create([d.cursor(n.main.head)]);if(!r)return!1;return t(C(e,r)),!0};function G(e,t){if(e.state.readOnly)return!1;let n="delete.selection",{state:r}=e,o=r.changeByRange((l)=>{let{from:s,to:c}=l;if(s==c){let a=t(l);if(a<s)n="delete.backward",a=J(e,a,!1);else if(a>s)n="delete.forward",a=J(e,a,!0);s=Math.min(s,a),c=Math.max(c,a)}else s=J(e,s,!1),c=J(e,c,!0);return s==c?{range:l}:{changes:{from:s,to:c},range:d.cursor(s,s<l.head?-1:1)}});if(o.changes.empty)return!1;return e.dispatch(r.update(o,{scrollIntoView:!0,userEvent:n,effects:n=="delete.selection"?b.announce.of(r.phrase("Selection deleted")):void 0})),!0}function J(e,t,n){if(e instanceof b)for(let r of e.state.facet(b.atomicRanges).map((o)=>o(e)))r.between(t,t,(o,l)=>{if(o<t&&l>t)t=n?l:o});return t}var Lt=(e,t,n)=>G(e,(r)=>{let o=r.from,{state:l}=e,s=l.doc.lineAt(o),c,a;if(n&&!t&&o>s.from&&o<s.from+200&&!/[^ \t]/.test(c=s.text.slice(0,o-s.from))){if(c[c.length-1]=="\t")return o-1;let h=Ze(c,l.tabSize),u=h%Gt(l)||Gt(l);for(let f=0;f<u&&c[c.length-1-f]==" ";f++)o--;a=o}else if(a=ye(s.text,o-s.from,t,t)+s.from,a==o&&s.number!=(t?l.doc.lines:1))a+=t?1:-1;else if(!t&&/[\ufe00-\ufe0f]/.test(s.text.slice(a-s.from,o-s.from)))a=ye(s.text,a-s.from,!1,!1)+s.from;return a}),Se=(e)=>Lt(e,!1,!0);var Bt=(e)=>Lt(e,!0,!1),Dt=(e,t)=>G(e,(n)=>{let r=n.head,{state:o}=e,l=o.doc.lineAt(r),s=o.charCategorizer(r);for(let c=null;;){if(r==(t?l.to:l.from)){if(r==n.head&&l.number!=(t?o.doc.lines:1))r+=t?1:-1;break}let a=ye(l.text,r-l.from,t)+l.from,h=l.text.slice(Math.min(r,a)-l.from,Math.max(r,a)-l.from),u=s(h);if(c!=null&&u!=c)break;if(h!=" "||r!=n.head)c=u;r=a}return r}),Et=(e)=>Dt(e,!1),jn=(e)=>Dt(e,!0);var Yn=(e)=>G(e,(t)=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)});var Zn=(e)=>G(e,(t)=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),er=(e)=>G(e,(t)=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)});var tr=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange((r)=>({changes:{from:r.from,to:r.to,insert:F.of(["",""])},range:d.cursor(r.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:"input"})),!0},nr=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange((r)=>{if(!r.empty||r.from==0||r.from==e.doc.length)return{range:r};let o=r.from,l=e.doc.lineAt(o),s=o==l.from?o-1:ye(l.text,o-l.from,!1)+l.from,c=o==l.to?o+1:ye(l.text,o-l.from,!0)+l.from;return{changes:{from:s,to:c,insert:e.doc.slice(o,c).append(e.doc.slice(s,o))},range:d.cursor(c)}});if(n.changes.empty)return!1;return t(e.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0};function ee(e){let t=[],n=-1;for(let r of e.selection.ranges){let o=e.doc.lineAt(r.from),l=e.doc.lineAt(r.to);if(!r.empty&&r.to==l.from)l=e.doc.lineAt(r.to-1);if(n>=o.number){let s=t[t.length-1];s.to=l.to,s.ranges.push(r)}else t.push({from:o.from,to:l.to,ranges:[r]});n=l.number+1}return t}function wt(e,t,n){if(e.readOnly)return!1;let r=[],o=[];for(let l of ee(e)){if(n?l.to==e.doc.length:l.from==0)continue;let s=e.doc.lineAt(n?l.to+1:l.from-1),c=s.length+1;if(n){r.push({from:l.to,to:s.to},{from:l.from,insert:s.text+e.lineBreak});for(let a of l.ranges)o.push(d.range(Math.min(e.doc.length,a.anchor+c),Math.min(e.doc.length,a.head+c)))}else{r.push({from:s.from,to:l.from},{from:l.to,insert:e.lineBreak+s.text});for(let a of l.ranges)o.push(d.range(a.anchor-c,a.head-c))}}if(!r.length)return!1;return t(e.update({changes:r,scrollIntoView:!0,selection:d.create(o,e.selection.mainIndex),userEvent:"move.line"})),!0}var rr=({state:e,dispatch:t})=>wt(e,t,!1),or=({state:e,dispatch:t})=>wt(e,t,!0);function Wt(e,t,n){if(e.readOnly)return!1;let r=[];for(let l of ee(e))if(n)r.push({from:l.from,insert:e.doc.slice(l.from,l.to)+e.lineBreak});else r.push({from:l.to,insert:e.lineBreak+e.doc.slice(l.from,l.to)});let o=e.changes(r);return t(e.update({changes:o,selection:e.selection.map(o,n?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}var lr=({state:e,dispatch:t})=>Wt(e,t,!1),ir=({state:e,dispatch:t})=>Wt(e,t,!0),sr=(e)=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(ee(t).map(({from:o,to:l})=>{if(o>0)o--;else if(l<t.doc.length)l++;return{from:o,to:l}})),r=W(t.selection,(o)=>{let l=void 0;if(e.lineWrapping){let s=e.lineBlockAt(o.head),c=e.coordsAtPos(o.head,o.assoc||1);if(c)l=s.bottom+e.documentTop-c.bottom+e.defaultLineHeight/2}return e.moveVertically(o,!0,l)}).map(n);return e.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:"delete.line"}),!0};function cr(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=I(e).resolveInner(t),r=n.childBefore(t),o=n.childAfter(t),l;if(r&&o&&r.to<=t&&o.from>=t&&(l=r.type.prop(Q.closedBy))&&l.indexOf(o.name)>-1&&e.doc.lineAt(r.to).from==e.doc.lineAt(o.from).from&&!/\S/.test(e.sliceDoc(r.to,o.from)))return{from:r.to,to:o.from};return null}var Qe=Rt(!1),ar=Rt(!0);function Rt(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=t.changeByRange((o)=>{let{from:l,to:s}=o,c=t.doc.lineAt(l),a=!e&&l==s&&cr(t,l);if(e)l=s=(s<=c.to?c:t.doc.lineAt(s)).to;let h=new Ln(t,{simulateBreak:l,simulateDoubleBreak:!!a}),u=Lr(h,l);if(u==null)u=Ze(/^\s*/.exec(t.doc.lineAt(l).text)[0],t.tabSize);while(s<c.to&&/\s/.test(c.text[s-c.from]))s++;if(a)({from:l,to:s}=a);else if(l>c.from&&l<c.from+100&&!/\S/.test(c.text.slice(0,l)))l=c.from;let f=["",fi(t,u)];if(a)f.push(fi(t,h.lineIndent(c.from,-1)));return{changes:{from:l,to:s,insert:F.of(f)},range:d.cursor(l+1+f[1].length)}});return n(t.update(r,{scrollIntoView:!0,userEvent:"input"})),!0}}function Me(e,t){let n=-1;return e.changeByRange((r)=>{let o=[];for(let s=r.from;s<=r.to;){let c=e.doc.lineAt(s);if(c.number>n&&(r.empty||r.to>c.from))t(c,o,r),n=c.number;s=c.to+1}let l=e.changes(o);return{changes:o,range:d.range(l.mapPos(r.anchor,1),l.mapPos(r.head,1))}})}var ur=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new Ln(e,{overrideIndentation:(l)=>{let s=n[l];return s==null?-1:s}}),o=Me(e,(l,s,c)=>{let a=Lr(r,l.from);if(a==null)return;if(!/\S/.test(l.text))a=0;let h=/^\s*/.exec(l.text)[0],u=fi(e,a);if(h!=u||c.from<l.from+h.length)n[l.from]=a,s.push({from:l.from,to:l.from+h.length,insert:u})});if(!o.changes.empty)t(e.update(o,{userEvent:"indent"}));return!0},te=({state:e,dispatch:t})=>{if(e.readOnly)return!1;return t(e.update(Me(e,(n,r)=>{r.push({from:n.from,insert:e.facet(it)})}),{userEvent:"input.indent"})),!0},Ft=({state:e,dispatch:t})=>{if(e.readOnly)return!1;return t(e.update(Me(e,(n,r)=>{let o=/^\s*/.exec(n.text)[0];if(!o)return;let l=Ze(o,e.tabSize),s=0,c=fi(e,Math.max(0,l-Gt(e)));while(s<o.length&&s<c.length&&o.charCodeAt(s)==c.charCodeAt(s))s++;r.push({from:n.from+s,to:n.from+o.length,insert:c.slice(s)})}),{userEvent:"delete.dedent"})),!0},hr=(e)=>(e.setTabFocusMode(),!0);var fr=[{key:"Ctrl-b",run:lt,shift:gt,preventDefault:!0},{key:"Ctrl-f",run:st,shift:yt},{key:"Ctrl-p",run:ut,shift:bt},{key:"Ctrl-n",run:ht,shift:Ct},{key:"Ctrl-a",run:Tn,shift:Un},{key:"Ctrl-e",run:wn,shift:zn},{key:"Ctrl-d",run:Bt},{key:"Ctrl-h",run:Se},{key:"Ctrl-k",run:Yn},{key:"Ctrl-Alt-h",run:Et},{key:"Ctrl-o",run:tr},{key:"Ctrl-t",run:nr},{key:"Ctrl-v",run:xe}],dr=[{key:"ArrowLeft",run:lt,shift:gt,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:kn,shift:On,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:Dn,shift:Vn,preventDefault:!0},{key:"ArrowRight",run:st,shift:yt,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:vn,shift:Fn,preventDefault:!0},{mac:"Cmd-ArrowRight",run:En,shift:Gn,preventDefault:!0},{key:"ArrowUp",run:ut,shift:bt,preventDefault:!0},{mac:"Cmd-ArrowUp",run:Je,shift:Ke},{mac:"Ctrl-ArrowUp",run:Ue,shift:ze},{key:"ArrowDown",run:ht,shift:Ct,preventDefault:!0},{mac:"Cmd-ArrowDown",run:$e,shift:He},{mac:"Ctrl-ArrowDown",run:xe,shift:_e},{key:"PageUp",run:Ue,shift:ze},{key:"PageDown",run:xe,shift:_e},{key:"Home",run:Bn,shift:qn,preventDefault:!0},{key:"Mod-Home",run:Je,shift:Ke},{key:"End",run:An,shift:Nn,preventDefault:!0},{key:"Mod-End",run:$e,shift:He},{key:"Enter",run:Qe,shift:Qe},{key:"Mod-a",run:_n},{key:"Backspace",run:Se,shift:Se,preventDefault:!0},{key:"Delete",run:Bt,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Et,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:jn,preventDefault:!0},{mac:"Mod-Backspace",run:Zn,preventDefault:!0},{mac:"Mod-Delete",run:er,preventDefault:!0}].concat(fr.map((e)=>({mac:e.key,run:e.run,shift:e.shift}))),It=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:Cn,shift:In},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:Mn,shift:Pn},{key:"Alt-ArrowUp",run:rr},{key:"Shift-Alt-ArrowUp",run:lr},{key:"Alt-ArrowDown",run:or},{key:"Shift-Alt-ArrowDown",run:ir},{key:"Mod-Alt-ArrowUp",run:Kn},{key:"Mod-Alt-ArrowDown",run:Hn},{key:"Escape",run:Qn},{key:"Mod-Enter",run:ar},{key:"Alt-l",mac:"Ctrl-l",run:Jn},{key:"Mod-i",run:$n,preventDefault:!0},{key:"Mod-[",run:Ft},{key:"Mod-]",run:te},{key:"Mod-Alt-\\",run:ur},{key:"Shift-Mod-k",run:sr},{key:"Shift-Mod-\\",run:Rn},{key:"Mod-/",run:nn},{key:"Alt-A",mac:"Ctrl-A",run:on},{key:"Ctrl-m",mac:"Shift-Alt-m",run:hr}].concat(dr),Pt={key:"Tab",run:te,shift:Ft};var Nt=typeof String.prototype.normalize=="function"?(e)=>e.normalize("NFKD"):(e)=>e;class E{constructor(e,t,n=0,r=e.length,o,l){this.test=l,this.value={from:0,to:0,precise:!1},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(n,r),this.bufferStart=n,this.normalize=o?(s)=>o(Nt(s)):Nt,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return Gi(this.buffer,this.bufferPos)}next(){while(this.matches.length)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=Uo(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=Zi(e);let r=this.normalize(t);if(r.length)for(let o=0,l=n,s=!0;;o++){let c=r.charCodeAt(o),a=this.match(c,l,s,this.bufferPos+this.bufferStart,o==r.length-1);if(a)return this.value=a,this;if(o==r.length-1)break;if(s&&o<t.length&&t.charCodeAt(o)==c)l++;else s=!1}}}match(e,t,n,r,o){let l=null;for(let s=0;s<this.matches.length;){let c=this.matches[s],a=!1;if(this.query.charCodeAt(c.index)==e)if(c.index==this.query.length-1)l={from:c.from,to:r,precise:o&&c.precise};else c.index++,a=!0;if(a)s++;else this.matches.splice(s,1)}if(this.query.charCodeAt(0)==e)if(this.query.length==1)l={from:t,to:r,precise:n&&o};else this.matches.push({from:t,index:1,precise:n});if(l&&this.test&&!this.test(l.from,l.to,this.buffer,this.bufferStart))l=null;return l}}if(typeof Symbol<"u")E.prototype[Symbol.iterator]=function(){return this};var zt={from:-1,to:-1,match:/.*/.exec(""),precise:!0},De="gm"+(/x/.unicode==null?"":"u");class Ee{constructor(e,t,n,r=0,o=e.length){if(this.text=e,this.to=o,this.curLine="",this.done=!1,this.value=zt,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new Te(e,t,n,r,o);this.re=new RegExp(t,De+((n===null||n===void 0?void 0:n.ignoreCase)?"i":"")),this.test=n===null||n===void 0?void 0:n.test,this.iter=e.iter();let l=e.lineAt(r);this.curLineStart=l.from,this.matchPos=ie(e,r),this.getLine(this.curLineStart)}getLine(e){if(this.iter.next(e),this.iter.lineBreak)this.curLine="";else{if(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to)this.curLine=this.curLine.slice(0,this.to-this.curLineStart);this.iter.next()}}nextLine(){if(this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to)this.curLine="";else this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let n=this.curLineStart+t.index,r=n+t[0].length;if(this.matchPos=ie(this.text,r+(n==r?1:0)),n==this.curLineStart+this.curLine.length)this.nextLine();if((n<r||n>this.value.to)&&(!this.test||this.test(n,r,t)))return this.value={from:n,to:r,precise:!0,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}}var Ae=new WeakMap;class P{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(e,t,n){let r=Ae.get(e);if(!r||r.from>=n||r.to<=t){let s=new P(t,e.sliceString(t,n));return Ae.set(e,s),s}if(r.from==t&&r.to==n)return r;let{text:o,from:l}=r;if(l>t)o=e.sliceString(t,l)+o,l=t;if(r.to<n)o+=e.sliceString(r.to,n);return Ae.set(e,new P(l,o)),new P(t,o.slice(t-l,n-l))}}class Te{constructor(e,t,n,r,o){this.text=e,this.to=o,this.done=!1,this.value=zt,this.matchPos=ie(e,r),this.re=new RegExp(t,De+((n===null||n===void 0?void 0:n.ignoreCase)?"i":"")),this.test=n===null||n===void 0?void 0:n.test,this.flat=P.get(e,r,this.chunkEnd(r+5000))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e)this.re.lastIndex=e+1,t=this.re.exec(this.flat.text);if(t){let n=this.flat.from+t.index,r=n+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(n,r,t)))return this.value={from:n,to:r,precise:!0,match:t},this.matchPos=ie(this.text,r+(n==r?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=P.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}if(typeof Symbol<"u")Ee.prototype[Symbol.iterator]=Te.prototype[Symbol.iterator]=function(){return this};function mr(e){try{return new RegExp(e,De),!0}catch(t){return!1}}function ie(e,t){if(t>=e.length)return t;let n=e.lineAt(t),r;while(t<n.to&&(r=n.text.charCodeAt(t-n.from))>=56320&&r<57344)t++;return t}var pr=(e)=>{let t=Go(e,"cm-goto-line");if(t){let s=t.dom.querySelector("input[type=text]");if(s)s.select();return!0}let{state:n}=e,r=String(n.doc.lineAt(e.state.selection.main.head).number),{close:o,result:l}=Fo(e,{class:"cm-goto-line",label:n.phrase("Go to line"),input:{type:"text",name:"line",value:r},focus:!0,submitLabel:n.phrase("go")});return l.then((s)=>{let c=s&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(s.elements.line.value);if(!c){e.dispatch({effects:o});return}let a=n.doc.lineAt(n.selection.main.head),[,h,u,f,m]=c,L=f?+f.slice(1):0,v=u?+u:a.number;if(u&&m){let me=v/100;if(h)me=me*(h=="-"?-1:1)+a.number/n.doc.lines;v=Math.round(n.doc.lines*me)}else if(u&&h)v=v*(h=="-"?-1:1)+a.number;let qe=n.doc.line(Math.max(1,Math.min(n.doc.lines,v))),Ve=d.cursor(qe.from+Math.max(0,Math.min(L,qe.length)));e.dispatch({effects:[o,b.scrollIntoView(Ve.from,{y:"center"})],selection:Ve})}),!0},gr={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},_t=w.define({combine(e){return vt(e,gr,{highlightWordAroundCursor:(t,n)=>t||n,minSelectionLength:Math.min,maxMatches:Math.min})}});function Jt(e){let t=[vr,kr];if(e)t.push(_t.of(e));return t}var yr=z.mark({class:"cm-selectionMatch"}),xr=z.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function Vt(e,t,n,r){return(n==0||e(t.sliceDoc(n-1,n))!=ce.Word)&&(r==t.doc.length||e(t.sliceDoc(r,r+1))!=ce.Word)}function Sr(e,t,n,r){return e(t.sliceDoc(n,n+1))==ce.Word&&e(t.sliceDoc(r-1,r))==ce.Word}var kr=Ie.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){if(e.selectionSet||e.docChanged||e.viewportChanged)this.decorations=this.getDeco(e.view)}getDeco(e){let t=e.state.facet(_t),{state:n}=e,r=n.selection;if(r.ranges.length>1)return z.none;let o=r.main,l,s=null;if(o.empty){if(!t.highlightWordAroundCursor)return z.none;let a=n.wordAt(o.head);if(!a)return z.none;s=n.charCategorizer(o.head),l=n.sliceDoc(a.from,a.to)}else{let a=o.to-o.from;if(a<t.minSelectionLength||a>200)return z.none;if(t.wholeWords){if(l=n.sliceDoc(o.from,o.to),s=n.charCategorizer(o.head),!(Vt(s,n,o.from,o.to)&&Sr(s,n,o.from,o.to)))return z.none}else if(l=n.sliceDoc(o.from,o.to),!l)return z.none}let c=[];for(let a of e.visibleRanges){let h=new E(n.doc,l,a.from,a.to);while(!h.next().done){let{from:u,to:f}=h.value;if(!s||Vt(s,n,u,f)){if(o.empty&&u<=o.from&&f>=o.to)c.push(xr.range(u,f));else if(u>=o.to||f<=o.from)c.push(yr.range(u,f));if(c.length>t.maxMatches)return z.none}}}return z.set(c)}},{decorations:(e)=>e.decorations}),vr=b.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),br=({state:e,dispatch:t})=>{let{selection:n}=e,r=d.create(n.ranges.map((o)=>e.wordAt(o.head)||d.cursor(o.head)),n.mainIndex);if(r.eq(n))return!1;return t(e.update({selection:r})),!0};function Cr(e,t){let{main:n,ranges:r}=e.selection,o=e.wordAt(n.head),l=o&&o.from==n.from&&o.to==n.to;for(let s=!1,c=new E(e.doc,t,r[r.length-1].to);;)if(c.next(),c.done){if(s)return null;c=new E(e.doc,t,0,Math.max(0,r[r.length-1].from-1)),s=!0}else{if(s&&r.some((a)=>a.from==c.value.from))continue;if(l){let a=e.wordAt(c.value.from);if(!a||a.from!=c.value.from||a.to!=c.value.to)continue}return c.value}}var Mr=({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some((l)=>l.from===l.to))return br({state:e,dispatch:t});let r=e.sliceDoc(n[0].from,n[0].to);if(e.selection.ranges.some((l)=>e.sliceDoc(l.from,l.to)!=r))return!1;let o=Cr(e,r);if(!o)return!1;return t(e.update({selection:e.selection.addRange(d.range(o.from,o.to),!1),effects:b.scrollIntoView(o.to)})),!0},T=w.define({combine(e){return vt(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:(t)=>new Zt(t),scrollToMatch:(t)=>b.scrollIntoView(t)})}});function $t(e){return e?[T.of(e),Be]:Be}class we{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||mr(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(t,n)=>n=="n"?`
|
|
2
|
-
`:n=="r"?"\r":n=="t"?"\t":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new Ht(this):new Kt(this)}getCursor(e,t=0,n){let r=e.doc?e:q.create({doc:e});if(n==null)n=r.doc.length;return this.regexp?O(this,r,t,n):R(this,r,t,n)}}class We{constructor(e){this.spec=e}}function Ar(e,t,n){return(r,o,l,s)=>{if(n&&!n(r,o,l,s))return!1;let c=r>=s&&o<=s+l.length?l.slice(r-s,o-s):t.doc.sliceString(r,o);return e(c,t,r,o)}}function R(e,t,n,r){let o;if(e.wholeWord)o=Br(t.doc,t.charCategorizer(t.selection.main.head));if(e.test)o=Ar(e.test,t,o);return new E(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:(l)=>l.toLowerCase(),o)}function Br(e,t){return(n,r,o,l)=>{if(l>n||l+o.length<r)l=Math.max(0,n-2),o=e.sliceString(l,Math.min(e.length,r+2));return(t(ae(o,n-l))!=ce.Word||t(ue(o,n-l))!=ce.Word)&&(t(ue(o,r-l))!=ce.Word||t(ae(o,r-l))!=ce.Word)}}class Kt extends We{constructor(e){super(e)}nextMatch(e,t,n){let r=R(this.spec,e,n,e.doc.length).nextOverlapping();if(r.done){let o=Math.min(e.doc.length,t+this.spec.unquoted.length);r=R(this.spec,e,0,o).nextOverlapping()}return r.done||r.value.from==t&&r.value.to==n?null:r.value}prevMatchInRange(e,t,n){for(let r=n;;){let o=Math.max(t,r-1e4-this.spec.unquoted.length),l=R(this.spec,e,o,r),s=null;while(!l.nextOverlapping().done)s=l.value;if(s)return s;if(o==t)return null;r-=1e4}}prevMatch(e,t,n){let r=this.prevMatchInRange(e,0,t);if(!r)r=this.prevMatchInRange(e,Math.max(0,n-this.spec.unquoted.length),e.doc.length);return r&&(r.from!=t||r.to!=n)?r:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let n=R(this.spec,e,0,e.doc.length),r=[];while(!n.next().done){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let o=R(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));while(!o.next().done)r(o.value.from,o.value.to)}}function Dr(e,t,n){return(r,o,l)=>(!n||n(r,o,l))&&e(l[0],t,r,o)}function O(e,t,n,r){let o;if(e.wholeWord)o=Er(t.charCategorizer(t.selection.main.head));if(e.test)o=Dr(e.test,t,o);return new Ee(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:o},n,r)}function ae(e,t){return e.slice(ye(e,t,!1),t)}function ue(e,t){return e.slice(t,ye(e,t))}function Er(e){return(t,n,r)=>!r[0].length||(e(ae(r.input,r.index))!=ce.Word||e(ue(r.input,r.index))!=ce.Word)&&(e(ue(r.input,r.index+r[0].length))!=ce.Word||e(ae(r.input,r.index+r[0].length))!=ce.Word)}class Ht extends We{nextMatch(e,t,n){let r=O(this.spec,e,n,e.doc.length).next();if(r.done)r=O(this.spec,e,0,t).next();return r.done?null:r.value}prevMatchInRange(e,t,n){for(let r=1;;r++){let o=Math.max(t,n-r*1e4),l=O(this.spec,e,o,n),s=null;while(!l.next().done)s=l.value;if(s&&(o==t||s.from>o+10))return s;if(o==t)return null}}prevMatch(e,t,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,n)=>{if(n=="&")return e.match[0];if(n=="$")return"$";for(let r=n.length;r>0;r--){let o=+n.slice(0,r);if(o>0&&o<e.match.length)return e.match[o]+n.slice(r)}return t})}matchAll(e,t){let n=O(this.spec,e,0,e.doc.length),r=[];while(!n.next().done){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let o=O(this.spec,e,Math.max(0,t-250),Math.min(n+250,e.doc.length));while(!o.next().done)r(o.value.from,o.value.to)}}var U=Z.define(),Re=Z.define(),D=Ne.define({create(e){return new oe(Le(e).create(),null)},update(e,t){for(let n of t.effects)if(n.is(U))e=new oe(n.value.create(),e.panel);else if(n.is(Re))e=new oe(e.query,n.value?Oe:null);return e},provide:(e)=>ci.from(e,(t)=>t.panel)});class oe{constructor(e,t){this.query=e,this.panel=t}}var Tr=z.mark({class:"cm-searchMatch"}),wr=z.mark({class:"cm-searchMatch cm-searchMatch-selected"}),Wr=Ie.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(D))}update(e){let t=e.state.field(D);if(t!=e.startState.field(D)||e.docChanged||e.selectionSet||e.viewportChanged)this.decorations=this.highlight(t)}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return z.none;let{view:n}=this,r=new xt;for(let o=0,l=n.visibleRanges,s=l.length;o<s;o++){let{from:c,to:a}=l[o];while(o<s-1&&a>l[o+1].from-500)a=l[++o].to;e.highlight(n.state,c,a,(h,u)=>{let f=n.state.selection.ranges.some((m)=>m.from==h&&m.to==u);r.add(h,u,f?wr:Tr)})}return r.finish()}},{decorations:(e)=>e.decorations});function _(e){return(t)=>{let n=t.state.field(D,!1);return n&&n.query.spec.valid?e(t,n):de(t)}}var he=_((e,{query:t})=>{let{to:n}=e.state.selection.main,r=t.nextMatch(e.state,n,n);if(!r)return!1;let o=d.single(r.from,r.to),l=e.state.facet(T);return e.dispatch({selection:o,effects:[Pe(e,r),l.scrollToMatch(o.main,e)],userEvent:"select.search"}),jt(e),!0}),fe=_((e,{query:t})=>{let{state:n}=e,{from:r}=n.selection.main,o=t.prevMatch(n,r,r);if(!o)return!1;let l=d.single(o.from,o.to),s=e.state.facet(T);return e.dispatch({selection:l,effects:[Pe(e,o),s.scrollToMatch(l.main,e)],userEvent:"select.search"}),jt(e),!0}),Rr=_((e,{query:t})=>{let n=t.matchAll(e.state,1000);if(!n||!n.length)return!1;return e.dispatch({selection:d.create(n.map((r)=>d.range(r.from,r.to))),userEvent:"select.search.matches"}),!0}),Or=({state:e,dispatch:t})=>{let n=e.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:r,to:o}=n.main,l=[],s=0;for(let c=new E(e.doc,e.sliceDoc(r,o));!c.next().done;){if(l.length>1000)return!1;if(c.value.from==r)s=l.length;l.push(d.range(c.value.from,c.value.to))}return t(e.update({selection:d.create(l,s),userEvent:"select.search.matches"})),!0},Ut=_((e,{query:t})=>{let{state:n}=e,{from:r,to:o}=n.selection.main;if(n.readOnly)return!1;let l=t.nextMatch(n,r,r);if(!l)return!1;let s=l,c=[],a,h,u=[];if(!s.precise)s=t.nextMatch(n,s.from,s.to);else if(s.from==r&&s.to==o)h=n.toText(t.getReplacement(s)),c.push({from:s.from,to:s.to,insert:h}),s=t.nextMatch(n,s.from,s.to),u.push(b.announce.of(n.phrase("replaced match on line $",n.doc.lineAt(r).number)+"."));let f=e.state.changes(c);if(s)a=d.single(s.from,s.to).map(f),u.push(Pe(e,s)),u.push(n.facet(T).scrollToMatch(a.main,e));return e.dispatch({changes:f,selection:a,effects:u,userEvent:"input.replace"}),!0}),Fr=_((e,{query:t})=>{if(e.state.readOnly)return!1;let n=[];for(let o of t.matchAll(e.state,1e9)){let{from:l,to:s,precise:c}=o;if(c)n.push({from:l,to:s,insert:t.getReplacement(o)})}if(!n.length)return!1;let r=e.state.phrase("replaced $ matches",n.length)+".";return e.dispatch({changes:n,effects:b.announce.of(r),userEvent:"input.replace.all"}),!0});function Oe(e){return e.state.facet(T).createPanel(e)}function Le(e,t){var n,r,o,l,s;let c=e.selection.main,a=c.empty||c.to>c.from+100?"":e.sliceDoc(c.from,c.to);if(t&&!a)return t;let h=e.facet(T);return new we({search:((n=t===null||t===void 0?void 0:t.literal)!==null&&n!==void 0?n:h.literal)?a:a.replace(/\n/g,"\\n"),caseSensitive:(r=t===null||t===void 0?void 0:t.caseSensitive)!==null&&r!==void 0?r:h.caseSensitive,literal:(o=t===null||t===void 0?void 0:t.literal)!==null&&o!==void 0?o:h.literal,regexp:(l=t===null||t===void 0?void 0:t.regexp)!==null&&l!==void 0?l:h.regexp,wholeWord:(s=t===null||t===void 0?void 0:t.wholeWord)!==null&&s!==void 0?s:h.wholeWord})}function Qt(e){let t=Wi(e,Oe);return t&&t.dom.querySelector("[main-field]")}function jt(e){let t=Qt(e);if(t&&t==e.root.activeElement)t.select()}var de=(e)=>{let t=e.state.field(D,!1);if(t&&t.panel){let n=Qt(e);if(n&&n!=e.root.activeElement){let r=Le(e.state,t.query.spec);if(r.valid)e.dispatch({effects:U.of(r)});n.focus(),n.select()}}else e.dispatch({effects:[Re.of(!0),t?U.of(Le(e.state,t.query.spec)):Z.appendConfig.of(Be)]});return!0},Xt=(e)=>{let t=e.state.field(D,!1);if(!t||!t.panel)return!1;let n=Wi(e,Oe);if(n&&n.dom.contains(e.root.activeElement))e.focus();return e.dispatch({effects:Re.of(!1)}),!0},Yt=[{key:"Mod-f",run:de,scope:"editor search-panel"},{key:"F3",run:he,shift:fe,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:he,shift:fe,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:Xt,scope:"editor search-panel"},{key:"Mod-Shift-l",run:Or},{key:"Mod-Alt-g",run:pr},{key:"Mod-d",run:Mr,preventDefault:!0}];class Zt{constructor(e){this.view=e;let t=this.query=e.state.field(D).query.spec;this.commit=this.commit.bind(this),this.searchField=ve("input",{value:t.search,placeholder:x(e,"Find"),"aria-label":x(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=ve("input",{value:t.replace,placeholder:x(e,"Replace"),"aria-label":x(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=ve("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=ve("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=ve("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit});function n(r,o,l){return ve("button",{class:"cm-button",name:r,onclick:o,type:"button"},l)}this.dom=ve("div",{onkeydown:(r)=>this.keydown(r),class:"cm-search"},[this.searchField,n("next",()=>he(e),[x(e,"next")]),n("prev",()=>fe(e),[x(e,"previous")]),n("select",()=>Rr(e),[x(e,"all")]),ve("label",null,[this.caseField,x(e,"match case")]),ve("label",null,[this.reField,x(e,"regexp")]),ve("label",null,[this.wordField,x(e,"by word")]),...e.state.readOnly?[]:[ve("br"),this.replaceField,n("replace",()=>Ut(e),[x(e,"replace")]),n("replaceAll",()=>Fr(e),[x(e,"replace all")])],ve("button",{name:"close",onclick:()=>Xt(e),"aria-label":x(e,"close"),type:"button"},["×"])])}commit(){let e=new we({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});if(!e.eq(this.query))this.query=e,this.view.dispatch({effects:U.of(e)})}keydown(e){if(Vo(this.view,e,"search-panel"))e.preventDefault();else if(e.keyCode==13&&e.target==this.searchField)e.preventDefault(),(e.shiftKey?fe:he)(this.view);else if(e.keyCode==13&&e.target==this.replaceField)e.preventDefault(),Ut(this.view)}update(e){for(let t of e.transactions)for(let n of t.effects)if(n.is(U)&&!n.value.eq(this.query))this.setQuery(n.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(T).top}}function x(e,t){return e.state.phrase(t)}var ne=30,re=/[\s\.,:;?!]/;function Pe(e,{from:t,to:n}){let r=e.state.doc.lineAt(t),o=e.state.doc.lineAt(n).to,l=Math.max(r.from,t-ne),s=Math.min(o,n+ne),c=e.state.sliceDoc(l,s);if(l!=r.from){for(let a=0;a<ne;a++)if(!re.test(c[a+1])&&re.test(c[a])){c=c.slice(a);break}}if(s!=o){for(let a=c.length-1;a>c.length-ne;a--)if(!re.test(c[a-1])&&re.test(c[a])){c=c.slice(0,a);break}}return b.announce.of(`${e.state.phrase("current match")}. ${c} ${e.state.phrase("on line")} ${r.number}.`)}var Ir=b.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),Be=[D,Fe.low(Wr),Ir];var Pr=b.theme({"&":{color:"var(--code-fg)",backgroundColor:"var(--code-bg)",height:"100%",fontSize:"var(--code-size, 13px)"},"&.cm-focused":{outline:"none"},".cm-scroller":{fontFamily:"var(--font-mono)",lineHeight:"1.55",overflow:"auto"},".cm-content":{caretColor:"var(--code-fg)",padding:"0.5rem 0"},".cm-line":{padding:"0 0.75rem"},".cm-cursor, .cm-dropCursor":{borderLeftColor:"var(--code-fg)"},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:"var(--code-selection)"},".cm-activeLine":{backgroundColor:"var(--code-active-line)"},".cm-gutters":{backgroundColor:"var(--code-gutter-bg)",color:"var(--code-gutter)",border:"none",borderRight:"1px solid var(--border)"},".cm-activeLineGutter":{backgroundColor:"var(--code-active-line)",color:"var(--code-fg)"},".cm-lineNumbers .cm-gutterElement":{padding:"0 0.5rem 0 0.5rem",minWidth:"2.25rem"},".cm-matchingBracket, .cm-nonmatchingBracket":{backgroundColor:"var(--code-selection)",outline:"1px solid var(--border-strong)"},".cm-searchMatch":{backgroundColor:"var(--warn-soft)",outline:"1px solid var(--warn)"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"var(--accent-soft)",outline:"1px solid var(--accent)"},".cm-panels":{backgroundColor:"var(--surface-2)",color:"var(--text)",borderColor:"var(--border)",fontFamily:"var(--font)"},".cm-panels-top":{borderBottom:"1px solid var(--border)"},".cm-panel.cm-search":{padding:"0.5rem 2rem 0.5rem 0.5rem"},".cm-panel.cm-search input, .cm-panel.cm-search button, .cm-panel.cm-search label":{fontSize:"0.875rem"},".cm-panel.cm-search input[type=text]":{backgroundColor:"var(--surface)",color:"var(--text)",border:"1px solid var(--control-border)",borderRadius:"var(--radius-sm)",padding:"0.25rem 0.5rem"},".cm-panel.cm-search button":{backgroundColor:"var(--surface-3)",color:"var(--text)",border:"1px solid var(--border-strong)",borderRadius:"var(--radius-sm)",backgroundImage:"none",padding:"0.25rem 0.625rem"},".cm-panel.cm-search [name=close]":{color:"var(--muted)"}}),Nr=Xn.define([{tag:[i.keyword,i.modifier,i.operatorKeyword,i.controlKeyword],color:"var(--code-keyword)"},{tag:[i.string,i.regexp,i.special(i.string),i.inserted],color:"var(--code-string)"},{tag:[i.number,i.bool,i.null,i.atom,i.literal],color:"var(--code-number)"},{tag:[i.comment,i.lineComment,i.blockComment,i.docComment],color:"var(--code-comment)",fontStyle:"italic"},{tag:[i.typeName,i.className,i.namespace,i.tagName,i.standard(i.tagName)],color:"var(--code-type)"},{tag:[i.function(i.variableName),i.function(i.propertyName),i.definition(i.variableName),i.labelName],color:"var(--code-function)"},{tag:[i.meta,i.processingInstruction,i.annotation,i.attributeName,i.propertyName,i.heading],color:"var(--code-meta)"},{tag:i.heading,fontWeight:"bold"},{tag:i.strong,fontWeight:"bold"},{tag:i.emphasis,fontStyle:"italic"},{tag:i.strikethrough,textDecoration:"line-through"},{tag:i.link,color:"var(--code-function)",textDecoration:"underline"},{tag:i.url,color:"var(--code-function)"},{tag:i.invalid,color:"var(--danger)"},{tag:i.deleted,color:"var(--danger)"}]),en=[Pr,jo(Nr)];var qr={typescript:()=>(p("r5npc6zf"),import("./chunk-lang-typescript-r5npc6zf.js")),javascript:()=>(p("bk2s6a56"),import("./chunk-lang-javascript-bk2s6a56.js")),json:()=>(p("4pe1fv7e"),import("./chunk-lang-json-4pe1fv7e.js")),markdown:()=>(p("67cm3tjx"),import("./chunk-lang-markdown-67cm3tjx.js")),css:()=>(p("rwkzd784"),import("./chunk-lang-css-rwkzd784.js")),html:()=>(p("zhngbs9v"),import("./chunk-lang-html-zhngbs9v.js")),python:()=>(p("mnfhcvww"),import("./chunk-lang-python-mnfhcvww.js")),yaml:()=>(p("vw22drt8"),import("./chunk-lang-yaml-vw22drt8.js")),go:()=>(p("kbcbn346"),import("./chunk-lang-go-kbcbn346.js")),rust:()=>(p("e4a9s76x"),import("./chunk-lang-rust-e4a9s76x.js")),sql:()=>(p("28364npv"),import("./chunk-lang-sql-28364npv.js")),xml:()=>(p("2hv5xc8n"),import("./chunk-lang-xml-2hv5xc8n.js")),shell:()=>(p("43nea8tq"),import("./chunk-lang-shell-43nea8tq.js")),toml:()=>(p("a83hr7bw"),import("./chunk-lang-toml-a83hr7bw.js")),dockerfile:()=>(p("e87ssppx"),import("./chunk-lang-dockerfile-e87ssppx.js"))};async function tn(e){if(e==="plain")return;try{return(await qr[e]()).language()}catch(t){console.warn("a language for the editor failed to load",t);return}}function Vr(e){if(typeof e.attachShadow!=="function"||typeof CSSStyleSheet>"u"||!("adoptedStyleSheets"in Document.prototype))return{parent:e,root:void 0};let t=e.shadowRoot??e.attachShadow({mode:"open"}),n=new CSSStyleSheet;return n.replaceSync(":host{display:flex;flex-direction:column;min-height:0}.cm-editor{flex:1;min-height:0}"),t.adoptedStyleSheets=[...t.adoptedStyleSheets,n],{parent:t,root:t}}async function ao(e){let t=new qt,n=new qt,r=new qt,o=await tn(e.language),l=(f)=>[q.readOnly.of(!f),b.editable.of(f)],s={editable:e.editable,wrap:e.wrap,language:o??[]},c,a=(f)=>[Zo(),Bo(),Wo(),et(),qo(),Ko(),Jt(),$t({top:!0}),it.of(" "),q.phrases.of(e.phrases),en,Tt.of([{key:"Mod-s",preventDefault:!0,run:()=>(e.onSave(),!0)},{key:"Escape",run:()=>(e.onEscape(),!0)},Pt,...Yt,...rt,...It]),q.lineSeparator.of(f),t.of(l(s.editable)),n.of(s.wrap?b.lineWrapping:[]),r.of(s.language),b.updateListener.of((m)=>{if(m.docChanged)e.onChange()})],h=Vr(e.parent),u=new b({parent:h.parent,root:h.root,state:q.create({doc:e.text,extensions:a(e.eol)})});return c=u.state.doc,{text:()=>u.state.doc.sliceString(0,void 0,u.state.lineBreak),dirty:()=>c===void 0||!u.state.doc.eq(c),snapshot:()=>u.state.doc,markSaved:(f)=>{c=f??u.state.doc},replace:(f,m)=>{let L=u.scrollDOM.scrollTop;u.setState(q.create({doc:f,extensions:a(m)})),c=u.state.doc,u.scrollDOM.scrollTop=L},setEditable:(f)=>{s.editable=f,u.dispatch({effects:t.reconfigure(l(f))})},setWrap:(f)=>{s.wrap=f,u.dispatch({effects:n.reconfigure(f?b.lineWrapping:[])})},setLanguage:async(f)=>{s.language=await tn(f)??[],u.dispatch({effects:r.reconfigure(s.language)})},undo:()=>{j(u)},redo:()=>{V(u)},find:()=>{de(u)},tab:()=>{te(u)},focus:()=>u.focus(),scrollTop:()=>u.scrollDOM.scrollTop,scrollTo:(f)=>{u.scrollDOM.scrollTop=f},destroy:()=>u.destroy()}}export{ao as createEditor};
|
|
1
|
+
import{G,be,Yi,Bo,Hi,mt,ve,d,w,Le,Fe,qt,Ge,W,le,ce,q,xt,St,Ze,xe,z,se,De,v,Tt,Fo,Go,Zo,ji,hi,Wo,Yo,Ho,jo,M,i,I,rt,Gt,gi,Ir,zn,In,es,ts,Ot}from"./chunk-index-ne8v2rxx.js";import{p}from"./chunk-index-rvatmx8s.js";var nn=(e)=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=Ce(e.state,n.from);return r.line?rn(e):r.block?ln(e):!1};function ke(e,t){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let o=e(t,n);if(!o)return!1;return r(n.update(o)),!0}}var rn=ke(an,0);var on=ke(je,0);var ln=ke((e,t)=>je(e,t,cn(t)),0);function Ce(e,t){let n=e.languageDataAt("commentTokens",t,1);return n.length?n[0]:{}}var V=50;function sn(e,{open:t,close:n},r,o){let l=e.sliceDoc(r-V,r),s=e.sliceDoc(o,o+V),c=/\s*$/.exec(l)[0].length,a=/^\s*/.exec(s)[0].length,h=l.length-c;if(l.slice(h-t.length,h)==t&&s.slice(a,a+n.length)==n)return{open:{pos:r-c,margin:c&&1},close:{pos:o+a,margin:a&&1}};let u,f;if(o-r<=2*V)u=f=e.sliceDoc(r,o);else u=e.sliceDoc(r,r+V),f=e.sliceDoc(o-V,o);let m=/^\s*/.exec(u)[0].length,B=/\s*$/.exec(f)[0].length,b=f.length-B-n.length;if(u.slice(m,m+t.length)==t&&f.slice(b,b+n.length)==n)return{open:{pos:r+m+t.length,margin:/\s/.test(u.charAt(m+t.length))?1:0},close:{pos:o-B-n.length,margin:/\s/.test(f.charAt(b-1))?1:0}};return null}function cn(e){let t=[];for(let n of e.selection.ranges){let r=e.doc.lineAt(n.from),o=n.to<=r.to?r:e.doc.lineAt(n.to);if(o.from>r.from&&o.from==n.to)o=n.to==r.to+1?r:e.doc.lineAt(n.to-1);let l=t.length-1;if(l>=0&&t[l].to>r.from)t[l].to=o.to;else t.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:o.to})}return t}function je(e,t,n=t.selection.ranges){let r=n.map((l)=>Ce(t,l.from).block);if(!r.every((l)=>l))return null;let o=n.map((l,s)=>sn(t,r[s],l.from,l.to));if(e!=2&&!o.every((l)=>l))return{changes:t.changes(n.map((l,s)=>{if(o[s])return[];return[{from:l.from,insert:r[s].open+" "},{from:l.to,insert:" "+r[s].close}]}))};else if(e!=1&&o.some((l)=>l)){let l=[];for(let s=0,c;s<o.length;s++)if(c=o[s]){let a=r[s],{open:h,close:u}=c;l.push({from:h.pos-a.open.length,to:h.pos+h.margin},{from:u.pos-u.margin,to:u.pos+a.close.length})}return{changes:l}}return null}function an(e,t,n=t.selection.ranges){let r=[],o=-1;e:for(let{from:l,to:s}of n){let c=r.length,a=1e9,h;for(let u=l;u<=s;){let f=t.doc.lineAt(u);if(h==null){if(h=Ce(t,f.from).line,!h)continue e}if(f.from>o&&(l==s||s>f.from)){o=f.from;let m=/^\s*/.exec(f.text)[0].length,B=m==f.length,b=f.text.slice(m,m+h.length)==h?m:-1;if(m<f.text.length&&m<a)a=m;r.push({line:f,comment:b,token:h,indent:m,empty:B,single:!1})}u=f.to+1}if(a<1e9){for(let u=c;u<r.length;u++)if(r[u].indent<r[u].line.text.length)r[u].indent=a}if(r.length==c+1)r[c].single=!0}if(e!=2&&r.some((l)=>l.comment<0&&(!l.empty||l.single))){let l=[];for(let{line:c,token:a,indent:h,empty:u,single:f}of r)if(f||!u)l.push({from:c.from+h,insert:a+" "});let s=t.changes(l);return{changes:s,selection:t.selection.map(s,1)}}else if(e!=1&&r.some((l)=>l.comment>=0)){let l=[];for(let{line:s,comment:c,token:a}of r)if(c>=0){let h=s.from+c,u=h+a.length;if(s.text[u-s.from]==" ")u++;l.push({from:h,to:u})}return{changes:l}}return null}var ge=Ge.define(),un=Ge.define(),hn=w.define(),Xe=w.define({combine(e){return xt(e,{minDepth:100,newGroupDelay:500,joinToEvent:(t,n)=>n},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(t,n)=>(r,o)=>t(r,o)||n(r,o)})}}),Ye=Le.define({create(){return L.empty},update(e,t){let n=t.state.facet(Xe),r=t.annotation(ge);if(r){let a=y.fromTransaction(t,r.selection),h=r.side,u=h==0?e.undone:e.done;if(a)u=Q(u,u.length,n.minDepth,a);else u=nt(u,t.startState.selection);return new L(h==0?r.rest:u,h==0?u:r.rest)}let o=t.annotation(un);if(o=="full"||o=="before")e=e.isolate();if(t.annotation(le.addToHistory)===!1)return!t.changes.empty?e.addMapping(t.changes.desc):e;let l=y.fromTransaction(t),s=t.annotation(le.time),c=t.annotation(le.userEvent);if(l)e=e.addChanges(l,s,c,n,t);else if(t.selection)e=e.addSelection(t.startState.selection,s,c,n.newGroupDelay);if(o=="full"||o=="after")e=e.isolate();return e},toJSON(e){return{done:e.done.map((t)=>t.toJSON()),undone:e.undone.map((t)=>t.toJSON())}},fromJSON(e){return new L(e.done.map(y.fromJSON),e.undone.map(y.fromJSON))}});function et(e={}){return[Ye,Xe.of(e),v.domEventHandlers({beforeinput(t,n){let r=t.inputType=="historyUndo"?X:t.inputType=="historyRedo"?U:null;if(!r)return!1;return t.preventDefault(),r(n)}})]}function j(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let o=n.field(Ye,!1);if(!o)return!1;let l=o.pop(e,n,t);if(!l)return!1;return r(l),!0}}var X=j(0,!1),U=j(1,!1),fn=j(0,!0),dn=j(1,!0);class y{constructor(e,t,n,r,o){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=r,this.selectionsAfter=o}setSelAfter(e){return new y(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,n;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(t=this.mapped)===null||t===void 0?void 0:t.toJSON(),startSelection:(n=this.startSelection)===null||n===void 0?void 0:n.toJSON(),selectionsAfter:this.selectionsAfter.map((r)=>r.toJSON())}}static fromJSON(e){return new y(e.changes&&ve.fromJSON(e.changes),[],e.mapped&&mt.fromJSON(e.mapped),e.startSelection&&d.fromJSON(e.startSelection),e.selectionsAfter.map(d.fromJSON))}static fromTransaction(e,t){let n=S;for(let r of e.startState.facet(hn)){let o=r(e);if(o.length)n=n.concat(o)}if(!n.length&&e.changes.empty)return null;return new y(e.changes.invert(e.startState.doc),n,void 0,t||e.startState.selection,S)}static selection(e){return new y(void 0,S,void 0,void 0,e)}}function Q(e,t,n,r){let o=t+1>n+20?t-n-1:0,l=e.slice(o,t);return l.push(r),l}function mn(e,t){let n=[],r=!1;return e.iterChangedRanges((o,l)=>n.push(o,l)),t.iterChangedRanges((o,l,s,c)=>{for(let a=0;a<n.length;){let h=n[a++],u=n[a++];if(c>=h&&s<=u)r=!0}}),r}function pn(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((n,r)=>n.empty!=t.ranges[r].empty).length===0}function tt(e,t){return!e.length?t:!t.length?e:e.concat(t)}var S=[],gn=200;function nt(e,t){if(!e.length)return[y.selection([t])];else{let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-gn));if(r.length&&r[r.length-1].eq(t))return e;return r.push(t),Q(e,e.length-1,1e9,n.setSelAfter(r))}}function yn(e){let t=e[e.length-1],n=e.slice();return n[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),n}function pe(e,t){if(!e.length)return e;let n=e.length,r=S;while(n){let o=xn(e[n-1],t,r);if(o.changes&&!o.changes.empty||o.effects.length){let l=e.slice(0,n);return l[n-1]=o,l}else t=o.mapped,n--,r=o.selectionsAfter}return r.length?[y.selection(r)]:S}function xn(e,t,n){let r=tt(e.selectionsAfter.length?e.selectionsAfter.map((c)=>c.map(t)):S,n);if(!e.changes)return y.selection(r);let o=e.changes.map(t),l=t.mapDesc(e.changes,!0),s=e.mapped?e.mapped.composeDesc(l):l;return new y(o,W.mapEffects(e.effects,t),s,e.startSelection.map(l),r)}var Sn=/^(input\.type|delete)($|\.)/;class L{constructor(e,t,n=0,r=void 0){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=r}isolate(){return this.prevTime?new L(this.done,this.undone):this}addChanges(e,t,n,r,o){let l=this.done,s=l[l.length-1];if(s&&s.changes&&!s.changes.empty&&e.changes&&(!n||Sn.test(n))&&(!s.selectionsAfter.length&&t-this.prevTime<r.newGroupDelay&&r.joinToEvent(o,mn(s.changes,e.changes))||n=="input.type.compose"))l=Q(l,l.length-1,r.minDepth,new y(e.changes.compose(s.changes),tt(W.mapEffects(e.effects,s.changes),s.effects),s.mapped,s.startSelection,S));else l=Q(l,l.length,r.minDepth,e);return new L(l,S,t,n)}addSelection(e,t,n,r){let o=this.done.length?this.done[this.done.length-1].selectionsAfter:S;if(o.length>0&&t-this.prevTime<r&&n==this.prevUserEvent&&n&&/^select($|\.)/.test(n)&&pn(o[o.length-1],e))return this;return new L(nt(this.done,e),this.undone,t,n)}addMapping(e){return new L(pe(this.done,e),pe(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,t,n){let r=e==0?this.done:this.undone;if(r.length==0)return null;let o=r[r.length-1],l=o.selectionsAfter[0]||(o.startSelection?o.startSelection.map(o.changes.invertedDesc,1):t.selection);if(n&&o.selectionsAfter.length)return t.update({selection:o.selectionsAfter[o.selectionsAfter.length-1],annotations:ge.of({side:e,rest:yn(r),selection:l}),userEvent:e==0?"select.undo":"select.redo",scrollIntoView:!0});else if(!o.changes)return null;else{let s=r.length==1?S:r.slice(0,r.length-1);if(o.mapped)s=pe(s,o.mapped);return t.update({changes:o.changes,selection:o.startSelection,effects:o.effects,annotations:ge.of({side:e,rest:s,selection:l}),filter:!1,userEvent:e==0?"undo":"redo",scrollIntoView:!0})}}}L.empty=new L(S,S);var ot=[{key:"Mod-z",run:X,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:U,preventDefault:!0},{linux:"Ctrl-Shift-z",run:U,preventDefault:!0},{key:"Mod-u",run:fn,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:dn,preventDefault:!0}];function O(e,t){return d.create(e.ranges.map(t),e.mainIndex)}function C(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:"select"})}function A({state:e,dispatch:t},n){let r=O(e.selection,n);if(r.eq(e.selection,!0))return!1;return t(C(e,r)),!0}function Y(e,t){return d.cursor(t?e.to:e.from)}function lt(e,t){return A(e,(n)=>n.empty?e.moveByChar(n,t):Y(n,t))}function g(e){return e.textDirectionAt(e.state.selection.main.head)==se.LTR}var it=(e)=>lt(e,!g(e)),st=(e)=>lt(e,g(e));function ct(e,t){return A(e,(n)=>n.empty?e.moveByGroup(n,t):Y(n,t))}var kn=(e)=>ct(e,!g(e)),vn=(e)=>ct(e,g(e));var Jr=typeof Intl<"u"&&Intl.Segmenter?new Intl.Segmenter(void 0,{granularity:"word"}):null;function bn(e,t,n){if(t.type.prop(n))return!0;let r=t.to-t.from;return r&&(r>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function Z(e,t,n){let r=I(e).resolveInner(t.head),o=n?M.closedBy:M.openedBy;for(let a=t.head;;){let h=n?r.childAfter(a):r.childBefore(a);if(!h)break;if(bn(e,h,o))r=h;else a=n?h.to:h.from}let l=r.type.prop(o),s,c;if(l&&(s=n?Ot(e,r.from,1):Ot(e,r.to,-1))&&s.matched)c=n?s.end.to:s.end.from;else c=n?r.to:r.from;return d.cursor(c,n?-1:1)}var Cn=(e)=>A(e,(t)=>Z(e.state,t,!g(e))),Mn=(e)=>A(e,(t)=>Z(e.state,t,g(e)));function at(e,t){return A(e,(n)=>{if(!n.empty)return Y(n,t);let r=e.moveVertically(n,t);return r.head!=n.head?r:e.moveToLineBoundary(n,t)})}var ut=(e)=>at(e,!1),ht=(e)=>at(e,!0);function ft(e){let t=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,n=0,r=0,o;if(t){for(let l of e.state.facet(v.scrollMargins)){let s=l(e);if(s===null||s===void 0?void 0:s.top)n=Math.max(s===null||s===void 0?void 0:s.top,n);if(s===null||s===void 0?void 0:s.bottom)r=Math.max(s===null||s===void 0?void 0:s.bottom,r)}o=e.scrollDOM.clientHeight-n-r}else o=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:r,selfScroll:t,height:Math.max(e.defaultLineHeight,o-5)}}function dt(e,t){let n=ft(e),{state:r}=e,o=O(r.selection,(s)=>s.empty?e.moveVertically(s,t,n.height):Y(s,t));if(o.eq(r.selection))return!1;let l;if(n.selfScroll){let s=e.coordsAtPos(r.selection.main.head),c=e.scrollDOM.getBoundingClientRect(),a=c.top+n.marginTop,h=c.bottom-n.marginBottom;if(s&&s.top>a&&s.bottom<h)l=v.scrollIntoView(o.main.head,{y:"start",yMargin:s.top-a})}return e.dispatch(C(r,o),{effects:l}),!0}var Ue=(e)=>dt(e,!1),ye=(e)=>dt(e,!0);function D(e,t,n){let r=e.lineBlockAt(t.head),o=e.moveToLineBoundary(t,n);if(o.head==t.head&&o.head!=(n?r.to:r.from))o=e.moveToLineBoundary(t,n,!1);if(!n&&o.head==r.from&&r.length){let l=/^\s*/.exec(e.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;if(l&&t.head!=r.from+l)o=d.cursor(r.from+l)}return o}var An=(e)=>A(e,(t)=>D(e,t,!0)),Ln=(e)=>A(e,(t)=>D(e,t,!1)),Bn=(e)=>A(e,(t)=>D(e,t,!g(e))),Dn=(e)=>A(e,(t)=>D(e,t,g(e))),En=(e)=>A(e,(t)=>e.moveToLineBoundary(t,!1,!1)),Tn=(e)=>A(e,(t)=>e.moveToLineBoundary(t,!0,!1));function wn(e,t,n){let r=!1,o=O(e.selection,(l)=>{let s=Ot(e,l.head,-1)||Ot(e,l.head,1)||l.head>0&&Ot(e,l.head-1,1)||l.head<e.doc.length&&Ot(e,l.head+1,-1);if(!s||!s.end)return l;r=!0;let c=s.start.from==l.head?s.end.to:s.end.from;return n?d.range(l.anchor,c):d.cursor(c)});if(!r)return!1;return t(C(e,o)),!0}var Wn=({state:e,dispatch:t})=>wn(e,t,!1);function k(e,t,n){let r=O(e.state.selection,(o)=>{if(o.undirectional&&o.head>=o.anchor!=t)o=d.range(o.head,o.anchor);let l=n(o);return d.range(o.anchor,l.head,l.goalColumn,l.bidiLevel||void 0,l.assoc)});if(r.eq(e.state.selection))return!1;return e.dispatch(C(e.state,r)),!0}function pt(e,t){return k(e,t,(n)=>e.moveByChar(n,t))}var gt=(e)=>pt(e,!g(e)),yt=(e)=>pt(e,g(e));function kt(e,t){return k(e,t,(n)=>e.moveByGroup(n,t))}var Rn=(e)=>kt(e,!g(e)),On=(e)=>kt(e,g(e));var Fn=(e)=>{let t=!g(e);return k(e,t,(n)=>Z(e.state,n,t))},Pn=(e)=>{let t=g(e);return k(e,t,(n)=>Z(e.state,n,t))};function vt(e,t){return k(e,t,(n)=>e.moveVertically(n,t))}var bt=(e)=>vt(e,!1),Ct=(e)=>vt(e,!0);function Mt(e,t){return k(e,t,(n)=>e.moveVertically(n,t,ft(e).height))}var ze=(e)=>Mt(e,!1),_e=(e)=>Mt(e,!0),Nn=(e)=>k(e,!0,(t)=>D(e,t,!0)),qn=(e)=>k(e,!1,(t)=>D(e,t,!1)),Vn=(e)=>{let t=!g(e);return k(e,t,(n)=>D(e,n,t))},Gn=(e)=>{let t=g(e);return k(e,t,(n)=>D(e,n,t))},Un=(e)=>k(e,!1,(t)=>d.cursor(e.lineBlockAt(t.head).from)),_n=(e)=>k(e,!0,(t)=>d.cursor(e.lineBlockAt(t.head).to)),Je=({state:e,dispatch:t})=>(t(C(e,{anchor:0})),!0),$e=({state:e,dispatch:t})=>(t(C(e,{anchor:e.doc.length})),!0),Ke=({state:e,dispatch:t})=>(t(C(e,{anchor:e.selection.main.anchor,head:0})),!0),He=({state:e,dispatch:t})=>(t(C(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),Jn=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:"select"})),!0),$n=({state:e,dispatch:t})=>{let n=ee(e).map(({from:r,to:o})=>d.undirectionalRange(r,Math.min(o+1,e.doc.length)));return t(e.update({selection:d.create(n),userEvent:"select"})),!0},Kn=({state:e,dispatch:t})=>{let n=O(e.selection,(r)=>{let o=I(e),l=o.resolveStack(r.from,1);if(r.empty){let s=o.resolveStack(r.from,-1);if(s.node.from>=l.node.from&&s.node.to<=l.node.to)l=s}for(let s=l;s;s=s.next){let{node:c}=s;if((c.from<r.from&&c.to>=r.to||c.to>r.to&&c.from<=r.from)&&s.next)return d.undirectionalRange(c.from,c.to)}return r});if(n.eq(e.selection))return!1;return t(C(e,n)),!0};function At(e,t){let{state:n}=e,r=n.selection,o=n.selection.ranges.slice();for(let l of n.selection.ranges){let s=n.doc.lineAt(l.head);if(t?s.to<e.state.doc.length:s.from>0)for(let c=l;;){let a=e.moveVertically(c,t);if(a.head<s.from||a.head>s.to){if(!o.some((h)=>h.head==a.head))o.push(a);break}else if(a.head==c.head)break;else c=a}}if(o.length==r.ranges.length)return!1;return e.dispatch(C(n,d.create(o,o.length-1))),!0}var Hn=(e)=>At(e,!1),Qn=(e)=>At(e,!0),jn=({state:e,dispatch:t})=>{let n=e.selection,r=null;if(n.ranges.length>1)r=d.create([n.main]);else if(!n.main.empty)r=d.create([d.cursor(n.main.head)]);if(!r)return!1;return t(C(e,r)),!0};function _(e,t){if(e.state.readOnly)return!1;let n="delete.selection",{state:r}=e,o=r.changeByRange((l)=>{let{from:s,to:c}=l;if(s==c){let a=t(l);if(a<s)n="delete.backward",a=H(e,a,!1);else if(a>s)n="delete.forward",a=H(e,a,!0);s=Math.min(s,a),c=Math.max(c,a)}else s=H(e,s,!1),c=H(e,c,!0);return s==c?{range:l}:{changes:{from:s,to:c},range:d.cursor(s,s<l.head?-1:1)}});if(o.changes.empty)return!1;return e.dispatch(r.update(o,{scrollIntoView:!0,userEvent:n,effects:n=="delete.selection"?v.announce.of(r.phrase("Selection deleted")):void 0})),!0}function H(e,t,n){if(e instanceof v)for(let r of e.state.facet(v.atomicRanges).map((o)=>o(e)))r.between(t,t,(o,l)=>{if(o<t&&l>t)t=n?l:o});return t}var Lt=(e,t,n)=>_(e,(r)=>{let o=r.from,{state:l}=e,s=l.doc.lineAt(o),c,a;if(n&&!t&&o>s.from&&o<s.from+200&&!/[^ \t]/.test(c=s.text.slice(0,o-s.from))){if(c[c.length-1]=="\t")return o-1;let h=Ze(c,l.tabSize),u=h%Gt(l)||Gt(l);for(let f=0;f<u&&c[c.length-1-f]==" ";f++)o--;a=o}else if(a=be(s.text,o-s.from,t,t)+s.from,a==o&&s.number!=(t?l.doc.lines:1))a+=t?1:-1;else if(!t&&/[\ufe00-\ufe0f]/.test(s.text.slice(a-s.from,o-s.from)))a=be(s.text,a-s.from,!1,!1)+s.from;return a}),Se=(e)=>Lt(e,!1,!0);var Bt=(e)=>Lt(e,!0,!1),Dt=(e,t)=>_(e,(n)=>{let r=n.head,{state:o}=e,l=o.doc.lineAt(r),s=o.charCategorizer(r);for(let c=null;;){if(r==(t?l.to:l.from)){if(r==n.head&&l.number!=(t?o.doc.lines:1))r+=t?1:-1;break}let a=be(l.text,r-l.from,t)+l.from,h=l.text.slice(Math.min(r,a)-l.from,Math.max(r,a)-l.from),u=s(h);if(c!=null&&u!=c)break;if(h!=" "||r!=n.head)c=u;r=a}return r}),Et=(e)=>Dt(e,!1),Xn=(e)=>Dt(e,!0);var Yn=(e)=>_(e,(t)=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)});var Zn=(e)=>_(e,(t)=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),er=(e)=>_(e,(t)=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)});var tr=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange((r)=>({changes:{from:r.from,to:r.to,insert:G.of(["",""])},range:d.cursor(r.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:"input"})),!0},nr=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange((r)=>{if(!r.empty||r.from==0||r.from==e.doc.length)return{range:r};let o=r.from,l=e.doc.lineAt(o),s=o==l.from?o-1:be(l.text,o-l.from,!1)+l.from,c=o==l.to?o+1:be(l.text,o-l.from,!0)+l.from;return{changes:{from:s,to:c,insert:e.doc.slice(o,c).append(e.doc.slice(s,o))},range:d.cursor(c)}});if(n.changes.empty)return!1;return t(e.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0};function ee(e){let t=[],n=-1;for(let r of e.selection.ranges){let o=e.doc.lineAt(r.from),l=e.doc.lineAt(r.to);if(!r.empty&&r.to==l.from)l=e.doc.lineAt(r.to-1);if(n>=o.number){let s=t[t.length-1];s.to=l.to,s.ranges.push(r)}else t.push({from:o.from,to:l.to,ranges:[r]});n=l.number+1}return t}function wt(e,t,n){if(e.readOnly)return!1;let r=[],o=[];for(let l of ee(e)){if(n?l.to==e.doc.length:l.from==0)continue;let s=e.doc.lineAt(n?l.to+1:l.from-1),c=s.length+1;if(n){r.push({from:l.to,to:s.to},{from:l.from,insert:s.text+e.lineBreak});for(let a of l.ranges)o.push(d.range(Math.min(e.doc.length,a.anchor+c),Math.min(e.doc.length,a.head+c)))}else{r.push({from:s.from,to:l.from},{from:l.to,insert:e.lineBreak+s.text});for(let a of l.ranges)o.push(d.range(a.anchor-c,a.head-c))}}if(!r.length)return!1;return t(e.update({changes:r,scrollIntoView:!0,selection:d.create(o,e.selection.mainIndex),userEvent:"move.line"})),!0}var rr=({state:e,dispatch:t})=>wt(e,t,!1),or=({state:e,dispatch:t})=>wt(e,t,!0);function Wt(e,t,n){if(e.readOnly)return!1;let r=[];for(let l of ee(e))if(n)r.push({from:l.from,insert:e.doc.slice(l.from,l.to)+e.lineBreak});else r.push({from:l.to,insert:e.lineBreak+e.doc.slice(l.from,l.to)});let o=e.changes(r);return t(e.update({changes:o,selection:e.selection.map(o,n?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}var lr=({state:e,dispatch:t})=>Wt(e,t,!1),ir=({state:e,dispatch:t})=>Wt(e,t,!0),sr=(e)=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(ee(t).map(({from:o,to:l})=>{if(o>0)o--;else if(l<t.doc.length)l++;return{from:o,to:l}})),r=O(t.selection,(o)=>{let l=void 0;if(e.lineWrapping){let s=e.lineBlockAt(o.head),c=e.coordsAtPos(o.head,o.assoc||1);if(c)l=s.bottom+e.documentTop-c.bottom+e.defaultLineHeight/2}return e.moveVertically(o,!0,l)}).map(n);return e.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:"delete.line"}),!0};function cr(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=I(e).resolveInner(t),r=n.childBefore(t),o=n.childAfter(t),l;if(r&&o&&r.to<=t&&o.from>=t&&(l=r.type.prop(M.closedBy))&&l.indexOf(o.name)>-1&&e.doc.lineAt(r.to).from==e.doc.lineAt(o.from).from&&!/\S/.test(e.sliceDoc(r.to,o.from)))return{from:r.to,to:o.from};return null}var Qe=Rt(!1),ar=Rt(!0);function Rt(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=t.changeByRange((o)=>{let{from:l,to:s}=o,c=t.doc.lineAt(l),a=!e&&l==s&&cr(t,l);if(e)l=s=(s<=c.to?c:t.doc.lineAt(s)).to;let h=new zn(t,{simulateBreak:l,simulateDoubleBreak:!!a}),u=Ir(h,l);if(u==null)u=Ze(/^\s*/.exec(t.doc.lineAt(l).text)[0],t.tabSize);while(s<c.to&&/\s/.test(c.text[s-c.from]))s++;if(a)({from:l,to:s}=a);else if(l>c.from&&l<c.from+100&&!/\S/.test(c.text.slice(0,l)))l=c.from;let f=["",gi(t,u)];if(a)f.push(gi(t,h.lineIndent(c.from,-1)));return{changes:{from:l,to:s,insert:G.of(f)},range:d.cursor(l+1+f[1].length)}});return n(t.update(r,{scrollIntoView:!0,userEvent:"input"})),!0}}function Me(e,t){let n=-1;return e.changeByRange((r)=>{let o=[];for(let s=r.from;s<=r.to;){let c=e.doc.lineAt(s);if(c.number>n&&(r.empty||r.to>c.from))t(c,o,r),n=c.number;s=c.to+1}let l=e.changes(o);return{changes:o,range:d.range(l.mapPos(r.anchor,1),l.mapPos(r.head,1))}})}var ur=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new zn(e,{overrideIndentation:(l)=>{let s=n[l];return s==null?-1:s}}),o=Me(e,(l,s,c)=>{let a=Ir(r,l.from);if(a==null)return;if(!/\S/.test(l.text))a=0;let h=/^\s*/.exec(l.text)[0],u=gi(e,a);if(h!=u||c.from<l.from+h.length)n[l.from]=a,s.push({from:l.from,to:l.from+h.length,insert:u})});if(!o.changes.empty)t(e.update(o,{userEvent:"indent"}));return!0},te=({state:e,dispatch:t})=>{if(e.readOnly)return!1;return t(e.update(Me(e,(n,r)=>{r.push({from:n.from,insert:e.facet(rt)})}),{userEvent:"input.indent"})),!0},Ft=({state:e,dispatch:t})=>{if(e.readOnly)return!1;return t(e.update(Me(e,(n,r)=>{let o=/^\s*/.exec(n.text)[0];if(!o)return;let l=Ze(o,e.tabSize),s=0,c=gi(e,Math.max(0,l-Gt(e)));while(s<o.length&&s<c.length&&o.charCodeAt(s)==c.charCodeAt(s))s++;r.push({from:n.from+s,to:n.from+o.length,insert:c.slice(s)})}),{userEvent:"delete.dedent"})),!0},hr=(e)=>(e.setTabFocusMode(),!0);var fr=[{key:"Ctrl-b",run:it,shift:gt,preventDefault:!0},{key:"Ctrl-f",run:st,shift:yt},{key:"Ctrl-p",run:ut,shift:bt},{key:"Ctrl-n",run:ht,shift:Ct},{key:"Ctrl-a",run:En,shift:Un},{key:"Ctrl-e",run:Tn,shift:_n},{key:"Ctrl-d",run:Bt},{key:"Ctrl-h",run:Se},{key:"Ctrl-k",run:Yn},{key:"Ctrl-Alt-h",run:Et},{key:"Ctrl-o",run:tr},{key:"Ctrl-t",run:nr},{key:"Ctrl-v",run:ye}],dr=[{key:"ArrowLeft",run:it,shift:gt,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:kn,shift:Rn,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:Bn,shift:Vn,preventDefault:!0},{key:"ArrowRight",run:st,shift:yt,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:vn,shift:On,preventDefault:!0},{mac:"Cmd-ArrowRight",run:Dn,shift:Gn,preventDefault:!0},{key:"ArrowUp",run:ut,shift:bt,preventDefault:!0},{mac:"Cmd-ArrowUp",run:Je,shift:Ke},{mac:"Ctrl-ArrowUp",run:Ue,shift:ze},{key:"ArrowDown",run:ht,shift:Ct,preventDefault:!0},{mac:"Cmd-ArrowDown",run:$e,shift:He},{mac:"Ctrl-ArrowDown",run:ye,shift:_e},{key:"PageUp",run:Ue,shift:ze},{key:"PageDown",run:ye,shift:_e},{key:"Home",run:Ln,shift:qn,preventDefault:!0},{key:"Mod-Home",run:Je,shift:Ke},{key:"End",run:An,shift:Nn,preventDefault:!0},{key:"Mod-End",run:$e,shift:He},{key:"Enter",run:Qe,shift:Qe},{key:"Mod-a",run:Jn},{key:"Backspace",run:Se,shift:Se,preventDefault:!0},{key:"Delete",run:Bt,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Et,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:Xn,preventDefault:!0},{mac:"Mod-Backspace",run:Zn,preventDefault:!0},{mac:"Mod-Delete",run:er,preventDefault:!0}].concat(fr.map((e)=>({mac:e.key,run:e.run,shift:e.shift}))),It=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:Cn,shift:Fn},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:Mn,shift:Pn},{key:"Alt-ArrowUp",run:rr},{key:"Shift-Alt-ArrowUp",run:lr},{key:"Alt-ArrowDown",run:or},{key:"Shift-Alt-ArrowDown",run:ir},{key:"Mod-Alt-ArrowUp",run:Hn},{key:"Mod-Alt-ArrowDown",run:Qn},{key:"Escape",run:jn},{key:"Mod-Enter",run:ar},{key:"Alt-l",mac:"Ctrl-l",run:$n},{key:"Mod-i",run:Kn,preventDefault:!0},{key:"Mod-[",run:Ft},{key:"Mod-]",run:te},{key:"Mod-Alt-\\",run:ur},{key:"Shift-Mod-k",run:sr},{key:"Shift-Mod-\\",run:Wn},{key:"Mod-/",run:nn},{key:"Alt-A",mac:"Ctrl-A",run:on},{key:"Ctrl-m",mac:"Shift-Alt-m",run:hr}].concat(dr),Pt={key:"Tab",run:te,shift:Ft};var Nt=typeof String.prototype.normalize=="function"?(e)=>e.normalize("NFKD"):(e)=>e;class T{constructor(e,t,n=0,r=e.length,o,l){this.test=l,this.value={from:0,to:0,precise:!1},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(n,r),this.bufferStart=n,this.normalize=o?(s)=>o(Nt(s)):Nt,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return Yi(this.buffer,this.bufferPos)}next(){while(this.matches.length)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=Bo(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=Hi(e);let r=this.normalize(t);if(r.length)for(let o=0,l=n,s=!0;;o++){let c=r.charCodeAt(o),a=this.match(c,l,s,this.bufferPos+this.bufferStart,o==r.length-1);if(a)return this.value=a,this;if(o==r.length-1)break;if(s&&o<t.length&&t.charCodeAt(o)==c)l++;else s=!1}}}match(e,t,n,r,o){let l=null;for(let s=0;s<this.matches.length;){let c=this.matches[s],a=!1;if(this.query.charCodeAt(c.index)==e)if(c.index==this.query.length-1)l={from:c.from,to:r,precise:o&&c.precise};else c.index++,a=!0;if(a)s++;else this.matches.splice(s,1)}if(this.query.charCodeAt(0)==e)if(this.query.length==1)l={from:t,to:r,precise:n&&o};else this.matches.push({from:t,index:1,precise:n});if(l&&this.test&&!this.test(l.from,l.to,this.buffer,this.bufferStart))l=null;return l}}if(typeof Symbol<"u")T.prototype[Symbol.iterator]=function(){return this};var zt={from:-1,to:-1,match:/.*/.exec(""),precise:!0},Te="gm"+(/x/.unicode==null?"":"u");class we{constructor(e,t,n,r=0,o=e.length){if(this.text=e,this.to=o,this.curLine="",this.done=!1,this.value=zt,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new We(e,t,n,r,o);this.re=new RegExp(t,Te+((n===null||n===void 0?void 0:n.ignoreCase)?"i":"")),this.test=n===null||n===void 0?void 0:n.test,this.iter=e.iter();let l=e.lineAt(r);this.curLineStart=l.from,this.matchPos=ie(e,r),this.getLine(this.curLineStart)}getLine(e){if(this.iter.next(e),this.iter.lineBreak)this.curLine="";else{if(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to)this.curLine=this.curLine.slice(0,this.to-this.curLineStart);this.iter.next()}}nextLine(){if(this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to)this.curLine="";else this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let n=this.curLineStart+t.index,r=n+t[0].length;if(this.matchPos=ie(this.text,r+(n==r?1:0)),n==this.curLineStart+this.curLine.length)this.nextLine();if((n<r||n>this.value.to)&&(!this.test||this.test(n,r,t)))return this.value={from:n,to:r,precise:!0,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}}var Ae=new WeakMap;class N{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(e,t,n){let r=Ae.get(e);if(!r||r.from>=n||r.to<=t){let s=new N(t,e.sliceString(t,n));return Ae.set(e,s),s}if(r.from==t&&r.to==n)return r;let{text:o,from:l}=r;if(l>t)o=e.sliceString(t,l)+o,l=t;if(r.to<n)o+=e.sliceString(r.to,n);return Ae.set(e,new N(l,o)),new N(t,o.slice(t-l,n-l))}}class We{constructor(e,t,n,r,o){this.text=e,this.to=o,this.done=!1,this.value=zt,this.matchPos=ie(e,r),this.re=new RegExp(t,Te+((n===null||n===void 0?void 0:n.ignoreCase)?"i":"")),this.test=n===null||n===void 0?void 0:n.test,this.flat=N.get(e,r,this.chunkEnd(r+5000))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e)this.re.lastIndex=e+1,t=this.re.exec(this.flat.text);if(t){let n=this.flat.from+t.index,r=n+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(n,r,t)))return this.value={from:n,to:r,precise:!0,match:t},this.matchPos=ie(this.text,r+(n==r?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=N.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}if(typeof Symbol<"u")we.prototype[Symbol.iterator]=We.prototype[Symbol.iterator]=function(){return this};function mr(e){try{return new RegExp(e,Te),!0}catch(t){return!1}}function ie(e,t){if(t>=e.length)return t;let n=e.lineAt(t),r;while(t<n.to&&(r=n.text.charCodeAt(t-n.from))>=56320&&r<57344)t++;return t}var pr=(e)=>{let t=Yo(e,"cm-goto-line");if(t){let s=t.dom.querySelector("input[type=text]");if(s)s.select();return!0}let{state:n}=e,r=String(n.doc.lineAt(e.state.selection.main.head).number),{close:o,result:l}=Wo(e,{class:"cm-goto-line",label:n.phrase("Go to line"),input:{type:"text",name:"line",value:r},focus:!0,submitLabel:n.phrase("go")});return l.then((s)=>{let c=s&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(s.elements.line.value);if(!c){e.dispatch({effects:o});return}let a=n.doc.lineAt(n.selection.main.head),[,h,u,f,m]=c,B=f?+f.slice(1):0,b=u?+u:a.number;if(u&&m){let me=b/100;if(h)me=me*(h=="-"?-1:1)+a.number/n.doc.lines;b=Math.round(n.doc.lines*me)}else if(u&&h)b=b*(h=="-"?-1:1)+a.number;let qe=n.doc.line(Math.max(1,Math.min(n.doc.lines,b))),Ve=d.cursor(qe.from+Math.max(0,Math.min(B,qe.length)));e.dispatch({effects:[o,v.scrollIntoView(Ve.from,{y:"center"})],selection:Ve})}),!0},gr={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},_t=w.define({combine(e){return xt(e,gr,{highlightWordAroundCursor:(t,n)=>t||n,minSelectionLength:Math.min,maxMatches:Math.min})}});function Jt(e){let t=[vr,kr];if(e)t.push(_t.of(e));return t}var yr=z.mark({class:"cm-selectionMatch"}),xr=z.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function Vt(e,t,n,r){return(n==0||e(t.sliceDoc(n-1,n))!=ce.Word)&&(r==t.doc.length||e(t.sliceDoc(r,r+1))!=ce.Word)}function Sr(e,t,n,r){return e(t.sliceDoc(n,n+1))==ce.Word&&e(t.sliceDoc(r-1,r))==ce.Word}var kr=De.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){if(e.selectionSet||e.docChanged||e.viewportChanged)this.decorations=this.getDeco(e.view)}getDeco(e){let t=e.state.facet(_t),{state:n}=e,r=n.selection;if(r.ranges.length>1)return z.none;let o=r.main,l,s=null;if(o.empty){if(!t.highlightWordAroundCursor)return z.none;let a=n.wordAt(o.head);if(!a)return z.none;s=n.charCategorizer(o.head),l=n.sliceDoc(a.from,a.to)}else{let a=o.to-o.from;if(a<t.minSelectionLength||a>200)return z.none;if(t.wholeWords){if(l=n.sliceDoc(o.from,o.to),s=n.charCategorizer(o.head),!(Vt(s,n,o.from,o.to)&&Sr(s,n,o.from,o.to)))return z.none}else if(l=n.sliceDoc(o.from,o.to),!l)return z.none}let c=[];for(let a of e.visibleRanges){let h=new T(n.doc,l,a.from,a.to);while(!h.next().done){let{from:u,to:f}=h.value;if(!s||Vt(s,n,u,f)){if(o.empty&&u<=o.from&&f>=o.to)c.push(xr.range(u,f));else if(u>=o.to||f<=o.from)c.push(yr.range(u,f));if(c.length>t.maxMatches)return z.none}}}return z.set(c)}},{decorations:(e)=>e.decorations}),vr=v.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),br=({state:e,dispatch:t})=>{let{selection:n}=e,r=d.create(n.ranges.map((o)=>e.wordAt(o.head)||d.cursor(o.head)),n.mainIndex);if(r.eq(n))return!1;return t(e.update({selection:r})),!0};function Cr(e,t){let{main:n,ranges:r}=e.selection,o=e.wordAt(n.head),l=o&&o.from==n.from&&o.to==n.to;for(let s=!1,c=new T(e.doc,t,r[r.length-1].to);;)if(c.next(),c.done){if(s)return null;c=new T(e.doc,t,0,Math.max(0,r[r.length-1].from-1)),s=!0}else{if(s&&r.some((a)=>a.from==c.value.from))continue;if(l){let a=e.wordAt(c.value.from);if(!a||a.from!=c.value.from||a.to!=c.value.to)continue}return c.value}}var Mr=({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some((l)=>l.from===l.to))return br({state:e,dispatch:t});let r=e.sliceDoc(n[0].from,n[0].to);if(e.selection.ranges.some((l)=>e.sliceDoc(l.from,l.to)!=r))return!1;let o=Cr(e,r);if(!o)return!1;return t(e.update({selection:e.selection.addRange(d.range(o.from,o.to),!1),effects:v.scrollIntoView(o.to)})),!0},R=w.define({combine(e){return xt(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:(t)=>new Zt(t),scrollToMatch:(t)=>v.scrollIntoView(t)})}});function $t(e){return e?[R.of(e),Ee]:Ee}class Re{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||mr(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(t,n)=>n=="n"?`
|
|
2
|
+
`:n=="r"?"\r":n=="t"?"\t":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new Ht(this):new Kt(this)}getCursor(e,t=0,n){let r=e.doc?e:q.create({doc:e});if(n==null)n=r.doc.length;return this.regexp?P(this,r,t,n):F(this,r,t,n)}}class Oe{constructor(e){this.spec=e}}function Ar(e,t,n){return(r,o,l,s)=>{if(n&&!n(r,o,l,s))return!1;let c=r>=s&&o<=s+l.length?l.slice(r-s,o-s):t.doc.sliceString(r,o);return e(c,t,r,o)}}function F(e,t,n,r){let o;if(e.wholeWord)o=Lr(t.doc,t.charCategorizer(t.selection.main.head));if(e.test)o=Ar(e.test,t,o);return new T(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:(l)=>l.toLowerCase(),o)}function Lr(e,t){return(n,r,o,l)=>{if(l>n||l+o.length<r)l=Math.max(0,n-2),o=e.sliceString(l,Math.min(e.length,r+2));return(t(ae(o,n-l))!=ce.Word||t(ue(o,n-l))!=ce.Word)&&(t(ue(o,r-l))!=ce.Word||t(ae(o,r-l))!=ce.Word)}}class Kt extends Oe{constructor(e){super(e)}nextMatch(e,t,n){let r=F(this.spec,e,n,e.doc.length).nextOverlapping();if(r.done){let o=Math.min(e.doc.length,t+this.spec.unquoted.length);r=F(this.spec,e,0,o).nextOverlapping()}return r.done||r.value.from==t&&r.value.to==n?null:r.value}prevMatchInRange(e,t,n){for(let r=n;;){let o=Math.max(t,r-1e4-this.spec.unquoted.length),l=F(this.spec,e,o,r),s=null;while(!l.nextOverlapping().done)s=l.value;if(s)return s;if(o==t)return null;r-=1e4}}prevMatch(e,t,n){let r=this.prevMatchInRange(e,0,t);if(!r)r=this.prevMatchInRange(e,Math.max(0,n-this.spec.unquoted.length),e.doc.length);return r&&(r.from!=t||r.to!=n)?r:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let n=F(this.spec,e,0,e.doc.length),r=[];while(!n.next().done){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let o=F(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));while(!o.next().done)r(o.value.from,o.value.to)}}function Br(e,t,n){return(r,o,l)=>(!n||n(r,o,l))&&e(l[0],t,r,o)}function P(e,t,n,r){let o;if(e.wholeWord)o=Dr(t.charCategorizer(t.selection.main.head));if(e.test)o=Br(e.test,t,o);return new we(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:o},n,r)}function ae(e,t){return e.slice(be(e,t,!1),t)}function ue(e,t){return e.slice(t,be(e,t))}function Dr(e){return(t,n,r)=>!r[0].length||(e(ae(r.input,r.index))!=ce.Word||e(ue(r.input,r.index))!=ce.Word)&&(e(ue(r.input,r.index+r[0].length))!=ce.Word||e(ae(r.input,r.index+r[0].length))!=ce.Word)}class Ht extends Oe{nextMatch(e,t,n){let r=P(this.spec,e,n,e.doc.length).next();if(r.done)r=P(this.spec,e,0,t).next();return r.done?null:r.value}prevMatchInRange(e,t,n){for(let r=1;;r++){let o=Math.max(t,n-r*1e4),l=P(this.spec,e,o,n),s=null;while(!l.next().done)s=l.value;if(s&&(o==t||s.from>o+10))return s;if(o==t)return null}}prevMatch(e,t,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,n)=>{if(n=="&")return e.match[0];if(n=="$")return"$";for(let r=n.length;r>0;r--){let o=+n.slice(0,r);if(o>0&&o<e.match.length)return e.match[o]+n.slice(r)}return t})}matchAll(e,t){let n=P(this.spec,e,0,e.doc.length),r=[];while(!n.next().done){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let o=P(this.spec,e,Math.max(0,t-250),Math.min(n+250,e.doc.length));while(!o.next().done)r(o.value.from,o.value.to)}}var J=W.define(),Ie=W.define(),E=Le.define({create(e){return new oe(Be(e).create(),null)},update(e,t){for(let n of t.effects)if(n.is(J))e=new oe(n.value.create(),e.panel);else if(n.is(Ie))e=new oe(e.query,n.value?Pe:null);return e},provide:(e)=>hi.from(e,(t)=>t.panel)});class oe{constructor(e,t){this.query=e,this.panel=t}}var Er=z.mark({class:"cm-searchMatch"}),Tr=z.mark({class:"cm-searchMatch cm-searchMatch-selected"}),wr=De.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(E))}update(e){let t=e.state.field(E);if(t!=e.startState.field(E)||e.docChanged||e.selectionSet||e.viewportChanged)this.decorations=this.highlight(t)}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return z.none;let{view:n}=this,r=new St;for(let o=0,l=n.visibleRanges,s=l.length;o<s;o++){let{from:c,to:a}=l[o];while(o<s-1&&a>l[o+1].from-500)a=l[++o].to;e.highlight(n.state,c,a,(h,u)=>{let f=n.state.selection.ranges.some((m)=>m.from==h&&m.to==u);r.add(h,u,f?Tr:Er)})}return r.finish()}},{decorations:(e)=>e.decorations});function K(e){return(t)=>{let n=t.state.field(E,!1);return n&&n.query.spec.valid?e(t,n):de(t)}}var he=K((e,{query:t})=>{let{to:n}=e.state.selection.main,r=t.nextMatch(e.state,n,n);if(!r)return!1;let o=d.single(r.from,r.to),l=e.state.facet(R);return e.dispatch({selection:o,effects:[Ne(e,r),l.scrollToMatch(o.main,e)],userEvent:"select.search"}),jt(e),!0}),fe=K((e,{query:t})=>{let{state:n}=e,{from:r}=n.selection.main,o=t.prevMatch(n,r,r);if(!o)return!1;let l=d.single(o.from,o.to),s=e.state.facet(R);return e.dispatch({selection:l,effects:[Ne(e,o),s.scrollToMatch(l.main,e)],userEvent:"select.search"}),jt(e),!0}),Wr=K((e,{query:t})=>{let n=t.matchAll(e.state,1000);if(!n||!n.length)return!1;return e.dispatch({selection:d.create(n.map((r)=>d.range(r.from,r.to))),userEvent:"select.search.matches"}),!0}),Rr=({state:e,dispatch:t})=>{let n=e.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:r,to:o}=n.main,l=[],s=0;for(let c=new T(e.doc,e.sliceDoc(r,o));!c.next().done;){if(l.length>1000)return!1;if(c.value.from==r)s=l.length;l.push(d.range(c.value.from,c.value.to))}return t(e.update({selection:d.create(l,s),userEvent:"select.search.matches"})),!0},Ut=K((e,{query:t})=>{let{state:n}=e,{from:r,to:o}=n.selection.main;if(n.readOnly)return!1;let l=t.nextMatch(n,r,r);if(!l)return!1;let s=l,c=[],a,h,u=[];if(!s.precise)s=t.nextMatch(n,s.from,s.to);else if(s.from==r&&s.to==o)h=n.toText(t.getReplacement(s)),c.push({from:s.from,to:s.to,insert:h}),s=t.nextMatch(n,s.from,s.to),u.push(v.announce.of(n.phrase("replaced match on line $",n.doc.lineAt(r).number)+"."));let f=e.state.changes(c);if(s)a=d.single(s.from,s.to).map(f),u.push(Ne(e,s)),u.push(n.facet(R).scrollToMatch(a.main,e));return e.dispatch({changes:f,selection:a,effects:u,userEvent:"input.replace"}),!0}),Or=K((e,{query:t})=>{if(e.state.readOnly)return!1;let n=[];for(let o of t.matchAll(e.state,1e9)){let{from:l,to:s,precise:c}=o;if(c)n.push({from:l,to:s,insert:t.getReplacement(o)})}if(!n.length)return!1;let r=e.state.phrase("replaced $ matches",n.length)+".";return e.dispatch({changes:n,effects:v.announce.of(r),userEvent:"input.replace.all"}),!0});function Pe(e){return e.state.facet(R).createPanel(e)}function Be(e,t){var n,r,o,l,s;let c=e.selection.main,a=c.empty||c.to>c.from+100?"":e.sliceDoc(c.from,c.to);if(t&&!a)return t;let h=e.facet(R);return new Re({search:((n=t===null||t===void 0?void 0:t.literal)!==null&&n!==void 0?n:h.literal)?a:a.replace(/\n/g,"\\n"),caseSensitive:(r=t===null||t===void 0?void 0:t.caseSensitive)!==null&&r!==void 0?r:h.caseSensitive,literal:(o=t===null||t===void 0?void 0:t.literal)!==null&&o!==void 0?o:h.literal,regexp:(l=t===null||t===void 0?void 0:t.regexp)!==null&&l!==void 0?l:h.regexp,wholeWord:(s=t===null||t===void 0?void 0:t.wholeWord)!==null&&s!==void 0?s:h.wholeWord})}function Qt(e){let t=ji(e,Pe);return t&&t.dom.querySelector("[main-field]")}function jt(e){let t=Qt(e);if(t&&t==e.root.activeElement)t.select()}var de=(e)=>{let t=e.state.field(E,!1);if(t&&t.panel){let n=Qt(e);if(n&&n!=e.root.activeElement){let r=Be(e.state,t.query.spec);if(r.valid)e.dispatch({effects:J.of(r)});n.focus(),n.select()}}else e.dispatch({effects:[Ie.of(!0),t?J.of(Be(e.state,t.query.spec)):W.appendConfig.of(Ee)]});return!0},Xt=(e)=>{let t=e.state.field(E,!1);if(!t||!t.panel)return!1;let n=ji(e,Pe);if(n&&n.dom.contains(e.root.activeElement))e.focus();return e.dispatch({effects:Ie.of(!1)}),!0},Yt=[{key:"Mod-f",run:de,scope:"editor search-panel"},{key:"F3",run:he,shift:fe,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:he,shift:fe,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:Xt,scope:"editor search-panel"},{key:"Mod-Shift-l",run:Rr},{key:"Mod-Alt-g",run:pr},{key:"Mod-d",run:Mr,preventDefault:!0}];class Zt{constructor(e){this.view=e;let t=this.query=e.state.field(E).query.spec;this.commit=this.commit.bind(this),this.searchField=xe("input",{value:t.search,placeholder:x(e,"Find"),"aria-label":x(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=xe("input",{value:t.replace,placeholder:x(e,"Replace"),"aria-label":x(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=xe("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=xe("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=xe("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit});function n(r,o,l){return xe("button",{class:"cm-button",name:r,onclick:o,type:"button"},l)}this.dom=xe("div",{onkeydown:(r)=>this.keydown(r),class:"cm-search"},[this.searchField,n("next",()=>he(e),[x(e,"next")]),n("prev",()=>fe(e),[x(e,"previous")]),n("select",()=>Wr(e),[x(e,"all")]),xe("label",null,[this.caseField,x(e,"match case")]),xe("label",null,[this.reField,x(e,"regexp")]),xe("label",null,[this.wordField,x(e,"by word")]),...e.state.readOnly?[]:[xe("br"),this.replaceField,n("replace",()=>Ut(e),[x(e,"replace")]),n("replaceAll",()=>Or(e),[x(e,"replace all")])],xe("button",{name:"close",onclick:()=>Xt(e),"aria-label":x(e,"close"),type:"button"},["×"])])}commit(){let e=new Re({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});if(!e.eq(this.query))this.query=e,this.view.dispatch({effects:J.of(e)})}keydown(e){if(Fo(this.view,e,"search-panel"))e.preventDefault();else if(e.keyCode==13&&e.target==this.searchField)e.preventDefault(),(e.shiftKey?fe:he)(this.view);else if(e.keyCode==13&&e.target==this.replaceField)e.preventDefault(),Ut(this.view)}update(e){for(let t of e.transactions)for(let n of t.effects)if(n.is(J)&&!n.value.eq(this.query))this.setQuery(n.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(R).top}}function x(e,t){return e.state.phrase(t)}var ne=30,re=/[\s\.,:;?!]/;function Ne(e,{from:t,to:n}){let r=e.state.doc.lineAt(t),o=e.state.doc.lineAt(n).to,l=Math.max(r.from,t-ne),s=Math.min(o,n+ne),c=e.state.sliceDoc(l,s);if(l!=r.from){for(let a=0;a<ne;a++)if(!re.test(c[a+1])&&re.test(c[a])){c=c.slice(a);break}}if(s!=o){for(let a=c.length-1;a>c.length-ne;a--)if(!re.test(c[a-1])&&re.test(c[a])){c=c.slice(0,a);break}}return v.announce.of(`${e.state.phrase("current match")}. ${c} ${e.state.phrase("on line")} ${r.number}.`)}var Fr=v.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),Ee=[E,Fe.low(wr),Fr];var Pr=v.theme({"&":{color:"var(--code-fg)",backgroundColor:"var(--code-bg)",height:"100%",fontSize:"var(--code-size, 13px)"},"&.cm-focused":{outline:"none"},".cm-scroller":{fontFamily:"var(--font-mono)",lineHeight:"1.55",overflow:"auto"},".cm-content":{caretColor:"var(--code-fg)",padding:"0.5rem 0"},".cm-line":{padding:"0 0.75rem"},".cm-cursor, .cm-dropCursor":{borderLeftColor:"var(--code-fg)"},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:"var(--code-selection)"},".cm-activeLine":{backgroundColor:"var(--code-active-line)"},".cm-gutters":{backgroundColor:"var(--code-gutter-bg)",color:"var(--code-gutter)",border:"none",borderRight:"1px solid var(--border)"},".cm-activeLineGutter":{backgroundColor:"var(--code-active-line)",color:"var(--code-fg)"},".cm-lineNumbers .cm-gutterElement":{padding:"0 0.5rem 0 0.5rem",minWidth:"2.25rem"},".cm-matchingBracket, .cm-nonmatchingBracket":{backgroundColor:"var(--code-selection)",outline:"1px solid var(--border-strong)"},".cm-searchMatch":{backgroundColor:"var(--warn-soft)",outline:"1px solid var(--warn)"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"var(--accent-soft)",outline:"1px solid var(--accent)"},".cm-panels":{backgroundColor:"var(--surface-2)",color:"var(--text)",borderColor:"var(--border)",fontFamily:"var(--font)"},".cm-panels-top":{borderBottom:"1px solid var(--border)"},".cm-panel.cm-search":{padding:"0.5rem 2rem 0.5rem 0.5rem"},".cm-panel.cm-search input, .cm-panel.cm-search button, .cm-panel.cm-search label":{fontSize:"0.875rem"},".cm-panel.cm-search input[type=text]":{backgroundColor:"var(--surface)",color:"var(--text)",border:"1px solid var(--control-border)",borderRadius:"var(--radius-sm)",padding:"0.25rem 0.5rem"},".cm-panel.cm-search button":{backgroundColor:"var(--surface-3)",color:"var(--text)",border:"1px solid var(--border-strong)",borderRadius:"var(--radius-sm)",backgroundImage:"none",padding:"0.25rem 0.625rem"},".cm-panel.cm-search [name=close]":{color:"var(--muted)"}}),Nr=In.define([{tag:[i.keyword,i.modifier,i.operatorKeyword,i.controlKeyword],color:"var(--code-keyword)"},{tag:[i.string,i.regexp,i.special(i.string),i.inserted],color:"var(--code-string)"},{tag:[i.number,i.bool,i.null,i.atom,i.literal],color:"var(--code-number)"},{tag:[i.comment,i.lineComment,i.blockComment,i.docComment],color:"var(--code-comment)",fontStyle:"italic"},{tag:[i.typeName,i.className,i.namespace,i.tagName,i.standard(i.tagName)],color:"var(--code-type)"},{tag:[i.function(i.variableName),i.function(i.propertyName),i.definition(i.variableName),i.labelName],color:"var(--code-function)"},{tag:[i.meta,i.processingInstruction,i.annotation,i.attributeName,i.propertyName,i.heading],color:"var(--code-meta)"},{tag:i.heading,fontWeight:"bold"},{tag:i.strong,fontWeight:"bold"},{tag:i.emphasis,fontStyle:"italic"},{tag:i.strikethrough,textDecoration:"line-through"},{tag:i.link,color:"var(--code-function)",textDecoration:"underline"},{tag:i.url,color:"var(--code-function)"},{tag:i.invalid,color:"var(--danger)"},{tag:i.deleted,color:"var(--danger)"}]),en=[Pr,es(Nr)];var qr={typescript:()=>(p("7gcbrhbd"),import("./chunk-lang-typescript-7gcbrhbd.js")),javascript:()=>(p("m57t19pw"),import("./chunk-lang-javascript-m57t19pw.js")),json:()=>(p("y33kawwg"),import("./chunk-lang-json-y33kawwg.js")),markdown:()=>(p("2c2sqc4z"),import("./chunk-lang-markdown-2c2sqc4z.js")),css:()=>(p("6t2q4xw4"),import("./chunk-lang-css-6t2q4xw4.js")),html:()=>(p("c6p22v5m"),import("./chunk-lang-html-c6p22v5m.js")),python:()=>(p("ymasvj52"),import("./chunk-lang-python-ymasvj52.js")),yaml:()=>(p("qp3asq06"),import("./chunk-lang-yaml-qp3asq06.js")),go:()=>(p("t47kg9n0"),import("./chunk-lang-go-t47kg9n0.js")),rust:()=>(p("qcg53mkn"),import("./chunk-lang-rust-qcg53mkn.js")),sql:()=>(p("60rh2y3y"),import("./chunk-lang-sql-60rh2y3y.js")),xml:()=>(p("k2a92cm3"),import("./chunk-lang-xml-k2a92cm3.js")),shell:()=>(p("996wb0dk"),import("./chunk-lang-shell-996wb0dk.js")),toml:()=>(p("q1yzt70y"),import("./chunk-lang-toml-q1yzt70y.js")),dockerfile:()=>(p("9rc0adjw"),import("./chunk-lang-dockerfile-9rc0adjw.js"))};async function tn(e){if(e==="plain")return;try{return(await qr[e]()).language()}catch(t){console.warn("a language for the editor failed to load",t);return}}function Vr(e){if(typeof e.attachShadow!=="function"||typeof CSSStyleSheet>"u"||!("adoptedStyleSheets"in Document.prototype))return{parent:e,root:void 0};let t=e.shadowRoot??e.attachShadow({mode:"open"}),n=new CSSStyleSheet;return n.replaceSync(":host{display:flex;flex-direction:column;min-height:0}.cm-editor{flex:1;min-height:0}"),t.adoptedStyleSheets=[...t.adoptedStyleSheets,n],{parent:t,root:t}}async function ao(e){let t=new qt,n=new qt,r=new qt,o=await tn(e.language),l=(f)=>[q.readOnly.of(!f),v.editable.of(f)],s={editable:e.editable,wrap:e.wrap,language:o??[]},c,a=(f)=>[Ho(),Zo(),jo(),et(),Go(),ts(),Jt(),$t({top:!0}),rt.of(" "),q.phrases.of(e.phrases),en,Tt.of([{key:"Mod-s",preventDefault:!0,run:()=>(e.onSave(),!0)},{key:"Escape",run:()=>(e.onEscape(),!0)},Pt,...Yt,...ot,...It]),q.lineSeparator.of(f),t.of(l(s.editable)),n.of(s.wrap?v.lineWrapping:[]),r.of(s.language),v.updateListener.of((m)=>{if(m.docChanged)e.onChange()})],h=Vr(e.parent),u=new v({parent:h.parent,root:h.root,state:q.create({doc:e.text,extensions:a(e.eol)})});return c=u.state.doc,{text:()=>u.state.doc.sliceString(0,void 0,u.state.lineBreak),dirty:()=>c===void 0||!u.state.doc.eq(c),snapshot:()=>u.state.doc,markSaved:(f)=>{c=f??u.state.doc},replace:(f,m)=>{let B=u.scrollDOM.scrollTop;u.setState(q.create({doc:f,extensions:a(m)})),c=u.state.doc,u.scrollDOM.scrollTop=B},setEditable:(f)=>{s.editable=f,u.dispatch({effects:t.reconfigure(l(f))})},setWrap:(f)=>{s.wrap=f,u.dispatch({effects:n.reconfigure(f?v.lineWrapping:[])})},setLanguage:async(f)=>{s.language=await tn(f)??[],u.dispatch({effects:r.reconfigure(s.language)})},undo:()=>{X(u)},redo:()=>{U(u)},find:()=>{de(u)},tab:()=>{te(u)},focus:()=>u.focus(),scrollTop:()=>u.scrollDOM.scrollTop,scrollTo:(f)=>{u.scrollDOM.scrollTop=f},destroy:()=>u.destroy()}}export{ao as createEditor};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import{o,R,r,e,n,gr}from"./chunk-index-rvatmx8s.js";import{B}from"./chunk-index-fw6kawhw.js";var x=`
|
|
2
|
+
/* A zero-height anchor just above the bar: the menu opens upward from it, over the room's messages. */
|
|
3
|
+
.command-anchor {
|
|
4
|
+
position: relative;
|
|
5
|
+
height: 0;
|
|
6
|
+
margin-bottom: calc(-1 * var(--space-2));
|
|
7
|
+
z-index: 5;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.command-menu {
|
|
11
|
+
position: absolute;
|
|
12
|
+
max-height: min(40vh, 18rem);
|
|
13
|
+
overflow-y: auto;
|
|
14
|
+
right: 0;
|
|
15
|
+
bottom: var(--space-2);
|
|
16
|
+
left: 0;
|
|
17
|
+
display: flex;
|
|
18
|
+
flex-direction: column;
|
|
19
|
+
margin: 0;
|
|
20
|
+
padding: var(--space-1);
|
|
21
|
+
list-style: none;
|
|
22
|
+
border: 1px solid var(--border);
|
|
23
|
+
border-radius: var(--radius-lg);
|
|
24
|
+
background: var(--surface);
|
|
25
|
+
box-shadow: var(--shadow-2);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.command-item {
|
|
29
|
+
display: flex;
|
|
30
|
+
flex-direction: column;
|
|
31
|
+
align-items: flex-start;
|
|
32
|
+
justify-content: center;
|
|
33
|
+
gap: 0;
|
|
34
|
+
min-height: var(--touch);
|
|
35
|
+
padding: var(--space-2) var(--space-3);
|
|
36
|
+
border: 1px solid transparent;
|
|
37
|
+
border-radius: var(--radius);
|
|
38
|
+
background: none;
|
|
39
|
+
color: var(--text);
|
|
40
|
+
text-align: left;
|
|
41
|
+
cursor: pointer;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.command-item:hover:not(:disabled),
|
|
45
|
+
.command-item[aria-selected="true"] {
|
|
46
|
+
background: var(--surface-2);
|
|
47
|
+
border-color: transparent;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.command-name {
|
|
51
|
+
font-family: var(--font-mono, monospace);
|
|
52
|
+
font-weight: var(--weight-medium);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.command-hint {
|
|
56
|
+
color: var(--muted);
|
|
57
|
+
font-size: var(--text-sm);
|
|
58
|
+
}
|
|
59
|
+
`;function k(s,m){let a=gr(s);if(a===void 0)return[];return m.filter((d)=>!d.hidden&&[d.name,...d.aliases??[]].some((l)=>l.startsWith(a)))}function w(s){B("command-menu",x);let m=R(),a=k(s.text,s.commands),[d,l]=r(0),[g,y]=r(),u=a.length>0&&g!==s.text,i=Math.min(d,a.length-1);o(()=>l(0),[s.text]),o(()=>{document.getElementById(`${m}-${i}`)?.scrollIntoView?.({block:"nearest"})},[m,i]);let{keys:f,area:v,onRun:h,onComplete:p}=s;if(o(()=>(f.current=(t)=>{let c=a[i];if(!u||!c||t.altKey||t.ctrlKey||t.metaKey)return!1;switch(t.key){case"ArrowDown":case"ArrowUp":l((i+(t.key==="ArrowDown"?1:a.length-1))%a.length);break;case"Enter":if(t.shiftKey)return!1;h(c);break;case"Tab":if(t.shiftKey)return!1;p(c);break;case"Escape":y(s.text);break;default:return!1}return t.preventDefault(),!0},()=>{f.current=void 0}),[f,a,i,u,h,p,s.text]),o(()=>{let t=v.current;if(!t||!u)return;return t.setAttribute("aria-controls",`${m}-list`),t.setAttribute("aria-activedescendant",`${m}-${i}`),()=>{t.removeAttribute("aria-controls"),t.removeAttribute("aria-activedescendant")}},[v,u,m,i]),!u)return null;return e("div",{className:"command-anchor",children:e("div",{className:"command-menu",id:`${m}-list`,role:"listbox",children:a.map((t,c)=>n("button",{type:"button",id:`${m}-${c}`,role:"option",tabIndex:-1,"aria-selected":c===i,className:"command-item",onPointerDown:(b)=>b.preventDefault(),onMouseDown:(b)=>b.preventDefault(),onMouseEnter:()=>l(c),onClick:()=>h(t),children:[n("span",{className:"command-name",children:["/",t.name]}),e("span",{className:"command-hint",children:t.description})]},t.name))})})}export{w as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{D}from"./chunk-index-gae833v6.js";import"./chunk-index-0dyf2gdm.js";export{D as Confirm};
|