pi-roundtable-web 0.30.0 → 0.30.3

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 (194) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/chunk-account-xz99gxg8.js +1 -0
  3. package/dist/{chunk-action-menu-mxcvx4a1.js → chunk-action-menu-fsxjfeaq.js} +1 -1
  4. package/dist/{chunk-agent-x53f7c2h.js → chunk-agent-bq536p6g.js} +1 -1
  5. package/dist/chunk-arranged-rooms-y2q330yg.js +1 -0
  6. package/dist/{chunk-attachments-qbv5ar62.js → chunk-attachments-s1z9jggf.js} +2 -2
  7. package/dist/chunk-bulk-actions-je4qp745.js +1 -0
  8. package/dist/{chunk-character-creator-1mfybhjz.js → chunk-character-creator-x8grfnwr.js} +2 -2
  9. package/dist/{chunk-codeeditor-y2emmmr0.js → chunk-codeeditor-3vh4q5af.js} +2 -2
  10. package/dist/{chunk-command-menu-sj2kfe4d.js → chunk-command-menu-2etjx0c7.js} +2 -2
  11. package/dist/chunk-confirm-wn14ffh3.js +1 -0
  12. package/dist/{chunk-connectors-1nmm8yc3.js → chunk-connectors-zxn3tbnv.js} +2 -2
  13. package/dist/{chunk-conversations-ec3aqjxs.js → chunk-conversations-2w67mmvv.js} +1 -1
  14. package/dist/{chunk-council-sheet-hdsg3fes.js → chunk-council-sheet-b4b04w9y.js} +2 -2
  15. package/dist/chunk-council-view-wem4vdqc.js +1 -0
  16. package/dist/{chunk-drag-pkghf4ts.js → chunk-drag-r9x782vs.js} +1 -1
  17. package/dist/{chunk-entry-e24gjxtd.js → chunk-entry-bq3j0xby.js} +1 -1
  18. package/dist/chunk-folder-list-bbn6ctsf.js +1 -0
  19. package/dist/chunk-folds-55w643e1.js +1 -0
  20. package/dist/{chunk-gate-xay9vedw.js → chunk-gate-d8deb600.js} +1 -1
  21. package/dist/chunk-host-icons-knmx5qa0.js +1 -0
  22. package/dist/chunk-host-picture-42n2n9gp.js +1 -0
  23. package/dist/chunk-host-state-az2ka7rs.js +1 -0
  24. package/dist/chunk-host-ui-1s0xyghd.js +1 -0
  25. package/dist/chunk-index-0xq8m6nw.js +2 -0
  26. package/dist/chunk-index-1k6n0hh9.js +2 -0
  27. package/dist/{chunk-index-0dyf2gdm.js → chunk-index-1kvnezap.js} +1 -1
  28. package/dist/{chunk-index-xekytvrr.js → chunk-index-25ewnkkb.js} +1 -1
  29. package/dist/chunk-index-3c4wvjkj.js +2 -0
  30. package/dist/chunk-index-4fyrpzwf.js +2 -0
  31. package/dist/{chunk-index-e3encn5p.js → chunk-index-50r5h98m.js} +1 -1
  32. package/dist/{chunk-index-65p4hfkr.js → chunk-index-5j6m33d2.js} +1 -1
  33. package/dist/chunk-index-5x86qy8d.js +2 -0
  34. package/dist/{chunk-index-r1g24er0.js → chunk-index-63qqjbs8.js} +2 -2
  35. package/dist/{chunk-index-xv3e4x0j.js → chunk-index-6btfp80d.js} +3 -3
  36. package/dist/{chunk-index-vaxytvde.js → chunk-index-6r61x1d2.js} +2 -2
  37. package/dist/{chunk-index-wqbcade7.js → chunk-index-711j3dpr.js} +2 -2
  38. package/dist/{chunk-index-xvdna54d.js → chunk-index-7379m5yw.js} +2 -2
  39. package/dist/{chunk-index-hk6aq03d.js → chunk-index-7wksnc48.js} +2 -2
  40. package/dist/{chunk-index-ndhwytvz.js → chunk-index-9hb4042t.js} +1 -1
  41. package/dist/{chunk-index-qqaaxh63.js → chunk-index-9smnxvd0.js} +2 -2
  42. package/dist/{chunk-index-6hy2fabj.js → chunk-index-ab60h2c5.js} +1 -1
  43. package/dist/{chunk-index-pz6926p5.js → chunk-index-apbknsyg.js} +2 -2
  44. package/dist/{chunk-index-ne8v2rxx.js → chunk-index-b093s676.js} +12 -12
  45. package/dist/chunk-index-b5924bb7.js +2 -0
  46. package/dist/chunk-index-bdf7gs56.js +2 -0
  47. package/dist/chunk-index-d0vznz2x.js +2 -0
  48. package/dist/{chunk-index-6e9nmad3.js → chunk-index-de5x85yn.js} +2 -2
  49. package/dist/chunk-index-e6z5kyz8.js +2 -0
  50. package/dist/chunk-index-evmzrr8e.js +2 -0
  51. package/dist/chunk-index-fdv6mepk.js +2 -0
  52. package/dist/chunk-index-ff8vzfgq.js +2 -0
  53. package/dist/chunk-index-hd7k712z.js +2 -0
  54. package/dist/{chunk-index-tfgd7vr5.js → chunk-index-hrpmm09c.js} +2 -2
  55. package/dist/{chunk-index-rvatmx8s.js → chunk-index-htdkpbrd.js} +25 -25
  56. package/dist/{chunk-index-vxn4zws9.js → chunk-index-jsgs2gmq.js} +3 -3
  57. package/dist/{chunk-index-gae833v6.js → chunk-index-kjxva289.js} +1 -1
  58. package/dist/{chunk-index-br1wechm.js → chunk-index-kkcx4bns.js} +2 -2
  59. package/dist/{chunk-index-xkb336kq.js → chunk-index-kvvmxbyh.js} +1 -1
  60. package/dist/{chunk-index-bh6m0bpm.js → chunk-index-mcb21c5a.js} +2 -2
  61. package/dist/chunk-index-n1w5rpxz.js +2 -0
  62. package/dist/{chunk-index-qb41kkt3.js → chunk-index-n7187vns.js} +2 -2
  63. package/dist/{chunk-index-37g8ggry.js → chunk-index-nk38jsgf.js} +1 -1
  64. package/dist/chunk-index-q6txr5q7.js +2 -0
  65. package/dist/{chunk-index-86x6b7dx.js → chunk-index-r868k92r.js} +3 -3
  66. package/dist/{chunk-index-ve07gdef.js → chunk-index-rj8cvc66.js} +1 -1
  67. package/dist/{chunk-index-93dr9fh8.js → chunk-index-rny986v2.js} +1 -1
  68. package/dist/{chunk-index-awc03q99.js → chunk-index-s6a9rvgd.js} +2 -2
  69. package/dist/{chunk-index-c8vsw9h8.js → chunk-index-sjt00y5k.js} +2 -2
  70. package/dist/{chunk-index-ads1abh1.js → chunk-index-sp35q2ay.js} +1 -1
  71. package/dist/{chunk-index-zr2qwzz4.js → chunk-index-t9an6yb2.js} +2 -2
  72. package/dist/{chunk-index-cd0ymvtj.js → chunk-index-tc8s2rz3.js} +1 -1
  73. package/dist/chunk-index-tn9qzrj2.js +2 -0
  74. package/dist/{chunk-index-gc30hm37.js → chunk-index-vgn794d7.js} +2 -2
  75. package/dist/{chunk-index-70pq2k7q.js → chunk-index-vvxr0vz8.js} +1 -1
  76. package/dist/{chunk-index-g3f1sdw0.js → chunk-index-w0vfwqck.js} +2 -2
  77. package/dist/{chunk-index-6j75embz.js → chunk-index-w1rarv3r.js} +2 -2
  78. package/dist/chunk-index-xfr1byr9.js +1 -0
  79. package/dist/{chunk-index-ptvrkv0r.js → chunk-index-xj1960qj.js} +2 -2
  80. package/dist/chunk-index-xwnkf825.js +2 -0
  81. package/dist/{chunk-index-vwd5drzh.js → chunk-index-y37ffyvy.js} +3 -3
  82. package/dist/{chunk-index-tqrjr37v.js → chunk-index-yrr5wvja.js} +2 -2
  83. package/dist/{chunk-index-726w3145.js → chunk-index-z1fvb2kq.js} +3 -3
  84. package/dist/chunk-index-zwfdwgnb.js +138 -0
  85. package/dist/chunk-lang-css-nt7ezre4.js +1 -0
  86. package/dist/{chunk-lang-dockerfile-9rc0adjw.js → chunk-lang-dockerfile-4422dqj4.js} +1 -1
  87. package/dist/{chunk-lang-go-t47kg9n0.js → chunk-lang-go-1n73q49t.js} +1 -1
  88. package/dist/chunk-lang-html-p4yg906g.js +1 -0
  89. package/dist/chunk-lang-javascript-yqkd14sv.js +1 -0
  90. package/dist/{chunk-lang-json-y33kawwg.js → chunk-lang-json-zm1ts7s7.js} +1 -1
  91. package/dist/{chunk-lang-markdown-2c2sqc4z.js → chunk-lang-markdown-3cv6a1mc.js} +2 -2
  92. package/dist/{chunk-lang-python-ymasvj52.js → chunk-lang-python-ba7s8q8w.js} +1 -1
  93. package/dist/{chunk-lang-rust-qcg53mkn.js → chunk-lang-rust-gx2hj5cw.js} +1 -1
  94. package/dist/{chunk-lang-shell-996wb0dk.js → chunk-lang-shell-ec7k63jq.js} +1 -1
  95. package/dist/{chunk-lang-sql-60rh2y3y.js → chunk-lang-sql-svdp20tw.js} +1 -1
  96. package/dist/{chunk-lang-toml-q1yzt70y.js → chunk-lang-toml-nj3sefw0.js} +1 -1
  97. package/dist/chunk-lang-typescript-84y9c0f8.js +1 -0
  98. package/dist/{chunk-lang-xml-k2a92cm3.js → chunk-lang-xml-jzdsx03j.js} +1 -1
  99. package/dist/{chunk-lang-yaml-qp3asq06.js → chunk-lang-yaml-deh87m32.js} +1 -1
  100. package/dist/chunk-layout-actions-x0xxb5da.js +1 -0
  101. package/dist/{chunk-mention-menu-qpksygcf.js → chunk-mention-menu-b1k1tm6b.js} +1 -1
  102. package/dist/chunk-menu-items-2meta18j.js +1 -0
  103. package/dist/chunk-mode-toggle-7a44994f.js +1 -0
  104. package/dist/{chunk-note-row-ngzxbdn6.js → chunk-note-row-pab6wtf0.js} +3 -3
  105. package/dist/{chunk-notes-9ykcajzc.js → chunk-notes-m0sjp2ct.js} +1 -1
  106. package/dist/{chunk-notice-bell-eryn2k5m.js → chunk-notice-bell-s15pgaw3.js} +1 -1
  107. package/dist/chunk-notices-zs8xg8v8.js +1 -0
  108. package/dist/{chunk-onboarding-ka11bgd0.js → chunk-onboarding-sddzxrw5.js} +1 -1
  109. package/dist/{chunk-overview-dgvrjwbc.js → chunk-overview-gkf6vfks.js} +1 -1
  110. package/dist/chunk-palette-m6bkdz1w.js +1 -0
  111. package/dist/chunk-placement-items-cb66mx65.js +1 -0
  112. package/dist/{chunk-profile-sdn7bs08.js → chunk-profile-mvj96kv6.js} +1 -1
  113. package/dist/{chunk-prompt-history-qfnj4w2y.js → chunk-prompt-history-mffm0c56.js} +1 -1
  114. package/dist/{chunk-prompts-4hdcvy6t.js → chunk-prompts-26ey03ak.js} +1 -1
  115. package/dist/chunk-room-confirms-1j8qfyj9.js +1 -0
  116. package/dist/{chunk-room-menu-18mnqcja.js → chunk-room-menu-6myvrac1.js} +1 -1
  117. package/dist/chunk-rooms-menu-button-3cnm8wdd.js +1 -0
  118. package/dist/{chunk-schedules-cy2dv8x0.js → chunk-schedules-gjfm0x30.js} +1 -1
  119. package/dist/{chunk-seat-menu-cw3z9560.js → chunk-seat-menu-neps7phz.js} +1 -1
  120. package/dist/chunk-section-fold-pgrjf74t.js +1 -0
  121. package/dist/{chunk-settings-rhdv64p7.js → chunk-settings-aa212bna.js} +1 -1
  122. package/dist/{chunk-sheet-hosts-hhs1e3a8.js → chunk-sheet-hosts-xwtaf228.js} +2 -2
  123. package/dist/{chunk-shortcut-help-fv6b6ntc.js → chunk-shortcut-help-aaat3wrh.js} +2 -2
  124. package/dist/{chunk-shortcuts-sjwrv858.js → chunk-shortcuts-wt9x6qd6.js} +1 -1
  125. package/dist/{chunk-skill-editor-zzmv9nfq.js → chunk-skill-editor-4jkr948n.js} +2 -2
  126. package/dist/{chunk-skills-b2enxk30.js → chunk-skills-87rvtwt1.js} +1 -1
  127. package/dist/{chunk-start-over-line-4rwasr8k.js → chunk-start-over-line-59zn5ekf.js} +2 -2
  128. package/dist/chunk-switcher-list-43n1vf29.js +1 -0
  129. package/dist/{chunk-tab-dot-b3gcgcrq.js → chunk-tab-dot-773bfgn1.js} +1 -1
  130. package/dist/chunk-table-1ghv10s7.js +1 -0
  131. package/dist/{chunk-table2d-k4z439nt.js → chunk-table2d-4k5n9dxy.js} +1 -1
  132. package/dist/{chunk-table3d-mx0afnv8.js → chunk-table3d-cwmxe12d.js} +21 -21
  133. package/dist/chunk-thread-actions-dd9ah02w.js +1 -0
  134. package/dist/{chunk-thread-cards-k9m7p5fn.js → chunk-thread-cards-qs242xk1.js} +1 -1
  135. package/dist/{chunk-thread-list-zz7596zy.js → chunk-thread-list-qxymkzs9.js} +2 -2
  136. package/dist/{chunk-transcript-8yjp18cr.js → chunk-transcript-sjra3d3m.js} +1 -1
  137. package/dist/{chunk-waiting-chip-nr9cza2j.js → chunk-waiting-chip-yq3485cq.js} +2 -2
  138. package/dist/chunk-waiting-xmy1cyk1.js +1 -0
  139. package/dist/chunk-where-m6ss9smq.js +1 -0
  140. package/dist/{chunk-workspace-hdamnf4r.js → chunk-workspace-jt68gwza.js} +2 -2
  141. package/dist/chunk-zh-tw-m2yyg5ty.js +1 -0
  142. package/dist/index.html +1 -1
  143. package/dist/sw.js +1 -1
  144. package/package.json +2 -2
  145. package/src/i18n/zh-tw.ts +0 -2
  146. package/dist/chunk-account-51nmc9g6.js +0 -1
  147. package/dist/chunk-arranged-rooms-1w3zqdtt.js +0 -1
  148. package/dist/chunk-bulk-actions-aktwxqc9.js +0 -1
  149. package/dist/chunk-confirm-ex5kc1st.js +0 -1
  150. package/dist/chunk-council-view-sba8fs4c.js +0 -1
  151. package/dist/chunk-folder-list-kghgyc0x.js +0 -1
  152. package/dist/chunk-folds-crd9k375.js +0 -1
  153. package/dist/chunk-host-icons-y9hd1qqd.js +0 -1
  154. package/dist/chunk-host-picture-k16n5wm3.js +0 -1
  155. package/dist/chunk-host-state-1mbsrmhk.js +0 -1
  156. package/dist/chunk-host-ui-4pymhn6v.js +0 -1
  157. package/dist/chunk-index-14cxgacv.js +0 -2
  158. package/dist/chunk-index-39gw0qhr.js +0 -2
  159. package/dist/chunk-index-4p45h04z.js +0 -2
  160. package/dist/chunk-index-5e8wn6r3.js +0 -2
  161. package/dist/chunk-index-6f4qvp5p.js +0 -2
  162. package/dist/chunk-index-8cxmgzhy.js +0 -2
  163. package/dist/chunk-index-97238pp8.js +0 -2
  164. package/dist/chunk-index-gpaychmm.js +0 -2
  165. package/dist/chunk-index-k3hj2310.js +0 -2
  166. package/dist/chunk-index-maf6wr1b.js +0 -2
  167. package/dist/chunk-index-mhb8mpg3.js +0 -2
  168. package/dist/chunk-index-n92zea3s.js +0 -2
  169. package/dist/chunk-index-p4rc9swx.js +0 -2
  170. package/dist/chunk-index-pce4byw4.js +0 -2
  171. package/dist/chunk-index-qwztcbjz.js +0 -2
  172. package/dist/chunk-index-tvsvtd4q.js +0 -2
  173. package/dist/chunk-index-vw592m3p.js +0 -2
  174. package/dist/chunk-index-x7p6k52w.js +0 -138
  175. package/dist/chunk-index-yzd9cg0s.js +0 -1
  176. package/dist/chunk-lang-css-6t2q4xw4.js +0 -1
  177. package/dist/chunk-lang-html-c6p22v5m.js +0 -1
  178. package/dist/chunk-lang-javascript-m57t19pw.js +0 -1
  179. package/dist/chunk-lang-typescript-7gcbrhbd.js +0 -1
  180. package/dist/chunk-layout-actions-yxh77zcz.js +0 -1
  181. package/dist/chunk-menu-items-95evdhk1.js +0 -1
  182. package/dist/chunk-mode-toggle-dqwvcr2p.js +0 -1
  183. package/dist/chunk-notices-jkv1derx.js +0 -1
  184. package/dist/chunk-palette-wmvynt7n.js +0 -1
  185. package/dist/chunk-placement-items-zyqq2mp7.js +0 -1
  186. package/dist/chunk-room-confirms-b8gvak47.js +0 -1
  187. package/dist/chunk-rooms-menu-button-hjg4zqjy.js +0 -1
  188. package/dist/chunk-section-fold-9tc2m103.js +0 -1
  189. package/dist/chunk-switcher-list-dcq91xxa.js +0 -1
  190. package/dist/chunk-table-6j64ps89.js +0 -1
  191. package/dist/chunk-thread-actions-rs5xpf1r.js +0 -1
  192. package/dist/chunk-waiting-9gshhhx0.js +0 -1
  193. package/dist/chunk-where-8mq8azgw.js +0 -1
  194. package/dist/chunk-zh-tw-ama40y87.js +0 -1
package/CHANGELOG.md CHANGED
@@ -5,6 +5,23 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
5
5
 
6
6
  ## [Unreleased]
7
7
 
