pi-roundtable-web 0.28.0 → 0.29.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (205) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.md +4 -4
  3. package/dist/chunk-account-9616x405.js +1 -0
  4. package/dist/{chunk-action-menu-qpp9bdxh.js → chunk-action-menu-q5y7xpry.js} +1 -1
  5. package/dist/chunk-agent-x74xezyt.js +1 -0
  6. package/dist/{chunk-arranged-rooms-6rdkk8t1.js → chunk-arranged-rooms-9prq46vh.js} +1 -1
  7. package/dist/chunk-bulk-actions-5dc4m9ad.js +1 -0
  8. package/dist/chunk-character-creator-wf02eg0h.js +1 -0
  9. package/dist/{chunk-codeeditor-jgj32247.js → chunk-codeeditor-239ss6a2.js} +2 -2
  10. package/dist/chunk-confirm-bhrx9195.js +1 -0
  11. package/dist/chunk-connectors-k77pd9by.js +37 -0
  12. package/dist/{chunk-conversations-fb071rez.js → chunk-conversations-ftcpaqw1.js} +1 -1
  13. package/dist/chunk-council-sheet-a5e6tspr.js +2 -0
  14. package/dist/chunk-council-view-6593rqbr.js +1 -0
  15. package/dist/{chunk-drag-04qfef58.js → chunk-drag-7873fvzw.js} +1 -1
  16. package/dist/{chunk-entry-mws704mc.js → chunk-entry-5zmjxadx.js} +1 -1
  17. package/dist/chunk-folder-list-h9hmbm8e.js +1 -0
  18. package/dist/chunk-folds-vxq86t1s.js +1 -0
  19. package/dist/{chunk-gate-vxetvn8t.js → chunk-gate-fa6za28z.js} +1 -1
  20. package/dist/chunk-host-icons-y6frbzqt.js +1 -0
  21. package/dist/chunk-host-picture-fqg55rbr.js +1 -0
  22. package/dist/chunk-host-state-65tdhkyq.js +1 -0
  23. package/dist/{chunk-host-ui-pc9r24e3.js → chunk-host-ui-233kz7qp.js} +1 -1
  24. package/dist/{chunk-index-5hbq6g2e.css → chunk-index-1652v386.css} +1 -1
  25. package/dist/chunk-index-2c00zf3z.js +2 -0
  26. package/dist/chunk-index-2dhrqvba.js +2 -0
  27. package/dist/chunk-index-2s4bkrz3.js +2 -0
  28. package/dist/{chunk-index-v8mma5np.js → chunk-index-2ypaqwjy.js} +2 -2
  29. package/dist/{chunk-index-7qd604rq.js → chunk-index-35zqk1zr.js} +2 -2
  30. package/dist/chunk-index-39qq37j5.js +2 -0
  31. package/dist/{chunk-index-2hvn2kte.js → chunk-index-3tjmyd1h.js} +2 -2
  32. package/dist/{chunk-index-2tr41qht.js → chunk-index-4eag6s50.js} +2 -2
  33. package/dist/{chunk-index-2y8r4s4f.js → chunk-index-4jnn2g09.js} +2 -2
  34. package/dist/{chunk-index-q5fyrtx4.js → chunk-index-4krm48hm.js} +1 -1
  35. package/dist/{chunk-index-zj0gjcvr.js → chunk-index-4re5prfp.js} +2 -2
  36. package/dist/chunk-index-57teqgct.js +2 -0
  37. package/dist/{chunk-index-e2gy763y.js → chunk-index-5ssncptg.js} +2 -2
  38. package/dist/{chunk-index-20xgx0k2.js → chunk-index-7c9fn21n.js} +2 -2
  39. package/dist/{chunk-index-p7jkr7gv.js → chunk-index-7k5895sn.js} +5 -5
  40. package/dist/chunk-index-93f3e06v.js +2 -0
  41. package/dist/chunk-index-9m9v1p7s.js +2 -0
  42. package/dist/{chunk-index-3yy10a5h.js → chunk-index-a8c0ap8g.js} +2 -2
  43. package/dist/chunk-index-a8nqn3y0.js +3 -0
  44. package/dist/chunk-index-am7ghh75.js +120 -0
  45. package/dist/{chunk-index-rgf4rvns.js → chunk-index-amspdq2j.js} +3 -3
  46. package/dist/{chunk-index-s53bxwkk.js → chunk-index-aycxt14t.js} +2 -2
  47. package/dist/{chunk-index-jc3r4qam.js → chunk-index-bjeg3e2j.js} +2 -2
  48. package/dist/chunk-index-cttrqfm8.js +2 -0
  49. package/dist/chunk-index-dajanzxc.js +1 -0
  50. package/dist/chunk-index-e2eeckhh.js +2 -0
  51. package/dist/{chunk-index-rsd8rftk.js → chunk-index-e46652wf.js} +2 -2
  52. package/dist/chunk-index-ek98d2rn.js +2 -0
  53. package/dist/{chunk-index-n0cmnwd2.js → chunk-index-en5dm1zv.js} +2 -2
  54. package/dist/{chunk-index-zcfr8jdv.js → chunk-index-evhaaqzk.js} +12 -12
  55. package/dist/{chunk-index-2syyyjnq.js → chunk-index-f4gqzfkv.js} +2 -2
  56. package/dist/{chunk-index-3gfbhmpb.js → chunk-index-gj3n4dh5.js} +2 -2
  57. package/dist/chunk-index-gp4chnp3.js +2 -0
  58. package/dist/{chunk-index-v9gbt5tz.js → chunk-index-h2a42p6s.js} +3 -3
  59. package/dist/{chunk-index-zt19fdmc.js → chunk-index-haac6nbt.js} +2 -2
  60. package/dist/{chunk-index-gwkhs8s3.js → chunk-index-hef4gwtb.js} +2 -2
  61. package/dist/chunk-index-mg96sqpk.js +2 -0
  62. package/dist/chunk-index-nsya88fn.js +1 -0
  63. package/dist/{chunk-index-6cg8xp1c.js → chunk-index-ntt3em2k.js} +1 -1
  64. package/dist/chunk-index-pcbkp62w.js +2 -0
  65. package/dist/{chunk-index-5t2jkecy.js → chunk-index-pfs6rm6w.js} +2 -2
  66. package/dist/{chunk-index-x60n1me6.js → chunk-index-pgxgq61x.js} +2 -2
  67. package/dist/{chunk-index-s9p27f9b.js → chunk-index-q33ppq0j.js} +3 -3
  68. package/dist/{chunk-index-fepsbhr6.js → chunk-index-r0hk9kyd.js} +2 -2
  69. package/dist/{chunk-index-2822z600.js → chunk-index-rr73h4kc.js} +3 -3
  70. package/dist/{chunk-index-e35v554x.js → chunk-index-rtz4936v.js} +1 -1
  71. package/dist/chunk-index-smz90j6p.js +2 -0
  72. package/dist/{chunk-index-c7dbvkrq.js → chunk-index-teyx2hz7.js} +2 -2
  73. package/dist/{chunk-index-4t6vnwap.js → chunk-index-v6h43553.js} +2 -2
  74. package/dist/chunk-index-vzqwn3wp.js +2 -0
  75. package/dist/chunk-index-wt2asefx.js +50 -0
  76. package/dist/chunk-index-x4tq9btg.js +2 -0
  77. package/dist/chunk-index-y6p8j3zv.js +2 -0
  78. package/dist/chunk-index-yvcdg5hh.js +2 -0
  79. package/dist/{chunk-index-m81362sc.js → chunk-index-zdzzf3fp.js} +1 -1
  80. package/dist/chunk-index-zeqfnkty.js +2 -0
  81. package/dist/chunk-index-zpwb8mkk.js +2 -0
  82. package/dist/chunk-lang-css-avzhvm72.js +1 -0
  83. package/dist/{chunk-lang-dockerfile-n4bt8jbt.js → chunk-lang-dockerfile-2p7e3ssz.js} +1 -1
  84. package/dist/{chunk-lang-go-9k4y107e.js → chunk-lang-go-zxp9k517.js} +3 -3
  85. package/dist/chunk-lang-html-red02gep.js +1 -0
  86. package/dist/chunk-lang-javascript-n33kmjcx.js +1 -0
  87. package/dist/{chunk-lang-json-hr12bzs1.js → chunk-lang-json-zmym50rg.js} +1 -1
  88. package/dist/{chunk-lang-markdown-ttzcpgkg.js → chunk-lang-markdown-ww2kcs85.js} +4 -4
  89. package/dist/{chunk-lang-python-ntj8maem.js → chunk-lang-python-ng1zdtd4.js} +2 -2
  90. package/dist/{chunk-lang-rust-gv8y859d.js → chunk-lang-rust-6ynhxjdd.js} +1 -1
  91. package/dist/{chunk-lang-shell-5zzs09b7.js → chunk-lang-shell-39t9bz2s.js} +1 -1
  92. package/dist/{chunk-lang-sql-6vmze4pg.js → chunk-lang-sql-w875ejpg.js} +2 -2
  93. package/dist/{chunk-lang-toml-tt0d4rw9.js → chunk-lang-toml-b8ckgkg5.js} +1 -1
  94. package/dist/chunk-lang-typescript-qf8acbb2.js +1 -0
  95. package/dist/{chunk-lang-xml-r2sbqnjv.js → chunk-lang-xml-bz91cjp1.js} +1 -1
  96. package/dist/{chunk-lang-yaml-ex31qbph.js → chunk-lang-yaml-g9zy0tdv.js} +1 -1
  97. package/dist/chunk-layout-actions-fyzzzeyp.js +1 -0
  98. package/dist/chunk-menu-items-yvnk3vds.js +1 -0
  99. package/dist/chunk-mode-toggle-ccv271hm.js +1 -0
  100. package/dist/{chunk-note-row-40ypghn9.js → chunk-note-row-314py1pp.js} +3 -3
  101. package/dist/{chunk-notes-a8nqffbf.js → chunk-notes-4rnrddzw.js} +1 -1
  102. package/dist/{chunk-notice-bell-rdnfmtf2.js → chunk-notice-bell-z9wgamnz.js} +1 -1
  103. package/dist/{chunk-notices-tefx93s6.js → chunk-notices-mtn7pg1z.js} +1 -1
  104. package/dist/{chunk-onboarding-wvh0s3vg.js → chunk-onboarding-f3hhxgg4.js} +1 -1
  105. package/dist/{chunk-overview-zrx3bpwf.js → chunk-overview-qmepntrr.js} +1 -1
  106. package/dist/chunk-palette-edkn1ypq.js +1 -0
  107. package/dist/chunk-placement-items-trsa5t23.js +1 -0
  108. package/dist/{chunk-profile-tyb48b79.js → chunk-profile-pwfq0wns.js} +1 -1
  109. package/dist/chunk-prompt-history-xp9hmeqt.js +1 -0
  110. package/dist/chunk-prompts-a56qvytg.js +1 -0
  111. package/dist/chunk-room-confirms-gqpkz4h0.js +1 -0
  112. package/dist/{chunk-room-menu-ha1evv71.js → chunk-room-menu-1m2c2ekt.js} +1 -1
  113. package/dist/chunk-rooms-menu-button-tcvda1gq.js +1 -0
  114. package/dist/{chunk-schedules-a5pewkhd.js → chunk-schedules-kwnw7p8v.js} +1 -1
  115. package/dist/{chunk-seat-menu-eh3ymmks.js → chunk-seat-menu-m2n9nvv0.js} +1 -1
  116. package/dist/chunk-sheet-hosts-pr8xktyq.js +29 -0
  117. package/dist/{chunk-shortcut-help-bh9ntk9s.js → chunk-shortcut-help-sbvrds1m.js} +2 -2
  118. package/dist/{chunk-shortcuts-6em0atk9.js → chunk-shortcuts-8705p7q3.js} +1 -1
  119. package/dist/{chunk-skill-editor-e43mwz01.js → chunk-skill-editor-7xy09sq1.js} +2 -2
  120. package/dist/chunk-skills-cnc25x7q.js +1 -0
  121. package/dist/{chunk-start-over-line-xd1v2p0g.js → chunk-start-over-line-97zdd9pb.js} +2 -2
  122. package/dist/{chunk-switcher-list-dtfh87zy.js → chunk-switcher-list-ehsn2wsk.js} +1 -1
  123. package/dist/{chunk-tab-dot-qd640mjr.js → chunk-tab-dot-gkpe06q8.js} +1 -1
  124. package/dist/chunk-table-av3kh3tt.js +1 -0
  125. package/dist/{chunk-table2d-5nrhfwft.js → chunk-table2d-5x3jptp9.js} +1 -1
  126. package/dist/{chunk-table3d-5cb66d99.js → chunk-table3d-rsvajx7r.js} +172 -172
  127. package/dist/chunk-thread-actions-7xtkegwm.js +1 -0
  128. package/dist/{chunk-thread-cards-kgt22sbp.js → chunk-thread-cards-grzszfha.js} +1 -1
  129. package/dist/{chunk-thread-list-j2v1pqkz.js → chunk-thread-list-9bjjac3j.js} +2 -2
  130. package/dist/{chunk-transcript-a0p3vwh6.js → chunk-transcript-t5szb8r0.js} +1 -1
  131. package/dist/{chunk-waiting-chip-58ttx9av.js → chunk-waiting-chip-d8b6a0p8.js} +2 -2
  132. package/dist/chunk-waiting-ts3kxjvv.js +1 -0
  133. package/dist/chunk-where-3d3ncsa5.js +1 -0
  134. package/dist/{chunk-workspace-d34njy4p.js → chunk-workspace-ct6hvn0z.js} +2 -2
  135. package/dist/chunk-zh-tw-v9v1eerm.js +1 -0
  136. package/dist/index.html +1 -1
  137. package/dist/sw.js +1 -1
  138. package/package.json +3 -3
  139. package/src/api-types.ts +39 -0
  140. package/src/app/rooms.ts +30 -2
  141. package/src/app/routes.ts +26 -2
  142. package/src/app/skill-group-routes.ts +126 -0
  143. package/src/authz.ts +1 -0
  144. package/src/i18n/zh-tw.ts +31 -2
  145. package/src/push/channel.ts +1 -0
  146. package/src/web-plugin.ts +1 -0
  147. package/dist/chunk-account-678dgbww.js +0 -1
  148. package/dist/chunk-agent-x0yvvdq2.js +0 -1
  149. package/dist/chunk-bulk-actions-zbwdaxtc.js +0 -1
  150. package/dist/chunk-character-creator-215psy17.js +0 -1
  151. package/dist/chunk-confirm-2pzrt272.js +0 -1
  152. package/dist/chunk-connectors-zha2d834.js +0 -37
  153. package/dist/chunk-council-sheet-k5fycefd.js +0 -2
  154. package/dist/chunk-folder-list-qxhmczwv.js +0 -1
  155. package/dist/chunk-folds-b7asegfs.js +0 -1
  156. package/dist/chunk-group-scene-63yhh1mh.js +0 -1
  157. package/dist/chunk-group-table-zy4hmgk3.js +0 -1
  158. package/dist/chunk-host-icons-tyktazzz.js +0 -1
  159. package/dist/chunk-host-picture-ebhejn2k.js +0 -1
  160. package/dist/chunk-host-state-wajep0yr.js +0 -1
  161. package/dist/chunk-index-1af8vsyb.js +0 -2
  162. package/dist/chunk-index-254701sm.js +0 -3
  163. package/dist/chunk-index-31m1b2f5.js +0 -2
  164. package/dist/chunk-index-5vatmakn.js +0 -2
  165. package/dist/chunk-index-6yra9kdq.js +0 -2
  166. package/dist/chunk-index-9bdstf8t.js +0 -2
  167. package/dist/chunk-index-acj4xxgq.js +0 -100
  168. package/dist/chunk-index-aexy023z.js +0 -2
  169. package/dist/chunk-index-bef0fc2m.js +0 -2
  170. package/dist/chunk-index-c6tphrjr.js +0 -1
  171. package/dist/chunk-index-cn49mawx.js +0 -50
  172. package/dist/chunk-index-gcmmwh8t.js +0 -2
  173. package/dist/chunk-index-h2vhv4kh.js +0 -2
  174. package/dist/chunk-index-h9ccz1r3.js +0 -2
  175. package/dist/chunk-index-n0ejy0wd.js +0 -2
  176. package/dist/chunk-index-nkdg1dfz.js +0 -7
  177. package/dist/chunk-index-qxynr1hf.js +0 -2
  178. package/dist/chunk-index-r7fdgzy1.js +0 -2
  179. package/dist/chunk-index-sdcpf5dp.js +0 -2
  180. package/dist/chunk-index-sm7kfb07.js +0 -2
  181. package/dist/chunk-index-sw9r4aa4.js +0 -2
  182. package/dist/chunk-index-t5bmsqqd.js +0 -1
  183. package/dist/chunk-index-vsfsv8hd.js +0 -2
  184. package/dist/chunk-index-wxft0aqb.js +0 -2
  185. package/dist/chunk-index-zvvwxkev.js +0 -2
  186. package/dist/chunk-lang-css-7q1dtpgm.js +0 -1
  187. package/dist/chunk-lang-html-xgvba8rn.js +0 -1
  188. package/dist/chunk-lang-javascript-vgxmgd0a.js +0 -1
  189. package/dist/chunk-lang-typescript-2v652sh5.js +0 -1
  190. package/dist/chunk-layout-actions-bfqtg71d.js +0 -1
  191. package/dist/chunk-menu-items-rztgekfj.js +0 -1
  192. package/dist/chunk-mode-toggle-m5kgb7c7.js +0 -1
  193. package/dist/chunk-palette-5xtdvy9a.js +0 -1
  194. package/dist/chunk-placement-items-rgyrktvy.js +0 -1
  195. package/dist/chunk-prompt-history-wv0vdsjv.js +0 -1
  196. package/dist/chunk-prompts-75hgb0t0.js +0 -1
  197. package/dist/chunk-room-confirms-bcvhpcry.js +0 -1
  198. package/dist/chunk-rooms-menu-button-ej3a2hyc.js +0 -1
  199. package/dist/chunk-sheet-hosts-d5zbwbbr.js +0 -29
  200. package/dist/chunk-skills-vp107wrp.js +0 -1
  201. package/dist/chunk-table-svb2xhfd.js +0 -1
  202. package/dist/chunk-thread-actions-926eab0w.js +0 -1
  203. package/dist/chunk-waiting-cdyz7r1g.js +0 -1
  204. package/dist/chunk-where-9jp6g029.js +0 -1
  205. package/dist/chunk-zh-tw-y3jb20wc.js +0 -1
