@aquera/nile-elements 2.0.0 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -0
- package/demo/nxtgen-dark.css +2 -2
- package/dist/{index-ccff99d6.esm.js → index-0fe57384.esm.js} +1 -1
- package/dist/index-f6944844.cjs.js +2 -0
- package/dist/{index-e43755f5.cjs.js.map → index-f6944844.cjs.js.map} +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1127 -741
- package/dist/nile-code-editor/extensionSetup.cjs.js +1 -1
- package/dist/nile-code-editor/extensionSetup.esm.js +1 -1
- package/dist/nile-code-editor/index.cjs.js +1 -1
- package/dist/nile-code-editor/index.esm.js +1 -1
- package/dist/nile-code-editor/nile-code-editor.cjs.js +2 -2
- package/dist/nile-code-editor/nile-code-editor.cjs.js.map +1 -1
- package/dist/nile-code-editor/nile-code-editor.css.cjs.js +1 -1
- package/dist/nile-code-editor/nile-code-editor.css.cjs.js.map +1 -1
- package/dist/nile-code-editor/nile-code-editor.css.esm.js +2 -2
- package/dist/nile-code-editor/nile-code-editor.esm.js +4 -4
- package/dist/nile-code-editor/theme.cjs.js +1 -1
- package/dist/nile-code-editor/theme.cjs.js.map +1 -1
- package/dist/nile-code-editor/theme.esm.js +1 -1
- package/dist/nile-combobox/nile-combobox.css.cjs.js +1 -1
- package/dist/nile-combobox/nile-combobox.css.cjs.js.map +1 -1
- package/dist/nile-combobox/nile-combobox.css.esm.js +1 -1
- package/dist/nile-detail/nile-detail.css.cjs.js +1 -1
- package/dist/nile-detail/nile-detail.css.cjs.js.map +1 -1
- package/dist/nile-detail/nile-detail.css.esm.js +1 -1
- package/dist/nile-side-bar-footer/nile-side-bar-footer.css.cjs.js +1 -1
- package/dist/nile-side-bar-footer/nile-side-bar-footer.css.cjs.js.map +1 -1
- package/dist/nile-side-bar-footer/nile-side-bar-footer.css.esm.js +3 -3
- package/dist/nile-side-bar-footer-item/nile-side-bar-footer-item.css.cjs.js +1 -1
- package/dist/nile-side-bar-footer-item/nile-side-bar-footer-item.css.cjs.js.map +1 -1
- package/dist/nile-side-bar-footer-item/nile-side-bar-footer-item.css.esm.js +13 -7
- package/dist/nile-timestamp-builder/index.cjs.js +2 -0
- package/dist/nile-timestamp-builder/index.cjs.js.map +1 -0
- package/dist/nile-timestamp-builder/index.esm.js +1 -0
- package/dist/nile-timestamp-builder/nile-timestamp-builder-utils.cjs.js +2 -0
- package/dist/nile-timestamp-builder/nile-timestamp-builder-utils.cjs.js.map +1 -0
- package/dist/nile-timestamp-builder/nile-timestamp-builder-utils.esm.js +1 -0
- package/dist/nile-timestamp-builder/nile-timestamp-builder.cjs.js +2 -0
- package/dist/nile-timestamp-builder/nile-timestamp-builder.cjs.js.map +1 -0
- package/dist/nile-timestamp-builder/nile-timestamp-builder.css.cjs.js +2 -0
- package/dist/nile-timestamp-builder/nile-timestamp-builder.css.cjs.js.map +1 -0
- package/dist/nile-timestamp-builder/nile-timestamp-builder.css.esm.js +195 -0
- package/dist/nile-timestamp-builder/nile-timestamp-builder.esm.js +154 -0
- package/dist/nile-timestamp-builder/timezones.cjs.js +2 -0
- package/dist/nile-timestamp-builder/timezones.cjs.js.map +1 -0
- package/dist/nile-timestamp-builder/timezones.esm.js +1 -0
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-editor.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-editor.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-editor.css.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-editor.css.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-editor.css.esm.js +91 -58
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-editor.esm.js +1 -1
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar.css.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar.css.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar.css.esm.js +19 -19
- package/dist/nile-wysiwyg-editor/ui/bookmark-panel.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/ui/bookmark-panel.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/ui/bookmark-panel.esm.js +14 -14
- package/dist/nile-wysiwyg-editor/ui/bubble-menu.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/ui/bubble-menu.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/ui/bubble-menu.esm.js +13 -13
- package/dist/nile-wysiwyg-editor/ui/code-block-menu.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/ui/code-block-menu.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/ui/code-block-menu.esm.js +12 -12
- package/dist/nile-wysiwyg-editor/ui/embed-menu.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/ui/embed-menu.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/ui/embed-menu.esm.js +10 -10
- package/dist/nile-wysiwyg-editor/ui/embed-panel.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/ui/embed-panel.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/ui/embed-panel.esm.js +4 -4
- package/dist/nile-wysiwyg-editor/ui/emoji-picker.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/ui/emoji-picker.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/ui/emoji-picker.esm.js +11 -11
- package/dist/nile-wysiwyg-editor/ui/find-replace.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/ui/find-replace.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/ui/find-replace.esm.js +9 -9
- package/dist/nile-wysiwyg-editor/ui/image-menu.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/ui/image-menu.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/ui/image-menu.esm.js +11 -11
- package/dist/nile-wysiwyg-editor/ui/image-panel.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/ui/image-panel.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/ui/image-panel.esm.js +6 -6
- package/dist/nile-wysiwyg-editor/ui/insert-menu.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/ui/insert-menu.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/ui/insert-menu.esm.js +14 -14
- package/dist/nile-wysiwyg-editor/ui/link-editor.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/ui/link-editor.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/ui/link-editor.esm.js +16 -16
- package/dist/nile-wysiwyg-editor/ui/markdown-panel.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/ui/markdown-panel.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/ui/markdown-panel.esm.js +8 -8
- package/dist/nile-wysiwyg-editor/ui/math-panel.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/ui/math-panel.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/ui/math-panel.esm.js +4 -4
- package/dist/nile-wysiwyg-editor/ui/shortcut-help.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/ui/shortcut-help.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/ui/shortcut-help.esm.js +16 -16
- package/dist/nile-wysiwyg-editor/ui/source-view.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/ui/source-view.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/ui/source-view.esm.js +29 -29
- package/dist/nile-wysiwyg-editor/ui/special-chars.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/ui/special-chars.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/ui/special-chars.esm.js +8 -8
- package/dist/nile-wysiwyg-editor/ui/suggest-list.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/ui/suggest-list.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/ui/suggest-list.esm.js +9 -9
- package/dist/nile-wysiwyg-editor/ui/table-grid-picker.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/ui/table-grid-picker.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/ui/table-grid-picker.esm.js +23 -23
- package/dist/nile-wysiwyg-editor/ui/table-menu.cjs.js +1 -1
- package/dist/nile-wysiwyg-editor/ui/table-menu.cjs.js.map +1 -1
- package/dist/nile-wysiwyg-editor/ui/table-menu.esm.js +7 -7
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +1 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/nile-code-editor/nile-code-editor.css.js +2 -2
- package/dist/src/nile-code-editor/nile-code-editor.css.js.map +1 -1
- package/dist/src/nile-code-editor/nile-code-editor.d.ts +15 -0
- package/dist/src/nile-code-editor/nile-code-editor.js +65 -6
- package/dist/src/nile-code-editor/nile-code-editor.js.map +1 -1
- package/dist/src/nile-code-editor/theme.d.ts +6 -117
- package/dist/src/nile-code-editor/theme.js +100 -147
- package/dist/src/nile-code-editor/theme.js.map +1 -1
- package/dist/src/nile-combobox/nile-combobox.css.js +1 -1
- package/dist/src/nile-combobox/nile-combobox.css.js.map +1 -1
- package/dist/src/nile-detail/nile-detail.css.js +1 -1
- package/dist/src/nile-detail/nile-detail.css.js.map +1 -1
- package/dist/src/nile-side-bar-footer/nile-side-bar-footer.css.js +3 -3
- package/dist/src/nile-side-bar-footer/nile-side-bar-footer.css.js.map +1 -1
- package/dist/src/nile-side-bar-footer-item/nile-side-bar-footer-item.css.js +11 -5
- package/dist/src/nile-side-bar-footer-item/nile-side-bar-footer-item.css.js.map +1 -1
- package/dist/src/nile-timestamp-builder/index.d.ts +1 -0
- package/dist/src/nile-timestamp-builder/index.js +2 -0
- package/dist/src/nile-timestamp-builder/index.js.map +1 -0
- package/dist/src/nile-timestamp-builder/nile-timestamp-builder-utils.d.ts +54 -0
- package/dist/src/nile-timestamp-builder/nile-timestamp-builder-utils.js +254 -0
- package/dist/src/nile-timestamp-builder/nile-timestamp-builder-utils.js.map +1 -0
- package/dist/src/nile-timestamp-builder/nile-timestamp-builder.css.d.ts +7 -0
- package/dist/src/nile-timestamp-builder/nile-timestamp-builder.css.js +203 -0
- package/dist/src/nile-timestamp-builder/nile-timestamp-builder.css.js.map +1 -0
- package/dist/src/nile-timestamp-builder/nile-timestamp-builder.d.ts +94 -0
- package/dist/src/nile-timestamp-builder/nile-timestamp-builder.js +578 -0
- package/dist/src/nile-timestamp-builder/nile-timestamp-builder.js.map +1 -0
- package/dist/src/nile-timestamp-builder/nile-timestamp-builder.test.d.ts +1 -0
- package/dist/src/nile-timestamp-builder/nile-timestamp-builder.test.js +890 -0
- package/dist/src/nile-timestamp-builder/nile-timestamp-builder.test.js.map +1 -0
- package/dist/src/nile-timestamp-builder/timezones.d.ts +8 -0
- package/dist/src/nile-timestamp-builder/timezones.js +357 -0
- package/dist/src/nile-timestamp-builder/timezones.js.map +1 -0
- package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-editor.css.js +91 -58
- package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-editor.css.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-editor.d.ts +2 -1
- package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-editor.js +23 -1
- package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-editor.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar.css.js +19 -19
- package/dist/src/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar.css.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/ui/bookmark-panel.js +10 -10
- package/dist/src/nile-wysiwyg-editor/ui/bookmark-panel.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/ui/bubble-menu.js +7 -7
- package/dist/src/nile-wysiwyg-editor/ui/bubble-menu.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/ui/code-block-menu.js +5 -5
- package/dist/src/nile-wysiwyg-editor/ui/code-block-menu.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/ui/embed-menu.js +6 -6
- package/dist/src/nile-wysiwyg-editor/ui/embed-menu.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/ui/embed-panel.js +4 -4
- package/dist/src/nile-wysiwyg-editor/ui/embed-panel.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/ui/emoji-picker.js +6 -6
- package/dist/src/nile-wysiwyg-editor/ui/emoji-picker.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/ui/find-replace.js +7 -7
- package/dist/src/nile-wysiwyg-editor/ui/find-replace.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/ui/image-menu.js +6 -6
- package/dist/src/nile-wysiwyg-editor/ui/image-menu.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/ui/image-panel.js +6 -6
- package/dist/src/nile-wysiwyg-editor/ui/image-panel.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/ui/insert-menu.js +7 -7
- package/dist/src/nile-wysiwyg-editor/ui/insert-menu.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/ui/link-editor.js +9 -9
- package/dist/src/nile-wysiwyg-editor/ui/link-editor.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/ui/markdown-panel.js +8 -8
- package/dist/src/nile-wysiwyg-editor/ui/markdown-panel.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/ui/math-panel.js +4 -4
- package/dist/src/nile-wysiwyg-editor/ui/math-panel.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/ui/shortcut-help.js +9 -9
- package/dist/src/nile-wysiwyg-editor/ui/shortcut-help.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/ui/source-view.js +24 -24
- package/dist/src/nile-wysiwyg-editor/ui/source-view.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/ui/special-chars.js +4 -4
- package/dist/src/nile-wysiwyg-editor/ui/special-chars.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/ui/suggest-list.js +7 -7
- package/dist/src/nile-wysiwyg-editor/ui/suggest-list.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/ui/table-grid-picker.js +16 -16
- package/dist/src/nile-wysiwyg-editor/ui/table-grid-picker.js.map +1 -1
- package/dist/src/nile-wysiwyg-editor/ui/table-menu.js +4 -4
- package/dist/src/nile-wysiwyg-editor/ui/table-menu.js.map +1 -1
- package/dist/src/version.js +2 -2
- package/dist/src/version.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/index.ts +1 -0
- package/src/nile-code-editor/nile-code-editor.css.ts +2 -2
- package/src/nile-code-editor/nile-code-editor.ts +68 -5
- package/src/nile-code-editor/theme.ts +129 -162
- package/src/nile-combobox/nile-combobox.css.ts +1 -1
- package/src/nile-detail/nile-detail.css.ts +1 -1
- package/src/nile-side-bar-footer/nile-side-bar-footer.css.ts +3 -3
- package/src/nile-side-bar-footer-item/nile-side-bar-footer-item.css.ts +11 -5
- package/src/nile-timestamp-builder/index.ts +1 -0
- package/src/nile-timestamp-builder/nile-timestamp-builder-utils.ts +321 -0
- package/src/nile-timestamp-builder/nile-timestamp-builder.css.ts +204 -0
- package/src/nile-timestamp-builder/nile-timestamp-builder.test.ts +1089 -0
- package/src/nile-timestamp-builder/nile-timestamp-builder.ts +625 -0
- package/src/nile-timestamp-builder/timezones.ts +356 -0
- package/src/nile-wysiwyg-editor/nile-wysiwyg-editor.css.ts +91 -58
- package/src/nile-wysiwyg-editor/nile-wysiwyg-editor.ts +21 -1
- package/src/nile-wysiwyg-editor/nile-wysiwyg-toolbar/nile-wysiwyg-toolbar.css.ts +19 -19
- package/src/nile-wysiwyg-editor/ui/bookmark-panel.ts +10 -10
- package/src/nile-wysiwyg-editor/ui/bubble-menu.ts +7 -7
- package/src/nile-wysiwyg-editor/ui/code-block-menu.ts +5 -5
- package/src/nile-wysiwyg-editor/ui/embed-menu.ts +6 -6
- package/src/nile-wysiwyg-editor/ui/embed-panel.ts +4 -4
- package/src/nile-wysiwyg-editor/ui/emoji-picker.ts +6 -6
- package/src/nile-wysiwyg-editor/ui/find-replace.ts +7 -7
- package/src/nile-wysiwyg-editor/ui/image-menu.ts +6 -6
- package/src/nile-wysiwyg-editor/ui/image-panel.ts +6 -6
- package/src/nile-wysiwyg-editor/ui/insert-menu.ts +7 -7
- package/src/nile-wysiwyg-editor/ui/link-editor.ts +9 -9
- package/src/nile-wysiwyg-editor/ui/markdown-panel.ts +8 -8
- package/src/nile-wysiwyg-editor/ui/math-panel.ts +4 -4
- package/src/nile-wysiwyg-editor/ui/shortcut-help.ts +9 -9
- package/src/nile-wysiwyg-editor/ui/source-view.ts +24 -24
- package/src/nile-wysiwyg-editor/ui/special-chars.ts +4 -4
- package/src/nile-wysiwyg-editor/ui/suggest-list.ts +7 -7
- package/src/nile-wysiwyg-editor/ui/table-grid-picker.ts +16 -16
- package/src/nile-wysiwyg-editor/ui/table-menu.ts +4 -4
- package/vscode-html-custom-data.json +94 -2
- package/dist/index-e43755f5.cjs.js +0 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
import{E as t,F as e,c as n,S as i,T as r,C as s,a as o,b as l,d as h,I as c,g as u,e as a,i as f,f as d,A as p,m,s as g,N as w,h as v,j as y,D as b,k,V as x,l as M,n as I,o as A,p as S,q as D,P as C,r as E,u as R,v as $,R as O,w as L,x as T,y as B,z as j,B as V,G as P,M as F,J as W,W as z,K as U,L as q,O as H,Q as N,U as J,X as _,Y as G,Z as K,_ as Q,$ as X,a0 as Y,a1 as Z}from"../index-ccff99d6.esm.js";import"../index-920675c4.esm.js";function tt(t,e){return({state:n,dispatch:i})=>{if(n.readOnly)return!1;let r=t(e,n);return!!r&&(i(n.update(r)),!0)}}const et=tt(lt,0),nt=tt(ot,0),it=tt(((t,e)=>ot(t,e,function(t){let e=[];for(let n of t.selection.ranges){let i=t.doc.lineAt(n.from),r=n.to<=i.to?i:t.doc.lineAt(n.to);r.from>i.from&&r.from==n.to&&(r=n.to==i.to+1?i:t.doc.lineAt(n.to-1));let s=e.length-1;s>=0&&e[s].to>i.from?e[s].to=r.to:e.push({from:i.from+/^\s*/.exec(i.text)[0].length,to:r.to})}return e}(e))),0);function rt(t,e){let n=t.languageDataAt("commentTokens",e);return n.length?n[0]:{}}const st=50;function ot(t,e,n=e.selection.ranges){let i=n.map((t=>rt(e,t.from).block));if(!i.every((t=>t)))return null;let r=n.map(((t,n)=>function(t,{open:e,close:n},i,r){let s,o,l=t.sliceDoc(i-st,i),h=t.sliceDoc(r,r+st),c=/\s*$/.exec(l)[0].length,u=/^\s*/.exec(h)[0].length,a=l.length-c;if(l.slice(a-e.length,a)==e&&h.slice(u,u+n.length)==n)return{open:{pos:i-c,margin:c&&1},close:{pos:r+u,margin:u&&1}};r-i<=2*st?s=o=t.sliceDoc(i,r):(s=t.sliceDoc(i,i+st),o=t.sliceDoc(r-st,r));let f=/^\s*/.exec(s)[0].length,d=/\s*$/.exec(o)[0].length,p=o.length-d-n.length;return s.slice(f,f+e.length)==e&&o.slice(p,p+n.length)==n?{open:{pos:i+f+e.length,margin:/\s/.test(s.charAt(f+e.length))?1:0},close:{pos:r-d-n.length,margin:/\s/.test(o.charAt(p-1))?1:0}}:null}(e,i[n],t.from,t.to)));if(2!=t&&!r.every((t=>t)))return{changes:e.changes(n.map(((t,e)=>r[e]?[]:[{from:t.from,insert:i[e].open+" "},{from:t.to,insert:" "+i[e].close}])))};if(1!=t&&r.some((t=>t))){let t=[];for(let e,n=0;n<r.length;n++)if(e=r[n]){let r=i[n],{open:s,close:o}=e;t.push({from:s.pos-r.open.length,to:s.pos+s.margin},{from:o.pos-o.margin,to:o.pos+r.close.length})}return{changes:t}}return null}function lt(t,e,n=e.selection.ranges){let i=[],r=-1;for(let{from:t,to:s}of n){let n=i.length,o=1e9,l=rt(e,t).line;if(l){for(let n=t;n<=s;){let h=e.doc.lineAt(n);if(h.from>r&&(t==s||s>h.from)){r=h.from;let t=/^\s*/.exec(h.text)[0].length,e=t==h.length,n=h.text.slice(t,t+l.length)==l?t:-1;t<h.text.length&&t<o&&(o=t),i.push({line:h,comment:n,token:l,indent:t,empty:e,single:!1})}n=h.to+1}if(o<1e9)for(let t=n;t<i.length;t++)i[t].indent<i[t].line.text.length&&(i[t].indent=o);i.length==n+1&&(i[n].single=!0)}}if(2!=t&&i.some((t=>t.comment<0&&(!t.empty||t.single)))){let t=[];for(let{line:e,token:n,indent:r,empty:s,single:o}of i)!o&&s||t.push({from:e.from+r,insert:n+" "});let n=e.changes(t);return{changes:n,selection:e.selection.map(n,1)}}if(1!=t&&i.some((t=>t.comment>=0))){let t=[];for(let{line:e,comment:n,token:r}of i)if(n>=0){let i=e.from+n,s=i+r.length;" "==e.text[s-e.from]&&s++,t.push({from:i,to:s})}return{changes:t}}return null}const ht=p.define(),ct=p.define(),ut=e.define(),at=e.define({combine:t=>n(t,{minDepth:100,newGroupDelay:500,joinToEvent:(t,e)=>e},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(t,e)=>(n,i)=>t(n,i)||e(n,i)})}),ft=i.define({create:()=>Ct.empty,update(t,e){let n=e.state.facet(at),i=e.annotation(ht);if(i){let r=vt.fromTransaction(e,i.selection),s=i.side,o=0==s?t.undone:t.done;return o=r?yt(o,o.length,n.minDepth,r):Mt(o,e.startState.selection),new Ct(0==s?i.rest:o,0==s?o:i.rest)}let s=e.annotation(ct);if("full"!=s&&"before"!=s||(t=t.isolate()),!1===e.annotation(r.addToHistory))return e.changes.empty?t:t.addMapping(e.changes.desc);let o=vt.fromTransaction(e),l=e.annotation(r.time),h=e.annotation(r.userEvent);return o?t=t.addChanges(o,l,h,n,e):e.selection&&(t=t.addSelection(e.startState.selection,l,h,n.newGroupDelay)),"full"!=s&&"after"!=s||(t=t.isolate()),t},toJSON:t=>({done:t.done.map((t=>t.toJSON())),undone:t.undone.map((t=>t.toJSON()))}),fromJSON:t=>new Ct(t.done.map(vt.fromJSON),t.undone.map(vt.fromJSON))});function dt(t,e){return function({state:n,dispatch:i}){if(!e&&n.readOnly)return!1;let r=n.field(ft,!1);if(!r)return!1;let s=r.pop(t,n,e);return!!s&&(i(s),!0)}}const pt=dt(0,!1),mt=dt(1,!1),gt=dt(0,!0),wt=dt(1,!0);class vt{constructor(t,e,n,i,r){this.changes=t,this.effects=e,this.mapped=n,this.startSelection=i,this.selectionsAfter=r}setSelAfter(t){return new vt(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){var t,e,n;return{changes:null===(t=this.changes)||void 0===t?void 0:t.toJSON(),mapped:null===(e=this.mapped)||void 0===e?void 0:e.toJSON(),startSelection:null===(n=this.startSelection)||void 0===n?void 0:n.toJSON(),selectionsAfter:this.selectionsAfter.map((t=>t.toJSON()))}}static fromJSON(t){return new vt(t.changes&&s.fromJSON(t.changes),[],t.mapped&&o.fromJSON(t.mapped),t.startSelection&&l.fromJSON(t.startSelection),t.selectionsAfter.map(l.fromJSON))}static fromTransaction(t,e){let n=kt;for(let e of t.startState.facet(ut)){let i=e(t);i.length&&(n=n.concat(i))}return!n.length&&t.changes.empty?null:new vt(t.changes.invert(t.startState.doc),n,void 0,e||t.startState.selection,kt)}static selection(t){return new vt(void 0,kt,void 0,void 0,t)}}function yt(t,e,n,i){let r=e+1>n+20?e-n-1:0,s=t.slice(r,e);return s.push(i),s}function bt(t,e){return t.length?e.length?t.concat(e):t:e}const kt=[],xt=200;function Mt(t,e){if(t.length){let n=t[t.length-1],i=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-xt));return i.length&&i[i.length-1].eq(e)?t:(i.push(e),yt(t,t.length-1,1e9,n.setSelAfter(i)))}return[vt.selection([e])]}function It(t){let e=t[t.length-1],n=t.slice();return n[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),n}function At(t,e){if(!t.length)return t;let n=t.length,i=kt;for(;n;){let r=St(t[n-1],e,i);if(r.changes&&!r.changes.empty||r.effects.length){let e=t.slice(0,n);return e[n-1]=r,e}e=r.mapped,n--,i=r.selectionsAfter}return i.length?[vt.selection(i)]:kt}function St(t,e,n){let i=bt(t.selectionsAfter.length?t.selectionsAfter.map((t=>t.map(e))):kt,n);if(!t.changes)return vt.selection(i);let r=t.changes.map(e),s=e.mapDesc(t.changes,!0),o=t.mapped?t.mapped.composeDesc(s):s;return new vt(r,h.mapEffects(t.effects,e),o,t.startSelection.map(s),i)}const Dt=/^(input\.type|delete)($|\.)/;class Ct{constructor(t,e,n=0,i=void 0){this.done=t,this.undone=e,this.prevTime=n,this.prevUserEvent=i}isolate(){return this.prevTime?new Ct(this.done,this.undone):this}addChanges(t,e,n,i,r){let s=this.done,o=s[s.length-1];return s=o&&o.changes&&!o.changes.empty&&t.changes&&(!n||Dt.test(n))&&(!o.selectionsAfter.length&&e-this.prevTime<i.newGroupDelay&&i.joinToEvent(r,function(t,e){let n=[],i=!1;return t.iterChangedRanges(((t,e)=>n.push(t,e))),e.iterChangedRanges(((t,e,r,s)=>{for(let t=0;t<n.length;){let e=n[t++],o=n[t++];s>=e&&r<=o&&(i=!0)}})),i}(o.changes,t.changes))||"input.type.compose"==n)?yt(s,s.length-1,i.minDepth,new vt(t.changes.compose(o.changes),bt(h.mapEffects(t.effects,o.changes),o.effects),o.mapped,o.startSelection,kt)):yt(s,s.length,i.minDepth,t),new Ct(s,kt,e,n)}addSelection(t,e,n,i){let r=this.done.length?this.done[this.done.length-1].selectionsAfter:kt;return r.length>0&&e-this.prevTime<i&&n==this.prevUserEvent&&n&&/^select($|\.)/.test(n)&&(s=r[r.length-1],o=t,s.ranges.length==o.ranges.length&&0===s.ranges.filter(((t,e)=>t.empty!=o.ranges[e].empty)).length)?this:new Ct(Mt(this.done,t),this.undone,e,n);var s,o}addMapping(t){return new Ct(At(this.done,t),At(this.undone,t),this.prevTime,this.prevUserEvent)}pop(t,e,n){let i=0==t?this.done:this.undone;if(0==i.length)return null;let r=i[i.length-1],s=r.selectionsAfter[0]||e.selection;if(n&&r.selectionsAfter.length)return e.update({selection:r.selectionsAfter[r.selectionsAfter.length-1],annotations:ht.of({side:t,rest:It(i),selection:s}),userEvent:0==t?"select.undo":"select.redo",scrollIntoView:!0});if(r.changes){let n=1==i.length?kt:i.slice(0,i.length-1);return r.mapped&&(n=At(n,r.mapped)),e.update({changes:r.changes,selection:r.startSelection,effects:r.effects,annotations:ht.of({side:t,rest:n,selection:s}),filter:!1,userEvent:0==t?"undo":"redo",scrollIntoView:!0})}return null}}Ct.empty=new Ct(kt,kt);const Et=[{key:"Mod-z",run:pt,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:mt,preventDefault:!0},{linux:"Ctrl-Shift-z",run:mt,preventDefault:!0},{key:"Mod-u",run:gt,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:wt,preventDefault:!0}];function Rt(t,e){return l.create(t.ranges.map(e),t.mainIndex)}function $t(t,e){return t.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function Ot({state:t,dispatch:e},n){let i=Rt(t.selection,n);return!i.eq(t.selection,!0)&&(e($t(t,i)),!0)}function Lt(t,e){return l.cursor(e?t.to:t.from)}function Tt(t,e){return Ot(t,(n=>n.empty?t.moveByChar(n,e):Lt(n,e)))}function Bt(t){return t.textDirectionAt(t.state.selection.main.head)==b.LTR}const jt=t=>Tt(t,!Bt(t)),Vt=t=>Tt(t,Bt(t));function Pt(t,e){return Ot(t,(n=>n.empty?t.moveByGroup(n,e):Lt(n,e)))}function Ft(t,e,n){if(e.type.prop(n))return!0;let i=e.to-e.from;return i&&(i>2||/[^\s,.;:]/.test(t.sliceDoc(e.from,e.to)))||e.firstChild}function Wt(t,e,n){let i,r,s=g(t).resolveInner(e.head),o=n?w.closedBy:w.openedBy;for(let i=e.head;;){let e=n?s.childAfter(i):s.childBefore(i);if(!e)break;Ft(t,e,o)?s=e:i=n?e.to:e.from}return r=s.type.prop(o)&&(i=n?m(t,s.from,1):m(t,s.to,-1))&&i.matched?n?i.end.to:i.end.from:n?s.to:s.from,l.cursor(r,n?-1:1)}function zt(t,e){return Ot(t,(n=>{if(!n.empty)return Lt(n,e);let i=t.moveVertically(n,e);return i.head!=n.head?i:t.moveToLineBoundary(n,e)}))}const Ut=t=>zt(t,!1),qt=t=>zt(t,!0);function Ht(e){let n,i=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,r=0,s=0;if(i){for(let n of e.state.facet(t.scrollMargins)){let t=n(e);(null==t?void 0:t.top)&&(r=Math.max(null==t?void 0:t.top,r)),(null==t?void 0:t.bottom)&&(s=Math.max(null==t?void 0:t.bottom,s))}n=e.scrollDOM.clientHeight-r-s}else n=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:r,marginBottom:s,selfScroll:i,height:Math.max(e.defaultLineHeight,n-5)}}function Nt(e,n){let i,r=Ht(e),{state:s}=e,o=Rt(s.selection,(t=>t.empty?e.moveVertically(t,n,r.height):Lt(t,n)));if(o.eq(s.selection))return!1;if(r.selfScroll){let n=e.coordsAtPos(s.selection.main.head),l=e.scrollDOM.getBoundingClientRect(),h=l.top+r.marginTop,c=l.bottom-r.marginBottom;n&&n.top>h&&n.bottom<c&&(i=t.scrollIntoView(o.main.head,{y:"start",yMargin:n.top-h}))}return e.dispatch($t(s,o),{effects:i}),!0}const Jt=t=>Nt(t,!1),_t=t=>Nt(t,!0);function Gt(t,e,n){let i=t.lineBlockAt(e.head),r=t.moveToLineBoundary(e,n);if(r.head==e.head&&r.head!=(n?i.to:i.from)&&(r=t.moveToLineBoundary(e,n,!1)),!n&&r.head==i.from&&i.length){let n=/^\s*/.exec(t.state.sliceDoc(i.from,Math.min(i.from+100,i.to)))[0].length;n&&e.head!=i.from+n&&(r=l.cursor(i.from+n))}return r}function Kt(t,e){let n=Rt(t.state.selection,(t=>{let n=e(t);return l.range(t.anchor,n.head,n.goalColumn,n.bidiLevel||void 0)}));return!n.eq(t.state.selection)&&(t.dispatch($t(t.state,n)),!0)}function Qt(t,e){return Kt(t,(n=>t.moveByChar(n,e)))}const Xt=t=>Qt(t,!Bt(t)),Yt=t=>Qt(t,Bt(t));function Zt(t,e){return Kt(t,(n=>t.moveByGroup(n,e)))}function te(t,e){return Kt(t,(n=>t.moveVertically(n,e)))}const ee=t=>te(t,!1),ne=t=>te(t,!0);function ie(t,e){return Kt(t,(n=>t.moveVertically(n,e,Ht(t).height)))}const re=t=>ie(t,!1),se=t=>ie(t,!0),oe=({state:t,dispatch:e})=>(e($t(t,{anchor:0})),!0),le=({state:t,dispatch:e})=>(e($t(t,{anchor:t.doc.length})),!0),he=({state:t,dispatch:e})=>(e($t(t,{anchor:t.selection.main.anchor,head:0})),!0),ce=({state:t,dispatch:e})=>(e($t(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0);function ue(e,n){if(e.state.readOnly)return!1;let i="delete.selection",{state:r}=e,s=r.changeByRange((t=>{let{from:r,to:s}=t;if(r==s){let o=n(t);o<r?(i="delete.backward",o=ae(e,o,!1)):o>r&&(i="delete.forward",o=ae(e,o,!0)),r=Math.min(r,o),s=Math.max(s,o)}else r=ae(e,r,!1),s=ae(e,s,!0);return r==s?{range:t}:{changes:{from:r,to:s},range:l.cursor(r,r<t.head?-1:1)}}));return!s.changes.empty&&(e.dispatch(r.update(s,{scrollIntoView:!0,userEvent:i,effects:"delete.selection"==i?t.announce.of(r.phrase("Selection deleted")):void 0})),!0)}function ae(e,n,i){if(e instanceof t)for(let r of e.state.facet(t.atomicRanges).map((t=>t(e))))r.between(n,n,((t,e)=>{t<n&&e>n&&(n=i?e:t)}));return n}const fe=(t,e,n)=>ue(t,(i=>{let r,s,o=i.from,{state:l}=t,h=l.doc.lineAt(o);if(n&&!e&&o>h.from&&o<h.from+200&&!/[^ \t]/.test(r=h.text.slice(0,o-h.from))){if("\t"==r[r.length-1])return o-1;let t=a(r,l.tabSize)%y(l)||y(l);for(let e=0;e<t&&" "==r[r.length-1-e];e++)o--;s=o}else s=k(h.text,o-h.from,e,e)+h.from,s==o&&h.number!=(e?l.doc.lines:1)?s+=e?1:-1:!e&&/[\ufe00-\ufe0f]/.test(h.text.slice(s-h.from,o-h.from))&&(s=k(h.text,s-h.from,!1,!1)+h.from);return s})),de=t=>fe(t,!1,!0),pe=t=>fe(t,!0,!1),me=(t,e)=>ue(t,(n=>{let i=n.head,{state:r}=t,s=r.doc.lineAt(i),o=r.charCategorizer(i);for(let t=null;;){if(i==(e?s.to:s.from)){i==n.head&&s.number!=(e?r.doc.lines:1)&&(i+=e?1:-1);break}let l=k(s.text,i-s.from,e)+s.from,h=s.text.slice(Math.min(i,l)-s.from,Math.max(i,l)-s.from),c=o(h);if(null!=t&&c!=t)break;" "==h&&i==n.head||(t=c),i=l}return i})),ge=t=>me(t,!1);function we(t){let e=[],n=-1;for(let i of t.selection.ranges){let r=t.doc.lineAt(i.from),s=t.doc.lineAt(i.to);if(i.empty||i.to!=s.from||(s=t.doc.lineAt(i.to-1)),n>=r.number){let t=e[e.length-1];t.to=s.to,t.ranges.push(i)}else e.push({from:r.from,to:s.to,ranges:[i]});n=s.number+1}return e}function ve(t,e,n){if(t.readOnly)return!1;let i=[],r=[];for(let e of we(t)){if(n?e.to==t.doc.length:0==e.from)continue;let s=t.doc.lineAt(n?e.to+1:e.from-1),o=s.length+1;if(n){i.push({from:e.to,to:s.to},{from:e.from,insert:s.text+t.lineBreak});for(let n of e.ranges)r.push(l.range(Math.min(t.doc.length,n.anchor+o),Math.min(t.doc.length,n.head+o)))}else{i.push({from:s.from,to:e.from},{from:e.to,insert:t.lineBreak+s.text});for(let t of e.ranges)r.push(l.range(t.anchor-o,t.head-o))}}return!!i.length&&(e(t.update({changes:i,scrollIntoView:!0,selection:l.create(r,t.selection.mainIndex),userEvent:"move.line"})),!0)}function ye(t,e,n){if(t.readOnly)return!1;let i=[];for(let e of we(t))n?i.push({from:e.from,insert:t.doc.slice(e.from,e.to)+t.lineBreak}):i.push({from:e.to,insert:t.lineBreak+t.doc.slice(e.from,e.to)});return e(t.update({changes:i,scrollIntoView:!0,userEvent:"input.copyline"})),!0}const be=ke(!1);function ke(t){return({state:e,dispatch:n})=>{if(e.readOnly)return!1;let i=e.changeByRange((n=>{let{from:i,to:r}=n,s=e.doc.lineAt(i),o=!t&&i==r&&function(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let n,i=g(t).resolveInner(e),r=i.childBefore(e),s=i.childAfter(e);return r&&s&&r.to<=e&&s.from>=e&&(n=r.type.prop(w.closedBy))&&n.indexOf(s.name)>-1&&t.doc.lineAt(r.to).from==t.doc.lineAt(s.from).from&&!/\S/.test(t.sliceDoc(r.to,s.from))?{from:r.to,to:s.from}:null}(e,i);t&&(i=r=(r<=s.to?s:e.doc.lineAt(r)).to);let h=new c(e,{simulateBreak:i,simulateDoubleBreak:!!o}),p=u(h,i);for(null==p&&(p=a(/^\s*/.exec(e.doc.lineAt(i).text)[0],e.tabSize));r<s.to&&/\s/.test(s.text[r-s.from]);)r++;o?({from:i,to:r}=o):i>s.from&&i<s.from+100&&!/\S/.test(s.text.slice(0,i))&&(i=s.from);let m=["",f(e,p)];return o&&m.push(f(e,h.lineIndent(s.from,-1))),{changes:{from:i,to:r,insert:d.of(m)},range:l.cursor(i+1+m[1].length)}}));return n(e.update(i,{scrollIntoView:!0,userEvent:"input"})),!0}}function xe(t,e){let n=-1;return t.changeByRange((i=>{let r=[];for(let s=i.from;s<=i.to;){let o=t.doc.lineAt(s);o.number>n&&(i.empty||i.to>o.from)&&(e(o,r,i),n=o.number),s=o.to+1}let s=t.changes(r);return{changes:r,range:l.range(s.mapPos(i.anchor,1),s.mapPos(i.head,1))}}))}const Me=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:t=>Ot(t,(e=>Wt(t.state,e,!Bt(t)))),shift:t=>Kt(t,(e=>Wt(t.state,e,!Bt(t))))},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:t=>Ot(t,(e=>Wt(t.state,e,Bt(t)))),shift:t=>Kt(t,(e=>Wt(t.state,e,Bt(t))))},{key:"Alt-ArrowUp",run:({state:t,dispatch:e})=>ve(t,e,!1)},{key:"Shift-Alt-ArrowUp",run:({state:t,dispatch:e})=>ye(t,e,!1)},{key:"Alt-ArrowDown",run:({state:t,dispatch:e})=>ve(t,e,!0)},{key:"Shift-Alt-ArrowDown",run:({state:t,dispatch:e})=>ye(t,e,!0)},{key:"Escape",run:({state:t,dispatch:e})=>{let n=t.selection,i=null;return n.ranges.length>1?i=l.create([n.main]):n.main.empty||(i=l.create([l.cursor(n.main.head)])),!!i&&(e($t(t,i)),!0)}},{key:"Mod-Enter",run:ke(!0)},{key:"Alt-l",mac:"Ctrl-l",run:({state:t,dispatch:e})=>{let n=we(t).map((({from:e,to:n})=>l.range(e,Math.min(n+1,t.doc.length))));return e(t.update({selection:l.create(n),userEvent:"select"})),!0}},{key:"Mod-i",run:({state:t,dispatch:e})=>{let n=Rt(t.selection,(e=>{let n=g(t),i=n.resolveStack(e.from,1);if(e.empty){let t=n.resolveStack(e.from,-1);t.node.from>=i.node.from&&t.node.to<=i.node.to&&(i=t)}for(let t=i;t;t=t.next){let{node:n}=t;if((n.from<e.from&&n.to>=e.to||n.to>e.to&&n.from<=e.from)&&t.next)return l.range(n.to,n.from)}return e}));return!n.eq(t.selection)&&(e($t(t,n)),!0)},preventDefault:!0},{key:"Mod-[",run:({state:t,dispatch:e})=>!t.readOnly&&(e(t.update(xe(t,((e,n)=>{let i=/^\s*/.exec(e.text)[0];if(!i)return;let r=a(i,t.tabSize),s=0,o=f(t,Math.max(0,r-y(t)));for(;s<i.length&&s<o.length&&i.charCodeAt(s)==o.charCodeAt(s);)s++;n.push({from:e.from+s,to:e.from+i.length,insert:o.slice(s)})})),{userEvent:"delete.dedent"})),!0)},{key:"Mod-]",run:({state:t,dispatch:e})=>!t.readOnly&&(e(t.update(xe(t,((e,n)=>{n.push({from:e.from,insert:t.facet(v)})})),{userEvent:"input.indent"})),!0)},{key:"Mod-Alt-\\",run:({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=Object.create(null),i=new c(t,{overrideIndentation:t=>{let e=n[t];return null==e?-1:e}}),r=xe(t,((e,r,s)=>{let o=u(i,e.from);if(null==o)return;/\S/.test(e.text)||(o=0);let l=/^\s*/.exec(e.text)[0],h=f(t,o);(l!=h||s.from<e.from+l.length)&&(n[e.from]=o,r.push({from:e.from,to:e.from+l.length,insert:h}))}));return r.changes.empty||e(t.update(r,{userEvent:"indent"})),!0}},{key:"Shift-Mod-k",run:t=>{if(t.state.readOnly)return!1;let{state:e}=t,n=e.changes(we(e).map((({from:t,to:n})=>(t>0?t--:n<e.doc.length&&n++,{from:t,to:n})))),i=Rt(e.selection,(e=>{let n;if(t.lineWrapping){let i=t.lineBlockAt(e.head),r=t.coordsAtPos(e.head,e.assoc||1);r&&(n=i.bottom+t.documentTop-r.bottom+t.defaultLineHeight/2)}return t.moveVertically(e,!0,n)})).map(n);return t.dispatch({changes:n,selection:i,scrollIntoView:!0,userEvent:"delete.line"}),!0}},{key:"Shift-Mod-\\",run:({state:t,dispatch:e})=>function(t,e,n){let i=!1,r=Rt(t.selection,(e=>{let r=m(t,e.head,-1)||m(t,e.head,1)||e.head>0&&m(t,e.head-1,1)||e.head<t.doc.length&&m(t,e.head+1,-1);if(!r||!r.end)return e;i=!0;let s=r.start.from==e.head?r.end.to:r.end.from;return n?l.range(e.anchor,s):l.cursor(s)}));return!!i&&(e($t(t,r)),!0)}(t,e,!1)},{key:"Mod-/",run:t=>{let{state:e}=t,n=e.doc.lineAt(e.selection.main.from),i=rt(t.state,n.from);return i.line?et(t):!!i.block&&it(t)}},{key:"Alt-A",run:nt},{key:"Ctrl-m",mac:"Shift-Alt-m",run:t=>(t.setTabFocusMode(),!0)}].concat([{key:"ArrowLeft",run:jt,shift:Xt,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:t=>Pt(t,!Bt(t)),shift:t=>Zt(t,!Bt(t)),preventDefault:!0},{mac:"Cmd-ArrowLeft",run:t=>Ot(t,(e=>Gt(t,e,!Bt(t)))),shift:t=>Kt(t,(e=>Gt(t,e,!Bt(t)))),preventDefault:!0},{key:"ArrowRight",run:Vt,shift:Yt,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:t=>Pt(t,Bt(t)),shift:t=>Zt(t,Bt(t)),preventDefault:!0},{mac:"Cmd-ArrowRight",run:t=>Ot(t,(e=>Gt(t,e,Bt(t)))),shift:t=>Kt(t,(e=>Gt(t,e,Bt(t)))),preventDefault:!0},{key:"ArrowUp",run:Ut,shift:ee,preventDefault:!0},{mac:"Cmd-ArrowUp",run:oe,shift:he},{mac:"Ctrl-ArrowUp",run:Jt,shift:re},{key:"ArrowDown",run:qt,shift:ne,preventDefault:!0},{mac:"Cmd-ArrowDown",run:le,shift:ce},{mac:"Ctrl-ArrowDown",run:_t,shift:se},{key:"PageUp",run:Jt,shift:re},{key:"PageDown",run:_t,shift:se},{key:"Home",run:t=>Ot(t,(e=>Gt(t,e,!1))),shift:t=>Kt(t,(e=>Gt(t,e,!1))),preventDefault:!0},{key:"Mod-Home",run:oe,shift:he},{key:"End",run:t=>Ot(t,(e=>Gt(t,e,!0))),shift:t=>Kt(t,(e=>Gt(t,e,!0))),preventDefault:!0},{key:"Mod-End",run:le,shift:ce},{key:"Enter",run:be,shift:be},{key:"Mod-a",run:({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0)},{key:"Backspace",run:de,shift:de},{key:"Delete",run:pe},{key:"Mod-Backspace",mac:"Alt-Backspace",run:ge},{key:"Mod-Delete",mac:"Alt-Delete",run:t=>me(t,!0)},{mac:"Mod-Backspace",run:t=>ue(t,(e=>{let n=t.moveToLineBoundary(e,!1).head;return e.head>n?n:Math.max(0,e.head-1)}))},{mac:"Mod-Delete",run:t=>ue(t,(e=>{let n=t.moveToLineBoundary(e,!0).head;return e.head<n?n:Math.min(t.state.doc.length,e.head+1)}))}].concat([{key:"Ctrl-b",run:jt,shift:Xt,preventDefault:!0},{key:"Ctrl-f",run:Vt,shift:Yt},{key:"Ctrl-p",run:Ut,shift:ee},{key:"Ctrl-n",run:qt,shift:ne},{key:"Ctrl-a",run:t=>Ot(t,(e=>l.cursor(t.lineBlockAt(e.head).from,1))),shift:t=>Kt(t,(e=>l.cursor(t.lineBlockAt(e.head).from)))},{key:"Ctrl-e",run:t=>Ot(t,(e=>l.cursor(t.lineBlockAt(e.head).to,-1))),shift:t=>Kt(t,(e=>l.cursor(t.lineBlockAt(e.head).to)))},{key:"Ctrl-d",run:pe},{key:"Ctrl-h",run:de},{key:"Ctrl-k",run:t=>ue(t,(e=>{let n=t.lineBlockAt(e.head).to;return e.head<n?n:Math.min(t.state.doc.length,e.head+1)}))},{key:"Ctrl-Alt-h",run:ge},{key:"Ctrl-o",run:({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=t.changeByRange((t=>({changes:{from:t.from,to:t.to,insert:d.of(["",""])},range:l.cursor(t.from)})));return e(t.update(n,{scrollIntoView:!0,userEvent:"input"})),!0}},{key:"Ctrl-t",run:({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=t.changeByRange((e=>{if(!e.empty||0==e.from||e.from==t.doc.length)return{range:e};let n=e.from,i=t.doc.lineAt(n),r=n==i.from?n-1:k(i.text,n-i.from,!1)+i.from,s=n==i.to?n+1:k(i.text,n-i.from,!0)+i.from;return{changes:{from:r,to:s,insert:t.doc.slice(n,s).append(t.doc.slice(r,n))},range:l.cursor(s)}}));return!n.changes.empty&&(e(t.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)}},{key:"Ctrl-v",run:_t}].map((t=>({mac:t.key,run:t.run,shift:t.shift})))));function Ie(){var t=arguments[0];"string"==typeof t&&(t=document.createElement(t));var e=1,n=arguments[1];if(n&&"object"==typeof n&&null==n.nodeType&&!Array.isArray(n)){for(var i in n)if(Object.prototype.hasOwnProperty.call(n,i)){var r=n[i];"string"==typeof r?t.setAttribute(i,r):null!=r&&(t[i]=r)}e++}for(;e<arguments.length;e++)Ae(t,arguments[e]);return t}function Ae(t,e){if("string"==typeof e)t.appendChild(document.createTextNode(e));else if(null==e);else if(null!=e.nodeType)t.appendChild(e);else{if(!Array.isArray(e))throw new RangeError("Unsupported child node: "+e);for(var n=0;n<e.length;n++)Ae(t,e[n])}}const Se="function"==typeof String.prototype.normalize?t=>t.normalize("NFKD"):t=>t;class De{constructor(t,e,n=0,i=t.length,r,s){this.test=s,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=t.iterRange(n,i),this.bufferStart=n,this.normalize=r?t=>r(Se(t)):Se,this.query=this.normalize(e)}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 I(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let t=this.peek();if(t<0)return this.done=!0,this;let e=E(t),n=this.bufferStart+this.bufferPos;this.bufferPos+=A(t);let i=this.normalize(e);if(i.length)for(let t=0,r=n;;t++){let s=i.charCodeAt(t),o=this.match(s,r,this.bufferPos+this.bufferStart);if(t==i.length-1){if(o)return this.value=o,this;break}r==n&&t<e.length&&e.charCodeAt(t)==s&&r++}}}match(t,e,n){let i=null;for(let e=0;e<this.matches.length;e+=2){let r=this.matches[e],s=!1;this.query.charCodeAt(r)==t&&(r==this.query.length-1?i={from:this.matches[e+1],to:n}:(this.matches[e]++,s=!0)),s||(this.matches.splice(e,2),e-=2)}return this.query.charCodeAt(0)==t&&(1==this.query.length?i={from:e,to:n}:this.matches.push(1,e)),i&&this.test&&!this.test(i.from,i.to,this.buffer,this.bufferStart)&&(i=null),i}}"undefined"!=typeof Symbol&&(De.prototype[Symbol.iterator]=function(){return this});const Ce={from:-1,to:-1,match:/.*/.exec("")},Ee="gm"+(null==/x/.unicode?"":"u");class Re{constructor(t,e,n,i=0,r=t.length){if(this.text=t,this.to=r,this.curLine="",this.done=!1,this.value=Ce,/\\[sWDnr]|\n|\r|\[\^/.test(e))return new Le(t,e,n,i,r);this.re=new RegExp(e,Ee+((null==n?void 0:n.ignoreCase)?"i":"")),this.test=null==n?void 0:n.test,this.iter=t.iter();let s=t.lineAt(i);this.curLineStart=s.from,this.matchPos=Te(t,i),this.getLine(this.curLineStart)}getLine(t){this.iter.next(t),this.iter.lineBreak?this.curLine="":(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(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let t=this.matchPos-this.curLineStart;;){this.re.lastIndex=t;let e=this.matchPos<=this.to&&this.re.exec(this.curLine);if(e){let n=this.curLineStart+e.index,i=n+e[0].length;if(this.matchPos=Te(this.text,i+(n==i?1:0)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<i||n>this.value.to)&&(!this.test||this.test(n,i,e)))return this.value={from:n,to:i,match:e},this;t=this.matchPos-this.curLineStart}else{if(!(this.curLineStart+this.curLine.length<this.to))return this.done=!0,this;this.nextLine(),t=0}}}}const $e=new WeakMap;class Oe{constructor(t,e){this.from=t,this.text=e}get to(){return this.from+this.text.length}static get(t,e,n){let i=$e.get(t);if(!i||i.from>=n||i.to<=e){let i=new Oe(e,t.sliceString(e,n));return $e.set(t,i),i}if(i.from==e&&i.to==n)return i;let{text:r,from:s}=i;return s>e&&(r=t.sliceString(e,s)+r,s=e),i.to<n&&(r+=t.sliceString(i.to,n)),$e.set(t,new Oe(s,r)),new Oe(e,r.slice(e-s,n-s))}}class Le{constructor(t,e,n,i,r){this.text=t,this.to=r,this.done=!1,this.value=Ce,this.matchPos=Te(t,i),this.re=new RegExp(e,Ee+((null==n?void 0:n.ignoreCase)?"i":"")),this.test=null==n?void 0:n.test,this.flat=Oe.get(t,i,this.chunkEnd(i+5e3))}chunkEnd(t){return t>=this.to?this.to:this.text.lineAt(t).to}next(){for(;;){let t=this.re.lastIndex=this.matchPos-this.flat.from,e=this.re.exec(this.flat.text);if(e&&!e[0]&&e.index==t&&(this.re.lastIndex=t+1,e=this.re.exec(this.flat.text)),e){let t=this.flat.from+e.index,n=t+e[0].length;if((this.flat.to>=this.to||e.index+e[0].length<=this.flat.text.length-10)&&(!this.test||this.test(t,n,e)))return this.value={from:t,to:n,match:e},this.matchPos=Te(this.text,n+(t==n?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=Oe.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+2*this.flat.text.length))}}}function Te(t,e){if(e>=t.length)return e;let n,i=t.lineAt(e);for(;e<i.to&&(n=i.text.charCodeAt(e-i.from))>=56320&&n<57344;)e++;return e}function Be(e){let n=Ie("input",{class:"cm-textfield",name:"line",value:String(e.state.doc.lineAt(e.state.selection.main.head).number)});function i(){let i=/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(n.value);if(!i)return;let{state:r}=e,s=r.doc.lineAt(r.selection.main.head),[,o,h,c,u]=i,a=c?+c.slice(1):0,f=h?+h:s.number;if(h&&u){let t=f/100;o&&(t=t*("-"==o?-1:1)+s.number/r.doc.lines),f=Math.round(r.doc.lines*t)}else h&&o&&(f=f*("-"==o?-1:1)+s.number);let d=r.doc.line(Math.max(1,Math.min(r.doc.lines,f))),p=l.cursor(d.from+Math.max(0,Math.min(a,d.length)));e.dispatch({effects:[je.of(!1),t.scrollIntoView(p.from,{y:"center"})],selection:p}),e.focus()}return{dom:Ie("form",{class:"cm-gotoLine",onkeydown:t=>{27==t.keyCode?(t.preventDefault(),e.dispatch({effects:je.of(!1)}),e.focus()):13==t.keyCode&&(t.preventDefault(),i())},onsubmit:t=>{t.preventDefault(),i()}},Ie("label",e.state.phrase("Go to line"),": ",n)," ",Ie("button",{class:"cm-button",type:"submit"},e.state.phrase("go")))}}"undefined"!=typeof Symbol&&(Re.prototype[Symbol.iterator]=Le.prototype[Symbol.iterator]=function(){return this});const je=h.define(),Ve=i.define({create:()=>!0,update(t,e){for(let n of e.effects)n.is(je)&&(t=n.value);return t},provide:t=>R.from(t,(t=>t?Be:null))}),Pe=t.baseTheme({".cm-panel.cm-gotoLine":{padding:"2px 6px 4px","& label":{fontSize:"80%"}}}),Fe={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},We=e.define({combine:t=>n(t,Fe,{highlightWordAroundCursor:(t,e)=>t||e,minSelectionLength:Math.min,maxMatches:Math.min})});const ze=M.mark({class:"cm-selectionMatch"}),Ue=M.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function qe(t,e,n,i){return!(0!=n&&t(e.sliceDoc(n-1,n))==D.Word||i!=e.doc.length&&t(e.sliceDoc(i,i+1))==D.Word)}const He=x.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.selectionSet||t.docChanged||t.viewportChanged)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=t.state.facet(We),{state:n}=t,i=n.selection;if(i.ranges.length>1)return M.none;let r,s=i.main,o=null;if(s.empty){if(!e.highlightWordAroundCursor)return M.none;let t=n.wordAt(s.head);if(!t)return M.none;o=n.charCategorizer(s.head),r=n.sliceDoc(t.from,t.to)}else{let t=s.to-s.from;if(t<e.minSelectionLength||t>200)return M.none;if(e.wholeWords){if(r=n.sliceDoc(s.from,s.to),o=n.charCategorizer(s.head),!qe(o,n,s.from,s.to)||!function(t,e,n,i){return t(e.sliceDoc(n,n+1))==D.Word&&t(e.sliceDoc(i-1,i))==D.Word}(o,n,s.from,s.to))return M.none}else if(r=n.sliceDoc(s.from,s.to),!r)return M.none}let l=[];for(let i of t.visibleRanges){let t=new De(n.doc,r,i.from,i.to);for(;!t.next().done;){let{from:i,to:r}=t.value;if((!o||qe(o,n,i,r))&&(s.empty&&i<=s.from&&r>=s.to?l.push(Ue.range(i,r)):(i>=s.to||r<=s.from)&&l.push(ze.range(i,r)),l.length>e.maxMatches))return M.none}}return M.set(l)}},{decorations:t=>t.decorations}),Ne=t.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}});const Je=e.define({combine:e=>n(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:t=>new xn(t),scrollToMatch:e=>t.scrollIntoView(e)})});class _e{constructor(t){this.search=t.search,this.caseSensitive=!!t.caseSensitive,this.literal=!!t.literal,this.regexp=!!t.regexp,this.replace=t.replace||"",this.valid=!!this.search&&(!this.regexp||function(t){try{return new RegExp(t,Ee),!0}catch(t){return!1}}(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!t.wholeWord}unquote(t){return this.literal?t:t.replace(/\\([nrt\\])/g,((t,e)=>"n"==e?"\n":"r"==e?"\r":"t"==e?"\t":"\\"))}eq(t){return this.search==t.search&&this.replace==t.replace&&this.caseSensitive==t.caseSensitive&&this.regexp==t.regexp&&this.wholeWord==t.wholeWord}create(){return this.regexp?new tn(this):new Qe(this)}getCursor(t,e=0,n){let i=t.doc?t:$.create({doc:t});return null==n&&(n=i.doc.length),this.regexp?Xe(this,i,e,n):Ke(this,i,e,n)}}class Ge{constructor(t){this.spec=t}}function Ke(t,e,n,i){return new De(e.doc,t.unquoted,n,i,t.caseSensitive?void 0:t=>t.toLowerCase(),t.wholeWord?(r=e.doc,s=e.charCategorizer(e.selection.main.head),(t,e,n,i)=>((i>t||i+n.length<e)&&(i=Math.max(0,t-2),n=r.sliceString(i,Math.min(r.length,e+2))),!(s(Ye(n,t-i))==D.Word&&s(Ze(n,t-i))==D.Word||s(Ze(n,e-i))==D.Word&&s(Ye(n,e-i))==D.Word))):void 0);var r,s}class Qe extends Ge{constructor(t){super(t)}nextMatch(t,e,n){let i=Ke(this.spec,t,n,t.doc.length).nextOverlapping();if(i.done){let n=Math.min(t.doc.length,e+this.spec.unquoted.length);i=Ke(this.spec,t,0,n).nextOverlapping()}return i.done||i.value.from==e&&i.value.to==n?null:i.value}prevMatchInRange(t,e,n){for(let i=n;;){let n=Math.max(e,i-1e4-this.spec.unquoted.length),r=Ke(this.spec,t,n,i),s=null;for(;!r.nextOverlapping().done;)s=r.value;if(s)return s;if(n==e)return null;i-=1e4}}prevMatch(t,e,n){let i=this.prevMatchInRange(t,0,e);return i||(i=this.prevMatchInRange(t,Math.max(0,n-this.spec.unquoted.length),t.doc.length)),!i||i.from==e&&i.to==n?null:i}getReplacement(t){return this.spec.unquote(this.spec.replace)}matchAll(t,e){let n=Ke(this.spec,t,0,t.doc.length),i=[];for(;!n.next().done;){if(i.length>=e)return null;i.push(n.value)}return i}highlight(t,e,n,i){let r=Ke(this.spec,t,Math.max(0,e-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,t.doc.length));for(;!r.next().done;)i(r.value.from,r.value.to)}}function Xe(t,e,n,i){return new Re(e.doc,t.search,{ignoreCase:!t.caseSensitive,test:t.wholeWord?(r=e.charCategorizer(e.selection.main.head),(t,e,n)=>!n[0].length||(r(Ye(n.input,n.index))!=D.Word||r(Ze(n.input,n.index))!=D.Word)&&(r(Ze(n.input,n.index+n[0].length))!=D.Word||r(Ye(n.input,n.index+n[0].length))!=D.Word)):void 0},n,i);var r}function Ye(t,e){return t.slice(k(t,e,!1),e)}function Ze(t,e){return t.slice(e,k(t,e))}class tn extends Ge{nextMatch(t,e,n){let i=Xe(this.spec,t,n,t.doc.length).next();return i.done&&(i=Xe(this.spec,t,0,e).next()),i.done?null:i.value}prevMatchInRange(t,e,n){for(let i=1;;i++){let r=Math.max(e,n-1e4*i),s=Xe(this.spec,t,r,n),o=null;for(;!s.next().done;)o=s.value;if(o&&(r==e||o.from>r+10))return o;if(r==e)return null}}prevMatch(t,e,n){return this.prevMatchInRange(t,0,e)||this.prevMatchInRange(t,n,t.doc.length)}getReplacement(t){return this.spec.unquote(this.spec.replace).replace(/\$([$&\d+])/g,((e,n)=>"$"==n?"$":"&"==n?t.match[0]:"0"!=n&&+n<t.match.length?t.match[n]:e))}matchAll(t,e){let n=Xe(this.spec,t,0,t.doc.length),i=[];for(;!n.next().done;){if(i.length>=e)return null;i.push(n.value)}return i}highlight(t,e,n,i){let r=Xe(this.spec,t,Math.max(0,e-250),Math.min(n+250,t.doc.length));for(;!r.next().done;)i(r.value.from,r.value.to)}}const en=h.define(),nn=h.define(),rn=i.define({create:t=>new sn(gn(t).create(),null),update(t,e){for(let n of e.effects)n.is(en)?t=new sn(n.value.create(),t.panel):n.is(nn)&&(t=new sn(t.query,n.value?mn:null));return t},provide:t=>R.from(t,(t=>t.panel))});class sn{constructor(t,e){this.query=t,this.panel=e}}const on=M.mark({class:"cm-searchMatch"}),ln=M.mark({class:"cm-searchMatch cm-searchMatch-selected"}),hn=x.fromClass(class{constructor(t){this.view=t,this.decorations=this.highlight(t.state.field(rn))}update(t){let e=t.state.field(rn);(e!=t.startState.field(rn)||t.docChanged||t.selectionSet||t.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:t,panel:e}){if(!e||!t.spec.valid)return M.none;let{view:n}=this,i=new O;for(let e=0,r=n.visibleRanges,s=r.length;e<s;e++){let{from:o,to:l}=r[e];for(;e<s-1&&l>r[e+1].from-500;)l=r[++e].to;t.highlight(n.state,o,l,((t,e)=>{let r=n.state.selection.ranges.some((n=>n.from==t&&n.to==e));i.add(t,e,r?ln:on)}))}return i.finish()}},{decorations:t=>t.decorations});function cn(t){return e=>{let n=e.state.field(rn,!1);return n&&n.query.spec.valid?t(e,n):yn(e)}}const un=cn(((t,{query:e})=>{let{to:n}=t.state.selection.main,i=e.nextMatch(t.state,n,n);if(!i)return!1;let r=l.single(i.from,i.to),s=t.state.facet(Je);return t.dispatch({selection:r,effects:[Sn(t,i),s.scrollToMatch(r.main,t)],userEvent:"select.search"}),vn(t),!0})),an=cn(((t,{query:e})=>{let{state:n}=t,{from:i}=n.selection.main,r=e.prevMatch(n,i,i);if(!r)return!1;let s=l.single(r.from,r.to),o=t.state.facet(Je);return t.dispatch({selection:s,effects:[Sn(t,r),o.scrollToMatch(s.main,t)],userEvent:"select.search"}),vn(t),!0})),fn=cn(((t,{query:e})=>{let n=e.matchAll(t.state,1e3);return!(!n||!n.length)&&(t.dispatch({selection:l.create(n.map((t=>l.range(t.from,t.to)))),userEvent:"select.search.matches"}),!0)})),dn=cn(((e,{query:n})=>{let{state:i}=e,{from:r,to:s}=i.selection.main;if(i.readOnly)return!1;let o=n.nextMatch(i,r,r);if(!o)return!1;let h,c,u=o,a=[],f=[];if(u.from==r&&u.to==s&&(c=i.toText(n.getReplacement(u)),a.push({from:u.from,to:u.to,insert:c}),u=n.nextMatch(i,u.from,u.to),f.push(t.announce.of(i.phrase("replaced match on line $",i.doc.lineAt(r).number)+"."))),u){let t=0==a.length||a[0].from>=o.to?0:o.to-o.from-c.length;h=l.single(u.from-t,u.to-t),f.push(Sn(e,u)),f.push(i.facet(Je).scrollToMatch(h.main,e))}return e.dispatch({changes:a,selection:h,effects:f,userEvent:"input.replace"}),!0})),pn=cn(((e,{query:n})=>{if(e.state.readOnly)return!1;let i=n.matchAll(e.state,1e9).map((t=>{let{from:e,to:i}=t;return{from:e,to:i,insert:n.getReplacement(t)}}));if(!i.length)return!1;let r=e.state.phrase("replaced $ matches",i.length)+".";return e.dispatch({changes:i,effects:t.announce.of(r),userEvent:"input.replace.all"}),!0}));function mn(t){return t.state.facet(Je).createPanel(t)}function gn(t,e){var n,i,r,s,o;let l=t.selection.main,h=l.empty||l.to>l.from+100?"":t.sliceDoc(l.from,l.to);if(e&&!h)return e;let c=t.facet(Je);return new _e({search:(null!==(n=null==e?void 0:e.literal)&&void 0!==n?n:c.literal)?h:h.replace(/\n/g,"\\n"),caseSensitive:null!==(i=null==e?void 0:e.caseSensitive)&&void 0!==i?i:c.caseSensitive,literal:null!==(r=null==e?void 0:e.literal)&&void 0!==r?r:c.literal,regexp:null!==(s=null==e?void 0:e.regexp)&&void 0!==s?s:c.regexp,wholeWord:null!==(o=null==e?void 0:e.wholeWord)&&void 0!==o?o:c.wholeWord})}function wn(t){let e=S(t,mn);return e&&e.dom.querySelector("[main-field]")}function vn(t){let e=wn(t);e&&e==t.root.activeElement&&e.select()}const yn=t=>{let e=t.state.field(rn,!1);if(e&&e.panel){let n=wn(t);if(n&&n!=t.root.activeElement){let i=gn(t.state,e.query.spec);i.valid&&t.dispatch({effects:en.of(i)}),n.focus(),n.select()}}else t.dispatch({effects:[nn.of(!0),e?en.of(gn(t.state,e.query.spec)):h.appendConfig.of(Cn)]});return!0},bn=t=>{let e=t.state.field(rn,!1);if(!e||!e.panel)return!1;let n=S(t,mn);return n&&n.dom.contains(t.root.activeElement)&&t.focus(),t.dispatch({effects:nn.of(!1)}),!0},kn=[{key:"Mod-f",run:yn,scope:"editor search-panel"},{key:"F3",run:un,shift:an,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:un,shift:an,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:bn,scope:"editor search-panel"},{key:"Mod-Shift-l",run:({state:t,dispatch:e})=>{let n=t.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:i,to:r}=n.main,s=[],o=0;for(let e=new De(t.doc,t.sliceDoc(i,r));!e.next().done;){if(s.length>1e3)return!1;e.value.from==i&&(o=s.length),s.push(l.range(e.value.from,e.value.to))}return e(t.update({selection:l.create(s,o),userEvent:"select.search.matches"})),!0}},{key:"Mod-Alt-g",run:t=>{let e=S(t,Be);if(!e){let n=[je.of(!0)];null==t.state.field(Ve,!1)&&n.push(h.appendConfig.of([Ve,Pe])),t.dispatch({effects:n}),e=S(t,Be)}return e&&e.dom.querySelector("input").select(),!0}},{key:"Mod-d",run:({state:e,dispatch:n})=>{let{ranges:i}=e.selection;if(i.some((t=>t.from===t.to)))return(({state:t,dispatch:e})=>{let{selection:n}=t,i=l.create(n.ranges.map((e=>t.wordAt(e.head)||l.cursor(e.head))),n.mainIndex);return!i.eq(n)&&(e(t.update({selection:i})),!0)})({state:e,dispatch:n});let r=e.sliceDoc(i[0].from,i[0].to);if(e.selection.ranges.some((t=>e.sliceDoc(t.from,t.to)!=r)))return!1;let s=function(t,e){let{main:n,ranges:i}=t.selection,r=t.wordAt(n.head),s=r&&r.from==n.from&&r.to==n.to;for(let n=!1,r=new De(t.doc,e,i[i.length-1].to);;){if(r.next(),!r.done){if(n&&i.some((t=>t.from==r.value.from)))continue;if(s){let e=t.wordAt(r.value.from);if(!e||e.from!=r.value.from||e.to!=r.value.to)continue}return r.value}if(n)return null;r=new De(t.doc,e,0,Math.max(0,i[i.length-1].from-1)),n=!0}}(e,r);return!!s&&(n(e.update({selection:e.selection.addRange(l.range(s.from,s.to),!1),effects:t.scrollIntoView(s.to)})),!0)},preventDefault:!0}];class xn{constructor(t){this.view=t;let e=this.query=t.state.field(rn).query.spec;function n(t,e,n){return Ie("button",{class:"cm-button",name:t,onclick:e,type:"button"},n)}this.commit=this.commit.bind(this),this.searchField=Ie("input",{value:e.search,placeholder:Mn(t,"Find"),"aria-label":Mn(t,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=Ie("input",{value:e.replace,placeholder:Mn(t,"Replace"),"aria-label":Mn(t,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=Ie("input",{type:"checkbox",name:"case",form:"",checked:e.caseSensitive,onchange:this.commit}),this.reField=Ie("input",{type:"checkbox",name:"re",form:"",checked:e.regexp,onchange:this.commit}),this.wordField=Ie("input",{type:"checkbox",name:"word",form:"",checked:e.wholeWord,onchange:this.commit}),this.dom=Ie("div",{onkeydown:t=>this.keydown(t),class:"cm-search"},[this.searchField,n("next",(()=>un(t)),[Mn(t,"next")]),n("prev",(()=>an(t)),[Mn(t,"previous")]),n("select",(()=>fn(t)),[Mn(t,"all")]),Ie("label",null,[this.caseField,Mn(t,"match case")]),Ie("label",null,[this.reField,Mn(t,"regexp")]),Ie("label",null,[this.wordField,Mn(t,"by word")]),...t.state.readOnly?[]:[Ie("br"),this.replaceField,n("replace",(()=>dn(t)),[Mn(t,"replace")]),n("replaceAll",(()=>pn(t)),[Mn(t,"replace all")])],Ie("button",{name:"close",onclick:()=>bn(t),"aria-label":Mn(t,"close"),type:"button"},["×"])])}commit(){let t=new _e({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});t.eq(this.query)||(this.query=t,this.view.dispatch({effects:en.of(t)}))}keydown(t){L(this.view,t,"search-panel")?t.preventDefault():13==t.keyCode&&t.target==this.searchField?(t.preventDefault(),(t.shiftKey?an:un)(this.view)):13==t.keyCode&&t.target==this.replaceField&&(t.preventDefault(),dn(this.view))}update(t){for(let e of t.transactions)for(let t of e.effects)t.is(en)&&!t.value.eq(this.query)&&this.setQuery(t.value)}setQuery(t){this.query=t,this.searchField.value=t.search,this.replaceField.value=t.replace,this.caseField.checked=t.caseSensitive,this.reField.checked=t.regexp,this.wordField.checked=t.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(Je).top}}function Mn(t,e){return t.state.phrase(e)}const In=30,An=/[\s\.,:;?!]/;function Sn(e,{from:n,to:i}){let r=e.state.doc.lineAt(n),s=e.state.doc.lineAt(i).to,o=Math.max(r.from,n-In),l=Math.min(s,i+In),h=e.state.sliceDoc(o,l);if(o!=r.from)for(let t=0;t<In;t++)if(!An.test(h[t+1])&&An.test(h[t])){h=h.slice(t);break}if(l!=s)for(let t=h.length-1;t>h.length-In;t--)if(!An.test(h[t-1])&&An.test(h[t])){h=h.slice(0,t);break}return t.announce.of(`${e.state.phrase("current match")}. ${h} ${e.state.phrase("on line")} ${r.number}.`)}const Dn=t.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"}}),Cn=[rn,C.low(hn),Dn];class En{constructor(t,e,n,i){this.state=t,this.pos=e,this.explicit=n,this.view=i,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(t){let e=g(this.state).resolveInner(this.pos,-1);for(;e&&t.indexOf(e.name)<0;)e=e.parent;return e?{from:e.from,to:this.pos,text:this.state.sliceDoc(e.from,this.pos),type:e.type}:null}matchBefore(t){let e=this.state.doc.lineAt(this.pos),n=Math.max(e.from,this.pos-250),i=e.text.slice(n-e.from,this.pos-e.from),r=i.search(Bn(t,!1));return r<0?null:{from:n+r,to:this.pos,text:i.slice(r)}}get aborted(){return null==this.abortListeners}addEventListener(t,e,n){"abort"==t&&this.abortListeners&&(this.abortListeners.push(e),n&&n.onDocChange&&(this.abortOnDocChange=!0))}}function Rn(t){let e=Object.keys(t).join(""),n=/\w/.test(e);return n&&(e=e.replace(/\w/g,"")),`[${n?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function $n(t){let e=t.map((t=>"string"==typeof t?{label:t}:t)),[n,i]=e.every((t=>/^\w+$/.test(t.label)))?[/\w*$/,/\w+$/]:function(t){let e=Object.create(null),n=Object.create(null);for(let{label:i}of t){e[i[0]]=!0;for(let t=1;t<i.length;t++)n[i[t]]=!0}let i=Rn(e)+Rn(n)+"*$";return[new RegExp("^"+i),new RegExp(i)]}(e);return t=>{let r=t.matchBefore(i);return r||t.explicit?{from:r?r.from:t.pos,options:e,validFor:n}:null}}function On(t,e){return n=>{for(let e=g(n.state).resolveInner(n.pos,-1);e;e=e.parent){if(t.indexOf(e.name)>-1)return null;if(e.type.isTop)break}return e(n)}}class Ln{constructor(t,e,n,i){this.completion=t,this.source=e,this.match=n,this.score=i}}function Tn(t){return t.selection.main.from}function Bn(t,e){var n;let{source:i}=t,r=e&&"^"!=i[0],s="$"!=i[i.length-1];return r||s?new RegExp(`${r?"^":""}(?:${i})${s?"$":""}`,null!==(n=t.flags)&&void 0!==n?n:t.ignoreCase?"i":""):t}const jn=p.define();const Vn=new WeakMap;function Pn(t){if(!Array.isArray(t))return t;let e=Vn.get(t);return e||Vn.set(t,e=$n(t)),e}const Fn=h.define(),Wn=h.define();class zn{constructor(t){this.pattern=t,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let e=0;e<t.length;){let n=I(t,e),i=A(n);this.chars.push(n);let r=t.slice(e,e+i),s=r.toUpperCase();this.folded.push(I(s==r?r.toLowerCase():s,0)),e+=i}this.astral=t.length!=this.chars.length}ret(t,e){return this.score=t,this.matched=e,this}match(t){if(0==this.pattern.length)return this.ret(-100,[]);if(t.length<this.pattern.length)return null;let{chars:e,folded:n,any:i,precise:r,byWord:s}=this;if(1==e.length){let i=I(t,0),r=A(i),s=r==t.length?0:-100;if(i==e[0]);else{if(i!=n[0])return null;s+=-200}return this.ret(s,[0,r])}let o=t.indexOf(this.pattern);if(0==o)return this.ret(t.length==this.pattern.length?0:-100,[0,this.pattern.length]);let l=e.length,h=0;if(o<0){for(let r=0,s=Math.min(t.length,200);r<s&&h<l;){let s=I(t,r);s!=e[h]&&s!=n[h]||(i[h++]=r),r+=A(s)}if(h<l)return null}let c=0,u=0,a=!1,f=0,d=-1,p=-1,m=/[a-z]/.test(t),g=!0;for(let i=0,h=Math.min(t.length,200),w=0;i<h&&u<l;){let h=I(t,i);o<0&&(c<l&&h==e[c]&&(r[c++]=i),f<l&&(h==e[f]||h==n[f]?(0==f&&(d=i),p=i+1,f++):f=0));let v,y=h<255?h>=48&&h<=57||h>=97&&h<=122?2:h>=65&&h<=90?1:0:(v=E(h))!=v.toLowerCase()?1:v!=v.toUpperCase()?2:0;(!i||1==y&&m||0==w&&0!=y)&&(e[u]==h||n[u]==h&&(a=!0)?s[u++]=i:s.length&&(g=!1)),w=y,i+=A(h)}return u==l&&0==s[0]&&g?this.result((a?-200:0)-100,s,t):f==l&&0==d?this.ret(-200-t.length+(p==t.length?0:-100),[0,p]):o>-1?this.ret(-700-t.length,[o,o+this.pattern.length]):f==l?this.ret(-900-t.length,[d,p]):u==l?this.result((a?-200:0)-100-700+(g?0:-1100),s,t):2==e.length?null:this.result((i[0]?-700:0)-200-1100,i,t)}result(t,e,n){let i=[],r=0;for(let t of e){let e=t+(this.astral?A(I(n,t)):1);r&&i[r-1]==t?i[r-1]=e:(i[r++]=t,i[r++]=e)}return this.ret(t-n.length,i)}}class Un{constructor(t){this.pattern=t,this.matched=[],this.score=0,this.folded=t.toLowerCase()}match(t){if(t.length<this.pattern.length)return null;let e=t.slice(0,this.pattern.length),n=e==this.pattern?0:e.toLowerCase()==this.folded?-200:null;return null==n?null:(this.matched=[0,e.length],this.score=n+(t.length==this.pattern.length?0:-100),this)}}const qn=e.define({combine:t=>n(t,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:Nn,filterStrict:!1,compareCompletions:(t,e)=>t.label.localeCompare(e.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(t,e)=>t&&e,closeOnBlur:(t,e)=>t&&e,icons:(t,e)=>t&&e,tooltipClass:(t,e)=>n=>Hn(t(n),e(n)),optionClass:(t,e)=>n=>Hn(t(n),e(n)),addToOptions:(t,e)=>t.concat(e),filterStrict:(t,e)=>t||e})});function Hn(t,e){return t?e?t+" "+e:t:e}function Nn(t,e,n,i,r,s){let o,l,h=t.textDirection==b.RTL,c=h,u=!1,a="top",f=e.left-r.left,d=r.right-e.right,p=i.right-i.left,m=i.bottom-i.top;if(c&&f<Math.min(p,d)?c=!1:!c&&d<Math.min(p,f)&&(c=!0),p<=(c?f:d))o=Math.max(r.top,Math.min(n.top,r.bottom-m))-e.top,l=Math.min(400,c?f:d);else{u=!0,l=Math.min(400,(h?e.right:r.right-e.left)-30);let t=r.bottom-e.bottom;t>=m||t>e.top?o=n.bottom-e.top:(a="bottom",o=e.bottom-n.top)}return{style:`${a}: ${o/((e.bottom-e.top)/s.offsetHeight)}px; max-width: ${l/((e.right-e.left)/s.offsetWidth)}px`,class:"cm-completionInfo-"+(u?h?"left-narrow":"right-narrow":c?"left":"right")}}function Jn(t,e,n){if(t<=n)return{from:0,to:t};if(e<0&&(e=0),e<=t>>1){let t=Math.floor(e/n);return{from:t*n,to:(t+1)*n}}let i=Math.floor((t-e)/n);return{from:t-(i+1)*n,to:t-i*n}}class _n{constructor(t,e,n){this.view=t,this.stateField=e,this.applyCompletion=n,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:t=>this.placeInfo(t),key:this},this.space=null,this.currentClass="";let i=t.state.field(e),{options:r,selected:s}=i.open,o=t.state.facet(qn);this.optionContent=function(t){let e=t.addToOptions.slice();return t.icons&&e.push({render(t){let e=document.createElement("div");return e.classList.add("cm-completionIcon"),t.type&&e.classList.add(...t.type.split(/\s+/g).map((t=>"cm-completionIcon-"+t))),e.setAttribute("aria-hidden","true"),e},position:20}),e.push({render(t,e,n,i){let r=document.createElement("span");r.className="cm-completionLabel";let s=t.displayLabel||t.label,o=0;for(let t=0;t<i.length;){let e=i[t++],n=i[t++];e>o&&r.appendChild(document.createTextNode(s.slice(o,e)));let l=r.appendChild(document.createElement("span"));l.appendChild(document.createTextNode(s.slice(e,n))),l.className="cm-completionMatchedText",o=n}return o<s.length&&r.appendChild(document.createTextNode(s.slice(o))),r},position:50},{render(t){if(!t.detail)return null;let e=document.createElement("span");return e.className="cm-completionDetail",e.textContent=t.detail,e},position:80}),e.sort(((t,e)=>t.position-e.position)).map((t=>t.render))}(o),this.optionClass=o.optionClass,this.tooltipClass=o.tooltipClass,this.range=Jn(r.length,s,o.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(t.state),this.dom.addEventListener("mousedown",(n=>{let{options:i}=t.state.field(e).open;for(let e,r=n.target;r&&r!=this.dom;r=r.parentNode)if("LI"==r.nodeName&&(e=/-(\d+)$/.exec(r.id))&&+e[1]<i.length)return this.applyCompletion(t,i[+e[1]]),void n.preventDefault()})),this.dom.addEventListener("focusout",(e=>{let n=t.state.field(this.stateField,!1);n&&n.tooltip&&t.state.facet(qn).closeOnBlur&&e.relatedTarget!=t.contentDOM&&t.dispatch({effects:Wn.of(null)})})),this.showOptions(r,i.id)}mount(){this.updateSel()}showOptions(t,e){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(t,e,this.range)),this.list.addEventListener("scroll",(()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)}))}update(t){var e;let n=t.state.field(this.stateField),i=t.startState.field(this.stateField);if(this.updateTooltipClass(t.state),n!=i){let{options:r,selected:s,disabled:o}=n.open;i.open&&i.open.options==r||(this.range=Jn(r.length,s,t.state.facet(qn).maxRenderedOptions),this.showOptions(r,n.id)),this.updateSel(),o!=(null===(e=i.open)||void 0===e?void 0:e.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!o)}}updateTooltipClass(t){let e=this.tooltipClass(t);if(e!=this.currentClass){for(let t of this.currentClass.split(" "))t&&this.dom.classList.remove(t);for(let t of e.split(" "))t&&this.dom.classList.add(t);this.currentClass=e}}positioned(t){this.space=t,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let t=this.view.state.field(this.stateField),e=t.open;if((e.selected>-1&&e.selected<this.range.from||e.selected>=this.range.to)&&(this.range=Jn(e.options.length,e.selected,this.view.state.facet(qn).maxRenderedOptions),this.showOptions(e.options,t.id)),this.updateSelectedOption(e.selected)){this.destroyInfo();let{completion:n}=e.options[e.selected],{info:i}=n;if(!i)return;let r="string"==typeof i?document.createTextNode(i):i(n);if(!r)return;"then"in r?r.then((e=>{e&&this.view.state.field(this.stateField,!1)==t&&this.addInfoPane(e,n)})).catch((t=>j(this.view.state,t,"completion info"))):this.addInfoPane(r,n)}}addInfoPane(t,e){this.destroyInfo();let n=this.info=document.createElement("div");if(n.className="cm-tooltip cm-completionInfo",null!=t.nodeType)n.appendChild(t),this.infoDestroy=null;else{let{dom:e,destroy:i}=t;n.appendChild(e),this.infoDestroy=i||null}this.dom.appendChild(n),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(t){let e=null;for(let n=this.list.firstChild,i=this.range.from;n;n=n.nextSibling,i++)"LI"==n.nodeName&&n.id?i==t?n.hasAttribute("aria-selected")||(n.setAttribute("aria-selected","true"),e=n):n.hasAttribute("aria-selected")&&n.removeAttribute("aria-selected"):i--;return e&&function(t,e){let n=t.getBoundingClientRect(),i=e.getBoundingClientRect(),r=n.height/t.offsetHeight;i.top<n.top?t.scrollTop-=(n.top-i.top)/r:i.bottom>n.bottom&&(t.scrollTop+=(i.bottom-n.bottom)/r)}(this.list,e),e}measureInfo(){let t=this.dom.querySelector("[aria-selected]");if(!t||!this.info)return null;let e=this.dom.getBoundingClientRect(),n=this.info.getBoundingClientRect(),i=t.getBoundingClientRect(),r=this.space;if(!r){let t=this.dom.ownerDocument.defaultView||window;r={left:0,top:0,right:t.innerWidth,bottom:t.innerHeight}}return i.top>Math.min(r.bottom,e.bottom)-10||i.bottom<Math.max(r.top,e.top)+10?null:this.view.state.facet(qn).positionInfo(this.view,e,i,n,r,this.dom)}placeInfo(t){this.info&&(t?(t.style&&(this.info.style.cssText=t.style),this.info.className="cm-tooltip cm-completionInfo "+(t.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(t,e,n){const i=document.createElement("ul");i.id=e,i.setAttribute("role","listbox"),i.setAttribute("aria-expanded","true"),i.setAttribute("aria-label",this.view.state.phrase("Completions"));let r=null;for(let s=n.from;s<n.to;s++){let{completion:o,match:l}=t[s],{section:h}=o;if(h){let t="string"==typeof h?h:h.name;if(t!=r&&(s>n.from||0==n.from))if(r=t,"string"!=typeof h&&h.header)i.appendChild(h.header(h));else{i.appendChild(document.createElement("completion-section")).textContent=t}}const c=i.appendChild(document.createElement("li"));c.id=e+"-"+s,c.setAttribute("role","option");let u=this.optionClass(o);u&&(c.className=u);for(let t of this.optionContent){let e=t(o,this.view.state,this.view,l);e&&c.appendChild(e)}}return n.from&&i.classList.add("cm-completionListIncompleteTop"),n.to<t.length&&i.classList.add("cm-completionListIncompleteBottom"),i}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function Gn(t,e){return n=>new _n(n,t,e)}function Kn(t){return 100*(t.boost||0)+(t.apply?10:0)+(t.info?5:0)+(t.type?1:0)}class Qn{constructor(t,e,n,i,r,s){this.options=t,this.attrs=e,this.tooltip=n,this.timestamp=i,this.selected=r,this.disabled=s}setSelected(t,e){return t==this.selected||t>=this.options.length?this:new Qn(this.options,ti(e,t),this.tooltip,this.timestamp,t,this.disabled)}static build(t,e,n,i,r,s){if(i&&!s&&t.some((t=>t.isPending)))return i.setDisabled();let o=function(t,e){let n=[],i=null,r=t=>{n.push(t);let{section:e}=t.completion;if(e){i||(i=[]);let t="string"==typeof e?e:e.name;i.some((e=>e.name==t))||i.push("string"==typeof e?{name:t}:e)}},s=e.facet(qn);for(let i of t)if(i.hasResult()){let t=i.result.getMatch;if(!1===i.result.filter)for(let e of i.result.options)r(new Ln(e,i.source,t?t(e):[],1e9-n.length));else{let n,o=e.sliceDoc(i.from,i.to),l=s.filterStrict?new Un(o):new zn(o);for(let e of i.result.options)if(n=l.match(e.label)){let s=e.displayLabel?t?t(e,n.matched):[]:n.matched;r(new Ln(e,i.source,s,n.score+(e.boost||0)))}}}if(i){let t=Object.create(null),e=0,r=(t,e)=>{var n,i;return(null!==(n=t.rank)&&void 0!==n?n:1e9)-(null!==(i=e.rank)&&void 0!==i?i:1e9)||(t.name<e.name?-1:1)};for(let n of i.sort(r))e-=1e5,t[n.name]=e;for(let e of n){let{section:n}=e.completion;n&&(e.score+=t["string"==typeof n?n:n.name])}}let o=[],l=null,h=s.compareCompletions;for(let t of n.sort(((t,e)=>e.score-t.score||h(t.completion,e.completion)))){let e=t.completion;!l||l.label!=e.label||l.detail!=e.detail||null!=l.type&&null!=e.type&&l.type!=e.type||l.apply!=e.apply||l.boost!=e.boost?o.push(t):Kn(t.completion)>Kn(l)&&(o[o.length-1]=t),l=t.completion}return o}(t,e);if(!o.length)return i&&t.some((t=>t.isPending))?i.setDisabled():null;let l=e.facet(qn).selectOnOpen?0:-1;if(i&&i.selected!=l&&-1!=i.selected){let t=i.options[i.selected].completion;for(let e=0;e<o.length;e++)if(o[e].completion==t){l=e;break}}return new Qn(o,ti(n,l),{pos:t.reduce(((t,e)=>e.hasResult()?Math.min(t,e.from):t),1e8),create:ci,above:r.aboveCursor},i?i.timestamp:Date.now(),l,!1)}map(t){return new Qn(this.options,this.attrs,Object.assign(Object.assign({},this.tooltip),{pos:t.mapPos(this.tooltip.pos)}),this.timestamp,this.selected,this.disabled)}setDisabled(){return new Qn(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class Xn{constructor(t,e,n){this.active=t,this.id=e,this.open=n}static start(){return new Xn(ei,"cm-ac-"+Math.floor(2e6*Math.random()).toString(36),null)}update(t){let{state:e}=t,n=e.facet(qn),i=(n.override||e.languageDataAt("autocomplete",Tn(e)).map(Pn)).map((e=>(this.active.find((t=>t.source==e))||new ii(e,this.active.some((t=>0!=t.state))?1:0)).update(t,n)));i.length==this.active.length&&i.every(((t,e)=>t==this.active[e]))&&(i=this.active);let r=this.open,s=t.effects.some((t=>t.is(si)));r&&t.docChanged&&(r=r.map(t.changes)),t.selection||i.some((e=>e.hasResult()&&t.changes.touchesRange(e.from,e.to)))||!function(t,e){if(t==e)return!0;for(let n=0,i=0;;){for(;n<t.length&&!t[n].hasResult();)n++;for(;i<e.length&&!e[i].hasResult();)i++;let r=n==t.length,s=i==e.length;if(r||s)return r==s;if(t[n++].result!=e[i++].result)return!1}}(i,this.active)||s?r=Qn.build(i,e,this.id,r,n,s):r&&r.disabled&&!i.some((t=>t.isPending))&&(r=null),!r&&i.every((t=>!t.isPending))&&i.some((t=>t.hasResult()))&&(i=i.map((t=>t.hasResult()?new ii(t.source,0):t)));for(let e of t.effects)e.is(oi)&&(r=r&&r.setSelected(e.value,this.id));return i==this.active&&r==this.open?this:new Xn(i,this.id,r)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?Yn:Zn}}const Yn={"aria-autocomplete":"list"},Zn={};function ti(t,e){let n={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":t};return e>-1&&(n["aria-activedescendant"]=t+"-"+e),n}const ei=[];function ni(t,e){if(t.isUserEvent("input.complete")){let n=t.annotation(jn);if(n&&e.activateOnCompletion(n))return 12}let n=t.isUserEvent("input.type");return n&&e.activateOnTyping?5:n?1:t.isUserEvent("delete.backward")?2:t.selection?8:t.docChanged?16:0}class ii{constructor(t,e,n=!1){this.source=t,this.state=e,this.explicit=n}hasResult(){return!1}get isPending(){return 1==this.state}update(t,e){let n=ni(t,e),i=this;(8&n||16&n&&this.touches(t))&&(i=new ii(i.source,0)),4&n&&0==i.state&&(i=new ii(this.source,1)),i=i.updateFor(t,n);for(let e of t.effects)if(e.is(Fn))i=new ii(i.source,1,e.value);else if(e.is(Wn))i=new ii(i.source,0);else if(e.is(si))for(let t of e.value)t.source==i.source&&(i=t);return i}updateFor(t,e){return this.map(t.changes)}map(t){return this}touches(t){return t.changes.touchesRange(Tn(t.state))}}class ri extends ii{constructor(t,e,n,i,r,s){super(t,3,e),this.limit=n,this.result=i,this.from=r,this.to=s}hasResult(){return!0}updateFor(t,e){var n;if(!(3&e))return this.map(t.changes);let i=this.result;i.map&&!t.changes.empty&&(i=i.map(i,t.changes));let r=t.changes.mapPos(this.from),s=t.changes.mapPos(this.to,1),o=Tn(t.state);if(o>s||!i||2&e&&(Tn(t.startState)==this.from||o<this.limit))return new ii(this.source,4&e?1:0);let l=t.changes.mapPos(this.limit);return function(t,e,n,i){if(!t)return!1;let r=e.sliceDoc(n,i);return"function"==typeof t?t(r,n,i,e):Bn(t,!0).test(r)}(i.validFor,t.state,r,s)?new ri(this.source,this.explicit,l,i,r,s):i.update&&(i=i.update(i,r,s,new En(t.state,o,!1)))?new ri(this.source,this.explicit,l,i,i.from,null!==(n=i.to)&&void 0!==n?n:Tn(t.state)):new ii(this.source,1,this.explicit)}map(t){if(t.empty)return this;return(this.result.map?this.result.map(this.result,t):this.result)?new ri(this.source,this.explicit,t.mapPos(this.limit),this.result,t.mapPos(this.from),t.mapPos(this.to,1)):new ii(this.source,0)}touches(t){return t.changes.touchesRange(this.from,this.to)}}const si=h.define({map:(t,e)=>t.map((t=>t.map(e)))}),oi=h.define(),li=i.define({create:()=>Xn.start(),update:(t,e)=>t.update(e),provide:e=>[B.from(e,(t=>t.tooltip)),t.contentAttributes.from(e,(t=>t.attrs))]});function hi(t,e){const n=e.completion.apply||e.completion.label;let i=t.state.field(li).active.find((t=>t.source==e.source));return i instanceof ri&&("string"==typeof n?t.dispatch(Object.assign(Object.assign({},function(t,e,n,i){let{main:r}=t.selection,s=n-r.from,o=i-r.from;return Object.assign(Object.assign({},t.changeByRange((h=>{if(h!=r&&n!=i&&t.sliceDoc(h.from+s,h.from+o)!=t.sliceDoc(n,i))return{range:h};let c=t.toText(e);return{changes:{from:h.from+s,to:i==r.from?h.to:h.from+o,insert:c},range:l.cursor(h.from+s+c.length)}}))),{scrollIntoView:!0,userEvent:"input.complete"})}(t.state,n,i.from,i.to)),{annotations:jn.of(e.completion)})):n(t,e.completion,i.from,i.to),!0)}const ci=Gn(li,hi);function ui(t,e="option"){return n=>{let i=n.state.field(li,!1);if(!i||!i.open||i.open.disabled||Date.now()-i.open.timestamp<n.state.facet(qn).interactionDelay)return!1;let r,s=1;"page"==e&&(r=V(n,i.open.tooltip))&&(s=Math.max(2,Math.floor(r.dom.offsetHeight/r.dom.querySelector("li").offsetHeight)-1));let{length:o}=i.open.options,l=i.open.selected>-1?i.open.selected+s*(t?1:-1):t?0:o-1;return l<0?l="page"==e?0:o-1:l>=o&&(l="page"==e?o-1:0),n.dispatch({effects:oi.of(l)}),!0}}const ai=t=>{let e=t.state.field(li,!1);return!(t.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestamp<t.state.facet(qn).interactionDelay)&&hi(t,e.open.options[e.open.selected])},fi=t=>!!t.state.field(li,!1)&&(t.dispatch({effects:Fn.of(!0)}),!0),di=t=>{let e=t.state.field(li,!1);return!(!e||!e.active.some((t=>0!=t.state)))&&(t.dispatch({effects:Wn.of(null)}),!0)};class pi{constructor(t,e){this.active=t,this.context=e,this.time=Date.now(),this.updates=[],this.done=void 0}}const mi=x.fromClass(class{constructor(t){this.view=t,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of t.state.field(li).active)e.isPending&&this.startQuery(e)}update(t){let e=t.state.field(li),n=t.state.facet(qn);if(!t.selectionSet&&!t.docChanged&&t.startState.field(li)==e)return;let i=t.transactions.some((t=>{let e=ni(t,n);return 8&e||(t.selection||t.docChanged)&&!(3&e)}));for(let e=0;e<this.running.length;e++){let n=this.running[e];if(i||n.context.abortOnDocChange&&t.docChanged||n.updates.length+t.transactions.length>50&&Date.now()-n.time>1e3){for(let t of n.context.abortListeners)try{t()}catch(t){j(this.view.state,t)}n.context.abortListeners=null,this.running.splice(e--,1)}else n.updates.push(...t.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),t.transactions.some((t=>t.effects.some((t=>t.is(Fn)))))&&(this.pendingStart=!0);let r=this.pendingStart?50:n.activateOnTypingDelay;if(this.debounceUpdate=e.active.some((t=>t.isPending&&!this.running.some((e=>e.active.source==t.source))))?setTimeout((()=>this.startUpdate()),r):-1,0!=this.composing)for(let e of t.transactions)e.isUserEvent("input.type")?this.composing=2:2==this.composing&&e.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:t}=this.view,e=t.field(li);for(let t of e.active)t.isPending&&!this.running.some((e=>e.active.source==t.source))&&this.startQuery(t);this.running.length&&e.open&&e.open.disabled&&(this.debounceAccept=setTimeout((()=>this.accept()),this.view.state.facet(qn).updateSyncTime))}startQuery(t){let{state:e}=this.view,n=Tn(e),i=new En(e,n,t.explicit,this.view),r=new pi(t,i);this.running.push(r),Promise.resolve(t.source(i)).then((t=>{r.context.aborted||(r.done=t||null,this.scheduleAccept())}),(t=>{this.view.dispatch({effects:Wn.of(null)}),j(this.view.state,t)}))}scheduleAccept(){this.running.every((t=>void 0!==t.done))?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout((()=>this.accept()),this.view.state.facet(qn).updateSyncTime))}accept(){var t;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],n=this.view.state.facet(qn),i=this.view.state.field(li);for(let r=0;r<this.running.length;r++){let s=this.running[r];if(void 0===s.done)continue;if(this.running.splice(r--,1),s.done){let i=Tn(s.updates.length?s.updates[0].startState:this.view.state),r=Math.min(i,s.done.from+(s.active.explicit?0:1)),o=new ri(s.active.source,s.active.explicit,r,s.done,s.done.from,null!==(t=s.done.to)&&void 0!==t?t:i);for(let t of s.updates)o=o.update(t,n);if(o.hasResult()){e.push(o);continue}}let o=i.active.find((t=>t.source==s.active.source));if(o&&o.isPending)if(null==s.done){let t=new ii(s.active.source,0);for(let e of s.updates)t=t.update(e,n);t.isPending||e.push(t)}else this.startQuery(o)}(e.length||i.open&&i.open.disabled)&&this.view.dispatch({effects:si.of(e)})}},{eventHandlers:{blur(t){let e=this.view.state.field(li,!1);if(e&&e.tooltip&&this.view.state.facet(qn).closeOnBlur){let n=e.open&&V(this.view,e.open.tooltip);n&&n.dom.contains(t.relatedTarget)||setTimeout((()=>this.view.dispatch({effects:Wn.of(null)})),10)}},compositionstart(){this.composing=1},compositionend(){3==this.composing&&setTimeout((()=>this.view.dispatch({effects:Fn.of(!1)})),20),this.composing=0}}}),gi="object"==typeof navigator&&/Win/.test(navigator.platform),wi=C.highest(t.domEventHandlers({keydown(t,e){let n=e.state.field(li,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||t.key.length>1||t.ctrlKey&&(!gi||!t.altKey)||t.metaKey)return!1;let i=n.open.options[n.open.selected],r=n.active.find((t=>t.source==i.source)),s=i.completion.commitCharacters||r.result.commitCharacters;return s&&s.indexOf(t.key)>-1&&hi(e,i),!1}})),vi=t.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});class yi{constructor(t,e,n,i){this.field=t,this.line=e,this.from=n,this.to=i}}class bi{constructor(t,e,n){this.field=t,this.from=e,this.to=n}map(t){let e=t.mapPos(this.from,-1,F.TrackDel),n=t.mapPos(this.to,1,F.TrackDel);return null==e||null==n?null:new bi(this.field,e,n)}}class ki{constructor(t,e){this.lines=t,this.fieldPositions=e}instantiate(t,e){let n=[],i=[e],r=t.doc.lineAt(e),s=/^\s*/.exec(r.text)[0];for(let r of this.lines){if(n.length){let n=s,o=/^\t*/.exec(r)[0].length;for(let e=0;e<o;e++)n+=t.facet(v);i.push(e+n.length-o),r=n+r.slice(o)}n.push(r),e+=r.length+1}let o=this.fieldPositions.map((t=>new bi(t.field,i[t.line]+t.from,i[t.line]+t.to)));return{text:n,ranges:o}}static parse(t){let e,n=[],i=[],r=[];for(let s of t.split(/\r\n?|\n/)){for(;e=/[#$]\{(?:(\d+)(?::([^}]*))?|((?:\\[{}]|[^}])*))\}/.exec(s);){let t=e[1]?+e[1]:null,o=e[2]||e[3]||"",l=-1,h=o.replace(/\\[{}]/g,(t=>t[1]));for(let e=0;e<n.length;e++)(null!=t?n[e].seq==t:h&&n[e].name==h)&&(l=e);if(l<0){let e=0;for(;e<n.length&&(null==t||null!=n[e].seq&&n[e].seq<t);)e++;n.splice(e,0,{seq:t,name:h}),l=e;for(let t of r)t.field>=l&&t.field++}r.push(new yi(l,i.length,e.index,e.index+h.length)),s=s.slice(0,e.index)+o+s.slice(e.index+e[0].length)}s=s.replace(/\\([{}])/g,((t,e,n)=>{for(let t of r)t.line==i.length&&t.from>n&&(t.from--,t.to--);return e})),i.push(s)}return new ki(i,r)}}let xi=M.widget({widget:new class extends z{toDOM(){let t=document.createElement("span");return t.className="cm-snippetFieldPosition",t}ignoreEvent(){return!1}}}),Mi=M.mark({class:"cm-snippetField"});class Ii{constructor(t,e){this.ranges=t,this.active=e,this.deco=M.set(t.map((t=>(t.from==t.to?xi:Mi).range(t.from,t.to))))}map(t){let e=[];for(let n of this.ranges){let i=n.map(t);if(!i)return null;e.push(i)}return new Ii(e,this.active)}selectionInsideField(t){return t.ranges.every((t=>this.ranges.some((e=>e.field==this.active&&e.from<=t.from&&e.to>=t.to))))}}const Ai=h.define({map:(t,e)=>t&&t.map(e)}),Si=h.define(),Di=i.define({create:()=>null,update(t,e){for(let n of e.effects){if(n.is(Ai))return n.value;if(n.is(Si)&&t)return new Ii(t.ranges,n.value)}return t&&e.docChanged&&(t=t.map(e.changes)),t&&e.selection&&!t.selectionInsideField(e.selection)&&(t=null),t},provide:e=>t.decorations.from(e,(t=>t?t.deco:M.none))});function Ci(t,e){return l.create(t.filter((t=>t.field==e)).map((t=>l.range(t.from,t.to))))}function Ei(t){let e=ki.parse(t);return(t,n,i,s)=>{let{text:o,ranges:l}=e.instantiate(t.state,i),{main:c}=t.state.selection,u={changes:{from:i,to:s==c.from?c.to:s,insert:d.of(o)},scrollIntoView:!0,annotations:n?[jn.of(n),r.userEvent.of("input.complete")]:void 0};if(l.length&&(u.selection=Ci(l,0)),l.some((t=>t.field>0))){let e=new Ii(l,0),n=u.effects=[Ai.of(e)];void 0===t.state.field(Di,!1)&&n.push(h.appendConfig.of([Di,Li,Bi,vi]))}t.dispatch(t.state.update(u))}}function Ri(t){return({state:e,dispatch:n})=>{let i=e.field(Di,!1);if(!i||t<0&&0==i.active)return!1;let r=i.active+t,s=t>0&&!i.ranges.some((e=>e.field==r+t));return n(e.update({selection:Ci(i.ranges,r),effects:Ai.of(s?null:new Ii(i.ranges,r)),scrollIntoView:!0})),!0}}const $i=[{key:"Tab",run:Ri(1),shift:Ri(-1)},{key:"Escape",run:({state:t,dispatch:e})=>!!t.field(Di,!1)&&(e(t.update({effects:Ai.of(null)})),!0)}],Oi=e.define({combine:t=>t.length?t[0]:$i}),Li=C.highest(T.compute([Oi],(t=>t.facet(Oi))));function Ti(t,e){return Object.assign(Object.assign({},e),{apply:Ei(t)})}const Bi=t.domEventHandlers({mousedown(t,e){let n,i=e.state.field(Di,!1);if(!i||null==(n=e.posAtCoords({x:t.clientX,y:t.clientY})))return!1;let r=i.ranges.find((t=>t.from<=n&&t.to>=n));return!(!r||r.field==i.active)&&(e.dispatch({selection:Ci(i.ranges,r.field),effects:Ai.of(i.ranges.some((t=>t.field>r.field))?new Ii(i.ranges,r.field):null),scrollIntoView:!0}),!0)}}),ji={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},Vi=h.define({map(t,e){let n=e.mapPos(t,-1,F.TrackAfter);return null==n?void 0:n}}),Pi=new class extends P{};Pi.startSide=1,Pi.endSide=-1;const Fi=i.define({create:()=>W.empty,update(t,e){if(t=t.map(e.changes),e.selection){let n=e.state.doc.lineAt(e.selection.main.head);t=t.update({filter:t=>t>=n.from&&t<=n.to})}for(let n of e.effects)n.is(Vi)&&(t=t.update({add:[Pi.range(n.value,n.value+1)]}));return t}});const Wi="()[]{}<>";function zi(t){for(let e=0;e<8;e+=2)if(Wi.charCodeAt(e)==t)return Wi.charAt(e+1);return E(t<128?t:t+1)}function Ui(t,e){return t.languageDataAt("closeBrackets",e)[0]||ji}const qi="object"==typeof navigator&&/Android\b/.test(navigator.userAgent),Hi=t.inputHandler.of(((t,e,n,i)=>{if((qi?t.composing:t.compositionStarted)||t.state.readOnly)return!1;let r=t.state.selection.main;if(i.length>2||2==i.length&&1==A(I(i,0))||e!=r.from||n!=r.to)return!1;let s=function(t,e){let n=Ui(t,t.selection.main.head),i=n.brackets||ji.brackets;for(let r of i){let s=zi(I(r,0));if(e==r)return s==r?Qi(t,r,i.indexOf(r+r+r)>-1,n):Gi(t,r,s,n.before||ji.before);if(e==s&&Ji(t,t.selection.main.from))return Ki(t,r,s)}return null}(t.state,i);return!!s&&(t.dispatch(s),!0)})),Ni=[{key:"Backspace",run:({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=Ui(t,t.selection.main.head).brackets||ji.brackets,i=null,r=t.changeByRange((e=>{if(e.empty){let i=function(t,e){let n=t.sliceString(e-2,e);return A(I(n,0))==n.length?n:n.slice(1)}(t.doc,e.head);for(let r of n)if(r==i&&_i(t.doc,e.head)==zi(I(r,0)))return{changes:{from:e.head-r.length,to:e.head+r.length},range:l.cursor(e.head-r.length)}}return{range:i=e}}));return i||e(t.update(r,{scrollIntoView:!0,userEvent:"delete.backward"})),!i}}];function Ji(t,e){let n=!1;return t.field(Fi).between(0,t.doc.length,(t=>{t==e&&(n=!0)})),n}function _i(t,e){let n=t.sliceString(e,e+2);return n.slice(0,A(I(n,0)))}function Gi(t,e,n,i){let r=null,s=t.changeByRange((s=>{if(!s.empty)return{changes:[{insert:e,from:s.from},{insert:n,from:s.to}],effects:Vi.of(s.to+e.length),range:l.range(s.anchor+e.length,s.head+e.length)};let o=_i(t.doc,s.head);return!o||/\s/.test(o)||i.indexOf(o)>-1?{changes:{insert:e+n,from:s.head},effects:Vi.of(s.head+e.length),range:l.cursor(s.head+e.length)}:{range:r=s}}));return r?null:t.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function Ki(t,e,n){let i=null,r=t.changeByRange((e=>e.empty&&_i(t.doc,e.head)==n?{changes:{from:e.head,to:e.head+n.length,insert:n},range:l.cursor(e.head+n.length)}:i={range:e}));return i?null:t.update(r,{scrollIntoView:!0,userEvent:"input.type"})}function Qi(t,e,n,i){let r=i.stringPrefixes||ji.stringPrefixes,s=null,o=t.changeByRange((i=>{if(!i.empty)return{changes:[{insert:e,from:i.from},{insert:e,from:i.to}],effects:Vi.of(i.to+e.length),range:l.range(i.anchor+e.length,i.head+e.length)};let o,h=i.head,c=_i(t.doc,h);if(c==e){if(Xi(t,h))return{changes:{insert:e+e,from:h},effects:Vi.of(h+e.length),range:l.cursor(h+e.length)};if(Ji(t,h)){let i=n&&t.sliceDoc(h,h+3*e.length)==e+e+e?e+e+e:e;return{changes:{from:h,to:h+i.length,insert:i},range:l.cursor(h+i.length)}}}else{if(n&&t.sliceDoc(h-2*e.length,h)==e+e&&(o=Yi(t,h-2*e.length,r))>-1&&Xi(t,o))return{changes:{insert:e+e+e+e,from:h},effects:Vi.of(h+e.length),range:l.cursor(h+e.length)};if(t.charCategorizer(h)(c)!=D.Word&&Yi(t,h,r)>-1&&!function(t,e,n,i){let r=g(t).resolveInner(e,-1),s=i.reduce(((t,e)=>Math.max(t,e.length)),0);for(let o=0;o<5;o++){let o=t.sliceDoc(r.from,Math.min(r.to,r.from+n.length+s)),l=o.indexOf(n);if(!l||l>-1&&i.indexOf(o.slice(0,l))>-1){let e=r.firstChild;for(;e&&e.from==r.from&&e.to-e.from>n.length+l;){if(t.sliceDoc(e.to-n.length,e.to)==n)return!1;e=e.firstChild}return!0}let h=r.to==e&&r.parent;if(!h)break;r=h}return!1}(t,h,e,r))return{changes:{insert:e+e,from:h},effects:Vi.of(h+e.length),range:l.cursor(h+e.length)}}return{range:s=i}}));return s?null:t.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function Xi(t,e){let n=g(t).resolveInner(e+1);return n.parent&&n.from==e}function Yi(t,e,n){let i=t.charCategorizer(e);if(i(t.sliceDoc(e-1,e))!=D.Word)return e;for(let r of n){let n=e-r.length;if(t.sliceDoc(n,e)==r&&i(t.sliceDoc(n-1,n))!=D.Word)return n}return-1}function Zi(t={}){return[wi,li,qn.of(t),mi,er,vi]}const tr=[{key:"Ctrl-Space",run:fi},{mac:"Alt-`",run:fi},{key:"Escape",run:di},{key:"ArrowDown",run:ui(!0)},{key:"ArrowUp",run:ui(!1)},{key:"PageDown",run:ui(!0,"page")},{key:"PageUp",run:ui(!1,"page")},{key:"Enter",run:ai}],er=C.highest(T.computeN([qn],(t=>t.facet(qn).defaultKeymap?[tr]:[])));function nr(t){let e=t.field(li,!1);return e&&e.active.some((t=>t.isPending))?"pending":e&&e.active.some((t=>0!=t.state))?"active":null}class ir{constructor(t,e,n){this.from=t,this.to=e,this.diagnostic=n}}class rr{constructor(t,e,n){this.diagnostics=t,this.panel=e,this.selected=n}static init(t,e,n){let i=t,r=n.facet(mr).markerFilter;r&&(i=r(i,n));let s=t.slice().sort(((t,e)=>t.from-e.from||t.to-e.to)),o=new O,l=[],h=0;for(let t=0;;){let e,i,r=t==s.length?null:s[t];if(!r&&!l.length)break;for(l.length?(e=h,i=l.reduce(((t,e)=>Math.min(t,e.to)),r&&r.from>e?r.from:1e8)):(e=r.from,i=r.to,l.push(r),t++);t<s.length;){let n=s[t];if(n.from!=e||!(n.to>n.from||n.to==e)){i=Math.min(n.from,i);break}l.push(n),t++,i=Math.min(n.to,i)}let c=Ir(l);if(l.some((t=>t.from==t.to||t.from==t.to-1&&n.doc.lineAt(t.from).to==t.from)))o.add(e,e,M.widget({widget:new vr(c),diagnostics:l.slice()}));else{let t=l.reduce(((t,e)=>e.markClass?t+" "+e.markClass:t),"");o.add(e,i,M.mark({class:"cm-lintRange cm-lintRange-"+c+t,diagnostics:l.slice(),inclusiveEnd:l.some((t=>t.to>i))}))}h=i;for(let t=0;t<l.length;t++)l[t].to<=h&&l.splice(t--,1)}let c=o.finish();return new rr(c,e,sr(c))}}function sr(t,e=null,n=0){let i=null;return t.between(n,1e9,((t,n,{spec:r})=>{if(!(e&&r.diagnostics.indexOf(e)<0))if(i){if(r.diagnostics.indexOf(i.diagnostic)<0)return!1;i=new ir(i.from,n,i.diagnostic)}else i=new ir(t,n,e||r.diagnostics[0])})),i}const or=h.define(),lr=h.define(),hr=h.define(),cr=i.define({create:()=>new rr(M.none,null,null),update(t,e){if(e.docChanged&&t.diagnostics.size){let n=t.diagnostics.map(e.changes),i=null,r=t.panel;if(t.selected){let r=e.changes.mapPos(t.selected.from,1);i=sr(n,t.selected.diagnostic,r)||sr(n,null,r)}!n.size&&r&&e.state.facet(mr).autoPanel&&(r=null),t=new rr(n,r,i)}for(let n of e.effects)if(n.is(or)){let i=e.state.facet(mr).autoPanel?n.value.length?br.open:null:t.panel;t=rr.init(n.value,i,e.state)}else n.is(lr)?t=new rr(t.diagnostics,n.value?br.open:null,t.selected):n.is(hr)&&(t=new rr(t.diagnostics,t.panel,n.value));return t},provide:e=>[R.from(e,(t=>t.panel)),t.decorations.from(e,(t=>t.diagnostics))]}),ur=M.mark({class:"cm-lintRange cm-lintRange-active"});function ar(t,e,n){let i,{diagnostics:r}=t.state.field(cr),s=-1,o=-1;r.between(e-(n<0?1:0),e+(n>0?1:0),((t,r,{spec:l})=>{if(e>=t&&e<=r&&(t==r||(e>t||n>0)&&(e<r||n<0)))return i=l.diagnostics,s=t,o=r,!1}));let l=t.state.facet(mr).tooltipFilter;return i&&l&&(i=l(i,t.state)),i?{pos:s,end:o,above:t.state.doc.lineAt(s).to<o,create:()=>({dom:fr(t,i)})}:null}function fr(t,e){return Ie("ul",{class:"cm-tooltip-lint"},e.map((e=>wr(t,e,!1))))}const dr=t=>{let e=t.state.field(cr,!1);return!(!e||!e.panel)&&(t.dispatch({effects:lr.of(!1)}),!0)},pr=[{key:"Mod-Shift-m",run:t=>{let e=t.state.field(cr,!1);var n,i;e&&e.panel||t.dispatch({effects:(n=t.state,i=[lr.of(!0)],n.field(cr,!1)?i:i.concat(h.appendConfig.of(Ar)))});let r=S(t,br.open);return r&&r.dom.querySelector(".cm-panel-lint ul").focus(),!0},preventDefault:!0},{key:"F8",run:t=>{let e=t.state.field(cr,!1);if(!e)return!1;let n=t.state.selection.main,i=e.diagnostics.iter(n.to+1);return!(!i.value&&(i=e.diagnostics.iter(0),!i.value||i.from==n.from&&i.to==n.to))&&(t.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0}),!0)}}],mr=e.define({combine:t=>Object.assign({sources:t.map((t=>t.source)).filter((t=>null!=t))},n(t.map((t=>t.config)),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{needsRefresh:(t,e)=>t?e?n=>t(n)||e(n):t:e}))});function gr(t){let e=[];if(t)t:for(let{name:n}of t){for(let t=0;t<n.length;t++){let i=n[t];if(/[a-zA-Z]/.test(i)&&!e.some((t=>t.toLowerCase()==i.toLowerCase()))){e.push(i);continue t}}e.push("")}return e}function wr(t,e,n){var i;let r=n?gr(e.actions):[];return Ie("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},Ie("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(t):e.message),null===(i=e.actions)||void 0===i?void 0:i.map(((n,i)=>{let s=!1,o=i=>{if(i.preventDefault(),s)return;s=!0;let r=sr(t.state.field(cr).diagnostics,e);r&&n.apply(t,r.from,r.to)},{name:l}=n,h=r[i]?l.indexOf(r[i]):-1,c=h<0?l:[l.slice(0,h),Ie("u",l.slice(h,h+1)),l.slice(h+1)];return Ie("button",{type:"button",class:"cm-diagnosticAction",onclick:o,onmousedown:o,"aria-label":` Action: ${l}${h<0?"":` (access key "${r[i]})"`}.`},c)})),e.source&&Ie("div",{class:"cm-diagnosticSource"},e.source))}class vr extends z{constructor(t){super(),this.sev=t}eq(t){return t.sev==this.sev}toDOM(){return Ie("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class yr{constructor(t,e){this.diagnostic=e,this.id="item_"+Math.floor(4294967295*Math.random()).toString(16),this.dom=wr(t,e,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class br{constructor(t){this.view=t,this.items=[];this.list=Ie("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:e=>{if(27==e.keyCode)dr(this.view),this.view.focus();else if(38==e.keyCode||33==e.keyCode)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(40==e.keyCode||34==e.keyCode)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(36==e.keyCode)this.moveSelection(0);else if(35==e.keyCode)this.moveSelection(this.items.length-1);else if(13==e.keyCode)this.view.focus();else{if(!(e.keyCode>=65&&e.keyCode<=90&&this.selectedIndex>=0))return;{let{diagnostic:n}=this.items[this.selectedIndex],i=gr(n.actions);for(let r=0;r<i.length;r++)if(i[r].toUpperCase().charCodeAt(0)==e.keyCode){let e=sr(this.view.state.field(cr).diagnostics,n);e&&n.actions[r].apply(t,e.from,e.to)}}}e.preventDefault()},onclick:t=>{for(let e=0;e<this.items.length;e++)this.items[e].dom.contains(t.target)&&this.moveSelection(e)}}),this.dom=Ie("div",{class:"cm-panel-lint"},this.list,Ie("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>dr(this.view)},"×")),this.update()}get selectedIndex(){let t=this.view.state.field(cr).selected;if(!t)return-1;for(let e=0;e<this.items.length;e++)if(this.items[e].diagnostic==t.diagnostic)return e;return-1}update(){let{diagnostics:t,selected:e}=this.view.state.field(cr),n=0,i=!1,r=null,s=new Set;for(t.between(0,this.view.state.doc.length,((t,o,{spec:l})=>{for(let t of l.diagnostics){if(s.has(t))continue;s.add(t);let o,l=-1;for(let e=n;e<this.items.length;e++)if(this.items[e].diagnostic==t){l=e;break}l<0?(o=new yr(this.view,t),this.items.splice(n,0,o),i=!0):(o=this.items[l],l>n&&(this.items.splice(n,l-n),i=!0)),e&&o.diagnostic==e.diagnostic?o.dom.hasAttribute("aria-selected")||(o.dom.setAttribute("aria-selected","true"),r=o):o.dom.hasAttribute("aria-selected")&&o.dom.removeAttribute("aria-selected"),n++}}));n<this.items.length&&!(1==this.items.length&&this.items[0].diagnostic.from<0);)i=!0,this.items.pop();0==this.items.length&&(this.items.push(new yr(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),i=!0),r?(this.list.setAttribute("aria-activedescendant",r.id),this.view.requestMeasure({key:this,read:()=>({sel:r.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:t,panel:e})=>{let n=e.height/this.list.offsetHeight;t.top<e.top?this.list.scrollTop-=(e.top-t.top)/n:t.bottom>e.bottom&&(this.list.scrollTop+=(t.bottom-e.bottom)/n)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),i&&this.sync()}sync(){let t=this.list.firstChild;function e(){let e=t;t=e.nextSibling,e.remove()}for(let n of this.items)if(n.dom.parentNode==this.list){for(;t!=n.dom;)e();t=n.dom.nextSibling}else this.list.insertBefore(n.dom,t);for(;t;)e()}moveSelection(t){if(this.selectedIndex<0)return;let e=sr(this.view.state.field(cr).diagnostics,this.items[t].diagnostic);e&&this.view.dispatch({selection:{anchor:e.from,head:e.to},scrollIntoView:!0,effects:hr.of(e)})}static open(t){return new br(t)}}function kr(t){return function(t,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${e}>${encodeURIComponent(t)}</svg>')`}(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${t}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}const xr=t.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:kr("#d11")},".cm-lintRange-warning":{backgroundImage:kr("orange")},".cm-lintRange-info":{backgroundImage:kr("#999")},".cm-lintRange-hint":{backgroundImage:kr("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}}});function Mr(t){return"error"==t?4:"warning"==t?3:"info"==t?2:1}function Ir(t){let e="hint",n=1;for(let i of t){let t=Mr(i.severity);t>n&&(n=t,e=i.severity)}return e}const Ar=[cr,t.decorations.compute([cr],(t=>{let{selected:e,panel:n}=t.field(cr);return e&&n&&e.from!=e.to?M.set([ur.range(e.from,e.to)]):M.none})),U(ar,{hideOn:function(t,e){let n=e.pos,i=e.end||n,r=t.state.facet(mr).hideOn(t,n,i);if(null!=r)return r;let s=t.startState.doc.lineAt(e.pos);return!(!t.effects.some((t=>t.is(or)))&&!t.changes.touchesRange(s.from,Math.max(s.to,i)))}}),xr],Sr=t=>void 0===t||t,Dr=(e={})=>{let n=[];Sr(e.defaultKeymap)&&n.push(...Me),Sr(e.closeBracketsKeymap)&&n.push(...Ni),Sr(e.searchKeymap)&&n.push(...kn),Sr(e.historyKeymap)&&n.push(...Et),Sr(e.foldKeymap)&&n.push(...q),Sr(e.lintKeymap)&&n.push(...pr);const i=[];return Sr(e.highlightActiveLineGutter)&&i.push(H()),Sr(e.highlightSpecialChars)&&i.push(N()),Sr(e.history)&&i.push(function(e={}){return[ft,at.of(e),t.domEventHandlers({beforeinput(t,e){let n="historyUndo"==t.inputType?pt:"historyRedo"==t.inputType?mt:null;return!!n&&(t.preventDefault(),n(e))}})]}()),Sr(e.foldGutter)&&i.push(J()),Sr(e.drawSelection)&&i.push(_()),Sr(e.dropCursor)&&i.push(G()),Sr(e.allowMultipleSelections)&&i.push($.allowMultipleSelections.of(!0)),Sr(e.indentOnInput)&&i.push(K()),Sr(e.bracketMatching)&&i.push(Q()),Sr(e.closeBrackets)&&i.push([Hi,Fi]),Sr(e.autocompletion)&&i.push(Zi()),Sr(e.rectangularSelection)&&i.push(X()),Sr(e.crosshairCursor)&&i.push(Y()),Sr(e.highlightActiveLine)&&i.push(Z()),Sr(e.highlightSelectionMatches)&&i.push(function(t){let e=[Ne,He];return t&&e.push(We.of(t)),e}()),e.enableSearch||i.push(T.of([{key:"Mod-f",run:()=>!0}])),e.tabSize&&"number"==typeof e.tabSize&&i.push(v.of(" ".repeat(e.tabSize))),i.concat([T.of(n.flat())]).filter(Boolean)};export{ai as a,Zi as b,$n as c,di as d,nr as e,Dr as f,On as i,Ti as s};
|
|
1
|
+
import{E as t,F as e,c as n,S as i,T as r,C as s,a as o,b as l,d as h,I as c,g as u,e as a,i as f,f as d,A as p,m,s as g,N as w,h as v,j as y,D as b,k,V as x,l as M,n as I,o as A,p as S,q as D,P as C,r as E,u as R,v as $,R as O,w as L,x as T,y as B,z as j,B as V,G as P,M as F,J as W,W as z,K as U,L as q,O as H,Q as N,U as J,X as _,Y as G,Z as K,_ as Q,$ as X,a0 as Y,a1 as Z}from"../index-0fe57384.esm.js";import"../index-920675c4.esm.js";function tt(t,e){return({state:n,dispatch:i})=>{if(n.readOnly)return!1;let r=t(e,n);return!!r&&(i(n.update(r)),!0)}}const et=tt(lt,0),nt=tt(ot,0),it=tt(((t,e)=>ot(t,e,function(t){let e=[];for(let n of t.selection.ranges){let i=t.doc.lineAt(n.from),r=n.to<=i.to?i:t.doc.lineAt(n.to);r.from>i.from&&r.from==n.to&&(r=n.to==i.to+1?i:t.doc.lineAt(n.to-1));let s=e.length-1;s>=0&&e[s].to>i.from?e[s].to=r.to:e.push({from:i.from+/^\s*/.exec(i.text)[0].length,to:r.to})}return e}(e))),0);function rt(t,e){let n=t.languageDataAt("commentTokens",e);return n.length?n[0]:{}}const st=50;function ot(t,e,n=e.selection.ranges){let i=n.map((t=>rt(e,t.from).block));if(!i.every((t=>t)))return null;let r=n.map(((t,n)=>function(t,{open:e,close:n},i,r){let s,o,l=t.sliceDoc(i-st,i),h=t.sliceDoc(r,r+st),c=/\s*$/.exec(l)[0].length,u=/^\s*/.exec(h)[0].length,a=l.length-c;if(l.slice(a-e.length,a)==e&&h.slice(u,u+n.length)==n)return{open:{pos:i-c,margin:c&&1},close:{pos:r+u,margin:u&&1}};r-i<=2*st?s=o=t.sliceDoc(i,r):(s=t.sliceDoc(i,i+st),o=t.sliceDoc(r-st,r));let f=/^\s*/.exec(s)[0].length,d=/\s*$/.exec(o)[0].length,p=o.length-d-n.length;return s.slice(f,f+e.length)==e&&o.slice(p,p+n.length)==n?{open:{pos:i+f+e.length,margin:/\s/.test(s.charAt(f+e.length))?1:0},close:{pos:r-d-n.length,margin:/\s/.test(o.charAt(p-1))?1:0}}:null}(e,i[n],t.from,t.to)));if(2!=t&&!r.every((t=>t)))return{changes:e.changes(n.map(((t,e)=>r[e]?[]:[{from:t.from,insert:i[e].open+" "},{from:t.to,insert:" "+i[e].close}])))};if(1!=t&&r.some((t=>t))){let t=[];for(let e,n=0;n<r.length;n++)if(e=r[n]){let r=i[n],{open:s,close:o}=e;t.push({from:s.pos-r.open.length,to:s.pos+s.margin},{from:o.pos-o.margin,to:o.pos+r.close.length})}return{changes:t}}return null}function lt(t,e,n=e.selection.ranges){let i=[],r=-1;for(let{from:t,to:s}of n){let n=i.length,o=1e9,l=rt(e,t).line;if(l){for(let n=t;n<=s;){let h=e.doc.lineAt(n);if(h.from>r&&(t==s||s>h.from)){r=h.from;let t=/^\s*/.exec(h.text)[0].length,e=t==h.length,n=h.text.slice(t,t+l.length)==l?t:-1;t<h.text.length&&t<o&&(o=t),i.push({line:h,comment:n,token:l,indent:t,empty:e,single:!1})}n=h.to+1}if(o<1e9)for(let t=n;t<i.length;t++)i[t].indent<i[t].line.text.length&&(i[t].indent=o);i.length==n+1&&(i[n].single=!0)}}if(2!=t&&i.some((t=>t.comment<0&&(!t.empty||t.single)))){let t=[];for(let{line:e,token:n,indent:r,empty:s,single:o}of i)!o&&s||t.push({from:e.from+r,insert:n+" "});let n=e.changes(t);return{changes:n,selection:e.selection.map(n,1)}}if(1!=t&&i.some((t=>t.comment>=0))){let t=[];for(let{line:e,comment:n,token:r}of i)if(n>=0){let i=e.from+n,s=i+r.length;" "==e.text[s-e.from]&&s++,t.push({from:i,to:s})}return{changes:t}}return null}const ht=p.define(),ct=p.define(),ut=e.define(),at=e.define({combine:t=>n(t,{minDepth:100,newGroupDelay:500,joinToEvent:(t,e)=>e},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(t,e)=>(n,i)=>t(n,i)||e(n,i)})}),ft=i.define({create:()=>Ct.empty,update(t,e){let n=e.state.facet(at),i=e.annotation(ht);if(i){let r=vt.fromTransaction(e,i.selection),s=i.side,o=0==s?t.undone:t.done;return o=r?yt(o,o.length,n.minDepth,r):Mt(o,e.startState.selection),new Ct(0==s?i.rest:o,0==s?o:i.rest)}let s=e.annotation(ct);if("full"!=s&&"before"!=s||(t=t.isolate()),!1===e.annotation(r.addToHistory))return e.changes.empty?t:t.addMapping(e.changes.desc);let o=vt.fromTransaction(e),l=e.annotation(r.time),h=e.annotation(r.userEvent);return o?t=t.addChanges(o,l,h,n,e):e.selection&&(t=t.addSelection(e.startState.selection,l,h,n.newGroupDelay)),"full"!=s&&"after"!=s||(t=t.isolate()),t},toJSON:t=>({done:t.done.map((t=>t.toJSON())),undone:t.undone.map((t=>t.toJSON()))}),fromJSON:t=>new Ct(t.done.map(vt.fromJSON),t.undone.map(vt.fromJSON))});function dt(t,e){return function({state:n,dispatch:i}){if(!e&&n.readOnly)return!1;let r=n.field(ft,!1);if(!r)return!1;let s=r.pop(t,n,e);return!!s&&(i(s),!0)}}const pt=dt(0,!1),mt=dt(1,!1),gt=dt(0,!0),wt=dt(1,!0);class vt{constructor(t,e,n,i,r){this.changes=t,this.effects=e,this.mapped=n,this.startSelection=i,this.selectionsAfter=r}setSelAfter(t){return new vt(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){var t,e,n;return{changes:null===(t=this.changes)||void 0===t?void 0:t.toJSON(),mapped:null===(e=this.mapped)||void 0===e?void 0:e.toJSON(),startSelection:null===(n=this.startSelection)||void 0===n?void 0:n.toJSON(),selectionsAfter:this.selectionsAfter.map((t=>t.toJSON()))}}static fromJSON(t){return new vt(t.changes&&s.fromJSON(t.changes),[],t.mapped&&o.fromJSON(t.mapped),t.startSelection&&l.fromJSON(t.startSelection),t.selectionsAfter.map(l.fromJSON))}static fromTransaction(t,e){let n=kt;for(let e of t.startState.facet(ut)){let i=e(t);i.length&&(n=n.concat(i))}return!n.length&&t.changes.empty?null:new vt(t.changes.invert(t.startState.doc),n,void 0,e||t.startState.selection,kt)}static selection(t){return new vt(void 0,kt,void 0,void 0,t)}}function yt(t,e,n,i){let r=e+1>n+20?e-n-1:0,s=t.slice(r,e);return s.push(i),s}function bt(t,e){return t.length?e.length?t.concat(e):t:e}const kt=[],xt=200;function Mt(t,e){if(t.length){let n=t[t.length-1],i=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-xt));return i.length&&i[i.length-1].eq(e)?t:(i.push(e),yt(t,t.length-1,1e9,n.setSelAfter(i)))}return[vt.selection([e])]}function It(t){let e=t[t.length-1],n=t.slice();return n[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),n}function At(t,e){if(!t.length)return t;let n=t.length,i=kt;for(;n;){let r=St(t[n-1],e,i);if(r.changes&&!r.changes.empty||r.effects.length){let e=t.slice(0,n);return e[n-1]=r,e}e=r.mapped,n--,i=r.selectionsAfter}return i.length?[vt.selection(i)]:kt}function St(t,e,n){let i=bt(t.selectionsAfter.length?t.selectionsAfter.map((t=>t.map(e))):kt,n);if(!t.changes)return vt.selection(i);let r=t.changes.map(e),s=e.mapDesc(t.changes,!0),o=t.mapped?t.mapped.composeDesc(s):s;return new vt(r,h.mapEffects(t.effects,e),o,t.startSelection.map(s),i)}const Dt=/^(input\.type|delete)($|\.)/;class Ct{constructor(t,e,n=0,i=void 0){this.done=t,this.undone=e,this.prevTime=n,this.prevUserEvent=i}isolate(){return this.prevTime?new Ct(this.done,this.undone):this}addChanges(t,e,n,i,r){let s=this.done,o=s[s.length-1];return s=o&&o.changes&&!o.changes.empty&&t.changes&&(!n||Dt.test(n))&&(!o.selectionsAfter.length&&e-this.prevTime<i.newGroupDelay&&i.joinToEvent(r,function(t,e){let n=[],i=!1;return t.iterChangedRanges(((t,e)=>n.push(t,e))),e.iterChangedRanges(((t,e,r,s)=>{for(let t=0;t<n.length;){let e=n[t++],o=n[t++];s>=e&&r<=o&&(i=!0)}})),i}(o.changes,t.changes))||"input.type.compose"==n)?yt(s,s.length-1,i.minDepth,new vt(t.changes.compose(o.changes),bt(h.mapEffects(t.effects,o.changes),o.effects),o.mapped,o.startSelection,kt)):yt(s,s.length,i.minDepth,t),new Ct(s,kt,e,n)}addSelection(t,e,n,i){let r=this.done.length?this.done[this.done.length-1].selectionsAfter:kt;return r.length>0&&e-this.prevTime<i&&n==this.prevUserEvent&&n&&/^select($|\.)/.test(n)&&(s=r[r.length-1],o=t,s.ranges.length==o.ranges.length&&0===s.ranges.filter(((t,e)=>t.empty!=o.ranges[e].empty)).length)?this:new Ct(Mt(this.done,t),this.undone,e,n);var s,o}addMapping(t){return new Ct(At(this.done,t),At(this.undone,t),this.prevTime,this.prevUserEvent)}pop(t,e,n){let i=0==t?this.done:this.undone;if(0==i.length)return null;let r=i[i.length-1],s=r.selectionsAfter[0]||e.selection;if(n&&r.selectionsAfter.length)return e.update({selection:r.selectionsAfter[r.selectionsAfter.length-1],annotations:ht.of({side:t,rest:It(i),selection:s}),userEvent:0==t?"select.undo":"select.redo",scrollIntoView:!0});if(r.changes){let n=1==i.length?kt:i.slice(0,i.length-1);return r.mapped&&(n=At(n,r.mapped)),e.update({changes:r.changes,selection:r.startSelection,effects:r.effects,annotations:ht.of({side:t,rest:n,selection:s}),filter:!1,userEvent:0==t?"undo":"redo",scrollIntoView:!0})}return null}}Ct.empty=new Ct(kt,kt);const Et=[{key:"Mod-z",run:pt,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:mt,preventDefault:!0},{linux:"Ctrl-Shift-z",run:mt,preventDefault:!0},{key:"Mod-u",run:gt,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:wt,preventDefault:!0}];function Rt(t,e){return l.create(t.ranges.map(e),t.mainIndex)}function $t(t,e){return t.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function Ot({state:t,dispatch:e},n){let i=Rt(t.selection,n);return!i.eq(t.selection,!0)&&(e($t(t,i)),!0)}function Lt(t,e){return l.cursor(e?t.to:t.from)}function Tt(t,e){return Ot(t,(n=>n.empty?t.moveByChar(n,e):Lt(n,e)))}function Bt(t){return t.textDirectionAt(t.state.selection.main.head)==b.LTR}const jt=t=>Tt(t,!Bt(t)),Vt=t=>Tt(t,Bt(t));function Pt(t,e){return Ot(t,(n=>n.empty?t.moveByGroup(n,e):Lt(n,e)))}function Ft(t,e,n){if(e.type.prop(n))return!0;let i=e.to-e.from;return i&&(i>2||/[^\s,.;:]/.test(t.sliceDoc(e.from,e.to)))||e.firstChild}function Wt(t,e,n){let i,r,s=g(t).resolveInner(e.head),o=n?w.closedBy:w.openedBy;for(let i=e.head;;){let e=n?s.childAfter(i):s.childBefore(i);if(!e)break;Ft(t,e,o)?s=e:i=n?e.to:e.from}return r=s.type.prop(o)&&(i=n?m(t,s.from,1):m(t,s.to,-1))&&i.matched?n?i.end.to:i.end.from:n?s.to:s.from,l.cursor(r,n?-1:1)}function zt(t,e){return Ot(t,(n=>{if(!n.empty)return Lt(n,e);let i=t.moveVertically(n,e);return i.head!=n.head?i:t.moveToLineBoundary(n,e)}))}const Ut=t=>zt(t,!1),qt=t=>zt(t,!0);function Ht(e){let n,i=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,r=0,s=0;if(i){for(let n of e.state.facet(t.scrollMargins)){let t=n(e);(null==t?void 0:t.top)&&(r=Math.max(null==t?void 0:t.top,r)),(null==t?void 0:t.bottom)&&(s=Math.max(null==t?void 0:t.bottom,s))}n=e.scrollDOM.clientHeight-r-s}else n=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:r,marginBottom:s,selfScroll:i,height:Math.max(e.defaultLineHeight,n-5)}}function Nt(e,n){let i,r=Ht(e),{state:s}=e,o=Rt(s.selection,(t=>t.empty?e.moveVertically(t,n,r.height):Lt(t,n)));if(o.eq(s.selection))return!1;if(r.selfScroll){let n=e.coordsAtPos(s.selection.main.head),l=e.scrollDOM.getBoundingClientRect(),h=l.top+r.marginTop,c=l.bottom-r.marginBottom;n&&n.top>h&&n.bottom<c&&(i=t.scrollIntoView(o.main.head,{y:"start",yMargin:n.top-h}))}return e.dispatch($t(s,o),{effects:i}),!0}const Jt=t=>Nt(t,!1),_t=t=>Nt(t,!0);function Gt(t,e,n){let i=t.lineBlockAt(e.head),r=t.moveToLineBoundary(e,n);if(r.head==e.head&&r.head!=(n?i.to:i.from)&&(r=t.moveToLineBoundary(e,n,!1)),!n&&r.head==i.from&&i.length){let n=/^\s*/.exec(t.state.sliceDoc(i.from,Math.min(i.from+100,i.to)))[0].length;n&&e.head!=i.from+n&&(r=l.cursor(i.from+n))}return r}function Kt(t,e){let n=Rt(t.state.selection,(t=>{let n=e(t);return l.range(t.anchor,n.head,n.goalColumn,n.bidiLevel||void 0)}));return!n.eq(t.state.selection)&&(t.dispatch($t(t.state,n)),!0)}function Qt(t,e){return Kt(t,(n=>t.moveByChar(n,e)))}const Xt=t=>Qt(t,!Bt(t)),Yt=t=>Qt(t,Bt(t));function Zt(t,e){return Kt(t,(n=>t.moveByGroup(n,e)))}function te(t,e){return Kt(t,(n=>t.moveVertically(n,e)))}const ee=t=>te(t,!1),ne=t=>te(t,!0);function ie(t,e){return Kt(t,(n=>t.moveVertically(n,e,Ht(t).height)))}const re=t=>ie(t,!1),se=t=>ie(t,!0),oe=({state:t,dispatch:e})=>(e($t(t,{anchor:0})),!0),le=({state:t,dispatch:e})=>(e($t(t,{anchor:t.doc.length})),!0),he=({state:t,dispatch:e})=>(e($t(t,{anchor:t.selection.main.anchor,head:0})),!0),ce=({state:t,dispatch:e})=>(e($t(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0);function ue(e,n){if(e.state.readOnly)return!1;let i="delete.selection",{state:r}=e,s=r.changeByRange((t=>{let{from:r,to:s}=t;if(r==s){let o=n(t);o<r?(i="delete.backward",o=ae(e,o,!1)):o>r&&(i="delete.forward",o=ae(e,o,!0)),r=Math.min(r,o),s=Math.max(s,o)}else r=ae(e,r,!1),s=ae(e,s,!0);return r==s?{range:t}:{changes:{from:r,to:s},range:l.cursor(r,r<t.head?-1:1)}}));return!s.changes.empty&&(e.dispatch(r.update(s,{scrollIntoView:!0,userEvent:i,effects:"delete.selection"==i?t.announce.of(r.phrase("Selection deleted")):void 0})),!0)}function ae(e,n,i){if(e instanceof t)for(let r of e.state.facet(t.atomicRanges).map((t=>t(e))))r.between(n,n,((t,e)=>{t<n&&e>n&&(n=i?e:t)}));return n}const fe=(t,e,n)=>ue(t,(i=>{let r,s,o=i.from,{state:l}=t,h=l.doc.lineAt(o);if(n&&!e&&o>h.from&&o<h.from+200&&!/[^ \t]/.test(r=h.text.slice(0,o-h.from))){if("\t"==r[r.length-1])return o-1;let t=a(r,l.tabSize)%y(l)||y(l);for(let e=0;e<t&&" "==r[r.length-1-e];e++)o--;s=o}else s=k(h.text,o-h.from,e,e)+h.from,s==o&&h.number!=(e?l.doc.lines:1)?s+=e?1:-1:!e&&/[\ufe00-\ufe0f]/.test(h.text.slice(s-h.from,o-h.from))&&(s=k(h.text,s-h.from,!1,!1)+h.from);return s})),de=t=>fe(t,!1,!0),pe=t=>fe(t,!0,!1),me=(t,e)=>ue(t,(n=>{let i=n.head,{state:r}=t,s=r.doc.lineAt(i),o=r.charCategorizer(i);for(let t=null;;){if(i==(e?s.to:s.from)){i==n.head&&s.number!=(e?r.doc.lines:1)&&(i+=e?1:-1);break}let l=k(s.text,i-s.from,e)+s.from,h=s.text.slice(Math.min(i,l)-s.from,Math.max(i,l)-s.from),c=o(h);if(null!=t&&c!=t)break;" "==h&&i==n.head||(t=c),i=l}return i})),ge=t=>me(t,!1);function we(t){let e=[],n=-1;for(let i of t.selection.ranges){let r=t.doc.lineAt(i.from),s=t.doc.lineAt(i.to);if(i.empty||i.to!=s.from||(s=t.doc.lineAt(i.to-1)),n>=r.number){let t=e[e.length-1];t.to=s.to,t.ranges.push(i)}else e.push({from:r.from,to:s.to,ranges:[i]});n=s.number+1}return e}function ve(t,e,n){if(t.readOnly)return!1;let i=[],r=[];for(let e of we(t)){if(n?e.to==t.doc.length:0==e.from)continue;let s=t.doc.lineAt(n?e.to+1:e.from-1),o=s.length+1;if(n){i.push({from:e.to,to:s.to},{from:e.from,insert:s.text+t.lineBreak});for(let n of e.ranges)r.push(l.range(Math.min(t.doc.length,n.anchor+o),Math.min(t.doc.length,n.head+o)))}else{i.push({from:s.from,to:e.from},{from:e.to,insert:t.lineBreak+s.text});for(let t of e.ranges)r.push(l.range(t.anchor-o,t.head-o))}}return!!i.length&&(e(t.update({changes:i,scrollIntoView:!0,selection:l.create(r,t.selection.mainIndex),userEvent:"move.line"})),!0)}function ye(t,e,n){if(t.readOnly)return!1;let i=[];for(let e of we(t))n?i.push({from:e.from,insert:t.doc.slice(e.from,e.to)+t.lineBreak}):i.push({from:e.to,insert:t.lineBreak+t.doc.slice(e.from,e.to)});return e(t.update({changes:i,scrollIntoView:!0,userEvent:"input.copyline"})),!0}const be=ke(!1);function ke(t){return({state:e,dispatch:n})=>{if(e.readOnly)return!1;let i=e.changeByRange((n=>{let{from:i,to:r}=n,s=e.doc.lineAt(i),o=!t&&i==r&&function(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let n,i=g(t).resolveInner(e),r=i.childBefore(e),s=i.childAfter(e);return r&&s&&r.to<=e&&s.from>=e&&(n=r.type.prop(w.closedBy))&&n.indexOf(s.name)>-1&&t.doc.lineAt(r.to).from==t.doc.lineAt(s.from).from&&!/\S/.test(t.sliceDoc(r.to,s.from))?{from:r.to,to:s.from}:null}(e,i);t&&(i=r=(r<=s.to?s:e.doc.lineAt(r)).to);let h=new c(e,{simulateBreak:i,simulateDoubleBreak:!!o}),p=u(h,i);for(null==p&&(p=a(/^\s*/.exec(e.doc.lineAt(i).text)[0],e.tabSize));r<s.to&&/\s/.test(s.text[r-s.from]);)r++;o?({from:i,to:r}=o):i>s.from&&i<s.from+100&&!/\S/.test(s.text.slice(0,i))&&(i=s.from);let m=["",f(e,p)];return o&&m.push(f(e,h.lineIndent(s.from,-1))),{changes:{from:i,to:r,insert:d.of(m)},range:l.cursor(i+1+m[1].length)}}));return n(e.update(i,{scrollIntoView:!0,userEvent:"input"})),!0}}function xe(t,e){let n=-1;return t.changeByRange((i=>{let r=[];for(let s=i.from;s<=i.to;){let o=t.doc.lineAt(s);o.number>n&&(i.empty||i.to>o.from)&&(e(o,r,i),n=o.number),s=o.to+1}let s=t.changes(r);return{changes:r,range:l.range(s.mapPos(i.anchor,1),s.mapPos(i.head,1))}}))}const Me=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:t=>Ot(t,(e=>Wt(t.state,e,!Bt(t)))),shift:t=>Kt(t,(e=>Wt(t.state,e,!Bt(t))))},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:t=>Ot(t,(e=>Wt(t.state,e,Bt(t)))),shift:t=>Kt(t,(e=>Wt(t.state,e,Bt(t))))},{key:"Alt-ArrowUp",run:({state:t,dispatch:e})=>ve(t,e,!1)},{key:"Shift-Alt-ArrowUp",run:({state:t,dispatch:e})=>ye(t,e,!1)},{key:"Alt-ArrowDown",run:({state:t,dispatch:e})=>ve(t,e,!0)},{key:"Shift-Alt-ArrowDown",run:({state:t,dispatch:e})=>ye(t,e,!0)},{key:"Escape",run:({state:t,dispatch:e})=>{let n=t.selection,i=null;return n.ranges.length>1?i=l.create([n.main]):n.main.empty||(i=l.create([l.cursor(n.main.head)])),!!i&&(e($t(t,i)),!0)}},{key:"Mod-Enter",run:ke(!0)},{key:"Alt-l",mac:"Ctrl-l",run:({state:t,dispatch:e})=>{let n=we(t).map((({from:e,to:n})=>l.range(e,Math.min(n+1,t.doc.length))));return e(t.update({selection:l.create(n),userEvent:"select"})),!0}},{key:"Mod-i",run:({state:t,dispatch:e})=>{let n=Rt(t.selection,(e=>{let n=g(t),i=n.resolveStack(e.from,1);if(e.empty){let t=n.resolveStack(e.from,-1);t.node.from>=i.node.from&&t.node.to<=i.node.to&&(i=t)}for(let t=i;t;t=t.next){let{node:n}=t;if((n.from<e.from&&n.to>=e.to||n.to>e.to&&n.from<=e.from)&&t.next)return l.range(n.to,n.from)}return e}));return!n.eq(t.selection)&&(e($t(t,n)),!0)},preventDefault:!0},{key:"Mod-[",run:({state:t,dispatch:e})=>!t.readOnly&&(e(t.update(xe(t,((e,n)=>{let i=/^\s*/.exec(e.text)[0];if(!i)return;let r=a(i,t.tabSize),s=0,o=f(t,Math.max(0,r-y(t)));for(;s<i.length&&s<o.length&&i.charCodeAt(s)==o.charCodeAt(s);)s++;n.push({from:e.from+s,to:e.from+i.length,insert:o.slice(s)})})),{userEvent:"delete.dedent"})),!0)},{key:"Mod-]",run:({state:t,dispatch:e})=>!t.readOnly&&(e(t.update(xe(t,((e,n)=>{n.push({from:e.from,insert:t.facet(v)})})),{userEvent:"input.indent"})),!0)},{key:"Mod-Alt-\\",run:({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=Object.create(null),i=new c(t,{overrideIndentation:t=>{let e=n[t];return null==e?-1:e}}),r=xe(t,((e,r,s)=>{let o=u(i,e.from);if(null==o)return;/\S/.test(e.text)||(o=0);let l=/^\s*/.exec(e.text)[0],h=f(t,o);(l!=h||s.from<e.from+l.length)&&(n[e.from]=o,r.push({from:e.from,to:e.from+l.length,insert:h}))}));return r.changes.empty||e(t.update(r,{userEvent:"indent"})),!0}},{key:"Shift-Mod-k",run:t=>{if(t.state.readOnly)return!1;let{state:e}=t,n=e.changes(we(e).map((({from:t,to:n})=>(t>0?t--:n<e.doc.length&&n++,{from:t,to:n})))),i=Rt(e.selection,(e=>{let n;if(t.lineWrapping){let i=t.lineBlockAt(e.head),r=t.coordsAtPos(e.head,e.assoc||1);r&&(n=i.bottom+t.documentTop-r.bottom+t.defaultLineHeight/2)}return t.moveVertically(e,!0,n)})).map(n);return t.dispatch({changes:n,selection:i,scrollIntoView:!0,userEvent:"delete.line"}),!0}},{key:"Shift-Mod-\\",run:({state:t,dispatch:e})=>function(t,e,n){let i=!1,r=Rt(t.selection,(e=>{let r=m(t,e.head,-1)||m(t,e.head,1)||e.head>0&&m(t,e.head-1,1)||e.head<t.doc.length&&m(t,e.head+1,-1);if(!r||!r.end)return e;i=!0;let s=r.start.from==e.head?r.end.to:r.end.from;return n?l.range(e.anchor,s):l.cursor(s)}));return!!i&&(e($t(t,r)),!0)}(t,e,!1)},{key:"Mod-/",run:t=>{let{state:e}=t,n=e.doc.lineAt(e.selection.main.from),i=rt(t.state,n.from);return i.line?et(t):!!i.block&&it(t)}},{key:"Alt-A",run:nt},{key:"Ctrl-m",mac:"Shift-Alt-m",run:t=>(t.setTabFocusMode(),!0)}].concat([{key:"ArrowLeft",run:jt,shift:Xt,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:t=>Pt(t,!Bt(t)),shift:t=>Zt(t,!Bt(t)),preventDefault:!0},{mac:"Cmd-ArrowLeft",run:t=>Ot(t,(e=>Gt(t,e,!Bt(t)))),shift:t=>Kt(t,(e=>Gt(t,e,!Bt(t)))),preventDefault:!0},{key:"ArrowRight",run:Vt,shift:Yt,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:t=>Pt(t,Bt(t)),shift:t=>Zt(t,Bt(t)),preventDefault:!0},{mac:"Cmd-ArrowRight",run:t=>Ot(t,(e=>Gt(t,e,Bt(t)))),shift:t=>Kt(t,(e=>Gt(t,e,Bt(t)))),preventDefault:!0},{key:"ArrowUp",run:Ut,shift:ee,preventDefault:!0},{mac:"Cmd-ArrowUp",run:oe,shift:he},{mac:"Ctrl-ArrowUp",run:Jt,shift:re},{key:"ArrowDown",run:qt,shift:ne,preventDefault:!0},{mac:"Cmd-ArrowDown",run:le,shift:ce},{mac:"Ctrl-ArrowDown",run:_t,shift:se},{key:"PageUp",run:Jt,shift:re},{key:"PageDown",run:_t,shift:se},{key:"Home",run:t=>Ot(t,(e=>Gt(t,e,!1))),shift:t=>Kt(t,(e=>Gt(t,e,!1))),preventDefault:!0},{key:"Mod-Home",run:oe,shift:he},{key:"End",run:t=>Ot(t,(e=>Gt(t,e,!0))),shift:t=>Kt(t,(e=>Gt(t,e,!0))),preventDefault:!0},{key:"Mod-End",run:le,shift:ce},{key:"Enter",run:be,shift:be},{key:"Mod-a",run:({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0)},{key:"Backspace",run:de,shift:de},{key:"Delete",run:pe},{key:"Mod-Backspace",mac:"Alt-Backspace",run:ge},{key:"Mod-Delete",mac:"Alt-Delete",run:t=>me(t,!0)},{mac:"Mod-Backspace",run:t=>ue(t,(e=>{let n=t.moveToLineBoundary(e,!1).head;return e.head>n?n:Math.max(0,e.head-1)}))},{mac:"Mod-Delete",run:t=>ue(t,(e=>{let n=t.moveToLineBoundary(e,!0).head;return e.head<n?n:Math.min(t.state.doc.length,e.head+1)}))}].concat([{key:"Ctrl-b",run:jt,shift:Xt,preventDefault:!0},{key:"Ctrl-f",run:Vt,shift:Yt},{key:"Ctrl-p",run:Ut,shift:ee},{key:"Ctrl-n",run:qt,shift:ne},{key:"Ctrl-a",run:t=>Ot(t,(e=>l.cursor(t.lineBlockAt(e.head).from,1))),shift:t=>Kt(t,(e=>l.cursor(t.lineBlockAt(e.head).from)))},{key:"Ctrl-e",run:t=>Ot(t,(e=>l.cursor(t.lineBlockAt(e.head).to,-1))),shift:t=>Kt(t,(e=>l.cursor(t.lineBlockAt(e.head).to)))},{key:"Ctrl-d",run:pe},{key:"Ctrl-h",run:de},{key:"Ctrl-k",run:t=>ue(t,(e=>{let n=t.lineBlockAt(e.head).to;return e.head<n?n:Math.min(t.state.doc.length,e.head+1)}))},{key:"Ctrl-Alt-h",run:ge},{key:"Ctrl-o",run:({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=t.changeByRange((t=>({changes:{from:t.from,to:t.to,insert:d.of(["",""])},range:l.cursor(t.from)})));return e(t.update(n,{scrollIntoView:!0,userEvent:"input"})),!0}},{key:"Ctrl-t",run:({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=t.changeByRange((e=>{if(!e.empty||0==e.from||e.from==t.doc.length)return{range:e};let n=e.from,i=t.doc.lineAt(n),r=n==i.from?n-1:k(i.text,n-i.from,!1)+i.from,s=n==i.to?n+1:k(i.text,n-i.from,!0)+i.from;return{changes:{from:r,to:s,insert:t.doc.slice(n,s).append(t.doc.slice(r,n))},range:l.cursor(s)}}));return!n.changes.empty&&(e(t.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)}},{key:"Ctrl-v",run:_t}].map((t=>({mac:t.key,run:t.run,shift:t.shift})))));function Ie(){var t=arguments[0];"string"==typeof t&&(t=document.createElement(t));var e=1,n=arguments[1];if(n&&"object"==typeof n&&null==n.nodeType&&!Array.isArray(n)){for(var i in n)if(Object.prototype.hasOwnProperty.call(n,i)){var r=n[i];"string"==typeof r?t.setAttribute(i,r):null!=r&&(t[i]=r)}e++}for(;e<arguments.length;e++)Ae(t,arguments[e]);return t}function Ae(t,e){if("string"==typeof e)t.appendChild(document.createTextNode(e));else if(null==e);else if(null!=e.nodeType)t.appendChild(e);else{if(!Array.isArray(e))throw new RangeError("Unsupported child node: "+e);for(var n=0;n<e.length;n++)Ae(t,e[n])}}const Se="function"==typeof String.prototype.normalize?t=>t.normalize("NFKD"):t=>t;class De{constructor(t,e,n=0,i=t.length,r,s){this.test=s,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=t.iterRange(n,i),this.bufferStart=n,this.normalize=r?t=>r(Se(t)):Se,this.query=this.normalize(e)}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 I(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let t=this.peek();if(t<0)return this.done=!0,this;let e=E(t),n=this.bufferStart+this.bufferPos;this.bufferPos+=A(t);let i=this.normalize(e);if(i.length)for(let t=0,r=n;;t++){let s=i.charCodeAt(t),o=this.match(s,r,this.bufferPos+this.bufferStart);if(t==i.length-1){if(o)return this.value=o,this;break}r==n&&t<e.length&&e.charCodeAt(t)==s&&r++}}}match(t,e,n){let i=null;for(let e=0;e<this.matches.length;e+=2){let r=this.matches[e],s=!1;this.query.charCodeAt(r)==t&&(r==this.query.length-1?i={from:this.matches[e+1],to:n}:(this.matches[e]++,s=!0)),s||(this.matches.splice(e,2),e-=2)}return this.query.charCodeAt(0)==t&&(1==this.query.length?i={from:e,to:n}:this.matches.push(1,e)),i&&this.test&&!this.test(i.from,i.to,this.buffer,this.bufferStart)&&(i=null),i}}"undefined"!=typeof Symbol&&(De.prototype[Symbol.iterator]=function(){return this});const Ce={from:-1,to:-1,match:/.*/.exec("")},Ee="gm"+(null==/x/.unicode?"":"u");class Re{constructor(t,e,n,i=0,r=t.length){if(this.text=t,this.to=r,this.curLine="",this.done=!1,this.value=Ce,/\\[sWDnr]|\n|\r|\[\^/.test(e))return new Le(t,e,n,i,r);this.re=new RegExp(e,Ee+((null==n?void 0:n.ignoreCase)?"i":"")),this.test=null==n?void 0:n.test,this.iter=t.iter();let s=t.lineAt(i);this.curLineStart=s.from,this.matchPos=Te(t,i),this.getLine(this.curLineStart)}getLine(t){this.iter.next(t),this.iter.lineBreak?this.curLine="":(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(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let t=this.matchPos-this.curLineStart;;){this.re.lastIndex=t;let e=this.matchPos<=this.to&&this.re.exec(this.curLine);if(e){let n=this.curLineStart+e.index,i=n+e[0].length;if(this.matchPos=Te(this.text,i+(n==i?1:0)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<i||n>this.value.to)&&(!this.test||this.test(n,i,e)))return this.value={from:n,to:i,match:e},this;t=this.matchPos-this.curLineStart}else{if(!(this.curLineStart+this.curLine.length<this.to))return this.done=!0,this;this.nextLine(),t=0}}}}const $e=new WeakMap;class Oe{constructor(t,e){this.from=t,this.text=e}get to(){return this.from+this.text.length}static get(t,e,n){let i=$e.get(t);if(!i||i.from>=n||i.to<=e){let i=new Oe(e,t.sliceString(e,n));return $e.set(t,i),i}if(i.from==e&&i.to==n)return i;let{text:r,from:s}=i;return s>e&&(r=t.sliceString(e,s)+r,s=e),i.to<n&&(r+=t.sliceString(i.to,n)),$e.set(t,new Oe(s,r)),new Oe(e,r.slice(e-s,n-s))}}class Le{constructor(t,e,n,i,r){this.text=t,this.to=r,this.done=!1,this.value=Ce,this.matchPos=Te(t,i),this.re=new RegExp(e,Ee+((null==n?void 0:n.ignoreCase)?"i":"")),this.test=null==n?void 0:n.test,this.flat=Oe.get(t,i,this.chunkEnd(i+5e3))}chunkEnd(t){return t>=this.to?this.to:this.text.lineAt(t).to}next(){for(;;){let t=this.re.lastIndex=this.matchPos-this.flat.from,e=this.re.exec(this.flat.text);if(e&&!e[0]&&e.index==t&&(this.re.lastIndex=t+1,e=this.re.exec(this.flat.text)),e){let t=this.flat.from+e.index,n=t+e[0].length;if((this.flat.to>=this.to||e.index+e[0].length<=this.flat.text.length-10)&&(!this.test||this.test(t,n,e)))return this.value={from:t,to:n,match:e},this.matchPos=Te(this.text,n+(t==n?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=Oe.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+2*this.flat.text.length))}}}function Te(t,e){if(e>=t.length)return e;let n,i=t.lineAt(e);for(;e<i.to&&(n=i.text.charCodeAt(e-i.from))>=56320&&n<57344;)e++;return e}function Be(e){let n=Ie("input",{class:"cm-textfield",name:"line",value:String(e.state.doc.lineAt(e.state.selection.main.head).number)});function i(){let i=/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(n.value);if(!i)return;let{state:r}=e,s=r.doc.lineAt(r.selection.main.head),[,o,h,c,u]=i,a=c?+c.slice(1):0,f=h?+h:s.number;if(h&&u){let t=f/100;o&&(t=t*("-"==o?-1:1)+s.number/r.doc.lines),f=Math.round(r.doc.lines*t)}else h&&o&&(f=f*("-"==o?-1:1)+s.number);let d=r.doc.line(Math.max(1,Math.min(r.doc.lines,f))),p=l.cursor(d.from+Math.max(0,Math.min(a,d.length)));e.dispatch({effects:[je.of(!1),t.scrollIntoView(p.from,{y:"center"})],selection:p}),e.focus()}return{dom:Ie("form",{class:"cm-gotoLine",onkeydown:t=>{27==t.keyCode?(t.preventDefault(),e.dispatch({effects:je.of(!1)}),e.focus()):13==t.keyCode&&(t.preventDefault(),i())},onsubmit:t=>{t.preventDefault(),i()}},Ie("label",e.state.phrase("Go to line"),": ",n)," ",Ie("button",{class:"cm-button",type:"submit"},e.state.phrase("go")))}}"undefined"!=typeof Symbol&&(Re.prototype[Symbol.iterator]=Le.prototype[Symbol.iterator]=function(){return this});const je=h.define(),Ve=i.define({create:()=>!0,update(t,e){for(let n of e.effects)n.is(je)&&(t=n.value);return t},provide:t=>R.from(t,(t=>t?Be:null))}),Pe=t.baseTheme({".cm-panel.cm-gotoLine":{padding:"2px 6px 4px","& label":{fontSize:"80%"}}}),Fe={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},We=e.define({combine:t=>n(t,Fe,{highlightWordAroundCursor:(t,e)=>t||e,minSelectionLength:Math.min,maxMatches:Math.min})});const ze=M.mark({class:"cm-selectionMatch"}),Ue=M.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function qe(t,e,n,i){return!(0!=n&&t(e.sliceDoc(n-1,n))==D.Word||i!=e.doc.length&&t(e.sliceDoc(i,i+1))==D.Word)}const He=x.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.selectionSet||t.docChanged||t.viewportChanged)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=t.state.facet(We),{state:n}=t,i=n.selection;if(i.ranges.length>1)return M.none;let r,s=i.main,o=null;if(s.empty){if(!e.highlightWordAroundCursor)return M.none;let t=n.wordAt(s.head);if(!t)return M.none;o=n.charCategorizer(s.head),r=n.sliceDoc(t.from,t.to)}else{let t=s.to-s.from;if(t<e.minSelectionLength||t>200)return M.none;if(e.wholeWords){if(r=n.sliceDoc(s.from,s.to),o=n.charCategorizer(s.head),!qe(o,n,s.from,s.to)||!function(t,e,n,i){return t(e.sliceDoc(n,n+1))==D.Word&&t(e.sliceDoc(i-1,i))==D.Word}(o,n,s.from,s.to))return M.none}else if(r=n.sliceDoc(s.from,s.to),!r)return M.none}let l=[];for(let i of t.visibleRanges){let t=new De(n.doc,r,i.from,i.to);for(;!t.next().done;){let{from:i,to:r}=t.value;if((!o||qe(o,n,i,r))&&(s.empty&&i<=s.from&&r>=s.to?l.push(Ue.range(i,r)):(i>=s.to||r<=s.from)&&l.push(ze.range(i,r)),l.length>e.maxMatches))return M.none}}return M.set(l)}},{decorations:t=>t.decorations}),Ne=t.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}});const Je=e.define({combine:e=>n(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:t=>new xn(t),scrollToMatch:e=>t.scrollIntoView(e)})});class _e{constructor(t){this.search=t.search,this.caseSensitive=!!t.caseSensitive,this.literal=!!t.literal,this.regexp=!!t.regexp,this.replace=t.replace||"",this.valid=!!this.search&&(!this.regexp||function(t){try{return new RegExp(t,Ee),!0}catch(t){return!1}}(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!t.wholeWord}unquote(t){return this.literal?t:t.replace(/\\([nrt\\])/g,((t,e)=>"n"==e?"\n":"r"==e?"\r":"t"==e?"\t":"\\"))}eq(t){return this.search==t.search&&this.replace==t.replace&&this.caseSensitive==t.caseSensitive&&this.regexp==t.regexp&&this.wholeWord==t.wholeWord}create(){return this.regexp?new tn(this):new Qe(this)}getCursor(t,e=0,n){let i=t.doc?t:$.create({doc:t});return null==n&&(n=i.doc.length),this.regexp?Xe(this,i,e,n):Ke(this,i,e,n)}}class Ge{constructor(t){this.spec=t}}function Ke(t,e,n,i){return new De(e.doc,t.unquoted,n,i,t.caseSensitive?void 0:t=>t.toLowerCase(),t.wholeWord?(r=e.doc,s=e.charCategorizer(e.selection.main.head),(t,e,n,i)=>((i>t||i+n.length<e)&&(i=Math.max(0,t-2),n=r.sliceString(i,Math.min(r.length,e+2))),!(s(Ye(n,t-i))==D.Word&&s(Ze(n,t-i))==D.Word||s(Ze(n,e-i))==D.Word&&s(Ye(n,e-i))==D.Word))):void 0);var r,s}class Qe extends Ge{constructor(t){super(t)}nextMatch(t,e,n){let i=Ke(this.spec,t,n,t.doc.length).nextOverlapping();if(i.done){let n=Math.min(t.doc.length,e+this.spec.unquoted.length);i=Ke(this.spec,t,0,n).nextOverlapping()}return i.done||i.value.from==e&&i.value.to==n?null:i.value}prevMatchInRange(t,e,n){for(let i=n;;){let n=Math.max(e,i-1e4-this.spec.unquoted.length),r=Ke(this.spec,t,n,i),s=null;for(;!r.nextOverlapping().done;)s=r.value;if(s)return s;if(n==e)return null;i-=1e4}}prevMatch(t,e,n){let i=this.prevMatchInRange(t,0,e);return i||(i=this.prevMatchInRange(t,Math.max(0,n-this.spec.unquoted.length),t.doc.length)),!i||i.from==e&&i.to==n?null:i}getReplacement(t){return this.spec.unquote(this.spec.replace)}matchAll(t,e){let n=Ke(this.spec,t,0,t.doc.length),i=[];for(;!n.next().done;){if(i.length>=e)return null;i.push(n.value)}return i}highlight(t,e,n,i){let r=Ke(this.spec,t,Math.max(0,e-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,t.doc.length));for(;!r.next().done;)i(r.value.from,r.value.to)}}function Xe(t,e,n,i){return new Re(e.doc,t.search,{ignoreCase:!t.caseSensitive,test:t.wholeWord?(r=e.charCategorizer(e.selection.main.head),(t,e,n)=>!n[0].length||(r(Ye(n.input,n.index))!=D.Word||r(Ze(n.input,n.index))!=D.Word)&&(r(Ze(n.input,n.index+n[0].length))!=D.Word||r(Ye(n.input,n.index+n[0].length))!=D.Word)):void 0},n,i);var r}function Ye(t,e){return t.slice(k(t,e,!1),e)}function Ze(t,e){return t.slice(e,k(t,e))}class tn extends Ge{nextMatch(t,e,n){let i=Xe(this.spec,t,n,t.doc.length).next();return i.done&&(i=Xe(this.spec,t,0,e).next()),i.done?null:i.value}prevMatchInRange(t,e,n){for(let i=1;;i++){let r=Math.max(e,n-1e4*i),s=Xe(this.spec,t,r,n),o=null;for(;!s.next().done;)o=s.value;if(o&&(r==e||o.from>r+10))return o;if(r==e)return null}}prevMatch(t,e,n){return this.prevMatchInRange(t,0,e)||this.prevMatchInRange(t,n,t.doc.length)}getReplacement(t){return this.spec.unquote(this.spec.replace).replace(/\$([$&\d+])/g,((e,n)=>"$"==n?"$":"&"==n?t.match[0]:"0"!=n&&+n<t.match.length?t.match[n]:e))}matchAll(t,e){let n=Xe(this.spec,t,0,t.doc.length),i=[];for(;!n.next().done;){if(i.length>=e)return null;i.push(n.value)}return i}highlight(t,e,n,i){let r=Xe(this.spec,t,Math.max(0,e-250),Math.min(n+250,t.doc.length));for(;!r.next().done;)i(r.value.from,r.value.to)}}const en=h.define(),nn=h.define(),rn=i.define({create:t=>new sn(gn(t).create(),null),update(t,e){for(let n of e.effects)n.is(en)?t=new sn(n.value.create(),t.panel):n.is(nn)&&(t=new sn(t.query,n.value?mn:null));return t},provide:t=>R.from(t,(t=>t.panel))});class sn{constructor(t,e){this.query=t,this.panel=e}}const on=M.mark({class:"cm-searchMatch"}),ln=M.mark({class:"cm-searchMatch cm-searchMatch-selected"}),hn=x.fromClass(class{constructor(t){this.view=t,this.decorations=this.highlight(t.state.field(rn))}update(t){let e=t.state.field(rn);(e!=t.startState.field(rn)||t.docChanged||t.selectionSet||t.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:t,panel:e}){if(!e||!t.spec.valid)return M.none;let{view:n}=this,i=new O;for(let e=0,r=n.visibleRanges,s=r.length;e<s;e++){let{from:o,to:l}=r[e];for(;e<s-1&&l>r[e+1].from-500;)l=r[++e].to;t.highlight(n.state,o,l,((t,e)=>{let r=n.state.selection.ranges.some((n=>n.from==t&&n.to==e));i.add(t,e,r?ln:on)}))}return i.finish()}},{decorations:t=>t.decorations});function cn(t){return e=>{let n=e.state.field(rn,!1);return n&&n.query.spec.valid?t(e,n):yn(e)}}const un=cn(((t,{query:e})=>{let{to:n}=t.state.selection.main,i=e.nextMatch(t.state,n,n);if(!i)return!1;let r=l.single(i.from,i.to),s=t.state.facet(Je);return t.dispatch({selection:r,effects:[Sn(t,i),s.scrollToMatch(r.main,t)],userEvent:"select.search"}),vn(t),!0})),an=cn(((t,{query:e})=>{let{state:n}=t,{from:i}=n.selection.main,r=e.prevMatch(n,i,i);if(!r)return!1;let s=l.single(r.from,r.to),o=t.state.facet(Je);return t.dispatch({selection:s,effects:[Sn(t,r),o.scrollToMatch(s.main,t)],userEvent:"select.search"}),vn(t),!0})),fn=cn(((t,{query:e})=>{let n=e.matchAll(t.state,1e3);return!(!n||!n.length)&&(t.dispatch({selection:l.create(n.map((t=>l.range(t.from,t.to)))),userEvent:"select.search.matches"}),!0)})),dn=cn(((e,{query:n})=>{let{state:i}=e,{from:r,to:s}=i.selection.main;if(i.readOnly)return!1;let o=n.nextMatch(i,r,r);if(!o)return!1;let h,c,u=o,a=[],f=[];if(u.from==r&&u.to==s&&(c=i.toText(n.getReplacement(u)),a.push({from:u.from,to:u.to,insert:c}),u=n.nextMatch(i,u.from,u.to),f.push(t.announce.of(i.phrase("replaced match on line $",i.doc.lineAt(r).number)+"."))),u){let t=0==a.length||a[0].from>=o.to?0:o.to-o.from-c.length;h=l.single(u.from-t,u.to-t),f.push(Sn(e,u)),f.push(i.facet(Je).scrollToMatch(h.main,e))}return e.dispatch({changes:a,selection:h,effects:f,userEvent:"input.replace"}),!0})),pn=cn(((e,{query:n})=>{if(e.state.readOnly)return!1;let i=n.matchAll(e.state,1e9).map((t=>{let{from:e,to:i}=t;return{from:e,to:i,insert:n.getReplacement(t)}}));if(!i.length)return!1;let r=e.state.phrase("replaced $ matches",i.length)+".";return e.dispatch({changes:i,effects:t.announce.of(r),userEvent:"input.replace.all"}),!0}));function mn(t){return t.state.facet(Je).createPanel(t)}function gn(t,e){var n,i,r,s,o;let l=t.selection.main,h=l.empty||l.to>l.from+100?"":t.sliceDoc(l.from,l.to);if(e&&!h)return e;let c=t.facet(Je);return new _e({search:(null!==(n=null==e?void 0:e.literal)&&void 0!==n?n:c.literal)?h:h.replace(/\n/g,"\\n"),caseSensitive:null!==(i=null==e?void 0:e.caseSensitive)&&void 0!==i?i:c.caseSensitive,literal:null!==(r=null==e?void 0:e.literal)&&void 0!==r?r:c.literal,regexp:null!==(s=null==e?void 0:e.regexp)&&void 0!==s?s:c.regexp,wholeWord:null!==(o=null==e?void 0:e.wholeWord)&&void 0!==o?o:c.wholeWord})}function wn(t){let e=S(t,mn);return e&&e.dom.querySelector("[main-field]")}function vn(t){let e=wn(t);e&&e==t.root.activeElement&&e.select()}const yn=t=>{let e=t.state.field(rn,!1);if(e&&e.panel){let n=wn(t);if(n&&n!=t.root.activeElement){let i=gn(t.state,e.query.spec);i.valid&&t.dispatch({effects:en.of(i)}),n.focus(),n.select()}}else t.dispatch({effects:[nn.of(!0),e?en.of(gn(t.state,e.query.spec)):h.appendConfig.of(Cn)]});return!0},bn=t=>{let e=t.state.field(rn,!1);if(!e||!e.panel)return!1;let n=S(t,mn);return n&&n.dom.contains(t.root.activeElement)&&t.focus(),t.dispatch({effects:nn.of(!1)}),!0},kn=[{key:"Mod-f",run:yn,scope:"editor search-panel"},{key:"F3",run:un,shift:an,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:un,shift:an,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:bn,scope:"editor search-panel"},{key:"Mod-Shift-l",run:({state:t,dispatch:e})=>{let n=t.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:i,to:r}=n.main,s=[],o=0;for(let e=new De(t.doc,t.sliceDoc(i,r));!e.next().done;){if(s.length>1e3)return!1;e.value.from==i&&(o=s.length),s.push(l.range(e.value.from,e.value.to))}return e(t.update({selection:l.create(s,o),userEvent:"select.search.matches"})),!0}},{key:"Mod-Alt-g",run:t=>{let e=S(t,Be);if(!e){let n=[je.of(!0)];null==t.state.field(Ve,!1)&&n.push(h.appendConfig.of([Ve,Pe])),t.dispatch({effects:n}),e=S(t,Be)}return e&&e.dom.querySelector("input").select(),!0}},{key:"Mod-d",run:({state:e,dispatch:n})=>{let{ranges:i}=e.selection;if(i.some((t=>t.from===t.to)))return(({state:t,dispatch:e})=>{let{selection:n}=t,i=l.create(n.ranges.map((e=>t.wordAt(e.head)||l.cursor(e.head))),n.mainIndex);return!i.eq(n)&&(e(t.update({selection:i})),!0)})({state:e,dispatch:n});let r=e.sliceDoc(i[0].from,i[0].to);if(e.selection.ranges.some((t=>e.sliceDoc(t.from,t.to)!=r)))return!1;let s=function(t,e){let{main:n,ranges:i}=t.selection,r=t.wordAt(n.head),s=r&&r.from==n.from&&r.to==n.to;for(let n=!1,r=new De(t.doc,e,i[i.length-1].to);;){if(r.next(),!r.done){if(n&&i.some((t=>t.from==r.value.from)))continue;if(s){let e=t.wordAt(r.value.from);if(!e||e.from!=r.value.from||e.to!=r.value.to)continue}return r.value}if(n)return null;r=new De(t.doc,e,0,Math.max(0,i[i.length-1].from-1)),n=!0}}(e,r);return!!s&&(n(e.update({selection:e.selection.addRange(l.range(s.from,s.to),!1),effects:t.scrollIntoView(s.to)})),!0)},preventDefault:!0}];class xn{constructor(t){this.view=t;let e=this.query=t.state.field(rn).query.spec;function n(t,e,n){return Ie("button",{class:"cm-button",name:t,onclick:e,type:"button"},n)}this.commit=this.commit.bind(this),this.searchField=Ie("input",{value:e.search,placeholder:Mn(t,"Find"),"aria-label":Mn(t,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=Ie("input",{value:e.replace,placeholder:Mn(t,"Replace"),"aria-label":Mn(t,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=Ie("input",{type:"checkbox",name:"case",form:"",checked:e.caseSensitive,onchange:this.commit}),this.reField=Ie("input",{type:"checkbox",name:"re",form:"",checked:e.regexp,onchange:this.commit}),this.wordField=Ie("input",{type:"checkbox",name:"word",form:"",checked:e.wholeWord,onchange:this.commit}),this.dom=Ie("div",{onkeydown:t=>this.keydown(t),class:"cm-search"},[this.searchField,n("next",(()=>un(t)),[Mn(t,"next")]),n("prev",(()=>an(t)),[Mn(t,"previous")]),n("select",(()=>fn(t)),[Mn(t,"all")]),Ie("label",null,[this.caseField,Mn(t,"match case")]),Ie("label",null,[this.reField,Mn(t,"regexp")]),Ie("label",null,[this.wordField,Mn(t,"by word")]),...t.state.readOnly?[]:[Ie("br"),this.replaceField,n("replace",(()=>dn(t)),[Mn(t,"replace")]),n("replaceAll",(()=>pn(t)),[Mn(t,"replace all")])],Ie("button",{name:"close",onclick:()=>bn(t),"aria-label":Mn(t,"close"),type:"button"},["×"])])}commit(){let t=new _e({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});t.eq(this.query)||(this.query=t,this.view.dispatch({effects:en.of(t)}))}keydown(t){L(this.view,t,"search-panel")?t.preventDefault():13==t.keyCode&&t.target==this.searchField?(t.preventDefault(),(t.shiftKey?an:un)(this.view)):13==t.keyCode&&t.target==this.replaceField&&(t.preventDefault(),dn(this.view))}update(t){for(let e of t.transactions)for(let t of e.effects)t.is(en)&&!t.value.eq(this.query)&&this.setQuery(t.value)}setQuery(t){this.query=t,this.searchField.value=t.search,this.replaceField.value=t.replace,this.caseField.checked=t.caseSensitive,this.reField.checked=t.regexp,this.wordField.checked=t.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(Je).top}}function Mn(t,e){return t.state.phrase(e)}const In=30,An=/[\s\.,:;?!]/;function Sn(e,{from:n,to:i}){let r=e.state.doc.lineAt(n),s=e.state.doc.lineAt(i).to,o=Math.max(r.from,n-In),l=Math.min(s,i+In),h=e.state.sliceDoc(o,l);if(o!=r.from)for(let t=0;t<In;t++)if(!An.test(h[t+1])&&An.test(h[t])){h=h.slice(t);break}if(l!=s)for(let t=h.length-1;t>h.length-In;t--)if(!An.test(h[t-1])&&An.test(h[t])){h=h.slice(0,t);break}return t.announce.of(`${e.state.phrase("current match")}. ${h} ${e.state.phrase("on line")} ${r.number}.`)}const Dn=t.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"}}),Cn=[rn,C.low(hn),Dn];class En{constructor(t,e,n,i){this.state=t,this.pos=e,this.explicit=n,this.view=i,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(t){let e=g(this.state).resolveInner(this.pos,-1);for(;e&&t.indexOf(e.name)<0;)e=e.parent;return e?{from:e.from,to:this.pos,text:this.state.sliceDoc(e.from,this.pos),type:e.type}:null}matchBefore(t){let e=this.state.doc.lineAt(this.pos),n=Math.max(e.from,this.pos-250),i=e.text.slice(n-e.from,this.pos-e.from),r=i.search(Bn(t,!1));return r<0?null:{from:n+r,to:this.pos,text:i.slice(r)}}get aborted(){return null==this.abortListeners}addEventListener(t,e,n){"abort"==t&&this.abortListeners&&(this.abortListeners.push(e),n&&n.onDocChange&&(this.abortOnDocChange=!0))}}function Rn(t){let e=Object.keys(t).join(""),n=/\w/.test(e);return n&&(e=e.replace(/\w/g,"")),`[${n?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function $n(t){let e=t.map((t=>"string"==typeof t?{label:t}:t)),[n,i]=e.every((t=>/^\w+$/.test(t.label)))?[/\w*$/,/\w+$/]:function(t){let e=Object.create(null),n=Object.create(null);for(let{label:i}of t){e[i[0]]=!0;for(let t=1;t<i.length;t++)n[i[t]]=!0}let i=Rn(e)+Rn(n)+"*$";return[new RegExp("^"+i),new RegExp(i)]}(e);return t=>{let r=t.matchBefore(i);return r||t.explicit?{from:r?r.from:t.pos,options:e,validFor:n}:null}}function On(t,e){return n=>{for(let e=g(n.state).resolveInner(n.pos,-1);e;e=e.parent){if(t.indexOf(e.name)>-1)return null;if(e.type.isTop)break}return e(n)}}class Ln{constructor(t,e,n,i){this.completion=t,this.source=e,this.match=n,this.score=i}}function Tn(t){return t.selection.main.from}function Bn(t,e){var n;let{source:i}=t,r=e&&"^"!=i[0],s="$"!=i[i.length-1];return r||s?new RegExp(`${r?"^":""}(?:${i})${s?"$":""}`,null!==(n=t.flags)&&void 0!==n?n:t.ignoreCase?"i":""):t}const jn=p.define();const Vn=new WeakMap;function Pn(t){if(!Array.isArray(t))return t;let e=Vn.get(t);return e||Vn.set(t,e=$n(t)),e}const Fn=h.define(),Wn=h.define();class zn{constructor(t){this.pattern=t,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let e=0;e<t.length;){let n=I(t,e),i=A(n);this.chars.push(n);let r=t.slice(e,e+i),s=r.toUpperCase();this.folded.push(I(s==r?r.toLowerCase():s,0)),e+=i}this.astral=t.length!=this.chars.length}ret(t,e){return this.score=t,this.matched=e,this}match(t){if(0==this.pattern.length)return this.ret(-100,[]);if(t.length<this.pattern.length)return null;let{chars:e,folded:n,any:i,precise:r,byWord:s}=this;if(1==e.length){let i=I(t,0),r=A(i),s=r==t.length?0:-100;if(i==e[0]);else{if(i!=n[0])return null;s+=-200}return this.ret(s,[0,r])}let o=t.indexOf(this.pattern);if(0==o)return this.ret(t.length==this.pattern.length?0:-100,[0,this.pattern.length]);let l=e.length,h=0;if(o<0){for(let r=0,s=Math.min(t.length,200);r<s&&h<l;){let s=I(t,r);s!=e[h]&&s!=n[h]||(i[h++]=r),r+=A(s)}if(h<l)return null}let c=0,u=0,a=!1,f=0,d=-1,p=-1,m=/[a-z]/.test(t),g=!0;for(let i=0,h=Math.min(t.length,200),w=0;i<h&&u<l;){let h=I(t,i);o<0&&(c<l&&h==e[c]&&(r[c++]=i),f<l&&(h==e[f]||h==n[f]?(0==f&&(d=i),p=i+1,f++):f=0));let v,y=h<255?h>=48&&h<=57||h>=97&&h<=122?2:h>=65&&h<=90?1:0:(v=E(h))!=v.toLowerCase()?1:v!=v.toUpperCase()?2:0;(!i||1==y&&m||0==w&&0!=y)&&(e[u]==h||n[u]==h&&(a=!0)?s[u++]=i:s.length&&(g=!1)),w=y,i+=A(h)}return u==l&&0==s[0]&&g?this.result((a?-200:0)-100,s,t):f==l&&0==d?this.ret(-200-t.length+(p==t.length?0:-100),[0,p]):o>-1?this.ret(-700-t.length,[o,o+this.pattern.length]):f==l?this.ret(-900-t.length,[d,p]):u==l?this.result((a?-200:0)-100-700+(g?0:-1100),s,t):2==e.length?null:this.result((i[0]?-700:0)-200-1100,i,t)}result(t,e,n){let i=[],r=0;for(let t of e){let e=t+(this.astral?A(I(n,t)):1);r&&i[r-1]==t?i[r-1]=e:(i[r++]=t,i[r++]=e)}return this.ret(t-n.length,i)}}class Un{constructor(t){this.pattern=t,this.matched=[],this.score=0,this.folded=t.toLowerCase()}match(t){if(t.length<this.pattern.length)return null;let e=t.slice(0,this.pattern.length),n=e==this.pattern?0:e.toLowerCase()==this.folded?-200:null;return null==n?null:(this.matched=[0,e.length],this.score=n+(t.length==this.pattern.length?0:-100),this)}}const qn=e.define({combine:t=>n(t,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:Nn,filterStrict:!1,compareCompletions:(t,e)=>t.label.localeCompare(e.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(t,e)=>t&&e,closeOnBlur:(t,e)=>t&&e,icons:(t,e)=>t&&e,tooltipClass:(t,e)=>n=>Hn(t(n),e(n)),optionClass:(t,e)=>n=>Hn(t(n),e(n)),addToOptions:(t,e)=>t.concat(e),filterStrict:(t,e)=>t||e})});function Hn(t,e){return t?e?t+" "+e:t:e}function Nn(t,e,n,i,r,s){let o,l,h=t.textDirection==b.RTL,c=h,u=!1,a="top",f=e.left-r.left,d=r.right-e.right,p=i.right-i.left,m=i.bottom-i.top;if(c&&f<Math.min(p,d)?c=!1:!c&&d<Math.min(p,f)&&(c=!0),p<=(c?f:d))o=Math.max(r.top,Math.min(n.top,r.bottom-m))-e.top,l=Math.min(400,c?f:d);else{u=!0,l=Math.min(400,(h?e.right:r.right-e.left)-30);let t=r.bottom-e.bottom;t>=m||t>e.top?o=n.bottom-e.top:(a="bottom",o=e.bottom-n.top)}return{style:`${a}: ${o/((e.bottom-e.top)/s.offsetHeight)}px; max-width: ${l/((e.right-e.left)/s.offsetWidth)}px`,class:"cm-completionInfo-"+(u?h?"left-narrow":"right-narrow":c?"left":"right")}}function Jn(t,e,n){if(t<=n)return{from:0,to:t};if(e<0&&(e=0),e<=t>>1){let t=Math.floor(e/n);return{from:t*n,to:(t+1)*n}}let i=Math.floor((t-e)/n);return{from:t-(i+1)*n,to:t-i*n}}class _n{constructor(t,e,n){this.view=t,this.stateField=e,this.applyCompletion=n,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:t=>this.placeInfo(t),key:this},this.space=null,this.currentClass="";let i=t.state.field(e),{options:r,selected:s}=i.open,o=t.state.facet(qn);this.optionContent=function(t){let e=t.addToOptions.slice();return t.icons&&e.push({render(t){let e=document.createElement("div");return e.classList.add("cm-completionIcon"),t.type&&e.classList.add(...t.type.split(/\s+/g).map((t=>"cm-completionIcon-"+t))),e.setAttribute("aria-hidden","true"),e},position:20}),e.push({render(t,e,n,i){let r=document.createElement("span");r.className="cm-completionLabel";let s=t.displayLabel||t.label,o=0;for(let t=0;t<i.length;){let e=i[t++],n=i[t++];e>o&&r.appendChild(document.createTextNode(s.slice(o,e)));let l=r.appendChild(document.createElement("span"));l.appendChild(document.createTextNode(s.slice(e,n))),l.className="cm-completionMatchedText",o=n}return o<s.length&&r.appendChild(document.createTextNode(s.slice(o))),r},position:50},{render(t){if(!t.detail)return null;let e=document.createElement("span");return e.className="cm-completionDetail",e.textContent=t.detail,e},position:80}),e.sort(((t,e)=>t.position-e.position)).map((t=>t.render))}(o),this.optionClass=o.optionClass,this.tooltipClass=o.tooltipClass,this.range=Jn(r.length,s,o.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(t.state),this.dom.addEventListener("mousedown",(n=>{let{options:i}=t.state.field(e).open;for(let e,r=n.target;r&&r!=this.dom;r=r.parentNode)if("LI"==r.nodeName&&(e=/-(\d+)$/.exec(r.id))&&+e[1]<i.length)return this.applyCompletion(t,i[+e[1]]),void n.preventDefault()})),this.dom.addEventListener("focusout",(e=>{let n=t.state.field(this.stateField,!1);n&&n.tooltip&&t.state.facet(qn).closeOnBlur&&e.relatedTarget!=t.contentDOM&&t.dispatch({effects:Wn.of(null)})})),this.showOptions(r,i.id)}mount(){this.updateSel()}showOptions(t,e){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(t,e,this.range)),this.list.addEventListener("scroll",(()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)}))}update(t){var e;let n=t.state.field(this.stateField),i=t.startState.field(this.stateField);if(this.updateTooltipClass(t.state),n!=i){let{options:r,selected:s,disabled:o}=n.open;i.open&&i.open.options==r||(this.range=Jn(r.length,s,t.state.facet(qn).maxRenderedOptions),this.showOptions(r,n.id)),this.updateSel(),o!=(null===(e=i.open)||void 0===e?void 0:e.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!o)}}updateTooltipClass(t){let e=this.tooltipClass(t);if(e!=this.currentClass){for(let t of this.currentClass.split(" "))t&&this.dom.classList.remove(t);for(let t of e.split(" "))t&&this.dom.classList.add(t);this.currentClass=e}}positioned(t){this.space=t,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let t=this.view.state.field(this.stateField),e=t.open;if((e.selected>-1&&e.selected<this.range.from||e.selected>=this.range.to)&&(this.range=Jn(e.options.length,e.selected,this.view.state.facet(qn).maxRenderedOptions),this.showOptions(e.options,t.id)),this.updateSelectedOption(e.selected)){this.destroyInfo();let{completion:n}=e.options[e.selected],{info:i}=n;if(!i)return;let r="string"==typeof i?document.createTextNode(i):i(n);if(!r)return;"then"in r?r.then((e=>{e&&this.view.state.field(this.stateField,!1)==t&&this.addInfoPane(e,n)})).catch((t=>j(this.view.state,t,"completion info"))):this.addInfoPane(r,n)}}addInfoPane(t,e){this.destroyInfo();let n=this.info=document.createElement("div");if(n.className="cm-tooltip cm-completionInfo",null!=t.nodeType)n.appendChild(t),this.infoDestroy=null;else{let{dom:e,destroy:i}=t;n.appendChild(e),this.infoDestroy=i||null}this.dom.appendChild(n),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(t){let e=null;for(let n=this.list.firstChild,i=this.range.from;n;n=n.nextSibling,i++)"LI"==n.nodeName&&n.id?i==t?n.hasAttribute("aria-selected")||(n.setAttribute("aria-selected","true"),e=n):n.hasAttribute("aria-selected")&&n.removeAttribute("aria-selected"):i--;return e&&function(t,e){let n=t.getBoundingClientRect(),i=e.getBoundingClientRect(),r=n.height/t.offsetHeight;i.top<n.top?t.scrollTop-=(n.top-i.top)/r:i.bottom>n.bottom&&(t.scrollTop+=(i.bottom-n.bottom)/r)}(this.list,e),e}measureInfo(){let t=this.dom.querySelector("[aria-selected]");if(!t||!this.info)return null;let e=this.dom.getBoundingClientRect(),n=this.info.getBoundingClientRect(),i=t.getBoundingClientRect(),r=this.space;if(!r){let t=this.dom.ownerDocument.defaultView||window;r={left:0,top:0,right:t.innerWidth,bottom:t.innerHeight}}return i.top>Math.min(r.bottom,e.bottom)-10||i.bottom<Math.max(r.top,e.top)+10?null:this.view.state.facet(qn).positionInfo(this.view,e,i,n,r,this.dom)}placeInfo(t){this.info&&(t?(t.style&&(this.info.style.cssText=t.style),this.info.className="cm-tooltip cm-completionInfo "+(t.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(t,e,n){const i=document.createElement("ul");i.id=e,i.setAttribute("role","listbox"),i.setAttribute("aria-expanded","true"),i.setAttribute("aria-label",this.view.state.phrase("Completions"));let r=null;for(let s=n.from;s<n.to;s++){let{completion:o,match:l}=t[s],{section:h}=o;if(h){let t="string"==typeof h?h:h.name;if(t!=r&&(s>n.from||0==n.from))if(r=t,"string"!=typeof h&&h.header)i.appendChild(h.header(h));else{i.appendChild(document.createElement("completion-section")).textContent=t}}const c=i.appendChild(document.createElement("li"));c.id=e+"-"+s,c.setAttribute("role","option");let u=this.optionClass(o);u&&(c.className=u);for(let t of this.optionContent){let e=t(o,this.view.state,this.view,l);e&&c.appendChild(e)}}return n.from&&i.classList.add("cm-completionListIncompleteTop"),n.to<t.length&&i.classList.add("cm-completionListIncompleteBottom"),i}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}}function Gn(t,e){return n=>new _n(n,t,e)}function Kn(t){return 100*(t.boost||0)+(t.apply?10:0)+(t.info?5:0)+(t.type?1:0)}class Qn{constructor(t,e,n,i,r,s){this.options=t,this.attrs=e,this.tooltip=n,this.timestamp=i,this.selected=r,this.disabled=s}setSelected(t,e){return t==this.selected||t>=this.options.length?this:new Qn(this.options,ti(e,t),this.tooltip,this.timestamp,t,this.disabled)}static build(t,e,n,i,r,s){if(i&&!s&&t.some((t=>t.isPending)))return i.setDisabled();let o=function(t,e){let n=[],i=null,r=t=>{n.push(t);let{section:e}=t.completion;if(e){i||(i=[]);let t="string"==typeof e?e:e.name;i.some((e=>e.name==t))||i.push("string"==typeof e?{name:t}:e)}},s=e.facet(qn);for(let i of t)if(i.hasResult()){let t=i.result.getMatch;if(!1===i.result.filter)for(let e of i.result.options)r(new Ln(e,i.source,t?t(e):[],1e9-n.length));else{let n,o=e.sliceDoc(i.from,i.to),l=s.filterStrict?new Un(o):new zn(o);for(let e of i.result.options)if(n=l.match(e.label)){let s=e.displayLabel?t?t(e,n.matched):[]:n.matched;r(new Ln(e,i.source,s,n.score+(e.boost||0)))}}}if(i){let t=Object.create(null),e=0,r=(t,e)=>{var n,i;return(null!==(n=t.rank)&&void 0!==n?n:1e9)-(null!==(i=e.rank)&&void 0!==i?i:1e9)||(t.name<e.name?-1:1)};for(let n of i.sort(r))e-=1e5,t[n.name]=e;for(let e of n){let{section:n}=e.completion;n&&(e.score+=t["string"==typeof n?n:n.name])}}let o=[],l=null,h=s.compareCompletions;for(let t of n.sort(((t,e)=>e.score-t.score||h(t.completion,e.completion)))){let e=t.completion;!l||l.label!=e.label||l.detail!=e.detail||null!=l.type&&null!=e.type&&l.type!=e.type||l.apply!=e.apply||l.boost!=e.boost?o.push(t):Kn(t.completion)>Kn(l)&&(o[o.length-1]=t),l=t.completion}return o}(t,e);if(!o.length)return i&&t.some((t=>t.isPending))?i.setDisabled():null;let l=e.facet(qn).selectOnOpen?0:-1;if(i&&i.selected!=l&&-1!=i.selected){let t=i.options[i.selected].completion;for(let e=0;e<o.length;e++)if(o[e].completion==t){l=e;break}}return new Qn(o,ti(n,l),{pos:t.reduce(((t,e)=>e.hasResult()?Math.min(t,e.from):t),1e8),create:ci,above:r.aboveCursor},i?i.timestamp:Date.now(),l,!1)}map(t){return new Qn(this.options,this.attrs,Object.assign(Object.assign({},this.tooltip),{pos:t.mapPos(this.tooltip.pos)}),this.timestamp,this.selected,this.disabled)}setDisabled(){return new Qn(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class Xn{constructor(t,e,n){this.active=t,this.id=e,this.open=n}static start(){return new Xn(ei,"cm-ac-"+Math.floor(2e6*Math.random()).toString(36),null)}update(t){let{state:e}=t,n=e.facet(qn),i=(n.override||e.languageDataAt("autocomplete",Tn(e)).map(Pn)).map((e=>(this.active.find((t=>t.source==e))||new ii(e,this.active.some((t=>0!=t.state))?1:0)).update(t,n)));i.length==this.active.length&&i.every(((t,e)=>t==this.active[e]))&&(i=this.active);let r=this.open,s=t.effects.some((t=>t.is(si)));r&&t.docChanged&&(r=r.map(t.changes)),t.selection||i.some((e=>e.hasResult()&&t.changes.touchesRange(e.from,e.to)))||!function(t,e){if(t==e)return!0;for(let n=0,i=0;;){for(;n<t.length&&!t[n].hasResult();)n++;for(;i<e.length&&!e[i].hasResult();)i++;let r=n==t.length,s=i==e.length;if(r||s)return r==s;if(t[n++].result!=e[i++].result)return!1}}(i,this.active)||s?r=Qn.build(i,e,this.id,r,n,s):r&&r.disabled&&!i.some((t=>t.isPending))&&(r=null),!r&&i.every((t=>!t.isPending))&&i.some((t=>t.hasResult()))&&(i=i.map((t=>t.hasResult()?new ii(t.source,0):t)));for(let e of t.effects)e.is(oi)&&(r=r&&r.setSelected(e.value,this.id));return i==this.active&&r==this.open?this:new Xn(i,this.id,r)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?Yn:Zn}}const Yn={"aria-autocomplete":"list"},Zn={};function ti(t,e){let n={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":t};return e>-1&&(n["aria-activedescendant"]=t+"-"+e),n}const ei=[];function ni(t,e){if(t.isUserEvent("input.complete")){let n=t.annotation(jn);if(n&&e.activateOnCompletion(n))return 12}let n=t.isUserEvent("input.type");return n&&e.activateOnTyping?5:n?1:t.isUserEvent("delete.backward")?2:t.selection?8:t.docChanged?16:0}class ii{constructor(t,e,n=!1){this.source=t,this.state=e,this.explicit=n}hasResult(){return!1}get isPending(){return 1==this.state}update(t,e){let n=ni(t,e),i=this;(8&n||16&n&&this.touches(t))&&(i=new ii(i.source,0)),4&n&&0==i.state&&(i=new ii(this.source,1)),i=i.updateFor(t,n);for(let e of t.effects)if(e.is(Fn))i=new ii(i.source,1,e.value);else if(e.is(Wn))i=new ii(i.source,0);else if(e.is(si))for(let t of e.value)t.source==i.source&&(i=t);return i}updateFor(t,e){return this.map(t.changes)}map(t){return this}touches(t){return t.changes.touchesRange(Tn(t.state))}}class ri extends ii{constructor(t,e,n,i,r,s){super(t,3,e),this.limit=n,this.result=i,this.from=r,this.to=s}hasResult(){return!0}updateFor(t,e){var n;if(!(3&e))return this.map(t.changes);let i=this.result;i.map&&!t.changes.empty&&(i=i.map(i,t.changes));let r=t.changes.mapPos(this.from),s=t.changes.mapPos(this.to,1),o=Tn(t.state);if(o>s||!i||2&e&&(Tn(t.startState)==this.from||o<this.limit))return new ii(this.source,4&e?1:0);let l=t.changes.mapPos(this.limit);return function(t,e,n,i){if(!t)return!1;let r=e.sliceDoc(n,i);return"function"==typeof t?t(r,n,i,e):Bn(t,!0).test(r)}(i.validFor,t.state,r,s)?new ri(this.source,this.explicit,l,i,r,s):i.update&&(i=i.update(i,r,s,new En(t.state,o,!1)))?new ri(this.source,this.explicit,l,i,i.from,null!==(n=i.to)&&void 0!==n?n:Tn(t.state)):new ii(this.source,1,this.explicit)}map(t){if(t.empty)return this;return(this.result.map?this.result.map(this.result,t):this.result)?new ri(this.source,this.explicit,t.mapPos(this.limit),this.result,t.mapPos(this.from),t.mapPos(this.to,1)):new ii(this.source,0)}touches(t){return t.changes.touchesRange(this.from,this.to)}}const si=h.define({map:(t,e)=>t.map((t=>t.map(e)))}),oi=h.define(),li=i.define({create:()=>Xn.start(),update:(t,e)=>t.update(e),provide:e=>[B.from(e,(t=>t.tooltip)),t.contentAttributes.from(e,(t=>t.attrs))]});function hi(t,e){const n=e.completion.apply||e.completion.label;let i=t.state.field(li).active.find((t=>t.source==e.source));return i instanceof ri&&("string"==typeof n?t.dispatch(Object.assign(Object.assign({},function(t,e,n,i){let{main:r}=t.selection,s=n-r.from,o=i-r.from;return Object.assign(Object.assign({},t.changeByRange((h=>{if(h!=r&&n!=i&&t.sliceDoc(h.from+s,h.from+o)!=t.sliceDoc(n,i))return{range:h};let c=t.toText(e);return{changes:{from:h.from+s,to:i==r.from?h.to:h.from+o,insert:c},range:l.cursor(h.from+s+c.length)}}))),{scrollIntoView:!0,userEvent:"input.complete"})}(t.state,n,i.from,i.to)),{annotations:jn.of(e.completion)})):n(t,e.completion,i.from,i.to),!0)}const ci=Gn(li,hi);function ui(t,e="option"){return n=>{let i=n.state.field(li,!1);if(!i||!i.open||i.open.disabled||Date.now()-i.open.timestamp<n.state.facet(qn).interactionDelay)return!1;let r,s=1;"page"==e&&(r=V(n,i.open.tooltip))&&(s=Math.max(2,Math.floor(r.dom.offsetHeight/r.dom.querySelector("li").offsetHeight)-1));let{length:o}=i.open.options,l=i.open.selected>-1?i.open.selected+s*(t?1:-1):t?0:o-1;return l<0?l="page"==e?0:o-1:l>=o&&(l="page"==e?o-1:0),n.dispatch({effects:oi.of(l)}),!0}}const ai=t=>{let e=t.state.field(li,!1);return!(t.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestamp<t.state.facet(qn).interactionDelay)&&hi(t,e.open.options[e.open.selected])},fi=t=>!!t.state.field(li,!1)&&(t.dispatch({effects:Fn.of(!0)}),!0),di=t=>{let e=t.state.field(li,!1);return!(!e||!e.active.some((t=>0!=t.state)))&&(t.dispatch({effects:Wn.of(null)}),!0)};class pi{constructor(t,e){this.active=t,this.context=e,this.time=Date.now(),this.updates=[],this.done=void 0}}const mi=x.fromClass(class{constructor(t){this.view=t,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of t.state.field(li).active)e.isPending&&this.startQuery(e)}update(t){let e=t.state.field(li),n=t.state.facet(qn);if(!t.selectionSet&&!t.docChanged&&t.startState.field(li)==e)return;let i=t.transactions.some((t=>{let e=ni(t,n);return 8&e||(t.selection||t.docChanged)&&!(3&e)}));for(let e=0;e<this.running.length;e++){let n=this.running[e];if(i||n.context.abortOnDocChange&&t.docChanged||n.updates.length+t.transactions.length>50&&Date.now()-n.time>1e3){for(let t of n.context.abortListeners)try{t()}catch(t){j(this.view.state,t)}n.context.abortListeners=null,this.running.splice(e--,1)}else n.updates.push(...t.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),t.transactions.some((t=>t.effects.some((t=>t.is(Fn)))))&&(this.pendingStart=!0);let r=this.pendingStart?50:n.activateOnTypingDelay;if(this.debounceUpdate=e.active.some((t=>t.isPending&&!this.running.some((e=>e.active.source==t.source))))?setTimeout((()=>this.startUpdate()),r):-1,0!=this.composing)for(let e of t.transactions)e.isUserEvent("input.type")?this.composing=2:2==this.composing&&e.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:t}=this.view,e=t.field(li);for(let t of e.active)t.isPending&&!this.running.some((e=>e.active.source==t.source))&&this.startQuery(t);this.running.length&&e.open&&e.open.disabled&&(this.debounceAccept=setTimeout((()=>this.accept()),this.view.state.facet(qn).updateSyncTime))}startQuery(t){let{state:e}=this.view,n=Tn(e),i=new En(e,n,t.explicit,this.view),r=new pi(t,i);this.running.push(r),Promise.resolve(t.source(i)).then((t=>{r.context.aborted||(r.done=t||null,this.scheduleAccept())}),(t=>{this.view.dispatch({effects:Wn.of(null)}),j(this.view.state,t)}))}scheduleAccept(){this.running.every((t=>void 0!==t.done))?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout((()=>this.accept()),this.view.state.facet(qn).updateSyncTime))}accept(){var t;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],n=this.view.state.facet(qn),i=this.view.state.field(li);for(let r=0;r<this.running.length;r++){let s=this.running[r];if(void 0===s.done)continue;if(this.running.splice(r--,1),s.done){let i=Tn(s.updates.length?s.updates[0].startState:this.view.state),r=Math.min(i,s.done.from+(s.active.explicit?0:1)),o=new ri(s.active.source,s.active.explicit,r,s.done,s.done.from,null!==(t=s.done.to)&&void 0!==t?t:i);for(let t of s.updates)o=o.update(t,n);if(o.hasResult()){e.push(o);continue}}let o=i.active.find((t=>t.source==s.active.source));if(o&&o.isPending)if(null==s.done){let t=new ii(s.active.source,0);for(let e of s.updates)t=t.update(e,n);t.isPending||e.push(t)}else this.startQuery(o)}(e.length||i.open&&i.open.disabled)&&this.view.dispatch({effects:si.of(e)})}},{eventHandlers:{blur(t){let e=this.view.state.field(li,!1);if(e&&e.tooltip&&this.view.state.facet(qn).closeOnBlur){let n=e.open&&V(this.view,e.open.tooltip);n&&n.dom.contains(t.relatedTarget)||setTimeout((()=>this.view.dispatch({effects:Wn.of(null)})),10)}},compositionstart(){this.composing=1},compositionend(){3==this.composing&&setTimeout((()=>this.view.dispatch({effects:Fn.of(!1)})),20),this.composing=0}}}),gi="object"==typeof navigator&&/Win/.test(navigator.platform),wi=C.highest(t.domEventHandlers({keydown(t,e){let n=e.state.field(li,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||t.key.length>1||t.ctrlKey&&(!gi||!t.altKey)||t.metaKey)return!1;let i=n.open.options[n.open.selected],r=n.active.find((t=>t.source==i.source)),s=i.completion.commitCharacters||r.result.commitCharacters;return s&&s.indexOf(t.key)>-1&&hi(e,i),!1}})),vi=t.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}});class yi{constructor(t,e,n,i){this.field=t,this.line=e,this.from=n,this.to=i}}class bi{constructor(t,e,n){this.field=t,this.from=e,this.to=n}map(t){let e=t.mapPos(this.from,-1,F.TrackDel),n=t.mapPos(this.to,1,F.TrackDel);return null==e||null==n?null:new bi(this.field,e,n)}}class ki{constructor(t,e){this.lines=t,this.fieldPositions=e}instantiate(t,e){let n=[],i=[e],r=t.doc.lineAt(e),s=/^\s*/.exec(r.text)[0];for(let r of this.lines){if(n.length){let n=s,o=/^\t*/.exec(r)[0].length;for(let e=0;e<o;e++)n+=t.facet(v);i.push(e+n.length-o),r=n+r.slice(o)}n.push(r),e+=r.length+1}let o=this.fieldPositions.map((t=>new bi(t.field,i[t.line]+t.from,i[t.line]+t.to)));return{text:n,ranges:o}}static parse(t){let e,n=[],i=[],r=[];for(let s of t.split(/\r\n?|\n/)){for(;e=/[#$]\{(?:(\d+)(?::([^}]*))?|((?:\\[{}]|[^}])*))\}/.exec(s);){let t=e[1]?+e[1]:null,o=e[2]||e[3]||"",l=-1,h=o.replace(/\\[{}]/g,(t=>t[1]));for(let e=0;e<n.length;e++)(null!=t?n[e].seq==t:h&&n[e].name==h)&&(l=e);if(l<0){let e=0;for(;e<n.length&&(null==t||null!=n[e].seq&&n[e].seq<t);)e++;n.splice(e,0,{seq:t,name:h}),l=e;for(let t of r)t.field>=l&&t.field++}r.push(new yi(l,i.length,e.index,e.index+h.length)),s=s.slice(0,e.index)+o+s.slice(e.index+e[0].length)}s=s.replace(/\\([{}])/g,((t,e,n)=>{for(let t of r)t.line==i.length&&t.from>n&&(t.from--,t.to--);return e})),i.push(s)}return new ki(i,r)}}let xi=M.widget({widget:new class extends z{toDOM(){let t=document.createElement("span");return t.className="cm-snippetFieldPosition",t}ignoreEvent(){return!1}}}),Mi=M.mark({class:"cm-snippetField"});class Ii{constructor(t,e){this.ranges=t,this.active=e,this.deco=M.set(t.map((t=>(t.from==t.to?xi:Mi).range(t.from,t.to))))}map(t){let e=[];for(let n of this.ranges){let i=n.map(t);if(!i)return null;e.push(i)}return new Ii(e,this.active)}selectionInsideField(t){return t.ranges.every((t=>this.ranges.some((e=>e.field==this.active&&e.from<=t.from&&e.to>=t.to))))}}const Ai=h.define({map:(t,e)=>t&&t.map(e)}),Si=h.define(),Di=i.define({create:()=>null,update(t,e){for(let n of e.effects){if(n.is(Ai))return n.value;if(n.is(Si)&&t)return new Ii(t.ranges,n.value)}return t&&e.docChanged&&(t=t.map(e.changes)),t&&e.selection&&!t.selectionInsideField(e.selection)&&(t=null),t},provide:e=>t.decorations.from(e,(t=>t?t.deco:M.none))});function Ci(t,e){return l.create(t.filter((t=>t.field==e)).map((t=>l.range(t.from,t.to))))}function Ei(t){let e=ki.parse(t);return(t,n,i,s)=>{let{text:o,ranges:l}=e.instantiate(t.state,i),{main:c}=t.state.selection,u={changes:{from:i,to:s==c.from?c.to:s,insert:d.of(o)},scrollIntoView:!0,annotations:n?[jn.of(n),r.userEvent.of("input.complete")]:void 0};if(l.length&&(u.selection=Ci(l,0)),l.some((t=>t.field>0))){let e=new Ii(l,0),n=u.effects=[Ai.of(e)];void 0===t.state.field(Di,!1)&&n.push(h.appendConfig.of([Di,Li,Bi,vi]))}t.dispatch(t.state.update(u))}}function Ri(t){return({state:e,dispatch:n})=>{let i=e.field(Di,!1);if(!i||t<0&&0==i.active)return!1;let r=i.active+t,s=t>0&&!i.ranges.some((e=>e.field==r+t));return n(e.update({selection:Ci(i.ranges,r),effects:Ai.of(s?null:new Ii(i.ranges,r)),scrollIntoView:!0})),!0}}const $i=[{key:"Tab",run:Ri(1),shift:Ri(-1)},{key:"Escape",run:({state:t,dispatch:e})=>!!t.field(Di,!1)&&(e(t.update({effects:Ai.of(null)})),!0)}],Oi=e.define({combine:t=>t.length?t[0]:$i}),Li=C.highest(T.compute([Oi],(t=>t.facet(Oi))));function Ti(t,e){return Object.assign(Object.assign({},e),{apply:Ei(t)})}const Bi=t.domEventHandlers({mousedown(t,e){let n,i=e.state.field(Di,!1);if(!i||null==(n=e.posAtCoords({x:t.clientX,y:t.clientY})))return!1;let r=i.ranges.find((t=>t.from<=n&&t.to>=n));return!(!r||r.field==i.active)&&(e.dispatch({selection:Ci(i.ranges,r.field),effects:Ai.of(i.ranges.some((t=>t.field>r.field))?new Ii(i.ranges,r.field):null),scrollIntoView:!0}),!0)}}),ji={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},Vi=h.define({map(t,e){let n=e.mapPos(t,-1,F.TrackAfter);return null==n?void 0:n}}),Pi=new class extends P{};Pi.startSide=1,Pi.endSide=-1;const Fi=i.define({create:()=>W.empty,update(t,e){if(t=t.map(e.changes),e.selection){let n=e.state.doc.lineAt(e.selection.main.head);t=t.update({filter:t=>t>=n.from&&t<=n.to})}for(let n of e.effects)n.is(Vi)&&(t=t.update({add:[Pi.range(n.value,n.value+1)]}));return t}});const Wi="()[]{}<>";function zi(t){for(let e=0;e<8;e+=2)if(Wi.charCodeAt(e)==t)return Wi.charAt(e+1);return E(t<128?t:t+1)}function Ui(t,e){return t.languageDataAt("closeBrackets",e)[0]||ji}const qi="object"==typeof navigator&&/Android\b/.test(navigator.userAgent),Hi=t.inputHandler.of(((t,e,n,i)=>{if((qi?t.composing:t.compositionStarted)||t.state.readOnly)return!1;let r=t.state.selection.main;if(i.length>2||2==i.length&&1==A(I(i,0))||e!=r.from||n!=r.to)return!1;let s=function(t,e){let n=Ui(t,t.selection.main.head),i=n.brackets||ji.brackets;for(let r of i){let s=zi(I(r,0));if(e==r)return s==r?Qi(t,r,i.indexOf(r+r+r)>-1,n):Gi(t,r,s,n.before||ji.before);if(e==s&&Ji(t,t.selection.main.from))return Ki(t,r,s)}return null}(t.state,i);return!!s&&(t.dispatch(s),!0)})),Ni=[{key:"Backspace",run:({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=Ui(t,t.selection.main.head).brackets||ji.brackets,i=null,r=t.changeByRange((e=>{if(e.empty){let i=function(t,e){let n=t.sliceString(e-2,e);return A(I(n,0))==n.length?n:n.slice(1)}(t.doc,e.head);for(let r of n)if(r==i&&_i(t.doc,e.head)==zi(I(r,0)))return{changes:{from:e.head-r.length,to:e.head+r.length},range:l.cursor(e.head-r.length)}}return{range:i=e}}));return i||e(t.update(r,{scrollIntoView:!0,userEvent:"delete.backward"})),!i}}];function Ji(t,e){let n=!1;return t.field(Fi).between(0,t.doc.length,(t=>{t==e&&(n=!0)})),n}function _i(t,e){let n=t.sliceString(e,e+2);return n.slice(0,A(I(n,0)))}function Gi(t,e,n,i){let r=null,s=t.changeByRange((s=>{if(!s.empty)return{changes:[{insert:e,from:s.from},{insert:n,from:s.to}],effects:Vi.of(s.to+e.length),range:l.range(s.anchor+e.length,s.head+e.length)};let o=_i(t.doc,s.head);return!o||/\s/.test(o)||i.indexOf(o)>-1?{changes:{insert:e+n,from:s.head},effects:Vi.of(s.head+e.length),range:l.cursor(s.head+e.length)}:{range:r=s}}));return r?null:t.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function Ki(t,e,n){let i=null,r=t.changeByRange((e=>e.empty&&_i(t.doc,e.head)==n?{changes:{from:e.head,to:e.head+n.length,insert:n},range:l.cursor(e.head+n.length)}:i={range:e}));return i?null:t.update(r,{scrollIntoView:!0,userEvent:"input.type"})}function Qi(t,e,n,i){let r=i.stringPrefixes||ji.stringPrefixes,s=null,o=t.changeByRange((i=>{if(!i.empty)return{changes:[{insert:e,from:i.from},{insert:e,from:i.to}],effects:Vi.of(i.to+e.length),range:l.range(i.anchor+e.length,i.head+e.length)};let o,h=i.head,c=_i(t.doc,h);if(c==e){if(Xi(t,h))return{changes:{insert:e+e,from:h},effects:Vi.of(h+e.length),range:l.cursor(h+e.length)};if(Ji(t,h)){let i=n&&t.sliceDoc(h,h+3*e.length)==e+e+e?e+e+e:e;return{changes:{from:h,to:h+i.length,insert:i},range:l.cursor(h+i.length)}}}else{if(n&&t.sliceDoc(h-2*e.length,h)==e+e&&(o=Yi(t,h-2*e.length,r))>-1&&Xi(t,o))return{changes:{insert:e+e+e+e,from:h},effects:Vi.of(h+e.length),range:l.cursor(h+e.length)};if(t.charCategorizer(h)(c)!=D.Word&&Yi(t,h,r)>-1&&!function(t,e,n,i){let r=g(t).resolveInner(e,-1),s=i.reduce(((t,e)=>Math.max(t,e.length)),0);for(let o=0;o<5;o++){let o=t.sliceDoc(r.from,Math.min(r.to,r.from+n.length+s)),l=o.indexOf(n);if(!l||l>-1&&i.indexOf(o.slice(0,l))>-1){let e=r.firstChild;for(;e&&e.from==r.from&&e.to-e.from>n.length+l;){if(t.sliceDoc(e.to-n.length,e.to)==n)return!1;e=e.firstChild}return!0}let h=r.to==e&&r.parent;if(!h)break;r=h}return!1}(t,h,e,r))return{changes:{insert:e+e,from:h},effects:Vi.of(h+e.length),range:l.cursor(h+e.length)}}return{range:s=i}}));return s?null:t.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function Xi(t,e){let n=g(t).resolveInner(e+1);return n.parent&&n.from==e}function Yi(t,e,n){let i=t.charCategorizer(e);if(i(t.sliceDoc(e-1,e))!=D.Word)return e;for(let r of n){let n=e-r.length;if(t.sliceDoc(n,e)==r&&i(t.sliceDoc(n-1,n))!=D.Word)return n}return-1}function Zi(t={}){return[wi,li,qn.of(t),mi,er,vi]}const tr=[{key:"Ctrl-Space",run:fi},{mac:"Alt-`",run:fi},{key:"Escape",run:di},{key:"ArrowDown",run:ui(!0)},{key:"ArrowUp",run:ui(!1)},{key:"PageDown",run:ui(!0,"page")},{key:"PageUp",run:ui(!1,"page")},{key:"Enter",run:ai}],er=C.highest(T.computeN([qn],(t=>t.facet(qn).defaultKeymap?[tr]:[])));function nr(t){let e=t.field(li,!1);return e&&e.active.some((t=>t.isPending))?"pending":e&&e.active.some((t=>0!=t.state))?"active":null}class ir{constructor(t,e,n){this.from=t,this.to=e,this.diagnostic=n}}class rr{constructor(t,e,n){this.diagnostics=t,this.panel=e,this.selected=n}static init(t,e,n){let i=t,r=n.facet(mr).markerFilter;r&&(i=r(i,n));let s=t.slice().sort(((t,e)=>t.from-e.from||t.to-e.to)),o=new O,l=[],h=0;for(let t=0;;){let e,i,r=t==s.length?null:s[t];if(!r&&!l.length)break;for(l.length?(e=h,i=l.reduce(((t,e)=>Math.min(t,e.to)),r&&r.from>e?r.from:1e8)):(e=r.from,i=r.to,l.push(r),t++);t<s.length;){let n=s[t];if(n.from!=e||!(n.to>n.from||n.to==e)){i=Math.min(n.from,i);break}l.push(n),t++,i=Math.min(n.to,i)}let c=Ir(l);if(l.some((t=>t.from==t.to||t.from==t.to-1&&n.doc.lineAt(t.from).to==t.from)))o.add(e,e,M.widget({widget:new vr(c),diagnostics:l.slice()}));else{let t=l.reduce(((t,e)=>e.markClass?t+" "+e.markClass:t),"");o.add(e,i,M.mark({class:"cm-lintRange cm-lintRange-"+c+t,diagnostics:l.slice(),inclusiveEnd:l.some((t=>t.to>i))}))}h=i;for(let t=0;t<l.length;t++)l[t].to<=h&&l.splice(t--,1)}let c=o.finish();return new rr(c,e,sr(c))}}function sr(t,e=null,n=0){let i=null;return t.between(n,1e9,((t,n,{spec:r})=>{if(!(e&&r.diagnostics.indexOf(e)<0))if(i){if(r.diagnostics.indexOf(i.diagnostic)<0)return!1;i=new ir(i.from,n,i.diagnostic)}else i=new ir(t,n,e||r.diagnostics[0])})),i}const or=h.define(),lr=h.define(),hr=h.define(),cr=i.define({create:()=>new rr(M.none,null,null),update(t,e){if(e.docChanged&&t.diagnostics.size){let n=t.diagnostics.map(e.changes),i=null,r=t.panel;if(t.selected){let r=e.changes.mapPos(t.selected.from,1);i=sr(n,t.selected.diagnostic,r)||sr(n,null,r)}!n.size&&r&&e.state.facet(mr).autoPanel&&(r=null),t=new rr(n,r,i)}for(let n of e.effects)if(n.is(or)){let i=e.state.facet(mr).autoPanel?n.value.length?br.open:null:t.panel;t=rr.init(n.value,i,e.state)}else n.is(lr)?t=new rr(t.diagnostics,n.value?br.open:null,t.selected):n.is(hr)&&(t=new rr(t.diagnostics,t.panel,n.value));return t},provide:e=>[R.from(e,(t=>t.panel)),t.decorations.from(e,(t=>t.diagnostics))]}),ur=M.mark({class:"cm-lintRange cm-lintRange-active"});function ar(t,e,n){let i,{diagnostics:r}=t.state.field(cr),s=-1,o=-1;r.between(e-(n<0?1:0),e+(n>0?1:0),((t,r,{spec:l})=>{if(e>=t&&e<=r&&(t==r||(e>t||n>0)&&(e<r||n<0)))return i=l.diagnostics,s=t,o=r,!1}));let l=t.state.facet(mr).tooltipFilter;return i&&l&&(i=l(i,t.state)),i?{pos:s,end:o,above:t.state.doc.lineAt(s).to<o,create:()=>({dom:fr(t,i)})}:null}function fr(t,e){return Ie("ul",{class:"cm-tooltip-lint"},e.map((e=>wr(t,e,!1))))}const dr=t=>{let e=t.state.field(cr,!1);return!(!e||!e.panel)&&(t.dispatch({effects:lr.of(!1)}),!0)},pr=[{key:"Mod-Shift-m",run:t=>{let e=t.state.field(cr,!1);var n,i;e&&e.panel||t.dispatch({effects:(n=t.state,i=[lr.of(!0)],n.field(cr,!1)?i:i.concat(h.appendConfig.of(Ar)))});let r=S(t,br.open);return r&&r.dom.querySelector(".cm-panel-lint ul").focus(),!0},preventDefault:!0},{key:"F8",run:t=>{let e=t.state.field(cr,!1);if(!e)return!1;let n=t.state.selection.main,i=e.diagnostics.iter(n.to+1);return!(!i.value&&(i=e.diagnostics.iter(0),!i.value||i.from==n.from&&i.to==n.to))&&(t.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0}),!0)}}],mr=e.define({combine:t=>Object.assign({sources:t.map((t=>t.source)).filter((t=>null!=t))},n(t.map((t=>t.config)),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{needsRefresh:(t,e)=>t?e?n=>t(n)||e(n):t:e}))});function gr(t){let e=[];if(t)t:for(let{name:n}of t){for(let t=0;t<n.length;t++){let i=n[t];if(/[a-zA-Z]/.test(i)&&!e.some((t=>t.toLowerCase()==i.toLowerCase()))){e.push(i);continue t}}e.push("")}return e}function wr(t,e,n){var i;let r=n?gr(e.actions):[];return Ie("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},Ie("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(t):e.message),null===(i=e.actions)||void 0===i?void 0:i.map(((n,i)=>{let s=!1,o=i=>{if(i.preventDefault(),s)return;s=!0;let r=sr(t.state.field(cr).diagnostics,e);r&&n.apply(t,r.from,r.to)},{name:l}=n,h=r[i]?l.indexOf(r[i]):-1,c=h<0?l:[l.slice(0,h),Ie("u",l.slice(h,h+1)),l.slice(h+1)];return Ie("button",{type:"button",class:"cm-diagnosticAction",onclick:o,onmousedown:o,"aria-label":` Action: ${l}${h<0?"":` (access key "${r[i]})"`}.`},c)})),e.source&&Ie("div",{class:"cm-diagnosticSource"},e.source))}class vr extends z{constructor(t){super(),this.sev=t}eq(t){return t.sev==this.sev}toDOM(){return Ie("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class yr{constructor(t,e){this.diagnostic=e,this.id="item_"+Math.floor(4294967295*Math.random()).toString(16),this.dom=wr(t,e,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class br{constructor(t){this.view=t,this.items=[];this.list=Ie("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:e=>{if(27==e.keyCode)dr(this.view),this.view.focus();else if(38==e.keyCode||33==e.keyCode)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(40==e.keyCode||34==e.keyCode)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(36==e.keyCode)this.moveSelection(0);else if(35==e.keyCode)this.moveSelection(this.items.length-1);else if(13==e.keyCode)this.view.focus();else{if(!(e.keyCode>=65&&e.keyCode<=90&&this.selectedIndex>=0))return;{let{diagnostic:n}=this.items[this.selectedIndex],i=gr(n.actions);for(let r=0;r<i.length;r++)if(i[r].toUpperCase().charCodeAt(0)==e.keyCode){let e=sr(this.view.state.field(cr).diagnostics,n);e&&n.actions[r].apply(t,e.from,e.to)}}}e.preventDefault()},onclick:t=>{for(let e=0;e<this.items.length;e++)this.items[e].dom.contains(t.target)&&this.moveSelection(e)}}),this.dom=Ie("div",{class:"cm-panel-lint"},this.list,Ie("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>dr(this.view)},"×")),this.update()}get selectedIndex(){let t=this.view.state.field(cr).selected;if(!t)return-1;for(let e=0;e<this.items.length;e++)if(this.items[e].diagnostic==t.diagnostic)return e;return-1}update(){let{diagnostics:t,selected:e}=this.view.state.field(cr),n=0,i=!1,r=null,s=new Set;for(t.between(0,this.view.state.doc.length,((t,o,{spec:l})=>{for(let t of l.diagnostics){if(s.has(t))continue;s.add(t);let o,l=-1;for(let e=n;e<this.items.length;e++)if(this.items[e].diagnostic==t){l=e;break}l<0?(o=new yr(this.view,t),this.items.splice(n,0,o),i=!0):(o=this.items[l],l>n&&(this.items.splice(n,l-n),i=!0)),e&&o.diagnostic==e.diagnostic?o.dom.hasAttribute("aria-selected")||(o.dom.setAttribute("aria-selected","true"),r=o):o.dom.hasAttribute("aria-selected")&&o.dom.removeAttribute("aria-selected"),n++}}));n<this.items.length&&!(1==this.items.length&&this.items[0].diagnostic.from<0);)i=!0,this.items.pop();0==this.items.length&&(this.items.push(new yr(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),i=!0),r?(this.list.setAttribute("aria-activedescendant",r.id),this.view.requestMeasure({key:this,read:()=>({sel:r.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:t,panel:e})=>{let n=e.height/this.list.offsetHeight;t.top<e.top?this.list.scrollTop-=(e.top-t.top)/n:t.bottom>e.bottom&&(this.list.scrollTop+=(t.bottom-e.bottom)/n)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),i&&this.sync()}sync(){let t=this.list.firstChild;function e(){let e=t;t=e.nextSibling,e.remove()}for(let n of this.items)if(n.dom.parentNode==this.list){for(;t!=n.dom;)e();t=n.dom.nextSibling}else this.list.insertBefore(n.dom,t);for(;t;)e()}moveSelection(t){if(this.selectedIndex<0)return;let e=sr(this.view.state.field(cr).diagnostics,this.items[t].diagnostic);e&&this.view.dispatch({selection:{anchor:e.from,head:e.to},scrollIntoView:!0,effects:hr.of(e)})}static open(t){return new br(t)}}function kr(t){return function(t,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${e}>${encodeURIComponent(t)}</svg>')`}(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${t}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}const xr=t.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:kr("#d11")},".cm-lintRange-warning":{backgroundImage:kr("orange")},".cm-lintRange-info":{backgroundImage:kr("#999")},".cm-lintRange-hint":{backgroundImage:kr("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}}});function Mr(t){return"error"==t?4:"warning"==t?3:"info"==t?2:1}function Ir(t){let e="hint",n=1;for(let i of t){let t=Mr(i.severity);t>n&&(n=t,e=i.severity)}return e}const Ar=[cr,t.decorations.compute([cr],(t=>{let{selected:e,panel:n}=t.field(cr);return e&&n&&e.from!=e.to?M.set([ur.range(e.from,e.to)]):M.none})),U(ar,{hideOn:function(t,e){let n=e.pos,i=e.end||n,r=t.state.facet(mr).hideOn(t,n,i);if(null!=r)return r;let s=t.startState.doc.lineAt(e.pos);return!(!t.effects.some((t=>t.is(or)))&&!t.changes.touchesRange(s.from,Math.max(s.to,i)))}}),xr],Sr=t=>void 0===t||t,Dr=(e={})=>{let n=[];Sr(e.defaultKeymap)&&n.push(...Me),Sr(e.closeBracketsKeymap)&&n.push(...Ni),Sr(e.searchKeymap)&&n.push(...kn),Sr(e.historyKeymap)&&n.push(...Et),Sr(e.foldKeymap)&&n.push(...q),Sr(e.lintKeymap)&&n.push(...pr);const i=[];return Sr(e.highlightActiveLineGutter)&&i.push(H()),Sr(e.highlightSpecialChars)&&i.push(N()),Sr(e.history)&&i.push(function(e={}){return[ft,at.of(e),t.domEventHandlers({beforeinput(t,e){let n="historyUndo"==t.inputType?pt:"historyRedo"==t.inputType?mt:null;return!!n&&(t.preventDefault(),n(e))}})]}()),Sr(e.foldGutter)&&i.push(J()),Sr(e.drawSelection)&&i.push(_()),Sr(e.dropCursor)&&i.push(G()),Sr(e.allowMultipleSelections)&&i.push($.allowMultipleSelections.of(!0)),Sr(e.indentOnInput)&&i.push(K()),Sr(e.bracketMatching)&&i.push(Q()),Sr(e.closeBrackets)&&i.push([Hi,Fi]),Sr(e.autocompletion)&&i.push(Zi()),Sr(e.rectangularSelection)&&i.push(X()),Sr(e.crosshairCursor)&&i.push(Y()),Sr(e.highlightActiveLine)&&i.push(Z()),Sr(e.highlightSelectionMatches)&&i.push(function(t){let e=[Ne,He];return t&&e.push(We.of(t)),e}()),e.enableSearch||i.push(T.of([{key:"Mod-f",run:()=>!0}])),e.tabSize&&"number"==typeof e.tabSize&&i.push(v.of(" ".repeat(e.tabSize))),i.concat([T.of(n.flat())]).filter(Boolean)};export{ai as a,Zi as b,$n as c,di as d,nr as e,Dr as f,On as i,Ti as s};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
System.register(["./nile-code-editor.cjs.js","tslib","lit","lit/decorators.js","./nile-code-editor.css.cjs.js","../index-
|
|
1
|
+
System.register(["./nile-code-editor.cjs.js","tslib","lit","lit/decorators.js","./nile-code-editor.css.cjs.js","../index-f6944844.cjs.js","../index-178e1e57.cjs.js","./extensionSetup.cjs.js","../internal/nile-element.cjs.js","../internal/accessibility/a11y.state.enum.cjs.js","../internal/accessibility/a11y.property.enum.cjs.js","../internal/accessibility/role.enum.cjs.js","lit/directives/class-map.js","./theme.cjs.js"],function(_export,_context){"use strict";return{setters:[function(_nileCodeEditorCjsJs){_export("NileCodeEditor",_nileCodeEditorCjsJs.N);},function(_tslib){},function(_lit){},function(_litDecoratorsJs){},function(_nileCodeEditorCssCjsJs){},function(_index007CjsJs){},function(_index008CjsJs){},function(_extensionSetupCjsJs){},function(_internalNileElementCjsJs){},function(_internalAccessibilityA11yStateEnumCjsJs){},function(_internalAccessibilityA11yPropertyEnumCjsJs){},function(_internalAccessibilityRoleEnumCjsJs){},function(_litDirectivesClassMapJs){},function(_themeCjsJs){}],execute:function execute(){}};});
|
|
2
2
|
//# sourceMappingURL=index.cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export{N as NileCodeEditor}from"./nile-code-editor.esm.js";import"tslib";import"lit";import"lit/decorators.js";import"./nile-code-editor.css.esm.js";import"../index-
|
|
1
|
+
export{N as NileCodeEditor}from"./nile-code-editor.esm.js";import"tslib";import"lit";import"lit/decorators.js";import"./nile-code-editor.css.esm.js";import"../index-0fe57384.esm.js";import"../index-920675c4.esm.js";import"./extensionSetup.esm.js";import"../internal/nile-element.esm.js";import"../internal/accessibility/a11y.state.enum.esm.js";import"../internal/accessibility/a11y.property.enum.esm.js";import"../internal/accessibility/role.enum.esm.js";import"lit/directives/class-map.js";import"./theme.esm.js";
|