diff --git a/frontend-dist/JuliaMono-Bold.68f7f035.woff2 b/frontend-dist/JuliaMono-Bold.68f7f035.woff2
new file mode 100644
index 0000000000..7cb28c7db1
Binary files /dev/null and b/frontend-dist/JuliaMono-Bold.68f7f035.woff2 differ
diff --git a/frontend-dist/JuliaMono-BoldLatin.a78b1eda.woff2 b/frontend-dist/JuliaMono-BoldLatin.a78b1eda.woff2
new file mode 100644
index 0000000000..3ce0143c23
Binary files /dev/null and b/frontend-dist/JuliaMono-BoldLatin.a78b1eda.woff2 differ
diff --git a/frontend-dist/JuliaMono-Regular.de4da299.woff2 b/frontend-dist/JuliaMono-Regular.de4da299.woff2
new file mode 100644
index 0000000000..e24039dda8
Binary files /dev/null and b/frontend-dist/JuliaMono-Regular.de4da299.woff2 differ
diff --git a/frontend-dist/JuliaMono-RegularItalic.963ec4f3.woff2 b/frontend-dist/JuliaMono-RegularItalic.963ec4f3.woff2
new file mode 100644
index 0000000000..3ef6f2865b
Binary files /dev/null and b/frontend-dist/JuliaMono-RegularItalic.963ec4f3.woff2 differ
diff --git a/frontend-dist/JuliaMono-RegularLatin.d51844a8.woff2 b/frontend-dist/JuliaMono-RegularLatin.d51844a8.woff2
new file mode 100644
index 0000000000..f334d875b3
Binary files /dev/null and b/frontend-dist/JuliaMono-RegularLatin.d51844a8.woff2 differ
diff --git a/frontend-dist/Vollkorn-Black.0ebdfbf5.woff2 b/frontend-dist/Vollkorn-Black.0ebdfbf5.woff2
new file mode 100644
index 0000000000..b51a37a406
Binary files /dev/null and b/frontend-dist/Vollkorn-Black.0ebdfbf5.woff2 differ
diff --git a/frontend-dist/Vollkorn-BlackItalic.4095acfe.woff2 b/frontend-dist/Vollkorn-BlackItalic.4095acfe.woff2
new file mode 100644
index 0000000000..bb2e060ce4
Binary files /dev/null and b/frontend-dist/Vollkorn-BlackItalic.4095acfe.woff2 differ
diff --git a/frontend-dist/Vollkorn-Bold.6e1feb70.woff2 b/frontend-dist/Vollkorn-Bold.6e1feb70.woff2
new file mode 100644
index 0000000000..cfb12e1520
Binary files /dev/null and b/frontend-dist/Vollkorn-Bold.6e1feb70.woff2 differ
diff --git a/frontend-dist/Vollkorn-BoldItalic.a48ab300.woff2 b/frontend-dist/Vollkorn-BoldItalic.a48ab300.woff2
new file mode 100644
index 0000000000..23d7a6c844
Binary files /dev/null and b/frontend-dist/Vollkorn-BoldItalic.a48ab300.woff2 differ
diff --git a/frontend-dist/Vollkorn-SemiBold.8072eb6c.woff2 b/frontend-dist/Vollkorn-SemiBold.8072eb6c.woff2
new file mode 100644
index 0000000000..78b781055b
Binary files /dev/null and b/frontend-dist/Vollkorn-SemiBold.8072eb6c.woff2 differ
diff --git a/frontend-dist/Vollkorn-SemiBoldItalic.5c3cd265.woff2 b/frontend-dist/Vollkorn-SemiBoldItalic.5c3cd265.woff2
new file mode 100644
index 0000000000..2162ab8ef4
Binary files /dev/null and b/frontend-dist/Vollkorn-SemiBoldItalic.5c3cd265.woff2 differ
diff --git a/frontend-dist/add-outline.e3c93c35.svg b/frontend-dist/add-outline.e3c93c35.svg
new file mode 100644
index 0000000000..7c7fb14877
--- /dev/null
+++ b/frontend-dist/add-outline.e3c93c35.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/frontend-dist/alegreya-sans-all-400-italic.f87bfe89.woff b/frontend-dist/alegreya-sans-all-400-italic.f87bfe89.woff
new file mode 100644
index 0000000000..75ef6a5671
Binary files /dev/null and b/frontend-dist/alegreya-sans-all-400-italic.f87bfe89.woff differ
diff --git a/frontend-dist/alegreya-sans-all-400-normal.a91dc265.woff b/frontend-dist/alegreya-sans-all-400-normal.a91dc265.woff
new file mode 100644
index 0000000000..0658fd17cc
Binary files /dev/null and b/frontend-dist/alegreya-sans-all-400-normal.a91dc265.woff differ
diff --git a/frontend-dist/alegreya-sans-all-500-italic.8917c3da.woff b/frontend-dist/alegreya-sans-all-500-italic.8917c3da.woff
new file mode 100644
index 0000000000..02b7436cd3
Binary files /dev/null and b/frontend-dist/alegreya-sans-all-500-italic.8917c3da.woff differ
diff --git a/frontend-dist/alegreya-sans-all-500-normal.5db27a5b.woff b/frontend-dist/alegreya-sans-all-500-normal.5db27a5b.woff
new file mode 100644
index 0000000000..4a6b7ff755
Binary files /dev/null and b/frontend-dist/alegreya-sans-all-500-normal.5db27a5b.woff differ
diff --git a/frontend-dist/alegreya-sans-all-700-italic.a6d70e05.woff b/frontend-dist/alegreya-sans-all-700-italic.a6d70e05.woff
new file mode 100644
index 0000000000..5118953a73
Binary files /dev/null and b/frontend-dist/alegreya-sans-all-700-italic.a6d70e05.woff differ
diff --git a/frontend-dist/alegreya-sans-all-700-normal.29d7dfa9.woff b/frontend-dist/alegreya-sans-all-700-normal.29d7dfa9.woff
new file mode 100644
index 0000000000..b8c1d8a284
Binary files /dev/null and b/frontend-dist/alegreya-sans-all-700-normal.29d7dfa9.woff differ
diff --git a/frontend-dist/alegreya-sans-cyrillic-400-italic.8c81649c.woff2 b/frontend-dist/alegreya-sans-cyrillic-400-italic.8c81649c.woff2
new file mode 100644
index 0000000000..3ebce2cffa
Binary files /dev/null and b/frontend-dist/alegreya-sans-cyrillic-400-italic.8c81649c.woff2 differ
diff --git a/frontend-dist/alegreya-sans-cyrillic-400-normal.ab3d1dcc.woff2 b/frontend-dist/alegreya-sans-cyrillic-400-normal.ab3d1dcc.woff2
new file mode 100644
index 0000000000..3434d6ed9e
Binary files /dev/null and b/frontend-dist/alegreya-sans-cyrillic-400-normal.ab3d1dcc.woff2 differ
diff --git a/frontend-dist/alegreya-sans-cyrillic-500-italic.a40f95be.woff2 b/frontend-dist/alegreya-sans-cyrillic-500-italic.a40f95be.woff2
new file mode 100644
index 0000000000..7338c02062
Binary files /dev/null and b/frontend-dist/alegreya-sans-cyrillic-500-italic.a40f95be.woff2 differ
diff --git a/frontend-dist/alegreya-sans-cyrillic-500-normal.8a029e9d.woff2 b/frontend-dist/alegreya-sans-cyrillic-500-normal.8a029e9d.woff2
new file mode 100644
index 0000000000..c3c821ba91
Binary files /dev/null and b/frontend-dist/alegreya-sans-cyrillic-500-normal.8a029e9d.woff2 differ
diff --git a/frontend-dist/alegreya-sans-cyrillic-700-italic.c4ef17a2.woff2 b/frontend-dist/alegreya-sans-cyrillic-700-italic.c4ef17a2.woff2
new file mode 100644
index 0000000000..ad187b0b86
Binary files /dev/null and b/frontend-dist/alegreya-sans-cyrillic-700-italic.c4ef17a2.woff2 differ
diff --git a/frontend-dist/alegreya-sans-cyrillic-700-normal.5a5aa5e3.woff2 b/frontend-dist/alegreya-sans-cyrillic-700-normal.5a5aa5e3.woff2
new file mode 100644
index 0000000000..dafc6f88c2
Binary files /dev/null and b/frontend-dist/alegreya-sans-cyrillic-700-normal.5a5aa5e3.woff2 differ
diff --git a/frontend-dist/alegreya-sans-cyrillic-ext-400-italic.7c2a4a40.woff2 b/frontend-dist/alegreya-sans-cyrillic-ext-400-italic.7c2a4a40.woff2
new file mode 100644
index 0000000000..4ead31cd71
Binary files /dev/null and b/frontend-dist/alegreya-sans-cyrillic-ext-400-italic.7c2a4a40.woff2 differ
diff --git a/frontend-dist/alegreya-sans-cyrillic-ext-400-normal.5f5cc2ef.woff2 b/frontend-dist/alegreya-sans-cyrillic-ext-400-normal.5f5cc2ef.woff2
new file mode 100644
index 0000000000..f81ae10995
Binary files /dev/null and b/frontend-dist/alegreya-sans-cyrillic-ext-400-normal.5f5cc2ef.woff2 differ
diff --git a/frontend-dist/alegreya-sans-cyrillic-ext-500-italic.78248b65.woff2 b/frontend-dist/alegreya-sans-cyrillic-ext-500-italic.78248b65.woff2
new file mode 100644
index 0000000000..387eb05d64
Binary files /dev/null and b/frontend-dist/alegreya-sans-cyrillic-ext-500-italic.78248b65.woff2 differ
diff --git a/frontend-dist/alegreya-sans-cyrillic-ext-500-normal.0e6ee102.woff2 b/frontend-dist/alegreya-sans-cyrillic-ext-500-normal.0e6ee102.woff2
new file mode 100644
index 0000000000..5f05b9e7d0
Binary files /dev/null and b/frontend-dist/alegreya-sans-cyrillic-ext-500-normal.0e6ee102.woff2 differ
diff --git a/frontend-dist/alegreya-sans-cyrillic-ext-700-italic.69b0617e.woff2 b/frontend-dist/alegreya-sans-cyrillic-ext-700-italic.69b0617e.woff2
new file mode 100644
index 0000000000..ae9dc86ec0
Binary files /dev/null and b/frontend-dist/alegreya-sans-cyrillic-ext-700-italic.69b0617e.woff2 differ
diff --git a/frontend-dist/alegreya-sans-cyrillic-ext-700-normal.2e02b08f.woff2 b/frontend-dist/alegreya-sans-cyrillic-ext-700-normal.2e02b08f.woff2
new file mode 100644
index 0000000000..43b5ba1286
Binary files /dev/null and b/frontend-dist/alegreya-sans-cyrillic-ext-700-normal.2e02b08f.woff2 differ
diff --git a/frontend-dist/alegreya-sans-greek-400-italic.1b909c63.woff2 b/frontend-dist/alegreya-sans-greek-400-italic.1b909c63.woff2
new file mode 100644
index 0000000000..c1cebd7a3f
Binary files /dev/null and b/frontend-dist/alegreya-sans-greek-400-italic.1b909c63.woff2 differ
diff --git a/frontend-dist/alegreya-sans-greek-400-normal.4e5a8597.woff2 b/frontend-dist/alegreya-sans-greek-400-normal.4e5a8597.woff2
new file mode 100644
index 0000000000..19ba95016c
Binary files /dev/null and b/frontend-dist/alegreya-sans-greek-400-normal.4e5a8597.woff2 differ
diff --git a/frontend-dist/alegreya-sans-greek-500-italic.19d09eea.woff2 b/frontend-dist/alegreya-sans-greek-500-italic.19d09eea.woff2
new file mode 100644
index 0000000000..5b9906e9c0
Binary files /dev/null and b/frontend-dist/alegreya-sans-greek-500-italic.19d09eea.woff2 differ
diff --git a/frontend-dist/alegreya-sans-greek-500-normal.54a6041f.woff2 b/frontend-dist/alegreya-sans-greek-500-normal.54a6041f.woff2
new file mode 100644
index 0000000000..5cb0e6b5a0
Binary files /dev/null and b/frontend-dist/alegreya-sans-greek-500-normal.54a6041f.woff2 differ
diff --git a/frontend-dist/alegreya-sans-greek-700-italic.5aef27cf.woff2 b/frontend-dist/alegreya-sans-greek-700-italic.5aef27cf.woff2
new file mode 100644
index 0000000000..2a17d2edfa
Binary files /dev/null and b/frontend-dist/alegreya-sans-greek-700-italic.5aef27cf.woff2 differ
diff --git a/frontend-dist/alegreya-sans-greek-700-normal.452fc62e.woff2 b/frontend-dist/alegreya-sans-greek-700-normal.452fc62e.woff2
new file mode 100644
index 0000000000..7415e7b66d
Binary files /dev/null and b/frontend-dist/alegreya-sans-greek-700-normal.452fc62e.woff2 differ
diff --git a/frontend-dist/alegreya-sans-greek-ext-400-italic.550f5118.woff2 b/frontend-dist/alegreya-sans-greek-ext-400-italic.550f5118.woff2
new file mode 100644
index 0000000000..4ddc332622
Binary files /dev/null and b/frontend-dist/alegreya-sans-greek-ext-400-italic.550f5118.woff2 differ
diff --git a/frontend-dist/alegreya-sans-greek-ext-400-normal.b82a0aea.woff2 b/frontend-dist/alegreya-sans-greek-ext-400-normal.b82a0aea.woff2
new file mode 100644
index 0000000000..f85a41731d
Binary files /dev/null and b/frontend-dist/alegreya-sans-greek-ext-400-normal.b82a0aea.woff2 differ
diff --git a/frontend-dist/alegreya-sans-greek-ext-500-italic.8b2e952b.woff2 b/frontend-dist/alegreya-sans-greek-ext-500-italic.8b2e952b.woff2
new file mode 100644
index 0000000000..77cf5e4551
Binary files /dev/null and b/frontend-dist/alegreya-sans-greek-ext-500-italic.8b2e952b.woff2 differ
diff --git a/frontend-dist/alegreya-sans-greek-ext-500-normal.00f2c6f3.woff2 b/frontend-dist/alegreya-sans-greek-ext-500-normal.00f2c6f3.woff2
new file mode 100644
index 0000000000..a6681017e2
Binary files /dev/null and b/frontend-dist/alegreya-sans-greek-ext-500-normal.00f2c6f3.woff2 differ
diff --git a/frontend-dist/alegreya-sans-greek-ext-700-italic.a1ccc0c2.woff2 b/frontend-dist/alegreya-sans-greek-ext-700-italic.a1ccc0c2.woff2
new file mode 100644
index 0000000000..ad23a55e70
Binary files /dev/null and b/frontend-dist/alegreya-sans-greek-ext-700-italic.a1ccc0c2.woff2 differ
diff --git a/frontend-dist/alegreya-sans-greek-ext-700-normal.ca9ee8e1.woff2 b/frontend-dist/alegreya-sans-greek-ext-700-normal.ca9ee8e1.woff2
new file mode 100644
index 0000000000..49c5654293
Binary files /dev/null and b/frontend-dist/alegreya-sans-greek-ext-700-normal.ca9ee8e1.woff2 differ
diff --git a/frontend-dist/alegreya-sans-latin-400-italic.ec56f658.woff2 b/frontend-dist/alegreya-sans-latin-400-italic.ec56f658.woff2
new file mode 100644
index 0000000000..df999c7eb2
Binary files /dev/null and b/frontend-dist/alegreya-sans-latin-400-italic.ec56f658.woff2 differ
diff --git a/frontend-dist/alegreya-sans-latin-400-normal.62b57001.woff2 b/frontend-dist/alegreya-sans-latin-400-normal.62b57001.woff2
new file mode 100644
index 0000000000..5d98f5cde9
Binary files /dev/null and b/frontend-dist/alegreya-sans-latin-400-normal.62b57001.woff2 differ
diff --git a/frontend-dist/alegreya-sans-latin-500-italic.6d8350bf.woff2 b/frontend-dist/alegreya-sans-latin-500-italic.6d8350bf.woff2
new file mode 100644
index 0000000000..7cd291700f
Binary files /dev/null and b/frontend-dist/alegreya-sans-latin-500-italic.6d8350bf.woff2 differ
diff --git a/frontend-dist/alegreya-sans-latin-500-normal.4428c984.woff2 b/frontend-dist/alegreya-sans-latin-500-normal.4428c984.woff2
new file mode 100644
index 0000000000..cf40f1fce9
Binary files /dev/null and b/frontend-dist/alegreya-sans-latin-500-normal.4428c984.woff2 differ
diff --git a/frontend-dist/alegreya-sans-latin-700-italic.abc64c8a.woff2 b/frontend-dist/alegreya-sans-latin-700-italic.abc64c8a.woff2
new file mode 100644
index 0000000000..befb4809c6
Binary files /dev/null and b/frontend-dist/alegreya-sans-latin-700-italic.abc64c8a.woff2 differ
diff --git a/frontend-dist/alegreya-sans-latin-700-normal.96e2fcc9.woff2 b/frontend-dist/alegreya-sans-latin-700-normal.96e2fcc9.woff2
new file mode 100644
index 0000000000..de0826d1b8
Binary files /dev/null and b/frontend-dist/alegreya-sans-latin-700-normal.96e2fcc9.woff2 differ
diff --git a/frontend-dist/alegreya-sans-latin-ext-400-italic.b9ce632b.woff2 b/frontend-dist/alegreya-sans-latin-ext-400-italic.b9ce632b.woff2
new file mode 100644
index 0000000000..c15ce0ec2c
Binary files /dev/null and b/frontend-dist/alegreya-sans-latin-ext-400-italic.b9ce632b.woff2 differ
diff --git a/frontend-dist/alegreya-sans-latin-ext-400-normal.1c1602b0.woff2 b/frontend-dist/alegreya-sans-latin-ext-400-normal.1c1602b0.woff2
new file mode 100644
index 0000000000..cc81c0133c
Binary files /dev/null and b/frontend-dist/alegreya-sans-latin-ext-400-normal.1c1602b0.woff2 differ
diff --git a/frontend-dist/alegreya-sans-latin-ext-500-italic.d15c8f11.woff2 b/frontend-dist/alegreya-sans-latin-ext-500-italic.d15c8f11.woff2
new file mode 100644
index 0000000000..c707422915
Binary files /dev/null and b/frontend-dist/alegreya-sans-latin-ext-500-italic.d15c8f11.woff2 differ
diff --git a/frontend-dist/alegreya-sans-latin-ext-500-normal.637067c1.woff2 b/frontend-dist/alegreya-sans-latin-ext-500-normal.637067c1.woff2
new file mode 100644
index 0000000000..6b61635fa8
Binary files /dev/null and b/frontend-dist/alegreya-sans-latin-ext-500-normal.637067c1.woff2 differ
diff --git a/frontend-dist/alegreya-sans-latin-ext-700-italic.733aea09.woff2 b/frontend-dist/alegreya-sans-latin-ext-700-italic.733aea09.woff2
new file mode 100644
index 0000000000..631822edac
Binary files /dev/null and b/frontend-dist/alegreya-sans-latin-ext-700-italic.733aea09.woff2 differ
diff --git a/frontend-dist/alegreya-sans-latin-ext-700-normal.b5306f41.woff2 b/frontend-dist/alegreya-sans-latin-ext-700-normal.b5306f41.woff2
new file mode 100644
index 0000000000..1896761236
Binary files /dev/null and b/frontend-dist/alegreya-sans-latin-ext-700-normal.b5306f41.woff2 differ
diff --git a/frontend-dist/alegreya-sans-vietnamese-400-italic.d08e8dff.woff2 b/frontend-dist/alegreya-sans-vietnamese-400-italic.d08e8dff.woff2
new file mode 100644
index 0000000000..5552c00e3d
Binary files /dev/null and b/frontend-dist/alegreya-sans-vietnamese-400-italic.d08e8dff.woff2 differ
diff --git a/frontend-dist/alegreya-sans-vietnamese-400-normal.bdc8a622.woff2 b/frontend-dist/alegreya-sans-vietnamese-400-normal.bdc8a622.woff2
new file mode 100644
index 0000000000..3ec2c8eb20
Binary files /dev/null and b/frontend-dist/alegreya-sans-vietnamese-400-normal.bdc8a622.woff2 differ
diff --git a/frontend-dist/alegreya-sans-vietnamese-500-italic.3ff20df8.woff2 b/frontend-dist/alegreya-sans-vietnamese-500-italic.3ff20df8.woff2
new file mode 100644
index 0000000000..528c2f36f7
Binary files /dev/null and b/frontend-dist/alegreya-sans-vietnamese-500-italic.3ff20df8.woff2 differ
diff --git a/frontend-dist/alegreya-sans-vietnamese-500-normal.97e250df.woff2 b/frontend-dist/alegreya-sans-vietnamese-500-normal.97e250df.woff2
new file mode 100644
index 0000000000..7f1f015cb3
Binary files /dev/null and b/frontend-dist/alegreya-sans-vietnamese-500-normal.97e250df.woff2 differ
diff --git a/frontend-dist/alegreya-sans-vietnamese-700-italic.7de0cccc.woff2 b/frontend-dist/alegreya-sans-vietnamese-700-italic.7de0cccc.woff2
new file mode 100644
index 0000000000..8bdb25ba3c
Binary files /dev/null and b/frontend-dist/alegreya-sans-vietnamese-700-italic.7de0cccc.woff2 differ
diff --git a/frontend-dist/alegreya-sans-vietnamese-700-normal.59390763.woff2 b/frontend-dist/alegreya-sans-vietnamese-700-normal.59390763.woff2
new file mode 100644
index 0000000000..bc5e38d57d
Binary files /dev/null and b/frontend-dist/alegreya-sans-vietnamese-700-normal.59390763.woff2 differ
diff --git a/frontend-dist/arrow-back-outline.9ae1bed8.svg b/frontend-dist/arrow-back-outline.9ae1bed8.svg
new file mode 100644
index 0000000000..8fc34ff6ec
--- /dev/null
+++ b/frontend-dist/arrow-back-outline.9ae1bed8.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/frontend-dist/arrow-forward-outline.f5f68f5c.svg b/frontend-dist/arrow-forward-outline.f5f68f5c.svg
new file mode 100644
index 0000000000..32a9f4f309
--- /dev/null
+++ b/frontend-dist/arrow-forward-outline.f5f68f5c.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/frontend-dist/arrow-redo-circle-outline.dfa899f4.svg b/frontend-dist/arrow-redo-circle-outline.dfa899f4.svg
new file mode 100644
index 0000000000..d0d9e1124d
--- /dev/null
+++ b/frontend-dist/arrow-redo-circle-outline.dfa899f4.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/frontend-dist/arrow-undo-outline.d8c99108.svg b/frontend-dist/arrow-undo-outline.d8c99108.svg
new file mode 100644
index 0000000000..a5d529e729
--- /dev/null
+++ b/frontend-dist/arrow-undo-outline.d8c99108.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/frontend-dist/arrow-up-circle-outline.3f146ffe.svg b/frontend-dist/arrow-up-circle-outline.3f146ffe.svg
new file mode 100644
index 0000000000..ba46f260f7
--- /dev/null
+++ b/frontend-dist/arrow-up-circle-outline.3f146ffe.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/frontend-dist/ban-outline.c97da9b4.svg b/frontend-dist/ban-outline.c97da9b4.svg
new file mode 100644
index 0000000000..c52ff62277
--- /dev/null
+++ b/frontend-dist/ban-outline.c97da9b4.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/frontend-dist/bandage-outline.37f88b63.svg b/frontend-dist/bandage-outline.37f88b63.svg
new file mode 100644
index 0000000000..a9e3764e9f
--- /dev/null
+++ b/frontend-dist/bandage-outline.37f88b63.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/frontend-dist/caret-down-outline.4253a2fe.svg b/frontend-dist/caret-down-outline.4253a2fe.svg
new file mode 100644
index 0000000000..c4c15b4722
--- /dev/null
+++ b/frontend-dist/caret-down-outline.4253a2fe.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/frontend-dist/caret-forward-circle-outline.d0bf2b34.svg b/frontend-dist/caret-forward-circle-outline.d0bf2b34.svg
new file mode 100644
index 0000000000..093c8e4ca2
--- /dev/null
+++ b/frontend-dist/caret-forward-circle-outline.d0bf2b34.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/frontend-dist/caret-forward-outline.348a84b6.svg b/frontend-dist/caret-forward-outline.348a84b6.svg
new file mode 100644
index 0000000000..888285c953
--- /dev/null
+++ b/frontend-dist/caret-forward-outline.348a84b6.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/frontend-dist/chatbox-ellipses-outline.4334a3a4.svg b/frontend-dist/chatbox-ellipses-outline.4334a3a4.svg
new file mode 100644
index 0000000000..4e04a58545
--- /dev/null
+++ b/frontend-dist/chatbox-ellipses-outline.4334a3a4.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/frontend-dist/checkmark-outline.4fb8c646.svg b/frontend-dist/checkmark-outline.4fb8c646.svg
new file mode 100644
index 0000000000..f62dcf9212
--- /dev/null
+++ b/frontend-dist/checkmark-outline.4fb8c646.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/frontend-dist/chevron-down-outline.1efaf1cc.svg b/frontend-dist/chevron-down-outline.1efaf1cc.svg
new file mode 100644
index 0000000000..e7a50cd112
--- /dev/null
+++ b/frontend-dist/chevron-down-outline.1efaf1cc.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/frontend-dist/chevron-forward-circle-outline.babf2a99.svg b/frontend-dist/chevron-forward-circle-outline.babf2a99.svg
new file mode 100644
index 0000000000..9e63a3c049
--- /dev/null
+++ b/frontend-dist/chevron-forward-circle-outline.babf2a99.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/frontend-dist/close-circle-outline.4baeedb9.svg b/frontend-dist/close-circle-outline.4baeedb9.svg
new file mode 100644
index 0000000000..588e2d4c82
--- /dev/null
+++ b/frontend-dist/close-circle-outline.4baeedb9.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/frontend-dist/close-circle.d0f6eac6.svg b/frontend-dist/close-circle.d0f6eac6.svg
new file mode 100644
index 0000000000..cce96081a3
--- /dev/null
+++ b/frontend-dist/close-circle.d0f6eac6.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/frontend-dist/close-outline.9c22a232.svg b/frontend-dist/close-outline.9c22a232.svg
new file mode 100644
index 0000000000..17d07818e6
--- /dev/null
+++ b/frontend-dist/close-outline.9c22a232.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/frontend-dist/cloud-download-outline.8c1ff9bb.svg b/frontend-dist/cloud-download-outline.8c1ff9bb.svg
new file mode 100644
index 0000000000..939a8c238e
--- /dev/null
+++ b/frontend-dist/cloud-download-outline.8c1ff9bb.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/frontend-dist/cloud-offline-outline.ac2eade9.svg b/frontend-dist/cloud-offline-outline.ac2eade9.svg
new file mode 100644
index 0000000000..426ff3b0d9
--- /dev/null
+++ b/frontend-dist/cloud-offline-outline.ac2eade9.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/frontend-dist/copy-outline.0f561529.svg b/frontend-dist/copy-outline.0f561529.svg
new file mode 100644
index 0000000000..01e29db632
--- /dev/null
+++ b/frontend-dist/copy-outline.0f561529.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/frontend-dist/document-text-outline.8d1e2333.svg b/frontend-dist/document-text-outline.8d1e2333.svg
new file mode 100644
index 0000000000..dacd264f49
--- /dev/null
+++ b/frontend-dist/document-text-outline.8d1e2333.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/frontend-dist/download-outline.523a74d8.svg b/frontend-dist/download-outline.523a74d8.svg
new file mode 100644
index 0000000000..8f0e680543
--- /dev/null
+++ b/frontend-dist/download-outline.523a74d8.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/frontend-dist/editor.30fdc042.js b/frontend-dist/editor.30fdc042.js
new file mode 100644
index 0000000000..3c4726b9af
--- /dev/null
+++ b/frontend-dist/editor.30fdc042.js
@@ -0,0 +1,5 @@
+function e(e,t,i,n){Object.defineProperty(e,t,{get:i,set:n,enumerable:!0,configurable:!0})}var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},i={},n={},r=t.parcelRequire94c2;null==r&&((r=function(e){if(e in i)return i[e].exports;if(e in n){var t=n[e];delete n[e];var r={id:e,exports:{}};return i[e]=r,t.call(r.exports,r,r.exports),r.exports}var O=new Error("Cannot find module '"+e+"'");throw O.code="MODULE_NOT_FOUND",O}).register=function(e,t){n[e]=t},t.parcelRequire94c2=r),r.register("fBBKY",(function(t,i){e(t.exports,"html",(()=>O)),e(t.exports,"render",(()=>r("29nid").render)),e(t.exports,"Component",(()=>r("29nid").Component)),e(t.exports,"useEffect",(()=>r("1051i").useEffect)),e(t.exports,"useLayoutEffect",(()=>r("1051i").useLayoutEffect)),e(t.exports,"useState",(()=>r("1051i").useState)),e(t.exports,"useRef",(()=>r("1051i").useRef)),e(t.exports,"useMemo",(()=>r("1051i").useMemo)),e(t.exports,"useCallback",(()=>r("1051i").useCallback)),e(t.exports,"createContext",(()=>r("29nid").createContext)),e(t.exports,"createRef",(()=>r("29nid").createRef)),e(t.exports,"useContext",(()=>r("1051i").useContext)),e(t.exports,"h",(()=>r("29nid").h)),e(t.exports,"cloneElement",(()=>r("29nid").cloneElement)),e(t.exports,"hydrate",(()=>r("29nid").hydrate)),r("3DSZl");var n=r("29nid");r("8Fvxu");r("1051i");r("17pQx");const O=r("k2XV1").default.bind(n.h)})),r.register("3DSZl",(function(t,i){e(t.exports,"h",(()=>r("29nid").h)),e(t.exports,"render",(()=>r("29nid").render)),e(t.exports,"Component",(()=>r("29nid").Component)),e(t.exports,"createContext",(()=>r("29nid").createContext)),e(t.exports,"createRef",(()=>r("29nid").createRef)),e(t.exports,"cloneElement",(()=>r("29nid").cloneElement)),e(t.exports,"hydrate",(()=>r("29nid").hydrate)),r("29nid")})),r.register("29nid",(function(t,i){e(t.exports,"options",(()=>r)),e(t.exports,"createRef",(()=>Q)),e(t.exports,"Component",(()=>g)),e(t.exports,"render",(()=>Y)),e(t.exports,"hydrate",(()=>N)),e(t.exports,"cloneElement",(()=>Z)),e(t.exports,"createContext",(()=>z)),e(t.exports,"h",(()=>p));var n,r,O,s,o,a,l,h={},c=[],u=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;function f(e,t){for(var i in t)e[i]=t[i];return e}function d(e){var t=e.parentNode;t&&t.removeChild(e)}function p(e,t,i){var r,O,s,o={};for(s in t)"key"==s?r=t[s]:"ref"==s?O=t[s]:o[s]=t[s];if(arguments.length>2&&(o.children=arguments.length>3?n.call(arguments,2):i),"function"==typeof e&&null!=e.defaultProps)for(s in e.defaultProps)void 0===o[s]&&(o[s]=e.defaultProps[s]);return $(e,o,r,O,null)}function $(e,t,i,n,s){var o={type:e,props:t,key:i,ref:n,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:s??++O};return null==s&&null!=r.vnode&&r.vnode(o),o}function Q(){return{current:null}}function m(e){return e.children}function g(e,t){this.props=e,this.context=t}function P(e,t){if(null==t)return e.__?P(e.__,e.__.__k.indexOf(e)+1):null;for(var i;t0?$(p.type,p.props,p.key,null,p.__v):p)){if(p.__=i,p.__b=i.__b+1,null===(d=y[u])||d&&p.key==d.key&&p.type===d.type)y[u]=void 0;else for(f=0;f2&&(o.children=arguments.length>3?n.call(arguments,2):i),$(e.type,o,r||e.key,O||e.ref,null)}function z(e,t){var i={__c:t="__cC"+l++,__:e,Consumer:function(e,t){return e.children(t)},Provider:function(e){var i,n;return this.getChildContext||(i=[],(n={})[t]=this,this.getChildContext=function(){return n},this.shouldComponentUpdate=function(e){this.props.value!==e.value&&i.some(y)},this.sub=function(e){i.push(e);var t=e.componentWillUnmount;e.componentWillUnmount=function(){i.splice(i.indexOf(e),1),t&&t.call(e)}}),e.children}};return i.Provider.__=i.Consumer.contextType=i}n=c.slice,r={__e:function(e,t){for(var i,n,r;t=t.__;)if((i=t.__c)&&!i.__)try{if((n=i.constructor)&&null!=n.getDerivedStateFromError&&(i.setState(n.getDerivedStateFromError(e)),r=i.__d),null!=i.componentDidCatch&&(i.componentDidCatch(e),r=i.__d),r)return i.__E=i}catch(t){e=t}throw e}},O=0,g.prototype.setState=function(e,t){var i;i=null!=this.__s&&this.__s!==this.state?this.__s:this.__s=f({},this.state),"function"==typeof e&&(e=e(f({},i),this.props)),e&&f(i,e),null!=e&&this.__v&&(t&&this.__h.push(t),y(this))},g.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),y(this))},g.prototype.render=m,s=[],o="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,w.__r=0,l=0})),r.register("8Fvxu",(function(t,i){e(t.exports,"useEffect",(()=>r("1051i").useEffect)),e(t.exports,"useLayoutEffect",(()=>r("1051i").useLayoutEffect)),e(t.exports,"useState",(()=>r("1051i").useState)),e(t.exports,"useRef",(()=>r("1051i").useRef)),e(t.exports,"useMemo",(()=>r("1051i").useMemo)),e(t.exports,"useCallback",(()=>r("1051i").useCallback)),e(t.exports,"useContext",(()=>r("1051i").useContext)),r("1051i")})),r.register("1051i",(function(t,i){e(t.exports,"useState",(()=>$)),e(t.exports,"useEffect",(()=>Q)),e(t.exports,"useLayoutEffect",(()=>m)),e(t.exports,"useRef",(()=>g)),e(t.exports,"useMemo",(()=>P)),e(t.exports,"useCallback",(()=>X)),e(t.exports,"useContext",(()=>y));var n,O,s,o=r("29nid"),a=0,l=[],h=o.options.__b,c=o.options.__r,u=o.options.diffed,f=o.options.__c,d=o.options.unmount;function p(e,t){o.options.__h&&o.options.__h(O,e,a||t),a=0;var i=O.__H||(O.__H={__:[],__h:[]});return e>=i.__.length&&i.__.push({}),i.__[e]}function $(e){return a=1,function(e,t,i){var r=p(n++,2);return r.t=e,r.__c||(r.__=[i?i(t):v(void 0,t),function(e){var t=r.t(r.__[0],e);r.__[0]!==t&&(r.__=[t,r.__[1]],r.__c.setState({}))}],r.__c=O),r.__}(v,e)}function Q(e,t){var i=p(n++,3);!o.options.__s&&k(i.__H,t)&&(i.__=e,i.__H=t,O.__H.__h.push(i))}function m(e,t){var i=p(n++,4);!o.options.__s&&k(i.__H,t)&&(i.__=e,i.__H=t,O.__h.push(i))}function g(e){return a=5,P((function(){return{current:e}}),[])}function P(e,t){var i=p(n++,7);return k(i.__H,t)&&(i.__=e(),i.__H=t,i.__h=e),i.__}function X(e,t){return a=8,P((function(){return e}),t)}function y(e){var t=O.context[e.__c],i=p(n++,9);return i.c=e,t?(null==i.__&&(i.__=!0,t.sub(O)),t.props.value):e.__}function w(){for(var e;e=l.shift();)if(e.__P)try{e.__H.__h.forEach(x),e.__H.__h.forEach(S),e.__H.__h=[]}catch(t){e.__H.__h=[],o.options.__e(t,e.__v)}}o.options.__b=function(e){O=null,h&&h(e)},o.options.__r=function(e){c&&c(e),n=0;var t=(O=e.__c).__H;t&&(t.__h.forEach(x),t.__h.forEach(S),t.__h=[])},o.options.diffed=function(e){u&&u(e);var t=e.__c;t&&t.__H&&t.__H.__h.length&&(1!==l.push(t)&&s===o.options.requestAnimationFrame||((s=o.options.requestAnimationFrame)||function(e){var t,i=function(){clearTimeout(n),b&&cancelAnimationFrame(t),setTimeout(e)},n=setTimeout(i,100);b&&(t=requestAnimationFrame(i))})(w)),O=null},o.options.__c=function(e,t){t.some((function(e){try{e.__h.forEach(x),e.__h=e.__h.filter((function(e){return!e.__||S(e)}))}catch(i){t.some((function(e){e.__h&&(e.__h=[])})),t=[],o.options.__e(i,e.__v)}})),f&&f(e,t)},o.options.unmount=function(e){d&&d(e);var t,i=e.__c;i&&i.__H&&(i.__H.__.forEach((function(e){try{x(e)}catch(e){t=e}})),t&&o.options.__e(t,i.__v))};var b="function"==typeof requestAnimationFrame;function x(e){var t=O,i=e.__c;"function"==typeof i&&(e.__c=void 0,i()),O=t}function S(e){var t=O;e.__c=e.__(),O=t}function k(e,t){return!e||e.length!==t.length||t.some((function(t,i){return t!==e[i]}))}function v(e,t){return"function"==typeof t?t(e):t}})),r.register("17pQx",(function(t,i){var n;n=t.exports,Object.defineProperty(n,"__esModule",{value:!0,configurable:!0}),e(t.exports,"default",(()=>r("k2XV1").default));r("k2XV1"),r("k2XV1")})),r.register("k2XV1",(function(t,i){e(t.exports,"default",(()=>O));var n=function(e,t,i,r){var O;t[0]=0;for(var s=1;s=5&&((r||!e&&5===n)&&(s.push(n,0,r,i),n=6),e&&(s.push(n,e,0,i),n=6)),r=""},a=0;a"===t?(n=1,r=""):r=t+r[0]:O?t===O?O="":r+=t:'"'===t||"'"===t?O=t:">"===t?(o(),n=1):n&&("="===t?(n=5,i=r,r=""):"/"===t&&(n<5||">"===e[a][l+1])?(o(),3===n&&(s=s[0]),n=s,(s=s[0]).push(2,0,n),n=0):" "===t||"\t"===t||"\n"===t||"\r"===t?(o(),n=2):r+=t),3===n&&"!--"===r&&(n=4,s=s[0])}return o(),s}(e)),t),arguments,[])).length>1?t:t[0]}})),r.register("8aCbc",(function(e,t){try{null==window.process&&(window.process={}),null==window.process.env&&(window.process.env={}),window.process.env.NODE_ENV="production"}catch(e){console.warn("Couldn't set window.process.env, this might break some things")}})),r.register("9lAXI",(function(t,i){e(t.exports,"default",(()=>n));var n=window._})),r.register("5Kx1V",(function(t,i){e(t.exports,"timeout_promise",(()=>s)),e(t.exports,"ws_address_from_base",(()=>u)),e(t.exports,"create_pluto_connection",(()=>d));var n=r("wLwQ2"),O=r("bmSg5");r("cz9Zp");const s=(e,t)=>Promise.race([e,new Promise(((e,i)=>{setTimeout((()=>{i(new Error("Promise timed out."))}),t)}))]),o=()=>crypto.getRandomValues(new Uint32Array(1))[0].toString(36),a=e=>e.readyState==WebSocket.OPEN||e.readyState==WebSocket.CONNECTING,l=e=>{e.onopen=()=>{l(e)},e.onmessage=e.onclose=e.onerror=void 0;try{e.close(1e3,"byebye")}catch(e){}},h=(e,{on_message:t,on_socket_close:i},n=30)=>new Promise(((r,s)=>{const o=new WebSocket(e);let h=!1;const c=setTimeout((()=>{console.warn("Creating websocket timed out",(new Date).toLocaleTimeString()),l(o),s("Socket timeout")}),1e3*n),u=e=>{const t=O.pack(e);o.send(t)};let f=Promise.resolve();o.onmessage=e=>{f=f.then((async()=>{try{const i=await e.data.arrayBuffer(),n=O.unpack(new Uint8Array(i));try{t(n)}catch(t){console.error("Failed to process message from websocket",t,{message:n}),alert(`Something went wrong! You might need to refresh the page.\n\nPlease open an issue on https://github.com/fonsp/Pluto.jl with this info:\n\nFailed to process update\n${t.message}\n\n${JSON.stringify(e)}`)}}catch(t){console.error("Failed to unpack message from websocket",t,{event:e}),alert(`Something went wrong! You might need to refresh the page.\n\nPlease open an issue on https://github.com/fonsp/Pluto.jl with this info:\n\nFailed to unpack message\n${t}\n\n${JSON.stringify(e)}`)}}))},o.onerror=async e=>{console.error(`Socket did an oopsie - ${e.type}`,(new Date).toLocaleTimeString(),"was open:",h,e),await(e=>new Promise((t=>{a(e)?t(!0):setTimeout((()=>{t(a(e))}),1e3)})))(o)?(console.log("The socket somehow recovered from an error?! Onbegrijpelijk"),console.log(o),console.log(o.readyState)):h?(i(),l(o)):s(e)},o.onclose=async e=>{console.error(`Socket did an oopsie - ${e.type}`,(new Date).toLocaleTimeString(),"was open:",h,e),h?(i(),l(o)):s(e)},o.onopen=()=>{console.log("Socket opened",(new Date).toLocaleTimeString()),clearInterval(c),h=!0,r({socket:o,send:u})},console.log("Waiting for socket to open...",(new Date).toLocaleTimeString())}));const c=e=>{let t=null,i=[],n=null;return async(r,O,s,o)=>{if("update_notebook"===r){if(null!=n&&n!=s.notebook_id)throw new Error("Switched notebook inbetween same-tick updates??? WHAT?!?!");return i=[...i,...O.updates],n=s.notebook_id,null==t&&(t=new Promise((e=>setTimeout(e,0))).then((async()=>{let O=i;return t=null,i=[],n=null,await e(r,{updates:O},s,o)}))),await t}return await e(r,O,s,o)}},u=e=>{const t=new URL("./",e);return t.protocol=t.protocol.replace("http","ws"),String(t)},f=()=>u(window.location.href),d=async({on_unrequested_update:e,on_reconnect:t,on_connection_status:i,connect_metadata:r={},ws_address:O=f()})=>{var s=null;const a={send:null,session_options:null,version_info:{julia:"unknown",pluto:"unknown",dismiss_update_notification:!1},notebook_exists:!0,kill:null},l=o(),u=new Map,d=async(t,i={},n={},r=!0)=>{const O=o(),a={type:t,client_id:l,request_id:O,body:i,...n};let h=(()=>{let e=()=>{},t=()=>{};return{current:new Promise(((i,n)=>{e=i,t=n})),resolve:e,reject:t}})();return u.set(O,(t=>{h.resolve(t),!1===r&&e(t,!0)})),s.send(a),await h.current};a.send=c(d);const p=async()=>{(async()=>{try{const e=new URL(window.location.href),t=await fetch("possible_binder_token_please");if(!t.ok)return;const i=await t.text();""!==i&&e.searchParams.get("token")!==i&&(e.searchParams.set("token",i),history.replaceState({},"",e.toString()))}catch(e){console.warn("Error while setting binder url:",e)}})();try{s=await h(String(O),{on_message:t=>{const i=t.initiator_id==l,n=t.request_id;if(i&&n){const e=u.get(n);if(e)return e(t),void u.delete(n)}e(t,i)},on_socket_close:async()=>{i(!1),console.log("Starting new websocket",(new Date).toLocaleTimeString()),await n.Promises.delay(500),await p(),console.log("Starting state sync",(new Date).toLocaleTimeString());const e=t();console.log(`State sync ${e?"":"not "}successful`,(new Date).toLocaleTimeString()),i(e),e||alert("Connection out of sync 😥\n\nRefresh the page to continue")}}),console.log("Hello?");const o=await d("connect",{},r);if(console.log("Hello!"),a.session_options=o.message.options,a.version_info=o.message.version_info,a.notebook_exists=o.message.notebook_exists,console.log("Client object: ",a),null!=r.notebook_id&&!o.message.notebook_exists)return confirm("A new server was started - this notebook session is no longer running.\n\nWould you like to go back to the main menu?")&&(window.location.href="./"),i(!1),{};i(!0);const c=()=>{d("ping",{},{}).then((()=>{setTimeout(c,28e3)})).catch()};return c(),o.message}catch(e){return console.error("connect() failed",e),await n.Promises.delay(5e3),await p()}};return await p(),a}})),r.register("wLwQ2",(function(t,i){e(t.exports,"default",(()=>r)),e(t.exports,"observablehq_for_cells",(()=>O)),e(t.exports,"Promises",(()=>s));let n=()=>{let e=new window.observablehq.Library;return{DOM:e.DOM,Files:e.Files,Generators:e.Generators,Promises:e.Promises,now:e.now,svg:e.svg(),html:e.html(),require:e.require()}};const r=n(),O=n();r.DOM,r.Files,r.Generators;let s=r.Promises;r.now,r.svg,r.html,r.require})),r.register("bmSg5",(function(t,i){e(t.exports,"pack",(()=>o)),e(t.exports,"unpack",(()=>a));var n=r("6nd3I");const O=n.default.createCodec(),s=e=>new Uint8Array(e.buffer);O.addExtPacker(17,Int8Array,s),O.addExtPacker(18,Uint8Array,s),O.addExtPacker(19,Int16Array,s),O.addExtPacker(20,Uint16Array,s),O.addExtPacker(21,Int32Array,s),O.addExtPacker(22,Uint32Array,s),O.addExtPacker(23,Float32Array,s),O.addExtPacker(24,Float64Array,s),O.addExtPacker(18,Uint8ClampedArray,s),O.addExtPacker(18,ArrayBuffer,(e=>new Uint8Array(e))),O.addExtPacker(18,DataView,s),O.addExtPacker(13,Date,(e=>new BigInt64Array([BigInt(+e)]))),O.addExtUnpacker(13,(e=>{if("getBigInt64"in DataView.prototype){let t=new DataView(e.buffer,e.byteOffset,e.byteLength).getBigInt64(0,!0);if(t>Number.MAX_SAFE_INTEGER)throw new Error("Can't read too big number as date (how far in the future is this?!)");return new Date(Number(t))}return new Date(NaN)})),O.addExtUnpacker(17,(e=>new Int8Array(e.buffer))),O.addExtUnpacker(18,(e=>new Uint8Array(e.buffer))),O.addExtUnpacker(19,(e=>new Int16Array(e.buffer))),O.addExtUnpacker(20,(e=>new Uint16Array(e.buffer))),O.addExtUnpacker(21,(e=>new Int32Array(e.buffer))),O.addExtUnpacker(22,(e=>new Uint32Array(e.buffer))),O.addExtUnpacker(23,(e=>new Float32Array(e.buffer))),O.addExtUnpacker(24,(e=>new Float64Array(e.buffer)));const o=e=>n.default.encode(e,{codec:O}),a=e=>n.default.decode(e,{codec:O})})),r.register("6nd3I",(function(t,i){e(t.exports,"default",(()=>n));var n=r("lJisg").default})),r.register("lJisg",(function(i,n){e(i.exports,"default",(()=>O));const r=function e(t,i,n){function r(s,o){if(!i[s]){if(!t[s]){var a=void 0;if(!o&&a)return a(s,!0);if(O)return O(s,!0);var l=new Error("Cannot find module '"+s+"'");throw l.code="MODULE_NOT_FOUND",l}var h=i[s]={exports:{}};t[s][0].call(h.exports,(function(e){var i=t[s][1][e];return r(i||e)}),h,h.exports,e,t,i,n)}return i[s].exports}for(var O=void 0,s=0;s>>6,i[n++]=128|63&O):O<55296||O>57343?(i[n++]=224|O>>>12,i[n++]=128|O>>>6&63,i[n++]=128|63&O):(O=65536+(O-55296<<10|e.charCodeAt(s++)-56320),i[n++]=240|O>>>18,i[n++]=128|O>>>12&63,i[n++]=128|O>>>6&63,i[n++]=128|63&O);return n-t}function r(e,t,i){var n=this,r=0|t;i||(i=n.length);for(var O="",s=0;r=65536?(s-=65536,O+=String.fromCharCode(55296+(s>>>10),56320+(1023&s))):O+=String.fromCharCode(s));return O}function O(e,t,i,n){var r;i||(i=0),n||0===n||(n=this.length),t||(t=0);var O=n-i;if(e===this&&i=0;r--)e[r+t]=this[r+i];else for(r=0;rthis.buffer.length)throw new Error($);return this.offset=i,t}return{bufferish:f,write:e,fetch:a,flush:t,push:h,pull:c,read:l,reserve:i,offset:0}}function s(){function e(){var e=this.start;if(e1?this.bufferish.concat(e):e[0];return e.length=0,t}function n(e){var t=0|e;if(this.buffer){var i=this.buffer.length,n=0|this.offset,r=n+t;if(rthis.minBufferSize)this.flush(),this.push(e);else{var i=this.reserve(t);f.prototype.copy.call(e,this.buffer,i)}}return{bufferish:f,write:o,fetch:e,flush:t,push:h,pull:i,read:l,reserve:n,send:r,maxBufferSize:p,minBufferSize:d,offset:0,start:0}}function o(){throw new Error("method not implemented: write()")}function a(){throw new Error("method not implemented: fetch()")}function l(){return this.buffers&&this.buffers.length?(this.flush(),this.pull()):this.fetch()}function h(e){(this.buffers||(this.buffers=[])).push(e)}function c(){return(this.buffers||(this.buffers=[])).shift()}function u(e){function t(t){for(var i in e)t[i]=e[i];return t}return t}i.FlexDecoder=n,i.FlexEncoder=r;var f=e("./bufferish"),d=2048,p=65536,$="BUFFER_SHORTAGE";n.mixin=u(O()),n.mixin(n.prototype),r.mixin=u(s()),r.mixin(r.prototype)},{"./bufferish":8}],22:[function(e,t,i){function n(e){function t(e){var t=l(e),n=i[t];if(!n)throw new Error("Invalid type: "+(t?"0x"+t.toString(16):t));return n(e)}var i=h.getReadToken(e);return t}function r(){var e=this.options;return this.decode=n(e),e&&e.preset&&a.setExtUnpackers(this),this}function O(e,t){(this.extUnpackers||(this.extUnpackers=[]))[e]=c.filter(t)}function s(e){function t(t){return new o(t,e)}return(this.extUnpackers||(this.extUnpackers=[]))[e]||t}var o=e("./ext-buffer").ExtBuffer,a=e("./ext-unpacker"),l=e("./read-format").readUint8,h=e("./read-token"),c=e("./codec-base");c.install({addExtUnpacker:O,getExtUnpacker:s,init:r}),i.preset=r.call(c.preset)},{"./codec-base":9,"./ext-buffer":17,"./ext-unpacker":19,"./read-format":23,"./read-token":24}],23:[function(e,t,i){function n(e){var t=v.hasArrayBuffer&&e&&e.binarraybuffer,i=e&&e.int64;return{map:W&&e&&e.usemap?O:r,array:s,str:o,bin:t?l:a,ext:h,uint8:c,uint16:f,uint32:p,uint64:Q(8,i?P:m),int8:u,int16:d,int32:$,int64:Q(8,i?X:g),float32:Q(4,y),float64:Q(8,w)}}function r(e,t){var i,n={},r=new Array(t),O=new Array(t),s=e.codec.decode;for(i=0;i>>8,r[n]=i}}function l(e){return function(t,i){var n=t.reserve(5),r=t.buffer;r[n++]=e,r[n++]=i>>>24,r[n++]=i>>>16,r[n++]=i>>>8,r[n]=i}}function h(e,t,i,n){return function(r,O){var s=r.reserve(t+1);r.buffer[s++]=e,i.call(r.buffer,O,s,n)}}function c(e,t){new Q(this,t,e)}function u(e,t){new m(this,t,e)}function f(e,t){p.write(this,e,t,!1,23,4)}function d(e,t){p.write(this,e,t,!1,52,8)}var p=e("ieee754"),$=e("int64-buffer"),Q=$.Uint64BE,m=$.Int64BE,g=e("./write-uint8").uint8,P=e("./bufferish"),X=P.global,y=P.hasBuffer&&"TYPED_ARRAY_SUPPORT"in X&&!X.TYPED_ARRAY_SUPPORT,w=P.hasBuffer&&X.prototype||{};i.getWriteToken=n},{"./bufferish":8,"./write-uint8":28,ieee754:32,"int64-buffer":33}],27:[function(e,t,i){function n(e){function t(e,t){R[t?195:194](e,t)}function i(e,t){var i=0|t;return t!==i?void R[203](e,t):void R[-32<=i&&i<=127?255&i:0<=i?i<=255?204:i<=65535?205:206:-128<=i?208:-32768<=i?209:210](e,i)}function n(e,t){R[207](e,t.toArray())}function O(e,t){R[211](e,t.toArray())}function $(e){return e<32?1:e<=255?2:e<=65535?3:5}function Q(e){return e<32?1:e<=65535?3:5}function m(e){function t(t,i){var n=i.length,r=5+3*n;t.offset=t.reserve(r);var O=t.buffer,s=e(n),o=t.offset+s;n=l.write.call(O,i,o);var a=e(n);if(s!==a){var h=o+a-s,c=o+n;l.copy.call(O,O,h,o,c)}R[1===a?160+n:a<=3?215+a:219](t,n),t.offset+=n}return t}function g(e,t){if(null===t)return X(e,t);if(_(t))return V(e,t);if(r(t))return y(e,t);if(s.isUint64BE(t))return n(e,t);if(o.isInt64BE(t))return O(e,t);var i=e.codec.getExtPacker(t);return i&&(t=i(t)),t instanceof u?x(e,t):void q(e,t)}function P(e,t){return _(t)?v(e,t):void g(e,t)}function X(e,t){R[192](e,t)}function y(e,t){var i=t.length;R[i<16?144+i:i<=65535?220:221](e,i);for(var n=e.codec.encode,r=0;r=r())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+r().toString(16)+" bytes");return 0|e}function $(e){return+e!=e&&(e=0),s.alloc(+e)}function Q(e,t){if(s.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var i=e.length;if(0===i)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return i;case"utf8":case"utf-8":case void 0:return E(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*i;case"hex":return i>>>1;case"base64":return L(e).length;default:if(n)return E(e).length;t=(""+t).toLowerCase(),n=!0}}function m(e,t,i){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===i||i>this.length)&&(i=this.length),i<=0)return"";if((i>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return V(this,t,i);case"utf8":case"utf-8":return R(this,t,i);case"ascii":return T(this,t,i);case"latin1":case"binary":return _(this,t,i);case"base64":return v(this,t,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return q(this,t,i);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function g(e,t,i){var n=e[t];e[t]=e[i],e[i]=n}function P(e,t,i,n,r){if(0===e.length)return-1;if("string"==typeof i?(n=i,i=0):i>2147483647?i=2147483647:i<-2147483648&&(i=-2147483648),i=+i,isNaN(i)&&(i=r?0:e.length-1),i<0&&(i=e.length+i),i>=e.length){if(r)return-1;i=e.length-1}else if(i<0){if(!r)return-1;i=0}if("string"==typeof t&&(t=s.from(t,n)),s.isBuffer(t))return 0===t.length?-1:X(e,t,i,n,r);if("number"==typeof t)return t&=255,s.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?r?Uint8Array.prototype.indexOf.call(e,t,i):Uint8Array.prototype.lastIndexOf.call(e,t,i):X(e,[t],i,n,r);throw new TypeError("val must be string, number or Buffer")}function X(e,t,i,n,r){function O(e,t){return 1===o?e[t]:e.readUInt16BE(t*o)}var s,o=1,a=e.length,l=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;o=2,a/=2,l/=2,i/=2}if(r){var h=-1;for(s=i;sa&&(i=a-l),s=i;s>=0;s--){for(var c=!0,u=0;ur&&(n=r):n=r;var O=t.length;if(O%2!=0)throw new TypeError("Invalid hex string");n>O/2&&(n=O/2);for(var s=0;s239?4:l>223?3:l>191?2:1;if(r+c<=i)switch(c){case 1:l<128&&(h=l);break;case 2:128==(192&(O=e[r+1]))&&(a=(31&l)<<6|63&O)>127&&(h=a);break;case 3:O=e[r+1],s=e[r+2],128==(192&O)&&128==(192&s)&&(a=(15&l)<<12|(63&O)<<6|63&s)>2047&&(a<55296||a>57343)&&(h=a);break;case 4:O=e[r+1],s=e[r+2],o=e[r+3],128==(192&O)&&128==(192&s)&&128==(192&o)&&(a=(15&l)<<18|(63&O)<<12|(63&s)<<6|63&o)>65535&&a<1114112&&(h=a)}null===h?(h=65533,c=1):h>65535&&(h-=65536,n.push(h>>>10&1023|55296),h=56320|1023&h),n.push(h),r+=c}return W(n)}function W(e){var t=e.length;if(t<=ee)return String.fromCharCode.apply(String,e);for(var i="",n=0;nn)&&(i=n);for(var r="",O=t;Oi)throw new RangeError("Trying to access beyond buffer length")}function Y(e,t,i,n,r,O){if(!s.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>r||te.length)throw new RangeError("Index out of range")}function N(e,t,i,n){t<0&&(t=65535+t+1);for(var r=0,O=Math.min(e.length-i,2);r>>8*(n?r:1-r)}function Z(e,t,i,n){t<0&&(t=4294967295+t+1);for(var r=0,O=Math.min(e.length-i,4);r>>8*(n?r:3-r)&255}function z(e,t,i,n,r,O){if(i+n>e.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("Index out of range")}function C(e,t,i,n,r){return r||z(e,t,i,4,34028234663852886e22,-34028234663852886e22),H.write(e,t,i,n,23,4),i+4}function U(e,t,i,n,r){return r||z(e,t,i,8,17976931348623157e292,-17976931348623157e292),H.write(e,t,i,n,52,8),i+8}function G(e){if((e=I(e).replace(te,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}function I(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}function j(e){return e<16?"0"+e.toString(16):e.toString(16)}function E(e,t){t=t||1/0;for(var i,n=e.length,r=null,O=[],s=0;s55295&&i<57344){if(!r){if(i>56319){(t-=3)>-1&&O.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&O.push(239,191,189);continue}r=i;continue}if(i<56320){(t-=3)>-1&&O.push(239,191,189),r=i;continue}i=65536+(r-55296<<10|i-56320)}else r&&(t-=3)>-1&&O.push(239,191,189);if(r=null,i<128){if((t-=1)<0)break;O.push(i)}else if(i<2048){if((t-=2)<0)break;O.push(i>>6|192,63&i|128)}else if(i<65536){if((t-=3)<0)break;O.push(i>>12|224,i>>6&63|128,63&i|128)}else{if(!(i<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;O.push(i>>18|240,i>>12&63|128,i>>6&63|128,63&i|128)}}return O}function D(e){for(var t=[],i=0;i>8,r=i%256,O.push(r),O.push(n);return O}function L(e){return F.toByteArray(G(e))}function B(e,t,i,n){for(var r=0;r=t.length||r>=e.length);++r)t[r+i]=e[r];return r}function K(e){return e!=e}var F=e("base64-js"),H=e("ieee754"),J=e("isarray");n.Buffer=s,n.SlowBuffer=$,n.INSPECT_MAX_BYTES=50,s.TYPED_ARRAY_SUPPORT=void 0!==t.TYPED_ARRAY_SUPPORT?t.TYPED_ARRAY_SUPPORT:i(),n.kMaxLength=r(),s.poolSize=8192,s._augment=function(e){return e.__proto__=s.prototype,e},s.from=function(e,t,i){return o(null,e,t,i)},s.TYPED_ARRAY_SUPPORT&&(s.prototype.__proto__=Uint8Array.prototype,s.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&s[Symbol.species]===s&&Object.defineProperty(s,Symbol.species,{value:null,configurable:!0})),s.alloc=function(e,t,i){return l(null,e,t,i)},s.allocUnsafe=function(e){return h(null,e)},s.allocUnsafeSlow=function(e){return h(null,e)},s.isBuffer=function(e){return!(null==e||!e._isBuffer)},s.compare=function(e,t){if(!s.isBuffer(e)||!s.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var i=e.length,n=t.length,r=0,O=Math.min(i,n);r0&&(e=this.toString("hex",0,t).match(/.{2}/g).join(" "),this.length>t&&(e+=" ... ")),""},s.prototype.compare=function(e,t,i,n,r){if(!s.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===i&&(i=e?e.length:0),void 0===n&&(n=0),void 0===r&&(r=this.length),t<0||i>e.length||n<0||r>this.length)throw new RangeError("out of range index");if(n>=r&&t>=i)return 0;if(n>=r)return-1;if(t>=i)return 1;if(this===e)return 0;for(var O=(r>>>=0)-(n>>>=0),o=(i>>>=0)-(t>>>=0),a=Math.min(O,o),l=this.slice(n,r),h=e.slice(t,i),c=0;cr)&&(i=r),e.length>0&&(i<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var O=!1;;)switch(n){case"hex":return y(this,e,t,i);case"utf8":case"utf-8":return w(this,e,t,i);case"ascii":return b(this,e,t,i);case"latin1":case"binary":return x(this,e,t,i);case"base64":return S(this,e,t,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,e,t,i);default:if(O)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),O=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var ee=4096;s.prototype.slice=function(e,t){var i,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(r*=256);)n+=this[e+--t]*r;return n},s.prototype.readUInt8=function(e,t){return t||A(e,1,this.length),this[e]},s.prototype.readUInt16LE=function(e,t){return t||A(e,2,this.length),this[e]|this[e+1]<<8},s.prototype.readUInt16BE=function(e,t){return t||A(e,2,this.length),this[e]<<8|this[e+1]},s.prototype.readUInt32LE=function(e,t){return t||A(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},s.prototype.readUInt32BE=function(e,t){return t||A(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},s.prototype.readIntLE=function(e,t,i){e|=0,t|=0,i||A(e,t,this.length);for(var n=this[e],r=1,O=0;++O=(r*=128)&&(n-=Math.pow(2,8*t)),n},s.prototype.readIntBE=function(e,t,i){e|=0,t|=0,i||A(e,t,this.length);for(var n=t,r=1,O=this[e+--n];n>0&&(r*=256);)O+=this[e+--n]*r;return O>=(r*=128)&&(O-=Math.pow(2,8*t)),O},s.prototype.readInt8=function(e,t){return t||A(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},s.prototype.readInt16LE=function(e,t){t||A(e,2,this.length);var i=this[e]|this[e+1]<<8;return 32768&i?4294901760|i:i},s.prototype.readInt16BE=function(e,t){t||A(e,2,this.length);var i=this[e+1]|this[e]<<8;return 32768&i?4294901760|i:i},s.prototype.readInt32LE=function(e,t){return t||A(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},s.prototype.readInt32BE=function(e,t){return t||A(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},s.prototype.readFloatLE=function(e,t){return t||A(e,4,this.length),H.read(this,e,!0,23,4)},s.prototype.readFloatBE=function(e,t){return t||A(e,4,this.length),H.read(this,e,!1,23,4)},s.prototype.readDoubleLE=function(e,t){return t||A(e,8,this.length),H.read(this,e,!0,52,8)},s.prototype.readDoubleBE=function(e,t){return t||A(e,8,this.length),H.read(this,e,!1,52,8)},s.prototype.writeUIntLE=function(e,t,i,n){e=+e,t|=0,i|=0,n||Y(this,e,t,i,Math.pow(2,8*i)-1,0);var r=1,O=0;for(this[t]=255&e;++O=0&&(O*=256);)this[t+r]=e/O&255;return t+i},s.prototype.writeUInt8=function(e,t,i){return e=+e,t|=0,i||Y(this,e,t,1,255,0),s.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},s.prototype.writeUInt16LE=function(e,t,i){return e=+e,t|=0,i||Y(this,e,t,2,65535,0),s.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):N(this,e,t,!0),t+2},s.prototype.writeUInt16BE=function(e,t,i){return e=+e,t|=0,i||Y(this,e,t,2,65535,0),s.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):N(this,e,t,!1),t+2},s.prototype.writeUInt32LE=function(e,t,i){return e=+e,t|=0,i||Y(this,e,t,4,4294967295,0),s.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):Z(this,e,t,!0),t+4},s.prototype.writeUInt32BE=function(e,t,i){return e=+e,t|=0,i||Y(this,e,t,4,4294967295,0),s.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Z(this,e,t,!1),t+4},s.prototype.writeIntLE=function(e,t,i,n){if(e=+e,t|=0,!n){var r=Math.pow(2,8*i-1);Y(this,e,t,i,r-1,-r)}var O=0,s=1,o=0;for(this[t]=255&e;++O>0)-o&255;return t+i},s.prototype.writeIntBE=function(e,t,i,n){if(e=+e,t|=0,!n){var r=Math.pow(2,8*i-1);Y(this,e,t,i,r-1,-r)}var O=i-1,s=1,o=0;for(this[t+O]=255&e;--O>=0&&(s*=256);)e<0&&0===o&&0!==this[t+O+1]&&(o=1),this[t+O]=(e/s>>0)-o&255;return t+i},s.prototype.writeInt8=function(e,t,i){return e=+e,t|=0,i||Y(this,e,t,1,127,-128),s.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},s.prototype.writeInt16LE=function(e,t,i){return e=+e,t|=0,i||Y(this,e,t,2,32767,-32768),s.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):N(this,e,t,!0),t+2},s.prototype.writeInt16BE=function(e,t,i){return e=+e,t|=0,i||Y(this,e,t,2,32767,-32768),s.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):N(this,e,t,!1),t+2},s.prototype.writeInt32LE=function(e,t,i){return e=+e,t|=0,i||Y(this,e,t,4,2147483647,-2147483648),s.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):Z(this,e,t,!0),t+4},s.prototype.writeInt32BE=function(e,t,i){return e=+e,t|=0,i||Y(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),s.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Z(this,e,t,!1),t+4},s.prototype.writeFloatLE=function(e,t,i){return C(this,e,t,!0,i)},s.prototype.writeFloatBE=function(e,t,i){return C(this,e,t,!1,i)},s.prototype.writeDoubleLE=function(e,t,i){return U(this,e,t,!0,i)},s.prototype.writeDoubleBE=function(e,t,i){return U(this,e,t,!1,i)},s.prototype.copy=function(e,t,i,n){if(i||(i=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--r)e[r+t]=this[r+i];else if(O<1e3||!s.TYPED_ARRAY_SUPPORT)for(r=0;r>>=0,i=void 0===i?this.length:i>>>0,e||(e=0),"number"==typeof e)for(O=t;O0)throw new Error("Invalid string. Length must be a multiple of 4");return"="===e[t-2]?2:"="===e[t-1]?1:0}function r(e){return 3*e.length/4-n(e)}function O(e){var t,i,r,O,s,o,a=e.length;s=n(e),o=new c(3*a/4-s),r=s>0?a-4:a;var l=0;for(t=0,i=0;t>16&255,o[l++]=O>>8&255,o[l++]=255&O;return 2===s?(O=h[e.charCodeAt(t)]<<2|h[e.charCodeAt(t+1)]>>4,o[l++]=255&O):1===s&&(O=h[e.charCodeAt(t)]<<10|h[e.charCodeAt(t+1)]<<4|h[e.charCodeAt(t+2)]>>2,o[l++]=O>>8&255,o[l++]=255&O),o}function s(e){return l[e>>18&63]+l[e>>12&63]+l[e>>6&63]+l[63&e]}function o(e,t,i){for(var n,r=[],O=t;Oh?h:a+s));return 1===n?(t=e[i-1],r+=l[t>>2],r+=l[t<<4&63],r+="=="):2===n&&(t=(e[i-2]<<8)+e[i-1],r+=l[t>>10],r+=l[t>>4&63],r+=l[t<<2&63],r+="="),O.push(r),O.join("")}i.byteLength=r,i.toByteArray=O,i.fromByteArray=a;for(var l=[],h=[],c="undefined"!=typeof Uint8Array?Uint8Array:Array,u="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",f=0,d=u.length;f>1,h=-7,c=i?r-1:0,u=i?-1:1,f=e[t+c];for(c+=u,O=f&(1<<-h)-1,f>>=-h,h+=o;h>0;O=256*O+e[t+c],c+=u,h-=8);for(s=O&(1<<-h)-1,O>>=-h,h+=n;h>0;s=256*s+e[t+c],c+=u,h-=8);if(0===O)O=1-l;else{if(O===a)return s?NaN:1/0*(f?-1:1);s+=Math.pow(2,n),O-=l}return(f?-1:1)*s*Math.pow(2,O-n)},i.write=function(e,t,i,n,r,O){var s,o,a,l=8*O-r-1,h=(1<>1,u=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,f=n?0:O-1,d=n?1:-1,p=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(o=isNaN(t)?1:0,s=h):(s=Math.floor(Math.log(t)/Math.LN2),t*(a=Math.pow(2,-s))<1&&(s--,a*=2),(t+=s+c>=1?u/a:u*Math.pow(2,1-c))*a>=2&&(s++,a/=2),s+c>=h?(o=0,s=h):s+c>=1?(o=(t*a-1)*Math.pow(2,r),s+=c):(o=t*Math.pow(2,c-1)*Math.pow(2,r),s=0));r>=8;e[i+f]=255&o,f+=d,o/=256,r-=8);for(s=s<0;e[i+f]=255&s,f+=d,s/=256,l-=8);e[i+f-d]|=128*p}},{}],33:[function(e,t,i){(function(e){!function(t){function i(e,i,f){function P(e,t,i,n){return this instanceof P?b(this,e,t,i,n):new P(e,t,i,n)}function w(e){return!(!e||!e[C])}function b(e,t,i,n,r){Q&&m&&(t instanceof m&&(t=new Q(t)),n instanceof m&&(n=new Q(n))),t||i||n||d?(s(t,i)||(r=i,n=t,i=0,t=new(d||Array)(8)),e.buffer=t,e.offset=i|=0,p!==typeof n&&("string"==typeof n?x(t,i,n,r||10):s(n,r)?o(t,i,n,r):"number"==typeof r?(v(t,i+W,n),v(t,i+T,r)):n>0?Y(t,i,n):n<0?N(t,i,n):o(t,i,g,0))):e.buffer=a(g,0)}function x(e,t,i,n){var r=0,O=i.length,s=0,o=0;"-"===i[0]&&r++;for(var a=r;r=0))break;o=o*n+l,s=s*n+Math.floor(o/X),o%=X}a&&(s=~s,o?o=X-o:s++),v(e,t+W,s),v(e,t+T,o)}function S(){var e=this.buffer,t=this.offset,i=R(e,t+W),n=R(e,t+T);return f||(i|=0),i?i*X+n:n}function k(e){var t=this.buffer,i=this.offset,n=R(t,i+W),r=R(t,i+T),O="",s=!f&&2147483648&n;for(s&&(n=~n,r=X-r),e=e||10;;){var o=n%e*X+r;if(n=Math.floor(n/e),r=Math.floor(o/e),O=(o%e).toString(e)+O,!n&&!r)break}return s&&(O="-"+O),O}function v(e,t,i){e[t+A]=255&i,i>>=8,e[t+q]=255&i,i>>=8,e[t+V]=255&i,i>>=8,e[t+_]=255&i}function R(e,t){return e[t+_]*y+(e[t+V]<<16)+(e[t+q]<<8)+e[t+A]}var W=i?0:4,T=i?4:0,_=i?0:3,V=i?1:2,q=i?2:1,A=i?3:0,Y=i?l:c,N=i?h:u,Z=P.prototype,z="is"+e,C="_"+z;return Z.buffer=void 0,Z.offset=0,Z[C]=!0,Z.toNumber=S,Z.toString=k,Z.toJSON=S,Z.toArray=n,$&&(Z.toBuffer=r),Q&&(Z.toArrayBuffer=O),P[z]=w,t[e]=P,P}function n(e){var t=this.buffer,i=this.offset;return d=null,!1!==e&&0===i&&8===t.length&&P(t)?t:a(t,i)}function r(t){var i=this.buffer,n=this.offset;if(d=$,!1!==t&&0===n&&8===i.length&&e.isBuffer(i))return i;var r=new $(8);return o(r,0,i,n),r}function O(e){var t=this.buffer,i=this.offset,n=t.buffer;if(d=Q,!1!==e&&0===i&&n instanceof m&&8===n.byteLength)return n;var r=new Q(8);return o(r,0,t,i),r.buffer}function s(e,t){var i=e&&e.length;return t|=0,i&&t+8<=i&&"string"!=typeof e[t]}function o(e,t,i,n){t|=0,n|=0;for(var r=0;r<8;r++)e[t++]=255&i[n++]}function a(e,t){return Array.prototype.slice.call(e,t,t+8)}function l(e,t,i){for(var n=t+8;n>t;)e[--n]=255&i,i/=256}function h(e,t,i){var n=t+8;for(i++;n>t;)e[--n]=255&-i^255,i/=256}function c(e,t,i){for(var n=t+8;t{e.onload=()=>{t(e.result)},e.onerror=t=>{e.abort(),i(t)}}));return e.readAsText(this),t}),null==Blob.prototype.arrayBuffer&&(Blob.prototype.arrayBuffer=function(){return new Response(this).arrayBuffer()}),i.polyfill()})),r.register("dM7tv",(function(t,i){e(t.exports,"polyfill",(()=>r("duQYe").polyfill)),r("duQYe")})),r.register("duQYe",(function(t,i){e(t.exports,"polyfill",(()=>j));var n=e=>void 0===e||"auto"===e||"instant"===e||"smooth"===e;function r(e,t){this.scrollLeft=e,this.scrollTop=t}var O=(e,t,i="cannot convert to dictionary.")=>`Failed to execute '${e}' on '${t}': ${i}`,s=(e,t,i)=>O(e,t,`The provided value '${i}' is not a valid enum value of type ScrollBehavior.`),o=(e,t,i)=>{var n;let r=`__SEAMLESS.BACKUP$${t}`;return!e[r]&&e[t]&&!(null!==(n=e[t])&&void 0!==n&&n.__isPolyfill)&&(e[r]=e[t]),e[r]||i},a=e=>{let t=typeof e;return null!==e&&("object"===t||"function"===t)},l=()=>"scrollBehavior"in window.document.documentElement.style,h=e=>{Object.defineProperty(e,"__isPolyfill",{value:!0})},c=(e,t)=>{h(t),[HTMLElement.prototype,SVGElement.prototype,Element.prototype].forEach((i=>{o(i,e),i[e]=t}))},u=e=>e.ownerDocument.scrollingElement||e.ownerDocument.documentElement,f=e=>.5*(1-Math.cos(Math.PI*e));function d(){var e;let t;return t=null!==(e=window.performance)&&void 0!==e&&e.now?()=>window.performance.now():()=>window.Date.now(),d=t,t()}var p=e=>{let t=(d()-e.timeStamp)/(e.duration||500);if(t>1)return e.method(e.targetX,e.targetY),void e.callback();let i=(e.timingFunc||f)(t),n=e.startX+(e.targetX-e.startX)*i,r=e.startY+(e.targetY-e.startY)*i;e.method(n,r),e.rafId=window.requestAnimationFrame((()=>{p(e)}))},$=e=>isFinite(e)?Number(e):0,Q=e=>(t,i,l)=>{let[h,c]=(e=>e.window===e)(t)?[u(t.document.documentElement),"Window"]:[t,"Element"],f=null!=i?i:{};if(!a(f))throw new TypeError(O(e,c));if(!n(f.behavior))throw new TypeError(s(e,c,f.behavior));"scrollBy"===e&&(f.left=$(f.left)+h.scrollLeft,f.top=$(f.top)+h.scrollTop),((e,t,i)=>{var n,O;if(!(e=>{var t;return null!==(t=e.isConnected)&&void 0!==t?t:!(e.ownerDocument&&1&e.ownerDocument.compareDocumentPosition(e))})(e))return;let s=e.scrollLeft,a=e.scrollTop,l=$(null!==(n=t.left)&&void 0!==n?n:s),h=$(null!==(O=t.top)&&void 0!==O?O:a);if(l===s&&h===a)return;let c=o(HTMLElement.prototype,"scroll",r),u=o(Object.getPrototypeOf(e),"scroll",c).bind(e);if("smooth"!==t.behavior)return void u(l,h);let f=()=>{window.removeEventListener("wheel",m),window.removeEventListener("touchmove",m)},Q=Object.assign(Object.assign({},i),{timeStamp:d(),startX:s,startY:a,targetX:l,targetY:h,rafId:0,method:u,callback:f}),m=()=>{window.cancelAnimationFrame(Q.rafId),f()};window.addEventListener("wheel",m,{passive:!0,once:!0}),window.addEventListener("touchmove",m,{passive:!0,once:!0}),p(Q)})(h,f,l)},m=Q("scroll"),g=Q("scrollTo"),P=Q("scrollBy"),X=m,y=(e,t)=>i=>{if(l())return;let n={scroll:m,scrollTo:g,scrollBy:P}[e];t(e,(function(){let e=arguments;if(1===arguments.length)return void n(this,e[0],i);let t=e[0],r=e[1];n(this,{left:t,top:r})}))},w=y("scroll",c),b=y("scrollTo",c),x=y("scrollBy",c),S=(e,t)=>{h(t),o(window,e),window[e]=t},k=y("scroll",S),v=y("scrollTo",S),R=y("scrollBy",S),W=e=>{switch(e){case"horizontal-tb":case"lr":case"lr-tb":case"rl":case"rl-tb":return 0;case"vertical-rl":case"tb":case"tb-rl":return 1;case"vertical-lr":case"tb-lr":return 2;case"sideways-rl":return 3;case"sideways-lr":return 4}return 0},T=(e,t,i,n)=>{let r=0;switch(t||(r^=2),e){case 0:r=r>>1|(1&r)<<1,[i,n]=[n,i];break;case 1:case 3:r^=1;break;case 4:r^=2}return[r,i,n]},_=e=>1==(1&T(W(e.writingMode),"rtl"!==e.direction,void 0,void 0)[0]),V=(e,t,i,n,r,O,s)=>0!==e?e:ri||r>t&&O=i&&s>=n?2:O>i&&sn?3:null,q=e=>"visible"!==e&&"clip"!==e,A=(e,t)=>(e.clientHeight{let t=e.parentNode,i=e.parentElement;if(null===i&&null!==t){if(11===t.nodeType)return t.host;if(9===t.nodeType)return(e=>{var t;try{return(null===(t=e.ownerDocument.defaultView)||void 0===t?void 0:t.frameElement)||null}catch(e){return null}})(e)}return i},N=(e,t,i)=>ei?i:e,Z=(e,t,i)=>{switch(e){case 1:return(t+i)/2;case 3:return i;case 2:case 0:return t}},z=(e,t)=>{var i,n,r;let O=null===(i=e.ownerDocument.defaultView)||void 0===i?void 0:i.visualViewport,[s,o,a,l]=e===u(e)?[0,0,null!==(n=null==O?void 0:O.width)&&void 0!==n?n:e.clientWidth,null!==(r=null==O?void 0:O.height)&&void 0!==r?r:e.clientHeight]:[t.left,t.top,e.clientWidth,e.clientHeight],h=s+e.clientLeft,c=o+e.clientTop;return[c,h+a,c+l,h]},C=(e,t)=>{let i=[],n=e.ownerDocument,r=n.defaultView;if(!r)return i;let O=window.getComputedStyle(e),s="rtl"!==O.direction,o=W(O.writingMode||O.getPropertyValue("-webkit-writing-mode")||O.getPropertyValue("-ms-writing-mode")),[a,l]=((e,t,i)=>{let[n,r,O]=T(t,i,e.block||"start",e.inline||"nearest");return[r,O].map(((e,t)=>{switch(e){case"center":return 1;case"nearest":return 0;default:return"start"===e==!(n>>t&1)?2:3}}))})(t,o,s),[h,c,u,f]=((e,t,i)=>{let{top:n,right:r,bottom:O,left:s}=t,o=(e=>["scroll-margin","scroll-snap-margin"].filter((t=>t in e.documentElement.style))[0])(e.ownerDocument);if(!o)return[n,r,O,s];let a=e=>{let t=i.getPropertyValue(`${o}-${e}`);return parseInt(t,10)||0};return[n-a("top"),r+a("right"),O+a("bottom"),s-a("left")]})(e,e.getBoundingClientRect(),O);for(let O=Y(e);null!==O;O=Y(O)){if(n!==O.ownerDocument){if(n=O.ownerDocument,r=n.defaultView,!r)break;let{left:e,top:t}=O.getBoundingClientRect();h+=t,c+=e,u+=t,f+=e}let e=r.getComputedStyle(O);if("fixed"===e.position)break;if(!A(O,e))continue;let s=O.getBoundingClientRect(),[o,d,p,$]=z(O,s),Q=V(a,$,d,O.clientWidth,f,c,c-f),m=V(l,o,p,O.clientHeight,h,u,u-h),g=null===Q?0:Z(Q,f,c)-Z(Q,$,d),P=null===m?0:Z(m,h,u)-Z(m,o,p),X=_(e)?N(g,-O.scrollWidth+O.clientWidth-O.scrollLeft,-O.scrollLeft):N(g,-O.scrollLeft,O.scrollWidth-O.clientWidth-O.scrollLeft),y=N(P,-O.scrollTop,O.scrollHeight-O.clientHeight-O.scrollTop);i.push([O,{left:O.scrollLeft+X,top:O.scrollTop+y,behavior:t.behavior}]),h=Math.max(h-y,o),c=Math.min(c-X,d),u=Math.min(u-y,p),f=Math.max(f-X,$)}return i},U=(e,t,i)=>{let r=t||{};if(!n(r.behavior))throw new TypeError(s("scrollIntoView","Element",r.behavior));C(e,r).forEach((([e,t])=>{X(e,t,i)}))};function G(e){U(this,{block:null==e||e?"start":"end",inline:"nearest"})}var I=e=>{if(l())return;let t=o(window.HTMLElement.prototype,"scrollIntoView",G);c("scrollIntoView",(function(){let i=arguments,n=i[0];1===i.length&&a(n)?U(this,n,e):t.apply(this,i)}))},j=e=>{l()||(w(e),b(e),x(e),I(e),k(e),v(e),R(e))}})),r.register("cu5N4",(function(e,t){})),r.register("gZ62d",(function(t,i){e(t.exports,"is_mac_keyboard",(()=>n)),e(t.exports,"ctrl_or_cmd_name",(()=>r)),e(t.exports,"has_ctrl_or_cmd_pressed",(()=>O)),e(t.exports,"in_textarea_or_input",(()=>s));let n=/Mac/.test(navigator.platform),r=n?"Cmd":"Ctrl",O=e=>e.ctrlKey||n&&e.metaKey,s=()=>{const e=null!=document.activeElement.closest("footer"),t=null!=document.activeElement.closest("header"),i=null!=document.activeElement.closest(".cm-editor"),{tagName:n}=document.activeElement;return"INPUT"===n||"TEXTAREA"===n||e||t||i}})),r.register("85ulz",(function(t,i){e(t.exports,"FilePicker",(()=>f));var n=r("fBBKY"),O=r("29nid"),s=r("8qR4G");r("gZ62d"),r("61LLQ");var o=r("9i4md");let{autocompletion:a,completionKeymap:l}=o.autocomplete,h=l.find((e=>"Ctrl-Space"===e.key)),c=l.find((e=>"Enter"===e.key)),u=l.find((e=>"Escape"===e.key));class f extends O.Component{constructor(e){super(e),this.state={is_button_disabled:!0},this.forced_value="",this.cm=null,this.suggest_not_tmp=()=>{const e=this.props.suggest_new_file;null!=e&&0===this.cm.state.doc.length&&(this.cm.dispatch({changes:{from:0,to:this.cm.state.doc.length,insert:e.base},selection:o.EditorSelection.cursor(e.base.length)}),this.request_path_completions()),window.dispatchEvent(new CustomEvent("collapse_cell_selection",{}))};this.on_submit=()=>this.cm.state.doc.toString()===this.forced_value?(this.suggest_not_tmp(),!0):((async e=>{await e()})((async()=>{try{await this.props.on_submit(this.cm.state.doc.toString()),this.cm.dom.blur()}catch(e){this.cm.dispatch({changes:{from:0,to:this.cm.state.doc.length,insert:this.props.value},selection:o.EditorSelection.cursor(this.props.value.length)})}})),!0)}componentDidUpdate(){this.forced_value!=this.props.value&&(this.cm.dispatch({changes:{from:0,to:this.cm.state.doc.length,insert:this.props.value},selection:o.EditorSelection.cursor(this.props.value.length)}),this.forced_value=this.props.value,this.cm.scrollDOM.scrollLeft=1e5,setTimeout((()=>{this.cm.scrollDOM.scrollLeft=1e5}),100))}componentDidMount(){const e=window.matchMedia("(prefers-color-scheme: dark)").matches;this.cm=new o.EditorView({state:o.EditorState.create({doc:"",extensions:[o.drawSelection(),o.EditorView.domEventHandlers({focus:(e,t)=>(setTimeout((()=>{this.props.suggest_new_file?this.suggest_not_tmp():0===t.state.doc.length&&this.request_path_completions()}),0),!0),blur:(e,t)=>{setTimeout((()=>{t.hasFocus||(t.dispatch({changes:{from:0,to:t.state.doc.length,insert:this.props.value},selection:o.EditorSelection.cursor(this.props.value.length)}),t.scrollPosIntoView(this.props.value.length),setTimeout((()=>{this.cm.scrollPosIntoView(this.props.value.length)}),100))}),200)}}),o.EditorView.updateListener.of((e=>{e.docChanged&&this.setState({is_button_disabled:0===e.state.doc.length})})),o.EditorView.theme({"&":{fontSize:"inherit"},".cm-scroller":{fontFamily:"inherit",overflowY:"hidden",overflowX:"auto"}},{dark:e}),o.history(),a({activateOnTyping:!0,override:[d({suggest_new_file:this.props.suggest_new_file,client:this.props.client})],defaultKeymap:!1,maxRenderedOptions:512,optionClass:e=>e.type}),o.EditorView.updateListener.of((e=>{e.transactions.forEach((t=>{null!=t.annotation(o.autocomplete.pickedCompletion)&&(e.view.scrollPosIntoView(e.state.doc.length),this.request_path_completions())}))})),o.keymap.of([{key:"Enter",run:e=>c.run(e)},{key:"Enter",run:this.on_submit},{key:"Ctrl-Enter",mac:"Cmd-Enter",run:this.on_submit},{key:"Ctrl-Shift-Enter",mac:"Cmd-Shift-Enter",run:this.on_submit},{key:"Escape",run:e=>(u.run(e),e.dispatch({changes:{from:0,to:e.state.doc.length,insert:this.props.value},selection:o.EditorSelection.cursor(this.props.value.length)}),document.activeElement.blur(),!0),preventDefault:!0},{key:"Tab",run:e=>c.run(e)?(this.request_path_completions(),!0):this.request_path_completions()}]),o.keymap.of(l),o.placeholder(this.props.placeholder)]})}),this.base.insertBefore(this.cm.dom,this.base.firstElementChild)}render(){return n.html`
+
+
+
+ `}request_path_completions(){let e=this.cm.state.selection.main;if(e.from===e.to&&this.cm.state.doc.length===e.to)return h.run(this.cm)}}const d=({client:e,suggest_new_file:t})=>i=>{i.state.selection.main.to;const n=i.state.doc.toString();return e.send("completepath",{query:n}).then((e=>{const i=n.split("/").pop().split("\\").pop(),r=e.message.results,O=s.utf8index_to_ut16index(n,e.message.start),o=s.utf8index_to_ut16index(n,e.message.stop);if(r.length>=1&&r[0]==i)return null;let a=r.map((e=>{let t=e.endsWith("/")||e.endsWith("\\");return{label:e,type:t?"dir":"file",boost:t?1:0}}));if(null!=t)for(let e=3;e>=0;e--){const t=".jl".substring(0,e);if(i.endsWith(t)){let t=i+".jl".substring(e);if(".jl"==t&&(t="notebook.jl"),3==e)return null;r.includes(t)||a.push({label:t+" (new)",apply:t,type:"file new",boost:-99});break}}return{options:a,from:O,to:o}}))}})),r.register("8qR4G",(function(t,i){e(t.exports,"utf8index_to_ut16index",(()=>O)),e(t.exports,"slice_utf8",(()=>s));const n=new TextEncoder,r=new TextDecoder,O=(e,t)=>r.decode(n.encode(e).slice(0,t)).length,s=(e,t,i)=>{const O=n.encode(e);return r.decode(O.slice(t,i))};console.assert("e é hannes ❤ is a dog"===((e,t,i,O)=>{const s=n.encode(e),o=n.encode(O),a=new Uint8Array(s.length+o.length-(i-t));return a.set(s.slice(0,t),0),a.set(o,t),a.set(s.slice(i),t+o.length),r.decode(a)})("e é 🐶 is a dog",5,9,"hannes ❤")),console.assert("🐶"===s("e é 🐶 is a dog",5,9))})),r.register("61LLQ",(function(t,i){e(t.exports,"EditorState",(()=>r("9i4md").EditorState)),e(t.exports,"EditorSelection",(()=>r("9i4md").EditorSelection)),e(t.exports,"Compartment",(()=>r("9i4md").Compartment)),e(t.exports,"EditorView",(()=>r("9i4md").EditorView)),e(t.exports,"placeholder",(()=>r("9i4md").placeholder)),e(t.exports,"julia_andrey",(()=>r("9i4md").julia_andrey)),e(t.exports,"keymap",(()=>r("9i4md").keymap)),e(t.exports,"history",(()=>r("9i4md").history)),e(t.exports,"historyKeymap",(()=>r("9i4md").historyKeymap)),e(t.exports,"defaultKeymap",(()=>r("9i4md").defaultKeymap)),e(t.exports,"indentMore",(()=>r("9i4md").indentMore)),e(t.exports,"indentLess",(()=>r("9i4md").indentLess)),e(t.exports,"tags",(()=>r("9i4md").tags)),e(t.exports,"HighlightStyle",(()=>r("9i4md").HighlightStyle)),e(t.exports,"lineNumbers",(()=>r("9i4md").lineNumbers)),e(t.exports,"highlightSpecialChars",(()=>r("9i4md").highlightSpecialChars)),e(t.exports,"drawSelection",(()=>r("9i4md").drawSelection)),e(t.exports,"indentOnInput",(()=>r("9i4md").indentOnInput)),e(t.exports,"defaultHighlightStyle",(()=>r("9i4md").defaultHighlightStyle)),e(t.exports,"closeBrackets",(()=>r("9i4md").closeBrackets)),e(t.exports,"rectangularSelection",(()=>r("9i4md").rectangularSelection)),e(t.exports,"highlightSelectionMatches",(()=>r("9i4md").highlightSelectionMatches)),e(t.exports,"closeBracketsKeymap",(()=>r("9i4md").closeBracketsKeymap)),e(t.exports,"foldKeymap",(()=>r("9i4md").foldKeymap)),e(t.exports,"syntaxTree",(()=>r("9i4md").syntaxTree)),e(t.exports,"syntaxTreeAvailable",(()=>r("9i4md").syntaxTreeAvailable)),e(t.exports,"Decoration",(()=>r("9i4md").Decoration)),e(t.exports,"ViewPlugin",(()=>r("9i4md").ViewPlugin)),e(t.exports,"WidgetType",(()=>r("9i4md").WidgetType)),e(t.exports,"Facet",(()=>r("9i4md").Facet)),e(t.exports,"StateField",(()=>r("9i4md").StateField)),e(t.exports,"StateEffect",(()=>r("9i4md").StateEffect)),e(t.exports,"indentUnit",(()=>r("9i4md").indentUnit)),e(t.exports,"combineConfig",(()=>r("9i4md").combineConfig)),e(t.exports,"autocomplete",(()=>r("9i4md").autocomplete)),e(t.exports,"html",(()=>r("9i4md").html)),e(t.exports,"htmlLanguage",(()=>r("9i4md").htmlLanguage)),e(t.exports,"javascriptLanguage",(()=>r("9i4md").javascriptLanguage)),e(t.exports,"markdown",(()=>r("9i4md").markdown)),e(t.exports,"markdownLanguage",(()=>r("9i4md").markdownLanguage)),e(t.exports,"parseCode",(()=>r("9i4md").parseCode)),e(t.exports,"parseMixed",(()=>r("9i4md").parseMixed)),e(t.exports,"PostgreSQL",(()=>r("9i4md").PostgreSQL)),e(t.exports,"pythonLanguage",(()=>r("9i4md").pythonLanguage)),e(t.exports,"sql",(()=>r("9i4md").sql)),e(t.exports,"javascript",(()=>r("9i4md").javascript)),e(t.exports,"python",(()=>r("9i4md").python)),e(t.exports,"Text",(()=>r("9i4md").Text));r("9i4md")})),r.register("9i4md",(function(t,i){e(t.exports,"Text",(()=>m)),e(t.exports,"EditorSelection",(()=>z)),e(t.exports,"Facet",(()=>I)),e(t.exports,"StateField",(()=>B)),e(t.exports,"Compartment",(()=>re)),e(t.exports,"StateEffect",(()=>ge)),e(t.exports,"EditorState",(()=>Te)),e(t.exports,"combineConfig",(()=>_e)),e(t.exports,"parseMixed",(()=>ot)),e(t.exports,"WidgetType",(()=>Bi)),e(t.exports,"Decoration",(()=>Fi)),e(t.exports,"ViewPlugin",(()=>Sn)),e(t.exports,"EditorView",(()=>bO)),e(t.exports,"keymap",(()=>VO)),e(t.exports,"drawSelection",(()=>CO)),e(t.exports,"highlightSpecialChars",(()=>is)),e(t.exports,"placeholder",(()=>os)),e(t.exports,"syntaxTree",(()=>ds)),e(t.exports,"syntaxTreeAvailable",(()=>ps)),e(t.exports,"indentUnit",(()=>vs)),e(t.exports,"indentOnInput",(()=>Gs)),e(t.exports,"HighlightStyle",(()=>Oo)),e(t.exports,"tags",(()=>ko)),e(t.exports,"defaultHighlightStyle",(()=>vo)),e(t.exports,"autocomplete",(()=>Gh)),e(t.exports,"julia_andrey",(()=>Kh)),e(t.exports,"lineNumbers",(()=>dc)),e(t.exports,"history",(()=>Xc)),e(t.exports,"historyKeymap",(()=>Nc)),e(t.exports,"indentMore",(()=>Uu)),e(t.exports,"indentLess",(()=>Gu)),e(t.exports,"defaultKeymap",(()=>Eu)),e(t.exports,"rectangularSelection",(()=>Lu)),e(t.exports,"foldKeymap",(()=>Of)),e(t.exports,"closeBrackets",(()=>$f)),e(t.exports,"closeBracketsKeymap",(()=>Xf)),e(t.exports,"highlightSelectionMatches",(()=>Bf)),e(t.exports,"parseCode",(()=>Up)),e(t.exports,"javascriptLanguage",(()=>eQ)),e(t.exports,"javascript",(()=>rQ)),e(t.exports,"htmlLanguage",(()=>yQ)),e(t.exports,"html",(()=>bQ)),e(t.exports,"markdownLanguage",(()=>WQ)),e(t.exports,"markdown",(()=>zQ)),e(t.exports,"sql",(()=>um)),e(t.exports,"PostgreSQL",(()=>dm)),e(t.exports,"pythonLanguage",(()=>bm)),e(t.exports,"python",(()=>xm));var n=r("cu5N4");let O="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map((e=>e?parseInt(e,36):1));for(let e=1;ee)return O[t-1]<=e;return!1}function o(e){return e>=127462&&e<=127487}function a(e,t,i=!0,n=!0){return(i?l:h)(e,t,n)}function l(e,t,i){if(t==e.length)return t;t&&c(e.charCodeAt(t))&&u(e.charCodeAt(t-1))&&t--;let n=f(e,t);for(t+=p(n);t=0&&o(f(e,n));)i++,n-=2;if(i%2==0)break;t+=2}}}return t}function h(e,t,i){for(;t>0;){let n=l(e,t-2,i);if(n=56320&&e<57344}function u(e){return e>=55296&&e<56320}function f(e,t){let i=e.charCodeAt(t);if(!u(i)||t+1==e.length)return i;let n=e.charCodeAt(t+1);return c(n)?n-56320+(i-55296<<10)+65536:i}function d(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode(55296+(e>>10),56320+(1023&e)))}function p(e){return e<65536?1:2}function $(e,t,i=e.length){let n=0;for(let r=0;r=t)return n;if(n==e.length)break;r+=9==e.charCodeAt(n)?i-r%i:1,n=a(e,n)}return!0===n?-1:e.length}class m{constructor(){}lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,i){let n=[];return this.decompose(0,e,n,2),i.length&&i.decompose(0,i.length,n,3),this.decompose(t,this.length,n,1),P.from(n,this.length-(t-e)+i.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){let i=[];return this.decompose(e,t,i,0),P.from(i,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),i=this.length-this.scanIdentical(e,-1),n=new w(this),r=new w(e);for(let e=t,O=t;;){if(n.next(e),r.next(e),e=0,n.lineBreak!=r.lineBreak||n.done!=r.done||n.value!=r.value)return!1;if(O+=n.value.length,n.done||O>=i)return!0}}iter(e=1){return new w(this,e)}iterRange(e,t=this.length){return new b(this,e,t)}iterLines(e,t){let i;if(null==e)i=this.iter();else{null==t&&(t=this.lines+1);let n=this.line(e).from;i=this.iterRange(n,Math.max(n,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new x(i)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}static of(e){if(0==e.length)throw new RangeError("A document must have at least one line");return 1!=e.length||e[0]?e.length<=32?new g(e):P.from(g.split(e,[])):m.empty}}class g extends m{constructor(e,t=function(e){let t=-1;for(let i of e)t+=i.length+1;return t}(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,i,n){for(let r=0;;r++){let O=this.text[r],s=n+O.length;if((t?i:s)>=e)return new S(n,s,i,O);n=s+1,i++}}decompose(e,t,i,n){let r=e<=0&&t>=this.length?this:new g(y(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(1&n){let e=i.pop(),t=X(r.text,e.text.slice(),0,r.length);if(t.length<=32)i.push(new g(t,e.length+r.length));else{let e=t.length>>1;i.push(new g(t.slice(0,e)),new g(t.slice(e)))}}else i.push(r)}replace(e,t,i){if(!(i instanceof g))return super.replace(e,t,i);let n=X(this.text,X(i.text,y(this.text,0,e)),t),r=this.length+i.length-(t-e);return n.length<=32?new g(n,r):P.from(g.split(n,[]),r)}sliceString(e,t=this.length,i="\n"){let n="";for(let r=0,O=0;r<=t&&Oe&&O&&(n+=i),er&&(n+=s.slice(Math.max(0,e-r),t-r)),r=o+1}return n}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let i=[],n=-1;for(let r of e)i.push(r),n+=r.length+1,32==i.length&&(t.push(new g(i,n)),i=[],n=-1);return n>-1&&t.push(new g(i,n)),t}}class P extends m{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let t of e)this.lines+=t.lines}lineInner(e,t,i,n){for(let r=0;;r++){let O=this.children[r],s=n+O.length,o=i+O.lines-1;if((t?o:s)>=e)return O.lineInner(e,t,i,n);n=s+1,i=o+1}}decompose(e,t,i,n){for(let r=0,O=0;O<=t&&r=O){let r=n&((O<=e?1:0)|(o>=t?2:0));O>=e&&o<=t&&!r?i.push(s):s.decompose(e-O,t-O,i,r)}O=o+1}}replace(e,t,i){if(i.lines=r&&t<=s){let o=O.replace(e-r,t-r,i),a=this.lines-O.lines+o.lines;if(o.lines>4&&o.lines>a>>6){let r=this.children.slice();return r[n]=o,new P(r,this.length-(t-e)+i.length)}return super.replace(r,s,o)}r=s+1}return super.replace(e,t,i)}sliceString(e,t=this.length,i="\n"){let n="";for(let r=0,O=0;re&&r&&(n+=i),eO&&(n+=s.sliceString(e-O,t-O,i)),O=o+1}return n}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof P))return 0;let i=0,[n,r,O,s]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;n+=t,r+=t){if(n==O||r==s)return i;let o=this.children[n],a=e.children[r];if(o!=a)return i+o.scanIdentical(a,t);i+=o.length+1}}static from(e,t=e.reduce(((e,t)=>e+t.length+1),-1)){let i=0;for(let t of e)i+=t.lines;if(i<32){let i=[];for(let t of e)t.flatten(i);return new g(i,t)}let n=Math.max(32,i>>5),r=n<<1,O=n>>1,s=[],o=0,a=-1,l=[];function h(e){let t;if(e.lines>r&&e instanceof P)for(let t of e.children)h(t);else e.lines>O&&(o>O||!o)?(c(),s.push(e)):e instanceof g&&o&&(t=l[l.length-1])instanceof g&&e.lines+t.lines<=32?(o+=e.lines,a+=e.length+1,l[l.length-1]=new g(t.text.concat(e.text),t.length+1+e.length)):(o+e.lines>n&&c(),o+=e.lines,a+=e.length+1,l.push(e))}function c(){0!=o&&(s.push(1==l.length?l[0]:P.from(l,a)),a=-1,o=l.length=0)}for(let t of e)h(t);return c(),1==s.length?s[0]:new P(s,t)}}function X(e,t,i=0,n=1e9){for(let r=0,O=0,s=!0;O=i&&(a>n&&(o=o.slice(0,n-r)),r0?1:(e instanceof g?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,n=this.nodes[i],r=this.offsets[i],O=r>>1,s=n instanceof g?n.text.length:n.children.length;if(O==(t>0?s:0)){if(0==i)return this.done=!0,this.value="",this;t>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((1&r)==(t>0?0:1)){if(this.offsets[i]+=t,0==e)return this.lineBreak=!0,this.value="\n",this;e--}else if(n instanceof g){let r=n.text[O+(t<0?-1:0)];if(this.offsets[i]+=t,r.length>Math.max(0,e))return this.value=0==e?r:t>0?r.slice(e):r.slice(0,r.length-e),this;e-=r.length}else{let r=n.children[O+(t<0?-1:0)];e>r.length?(e-=r.length,this.offsets[i]+=t):(t<0&&this.offsets[i]--,this.nodes.push(r),this.offsets.push(t>0?1:(r instanceof g?r.text.length:r.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class b{constructor(e,t,i){this.value="",this.done=!1,this.cursor=new w(e,t>i?-1:1),this.pos=t>i?e.length:0,this.from=Math.min(t,i),this.to=Math.max(t,i)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let i=t<0?this.pos-this.from:this.to-this.pos;e>i&&(e=i),i-=e;let{value:n}=this.cursor.next(e);return this.pos+=(n.length+e)*t,this.value=n.length<=i?n:t<0?n.slice(n.length-i):n.slice(0,i),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&""!=this.value}}class x{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:i,value:n}=this.inner.next(e);return t?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=n,this.afterBreak=!1),this}get lineBreak(){return!1}}"undefined"!=typeof Symbol&&(m.prototype[Symbol.iterator]=function(){return this.iter()},w.prototype[Symbol.iterator]=b.prototype[Symbol.iterator]=x.prototype[Symbol.iterator]=function(){return this});class S{constructor(e,t,i,n){this.from=e,this.to=t,this.number=i,this.text=n}get length(){return this.to-this.from}}const k=/\r\n?|\n/;var v,R=((v=R||(R={}))[v.Simple=0]="Simple",v[v.TrackDel=1]="TrackDel",v[v.TrackBefore=2]="TrackBefore",v[v.TrackAfter=3]="TrackAfter",v);class W{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;te)return r+(e-n);r+=s}else{if(i!=R.Simple&&a>=e&&(i==R.TrackDel&&ne||i==R.TrackBefore&&ne))return null;if(a>e||a==e&&t<0&&!s)return e==n||t<0?r:r+o;r+=o}n=a}if(e>n)throw new RangeError(`Position ${e} is out of range for changeset of length ${n}`);return r}touchesRange(e,t=e){for(let i=0,n=0;i=0&&n<=t&&r>=e)return!(nt)||"cover";n=r}return!1}toString(){let e="";for(let t=0;t=0?":"+n:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some((e=>"number"!=typeof e)))throw new RangeError("Invalid JSON representation of ChangeDesc");return new W(e)}}class T extends W{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return q(this,((t,i,n,r,O)=>e=e.replace(n,n+(i-t),O)),!1),e}mapDesc(e,t=!1){return A(this,e,t,!0)}invert(e){let t=this.sections.slice(),i=[];for(let n=0,r=0;n=0){t[n]=s,t[n+1]=O;let o=n>>1;for(;i.length0&&V(i,t,r.text),r.forward(e),s+=e}let a=e[O++];for(;s>1].toJSON()))}return e}static of(e,t,i){let n=[],r=[],O=0,s=null;function o(e=!1){if(!e&&!n.length)return;Os||e<0||s>t)throw new RangeError(`Invalid change range ${e} to ${s} (in doc of length ${t})`);let h=l?"string"==typeof l?m.of(l.split(i||k)):l:m.empty,c=h.length;if(e==s&&0==c)return;eO&&_(n,e-O,-1),_(n,s-e,c),V(r,n,h),O=s}}(e),o(!s),s}static empty(e){return new T(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],i=[];for(let n=0;nt&&"string"!=typeof e)))throw new RangeError("Invalid JSON representation of ChangeSet");if(1==r.length)t.push(r[0],0);else{for(;i.length=0&&i<=0&&i==e[r+1]?e[r]+=t:0==t&&0==e[r]?e[r+1]+=i:n?(e[r]+=t,e[r+1]+=i):e.push(t,i)}function V(e,t,i){if(0==i.length)return;let n=t.length-2>>1;if(n>1])),!(i||s==e.sections.length||e.sections[s+1]<0);)o=e.sections[s++],a=e.sections[s++];t(r,l,O,h,c),r=l,O=h}}}function A(e,t,i,n=!1){let r=[],O=n?[]:null,s=new N(e),o=new N(t);for(let e=0,t=0;;)if(-1==s.ins)e+=s.len,s.next();else if(-1==o.ins&&t=0&&(s.done||tt&&!s.done&&e+s.len=0)){if(s.done&&o.done)return O?new T(r,O):new W(r);throw new Error("Mismatched change set lengths")}{let i=0,n=e+s.len;for(;;)if(o.ins>=0&&t>e&&t+o.lent||s.ins>=0&&s.len>t)&&(e||n.length>i),O.forward2(t),s.forward(t)}}else _(n,0,s.ins,e),r&&V(r,n,s.text),s.next()}}class N{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return t>=e.length?m.empty:e[t]}textBit(e){let{inserted:t}=this.set,i=this.i-2>>1;return i>=t.length&&!e?m.empty:t[i].slice(this.off,null==e?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){-1==this.ins?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class Z{constructor(e,t,i){this.from=e,this.to=t,this.flags=i}get anchor(){return 16&this.flags?this.to:this.from}get head(){return 16&this.flags?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return 4&this.flags?-1:8&this.flags?1:0}get bidiLevel(){let e=3&this.flags;return 3==e?null:e}get goalColumn(){let e=this.flags>>5;return 33554431==e?void 0:e}map(e,t=-1){let i,n;return this.empty?i=n=e.mapPos(this.from,t):(i=e.mapPos(this.from,1),n=e.mapPos(this.to,-1)),i==this.from&&n==this.to?this:new Z(i,n,this.flags)}extend(e,t=e){if(e<=this.anchor&&t>=this.anchor)return z.range(e,t);let i=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return z.range(this.anchor,i)}eq(e){return this.anchor==e.anchor&&this.head==e.head}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||"number"!=typeof e.anchor||"number"!=typeof e.head)throw new RangeError("Invalid JSON representation for SelectionRange");return z.range(e.anchor,e.head)}}class z{constructor(e,t=0){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:z.create(this.ranges.map((i=>i.map(e,t))),this.mainIndex)}eq(e){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let t=0;te.toJSON())),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||"number"!=typeof e.main||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new z(e.ranges.map((e=>Z.fromJSON(e))),e.main)}static single(e,t=e){return new z([z.range(e,t)],0)}static create(e,t=0){if(0==e.length)throw new RangeError("A selection needs at least one range");for(let i=0,n=0;ne?4:0))}}function C(e,t=0){let i=e[t];e.sort(((e,t)=>e.from-t.from)),t=e.indexOf(i);for(let i=1;in.head?z.range(s,O):z.range(O,s))}}return new z(e,t)}function U(e,t){for(let i of e.ranges)if(i.to>t)throw new RangeError("Selection points outside of document")}let G=0;class I{constructor(e,t,i,n,r){this.combine=e,this.compareInput=t,this.compare=i,this.isStatic=n,this.extensions=r,this.id=G++,this.default=e([])}static define(e={}){return new I(e.combine||(e=>e),e.compareInput||((e,t)=>e===t),e.compare||(e.combine?(e,t)=>e===t:j),!!e.static,e.enables)}of(e){return new E([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new E(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new E(e,this,2,t)}from(e,t){return t||(t=e=>e),this.compute([e],(i=>t(i.field(e))))}}function j(e,t){return e==t||e.length==t.length&&e.every(((e,i)=>e===t[i]))}class E{constructor(e,t,i,n){this.dependencies=e,this.facet=t,this.type=i,this.value=n,this.id=G++}dynamicSlot(e){var t;let i=this.value,n=this.facet.compareInput,r=this.id,O=e[r]>>1,s=2==this.type,o=!1,a=!1,l=[];for(let i of this.dependencies)"doc"==i?o=!0:"selection"==i?a=!0:0==(1&(null!==(t=e[i.id])&&void 0!==t?t:1))&&l.push(e[i.id]);return{create:e=>(e.values[O]=i(e),1),update(e,t){if(o&&t.docChanged||a&&(t.docChanged||t.selection)||l.some((t=>(1&oe(e,t))>0))){let t=i(e);if(s?!D(t,e.values[O],n):!n(t,e.values[O]))return e.values[O]=t,1}return 0},reconfigure(e,t){let o=i(e),a=t.config.address[r];if(null!=a){let i=ae(t,a);if(s?D(o,i,n):n(o,i))return e.values[O]=i,0}return e.values[O]=o,1}}}}function D(e,t,i){if(e.length!=t.length)return!1;for(let n=0;ne[t.id])),r=i.map((e=>e.type)),O=n.filter((e=>!(1&e))),s=e[t.id]>>1;function o(e){let i=[];for(let t=0;t1&oe(e,t))))return 0;let n=o(e);return t.compare(n,e.values[s])?0:(e.values[s]=n,1)},reconfigure(e,r){let O=n.some((t=>1&oe(e,t))),a=r.config.facets[t.id],l=r.facet(t);if(a&&!O&&j(i,a))return e.values[s]=l,0;let h=o(e);return t.compare(h,l)?(e.values[s]=l,0):(e.values[s]=h,1)}}}const L=I.define({static:!0});class B{constructor(e,t,i,n,r){this.id=e,this.createF=t,this.updateF=i,this.compareF=n,this.spec=r,this.provides=void 0}static define(e){let t=new B(G++,e.create,e.update,e.compare||((e,t)=>e===t),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(L).find((e=>e.field==this));return((null==t?void 0:t.create)||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:e=>(e.values[t]=this.create(e),1),update:(e,i)=>{let n=e.values[t],r=this.updateF(n,i);return this.compareF(n,r)?0:(e.values[t]=r,1)},reconfigure:(e,i)=>null!=i.config.address[this.id]?(e.values[t]=i.field(this),0):(e.values[t]=this.create(e),1)}}init(e){return[this,L.of({field:this,create:e})]}get extension(){return this}}const K=4,F=3,H=2,J=1,ee=0;function te(e){return t=>new ne(t,e)}const ie={lowest:te(K),low:te(F),default:te(H),high:te(J),highest:te(ee),fallback:te(K),extend:te(J),override:te(ee)};class ne{constructor(e,t){this.inner=e,this.prec=t}}class re{of(e){return new Oe(this,e)}reconfigure(e){return re.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class Oe{constructor(e,t){this.compartment=e,this.inner=t}}class se{constructor(e,t,i,n,r,O){for(this.base=e,this.compartments=t,this.dynamicSlots=i,this.address=n,this.staticValues=r,this.facets=O,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(e,t,i){let n=[],r=Object.create(null),O=new Map;for(let i of function(e,t,i){let n=[[],[],[],[],[]],r=new Map;return function e(O,s){let o=r.get(O);if(null!=o){if(o>=s)return;let e=n[o].indexOf(O);e>-1&&n[o].splice(e,1),O instanceof Oe&&i.delete(O.compartment)}if(r.set(O,s),Array.isArray(O))for(let t of O)e(t,s);else if(O instanceof Oe){if(i.has(O.compartment))throw new RangeError("Duplicate use of compartment in extensions");let n=t.get(O.compartment)||O.inner;i.set(O.compartment,n),e(n,s)}else if(O instanceof ne)e(O.inner,O.prec);else if(O instanceof B)n[s].push(O),O.provides&&e(O.provides,s);else if(O instanceof E)n[s].push(O),O.facet.extensions&&e(O.facet.extensions,s);else{let t=O.extension;if(!t)throw new Error(`Unrecognized extension value in extension set (${O}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);e(t,s)}}(e,H),n.reduce(((e,t)=>e.concat(t)))}(e,t,O))i instanceof B?n.push(i):(r[i.facet.id]||(r[i.facet.id]=[])).push(i);let s=Object.create(null),o=[],a=[];for(let e of n)s[e.id]=a.length<<1,a.push((t=>e.slot(t)));let l=null==i?void 0:i.config.facets;for(let e in r){let t=r[e],n=t[0].facet,O=l&&l[e]||[];if(t.every((e=>0==e.type)))if(s[n.id]=o.length<<1|1,j(O,t))o.push(i.facet(n));else{let e=n.combine(t.map((e=>e.value)));o.push(i&&n.compare(e,i.facet(n))?i.facet(n):e)}else{for(let e of t)0==e.type?(s[e.id]=o.length<<1|1,o.push(e.value)):(s[e.id]=a.length<<1,a.push((t=>e.dynamicSlot(t))));s[n.id]=a.length<<1,a.push((e=>M(e,n,t)))}}let h=a.map((e=>e(s)));return new se(e,O,h,s,o,r)}}function oe(e,t){if(1&t)return 2;let i=t>>1,n=e.status[i];if(4==n)throw new Error("Cyclic dependency between fields and/or facets");if(2&n)return n;e.status[i]=4;let r=e.computeSlot(e,e.config.dynamicSlots[i]);return e.status[i]=2|r}function ae(e,t){return 1&t?e.config.staticValues[t>>1]:e.values[t>>1]}const le=I.define(),he=I.define({combine:e=>e.some((e=>e)),static:!0}),ce=I.define({combine:e=>e.length?e[0]:void 0,static:!0}),ue=I.define(),fe=I.define(),de=I.define(),pe=I.define({combine:e=>!!e.length&&e[0]});class $e{constructor(e,t){this.type=e,this.value=t}static define(){return new Qe}}class Qe{of(e){return new $e(this,e)}}class me{constructor(e){this.map=e}of(e){return new ge(this,e)}}class ge{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return void 0===t?void 0:t==this.value?this:new ge(this.type,t)}is(e){return this.type==e}static define(e={}){return new me(e.map||(e=>e))}static mapEffects(e,t){if(!e.length)return e;let i=[];for(let n of e){let e=n.map(t);e&&i.push(e)}return i}}ge.reconfigure=ge.define(),ge.appendConfig=ge.define();class Pe{constructor(e,t,i,n,r,O){this.startState=e,this.changes=t,this.selection=i,this.effects=n,this.annotations=r,this.scrollIntoView=O,this._doc=null,this._state=null,i&&U(i,t.newLength),r.some((e=>e.type==Pe.time))||(this.annotations=r.concat(Pe.time.of(Date.now())))}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(Pe.userEvent);return!(!t||!(t==e||t.length>e.length&&t.slice(0,e.length)==e&&"."==t[e.length]))}}function Xe(e,t){let i=[];for(let n=0,r=0;;){let O,s;if(n=e[n]))O=e[n++],s=e[n++];else{if(!(r=0;r--){let O=i[r](e);O&&Object.keys(O).length&&(n=ye(e,we(t,O,e.changes.newLength),!0))}return n==e?e:new Pe(t,e.changes,e.selection,n.effects,n.annotations,n.scrollIntoView)}(i?function(e){let t=e.startState,i=!0;for(let n of t.facet(ue)){let t=n(e);if(!1===t){i=!1;break}Array.isArray(t)&&(i=!0===i?t:Xe(i,t))}if(!0!==i){let n,r;if(!1===i)r=e.changes.invertedDesc,n=T.empty(t.doc.length);else{let t=e.changes.filter(i);n=t.changes,r=t.filtered.invertedDesc}e=new Pe(t,n,e.selection&&e.selection.map(r),ge.mapEffects(e.effects,r),e.annotations,e.scrollIntoView)}let n=t.facet(fe);for(let i=n.length-1;i>=0;i--){let r=n[i](e);e=r instanceof Pe?r:Array.isArray(r)&&1==r.length&&r[0]instanceof Pe?r[0]:be(t,Se(r),!1)}return e}(r):r)}Pe.time=$e.define(),Pe.userEvent=$e.define(),Pe.addToHistory=$e.define(),Pe.remote=$e.define();const xe=[];function Se(e){return null==e?xe:Array.isArray(e)?e:[e]}var ke=function(e){return e[e.Word=0]="Word",e[e.Space=1]="Space",e[e.Other=2]="Other",e}(ke||(ke={}));const ve=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let Re;try{Re=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch(e){}function We(e){return t=>{if(!/\S/.test(t))return ke.Space;if(function(e){if(Re)return Re.test(e);for(let t=0;t""&&(i.toUpperCase()!=i.toLowerCase()||ve.test(i)))return!0}return!1}(t))return ke.Word;for(let i=0;i-1)return ke.Word;return ke.Other}}class Te{constructor(e,t,i,n,r,O){this.config=e,this.doc=t,this.selection=i,this.values=n,this.status=e.statusTemplate.slice(),this.computeSlot=r,O&&(O._state=this);for(let e=0;er.set(t,e))),i=null),r.set(t.value.compartment,t.value.extension)):t.is(ge.reconfigure)?(i=null,n=t.value):t.is(ge.appendConfig)&&(i=null,n=Se(n).concat(t.value));i?t=e.startState.values.slice():(i=se.resolve(n,r,this),t=new Te(i,this.doc,this.selection,i.dynamicSlots.map((()=>null)),((e,t)=>t.reconfigure(e,this)),null).values),new Te(i,e.newDoc,e.newSelection,t,((t,i)=>i.update(t,e)),e)}replaceSelection(e){return"string"==typeof e&&(e=this.toText(e)),this.changeByRange((t=>({changes:{from:t.from,to:t.to,insert:e},range:z.cursor(t.from+e.length)})))}changeByRange(e){let t=this.selection,i=e(t.ranges[0]),n=this.changes(i.changes),r=[i.range],O=Se(i.effects);for(let i=1;ir.spec.fromJSON(O,e))))}return Te.create({doc:e.doc,selection:z.fromJSON(e.selection),extensions:t.extensions?n.concat([t.extensions]):n})}static create(e={}){let t=se.resolve(e.extensions||[],new Map),i=e.doc instanceof m?e.doc:m.of((e.doc||"").split(t.staticFacet(Te.lineSeparator)||k)),n=e.selection?e.selection instanceof z?e.selection:z.single(e.selection.anchor,e.selection.head):z.single(0);return U(n,i.length),t.staticFacet(he)||(n=n.asSingle()),new Te(t,i,n,t.dynamicSlots.map((()=>null)),((e,t)=>t.create(e)),null)}get tabSize(){return this.facet(Te.tabSize)}get lineBreak(){return this.facet(Te.lineSeparator)||"\n"}get readOnly(){return this.facet(pe)}phrase(e){for(let t of this.facet(Te.phrases))if(Object.prototype.hasOwnProperty.call(t,e))return t[e];return e}languageDataAt(e,t,i=-1){let n=[];for(let r of this.facet(le))for(let O of r(this,t,i))Object.prototype.hasOwnProperty.call(O,e)&&n.push(O[e]);return n}charCategorizer(e){return We(this.languageDataAt("wordChars",e).join(""))}wordAt(e){let{text:t,from:i,length:n}=this.doc.lineAt(e),r=this.charCategorizer(e),O=e-i,s=e-i;for(;O>0;){let e=a(t,O,!1);if(r(t.slice(e,O))!=ke.Word)break;O=e}for(;se.length?e[0]:4}),Te.lineSeparator=ce,Te.readOnly=pe,Te.phrases=I.define(),Te.languageData=le,Te.changeFilter=ue,Te.transactionFilter=fe,Te.transactionExtender=de,re.reconfigure=ge.define();const Ve=1024;let qe=0;class Ae{constructor(e,t){this.from=e,this.to=t}}class Ye{constructor(e={}){this.id=qe++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")})}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return"function"!=typeof e&&(e=ze.match(e)),t=>{let i=e(t);return void 0===i?null:[this,i]}}}Ye.closedBy=new Ye({deserialize:e=>e.split(" ")}),Ye.openedBy=new Ye({deserialize:e=>e.split(" ")}),Ye.group=new Ye({deserialize:e=>e.split(" ")}),Ye.contextHash=new Ye({perNode:!0}),Ye.lookAhead=new Ye({perNode:!0}),Ye.mounted=new Ye({perNode:!0});class Ne{constructor(e,t,i){this.tree=e,this.overlay=t,this.parser=i}}const Ze=Object.create(null);class ze{constructor(e,t,i,n=0){this.name=e,this.props=t,this.id=i,this.flags=n}static define(e){let t=e.props&&e.props.length?Object.create(null):Ze,i=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(null==e.name?8:0),n=new ze(e.name||"",t,e.id,i);if(e.props)for(let i of e.props)if(Array.isArray(i)||(i=i(n)),i){if(i[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[i[0].id]=i[1]}return n}prop(e){return this.props[e.id]}get isTop(){return(1&this.flags)>0}get isSkipped(){return(2&this.flags)>0}get isError(){return(4&this.flags)>0}get isAnonymous(){return(8&this.flags)>0}is(e){if("string"==typeof e){if(this.name==e)return!0;let t=this.prop(Ye.group);return!!t&&t.indexOf(e)>-1}return this.id==e}static match(e){let t=Object.create(null);for(let i in e)for(let n of i.split(" "))t[n]=e[i];return e=>{for(let i=e.prop(Ye.group),n=-1;n<(i?i.length:0);n++){let r=t[n<0?e.name:i[n]];if(r)return r}}}}ze.none=new ze("",Object.create(null),0,8);class Ce{constructor(e){this.types=e;for(let t=0;te.node;;){let s=!1;if(e.from<=r&&e.to>=n&&(e.type.isAnonymous||!1!==t(e.type,e.from,e.to,O))){if(e.firstChild())continue;e.type.isAnonymous||(s=!0)}for(;s&&i&&i(e.type,e.from,e.to,O),s=e.type.isAnonymous,!e.nextSibling();){if(!e.parent())return;s=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:nt(ze.none,this.children,this.positions,0,this.children.length,0,this.length,((e,t,i)=>new Ie(this.type,e,t,i,this.propValues)),e.makeTree||((e,t,i)=>new Ie(ze.none,e,t,i)))}static build(e){return function(e){var t;let{buffer:i,nodeSet:n,maxBufferLength:r=Ve,reused:O=[],minRepeatType:s=n.types.length}=e,o=Array.isArray(i)?new je(i,i.length):i,a=n.types,l=0,h=0;function c(e,t,i,p,$){let{id:Q,start:m,end:g,size:P}=o,X=h;for(;P<0;){if(o.next(),-1==P){let t=O[Q];return i.push(t),void p.push(m-e)}if(-3==P)return void(l=Q);if(-4==P)return void(h=Q);throw new RangeError(`Unrecognized record size: ${P}`)}let y,w,b=a[Q],x=m-e;if(g-m<=r&&(w=function(e,t){let i=o.fork(),n=0,O=0,a=0,l=i.end-r,h={size:0,start:0,skip:0};e:for(let r=i.pos-e;i.pos>r;){let e=i.size;if(i.id==t&&e>=0){h.size=n,h.start=O,h.skip=a,a+=4,n+=4,i.next();continue}let o=i.pos-e;if(e<0||o=s?4:0,u=i.start;for(i.next();i.pos>o;){if(i.size<0){if(-3!=i.size)break e;c+=4}else i.id>=s&&(c+=4);i.next()}O=u,n+=e,a+=c}return(t<0||n==e)&&(h.size=n,h.start=O,h.skip=a),h.size>4?h:void 0}(o.pos-t,$))){let t=new Uint16Array(w.size-w.skip),i=o.pos-w.size,r=t.length;for(;o.pos>i;)r=d(w.start,t,r);y=new Ee(t,g-w.start,n),x=w.start-e}else{let e=o.pos-P;o.next();let t=[],i=[],n=Q>=s?Q:-1,O=0,a=g;for(;o.pos>e;)n>=0&&o.id==n&&o.size>=0?(o.end<=a-r&&(u(t,i,m,O,o.end,a,n,X),O=t.length,a=o.end),o.next()):c(m,e,t,i,n);if(n>=0&&O>0&&O-1&&O>0){let e=function(e){return(t,i,n)=>{let r,O,s=0,o=t.length-1;if(o>=0&&(r=t[o])instanceof Ie){if(!o&&r.type==e&&r.length==n)return r;(O=r.prop(Ye.lookAhead))&&(s=i[o]+r.length+O)}return f(e,t,i,n,s)}}(b);y=nt(b,t,i,0,t.length,0,g-m,e,e)}else y=f(b,t,i,g-m,X-g)}i.push(y),p.push(x)}function u(e,t,i,r,O,s,o,a){let l=[],h=[];for(;e.length>r;)l.push(e.pop()),h.push(t.pop()+i-O);e.push(f(n.types[o],l,h,s-O,a-s)),t.push(O-i)}function f(e,t,i,n,r=0,O){if(l){let e=[Ye.contextHash,l];O=O?[e].concat(O):[e]}if(r>25){let e=[Ye.lookAhead,r];O=O?[e].concat(O):[e]}return new Ie(e,t,i,n,O)}function d(e,t,i){let{id:n,start:r,end:O,size:a}=o;if(o.next(),a>=0&&n4){let n=o.pos-(a-4);for(;o.pos>n;)i=d(e,t,i)}t[--i]=s,t[--i]=O-e,t[--i]=r-e,t[--i]=n}else-3==a?l=n:-4==a&&(h=n);return i}let p=[],$=[];for(;o.pos>0;)c(e.start||0,e.bufferStart||0,p,$,-1);let Q=null!==(t=e.length)&&void 0!==t?t:p.length?$[0]+p[0].length:0;return new Ie(a[e.topID],p.reverse(),$.reverse(),Q)}(e)}}Ie.empty=new Ie(ze.none,[],[],0);class je{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new je(this.buffer,this.index)}}class Ee{constructor(e,t,i){this.buffer=e,this.length=t,this.set=i}get type(){return ze.none}toString(){let e=[];for(let t=0;t0));o=O[o+3]);return s}slice(e,t,i,n){let r=this.buffer,O=new Uint16Array(t-e);for(let n=e,s=0;n=t&⁢case 1:return i<=t&&n>t;case 2:return n>t;case 4:return!0}}function Me(e,t){let i=e.childBefore(t);for(;i;){let t=i.lastChild;if(!t||t.to!=i.to)break;t.type.isError&&t.from==t.to?(e=i,i=t.prevSibling):i=t}return e}function Le(e,t,i,n){for(var r;e.from==e.to||(i<1?e.from>=t:e.from>t)||(i>-1?e.to<=t:e.to0?s.length:-1;e!=a;e+=t){let a=s[e],l=o[e]+O._from;if(De(n,i,l,l+a.length))if(a instanceof Ee){if(2&r)continue;let s=a.findChild(0,a.buffer.length,t,i-l,n);if(s>-1)return new He(new Fe(O,a,e,l),null,s)}else if(1&r||!a.type.isAnonymous||et(a)){let s;if(!(1&r)&&a.props&&(s=a.prop(Ye.mounted))&&!s.overlay)return new Be(s.tree,l,e,O);let o=new Be(a,l,e,O);return 1&r||!o.type.isAnonymous?o:o.nextChild(t<0?a.children.length-1:0,t,i,n)}}if(1&r||!O.type.isAnonymous)return null;if(e=O.index>=0?O.index+t:t<0?-1:O._parent.node.children.length,O=O._parent,!O)return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this.node.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this.node.children.length-1,-1,e,-2)}enter(e,t,i=!0,n=!0){let r;if(i&&(r=this.node.prop(Ye.mounted))&&r.overlay){let i=e-this.from;for(let{from:e,to:n}of r.overlay)if((t>0?e<=i:e=i:n>i))return new Be(r.tree,r.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,n?0:2)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get cursor(){return new Je(this)}get tree(){return this.node}toTree(){return this.node}resolve(e,t=0){return Le(this,e,t,!1)}resolveInner(e,t=0){return Le(this,e,t,!0)}enterUnfinishedNodesBefore(e){return Me(this,e)}getChild(e,t=null,i=null){let n=Ke(this,e,t,i);return n.length?n[0]:null}getChildren(e,t=null,i=null){return Ke(this,e,t,i)}toString(){return this.node.toString()}}function Ke(e,t,i,n){let r=e.cursor,O=[];if(!r.firstChild())return O;if(null!=i)for(;!r.type.is(i);)if(!r.nextSibling())return O;for(;;){if(null!=n&&r.type.is(n))return O;if(r.type.is(t)&&O.push(r.node),!r.nextSibling())return null==n?O:[]}}class Fe{constructor(e,t,i,n){this.parent=e,this.buffer=t,this.index=i,this.start=n}}class He{constructor(e,t,i){this.context=e,this._parent=t,this.index=i,this.type=e.buffer.set.types[e.buffer.buffer[i]]}get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}child(e,t,i){let{buffer:n}=this.context,r=n.findChild(this.index+4,n.buffer[this.index+3],e,t-this.context.start,i);return r<0?null:new He(this.context,this,r)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}enter(e,t,i,n=!0){if(!n)return null;let{buffer:r}=this.context,O=r.findChild(this.index+4,r.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return O<0?null:new He(this.context,this,O)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new He(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new He(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get cursor(){return new Je(this)}get tree(){return null}toTree(){let e=[],t=[],{buffer:i}=this.context,n=this.index+4,r=i.buffer[this.index+3];if(r>n){let O=i.buffer[this.index+1],s=i.buffer[this.index+2];e.push(i.slice(n,r,O,s)),t.push(0)}return new Ie(this.type,e,t,this.to-this.from)}resolve(e,t=0){return Le(this,e,t,!1)}resolveInner(e,t=0){return Le(this,e,t,!0)}enterUnfinishedNodesBefore(e){return Me(this,e)}toString(){return this.context.buffer.childString(this.index)}getChild(e,t=null,i=null){let n=Ke(this,e,t,i);return n.length?n[0]:null}getChildren(e,t=null,i=null){return Ke(this,e,t,i)}}class Je{constructor(e,t=0){if(this.mode=t,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,e instanceof Be)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let t=e._parent;t;t=t._parent)this.stack.unshift(t.index);this.bufferNode=e,this.yieldBuf(e.index)}}get name(){return this.type.name}yieldNode(e){return!!e&&(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0)}yieldBuf(e,t){this.index=e;let{start:i,buffer:n}=this.buffer;return this.type=t||n.set.types[n.buffer[e]],this.from=i+n.buffer[e+1],this.to=i+n.buffer[e+2],!0}yield(e){return!!e&&(e instanceof Be?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)))}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,i){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree.node.children.length-1:0,e,t,i,this.mode));let{buffer:n}=this.buffer,r=n.findChild(this.index+4,n.buffer[this.index+3],e,t-this.buffer.start,i);return!(r<0)&&(this.stack.push(this.index),this.yieldBuf(r))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,i=!0,n=!0){return this.buffer?!!n&&this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,i&&!(1&this.mode),n))}parent(){if(!this.buffer)return this.yieldNode(1&this.mode?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=1&this.mode?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return!!this._tree._parent&&this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode));let{buffer:t}=this.buffer,i=this.stack.length-1;if(e<0){let e=i<0?0:this.stack[i]+4;if(this.index!=e)return this.yieldBuf(t.findChild(e,this.index,-1,0,4))}else{let e=t.buffer[this.index+3];if(e<(i<0?t.buffer.length:t.buffer[this.stack[i]+3]))return this.yieldBuf(e)}return i<0&&this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode))}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,i,{buffer:n}=this;if(n){if(e>0){if(this.index-1)for(let n=t+e,r=e<0?-1:i.node.children.length;n!=r;n+=e){let e=i.node.children[n];if(1&this.mode||e instanceof Ee||!e.type.isAnonymous||et(e))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to=0;){for(let O=e;O;O=O._parent)if(O.index==n){if(n==this.index)return O;t=O,i=r+1;break e}n=this.stack[--r]}for(let e=i;ee instanceof Ee||!e.type.isAnonymous||et(e)))}const tt=new WeakMap;function it(e,t){if(!e.isAnonymous||t instanceof Ee||t.type!=e)return 1;let i=tt.get(t);if(null==i){i=1;for(let n of t.children){if(n.type!=e||!(n instanceof Ie)){i=1;break}i+=it(e,n)}tt.set(t,i)}return i}function nt(e,t,i,n,r,O,s,o,a){let l=0;for(let i=n;i=h)break;d+=t}if(l==r+1){if(d>h){let e=i[r];t(e.children,e.positions,0,e.children.length,n[r]+o);continue}c.push(i[r])}else{let t=n[l-1]+i[l-1].length-f;c.push(nt(e,i,n,r,l,f,t,null,a))}u.push(f+o-O)}}(t,i,n,r,0),(o||a)(c,u,s)}class rt{constructor(e,t,i,n,r=!1,O=!1){this.from=e,this.to=t,this.tree=i,this.offset=n,this.open=(r?1:0)|(O?2:0)}get openStart(){return(1&this.open)>0}get openEnd(){return(2&this.open)>0}static addTree(e,t=[],i=!1){let n=[new rt(0,e.length,e,0,!1,i)];for(let i of t)i.to>e.length&&n.push(i);return n}static applyChanges(e,t,i=128){if(!t.length)return e;let n=[],r=1,O=e.length?e[0]:null;for(let s=0,o=0,a=0;;s++){let l=s=i)for(;O&&O.from=t.from||h<=t.to||a){let e=Math.max(t.from,o)-a,i=Math.min(t.to,h)-a;t=e>=i?null:new rt(e,i,t.tree,t.offset+a,s>0,!!l)}if(t&&n.push(t),O.to>h)break;O=rnew Ae(e.from,e.to))):[new Ae(0,0)]:[new Ae(0,e.length)],this.createParse(e,t||[],i)}parse(e,t,i){let n=this.startParse(e,t,i);for(;;){let e=n.advance();if(e)return e}}}class st{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}}function ot(e){return(t,i,n,r)=>new ct(t,e,i,n,r)}class at{constructor(e,t,i,n,r){this.parser=e,this.parse=t,this.overlay=i,this.target=n,this.ranges=r}}class lt{constructor(e,t,i,n,r,O,s){this.parser=e,this.predicate=t,this.mounts=i,this.index=n,this.start=r,this.target=O,this.prev=s,this.depth=0,this.ranges=[]}}const ht=new Ye({perNode:!0});class ct{constructor(e,t,i,n,r){this.nest=t,this.input=i,this.fragments=n,this.ranges=r,this.inner=[],this.innerDone=0,this.baseTree=null,this.stoppedAt=null,this.baseParse=e}advance(){if(this.baseParse){let e=this.baseParse.advance();if(!e)return null;if(this.baseParse=null,this.baseTree=e,this.startInner(),null!=this.stoppedAt)for(let e of this.inner)e.parse.stopAt(this.stoppedAt)}if(this.innerDone==this.inner.length){let e=this.baseTree;return null!=this.stoppedAt&&(e=new Ie(e.type,e.children,e.positions,e.length,e.propValues.concat([[ht,this.stoppedAt]]))),e}let e=this.inner[this.innerDone],t=e.parse.advance();if(t){this.innerDone++;let i=Object.assign(Object.create(null),e.target.props);i[Ye.mounted.id]=new Ne(t,e.overlay,e.parser),e.target.props=i}return null}get parsedPos(){if(this.baseParse)return 0;let e=this.input.length;for(let t=this.innerDone;te.frag.from<=n.from&&e.frag.to>=n.to&&e.mount.overlay));if(e)for(let i of e.mount.overlay){let r=i.from+e.pos,O=i.to+e.pos;r>=n.from&&O<=n.to&&!t.ranges.some((e=>e.fromr))&&t.ranges.push({from:r,to:O})}}o=!1}else if(i&&(O=ut(i.ranges,n.from,n.to)))o=2!=O;else if(!n.type.isAnonymous&&n.fromnew Ae(e.from-n.from,e.to-n.from))):null,n.tree,e)),r.overlay?e.length&&(i={ranges:e,depth:0,prev:i}):o=!1}}else t&&(s=t.predicate(n))&&(!0===s&&(s=new Ae(n.from,n.to)),s.fromnew Ae(e.from-t.start,e.to-t.start))),t.target,e)),t=t.prev}i&&!--i.depth&&(i=i.prev)}}}}function ut(e,t,i){for(let n of e){if(n.from>=i)break;if(n.to>t)return n.from<=t&&n.to>=i?2:1}return 0}function ft(e,t,i,n,r,O){if(t=t.to);n++);let s=r.children[n],o=s.buffer;r.children[n]=function e(i,n,r,a,l){let h=i;for(;o[h+2]+O<=t.from;)h=o[h+3];let c=[],u=[];ft(s,i,h,c,u,a);let f=o[h+1],d=o[h+2],p=f+O==t.from&&d+O==t.to&&o[h]==t.type.id;return c.push(p?t.toTree():e(h+4,o[h+3],s.set.types[o[h]],f,d-f)),u.push(f-a),ft(s,o[h+3],n,c,u,a),new Ie(r,c,u,l)}(0,o.length,ze.none,0,s.length);for(let n=0;n<=i;n++)e.childAfter(t.from)}class pt{constructor(e,t){this.offset=t,this.done=!1,this.cursor=e.fullCursor()}moveTo(e){let{cursor:t}=this,i=e-this.offset;for(;!this.done&&t.from=e&&t.enter(i,1,!1,!1)||t.next(!1)||(this.done=!0)}hasNode(e){if(this.moveTo(e.from),!this.done&&this.cursor.from+this.offset==e.from&&this.cursor.tree)for(let t=this.cursor.tree;;){if(t==e.tree)return!0;if(!(t.children.length&&0==t.positions[0]&&t.children[0]instanceof Ie))break;t=t.children[0]}return!1}}class $t{constructor(e){var t;if(this.fragments=e,this.curTo=0,this.fragI=0,e.length){let i=this.curFrag=e[0];this.curTo=null!==(t=i.tree.prop(ht))&&void 0!==t?t:i.to,this.inner=new pt(i.tree,-i.offset)}else this.curFrag=this.inner=null}hasNode(e){for(;this.curFrag&&e.from>=this.curTo;)this.nextFrag();return this.curFrag&&this.curFrag.from<=e.from&&this.curTo>=e.to&&this.inner.hasNode(e)}nextFrag(){var e;if(this.fragI++,this.fragI==this.fragments.length)this.curFrag=this.inner=null;else{let t=this.curFrag=this.fragments[this.fragI];this.curTo=null!==(e=t.tree.prop(ht))&&void 0!==e?e:t.to,this.inner=new pt(t.tree,-t.offset)}}findMounts(e,t){var i;let n=[];if(this.inner){this.inner.cursor.moveTo(e,1);for(let e=this.inner.cursor.node;e;e=e.parent){let r=null===(i=e.tree)||void 0===i?void 0:i.prop(Ye.mounted);if(r&&r.parser==t)for(let t=this.fragI;t=e.to)break;i.tree==this.curFrag.tree&&n.push({frag:i,pos:e.from-i.offset,mount:r})}}}return n}}function Qt(e,t){let i=null,n=t;for(let r=1,O=0;r=o)break;e.to<=s||(i||(n=i=t.slice()),e.fromo&&i.splice(O+1,0,new Ae(o,e.to))):e.to>o?i[O--]=new Ae(o,e.to):i.splice(O--,1))}}return n}function mt(e,t,i,n){let r=0,O=0,s=!1,o=!1,a=-1e9,l=[];for(;;){let h=r==e.length?1e9:s?e[r].to:e[r].from,c=O==t.length?1e9:o?t[O].to:t[O].from;if(s!=o){let e=Math.max(a,i),t=Math.min(h,c,n);enew Ae(e.from+n,e.to+n))),o,a);for(let t=0,n=o;;t++){let o=t==s.length,l=o?a:s[t].from;if(l>n&&i.push(new rt(n,l,r.tree,-e,O.from>=n,O.to<=l)),o)break;n=s[t].to}}else i.push(new rt(o,a,r.tree,-e,O.from>=e,O.to<=s))}return i}const Pt="undefined"==typeof Symbol?"__ͼ":Symbol.for("ͼ"),Xt="undefined"==typeof Symbol?"__styleSet"+Math.floor(1e8*Math.random()):Symbol("styleSet"),yt="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:{};class wt{constructor(e,t){this.rules=[];let{finish:i}=t||{};function n(e){return/^@/.test(e)?[e]:e.split(/,\s*/)}function r(e,t,O,s){let o=[],a=/^@(\w+)\b/.exec(e[0]),l=a&&"keyframes"==a[1];if(a&&null==t)return O.push(e[0]+";");for(let i in t){let s=t[i];if(/&/.test(i))r(i.split(/,\s*/).map((t=>e.map((e=>t.replace(/&/,e))))).reduce(((e,t)=>e.concat(t))),s,O);else if(s&&"object"==typeof s){if(!a)throw new RangeError("The value of a property ("+i+") should be a primitive value.");r(n(i),s,o,l)}else null!=s&&o.push(i.replace(/_.*/,"").replace(/[A-Z]/g,(e=>"-"+e.toLowerCase()))+": "+s+";")}(o.length||l)&&O.push((!i||a||s?e:e.map(i)).join(", ")+" {"+o.join(" ")+"}")}for(let t in e)r(n(t),e[t],this.rules)}getRules(){return this.rules.join("\n")}static newName(){let e=yt[Pt]||1;return yt[Pt]=e+1,"ͼ"+e.toString(36)}static mount(e,t){(e[Xt]||new xt(e)).mount(Array.isArray(t)?t:[t])}}let bt=null;class xt{constructor(e){if(!e.head&&e.adoptedStyleSheets&&"undefined"!=typeof CSSStyleSheet){if(bt)return e.adoptedStyleSheets=[bt.sheet].concat(e.adoptedStyleSheets),e[Xt]=bt;this.sheet=new CSSStyleSheet,e.adoptedStyleSheets=[this.sheet].concat(e.adoptedStyleSheets),bt=this}else{this.styleTag=(e.ownerDocument||e).createElement("style");let t=e.head||e;t.insertBefore(this.styleTag,t.firstChild)}this.modules=[],e[Xt]=this}mount(e){let t=this.sheet,i=0,n=0;for(let r=0;r-1&&(this.modules.splice(s,1),n--,s=-1),-1==s){if(this.modules.splice(n++,0,O),t)for(let e=0;e>1,o=r[n]-e||(i?this.value[n].endSide:this.value[n].startSide)-t;if(n==O)return o>=0?O:s;o>=0?s=n:O=n+1}}between(e,t,i,n){for(let r=this.findIndex(t,-1e9,!0),O=this.findIndex(i,1e9,!1,r);rl||a==l&&h.startSide>0&&h.endSide<=0)continue;(l-a||h.endSide-h.startSide)<0||(O<0&&(O=a),h.point&&(s=Math.max(s,l-a)),i.push(h),n.push(a-O),r.push(l-O))}return{mapped:i.length?new Rt(n,r,i,s):null,pos:O}}}class Wt{constructor(e,t,i=Wt.empty,n){this.chunkPos=e,this.chunk=t,this.nextLayer=i,this.maxPoint=n}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let t of this.chunk)e+=t.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:t=[],sort:i=!1,filterFrom:n=0,filterTo:r=this.length}=e,O=e.filter;if(0==t.length&&!O)return this;if(i&&(t=t.slice().sort(vt)),this.isEmpty)return t.length?Wt.of(t):this;let s=new Vt(this,null,-1).goto(0),o=0,a=[],l=new Tt;for(;s.value||o=0){let e=t[o++];l.addInner(e.from,e.to,e.value)||a.push(e)}else 1==s.rangeIndex&&s.chunkIndexthis.chunkEnd(s.chunkIndex)||rs.to||r=r&&e<=r+O.length&&!1===O.between(r,e-r,t-r,i))return}this.nextLayer.between(e,t,i)}}iter(e=0){return qt.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return qt.from(e).goto(t)}static compare(e,t,i,n,r=-1){let O=e.filter((e=>e.maxPoint>0||!e.isEmpty&&e.maxPoint>=r)),s=t.filter((e=>e.maxPoint>0||!e.isEmpty&&e.maxPoint>=r)),o=_t(O,s,i),a=new Yt(O,o,r),l=new Yt(s,o,r);i.iterGaps(((e,t,i)=>Nt(a,e,l,t,i,n))),i.empty&&0==i.length&&Nt(a,0,l,0,0,n)}static eq(e,t,i=0,n){null==n&&(n=1e9);let r=e.filter((e=>!e.isEmpty&&t.indexOf(e)<0)),O=t.filter((t=>!t.isEmpty&&e.indexOf(t)<0));if(r.length!=O.length)return!1;if(!r.length)return!0;let s=_t(r,O),o=new Yt(r,s,0).goto(i),a=new Yt(O,s,0).goto(i);for(;;){if(o.to!=a.to||!Zt(o.active,a.active)||o.point&&(!a.point||!o.point.eq(a.point)))return!1;if(o.to>n)return!0;o.next(),a.next()}}static spans(e,t,i,n,r=-1){var O;let s=new Yt(e,null,r,null===(O=n.filterPoint)||void 0===O?void 0:O.bind(n)).goto(t),o=t,a=s.openStart;for(;;){let e=Math.min(s.to,i);if(s.point?(n.point(o,e,s.point,s.activeForPoint(s.to),a),a=s.openEnd(e)+(s.to>e?1:0)):e>o&&(n.span(o,e,s.active,a),a=s.openEnd(e)),s.to>i)break;o=s.to,s.next()}return a}static of(e,t=!1){let i=new Tt;for(let n of e instanceof kt?[e]:t?function(e){if(e.length>1)for(let t=e[0],i=1;i0)return e.slice().sort(vt);t=n}return e}(e):e)i.add(n.from,n.to,n.value);return i.finish()}}Wt.empty=new Wt([],[],null,-1),Wt.empty.nextLayer=Wt.empty;class Tt{constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}finishChunk(e){this.chunks.push(new Rt(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}add(e,t,i){this.addInner(e,t,i)||(this.nextLayer||(this.nextLayer=new Tt)).add(e,t,i)}addInner(e,t,i){let n=e-this.lastTo||i.startSide-this.last.endSide;if(n<=0&&(e-this.lastFrom||i.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return!(n<0||(250==this.from.length&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(t-this.chunkStart),this.last=i,this.lastFrom=e,this.lastTo=t,this.value.push(i),i.point&&(this.maxPoint=Math.max(this.maxPoint,t-e)),0))}addChunk(e,t){if((e-this.lastTo||t.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,t.maxPoint),this.chunks.push(t),this.chunkPos.push(e);let i=t.value.length-1;return this.last=t.value[i],this.lastFrom=t.from[i]+e,this.lastTo=t.to[i]+e,!0}finish(){return this.finishInner(Wt.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),0==this.chunks.length)return e;let t=new Wt(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}}function _t(e,t,i){let n=new Map;for(let t of e)for(let e=0;e=this.minPoint)break}}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex=i&&n.push(new Vt(O,t,i,r));return 1==n.length?n[0]:new qt(n)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let i of this.heap)i.goto(e,t);for(let e=this.heap.length>>1;e>=0;e--)At(this.heap,e);return this.next(),this}forward(e,t){for(let i of this.heap)i.forward(e,t);for(let e=this.heap.length>>1;e>=0;e--)At(this.heap,e);(this.to-e||this.value.endSide-t)<0&&this.next()}next(){if(0==this.heap.length)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),At(this.heap,0)}}}function At(e,t){for(let i=e[t];;){let n=1+(t<<1);if(n>=e.length)break;let r=e[n];if(n+1=0&&(r=e[n+1],n++),i.compare(r)<0)break;e[n]=i,e[t]=r,t=n}}class Yt{constructor(e,t,i,n=(()=>!0)){this.minPoint=i,this.filterPoint=n,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=qt.from(e,t,i)}goto(e,t=-1e9){return this.cursor.goto(e,t),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=t,this.openStart=-1,this.next(),this}forward(e,t){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t)<0;)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){zt(this.active,e),zt(this.activeTo,e),zt(this.activeRank,e),this.minActive=Ut(this.active,this.activeTo)}addActive(e){let t=0,{value:i,to:n,rank:r}=this.cursor;for(;t-1&&(this.activeTo[r]-this.cursor.from||this.active[r].endSide-this.cursor.startSide)<0){if(this.activeTo[r]>e){this.to=this.activeTo[r],this.endSide=this.active[r].endSide;break}this.removeActive(r),i&&zt(i,r)}else{if(!this.cursor.value){this.to=this.endSide=1e9;break}if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}{let r=this.cursor.value;if(r.point)if(t&&this.cursor.to==this.to&&this.cursor.from=0&&!(this.activeRank[i]e||this.activeTo[i]==e&&this.active[i].endSide>=this.point.endSide)&&t.push(this.active[i]);return t.reverse()}openEnd(e){let t=0;for(let i=this.activeTo.length-1;i>=0&&this.activeTo[i]>e;i--)t++;return t}}function Nt(e,t,i,n,r,O){e.goto(t),i.goto(n);let s=n+r,o=n,a=n-t;for(;;){let t=e.to+a-i.to||e.endSide-i.endSide,n=t<0?e.to+a:i.to,r=Math.min(n,s);if(e.point||i.point?e.point&&i.point&&(e.point==i.point||e.point.eq(i.point))&&Zt(e.activeForPoint(e.to+a),i.activeForPoint(i.to))||O.comparePoint(o,r,e.point,i.point):r>o&&!Zt(e.active,i.active)&&O.compareRange(o,r,e.active,i.active),n>s)break;o=n,t<=0&&e.next(),t>=0&&i.next()}}function Zt(e,t){if(e.length!=t.length)return!1;for(let i=0;i=t;i--)e[i+1]=e[i];e[t]=i}function Ut(e,t){let i=-1,n=1e9;for(let r=0;r",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"',229:"Q"},jt="undefined"!=typeof navigator&&/Chrome\/(\d+)/.exec(navigator.userAgent),Et="undefined"!=typeof navigator&&/Apple Computer/.test(navigator.vendor),Dt="undefined"!=typeof navigator&&/Gecko\/\d+/.test(navigator.userAgent),Mt="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),Lt="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),Bt=jt&&(Mt||+jt[1]<57)||Dt&&Mt,Kt=0;Kt<10;Kt++)Gt[48+Kt]=Gt[96+Kt]=String(Kt);for(Kt=1;Kt<=24;Kt++)Gt[Kt+111]="F"+Kt;for(Kt=65;Kt<=90;Kt++)Gt[Kt]=String.fromCharCode(Kt+32),It[Kt]=String.fromCharCode(Kt);for(var Ft in Gt)It.hasOwnProperty(Ft)||(It[Ft]=Gt[Ft]);function Ht(e){let t;return t=11==e.nodeType?e.getSelection?e:e.ownerDocument:e,t.getSelection()}function Jt(e,t){return!!t&&(e==t||e.contains(1!=t.nodeType?t.parentNode:t))}function ei(e,t){if(!t.anchorNode)return!1;try{return Jt(e,t.anchorNode)}catch(e){return!1}}function ti(e){return 3==e.nodeType?fi(e,0,e.nodeValue.length).getClientRects():1==e.nodeType?e.getClientRects():[]}function ii(e,t,i,n){return!!i&&(ri(e,t,i,n,-1)||ri(e,t,i,n,1))}function ni(e){for(var t=0;;t++)if(!(e=e.previousSibling))return t}function ri(e,t,i,n,r){for(;;){if(e==i&&t==n)return!0;if(t==(r<0?0:Oi(e))){if("DIV"==e.nodeName)return!1;let i=e.parentNode;if(!i||1!=i.nodeType)return!1;t=ni(e)+(r<0?0:1),e=i}else{if(1!=e.nodeType)return!1;if(1==(e=e.childNodes[t+(r<0?-1:0)]).nodeType&&"false"==e.contentEditable)return!1;t=r<0?Oi(e):0}}}function Oi(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}const si={left:0,right:0,top:0,bottom:0};function oi(e,t){let i=t?e.left:e.right;return{left:i,right:i,top:e.top,bottom:e.bottom}}function ai(e){return{left:0,right:e.innerWidth,top:0,bottom:e.innerHeight}}class li{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){this.set(e.anchorNode,e.anchorOffset,e.focusNode,e.focusOffset)}set(e,t,i,n){this.anchorNode=e,this.anchorOffset=t,this.focusNode=i,this.focusOffset=n}}let hi,ci=null;function ui(e){if(e.setActive)return e.setActive();if(ci)return e.focus(ci);let t=[];for(let i=e;i&&(t.push(i,i.scrollTop,i.scrollLeft),i!=i.ownerDocument);i=i.parentNode);if(e.focus(null==ci?{get preventScroll(){return ci={preventScroll:!0},!0}}:void 0),!ci){ci=!1;for(let e=0;et)return i.domBoundsAround(e,t,a);if(h>=e&&-1==n&&(n=o,r=a),a>t&&i.dom.parentNode==this.dom){O=o,s=l;break}l=h,a=h+i.breakAfter}return{from:r,to:s<0?i+this.length:s,startDOM:(n?this.children[n-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:O=0?this.children[O].dom:null}}markDirty(e=!1){this.dirty|=2,this.markParentsDirty(e)}markParentsDirty(e){for(let t=this.parent;t;t=t.parent){if(e&&(t.dirty|=2),1&t.dirty)return;t.dirty|=1,e=!1}}setParent(e){this.parent!=e&&(this.parent=e,this.dirty&&this.markParentsDirty(!0))}setDOM(e){this.dom&&(this.dom.cmView=null),this.dom=e,e.cmView=this}get rootView(){for(let e=this;;){let t=e.parent;if(!t)return e;e=t}}replaceChildren(e,t,i=Qi){this.markDirty();for(let i=e;ithis.pos||e==this.pos&&(t>0||0==this.i||this.children[this.i-1].breakAfter))return this.off=e-this.pos,this;let i=this.children[--this.i];this.pos-=i.length+i.breakAfter}}}function Xi(e,t,i,n,r,O,s,o,a){let{children:l}=e,h=l.length?l[t]:null,c=O.length?O[O.length-1]:null,u=c?c.breakAfter:s;if(!(t==n&&h&&!s&&!u&&O.length<2&&h.merge(i,r,O.length?c:null,0==i,o,a))){if(n0&&(!s&&O.length&&h.merge(i,h.length,O[0],!1,o,0)?h.breakAfter=O.shift().breakAfter:(i2);var qi={mac:Vi||/Mac/.test(wi.platform),windows:/Win/.test(wi.platform),linux:/Linux|X11/.test(wi.platform),ie:vi,ie_version:Si?bi.documentMode||6:ki?+ki[1]:xi?+xi[1]:0,gecko:Ri,gecko_version:Ri?+(/Firefox\/(\d+)/.exec(wi.userAgent)||[0,0])[1]:0,chrome:!!Wi,chrome_version:Wi?+Wi[1]:0,ios:Vi,android:/Android\b/.test(wi.userAgent),webkit:Ti,safari:_i,webkit_version:Ti?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0,tabSize:null!=bi.documentElement.style.tabSize?"tab-size":"-moz-tab-size"};class Ai extends mi{constructor(e){super(),this.text=e}get length(){return this.text.length}createDOM(e){this.setDOM(e||document.createTextNode(this.text))}sync(e){this.dom||this.createDOM(),this.dom.nodeValue!=this.text&&(e&&e.node==this.dom&&(e.written=!0),this.dom.nodeValue=this.text)}reuseDOM(e){3==e.nodeType&&this.createDOM(e)}merge(e,t,i){return(!i||i instanceof Ai&&!(this.length-(t-e)+i.length>256))&&(this.text=this.text.slice(0,e)+(i?i.text:"")+this.text.slice(t),this.markDirty(),!0)}split(e){let t=new Ai(this.text.slice(e));return this.text=this.text.slice(0,e),this.markDirty(),t}localPosFromDOM(e,t){return e==this.dom?t:t?this.text.length:0}domAtPos(e){return new $i(this.dom,e)}domBoundsAround(e,t,i){return{from:i,to:i+this.length,startDOM:this.dom,endDOM:this.dom.nextSibling}}coordsAt(e,t){return Ni(this.dom,e,t)}}class Yi extends mi{constructor(e,t=[],i=0){super(),this.mark=e,this.children=t,this.length=i;for(let e of t)e.setParent(this)}setAttrs(e){if(pi(e),this.mark.class&&(e.className=this.mark.class),this.mark.attrs)for(let t in this.mark.attrs)e.setAttribute(t,this.mark.attrs[t]);return e}reuseDOM(e){e.nodeName==this.mark.tagName.toUpperCase()&&(this.setDOM(e),this.dirty|=6)}sync(e){this.dom?4&this.dirty&&this.setAttrs(this.dom):this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))),super.sync(e)}merge(e,t,i,n,r,O){return!(i&&(!(i instanceof Yi&&i.mark.eq(this.mark))||e&&r<=0||te&&t.push(i=e&&(n=r),i=s,r++}let O=this.length-e;return this.length=e,n>-1&&(this.children.length=n,this.markDirty()),new Yi(this.mark,t,O)}domAtPos(e){return Ii(this.dom,this.children,e)}coordsAt(e,t){return Ei(this,e,t)}}function Ni(e,t,i){let n=e.nodeValue.length;t>n&&(t=n);let r=t,O=t,s=0;0==t&&i<0||t==n&&i>=0?qi.chrome||qi.gecko||(t?(r--,s=1):(O++,s=-1)):i<0?r--:O++;let o=fi(e,r,O).getClientRects();if(!o.length)return si;let a=o[(s?s<0:i>=0)?0:o.length-1];return qi.safari&&!s&&0==a.width&&(a=Array.prototype.find.call(o,(e=>e.width))||a),s?oi(a,s<0):a||null}class Zi extends mi{constructor(e,t,i){super(),this.widget=e,this.length=t,this.side=i,this.prevWidget=null}static create(e,t,i){return new(e.customView||Zi)(e,t,i)}split(e){let t=Zi.create(this.widget,this.length-e,this.side);return this.length-=e,t}sync(){this.dom&&this.widget.updateDOM(this.dom)||(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(this.editorView)),this.dom.contentEditable="false")}getSide(){return this.side}merge(e,t,i,n,r,O){return!(i&&(!(i instanceof Zi&&this.widget.compare(i.widget))||e>0&&r<=0||t0?i.length-1:0;n=i[t],!(e>0?0==t:t==i.length-1||n.top0?-1:1);return 0==e&&t>0||e==this.length&&t<=0?n:oi(n,0==e)}get isEditable(){return!1}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}}class zi extends Zi{domAtPos(e){let{topView:t,text:i}=this.widget;return t?Ci(e,0,t,i,((e,t)=>e.domAtPos(t)),(e=>new $i(i,Math.min(e,i.nodeValue.length)))):new $i(i,Math.min(e,i.nodeValue.length))}sync(){this.setDOM(this.widget.toDOM())}localPosFromDOM(e,t){let{topView:i,text:n}=this.widget;return i?Ui(e,t,i,n):Math.min(t,this.length)}ignoreMutation(){return!1}get overrideDOMText(){return null}coordsAt(e,t){let{topView:i,text:n}=this.widget;return i?Ci(e,t,i,n,((e,t,i)=>e.coordsAt(t,i)),((e,t)=>Ni(n,e,t))):Ni(n,e,t)}destroy(){var e;super.destroy(),null===(e=this.widget.topView)||void 0===e||e.destroy()}get isEditable(){return!0}}function Ci(e,t,i,n,r,O){if(i instanceof Yi){for(let s of i.children){let i=Jt(s.dom,n),o=i?n.nodeValue.length:s.length;if(e=0;)if(t<0?n>0:n0?-1:1);return i&&i.topt.top?{left:t.left,right:t.right,top:i.top,bottom:i.bottom}:t}get overrideDOMText(){return m.empty}}function Ii(e,t,i){let n=0;for(let r=0;nr&&i0;n--){let i=t[n-1].dom;if(i.parentNode==e)return $i.after(i)}return new $i(e,0)}function ji(e,t,i){let n,{children:r}=e;i>0&&t instanceof Yi&&r.length&&(n=r[r.length-1])instanceof Yi&&n.mark.eq(t.mark)?ji(n,t.children[0],i-1):(r.push(t),t.setParent(e)),e.length+=t.length}function Ei(e,t,i){for(let n=0,r=0;r0?o>=t:o>t)&&(t0)){let e=0;if(o==n){if(s.getSide()<=0)continue;e=i=-s.getSide()}let r=s.coordsAt(Math.max(0,t-n),i);return e&&r?oi(r,i<0):r}n=o}let n=e.dom.lastChild;if(!n)return e.dom.getBoundingClientRect();let r=ti(n);return r[r.length-1]||null}function Di(e,t){for(let i in e)"class"==i&&t.class?t.class+=" "+e.class:"style"==i&&t.style?t.style+=";"+e.style:t[i]=e[i];return t}function Mi(e,t){if(e==t)return!0;if(!e||!t)return!1;let i=Object.keys(e),n=Object.keys(t);if(i.length!=n.length)return!1;for(let r of i)if(-1==n.indexOf(r)||e[r]!==t[r])return!1;return!0}function Li(e,t,i){if(t)for(let n in t)i&&n in i||e.removeAttribute(n);if(i)for(let n in i)t&&t[n]==i[n]||e.setAttribute(n,i[n])}Ai.prototype.children=Zi.prototype.children=Gi.prototype.children=Qi;class Bi{eq(e){return!1}updateDOM(e){return!1}compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}get estimatedHeight(){return-1}ignoreEvent(e){return!0}get customView(){return null}destroy(e){}}var Ki=function(e){return e[e.Text=0]="Text",e[e.WidgetBefore=1]="WidgetBefore",e[e.WidgetAfter=2]="WidgetAfter",e[e.WidgetRange=3]="WidgetRange",e}(Ki||(Ki={}));class Fi extends St{constructor(e,t,i,n){super(),this.startSide=e,this.endSide=t,this.widget=i,this.spec=n}get heightRelevant(){return!1}static mark(e){return new Hi(e)}static widget(e){let t=e.side||0,i=!!e.block;return t+=i?t>0?3e8:-4e8:t>0?1e8:-1e8,new en(e,t,t,i,e.widget||null,!1)}static replace(e){let t,i,n=!!e.block;if(e.isBlockGap)t=-5e8,i=4e8;else{let{start:r,end:O}=tn(e,n);t=(r?n?-3e8:-1:5e8)-1,i=1+(O?n?2e8:1:-6e8)}return new en(e,t,i,n,e.widget||null,!0)}static line(e){return new Ji(e)}static set(e,t=!1){return Wt.of(e,t)}hasHeight(){return!!this.widget&&this.widget.estimatedHeight>-1}}Fi.none=Wt.empty;class Hi extends Fi{constructor(e){let{start:t,end:i}=tn(e);super(t?-1:5e8,i?1:-6e8,null,e),this.tagName=e.tagName||"span",this.class=e.class||"",this.attrs=e.attributes||null}eq(e){return this==e||e instanceof Hi&&this.tagName==e.tagName&&this.class==e.class&&Mi(this.attrs,e.attrs)}range(e,t=e){if(e>=t)throw new RangeError("Mark decorations may not be empty");return super.range(e,t)}}Hi.prototype.point=!1;class Ji extends Fi{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof Ji&&Mi(this.spec.attributes,e.spec.attributes)}range(e,t=e){if(t!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,t)}}Ji.prototype.mapMode=R.TrackBefore,Ji.prototype.point=!0;class en extends Fi{constructor(e,t,i,n,r,O){super(t,i,r,e),this.block=n,this.isReplace=O,this.mapMode=n?t<=0?R.TrackBefore:R.TrackAfter:R.TrackDel}get type(){return this.startSide=5}eq(e){return e instanceof en&&function(e,t){return e==t||!!(e&&t&&e.compare(t))}(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&t!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,t)}}function tn(e,t=!1){let{inclusiveStart:i,inclusiveEnd:n}=e;return null==i&&(i=e.inclusive),null==n&&(n=e.inclusive),{start:null!=i?i:t,end:null!=n?n:t}}function nn(e,t,i,n=0){let r=i.length-1;r>=0&&i[r]+n>=e?i[r]=Math.max(i[r],t):i.push(e,t)}en.prototype.point=!0;class rn extends mi{constructor(){super(...arguments),this.children=[],this.length=0,this.prevAttrs=void 0,this.attrs=null,this.breakAfter=0}merge(e,t,i,n,r,O){if(i){if(!(i instanceof rn))return!1;this.dom||i.transferDOM(this)}return n&&this.setDeco(i?i.attrs:null),yi(this,e,t,i?i.children:[],r,O),!0}split(e){let t=new rn;if(t.breakAfter=this.breakAfter,0==this.length)return t;let{i:i,off:n}=this.childPos(e);n&&(t.append(this.children[i].split(n),0),this.children[i].merge(n,this.children[i].length,null,!1,0,0),i++);for(let e=i;e0&&0==this.children[i-1].length;)this.children[--i].destroy();return this.children.length=i,this.markDirty(),this.length=e,t}transferDOM(e){this.dom&&(e.setDOM(this.dom),e.prevAttrs=void 0===this.prevAttrs?this.attrs:this.prevAttrs,this.prevAttrs=void 0,this.dom=null)}setDeco(e){Mi(this.attrs,e)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=e)}append(e,t){ji(this,e,t)}addLineDeco(e){let t=e.spec.attributes,i=e.spec.class;t&&(this.attrs=Di(t,this.attrs||{})),i&&(this.attrs=Di({class:i},this.attrs||{}))}domAtPos(e){return Ii(this.dom,this.children,e)}reuseDOM(e){"DIV"==e.nodeName&&(this.setDOM(e),this.dirty|=6)}sync(e){var t;this.dom?4&this.dirty&&(pi(this.dom),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0):(this.setDOM(document.createElement("div")),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0),void 0!==this.prevAttrs&&(Li(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(e);let i=this.dom.lastChild;for(;i&&mi.get(i)instanceof Yi;)i=i.lastChild;if(!(i&&this.length&&("BR"==i.nodeName||0!=(null===(t=mi.get(i))||void 0===t?void 0:t.isEditable)||qi.ios&&this.children.some((e=>e instanceof Ai))))){let e=document.createElement("BR");e.cmIgnore=!0,this.dom.appendChild(e)}}measureTextSize(){if(0==this.children.length||this.length>20)return null;let e=0;for(let t of this.children){if(!(t instanceof Ai))return null;let i=ti(t.dom);if(1!=i.length)return null;e+=i[0].width}return{lineHeight:this.dom.getBoundingClientRect().height,charWidth:e/this.length}}coordsAt(e,t){return Ei(this,e,t)}become(e){return!1}get type(){return Ki.Text}static find(e,t){for(let i=0,n=0;i=t){if(r instanceof rn)return r;if(O>t)break}n=O+r.breakAfter}return null}}class On extends mi{constructor(e,t,i){super(),this.widget=e,this.length=t,this.type=i,this.breakAfter=0,this.prevWidget=null}merge(e,t,i,n,r,O){return!(i&&(!(i instanceof On&&this.widget.compare(i.widget))||e>0&&r<=0||t0;){if(this.textOff==this.text.length){let{value:t,lineBreak:i,done:n}=this.cursor.next(this.skip);if(this.skip=0,n)throw new Error("Ran out of text content when drawing inline views");if(i){this.posCovered()||this.getLine(),this.content.length?this.content[this.content.length-1].breakAfter=1:this.breakAtStart=1,this.flushBuffer([]),this.curLine=null,e--;continue}this.text=t,this.textOff=0}let n=Math.min(this.text.length-this.textOff,e,512);this.flushBuffer(t.slice(0,i)),this.getLine().append(on(new Ai(this.text.slice(this.textOff,this.textOff+n)),t),i),this.atCursorPos=!0,this.textOff+=n,e-=n,i=0}}span(e,t,i,n){this.buildText(t-e,i,n),this.pos=t,this.openStart<0&&(this.openStart=n)}point(e,t,i,n,r){let O=t-e;if(i instanceof en)if(i.block){let{type:e}=i;e!=Ki.WidgetAfter||this.posCovered()||this.getLine(),this.addBlockWidget(new On(i.widget||new an("div"),O,e))}else{let s=Zi.create(i.widget||new an("span"),O,i.startSide),o=this.atCursorPos&&!s.isEditable&&r<=n.length&&(e0),a=!s.isEditable&&(ethis.doc.lineAt(this.pos).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}return!0}static build(e,t,i,n,r){let O=new sn(e,t,i,r);return O.openEnd=Wt.spans(n,t,i,O),O.openStart<0&&(O.openStart=O.openEnd),O.finish(O.openEnd),O}}function on(e,t){for(let i of t)e=new Yi(i,[e],e.length);return e}class an extends Bi{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}}const ln=[],hn=I.define(),cn=I.define(),un=I.define(),fn=I.define(),dn=I.define(),pn=I.define(),$n=ge.define({map:(e,t)=>e.map(t)}),Qn=ge.define({map:(e,t)=>e.map(t)});class mn{constructor(e,t="nearest",i="nearest",n=5,r=5){this.range=e,this.y=t,this.x=i,this.yMargin=n,this.xMargin=r}map(e){return e.empty?this:new mn(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin)}}const gn=ge.define({map:(e,t)=>e.map(t)});function Pn(e,t,i){let n=e.facet(fn);n.length?n[0](t):window.onerror?window.onerror(String(t),i,void 0,void 0,t):i?console.error(i+":",t):console.error(t)}const Xn=I.define({combine:e=>!e.length||e[0]});class yn{constructor(e,t){this.field=e,this.get=t}}class wn{from(e){return new yn(this,e)}static define(){return new wn}}wn.decorations=wn.define(),wn.atomicRanges=wn.define(),wn.scrollMargins=wn.define();let bn=0;const xn=I.define();class Sn{constructor(e,t,i){this.id=e,this.create=t,this.fields=i,this.extension=xn.of(this)}static define(e,t){let{eventHandlers:i,provide:n,decorations:r}=t||{},O=[];if(n)for(let e of Array.isArray(n)?n:[n])O.push(e);return i&&O.push(kn.from((e=>({plugin:e,handlers:i})))),r&&O.push(wn.decorations.from(r)),new Sn(bn++,e,O)}static fromClass(e,t){return Sn.define((t=>new e(t)),t)}}const kn=wn.define();class vn{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}takeField(e,t){if(this.spec)for(let{field:i,get:n}of this.spec.fields)i==e&&t.push(n(this.value))}update(e){if(this.value){if(this.mustUpdate){let e=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(e)}catch(t){if(Pn(e.state,t,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch(e){}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.create(e)}catch(t){Pn(e.state,t,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var t;if(null===(t=this.value)||void 0===t?void 0:t.destroy)try{this.value.destroy()}catch(t){Pn(e.state,t,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const Rn=I.define(),Wn=I.define(),Tn=I.define(),_n=I.define();class Vn{constructor(e,t,i,n){this.fromA=e,this.toA=t,this.fromB=i,this.toB=n}join(e){return new Vn(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let t=e.length,i=this;for(;t>0;t--){let n=e[t-1];if(!(n.fromA>i.toA)){if(n.toAl)break;r+=2}if(!o)return i;new Vn(o.fromA,o.toA,o.fromB,o.toB).addToSet(i),O=o.toA,s=o.toB}}}class qn{constructor(e,t,i=ln){this.view=e,this.state=t,this.transactions=i,this.flags=0,this.startState=e.state,this.changes=T.empty(this.startState.doc.length);for(let e of i)this.changes=this.changes.compose(e.changes);let n=[];this.changes.iterChangedRanges(((e,t,i,r)=>n.push(new Vn(e,t,i,r)))),this.changedRanges=n;let r=e.hasFocus;r!=e.inputState.notifiedFocused&&(e.inputState.notifiedFocused=r,this.flags|=1)}get viewportChanged(){return(4&this.flags)>0}get heightChanged(){return(2&this.flags)>0}get geometryChanged(){return this.docChanged||(10&this.flags)>0}get focusChanged(){return(1&this.flags)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some((e=>e.selection))}get empty(){return 0==this.flags&&0==this.transactions.length}}var An=function(e){return e[e.LTR=0]="LTR",e[e.RTL=1]="RTL",e}(An||(An={}));const Yn=An.LTR,Nn=An.RTL;function Zn(e){let t=[];for(let i=0;i=t){if(s.level==i)return O;(r<0||(0!=n?n<0?s.fromt:e[r].level>s.level))&&(r=O)}}if(r<0)throw new RangeError("Index out of range");return r}}const Dn=[];function Mn(e){return[new En(0,e,0)]}let Ln="";function Bn(e,t,i,n,r){var O;let s=n.head-e.from,o=-1;if(0==s){if(!r||!e.length)return null;t[0].level!=i&&(s=t[0].side(!1,i),o=0)}else if(s==e.length){if(r)return null;let e=t[t.length-1];e.level!=i&&(s=e.side(!0,i),o=t.length-1)}o<0&&(o=En.find(t,s,null!==(O=n.bidiLevel)&&void 0!==O?O:-1,n.assoc));let l=t[o];s==l.side(r,i)&&(l=t[o+=r?1:-1],s=l.side(!r,i));let h=r==(l.dir==i),c=a(e.text,s,h);if(Ln=e.text.slice(Math.min(s,c),Math.max(s,c)),c!=l.side(r,i))return z.cursor(c+e.from,h?-1:1,l.level);let u=o==(r?t.length-1:0)?null:t[o+(r?1:-1)];return u||l.level==i?u&&u.level1)for(let t of this.points)t.node==e&&t.pos>this.text.length&&(t.pos-=s-1);i=O+s}}readNode(e){if(e.cmIgnore)return;let t=mi.get(e),i=t&&t.overrideDOMText;if(null!=i){this.findPointInside(e,i.length);for(let e=i.iter();!e.next().done;)e.lineBreak?this.lineBreak():this.append(e.value)}else 3==e.nodeType?this.readTextNode(e):"BR"==e.nodeName?e.nextSibling&&this.lineBreak():1==e.nodeType&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let i of this.points)i.node==e&&e.childNodes[i.offset]==t&&(i.pos=this.text.length)}findPointInside(e,t){for(let i of this.points)(3==e.nodeType?i.node==e:e.contains(i.node))&&(i.pos=this.text.length+Math.min(t,i.offset))}}function Fn(e){return 1==e.nodeType&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(e.nodeName)}class Hn{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}}class Jn extends mi{constructor(e){super(),this.view=e,this.compositionDeco=Fi.none,this.decorations=[],this.pluginDecorationLength=0,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.setDOM(e.contentDOM),this.children=[new rn],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new Vn(0,0,0,e.state.doc.length)],0)}get root(){return this.view.root}get editorView(){return this.view}get length(){return this.view.state.doc.length}update(e){let t=e.changedRanges;this.minWidth>0&&t.length&&(t.every((({fromA:e,toA:t})=>tthis.minWidthTo))?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.view.inputState.composing<0?this.compositionDeco=Fi.none:(e.transactions.length||this.dirty)&&(this.compositionDeco=function(e,t){let i=tr(e);if(!i)return Fi.none;let{from:n,to:r,node:O,text:s}=i,o=t.mapPos(n,1),a=Math.max(o,t.mapPos(r,-1)),{state:l}=e,h=3==O.nodeType?O.nodeValue:new Kn([],l).readRange(O.firstChild,null).text;if(a-o{this.dom.style.height=this.view.viewState.contentHeight+"px",this.dom.style.minWidth=this.minWidth?this.minWidth+"px":"";let e=qi.chrome||qi.ios?{node:i.selectionRange.focusNode,written:!1}:void 0;this.sync(e),this.dirty=0,e&&(e.written||i.selectionRange.focusNode!=e.node)&&(this.forceSelection=!0),this.dom.style.height=""}));let n=[];if(this.view.viewport.from||this.view.viewport.to=0?e[t]:null;if(!n)break;let{fromA:r,toA:O,fromB:s,toB:o}=n,{content:a,breakAtStart:l,openStart:h,openEnd:c}=sn.build(this.view.state.doc,s,o,this.decorations,this.pluginDecorationLength),{i:u,off:f}=i.findPos(O,1),{i:d,off:p}=i.findPos(r,-1);Xi(this,d,p,u,f,a,l,h,c)}}updateSelection(e=!1,t=!1){if(e&&this.view.observer.readSelectionRange(),!t&&!this.mayControlSelection()||qi.ios&&this.view.inputState.rapidCompositionStart)return;let i=this.forceSelection;this.forceSelection=!1;let n=this.view.state.selection.main,r=this.domAtPos(n.anchor),O=n.empty?r:this.domAtPos(n.head);if(qi.gecko&&n.empty&&function(e){return 1==e.node.nodeType&&e.node.firstChild&&(0==e.offset||"false"==e.node.childNodes[e.offset-1].contentEditable)&&(e.offset==e.node.childNodes.length||"false"==e.node.childNodes[e.offset].contentEditable)}(r)){let e=document.createTextNode("");this.view.observer.ignore((()=>r.node.insertBefore(e,r.node.childNodes[r.offset]||null))),r=O=new $i(e,0),i=!0}let s=this.view.observer.selectionRange;!i&&s.focusNode&&ii(r.node,r.offset,s.anchorNode,s.anchorOffset)&&ii(O.node,O.offset,s.focusNode,s.focusOffset)||(this.view.observer.ignore((()=>{qi.android&&qi.chrome&&this.dom.contains(s.focusNode)&&function(e,t){for(let i=e;i&&i!=t;i=i.assignedSlot||i.parentNode)if(1==i.nodeType&&"false"==i.contentEditable)return!0;return!1}(s.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let e=Ht(this.root);if(n.empty){if(qi.gecko){let e=function(e,t){return 1!=e.nodeType?0:(t&&"false"==e.childNodes[t-1].contentEditable?1:0)|(tn.head&&([r,O]=[O,r]),t.setEnd(O.node,O.offset),t.setStart(r.node,r.offset),e.removeAllRanges(),e.addRange(t)}})),this.view.observer.setSelectionRange(r,O)),this.impreciseAnchor=r.precise?null:new $i(s.anchorNode,s.anchorOffset),this.impreciseHead=O.precise?null:new $i(s.focusNode,s.focusOffset)}enforceCursorAssoc(){if(this.compositionDeco.size)return;let e=this.view.state.selection.main,t=Ht(this.root);if(!e.empty||!e.assoc||!t.modify)return;let i=rn.find(this,e.head);if(!i)return;let n=i.posAtStart;if(e.head==n||e.head==n+i.length)return;let r=this.coordsAt(e.head,-1),O=this.coordsAt(e.head,1);if(!r||!O||r.bottom>O.top)return;let s=this.domAtPos(e.head+e.assoc);t.collapse(s.node,s.offset),t.modify("move",e.assoc<0?"forward":"backward","lineboundary")}mayControlSelection(){return this.view.state.facet(Xn)?this.root.activeElement==this.dom:ei(this.dom,this.view.observer.selectionRange)}nearest(e){for(let t=e;t;){let e=mi.get(t);if(e&&e.rootView==this)return e;t=t.parentNode}return null}posFromDOM(e,t){let i=this.nearest(e);if(!i)throw new RangeError("Trying to find position for a DOM position outside of the document");return i.localPosFromDOM(e,t)+i.posAtStart}domAtPos(e){let{i:t,off:i}=this.childCursor().findPos(e,-1);for(;tO||e==O&&r.type!=Ki.WidgetBefore&&r.type!=Ki.WidgetAfter&&(!n||2==t||this.children[n-1].breakAfter||this.children[n-1].type==Ki.WidgetBefore&&t>-2))return r.coordsAt(e-O,t);i=O}}measureVisibleLineHeights(){let e=[],{from:t,to:i}=this.view.viewState.viewport,n=this.view.contentDOM.clientWidth,r=n>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,O=-1;for(let s=0,o=0;oi)break;if(s>=t){let t=a.dom.getBoundingClientRect();if(e.push(t.height),r){let e=a.dom.lastChild,i=e?ti(e):[];if(i.length){let e=i[i.length-1],r=this.view.textDirection==An.LTR?e.right-t.left:t.right-e.left;r>O&&(O=r,this.minWidth=n,this.minWidthFrom=s,this.minWidthTo=l)}}}s=l+a.breakAfter}return e}measureTextSize(){for(let e of this.children)if(e instanceof rn){let t=e.measureTextSize();if(t)return t}let e,t,i=document.createElement("div");return i.className="cm-line",i.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore((()=>{this.dom.appendChild(i);let n=ti(i.firstChild)[0];e=i.getBoundingClientRect().height,t=n?n.width/27:7,i.remove()})),{lineHeight:e,charWidth:t}}childCursor(e=this.length){let t=this.children.length;return t&&(e-=this.children[--t].length),new Pi(this.children,e,t)}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let i=0,n=0;;n++){let r=n==t.viewports.length?null:t.viewports[n],O=r?r.from-1:this.length;if(O>i){let n=t.lineBlockAt(O).bottom-t.lineBlockAt(i).top;e.push(Fi.replace({widget:new er(n),block:!0,inclusive:!0,isBlockGap:!0}).range(i,O))}if(!r)break;i=r.to+1}return Fi.set(e)}updateDeco(){let e=this.view.pluginField(wn.decorations);return this.pluginDecorationLength=e.length,this.decorations=[...e,...this.view.state.facet(Tn),this.compositionDeco,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco]}scrollIntoView(e){let t,{range:i}=e,n=this.coordsAt(i.head,i.empty?i.assoc:i.head>i.anchor?-1:1);if(!n)return;!i.empty&&(t=this.coordsAt(i.anchor,i.anchor>i.head?-1:1))&&(n={left:Math.min(n.left,t.left),top:Math.min(n.top,t.top),right:Math.max(n.right,t.right),bottom:Math.max(n.bottom,t.bottom)});let r=0,O=0,s=0,o=0;for(let e of this.view.pluginField(wn.scrollMargins))if(e){let{left:t,right:i,top:n,bottom:a}=e;null!=t&&(r=Math.max(r,t)),null!=i&&(O=Math.max(O,i)),null!=n&&(s=Math.max(s,n)),null!=a&&(o=Math.max(o,a))}let a={left:n.left-r,top:n.top-s,right:n.right+O,bottom:n.bottom+o};!function(e,t,i,n,r,O,s,o){let a=e.ownerDocument,l=a.defaultView;for(let h=e;h;)if(1==h.nodeType){let e,c=h==a.body;if(c)e=ai(l);else{if(h.scrollHeight<=h.clientHeight&&h.scrollWidth<=h.clientWidth){h=h.parentNode;continue}let t=h.getBoundingClientRect();e={left:t.left,right:t.left+h.clientWidth,top:t.top,bottom:t.top+h.clientHeight}}let u=0,f=0;if("nearest"==r)t.top0&&t.bottom>e.bottom+f&&(f=t.bottom-e.bottom+f+s)):t.bottom>e.bottom&&(f=t.bottom-e.bottom+s,i<0&&t.top-f0&&t.right>e.right+u&&(u=t.right-e.right+u+O)):t.right>e.right&&(u=t.right-e.right+O,i<0&&t.left0&&i<=0)t=Oi(e=e.childNodes[t-1]);else{if(!(1==e.nodeType&&t=0))return null;e=e.childNodes[t],t=0}}}class rr{constructor(){this.changes=[]}compareRange(e,t){nn(e,t,this.changes)}comparePoint(e,t){nn(e,t,this.changes)}}function Or(e,t){return t.left>e?t.left-e:Math.max(0,e-t.right)}function sr(e,t){return t.top>e?t.top-e:Math.max(0,e-t.bottom)}function or(e,t){return e.topt.top+1}function ar(e,t){return te.bottom?{top:e.top,left:e.left,right:e.right,bottom:t}:e}function hr(e,t,i){let n,r,O,s,o,a,l,h;for(let c=e.firstChild;c;c=c.nextSibling){let e=ti(c);for(let u=0;up||s==p&&O>d)&&(n=c,r=f,O=d,s=p),0==d?i>f.bottom&&(!l||l.bottomf.top)&&(a=c,h=f):l&&or(l,f)?l=lr(l,f.bottom):h&&or(h,f)&&(h=ar(h,f.top))}}if(l&&l.bottom>=i?(n=o,r=l):h&&h.top<=i&&(n=a,r=h),!n)return{node:e,offset:0};let c=Math.max(r.left,Math.min(r.right,t));return 3==n.nodeType?cr(n,c,i):O||"true"!=n.contentEditable?{node:e,offset:Array.prototype.indexOf.call(e.childNodes,n)+(t>=(r.left+r.right)/2?1:0)}:hr(n,c,i)}function cr(e,t,i){let n=e.nodeValue.length,r=-1,O=1e9,s=0;for(let o=0;oi?l.top-i:i-l.bottom)-1;if(l.left-1<=t&&l.right+1>=t&&h=(l.left+l.right)/2,n=i;if((qi.chrome||qi.gecko)&&fi(e,o).getBoundingClientRect().left==l.right&&(n=!i),h<=0)return{node:e,offset:o+(n?1:0)};r=o+(n?1:0),O=h}}}return{node:e,offset:r>-1?r:s>0?e.nodeValue.length:0}}function ur(e,{x:t,y:i},n,r=-1){var O;let s,o=e.contentDOM.getBoundingClientRect(),a=o.top+e.viewState.paddingTop,{docHeight:l}=e.viewState,h=i-a;if(h<0)return 0;if(h>l)return e.state.doc.length;for(let t=e.defaultLineHeight/2,i=!1;s=e.elementAtHeight(h),s.type!=Ki.Text;)for(;h=r>0?s.bottom+t:s.top-t,!(h>=0&&h<=l);){if(i)return n?null:0;i=!0,r=-r}i=a+h;let c=s.from;if(ce.viewport.to)return e.viewport.to==e.state.doc.length?e.state.doc.length:n?null:fr(e,o,s,t,i);let u=e.dom.ownerDocument,f=e.root.elementFromPoint?e.root:u,d=f.elementFromPoint(t,i);d&&!e.contentDOM.contains(d)&&(d=null),d||(t=Math.max(o.left+1,Math.min(o.right-1,t)),d=f.elementFromPoint(t,i),d&&!e.contentDOM.contains(d)&&(d=null));let p,$=-1;if(d&&0!=(null===(O=e.docView.nearest(d))||void 0===O?void 0:O.isEditable))if(u.caretPositionFromPoint){let e=u.caretPositionFromPoint(t,i);e&&({offsetNode:p,offset:$}=e)}else if(u.caretRangeFromPoint){let e=u.caretRangeFromPoint(t,i);e&&(({startContainer:p,startOffset:$}=e),qi.safari&&function(e,t,i){let n;if(3!=e.nodeType||t!=(n=e.nodeValue.length))return!1;for(let t=e.nextSibling;t;t=t.nextSibling)if(1!=t.nodeType||"BR"!=t.nodeName)return!1;return fi(e,n-1,n).getBoundingClientRect().left>i}(p,$,t)&&(p=void 0))}if(!p||!e.docView.dom.contains(p)){let n=rn.find(e.docView,c);if(!n)return h>s.top+s.height/2?s.to:s.from;({node:p,offset:$}=hr(n.dom,t,i))}return e.docView.posFromDOM(p,$)}function fr(e,t,i,n,r){let O=Math.round((n-t.left)*e.defaultCharacterWidth);e.lineWrapping&&i.height>1.5*e.defaultLineHeight&&(O+=Math.floor((r-i.top)/e.defaultLineHeight)*e.viewState.heightOracle.lineLength);let s=e.state.sliceDoc(i.from,i.to);return i.from+Q(s,O,e.state.tabSize)}function dr(e,t,i,n){let r=e.state.doc.lineAt(t.head),O=e.bidiSpans(r);for(let s=t,o=null;;){let t=Bn(r,O,e.textDirection,s,i),a=Ln;if(!t){if(r.number==(i?e.state.doc.lines:1))return s;a="\n",r=e.state.doc.line(r.number+(i?1:-1)),O=e.bidiSpans(r),t=z.cursor(i?r.from:r.to)}if(o){if(!o(a))return s}else{if(!n)return t;o=n(a)}s=t}}function pr(e,t,i){let n=e.pluginField(wn.atomicRanges);for(;;){let e=!1;for(let r of n)r.between(i.from-1,i.from+1,((n,r,O)=>{i.from>n&&i.fromi.from?z.cursor(n,1):z.cursor(r,-1),e=!0)}));if(!e)return i}}class $r{constructor(e){this.lastKeyCode=0,this.lastKeyTime=0,this.pendingIOSKey=void 0,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastEscPress=0,this.lastContextMenu=0,this.scrollHandlers=[],this.registeredEvents=[],this.customHandlers=[],this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.rapidCompositionStart=!1,this.mouseSelection=null;for(let t in Xr){let i=Xr[t];e.contentDOM.addEventListener(t,(n=>{Pr(e,n)&&!this.ignoreDuringComposition(n)&&("keydown"==t&&this.keydown(e,n)||(this.mustFlushObserver(n)&&e.observer.forceFlush(),this.runCustomHandlers(t,e,n)?n.preventDefault():i(e,n)))})),this.registeredEvents.push(t)}this.notifiedFocused=e.hasFocus,this.ensureHandlers(e),qi.safari&&e.contentDOM.addEventListener("input",(()=>null))}setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}ensureHandlers(e){let t=this.customHandlers=e.pluginField(kn);for(let i of t)for(let t in i.handlers)this.registeredEvents.indexOf(t)<0&&"scroll"!=t&&(this.registeredEvents.push(t),e.contentDOM.addEventListener(t,(i=>{Pr(e,i)&&this.runCustomHandlers(t,e,i)&&i.preventDefault()})))}runCustomHandlers(e,t,i){for(let n of this.customHandlers){let r=n.handlers[e];if(r)try{if(r.call(n.plugin,i,t)||i.defaultPrevented)return!0}catch(e){Pn(t.state,e)}}return!1}runScrollHandlers(e,t){for(let i of this.customHandlers){let n=i.handlers.scroll;if(n)try{n.call(i.plugin,t,e)}catch(t){Pn(e.state,t)}}}keydown(e,t){if(this.lastKeyCode=t.keyCode,this.lastKeyTime=Date.now(),9==t.keyCode&&Date.now()e.keyCode==t.keyCode)))||t.ctrlKey||t.altKey||t.metaKey||t.synthetic||(this.pendingIOSKey=i,setTimeout((()=>this.flushIOSKey(e)),250),0))}flushIOSKey(e){let t=this.pendingIOSKey;return!!t&&(this.pendingIOSKey=void 0,di(e.contentDOM,t.key,t.keyCode))}ignoreDuringComposition(e){return!!/^key/.test(e.type)&&(this.composing>0||!!(qi.safari&&Date.now()-this.compositionEndedAt<500)&&(this.compositionEndedAt=0,!0))}mustFlushObserver(e){return"keydown"==e.type&&229!=e.keyCode||"compositionend"==e.type&&!qi.ios}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.mouseSelection&&this.mouseSelection.update(e),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}const Qr=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],mr=[16,17,18,20,91,92,224,225];class gr{constructor(e,t,i,n){this.view=e,this.style=i,this.mustSelect=n,this.lastEvent=t;let r=e.contentDOM.ownerDocument;r.addEventListener("mousemove",this.move=this.move.bind(this)),r.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(Te.allowMultipleSelections)&&function(e,t){let i=e.state.facet(hn);return i.length?i[0](t):qi.mac?t.metaKey:t.ctrlKey}(e,t),this.dragMove=function(e,t){let i=e.state.facet(cn);return i.length?i[0](t):qi.mac?!t.altKey:!t.ctrlKey}(e,t),this.dragging=!(!function(e,t){let{main:i}=e.state.selection;if(i.empty)return!1;let n=Ht(e.root);if(0==n.rangeCount)return!0;let r=n.getRangeAt(0).getClientRects();for(let e=0;e=t.clientX&&i.top<=t.clientY&&i.bottom>=t.clientY)return!0}return!1}(e,t)||1!=qr(t))&&null,!1===this.dragging&&(t.preventDefault(),this.select(t))}move(e){if(0==e.buttons)return this.destroy();!1===this.dragging&&this.select(this.lastEvent=e)}up(e){null==this.dragging&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=null}select(e){let t=this.style.get(e,this.extend,this.multiple);!this.mustSelect&&t.eq(this.view.state.selection)&&t.main.assoc==this.view.state.selection.main.assoc||this.view.dispatch({selection:t,userEvent:"select.pointer",scrollIntoView:!0}),this.mustSelect=!1}update(e){e.docChanged&&this.dragging&&(this.dragging=this.dragging.map(e.changes)),this.style.update(e)&&setTimeout((()=>this.select(this.lastEvent)),20)}}function Pr(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let i,n=t.target;n!=e.contentDOM;n=n.parentNode)if(!n||11==n.nodeType||(i=mi.get(n))&&i.ignoreEvent(t))return!1;return!0}const Xr=Object.create(null),yr=qi.ie&&qi.ie_version<15||qi.ios&&qi.webkit_version<604;function wr(e,t){let i,{state:n}=e,r=1,O=n.toText(t),s=O.lines==n.selection.ranges.length;if(null!=Yr&&n.selection.ranges.every((e=>e.empty))&&Yr==O.toString()){let e=-1;i=n.changeByRange((i=>{let o=n.doc.lineAt(i.from);if(o.from==e)return{range:i};e=o.from;let a=n.toText((s?O.line(r++).text:t)+n.lineBreak);return{changes:{from:o.from,insert:a},range:z.cursor(i.from+a.length)}}))}else i=s?n.changeByRange((e=>{let t=O.line(r++);return{changes:{from:e.from,to:e.to,insert:t.text},range:z.cursor(e.from+t.length)}})):n.replaceSelection(O);e.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}Xr.keydown=(e,t)=>{e.inputState.setSelectionOrigin("select"),27==t.keyCode?e.inputState.lastEscPress=Date.now():mr.indexOf(t.keyCode)<0&&(e.inputState.lastEscPress=0)};let br=0;function xr(e,t,i,n){if(1==n)return z.cursor(t,i);if(2==n)return function(e,t,i=1){let n=e.charCategorizer(t),r=e.doc.lineAt(t),O=t-r.from;if(0==r.length)return z.cursor(t);0==O?i=1:O==r.length&&(i=-1);let s=O,o=O;i<0?s=a(r.text,O,!1):o=a(r.text,O);let l=n(r.text.slice(s,o));for(;s>0;){let e=a(r.text,s,!1);if(n(r.text.slice(e,s))!=l)break;s=e}for(;o{br=Date.now(),e.inputState.setSelectionOrigin("select.pointer")},Xr.touchmove=e=>{e.inputState.setSelectionOrigin("select.pointer")},Xr.mousedown=(e,t)=>{if(e.observer.flush(),br>Date.now()-2e3&&1==qr(t))return;let i=null;for(let n of e.state.facet(un))if(i=n(e,t),i)break;if(i||0!=t.button||(i=function(e,t){let i=Rr(e,t),n=qr(t),r=e.state.selection,O=i,s=t;return{update(e){e.docChanged&&(i&&(i.pos=e.changes.mapPos(i.pos)),r=r.map(e.changes),s=null)},get(t,o,a){let l;if(s&&t.clientX==s.clientX&&t.clientY==s.clientY?l=O:(l=O=Rr(e,t),s=t),!l||!i)return r;let h=xr(e,l.pos,l.bias,n);if(i.pos!=l.pos&&!o){let t=xr(e,i.pos,i.bias,n),r=Math.min(t.from,h.from),O=Math.max(t.to,h.to);h=rui(e.contentDOM))),e.inputState.startMouseSelection(new gr(e,t,i,n))}};let Sr=(e,t)=>e>=t.top&&e<=t.bottom,kr=(e,t,i)=>Sr(t,i)&&e>=i.left&&e<=i.right;function vr(e,t,i,n){let r=rn.find(e.docView,t);if(!r)return 1;let O=t-r.posAtStart;if(0==O)return 1;if(O==r.length)return-1;let s=r.coordsAt(O,-1);if(s&&kr(i,n,s))return-1;let o=r.coordsAt(O,1);return o&&kr(i,n,o)?1:s&&Sr(n,s)?-1:1}function Rr(e,t){let i=e.posAtCoords({x:t.clientX,y:t.clientY},!1);return{pos:i,bias:vr(e,i,t.clientX,t.clientY)}}const Wr=qi.ie&&qi.ie_version<=11;let Tr=null,_r=0,Vr=0;function qr(e){if(!Wr)return e.detail;let t=Tr,i=Vr;return Tr=e,Vr=Date.now(),_r=!t||i>Date.now()-400&&Math.abs(t.clientX-e.clientX)<2&&Math.abs(t.clientY-e.clientY)<2?(_r+1)%3:1}function Ar(e,t,i,n){if(!i)return;let r=e.posAtCoords({x:t.clientX,y:t.clientY},!1);t.preventDefault();let{mouseSelection:O}=e.inputState,s=n&&O&&O.dragging&&O.dragMove?{from:O.dragging.from,to:O.dragging.to}:null,o={from:r,insert:i},a=e.state.changes(s?[s,o]:o);e.focus(),e.dispatch({changes:a,selection:{anchor:a.mapPos(r,-1),head:a.mapPos(r,1)},userEvent:s?"move.drop":"input.drop"})}Xr.dragstart=(e,t)=>{let{selection:{main:i}}=e.state,{mouseSelection:n}=e.inputState;n&&(n.dragging=i),t.dataTransfer&&(t.dataTransfer.setData("Text",e.state.sliceDoc(i.from,i.to)),t.dataTransfer.effectAllowed="copyMove")},Xr.drop=(e,t)=>{if(!t.dataTransfer)return;if(e.state.readOnly)return t.preventDefault();let i=t.dataTransfer.files;if(i&&i.length){t.preventDefault();let n=Array(i.length),r=0,O=()=>{++r==i.length&&Ar(e,t,n.filter((e=>null!=e)).join(e.state.lineBreak),!1)};for(let e=0;e{/[\x00-\x08\x0e-\x1f]{2}/.test(t.result)||(n[e]=t.result),O()},t.readAsText(i[e])}}else Ar(e,t,t.dataTransfer.getData("Text"),!0)},Xr.paste=(e,t)=>{if(e.state.readOnly)return t.preventDefault();e.observer.flush();let i=yr?null:t.clipboardData;i?(wr(e,i.getData("text/plain")),t.preventDefault()):function(e){let t=e.dom.parentNode;if(!t)return;let i=t.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.focus(),setTimeout((()=>{e.focus(),i.remove(),wr(e,i.value)}),50)}(e)};let Yr=null;function Nr(e,t){if(e.docView.compositionDeco.size){e.inputState.rapidCompositionStart=t;try{e.update([])}finally{e.inputState.rapidCompositionStart=!1}}}Xr.copy=Xr.cut=(e,t)=>{let{text:i,ranges:n,linewise:r}=function(e){let t=[],i=[],n=!1;for(let n of e.selection.ranges)n.empty||(t.push(e.sliceDoc(n.from,n.to)),i.push(n));if(!t.length){let r=-1;for(let{from:n}of e.selection.ranges){let O=e.doc.lineAt(n);O.number>r&&(t.push(O.text),i.push({from:O.from,to:Math.min(e.doc.length,O.to+1)})),r=O.number}n=!0}return{text:t.join(e.lineBreak),ranges:i,linewise:n}}(e.state);if(!i&&!r)return;Yr=r?i:null;let O=yr?null:t.clipboardData;O?(t.preventDefault(),O.clearData(),O.setData("text/plain",i)):function(e,t){let i=e.dom.parentNode;if(!i)return;let n=i.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.value=t,n.focus(),n.selectionEnd=t.length,n.selectionStart=0,setTimeout((()=>{n.remove(),e.focus()}),50)}(e,i),"cut"!=t.type||e.state.readOnly||e.dispatch({changes:n,scrollIntoView:!0,userEvent:"delete.cut"})},Xr.focus=Xr.blur=e=>{setTimeout((()=>{e.hasFocus!=e.inputState.notifiedFocused&&e.update([])}),10)},Xr.compositionstart=Xr.compositionupdate=e=>{null==e.inputState.compositionFirstChange&&(e.inputState.compositionFirstChange=!0),e.inputState.composing<0&&(e.inputState.composing=0,e.docView.compositionDeco.size&&(e.observer.flush(),Nr(e,!0)))},Xr.compositionend=e=>{e.inputState.composing=-1,e.inputState.compositionEndedAt=Date.now(),e.inputState.compositionFirstChange=null,setTimeout((()=>{e.inputState.composing<0&&Nr(e,!1)}),50)},Xr.contextmenu=e=>{e.inputState.lastContextMenu=Date.now()},Xr.beforeinput=(e,t)=>{var i;let n;if(qi.chrome&&qi.android&&(n=Qr.find((e=>e.inputType==t.inputType)))&&(e.observer.delayAndroidKey(n.key,n.keyCode),"Backspace"==n.key||"Delete"==n.key)){let t=(null===(i=window.visualViewport)||void 0===i?void 0:i.height)||0;setTimeout((()=>{var i;((null===(i=window.visualViewport)||void 0===i?void 0:i.height)||0)>t+10&&e.hasFocus&&(e.contentDOM.blur(),e.focus())}),100)}};const Zr=["pre-wrap","normal","pre-line","break-spaces"];class zr{constructor(){this.doc=m.empty,this.lineWrapping=!1,this.direction=An.LTR,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.lineLength=30,this.heightChanged=!1}heightForGap(e,t){let i=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(i+=Math.ceil((t-e-i*this.lineLength*.5)/this.lineLength)),this.lineHeight*i}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/(this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForStyle(e,t){return Zr.indexOf(e)>-1!=this.lineWrapping||this.direction!=t}mustRefreshForHeights(e){let t=!1;for(let i=0;i-1,o=Math.round(i)!=Math.round(this.lineHeight)||this.lineWrapping!=s||this.direction!=t;if(this.lineWrapping=s,this.direction=t,this.lineHeight=i,this.charWidth=n,this.lineLength=r,o){this.heightSamples={};for(let e=0;et.moveY(e))):this.type):this}}var Gr=function(e){return e[e.ByPos=0]="ByPos",e[e.ByHeight=1]="ByHeight",e[e.ByPosNoHeight=2]="ByPosNoHeight",e}(Gr||(Gr={}));class Ir{constructor(e,t,i=2){this.length=e,this.height=t,this.flags=i}get outdated(){return(2&this.flags)>0}set outdated(e){this.flags=(e?2:0)|-3&this.flags}setHeight(e,t){this.height!=t&&(Math.abs(this.height-t)>.001&&(e.heightChanged=!0),this.height=t)}replace(e,t,i){return Ir.of(i)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,i,n){let r=this;for(let O=n.length-1;O>=0;O--){let{fromA:s,toA:o,fromB:a,toB:l}=n[O],h=r.lineAt(s,Gr.ByPosNoHeight,t,0,0),c=h.to>=o?h:r.lineAt(o,Gr.ByPosNoHeight,t,0,0);for(l+=c.to-o,o=c.to;O>0&&h.from<=n[O-1].toA;)s=n[O-1].fromA,a=n[O-1].fromB,O--,s2*r){let r=e[t-1];r.break?e.splice(--t,1,r.left,null,r.right):e.splice(--t,1,r.left,r.right),i+=1+r.break,n-=r.size}else{if(!(r>2*n))break;{let t=e[i];t.break?e.splice(i,1,t.left,null,t.right):e.splice(i,1,t.left,t.right),i+=2+t.break,r-=t.size}}else if(n0){let e=i[i.length-1];e instanceof Dr?i[i.length-1]=new Dr(e.length+n):i.push(null,new Dr(n-1))}if(e>0){let t=i[0];t instanceof Dr?i[0]=new Dr(e+t.length):i.unshift(new Dr(e-1),null)}return Ir.of(i)}decomposeLeft(e,t){t.push(new Dr(e-1),null)}decomposeRight(e,t){t.push(null,new Dr(this.length-e-1))}updateHeight(e,t=0,i=!1,n){let r=t+this.length;if(n&&n.from<=t+this.length&&n.more){let i=[],O=Math.max(t,n.from),s=-1,o=e.heightChanged;for(n.from>t&&i.push(new Dr(n.from-t-1).updateHeight(e,t));O<=r&&n.more;){let t=e.doc.lineAt(O).length;i.length&&i.push(null);let r=n.heights[n.index++];-1==s?s=r:Math.abs(r-s)>=.001&&(s=-2);let o=new Er(t,r);o.outdated=!1,i.push(o),O+=t+1}O<=r&&i.push(null,new Dr(r-O).updateHeight(e,O));let a=Ir.of(i);return e.heightChanged=o||s<0||Math.abs(a.height-this.height)>=.001||Math.abs(s-this.lines(e.doc,t).lineHeight)>=.001,a}return(i||this.outdated)&&(this.setHeight(e,e.heightForGap(t,t+this.length)),this.outdated=!1),this}toString(){return`gap(${this.length})`}}class Mr extends Ir{constructor(e,t,i){super(e.length+t+i.length,e.height+i.height,t|(e.outdated||i.outdated?2:0)),this.left=e,this.right=i,this.size=e.size+i.size}get break(){return 1&this.flags}blockAt(e,t,i,n){let r=i+this.left.height;return es))return a;let l=t==Gr.ByPosNoHeight?Gr.ByPosNoHeight:Gr.ByPos;return o?a.join(this.right.lineAt(s,l,i,O,s)):this.left.lineAt(s,l,i,n,r).join(a)}forEachLine(e,t,i,n,r,O){let s=n+this.left.height,o=r+this.left.length+this.break;if(this.break)e=o&&this.right.forEachLine(e,t,i,s,o,O);else{let a=this.lineAt(o,Gr.ByPos,i,n,r);e=e&&a.from<=t&&O(a),t>a.to&&this.right.forEachLine(a.to+1,t,i,s,o,O)}}replace(e,t,i){let n=this.left.length+this.break;if(tthis.left.length)return this.balanced(this.left,this.right.replace(e-n,t-n,i));let r=[];e>0&&this.decomposeLeft(e,r);let O=r.length;for(let e of i)r.push(e);if(e>0&&Lr(r,O-1),t=i&&t.push(null)),e>i&&this.right.decomposeLeft(e-i,t)}decomposeRight(e,t){let i=this.left.length,n=i+this.break;if(e>=n)return this.right.decomposeRight(e-n,t);e2*t.size||t.size>2*e.size?Ir.of(this.break?[e,null,t]:[e,t]):(this.left=e,this.right=t,this.height=e.height+t.height,this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,i=!1,n){let{left:r,right:O}=this,s=t+r.length+this.break,o=null;return n&&n.from<=t+r.length&&n.more?o=r=r.updateHeight(e,t,i,n):r.updateHeight(e,t,i),n&&n.from<=s+O.length&&n.more?o=O=O.updateHeight(e,s,i,n):O.updateHeight(e,s,i),o?this.balanced(r,O):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function Lr(e,t){let i,n;null==e[t]&&(i=e[t-1])instanceof Dr&&(n=e[t+1])instanceof Dr&&e.splice(t-1,3,new Dr(i.length+1+n.length))}class Br{constructor(e,t){this.pos=e,this.oracle=t,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,t){if(this.lineStart>-1){let e=Math.min(t,this.lineEnd),i=this.nodes[this.nodes.length-1];i instanceof Er?i.length+=e-this.pos:(e>this.pos||!this.isCovered)&&this.nodes.push(new Er(e-this.pos,-1)),this.writtenTo=e,t>e&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,i){if(e=5)&&this.addLineDeco(n,r)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenToe&&this.nodes.push(new Er(this.pos-e,-1)),this.writtenTo=this.pos}blankContent(e,t){let i=new Dr(t-e);return this.oracle.doc.lineAt(e).to==t&&(i.flags|=4),i}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof Er)return e;let t=new Er(0,-1);return this.nodes.push(t),t}addBlock(e){this.enterLine(),e.type!=Ki.WidgetAfter||this.isCovered||this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,e.type!=Ki.WidgetBefore&&(this.covering=e)}addLineDeco(e,t){let i=this.ensureLine();i.length+=t,i.collapsed+=t,i.widgetHeight=Math.max(i.widgetHeight,e),this.writtenTo=this.pos=this.pos+t}finish(e){let t=0==this.nodes.length?null:this.nodes[this.nodes.length-1];!(this.lineStart>-1)||t instanceof Er||this.isCovered?(this.writtenToe.clientHeight||e.scrollWidth>e.clientWidth)&&"visible"!=i.overflow){let t=e.getBoundingClientRect();n=Math.max(n,t.left),r=Math.min(r,t.right),O=Math.max(O,t.top),s=Math.min(s,t.bottom)}t="absolute"==i.position||"fixed"==i.position?e.offsetParent:e.parentNode}else{if(11!=t.nodeType)break;t=t.host}return{left:n-i.left,right:Math.max(n,r)-i.left,top:O-(i.top+t),bottom:Math.max(O,s)-(i.top+t)}}function Hr(e,t){let i=e.getBoundingClientRect();return{left:0,right:i.right-i.left,top:t,bottom:i.bottom-(i.top+t)}}class Jr{constructor(e,t,i){this.from=e,this.to=t,this.size=i}static same(e,t){if(e.length!=t.length)return!1;for(let i=0;ie.draw(!1)))),this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let i=0;i<=1;i++){let n=i?t.head:t.anchor;if(!e.some((({from:e,to:t})=>n>=e&&n<=t))){let{from:t,to:i}=this.lineBlockAt(n);e.push(new iO(t,i))}}this.viewports=e.sort(((e,t)=>e.from-t.from)),this.scaler=this.heightMap.height<=7e6?aO:new lO(this.heightOracle.doc,this.heightMap,this.viewports)}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.state.doc,0,0,(e=>{this.viewportLines.push(1==this.scaler.scale?e:hO(e,this.scaler))}))}update(e,t=null){let i=this.state;this.state=e.state;let n=this.state.facet(Tn),r=e.changedRanges,O=Vn.extendWithRanges(r,function(e,t,i){let n=new Kr;return Wt.compare(e,t,i,n,0),n.changes}(e.startState.facet(Tn),n,e?e.changes:T.empty(this.state.doc.length))),s=this.heightMap.height;this.heightMap=this.heightMap.applyChanges(n,i.doc,this.heightOracle.setDoc(this.state.doc),O),this.heightMap.height!=s&&(e.flags|=2);let o=O.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.heado.to)||!this.viewportIsAppropriate(o))&&(o=this.getViewport(0,t));let a=!e.changes.empty||2&e.flags||o.from!=this.viewport.from||o.to!=this.viewport.to;this.viewport=o,this.updateForViewport(),a&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&e.selectionSet&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&(this.mustEnforceCursorAssoc=!0)}measure(e){let t=e.contentDOM,i=window.getComputedStyle(t),n=this.heightOracle,r=i.whiteSpace,O="rtl"==i.direction?An.RTL:An.LTR,s=this.heightOracle.mustRefreshForStyle(r,O),o=s||this.mustMeasureContent||this.contentDOMHeight!=t.clientHeight,a=0,l=0;if(this.editorWidth!=e.scrollDOM.clientWidth&&(n.lineWrapping&&(o=!0),this.editorWidth=e.scrollDOM.clientWidth,a|=8),o){this.mustMeasureContent=!1,this.contentDOMHeight=t.clientHeight;let e=parseInt(i.paddingTop)||0,n=parseInt(i.paddingBottom)||0;this.paddingTop==e&&this.paddingBottom==n||(a|=8,this.paddingTop=e,this.paddingBottom=n)}let h=(this.printing?Hr:Fr)(t,this.paddingTop),c=h.top-this.pixelViewport.top,u=h.bottom-this.pixelViewport.bottom;this.pixelViewport=h;let f=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(f!=this.inView&&(this.inView=f,f&&(o=!0)),!this.inView)return 0;let d=t.clientWidth;if(this.contentDOMWidth==d&&this.editorHeight==e.scrollDOM.clientHeight||(this.contentDOMWidth=d,this.editorHeight=e.scrollDOM.clientHeight,a|=8),o){let t=e.docView.measureVisibleLineHeights();if(n.mustRefreshForHeights(t)&&(s=!0),s||n.lineWrapping&&Math.abs(d-this.contentDOMWidth)>n.charWidth){let{lineHeight:i,charWidth:o}=e.docView.measureTextSize();s=n.refresh(r,O,i,o,d/o,t),s&&(e.docView.minWidth=0,a|=8)}c>0&&u>0?l=Math.max(c,u):c<0&&u<0&&(l=Math.min(c,u)),n.heightChanged=!1,this.heightMap=this.heightMap.updateHeight(n,0,s,new Cr(this.viewport.from,t)),n.heightChanged&&(a|=2)}let p=!this.viewportIsAppropriate(this.viewport,l)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return p&&(this.viewport=this.getViewport(l,this.scrollTarget)),this.updateForViewport(),(2&a||p)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(s?[]:this.lineGaps)),a|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),a}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let i=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),n=this.heightMap,r=this.state.doc,{visibleTop:O,visibleBottom:s}=this,o=new iO(n.lineAt(O-1e3*i,Gr.ByHeight,r,0,0).from,n.lineAt(s+1e3*(1-i),Gr.ByHeight,r,0,0).to);if(t){let{head:e}=t.range;if(eo.to){let i,O=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),s=n.lineAt(e,Gr.ByPos,r,0,0);i="center"==t.y?(s.top+s.bottom)/2-O/2:"start"==t.y||"nearest"==t.y&&e=s+Math.max(10,Math.min(i,250)))&&n>O-2e3&&ri.from&&s.push({from:i.from,to:n}),r=i.from&&o.from<=i.to&&sO(s,o.from-10,o.from+10),!o.empty&&o.to>=i.from&&o.to<=i.to&&sO(s,o.to-10,o.to+10);for(let{from:n,to:r}of s)r-n>1e3&&t.push(oO(e,(e=>e.from>=i.from&&e.to<=i.to&&Math.abs(e.from-n)<1e3&&Math.abs(e.to-r)<1e3))||new Jr(n,r,this.gapSize(i,n,r,O)))}return t}gapSize(e,t,i,n){let r=OO(n,i)-OO(n,t);return this.heightOracle.lineWrapping?e.height*r:n.total*this.heightOracle.charWidth*r}updateLineGaps(e){Jr.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=Fi.set(e.map((e=>e.draw(this.heightOracle.lineWrapping)))))}computeVisibleRanges(){let e=this.state.facet(Tn);this.lineGaps.length&&(e=e.concat(this.lineGapDeco));let t=[];Wt.spans(e,this.viewport.from,this.viewport.to,{span(e,i){t.push({from:e,to:i})},point(){}},20);let i=t.length!=this.visibleRanges.length||this.visibleRanges.some(((e,i)=>e.from!=t[i].from||e.to!=t[i].to));return this.visibleRanges=t,i?4:0}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find((t=>t.from<=e&&t.to>=e))||hO(this.heightMap.lineAt(e,Gr.ByPos,this.state.doc,0,0),this.scaler)}lineBlockAtHeight(e){return hO(this.heightMap.lineAt(this.scaler.fromDOM(e),Gr.ByHeight,this.state.doc,0,0),this.scaler)}elementAtHeight(e){return hO(this.heightMap.blockAt(this.scaler.fromDOM(e),this.state.doc,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class iO{constructor(e,t){this.from=e,this.to=t}}function nO(e,t,i){let n=[],r=e,O=0;return Wt.spans(i.facet(Tn),e,t,{span(){},point(e,t){e>r&&(n.push({from:r,to:e}),O+=e-r),r=t}},20),r=1)return t[t.length-1].to;let n=Math.floor(e*i);for(let e=0;;e++){let{from:i,to:r}=t[e],O=r-i;if(n<=O)return i+n;n-=O}}function OO(e,t){let i=0;for(let{from:n,to:r}of e.ranges){if(t<=r){i+=t-n;break}i+=r-n}return i/e.total}function sO(e,t,i){for(let n=0;nt){let O=[];r.fromi&&O.push({from:i,to:r.to}),e.splice(n,1,...O),n+=O.length-1}}}function oO(e,t){for(let i of e)if(t(i))return i}const aO={toDOM:e=>e,fromDOM:e=>e,scale:1};class lO{constructor(e,t,i){let n=0,r=0,O=0;this.viewports=i.map((({from:i,to:r})=>{let O=t.lineAt(i,Gr.ByPos,e,0,0).top,s=t.lineAt(r,Gr.ByPos,e,0,0).bottom;return n+=s-O,{from:i,to:r,top:O,bottom:s,domTop:0,domBottom:0}})),this.scale=(7e6-n)/(t.height-n);for(let e of this.viewports)e.domTop=O+(e.top-r)*this.scale,O=e.domBottom=e.domTop+(e.bottom-e.top),r=e.bottom}toDOM(e){for(let t=0,i=0,n=0;;t++){let r=thO(e,t))):e.type)}const cO=I.define({combine:e=>e.join(" ")}),uO=I.define({combine:e=>e.indexOf(!0)>-1}),fO=wt.newName(),dO=wt.newName(),pO=wt.newName(),$O={"&light":"."+dO,"&dark":"."+pO};function QO(e,t,i){return new wt(t,{finish:t=>/&/.test(t)?t.replace(/&\w*/,(t=>{if("&"==t)return e;if(!i||!i[t])throw new RangeError(`Unsupported selector: ${t}`);return i[t]})):e+" "+t})}const mO=QO("."+fO,{"&.cm-editor":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0},".cm-content":{margin:0,flexGrow:2,minHeight:"100%",display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere"},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 4px"},".cm-selectionLayer":{zIndex:-1,contain:"size style"},".cm-selectionBackground":{position:"absolute"},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{zIndex:100,contain:"size style",pointerEvents:"none"},"&.cm-focused .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{visibility:"hidden"},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{visibility:"hidden"},"100%":{}},".cm-cursor, .cm-dropCursor":{position:"absolute",borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#444"},"&.cm-focused .cm-cursor":{display:"block"},"&light .cm-activeLine":{backgroundColor:"#f3f9ff"},"&dark .cm-activeLine":{backgroundColor:"#223039"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},$O),gO={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},PO=qi.ie&&qi.ie_version<=11;class XO{constructor(e,t,i){this.view=e,this.onChange=t,this.onScrollChanged=i,this.active=!1,this.selectionRange=new li,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.scrollTargets=[],this.intersection=null,this.resize=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver((t=>{for(let e of t)this.queue.push(e);(qi.ie&&qi.ie_version<=11||qi.ios&&e.composing)&&t.some((e=>"childList"==e.type&&e.removedNodes.length||"characterData"==e.type&&e.oldValue.length>e.target.nodeValue.length))?this.flushSoon():this.flush()})),PO&&(this.onCharData=e=>{this.queue.push({target:e.target,type:"characterData",oldValue:e.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),window.addEventListener("resize",this.onResize=this.onResize.bind(this)),"function"==typeof ResizeObserver&&(this.resize=new ResizeObserver((()=>{this.view.docView.lastUpdate{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),e.length>0&&e[e.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))}),{}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver((e=>{e.length>0&&e[e.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))}),{})),this.listenForScroll(),this.readSelectionRange(),this.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}onScroll(e){this.intersecting&&this.flush(!1),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout((()=>{this.resizeTimeout=-1,this.view.requestMeasure()}),50))}onPrint(){this.view.viewState.printing=!0,this.view.measure(),setTimeout((()=>{this.view.viewState.printing=!1,this.view.requestMeasure()}),500)}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some(((t,i)=>t!=e[i])))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:t}=this,i=this.selectionRange;if(t.state.facet(Xn)?t.root.activeElement!=this.dom:!ei(t.dom,i))return;let n=i.anchorNode&&t.docView.nearest(i.anchorNode);n&&n.ignoreEvent(e)||((qi.ie&&qi.ie_version<=11||qi.android&&qi.chrome)&&!t.state.selection.main.empty&&i.focusNode&&ii(i.focusNode,i.focusOffset,i.anchorNode,i.anchorOffset)?this.flushSoon():this.flush(!1))}readSelectionRange(){let{root:e}=this.view,t=Ht(e),i=qi.safari&&11==e.nodeType&&function(){let e=document.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}()==this.view.contentDOM&&function(e){let t=null;function i(e){e.preventDefault(),e.stopImmediatePropagation(),t=e.getTargetRanges()[0]}if(e.contentDOM.addEventListener("beforeinput",i,!0),document.execCommand("indent"),e.contentDOM.removeEventListener("beforeinput",i,!0),!t)return null;let n=t.startContainer,r=t.startOffset,O=t.endContainer,s=t.endOffset,o=e.docView.domAtPos(e.state.selection.main.anchor);return ii(o.node,o.offset,O,s)&&([n,r,O,s]=[O,s,n,r]),{anchorNode:n,anchorOffset:r,focusNode:O,focusOffset:s}}(this.view)||t;return!this.selectionRange.eq(i)&&(this.selectionRange.setRange(i),this.selectionChanged=!0)}setSelectionRange(e,t){this.selectionRange.set(e.node,e.offset,t.node,t.offset),this.selectionChanged=!1}listenForScroll(){this.parentCheck=-1;let e=0,t=null;for(let i=this.dom;i;)if(1==i.nodeType)!t&&e{let e=this.delayedAndroidKey;this.delayedAndroidKey=null;let t=this.view.state;di(this.view.contentDOM,e.key,e.keyCode)?this.processRecords():this.flush(),this.view.state==t&&this.view.update([])})),this.delayedAndroidKey&&"Enter"!=e||(this.delayedAndroidKey={key:e,keyCode:t})}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=window.setTimeout((()=>{this.delayedFlush=-1,this.flush()}),20))}forceFlush(){this.delayedFlush>=0&&(window.clearTimeout(this.delayedFlush),this.delayedFlush=-1,this.flush())}processRecords(){let e=this.queue;for(let t of this.observer.takeRecords())e.push(t);e.length&&(this.queue=[]);let t=-1,i=-1,n=!1;for(let r of e){let e=this.readMutation(r);e&&(e.typeOver&&(n=!0),-1==t?({from:t,to:i}=e):(t=Math.min(e.from,t),i=Math.max(e.to,i)))}return{from:t,to:i,typeOver:n}}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return;e&&this.readSelectionRange();let{from:t,to:i,typeOver:n}=this.processRecords(),r=this.selectionChanged&&ei(this.dom,this.selectionRange);if(t<0&&!r)return;this.selectionChanged=!1;let O=this.view.state;this.onChange(t,i,n),this.view.state==O&&this.view.update([])}readMutation(e){let t=this.view.docView.nearest(e.target);if(!t||t.ignoreMutation(e))return null;if(t.markDirty("attributes"==e.type),"attributes"==e.type&&(t.dirty|=4),"childList"==e.type){let i=yO(t,e.previousSibling||e.target.previousSibling,-1),n=yO(t,e.nextSibling||e.target.nextSibling,1);return{from:i?t.posAfter(i):t.posAtStart,to:n?t.posBefore(n):t.posAtEnd,typeOver:!1}}return"characterData"==e.type?{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}destroy(){var e,t,i;this.stop(),null===(e=this.intersection)||void 0===e||e.disconnect(),null===(t=this.gapIntersection)||void 0===t||t.disconnect(),null===(i=this.resize)||void 0===i||i.disconnect();for(let e of this.scrollTargets)e.removeEventListener("scroll",this.onScroll);window.removeEventListener("scroll",this.onScroll),window.removeEventListener("resize",this.onResize),window.removeEventListener("beforeprint",this.onPrint),this.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout)}}function yO(e,t,i){for(;t;){let n=mi.get(t);if(n&&n.parent==e)return n;let r=t.parentNode;t=r!=e.dom?r:i>0?t.nextSibling:t.previousSibling}return null}function wO(e,t,i,n){let r,O,s=e.state.selection.main;if(t>-1){let n=e.docView.domBoundsAround(t,i,0);if(!n||e.state.readOnly)return;let{from:o,to:a}=n,l=e.docView.impreciseHead||e.docView.impreciseAnchor?[]:function(e){let t=[];if(e.root.activeElement!=e.contentDOM)return t;let{anchorNode:i,anchorOffset:n,focusNode:r,focusOffset:O}=e.observer.selectionRange;return i&&(t.push(new Hn(i,n)),r==i&&O==n||t.push(new Hn(r,O))),t}(e),h=new Kn(l,e.state);h.readRange(n.startDOM,n.endDOM);let c=s.from,u=null;(8===e.inputState.lastKeyCode&&e.inputState.lastKeyTime>Date.now()-100||qi.android&&h.text.length0&&o>0&&e.charCodeAt(s-1)==t.charCodeAt(o-1);)s--,o--;"end"==n&&(i-=s+Math.max(0,O-Math.min(s,o))-O);s=s?O-i:0,o=O+(o-s),s=O):o=o?O-i:0,s=O+(s-o),o=O);return{from:O,toA:s,toB:o}}(e.state.doc.sliceString(o,a,""),h.text,c-o,u);f&&(qi.chrome&&13==e.inputState.lastKeyCode&&f.toB==f.from+2&&""==h.text.slice(f.from,f.toB)&&f.toB--,r={from:o+f.from,to:o+f.toA,insert:m.of(h.text.slice(f.from,f.toB).split(""))}),O=function(e,t){if(0==e.length)return null;let i=e[0].pos,n=2==e.length?e[1].pos:i;return i>-1&&n>-1?z.single(i+t,n+t):null}(l,o)}else if(e.hasFocus||!e.state.facet(Xn)){let t=e.observer.selectionRange,{impreciseHead:i,impreciseAnchor:n}=e.docView,r=i&&i.node==t.focusNode&&i.offset==t.focusOffset||!Jt(e.contentDOM,t.focusNode)?e.state.selection.main.head:e.docView.posFromDOM(t.focusNode,t.focusOffset),o=n&&n.node==t.anchorNode&&n.offset==t.anchorOffset||!Jt(e.contentDOM,t.anchorNode)?e.state.selection.main.anchor:e.docView.posFromDOM(t.anchorNode,t.anchorOffset);r==s.head&&o==s.anchor||(O=z.single(o,r))}if(r||O)if(!r&&n&&!s.empty&&O&&O.main.empty?r={from:s.from,to:s.to,insert:e.state.doc.slice(s.from,s.to)}:r&&r.from>=s.from&&r.to<=s.to&&(r.from!=s.from||r.to!=s.to)&&s.to-s.from-(r.to-r.from)<=4&&(r={from:s.from,to:s.to,insert:e.state.doc.slice(s.from,r.from).append(r.insert).append(e.state.doc.slice(r.to,s.to))}),r){let t=e.state;if(qi.ios&&e.inputState.flushIOSKey(e))return;if(qi.android&&(r.from==s.from&&r.to==s.to&&1==r.insert.length&&2==r.insert.lines&&di(e.contentDOM,"Enter",13)||r.from==s.from-1&&r.to==s.to&&0==r.insert.length&&di(e.contentDOM,"Backspace",8)||r.from==s.from&&r.to==s.to+1&&0==r.insert.length&&di(e.contentDOM,"Delete",46)))return;let i,n=r.insert.toString();if(e.state.facet(pn).some((t=>t(e,r.from,r.to,n))))return;if(e.inputState.composing>=0&&e.inputState.composing++,r.from>=s.from&&r.to<=s.to&&r.to-r.from>=(s.to-s.from)/3&&(!O||O.main.empty&&O.main.from==r.from+r.insert.length)&&e.inputState.composing<0){let n=s.fromr.to?t.sliceDoc(r.to,s.to):"";i=t.replaceSelection(e.state.toText(n+r.insert.sliceString(0,void 0,e.state.lineBreak)+O))}else{let n=t.changes(r),o=O&&!t.selection.main.eq(O.main)&&O.main.to<=n.newLength?O.main:void 0;if(t.selection.ranges.length>1&&e.inputState.composing>=0&&r.to<=s.to&&r.to>=s.to-10){let O=e.state.sliceDoc(r.from,r.to),a=tr(e)||e.state.doc.lineAt(s.head),l=s.to-r.to,h=s.to-s.from;i=t.changeByRange((i=>{if(i.from==s.from&&i.to==s.to)return{changes:n,range:o||i.map(n)};let c=i.to-l,u=c-O.length;if(i.to-i.from!=h||e.state.sliceDoc(u,c)!=O||a&&i.to>=a.from&&i.from<=a.to)return{range:i};let f=t.changes({from:u,to:c,insert:r.insert}),d=i.to-s.to;return{changes:f,range:o?z.range(Math.max(0,o.anchor+d),Math.max(0,o.head+d)):i.map(f)}}))}else i={changes:n,selection:o&&t.selection.replaceRange(o)}}let o="input.type";e.composing&&(o+=".compose",e.inputState.compositionFirstChange&&(o+=".start",e.inputState.compositionFirstChange=!1)),e.dispatch(i,{scrollIntoView:!0,userEvent:o})}else if(O&&!O.main.eq(s)){let t=!1,i="select";e.inputState.lastSelectionTime>Date.now()-50&&("select"==e.inputState.lastSelectionOrigin&&(t=!0),i=e.inputState.lastSelectionOrigin),e.dispatch({selection:O,scrollIntoView:t,userEvent:i})}}class bO{constructor(e={}){this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.style.cssText="position: absolute; top: -10000px",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),this._dispatch=e.dispatch||(e=>this.update([e])),this.dispatch=this.dispatch.bind(this),this.root=e.root||function(e){for(;e;){if(e&&(9==e.nodeType||11==e.nodeType&&e.host))return e;e=e.assignedSlot||e.parentNode}return null}(e.parent)||document,this.viewState=new tO(e.state||Te.create()),this.plugins=this.state.facet(xn).map((e=>new vn(e)));for(let e of this.plugins)e.update(this);this.observer=new XO(this,((e,t,i)=>{wO(this,e,t,i)}),(e=>{this.inputState.runScrollHandlers(this,e),this.observer.intersecting&&this.measure()})),this.inputState=new $r(this),this.docView=new Jn(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),e.parent&&e.parent.appendChild(this.dom)}get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return this.inputState.composing>0}get compositionStarted(){return this.inputState.composing>=0}dispatch(...e){this._dispatch(1==e.length&&e[0]instanceof Pe?e[0]:this.state.update(...e))}update(e){if(0!=this.updateState)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let t,i=!1,n=this.state;for(let t of e){if(t.startState!=n)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");n=t.state}if(this.destroyed)return void(this.viewState.state=n);if(n.facet(Te.phrases)!=this.state.facet(Te.phrases))return this.setState(n);t=new qn(this,n,e);let r=this.viewState.scrollTarget;try{this.updateState=2;for(let t of e){if(r&&(r=r.map(t.changes)),t.scrollIntoView){let{main:e}=t.state.selection;r=new mn(e.empty?e:z.cursor(e.head,e.head>e.anchor?-1:1))}for(let e of t.effects)e.is($n)?r=new mn(e.value):e.is(Qn)?r=new mn(e.value,"center"):e.is(gn)&&(r=e.value)}this.viewState.update(t,r),this.bidiCache=vO.update(this.bidiCache,t.changes),t.empty||(this.updatePlugins(t),this.inputState.update(t)),i=this.docView.update(t),this.state.facet(_n)!=this.styleModules&&this.mountStyles(),this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(i,e.some((e=>e.isUserEvent("select.pointer"))))}finally{this.updateState=0}if(t.startState.facet(cO)!=t.state.facet(cO)&&(this.viewState.mustMeasureContent=!0),(i||r||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),!t.empty)for(let e of this.state.facet(dn))e(t)}setState(e){if(0!=this.updateState)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed)return void(this.viewState.state=e);this.updateState=2;let t=this.hasFocus;try{for(let e of this.plugins)e.destroy(this);this.viewState=new tO(e),this.plugins=e.facet(xn).map((e=>new vn(e))),this.pluginMap.clear();for(let e of this.plugins)e.update(this);this.docView=new Jn(this),this.inputState.ensureHandlers(this),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(xn),i=e.state.facet(xn);if(t!=i){let n=[];for(let r of i){let i=t.indexOf(r);if(i<0)n.push(new vn(r));else{let t=this.plugins[i];t.mustUpdate=e,n.push(t)}}for(let t of this.plugins)t.mustUpdate!=e&&t.destroy(this);this.plugins=n,this.pluginMap.clear(),this.inputState.ensureHandlers(this)}else for(let t of this.plugins)t.mustUpdate=e;for(let e=0;e-1&&cancelAnimationFrame(this.measureScheduled),this.measureScheduled=0,e&&this.observer.flush();let t=null;try{for(let e=0;;e++){this.updateState=1;let i=this.viewport,n=this.viewState.measure(this);if(!n&&!this.measureRequests.length&&null==this.viewState.scrollTarget)break;if(e>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let r=[];4&n||([this.measureRequests,r]=[r,this.measureRequests]);let O=r.map((e=>{try{return e.read(this)}catch(e){return Pn(this.state,e),kO}})),s=new qn(this,this.state),o=!1,a=!1;s.flags|=n,t?t.flags|=n:t=s,this.updateState=2,s.empty||(this.updatePlugins(s),this.inputState.update(s),this.updateAttrs(),o=this.docView.update(s));for(let e=0;e{Li(this.contentDOM,this.contentAttrs,t),Li(this.dom,this.editorAttrs,e)})),this.editorAttrs=e,this.contentAttrs=t}showAnnouncements(e){let t=!0;for(let i of e)for(let e of i.effects)e.is(bO.announce)&&(t&&(this.announceDOM.textContent=""),t=!1,this.announceDOM.appendChild(document.createElement("div")).textContent=e.value)}mountStyles(){this.styleModules=this.state.facet(_n),wt.mount(this.root,this.styleModules.concat(mO).reverse())}readMeasured(){if(2==this.updateState)throw new Error("Reading the editor layout isn't allowed during an update");0==this.updateState&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=requestAnimationFrame((()=>this.measure()))),e){if(null!=e.key)for(let t=0;tt.spec==e))||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}blockAtHeight(e,t){let i=SO(t,this);return this.elementAtHeight(e-i).moveY(i)}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}visualLineAtHeight(e,t){let i=SO(t,this);return this.lineBlockAtHeight(e-i).moveY(i)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}viewportLines(e,t){let i=SO(t,this);for(let t of this.viewportLineBlocks)e(t.moveY(i))}get viewportLineBlocks(){return this.viewState.viewportLines}visualLineAt(e,t=0){return this.lineBlockAt(e).moveY(t+this.viewState.paddingTop)}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,i){return pr(this,e,dr(this,e,t,i))}moveByGroup(e,t){return pr(this,e,dr(this,e,t,(t=>function(e,t,i){let n=e.state.charCategorizer(t),r=n(i);return e=>{let t=n(e);return r==ke.Space&&(r=t),r==t}}(this,e.head,t))))}moveToLineBoundary(e,t,i=!0){return function(e,t,i,n){let r=e.state.doc.lineAt(t.head),O=n&&e.lineWrapping?e.coordsAtPos(t.assoc<0&&t.head>r.from?t.head-1:t.head):null;if(O){let t=e.dom.getBoundingClientRect(),n=e.posAtCoords({x:i==(e.textDirection==An.LTR)?t.right-1:t.left+1,y:(O.top+O.bottom)/2});if(null!=n)return z.cursor(n,i?-1:1)}let s=rn.find(e.docView,t.head),o=s?i?s.posAtEnd:s.posAtStart:i?r.to:r.from;return z.cursor(o,i?-1:1)}(this,e,t,i)}moveVertically(e,t,i){return pr(this,e,function(e,t,i,n){let r=t.head,O=i?1:-1;if(r==(i?e.state.doc.length:0))return z.cursor(r,t.assoc);let s,o=t.goalColumn,a=e.contentDOM.getBoundingClientRect(),l=e.coordsAtPos(r),h=e.documentTop;if(l)null==o&&(o=l.left-a.left),s=O<0?l.top:l.bottom;else{let t=e.viewState.lineBlockAt(r-h);null==o&&(o=Math.min(a.right-a.left,e.defaultCharacterWidth*(r-t.from))),s=(O<0?t.top:t.bottom)+h}let c=a.left+o,u=null!=n?n:e.defaultLineHeight>>1;for(let i=0;;i+=10){let n=s+(u+i)*O,l=ur(e,{x:c,y:n},!1,O);if(na.bottom||(O<0?lr))return z.cursor(l,t.assoc,void 0,o)}}(this,e,t,i))}scrollPosIntoView(e){this.dispatch({effects:$n.of(z.cursor(e))})}domAtPos(e){return this.docView.domAtPos(e)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){return this.readMeasured(),ur(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let i=this.docView.coordsAt(e,t);if(!i||i.left==i.right)return i;let n=this.state.doc.lineAt(e),r=this.bidiSpans(n);return oi(i,r[En.find(r,e-n.from,-1,t)].dir==An.LTR==t>0)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.heightOracle.direction}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>xO)return Mn(e.length);let t=this.textDirection;for(let i of this.bidiCache)if(i.from==e.from&&i.dir==t)return i.order;let i=function(e,t){let i=e.length,n=t==Yn?1:2,r=t==Yn?2:1;if(!e||1==n&&!jn.test(e))return Mn(i);for(let t=0,r=n,O=n;t=0;e-=3)if(Gn[e+1]==-O){let t=Gn[e+2],i=2&t?n:4&t?1&t?r:n:0;i&&(Dn[o]=Dn[Gn[e]]=i),a=e;break}}else{if(189==Gn.length)break;Gn[a++]=o,Gn[a++]=t,Gn[a++]=l}else if(2==(s=Dn[o])||1==s){let e=s==n;l=e?0:1;for(let t=a-3;t>=0;t-=3){let i=Gn[t+2];if(2&i)break;if(e)Gn[t+2]|=2;else{if(4&i)break;Gn[t+2]|=4}}}for(let e=0;et;){let e=i,n=2!=Dn[--i];for(;i>t&&n==(2!=Dn[i-1]);)i--;O.push(new En(i,e,n?2:1))}else O.push(new En(t,e,0))}else for(let e=0;eDate.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore((()=>{ui(this.contentDOM),this.docView.updateSelection()}))}destroy(){for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){return gn.of(new mn("number"==typeof e?z.cursor(e):e,t.y,t.x,t.yMargin,t.xMargin))}static domEventHandlers(e){return Sn.define((()=>({})),{eventHandlers:e})}static theme(e,t){let i=wt.newName(),n=[cO.of(i),_n.of(QO(`.${i}`,e))];return t&&t.dark&&n.push(uO.of(!0)),n}static baseTheme(e){return ie.lowest(_n.of(QO("."+fO,e,$O)))}}bO.scrollTo=$n,bO.centerOn=Qn,bO.styleModule=_n,bO.inputHandler=pn,bO.exceptionSink=fn,bO.updateListener=dn,bO.editable=Xn,bO.mouseSelectionStyle=un,bO.dragMovesSelection=cn,bO.clickAddsSelectionRange=hn,bO.decorations=Tn,bO.darkTheme=uO,bO.contentAttributes=Wn,bO.editorAttributes=Rn,bO.lineWrapping=bO.contentAttributes.of({class:"cm-lineWrapping"}),bO.announce=ge.define();const xO=4096;function SO(e,t){return(null==e?t.contentDOM.getBoundingClientRect().top:e)+t.viewState.paddingTop}const kO={};class vO{constructor(e,t,i,n){this.from=e,this.to=t,this.dir=i,this.order=n}static update(e,t){if(t.empty)return e;let i=[],n=e.length?e[e.length-1].dir:An.LTR;for(let r=Math.max(0,e.length-10);r=0;r--){let t=n[r],O="function"==typeof t?t(e):t;O&&Di(O,i)}return i}const WO=qi.mac?"mac":qi.windows?"win":qi.linux?"linux":"key";function TO(e,t,i){return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),!1!==i&&t.shiftKey&&(e="Shift-"+e),e}const _O=bO.domEventHandlers({keydown:(e,t)=>NO(AO(t.state),e,t,"editor")}),VO=I.define({enables:_O}),qO=new WeakMap;function AO(e){let t=e.facet(VO),i=qO.get(t);return i||qO.set(t,i=function(e,t=WO){let i=Object.create(null),n=Object.create(null),r=(e,t)=>{let i=n[e];if(null==i)n[e]=t;else if(i!=t)throw new Error("Key binding "+e+" is used both as a regular binding and as a multi-stroke prefix")},O=(e,n,O,s)=>{let o=i[e]||(i[e]=Object.create(null)),a=n.split(/ (?!$)/).map((e=>function(e,t){const i=e.split(/-(?!$)/);let n,r,O,s,o=i[i.length-1];"Space"==o&&(o=" ");for(let e=0;e{let n=YO={view:t,prefix:i,scope:e};return setTimeout((()=>{YO==n&&(YO=null)}),4e3),!0}]})}let l=a.join(" ");r(l,!1);let h=o[l]||(o[l]={preventDefault:!1,commands:[]});h.commands.push(O),s&&(h.preventDefault=!0)};for(let i of e){let e=i[t]||i.key;if(e)for(let t of i.scope?i.scope.split(" "):["editor"])O(t,e,i.run,i.preventDefault),i.shift&&O(t,"Shift-"+e,i.shift,i.preventDefault)}return i}(t.reduce(((e,t)=>e.concat(t)),[]))),i}let YO=null;function NO(e,t,i,n){let r=function(e){var t=!(Bt&&(e.ctrlKey||e.altKey||e.metaKey)||(Et||Lt)&&e.shiftKey&&e.key&&1==e.key.length)&&e.key||(e.shiftKey?It:Gt)[e.keyCode]||e.key||"Unidentified";return"Esc"==t&&(t="Escape"),"Del"==t&&(t="Delete"),"Left"==t&&(t="ArrowLeft"),"Up"==t&&(t="ArrowUp"),"Right"==t&&(t="ArrowRight"),"Down"==t&&(t="ArrowDown"),t}(t),O=1==r.length&&" "!=r,s="",o=!1;YO&&YO.view==i&&YO.scope==n&&(s=YO.prefix+" ",(o=mr.indexOf(t.keyCode)<0)&&(YO=null));let a,l=e=>{if(e){for(let t of e.commands)if(t(i))return!0;e.preventDefault&&(o=!0)}return!1},h=e[n];if(h){if(l(h[s+TO(r,t,!O)]))return!0;if(O&&(t.shiftKey||t.altKey||t.metaKey)&&(a=Gt[t.keyCode])&&a!=r){if(l(h[s+TO(a,t,!0)]))return!0}else if(O&&t.shiftKey&&l(h[s+TO(r,t,!0)]))return!0}return o}const ZO=!qi.ios,zO=I.define({combine:e=>_e(e,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})});function CO(e={}){return[zO.of(e),GO,jO]}class UO{constructor(e,t,i,n,r){this.left=e,this.top=t,this.width=i,this.height=n,this.className=r}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width>=0&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}}const GO=Sn.fromClass(class{constructor(e){this.view=e,this.rangePieces=[],this.cursors=[],this.measureReq={read:this.readPos.bind(this),write:this.drawSel.bind(this)},this.selectionLayer=e.scrollDOM.appendChild(document.createElement("div")),this.selectionLayer.className="cm-selectionLayer",this.selectionLayer.setAttribute("aria-hidden","true"),this.cursorLayer=e.scrollDOM.appendChild(document.createElement("div")),this.cursorLayer.className="cm-cursorLayer",this.cursorLayer.setAttribute("aria-hidden","true"),e.requestMeasure(this.measureReq),this.setBlinkRate()}setBlinkRate(){this.cursorLayer.style.animationDuration=this.view.state.facet(zO).cursorBlinkRate+"ms"}update(e){let t=e.startState.facet(zO)!=e.state.facet(zO);(t||e.selectionSet||e.geometryChanged||e.viewportChanged)&&this.view.requestMeasure(this.measureReq),e.transactions.some((e=>e.scrollIntoView))&&(this.cursorLayer.style.animationName="cm-blink"==this.cursorLayer.style.animationName?"cm-blink2":"cm-blink"),t&&this.setBlinkRate()}readPos(){let{state:e}=this.view,t=e.facet(zO),i=e.selection.ranges.map((e=>e.empty?[]:function(e,t){if(t.to<=e.viewport.from||t.from>=e.viewport.to)return[];let i=Math.max(t.from,e.viewport.from),n=Math.min(t.to,e.viewport.to),r=e.textDirection==An.LTR,O=e.contentDOM,s=O.getBoundingClientRect(),o=EO(e),a=window.getComputedStyle(O.firstChild),l=s.left+parseInt(a.paddingLeft)+Math.min(0,parseInt(a.textIndent)),h=s.right-parseInt(a.paddingRight),c=MO(e,i),u=MO(e,n),f=c.type==Ki.Text?c:null,d=u.type==Ki.Text?u:null;if(e.lineWrapping&&(f&&(f=DO(e,i,f)),d&&(d=DO(e,n,d))),f&&d&&f.from==d.from)return $(Q(t.from,t.to,f));{let i=f?Q(t.from,null,f):m(c,!1),n=d?Q(null,t.to,d):m(u,!0),r=[];return(f||c).to<(d||u).from-1?r.push(p(l,i.bottom,h,n.top)):i.bottomc&&n.from=O)break;o>r&&a(Math.max(e,r),null==t&&e<=c,Math.min(o,O),null==i&&o>=u,s.dir)}if(r=n.to+1,r>=O)break}return 0==o.length&&a(c,null==t,u,null==i,e.textDirection),{top:O,bottom:s,horizontal:o}}function m(e,t){let i=s.top+(t?e.top:e.bottom);return{top:i,bottom:i,horizontal:[]}}}(this.view,e))).reduce(((e,t)=>e.concat(t))),n=[];for(let i of e.selection.ranges){let r=i==e.selection.main;if(i.empty?!r||ZO:t.drawRangeCursor){let e=LO(this.view,i,r);e&&n.push(e)}}return{rangePieces:i,cursors:n}}drawSel({rangePieces:e,cursors:t}){if(e.length!=this.rangePieces.length||e.some(((e,t)=>!e.eq(this.rangePieces[t])))){this.selectionLayer.textContent="";for(let t of e)this.selectionLayer.appendChild(t.draw());this.rangePieces=e}if(t.length!=this.cursors.length||t.some(((e,t)=>!e.eq(this.cursors[t])))){let e=this.cursorLayer.children;if(e.length!==t.length){this.cursorLayer.textContent="";for(const e of t)this.cursorLayer.appendChild(e.draw())}else t.forEach(((t,i)=>t.adjust(e[i])));this.cursors=t}}destroy(){this.selectionLayer.remove(),this.cursorLayer.remove()}}),IO={".cm-line":{"& ::selection":{backgroundColor:"transparent !important"},"&::selection":{backgroundColor:"transparent !important"}}};ZO&&(IO[".cm-line"].caretColor="transparent !important");const jO=ie.highest(bO.theme(IO));function EO(e){let t=e.scrollDOM.getBoundingClientRect();return{left:(e.textDirection==An.LTR?t.left:t.right-e.scrollDOM.clientWidth)-e.scrollDOM.scrollLeft,top:t.top-e.scrollDOM.scrollTop}}function DO(e,t,i){let n=z.cursor(t);return{from:Math.max(i.from,e.moveToLineBoundary(n,!1,!0).from),to:Math.min(i.to,e.moveToLineBoundary(n,!0,!0).from),type:Ki.Text}}function MO(e,t){let i=e.lineBlockAt(t);if(Array.isArray(i.type))for(let e of i.type)if(e.to>t||e.to==t&&(e.to==i.to||e.type==Ki.Text))return e;return i}function LO(e,t,i){let n=e.coordsAtPos(t.head,t.assoc||1);if(!n)return null;let r=EO(e);return new UO(n.left-r.left,n.top-r.top,-1,n.bottom-n.top,i?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary")}function BO(e,t,i,n,r){t.lastIndex=0;for(let O,s=e.iterRange(i,n),o=i;!s.next().done;o+=s.value.length)if(!s.lineBreak)for(;O=t.exec(s.value);)r(o+O.index,o+O.index+O[0].length,O)}class KO{constructor(e){let{regexp:t,decoration:i,boundary:n,maxLength:r=1e3}=e;if(!t.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");this.regexp=t,this.getDeco="function"==typeof i?i:()=>i,this.boundary=n,this.maxLength=r}createDeco(e){let t=new Tt;for(let{from:i,to:n}of function(e,t){let i=e.visibleRanges;if(1==i.length&&i[0].from==e.viewport.from&&i[0].to==e.viewport.to)return i;let n=[];for(let{from:r,to:O}of i)r=Math.max(e.state.doc.lineAt(r).from,r-t),O=Math.min(e.state.doc.lineAt(O).to,O+t),n.length&&n[n.length-1].to>=r?n[n.length-1].to=O:n.push({from:r,to:O});return n}(e,this.maxLength))BO(e.state.doc,this.regexp,i,n,((i,n,r)=>t.add(i,n,this.getDeco(r,e,i))));return t.finish()}updateDeco(e,t){let i=1e9,n=-1;return e.docChanged&&e.changes.iterChanges(((t,r,O,s)=>{s>e.view.viewport.from&&O1e3?this.createDeco(e.view):n>-1?this.updateRange(e.view,t.map(e.changes),i,n):t}updateRange(e,t,i,n){for(let r of e.visibleRanges){let O=Math.max(r.from,i),s=Math.min(r.to,n);if(s>O){let i=e.state.doc.lineAt(O),n=i.toi.from;O--)if(this.boundary.test(i.text[O-1-i.from])){o=O;break}for(;sh.push(this.getDeco(n,e,t).range(t,i))));t=t.update({filterFrom:o,filterTo:a,filter:(e,t)=>ea,add:h})}}return t}}const FO=null!=/x/.unicode?"gu":"g",HO=new RegExp("[\0-\b\n--\u2028\u2029\ufeff-]",FO),JO={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"};let es=null;const ts=I.define({combine(e){let t=_e(e,{render:null,specialChars:HO,addSpecialChars:null});return(t.replaceTabs=!function(){var e;if(null==es&&"undefined"!=typeof document&&document.body){let t=document.body.style;es=null!=(null!==(e=t.tabSize)&&void 0!==e?e:t.MozTabSize)}return es||!1}())&&(t.specialChars=new RegExp("\t|"+t.specialChars.source,FO)),t.addSpecialChars&&(t.specialChars=new RegExp(t.specialChars.source+"|"+t.addSpecialChars.source,FO)),t}});function is(e={}){return[ts.of(e),ns||(ns=Sn.fromClass(class{constructor(e){this.view=e,this.decorations=Fi.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(e.state.facet(ts)),this.decorations=this.decorator.createDeco(e)}makeDecorator(e){return new KO({regexp:e.specialChars,decoration:(t,i,n)=>{let{doc:r}=i.state,O=f(t[0],0);if(9==O){let e=r.lineAt(n),t=i.state.tabSize,O=$(e.text,t,n-e.from);return Fi.replace({widget:new Os((t-O%t)*this.view.defaultCharacterWidth)})}return this.decorationCache[O]||(this.decorationCache[O]=Fi.replace({widget:new rs(e,O)}))},boundary:e.replaceTabs?void 0:/[^]/})}update(e){let t=e.state.facet(ts);e.startState.facet(ts)!=t?(this.decorator=this.makeDecorator(t),this.decorations=this.decorator.createDeco(e.view)):this.decorations=this.decorator.updateDeco(e,this.decorations)}},{decorations:e=>e.decorations}))]}let ns=null;class rs extends Bi{constructor(e,t){super(),this.options=e,this.code=t}eq(e){return e.code==this.code}toDOM(e){let t=function(e){return e>=32?"•":10==e?"":String.fromCharCode(9216+e)}(this.code),i=e.state.phrase("Control character")+" "+(JO[this.code]||"0x"+this.code.toString(16)),n=this.options.render&&this.options.render(this.code,i,t);if(n)return n;let r=document.createElement("span");return r.textContent=t,r.title=i,r.setAttribute("aria-label",i),r.className="cm-specialChar",r}ignoreEvent(){return!1}}class Os extends Bi{constructor(e){super(),this.width=e}eq(e){return e.width==this.width}toDOM(){let e=document.createElement("span");return e.textContent="\t",e.className="cm-tab",e.style.width=this.width+"px",e}ignoreEvent(){return!1}}class ss extends Bi{constructor(e){super(),this.content=e}toDOM(){let e=document.createElement("span");return e.className="cm-placeholder",e.style.pointerEvents="none",e.appendChild("string"==typeof this.content?document.createTextNode(this.content):this.content),"string"==typeof this.content?e.setAttribute("aria-label","placeholder "+this.content):e.setAttribute("aria-hidden","true"),e}ignoreEvent(){return!1}}function os(e){return Sn.fromClass(class{constructor(t){this.view=t,this.placeholder=Fi.set([Fi.widget({widget:new ss(e),side:1}).range(0)])}get decorations(){return this.view.state.doc.length?Fi.none:this.placeholder}},{decorations:e=>e.decorations})}var as;const ls=new Ye;function hs(e){return I.define({combine:e?t=>t.concat(e):void 0})}class cs{constructor(e,t,i,n=[]){this.data=e,this.topNode=i,Te.prototype.hasOwnProperty("tree")||Object.defineProperty(Te.prototype,"tree",{get(){return ds(this)}}),this.parser=t,this.extension=[bs.of(this),Te.languageData.of(((e,t,i)=>e.facet(us(e,t,i))))].concat(n)}isActiveAt(e,t,i=-1){return us(e,t,i)==this.data}findRegions(e){let t=e.facet(bs);if((null==t?void 0:t.data)==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let i=[],n=(e,t)=>{if(e.prop(ls)==this.data)return void i.push({from:t,to:t+e.length});let r=e.prop(Ye.mounted);if(r){if(r.tree.prop(ls)==this.data){if(r.overlay)for(let e of r.overlay)i.push({from:e.from+t,to:e.to+t});else i.push({from:t,to:t+e.length});return}if(r.overlay){let e=i.length;if(n(r.tree,r.overlay[0].from+t),i.length>e)return}}for(let i=0;ie.isTop?t:void 0))]}))}configure(e){return new fs(this.data,this.parser.configure(e))}get allowsNesting(){return this.parser.wrappers.length>0}}function ds(e){let t=e.field(cs.state,!1);return t?t.tree:Ie.empty}function ps(e,t=e.doc.length){var i;return(null===(i=e.field(cs.state,!1))||void 0===i?void 0:i.context.isDone(t))||!1}class $s{constructor(e,t=e.length){this.doc=e,this.length=t,this.cursorPos=0,this.string="",this.cursor=e.iter()}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let i=this.cursorPos-this.string.length;return e=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-i,t-i)}}let Qs=null;class ms{constructor(e,t,i=[],n,r,O,s,o){this.parser=e,this.state=t,this.fragments=i,this.tree=n,this.treeLen=r,this.viewport=O,this.skipped=s,this.scheduleOn=o,this.parse=null,this.tempSkipped=[]}startParse(){return this.parser.startParse(new $s(this.state.doc),this.fragments)}work(e,t){return null!=t&&t>=this.state.doc.length&&(t=void 0),this.tree!=Ie.empty&&this.isDone(null!=t?t:this.state.doc.length)?(this.takeTree(),!0):this.withContext((()=>{var i;if("number"==typeof e){let t=Date.now()+e;e=()=>Date.now()>t}for(this.parse||(this.parse=this.startParse()),null!=t&&(null==this.parse.stoppedAt||this.parse.stoppedAt>t)&&t=this.treeLen&&((null==this.parse.stoppedAt||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext((()=>{for(;!(t=this.parse.advance()););})),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(rt.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=Qs;Qs=this;try{return e()}finally{Qs=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=gs(e,t.from,t.to);return e}changes(e,t){let{fragments:i,tree:n,treeLen:r,viewport:O,skipped:s}=this;if(this.takeTree(),!e.empty){let t=[];if(e.iterChangedRanges(((e,i,n,r)=>t.push({fromA:e,toA:i,fromB:n,toB:r}))),i=rt.applyChanges(i,t),n=Ie.empty,r=0,O={from:e.mapPos(O.from,-1),to:e.mapPos(O.to,1)},this.skipped.length){s=[];for(let t of this.skipped){let i=e.mapPos(t.from,1),n=e.mapPos(t.to,-1);ie.from&&(this.fragments=gs(this.fragments,i,n),this.skipped.splice(t--,1))}return!(this.skipped.length>=t||(this.reset(),0))}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends Ot{createParse(t,i,n){let r=n[0].from,O=n[n.length-1].to;return{parsedPos:r,advance(){let t=Qs;if(t){for(let e of n)t.tempSkipped.push(e);e&&(t.scheduleOn=t.scheduleOn?Promise.all([t.scheduleOn,e]):e)}return this.parsedPos=O,new Ie(ze.none,[],[],O-r)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&0==t[0].from&&t[0].to>=e}static get(){return Qs}}function gs(e,t,i){return rt.applyChanges(e,[{fromA:t,toA:i,fromB:t,toB:i}])}class Ps{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),i=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,i)||t.takeTree(),new Ps(t)}static init(e){let t=Math.min(3e3,e.doc.length),i=new ms(e.facet(bs).parser,e,[],Ie.empty,0,{from:0,to:t},[],null);return i.work(20,t)||i.takeTree(),new Ps(i)}}cs.state=B.define({create:Ps.init,update(e,t){for(let e of t.effects)if(e.is(cs.setState))return e.value;return t.startState.facet(bs)!=t.state.facet(bs)?Ps.init(t.state):e.apply(t)}});let Xs=e=>{let t=setTimeout((()=>e()),500);return()=>clearTimeout(t)};"undefined"!=typeof requestIdleCallback&&(Xs=e=>{let t=-1,i=setTimeout((()=>{t=requestIdleCallback(e,{timeout:400})}),100);return()=>t<0?clearTimeout(i):cancelIdleCallback(t)});const ys="undefined"!=typeof navigator&&(null===(as=navigator.scheduling)||void 0===as?void 0:as.isInputPending)?()=>navigator.scheduling.isInputPending():null,ws=Sn.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(cs.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),e.docChanged&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(cs.state);t.tree==t.context.tree&&t.context.isDone(e.doc.length)||(this.working=Xs(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEndn+1e3,o=r.context.work((()=>ys&&ys()||Date.now()>O),n+(s?0:1e5));this.chunkBudget-=Date.now()-t,(o||this.chunkBudget<=0)&&(r.context.takeTree(),this.view.dispatch({effects:cs.setState.of(new Ps(r.context))})),this.chunkBudget>0&&(!o||s)&&this.scheduleWork(),this.checkAsyncSchedule(r.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then((()=>this.scheduleWork())).catch((e=>Pn(this.view.state,e))).then((()=>this.workScheduled--)),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),bs=I.define({combine:e=>e.length?e[0]:null,enables:[cs.state,ws]});class xs{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}}class Ss{constructor(e,t,i,n,r,O){this.name=e,this.alias=t,this.extensions=i,this.filename=n,this.loadFunc=r,this.support=O,this.loading=null}load(){return this.loading||(this.loading=this.loadFunc().then((e=>this.support=e),(e=>{throw this.loading=null,e})))}static of(e){let{load:t,support:i}=e;if(!t){if(!i)throw new RangeError("Must pass either 'load' or 'support' to LanguageDescription.of");t=()=>Promise.resolve(i)}return new Ss(e.name,(e.alias||[]).concat(e.name).map((e=>e.toLowerCase())),e.extensions||[],e.filename,t,i)}static matchFilename(e,t){for(let i of e)if(i.filename&&i.filename.test(t))return i;let i=/\.([^.]+)$/.exec(t);if(i)for(let t of e)if(t.extensions.indexOf(i[1])>-1)return t;return null}static matchLanguageName(e,t,i=!0){t=t.toLowerCase();for(let i of e)if(i.alias.some((e=>e==t)))return i;if(i)for(let i of e)for(let e of i.alias){let n=t.indexOf(e);if(n>-1&&(e.length>2||!/\w/.test(t[n-1])&&!/\w/.test(t[n+e.length])))return i}return null}}const ks=I.define(),vs=I.define({combine:e=>{if(!e.length)return" ";if(!/^(?: +|\t+)$/.test(e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(e[0]));return e[0]}});function Rs(e){let t=e.facet(vs);return 9==t.charCodeAt(0)?e.tabSize*t.length:t.length}function Ws(e,t){let i="",n=e.tabSize;if(9==e.facet(vs).charCodeAt(0))for(;t>=n;)i+="\t",t-=n;for(let e=0;e=i.from&&n<=i.to?r&&n==e?{text:"",from:e}:(t<0?n-1&&(r+=O-this.countColumn(i,i.search(/\S|$/))),r}countColumn(e,t=e.length){return $(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:i,from:n}=this.lineAt(e,t),r=this.options.overrideIndentation;if(r){let e=r(n);if(e>-1)return e}return this.countColumn(i,i.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const Vs=new Ye;function qs(e){let t=e.type.prop(Vs);if(t)return t;let i,n=e.firstChild;if(n&&(i=n.type.prop(Ye.closedBy))){let t=e.lastChild,n=t&&i.indexOf(t.name)>-1;return e=>Cs(e,!0,1,void 0,n&&!function(e){return e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak}(e)?t.from:void 0)}return null==e.parent?Ys:null}function As(e,t,i){for(;e;e=e.parent){let n=qs(e);if(n)return n(new Ns(i,t,e))}return null}function Ys(){return 0}class Ns extends _s{constructor(e,t,i){super(e.state,e.options),this.base=e,this.pos=t,this.node=i}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){let e=this.state.doc.lineAt(this.node.from);for(;;){let t=this.node.resolve(e.from);for(;t.parent&&t.parent.from==t.from;)t=t.parent;if(Zs(t,this.node))break;e=this.state.doc.lineAt(t.from)}return this.lineIndent(e.from)}continue(){let e=this.node.parent;return e?As(e,this.pos,this.base):0}}function Zs(e,t){for(let i=t;i;i=i.parent)if(e==i)return!0;return!1}function zs({closing:e,align:t=!0,units:i=1}){return n=>Cs(n,t,i,e)}function Cs(e,t,i,n,r){let O=e.textAfter,s=O.match(/^\s*/)[0].length,o=n&&O.slice(s,s+n.length)==n||r==e.pos+s,a=t?function(e){let t=e.node,i=t.childAfter(t.from),n=t.lastChild;if(!i)return null;let r=e.options.simulateBreak,O=e.state.doc.lineAt(i.from),s=null==r||r<=O.from?O.to:Math.min(O.to,r);for(let e=i.to;;){let r=t.childAfter(e);if(!r||r==n)return null;if(!r.type.isSkipped)return r.from{let n=e&&e.test(i.textAfter);return i.baseIndent+(n?0:t*i.unit)}}function Gs(){return Te.transactionFilter.of((e=>{if(!e.docChanged||!e.isUserEvent("input.type")&&!e.isUserEvent("input.complete"))return e;let t=e.startState.languageDataAt("indentOnInput",e.startState.selection.main.head);if(!t.length)return e;let i=e.newDoc,{head:n}=e.newSelection.main,r=i.lineAt(n);if(n>r.from+200)return e;let O=i.sliceString(r.from,n);if(!t.some((e=>e.test(O))))return e;let{state:s}=e,o=-1,a=[];for(let{head:e}of s.selection.ranges){let t=s.doc.lineAt(e);if(t.from==o)continue;o=t.from;let i=Ts(s,t.from);if(null==i)continue;let n=/^\s*/.exec(t.text)[0],r=Ws(s,i);n!=r&&a.push({from:t.from,to:t.from+n.length,insert:r})}return a.length?[e,{changes:a,sequential:!0}]:e}))}const Is=I.define(),js=new Ye;function Es(e){let t=e.firstChild,i=e.lastChild;return t&&t.toi)continue;if(r&&O.from=t&&n.to>i&&(r=n)}}return r}(e,t,i)}let Ls=0;class Bs{constructor(e,t,i){this.set=e,this.base=t,this.modified=i,this.id=Ls++}static define(e){if(null==e?void 0:e.base)throw new Error("Can not derive from a modified tag");let t=new Bs([],null,[]);if(t.set.push(t),e)for(let i of e.set)t.set.push(i);return t}static defineModifier(){let e=new Fs;return t=>t.modified.indexOf(e)>-1?t:Fs.get(t.base||t,t.modified.concat(e).sort(((e,t)=>e.id-t.id)))}}let Ks=0;class Fs{constructor(){this.instances=[],this.id=Ks++}static get(e,t){if(!t.length)return e;let i=t[0].instances.find((i=>i.base==e&&function(e,t){return e.length==t.length&&e.every(((e,i)=>e==t[i]))}(t,i.modified)));if(i)return i;let n=[],r=new Bs(n,e,t);for(let e of t)e.instances.push(r);let O=Hs(t);for(let t of e.set)for(let e of O)n.push(Fs.get(t,e));return r}}function Hs(e){let t=[e];for(let i=0;i0&&t+3==e.length){r=1;break}let n=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(O);if(!n)throw new RangeError("Invalid path: "+e);if(i.push("*"==n[0]?null:'"'==n[0][0]?JSON.parse(n[0]):n[0]),t+=n[0].length,t==e.length)break;let s=e[t++];if(t==e.length&&"!"==s){r=0;break}if("/"!=s)throw new RangeError("Invalid path: "+e);O=e.slice(t)}let s=i.length-1,o=i[s];if(!o)throw new RangeError("Invalid path: "+e);let a=new ro(n,r,s>0?i.slice(0,s):null);t[o]=a.sort(t[o])}}return eo.add(t)}const eo=new Ye,to=I.define({combine:e=>e.length?Oo.combinedMatch(e):null}),io=I.define({combine:e=>e.length?e[0].match:null});function no(e){return e.facet(to)||e.facet(io)}class ro{constructor(e,t,i,n){this.tags=e,this.mode=t,this.context=i,this.next=n}sort(e){return!e||e.depthe.facet(bO.darkTheme)==("dark"==t.themeType)?[this]:[]))),this.fallback=r.concat(io.of(this))}match(e,t){if(this.scope&&t!=this.scope)return null;for(let t of e.set){let i=this.map[t.id];if(void 0!==i)return t!=e&&(this.map[e.id]=i),i}return this.map[e.id]=this.all}static combinedMatch(e){if(1==e.length)return e[0].match;let t=e.some((e=>e.scope))?void 0:Object.create(null);return(i,n)=>{let r=t&&t[i.id];if(void 0!==r)return r;let O=null;for(let t of e){let e=t.match(i,n);e&&(O=O?O+" "+e:e)}return t&&(t[i.id]=O),O}}static define(e,t){return new Oo(e,t||{})}static get(e,t,i){let n=no(e);return n&&n(t,i||ze.none)}}const so=ie.high(Sn.fromClass(class{constructor(e){this.markCache=Object.create(null),this.tree=ds(e.state),this.decorations=this.buildDeco(e,no(e.state))}update(e){let t=ds(e.state),i=no(e.state),n=i!=e.startState.facet(to);t.length{i.add(e,t,this.markCache[n]||(this.markCache[n]=Fi.mark({class:n})))}));return i.finish()}},{decorations:e=>e.decorations})),oo=[""];class ao{constructor(e,t,i){this.at=e,this.style=t,this.span=i,this.class=""}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,i,n,r,O){let{type:s,from:o,to:a}=e;if(o>=i||a<=t)return;oo[r]=s.name,s.isTop&&(O=s);let l=n,h=s.prop(eo),c=!1;for(;h;){if(!h.context||ho(h.context,oo,r)){for(let e of h.tags){let t=this.style(e,O);t&&(l&&(l+=" "),l+=t,1==h.mode?n+=(n?" ":"")+t:0==h.mode&&(c=!0))}break}h=h.next}if(this.startSpan(e.from,l),c)return;let u=e.tree&&e.tree.prop(Ye.mounted);if(u&&u.overlay){let s=e.node.enter(u.overlay[0].from+o,1),h=e.firstChild();for(let c=0,f=o;;c++){let d=c=p)&&e.nextSibling()););if(!d||p>i)break;f=d.to+o,f>t&&(this.highlightRange(s.cursor,Math.max(t,d.from+o),Math.min(i,f),n,r,u.tree.type),this.startSpan(f,l))}h&&e.parent()}else if(e.firstChild()){do{if(!(e.to<=t)){if(e.from>=i)break;this.highlightRange(e,t,i,n,r+1,O),this.startSpan(Math.min(i,e.to),l)}}while(e.nextSibling());e.parent()}}}function lo(e,t,i,n,r){let O=new ao(t,n,r);O.highlightRange(e.cursor(),t,i,"",0,e.type),O.flush(i)}function ho(e,t,i){if(e.length>i-1)return!1;for(let n=i-1,r=e.length-1;r>=0;r--,n--){let i=e[r];if(i&&i!=t[n])return!1}return!0}const co=Bs.define,uo=co(),fo=co(),po=co(fo),$o=co(fo),Qo=co(),mo=co(Qo),go=co(Qo),Po=co(),Xo=co(Po),yo=co(),wo=co(),bo=co(),xo=co(bo),So=co(),ko={comment:uo,lineComment:co(uo),blockComment:co(uo),docComment:co(uo),name:fo,variableName:co(fo),typeName:po,tagName:co(po),propertyName:$o,attributeName:co($o),className:co(fo),labelName:co(fo),namespace:co(fo),macroName:co(fo),literal:Qo,string:mo,docString:co(mo),character:co(mo),attributeValue:co(mo),number:go,integer:co(go),float:co(go),bool:co(Qo),regexp:co(Qo),escape:co(Qo),color:co(Qo),url:co(Qo),keyword:yo,self:co(yo),null:co(yo),atom:co(yo),unit:co(yo),modifier:co(yo),operatorKeyword:co(yo),controlKeyword:co(yo),definitionKeyword:co(yo),moduleKeyword:co(yo),operator:wo,derefOperator:co(wo),arithmeticOperator:co(wo),logicOperator:co(wo),bitwiseOperator:co(wo),compareOperator:co(wo),updateOperator:co(wo),definitionOperator:co(wo),typeOperator:co(wo),controlOperator:co(wo),punctuation:bo,separator:co(bo),bracket:xo,angleBracket:co(xo),squareBracket:co(xo),paren:co(xo),brace:co(xo),content:Po,heading:Xo,heading1:co(Xo),heading2:co(Xo),heading3:co(Xo),heading4:co(Xo),heading5:co(Xo),heading6:co(Xo),contentSeparator:co(Po),list:co(Po),quote:co(Po),emphasis:co(Po),strong:co(Po),link:co(Po),monospace:co(Po),strikethrough:co(Po),inserted:co(),deleted:co(),changed:co(),invalid:co(),meta:So,documentMeta:co(So),annotation:co(So),processingInstruction:co(So),definition:Bs.defineModifier(),constant:Bs.defineModifier(),function:Bs.defineModifier(),standard:Bs.defineModifier(),local:Bs.defineModifier(),special:Bs.defineModifier()},vo=Oo.define([{tag:ko.link,textDecoration:"underline"},{tag:ko.heading,textDecoration:"underline",fontWeight:"bold"},{tag:ko.emphasis,fontStyle:"italic"},{tag:ko.strong,fontWeight:"bold"},{tag:ko.strikethrough,textDecoration:"line-through"},{tag:ko.keyword,color:"#708"},{tag:[ko.atom,ko.bool,ko.url,ko.contentSeparator,ko.labelName],color:"#219"},{tag:[ko.literal,ko.inserted],color:"#164"},{tag:[ko.string,ko.deleted],color:"#a11"},{tag:[ko.regexp,ko.escape,ko.special(ko.string)],color:"#e40"},{tag:ko.definition(ko.variableName),color:"#00f"},{tag:ko.local(ko.variableName),color:"#30a"},{tag:[ko.typeName,ko.namespace],color:"#085"},{tag:ko.className,color:"#167"},{tag:[ko.special(ko.variableName),ko.macroName],color:"#256"},{tag:ko.definition(ko.propertyName),color:"#00c"},{tag:ko.comment,color:"#940"},{tag:ko.meta,color:"#7a757a"},{tag:ko.invalid,color:"#f00"}]);const Ro=Object.create(null),Wo=[ze.none],To=(new Ce(Wo),[]),_o=Object.create(null);for(let[e,t]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","typeName"],["attribute","propertyName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])_o[e]=Ao(Ro,t);class Vo{constructor(e){this.extra=e,this.table=Object.assign(Object.create(null),_o)}resolve(e){return e?this.table[e]||(this.table[e]=Ao(this.extra,e)):0}}new Vo(Ro);function qo(e,t){To.indexOf(e)>-1||(To.push(e),console.warn(t))}function Ao(e,t){let i=null;for(let n of t.split(".")){let t=e[n]||ko[n];t?"function"==typeof t?i?i=t(i):qo(n,`Modifier ${n} used at start of tag`):i?qo(n,`Tag ${n} used as modifier`):i=t:qo(n,`Unknown highlighting tag ${n}`)}if(!i)return 0;let n=t.replace(/ /g,"_"),r=ze.define({id:Wo.length,name:n,props:[Js({[n]:i})]});return Wo.push(r),r.id}function Yo(e,t,i){return void 0===i&&(i=""),void 0===t&&(t="\\b"),new RegExp("^"+i+"(("+e.join(")|(")+"))"+t)}var No=["[<>]:","[<>=]=","<<=?",">>>?=?","=>","--?>","<--[->]?","\\/\\/","\\.{2,3}","[\\.\\\\%*+\\-<>!\\/^|&]=?","\\?","\\$","~",":"],Zo=(Yo(["[<>]:","[<>=]=","<<=?",">>>?=?","=>","--?>","<--[->]?","\\/\\/","[\\\\%*+\\-<>!\\/^|&\\u00F7\\u22BB]=?","\\?","\\$","~",":","\\u00D7","\\u2208","\\u2209","\\u220B","\\u220C","\\u2218","\\u221A","\\u221B","\\u2229","\\u222A","\\u2260","\\u2264","\\u2265","\\u2286","\\u2288","\\u228A","\\u22C5","\\b(in|isa)\\b(?!.?\\()"],""),Yo(["\\\\[0-7]{1,3}","\\\\x[A-Fa-f0-9]{1,2}","\\\\[abefnrtv0%?'\"\\\\]","([^\\u0027\\u005C\\uD800-\\uDFFF]|[\\uD800-\\uDFFF][\\uDC00-\\uDFFF])"],"'"),["if","else","elseif","while","for","begin","let","end","do","try","catch","finally","return","break","continue","global","local","const","export","import","importall","using","function","where","macro","module","baremodule","struct","type","mutable","immutable","quote","typealias","abstract","primitive","bitstype"]),zo=["true","false","nothing","NaN","Inf"];Yo(["begin","function","type","struct","immutable","let","macro","for","while","quote","if","else","elseif","try","finally","catch","do"]),Yo(["end","else","elseif","catch","finally"]),Yo(Zo),Yo(zo),Yo(No,"","@"),Yo(No,"",":");Zo.concat(zo);class Co{constructor(e,t,i,n,r,O,s,o,a,l=0,h){this.p=e,this.stack=t,this.state=i,this.reducePos=n,this.pos=r,this.score=O,this.buffer=s,this.bufferBase=o,this.curContext=a,this.lookAhead=l,this.parent=h}toString(){return`[${this.stack.filter(((e,t)=>t%3==0)).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,t,i=0){let n=e.parser.context;return new Co(e,[],t,i,i,0,[],0,n?new Uo(n,n.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,t){this.stack.push(this.state,t,this.bufferBase+this.buffer.length),this.state=e}reduce(e){let t=e>>19,i=65535&e,{parser:n}=this.p,r=n.dynamicPrecedence(i);if(r&&(this.score+=r),0==t)return this.pushState(n.getGoto(this.state,i,!0),this.reducePos),iO;)this.stack.pop();this.reduceContext(i,s)}storeNode(e,t,i,n=4,r=!1){if(0==e){let e=this,n=this.buffer.length;if(0==n&&e.parent&&(n=e.bufferBase-e.parent.bufferBase,e=e.parent),n>0&&0==e.buffer[n-4]&&e.buffer[n-1]>-1){if(t==i)return;if(e.buffer[n-2]>=t)return void(e.buffer[n-2]=i)}}if(r&&this.pos!=i){let r=this.buffer.length;if(r>0&&0!=this.buffer[r-4])for(;r>0&&this.buffer[r-2]>i;)this.buffer[r]=this.buffer[r-4],this.buffer[r+1]=this.buffer[r-3],this.buffer[r+2]=this.buffer[r-2],this.buffer[r+3]=this.buffer[r-1],r-=4,n>4&&(n-=4);this.buffer[r]=e,this.buffer[r+1]=t,this.buffer[r+2]=i,this.buffer[r+3]=n}else this.buffer.push(e,t,i,n)}shift(e,t,i){let n=this.pos;if(131072&e)this.pushState(65535&e,this.pos);else if(0==(262144&e)){let r=e,{parser:O}=this.p;(i>this.pos||t<=O.maxNode)&&(this.pos=i,O.stateFlag(r,1)||(this.reducePos=i)),this.pushState(r,n),this.shiftContext(t,n),t<=O.maxNode&&this.buffer.push(t,n,i,4)}else this.pos=i,this.shiftContext(t,n),t<=this.p.parser.maxNode&&this.buffer.push(t,n,i,4)}apply(e,t,i){65536&e?this.reduce(e):this.shift(e,t,i)}useNode(e,t){let i=this.p.reused.length-1;(i<0||this.p.reused[i]!=e)&&(this.p.reused.push(e),i++);let n=this.pos;this.reducePos=this.pos=n+e.length,this.pushState(t,n),this.buffer.push(i,n,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,t=e.buffer.length;for(;t>0&&e.buffer[t-2]>e.reducePos;)t-=4;let i=e.buffer.slice(t),n=e.bufferBase+t;for(;e&&n==e.bufferBase;)e=e.parent;return new Co(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,i,n,this.curContext,this.lookAhead,e)}recoverByDelete(e,t){let i=e<=this.p.parser.maxNode;i&&this.storeNode(e,this.pos,t,4),this.storeNode(0,this.pos,t,i?8:4),this.pos=this.reducePos=t,this.score-=190}canShift(e){for(let t=new Io(this);;){let i=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(0==(65536&i))return!0;if(0==i)return!1;t.reduce(i)}}recoverByInsert(e){if(this.stack.length>=300)return[];let t=this.p.parser.nextStates(this.state);if(t.length>8||this.stack.length>=120){let i=[];for(let n,r=0;r1&t&&e==n))||i.push(t[e],n)}t=i}let i=[];for(let e=0;e>19,n=65535&e,r=this.stack.length-3*i;if(r<0||t.getGoto(this.stack[r],n,!1)<0)return!1;this.storeNode(0,this.reducePos,this.reducePos,4,!0),this.score-=100}return this.reduce(e),!0}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(3!=this.stack.length)return!1;let{parser:e}=this.p;return 65535==e.data[e.stateSlot(this.state,1)]&&!e.stateSlot(this.state,4)}restart(){this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let t=0;tthis.lookAhead&&(this.emitLookAhead(),this.lookAhead=e)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}}class Uo{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}}var Go;!function(e){e[e.Insert=200]="Insert",e[e.Delete=190]="Delete",e[e.Reduce=100]="Reduce",e[e.MaxNext=4]="MaxNext",e[e.MaxInsertStackDepth=300]="MaxInsertStackDepth",e[e.DampenInsertStackDepth=120]="DampenInsertStackDepth"}(Go||(Go={}));class Io{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let t=65535&e,i=e>>19;0==i?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=3*(i-1);let n=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=n}}class jo{constructor(e,t,i){this.stack=e,this.pos=t,this.index=i,this.buffer=e.buffer,0==this.index&&this.maybeNext()}static create(e,t=e.bufferBase+e.buffer.length){return new jo(e,t,t-e.bufferBase)}maybeNext(){let e=this.stack.parent;null!=e&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,0==this.index&&this.maybeNext()}fork(){return new jo(this.stack,this.pos,this.index)}}class Eo{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const Do=new Eo;class Mo{constructor(e,t){this.input=e,this.ranges=t,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=Do,this.rangeIndex=0,this.pos=this.chunkPos=t[0].from,this.range=t[0],this.end=t[t.length-1].to,this.readNext()}resolveOffset(e,t){let i=this.range,n=this.rangeIndex,r=this.pos+e;for(;ri.to:r>=i.to;){if(n==this.ranges.length-1)return null;let e=this.ranges[++n];r+=e.from-i.to,i=e}return r}peek(e){let t,i,n=this.chunkOff+e;if(n>=0&&n=this.chunk2Pos&&tn.to&&(this.chunk2=this.chunk2.slice(0,n.to-t)),i=this.chunk2.charCodeAt(0)}}return t>=this.token.lookAhead&&(this.token.lookAhead=t+1),i}acceptToken(e,t=0){let i=t?this.resolveOffset(t,-1):this.pos;if(null==i||i=this.chunk2Pos&&this.posthis.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,t){if(t?(this.token=t,t.start=e,t.lookAhead=e+1,t.value=t.extended=-1):this.token=Do,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e=this.chunkPos&&t<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,t-this.chunkPos);if(e>=this.chunk2Pos&&t<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,t-this.chunk2Pos);if(e>=this.range.from&&t<=this.range.to)return this.input.read(e,t);let i="";for(let n of this.ranges){if(n.from>=t)break;n.to>e&&(i+=this.input.read(Math.max(n.from,e),Math.min(n.to,t)))}return i}}class Lo{constructor(e,t){this.data=e,this.id=t}token(e,t){!function(e,t,i,n){let r=0,O=1<