package/CHANGELOG.md CHANGED
@@ -5,6 +5,28 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
5
5
 
6
6
  ## [Unreleased]
7
7
 
8
+ ## [0.29.0] - 2026-10-31
9
+
10
+ ### Added
11
+
12
+ - Skill groups in the app. The Skills page has a "Skill groups" section that lists each group with its skills and creates, edits (name, description, skills picked from the catalog) and deletes a group after a confirmation. The Edit knight sheet's Skills section has a switch per group, the same switch as each skill's: it shows on when the knight carries all of the group, otherwise what it lacks. Switching it on, after a confirmation, switches on the group's skills the knight lacks through the same path as the per-skill switch; switching it off switches off the group's skills the knight carries, built-in ones excepted. Either names what changed. A knight carries skills, not groups. The routes are under `api/skill-groups/` (list, `PUT` to create or replace with `from` to rename, `DELETE`, `POST …/apply` with `on: false` to switch a group off, answering `added` and `removed`) and answer owners only; `AppApiOptions.skills.groups` takes the registry's `groups`, `setGroup` and `deleteGroup`.
13
+
14
+ ### Changed
15
+
16
+ - A group's council has one view, `CouncilView`, that both the group room and the round table page show: the council chip and sheet, the Animation mode / Chat mode switch, Reset view in the scene, the waiting cards, the room menu, the mode and offline banners, and the scene or the chat with the room's composer (with its @AI/note switch where the room takes notes). The table page gains the waiting cards and the room menu; the room gains the council chip, seat menus in the scene, and a phone keyboard that closes after a send.
17
+ - The round table's dialogue box types a knight's words out whole before the scene moves on. A knight who starts thinking meanwhile shows its thinking on its seat while the camera and the box stay on the speaker; once the words stand, the box takes the next knight's words, or the camera turns to the knight still thinking and the box shows its progress under the last words. Lines said while one types wait and come in order, a tap still shows the whole line and moves on, and with reduced motion each line shows whole and the next follows at once. Both the 3D and the 2D table; the chat mode is unchanged.
18
+ - The mode is kept per council room (`roundtable-console:council-mode:<room>`) instead of a group room's "Table" toggle and the table page's per-device mode. The first read takes the room's old toggle (`rt-table-mode:<room>`, then removed), else the old device mode (`roundtable-console:table-mode`), else the scene.
19
+ - A temp knight made on Discord stays off the room list and the switcher until its room has a message or someone opens it from a link; `GET api/rooms/<key>` answers its view and lists it from then on. A card it waits on still shows. One made in the web app, or before its origin was kept, is listed as before.
20
+
21
+ ### Removed
22
+
23
+ - The group room's "Table" toggle button and the table page's own header, mode switch and chat wrapper.
24
+
25
+ ### Fixed
26
+
27
+ - A swipe in a round table close-up steps the way the finger moves: a swipe to the left brings in the podium on the right. It went the other way.
28
+ - A room's chat stops following its newest end the moment the person scrolls up, by wheel, finger, key or scrollbar. Scrolling up just a little from the end used to count as still at the end, so rows settling or a reply streaming in pulled the view back down, and it shook.
29
+
8
30
  ## [0.28.0] - 2026-10-31
9
31
 
10
32
  ### 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.28.0 <0.29.0` as a peer dependency.