8
+ ## [0.30.3] - 2026-11-01
9
+
10
+ - 0.30.2 was tagged but never published: its release run stopped on lint (a hook's dependency suppression the change had dropped) before any package was published. 0.30.3 carries 0.30.2's changes.
11
+
12
+ ## [0.30.2] - 2026-11-01
13
+
14
+ ### Fixed
15
+
16
+ - The animated scene now reports reading, as the chat log does. A stored message counts as read once the dialogue box shows it while the page is visible; a line still waiting in the box's queue, a reply still streaming and an owner's message not yet sent do not count, and a line shown while the page is hidden is reported when the page shows again. The open Log sheet reports the newest message in its view. Before, nothing in the scene moved the read cursor, so unread counts and other people's read marks stayed where the chat log had left them.
17
+
18
+ ## [0.30.1] - 2026-11-01
19
+
20
+ ### Fixed
21
+
22
+ - In a host's room, a message that is `/clear` or `/new` whole is sent as an ordinary message to the host kind, as any other text is: it is no longer caught for a refusal notice, so a host kind whose own conversation takes that text can receive it. A host's room still has no command menu.
23
+ - A Pi extension command is offered in a knight's command menu only when the plugin that declared it also registers it (see the core changelog).
24
+
8
25
  ## [0.30.0] - 2026-11-01
9
26
 
10
27
  ### Added
@@ -0,0 +1 @@
1
+ import{p,T,b,e,S}from"./chunk-index-htdkpbrd.js";var a={profile:b(()=>(p("mvj96kv6"),import("./chunk-profile-mvj96kv6.js")).then((o)=>({default:o.ProfilePage}))),notices:b(()=>(p("zs8xg8v8"),import("./chunk-notices-zs8xg8v8.js")).then((o)=>({default:o.NoticesPage}))),onboarding:b(()=>(p("sddzxrw5"),import("./chunk-onboarding-sddzxrw5.js")).then((o)=>({default:o.OnboardingPage})))};function n({pane:o}){let t=a[o];return t?e(T,{fallback:e(S,{}),children:e(t,{})}):null}export{n as default};
@@ -1 +1 @@
1
- import{o,Se,a,r,g,e,n,s,_t,js}from"./chunk-index-rvatmx8s.js";import{A}from"./chunk-index-0dyf2gdm.js";var L=()=>typeof matchMedia==="function"&&matchMedia("(max-width: 719px)").matches,k={rtMenu:!0},x=()=>Boolean(window.history.state?.rtMenu),w=8,E=(t)=>t?.isConnected?t:null;function M(t){return t.items.map((i)=>n("button",{type:"button",role:i.checked===void 0?"menuitem":"menuitemcheckbox",...i.checked===void 0?{}:{"aria-checked":i.checked},className:"menu-item menu-link","data-tone":i.tone,onClick:()=>t.onChoose(i),children:[i.icon?e("span",{className:"menu-icon","data-tone":i.tone,children:e(s,{name:i.icon,size:18})}):null,e("span",{className:"menu-text",children:e("strong",{children:i.label})}),i.checked?e(s,{name:"check",size:18,className:"menu-check"}):null]},i.id))}function H({menu:t}){let i=a(void 0);if(t)i.current=t;let l=i.current,m=a(!1),h=a(void 0),p=t?.serial;return o(()=>{if(p===void 0)return;return window.history.pushState(k,"",window.location.href),m.current=!0,()=>{if(m.current)m.current=!1,window.history.back()}},[p]),o(()=>{let f=()=>{if(!m.current||x())return;m.current=!1,_t();let y=h.current;h.current=void 0,y?.()};return window.addEventListener("popstate",f),()=>window.removeEventListener("popstate",f)},[]),e(A,{open:t!==void 0,title:l?.title??"",onClose:_t,restoreFocus:()=>E(l?.source??null),children:l?e("div",{className:"menu action-items",role:"menu","aria-label":l.title,children:e(M,{items:l.items,onChoose:(f)=>{if(!m.current){_t(),f.run();return}h.current=f.run,window.history.back()}})}):null})}function T({menu:t}){let i=a(null),[l,m]=r(t.at),{source:h}=t,p=(u)=>{E(h)?.focus(),_t(),u?.()},f=a(p);f.current=p,Se(()=>{let u=i.current;if(!u)return;let d={left:u.style.left,top:u.style.top};u.style.left="0px",u.style.top="0px";let c={width:u.offsetWidth,height:u.offsetHeight};u.style.left=d.left,u.style.top=d.top,m({x:Math.max(w,Math.min(t.at.x,window.innerWidth-c.width-w)),y:Math.max(w,Math.min(t.at.y,window.innerHeight-c.height-w))}),u.querySelector('[role^="menuitem"]')?.focus()},[t.serial]),o(()=>{let u=(c)=>{if(c.target instanceof Node&&i.current?.contains(c.target))return;_t()},d=()=>_t();return document.addEventListener("pointerdown",u,!0),document.addEventListener("wheel",u,{capture:!0,passive:!0}),document.addEventListener("touchmove",u,{capture:!0,passive:!0}),window.addEventListener("resize",d),()=>{document.removeEventListener("pointerdown",u,!0),document.removeEventListener("wheel",u,!0),document.removeEventListener("touchmove",u,!0),window.removeEventListener("resize",d)}},[]);let y=(u)=>{let d=[...i.current?.querySelectorAll('[role^="menuitem"]')??[]],c=d.indexOf(document.activeElement),v=(b)=>{u.preventDefault(),d[(b+d.length)%d.length]?.focus()};switch(u.key){case"Escape":u.preventDefault(),u.stopPropagation(),f.current();return;case"ArrowDown":return v(c+1);case"ArrowUp":return v(c<0?-1:c-1);case"Tab":return v(u.shiftKey?c<0?-1:c-1:c+1);case"Home":return v(0);case"End":return v(-1)}};return e("div",{ref:i,className:"action-popover",role:"menu","aria-label":t.title,tabIndex:-1,style:{left:`${l.x}px`,top:`${l.y}px`},onKeyDown:y,children:e(M,{items:t.items,onChoose:(u)=>p(u.run)})})}function I(){let t=js(),i=a(void 0);if(t&&i.current?.serial!==t.serial)i.current={serial:t.serial,sheet:L()};let l=Boolean(t&&i.current?.sheet);return n(g,{children:[e(H,{menu:l?t:void 0}),t&&!l?e(T,{menu:t},t.serial):null]})}export{I as ActionMenuHost};
1
+ import{o,Se,a,r,g,e,n,s,_t,Js}from"./chunk-index-htdkpbrd.js";import{A}from"./chunk-index-1kvnezap.js";var L=()=>typeof matchMedia==="function"&&matchMedia("(max-width: 719px)").matches,k={rtMenu:!0},x=()=>Boolean(window.history.state?.rtMenu),w=8,E=(t)=>t?.isConnected?t:null;function M(t){return t.items.map((i)=>n("button",{type:"button",role:i.checked===void 0?"menuitem":"menuitemcheckbox",...i.checked===void 0?{}:{"aria-checked":i.checked},className:"menu-item menu-link","data-tone":i.tone,onClick:()=>t.onChoose(i),children:[i.icon?e("span",{className:"menu-icon","data-tone":i.tone,children:e(s,{name:i.icon,size:18})}):null,e("span",{className:"menu-text",children:e("strong",{children:i.label})}),i.checked?e(s,{name:"check",size:18,className:"menu-check"}):null]},i.id))}function H({menu:t}){let i=a(void 0);if(t)i.current=t;let l=i.current,m=a(!1),h=a(void 0),p=t?.serial;return o(()=>{if(p===void 0)return;return window.history.pushState(k,"",window.location.href),m.current=!0,()=>{if(m.current)m.current=!1,window.history.back()}},[p]),o(()=>{let f=()=>{if(!m.current||x())return;m.current=!1,_t();let y=h.current;h.current=void 0,y?.()};return window.addEventListener("popstate",f),()=>window.removeEventListener("popstate",f)},[]),e(A,{open:t!==void 0,title:l?.title??"",onClose:_t,restoreFocus:()=>E(l?.source??null),children:l?e("div",{className:"menu action-items",role:"menu","aria-label":l.title,children:e(M,{items:l.items,onChoose:(f)=>{if(!m.current){_t(),f.run();return}h.current=f.run,window.history.back()}})}):null})}function T({menu:t}){let i=a(null),[l,m]=r(t.at),{source:h}=t,p=(u)=>{E(h)?.focus(),_t(),u?.()},f=a(p);f.current=p,Se(()=>{let u=i.current;if(!u)return;let d={left:u.style.left,top:u.style.top};u.style.left="0px",u.style.top="0px";let c={width:u.offsetWidth,height:u.offsetHeight};u.style.left=d.left,u.style.top=d.top,m({x:Math.max(w,Math.min(t.at.x,window.innerWidth-c.width-w)),y:Math.max(w,Math.min(t.at.y,window.innerHeight-c.height-w))}),u.querySelector('[role^="menuitem"]')?.focus()},[t.serial]),o(()=>{let u=(c)=>{if(c.target instanceof Node&&i.current?.contains(c.target))return;_t()},d=()=>_t();return document.addEventListener("pointerdown",u,!0),document.addEventListener("wheel",u,{capture:!0,passive:!0}),document.addEventListener("touchmove",u,{capture:!0,passive:!0}),window.addEventListener("resize",d),()=>{document.removeEventListener("pointerdown",u,!0),document.removeEventListener("wheel",u,!0),document.removeEventListener("touchmove",u,!0),window.removeEventListener("resize",d)}},[]);let y=(u)=>{let d=[...i.current?.querySelectorAll('[role^="menuitem"]')??[]],c=d.indexOf(document.activeElement),v=(b)=>{u.preventDefault(),d[(b+d.length)%d.length]?.focus()};switch(u.key){case"Escape":u.preventDefault(),u.stopPropagation(),f.current();return;case"ArrowDown":return v(c+1);case"ArrowUp":return v(c<0?-1:c-1);case"Tab":return v(u.shiftKey?c<0?-1:c-1:c+1);case"Home":return v(0);case"End":return v(-1)}};return e("div",{ref:i,className:"action-popover",role:"menu","aria-label":t.title,tabIndex:-1,style:{left:`${l.x}px`,top:`${l.y}px`},onKeyDown:y,children:e(M,{items:t.items,onChoose:(u)=>p(u.run)})})}function I(){let t=Js(),i=a(void 0);if(t&&i.current?.serial!==t.serial)i.current={serial:t.serial,sheet:L()};let l=Boolean(t&&i.current?.sheet);return n(g,{children:[e(H,{menu:l?t:void 0}),t&&!l?e(T,{menu:t},t.serial):null]})}export{I as ActionMenuHost};
@@ -1 +1 @@
1
- import{o,e,X,u,S,Ke}from"./chunk-index-rvatmx8s.js";function c({name:r}){let m=u((i)=>i.listed),t=u((i)=>Object.values(i.rooms).find((n)=>n.view?.kind==="agent"&&n.view.name===r)?.view?.key,r);return o(()=>{if(t)X("room",t,{replace:!0}),Ke(r);else if(m)X("rooms",void 0,{replace:!0})},[t,m,r]),e("div",{className:"page",children:e(S,{})})}export{c as AgentPage};
1
+ import{o,e,X,l,S,Ke}from"./chunk-index-htdkpbrd.js";function c({name:r}){let m=l((i)=>i.listed),t=l((i)=>Object.values(i.rooms).find((n)=>n.view?.kind==="agent"&&n.view.name===r)?.view?.key,r);return o(()=>{if(t)X("room",t,{replace:!0}),Ke(r);else if(m)X("rooms",void 0,{replace:!0})},[t,m,r]),e("div",{className:"page",children:e(S,{})})}export{c as AgentPage};
@@ -0,0 +1 @@
1
+ import{p,T,b,ee,C,a,t,g,e,n,s,ze,l,k,_,Oe,rn,Mn,te,$e,Er,Bi,vo,Dt,Fi,xo}from"./chunk-index-htdkpbrd.js";import"./chunk-index-50r5h98m.js";import"./chunk-index-hrpmm09c.js";import{bn,hr}from"./chunk-index-y37ffyvy.js";import{Ue}from"./chunk-index-5x86qy8d.js";import{Li}from"./chunk-index-q6txr5q7.js";import{bi}from"./chunk-index-hd7k712z.js";import{Ni}from"./chunk-index-ff8vzfgq.js";import{Jt}from"./chunk-index-n7187vns.js";import"./chunk-index-b5924bb7.js";import"./chunk-index-711j3dpr.js";import{ut}from"./chunk-index-w0vfwqck.js";bn();var O=b(()=>(p("bbn6ctsf"),import("./chunk-folder-list-bbn6ctsf.js")).then((o)=>({default:o.FolderList}))),Z=ee(function(c){let{view:i}=c,h=Jt(()=>rn(i.key),i.home?void 0:Ni(i.key));return e(vo,{...c,press:h,item:{...i.home?{}:{"data-drop-item":"","data-key":i.key},...c.arranging?{"data-arranging":""}:{}},after:c.arranging?e("button",{type:"button",className:"icon-button row-more","aria-haspopup":"menu","aria-label":t("Room menu"),onClick:(r)=>{let u=r.currentTarget;rn(i.key).then((d)=>{if(!d)return;let N=u.getBoundingClientRect();Oe({...d,at:{x:N.left,y:N.bottom},via:"key",source:u})},()=>{return})},children:e(s,{name:"more",size:18})}):null})});function L(o){let{now:c}=te(),{timeZone:i}=_(),h=Dt(o.rooms);return e("ul",{className:"room-list",children:h.map(({key:r,...u})=>{let d=o.threads[r];return e(Z,{...u,active:r===o.active,now:c,timeZone:i,arranging:o.arranging,...d?{threads:e(Fi,{open:d.open,closed:d.closed,active:o.active,parent:r})}:{}},r)})})}function y(o){let i=Dt(o.rooms).length===0;if(i&&o.zone?.kind!=="pinned")return null;let h=o.zone?{"data-drop-zone":o.zone.kind,"data-zone-id":o.zone.id}:{},r=(u)=>e(L,{rooms:u,threads:o.threads,active:o.active,arranging:o.arranging});if(o.fold&&!i)return e(hr,{id:o.fold,title:o.title,rooms:o.rooms,active:o.active,attrs:h,children:r});return n("section",{className:"stack",...i?{"data-empty":""}:{},...h,children:[e("h2",{className:"section-title",children:o.title}),i?null:r(o.rooms)]})}function le(o){let c=Boolean(_().kinds?.length),i=l((m)=>JSON.stringify({listed:m.listed,...ut(m,(M)=>ze(m,M))})),h=Li(),r=a(i);if(!h)r.current=i;let u=r.current,{listed:d,...N}=C(()=>JSON.parse(u),[u]),{home:z,pinned:S,folders:R,restAgents:P,restGroups:D,rest:A,threads:F,orphans:f}=N,w=Er(),K=z.length+S.length+A.length===0&&R.every((m)=>m.rooms.length===0)&&f.open.length+f.closed.length===0,v={threads:F,active:o.active,arranging:w};return n("div",{className:"page","data-column":o.active?"":void 0,"data-drop-root":"",children:[n("header",{className:"page-head",children:[e("h1",{children:t("Rooms")}),n("div",{className:"actions",children:[n("button",{type:"button",className:"header-button search-button",onClick:o.onSearch,children:[e(s,{name:"search",size:16}),e("span",{children:t("Find a room")}),e("kbd",{children:"⌘K"})]}),d?e("button",{type:"button",className:"header-button icon-button","aria-haspopup":"menu","aria-label":t("Folders and order"),onClick:(m)=>bi(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)=>Mn(m.currentTarget),children:e(s,{name:"plus"})})]})]}),w?n("div",{className:"arrange-bar",children:[n("button",{type:"button",className:"secondary",onClick:()=>Ue({kind:"new"}),children:[e(s,{name:"plus",size:16}),e("span",{children:t("Add a folder")})]}),e("button",{type:"button",onClick:()=>Bi(!1),children:t("Done")})]}):null,d&&K&&!c?e(k,{children:t("No rooms yet. Rooms appear when the team has a knight.")}):null,!d?n("div",{className:"stack","aria-busy":"true",children:[e("div",{className:"skeleton"}),e("div",{className:"skeleton"}),e("div",{className:"skeleton"})]}):null,e(y,{title:t("Home"),rooms:z,...v}),e(y,{title:t("Pinned"),rooms:S,zone:{kind:"pinned",id:"pinned"},fold:$e("pinned"),...v}),R.length>0?e("div",{className:"stack folder-list","data-folder-list":"",children:e(T,{fallback:e("div",{className:"skeleton","aria-busy":"true"}),children:e(O,{folders:R,active:o.active,listed:d,rooms:(m)=>e(L,{rooms:m,threads:F,active:o.active,arranging:w})})})}):null,R.length>0?e(y,{title:t("Ungrouped"),rooms:A,zone:{kind:"rest",id:"rest"},fold:$e("rest"),...v}):n(g,{children:[e(y,{title:t("Knights"),rooms:P,zone:{kind:"rest",id:"rest-agents"},fold:$e("agents"),...v}),e(y,{title:t("Groups"),rooms:D,zone:{kind:"rest",id:"rest-groups"},fold:$e("groups"),...v})]}),f.open.length+f.closed.length>0?n("section",{className:"stack",children:[e("h2",{className:"section-title",children:t("Dispatch threads")}),e(Fi,{open:f.open,closed:f.closed,active:o.active})]}):null,e(xo,{active:o.active})]})}export{le as ArrangedRoomsPage};
@@ -1,4 +1,4 @@
1
- import{Se,a,r,t,F,e,n,s,_e,en,Zs,Pe,Lt,na}from"./chunk-index-rvatmx8s.js";import{B}from"./chunk-index-fw6kawhw.js";var u=`
1
+ import{Se,a,r,t,F,e,n,s,_e,en,Ys,Pe,Lt,ra}from"./chunk-index-htdkpbrd.js";import{B}from"./chunk-index-fw6kawhw.js";var u=`
2
2
  .attachments {
3
3
  margin-top: var(--space-3);
4
4
  padding: var(--space-2);
@@ -99,4 +99,4 @@ import{Se,a,r,t,F,e,n,s,_e,en,Zs,Pe,Lt,na}from"./chunk-index-rvatmx8s.js";import
99
99
  color: inherit;
100
100
  text-decoration: underline;
101
101
  }
102
- `;function h({file:o}){let i=Lt(()=>na(o));return o.type.startsWith("image/")?e("li",{children:e("a",{...i,href:en(o),target:"_blank",rel:"noreferrer noopener",children:e("img",{src:en(o),alt:o.name,loading:"lazy",decoding:"async",className:"file-image"})})}):e("li",{children:n("a",{...i,className:"file-chip",href:en(o),download:o.name,title:o.name,children:[e(s,{name:"file",size:16}),e("span",{className:"file-name",children:o.name}),e("span",{className:"file-size",children:Pe(o.size)})]})})}function f(o){B("attachments",u);let{files:i,message:m}=o;return n("section",{className:"attachments","aria-label":t("Attachments ({count})",{count:i.length}),children:[n("div",{className:"attachments-head",children:[e(s,{name:"attach",size:16}),e("span",{children:t("Attachments ({count})",{count:i.length})}),m&&i.length>=2?n("a",{className:"link-button",href:Zs(m),download:!0,children:[e(s,{name:"download",size:16}),t("Download all")]}):null]}),e("ul",{className:"files",children:i.map((c)=>e(h,{file:c},c.id))})]})}var g=0.9;function A({count:o}){B("attachments",u);let i=a(null),[m,c]=r(!1);return Se(()=>{let l=i.current?.closest(".bubble");if(!l)return;let d=()=>c(l.getBoundingClientRect().height>window.innerHeight*g);d(),window.addEventListener("resize",d);let p=typeof ResizeObserver==="function"?new ResizeObserver(d):void 0;return p?.observe(l),()=>{window.removeEventListener("resize",d),p?.disconnect()}},[]),n("button",{ref:i,type:"button",className:"link-button attachments-jump",hidden:!m,onClick:(l)=>{l.stopPropagation(),i.current?.closest(".bubble")?.querySelector(".attachments")?.scrollIntoView({behavior:_e()?"auto":"smooth",block:"start"})},children:[e(s,{name:"attach",size:14}),F(o,"{count} attachment","{count} attachments")]})}export{A as AttachmentsJump,f as default};
102
+ `;function h({file:o}){let i=Lt(()=>ra(o));return o.type.startsWith("image/")?e("li",{children:e("a",{...i,href:en(o),target:"_blank",rel:"noreferrer noopener",children:e("img",{src:en(o),alt:o.name,loading:"lazy",decoding:"async",className:"file-image"})})}):e("li",{children:n("a",{...i,className:"file-chip",href:en(o),download:o.name,title:o.name,children:[e(s,{name:"file",size:16}),e("span",{className:"file-name",children:o.name}),e("span",{className:"file-size",children:Pe(o.size)})]})})}function f(o){B("attachments",u);let{files:i,message:m}=o;return n("section",{className:"attachments","aria-label":t("Attachments ({count})",{count:i.length}),children:[n("div",{className:"attachments-head",children:[e(s,{name:"attach",size:16}),e("span",{children:t("Attachments ({count})",{count:i.length})}),m&&i.length>=2?n("a",{className:"link-button",href:Ys(m),download:!0,children:[e(s,{name:"download",size:16}),t("Download all")]}):null]}),e("ul",{className:"files",children:i.map((c)=>e(h,{file:c},c.id))})]})}var g=0.9;function A({count:o}){B("attachments",u);let i=a(null),[m,c]=r(!1);return Se(()=>{let l=i.current?.closest(".bubble");if(!l)return;let d=()=>c(l.getBoundingClientRect().height>window.innerHeight*g);d(),window.addEventListener("resize",d);let p=typeof ResizeObserver==="function"?new ResizeObserver(d):void 0;return p?.observe(l),()=>{window.removeEventListener("resize",d),p?.disconnect()}},[]),n("button",{ref:i,type:"button",className:"link-button attachments-jump",hidden:!m,onClick:(l)=>{l.stopPropagation(),i.current?.closest(".bubble")?.querySelector(".attachments")?.scrollIntoView({behavior:_e()?"auto":"smooth",block:"start"})},children:[e(s,{name:"attach",size:14}),F(o,"{count} attachment","{count} attachments")]})}export{A as AttachmentsJump,f as default};
@@ -0,0 +1 @@
1
+ import{t,F,O,c,f}from"./chunk-index-htdkpbrd.js";import{an}from"./chunk-index-hrpmm09c.js";import"./chunk-index-50r5h98m.js";import{Ln,Po}from"./chunk-index-sjt00y5k.js";import{Mo}from"./chunk-index-b5924bb7.js";import{re}from"./chunk-index-kvvmxbyh.js";import"./chunk-index-711j3dpr.js";var s=500,d=(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=Mo(n),e=Object.keys(r);if(e.length===0)return;let a=[];try{for(let o of d(e))a.push(...(await Ln.readAll(o)).moved)}catch(o){f(c(o),"danger"),i();return}an(Object.fromEntries(e.map((o)=>[o,0]))),f(F(e.length,"Marked {count} room as read","Marked {count} rooms as read"),"info",a.length?{label:t("Undo"),run:()=>void m(a,r)}:void 0)}async function m(n,r){try{for(let e of d(n)){let{restored:a}=await Ln.unreadAll(e);an(Object.fromEntries(a.map((o)=>[o,r[o]??0])))}}catch(e){f(c(e),"danger")}i()}var P=(n)=>Po(n);async function l(n){try{await Ln.restoreHelpers(n)}catch(r){f(c(r),"danger")}i()}async function R(n){let r;try{r=(await Ln.archiveFinishedHelpers(n)).archived.flatMap((a)=>a.names)}catch(e){f(c(e),"danger"),i();return}if(i(),r.length===0)return;f(F(r.length,"Archived {count} temp knight","Archived {count} temp knights"),"info",{label:t("Undo"),run:()=>void l(r)})}async function T(n,r){try{await re.archiveAgent(n)}catch(e){f(c(e),"danger"),i();return}i(),f(t("Archived {name}",{name:r}),"info",{label:t("Undo"),run:()=>void l([n])})}export{T as archiveHelper,P as clearAllFinished,R as clearFinishedHelpers,w as markAllRead,l as putBackHelpers};
@@ -1,4 +1,4 @@
1
- import{Je,sn,Y,Fi,Nn}from"./chunk-index-xvdna54d.js";import{ee,ao,o,R,C,a,r,t,c,g,e,n,Xi,fe,y,l,f,Re,Rn,he,et}from"./chunk-index-rvatmx8s.js";import{D}from"./chunk-index-gae833v6.js";import{A}from"./chunk-index-0dyf2gdm.js";import{B}from"./chunk-index-fw6kawhw.js";var ue={"hat.none":"No hat","hat.goggcap":"Leather cap","hat.tallcap":"Burgundian felt cap","hat.softcap":"Soft cap","hat.hardhat":"Iron skullcap","hat.fcap":"Hunter's cap","hat.winghelm":"Winged helm","hat.helm":"Helm","hat.mortar":"Biretta","hat.beret":"Chaperon","hat.goggles":"Pointed cap","hat.tricorn":"Pilgrim hat","hat.sailor":"Straw hat","hat.kettle":"Kettle hat","hat.cavalier":"Feathered hat","hat.toque":"Linen cook's cap","hair.none":"No hair","beard.none":"No beard","accessory.none":"No accessory","prop.beads":"Prayer beads","prop.marotte":"Marotte","prop.map":"Chart","prop.flask":"Alchemist's phial","prop.telescope":"Astrolabe","prop.wrench":"Dividers","outfit.surplice":"Surplice","outfit.overalls":"Work jerkin","outfit.armor":"Mail hauberk","outfit.apron":"Smith's apron","outfit.chef":"Cook's tunic","outfit.coat":"Doublet","outfit.vest":"Pourpoint","outfit.sailor":"Mariner's tunic","hair.bob":"Bob","hair.bun":"Bun","hair.ponytail":"Ponytail"},X=(i)=>i.charAt(0).toUpperCase()+i.slice(1);function x(i,d){let h=`character.${i}.${d}`,p=t(h);if(p!==h)return p;if(i==="class")return Y.classes[d]?.label??X(d);return ue[`${i}.${d}`]??X(d)}function Z(i){let d=`character.jobs.${i}`,h=t(d);return h!==d?h:Y.classes[i]?.jobs??""}var ae=`
1
+ import{Je,sn,Y,Gi,Nn}from"./chunk-index-7379m5yw.js";import{ee,lo,o,R,C,a,r,t,u,g,e,n,zi,fe,y,c,f,Re,Rn,he,et}from"./chunk-index-htdkpbrd.js";import{D}from"./chunk-index-kjxva289.js";import{A}from"./chunk-index-1kvnezap.js";import{B}from"./chunk-index-fw6kawhw.js";var ue={"hat.none":"No hat","hat.goggcap":"Leather cap","hat.tallcap":"Burgundian felt cap","hat.softcap":"Soft cap","hat.hardhat":"Iron skullcap","hat.fcap":"Hunter's cap","hat.winghelm":"Winged helm","hat.helm":"Helm","hat.mortar":"Biretta","hat.beret":"Chaperon","hat.goggles":"Pointed cap","hat.tricorn":"Pilgrim hat","hat.sailor":"Straw hat","hat.kettle":"Kettle hat","hat.cavalier":"Feathered hat","hat.toque":"Linen cook's cap","hair.none":"No hair","beard.none":"No beard","accessory.none":"No accessory","prop.beads":"Prayer beads","prop.marotte":"Marotte","prop.map":"Chart","prop.flask":"Alchemist's phial","prop.telescope":"Astrolabe","prop.wrench":"Dividers","outfit.surplice":"Surplice","outfit.overalls":"Work jerkin","outfit.armor":"Mail hauberk","outfit.apron":"Smith's apron","outfit.chef":"Cook's tunic","outfit.coat":"Doublet","outfit.vest":"Pourpoint","outfit.sailor":"Mariner's tunic","hair.bob":"Bob","hair.bun":"Bun","hair.ponytail":"Ponytail"},X=(i)=>i.charAt(0).toUpperCase()+i.slice(1);function x(i,l){let h=`character.${i}.${l}`,p=t(h);if(p!==h)return p;if(i==="class")return Y.classes[l]?.label??X(l);return ue[`${i}.${l}`]??X(l)}function Z(i){let l=`character.jobs.${i}`,h=t(l);return h!==l?h:Y.classes[i]?.jobs??""}var ae=`
2
2
  .creator {
3
3
  display: grid;
4
4
  gap: var(--space-5);
@@ -222,4 +222,4 @@ dialog.sheet dialog.sheet .creator-field > h3 {
222
222
  .creator-actions {
223
223
  flex-wrap: wrap;
224
224
  }
225
- `;var M=[{field:"hat",title:c("Hat"),ids:Y.hats},{field:"outfit",title:c("Outfit"),ids:Y.outfits},{field:"prop",title:c("Prop"),ids:Y.props},{field:"hair",title:c("Hair"),ids:Y.hair},{field:"beard",title:c("Beard"),ids:["none",...Y.beards]},{field:"accessory",title:c("Accessory"),ids:["none",...Y.accessories]}],pe=new Set(["class","colors","palette","build","skin","hairColor",...M.map((i)=>i.field)]),oe=Object.keys(Y.palettes),te={idle:c("Idle"),thinking:c("Thinking"),working:c("Working"),waiting:c("Waiting for you"),done:c("Done"),error:c("Error"),sleepy:c("Sleepy")},ge={slim:c("Slim"),regular:c("Regular"),stout:c("Stout")};function _(i){return{class:i.class,outfit:i.outfit,hat:i.hat,prop:i.prop,hair:i.hair,beard:i.beard,accessory:i.accessory,build:i.build,skin:i.skin,hairColor:i.hairColor,colors:{...i.colors}}}var re=(i)=>JSON.stringify(_(i)),k=(i)=>i[Math.floor(Math.random()*i.length)];function be(){return{class:k(Je),outfit:k(Y.outfits),hat:k(Y.hats),prop:k(Y.props),hair:k(Y.hair),beard:k(["none",...Y.beards]),accessory:k(["none",...Y.accessories]),build:k(["slim","regular","stout"]),skin:k([0,1,2,3,4,5]),hairColor:k(Y.hairColors),palette:k(oe)}}var ne=ee(function(d){return n("button",{type:"button",className:"creator-tile","aria-pressed":d.pressed,title:d.hint?`${d.label} — ${d.hint}`:d.label,onClick:d.onPick,...d.data,children:[e(he,{spec:d.spec,size:d.size,live:!1}),e("span",{children:d.label})]})});function ve(i,d,h){let p=JSON.stringify({...i,[d]:0});return C(()=>h.map((m)=>({...i,[d]:m})),[p,d,h])}function ye(){let i=a(null),[d,h]=r();return o(()=>{let p=i.current;if(!p)return;let m=()=>{let S=p.scrollLeft>1,P=p.scrollLeft+p.clientWidth<p.scrollWidth-1;h(S&&P?"both":P?"end":S?"start":void 0)};m(),p.addEventListener("scroll",m,{passive:!0});let b=typeof ResizeObserver>"u"?void 0:new ResizeObserver(m);return b?.observe(p),()=>{p.removeEventListener("scroll",m),b?.disconnect()}},[]),[i,d]}function ke(i){let{part:d}=i,h=ve(i.shown,d.field,d.ids),[p,m]=ye();return e("div",{className:"creator-strip",ref:p,"data-more":m,children:d.ids.map((b,S)=>e(ne,{data:{[`data-${d.field}`]:b},spec:h[S],size:44,label:x(d.field,b),pressed:i.draft[d.field]===b,onPick:()=>i.onPick(b)},b))})}function K(i){return e("button",{type:"button",className:"creator-swatch","aria-pressed":i.pressed,"aria-label":i.label,title:i.label,style:{background:i.background},onClick:i.onPick,...i.data})}function N(i){return n("div",{className:"creator-field","data-field":i.field,children:[i.title?e("h3",{children:i.title}):null,i.children,i.error?e("p",{className:"field-error",role:"alert",children:i.error}):null]})}function _e(i){B("creator",ae);let[d,h]=r(i.character),p=ao(d),[m,b]=r({}),[S,P]=r(!1),[I,se]=r("idle"),[W,T]=r(),[z,j]=r(),U=Re("(max-width: 719px)"),G=a(null),F=R(),le=et(d),ce=Rn(),L=re(d)!==re(i.character);o(()=>h(i.character),[i.character]),o(()=>{if(!L||i.onPick)return;let s=(v)=>v.preventDefault(),u=(v)=>{if(v.button!==0||v.metaKey||v.ctrlKey||v.shiftKey||v.altKey)return;let E=v.target instanceof Element?v.target.closest("a"):null;if(!E||E.target||E.hasAttribute("download"))return;if(G.current?.contains(E))return;v.preventDefault(),v.stopPropagation(),T({kind:"link",anchor:E})},H=Xi((v)=>T({kind:"navigate",proceed:v}));return window.addEventListener("beforeunload",s),document.addEventListener("click",u,!0),()=>{H(),window.removeEventListener("beforeunload",s),document.removeEventListener("click",u,!0)}},[L,i.onPick]);let w=(s)=>{b({}),h((u)=>Fi(s,u))},de=async()=>{if(i.onPick){i.onPick(_(d),d);return}P(!0),b({});try{let s=await y.setCharacter(i.name,_(d));i.onSaved?.(s),f(t("Saved."))}catch(s){let u=s instanceof fe&&s.field?s.field.split(".")[0]:void 0,H=u&&pe.has(u)?u:"*";b({[H]:l(s)})}finally{P(!1)}},me=async()=>{let s=W;if(h(i.character),b({}),s?.kind==="link")setTimeout(()=>s.anchor.click(),0);else if(s?.kind==="navigate")s.proceed()},J=e(N,{field:"class",title:t("Class"),error:m.class,children:e("div",{className:"creator-grid",children:Je.map((s)=>e(Ce,{id:s,base:p,pressed:d.class===s,onPick:()=>w({class:s,colors:d.colors})},s))})}),V=n(N,{field:"colors",title:t("Colors"),error:m.colors??m.palette,children:[n("fieldset",{className:"creator-swatches",children:[e("legend",{className:"visually-hidden",children:t("Palette")}),oe.map((s)=>{let u=Y.palettes[s];return e(K,{data:{"data-palette":s},label:x("palette",s),pressed:d.palette===s,background:`linear-gradient(135deg, ${u.primary} 52%, ${u.trim} 52%)`,onPick:()=>w({palette:s})},s)})]}),e("div",{className:"creator-custom",children:["primary","secondary","trim"].map((s)=>n("label",{children:[e("span",{children:s==="primary"?t("Primary (the accent)"):s==="secondary"?t("Secondary"):t("Trim")}),e("input",{type:"color",value:d.colors[s],onChange:(u)=>w({colors:{[s]:u.target.value}})})]},s))})]}),q=M.map((s)=>e(N,{field:s.field,title:t(s.title),error:m[s.field],children:e(ke,{part:s,draft:d,shown:p,onPick:(u)=>w({[s.field]:u})})},s.field)),Q=n(g,{children:[e(N,{field:"build",title:t("Build"),error:m.build,children:n("fieldset",{className:"segmented",children:[e("legend",{className:"visually-hidden",children:t("Build")}),["slim","regular","stout"].map((s)=>n("label",{"data-checked":d.build===s,children:[e("input",{type:"radio",name:`${F}-build`,checked:d.build===s,onChange:()=>w({build:s})}),ie(s)]},s))]})}),e(N,{field:"skin",title:t("Skin tone"),error:m.skin,children:n("fieldset",{className:"creator-swatches",children:[e("legend",{className:"visually-hidden",children:t("Skin tone")}),(ce??Y.skins).map((s,u)=>e(K,{data:{"data-skin":String(u)},label:t("Skin tone {n}",{n:u+1}),pressed:d.skin===u,background:s,onPick:()=>w({skin:u})},u))]})}),e(N,{field:"hairColor",title:t("Hair color"),error:m.hairColor,children:n("fieldset",{className:"creator-swatches",children:[e("legend",{className:"visually-hidden",children:t("Hair color")}),Y.hairColors.map((s,u)=>e(K,{data:{"data-hair-color":s},label:t("Hair color {n}",{n:u+1}),pressed:d.hairColor===s,background:s,onPick:()=>w({hairColor:s})},s)),e("input",{type:"color","aria-label":t("Hair color"),value:d.hairColor,onChange:(s)=>w({hairColor:s.target.value})})]})})]}),O=[{id:"class",title:t("Class"),summary:x("class",d.class),error:m.class,node:J},{id:"colors",title:t("Colors"),summary:d.palette?x("palette",d.palette):d.colors.primary,error:m.colors??m.palette,node:V},...M.map((s,u)=>({id:s.field,title:t(s.title),summary:x(s.field,d[s.field]),error:m[s.field],node:q[u]})),{id:"body",title:t("Body"),summary:ie(d.build),error:m.build??m.skin??m.hairColor,node:Q}];return n("form",{ref:G,className:"creator",style:le,"aria-labelledby":F,onSubmit:(s)=>{if(s.preventDefault(),(L||i.onPick)&&!S)de()},children:[e("h2",{id:F,className:"visually-hidden",children:t("Character of {name}",{name:i.displayName})}),n("div",{className:"creator-preview",children:[e(he,{spec:d,name:i.name,state:I,size:176,label:t("{name}, {state}",{name:i.displayName,state:t(te[I])})}),e("button",{type:"button",className:"secondary","data-action":"cycle",onClick:()=>se((s)=>sn[(sn.indexOf(s)+1)%sn.length]??"idle"),children:t("Preview states")}),e("span",{className:"meta","aria-live":"polite",children:t(te[I])})]}),n("div",{className:"creator-body",children:[m["*"]?e("p",{className:"field-error",role:"alert","data-field":"*",children:m["*"]}):null,U?e("ul",{className:"creator-sections",children:O.map((s)=>e("li",{children:n("button",{type:"button",className:"creator-section secondary",onClick:()=>j(s.id),children:[e("strong",{children:s.title}),e("span",{className:"meta",children:s.summary}),s.error?e("span",{className:"field-error",role:"alert",children:s.error}):null]})},s.id))}):n(g,{children:[J,V,q,Q]}),n("div",{className:"actions creator-actions",children:[e("button",{type:"button",className:"secondary","data-action":"suggest",onClick:()=>{b({}),h(Nn({name:i.name,displayName:i.displayName,prompt:i.prompt}))},children:t("Suggest from role")}),e("button",{type:"button",className:"secondary","data-action":"randomize",onClick:()=>w(be()),children:t("Randomize")}),e("button",{type:"button",className:"secondary","data-action":"cancel",onClick:()=>{if(i.onCancel)i.onCancel();else if(L)T({kind:"cancel"})},children:t("Cancel")}),e("button",{type:"submit","data-action":"save",disabled:!L&&!i.onPick||S,children:S?t("Saving…"):i.onPick?t("Use this look"):t("Save")})]})]}),e(A,{open:U&&z!==void 0,title:O.find((s)=>s.id===z)?.title??"",onClose:()=>j(void 0),children:e("div",{className:"stack",children:O.find((s)=>s.id===z)?.node})}),e(D,{open:W!==void 0,title:t("Discard your changes?"),confirmLabel:t("Discard"),cancelLabel:t("Keep editing"),tone:"danger",onClose:()=>T(void 0),onConfirm:me,children:e("p",{children:t("The new look for {name} has not been saved.",{name:i.displayName})})})]})}var ie=(i)=>t(ge[i]);function Ce(i){let d=i.base.colors,h=C(()=>Fi({class:i.id,colors:d}),[i.id,d]);return e(ne,{data:{"data-class":i.id},spec:h,size:56,label:x("class",i.id),hint:Z(i.id),pressed:i.pressed,onPick:i.onPick})}export{_e as CharacterCreator};
225
+ `;var M=[{field:"hat",title:u("Hat"),ids:Y.hats},{field:"outfit",title:u("Outfit"),ids:Y.outfits},{field:"prop",title:u("Prop"),ids:Y.props},{field:"hair",title:u("Hair"),ids:Y.hair},{field:"beard",title:u("Beard"),ids:["none",...Y.beards]},{field:"accessory",title:u("Accessory"),ids:["none",...Y.accessories]}],pe=new Set(["class","colors","palette","build","skin","hairColor",...M.map((i)=>i.field)]),oe=Object.keys(Y.palettes),te={idle:u("Idle"),thinking:u("Thinking"),working:u("Working"),waiting:u("Waiting for you"),done:u("Done"),error:u("Error"),sleepy:u("Sleepy")},ge={slim:u("Slim"),regular:u("Regular"),stout:u("Stout")};function _(i){return{class:i.class,outfit:i.outfit,hat:i.hat,prop:i.prop,hair:i.hair,beard:i.beard,accessory:i.accessory,build:i.build,skin:i.skin,hairColor:i.hairColor,colors:{...i.colors}}}var re=(i)=>JSON.stringify(_(i)),k=(i)=>i[Math.floor(Math.random()*i.length)];function be(){return{class:k(Je),outfit:k(Y.outfits),hat:k(Y.hats),prop:k(Y.props),hair:k(Y.hair),beard:k(["none",...Y.beards]),accessory:k(["none",...Y.accessories]),build:k(["slim","regular","stout"]),skin:k([0,1,2,3,4,5]),hairColor:k(Y.hairColors),palette:k(oe)}}var ne=ee(function(l){return n("button",{type:"button",className:"creator-tile","aria-pressed":l.pressed,title:l.hint?`${l.label} — ${l.hint}`:l.label,onClick:l.onPick,...l.data,children:[e(he,{spec:l.spec,size:l.size,live:!1}),e("span",{children:l.label})]})});function ve(i,l,h){let p=JSON.stringify({...i,[l]:0});return C(()=>h.map((d)=>({...i,[l]:d})),[p,l,h])}function ye(){let i=a(null),[l,h]=r();return o(()=>{let p=i.current;if(!p)return;let d=()=>{let S=p.scrollLeft>1,P=p.scrollLeft+p.clientWidth<p.scrollWidth-1;h(S&&P?"both":P?"end":S?"start":void 0)};d(),p.addEventListener("scroll",d,{passive:!0});let b=typeof ResizeObserver>"u"?void 0:new ResizeObserver(d);return b?.observe(p),()=>{p.removeEventListener("scroll",d),b?.disconnect()}},[]),[i,l]}function ke(i){let{part:l}=i,h=ve(i.shown,l.field,l.ids),[p,d]=ye();return e("div",{className:"creator-strip",ref:p,"data-more":d,children:l.ids.map((b,S)=>e(ne,{data:{[`data-${l.field}`]:b},spec:h[S],size:44,label:x(l.field,b),pressed:i.draft[l.field]===b,onPick:()=>i.onPick(b)},b))})}function K(i){return e("button",{type:"button",className:"creator-swatch","aria-pressed":i.pressed,"aria-label":i.label,title:i.label,style:{background:i.background},onClick:i.onPick,...i.data})}function N(i){return n("div",{className:"creator-field","data-field":i.field,children:[i.title?e("h3",{children:i.title}):null,i.children,i.error?e("p",{className:"field-error",role:"alert",children:i.error}):null]})}function _e(i){B("creator",ae);let[l,h]=r(i.character),p=lo(l),[d,b]=r({}),[S,P]=r(!1),[I,se]=r("idle"),[W,T]=r(),[z,j]=r(),U=Re("(max-width: 719px)"),G=a(null),F=R(),le=et(l),ce=Rn(),L=re(l)!==re(i.character);o(()=>h(i.character),[i.character]),o(()=>{if(!L||i.onPick)return;let s=(v)=>v.preventDefault(),m=(v)=>{if(v.button!==0||v.metaKey||v.ctrlKey||v.shiftKey||v.altKey)return;let E=v.target instanceof Element?v.target.closest("a"):null;if(!E||E.target||E.hasAttribute("download"))return;if(G.current?.contains(E))return;v.preventDefault(),v.stopPropagation(),T({kind:"link",anchor:E})},H=zi((v)=>T({kind:"navigate",proceed:v}));return window.addEventListener("beforeunload",s),document.addEventListener("click",m,!0),()=>{H(),window.removeEventListener("beforeunload",s),document.removeEventListener("click",m,!0)}},[L,i.onPick]);let w=(s)=>{b({}),h((m)=>Gi(s,m))},de=async()=>{if(i.onPick){i.onPick(_(l),l);return}P(!0),b({});try{let s=await y.setCharacter(i.name,_(l));i.onSaved?.(s),f(t("Saved."))}catch(s){let m=s instanceof fe&&s.field?s.field.split(".")[0]:void 0,H=m&&pe.has(m)?m:"*";b({[H]:c(s)})}finally{P(!1)}},me=async()=>{let s=W;if(h(i.character),b({}),s?.kind==="link")setTimeout(()=>s.anchor.click(),0);else if(s?.kind==="navigate")s.proceed()},J=e(N,{field:"class",title:t("Class"),error:d.class,children:e("div",{className:"creator-grid",children:Je.map((s)=>e(Ce,{id:s,base:p,pressed:l.class===s,onPick:()=>w({class:s,colors:l.colors})},s))})}),V=n(N,{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")}),oe.map((s)=>{let m=Y.palettes[s];return e(K,{data:{"data-palette":s},label:x("palette",s),pressed:l.palette===s,background:`linear-gradient(135deg, ${m.primary} 52%, ${m.trim} 52%)`,onPick:()=>w({palette:s})},s)})]}),e("div",{className:"creator-custom",children:["primary","secondary","trim"].map((s)=>n("label",{children:[e("span",{children:s==="primary"?t("Primary (the accent)"):s==="secondary"?t("Secondary"):t("Trim")}),e("input",{type:"color",value:l.colors[s],onChange:(m)=>w({colors:{[s]:m.target.value}})})]},s))})]}),q=M.map((s)=>e(N,{field:s.field,title:t(s.title),error:d[s.field],children:e(ke,{part:s,draft:l,shown:p,onPick:(m)=>w({[s.field]:m})})},s.field)),Q=n(g,{children:[e(N,{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":l.build===s,children:[e("input",{type:"radio",name:`${F}-build`,checked:l.build===s,onChange:()=>w({build:s})}),ie(s)]},s))]})}),e(N,{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")}),(ce??Y.skins).map((s,m)=>e(K,{data:{"data-skin":String(m)},label:t("Skin tone {n}",{n:m+1}),pressed:l.skin===m,background:s,onPick:()=>w({skin:m})},m))]})}),e(N,{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")}),Y.hairColors.map((s,m)=>e(K,{data:{"data-hair-color":s},label:t("Hair color {n}",{n:m+1}),pressed:l.hairColor===s,background:s,onPick:()=>w({hairColor:s})},s)),e("input",{type:"color","aria-label":t("Hair color"),value:l.hairColor,onChange:(s)=>w({hairColor:s.target.value})})]})})]}),O=[{id:"class",title:t("Class"),summary:x("class",l.class),error:d.class,node:J},{id:"colors",title:t("Colors"),summary:l.palette?x("palette",l.palette):l.colors.primary,error:d.colors??d.palette,node:V},...M.map((s,m)=>({id:s.field,title:t(s.title),summary:x(s.field,l[s.field]),error:d[s.field],node:q[m]})),{id:"body",title:t("Body"),summary:ie(l.build),error:d.build??d.skin??d.hairColor,node:Q}];return n("form",{ref:G,className:"creator",style:le,"aria-labelledby":F,onSubmit:(s)=>{if(s.preventDefault(),(L||i.onPick)&&!S)de()},children:[e("h2",{id:F,className:"visually-hidden",children:t("Character of {name}",{name:i.displayName})}),n("div",{className:"creator-preview",children:[e(he,{spec:l,name:i.name,state:I,size:176,label:t("{name}, {state}",{name:i.displayName,state:t(te[I])})}),e("button",{type:"button",className:"secondary","data-action":"cycle",onClick:()=>se((s)=>sn[(sn.indexOf(s)+1)%sn.length]??"idle"),children:t("Preview states")}),e("span",{className:"meta","aria-live":"polite",children:t(te[I])})]}),n("div",{className:"creator-body",children:[d["*"]?e("p",{className:"field-error",role:"alert","data-field":"*",children:d["*"]}):null,U?e("ul",{className:"creator-sections",children:O.map((s)=>e("li",{children:n("button",{type:"button",className:"creator-section secondary",onClick:()=>j(s.id),children:[e("strong",{children:s.title}),e("span",{className:"meta",children:s.summary}),s.error?e("span",{className:"field-error",role:"alert",children:s.error}):null]})},s.id))}):n(g,{children:[J,V,q,Q]}),n("div",{className:"actions creator-actions",children:[e("button",{type:"button",className:"secondary","data-action":"suggest",onClick:()=>{b({}),h(Nn({name:i.name,displayName:i.displayName,prompt:i.prompt}))},children:t("Suggest from role")}),e("button",{type:"button",className:"secondary","data-action":"randomize",onClick:()=>w(be()),children:t("Randomize")}),e("button",{type:"button",className:"secondary","data-action":"cancel",onClick:()=>{if(i.onCancel)i.onCancel();else if(L)T({kind:"cancel"})},children:t("Cancel")}),e("button",{type:"submit","data-action":"save",disabled:!L&&!i.onPick||S,children:S?t("Saving…"):i.onPick?t("Use this look"):t("Save")})]})]}),e(A,{open:U&&z!==void 0,title:O.find((s)=>s.id===z)?.title??"",onClose:()=>j(void 0),children:e("div",{className:"stack",children:O.find((s)=>s.id===z)?.node})}),e(D,{open:W!==void 0,title:t("Discard your changes?"),confirmLabel:t("Discard"),cancelLabel:t("Keep editing"),tone:"danger",onClose:()=>T(void 0),onConfirm:me,children:e("p",{children:t("The new look for {name} has not been saved.",{name:i.displayName})})})]})}var ie=(i)=>t(ge[i]);function Ce(i){let l=i.base.colors,h=C(()=>Gi({class:i.id,colors:l}),[i.id,l]);return e(ne,{data:{"data-class":i.id},spec:h,size:56,label:x("class",i.id),hint:Z(i.id),pressed:i.pressed,onPick:i.onPick})}export{_e as CharacterCreator};
@@ -1,2 +1,2 @@
1
- import{G,be,Yi,Bo,Hi,mt,ve,d,w,Le,Fe,qt,Ge,W,le,ce,q,xt,St,Ze,xe,z,se,De,v,Tt,Fo,Go,Zo,ji,hi,Wo,Yo,Ho,jo,M,i,I,rt,Gt,gi,Ir,zn,In,es,ts,Ot}from"./chunk-index-ne8v2rxx.js";import{p}from"./chunk-index-rvatmx8s.js";var nn=(e)=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=Ce(e.state,n.from);return r.line?rn(e):r.block?ln(e):!1};function ke(e,t){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let o=e(t,n);if(!o)return!1;return r(n.update(o)),!0}}var rn=ke(an,0);var on=ke(je,0);var ln=ke((e,t)=>je(e,t,cn(t)),0);function Ce(e,t){let n=e.languageDataAt("commentTokens",t,1);return n.length?n[0]:{}}var V=50;function sn(e,{open:t,close:n},r,o){let l=e.sliceDoc(r-V,r),s=e.sliceDoc(o,o+V),c=/\s*$/.exec(l)[0].length,a=/^\s*/.exec(s)[0].length,h=l.length-c;if(l.slice(h-t.length,h)==t&&s.slice(a,a+n.length)==n)return{open:{pos:r-c,margin:c&&1},close:{pos:o+a,margin:a&&1}};let u,f;if(o-r<=2*V)u=f=e.sliceDoc(r,o);else u=e.sliceDoc(r,r+V),f=e.sliceDoc(o-V,o);let m=/^\s*/.exec(u)[0].length,B=/\s*$/.exec(f)[0].length,b=f.length-B-n.length;if(u.slice(m,m+t.length)==t&&f.slice(b,b+n.length)==n)return{open:{pos:r+m+t.length,margin:/\s/.test(u.charAt(m+t.length))?1:0},close:{pos:o-B-n.length,margin:/\s/.test(f.charAt(b-1))?1:0}};return null}function cn(e){let t=[];for(let n of e.selection.ranges){let r=e.doc.lineAt(n.from),o=n.to<=r.to?r:e.doc.lineAt(n.to);if(o.from>r.from&&o.from==n.to)o=n.to==r.to+1?r:e.doc.lineAt(n.to-1);let l=t.length-1;if(l>=0&&t[l].to>r.from)t[l].to=o.to;else t.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:o.to})}return t}function je(e,t,n=t.selection.ranges){let r=n.map((l)=>Ce(t,l.from).block);if(!r.every((l)=>l))return null;let o=n.map((l,s)=>sn(t,r[s],l.from,l.to));if(e!=2&&!o.every((l)=>l))return{changes:t.changes(n.map((l,s)=>{if(o[s])return[];return[{from:l.from,insert:r[s].open+" "},{from:l.to,insert:" "+r[s].close}]}))};else if(e!=1&&o.some((l)=>l)){let l=[];for(let s=0,c;s<o.length;s++)if(c=o[s]){let a=r[s],{open:h,close:u}=c;l.push({from:h.pos-a.open.length,to:h.pos+h.margin},{from:u.pos-u.margin,to:u.pos+a.close.length})}return{changes:l}}return null}function an(e,t,n=t.selection.ranges){let r=[],o=-1;e:for(let{from:l,to:s}of n){let c=r.length,a=1e9,h;for(let u=l;u<=s;){let f=t.doc.lineAt(u);if(h==null){if(h=Ce(t,f.from).line,!h)continue e}if(f.from>o&&(l==s||s>f.from)){o=f.from;let m=/^\s*/.exec(f.text)[0].length,B=m==f.length,b=f.text.slice(m,m+h.length)==h?m:-1;if(m<f.text.length&&m<a)a=m;r.push({line:f,comment:b,token:h,indent:m,empty:B,single:!1})}u=f.to+1}if(a<1e9){for(let u=c;u<r.length;u++)if(r[u].indent<r[u].line.text.length)r[u].indent=a}if(r.length==c+1)r[c].single=!0}if(e!=2&&r.some((l)=>l.comment<0&&(!l.empty||l.single))){let l=[];for(let{line:c,token:a,indent:h,empty:u,single:f}of r)if(f||!u)l.push({from:c.from+h,insert:a+" "});let s=t.changes(l);return{changes:s,selection:t.selection.map(s,1)}}else if(e!=1&&r.some((l)=>l.comment>=0)){let l=[];for(let{line:s,comment:c,token:a}of r)if(c>=0){let h=s.from+c,u=h+a.length;if(s.text[u-s.from]==" ")u++;l.push({from:h,to:u})}return{changes:l}}return null}var ge=Ge.define(),un=Ge.define(),hn=w.define(),Xe=w.define({combine(e){return xt(e,{minDepth:100,newGroupDelay:500,joinToEvent:(t,n)=>n},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(t,n)=>(r,o)=>t(r,o)||n(r,o)})}}),Ye=Le.define({create(){return L.empty},update(e,t){let n=t.state.facet(Xe),r=t.annotation(ge);if(r){let a=y.fromTransaction(t,r.selection),h=r.side,u=h==0?e.undone:e.done;if(a)u=Q(u,u.length,n.minDepth,a);else u=nt(u,t.startState.selection);return new L(h==0?r.rest:u,h==0?u:r.rest)}let o=t.annotation(un);if(o=="full"||o=="before")e=e.isolate();if(t.annotation(le.addToHistory)===!1)return!t.changes.empty?e.addMapping(t.changes.desc):e;let l=y.fromTransaction(t),s=t.annotation(le.time),c=t.annotation(le.userEvent);if(l)e=e.addChanges(l,s,c,n,t);else if(t.selection)e=e.addSelection(t.startState.selection,s,c,n.newGroupDelay);if(o=="full"||o=="after")e=e.isolate();return e},toJSON(e){return{done:e.done.map((t)=>t.toJSON()),undone:e.undone.map((t)=>t.toJSON())}},fromJSON(e){return new L(e.done.map(y.fromJSON),e.undone.map(y.fromJSON))}});function et(e={}){return[Ye,Xe.of(e),v.domEventHandlers({beforeinput(t,n){let r=t.inputType=="historyUndo"?X:t.inputType=="historyRedo"?U:null;if(!r)return!1;return t.preventDefault(),r(n)}})]}function j(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let o=n.field(Ye,!1);if(!o)return!1;let l=o.pop(e,n,t);if(!l)return!1;return r(l),!0}}var X=j(0,!1),U=j(1,!1),fn=j(0,!0),dn=j(1,!0);class y{constructor(e,t,n,r,o){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=r,this.selectionsAfter=o}setSelAfter(e){return new y(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,n;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(t=this.mapped)===null||t===void 0?void 0:t.toJSON(),startSelection:(n=this.startSelection)===null||n===void 0?void 0:n.toJSON(),selectionsAfter:this.selectionsAfter.map((r)=>r.toJSON())}}static fromJSON(e){return new y(e.changes&&ve.fromJSON(e.changes),[],e.mapped&&mt.fromJSON(e.mapped),e.startSelection&&d.fromJSON(e.startSelection),e.selectionsAfter.map(d.fromJSON))}static fromTransaction(e,t){let n=S;for(let r of e.startState.facet(hn)){let o=r(e);if(o.length)n=n.concat(o)}if(!n.length&&e.changes.empty)return null;return new y(e.changes.invert(e.startState.doc),n,void 0,t||e.startState.selection,S)}static selection(e){return new y(void 0,S,void 0,void 0,e)}}function Q(e,t,n,r){let o=t+1>n+20?t-n-1:0,l=e.slice(o,t);return l.push(r),l}function mn(e,t){let n=[],r=!1;return e.iterChangedRanges((o,l)=>n.push(o,l)),t.iterChangedRanges((o,l,s,c)=>{for(let a=0;a<n.length;){let h=n[a++],u=n[a++];if(c>=h&&s<=u)r=!0}}),r}function pn(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((n,r)=>n.empty!=t.ranges[r].empty).length===0}function tt(e,t){return!e.length?t:!t.length?e:e.concat(t)}var S=[],gn=200;function nt(e,t){if(!e.length)return[y.selection([t])];else{let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-gn));if(r.length&&r[r.length-1].eq(t))return e;return r.push(t),Q(e,e.length-1,1e9,n.setSelAfter(r))}}function yn(e){let t=e[e.length-1],n=e.slice();return n[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),n}function pe(e,t){if(!e.length)return e;let n=e.length,r=S;while(n){let o=xn(e[n-1],t,r);if(o.changes&&!o.changes.empty||o.effects.length){let l=e.slice(0,n);return l[n-1]=o,l}else t=o.mapped,n--,r=o.selectionsAfter}return r.length?[y.selection(r)]:S}function xn(e,t,n){let r=tt(e.selectionsAfter.length?e.selectionsAfter.map((c)=>c.map(t)):S,n);if(!e.changes)return y.selection(r);let o=e.changes.map(t),l=t.mapDesc(e.changes,!0),s=e.mapped?e.mapped.composeDesc(l):l;return new y(o,W.mapEffects(e.effects,t),s,e.startSelection.map(l),r)}var Sn=/^(input\.type|delete)($|\.)/;class L{constructor(e,t,n=0,r=void 0){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=r}isolate(){return this.prevTime?new L(this.done,this.undone):this}addChanges(e,t,n,r,o){let l=this.done,s=l[l.length-1];if(s&&s.changes&&!s.changes.empty&&e.changes&&(!n||Sn.test(n))&&(!s.selectionsAfter.length&&t-this.prevTime<r.newGroupDelay&&r.joinToEvent(o,mn(s.changes,e.changes))||n=="input.type.compose"))l=Q(l,l.length-1,r.minDepth,new y(e.changes.compose(s.changes),tt(W.mapEffects(e.effects,s.changes),s.effects),s.mapped,s.startSelection,S));else l=Q(l,l.length,r.minDepth,e);return new L(l,S,t,n)}addSelection(e,t,n,r){let o=this.done.length?this.done[this.done.length-1].selectionsAfter:S;if(o.length>0&&t-this.prevTime<r&&n==this.prevUserEvent&&n&&/^select($|\.)/.test(n)&&pn(o[o.length-1],e))return this;return new L(nt(this.done,e),this.undone,t,n)}addMapping(e){return new L(pe(this.done,e),pe(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,t,n){let r=e==0?this.done:this.undone;if(r.length==0)return null;let o=r[r.length-1],l=o.selectionsAfter[0]||(o.startSelection?o.startSelection.map(o.changes.invertedDesc,1):t.selection);if(n&&o.selectionsAfter.length)return t.update({selection:o.selectionsAfter[o.selectionsAfter.length-1],annotations:ge.of({side:e,rest:yn(r),selection:l}),userEvent:e==0?"select.undo":"select.redo",scrollIntoView:!0});else if(!o.changes)return null;else{let s=r.length==1?S:r.slice(0,r.length-1);if(o.mapped)s=pe(s,o.mapped);return t.update({changes:o.changes,selection:o.startSelection,effects:o.effects,annotations:ge.of({side:e,rest:s,selection:l}),filter:!1,userEvent:e==0?"undo":"redo",scrollIntoView:!0})}}}L.empty=new L(S,S);var ot=[{key:"Mod-z",run:X,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:U,preventDefault:!0},{linux:"Ctrl-Shift-z",run:U,preventDefault:!0},{key:"Mod-u",run:fn,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:dn,preventDefault:!0}];function O(e,t){return d.create(e.ranges.map(t),e.mainIndex)}function C(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:"select"})}function A({state:e,dispatch:t},n){let r=O(e.selection,n);if(r.eq(e.selection,!0))return!1;return t(C(e,r)),!0}function Y(e,t){return d.cursor(t?e.to:e.from)}function lt(e,t){return A(e,(n)=>n.empty?e.moveByChar(n,t):Y(n,t))}function g(e){return e.textDirectionAt(e.state.selection.main.head)==se.LTR}var it=(e)=>lt(e,!g(e)),st=(e)=>lt(e,g(e));function ct(e,t){return A(e,(n)=>n.empty?e.moveByGroup(n,t):Y(n,t))}var kn=(e)=>ct(e,!g(e)),vn=(e)=>ct(e,g(e));var Jr=typeof Intl<"u"&&Intl.Segmenter?new Intl.Segmenter(void 0,{granularity:"word"}):null;function bn(e,t,n){if(t.type.prop(n))return!0;let r=t.to-t.from;return r&&(r>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function Z(e,t,n){let r=I(e).resolveInner(t.head),o=n?M.closedBy:M.openedBy;for(let a=t.head;;){let h=n?r.childAfter(a):r.childBefore(a);if(!h)break;if(bn(e,h,o))r=h;else a=n?h.to:h.from}let l=r.type.prop(o),s,c;if(l&&(s=n?Ot(e,r.from,1):Ot(e,r.to,-1))&&s.matched)c=n?s.end.to:s.end.from;else c=n?r.to:r.from;return d.cursor(c,n?-1:1)}var Cn=(e)=>A(e,(t)=>Z(e.state,t,!g(e))),Mn=(e)=>A(e,(t)=>Z(e.state,t,g(e)));function at(e,t){return A(e,(n)=>{if(!n.empty)return Y(n,t);let r=e.moveVertically(n,t);return r.head!=n.head?r:e.moveToLineBoundary(n,t)})}var ut=(e)=>at(e,!1),ht=(e)=>at(e,!0);function ft(e){let t=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,n=0,r=0,o;if(t){for(let l of e.state.facet(v.scrollMargins)){let s=l(e);if(s===null||s===void 0?void 0:s.top)n=Math.max(s===null||s===void 0?void 0:s.top,n);if(s===null||s===void 0?void 0:s.bottom)r=Math.max(s===null||s===void 0?void 0:s.bottom,r)}o=e.scrollDOM.clientHeight-n-r}else o=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:r,selfScroll:t,height:Math.max(e.defaultLineHeight,o-5)}}function dt(e,t){let n=ft(e),{state:r}=e,o=O(r.selection,(s)=>s.empty?e.moveVertically(s,t,n.height):Y(s,t));if(o.eq(r.selection))return!1;let l;if(n.selfScroll){let s=e.coordsAtPos(r.selection.main.head),c=e.scrollDOM.getBoundingClientRect(),a=c.top+n.marginTop,h=c.bottom-n.marginBottom;if(s&&s.top>a&&s.bottom<h)l=v.scrollIntoView(o.main.head,{y:"start",yMargin:s.top-a})}return e.dispatch(C(r,o),{effects:l}),!0}var Ue=(e)=>dt(e,!1),ye=(e)=>dt(e,!0);function D(e,t,n){let r=e.lineBlockAt(t.head),o=e.moveToLineBoundary(t,n);if(o.head==t.head&&o.head!=(n?r.to:r.from))o=e.moveToLineBoundary(t,n,!1);if(!n&&o.head==r.from&&r.length){let l=/^\s*/.exec(e.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;if(l&&t.head!=r.from+l)o=d.cursor(r.from+l)}return o}var An=(e)=>A(e,(t)=>D(e,t,!0)),Ln=(e)=>A(e,(t)=>D(e,t,!1)),Bn=(e)=>A(e,(t)=>D(e,t,!g(e))),Dn=(e)=>A(e,(t)=>D(e,t,g(e))),En=(e)=>A(e,(t)=>e.moveToLineBoundary(t,!1,!1)),Tn=(e)=>A(e,(t)=>e.moveToLineBoundary(t,!0,!1));function wn(e,t,n){let r=!1,o=O(e.selection,(l)=>{let s=Ot(e,l.head,-1)||Ot(e,l.head,1)||l.head>0&&Ot(e,l.head-1,1)||l.head<e.doc.length&&Ot(e,l.head+1,-1);if(!s||!s.end)return l;r=!0;let c=s.start.from==l.head?s.end.to:s.end.from;return n?d.range(l.anchor,c):d.cursor(c)});if(!r)return!1;return t(C(e,o)),!0}var Wn=({state:e,dispatch:t})=>wn(e,t,!1);function k(e,t,n){let r=O(e.state.selection,(o)=>{if(o.undirectional&&o.head>=o.anchor!=t)o=d.range(o.head,o.anchor);let l=n(o);return d.range(o.anchor,l.head,l.goalColumn,l.bidiLevel||void 0,l.assoc)});if(r.eq(e.state.selection))return!1;return e.dispatch(C(e.state,r)),!0}function pt(e,t){return k(e,t,(n)=>e.moveByChar(n,t))}var gt=(e)=>pt(e,!g(e)),yt=(e)=>pt(e,g(e));function kt(e,t){return k(e,t,(n)=>e.moveByGroup(n,t))}var Rn=(e)=>kt(e,!g(e)),On=(e)=>kt(e,g(e));var Fn=(e)=>{let t=!g(e);return k(e,t,(n)=>Z(e.state,n,t))},Pn=(e)=>{let t=g(e);return k(e,t,(n)=>Z(e.state,n,t))};function vt(e,t){return k(e,t,(n)=>e.moveVertically(n,t))}var bt=(e)=>vt(e,!1),Ct=(e)=>vt(e,!0);function Mt(e,t){return k(e,t,(n)=>e.moveVertically(n,t,ft(e).height))}var ze=(e)=>Mt(e,!1),_e=(e)=>Mt(e,!0),Nn=(e)=>k(e,!0,(t)=>D(e,t,!0)),qn=(e)=>k(e,!1,(t)=>D(e,t,!1)),Vn=(e)=>{let t=!g(e);return k(e,t,(n)=>D(e,n,t))},Gn=(e)=>{let t=g(e);return k(e,t,(n)=>D(e,n,t))},Un=(e)=>k(e,!1,(t)=>d.cursor(e.lineBlockAt(t.head).from)),_n=(e)=>k(e,!0,(t)=>d.cursor(e.lineBlockAt(t.head).to)),Je=({state:e,dispatch:t})=>(t(C(e,{anchor:0})),!0),$e=({state:e,dispatch:t})=>(t(C(e,{anchor:e.doc.length})),!0),Ke=({state:e,dispatch:t})=>(t(C(e,{anchor:e.selection.main.anchor,head:0})),!0),He=({state:e,dispatch:t})=>(t(C(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),Jn=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:"select"})),!0),$n=({state:e,dispatch:t})=>{let n=ee(e).map(({from:r,to:o})=>d.undirectionalRange(r,Math.min(o+1,e.doc.length)));return t(e.update({selection:d.create(n),userEvent:"select"})),!0},Kn=({state:e,dispatch:t})=>{let n=O(e.selection,(r)=>{let o=I(e),l=o.resolveStack(r.from,1);if(r.empty){let s=o.resolveStack(r.from,-1);if(s.node.from>=l.node.from&&s.node.to<=l.node.to)l=s}for(let s=l;s;s=s.next){let{node:c}=s;if((c.from<r.from&&c.to>=r.to||c.to>r.to&&c.from<=r.from)&&s.next)return d.undirectionalRange(c.from,c.to)}return r});if(n.eq(e.selection))return!1;return t(C(e,n)),!0};function At(e,t){let{state:n}=e,r=n.selection,o=n.selection.ranges.slice();for(let l of n.selection.ranges){let s=n.doc.lineAt(l.head);if(t?s.to<e.state.doc.length:s.from>0)for(let c=l;;){let a=e.moveVertically(c,t);if(a.head<s.from||a.head>s.to){if(!o.some((h)=>h.head==a.head))o.push(a);break}else if(a.head==c.head)break;else c=a}}if(o.length==r.ranges.length)return!1;return e.dispatch(C(n,d.create(o,o.length-1))),!0}var Hn=(e)=>At(e,!1),Qn=(e)=>At(e,!0),jn=({state:e,dispatch:t})=>{let n=e.selection,r=null;if(n.ranges.length>1)r=d.create([n.main]);else if(!n.main.empty)r=d.create([d.cursor(n.main.head)]);if(!r)return!1;return t(C(e,r)),!0};function _(e,t){if(e.state.readOnly)return!1;let n="delete.selection",{state:r}=e,o=r.changeByRange((l)=>{let{from:s,to:c}=l;if(s==c){let a=t(l);if(a<s)n="delete.backward",a=H(e,a,!1);else if(a>s)n="delete.forward",a=H(e,a,!0);s=Math.min(s,a),c=Math.max(c,a)}else s=H(e,s,!1),c=H(e,c,!0);return s==c?{range:l}:{changes:{from:s,to:c},range:d.cursor(s,s<l.head?-1:1)}});if(o.changes.empty)return!1;return e.dispatch(r.update(o,{scrollIntoView:!0,userEvent:n,effects:n=="delete.selection"?v.announce.of(r.phrase("Selection deleted")):void 0})),!0}function H(e,t,n){if(e instanceof v)for(let r of e.state.facet(v.atomicRanges).map((o)=>o(e)))r.between(t,t,(o,l)=>{if(o<t&&l>t)t=n?l:o});return t}var Lt=(e,t,n)=>_(e,(r)=>{let o=r.from,{state:l}=e,s=l.doc.lineAt(o),c,a;if(n&&!t&&o>s.from&&o<s.from+200&&!/[^ \t]/.test(c=s.text.slice(0,o-s.from))){if(c[c.length-1]=="\t")return o-1;let h=Ze(c,l.tabSize),u=h%Gt(l)||Gt(l);for(let f=0;f<u&&c[c.length-1-f]==" ";f++)o--;a=o}else if(a=be(s.text,o-s.from,t,t)+s.from,a==o&&s.number!=(t?l.doc.lines:1))a+=t?1:-1;else if(!t&&/[\ufe00-\ufe0f]/.test(s.text.slice(a-s.from,o-s.from)))a=be(s.text,a-s.from,!1,!1)+s.from;return a}),Se=(e)=>Lt(e,!1,!0);var Bt=(e)=>Lt(e,!0,!1),Dt=(e,t)=>_(e,(n)=>{let r=n.head,{state:o}=e,l=o.doc.lineAt(r),s=o.charCategorizer(r);for(let c=null;;){if(r==(t?l.to:l.from)){if(r==n.head&&l.number!=(t?o.doc.lines:1))r+=t?1:-1;break}let a=be(l.text,r-l.from,t)+l.from,h=l.text.slice(Math.min(r,a)-l.from,Math.max(r,a)-l.from),u=s(h);if(c!=null&&u!=c)break;if(h!=" "||r!=n.head)c=u;r=a}return r}),Et=(e)=>Dt(e,!1),Xn=(e)=>Dt(e,!0);var Yn=(e)=>_(e,(t)=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)});var Zn=(e)=>_(e,(t)=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),er=(e)=>_(e,(t)=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)});var tr=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange((r)=>({changes:{from:r.from,to:r.to,insert:G.of(["",""])},range:d.cursor(r.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:"input"})),!0},nr=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange((r)=>{if(!r.empty||r.from==0||r.from==e.doc.length)return{range:r};let o=r.from,l=e.doc.lineAt(o),s=o==l.from?o-1:be(l.text,o-l.from,!1)+l.from,c=o==l.to?o+1:be(l.text,o-l.from,!0)+l.from;return{changes:{from:s,to:c,insert:e.doc.slice(o,c).append(e.doc.slice(s,o))},range:d.cursor(c)}});if(n.changes.empty)return!1;return t(e.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0};function ee(e){let t=[],n=-1;for(let r of e.selection.ranges){let o=e.doc.lineAt(r.from),l=e.doc.lineAt(r.to);if(!r.empty&&r.to==l.from)l=e.doc.lineAt(r.to-1);if(n>=o.number){let s=t[t.length-1];s.to=l.to,s.ranges.push(r)}else t.push({from:o.from,to:l.to,ranges:[r]});n=l.number+1}return t}function wt(e,t,n){if(e.readOnly)return!1;let r=[],o=[];for(let l of ee(e)){if(n?l.to==e.doc.length:l.from==0)continue;let s=e.doc.lineAt(n?l.to+1:l.from-1),c=s.length+1;if(n){r.push({from:l.to,to:s.to},{from:l.from,insert:s.text+e.lineBreak});for(let a of l.ranges)o.push(d.range(Math.min(e.doc.length,a.anchor+c),Math.min(e.doc.length,a.head+c)))}else{r.push({from:s.from,to:l.from},{from:l.to,insert:e.lineBreak+s.text});for(let a of l.ranges)o.push(d.range(a.anchor-c,a.head-c))}}if(!r.length)return!1;return t(e.update({changes:r,scrollIntoView:!0,selection:d.create(o,e.selection.mainIndex),userEvent:"move.line"})),!0}var rr=({state:e,dispatch:t})=>wt(e,t,!1),or=({state:e,dispatch:t})=>wt(e,t,!0);function Wt(e,t,n){if(e.readOnly)return!1;let r=[];for(let l of ee(e))if(n)r.push({from:l.from,insert:e.doc.slice(l.from,l.to)+e.lineBreak});else r.push({from:l.to,insert:e.lineBreak+e.doc.slice(l.from,l.to)});let o=e.changes(r);return t(e.update({changes:o,selection:e.selection.map(o,n?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}var lr=({state:e,dispatch:t})=>Wt(e,t,!1),ir=({state:e,dispatch:t})=>Wt(e,t,!0),sr=(e)=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(ee(t).map(({from:o,to:l})=>{if(o>0)o--;else if(l<t.doc.length)l++;return{from:o,to:l}})),r=O(t.selection,(o)=>{let l=void 0;if(e.lineWrapping){let s=e.lineBlockAt(o.head),c=e.coordsAtPos(o.head,o.assoc||1);if(c)l=s.bottom+e.documentTop-c.bottom+e.defaultLineHeight/2}return e.moveVertically(o,!0,l)}).map(n);return e.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:"delete.line"}),!0};function cr(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=I(e).resolveInner(t),r=n.childBefore(t),o=n.childAfter(t),l;if(r&&o&&r.to<=t&&o.from>=t&&(l=r.type.prop(M.closedBy))&&l.indexOf(o.name)>-1&&e.doc.lineAt(r.to).from==e.doc.lineAt(o.from).from&&!/\S/.test(e.sliceDoc(r.to,o.from)))return{from:r.to,to:o.from};return null}var Qe=Rt(!1),ar=Rt(!0);function Rt(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=t.changeByRange((o)=>{let{from:l,to:s}=o,c=t.doc.lineAt(l),a=!e&&l==s&&cr(t,l);if(e)l=s=(s<=c.to?c:t.doc.lineAt(s)).to;let h=new zn(t,{simulateBreak:l,simulateDoubleBreak:!!a}),u=Ir(h,l);if(u==null)u=Ze(/^\s*/.exec(t.doc.lineAt(l).text)[0],t.tabSize);while(s<c.to&&/\s/.test(c.text[s-c.from]))s++;if(a)({from:l,to:s}=a);else if(l>c.from&&l<c.from+100&&!/\S/.test(c.text.slice(0,l)))l=c.from;let f=["",gi(t,u)];if(a)f.push(gi(t,h.lineIndent(c.from,-1)));return{changes:{from:l,to:s,insert:G.of(f)},range:d.cursor(l+1+f[1].length)}});return n(t.update(r,{scrollIntoView:!0,userEvent:"input"})),!0}}function Me(e,t){let n=-1;return e.changeByRange((r)=>{let o=[];for(let s=r.from;s<=r.to;){let c=e.doc.lineAt(s);if(c.number>n&&(r.empty||r.to>c.from))t(c,o,r),n=c.number;s=c.to+1}let l=e.changes(o);return{changes:o,range:d.range(l.mapPos(r.anchor,1),l.mapPos(r.head,1))}})}var ur=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new zn(e,{overrideIndentation:(l)=>{let s=n[l];return s==null?-1:s}}),o=Me(e,(l,s,c)=>{let a=Ir(r,l.from);if(a==null)return;if(!/\S/.test(l.text))a=0;let h=/^\s*/.exec(l.text)[0],u=gi(e,a);if(h!=u||c.from<l.from+h.length)n[l.from]=a,s.push({from:l.from,to:l.from+h.length,insert:u})});if(!o.changes.empty)t(e.update(o,{userEvent:"indent"}));return!0},te=({state:e,dispatch:t})=>{if(e.readOnly)return!1;return t(e.update(Me(e,(n,r)=>{r.push({from:n.from,insert:e.facet(rt)})}),{userEvent:"input.indent"})),!0},Ft=({state:e,dispatch:t})=>{if(e.readOnly)return!1;return t(e.update(Me(e,(n,r)=>{let o=/^\s*/.exec(n.text)[0];if(!o)return;let l=Ze(o,e.tabSize),s=0,c=gi(e,Math.max(0,l-Gt(e)));while(s<o.length&&s<c.length&&o.charCodeAt(s)==c.charCodeAt(s))s++;r.push({from:n.from+s,to:n.from+o.length,insert:c.slice(s)})}),{userEvent:"delete.dedent"})),!0},hr=(e)=>(e.setTabFocusMode(),!0);var fr=[{key:"Ctrl-b",run:it,shift:gt,preventDefault:!0},{key:"Ctrl-f",run:st,shift:yt},{key:"Ctrl-p",run:ut,shift:bt},{key:"Ctrl-n",run:ht,shift:Ct},{key:"Ctrl-a",run:En,shift:Un},{key:"Ctrl-e",run:Tn,shift:_n},{key:"Ctrl-d",run:Bt},{key:"Ctrl-h",run:Se},{key:"Ctrl-k",run:Yn},{key:"Ctrl-Alt-h",run:Et},{key:"Ctrl-o",run:tr},{key:"Ctrl-t",run:nr},{key:"Ctrl-v",run:ye}],dr=[{key:"ArrowLeft",run:it,shift:gt,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:kn,shift:Rn,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:Bn,shift:Vn,preventDefault:!0},{key:"ArrowRight",run:st,shift:yt,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:vn,shift:On,preventDefault:!0},{mac:"Cmd-ArrowRight",run:Dn,shift:Gn,preventDefault:!0},{key:"ArrowUp",run:ut,shift:bt,preventDefault:!0},{mac:"Cmd-ArrowUp",run:Je,shift:Ke},{mac:"Ctrl-ArrowUp",run:Ue,shift:ze},{key:"ArrowDown",run:ht,shift:Ct,preventDefault:!0},{mac:"Cmd-ArrowDown",run:$e,shift:He},{mac:"Ctrl-ArrowDown",run:ye,shift:_e},{key:"PageUp",run:Ue,shift:ze},{key:"PageDown",run:ye,shift:_e},{key:"Home",run:Ln,shift:qn,preventDefault:!0},{key:"Mod-Home",run:Je,shift:Ke},{key:"End",run:An,shift:Nn,preventDefault:!0},{key:"Mod-End",run:$e,shift:He},{key:"Enter",run:Qe,shift:Qe},{key:"Mod-a",run:Jn},{key:"Backspace",run:Se,shift:Se,preventDefault:!0},{key:"Delete",run:Bt,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Et,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:Xn,preventDefault:!0},{mac:"Mod-Backspace",run:Zn,preventDefault:!0},{mac:"Mod-Delete",run:er,preventDefault:!0}].concat(fr.map((e)=>({mac:e.key,run:e.run,shift:e.shift}))),It=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:Cn,shift:Fn},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:Mn,shift:Pn},{key:"Alt-ArrowUp",run:rr},{key:"Shift-Alt-ArrowUp",run:lr},{key:"Alt-ArrowDown",run:or},{key:"Shift-Alt-ArrowDown",run:ir},{key:"Mod-Alt-ArrowUp",run:Hn},{key:"Mod-Alt-ArrowDown",run:Qn},{key:"Escape",run:jn},{key:"Mod-Enter",run:ar},{key:"Alt-l",mac:"Ctrl-l",run:$n},{key:"Mod-i",run:Kn,preventDefault:!0},{key:"Mod-[",run:Ft},{key:"Mod-]",run:te},{key:"Mod-Alt-\\",run:ur},{key:"Shift-Mod-k",run:sr},{key:"Shift-Mod-\\",run:Wn},{key:"Mod-/",run:nn},{key:"Alt-A",mac:"Ctrl-A",run:on},{key:"Ctrl-m",mac:"Shift-Alt-m",run:hr}].concat(dr),Pt={key:"Tab",run:te,shift:Ft};var Nt=typeof String.prototype.normalize=="function"?(e)=>e.normalize("NFKD"):(e)=>e;class T{constructor(e,t,n=0,r=e.length,o,l){this.test=l,this.value={from:0,to:0,precise:!1},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(n,r),this.bufferStart=n,this.normalize=o?(s)=>o(Nt(s)):Nt,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return Yi(this.buffer,this.bufferPos)}next(){while(this.matches.length)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=Bo(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=Hi(e);let r=this.normalize(t);if(r.length)for(let o=0,l=n,s=!0;;o++){let c=r.charCodeAt(o),a=this.match(c,l,s,this.bufferPos+this.bufferStart,o==r.length-1);if(a)return this.value=a,this;if(o==r.length-1)break;if(s&&o<t.length&&t.charCodeAt(o)==c)l++;else s=!1}}}match(e,t,n,r,o){let l=null;for(let s=0;s<this.matches.length;){let c=this.matches[s],a=!1;if(this.query.charCodeAt(c.index)==e)if(c.index==this.query.length-1)l={from:c.from,to:r,precise:o&&c.precise};else c.index++,a=!0;if(a)s++;else this.matches.splice(s,1)}if(this.query.charCodeAt(0)==e)if(this.query.length==1)l={from:t,to:r,precise:n&&o};else this.matches.push({from:t,index:1,precise:n});if(l&&this.test&&!this.test(l.from,l.to,this.buffer,this.bufferStart))l=null;return l}}if(typeof Symbol<"u")T.prototype[Symbol.iterator]=function(){return this};var zt={from:-1,to:-1,match:/.*/.exec(""),precise:!0},Te="gm"+(/x/.unicode==null?"":"u");class we{constructor(e,t,n,r=0,o=e.length){if(this.text=e,this.to=o,this.curLine="",this.done=!1,this.value=zt,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new We(e,t,n,r,o);this.re=new RegExp(t,Te+((n===null||n===void 0?void 0:n.ignoreCase)?"i":"")),this.test=n===null||n===void 0?void 0:n.test,this.iter=e.iter();let l=e.lineAt(r);this.curLineStart=l.from,this.matchPos=ie(e,r),this.getLine(this.curLineStart)}getLine(e){if(this.iter.next(e),this.iter.lineBreak)this.curLine="";else{if(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to)this.curLine=this.curLine.slice(0,this.to-this.curLineStart);this.iter.next()}}nextLine(){if(this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to)this.curLine="";else this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let n=this.curLineStart+t.index,r=n+t[0].length;if(this.matchPos=ie(this.text,r+(n==r?1:0)),n==this.curLineStart+this.curLine.length)this.nextLine();if((n<r||n>this.value.to)&&(!this.test||this.test(n,r,t)))return this.value={from:n,to:r,precise:!0,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}}var Ae=new WeakMap;class N{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(e,t,n){let r=Ae.get(e);if(!r||r.from>=n||r.to<=t){let s=new N(t,e.sliceString(t,n));return Ae.set(e,s),s}if(r.from==t&&r.to==n)return r;let{text:o,from:l}=r;if(l>t)o=e.sliceString(t,l)+o,l=t;if(r.to<n)o+=e.sliceString(r.to,n);return Ae.set(e,new N(l,o)),new N(t,o.slice(t-l,n-l))}}class We{constructor(e,t,n,r,o){this.text=e,this.to=o,this.done=!1,this.value=zt,this.matchPos=ie(e,r),this.re=new RegExp(t,Te+((n===null||n===void 0?void 0:n.ignoreCase)?"i":"")),this.test=n===null||n===void 0?void 0:n.test,this.flat=N.get(e,r,this.chunkEnd(r+5000))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e)this.re.lastIndex=e+1,t=this.re.exec(this.flat.text);if(t){let n=this.flat.from+t.index,r=n+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(n,r,t)))return this.value={from:n,to:r,precise:!0,match:t},this.matchPos=ie(this.text,r+(n==r?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=N.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}if(typeof Symbol<"u")we.prototype[Symbol.iterator]=We.prototype[Symbol.iterator]=function(){return this};function mr(e){try{return new RegExp(e,Te),!0}catch(t){return!1}}function ie(e,t){if(t>=e.length)return t;let n=e.lineAt(t),r;while(t<n.to&&(r=n.text.charCodeAt(t-n.from))>=56320&&r<57344)t++;return t}var pr=(e)=>{let t=Yo(e,"cm-goto-line");if(t){let s=t.dom.querySelector("input[type=text]");if(s)s.select();return!0}let{state:n}=e,r=String(n.doc.lineAt(e.state.selection.main.head).number),{close:o,result:l}=Wo(e,{class:"cm-goto-line",label:n.phrase("Go to line"),input:{type:"text",name:"line",value:r},focus:!0,submitLabel:n.phrase("go")});return l.then((s)=>{let c=s&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(s.elements.line.value);if(!c){e.dispatch({effects:o});return}let a=n.doc.lineAt(n.selection.main.head),[,h,u,f,m]=c,B=f?+f.slice(1):0,b=u?+u:a.number;if(u&&m){let me=b/100;if(h)me=me*(h=="-"?-1:1)+a.number/n.doc.lines;b=Math.round(n.doc.lines*me)}else if(u&&h)b=b*(h=="-"?-1:1)+a.number;let qe=n.doc.line(Math.max(1,Math.min(n.doc.lines,b))),Ve=d.cursor(qe.from+Math.max(0,Math.min(B,qe.length)));e.dispatch({effects:[o,v.scrollIntoView(Ve.from,{y:"center"})],selection:Ve})}),!0},gr={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},_t=w.define({combine(e){return xt(e,gr,{highlightWordAroundCursor:(t,n)=>t||n,minSelectionLength:Math.min,maxMatches:Math.min})}});function Jt(e){let t=[vr,kr];if(e)t.push(_t.of(e));return t}var yr=z.mark({class:"cm-selectionMatch"}),xr=z.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function Vt(e,t,n,r){return(n==0||e(t.sliceDoc(n-1,n))!=ce.Word)&&(r==t.doc.length||e(t.sliceDoc(r,r+1))!=ce.Word)}function Sr(e,t,n,r){return e(t.sliceDoc(n,n+1))==ce.Word&&e(t.sliceDoc(r-1,r))==ce.Word}var kr=De.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){if(e.selectionSet||e.docChanged||e.viewportChanged)this.decorations=this.getDeco(e.view)}getDeco(e){let t=e.state.facet(_t),{state:n}=e,r=n.selection;if(r.ranges.length>1)return z.none;let o=r.main,l,s=null;if(o.empty){if(!t.highlightWordAroundCursor)return z.none;let a=n.wordAt(o.head);if(!a)return z.none;s=n.charCategorizer(o.head),l=n.sliceDoc(a.from,a.to)}else{let a=o.to-o.from;if(a<t.minSelectionLength||a>200)return z.none;if(t.wholeWords){if(l=n.sliceDoc(o.from,o.to),s=n.charCategorizer(o.head),!(Vt(s,n,o.from,o.to)&&Sr(s,n,o.from,o.to)))return z.none}else if(l=n.sliceDoc(o.from,o.to),!l)return z.none}let c=[];for(let a of e.visibleRanges){let h=new T(n.doc,l,a.from,a.to);while(!h.next().done){let{from:u,to:f}=h.value;if(!s||Vt(s,n,u,f)){if(o.empty&&u<=o.from&&f>=o.to)c.push(xr.range(u,f));else if(u>=o.to||f<=o.from)c.push(yr.range(u,f));if(c.length>t.maxMatches)return z.none}}}return z.set(c)}},{decorations:(e)=>e.decorations}),vr=v.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),br=({state:e,dispatch:t})=>{let{selection:n}=e,r=d.create(n.ranges.map((o)=>e.wordAt(o.head)||d.cursor(o.head)),n.mainIndex);if(r.eq(n))return!1;return t(e.update({selection:r})),!0};function Cr(e,t){let{main:n,ranges:r}=e.selection,o=e.wordAt(n.head),l=o&&o.from==n.from&&o.to==n.to;for(let s=!1,c=new T(e.doc,t,r[r.length-1].to);;)if(c.next(),c.done){if(s)return null;c=new T(e.doc,t,0,Math.max(0,r[r.length-1].from-1)),s=!0}else{if(s&&r.some((a)=>a.from==c.value.from))continue;if(l){let a=e.wordAt(c.value.from);if(!a||a.from!=c.value.from||a.to!=c.value.to)continue}return c.value}}var Mr=({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some((l)=>l.from===l.to))return br({state:e,dispatch:t});let r=e.sliceDoc(n[0].from,n[0].to);if(e.selection.ranges.some((l)=>e.sliceDoc(l.from,l.to)!=r))return!1;let o=Cr(e,r);if(!o)return!1;return t(e.update({selection:e.selection.addRange(d.range(o.from,o.to),!1),effects:v.scrollIntoView(o.to)})),!0},R=w.define({combine(e){return xt(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:(t)=>new Zt(t),scrollToMatch:(t)=>v.scrollIntoView(t)})}});function $t(e){return e?[R.of(e),Ee]:Ee}class Re{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||mr(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(t,n)=>n=="n"?`
2
- `:n=="r"?"\r":n=="t"?"\t":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new Ht(this):new Kt(this)}getCursor(e,t=0,n){let r=e.doc?e:q.create({doc:e});if(n==null)n=r.doc.length;return this.regexp?P(this,r,t,n):F(this,r,t,n)}}class Oe{constructor(e){this.spec=e}}function Ar(e,t,n){return(r,o,l,s)=>{if(n&&!n(r,o,l,s))return!1;let c=r>=s&&o<=s+l.length?l.slice(r-s,o-s):t.doc.sliceString(r,o);return e(c,t,r,o)}}function F(e,t,n,r){let o;if(e.wholeWord)o=Lr(t.doc,t.charCategorizer(t.selection.main.head));if(e.test)o=Ar(e.test,t,o);return new T(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:(l)=>l.toLowerCase(),o)}function Lr(e,t){return(n,r,o,l)=>{if(l>n||l+o.length<r)l=Math.max(0,n-2),o=e.sliceString(l,Math.min(e.length,r+2));return(t(ae(o,n-l))!=ce.Word||t(ue(o,n-l))!=ce.Word)&&(t(ue(o,r-l))!=ce.Word||t(ae(o,r-l))!=ce.Word)}}class Kt extends Oe{constructor(e){super(e)}nextMatch(e,t,n){let r=F(this.spec,e,n,e.doc.length).nextOverlapping();if(r.done){let o=Math.min(e.doc.length,t+this.spec.unquoted.length);r=F(this.spec,e,0,o).nextOverlapping()}return r.done||r.value.from==t&&r.value.to==n?null:r.value}prevMatchInRange(e,t,n){for(let r=n;;){let o=Math.max(t,r-1e4-this.spec.unquoted.length),l=F(this.spec,e,o,r),s=null;while(!l.nextOverlapping().done)s=l.value;if(s)return s;if(o==t)return null;r-=1e4}}prevMatch(e,t,n){let r=this.prevMatchInRange(e,0,t);if(!r)r=this.prevMatchInRange(e,Math.max(0,n-this.spec.unquoted.length),e.doc.length);return r&&(r.from!=t||r.to!=n)?r:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let n=F(this.spec,e,0,e.doc.length),r=[];while(!n.next().done){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let o=F(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));while(!o.next().done)r(o.value.from,o.value.to)}}function Br(e,t,n){return(r,o,l)=>(!n||n(r,o,l))&&e(l[0],t,r,o)}function P(e,t,n,r){let o;if(e.wholeWord)o=Dr(t.charCategorizer(t.selection.main.head));if(e.test)o=Br(e.test,t,o);return new we(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:o},n,r)}function ae(e,t){return e.slice(be(e,t,!1),t)}function ue(e,t){return e.slice(t,be(e,t))}function Dr(e){return(t,n,r)=>!r[0].length||(e(ae(r.input,r.index))!=ce.Word||e(ue(r.input,r.index))!=ce.Word)&&(e(ue(r.input,r.index+r[0].length))!=ce.Word||e(ae(r.input,r.index+r[0].length))!=ce.Word)}class Ht extends Oe{nextMatch(e,t,n){let r=P(this.spec,e,n,e.doc.length).next();if(r.done)r=P(this.spec,e,0,t).next();return r.done?null:r.value}prevMatchInRange(e,t,n){for(let r=1;;r++){let o=Math.max(t,n-r*1e4),l=P(this.spec,e,o,n),s=null;while(!l.next().done)s=l.value;if(s&&(o==t||s.from>o+10))return s;if(o==t)return null}}prevMatch(e,t,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,n)=>{if(n=="&")return e.match[0];if(n=="$")return"$";for(let r=n.length;r>0;r--){let o=+n.slice(0,r);if(o>0&&o<e.match.length)return e.match[o]+n.slice(r)}return t})}matchAll(e,t){let n=P(this.spec,e,0,e.doc.length),r=[];while(!n.next().done){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let o=P(this.spec,e,Math.max(0,t-250),Math.min(n+250,e.doc.length));while(!o.next().done)r(o.value.from,o.value.to)}}var J=W.define(),Ie=W.define(),E=Le.define({create(e){return new oe(Be(e).create(),null)},update(e,t){for(let n of t.effects)if(n.is(J))e=new oe(n.value.create(),e.panel);else if(n.is(Ie))e=new oe(e.query,n.value?Pe:null);return e},provide:(e)=>hi.from(e,(t)=>t.panel)});class oe{constructor(e,t){this.query=e,this.panel=t}}var Er=z.mark({class:"cm-searchMatch"}),Tr=z.mark({class:"cm-searchMatch cm-searchMatch-selected"}),wr=De.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(E))}update(e){let t=e.state.field(E);if(t!=e.startState.field(E)||e.docChanged||e.selectionSet||e.viewportChanged)this.decorations=this.highlight(t)}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return z.none;let{view:n}=this,r=new St;for(let o=0,l=n.visibleRanges,s=l.length;o<s;o++){let{from:c,to:a}=l[o];while(o<s-1&&a>l[o+1].from-500)a=l[++o].to;e.highlight(n.state,c,a,(h,u)=>{let f=n.state.selection.ranges.some((m)=>m.from==h&&m.to==u);r.add(h,u,f?Tr:Er)})}return r.finish()}},{decorations:(e)=>e.decorations});function K(e){return(t)=>{let n=t.state.field(E,!1);return n&&n.query.spec.valid?e(t,n):de(t)}}var he=K((e,{query:t})=>{let{to:n}=e.state.selection.main,r=t.nextMatch(e.state,n,n);if(!r)return!1;let o=d.single(r.from,r.to),l=e.state.facet(R);return e.dispatch({selection:o,effects:[Ne(e,r),l.scrollToMatch(o.main,e)],userEvent:"select.search"}),jt(e),!0}),fe=K((e,{query:t})=>{let{state:n}=e,{from:r}=n.selection.main,o=t.prevMatch(n,r,r);if(!o)return!1;let l=d.single(o.from,o.to),s=e.state.facet(R);return e.dispatch({selection:l,effects:[Ne(e,o),s.scrollToMatch(l.main,e)],userEvent:"select.search"}),jt(e),!0}),Wr=K((e,{query:t})=>{let n=t.matchAll(e.state,1000);if(!n||!n.length)return!1;return e.dispatch({selection:d.create(n.map((r)=>d.range(r.from,r.to))),userEvent:"select.search.matches"}),!0}),Rr=({state:e,dispatch:t})=>{let n=e.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:r,to:o}=n.main,l=[],s=0;for(let c=new T(e.doc,e.sliceDoc(r,o));!c.next().done;){if(l.length>1000)return!1;if(c.value.from==r)s=l.length;l.push(d.range(c.value.from,c.value.to))}return t(e.update({selection:d.create(l,s),userEvent:"select.search.matches"})),!0},Ut=K((e,{query:t})=>{let{state:n}=e,{from:r,to:o}=n.selection.main;if(n.readOnly)return!1;let l=t.nextMatch(n,r,r);if(!l)return!1;let s=l,c=[],a,h,u=[];if(!s.precise)s=t.nextMatch(n,s.from,s.to);else if(s.from==r&&s.to==o)h=n.toText(t.getReplacement(s)),c.push({from:s.from,to:s.to,insert:h}),s=t.nextMatch(n,s.from,s.to),u.push(v.announce.of(n.phrase("replaced match on line $",n.doc.lineAt(r).number)+"."));let f=e.state.changes(c);if(s)a=d.single(s.from,s.to).map(f),u.push(Ne(e,s)),u.push(n.facet(R).scrollToMatch(a.main,e));return e.dispatch({changes:f,selection:a,effects:u,userEvent:"input.replace"}),!0}),Or=K((e,{query:t})=>{if(e.state.readOnly)return!1;let n=[];for(let o of t.matchAll(e.state,1e9)){let{from:l,to:s,precise:c}=o;if(c)n.push({from:l,to:s,insert:t.getReplacement(o)})}if(!n.length)return!1;let r=e.state.phrase("replaced $ matches",n.length)+".";return e.dispatch({changes:n,effects:v.announce.of(r),userEvent:"input.replace.all"}),!0});function Pe(e){return e.state.facet(R).createPanel(e)}function Be(e,t){var n,r,o,l,s;let c=e.selection.main,a=c.empty||c.to>c.from+100?"":e.sliceDoc(c.from,c.to);if(t&&!a)return t;let h=e.facet(R);return new Re({search:((n=t===null||t===void 0?void 0:t.literal)!==null&&n!==void 0?n:h.literal)?a:a.replace(/\n/g,"\\n"),caseSensitive:(r=t===null||t===void 0?void 0:t.caseSensitive)!==null&&r!==void 0?r:h.caseSensitive,literal:(o=t===null||t===void 0?void 0:t.literal)!==null&&o!==void 0?o:h.literal,regexp:(l=t===null||t===void 0?void 0:t.regexp)!==null&&l!==void 0?l:h.regexp,wholeWord:(s=t===null||t===void 0?void 0:t.wholeWord)!==null&&s!==void 0?s:h.wholeWord})}function Qt(e){let t=ji(e,Pe);return t&&t.dom.querySelector("[main-field]")}function jt(e){let t=Qt(e);if(t&&t==e.root.activeElement)t.select()}var de=(e)=>{let t=e.state.field(E,!1);if(t&&t.panel){let n=Qt(e);if(n&&n!=e.root.activeElement){let r=Be(e.state,t.query.spec);if(r.valid)e.dispatch({effects:J.of(r)});n.focus(),n.select()}}else e.dispatch({effects:[Ie.of(!0),t?J.of(Be(e.state,t.query.spec)):W.appendConfig.of(Ee)]});return!0},Xt=(e)=>{let t=e.state.field(E,!1);if(!t||!t.panel)return!1;let n=ji(e,Pe);if(n&&n.dom.contains(e.root.activeElement))e.focus();return e.dispatch({effects:Ie.of(!1)}),!0},Yt=[{key:"Mod-f",run:de,scope:"editor search-panel"},{key:"F3",run:he,shift:fe,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:he,shift:fe,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:Xt,scope:"editor search-panel"},{key:"Mod-Shift-l",run:Rr},{key:"Mod-Alt-g",run:pr},{key:"Mod-d",run:Mr,preventDefault:!0}];class Zt{constructor(e){this.view=e;let t=this.query=e.state.field(E).query.spec;this.commit=this.commit.bind(this),this.searchField=xe("input",{value:t.search,placeholder:x(e,"Find"),"aria-label":x(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=xe("input",{value:t.replace,placeholder:x(e,"Replace"),"aria-label":x(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=xe("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=xe("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=xe("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit});function n(r,o,l){return xe("button",{class:"cm-button",name:r,onclick:o,type:"button"},l)}this.dom=xe("div",{onkeydown:(r)=>this.keydown(r),class:"cm-search"},[this.searchField,n("next",()=>he(e),[x(e,"next")]),n("prev",()=>fe(e),[x(e,"previous")]),n("select",()=>Wr(e),[x(e,"all")]),xe("label",null,[this.caseField,x(e,"match case")]),xe("label",null,[this.reField,x(e,"regexp")]),xe("label",null,[this.wordField,x(e,"by word")]),...e.state.readOnly?[]:[xe("br"),this.replaceField,n("replace",()=>Ut(e),[x(e,"replace")]),n("replaceAll",()=>Or(e),[x(e,"replace all")])],xe("button",{name:"close",onclick:()=>Xt(e),"aria-label":x(e,"close"),type:"button"},["×"])])}commit(){let e=new Re({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});if(!e.eq(this.query))this.query=e,this.view.dispatch({effects:J.of(e)})}keydown(e){if(Fo(this.view,e,"search-panel"))e.preventDefault();else if(e.keyCode==13&&e.target==this.searchField)e.preventDefault(),(e.shiftKey?fe:he)(this.view);else if(e.keyCode==13&&e.target==this.replaceField)e.preventDefault(),Ut(this.view)}update(e){for(let t of e.transactions)for(let n of t.effects)if(n.is(J)&&!n.value.eq(this.query))this.setQuery(n.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(R).top}}function x(e,t){return e.state.phrase(t)}var ne=30,re=/[\s\.,:;?!]/;function Ne(e,{from:t,to:n}){let r=e.state.doc.lineAt(t),o=e.state.doc.lineAt(n).to,l=Math.max(r.from,t-ne),s=Math.min(o,n+ne),c=e.state.sliceDoc(l,s);if(l!=r.from){for(let a=0;a<ne;a++)if(!re.test(c[a+1])&&re.test(c[a])){c=c.slice(a);break}}if(s!=o){for(let a=c.length-1;a>c.length-ne;a--)if(!re.test(c[a-1])&&re.test(c[a])){c=c.slice(0,a);break}}return v.announce.of(`${e.state.phrase("current match")}. ${c} ${e.state.phrase("on line")} ${r.number}.`)}var Fr=v.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),Ee=[E,Fe.low(wr),Fr];var Pr=v.theme({"&":{color:"var(--code-fg)",backgroundColor:"var(--code-bg)",height:"100%",fontSize:"var(--code-size, 13px)"},"&.cm-focused":{outline:"none"},".cm-scroller":{fontFamily:"var(--font-mono)",lineHeight:"1.55",overflow:"auto"},".cm-content":{caretColor:"var(--code-fg)",padding:"0.5rem 0"},".cm-line":{padding:"0 0.75rem"},".cm-cursor, .cm-dropCursor":{borderLeftColor:"var(--code-fg)"},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:"var(--code-selection)"},".cm-activeLine":{backgroundColor:"var(--code-active-line)"},".cm-gutters":{backgroundColor:"var(--code-gutter-bg)",color:"var(--code-gutter)",border:"none",borderRight:"1px solid var(--border)"},".cm-activeLineGutter":{backgroundColor:"var(--code-active-line)",color:"var(--code-fg)"},".cm-lineNumbers .cm-gutterElement":{padding:"0 0.5rem 0 0.5rem",minWidth:"2.25rem"},".cm-matchingBracket, .cm-nonmatchingBracket":{backgroundColor:"var(--code-selection)",outline:"1px solid var(--border-strong)"},".cm-searchMatch":{backgroundColor:"var(--warn-soft)",outline:"1px solid var(--warn)"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"var(--accent-soft)",outline:"1px solid var(--accent)"},".cm-panels":{backgroundColor:"var(--surface-2)",color:"var(--text)",borderColor:"var(--border)",fontFamily:"var(--font)"},".cm-panels-top":{borderBottom:"1px solid var(--border)"},".cm-panel.cm-search":{padding:"0.5rem 2rem 0.5rem 0.5rem"},".cm-panel.cm-search input, .cm-panel.cm-search button, .cm-panel.cm-search label":{fontSize:"0.875rem"},".cm-panel.cm-search input[type=text]":{backgroundColor:"var(--surface)",color:"var(--text)",border:"1px solid var(--control-border)",borderRadius:"var(--radius-sm)",padding:"0.25rem 0.5rem"},".cm-panel.cm-search button":{backgroundColor:"var(--surface-3)",color:"var(--text)",border:"1px solid var(--border-strong)",borderRadius:"var(--radius-sm)",backgroundImage:"none",padding:"0.25rem 0.625rem"},".cm-panel.cm-search [name=close]":{color:"var(--muted)"}}),Nr=In.define([{tag:[i.keyword,i.modifier,i.operatorKeyword,i.controlKeyword],color:"var(--code-keyword)"},{tag:[i.string,i.regexp,i.special(i.string),i.inserted],color:"var(--code-string)"},{tag:[i.number,i.bool,i.null,i.atom,i.literal],color:"var(--code-number)"},{tag:[i.comment,i.lineComment,i.blockComment,i.docComment],color:"var(--code-comment)",fontStyle:"italic"},{tag:[i.typeName,i.className,i.namespace,i.tagName,i.standard(i.tagName)],color:"var(--code-type)"},{tag:[i.function(i.variableName),i.function(i.propertyName),i.definition(i.variableName),i.labelName],color:"var(--code-function)"},{tag:[i.meta,i.processingInstruction,i.annotation,i.attributeName,i.propertyName,i.heading],color:"var(--code-meta)"},{tag:i.heading,fontWeight:"bold"},{tag:i.strong,fontWeight:"bold"},{tag:i.emphasis,fontStyle:"italic"},{tag:i.strikethrough,textDecoration:"line-through"},{tag:i.link,color:"var(--code-function)",textDecoration:"underline"},{tag:i.url,color:"var(--code-function)"},{tag:i.invalid,color:"var(--danger)"},{tag:i.deleted,color:"var(--danger)"}]),en=[Pr,es(Nr)];var qr={typescript:()=>(p("7gcbrhbd"),import("./chunk-lang-typescript-7gcbrhbd.js")),javascript:()=>(p("m57t19pw"),import("./chunk-lang-javascript-m57t19pw.js")),json:()=>(p("y33kawwg"),import("./chunk-lang-json-y33kawwg.js")),markdown:()=>(p("2c2sqc4z"),import("./chunk-lang-markdown-2c2sqc4z.js")),css:()=>(p("6t2q4xw4"),import("./chunk-lang-css-6t2q4xw4.js")),html:()=>(p("c6p22v5m"),import("./chunk-lang-html-c6p22v5m.js")),python:()=>(p("ymasvj52"),import("./chunk-lang-python-ymasvj52.js")),yaml:()=>(p("qp3asq06"),import("./chunk-lang-yaml-qp3asq06.js")),go:()=>(p("t47kg9n0"),import("./chunk-lang-go-t47kg9n0.js")),rust:()=>(p("qcg53mkn"),import("./chunk-lang-rust-qcg53mkn.js")),sql:()=>(p("60rh2y3y"),import("./chunk-lang-sql-60rh2y3y.js")),xml:()=>(p("k2a92cm3"),import("./chunk-lang-xml-k2a92cm3.js")),shell:()=>(p("996wb0dk"),import("./chunk-lang-shell-996wb0dk.js")),toml:()=>(p("q1yzt70y"),import("./chunk-lang-toml-q1yzt70y.js")),dockerfile:()=>(p("9rc0adjw"),import("./chunk-lang-dockerfile-9rc0adjw.js"))};async function tn(e){if(e==="plain")return;try{return(await qr[e]()).language()}catch(t){console.warn("a language for the editor failed to load",t);return}}function Vr(e){if(typeof e.attachShadow!=="function"||typeof CSSStyleSheet>"u"||!("adoptedStyleSheets"in Document.prototype))return{parent:e,root:void 0};let t=e.shadowRoot??e.attachShadow({mode:"open"}),n=new CSSStyleSheet;return n.replaceSync(":host{display:flex;flex-direction:column;min-height:0}.cm-editor{flex:1;min-height:0}"),t.adoptedStyleSheets=[...t.adoptedStyleSheets,n],{parent:t,root:t}}async function ao(e){let t=new qt,n=new qt,r=new qt,o=await tn(e.language),l=(f)=>[q.readOnly.of(!f),v.editable.of(f)],s={editable:e.editable,wrap:e.wrap,language:o??[]},c,a=(f)=>[Ho(),Zo(),jo(),et(),Go(),ts(),Jt(),$t({top:!0}),rt.of(" "),q.phrases.of(e.phrases),en,Tt.of([{key:"Mod-s",preventDefault:!0,run:()=>(e.onSave(),!0)},{key:"Escape",run:()=>(e.onEscape(),!0)},Pt,...Yt,...ot,...It]),q.lineSeparator.of(f),t.of(l(s.editable)),n.of(s.wrap?v.lineWrapping:[]),r.of(s.language),v.updateListener.of((m)=>{if(m.docChanged)e.onChange()})],h=Vr(e.parent),u=new v({parent:h.parent,root:h.root,state:q.create({doc:e.text,extensions:a(e.eol)})});return c=u.state.doc,{text:()=>u.state.doc.sliceString(0,void 0,u.state.lineBreak),dirty:()=>c===void 0||!u.state.doc.eq(c),snapshot:()=>u.state.doc,markSaved:(f)=>{c=f??u.state.doc},replace:(f,m)=>{let B=u.scrollDOM.scrollTop;u.setState(q.create({doc:f,extensions:a(m)})),c=u.state.doc,u.scrollDOM.scrollTop=B},setEditable:(f)=>{s.editable=f,u.dispatch({effects:t.reconfigure(l(f))})},setWrap:(f)=>{s.wrap=f,u.dispatch({effects:n.reconfigure(f?v.lineWrapping:[])})},setLanguage:async(f)=>{s.language=await tn(f)??[],u.dispatch({effects:r.reconfigure(s.language)})},undo:()=>{X(u)},redo:()=>{U(u)},find:()=>{de(u)},tab:()=>{te(u)},focus:()=>u.focus(),scrollTop:()=>u.scrollDOM.scrollTop,scrollTo:(f)=>{u.scrollDOM.scrollTop=f},destroy:()=>u.destroy()}}export{ao as createEditor};
1
+ import{G,be,Hi,Fo,ji,mt,ve,d,w,Xe,Fe,qt,Ge,W,le,ce,q,xt,St,Ze,xe,z,se,De,v,Tt,Go,Zo,Wo,Ki,hi,Yo,Ho,jo,Ko,M,i,I,rt,Gt,gi,Dr,zn,In,ts,ns,Ot}from"./chunk-index-b093s676.js";import{p}from"./chunk-index-htdkpbrd.js";var nn=(e)=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=Ce(e.state,n.from);return r.line?rn(e):r.block?ln(e):!1};function ke(e,t){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let o=e(t,n);if(!o)return!1;return r(n.update(o)),!0}}var rn=ke(an,0);var on=ke(Qe,0);var ln=ke((e,t)=>Qe(e,t,cn(t)),0);function Ce(e,t){let n=e.languageDataAt("commentTokens",t,1);return n.length?n[0]:{}}var V=50;function sn(e,{open:t,close:n},r,o){let l=e.sliceDoc(r-V,r),s=e.sliceDoc(o,o+V),c=/\s*$/.exec(l)[0].length,a=/^\s*/.exec(s)[0].length,h=l.length-c;if(l.slice(h-t.length,h)==t&&s.slice(a,a+n.length)==n)return{open:{pos:r-c,margin:c&&1},close:{pos:o+a,margin:a&&1}};let u,f;if(o-r<=2*V)u=f=e.sliceDoc(r,o);else u=e.sliceDoc(r,r+V),f=e.sliceDoc(o-V,o);let m=/^\s*/.exec(u)[0].length,B=/\s*$/.exec(f)[0].length,b=f.length-B-n.length;if(u.slice(m,m+t.length)==t&&f.slice(b,b+n.length)==n)return{open:{pos:r+m+t.length,margin:/\s/.test(u.charAt(m+t.length))?1:0},close:{pos:o-B-n.length,margin:/\s/.test(f.charAt(b-1))?1:0}};return null}function cn(e){let t=[];for(let n of e.selection.ranges){let r=e.doc.lineAt(n.from),o=n.to<=r.to?r:e.doc.lineAt(n.to);if(o.from>r.from&&o.from==n.to)o=n.to==r.to+1?r:e.doc.lineAt(n.to-1);let l=t.length-1;if(l>=0&&t[l].to>r.from)t[l].to=o.to;else t.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:o.to})}return t}function Qe(e,t,n=t.selection.ranges){let r=n.map((l)=>Ce(t,l.from).block);if(!r.every((l)=>l))return null;let o=n.map((l,s)=>sn(t,r[s],l.from,l.to));if(e!=2&&!o.every((l)=>l))return{changes:t.changes(n.map((l,s)=>{if(o[s])return[];return[{from:l.from,insert:r[s].open+" "},{from:l.to,insert:" "+r[s].close}]}))};else if(e!=1&&o.some((l)=>l)){let l=[];for(let s=0,c;s<o.length;s++)if(c=o[s]){let a=r[s],{open:h,close:u}=c;l.push({from:h.pos-a.open.length,to:h.pos+h.margin},{from:u.pos-u.margin,to:u.pos+a.close.length})}return{changes:l}}return null}function an(e,t,n=t.selection.ranges){let r=[],o=-1;e:for(let{from:l,to:s}of n){let c=r.length,a=1e9,h;for(let u=l;u<=s;){let f=t.doc.lineAt(u);if(h==null){if(h=Ce(t,f.from).line,!h)continue e}if(f.from>o&&(l==s||s>f.from)){o=f.from;let m=/^\s*/.exec(f.text)[0].length,B=m==f.length,b=f.text.slice(m,m+h.length)==h?m:-1;if(m<f.text.length&&m<a)a=m;r.push({line:f,comment:b,token:h,indent:m,empty:B,single:!1})}u=f.to+1}if(a<1e9){for(let u=c;u<r.length;u++)if(r[u].indent<r[u].line.text.length)r[u].indent=a}if(r.length==c+1)r[c].single=!0}if(e!=2&&r.some((l)=>l.comment<0&&(!l.empty||l.single))){let l=[];for(let{line:c,token:a,indent:h,empty:u,single:f}of r)if(f||!u)l.push({from:c.from+h,insert:a+" "});let s=t.changes(l);return{changes:s,selection:t.selection.map(s,1)}}else if(e!=1&&r.some((l)=>l.comment>=0)){let l=[];for(let{line:s,comment:c,token:a}of r)if(c>=0){let h=s.from+c,u=h+a.length;if(s.text[u-s.from]==" ")u++;l.push({from:h,to:u})}return{changes:l}}return null}var ge=Ge.define(),un=Ge.define(),hn=w.define(),je=w.define({combine(e){return xt(e,{minDepth:100,newGroupDelay:500,joinToEvent:(t,n)=>n},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(t,n)=>(r,o)=>t(r,o)||n(r,o)})}}),Ye=Xe.define({create(){return L.empty},update(e,t){let n=t.state.facet(je),r=t.annotation(ge);if(r){let a=y.fromTransaction(t,r.selection),h=r.side,u=h==0?e.undone:e.done;if(a)u=Q(u,u.length,n.minDepth,a);else u=nt(u,t.startState.selection);return new L(h==0?r.rest:u,h==0?u:r.rest)}let o=t.annotation(un);if(o=="full"||o=="before")e=e.isolate();if(t.annotation(le.addToHistory)===!1)return!t.changes.empty?e.addMapping(t.changes.desc):e;let l=y.fromTransaction(t),s=t.annotation(le.time),c=t.annotation(le.userEvent);if(l)e=e.addChanges(l,s,c,n,t);else if(t.selection)e=e.addSelection(t.startState.selection,s,c,n.newGroupDelay);if(o=="full"||o=="after")e=e.isolate();return e},toJSON(e){return{done:e.done.map((t)=>t.toJSON()),undone:e.undone.map((t)=>t.toJSON())}},fromJSON(e){return new L(e.done.map(y.fromJSON),e.undone.map(y.fromJSON))}});function et(e={}){return[Ye,je.of(e),v.domEventHandlers({beforeinput(t,n){let r=t.inputType=="historyUndo"?X:t.inputType=="historyRedo"?U:null;if(!r)return!1;return t.preventDefault(),r(n)}})]}function j(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let o=n.field(Ye,!1);if(!o)return!1;let l=o.pop(e,n,t);if(!l)return!1;return r(l),!0}}var X=j(0,!1),U=j(1,!1),fn=j(0,!0),dn=j(1,!0);class y{constructor(e,t,n,r,o){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=r,this.selectionsAfter=o}setSelAfter(e){return new y(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,n;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(t=this.mapped)===null||t===void 0?void 0:t.toJSON(),startSelection:(n=this.startSelection)===null||n===void 0?void 0:n.toJSON(),selectionsAfter:this.selectionsAfter.map((r)=>r.toJSON())}}static fromJSON(e){return new y(e.changes&&ve.fromJSON(e.changes),[],e.mapped&&mt.fromJSON(e.mapped),e.startSelection&&d.fromJSON(e.startSelection),e.selectionsAfter.map(d.fromJSON))}static fromTransaction(e,t){let n=S;for(let r of e.startState.facet(hn)){let o=r(e);if(o.length)n=n.concat(o)}if(!n.length&&e.changes.empty)return null;return new y(e.changes.invert(e.startState.doc),n,void 0,t||e.startState.selection,S)}static selection(e){return new y(void 0,S,void 0,void 0,e)}}function Q(e,t,n,r){let o=t+1>n+20?t-n-1:0,l=e.slice(o,t);return l.push(r),l}function mn(e,t){let n=[],r=!1;return e.iterChangedRanges((o,l)=>n.push(o,l)),t.iterChangedRanges((o,l,s,c)=>{for(let a=0;a<n.length;){let h=n[a++],u=n[a++];if(c>=h&&s<=u)r=!0}}),r}function pn(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((n,r)=>n.empty!=t.ranges[r].empty).length===0}function tt(e,t){return!e.length?t:!t.length?e:e.concat(t)}var S=[],gn=200;function nt(e,t){if(!e.length)return[y.selection([t])];else{let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-gn));if(r.length&&r[r.length-1].eq(t))return e;return r.push(t),Q(e,e.length-1,1e9,n.setSelAfter(r))}}function yn(e){let t=e[e.length-1],n=e.slice();return n[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),n}function pe(e,t){if(!e.length)return e;let n=e.length,r=S;while(n){let o=xn(e[n-1],t,r);if(o.changes&&!o.changes.empty||o.effects.length){let l=e.slice(0,n);return l[n-1]=o,l}else t=o.mapped,n--,r=o.selectionsAfter}return r.length?[y.selection(r)]:S}function xn(e,t,n){let r=tt(e.selectionsAfter.length?e.selectionsAfter.map((c)=>c.map(t)):S,n);if(!e.changes)return y.selection(r);let o=e.changes.map(t),l=t.mapDesc(e.changes,!0),s=e.mapped?e.mapped.composeDesc(l):l;return new y(o,W.mapEffects(e.effects,t),s,e.startSelection.map(l),r)}var Sn=/^(input\.type|delete)($|\.)/;class L{constructor(e,t,n=0,r=void 0){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=r}isolate(){return this.prevTime?new L(this.done,this.undone):this}addChanges(e,t,n,r,o){let l=this.done,s=l[l.length-1];if(s&&s.changes&&!s.changes.empty&&e.changes&&(!n||Sn.test(n))&&(!s.selectionsAfter.length&&t-this.prevTime<r.newGroupDelay&&r.joinToEvent(o,mn(s.changes,e.changes))||n=="input.type.compose"))l=Q(l,l.length-1,r.minDepth,new y(e.changes.compose(s.changes),tt(W.mapEffects(e.effects,s.changes),s.effects),s.mapped,s.startSelection,S));else l=Q(l,l.length,r.minDepth,e);return new L(l,S,t,n)}addSelection(e,t,n,r){let o=this.done.length?this.done[this.done.length-1].selectionsAfter:S;if(o.length>0&&t-this.prevTime<r&&n==this.prevUserEvent&&n&&/^select($|\.)/.test(n)&&pn(o[o.length-1],e))return this;return new L(nt(this.done,e),this.undone,t,n)}addMapping(e){return new L(pe(this.done,e),pe(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,t,n){let r=e==0?this.done:this.undone;if(r.length==0)return null;let o=r[r.length-1],l=o.selectionsAfter[0]||(o.startSelection?o.startSelection.map(o.changes.invertedDesc,1):t.selection);if(n&&o.selectionsAfter.length)return t.update({selection:o.selectionsAfter[o.selectionsAfter.length-1],annotations:ge.of({side:e,rest:yn(r),selection:l}),userEvent:e==0?"select.undo":"select.redo",scrollIntoView:!0});else if(!o.changes)return null;else{let s=r.length==1?S:r.slice(0,r.length-1);if(o.mapped)s=pe(s,o.mapped);return t.update({changes:o.changes,selection:o.startSelection,effects:o.effects,annotations:ge.of({side:e,rest:s,selection:l}),filter:!1,userEvent:e==0?"undo":"redo",scrollIntoView:!0})}}}L.empty=new L(S,S);var ot=[{key:"Mod-z",run:X,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:U,preventDefault:!0},{linux:"Ctrl-Shift-z",run:U,preventDefault:!0},{key:"Mod-u",run:fn,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:dn,preventDefault:!0}];function O(e,t){return d.create(e.ranges.map(t),e.mainIndex)}function C(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:"select"})}function A({state:e,dispatch:t},n){let r=O(e.selection,n);if(r.eq(e.selection,!0))return!1;return t(C(e,r)),!0}function Y(e,t){return d.cursor(t?e.to:e.from)}function lt(e,t){return A(e,(n)=>n.empty?e.moveByChar(n,t):Y(n,t))}function g(e){return e.textDirectionAt(e.state.selection.main.head)==se.LTR}var it=(e)=>lt(e,!g(e)),st=(e)=>lt(e,g(e));function ct(e,t){return A(e,(n)=>n.empty?e.moveByGroup(n,t):Y(n,t))}var kn=(e)=>ct(e,!g(e)),vn=(e)=>ct(e,g(e));var Jr=typeof Intl<"u"&&Intl.Segmenter?new Intl.Segmenter(void 0,{granularity:"word"}):null;function bn(e,t,n){if(t.type.prop(n))return!0;let r=t.to-t.from;return r&&(r>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function Z(e,t,n){let r=I(e).resolveInner(t.head),o=n?M.closedBy:M.openedBy;for(let a=t.head;;){let h=n?r.childAfter(a):r.childBefore(a);if(!h)break;if(bn(e,h,o))r=h;else a=n?h.to:h.from}let l=r.type.prop(o),s,c;if(l&&(s=n?Ot(e,r.from,1):Ot(e,r.to,-1))&&s.matched)c=n?s.end.to:s.end.from;else c=n?r.to:r.from;return d.cursor(c,n?-1:1)}var Cn=(e)=>A(e,(t)=>Z(e.state,t,!g(e))),Mn=(e)=>A(e,(t)=>Z(e.state,t,g(e)));function at(e,t){return A(e,(n)=>{if(!n.empty)return Y(n,t);let r=e.moveVertically(n,t);return r.head!=n.head?r:e.moveToLineBoundary(n,t)})}var ut=(e)=>at(e,!1),ht=(e)=>at(e,!0);function ft(e){let t=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,n=0,r=0,o;if(t){for(let l of e.state.facet(v.scrollMargins)){let s=l(e);if(s===null||s===void 0?void 0:s.top)n=Math.max(s===null||s===void 0?void 0:s.top,n);if(s===null||s===void 0?void 0:s.bottom)r=Math.max(s===null||s===void 0?void 0:s.bottom,r)}o=e.scrollDOM.clientHeight-n-r}else o=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:r,selfScroll:t,height:Math.max(e.defaultLineHeight,o-5)}}function dt(e,t){let n=ft(e),{state:r}=e,o=O(r.selection,(s)=>s.empty?e.moveVertically(s,t,n.height):Y(s,t));if(o.eq(r.selection))return!1;let l;if(n.selfScroll){let s=e.coordsAtPos(r.selection.main.head),c=e.scrollDOM.getBoundingClientRect(),a=c.top+n.marginTop,h=c.bottom-n.marginBottom;if(s&&s.top>a&&s.bottom<h)l=v.scrollIntoView(o.main.head,{y:"start",yMargin:s.top-a})}return e.dispatch(C(r,o),{effects:l}),!0}var Ve=(e)=>dt(e,!1),ye=(e)=>dt(e,!0);function D(e,t,n){let r=e.lineBlockAt(t.head),o=e.moveToLineBoundary(t,n);if(o.head==t.head&&o.head!=(n?r.to:r.from))o=e.moveToLineBoundary(t,n,!1);if(!n&&o.head==r.from&&r.length){let l=/^\s*/.exec(e.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;if(l&&t.head!=r.from+l)o=d.cursor(r.from+l)}return o}var An=(e)=>A(e,(t)=>D(e,t,!0)),Ln=(e)=>A(e,(t)=>D(e,t,!1)),Bn=(e)=>A(e,(t)=>D(e,t,!g(e))),Dn=(e)=>A(e,(t)=>D(e,t,g(e))),En=(e)=>A(e,(t)=>e.moveToLineBoundary(t,!1,!1)),Tn=(e)=>A(e,(t)=>e.moveToLineBoundary(t,!0,!1));function wn(e,t,n){let r=!1,o=O(e.selection,(l)=>{let s=Ot(e,l.head,-1)||Ot(e,l.head,1)||l.head>0&&Ot(e,l.head-1,1)||l.head<e.doc.length&&Ot(e,l.head+1,-1);if(!s||!s.end)return l;r=!0;let c=s.start.from==l.head?s.end.to:s.end.from;return n?d.range(l.anchor,c):d.cursor(c)});if(!r)return!1;return t(C(e,o)),!0}var Wn=({state:e,dispatch:t})=>wn(e,t,!1);function k(e,t,n){let r=O(e.state.selection,(o)=>{if(o.undirectional&&o.head>=o.anchor!=t)o=d.range(o.head,o.anchor);let l=n(o);return d.range(o.anchor,l.head,l.goalColumn,l.bidiLevel||void 0,l.assoc)});if(r.eq(e.state.selection))return!1;return e.dispatch(C(e.state,r)),!0}function pt(e,t){return k(e,t,(n)=>e.moveByChar(n,t))}var gt=(e)=>pt(e,!g(e)),yt=(e)=>pt(e,g(e));function kt(e,t){return k(e,t,(n)=>e.moveByGroup(n,t))}var Rn=(e)=>kt(e,!g(e)),On=(e)=>kt(e,g(e));var Fn=(e)=>{let t=!g(e);return k(e,t,(n)=>Z(e.state,n,t))},Pn=(e)=>{let t=g(e);return k(e,t,(n)=>Z(e.state,n,t))};function vt(e,t){return k(e,t,(n)=>e.moveVertically(n,t))}var bt=(e)=>vt(e,!1),Ct=(e)=>vt(e,!0);function Mt(e,t){return k(e,t,(n)=>e.moveVertically(n,t,ft(e).height))}var Ue=(e)=>Mt(e,!1),ze=(e)=>Mt(e,!0),Nn=(e)=>k(e,!0,(t)=>D(e,t,!0)),qn=(e)=>k(e,!1,(t)=>D(e,t,!1)),Vn=(e)=>{let t=!g(e);return k(e,t,(n)=>D(e,n,t))},Gn=(e)=>{let t=g(e);return k(e,t,(n)=>D(e,n,t))},Un=(e)=>k(e,!1,(t)=>d.cursor(e.lineBlockAt(t.head).from)),_n=(e)=>k(e,!0,(t)=>d.cursor(e.lineBlockAt(t.head).to)),_e=({state:e,dispatch:t})=>(t(C(e,{anchor:0})),!0),Je=({state:e,dispatch:t})=>(t(C(e,{anchor:e.doc.length})),!0),$e=({state:e,dispatch:t})=>(t(C(e,{anchor:e.selection.main.anchor,head:0})),!0),Ke=({state:e,dispatch:t})=>(t(C(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),Jn=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:"select"})),!0),$n=({state:e,dispatch:t})=>{let n=ee(e).map(({from:r,to:o})=>d.undirectionalRange(r,Math.min(o+1,e.doc.length)));return t(e.update({selection:d.create(n),userEvent:"select"})),!0},Kn=({state:e,dispatch:t})=>{let n=O(e.selection,(r)=>{let o=I(e),l=o.resolveStack(r.from,1);if(r.empty){let s=o.resolveStack(r.from,-1);if(s.node.from>=l.node.from&&s.node.to<=l.node.to)l=s}for(let s=l;s;s=s.next){let{node:c}=s;if((c.from<r.from&&c.to>=r.to||c.to>r.to&&c.from<=r.from)&&s.next)return d.undirectionalRange(c.from,c.to)}return r});if(n.eq(e.selection))return!1;return t(C(e,n)),!0};function At(e,t){let{state:n}=e,r=n.selection,o=n.selection.ranges.slice();for(let l of n.selection.ranges){let s=n.doc.lineAt(l.head);if(t?s.to<e.state.doc.length:s.from>0)for(let c=l;;){let a=e.moveVertically(c,t);if(a.head<s.from||a.head>s.to){if(!o.some((h)=>h.head==a.head))o.push(a);break}else if(a.head==c.head)break;else c=a}}if(o.length==r.ranges.length)return!1;return e.dispatch(C(n,d.create(o,o.length-1))),!0}var Hn=(e)=>At(e,!1),Qn=(e)=>At(e,!0),jn=({state:e,dispatch:t})=>{let n=e.selection,r=null;if(n.ranges.length>1)r=d.create([n.main]);else if(!n.main.empty)r=d.create([d.cursor(n.main.head)]);if(!r)return!1;return t(C(e,r)),!0};function _(e,t){if(e.state.readOnly)return!1;let n="delete.selection",{state:r}=e,o=r.changeByRange((l)=>{let{from:s,to:c}=l;if(s==c){let a=t(l);if(a<s)n="delete.backward",a=H(e,a,!1);else if(a>s)n="delete.forward",a=H(e,a,!0);s=Math.min(s,a),c=Math.max(c,a)}else s=H(e,s,!1),c=H(e,c,!0);return s==c?{range:l}:{changes:{from:s,to:c},range:d.cursor(s,s<l.head?-1:1)}});if(o.changes.empty)return!1;return e.dispatch(r.update(o,{scrollIntoView:!0,userEvent:n,effects:n=="delete.selection"?v.announce.of(r.phrase("Selection deleted")):void 0})),!0}function H(e,t,n){if(e instanceof v)for(let r of e.state.facet(v.atomicRanges).map((o)=>o(e)))r.between(t,t,(o,l)=>{if(o<t&&l>t)t=n?l:o});return t}var Lt=(e,t,n)=>_(e,(r)=>{let o=r.from,{state:l}=e,s=l.doc.lineAt(o),c,a;if(n&&!t&&o>s.from&&o<s.from+200&&!/[^ \t]/.test(c=s.text.slice(0,o-s.from))){if(c[c.length-1]=="\t")return o-1;let h=Ze(c,l.tabSize),u=h%Gt(l)||Gt(l);for(let f=0;f<u&&c[c.length-1-f]==" ";f++)o--;a=o}else if(a=be(s.text,o-s.from,t,t)+s.from,a==o&&s.number!=(t?l.doc.lines:1))a+=t?1:-1;else if(!t&&/[\ufe00-\ufe0f]/.test(s.text.slice(a-s.from,o-s.from)))a=be(s.text,a-s.from,!1,!1)+s.from;return a}),Se=(e)=>Lt(e,!1,!0);var Bt=(e)=>Lt(e,!0,!1),Dt=(e,t)=>_(e,(n)=>{let r=n.head,{state:o}=e,l=o.doc.lineAt(r),s=o.charCategorizer(r);for(let c=null;;){if(r==(t?l.to:l.from)){if(r==n.head&&l.number!=(t?o.doc.lines:1))r+=t?1:-1;break}let a=be(l.text,r-l.from,t)+l.from,h=l.text.slice(Math.min(r,a)-l.from,Math.max(r,a)-l.from),u=s(h);if(c!=null&&u!=c)break;if(h!=" "||r!=n.head)c=u;r=a}return r}),Et=(e)=>Dt(e,!1),Xn=(e)=>Dt(e,!0);var Yn=(e)=>_(e,(t)=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)});var Zn=(e)=>_(e,(t)=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),er=(e)=>_(e,(t)=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)});var tr=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange((r)=>({changes:{from:r.from,to:r.to,insert:G.of(["",""])},range:d.cursor(r.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:"input"})),!0},nr=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange((r)=>{if(!r.empty||r.from==0||r.from==e.doc.length)return{range:r};let o=r.from,l=e.doc.lineAt(o),s=o==l.from?o-1:be(l.text,o-l.from,!1)+l.from,c=o==l.to?o+1:be(l.text,o-l.from,!0)+l.from;return{changes:{from:s,to:c,insert:e.doc.slice(o,c).append(e.doc.slice(s,o))},range:d.cursor(c)}});if(n.changes.empty)return!1;return t(e.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0};function ee(e){let t=[],n=-1;for(let r of e.selection.ranges){let o=e.doc.lineAt(r.from),l=e.doc.lineAt(r.to);if(!r.empty&&r.to==l.from)l=e.doc.lineAt(r.to-1);if(n>=o.number){let s=t[t.length-1];s.to=l.to,s.ranges.push(r)}else t.push({from:o.from,to:l.to,ranges:[r]});n=l.number+1}return t}function wt(e,t,n){if(e.readOnly)return!1;let r=[],o=[];for(let l of ee(e)){if(n?l.to==e.doc.length:l.from==0)continue;let s=e.doc.lineAt(n?l.to+1:l.from-1),c=s.length+1;if(n){r.push({from:l.to,to:s.to},{from:l.from,insert:s.text+e.lineBreak});for(let a of l.ranges)o.push(d.range(Math.min(e.doc.length,a.anchor+c),Math.min(e.doc.length,a.head+c)))}else{r.push({from:s.from,to:l.from},{from:l.to,insert:e.lineBreak+s.text});for(let a of l.ranges)o.push(d.range(a.anchor-c,a.head-c))}}if(!r.length)return!1;return t(e.update({changes:r,scrollIntoView:!0,selection:d.create(o,e.selection.mainIndex),userEvent:"move.line"})),!0}var rr=({state:e,dispatch:t})=>wt(e,t,!1),or=({state:e,dispatch:t})=>wt(e,t,!0);function Wt(e,t,n){if(e.readOnly)return!1;let r=[];for(let l of ee(e))if(n)r.push({from:l.from,insert:e.doc.slice(l.from,l.to)+e.lineBreak});else r.push({from:l.to,insert:e.lineBreak+e.doc.slice(l.from,l.to)});let o=e.changes(r);return t(e.update({changes:o,selection:e.selection.map(o,n?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}var lr=({state:e,dispatch:t})=>Wt(e,t,!1),ir=({state:e,dispatch:t})=>Wt(e,t,!0),sr=(e)=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(ee(t).map(({from:o,to:l})=>{if(o>0)o--;else if(l<t.doc.length)l++;return{from:o,to:l}})),r=O(t.selection,(o)=>{let l=void 0;if(e.lineWrapping){let s=e.lineBlockAt(o.head),c=e.coordsAtPos(o.head,o.assoc||1);if(c)l=s.bottom+e.documentTop-c.bottom+e.defaultLineHeight/2}return e.moveVertically(o,!0,l)}).map(n);return e.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:"delete.line"}),!0};function cr(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=I(e).resolveInner(t),r=n.childBefore(t),o=n.childAfter(t),l;if(r&&o&&r.to<=t&&o.from>=t&&(l=r.type.prop(M.closedBy))&&l.indexOf(o.name)>-1&&e.doc.lineAt(r.to).from==e.doc.lineAt(o.from).from&&!/\S/.test(e.sliceDoc(r.to,o.from)))return{from:r.to,to:o.from};return null}var He=Rt(!1),ar=Rt(!0);function Rt(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=t.changeByRange((o)=>{let{from:l,to:s}=o,c=t.doc.lineAt(l),a=!e&&l==s&&cr(t,l);if(e)l=s=(s<=c.to?c:t.doc.lineAt(s)).to;let h=new zn(t,{simulateBreak:l,simulateDoubleBreak:!!a}),u=Dr(h,l);if(u==null)u=Ze(/^\s*/.exec(t.doc.lineAt(l).text)[0],t.tabSize);while(s<c.to&&/\s/.test(c.text[s-c.from]))s++;if(a)({from:l,to:s}=a);else if(l>c.from&&l<c.from+100&&!/\S/.test(c.text.slice(0,l)))l=c.from;let f=["",gi(t,u)];if(a)f.push(gi(t,h.lineIndent(c.from,-1)));return{changes:{from:l,to:s,insert:G.of(f)},range:d.cursor(l+1+f[1].length)}});return n(t.update(r,{scrollIntoView:!0,userEvent:"input"})),!0}}function Me(e,t){let n=-1;return e.changeByRange((r)=>{let o=[];for(let s=r.from;s<=r.to;){let c=e.doc.lineAt(s);if(c.number>n&&(r.empty||r.to>c.from))t(c,o,r),n=c.number;s=c.to+1}let l=e.changes(o);return{changes:o,range:d.range(l.mapPos(r.anchor,1),l.mapPos(r.head,1))}})}var ur=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new zn(e,{overrideIndentation:(l)=>{let s=n[l];return s==null?-1:s}}),o=Me(e,(l,s,c)=>{let a=Dr(r,l.from);if(a==null)return;if(!/\S/.test(l.text))a=0;let h=/^\s*/.exec(l.text)[0],u=gi(e,a);if(h!=u||c.from<l.from+h.length)n[l.from]=a,s.push({from:l.from,to:l.from+h.length,insert:u})});if(!o.changes.empty)t(e.update(o,{userEvent:"indent"}));return!0},te=({state:e,dispatch:t})=>{if(e.readOnly)return!1;return t(e.update(Me(e,(n,r)=>{r.push({from:n.from,insert:e.facet(rt)})}),{userEvent:"input.indent"})),!0},Ft=({state:e,dispatch:t})=>{if(e.readOnly)return!1;return t(e.update(Me(e,(n,r)=>{let o=/^\s*/.exec(n.text)[0];if(!o)return;let l=Ze(o,e.tabSize),s=0,c=gi(e,Math.max(0,l-Gt(e)));while(s<o.length&&s<c.length&&o.charCodeAt(s)==c.charCodeAt(s))s++;r.push({from:n.from+s,to:n.from+o.length,insert:c.slice(s)})}),{userEvent:"delete.dedent"})),!0},hr=(e)=>(e.setTabFocusMode(),!0);var fr=[{key:"Ctrl-b",run:it,shift:gt,preventDefault:!0},{key:"Ctrl-f",run:st,shift:yt},{key:"Ctrl-p",run:ut,shift:bt},{key:"Ctrl-n",run:ht,shift:Ct},{key:"Ctrl-a",run:En,shift:Un},{key:"Ctrl-e",run:Tn,shift:_n},{key:"Ctrl-d",run:Bt},{key:"Ctrl-h",run:Se},{key:"Ctrl-k",run:Yn},{key:"Ctrl-Alt-h",run:Et},{key:"Ctrl-o",run:tr},{key:"Ctrl-t",run:nr},{key:"Ctrl-v",run:ye}],dr=[{key:"ArrowLeft",run:it,shift:gt,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:kn,shift:Rn,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:Bn,shift:Vn,preventDefault:!0},{key:"ArrowRight",run:st,shift:yt,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:vn,shift:On,preventDefault:!0},{mac:"Cmd-ArrowRight",run:Dn,shift:Gn,preventDefault:!0},{key:"ArrowUp",run:ut,shift:bt,preventDefault:!0},{mac:"Cmd-ArrowUp",run:_e,shift:$e},{mac:"Ctrl-ArrowUp",run:Ve,shift:Ue},{key:"ArrowDown",run:ht,shift:Ct,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Je,shift:Ke},{mac:"Ctrl-ArrowDown",run:ye,shift:ze},{key:"PageUp",run:Ve,shift:Ue},{key:"PageDown",run:ye,shift:ze},{key:"Home",run:Ln,shift:qn,preventDefault:!0},{key:"Mod-Home",run:_e,shift:$e},{key:"End",run:An,shift:Nn,preventDefault:!0},{key:"Mod-End",run:Je,shift:Ke},{key:"Enter",run:He,shift:He},{key:"Mod-a",run:Jn},{key:"Backspace",run:Se,shift:Se,preventDefault:!0},{key:"Delete",run:Bt,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Et,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:Xn,preventDefault:!0},{mac:"Mod-Backspace",run:Zn,preventDefault:!0},{mac:"Mod-Delete",run:er,preventDefault:!0}].concat(fr.map((e)=>({mac:e.key,run:e.run,shift:e.shift}))),It=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:Cn,shift:Fn},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:Mn,shift:Pn},{key:"Alt-ArrowUp",run:rr},{key:"Shift-Alt-ArrowUp",run:lr},{key:"Alt-ArrowDown",run:or},{key:"Shift-Alt-ArrowDown",run:ir},{key:"Mod-Alt-ArrowUp",run:Hn},{key:"Mod-Alt-ArrowDown",run:Qn},{key:"Escape",run:jn},{key:"Mod-Enter",run:ar},{key:"Alt-l",mac:"Ctrl-l",run:$n},{key:"Mod-i",run:Kn,preventDefault:!0},{key:"Mod-[",run:Ft},{key:"Mod-]",run:te},{key:"Mod-Alt-\\",run:ur},{key:"Shift-Mod-k",run:sr},{key:"Shift-Mod-\\",run:Wn},{key:"Mod-/",run:nn},{key:"Alt-A",mac:"Ctrl-A",run:on},{key:"Ctrl-m",mac:"Shift-Alt-m",run:hr}].concat(dr),Pt={key:"Tab",run:te,shift:Ft};var Nt=typeof String.prototype.normalize=="function"?(e)=>e.normalize("NFKD"):(e)=>e;class T{constructor(e,t,n=0,r=e.length,o,l){this.test=l,this.value={from:0,to:0,precise:!1},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(n,r),this.bufferStart=n,this.normalize=o?(s)=>o(Nt(s)):Nt,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return Hi(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=Fo(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=ji(e);let r=this.normalize(t);if(r.length)for(let o=0,l=n,s=!0;;o++){let c=r.charCodeAt(o),a=this.match(c,l,s,this.bufferPos+this.bufferStart,o==r.length-1);if(a)return this.value=a,this;if(o==r.length-1)break;if(s&&o<t.length&&t.charCodeAt(o)==c)l++;else s=!1}}}match(e,t,n,r,o){let l=null;for(let s=0;s<this.matches.length;){let c=this.matches[s],a=!1;if(this.query.charCodeAt(c.index)==e)if(c.index==this.query.length-1)l={from:c.from,to:r,precise:o&&c.precise};else c.index++,a=!0;if(a)s++;else this.matches.splice(s,1)}if(this.query.charCodeAt(0)==e)if(this.query.length==1)l={from:t,to:r,precise:n&&o};else this.matches.push({from:t,index:1,precise:n});if(l&&this.test&&!this.test(l.from,l.to,this.buffer,this.bufferStart))l=null;return l}}if(typeof Symbol<"u")T.prototype[Symbol.iterator]=function(){return this};var zt={from:-1,to:-1,match:/.*/.exec(""),precise:!0},Ee="gm"+(/x/.unicode==null?"":"u");class Te{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,Ee+((n===null||n===void 0?void 0:n.ignoreCase)?"i":"")),this.test=n===null||n===void 0?void 0:n.test,this.iter=e.iter();let l=e.lineAt(r);this.curLineStart=l.from,this.matchPos=ie(e,r),this.getLine(this.curLineStart)}getLine(e){if(this.iter.next(e),this.iter.lineBreak)this.curLine="";else{if(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to)this.curLine=this.curLine.slice(0,this.to-this.curLineStart);this.iter.next()}}nextLine(){if(this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to)this.curLine="";else this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let n=this.curLineStart+t.index,r=n+t[0].length;if(this.matchPos=ie(this.text,r+(n==r?1:0)),n==this.curLineStart+this.curLine.length)this.nextLine();if((n<r||n>this.value.to)&&(!this.test||this.test(n,r,t)))return this.value={from:n,to:r,precise:!0,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}}var Ae=new WeakMap;class N{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(e,t,n){let r=Ae.get(e);if(!r||r.from>=n||r.to<=t){let s=new N(t,e.sliceString(t,n));return Ae.set(e,s),s}if(r.from==t&&r.to==n)return r;let{text:o,from:l}=r;if(l>t)o=e.sliceString(t,l)+o,l=t;if(r.to<n)o+=e.sliceString(r.to,n);return Ae.set(e,new N(l,o)),new N(t,o.slice(t-l,n-l))}}class we{constructor(e,t,n,r,o){this.text=e,this.to=o,this.done=!1,this.value=zt,this.matchPos=ie(e,r),this.re=new RegExp(t,Ee+((n===null||n===void 0?void 0:n.ignoreCase)?"i":"")),this.test=n===null||n===void 0?void 0:n.test,this.flat=N.get(e,r,this.chunkEnd(r+5000))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e)this.re.lastIndex=e+1,t=this.re.exec(this.flat.text);if(t){let n=this.flat.from+t.index,r=n+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(n,r,t)))return this.value={from:n,to:r,precise:!0,match:t},this.matchPos=ie(this.text,r+(n==r?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=N.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}if(typeof Symbol<"u")Te.prototype[Symbol.iterator]=we.prototype[Symbol.iterator]=function(){return this};function mr(e){try{return new RegExp(e,Ee),!0}catch(t){return!1}}function ie(e,t){if(t>=e.length)return t;let n=e.lineAt(t),r;while(t<n.to&&(r=n.text.charCodeAt(t-n.from))>=56320&&r<57344)t++;return t}var pr=(e)=>{let t=Ho(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}=Yo(e,{class:"cm-goto-line",label:n.phrase("Go to line"),input:{type:"text",name:"line",value:r},focus:!0,submitLabel:n.phrase("go")});return l.then((s)=>{let c=s&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(s.elements.line.value);if(!c){e.dispatch({effects:o});return}let a=n.doc.lineAt(n.selection.main.head),[,h,u,f,m]=c,B=f?+f.slice(1):0,b=u?+u:a.number;if(u&&m){let me=b/100;if(h)me=me*(h=="-"?-1:1)+a.number/n.doc.lines;b=Math.round(n.doc.lines*me)}else if(u&&h)b=b*(h=="-"?-1:1)+a.number;let Ne=n.doc.line(Math.max(1,Math.min(n.doc.lines,b))),qe=d.cursor(Ne.from+Math.max(0,Math.min(B,Ne.length)));e.dispatch({effects:[o,v.scrollIntoView(qe.from,{y:"center"})],selection:qe})}),!0},gr={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},_t=w.define({combine(e){return xt(e,gr,{highlightWordAroundCursor:(t,n)=>t||n,minSelectionLength:Math.min,maxMatches:Math.min})}});function Jt(e){let t=[vr,kr];if(e)t.push(_t.of(e));return t}var yr=z.mark({class:"cm-selectionMatch"}),xr=z.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function Vt(e,t,n,r){return(n==0||e(t.sliceDoc(n-1,n))!=ce.Word)&&(r==t.doc.length||e(t.sliceDoc(r,r+1))!=ce.Word)}function Sr(e,t,n,r){return e(t.sliceDoc(n,n+1))==ce.Word&&e(t.sliceDoc(r-1,r))==ce.Word}var kr=De.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){if(e.selectionSet||e.docChanged||e.viewportChanged)this.decorations=this.getDeco(e.view)}getDeco(e){let t=e.state.facet(_t),{state:n}=e,r=n.selection;if(r.ranges.length>1)return z.none;let o=r.main,l,s=null;if(o.empty){if(!t.highlightWordAroundCursor)return z.none;let a=n.wordAt(o.head);if(!a)return z.none;s=n.charCategorizer(o.head),l=n.sliceDoc(a.from,a.to)}else{let a=o.to-o.from;if(a<t.minSelectionLength||a>200)return z.none;if(t.wholeWords){if(l=n.sliceDoc(o.from,o.to),s=n.charCategorizer(o.head),!(Vt(s,n,o.from,o.to)&&Sr(s,n,o.from,o.to)))return z.none}else if(l=n.sliceDoc(o.from,o.to),!l)return z.none}let c=[];for(let a of e.visibleRanges){let h=new T(n.doc,l,a.from,a.to);while(!h.next().done){let{from:u,to:f}=h.value;if(!s||Vt(s,n,u,f)){if(o.empty&&u<=o.from&&f>=o.to)c.push(xr.range(u,f));else if(u>=o.to||f<=o.from)c.push(yr.range(u,f));if(c.length>t.maxMatches)return z.none}}}return z.set(c)}},{decorations:(e)=>e.decorations}),vr=v.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),br=({state:e,dispatch:t})=>{let{selection:n}=e,r=d.create(n.ranges.map((o)=>e.wordAt(o.head)||d.cursor(o.head)),n.mainIndex);if(r.eq(n))return!1;return t(e.update({selection:r})),!0};function Cr(e,t){let{main:n,ranges:r}=e.selection,o=e.wordAt(n.head),l=o&&o.from==n.from&&o.to==n.to;for(let s=!1,c=new T(e.doc,t,r[r.length-1].to);;)if(c.next(),c.done){if(s)return null;c=new T(e.doc,t,0,Math.max(0,r[r.length-1].from-1)),s=!0}else{if(s&&r.some((a)=>a.from==c.value.from))continue;if(l){let a=e.wordAt(c.value.from);if(!a||a.from!=c.value.from||a.to!=c.value.to)continue}return c.value}}var Mr=({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some((l)=>l.from===l.to))return br({state:e,dispatch:t});let r=e.sliceDoc(n[0].from,n[0].to);if(e.selection.ranges.some((l)=>e.sliceDoc(l.from,l.to)!=r))return!1;let o=Cr(e,r);if(!o)return!1;return t(e.update({selection:e.selection.addRange(d.range(o.from,o.to),!1),effects:v.scrollIntoView(o.to)})),!0},R=w.define({combine(e){return xt(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:(t)=>new Zt(t),scrollToMatch:(t)=>v.scrollIntoView(t)})}});function $t(e){return e?[R.of(e),Be]:Be}class We{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||mr(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(t,n)=>n=="n"?`
2
+ `:n=="r"?"\r":n=="t"?"\t":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new Ht(this):new Kt(this)}getCursor(e,t=0,n){let r=e.doc?e:q.create({doc:e});if(n==null)n=r.doc.length;return this.regexp?P(this,r,t,n):F(this,r,t,n)}}class Re{constructor(e){this.spec=e}}function Ar(e,t,n){return(r,o,l,s)=>{if(n&&!n(r,o,l,s))return!1;let c=r>=s&&o<=s+l.length?l.slice(r-s,o-s):t.doc.sliceString(r,o);return e(c,t,r,o)}}function F(e,t,n,r){let o;if(e.wholeWord)o=Lr(t.doc,t.charCategorizer(t.selection.main.head));if(e.test)o=Ar(e.test,t,o);return new T(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:(l)=>l.toLowerCase(),o)}function Lr(e,t){return(n,r,o,l)=>{if(l>n||l+o.length<r)l=Math.max(0,n-2),o=e.sliceString(l,Math.min(e.length,r+2));return(t(ae(o,n-l))!=ce.Word||t(ue(o,n-l))!=ce.Word)&&(t(ue(o,r-l))!=ce.Word||t(ae(o,r-l))!=ce.Word)}}class Kt extends Re{constructor(e){super(e)}nextMatch(e,t,n){let r=F(this.spec,e,n,e.doc.length).nextOverlapping();if(r.done){let o=Math.min(e.doc.length,t+this.spec.unquoted.length);r=F(this.spec,e,0,o).nextOverlapping()}return r.done||r.value.from==t&&r.value.to==n?null:r.value}prevMatchInRange(e,t,n){for(let r=n;;){let o=Math.max(t,r-1e4-this.spec.unquoted.length),l=F(this.spec,e,o,r),s=null;while(!l.nextOverlapping().done)s=l.value;if(s)return s;if(o==t)return null;r-=1e4}}prevMatch(e,t,n){let r=this.prevMatchInRange(e,0,t);if(!r)r=this.prevMatchInRange(e,Math.max(0,n-this.spec.unquoted.length),e.doc.length);return r&&(r.from!=t||r.to!=n)?r:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let n=F(this.spec,e,0,e.doc.length),r=[];while(!n.next().done){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let o=F(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));while(!o.next().done)r(o.value.from,o.value.to)}}function Br(e,t,n){return(r,o,l)=>(!n||n(r,o,l))&&e(l[0],t,r,o)}function P(e,t,n,r){let o;if(e.wholeWord)o=Er(t.charCategorizer(t.selection.main.head));if(e.test)o=Br(e.test,t,o);return new Te(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:o},n,r)}function ae(e,t){return e.slice(be(e,t,!1),t)}function ue(e,t){return e.slice(t,be(e,t))}function 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 Re{nextMatch(e,t,n){let r=P(this.spec,e,n,e.doc.length).next();if(r.done)r=P(this.spec,e,0,t).next();return r.done?null:r.value}prevMatchInRange(e,t,n){for(let r=1;;r++){let o=Math.max(t,n-r*1e4),l=P(this.spec,e,o,n),s=null;while(!l.next().done)s=l.value;if(s&&(o==t||s.from>o+10))return s;if(o==t)return null}}prevMatch(e,t,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,n)=>{if(n=="&")return e.match[0];if(n=="$")return"$";for(let r=n.length;r>0;r--){let o=+n.slice(0,r);if(o>0&&o<e.match.length)return e.match[o]+n.slice(r)}return t})}matchAll(e,t){let n=P(this.spec,e,0,e.doc.length),r=[];while(!n.next().done){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let o=P(this.spec,e,Math.max(0,t-250),Math.min(n+250,e.doc.length));while(!o.next().done)r(o.value.from,o.value.to)}}var J=W.define(),Oe=W.define(),E=Xe.define({create(e){return new oe(Le(e).create(),null)},update(e,t){for(let n of t.effects)if(n.is(J))e=new oe(n.value.create(),e.panel);else if(n.is(Oe))e=new oe(e.query,n.value?Ie:null);return e},provide:(e)=>hi.from(e,(t)=>t.panel)});class oe{constructor(e,t){this.query=e,this.panel=t}}var Tr=z.mark({class:"cm-searchMatch"}),wr=z.mark({class:"cm-searchMatch cm-searchMatch-selected"}),Wr=De.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(E))}update(e){let t=e.state.field(E);if(t!=e.startState.field(E)||e.docChanged||e.selectionSet||e.viewportChanged)this.decorations=this.highlight(t)}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return z.none;let{view:n}=this,r=new St;for(let o=0,l=n.visibleRanges,s=l.length;o<s;o++){let{from:c,to:a}=l[o];while(o<s-1&&a>l[o+1].from-500)a=l[++o].to;e.highlight(n.state,c,a,(h,u)=>{let f=n.state.selection.ranges.some((m)=>m.from==h&&m.to==u);r.add(h,u,f?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=d.single(r.from,r.to),l=e.state.facet(R);return e.dispatch({selection:o,effects:[Pe(e,r),l.scrollToMatch(o.main,e)],userEvent:"select.search"}),jt(e),!0}),fe=K((e,{query:t})=>{let{state:n}=e,{from:r}=n.selection.main,o=t.prevMatch(n,r,r);if(!o)return!1;let l=d.single(o.from,o.to),s=e.state.facet(R);return e.dispatch({selection:l,effects:[Pe(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:d.create(n.map((r)=>d.range(r.from,r.to))),userEvent:"select.search.matches"}),!0}),Or=({state:e,dispatch:t})=>{let n=e.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:r,to:o}=n.main,l=[],s=0;for(let c=new T(e.doc,e.sliceDoc(r,o));!c.next().done;){if(l.length>1000)return!1;if(c.value.from==r)s=l.length;l.push(d.range(c.value.from,c.value.to))}return t(e.update({selection:d.create(l,s),userEvent:"select.search.matches"})),!0},Ut=K((e,{query:t})=>{let{state:n}=e,{from:r,to:o}=n.selection.main;if(n.readOnly)return!1;let l=t.nextMatch(n,r,r);if(!l)return!1;let s=l,c=[],a,h,u=[];if(!s.precise)s=t.nextMatch(n,s.from,s.to);else if(s.from==r&&s.to==o)h=n.toText(t.getReplacement(s)),c.push({from:s.from,to:s.to,insert:h}),s=t.nextMatch(n,s.from,s.to),u.push(v.announce.of(n.phrase("replaced match on line $",n.doc.lineAt(r).number)+"."));let f=e.state.changes(c);if(s)a=d.single(s.from,s.to).map(f),u.push(Pe(e,s)),u.push(n.facet(R).scrollToMatch(a.main,e));return e.dispatch({changes:f,selection:a,effects:u,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:c}=o;if(c)n.push({from:l,to:s,insert:t.getReplacement(o)})}if(!n.length)return!1;let r=e.state.phrase("replaced $ matches",n.length)+".";return e.dispatch({changes:n,effects:v.announce.of(r),userEvent:"input.replace.all"}),!0});function Ie(e){return e.state.facet(R).createPanel(e)}function Le(e,t){var n,r,o,l,s;let c=e.selection.main,a=c.empty||c.to>c.from+100?"":e.sliceDoc(c.from,c.to);if(t&&!a)return t;let h=e.facet(R);return new We({search:((n=t===null||t===void 0?void 0:t.literal)!==null&&n!==void 0?n:h.literal)?a:a.replace(/\n/g,"\\n"),caseSensitive:(r=t===null||t===void 0?void 0:t.caseSensitive)!==null&&r!==void 0?r:h.caseSensitive,literal:(o=t===null||t===void 0?void 0:t.literal)!==null&&o!==void 0?o:h.literal,regexp:(l=t===null||t===void 0?void 0:t.regexp)!==null&&l!==void 0?l:h.regexp,wholeWord:(s=t===null||t===void 0?void 0:t.wholeWord)!==null&&s!==void 0?s:h.wholeWord})}function Qt(e){let t=Ki(e,Ie);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=Le(e.state,t.query.spec);if(r.valid)e.dispatch({effects:J.of(r)});n.focus(),n.select()}}else e.dispatch({effects:[Oe.of(!0),t?J.of(Le(e.state,t.query.spec)):W.appendConfig.of(Be)]});return!0},Xt=(e)=>{let t=e.state.field(E,!1);if(!t||!t.panel)return!1;let n=Ki(e,Ie);if(n&&n.dom.contains(e.root.activeElement))e.focus();return e.dispatch({effects:Oe.of(!1)}),!0},Yt=[{key:"Mod-f",run:de,scope:"editor search-panel"},{key:"F3",run:he,shift:fe,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:he,shift:fe,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:Xt,scope:"editor search-panel"},{key:"Mod-Shift-l",run:Or},{key:"Mod-Alt-g",run:pr},{key:"Mod-d",run:Mr,preventDefault:!0}];class Zt{constructor(e){this.view=e;let t=this.query=e.state.field(E).query.spec;this.commit=this.commit.bind(this),this.searchField=xe("input",{value:t.search,placeholder:x(e,"Find"),"aria-label":x(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=xe("input",{value:t.replace,placeholder:x(e,"Replace"),"aria-label":x(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=xe("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=xe("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=xe("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit});function n(r,o,l){return xe("button",{class:"cm-button",name:r,onclick:o,type:"button"},l)}this.dom=xe("div",{onkeydown:(r)=>this.keydown(r),class:"cm-search"},[this.searchField,n("next",()=>he(e),[x(e,"next")]),n("prev",()=>fe(e),[x(e,"previous")]),n("select",()=>Rr(e),[x(e,"all")]),xe("label",null,[this.caseField,x(e,"match case")]),xe("label",null,[this.reField,x(e,"regexp")]),xe("label",null,[this.wordField,x(e,"by word")]),...e.state.readOnly?[]:[xe("br"),this.replaceField,n("replace",()=>Ut(e),[x(e,"replace")]),n("replaceAll",()=>Fr(e),[x(e,"replace all")])],xe("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(Go(this.view,e,"search-panel"))e.preventDefault();else if(e.keyCode==13&&e.target==this.searchField)e.preventDefault(),(e.shiftKey?fe:he)(this.view);else if(e.keyCode==13&&e.target==this.replaceField)e.preventDefault(),Ut(this.view)}update(e){for(let t of e.transactions)for(let n of t.effects)if(n.is(J)&&!n.value.eq(this.query))this.setQuery(n.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(R).top}}function x(e,t){return e.state.phrase(t)}var ne=30,re=/[\s\.,:;?!]/;function Pe(e,{from:t,to:n}){let r=e.state.doc.lineAt(t),o=e.state.doc.lineAt(n).to,l=Math.max(r.from,t-ne),s=Math.min(o,n+ne),c=e.state.sliceDoc(l,s);if(l!=r.from){for(let a=0;a<ne;a++)if(!re.test(c[a+1])&&re.test(c[a])){c=c.slice(a);break}}if(s!=o){for(let a=c.length-1;a>c.length-ne;a--)if(!re.test(c[a-1])&&re.test(c[a])){c=c.slice(0,a);break}}return v.announce.of(`${e.state.phrase("current match")}. ${c} ${e.state.phrase("on line")} ${r.number}.`)}var Ir=v.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),Be=[E,Fe.low(Wr),Ir];var Pr=v.theme({"&":{color:"var(--code-fg)",backgroundColor:"var(--code-bg)",height:"100%",fontSize:"var(--code-size, 13px)"},"&.cm-focused":{outline:"none"},".cm-scroller":{fontFamily:"var(--font-mono)",lineHeight:"1.55",overflow:"auto"},".cm-content":{caretColor:"var(--code-fg)",padding:"0.5rem 0"},".cm-line":{padding:"0 0.75rem"},".cm-cursor, .cm-dropCursor":{borderLeftColor:"var(--code-fg)"},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:"var(--code-selection)"},".cm-activeLine":{backgroundColor:"var(--code-active-line)"},".cm-gutters":{backgroundColor:"var(--code-gutter-bg)",color:"var(--code-gutter)",border:"none",borderRight:"1px solid var(--border)"},".cm-activeLineGutter":{backgroundColor:"var(--code-active-line)",color:"var(--code-fg)"},".cm-lineNumbers .cm-gutterElement":{padding:"0 0.5rem 0 0.5rem",minWidth:"2.25rem"},".cm-matchingBracket, .cm-nonmatchingBracket":{backgroundColor:"var(--code-selection)",outline:"1px solid var(--border-strong)"},".cm-searchMatch":{backgroundColor:"var(--warn-soft)",outline:"1px solid var(--warn)"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"var(--accent-soft)",outline:"1px solid var(--accent)"},".cm-panels":{backgroundColor:"var(--surface-2)",color:"var(--text)",borderColor:"var(--border)",fontFamily:"var(--font)"},".cm-panels-top":{borderBottom:"1px solid var(--border)"},".cm-panel.cm-search":{padding:"0.5rem 2rem 0.5rem 0.5rem"},".cm-panel.cm-search input, .cm-panel.cm-search button, .cm-panel.cm-search label":{fontSize:"0.875rem"},".cm-panel.cm-search input[type=text]":{backgroundColor:"var(--surface)",color:"var(--text)",border:"1px solid var(--control-border)",borderRadius:"var(--radius-sm)",padding:"0.25rem 0.5rem"},".cm-panel.cm-search button":{backgroundColor:"var(--surface-3)",color:"var(--text)",border:"1px solid var(--border-strong)",borderRadius:"var(--radius-sm)",backgroundImage:"none",padding:"0.25rem 0.625rem"},".cm-panel.cm-search [name=close]":{color:"var(--muted)"}}),Nr=In.define([{tag:[i.keyword,i.modifier,i.operatorKeyword,i.controlKeyword],color:"var(--code-keyword)"},{tag:[i.string,i.regexp,i.special(i.string),i.inserted],color:"var(--code-string)"},{tag:[i.number,i.bool,i.null,i.atom,i.literal],color:"var(--code-number)"},{tag:[i.comment,i.lineComment,i.blockComment,i.docComment],color:"var(--code-comment)",fontStyle:"italic"},{tag:[i.typeName,i.className,i.namespace,i.tagName,i.standard(i.tagName)],color:"var(--code-type)"},{tag:[i.function(i.variableName),i.function(i.propertyName),i.definition(i.variableName),i.labelName],color:"var(--code-function)"},{tag:[i.meta,i.processingInstruction,i.annotation,i.attributeName,i.propertyName,i.heading],color:"var(--code-meta)"},{tag:i.heading,fontWeight:"bold"},{tag:i.strong,fontWeight:"bold"},{tag:i.emphasis,fontStyle:"italic"},{tag:i.strikethrough,textDecoration:"line-through"},{tag:i.link,color:"var(--code-function)",textDecoration:"underline"},{tag:i.url,color:"var(--code-function)"},{tag:i.invalid,color:"var(--danger)"},{tag:i.deleted,color:"var(--danger)"}]),en=[Pr,ts(Nr)];var qr={typescript:()=>(p("84y9c0f8"),import("./chunk-lang-typescript-84y9c0f8.js")),javascript:()=>(p("yqkd14sv"),import("./chunk-lang-javascript-yqkd14sv.js")),json:()=>(p("zm1ts7s7"),import("./chunk-lang-json-zm1ts7s7.js")),markdown:()=>(p("3cv6a1mc"),import("./chunk-lang-markdown-3cv6a1mc.js")),css:()=>(p("nt7ezre4"),import("./chunk-lang-css-nt7ezre4.js")),html:()=>(p("p4yg906g"),import("./chunk-lang-html-p4yg906g.js")),python:()=>(p("ba7s8q8w"),import("./chunk-lang-python-ba7s8q8w.js")),yaml:()=>(p("deh87m32"),import("./chunk-lang-yaml-deh87m32.js")),go:()=>(p("1n73q49t"),import("./chunk-lang-go-1n73q49t.js")),rust:()=>(p("gx2hj5cw"),import("./chunk-lang-rust-gx2hj5cw.js")),sql:()=>(p("svdp20tw"),import("./chunk-lang-sql-svdp20tw.js")),xml:()=>(p("jzdsx03j"),import("./chunk-lang-xml-jzdsx03j.js")),shell:()=>(p("ec7k63jq"),import("./chunk-lang-shell-ec7k63jq.js")),toml:()=>(p("nj3sefw0"),import("./chunk-lang-toml-nj3sefw0.js")),dockerfile:()=>(p("4422dqj4"),import("./chunk-lang-dockerfile-4422dqj4.js"))};async function tn(e){if(e==="plain")return;try{return(await qr[e]()).language()}catch(t){console.warn("a language for the editor failed to load",t);return}}function Vr(e){if(typeof e.attachShadow!=="function"||typeof CSSStyleSheet>"u"||!("adoptedStyleSheets"in Document.prototype))return{parent:e,root:void 0};let t=e.shadowRoot??e.attachShadow({mode:"open"}),n=new CSSStyleSheet;return n.replaceSync(":host{display:flex;flex-direction:column;min-height:0}.cm-editor{flex:1;min-height:0}"),t.adoptedStyleSheets=[...t.adoptedStyleSheets,n],{parent:t,root:t}}async function ao(e){let t=new qt,n=new qt,r=new qt,o=await tn(e.language),l=(f)=>[q.readOnly.of(!f),v.editable.of(f)],s={editable:e.editable,wrap:e.wrap,language:o??[]},c,a=(f)=>[jo(),Wo(),Ko(),et(),Zo(),ns(),Jt(),$t({top:!0}),rt.of(" "),q.phrases.of(e.phrases),en,Tt.of([{key:"Mod-s",preventDefault:!0,run:()=>(e.onSave(),!0)},{key:"Escape",run:()=>(e.onEscape(),!0)},Pt,...Yt,...ot,...It]),q.lineSeparator.of(f),t.of(l(s.editable)),n.of(s.wrap?v.lineWrapping:[]),r.of(s.language),v.updateListener.of((m)=>{if(m.docChanged)e.onChange()})],h=Vr(e.parent),u=new v({parent:h.parent,root:h.root,state:q.create({doc:e.text,extensions:a(e.eol)})});return c=u.state.doc,{text:()=>u.state.doc.sliceString(0,void 0,u.state.lineBreak),dirty:()=>c===void 0||!u.state.doc.eq(c),snapshot:()=>u.state.doc,markSaved:(f)=>{c=f??u.state.doc},replace:(f,m)=>{let B=u.scrollDOM.scrollTop;u.setState(q.create({doc:f,extensions:a(m)})),c=u.state.doc,u.scrollDOM.scrollTop=B},setEditable:(f)=>{s.editable=f,u.dispatch({effects:t.reconfigure(l(f))})},setWrap:(f)=>{s.wrap=f,u.dispatch({effects:n.reconfigure(f?v.lineWrapping:[])})},setLanguage:async(f)=>{s.language=await tn(f)??[],u.dispatch({effects:r.reconfigure(s.language)})},undo:()=>{X(u)},redo:()=>{U(u)},find:()=>{de(u)},tab:()=>{te(u)},focus:()=>u.focus(),scrollTop:()=>u.scrollDOM.scrollTop,scrollTo:(f)=>{u.scrollDOM.scrollTop=f},destroy:()=>u.destroy()}}export{ao as createEditor};
@@ -1,4 +1,4 @@
1
- import{o,R,r,e,n,gr}from"./chunk-index-rvatmx8s.js";import{B}from"./chunk-index-fw6kawhw.js";var x=`
1
+ import{o,R,r,e,n,Or}from"./chunk-index-htdkpbrd.js";import{B}from"./chunk-index-fw6kawhw.js";var x=`
2
2
  /* A zero-height anchor just above the bar: the menu opens upward from it, over the room's messages. */
3
3
  .command-anchor {
4
4
  position: relative;
@@ -56,4 +56,4 @@ import{o,R,r,e,n,gr}from"./chunk-index-rvatmx8s.js";import{B}from"./chunk-index-
56
56
  color: var(--muted);
57
57
  font-size: var(--text-sm);
58
58
  }
59
- `;function k(s,m){let a=gr(s);if(a===void 0)return[];return m.filter((d)=>!d.hidden&&[d.name,...d.aliases??[]].some((l)=>l.startsWith(a)))}function w(s){B("command-menu",x);let m=R(),a=k(s.text,s.commands),[d,l]=r(0),[g,y]=r(),u=a.length>0&&g!==s.text,i=Math.min(d,a.length-1);o(()=>l(0),[s.text]),o(()=>{document.getElementById(`${m}-${i}`)?.scrollIntoView?.({block:"nearest"})},[m,i]);let{keys:f,area:v,onRun:h,onComplete:p}=s;if(o(()=>(f.current=(t)=>{let c=a[i];if(!u||!c||t.altKey||t.ctrlKey||t.metaKey)return!1;switch(t.key){case"ArrowDown":case"ArrowUp":l((i+(t.key==="ArrowDown"?1:a.length-1))%a.length);break;case"Enter":if(t.shiftKey)return!1;h(c);break;case"Tab":if(t.shiftKey)return!1;p(c);break;case"Escape":y(s.text);break;default:return!1}return t.preventDefault(),!0},()=>{f.current=void 0}),[f,a,i,u,h,p,s.text]),o(()=>{let t=v.current;if(!t||!u)return;return t.setAttribute("aria-controls",`${m}-list`),t.setAttribute("aria-activedescendant",`${m}-${i}`),()=>{t.removeAttribute("aria-controls"),t.removeAttribute("aria-activedescendant")}},[v,u,m,i]),!u)return null;return e("div",{className:"command-anchor",children:e("div",{className:"command-menu",id:`${m}-list`,role:"listbox",children:a.map((t,c)=>n("button",{type:"button",id:`${m}-${c}`,role:"option",tabIndex:-1,"aria-selected":c===i,className:"command-item",onPointerDown:(b)=>b.preventDefault(),onMouseDown:(b)=>b.preventDefault(),onMouseEnter:()=>l(c),onClick:()=>h(t),children:[n("span",{className:"command-name",children:["/",t.name]}),e("span",{className:"command-hint",children:t.description})]},t.name))})})}export{w as default};
59
+ `;function k(s,m){let a=Or(s);if(a===void 0)return[];return m.filter((d)=>!d.hidden&&[d.name,...d.aliases??[]].some((l)=>l.startsWith(a)))}function w(s){B("command-menu",x);let m=R(),a=k(s.text,s.commands),[d,l]=r(0),[g,y]=r(),u=a.length>0&&g!==s.text,i=Math.min(d,a.length-1);o(()=>l(0),[s.text]),o(()=>{document.getElementById(`${m}-${i}`)?.scrollIntoView?.({block:"nearest"})},[m,i]);let{keys:f,area:v,onRun:h,onComplete:p}=s;if(o(()=>(f.current=(t)=>{let c=a[i];if(!u||!c||t.altKey||t.ctrlKey||t.metaKey)return!1;switch(t.key){case"ArrowDown":case"ArrowUp":l((i+(t.key==="ArrowDown"?1:a.length-1))%a.length);break;case"Enter":if(t.shiftKey)return!1;h(c);break;case"Tab":if(t.shiftKey)return!1;p(c);break;case"Escape":y(s.text);break;default:return!1}return t.preventDefault(),!0},()=>{f.current=void 0}),[f,a,i,u,h,p,s.text]),o(()=>{let t=v.current;if(!t||!u)return;return t.setAttribute("aria-controls",`${m}-list`),t.setAttribute("aria-activedescendant",`${m}-${i}`),()=>{t.removeAttribute("aria-controls"),t.removeAttribute("aria-activedescendant")}},[v,u,m,i]),!u)return null;return e("div",{className:"command-anchor",children:e("div",{className:"command-menu",id:`${m}-list`,role:"listbox",children:a.map((t,c)=>n("button",{type:"button",id:`${m}-${c}`,role:"option",tabIndex:-1,"aria-selected":c===i,className:"command-item",onPointerDown:(b)=>b.preventDefault(),onMouseDown:(b)=>b.preventDefault(),onMouseEnter:()=>l(c),onClick:()=>h(t),children:[n("span",{className:"command-name",children:["/",t.name]}),e("span",{className:"command-hint",children:t.description})]},t.name))})})}export{w as default};
@@ -0,0 +1 @@
1
+ import{D}from"./chunk-index-kjxva289.js";import"./chunk-index-1kvnezap.js";export{D as Confirm};
@@ -1,4 +1,4 @@
1
- import{o,r,t,g,e,n,h,y,l,f,S,m,k,Q,_,oe}from"./chunk-index-rvatmx8s.js";import{D}from"./chunk-index-gae833v6.js";import{cn}from"./chunk-index-p4rc9swx.js";import{ke}from"./chunk-index-65p4hfkr.js";import{Ee}from"./chunk-index-xv3e4x0j.js";import{H}from"./chunk-index-5e8wn6r3.js";import"./chunk-index-0dyf2gdm.js";import{B}from"./chunk-index-fw6kawhw.js";var P=(a,s)=>({method:a,body:JSON.stringify(s)}),U=encodeURIComponent,L={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 j(a){let[s,i]=r(F),[d,b]=r(),[v,C]=r(!1),p=(c)=>(R)=>i((E)=>({...E,[c]:R}));return n("form",{className:"stack",onSubmit:async(c)=>{c.preventDefault(),C(!0),b(void 0);try{let{connector:R,skipped:E}=await L.add({name:s.name,url:s.url,description:s.description,...s.header.trim()?{header:s.header}:{},...s.token?{token:s.token}:{}});i(F),f(E.length?t("Added {name}. Left out tools whose names are too long: {tools}",{name:R.name,tools:E.join(", ")}):t("Added {name}.",{name:R.name})),a.onDone()}catch(R){b(l(R))}finally{C(!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:v,onClick:a.onCancel,children:t("Cancel")}),e("button",{type:"submit",disabled:v,children:t("Add connector")})]})]})}function J(a){let[s,i]=r(a.connector.description),[d,b]=r(),[v,C]=r(!1);return n("form",{className:"stack",onSubmit:async(w)=>{w.preventDefault(),C(!0),b(void 0);try{await L.describe(a.connector.name,s),f(t("Purpose updated.")),a.onDone()}catch(c){b(l(c))}finally{C(!1)}},children:[n("label",{children:[t("Purpose"),e("textarea",{value:s,maxLength:1000,rows:4,required:!0,onChange:(w)=>i(w.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:v,onClick:a.onCancel,children:t("Cancel")}),e("button",{type:"submit",disabled:v,children:t("Save")})]})]})}function G(){let{data:a,error:s,reload:i}=cn(()=>L.list()),[d,b]=r(!1),[v,C]=r(),[p,w]=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(S,{}):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(Q,{tone:"warn",children:t("Tools unreadable")}):e(Q,{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:()=>C(c),children:t("Edit purpose")}),e("button",{type:"button",className:"danger",onClick:()=>w(c),children:t("Remove")})]})]},c.name)),e(H,{open:d,title:t("Add an MCP connector"),onClose:()=>b(!1),children:d?e(j,{onCancel:()=>b(!1),onDone:()=>{b(!1),i()}}):null}),e(H,{open:v!==void 0,title:t("Edit purpose of {name}",{name:v?.name??""}),onClose:()=>C(void 0),children:v?e(J,{connector:v,onCancel:()=>C(void 0),onDone:()=>{C(void 0),i()}},v.name):null}),e(D,{open:p!==void 0,title:t("Remove connector"),confirmLabel:t("Remove"),tone:"danger",onClose:()=>w(void 0),onConfirm:async()=>{if(!p)return;await L.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 T=" new",K=(a,s)=>a.map((i)=>s.find((d)=>d.id===i)?.label??i).join(", ");function X(a){return e(H,{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 Z(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 ee(a){let{view:s}=a,[i,d]=r(),[b,v]=r(s.bundles[0]?.name??T),[C,p]=r(""),[w,c]=r(""),[R,E]=r([]),[M,N]=r(""),[A,Y]=r(""),[V,I]=r(),[O,z]=r(!1);return o(()=>{L.channels().then((u)=>{d(u),c((x)=>x||u[0]?.id||"")},(u)=>I(l(u)))},[]),n("form",{className:"stack",onSubmit:async(u)=>{u.preventDefault(),z(!0),I(void 0);try{let x=await L.authorize({bundle:b===T?C:b,channelId:w,operations:R,...M.trim()?{displayName:M}:{},...A.trim()?{description:A}:{}});f(t("Authorized the channel in {bundle}.",{bundle:x.bundle})),a.onDone(x.url?{bundle:x.bundle,url:x.url}:void 0)}catch(x){I(l(x))}finally{z(!1)}},children:[n("label",{htmlFor:"mcp-bundle",children:[t("Bundle"),n(Ee,{id:"mcp-bundle",value:b,onChange:(u)=>v(u.target.value),children:[s.bundles.map((u)=>e("option",{value:u.name,children:u.name},u.name)),e("option",{value:T,children:t("New bundle…")})]})]}),b===T?n("label",{children:[t("New bundle name"),e("input",{value:C,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&&!V?e(S,{}):e(Ee,{id:"mcp-channel",value:w,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(Z,{operations:s.operations,chosen:R,onChange:E}),n("label",{children:[t("Name outside AI clients see (optional)"),e("input",{value:M,maxLength:100,onChange:(u)=>N(u.target.value)})]}),n("label",{children:[t("Purpose (optional)"),e("textarea",{value:A,maxLength:1000,rows:2,onChange:(u)=>Y(u.target.value)})]}),V?e(m,{message:V}):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||!w||R.length===0,children:t("Authorize")})]})]})}function ne(a){let{bundle:s,grant:i}=a.target,[d,b]=r(i.displayName),[v,C]=r(i.description),[p,w]=r(),[c,R]=r(!1);return n("form",{className:"stack",onSubmit:async(M)=>{M.preventDefault(),R(!0),w(void 0);try{await L.describeGrant(s,i.channelId,{displayName:d,description:v}),f(t("Updated what outside AI clients see.")),a.onDone()}catch(N){w(l(N))}finally{R(!1)}},children:[n("label",{children:[t("Name outside AI clients see"),e("input",{value:d,maxLength:100,required:!0,onChange:(M)=>b(M.target.value)})]}),n("label",{children:[t("Purpose"),e("textarea",{value:v,maxLength:1000,rows:3,onChange:(M)=>C(M.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 te(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(Q,{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:K(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:oe(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}=cn(()=>L.grants()),[d,b]=r(!1),[v,C]=r(),[p,w]=r(),[c,R]=r(),[E,M]=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(S,{}):null,a?.bundles.length===0?e(k,{children:t("There are no authorizations yet.")}):null,a?.bundles.map((N)=>n("article",{className:"card bundle-card",children:[n("div",{className:"card-head",children:[e("strong",{children:N.name}),e("button",{type:"button",className:"secondary",onClick:()=>R(N.name),children:t("New URL")})]}),N.grants.length===0?e(k,{children:t("No channels")}):null,e("ul",{className:"grants",children:N.grants.map((A)=>e(te,{bundle:N.name,grant:A,operations:a.operations,onDescribe:()=>C({bundle:N.name,grant:A}),onRevoke:()=>w({bundle:N.name,grant:A})},A.channelId))})]},N.name)),e(H,{open:d,title:t("Authorize a channel"),onClose:()=>b(!1),children:d&&a?e(ee,{view:a,onCancel:()=>b(!1),onDone:(N)=>{if(b(!1),N)M(N);i()}}):null}),e(H,{open:v!==void 0,title:t("What outside AI clients see"),onClose:()=>C(void 0),children:v?e(ne,{target:v,onCancel:()=>C(void 0),onDone:()=>{C(void 0),i()}},`${v.bundle}/${v.grant.channelId}`):null}),e(D,{open:p!==void 0,title:t("Revoke the channel"),confirmLabel:t("Revoke"),tone:"danger",onClose:()=>w(void 0),onConfirm:async()=>{if(!p)return;await L.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:()=>R(void 0),onConfirm:async()=>{if(!c)return;let{bundle:N,url:A}=await L.rotate(c);if(A)M({bundle:N,url:A});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(X,{...E?{shown:E}:{},onClose:()=>M(void 0)})]})}var ae=`
1
+ import{o,r,t,g,e,n,h,y,c,f,S,m,k,Q,_,oe}from"./chunk-index-htdkpbrd.js";import{D}from"./chunk-index-kjxva289.js";import{cn}from"./chunk-index-0xq8m6nw.js";import{ke}from"./chunk-index-5j6m33d2.js";import{Ae}from"./chunk-index-6btfp80d.js";import{H}from"./chunk-index-evmzrr8e.js";import"./chunk-index-1kvnezap.js";import{B}from"./chunk-index-fw6kawhw.js";var P=(a,s)=>({method:a,body:JSON.stringify(s)}),U=encodeURIComponent,L={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,l)=>h(`connectors/grants/${U(a)}/${U(s)}`,P("PATCH",l)),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 j(a){let[s,l]=r(F),[d,b]=r(),[v,C]=r(!1),p=(i)=>(R)=>l((E)=>({...E,[i]:R}));return n("form",{className:"stack",onSubmit:async(i)=>{i.preventDefault(),C(!0),b(void 0);try{let{connector:R,skipped:E}=await L.add({name:s.name,url:s.url,description:s.description,...s.header.trim()?{header:s.header}:{},...s.token?{token:s.token}:{}});l(F),f(E.length?t("Added {name}. Left out tools whose names are too long: {tools}",{name:R.name,tools:E.join(", ")}):t("Added {name}.",{name:R.name})),a.onDone()}catch(R){b(c(R))}finally{C(!1)}},autoComplete:"off",children:[n("label",{children:[t("Name"),e("input",{value:s.name,maxLength:12,placeholder:"notion",required:!0,onChange:(i)=>p("name")(i.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:(i)=>p("url")(i.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:(i)=>p("description")(i.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:(i)=>p("header")(i.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:(i)=>p("token")(i.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:v,onClick:a.onCancel,children:t("Cancel")}),e("button",{type:"submit",disabled:v,children:t("Add connector")})]})]})}function J(a){let[s,l]=r(a.connector.description),[d,b]=r(),[v,C]=r(!1);return n("form",{className:"stack",onSubmit:async(w)=>{w.preventDefault(),C(!0),b(void 0);try{await L.describe(a.connector.name,s),f(t("Purpose updated.")),a.onDone()}catch(i){b(c(i))}finally{C(!1)}},children:[n("label",{children:[t("Purpose"),e("textarea",{value:s,maxLength:1000,rows:4,required:!0,onChange:(w)=>l(w.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:v,onClick:a.onCancel,children:t("Cancel")}),e("button",{type:"submit",disabled:v,children:t("Save")})]})]})}function G(){let{data:a,error:s,reload:l}=cn(()=>L.list()),[d,b]=r(!1),[v,C]=r(),[p,w]=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(S,{}):null,a?.length===0?e(k,{children:t("No connectors yet.")}):null,a?.map((i)=>n("article",{className:"card connector-card",children:[n("div",{className:"card-head",children:[e("strong",{children:i.name}),i.tools===void 0?e(Q,{tone:"warn",children:t("Tools unreadable")}):e(Q,{children:t("{count} tools",{count:i.tools})})]}),e("p",{className:"meta connector-url",children:i.displayUrl??t("(the URL cannot be parsed)")}),e("p",{children:i.description}),n("div",{className:"actions",children:[e("button",{type:"button",className:"secondary",onClick:()=>C(i),children:t("Edit purpose")}),e("button",{type:"button",className:"danger",onClick:()=>w(i),children:t("Remove")})]})]},i.name)),e(H,{open:d,title:t("Add an MCP connector"),onClose:()=>b(!1),children:d?e(j,{onCancel:()=>b(!1),onDone:()=>{b(!1),l()}}):null}),e(H,{open:v!==void 0,title:t("Edit purpose of {name}",{name:v?.name??""}),onClose:()=>C(void 0),children:v?e(J,{connector:v,onCancel:()=>C(void 0),onDone:()=>{C(void 0),l()}},v.name):null}),e(D,{open:p!==void 0,title:t("Remove connector"),confirmLabel:t("Remove"),tone:"danger",onClose:()=>w(void 0),onConfirm:async()=>{if(!p)return;await L.remove(p.name),f(t("Removed {name}.",{name:p.name})),l()},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 T=" new",K=(a,s)=>a.map((l)=>s.find((d)=>d.id===l)?.label??l).join(", ");function X(a){return e(H,{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 Z(a){return n("fieldset",{className:"field",children:[e("legend",{children:t("Allowed operations")}),e("ul",{className:"menu",children:a.operations.map((s)=>{let l=a.chosen.includes(s.id);return e("li",{children:n("label",{className:"menu-item menu-toggle",children:[e("input",{type:"checkbox",checked:l,onChange:()=>a.onChange(l?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 ee(a){let{view:s}=a,[l,d]=r(),[b,v]=r(s.bundles[0]?.name??T),[C,p]=r(""),[w,i]=r(""),[R,E]=r([]),[M,N]=r(""),[A,Y]=r(""),[V,I]=r(),[O,z]=r(!1);return o(()=>{L.channels().then((u)=>{d(u),i((x)=>x||u[0]?.id||"")},(u)=>I(c(u)))},[]),n("form",{className:"stack",onSubmit:async(u)=>{u.preventDefault(),z(!0),I(void 0);try{let x=await L.authorize({bundle:b===T?C:b,channelId:w,operations:R,...M.trim()?{displayName:M}:{},...A.trim()?{description:A}:{}});f(t("Authorized the channel in {bundle}.",{bundle:x.bundle})),a.onDone(x.url?{bundle:x.bundle,url:x.url}:void 0)}catch(x){I(c(x))}finally{z(!1)}},children:[n("label",{htmlFor:"mcp-bundle",children:[t("Bundle"),n(Ae,{id:"mcp-bundle",value:b,onChange:(u)=>v(u.target.value),children:[s.bundles.map((u)=>e("option",{value:u.name,children:u.name},u.name)),e("option",{value:T,children:t("New bundle…")})]})]}),b===T?n("label",{children:[t("New bundle name"),e("input",{value:C,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"),l===void 0&&!V?e(S,{}):e(Ae,{id:"mcp-channel",value:w,required:!0,onChange:(u)=>i(u.target.value),children:(l??[]).map((u)=>e("option",{value:u.id,children:`${u.guild} › #${u.name}`},u.id))})]}),e(Z,{operations:s.operations,chosen:R,onChange:E}),n("label",{children:[t("Name outside AI clients see (optional)"),e("input",{value:M,maxLength:100,onChange:(u)=>N(u.target.value)})]}),n("label",{children:[t("Purpose (optional)"),e("textarea",{value:A,maxLength:1000,rows:2,onChange:(u)=>Y(u.target.value)})]}),V?e(m,{message:V}):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||!w||R.length===0,children:t("Authorize")})]})]})}function ne(a){let{bundle:s,grant:l}=a.target,[d,b]=r(l.displayName),[v,C]=r(l.description),[p,w]=r(),[i,R]=r(!1);return n("form",{className:"stack",onSubmit:async(M)=>{M.preventDefault(),R(!0),w(void 0);try{await L.describeGrant(s,l.channelId,{displayName:d,description:v}),f(t("Updated what outside AI clients see.")),a.onDone()}catch(N){w(c(N))}finally{R(!1)}},children:[n("label",{children:[t("Name outside AI clients see"),e("input",{value:d,maxLength:100,required:!0,onChange:(M)=>b(M.target.value)})]}),n("label",{children:[t("Purpose"),e("textarea",{value:v,maxLength:1000,rows:3,onChange:(M)=>C(M.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:i,onClick:a.onCancel,children:t("Cancel")}),e("button",{type:"submit",disabled:i,children:t("Save")})]})]})}function te(a){let{grant:s}=a,{timeZone:l}=_();return n("li",{className:"grant",children:[n("div",{className:"card-head",children:[e("strong",{children:s.displayName}),s.visible?null:e(Q,{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:K(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:oe(d.at,l)})," ",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:l}=cn(()=>L.grants()),[d,b]=r(!1),[v,C]=r(),[p,w]=r(),[i,R]=r(),[E,M]=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(S,{}):null,a?.bundles.length===0?e(k,{children:t("There are no authorizations yet.")}):null,a?.bundles.map((N)=>n("article",{className:"card bundle-card",children:[n("div",{className:"card-head",children:[e("strong",{children:N.name}),e("button",{type:"button",className:"secondary",onClick:()=>R(N.name),children:t("New URL")})]}),N.grants.length===0?e(k,{children:t("No channels")}):null,e("ul",{className:"grants",children:N.grants.map((A)=>e(te,{bundle:N.name,grant:A,operations:a.operations,onDescribe:()=>C({bundle:N.name,grant:A}),onRevoke:()=>w({bundle:N.name,grant:A})},A.channelId))})]},N.name)),e(H,{open:d,title:t("Authorize a channel"),onClose:()=>b(!1),children:d&&a?e(ee,{view:a,onCancel:()=>b(!1),onDone:(N)=>{if(b(!1),N)M(N);l()}}):null}),e(H,{open:v!==void 0,title:t("What outside AI clients see"),onClose:()=>C(void 0),children:v?e(ne,{target:v,onCancel:()=>C(void 0),onDone:()=>{C(void 0),l()}},`${v.bundle}/${v.grant.channelId}`):null}),e(D,{open:p!==void 0,title:t("Revoke the channel"),confirmLabel:t("Revoke"),tone:"danger",onClose:()=>w(void 0),onConfirm:async()=>{if(!p)return;await L.revoke(p.bundle,p.grant.channelId),f(t("Revoked.")),l()},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:i!==void 0,title:t("Replace the MCP URL"),confirmLabel:t("Replace URL"),tone:"danger",onClose:()=>R(void 0),onConfirm:async()=>{if(!i)return;let{bundle:N,url:A}=await L.rotate(i);if(A)M({bundle:N,url:A});l()},children:e("p",{children:t("Replace the URL of bundle {bundle}? The old URL stops working at once; every channel setting stays.",{bundle:i??""})})}),e(X,{...E?{shown:E}:{},onClose:()=>M(void 0)})]})}var ae=`
2
2
  /* The Connectors page's management: an address never breaks the layout, a bundle's channels sit as rows. */
3
3
  .connector-url,
4
4
  .connectors-page .grant .meta {
@@ -34,4 +34,4 @@ import{o,r,t,g,e,n,h,y,l,f,S,m,k,Q,_,oe}from"./chunk-index-rvatmx8s.js";import{D
34
34
  .mcp-url {
35
35
  font-family: var(--font-mono);
36
36
  }
37
- `,W=()=>B("connectors",ae);function _e(){W();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(se,{}):null]})}function se(){let{data:a,error:s}=ke(()=>y.connectors(),"connectors");return n("section",{className:"stack",children:[s?e(m,{message:s}):null,!a&&!s?e(S,{}):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(Q,{children:i.enabled?t("Enabled"):t("Disabled")}),e(Q,{tone:i.reachable?"plain":"warn",children:i.reachable?t("Reachable"):t("Unreachable")}),e(Q,{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(Q,{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};
37
+ `,W=()=>B("connectors",ae);function _e(){W();let{connectorAdminUrl:a,connectorParts:s}=_(),l=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.")}),l.manage?e(G,{}):null,l.grants?e(q,{}):null,l.gateways?e(se,{}):null]})}function se(){let{data:a,error:s}=ke(()=>y.connectors(),"connectors");return n("section",{className:"stack",children:[s?e(m,{message:s}):null,!a&&!s?e(S,{}):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((l)=>e("article",{className:"card",children:n("div",{className:"card-head",children:[e("strong",{children:l.name}),e(Q,{children:l.enabled?t("Enabled"):t("Disabled")}),e(Q,{tone:l.reachable?"plain":"warn",children:l.reachable?t("Reachable"):t("Unreachable")}),e(Q,{children:t("{count} tools",{count:l.tools})})]})},l.name)),e("h3",{children:t("Virtual servers")}),a.servers.length===0?e(k,{children:t("No virtual servers.")}):null,a.servers.map((l)=>n("article",{className:"card",children:[n("div",{className:"card-head",children:[e("strong",{children:l.name}),e(Q,{children:t("{count} tools",{count:l.tools.length})})]}),n("p",{children:[t("Used by"),": ",l.usedBy.join(", ")||t("None")]}),n("details",{children:[e("summary",{children:t("Tool list")}),e("ul",{children:l.tools.map((d)=>e("li",{children:d},d))})]})]},l.name))]}):null]})}export{_e as ConnectorsPage};
@@ -1 +1 @@
1
- import{t,c,g,e,n,x,y,S,m,k,Q,_,Te,oe,Pe,wn,Di,te}from"./chunk-index-rvatmx8s.js";import{ke}from"./chunk-index-65p4hfkr.js";var u=[{kind:"owner",title:c("Owner channels"),note:c("Direct messages and channels where the owner talks to a knight.")},{kind:"agent",title:c("Bot server channels"),note:c("The bot server's one-to-one channels.")},{kind:"group",title:c("Group channels"),note:c("The bot server's group channels.")},{kind:"outside",title:c("Outside AI clients"),note:c("Conversations an outside AI client holds over MCP.")},{kind:"plugin",title:c("Plugin conversations"),note:c("Conversations a plugin runs, such as a web chat, as the host recorded them.")}];function T(){let{timeZone:o}=_(),{now:i}=te(),{data:a,error:s}=ke(()=>y.conversations(),"conversations"),d=a?.conversations;if(!d)return s?e(m,{message:s}):e(S,{});return n(g,{children:[s?e(m,{message:s}):null,u.map((r)=>{let h=d.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)}),h.length===0?e(k,{children:t("None stored.")}):null,h.map((l)=>e(v,{item:l,now:i,timeZone:o},l.key))]},r.kind)})]})}function v(o){let{item:i}=o,a=wn(i.channel,i.id),s=Di(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(Q,{tone:"busy",children:t("running")}):null,i.liveBytes===0?e(Q,{children:t("archived only")}):null]}),n("p",{className:"meta",children:[(i.kind==="outside"||i.kind==="plugin")&&i.startedAt?`${t("Started")} ${oe(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")," ",Te(i.lastActive,o.now,o.timeZone)," ·"," ",Pe(i.liveBytes)," ·"," ",t("{count} archived",{count:i.archives})]})]})}export{T as ConversationsPage};
1
+ import{t,u,g,e,n,x,y,S,m,k,Q,_,Te,oe,Pe,wn,Ui,te}from"./chunk-index-htdkpbrd.js";import{ke}from"./chunk-index-5j6m33d2.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 T(){let{timeZone:o}=_(),{now:i}=te(),{data:a,error:s}=ke(()=>y.conversations(),"conversations"),c=a?.conversations;if(!c)return s?e(m,{message:s}):e(S,{});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(v,{item:l,now:i,timeZone:o},l.key))]},r.kind)})]})}function v(o){let{item:i}=o,a=wn(i.channel,i.id),s=Ui(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(Q,{tone:"busy",children:t("running")}):null,i.liveBytes===0?e(Q,{children:t("archived only")}):null]}),n("p",{className:"meta",children:[(i.kind==="outside"||i.kind==="plugin")&&i.startedAt?`${t("Started")} ${oe(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")," ",Te(i.lastActive,o.now,o.timeZone)," ·"," ",Pe(i.liveBytes)," ·"," ",t("{count} archived",{count:i.archives})]})]})}export{T as ConversationsPage};