33
+ - Bun 1.4.4 or later, and pi-roundtable `>=0.29.0 <0.30.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.
@@ -157,7 +157,7 @@ The room list's menu (the button beside the search) and each folder's menu clear
157
157
 
158
158
  #### Temp knights
159
159
 
160
- A knight's temp knights (the helpers it makes with `helper_create`, see the core guide) hang under its row like threads: a small face, the name, and a state, a pulsing dot while it works, the card badge while it waits for you, and a dimmed **Ended** with the time once it has nothing running, queued or waiting. The group of them is unfolded while one is at work and folded when all have ended, as the person last chose on this device. They follow the knight's pin and folder, have no drag handle and no seat at the round table, are left out of groups, the council tick list and the switcher, and their push is held back by default because their answers reach the knight's room (a card still pushes). A temp knight's room works like any other room: you may write to it directly, and its header reads "Temp knight · Made by <knight>" with a link to the knight.
160
+ A knight's temp knights (the helpers it makes with `helper_create`, see the core guide) hang under its row like threads: a small face, the name, and a state, a pulsing dot while it works, the card badge while it waits for you, and a dimmed **Ended** with the time once it has nothing running, queued or waiting. The group of them is unfolded while one is at work and folded when all have ended, as the person last chose on this device. They follow the knight's pin and folder, have no drag handle and no seat at the round table, are left out of groups, the council tick list and the switcher, and their push is held back by default because their answers reach the knight's room (a card still pushes). A temp knight's room works like any other room: you may write to it directly, and its header reads "Temp knight · Made by <knight>" with a link to the knight. A temp knight lives on the surface that made it: one made here gets no Discord thread until someone messages it there, and one made on Discord stays off the room list, the switcher included, until its room has a message or you open it from a link (`GET api/rooms/<key>` answers its view and lists it from then on); a card it waits on still shows.
161
161
  **Clear finished temp knights** is in the room list's menu, a folder's menu and a knight's menu, and is left out when nothing has ended. It archives at once, with no confirmation, and the notice's Undo restores exactly those. A temp knight's own menu has **Archive this temp knight**, with the same notice. When a knight clears its own with `helper_end`, its room shows a line naming them with an Undo. The archive page lists each temp knight right after its knight.
162
162
  The routes are `POST api/rooms/archive-finished-helpers` (body `{ "rooms": [<keys>] }` of knights' rooms, at most 500; left out, every knight's; answers `{ "archived": [{ "room", "names" }] }`) and `POST api/rooms/restore-helpers` (body `{ "names": [<names>] }`, at most 500; answers `{ "restored": [<names>] }`; a name that is not a temp knight is refused with `400` and named, and one that is no longer archived is passed over). Both are the owners', like the rest of `api/rooms`. `RoomView.helper` is `{ parent, parentName, finished? }` on a temp knight's room.
163
163
 
@@ -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 device (`roundtable-console:table-mode`). 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; **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: its header has a "Table" button that switches the room between its list and the scene; the choice is kept per room. 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 the list, with the speaker lit.
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.
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,Q,S,e,v}from"./chunk-index-wt2asefx.js";var a={profile:S(()=>(p("pwfq0wns"),import("./chunk-profile-pwfq0wns.js")).then((o)=>({default:o.ProfilePage}))),notices:S(()=>(p("mtn7pg1z"),import("./chunk-notices-mtn7pg1z.js")).then((o)=>({default:o.NoticesPage}))),onboarding:S(()=>(p("f3hhxgg4"),import("./chunk-onboarding-f3hhxgg4.js")).then((o)=>({default:o.OnboardingPage})))};function n({pane:o}){let t=a[o];return t?e(Q,{fallback:e(v,{}),children:e(t,{})}):null}export{n as default};
@@ -1 +1 @@
1
- import{o,$e,a,r,g,e,n,s,kt,ns}from"./chunk-index-cn49mawx.js";import{R}from"./chunk-index-m81362sc.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,kt();let y=h.current;h.current=void 0,y?.()};return window.addEventListener("popstate",f),()=>window.removeEventListener("popstate",f)},[]),e(R,{open:t!==void 0,title:l?.title??"",onClose:kt,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){kt(),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(),kt(),u?.()},f=a(p);f.current=p,$e(()=>{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;kt()},d=()=>kt();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=ns(),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};
1
+ import{o,Ne,a,r,g,e,n,s,wt,es}from"./chunk-index-wt2asefx.js";import{R}from"./chunk-index-zdzzf3fp.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,wt();let y=h.current;h.current=void 0,y?.()};return window.addEventListener("popstate",f),()=>window.removeEventListener("popstate",f)},[]),e(R,{open:t!==void 0,title:l?.title??"",onClose:wt,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){wt(),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(),wt(),u?.()},f=a(p);f.current=p,Ne(()=>{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;wt()},d=()=>wt();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=es(),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,d,v,Ye}from"./chunk-index-wt2asefx.js";function g({name:r}){let m=d((i)=>i.listed),t=d((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}),Ye(r);else if(m)X("rooms",void 0,{replace:!0})},[t,m,r]),e("div",{className:"page",children:e(v,{})})}export{g as AgentPage};
@@ -1 +1 @@
1
- import{p,Q,S,j,C,a,t,g,e,n,s,Re,l,k,_,me,Ht,bn,J,ar,wi,qr,Nt,ki,Br}from"./chunk-index-cn49mawx.js";import{ze}from"./chunk-index-6yra9kdq.js";import{ui}from"./chunk-index-sdcpf5dp.js";import"./chunk-index-q5fyrtx4.js";import"./chunk-index-gwkhs8s3.js";import{si}from"./chunk-index-31m1b2f5.js";import{ai,li}from"./chunk-index-s9p27f9b.js";import{Gt}from"./chunk-index-2tr41qht.js";import"./chunk-index-vsfsv8hd.js";import"./chunk-index-s53bxwkk.js";import{at}from"./chunk-index-20xgx0k2.js";ai();var M=S(()=>(p("qxhmczwv"),import("./chunk-folder-list-qxhmczwv.js")).then((o)=>({default:o.FolderList}))),O=j(function(d){let{view:r}=d,f=Gt(()=>Ht(r.key),r.home?void 0:li(r.key));return e(qr,{...d,press:f,item:{...r.home?{}:{"data-drop-item":"","data-key":r.key},...d.arranging?{"data-arranging":""}:{}},after:d.arranging?e("button",{type:"button",className:"icon-button row-more","aria-haspopup":"menu","aria-label":t("Room menu"),onClick:(c)=>{let u=c.currentTarget;Ht(r.key).then((i)=>{if(!i)return;let y=u.getBoundingClientRect();me({...i,at:{x:y.left,y:y.bottom},via:"key",source:u})},()=>{return})},children:e(s,{name:"more",size:18})}):null})});function P(o){let{now:d}=J(),{timeZone:r}=_(),f=Nt(o.rooms);return e("ul",{className:"room-list",children:f.map(({key:c,...u})=>{let i=o.threads[c];return e(O,{...u,active:c===o.active,now:d,timeZone:r,arranging:o.arranging,...i?{threads:e(ki,{open:i.open,closed:i.closed,active:o.active,parent:c})}:{}},c)})})}function v(o){let r=Nt(o.rooms).length===0;if(r&&o.zone?.kind!=="pinned")return null;return n("section",{className:"stack",...r?{"data-empty":""}:{},...o.zone?{"data-drop-zone":o.zone.kind,"data-zone-id":o.zone.id}:{},children:[e("h2",{className:"section-title",children:o.title}),r?null:e(P,{rooms:o.rooms,threads:o.threads,active:o.active,arranging:o.arranging})]})}function re(o){let d=Boolean(_().kinds?.length),r=l((m)=>JSON.stringify({listed:m.listed,...at(m,(F)=>Re(m,F))})),f=ui(),c=a(r);if(!f)c.current=r;let u=c.current,{listed:i,...y}=C(()=>JSON.parse(u),[u]),{home:w,pinned:z,folders:N,restAgents:T,restGroups:D,rest:A,threads:L,orphans:h}=y,R=ar(),K=w.length+z.length+A.length===0&&N.every((m)=>m.rooms.length===0)&&h.open.length+h.closed.length===0,b={threads:L,active:o.active,arranging:R};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"})]}),i?e("button",{type:"button",className:"header-button icon-button","aria-haspopup":"menu","aria-label":t("Folders and order"),onClick:(m)=>si(m.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:(m)=>bn(m.currentTarget),children:e(s,{name:"plus"})})]})]}),R?n("div",{className:"arrange-bar",children:[n("button",{type:"button",className:"secondary",onClick:()=>ze({kind:"new"}),children:[e(s,{name:"plus",size:16}),e("span",{children:t("Add a folder")})]}),e("button",{type:"button",onClick:()=>wi(!1),children:t("Done")})]}):null,i&&K&&!d?e(k,{children:t("No rooms yet. Rooms appear when the team has a knight.")}):null,!i?n("div",{className:"stack","aria-busy":"true",children:[e("div",{className:"skeleton"}),e("div",{className:"skeleton"}),e("div",{className:"skeleton"})]}):null,e(v,{title:t("Home"),rooms:w,...b}),e(v,{title:t("Pinned"),rooms:z,zone:{kind:"pinned",id:"pinned"},...b}),N.length>0?e("div",{className:"stack folder-list","data-folder-list":"",children:e(Q,{fallback:e("div",{className:"skeleton","aria-busy":"true"}),children:e(M,{folders:N,active:o.active,listed:i,rooms:(m)=>e(P,{rooms:m,threads:L,active:o.active,arranging:R})})})}):null,N.length>0?e(v,{title:t("Ungrouped"),rooms:A,zone:{kind:"rest",id:"rest"},...b}):n(g,{children:[e(v,{title:t("Knights"),rooms:T,zone:{kind:"rest",id:"rest-agents"},...b}),e(v,{title:t("Groups"),rooms:D,zone:{kind:"rest",id:"rest-groups"},...b})]}),h.open.length+h.closed.length>0?n("section",{className:"stack",children:[e("h2",{className:"section-title",children:t("Dispatch threads")}),e(ki,{open:h.open,closed:h.closed,active:o.active})]}):null,e(Br,{active:o.active})]})}export{re as ArrangedRoomsPage};
1
+ import{p,Q,S,j,C,a,t,g,e,n,s,Re,d,k,_,ge,Yt,vn,J,dr,Ti,Fr,Lt,Pi,Gr}from"./chunk-index-wt2asefx.js";import{Xe}from"./chunk-index-smz90j6p.js";import{pi}from"./chunk-index-2s4bkrz3.js";import"./chunk-index-4krm48hm.js";import"./chunk-index-hef4gwtb.js";import{ui}from"./chunk-index-vzqwn3wp.js";import{di,fi}from"./chunk-index-q33ppq0j.js";import{Ft}from"./chunk-index-4eag6s50.js";import"./chunk-index-gp4chnp3.js";import"./chunk-index-aycxt14t.js";import{st}from"./chunk-index-7c9fn21n.js";di();var M=S(()=>(p("h9hmbm8e"),import("./chunk-folder-list-h9hmbm8e.js")).then((o)=>({default:o.FolderList}))),O=j(function(l){let{view:r}=l,f=Ft(()=>Yt(r.key),r.home?void 0:fi(r.key));return e(Fr,{...l,press:f,item:{...r.home?{}:{"data-drop-item":"","data-key":r.key},...l.arranging?{"data-arranging":""}:{}},after:l.arranging?e("button",{type:"button",className:"icon-button row-more","aria-haspopup":"menu","aria-label":t("Room menu"),onClick:(c)=>{let u=c.currentTarget;Yt(r.key).then((i)=>{if(!i)return;let y=u.getBoundingClientRect();ge({...i,at:{x:y.left,y:y.bottom},via:"key",source:u})},()=>{return})},children:e(s,{name:"more",size:18})}):null})});function P(o){let{now:l}=J(),{timeZone:r}=_(),f=Lt(o.rooms);return e("ul",{className:"room-list",children:f.map(({key:c,...u})=>{let i=o.threads[c];return e(O,{...u,active:c===o.active,now:l,timeZone:r,arranging:o.arranging,...i?{threads:e(Pi,{open:i.open,closed:i.closed,active:o.active,parent:c})}:{}},c)})})}function v(o){let r=Lt(o.rooms).length===0;if(r&&o.zone?.kind!=="pinned")return null;return n("section",{className:"stack",...r?{"data-empty":""}:{},...o.zone?{"data-drop-zone":o.zone.kind,"data-zone-id":o.zone.id}:{},children:[e("h2",{className:"section-title",children:o.title}),r?null:e(P,{rooms:o.rooms,threads:o.threads,active:o.active,arranging:o.arranging})]})}function re(o){let l=Boolean(_().kinds?.length),r=d((m)=>JSON.stringify({listed:m.listed,...st(m,(F)=>Re(m,F))})),f=pi(),c=a(r);if(!f)c.current=r;let u=c.current,{listed:i,...y}=C(()=>JSON.parse(u),[u]),{home:w,pinned:z,folders:N,restAgents:T,restGroups:D,rest:A,threads:L,orphans:h}=y,R=dr(),K=w.length+z.length+A.length===0&&N.every((m)=>m.rooms.length===0)&&h.open.length+h.closed.length===0,b={threads:L,active:o.active,arranging:R};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"})]}),i?e("button",{type:"button",className:"header-button icon-button","aria-haspopup":"menu","aria-label":t("Folders and order"),onClick:(m)=>ui(m.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:(m)=>vn(m.currentTarget),children:e(s,{name:"plus"})})]})]}),R?n("div",{className:"arrange-bar",children:[n("button",{type:"button",className:"secondary",onClick:()=>Xe({kind:"new"}),children:[e(s,{name:"plus",size:16}),e("span",{children:t("Add a folder")})]}),e("button",{type:"button",onClick:()=>Ti(!1),children:t("Done")})]}):null,i&&K&&!l?e(k,{children:t("No rooms yet. Rooms appear when the team has a knight.")}):null,!i?n("div",{className:"stack","aria-busy":"true",children:[e("div",{className:"skeleton"}),e("div",{className:"skeleton"}),e("div",{className:"skeleton"})]}):null,e(v,{title:t("Home"),rooms:w,...b}),e(v,{title:t("Pinned"),rooms:z,zone:{kind:"pinned",id:"pinned"},...b}),N.length>0?e("div",{className:"stack folder-list","data-folder-list":"",children:e(Q,{fallback:e("div",{className:"skeleton","aria-busy":"true"}),children:e(M,{folders:N,active:o.active,listed:i,rooms:(m)=>e(P,{rooms:m,threads:L,active:o.active,arranging:R})})})}):null,N.length>0?e(v,{title:t("Ungrouped"),rooms:A,zone:{kind:"rest",id:"rest"},...b}):n(g,{children:[e(v,{title:t("Knights"),rooms:T,zone:{kind:"rest",id:"rest-agents"},...b}),e(v,{title:t("Groups"),rooms:D,zone:{kind:"rest",id:"rest-groups"},...b})]}),h.open.length+h.closed.length>0?n("section",{className:"stack",children:[e("h2",{className:"section-title",children:t("Dispatch threads")}),e(Pi,{open:h.open,closed:h.closed,active:o.active})]}):null,e(Gr,{active:o.active})]})}export{re as ArrangedRoomsPage};
@@ -0,0 +1 @@
1
+ import{t,K,O,l,f}from"./chunk-index-wt2asefx.js";import{rn}from"./chunk-index-hef4gwtb.js";import"./chunk-index-4krm48hm.js";import{Tn,Kr}from"./chunk-index-pfs6rm6w.js";import{ie}from"./chunk-index-teyx2hz7.js";import{ho}from"./chunk-index-gp4chnp3.js";import"./chunk-index-aycxt14t.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=ho(n),e=Object.keys(r);if(e.length===0)return;let a=[];try{for(let o of c(e))a.push(...(await Tn.readAll(o)).moved)}catch(o){f(l(o),"danger"),i();return}rn(Object.fromEntries(e.map((o)=>[o,0]))),f(K(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 Tn.unreadAll(e);rn(Object.fromEntries(a.map((o)=>[o,r[o]??0])))}}catch(e){f(l(e),"danger")}i()}var P=(n)=>Kr(n);async function d(n){try{await Tn.restoreHelpers(n)}catch(r){f(l(r),"danger")}i()}async function R(n){let r;try{r=(await Tn.archiveFinishedHelpers(n)).archived.flatMap((a)=>a.names)}catch(e){f(l(e),"danger"),i();return}if(i(),r.length===0)return;f(K(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 ie.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};
@@ -0,0 +1 @@
1
+ import{je,jt,Z,Qi,_n}from"./chunk-index-r0hk9kyd.js";import{j,zr,o,L,C,a,r,t,u,g,e,n,vi,fe,y,l,f,xn,he,Je,Ce}from"./chunk-index-wt2asefx.js";import{D}from"./chunk-index-y6p8j3zv.js";import{R}from"./chunk-index-zdzzf3fp.js";var de={"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 P(i,c){let h=`character.${i}.${c}`,b=t(h);if(b!==h)return b;if(i==="class")return Z.classes[c]?.label??X(c);return de[`${i}.${c}`]??X(c)}function Y(i){let c=`character.jobs.${i}`,h=t(c);return h!==c?h:Z.classes[i]?.jobs??""}var z=[{field:"hat",title:u("Hat"),ids:Z.hats},{field:"outfit",title:u("Outfit"),ids:Z.outfits},{field:"prop",title:u("Prop"),ids:Z.props},{field:"hair",title:u("Hair"),ids:Z.hair},{field:"beard",title:u("Beard"),ids:["none",...Z.beards]},{field:"accessory",title:u("Accessory"),ids:["none",...Z.accessories]}],ue=new Set(["class","colors","palette","build","skin","hairColor",...z.map((i)=>i.field)]),re=Object.keys(Z.palettes),ee={idle:u("Idle"),thinking:u("Thinking"),working:u("Working"),waiting:u("Waiting for you"),done:u("Done"),error:u("Error"),sleepy:u("Sleepy")},me={slim:u("Slim"),regular:u("Regular"),stout:u("Stout")};function W(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 te=(i)=>JSON.stringify(W(i)),v=(i)=>i[Math.floor(Math.random()*i.length)];function be(){return{class:v(je),outfit:v(Z.outfits),hat:v(Z.hats),prop:v(Z.props),hair:v(Z.hair),beard:v(["none",...Z.beards]),accessory:v(["none",...Z.accessories]),build:v(["slim","regular","stout"]),skin:v([0,1,2,3,4,5]),hairColor:v(Z.hairColors),palette:v(re)}}var ie=j(function(c){return n("button",{type:"button",className:"creator-tile","aria-pressed":c.pressed,title:c.hint?`${c.label} — ${c.hint}`:c.label,onClick:c.onPick,...c.data,children:[e(he,{spec:c.spec,size:c.size,live:!1}),e("span",{children:c.label})]})});function ge(i,c,h){let b=JSON.stringify({...i,[c]:0});return C(()=>h.map((d)=>({...i,[c]:d})),[b,c,h])}function pe(){let i=a(null),[c,h]=r();return o(()=>{let b=i.current;if(!b)return;let d=()=>{let N=b.scrollLeft>1,A=b.scrollLeft+b.clientWidth<b.scrollWidth-1;h(N&&A?"both":A?"end":N?"start":void 0)};d(),b.addEventListener("scroll",d,{passive:!0});let p=typeof ResizeObserver>"u"?void 0:new ResizeObserver(d);return p?.observe(b),()=>{b.removeEventListener("scroll",d),p?.disconnect()}},[]),[i,c]}function ye(i){let{part:c}=i,h=ge(i.shown,c.field,c.ids),[b,d]=pe();return e("div",{className:"creator-strip",ref:b,"data-more":d,children:c.ids.map((p,N)=>e(ie,{data:{[`data-${c.field}`]:p},spec:h[N],size:44,label:P(c.field,p),pressed:i.draft[c.field]===p,onPick:()=>i.onPick(p)},p))})}function O(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 w(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 Me(i){let[c,h]=r(i.character),b=zr(c),[d,p]=r({}),[N,A]=r(!1),[F,ne]=r("idle"),[U,I]=r(),[B,_]=r(),G=Ce("(max-width: 719px)"),J=a(null),H=L(),oe=Je(c),se=xn(),E=te(c)!==te(i.character);o(()=>h(i.character),[i.character]),o(()=>{if(!E||i.onPick)return;let s=(k)=>k.preventDefault(),m=(k)=>{if(k.button!==0||k.metaKey||k.ctrlKey||k.shiftKey||k.altKey)return;let T=k.target instanceof Element?k.target.closest("a"):null;if(!T||T.target||T.hasAttribute("download"))return;if(J.current?.contains(T))return;k.preventDefault(),k.stopPropagation(),I({kind:"link",anchor:T})},M=vi((k)=>I({kind:"navigate",proceed:k}));return window.addEventListener("beforeunload",s),document.addEventListener("click",m,!0),()=>{M(),window.removeEventListener("beforeunload",s),document.removeEventListener("click",m,!0)}},[E,i.onPick]);let S=(s)=>{p({}),h((m)=>Qi(s,m))},le=async()=>{if(i.onPick){i.onPick(W(c),c);return}A(!0),p({});try{let s=await y.setCharacter(i.name,W(c));i.onSaved?.(s),f(t("Saved."))}catch(s){let m=s instanceof fe&&s.field?s.field.split(".")[0]:void 0,M=m&&ue.has(m)?m:"*";p({[M]:l(s)})}finally{A(!1)}},ce=async()=>{let s=U;if(h(i.character),p({}),s?.kind==="link")setTimeout(()=>s.anchor.click(),0);else if(s?.kind==="navigate")s.proceed()},V=e(w,{field:"class",title:t("Class"),error:d.class,children:e("div",{className:"creator-grid",children:je.map((s)=>e(ke,{id:s,base:b,pressed:c.class===s,onPick:()=>S({class:s,colors:c.colors})},s))})}),q=n(w,{field:"colors",title:t("Colors"),error:d.colors??d.palette,children:[n("fieldset",{className:"creator-swatches",children:[e("legend",{className:"visually-hidden",children:t("Palette")}),re.map((s)=>{let m=Z.palettes[s];return e(O,{data:{"data-palette":s},label:P("palette",s),pressed:c.palette===s,background:`linear-gradient(135deg, ${m.primary} 52%, ${m.trim} 52%)`,onPick:()=>S({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:c.colors[s],onChange:(m)=>S({colors:{[s]:m.target.value}})})]},s))})]}),x=z.map((s)=>e(w,{field:s.field,title:t(s.title),error:d[s.field],children:e(ye,{part:s,draft:c,shown:b,onPick:(m)=>S({[s.field]:m})})},s.field)),Q=n(g,{children:[e(w,{field:"build",title:t("Build"),error:d.build,children:n("fieldset",{className:"segmented",children:[e("legend",{className:"visually-hidden",children:t("Build")}),["slim","regular","stout"].map((s)=>n("label",{"data-checked":c.build===s,children:[e("input",{type:"radio",name:`${H}-build`,checked:c.build===s,onChange:()=>S({build:s})}),ae(s)]},s))]})}),e(w,{field:"skin",title:t("Skin tone"),error:d.skin,children:n("fieldset",{className:"creator-swatches",children:[e("legend",{className:"visually-hidden",children:t("Skin tone")}),(se??Z.skins).map((s,m)=>e(O,{data:{"data-skin":String(m)},label:t("Skin tone {n}",{n:m+1}),pressed:c.skin===m,background:s,onPick:()=>S({skin:m})},m))]})}),e(w,{field:"hairColor",title:t("Hair color"),error:d.hairColor,children:n("fieldset",{className:"creator-swatches",children:[e("legend",{className:"visually-hidden",children:t("Hair color")}),Z.hairColors.map((s,m)=>e(O,{data:{"data-hair-color":s},label:t("Hair color {n}",{n:m+1}),pressed:c.hairColor===s,background:s,onPick:()=>S({hairColor:s})},s)),e("input",{type:"color","aria-label":t("Hair color"),value:c.hairColor,onChange:(s)=>S({hairColor:s.target.value})})]})})]}),K=[{id:"class",title:t("Class"),summary:P("class",c.class),error:d.class,node:V},{id:"colors",title:t("Colors"),summary:c.palette?P("palette",c.palette):c.colors.primary,error:d.colors??d.palette,node:q},...z.map((s,m)=>({id:s.field,title:t(s.title),summary:P(s.field,c[s.field]),error:d[s.field],node:x[m]})),{id:"body",title:t("Body"),summary:ae(c.build),error:d.build??d.skin??d.hairColor,node:Q}];return n("form",{ref:J,className:"creator",style:oe,"aria-labelledby":H,onSubmit:(s)=>{if(s.preventDefault(),(E||i.onPick)&&!N)le()},children:[e("h2",{id:H,className:"visually-hidden",children:t("Character of {name}",{name:i.displayName})}),n("div",{className:"creator-preview",children:[e(he,{spec:c,name:i.name,state:F,size:176,label:t("{name}, {state}",{name:i.displayName,state:t(ee[F])})}),e("button",{type:"button",className:"secondary","data-action":"cycle",onClick:()=>ne((s)=>jt[(jt.indexOf(s)+1)%jt.length]??"idle"),children:t("Preview states")}),e("span",{className:"meta","aria-live":"polite",children:t(ee[F])})]}),n("div",{className:"creator-body",children:[d["*"]?e("p",{className:"field-error",role:"alert","data-field":"*",children:d["*"]}):null,G?e("ul",{className:"creator-sections",children:K.map((s)=>e("li",{children:n("button",{type:"button",className:"creator-section secondary",onClick:()=>_(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:[V,q,x,Q]}),n("div",{className:"actions creator-actions",children:[e("button",{type:"button",className:"secondary","data-action":"suggest",onClick:()=>{p({}),h(_n({name:i.name,displayName:i.displayName,prompt:i.prompt}))},children:t("Suggest from role")}),e("button",{type:"button",className:"secondary","data-action":"randomize",onClick:()=>S(be()),children:t("Randomize")}),e("button",{type:"button",className:"secondary","data-action":"cancel",onClick:()=>{if(i.onCancel)i.onCancel();else if(E)I({kind:"cancel"})},children:t("Cancel")}),e("button",{type:"submit","data-action":"save",disabled:!E&&!i.onPick||N,children:N?t("Saving…"):i.onPick?t("Use this look"):t("Save")})]})]}),e(R,{open:G&&B!==void 0,title:K.find((s)=>s.id===B)?.title??"",onClose:()=>_(void 0),children:e("div",{className:"stack",children:K.find((s)=>s.id===B)?.node})}),e(D,{open:U!==void 0,title:t("Discard your changes?"),confirmLabel:t("Discard"),cancelLabel:t("Keep editing"),tone:"danger",onClose:()=>I(void 0),onConfirm:ce,children:e("p",{children:t("The new look for {name} has not been saved.",{name:i.displayName})})})]})}var ae=(i)=>t(me[i]);function ke(i){let c=i.base.colors,h=C(()=>Qi({class:i.id,colors:c}),[i.id,c]);return e(ie,{data:{"data-class":i.id},spec:h,size:56,label:P("class",i.id),hint:Y(i.id),pressed:i.pressed,onPick:i.onPick})}export{Me as CharacterCreator};
@@ -1,2 +1,2 @@
1
- import{B,ge,Ei,wo,Ai,pt,Oe,c,w,Me,Ve,It,qe,G,le,ce,V,bt,vt,Be,ye,L,oe,Ae,b,Tt,ko,_o,To,$i,Kn,Po,Qo,Mo,Ro,P,i,X,it,Vt,ti,mr,Qn,Mn,Ao,$o,gt}from"./chunk-index-zcfr8jdv.js";import{p}from"./chunk-index-cn49mawx.js";var nn=(e)=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=be(e.state,n.from);return r.line?rn(e):r.block?ln(e):!1};function ve(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=ve(an,0);var on=ve(Xe,0);var ln=ve((e,t)=>Xe(e,t,cn(t)),0);function be(e,t){let n=e.languageDataAt("commentTokens",t,1);return n.length?n[0]:{}}var q=50;function sn(e,{open:t,close:n},r,o){let l=e.sliceDoc(r-q,r),s=e.sliceDoc(o,o+q),a=/\s*$/.exec(l)[0].length,u=/^\s*/.exec(s)[0].length,f=l.length-a;if(l.slice(f-t.length,f)==t&&s.slice(u,u+n.length)==n)return{open:{pos:r-a,margin:a&&1},close:{pos:o+u,margin:u&&1}};let h,d;if(o-r<=2*q)h=d=e.sliceDoc(r,o);else h=e.sliceDoc(r,r+q),d=e.sliceDoc(o-q,o);let m=/^\s*/.exec(h)[0].length,D=/\s*$/.exec(d)[0].length,v=d.length-D-n.length;if(h.slice(m,m+t.length)==t&&d.slice(v,v+n.length)==n)return{open:{pos:r+m+t.length,margin:/\s/.test(h.charAt(m+t.length))?1:0},close:{pos:o-D-n.length,margin:/\s/.test(d.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 Xe(e,t,n=t.selection.ranges){let r=n.map((l)=>be(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,a;s<o.length;s++)if(a=o[s]){let u=r[s],{open:f,close:h}=a;l.push({from:f.pos-u.open.length,to:f.pos+f.margin},{from:h.pos-h.margin,to:h.pos+u.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 a=r.length,u=1e9,f;for(let h=l;h<=s;){let d=t.doc.lineAt(h);if(f==null){if(f=be(t,d.from).line,!f)continue e}if(d.from>o&&(l==s||s>d.from)){o=d.from;let m=/^\s*/.exec(d.text)[0].length,D=m==d.length,v=d.text.slice(m,m+f.length)==f?m:-1;if(m<d.text.length&&m<u)u=m;r.push({line:d,comment:v,token:f,indent:m,empty:D,single:!1})}h=d.to+1}if(u<1e9){for(let h=a;h<r.length;h++)if(r[h].indent<r[h].line.text.length)r[h].indent=u}if(r.length==a+1)r[a].single=!0}if(e!=2&&r.some((l)=>l.comment<0&&(!l.empty||l.single))){let l=[];for(let{line:a,token:u,indent:f,empty:h,single:d}of r)if(d||!h)l.push({from:a.from+f,insert:u+" "});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:a,token:u}of r)if(a>=0){let f=s.from+a,h=f+u.length;if(s.text[h-s.from]==" ")h++;l.push({from:f,to:h})}return{changes:l}}return null}var xe=qe.define(),un=qe.define(),hn=w.define(),Ye=w.define({combine(e){return bt(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)})}}),Ze=Me.define({create(){return A.empty},update(e,t){let n=t.state.facet(Ye),r=t.annotation(xe);if(r){let u=y.fromTransaction(t,r.selection),f=r.side,h=f==0?e.undone:e.done;if(u)h=H(h,h.length,n.minDepth,u);else h=nt(h,t.startState.selection);return new A(f==0?r.rest:h,f==0?h: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),a=t.annotation(le.userEvent);if(l)e=e.addChanges(l,s,a,n,t);else if(t.selection)e=e.addSelection(t.startState.selection,s,a,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[Ze,Ye.of(e),b.domEventHandlers({beforeinput(t,n){let r=t.inputType=="historyUndo"?j:t.inputType=="historyRedo"?U:null;if(!r)return!1;return t.preventDefault(),r(n)}})]}function Q(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let o=n.field(Ze,!1);if(!o)return!1;let l=o.pop(e,n,t);if(!l)return!1;return r(l),!0}}var j=Q(0,!1),U=Q(1,!1),fn=Q(0,!0),dn=Q(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&&Oe.fromJSON(e.changes),[],e.mapped&&pt.fromJSON(e.mapped),e.startSelection&&c.fromJSON(e.startSelection),e.selectionsAfter.map(c.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 H(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,a)=>{for(let u=0;u<n.length;){let f=n[u++],h=n[u++];if(a>=f&&s<=h)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),H(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((a)=>a.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,G.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=H(l,l.length-1,r.minDepth,new y(e.changes.compose(s.changes),tt(G.mapEffects(e.effects,s.changes),s.effects),s.mapped,s.startSelection,S));else l=H(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:xe.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:xe.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: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 c.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=O(e.selection,n);if(r.eq(e.selection,!0))return!1;return t(C(e,r)),!0}function Y(e,t){return c.cursor(t?e.to:e.from)}function ot(e,t){return M(e,(n)=>n.empty?e.moveByChar(n,t):Y(n,t))}function g(e){return e.textDirectionAt(e.state.selection.main.head)==oe.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):Y(n,t))}var kn=(e)=>ct(e,!g(e)),vn=(e)=>ct(e,g(e));var $r=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=X(e).resolveInner(t.head),o=n?P.closedBy:P.openedBy;for(let u=t.head;;){let f=n?r.childAfter(u):r.childBefore(u);if(!f)break;if(bn(e,f,o))r=f;else u=n?f.to:f.from}let l=r.type.prop(o),s,a;if(l&&(s=n?gt(e,r.from,1):gt(e,r.to,-1))&&s.matched)a=n?s.end.to:s.end.from;else a=n?r.to:r.from;return c.cursor(a,n?-1:1)}var Cn=(e)=>M(e,(t)=>Z(e.state,t,!g(e))),An=(e)=>M(e,(t)=>Z(e.state,t,g(e)));function at(e,t){return M(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(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=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),a=e.scrollDOM.getBoundingClientRect(),u=a.top+n.marginTop,f=a.bottom-n.marginBottom;if(s&&s.top>u&&s.bottom<f)l=b.scrollIntoView(o.main.head,{y:"start",yMargin:s.top-u})}return e.dispatch(C(r,o),{effects:l}),!0}var ze=(e)=>dt(e,!1),Se=(e)=>dt(e,!0);function E(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=c.cursor(r.from+l)}return o}var Ln=(e)=>M(e,(t)=>E(e,t,!0)),Bn=(e)=>M(e,(t)=>E(e,t,!1)),Dn=(e)=>M(e,(t)=>E(e,t,!g(e))),En=(e)=>M(e,(t)=>E(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=O(e.selection,(l)=>{let s=gt(e,l.head,-1)||gt(e,l.head,1)||l.head>0&&gt(e,l.head-1,1)||l.head<e.doc.length&&gt(e,l.head+1,-1);if(!s||!s.end)return l;r=!0;let a=s.start.from==l.head?s.end.to:s.end.from;return n?c.range(l.anchor,a):c.cursor(a)});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=O(e.state.selection,(o)=>{if(o.undirectional&&o.head>=o.anchor!=t)o=c.range(o.head,o.anchor);let l=n(o);return c.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 mt(e,t){return k(e,t,(n)=>e.moveByChar(n,t))}var yt=(e)=>mt(e,!g(e)),xt=(e)=>mt(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)=>Z(e.state,n,t))},Pn=(e)=>{let t=g(e);return k(e,t,(n)=>Z(e.state,n,t))};function kt(e,t){return k(e,t,(n)=>e.moveVertically(n,t))}var Ct=(e)=>kt(e,!1),Mt=(e)=>kt(e,!0);function At(e,t){return k(e,t,(n)=>e.moveVertically(n,t,ft(e).height))}var _e=(e)=>At(e,!1),Je=(e)=>At(e,!0),Nn=(e)=>k(e,!0,(t)=>E(e,t,!0)),qn=(e)=>k(e,!1,(t)=>E(e,t,!1)),Vn=(e)=>{let t=!g(e);return k(e,t,(n)=>E(e,n,t))},Gn=(e)=>{let t=g(e);return k(e,t,(n)=>E(e,n,t))},Un=(e)=>k(e,!1,(t)=>c.cursor(e.lineBlockAt(t.head).from)),zn=(e)=>k(e,!0,(t)=>c.cursor(e.lineBlockAt(t.head).to)),$e=({state:e,dispatch:t})=>(t(C(e,{anchor:0})),!0),Ke=({state:e,dispatch:t})=>(t(C(e,{anchor:e.doc.length})),!0),He=({state:e,dispatch:t})=>(t(C(e,{anchor:e.selection.main.anchor,head:0})),!0),Qe=({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})=>c.undirectionalRange(r,Math.min(o+1,e.doc.length)));return t(e.update({selection:c.create(n),userEvent:"select"})),!0},$n=({state:e,dispatch:t})=>{let n=O(e.selection,(r)=>{let o=X(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:a}=s;if((a.from<r.from&&a.to>=r.to||a.to>r.to&&a.from<=r.from)&&s.next)return c.undirectionalRange(a.from,a.to)}return r});if(n.eq(e.selection))return!1;return t(C(e,n)),!0};function Lt(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 a=l;;){let u=e.moveVertically(a,t);if(u.head<s.from||u.head>s.to){if(!o.some((f)=>f.head==u.head))o.push(u);break}else if(u.head==a.head)break;else a=u}}if(o.length==r.ranges.length)return!1;return e.dispatch(C(n,c.create(o,o.length-1))),!0}var Hn=(e)=>Lt(e,!1),jn=(e)=>Lt(e,!0),Xn=({state:e,dispatch:t})=>{let n=e.selection,r=null;if(n.ranges.length>1)r=c.create([n.main]);else if(!n.main.empty)r=c.create([c.cursor(n.main.head)]);if(!r)return!1;return t(C(e,r)),!0};function z(e,t){if(e.state.readOnly)return!1;let n="delete.selection",{state:r}=e,o=r.changeByRange((l)=>{let{from:s,to:a}=l;if(s==a){let u=t(l);if(u<s)n="delete.backward",u=K(e,u,!1);else if(u>s)n="delete.forward",u=K(e,u,!0);s=Math.min(s,u),a=Math.max(a,u)}else s=K(e,s,!1),a=K(e,a,!0);return s==a?{range:l}:{changes:{from:s,to:a},range:c.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 K(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 Bt=(e,t,n)=>z(e,(r)=>{let o=r.from,{state:l}=e,s=l.doc.lineAt(o),a,u;if(n&&!t&&o>s.from&&o<s.from+200&&!/[^ \t]/.test(a=s.text.slice(0,o-s.from))){if(a[a.length-1]=="\t")return o-1;let f=Be(a,l.tabSize),h=f%Vt(l)||Vt(l);for(let d=0;d<h&&a[a.length-1-d]==" ";d++)o--;u=o}else if(u=ge(s.text,o-s.from,t,t)+s.from,u==o&&s.number!=(t?l.doc.lines:1))u+=t?1:-1;else if(!t&&/[\ufe00-\ufe0f]/.test(s.text.slice(u-s.from,o-s.from)))u=ge(s.text,u-s.from,!1,!1)+s.from;return u}),ke=(e)=>Bt(e,!1,!0);var Dt=(e)=>Bt(e,!0,!1),Et=(e,t)=>z(e,(n)=>{let r=n.head,{state:o}=e,l=o.doc.lineAt(r),s=o.charCategorizer(r);for(let a=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 u=ge(l.text,r-l.from,t)+l.from,f=l.text.slice(Math.min(r,u)-l.from,Math.max(r,u)-l.from),h=s(f);if(a!=null&&h!=a)break;if(f!=" "||r!=n.head)a=h;r=u}return r}),wt=(e)=>Et(e,!1),Yn=(e)=>Et(e,!0);var Zn=(e)=>z(e,(t)=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)});var er=(e)=>z(e,(t)=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),tr=(e)=>z(e,(t)=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)});var nr=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange((r)=>({changes:{from:r.from,to:r.to,insert:B.of(["",""])},range:c.cursor(r.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:"input"})),!0},rr=({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:ge(l.text,o-l.from,!1)+l.from,a=o==l.to?o+1:ge(l.text,o-l.from,!0)+l.from;return{changes:{from:s,to:a,insert:e.doc.slice(o,a).append(e.doc.slice(s,o))},range:c.cursor(a)}});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),a=s.length+1;if(n){r.push({from:l.to,to:s.to},{from:l.from,insert:s.text+e.lineBreak});for(let u of l.ranges)o.push(c.range(Math.min(e.doc.length,u.anchor+a),Math.min(e.doc.length,u.head+a)))}else{r.push({from:s.from,to:l.from},{from:l.to,insert:e.lineBreak+s.text});for(let u of l.ranges)o.push(c.range(u.anchor-a,u.head-a))}}if(!r.length)return!1;return t(e.update({changes:r,scrollIntoView:!0,selection:c.create(o,e.selection.mainIndex),userEvent:"move.line"})),!0}var or=({state:e,dispatch:t})=>Wt(e,t,!1),lr=({state:e,dispatch:t})=>Wt(e,t,!0);function Rt(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 ir=({state:e,dispatch:t})=>Rt(e,t,!1),sr=({state:e,dispatch:t})=>Rt(e,t,!0),cr=(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),a=e.coordsAtPos(o.head,o.assoc||1);if(a)l=s.bottom+e.documentTop-a.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 ar(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=X(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(P.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 je=Ot(!1),ur=Ot(!0);function Ot(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=t.changeByRange((o)=>{let{from:l,to:s}=o,a=t.doc.lineAt(l),u=!e&&l==s&&ar(t,l);if(e)l=s=(s<=a.to?a:t.doc.lineAt(s)).to;let f=new Qn(t,{simulateBreak:l,simulateDoubleBreak:!!u}),h=mr(f,l);if(h==null)h=Be(/^\s*/.exec(t.doc.lineAt(l).text)[0],t.tabSize);while(s<a.to&&/\s/.test(a.text[s-a.from]))s++;if(u)({from:l,to:s}=u);else if(l>a.from&&l<a.from+100&&!/\S/.test(a.text.slice(0,l)))l=a.from;let d=["",ti(t,h)];if(u)d.push(ti(t,f.lineIndent(a.from,-1)));return{changes:{from:l,to:s,insert:B.of(d)},range:c.cursor(l+1+d[1].length)}});return n(t.update(r,{scrollIntoView:!0,userEvent:"input"})),!0}}function Ce(e,t){let n=-1;return e.changeByRange((r)=>{let o=[];for(let s=r.from;s<=r.to;){let a=e.doc.lineAt(s);if(a.number>n&&(r.empty||r.to>a.from))t(a,o,r),n=a.number;s=a.to+1}let l=e.changes(o);return{changes:o,range:c.range(l.mapPos(r.anchor,1),l.mapPos(r.head,1))}})}var hr=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new Qn(e,{overrideIndentation:(l)=>{let s=n[l];return s==null?-1:s}}),o=Ce(e,(l,s,a)=>{let u=mr(r,l.from);if(u==null)return;if(!/\S/.test(l.text))u=0;let f=/^\s*/.exec(l.text)[0],h=ti(e,u);if(f!=h||a.from<l.from+f.length)n[l.from]=u,s.push({from:l.from,to:l.from+f.length,insert:h})});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(Ce(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(Ce(e,(n,r)=>{let o=/^\s*/.exec(n.text)[0];if(!o)return;let l=Be(o,e.tabSize),s=0,a=ti(e,Math.max(0,l-Vt(e)));while(s<o.length&&s<a.length&&o.charCodeAt(s)==a.charCodeAt(s))s++;r.push({from:n.from+s,to:n.from+o.length,insert:a.slice(s)})}),{userEvent:"delete.dedent"})),!0},fr=(e)=>(e.setTabFocusMode(),!0);var dr=[{key:"Ctrl-b",run:lt,shift:yt,preventDefault:!0},{key:"Ctrl-f",run:st,shift:xt},{key:"Ctrl-p",run:ut,shift:Ct},{key:"Ctrl-n",run:ht,shift:Mt},{key:"Ctrl-a",run:Tn,shift:Un},{key:"Ctrl-e",run:wn,shift:zn},{key:"Ctrl-d",run:Dt},{key:"Ctrl-h",run:ke},{key:"Ctrl-k",run:Zn},{key:"Ctrl-Alt-h",run:wt},{key:"Ctrl-o",run:nr},{key:"Ctrl-t",run:rr},{key:"Ctrl-v",run:Se}],pr=[{key:"ArrowLeft",run:lt,shift:yt,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:xt,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:Ct,preventDefault:!0},{mac:"Cmd-ArrowUp",run:$e,shift:He},{mac:"Ctrl-ArrowUp",run:ze,shift:_e},{key:"ArrowDown",run:ht,shift:Mt,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Ke,shift:Qe},{mac:"Ctrl-ArrowDown",run:Se,shift:Je},{key:"PageUp",run:ze,shift:_e},{key:"PageDown",run:Se,shift:Je},{key:"Home",run:Bn,shift:qn,preventDefault:!0},{key:"Mod-Home",run:$e,shift:He},{key:"End",run:Ln,shift:Nn,preventDefault:!0},{key:"Mod-End",run:Ke,shift:Qe},{key:"Enter",run:je,shift:je},{key:"Mod-a",run:_n},{key:"Backspace",run:ke,shift:ke,preventDefault:!0},{key:"Delete",run:Dt,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:wt,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:Yn,preventDefault:!0},{mac:"Mod-Backspace",run:er,preventDefault:!0},{mac:"Mod-Delete",run:tr,preventDefault:!0}].concat(dr.map((e)=>({mac:e.key,run:e.run,shift:e.shift}))),Pt=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:Cn,shift:In},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:An,shift:Pn},{key:"Alt-ArrowUp",run:or},{key:"Shift-Alt-ArrowUp",run:ir},{key:"Alt-ArrowDown",run:lr},{key:"Shift-Alt-ArrowDown",run:sr},{key:"Mod-Alt-ArrowUp",run:Hn},{key:"Mod-Alt-ArrowDown",run:jn},{key:"Escape",run:Xn},{key:"Mod-Enter",run:ur},{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:hr},{key:"Shift-Mod-k",run:cr},{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:fr}].concat(pr),Nt={key:"Tab",run:te,shift:Ft};var qt=typeof String.prototype.normalize=="function"?(e)=>e.normalize("NFKD"):(e)=>e;class W{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(qt(s)):qt,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 Ei(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=wo(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=Ai(e);let r=this.normalize(t);if(r.length)for(let o=0,l=n,s=!0;;o++){let a=r.charCodeAt(o),u=this.match(a,l,s,this.bufferPos+this.bufferStart,o==r.length-1);if(u)return this.value=u,this;if(o==r.length-1)break;if(s&&o<t.length&&t.charCodeAt(o)==a)l++;else s=!1}}}match(e,t,n,r,o){let l=null;for(let s=0;s<this.matches.length;){let a=this.matches[s],u=!1;if(this.query.charCodeAt(a.index)==e)if(a.index==this.query.length-1)l={from:a.from,to:r,precise:o&&a.precise};else a.index++,u=!0;if(u)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")W.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=se(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=se(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 Le=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=Le.get(e);if(!r||r.from>=n||r.to<=t){let s=new N(t,e.sliceString(t,n));return Le.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 Le.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=se(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=se(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 gr(e){try{return new RegExp(e,Te),!0}catch(t){return!1}}function se(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 yr=(e)=>{let t=Qo(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}=Po(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 a=s&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(s.elements.line.value);if(!a){e.dispatch({effects:o});return}let u=n.doc.lineAt(n.selection.main.head),[,f,h,d,m]=a,D=d?+d.slice(1):0,v=h?+h:u.number;if(h&&m){let me=v/100;if(f)me=me*(f=="-"?-1:1)+u.number/n.doc.lines;v=Math.round(n.doc.lines*me)}else if(h&&f)v=v*(f=="-"?-1:1)+u.number;let Ge=n.doc.line(Math.max(1,Math.min(n.doc.lines,v))),Ue=c.cursor(Ge.from+Math.max(0,Math.min(D,Ge.length)));e.dispatch({effects:[o,b.scrollIntoView(Ue.from,{y:"center"})],selection:Ue})}),!0},xr={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},_t=w.define({combine(e){return bt(e,xr,{highlightWordAroundCursor:(t,n)=>t||n,minSelectionLength:Math.min,maxMatches:Math.min})}});function Jt(e){let t=[Cr,br];if(e)t.push(_t.of(e));return t}var Sr=L.mark({class:"cm-selectionMatch"}),kr=L.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function Gt(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 vr(e,t,n,r){return e(t.sliceDoc(n,n+1))==ce.Word&&e(t.sliceDoc(r-1,r))==ce.Word}var br=Ae.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 L.none;let o=r.main,l,s=null;if(o.empty){if(!t.highlightWordAroundCursor)return L.none;let u=n.wordAt(o.head);if(!u)return L.none;s=n.charCategorizer(o.head),l=n.sliceDoc(u.from,u.to)}else{let u=o.to-o.from;if(u<t.minSelectionLength||u>200)return L.none;if(t.wholeWords){if(l=n.sliceDoc(o.from,o.to),s=n.charCategorizer(o.head),!(Gt(s,n,o.from,o.to)&&vr(s,n,o.from,o.to)))return L.none}else if(l=n.sliceDoc(o.from,o.to),!l)return L.none}let a=[];for(let u of e.visibleRanges){let f=new W(n.doc,l,u.from,u.to);while(!f.next().done){let{from:h,to:d}=f.value;if(!s||Gt(s,n,h,d)){if(o.empty&&h<=o.from&&d>=o.to)a.push(kr.range(h,d));else if(h>=o.to||d<=o.from)a.push(Sr.range(h,d));if(a.length>t.maxMatches)return L.none}}}return L.set(a)}},{decorations:(e)=>e.decorations}),Cr=b.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),Mr=({state:e,dispatch:t})=>{let{selection:n}=e,r=c.create(n.ranges.map((o)=>e.wordAt(o.head)||c.cursor(o.head)),n.mainIndex);if(r.eq(n))return!1;return t(e.update({selection:r})),!0};function Ar(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,a=new W(e.doc,t,r[r.length-1].to);;)if(a.next(),a.done){if(s)return null;a=new W(e.doc,t,0,Math.max(0,r[r.length-1].from-1)),s=!0}else{if(s&&r.some((u)=>u.from==a.value.from))continue;if(l){let u=e.wordAt(a.value.from);if(!u||u.from!=a.value.from||u.to!=a.value.to)continue}return a.value}}var Lr=({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some((l)=>l.from===l.to))return Mr({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=Ar(e,r);if(!o)return!1;return t(e.update({selection:e.selection.addRange(c.range(o.from,o.to),!1),effects:b.scrollIntoView(o.to)})),!0},R=w.define({combine(e){return bt(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?[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||gr(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:V.create({doc:e});if(n==null)n=r.doc.length;return this.regexp?I(this,r,t,n):F(this,r,t,n)}}class Fe{constructor(e){this.spec=e}}function Br(e,t,n){return(r,o,l,s)=>{if(n&&!n(r,o,l,s))return!1;let a=r>=s&&o<=s+l.length?l.slice(r-s,o-s):t.doc.sliceString(r,o);return e(a,t,r,o)}}function F(e,t,n,r){let o;if(e.wholeWord)o=Dr(t.doc,t.charCategorizer(t.selection.main.head));if(e.test)o=Br(e.test,t,o);return new W(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:(l)=>l.toLowerCase(),o)}function Dr(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 Fe{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 Er(e,t,n){return(r,o,l)=>(!n||n(r,o,l))&&e(l[0],t,r,o)}function I(e,t,n,r){let o;if(e.wholeWord)o=Tr(t.charCategorizer(t.selection.main.head));if(e.test)o=Er(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(ge(e,t,!1),t)}function ue(e,t){return e.slice(t,ge(e,t))}function Tr(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 Fe{nextMatch(e,t,n){let r=I(this.spec,e,n,e.doc.length).next();if(r.done)r=I(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=I(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=I(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=I(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 _=G.define(),Ie=G.define(),T=Me.define({create(e){return new ie(De(e).create(),null)},update(e,t){for(let n of t.effects)if(n.is(_))e=new ie(n.value.create(),e.panel);else if(n.is(Ie))e=new ie(e.query,n.value?Pe:null);return e},provide:(e)=>Kn.from(e,(t)=>t.panel)});class ie{constructor(e,t){this.query=e,this.panel=t}}var wr=L.mark({class:"cm-searchMatch"}),Wr=L.mark({class:"cm-searchMatch cm-searchMatch-selected"}),Rr=Ae.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(T))}update(e){let t=e.state.field(T);if(t!=e.startState.field(T)||e.docChanged||e.selectionSet||e.viewportChanged)this.decorations=this.highlight(t)}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return L.none;let{view:n}=this,r=new vt;for(let o=0,l=n.visibleRanges,s=l.length;o<s;o++){let{from:a,to:u}=l[o];while(o<s-1&&u>l[o+1].from-500)u=l[++o].to;e.highlight(n.state,a,u,(f,h)=>{let d=n.state.selection.ranges.some((m)=>m.from==f&&m.to==h);r.add(f,h,d?Wr:wr)})}return r.finish()}},{decorations:(e)=>e.decorations});function J(e){return(t)=>{let n=t.state.field(T,!1);return n&&n.query.spec.valid?e(t,n):de(t)}}var he=J((e,{query:t})=>{let{to:n}=e.state.selection.main,r=t.nextMatch(e.state,n,n);if(!r)return!1;let o=c.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=J((e,{query:t})=>{let{state:n}=e,{from:r}=n.selection.main,o=t.prevMatch(n,r,r);if(!o)return!1;let l=c.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}),Or=J((e,{query:t})=>{let n=t.matchAll(e.state,1000);if(!n||!n.length)return!1;return e.dispatch({selection:c.create(n.map((r)=>c.range(r.from,r.to))),userEvent:"select.search.matches"}),!0}),Fr=({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 a=new W(e.doc,e.sliceDoc(r,o));!a.next().done;){if(l.length>1000)return!1;if(a.value.from==r)s=l.length;l.push(c.range(a.value.from,a.value.to))}return t(e.update({selection:c.create(l,s),userEvent:"select.search.matches"})),!0},Ut=J((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,a=[],u,f,h=[];if(!s.precise)s=t.nextMatch(n,s.from,s.to);else if(s.from==r&&s.to==o)f=n.toText(t.getReplacement(s)),a.push({from:s.from,to:s.to,insert:f}),s=t.nextMatch(n,s.from,s.to),h.push(b.announce.of(n.phrase("replaced match on line $",n.doc.lineAt(r).number)+"."));let d=e.state.changes(a);if(s)u=c.single(s.from,s.to).map(d),h.push(Ne(e,s)),h.push(n.facet(R).scrollToMatch(u.main,e));return e.dispatch({changes:d,selection:u,effects:h,userEvent:"input.replace"}),!0}),Ir=J((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:a}=o;if(a)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 Pe(e){return e.state.facet(R).createPanel(e)}function De(e,t){var n,r,o,l,s;let a=e.selection.main,u=a.empty||a.to>a.from+100?"":e.sliceDoc(a.from,a.to);if(t&&!u)return t;let f=e.facet(R);return new Re({search:((n=t===null||t===void 0?void 0:t.literal)!==null&&n!==void 0?n:f.literal)?u:u.replace(/\n/g,"\\n"),caseSensitive:(r=t===null||t===void 0?void 0:t.caseSensitive)!==null&&r!==void 0?r:f.caseSensitive,literal:(o=t===null||t===void 0?void 0:t.literal)!==null&&o!==void 0?o:f.literal,regexp:(l=t===null||t===void 0?void 0:t.regexp)!==null&&l!==void 0?l:f.regexp,wholeWord:(s=t===null||t===void 0?void 0:t.wholeWord)!==null&&s!==void 0?s:f.wholeWord})}function Qt(e){let t=$i(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(T,!1);if(t&&t.panel){let n=Qt(e);if(n&&n!=e.root.activeElement){let r=De(e.state,t.query.spec);if(r.valid)e.dispatch({effects:_.of(r)});n.focus(),n.select()}}else e.dispatch({effects:[Ie.of(!0),t?_.of(De(e.state,t.query.spec)):G.appendConfig.of(Ee)]});return!0},Xt=(e)=>{let t=e.state.field(T,!1);if(!t||!t.panel)return!1;let n=$i(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:Fr},{key:"Mod-Alt-g",run:yr},{key:"Mod-d",run:Lr,preventDefault:!0}];class Zt{constructor(e){this.view=e;let t=this.query=e.state.field(T).query.spec;this.commit=this.commit.bind(this),this.searchField=ye("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=ye("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=ye("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=ye("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=ye("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit});function n(r,o,l){return ye("button",{class:"cm-button",name:r,onclick:o,type:"button"},l)}this.dom=ye("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",()=>Or(e),[x(e,"all")]),ye("label",null,[this.caseField,x(e,"match case")]),ye("label",null,[this.reField,x(e,"regexp")]),ye("label",null,[this.wordField,x(e,"by word")]),...e.state.readOnly?[]:[ye("br"),this.replaceField,n("replace",()=>Ut(e),[x(e,"replace")]),n("replaceAll",()=>Ir(e),[x(e,"replace all")])],ye("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:_.of(e)})}keydown(e){if(ko(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(_)&&!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),a=e.state.sliceDoc(l,s);if(l!=r.from){for(let u=0;u<ne;u++)if(!re.test(a[u+1])&&re.test(a[u])){a=a.slice(u);break}}if(s!=o){for(let u=a.length-1;u>a.length-ne;u--)if(!re.test(a[u-1])&&re.test(a[u])){a=a.slice(0,u);break}}return b.announce.of(`${e.state.phrase("current match")}. ${a} ${e.state.phrase("on line")} ${r.number}.`)}var Pr=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"}}),Ee=[T,Ve.low(Rr),Pr];var Nr=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)"}}),qr=Mn.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=[Nr,Ao(qr)];var Vr={typescript:()=>(p("2v652sh5"),import("./chunk-lang-typescript-2v652sh5.js")),javascript:()=>(p("vgxmgd0a"),import("./chunk-lang-javascript-vgxmgd0a.js")),json:()=>(p("hr12bzs1"),import("./chunk-lang-json-hr12bzs1.js")),markdown:()=>(p("ttzcpgkg"),import("./chunk-lang-markdown-ttzcpgkg.js")),css:()=>(p("7q1dtpgm"),import("./chunk-lang-css-7q1dtpgm.js")),html:()=>(p("xgvba8rn"),import("./chunk-lang-html-xgvba8rn.js")),python:()=>(p("ntj8maem"),import("./chunk-lang-python-ntj8maem.js")),yaml:()=>(p("ex31qbph"),import("./chunk-lang-yaml-ex31qbph.js")),go:()=>(p("9k4y107e"),import("./chunk-lang-go-9k4y107e.js")),rust:()=>(p("gv8y859d"),import("./chunk-lang-rust-gv8y859d.js")),sql:()=>(p("6vmze4pg"),import("./chunk-lang-sql-6vmze4pg.js")),xml:()=>(p("r2sbqnjv"),import("./chunk-lang-xml-r2sbqnjv.js")),shell:()=>(p("5zzs09b7"),import("./chunk-lang-shell-5zzs09b7.js")),toml:()=>(p("tt0d4rw9"),import("./chunk-lang-toml-tt0d4rw9.js")),dockerfile:()=>(p("n4bt8jbt"),import("./chunk-lang-dockerfile-n4bt8jbt.js"))};async function tn(e){if(e==="plain")return;try{return(await Vr[e]()).language()}catch(t){console.warn("a language for the editor failed to load",t);return}}function Gr(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 uo(e){let t=new It,n=new It,r=new It,o=await tn(e.language),l=(d)=>[V.readOnly.of(!d),b.editable.of(d)],s={editable:e.editable,wrap:e.wrap,language:o??[]},a,u=(d)=>[Mo(),To(),Ro(),et(),_o(),$o(),Jt(),$t({top:!0}),it.of(" "),V.phrases.of(e.phrases),en,Tt.of([{key:"Mod-s",preventDefault:!0,run:()=>(e.onSave(),!0)},{key:"Escape",run:()=>(e.onEscape(),!0)},Nt,...Yt,...rt,...Pt]),V.lineSeparator.of(d),t.of(l(s.editable)),n.of(s.wrap?b.lineWrapping:[]),r.of(s.language),b.updateListener.of((m)=>{if(m.docChanged)e.onChange()})],f=Gr(e.parent),h=new b({parent:f.parent,root:f.root,state:V.create({doc:e.text,extensions:u(e.eol)})});return a=h.state.doc,{text:()=>h.state.doc.sliceString(0,void 0,h.state.lineBreak),dirty:()=>a===void 0||!h.state.doc.eq(a),snapshot:()=>h.state.doc,markSaved:(d)=>{a=d??h.state.doc},replace:(d,m)=>{let D=h.scrollDOM.scrollTop;h.setState(V.create({doc:d,extensions:u(m)})),a=h.state.doc,h.scrollDOM.scrollTop=D},setEditable:(d)=>{s.editable=d,h.dispatch({effects:t.reconfigure(l(d))})},setWrap:(d)=>{s.wrap=d,h.dispatch({effects:n.reconfigure(d?b.lineWrapping:[])})},setLanguage:async(d)=>{s.language=await tn(d)??[],h.dispatch({effects:r.reconfigure(s.language)})},undo:()=>{j(h)},redo:()=>{U(h)},find:()=>{de(h)},tab:()=>{te(h)},focus:()=>h.focus(),scrollTop:()=>h.scrollDOM.scrollTop,scrollTo:(d)=>{h.scrollDOM.scrollTop=d},destroy:()=>h.destroy()}}export{uo as createEditor};
1
+ import{B,Oe,Ni,_o,Li,ht,ye,c,w,Qe,Ve,Dt,qe,G,le,ce,q,bt,vt,Be,be,z,oe,$e,b,_t,To,Po,Qo,Xi,ti,Mo,Ro,Co,Eo,P,i,I,nt,qt,ri,br,Rn,Cn,No,Lo,mt}from"./chunk-index-evhaaqzk.js";import{p}from"./chunk-index-wt2asefx.js";var nn=(e)=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=ve(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(Xe,0);var ln=ke((e,t)=>Xe(e,t,cn(t)),0);function ve(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),a=/\s*$/.exec(l)[0].length,u=/^\s*/.exec(s)[0].length,f=l.length-a;if(l.slice(f-t.length,f)==t&&s.slice(u,u+n.length)==n)return{open:{pos:r-a,margin:a&&1},close:{pos:o+u,margin:u&&1}};let h,d;if(o-r<=2*V)h=d=e.sliceDoc(r,o);else h=e.sliceDoc(r,r+V),d=e.sliceDoc(o-V,o);let m=/^\s*/.exec(h)[0].length,L=/\s*$/.exec(d)[0].length,v=d.length-L-n.length;if(h.slice(m,m+t.length)==t&&d.slice(v,v+n.length)==n)return{open:{pos:r+m+t.length,margin:/\s/.test(h.charAt(m+t.length))?1:0},close:{pos:o-L-n.length,margin:/\s/.test(d.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 Xe(e,t,n=t.selection.ranges){let r=n.map((l)=>ve(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,a;s<o.length;s++)if(a=o[s]){let u=r[s],{open:f,close:h}=a;l.push({from:f.pos-u.open.length,to:f.pos+f.margin},{from:h.pos-h.margin,to:h.pos+u.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 a=r.length,u=1e9,f;for(let h=l;h<=s;){let d=t.doc.lineAt(h);if(f==null){if(f=ve(t,d.from).line,!f)continue e}if(d.from>o&&(l==s||s>d.from)){o=d.from;let m=/^\s*/.exec(d.text)[0].length,L=m==d.length,v=d.text.slice(m,m+f.length)==f?m:-1;if(m<d.text.length&&m<u)u=m;r.push({line:d,comment:v,token:f,indent:m,empty:L,single:!1})}h=d.to+1}if(u<1e9){for(let h=a;h<r.length;h++)if(r[h].indent<r[h].line.text.length)r[h].indent=u}if(r.length==a+1)r[a].single=!0}if(e!=2&&r.some((l)=>l.comment<0&&(!l.empty||l.single))){let l=[];for(let{line:a,token:u,indent:f,empty:h,single:d}of r)if(d||!h)l.push({from:a.from+f,insert:u+" "});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:a,token:u}of r)if(a>=0){let f=s.from+a,h=f+u.length;if(s.text[h-s.from]==" ")h++;l.push({from:f,to:h})}return{changes:l}}return null}var ge=qe.define(),un=qe.define(),hn=w.define(),Ye=w.define({combine(e){return bt(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)})}}),Ze=Qe.define({create(){return A.empty},update(e,t){let n=t.state.facet(Ye),r=t.annotation(ge);if(r){let u=y.fromTransaction(t,r.selection),f=r.side,h=f==0?e.undone:e.done;if(u)h=Q(h,h.length,n.minDepth,u);else h=rt(h,t.startState.selection);return new A(f==0?r.rest:h,f==0?h: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),a=t.annotation(le.userEvent);if(l)e=e.addChanges(l,s,a,n,t);else if(t.selection)e=e.addSelection(t.startState.selection,s,a,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[Ze,Ye.of(e),b.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(Ze,!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&&ye.fromJSON(e.changes),[],e.mapped&&ht.fromJSON(e.mapped),e.startSelection&&c.fromJSON(e.startSelection),e.selectionsAfter.map(c.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,a)=>{for(let u=0;u<n.length;){let f=n[u++],h=n[u++];if(a>=f&&s<=h)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 rt(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((a)=>a.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,G.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=Q(l,l.length-1,r.minDepth,new y(e.changes.compose(s.changes),tt(G.mapEffects(e.effects,s.changes),s.effects),s.mapped,s.startSelection,S));else l=Q(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(rt(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 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 R(e,t){return c.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=R(e.selection,n);if(r.eq(e.selection,!0))return!1;return t(C(e,r)),!0}function Y(e,t){return c.cursor(t?e.to:e.from)}function lt(e,t){return M(e,(n)=>n.empty?e.moveByChar(n,t):Y(n,t))}function g(e){return e.textDirectionAt(e.state.selection.main.head)==oe.LTR}var it=(e)=>lt(e,!g(e)),st=(e)=>lt(e,g(e));function ct(e,t){return M(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?P.closedBy:P.openedBy;for(let u=t.head;;){let f=n?r.childAfter(u):r.childBefore(u);if(!f)break;if(bn(e,f,o))r=f;else u=n?f.to:f.from}let l=r.type.prop(o),s,a;if(l&&(s=n?mt(e,r.from,1):mt(e,r.to,-1))&&s.matched)a=n?s.end.to:s.end.from;else a=n?r.to:r.from;return c.cursor(a,n?-1:1)}var Mn=(e)=>M(e,(t)=>Z(e.state,t,!g(e))),An=(e)=>M(e,(t)=>Z(e.state,t,g(e)));function at(e,t){return M(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),ft=(e)=>at(e,!0);function dt(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 pt(e,t){let n=dt(e),{state:r}=e,o=R(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),a=e.scrollDOM.getBoundingClientRect(),u=a.top+n.marginTop,f=a.bottom-n.marginBottom;if(s&&s.top>u&&s.bottom<f)l=b.scrollIntoView(o.main.head,{y:"start",yMargin:s.top-u})}return e.dispatch(C(r,o),{effects:l}),!0}var Ge=(e)=>pt(e,!1),xe=(e)=>pt(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=c.cursor(r.from+l)}return o}var Ln=(e)=>M(e,(t)=>D(e,t,!0)),Bn=(e)=>M(e,(t)=>D(e,t,!1)),Dn=(e)=>M(e,(t)=>D(e,t,!g(e))),En=(e)=>M(e,(t)=>D(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=R(e.selection,(l)=>{let s=mt(e,l.head,-1)||mt(e,l.head,1)||l.head>0&&mt(e,l.head-1,1)||l.head<e.doc.length&&mt(e,l.head+1,-1);if(!s||!s.end)return l;r=!0;let a=s.start.from==l.head?s.end.to:s.end.from;return n?c.range(l.anchor,a):c.cursor(a)});if(!r)return!1;return t(C(e,o)),!0}var On=({state:e,dispatch:t})=>Wn(e,t,!1);function k(e,t,n){let r=R(e.state.selection,(o)=>{if(o.undirectional&&o.head>=o.anchor!=t)o=c.range(o.head,o.anchor);let l=n(o);return c.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 gt(e,t){return k(e,t,(n)=>e.moveByChar(n,t))}var yt=(e)=>gt(e,!g(e)),xt=(e)=>gt(e,g(e));function St(e,t){return k(e,t,(n)=>e.moveByGroup(n,t))}var Fn=(e)=>St(e,!g(e)),In=(e)=>St(e,g(e));var Pn=(e)=>{let t=!g(e);return k(e,t,(n)=>Z(e.state,n,t))},Nn=(e)=>{let t=g(e);return k(e,t,(n)=>Z(e.state,n,t))};function kt(e,t){return k(e,t,(n)=>e.moveVertically(n,t))}var Ct=(e)=>kt(e,!1),Mt=(e)=>kt(e,!0);function At(e,t){return k(e,t,(n)=>e.moveVertically(n,t,dt(e).height))}var Ue=(e)=>At(e,!1),ze=(e)=>At(e,!0),qn=(e)=>k(e,!0,(t)=>D(e,t,!0)),Vn=(e)=>k(e,!1,(t)=>D(e,t,!1)),Gn=(e)=>{let t=!g(e);return k(e,t,(n)=>D(e,n,t))},Un=(e)=>{let t=g(e);return k(e,t,(n)=>D(e,n,t))},zn=(e)=>k(e,!1,(t)=>c.cursor(e.lineBlockAt(t.head).from)),_n=(e)=>k(e,!0,(t)=>c.cursor(e.lineBlockAt(t.head).to)),_e=({state:e,dispatch:t})=>(t(C(e,{anchor:0})),!0),Je=({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})=>c.undirectionalRange(r,Math.min(o+1,e.doc.length)));return t(e.update({selection:c.create(n),userEvent:"select"})),!0},Kn=({state:e,dispatch:t})=>{let n=R(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:a}=s;if((a.from<r.from&&a.to>=r.to||a.to>r.to&&a.from<=r.from)&&s.next)return c.undirectionalRange(a.from,a.to)}return r});if(n.eq(e.selection))return!1;return t(C(e,n)),!0};function Lt(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 a=l;;){let u=e.moveVertically(a,t);if(u.head<s.from||u.head>s.to){if(!o.some((f)=>f.head==u.head))o.push(u);break}else if(u.head==a.head)break;else a=u}}if(o.length==r.ranges.length)return!1;return e.dispatch(C(n,c.create(o,o.length-1))),!0}var Hn=(e)=>Lt(e,!1),Qn=(e)=>Lt(e,!0),jn=({state:e,dispatch:t})=>{let n=e.selection,r=null;if(n.ranges.length>1)r=c.create([n.main]);else if(!n.main.empty)r=c.create([c.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:a}=l;if(s==a){let u=t(l);if(u<s)n="delete.backward",u=H(e,u,!1);else if(u>s)n="delete.forward",u=H(e,u,!0);s=Math.min(s,u),a=Math.max(a,u)}else s=H(e,s,!1),a=H(e,a,!0);return s==a?{range:l}:{changes:{from:s,to:a},range:c.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 H(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 Bt=(e,t,n)=>_(e,(r)=>{let o=r.from,{state:l}=e,s=l.doc.lineAt(o),a,u;if(n&&!t&&o>s.from&&o<s.from+200&&!/[^ \t]/.test(a=s.text.slice(0,o-s.from))){if(a[a.length-1]=="\t")return o-1;let f=Be(a,l.tabSize),h=f%qt(l)||qt(l);for(let d=0;d<h&&a[a.length-1-d]==" ";d++)o--;u=o}else if(u=Oe(s.text,o-s.from,t,t)+s.from,u==o&&s.number!=(t?l.doc.lines:1))u+=t?1:-1;else if(!t&&/[\ufe00-\ufe0f]/.test(s.text.slice(u-s.from,o-s.from)))u=Oe(s.text,u-s.from,!1,!1)+s.from;return u}),Se=(e)=>Bt(e,!1,!0);var Et=(e)=>Bt(e,!0,!1),Tt=(e,t)=>_(e,(n)=>{let r=n.head,{state:o}=e,l=o.doc.lineAt(r),s=o.charCategorizer(r);for(let a=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 u=Oe(l.text,r-l.from,t)+l.from,f=l.text.slice(Math.min(r,u)-l.from,Math.max(r,u)-l.from),h=s(f);if(a!=null&&h!=a)break;if(f!=" "||r!=n.head)a=h;r=u}return r}),wt=(e)=>Tt(e,!1),Xn=(e)=>Tt(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:B.of(["",""])},range:c.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:Oe(l.text,o-l.from,!1)+l.from,a=o==l.to?o+1:Oe(l.text,o-l.from,!0)+l.from;return{changes:{from:s,to:a,insert:e.doc.slice(o,a).append(e.doc.slice(s,o))},range:c.cursor(a)}});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),a=s.length+1;if(n){r.push({from:l.to,to:s.to},{from:l.from,insert:s.text+e.lineBreak});for(let u of l.ranges)o.push(c.range(Math.min(e.doc.length,u.anchor+a),Math.min(e.doc.length,u.head+a)))}else{r.push({from:s.from,to:l.from},{from:l.to,insert:e.lineBreak+s.text});for(let u of l.ranges)o.push(c.range(u.anchor-a,u.head-a))}}if(!r.length)return!1;return t(e.update({changes:r,scrollIntoView:!0,selection:c.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 Rt(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})=>Rt(e,t,!1),ir=({state:e,dispatch:t})=>Rt(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=R(t.selection,(o)=>{let l=void 0;if(e.lineWrapping){let s=e.lineBlockAt(o.head),a=e.coordsAtPos(o.head,o.assoc||1);if(a)l=s.bottom+e.documentTop-a.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(P.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 je=Ot(!1),ar=Ot(!0);function Ot(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=t.changeByRange((o)=>{let{from:l,to:s}=o,a=t.doc.lineAt(l),u=!e&&l==s&&cr(t,l);if(e)l=s=(s<=a.to?a:t.doc.lineAt(s)).to;let f=new Rn(t,{simulateBreak:l,simulateDoubleBreak:!!u}),h=br(f,l);if(h==null)h=Be(/^\s*/.exec(t.doc.lineAt(l).text)[0],t.tabSize);while(s<a.to&&/\s/.test(a.text[s-a.from]))s++;if(u)({from:l,to:s}=u);else if(l>a.from&&l<a.from+100&&!/\S/.test(a.text.slice(0,l)))l=a.from;let d=["",ri(t,h)];if(u)d.push(ri(t,f.lineIndent(a.from,-1)));return{changes:{from:l,to:s,insert:B.of(d)},range:c.cursor(l+1+d[1].length)}});return n(t.update(r,{scrollIntoView:!0,userEvent:"input"})),!0}}function Ce(e,t){let n=-1;return e.changeByRange((r)=>{let o=[];for(let s=r.from;s<=r.to;){let a=e.doc.lineAt(s);if(a.number>n&&(r.empty||r.to>a.from))t(a,o,r),n=a.number;s=a.to+1}let l=e.changes(o);return{changes:o,range:c.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 Rn(e,{overrideIndentation:(l)=>{let s=n[l];return s==null?-1:s}}),o=Ce(e,(l,s,a)=>{let u=br(r,l.from);if(u==null)return;if(!/\S/.test(l.text))u=0;let f=/^\s*/.exec(l.text)[0],h=ri(e,u);if(f!=h||a.from<l.from+f.length)n[l.from]=u,s.push({from:l.from,to:l.from+f.length,insert:h})});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(Ce(e,(n,r)=>{r.push({from:n.from,insert:e.facet(nt)})}),{userEvent:"input.indent"})),!0},Ft=({state:e,dispatch:t})=>{if(e.readOnly)return!1;return t(e.update(Ce(e,(n,r)=>{let o=/^\s*/.exec(n.text)[0];if(!o)return;let l=Be(o,e.tabSize),s=0,a=ri(e,Math.max(0,l-qt(e)));while(s<o.length&&s<a.length&&o.charCodeAt(s)==a.charCodeAt(s))s++;r.push({from:n.from+s,to:n.from+o.length,insert:a.slice(s)})}),{userEvent:"delete.dedent"})),!0},hr=(e)=>(e.setTabFocusMode(),!0);var fr=[{key:"Ctrl-b",run:it,shift:yt,preventDefault:!0},{key:"Ctrl-f",run:st,shift:xt},{key:"Ctrl-p",run:ut,shift:Ct},{key:"Ctrl-n",run:ft,shift:Mt},{key:"Ctrl-a",run:Tn,shift:zn},{key:"Ctrl-e",run:wn,shift:_n},{key:"Ctrl-d",run:Et},{key:"Ctrl-h",run:Se},{key:"Ctrl-k",run:Yn},{key:"Ctrl-Alt-h",run:wt},{key:"Ctrl-o",run:tr},{key:"Ctrl-t",run:nr},{key:"Ctrl-v",run:xe}],dr=[{key:"ArrowLeft",run:it,shift:yt,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:kn,shift:Fn,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:Dn,shift:Gn,preventDefault:!0},{key:"ArrowRight",run:st,shift:xt,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:vn,shift:In,preventDefault:!0},{mac:"Cmd-ArrowRight",run:En,shift:Un,preventDefault:!0},{key:"ArrowUp",run:ut,shift:Ct,preventDefault:!0},{mac:"Cmd-ArrowUp",run:_e,shift:Ke},{mac:"Ctrl-ArrowUp",run:Ge,shift:Ue},{key:"ArrowDown",run:ft,shift:Mt,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Je,shift:He},{mac:"Ctrl-ArrowDown",run:xe,shift:ze},{key:"PageUp",run:Ge,shift:Ue},{key:"PageDown",run:xe,shift:ze},{key:"Home",run:Bn,shift:Vn,preventDefault:!0},{key:"Mod-Home",run:_e,shift:Ke},{key:"End",run:Ln,shift:qn,preventDefault:!0},{key:"Mod-End",run:Je,shift:He},{key:"Enter",run:je,shift:je},{key:"Mod-a",run:Jn},{key:"Backspace",run:Se,shift:Se,preventDefault:!0},{key:"Delete",run:Et,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:wt,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:Mn,shift:Pn},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:An,shift:Nn},{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:On},{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 Ni(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=_o(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=Li(e);let r=this.normalize(t);if(r.length)for(let o=0,l=n,s=!0;;o++){let a=r.charCodeAt(o),u=this.match(a,l,s,this.bufferPos+this.bufferStart,o==r.length-1);if(u)return this.value=u,this;if(o==r.length-1)break;if(s&&o<t.length&&t.charCodeAt(o)==a)l++;else s=!1}}}match(e,t,n,r,o){let l=null;for(let s=0;s<this.matches.length;){let a=this.matches[s],u=!1;if(this.query.charCodeAt(a.index)==e)if(a.index==this.query.length-1)l={from:a.from,to:r,precise:o&&a.precise};else a.index++,u=!0;if(u)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 Ut={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=Ut,/\\[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=se(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=se(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 Me=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=Me.get(e);if(!r||r.from>=n||r.to<=t){let s=new N(t,e.sliceString(t,n));return Me.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 Me.set(e,new N(l,o)),new N(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=Ut,this.matchPos=se(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=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=se(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")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 se(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=Ro(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}=Mo(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 a=s&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(s.elements.line.value);if(!a){e.dispatch({effects:o});return}let u=n.doc.lineAt(n.selection.main.head),[,f,h,d,m]=a,L=d?+d.slice(1):0,v=h?+h:u.number;if(h&&m){let me=v/100;if(f)me=me*(f=="-"?-1:1)+u.number/n.doc.lines;v=Math.round(n.doc.lines*me)}else if(h&&f)v=v*(f=="-"?-1:1)+u.number;let Pe=n.doc.line(Math.max(1,Math.min(n.doc.lines,v))),Ne=c.cursor(Pe.from+Math.max(0,Math.min(L,Pe.length)));e.dispatch({effects:[o,b.scrollIntoView(Ne.from,{y:"center"})],selection:Ne})}),!0},gr={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},zt=w.define({combine(e){return bt(e,gr,{highlightWordAroundCursor:(t,n)=>t||n,minSelectionLength:Math.min,maxMatches:Math.min})}});function Jt(e){let t=[vr,kr];if(e)t.push(zt.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=$e.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(zt),{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 u=n.wordAt(o.head);if(!u)return z.none;s=n.charCategorizer(o.head),l=n.sliceDoc(u.from,u.to)}else{let u=o.to-o.from;if(u<t.minSelectionLength||u>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 a=[];for(let u of e.visibleRanges){let f=new T(n.doc,l,u.from,u.to);while(!f.next().done){let{from:h,to:d}=f.value;if(!s||Vt(s,n,h,d)){if(o.empty&&h<=o.from&&d>=o.to)a.push(xr.range(h,d));else if(h>=o.to||d<=o.from)a.push(yr.range(h,d));if(a.length>t.maxMatches)return z.none}}}return z.set(a)}},{decorations:(e)=>e.decorations}),vr=b.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),Cr=({state:e,dispatch:t})=>{let{selection:n}=e,r=c.create(n.ranges.map((o)=>e.wordAt(o.head)||c.cursor(o.head)),n.mainIndex);if(r.eq(n))return!1;return t(e.update({selection:r})),!0};function Mr(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,a=new T(e.doc,t,r[r.length-1].to);;)if(a.next(),a.done){if(s)return null;a=new T(e.doc,t,0,Math.max(0,r[r.length-1].from-1)),s=!0}else{if(s&&r.some((u)=>u.from==a.value.from))continue;if(l){let u=e.wordAt(a.value.from);if(!u||u.from!=a.value.from||u.to!=a.value.to)continue}return a.value}}var Ar=({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some((l)=>l.from===l.to))return Cr({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=Mr(e,r);if(!o)return!1;return t(e.update({selection:e.selection.addRange(c.range(o.from,o.to),!1),effects:b.scrollIntoView(o.to)})),!0},W=w.define({combine(e){return bt(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?[W.of(e),Le]:Le}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?F(this,r,t,n):O(this,r,t,n)}}class We{constructor(e){this.spec=e}}function Lr(e,t,n){return(r,o,l,s)=>{if(n&&!n(r,o,l,s))return!1;let a=r>=s&&o<=s+l.length?l.slice(r-s,o-s):t.doc.sliceString(r,o);return e(a,t,r,o)}}function O(e,t,n,r){let o;if(e.wholeWord)o=Br(t.doc,t.charCategorizer(t.selection.main.head));if(e.test)o=Lr(e.test,t,o);return new T(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=O(this.spec,e,n,e.doc.length).nextOverlapping();if(r.done){let o=Math.min(e.doc.length,t+this.spec.unquoted.length);r=O(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=O(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=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-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 F(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(Oe(e,t,!1),t)}function ue(e,t){return e.slice(t,Oe(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=F(this.spec,e,n,e.doc.length).next();if(r.done)r=F(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=F(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=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-250),Math.min(n+250,e.doc.length));while(!o.next().done)r(o.value.from,o.value.to)}}var J=G.define(),Re=G.define(),E=Qe.define({create(e){return new ie(Ae(e).create(),null)},update(e,t){for(let n of t.effects)if(n.is(J))e=new ie(n.value.create(),e.panel);else if(n.is(Re))e=new ie(e.query,n.value?Fe:null);return e},provide:(e)=>ti.from(e,(t)=>t.panel)});class ie{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=$e.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 vt;for(let o=0,l=n.visibleRanges,s=l.length;o<s;o++){let{from:a,to:u}=l[o];while(o<s-1&&u>l[o+1].from-500)u=l[++o].to;e.highlight(n.state,a,u,(f,h)=>{let d=n.state.selection.ranges.some((m)=>m.from==f&&m.to==h);r.add(f,h,d?wr:Tr)})}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=c.single(r.from,r.to),l=e.state.facet(W);return e.dispatch({selection:o,effects:[Ie(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=c.single(o.from,o.to),s=e.state.facet(W);return e.dispatch({selection:l,effects:[Ie(e,o),s.scrollToMatch(l.main,e)],userEvent:"select.search"}),jt(e),!0}),Rr=K((e,{query:t})=>{let n=t.matchAll(e.state,1000);if(!n||!n.length)return!1;return e.dispatch({selection:c.create(n.map((r)=>c.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 a=new T(e.doc,e.sliceDoc(r,o));!a.next().done;){if(l.length>1000)return!1;if(a.value.from==r)s=l.length;l.push(c.range(a.value.from,a.value.to))}return t(e.update({selection:c.create(l,s),userEvent:"select.search.matches"})),!0},Gt=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,a=[],u,f,h=[];if(!s.precise)s=t.nextMatch(n,s.from,s.to);else if(s.from==r&&s.to==o)f=n.toText(t.getReplacement(s)),a.push({from:s.from,to:s.to,insert:f}),s=t.nextMatch(n,s.from,s.to),h.push(b.announce.of(n.phrase("replaced match on line $",n.doc.lineAt(r).number)+"."));let d=e.state.changes(a);if(s)u=c.single(s.from,s.to).map(d),h.push(Ie(e,s)),h.push(n.facet(W).scrollToMatch(u.main,e));return e.dispatch({changes:d,selection:u,effects:h,userEvent:"input.replace"}),!0}),Fr=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:a}=o;if(a)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 Fe(e){return e.state.facet(W).createPanel(e)}function Ae(e,t){var n,r,o,l,s;let a=e.selection.main,u=a.empty||a.to>a.from+100?"":e.sliceDoc(a.from,a.to);if(t&&!u)return t;let f=e.facet(W);return new we({search:((n=t===null||t===void 0?void 0:t.literal)!==null&&n!==void 0?n:f.literal)?u:u.replace(/\n/g,"\\n"),caseSensitive:(r=t===null||t===void 0?void 0:t.caseSensitive)!==null&&r!==void 0?r:f.caseSensitive,literal:(o=t===null||t===void 0?void 0:t.literal)!==null&&o!==void 0?o:f.literal,regexp:(l=t===null||t===void 0?void 0:t.regexp)!==null&&l!==void 0?l:f.regexp,wholeWord:(s=t===null||t===void 0?void 0:t.wholeWord)!==null&&s!==void 0?s:f.wholeWord})}function Qt(e){let t=Xi(e,Fe);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=Ae(e.state,t.query.spec);if(r.valid)e.dispatch({effects:J.of(r)});n.focus(),n.select()}}else e.dispatch({effects:[Re.of(!0),t?J.of(Ae(e.state,t.query.spec)):G.appendConfig.of(Le)]});return!0},Xt=(e)=>{let t=e.state.field(E,!1);if(!t||!t.panel)return!1;let n=Xi(e,Fe);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:Ar,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=be("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=be("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=be("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=be("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=be("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit});function n(r,o,l){return be("button",{class:"cm-button",name:r,onclick:o,type:"button"},l)}this.dom=be("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")]),be("label",null,[this.caseField,x(e,"match case")]),be("label",null,[this.reField,x(e,"regexp")]),be("label",null,[this.wordField,x(e,"by word")]),...e.state.readOnly?[]:[be("br"),this.replaceField,n("replace",()=>Gt(e),[x(e,"replace")]),n("replaceAll",()=>Fr(e),[x(e,"replace all")])],be("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:J.of(e)})}keydown(e){if(To(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(),Gt(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(W).top}}function x(e,t){return e.state.phrase(t)}var ne=30,re=/[\s\.,:;?!]/;function Ie(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),a=e.state.sliceDoc(l,s);if(l!=r.from){for(let u=0;u<ne;u++)if(!re.test(a[u+1])&&re.test(a[u])){a=a.slice(u);break}}if(s!=o){for(let u=a.length-1;u>a.length-ne;u--)if(!re.test(a[u-1])&&re.test(a[u])){a=a.slice(0,u);break}}return b.announce.of(`${e.state.phrase("current match")}. ${a} ${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"}}),Le=[E,Ve.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=Cn.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,No(Nr)];var qr={typescript:()=>(p("qf8acbb2"),import("./chunk-lang-typescript-qf8acbb2.js")),javascript:()=>(p("n33kmjcx"),import("./chunk-lang-javascript-n33kmjcx.js")),json:()=>(p("zmym50rg"),import("./chunk-lang-json-zmym50rg.js")),markdown:()=>(p("ww2kcs85"),import("./chunk-lang-markdown-ww2kcs85.js")),css:()=>(p("avzhvm72"),import("./chunk-lang-css-avzhvm72.js")),html:()=>(p("red02gep"),import("./chunk-lang-html-red02gep.js")),python:()=>(p("ng1zdtd4"),import("./chunk-lang-python-ng1zdtd4.js")),yaml:()=>(p("g9zy0tdv"),import("./chunk-lang-yaml-g9zy0tdv.js")),go:()=>(p("zxp9k517"),import("./chunk-lang-go-zxp9k517.js")),rust:()=>(p("6ynhxjdd"),import("./chunk-lang-rust-6ynhxjdd.js")),sql:()=>(p("w875ejpg"),import("./chunk-lang-sql-w875ejpg.js")),xml:()=>(p("bz91cjp1"),import("./chunk-lang-xml-bz91cjp1.js")),shell:()=>(p("39t9bz2s"),import("./chunk-lang-shell-39t9bz2s.js")),toml:()=>(p("b8ckgkg5"),import("./chunk-lang-toml-b8ckgkg5.js")),dockerfile:()=>(p("2p7e3ssz"),import("./chunk-lang-dockerfile-2p7e3ssz.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 Dt,n=new Dt,r=new Dt,o=await tn(e.language),l=(d)=>[q.readOnly.of(!d),b.editable.of(d)],s={editable:e.editable,wrap:e.wrap,language:o??[]},a,u=(d)=>[Co(),Qo(),Eo(),et(),Po(),Lo(),Jt(),$t({top:!0}),nt.of(" "),q.phrases.of(e.phrases),en,_t.of([{key:"Mod-s",preventDefault:!0,run:()=>(e.onSave(),!0)},{key:"Escape",run:()=>(e.onEscape(),!0)},Pt,...Yt,...ot,...It]),q.lineSeparator.of(d),t.of(l(s.editable)),n.of(s.wrap?b.lineWrapping:[]),r.of(s.language),b.updateListener.of((m)=>{if(m.docChanged)e.onChange()})],f=Vr(e.parent),h=new b({parent:f.parent,root:f.root,state:q.create({doc:e.text,extensions:u(e.eol)})});return a=h.state.doc,{text:()=>h.state.doc.sliceString(0,void 0,h.state.lineBreak),dirty:()=>a===void 0||!h.state.doc.eq(a),snapshot:()=>h.state.doc,markSaved:(d)=>{a=d??h.state.doc},replace:(d,m)=>{let L=h.scrollDOM.scrollTop;h.setState(q.create({doc:d,extensions:u(m)})),a=h.state.doc,h.scrollDOM.scrollTop=L},setEditable:(d)=>{s.editable=d,h.dispatch({effects:t.reconfigure(l(d))})},setWrap:(d)=>{s.wrap=d,h.dispatch({effects:n.reconfigure(d?b.lineWrapping:[])})},setLanguage:async(d)=>{s.language=await tn(d)??[],h.dispatch({effects:r.reconfigure(s.language)})},undo:()=>{X(h)},redo:()=>{U(h)},find:()=>{de(h)},tab:()=>{te(h)},focus:()=>h.focus(),scrollTop:()=>h.scrollDOM.scrollTop,scrollTo:(d)=>{h.scrollDOM.scrollTop=d},destroy:()=>h.destroy()}}export{ao as createEditor};
@@ -0,0 +1 @@
1
+ import{D}from"./chunk-index-y6p8j3zv.js";import"./chunk-index-zdzzf3fp.js";export{D as Confirm};
@@ -0,0 +1,37 @@
1
+ import{o,r,t,g,e,n,h,y,l,f,v,m,k,T,_,re}from"./chunk-index-wt2asefx.js";import{D}from"./chunk-index-y6p8j3zv.js";import{on}from"./chunk-index-2dhrqvba.js";import{xe}from"./chunk-index-ek98d2rn.js";import{Te}from"./chunk-index-rtz4936v.js";import{ne}from"./chunk-index-57teqgct.js";import{se}from"./chunk-index-amxa2bn3.js";import"./chunk-index-zdzzf3fp.js";var P=(a,s)=>({method:a,body:JSON.stringify(s)}),U=encodeURIComponent,A={list:()=>h("connectors/managed"),add:(a)=>h("connectors/managed",P("POST",a)),describe:(a,s)=>h(`connectors/managed/${U(a)}`,P("PATCH",{description:s})),remove:(a)=>h(`connectors/managed/${U(a)}`,{method:"DELETE"}),grants:()=>h("connectors/grants"),channels:()=>h("connectors/grants/channels"),authorize:(a)=>h("connectors/grants",P("POST",a)),describeGrant:(a,s,i)=>h(`connectors/grants/${U(a)}/${U(s)}`,P("PATCH",i)),revoke:(a,s)=>h(`connectors/grants/${U(a)}/${U(s)}`,{method:"DELETE"}),rotate:(a)=>h(`connectors/grants/${U(a)}/rotate`,{method:"POST"})};var F={name:"",url:"",description:"",header:"",token:""};function Y(a){let[s,i]=r(F),[d,b]=r(),[C,w]=r(!1),p=(c)=>(M)=>i((x)=>({...x,[c]:M}));return n("form",{className:"stack",onSubmit:async(c)=>{c.preventDefault(),w(!0),b(void 0);try{let{connector:M,skipped:x}=await A.add({name:s.name,url:s.url,description:s.description,...s.header.trim()?{header:s.header}:{},...s.token?{token:s.token}:{}});i(F),f(x.length?t("Added {name}. Left out tools whose names are too long: {tools}",{name:M.name,tools:x.join(", ")}):t("Added {name}.",{name:M.name})),a.onDone()}catch(M){b(l(M))}finally{w(!1)}},autoComplete:"off",children:[n("label",{children:[t("Name"),e("input",{value:s.name,maxLength:12,placeholder:"notion",required:!0,onChange:(c)=>p("name")(c.target.value)}),e("span",{className:"meta",children:t("Lowercase letters, digits and -, up to 12; it becomes the prefix of its tool names.")})]}),n("label",{children:[t("MCP URL"),e("input",{type:"url",value:s.url,maxLength:500,placeholder:"https://mcp.example.com/mcp",required:!0,onChange:(c)=>p("url")(c.target.value)}),e("span",{className:"meta",children:t("A Streamable HTTP endpoint; one ending in /sse uses SSE. A credential may be part of the URL.")})]}),n("label",{children:[t("Purpose"),e("textarea",{value:s.description,maxLength:1000,rows:3,required:!0,onChange:(c)=>p("description")(c.target.value)}),e("span",{className:"meta",children:t("The knights decide from this text when to use the connector.")})]}),n("div",{className:"form-row",children:[n("label",{children:[t("Header name (optional)"),e("input",{value:s.header,maxLength:100,placeholder:"X-API-Key",onChange:(c)=>p("header")(c.target.value)}),e("span",{className:"meta",children:t("Leave empty to send Authorization: Bearer <token>.")})]}),n("label",{children:[t("Token (optional)"),e("input",{type:"password",value:s.token,maxLength:4000,autoComplete:"new-password",onChange:(c)=>p("token")(c.target.value)}),e("span",{className:"meta",children:t("Stored encrypted by the gateway and never shown again; leave empty if the credential is in the URL.")})]})]}),d?e(m,{message:d}):null,n("div",{className:"actions",children:[e("button",{type:"button",className:"secondary",disabled:C,onClick:a.onCancel,children:t("Cancel")}),e("button",{type:"submit",disabled:C,children:t("Add connector")})]})]})}function j(a){let[s,i]=r(a.connector.description),[d,b]=r(),[C,w]=r(!1);return n("form",{className:"stack",onSubmit:async(N)=>{N.preventDefault(),w(!0),b(void 0);try{await A.describe(a.connector.name,s),f(t("Purpose updated.")),a.onDone()}catch(c){b(l(c))}finally{w(!1)}},children:[n("label",{children:[t("Purpose"),e("textarea",{value:s,maxLength:1000,rows:4,required:!0,onChange:(N)=>i(N.target.value)}),e("span",{className:"meta",children:t("From the next message on, the knights follow the new purpose.")})]}),d?e(m,{message:d}):null,n("div",{className:"actions",children:[e("button",{type:"button",className:"secondary",disabled:C,onClick:a.onCancel,children:t("Cancel")}),e("button",{type:"submit",disabled:C,children:t("Save")})]})]})}function G(){let{data:a,error:s,reload:i}=on(()=>A.list()),[d,b]=r(!1),[C,w]=r(),[p,N]=r();return n("section",{className:"stack","aria-labelledby":"connectors-mine",children:[n("div",{className:"card-head",children:[e("h3",{id:"connectors-mine",children:t("MCP connectors")}),e("button",{type:"button",onClick:()=>b(!0),children:t("Add connector")})]}),s?e(m,{message:s}):null,!a&&!s?e(v,{}):null,a?.length===0?e(k,{children:t("No connectors yet.")}):null,a?.map((c)=>n("article",{className:"card connector-card",children:[n("div",{className:"card-head",children:[e("strong",{children:c.name}),c.tools===void 0?e(T,{tone:"warn",children:t("Tools unreadable")}):e(T,{children:t("{count} tools",{count:c.tools})})]}),e("p",{className:"meta connector-url",children:c.displayUrl??t("(the URL cannot be parsed)")}),e("p",{children:c.description}),n("div",{className:"actions",children:[e("button",{type:"button",className:"secondary",onClick:()=>w(c),children:t("Edit purpose")}),e("button",{type:"button",className:"danger",onClick:()=>N(c),children:t("Remove")})]})]},c.name)),e(ne,{open:d,title:t("Add an MCP connector"),onClose:()=>b(!1),children:d?e(Y,{onCancel:()=>b(!1),onDone:()=>{b(!1),i()}}):null}),e(ne,{open:C!==void 0,title:t("Edit purpose of {name}",{name:C?.name??""}),onClose:()=>w(void 0),children:C?e(j,{connector:C,onCancel:()=>w(void 0),onDone:()=>{w(void 0),i()}},C.name):null}),e(D,{open:p!==void 0,title:t("Remove connector"),confirmLabel:t("Remove"),tone:"danger",onClose:()=>N(void 0),onConfirm:async()=>{if(!p)return;await A.remove(p.name),f(t("Removed {name}.",{name:p.name})),i()},children:e("p",{children:t("Remove {name} and its token? From the next message on, the knights no longer use it.",{name:p?.name??""})})})]})}var V=" new",J=(a,s)=>a.map((i)=>s.find((d)=>d.id===i)?.label??i).join(", ");function K(a){return e(ne,{open:a.shown!==void 0,title:t("MCP URL of {bundle}",{bundle:a.shown?.bundle??""}),onClose:a.onClose,children:n("div",{className:"stack",children:[e("p",{children:t("This URL is the access credential and is shown only this once. Add a remote MCP server in the AI client and paste it; no separate token is needed.")}),e("input",{readOnly:!0,"aria-label":t("MCP URL"),className:"mcp-url",value:a.shown?.url??"",onFocus:(s)=>s.target.select()}),n("div",{className:"actions",children:[e("button",{type:"button",className:"secondary",onClick:()=>{navigator.clipboard?.writeText(a.shown?.url??"").then(()=>f(t("Copied")))},children:t("Copy")}),e("button",{type:"button",onClick:a.onClose,children:t("Done")})]})]})})}function X(a){return n("fieldset",{className:"field",children:[e("legend",{children:t("Allowed operations")}),e("ul",{className:"menu",children:a.operations.map((s)=>{let i=a.chosen.includes(s.id);return e("li",{children:n("label",{className:"menu-item menu-toggle",children:[e("input",{type:"checkbox",checked:i,onChange:()=>a.onChange(i?a.chosen.filter((d)=>d!==s.id):[...a.chosen,s.id])}),e("span",{className:"menu-text",children:e("strong",{children:s.label})})]})},s.id)})})]})}function Z(a){let{view:s}=a,[i,d]=r(),[b,C]=r(s.bundles[0]?.name??V),[w,p]=r(""),[N,c]=r(""),[M,x]=r([]),[L,R]=r(""),[E,W]=r(""),[I,B]=r(),[O,z]=r(!1);return o(()=>{A.channels().then((u)=>{d(u),c((S)=>S||u[0]?.id||"")},(u)=>B(l(u)))},[]),n("form",{className:"stack",onSubmit:async(u)=>{u.preventDefault(),z(!0),B(void 0);try{let S=await A.authorize({bundle:b===V?w:b,channelId:N,operations:M,...L.trim()?{displayName:L}:{},...E.trim()?{description:E}:{}});f(t("Authorized the channel in {bundle}.",{bundle:S.bundle})),a.onDone(S.url?{bundle:S.bundle,url:S.url}:void 0)}catch(S){B(l(S))}finally{z(!1)}},children:[n("label",{htmlFor:"mcp-bundle",children:[t("Bundle"),n(Te,{id:"mcp-bundle",value:b,onChange:(u)=>C(u.target.value),children:[s.bundles.map((u)=>e("option",{value:u.name,children:u.name},u.name)),e("option",{value:V,children:t("New bundle…")})]})]}),b===V?n("label",{children:[t("New bundle name"),e("input",{value:w,maxLength:80,required:!0,onChange:(u)=>p(u.target.value)}),e("span",{className:"meta",children:t("Channels in one bundle share one MCP URL.")})]}):null,n("label",{htmlFor:"mcp-channel",children:[t("Channel"),i===void 0&&!I?e(v,{}):e(Te,{id:"mcp-channel",value:N,required:!0,onChange:(u)=>c(u.target.value),children:(i??[]).map((u)=>e("option",{value:u.id,children:`${u.guild} › #${u.name}`},u.id))})]}),e(X,{operations:s.operations,chosen:M,onChange:x}),n("label",{children:[t("Name outside AI clients see (optional)"),e("input",{value:L,maxLength:100,onChange:(u)=>R(u.target.value)})]}),n("label",{children:[t("Purpose (optional)"),e("textarea",{value:E,maxLength:1000,rows:2,onChange:(u)=>W(u.target.value)})]}),I?e(m,{message:I}):null,n("div",{className:"actions",children:[e("button",{type:"button",className:"secondary",disabled:O,onClick:a.onCancel,children:t("Cancel")}),e("button",{type:"submit",disabled:O||!N||M.length===0,children:t("Authorize")})]})]})}function Q(a){let{bundle:s,grant:i}=a.target,[d,b]=r(i.displayName),[C,w]=r(i.description),[p,N]=r(),[c,M]=r(!1);return n("form",{className:"stack",onSubmit:async(L)=>{L.preventDefault(),M(!0),N(void 0);try{await A.describeGrant(s,i.channelId,{displayName:d,description:C}),f(t("Updated what outside AI clients see.")),a.onDone()}catch(R){N(l(R))}finally{M(!1)}},children:[n("label",{children:[t("Name outside AI clients see"),e("input",{value:d,maxLength:100,required:!0,onChange:(L)=>b(L.target.value)})]}),n("label",{children:[t("Purpose"),e("textarea",{value:C,maxLength:1000,rows:3,onChange:(L)=>w(L.target.value)}),e("span",{className:"meta",children:t("The channel's name and topic on Discord stay as they are.")})]}),p?e(m,{message:p}):null,n("div",{className:"actions",children:[e("button",{type:"button",className:"secondary",disabled:c,onClick:a.onCancel,children:t("Cancel")}),e("button",{type:"submit",disabled:c,children:t("Save")})]})]})}function ee(a){let{grant:s}=a,{timeZone:i}=_();return n("li",{className:"grant",children:[n("div",{className:"card-head",children:[e("strong",{children:s.displayName}),s.visible?null:e(T,{tone:"warn",children:t("Not visible now")})]}),e("p",{className:"meta",children:`${s.guildName} › #${s.channelName}`}),e("p",{children:s.description||t("No purpose set.")}),e("p",{className:"meta",children:t("Allowed: {operations}",{operations:J(s.operations,a.operations)})}),s.audit.length?n("details",{children:[e("summary",{children:t("Recent activity")}),e("ul",{className:"audit",children:s.audit.map((d)=>n("li",{children:[e("time",{dateTime:d.at,children:re(d.at,i)})," ",e("code",{children:d.tool})," ",d.status]},`${d.at}-${d.tool}`))})]}):null,n("div",{className:"actions",children:[e("button",{type:"button",className:"secondary",onClick:a.onDescribe,children:t("Rename / purpose")}),e("button",{type:"button",className:"danger",onClick:a.onRevoke,children:t("Revoke")})]})]})}function q(){let{data:a,error:s,reload:i}=on(()=>A.grants()),[d,b]=r(!1),[C,w]=r(),[p,N]=r(),[c,M]=r(),[x,L]=r();return n("section",{className:"stack","aria-labelledby":"mcp-grants",children:[n("div",{className:"card-head",children:[n("div",{children:[e("h3",{id:"mcp-grants",children:t("MCP authorizations")}),e("p",{className:"hint",children:t("Which channels outside AI clients may use through each bundle's MCP URL, and with which operations.")})]}),e("button",{type:"button",disabled:!a,onClick:()=>b(!0),children:t("Authorize a channel")})]}),s?e(m,{message:s}):null,!a&&!s?e(v,{}):null,a?.bundles.length===0?e(k,{children:t("There are no authorizations yet.")}):null,a?.bundles.map((R)=>n("article",{className:"card bundle-card",children:[n("div",{className:"card-head",children:[e("strong",{children:R.name}),e("button",{type:"button",className:"secondary",onClick:()=>M(R.name),children:t("New URL")})]}),R.grants.length===0?e(k,{children:t("No channels")}):null,e("ul",{className:"grants",children:R.grants.map((E)=>e(ee,{bundle:R.name,grant:E,operations:a.operations,onDescribe:()=>w({bundle:R.name,grant:E}),onRevoke:()=>N({bundle:R.name,grant:E})},E.channelId))})]},R.name)),e(ne,{open:d,title:t("Authorize a channel"),onClose:()=>b(!1),children:d&&a?e(Z,{view:a,onCancel:()=>b(!1),onDone:(R)=>{if(b(!1),R)L(R);i()}}):null}),e(ne,{open:C!==void 0,title:t("What outside AI clients see"),onClose:()=>w(void 0),children:C?e(Q,{target:C,onCancel:()=>w(void 0),onDone:()=>{w(void 0),i()}},`${C.bundle}/${C.grant.channelId}`):null}),e(D,{open:p!==void 0,title:t("Revoke the channel"),confirmLabel:t("Revoke"),tone:"danger",onClose:()=>N(void 0),onConfirm:async()=>{if(!p)return;await A.revoke(p.bundle,p.grant.channelId),f(t("Revoked.")),i()},children:e("p",{children:t("Remove {channel} from bundle {bundle}? Its other channels and its URL keep working; operations already sent are not undone.",{channel:p?.grant.displayName??"",bundle:p?.bundle??""})})}),e(D,{open:c!==void 0,title:t("Replace the MCP URL"),confirmLabel:t("Replace URL"),tone:"danger",onClose:()=>M(void 0),onConfirm:async()=>{if(!c)return;let{bundle:R,url:E}=await A.rotate(c);if(E)L({bundle:R,url:E});i()},children:e("p",{children:t("Replace the URL of bundle {bundle}? The old URL stops working at once; every channel setting stays.",{bundle:c??""})})}),e(K,{...x?{shown:x}:{},onClose:()=>L(void 0)})]})}var te=`
2
+ /* The Connectors page's management: an address never breaks the layout, a bundle's channels sit as rows. */
3
+ .connector-url,
4
+ .connectors-page .grant .meta {
5
+ overflow-wrap: anywhere;
6
+ }
7
+
8
+ .connectors-page .grants,
9
+ .connectors-page .audit {
10
+ display: flex;
11
+ flex-direction: column;
12
+ margin: 0;
13
+ padding: 0;
14
+ list-style: none;
15
+ }
16
+
17
+ .connectors-page .grant {
18
+ display: flex;
19
+ flex-direction: column;
20
+ gap: var(--space-1);
21
+ padding: var(--space-3) 0;
22
+ border-top: 1px solid var(--border);
23
+ }
24
+
25
+ .connectors-page .grant p {
26
+ margin: 0;
27
+ }
28
+
29
+ .connectors-page .audit {
30
+ gap: var(--space-1);
31
+ font-size: var(--text-sm);
32
+ }
33
+
34
+ .mcp-url {
35
+ font-family: var(--font-mono);
36
+ }
37
+ `,H=()=>se("connectors",te);function _e(){H();let{connectorAdminUrl:a,connectorParts:s}=_(),i=s??{gateways:!0};return n("section",{className:"stack connectors-page",children:[n("header",{className:"page-head",children:[e("h1",{children:t("Connectors")}),a?e("a",{href:a,target:"_blank",rel:"noreferrer",children:t("Open connector admin")}):null]}),e("p",{className:"hint",children:t("Upstream MCP gateways and virtual servers used by the knights.")}),i.manage?e(G,{}):null,i.grants?e(q,{}):null,i.gateways?e(ae,{}):null]})}function ae(){let{data:a,error:s}=xe(()=>y.connectors(),"connectors");return n("section",{className:"stack",children:[s?e(m,{message:s}):null,!a&&!s?e(v,{}):null,a?n(g,{children:[e("h3",{children:t("Upstream gateways")}),a.gateways.length===0?e(k,{children:t("No gateways.")}):null,a.gateways.map((i)=>e("article",{className:"card",children:n("div",{className:"card-head",children:[e("strong",{children:i.name}),e(T,{children:i.enabled?t("Enabled"):t("Disabled")}),e(T,{tone:i.reachable?"plain":"warn",children:i.reachable?t("Reachable"):t("Unreachable")}),e(T,{children:t("{count} tools",{count:i.tools})})]})},i.name)),e("h3",{children:t("Virtual servers")}),a.servers.length===0?e(k,{children:t("No virtual servers.")}):null,a.servers.map((i)=>n("article",{className:"card",children:[n("div",{className:"card-head",children:[e("strong",{children:i.name}),e(T,{children:t("{count} tools",{count:i.tools.length})})]}),n("p",{children:[t("Used by"),": ",i.usedBy.join(", ")||t("None")]}),n("details",{children:[e("summary",{children:t("Tool list")}),e("ul",{children:i.tools.map((d)=>e("li",{children:d},d))})]})]},i.name))]}):null]})}export{_e as ConnectorsPage};
@@ -1 +1 @@
1
- import{t,u,g,e,n,x,y,v,m,k,T,_,xe,re,Ne,mn,vi,J}from"./chunk-index-cn49mawx.js";import{ve}from"./chunk-index-gcmmwh8t.js";var h=[{kind:"owner",title:u("Owner channels"),note:u("Direct messages and channels where the owner talks to a knight.")},{kind:"agent",title:u("Bot server channels"),note:u("The bot server's one-to-one channels.")},{kind:"group",title:u("Group channels"),note:u("The bot server's group channels.")},{kind:"outside",title:u("Outside AI clients"),note:u("Conversations an outside AI client holds over MCP.")},{kind:"plugin",title:u("Plugin conversations"),note:u("Conversations a plugin runs, such as a web chat, as the host recorded them.")}];function P(){let{timeZone:o}=_(),{now:i}=J(),{data:a,error:s}=ve(()=>y.conversations(),"conversations"),c=a?.conversations;if(!c)return s?e(m,{message:s}):e(v,{});return n(g,{children:[s?e(m,{message:s}):null,h.map((r)=>{let d=c.filter((l)=>l.kind===r.kind);return n("section",{className:"stack",children:[e("h2",{children:t(r.title)}),e("p",{className:"hint",children:t(r.note)}),d.length===0?e(k,{children:t("None stored.")}):null,d.map((l)=>e(p,{item:l,now:i,timeZone:o},l.key))]},r.kind)})]})}function p(o){let{item:i}=o,a=mn(i.channel,i.id),s=vi(i);return n("a",{className:"card card-link",href:x("conversations",i.key),children:[n("div",{className:"card-head",children:[e("strong",{children:s}),i.busy>0?e(T,{tone:"busy",children:t("running")}):null,i.liveBytes===0?e(T,{children:t("archived only")}):null]}),n("p",{className:"meta",children:[(i.kind==="outside"||i.kind==="plugin")&&i.startedAt?`${t("Started")} ${re(i.startedAt,o.timeZone)} · `:a.detail?`${a.detail} · `:"",i.principal?`${i.visibility==="private"?t("Private to {name}",{name:i.principal.name}):t("Shared · {name}",{name:i.principal.name})} · `:"",t("Last active")," ",xe(i.lastActive,o.now,o.timeZone)," ·"," ",Ne(i.liveBytes)," ·"," ",t("{count} archived",{count:i.archives})]})]})}export{P as ConversationsPage};
1
+ import{t,u,g,e,n,x,y,v,m,k,T,_,Se,re,Le,mn,wi,J}from"./chunk-index-wt2asefx.js";import{xe}from"./chunk-index-ek98d2rn.js";var h=[{kind:"owner",title:u("Owner channels"),note:u("Direct messages and channels where the owner talks to a knight.")},{kind:"agent",title:u("Bot server channels"),note:u("The bot server's one-to-one channels.")},{kind:"group",title:u("Group channels"),note:u("The bot server's group channels.")},{kind:"outside",title:u("Outside AI clients"),note:u("Conversations an outside AI client holds over MCP.")},{kind:"plugin",title:u("Plugin conversations"),note:u("Conversations a plugin runs, such as a web chat, as the host recorded them.")}];function P(){let{timeZone:o}=_(),{now:i}=J(),{data:a,error:s}=xe(()=>y.conversations(),"conversations"),c=a?.conversations;if(!c)return s?e(m,{message:s}):e(v,{});return n(g,{children:[s?e(m,{message:s}):null,h.map((r)=>{let d=c.filter((l)=>l.kind===r.kind);return n("section",{className:"stack",children:[e("h2",{children:t(r.title)}),e("p",{className:"hint",children:t(r.note)}),d.length===0?e(k,{children:t("None stored.")}):null,d.map((l)=>e(p,{item:l,now:i,timeZone:o},l.key))]},r.kind)})]})}function p(o){let{item:i}=o,a=mn(i.channel,i.id),s=wi(i);return n("a",{className:"card card-link",href:x("conversations",i.key),children:[n("div",{className:"card-head",children:[e("strong",{children:s}),i.busy>0?e(T,{tone:"busy",children:t("running")}):null,i.liveBytes===0?e(T,{children:t("archived only")}):null]}),n("p",{className:"meta",children:[(i.kind==="outside"||i.kind==="plugin")&&i.startedAt?`${t("Started")} ${re(i.startedAt,o.timeZone)} · `:a.detail?`${a.detail} · `:"",i.principal?`${i.visibility==="private"?t("Private to {name}",{name:i.principal.name}):t("Shared · {name}",{name:i.principal.name})} · `:"",t("Last active")," ",Se(i.lastActive,o.now,o.timeZone)," ·"," ",Le(i.liveBytes)," ·"," ",t("{count} archived",{count:i.archives})]})]})}export{P as ConversationsPage};
@@ -0,0 +1,2 @@
1
+ import{o,L,C,r,t,g,e,n,X,l,f,m,Ue}from"./chunk-index-wt2asefx.js";import"./chunk-index-zeqfnkty.js";import"./chunk-index-haac6nbt.js";import"./chunk-index-4jnn2g09.js";import"./chunk-index-hef4gwtb.js";import{ci}from"./chunk-index-am7ghh75.js";import{Bt}from"./chunk-index-en5dm1zv.js";import{R}from"./chunk-index-zdzzf3fp.js";import{Jt,Wn,so,Mi,ys,bs,vs,xs,Ss}from"./chunk-index-x4tq9btg.js";import{ie,Ae}from"./chunk-index-teyx2hz7.js";var Q=(a)=>X("table",a.name,{replace:!0});function W(a){let{view:i}=a;return e("li",{children:n("button",{type:"button",className:"menu-item council-row","aria-current":a.current||void 0,onClick:a.onPick,children:[e(Ue,{view:i,size:40}),n("span",{className:"menu-text",children:[e("strong",{children:i.displayName}),e("span",{className:"meta",children:t("{count} knights",{count:i.members?.length??0})})]})]})})}function Y(a){let{council:i}=a,w=Mi(),d=ci(),[v,A]=r([]),[y,M]=r(),[B,S]=r(""),[O,I]=r(!1),[P,j]=r(""),[b,k]=r(!1),[z,G]=r(),E=L(),x=i?.name,D=i?.members?.join(`
2
+ `);o(()=>{if(!a.open)return;if(G(void 0),I(i===void 0),j(""),k(!1),M(void 0),S(""),A(i?[...i.members??[]]:ys(d)),!x)return;let s=!0;return ie.group(x).then((c)=>{if(!s)return;M(c),S(c.host)},()=>{return}),()=>{s=!1}},[a.open,x,D]);let H=C(()=>new Set(d.map((s)=>s.name)),[d]),U=d.find((s)=>s.home)?.name,u=vs(v,(s)=>H.has(s)),h=xs(u,B||void 0,U),_=(s)=>d.find((c)=>c.name===s)?.displayName??s,F=u.length>=Jt,N=u.length>=Wn,q=i===void 0||u.join(",")!==(i.members??[]).join(",")||y!==void 0&&h!==y.host,T=async(s)=>{k(!0),G(void 0);try{await s(),await Ae()}catch(c){return G(l(c)),k(!1),!1}return k(!1),!0},J=async()=>{if(!i)return;if(!await T(async()=>{await ie.updateGroup(i.name,{...u.join(",")!==(i.members??[]).join(",")?{members:u}:{},...y&&h!==y.host?{host:h}:{}})}))return;f(t("Saved.")),a.onClose()},K=async()=>{let s=P.trim();if(s==="")return;let c=new Set([...d.map((V)=>V.name),...w.map((V)=>V.name)]),p;if(!await T(async()=>{p=await ie.createGroup({name:Ss(s,c),displayName:s,members:u,host:h})})||!p)return;so(p.room),a.go({key:p.room,name:p.name}),f(t("Made {name}.",{name:p.displayName})),a.onClose()};return n("div",{className:"stack council-sheet",children:[w.length>0?n("section",{className:"stack","aria-label":t("Councils"),children:[e("h3",{children:t("Councils")}),e("ul",{className:"menu",children:w.map((s)=>e(W,{view:s,current:s.key===i?.key,onPick:()=>{so(s.key),a.go(s),a.onClose()}},s.key))})]}):null,n("fieldset",{className:"field council-pick",children:[e("legend",{children:i?t("Edit this council"):t("Pick who sits")}),n("span",{className:"meta council-count","aria-live":"polite",children:[t("{count} of {max} picked",{count:u.length,max:Jt}),F?` · ${t("At most {max} knights",{max:Jt})}`:""]}),e("ul",{className:"menu",children:d.map((s)=>{let c=v.includes(s.name);return e("li",{children:n("label",{className:"menu-item menu-toggle seat-row",children:[e("input",{type:"checkbox",checked:c,disabled:!c&&F,onChange:()=>A(bs(v,s.name,Jt))}),e(Ue,{view:s,size:32}),e("span",{className:"menu-text",children:e("strong",{children:s.displayName})})]})},s.key)})})]}),N?e(Bt,{label:t("Host"),value:h,onChange:S,options:u.map((s)=>({value:s,label:_(s)}))}):e("span",{className:"meta",children:t("A council needs at least {min} knights.",{min:Wn})}),O?n("label",{htmlFor:E,children:[t("Council name"),e("input",{id:E,value:P,autoComplete:"off",onChange:(s)=>j(s.target.value)})]}):null,z?e(m,{message:z}):null,e("div",{className:"actions",children:i&&!O?n(g,{children:[e("button",{type:"button",className:"secondary",disabled:!N||b,onClick:()=>I(!0),children:t("Save as a new council")}),e("button",{type:"button",disabled:!N||!q||b,onClick:J,children:b?t("Saving…"):t("Done")})]}):e("button",{type:"button",disabled:!N||P.trim()===""||b,onClick:K,children:b?t("Saving…"):i?t("Save as a new council"):t("Make council")})})]})}function fe(a){return e(R,{open:a.open,title:t("Council"),onClose:a.onClose,size:"default",children:e(Y,{open:a.open,council:a.council,onClose:a.onClose,go:a.go??Q})})}export{fe as CouncilSheet};
@@ -0,0 +1 @@
1
+ import{Di,Ui,xr}from"./chunk-index-am7ghh75.js";import"./chunk-index-4jnn2g09.js";import"./chunk-index-haac6nbt.js";import"./chunk-index-zdzzf3fp.js";import"./chunk-index-zeqfnkty.js";import"./chunk-index-hef4gwtb.js";export{Di as CouncilChip,xr as CouncilView,Ui as useCouncilSheet};