@carbon/ai-chat-components 0.6.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/custom-elements.json +10 -0
- package/dist/{button-BI6h3BZU.js → button-CBb7Jhi7.js} +24 -24
- package/dist/{button-skeleton-C4ElE3Ew.js → button-skeleton-B4XMARh-.js} +24 -24
- package/dist/chain-of-thought.min.js +24 -24
- package/dist/chat-button.min.js +24 -24
- package/dist/{checkbox-skeleton-CoblyagM.js → checkbox-skeleton-DwMLLcdk.js} +24 -24
- package/dist/{class-map-DjCKKx83.js → class-map-C_OkZP0k.js} +24 -24
- package/dist/code-snippet.min.js +24 -24
- package/dist/{codemirror-runtime-_n4XfRE9.js → codemirror-runtime-B436WsU5.js} +25 -25
- package/dist/{dockerfile-BvZrCdwA.js → dockerfile-DqeVY5Wu.js} +24 -24
- package/dist/{factor-C-o9WMfc.js → factor-DT3csLlE.js} +24 -24
- package/dist/feedback.min.js +24 -24
- package/dist/{icon-button-DaHH0wRX.js → icon-button-OMMcBXs2.js} +24 -24
- package/dist/{icon-loader-DXc1LXfv.js → icon-loader-BjBTslVK.js} +24 -24
- package/dist/{if-defined-CBJZ5Gfw.js → if-defined-BVYgSqhJ.js} +24 -24
- package/dist/{index-CLun6lGz.js → index-4jRdBit9.js} +24 -24
- package/dist/{index-CRQ_c60v.js → index-BM41YEqq.js} +24 -24
- package/dist/{index-CwJXiNAs.js → index-BOh_nBln.js} +24 -24
- package/dist/{index-DAE055Cu.js → index-Bu9gWUiF.js} +24 -24
- package/dist/{index-PudNB5nC.js → index-C8bEg5Uj.js} +24 -24
- package/dist/{index-DXBfzR2s.js → index-C8xRVVPE.js} +24 -24
- package/dist/{index-yVLVhp6V.js → index-COYOBWaJ.js} +24 -24
- package/dist/{index-BkOGOowl.js → index-CSEyeHT9.js} +24 -24
- package/dist/{index-CoHvpVb0.js → index-Ci2IAejb.js} +24 -24
- package/dist/{index-BfrNY07c.js → index-CmkRN7JA.js} +24 -24
- package/dist/{index-Cs0owqXP.js → index-CsQW_IZu.js} +24 -24
- package/dist/{index-Cv8hjf43.js → index-Cy4O64oM.js} +24 -24
- package/dist/{index-6Jr9D3_B.js → index-D2t8pNSN.js} +24 -24
- package/dist/{index-8KclZ0nm.js → index-DBxz4i7M.js} +24 -24
- package/dist/{index-GIcY4W_W.js → index-DWCU-zPy.js} +24 -24
- package/dist/{index-BUcHzgqY.js → index-DXc2fPMn.js} +24 -24
- package/dist/{index-BIipjmyi.js → index-DcP0S8R8.js} +24 -24
- package/dist/{index-URihvplO.js → index-DeCI268E.js} +25 -25
- package/dist/{index-DAFvuacj.js → index-DebFxHTs.js} +24 -24
- package/dist/{index-BvNnbnhR.js → index-DiiLbFxH.js} +24 -24
- package/dist/{index-DOyxM-mj.js → index-EHu0fYXl.js} +24 -24
- package/dist/{index-BOZ1EumZ.js → index-ayWik3gi.js} +25 -25
- package/dist/{index-DMHecuNR.js → index-muXVkugt.js} +24 -24
- package/dist/{index-DBeVfXDs.js → index-tnMbrHKo.js} +24 -24
- package/dist/markdown.min.js +24 -24
- package/dist/{nsis-dTUTRg0D.js → nsis-B-vzq3eT.js} +24 -24
- package/dist/processing.min.js +24 -24
- package/dist/{pug-dysr1PFn.js → pug-Flk_Hgat.js} +24 -24
- package/dist/reasoning-steps.min.js +31 -31
- package/dist/{repeat-DVX8OmkT.js → repeat-Ck4tYPIW.js} +24 -24
- package/dist/{state-szSaUXxk.js → state-kzgjVNgy.js} +24 -24
- package/dist/{table-runtime-BJvGMFSi.js → table-runtime-C9nhKjvI.js} +24 -24
- package/dist/table.min.js +24 -24
- package/dist/{text-input-VLXorzoU.js → text-input-DBmpDGoh.js} +24 -24
- package/dist/tile-container.min.js +24 -24
- package/dist/toolbar.min.js +24 -24
- package/dist/workspace-shell.min.js +24 -24
- package/es/components/reasoning-steps/src/cds-aichat-reasoning-step.d.ts +5 -0
- package/es/components/reasoning-steps/src/cds-aichat-reasoning-step.js +24 -2
- package/es/components/reasoning-steps/src/cds-aichat-reasoning-step.js.map +1 -1
- package/es/components/reasoning-steps/src/cds-aichat-reasoning-step.scss.js +1 -1
- package/es/components/reasoning-steps/src/cds-aichat-reasoning-steps.d.ts +1 -0
- package/es/components/reasoning-steps/src/cds-aichat-reasoning-steps.js +13 -0
- package/es/components/reasoning-steps/src/cds-aichat-reasoning-steps.js.map +1 -1
- package/es/components/reasoning-steps/src/cds-aichat-reasoning-steps.scss.js +1 -1
- package/es/react/feedback-buttons.js +3 -0
- package/es/react/feedback-buttons.js.map +1 -1
- package/package.json +2 -2
- package/dist/{16-CVRN2AV_.js → 16-DYDOiPFg.js} +23 -23
- package/dist/{apl-efZAUIfn.js → apl-DqPKPgQT.js} +23 -23
- package/dist/{asciiarmor-DSPxllJn.js → asciiarmor-D-S0VxwT.js} +23 -23
- package/dist/{asn1-DrA2u-JN.js → asn1-CFFEZSZ_.js} +23 -23
- package/dist/{asterisk-Bd48VInq.js → asterisk-C3IDaiGv.js} +23 -23
- package/dist/{carbon-element-KGohr2u6.js → carbon-element-BrN6iUKF.js} +23 -23
- package/dist/{carbon-element-PpxUeR2N.js → carbon-element-qvUUzdlm.js} +23 -23
- package/dist/{clike-BcRI5X0E.js → clike-CWAiRpcw.js} +23 -23
- package/dist/{clojure-C2IHkUPA.js → clojure-Ch3ZXkHC.js} +23 -23
- package/dist/{cmake-CJhCxpap.js → cmake-DJ6-M7RZ.js} +23 -23
- package/dist/{cobol-CFDSE9dZ.js → cobol-CefNQ_w0.js} +23 -23
- package/dist/{coffeescript-CURj13L6.js → coffeescript-4qvUnmrT.js} +23 -23
- package/dist/{collection-helpers-CzRdH5Lb.js → collection-helpers-DOm4PvT7.js} +23 -23
- package/dist/{commonlisp-DLkoJfhj.js → commonlisp-k5lBHlrn.js} +23 -23
- package/dist/{crystal-DedS5Vzh.js → crystal-DFd4Ih4u.js} +23 -23
- package/dist/{css-BypXLy0l.js → css-BhqlouBq.js} +23 -23
- package/dist/{custom-element-hMrhyYJ7.js → custom-element-BIWH1gT0.js} +23 -23
- package/dist/{cypher-BlL-7Ae0.js → cypher-BlVNs-s1.js} +23 -23
- package/dist/{d-ComvWfj7.js → d-CM_npLQV.js} +23 -23
- package/dist/{diff-BoSIXa2o.js → diff-7P1q5HUO.js} +23 -23
- package/dist/{dtd-C_ndqcjb.js → dtd-CWbJaDIV.js} +23 -23
- package/dist/{dylan-D7jWxiNW.js → dylan-EbE5y8Qm.js} +23 -23
- package/dist/{ebnf-Cdzhx-3O.js → ebnf-DbYI1jy4.js} +23 -23
- package/dist/{ecl-CjIaslgI.js → ecl-CFSa7Lym.js} +23 -23
- package/dist/{eiffel-hCXL6Hzk.js → eiffel-9Wtpmi2K.js} +23 -23
- package/dist/{elm-B2FABL8h.js → elm-DWhcgMBd.js} +23 -23
- package/dist/{erlang-ClnyfmZz.js → erlang-CR1HJySh.js} +23 -23
- package/dist/{fcl-CBMB3lji.js → fcl-CbvOTRm9.js} +23 -23
- package/dist/{forth-DgWLtPeN.js → forth-BsE0kFPn.js} +23 -23
- package/dist/{fortran-Cg40eZO_.js → fortran-AWWy4gQC.js} +23 -23
- package/dist/{gas-CEhqqWlu.js → gas-DjE-0YRJ.js} +23 -23
- package/dist/{gherkin-D5qmKtXD.js → gherkin-G3xXRA7g.js} +23 -23
- package/dist/{groovy-BRxJpyHw.js → groovy-CNwvtTN8.js} +23 -23
- package/dist/{haskell-5r5d3GWp.js → haskell-B--9zNgZ.js} +23 -23
- package/dist/{haxe-BXDNjS-F.js → haxe-BH6QOKpD.js} +23 -23
- package/dist/{http-RMcNtqTE.js → http-ZbVY0uts.js} +23 -23
- package/dist/{idl-Khw9YfYf.js → idl-D7fBoMHw.js} +23 -23
- package/dist/{javascript-DNcQn7za.js → javascript-BynWom2t.js} +23 -23
- package/dist/{julia-CoEZVOJ2.js → julia-BgwMKKt8.js} +23 -23
- package/dist/{lit-element-CQ-JjgUk.js → lit-element-CALvSsJe.js} +23 -23
- package/dist/{livescript-CMAVg7yW.js → livescript-CfylQWC2.js} +23 -23
- package/dist/{lua-BQ_ols-d.js → lua-bFmn3AKO.js} +23 -23
- package/dist/{mathematica-BZCuRavb.js → mathematica-Dws9P2fA.js} +23 -23
- package/dist/{mbox-BB3SftKu.js → mbox-BIh2BjAu.js} +23 -23
- package/dist/{mirc-DHtAJyAO.js → mirc-XnPCL3O-.js} +23 -23
- package/dist/{mllike-BLsWzAfZ.js → mllike-l-LEbnhM.js} +23 -23
- package/dist/{modelica-B276R2MG.js → modelica-BbO92hea.js} +23 -23
- package/dist/{mscgen-BDqesV2g.js → mscgen-CQJIxZ4W.js} +23 -23
- package/dist/{mumps-DDBLeXPz.js → mumps-CktIo_vc.js} +23 -23
- package/dist/{nginx-mb-Aga98.js → nginx-BOcx_Qcw.js} +23 -23
- package/dist/{ntriples-fhwVir-C.js → ntriples-C1FRJSj6.js} +23 -23
- package/dist/{octave-CaylO_Vc.js → octave-BOQo3ezn.js} +23 -23
- package/dist/{oz-Dh05qSSW.js → oz-OnSdrfM9.js} +23 -23
- package/dist/{pascal-63zXOTpO.js → pascal-4g6TYfFw.js} +23 -23
- package/dist/{perl-YLBat7Y_.js → perl-Dgr-ngbg.js} +23 -23
- package/dist/{pig-CpUGLxE0.js → pig-CZMi3-8m.js} +23 -23
- package/dist/{powershell-D-0C_k0n.js → powershell-DXvQ4x1m.js} +23 -23
- package/dist/{properties-DD0PUgdh.js → properties-FpKoskXV.js} +23 -23
- package/dist/{protobuf-CZ1s_eBQ.js → protobuf-MCw-m64T.js} +23 -23
- package/dist/{puppet-CwcTPQbC.js → puppet-6S-P5OOW.js} +23 -23
- package/dist/{python-CmvkgikI.js → python-CngGfBf0.js} +23 -23
- package/dist/{q-BWyI6IDo.js → q-44edCNj4.js} +23 -23
- package/dist/{query-NiN2ru73.js → query-D35TocCM.js} +23 -23
- package/dist/{r-kSNVbRo5.js → r-DIR8PHAo.js} +23 -23
- package/dist/{radio-group-manager-No5_drV3.js → radio-group-manager-BpBQjS73.js} +23 -23
- package/dist/{rpm-qSrPkZZG.js → rpm-BRQLtgp3.js} +23 -23
- package/dist/{ruby-P6s3XPo8.js → ruby-D8RNHeY9.js} +23 -23
- package/dist/{sas-BQWlj8o3.js → sas-D5OczIPs.js} +23 -23
- package/dist/{scheme-DQ-rMZD6.js → scheme-B8-CRLJA.js} +23 -23
- package/dist/{settings-BkQB2kcr.js → settings-llVPjFVY.js} +23 -23
- package/dist/{shell-BtjXl0_5.js → shell-D8CunHXO.js} +23 -23
- package/dist/{sieve-DZ5JhAHC.js → sieve-Bf_yZtZi.js} +23 -23
- package/dist/{simple-mode-XUd0AnfN.js → simple-mode-U-UkJvaV.js} +23 -23
- package/dist/{smalltalk-CwL8Wq0t.js → smalltalk-NwhojTAP.js} +23 -23
- package/dist/{solr-uusPPpvv.js → solr-DpsSZ9SG.js} +23 -23
- package/dist/{sparql-DSknSqv4.js → sparql-ClZP4ej6.js} +23 -23
- package/dist/{spreadsheet-CdCA4zLR.js → spreadsheet-DnW91EGa.js} +23 -23
- package/dist/{sql-v0_lDusO.js → sql-DoWohZH_.js} +23 -23
- package/dist/{stex-EBy3ayec.js → stex-CyIvgWqs.js} +23 -23
- package/dist/{stylus-Dl16Npcf.js → stylus-C8jtBncI.js} +23 -23
- package/dist/{swift-DSgSX742.js → swift-CaGCX2Dw.js} +23 -23
- package/dist/{sync-Bl70vkEu.js → sync-BXekdfhT.js} +23 -23
- package/dist/{tcl-Cikwf4s-.js → tcl-CZLOxvIM.js} +23 -23
- package/dist/{textile-BYnRCuKw.js → textile-MK6Fa0rE.js} +23 -23
- package/dist/{throttle-Yp_y_3mg.js → throttle-Bam9Y9Iz.js} +23 -23
- package/dist/{tiddlywiki-DfaFDhWw.js → tiddlywiki-DUbhySn3.js} +23 -23
- package/dist/{tiki-B4Xv4zUI.js → tiki-DaH-6R3-.js} +23 -23
- package/dist/{toml-BmBzmufK.js → toml-SjzHK0kN.js} +23 -23
- package/dist/{troff-hEGKg6bv.js → troff-Bz5Iai1v.js} +23 -23
- package/dist/{ttcn-J3U6ow4d.js → ttcn-C4gOnQYH.js} +23 -23
- package/dist/{ttcn-cfg-s_dlQaOf.js → ttcn-cfg-C8jO5Cys.js} +23 -23
- package/dist/{turtle-DetvELcp.js → turtle-C8Ccmmmk.js} +23 -23
- package/dist/{vb-CgyK0Pzn.js → vb-Cwma-1KF.js} +23 -23
- package/dist/{vbscript-VBj1G19a.js → vbscript-DMhmzc0h.js} +23 -23
- package/dist/{velocity-BGZcyv0R.js → velocity-RZxqTCZo.js} +23 -23
- package/dist/{verilog-FKqktXcv.js → verilog-Dld4vhaQ.js} +23 -23
- package/dist/{vhdl-Co-SIqiJ.js → vhdl-DMOFQvtW.js} +23 -23
- package/dist/{webidl-9OF0eUyD.js → webidl-BgptLqNm.js} +23 -23
- package/dist/{xquery-DtgT47pa.js → xquery-8Z_FGC6j.js} +23 -23
- package/dist/{yacas-CejZbYou.js → yacas-C3ZexFYq.js} +23 -23
- package/dist/{z80-CQ0L9hHY.js → z80-Dz8lvJzy.js} +23 -23
|
@@ -18,39 +18,39 @@
|
|
|
18
18
|
* https://www.npmjs.com/package/markdown-it
|
|
19
19
|
* https://www.npmjs.com/package/lodash-es
|
|
20
20
|
* https://www.npmjs.com/package/dompurify
|
|
21
|
-
* https://www.npmjs.com/package/csv-stringify
|
|
22
21
|
* https://www.npmjs.com/package/lit-html
|
|
22
|
+
* https://www.npmjs.com/package/csv-stringify
|
|
23
23
|
* https://www.npmjs.com/package/@carbon/web-components
|
|
24
24
|
* https://www.npmjs.com/package/codemirror
|
|
25
25
|
* https://www.npmjs.com/package/@codemirror/state
|
|
26
26
|
* https://www.npmjs.com/package/@codemirror/language
|
|
27
|
-
* https://www.npmjs.com/package/@codemirror/commands
|
|
28
|
-
* https://www.npmjs.com/package/@codemirror/lint
|
|
29
27
|
* https://www.npmjs.com/package/@codemirror/lang-cpp
|
|
30
|
-
* https://www.npmjs.com/package/@lezer/highlight
|
|
31
|
-
* https://www.npmjs.com/package/@codemirror/autocomplete
|
|
32
|
-
* https://www.npmjs.com/package/@codemirror/view
|
|
33
|
-
* https://www.npmjs.com/package/@codemirror/lang-javascript
|
|
34
|
-
* https://www.npmjs.com/package/@codemirror/lang-css
|
|
35
|
-
* https://www.npmjs.com/package/@codemirror/lang-sql
|
|
36
|
-
* https://www.npmjs.com/package/@codemirror/lang-java
|
|
37
28
|
* https://www.npmjs.com/package/@codemirror/lang-go
|
|
29
|
+
* https://www.npmjs.com/package/@codemirror/lang-sql
|
|
30
|
+
* https://www.npmjs.com/package/@codemirror/lang-css
|
|
38
31
|
* https://www.npmjs.com/package/@codemirror/lang-html
|
|
32
|
+
* https://www.npmjs.com/package/@codemirror/lang-java
|
|
33
|
+
* https://www.npmjs.com/package/@codemirror/lang-javascript
|
|
39
34
|
* https://www.npmjs.com/package/@codemirror/lang-jinja
|
|
40
|
-
* https://www.npmjs.com/package/@codemirror/lang-php
|
|
41
35
|
* https://www.npmjs.com/package/@codemirror/lang-less
|
|
42
|
-
* https://www.npmjs.com/package/@codemirror/lang-python
|
|
43
36
|
* https://www.npmjs.com/package/@codemirror/lang-liquid
|
|
44
|
-
* https://www.npmjs.com/package/@codemirror/lang-markdown
|
|
45
37
|
* https://www.npmjs.com/package/@codemirror/lang-json
|
|
38
|
+
* https://www.npmjs.com/package/@codemirror/lang-python
|
|
39
|
+
* https://www.npmjs.com/package/@codemirror/lang-php
|
|
40
|
+
* https://www.npmjs.com/package/@codemirror/lang-markdown
|
|
46
41
|
* https://www.npmjs.com/package/@codemirror/lang-sass
|
|
42
|
+
* https://www.npmjs.com/package/@codemirror/legacy-modes
|
|
47
43
|
* https://www.npmjs.com/package/@codemirror/lang-rust
|
|
48
|
-
* https://www.npmjs.com/package/@codemirror/lang-wast
|
|
49
44
|
* https://www.npmjs.com/package/@codemirror/lang-xml
|
|
50
45
|
* https://www.npmjs.com/package/@codemirror/lang-yaml
|
|
51
|
-
* https://www.npmjs.com/package/@codemirror/
|
|
46
|
+
* https://www.npmjs.com/package/@codemirror/lang-wast
|
|
52
47
|
* https://www.npmjs.com/package/@codemirror/lang-vue
|
|
53
48
|
* https://www.npmjs.com/package/@codemirror/lang-angular
|
|
49
|
+
* https://www.npmjs.com/package/@codemirror/lint
|
|
50
|
+
* https://www.npmjs.com/package/@codemirror/view
|
|
51
|
+
* https://www.npmjs.com/package/@lezer/highlight
|
|
52
|
+
* https://www.npmjs.com/package/@codemirror/autocomplete
|
|
53
|
+
* https://www.npmjs.com/package/@codemirror/commands
|
|
54
54
|
* https://www.npmjs.com/package/@carbon/icons
|
|
55
55
|
* https://www.npmjs.com/package/@carbon/utilities
|
|
56
56
|
* https://www.npmjs.com/package/@carbon/icon-helpers
|
|
@@ -64,23 +64,23 @@
|
|
|
64
64
|
* https://www.npmjs.com/package/@marijn/find-cluster-break
|
|
65
65
|
* https://www.npmjs.com/package/@lezer/common
|
|
66
66
|
* https://www.npmjs.com/package/@lezer/cpp
|
|
67
|
-
* https://www.npmjs.com/package/@lezer/
|
|
67
|
+
* https://www.npmjs.com/package/@lezer/go
|
|
68
68
|
* https://www.npmjs.com/package/@lezer/css
|
|
69
69
|
* https://www.npmjs.com/package/@lezer/lr
|
|
70
|
-
* https://www.npmjs.com/package/@lezer/go
|
|
71
70
|
* https://www.npmjs.com/package/@lezer/java
|
|
72
71
|
* https://www.npmjs.com/package/@lezer/html
|
|
73
|
-
* https://www.npmjs.com/package/@lezer/
|
|
74
|
-
* https://www.npmjs.com/package/@lezer/python
|
|
72
|
+
* https://www.npmjs.com/package/@lezer/javascript
|
|
75
73
|
* https://www.npmjs.com/package/@lezer/json
|
|
76
|
-
* https://www.npmjs.com/package/@lezer/
|
|
74
|
+
* https://www.npmjs.com/package/@lezer/python
|
|
75
|
+
* https://www.npmjs.com/package/@lezer/php
|
|
76
|
+
* https://www.npmjs.com/package/@lezer/xml
|
|
77
77
|
* https://www.npmjs.com/package/@lezer/sass
|
|
78
|
-
* https://www.npmjs.com/package/@lezer/yaml
|
|
79
78
|
* https://www.npmjs.com/package/@lezer/rust
|
|
80
|
-
* https://www.npmjs.com/package/@lezer/
|
|
79
|
+
* https://www.npmjs.com/package/@lezer/markdown
|
|
80
|
+
* https://www.npmjs.com/package/@lezer/yaml
|
|
81
81
|
* https://www.npmjs.com/package/@internationalized/number
|
|
82
|
-
* https://www.npmjs.com/package/mdurl
|
|
83
82
|
* https://www.npmjs.com/package/linkify-it
|
|
83
|
+
* https://www.npmjs.com/package/mdurl
|
|
84
84
|
* https://www.npmjs.com/package/punycode.js
|
|
85
85
|
* https://www.npmjs.com/package/uc.micro
|
|
86
86
|
* https://www.npmjs.com/package/@floating-ui/dom
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
* https://www.npmjs.com/package/@floating-ui/utils
|
|
89
89
|
*/
|
|
90
90
|
|
|
91
|
-
import{t}from"./throttle-Yp_y_3mg.js";import{_ as e}from"./radio-group-manager-No5_drV3.js";const i=1024;let n=0,s=class{constructor(t,e){this.from=t,this.to=e}};class o{constructor(t={}){this.id=n++,this.perNode=!!t.perNode,this.deserialize=t.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=t.combine||null}add(t){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return"function"!=typeof t&&(t=a.match(t)),e=>{let i=t(e);return void 0===i?null:[this,i]}}}o.closedBy=new o({deserialize:t=>t.split(" ")}),o.openedBy=new o({deserialize:t=>t.split(" ")}),o.group=new o({deserialize:t=>t.split(" ")}),o.isolate=new o({deserialize:t=>{if(t&&"rtl"!=t&&"ltr"!=t&&"auto"!=t)throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}}),o.contextHash=new o({perNode:!0}),o.lookAhead=new o({perNode:!0}),o.mounted=new o({perNode:!0});class r{constructor(t,e,i){this.tree=t,this.overlay=e,this.parser=i}static get(t){return t&&t.props&&t.props[o.mounted.id]}}const l=Object.create(null);class a{constructor(t,e,i,n=0){this.name=t,this.props=e,this.id=i,this.flags=n}static define(t){let e=t.props&&t.props.length?Object.create(null):l,i=(t.top?1:0)|(t.skipped?2:0)|(t.error?4:0)|(null==t.name?8:0),n=new a(t.name||"",e,t.id,i);if(t.props)for(let i of t.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");e[i[0].id]=i[1]}return n}prop(t){return this.props[t.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(t){if("string"==typeof t){if(this.name==t)return!0;let e=this.prop(o.group);return!!e&&e.indexOf(t)>-1}return this.id==t}static match(t){let e=Object.create(null);for(let i in t)for(let n of i.split(" "))e[n]=t[i];return t=>{for(let i=t.prop(o.group),n=-1;n<(i?i.length:0);n++){let s=e[n<0?t.name:i[n]];if(s)return s}}}}a.none=new a("",Object.create(null),0,8);class h{constructor(t){this.types=t;for(let e=0;e<t.length;e++)if(t[e].id!=e)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...t){let e=[];for(let i of this.types){let n=null;for(let e of t){let t=e(i);if(t){n||(n=Object.assign({},i.props));let e=t[1],s=t[0];s.combine&&s.id in n&&(e=s.combine(n[s.id],e)),n[s.id]=e}}e.push(n?new a(i.name,n,i.id,i.flags):i)}return new h(e)}}const c=new WeakMap,f=new WeakMap;var d;!function(t){t[t.ExcludeBuffers=1]="ExcludeBuffers",t[t.IncludeAnonymous=2]="IncludeAnonymous",t[t.IgnoreMounts=4]="IgnoreMounts",t[t.IgnoreOverlays=8]="IgnoreOverlays"}(d||(d={}));class u{constructor(t,e,i,n,s){if(this.type=t,this.children=e,this.positions=i,this.length=n,this.props=null,s&&s.length){this.props=Object.create(null);for(let[t,e]of s)this.props["number"==typeof t?t:t.id]=e}}toString(){let t=r.get(this);if(t&&!t.overlay)return t.tree.toString();let e="";for(let t of this.children){let i=t.toString();i&&(e&&(e+=","),e+=i)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(e.length?"("+e+")":""):e}cursor(t=0){return new M(this.topNode,t)}cursorAt(t,e=0,i=0){let n=c.get(this)||this.topNode,s=new M(n);return s.moveTo(t,e),c.set(this,s._tree),s}get topNode(){return new b(this,0,0,null)}resolve(t,e=0){let i=w(c.get(this)||this.topNode,t,e,!1);return c.set(this,i),i}resolveInner(t,e=0){let i=w(f.get(this)||this.topNode,t,e,!0);return f.set(this,i),i}resolveStack(t,e=0){return function(t,e,i){let n=t.resolveInner(e,i),s=null;for(let t=n instanceof b?n:n.context.parent;t;t=t.parent)if(t.index<0){let o=t.parent;(s||(s=[n])).push(o.resolve(e,i)),t=o}else{let o=r.get(t.tree);if(o&&o.overlay&&o.overlay[0].from<=e&&o.overlay[o.overlay.length-1].to>=e){let r=new b(o.tree,o.overlay[0].from+t.from,-1,t);(s||(s=[n])).push(w(r,e,i,!1))}}return s?C(s):n}(this,t,e)}iterate(t){let{enter:e,leave:i,from:n=0,to:s=this.length}=t,o=t.mode||0,r=(o&d.IncludeAnonymous)>0;for(let t=this.cursor(o|d.IncludeAnonymous);;){let o=!1;if(t.from<=s&&t.to>=n&&(!r&&t.type.isAnonymous||!1!==e(t))){if(t.firstChild())continue;o=!0}for(;o&&i&&(r||!t.type.isAnonymous)&&i(t),!t.nextSibling();){if(!t.parent())return;o=!0}}}prop(t){return t.perNode?this.props?this.props[t.id]:void 0:this.type.prop(t)}get propValues(){let t=[];if(this.props)for(let e in this.props)t.push([+e,this.props[e]]);return t}balance(t={}){return this.children.length<=8?this:L(a.none,this.children,this.positions,0,this.children.length,0,this.length,(t,e,i)=>new u(this.type,t,e,i,this.propValues),t.makeTree||((t,e,i)=>new u(a.none,t,e,i)))}static build(t){return function(t){var e;let{buffer:n,nodeSet:s,maxBufferLength:r=i,reused:l=[],minRepeatType:a=s.types.length}=t,h=Array.isArray(n)?new p(n,n.length):n,c=s.types,f=0,d=0;function g(t,e,i,n,o,u){let{id:p,start:S,end:C,size:A}=h,M=d,T=f;if(A<0){if(h.next(),-1==A){let e=l[p];return i.push(e),void n.push(S-t)}if(-3==A)return void(f=p);if(-4==A)return void(d=p);throw new RangeError(`Unrecognized record size: ${A}`)}let O,D,E=c[p],P=S-t;if(C-S<=r&&(D=x(h.pos-e,o))){let e=new Uint16Array(D.size-D.skip),i=h.pos-D.size,n=e.length;for(;h.pos>i;)n=k(D.start,e,n);O=new m(e,C-D.start,s),P=D.start-t}else{let t=h.pos-A;h.next();let e=[],i=[],n=p>=a?p:-1,s=0,o=C;for(;h.pos>t;)n>=0&&h.id==n&&h.size>=0?(h.end<=o-r&&(b(e,i,S,s,h.end,o,n,M,T),s=e.length,o=h.end),h.next()):u>2500?w(S,t,e,i):g(S,t,e,i,n,u+1);if(n>=0&&s>0&&s<e.length&&b(e,i,S,s,S,o,n,M,T),e.reverse(),i.reverse(),n>-1&&s>0){let t=v(E,T);O=L(E,e,i,0,e.length,0,C-S,t,t)}else O=y(E,e,i,C-S,M-C,T)}i.push(O),n.push(P)}function w(t,e,i,n){let o=[],l=0,a=-1;for(;h.pos>e;){let{id:t,start:e,end:i,size:n}=h;if(n>4)h.next();else{if(a>-1&&e<a)break;a<0&&(a=i-r),o.push(t,e,i),l++,h.next()}}if(l){let e=new Uint16Array(4*l),r=o[o.length-2];for(let t=o.length-3,i=0;t>=0;t-=3)e[i++]=o[t],e[i++]=o[t+1]-r,e[i++]=o[t+2]-r,e[i++]=i;i.push(new m(e,o[2]-r,s)),n.push(r-t)}}function v(t,e){return(i,n,s)=>{let r,l,a=0,h=i.length-1;if(h>=0&&(r=i[h])instanceof u){if(!h&&r.type==t&&r.length==s)return r;(l=r.prop(o.lookAhead))&&(a=n[h]+r.length+l)}return y(t,i,n,s,a,e)}}function b(t,e,i,n,o,r,l,a,h){let c=[],f=[];for(;t.length>n;)c.push(t.pop()),f.push(e.pop()+i-o);t.push(y(s.types[l],c,f,r-o,a-r,h)),e.push(o-i)}function y(t,e,i,n,s,r,l){if(r){let t=[o.contextHash,r];l=l?[t].concat(l):[t]}if(s>25){let t=[o.lookAhead,s];l=l?[t].concat(l):[t]}return new u(t,e,i,n,l)}function x(t,e){let i=h.fork(),n=0,s=0,o=0,l=i.end-r,c={size:0,start:0,skip:0};t:for(let r=i.pos-t;i.pos>r;){let t=i.size;if(i.id==e&&t>=0){c.size=n,c.start=s,c.skip=o,o+=4,n+=4,i.next();continue}let h=i.pos-t;if(t<0||h<r||i.start<l)break;let f=i.id>=a?4:0,d=i.start;for(i.next();i.pos>h;){if(i.size<0){if(-3!=i.size&&-4!=i.size)break t;f+=4}else i.id>=a&&(f+=4);i.next()}s=d,n+=t,o+=f}return(e<0||n==t)&&(c.size=n,c.start=s,c.skip=o),c.size>4?c:void 0}function k(t,e,i){let{id:n,start:s,end:o,size:r}=h;if(h.next(),r>=0&&n<a){let l=i;if(r>4){let n=h.pos-(r-4);for(;h.pos>n;)i=k(t,e,i)}e[--i]=l,e[--i]=o-t,e[--i]=s-t,e[--i]=n}else-3==r?f=n:-4==r&&(d=n);return i}let S=[],C=[];for(;h.pos>0;)g(t.start||0,t.bufferStart||0,S,C,-1,0);let A=null!==(e=t.length)&&void 0!==e?e:S.length?C[0]+S[0].length:0;return new u(c[t.topID],S.reverse(),C.reverse(),A)}(t)}}u.empty=new u(a.none,[],[],0);class p{constructor(t,e){this.buffer=t,this.index=e}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 p(this.buffer,this.index)}}class m{constructor(t,e,i){this.buffer=t,this.length=e,this.set=i}get type(){return a.none}toString(){let t=[];for(let e=0;e<this.buffer.length;)t.push(this.childString(e)),e=this.buffer[e+3];return t.join(",")}childString(t){let e=this.buffer[t],i=this.buffer[t+3],n=this.set.types[e],s=n.name;if(/\W/.test(s)&&!n.isError&&(s=JSON.stringify(s)),i==(t+=4))return s;let o=[];for(;t<i;)o.push(this.childString(t)),t=this.buffer[t+3];return s+"("+o.join(",")+")"}findChild(t,e,i,n,s){let{buffer:o}=this,r=-1;for(let l=t;l!=e&&!(g(s,n,o[l+1],o[l+2])&&(r=l,i>0));l=o[l+3]);return r}slice(t,e,i){let n=this.buffer,s=new Uint16Array(e-t),o=0;for(let r=t,l=0;r<e;){s[l++]=n[r++],s[l++]=n[r++]-i;let e=s[l++]=n[r++]-i;s[l++]=n[r++]-t,o=Math.max(o,e)}return new m(s,o,this.set)}}function g(t,e,i,n){switch(t){case-2:return i<e;case-1:return n>=e&&i<e;case 0:return i<e&&n>e;case 1:return i<=e&&n>e;case 2:return n>e;case 4:return!0}}function w(t,e,i,n){for(var s;t.from==t.to||(i<1?t.from>=e:t.from>e)||(i>-1?t.to<=e:t.to<e);){let e=!n&&t instanceof b&&t.index<0?null:t.parent;if(!e)return t;t=e}let o=n?0:d.IgnoreOverlays;if(n)for(let n=t,r=n.parent;r;n=r,r=n.parent)n instanceof b&&n.index<0&&(null===(s=r.enter(e,i,o))||void 0===s?void 0:s.from)!=n.from&&(t=r);for(;;){let n=t.enter(e,i,o);if(!n)return t;t=n}}class v{cursor(t=0){return new M(this,t)}getChild(t,e=null,i=null){let n=y(this,t,e,i);return n.length?n[0]:null}getChildren(t,e=null,i=null){return y(this,t,e,i)}resolve(t,e=0){return w(this,t,e,!1)}resolveInner(t,e=0){return w(this,t,e,!0)}matchContext(t){return x(this.parent,t)}enterUnfinishedNodesBefore(t){let e=this.childBefore(t),i=this;for(;e;){let t=e.lastChild;if(!t||t.to!=e.to)break;t.type.isError&&t.from==t.to?(i=e,e=t.prevSibling):e=t}return i}get node(){return this}get next(){return this.parent}}class b extends v{constructor(t,e,i,n){super(),this._tree=t,this.from=e,this.index=i,this._parent=n}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(t,e,i,n,s=0){for(let o=this;;){for(let{children:l,positions:a}=o._tree,h=e>0?l.length:-1;t!=h;t+=e){let h=l[t],c=a[t]+o.from;if(g(n,i,c,c+h.length))if(h instanceof m){if(s&d.ExcludeBuffers)continue;let r=h.findChild(0,h.buffer.length,e,i-c,n);if(r>-1)return new S(new k(o,h,t,c),null,r)}else if(s&d.IncludeAnonymous||!h.type.isAnonymous||T(h)){let l;if(!(s&d.IgnoreMounts)&&(l=r.get(h))&&!l.overlay)return new b(l.tree,c,t,o);let a=new b(h,c,t,o);return s&d.IncludeAnonymous||!a.type.isAnonymous?a:a.nextChild(e<0?h.children.length-1:0,e,i,n)}}if(s&d.IncludeAnonymous||!o.type.isAnonymous)return null;if(t=o.index>=0?o.index+e:e<0?-1:o._parent._tree.children.length,o=o._parent,!o)return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(t){return this.nextChild(0,1,t,2)}childBefore(t){return this.nextChild(this._tree.children.length-1,-1,t,-2)}prop(t){return this._tree.prop(t)}enter(t,e,i=0){let n;if(!(i&d.IgnoreOverlays)&&(n=r.get(this._tree))&&n.overlay){let i=t-this.from;for(let{from:t,to:s}of n.overlay)if((e>0?t<=i:t<i)&&(e<0?s>=i:s>i))return new b(n.tree,n.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,e,i)}nextSignificantParent(){let t=this;for(;t.type.isAnonymous&&t._parent;)t=t._parent;return t}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 tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function y(t,e,i,n){let s=t.cursor(),o=[];if(!s.firstChild())return o;if(null!=i)for(let t=!1;!t;)if(t=s.type.is(i),!s.nextSibling())return o;for(;;){if(null!=n&&s.type.is(n))return o;if(s.type.is(e)&&o.push(s.node),!s.nextSibling())return null==n?o:[]}}function x(t,e,i=e.length-1){for(let n=t;i>=0;n=n.parent){if(!n)return!1;if(!n.type.isAnonymous){if(e[i]&&e[i]!=n.name)return!1;i--}}return!0}class k{constructor(t,e,i,n){this.parent=t,this.buffer=e,this.index=i,this.start=n}}class S extends v{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]}constructor(t,e,i){super(),this.context=t,this._parent=e,this.index=i,this.type=t.buffer.set.types[t.buffer.buffer[i]]}child(t,e,i){let{buffer:n}=this.context,s=n.findChild(this.index+4,n.buffer[this.index+3],t,e-this.context.start,i);return s<0?null:new S(this.context,this,s)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(t){return this.child(1,t,2)}childBefore(t){return this.child(-1,t,-2)}prop(t){return this.type.prop(t)}enter(t,e,i=0){if(i&d.ExcludeBuffers)return null;let{buffer:n}=this.context,s=n.findChild(this.index+4,n.buffer[this.index+3],e>0?1:-1,t-this.context.start,e);return s<0?null:new S(this.context,this,s)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(t){return this._parent?null:this.context.parent.nextChild(this.context.index+t,t,0,4)}get nextSibling(){let{buffer:t}=this.context,e=t.buffer[this.index+3];return e<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length)?new S(this.context,this._parent,e):this.externalSibling(1)}get prevSibling(){let{buffer:t}=this.context,e=this._parent?this._parent.index+4:0;return this.index==e?this.externalSibling(-1):new S(this.context,this._parent,t.findChild(e,this.index,-1,0,4))}get tree(){return null}toTree(){let t=[],e=[],{buffer:i}=this.context,n=this.index+4,s=i.buffer[this.index+3];if(s>n){let o=i.buffer[this.index+1];t.push(i.slice(n,s,o)),e.push(0)}return new u(this.type,t,e,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function C(t){if(!t.length)return null;let e=0,i=t[0];for(let n=1;n<t.length;n++){let s=t[n];(s.from>i.from||s.to<i.to)&&(i=s,e=n)}let n=i instanceof b&&i.index<0?null:i.parent,s=t.slice();return n?s[e]=n:s.splice(e,1),new A(s,i)}class A{constructor(t,e){this.heads=t,this.node=e}get next(){return C(this.heads)}}class M{get name(){return this.type.name}constructor(t,e=0){if(this.mode=e,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,t instanceof b)this.yieldNode(t);else{this._tree=t.context.parent,this.buffer=t.context;for(let e=t._parent;e;e=e._parent)this.stack.unshift(e.index);this.bufferNode=t,this.yieldBuf(t.index)}}yieldNode(t){return!!t&&(this._tree=t,this.type=t.type,this.from=t.from,this.to=t.to,!0)}yieldBuf(t,e){this.index=t;let{start:i,buffer:n}=this.buffer;return this.type=e||n.set.types[n.buffer[t]],this.from=i+n.buffer[t+1],this.to=i+n.buffer[t+2],!0}yield(t){return!!t&&(t instanceof b?(this.buffer=null,this.yieldNode(t)):(this.buffer=t.context,this.yieldBuf(t.index,t.type)))}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(t,e,i){if(!this.buffer)return this.yield(this._tree.nextChild(t<0?this._tree._tree.children.length-1:0,t,e,i,this.mode));let{buffer:n}=this.buffer,s=n.findChild(this.index+4,n.buffer[this.index+3],t,e-this.buffer.start,i);return!(s<0)&&(this.stack.push(this.index),this.yieldBuf(s))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(t){return this.enterChild(1,t,2)}childBefore(t){return this.enterChild(-1,t,-2)}enter(t,e,i=this.mode){return this.buffer?!(i&d.ExcludeBuffers)&&this.enterChild(1,t,e):this.yield(this._tree.enter(t,e,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&d.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let t=this.mode&d.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(t)}sibling(t){if(!this.buffer)return!!this._tree._parent&&this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+t,t,0,4,this.mode));let{buffer:e}=this.buffer,i=this.stack.length-1;if(t<0){let t=i<0?0:this.stack[i]+4;if(this.index!=t)return this.yieldBuf(e.findChild(t,this.index,-1,0,4))}else{let t=e.buffer[this.index+3];if(t<(i<0?e.buffer.length:e.buffer[this.stack[i]+3]))return this.yieldBuf(t)}return i<0&&this.yield(this.buffer.parent.nextChild(this.buffer.index+t,t,0,4,this.mode))}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(t){let e,i,{buffer:n}=this;if(n){if(t>0){if(this.index<n.buffer.buffer.length)return!1}else for(let t=0;t<this.index;t++)if(n.buffer.buffer[t+3]<this.index)return!1;({index:e,parent:i}=n)}else({index:e,_parent:i}=this._tree);for(;i;({index:e,_parent:i}=i))if(e>-1)for(let n=e+t,s=t<0?-1:i._tree.children.length;n!=s;n+=t){let t=i._tree.children[n];if(this.mode&d.IncludeAnonymous||t instanceof m||!t.type.isAnonymous||T(t))return!1}return!0}move(t,e){if(e&&this.enterChild(t,0,4))return!0;for(;;){if(this.sibling(t))return!0;if(this.atLastNode(t)||!this.parent())return!1}}next(t=!0){return this.move(1,t)}prev(t=!0){return this.move(-1,t)}moveTo(t,e=0){for(;(this.from==this.to||(e<1?this.from>=t:this.from>t)||(e>-1?this.to<=t:this.to<t))&&this.parent(););for(;this.enterChild(1,t,e););return this}get node(){if(!this.buffer)return this._tree;let t=this.bufferNode,e=null,i=0;if(t&&t.context==this.buffer)t:for(let n=this.index,s=this.stack.length;s>=0;){for(let o=t;o;o=o._parent)if(o.index==n){if(n==this.index)return o;e=o,i=s+1;break t}n=this.stack[--s]}for(let t=i;t<this.stack.length;t++)e=new S(this.buffer,e,this.stack[t]);return this.bufferNode=new S(this.buffer,e,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(t,e){for(let i=0;;){let n=!1;if(this.type.isAnonymous||!1!==t(this)){if(this.firstChild()){i++;continue}this.type.isAnonymous||(n=!0)}for(;;){if(n&&e&&e(this),n=this.type.isAnonymous,!i)return;if(this.nextSibling())break;this.parent(),i--,n=!0}}}matchContext(t){if(!this.buffer)return x(this.node.parent,t);let{buffer:e}=this.buffer,{types:i}=e.set;for(let n=t.length-1,s=this.stack.length-1;n>=0;s--){if(s<0)return x(this._tree,t,n);let o=i[e.buffer[this.stack[s]]];if(!o.isAnonymous){if(t[n]&&t[n]!=o.name)return!1;n--}}return!0}}function T(t){return t.children.some(t=>t instanceof m||!t.type.isAnonymous||T(t))}const O=new WeakMap;function D(t,e){if(!t.isAnonymous||e instanceof m||e.type!=t)return 1;let i=O.get(e);if(null==i){i=1;for(let n of e.children){if(n.type!=t||!(n instanceof u)){i=1;break}i+=D(t,n)}O.set(e,i)}return i}function L(t,e,i,n,s,o,r,l,a){let h=0;for(let i=n;i<s;i++)h+=D(t,e[i]);let c=Math.ceil(1.5*h/8),f=[],d=[];return function e(i,n,s,r,l){for(let h=s;h<r;){let s=h,u=n[h],p=D(t,i[h]);for(h++;h<r;h++){let e=D(t,i[h]);if(p+e>=c)break;p+=e}if(h==s+1){if(p>c){let t=i[s];e(t.children,t.positions,0,t.children.length,n[s]+l);continue}f.push(i[s])}else{let e=n[h-1]+i[h-1].length-u;f.push(L(t,i,n,s,h,u,e,null,a))}d.push(u+l-o)}}(e,i,n,s,0),(l||a)(f,d,r)}class E{constructor(){this.map=new WeakMap}setBuffer(t,e,i){let n=this.map.get(t);n||this.map.set(t,n=new Map),n.set(e,i)}getBuffer(t,e){let i=this.map.get(t);return i&&i.get(e)}set(t,e){t instanceof S?this.setBuffer(t.context.buffer,t.index,e):t instanceof b&&this.map.set(t.tree,e)}get(t){return t instanceof S?this.getBuffer(t.context.buffer,t.index):t instanceof b?this.map.get(t.tree):void 0}cursorSet(t,e){t.buffer?this.setBuffer(t.buffer.buffer,t.index,e):this.map.set(t.tree,e)}cursorGet(t){return t.buffer?this.getBuffer(t.buffer.buffer,t.index):this.map.get(t.tree)}}class P{constructor(t,e,i,n,s=!1,o=!1){this.from=t,this.to=e,this.tree=i,this.offset=n,this.open=(s?1:0)|(o?2:0)}get openStart(){return(1&this.open)>0}get openEnd(){return(2&this.open)>0}static addTree(t,e=[],i=!1){let n=[new P(0,t.length,t,0,!1,i)];for(let i of e)i.to>t.length&&n.push(i);return n}static applyChanges(t,e,i=128){if(!e.length)return t;let n=[],s=1,o=t.length?t[0]:null;for(let r=0,l=0,a=0;;r++){let h=r<e.length?e[r]:null,c=h?h.fromA:1e9;if(c-l>=i)for(;o&&o.from<c;){let e=o;if(l>=e.from||c<=e.to||a){let t=Math.max(e.from,l)-a,i=Math.min(e.to,c)-a;e=t>=i?null:new P(t,i,e.tree,e.offset+a,r>0,!!h)}if(e&&n.push(e),o.to>c)break;o=s<t.length?t[s++]:null}if(!h)break;l=h.toA,a=h.toA-h.toB}return n}}class B{startParse(t,e,i){return"string"==typeof t&&(t=new R(t)),i=i?i.length?i.map(t=>new s(t.from,t.to)):[new s(0,0)]:[new s(0,t.length)],this.createParse(t,e||[],i)}parse(t,e,i){let n=this.startParse(t,e,i);for(;;){let t=n.advance();if(t)return t}}}class R{constructor(t){this.string=t}get length(){return this.string.length}chunk(t){return this.string.slice(t)}get lineChunks(){return!1}read(t,e){return this.string.slice(t,e)}}function N(t){return(e,i,n,s)=>new F(e,t,i,n,s)}class I{constructor(t,e,i,n,s){this.parser=t,this.parse=e,this.overlay=i,this.target=n,this.from=s}}function j(t){if(!t.length||t.some(t=>t.from>=t.to))throw new RangeError("Invalid inner parse ranges given: "+JSON.stringify(t))}class H{constructor(t,e,i,n,s,o,r){this.parser=t,this.predicate=e,this.mounts=i,this.index=n,this.start=s,this.target=o,this.prev=r,this.depth=0,this.ranges=[]}}const V=new o({perNode:!0});class F{constructor(t,e,i,n,s){this.nest=e,this.input=i,this.fragments=n,this.ranges=s,this.inner=[],this.innerDone=0,this.baseTree=null,this.stoppedAt=null,this.baseParse=t}advance(){if(this.baseParse){let t=this.baseParse.advance();if(!t)return null;if(this.baseParse=null,this.baseTree=t,this.startInner(),null!=this.stoppedAt)for(let t of this.inner)t.parse.stopAt(this.stoppedAt)}if(this.innerDone==this.inner.length){let t=this.baseTree;return null!=this.stoppedAt&&(t=new u(t.type,t.children,t.positions,t.length,t.propValues.concat([[V,this.stoppedAt]]))),t}let t=this.inner[this.innerDone],e=t.parse.advance();if(e){this.innerDone++;let i=Object.assign(Object.create(null),t.target.props);i[o.mounted.id]=new r(e,t.overlay,t.parser),t.target.props=i}return null}get parsedPos(){if(this.baseParse)return 0;let t=this.input.length;for(let e=this.innerDone;e<this.inner.length;e++)this.inner[e].from<t&&(t=Math.min(t,this.inner[e].parse.parsedPos));return t}stopAt(t){if(this.stoppedAt=t,this.baseParse)this.baseParse.stopAt(t);else for(let e=this.innerDone;e<this.inner.length;e++)this.inner[e].parse.stopAt(t)}startInner(){let t=new K(this.fragments),e=null,i=null,n=new M(new b(this.baseTree,this.ranges[0].from,0,null),d.IncludeAnonymous|d.IgnoreMounts);t:for(let o,r;;){let l,a=!0;if(null!=this.stoppedAt&&n.from>=this.stoppedAt)a=!1;else if(t.hasNode(n)){if(e){let t=e.mounts.find(t=>t.frag.from<=n.from&&t.frag.to>=n.to&&t.mount.overlay);if(t)for(let i of t.mount.overlay){let s=i.from+t.pos,o=i.to+t.pos;s>=n.from&&o<=n.to&&!e.ranges.some(t=>t.from<o&&t.to>s)&&e.ranges.push({from:s,to:o})}}a=!1}else if(i&&(r=z(i.ranges,n.from,n.to)))a=2!=r;else if(!n.type.isAnonymous&&(o=this.nest(n,this.input))&&(n.from<n.to||!o.overlay)){n.tree||(q(n),e&&e.depth++,i&&i.depth++);let r=t.findMounts(n.from,o.parser);if("function"==typeof o.overlay)e=new H(o.parser,o.overlay,r,this.inner.length,n.from,n.tree,e);else{let t=$(this.ranges,o.overlay||(n.from<n.to?[new s(n.from,n.to)]:[]));t.length&&j(t),!t.length&&o.overlay||this.inner.push(new I(o.parser,t.length?o.parser.startParse(this.input,G(r,t),t):o.parser.startParse(""),o.overlay?o.overlay.map(t=>new s(t.from-n.from,t.to-n.from)):null,n.tree,t.length?t[0].from:n.from)),o.overlay?t.length&&(i={ranges:t,depth:0,prev:i}):a=!1}}else if(e&&(l=e.predicate(n))&&(!0===l&&(l=new s(n.from,n.to)),l.from<l.to)){let t=e.ranges.length-1;t>=0&&e.ranges[t].to==l.from?e.ranges[t]={from:e.ranges[t].from,to:l.to}:e.ranges.push(l)}if(a&&n.firstChild())e&&e.depth++,i&&i.depth++;else for(;!n.nextSibling();){if(!n.parent())break t;if(e&&! --e.depth){let t=$(this.ranges,e.ranges);t.length&&(j(t),this.inner.splice(e.index,0,new I(e.parser,e.parser.startParse(this.input,G(e.mounts,t),t),e.ranges.map(t=>new s(t.from-e.start,t.to-e.start)),e.target,t[0].from))),e=e.prev}i&&! --i.depth&&(i=i.prev)}}}}function z(t,e,i){for(let n of t){if(n.from>=i)break;if(n.to>e)return n.from<=e&&n.to>=i?2:1}return 0}function W(t,e,i,n,s,o){if(e<i){let r=t.buffer[e+1];n.push(t.slice(e,i,r)),s.push(r-o)}}function q(t){let{node:e}=t,i=[],n=e.context.buffer;do{i.push(t.index),t.parent()}while(!t.tree);let s=t.tree,o=s.children.indexOf(n),r=s.children[o],l=r.buffer,h=[o];s.children[o]=function t(n,s,o,a,c,f){let d=i[f],p=[],m=[];W(r,n,d,p,m,a);let g=l[d+1],w=l[d+2];h.push(p.length);let v=f?t(d+4,l[d+3],r.set.types[l[d]],g,w-g,f-1):e.toTree();return p.push(v),m.push(g-a),W(r,l[d+3],s,p,m,a),new u(o,p,m,c)}(0,l.length,a.none,0,r.length,i.length-1);for(let e of h){let i=t.tree.children[e],n=t.tree.positions[e];t.yield(new b(i,n+t.from,e,t._tree))}}class _{constructor(t,e){this.offset=e,this.done=!1,this.cursor=t.cursor(d.IncludeAnonymous|d.IgnoreMounts)}moveTo(t){let{cursor:e}=this,i=t-this.offset;for(;!this.done&&e.from<i;)e.to>=t&&e.enter(i,1,d.IgnoreOverlays|d.ExcludeBuffers)||e.next(!1)||(this.done=!0)}hasNode(t){if(this.moveTo(t.from),!this.done&&this.cursor.from+this.offset==t.from&&this.cursor.tree)for(let e=this.cursor.tree;;){if(e==t.tree)return!0;if(!(e.children.length&&0==e.positions[0]&&e.children[0]instanceof u))break;e=e.children[0]}return!1}}class K{constructor(t){var e;if(this.fragments=t,this.curTo=0,this.fragI=0,t.length){let i=this.curFrag=t[0];this.curTo=null!==(e=i.tree.prop(V))&&void 0!==e?e:i.to,this.inner=new _(i.tree,-i.offset)}else this.curFrag=this.inner=null}hasNode(t){for(;this.curFrag&&t.from>=this.curTo;)this.nextFrag();return this.curFrag&&this.curFrag.from<=t.from&&this.curTo>=t.to&&this.inner.hasNode(t)}nextFrag(){var t;if(this.fragI++,this.fragI==this.fragments.length)this.curFrag=this.inner=null;else{let e=this.curFrag=this.fragments[this.fragI];this.curTo=null!==(t=e.tree.prop(V))&&void 0!==t?t:e.to,this.inner=new _(e.tree,-e.offset)}}findMounts(t,e){var i;let n=[];if(this.inner){this.inner.cursor.moveTo(t,1);for(let t=this.inner.cursor.node;t;t=t.parent){let s=null===(i=t.tree)||void 0===i?void 0:i.prop(o.mounted);if(s&&s.parser==e)for(let e=this.fragI;e<this.fragments.length;e++){let i=this.fragments[e];if(i.from>=t.to)break;i.tree==this.curFrag.tree&&n.push({frag:i,pos:t.from-i.offset,mount:s})}}}return n}}function $(t,e){let i=null,n=e;for(let o=1,r=0;o<t.length;o++){let l=t[o-1].to,a=t[o].from;for(;r<n.length;r++){let t=n[r];if(t.from>=a)break;t.to<=l||(i||(n=i=e.slice()),t.from<l?(i[r]=new s(t.from,l),t.to>a&&i.splice(r+1,0,new s(a,t.to))):t.to>a?i[r--]=new s(a,t.to):i.splice(r--,1))}}return n}function U(t,e,i,n){let o=0,r=0,l=!1,a=!1,h=-1e9,c=[];for(;;){let f=o==t.length?1e9:l?t[o].to:t[o].from,d=r==e.length?1e9:a?e[r].to:e[r].from;if(l!=a){let t=Math.max(h,i),e=Math.min(f,d,n);t<e&&c.push(new s(t,e))}if(h=Math.min(f,d),1e9==h)break;f==h&&(l?(l=!1,o++):l=!0),d==h&&(a?(a=!1,r++):a=!0)}return c}function G(t,e){let i=[];for(let{pos:n,mount:o,frag:r}of t){let t=n+(o.overlay?o.overlay[0].from:0),l=t+o.tree.length,a=Math.max(r.from,t),h=Math.min(r.to,l);if(o.overlay){let l=U(e,o.overlay.map(t=>new s(t.from+n,t.to+n)),a,h);for(let e=0,n=a;;e++){let s=e==l.length,a=s?h:l[e].from;if(a>n&&i.push(new P(n,a,o.tree,-t,r.from>=n||r.openStart,r.to<=a||r.openEnd)),s)break;n=l[e].to}}else i.push(new P(a,h,o.tree,-t,r.from>=t||r.openStart,r.to<=l||r.openEnd))}return i}let Y=[],J=[];function X(t){if(t<768)return!1;for(let e=0,i=Y.length;;){let n=e+i>>1;if(t<Y[n])i=n;else{if(!(t>=J[n]))return!0;e=n+1}if(e==i)return!1}}function Q(t){return t>=127462&&t<=127487}(()=>{let t="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(t=>t?parseInt(t,36):1);for(let e=0,i=0;e<t.length;e++)(e%2?J:Y).push(i+=t[e])})();function Z(t,e,i=!0,n=!0){return(i?tt:et)(t,e,n)}function tt(t,e,i){if(e==t.length)return e;e&&nt(t.charCodeAt(e))&&st(t.charCodeAt(e-1))&&e--;let n=it(t,e);for(e+=ot(n);e<t.length;){let s=it(t,e);if(8205==n||8205==s||i&&X(s))e+=ot(s),n=s;else{if(!Q(s))break;{let i=0,n=e-2;for(;n>=0&&Q(it(t,n));)i++,n-=2;if(i%2==0)break;e+=2}}}return e}function et(t,e,i){for(;e>0;){let n=tt(t,e-2,i);if(n<e)return n;e--}return 0}function it(t,e){let i=t.charCodeAt(e);if(!st(i)||e+1==t.length)return i;let n=t.charCodeAt(e+1);return nt(n)?n-56320+(i-55296<<10)+65536:i}function nt(t){return t>=56320&&t<57344}function st(t){return t>=55296&&t<56320}function ot(t){return t<65536?1:2}class rt{lineAt(t){if(t<0||t>this.length)throw new RangeError(`Invalid position ${t} in document of length ${this.length}`);return this.lineInner(t,!1,1,0)}line(t){if(t<1||t>this.lines)throw new RangeError(`Invalid line number ${t} in ${this.lines}-line document`);return this.lineInner(t,!0,1,0)}replace(t,e,i){[t,e]=mt(this,t,e);let n=[];return this.decompose(0,t,n,2),i.length&&i.decompose(0,i.length,n,3),this.decompose(e,this.length,n,1),at.from(n,this.length-(e-t)+i.length)}append(t){return this.replace(this.length,this.length,t)}slice(t,e=this.length){[t,e]=mt(this,t,e);let i=[];return this.decompose(t,e,i,0),at.from(i,e-t)}eq(t){if(t==this)return!0;if(t.length!=this.length||t.lines!=this.lines)return!1;let e=this.scanIdentical(t,1),i=this.length-this.scanIdentical(t,-1),n=new ft(this),s=new ft(t);for(let t=e,o=e;;){if(n.next(t),s.next(t),t=0,n.lineBreak!=s.lineBreak||n.done!=s.done||n.value!=s.value)return!1;if(o+=n.value.length,n.done||o>=i)return!0}}iter(t=1){return new ft(this,t)}iterRange(t,e=this.length){return new dt(this,t,e)}iterLines(t,e){let i;if(null==t)i=this.iter();else{null==e&&(e=this.lines+1);let n=this.line(t).from;i=this.iterRange(n,Math.max(n,e==this.lines+1?this.length:e<=1?0:this.line(e-1).to))}return new ut(i)}toString(){return this.sliceString(0)}toJSON(){let t=[];return this.flatten(t),t}constructor(){}static of(t){if(0==t.length)throw new RangeError("A document must have at least one line");return 1!=t.length||t[0]?t.length<=32?new lt(t):at.from(lt.split(t,[])):rt.empty}}class lt extends rt{constructor(t,e=function(t){let e=-1;for(let i of t)e+=i.length+1;return e}(t)){super(),this.text=t,this.length=e}get lines(){return this.text.length}get children(){return null}lineInner(t,e,i,n){for(let s=0;;s++){let o=this.text[s],r=n+o.length;if((e?i:r)>=t)return new pt(n,r,i,o);n=r+1,i++}}decompose(t,e,i,n){let s=t<=0&&e>=this.length?this:new lt(ct(this.text,t,e),Math.min(e,this.length)-Math.max(0,t));if(1&n){let t=i.pop(),e=ht(s.text,t.text.slice(),0,s.length);if(e.length<=32)i.push(new lt(e,t.length+s.length));else{let t=e.length>>1;i.push(new lt(e.slice(0,t)),new lt(e.slice(t)))}}else i.push(s)}replace(t,e,i){if(!(i instanceof lt))return super.replace(t,e,i);[t,e]=mt(this,t,e);let n=ht(this.text,ht(i.text,ct(this.text,0,t)),e),s=this.length+i.length-(e-t);return n.length<=32?new lt(n,s):at.from(lt.split(n,[]),s)}sliceString(t,e=this.length,i="\n"){[t,e]=mt(this,t,e);let n="";for(let s=0,o=0;s<=e&&o<this.text.length;o++){let r=this.text[o],l=s+r.length;s>t&&o&&(n+=i),t<l&&e>s&&(n+=r.slice(Math.max(0,t-s),e-s)),s=l+1}return n}flatten(t){for(let e of this.text)t.push(e)}scanIdentical(){return 0}static split(t,e){let i=[],n=-1;for(let s of t)i.push(s),n+=s.length+1,32==i.length&&(e.push(new lt(i,n)),i=[],n=-1);return n>-1&&e.push(new lt(i,n)),e}}class at extends rt{constructor(t,e){super(),this.children=t,this.length=e,this.lines=0;for(let e of t)this.lines+=e.lines}lineInner(t,e,i,n){for(let s=0;;s++){let o=this.children[s],r=n+o.length,l=i+o.lines-1;if((e?l:r)>=t)return o.lineInner(t,e,i,n);n=r+1,i=l+1}}decompose(t,e,i,n){for(let s=0,o=0;o<=e&&s<this.children.length;s++){let r=this.children[s],l=o+r.length;if(t<=l&&e>=o){let s=n&((o<=t?1:0)|(l>=e?2:0));o>=t&&l<=e&&!s?i.push(r):r.decompose(t-o,e-o,i,s)}o=l+1}}replace(t,e,i){if([t,e]=mt(this,t,e),i.lines<this.lines)for(let n=0,s=0;n<this.children.length;n++){let o=this.children[n],r=s+o.length;if(t>=s&&e<=r){let l=o.replace(t-s,e-s,i),a=this.lines-o.lines+l.lines;if(l.lines<a>>4&&l.lines>a>>6){let s=this.children.slice();return s[n]=l,new at(s,this.length-(e-t)+i.length)}return super.replace(s,r,l)}s=r+1}return super.replace(t,e,i)}sliceString(t,e=this.length,i="\n"){[t,e]=mt(this,t,e);let n="";for(let s=0,o=0;s<this.children.length&&o<=e;s++){let r=this.children[s],l=o+r.length;o>t&&s&&(n+=i),t<l&&e>o&&(n+=r.sliceString(t-o,e-o,i)),o=l+1}return n}flatten(t){for(let e of this.children)e.flatten(t)}scanIdentical(t,e){if(!(t instanceof at))return 0;let i=0,[n,s,o,r]=e>0?[0,0,this.children.length,t.children.length]:[this.children.length-1,t.children.length-1,-1,-1];for(;;n+=e,s+=e){if(n==o||s==r)return i;let l=this.children[n],a=t.children[s];if(l!=a)return i+l.scanIdentical(a,e);i+=l.length+1}}static from(t,e=t.reduce((t,e)=>t+e.length+1,-1)){let i=0;for(let e of t)i+=e.lines;if(i<32){let i=[];for(let e of t)e.flatten(i);return new lt(i,e)}let n=Math.max(32,i>>5),s=n<<1,o=n>>1,r=[],l=0,a=-1,h=[];function c(t){let e;if(t.lines>s&&t instanceof at)for(let e of t.children)c(e);else t.lines>o&&(l>o||!l)?(f(),r.push(t)):t instanceof lt&&l&&(e=h[h.length-1])instanceof lt&&t.lines+e.lines<=32?(l+=t.lines,a+=t.length+1,h[h.length-1]=new lt(e.text.concat(t.text),e.length+1+t.length)):(l+t.lines>n&&f(),l+=t.lines,a+=t.length+1,h.push(t))}function f(){0!=l&&(r.push(1==h.length?h[0]:at.from(h,a)),a=-1,l=h.length=0)}for(let e of t)c(e);return f(),1==r.length?r[0]:new at(r,e)}}function ht(t,e,i=0,n=1e9){for(let s=0,o=0,r=!0;o<t.length&&s<=n;o++){let l=t[o],a=s+l.length;a>=i&&(a>n&&(l=l.slice(0,n-s)),s<i&&(l=l.slice(i-s)),r?(e[e.length-1]+=l,r=!1):e.push(l)),s=a+1}return e}function ct(t,e,i){return ht(t,[""],e,i)}rt.empty=new lt([""],0);class ft{constructor(t,e=1){this.dir=e,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[t],this.offsets=[e>0?1:(t instanceof lt?t.text.length:t.children.length)<<1]}nextInner(t,e){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,n=this.nodes[i],s=this.offsets[i],o=s>>1,r=n instanceof lt?n.text.length:n.children.length;if(o==(e>0?r:0)){if(0==i)return this.done=!0,this.value="",this;e>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((1&s)==(e>0?0:1)){if(this.offsets[i]+=e,0==t)return this.lineBreak=!0,this.value="\n",this;t--}else if(n instanceof lt){let s=n.text[o+(e<0?-1:0)];if(this.offsets[i]+=e,s.length>Math.max(0,t))return this.value=0==t?s:e>0?s.slice(t):s.slice(0,s.length-t),this;t-=s.length}else{let s=n.children[o+(e<0?-1:0)];t>s.length?(t-=s.length,this.offsets[i]+=e):(e<0&&this.offsets[i]--,this.nodes.push(s),this.offsets.push(e>0?1:(s instanceof lt?s.text.length:s.children.length)<<1))}}}next(t=0){return t<0&&(this.nextInner(-t,-this.dir),t=this.value.length),this.nextInner(t,this.dir)}}class dt{constructor(t,e,i){this.value="",this.done=!1,this.cursor=new ft(t,e>i?-1:1),this.pos=e>i?t.length:0,this.from=Math.min(e,i),this.to=Math.max(e,i)}nextInner(t,e){if(e<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;t+=Math.max(0,e<0?this.pos-this.to:this.from-this.pos);let i=e<0?this.pos-this.from:this.to-this.pos;t>i&&(t=i),i-=t;let{value:n}=this.cursor.next(t);return this.pos+=(n.length+t)*e,this.value=n.length<=i?n:e<0?n.slice(n.length-i):n.slice(0,i),this.done=!this.value,this}next(t=0){return t<0?t=Math.max(t,this.from-this.pos):t>0&&(t=Math.min(t,this.to-this.pos)),this.nextInner(t,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&""!=this.value}}class ut{constructor(t){this.inner=t,this.afterBreak=!0,this.value="",this.done=!1}next(t=0){let{done:e,lineBreak:i,value:n}=this.inner.next(t);return e&&this.afterBreak?(this.value="",this.afterBreak=!1):e?(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&&(rt.prototype[Symbol.iterator]=function(){return this.iter()},ft.prototype[Symbol.iterator]=dt.prototype[Symbol.iterator]=ut.prototype[Symbol.iterator]=function(){return this});class pt{constructor(t,e,i,n){this.from=t,this.to=e,this.number=i,this.text=n}get length(){return this.to-this.from}}function mt(t,e,i){return[e=Math.max(0,Math.min(t.length,e)),Math.max(e,Math.min(t.length,i))]}function gt(t,e,i=!0,n=!0){return Z(t,e,i,n)}function wt(t,e){let i=t.charCodeAt(e);if(!(n=i,n>=55296&&n<56320&&e+1!=t.length))return i;var n;let s=t.charCodeAt(e+1);return function(t){return t>=56320&&t<57344}(s)?s-56320+(i-55296<<10)+65536:i}function vt(t){return t<65536?1:2}const bt=/\r\n?|\n/;var yt=function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t}(yt||(yt={}));class xt{constructor(t){this.sections=t}get length(){let t=0;for(let e=0;e<this.sections.length;e+=2)t+=this.sections[e];return t}get newLength(){let t=0;for(let e=0;e<this.sections.length;e+=2){let i=this.sections[e+1];t+=i<0?this.sections[e]:i}return t}get empty(){return 0==this.sections.length||2==this.sections.length&&this.sections[1]<0}iterGaps(t){for(let e=0,i=0,n=0;e<this.sections.length;){let s=this.sections[e++],o=this.sections[e++];o<0?(t(i,n,s),n+=s):n+=o,i+=s}}iterChangedRanges(t,e=!1){At(this,t,e)}get invertedDesc(){let t=[];for(let e=0;e<this.sections.length;){let i=this.sections[e++],n=this.sections[e++];n<0?t.push(i,n):t.push(n,i)}return new xt(t)}composeDesc(t){return this.empty?t:t.empty?this:Tt(this,t)}mapDesc(t,e=!1){return t.empty?this:Mt(this,t,e)}mapPos(t,e=-1,i=yt.Simple){let n=0,s=0;for(let o=0;o<this.sections.length;){let r=this.sections[o++],l=this.sections[o++],a=n+r;if(l<0){if(a>t)return s+(t-n);s+=r}else{if(i!=yt.Simple&&a>=t&&(i==yt.TrackDel&&n<t&&a>t||i==yt.TrackBefore&&n<t||i==yt.TrackAfter&&a>t))return null;if(a>t||a==t&&e<0&&!r)return t==n||e<0?s:s+l;s+=l}n=a}if(t>n)throw new RangeError(`Position ${t} is out of range for changeset of length ${n}`);return s}touchesRange(t,e=t){for(let i=0,n=0;i<this.sections.length&&n<=e;){let s=n+this.sections[i++];if(this.sections[i++]>=0&&n<=e&&s>=t)return!(n<t&&s>e)||"cover";n=s}return!1}toString(){let t="";for(let e=0;e<this.sections.length;){let i=this.sections[e++],n=this.sections[e++];t+=(t?" ":"")+i+(n>=0?":"+n:"")}return t}toJSON(){return this.sections}static fromJSON(t){if(!Array.isArray(t)||t.length%2||t.some(t=>"number"!=typeof t))throw new RangeError("Invalid JSON representation of ChangeDesc");return new xt(t)}static create(t){return new xt(t)}}class kt extends xt{constructor(t,e){super(t),this.inserted=e}apply(t){if(this.length!=t.length)throw new RangeError("Applying change set to a document with the wrong length");return At(this,(e,i,n,s,o)=>t=t.replace(n,n+(i-e),o),!1),t}mapDesc(t,e=!1){return Mt(this,t,e,!0)}invert(t){let e=this.sections.slice(),i=[];for(let n=0,s=0;n<e.length;n+=2){let o=e[n],r=e[n+1];if(r>=0){e[n]=r,e[n+1]=o;let l=n>>1;for(;i.length<l;)i.push(rt.empty);i.push(o?t.slice(s,s+o):rt.empty)}s+=o}return new kt(e,i)}compose(t){return this.empty?t:t.empty?this:Tt(this,t,!0)}map(t,e=!1){return t.empty?this:Mt(this,t,e,!0)}iterChanges(t,e=!1){At(this,t,e)}get desc(){return xt.create(this.sections)}filter(t){let e=[],i=[],n=[],s=new Ot(this);t:for(let o=0,r=0;;){let l=o==t.length?1e9:t[o++];for(;r<l||r==l&&0==s.len;){if(s.done)break t;let t=Math.min(s.len,l-r);St(n,t,-1);let o=-1==s.ins?-1:0==s.off?s.ins:0;St(e,t,o),o>0&&Ct(i,e,s.text),s.forward(t),r+=t}let a=t[o++];for(;r<a;){if(s.done)break t;let t=Math.min(s.len,a-r);St(e,t,-1),St(n,t,-1==s.ins?-1:0==s.off?s.ins:0),s.forward(t),r+=t}}return{changes:new kt(e,i),filtered:xt.create(n)}}toJSON(){let t=[];for(let e=0;e<this.sections.length;e+=2){let i=this.sections[e],n=this.sections[e+1];n<0?t.push(i):0==n?t.push([i]):t.push([i].concat(this.inserted[e>>1].toJSON()))}return t}static of(t,e,i){let n=[],s=[],o=0,r=null;function l(t=!1){if(!t&&!n.length)return;o<e&&St(n,e-o,-1);let i=new kt(n,s);r=r?r.compose(i.map(r)):i,n=[],s=[],o=0}return function t(a){if(Array.isArray(a))for(let e of a)t(e);else if(a instanceof kt){if(a.length!=e)throw new RangeError(`Mismatched change set length (got ${a.length}, expected ${e})`);l(),r=r?r.compose(a.map(r)):a}else{let{from:t,to:r=t,insert:h}=a;if(t>r||t<0||r>e)throw new RangeError(`Invalid change range ${t} to ${r} (in doc of length ${e})`);let c=h?"string"==typeof h?rt.of(h.split(i||bt)):h:rt.empty,f=c.length;if(t==r&&0==f)return;t<o&&l(),t>o&&St(n,t-o,-1),St(n,r-t,f),Ct(s,n,c),o=r}}(t),l(!r),r}static empty(t){return new kt(t?[t,-1]:[],[])}static fromJSON(t){if(!Array.isArray(t))throw new RangeError("Invalid JSON representation of ChangeSet");let e=[],i=[];for(let n=0;n<t.length;n++){let s=t[n];if("number"==typeof s)e.push(s,-1);else{if(!Array.isArray(s)||"number"!=typeof s[0]||s.some((t,e)=>e&&"string"!=typeof t))throw new RangeError("Invalid JSON representation of ChangeSet");if(1==s.length)e.push(s[0],0);else{for(;i.length<n;)i.push(rt.empty);i[n]=rt.of(s.slice(1)),e.push(s[0],i[n].length)}}}return new kt(e,i)}static createSet(t,e){return new kt(t,e)}}function St(t,e,i,n=!1){if(0==e&&i<=0)return;let s=t.length-2;s>=0&&i<=0&&i==t[s+1]?t[s]+=e:s>=0&&0==e&&0==t[s]?t[s+1]+=i:n?(t[s]+=e,t[s+1]+=i):t.push(e,i)}function Ct(t,e,i){if(0==i.length)return;let n=e.length-2>>1;if(n<t.length)t[t.length-1]=t[t.length-1].append(i);else{for(;t.length<n;)t.push(rt.empty);t.push(i)}}function At(t,e,i){let n=t.inserted;for(let s=0,o=0,r=0;r<t.sections.length;){let l=t.sections[r++],a=t.sections[r++];if(a<0)s+=l,o+=l;else{let h=s,c=o,f=rt.empty;for(;h+=l,c+=a,a&&n&&(f=f.append(n[r-2>>1])),!(i||r==t.sections.length||t.sections[r+1]<0);)l=t.sections[r++],a=t.sections[r++];e(s,h,o,c,f),s=h,o=c}}}function Mt(t,e,i,n=!1){let s=[],o=n?[]:null,r=new Ot(t),l=new Ot(e);for(let t=-1;;){if(r.done&&l.len||l.done&&r.len)throw new Error("Mismatched change set lengths");if(-1==r.ins&&-1==l.ins){let t=Math.min(r.len,l.len);St(s,t,-1),r.forward(t),l.forward(t)}else if(l.ins>=0&&(r.ins<0||t==r.i||0==r.off&&(l.len<r.len||l.len==r.len&&!i))){let e=l.len;for(St(s,l.ins,-1);e;){let i=Math.min(r.len,e);r.ins>=0&&t<r.i&&r.len<=i&&(St(s,0,r.ins),o&&Ct(o,s,r.text),t=r.i),r.forward(i),e-=i}l.next()}else{if(!(r.ins>=0)){if(r.done&&l.done)return o?kt.createSet(s,o):xt.create(s);throw new Error("Mismatched change set lengths")}{let e=0,i=r.len;for(;i;)if(-1==l.ins){let t=Math.min(i,l.len);e+=t,i-=t,l.forward(t)}else{if(!(0==l.ins&&l.len<i))break;i-=l.len,l.next()}St(s,e,t<r.i?r.ins:0),o&&t<r.i&&Ct(o,s,r.text),t=r.i,r.forward(r.len-i)}}}}function Tt(t,e,i=!1){let n=[],s=i?[]:null,o=new Ot(t),r=new Ot(e);for(let t=!1;;){if(o.done&&r.done)return s?kt.createSet(n,s):xt.create(n);if(0==o.ins)St(n,o.len,0,t),o.next();else if(0!=r.len||r.done){if(o.done||r.done)throw new Error("Mismatched change set lengths");{let e=Math.min(o.len2,r.len),i=n.length;if(-1==o.ins){let i=-1==r.ins?-1:r.off?0:r.ins;St(n,e,i,t),s&&i&&Ct(s,n,r.text)}else-1==r.ins?(St(n,o.off?0:o.len,e,t),s&&Ct(s,n,o.textBit(e))):(St(n,o.off?0:o.len,r.off?0:r.ins,t),s&&!r.off&&Ct(s,n,r.text));t=(o.ins>e||r.ins>=0&&r.len>e)&&(t||n.length>i),o.forward2(e),r.forward(e)}}else St(n,0,r.ins,t),s&&Ct(s,n,r.text),r.next()}}class Ot{constructor(t){this.set=t,this.i=0,this.next()}next(){let{sections:t}=this.set;this.i<t.length?(this.len=t[this.i++],this.ins=t[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return-2==this.ins}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:t}=this.set,e=this.i-2>>1;return e>=t.length?rt.empty:t[e]}textBit(t){let{inserted:e}=this.set,i=this.i-2>>1;return i>=e.length&&!t?rt.empty:e[i].slice(this.off,null==t?void 0:this.off+t)}forward(t){t==this.len?this.next():(this.len-=t,this.off+=t)}forward2(t){-1==this.ins?this.forward(t):t==this.ins?this.next():(this.ins-=t,this.off+=t)}}class Dt{constructor(t,e,i){this.from=t,this.to=e,this.flags=i}get anchor(){return 32&this.flags?this.to:this.from}get head(){return 32&this.flags?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return 8&this.flags?-1:16&this.flags?1:0}get bidiLevel(){let t=7&this.flags;return 7==t?null:t}get goalColumn(){let t=this.flags>>6;return 16777215==t?void 0:t}map(t,e=-1){let i,n;return this.empty?i=n=t.mapPos(this.from,e):(i=t.mapPos(this.from,1),n=t.mapPos(this.to,-1)),i==this.from&&n==this.to?this:new Dt(i,n,this.flags)}extend(t,e=t){if(t<=this.anchor&&e>=this.anchor)return Lt.range(t,e);let i=Math.abs(t-this.anchor)>Math.abs(e-this.anchor)?t:e;return Lt.range(this.anchor,i)}eq(t,e=!1){return!(this.anchor!=t.anchor||this.head!=t.head||e&&this.empty&&this.assoc!=t.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(t){if(!t||"number"!=typeof t.anchor||"number"!=typeof t.head)throw new RangeError("Invalid JSON representation for SelectionRange");return Lt.range(t.anchor,t.head)}static create(t,e,i){return new Dt(t,e,i)}}class Lt{constructor(t,e){this.ranges=t,this.mainIndex=e}map(t,e=-1){return t.empty?this:Lt.create(this.ranges.map(i=>i.map(t,e)),this.mainIndex)}eq(t,e=!1){if(this.ranges.length!=t.ranges.length||this.mainIndex!=t.mainIndex)return!1;for(let i=0;i<this.ranges.length;i++)if(!this.ranges[i].eq(t.ranges[i],e))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return 1==this.ranges.length?this:new Lt([this.main],0)}addRange(t,e=!0){return Lt.create([t].concat(this.ranges),e?0:this.mainIndex+1)}replaceRange(t,e=this.mainIndex){let i=this.ranges.slice();return i[e]=t,Lt.create(i,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(t=>t.toJSON()),main:this.mainIndex}}static fromJSON(t){if(!t||!Array.isArray(t.ranges)||"number"!=typeof t.main||t.main>=t.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new Lt(t.ranges.map(t=>Dt.fromJSON(t)),t.main)}static single(t,e=t){return new Lt([Lt.range(t,e)],0)}static create(t,e=0){if(0==t.length)throw new RangeError("A selection needs at least one range");for(let i=0,n=0;n<t.length;n++){let s=t[n];if(s.empty?s.from<=i:s.from<i)return Lt.normalized(t.slice(),e);i=s.to}return new Lt(t,e)}static cursor(t,e=0,i,n){return Dt.create(t,t,(0==e?0:e<0?8:16)|(null==i?7:Math.min(6,i))|(null!=n?n:16777215)<<6)}static range(t,e,i,n){let s=(null!=i?i:16777215)<<6|(null==n?7:Math.min(6,n));return e<t?Dt.create(e,t,48|s):Dt.create(t,e,(e>t?8:0)|s)}static normalized(t,e=0){let i=t[e];t.sort((t,e)=>t.from-e.from),e=t.indexOf(i);for(let i=1;i<t.length;i++){let n=t[i],s=t[i-1];if(n.empty?n.from<=s.to:n.from<s.to){let o=s.from,r=Math.max(n.to,s.to);i<=e&&e--,t.splice(--i,2,n.anchor>n.head?Lt.range(r,o):Lt.range(o,r))}}return new Lt(t,e)}}function Et(t,e){for(let i of t.ranges)if(i.to>e)throw new RangeError("Selection points outside of document")}let Pt=0;class Bt{constructor(t,e,i,n,s){this.combine=t,this.compareInput=e,this.compare=i,this.isStatic=n,this.id=Pt++,this.default=t([]),this.extensions="function"==typeof s?s(this):s}get reader(){return this}static define(t={}){return new Bt(t.combine||(t=>t),t.compareInput||((t,e)=>t===e),t.compare||(t.combine?(t,e)=>t===e:Rt),!!t.static,t.enables)}of(t){return new Nt([],this,0,t)}compute(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new Nt(t,this,1,e)}computeN(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new Nt(t,this,2,e)}from(t,e){return e||(e=t=>t),this.compute([t],i=>e(i.field(t)))}}function Rt(t,e){return t==e||t.length==e.length&&t.every((t,i)=>t===e[i])}class Nt{constructor(t,e,i,n){this.dependencies=t,this.facet=e,this.type=i,this.value=n,this.id=Pt++}dynamicSlot(t){var e;let i=this.value,n=this.facet.compareInput,s=this.id,o=t[s]>>1,r=2==this.type,l=!1,a=!1,h=[];for(let i of this.dependencies)"doc"==i?l=!0:"selection"==i?a=!0:1&(null!==(e=t[i.id])&&void 0!==e?e:1)||h.push(t[i.id]);return{create:t=>(t.values[o]=i(t),1),update(t,e){if(l&&e.docChanged||a&&(e.docChanged||e.selection)||jt(t,h)){let e=i(t);if(r?!It(e,t.values[o],n):!n(e,t.values[o]))return t.values[o]=e,1}return 0},reconfigure:(t,e)=>{let l,a=e.config.address[s];if(null!=a){let s=Qt(e,a);if(this.dependencies.every(i=>i instanceof Bt?e.facet(i)===t.facet(i):!(i instanceof Ft)||e.field(i,!1)==t.field(i,!1))||(r?It(l=i(t),s,n):n(l=i(t),s)))return t.values[o]=s,0}else l=i(t);return t.values[o]=l,1}}}}function It(t,e,i){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!i(t[n],e[n]))return!1;return!0}function jt(t,e){let i=!1;for(let n of e)1&Xt(t,n)&&(i=!0);return i}function Ht(t,e,i){let n=i.map(e=>t[e.id]),s=i.map(t=>t.type),o=n.filter(t=>!(1&t)),r=t[e.id]>>1;function l(t){let i=[];for(let e=0;e<n.length;e++){let o=Qt(t,n[e]);if(2==s[e])for(let t of o)i.push(t);else i.push(o)}return e.combine(i)}return{create(t){for(let e of n)Xt(t,e);return t.values[r]=l(t),1},update(t,i){if(!jt(t,o))return 0;let n=l(t);return e.compare(n,t.values[r])?0:(t.values[r]=n,1)},reconfigure(t,s){let o=jt(t,n),a=s.config.facets[e.id],h=s.facet(e);if(a&&!o&&Rt(i,a))return t.values[r]=h,0;let c=l(t);return e.compare(c,h)?(t.values[r]=h,0):(t.values[r]=c,1)}}}const Vt=Bt.define({static:!0});class Ft{constructor(t,e,i,n,s){this.id=t,this.createF=e,this.updateF=i,this.compareF=n,this.spec=s,this.provides=void 0}static define(t){let e=new Ft(Pt++,t.create,t.update,t.compare||((t,e)=>t===e),t);return t.provide&&(e.provides=t.provide(e)),e}create(t){let e=t.facet(Vt).find(t=>t.field==this);return((null==e?void 0:e.create)||this.createF)(t)}slot(t){let e=t[this.id]>>1;return{create:t=>(t.values[e]=this.create(t),1),update:(t,i)=>{let n=t.values[e],s=this.updateF(n,i);return this.compareF(n,s)?0:(t.values[e]=s,1)},reconfigure:(t,i)=>{let n,s=t.facet(Vt),o=i.facet(Vt);return(n=s.find(t=>t.field==this))&&n!=o.find(t=>t.field==this)?(t.values[e]=n.create(t),1):null!=i.config.address[this.id]?(t.values[e]=i.field(this),0):(t.values[e]=this.create(t),1)}}}init(t){return[this,Vt.of({field:this,create:t})]}get extension(){return this}}const zt=4,Wt=3,qt=2,_t=1;function Kt(t){return e=>new Ut(e,t)}const $t={highest:Kt(0),high:Kt(_t),default:Kt(qt),low:Kt(Wt),lowest:Kt(zt)};class Ut{constructor(t,e){this.inner=t,this.prec=e}}class Gt{of(t){return new Yt(this,t)}reconfigure(t){return Gt.reconfigure.of({compartment:this,extension:t})}get(t){return t.config.compartments.get(this)}}class Yt{constructor(t,e){this.compartment=t,this.inner=e}}class Jt{constructor(t,e,i,n,s,o){for(this.base=t,this.compartments=e,this.dynamicSlots=i,this.address=n,this.staticValues=s,this.facets=o,this.statusTemplate=[];this.statusTemplate.length<i.length;)this.statusTemplate.push(0)}staticFacet(t){let e=this.address[t.id];return null==e?t.default:this.staticValues[e>>1]}static resolve(t,e,i){let n=[],s=Object.create(null),o=new Map;for(let i of function(t,e,i){let n=[[],[],[],[],[]],s=new Map;function o(t,r){let l=s.get(t);if(null!=l){if(l<=r)return;let e=n[l].indexOf(t);e>-1&&n[l].splice(e,1),t instanceof Yt&&i.delete(t.compartment)}if(s.set(t,r),Array.isArray(t))for(let e of t)o(e,r);else if(t instanceof Yt){if(i.has(t.compartment))throw new RangeError("Duplicate use of compartment in extensions");let n=e.get(t.compartment)||t.inner;i.set(t.compartment,n),o(n,r)}else if(t instanceof Ut)o(t.inner,t.prec);else if(t instanceof Ft)n[r].push(t),t.provides&&o(t.provides,r);else if(t instanceof Nt)n[r].push(t),t.facet.extensions&&o(t.facet.extensions,qt);else{let e=t.extension;if(!e)throw new Error(`Unrecognized extension value in extension set (${t}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);o(e,r)}}return o(t,qt),n.reduce((t,e)=>t.concat(e))}(t,e,o))i instanceof Ft?n.push(i):(s[i.facet.id]||(s[i.facet.id]=[])).push(i);let r=Object.create(null),l=[],a=[];for(let t of n)r[t.id]=a.length<<1,a.push(e=>t.slot(e));let h=null==i?void 0:i.config.facets;for(let t in s){let e=s[t],n=e[0].facet,o=h&&h[t]||[];if(e.every(t=>0==t.type))if(r[n.id]=l.length<<1|1,Rt(o,e))l.push(i.facet(n));else{let t=n.combine(e.map(t=>t.value));l.push(i&&n.compare(t,i.facet(n))?i.facet(n):t)}else{for(let t of e)0==t.type?(r[t.id]=l.length<<1|1,l.push(t.value)):(r[t.id]=a.length<<1,a.push(e=>t.dynamicSlot(e)));r[n.id]=a.length<<1,a.push(t=>Ht(t,n,e))}}let c=a.map(t=>t(r));return new Jt(t,o,c,r,l,s)}}function Xt(t,e){if(1&e)return 2;let i=e>>1,n=t.status[i];if(4==n)throw new Error("Cyclic dependency between fields and/or facets");if(2&n)return n;t.status[i]=4;let s=t.computeSlot(t,t.config.dynamicSlots[i]);return t.status[i]=2|s}function Qt(t,e){return 1&e?t.config.staticValues[e>>1]:t.values[e>>1]}const Zt=Bt.define(),te=Bt.define({combine:t=>t.some(t=>t),static:!0}),ee=Bt.define({combine:t=>t.length?t[0]:void 0,static:!0}),ie=Bt.define(),ne=Bt.define(),se=Bt.define(),oe=Bt.define({combine:t=>!!t.length&&t[0]});class re{constructor(t,e){this.type=t,this.value=e}static define(){return new le}}class le{of(t){return new re(this,t)}}class ae{constructor(t){this.map=t}of(t){return new he(this,t)}}class he{constructor(t,e){this.type=t,this.value=e}map(t){let e=this.type.map(this.value,t);return void 0===e?void 0:e==this.value?this:new he(this.type,e)}is(t){return this.type==t}static define(t={}){return new ae(t.map||(t=>t))}static mapEffects(t,e){if(!t.length)return t;let i=[];for(let n of t){let t=n.map(e);t&&i.push(t)}return i}}he.reconfigure=he.define(),he.appendConfig=he.define();class ce{constructor(t,e,i,n,s,o){this.startState=t,this.changes=e,this.selection=i,this.effects=n,this.annotations=s,this.scrollIntoView=o,this._doc=null,this._state=null,i&&Et(i,e.newLength),s.some(t=>t.type==ce.time)||(this.annotations=s.concat(ce.time.of(Date.now())))}static create(t,e,i,n,s,o){return new ce(t,e,i,n,s,o)}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(t){for(let e of this.annotations)if(e.type==t)return e.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(t){let e=this.annotation(ce.userEvent);return!(!e||!(e==t||e.length>t.length&&e.slice(0,t.length)==t&&"."==e[t.length]))}}function fe(t,e){let i=[];for(let n=0,s=0;;){let o,r;if(n<t.length&&(s==e.length||e[s]>=t[n]))o=t[n++],r=t[n++];else{if(!(s<e.length))return i;o=e[s++],r=e[s++]}!i.length||i[i.length-1]<o?i.push(o,r):i[i.length-1]<r&&(i[i.length-1]=r)}}function de(t,e,i){var n;let s,o,r;return i?(s=e.changes,o=kt.empty(e.changes.length),r=t.changes.compose(e.changes)):(s=e.changes.map(t.changes),o=t.changes.mapDesc(e.changes,!0),r=t.changes.compose(s)),{changes:r,selection:e.selection?e.selection.map(o):null===(n=t.selection)||void 0===n?void 0:n.map(s),effects:he.mapEffects(t.effects,s).concat(he.mapEffects(e.effects,o)),annotations:t.annotations.length?t.annotations.concat(e.annotations):e.annotations,scrollIntoView:t.scrollIntoView||e.scrollIntoView}}function ue(t,e,i){let n=e.selection,s=ge(e.annotations);return e.userEvent&&(s=s.concat(ce.userEvent.of(e.userEvent))),{changes:e.changes instanceof kt?e.changes:kt.of(e.changes||[],i,t.facet(ee)),selection:n&&(n instanceof Lt?n:Lt.single(n.anchor,n.head)),effects:ge(e.effects),annotations:s,scrollIntoView:!!e.scrollIntoView}}function pe(t,e,i){let n=ue(t,e.length?e[0]:{},t.doc.length);e.length&&!1===e[0].filter&&(i=!1);for(let s=1;s<e.length;s++){!1===e[s].filter&&(i=!1);let o=!!e[s].sequential;n=de(n,ue(t,e[s],o?n.changes.newLength:t.doc.length),o)}let s=ce.create(t,n.changes,n.selection,n.effects,n.annotations,n.scrollIntoView);return function(t){let e=t.startState,i=e.facet(se),n=t;for(let s=i.length-1;s>=0;s--){let o=i[s](t);o&&Object.keys(o).length&&(n=de(n,ue(e,o,t.changes.newLength),!0))}return n==t?t:ce.create(e,t.changes,t.selection,n.effects,n.annotations,n.scrollIntoView)}(i?function(t){let e=t.startState,i=!0;for(let n of e.facet(ie)){let e=n(t);if(!1===e){i=!1;break}Array.isArray(e)&&(i=!0===i?e:fe(i,e))}if(!0!==i){let n,s;if(!1===i)s=t.changes.invertedDesc,n=kt.empty(e.doc.length);else{let e=t.changes.filter(i);n=e.changes,s=e.filtered.mapDesc(e.changes).invertedDesc}t=ce.create(e,n,t.selection&&t.selection.map(s),he.mapEffects(t.effects,s),t.annotations,t.scrollIntoView)}let n=e.facet(ne);for(let i=n.length-1;i>=0;i--){let s=n[i](t);t=s instanceof ce?s:Array.isArray(s)&&1==s.length&&s[0]instanceof ce?s[0]:pe(e,ge(s),!1)}return t}(s):s)}ce.time=re.define(),ce.userEvent=re.define(),ce.addToHistory=re.define(),ce.remote=re.define();const me=[];function ge(t){return null==t?me:Array.isArray(t)?t:[t]}var we=function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t}(we||(we={}));const ve=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let be;try{be=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch(t){}function ye(t){return e=>{if(!/\S/.test(e))return we.Space;if(function(t){if(be)return be.test(t);for(let e=0;e<t.length;e++){let i=t[e];if(/\w/.test(i)||i>""&&(i.toUpperCase()!=i.toLowerCase()||ve.test(i)))return!0}return!1}(e))return we.Word;for(let i=0;i<t.length;i++)if(e.indexOf(t[i])>-1)return we.Word;return we.Other}}class xe{constructor(t,e,i,n,s,o){this.config=t,this.doc=e,this.selection=i,this.values=n,this.status=t.statusTemplate.slice(),this.computeSlot=s,o&&(o._state=this);for(let t=0;t<this.config.dynamicSlots.length;t++)Xt(this,t<<1);this.computeSlot=null}field(t,e=!0){let i=this.config.address[t.id];if(null!=i)return Xt(this,i),Qt(this,i);if(e)throw new RangeError("Field is not present in this state")}update(...t){return pe(this,t,!0)}applyTransaction(t){let e,i=this.config,{base:n,compartments:s}=i;for(let e of t.effects)e.is(Gt.reconfigure)?(i&&(s=new Map,i.compartments.forEach((t,e)=>s.set(e,t)),i=null),s.set(e.value.compartment,e.value.extension)):e.is(he.reconfigure)?(i=null,n=e.value):e.is(he.appendConfig)&&(i=null,n=ge(n).concat(e.value));if(i)e=t.startState.values.slice();else{i=Jt.resolve(n,s,this),e=new xe(i,this.doc,this.selection,i.dynamicSlots.map(()=>null),(t,e)=>e.reconfigure(t,this),null).values}let o=t.startState.facet(te)?t.newSelection:t.newSelection.asSingle();new xe(i,t.newDoc,o,e,(e,i)=>i.update(e,t),t)}replaceSelection(t){return"string"==typeof t&&(t=this.toText(t)),this.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:t},range:Lt.cursor(e.from+t.length)}))}changeByRange(t){let e=this.selection,i=t(e.ranges[0]),n=this.changes(i.changes),s=[i.range],o=ge(i.effects);for(let i=1;i<e.ranges.length;i++){let r=t(e.ranges[i]),l=this.changes(r.changes),a=l.map(n);for(let t=0;t<i;t++)s[t]=s[t].map(a);let h=n.mapDesc(l,!0);s.push(r.range.map(h)),n=n.compose(a),o=he.mapEffects(o,a).concat(he.mapEffects(ge(r.effects),h))}return{changes:n,selection:Lt.create(s,e.mainIndex),effects:o}}changes(t=[]){return t instanceof kt?t:kt.of(t,this.doc.length,this.facet(xe.lineSeparator))}toText(t){return rt.of(t.split(this.facet(xe.lineSeparator)||bt))}sliceDoc(t=0,e=this.doc.length){return this.doc.sliceString(t,e,this.lineBreak)}facet(t){let e=this.config.address[t.id];return null==e?t.default:(Xt(this,e),Qt(this,e))}toJSON(t){let e={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(t)for(let i in t){let n=t[i];n instanceof Ft&&null!=this.config.address[n.id]&&(e[i]=n.spec.toJSON(this.field(t[i]),this))}return e}static fromJSON(t,e={},i){if(!t||"string"!=typeof t.doc)throw new RangeError("Invalid JSON representation for EditorState");let n=[];if(i)for(let e in i)if(Object.prototype.hasOwnProperty.call(t,e)){let s=i[e],o=t[e];n.push(s.init(t=>s.spec.fromJSON(o,t)))}return xe.create({doc:t.doc,selection:Lt.fromJSON(t.selection),extensions:e.extensions?n.concat([e.extensions]):n})}static create(t={}){let e=Jt.resolve(t.extensions||[],new Map),i=t.doc instanceof rt?t.doc:rt.of((t.doc||"").split(e.staticFacet(xe.lineSeparator)||bt)),n=t.selection?t.selection instanceof Lt?t.selection:Lt.single(t.selection.anchor,t.selection.head):Lt.single(0);return Et(n,i.length),e.staticFacet(te)||(n=n.asSingle()),new xe(e,i,n,e.dynamicSlots.map(()=>null),(t,e)=>e.create(t),null)}get tabSize(){return this.facet(xe.tabSize)}get lineBreak(){return this.facet(xe.lineSeparator)||"\n"}get readOnly(){return this.facet(oe)}phrase(t,...e){for(let e of this.facet(xe.phrases))if(Object.prototype.hasOwnProperty.call(e,t)){t=e[t];break}return e.length&&(t=t.replace(/\$(\$|\d*)/g,(t,i)=>{if("$"==i)return"$";let n=+(i||1);return!n||n>e.length?t:e[n-1]})),t}languageDataAt(t,e,i=-1){let n=[];for(let s of this.facet(Zt))for(let o of s(this,e,i))Object.prototype.hasOwnProperty.call(o,t)&&n.push(o[t]);return n}charCategorizer(t){return ye(this.languageDataAt("wordChars",t).join(""))}wordAt(t){let{text:e,from:i,length:n}=this.doc.lineAt(t),s=this.charCategorizer(t),o=t-i,r=t-i;for(;o>0;){let t=gt(e,o,!1);if(s(e.slice(t,o))!=we.Word)break;o=t}for(;r<n;){let t=gt(e,r);if(s(e.slice(r,t))!=we.Word)break;r=t}return o==r?null:Lt.range(o+i,r+i)}}function ke(t,e,i={}){let n={};for(let e of t)for(let t of Object.keys(e)){let s=e[t],o=n[t];if(void 0===o)n[t]=s;else if(o===s||void 0===s);else{if(!Object.hasOwnProperty.call(i,t))throw new Error("Config merge conflict for field "+t);n[t]=i[t](o,s)}}for(let t in e)void 0===n[t]&&(n[t]=e[t]);return n}xe.allowMultipleSelections=te,xe.tabSize=Bt.define({combine:t=>t.length?t[0]:4}),xe.lineSeparator=ee,xe.readOnly=oe,xe.phrases=Bt.define({compare(t,e){let i=Object.keys(t),n=Object.keys(e);return i.length==n.length&&i.every(i=>t[i]==e[i])}}),xe.languageData=Zt,xe.changeFilter=ie,xe.transactionFilter=ne,xe.transactionExtender=se,Gt.reconfigure=he.define();class Se{eq(t){return this==t}range(t,e=t){return Ce.create(t,e,this)}}Se.prototype.startSide=Se.prototype.endSide=0,Se.prototype.point=!1,Se.prototype.mapMode=yt.TrackDel;class Ce{constructor(t,e,i){this.from=t,this.to=e,this.value=i}static create(t,e,i){return new Ce(t,e,i)}}function Ae(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class Me{constructor(t,e,i,n){this.from=t,this.to=e,this.value=i,this.maxPoint=n}get length(){return this.to[this.to.length-1]}findIndex(t,e,i,n=0){let s=i?this.to:this.from;for(let o=n,r=s.length;;){if(o==r)return o;let n=o+r>>1,l=s[n]-t||(i?this.value[n].endSide:this.value[n].startSide)-e;if(n==o)return l>=0?o:r;l>=0?r=n:o=n+1}}between(t,e,i,n){for(let s=this.findIndex(e,-1e9,!0),o=this.findIndex(i,1e9,!1,s);s<o;s++)if(!1===n(this.from[s]+t,this.to[s]+t,this.value[s]))return!1}map(t,e){let i=[],n=[],s=[],o=-1,r=-1;for(let l=0;l<this.value.length;l++){let a,h,c=this.value[l],f=this.from[l]+t,d=this.to[l]+t;if(f==d){let t=e.mapPos(f,c.startSide,c.mapMode);if(null==t)continue;if(a=h=t,c.startSide!=c.endSide&&(h=e.mapPos(f,c.endSide),h<a))continue}else if(a=e.mapPos(f,c.startSide),h=e.mapPos(d,c.endSide),a>h||a==h&&c.startSide>0&&c.endSide<=0)continue;(h-a||c.endSide-c.startSide)<0||(o<0&&(o=a),c.point&&(r=Math.max(r,h-a)),i.push(c),n.push(a-o),s.push(h-o))}return{mapped:i.length?new Me(n,s,i,r):null,pos:o}}}class Te{constructor(t,e,i,n){this.chunkPos=t,this.chunk=e,this.nextLayer=i,this.maxPoint=n}static create(t,e,i,n){return new Te(t,e,i,n)}get length(){let t=this.chunk.length-1;return t<0?0:Math.max(this.chunkEnd(t),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let t=this.nextLayer.size;for(let e of this.chunk)t+=e.value.length;return t}chunkEnd(t){return this.chunkPos[t]+this.chunk[t].length}update(t){let{add:e=[],sort:i=!1,filterFrom:n=0,filterTo:s=this.length}=t,o=t.filter;if(0==e.length&&!o)return this;if(i&&(e=e.slice().sort(Ae)),this.isEmpty)return e.length?Te.of(e):this;let r=new Le(this,null,-1).goto(0),l=0,a=[],h=new Oe;for(;r.value||l<e.length;)if(l<e.length&&(r.from-e[l].from||r.startSide-e[l].value.startSide)>=0){let t=e[l++];h.addInner(t.from,t.to,t.value)||a.push(t)}else 1==r.rangeIndex&&r.chunkIndex<this.chunk.length&&(l==e.length||this.chunkEnd(r.chunkIndex)<e[l].from)&&(!o||n>this.chunkEnd(r.chunkIndex)||s<this.chunkPos[r.chunkIndex])&&h.addChunk(this.chunkPos[r.chunkIndex],this.chunk[r.chunkIndex])?r.nextChunk():((!o||n>r.to||s<r.from||o(r.from,r.to,r.value))&&(h.addInner(r.from,r.to,r.value)||a.push(Ce.create(r.from,r.to,r.value))),r.next());return h.finishInner(this.nextLayer.isEmpty&&!a.length?Te.empty:this.nextLayer.update({add:a,filter:o,filterFrom:n,filterTo:s}))}map(t){if(t.empty||this.isEmpty)return this;let e=[],i=[],n=-1;for(let s=0;s<this.chunk.length;s++){let o=this.chunkPos[s],r=this.chunk[s],l=t.touchesRange(o,o+r.length);if(!1===l)n=Math.max(n,r.maxPoint),e.push(r),i.push(t.mapPos(o));else if(!0===l){let{mapped:s,pos:l}=r.map(o,t);s&&(n=Math.max(n,s.maxPoint),e.push(s),i.push(l))}}let s=this.nextLayer.map(t);return 0==e.length?s:new Te(i,e,s||Te.empty,n)}between(t,e,i){if(!this.isEmpty){for(let n=0;n<this.chunk.length;n++){let s=this.chunkPos[n],o=this.chunk[n];if(e>=s&&t<=s+o.length&&!1===o.between(s,t-s,e-s,i))return}this.nextLayer.between(t,e,i)}}iter(t=0){return Ee.from([this]).goto(t)}get isEmpty(){return this.nextLayer==this}static iter(t,e=0){return Ee.from(t).goto(e)}static compare(t,e,i,n,s=-1){let o=t.filter(t=>t.maxPoint>0||!t.isEmpty&&t.maxPoint>=s),r=e.filter(t=>t.maxPoint>0||!t.isEmpty&&t.maxPoint>=s),l=De(o,r,i),a=new Be(o,l,s),h=new Be(r,l,s);i.iterGaps((t,e,i)=>Re(a,t,h,e,i,n)),i.empty&&0==i.length&&Re(a,0,h,0,0,n)}static eq(t,e,i=0,n){null==n&&(n=999999999);let s=t.filter(t=>!t.isEmpty&&e.indexOf(t)<0),o=e.filter(e=>!e.isEmpty&&t.indexOf(e)<0);if(s.length!=o.length)return!1;if(!s.length)return!0;let r=De(s,o),l=new Be(s,r,0).goto(i),a=new Be(o,r,0).goto(i);for(;;){if(l.to!=a.to||!Ne(l.active,a.active)||l.point&&(!a.point||!l.point.eq(a.point)))return!1;if(l.to>n)return!0;l.next(),a.next()}}static spans(t,e,i,n,s=-1){let o=new Be(t,null,s).goto(e),r=e,l=o.openStart;for(;;){let t=Math.min(o.to,i);if(o.point){let i=o.activeForPoint(o.to),s=o.pointFrom<e?i.length+1:o.point.startSide<0?i.length:Math.min(i.length,l);n.point(r,t,o.point,i,s,o.pointRank),l=Math.min(o.openEnd(t),i.length)}else t>r&&(n.span(r,t,o.active,l),l=o.openEnd(t));if(o.to>i)return l+(o.point&&o.to>i?1:0);r=o.to,o.next()}}static of(t,e=!1){let i=new Oe;for(let n of t instanceof Ce?[t]:e?function(t){if(t.length>1)for(let e=t[0],i=1;i<t.length;i++){let n=t[i];if(Ae(e,n)>0)return t.slice().sort(Ae);e=n}return t}(t):t)i.add(n.from,n.to,n.value);return i.finish()}static join(t){if(!t.length)return Te.empty;let e=t[t.length-1];for(let i=t.length-2;i>=0;i--)for(let n=t[i];n!=Te.empty;n=n.nextLayer)e=new Te(n.chunkPos,n.chunk,e,Math.max(n.maxPoint,e.maxPoint));return e}}Te.empty=new Te([],[],null,-1),Te.empty.nextLayer=Te.empty;class Oe{finishChunk(t){this.chunks.push(new Me(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,t&&(this.from=[],this.to=[],this.value=[])}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}add(t,e,i){this.addInner(t,e,i)||(this.nextLayer||(this.nextLayer=new Oe)).add(t,e,i)}addInner(t,e,i){let n=t-this.lastTo||i.startSide-this.last.endSide;if(n<=0&&(t-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=t),this.from.push(t-this.chunkStart),this.to.push(e-this.chunkStart),this.last=i,this.lastFrom=t,this.lastTo=e,this.value.push(i),i.point&&(this.maxPoint=Math.max(this.maxPoint,e-t)),!0)}addChunk(t,e){if((t-this.lastTo||e.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,e.maxPoint),this.chunks.push(e),this.chunkPos.push(t);let i=e.value.length-1;return this.last=e.value[i],this.lastFrom=e.from[i]+t,this.lastTo=e.to[i]+t,!0}finish(){return this.finishInner(Te.empty)}finishInner(t){if(this.from.length&&this.finishChunk(!1),0==this.chunks.length)return t;let e=Te.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(t):t,this.setMaxPoint);return this.from=null,e}}function De(t,e,i){let n=new Map;for(let e of t)for(let t=0;t<e.chunk.length;t++)e.chunk[t].maxPoint<=0&&n.set(e.chunk[t],e.chunkPos[t]);let s=new Set;for(let t of e)for(let e=0;e<t.chunk.length;e++){let o=n.get(t.chunk[e]);null==o||(i?i.mapPos(o):o)!=t.chunkPos[e]||(null==i?void 0:i.touchesRange(o,o+t.chunk[e].length))||s.add(t.chunk[e])}return s}class Le{constructor(t,e,i,n=0){this.layer=t,this.skip=e,this.minPoint=i,this.rank=n}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(t,e=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(t,e,!1),this}gotoInner(t,e,i){for(;this.chunkIndex<this.layer.chunk.length;){let e=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(e)||this.layer.chunkEnd(this.chunkIndex)<t||e.maxPoint<this.minPoint))break;this.chunkIndex++,i=!1}if(this.chunkIndex<this.layer.chunk.length){let n=this.layer.chunk[this.chunkIndex].findIndex(t-this.layer.chunkPos[this.chunkIndex],e,!0);(!i||this.rangeIndex<n)&&this.setRangeIndex(n)}this.next()}forward(t,e){(this.to-t||this.endSide-e)<0&&this.gotoInner(t,e,!0)}next(){for(;;){if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}{let t=this.layer.chunkPos[this.chunkIndex],e=this.layer.chunk[this.chunkIndex],i=t+e.from[this.rangeIndex];if(this.from=i,this.to=t+e.to[this.rangeIndex],this.value=e.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}}setRangeIndex(t){if(t==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=t}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(t){return this.from-t.from||this.startSide-t.startSide||this.rank-t.rank||this.to-t.to||this.endSide-t.endSide}}class Ee{constructor(t){this.heap=t}static from(t,e=null,i=-1){let n=[];for(let s=0;s<t.length;s++)for(let o=t[s];!o.isEmpty;o=o.nextLayer)o.maxPoint>=i&&n.push(new Le(o,e,i,s));return 1==n.length?n[0]:new Ee(n)}get startSide(){return this.value?this.value.startSide:0}goto(t,e=-1e9){for(let i of this.heap)i.goto(t,e);for(let t=this.heap.length>>1;t>=0;t--)Pe(this.heap,t);return this.next(),this}forward(t,e){for(let i of this.heap)i.forward(t,e);for(let t=this.heap.length>>1;t>=0;t--)Pe(this.heap,t);(this.to-t||this.value.endSide-e)<0&&this.next()}next(){if(0==this.heap.length)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let t=this.heap[0];this.from=t.from,this.to=t.to,this.value=t.value,this.rank=t.rank,t.value&&t.next(),Pe(this.heap,0)}}}function Pe(t,e){for(let i=t[e];;){let n=1+(e<<1);if(n>=t.length)break;let s=t[n];if(n+1<t.length&&s.compare(t[n+1])>=0&&(s=t[n+1],n++),i.compare(s)<0)break;t[n]=i,t[e]=s,e=n}}class Be{constructor(t,e,i){this.minPoint=i,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=Ee.from(t,e,i)}goto(t,e=-1e9){return this.cursor.goto(t,e),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=t,this.endSide=e,this.openStart=-1,this.next(),this}forward(t,e){for(;this.minActive>-1&&(this.activeTo[this.minActive]-t||this.active[this.minActive].endSide-e)<0;)this.removeActive(this.minActive);this.cursor.forward(t,e)}removeActive(t){Ie(this.active,t),Ie(this.activeTo,t),Ie(this.activeRank,t),this.minActive=He(this.active,this.activeTo)}addActive(t){let e=0,{value:i,to:n,rank:s}=this.cursor;for(;e<this.activeRank.length&&(s-this.activeRank[e]||n-this.activeTo[e])>0;)e++;je(this.active,e,i),je(this.activeTo,e,n),je(this.activeRank,e,s),t&&je(t,e,this.cursor.from),this.minActive=He(this.active,this.activeTo)}next(){let t=this.to,e=this.point;this.point=null;let i=this.openStart<0?[]:null;for(;;){let n=this.minActive;if(n>-1&&(this.activeTo[n]-this.cursor.from||this.active[n].endSide-this.cursor.startSide)<0){if(this.activeTo[n]>t){this.to=this.activeTo[n],this.endSide=this.active[n].endSide;break}this.removeActive(n),i&&Ie(i,n)}else{if(!this.cursor.value){this.to=this.endSide=1e9;break}if(this.cursor.from>t){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}{let t=this.cursor.value;if(t.point){if(!(e&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)){this.point=t,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=t.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}this.cursor.next()}else this.addActive(i),this.cursor.next()}}}if(i){this.openStart=0;for(let e=i.length-1;e>=0&&i[e]<t;e--)this.openStart++}}activeForPoint(t){if(!this.active.length)return this.active;let e=[];for(let i=this.active.length-1;i>=0&&!(this.activeRank[i]<this.pointRank);i--)(this.activeTo[i]>t||this.activeTo[i]==t&&this.active[i].endSide>=this.point.endSide)&&e.push(this.active[i]);return e.reverse()}openEnd(t){let e=0;for(let i=this.activeTo.length-1;i>=0&&this.activeTo[i]>t;i--)e++;return e}}function Re(t,e,i,n,s,o){t.goto(e),i.goto(n);let r=n+s,l=n,a=n-e;for(;;){let e=t.to+a-i.to,n=e||t.endSide-i.endSide,s=n<0?t.to+a:i.to,h=Math.min(s,r);if(t.point||i.point?t.point&&i.point&&(t.point==i.point||t.point.eq(i.point))&&Ne(t.activeForPoint(t.to),i.activeForPoint(i.to))||o.comparePoint(l,h,t.point,i.point):h>l&&!Ne(t.active,i.active)&&o.compareRange(l,h,t.active,i.active),s>r)break;(e||t.openEnd!=i.openEnd)&&o.boundChange&&o.boundChange(s),l=s,n<=0&&t.next(),n>=0&&i.next()}}function Ne(t,e){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++)if(t[i]!=e[i]&&!t[i].eq(e[i]))return!1;return!0}function Ie(t,e){for(let i=e,n=t.length-1;i<n;i++)t[i]=t[i+1];t.pop()}function je(t,e,i){for(let i=t.length-1;i>=e;i--)t[i+1]=t[i];t[e]=i}function He(t,e){let i=-1,n=1e9;for(let s=0;s<e.length;s++)(e[s]-n||t[s].endSide-t[i].endSide)<0&&(i=s,n=e[s]);return i}function Ve(t,e,i=t.length){let n=0;for(let s=0;s<i&&s<t.length;)9==t.charCodeAt(s)?(n+=e-n%e,s++):(n++,s=gt(t,s));return n}const Fe="undefined"==typeof Symbol?"__ͼ":Symbol.for("ͼ"),ze="undefined"==typeof Symbol?"__styleSet"+Math.floor(1e8*Math.random()):Symbol("styleSet"),We="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:{};class qe{constructor(t,e){this.rules=[];let{finish:i}=e||{};function n(t){return/^@/.test(t)?[t]:t.split(/,\s*/)}function s(t,e,o,r){let l=[],a=/^@(\w+)\b/.exec(t[0]),h=a&&"keyframes"==a[1];if(a&&null==e)return o.push(t[0]+";");for(let i in e){let r=e[i];if(/&/.test(i))s(i.split(/,\s*/).map(e=>t.map(t=>e.replace(/&/,t))).reduce((t,e)=>t.concat(e)),r,o);else if(r&&"object"==typeof r){if(!a)throw new RangeError("The value of a property ("+i+") should be a primitive value.");s(n(i),r,l,h)}else null!=r&&l.push(i.replace(/_.*/,"").replace(/[A-Z]/g,t=>"-"+t.toLowerCase())+": "+r+";")}(l.length||h)&&o.push((!i||a||r?t:t.map(i)).join(", ")+" {"+l.join(" ")+"}")}for(let e in t)s(n(e),t[e],this.rules)}getRules(){return this.rules.join("\n")}static newName(){let t=We[Fe]||1;return We[Fe]=t+1,"ͼ"+t.toString(36)}static mount(t,e,i){let n=t[ze],s=i&&i.nonce;n?s&&n.setNonce(s):n=new Ke(t,s),n.mount(Array.isArray(e)?e:[e],t)}}let _e=new Map;class Ke{constructor(t,e){let i=t.ownerDocument||t,n=i.defaultView;if(!t.head&&t.adoptedStyleSheets&&n.CSSStyleSheet){let e=_e.get(i);if(e)return t[ze]=e;this.sheet=new n.CSSStyleSheet,_e.set(i,this)}else this.styleTag=i.createElement("style"),e&&this.styleTag.setAttribute("nonce",e);this.modules=[],t[ze]=this}mount(t,e){let i=this.sheet,n=0,s=0;for(let e=0;e<t.length;e++){let o=t[e],r=this.modules.indexOf(o);if(r<s&&r>-1&&(this.modules.splice(r,1),s--,r=-1),-1==r){if(this.modules.splice(s++,0,o),i)for(let t=0;t<o.rules.length;t++)i.insertRule(o.rules[t],n++)}else{for(;s<r;)n+=this.modules[s++].rules.length;n+=o.rules.length,s++}}if(i)e.adoptedStyleSheets.indexOf(this.sheet)<0&&(e.adoptedStyleSheets=[this.sheet,...e.adoptedStyleSheets]);else{let t="";for(let e=0;e<this.modules.length;e++)t+=this.modules[e].getRules()+"\n";this.styleTag.textContent=t;let i=e.head||e;this.styleTag.parentNode!=i&&i.insertBefore(this.styleTag,i.firstChild)}}setNonce(t){this.styleTag&&this.styleTag.getAttribute("nonce")!=t&&this.styleTag.setAttribute("nonce",t)}}for(var $e={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},Ue={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Ge="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),Ye="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),Je=0;Je<10;Je++)$e[48+Je]=$e[96+Je]=String(Je);for(Je=1;Je<=24;Je++)$e[Je+111]="F"+Je;for(Je=65;Je<=90;Je++)$e[Je]=String.fromCharCode(Je+32),Ue[Je]=String.fromCharCode(Je);for(var Xe in $e)Ue.hasOwnProperty(Xe)||(Ue[Xe]=$e[Xe]);function Qe(){var t=arguments[0];"string"==typeof t&&(t=document.createElement(t));var e=1,i=arguments[1];if(i&&"object"==typeof i&&null==i.nodeType&&!Array.isArray(i)){for(var n in i)if(Object.prototype.hasOwnProperty.call(i,n)){var s=i[n];"string"==typeof s?t.setAttribute(n,s):null!=s&&(t[n]=s)}e++}for(;e<arguments.length;e++)Ze(t,arguments[e]);return t}function Ze(t,e){if("string"==typeof e)t.appendChild(document.createTextNode(e));else if(null==e);else if(null!=e.nodeType)t.appendChild(e);else{if(!Array.isArray(e))throw new RangeError("Unsupported child node: "+e);for(var i=0;i<e.length;i++)Ze(t,e[i])}}let ti="undefined"!=typeof navigator?navigator:{userAgent:"",vendor:"",platform:""},ei="undefined"!=typeof document?document:{documentElement:{style:{}}};const ii=/Edge\/(\d+)/.exec(ti.userAgent),ni=/MSIE \d/.test(ti.userAgent),si=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(ti.userAgent),oi=!!(ni||si||ii),ri=!oi&&/gecko\/(\d+)/i.test(ti.userAgent),li=!oi&&/Chrome\/(\d+)/.exec(ti.userAgent),ai="webkitFontSmoothing"in ei.documentElement.style,hi=!oi&&/Apple Computer/.test(ti.vendor),ci=hi&&(/Mobile\/\w+/.test(ti.userAgent)||ti.maxTouchPoints>2);var fi={mac:ci||/Mac/.test(ti.platform),windows:/Win/.test(ti.platform),linux:/Linux|X11/.test(ti.platform),ie:oi,ie_version:ni?ei.documentMode||6:si?+si[1]:ii?+ii[1]:0,gecko:ri,gecko_version:ri?+(/Firefox\/(\d+)/.exec(ti.userAgent)||[0,0])[1]:0,chrome:!!li,chrome_version:li?+li[1]:0,ios:ci,android:/Android\b/.test(ti.userAgent),webkit_version:ai?+(/\bAppleWebKit\/(\d+)/.exec(ti.userAgent)||[0,0])[1]:0,safari:hi,safari_version:hi?+(/\bVersion\/(\d+(\.\d+)?)/.exec(ti.userAgent)||[0,0])[1]:0,tabSize:null!=ei.documentElement.style.tabSize?"tab-size":"-moz-tab-size"};function di(t){let e;return e=11==t.nodeType?t.getSelection?t:t.ownerDocument:t,e.getSelection()}function ui(t,e){return!!e&&(t==e||t.contains(1!=e.nodeType?e.parentNode:e))}function pi(t,e){if(!e.anchorNode)return!1;try{return ui(t,e.anchorNode)}catch(t){return!1}}function mi(t){return 3==t.nodeType?Oi(t,0,t.nodeValue.length).getClientRects():1==t.nodeType?t.getClientRects():[]}function gi(t,e,i,n){return!!i&&(bi(t,e,i,n,-1)||bi(t,e,i,n,1))}function wi(t){for(var e=0;;e++)if(!(t=t.previousSibling))return e}function vi(t){return 1==t.nodeType&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}function bi(t,e,i,n,s){for(;;){if(t==i&&e==n)return!0;if(e==(s<0?0:yi(t))){if("DIV"==t.nodeName)return!1;let i=t.parentNode;if(!i||1!=i.nodeType)return!1;e=wi(t)+(s<0?0:1),t=i}else{if(1!=t.nodeType)return!1;if(1==(t=t.childNodes[e+(s<0?-1:0)]).nodeType&&"false"==t.contentEditable)return!1;e=s<0?yi(t):0}}}function yi(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function xi(t,e){let i=e?t.left:t.right;return{left:i,right:i,top:t.top,bottom:t.bottom}}function ki(t){let e=t.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}function Si(t,e){let i=e.width/t.offsetWidth,n=e.height/t.offsetHeight;return(i>.995&&i<1.005||!isFinite(i)||Math.abs(e.width-t.offsetWidth)<1)&&(i=1),(n>.995&&n<1.005||!isFinite(n)||Math.abs(e.height-t.offsetHeight)<1)&&(n=1),{scaleX:i,scaleY:n}}class Ci{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(t){return this.anchorNode==t.anchorNode&&this.anchorOffset==t.anchorOffset&&this.focusNode==t.focusNode&&this.focusOffset==t.focusOffset}setRange(t){let{anchorNode:e,focusNode:i}=t;this.set(e,Math.min(t.anchorOffset,e?yi(e):0),i,Math.min(t.focusOffset,i?yi(i):0))}set(t,e,i,n){this.anchorNode=t,this.anchorOffset=e,this.focusNode=i,this.focusOffset=n}}let Ai,Mi=null;function Ti(t){if(t.setActive)return t.setActive();if(Mi)return t.focus(Mi);let e=[];for(let i=t;i&&(e.push(i,i.scrollTop,i.scrollLeft),i!=i.ownerDocument);i=i.parentNode);if(t.focus(null==Mi?{get preventScroll(){return Mi={preventScroll:!0},!0}}:void 0),!Mi){Mi=!1;for(let t=0;t<e.length;){let i=e[t++],n=e[t++],s=e[t++];i.scrollTop!=n&&(i.scrollTop=n),i.scrollLeft!=s&&(i.scrollLeft=s)}}}function Oi(t,e,i=e){let n=Ai||(Ai=document.createRange());return n.setEnd(t,i),n.setStart(t,e),n}function Di(t,e,i,n){let s={key:e,code:e,keyCode:i,which:i,cancelable:!0};n&&({altKey:s.altKey,ctrlKey:s.ctrlKey,shiftKey:s.shiftKey,metaKey:s.metaKey}=n);let o=new KeyboardEvent("keydown",s);o.synthetic=!0,t.dispatchEvent(o);let r=new KeyboardEvent("keyup",s);return r.synthetic=!0,t.dispatchEvent(r),o.defaultPrevented||r.defaultPrevented}function Li(t){for(;t.attributes.length;)t.removeAttributeNode(t.attributes[0])}function Ei(t){return t.scrollTop>Math.max(1,t.scrollHeight-t.clientHeight-4)}function Pi(t,e){for(let i=t,n=e;;){if(3==i.nodeType&&n>0)return{node:i,offset:n};if(1==i.nodeType&&n>0){if("false"==i.contentEditable)return null;i=i.childNodes[n-1],n=yi(i)}else{if(!i.parentNode||vi(i))return null;n=wi(i),i=i.parentNode}}}function Bi(t,e){for(let i=t,n=e;;){if(3==i.nodeType&&n<i.nodeValue.length)return{node:i,offset:n};if(1==i.nodeType&&n<i.childNodes.length){if("false"==i.contentEditable)return null;i=i.childNodes[n],n=0}else{if(!i.parentNode||vi(i))return null;n=wi(i)+1,i=i.parentNode}}}fi.safari&&fi.safari_version>=26&&(Mi=!1);class Ri{constructor(t,e,i=!0){this.node=t,this.offset=e,this.precise=i}static before(t,e){return new Ri(t.parentNode,wi(t),e)}static after(t,e){return new Ri(t.parentNode,wi(t)+1,e)}}const Ni=[];class Ii{constructor(){this.parent=null,this.dom=null,this.flags=2}get overrideDOMText(){return null}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(t){let e=this.posAtStart;for(let i of this.children){if(i==t)return e;e+=i.length+i.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(t){return this.posBefore(t)+t.length}sync(t,e){if(2&this.flags){let i,n=this.dom,s=null;for(let o of this.children){if(7&o.flags){if(!o.dom&&(i=s?s.nextSibling:n.firstChild)){let t=Ii.get(i);(!t||!t.parent&&t.canReuseDOM(o))&&o.reuseDOM(i)}o.sync(t,e),o.flags&=-8}if(i=s?s.nextSibling:n.firstChild,e&&!e.written&&e.node==n&&i!=o.dom&&(e.written=!0),o.dom.parentNode==n)for(;i&&i!=o.dom;)i=ji(i);else n.insertBefore(o.dom,i);s=o.dom}for(i=s?s.nextSibling:n.firstChild,i&&e&&e.node==n&&(e.written=!0);i;)i=ji(i)}else if(1&this.flags)for(let i of this.children)7&i.flags&&(i.sync(t,e),i.flags&=-8)}reuseDOM(t){}localPosFromDOM(t,e){let i;if(t==this.dom)i=this.dom.childNodes[e];else{let n=0==yi(t)?0:0==e?-1:1;for(;;){let e=t.parentNode;if(e==this.dom)break;0==n&&e.firstChild!=e.lastChild&&(n=t==e.firstChild?-1:1),t=e}i=n<0?t:t.nextSibling}if(i==this.dom.firstChild)return 0;for(;i&&!Ii.get(i);)i=i.nextSibling;if(!i)return this.length;for(let t=0,e=0;;t++){let n=this.children[t];if(n.dom==i)return e;e+=n.length+n.breakAfter}}domBoundsAround(t,e,i=0){let n=-1,s=-1,o=-1,r=-1;for(let l=0,a=i,h=i;l<this.children.length;l++){let i=this.children[l],c=a+i.length;if(a<t&&c>e)return i.domBoundsAround(t,e,a);if(c>=t&&-1==n&&(n=l,s=a),a>e&&i.dom.parentNode==this.dom){o=l,r=h;break}h=c,a=c+i.breakAfter}return{from:s,to:r<0?i+this.length:r,startDOM:(n?this.children[n-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:o<this.children.length&&o>=0?this.children[o].dom:null}}markDirty(t=!1){this.flags|=2,this.markParentsDirty(t)}markParentsDirty(t){for(let e=this.parent;e;e=e.parent){if(t&&(e.flags|=2),1&e.flags)return;e.flags|=1,t=!1}}setParent(t){this.parent!=t&&(this.parent=t,7&this.flags&&this.markParentsDirty(!0))}setDOM(t){this.dom!=t&&(this.dom&&(this.dom.cmView=null),this.dom=t,t.cmView=this)}get rootView(){for(let t=this;;){let e=t.parent;if(!e)return t;t=e}}replaceChildren(t,e,i=Ni){this.markDirty();for(let n=t;n<e;n++){let t=this.children[n];t.parent==this&&i.indexOf(t)<0&&t.destroy()}i.length<250?this.children.splice(t,e-t,...i):this.children=[].concat(this.children.slice(0,t),i,this.children.slice(e));for(let t=0;t<i.length;t++)i[t].setParent(this)}ignoreMutation(t){return!1}ignoreEvent(t){return!1}childCursor(t=this.length){return new Hi(this.children,t,this.children.length)}childPos(t,e=1){return this.childCursor().findPos(t,e)}toString(){let t=this.constructor.name.replace("View","");return t+(this.children.length?"("+this.children.join()+")":this.length?"["+("Text"==t?this.text:this.length)+"]":"")+(this.breakAfter?"#":"")}static get(t){return t.cmView}get isEditable(){return!0}get isWidget(){return!1}get isHidden(){return!1}merge(t,e,i,n,s,o){return!1}become(t){return!1}canReuseDOM(t){return t.constructor==this.constructor&&!(8&(this.flags|t.flags))}getSide(){return 0}destroy(){for(let t of this.children)t.parent==this&&t.destroy();this.parent=null}}function ji(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}Ii.prototype.breakAfter=0;class Hi{constructor(t,e,i){this.children=t,this.pos=e,this.i=i,this.off=0}findPos(t,e=1){for(;;){if(t>this.pos||t==this.pos&&(e>0||0==this.i||this.children[this.i-1].breakAfter))return this.off=t-this.pos,this;let i=this.children[--this.i];this.pos-=i.length+i.breakAfter}}}function Vi(t,e,i,n,s,o,r,l,a){let{children:h}=t,c=h.length?h[e]:null,f=o.length?o[o.length-1]:null,d=f?f.breakAfter:r;if(!(e==n&&c&&!r&&!d&&o.length<2&&c.merge(i,s,o.length?f:null,0==i,l,a))){if(n<h.length){let t=h[n];t&&(s<t.length||t.breakAfter&&(null==f?void 0:f.breakAfter))?(e==n&&(t=t.split(s),s=0),!d&&f&&t.merge(0,s,f,!0,0,a)?o[o.length-1]=t:((s||t.children.length&&!t.children[0].length)&&t.merge(0,s,null,!1,0,a),o.push(t))):(null==t?void 0:t.breakAfter)&&(f?f.breakAfter=1:r=1),n++}for(c&&(c.breakAfter=r,i>0&&(!r&&o.length&&c.merge(i,c.length,o[0],!1,l,0)?c.breakAfter=o.shift().breakAfter:(i<c.length||c.children.length&&0==c.children[c.children.length-1].length)&&c.merge(i,c.length,null,!1,l,0),e++));e<n&&o.length;)if(h[n-1].become(o[o.length-1]))n--,o.pop(),a=o.length?0:l;else{if(!h[e].become(o[0]))break;e++,o.shift(),l=o.length?0:a}!o.length&&e&&n<h.length&&!h[e-1].breakAfter&&h[n].merge(0,0,h[e-1],!1,l,a)&&e--,(e<n||o.length)&&t.replaceChildren(e,n,o)}}function Fi(t,e,i,n,s,o){let r=t.childCursor(),{i:l,off:a}=r.findPos(i,1),{i:h,off:c}=r.findPos(e,-1),f=e-i;for(let t of n)f+=t.length;t.length+=f,Vi(t,h,c,l,a,n,0,s,o)}class zi extends Ii{constructor(t){super(),this.text=t}get length(){return this.text.length}createDOM(t){this.setDOM(t||document.createTextNode(this.text))}sync(t,e){this.dom||this.createDOM(),this.dom.nodeValue!=this.text&&(e&&e.node==this.dom&&(e.written=!0),this.dom.nodeValue=this.text)}reuseDOM(t){3==t.nodeType&&this.createDOM(t)}merge(t,e,i){return!(8&this.flags||i&&(!(i instanceof zi)||this.length-(e-t)+i.length>256||8&i.flags))&&(this.text=this.text.slice(0,t)+(i?i.text:"")+this.text.slice(e),this.markDirty(),!0)}split(t){let e=new zi(this.text.slice(t));return this.text=this.text.slice(0,t),this.markDirty(),e.flags|=8&this.flags,e}localPosFromDOM(t,e){return t==this.dom?e:e?this.text.length:0}domAtPos(t){return new Ri(this.dom,t)}domBoundsAround(t,e,i){return{from:i,to:i+this.length,startDOM:this.dom,endDOM:this.dom.nextSibling}}coordsAt(t,e){return function(t,e,i){let n=t.nodeValue.length;e>n&&(e=n);let s=e,o=e,r=0;0==e&&i<0||e==n&&i>=0?fi.chrome||fi.gecko||(e?(s--,r=1):o<n&&(o++,r=-1)):i<0?s--:o<n&&o++;let l=Oi(t,s,o).getClientRects();if(!l.length)return null;let a=l[(r?r<0:i>=0)?0:l.length-1];fi.safari&&!r&&0==a.width&&(a=Array.prototype.find.call(l,t=>t.width)||a);return r?xi(a,r<0):a||null}(this.dom,t,e)}}class Wi extends Ii{constructor(t,e=[],i=0){super(),this.mark=t,this.children=e,this.length=i;for(let t of e)t.setParent(this)}setAttrs(t){if(Li(t),this.mark.class&&(t.className=this.mark.class),this.mark.attrs)for(let e in this.mark.attrs)t.setAttribute(e,this.mark.attrs[e]);return t}canReuseDOM(t){return super.canReuseDOM(t)&&!(8&(this.flags|t.flags))}reuseDOM(t){t.nodeName==this.mark.tagName.toUpperCase()&&(this.setDOM(t),this.flags|=6)}sync(t,e){this.dom?4&this.flags&&this.setAttrs(this.dom):this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))),super.sync(t,e)}merge(t,e,i,n,s,o){return(!i||!(!(i instanceof Wi&&i.mark.eq(this.mark))||t&&s<=0||e<this.length&&o<=0))&&(Fi(this,t,e,i?i.children.slice():[],s-1,o-1),this.markDirty(),!0)}split(t){let e=[],i=0,n=-1,s=0;for(let o of this.children){let r=i+o.length;r>t&&e.push(i<t?o.split(t-i):o),n<0&&i>=t&&(n=s),i=r,s++}let o=this.length-t;return this.length=t,n>-1&&(this.children.length=n,this.markDirty()),new Wi(this.mark,e,o)}domAtPos(t){return Ki(this,t)}coordsAt(t,e){return Ui(this,t,e)}}class qi extends Ii{static create(t,e,i){return new qi(t,e,i)}constructor(t,e,i){super(),this.widget=t,this.length=e,this.side=i,this.prevWidget=null}split(t){let e=qi.create(this.widget,this.length-t,this.side);return this.length-=t,e}sync(t){this.dom&&this.widget.updateDOM(this.dom,t)||(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(t)),this.widget.editable||(this.dom.contentEditable="false"))}getSide(){return this.side}merge(t,e,i,n,s,o){return!(i&&(!(i instanceof qi&&this.widget.compare(i.widget))||t>0&&s<=0||e<this.length&&o<=0))&&(this.length=t+(i?i.length:0)+(this.length-e),!0)}become(t){return t instanceof qi&&t.side==this.side&&this.widget.constructor==t.widget.constructor&&(this.widget.compare(t.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=t.widget,this.length=t.length,!0)}ignoreMutation(){return!0}ignoreEvent(t){return this.widget.ignoreEvent(t)}get overrideDOMText(){if(0==this.length)return rt.empty;let t=this;for(;t.parent;)t=t.parent;let{view:e}=t,i=e&&e.state.doc,n=this.posAtStart;return i?i.slice(n,n+this.length):rt.empty}domAtPos(t){return(this.length?0==t:this.side>0)?Ri.before(this.dom):Ri.after(this.dom,t==this.length)}domBoundsAround(){return null}coordsAt(t,e){let i=this.widget.coordsAt(this.dom,t,e);if(i)return i;let n=this.dom.getClientRects(),s=null;if(!n.length)return null;let o=this.side?this.side<0:t>0;for(let e=o?n.length-1:0;s=n[e],!(t>0?0==e:e==n.length-1||s.top<s.bottom);e+=o?-1:1);return xi(s,!o)}get isEditable(){return!1}get isWidget(){return!0}get isHidden(){return this.widget.isHidden}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}}class _i extends Ii{constructor(t){super(),this.side=t}get length(){return 0}merge(){return!1}become(t){return t instanceof _i&&t.side==this.side}split(){return new _i(this.side)}sync(){if(!this.dom){let t=document.createElement("img");t.className="cm-widgetBuffer",t.setAttribute("aria-hidden","true"),this.setDOM(t)}}getSide(){return this.side}domAtPos(t){return this.side>0?Ri.before(this.dom):Ri.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(t){return this.dom.getBoundingClientRect()}get overrideDOMText(){return rt.empty}get isHidden(){return!0}}function Ki(t,e){let i=t.dom,{children:n}=t,s=0;for(let t=0;s<n.length;s++){let o=n[s],r=t+o.length;if(!(r==t&&o.getSide()<=0)){if(e>t&&e<r&&o.dom.parentNode==i)return o.domAtPos(e-t);if(e<=t)break;t=r}}for(let t=s;t>0;t--){let e=n[t-1];if(e.dom.parentNode==i)return e.domAtPos(e.length)}for(let t=s;t<n.length;t++){let e=n[t];if(e.dom.parentNode==i)return e.domAtPos(0)}return new Ri(i,0)}function $i(t,e,i){let n,{children:s}=t;i>0&&e instanceof Wi&&s.length&&(n=s[s.length-1])instanceof Wi&&n.mark.eq(e.mark)?$i(n,e.children[0],i-1):(s.push(e),e.setParent(t)),t.length+=e.length}function Ui(t,e,i){let n=null,s=-1,o=null,r=-1;!function t(e,l){for(let a=0,h=0;a<e.children.length&&h<=l;a++){let c=e.children[a],f=h+c.length;f>=l&&(c.children.length?t(c,l-h):(!o||o.isHidden&&(i>0||Gi(o,c)))&&(f>l||h==f&&c.getSide()>0)?(o=c,r=l-h):(h<l||h==f&&c.getSide()<0&&!c.isHidden)&&(n=c,s=l-h)),h=f}}(t,e);let l=(i<0?n:o)||n||o;return l?l.coordsAt(Math.max(0,l==n?s:r),i):function(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let i=mi(e);return i[i.length-1]||null}(t)}function Gi(t,e){let i=t.coordsAt(0,1),n=e.coordsAt(0,1);return i&&n&&n.top<i.bottom}function Yi(t,e){for(let i in t)"class"==i&&e.class?e.class+=" "+t.class:"style"==i&&e.style?e.style+=";"+t.style:e[i]=t[i];return e}zi.prototype.children=qi.prototype.children=_i.prototype.children=Ni;const Ji=Object.create(null);function Xi(t,e,i){if(t==e)return!0;t||(t=Ji),e||(e=Ji);let n=Object.keys(t),s=Object.keys(e);if(n.length-(i&&n.indexOf(i)>-1?1:0)!=s.length-(i&&s.indexOf(i)>-1?1:0))return!1;for(let o of n)if(o!=i&&(-1==s.indexOf(o)||t[o]!==e[o]))return!1;return!0}function Qi(t,e,i){let n=!1;if(e)for(let s in e)i&&s in i||(n=!0,"style"==s?t.style.cssText="":t.removeAttribute(s));if(i)for(let s in i)e&&e[s]==i[s]||(n=!0,"style"==s?t.style.cssText=i[s]:t.setAttribute(s,i[s]));return n}function Zi(t){let e=Object.create(null);for(let i=0;i<t.attributes.length;i++){let n=t.attributes[i];e[n.name]=n.value}return e}class tn{eq(t){return!1}updateDOM(t,e){return!1}compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(t){return!0}coordsAt(t,e,i){return null}get isHidden(){return!1}get editable(){return!1}destroy(t){}}var en=function(t){return t[t.Text=0]="Text",t[t.WidgetBefore=1]="WidgetBefore",t[t.WidgetAfter=2]="WidgetAfter",t[t.WidgetRange=3]="WidgetRange",t}(en||(en={}));class nn extends Se{constructor(t,e,i,n){super(),this.startSide=t,this.endSide=e,this.widget=i,this.spec=n}get heightRelevant(){return!1}static mark(t){return new sn(t)}static widget(t){let e=Math.max(-1e4,Math.min(1e4,t.side||0)),i=!!t.block;return e+=i&&!t.inlineOrder?e>0?3e8:-4e8:e>0?1e8:-1e8,new rn(t,e,e,i,t.widget||null,!1)}static replace(t){let e,i,n=!!t.block;if(t.isBlockGap)e=-5e8,i=4e8;else{let{start:s,end:o}=ln(t,n);e=(s?n?-3e8:-1:5e8)-1,i=1+(o?n?2e8:1:-6e8)}return new rn(t,e,i,n,t.widget||null,!0)}static line(t){return new on(t)}static set(t,e=!1){return Te.of(t,e)}hasHeight(){return!!this.widget&&this.widget.estimatedHeight>-1}}nn.none=Te.empty;class sn extends nn{constructor(t){let{start:e,end:i}=ln(t);super(e?-1:5e8,i?1:-6e8,null,t),this.tagName=t.tagName||"span",this.class=t.class||"",this.attrs=t.attributes||null}eq(t){var e,i;return this==t||t instanceof sn&&this.tagName==t.tagName&&(this.class||(null===(e=this.attrs)||void 0===e?void 0:e.class))==(t.class||(null===(i=t.attrs)||void 0===i?void 0:i.class))&&Xi(this.attrs,t.attrs,"class")}range(t,e=t){if(t>=e)throw new RangeError("Mark decorations may not be empty");return super.range(t,e)}}sn.prototype.point=!1;class on extends nn{constructor(t){super(-2e8,-2e8,null,t)}eq(t){return t instanceof on&&this.spec.class==t.spec.class&&Xi(this.spec.attributes,t.spec.attributes)}range(t,e=t){if(e!=t)throw new RangeError("Line decoration ranges must be zero-length");return super.range(t,e)}}on.prototype.mapMode=yt.TrackBefore,on.prototype.point=!0;class rn extends nn{constructor(t,e,i,n,s,o){super(e,i,s,t),this.block=n,this.isReplace=o,this.mapMode=n?e<=0?yt.TrackBefore:yt.TrackAfter:yt.TrackDel}get type(){return this.startSide!=this.endSide?en.WidgetRange:this.startSide<=0?en.WidgetBefore:en.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(t){return t instanceof rn&&(e=this.widget,i=t.widget,e==i||!!(e&&i&&e.compare(i)))&&this.block==t.block&&this.startSide==t.startSide&&this.endSide==t.endSide;var e,i}range(t,e=t){if(this.isReplace&&(t>e||t==e&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&e!=t)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(t,e)}}function ln(t,e=!1){let{inclusiveStart:i,inclusiveEnd:n}=t;return null==i&&(i=t.inclusive),null==n&&(n=t.inclusive),{start:null!=i?i:e,end:null!=n?n:e}}function an(t,e,i,n=0){let s=i.length-1;s>=0&&i[s]+n>=t?i[s]=Math.max(i[s],e):i.push(t,e)}rn.prototype.point=!0;class hn extends Ii{constructor(){super(...arguments),this.children=[],this.length=0,this.prevAttrs=void 0,this.attrs=null,this.breakAfter=0}merge(t,e,i,n,s,o){if(i){if(!(i instanceof hn))return!1;this.dom||i.transferDOM(this)}return n&&this.setDeco(i?i.attrs:null),Fi(this,t,e,i?i.children.slice():[],s,o),!0}split(t){let e=new hn;if(e.breakAfter=this.breakAfter,0==this.length)return e;let{i:i,off:n}=this.childPos(t);n&&(e.append(this.children[i].split(n),0),this.children[i].merge(n,this.children[i].length,null,!1,0,0),i++);for(let t=i;t<this.children.length;t++)e.append(this.children[t],0);for(;i>0&&0==this.children[i-1].length;)this.children[--i].destroy();return this.children.length=i,this.markDirty(),this.length=t,e}transferDOM(t){this.dom&&(this.markDirty(),t.setDOM(this.dom),t.prevAttrs=void 0===this.prevAttrs?this.attrs:this.prevAttrs,this.prevAttrs=void 0,this.dom=null)}setDeco(t){Xi(this.attrs,t)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=t)}append(t,e){$i(this,t,e)}addLineDeco(t){let e=t.spec.attributes,i=t.spec.class;e&&(this.attrs=Yi(e,this.attrs||{})),i&&(this.attrs=Yi({class:i},this.attrs||{}))}domAtPos(t){return Ki(this,t)}reuseDOM(t){"DIV"==t.nodeName&&(this.setDOM(t),this.flags|=6)}sync(t,e){var i;this.dom?4&this.flags&&(Li(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&&(Qi(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(t,e);let n=this.dom.lastChild;for(;n&&Ii.get(n)instanceof Wi;)n=n.lastChild;if(!(n&&this.length&&("BR"==n.nodeName||0!=(null===(i=Ii.get(n))||void 0===i?void 0:i.isEditable)||fi.ios&&this.children.some(t=>t instanceof zi)))){let t=document.createElement("BR");t.cmIgnore=!0,this.dom.appendChild(t)}}measureTextSize(){if(0==this.children.length||this.length>20)return null;let t,e=0;for(let i of this.children){if(!(i instanceof zi)||/[^ -~]/.test(i.text))return null;let n=mi(i.dom);if(1!=n.length)return null;e+=n[0].width,t=n[0].height}return e?{lineHeight:this.dom.getBoundingClientRect().height,charWidth:e/this.length,textHeight:t}:null}coordsAt(t,e){let i=Ui(this,t,e);if(!this.children.length&&i&&this.parent){let{heightOracle:t}=this.parent.view.viewState,e=i.bottom-i.top;if(Math.abs(e-t.lineHeight)<2&&t.textHeight<e){let n=(e-t.textHeight)/2;return{top:i.top+n,bottom:i.bottom-n,left:i.left,right:i.left}}}return i}become(t){return t instanceof hn&&0==this.children.length&&0==t.children.length&&Xi(this.attrs,t.attrs)&&this.breakAfter==t.breakAfter}covers(){return!0}static find(t,e){for(let i=0,n=0;i<t.children.length;i++){let s=t.children[i],o=n+s.length;if(o>=e){if(s instanceof hn)return s;if(o>e)break}n=o+s.breakAfter}return null}}class cn extends Ii{constructor(t,e,i){super(),this.widget=t,this.length=e,this.deco=i,this.breakAfter=0,this.prevWidget=null}merge(t,e,i,n,s,o){return!(i&&(!(i instanceof cn&&this.widget.compare(i.widget))||t>0&&s<=0||e<this.length&&o<=0))&&(this.length=t+(i?i.length:0)+(this.length-e),!0)}domAtPos(t){return 0==t?Ri.before(this.dom):Ri.after(this.dom,t==this.length)}split(t){let e=this.length-t;this.length=t;let i=new cn(this.widget,e,this.deco);return i.breakAfter=this.breakAfter,i}get children(){return Ni}sync(t){this.dom&&this.widget.updateDOM(this.dom,t)||(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(t)),this.widget.editable||(this.dom.contentEditable="false"))}get overrideDOMText(){return this.parent?this.parent.view.state.doc.slice(this.posAtStart,this.posAtEnd):rt.empty}domBoundsAround(){return null}become(t){return t instanceof cn&&t.widget.constructor==this.widget.constructor&&(t.widget.compare(this.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=t.widget,this.length=t.length,this.deco=t.deco,this.breakAfter=t.breakAfter,!0)}ignoreMutation(){return!0}ignoreEvent(t){return this.widget.ignoreEvent(t)}get isEditable(){return!1}get isWidget(){return!0}coordsAt(t,e){let i=this.widget.coordsAt(this.dom,t,e);return i||(this.widget instanceof fn?null:xi(this.dom.getBoundingClientRect(),this.length?0==t:e<=0))}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}covers(t){let{startSide:e,endSide:i}=this.deco;return e!=i&&(t<0?e<0:i>0)}}class fn extends tn{constructor(t){super(),this.height=t}toDOM(){let t=document.createElement("div");return t.className="cm-gap",this.updateDOM(t),t}eq(t){return t.height==this.height}updateDOM(t){return t.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}class dn{constructor(t,e,i,n){this.doc=t,this.pos=e,this.end=i,this.disallowBlockEffectsFor=n,this.content=[],this.curLine=null,this.breakAtStart=0,this.pendingBuffer=0,this.bufferMarks=[],this.atCursorPos=!0,this.openStart=-1,this.openEnd=-1,this.text="",this.textOff=0,this.cursor=t.iter(),this.skip=e}posCovered(){if(0==this.content.length)return!this.breakAtStart&&this.doc.lineAt(this.pos).from!=this.pos;let t=this.content[this.content.length-1];return!(t.breakAfter||t instanceof cn&&t.deco.endSide<0)}getLine(){return this.curLine||(this.content.push(this.curLine=new hn),this.atCursorPos=!0),this.curLine}flushBuffer(t=this.bufferMarks){this.pendingBuffer&&(this.curLine.append(un(new _i(-1),t),t.length),this.pendingBuffer=0)}addBlockWidget(t){this.flushBuffer(),this.curLine=null,this.content.push(t)}finish(t){this.pendingBuffer&&t<=this.bufferMarks.length?this.flushBuffer():this.pendingBuffer=0,this.posCovered()||t&&this.content.length&&this.content[this.content.length-1]instanceof cn||this.getLine()}buildText(t,e,i){for(;t>0;){if(this.textOff==this.text.length){let{value:e,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,this.atCursorPos=!0,t--;continue}this.text=e,this.textOff=0}let n=Math.min(this.text.length-this.textOff,t),s=Math.min(n,512);this.flushBuffer(e.slice(e.length-i)),this.getLine().append(un(new zi(this.text.slice(this.textOff,this.textOff+s)),e),i),this.atCursorPos=!0,this.textOff+=s,t-=s,i=n<=s?0:e.length}}span(t,e,i,n){this.buildText(e-t,i,n),this.pos=e,this.openStart<0&&(this.openStart=n)}point(t,e,i,n,s,o){if(this.disallowBlockEffectsFor[o]&&i instanceof rn){if(i.block)throw new RangeError("Block decorations may not be specified via plugins");if(e>this.doc.lineAt(this.pos).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}let r=e-t;if(i instanceof rn)if(i.block)i.startSide>0&&!this.posCovered()&&this.getLine(),this.addBlockWidget(new cn(i.widget||pn.block,r,i));else{let o=qi.create(i.widget||pn.inline,r,r?0:i.startSide),l=this.atCursorPos&&!o.isEditable&&s<=n.length&&(t<e||i.startSide>0),a=!o.isEditable&&(t<e||s>n.length||i.startSide<=0),h=this.getLine();2!=this.pendingBuffer||l||o.isEditable||(this.pendingBuffer=0),this.flushBuffer(n),l&&(h.append(un(new _i(1),n),s),s=n.length+Math.max(0,s-n.length)),h.append(un(o,n),s),this.atCursorPos=a,this.pendingBuffer=a?t<e||s>n.length?1:2:0,this.pendingBuffer&&(this.bufferMarks=n.slice())}else this.doc.lineAt(this.pos).from==this.pos&&this.getLine().addLineDeco(i);r&&(this.textOff+r<=this.text.length?this.textOff+=r:(this.skip+=r-(this.text.length-this.textOff),this.text="",this.textOff=0),this.pos=e),this.openStart<0&&(this.openStart=s)}static build(t,e,i,n,s){let o=new dn(t,e,i,s);return o.openEnd=Te.spans(n,e,i,o),o.openStart<0&&(o.openStart=o.openEnd),o.finish(o.openEnd),o}}function un(t,e){for(let i of e)t=new Wi(i,[t],t.length);return t}class pn extends tn{constructor(t){super(),this.tag=t}eq(t){return t.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(t){return t.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}pn.inline=new pn("span"),pn.block=new pn("div");var mn=function(t){return t[t.LTR=0]="LTR",t[t.RTL=1]="RTL",t}(mn||(mn={}));const gn=mn.LTR,wn=mn.RTL;function vn(t){let e=[];for(let i=0;i<t.length;i++)e.push(1<<+t[i]);return e}const bn=vn("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),yn=vn("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),xn=Object.create(null),kn=[];for(let t of["()","[]","{}"]){let e=t.charCodeAt(0),i=t.charCodeAt(1);xn[e]=i,xn[i]=-e}function Sn(t){return t<=247?bn[t]:1424<=t&&t<=1524?2:1536<=t&&t<=1785?yn[t-1536]:1774<=t&&t<=2220?4:8192<=t&&t<=8204?256:64336<=t&&t<=65023?4:1}const Cn=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class An{get dir(){return this.level%2?wn:gn}constructor(t,e,i){this.from=t,this.to=e,this.level=i}side(t,e){return this.dir==e==t?this.to:this.from}forward(t,e){return t==(this.dir==e)}static find(t,e,i,n){let s=-1;for(let o=0;o<t.length;o++){let r=t[o];if(r.from<=e&&r.to>=e){if(r.level==i)return o;(s<0||(0!=n?n<0?r.from<e:r.to>e:t[s].level>r.level))&&(s=o)}}if(s<0)throw new RangeError("Index out of range");return s}}function Mn(t,e){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++){let n=t[i],s=e[i];if(n.from!=s.from||n.to!=s.to||n.direction!=s.direction||!Mn(n.inner,s.inner))return!1}return!0}const Tn=[];function On(t,e,i,n,s,o,r){let l=n%2?2:1;if(n%2==s%2)for(let a=e,h=0;a<i;){let e=!0,c=!1;if(h==o.length||a<o[h].from){let t=Tn[a];t!=l&&(e=!1,c=16==t)}let f=e||1!=l?null:[],d=e?n:n+1,u=a;t:for(;;)if(h<o.length&&u==o[h].from){if(c)break t;let p=o[h];if(!e)for(let t=p.to,e=h+1;;){if(t==i)break t;if(!(e<o.length&&o[e].from==t)){if(Tn[t]==l)break t;break}t=o[e++].to}if(h++,f)f.push(p);else{p.from>a&&r.push(new An(a,p.from,d)),Dn(t,p.direction==gn!=!(d%2)?n+1:n,s,p.inner,p.from,p.to,r),a=p.to}u=p.to}else{if(u==i||(e?Tn[u]!=l:Tn[u]==l))break;u++}f?On(t,a,u,n+1,s,f,r):a<u&&r.push(new An(a,u,d)),a=u}else for(let a=i,h=o.length;a>e;){let i=!0,c=!1;if(!h||a>o[h-1].to){let t=Tn[a-1];t!=l&&(i=!1,c=16==t)}let f=i||1!=l?null:[],d=i?n:n+1,u=a;t:for(;;)if(h&&u==o[h-1].to){if(c)break t;let p=o[--h];if(!i)for(let t=p.from,i=h;;){if(t==e)break t;if(!i||o[i-1].to!=t){if(Tn[t-1]==l)break t;break}t=o[--i].from}if(f)f.push(p);else{p.to<a&&r.push(new An(p.to,a,d)),Dn(t,p.direction==gn!=!(d%2)?n+1:n,s,p.inner,p.from,p.to,r),a=p.from}u=p.from}else{if(u==e||(i?Tn[u-1]!=l:Tn[u-1]==l))break;u--}f?On(t,u,a,n+1,s,f,r):u<a&&r.push(new An(u,a,d)),a=u}}function Dn(t,e,i,n,s,o,r){let l=e%2?2:1;!function(t,e,i,n,s){for(let o=0;o<=n.length;o++){let r=o?n[o-1].to:e,l=o<n.length?n[o].from:i,a=o?256:s;for(let e=r,i=a,n=a;e<l;e++){let s=Sn(t.charCodeAt(e));512==s?s=i:8==s&&4==n&&(s=16),Tn[e]=4==s?2:s,7&s&&(n=s),i=s}for(let t=r,e=a,n=a;t<l;t++){let s=Tn[t];if(128==s)t<l-1&&e==Tn[t+1]&&24&e?s=Tn[t]=e:Tn[t]=256;else if(64==s){let s=t+1;for(;s<l&&64==Tn[s];)s++;let o=t&&8==e||s<i&&8==Tn[s]?1==n?1:8:256;for(let e=t;e<s;e++)Tn[e]=o;t=s-1}else 8==s&&1==n&&(Tn[t]=1);e=s,7&s&&(n=s)}}}(t,s,o,n,l),function(t,e,i,n,s){let o=1==s?2:1;for(let r=0,l=0,a=0;r<=n.length;r++){let h=r?n[r-1].to:e,c=r<n.length?n[r].from:i;for(let e,i,n,r=h;r<c;r++)if(i=xn[e=t.charCodeAt(r)])if(i<0){for(let t=l-3;t>=0;t-=3)if(kn[t+1]==-i){let e=kn[t+2],i=2&e?s:4&e?1&e?o:s:0;i&&(Tn[r]=Tn[kn[t]]=i),l=t;break}}else{if(189==kn.length)break;kn[l++]=r,kn[l++]=e,kn[l++]=a}else if(2==(n=Tn[r])||1==n){let t=n==s;a=t?0:1;for(let e=l-3;e>=0;e-=3){let i=kn[e+2];if(2&i)break;if(t)kn[e+2]|=2;else{if(4&i)break;kn[e+2]|=4}}}}}(t,s,o,n,l),function(t,e,i,n){for(let s=0,o=n;s<=i.length;s++){let r=s?i[s-1].to:t,l=s<i.length?i[s].from:e;for(let a=r;a<l;){let r=Tn[a];if(256==r){let r=a+1;for(;;)if(r==l){if(s==i.length)break;r=i[s++].to,l=s<i.length?i[s].from:e}else{if(256!=Tn[r])break;r++}let h=1==o,c=h==(1==(r<e?Tn[r]:n))?h?1:2:n;for(let e=r,n=s,o=n?i[n-1].to:t;e>a;)e==o&&(e=i[--n].from,o=n?i[n-1].to:t),Tn[--e]=c;a=r}else o=r,a++}}}(s,o,n,l),On(t,s,o,e,i,n,r)}function Ln(t){return[new An(0,t,0)]}let En="";function Pn(t,e,i,n,s){var o;let r=n.head-t.from,l=An.find(e,r,null!==(o=n.bidiLevel)&&void 0!==o?o:-1,n.assoc),a=e[l],h=a.side(s,i);if(r==h){let t=l+=s?1:-1;if(t<0||t>=e.length)return null;a=e[l=t],r=a.side(!s,i),h=a.side(s,i)}let c=gt(t.text,r,a.forward(s,i));(c<a.from||c>a.to)&&(c=h),En=t.text.slice(Math.min(r,c),Math.max(r,c));let f=l==(s?e.length-1:0)?null:e[l+(s?1:-1)];return f&&c==h&&f.level+(s?0:1)<a.level?Lt.cursor(f.side(!s,i)+t.from,f.forward(s,i)?1:-1,f.level):Lt.cursor(c+t.from,a.forward(s,i)?-1:1,a.level)}function Bn(t,e,i){for(let n=e;n<i;n++){let e=Sn(t.charCodeAt(n));if(1==e)return gn;if(2==e||4==e)return wn}return gn}const Rn=Bt.define(),Nn=Bt.define(),In=Bt.define(),jn=Bt.define(),Hn=Bt.define(),Vn=Bt.define(),Fn=Bt.define(),zn=Bt.define(),Wn=Bt.define(),qn=Bt.define({combine:t=>t.some(t=>t)}),_n=Bt.define({combine:t=>t.some(t=>t)}),Kn=Bt.define();class $n{constructor(t,e="nearest",i="nearest",n=5,s=5,o=!1){this.range=t,this.y=e,this.x=i,this.yMargin=n,this.xMargin=s,this.isSnapshot=o}map(t){return t.empty?this:new $n(this.range.map(t),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(t){return this.range.to<=t.doc.length?this:new $n(Lt.cursor(t.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const Un=he.define({map:(t,e)=>t.map(e)}),Gn=he.define();function Yn(t,e,i){let n=t.facet(jn);n.length?n[0](e):window.onerror&&window.onerror(String(e),i,void 0,void 0,e)||(i?console.error(i+":",e):console.error(e))}const Jn=Bt.define({combine:t=>!t.length||t[0]});let Xn=0;const Qn=Bt.define({combine:t=>t.filter((e,i)=>{for(let n=0;n<i;n++)if(t[n].plugin==e.plugin)return!1;return!0})});class Zn{constructor(t,e,i,n,s){this.id=t,this.create=e,this.domEventHandlers=i,this.domEventObservers=n,this.baseExtensions=s(this),this.extension=this.baseExtensions.concat(Qn.of({plugin:this,arg:void 0}))}of(t){return this.baseExtensions.concat(Qn.of({plugin:this,arg:t}))}static define(t,e){const{eventHandlers:i,eventObservers:n,provide:s,decorations:o}=e||{};return new Zn(Xn++,t,i,n,t=>{let e=[];return o&&e.push(ns.of(e=>{let i=e.plugin(t);return i?o(i):nn.none})),s&&e.push(s(t)),e})}static fromClass(t,e){return Zn.define((e,i)=>new t(e,i),e)}}class ts{constructor(t){this.spec=t,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(t){if(this.value){if(this.mustUpdate){let t=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(t)}catch(e){if(Yn(t.state,e,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch(t){}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(t,this.spec.arg)}catch(e){Yn(t.state,e,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(t){var e;if(null===(e=this.value)||void 0===e?void 0:e.destroy)try{this.value.destroy()}catch(e){Yn(t.state,e,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const es=Bt.define(),is=Bt.define(),ns=Bt.define(),ss=Bt.define(),os=Bt.define(),rs=Bt.define();function ls(t,e){let i=t.state.facet(rs);if(!i.length)return i;let n=i.map(e=>e instanceof Function?e(t):e),s=[];return Te.spans(n,e.from,e.to,{point(){},span(t,i,n,o){let r=t-e.from,l=i-e.from,a=s;for(let t=n.length-1;t>=0;t--,o--){let i,s=n[t].spec.bidiIsolate;if(null==s&&(s=Bn(e.text,r,l)),o>0&&a.length&&(i=a[a.length-1]).to==r&&i.direction==s)i.to=l,a=i.inner;else{let t={from:r,to:l,direction:s,inner:[]};a.push(t),a=t.inner}}}}),s}const as=Bt.define();function hs(t){let e=0,i=0,n=0,s=0;for(let o of t.state.facet(as)){let r=o(t);r&&(null!=r.left&&(e=Math.max(e,r.left)),null!=r.right&&(i=Math.max(i,r.right)),null!=r.top&&(n=Math.max(n,r.top)),null!=r.bottom&&(s=Math.max(s,r.bottom)))}return{left:e,right:i,top:n,bottom:s}}const cs=Bt.define();class fs{constructor(t,e,i,n){this.fromA=t,this.toA=e,this.fromB=i,this.toB=n}join(t){return new fs(Math.min(this.fromA,t.fromA),Math.max(this.toA,t.toA),Math.min(this.fromB,t.fromB),Math.max(this.toB,t.toB))}addToSet(t){let e=t.length,i=this;for(;e>0;e--){let n=t[e-1];if(!(n.fromA>i.toA)){if(n.toA<i.fromA)break;i=i.join(n),t.splice(e-1,1)}}return t.splice(e,0,i),t}static extendWithRanges(t,e){if(0==e.length)return t;let i=[];for(let n=0,s=0,o=0,r=0;;n++){let l=n==t.length?null:t[n],a=o-r,h=l?l.fromB:1e9;for(;s<e.length&&e[s]<h;){let t=e[s],n=e[s+1],o=Math.max(r,t),l=Math.min(h,n);if(o<=l&&new fs(o+a,l+a,o,l).addToSet(i),n>h)break;s+=2}if(!l)return i;new fs(l.fromA,l.toA,l.fromB,l.toB).addToSet(i),o=l.toA,r=l.toB}}}class ds{constructor(t,e,i){this.view=t,this.state=e,this.transactions=i,this.flags=0,this.startState=t.state,this.changes=kt.empty(this.startState.doc.length);for(let t of i)this.changes=this.changes.compose(t.changes);let n=[];this.changes.iterChangedRanges((t,e,i,s)=>n.push(new fs(t,e,i,s))),this.changedRanges=n}static create(t,e,i){return new ds(t,e,i)}get viewportChanged(){return(4&this.flags)>0}get viewportMoved(){return(8&this.flags)>0}get heightChanged(){return(2&this.flags)>0}get geometryChanged(){return this.docChanged||(18&this.flags)>0}get focusChanged(){return(1&this.flags)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(t=>t.selection)}get empty(){return 0==this.flags&&0==this.transactions.length}}class us extends Ii{get length(){return this.view.state.doc.length}constructor(t){super(),this.view=t,this.decorations=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.markedForComposition=new Set,this.editContextFormatting=nn.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.setDOM(t.contentDOM),this.children=[new hn],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new fs(0,0,0,t.state.doc.length)],0,null)}update(t){var e;let i=t.changedRanges;this.minWidth>0&&i.length&&(i.every(({fromA:t,toA:e})=>e<this.minWidthFrom||t>this.minWidthTo)?(this.minWidthFrom=t.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=t.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(t);let n=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&((null===(e=this.domChanged)||void 0===e?void 0:e.newSel)?n=this.domChanged.newSel.head:function(t,e){let i=!1;e&&t.iterChangedRanges((t,n)=>{t<e.to&&n>e.from&&(i=!0)});return i}(t.changes,this.hasComposition)||t.selectionSet||(n=t.state.selection.main.head));let s=n>-1?function(t,e,i){let n=ps(t,i);if(!n)return null;let{node:s,from:o,to:r}=n,l=s.nodeValue;if(/[\n\r]/.test(l))return null;if(t.state.doc.sliceString(n.from,n.to)!=l)return null;let a=e.invertedDesc,h=new fs(a.mapPos(o),a.mapPos(r),o,r),c=[];for(let e=s.parentNode;;e=e.parentNode){let i=Ii.get(e);if(i instanceof Wi)c.push({node:e,deco:i.mark});else{if(i instanceof hn||"DIV"==e.nodeName&&e.parentNode==t.contentDOM)return{range:h,text:s,marks:c,line:e};if(e==t.contentDOM)return null;c.push({node:e,deco:new sn({inclusive:!0,attributes:Zi(e),tagName:e.tagName.toLowerCase()})})}}}(this.view,t.changes,n):null;if(this.domChanged=null,this.hasComposition){this.markedForComposition.clear();let{from:e,to:n}=this.hasComposition;i=new fs(e,n,t.changes.mapPos(e,-1),t.changes.mapPos(n,1)).addToSet(i.slice())}this.hasComposition=s?{from:s.range.fromB,to:s.range.toB}:null,(fi.ie||fi.chrome)&&!s&&t&&t.state.doc.lines!=t.startState.doc.lines&&(this.forceSelection=!0);let o=function(t,e,i){let n=new ms;return Te.compare(t,e,i,n),n.changes}(this.decorations,this.updateDeco(),t.changes);return i=fs.extendWithRanges(i,o),!!(7&this.flags||0!=i.length)&&(this.updateInner(i,t.startState.doc.length,s),t.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(t,e,i){this.view.viewState.mustMeasureContent=!0,this.updateChildren(t,e,i);let{observer:n}=this.view;n.ignore(()=>{this.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let t=fi.chrome||fi.ios?{node:n.selectionRange.focusNode,written:!1}:void 0;this.sync(this.view,t),this.flags&=-8,t&&(t.written||n.selectionRange.focusNode!=t.node)&&(this.forceSelection=!0),this.dom.style.height=""}),this.markedForComposition.forEach(t=>t.flags&=-9);let s=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let t of this.children)t instanceof cn&&t.widget instanceof fn&&s.push(t.dom);n.updateGaps(s)}updateChildren(t,e,i){let n=i?i.range.addToSet(t.slice()):t,s=this.childCursor(e);for(let t=n.length-1;;t--){let e=t>=0?n[t]:null;if(!e)break;let o,r,l,a,{fromA:h,toA:c,fromB:f,toB:d}=e;if(i&&i.range.fromB<d&&i.range.toB>f){let t=dn.build(this.view.state.doc,f,i.range.fromB,this.decorations,this.dynamicDecorationMap),e=dn.build(this.view.state.doc,i.range.toB,d,this.decorations,this.dynamicDecorationMap);r=t.breakAtStart,l=t.openStart,a=e.openEnd;let n=this.compositionView(i);e.breakAtStart?n.breakAfter=1:e.content.length&&n.merge(n.length,n.length,e.content[0],!1,e.openStart,0)&&(n.breakAfter=e.content[0].breakAfter,e.content.shift()),t.content.length&&n.merge(0,0,t.content[t.content.length-1],!0,0,t.openEnd)&&t.content.pop(),o=t.content.concat(n).concat(e.content)}else({content:o,breakAtStart:r,openStart:l,openEnd:a}=dn.build(this.view.state.doc,f,d,this.decorations,this.dynamicDecorationMap));let{i:u,off:p}=s.findPos(c,1),{i:m,off:g}=s.findPos(h,-1);Vi(this,m,g,u,p,o,r,l,a)}i&&this.fixCompositionDOM(i)}updateEditContextFormatting(t){this.editContextFormatting=this.editContextFormatting.map(t.changes);for(let e of t.transactions)for(let t of e.effects)t.is(Gn)&&(this.editContextFormatting=t.value)}compositionView(t){let e=new zi(t.text.nodeValue);e.flags|=8;for(let{deco:i}of t.marks)e=new Wi(i,[e],e.length);let i=new hn;return i.append(e,0),i}fixCompositionDOM(t){let e=(t,e)=>{e.flags|=8|(e.children.some(t=>7&t.flags)?1:0),this.markedForComposition.add(e);let i=Ii.get(t);i&&i!=e&&(i.dom=null),e.setDOM(t)},i=this.childPos(t.range.fromB,1),n=this.children[i.i];e(t.line,n);for(let s=t.marks.length-1;s>=-1;s--)i=n.childPos(i.off,1),n=n.children[i.i],e(s>=0?t.marks[s].node:t.text,n)}updateSelection(t=!1,e=!1){!t&&this.view.observer.selectionRange.focusNode||this.view.observer.readSelectionRange();let i=this.view.root.activeElement,n=i==this.dom,s=!n&&!(this.view.state.facet(Jn)||this.dom.tabIndex>-1)&&pi(this.dom,this.view.observer.selectionRange)&&!(i&&this.dom.contains(i));if(!(n||e||s))return;let o=this.forceSelection;this.forceSelection=!1;let r=this.view.state.selection.main,l=this.moveToLine(this.domAtPos(r.anchor)),a=r.empty?l:this.moveToLine(this.domAtPos(r.head));if(fi.gecko&&r.empty&&!this.hasComposition&&(1==(h=l).node.nodeType&&h.node.firstChild&&(0==h.offset||"false"==h.node.childNodes[h.offset-1].contentEditable)&&(h.offset==h.node.childNodes.length||"false"==h.node.childNodes[h.offset].contentEditable))){let t=document.createTextNode("");this.view.observer.ignore(()=>l.node.insertBefore(t,l.node.childNodes[l.offset]||null)),l=a=new Ri(t,0),o=!0}var h;let c=this.view.observer.selectionRange;!o&&c.focusNode&&(gi(l.node,l.offset,c.anchorNode,c.anchorOffset)&&gi(a.node,a.offset,c.focusNode,c.focusOffset)||this.suppressWidgetCursorChange(c,r))||(this.view.observer.ignore(()=>{fi.android&&fi.chrome&&this.dom.contains(c.focusNode)&&function(t,e){for(let i=t;i&&i!=e;i=i.assignedSlot||i.parentNode)if(1==i.nodeType&&"false"==i.contentEditable)return!0;return!1}(c.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let t=di(this.view.root);if(t)if(r.empty){if(fi.gecko){let t=(e=l.node,n=l.offset,1!=e.nodeType?0:(n&&"false"==e.childNodes[n-1].contentEditable?1:0)|(n<e.childNodes.length&&"false"==e.childNodes[n].contentEditable?2:0));if(t&&3!=t){let e=(1==t?Pi:Bi)(l.node,l.offset);e&&(l=new Ri(e.node,e.offset))}}t.collapse(l.node,l.offset),null!=r.bidiLevel&&void 0!==t.caretBidiLevel&&(t.caretBidiLevel=r.bidiLevel)}else if(t.extend){t.collapse(l.node,l.offset);try{t.extend(a.node,a.offset)}catch(t){}}else{let e=document.createRange();r.anchor>r.head&&([l,a]=[a,l]),e.setEnd(a.node,a.offset),e.setStart(l.node,l.offset),t.removeAllRanges(),t.addRange(e)}else;var e,n;s&&this.view.root.activeElement==this.dom&&(this.dom.blur(),i&&i.focus())}),this.view.observer.setSelectionRange(l,a)),this.impreciseAnchor=l.precise?null:new Ri(c.anchorNode,c.anchorOffset),this.impreciseHead=a.precise?null:new Ri(c.focusNode,c.focusOffset)}suppressWidgetCursorChange(t,e){return this.hasComposition&&e.empty&&gi(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)&&this.posFromDOM(t.focusNode,t.focusOffset)==e.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:t}=this,e=t.state.selection.main,i=di(t.root),{anchorNode:n,anchorOffset:s}=t.observer.selectionRange;if(!(i&&e.empty&&e.assoc&&i.modify))return;let o=hn.find(this,e.head);if(!o)return;let r=o.posAtStart;if(e.head==r||e.head==r+o.length)return;let l=this.coordsAt(e.head,-1),a=this.coordsAt(e.head,1);if(!l||!a||l.bottom>a.top)return;let h=this.domAtPos(e.head+e.assoc);i.collapse(h.node,h.offset),i.modify("move",e.assoc<0?"forward":"backward","lineboundary"),t.observer.readSelectionRange();let c=t.observer.selectionRange;t.docView.posFromDOM(c.anchorNode,c.anchorOffset)!=e.from&&i.collapse(n,s)}moveToLine(t){let e,i=this.dom;if(t.node!=i)return t;for(let n=t.offset;!e&&n<i.childNodes.length;n++){let t=Ii.get(i.childNodes[n]);t instanceof hn&&(e=t.domAtPos(0))}for(let n=t.offset-1;!e&&n>=0;n--){let t=Ii.get(i.childNodes[n]);t instanceof hn&&(e=t.domAtPos(t.length))}return e?new Ri(e.node,e.offset,!0):t}nearest(t){for(let e=t;e;){let t=Ii.get(e);if(t&&t.rootView==this)return t;e=e.parentNode}return null}posFromDOM(t,e){let i=this.nearest(t);if(!i)throw new RangeError("Trying to find position for a DOM position outside of the document");return i.localPosFromDOM(t,e)+i.posAtStart}domAtPos(t){let{i:e,off:i}=this.childCursor().findPos(t,-1);for(;e<this.children.length-1;){let t=this.children[e];if(i<t.length||t instanceof hn)break;e++,i=0}return this.children[e].domAtPos(i)}coordsAt(t,e){let i=null,n=0;for(let s=this.length,o=this.children.length-1;o>=0;o--){let r=this.children[o],l=s-r.breakAfter,a=l-r.length;if(l<t)break;if(a<=t&&(a<t||r.covers(-1))&&(l>t||r.covers(1))&&(!i||r instanceof hn&&!(i instanceof hn&&e>=0)))i=r,n=a;else if(i&&a==t&&l==t&&r instanceof cn&&Math.abs(e)<2){if(r.deco.startSide<0)break;o&&(i=null)}s=a}return i?i.coordsAt(t-n,e):null}coordsForChar(t){let{i:e,off:i}=this.childPos(t,1),n=this.children[e];if(!(n instanceof hn))return null;for(;n.children.length;){let{i:t,off:e}=n.childPos(i,1);for(;;t++){if(t==n.children.length)return null;if((n=n.children[t]).length)break}i=e}if(!(n instanceof zi))return null;let s=gt(n.text,i);if(s==i)return null;let o=Oi(n.dom,i,s).getClientRects();for(let t=0;t<o.length;t++){let e=o[t];if(t==o.length-1||e.top<e.bottom&&e.left<e.right)return e}return null}measureVisibleLineHeights(t){let e=[],{from:i,to:n}=t,s=this.view.contentDOM.clientWidth,o=s>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,r=-1,l=this.view.textDirection==mn.LTR;for(let t=0,a=0;a<this.children.length;a++){let h=this.children[a],c=t+h.length;if(c>n)break;if(t>=i){let i=h.dom.getBoundingClientRect();if(e.push(i.height),o){let e=h.dom.lastChild,n=e?mi(e):[];if(n.length){let e=n[n.length-1],o=l?e.right-i.left:i.right-e.left;o>r&&(r=o,this.minWidth=s,this.minWidthFrom=t,this.minWidthTo=c)}}}t=c+h.breakAfter}return e}textDirectionAt(t){let{i:e}=this.childPos(t,1);return"rtl"==getComputedStyle(this.children[e].dom).direction?mn.RTL:mn.LTR}measureTextSize(){for(let t of this.children)if(t instanceof hn){let e=t.measureTextSize();if(e)return e}let t,e,i,n=document.createElement("div");return n.className="cm-line",n.style.width="99999px",n.style.position="absolute",n.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.dom.appendChild(n);let s=mi(n.firstChild)[0];t=n.getBoundingClientRect().height,e=s?s.width/27:7,i=s?s.height:t,n.remove()}),{lineHeight:t,charWidth:e,textHeight:i}}childCursor(t=this.length){let e=this.children.length;return e&&(t-=this.children[--e].length),new Hi(this.children,t,e)}computeBlockGapDeco(){let t=[],e=this.view.viewState;for(let i=0,n=0;;n++){let s=n==e.viewports.length?null:e.viewports[n],o=s?s.from-1:this.length;if(o>i){let n=(e.lineBlockAt(o).bottom-e.lineBlockAt(i).top)/this.view.scaleY;t.push(nn.replace({widget:new fn(n),block:!0,inclusive:!0,isBlockGap:!0}).range(i,o))}if(!s)break;i=s.to+1}return nn.set(t)}updateDeco(){let t=1,e=this.view.state.facet(ns).map(e=>(this.dynamicDecorationMap[t++]="function"==typeof e)?e(this.view):e),i=!1,n=this.view.state.facet(ss).map((t,e)=>{let n="function"==typeof t;return n&&(i=!0),n?t(this.view):t});for(n.length&&(this.dynamicDecorationMap[t++]=i,e.push(Te.join(n))),this.decorations=[this.editContextFormatting,...e,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];t<this.decorations.length;)this.dynamicDecorationMap[t++]=!1;return this.decorations}scrollIntoView(t){if(t.isSnapshot){let e=this.view.viewState.lineBlockAt(t.range.head);return this.view.scrollDOM.scrollTop=e.top-t.yMargin,void(this.view.scrollDOM.scrollLeft=t.xMargin)}for(let e of this.view.state.facet(Kn))try{if(e(this.view,t.range,t))return!0}catch(t){Yn(this.view.state,t,"scroll handler")}let e,{range:i}=t,n=this.coordsAt(i.head,i.empty?i.assoc:i.head>i.anchor?-1:1);if(!n)return;!i.empty&&(e=this.coordsAt(i.anchor,i.anchor>i.head?-1:1))&&(n={left:Math.min(n.left,e.left),top:Math.min(n.top,e.top),right:Math.max(n.right,e.right),bottom:Math.max(n.bottom,e.bottom)});let s=hs(this.view),o={left:n.left-s.left,top:n.top-s.top,right:n.right+s.right,bottom:n.bottom+s.bottom},{offsetWidth:r,offsetHeight:l}=this.view.scrollDOM;!function(t,e,i,n,s,o,r,l){let a=t.ownerDocument,h=a.defaultView||window;for(let c=t,f=!1;c&&!f;)if(1==c.nodeType){let t,d=c==a.body,u=1,p=1;if(d)t=ki(h);else{if(/^(fixed|sticky)$/.test(getComputedStyle(c).position)&&(f=!0),c.scrollHeight<=c.clientHeight&&c.scrollWidth<=c.clientWidth){c=c.assignedSlot||c.parentNode;continue}let e=c.getBoundingClientRect();({scaleX:u,scaleY:p}=Si(c,e)),t={left:e.left,right:e.left+c.clientWidth*u,top:e.top,bottom:e.top+c.clientHeight*p}}let m=0,g=0;if("nearest"==s)e.top<t.top?(g=e.top-(t.top+r),i>0&&e.bottom>t.bottom+g&&(g=e.bottom-t.bottom+r)):e.bottom>t.bottom&&(g=e.bottom-t.bottom+r,i<0&&e.top-g<t.top&&(g=e.top-(t.top+r)));else{let n=e.bottom-e.top,o=t.bottom-t.top;g=("center"==s&&n<=o?e.top+n/2-o/2:"start"==s||"center"==s&&i<0?e.top-r:e.bottom-o+r)-t.top}if("nearest"==n?e.left<t.left?(m=e.left-(t.left+o),i>0&&e.right>t.right+m&&(m=e.right-t.right+o)):e.right>t.right&&(m=e.right-t.right+o,i<0&&e.left<t.left+m&&(m=e.left-(t.left+o))):m=("center"==n?e.left+(e.right-e.left)/2-(t.right-t.left)/2:"start"==n==l?e.left-o:e.right-(t.right-t.left)+o)-t.left,m||g)if(d)h.scrollBy(m,g);else{let t=0,i=0;if(g){let t=c.scrollTop;c.scrollTop+=g/p,i=(c.scrollTop-t)*p}if(m){let e=c.scrollLeft;c.scrollLeft+=m/u,t=(c.scrollLeft-e)*u}e={left:e.left-t,top:e.top-i,right:e.right-t,bottom:e.bottom-i},t&&Math.abs(t-m)<1&&(n="nearest"),i&&Math.abs(i-g)<1&&(s="nearest")}if(d)break;(e.top<t.top||e.bottom>t.bottom||e.left<t.left||e.right>t.right)&&(e={left:Math.max(e.left,t.left),right:Math.min(e.right,t.right),top:Math.max(e.top,t.top),bottom:Math.min(e.bottom,t.bottom)}),c=c.assignedSlot||c.parentNode}else{if(11!=c.nodeType)break;c=c.host}}(this.view.scrollDOM,o,i.head<i.anchor?-1:1,t.x,t.y,Math.max(Math.min(t.xMargin,r),-r),Math.max(Math.min(t.yMargin,l),-l),this.view.textDirection==mn.LTR)}lineHasWidget(t){let{i:e}=this.childCursor().findPos(t);if(e==this.children.length)return!1;let i=t=>t instanceof qi||t.children.some(i);return i(this.children[e])}}function ps(t,e){let i=t.observer.selectionRange;if(!i.focusNode)return null;let n=Pi(i.focusNode,i.focusOffset),s=Bi(i.focusNode,i.focusOffset),o=n||s;if(s&&n&&s.node!=n.node){let e=Ii.get(s.node);if(!e||e instanceof zi&&e.text!=s.node.nodeValue)o=s;else if(t.docView.lastCompositionAfterCursor){let t=Ii.get(n.node);!t||t instanceof zi&&t.text!=n.node.nodeValue||(o=s)}}if(t.docView.lastCompositionAfterCursor=o!=n,!o)return null;let r=e-o.offset;return{from:r,to:r+o.node.nodeValue.length,node:o.node}}let ms=class{constructor(){this.changes=[]}compareRange(t,e){an(t,e,this.changes)}comparePoint(t,e){an(t,e,this.changes)}boundChange(t){an(t,t,this.changes)}};function gs(t,e){return e.left>t?e.left-t:Math.max(0,t-e.right)}function ws(t,e){return e.top>t?e.top-t:Math.max(0,t-e.bottom)}function vs(t,e){return t.top<e.bottom-1&&t.bottom>e.top+1}function bs(t,e){return e<t.top?{top:e,left:t.left,right:t.right,bottom:t.bottom}:t}function ys(t,e){return e>t.bottom?{top:t.top,left:t.left,right:t.right,bottom:e}:t}function xs(t,e,i){let n,s,o,r,l,a,h,c,f=!1;for(let d=t.firstChild;d;d=d.nextSibling){let t=mi(d);for(let u=0;u<t.length;u++){let p=t[u];s&&vs(s,p)&&(p=bs(ys(p,s.bottom),s.top));let m=gs(e,p),g=ws(i,p);if(0==m&&0==g)return 3==d.nodeType?ks(d,e,i):xs(d,e,i);(!n||r>g||r==g&&o>m)&&(n=d,s=p,o=m,r=g,f=!m||(e<p.left?u>0:u<t.length-1)),0==m?i>p.bottom&&(!h||h.bottom<p.bottom)?(l=d,h=p):i<p.top&&(!c||c.top>p.top)&&(a=d,c=p):h&&vs(h,p)?h=ys(h,p.bottom):c&&vs(c,p)&&(c=bs(c,p.top))}}if(h&&h.bottom>=i?(n=l,s=h):c&&c.top<=i&&(n=a,s=c),!n)return{node:t,offset:0};let d=Math.max(s.left,Math.min(s.right,e));return 3==n.nodeType?ks(n,d,i):f&&"false"!=n.contentEditable?xs(n,d,i):{node:t,offset:Array.prototype.indexOf.call(t.childNodes,n)+(e>=(s.left+s.right)/2?1:0)}}function ks(t,e,i){let n=t.nodeValue.length,s=-1,o=1e9,r=0;for(let l=0;l<n;l++){let n=Oi(t,l,l+1).getClientRects();for(let a=0;a<n.length;a++){let h=n[a];if(h.top==h.bottom)continue;r||(r=e-h.left);let c=(h.top>i?h.top-i:i-h.bottom)-1;if(h.left-1<=e&&h.right+1>=e&&c<o){let i=e>=(h.left+h.right)/2,n=i;if(fi.chrome||fi.gecko){let e=Oi(t,l).getBoundingClientRect();Math.abs(e.left-h.right)<.1&&(n=!i)}if(c<=0)return{node:t,offset:l+(n?1:0)};s=l+(n?1:0),o=c}}}return{node:t,offset:s>-1?s:r>0?t.nodeValue.length:0}}function Ss(t,e,i,n=-1){var s,o;let r,l=t.contentDOM.getBoundingClientRect(),a=l.top+t.viewState.paddingTop,{docHeight:h}=t.viewState,{x:c,y:f}=e,d=f-a;if(d<0)return 0;if(d>h)return t.state.doc.length;for(let e=t.viewState.heightOracle.textHeight/2,s=!1;r=t.elementAtHeight(d),r.type!=en.Text;)for(;d=n>0?r.bottom+e:r.top-e,!(d>=0&&d<=h);){if(s)return i?null:0;s=!0,n=-n}f=a+d;let u=r.from;if(u<t.viewport.from)return 0==t.viewport.from?0:i?null:Cs(t,l,r,c,f);if(u>t.viewport.to)return t.viewport.to==t.state.doc.length?t.state.doc.length:i?null:Cs(t,l,r,c,f);let p=t.dom.ownerDocument,m=t.root.elementFromPoint?t.root:p,g=m.elementFromPoint(c,f);g&&!t.contentDOM.contains(g)&&(g=null),g||(c=Math.max(l.left+1,Math.min(l.right-1,c)),g=m.elementFromPoint(c,f),g&&!t.contentDOM.contains(g)&&(g=null));let w,v=-1;if(g&&0!=(null===(s=t.docView.nearest(g))||void 0===s?void 0:s.isEditable)){if(p.caretPositionFromPoint){let t=p.caretPositionFromPoint(c,f);t&&({offsetNode:w,offset:v}=t)}else if(p.caretRangeFromPoint){let t=p.caretRangeFromPoint(c,f);t&&({startContainer:w,startOffset:v}=t)}w&&(!t.contentDOM.contains(w)||fi.safari&&function(t,e,i){return As(t,e,i)}(w,v,c)||fi.chrome&&function(t,e,i){if(0!=e)return As(t,e,i);for(let e=t;;){let t=e.parentNode;if(!t||1!=t.nodeType||t.firstChild!=e)return!1;if(t.classList.contains("cm-line"))break;e=t}let n=1==t.nodeType?t.getBoundingClientRect():Oi(t,0,Math.max(t.nodeValue.length,1)).getBoundingClientRect();return i-n.left>5}(w,v,c))&&(w=void 0),w&&(v=Math.min(yi(w),v))}if(!w||!t.docView.dom.contains(w)){let e=hn.find(t.docView,u);if(!e)return d>r.top+r.height/2?r.to:r.from;({node:w,offset:v}=xs(e.dom,c,f))}let b=t.docView.nearest(w);if(!b)return null;if(b.isWidget&&1==(null===(o=b.dom)||void 0===o?void 0:o.nodeType)){let t=b.dom.getBoundingClientRect();return e.y<t.top||e.y<=t.bottom&&e.x<=(t.left+t.right)/2?b.posAtStart:b.posAtEnd}return b.localPosFromDOM(w,v)+b.posAtStart}function Cs(t,e,i,n,s){let o=Math.round((n-e.left)*t.defaultCharacterWidth);if(t.lineWrapping&&i.height>1.5*t.defaultLineHeight){let e=t.viewState.heightOracle.textHeight;o+=Math.floor((s-i.top-.5*(t.defaultLineHeight-e))/e)*t.viewState.heightOracle.lineLength}let r=t.state.sliceDoc(i.from,i.to);return i.from+function(t,e,i){for(let n=0,s=0;;){if(s>=e)return n;if(n==t.length)break;s+=9==t.charCodeAt(n)?i-s%i:1,n=gt(t,n)}return t.length}(r,o,t.state.tabSize)}function As(t,e,i){let n,s=t;if(3!=t.nodeType||e!=(n=t.nodeValue.length))return!1;for(;;){let t=s.nextSibling;if(t){if("BR"==t.nodeName)break;return!1}{let t=s.parentNode;if(!t||"DIV"==t.nodeName)break;s=t}}return Oi(t,n-1,n).getBoundingClientRect().right>i}function Ms(t,e,i){let n=t.lineBlockAt(e);if(Array.isArray(n.type)){let t;for(let s of n.type){if(s.from>e)break;if(!(s.to<e)){if(s.from<e&&s.to>e)return s;t&&(s.type!=en.Text||t.type==s.type&&!(i<0?s.from<e:s.to>e))||(t=s)}}return t||n}return n}function Ts(t,e,i,n){let s=t.state.doc.lineAt(e.head),o=t.bidiSpans(s),r=t.textDirectionAt(s.from);for(let l=e,a=null;;){let e=Pn(s,o,r,l,i),h=En;if(!e){if(s.number==(i?t.state.doc.lines:1))return l;h="\n",s=t.state.doc.line(s.number+(i?1:-1)),o=t.bidiSpans(s),e=t.visualLineSide(s,!i)}if(a){if(!a(h))return l}else{if(!n)return e;a=n(h)}l=e}}function Os(t,e,i){for(;;){let n=0;for(let s of t)s.between(e-1,e+1,(t,s,o)=>{if(e>t&&e<s){let o=n||i||(e-t<s-e?-1:1);e=o<0?t:s,n=o}});if(!n)return e}}function Ds(t,e){let i=null;for(let n=0;n<e.ranges.length;n++){let s=e.ranges[n],o=null;if(s.empty){let e=Os(t,s.from,0);e!=s.from&&(o=Lt.cursor(e,-1))}else{let e=Os(t,s.from,-1),i=Os(t,s.to,1);e==s.from&&i==s.to||(o=Lt.range(s.from==s.anchor?e:i,s.from==s.head?e:i))}o&&(i||(i=e.ranges.slice()),i[n]=o)}return i?Lt.create(i,e.mainIndex):e}function Ls(t,e,i){let n=Os(t.state.facet(os).map(e=>e(t)),i.from,e.head>i.from?-1:1);return n==i.from?i:Lt.cursor(n,n<i.from?1:-1)}const Es="";class Ps{constructor(t,e){this.points=t,this.text="",this.lineSeparator=e.facet(xe.lineSeparator)}append(t){this.text+=t}lineBreak(){this.text+=Es}readRange(t,e){if(!t)return this;let i=t.parentNode;for(let n=t;;){this.findPointBefore(i,n);let t=this.text.length;this.readNode(n);let s=n.nextSibling;if(s==e)break;let o=Ii.get(n),r=Ii.get(s);(o&&r?o.breakAfter:(o?o.breakAfter:vi(n))||vi(s)&&("BR"!=n.nodeName||n.cmIgnore)&&this.text.length>t)&&!Rs(s,e)&&this.lineBreak(),n=s}return this.findPointBefore(i,e),this}readTextNode(t){let e=t.nodeValue;for(let i of this.points)i.node==t&&(i.pos=this.text.length+Math.min(i.offset,e.length));for(let i=0,n=this.lineSeparator?null:/\r\n?|\n/g;;){let s,o=-1,r=1;if(this.lineSeparator?(o=e.indexOf(this.lineSeparator,i),r=this.lineSeparator.length):(s=n.exec(e))&&(o=s.index,r=s[0].length),this.append(e.slice(i,o<0?e.length:o)),o<0)break;if(this.lineBreak(),r>1)for(let e of this.points)e.node==t&&e.pos>this.text.length&&(e.pos-=r-1);i=o+r}}readNode(t){if(t.cmIgnore)return;let e=Ii.get(t),i=e&&e.overrideDOMText;if(null!=i){this.findPointInside(t,i.length);for(let t=i.iter();!t.next().done;)t.lineBreak?this.lineBreak():this.append(t.value)}else 3==t.nodeType?this.readTextNode(t):"BR"==t.nodeName?t.nextSibling&&this.lineBreak():1==t.nodeType&&this.readRange(t.firstChild,null)}findPointBefore(t,e){for(let i of this.points)i.node==t&&t.childNodes[i.offset]==e&&(i.pos=this.text.length)}findPointInside(t,e){for(let i of this.points)(3==t.nodeType?i.node==t:t.contains(i.node))&&(i.pos=this.text.length+(Bs(t,i.node,i.offset)?e:0))}}function Bs(t,e,i){for(;;){if(!e||i<yi(e))return!1;if(e==t)return!0;i=wi(e)+1,e=e.parentNode}}function Rs(t,e){let i;for(;t!=e&&t;t=t.nextSibling){let e=Ii.get(t);if(!(null==e?void 0:e.isWidget)&&!t.cmIgnore)return!1;e&&(i||(i=[])).push(e)}if(i)for(let t of i){let e=t.overrideDOMText;if(null==e?void 0:e.length)return!1}return!0}class Ns{constructor(t,e){this.node=t,this.offset=e,this.pos=-1}}class Is{constructor(t,e,i,n){this.typeOver=n,this.bounds=null,this.text="",this.domChanged=e>-1;let{impreciseHead:s,impreciseAnchor:o}=t.docView;if(t.state.readOnly&&e>-1)this.newSel=null;else if(e>-1&&(this.bounds=t.docView.domBoundsAround(e,i,0))){let e=s||o?[]:function(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:i,anchorOffset:n,focusNode:s,focusOffset:o}=t.observer.selectionRange;i&&(e.push(new Ns(i,n)),s==i&&o==n||e.push(new Ns(s,o)));return e}(t),i=new Ps(e,t.state);i.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=i.text,this.newSel=function(t,e){if(0==t.length)return null;let i=t[0].pos,n=2==t.length?t[1].pos:i;return i>-1&&n>-1?Lt.single(i+e,n+e):null}(e,this.bounds.from)}else{let e=t.observer.selectionRange,i=s&&s.node==e.focusNode&&s.offset==e.focusOffset||!ui(t.contentDOM,e.focusNode)?t.state.selection.main.head:t.docView.posFromDOM(e.focusNode,e.focusOffset),n=o&&o.node==e.anchorNode&&o.offset==e.anchorOffset||!ui(t.contentDOM,e.anchorNode)?t.state.selection.main.anchor:t.docView.posFromDOM(e.anchorNode,e.anchorOffset),r=t.viewport;if((fi.ios||fi.chrome)&&t.state.selection.main.empty&&i!=n&&(r.from>0||r.to<t.state.doc.length)){let e=Math.min(i,n),s=Math.max(i,n),o=r.from-e,l=r.to-s;0!=o&&1!=o&&0!=e||0!=l&&-1!=l&&s!=t.state.doc.length||(i=0,n=t.state.doc.length)}t.inputState.composing>-1&&t.state.selection.ranges.length>1?this.newSel=t.state.selection.replaceRange(Lt.range(n,i)):this.newSel=Lt.single(n,i)}}}function js(t,e){let i,{newSel:n}=e,s=t.state.selection.main,o=t.inputState.lastKeyTime>Date.now()-100?t.inputState.lastKeyCode:-1;if(e.bounds){let{from:n,to:r}=e.bounds,l=s.from,a=null;(8===o||fi.android&&e.text.length<r-n)&&(l=s.to,a="end");let h=Vs(t.state.doc.sliceString(n,r,Es),e.text,l-n,a);h&&(fi.chrome&&13==o&&h.toB==h.from+2&&e.text.slice(h.from,h.toB)==Es+Es&&h.toB--,i={from:n+h.from,to:n+h.toA,insert:rt.of(e.text.slice(h.from,h.toB).split(Es))})}else n&&(!t.hasFocus&&t.state.facet(Jn)||n.main.eq(s))&&(n=null);if(!i&&!n)return!1;if(!i&&e.typeOver&&!s.empty&&n&&n.main.empty?i={from:s.from,to:s.to,insert:t.state.doc.slice(s.from,s.to)}:(fi.mac||fi.android)&&i&&i.from==i.to&&i.from==s.head-1&&/^\. ?$/.test(i.insert.toString())&&"off"==t.contentDOM.getAttribute("autocorrect")?(n&&2==i.insert.length&&(n=Lt.single(n.main.anchor-1,n.main.head-1)),i={from:i.from,to:i.to,insert:rt.of([i.insert.toString().replace("."," ")])}):i&&i.from>=s.from&&i.to<=s.to&&(i.from!=s.from||i.to!=s.to)&&s.to-s.from-(i.to-i.from)<=4?i={from:s.from,to:s.to,insert:t.state.doc.slice(s.from,i.from).append(i.insert).append(t.state.doc.slice(i.to,s.to))}:t.state.doc.lineAt(s.from).to<s.to&&t.docView.lineHasWidget(s.to)&&t.inputState.insertingTextAt>Date.now()-50?i={from:s.from,to:s.to,insert:t.state.toText(t.inputState.insertingText)}:fi.chrome&&i&&i.from==i.to&&i.from==s.head&&"\n "==i.insert.toString()&&t.lineWrapping&&(n&&(n=Lt.single(n.main.anchor-1,n.main.head-1)),i={from:s.from,to:s.to,insert:rt.of([" "])}),i)return Hs(t,i,n,o);if(n&&!n.main.eq(s)){let e=!1,i="select";return t.inputState.lastSelectionTime>Date.now()-50&&("select"==t.inputState.lastSelectionOrigin&&(e=!0),i=t.inputState.lastSelectionOrigin,"select.pointer"==i&&(n=Ds(t.state.facet(os).map(e=>e(t)),n))),t.dispatch({selection:n,scrollIntoView:e,userEvent:i}),!0}return!1}function Hs(t,e,i,n=-1){if(fi.ios&&t.inputState.flushIOSKey(e))return!0;let s=t.state.selection.main;if(fi.android&&(e.to==s.to&&(e.from==s.from||e.from==s.from-1&&" "==t.state.sliceDoc(e.from,s.from))&&1==e.insert.length&&2==e.insert.lines&&Di(t.contentDOM,"Enter",13)||(e.from==s.from-1&&e.to==s.to&&0==e.insert.length||8==n&&e.insert.length<e.to-e.from&&e.to>s.head)&&Di(t.contentDOM,"Backspace",8)||e.from==s.from&&e.to==s.to+1&&0==e.insert.length&&Di(t.contentDOM,"Delete",46)))return!0;let o,r=e.insert.toString();t.inputState.composing>=0&&t.inputState.composing++;let l=()=>o||(o=function(t,e,i){let n,s=t.state,o=s.selection.main,r=-1;if(e.from==e.to&&e.from<o.from||e.from>o.to){let i=e.from<o.from?-1:1,n=i<0?o.from:o.to,l=Os(s.facet(os).map(e=>e(t)),n,i);e.from==l&&(r=l)}if(r>-1)n={changes:e,selection:Lt.cursor(e.from+e.insert.length,-1)};else if(e.from>=o.from&&e.to<=o.to&&e.to-e.from>=(o.to-o.from)/3&&(!i||i.main.empty&&i.main.from==e.from+e.insert.length)&&t.inputState.composing<0){let i=o.from<e.from?s.sliceDoc(o.from,e.from):"",r=o.to>e.to?s.sliceDoc(e.to,o.to):"";n=s.replaceSelection(t.state.toText(i+e.insert.sliceString(0,void 0,t.state.lineBreak)+r))}else{let r=s.changes(e),l=i&&i.main.to<=r.newLength?i.main:void 0;if(s.selection.ranges.length>1&&(t.inputState.composing>=0||t.inputState.compositionPendingChange)&&e.to<=o.to+10&&e.to>=o.to-10){let a,h=t.state.sliceDoc(e.from,e.to),c=i&&ps(t,i.main.head);if(c){let t=e.insert.length-(e.to-e.from);a={from:c.from,to:c.to-t}}else a=t.state.doc.lineAt(o.head);let f=o.to-e.to;n=s.changeByRange(i=>{if(i.from==o.from&&i.to==o.to)return{changes:r,range:l||i.map(r)};let n=i.to-f,c=n-h.length;if(t.state.sliceDoc(c,n)!=h||n>=a.from&&c<=a.to)return{range:i};let d=s.changes({from:c,to:n,insert:e.insert}),u=i.to-o.to;return{changes:d,range:l?Lt.range(Math.max(0,l.anchor+u),Math.max(0,l.head+u)):i.map(d)}})}else n={changes:r,selection:l&&s.selection.replaceRange(l)}}let l="input.type";(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,l+=".compose",t.inputState.compositionFirstChange&&(l+=".start",t.inputState.compositionFirstChange=!1));return s.update(n,{userEvent:l,scrollIntoView:!0})}(t,e,i));return t.state.facet(Vn).some(i=>i(t,e.from,e.to,r,l))||t.dispatch(l()),!0}function Vs(t,e,i,n){let s=Math.min(t.length,e.length),o=0;for(;o<s&&t.charCodeAt(o)==e.charCodeAt(o);)o++;if(o==s&&t.length==e.length)return null;let r=t.length,l=e.length;for(;r>0&&l>0&&t.charCodeAt(r-1)==e.charCodeAt(l-1);)r--,l--;if("end"==n){i-=r+Math.max(0,o-Math.min(r,l))-o}if(r<o&&t.length<e.length){o-=i<=o&&i>=r?o-i:0,l=o+(l-r),r=o}else if(l<o){o-=i<=o&&i>=l?o-i:0,r=o+(r-l),l=o}return{from:o,toA:r,toB:l}}class Fs{setSelectionOrigin(t){this.lastSelectionOrigin=t,this.lastSelectionTime=Date.now()}constructor(t){this.view=t,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.pendingIOSKey=void 0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=t.hasFocus,fi.safari&&t.contentDOM.addEventListener("input",()=>null),fi.gecko&&function(t){po.has(t)||(po.add(t),t.addEventListener("copy",()=>{}),t.addEventListener("cut",()=>{}))}(t.contentDOM.ownerDocument)}handleEvent(t){(function(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let i,n=e.target;n!=t.contentDOM;n=n.parentNode)if(!n||11==n.nodeType||(i=Ii.get(n))&&i.ignoreEvent(e))return!1;return!0})(this.view,t)&&!this.ignoreDuringComposition(t)&&("keydown"==t.type&&this.keydown(t)||(0!=this.view.updateState?Promise.resolve().then(()=>this.runHandlers(t.type,t)):this.runHandlers(t.type,t)))}runHandlers(t,e){let i=this.handlers[t];if(i){for(let t of i.observers)t(this.view,e);for(let t of i.handlers){if(e.defaultPrevented)break;if(t(this.view,e)){e.preventDefault();break}}}}ensureHandlers(t){let e=Ws(t),i=this.handlers,n=this.view.contentDOM;for(let t in e)if("scroll"!=t){let s=!e[t].handlers.length,o=i[t];o&&s!=!o.handlers.length&&(n.removeEventListener(t,this.handleEvent),o=null),o||n.addEventListener(t,this.handleEvent,{passive:s})}for(let t in i)"scroll"==t||e[t]||n.removeEventListener(t,this.handleEvent);this.handlers=e}keydown(t){if(this.lastKeyCode=t.keyCode,this.lastKeyTime=Date.now(),9==t.keyCode&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&27!=t.keyCode&&Ks.indexOf(t.keyCode)<0&&(this.tabFocusMode=-1),fi.android&&fi.chrome&&!t.synthetic&&(13==t.keyCode||8==t.keyCode))return this.view.observer.delayAndroidKey(t.key,t.keyCode),!0;let e;return!fi.ios||t.synthetic||t.altKey||t.metaKey||!((e=qs.find(e=>e.keyCode==t.keyCode))&&!t.ctrlKey||_s.indexOf(t.key)>-1&&t.ctrlKey&&!t.shiftKey)?(229!=t.keyCode&&this.view.observer.forceFlush(),!1):(this.pendingIOSKey=e||t,setTimeout(()=>this.flushIOSKey(),250),!0)}flushIOSKey(t){let e=this.pendingIOSKey;return!!e&&(!("Enter"==e.key&&t&&t.from<t.to&&/^\S+$/.test(t.insert.toString()))&&(this.pendingIOSKey=void 0,Di(this.view.contentDOM,e.key,e.keyCode,e instanceof KeyboardEvent?e:void 0)))}ignoreDuringComposition(t){return!(!/^key/.test(t.type)||t.synthetic)&&(this.composing>0||!!(fi.safari&&!fi.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100)&&(this.compositionPendingKey=!1,!0))}startMouseSelection(t){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=t}update(t){this.view.observer.update(t),this.mouseSelection&&this.mouseSelection.update(t),this.draggedContent&&t.docChanged&&(this.draggedContent=this.draggedContent.map(t.changes)),t.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function zs(t,e){return(i,n)=>{try{return e.call(t,n,i)}catch(t){Yn(i.state,t)}}}function Ws(t){let e=Object.create(null);function i(t){return e[t]||(e[t]={observers:[],handlers:[]})}for(let e of t){let t=e.spec,n=t&&t.plugin.domEventHandlers,s=t&&t.plugin.domEventObservers;if(n)for(let t in n){let s=n[t];s&&i(t).handlers.push(zs(e.value,s))}if(s)for(let t in s){let n=s[t];n&&i(t).observers.push(zs(e.value,n))}}for(let t in Gs)i(t).handlers.push(Gs[t]);for(let t in Ys)i(t).observers.push(Ys[t]);return e}const qs=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],_s="dthko",Ks=[16,17,18,20,91,92,224,225];function $s(t){return.7*Math.max(0,t)+8}class Us{constructor(t,e,i,n){this.view=t,this.startEvent=e,this.style=i,this.mustSelect=n,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=e,this.scrollParents=function(t){let e,i,n=t.ownerDocument;for(let s=t.parentNode;s&&!(s==n.body||e&&i);)if(1==s.nodeType)!i&&s.scrollHeight>s.clientHeight&&(i=s),!e&&s.scrollWidth>s.clientWidth&&(e=s),s=s.assignedSlot||s.parentNode;else{if(11!=s.nodeType)break;s=s.host}return{x:e,y:i}}(t.contentDOM),this.atoms=t.state.facet(os).map(e=>e(t));let s=t.contentDOM.ownerDocument;s.addEventListener("mousemove",this.move=this.move.bind(this)),s.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=e.shiftKey,this.multiple=t.state.facet(xe.allowMultipleSelections)&&function(t,e){let i=t.state.facet(Rn);return i.length?i[0](e):fi.mac?e.metaKey:e.ctrlKey}(t,e),this.dragging=!(!function(t,e){let{main:i}=t.state.selection;if(i.empty)return!1;let n=di(t.root);if(!n||0==n.rangeCount)return!0;let s=n.getRangeAt(0).getClientRects();for(let t=0;t<s.length;t++){let i=s[t];if(i.left<=e.clientX&&i.right>=e.clientX&&i.top<=e.clientY&&i.bottom>=e.clientY)return!0}return!1}(t,e)||1!=lo(e))&&null}start(t){!1===this.dragging&&this.select(t)}move(t){if(0==t.buttons)return this.destroy();if(this.dragging||null==this.dragging&&(e=this.startEvent,i=t,Math.max(Math.abs(e.clientX-i.clientX),Math.abs(e.clientY-i.clientY))<10))return;var e,i;this.select(this.lastEvent=t);let n=0,s=0,o=0,r=0,l=this.view.win.innerWidth,a=this.view.win.innerHeight;this.scrollParents.x&&({left:o,right:l}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:r,bottom:a}=this.scrollParents.y.getBoundingClientRect());let h=hs(this.view);t.clientX-h.left<=o+6?n=-$s(o-t.clientX):t.clientX+h.right>=l-6&&(n=$s(t.clientX-l)),t.clientY-h.top<=r+6?s=-$s(r-t.clientY):t.clientY+h.bottom>=a-6&&(s=$s(t.clientY-a)),this.setScrollSpeed(n,s)}up(t){null==this.dragging&&this.select(this.lastEvent),this.dragging||t.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let t=this.view.contentDOM.ownerDocument;t.removeEventListener("mousemove",this.move),t.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(t,e){this.scrollSpeed={x:t,y:e},t||e?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:t,y:e}=this.scrollSpeed;t&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=t,t=0),e&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=e,e=0),(t||e)&&this.view.win.scrollBy(t,e),!1===this.dragging&&this.select(this.lastEvent)}select(t){let{view:e}=this,i=Ds(this.atoms,this.style.get(t,this.extend,this.multiple));!this.mustSelect&&i.eq(e.state.selection,!1===this.dragging)||this.view.dispatch({selection:i,userEvent:"select.pointer"}),this.mustSelect=!1}update(t){t.transactions.some(t=>t.isUserEvent("input.type"))?this.destroy():this.style.update(t)&&setTimeout(()=>this.select(this.lastEvent),20)}}const Gs=Object.create(null),Ys=Object.create(null),Js=fi.ie&&fi.ie_version<15||fi.ios&&fi.webkit_version<604;function Xs(t,e,i){for(let n of t.facet(e))i=n(i,t);return i}function Qs(t,e){e=Xs(t.state,zn,e);let i,{state:n}=t,s=1,o=n.toText(e),r=o.lines==n.selection.ranges.length;if(null!=ho&&n.selection.ranges.every(t=>t.empty)&&ho==o.toString()){let t=-1;i=n.changeByRange(i=>{let l=n.doc.lineAt(i.from);if(l.from==t)return{range:i};t=l.from;let a=n.toText((r?o.line(s++).text:e)+n.lineBreak);return{changes:{from:l.from,insert:a},range:Lt.cursor(i.from+a.length)}})}else i=r?n.changeByRange(t=>{let e=o.line(s++);return{changes:{from:t.from,to:t.to,insert:e.text},range:Lt.cursor(t.from+e.length)}}):n.replaceSelection(o);t.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}function Zs(t,e,i,n){if(1==n)return Lt.cursor(e,i);if(2==n)return function(t,e,i=1){let n=t.charCategorizer(e),s=t.doc.lineAt(e),o=e-s.from;if(0==s.length)return Lt.cursor(e);0==o?i=1:o==s.length&&(i=-1);let r=o,l=o;i<0?r=gt(s.text,o,!1):l=gt(s.text,o);let a=n(s.text.slice(r,l));for(;r>0;){let t=gt(s.text,r,!1);if(n(s.text.slice(t,r))!=a)break;r=t}for(;l<s.length;){let t=gt(s.text,l);if(n(s.text.slice(l,t))!=a)break;l=t}return Lt.range(r+s.from,l+s.from)}(t.state,e,i);{let i=hn.find(t.docView,e),n=t.state.doc.lineAt(i?i.posAtEnd:e),s=i?i.posAtStart:n.from,o=i?i.posAtEnd:n.to;return o<t.state.doc.length&&o==n.to&&o++,Lt.range(s,o)}}Ys.scroll=t=>{t.inputState.lastScrollTop=t.scrollDOM.scrollTop,t.inputState.lastScrollLeft=t.scrollDOM.scrollLeft},Gs.keydown=(t,e)=>(t.inputState.setSelectionOrigin("select"),27==e.keyCode&&0!=t.inputState.tabFocusMode&&(t.inputState.tabFocusMode=Date.now()+2e3),!1),Ys.touchstart=(t,e)=>{t.inputState.lastTouchTime=Date.now(),t.inputState.setSelectionOrigin("select.pointer")},Ys.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")},Gs.mousedown=(t,e)=>{if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return!1;let i=null;for(let n of t.state.facet(In))if(i=n(t,e),i)break;if(i||0!=e.button||(i=function(t,e){let i=io(t,e),n=lo(e),s=t.state.selection;return{update(t){t.docChanged&&(i.pos=t.changes.mapPos(i.pos),s=s.map(t.changes))},get(e,o,r){let l,a=io(t,e),h=Zs(t,a.pos,a.bias,n);if(i.pos!=a.pos&&!o){let e=Zs(t,i.pos,i.bias,n),s=Math.min(e.from,h.from),o=Math.max(e.to,h.to);h=s<h.from?Lt.range(s,o):Lt.range(o,s)}return o?s.replaceRange(s.main.extend(h.from,h.to)):r&&1==n&&s.ranges.length>1&&(l=function(t,e){for(let i=0;i<t.ranges.length;i++){let{from:n,to:s}=t.ranges[i];if(n<=e&&s>=e)return Lt.create(t.ranges.slice(0,i).concat(t.ranges.slice(i+1)),t.mainIndex==i?0:t.mainIndex-(t.mainIndex>i?1:0))}return null}(s,a.pos))?l:r?s.addRange(h):Lt.create([h])}}}(t,e)),i){let n=!t.hasFocus;t.inputState.startMouseSelection(new Us(t,e,i,n)),n&&t.observer.ignore(()=>{Ti(t.contentDOM);let e=t.root.activeElement;e&&!e.contains(t.contentDOM)&&e.blur()});let s=t.inputState.mouseSelection;if(s)return s.start(e),!1===s.dragging}else t.inputState.setSelectionOrigin("select.pointer");return!1};let to=(t,e,i)=>e>=i.top&&e<=i.bottom&&t>=i.left&&t<=i.right;function eo(t,e,i,n){let s=hn.find(t.docView,e);if(!s)return 1;let o=e-s.posAtStart;if(0==o)return 1;if(o==s.length)return-1;let r=s.coordsAt(o,-1);if(r&&to(i,n,r))return-1;let l=s.coordsAt(o,1);return l&&to(i,n,l)?1:r&&r.bottom>=n?-1:1}function io(t,e){let i=t.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:i,bias:eo(t,i,e.clientX,e.clientY)}}const no=fi.ie&&fi.ie_version<=11;let so=null,oo=0,ro=0;function lo(t){if(!no)return t.detail;let e=so,i=ro;return so=t,ro=Date.now(),oo=!e||i>Date.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(oo+1)%3:1}function ao(t,e,i,n){if(!(i=Xs(t.state,zn,i)))return;let s=t.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:o}=t.inputState,r=n&&o&&function(t,e){let i=t.state.facet(Nn);return i.length?i[0](e):fi.mac?!e.altKey:!e.ctrlKey}(t,e)?{from:o.from,to:o.to}:null,l={from:s,insert:i},a=t.state.changes(r?[r,l]:l);t.focus(),t.dispatch({changes:a,selection:{anchor:a.mapPos(s,-1),head:a.mapPos(s,1)},userEvent:r?"move.drop":"input.drop"}),t.inputState.draggedContent=null}Gs.dragstart=(t,e)=>{let{selection:{main:i}}=t.state;if(e.target.draggable){let n=t.docView.nearest(e.target);if(n&&n.isWidget){let t=n.posAtStart,e=t+n.length;(t>=i.to||e<=i.from)&&(i=Lt.range(t,e))}}let{inputState:n}=t;return n.mouseSelection&&(n.mouseSelection.dragging=!0),n.draggedContent=i,e.dataTransfer&&(e.dataTransfer.setData("Text",Xs(t.state,Wn,t.state.sliceDoc(i.from,i.to))),e.dataTransfer.effectAllowed="copyMove"),!1},Gs.dragend=t=>(t.inputState.draggedContent=null,!1),Gs.drop=(t,e)=>{if(!e.dataTransfer)return!1;if(t.state.readOnly)return!0;let i=e.dataTransfer.files;if(i&&i.length){let n=Array(i.length),s=0,o=()=>{++s==i.length&&ao(t,e,n.filter(t=>null!=t).join(t.state.lineBreak),!1)};for(let t=0;t<i.length;t++){let e=new FileReader;e.onerror=o,e.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(e.result)||(n[t]=e.result),o()},e.readAsText(i[t])}return!0}{let i=e.dataTransfer.getData("Text");if(i)return ao(t,e,i,!0),!0}return!1},Gs.paste=(t,e)=>{if(t.state.readOnly)return!0;t.observer.flush();let i=Js?null:e.clipboardData;return i?(Qs(t,i.getData("text/plain")||i.getData("text/uri-list")),!0):(function(t){let e=t.dom.parentNode;if(!e)return;let i=e.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.focus(),setTimeout(()=>{t.focus(),i.remove(),Qs(t,i.value)},50)}(t),!1)};let ho=null;Gs.copy=Gs.cut=(t,e)=>{let{text:i,ranges:n,linewise:s}=function(t){let e=[],i=[],n=!1;for(let n of t.selection.ranges)n.empty||(e.push(t.sliceDoc(n.from,n.to)),i.push(n));if(!e.length){let s=-1;for(let{from:n}of t.selection.ranges){let o=t.doc.lineAt(n);o.number>s&&(e.push(o.text),i.push({from:o.from,to:Math.min(t.doc.length,o.to+1)})),s=o.number}n=!0}return{text:Xs(t,Wn,e.join(t.lineBreak)),ranges:i,linewise:n}}(t.state);if(!i&&!s)return!1;ho=s?i:null,"cut"!=e.type||t.state.readOnly||t.dispatch({changes:n,scrollIntoView:!0,userEvent:"delete.cut"});let o=Js?null:e.clipboardData;return o?(o.clearData(),o.setData("text/plain",i),!0):(function(t,e){let i=t.dom.parentNode;if(!i)return;let n=i.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.value=e,n.focus(),n.selectionEnd=e.length,n.selectionStart=0,setTimeout(()=>{n.remove(),t.focus()},50)}(t,i),!1)};const co=re.define();function fo(t,e){let i=[];for(let n of t.facet(Fn)){let s=n(t,e);s&&i.push(s)}return i.length?t.update({effects:i,annotations:co.of(!0)}):null}function uo(t){setTimeout(()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let i=fo(t.state,e);i?t.dispatch(i):t.update([])}},10)}Ys.focus=t=>{t.inputState.lastFocusTime=Date.now(),t.scrollDOM.scrollTop||!t.inputState.lastScrollTop&&!t.inputState.lastScrollLeft||(t.scrollDOM.scrollTop=t.inputState.lastScrollTop,t.scrollDOM.scrollLeft=t.inputState.lastScrollLeft),uo(t)},Ys.blur=t=>{t.observer.clearSelectionRange(),uo(t)},Ys.compositionstart=Ys.compositionupdate=t=>{t.observer.editContext||(null==t.inputState.compositionFirstChange&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0))},Ys.compositionend=t=>{t.observer.editContext||(t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionPendingKey=!0,t.inputState.compositionPendingChange=t.observer.pendingRecords().length>0,t.inputState.compositionFirstChange=null,fi.chrome&&fi.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then(()=>t.observer.flush()):setTimeout(()=>{t.inputState.composing<0&&t.docView.hasComposition&&t.update([])},50))},Ys.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()},Gs.beforeinput=(t,e)=>{var i,n;if("insertText"!=e.inputType&&"insertCompositionText"!=e.inputType||(t.inputState.insertingText=e.data,t.inputState.insertingTextAt=Date.now()),"insertReplacementText"==e.inputType&&t.observer.editContext){let n=null===(i=e.dataTransfer)||void 0===i?void 0:i.getData("text/plain"),s=e.getTargetRanges();if(n&&s.length){let e=s[0],i=t.posAtDOM(e.startContainer,e.startOffset),o=t.posAtDOM(e.endContainer,e.endOffset);return Hs(t,{from:i,to:o,insert:t.state.toText(n)},null),!0}}let s;if(fi.chrome&&fi.android&&(s=qs.find(t=>t.inputType==e.inputType))&&(t.observer.delayAndroidKey(s.key,s.keyCode),"Backspace"==s.key||"Delete"==s.key)){let e=(null===(n=window.visualViewport)||void 0===n?void 0:n.height)||0;setTimeout(()=>{var i;((null===(i=window.visualViewport)||void 0===i?void 0:i.height)||0)>e+10&&t.hasFocus&&(t.contentDOM.blur(),t.focus())},100)}return fi.ios&&"deleteContentForward"==e.inputType&&t.observer.flushSoon(),fi.safari&&"insertText"==e.inputType&&t.inputState.composing>=0&&setTimeout(()=>Ys.compositionend(t,e),20),!1};const po=new Set;const mo=["pre-wrap","normal","pre-line","break-spaces"];let go=!1;function wo(){go=!1}class vo{constructor(t){this.lineWrapping=t,this.doc=rt.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(t,e){let i=this.doc.lineAt(e).number-this.doc.lineAt(t).number+1;return this.lineWrapping&&(i+=Math.max(0,Math.ceil((e-t-i*this.lineLength*.5)/this.lineLength))),this.lineHeight*i}heightForLine(t){if(!this.lineWrapping)return this.lineHeight;return(1+Math.max(0,Math.ceil((t-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight}setDoc(t){return this.doc=t,this}mustRefreshForWrapping(t){return mo.indexOf(t)>-1!=this.lineWrapping}mustRefreshForHeights(t){let e=!1;for(let i=0;i<t.length;i++){let n=t[i];n<0?i++:this.heightSamples[Math.floor(10*n)]||(e=!0,this.heightSamples[Math.floor(10*n)]=!0)}return e}refresh(t,e,i,n,s,o){let r=mo.indexOf(t)>-1,l=Math.round(e)!=Math.round(this.lineHeight)||this.lineWrapping!=r;if(this.lineWrapping=r,this.lineHeight=e,this.charWidth=i,this.textHeight=n,this.lineLength=s,l){this.heightSamples={};for(let t=0;t<o.length;t++){let e=o[t];e<0?t++:this.heightSamples[Math.floor(10*e)]=!0}}return l}}class bo{constructor(t,e){this.from=t,this.heights=e,this.index=0}get more(){return this.index<this.heights.length}}class yo{constructor(t,e,i,n,s){this.from=t,this.length=e,this.top=i,this.height=n,this._content=s}get type(){return"number"==typeof this._content?en.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof rn?this._content.widget:null}get widgetLineBreaks(){return"number"==typeof this._content?this._content:0}join(t){let e=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(t._content)?t._content:[t]);return new yo(this.from,this.length+t.length,this.top,this.height+t.height,e)}}var xo=function(t){return t[t.ByPos=0]="ByPos",t[t.ByHeight=1]="ByHeight",t[t.ByPosNoHeight=2]="ByPosNoHeight",t}(xo||(xo={}));const ko=.001;class So{constructor(t,e,i=2){this.length=t,this.height=e,this.flags=i}get outdated(){return(2&this.flags)>0}set outdated(t){this.flags=(t?2:0)|-3&this.flags}setHeight(t){this.height!=t&&(Math.abs(this.height-t)>ko&&(go=!0),this.height=t)}replace(t,e,i){return So.of(i)}decomposeLeft(t,e){e.push(this)}decomposeRight(t,e){e.push(this)}applyChanges(t,e,i,n){let s=this,o=i.doc;for(let r=n.length-1;r>=0;r--){let{fromA:l,toA:a,fromB:h,toB:c}=n[r],f=s.lineAt(l,xo.ByPosNoHeight,i.setDoc(e),0,0),d=f.to>=a?f:s.lineAt(a,xo.ByPosNoHeight,i,0,0);for(c+=d.to-a,a=d.to;r>0&&f.from<=n[r-1].toA;)l=n[r-1].fromA,h=n[r-1].fromB,r--,l<f.from&&(f=s.lineAt(l,xo.ByPosNoHeight,i,0,0));h+=f.from-l,l=f.from;let u=Lo.build(i.setDoc(o),t,h,c);s=Co(s,s.replace(l,a,u))}return s.updateHeight(i,0)}static empty(){return new Mo(0,0)}static of(t){if(1==t.length)return t[0];let e=0,i=t.length,n=0,s=0;for(;;)if(e==i)if(n>2*s){let s=t[e-1];s.break?t.splice(--e,1,s.left,null,s.right):t.splice(--e,1,s.left,s.right),i+=1+s.break,n-=s.size}else{if(!(s>2*n))break;{let e=t[i];e.break?t.splice(i,1,e.left,null,e.right):t.splice(i,1,e.left,e.right),i+=2+e.break,s-=e.size}}else if(n<s){let i=t[e++];i&&(n+=i.size)}else{let e=t[--i];e&&(s+=e.size)}let o=0;return null==t[e-1]?(o=1,e--):null==t[e]&&(o=1,i++),new Oo(So.of(t.slice(0,e)),o,So.of(t.slice(i)))}}function Co(t,e){return t==e?t:(t.constructor!=e.constructor&&(go=!0),e)}So.prototype.size=1;class Ao extends So{constructor(t,e,i){super(t,e),this.deco=i}blockAt(t,e,i,n){return new yo(n,this.length,i,this.height,this.deco||0)}lineAt(t,e,i,n,s){return this.blockAt(0,i,n,s)}forEachLine(t,e,i,n,s,o){t<=s+this.length&&e>=s&&o(this.blockAt(0,i,n,s))}updateHeight(t,e=0,i=!1,n){return n&&n.from<=e&&n.more&&this.setHeight(n.heights[n.index++]),this.outdated=!1,this}toString(){return`block(${this.length})`}}class Mo extends Ao{constructor(t,e){super(t,e,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(t,e,i,n){return new yo(n,this.length,i,this.height,this.breaks)}replace(t,e,i){let n=i[0];return 1==i.length&&(n instanceof Mo||n instanceof To&&4&n.flags)&&Math.abs(this.length-n.length)<10?(n instanceof To?n=new Mo(n.length,this.height):n.height=this.height,this.outdated||(n.outdated=!1),n):So.of(i)}updateHeight(t,e=0,i=!1,n){return n&&n.from<=e&&n.more?this.setHeight(n.heights[n.index++]):(i||this.outdated)&&this.setHeight(Math.max(this.widgetHeight,t.heightForLine(this.length-this.collapsed))+this.breaks*t.lineHeight),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class To extends So{constructor(t){super(t,0)}heightMetrics(t,e){let i,n=t.doc.lineAt(e).number,s=t.doc.lineAt(e+this.length).number,o=s-n+1,r=0;if(t.lineWrapping){let e=Math.min(this.height,t.lineHeight*o);i=e/o,this.length>o+1&&(r=(this.height-e)/(this.length-o-1))}else i=this.height/o;return{firstLine:n,lastLine:s,perLine:i,perChar:r}}blockAt(t,e,i,n){let{firstLine:s,lastLine:o,perLine:r,perChar:l}=this.heightMetrics(e,n);if(e.lineWrapping){let s=n+(t<e.lineHeight?0:Math.round(Math.max(0,Math.min(1,(t-i)/this.height))*this.length)),o=e.doc.lineAt(s),a=r+o.length*l,h=Math.max(i,t-a/2);return new yo(o.from,o.length,h,a,0)}{let n=Math.max(0,Math.min(o-s,Math.floor((t-i)/r))),{from:l,length:a}=e.doc.line(s+n);return new yo(l,a,i+r*n,r,0)}}lineAt(t,e,i,n,s){if(e==xo.ByHeight)return this.blockAt(t,i,n,s);if(e==xo.ByPosNoHeight){let{from:e,to:n}=i.doc.lineAt(t);return new yo(e,n-e,0,0,0)}let{firstLine:o,perLine:r,perChar:l}=this.heightMetrics(i,s),a=i.doc.lineAt(t),h=r+a.length*l,c=a.number-o,f=n+r*c+l*(a.from-s-c);return new yo(a.from,a.length,Math.max(n,Math.min(f,n+this.height-h)),h,0)}forEachLine(t,e,i,n,s,o){t=Math.max(t,s),e=Math.min(e,s+this.length);let{firstLine:r,perLine:l,perChar:a}=this.heightMetrics(i,s);for(let h=t,c=n;h<=e;){let e=i.doc.lineAt(h);if(h==t){let i=e.number-r;c+=l*i+a*(t-s-i)}let n=l+a*e.length;o(new yo(e.from,e.length,c,n,0)),c+=n,h=e.to+1}}replace(t,e,i){let n=this.length-e;if(n>0){let t=i[i.length-1];t instanceof To?i[i.length-1]=new To(t.length+n):i.push(null,new To(n-1))}if(t>0){let e=i[0];e instanceof To?i[0]=new To(t+e.length):i.unshift(new To(t-1),null)}return So.of(i)}decomposeLeft(t,e){e.push(new To(t-1),null)}decomposeRight(t,e){e.push(null,new To(this.length-t-1))}updateHeight(t,e=0,i=!1,n){let s=e+this.length;if(n&&n.from<=e+this.length&&n.more){let i=[],o=Math.max(e,n.from),r=-1;for(n.from>e&&i.push(new To(n.from-e-1).updateHeight(t,e));o<=s&&n.more;){let e=t.doc.lineAt(o).length;i.length&&i.push(null);let s=n.heights[n.index++];-1==r?r=s:Math.abs(s-r)>=ko&&(r=-2);let l=new Mo(e,s);l.outdated=!1,i.push(l),o+=e+1}o<=s&&i.push(null,new To(s-o).updateHeight(t,o));let l=So.of(i);return(r<0||Math.abs(l.height-this.height)>=ko||Math.abs(r-this.heightMetrics(t,e).perLine)>=ko)&&(go=!0),Co(this,l)}return(i||this.outdated)&&(this.setHeight(t.heightForGap(e,e+this.length)),this.outdated=!1),this}toString(){return`gap(${this.length})`}}class Oo extends So{constructor(t,e,i){super(t.length+e+i.length,t.height+i.height,e|(t.outdated||i.outdated?2:0)),this.left=t,this.right=i,this.size=t.size+i.size}get break(){return 1&this.flags}blockAt(t,e,i,n){let s=i+this.left.height;return t<s?this.left.blockAt(t,e,i,n):this.right.blockAt(t,e,s,n+this.left.length+this.break)}lineAt(t,e,i,n,s){let o=n+this.left.height,r=s+this.left.length+this.break,l=e==xo.ByHeight?t<o:t<r,a=l?this.left.lineAt(t,e,i,n,s):this.right.lineAt(t,e,i,o,r);if(this.break||(l?a.to<r:a.from>r))return a;let h=e==xo.ByPosNoHeight?xo.ByPosNoHeight:xo.ByPos;return l?a.join(this.right.lineAt(r,h,i,o,r)):this.left.lineAt(r,h,i,n,s).join(a)}forEachLine(t,e,i,n,s,o){let r=n+this.left.height,l=s+this.left.length+this.break;if(this.break)t<l&&this.left.forEachLine(t,e,i,n,s,o),e>=l&&this.right.forEachLine(t,e,i,r,l,o);else{let a=this.lineAt(l,xo.ByPos,i,n,s);t<a.from&&this.left.forEachLine(t,a.from-1,i,n,s,o),a.to>=t&&a.from<=e&&o(a),e>a.to&&this.right.forEachLine(a.to+1,e,i,r,l,o)}}replace(t,e,i){let n=this.left.length+this.break;if(e<n)return this.balanced(this.left.replace(t,e,i),this.right);if(t>this.left.length)return this.balanced(this.left,this.right.replace(t-n,e-n,i));let s=[];t>0&&this.decomposeLeft(t,s);let o=s.length;for(let t of i)s.push(t);if(t>0&&Do(s,o-1),e<this.length){let t=s.length;this.decomposeRight(e,s),Do(s,t)}return So.of(s)}decomposeLeft(t,e){let i=this.left.length;if(t<=i)return this.left.decomposeLeft(t,e);e.push(this.left),this.break&&(i++,t>=i&&e.push(null)),t>i&&this.right.decomposeLeft(t-i,e)}decomposeRight(t,e){let i=this.left.length,n=i+this.break;if(t>=n)return this.right.decomposeRight(t-n,e);t<i&&this.left.decomposeRight(t,e),this.break&&t<n&&e.push(null),e.push(this.right)}balanced(t,e){return t.size>2*e.size||e.size>2*t.size?So.of(this.break?[t,null,e]:[t,e]):(this.left=Co(this.left,t),this.right=Co(this.right,e),this.setHeight(t.height+e.height),this.outdated=t.outdated||e.outdated,this.size=t.size+e.size,this.length=t.length+this.break+e.length,this)}updateHeight(t,e=0,i=!1,n){let{left:s,right:o}=this,r=e+s.length+this.break,l=null;return n&&n.from<=e+s.length&&n.more?l=s=s.updateHeight(t,e,i,n):s.updateHeight(t,e,i),n&&n.from<=r+o.length&&n.more?l=o=o.updateHeight(t,r,i,n):o.updateHeight(t,r,i),l?this.balanced(s,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function Do(t,e){let i,n;null==t[e]&&(i=t[e-1])instanceof To&&(n=t[e+1])instanceof To&&t.splice(e-1,3,new To(i.length+1+n.length))}class Lo{constructor(t,e){this.pos=t,this.oracle=e,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=t}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(t,e){if(this.lineStart>-1){let t=Math.min(e,this.lineEnd),i=this.nodes[this.nodes.length-1];i instanceof Mo?i.length+=t-this.pos:(t>this.pos||!this.isCovered)&&this.nodes.push(new Mo(t-this.pos,-1)),this.writtenTo=t,e>t&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=e}point(t,e,i){if(t<e||i.heightRelevant){let n=i.widget?i.widget.estimatedHeight:0,s=i.widget?i.widget.lineBreaks:0;n<0&&(n=this.oracle.lineHeight);let o=e-t;i.block?this.addBlock(new Ao(o,n,i)):(o||s||n>=5)&&this.addLineDeco(n,s,o)}else e>t&&this.span(t,e);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:t,to:e}=this.oracle.doc.lineAt(this.pos);this.lineStart=t,this.lineEnd=e,this.writtenTo<t&&((this.writtenTo<t-1||null==this.nodes[this.nodes.length-1])&&this.nodes.push(this.blankContent(this.writtenTo,t-1)),this.nodes.push(null)),this.pos>t&&this.nodes.push(new Mo(this.pos-t,-1)),this.writtenTo=this.pos}blankContent(t,e){let i=new To(e-t);return this.oracle.doc.lineAt(t).to==e&&(i.flags|=4),i}ensureLine(){this.enterLine();let t=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(t instanceof Mo)return t;let e=new Mo(0,-1);return this.nodes.push(e),e}addBlock(t){this.enterLine();let e=t.deco;e&&e.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(t),this.writtenTo=this.pos=this.pos+t.length,e&&e.endSide>0&&(this.covering=t)}addLineDeco(t,e,i){let n=this.ensureLine();n.length+=i,n.collapsed+=i,n.widgetHeight=Math.max(n.widgetHeight,t),n.breaks+=e,this.writtenTo=this.pos=this.pos+i}finish(t){let e=0==this.nodes.length?null:this.nodes[this.nodes.length-1];!(this.lineStart>-1)||e instanceof Mo||this.isCovered?(this.writtenTo<this.pos||null==e)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos)):this.nodes.push(new Mo(0,-1));let i=t;for(let t of this.nodes)t instanceof Mo&&t.updateHeight(this.oracle,i),i+=t?t.length:1;return this.nodes}static build(t,e,i,n){let s=new Lo(i,t);return Te.spans(e,i,n,s,0),s.finish(i)}}class Eo{constructor(){this.changes=[]}compareRange(){}comparePoint(t,e,i,n){(t<e||i&&i.heightRelevant||n&&n.heightRelevant)&&an(t,e,this.changes,5)}}function Po(t,e){let i=t.getBoundingClientRect(),n=t.ownerDocument,s=n.defaultView||window,o=Math.max(0,i.left),r=Math.min(s.innerWidth,i.right),l=Math.max(0,i.top),a=Math.min(s.innerHeight,i.bottom);for(let e=t.parentNode;e&&e!=n.body;)if(1==e.nodeType){let i=e,n=window.getComputedStyle(i);if((i.scrollHeight>i.clientHeight||i.scrollWidth>i.clientWidth)&&"visible"!=n.overflow){let n=i.getBoundingClientRect();o=Math.max(o,n.left),r=Math.min(r,n.right),l=Math.max(l,n.top),a=Math.min(e==t.parentNode?s.innerHeight:a,n.bottom)}e="absolute"==n.position||"fixed"==n.position?i.offsetParent:i.parentNode}else{if(11!=e.nodeType)break;e=e.host}return{left:o-i.left,right:Math.max(o,r)-i.left,top:l-(i.top+e),bottom:Math.max(l,a)-(i.top+e)}}function Bo(t,e){let i=t.getBoundingClientRect();return{left:0,right:i.right-i.left,top:e,bottom:i.bottom-(i.top+e)}}class Ro{constructor(t,e,i,n){this.from=t,this.to=e,this.size=i,this.displaySize=n}static same(t,e){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++){let n=t[i],s=e[i];if(n.from!=s.from||n.to!=s.to||n.size!=s.size)return!1}return!0}draw(t,e){return nn.replace({widget:new No(this.displaySize*(e?t.scaleY:t.scaleX),e)}).range(this.from,this.to)}}class No extends tn{constructor(t,e){super(),this.size=t,this.vertical=e}eq(t){return t.size==this.size&&t.vertical==this.vertical}toDOM(){let t=document.createElement("div");return this.vertical?t.style.height=this.size+"px":(t.style.width=this.size+"px",t.style.height="2px",t.style.display="inline-block"),t}get estimatedHeight(){return this.vertical?this.size:-1}}class Io{constructor(t){this.state=t,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scrollTop=0,this.scrolledToBottom=!1,this.scaleX=1,this.scaleY=1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=Fo,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=mn.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let e=t.facet(is).some(t=>"function"!=typeof t&&"cm-lineWrapping"==t.class);this.heightOracle=new vo(e),this.stateDeco=t.facet(ns).filter(t=>"function"!=typeof t),this.heightMap=So.empty().applyChanges(this.stateDeco,rt.empty,this.heightOracle.setDoc(t.doc),[new fs(0,0,0,t.doc.length)]);for(let t=0;t<2&&(this.viewport=this.getViewport(0,null),this.updateForViewport());t++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=nn.set(this.lineGaps.map(t=>t.draw(this,!1))),this.computeVisibleRanges()}updateForViewport(){let t=[this.viewport],{main:e}=this.state.selection;for(let i=0;i<=1;i++){let n=i?e.head:e.anchor;if(!t.some(({from:t,to:e})=>n>=t&&n<=e)){let{from:e,to:i}=this.lineBlockAt(n);t.push(new jo(e,i))}}return this.viewports=t.sort((t,e)=>t.from-e.from),this.updateScaler()}updateScaler(){let t=this.scaler;return this.scaler=this.heightMap.height<=7e6?Fo:new zo(this.heightOracle,this.heightMap,this.viewports),t.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,t=>{this.viewportLines.push(Wo(t,this.scaler))})}update(t,e=null){this.state=t.state;let i=this.stateDeco;this.stateDeco=this.state.facet(ns).filter(t=>"function"!=typeof t);let n=t.changedRanges,s=fs.extendWithRanges(n,function(t,e,i){let n=new Eo;return Te.compare(t,e,i,n,0),n.changes}(i,this.stateDeco,t?t.changes:kt.empty(this.state.doc.length))),o=this.heightMap.height,r=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);wo(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,t.startState.doc,this.heightOracle.setDoc(this.state.doc),s),(this.heightMap.height!=o||go)&&(t.flags|=2),r?(this.scrollAnchorPos=t.changes.mapPos(r.from,-1),this.scrollAnchorHeight=r.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=o);let l=s.length?this.mapViewport(this.viewport,t.changes):this.viewport;(e&&(e.range.head<l.from||e.range.head>l.to)||!this.viewportIsAppropriate(l))&&(l=this.getViewport(0,e));let a=l.from!=this.viewport.from||l.to!=this.viewport.to;this.viewport=l,t.flags|=this.updateForViewport(),(a||!t.changes.empty||2&t.flags)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,t.changes))),t.flags|=this.computeVisibleRanges(t.changes),e&&(this.scrollTarget=e),!this.mustEnforceCursorAssoc&&t.selectionSet&&t.view.lineWrapping&&t.state.selection.main.empty&&t.state.selection.main.assoc&&!t.state.facet(_n)&&(this.mustEnforceCursorAssoc=!0)}measure(t){let e=t.contentDOM,i=window.getComputedStyle(e),n=this.heightOracle,s=i.whiteSpace;this.defaultTextDirection="rtl"==i.direction?mn.RTL:mn.LTR;let o=this.heightOracle.mustRefreshForWrapping(s),r=e.getBoundingClientRect(),l=o||this.mustMeasureContent||this.contentDOMHeight!=r.height;this.contentDOMHeight=r.height,this.mustMeasureContent=!1;let a=0,h=0;if(r.width&&r.height){let{scaleX:t,scaleY:i}=Si(e,r);(t>.005&&Math.abs(this.scaleX-t)>.005||i>.005&&Math.abs(this.scaleY-i)>.005)&&(this.scaleX=t,this.scaleY=i,a|=16,o=l=!0)}let c=(parseInt(i.paddingTop)||0)*this.scaleY,f=(parseInt(i.paddingBottom)||0)*this.scaleY;this.paddingTop==c&&this.paddingBottom==f||(this.paddingTop=c,this.paddingBottom=f,a|=18),this.editorWidth!=t.scrollDOM.clientWidth&&(n.lineWrapping&&(l=!0),this.editorWidth=t.scrollDOM.clientWidth,a|=16);let d=t.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=d&&(this.scrollAnchorHeight=-1,this.scrollTop=d),this.scrolledToBottom=Ei(t.scrollDOM);let u=(this.printing?Bo:Po)(e,this.paddingTop),p=u.top-this.pixelViewport.top,m=u.bottom-this.pixelViewport.bottom;this.pixelViewport=u;let g=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(g!=this.inView&&(this.inView=g,g&&(l=!0)),!this.inView&&!this.scrollTarget&&!function(t){let e=t.getBoundingClientRect(),i=t.ownerDocument.defaultView||window;return e.left<i.innerWidth&&e.right>0&&e.top<i.innerHeight&&e.bottom>0}(t.dom))return 0;let w=r.width;if(this.contentDOMWidth==w&&this.editorHeight==t.scrollDOM.clientHeight||(this.contentDOMWidth=r.width,this.editorHeight=t.scrollDOM.clientHeight,a|=16),l){let e=t.docView.measureVisibleLineHeights(this.viewport);if(n.mustRefreshForHeights(e)&&(o=!0),o||n.lineWrapping&&Math.abs(w-this.contentDOMWidth)>n.charWidth){let{lineHeight:i,charWidth:r,textHeight:l}=t.docView.measureTextSize();o=i>0&&n.refresh(s,i,r,l,Math.max(5,w/r),e),o&&(t.docView.minWidth=0,a|=16)}p>0&&m>0?h=Math.max(p,m):p<0&&m<0&&(h=Math.min(p,m)),wo();for(let i of this.viewports){let s=i.from==this.viewport.from?e:t.docView.measureVisibleLineHeights(i);this.heightMap=(o?So.empty().applyChanges(this.stateDeco,rt.empty,this.heightOracle,[new fs(0,0,0,t.state.doc.length)]):this.heightMap).updateHeight(n,0,o,new bo(i.from,s))}go&&(a|=2)}let v=!this.viewportIsAppropriate(this.viewport,h)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return v&&(2&a&&(a|=this.updateScaler()),this.viewport=this.getViewport(h,this.scrollTarget),a|=this.updateForViewport()),(2&a||v)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,t)),a|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,t.docView.enforceCursorAssoc()),a}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(t,e){let i=.5-Math.max(-.5,Math.min(.5,t/1e3/2)),n=this.heightMap,s=this.heightOracle,{visibleTop:o,visibleBottom:r}=this,l=new jo(n.lineAt(o-1e3*i,xo.ByHeight,s,0,0).from,n.lineAt(r+1e3*(1-i),xo.ByHeight,s,0,0).to);if(e){let{head:t}=e.range;if(t<l.from||t>l.to){let i,o=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),r=n.lineAt(t,xo.ByPos,s,0,0);i="center"==e.y?(r.top+r.bottom)/2-o/2:"start"==e.y||"nearest"==e.y&&t<l.from?r.top:r.bottom-o,l=new jo(n.lineAt(i-500,xo.ByHeight,s,0,0).from,n.lineAt(i+o+500,xo.ByHeight,s,0,0).to)}}return l}mapViewport(t,e){let i=e.mapPos(t.from,-1),n=e.mapPos(t.to,1);return new jo(this.heightMap.lineAt(i,xo.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(n,xo.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:t,to:e},i=0){if(!this.inView)return!0;let{top:n}=this.heightMap.lineAt(t,xo.ByPos,this.heightOracle,0,0),{bottom:s}=this.heightMap.lineAt(e,xo.ByPos,this.heightOracle,0,0),{visibleTop:o,visibleBottom:r}=this;return(0==t||n<=o-Math.max(10,Math.min(-i,250)))&&(e==this.state.doc.length||s>=r+Math.max(10,Math.min(i,250)))&&n>o-2e3&&s<r+2e3}mapLineGaps(t,e){if(!t.length||e.empty)return t;let i=[];for(let n of t)e.touchesRange(n.from,n.to)||i.push(new Ro(e.mapPos(n.from),e.mapPos(n.to),n.size,n.displaySize));return i}ensureLineGaps(t,e){let i=this.heightOracle.lineWrapping,n=i?1e4:2e3,s=n>>1,o=n<<1;if(this.defaultTextDirection!=mn.LTR&&!i)return[];let r=[],l=(n,o,a,h)=>{if(o-n<s)return;let c=this.state.selection.main,f=[c.from];c.empty||f.push(c.to);for(let t of f)if(t>n&&t<o)return l(n,t-10,a,h),void l(t+10,o,a,h);let d=function(t,e){for(let i of t)if(e(i))return i;return}(t,t=>t.from>=a.from&&t.to<=a.to&&Math.abs(t.from-n)<s&&Math.abs(t.to-o)<s&&!f.some(e=>t.from<e&&t.to>e));if(!d){if(o<a.to&&e&&i&&e.visibleRanges.some(t=>t.from<=o&&t.to>=o)){let t=e.moveToLineBoundary(Lt.cursor(o),!1,!0).head;t>n&&(o=t)}let t=this.gapSize(a,n,o,h);d=new Ro(n,o,t,i||t<2e6?t:2e6)}r.push(d)},a=e=>{if(e.length<o||e.type!=en.Text)return;let s=function(t,e,i){let n=[],s=t,o=0;Te.spans(i,t,e,{span(){},point(t,e){t>s&&(n.push({from:s,to:t}),o+=t-s),s=e}},20),s<e&&(n.push({from:s,to:e}),o+=e-s);return{total:o,ranges:n}}(e.from,e.to,this.stateDeco);if(s.total<o)return;let r,a,h=this.scrollTarget?this.scrollTarget.range.head:null;if(i){let t,i,o=n/this.heightOracle.lineLength*this.heightOracle.lineHeight;if(null!=h){let n=Vo(s,h),r=((this.visibleBottom-this.visibleTop)/2+o)/e.height;t=n-r,i=n+r}else t=(this.visibleTop-e.top-o)/e.height,i=(this.visibleBottom-e.top+o)/e.height;r=Ho(s,t),a=Ho(s,i)}else{let i=s.total*this.heightOracle.charWidth,o=n*this.heightOracle.charWidth,l=0;if(i>2e6)for(let i of t)i.from>=e.from&&i.from<e.to&&i.size!=i.displaySize&&i.from*this.heightOracle.charWidth+l<this.pixelViewport.left&&(l=i.size-i.displaySize);let c,f,d=this.pixelViewport.left+l,u=this.pixelViewport.right+l;if(null!=h){let t=Vo(s,h),e=((u-d)/2+o)/i;c=t-e,f=t+e}else c=(d-o)/i,f=(u+o)/i;r=Ho(s,c),a=Ho(s,f)}r>e.from&&l(e.from,r,e,s),a<e.to&&l(a,e.to,e,s)};for(let t of this.viewportLines)Array.isArray(t.type)?t.type.forEach(a):a(t);return r}gapSize(t,e,i,n){let s=Vo(n,i)-Vo(n,e);return this.heightOracle.lineWrapping?t.height*s:n.total*this.heightOracle.charWidth*s}updateLineGaps(t){Ro.same(t,this.lineGaps)||(this.lineGaps=t,this.lineGapDeco=nn.set(t.map(t=>t.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(t){let e=this.stateDeco;this.lineGaps.length&&(e=e.concat(this.lineGapDeco));let i=[];Te.spans(e,this.viewport.from,this.viewport.to,{span(t,e){i.push({from:t,to:e})},point(){}},20);let n=0;if(i.length!=this.visibleRanges.length)n=12;else for(let e=0;e<i.length&&!(8&n);e++){let s=this.visibleRanges[e],o=i[e];s.from==o.from&&s.to==o.to||(n|=4,t&&t.mapPos(s.from,-1)==o.from&&t.mapPos(s.to,1)==o.to||(n|=8))}return this.visibleRanges=i,n}lineBlockAt(t){return t>=this.viewport.from&&t<=this.viewport.to&&this.viewportLines.find(e=>e.from<=t&&e.to>=t)||Wo(this.heightMap.lineAt(t,xo.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(t){return t>=this.viewportLines[0].top&&t<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(e=>e.top<=t&&e.bottom>=t)||Wo(this.heightMap.lineAt(this.scaler.fromDOM(t),xo.ByHeight,this.heightOracle,0,0),this.scaler)}scrollAnchorAt(t){let e=this.lineBlockAtHeight(t+8);return e.from>=this.viewport.from||this.viewportLines[0].top-t>200?e:this.viewportLines[0]}elementAtHeight(t){return Wo(this.heightMap.blockAt(this.scaler.fromDOM(t),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class jo{constructor(t,e){this.from=t,this.to=e}}function Ho({total:t,ranges:e},i){if(i<=0)return e[0].from;if(i>=1)return e[e.length-1].to;let n=Math.floor(t*i);for(let t=0;;t++){let{from:i,to:s}=e[t],o=s-i;if(n<=o)return i+n;n-=o}}function Vo(t,e){let i=0;for(let{from:n,to:s}of t.ranges){if(e<=s){i+=e-n;break}i+=s-n}return i/t.total}const Fo={toDOM:t=>t,fromDOM:t=>t,scale:1,eq(t){return t==this}};class zo{constructor(t,e,i){let n=0,s=0,o=0;this.viewports=i.map(({from:i,to:s})=>{let o=e.lineAt(i,xo.ByPos,t,0,0).top,r=e.lineAt(s,xo.ByPos,t,0,0).bottom;return n+=r-o,{from:i,to:s,top:o,bottom:r,domTop:0,domBottom:0}}),this.scale=(7e6-n)/(e.height-n);for(let t of this.viewports)t.domTop=o+(t.top-s)*this.scale,o=t.domBottom=t.domTop+(t.bottom-t.top),s=t.bottom}toDOM(t){for(let e=0,i=0,n=0;;e++){let s=e<this.viewports.length?this.viewports[e]:null;if(!s||t<s.top)return n+(t-i)*this.scale;if(t<=s.bottom)return s.domTop+(t-s.top);i=s.bottom,n=s.domBottom}}fromDOM(t){for(let e=0,i=0,n=0;;e++){let s=e<this.viewports.length?this.viewports[e]:null;if(!s||t<s.domTop)return i+(t-n)/this.scale;if(t<=s.domBottom)return s.top+(t-s.domTop);i=s.bottom,n=s.domBottom}}eq(t){return t instanceof zo&&(this.scale==t.scale&&this.viewports.length==t.viewports.length&&this.viewports.every((e,i)=>e.from==t.viewports[i].from&&e.to==t.viewports[i].to))}}function Wo(t,e){if(1==e.scale)return t;let i=e.toDOM(t.top),n=e.toDOM(t.bottom);return new yo(t.from,t.length,i,n-i,Array.isArray(t._content)?t._content.map(t=>Wo(t,e)):t._content)}const qo=Bt.define({combine:t=>t.join(" ")}),_o=Bt.define({combine:t=>t.indexOf(!0)>-1}),Ko=qe.newName(),$o=qe.newName(),Uo=qe.newName(),Go={"&light":"."+$o,"&dark":"."+Uo};function Yo(t,e,i){return new qe(e,{finish:e=>/&/.test(e)?e.replace(/&\w*/,e=>{if("&"==e)return t;if(!i||!i[e])throw new RangeError(`Unsupported selector: ${e}`);return i[e]}):t+" "+e})}const Jo=Yo("."+Ko,{"&":{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,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",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",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".cm-highlightTab":{backgroundImage:'url(\'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>\')',backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".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"}},Go),Xo={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Qo=fi.ie&&fi.ie_version<=11;class Zo{constructor(t){this.view=t,this.active=!1,this.editContext=null,this.selectionRange=new Ci,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=t.contentDOM,this.observer=new MutationObserver(e=>{for(let t of e)this.queue.push(t);(fi.ie&&fi.ie_version<=11||fi.ios&&t.composing)&&e.some(t=>"childList"==t.type&&t.removedNodes.length||"characterData"==t.type&&t.oldValue.length>t.target.nodeValue.length)?this.flushSoon():this.flush()}),!window.EditContext||!fi.android||!1===t.constructor.EDIT_CONTEXT||fi.chrome&&fi.chrome_version<126||(this.editContext=new ir(t),t.state.facet(Jn)&&(t.contentDOM.editContext=this.editContext.editContext)),Qo&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),"function"==typeof ResizeObserver&&(this.resizeScroll=new ResizeObserver(()=>{var t;(null===(t=this.view.docView)||void 0===t?void 0:t.lastUpdate)<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(t.scrollDOM)),this.addWindowListeners(this.win=t.win),this.start(),"function"==typeof IntersectionObserver&&(this.intersection=new IntersectionObserver(t=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),t.length>0&&t[t.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(t=>{t.length>0&&t[t.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(t){this.view.inputState.runHandlers("scroll",t),this.intersecting&&this.view.measure()}onScroll(t){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(t)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(t){("change"!=t.type&&t.type||t.matches)&&(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(t){if(this.gapIntersection&&(t.length!=this.gaps.length||this.gaps.some((e,i)=>e!=t[i]))){this.gapIntersection.disconnect();for(let e of t)this.gapIntersection.observe(e);this.gaps=t}}onSelectionChange(t){let e=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:i}=this,n=this.selectionRange;if(i.state.facet(Jn)?i.root.activeElement!=this.dom:!pi(this.dom,n))return;let s=n.anchorNode&&i.docView.nearest(n.anchorNode);s&&s.ignoreEvent(t)?e||(this.selectionChanged=!1):(fi.ie&&fi.ie_version<=11||fi.android&&fi.chrome)&&!i.state.selection.main.empty&&n.focusNode&&gi(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:t}=this,e=di(t.root);if(!e)return!1;let i=fi.safari&&11==t.root.nodeType&&t.root.activeElement==this.dom&&function(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return er(t,i)}let i=null;function n(t){t.preventDefault(),t.stopImmediatePropagation(),i=t.getTargetRanges()[0]}return t.contentDOM.addEventListener("beforeinput",n,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",n,!0),i?er(t,i):null}(this.view,e)||e;if(!i||this.selectionRange.eq(i))return!1;let n=pi(this.dom,i);return n&&!this.selectionChanged&&t.inputState.lastFocusTime>Date.now()-200&&t.inputState.lastTouchTime<Date.now()-300&&function(t,e){let i=e.focusNode,n=e.focusOffset;if(!i||e.anchorNode!=i||e.anchorOffset!=n)return!1;for(n=Math.min(n,yi(i));;)if(n){if(1!=i.nodeType)return!1;let t=i.childNodes[n-1];"false"==t.contentEditable?n--:(i=t,n=yi(i))}else{if(i==t)return!0;n=wi(i),i=i.parentNode}}(this.dom,i)?(this.view.inputState.lastFocusTime=0,t.docView.updateSelection(),!1):(this.selectionRange.setRange(i),n&&(this.selectionChanged=!0),!0)}setSelectionRange(t,e){this.selectionRange.set(t.node,t.offset,e.node,e.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let t=0,e=null;for(let i=this.dom;i;)if(1==i.nodeType)!e&&t<this.scrollTargets.length&&this.scrollTargets[t]==i?t++:e||(e=this.scrollTargets.slice(0,t)),e&&e.push(i),i=i.assignedSlot||i.parentNode;else{if(11!=i.nodeType)break;i=i.host}if(t<this.scrollTargets.length&&!e&&(e=this.scrollTargets.slice(0,t)),e){for(let t of this.scrollTargets)t.removeEventListener("scroll",this.onScroll);for(let t of this.scrollTargets=e)t.addEventListener("scroll",this.onScroll)}}ignore(t){if(!this.active)return t();try{return this.stop(),t()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,Xo),Qo&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),Qo&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(t,e){var i;if(!this.delayedAndroidKey){let t=()=>{let t=this.delayedAndroidKey;if(t){this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=t.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&t.force&&Di(this.dom,t.key,t.keyCode)}};this.flushingAndroidKey=this.view.win.requestAnimationFrame(t)}this.delayedAndroidKey&&"Enter"!=t||(this.delayedAndroidKey={key:t,keyCode:e,force:this.lastChange<Date.now()-50||!!(null===(i=this.delayedAndroidKey)||void 0===i?void 0:i.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let t of this.observer.takeRecords())this.queue.push(t);return this.queue}processRecords(){let t=this.pendingRecords();t.length&&(this.queue=[]);let e=-1,i=-1,n=!1;for(let s of t){let t=this.readMutation(s);t&&(t.typeOver&&(n=!0),-1==e?({from:e,to:i}=t):(e=Math.min(t.from,e),i=Math.max(t.to,i)))}return{from:e,to:i,typeOver:n}}readChange(){let{from:t,to:e,typeOver:i}=this.processRecords(),n=this.selectionChanged&&pi(this.dom,this.selectionRange);if(t<0&&!n)return null;t>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let s=new Is(this.view,t,e,i);return this.view.docView.domChanged={newSel:s.newSel?s.newSel.main:null},s}flush(t=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;t&&this.readSelectionRange();let e=this.readChange();if(!e)return this.view.requestMeasure(),!1;let i=this.view.state,n=js(this.view,e);return this.view.state==i&&(e.domChanged||e.newSel&&!e.newSel.main.eq(this.view.state.selection.main))&&this.view.update([]),n}readMutation(t){let e=this.view.docView.nearest(t.target);if(!e||e.ignoreMutation(t))return null;if(e.markDirty("attributes"==t.type),"attributes"==t.type&&(e.flags|=4),"childList"==t.type){let i=tr(e,t.previousSibling||t.target.previousSibling,-1),n=tr(e,t.nextSibling||t.target.nextSibling,1);return{from:i?e.posAfter(i):e.posAtStart,to:n?e.posBefore(n):e.posAtEnd,typeOver:!1}}return"characterData"==t.type?{from:e.posAtStart,to:e.posAtEnd,typeOver:t.target.nodeValue==t.oldValue}:null}setWindow(t){t!=this.win&&(this.removeWindowListeners(this.win),this.win=t,this.addWindowListeners(this.win))}addWindowListeners(t){t.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):t.addEventListener("beforeprint",this.onPrint),t.addEventListener("scroll",this.onScroll),t.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(t){t.removeEventListener("scroll",this.onScroll),t.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):t.removeEventListener("beforeprint",this.onPrint),t.document.removeEventListener("selectionchange",this.onSelectionChange)}update(t){this.editContext&&(this.editContext.update(t),t.startState.facet(Jn)!=t.state.facet(Jn)&&(t.view.contentDOM.editContext=t.state.facet(Jn)?this.editContext.editContext:null))}destroy(){var t,e,i;this.stop(),null===(t=this.intersection)||void 0===t||t.disconnect(),null===(e=this.gapIntersection)||void 0===e||e.disconnect(),null===(i=this.resizeScroll)||void 0===i||i.disconnect();for(let t of this.scrollTargets)t.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function tr(t,e,i){for(;e;){let n=Ii.get(e);if(n&&n.parent==t)return n;let s=e.parentNode;e=s!=t.dom?s:i>0?e.nextSibling:e.previousSibling}return null}function er(t,e){let i=e.startContainer,n=e.startOffset,s=e.endContainer,o=e.endOffset,r=t.docView.domAtPos(t.state.selection.main.anchor);return gi(r.node,r.offset,s,o)&&([i,n,s,o]=[s,o,i,n]),{anchorNode:i,anchorOffset:n,focusNode:s,focusOffset:o}}class ir{constructor(t){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(t.state);let e=this.editContext=new window.EditContext({text:t.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,t.state.selection.main.anchor))),selectionEnd:this.toContextPos(t.state.selection.main.head)});this.handlers.textupdate=i=>{let n=t.state.selection.main,{anchor:s,head:o}=n,r=this.toEditorPos(i.updateRangeStart),l=this.toEditorPos(i.updateRangeEnd);t.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:i.updateRangeStart,editorBase:r,drifted:!1});let a=l-r>i.text.length;r==this.from&&s<this.from?r=s:l==this.to&&s>this.to&&(l=s);let h=Vs(t.state.sliceDoc(r,l),i.text,(a?n.from:n.to)-r,a?"end":null);if(!h){let e=Lt.single(this.toEditorPos(i.selectionStart),this.toEditorPos(i.selectionEnd));return void(e.main.eq(n)||t.dispatch({selection:e,userEvent:"select"}))}let c={from:h.from+r,to:h.toA+r,insert:rt.of(i.text.slice(h.from,h.toB).split("\n"))};if((fi.mac||fi.android)&&c.from==o-1&&/^\. ?$/.test(i.text)&&"off"==t.contentDOM.getAttribute("autocorrect")&&(c={from:r,to:l,insert:rt.of([i.text.replace("."," ")])}),this.pendingContextChange=c,!t.state.readOnly){let e=this.to-this.from+(c.to-c.from+c.insert.length);Hs(t,c,Lt.single(this.toEditorPos(i.selectionStart,e),this.toEditorPos(i.selectionEnd,e)))}this.pendingContextChange&&(this.revertPending(t.state),this.setSelection(t.state)),c.from<c.to&&!c.insert.length&&t.inputState.composing>=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(e.text.slice(Math.max(0,i.updateRangeStart-1),Math.min(e.text.length,i.updateRangeStart+1)))&&this.handlers.compositionend(i)},this.handlers.characterboundsupdate=i=>{let n=[],s=null;for(let e=this.toEditorPos(i.rangeStart),o=this.toEditorPos(i.rangeEnd);e<o;e++){let i=t.coordsForChar(e);s=i&&new DOMRect(i.left,i.top,i.right-i.left,i.bottom-i.top)||s||new DOMRect,n.push(s)}e.updateCharacterBounds(i.rangeStart,n)},this.handlers.textformatupdate=e=>{let i=[];for(let t of e.getTextFormats()){let e=t.underlineStyle,n=t.underlineThickness;if(!/none/i.test(e)&&!/none/i.test(n)){let s=this.toEditorPos(t.rangeStart),o=this.toEditorPos(t.rangeEnd);if(s<o){let t=`text-decoration: underline ${/^[a-z]/.test(e)?e+" ":"Dashed"==e?"dashed ":"Squiggle"==e?"wavy ":""}${/thin/i.test(n)?1:2}px`;i.push(nn.mark({attributes:{style:t}}).range(s,o))}}}t.dispatch({effects:Gn.of(nn.set(i))})},this.handlers.compositionstart=()=>{t.inputState.composing<0&&(t.inputState.composing=0,t.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(t.inputState.composing=-1,t.inputState.compositionFirstChange=null,this.composing){let{drifted:e}=this.composing;this.composing=null,e&&this.reset(t.state)}};for(let t in this.handlers)e.addEventListener(t,this.handlers[t]);this.measureReq={read:t=>{this.editContext.updateControlBounds(t.contentDOM.getBoundingClientRect());let e=di(t.root);e&&e.rangeCount&&this.editContext.updateSelectionBounds(e.getRangeAt(0).getBoundingClientRect())}}}applyEdits(t){let e=0,i=!1,n=this.pendingContextChange;return t.changes.iterChanges((s,o,r,l,a)=>{if(i)return;let h=a.length-(o-s);if(n&&o>=n.to){if(n.from==s&&n.to==o&&n.insert.eq(a))return n=this.pendingContextChange=null,e+=h,void(this.to+=h);n=null,this.revertPending(t.state)}if(s+=e,(o+=e)<=this.from)this.from+=h,this.to+=h;else if(s<this.to){if(s<this.from||o>this.to||this.to-this.from+a.length>3e4)return void(i=!0);this.editContext.updateText(this.toContextPos(s),this.toContextPos(o),a.toString()),this.to+=h}e+=h}),n&&!i&&this.revertPending(t.state),!i}update(t){let e=this.pendingContextChange,i=t.startState.selection.main;this.composing&&(this.composing.drifted||!t.changes.touchesRange(i.from,i.to)&&t.transactions.some(t=>!t.isUserEvent("input.type")&&t.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=t.changes.mapPos(this.composing.editorBase)):this.applyEdits(t)&&this.rangeIsValid(t.state)?(t.docChanged||t.selectionSet||e)&&this.setSelection(t.state):(this.pendingContextChange=null,this.reset(t.state)),(t.geometryChanged||t.docChanged||t.selectionSet)&&t.view.requestMeasure(this.measureReq)}resetRange(t){let{head:e}=t.selection.main;this.from=Math.max(0,e-1e4),this.to=Math.min(t.doc.length,e+1e4)}reset(t){this.resetRange(t),this.editContext.updateText(0,this.editContext.text.length,t.doc.sliceString(this.from,this.to)),this.setSelection(t)}revertPending(t){let e=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(e.from),this.toContextPos(e.from+e.insert.length),t.doc.sliceString(e.from,e.to))}setSelection(t){let{main:e}=t.selection,i=this.toContextPos(Math.max(this.from,Math.min(this.to,e.anchor))),n=this.toContextPos(e.head);this.editContext.selectionStart==i&&this.editContext.selectionEnd==n||this.editContext.updateSelection(i,n)}rangeIsValid(t){let{head:e}=t.selection.main;return!(this.from>0&&e-this.from<500||this.to<t.doc.length&&this.to-e<500||this.to-this.from>3e4)}toEditorPos(t,e=this.to-this.from){t=Math.min(t,e);let i=this.composing;return i&&i.drifted?i.editorBase+(t-i.contextBase):t+this.from}toContextPos(t){let e=this.composing;return e&&e.drifted?e.contextBase+(t-e.editorBase):t-this.from}destroy(){for(let t in this.handlers)this.editContext.removeEventListener(t,this.handlers[t])}}class nr{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&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(t={}){var 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.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),t.parent&&t.parent.appendChild(this.dom);let{dispatch:i}=t;this.dispatchTransactions=t.dispatchTransactions||i&&(t=>t.forEach(t=>i(t,this)))||(t=>this.update(t)),this.dispatch=this.dispatch.bind(this),this._root=t.root||function(t){for(;t;){if(t&&(9==t.nodeType||11==t.nodeType&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}(t.parent)||document,this.viewState=new Io(t.state||xe.create(t)),t.scrollTo&&t.scrollTo.is(Un)&&(this.viewState.scrollTarget=t.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Qn).map(t=>new ts(t));for(let t of this.plugins)t.update(this);this.observer=new Zo(this),this.inputState=new Fs(this),this.inputState.ensureHandlers(this.plugins),this.docView=new us(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),(null===(e=document.fonts)||void 0===e?void 0:e.ready)&&document.fonts.ready.then(()=>this.requestMeasure())}dispatch(...t){let e=1==t.length&&t[0]instanceof ce?t:1==t.length&&Array.isArray(t[0])?t[0]:[this.state.update(...t)];this.dispatchTransactions(e,this)}update(t){if(0!=this.updateState)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let e,i=!1,n=!1,s=this.state;for(let e of t){if(e.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=e.state}if(this.destroyed)return void(this.viewState.state=s);let o=this.hasFocus,r=0,l=null;t.some(t=>t.annotation(co))?(this.inputState.notifiedFocused=o,r=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,l=fo(s,o),l||(r=1));let a=this.observer.delayedAndroidKey,h=null;if(a?(this.observer.clearDelayedAndroidKey(),h=this.observer.readChange(),(h&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(h=null)):this.observer.clear(),s.facet(xe.phrases)!=this.state.facet(xe.phrases))return this.setState(s);e=ds.create(this,s,t),e.flags|=r;let c=this.viewState.scrollTarget;try{this.updateState=2;for(let e of t){if(c&&(c=c.map(e.changes)),e.scrollIntoView){let{main:t}=e.state.selection;c=new $n(t.empty?t:Lt.cursor(t.head,t.head>t.anchor?-1:1))}for(let t of e.effects)t.is(Un)&&(c=t.value.clip(this.state))}this.viewState.update(e,c),this.bidiCache=rr.update(this.bidiCache,e.changes),e.empty||(this.updatePlugins(e),this.inputState.update(e)),i=this.docView.update(e),this.state.facet(cs)!=this.styleModules&&this.mountStyles(),n=this.updateAttrs(),this.showAnnouncements(t),this.docView.updateSelection(i,t.some(t=>t.isUserEvent("select.pointer")))}finally{this.updateState=0}if(e.startState.facet(qo)!=e.state.facet(qo)&&(this.viewState.mustMeasureContent=!0),(i||n||c||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),i&&this.docViewUpdate(),!e.empty)for(let t of this.state.facet(Hn))try{t(e)}catch(t){Yn(this.state,t,"update listener")}(l||h)&&Promise.resolve().then(()=>{l&&this.state==l.startState&&this.dispatch(l),h&&!js(this,h)&&a.force&&Di(this.contentDOM,a.key,a.keyCode)})}setState(t){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=t);this.updateState=2;let e=this.hasFocus;try{for(let t of this.plugins)t.destroy(this);this.viewState=new Io(t),this.plugins=t.facet(Qn).map(t=>new ts(t)),this.pluginMap.clear();for(let t of this.plugins)t.update(this);this.docView.destroy(),this.docView=new us(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}e&&this.focus(),this.requestMeasure()}updatePlugins(t){let e=t.startState.facet(Qn),i=t.state.facet(Qn);if(e!=i){let n=[];for(let s of i){let i=e.indexOf(s);if(i<0)n.push(new ts(s));else{let e=this.plugins[i];e.mustUpdate=t,n.push(e)}}for(let e of this.plugins)e.mustUpdate!=t&&e.destroy(this);this.plugins=n,this.pluginMap.clear()}else for(let e of this.plugins)e.mustUpdate=t;for(let t=0;t<this.plugins.length;t++)this.plugins[t].update(this);e!=i&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let t of this.plugins){let e=t.value;if(e&&e.docViewUpdate)try{e.docViewUpdate(this)}catch(t){Yn(this.state,t,"doc view update listener")}}}measure(t=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey)return this.measureScheduled=-1,void this.requestMeasure();this.measureScheduled=0,t&&this.observer.forceFlush();let e=null,i=this.scrollDOM,n=i.scrollTop*this.scaleY,{scrollAnchorPos:s,scrollAnchorHeight:o}=this.viewState;Math.abs(n-this.viewState.scrollTop)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let t=0;;t++){if(o<0)if(Ei(i))s=-1,o=this.viewState.heightMap.height;else{let t=this.viewState.scrollAnchorAt(n);s=t.from,o=t.top}this.updateState=1;let r=this.viewState.measure(this);if(!r&&!this.measureRequests.length&&null==this.viewState.scrollTarget)break;if(t>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let l=[];4&r||([this.measureRequests,l]=[l,this.measureRequests]);let a=l.map(t=>{try{return t.read(this)}catch(t){return Yn(this.state,t),or}}),h=ds.create(this,this.state,[]),c=!1;h.flags|=r,e?e.flags|=r:e=h,this.updateState=2,h.empty||(this.updatePlugins(h),this.inputState.update(h),this.updateAttrs(),c=this.docView.update(h),c&&this.docViewUpdate());for(let t=0;t<l.length;t++)if(a[t]!=or)try{let e=l[t];e.write&&e.write(a[t],this)}catch(t){Yn(this.state,t)}if(c&&this.docView.updateSelection(!0),!h.viewportChanged&&0==this.measureRequests.length){if(this.viewState.editorHeight){if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,o=-1;continue}{let t=(s<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(s).top)-o;if(t>1||t<-1){n+=t,i.scrollTop=n/this.scaleY,o=-1;continue}}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(e&&!e.empty)for(let t of this.state.facet(Hn))t(e)}get themeClasses(){return Ko+" "+(this.state.facet(_o)?Uo:$o)+" "+this.state.facet(qo)}updateAttrs(){let t=lr(this,es,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),e={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(Jn)?"true":"false",class:"cm-content",style:`${fi.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(e["aria-readonly"]="true"),lr(this,is,e);let i=this.observer.ignore(()=>{let i=Qi(this.contentDOM,this.contentAttrs,e),n=Qi(this.dom,this.editorAttrs,t);return i||n});return this.editorAttrs=t,this.contentAttrs=e,i}showAnnouncements(t){let e=!0;for(let i of t)for(let t of i.effects)if(t.is(nr.announce)){e&&(this.announceDOM.textContent=""),e=!1,this.announceDOM.appendChild(document.createElement("div")).textContent=t.value}}mountStyles(){this.styleModules=this.state.facet(cs);let t=this.state.facet(nr.cspNonce);qe.mount(this.root,this.styleModules.concat(Jo).reverse(),t?{nonce:t}:void 0)}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(t){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),t){if(this.measureRequests.indexOf(t)>-1)return;if(null!=t.key)for(let e=0;e<this.measureRequests.length;e++)if(this.measureRequests[e].key===t.key)return void(this.measureRequests[e]=t);this.measureRequests.push(t)}}plugin(t){let e=this.pluginMap.get(t);return(void 0===e||e&&e.plugin!=t)&&this.pluginMap.set(t,e=this.plugins.find(e=>e.plugin==t)||null),e&&e.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(t){return this.readMeasured(),this.viewState.elementAtHeight(t)}lineBlockAtHeight(t){return this.readMeasured(),this.viewState.lineBlockAtHeight(t)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(t){return this.viewState.lineBlockAt(t)}get contentHeight(){return this.viewState.contentHeight}moveByChar(t,e,i){return Ls(this,t,Ts(this,t,e,i))}moveByGroup(t,e){return Ls(this,t,Ts(this,t,e,e=>function(t,e,i){let n=t.state.charCategorizer(e),s=n(i);return t=>{let e=n(t);return s==we.Space&&(s=e),s==e}}(this,t.head,e)))}visualLineSide(t,e){let i=this.bidiSpans(t),n=this.textDirectionAt(t.from),s=i[e?i.length-1:0];return Lt.cursor(s.side(e,n)+t.from,s.forward(!e,n)?1:-1)}moveToLineBoundary(t,e,i=!0){return function(t,e,i,n){let s=Ms(t,e.head,e.assoc||-1),o=n&&s.type==en.Text&&(t.lineWrapping||s.widgetLineBreaks)?t.coordsAtPos(e.assoc<0&&e.head>s.from?e.head-1:e.head):null;if(o){let e=t.dom.getBoundingClientRect(),n=t.textDirectionAt(s.from),r=t.posAtCoords({x:i==(n==mn.LTR)?e.right-1:e.left+1,y:(o.top+o.bottom)/2});if(null!=r)return Lt.cursor(r,i?-1:1)}return Lt.cursor(i?s.to:s.from,i?-1:1)}(this,t,e,i)}moveVertically(t,e,i){return Ls(this,t,function(t,e,i,n){let s=e.head,o=i?1:-1;if(s==(i?t.state.doc.length:0))return Lt.cursor(s,e.assoc);let r,l=e.goalColumn,a=t.contentDOM.getBoundingClientRect(),h=t.coordsAtPos(s,e.assoc||-1),c=t.documentTop;if(h)null==l&&(l=h.left-a.left),r=o<0?h.top:h.bottom;else{let e=t.viewState.lineBlockAt(s);null==l&&(l=Math.min(a.right-a.left,t.defaultCharacterWidth*(s-e.from))),r=(o<0?e.top:e.bottom)+c}let f=a.left+l,d=null!=n?n:t.viewState.heightOracle.textHeight>>1;for(let e=0;;e+=10){let i=r+(d+e)*o,n=Ss(t,{x:f,y:i},!1,o);if(i<a.top||i>a.bottom||(o<0?n<s:n>s)){let e=t.docView.coordsForChar(n),s=!e||i<e.top?-1:1;return Lt.cursor(n,s,void 0,l)}}}(this,t,e,i))}domAtPos(t){return this.docView.domAtPos(t)}posAtDOM(t,e=0){return this.docView.posFromDOM(t,e)}posAtCoords(t,e=!0){return this.readMeasured(),Ss(this,t,e)}coordsAtPos(t,e=1){this.readMeasured();let i=this.docView.coordsAt(t,e);if(!i||i.left==i.right)return i;let n=this.state.doc.lineAt(t),s=this.bidiSpans(n);return xi(i,s[An.find(s,t-n.from,-1,e)].dir==mn.LTR==e>0)}coordsForChar(t){return this.readMeasured(),this.docView.coordsForChar(t)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(t){return!this.state.facet(qn)||t<this.viewport.from||t>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(t))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(t){if(t.length>sr)return Ln(t.length);let e,i=this.textDirectionAt(t.from);for(let n of this.bidiCache)if(n.from==t.from&&n.dir==i&&(n.fresh||Mn(n.isolates,e=ls(this,t))))return n.order;e||(e=ls(this,t));let n=function(t,e,i){if(!t)return[new An(0,0,e==wn?1:0)];if(e==gn&&!i.length&&!Cn.test(t))return Ln(t.length);if(i.length)for(;t.length>Tn.length;)Tn[Tn.length]=256;let n=[],s=e==gn?0:1;return Dn(t,s,s,i,0,t.length,n),n}(t.text,i,e);return this.bidiCache.push(new rr(t.from,t.to,i,e,!0,n)),n}get hasFocus(){var t;return(this.dom.ownerDocument.hasFocus()||fi.safari&&(null===(t=this.inputState)||void 0===t?void 0:t.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{Ti(this.contentDOM),this.docView.updateSelection()})}setRoot(t){this._root!=t&&(this._root=t,this.observer.setWindow((9==t.nodeType?t:t.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let t of this.plugins)t.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(t,e={}){return Un.of(new $n("number"==typeof t?Lt.cursor(t):t,e.y,e.x,e.yMargin,e.xMargin))}scrollSnapshot(){let{scrollTop:t,scrollLeft:e}=this.scrollDOM,i=this.viewState.scrollAnchorAt(t);return Un.of(new $n(Lt.cursor(i.from),"start","start",i.top-t,e,!0))}setTabFocusMode(t){null==t?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:"boolean"==typeof t?this.inputState.tabFocusMode=t?0:-1:0!=this.inputState.tabFocusMode&&(this.inputState.tabFocusMode=Date.now()+t)}static domEventHandlers(t){return Zn.define(()=>({}),{eventHandlers:t})}static domEventObservers(t){return Zn.define(()=>({}),{eventObservers:t})}static theme(t,e){let i=qe.newName(),n=[qo.of(i),cs.of(Yo(`.${i}`,t))];return e&&e.dark&&n.push(_o.of(!0)),n}static baseTheme(t){return $t.lowest(cs.of(Yo("."+Ko,t,Go)))}static findFromDOM(t){var e;let i=t.querySelector(".cm-content"),n=i&&Ii.get(i)||Ii.get(t);return(null===(e=null==n?void 0:n.rootView)||void 0===e?void 0:e.view)||null}}nr.styleModule=cs,nr.inputHandler=Vn,nr.clipboardInputFilter=zn,nr.clipboardOutputFilter=Wn,nr.scrollHandler=Kn,nr.focusChangeEffect=Fn,nr.perLineTextDirection=qn,nr.exceptionSink=jn,nr.updateListener=Hn,nr.editable=Jn,nr.mouseSelectionStyle=In,nr.dragMovesSelection=Nn,nr.clickAddsSelectionRange=Rn,nr.decorations=ns,nr.outerDecorations=ss,nr.atomicRanges=os,nr.bidiIsolatedRanges=rs,nr.scrollMargins=as,nr.darkTheme=_o,nr.cspNonce=Bt.define({combine:t=>t.length?t[0]:""}),nr.contentAttributes=is,nr.editorAttributes=es,nr.lineWrapping=nr.contentAttributes.of({class:"cm-lineWrapping"}),nr.announce=he.define();const sr=4096,or={};class rr{constructor(t,e,i,n,s,o){this.from=t,this.to=e,this.dir=i,this.isolates=n,this.fresh=s,this.order=o}static update(t,e){if(e.empty&&!t.some(t=>t.fresh))return t;let i=[],n=t.length?t[t.length-1].dir:mn.LTR;for(let s=Math.max(0,t.length-10);s<t.length;s++){let o=t[s];o.dir!=n||e.touchesRange(o.from,o.to)||i.push(new rr(e.mapPos(o.from,1),e.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return i}}function lr(t,e,i){for(let n=t.state.facet(e),s=n.length-1;s>=0;s--){let e=n[s],o="function"==typeof e?e(t):e;o&&Yi(o,i)}return i}const ar=fi.mac?"mac":fi.windows?"win":fi.linux?"linux":"key";function hr(t,e,i){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),!1!==i&&e.shiftKey&&(t="Shift-"+t),t}const cr=$t.default(nr.domEventHandlers({keydown:(t,e)=>function(t,e,i,n){mr=e;let s=function(t){var e=!(Ge&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||Ye&&t.shiftKey&&t.key&&1==t.key.length||"Unidentified"==t.key)&&t.key||(t.shiftKey?Ue:$e)[t.keyCode]||t.key||"Unidentified";return"Esc"==e&&(e="Escape"),"Del"==e&&(e="Delete"),"Left"==e&&(e="ArrowLeft"),"Up"==e&&(e="ArrowUp"),"Right"==e&&(e="ArrowRight"),"Down"==e&&(e="ArrowDown"),e}(e),o=wt(s,0),r=vt(o)==s.length&&" "!=s,l="",a=!1,h=!1,c=!1;ur&&ur.view==i&&ur.scope==n&&(l=ur.prefix+" ",Ks.indexOf(e.keyCode)<0&&(h=!0,ur=null));let f,d,u=new Set,p=t=>{if(t){for(let e of t.run)if(!u.has(e)&&(u.add(e),e(i)))return t.stopPropagation&&(c=!0),!0;t.preventDefault&&(t.stopPropagation&&(c=!0),h=!0)}return!1},m=t[n];m&&(p(m[l+hr(s,e,!r)])?a=!0:!r||!(e.altKey||e.metaKey||e.ctrlKey)||fi.windows&&e.ctrlKey&&e.altKey||fi.mac&&e.altKey&&!e.ctrlKey&&!e.metaKey||!(f=$e[e.keyCode])||f==s?r&&e.shiftKey&&p(m[l+hr(s,e,!0)])&&(a=!0):(p(m[l+hr(f,e,!0)])||e.shiftKey&&(d=Ue[e.keyCode])!=s&&d!=f&&p(m[l+hr(d,e,!1)]))&&(a=!0),!a&&p(m._any)&&(a=!0));h&&(a=!0);a&&c&&e.stopPropagation();return mr=null,a}(function(t){let e=t.facet(fr),i=dr.get(e);i||dr.set(e,i=function(t,e=ar){let i=Object.create(null),n=Object.create(null),s=(t,e)=>{let i=n[t];if(null==i)n[t]=e;else if(i!=e)throw new Error("Key binding "+t+" is used both as a regular binding and as a multi-stroke prefix")},o=(t,n,o,r,l)=>{var a,h;let c=i[t]||(i[t]=Object.create(null)),f=n.split(/ (?!$)/).map(t=>function(t,e){const i=t.split(/-(?!$)/);let n,s,o,r,l=i[i.length-1];"Space"==l&&(l=" ");for(let t=0;t<i.length-1;++t){const l=i[t];if(/^(cmd|meta|m)$/i.test(l))r=!0;else if(/^a(lt)?$/i.test(l))n=!0;else if(/^(c|ctrl|control)$/i.test(l))s=!0;else if(/^s(hift)?$/i.test(l))o=!0;else{if(!/^mod$/i.test(l))throw new Error("Unrecognized modifier name: "+l);"mac"==e?r=!0:s=!0}}return n&&(l="Alt-"+l),s&&(l="Ctrl-"+l),r&&(l="Meta-"+l),o&&(l="Shift-"+l),l}(t,e));for(let e=1;e<f.length;e++){let i=f.slice(0,e).join(" ");s(i,!0),c[i]||(c[i]={preventDefault:!0,stopPropagation:!1,run:[e=>{let n=ur={view:e,prefix:i,scope:t};return setTimeout(()=>{ur==n&&(ur=null)},pr),!0}]})}let d=f.join(" ");s(d,!1);let u=c[d]||(c[d]={preventDefault:!1,stopPropagation:!1,run:(null===(h=null===(a=c._any)||void 0===a?void 0:a.run)||void 0===h?void 0:h.slice())||[]});o&&u.run.push(o),r&&(u.preventDefault=!0),l&&(u.stopPropagation=!0)};for(let n of t){let t=n.scope?n.scope.split(" "):["editor"];if(n.any)for(let e of t){let t=i[e]||(i[e]=Object.create(null));t._any||(t._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:s}=n;for(let e in t)t[e].run.push(t=>s(t,mr))}let s=n[e]||n.key;if(s)for(let e of t)o(e,s,n.run,n.preventDefault,n.stopPropagation),n.shift&&o(e,"Shift-"+s,n.shift,n.preventDefault,n.stopPropagation)}return i}(e.reduce((t,e)=>t.concat(e),[])));return i}(e.state),t,e,"editor")})),fr=Bt.define({enables:cr}),dr=new WeakMap;let ur=null;const pr=4e3;let mr=null;class gr{constructor(t,e,i,n,s){this.className=t,this.left=e,this.top=i,this.width=n,this.height=s}draw(){let t=document.createElement("div");return t.className=this.className,this.adjust(t),t}update(t,e){return e.className==this.className&&(this.adjust(t),!0)}adjust(t){t.style.left=this.left+"px",t.style.top=this.top+"px",null!=this.width&&(t.style.width=this.width+"px"),t.style.height=this.height+"px"}eq(t){return this.left==t.left&&this.top==t.top&&this.width==t.width&&this.height==t.height&&this.className==t.className}static forRange(t,e,i){if(i.empty){let n=t.coordsAtPos(i.head,i.assoc||1);if(!n)return[];let s=wr(t);return[new gr(e,n.left-s.left,n.top-s.top,null,n.bottom-n.top)]}return function(t,e,i){if(i.to<=t.viewport.from||i.from>=t.viewport.to)return[];let n=Math.max(i.from,t.viewport.from),s=Math.min(i.to,t.viewport.to),o=t.textDirection==mn.LTR,r=t.contentDOM,l=r.getBoundingClientRect(),a=wr(t),h=r.querySelector(".cm-line"),c=h&&window.getComputedStyle(h),f=l.left+(c?parseInt(c.paddingLeft)+Math.min(0,parseInt(c.textIndent)):0),d=l.right-(c?parseInt(c.paddingRight):0),u=Ms(t,n,1),p=Ms(t,s,-1),m=u.type==en.Text?u:null,g=p.type==en.Text?p:null;m&&(t.lineWrapping||u.widgetLineBreaks)&&(m=vr(t,n,1,m));g&&(t.lineWrapping||p.widgetLineBreaks)&&(g=vr(t,s,-1,g));if(m&&g&&m.from==g.from&&m.to==g.to)return v(b(i.from,i.to,m));{let e=m?b(i.from,null,m):y(u,!1),n=g?b(null,i.to,g):y(p,!0),s=[];return(m||u).to<(g||p).from-(m&&g?1:0)||u.widgetLineBreaks>1&&e.bottom+t.defaultLineHeight/2<n.top?s.push(w(f,e.bottom,d,n.top)):e.bottom<n.top&&t.elementAtHeight((e.bottom+n.top)/2).type==en.Text&&(e.bottom=n.top=(e.bottom+n.top)/2),v(e).concat(s).concat(v(n))}function w(t,i,n,s){return new gr(e,t-a.left,i-a.top,n-t,s-i)}function v({top:t,bottom:e,horizontal:i}){let n=[];for(let s=0;s<i.length;s+=2)n.push(w(i[s],t,i[s+1],e));return n}function b(e,i,n){let s=1e9,r=-1e9,l=[];function a(e,i,a,h,c){let u=t.coordsAtPos(e,e==n.to?-2:2),p=t.coordsAtPos(a,a==n.from?2:-2);u&&p&&(s=Math.min(u.top,p.top,s),r=Math.max(u.bottom,p.bottom,r),c==mn.LTR?l.push(o&&i?f:u.left,o&&h?d:p.right):l.push(!o&&h?f:p.left,!o&&i?d:u.right))}let h=null!=e?e:n.from,c=null!=i?i:n.to;for(let n of t.visibleRanges)if(n.to>h&&n.from<c)for(let s=Math.max(n.from,h),o=Math.min(n.to,c);;){let n=t.state.doc.lineAt(s);for(let r of t.bidiSpans(n)){let t=r.from+n.from,l=r.to+n.from;if(t>=o)break;l>s&&a(Math.max(t,s),null==e&&t<=h,Math.min(l,o),null==i&&l>=c,r.dir)}if(s=n.to+1,s>=o)break}return 0==l.length&&a(h,null==e,c,null==i,t.textDirection),{top:s,bottom:r,horizontal:l}}function y(t,e){let i=l.top+(e?t.top:t.bottom);return{top:i,bottom:i,horizontal:[]}}}(t,e,i)}}function wr(t){let e=t.scrollDOM.getBoundingClientRect();return{left:(t.textDirection==mn.LTR?e.left:e.right-t.scrollDOM.clientWidth*t.scaleX)-t.scrollDOM.scrollLeft*t.scaleX,top:e.top-t.scrollDOM.scrollTop*t.scaleY}}function vr(t,e,i,n){let s=t.coordsAtPos(e,2*i);if(!s)return n;let o=t.dom.getBoundingClientRect(),r=(s.top+s.bottom)/2,l=t.posAtCoords({x:o.left+1,y:r}),a=t.posAtCoords({x:o.right-1,y:r});return null==l||null==a?n:{from:Math.max(n.from,Math.min(l,a)),to:Math.min(n.to,Math.max(l,a))}}class br{constructor(t,e){this.view=t,this.layer=e,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=t.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),e.above&&this.dom.classList.add("cm-layer-above"),e.class&&this.dom.classList.add(e.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(t.state),t.requestMeasure(this.measureReq),e.mount&&e.mount(this.dom,t)}update(t){t.startState.facet(yr)!=t.state.facet(yr)&&this.setOrder(t.state),(this.layer.update(t,this.dom)||t.geometryChanged)&&(this.scale(),t.view.requestMeasure(this.measureReq))}docViewUpdate(t){!1!==this.layer.updateOnDocViewUpdate&&t.requestMeasure(this.measureReq)}setOrder(t){let e=0,i=t.facet(yr);for(;e<i.length&&i[e]!=this.layer;)e++;this.dom.style.zIndex=String((this.layer.above?150:-1)-e)}measure(){return this.layer.markers(this.view)}scale(){let{scaleX:t,scaleY:e}=this.view;t==this.scaleX&&e==this.scaleY||(this.scaleX=t,this.scaleY=e,this.dom.style.transform=`scale(${1/t}, ${1/e})`)}draw(t){if(t.length!=this.drawn.length||t.some((t,e)=>{return i=t,n=this.drawn[e],!(i.constructor==n.constructor&&i.eq(n));var i,n})){let e=this.dom.firstChild,i=0;for(let n of t)n.update&&e&&n.constructor&&this.drawn[i].constructor&&n.update(e,this.drawn[i])?(e=e.nextSibling,i++):this.dom.insertBefore(n.draw(),e);for(;e;){let t=e.nextSibling;e.remove(),e=t}this.drawn=t,fi.safari&&fi.safari_version>=26&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const yr=Bt.define();function xr(t){return[Zn.define(e=>new br(e,t)),yr.of(t)]}const kr=Bt.define({combine:t=>ke(t,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(t,e)=>Math.min(t,e),drawRangeCursor:(t,e)=>t||e})});function Sr(t={}){return[kr.of(t),Ar,Tr,Or,_n.of(!0)]}function Cr(t){return t.startState.facet(kr)!=t.state.facet(kr)}const Ar=xr({above:!0,markers(t){let{state:e}=t,i=e.facet(kr),n=[];for(let s of e.selection.ranges){let o=s==e.selection.main;if(s.empty||i.drawRangeCursor){let e=o?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",i=s.empty?s:Lt.cursor(s.head,s.head>s.anchor?-1:1);for(let s of gr.forRange(t,e,i))n.push(s)}}return n},update(t,e){t.transactions.some(t=>t.selection)&&(e.style.animationName="cm-blink"==e.style.animationName?"cm-blink2":"cm-blink");let i=Cr(t);return i&&Mr(t.state,e),t.docChanged||t.selectionSet||i},mount(t,e){Mr(e.state,t)},class:"cm-cursorLayer"});function Mr(t,e){e.style.animationDuration=t.facet(kr).cursorBlinkRate+"ms"}const Tr=xr({above:!1,markers:t=>t.state.selection.ranges.map(e=>e.empty?[]:gr.forRange(t,"cm-selectionBackground",e)).reduce((t,e)=>t.concat(e)),update:(t,e)=>t.docChanged||t.selectionSet||t.viewportChanged||Cr(t),class:"cm-selectionLayer"}),Or=$t.highest(nr.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:"transparent !important"},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}})),Dr="-10000px";class Lr{constructor(t,e,i,n){this.facet=e,this.createTooltipView=i,this.removeTooltipView=n,this.input=t.state.facet(e),this.tooltips=this.input.filter(t=>t);let s=null;this.tooltipViews=this.tooltips.map(t=>s=i(t,s))}update(t,e){var i;let n=t.state.facet(this.facet),s=n.filter(t=>t);if(n===this.input){for(let e of this.tooltipViews)e.update&&e.update(t);return!1}let o=[],r=e?[]:null;for(let i=0;i<s.length;i++){let n=s[i],l=-1;if(n){for(let t=0;t<this.tooltips.length;t++){let e=this.tooltips[t];e&&e.create==n.create&&(l=t)}if(l<0)o[i]=this.createTooltipView(n,i?o[i-1]:null),r&&(r[i]=!!n.above);else{let n=o[i]=this.tooltipViews[l];r&&(r[i]=e[l]),n.update&&n.update(t)}}}for(let t of this.tooltipViews)o.indexOf(t)<0&&(this.removeTooltipView(t),null===(i=t.destroy)||void 0===i||i.call(t));return e&&(r.forEach((t,i)=>e[i]=t),e.length=r.length),this.input=n,this.tooltips=s,this.tooltipViews=o,!0}}function Er(t){let e=t.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:e.clientHeight,right:e.clientWidth}}const Pr=Bt.define({combine:t=>{var e,i,n;return{position:fi.ios?"absolute":(null===(e=t.find(t=>t.position))||void 0===e?void 0:e.position)||"fixed",parent:(null===(i=t.find(t=>t.parent))||void 0===i?void 0:i.parent)||null,tooltipSpace:(null===(n=t.find(t=>t.tooltipSpace))||void 0===n?void 0:n.tooltipSpace)||Er}}}),Br=new WeakMap,Rr=Zn.fromClass(class{constructor(t){this.view=t,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let e=t.state.facet(Pr);this.position=e.position,this.parent=e.parent,this.classes=t.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver="function"==typeof ResizeObserver?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new Lr(t,Hr,(t,e)=>this.createTooltip(t,e),t=>{this.resizeObserver&&this.resizeObserver.unobserve(t.dom),t.dom.remove()}),this.above=this.manager.tooltips.map(t=>!!t.above),this.intersectionObserver="function"==typeof IntersectionObserver?new IntersectionObserver(t=>{Date.now()>this.lastTransaction-50&&t.length>0&&t[t.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),t.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let t of this.manager.tooltipViews)this.intersectionObserver.observe(t.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(t){t.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(t,this.above);e&&this.observeIntersection();let i=e||t.geometryChanged,n=t.state.facet(Pr);if(n.position!=this.position&&!this.madeAbsolute){this.position=n.position;for(let t of this.manager.tooltipViews)t.dom.style.position=this.position;i=!0}if(n.parent!=this.parent){this.parent&&this.container.remove(),this.parent=n.parent,this.createContainer();for(let t of this.manager.tooltipViews)this.container.appendChild(t.dom);i=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);i&&this.maybeMeasure()}createTooltip(t,e){let i=t.create(this.view),n=e?e.dom:null;if(i.dom.classList.add("cm-tooltip"),t.arrow&&!i.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let t=document.createElement("div");t.className="cm-tooltip-arrow",i.dom.appendChild(t)}return i.dom.style.position=this.position,i.dom.style.top=Dr,i.dom.style.left="0px",this.container.insertBefore(i.dom,n),i.mount&&i.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(i.dom),i}destroy(){var t,e,i;this.view.win.removeEventListener("resize",this.measureSoon);for(let e of this.manager.tooltipViews)e.dom.remove(),null===(t=e.destroy)||void 0===t||t.call(e);this.parent&&this.container.remove(),null===(e=this.resizeObserver)||void 0===e||e.disconnect(),null===(i=this.intersectionObserver)||void 0===i||i.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let t=1,e=1,i=!1;if("fixed"==this.position&&this.manager.tooltipViews.length){let{dom:t}=this.manager.tooltipViews[0];if(fi.safari){let e=t.getBoundingClientRect();i=Math.abs(e.top+1e4)>1||Math.abs(e.left)>1}else i=!!t.offsetParent&&t.offsetParent!=this.container.ownerDocument.body}if(i||"absolute"==this.position)if(this.parent){let i=this.parent.getBoundingClientRect();i.width&&i.height&&(t=i.width/this.parent.offsetWidth,e=i.height/this.parent.offsetHeight)}else({scaleX:t,scaleY:e}=this.view.viewState);let n=this.view.scrollDOM.getBoundingClientRect(),s=hs(this.view);return{visible:{left:n.left+s.left,top:n.top+s.top,right:n.right-s.right,bottom:n.bottom-s.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((t,e)=>{let i=this.manager.tooltipViews[e];return i.getCoords?i.getCoords(t.pos):this.view.coordsAtPos(t.pos)}),size:this.manager.tooltipViews.map(({dom:t})=>t.getBoundingClientRect()),space:this.view.state.facet(Pr).tooltipSpace(this.view),scaleX:t,scaleY:e,makeAbsolute:i}}writeMeasure(t){var e;if(t.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let t of this.manager.tooltipViews)t.dom.style.position="absolute"}let{visible:i,space:n,scaleX:s,scaleY:o}=t,r=[];for(let l=0;l<this.manager.tooltips.length;l++){let a=this.manager.tooltips[l],h=this.manager.tooltipViews[l],{dom:c}=h,f=t.pos[l],d=t.size[l];if(!f||!1!==a.clip&&(f.bottom<=Math.max(i.top,n.top)||f.top>=Math.min(i.bottom,n.bottom)||f.right<Math.max(i.left,n.left)-.1||f.left>Math.min(i.right,n.right)+.1)){c.style.top=Dr;continue}let u=a.arrow?h.dom.querySelector(".cm-tooltip-arrow"):null,p=u?7:0,m=d.right-d.left,g=null!==(e=Br.get(h))&&void 0!==e?e:d.bottom-d.top,w=h.offset||jr,v=this.view.textDirection==mn.LTR,b=d.width>n.right-n.left?v?n.left:n.right-d.width:v?Math.max(n.left,Math.min(f.left-(u?14:0)+w.x,n.right-m)):Math.min(Math.max(n.left,f.left-m+(u?14:0)-w.x),n.right-m),y=this.above[l];!a.strictSide&&(y?f.top-g-p-w.y<n.top:f.bottom+g+p+w.y>n.bottom)&&y==n.bottom-f.bottom>f.top-n.top&&(y=this.above[l]=!y);let x=(y?f.top-n.top:n.bottom-f.bottom)-p;if(x<g&&!1!==h.resize){if(x<this.view.defaultLineHeight){c.style.top=Dr;continue}Br.set(h,g),c.style.height=(g=x)/o+"px"}else c.style.height&&(c.style.height="");let k=y?f.top-g-p-w.y:f.bottom+p+w.y,S=b+m;if(!0!==h.overlap)for(let t of r)t.left<S&&t.right>b&&t.top<k+g&&t.bottom>k&&(k=y?t.top-g-2-p:t.bottom+p+2);if("absolute"==this.position?(c.style.top=(k-t.parent.top)/o+"px",Nr(c,(b-t.parent.left)/s)):(c.style.top=k/o+"px",Nr(c,b/s)),u){let t=f.left+(v?w.x:-w.x)-(b+14-7);u.style.left=t/s+"px"}!0!==h.overlap&&r.push({left:b,top:k,right:S,bottom:k+g}),c.classList.toggle("cm-tooltip-above",y),c.classList.toggle("cm-tooltip-below",!y),h.positioned&&h.positioned(t.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let t of this.manager.tooltipViews)t.dom.style.top=Dr}},{eventObservers:{scroll(){this.maybeMeasure()}}});function Nr(t,e){let i=parseInt(t.style.left,10);(isNaN(i)||Math.abs(e-i)>1)&&(t.style.left=e+"px")}const Ir=nr.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:"14px",position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),jr={x:0,y:0},Hr=Bt.define({enables:[Rr,Ir]}),Vr=Bt.define({combine:t=>t.reduce((t,e)=>t.concat(e),[])});class Fr{static create(t){return new Fr(t)}constructor(t){this.view=t,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new Lr(t,Vr,(t,e)=>this.createHostedView(t,e),t=>t.dom.remove())}createHostedView(t,e){let i=t.create(this.view);return i.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(i.dom,e?e.dom.nextSibling:this.dom.firstChild),this.mounted&&i.mount&&i.mount(this.view),i}mount(t){for(let e of this.manager.tooltipViews)e.mount&&e.mount(t);this.mounted=!0}positioned(t){for(let e of this.manager.tooltipViews)e.positioned&&e.positioned(t)}update(t){this.manager.update(t)}destroy(){var t;for(let e of this.manager.tooltipViews)null===(t=e.destroy)||void 0===t||t.call(e)}passProp(t){let e;for(let i of this.manager.tooltipViews){let n=i[t];if(void 0!==n)if(void 0===e)e=n;else if(e!==n)return}return e}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}}const zr=Hr.compute([Vr],t=>{let e=t.facet(Vr);return 0===e.length?null:{pos:Math.min(...e.map(t=>t.pos)),end:Math.max(...e.map(t=>{var e;return null!==(e=t.end)&&void 0!==e?e:t.pos})),create:Fr.create,above:e[0].above,arrow:e.some(t=>t.arrow)}});class Wr{constructor(t,e,i,n,s){this.view=t,this.source=e,this.field=i,this.setHover=n,this.hoverTime=s,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:t.dom,time:0},this.checkHover=this.checkHover.bind(this),t.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),t.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let t=Date.now()-this.lastMove.time;t<this.hoverTime?this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-t):this.startHover()}startHover(){clearTimeout(this.restartTimeout);let{view:t,lastMove:e}=this,i=t.docView.nearest(e.target);if(!i)return;let n,s=1;if(i instanceof qi)n=i.posAtStart;else{if(n=t.posAtCoords(e),null==n)return;let i=t.coordsAtPos(n);if(!i||e.y<i.top||e.y>i.bottom||e.x<i.left-t.defaultCharacterWidth||e.x>i.right+t.defaultCharacterWidth)return;let o=t.bidiSpans(t.state.doc.lineAt(n)).find(t=>t.from<=n&&t.to>=n),r=o&&o.dir==mn.RTL?-1:1;s=e.x<i.left?-r:r}let o=this.source(t,n,s);if(null==o?void 0:o.then){let e=this.pending={pos:n};o.then(i=>{this.pending==e&&(this.pending=null,!i||Array.isArray(i)&&!i.length||t.dispatch({effects:this.setHover.of(Array.isArray(i)?i:[i])}))},e=>Yn(t.state,e,"hover tooltip"))}else!o||Array.isArray(o)&&!o.length||t.dispatch({effects:this.setHover.of(Array.isArray(o)?o:[o])})}get tooltip(){let t=this.view.plugin(Rr),e=t?t.manager.tooltips.findIndex(t=>t.create==Fr.create):-1;return e>-1?t.manager.tooltipViews[e]:null}mousemove(t){var e,i;this.lastMove={x:t.clientX,y:t.clientY,target:t.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:n,tooltip:s}=this;if(n.length&&s&&!function(t,e){let i,{left:n,right:s,top:o,bottom:r}=t.getBoundingClientRect();if(i=t.querySelector(".cm-tooltip-arrow")){let t=i.getBoundingClientRect();o=Math.min(t.top,o),r=Math.max(t.bottom,r)}return e.clientX>=n-qr&&e.clientX<=s+qr&&e.clientY>=o-qr&&e.clientY<=r+qr}(s.dom,t)||this.pending){let{pos:s}=n[0]||this.pending,o=null!==(i=null===(e=n[0])||void 0===e?void 0:e.end)&&void 0!==i?i:s;(s==o?this.view.posAtCoords(this.lastMove)==s:function(t,e,i,n,s){let o=t.scrollDOM.getBoundingClientRect(),r=t.documentTop+t.documentPadding.top+t.contentHeight;if(o.left>n||o.right<n||o.top>s||Math.min(o.bottom,r)<s)return!1;let l=t.posAtCoords({x:n,y:s},!1);return l>=e&&l<=i}(this.view,s,o,t.clientX,t.clientY))||(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(t){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:e}=this;if(e.length){let{tooltip:e}=this;e&&e.dom.contains(t.relatedTarget)?this.watchTooltipLeave(e.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(t){let e=i=>{t.removeEventListener("mouseleave",e),this.active.length&&!this.view.dom.contains(i.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};t.addEventListener("mouseleave",e)}destroy(){clearTimeout(this.hoverTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}const qr=4;function _r(t,e={}){let i=he.define(),n=Ft.define({create:()=>[],update(t,n){if(t.length&&(e.hideOnChange&&(n.docChanged||n.selection)?t=[]:e.hideOn&&(t=t.filter(t=>!e.hideOn(n,t))),n.docChanged)){let e=[];for(let i of t){let t=n.changes.mapPos(i.pos,-1,yt.TrackDel);if(null!=t){let s=Object.assign(Object.create(null),i);s.pos=t,null!=s.end&&(s.end=n.changes.mapPos(s.end)),e.push(s)}}t=e}for(let e of n.effects)e.is(i)&&(t=e.value),e.is(Kr)&&(t=[]);return t},provide:t=>Vr.from(t)});return{active:n,extension:[n,Zn.define(s=>new Wr(s,t,n,i,e.hoverTime||300)),zr]}}const Kr=he.define(),$r=Bt.define({combine(t){let e,i;for(let n of t)e=e||n.topContainer,i=i||n.bottomContainer;return{topContainer:e,bottomContainer:i}}});const Ur=Zn.fromClass(class{constructor(t){this.input=t.state.facet(Jr),this.specs=this.input.filter(t=>t),this.panels=this.specs.map(e=>e(t));let e=t.state.facet($r);this.top=new Gr(t,!0,e.topContainer),this.bottom=new Gr(t,!1,e.bottomContainer),this.top.sync(this.panels.filter(t=>t.top)),this.bottom.sync(this.panels.filter(t=>!t.top));for(let t of this.panels)t.dom.classList.add("cm-panel"),t.mount&&t.mount()}update(t){let e=t.state.facet($r);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new Gr(t.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new Gr(t.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let i=t.state.facet(Jr);if(i!=this.input){let e=i.filter(t=>t),n=[],s=[],o=[],r=[];for(let i of e){let e,l=this.specs.indexOf(i);l<0?(e=i(t.view),r.push(e)):(e=this.panels[l],e.update&&e.update(t)),n.push(e),(e.top?s:o).push(e)}this.specs=e,this.panels=n,this.top.sync(s),this.bottom.sync(o);for(let t of r)t.dom.classList.add("cm-panel"),t.mount&&t.mount()}else for(let e of this.panels)e.update&&e.update(t)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:t=>nr.scrollMargins.of(e=>{let i=e.plugin(t);return i&&{top:i.top.scrollMargin(),bottom:i.bottom.scrollMargin()}})});class Gr{constructor(t,e,i){this.view=t,this.top=e,this.container=i,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(t){for(let e of this.panels)e.destroy&&t.indexOf(e)<0&&e.destroy();this.panels=t,this.syncDOM()}syncDOM(){if(0==this.panels.length)return void(this.dom&&(this.dom.remove(),this.dom=void 0));if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom",this.dom.style[this.top?"top":"bottom"]="0";let t=this.container||this.view.dom;t.insertBefore(this.dom,this.top?t.firstChild:null)}let t=this.dom.firstChild;for(let e of this.panels)if(e.dom.parentNode==this.dom){for(;t!=e.dom;)t=Yr(t);t=t.nextSibling}else this.dom.insertBefore(e.dom,t);for(;t;)t=Yr(t)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(this.container&&this.classes!=this.view.themeClasses){for(let t of this.classes.split(" "))t&&this.container.classList.remove(t);for(let t of(this.classes=this.view.themeClasses).split(" "))t&&this.container.classList.add(t)}}}function Yr(t){let e=t.nextSibling;return t.remove(),e}const Jr=Bt.define({enables:Ur});class Xr extends Se{compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}eq(t){return!1}destroy(t){}}Xr.prototype.elementClass="",Xr.prototype.toDOM=void 0,Xr.prototype.mapMode=yt.TrackBefore,Xr.prototype.startSide=Xr.prototype.endSide=-1,Xr.prototype.point=!0;const Qr=Bt.define(),Zr=Bt.define(),tl={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>Te.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:"before"},el=Bt.define();function il(t){return[sl(),el.of({...tl,...t})]}const nl=Bt.define({combine:t=>t.some(t=>t)});function sl(t){return[ol]}const ol=Zn.fromClass(class{constructor(t){this.view=t,this.domAfter=null,this.prevViewport=t.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=t.state.facet(el).map(e=>new hl(t,e)),this.fixed=!t.state.facet(nl);for(let t of this.gutters)"after"==t.config.side?this.getDOMAfter().appendChild(t.dom):this.dom.appendChild(t.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),t.scrollDOM.insertBefore(this.dom,t.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(t){if(this.updateGutters(t)){let e=this.prevViewport,i=t.view.viewport,n=Math.min(e.to,i.to)-Math.max(e.from,i.from);this.syncGutters(n<.8*(i.to-i.from))}if(t.geometryChanged){let t=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=t,this.domAfter&&(this.domAfter.style.minHeight=t)}this.view.state.facet(nl)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=t.view.viewport}syncGutters(t){let e=this.dom.nextSibling;t&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let i=Te.iter(this.view.state.facet(Qr),this.view.viewport.from),n=[],s=this.gutters.map(t=>new al(t,this.view.viewport,-this.view.documentPadding.top));for(let t of this.view.viewportLineBlocks)if(n.length&&(n=[]),Array.isArray(t.type)){let e=!0;for(let o of t.type)if(o.type==en.Text&&e){ll(i,n,o.from);for(let t of s)t.line(this.view,o,n);e=!1}else if(o.widget)for(let t of s)t.widget(this.view,o)}else if(t.type==en.Text){ll(i,n,t.from);for(let e of s)e.line(this.view,t,n)}else if(t.widget)for(let e of s)e.widget(this.view,t);for(let t of s)t.finish();t&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(t){let e=t.startState.facet(el),i=t.state.facet(el),n=t.docChanged||t.heightChanged||t.viewportChanged||!Te.eq(t.startState.facet(Qr),t.state.facet(Qr),t.view.viewport.from,t.view.viewport.to);if(e==i)for(let e of this.gutters)e.update(t)&&(n=!0);else{n=!0;let s=[];for(let n of i){let i=e.indexOf(n);i<0?s.push(new hl(this.view,n)):(this.gutters[i].update(t),s.push(this.gutters[i]))}for(let t of this.gutters)t.dom.remove(),s.indexOf(t)<0&&t.destroy();for(let t of s)"after"==t.config.side?this.getDOMAfter().appendChild(t.dom):this.dom.appendChild(t.dom);this.gutters=s}return n}destroy(){for(let t of this.gutters)t.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:t=>nr.scrollMargins.of(e=>{let i=e.plugin(t);if(!i||0==i.gutters.length||!i.fixed)return null;let n=i.dom.offsetWidth*e.scaleX,s=i.domAfter?i.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==mn.LTR?{left:n,right:s}:{right:n,left:s}})});function rl(t){return Array.isArray(t)?t:[t]}function ll(t,e,i){for(;t.value&&t.from<=i;)t.from==i&&e.push(t.value),t.next()}class al{constructor(t,e,i){this.gutter=t,this.height=i,this.i=0,this.cursor=Te.iter(t.markers,e.from)}addElement(t,e,i){let{gutter:n}=this,s=(e.top-this.height)/t.scaleY,o=e.height/t.scaleY;if(this.i==n.elements.length){let e=new cl(t,o,s,i);n.elements.push(e),n.dom.appendChild(e.dom)}else n.elements[this.i].update(t,o,s,i);this.height=e.bottom,this.i++}line(t,e,i){let n=[];ll(this.cursor,n,e.from),i.length&&(n=n.concat(i));let s=this.gutter.config.lineMarker(t,e,n);s&&n.unshift(s);let o=this.gutter;(0!=n.length||o.config.renderEmptyElements)&&this.addElement(t,e,n)}widget(t,e){let i=this.gutter.config.widgetMarker(t,e.widget,e),n=i?[i]:null;for(let i of t.state.facet(Zr)){let s=i(t,e.widget,e);s&&(n||(n=[])).push(s)}n&&this.addElement(t,e,n)}finish(){let t=this.gutter;for(;t.elements.length>this.i;){let e=t.elements.pop();t.dom.removeChild(e.dom),e.destroy()}}}class hl{constructor(t,e){this.view=t,this.config=e,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let i in e.domEventHandlers)this.dom.addEventListener(i,n=>{let s,o=n.target;if(o!=this.dom&&this.dom.contains(o)){for(;o.parentNode!=this.dom;)o=o.parentNode;let t=o.getBoundingClientRect();s=(t.top+t.bottom)/2}else s=n.clientY;let r=t.lineBlockAtHeight(s-t.documentTop);e.domEventHandlers[i](t,r,n)&&n.preventDefault()});this.markers=rl(e.markers(t)),e.initialSpacer&&(this.spacer=new cl(t,0,0,[e.initialSpacer(t)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(t){let e=this.markers;if(this.markers=rl(this.config.markers(t.view)),this.spacer&&this.config.updateSpacer){let e=this.config.updateSpacer(this.spacer.markers[0],t);e!=this.spacer.markers[0]&&this.spacer.update(t.view,0,0,[e])}let i=t.view.viewport;return!Te.eq(this.markers,e,i.from,i.to)||!!this.config.lineMarkerChange&&this.config.lineMarkerChange(t)}destroy(){for(let t of this.elements)t.destroy()}}class cl{constructor(t,e,i,n){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(t,e,i,n)}update(t,e,i,n){this.height!=e&&(this.height=e,this.dom.style.height=e+"px"),this.above!=i&&(this.dom.style.marginTop=(this.above=i)?i+"px":""),function(t,e){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++)if(!t[i].compare(e[i]))return!1;return!0}(this.markers,n)||this.setMarkers(t,n)}setMarkers(t,e){let i="cm-gutterElement",n=this.dom.firstChild;for(let s=0,o=0;;){let r=o,l=s<e.length?e[s++]:null,a=!1;if(l){let t=l.elementClass;t&&(i+=" "+t);for(let t=o;t<this.markers.length;t++)if(this.markers[t].compare(l)){r=t,a=!0;break}}else r=this.markers.length;for(;o<r;){let t=this.markers[o++];if(t.toDOM){t.destroy(n);let e=n.nextSibling;n.remove(),n=e}}if(!l)break;l.toDOM&&(a?n=n.nextSibling:this.dom.insertBefore(l.toDOM(t),n)),a&&o++}this.dom.className=i,this.markers=e}destroy(){this.setMarkers(null,[])}}const fl=Bt.define(),dl=Bt.define(),ul=Bt.define({combine:t=>ke(t,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(t,e){let i=Object.assign({},t);for(let t in e){let n=i[t],s=e[t];i[t]=n?(t,e,i)=>n(t,e,i)||s(t,e,i):s}return i}})});class pl extends Xr{constructor(t){super(),this.number=t}eq(t){return this.number==t.number}toDOM(){return document.createTextNode(this.number)}}function ml(t,e){return t.state.facet(ul).formatNumber(e,t.state)}const gl=el.compute([ul],t=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers:t=>t.state.facet(fl),lineMarker:(t,e,i)=>i.some(t=>t.toDOM)?null:new pl(ml(t,t.state.doc.lineAt(e.from).number)),widgetMarker:(t,e,i)=>{for(let n of t.state.facet(dl)){let s=n(t,e,i);if(s)return s}return null},lineMarkerChange:t=>t.startState.facet(ul)!=t.state.facet(ul),initialSpacer:t=>new pl(ml(t,vl(t.state.doc.lines))),updateSpacer(t,e){let i=ml(e.view,vl(e.view.state.doc.lines));return i==t.number?t:new pl(i)},domEventHandlers:t.facet(ul).domEventHandlers,side:"before"}));function wl(t={}){return[ul.of(t),sl(),gl]}function vl(t){let e=9;for(;e<t;)e=10*e+9;return e}let bl=0;class yl{constructor(t,e,i,n){this.name=t,this.set=e,this.base=i,this.modified=n,this.id=bl++}toString(){let{name:t}=this;for(let e of this.modified)e.name&&(t=`${e.name}(${t})`);return t}static define(t,e){let i="string"==typeof t?t:"?";if(t instanceof yl&&(e=t),null==e?void 0:e.base)throw new Error("Can not derive from a modified tag");let n=new yl(i,[],null,[]);if(n.set.push(n),e)for(let t of e.set)n.set.push(t);return n}static defineModifier(t){let e=new kl(t);return t=>t.modified.indexOf(e)>-1?t:kl.get(t.base||t,t.modified.concat(e).sort((t,e)=>t.id-e.id))}}let xl=0;class kl{constructor(t){this.name=t,this.instances=[],this.id=xl++}static get(t,e){if(!e.length)return t;let i=e[0].instances.find(i=>{return i.base==t&&(n=e,s=i.modified,n.length==s.length&&n.every((t,e)=>t==s[e]));var n,s});if(i)return i;let n=[],s=new yl(t.name,n,t,e);for(let t of e)t.instances.push(s);let o=function(t){let e=[[]];for(let i=0;i<t.length;i++)for(let n=0,s=e.length;n<s;n++)e.push(e[n].concat(t[i]));return e.sort((t,e)=>e.length-t.length)}(e);for(let e of t.set)if(!e.modified.length)for(let t of o)n.push(kl.get(e,t));return s}}function Sl(t){let e=Object.create(null);for(let i in t){let n=t[i];Array.isArray(n)||(n=[n]);for(let t of i.split(" "))if(t){let i=[],s=2,o=t;for(let e=0;;){if("..."==o&&e>0&&e+3==t.length){s=1;break}let n=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(o);if(!n)throw new RangeError("Invalid path: "+t);if(i.push("*"==n[0]?"":'"'==n[0][0]?JSON.parse(n[0]):n[0]),e+=n[0].length,e==t.length)break;let r=t[e++];if(e==t.length&&"!"==r){s=0;break}if("/"!=r)throw new RangeError("Invalid path: "+t);o=t.slice(e)}let r=i.length-1,l=i[r];if(!l)throw new RangeError("Invalid path: "+t);let a=new Al(n,s,r>0?i.slice(0,r):null);e[l]=a.sort(e[l])}}return Cl.add(e)}const Cl=new o({combine(t,e){let i,n,s;for(;t||e;){if(!t||e&&t.depth>=e.depth?(s=e,e=e.next):(s=t,t=t.next),i&&i.mode==s.mode&&!s.context&&!i.context)continue;let o=new Al(s.tags,s.mode,s.context);i?i.next=o:n=o,i=o}return n}});class Al{constructor(t,e,i,n){this.tags=t,this.mode=e,this.context=i,this.next=n}get opaque(){return 0==this.mode}get inherit(){return 1==this.mode}sort(t){return!t||t.depth<this.depth?(this.next=t,this):(t.next=this.sort(t.next),t)}get depth(){return this.context?this.context.length:0}}function Ml(t,e){let i=Object.create(null);for(let e of t)if(Array.isArray(e.tag))for(let t of e.tag)i[t.id]=e.class;else i[e.tag.id]=e.class;let{scope:n,all:s=null}=e||{};return{style:t=>{let e=s;for(let n of t)for(let t of n.set){let n=i[t.id];if(n){e=e?e+" "+n:n;break}}return e},scope:n}}function Tl(t,e,i,n=0,s=t.length){let o=new Ol(n,Array.isArray(e)?e:[e],i);o.highlightRange(t.cursor(),n,s,"",o.highlighters),o.flush(s)}Al.empty=new Al([],2,null);class Ol{constructor(t,e,i){this.at=t,this.highlighters=e,this.span=i,this.class=""}startSpan(t,e){e!=this.class&&(this.flush(t),t>this.at&&(this.at=t),this.class=e)}flush(t){t>this.at&&this.class&&this.span(this.at,t,this.class)}highlightRange(t,e,i,n,s){let{type:r,from:l,to:a}=t;if(l>=i||a<=e)return;r.isTop&&(s=this.highlighters.filter(t=>!t.scope||t.scope(r)));let h=n,c=function(t){let e=t.type.prop(Cl);for(;e&&e.context&&!t.matchContext(e.context);)e=e.next;return e||null}(t)||Al.empty,f=function(t,e){let i=null;for(let n of t){let t=n.style(e);t&&(i=i?i+" "+t:t)}return i}(s,c.tags);if(f&&(h&&(h+=" "),h+=f,1==c.mode&&(n+=(n?" ":"")+f)),this.startSpan(Math.max(e,l),h),c.opaque)return;let d=t.tree&&t.tree.prop(o.mounted);if(d&&d.overlay){let o=t.node.enter(d.overlay[0].from+l,1),r=this.highlighters.filter(t=>!t.scope||t.scope(d.tree.type)),c=t.firstChild();for(let f=0,u=l;;f++){let p=f<d.overlay.length?d.overlay[f]:null,m=p?p.from+l:a,g=Math.max(e,u),w=Math.min(i,m);if(g<w&&c)for(;t.from<w&&(this.highlightRange(t,g,w,n,s),this.startSpan(Math.min(w,t.to),h),!(t.to>=m)&&t.nextSibling()););if(!p||m>i)break;u=p.to+l,u>e&&(this.highlightRange(o.cursor(),Math.max(e,p.from+l),Math.min(i,u),"",r),this.startSpan(Math.min(i,u),h))}c&&t.parent()}else if(t.firstChild()){d&&(n="");do{if(!(t.to<=e)){if(t.from>=i)break;this.highlightRange(t,e,i,n,s),this.startSpan(Math.min(i,t.to),h)}}while(t.nextSibling());t.parent()}}}const Dl=yl.define,Ll=Dl(),El=Dl(),Pl=Dl(El),Bl=Dl(El),Rl=Dl(),Nl=Dl(Rl),Il=Dl(Rl),jl=Dl(),Hl=Dl(jl),Vl=Dl(),Fl=Dl(),zl=Dl(),Wl=Dl(zl),ql=Dl(),_l={comment:Ll,lineComment:Dl(Ll),blockComment:Dl(Ll),docComment:Dl(Ll),name:El,variableName:Dl(El),typeName:Pl,tagName:Dl(Pl),propertyName:Bl,attributeName:Dl(Bl),className:Dl(El),labelName:Dl(El),namespace:Dl(El),macroName:Dl(El),literal:Rl,string:Nl,docString:Dl(Nl),character:Dl(Nl),attributeValue:Dl(Nl),number:Il,integer:Dl(Il),float:Dl(Il),bool:Dl(Rl),regexp:Dl(Rl),escape:Dl(Rl),color:Dl(Rl),url:Dl(Rl),keyword:Vl,self:Dl(Vl),null:Dl(Vl),atom:Dl(Vl),unit:Dl(Vl),modifier:Dl(Vl),operatorKeyword:Dl(Vl),controlKeyword:Dl(Vl),definitionKeyword:Dl(Vl),moduleKeyword:Dl(Vl),operator:Fl,derefOperator:Dl(Fl),arithmeticOperator:Dl(Fl),logicOperator:Dl(Fl),bitwiseOperator:Dl(Fl),compareOperator:Dl(Fl),updateOperator:Dl(Fl),definitionOperator:Dl(Fl),typeOperator:Dl(Fl),controlOperator:Dl(Fl),punctuation:zl,separator:Dl(zl),bracket:Wl,angleBracket:Dl(Wl),squareBracket:Dl(Wl),paren:Dl(Wl),brace:Dl(Wl),content:jl,heading:Hl,heading1:Dl(Hl),heading2:Dl(Hl),heading3:Dl(Hl),heading4:Dl(Hl),heading5:Dl(Hl),heading6:Dl(Hl),contentSeparator:Dl(jl),list:Dl(jl),quote:Dl(jl),emphasis:Dl(jl),strong:Dl(jl),link:Dl(jl),monospace:Dl(jl),strikethrough:Dl(jl),inserted:Dl(),deleted:Dl(),changed:Dl(),invalid:Dl(),meta:ql,documentMeta:Dl(ql),annotation:Dl(ql),processingInstruction:Dl(ql),definition:yl.defineModifier("definition"),constant:yl.defineModifier("constant"),function:yl.defineModifier("function"),standard:yl.defineModifier("standard"),local:yl.defineModifier("local"),special:yl.defineModifier("special")};for(let t in _l){let e=_l[t];e instanceof yl&&(e.name=t)}var Kl;Ml([{tag:_l.link,class:"tok-link"},{tag:_l.heading,class:"tok-heading"},{tag:_l.emphasis,class:"tok-emphasis"},{tag:_l.strong,class:"tok-strong"},{tag:_l.keyword,class:"tok-keyword"},{tag:_l.atom,class:"tok-atom"},{tag:_l.bool,class:"tok-bool"},{tag:_l.url,class:"tok-url"},{tag:_l.labelName,class:"tok-labelName"},{tag:_l.inserted,class:"tok-inserted"},{tag:_l.deleted,class:"tok-deleted"},{tag:_l.literal,class:"tok-literal"},{tag:_l.string,class:"tok-string"},{tag:_l.number,class:"tok-number"},{tag:[_l.regexp,_l.escape,_l.special(_l.string)],class:"tok-string2"},{tag:_l.variableName,class:"tok-variableName"},{tag:_l.local(_l.variableName),class:"tok-variableName tok-local"},{tag:_l.definition(_l.variableName),class:"tok-variableName tok-definition"},{tag:_l.special(_l.variableName),class:"tok-variableName2"},{tag:_l.definition(_l.propertyName),class:"tok-propertyName tok-definition"},{tag:_l.typeName,class:"tok-typeName"},{tag:_l.namespace,class:"tok-namespace"},{tag:_l.className,class:"tok-className"},{tag:_l.macroName,class:"tok-macroName"},{tag:_l.propertyName,class:"tok-propertyName"},{tag:_l.operator,class:"tok-operator"},{tag:_l.comment,class:"tok-comment"},{tag:_l.meta,class:"tok-meta"},{tag:_l.invalid,class:"tok-invalid"},{tag:_l.punctuation,class:"tok-punctuation"}]);const $l=new o;function Ul(t){return Bt.define({combine:t?e=>e.concat(t):void 0})}const Gl=new o;class Yl{constructor(t,e,i=[],n=""){this.data=t,this.name=n,xe.prototype.hasOwnProperty("tree")||Object.defineProperty(xe.prototype,"tree",{get(){return Ql(this)}}),this.parser=e,this.extension=[la.of(this),xe.languageData.of((t,e,i)=>{let n=Jl(t,e,i),s=n.type.prop($l);if(!s)return[];let o=t.facet(s),r=n.type.prop(Gl);if(r){let s=n.resolve(e-n.from,i);for(let e of r)if(e.test(s,t)){let i=t.facet(e.facet);return"replace"==e.type?i:i.concat(o)}}return o})].concat(i)}isActiveAt(t,e,i=-1){return Jl(t,e,i).type.prop($l)==this.data}findRegions(t){let e=t.facet(la);if((null==e?void 0:e.data)==this.data)return[{from:0,to:t.doc.length}];if(!e||!e.allowsNesting)return[];let i=[],n=(t,e)=>{if(t.prop($l)==this.data)return void i.push({from:e,to:e+t.length});let s=t.prop(o.mounted);if(s){if(s.tree.prop($l)==this.data){if(s.overlay)for(let t of s.overlay)i.push({from:t.from+e,to:t.to+e});else i.push({from:e,to:e+t.length});return}if(s.overlay){let t=i.length;if(n(s.tree,s.overlay[0].from+e),i.length>t)return}}for(let i=0;i<t.children.length;i++){let s=t.children[i];s instanceof u&&n(s,t.positions[i]+e)}};return n(Ql(t),0),i}get allowsNesting(){return!0}}function Jl(t,e,i){let n=t.facet(la),s=Ql(t).topNode;if(!n||n.allowsNesting)for(let t=s;t;t=t.enter(e,i,d.ExcludeBuffers))t.type.isTop&&(s=t);return s}Yl.setState=he.define();class Xl extends Yl{constructor(t,e,i){super(t,e,[],i),this.parser=e}static define(t){let e=Ul(t.languageData);return new Xl(e,t.parser.configure({props:[$l.add(t=>t.isTop?e:void 0)]}),t.name)}configure(t,e){return new Xl(this.data,this.parser.configure(t),e||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function Ql(t){let e=t.field(Yl.state,!1);return e?e.tree:u.empty}class Zl{constructor(t){this.doc=t,this.cursorPos=0,this.string="",this.cursor=t.iter()}get length(){return this.doc.length}syncTo(t){return this.string=this.cursor.next(t-this.cursorPos).value,this.cursorPos=t+this.string.length,this.cursorPos-this.string.length}chunk(t){return this.syncTo(t),this.string}get lineChunks(){return!0}read(t,e){let i=this.cursorPos-this.string.length;return t<i||e>=this.cursorPos?this.doc.sliceString(t,e):this.string.slice(t-i,e-i)}}let ta=null;class ea{constructor(t,e,i=[],n,s,o,r,l){this.parser=t,this.state=e,this.fragments=i,this.tree=n,this.treeLen=s,this.viewport=o,this.skipped=r,this.scheduleOn=l,this.parse=null,this.tempSkipped=[]}static create(t,e,i){return new ea(t,e,[],u.empty,0,i,[],null)}startParse(){return this.parser.startParse(new Zl(this.state.doc),this.fragments)}work(t,e){return null!=e&&e>=this.state.doc.length&&(e=void 0),this.tree!=u.empty&&this.isDone(null!=e?e:this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var i;if("number"==typeof t){let e=Date.now()+t;t=()=>Date.now()>e}for(this.parse||(this.parse=this.startParse()),null!=e&&(null==this.parse.stoppedAt||this.parse.stoppedAt>e)&&e<this.state.doc.length&&this.parse.stopAt(e);;){let n=this.parse.advance();if(n){if(this.fragments=this.withoutTempSkipped(P.addTree(n,this.fragments,null!=this.parse.stoppedAt)),this.treeLen=null!==(i=this.parse.stoppedAt)&&void 0!==i?i:this.state.doc.length,this.tree=n,this.parse=null,!(this.treeLen<(null!=e?e:this.state.doc.length)))return!0;this.parse=this.startParse()}if(t())return!1}})}takeTree(){let t,e;this.parse&&(t=this.parse.parsedPos)>=this.treeLen&&((null==this.parse.stoppedAt||this.parse.stoppedAt>t)&&this.parse.stopAt(t),this.withContext(()=>{for(;!(e=this.parse.advance()););}),this.treeLen=t,this.tree=e,this.fragments=this.withoutTempSkipped(P.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(t){let e=ta;ta=this;try{return t()}finally{ta=e}}withoutTempSkipped(t){for(let e;e=this.tempSkipped.pop();)t=ia(t,e.from,e.to);return t}changes(t,e){let{fragments:i,tree:n,treeLen:s,viewport:o,skipped:r}=this;if(this.takeTree(),!t.empty){let e=[];if(t.iterChangedRanges((t,i,n,s)=>e.push({fromA:t,toA:i,fromB:n,toB:s})),i=P.applyChanges(i,e),n=u.empty,s=0,o={from:t.mapPos(o.from,-1),to:t.mapPos(o.to,1)},this.skipped.length){r=[];for(let e of this.skipped){let i=t.mapPos(e.from,1),n=t.mapPos(e.to,-1);i<n&&r.push({from:i,to:n})}}}return new ea(this.parser,e,i,n,s,o,r,this.scheduleOn)}updateViewport(t){if(this.viewport.from==t.from&&this.viewport.to==t.to)return!1;this.viewport=t;let e=this.skipped.length;for(let e=0;e<this.skipped.length;e++){let{from:i,to:n}=this.skipped[e];i<t.to&&n>t.from&&(this.fragments=ia(this.fragments,i,n),this.skipped.splice(e--,1))}return!(this.skipped.length>=e)&&(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(t,e){this.skipped.push({from:t,to:e})}static getSkippingParser(t){return new class extends B{createParse(e,i,n){let s=n[0].from,o=n[n.length-1].to;return{parsedPos:s,advance(){let e=ta;if(e){for(let t of n)e.tempSkipped.push(t);t&&(e.scheduleOn=e.scheduleOn?Promise.all([e.scheduleOn,t]):t)}return this.parsedPos=o,new u(a.none,[],[],o-s)},stoppedAt:null,stopAt(){}}}}}isDone(t){t=Math.min(t,this.state.doc.length);let e=this.fragments;return this.treeLen>=t&&e.length&&0==e[0].from&&e[0].to>=t}static get(){return ta}}function ia(t,e,i){return P.applyChanges(t,[{fromA:e,toA:i,fromB:e,toB:i}])}class na{constructor(t){this.context=t,this.tree=t.tree}apply(t){if(!t.docChanged&&this.tree==this.context.tree)return this;let e=this.context.changes(t.changes,t.state),i=this.context.treeLen==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.treeLen),e.viewport.to);return e.work(20,i)||e.takeTree(),new na(e)}static init(t){let e=Math.min(3e3,t.doc.length),i=ea.create(t.facet(la).parser,t,{from:0,to:e});return i.work(20,e)||i.takeTree(),new na(i)}}Yl.state=Ft.define({create:na.init,update(t,e){for(let t of e.effects)if(t.is(Yl.setState))return t.value;return e.startState.facet(la)!=e.state.facet(la)?na.init(e.state):t.apply(e)}});let sa=t=>{let e=setTimeout(()=>t(),500);return()=>clearTimeout(e)};"undefined"!=typeof requestIdleCallback&&(sa=t=>{let e=-1,i=setTimeout(()=>{e=requestIdleCallback(t,{timeout:400})},100);return()=>e<0?clearTimeout(i):cancelIdleCallback(e)});const oa="undefined"!=typeof navigator&&(null===(Kl=navigator.scheduling)||void 0===Kl?void 0:Kl.isInputPending)?()=>navigator.scheduling.isInputPending():null,ra=Zn.fromClass(class{constructor(t){this.view=t,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(t){let e=this.view.state.field(Yl.state).context;(e.updateViewport(t.view.viewport)||this.view.viewport.to>e.treeLen)&&this.scheduleWork(),(t.docChanged||t.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(e)}scheduleWork(){if(this.working)return;let{state:t}=this.view,e=t.field(Yl.state);e.tree==e.context.tree&&e.context.isDone(t.doc.length)||(this.working=sa(this.work))}work(t){this.working=null;let e=Date.now();if(this.chunkEnd<e&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=e+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:i,viewport:{to:n}}=this.view,s=i.field(Yl.state);if(s.tree==s.context.tree&&s.context.isDone(n+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,t&&!oa?Math.max(25,t.timeRemaining()-5):1e9),r=s.context.treeLen<n&&i.doc.length>n+1e3,l=s.context.work(()=>oa&&oa()||Date.now()>o,n+(r?0:1e5));this.chunkBudget-=Date.now()-e,(l||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:Yl.setState.of(new na(s.context))})),this.chunkBudget>0&&(!l||r)&&this.scheduleWork(),this.checkAsyncSchedule(s.context)}checkAsyncSchedule(t){t.scheduleOn&&(this.workScheduled++,t.scheduleOn.then(()=>this.scheduleWork()).catch(t=>Yn(this.view.state,t)).then(()=>this.workScheduled--),t.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),la=Bt.define({combine:t=>t.length?t[0]:null,enables:t=>[Yl.state,ra,nr.contentAttributes.compute([t],e=>{let i=e.facet(t);return i&&i.name?{"data-language":i.name}:{}})]});class aa{constructor(t,e=[]){this.language=t,this.support=e,this.extension=[t,e]}}class ha{constructor(t,e,i,n,s,o=void 0){this.name=t,this.alias=e,this.extensions=i,this.filename=n,this.loadFunc=s,this.support=o,this.loading=null}load(){return this.loading||(this.loading=this.loadFunc().then(t=>this.support=t,t=>{throw this.loading=null,t}))}static of(t){let{load:e,support:i}=t;if(!e){if(!i)throw new RangeError("Must pass either 'load' or 'support' to LanguageDescription.of");e=()=>Promise.resolve(i)}return new ha(t.name,(t.alias||[]).concat(t.name).map(t=>t.toLowerCase()),t.extensions||[],t.filename,e,i)}static matchFilename(t,e){for(let i of t)if(i.filename&&i.filename.test(e))return i;let i=/\.([^.]+)$/.exec(e);if(i)for(let e of t)if(e.extensions.indexOf(i[1])>-1)return e;return null}static matchLanguageName(t,e,i=!0){e=e.toLowerCase();for(let i of t)if(i.alias.some(t=>t==e))return i;if(i)for(let i of t)for(let t of i.alias){let n=e.indexOf(t);if(n>-1&&(t.length>2||!/\w/.test(e[n-1])&&!/\w/.test(e[n+t.length])))return i}return null}}const ca=Bt.define(),fa=Bt.define({combine:t=>{if(!t.length)return" ";let e=t[0];if(!e||/\S/.test(e)||Array.from(e).some(t=>t!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(t[0]));return e}});function da(t){let e=t.facet(fa);return 9==e.charCodeAt(0)?t.tabSize*e.length:e.length}function ua(t,e){let i="",n=t.tabSize,s=t.facet(fa)[0];if("\t"==s){for(;e>=n;)i+="\t",e-=n;s=" "}for(let t=0;t<e;t++)i+=s;return i}function pa(t,e){t instanceof xe&&(t=new ma(t));for(let i of t.state.facet(ca)){let n=i(t,e);if(void 0!==n)return n}let i=Ql(t.state);return i.length>=e?function(t,e,i){let n=e.resolveStack(i),s=e.resolveInner(i,-1).resolve(i,0).enterUnfinishedNodesBefore(i);if(s!=n.node){let t=[];for(let e=s;e&&!(e.from<n.node.from||e.to>n.node.to||e.from==n.node.from&&e.type==n.node.type);e=e.parent)t.push(e);for(let e=t.length-1;e>=0;e--)n={node:t[e],next:n}}return wa(n,t,i)}(t,i,e):null}class ma{constructor(t,e={}){this.state=t,this.options=e,this.unit=da(t)}lineAt(t,e=1){let i=this.state.doc.lineAt(t),{simulateBreak:n,simulateDoubleBreak:s}=this.options;return null!=n&&n>=i.from&&n<=i.to?s&&n==t?{text:"",from:t}:(e<0?n<t:n<=t)?{text:i.text.slice(n-i.from),from:n}:{text:i.text.slice(0,n-i.from),from:i.from}:i}textAfterPos(t,e=1){if(this.options.simulateDoubleBreak&&t==this.options.simulateBreak)return"";let{text:i,from:n}=this.lineAt(t,e);return i.slice(t-n,Math.min(i.length,t+100-n))}column(t,e=1){let{text:i,from:n}=this.lineAt(t,e),s=this.countColumn(i,t-n),o=this.options.overrideIndentation?this.options.overrideIndentation(n):-1;return o>-1&&(s+=o-this.countColumn(i,i.search(/\S|$/))),s}countColumn(t,e=t.length){return Ve(t,this.state.tabSize,e)}lineIndent(t,e=1){let{text:i,from:n}=this.lineAt(t,e),s=this.options.overrideIndentation;if(s){let t=s(n);if(t>-1)return t}return this.countColumn(i,i.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const ga=new o;function wa(t,e,i){for(let n=t;n;n=n.next){let t=va(n.node);if(t)return t(ya.create(e,i,n))}return 0}function va(t){let e=t.type.prop(ga);if(e)return e;let i,n=t.firstChild;if(n&&(i=n.type.prop(o.closedBy))){let e=t.lastChild,n=e&&i.indexOf(e.name)>-1;return t=>Sa(t,!0,1,void 0,n&&!function(t){return t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak}(t)?e.from:void 0)}return null==t.parent?ba:null}function ba(){return 0}class ya extends ma{constructor(t,e,i){super(t.state,t.options),this.base=t,this.pos=e,this.context=i}get node(){return this.context.node}static create(t,e,i){return new ya(t,e,i)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(t){let e=this.state.doc.lineAt(t.from);for(;;){let i=t.resolve(e.from);for(;i.parent&&i.parent.from==i.from;)i=i.parent;if(xa(i,t))break;e=this.state.doc.lineAt(i.from)}return this.lineIndent(e.from)}continue(){return wa(this.context.next,this.base,this.pos)}}function xa(t,e){for(let i=e;i;i=i.parent)if(t==i)return!0;return!1}function ka({closing:t,align:e=!0,units:i=1}){return n=>Sa(n,e,i,t)}function Sa(t,e,i,n,s){let o=t.textAfter,r=o.match(/^\s*/)[0].length,l=n&&o.slice(r,r+n.length)==n||s==t.pos+r,a=e?function(t){let e=t.node,i=e.childAfter(e.from),n=e.lastChild;if(!i)return null;let s=t.options.simulateBreak,o=t.state.doc.lineAt(i.from),r=null==s||s<=o.from?o.to:Math.min(o.to,s);for(let t=i.to;;){let s=e.childAfter(t);if(!s||s==n)return null;if(!s.type.isSkipped){if(s.from>=r)return null;let t=/^ */.exec(o.text.slice(i.to-o.from))[0].length;return{from:i.from,to:i.to+t}}t=s.to}}(t):null;return a?l?t.column(a.from):t.column(a.to):t.baseIndent+(l?0:t.unit*i)}const Ca=t=>t.baseIndent;function Aa({except:t,units:e=1}={}){return i=>{let n=t&&t.test(i.textAfter);return i.baseIndent+(n?0:e*i.unit)}}const Ma=Bt.define(),Ta=new o;function Oa(t){let e=t.firstChild,i=t.lastChild;return e&&e.to<i.from?{from:e.to,to:i.type.isError?t.to:i.from}:null}function Da(t){let e=t.lastChild;return e&&e.to==t.to&&e.type.isError}function La(t,e,i){for(let n of t.facet(Ma)){let s=n(t,e,i);if(s)return s}return function(t,e,i){let n=Ql(t);if(n.length<i)return null;let s=null;for(let o=n.resolveStack(i,1);o;o=o.next){let r=o.node;if(r.to<=i||r.from>i)continue;if(s&&r.from<e)break;let l=r.type.prop(Ta);if(l&&(r.to<n.length-50||n.length==t.doc.length||!Da(r))){let n=l(r,t);n&&n.from<=i&&n.from>=e&&n.to>i&&(s=n)}}return s}(t,e,i)}function Ea(t,e){let i=e.mapPos(t.from,1),n=e.mapPos(t.to,-1);return i>=n?void 0:{from:i,to:n}}const Pa=he.define({map:Ea}),Ba=he.define({map:Ea});function Ra(t){let e=[];for(let{head:i}of t.state.selection.ranges)e.some(t=>t.from<=i&&t.to>=i)||e.push(t.lineBlockAt(i));return e}const Na=Ft.define({create:()=>nn.none,update(t,e){e.isUserEvent("delete")&&e.changes.iterChangedRanges((e,i)=>t=Ia(t,e,i)),t=t.map(e.changes);for(let i of e.effects)if(i.is(Pa)&&!Ha(t,i.value.from,i.value.to)){let{preparePlaceholder:n}=e.state.facet(qa),s=n?nn.replace({widget:new Ua(n(e.state,i.value))}):$a;t=t.update({add:[s.range(i.value.from,i.value.to)]})}else i.is(Ba)&&(t=t.update({filter:(t,e)=>i.value.from!=t||i.value.to!=e,filterFrom:i.value.from,filterTo:i.value.to}));return e.selection&&(t=Ia(t,e.selection.main.head)),t},provide:t=>nr.decorations.from(t),toJSON(t,e){let i=[];return t.between(0,e.doc.length,(t,e)=>{i.push(t,e)}),i},fromJSON(t){if(!Array.isArray(t)||t.length%2)throw new RangeError("Invalid JSON for fold state");let e=[];for(let i=0;i<t.length;){let n=t[i++],s=t[i++];if("number"!=typeof n||"number"!=typeof s)throw new RangeError("Invalid JSON for fold state");e.push($a.range(n,s))}return nn.set(e,!0)}});function Ia(t,e,i=e){let n=!1;return t.between(e,i,(t,s)=>{t<i&&s>e&&(n=!0)}),n?t.update({filterFrom:e,filterTo:i,filter:(t,n)=>t>=i||n<=e}):t}function ja(t,e,i){var n;let s=null;return null===(n=t.field(Na,!1))||void 0===n||n.between(e,i,(t,e)=>{(!s||s.from>t)&&(s={from:t,to:e})}),s}function Ha(t,e,i){let n=!1;return t.between(e,e,(t,s)=>{t==e&&s==i&&(n=!0)}),n}function Va(t,e){return t.field(Na,!1)?e:e.concat(he.appendConfig.of(_a()))}function Fa(t,e,i=!0){let n=t.state.doc.lineAt(e.from).number,s=t.state.doc.lineAt(e.to).number;return nr.announce.of(`${t.state.phrase(i?"Folded lines":"Unfolded lines")} ${n} ${t.state.phrase("to")} ${s}.`)}const za=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:t=>{for(let e of Ra(t)){let i=La(t.state,e.from,e.to);if(i)return t.dispatch({effects:Va(t.state,[Pa.of(i),Fa(t,i)])}),!0}return!1}},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:t=>{if(!t.state.field(Na,!1))return!1;let e=[];for(let i of Ra(t)){let n=ja(t.state,i.from,i.to);n&&e.push(Ba.of(n),Fa(t,n,!1))}return e.length&&t.dispatch({effects:e}),e.length>0}},{key:"Ctrl-Alt-[",run:t=>{let{state:e}=t,i=[];for(let n=0;n<e.doc.length;){let s=t.lineBlockAt(n),o=La(e,s.from,s.to);o&&i.push(Pa.of(o)),n=(o?t.lineBlockAt(o.to):s).to+1}return i.length&&t.dispatch({effects:Va(t.state,i)}),!!i.length}},{key:"Ctrl-Alt-]",run:t=>{let e=t.state.field(Na,!1);if(!e||!e.size)return!1;let i=[];return e.between(0,t.state.doc.length,(t,e)=>{i.push(Ba.of({from:t,to:e}))}),t.dispatch({effects:i}),!0}}],Wa={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},qa=Bt.define({combine:t=>ke(t,Wa)});function _a(t){return[Na,Xa]}function Ka(t,e){let{state:i}=t,n=i.facet(qa),s=e=>{let i=t.lineBlockAt(t.posAtDOM(e.target)),n=ja(t.state,i.from,i.to);n&&t.dispatch({effects:Ba.of(n)}),e.preventDefault()};if(n.placeholderDOM)return n.placeholderDOM(t,s,e);let o=document.createElement("span");return o.textContent=n.placeholderText,o.setAttribute("aria-label",i.phrase("folded code")),o.title=i.phrase("unfold"),o.className="cm-foldPlaceholder",o.onclick=s,o}const $a=nn.replace({widget:new class extends tn{toDOM(t){return Ka(t,null)}}});class Ua extends tn{constructor(t){super(),this.value=t}eq(t){return this.value==t.value}toDOM(t){return Ka(t,this.value)}}const Ga={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class Ya extends Xr{constructor(t,e){super(),this.config=t,this.open=e}eq(t){return this.config==t.config&&this.open==t.open}toDOM(t){if(this.config.markerDOM)return this.config.markerDOM(this.open);let e=document.createElement("span");return e.textContent=this.open?this.config.openText:this.config.closedText,e.title=t.state.phrase(this.open?"Fold line":"Unfold line"),e}}function Ja(t={}){let e={...Ga,...t},i=new Ya(e,!0),n=new Ya(e,!1),s=Zn.fromClass(class{constructor(t){this.from=t.viewport.from,this.markers=this.buildMarkers(t)}update(t){(t.docChanged||t.viewportChanged||t.startState.facet(la)!=t.state.facet(la)||t.startState.field(Na,!1)!=t.state.field(Na,!1)||Ql(t.startState)!=Ql(t.state)||e.foldingChanged(t))&&(this.markers=this.buildMarkers(t.view))}buildMarkers(t){let e=new Oe;for(let s of t.viewportLineBlocks){let o=ja(t.state,s.from,s.to)?n:La(t.state,s.from,s.to)?i:null;o&&e.add(s.from,s.from,o)}return e.finish()}}),{domEventHandlers:o}=e;return[s,il({class:"cm-foldGutter",markers(t){var e;return(null===(e=t.plugin(s))||void 0===e?void 0:e.markers)||Te.empty},initialSpacer:()=>new Ya(e,!1),domEventHandlers:{...o,click:(t,e,i)=>{if(o.click&&o.click(t,e,i))return!0;let n=ja(t.state,e.from,e.to);if(n)return t.dispatch({effects:Ba.of(n)}),!0;let s=La(t.state,e.from,e.to);return!!s&&(t.dispatch({effects:Pa.of(s)}),!0)}}}),_a()]}const Xa=nr.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}});class Qa{constructor(t,e){let i;function n(t){let e=qe.newName();return(i||(i=Object.create(null)))["."+e]=t,e}this.specs=t;const s="string"==typeof e.all?e.all:e.all?n(e.all):void 0,o=e.scope;this.scope=o instanceof Yl?t=>t.prop($l)==o.data:o?t=>t==o:void 0,this.style=Ml(t.map(t=>({tag:t.tag,class:t.class||n(Object.assign({},t,{tag:null}))})),{all:s}).style,this.module=i?new qe(i):null,this.themeType=e.themeType}static define(t,e){return new Qa(t,e||{})}}const Za=Bt.define(),th=Bt.define({combine:t=>t.length?[t[0]]:null});function eh(t){let e=t.facet(Za);return e.length?e:t.facet(th)}function ih(t,e){let i,n=[sh];return t instanceof Qa&&(t.module&&n.push(nr.styleModule.of(t.module)),i=t.themeType),(null==e?void 0:e.fallback)?n.push(th.of(t)):i?n.push(Za.computeN([nr.darkTheme],e=>e.facet(nr.darkTheme)==("dark"==i)?[t]:[])):n.push(Za.of(t)),n}class nh{constructor(t){this.markCache=Object.create(null),this.tree=Ql(t.state),this.decorations=this.buildDeco(t,eh(t.state)),this.decoratedTo=t.viewport.to}update(t){let e=Ql(t.state),i=eh(t.state),n=i!=eh(t.startState),{viewport:s}=t.view,o=t.changes.mapPos(this.decoratedTo,1);e.length<s.to&&!n&&e.type==this.tree.type&&o>=s.to?(this.decorations=this.decorations.map(t.changes),this.decoratedTo=o):(e!=this.tree||t.viewportChanged||n)&&(this.tree=e,this.decorations=this.buildDeco(t.view,i),this.decoratedTo=s.to)}buildDeco(t,e){if(!e||!this.tree.length)return nn.none;let i=new Oe;for(let{from:n,to:s}of t.visibleRanges)Tl(this.tree,e,(t,e,n)=>{i.add(t,e,this.markCache[n]||(this.markCache[n]=nn.mark({class:n})))},n,s);return i.finish()}}const sh=$t.high(Zn.fromClass(nh,{decorations:t=>t.decorations})),oh=Qa.define([{tag:_l.meta,color:"#404740"},{tag:_l.link,textDecoration:"underline"},{tag:_l.heading,textDecoration:"underline",fontWeight:"bold"},{tag:_l.emphasis,fontStyle:"italic"},{tag:_l.strong,fontWeight:"bold"},{tag:_l.strikethrough,textDecoration:"line-through"},{tag:_l.keyword,color:"#708"},{tag:[_l.atom,_l.bool,_l.url,_l.contentSeparator,_l.labelName],color:"#219"},{tag:[_l.literal,_l.inserted],color:"#164"},{tag:[_l.string,_l.deleted],color:"#a11"},{tag:[_l.regexp,_l.escape,_l.special(_l.string)],color:"#e40"},{tag:_l.definition(_l.variableName),color:"#00f"},{tag:_l.local(_l.variableName),color:"#30a"},{tag:[_l.typeName,_l.namespace],color:"#085"},{tag:_l.className,color:"#167"},{tag:[_l.special(_l.variableName),_l.macroName],color:"#256"},{tag:_l.definition(_l.propertyName),color:"#00c"},{tag:_l.comment,color:"#940"},{tag:_l.invalid,color:"#f00"}]),rh=new o;function lh(t,e,i){let n=t.prop(e<0?o.openedBy:o.closedBy);if(n)return n;if(1==t.name.length){let n=i.indexOf(t.name);if(n>-1&&n%2==(e<0?1:0))return[i[n+e]]}return null}function ah(t){let e=t.type.prop(rh);return e?e(t.node):t}function hh(t,e,i,n={}){let s=n.maxScanDistance||1e4,o=n.brackets||"()[]{}",r=Ql(t),l=r.resolveInner(e,i);for(let n=l;n;n=n.parent){let s=lh(n.type,i,o);if(s&&n.from<n.to){let r=ah(n);if(r&&(i>0?e>=r.from&&e<r.to:e>r.from&&e<=r.to))return ch(t,e,i,n,r,s,o)}}return function(t,e,i,n,s,o,r){let l=i<0?t.sliceDoc(e-1,e):t.sliceDoc(e,e+1),a=r.indexOf(l);if(a<0||a%2==0!=i>0)return null;let h={from:i<0?e-1:e,to:i>0?e+1:e},c=t.doc.iterRange(e,i>0?t.doc.length:0),f=0;for(let t=0;!c.next().done&&t<=o;){let o=c.value;i<0&&(t+=o.length);let l=e+t*i;for(let t=i>0?0:o.length-1,e=i>0?o.length:-1;t!=e;t+=i){let e=r.indexOf(o[t]);if(!(e<0||n.resolveInner(l+t,1).type!=s))if(e%2==0==i>0)f++;else{if(1==f)return{start:h,end:{from:l+t,to:l+t+1},matched:e>>1==a>>1};f--}}i>0&&(t+=o.length)}return c.done?{start:h,matched:!1}:null}(t,e,i,r,l.type,s,o)}function ch(t,e,i,n,s,o,r){let l=n.parent,a={from:s.from,to:s.to},h=0,c=null==l?void 0:l.cursor();if(c&&(i<0?c.childBefore(n.from):c.childAfter(n.to)))do{if(i<0?c.to<=n.from:c.from>=n.to){if(0==h&&o.indexOf(c.type.name)>-1&&c.from<c.to){let t=ah(c);return{start:a,end:t?{from:t.from,to:t.to}:void 0,matched:!0}}if(lh(c.type,i,r))h++;else if(lh(c.type,-i,r)){if(0==h){let t=ah(c);return{start:a,end:t&&t.from<t.to?{from:t.from,to:t.to}:void 0,matched:!1}}h--}}}while(i<0?c.prevSibling():c.nextSibling());return{start:a,matched:!1}}function fh(t,e,i,n=0,s=0){null==e&&-1==(e=t.search(/[^\s\u00a0]/))&&(e=t.length);let o=s;for(let s=n;s<e;s++)9==t.charCodeAt(s)?o+=i-o%i:o++;return o}class dh{constructor(t,e,i,n){this.string=t,this.tabSize=e,this.indentUnit=i,this.overrideIndent=n,this.pos=0,this.start=0,this.lastColumnPos=0,this.lastColumnValue=0}eol(){return this.pos>=this.string.length}sol(){return 0==this.pos}peek(){return this.string.charAt(this.pos)||void 0}next(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)}eat(t){let e,i=this.string.charAt(this.pos);if(e="string"==typeof t?i==t:i&&(t instanceof RegExp?t.test(i):t(i)),e)return++this.pos,i}eatWhile(t){let e=this.pos;for(;this.eat(t););return this.pos>e}eatSpace(){let t=this.pos;for(;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>t}skipToEnd(){this.pos=this.string.length}skipTo(t){let e=this.string.indexOf(t,this.pos);if(e>-1)return this.pos=e,!0}backUp(t){this.pos-=t}column(){return this.lastColumnPos<this.start&&(this.lastColumnValue=fh(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue}indentation(){var t;return null!==(t=this.overrideIndent)&&void 0!==t?t:fh(this.string,null,this.tabSize)}match(t,e,i){if("string"==typeof t){let n=t=>i?t.toLowerCase():t;return n(this.string.substr(this.pos,t.length))==n(t)?(!1!==e&&(this.pos+=t.length),!0):null}{let i=this.string.slice(this.pos).match(t);return i&&i.index>0?null:(i&&!1!==e&&(this.pos+=i[0].length),i)}}current(){return this.string.slice(this.start,this.pos)}}function uh(t){if("object"!=typeof t)return t;let e={};for(let i in t){let n=t[i];e[i]=n instanceof Array?n.slice():n}return e}const ph=new WeakMap;class mh extends Yl{constructor(t){let e,i=Ul(t.languageData),n={name:(s=t).name||"",token:s.token,blankLine:s.blankLine||(()=>{}),startState:s.startState||(()=>!0),copyState:s.copyState||uh,indent:s.indent||(()=>null),languageData:s.languageData||{},tokenTable:s.tokenTable||yh,mergeTokens:!1!==s.mergeTokens};var s;super(i,new class extends B{createParse(t,i,n){return new vh(e,t,i,n)}},[],t.name),this.topNode=function(t,e){let i=a.define({id:xh.length,name:"Document",props:[$l.add(()=>t),ga.add(()=>t=>e.getIndent(t))],top:!0});return xh.push(i),i}(i,this),e=this,this.streamParser=n,this.stateAfter=new o({perNode:!0}),this.tokenTable=t.tokenTable?new Mh(n.tokenTable):Th}static define(t){return new mh(t)}getIndent(t){let e,{overrideIndentation:i}=t.options;i&&(e=ph.get(t.state),null!=e&&e<t.pos-1e4&&(e=void 0));let n,s,o=gh(this,t.node.tree,t.node.from,t.node.from,null!=e?e:t.pos);if(o?(s=o.state,n=o.pos+1):(s=this.streamParser.startState(t.unit),n=t.node.from),t.pos-n>1e4)return null;for(;n<t.pos;){let e=t.state.doc.lineAt(n),o=Math.min(t.pos,e.to);if(e.length){let n=i?i(e.from):-1,r=new dh(e.text,t.state.tabSize,t.unit,n<0?void 0:n);for(;r.pos<o-e.from;)bh(this.streamParser.token,r,s)}else this.streamParser.blankLine(s,t.unit);if(o==t.pos)break;n=e.to+1}let r=t.lineAt(t.pos);return i&&null==e&&ph.set(t.state,r.from),this.streamParser.indent(s,/^\s*(.*)/.exec(r.text)[1],t)}get allowsNesting(){return!1}}function gh(t,e,i,n,s){let o=i>=n&&i+e.length<=s&&e.prop(t.stateAfter);if(o)return{state:t.streamParser.copyState(o),pos:i+e.length};for(let o=e.children.length-1;o>=0;o--){let r=e.children[o],l=i+e.positions[o],a=r instanceof u&&l<s&&gh(t,r,l,n,s);if(a)return a}return null}function wh(t,e,i,n,s){if(s&&i<=0&&n>=e.length)return e;s||0!=i||e.type!=t.topNode||(s=!0);for(let o=e.children.length-1;o>=0;o--){let r,l=e.positions[o],a=e.children[o];if(l<n&&a instanceof u){if(!(r=wh(t,a,i-l,n-l,s)))break;return s?new u(e.type,e.children.slice(0,o).concat(r),e.positions.slice(0,o+1),l+r.length):r}}return null}class vh{constructor(t,e,i,n){this.lang=t,this.input=e,this.fragments=i,this.ranges=n,this.stoppedAt=null,this.chunks=[],this.chunkPos=[],this.chunk=[],this.chunkReused=void 0,this.rangeIndex=0,this.to=n[n.length-1].to;let s=ea.get(),o=n[0].from,{state:r,tree:l}=function(t,e,i,n,s){for(let s of e){let e,o=s.from+(s.openStart?25:0),r=s.to-(s.openEnd?25:0),l=o<=i&&r>i&&gh(t,s.tree,0-s.offset,i,r);if(l&&l.pos<=n&&(e=wh(t,s.tree,i+s.offset,l.pos+s.offset,!1)))return{state:l.state,tree:e}}return{state:t.streamParser.startState(s?da(s):4),tree:u.empty}}(t,i,o,this.to,null==s?void 0:s.state);this.state=r,this.parsedPos=this.chunkStart=o+l.length;for(let t=0;t<l.children.length;t++)this.chunks.push(l.children[t]),this.chunkPos.push(l.positions[t]);s&&this.parsedPos<s.viewport.from-1e5&&n.some(t=>t.from<=s.viewport.from&&t.to>=s.viewport.from)&&(this.state=this.lang.streamParser.startState(da(s.state)),s.skipUntilInView(this.parsedPos,s.viewport.from),this.parsedPos=s.viewport.from),this.moveRangeIndex()}advance(){let t=ea.get(),e=null==this.stoppedAt?this.to:Math.min(this.to,this.stoppedAt),i=Math.min(e,this.chunkStart+512);for(t&&(i=Math.min(i,t.viewport.to));this.parsedPos<i;)this.parseLine(t);return this.chunkStart<this.parsedPos&&this.finishChunk(),this.parsedPos>=e?this.finish():t&&this.parsedPos>=t.viewport.to?(t.skipUntilInView(this.parsedPos,e),this.finish()):null}stopAt(t){this.stoppedAt=t}lineAfter(t){let e=this.input.chunk(t);if(this.input.lineChunks)"\n"==e&&(e="");else{let t=e.indexOf("\n");t>-1&&(e=e.slice(0,t))}return t+e.length<=this.to?e:e.slice(0,this.to-t)}nextLine(){let t=this.parsedPos,e=this.lineAfter(t),i=t+e.length;for(let t=this.rangeIndex;;){let n=this.ranges[t].to;if(n>=i)break;if(e=e.slice(0,n-(i-e.length)),t++,t==this.ranges.length)break;let s=this.ranges[t].from,o=this.lineAfter(s);e+=o,i=s+o.length}return{line:e,end:i}}skipGapsTo(t,e,i){for(;;){let n=this.ranges[this.rangeIndex].to,s=t+e;if(i>0?n>s:n>=s)break;e+=this.ranges[++this.rangeIndex].from-n}return e}moveRangeIndex(){for(;this.ranges[this.rangeIndex].to<this.parsedPos;)this.rangeIndex++}emitToken(t,e,i,n){let s=4;if(this.ranges.length>1){e+=n=this.skipGapsTo(e,n,1);let t=this.chunk.length;i+=n=this.skipGapsTo(i,n,-1),s+=this.chunk.length-t}let o=this.chunk.length-4;return this.lang.streamParser.mergeTokens&&4==s&&o>=0&&this.chunk[o]==t&&this.chunk[o+2]==e?this.chunk[o+2]=i:this.chunk.push(t,e,i,s),n}parseLine(t){let{line:e,end:i}=this.nextLine(),n=0,{streamParser:s}=this.lang,o=new dh(e,t?t.state.tabSize:4,t?da(t.state):2);if(o.eol())s.blankLine(this.state,o.indentUnit);else for(;!o.eol();){let t=bh(s.token,o,this.state);if(t&&(n=this.emitToken(this.lang.tokenTable.resolve(t),this.parsedPos+o.start,this.parsedPos+o.pos,n)),o.start>1e4)break}this.parsedPos=i,this.moveRangeIndex(),this.parsedPos<this.to&&this.parsedPos++}finishChunk(){let t=u.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:kh,topID:0,maxBufferLength:512,reused:this.chunkReused});t=new u(t.type,t.children,t.positions,t.length,[[this.lang.stateAfter,this.lang.streamParser.copyState(this.state)]]),this.chunks.push(t),this.chunkPos.push(this.chunkStart-this.ranges[0].from),this.chunk=[],this.chunkReused=void 0,this.chunkStart=this.parsedPos}finish(){return new u(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}}function bh(t,e,i){e.start=e.pos;for(let n=0;n<10;n++){let n=t(e,i);if(e.pos>e.start)return n}throw new Error("Stream parser failed to advance stream.")}const yh=Object.create(null),xh=[a.none],kh=new h(xh),Sh=[],Ch=Object.create(null),Ah=Object.create(null);for(let[t,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])Ah[t]=Dh(yh,e);class Mh{constructor(t){this.extra=t,this.table=Object.assign(Object.create(null),Ah)}resolve(t){return t?this.table[t]||(this.table[t]=Dh(this.extra,t)):0}}const Th=new Mh(yh);function Oh(t,e){Sh.indexOf(t)>-1||(Sh.push(t),console.warn(e))}function Dh(t,e){let i=[];for(let n of e.split(" ")){let e=[];for(let i of n.split(".")){let n=t[i]||_l[i];n?"function"==typeof n?e.length?e=e.map(n):Oh(i,`Modifier ${i} used at start of tag`):e.length?Oh(i,`Tag ${i} used as modifier`):e=Array.isArray(n)?n:[n]:Oh(i,`Unknown highlighting tag ${i}`)}for(let t of e)i.push(t)}if(!i.length)return 0;let n=e.replace(/ /g,"_"),s=n+" "+i.map(t=>t.id),o=Ch[s];if(o)return o.id;let r=Ch[s]=a.define({id:xh.length,name:n,props:[Sl({[n]:i})]});return xh.push(r),r.id}
|
|
91
|
+
import{t}from"./throttle-Bam9Y9Iz.js";import{_ as e}from"./radio-group-manager-BpBQjS73.js";const i=1024;let n=0,s=class{constructor(t,e){this.from=t,this.to=e}};class o{constructor(t={}){this.id=n++,this.perNode=!!t.perNode,this.deserialize=t.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=t.combine||null}add(t){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return"function"!=typeof t&&(t=a.match(t)),e=>{let i=t(e);return void 0===i?null:[this,i]}}}o.closedBy=new o({deserialize:t=>t.split(" ")}),o.openedBy=new o({deserialize:t=>t.split(" ")}),o.group=new o({deserialize:t=>t.split(" ")}),o.isolate=new o({deserialize:t=>{if(t&&"rtl"!=t&&"ltr"!=t&&"auto"!=t)throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}}),o.contextHash=new o({perNode:!0}),o.lookAhead=new o({perNode:!0}),o.mounted=new o({perNode:!0});class r{constructor(t,e,i){this.tree=t,this.overlay=e,this.parser=i}static get(t){return t&&t.props&&t.props[o.mounted.id]}}const l=Object.create(null);class a{constructor(t,e,i,n=0){this.name=t,this.props=e,this.id=i,this.flags=n}static define(t){let e=t.props&&t.props.length?Object.create(null):l,i=(t.top?1:0)|(t.skipped?2:0)|(t.error?4:0)|(null==t.name?8:0),n=new a(t.name||"",e,t.id,i);if(t.props)for(let i of t.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");e[i[0].id]=i[1]}return n}prop(t){return this.props[t.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(t){if("string"==typeof t){if(this.name==t)return!0;let e=this.prop(o.group);return!!e&&e.indexOf(t)>-1}return this.id==t}static match(t){let e=Object.create(null);for(let i in t)for(let n of i.split(" "))e[n]=t[i];return t=>{for(let i=t.prop(o.group),n=-1;n<(i?i.length:0);n++){let s=e[n<0?t.name:i[n]];if(s)return s}}}}a.none=new a("",Object.create(null),0,8);class h{constructor(t){this.types=t;for(let e=0;e<t.length;e++)if(t[e].id!=e)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...t){let e=[];for(let i of this.types){let n=null;for(let e of t){let t=e(i);if(t){n||(n=Object.assign({},i.props));let e=t[1],s=t[0];s.combine&&s.id in n&&(e=s.combine(n[s.id],e)),n[s.id]=e}}e.push(n?new a(i.name,n,i.id,i.flags):i)}return new h(e)}}const c=new WeakMap,f=new WeakMap;var d;!function(t){t[t.ExcludeBuffers=1]="ExcludeBuffers",t[t.IncludeAnonymous=2]="IncludeAnonymous",t[t.IgnoreMounts=4]="IgnoreMounts",t[t.IgnoreOverlays=8]="IgnoreOverlays"}(d||(d={}));class u{constructor(t,e,i,n,s){if(this.type=t,this.children=e,this.positions=i,this.length=n,this.props=null,s&&s.length){this.props=Object.create(null);for(let[t,e]of s)this.props["number"==typeof t?t:t.id]=e}}toString(){let t=r.get(this);if(t&&!t.overlay)return t.tree.toString();let e="";for(let t of this.children){let i=t.toString();i&&(e&&(e+=","),e+=i)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(e.length?"("+e+")":""):e}cursor(t=0){return new M(this.topNode,t)}cursorAt(t,e=0,i=0){let n=c.get(this)||this.topNode,s=new M(n);return s.moveTo(t,e),c.set(this,s._tree),s}get topNode(){return new b(this,0,0,null)}resolve(t,e=0){let i=w(c.get(this)||this.topNode,t,e,!1);return c.set(this,i),i}resolveInner(t,e=0){let i=w(f.get(this)||this.topNode,t,e,!0);return f.set(this,i),i}resolveStack(t,e=0){return function(t,e,i){let n=t.resolveInner(e,i),s=null;for(let t=n instanceof b?n:n.context.parent;t;t=t.parent)if(t.index<0){let o=t.parent;(s||(s=[n])).push(o.resolve(e,i)),t=o}else{let o=r.get(t.tree);if(o&&o.overlay&&o.overlay[0].from<=e&&o.overlay[o.overlay.length-1].to>=e){let r=new b(o.tree,o.overlay[0].from+t.from,-1,t);(s||(s=[n])).push(w(r,e,i,!1))}}return s?C(s):n}(this,t,e)}iterate(t){let{enter:e,leave:i,from:n=0,to:s=this.length}=t,o=t.mode||0,r=(o&d.IncludeAnonymous)>0;for(let t=this.cursor(o|d.IncludeAnonymous);;){let o=!1;if(t.from<=s&&t.to>=n&&(!r&&t.type.isAnonymous||!1!==e(t))){if(t.firstChild())continue;o=!0}for(;o&&i&&(r||!t.type.isAnonymous)&&i(t),!t.nextSibling();){if(!t.parent())return;o=!0}}}prop(t){return t.perNode?this.props?this.props[t.id]:void 0:this.type.prop(t)}get propValues(){let t=[];if(this.props)for(let e in this.props)t.push([+e,this.props[e]]);return t}balance(t={}){return this.children.length<=8?this:L(a.none,this.children,this.positions,0,this.children.length,0,this.length,(t,e,i)=>new u(this.type,t,e,i,this.propValues),t.makeTree||((t,e,i)=>new u(a.none,t,e,i)))}static build(t){return function(t){var e;let{buffer:n,nodeSet:s,maxBufferLength:r=i,reused:l=[],minRepeatType:a=s.types.length}=t,h=Array.isArray(n)?new p(n,n.length):n,c=s.types,f=0,d=0;function g(t,e,i,n,o,u){let{id:p,start:S,end:C,size:A}=h,M=d,T=f;if(A<0){if(h.next(),-1==A){let e=l[p];return i.push(e),void n.push(S-t)}if(-3==A)return void(f=p);if(-4==A)return void(d=p);throw new RangeError(`Unrecognized record size: ${A}`)}let O,D,E=c[p],P=S-t;if(C-S<=r&&(D=x(h.pos-e,o))){let e=new Uint16Array(D.size-D.skip),i=h.pos-D.size,n=e.length;for(;h.pos>i;)n=k(D.start,e,n);O=new m(e,C-D.start,s),P=D.start-t}else{let t=h.pos-A;h.next();let e=[],i=[],n=p>=a?p:-1,s=0,o=C;for(;h.pos>t;)n>=0&&h.id==n&&h.size>=0?(h.end<=o-r&&(b(e,i,S,s,h.end,o,n,M,T),s=e.length,o=h.end),h.next()):u>2500?w(S,t,e,i):g(S,t,e,i,n,u+1);if(n>=0&&s>0&&s<e.length&&b(e,i,S,s,S,o,n,M,T),e.reverse(),i.reverse(),n>-1&&s>0){let t=v(E,T);O=L(E,e,i,0,e.length,0,C-S,t,t)}else O=y(E,e,i,C-S,M-C,T)}i.push(O),n.push(P)}function w(t,e,i,n){let o=[],l=0,a=-1;for(;h.pos>e;){let{id:t,start:e,end:i,size:n}=h;if(n>4)h.next();else{if(a>-1&&e<a)break;a<0&&(a=i-r),o.push(t,e,i),l++,h.next()}}if(l){let e=new Uint16Array(4*l),r=o[o.length-2];for(let t=o.length-3,i=0;t>=0;t-=3)e[i++]=o[t],e[i++]=o[t+1]-r,e[i++]=o[t+2]-r,e[i++]=i;i.push(new m(e,o[2]-r,s)),n.push(r-t)}}function v(t,e){return(i,n,s)=>{let r,l,a=0,h=i.length-1;if(h>=0&&(r=i[h])instanceof u){if(!h&&r.type==t&&r.length==s)return r;(l=r.prop(o.lookAhead))&&(a=n[h]+r.length+l)}return y(t,i,n,s,a,e)}}function b(t,e,i,n,o,r,l,a,h){let c=[],f=[];for(;t.length>n;)c.push(t.pop()),f.push(e.pop()+i-o);t.push(y(s.types[l],c,f,r-o,a-r,h)),e.push(o-i)}function y(t,e,i,n,s,r,l){if(r){let t=[o.contextHash,r];l=l?[t].concat(l):[t]}if(s>25){let t=[o.lookAhead,s];l=l?[t].concat(l):[t]}return new u(t,e,i,n,l)}function x(t,e){let i=h.fork(),n=0,s=0,o=0,l=i.end-r,c={size:0,start:0,skip:0};t:for(let r=i.pos-t;i.pos>r;){let t=i.size;if(i.id==e&&t>=0){c.size=n,c.start=s,c.skip=o,o+=4,n+=4,i.next();continue}let h=i.pos-t;if(t<0||h<r||i.start<l)break;let f=i.id>=a?4:0,d=i.start;for(i.next();i.pos>h;){if(i.size<0){if(-3!=i.size&&-4!=i.size)break t;f+=4}else i.id>=a&&(f+=4);i.next()}s=d,n+=t,o+=f}return(e<0||n==t)&&(c.size=n,c.start=s,c.skip=o),c.size>4?c:void 0}function k(t,e,i){let{id:n,start:s,end:o,size:r}=h;if(h.next(),r>=0&&n<a){let l=i;if(r>4){let n=h.pos-(r-4);for(;h.pos>n;)i=k(t,e,i)}e[--i]=l,e[--i]=o-t,e[--i]=s-t,e[--i]=n}else-3==r?f=n:-4==r&&(d=n);return i}let S=[],C=[];for(;h.pos>0;)g(t.start||0,t.bufferStart||0,S,C,-1,0);let A=null!==(e=t.length)&&void 0!==e?e:S.length?C[0]+S[0].length:0;return new u(c[t.topID],S.reverse(),C.reverse(),A)}(t)}}u.empty=new u(a.none,[],[],0);class p{constructor(t,e){this.buffer=t,this.index=e}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 p(this.buffer,this.index)}}class m{constructor(t,e,i){this.buffer=t,this.length=e,this.set=i}get type(){return a.none}toString(){let t=[];for(let e=0;e<this.buffer.length;)t.push(this.childString(e)),e=this.buffer[e+3];return t.join(",")}childString(t){let e=this.buffer[t],i=this.buffer[t+3],n=this.set.types[e],s=n.name;if(/\W/.test(s)&&!n.isError&&(s=JSON.stringify(s)),i==(t+=4))return s;let o=[];for(;t<i;)o.push(this.childString(t)),t=this.buffer[t+3];return s+"("+o.join(",")+")"}findChild(t,e,i,n,s){let{buffer:o}=this,r=-1;for(let l=t;l!=e&&!(g(s,n,o[l+1],o[l+2])&&(r=l,i>0));l=o[l+3]);return r}slice(t,e,i){let n=this.buffer,s=new Uint16Array(e-t),o=0;for(let r=t,l=0;r<e;){s[l++]=n[r++],s[l++]=n[r++]-i;let e=s[l++]=n[r++]-i;s[l++]=n[r++]-t,o=Math.max(o,e)}return new m(s,o,this.set)}}function g(t,e,i,n){switch(t){case-2:return i<e;case-1:return n>=e&&i<e;case 0:return i<e&&n>e;case 1:return i<=e&&n>e;case 2:return n>e;case 4:return!0}}function w(t,e,i,n){for(var s;t.from==t.to||(i<1?t.from>=e:t.from>e)||(i>-1?t.to<=e:t.to<e);){let e=!n&&t instanceof b&&t.index<0?null:t.parent;if(!e)return t;t=e}let o=n?0:d.IgnoreOverlays;if(n)for(let n=t,r=n.parent;r;n=r,r=n.parent)n instanceof b&&n.index<0&&(null===(s=r.enter(e,i,o))||void 0===s?void 0:s.from)!=n.from&&(t=r);for(;;){let n=t.enter(e,i,o);if(!n)return t;t=n}}class v{cursor(t=0){return new M(this,t)}getChild(t,e=null,i=null){let n=y(this,t,e,i);return n.length?n[0]:null}getChildren(t,e=null,i=null){return y(this,t,e,i)}resolve(t,e=0){return w(this,t,e,!1)}resolveInner(t,e=0){return w(this,t,e,!0)}matchContext(t){return x(this.parent,t)}enterUnfinishedNodesBefore(t){let e=this.childBefore(t),i=this;for(;e;){let t=e.lastChild;if(!t||t.to!=e.to)break;t.type.isError&&t.from==t.to?(i=e,e=t.prevSibling):e=t}return i}get node(){return this}get next(){return this.parent}}class b extends v{constructor(t,e,i,n){super(),this._tree=t,this.from=e,this.index=i,this._parent=n}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(t,e,i,n,s=0){for(let o=this;;){for(let{children:l,positions:a}=o._tree,h=e>0?l.length:-1;t!=h;t+=e){let h=l[t],c=a[t]+o.from;if(g(n,i,c,c+h.length))if(h instanceof m){if(s&d.ExcludeBuffers)continue;let r=h.findChild(0,h.buffer.length,e,i-c,n);if(r>-1)return new S(new k(o,h,t,c),null,r)}else if(s&d.IncludeAnonymous||!h.type.isAnonymous||T(h)){let l;if(!(s&d.IgnoreMounts)&&(l=r.get(h))&&!l.overlay)return new b(l.tree,c,t,o);let a=new b(h,c,t,o);return s&d.IncludeAnonymous||!a.type.isAnonymous?a:a.nextChild(e<0?h.children.length-1:0,e,i,n)}}if(s&d.IncludeAnonymous||!o.type.isAnonymous)return null;if(t=o.index>=0?o.index+e:e<0?-1:o._parent._tree.children.length,o=o._parent,!o)return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(t){return this.nextChild(0,1,t,2)}childBefore(t){return this.nextChild(this._tree.children.length-1,-1,t,-2)}prop(t){return this._tree.prop(t)}enter(t,e,i=0){let n;if(!(i&d.IgnoreOverlays)&&(n=r.get(this._tree))&&n.overlay){let i=t-this.from;for(let{from:t,to:s}of n.overlay)if((e>0?t<=i:t<i)&&(e<0?s>=i:s>i))return new b(n.tree,n.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,e,i)}nextSignificantParent(){let t=this;for(;t.type.isAnonymous&&t._parent;)t=t._parent;return t}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 tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function y(t,e,i,n){let s=t.cursor(),o=[];if(!s.firstChild())return o;if(null!=i)for(let t=!1;!t;)if(t=s.type.is(i),!s.nextSibling())return o;for(;;){if(null!=n&&s.type.is(n))return o;if(s.type.is(e)&&o.push(s.node),!s.nextSibling())return null==n?o:[]}}function x(t,e,i=e.length-1){for(let n=t;i>=0;n=n.parent){if(!n)return!1;if(!n.type.isAnonymous){if(e[i]&&e[i]!=n.name)return!1;i--}}return!0}class k{constructor(t,e,i,n){this.parent=t,this.buffer=e,this.index=i,this.start=n}}class S extends v{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]}constructor(t,e,i){super(),this.context=t,this._parent=e,this.index=i,this.type=t.buffer.set.types[t.buffer.buffer[i]]}child(t,e,i){let{buffer:n}=this.context,s=n.findChild(this.index+4,n.buffer[this.index+3],t,e-this.context.start,i);return s<0?null:new S(this.context,this,s)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(t){return this.child(1,t,2)}childBefore(t){return this.child(-1,t,-2)}prop(t){return this.type.prop(t)}enter(t,e,i=0){if(i&d.ExcludeBuffers)return null;let{buffer:n}=this.context,s=n.findChild(this.index+4,n.buffer[this.index+3],e>0?1:-1,t-this.context.start,e);return s<0?null:new S(this.context,this,s)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(t){return this._parent?null:this.context.parent.nextChild(this.context.index+t,t,0,4)}get nextSibling(){let{buffer:t}=this.context,e=t.buffer[this.index+3];return e<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length)?new S(this.context,this._parent,e):this.externalSibling(1)}get prevSibling(){let{buffer:t}=this.context,e=this._parent?this._parent.index+4:0;return this.index==e?this.externalSibling(-1):new S(this.context,this._parent,t.findChild(e,this.index,-1,0,4))}get tree(){return null}toTree(){let t=[],e=[],{buffer:i}=this.context,n=this.index+4,s=i.buffer[this.index+3];if(s>n){let o=i.buffer[this.index+1];t.push(i.slice(n,s,o)),e.push(0)}return new u(this.type,t,e,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function C(t){if(!t.length)return null;let e=0,i=t[0];for(let n=1;n<t.length;n++){let s=t[n];(s.from>i.from||s.to<i.to)&&(i=s,e=n)}let n=i instanceof b&&i.index<0?null:i.parent,s=t.slice();return n?s[e]=n:s.splice(e,1),new A(s,i)}class A{constructor(t,e){this.heads=t,this.node=e}get next(){return C(this.heads)}}class M{get name(){return this.type.name}constructor(t,e=0){if(this.mode=e,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,t instanceof b)this.yieldNode(t);else{this._tree=t.context.parent,this.buffer=t.context;for(let e=t._parent;e;e=e._parent)this.stack.unshift(e.index);this.bufferNode=t,this.yieldBuf(t.index)}}yieldNode(t){return!!t&&(this._tree=t,this.type=t.type,this.from=t.from,this.to=t.to,!0)}yieldBuf(t,e){this.index=t;let{start:i,buffer:n}=this.buffer;return this.type=e||n.set.types[n.buffer[t]],this.from=i+n.buffer[t+1],this.to=i+n.buffer[t+2],!0}yield(t){return!!t&&(t instanceof b?(this.buffer=null,this.yieldNode(t)):(this.buffer=t.context,this.yieldBuf(t.index,t.type)))}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(t,e,i){if(!this.buffer)return this.yield(this._tree.nextChild(t<0?this._tree._tree.children.length-1:0,t,e,i,this.mode));let{buffer:n}=this.buffer,s=n.findChild(this.index+4,n.buffer[this.index+3],t,e-this.buffer.start,i);return!(s<0)&&(this.stack.push(this.index),this.yieldBuf(s))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(t){return this.enterChild(1,t,2)}childBefore(t){return this.enterChild(-1,t,-2)}enter(t,e,i=this.mode){return this.buffer?!(i&d.ExcludeBuffers)&&this.enterChild(1,t,e):this.yield(this._tree.enter(t,e,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&d.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let t=this.mode&d.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(t)}sibling(t){if(!this.buffer)return!!this._tree._parent&&this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+t,t,0,4,this.mode));let{buffer:e}=this.buffer,i=this.stack.length-1;if(t<0){let t=i<0?0:this.stack[i]+4;if(this.index!=t)return this.yieldBuf(e.findChild(t,this.index,-1,0,4))}else{let t=e.buffer[this.index+3];if(t<(i<0?e.buffer.length:e.buffer[this.stack[i]+3]))return this.yieldBuf(t)}return i<0&&this.yield(this.buffer.parent.nextChild(this.buffer.index+t,t,0,4,this.mode))}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(t){let e,i,{buffer:n}=this;if(n){if(t>0){if(this.index<n.buffer.buffer.length)return!1}else for(let t=0;t<this.index;t++)if(n.buffer.buffer[t+3]<this.index)return!1;({index:e,parent:i}=n)}else({index:e,_parent:i}=this._tree);for(;i;({index:e,_parent:i}=i))if(e>-1)for(let n=e+t,s=t<0?-1:i._tree.children.length;n!=s;n+=t){let t=i._tree.children[n];if(this.mode&d.IncludeAnonymous||t instanceof m||!t.type.isAnonymous||T(t))return!1}return!0}move(t,e){if(e&&this.enterChild(t,0,4))return!0;for(;;){if(this.sibling(t))return!0;if(this.atLastNode(t)||!this.parent())return!1}}next(t=!0){return this.move(1,t)}prev(t=!0){return this.move(-1,t)}moveTo(t,e=0){for(;(this.from==this.to||(e<1?this.from>=t:this.from>t)||(e>-1?this.to<=t:this.to<t))&&this.parent(););for(;this.enterChild(1,t,e););return this}get node(){if(!this.buffer)return this._tree;let t=this.bufferNode,e=null,i=0;if(t&&t.context==this.buffer)t:for(let n=this.index,s=this.stack.length;s>=0;){for(let o=t;o;o=o._parent)if(o.index==n){if(n==this.index)return o;e=o,i=s+1;break t}n=this.stack[--s]}for(let t=i;t<this.stack.length;t++)e=new S(this.buffer,e,this.stack[t]);return this.bufferNode=new S(this.buffer,e,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(t,e){for(let i=0;;){let n=!1;if(this.type.isAnonymous||!1!==t(this)){if(this.firstChild()){i++;continue}this.type.isAnonymous||(n=!0)}for(;;){if(n&&e&&e(this),n=this.type.isAnonymous,!i)return;if(this.nextSibling())break;this.parent(),i--,n=!0}}}matchContext(t){if(!this.buffer)return x(this.node.parent,t);let{buffer:e}=this.buffer,{types:i}=e.set;for(let n=t.length-1,s=this.stack.length-1;n>=0;s--){if(s<0)return x(this._tree,t,n);let o=i[e.buffer[this.stack[s]]];if(!o.isAnonymous){if(t[n]&&t[n]!=o.name)return!1;n--}}return!0}}function T(t){return t.children.some(t=>t instanceof m||!t.type.isAnonymous||T(t))}const O=new WeakMap;function D(t,e){if(!t.isAnonymous||e instanceof m||e.type!=t)return 1;let i=O.get(e);if(null==i){i=1;for(let n of e.children){if(n.type!=t||!(n instanceof u)){i=1;break}i+=D(t,n)}O.set(e,i)}return i}function L(t,e,i,n,s,o,r,l,a){let h=0;for(let i=n;i<s;i++)h+=D(t,e[i]);let c=Math.ceil(1.5*h/8),f=[],d=[];return function e(i,n,s,r,l){for(let h=s;h<r;){let s=h,u=n[h],p=D(t,i[h]);for(h++;h<r;h++){let e=D(t,i[h]);if(p+e>=c)break;p+=e}if(h==s+1){if(p>c){let t=i[s];e(t.children,t.positions,0,t.children.length,n[s]+l);continue}f.push(i[s])}else{let e=n[h-1]+i[h-1].length-u;f.push(L(t,i,n,s,h,u,e,null,a))}d.push(u+l-o)}}(e,i,n,s,0),(l||a)(f,d,r)}class E{constructor(){this.map=new WeakMap}setBuffer(t,e,i){let n=this.map.get(t);n||this.map.set(t,n=new Map),n.set(e,i)}getBuffer(t,e){let i=this.map.get(t);return i&&i.get(e)}set(t,e){t instanceof S?this.setBuffer(t.context.buffer,t.index,e):t instanceof b&&this.map.set(t.tree,e)}get(t){return t instanceof S?this.getBuffer(t.context.buffer,t.index):t instanceof b?this.map.get(t.tree):void 0}cursorSet(t,e){t.buffer?this.setBuffer(t.buffer.buffer,t.index,e):this.map.set(t.tree,e)}cursorGet(t){return t.buffer?this.getBuffer(t.buffer.buffer,t.index):this.map.get(t.tree)}}class P{constructor(t,e,i,n,s=!1,o=!1){this.from=t,this.to=e,this.tree=i,this.offset=n,this.open=(s?1:0)|(o?2:0)}get openStart(){return(1&this.open)>0}get openEnd(){return(2&this.open)>0}static addTree(t,e=[],i=!1){let n=[new P(0,t.length,t,0,!1,i)];for(let i of e)i.to>t.length&&n.push(i);return n}static applyChanges(t,e,i=128){if(!e.length)return t;let n=[],s=1,o=t.length?t[0]:null;for(let r=0,l=0,a=0;;r++){let h=r<e.length?e[r]:null,c=h?h.fromA:1e9;if(c-l>=i)for(;o&&o.from<c;){let e=o;if(l>=e.from||c<=e.to||a){let t=Math.max(e.from,l)-a,i=Math.min(e.to,c)-a;e=t>=i?null:new P(t,i,e.tree,e.offset+a,r>0,!!h)}if(e&&n.push(e),o.to>c)break;o=s<t.length?t[s++]:null}if(!h)break;l=h.toA,a=h.toA-h.toB}return n}}class B{startParse(t,e,i){return"string"==typeof t&&(t=new R(t)),i=i?i.length?i.map(t=>new s(t.from,t.to)):[new s(0,0)]:[new s(0,t.length)],this.createParse(t,e||[],i)}parse(t,e,i){let n=this.startParse(t,e,i);for(;;){let t=n.advance();if(t)return t}}}class R{constructor(t){this.string=t}get length(){return this.string.length}chunk(t){return this.string.slice(t)}get lineChunks(){return!1}read(t,e){return this.string.slice(t,e)}}function N(t){return(e,i,n,s)=>new F(e,t,i,n,s)}class I{constructor(t,e,i,n,s){this.parser=t,this.parse=e,this.overlay=i,this.target=n,this.from=s}}function j(t){if(!t.length||t.some(t=>t.from>=t.to))throw new RangeError("Invalid inner parse ranges given: "+JSON.stringify(t))}class H{constructor(t,e,i,n,s,o,r){this.parser=t,this.predicate=e,this.mounts=i,this.index=n,this.start=s,this.target=o,this.prev=r,this.depth=0,this.ranges=[]}}const V=new o({perNode:!0});class F{constructor(t,e,i,n,s){this.nest=e,this.input=i,this.fragments=n,this.ranges=s,this.inner=[],this.innerDone=0,this.baseTree=null,this.stoppedAt=null,this.baseParse=t}advance(){if(this.baseParse){let t=this.baseParse.advance();if(!t)return null;if(this.baseParse=null,this.baseTree=t,this.startInner(),null!=this.stoppedAt)for(let t of this.inner)t.parse.stopAt(this.stoppedAt)}if(this.innerDone==this.inner.length){let t=this.baseTree;return null!=this.stoppedAt&&(t=new u(t.type,t.children,t.positions,t.length,t.propValues.concat([[V,this.stoppedAt]]))),t}let t=this.inner[this.innerDone],e=t.parse.advance();if(e){this.innerDone++;let i=Object.assign(Object.create(null),t.target.props);i[o.mounted.id]=new r(e,t.overlay,t.parser),t.target.props=i}return null}get parsedPos(){if(this.baseParse)return 0;let t=this.input.length;for(let e=this.innerDone;e<this.inner.length;e++)this.inner[e].from<t&&(t=Math.min(t,this.inner[e].parse.parsedPos));return t}stopAt(t){if(this.stoppedAt=t,this.baseParse)this.baseParse.stopAt(t);else for(let e=this.innerDone;e<this.inner.length;e++)this.inner[e].parse.stopAt(t)}startInner(){let t=new K(this.fragments),e=null,i=null,n=new M(new b(this.baseTree,this.ranges[0].from,0,null),d.IncludeAnonymous|d.IgnoreMounts);t:for(let o,r;;){let l,a=!0;if(null!=this.stoppedAt&&n.from>=this.stoppedAt)a=!1;else if(t.hasNode(n)){if(e){let t=e.mounts.find(t=>t.frag.from<=n.from&&t.frag.to>=n.to&&t.mount.overlay);if(t)for(let i of t.mount.overlay){let s=i.from+t.pos,o=i.to+t.pos;s>=n.from&&o<=n.to&&!e.ranges.some(t=>t.from<o&&t.to>s)&&e.ranges.push({from:s,to:o})}}a=!1}else if(i&&(r=z(i.ranges,n.from,n.to)))a=2!=r;else if(!n.type.isAnonymous&&(o=this.nest(n,this.input))&&(n.from<n.to||!o.overlay)){n.tree||(q(n),e&&e.depth++,i&&i.depth++);let r=t.findMounts(n.from,o.parser);if("function"==typeof o.overlay)e=new H(o.parser,o.overlay,r,this.inner.length,n.from,n.tree,e);else{let t=$(this.ranges,o.overlay||(n.from<n.to?[new s(n.from,n.to)]:[]));t.length&&j(t),!t.length&&o.overlay||this.inner.push(new I(o.parser,t.length?o.parser.startParse(this.input,G(r,t),t):o.parser.startParse(""),o.overlay?o.overlay.map(t=>new s(t.from-n.from,t.to-n.from)):null,n.tree,t.length?t[0].from:n.from)),o.overlay?t.length&&(i={ranges:t,depth:0,prev:i}):a=!1}}else if(e&&(l=e.predicate(n))&&(!0===l&&(l=new s(n.from,n.to)),l.from<l.to)){let t=e.ranges.length-1;t>=0&&e.ranges[t].to==l.from?e.ranges[t]={from:e.ranges[t].from,to:l.to}:e.ranges.push(l)}if(a&&n.firstChild())e&&e.depth++,i&&i.depth++;else for(;!n.nextSibling();){if(!n.parent())break t;if(e&&! --e.depth){let t=$(this.ranges,e.ranges);t.length&&(j(t),this.inner.splice(e.index,0,new I(e.parser,e.parser.startParse(this.input,G(e.mounts,t),t),e.ranges.map(t=>new s(t.from-e.start,t.to-e.start)),e.target,t[0].from))),e=e.prev}i&&! --i.depth&&(i=i.prev)}}}}function z(t,e,i){for(let n of t){if(n.from>=i)break;if(n.to>e)return n.from<=e&&n.to>=i?2:1}return 0}function W(t,e,i,n,s,o){if(e<i){let r=t.buffer[e+1];n.push(t.slice(e,i,r)),s.push(r-o)}}function q(t){let{node:e}=t,i=[],n=e.context.buffer;do{i.push(t.index),t.parent()}while(!t.tree);let s=t.tree,o=s.children.indexOf(n),r=s.children[o],l=r.buffer,h=[o];s.children[o]=function t(n,s,o,a,c,f){let d=i[f],p=[],m=[];W(r,n,d,p,m,a);let g=l[d+1],w=l[d+2];h.push(p.length);let v=f?t(d+4,l[d+3],r.set.types[l[d]],g,w-g,f-1):e.toTree();return p.push(v),m.push(g-a),W(r,l[d+3],s,p,m,a),new u(o,p,m,c)}(0,l.length,a.none,0,r.length,i.length-1);for(let e of h){let i=t.tree.children[e],n=t.tree.positions[e];t.yield(new b(i,n+t.from,e,t._tree))}}class _{constructor(t,e){this.offset=e,this.done=!1,this.cursor=t.cursor(d.IncludeAnonymous|d.IgnoreMounts)}moveTo(t){let{cursor:e}=this,i=t-this.offset;for(;!this.done&&e.from<i;)e.to>=t&&e.enter(i,1,d.IgnoreOverlays|d.ExcludeBuffers)||e.next(!1)||(this.done=!0)}hasNode(t){if(this.moveTo(t.from),!this.done&&this.cursor.from+this.offset==t.from&&this.cursor.tree)for(let e=this.cursor.tree;;){if(e==t.tree)return!0;if(!(e.children.length&&0==e.positions[0]&&e.children[0]instanceof u))break;e=e.children[0]}return!1}}class K{constructor(t){var e;if(this.fragments=t,this.curTo=0,this.fragI=0,t.length){let i=this.curFrag=t[0];this.curTo=null!==(e=i.tree.prop(V))&&void 0!==e?e:i.to,this.inner=new _(i.tree,-i.offset)}else this.curFrag=this.inner=null}hasNode(t){for(;this.curFrag&&t.from>=this.curTo;)this.nextFrag();return this.curFrag&&this.curFrag.from<=t.from&&this.curTo>=t.to&&this.inner.hasNode(t)}nextFrag(){var t;if(this.fragI++,this.fragI==this.fragments.length)this.curFrag=this.inner=null;else{let e=this.curFrag=this.fragments[this.fragI];this.curTo=null!==(t=e.tree.prop(V))&&void 0!==t?t:e.to,this.inner=new _(e.tree,-e.offset)}}findMounts(t,e){var i;let n=[];if(this.inner){this.inner.cursor.moveTo(t,1);for(let t=this.inner.cursor.node;t;t=t.parent){let s=null===(i=t.tree)||void 0===i?void 0:i.prop(o.mounted);if(s&&s.parser==e)for(let e=this.fragI;e<this.fragments.length;e++){let i=this.fragments[e];if(i.from>=t.to)break;i.tree==this.curFrag.tree&&n.push({frag:i,pos:t.from-i.offset,mount:s})}}}return n}}function $(t,e){let i=null,n=e;for(let o=1,r=0;o<t.length;o++){let l=t[o-1].to,a=t[o].from;for(;r<n.length;r++){let t=n[r];if(t.from>=a)break;t.to<=l||(i||(n=i=e.slice()),t.from<l?(i[r]=new s(t.from,l),t.to>a&&i.splice(r+1,0,new s(a,t.to))):t.to>a?i[r--]=new s(a,t.to):i.splice(r--,1))}}return n}function U(t,e,i,n){let o=0,r=0,l=!1,a=!1,h=-1e9,c=[];for(;;){let f=o==t.length?1e9:l?t[o].to:t[o].from,d=r==e.length?1e9:a?e[r].to:e[r].from;if(l!=a){let t=Math.max(h,i),e=Math.min(f,d,n);t<e&&c.push(new s(t,e))}if(h=Math.min(f,d),1e9==h)break;f==h&&(l?(l=!1,o++):l=!0),d==h&&(a?(a=!1,r++):a=!0)}return c}function G(t,e){let i=[];for(let{pos:n,mount:o,frag:r}of t){let t=n+(o.overlay?o.overlay[0].from:0),l=t+o.tree.length,a=Math.max(r.from,t),h=Math.min(r.to,l);if(o.overlay){let l=U(e,o.overlay.map(t=>new s(t.from+n,t.to+n)),a,h);for(let e=0,n=a;;e++){let s=e==l.length,a=s?h:l[e].from;if(a>n&&i.push(new P(n,a,o.tree,-t,r.from>=n||r.openStart,r.to<=a||r.openEnd)),s)break;n=l[e].to}}else i.push(new P(a,h,o.tree,-t,r.from>=t||r.openStart,r.to<=l||r.openEnd))}return i}let Y=[],J=[];function X(t){if(t<768)return!1;for(let e=0,i=Y.length;;){let n=e+i>>1;if(t<Y[n])i=n;else{if(!(t>=J[n]))return!0;e=n+1}if(e==i)return!1}}function Q(t){return t>=127462&&t<=127487}(()=>{let t="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(t=>t?parseInt(t,36):1);for(let e=0,i=0;e<t.length;e++)(e%2?J:Y).push(i+=t[e])})();function Z(t,e,i=!0,n=!0){return(i?tt:et)(t,e,n)}function tt(t,e,i){if(e==t.length)return e;e&&nt(t.charCodeAt(e))&&st(t.charCodeAt(e-1))&&e--;let n=it(t,e);for(e+=ot(n);e<t.length;){let s=it(t,e);if(8205==n||8205==s||i&&X(s))e+=ot(s),n=s;else{if(!Q(s))break;{let i=0,n=e-2;for(;n>=0&&Q(it(t,n));)i++,n-=2;if(i%2==0)break;e+=2}}}return e}function et(t,e,i){for(;e>0;){let n=tt(t,e-2,i);if(n<e)return n;e--}return 0}function it(t,e){let i=t.charCodeAt(e);if(!st(i)||e+1==t.length)return i;let n=t.charCodeAt(e+1);return nt(n)?n-56320+(i-55296<<10)+65536:i}function nt(t){return t>=56320&&t<57344}function st(t){return t>=55296&&t<56320}function ot(t){return t<65536?1:2}class rt{lineAt(t){if(t<0||t>this.length)throw new RangeError(`Invalid position ${t} in document of length ${this.length}`);return this.lineInner(t,!1,1,0)}line(t){if(t<1||t>this.lines)throw new RangeError(`Invalid line number ${t} in ${this.lines}-line document`);return this.lineInner(t,!0,1,0)}replace(t,e,i){[t,e]=mt(this,t,e);let n=[];return this.decompose(0,t,n,2),i.length&&i.decompose(0,i.length,n,3),this.decompose(e,this.length,n,1),at.from(n,this.length-(e-t)+i.length)}append(t){return this.replace(this.length,this.length,t)}slice(t,e=this.length){[t,e]=mt(this,t,e);let i=[];return this.decompose(t,e,i,0),at.from(i,e-t)}eq(t){if(t==this)return!0;if(t.length!=this.length||t.lines!=this.lines)return!1;let e=this.scanIdentical(t,1),i=this.length-this.scanIdentical(t,-1),n=new ft(this),s=new ft(t);for(let t=e,o=e;;){if(n.next(t),s.next(t),t=0,n.lineBreak!=s.lineBreak||n.done!=s.done||n.value!=s.value)return!1;if(o+=n.value.length,n.done||o>=i)return!0}}iter(t=1){return new ft(this,t)}iterRange(t,e=this.length){return new dt(this,t,e)}iterLines(t,e){let i;if(null==t)i=this.iter();else{null==e&&(e=this.lines+1);let n=this.line(t).from;i=this.iterRange(n,Math.max(n,e==this.lines+1?this.length:e<=1?0:this.line(e-1).to))}return new ut(i)}toString(){return this.sliceString(0)}toJSON(){let t=[];return this.flatten(t),t}constructor(){}static of(t){if(0==t.length)throw new RangeError("A document must have at least one line");return 1!=t.length||t[0]?t.length<=32?new lt(t):at.from(lt.split(t,[])):rt.empty}}class lt extends rt{constructor(t,e=function(t){let e=-1;for(let i of t)e+=i.length+1;return e}(t)){super(),this.text=t,this.length=e}get lines(){return this.text.length}get children(){return null}lineInner(t,e,i,n){for(let s=0;;s++){let o=this.text[s],r=n+o.length;if((e?i:r)>=t)return new pt(n,r,i,o);n=r+1,i++}}decompose(t,e,i,n){let s=t<=0&&e>=this.length?this:new lt(ct(this.text,t,e),Math.min(e,this.length)-Math.max(0,t));if(1&n){let t=i.pop(),e=ht(s.text,t.text.slice(),0,s.length);if(e.length<=32)i.push(new lt(e,t.length+s.length));else{let t=e.length>>1;i.push(new lt(e.slice(0,t)),new lt(e.slice(t)))}}else i.push(s)}replace(t,e,i){if(!(i instanceof lt))return super.replace(t,e,i);[t,e]=mt(this,t,e);let n=ht(this.text,ht(i.text,ct(this.text,0,t)),e),s=this.length+i.length-(e-t);return n.length<=32?new lt(n,s):at.from(lt.split(n,[]),s)}sliceString(t,e=this.length,i="\n"){[t,e]=mt(this,t,e);let n="";for(let s=0,o=0;s<=e&&o<this.text.length;o++){let r=this.text[o],l=s+r.length;s>t&&o&&(n+=i),t<l&&e>s&&(n+=r.slice(Math.max(0,t-s),e-s)),s=l+1}return n}flatten(t){for(let e of this.text)t.push(e)}scanIdentical(){return 0}static split(t,e){let i=[],n=-1;for(let s of t)i.push(s),n+=s.length+1,32==i.length&&(e.push(new lt(i,n)),i=[],n=-1);return n>-1&&e.push(new lt(i,n)),e}}class at extends rt{constructor(t,e){super(),this.children=t,this.length=e,this.lines=0;for(let e of t)this.lines+=e.lines}lineInner(t,e,i,n){for(let s=0;;s++){let o=this.children[s],r=n+o.length,l=i+o.lines-1;if((e?l:r)>=t)return o.lineInner(t,e,i,n);n=r+1,i=l+1}}decompose(t,e,i,n){for(let s=0,o=0;o<=e&&s<this.children.length;s++){let r=this.children[s],l=o+r.length;if(t<=l&&e>=o){let s=n&((o<=t?1:0)|(l>=e?2:0));o>=t&&l<=e&&!s?i.push(r):r.decompose(t-o,e-o,i,s)}o=l+1}}replace(t,e,i){if([t,e]=mt(this,t,e),i.lines<this.lines)for(let n=0,s=0;n<this.children.length;n++){let o=this.children[n],r=s+o.length;if(t>=s&&e<=r){let l=o.replace(t-s,e-s,i),a=this.lines-o.lines+l.lines;if(l.lines<a>>4&&l.lines>a>>6){let s=this.children.slice();return s[n]=l,new at(s,this.length-(e-t)+i.length)}return super.replace(s,r,l)}s=r+1}return super.replace(t,e,i)}sliceString(t,e=this.length,i="\n"){[t,e]=mt(this,t,e);let n="";for(let s=0,o=0;s<this.children.length&&o<=e;s++){let r=this.children[s],l=o+r.length;o>t&&s&&(n+=i),t<l&&e>o&&(n+=r.sliceString(t-o,e-o,i)),o=l+1}return n}flatten(t){for(let e of this.children)e.flatten(t)}scanIdentical(t,e){if(!(t instanceof at))return 0;let i=0,[n,s,o,r]=e>0?[0,0,this.children.length,t.children.length]:[this.children.length-1,t.children.length-1,-1,-1];for(;;n+=e,s+=e){if(n==o||s==r)return i;let l=this.children[n],a=t.children[s];if(l!=a)return i+l.scanIdentical(a,e);i+=l.length+1}}static from(t,e=t.reduce((t,e)=>t+e.length+1,-1)){let i=0;for(let e of t)i+=e.lines;if(i<32){let i=[];for(let e of t)e.flatten(i);return new lt(i,e)}let n=Math.max(32,i>>5),s=n<<1,o=n>>1,r=[],l=0,a=-1,h=[];function c(t){let e;if(t.lines>s&&t instanceof at)for(let e of t.children)c(e);else t.lines>o&&(l>o||!l)?(f(),r.push(t)):t instanceof lt&&l&&(e=h[h.length-1])instanceof lt&&t.lines+e.lines<=32?(l+=t.lines,a+=t.length+1,h[h.length-1]=new lt(e.text.concat(t.text),e.length+1+t.length)):(l+t.lines>n&&f(),l+=t.lines,a+=t.length+1,h.push(t))}function f(){0!=l&&(r.push(1==h.length?h[0]:at.from(h,a)),a=-1,l=h.length=0)}for(let e of t)c(e);return f(),1==r.length?r[0]:new at(r,e)}}function ht(t,e,i=0,n=1e9){for(let s=0,o=0,r=!0;o<t.length&&s<=n;o++){let l=t[o],a=s+l.length;a>=i&&(a>n&&(l=l.slice(0,n-s)),s<i&&(l=l.slice(i-s)),r?(e[e.length-1]+=l,r=!1):e.push(l)),s=a+1}return e}function ct(t,e,i){return ht(t,[""],e,i)}rt.empty=new lt([""],0);class ft{constructor(t,e=1){this.dir=e,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[t],this.offsets=[e>0?1:(t instanceof lt?t.text.length:t.children.length)<<1]}nextInner(t,e){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,n=this.nodes[i],s=this.offsets[i],o=s>>1,r=n instanceof lt?n.text.length:n.children.length;if(o==(e>0?r:0)){if(0==i)return this.done=!0,this.value="",this;e>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((1&s)==(e>0?0:1)){if(this.offsets[i]+=e,0==t)return this.lineBreak=!0,this.value="\n",this;t--}else if(n instanceof lt){let s=n.text[o+(e<0?-1:0)];if(this.offsets[i]+=e,s.length>Math.max(0,t))return this.value=0==t?s:e>0?s.slice(t):s.slice(0,s.length-t),this;t-=s.length}else{let s=n.children[o+(e<0?-1:0)];t>s.length?(t-=s.length,this.offsets[i]+=e):(e<0&&this.offsets[i]--,this.nodes.push(s),this.offsets.push(e>0?1:(s instanceof lt?s.text.length:s.children.length)<<1))}}}next(t=0){return t<0&&(this.nextInner(-t,-this.dir),t=this.value.length),this.nextInner(t,this.dir)}}class dt{constructor(t,e,i){this.value="",this.done=!1,this.cursor=new ft(t,e>i?-1:1),this.pos=e>i?t.length:0,this.from=Math.min(e,i),this.to=Math.max(e,i)}nextInner(t,e){if(e<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;t+=Math.max(0,e<0?this.pos-this.to:this.from-this.pos);let i=e<0?this.pos-this.from:this.to-this.pos;t>i&&(t=i),i-=t;let{value:n}=this.cursor.next(t);return this.pos+=(n.length+t)*e,this.value=n.length<=i?n:e<0?n.slice(n.length-i):n.slice(0,i),this.done=!this.value,this}next(t=0){return t<0?t=Math.max(t,this.from-this.pos):t>0&&(t=Math.min(t,this.to-this.pos)),this.nextInner(t,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&""!=this.value}}class ut{constructor(t){this.inner=t,this.afterBreak=!0,this.value="",this.done=!1}next(t=0){let{done:e,lineBreak:i,value:n}=this.inner.next(t);return e&&this.afterBreak?(this.value="",this.afterBreak=!1):e?(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&&(rt.prototype[Symbol.iterator]=function(){return this.iter()},ft.prototype[Symbol.iterator]=dt.prototype[Symbol.iterator]=ut.prototype[Symbol.iterator]=function(){return this});class pt{constructor(t,e,i,n){this.from=t,this.to=e,this.number=i,this.text=n}get length(){return this.to-this.from}}function mt(t,e,i){return[e=Math.max(0,Math.min(t.length,e)),Math.max(e,Math.min(t.length,i))]}function gt(t,e,i=!0,n=!0){return Z(t,e,i,n)}function wt(t,e){let i=t.charCodeAt(e);if(!(n=i,n>=55296&&n<56320&&e+1!=t.length))return i;var n;let s=t.charCodeAt(e+1);return function(t){return t>=56320&&t<57344}(s)?s-56320+(i-55296<<10)+65536:i}function vt(t){return t<65536?1:2}const bt=/\r\n?|\n/;var yt=function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t}(yt||(yt={}));class xt{constructor(t){this.sections=t}get length(){let t=0;for(let e=0;e<this.sections.length;e+=2)t+=this.sections[e];return t}get newLength(){let t=0;for(let e=0;e<this.sections.length;e+=2){let i=this.sections[e+1];t+=i<0?this.sections[e]:i}return t}get empty(){return 0==this.sections.length||2==this.sections.length&&this.sections[1]<0}iterGaps(t){for(let e=0,i=0,n=0;e<this.sections.length;){let s=this.sections[e++],o=this.sections[e++];o<0?(t(i,n,s),n+=s):n+=o,i+=s}}iterChangedRanges(t,e=!1){At(this,t,e)}get invertedDesc(){let t=[];for(let e=0;e<this.sections.length;){let i=this.sections[e++],n=this.sections[e++];n<0?t.push(i,n):t.push(n,i)}return new xt(t)}composeDesc(t){return this.empty?t:t.empty?this:Tt(this,t)}mapDesc(t,e=!1){return t.empty?this:Mt(this,t,e)}mapPos(t,e=-1,i=yt.Simple){let n=0,s=0;for(let o=0;o<this.sections.length;){let r=this.sections[o++],l=this.sections[o++],a=n+r;if(l<0){if(a>t)return s+(t-n);s+=r}else{if(i!=yt.Simple&&a>=t&&(i==yt.TrackDel&&n<t&&a>t||i==yt.TrackBefore&&n<t||i==yt.TrackAfter&&a>t))return null;if(a>t||a==t&&e<0&&!r)return t==n||e<0?s:s+l;s+=l}n=a}if(t>n)throw new RangeError(`Position ${t} is out of range for changeset of length ${n}`);return s}touchesRange(t,e=t){for(let i=0,n=0;i<this.sections.length&&n<=e;){let s=n+this.sections[i++];if(this.sections[i++]>=0&&n<=e&&s>=t)return!(n<t&&s>e)||"cover";n=s}return!1}toString(){let t="";for(let e=0;e<this.sections.length;){let i=this.sections[e++],n=this.sections[e++];t+=(t?" ":"")+i+(n>=0?":"+n:"")}return t}toJSON(){return this.sections}static fromJSON(t){if(!Array.isArray(t)||t.length%2||t.some(t=>"number"!=typeof t))throw new RangeError("Invalid JSON representation of ChangeDesc");return new xt(t)}static create(t){return new xt(t)}}class kt extends xt{constructor(t,e){super(t),this.inserted=e}apply(t){if(this.length!=t.length)throw new RangeError("Applying change set to a document with the wrong length");return At(this,(e,i,n,s,o)=>t=t.replace(n,n+(i-e),o),!1),t}mapDesc(t,e=!1){return Mt(this,t,e,!0)}invert(t){let e=this.sections.slice(),i=[];for(let n=0,s=0;n<e.length;n+=2){let o=e[n],r=e[n+1];if(r>=0){e[n]=r,e[n+1]=o;let l=n>>1;for(;i.length<l;)i.push(rt.empty);i.push(o?t.slice(s,s+o):rt.empty)}s+=o}return new kt(e,i)}compose(t){return this.empty?t:t.empty?this:Tt(this,t,!0)}map(t,e=!1){return t.empty?this:Mt(this,t,e,!0)}iterChanges(t,e=!1){At(this,t,e)}get desc(){return xt.create(this.sections)}filter(t){let e=[],i=[],n=[],s=new Ot(this);t:for(let o=0,r=0;;){let l=o==t.length?1e9:t[o++];for(;r<l||r==l&&0==s.len;){if(s.done)break t;let t=Math.min(s.len,l-r);St(n,t,-1);let o=-1==s.ins?-1:0==s.off?s.ins:0;St(e,t,o),o>0&&Ct(i,e,s.text),s.forward(t),r+=t}let a=t[o++];for(;r<a;){if(s.done)break t;let t=Math.min(s.len,a-r);St(e,t,-1),St(n,t,-1==s.ins?-1:0==s.off?s.ins:0),s.forward(t),r+=t}}return{changes:new kt(e,i),filtered:xt.create(n)}}toJSON(){let t=[];for(let e=0;e<this.sections.length;e+=2){let i=this.sections[e],n=this.sections[e+1];n<0?t.push(i):0==n?t.push([i]):t.push([i].concat(this.inserted[e>>1].toJSON()))}return t}static of(t,e,i){let n=[],s=[],o=0,r=null;function l(t=!1){if(!t&&!n.length)return;o<e&&St(n,e-o,-1);let i=new kt(n,s);r=r?r.compose(i.map(r)):i,n=[],s=[],o=0}return function t(a){if(Array.isArray(a))for(let e of a)t(e);else if(a instanceof kt){if(a.length!=e)throw new RangeError(`Mismatched change set length (got ${a.length}, expected ${e})`);l(),r=r?r.compose(a.map(r)):a}else{let{from:t,to:r=t,insert:h}=a;if(t>r||t<0||r>e)throw new RangeError(`Invalid change range ${t} to ${r} (in doc of length ${e})`);let c=h?"string"==typeof h?rt.of(h.split(i||bt)):h:rt.empty,f=c.length;if(t==r&&0==f)return;t<o&&l(),t>o&&St(n,t-o,-1),St(n,r-t,f),Ct(s,n,c),o=r}}(t),l(!r),r}static empty(t){return new kt(t?[t,-1]:[],[])}static fromJSON(t){if(!Array.isArray(t))throw new RangeError("Invalid JSON representation of ChangeSet");let e=[],i=[];for(let n=0;n<t.length;n++){let s=t[n];if("number"==typeof s)e.push(s,-1);else{if(!Array.isArray(s)||"number"!=typeof s[0]||s.some((t,e)=>e&&"string"!=typeof t))throw new RangeError("Invalid JSON representation of ChangeSet");if(1==s.length)e.push(s[0],0);else{for(;i.length<n;)i.push(rt.empty);i[n]=rt.of(s.slice(1)),e.push(s[0],i[n].length)}}}return new kt(e,i)}static createSet(t,e){return new kt(t,e)}}function St(t,e,i,n=!1){if(0==e&&i<=0)return;let s=t.length-2;s>=0&&i<=0&&i==t[s+1]?t[s]+=e:s>=0&&0==e&&0==t[s]?t[s+1]+=i:n?(t[s]+=e,t[s+1]+=i):t.push(e,i)}function Ct(t,e,i){if(0==i.length)return;let n=e.length-2>>1;if(n<t.length)t[t.length-1]=t[t.length-1].append(i);else{for(;t.length<n;)t.push(rt.empty);t.push(i)}}function At(t,e,i){let n=t.inserted;for(let s=0,o=0,r=0;r<t.sections.length;){let l=t.sections[r++],a=t.sections[r++];if(a<0)s+=l,o+=l;else{let h=s,c=o,f=rt.empty;for(;h+=l,c+=a,a&&n&&(f=f.append(n[r-2>>1])),!(i||r==t.sections.length||t.sections[r+1]<0);)l=t.sections[r++],a=t.sections[r++];e(s,h,o,c,f),s=h,o=c}}}function Mt(t,e,i,n=!1){let s=[],o=n?[]:null,r=new Ot(t),l=new Ot(e);for(let t=-1;;){if(r.done&&l.len||l.done&&r.len)throw new Error("Mismatched change set lengths");if(-1==r.ins&&-1==l.ins){let t=Math.min(r.len,l.len);St(s,t,-1),r.forward(t),l.forward(t)}else if(l.ins>=0&&(r.ins<0||t==r.i||0==r.off&&(l.len<r.len||l.len==r.len&&!i))){let e=l.len;for(St(s,l.ins,-1);e;){let i=Math.min(r.len,e);r.ins>=0&&t<r.i&&r.len<=i&&(St(s,0,r.ins),o&&Ct(o,s,r.text),t=r.i),r.forward(i),e-=i}l.next()}else{if(!(r.ins>=0)){if(r.done&&l.done)return o?kt.createSet(s,o):xt.create(s);throw new Error("Mismatched change set lengths")}{let e=0,i=r.len;for(;i;)if(-1==l.ins){let t=Math.min(i,l.len);e+=t,i-=t,l.forward(t)}else{if(!(0==l.ins&&l.len<i))break;i-=l.len,l.next()}St(s,e,t<r.i?r.ins:0),o&&t<r.i&&Ct(o,s,r.text),t=r.i,r.forward(r.len-i)}}}}function Tt(t,e,i=!1){let n=[],s=i?[]:null,o=new Ot(t),r=new Ot(e);for(let t=!1;;){if(o.done&&r.done)return s?kt.createSet(n,s):xt.create(n);if(0==o.ins)St(n,o.len,0,t),o.next();else if(0!=r.len||r.done){if(o.done||r.done)throw new Error("Mismatched change set lengths");{let e=Math.min(o.len2,r.len),i=n.length;if(-1==o.ins){let i=-1==r.ins?-1:r.off?0:r.ins;St(n,e,i,t),s&&i&&Ct(s,n,r.text)}else-1==r.ins?(St(n,o.off?0:o.len,e,t),s&&Ct(s,n,o.textBit(e))):(St(n,o.off?0:o.len,r.off?0:r.ins,t),s&&!r.off&&Ct(s,n,r.text));t=(o.ins>e||r.ins>=0&&r.len>e)&&(t||n.length>i),o.forward2(e),r.forward(e)}}else St(n,0,r.ins,t),s&&Ct(s,n,r.text),r.next()}}class Ot{constructor(t){this.set=t,this.i=0,this.next()}next(){let{sections:t}=this.set;this.i<t.length?(this.len=t[this.i++],this.ins=t[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return-2==this.ins}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:t}=this.set,e=this.i-2>>1;return e>=t.length?rt.empty:t[e]}textBit(t){let{inserted:e}=this.set,i=this.i-2>>1;return i>=e.length&&!t?rt.empty:e[i].slice(this.off,null==t?void 0:this.off+t)}forward(t){t==this.len?this.next():(this.len-=t,this.off+=t)}forward2(t){-1==this.ins?this.forward(t):t==this.ins?this.next():(this.ins-=t,this.off+=t)}}class Dt{constructor(t,e,i){this.from=t,this.to=e,this.flags=i}get anchor(){return 32&this.flags?this.to:this.from}get head(){return 32&this.flags?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return 8&this.flags?-1:16&this.flags?1:0}get bidiLevel(){let t=7&this.flags;return 7==t?null:t}get goalColumn(){let t=this.flags>>6;return 16777215==t?void 0:t}map(t,e=-1){let i,n;return this.empty?i=n=t.mapPos(this.from,e):(i=t.mapPos(this.from,1),n=t.mapPos(this.to,-1)),i==this.from&&n==this.to?this:new Dt(i,n,this.flags)}extend(t,e=t){if(t<=this.anchor&&e>=this.anchor)return Lt.range(t,e);let i=Math.abs(t-this.anchor)>Math.abs(e-this.anchor)?t:e;return Lt.range(this.anchor,i)}eq(t,e=!1){return!(this.anchor!=t.anchor||this.head!=t.head||e&&this.empty&&this.assoc!=t.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(t){if(!t||"number"!=typeof t.anchor||"number"!=typeof t.head)throw new RangeError("Invalid JSON representation for SelectionRange");return Lt.range(t.anchor,t.head)}static create(t,e,i){return new Dt(t,e,i)}}class Lt{constructor(t,e){this.ranges=t,this.mainIndex=e}map(t,e=-1){return t.empty?this:Lt.create(this.ranges.map(i=>i.map(t,e)),this.mainIndex)}eq(t,e=!1){if(this.ranges.length!=t.ranges.length||this.mainIndex!=t.mainIndex)return!1;for(let i=0;i<this.ranges.length;i++)if(!this.ranges[i].eq(t.ranges[i],e))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return 1==this.ranges.length?this:new Lt([this.main],0)}addRange(t,e=!0){return Lt.create([t].concat(this.ranges),e?0:this.mainIndex+1)}replaceRange(t,e=this.mainIndex){let i=this.ranges.slice();return i[e]=t,Lt.create(i,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(t=>t.toJSON()),main:this.mainIndex}}static fromJSON(t){if(!t||!Array.isArray(t.ranges)||"number"!=typeof t.main||t.main>=t.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new Lt(t.ranges.map(t=>Dt.fromJSON(t)),t.main)}static single(t,e=t){return new Lt([Lt.range(t,e)],0)}static create(t,e=0){if(0==t.length)throw new RangeError("A selection needs at least one range");for(let i=0,n=0;n<t.length;n++){let s=t[n];if(s.empty?s.from<=i:s.from<i)return Lt.normalized(t.slice(),e);i=s.to}return new Lt(t,e)}static cursor(t,e=0,i,n){return Dt.create(t,t,(0==e?0:e<0?8:16)|(null==i?7:Math.min(6,i))|(null!=n?n:16777215)<<6)}static range(t,e,i,n){let s=(null!=i?i:16777215)<<6|(null==n?7:Math.min(6,n));return e<t?Dt.create(e,t,48|s):Dt.create(t,e,(e>t?8:0)|s)}static normalized(t,e=0){let i=t[e];t.sort((t,e)=>t.from-e.from),e=t.indexOf(i);for(let i=1;i<t.length;i++){let n=t[i],s=t[i-1];if(n.empty?n.from<=s.to:n.from<s.to){let o=s.from,r=Math.max(n.to,s.to);i<=e&&e--,t.splice(--i,2,n.anchor>n.head?Lt.range(r,o):Lt.range(o,r))}}return new Lt(t,e)}}function Et(t,e){for(let i of t.ranges)if(i.to>e)throw new RangeError("Selection points outside of document")}let Pt=0;class Bt{constructor(t,e,i,n,s){this.combine=t,this.compareInput=e,this.compare=i,this.isStatic=n,this.id=Pt++,this.default=t([]),this.extensions="function"==typeof s?s(this):s}get reader(){return this}static define(t={}){return new Bt(t.combine||(t=>t),t.compareInput||((t,e)=>t===e),t.compare||(t.combine?(t,e)=>t===e:Rt),!!t.static,t.enables)}of(t){return new Nt([],this,0,t)}compute(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new Nt(t,this,1,e)}computeN(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new Nt(t,this,2,e)}from(t,e){return e||(e=t=>t),this.compute([t],i=>e(i.field(t)))}}function Rt(t,e){return t==e||t.length==e.length&&t.every((t,i)=>t===e[i])}class Nt{constructor(t,e,i,n){this.dependencies=t,this.facet=e,this.type=i,this.value=n,this.id=Pt++}dynamicSlot(t){var e;let i=this.value,n=this.facet.compareInput,s=this.id,o=t[s]>>1,r=2==this.type,l=!1,a=!1,h=[];for(let i of this.dependencies)"doc"==i?l=!0:"selection"==i?a=!0:1&(null!==(e=t[i.id])&&void 0!==e?e:1)||h.push(t[i.id]);return{create:t=>(t.values[o]=i(t),1),update(t,e){if(l&&e.docChanged||a&&(e.docChanged||e.selection)||jt(t,h)){let e=i(t);if(r?!It(e,t.values[o],n):!n(e,t.values[o]))return t.values[o]=e,1}return 0},reconfigure:(t,e)=>{let l,a=e.config.address[s];if(null!=a){let s=Qt(e,a);if(this.dependencies.every(i=>i instanceof Bt?e.facet(i)===t.facet(i):!(i instanceof Ft)||e.field(i,!1)==t.field(i,!1))||(r?It(l=i(t),s,n):n(l=i(t),s)))return t.values[o]=s,0}else l=i(t);return t.values[o]=l,1}}}}function It(t,e,i){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!i(t[n],e[n]))return!1;return!0}function jt(t,e){let i=!1;for(let n of e)1&Xt(t,n)&&(i=!0);return i}function Ht(t,e,i){let n=i.map(e=>t[e.id]),s=i.map(t=>t.type),o=n.filter(t=>!(1&t)),r=t[e.id]>>1;function l(t){let i=[];for(let e=0;e<n.length;e++){let o=Qt(t,n[e]);if(2==s[e])for(let t of o)i.push(t);else i.push(o)}return e.combine(i)}return{create(t){for(let e of n)Xt(t,e);return t.values[r]=l(t),1},update(t,i){if(!jt(t,o))return 0;let n=l(t);return e.compare(n,t.values[r])?0:(t.values[r]=n,1)},reconfigure(t,s){let o=jt(t,n),a=s.config.facets[e.id],h=s.facet(e);if(a&&!o&&Rt(i,a))return t.values[r]=h,0;let c=l(t);return e.compare(c,h)?(t.values[r]=h,0):(t.values[r]=c,1)}}}const Vt=Bt.define({static:!0});class Ft{constructor(t,e,i,n,s){this.id=t,this.createF=e,this.updateF=i,this.compareF=n,this.spec=s,this.provides=void 0}static define(t){let e=new Ft(Pt++,t.create,t.update,t.compare||((t,e)=>t===e),t);return t.provide&&(e.provides=t.provide(e)),e}create(t){let e=t.facet(Vt).find(t=>t.field==this);return((null==e?void 0:e.create)||this.createF)(t)}slot(t){let e=t[this.id]>>1;return{create:t=>(t.values[e]=this.create(t),1),update:(t,i)=>{let n=t.values[e],s=this.updateF(n,i);return this.compareF(n,s)?0:(t.values[e]=s,1)},reconfigure:(t,i)=>{let n,s=t.facet(Vt),o=i.facet(Vt);return(n=s.find(t=>t.field==this))&&n!=o.find(t=>t.field==this)?(t.values[e]=n.create(t),1):null!=i.config.address[this.id]?(t.values[e]=i.field(this),0):(t.values[e]=this.create(t),1)}}}init(t){return[this,Vt.of({field:this,create:t})]}get extension(){return this}}const zt=4,Wt=3,qt=2,_t=1;function Kt(t){return e=>new Ut(e,t)}const $t={highest:Kt(0),high:Kt(_t),default:Kt(qt),low:Kt(Wt),lowest:Kt(zt)};class Ut{constructor(t,e){this.inner=t,this.prec=e}}class Gt{of(t){return new Yt(this,t)}reconfigure(t){return Gt.reconfigure.of({compartment:this,extension:t})}get(t){return t.config.compartments.get(this)}}class Yt{constructor(t,e){this.compartment=t,this.inner=e}}class Jt{constructor(t,e,i,n,s,o){for(this.base=t,this.compartments=e,this.dynamicSlots=i,this.address=n,this.staticValues=s,this.facets=o,this.statusTemplate=[];this.statusTemplate.length<i.length;)this.statusTemplate.push(0)}staticFacet(t){let e=this.address[t.id];return null==e?t.default:this.staticValues[e>>1]}static resolve(t,e,i){let n=[],s=Object.create(null),o=new Map;for(let i of function(t,e,i){let n=[[],[],[],[],[]],s=new Map;function o(t,r){let l=s.get(t);if(null!=l){if(l<=r)return;let e=n[l].indexOf(t);e>-1&&n[l].splice(e,1),t instanceof Yt&&i.delete(t.compartment)}if(s.set(t,r),Array.isArray(t))for(let e of t)o(e,r);else if(t instanceof Yt){if(i.has(t.compartment))throw new RangeError("Duplicate use of compartment in extensions");let n=e.get(t.compartment)||t.inner;i.set(t.compartment,n),o(n,r)}else if(t instanceof Ut)o(t.inner,t.prec);else if(t instanceof Ft)n[r].push(t),t.provides&&o(t.provides,r);else if(t instanceof Nt)n[r].push(t),t.facet.extensions&&o(t.facet.extensions,qt);else{let e=t.extension;if(!e)throw new Error(`Unrecognized extension value in extension set (${t}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);o(e,r)}}return o(t,qt),n.reduce((t,e)=>t.concat(e))}(t,e,o))i instanceof Ft?n.push(i):(s[i.facet.id]||(s[i.facet.id]=[])).push(i);let r=Object.create(null),l=[],a=[];for(let t of n)r[t.id]=a.length<<1,a.push(e=>t.slot(e));let h=null==i?void 0:i.config.facets;for(let t in s){let e=s[t],n=e[0].facet,o=h&&h[t]||[];if(e.every(t=>0==t.type))if(r[n.id]=l.length<<1|1,Rt(o,e))l.push(i.facet(n));else{let t=n.combine(e.map(t=>t.value));l.push(i&&n.compare(t,i.facet(n))?i.facet(n):t)}else{for(let t of e)0==t.type?(r[t.id]=l.length<<1|1,l.push(t.value)):(r[t.id]=a.length<<1,a.push(e=>t.dynamicSlot(e)));r[n.id]=a.length<<1,a.push(t=>Ht(t,n,e))}}let c=a.map(t=>t(r));return new Jt(t,o,c,r,l,s)}}function Xt(t,e){if(1&e)return 2;let i=e>>1,n=t.status[i];if(4==n)throw new Error("Cyclic dependency between fields and/or facets");if(2&n)return n;t.status[i]=4;let s=t.computeSlot(t,t.config.dynamicSlots[i]);return t.status[i]=2|s}function Qt(t,e){return 1&e?t.config.staticValues[e>>1]:t.values[e>>1]}const Zt=Bt.define(),te=Bt.define({combine:t=>t.some(t=>t),static:!0}),ee=Bt.define({combine:t=>t.length?t[0]:void 0,static:!0}),ie=Bt.define(),ne=Bt.define(),se=Bt.define(),oe=Bt.define({combine:t=>!!t.length&&t[0]});class re{constructor(t,e){this.type=t,this.value=e}static define(){return new le}}class le{of(t){return new re(this,t)}}class ae{constructor(t){this.map=t}of(t){return new he(this,t)}}class he{constructor(t,e){this.type=t,this.value=e}map(t){let e=this.type.map(this.value,t);return void 0===e?void 0:e==this.value?this:new he(this.type,e)}is(t){return this.type==t}static define(t={}){return new ae(t.map||(t=>t))}static mapEffects(t,e){if(!t.length)return t;let i=[];for(let n of t){let t=n.map(e);t&&i.push(t)}return i}}he.reconfigure=he.define(),he.appendConfig=he.define();class ce{constructor(t,e,i,n,s,o){this.startState=t,this.changes=e,this.selection=i,this.effects=n,this.annotations=s,this.scrollIntoView=o,this._doc=null,this._state=null,i&&Et(i,e.newLength),s.some(t=>t.type==ce.time)||(this.annotations=s.concat(ce.time.of(Date.now())))}static create(t,e,i,n,s,o){return new ce(t,e,i,n,s,o)}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(t){for(let e of this.annotations)if(e.type==t)return e.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(t){let e=this.annotation(ce.userEvent);return!(!e||!(e==t||e.length>t.length&&e.slice(0,t.length)==t&&"."==e[t.length]))}}function fe(t,e){let i=[];for(let n=0,s=0;;){let o,r;if(n<t.length&&(s==e.length||e[s]>=t[n]))o=t[n++],r=t[n++];else{if(!(s<e.length))return i;o=e[s++],r=e[s++]}!i.length||i[i.length-1]<o?i.push(o,r):i[i.length-1]<r&&(i[i.length-1]=r)}}function de(t,e,i){var n;let s,o,r;return i?(s=e.changes,o=kt.empty(e.changes.length),r=t.changes.compose(e.changes)):(s=e.changes.map(t.changes),o=t.changes.mapDesc(e.changes,!0),r=t.changes.compose(s)),{changes:r,selection:e.selection?e.selection.map(o):null===(n=t.selection)||void 0===n?void 0:n.map(s),effects:he.mapEffects(t.effects,s).concat(he.mapEffects(e.effects,o)),annotations:t.annotations.length?t.annotations.concat(e.annotations):e.annotations,scrollIntoView:t.scrollIntoView||e.scrollIntoView}}function ue(t,e,i){let n=e.selection,s=ge(e.annotations);return e.userEvent&&(s=s.concat(ce.userEvent.of(e.userEvent))),{changes:e.changes instanceof kt?e.changes:kt.of(e.changes||[],i,t.facet(ee)),selection:n&&(n instanceof Lt?n:Lt.single(n.anchor,n.head)),effects:ge(e.effects),annotations:s,scrollIntoView:!!e.scrollIntoView}}function pe(t,e,i){let n=ue(t,e.length?e[0]:{},t.doc.length);e.length&&!1===e[0].filter&&(i=!1);for(let s=1;s<e.length;s++){!1===e[s].filter&&(i=!1);let o=!!e[s].sequential;n=de(n,ue(t,e[s],o?n.changes.newLength:t.doc.length),o)}let s=ce.create(t,n.changes,n.selection,n.effects,n.annotations,n.scrollIntoView);return function(t){let e=t.startState,i=e.facet(se),n=t;for(let s=i.length-1;s>=0;s--){let o=i[s](t);o&&Object.keys(o).length&&(n=de(n,ue(e,o,t.changes.newLength),!0))}return n==t?t:ce.create(e,t.changes,t.selection,n.effects,n.annotations,n.scrollIntoView)}(i?function(t){let e=t.startState,i=!0;for(let n of e.facet(ie)){let e=n(t);if(!1===e){i=!1;break}Array.isArray(e)&&(i=!0===i?e:fe(i,e))}if(!0!==i){let n,s;if(!1===i)s=t.changes.invertedDesc,n=kt.empty(e.doc.length);else{let e=t.changes.filter(i);n=e.changes,s=e.filtered.mapDesc(e.changes).invertedDesc}t=ce.create(e,n,t.selection&&t.selection.map(s),he.mapEffects(t.effects,s),t.annotations,t.scrollIntoView)}let n=e.facet(ne);for(let i=n.length-1;i>=0;i--){let s=n[i](t);t=s instanceof ce?s:Array.isArray(s)&&1==s.length&&s[0]instanceof ce?s[0]:pe(e,ge(s),!1)}return t}(s):s)}ce.time=re.define(),ce.userEvent=re.define(),ce.addToHistory=re.define(),ce.remote=re.define();const me=[];function ge(t){return null==t?me:Array.isArray(t)?t:[t]}var we=function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t}(we||(we={}));const ve=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let be;try{be=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch(t){}function ye(t){return e=>{if(!/\S/.test(e))return we.Space;if(function(t){if(be)return be.test(t);for(let e=0;e<t.length;e++){let i=t[e];if(/\w/.test(i)||i>""&&(i.toUpperCase()!=i.toLowerCase()||ve.test(i)))return!0}return!1}(e))return we.Word;for(let i=0;i<t.length;i++)if(e.indexOf(t[i])>-1)return we.Word;return we.Other}}class xe{constructor(t,e,i,n,s,o){this.config=t,this.doc=e,this.selection=i,this.values=n,this.status=t.statusTemplate.slice(),this.computeSlot=s,o&&(o._state=this);for(let t=0;t<this.config.dynamicSlots.length;t++)Xt(this,t<<1);this.computeSlot=null}field(t,e=!0){let i=this.config.address[t.id];if(null!=i)return Xt(this,i),Qt(this,i);if(e)throw new RangeError("Field is not present in this state")}update(...t){return pe(this,t,!0)}applyTransaction(t){let e,i=this.config,{base:n,compartments:s}=i;for(let e of t.effects)e.is(Gt.reconfigure)?(i&&(s=new Map,i.compartments.forEach((t,e)=>s.set(e,t)),i=null),s.set(e.value.compartment,e.value.extension)):e.is(he.reconfigure)?(i=null,n=e.value):e.is(he.appendConfig)&&(i=null,n=ge(n).concat(e.value));if(i)e=t.startState.values.slice();else{i=Jt.resolve(n,s,this),e=new xe(i,this.doc,this.selection,i.dynamicSlots.map(()=>null),(t,e)=>e.reconfigure(t,this),null).values}let o=t.startState.facet(te)?t.newSelection:t.newSelection.asSingle();new xe(i,t.newDoc,o,e,(e,i)=>i.update(e,t),t)}replaceSelection(t){return"string"==typeof t&&(t=this.toText(t)),this.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:t},range:Lt.cursor(e.from+t.length)}))}changeByRange(t){let e=this.selection,i=t(e.ranges[0]),n=this.changes(i.changes),s=[i.range],o=ge(i.effects);for(let i=1;i<e.ranges.length;i++){let r=t(e.ranges[i]),l=this.changes(r.changes),a=l.map(n);for(let t=0;t<i;t++)s[t]=s[t].map(a);let h=n.mapDesc(l,!0);s.push(r.range.map(h)),n=n.compose(a),o=he.mapEffects(o,a).concat(he.mapEffects(ge(r.effects),h))}return{changes:n,selection:Lt.create(s,e.mainIndex),effects:o}}changes(t=[]){return t instanceof kt?t:kt.of(t,this.doc.length,this.facet(xe.lineSeparator))}toText(t){return rt.of(t.split(this.facet(xe.lineSeparator)||bt))}sliceDoc(t=0,e=this.doc.length){return this.doc.sliceString(t,e,this.lineBreak)}facet(t){let e=this.config.address[t.id];return null==e?t.default:(Xt(this,e),Qt(this,e))}toJSON(t){let e={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(t)for(let i in t){let n=t[i];n instanceof Ft&&null!=this.config.address[n.id]&&(e[i]=n.spec.toJSON(this.field(t[i]),this))}return e}static fromJSON(t,e={},i){if(!t||"string"!=typeof t.doc)throw new RangeError("Invalid JSON representation for EditorState");let n=[];if(i)for(let e in i)if(Object.prototype.hasOwnProperty.call(t,e)){let s=i[e],o=t[e];n.push(s.init(t=>s.spec.fromJSON(o,t)))}return xe.create({doc:t.doc,selection:Lt.fromJSON(t.selection),extensions:e.extensions?n.concat([e.extensions]):n})}static create(t={}){let e=Jt.resolve(t.extensions||[],new Map),i=t.doc instanceof rt?t.doc:rt.of((t.doc||"").split(e.staticFacet(xe.lineSeparator)||bt)),n=t.selection?t.selection instanceof Lt?t.selection:Lt.single(t.selection.anchor,t.selection.head):Lt.single(0);return Et(n,i.length),e.staticFacet(te)||(n=n.asSingle()),new xe(e,i,n,e.dynamicSlots.map(()=>null),(t,e)=>e.create(t),null)}get tabSize(){return this.facet(xe.tabSize)}get lineBreak(){return this.facet(xe.lineSeparator)||"\n"}get readOnly(){return this.facet(oe)}phrase(t,...e){for(let e of this.facet(xe.phrases))if(Object.prototype.hasOwnProperty.call(e,t)){t=e[t];break}return e.length&&(t=t.replace(/\$(\$|\d*)/g,(t,i)=>{if("$"==i)return"$";let n=+(i||1);return!n||n>e.length?t:e[n-1]})),t}languageDataAt(t,e,i=-1){let n=[];for(let s of this.facet(Zt))for(let o of s(this,e,i))Object.prototype.hasOwnProperty.call(o,t)&&n.push(o[t]);return n}charCategorizer(t){return ye(this.languageDataAt("wordChars",t).join(""))}wordAt(t){let{text:e,from:i,length:n}=this.doc.lineAt(t),s=this.charCategorizer(t),o=t-i,r=t-i;for(;o>0;){let t=gt(e,o,!1);if(s(e.slice(t,o))!=we.Word)break;o=t}for(;r<n;){let t=gt(e,r);if(s(e.slice(r,t))!=we.Word)break;r=t}return o==r?null:Lt.range(o+i,r+i)}}function ke(t,e,i={}){let n={};for(let e of t)for(let t of Object.keys(e)){let s=e[t],o=n[t];if(void 0===o)n[t]=s;else if(o===s||void 0===s);else{if(!Object.hasOwnProperty.call(i,t))throw new Error("Config merge conflict for field "+t);n[t]=i[t](o,s)}}for(let t in e)void 0===n[t]&&(n[t]=e[t]);return n}xe.allowMultipleSelections=te,xe.tabSize=Bt.define({combine:t=>t.length?t[0]:4}),xe.lineSeparator=ee,xe.readOnly=oe,xe.phrases=Bt.define({compare(t,e){let i=Object.keys(t),n=Object.keys(e);return i.length==n.length&&i.every(i=>t[i]==e[i])}}),xe.languageData=Zt,xe.changeFilter=ie,xe.transactionFilter=ne,xe.transactionExtender=se,Gt.reconfigure=he.define();class Se{eq(t){return this==t}range(t,e=t){return Ce.create(t,e,this)}}Se.prototype.startSide=Se.prototype.endSide=0,Se.prototype.point=!1,Se.prototype.mapMode=yt.TrackDel;class Ce{constructor(t,e,i){this.from=t,this.to=e,this.value=i}static create(t,e,i){return new Ce(t,e,i)}}function Ae(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class Me{constructor(t,e,i,n){this.from=t,this.to=e,this.value=i,this.maxPoint=n}get length(){return this.to[this.to.length-1]}findIndex(t,e,i,n=0){let s=i?this.to:this.from;for(let o=n,r=s.length;;){if(o==r)return o;let n=o+r>>1,l=s[n]-t||(i?this.value[n].endSide:this.value[n].startSide)-e;if(n==o)return l>=0?o:r;l>=0?r=n:o=n+1}}between(t,e,i,n){for(let s=this.findIndex(e,-1e9,!0),o=this.findIndex(i,1e9,!1,s);s<o;s++)if(!1===n(this.from[s]+t,this.to[s]+t,this.value[s]))return!1}map(t,e){let i=[],n=[],s=[],o=-1,r=-1;for(let l=0;l<this.value.length;l++){let a,h,c=this.value[l],f=this.from[l]+t,d=this.to[l]+t;if(f==d){let t=e.mapPos(f,c.startSide,c.mapMode);if(null==t)continue;if(a=h=t,c.startSide!=c.endSide&&(h=e.mapPos(f,c.endSide),h<a))continue}else if(a=e.mapPos(f,c.startSide),h=e.mapPos(d,c.endSide),a>h||a==h&&c.startSide>0&&c.endSide<=0)continue;(h-a||c.endSide-c.startSide)<0||(o<0&&(o=a),c.point&&(r=Math.max(r,h-a)),i.push(c),n.push(a-o),s.push(h-o))}return{mapped:i.length?new Me(n,s,i,r):null,pos:o}}}class Te{constructor(t,e,i,n){this.chunkPos=t,this.chunk=e,this.nextLayer=i,this.maxPoint=n}static create(t,e,i,n){return new Te(t,e,i,n)}get length(){let t=this.chunk.length-1;return t<0?0:Math.max(this.chunkEnd(t),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let t=this.nextLayer.size;for(let e of this.chunk)t+=e.value.length;return t}chunkEnd(t){return this.chunkPos[t]+this.chunk[t].length}update(t){let{add:e=[],sort:i=!1,filterFrom:n=0,filterTo:s=this.length}=t,o=t.filter;if(0==e.length&&!o)return this;if(i&&(e=e.slice().sort(Ae)),this.isEmpty)return e.length?Te.of(e):this;let r=new Le(this,null,-1).goto(0),l=0,a=[],h=new Oe;for(;r.value||l<e.length;)if(l<e.length&&(r.from-e[l].from||r.startSide-e[l].value.startSide)>=0){let t=e[l++];h.addInner(t.from,t.to,t.value)||a.push(t)}else 1==r.rangeIndex&&r.chunkIndex<this.chunk.length&&(l==e.length||this.chunkEnd(r.chunkIndex)<e[l].from)&&(!o||n>this.chunkEnd(r.chunkIndex)||s<this.chunkPos[r.chunkIndex])&&h.addChunk(this.chunkPos[r.chunkIndex],this.chunk[r.chunkIndex])?r.nextChunk():((!o||n>r.to||s<r.from||o(r.from,r.to,r.value))&&(h.addInner(r.from,r.to,r.value)||a.push(Ce.create(r.from,r.to,r.value))),r.next());return h.finishInner(this.nextLayer.isEmpty&&!a.length?Te.empty:this.nextLayer.update({add:a,filter:o,filterFrom:n,filterTo:s}))}map(t){if(t.empty||this.isEmpty)return this;let e=[],i=[],n=-1;for(let s=0;s<this.chunk.length;s++){let o=this.chunkPos[s],r=this.chunk[s],l=t.touchesRange(o,o+r.length);if(!1===l)n=Math.max(n,r.maxPoint),e.push(r),i.push(t.mapPos(o));else if(!0===l){let{mapped:s,pos:l}=r.map(o,t);s&&(n=Math.max(n,s.maxPoint),e.push(s),i.push(l))}}let s=this.nextLayer.map(t);return 0==e.length?s:new Te(i,e,s||Te.empty,n)}between(t,e,i){if(!this.isEmpty){for(let n=0;n<this.chunk.length;n++){let s=this.chunkPos[n],o=this.chunk[n];if(e>=s&&t<=s+o.length&&!1===o.between(s,t-s,e-s,i))return}this.nextLayer.between(t,e,i)}}iter(t=0){return Ee.from([this]).goto(t)}get isEmpty(){return this.nextLayer==this}static iter(t,e=0){return Ee.from(t).goto(e)}static compare(t,e,i,n,s=-1){let o=t.filter(t=>t.maxPoint>0||!t.isEmpty&&t.maxPoint>=s),r=e.filter(t=>t.maxPoint>0||!t.isEmpty&&t.maxPoint>=s),l=De(o,r,i),a=new Be(o,l,s),h=new Be(r,l,s);i.iterGaps((t,e,i)=>Re(a,t,h,e,i,n)),i.empty&&0==i.length&&Re(a,0,h,0,0,n)}static eq(t,e,i=0,n){null==n&&(n=999999999);let s=t.filter(t=>!t.isEmpty&&e.indexOf(t)<0),o=e.filter(e=>!e.isEmpty&&t.indexOf(e)<0);if(s.length!=o.length)return!1;if(!s.length)return!0;let r=De(s,o),l=new Be(s,r,0).goto(i),a=new Be(o,r,0).goto(i);for(;;){if(l.to!=a.to||!Ne(l.active,a.active)||l.point&&(!a.point||!l.point.eq(a.point)))return!1;if(l.to>n)return!0;l.next(),a.next()}}static spans(t,e,i,n,s=-1){let o=new Be(t,null,s).goto(e),r=e,l=o.openStart;for(;;){let t=Math.min(o.to,i);if(o.point){let i=o.activeForPoint(o.to),s=o.pointFrom<e?i.length+1:o.point.startSide<0?i.length:Math.min(i.length,l);n.point(r,t,o.point,i,s,o.pointRank),l=Math.min(o.openEnd(t),i.length)}else t>r&&(n.span(r,t,o.active,l),l=o.openEnd(t));if(o.to>i)return l+(o.point&&o.to>i?1:0);r=o.to,o.next()}}static of(t,e=!1){let i=new Oe;for(let n of t instanceof Ce?[t]:e?function(t){if(t.length>1)for(let e=t[0],i=1;i<t.length;i++){let n=t[i];if(Ae(e,n)>0)return t.slice().sort(Ae);e=n}return t}(t):t)i.add(n.from,n.to,n.value);return i.finish()}static join(t){if(!t.length)return Te.empty;let e=t[t.length-1];for(let i=t.length-2;i>=0;i--)for(let n=t[i];n!=Te.empty;n=n.nextLayer)e=new Te(n.chunkPos,n.chunk,e,Math.max(n.maxPoint,e.maxPoint));return e}}Te.empty=new Te([],[],null,-1),Te.empty.nextLayer=Te.empty;class Oe{finishChunk(t){this.chunks.push(new Me(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,t&&(this.from=[],this.to=[],this.value=[])}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}add(t,e,i){this.addInner(t,e,i)||(this.nextLayer||(this.nextLayer=new Oe)).add(t,e,i)}addInner(t,e,i){let n=t-this.lastTo||i.startSide-this.last.endSide;if(n<=0&&(t-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=t),this.from.push(t-this.chunkStart),this.to.push(e-this.chunkStart),this.last=i,this.lastFrom=t,this.lastTo=e,this.value.push(i),i.point&&(this.maxPoint=Math.max(this.maxPoint,e-t)),!0)}addChunk(t,e){if((t-this.lastTo||e.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,e.maxPoint),this.chunks.push(e),this.chunkPos.push(t);let i=e.value.length-1;return this.last=e.value[i],this.lastFrom=e.from[i]+t,this.lastTo=e.to[i]+t,!0}finish(){return this.finishInner(Te.empty)}finishInner(t){if(this.from.length&&this.finishChunk(!1),0==this.chunks.length)return t;let e=Te.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(t):t,this.setMaxPoint);return this.from=null,e}}function De(t,e,i){let n=new Map;for(let e of t)for(let t=0;t<e.chunk.length;t++)e.chunk[t].maxPoint<=0&&n.set(e.chunk[t],e.chunkPos[t]);let s=new Set;for(let t of e)for(let e=0;e<t.chunk.length;e++){let o=n.get(t.chunk[e]);null==o||(i?i.mapPos(o):o)!=t.chunkPos[e]||(null==i?void 0:i.touchesRange(o,o+t.chunk[e].length))||s.add(t.chunk[e])}return s}class Le{constructor(t,e,i,n=0){this.layer=t,this.skip=e,this.minPoint=i,this.rank=n}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(t,e=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(t,e,!1),this}gotoInner(t,e,i){for(;this.chunkIndex<this.layer.chunk.length;){let e=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(e)||this.layer.chunkEnd(this.chunkIndex)<t||e.maxPoint<this.minPoint))break;this.chunkIndex++,i=!1}if(this.chunkIndex<this.layer.chunk.length){let n=this.layer.chunk[this.chunkIndex].findIndex(t-this.layer.chunkPos[this.chunkIndex],e,!0);(!i||this.rangeIndex<n)&&this.setRangeIndex(n)}this.next()}forward(t,e){(this.to-t||this.endSide-e)<0&&this.gotoInner(t,e,!0)}next(){for(;;){if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}{let t=this.layer.chunkPos[this.chunkIndex],e=this.layer.chunk[this.chunkIndex],i=t+e.from[this.rangeIndex];if(this.from=i,this.to=t+e.to[this.rangeIndex],this.value=e.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}}setRangeIndex(t){if(t==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=t}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(t){return this.from-t.from||this.startSide-t.startSide||this.rank-t.rank||this.to-t.to||this.endSide-t.endSide}}class Ee{constructor(t){this.heap=t}static from(t,e=null,i=-1){let n=[];for(let s=0;s<t.length;s++)for(let o=t[s];!o.isEmpty;o=o.nextLayer)o.maxPoint>=i&&n.push(new Le(o,e,i,s));return 1==n.length?n[0]:new Ee(n)}get startSide(){return this.value?this.value.startSide:0}goto(t,e=-1e9){for(let i of this.heap)i.goto(t,e);for(let t=this.heap.length>>1;t>=0;t--)Pe(this.heap,t);return this.next(),this}forward(t,e){for(let i of this.heap)i.forward(t,e);for(let t=this.heap.length>>1;t>=0;t--)Pe(this.heap,t);(this.to-t||this.value.endSide-e)<0&&this.next()}next(){if(0==this.heap.length)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let t=this.heap[0];this.from=t.from,this.to=t.to,this.value=t.value,this.rank=t.rank,t.value&&t.next(),Pe(this.heap,0)}}}function Pe(t,e){for(let i=t[e];;){let n=1+(e<<1);if(n>=t.length)break;let s=t[n];if(n+1<t.length&&s.compare(t[n+1])>=0&&(s=t[n+1],n++),i.compare(s)<0)break;t[n]=i,t[e]=s,e=n}}class Be{constructor(t,e,i){this.minPoint=i,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=Ee.from(t,e,i)}goto(t,e=-1e9){return this.cursor.goto(t,e),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=t,this.endSide=e,this.openStart=-1,this.next(),this}forward(t,e){for(;this.minActive>-1&&(this.activeTo[this.minActive]-t||this.active[this.minActive].endSide-e)<0;)this.removeActive(this.minActive);this.cursor.forward(t,e)}removeActive(t){Ie(this.active,t),Ie(this.activeTo,t),Ie(this.activeRank,t),this.minActive=He(this.active,this.activeTo)}addActive(t){let e=0,{value:i,to:n,rank:s}=this.cursor;for(;e<this.activeRank.length&&(s-this.activeRank[e]||n-this.activeTo[e])>0;)e++;je(this.active,e,i),je(this.activeTo,e,n),je(this.activeRank,e,s),t&&je(t,e,this.cursor.from),this.minActive=He(this.active,this.activeTo)}next(){let t=this.to,e=this.point;this.point=null;let i=this.openStart<0?[]:null;for(;;){let n=this.minActive;if(n>-1&&(this.activeTo[n]-this.cursor.from||this.active[n].endSide-this.cursor.startSide)<0){if(this.activeTo[n]>t){this.to=this.activeTo[n],this.endSide=this.active[n].endSide;break}this.removeActive(n),i&&Ie(i,n)}else{if(!this.cursor.value){this.to=this.endSide=1e9;break}if(this.cursor.from>t){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}{let t=this.cursor.value;if(t.point){if(!(e&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)){this.point=t,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=t.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}this.cursor.next()}else this.addActive(i),this.cursor.next()}}}if(i){this.openStart=0;for(let e=i.length-1;e>=0&&i[e]<t;e--)this.openStart++}}activeForPoint(t){if(!this.active.length)return this.active;let e=[];for(let i=this.active.length-1;i>=0&&!(this.activeRank[i]<this.pointRank);i--)(this.activeTo[i]>t||this.activeTo[i]==t&&this.active[i].endSide>=this.point.endSide)&&e.push(this.active[i]);return e.reverse()}openEnd(t){let e=0;for(let i=this.activeTo.length-1;i>=0&&this.activeTo[i]>t;i--)e++;return e}}function Re(t,e,i,n,s,o){t.goto(e),i.goto(n);let r=n+s,l=n,a=n-e;for(;;){let e=t.to+a-i.to,n=e||t.endSide-i.endSide,s=n<0?t.to+a:i.to,h=Math.min(s,r);if(t.point||i.point?t.point&&i.point&&(t.point==i.point||t.point.eq(i.point))&&Ne(t.activeForPoint(t.to),i.activeForPoint(i.to))||o.comparePoint(l,h,t.point,i.point):h>l&&!Ne(t.active,i.active)&&o.compareRange(l,h,t.active,i.active),s>r)break;(e||t.openEnd!=i.openEnd)&&o.boundChange&&o.boundChange(s),l=s,n<=0&&t.next(),n>=0&&i.next()}}function Ne(t,e){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++)if(t[i]!=e[i]&&!t[i].eq(e[i]))return!1;return!0}function Ie(t,e){for(let i=e,n=t.length-1;i<n;i++)t[i]=t[i+1];t.pop()}function je(t,e,i){for(let i=t.length-1;i>=e;i--)t[i+1]=t[i];t[e]=i}function He(t,e){let i=-1,n=1e9;for(let s=0;s<e.length;s++)(e[s]-n||t[s].endSide-t[i].endSide)<0&&(i=s,n=e[s]);return i}function Ve(t,e,i=t.length){let n=0;for(let s=0;s<i&&s<t.length;)9==t.charCodeAt(s)?(n+=e-n%e,s++):(n++,s=gt(t,s));return n}const Fe="undefined"==typeof Symbol?"__ͼ":Symbol.for("ͼ"),ze="undefined"==typeof Symbol?"__styleSet"+Math.floor(1e8*Math.random()):Symbol("styleSet"),We="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:{};class qe{constructor(t,e){this.rules=[];let{finish:i}=e||{};function n(t){return/^@/.test(t)?[t]:t.split(/,\s*/)}function s(t,e,o,r){let l=[],a=/^@(\w+)\b/.exec(t[0]),h=a&&"keyframes"==a[1];if(a&&null==e)return o.push(t[0]+";");for(let i in e){let r=e[i];if(/&/.test(i))s(i.split(/,\s*/).map(e=>t.map(t=>e.replace(/&/,t))).reduce((t,e)=>t.concat(e)),r,o);else if(r&&"object"==typeof r){if(!a)throw new RangeError("The value of a property ("+i+") should be a primitive value.");s(n(i),r,l,h)}else null!=r&&l.push(i.replace(/_.*/,"").replace(/[A-Z]/g,t=>"-"+t.toLowerCase())+": "+r+";")}(l.length||h)&&o.push((!i||a||r?t:t.map(i)).join(", ")+" {"+l.join(" ")+"}")}for(let e in t)s(n(e),t[e],this.rules)}getRules(){return this.rules.join("\n")}static newName(){let t=We[Fe]||1;return We[Fe]=t+1,"ͼ"+t.toString(36)}static mount(t,e,i){let n=t[ze],s=i&&i.nonce;n?s&&n.setNonce(s):n=new Ke(t,s),n.mount(Array.isArray(e)?e:[e],t)}}let _e=new Map;class Ke{constructor(t,e){let i=t.ownerDocument||t,n=i.defaultView;if(!t.head&&t.adoptedStyleSheets&&n.CSSStyleSheet){let e=_e.get(i);if(e)return t[ze]=e;this.sheet=new n.CSSStyleSheet,_e.set(i,this)}else this.styleTag=i.createElement("style"),e&&this.styleTag.setAttribute("nonce",e);this.modules=[],t[ze]=this}mount(t,e){let i=this.sheet,n=0,s=0;for(let e=0;e<t.length;e++){let o=t[e],r=this.modules.indexOf(o);if(r<s&&r>-1&&(this.modules.splice(r,1),s--,r=-1),-1==r){if(this.modules.splice(s++,0,o),i)for(let t=0;t<o.rules.length;t++)i.insertRule(o.rules[t],n++)}else{for(;s<r;)n+=this.modules[s++].rules.length;n+=o.rules.length,s++}}if(i)e.adoptedStyleSheets.indexOf(this.sheet)<0&&(e.adoptedStyleSheets=[this.sheet,...e.adoptedStyleSheets]);else{let t="";for(let e=0;e<this.modules.length;e++)t+=this.modules[e].getRules()+"\n";this.styleTag.textContent=t;let i=e.head||e;this.styleTag.parentNode!=i&&i.insertBefore(this.styleTag,i.firstChild)}}setNonce(t){this.styleTag&&this.styleTag.getAttribute("nonce")!=t&&this.styleTag.setAttribute("nonce",t)}}for(var $e={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},Ue={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Ge="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),Ye="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),Je=0;Je<10;Je++)$e[48+Je]=$e[96+Je]=String(Je);for(Je=1;Je<=24;Je++)$e[Je+111]="F"+Je;for(Je=65;Je<=90;Je++)$e[Je]=String.fromCharCode(Je+32),Ue[Je]=String.fromCharCode(Je);for(var Xe in $e)Ue.hasOwnProperty(Xe)||(Ue[Xe]=$e[Xe]);function Qe(){var t=arguments[0];"string"==typeof t&&(t=document.createElement(t));var e=1,i=arguments[1];if(i&&"object"==typeof i&&null==i.nodeType&&!Array.isArray(i)){for(var n in i)if(Object.prototype.hasOwnProperty.call(i,n)){var s=i[n];"string"==typeof s?t.setAttribute(n,s):null!=s&&(t[n]=s)}e++}for(;e<arguments.length;e++)Ze(t,arguments[e]);return t}function Ze(t,e){if("string"==typeof e)t.appendChild(document.createTextNode(e));else if(null==e);else if(null!=e.nodeType)t.appendChild(e);else{if(!Array.isArray(e))throw new RangeError("Unsupported child node: "+e);for(var i=0;i<e.length;i++)Ze(t,e[i])}}let ti="undefined"!=typeof navigator?navigator:{userAgent:"",vendor:"",platform:""},ei="undefined"!=typeof document?document:{documentElement:{style:{}}};const ii=/Edge\/(\d+)/.exec(ti.userAgent),ni=/MSIE \d/.test(ti.userAgent),si=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(ti.userAgent),oi=!!(ni||si||ii),ri=!oi&&/gecko\/(\d+)/i.test(ti.userAgent),li=!oi&&/Chrome\/(\d+)/.exec(ti.userAgent),ai="webkitFontSmoothing"in ei.documentElement.style,hi=!oi&&/Apple Computer/.test(ti.vendor),ci=hi&&(/Mobile\/\w+/.test(ti.userAgent)||ti.maxTouchPoints>2);var fi={mac:ci||/Mac/.test(ti.platform),windows:/Win/.test(ti.platform),linux:/Linux|X11/.test(ti.platform),ie:oi,ie_version:ni?ei.documentMode||6:si?+si[1]:ii?+ii[1]:0,gecko:ri,gecko_version:ri?+(/Firefox\/(\d+)/.exec(ti.userAgent)||[0,0])[1]:0,chrome:!!li,chrome_version:li?+li[1]:0,ios:ci,android:/Android\b/.test(ti.userAgent),webkit_version:ai?+(/\bAppleWebKit\/(\d+)/.exec(ti.userAgent)||[0,0])[1]:0,safari:hi,safari_version:hi?+(/\bVersion\/(\d+(\.\d+)?)/.exec(ti.userAgent)||[0,0])[1]:0,tabSize:null!=ei.documentElement.style.tabSize?"tab-size":"-moz-tab-size"};function di(t){let e;return e=11==t.nodeType?t.getSelection?t:t.ownerDocument:t,e.getSelection()}function ui(t,e){return!!e&&(t==e||t.contains(1!=e.nodeType?e.parentNode:e))}function pi(t,e){if(!e.anchorNode)return!1;try{return ui(t,e.anchorNode)}catch(t){return!1}}function mi(t){return 3==t.nodeType?Oi(t,0,t.nodeValue.length).getClientRects():1==t.nodeType?t.getClientRects():[]}function gi(t,e,i,n){return!!i&&(bi(t,e,i,n,-1)||bi(t,e,i,n,1))}function wi(t){for(var e=0;;e++)if(!(t=t.previousSibling))return e}function vi(t){return 1==t.nodeType&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}function bi(t,e,i,n,s){for(;;){if(t==i&&e==n)return!0;if(e==(s<0?0:yi(t))){if("DIV"==t.nodeName)return!1;let i=t.parentNode;if(!i||1!=i.nodeType)return!1;e=wi(t)+(s<0?0:1),t=i}else{if(1!=t.nodeType)return!1;if(1==(t=t.childNodes[e+(s<0?-1:0)]).nodeType&&"false"==t.contentEditable)return!1;e=s<0?yi(t):0}}}function yi(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function xi(t,e){let i=e?t.left:t.right;return{left:i,right:i,top:t.top,bottom:t.bottom}}function ki(t){let e=t.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}function Si(t,e){let i=e.width/t.offsetWidth,n=e.height/t.offsetHeight;return(i>.995&&i<1.005||!isFinite(i)||Math.abs(e.width-t.offsetWidth)<1)&&(i=1),(n>.995&&n<1.005||!isFinite(n)||Math.abs(e.height-t.offsetHeight)<1)&&(n=1),{scaleX:i,scaleY:n}}class Ci{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(t){return this.anchorNode==t.anchorNode&&this.anchorOffset==t.anchorOffset&&this.focusNode==t.focusNode&&this.focusOffset==t.focusOffset}setRange(t){let{anchorNode:e,focusNode:i}=t;this.set(e,Math.min(t.anchorOffset,e?yi(e):0),i,Math.min(t.focusOffset,i?yi(i):0))}set(t,e,i,n){this.anchorNode=t,this.anchorOffset=e,this.focusNode=i,this.focusOffset=n}}let Ai,Mi=null;function Ti(t){if(t.setActive)return t.setActive();if(Mi)return t.focus(Mi);let e=[];for(let i=t;i&&(e.push(i,i.scrollTop,i.scrollLeft),i!=i.ownerDocument);i=i.parentNode);if(t.focus(null==Mi?{get preventScroll(){return Mi={preventScroll:!0},!0}}:void 0),!Mi){Mi=!1;for(let t=0;t<e.length;){let i=e[t++],n=e[t++],s=e[t++];i.scrollTop!=n&&(i.scrollTop=n),i.scrollLeft!=s&&(i.scrollLeft=s)}}}function Oi(t,e,i=e){let n=Ai||(Ai=document.createRange());return n.setEnd(t,i),n.setStart(t,e),n}function Di(t,e,i,n){let s={key:e,code:e,keyCode:i,which:i,cancelable:!0};n&&({altKey:s.altKey,ctrlKey:s.ctrlKey,shiftKey:s.shiftKey,metaKey:s.metaKey}=n);let o=new KeyboardEvent("keydown",s);o.synthetic=!0,t.dispatchEvent(o);let r=new KeyboardEvent("keyup",s);return r.synthetic=!0,t.dispatchEvent(r),o.defaultPrevented||r.defaultPrevented}function Li(t){for(;t.attributes.length;)t.removeAttributeNode(t.attributes[0])}function Ei(t){return t.scrollTop>Math.max(1,t.scrollHeight-t.clientHeight-4)}function Pi(t,e){for(let i=t,n=e;;){if(3==i.nodeType&&n>0)return{node:i,offset:n};if(1==i.nodeType&&n>0){if("false"==i.contentEditable)return null;i=i.childNodes[n-1],n=yi(i)}else{if(!i.parentNode||vi(i))return null;n=wi(i),i=i.parentNode}}}function Bi(t,e){for(let i=t,n=e;;){if(3==i.nodeType&&n<i.nodeValue.length)return{node:i,offset:n};if(1==i.nodeType&&n<i.childNodes.length){if("false"==i.contentEditable)return null;i=i.childNodes[n],n=0}else{if(!i.parentNode||vi(i))return null;n=wi(i)+1,i=i.parentNode}}}fi.safari&&fi.safari_version>=26&&(Mi=!1);class Ri{constructor(t,e,i=!0){this.node=t,this.offset=e,this.precise=i}static before(t,e){return new Ri(t.parentNode,wi(t),e)}static after(t,e){return new Ri(t.parentNode,wi(t)+1,e)}}const Ni=[];class Ii{constructor(){this.parent=null,this.dom=null,this.flags=2}get overrideDOMText(){return null}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(t){let e=this.posAtStart;for(let i of this.children){if(i==t)return e;e+=i.length+i.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(t){return this.posBefore(t)+t.length}sync(t,e){if(2&this.flags){let i,n=this.dom,s=null;for(let o of this.children){if(7&o.flags){if(!o.dom&&(i=s?s.nextSibling:n.firstChild)){let t=Ii.get(i);(!t||!t.parent&&t.canReuseDOM(o))&&o.reuseDOM(i)}o.sync(t,e),o.flags&=-8}if(i=s?s.nextSibling:n.firstChild,e&&!e.written&&e.node==n&&i!=o.dom&&(e.written=!0),o.dom.parentNode==n)for(;i&&i!=o.dom;)i=ji(i);else n.insertBefore(o.dom,i);s=o.dom}for(i=s?s.nextSibling:n.firstChild,i&&e&&e.node==n&&(e.written=!0);i;)i=ji(i)}else if(1&this.flags)for(let i of this.children)7&i.flags&&(i.sync(t,e),i.flags&=-8)}reuseDOM(t){}localPosFromDOM(t,e){let i;if(t==this.dom)i=this.dom.childNodes[e];else{let n=0==yi(t)?0:0==e?-1:1;for(;;){let e=t.parentNode;if(e==this.dom)break;0==n&&e.firstChild!=e.lastChild&&(n=t==e.firstChild?-1:1),t=e}i=n<0?t:t.nextSibling}if(i==this.dom.firstChild)return 0;for(;i&&!Ii.get(i);)i=i.nextSibling;if(!i)return this.length;for(let t=0,e=0;;t++){let n=this.children[t];if(n.dom==i)return e;e+=n.length+n.breakAfter}}domBoundsAround(t,e,i=0){let n=-1,s=-1,o=-1,r=-1;for(let l=0,a=i,h=i;l<this.children.length;l++){let i=this.children[l],c=a+i.length;if(a<t&&c>e)return i.domBoundsAround(t,e,a);if(c>=t&&-1==n&&(n=l,s=a),a>e&&i.dom.parentNode==this.dom){o=l,r=h;break}h=c,a=c+i.breakAfter}return{from:s,to:r<0?i+this.length:r,startDOM:(n?this.children[n-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:o<this.children.length&&o>=0?this.children[o].dom:null}}markDirty(t=!1){this.flags|=2,this.markParentsDirty(t)}markParentsDirty(t){for(let e=this.parent;e;e=e.parent){if(t&&(e.flags|=2),1&e.flags)return;e.flags|=1,t=!1}}setParent(t){this.parent!=t&&(this.parent=t,7&this.flags&&this.markParentsDirty(!0))}setDOM(t){this.dom!=t&&(this.dom&&(this.dom.cmView=null),this.dom=t,t.cmView=this)}get rootView(){for(let t=this;;){let e=t.parent;if(!e)return t;t=e}}replaceChildren(t,e,i=Ni){this.markDirty();for(let n=t;n<e;n++){let t=this.children[n];t.parent==this&&i.indexOf(t)<0&&t.destroy()}i.length<250?this.children.splice(t,e-t,...i):this.children=[].concat(this.children.slice(0,t),i,this.children.slice(e));for(let t=0;t<i.length;t++)i[t].setParent(this)}ignoreMutation(t){return!1}ignoreEvent(t){return!1}childCursor(t=this.length){return new Hi(this.children,t,this.children.length)}childPos(t,e=1){return this.childCursor().findPos(t,e)}toString(){let t=this.constructor.name.replace("View","");return t+(this.children.length?"("+this.children.join()+")":this.length?"["+("Text"==t?this.text:this.length)+"]":"")+(this.breakAfter?"#":"")}static get(t){return t.cmView}get isEditable(){return!0}get isWidget(){return!1}get isHidden(){return!1}merge(t,e,i,n,s,o){return!1}become(t){return!1}canReuseDOM(t){return t.constructor==this.constructor&&!(8&(this.flags|t.flags))}getSide(){return 0}destroy(){for(let t of this.children)t.parent==this&&t.destroy();this.parent=null}}function ji(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}Ii.prototype.breakAfter=0;class Hi{constructor(t,e,i){this.children=t,this.pos=e,this.i=i,this.off=0}findPos(t,e=1){for(;;){if(t>this.pos||t==this.pos&&(e>0||0==this.i||this.children[this.i-1].breakAfter))return this.off=t-this.pos,this;let i=this.children[--this.i];this.pos-=i.length+i.breakAfter}}}function Vi(t,e,i,n,s,o,r,l,a){let{children:h}=t,c=h.length?h[e]:null,f=o.length?o[o.length-1]:null,d=f?f.breakAfter:r;if(!(e==n&&c&&!r&&!d&&o.length<2&&c.merge(i,s,o.length?f:null,0==i,l,a))){if(n<h.length){let t=h[n];t&&(s<t.length||t.breakAfter&&(null==f?void 0:f.breakAfter))?(e==n&&(t=t.split(s),s=0),!d&&f&&t.merge(0,s,f,!0,0,a)?o[o.length-1]=t:((s||t.children.length&&!t.children[0].length)&&t.merge(0,s,null,!1,0,a),o.push(t))):(null==t?void 0:t.breakAfter)&&(f?f.breakAfter=1:r=1),n++}for(c&&(c.breakAfter=r,i>0&&(!r&&o.length&&c.merge(i,c.length,o[0],!1,l,0)?c.breakAfter=o.shift().breakAfter:(i<c.length||c.children.length&&0==c.children[c.children.length-1].length)&&c.merge(i,c.length,null,!1,l,0),e++));e<n&&o.length;)if(h[n-1].become(o[o.length-1]))n--,o.pop(),a=o.length?0:l;else{if(!h[e].become(o[0]))break;e++,o.shift(),l=o.length?0:a}!o.length&&e&&n<h.length&&!h[e-1].breakAfter&&h[n].merge(0,0,h[e-1],!1,l,a)&&e--,(e<n||o.length)&&t.replaceChildren(e,n,o)}}function Fi(t,e,i,n,s,o){let r=t.childCursor(),{i:l,off:a}=r.findPos(i,1),{i:h,off:c}=r.findPos(e,-1),f=e-i;for(let t of n)f+=t.length;t.length+=f,Vi(t,h,c,l,a,n,0,s,o)}class zi extends Ii{constructor(t){super(),this.text=t}get length(){return this.text.length}createDOM(t){this.setDOM(t||document.createTextNode(this.text))}sync(t,e){this.dom||this.createDOM(),this.dom.nodeValue!=this.text&&(e&&e.node==this.dom&&(e.written=!0),this.dom.nodeValue=this.text)}reuseDOM(t){3==t.nodeType&&this.createDOM(t)}merge(t,e,i){return!(8&this.flags||i&&(!(i instanceof zi)||this.length-(e-t)+i.length>256||8&i.flags))&&(this.text=this.text.slice(0,t)+(i?i.text:"")+this.text.slice(e),this.markDirty(),!0)}split(t){let e=new zi(this.text.slice(t));return this.text=this.text.slice(0,t),this.markDirty(),e.flags|=8&this.flags,e}localPosFromDOM(t,e){return t==this.dom?e:e?this.text.length:0}domAtPos(t){return new Ri(this.dom,t)}domBoundsAround(t,e,i){return{from:i,to:i+this.length,startDOM:this.dom,endDOM:this.dom.nextSibling}}coordsAt(t,e){return function(t,e,i){let n=t.nodeValue.length;e>n&&(e=n);let s=e,o=e,r=0;0==e&&i<0||e==n&&i>=0?fi.chrome||fi.gecko||(e?(s--,r=1):o<n&&(o++,r=-1)):i<0?s--:o<n&&o++;let l=Oi(t,s,o).getClientRects();if(!l.length)return null;let a=l[(r?r<0:i>=0)?0:l.length-1];fi.safari&&!r&&0==a.width&&(a=Array.prototype.find.call(l,t=>t.width)||a);return r?xi(a,r<0):a||null}(this.dom,t,e)}}class Wi extends Ii{constructor(t,e=[],i=0){super(),this.mark=t,this.children=e,this.length=i;for(let t of e)t.setParent(this)}setAttrs(t){if(Li(t),this.mark.class&&(t.className=this.mark.class),this.mark.attrs)for(let e in this.mark.attrs)t.setAttribute(e,this.mark.attrs[e]);return t}canReuseDOM(t){return super.canReuseDOM(t)&&!(8&(this.flags|t.flags))}reuseDOM(t){t.nodeName==this.mark.tagName.toUpperCase()&&(this.setDOM(t),this.flags|=6)}sync(t,e){this.dom?4&this.flags&&this.setAttrs(this.dom):this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))),super.sync(t,e)}merge(t,e,i,n,s,o){return(!i||!(!(i instanceof Wi&&i.mark.eq(this.mark))||t&&s<=0||e<this.length&&o<=0))&&(Fi(this,t,e,i?i.children.slice():[],s-1,o-1),this.markDirty(),!0)}split(t){let e=[],i=0,n=-1,s=0;for(let o of this.children){let r=i+o.length;r>t&&e.push(i<t?o.split(t-i):o),n<0&&i>=t&&(n=s),i=r,s++}let o=this.length-t;return this.length=t,n>-1&&(this.children.length=n,this.markDirty()),new Wi(this.mark,e,o)}domAtPos(t){return Ki(this,t)}coordsAt(t,e){return Ui(this,t,e)}}class qi extends Ii{static create(t,e,i){return new qi(t,e,i)}constructor(t,e,i){super(),this.widget=t,this.length=e,this.side=i,this.prevWidget=null}split(t){let e=qi.create(this.widget,this.length-t,this.side);return this.length-=t,e}sync(t){this.dom&&this.widget.updateDOM(this.dom,t)||(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(t)),this.widget.editable||(this.dom.contentEditable="false"))}getSide(){return this.side}merge(t,e,i,n,s,o){return!(i&&(!(i instanceof qi&&this.widget.compare(i.widget))||t>0&&s<=0||e<this.length&&o<=0))&&(this.length=t+(i?i.length:0)+(this.length-e),!0)}become(t){return t instanceof qi&&t.side==this.side&&this.widget.constructor==t.widget.constructor&&(this.widget.compare(t.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=t.widget,this.length=t.length,!0)}ignoreMutation(){return!0}ignoreEvent(t){return this.widget.ignoreEvent(t)}get overrideDOMText(){if(0==this.length)return rt.empty;let t=this;for(;t.parent;)t=t.parent;let{view:e}=t,i=e&&e.state.doc,n=this.posAtStart;return i?i.slice(n,n+this.length):rt.empty}domAtPos(t){return(this.length?0==t:this.side>0)?Ri.before(this.dom):Ri.after(this.dom,t==this.length)}domBoundsAround(){return null}coordsAt(t,e){let i=this.widget.coordsAt(this.dom,t,e);if(i)return i;let n=this.dom.getClientRects(),s=null;if(!n.length)return null;let o=this.side?this.side<0:t>0;for(let e=o?n.length-1:0;s=n[e],!(t>0?0==e:e==n.length-1||s.top<s.bottom);e+=o?-1:1);return xi(s,!o)}get isEditable(){return!1}get isWidget(){return!0}get isHidden(){return this.widget.isHidden}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}}class _i extends Ii{constructor(t){super(),this.side=t}get length(){return 0}merge(){return!1}become(t){return t instanceof _i&&t.side==this.side}split(){return new _i(this.side)}sync(){if(!this.dom){let t=document.createElement("img");t.className="cm-widgetBuffer",t.setAttribute("aria-hidden","true"),this.setDOM(t)}}getSide(){return this.side}domAtPos(t){return this.side>0?Ri.before(this.dom):Ri.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(t){return this.dom.getBoundingClientRect()}get overrideDOMText(){return rt.empty}get isHidden(){return!0}}function Ki(t,e){let i=t.dom,{children:n}=t,s=0;for(let t=0;s<n.length;s++){let o=n[s],r=t+o.length;if(!(r==t&&o.getSide()<=0)){if(e>t&&e<r&&o.dom.parentNode==i)return o.domAtPos(e-t);if(e<=t)break;t=r}}for(let t=s;t>0;t--){let e=n[t-1];if(e.dom.parentNode==i)return e.domAtPos(e.length)}for(let t=s;t<n.length;t++){let e=n[t];if(e.dom.parentNode==i)return e.domAtPos(0)}return new Ri(i,0)}function $i(t,e,i){let n,{children:s}=t;i>0&&e instanceof Wi&&s.length&&(n=s[s.length-1])instanceof Wi&&n.mark.eq(e.mark)?$i(n,e.children[0],i-1):(s.push(e),e.setParent(t)),t.length+=e.length}function Ui(t,e,i){let n=null,s=-1,o=null,r=-1;!function t(e,l){for(let a=0,h=0;a<e.children.length&&h<=l;a++){let c=e.children[a],f=h+c.length;f>=l&&(c.children.length?t(c,l-h):(!o||o.isHidden&&(i>0||Gi(o,c)))&&(f>l||h==f&&c.getSide()>0)?(o=c,r=l-h):(h<l||h==f&&c.getSide()<0&&!c.isHidden)&&(n=c,s=l-h)),h=f}}(t,e);let l=(i<0?n:o)||n||o;return l?l.coordsAt(Math.max(0,l==n?s:r),i):function(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let i=mi(e);return i[i.length-1]||null}(t)}function Gi(t,e){let i=t.coordsAt(0,1),n=e.coordsAt(0,1);return i&&n&&n.top<i.bottom}function Yi(t,e){for(let i in t)"class"==i&&e.class?e.class+=" "+t.class:"style"==i&&e.style?e.style+=";"+t.style:e[i]=t[i];return e}zi.prototype.children=qi.prototype.children=_i.prototype.children=Ni;const Ji=Object.create(null);function Xi(t,e,i){if(t==e)return!0;t||(t=Ji),e||(e=Ji);let n=Object.keys(t),s=Object.keys(e);if(n.length-(i&&n.indexOf(i)>-1?1:0)!=s.length-(i&&s.indexOf(i)>-1?1:0))return!1;for(let o of n)if(o!=i&&(-1==s.indexOf(o)||t[o]!==e[o]))return!1;return!0}function Qi(t,e,i){let n=!1;if(e)for(let s in e)i&&s in i||(n=!0,"style"==s?t.style.cssText="":t.removeAttribute(s));if(i)for(let s in i)e&&e[s]==i[s]||(n=!0,"style"==s?t.style.cssText=i[s]:t.setAttribute(s,i[s]));return n}function Zi(t){let e=Object.create(null);for(let i=0;i<t.attributes.length;i++){let n=t.attributes[i];e[n.name]=n.value}return e}class tn{eq(t){return!1}updateDOM(t,e){return!1}compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(t){return!0}coordsAt(t,e,i){return null}get isHidden(){return!1}get editable(){return!1}destroy(t){}}var en=function(t){return t[t.Text=0]="Text",t[t.WidgetBefore=1]="WidgetBefore",t[t.WidgetAfter=2]="WidgetAfter",t[t.WidgetRange=3]="WidgetRange",t}(en||(en={}));class nn extends Se{constructor(t,e,i,n){super(),this.startSide=t,this.endSide=e,this.widget=i,this.spec=n}get heightRelevant(){return!1}static mark(t){return new sn(t)}static widget(t){let e=Math.max(-1e4,Math.min(1e4,t.side||0)),i=!!t.block;return e+=i&&!t.inlineOrder?e>0?3e8:-4e8:e>0?1e8:-1e8,new rn(t,e,e,i,t.widget||null,!1)}static replace(t){let e,i,n=!!t.block;if(t.isBlockGap)e=-5e8,i=4e8;else{let{start:s,end:o}=ln(t,n);e=(s?n?-3e8:-1:5e8)-1,i=1+(o?n?2e8:1:-6e8)}return new rn(t,e,i,n,t.widget||null,!0)}static line(t){return new on(t)}static set(t,e=!1){return Te.of(t,e)}hasHeight(){return!!this.widget&&this.widget.estimatedHeight>-1}}nn.none=Te.empty;class sn extends nn{constructor(t){let{start:e,end:i}=ln(t);super(e?-1:5e8,i?1:-6e8,null,t),this.tagName=t.tagName||"span",this.class=t.class||"",this.attrs=t.attributes||null}eq(t){var e,i;return this==t||t instanceof sn&&this.tagName==t.tagName&&(this.class||(null===(e=this.attrs)||void 0===e?void 0:e.class))==(t.class||(null===(i=t.attrs)||void 0===i?void 0:i.class))&&Xi(this.attrs,t.attrs,"class")}range(t,e=t){if(t>=e)throw new RangeError("Mark decorations may not be empty");return super.range(t,e)}}sn.prototype.point=!1;class on extends nn{constructor(t){super(-2e8,-2e8,null,t)}eq(t){return t instanceof on&&this.spec.class==t.spec.class&&Xi(this.spec.attributes,t.spec.attributes)}range(t,e=t){if(e!=t)throw new RangeError("Line decoration ranges must be zero-length");return super.range(t,e)}}on.prototype.mapMode=yt.TrackBefore,on.prototype.point=!0;class rn extends nn{constructor(t,e,i,n,s,o){super(e,i,s,t),this.block=n,this.isReplace=o,this.mapMode=n?e<=0?yt.TrackBefore:yt.TrackAfter:yt.TrackDel}get type(){return this.startSide!=this.endSide?en.WidgetRange:this.startSide<=0?en.WidgetBefore:en.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(t){return t instanceof rn&&(e=this.widget,i=t.widget,e==i||!!(e&&i&&e.compare(i)))&&this.block==t.block&&this.startSide==t.startSide&&this.endSide==t.endSide;var e,i}range(t,e=t){if(this.isReplace&&(t>e||t==e&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&e!=t)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(t,e)}}function ln(t,e=!1){let{inclusiveStart:i,inclusiveEnd:n}=t;return null==i&&(i=t.inclusive),null==n&&(n=t.inclusive),{start:null!=i?i:e,end:null!=n?n:e}}function an(t,e,i,n=0){let s=i.length-1;s>=0&&i[s]+n>=t?i[s]=Math.max(i[s],e):i.push(t,e)}rn.prototype.point=!0;class hn extends Ii{constructor(){super(...arguments),this.children=[],this.length=0,this.prevAttrs=void 0,this.attrs=null,this.breakAfter=0}merge(t,e,i,n,s,o){if(i){if(!(i instanceof hn))return!1;this.dom||i.transferDOM(this)}return n&&this.setDeco(i?i.attrs:null),Fi(this,t,e,i?i.children.slice():[],s,o),!0}split(t){let e=new hn;if(e.breakAfter=this.breakAfter,0==this.length)return e;let{i:i,off:n}=this.childPos(t);n&&(e.append(this.children[i].split(n),0),this.children[i].merge(n,this.children[i].length,null,!1,0,0),i++);for(let t=i;t<this.children.length;t++)e.append(this.children[t],0);for(;i>0&&0==this.children[i-1].length;)this.children[--i].destroy();return this.children.length=i,this.markDirty(),this.length=t,e}transferDOM(t){this.dom&&(this.markDirty(),t.setDOM(this.dom),t.prevAttrs=void 0===this.prevAttrs?this.attrs:this.prevAttrs,this.prevAttrs=void 0,this.dom=null)}setDeco(t){Xi(this.attrs,t)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=t)}append(t,e){$i(this,t,e)}addLineDeco(t){let e=t.spec.attributes,i=t.spec.class;e&&(this.attrs=Yi(e,this.attrs||{})),i&&(this.attrs=Yi({class:i},this.attrs||{}))}domAtPos(t){return Ki(this,t)}reuseDOM(t){"DIV"==t.nodeName&&(this.setDOM(t),this.flags|=6)}sync(t,e){var i;this.dom?4&this.flags&&(Li(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&&(Qi(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(t,e);let n=this.dom.lastChild;for(;n&&Ii.get(n)instanceof Wi;)n=n.lastChild;if(!(n&&this.length&&("BR"==n.nodeName||0!=(null===(i=Ii.get(n))||void 0===i?void 0:i.isEditable)||fi.ios&&this.children.some(t=>t instanceof zi)))){let t=document.createElement("BR");t.cmIgnore=!0,this.dom.appendChild(t)}}measureTextSize(){if(0==this.children.length||this.length>20)return null;let t,e=0;for(let i of this.children){if(!(i instanceof zi)||/[^ -~]/.test(i.text))return null;let n=mi(i.dom);if(1!=n.length)return null;e+=n[0].width,t=n[0].height}return e?{lineHeight:this.dom.getBoundingClientRect().height,charWidth:e/this.length,textHeight:t}:null}coordsAt(t,e){let i=Ui(this,t,e);if(!this.children.length&&i&&this.parent){let{heightOracle:t}=this.parent.view.viewState,e=i.bottom-i.top;if(Math.abs(e-t.lineHeight)<2&&t.textHeight<e){let n=(e-t.textHeight)/2;return{top:i.top+n,bottom:i.bottom-n,left:i.left,right:i.left}}}return i}become(t){return t instanceof hn&&0==this.children.length&&0==t.children.length&&Xi(this.attrs,t.attrs)&&this.breakAfter==t.breakAfter}covers(){return!0}static find(t,e){for(let i=0,n=0;i<t.children.length;i++){let s=t.children[i],o=n+s.length;if(o>=e){if(s instanceof hn)return s;if(o>e)break}n=o+s.breakAfter}return null}}class cn extends Ii{constructor(t,e,i){super(),this.widget=t,this.length=e,this.deco=i,this.breakAfter=0,this.prevWidget=null}merge(t,e,i,n,s,o){return!(i&&(!(i instanceof cn&&this.widget.compare(i.widget))||t>0&&s<=0||e<this.length&&o<=0))&&(this.length=t+(i?i.length:0)+(this.length-e),!0)}domAtPos(t){return 0==t?Ri.before(this.dom):Ri.after(this.dom,t==this.length)}split(t){let e=this.length-t;this.length=t;let i=new cn(this.widget,e,this.deco);return i.breakAfter=this.breakAfter,i}get children(){return Ni}sync(t){this.dom&&this.widget.updateDOM(this.dom,t)||(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(t)),this.widget.editable||(this.dom.contentEditable="false"))}get overrideDOMText(){return this.parent?this.parent.view.state.doc.slice(this.posAtStart,this.posAtEnd):rt.empty}domBoundsAround(){return null}become(t){return t instanceof cn&&t.widget.constructor==this.widget.constructor&&(t.widget.compare(this.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=t.widget,this.length=t.length,this.deco=t.deco,this.breakAfter=t.breakAfter,!0)}ignoreMutation(){return!0}ignoreEvent(t){return this.widget.ignoreEvent(t)}get isEditable(){return!1}get isWidget(){return!0}coordsAt(t,e){let i=this.widget.coordsAt(this.dom,t,e);return i||(this.widget instanceof fn?null:xi(this.dom.getBoundingClientRect(),this.length?0==t:e<=0))}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}covers(t){let{startSide:e,endSide:i}=this.deco;return e!=i&&(t<0?e<0:i>0)}}class fn extends tn{constructor(t){super(),this.height=t}toDOM(){let t=document.createElement("div");return t.className="cm-gap",this.updateDOM(t),t}eq(t){return t.height==this.height}updateDOM(t){return t.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}class dn{constructor(t,e,i,n){this.doc=t,this.pos=e,this.end=i,this.disallowBlockEffectsFor=n,this.content=[],this.curLine=null,this.breakAtStart=0,this.pendingBuffer=0,this.bufferMarks=[],this.atCursorPos=!0,this.openStart=-1,this.openEnd=-1,this.text="",this.textOff=0,this.cursor=t.iter(),this.skip=e}posCovered(){if(0==this.content.length)return!this.breakAtStart&&this.doc.lineAt(this.pos).from!=this.pos;let t=this.content[this.content.length-1];return!(t.breakAfter||t instanceof cn&&t.deco.endSide<0)}getLine(){return this.curLine||(this.content.push(this.curLine=new hn),this.atCursorPos=!0),this.curLine}flushBuffer(t=this.bufferMarks){this.pendingBuffer&&(this.curLine.append(un(new _i(-1),t),t.length),this.pendingBuffer=0)}addBlockWidget(t){this.flushBuffer(),this.curLine=null,this.content.push(t)}finish(t){this.pendingBuffer&&t<=this.bufferMarks.length?this.flushBuffer():this.pendingBuffer=0,this.posCovered()||t&&this.content.length&&this.content[this.content.length-1]instanceof cn||this.getLine()}buildText(t,e,i){for(;t>0;){if(this.textOff==this.text.length){let{value:e,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,this.atCursorPos=!0,t--;continue}this.text=e,this.textOff=0}let n=Math.min(this.text.length-this.textOff,t),s=Math.min(n,512);this.flushBuffer(e.slice(e.length-i)),this.getLine().append(un(new zi(this.text.slice(this.textOff,this.textOff+s)),e),i),this.atCursorPos=!0,this.textOff+=s,t-=s,i=n<=s?0:e.length}}span(t,e,i,n){this.buildText(e-t,i,n),this.pos=e,this.openStart<0&&(this.openStart=n)}point(t,e,i,n,s,o){if(this.disallowBlockEffectsFor[o]&&i instanceof rn){if(i.block)throw new RangeError("Block decorations may not be specified via plugins");if(e>this.doc.lineAt(this.pos).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}let r=e-t;if(i instanceof rn)if(i.block)i.startSide>0&&!this.posCovered()&&this.getLine(),this.addBlockWidget(new cn(i.widget||pn.block,r,i));else{let o=qi.create(i.widget||pn.inline,r,r?0:i.startSide),l=this.atCursorPos&&!o.isEditable&&s<=n.length&&(t<e||i.startSide>0),a=!o.isEditable&&(t<e||s>n.length||i.startSide<=0),h=this.getLine();2!=this.pendingBuffer||l||o.isEditable||(this.pendingBuffer=0),this.flushBuffer(n),l&&(h.append(un(new _i(1),n),s),s=n.length+Math.max(0,s-n.length)),h.append(un(o,n),s),this.atCursorPos=a,this.pendingBuffer=a?t<e||s>n.length?1:2:0,this.pendingBuffer&&(this.bufferMarks=n.slice())}else this.doc.lineAt(this.pos).from==this.pos&&this.getLine().addLineDeco(i);r&&(this.textOff+r<=this.text.length?this.textOff+=r:(this.skip+=r-(this.text.length-this.textOff),this.text="",this.textOff=0),this.pos=e),this.openStart<0&&(this.openStart=s)}static build(t,e,i,n,s){let o=new dn(t,e,i,s);return o.openEnd=Te.spans(n,e,i,o),o.openStart<0&&(o.openStart=o.openEnd),o.finish(o.openEnd),o}}function un(t,e){for(let i of e)t=new Wi(i,[t],t.length);return t}class pn extends tn{constructor(t){super(),this.tag=t}eq(t){return t.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(t){return t.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}pn.inline=new pn("span"),pn.block=new pn("div");var mn=function(t){return t[t.LTR=0]="LTR",t[t.RTL=1]="RTL",t}(mn||(mn={}));const gn=mn.LTR,wn=mn.RTL;function vn(t){let e=[];for(let i=0;i<t.length;i++)e.push(1<<+t[i]);return e}const bn=vn("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),yn=vn("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),xn=Object.create(null),kn=[];for(let t of["()","[]","{}"]){let e=t.charCodeAt(0),i=t.charCodeAt(1);xn[e]=i,xn[i]=-e}function Sn(t){return t<=247?bn[t]:1424<=t&&t<=1524?2:1536<=t&&t<=1785?yn[t-1536]:1774<=t&&t<=2220?4:8192<=t&&t<=8204?256:64336<=t&&t<=65023?4:1}const Cn=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class An{get dir(){return this.level%2?wn:gn}constructor(t,e,i){this.from=t,this.to=e,this.level=i}side(t,e){return this.dir==e==t?this.to:this.from}forward(t,e){return t==(this.dir==e)}static find(t,e,i,n){let s=-1;for(let o=0;o<t.length;o++){let r=t[o];if(r.from<=e&&r.to>=e){if(r.level==i)return o;(s<0||(0!=n?n<0?r.from<e:r.to>e:t[s].level>r.level))&&(s=o)}}if(s<0)throw new RangeError("Index out of range");return s}}function Mn(t,e){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++){let n=t[i],s=e[i];if(n.from!=s.from||n.to!=s.to||n.direction!=s.direction||!Mn(n.inner,s.inner))return!1}return!0}const Tn=[];function On(t,e,i,n,s,o,r){let l=n%2?2:1;if(n%2==s%2)for(let a=e,h=0;a<i;){let e=!0,c=!1;if(h==o.length||a<o[h].from){let t=Tn[a];t!=l&&(e=!1,c=16==t)}let f=e||1!=l?null:[],d=e?n:n+1,u=a;t:for(;;)if(h<o.length&&u==o[h].from){if(c)break t;let p=o[h];if(!e)for(let t=p.to,e=h+1;;){if(t==i)break t;if(!(e<o.length&&o[e].from==t)){if(Tn[t]==l)break t;break}t=o[e++].to}if(h++,f)f.push(p);else{p.from>a&&r.push(new An(a,p.from,d)),Dn(t,p.direction==gn!=!(d%2)?n+1:n,s,p.inner,p.from,p.to,r),a=p.to}u=p.to}else{if(u==i||(e?Tn[u]!=l:Tn[u]==l))break;u++}f?On(t,a,u,n+1,s,f,r):a<u&&r.push(new An(a,u,d)),a=u}else for(let a=i,h=o.length;a>e;){let i=!0,c=!1;if(!h||a>o[h-1].to){let t=Tn[a-1];t!=l&&(i=!1,c=16==t)}let f=i||1!=l?null:[],d=i?n:n+1,u=a;t:for(;;)if(h&&u==o[h-1].to){if(c)break t;let p=o[--h];if(!i)for(let t=p.from,i=h;;){if(t==e)break t;if(!i||o[i-1].to!=t){if(Tn[t-1]==l)break t;break}t=o[--i].from}if(f)f.push(p);else{p.to<a&&r.push(new An(p.to,a,d)),Dn(t,p.direction==gn!=!(d%2)?n+1:n,s,p.inner,p.from,p.to,r),a=p.from}u=p.from}else{if(u==e||(i?Tn[u-1]!=l:Tn[u-1]==l))break;u--}f?On(t,u,a,n+1,s,f,r):u<a&&r.push(new An(u,a,d)),a=u}}function Dn(t,e,i,n,s,o,r){let l=e%2?2:1;!function(t,e,i,n,s){for(let o=0;o<=n.length;o++){let r=o?n[o-1].to:e,l=o<n.length?n[o].from:i,a=o?256:s;for(let e=r,i=a,n=a;e<l;e++){let s=Sn(t.charCodeAt(e));512==s?s=i:8==s&&4==n&&(s=16),Tn[e]=4==s?2:s,7&s&&(n=s),i=s}for(let t=r,e=a,n=a;t<l;t++){let s=Tn[t];if(128==s)t<l-1&&e==Tn[t+1]&&24&e?s=Tn[t]=e:Tn[t]=256;else if(64==s){let s=t+1;for(;s<l&&64==Tn[s];)s++;let o=t&&8==e||s<i&&8==Tn[s]?1==n?1:8:256;for(let e=t;e<s;e++)Tn[e]=o;t=s-1}else 8==s&&1==n&&(Tn[t]=1);e=s,7&s&&(n=s)}}}(t,s,o,n,l),function(t,e,i,n,s){let o=1==s?2:1;for(let r=0,l=0,a=0;r<=n.length;r++){let h=r?n[r-1].to:e,c=r<n.length?n[r].from:i;for(let e,i,n,r=h;r<c;r++)if(i=xn[e=t.charCodeAt(r)])if(i<0){for(let t=l-3;t>=0;t-=3)if(kn[t+1]==-i){let e=kn[t+2],i=2&e?s:4&e?1&e?o:s:0;i&&(Tn[r]=Tn[kn[t]]=i),l=t;break}}else{if(189==kn.length)break;kn[l++]=r,kn[l++]=e,kn[l++]=a}else if(2==(n=Tn[r])||1==n){let t=n==s;a=t?0:1;for(let e=l-3;e>=0;e-=3){let i=kn[e+2];if(2&i)break;if(t)kn[e+2]|=2;else{if(4&i)break;kn[e+2]|=4}}}}}(t,s,o,n,l),function(t,e,i,n){for(let s=0,o=n;s<=i.length;s++){let r=s?i[s-1].to:t,l=s<i.length?i[s].from:e;for(let a=r;a<l;){let r=Tn[a];if(256==r){let r=a+1;for(;;)if(r==l){if(s==i.length)break;r=i[s++].to,l=s<i.length?i[s].from:e}else{if(256!=Tn[r])break;r++}let h=1==o,c=h==(1==(r<e?Tn[r]:n))?h?1:2:n;for(let e=r,n=s,o=n?i[n-1].to:t;e>a;)e==o&&(e=i[--n].from,o=n?i[n-1].to:t),Tn[--e]=c;a=r}else o=r,a++}}}(s,o,n,l),On(t,s,o,e,i,n,r)}function Ln(t){return[new An(0,t,0)]}let En="";function Pn(t,e,i,n,s){var o;let r=n.head-t.from,l=An.find(e,r,null!==(o=n.bidiLevel)&&void 0!==o?o:-1,n.assoc),a=e[l],h=a.side(s,i);if(r==h){let t=l+=s?1:-1;if(t<0||t>=e.length)return null;a=e[l=t],r=a.side(!s,i),h=a.side(s,i)}let c=gt(t.text,r,a.forward(s,i));(c<a.from||c>a.to)&&(c=h),En=t.text.slice(Math.min(r,c),Math.max(r,c));let f=l==(s?e.length-1:0)?null:e[l+(s?1:-1)];return f&&c==h&&f.level+(s?0:1)<a.level?Lt.cursor(f.side(!s,i)+t.from,f.forward(s,i)?1:-1,f.level):Lt.cursor(c+t.from,a.forward(s,i)?-1:1,a.level)}function Bn(t,e,i){for(let n=e;n<i;n++){let e=Sn(t.charCodeAt(n));if(1==e)return gn;if(2==e||4==e)return wn}return gn}const Rn=Bt.define(),Nn=Bt.define(),In=Bt.define(),jn=Bt.define(),Hn=Bt.define(),Vn=Bt.define(),Fn=Bt.define(),zn=Bt.define(),Wn=Bt.define(),qn=Bt.define({combine:t=>t.some(t=>t)}),_n=Bt.define({combine:t=>t.some(t=>t)}),Kn=Bt.define();class $n{constructor(t,e="nearest",i="nearest",n=5,s=5,o=!1){this.range=t,this.y=e,this.x=i,this.yMargin=n,this.xMargin=s,this.isSnapshot=o}map(t){return t.empty?this:new $n(this.range.map(t),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(t){return this.range.to<=t.doc.length?this:new $n(Lt.cursor(t.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const Un=he.define({map:(t,e)=>t.map(e)}),Gn=he.define();function Yn(t,e,i){let n=t.facet(jn);n.length?n[0](e):window.onerror&&window.onerror(String(e),i,void 0,void 0,e)||(i?console.error(i+":",e):console.error(e))}const Jn=Bt.define({combine:t=>!t.length||t[0]});let Xn=0;const Qn=Bt.define({combine:t=>t.filter((e,i)=>{for(let n=0;n<i;n++)if(t[n].plugin==e.plugin)return!1;return!0})});class Zn{constructor(t,e,i,n,s){this.id=t,this.create=e,this.domEventHandlers=i,this.domEventObservers=n,this.baseExtensions=s(this),this.extension=this.baseExtensions.concat(Qn.of({plugin:this,arg:void 0}))}of(t){return this.baseExtensions.concat(Qn.of({plugin:this,arg:t}))}static define(t,e){const{eventHandlers:i,eventObservers:n,provide:s,decorations:o}=e||{};return new Zn(Xn++,t,i,n,t=>{let e=[];return o&&e.push(ns.of(e=>{let i=e.plugin(t);return i?o(i):nn.none})),s&&e.push(s(t)),e})}static fromClass(t,e){return Zn.define((e,i)=>new t(e,i),e)}}class ts{constructor(t){this.spec=t,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(t){if(this.value){if(this.mustUpdate){let t=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(t)}catch(e){if(Yn(t.state,e,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch(t){}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(t,this.spec.arg)}catch(e){Yn(t.state,e,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(t){var e;if(null===(e=this.value)||void 0===e?void 0:e.destroy)try{this.value.destroy()}catch(e){Yn(t.state,e,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const es=Bt.define(),is=Bt.define(),ns=Bt.define(),ss=Bt.define(),os=Bt.define(),rs=Bt.define();function ls(t,e){let i=t.state.facet(rs);if(!i.length)return i;let n=i.map(e=>e instanceof Function?e(t):e),s=[];return Te.spans(n,e.from,e.to,{point(){},span(t,i,n,o){let r=t-e.from,l=i-e.from,a=s;for(let t=n.length-1;t>=0;t--,o--){let i,s=n[t].spec.bidiIsolate;if(null==s&&(s=Bn(e.text,r,l)),o>0&&a.length&&(i=a[a.length-1]).to==r&&i.direction==s)i.to=l,a=i.inner;else{let t={from:r,to:l,direction:s,inner:[]};a.push(t),a=t.inner}}}}),s}const as=Bt.define();function hs(t){let e=0,i=0,n=0,s=0;for(let o of t.state.facet(as)){let r=o(t);r&&(null!=r.left&&(e=Math.max(e,r.left)),null!=r.right&&(i=Math.max(i,r.right)),null!=r.top&&(n=Math.max(n,r.top)),null!=r.bottom&&(s=Math.max(s,r.bottom)))}return{left:e,right:i,top:n,bottom:s}}const cs=Bt.define();class fs{constructor(t,e,i,n){this.fromA=t,this.toA=e,this.fromB=i,this.toB=n}join(t){return new fs(Math.min(this.fromA,t.fromA),Math.max(this.toA,t.toA),Math.min(this.fromB,t.fromB),Math.max(this.toB,t.toB))}addToSet(t){let e=t.length,i=this;for(;e>0;e--){let n=t[e-1];if(!(n.fromA>i.toA)){if(n.toA<i.fromA)break;i=i.join(n),t.splice(e-1,1)}}return t.splice(e,0,i),t}static extendWithRanges(t,e){if(0==e.length)return t;let i=[];for(let n=0,s=0,o=0,r=0;;n++){let l=n==t.length?null:t[n],a=o-r,h=l?l.fromB:1e9;for(;s<e.length&&e[s]<h;){let t=e[s],n=e[s+1],o=Math.max(r,t),l=Math.min(h,n);if(o<=l&&new fs(o+a,l+a,o,l).addToSet(i),n>h)break;s+=2}if(!l)return i;new fs(l.fromA,l.toA,l.fromB,l.toB).addToSet(i),o=l.toA,r=l.toB}}}class ds{constructor(t,e,i){this.view=t,this.state=e,this.transactions=i,this.flags=0,this.startState=t.state,this.changes=kt.empty(this.startState.doc.length);for(let t of i)this.changes=this.changes.compose(t.changes);let n=[];this.changes.iterChangedRanges((t,e,i,s)=>n.push(new fs(t,e,i,s))),this.changedRanges=n}static create(t,e,i){return new ds(t,e,i)}get viewportChanged(){return(4&this.flags)>0}get viewportMoved(){return(8&this.flags)>0}get heightChanged(){return(2&this.flags)>0}get geometryChanged(){return this.docChanged||(18&this.flags)>0}get focusChanged(){return(1&this.flags)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(t=>t.selection)}get empty(){return 0==this.flags&&0==this.transactions.length}}class us extends Ii{get length(){return this.view.state.doc.length}constructor(t){super(),this.view=t,this.decorations=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.markedForComposition=new Set,this.editContextFormatting=nn.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.setDOM(t.contentDOM),this.children=[new hn],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new fs(0,0,0,t.state.doc.length)],0,null)}update(t){var e;let i=t.changedRanges;this.minWidth>0&&i.length&&(i.every(({fromA:t,toA:e})=>e<this.minWidthFrom||t>this.minWidthTo)?(this.minWidthFrom=t.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=t.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(t);let n=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&((null===(e=this.domChanged)||void 0===e?void 0:e.newSel)?n=this.domChanged.newSel.head:function(t,e){let i=!1;e&&t.iterChangedRanges((t,n)=>{t<e.to&&n>e.from&&(i=!0)});return i}(t.changes,this.hasComposition)||t.selectionSet||(n=t.state.selection.main.head));let s=n>-1?function(t,e,i){let n=ps(t,i);if(!n)return null;let{node:s,from:o,to:r}=n,l=s.nodeValue;if(/[\n\r]/.test(l))return null;if(t.state.doc.sliceString(n.from,n.to)!=l)return null;let a=e.invertedDesc,h=new fs(a.mapPos(o),a.mapPos(r),o,r),c=[];for(let e=s.parentNode;;e=e.parentNode){let i=Ii.get(e);if(i instanceof Wi)c.push({node:e,deco:i.mark});else{if(i instanceof hn||"DIV"==e.nodeName&&e.parentNode==t.contentDOM)return{range:h,text:s,marks:c,line:e};if(e==t.contentDOM)return null;c.push({node:e,deco:new sn({inclusive:!0,attributes:Zi(e),tagName:e.tagName.toLowerCase()})})}}}(this.view,t.changes,n):null;if(this.domChanged=null,this.hasComposition){this.markedForComposition.clear();let{from:e,to:n}=this.hasComposition;i=new fs(e,n,t.changes.mapPos(e,-1),t.changes.mapPos(n,1)).addToSet(i.slice())}this.hasComposition=s?{from:s.range.fromB,to:s.range.toB}:null,(fi.ie||fi.chrome)&&!s&&t&&t.state.doc.lines!=t.startState.doc.lines&&(this.forceSelection=!0);let o=function(t,e,i){let n=new ms;return Te.compare(t,e,i,n),n.changes}(this.decorations,this.updateDeco(),t.changes);return i=fs.extendWithRanges(i,o),!!(7&this.flags||0!=i.length)&&(this.updateInner(i,t.startState.doc.length,s),t.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(t,e,i){this.view.viewState.mustMeasureContent=!0,this.updateChildren(t,e,i);let{observer:n}=this.view;n.ignore(()=>{this.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let t=fi.chrome||fi.ios?{node:n.selectionRange.focusNode,written:!1}:void 0;this.sync(this.view,t),this.flags&=-8,t&&(t.written||n.selectionRange.focusNode!=t.node)&&(this.forceSelection=!0),this.dom.style.height=""}),this.markedForComposition.forEach(t=>t.flags&=-9);let s=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let t of this.children)t instanceof cn&&t.widget instanceof fn&&s.push(t.dom);n.updateGaps(s)}updateChildren(t,e,i){let n=i?i.range.addToSet(t.slice()):t,s=this.childCursor(e);for(let t=n.length-1;;t--){let e=t>=0?n[t]:null;if(!e)break;let o,r,l,a,{fromA:h,toA:c,fromB:f,toB:d}=e;if(i&&i.range.fromB<d&&i.range.toB>f){let t=dn.build(this.view.state.doc,f,i.range.fromB,this.decorations,this.dynamicDecorationMap),e=dn.build(this.view.state.doc,i.range.toB,d,this.decorations,this.dynamicDecorationMap);r=t.breakAtStart,l=t.openStart,a=e.openEnd;let n=this.compositionView(i);e.breakAtStart?n.breakAfter=1:e.content.length&&n.merge(n.length,n.length,e.content[0],!1,e.openStart,0)&&(n.breakAfter=e.content[0].breakAfter,e.content.shift()),t.content.length&&n.merge(0,0,t.content[t.content.length-1],!0,0,t.openEnd)&&t.content.pop(),o=t.content.concat(n).concat(e.content)}else({content:o,breakAtStart:r,openStart:l,openEnd:a}=dn.build(this.view.state.doc,f,d,this.decorations,this.dynamicDecorationMap));let{i:u,off:p}=s.findPos(c,1),{i:m,off:g}=s.findPos(h,-1);Vi(this,m,g,u,p,o,r,l,a)}i&&this.fixCompositionDOM(i)}updateEditContextFormatting(t){this.editContextFormatting=this.editContextFormatting.map(t.changes);for(let e of t.transactions)for(let t of e.effects)t.is(Gn)&&(this.editContextFormatting=t.value)}compositionView(t){let e=new zi(t.text.nodeValue);e.flags|=8;for(let{deco:i}of t.marks)e=new Wi(i,[e],e.length);let i=new hn;return i.append(e,0),i}fixCompositionDOM(t){let e=(t,e)=>{e.flags|=8|(e.children.some(t=>7&t.flags)?1:0),this.markedForComposition.add(e);let i=Ii.get(t);i&&i!=e&&(i.dom=null),e.setDOM(t)},i=this.childPos(t.range.fromB,1),n=this.children[i.i];e(t.line,n);for(let s=t.marks.length-1;s>=-1;s--)i=n.childPos(i.off,1),n=n.children[i.i],e(s>=0?t.marks[s].node:t.text,n)}updateSelection(t=!1,e=!1){!t&&this.view.observer.selectionRange.focusNode||this.view.observer.readSelectionRange();let i=this.view.root.activeElement,n=i==this.dom,s=!n&&!(this.view.state.facet(Jn)||this.dom.tabIndex>-1)&&pi(this.dom,this.view.observer.selectionRange)&&!(i&&this.dom.contains(i));if(!(n||e||s))return;let o=this.forceSelection;this.forceSelection=!1;let r=this.view.state.selection.main,l=this.moveToLine(this.domAtPos(r.anchor)),a=r.empty?l:this.moveToLine(this.domAtPos(r.head));if(fi.gecko&&r.empty&&!this.hasComposition&&(1==(h=l).node.nodeType&&h.node.firstChild&&(0==h.offset||"false"==h.node.childNodes[h.offset-1].contentEditable)&&(h.offset==h.node.childNodes.length||"false"==h.node.childNodes[h.offset].contentEditable))){let t=document.createTextNode("");this.view.observer.ignore(()=>l.node.insertBefore(t,l.node.childNodes[l.offset]||null)),l=a=new Ri(t,0),o=!0}var h;let c=this.view.observer.selectionRange;!o&&c.focusNode&&(gi(l.node,l.offset,c.anchorNode,c.anchorOffset)&&gi(a.node,a.offset,c.focusNode,c.focusOffset)||this.suppressWidgetCursorChange(c,r))||(this.view.observer.ignore(()=>{fi.android&&fi.chrome&&this.dom.contains(c.focusNode)&&function(t,e){for(let i=t;i&&i!=e;i=i.assignedSlot||i.parentNode)if(1==i.nodeType&&"false"==i.contentEditable)return!0;return!1}(c.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let t=di(this.view.root);if(t)if(r.empty){if(fi.gecko){let t=(e=l.node,n=l.offset,1!=e.nodeType?0:(n&&"false"==e.childNodes[n-1].contentEditable?1:0)|(n<e.childNodes.length&&"false"==e.childNodes[n].contentEditable?2:0));if(t&&3!=t){let e=(1==t?Pi:Bi)(l.node,l.offset);e&&(l=new Ri(e.node,e.offset))}}t.collapse(l.node,l.offset),null!=r.bidiLevel&&void 0!==t.caretBidiLevel&&(t.caretBidiLevel=r.bidiLevel)}else if(t.extend){t.collapse(l.node,l.offset);try{t.extend(a.node,a.offset)}catch(t){}}else{let e=document.createRange();r.anchor>r.head&&([l,a]=[a,l]),e.setEnd(a.node,a.offset),e.setStart(l.node,l.offset),t.removeAllRanges(),t.addRange(e)}else;var e,n;s&&this.view.root.activeElement==this.dom&&(this.dom.blur(),i&&i.focus())}),this.view.observer.setSelectionRange(l,a)),this.impreciseAnchor=l.precise?null:new Ri(c.anchorNode,c.anchorOffset),this.impreciseHead=a.precise?null:new Ri(c.focusNode,c.focusOffset)}suppressWidgetCursorChange(t,e){return this.hasComposition&&e.empty&&gi(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)&&this.posFromDOM(t.focusNode,t.focusOffset)==e.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:t}=this,e=t.state.selection.main,i=di(t.root),{anchorNode:n,anchorOffset:s}=t.observer.selectionRange;if(!(i&&e.empty&&e.assoc&&i.modify))return;let o=hn.find(this,e.head);if(!o)return;let r=o.posAtStart;if(e.head==r||e.head==r+o.length)return;let l=this.coordsAt(e.head,-1),a=this.coordsAt(e.head,1);if(!l||!a||l.bottom>a.top)return;let h=this.domAtPos(e.head+e.assoc);i.collapse(h.node,h.offset),i.modify("move",e.assoc<0?"forward":"backward","lineboundary"),t.observer.readSelectionRange();let c=t.observer.selectionRange;t.docView.posFromDOM(c.anchorNode,c.anchorOffset)!=e.from&&i.collapse(n,s)}moveToLine(t){let e,i=this.dom;if(t.node!=i)return t;for(let n=t.offset;!e&&n<i.childNodes.length;n++){let t=Ii.get(i.childNodes[n]);t instanceof hn&&(e=t.domAtPos(0))}for(let n=t.offset-1;!e&&n>=0;n--){let t=Ii.get(i.childNodes[n]);t instanceof hn&&(e=t.domAtPos(t.length))}return e?new Ri(e.node,e.offset,!0):t}nearest(t){for(let e=t;e;){let t=Ii.get(e);if(t&&t.rootView==this)return t;e=e.parentNode}return null}posFromDOM(t,e){let i=this.nearest(t);if(!i)throw new RangeError("Trying to find position for a DOM position outside of the document");return i.localPosFromDOM(t,e)+i.posAtStart}domAtPos(t){let{i:e,off:i}=this.childCursor().findPos(t,-1);for(;e<this.children.length-1;){let t=this.children[e];if(i<t.length||t instanceof hn)break;e++,i=0}return this.children[e].domAtPos(i)}coordsAt(t,e){let i=null,n=0;for(let s=this.length,o=this.children.length-1;o>=0;o--){let r=this.children[o],l=s-r.breakAfter,a=l-r.length;if(l<t)break;if(a<=t&&(a<t||r.covers(-1))&&(l>t||r.covers(1))&&(!i||r instanceof hn&&!(i instanceof hn&&e>=0)))i=r,n=a;else if(i&&a==t&&l==t&&r instanceof cn&&Math.abs(e)<2){if(r.deco.startSide<0)break;o&&(i=null)}s=a}return i?i.coordsAt(t-n,e):null}coordsForChar(t){let{i:e,off:i}=this.childPos(t,1),n=this.children[e];if(!(n instanceof hn))return null;for(;n.children.length;){let{i:t,off:e}=n.childPos(i,1);for(;;t++){if(t==n.children.length)return null;if((n=n.children[t]).length)break}i=e}if(!(n instanceof zi))return null;let s=gt(n.text,i);if(s==i)return null;let o=Oi(n.dom,i,s).getClientRects();for(let t=0;t<o.length;t++){let e=o[t];if(t==o.length-1||e.top<e.bottom&&e.left<e.right)return e}return null}measureVisibleLineHeights(t){let e=[],{from:i,to:n}=t,s=this.view.contentDOM.clientWidth,o=s>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,r=-1,l=this.view.textDirection==mn.LTR;for(let t=0,a=0;a<this.children.length;a++){let h=this.children[a],c=t+h.length;if(c>n)break;if(t>=i){let i=h.dom.getBoundingClientRect();if(e.push(i.height),o){let e=h.dom.lastChild,n=e?mi(e):[];if(n.length){let e=n[n.length-1],o=l?e.right-i.left:i.right-e.left;o>r&&(r=o,this.minWidth=s,this.minWidthFrom=t,this.minWidthTo=c)}}}t=c+h.breakAfter}return e}textDirectionAt(t){let{i:e}=this.childPos(t,1);return"rtl"==getComputedStyle(this.children[e].dom).direction?mn.RTL:mn.LTR}measureTextSize(){for(let t of this.children)if(t instanceof hn){let e=t.measureTextSize();if(e)return e}let t,e,i,n=document.createElement("div");return n.className="cm-line",n.style.width="99999px",n.style.position="absolute",n.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.dom.appendChild(n);let s=mi(n.firstChild)[0];t=n.getBoundingClientRect().height,e=s?s.width/27:7,i=s?s.height:t,n.remove()}),{lineHeight:t,charWidth:e,textHeight:i}}childCursor(t=this.length){let e=this.children.length;return e&&(t-=this.children[--e].length),new Hi(this.children,t,e)}computeBlockGapDeco(){let t=[],e=this.view.viewState;for(let i=0,n=0;;n++){let s=n==e.viewports.length?null:e.viewports[n],o=s?s.from-1:this.length;if(o>i){let n=(e.lineBlockAt(o).bottom-e.lineBlockAt(i).top)/this.view.scaleY;t.push(nn.replace({widget:new fn(n),block:!0,inclusive:!0,isBlockGap:!0}).range(i,o))}if(!s)break;i=s.to+1}return nn.set(t)}updateDeco(){let t=1,e=this.view.state.facet(ns).map(e=>(this.dynamicDecorationMap[t++]="function"==typeof e)?e(this.view):e),i=!1,n=this.view.state.facet(ss).map((t,e)=>{let n="function"==typeof t;return n&&(i=!0),n?t(this.view):t});for(n.length&&(this.dynamicDecorationMap[t++]=i,e.push(Te.join(n))),this.decorations=[this.editContextFormatting,...e,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];t<this.decorations.length;)this.dynamicDecorationMap[t++]=!1;return this.decorations}scrollIntoView(t){if(t.isSnapshot){let e=this.view.viewState.lineBlockAt(t.range.head);return this.view.scrollDOM.scrollTop=e.top-t.yMargin,void(this.view.scrollDOM.scrollLeft=t.xMargin)}for(let e of this.view.state.facet(Kn))try{if(e(this.view,t.range,t))return!0}catch(t){Yn(this.view.state,t,"scroll handler")}let e,{range:i}=t,n=this.coordsAt(i.head,i.empty?i.assoc:i.head>i.anchor?-1:1);if(!n)return;!i.empty&&(e=this.coordsAt(i.anchor,i.anchor>i.head?-1:1))&&(n={left:Math.min(n.left,e.left),top:Math.min(n.top,e.top),right:Math.max(n.right,e.right),bottom:Math.max(n.bottom,e.bottom)});let s=hs(this.view),o={left:n.left-s.left,top:n.top-s.top,right:n.right+s.right,bottom:n.bottom+s.bottom},{offsetWidth:r,offsetHeight:l}=this.view.scrollDOM;!function(t,e,i,n,s,o,r,l){let a=t.ownerDocument,h=a.defaultView||window;for(let c=t,f=!1;c&&!f;)if(1==c.nodeType){let t,d=c==a.body,u=1,p=1;if(d)t=ki(h);else{if(/^(fixed|sticky)$/.test(getComputedStyle(c).position)&&(f=!0),c.scrollHeight<=c.clientHeight&&c.scrollWidth<=c.clientWidth){c=c.assignedSlot||c.parentNode;continue}let e=c.getBoundingClientRect();({scaleX:u,scaleY:p}=Si(c,e)),t={left:e.left,right:e.left+c.clientWidth*u,top:e.top,bottom:e.top+c.clientHeight*p}}let m=0,g=0;if("nearest"==s)e.top<t.top?(g=e.top-(t.top+r),i>0&&e.bottom>t.bottom+g&&(g=e.bottom-t.bottom+r)):e.bottom>t.bottom&&(g=e.bottom-t.bottom+r,i<0&&e.top-g<t.top&&(g=e.top-(t.top+r)));else{let n=e.bottom-e.top,o=t.bottom-t.top;g=("center"==s&&n<=o?e.top+n/2-o/2:"start"==s||"center"==s&&i<0?e.top-r:e.bottom-o+r)-t.top}if("nearest"==n?e.left<t.left?(m=e.left-(t.left+o),i>0&&e.right>t.right+m&&(m=e.right-t.right+o)):e.right>t.right&&(m=e.right-t.right+o,i<0&&e.left<t.left+m&&(m=e.left-(t.left+o))):m=("center"==n?e.left+(e.right-e.left)/2-(t.right-t.left)/2:"start"==n==l?e.left-o:e.right-(t.right-t.left)+o)-t.left,m||g)if(d)h.scrollBy(m,g);else{let t=0,i=0;if(g){let t=c.scrollTop;c.scrollTop+=g/p,i=(c.scrollTop-t)*p}if(m){let e=c.scrollLeft;c.scrollLeft+=m/u,t=(c.scrollLeft-e)*u}e={left:e.left-t,top:e.top-i,right:e.right-t,bottom:e.bottom-i},t&&Math.abs(t-m)<1&&(n="nearest"),i&&Math.abs(i-g)<1&&(s="nearest")}if(d)break;(e.top<t.top||e.bottom>t.bottom||e.left<t.left||e.right>t.right)&&(e={left:Math.max(e.left,t.left),right:Math.min(e.right,t.right),top:Math.max(e.top,t.top),bottom:Math.min(e.bottom,t.bottom)}),c=c.assignedSlot||c.parentNode}else{if(11!=c.nodeType)break;c=c.host}}(this.view.scrollDOM,o,i.head<i.anchor?-1:1,t.x,t.y,Math.max(Math.min(t.xMargin,r),-r),Math.max(Math.min(t.yMargin,l),-l),this.view.textDirection==mn.LTR)}lineHasWidget(t){let{i:e}=this.childCursor().findPos(t);if(e==this.children.length)return!1;let i=t=>t instanceof qi||t.children.some(i);return i(this.children[e])}}function ps(t,e){let i=t.observer.selectionRange;if(!i.focusNode)return null;let n=Pi(i.focusNode,i.focusOffset),s=Bi(i.focusNode,i.focusOffset),o=n||s;if(s&&n&&s.node!=n.node){let e=Ii.get(s.node);if(!e||e instanceof zi&&e.text!=s.node.nodeValue)o=s;else if(t.docView.lastCompositionAfterCursor){let t=Ii.get(n.node);!t||t instanceof zi&&t.text!=n.node.nodeValue||(o=s)}}if(t.docView.lastCompositionAfterCursor=o!=n,!o)return null;let r=e-o.offset;return{from:r,to:r+o.node.nodeValue.length,node:o.node}}let ms=class{constructor(){this.changes=[]}compareRange(t,e){an(t,e,this.changes)}comparePoint(t,e){an(t,e,this.changes)}boundChange(t){an(t,t,this.changes)}};function gs(t,e){return e.left>t?e.left-t:Math.max(0,t-e.right)}function ws(t,e){return e.top>t?e.top-t:Math.max(0,t-e.bottom)}function vs(t,e){return t.top<e.bottom-1&&t.bottom>e.top+1}function bs(t,e){return e<t.top?{top:e,left:t.left,right:t.right,bottom:t.bottom}:t}function ys(t,e){return e>t.bottom?{top:t.top,left:t.left,right:t.right,bottom:e}:t}function xs(t,e,i){let n,s,o,r,l,a,h,c,f=!1;for(let d=t.firstChild;d;d=d.nextSibling){let t=mi(d);for(let u=0;u<t.length;u++){let p=t[u];s&&vs(s,p)&&(p=bs(ys(p,s.bottom),s.top));let m=gs(e,p),g=ws(i,p);if(0==m&&0==g)return 3==d.nodeType?ks(d,e,i):xs(d,e,i);(!n||r>g||r==g&&o>m)&&(n=d,s=p,o=m,r=g,f=!m||(e<p.left?u>0:u<t.length-1)),0==m?i>p.bottom&&(!h||h.bottom<p.bottom)?(l=d,h=p):i<p.top&&(!c||c.top>p.top)&&(a=d,c=p):h&&vs(h,p)?h=ys(h,p.bottom):c&&vs(c,p)&&(c=bs(c,p.top))}}if(h&&h.bottom>=i?(n=l,s=h):c&&c.top<=i&&(n=a,s=c),!n)return{node:t,offset:0};let d=Math.max(s.left,Math.min(s.right,e));return 3==n.nodeType?ks(n,d,i):f&&"false"!=n.contentEditable?xs(n,d,i):{node:t,offset:Array.prototype.indexOf.call(t.childNodes,n)+(e>=(s.left+s.right)/2?1:0)}}function ks(t,e,i){let n=t.nodeValue.length,s=-1,o=1e9,r=0;for(let l=0;l<n;l++){let n=Oi(t,l,l+1).getClientRects();for(let a=0;a<n.length;a++){let h=n[a];if(h.top==h.bottom)continue;r||(r=e-h.left);let c=(h.top>i?h.top-i:i-h.bottom)-1;if(h.left-1<=e&&h.right+1>=e&&c<o){let i=e>=(h.left+h.right)/2,n=i;if(fi.chrome||fi.gecko){let e=Oi(t,l).getBoundingClientRect();Math.abs(e.left-h.right)<.1&&(n=!i)}if(c<=0)return{node:t,offset:l+(n?1:0)};s=l+(n?1:0),o=c}}}return{node:t,offset:s>-1?s:r>0?t.nodeValue.length:0}}function Ss(t,e,i,n=-1){var s,o;let r,l=t.contentDOM.getBoundingClientRect(),a=l.top+t.viewState.paddingTop,{docHeight:h}=t.viewState,{x:c,y:f}=e,d=f-a;if(d<0)return 0;if(d>h)return t.state.doc.length;for(let e=t.viewState.heightOracle.textHeight/2,s=!1;r=t.elementAtHeight(d),r.type!=en.Text;)for(;d=n>0?r.bottom+e:r.top-e,!(d>=0&&d<=h);){if(s)return i?null:0;s=!0,n=-n}f=a+d;let u=r.from;if(u<t.viewport.from)return 0==t.viewport.from?0:i?null:Cs(t,l,r,c,f);if(u>t.viewport.to)return t.viewport.to==t.state.doc.length?t.state.doc.length:i?null:Cs(t,l,r,c,f);let p=t.dom.ownerDocument,m=t.root.elementFromPoint?t.root:p,g=m.elementFromPoint(c,f);g&&!t.contentDOM.contains(g)&&(g=null),g||(c=Math.max(l.left+1,Math.min(l.right-1,c)),g=m.elementFromPoint(c,f),g&&!t.contentDOM.contains(g)&&(g=null));let w,v=-1;if(g&&0!=(null===(s=t.docView.nearest(g))||void 0===s?void 0:s.isEditable)){if(p.caretPositionFromPoint){let t=p.caretPositionFromPoint(c,f);t&&({offsetNode:w,offset:v}=t)}else if(p.caretRangeFromPoint){let t=p.caretRangeFromPoint(c,f);t&&({startContainer:w,startOffset:v}=t)}w&&(!t.contentDOM.contains(w)||fi.safari&&function(t,e,i){return As(t,e,i)}(w,v,c)||fi.chrome&&function(t,e,i){if(0!=e)return As(t,e,i);for(let e=t;;){let t=e.parentNode;if(!t||1!=t.nodeType||t.firstChild!=e)return!1;if(t.classList.contains("cm-line"))break;e=t}let n=1==t.nodeType?t.getBoundingClientRect():Oi(t,0,Math.max(t.nodeValue.length,1)).getBoundingClientRect();return i-n.left>5}(w,v,c))&&(w=void 0),w&&(v=Math.min(yi(w),v))}if(!w||!t.docView.dom.contains(w)){let e=hn.find(t.docView,u);if(!e)return d>r.top+r.height/2?r.to:r.from;({node:w,offset:v}=xs(e.dom,c,f))}let b=t.docView.nearest(w);if(!b)return null;if(b.isWidget&&1==(null===(o=b.dom)||void 0===o?void 0:o.nodeType)){let t=b.dom.getBoundingClientRect();return e.y<t.top||e.y<=t.bottom&&e.x<=(t.left+t.right)/2?b.posAtStart:b.posAtEnd}return b.localPosFromDOM(w,v)+b.posAtStart}function Cs(t,e,i,n,s){let o=Math.round((n-e.left)*t.defaultCharacterWidth);if(t.lineWrapping&&i.height>1.5*t.defaultLineHeight){let e=t.viewState.heightOracle.textHeight;o+=Math.floor((s-i.top-.5*(t.defaultLineHeight-e))/e)*t.viewState.heightOracle.lineLength}let r=t.state.sliceDoc(i.from,i.to);return i.from+function(t,e,i){for(let n=0,s=0;;){if(s>=e)return n;if(n==t.length)break;s+=9==t.charCodeAt(n)?i-s%i:1,n=gt(t,n)}return t.length}(r,o,t.state.tabSize)}function As(t,e,i){let n,s=t;if(3!=t.nodeType||e!=(n=t.nodeValue.length))return!1;for(;;){let t=s.nextSibling;if(t){if("BR"==t.nodeName)break;return!1}{let t=s.parentNode;if(!t||"DIV"==t.nodeName)break;s=t}}return Oi(t,n-1,n).getBoundingClientRect().right>i}function Ms(t,e,i){let n=t.lineBlockAt(e);if(Array.isArray(n.type)){let t;for(let s of n.type){if(s.from>e)break;if(!(s.to<e)){if(s.from<e&&s.to>e)return s;t&&(s.type!=en.Text||t.type==s.type&&!(i<0?s.from<e:s.to>e))||(t=s)}}return t||n}return n}function Ts(t,e,i,n){let s=t.state.doc.lineAt(e.head),o=t.bidiSpans(s),r=t.textDirectionAt(s.from);for(let l=e,a=null;;){let e=Pn(s,o,r,l,i),h=En;if(!e){if(s.number==(i?t.state.doc.lines:1))return l;h="\n",s=t.state.doc.line(s.number+(i?1:-1)),o=t.bidiSpans(s),e=t.visualLineSide(s,!i)}if(a){if(!a(h))return l}else{if(!n)return e;a=n(h)}l=e}}function Os(t,e,i){for(;;){let n=0;for(let s of t)s.between(e-1,e+1,(t,s,o)=>{if(e>t&&e<s){let o=n||i||(e-t<s-e?-1:1);e=o<0?t:s,n=o}});if(!n)return e}}function Ds(t,e){let i=null;for(let n=0;n<e.ranges.length;n++){let s=e.ranges[n],o=null;if(s.empty){let e=Os(t,s.from,0);e!=s.from&&(o=Lt.cursor(e,-1))}else{let e=Os(t,s.from,-1),i=Os(t,s.to,1);e==s.from&&i==s.to||(o=Lt.range(s.from==s.anchor?e:i,s.from==s.head?e:i))}o&&(i||(i=e.ranges.slice()),i[n]=o)}return i?Lt.create(i,e.mainIndex):e}function Ls(t,e,i){let n=Os(t.state.facet(os).map(e=>e(t)),i.from,e.head>i.from?-1:1);return n==i.from?i:Lt.cursor(n,n<i.from?1:-1)}const Es="";class Ps{constructor(t,e){this.points=t,this.text="",this.lineSeparator=e.facet(xe.lineSeparator)}append(t){this.text+=t}lineBreak(){this.text+=Es}readRange(t,e){if(!t)return this;let i=t.parentNode;for(let n=t;;){this.findPointBefore(i,n);let t=this.text.length;this.readNode(n);let s=n.nextSibling;if(s==e)break;let o=Ii.get(n),r=Ii.get(s);(o&&r?o.breakAfter:(o?o.breakAfter:vi(n))||vi(s)&&("BR"!=n.nodeName||n.cmIgnore)&&this.text.length>t)&&!Rs(s,e)&&this.lineBreak(),n=s}return this.findPointBefore(i,e),this}readTextNode(t){let e=t.nodeValue;for(let i of this.points)i.node==t&&(i.pos=this.text.length+Math.min(i.offset,e.length));for(let i=0,n=this.lineSeparator?null:/\r\n?|\n/g;;){let s,o=-1,r=1;if(this.lineSeparator?(o=e.indexOf(this.lineSeparator,i),r=this.lineSeparator.length):(s=n.exec(e))&&(o=s.index,r=s[0].length),this.append(e.slice(i,o<0?e.length:o)),o<0)break;if(this.lineBreak(),r>1)for(let e of this.points)e.node==t&&e.pos>this.text.length&&(e.pos-=r-1);i=o+r}}readNode(t){if(t.cmIgnore)return;let e=Ii.get(t),i=e&&e.overrideDOMText;if(null!=i){this.findPointInside(t,i.length);for(let t=i.iter();!t.next().done;)t.lineBreak?this.lineBreak():this.append(t.value)}else 3==t.nodeType?this.readTextNode(t):"BR"==t.nodeName?t.nextSibling&&this.lineBreak():1==t.nodeType&&this.readRange(t.firstChild,null)}findPointBefore(t,e){for(let i of this.points)i.node==t&&t.childNodes[i.offset]==e&&(i.pos=this.text.length)}findPointInside(t,e){for(let i of this.points)(3==t.nodeType?i.node==t:t.contains(i.node))&&(i.pos=this.text.length+(Bs(t,i.node,i.offset)?e:0))}}function Bs(t,e,i){for(;;){if(!e||i<yi(e))return!1;if(e==t)return!0;i=wi(e)+1,e=e.parentNode}}function Rs(t,e){let i;for(;t!=e&&t;t=t.nextSibling){let e=Ii.get(t);if(!(null==e?void 0:e.isWidget)&&!t.cmIgnore)return!1;e&&(i||(i=[])).push(e)}if(i)for(let t of i){let e=t.overrideDOMText;if(null==e?void 0:e.length)return!1}return!0}class Ns{constructor(t,e){this.node=t,this.offset=e,this.pos=-1}}class Is{constructor(t,e,i,n){this.typeOver=n,this.bounds=null,this.text="",this.domChanged=e>-1;let{impreciseHead:s,impreciseAnchor:o}=t.docView;if(t.state.readOnly&&e>-1)this.newSel=null;else if(e>-1&&(this.bounds=t.docView.domBoundsAround(e,i,0))){let e=s||o?[]:function(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:i,anchorOffset:n,focusNode:s,focusOffset:o}=t.observer.selectionRange;i&&(e.push(new Ns(i,n)),s==i&&o==n||e.push(new Ns(s,o)));return e}(t),i=new Ps(e,t.state);i.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=i.text,this.newSel=function(t,e){if(0==t.length)return null;let i=t[0].pos,n=2==t.length?t[1].pos:i;return i>-1&&n>-1?Lt.single(i+e,n+e):null}(e,this.bounds.from)}else{let e=t.observer.selectionRange,i=s&&s.node==e.focusNode&&s.offset==e.focusOffset||!ui(t.contentDOM,e.focusNode)?t.state.selection.main.head:t.docView.posFromDOM(e.focusNode,e.focusOffset),n=o&&o.node==e.anchorNode&&o.offset==e.anchorOffset||!ui(t.contentDOM,e.anchorNode)?t.state.selection.main.anchor:t.docView.posFromDOM(e.anchorNode,e.anchorOffset),r=t.viewport;if((fi.ios||fi.chrome)&&t.state.selection.main.empty&&i!=n&&(r.from>0||r.to<t.state.doc.length)){let e=Math.min(i,n),s=Math.max(i,n),o=r.from-e,l=r.to-s;0!=o&&1!=o&&0!=e||0!=l&&-1!=l&&s!=t.state.doc.length||(i=0,n=t.state.doc.length)}t.inputState.composing>-1&&t.state.selection.ranges.length>1?this.newSel=t.state.selection.replaceRange(Lt.range(n,i)):this.newSel=Lt.single(n,i)}}}function js(t,e){let i,{newSel:n}=e,s=t.state.selection.main,o=t.inputState.lastKeyTime>Date.now()-100?t.inputState.lastKeyCode:-1;if(e.bounds){let{from:n,to:r}=e.bounds,l=s.from,a=null;(8===o||fi.android&&e.text.length<r-n)&&(l=s.to,a="end");let h=Vs(t.state.doc.sliceString(n,r,Es),e.text,l-n,a);h&&(fi.chrome&&13==o&&h.toB==h.from+2&&e.text.slice(h.from,h.toB)==Es+Es&&h.toB--,i={from:n+h.from,to:n+h.toA,insert:rt.of(e.text.slice(h.from,h.toB).split(Es))})}else n&&(!t.hasFocus&&t.state.facet(Jn)||n.main.eq(s))&&(n=null);if(!i&&!n)return!1;if(!i&&e.typeOver&&!s.empty&&n&&n.main.empty?i={from:s.from,to:s.to,insert:t.state.doc.slice(s.from,s.to)}:(fi.mac||fi.android)&&i&&i.from==i.to&&i.from==s.head-1&&/^\. ?$/.test(i.insert.toString())&&"off"==t.contentDOM.getAttribute("autocorrect")?(n&&2==i.insert.length&&(n=Lt.single(n.main.anchor-1,n.main.head-1)),i={from:i.from,to:i.to,insert:rt.of([i.insert.toString().replace("."," ")])}):i&&i.from>=s.from&&i.to<=s.to&&(i.from!=s.from||i.to!=s.to)&&s.to-s.from-(i.to-i.from)<=4?i={from:s.from,to:s.to,insert:t.state.doc.slice(s.from,i.from).append(i.insert).append(t.state.doc.slice(i.to,s.to))}:t.state.doc.lineAt(s.from).to<s.to&&t.docView.lineHasWidget(s.to)&&t.inputState.insertingTextAt>Date.now()-50?i={from:s.from,to:s.to,insert:t.state.toText(t.inputState.insertingText)}:fi.chrome&&i&&i.from==i.to&&i.from==s.head&&"\n "==i.insert.toString()&&t.lineWrapping&&(n&&(n=Lt.single(n.main.anchor-1,n.main.head-1)),i={from:s.from,to:s.to,insert:rt.of([" "])}),i)return Hs(t,i,n,o);if(n&&!n.main.eq(s)){let e=!1,i="select";return t.inputState.lastSelectionTime>Date.now()-50&&("select"==t.inputState.lastSelectionOrigin&&(e=!0),i=t.inputState.lastSelectionOrigin,"select.pointer"==i&&(n=Ds(t.state.facet(os).map(e=>e(t)),n))),t.dispatch({selection:n,scrollIntoView:e,userEvent:i}),!0}return!1}function Hs(t,e,i,n=-1){if(fi.ios&&t.inputState.flushIOSKey(e))return!0;let s=t.state.selection.main;if(fi.android&&(e.to==s.to&&(e.from==s.from||e.from==s.from-1&&" "==t.state.sliceDoc(e.from,s.from))&&1==e.insert.length&&2==e.insert.lines&&Di(t.contentDOM,"Enter",13)||(e.from==s.from-1&&e.to==s.to&&0==e.insert.length||8==n&&e.insert.length<e.to-e.from&&e.to>s.head)&&Di(t.contentDOM,"Backspace",8)||e.from==s.from&&e.to==s.to+1&&0==e.insert.length&&Di(t.contentDOM,"Delete",46)))return!0;let o,r=e.insert.toString();t.inputState.composing>=0&&t.inputState.composing++;let l=()=>o||(o=function(t,e,i){let n,s=t.state,o=s.selection.main,r=-1;if(e.from==e.to&&e.from<o.from||e.from>o.to){let i=e.from<o.from?-1:1,n=i<0?o.from:o.to,l=Os(s.facet(os).map(e=>e(t)),n,i);e.from==l&&(r=l)}if(r>-1)n={changes:e,selection:Lt.cursor(e.from+e.insert.length,-1)};else if(e.from>=o.from&&e.to<=o.to&&e.to-e.from>=(o.to-o.from)/3&&(!i||i.main.empty&&i.main.from==e.from+e.insert.length)&&t.inputState.composing<0){let i=o.from<e.from?s.sliceDoc(o.from,e.from):"",r=o.to>e.to?s.sliceDoc(e.to,o.to):"";n=s.replaceSelection(t.state.toText(i+e.insert.sliceString(0,void 0,t.state.lineBreak)+r))}else{let r=s.changes(e),l=i&&i.main.to<=r.newLength?i.main:void 0;if(s.selection.ranges.length>1&&(t.inputState.composing>=0||t.inputState.compositionPendingChange)&&e.to<=o.to+10&&e.to>=o.to-10){let a,h=t.state.sliceDoc(e.from,e.to),c=i&&ps(t,i.main.head);if(c){let t=e.insert.length-(e.to-e.from);a={from:c.from,to:c.to-t}}else a=t.state.doc.lineAt(o.head);let f=o.to-e.to;n=s.changeByRange(i=>{if(i.from==o.from&&i.to==o.to)return{changes:r,range:l||i.map(r)};let n=i.to-f,c=n-h.length;if(t.state.sliceDoc(c,n)!=h||n>=a.from&&c<=a.to)return{range:i};let d=s.changes({from:c,to:n,insert:e.insert}),u=i.to-o.to;return{changes:d,range:l?Lt.range(Math.max(0,l.anchor+u),Math.max(0,l.head+u)):i.map(d)}})}else n={changes:r,selection:l&&s.selection.replaceRange(l)}}let l="input.type";(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,l+=".compose",t.inputState.compositionFirstChange&&(l+=".start",t.inputState.compositionFirstChange=!1));return s.update(n,{userEvent:l,scrollIntoView:!0})}(t,e,i));return t.state.facet(Vn).some(i=>i(t,e.from,e.to,r,l))||t.dispatch(l()),!0}function Vs(t,e,i,n){let s=Math.min(t.length,e.length),o=0;for(;o<s&&t.charCodeAt(o)==e.charCodeAt(o);)o++;if(o==s&&t.length==e.length)return null;let r=t.length,l=e.length;for(;r>0&&l>0&&t.charCodeAt(r-1)==e.charCodeAt(l-1);)r--,l--;if("end"==n){i-=r+Math.max(0,o-Math.min(r,l))-o}if(r<o&&t.length<e.length){o-=i<=o&&i>=r?o-i:0,l=o+(l-r),r=o}else if(l<o){o-=i<=o&&i>=l?o-i:0,r=o+(r-l),l=o}return{from:o,toA:r,toB:l}}class Fs{setSelectionOrigin(t){this.lastSelectionOrigin=t,this.lastSelectionTime=Date.now()}constructor(t){this.view=t,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.pendingIOSKey=void 0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=t.hasFocus,fi.safari&&t.contentDOM.addEventListener("input",()=>null),fi.gecko&&function(t){po.has(t)||(po.add(t),t.addEventListener("copy",()=>{}),t.addEventListener("cut",()=>{}))}(t.contentDOM.ownerDocument)}handleEvent(t){(function(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let i,n=e.target;n!=t.contentDOM;n=n.parentNode)if(!n||11==n.nodeType||(i=Ii.get(n))&&i.ignoreEvent(e))return!1;return!0})(this.view,t)&&!this.ignoreDuringComposition(t)&&("keydown"==t.type&&this.keydown(t)||(0!=this.view.updateState?Promise.resolve().then(()=>this.runHandlers(t.type,t)):this.runHandlers(t.type,t)))}runHandlers(t,e){let i=this.handlers[t];if(i){for(let t of i.observers)t(this.view,e);for(let t of i.handlers){if(e.defaultPrevented)break;if(t(this.view,e)){e.preventDefault();break}}}}ensureHandlers(t){let e=Ws(t),i=this.handlers,n=this.view.contentDOM;for(let t in e)if("scroll"!=t){let s=!e[t].handlers.length,o=i[t];o&&s!=!o.handlers.length&&(n.removeEventListener(t,this.handleEvent),o=null),o||n.addEventListener(t,this.handleEvent,{passive:s})}for(let t in i)"scroll"==t||e[t]||n.removeEventListener(t,this.handleEvent);this.handlers=e}keydown(t){if(this.lastKeyCode=t.keyCode,this.lastKeyTime=Date.now(),9==t.keyCode&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&27!=t.keyCode&&Ks.indexOf(t.keyCode)<0&&(this.tabFocusMode=-1),fi.android&&fi.chrome&&!t.synthetic&&(13==t.keyCode||8==t.keyCode))return this.view.observer.delayAndroidKey(t.key,t.keyCode),!0;let e;return!fi.ios||t.synthetic||t.altKey||t.metaKey||!((e=qs.find(e=>e.keyCode==t.keyCode))&&!t.ctrlKey||_s.indexOf(t.key)>-1&&t.ctrlKey&&!t.shiftKey)?(229!=t.keyCode&&this.view.observer.forceFlush(),!1):(this.pendingIOSKey=e||t,setTimeout(()=>this.flushIOSKey(),250),!0)}flushIOSKey(t){let e=this.pendingIOSKey;return!!e&&(!("Enter"==e.key&&t&&t.from<t.to&&/^\S+$/.test(t.insert.toString()))&&(this.pendingIOSKey=void 0,Di(this.view.contentDOM,e.key,e.keyCode,e instanceof KeyboardEvent?e:void 0)))}ignoreDuringComposition(t){return!(!/^key/.test(t.type)||t.synthetic)&&(this.composing>0||!!(fi.safari&&!fi.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100)&&(this.compositionPendingKey=!1,!0))}startMouseSelection(t){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=t}update(t){this.view.observer.update(t),this.mouseSelection&&this.mouseSelection.update(t),this.draggedContent&&t.docChanged&&(this.draggedContent=this.draggedContent.map(t.changes)),t.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function zs(t,e){return(i,n)=>{try{return e.call(t,n,i)}catch(t){Yn(i.state,t)}}}function Ws(t){let e=Object.create(null);function i(t){return e[t]||(e[t]={observers:[],handlers:[]})}for(let e of t){let t=e.spec,n=t&&t.plugin.domEventHandlers,s=t&&t.plugin.domEventObservers;if(n)for(let t in n){let s=n[t];s&&i(t).handlers.push(zs(e.value,s))}if(s)for(let t in s){let n=s[t];n&&i(t).observers.push(zs(e.value,n))}}for(let t in Gs)i(t).handlers.push(Gs[t]);for(let t in Ys)i(t).observers.push(Ys[t]);return e}const qs=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],_s="dthko",Ks=[16,17,18,20,91,92,224,225];function $s(t){return.7*Math.max(0,t)+8}class Us{constructor(t,e,i,n){this.view=t,this.startEvent=e,this.style=i,this.mustSelect=n,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=e,this.scrollParents=function(t){let e,i,n=t.ownerDocument;for(let s=t.parentNode;s&&!(s==n.body||e&&i);)if(1==s.nodeType)!i&&s.scrollHeight>s.clientHeight&&(i=s),!e&&s.scrollWidth>s.clientWidth&&(e=s),s=s.assignedSlot||s.parentNode;else{if(11!=s.nodeType)break;s=s.host}return{x:e,y:i}}(t.contentDOM),this.atoms=t.state.facet(os).map(e=>e(t));let s=t.contentDOM.ownerDocument;s.addEventListener("mousemove",this.move=this.move.bind(this)),s.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=e.shiftKey,this.multiple=t.state.facet(xe.allowMultipleSelections)&&function(t,e){let i=t.state.facet(Rn);return i.length?i[0](e):fi.mac?e.metaKey:e.ctrlKey}(t,e),this.dragging=!(!function(t,e){let{main:i}=t.state.selection;if(i.empty)return!1;let n=di(t.root);if(!n||0==n.rangeCount)return!0;let s=n.getRangeAt(0).getClientRects();for(let t=0;t<s.length;t++){let i=s[t];if(i.left<=e.clientX&&i.right>=e.clientX&&i.top<=e.clientY&&i.bottom>=e.clientY)return!0}return!1}(t,e)||1!=lo(e))&&null}start(t){!1===this.dragging&&this.select(t)}move(t){if(0==t.buttons)return this.destroy();if(this.dragging||null==this.dragging&&(e=this.startEvent,i=t,Math.max(Math.abs(e.clientX-i.clientX),Math.abs(e.clientY-i.clientY))<10))return;var e,i;this.select(this.lastEvent=t);let n=0,s=0,o=0,r=0,l=this.view.win.innerWidth,a=this.view.win.innerHeight;this.scrollParents.x&&({left:o,right:l}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:r,bottom:a}=this.scrollParents.y.getBoundingClientRect());let h=hs(this.view);t.clientX-h.left<=o+6?n=-$s(o-t.clientX):t.clientX+h.right>=l-6&&(n=$s(t.clientX-l)),t.clientY-h.top<=r+6?s=-$s(r-t.clientY):t.clientY+h.bottom>=a-6&&(s=$s(t.clientY-a)),this.setScrollSpeed(n,s)}up(t){null==this.dragging&&this.select(this.lastEvent),this.dragging||t.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let t=this.view.contentDOM.ownerDocument;t.removeEventListener("mousemove",this.move),t.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(t,e){this.scrollSpeed={x:t,y:e},t||e?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:t,y:e}=this.scrollSpeed;t&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=t,t=0),e&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=e,e=0),(t||e)&&this.view.win.scrollBy(t,e),!1===this.dragging&&this.select(this.lastEvent)}select(t){let{view:e}=this,i=Ds(this.atoms,this.style.get(t,this.extend,this.multiple));!this.mustSelect&&i.eq(e.state.selection,!1===this.dragging)||this.view.dispatch({selection:i,userEvent:"select.pointer"}),this.mustSelect=!1}update(t){t.transactions.some(t=>t.isUserEvent("input.type"))?this.destroy():this.style.update(t)&&setTimeout(()=>this.select(this.lastEvent),20)}}const Gs=Object.create(null),Ys=Object.create(null),Js=fi.ie&&fi.ie_version<15||fi.ios&&fi.webkit_version<604;function Xs(t,e,i){for(let n of t.facet(e))i=n(i,t);return i}function Qs(t,e){e=Xs(t.state,zn,e);let i,{state:n}=t,s=1,o=n.toText(e),r=o.lines==n.selection.ranges.length;if(null!=ho&&n.selection.ranges.every(t=>t.empty)&&ho==o.toString()){let t=-1;i=n.changeByRange(i=>{let l=n.doc.lineAt(i.from);if(l.from==t)return{range:i};t=l.from;let a=n.toText((r?o.line(s++).text:e)+n.lineBreak);return{changes:{from:l.from,insert:a},range:Lt.cursor(i.from+a.length)}})}else i=r?n.changeByRange(t=>{let e=o.line(s++);return{changes:{from:t.from,to:t.to,insert:e.text},range:Lt.cursor(t.from+e.length)}}):n.replaceSelection(o);t.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}function Zs(t,e,i,n){if(1==n)return Lt.cursor(e,i);if(2==n)return function(t,e,i=1){let n=t.charCategorizer(e),s=t.doc.lineAt(e),o=e-s.from;if(0==s.length)return Lt.cursor(e);0==o?i=1:o==s.length&&(i=-1);let r=o,l=o;i<0?r=gt(s.text,o,!1):l=gt(s.text,o);let a=n(s.text.slice(r,l));for(;r>0;){let t=gt(s.text,r,!1);if(n(s.text.slice(t,r))!=a)break;r=t}for(;l<s.length;){let t=gt(s.text,l);if(n(s.text.slice(l,t))!=a)break;l=t}return Lt.range(r+s.from,l+s.from)}(t.state,e,i);{let i=hn.find(t.docView,e),n=t.state.doc.lineAt(i?i.posAtEnd:e),s=i?i.posAtStart:n.from,o=i?i.posAtEnd:n.to;return o<t.state.doc.length&&o==n.to&&o++,Lt.range(s,o)}}Ys.scroll=t=>{t.inputState.lastScrollTop=t.scrollDOM.scrollTop,t.inputState.lastScrollLeft=t.scrollDOM.scrollLeft},Gs.keydown=(t,e)=>(t.inputState.setSelectionOrigin("select"),27==e.keyCode&&0!=t.inputState.tabFocusMode&&(t.inputState.tabFocusMode=Date.now()+2e3),!1),Ys.touchstart=(t,e)=>{t.inputState.lastTouchTime=Date.now(),t.inputState.setSelectionOrigin("select.pointer")},Ys.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")},Gs.mousedown=(t,e)=>{if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return!1;let i=null;for(let n of t.state.facet(In))if(i=n(t,e),i)break;if(i||0!=e.button||(i=function(t,e){let i=io(t,e),n=lo(e),s=t.state.selection;return{update(t){t.docChanged&&(i.pos=t.changes.mapPos(i.pos),s=s.map(t.changes))},get(e,o,r){let l,a=io(t,e),h=Zs(t,a.pos,a.bias,n);if(i.pos!=a.pos&&!o){let e=Zs(t,i.pos,i.bias,n),s=Math.min(e.from,h.from),o=Math.max(e.to,h.to);h=s<h.from?Lt.range(s,o):Lt.range(o,s)}return o?s.replaceRange(s.main.extend(h.from,h.to)):r&&1==n&&s.ranges.length>1&&(l=function(t,e){for(let i=0;i<t.ranges.length;i++){let{from:n,to:s}=t.ranges[i];if(n<=e&&s>=e)return Lt.create(t.ranges.slice(0,i).concat(t.ranges.slice(i+1)),t.mainIndex==i?0:t.mainIndex-(t.mainIndex>i?1:0))}return null}(s,a.pos))?l:r?s.addRange(h):Lt.create([h])}}}(t,e)),i){let n=!t.hasFocus;t.inputState.startMouseSelection(new Us(t,e,i,n)),n&&t.observer.ignore(()=>{Ti(t.contentDOM);let e=t.root.activeElement;e&&!e.contains(t.contentDOM)&&e.blur()});let s=t.inputState.mouseSelection;if(s)return s.start(e),!1===s.dragging}else t.inputState.setSelectionOrigin("select.pointer");return!1};let to=(t,e,i)=>e>=i.top&&e<=i.bottom&&t>=i.left&&t<=i.right;function eo(t,e,i,n){let s=hn.find(t.docView,e);if(!s)return 1;let o=e-s.posAtStart;if(0==o)return 1;if(o==s.length)return-1;let r=s.coordsAt(o,-1);if(r&&to(i,n,r))return-1;let l=s.coordsAt(o,1);return l&&to(i,n,l)?1:r&&r.bottom>=n?-1:1}function io(t,e){let i=t.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:i,bias:eo(t,i,e.clientX,e.clientY)}}const no=fi.ie&&fi.ie_version<=11;let so=null,oo=0,ro=0;function lo(t){if(!no)return t.detail;let e=so,i=ro;return so=t,ro=Date.now(),oo=!e||i>Date.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(oo+1)%3:1}function ao(t,e,i,n){if(!(i=Xs(t.state,zn,i)))return;let s=t.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:o}=t.inputState,r=n&&o&&function(t,e){let i=t.state.facet(Nn);return i.length?i[0](e):fi.mac?!e.altKey:!e.ctrlKey}(t,e)?{from:o.from,to:o.to}:null,l={from:s,insert:i},a=t.state.changes(r?[r,l]:l);t.focus(),t.dispatch({changes:a,selection:{anchor:a.mapPos(s,-1),head:a.mapPos(s,1)},userEvent:r?"move.drop":"input.drop"}),t.inputState.draggedContent=null}Gs.dragstart=(t,e)=>{let{selection:{main:i}}=t.state;if(e.target.draggable){let n=t.docView.nearest(e.target);if(n&&n.isWidget){let t=n.posAtStart,e=t+n.length;(t>=i.to||e<=i.from)&&(i=Lt.range(t,e))}}let{inputState:n}=t;return n.mouseSelection&&(n.mouseSelection.dragging=!0),n.draggedContent=i,e.dataTransfer&&(e.dataTransfer.setData("Text",Xs(t.state,Wn,t.state.sliceDoc(i.from,i.to))),e.dataTransfer.effectAllowed="copyMove"),!1},Gs.dragend=t=>(t.inputState.draggedContent=null,!1),Gs.drop=(t,e)=>{if(!e.dataTransfer)return!1;if(t.state.readOnly)return!0;let i=e.dataTransfer.files;if(i&&i.length){let n=Array(i.length),s=0,o=()=>{++s==i.length&&ao(t,e,n.filter(t=>null!=t).join(t.state.lineBreak),!1)};for(let t=0;t<i.length;t++){let e=new FileReader;e.onerror=o,e.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(e.result)||(n[t]=e.result),o()},e.readAsText(i[t])}return!0}{let i=e.dataTransfer.getData("Text");if(i)return ao(t,e,i,!0),!0}return!1},Gs.paste=(t,e)=>{if(t.state.readOnly)return!0;t.observer.flush();let i=Js?null:e.clipboardData;return i?(Qs(t,i.getData("text/plain")||i.getData("text/uri-list")),!0):(function(t){let e=t.dom.parentNode;if(!e)return;let i=e.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.focus(),setTimeout(()=>{t.focus(),i.remove(),Qs(t,i.value)},50)}(t),!1)};let ho=null;Gs.copy=Gs.cut=(t,e)=>{let{text:i,ranges:n,linewise:s}=function(t){let e=[],i=[],n=!1;for(let n of t.selection.ranges)n.empty||(e.push(t.sliceDoc(n.from,n.to)),i.push(n));if(!e.length){let s=-1;for(let{from:n}of t.selection.ranges){let o=t.doc.lineAt(n);o.number>s&&(e.push(o.text),i.push({from:o.from,to:Math.min(t.doc.length,o.to+1)})),s=o.number}n=!0}return{text:Xs(t,Wn,e.join(t.lineBreak)),ranges:i,linewise:n}}(t.state);if(!i&&!s)return!1;ho=s?i:null,"cut"!=e.type||t.state.readOnly||t.dispatch({changes:n,scrollIntoView:!0,userEvent:"delete.cut"});let o=Js?null:e.clipboardData;return o?(o.clearData(),o.setData("text/plain",i),!0):(function(t,e){let i=t.dom.parentNode;if(!i)return;let n=i.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.value=e,n.focus(),n.selectionEnd=e.length,n.selectionStart=0,setTimeout(()=>{n.remove(),t.focus()},50)}(t,i),!1)};const co=re.define();function fo(t,e){let i=[];for(let n of t.facet(Fn)){let s=n(t,e);s&&i.push(s)}return i.length?t.update({effects:i,annotations:co.of(!0)}):null}function uo(t){setTimeout(()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let i=fo(t.state,e);i?t.dispatch(i):t.update([])}},10)}Ys.focus=t=>{t.inputState.lastFocusTime=Date.now(),t.scrollDOM.scrollTop||!t.inputState.lastScrollTop&&!t.inputState.lastScrollLeft||(t.scrollDOM.scrollTop=t.inputState.lastScrollTop,t.scrollDOM.scrollLeft=t.inputState.lastScrollLeft),uo(t)},Ys.blur=t=>{t.observer.clearSelectionRange(),uo(t)},Ys.compositionstart=Ys.compositionupdate=t=>{t.observer.editContext||(null==t.inputState.compositionFirstChange&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0))},Ys.compositionend=t=>{t.observer.editContext||(t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionPendingKey=!0,t.inputState.compositionPendingChange=t.observer.pendingRecords().length>0,t.inputState.compositionFirstChange=null,fi.chrome&&fi.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then(()=>t.observer.flush()):setTimeout(()=>{t.inputState.composing<0&&t.docView.hasComposition&&t.update([])},50))},Ys.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()},Gs.beforeinput=(t,e)=>{var i,n;if("insertText"!=e.inputType&&"insertCompositionText"!=e.inputType||(t.inputState.insertingText=e.data,t.inputState.insertingTextAt=Date.now()),"insertReplacementText"==e.inputType&&t.observer.editContext){let n=null===(i=e.dataTransfer)||void 0===i?void 0:i.getData("text/plain"),s=e.getTargetRanges();if(n&&s.length){let e=s[0],i=t.posAtDOM(e.startContainer,e.startOffset),o=t.posAtDOM(e.endContainer,e.endOffset);return Hs(t,{from:i,to:o,insert:t.state.toText(n)},null),!0}}let s;if(fi.chrome&&fi.android&&(s=qs.find(t=>t.inputType==e.inputType))&&(t.observer.delayAndroidKey(s.key,s.keyCode),"Backspace"==s.key||"Delete"==s.key)){let e=(null===(n=window.visualViewport)||void 0===n?void 0:n.height)||0;setTimeout(()=>{var i;((null===(i=window.visualViewport)||void 0===i?void 0:i.height)||0)>e+10&&t.hasFocus&&(t.contentDOM.blur(),t.focus())},100)}return fi.ios&&"deleteContentForward"==e.inputType&&t.observer.flushSoon(),fi.safari&&"insertText"==e.inputType&&t.inputState.composing>=0&&setTimeout(()=>Ys.compositionend(t,e),20),!1};const po=new Set;const mo=["pre-wrap","normal","pre-line","break-spaces"];let go=!1;function wo(){go=!1}class vo{constructor(t){this.lineWrapping=t,this.doc=rt.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(t,e){let i=this.doc.lineAt(e).number-this.doc.lineAt(t).number+1;return this.lineWrapping&&(i+=Math.max(0,Math.ceil((e-t-i*this.lineLength*.5)/this.lineLength))),this.lineHeight*i}heightForLine(t){if(!this.lineWrapping)return this.lineHeight;return(1+Math.max(0,Math.ceil((t-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight}setDoc(t){return this.doc=t,this}mustRefreshForWrapping(t){return mo.indexOf(t)>-1!=this.lineWrapping}mustRefreshForHeights(t){let e=!1;for(let i=0;i<t.length;i++){let n=t[i];n<0?i++:this.heightSamples[Math.floor(10*n)]||(e=!0,this.heightSamples[Math.floor(10*n)]=!0)}return e}refresh(t,e,i,n,s,o){let r=mo.indexOf(t)>-1,l=Math.round(e)!=Math.round(this.lineHeight)||this.lineWrapping!=r;if(this.lineWrapping=r,this.lineHeight=e,this.charWidth=i,this.textHeight=n,this.lineLength=s,l){this.heightSamples={};for(let t=0;t<o.length;t++){let e=o[t];e<0?t++:this.heightSamples[Math.floor(10*e)]=!0}}return l}}class bo{constructor(t,e){this.from=t,this.heights=e,this.index=0}get more(){return this.index<this.heights.length}}class yo{constructor(t,e,i,n,s){this.from=t,this.length=e,this.top=i,this.height=n,this._content=s}get type(){return"number"==typeof this._content?en.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof rn?this._content.widget:null}get widgetLineBreaks(){return"number"==typeof this._content?this._content:0}join(t){let e=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(t._content)?t._content:[t]);return new yo(this.from,this.length+t.length,this.top,this.height+t.height,e)}}var xo=function(t){return t[t.ByPos=0]="ByPos",t[t.ByHeight=1]="ByHeight",t[t.ByPosNoHeight=2]="ByPosNoHeight",t}(xo||(xo={}));const ko=.001;class So{constructor(t,e,i=2){this.length=t,this.height=e,this.flags=i}get outdated(){return(2&this.flags)>0}set outdated(t){this.flags=(t?2:0)|-3&this.flags}setHeight(t){this.height!=t&&(Math.abs(this.height-t)>ko&&(go=!0),this.height=t)}replace(t,e,i){return So.of(i)}decomposeLeft(t,e){e.push(this)}decomposeRight(t,e){e.push(this)}applyChanges(t,e,i,n){let s=this,o=i.doc;for(let r=n.length-1;r>=0;r--){let{fromA:l,toA:a,fromB:h,toB:c}=n[r],f=s.lineAt(l,xo.ByPosNoHeight,i.setDoc(e),0,0),d=f.to>=a?f:s.lineAt(a,xo.ByPosNoHeight,i,0,0);for(c+=d.to-a,a=d.to;r>0&&f.from<=n[r-1].toA;)l=n[r-1].fromA,h=n[r-1].fromB,r--,l<f.from&&(f=s.lineAt(l,xo.ByPosNoHeight,i,0,0));h+=f.from-l,l=f.from;let u=Lo.build(i.setDoc(o),t,h,c);s=Co(s,s.replace(l,a,u))}return s.updateHeight(i,0)}static empty(){return new Mo(0,0)}static of(t){if(1==t.length)return t[0];let e=0,i=t.length,n=0,s=0;for(;;)if(e==i)if(n>2*s){let s=t[e-1];s.break?t.splice(--e,1,s.left,null,s.right):t.splice(--e,1,s.left,s.right),i+=1+s.break,n-=s.size}else{if(!(s>2*n))break;{let e=t[i];e.break?t.splice(i,1,e.left,null,e.right):t.splice(i,1,e.left,e.right),i+=2+e.break,s-=e.size}}else if(n<s){let i=t[e++];i&&(n+=i.size)}else{let e=t[--i];e&&(s+=e.size)}let o=0;return null==t[e-1]?(o=1,e--):null==t[e]&&(o=1,i++),new Oo(So.of(t.slice(0,e)),o,So.of(t.slice(i)))}}function Co(t,e){return t==e?t:(t.constructor!=e.constructor&&(go=!0),e)}So.prototype.size=1;class Ao extends So{constructor(t,e,i){super(t,e),this.deco=i}blockAt(t,e,i,n){return new yo(n,this.length,i,this.height,this.deco||0)}lineAt(t,e,i,n,s){return this.blockAt(0,i,n,s)}forEachLine(t,e,i,n,s,o){t<=s+this.length&&e>=s&&o(this.blockAt(0,i,n,s))}updateHeight(t,e=0,i=!1,n){return n&&n.from<=e&&n.more&&this.setHeight(n.heights[n.index++]),this.outdated=!1,this}toString(){return`block(${this.length})`}}class Mo extends Ao{constructor(t,e){super(t,e,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(t,e,i,n){return new yo(n,this.length,i,this.height,this.breaks)}replace(t,e,i){let n=i[0];return 1==i.length&&(n instanceof Mo||n instanceof To&&4&n.flags)&&Math.abs(this.length-n.length)<10?(n instanceof To?n=new Mo(n.length,this.height):n.height=this.height,this.outdated||(n.outdated=!1),n):So.of(i)}updateHeight(t,e=0,i=!1,n){return n&&n.from<=e&&n.more?this.setHeight(n.heights[n.index++]):(i||this.outdated)&&this.setHeight(Math.max(this.widgetHeight,t.heightForLine(this.length-this.collapsed))+this.breaks*t.lineHeight),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class To extends So{constructor(t){super(t,0)}heightMetrics(t,e){let i,n=t.doc.lineAt(e).number,s=t.doc.lineAt(e+this.length).number,o=s-n+1,r=0;if(t.lineWrapping){let e=Math.min(this.height,t.lineHeight*o);i=e/o,this.length>o+1&&(r=(this.height-e)/(this.length-o-1))}else i=this.height/o;return{firstLine:n,lastLine:s,perLine:i,perChar:r}}blockAt(t,e,i,n){let{firstLine:s,lastLine:o,perLine:r,perChar:l}=this.heightMetrics(e,n);if(e.lineWrapping){let s=n+(t<e.lineHeight?0:Math.round(Math.max(0,Math.min(1,(t-i)/this.height))*this.length)),o=e.doc.lineAt(s),a=r+o.length*l,h=Math.max(i,t-a/2);return new yo(o.from,o.length,h,a,0)}{let n=Math.max(0,Math.min(o-s,Math.floor((t-i)/r))),{from:l,length:a}=e.doc.line(s+n);return new yo(l,a,i+r*n,r,0)}}lineAt(t,e,i,n,s){if(e==xo.ByHeight)return this.blockAt(t,i,n,s);if(e==xo.ByPosNoHeight){let{from:e,to:n}=i.doc.lineAt(t);return new yo(e,n-e,0,0,0)}let{firstLine:o,perLine:r,perChar:l}=this.heightMetrics(i,s),a=i.doc.lineAt(t),h=r+a.length*l,c=a.number-o,f=n+r*c+l*(a.from-s-c);return new yo(a.from,a.length,Math.max(n,Math.min(f,n+this.height-h)),h,0)}forEachLine(t,e,i,n,s,o){t=Math.max(t,s),e=Math.min(e,s+this.length);let{firstLine:r,perLine:l,perChar:a}=this.heightMetrics(i,s);for(let h=t,c=n;h<=e;){let e=i.doc.lineAt(h);if(h==t){let i=e.number-r;c+=l*i+a*(t-s-i)}let n=l+a*e.length;o(new yo(e.from,e.length,c,n,0)),c+=n,h=e.to+1}}replace(t,e,i){let n=this.length-e;if(n>0){let t=i[i.length-1];t instanceof To?i[i.length-1]=new To(t.length+n):i.push(null,new To(n-1))}if(t>0){let e=i[0];e instanceof To?i[0]=new To(t+e.length):i.unshift(new To(t-1),null)}return So.of(i)}decomposeLeft(t,e){e.push(new To(t-1),null)}decomposeRight(t,e){e.push(null,new To(this.length-t-1))}updateHeight(t,e=0,i=!1,n){let s=e+this.length;if(n&&n.from<=e+this.length&&n.more){let i=[],o=Math.max(e,n.from),r=-1;for(n.from>e&&i.push(new To(n.from-e-1).updateHeight(t,e));o<=s&&n.more;){let e=t.doc.lineAt(o).length;i.length&&i.push(null);let s=n.heights[n.index++];-1==r?r=s:Math.abs(s-r)>=ko&&(r=-2);let l=new Mo(e,s);l.outdated=!1,i.push(l),o+=e+1}o<=s&&i.push(null,new To(s-o).updateHeight(t,o));let l=So.of(i);return(r<0||Math.abs(l.height-this.height)>=ko||Math.abs(r-this.heightMetrics(t,e).perLine)>=ko)&&(go=!0),Co(this,l)}return(i||this.outdated)&&(this.setHeight(t.heightForGap(e,e+this.length)),this.outdated=!1),this}toString(){return`gap(${this.length})`}}class Oo extends So{constructor(t,e,i){super(t.length+e+i.length,t.height+i.height,e|(t.outdated||i.outdated?2:0)),this.left=t,this.right=i,this.size=t.size+i.size}get break(){return 1&this.flags}blockAt(t,e,i,n){let s=i+this.left.height;return t<s?this.left.blockAt(t,e,i,n):this.right.blockAt(t,e,s,n+this.left.length+this.break)}lineAt(t,e,i,n,s){let o=n+this.left.height,r=s+this.left.length+this.break,l=e==xo.ByHeight?t<o:t<r,a=l?this.left.lineAt(t,e,i,n,s):this.right.lineAt(t,e,i,o,r);if(this.break||(l?a.to<r:a.from>r))return a;let h=e==xo.ByPosNoHeight?xo.ByPosNoHeight:xo.ByPos;return l?a.join(this.right.lineAt(r,h,i,o,r)):this.left.lineAt(r,h,i,n,s).join(a)}forEachLine(t,e,i,n,s,o){let r=n+this.left.height,l=s+this.left.length+this.break;if(this.break)t<l&&this.left.forEachLine(t,e,i,n,s,o),e>=l&&this.right.forEachLine(t,e,i,r,l,o);else{let a=this.lineAt(l,xo.ByPos,i,n,s);t<a.from&&this.left.forEachLine(t,a.from-1,i,n,s,o),a.to>=t&&a.from<=e&&o(a),e>a.to&&this.right.forEachLine(a.to+1,e,i,r,l,o)}}replace(t,e,i){let n=this.left.length+this.break;if(e<n)return this.balanced(this.left.replace(t,e,i),this.right);if(t>this.left.length)return this.balanced(this.left,this.right.replace(t-n,e-n,i));let s=[];t>0&&this.decomposeLeft(t,s);let o=s.length;for(let t of i)s.push(t);if(t>0&&Do(s,o-1),e<this.length){let t=s.length;this.decomposeRight(e,s),Do(s,t)}return So.of(s)}decomposeLeft(t,e){let i=this.left.length;if(t<=i)return this.left.decomposeLeft(t,e);e.push(this.left),this.break&&(i++,t>=i&&e.push(null)),t>i&&this.right.decomposeLeft(t-i,e)}decomposeRight(t,e){let i=this.left.length,n=i+this.break;if(t>=n)return this.right.decomposeRight(t-n,e);t<i&&this.left.decomposeRight(t,e),this.break&&t<n&&e.push(null),e.push(this.right)}balanced(t,e){return t.size>2*e.size||e.size>2*t.size?So.of(this.break?[t,null,e]:[t,e]):(this.left=Co(this.left,t),this.right=Co(this.right,e),this.setHeight(t.height+e.height),this.outdated=t.outdated||e.outdated,this.size=t.size+e.size,this.length=t.length+this.break+e.length,this)}updateHeight(t,e=0,i=!1,n){let{left:s,right:o}=this,r=e+s.length+this.break,l=null;return n&&n.from<=e+s.length&&n.more?l=s=s.updateHeight(t,e,i,n):s.updateHeight(t,e,i),n&&n.from<=r+o.length&&n.more?l=o=o.updateHeight(t,r,i,n):o.updateHeight(t,r,i),l?this.balanced(s,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function Do(t,e){let i,n;null==t[e]&&(i=t[e-1])instanceof To&&(n=t[e+1])instanceof To&&t.splice(e-1,3,new To(i.length+1+n.length))}class Lo{constructor(t,e){this.pos=t,this.oracle=e,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=t}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(t,e){if(this.lineStart>-1){let t=Math.min(e,this.lineEnd),i=this.nodes[this.nodes.length-1];i instanceof Mo?i.length+=t-this.pos:(t>this.pos||!this.isCovered)&&this.nodes.push(new Mo(t-this.pos,-1)),this.writtenTo=t,e>t&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=e}point(t,e,i){if(t<e||i.heightRelevant){let n=i.widget?i.widget.estimatedHeight:0,s=i.widget?i.widget.lineBreaks:0;n<0&&(n=this.oracle.lineHeight);let o=e-t;i.block?this.addBlock(new Ao(o,n,i)):(o||s||n>=5)&&this.addLineDeco(n,s,o)}else e>t&&this.span(t,e);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:t,to:e}=this.oracle.doc.lineAt(this.pos);this.lineStart=t,this.lineEnd=e,this.writtenTo<t&&((this.writtenTo<t-1||null==this.nodes[this.nodes.length-1])&&this.nodes.push(this.blankContent(this.writtenTo,t-1)),this.nodes.push(null)),this.pos>t&&this.nodes.push(new Mo(this.pos-t,-1)),this.writtenTo=this.pos}blankContent(t,e){let i=new To(e-t);return this.oracle.doc.lineAt(t).to==e&&(i.flags|=4),i}ensureLine(){this.enterLine();let t=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(t instanceof Mo)return t;let e=new Mo(0,-1);return this.nodes.push(e),e}addBlock(t){this.enterLine();let e=t.deco;e&&e.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(t),this.writtenTo=this.pos=this.pos+t.length,e&&e.endSide>0&&(this.covering=t)}addLineDeco(t,e,i){let n=this.ensureLine();n.length+=i,n.collapsed+=i,n.widgetHeight=Math.max(n.widgetHeight,t),n.breaks+=e,this.writtenTo=this.pos=this.pos+i}finish(t){let e=0==this.nodes.length?null:this.nodes[this.nodes.length-1];!(this.lineStart>-1)||e instanceof Mo||this.isCovered?(this.writtenTo<this.pos||null==e)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos)):this.nodes.push(new Mo(0,-1));let i=t;for(let t of this.nodes)t instanceof Mo&&t.updateHeight(this.oracle,i),i+=t?t.length:1;return this.nodes}static build(t,e,i,n){let s=new Lo(i,t);return Te.spans(e,i,n,s,0),s.finish(i)}}class Eo{constructor(){this.changes=[]}compareRange(){}comparePoint(t,e,i,n){(t<e||i&&i.heightRelevant||n&&n.heightRelevant)&&an(t,e,this.changes,5)}}function Po(t,e){let i=t.getBoundingClientRect(),n=t.ownerDocument,s=n.defaultView||window,o=Math.max(0,i.left),r=Math.min(s.innerWidth,i.right),l=Math.max(0,i.top),a=Math.min(s.innerHeight,i.bottom);for(let e=t.parentNode;e&&e!=n.body;)if(1==e.nodeType){let i=e,n=window.getComputedStyle(i);if((i.scrollHeight>i.clientHeight||i.scrollWidth>i.clientWidth)&&"visible"!=n.overflow){let n=i.getBoundingClientRect();o=Math.max(o,n.left),r=Math.min(r,n.right),l=Math.max(l,n.top),a=Math.min(e==t.parentNode?s.innerHeight:a,n.bottom)}e="absolute"==n.position||"fixed"==n.position?i.offsetParent:i.parentNode}else{if(11!=e.nodeType)break;e=e.host}return{left:o-i.left,right:Math.max(o,r)-i.left,top:l-(i.top+e),bottom:Math.max(l,a)-(i.top+e)}}function Bo(t,e){let i=t.getBoundingClientRect();return{left:0,right:i.right-i.left,top:e,bottom:i.bottom-(i.top+e)}}class Ro{constructor(t,e,i,n){this.from=t,this.to=e,this.size=i,this.displaySize=n}static same(t,e){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++){let n=t[i],s=e[i];if(n.from!=s.from||n.to!=s.to||n.size!=s.size)return!1}return!0}draw(t,e){return nn.replace({widget:new No(this.displaySize*(e?t.scaleY:t.scaleX),e)}).range(this.from,this.to)}}class No extends tn{constructor(t,e){super(),this.size=t,this.vertical=e}eq(t){return t.size==this.size&&t.vertical==this.vertical}toDOM(){let t=document.createElement("div");return this.vertical?t.style.height=this.size+"px":(t.style.width=this.size+"px",t.style.height="2px",t.style.display="inline-block"),t}get estimatedHeight(){return this.vertical?this.size:-1}}class Io{constructor(t){this.state=t,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scrollTop=0,this.scrolledToBottom=!1,this.scaleX=1,this.scaleY=1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=Fo,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=mn.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let e=t.facet(is).some(t=>"function"!=typeof t&&"cm-lineWrapping"==t.class);this.heightOracle=new vo(e),this.stateDeco=t.facet(ns).filter(t=>"function"!=typeof t),this.heightMap=So.empty().applyChanges(this.stateDeco,rt.empty,this.heightOracle.setDoc(t.doc),[new fs(0,0,0,t.doc.length)]);for(let t=0;t<2&&(this.viewport=this.getViewport(0,null),this.updateForViewport());t++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=nn.set(this.lineGaps.map(t=>t.draw(this,!1))),this.computeVisibleRanges()}updateForViewport(){let t=[this.viewport],{main:e}=this.state.selection;for(let i=0;i<=1;i++){let n=i?e.head:e.anchor;if(!t.some(({from:t,to:e})=>n>=t&&n<=e)){let{from:e,to:i}=this.lineBlockAt(n);t.push(new jo(e,i))}}return this.viewports=t.sort((t,e)=>t.from-e.from),this.updateScaler()}updateScaler(){let t=this.scaler;return this.scaler=this.heightMap.height<=7e6?Fo:new zo(this.heightOracle,this.heightMap,this.viewports),t.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,t=>{this.viewportLines.push(Wo(t,this.scaler))})}update(t,e=null){this.state=t.state;let i=this.stateDeco;this.stateDeco=this.state.facet(ns).filter(t=>"function"!=typeof t);let n=t.changedRanges,s=fs.extendWithRanges(n,function(t,e,i){let n=new Eo;return Te.compare(t,e,i,n,0),n.changes}(i,this.stateDeco,t?t.changes:kt.empty(this.state.doc.length))),o=this.heightMap.height,r=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);wo(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,t.startState.doc,this.heightOracle.setDoc(this.state.doc),s),(this.heightMap.height!=o||go)&&(t.flags|=2),r?(this.scrollAnchorPos=t.changes.mapPos(r.from,-1),this.scrollAnchorHeight=r.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=o);let l=s.length?this.mapViewport(this.viewport,t.changes):this.viewport;(e&&(e.range.head<l.from||e.range.head>l.to)||!this.viewportIsAppropriate(l))&&(l=this.getViewport(0,e));let a=l.from!=this.viewport.from||l.to!=this.viewport.to;this.viewport=l,t.flags|=this.updateForViewport(),(a||!t.changes.empty||2&t.flags)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,t.changes))),t.flags|=this.computeVisibleRanges(t.changes),e&&(this.scrollTarget=e),!this.mustEnforceCursorAssoc&&t.selectionSet&&t.view.lineWrapping&&t.state.selection.main.empty&&t.state.selection.main.assoc&&!t.state.facet(_n)&&(this.mustEnforceCursorAssoc=!0)}measure(t){let e=t.contentDOM,i=window.getComputedStyle(e),n=this.heightOracle,s=i.whiteSpace;this.defaultTextDirection="rtl"==i.direction?mn.RTL:mn.LTR;let o=this.heightOracle.mustRefreshForWrapping(s),r=e.getBoundingClientRect(),l=o||this.mustMeasureContent||this.contentDOMHeight!=r.height;this.contentDOMHeight=r.height,this.mustMeasureContent=!1;let a=0,h=0;if(r.width&&r.height){let{scaleX:t,scaleY:i}=Si(e,r);(t>.005&&Math.abs(this.scaleX-t)>.005||i>.005&&Math.abs(this.scaleY-i)>.005)&&(this.scaleX=t,this.scaleY=i,a|=16,o=l=!0)}let c=(parseInt(i.paddingTop)||0)*this.scaleY,f=(parseInt(i.paddingBottom)||0)*this.scaleY;this.paddingTop==c&&this.paddingBottom==f||(this.paddingTop=c,this.paddingBottom=f,a|=18),this.editorWidth!=t.scrollDOM.clientWidth&&(n.lineWrapping&&(l=!0),this.editorWidth=t.scrollDOM.clientWidth,a|=16);let d=t.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=d&&(this.scrollAnchorHeight=-1,this.scrollTop=d),this.scrolledToBottom=Ei(t.scrollDOM);let u=(this.printing?Bo:Po)(e,this.paddingTop),p=u.top-this.pixelViewport.top,m=u.bottom-this.pixelViewport.bottom;this.pixelViewport=u;let g=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(g!=this.inView&&(this.inView=g,g&&(l=!0)),!this.inView&&!this.scrollTarget&&!function(t){let e=t.getBoundingClientRect(),i=t.ownerDocument.defaultView||window;return e.left<i.innerWidth&&e.right>0&&e.top<i.innerHeight&&e.bottom>0}(t.dom))return 0;let w=r.width;if(this.contentDOMWidth==w&&this.editorHeight==t.scrollDOM.clientHeight||(this.contentDOMWidth=r.width,this.editorHeight=t.scrollDOM.clientHeight,a|=16),l){let e=t.docView.measureVisibleLineHeights(this.viewport);if(n.mustRefreshForHeights(e)&&(o=!0),o||n.lineWrapping&&Math.abs(w-this.contentDOMWidth)>n.charWidth){let{lineHeight:i,charWidth:r,textHeight:l}=t.docView.measureTextSize();o=i>0&&n.refresh(s,i,r,l,Math.max(5,w/r),e),o&&(t.docView.minWidth=0,a|=16)}p>0&&m>0?h=Math.max(p,m):p<0&&m<0&&(h=Math.min(p,m)),wo();for(let i of this.viewports){let s=i.from==this.viewport.from?e:t.docView.measureVisibleLineHeights(i);this.heightMap=(o?So.empty().applyChanges(this.stateDeco,rt.empty,this.heightOracle,[new fs(0,0,0,t.state.doc.length)]):this.heightMap).updateHeight(n,0,o,new bo(i.from,s))}go&&(a|=2)}let v=!this.viewportIsAppropriate(this.viewport,h)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return v&&(2&a&&(a|=this.updateScaler()),this.viewport=this.getViewport(h,this.scrollTarget),a|=this.updateForViewport()),(2&a||v)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,t)),a|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,t.docView.enforceCursorAssoc()),a}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(t,e){let i=.5-Math.max(-.5,Math.min(.5,t/1e3/2)),n=this.heightMap,s=this.heightOracle,{visibleTop:o,visibleBottom:r}=this,l=new jo(n.lineAt(o-1e3*i,xo.ByHeight,s,0,0).from,n.lineAt(r+1e3*(1-i),xo.ByHeight,s,0,0).to);if(e){let{head:t}=e.range;if(t<l.from||t>l.to){let i,o=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),r=n.lineAt(t,xo.ByPos,s,0,0);i="center"==e.y?(r.top+r.bottom)/2-o/2:"start"==e.y||"nearest"==e.y&&t<l.from?r.top:r.bottom-o,l=new jo(n.lineAt(i-500,xo.ByHeight,s,0,0).from,n.lineAt(i+o+500,xo.ByHeight,s,0,0).to)}}return l}mapViewport(t,e){let i=e.mapPos(t.from,-1),n=e.mapPos(t.to,1);return new jo(this.heightMap.lineAt(i,xo.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(n,xo.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:t,to:e},i=0){if(!this.inView)return!0;let{top:n}=this.heightMap.lineAt(t,xo.ByPos,this.heightOracle,0,0),{bottom:s}=this.heightMap.lineAt(e,xo.ByPos,this.heightOracle,0,0),{visibleTop:o,visibleBottom:r}=this;return(0==t||n<=o-Math.max(10,Math.min(-i,250)))&&(e==this.state.doc.length||s>=r+Math.max(10,Math.min(i,250)))&&n>o-2e3&&s<r+2e3}mapLineGaps(t,e){if(!t.length||e.empty)return t;let i=[];for(let n of t)e.touchesRange(n.from,n.to)||i.push(new Ro(e.mapPos(n.from),e.mapPos(n.to),n.size,n.displaySize));return i}ensureLineGaps(t,e){let i=this.heightOracle.lineWrapping,n=i?1e4:2e3,s=n>>1,o=n<<1;if(this.defaultTextDirection!=mn.LTR&&!i)return[];let r=[],l=(n,o,a,h)=>{if(o-n<s)return;let c=this.state.selection.main,f=[c.from];c.empty||f.push(c.to);for(let t of f)if(t>n&&t<o)return l(n,t-10,a,h),void l(t+10,o,a,h);let d=function(t,e){for(let i of t)if(e(i))return i;return}(t,t=>t.from>=a.from&&t.to<=a.to&&Math.abs(t.from-n)<s&&Math.abs(t.to-o)<s&&!f.some(e=>t.from<e&&t.to>e));if(!d){if(o<a.to&&e&&i&&e.visibleRanges.some(t=>t.from<=o&&t.to>=o)){let t=e.moveToLineBoundary(Lt.cursor(o),!1,!0).head;t>n&&(o=t)}let t=this.gapSize(a,n,o,h);d=new Ro(n,o,t,i||t<2e6?t:2e6)}r.push(d)},a=e=>{if(e.length<o||e.type!=en.Text)return;let s=function(t,e,i){let n=[],s=t,o=0;Te.spans(i,t,e,{span(){},point(t,e){t>s&&(n.push({from:s,to:t}),o+=t-s),s=e}},20),s<e&&(n.push({from:s,to:e}),o+=e-s);return{total:o,ranges:n}}(e.from,e.to,this.stateDeco);if(s.total<o)return;let r,a,h=this.scrollTarget?this.scrollTarget.range.head:null;if(i){let t,i,o=n/this.heightOracle.lineLength*this.heightOracle.lineHeight;if(null!=h){let n=Vo(s,h),r=((this.visibleBottom-this.visibleTop)/2+o)/e.height;t=n-r,i=n+r}else t=(this.visibleTop-e.top-o)/e.height,i=(this.visibleBottom-e.top+o)/e.height;r=Ho(s,t),a=Ho(s,i)}else{let i=s.total*this.heightOracle.charWidth,o=n*this.heightOracle.charWidth,l=0;if(i>2e6)for(let i of t)i.from>=e.from&&i.from<e.to&&i.size!=i.displaySize&&i.from*this.heightOracle.charWidth+l<this.pixelViewport.left&&(l=i.size-i.displaySize);let c,f,d=this.pixelViewport.left+l,u=this.pixelViewport.right+l;if(null!=h){let t=Vo(s,h),e=((u-d)/2+o)/i;c=t-e,f=t+e}else c=(d-o)/i,f=(u+o)/i;r=Ho(s,c),a=Ho(s,f)}r>e.from&&l(e.from,r,e,s),a<e.to&&l(a,e.to,e,s)};for(let t of this.viewportLines)Array.isArray(t.type)?t.type.forEach(a):a(t);return r}gapSize(t,e,i,n){let s=Vo(n,i)-Vo(n,e);return this.heightOracle.lineWrapping?t.height*s:n.total*this.heightOracle.charWidth*s}updateLineGaps(t){Ro.same(t,this.lineGaps)||(this.lineGaps=t,this.lineGapDeco=nn.set(t.map(t=>t.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(t){let e=this.stateDeco;this.lineGaps.length&&(e=e.concat(this.lineGapDeco));let i=[];Te.spans(e,this.viewport.from,this.viewport.to,{span(t,e){i.push({from:t,to:e})},point(){}},20);let n=0;if(i.length!=this.visibleRanges.length)n=12;else for(let e=0;e<i.length&&!(8&n);e++){let s=this.visibleRanges[e],o=i[e];s.from==o.from&&s.to==o.to||(n|=4,t&&t.mapPos(s.from,-1)==o.from&&t.mapPos(s.to,1)==o.to||(n|=8))}return this.visibleRanges=i,n}lineBlockAt(t){return t>=this.viewport.from&&t<=this.viewport.to&&this.viewportLines.find(e=>e.from<=t&&e.to>=t)||Wo(this.heightMap.lineAt(t,xo.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(t){return t>=this.viewportLines[0].top&&t<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(e=>e.top<=t&&e.bottom>=t)||Wo(this.heightMap.lineAt(this.scaler.fromDOM(t),xo.ByHeight,this.heightOracle,0,0),this.scaler)}scrollAnchorAt(t){let e=this.lineBlockAtHeight(t+8);return e.from>=this.viewport.from||this.viewportLines[0].top-t>200?e:this.viewportLines[0]}elementAtHeight(t){return Wo(this.heightMap.blockAt(this.scaler.fromDOM(t),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class jo{constructor(t,e){this.from=t,this.to=e}}function Ho({total:t,ranges:e},i){if(i<=0)return e[0].from;if(i>=1)return e[e.length-1].to;let n=Math.floor(t*i);for(let t=0;;t++){let{from:i,to:s}=e[t],o=s-i;if(n<=o)return i+n;n-=o}}function Vo(t,e){let i=0;for(let{from:n,to:s}of t.ranges){if(e<=s){i+=e-n;break}i+=s-n}return i/t.total}const Fo={toDOM:t=>t,fromDOM:t=>t,scale:1,eq(t){return t==this}};class zo{constructor(t,e,i){let n=0,s=0,o=0;this.viewports=i.map(({from:i,to:s})=>{let o=e.lineAt(i,xo.ByPos,t,0,0).top,r=e.lineAt(s,xo.ByPos,t,0,0).bottom;return n+=r-o,{from:i,to:s,top:o,bottom:r,domTop:0,domBottom:0}}),this.scale=(7e6-n)/(e.height-n);for(let t of this.viewports)t.domTop=o+(t.top-s)*this.scale,o=t.domBottom=t.domTop+(t.bottom-t.top),s=t.bottom}toDOM(t){for(let e=0,i=0,n=0;;e++){let s=e<this.viewports.length?this.viewports[e]:null;if(!s||t<s.top)return n+(t-i)*this.scale;if(t<=s.bottom)return s.domTop+(t-s.top);i=s.bottom,n=s.domBottom}}fromDOM(t){for(let e=0,i=0,n=0;;e++){let s=e<this.viewports.length?this.viewports[e]:null;if(!s||t<s.domTop)return i+(t-n)/this.scale;if(t<=s.domBottom)return s.top+(t-s.domTop);i=s.bottom,n=s.domBottom}}eq(t){return t instanceof zo&&(this.scale==t.scale&&this.viewports.length==t.viewports.length&&this.viewports.every((e,i)=>e.from==t.viewports[i].from&&e.to==t.viewports[i].to))}}function Wo(t,e){if(1==e.scale)return t;let i=e.toDOM(t.top),n=e.toDOM(t.bottom);return new yo(t.from,t.length,i,n-i,Array.isArray(t._content)?t._content.map(t=>Wo(t,e)):t._content)}const qo=Bt.define({combine:t=>t.join(" ")}),_o=Bt.define({combine:t=>t.indexOf(!0)>-1}),Ko=qe.newName(),$o=qe.newName(),Uo=qe.newName(),Go={"&light":"."+$o,"&dark":"."+Uo};function Yo(t,e,i){return new qe(e,{finish:e=>/&/.test(e)?e.replace(/&\w*/,e=>{if("&"==e)return t;if(!i||!i[e])throw new RangeError(`Unsupported selector: ${e}`);return i[e]}):t+" "+e})}const Jo=Yo("."+Ko,{"&":{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,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",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",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".cm-highlightTab":{backgroundImage:'url(\'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>\')',backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".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"}},Go),Xo={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Qo=fi.ie&&fi.ie_version<=11;class Zo{constructor(t){this.view=t,this.active=!1,this.editContext=null,this.selectionRange=new Ci,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=t.contentDOM,this.observer=new MutationObserver(e=>{for(let t of e)this.queue.push(t);(fi.ie&&fi.ie_version<=11||fi.ios&&t.composing)&&e.some(t=>"childList"==t.type&&t.removedNodes.length||"characterData"==t.type&&t.oldValue.length>t.target.nodeValue.length)?this.flushSoon():this.flush()}),!window.EditContext||!fi.android||!1===t.constructor.EDIT_CONTEXT||fi.chrome&&fi.chrome_version<126||(this.editContext=new ir(t),t.state.facet(Jn)&&(t.contentDOM.editContext=this.editContext.editContext)),Qo&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),"function"==typeof ResizeObserver&&(this.resizeScroll=new ResizeObserver(()=>{var t;(null===(t=this.view.docView)||void 0===t?void 0:t.lastUpdate)<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(t.scrollDOM)),this.addWindowListeners(this.win=t.win),this.start(),"function"==typeof IntersectionObserver&&(this.intersection=new IntersectionObserver(t=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),t.length>0&&t[t.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(t=>{t.length>0&&t[t.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(t){this.view.inputState.runHandlers("scroll",t),this.intersecting&&this.view.measure()}onScroll(t){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(t)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(t){("change"!=t.type&&t.type||t.matches)&&(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(t){if(this.gapIntersection&&(t.length!=this.gaps.length||this.gaps.some((e,i)=>e!=t[i]))){this.gapIntersection.disconnect();for(let e of t)this.gapIntersection.observe(e);this.gaps=t}}onSelectionChange(t){let e=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:i}=this,n=this.selectionRange;if(i.state.facet(Jn)?i.root.activeElement!=this.dom:!pi(this.dom,n))return;let s=n.anchorNode&&i.docView.nearest(n.anchorNode);s&&s.ignoreEvent(t)?e||(this.selectionChanged=!1):(fi.ie&&fi.ie_version<=11||fi.android&&fi.chrome)&&!i.state.selection.main.empty&&n.focusNode&&gi(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:t}=this,e=di(t.root);if(!e)return!1;let i=fi.safari&&11==t.root.nodeType&&t.root.activeElement==this.dom&&function(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return er(t,i)}let i=null;function n(t){t.preventDefault(),t.stopImmediatePropagation(),i=t.getTargetRanges()[0]}return t.contentDOM.addEventListener("beforeinput",n,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",n,!0),i?er(t,i):null}(this.view,e)||e;if(!i||this.selectionRange.eq(i))return!1;let n=pi(this.dom,i);return n&&!this.selectionChanged&&t.inputState.lastFocusTime>Date.now()-200&&t.inputState.lastTouchTime<Date.now()-300&&function(t,e){let i=e.focusNode,n=e.focusOffset;if(!i||e.anchorNode!=i||e.anchorOffset!=n)return!1;for(n=Math.min(n,yi(i));;)if(n){if(1!=i.nodeType)return!1;let t=i.childNodes[n-1];"false"==t.contentEditable?n--:(i=t,n=yi(i))}else{if(i==t)return!0;n=wi(i),i=i.parentNode}}(this.dom,i)?(this.view.inputState.lastFocusTime=0,t.docView.updateSelection(),!1):(this.selectionRange.setRange(i),n&&(this.selectionChanged=!0),!0)}setSelectionRange(t,e){this.selectionRange.set(t.node,t.offset,e.node,e.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let t=0,e=null;for(let i=this.dom;i;)if(1==i.nodeType)!e&&t<this.scrollTargets.length&&this.scrollTargets[t]==i?t++:e||(e=this.scrollTargets.slice(0,t)),e&&e.push(i),i=i.assignedSlot||i.parentNode;else{if(11!=i.nodeType)break;i=i.host}if(t<this.scrollTargets.length&&!e&&(e=this.scrollTargets.slice(0,t)),e){for(let t of this.scrollTargets)t.removeEventListener("scroll",this.onScroll);for(let t of this.scrollTargets=e)t.addEventListener("scroll",this.onScroll)}}ignore(t){if(!this.active)return t();try{return this.stop(),t()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,Xo),Qo&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),Qo&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(t,e){var i;if(!this.delayedAndroidKey){let t=()=>{let t=this.delayedAndroidKey;if(t){this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=t.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&t.force&&Di(this.dom,t.key,t.keyCode)}};this.flushingAndroidKey=this.view.win.requestAnimationFrame(t)}this.delayedAndroidKey&&"Enter"!=t||(this.delayedAndroidKey={key:t,keyCode:e,force:this.lastChange<Date.now()-50||!!(null===(i=this.delayedAndroidKey)||void 0===i?void 0:i.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let t of this.observer.takeRecords())this.queue.push(t);return this.queue}processRecords(){let t=this.pendingRecords();t.length&&(this.queue=[]);let e=-1,i=-1,n=!1;for(let s of t){let t=this.readMutation(s);t&&(t.typeOver&&(n=!0),-1==e?({from:e,to:i}=t):(e=Math.min(t.from,e),i=Math.max(t.to,i)))}return{from:e,to:i,typeOver:n}}readChange(){let{from:t,to:e,typeOver:i}=this.processRecords(),n=this.selectionChanged&&pi(this.dom,this.selectionRange);if(t<0&&!n)return null;t>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let s=new Is(this.view,t,e,i);return this.view.docView.domChanged={newSel:s.newSel?s.newSel.main:null},s}flush(t=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;t&&this.readSelectionRange();let e=this.readChange();if(!e)return this.view.requestMeasure(),!1;let i=this.view.state,n=js(this.view,e);return this.view.state==i&&(e.domChanged||e.newSel&&!e.newSel.main.eq(this.view.state.selection.main))&&this.view.update([]),n}readMutation(t){let e=this.view.docView.nearest(t.target);if(!e||e.ignoreMutation(t))return null;if(e.markDirty("attributes"==t.type),"attributes"==t.type&&(e.flags|=4),"childList"==t.type){let i=tr(e,t.previousSibling||t.target.previousSibling,-1),n=tr(e,t.nextSibling||t.target.nextSibling,1);return{from:i?e.posAfter(i):e.posAtStart,to:n?e.posBefore(n):e.posAtEnd,typeOver:!1}}return"characterData"==t.type?{from:e.posAtStart,to:e.posAtEnd,typeOver:t.target.nodeValue==t.oldValue}:null}setWindow(t){t!=this.win&&(this.removeWindowListeners(this.win),this.win=t,this.addWindowListeners(this.win))}addWindowListeners(t){t.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):t.addEventListener("beforeprint",this.onPrint),t.addEventListener("scroll",this.onScroll),t.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(t){t.removeEventListener("scroll",this.onScroll),t.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):t.removeEventListener("beforeprint",this.onPrint),t.document.removeEventListener("selectionchange",this.onSelectionChange)}update(t){this.editContext&&(this.editContext.update(t),t.startState.facet(Jn)!=t.state.facet(Jn)&&(t.view.contentDOM.editContext=t.state.facet(Jn)?this.editContext.editContext:null))}destroy(){var t,e,i;this.stop(),null===(t=this.intersection)||void 0===t||t.disconnect(),null===(e=this.gapIntersection)||void 0===e||e.disconnect(),null===(i=this.resizeScroll)||void 0===i||i.disconnect();for(let t of this.scrollTargets)t.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function tr(t,e,i){for(;e;){let n=Ii.get(e);if(n&&n.parent==t)return n;let s=e.parentNode;e=s!=t.dom?s:i>0?e.nextSibling:e.previousSibling}return null}function er(t,e){let i=e.startContainer,n=e.startOffset,s=e.endContainer,o=e.endOffset,r=t.docView.domAtPos(t.state.selection.main.anchor);return gi(r.node,r.offset,s,o)&&([i,n,s,o]=[s,o,i,n]),{anchorNode:i,anchorOffset:n,focusNode:s,focusOffset:o}}class ir{constructor(t){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(t.state);let e=this.editContext=new window.EditContext({text:t.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,t.state.selection.main.anchor))),selectionEnd:this.toContextPos(t.state.selection.main.head)});this.handlers.textupdate=i=>{let n=t.state.selection.main,{anchor:s,head:o}=n,r=this.toEditorPos(i.updateRangeStart),l=this.toEditorPos(i.updateRangeEnd);t.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:i.updateRangeStart,editorBase:r,drifted:!1});let a=l-r>i.text.length;r==this.from&&s<this.from?r=s:l==this.to&&s>this.to&&(l=s);let h=Vs(t.state.sliceDoc(r,l),i.text,(a?n.from:n.to)-r,a?"end":null);if(!h){let e=Lt.single(this.toEditorPos(i.selectionStart),this.toEditorPos(i.selectionEnd));return void(e.main.eq(n)||t.dispatch({selection:e,userEvent:"select"}))}let c={from:h.from+r,to:h.toA+r,insert:rt.of(i.text.slice(h.from,h.toB).split("\n"))};if((fi.mac||fi.android)&&c.from==o-1&&/^\. ?$/.test(i.text)&&"off"==t.contentDOM.getAttribute("autocorrect")&&(c={from:r,to:l,insert:rt.of([i.text.replace("."," ")])}),this.pendingContextChange=c,!t.state.readOnly){let e=this.to-this.from+(c.to-c.from+c.insert.length);Hs(t,c,Lt.single(this.toEditorPos(i.selectionStart,e),this.toEditorPos(i.selectionEnd,e)))}this.pendingContextChange&&(this.revertPending(t.state),this.setSelection(t.state)),c.from<c.to&&!c.insert.length&&t.inputState.composing>=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(e.text.slice(Math.max(0,i.updateRangeStart-1),Math.min(e.text.length,i.updateRangeStart+1)))&&this.handlers.compositionend(i)},this.handlers.characterboundsupdate=i=>{let n=[],s=null;for(let e=this.toEditorPos(i.rangeStart),o=this.toEditorPos(i.rangeEnd);e<o;e++){let i=t.coordsForChar(e);s=i&&new DOMRect(i.left,i.top,i.right-i.left,i.bottom-i.top)||s||new DOMRect,n.push(s)}e.updateCharacterBounds(i.rangeStart,n)},this.handlers.textformatupdate=e=>{let i=[];for(let t of e.getTextFormats()){let e=t.underlineStyle,n=t.underlineThickness;if(!/none/i.test(e)&&!/none/i.test(n)){let s=this.toEditorPos(t.rangeStart),o=this.toEditorPos(t.rangeEnd);if(s<o){let t=`text-decoration: underline ${/^[a-z]/.test(e)?e+" ":"Dashed"==e?"dashed ":"Squiggle"==e?"wavy ":""}${/thin/i.test(n)?1:2}px`;i.push(nn.mark({attributes:{style:t}}).range(s,o))}}}t.dispatch({effects:Gn.of(nn.set(i))})},this.handlers.compositionstart=()=>{t.inputState.composing<0&&(t.inputState.composing=0,t.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(t.inputState.composing=-1,t.inputState.compositionFirstChange=null,this.composing){let{drifted:e}=this.composing;this.composing=null,e&&this.reset(t.state)}};for(let t in this.handlers)e.addEventListener(t,this.handlers[t]);this.measureReq={read:t=>{this.editContext.updateControlBounds(t.contentDOM.getBoundingClientRect());let e=di(t.root);e&&e.rangeCount&&this.editContext.updateSelectionBounds(e.getRangeAt(0).getBoundingClientRect())}}}applyEdits(t){let e=0,i=!1,n=this.pendingContextChange;return t.changes.iterChanges((s,o,r,l,a)=>{if(i)return;let h=a.length-(o-s);if(n&&o>=n.to){if(n.from==s&&n.to==o&&n.insert.eq(a))return n=this.pendingContextChange=null,e+=h,void(this.to+=h);n=null,this.revertPending(t.state)}if(s+=e,(o+=e)<=this.from)this.from+=h,this.to+=h;else if(s<this.to){if(s<this.from||o>this.to||this.to-this.from+a.length>3e4)return void(i=!0);this.editContext.updateText(this.toContextPos(s),this.toContextPos(o),a.toString()),this.to+=h}e+=h}),n&&!i&&this.revertPending(t.state),!i}update(t){let e=this.pendingContextChange,i=t.startState.selection.main;this.composing&&(this.composing.drifted||!t.changes.touchesRange(i.from,i.to)&&t.transactions.some(t=>!t.isUserEvent("input.type")&&t.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=t.changes.mapPos(this.composing.editorBase)):this.applyEdits(t)&&this.rangeIsValid(t.state)?(t.docChanged||t.selectionSet||e)&&this.setSelection(t.state):(this.pendingContextChange=null,this.reset(t.state)),(t.geometryChanged||t.docChanged||t.selectionSet)&&t.view.requestMeasure(this.measureReq)}resetRange(t){let{head:e}=t.selection.main;this.from=Math.max(0,e-1e4),this.to=Math.min(t.doc.length,e+1e4)}reset(t){this.resetRange(t),this.editContext.updateText(0,this.editContext.text.length,t.doc.sliceString(this.from,this.to)),this.setSelection(t)}revertPending(t){let e=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(e.from),this.toContextPos(e.from+e.insert.length),t.doc.sliceString(e.from,e.to))}setSelection(t){let{main:e}=t.selection,i=this.toContextPos(Math.max(this.from,Math.min(this.to,e.anchor))),n=this.toContextPos(e.head);this.editContext.selectionStart==i&&this.editContext.selectionEnd==n||this.editContext.updateSelection(i,n)}rangeIsValid(t){let{head:e}=t.selection.main;return!(this.from>0&&e-this.from<500||this.to<t.doc.length&&this.to-e<500||this.to-this.from>3e4)}toEditorPos(t,e=this.to-this.from){t=Math.min(t,e);let i=this.composing;return i&&i.drifted?i.editorBase+(t-i.contextBase):t+this.from}toContextPos(t){let e=this.composing;return e&&e.drifted?e.contextBase+(t-e.editorBase):t-this.from}destroy(){for(let t in this.handlers)this.editContext.removeEventListener(t,this.handlers[t])}}class nr{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&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(t={}){var 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.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),t.parent&&t.parent.appendChild(this.dom);let{dispatch:i}=t;this.dispatchTransactions=t.dispatchTransactions||i&&(t=>t.forEach(t=>i(t,this)))||(t=>this.update(t)),this.dispatch=this.dispatch.bind(this),this._root=t.root||function(t){for(;t;){if(t&&(9==t.nodeType||11==t.nodeType&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}(t.parent)||document,this.viewState=new Io(t.state||xe.create(t)),t.scrollTo&&t.scrollTo.is(Un)&&(this.viewState.scrollTarget=t.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Qn).map(t=>new ts(t));for(let t of this.plugins)t.update(this);this.observer=new Zo(this),this.inputState=new Fs(this),this.inputState.ensureHandlers(this.plugins),this.docView=new us(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),(null===(e=document.fonts)||void 0===e?void 0:e.ready)&&document.fonts.ready.then(()=>this.requestMeasure())}dispatch(...t){let e=1==t.length&&t[0]instanceof ce?t:1==t.length&&Array.isArray(t[0])?t[0]:[this.state.update(...t)];this.dispatchTransactions(e,this)}update(t){if(0!=this.updateState)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let e,i=!1,n=!1,s=this.state;for(let e of t){if(e.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=e.state}if(this.destroyed)return void(this.viewState.state=s);let o=this.hasFocus,r=0,l=null;t.some(t=>t.annotation(co))?(this.inputState.notifiedFocused=o,r=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,l=fo(s,o),l||(r=1));let a=this.observer.delayedAndroidKey,h=null;if(a?(this.observer.clearDelayedAndroidKey(),h=this.observer.readChange(),(h&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(h=null)):this.observer.clear(),s.facet(xe.phrases)!=this.state.facet(xe.phrases))return this.setState(s);e=ds.create(this,s,t),e.flags|=r;let c=this.viewState.scrollTarget;try{this.updateState=2;for(let e of t){if(c&&(c=c.map(e.changes)),e.scrollIntoView){let{main:t}=e.state.selection;c=new $n(t.empty?t:Lt.cursor(t.head,t.head>t.anchor?-1:1))}for(let t of e.effects)t.is(Un)&&(c=t.value.clip(this.state))}this.viewState.update(e,c),this.bidiCache=rr.update(this.bidiCache,e.changes),e.empty||(this.updatePlugins(e),this.inputState.update(e)),i=this.docView.update(e),this.state.facet(cs)!=this.styleModules&&this.mountStyles(),n=this.updateAttrs(),this.showAnnouncements(t),this.docView.updateSelection(i,t.some(t=>t.isUserEvent("select.pointer")))}finally{this.updateState=0}if(e.startState.facet(qo)!=e.state.facet(qo)&&(this.viewState.mustMeasureContent=!0),(i||n||c||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),i&&this.docViewUpdate(),!e.empty)for(let t of this.state.facet(Hn))try{t(e)}catch(t){Yn(this.state,t,"update listener")}(l||h)&&Promise.resolve().then(()=>{l&&this.state==l.startState&&this.dispatch(l),h&&!js(this,h)&&a.force&&Di(this.contentDOM,a.key,a.keyCode)})}setState(t){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=t);this.updateState=2;let e=this.hasFocus;try{for(let t of this.plugins)t.destroy(this);this.viewState=new Io(t),this.plugins=t.facet(Qn).map(t=>new ts(t)),this.pluginMap.clear();for(let t of this.plugins)t.update(this);this.docView.destroy(),this.docView=new us(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}e&&this.focus(),this.requestMeasure()}updatePlugins(t){let e=t.startState.facet(Qn),i=t.state.facet(Qn);if(e!=i){let n=[];for(let s of i){let i=e.indexOf(s);if(i<0)n.push(new ts(s));else{let e=this.plugins[i];e.mustUpdate=t,n.push(e)}}for(let e of this.plugins)e.mustUpdate!=t&&e.destroy(this);this.plugins=n,this.pluginMap.clear()}else for(let e of this.plugins)e.mustUpdate=t;for(let t=0;t<this.plugins.length;t++)this.plugins[t].update(this);e!=i&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let t of this.plugins){let e=t.value;if(e&&e.docViewUpdate)try{e.docViewUpdate(this)}catch(t){Yn(this.state,t,"doc view update listener")}}}measure(t=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey)return this.measureScheduled=-1,void this.requestMeasure();this.measureScheduled=0,t&&this.observer.forceFlush();let e=null,i=this.scrollDOM,n=i.scrollTop*this.scaleY,{scrollAnchorPos:s,scrollAnchorHeight:o}=this.viewState;Math.abs(n-this.viewState.scrollTop)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let t=0;;t++){if(o<0)if(Ei(i))s=-1,o=this.viewState.heightMap.height;else{let t=this.viewState.scrollAnchorAt(n);s=t.from,o=t.top}this.updateState=1;let r=this.viewState.measure(this);if(!r&&!this.measureRequests.length&&null==this.viewState.scrollTarget)break;if(t>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let l=[];4&r||([this.measureRequests,l]=[l,this.measureRequests]);let a=l.map(t=>{try{return t.read(this)}catch(t){return Yn(this.state,t),or}}),h=ds.create(this,this.state,[]),c=!1;h.flags|=r,e?e.flags|=r:e=h,this.updateState=2,h.empty||(this.updatePlugins(h),this.inputState.update(h),this.updateAttrs(),c=this.docView.update(h),c&&this.docViewUpdate());for(let t=0;t<l.length;t++)if(a[t]!=or)try{let e=l[t];e.write&&e.write(a[t],this)}catch(t){Yn(this.state,t)}if(c&&this.docView.updateSelection(!0),!h.viewportChanged&&0==this.measureRequests.length){if(this.viewState.editorHeight){if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,o=-1;continue}{let t=(s<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(s).top)-o;if(t>1||t<-1){n+=t,i.scrollTop=n/this.scaleY,o=-1;continue}}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(e&&!e.empty)for(let t of this.state.facet(Hn))t(e)}get themeClasses(){return Ko+" "+(this.state.facet(_o)?Uo:$o)+" "+this.state.facet(qo)}updateAttrs(){let t=lr(this,es,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),e={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(Jn)?"true":"false",class:"cm-content",style:`${fi.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(e["aria-readonly"]="true"),lr(this,is,e);let i=this.observer.ignore(()=>{let i=Qi(this.contentDOM,this.contentAttrs,e),n=Qi(this.dom,this.editorAttrs,t);return i||n});return this.editorAttrs=t,this.contentAttrs=e,i}showAnnouncements(t){let e=!0;for(let i of t)for(let t of i.effects)if(t.is(nr.announce)){e&&(this.announceDOM.textContent=""),e=!1,this.announceDOM.appendChild(document.createElement("div")).textContent=t.value}}mountStyles(){this.styleModules=this.state.facet(cs);let t=this.state.facet(nr.cspNonce);qe.mount(this.root,this.styleModules.concat(Jo).reverse(),t?{nonce:t}:void 0)}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(t){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),t){if(this.measureRequests.indexOf(t)>-1)return;if(null!=t.key)for(let e=0;e<this.measureRequests.length;e++)if(this.measureRequests[e].key===t.key)return void(this.measureRequests[e]=t);this.measureRequests.push(t)}}plugin(t){let e=this.pluginMap.get(t);return(void 0===e||e&&e.plugin!=t)&&this.pluginMap.set(t,e=this.plugins.find(e=>e.plugin==t)||null),e&&e.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(t){return this.readMeasured(),this.viewState.elementAtHeight(t)}lineBlockAtHeight(t){return this.readMeasured(),this.viewState.lineBlockAtHeight(t)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(t){return this.viewState.lineBlockAt(t)}get contentHeight(){return this.viewState.contentHeight}moveByChar(t,e,i){return Ls(this,t,Ts(this,t,e,i))}moveByGroup(t,e){return Ls(this,t,Ts(this,t,e,e=>function(t,e,i){let n=t.state.charCategorizer(e),s=n(i);return t=>{let e=n(t);return s==we.Space&&(s=e),s==e}}(this,t.head,e)))}visualLineSide(t,e){let i=this.bidiSpans(t),n=this.textDirectionAt(t.from),s=i[e?i.length-1:0];return Lt.cursor(s.side(e,n)+t.from,s.forward(!e,n)?1:-1)}moveToLineBoundary(t,e,i=!0){return function(t,e,i,n){let s=Ms(t,e.head,e.assoc||-1),o=n&&s.type==en.Text&&(t.lineWrapping||s.widgetLineBreaks)?t.coordsAtPos(e.assoc<0&&e.head>s.from?e.head-1:e.head):null;if(o){let e=t.dom.getBoundingClientRect(),n=t.textDirectionAt(s.from),r=t.posAtCoords({x:i==(n==mn.LTR)?e.right-1:e.left+1,y:(o.top+o.bottom)/2});if(null!=r)return Lt.cursor(r,i?-1:1)}return Lt.cursor(i?s.to:s.from,i?-1:1)}(this,t,e,i)}moveVertically(t,e,i){return Ls(this,t,function(t,e,i,n){let s=e.head,o=i?1:-1;if(s==(i?t.state.doc.length:0))return Lt.cursor(s,e.assoc);let r,l=e.goalColumn,a=t.contentDOM.getBoundingClientRect(),h=t.coordsAtPos(s,e.assoc||-1),c=t.documentTop;if(h)null==l&&(l=h.left-a.left),r=o<0?h.top:h.bottom;else{let e=t.viewState.lineBlockAt(s);null==l&&(l=Math.min(a.right-a.left,t.defaultCharacterWidth*(s-e.from))),r=(o<0?e.top:e.bottom)+c}let f=a.left+l,d=null!=n?n:t.viewState.heightOracle.textHeight>>1;for(let e=0;;e+=10){let i=r+(d+e)*o,n=Ss(t,{x:f,y:i},!1,o);if(i<a.top||i>a.bottom||(o<0?n<s:n>s)){let e=t.docView.coordsForChar(n),s=!e||i<e.top?-1:1;return Lt.cursor(n,s,void 0,l)}}}(this,t,e,i))}domAtPos(t){return this.docView.domAtPos(t)}posAtDOM(t,e=0){return this.docView.posFromDOM(t,e)}posAtCoords(t,e=!0){return this.readMeasured(),Ss(this,t,e)}coordsAtPos(t,e=1){this.readMeasured();let i=this.docView.coordsAt(t,e);if(!i||i.left==i.right)return i;let n=this.state.doc.lineAt(t),s=this.bidiSpans(n);return xi(i,s[An.find(s,t-n.from,-1,e)].dir==mn.LTR==e>0)}coordsForChar(t){return this.readMeasured(),this.docView.coordsForChar(t)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(t){return!this.state.facet(qn)||t<this.viewport.from||t>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(t))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(t){if(t.length>sr)return Ln(t.length);let e,i=this.textDirectionAt(t.from);for(let n of this.bidiCache)if(n.from==t.from&&n.dir==i&&(n.fresh||Mn(n.isolates,e=ls(this,t))))return n.order;e||(e=ls(this,t));let n=function(t,e,i){if(!t)return[new An(0,0,e==wn?1:0)];if(e==gn&&!i.length&&!Cn.test(t))return Ln(t.length);if(i.length)for(;t.length>Tn.length;)Tn[Tn.length]=256;let n=[],s=e==gn?0:1;return Dn(t,s,s,i,0,t.length,n),n}(t.text,i,e);return this.bidiCache.push(new rr(t.from,t.to,i,e,!0,n)),n}get hasFocus(){var t;return(this.dom.ownerDocument.hasFocus()||fi.safari&&(null===(t=this.inputState)||void 0===t?void 0:t.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{Ti(this.contentDOM),this.docView.updateSelection()})}setRoot(t){this._root!=t&&(this._root=t,this.observer.setWindow((9==t.nodeType?t:t.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let t of this.plugins)t.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(t,e={}){return Un.of(new $n("number"==typeof t?Lt.cursor(t):t,e.y,e.x,e.yMargin,e.xMargin))}scrollSnapshot(){let{scrollTop:t,scrollLeft:e}=this.scrollDOM,i=this.viewState.scrollAnchorAt(t);return Un.of(new $n(Lt.cursor(i.from),"start","start",i.top-t,e,!0))}setTabFocusMode(t){null==t?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:"boolean"==typeof t?this.inputState.tabFocusMode=t?0:-1:0!=this.inputState.tabFocusMode&&(this.inputState.tabFocusMode=Date.now()+t)}static domEventHandlers(t){return Zn.define(()=>({}),{eventHandlers:t})}static domEventObservers(t){return Zn.define(()=>({}),{eventObservers:t})}static theme(t,e){let i=qe.newName(),n=[qo.of(i),cs.of(Yo(`.${i}`,t))];return e&&e.dark&&n.push(_o.of(!0)),n}static baseTheme(t){return $t.lowest(cs.of(Yo("."+Ko,t,Go)))}static findFromDOM(t){var e;let i=t.querySelector(".cm-content"),n=i&&Ii.get(i)||Ii.get(t);return(null===(e=null==n?void 0:n.rootView)||void 0===e?void 0:e.view)||null}}nr.styleModule=cs,nr.inputHandler=Vn,nr.clipboardInputFilter=zn,nr.clipboardOutputFilter=Wn,nr.scrollHandler=Kn,nr.focusChangeEffect=Fn,nr.perLineTextDirection=qn,nr.exceptionSink=jn,nr.updateListener=Hn,nr.editable=Jn,nr.mouseSelectionStyle=In,nr.dragMovesSelection=Nn,nr.clickAddsSelectionRange=Rn,nr.decorations=ns,nr.outerDecorations=ss,nr.atomicRanges=os,nr.bidiIsolatedRanges=rs,nr.scrollMargins=as,nr.darkTheme=_o,nr.cspNonce=Bt.define({combine:t=>t.length?t[0]:""}),nr.contentAttributes=is,nr.editorAttributes=es,nr.lineWrapping=nr.contentAttributes.of({class:"cm-lineWrapping"}),nr.announce=he.define();const sr=4096,or={};class rr{constructor(t,e,i,n,s,o){this.from=t,this.to=e,this.dir=i,this.isolates=n,this.fresh=s,this.order=o}static update(t,e){if(e.empty&&!t.some(t=>t.fresh))return t;let i=[],n=t.length?t[t.length-1].dir:mn.LTR;for(let s=Math.max(0,t.length-10);s<t.length;s++){let o=t[s];o.dir!=n||e.touchesRange(o.from,o.to)||i.push(new rr(e.mapPos(o.from,1),e.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return i}}function lr(t,e,i){for(let n=t.state.facet(e),s=n.length-1;s>=0;s--){let e=n[s],o="function"==typeof e?e(t):e;o&&Yi(o,i)}return i}const ar=fi.mac?"mac":fi.windows?"win":fi.linux?"linux":"key";function hr(t,e,i){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),!1!==i&&e.shiftKey&&(t="Shift-"+t),t}const cr=$t.default(nr.domEventHandlers({keydown:(t,e)=>function(t,e,i,n){mr=e;let s=function(t){var e=!(Ge&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||Ye&&t.shiftKey&&t.key&&1==t.key.length||"Unidentified"==t.key)&&t.key||(t.shiftKey?Ue:$e)[t.keyCode]||t.key||"Unidentified";return"Esc"==e&&(e="Escape"),"Del"==e&&(e="Delete"),"Left"==e&&(e="ArrowLeft"),"Up"==e&&(e="ArrowUp"),"Right"==e&&(e="ArrowRight"),"Down"==e&&(e="ArrowDown"),e}(e),o=wt(s,0),r=vt(o)==s.length&&" "!=s,l="",a=!1,h=!1,c=!1;ur&&ur.view==i&&ur.scope==n&&(l=ur.prefix+" ",Ks.indexOf(e.keyCode)<0&&(h=!0,ur=null));let f,d,u=new Set,p=t=>{if(t){for(let e of t.run)if(!u.has(e)&&(u.add(e),e(i)))return t.stopPropagation&&(c=!0),!0;t.preventDefault&&(t.stopPropagation&&(c=!0),h=!0)}return!1},m=t[n];m&&(p(m[l+hr(s,e,!r)])?a=!0:!r||!(e.altKey||e.metaKey||e.ctrlKey)||fi.windows&&e.ctrlKey&&e.altKey||fi.mac&&e.altKey&&!e.ctrlKey&&!e.metaKey||!(f=$e[e.keyCode])||f==s?r&&e.shiftKey&&p(m[l+hr(s,e,!0)])&&(a=!0):(p(m[l+hr(f,e,!0)])||e.shiftKey&&(d=Ue[e.keyCode])!=s&&d!=f&&p(m[l+hr(d,e,!1)]))&&(a=!0),!a&&p(m._any)&&(a=!0));h&&(a=!0);a&&c&&e.stopPropagation();return mr=null,a}(function(t){let e=t.facet(fr),i=dr.get(e);i||dr.set(e,i=function(t,e=ar){let i=Object.create(null),n=Object.create(null),s=(t,e)=>{let i=n[t];if(null==i)n[t]=e;else if(i!=e)throw new Error("Key binding "+t+" is used both as a regular binding and as a multi-stroke prefix")},o=(t,n,o,r,l)=>{var a,h;let c=i[t]||(i[t]=Object.create(null)),f=n.split(/ (?!$)/).map(t=>function(t,e){const i=t.split(/-(?!$)/);let n,s,o,r,l=i[i.length-1];"Space"==l&&(l=" ");for(let t=0;t<i.length-1;++t){const l=i[t];if(/^(cmd|meta|m)$/i.test(l))r=!0;else if(/^a(lt)?$/i.test(l))n=!0;else if(/^(c|ctrl|control)$/i.test(l))s=!0;else if(/^s(hift)?$/i.test(l))o=!0;else{if(!/^mod$/i.test(l))throw new Error("Unrecognized modifier name: "+l);"mac"==e?r=!0:s=!0}}return n&&(l="Alt-"+l),s&&(l="Ctrl-"+l),r&&(l="Meta-"+l),o&&(l="Shift-"+l),l}(t,e));for(let e=1;e<f.length;e++){let i=f.slice(0,e).join(" ");s(i,!0),c[i]||(c[i]={preventDefault:!0,stopPropagation:!1,run:[e=>{let n=ur={view:e,prefix:i,scope:t};return setTimeout(()=>{ur==n&&(ur=null)},pr),!0}]})}let d=f.join(" ");s(d,!1);let u=c[d]||(c[d]={preventDefault:!1,stopPropagation:!1,run:(null===(h=null===(a=c._any)||void 0===a?void 0:a.run)||void 0===h?void 0:h.slice())||[]});o&&u.run.push(o),r&&(u.preventDefault=!0),l&&(u.stopPropagation=!0)};for(let n of t){let t=n.scope?n.scope.split(" "):["editor"];if(n.any)for(let e of t){let t=i[e]||(i[e]=Object.create(null));t._any||(t._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:s}=n;for(let e in t)t[e].run.push(t=>s(t,mr))}let s=n[e]||n.key;if(s)for(let e of t)o(e,s,n.run,n.preventDefault,n.stopPropagation),n.shift&&o(e,"Shift-"+s,n.shift,n.preventDefault,n.stopPropagation)}return i}(e.reduce((t,e)=>t.concat(e),[])));return i}(e.state),t,e,"editor")})),fr=Bt.define({enables:cr}),dr=new WeakMap;let ur=null;const pr=4e3;let mr=null;class gr{constructor(t,e,i,n,s){this.className=t,this.left=e,this.top=i,this.width=n,this.height=s}draw(){let t=document.createElement("div");return t.className=this.className,this.adjust(t),t}update(t,e){return e.className==this.className&&(this.adjust(t),!0)}adjust(t){t.style.left=this.left+"px",t.style.top=this.top+"px",null!=this.width&&(t.style.width=this.width+"px"),t.style.height=this.height+"px"}eq(t){return this.left==t.left&&this.top==t.top&&this.width==t.width&&this.height==t.height&&this.className==t.className}static forRange(t,e,i){if(i.empty){let n=t.coordsAtPos(i.head,i.assoc||1);if(!n)return[];let s=wr(t);return[new gr(e,n.left-s.left,n.top-s.top,null,n.bottom-n.top)]}return function(t,e,i){if(i.to<=t.viewport.from||i.from>=t.viewport.to)return[];let n=Math.max(i.from,t.viewport.from),s=Math.min(i.to,t.viewport.to),o=t.textDirection==mn.LTR,r=t.contentDOM,l=r.getBoundingClientRect(),a=wr(t),h=r.querySelector(".cm-line"),c=h&&window.getComputedStyle(h),f=l.left+(c?parseInt(c.paddingLeft)+Math.min(0,parseInt(c.textIndent)):0),d=l.right-(c?parseInt(c.paddingRight):0),u=Ms(t,n,1),p=Ms(t,s,-1),m=u.type==en.Text?u:null,g=p.type==en.Text?p:null;m&&(t.lineWrapping||u.widgetLineBreaks)&&(m=vr(t,n,1,m));g&&(t.lineWrapping||p.widgetLineBreaks)&&(g=vr(t,s,-1,g));if(m&&g&&m.from==g.from&&m.to==g.to)return v(b(i.from,i.to,m));{let e=m?b(i.from,null,m):y(u,!1),n=g?b(null,i.to,g):y(p,!0),s=[];return(m||u).to<(g||p).from-(m&&g?1:0)||u.widgetLineBreaks>1&&e.bottom+t.defaultLineHeight/2<n.top?s.push(w(f,e.bottom,d,n.top)):e.bottom<n.top&&t.elementAtHeight((e.bottom+n.top)/2).type==en.Text&&(e.bottom=n.top=(e.bottom+n.top)/2),v(e).concat(s).concat(v(n))}function w(t,i,n,s){return new gr(e,t-a.left,i-a.top,n-t,s-i)}function v({top:t,bottom:e,horizontal:i}){let n=[];for(let s=0;s<i.length;s+=2)n.push(w(i[s],t,i[s+1],e));return n}function b(e,i,n){let s=1e9,r=-1e9,l=[];function a(e,i,a,h,c){let u=t.coordsAtPos(e,e==n.to?-2:2),p=t.coordsAtPos(a,a==n.from?2:-2);u&&p&&(s=Math.min(u.top,p.top,s),r=Math.max(u.bottom,p.bottom,r),c==mn.LTR?l.push(o&&i?f:u.left,o&&h?d:p.right):l.push(!o&&h?f:p.left,!o&&i?d:u.right))}let h=null!=e?e:n.from,c=null!=i?i:n.to;for(let n of t.visibleRanges)if(n.to>h&&n.from<c)for(let s=Math.max(n.from,h),o=Math.min(n.to,c);;){let n=t.state.doc.lineAt(s);for(let r of t.bidiSpans(n)){let t=r.from+n.from,l=r.to+n.from;if(t>=o)break;l>s&&a(Math.max(t,s),null==e&&t<=h,Math.min(l,o),null==i&&l>=c,r.dir)}if(s=n.to+1,s>=o)break}return 0==l.length&&a(h,null==e,c,null==i,t.textDirection),{top:s,bottom:r,horizontal:l}}function y(t,e){let i=l.top+(e?t.top:t.bottom);return{top:i,bottom:i,horizontal:[]}}}(t,e,i)}}function wr(t){let e=t.scrollDOM.getBoundingClientRect();return{left:(t.textDirection==mn.LTR?e.left:e.right-t.scrollDOM.clientWidth*t.scaleX)-t.scrollDOM.scrollLeft*t.scaleX,top:e.top-t.scrollDOM.scrollTop*t.scaleY}}function vr(t,e,i,n){let s=t.coordsAtPos(e,2*i);if(!s)return n;let o=t.dom.getBoundingClientRect(),r=(s.top+s.bottom)/2,l=t.posAtCoords({x:o.left+1,y:r}),a=t.posAtCoords({x:o.right-1,y:r});return null==l||null==a?n:{from:Math.max(n.from,Math.min(l,a)),to:Math.min(n.to,Math.max(l,a))}}class br{constructor(t,e){this.view=t,this.layer=e,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=t.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),e.above&&this.dom.classList.add("cm-layer-above"),e.class&&this.dom.classList.add(e.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(t.state),t.requestMeasure(this.measureReq),e.mount&&e.mount(this.dom,t)}update(t){t.startState.facet(yr)!=t.state.facet(yr)&&this.setOrder(t.state),(this.layer.update(t,this.dom)||t.geometryChanged)&&(this.scale(),t.view.requestMeasure(this.measureReq))}docViewUpdate(t){!1!==this.layer.updateOnDocViewUpdate&&t.requestMeasure(this.measureReq)}setOrder(t){let e=0,i=t.facet(yr);for(;e<i.length&&i[e]!=this.layer;)e++;this.dom.style.zIndex=String((this.layer.above?150:-1)-e)}measure(){return this.layer.markers(this.view)}scale(){let{scaleX:t,scaleY:e}=this.view;t==this.scaleX&&e==this.scaleY||(this.scaleX=t,this.scaleY=e,this.dom.style.transform=`scale(${1/t}, ${1/e})`)}draw(t){if(t.length!=this.drawn.length||t.some((t,e)=>{return i=t,n=this.drawn[e],!(i.constructor==n.constructor&&i.eq(n));var i,n})){let e=this.dom.firstChild,i=0;for(let n of t)n.update&&e&&n.constructor&&this.drawn[i].constructor&&n.update(e,this.drawn[i])?(e=e.nextSibling,i++):this.dom.insertBefore(n.draw(),e);for(;e;){let t=e.nextSibling;e.remove(),e=t}this.drawn=t,fi.safari&&fi.safari_version>=26&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const yr=Bt.define();function xr(t){return[Zn.define(e=>new br(e,t)),yr.of(t)]}const kr=Bt.define({combine:t=>ke(t,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(t,e)=>Math.min(t,e),drawRangeCursor:(t,e)=>t||e})});function Sr(t={}){return[kr.of(t),Ar,Tr,Or,_n.of(!0)]}function Cr(t){return t.startState.facet(kr)!=t.state.facet(kr)}const Ar=xr({above:!0,markers(t){let{state:e}=t,i=e.facet(kr),n=[];for(let s of e.selection.ranges){let o=s==e.selection.main;if(s.empty||i.drawRangeCursor){let e=o?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",i=s.empty?s:Lt.cursor(s.head,s.head>s.anchor?-1:1);for(let s of gr.forRange(t,e,i))n.push(s)}}return n},update(t,e){t.transactions.some(t=>t.selection)&&(e.style.animationName="cm-blink"==e.style.animationName?"cm-blink2":"cm-blink");let i=Cr(t);return i&&Mr(t.state,e),t.docChanged||t.selectionSet||i},mount(t,e){Mr(e.state,t)},class:"cm-cursorLayer"});function Mr(t,e){e.style.animationDuration=t.facet(kr).cursorBlinkRate+"ms"}const Tr=xr({above:!1,markers:t=>t.state.selection.ranges.map(e=>e.empty?[]:gr.forRange(t,"cm-selectionBackground",e)).reduce((t,e)=>t.concat(e)),update:(t,e)=>t.docChanged||t.selectionSet||t.viewportChanged||Cr(t),class:"cm-selectionLayer"}),Or=$t.highest(nr.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:"transparent !important"},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}})),Dr="-10000px";class Lr{constructor(t,e,i,n){this.facet=e,this.createTooltipView=i,this.removeTooltipView=n,this.input=t.state.facet(e),this.tooltips=this.input.filter(t=>t);let s=null;this.tooltipViews=this.tooltips.map(t=>s=i(t,s))}update(t,e){var i;let n=t.state.facet(this.facet),s=n.filter(t=>t);if(n===this.input){for(let e of this.tooltipViews)e.update&&e.update(t);return!1}let o=[],r=e?[]:null;for(let i=0;i<s.length;i++){let n=s[i],l=-1;if(n){for(let t=0;t<this.tooltips.length;t++){let e=this.tooltips[t];e&&e.create==n.create&&(l=t)}if(l<0)o[i]=this.createTooltipView(n,i?o[i-1]:null),r&&(r[i]=!!n.above);else{let n=o[i]=this.tooltipViews[l];r&&(r[i]=e[l]),n.update&&n.update(t)}}}for(let t of this.tooltipViews)o.indexOf(t)<0&&(this.removeTooltipView(t),null===(i=t.destroy)||void 0===i||i.call(t));return e&&(r.forEach((t,i)=>e[i]=t),e.length=r.length),this.input=n,this.tooltips=s,this.tooltipViews=o,!0}}function Er(t){let e=t.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:e.clientHeight,right:e.clientWidth}}const Pr=Bt.define({combine:t=>{var e,i,n;return{position:fi.ios?"absolute":(null===(e=t.find(t=>t.position))||void 0===e?void 0:e.position)||"fixed",parent:(null===(i=t.find(t=>t.parent))||void 0===i?void 0:i.parent)||null,tooltipSpace:(null===(n=t.find(t=>t.tooltipSpace))||void 0===n?void 0:n.tooltipSpace)||Er}}}),Br=new WeakMap,Rr=Zn.fromClass(class{constructor(t){this.view=t,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let e=t.state.facet(Pr);this.position=e.position,this.parent=e.parent,this.classes=t.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver="function"==typeof ResizeObserver?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new Lr(t,Hr,(t,e)=>this.createTooltip(t,e),t=>{this.resizeObserver&&this.resizeObserver.unobserve(t.dom),t.dom.remove()}),this.above=this.manager.tooltips.map(t=>!!t.above),this.intersectionObserver="function"==typeof IntersectionObserver?new IntersectionObserver(t=>{Date.now()>this.lastTransaction-50&&t.length>0&&t[t.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),t.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let t of this.manager.tooltipViews)this.intersectionObserver.observe(t.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(t){t.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(t,this.above);e&&this.observeIntersection();let i=e||t.geometryChanged,n=t.state.facet(Pr);if(n.position!=this.position&&!this.madeAbsolute){this.position=n.position;for(let t of this.manager.tooltipViews)t.dom.style.position=this.position;i=!0}if(n.parent!=this.parent){this.parent&&this.container.remove(),this.parent=n.parent,this.createContainer();for(let t of this.manager.tooltipViews)this.container.appendChild(t.dom);i=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);i&&this.maybeMeasure()}createTooltip(t,e){let i=t.create(this.view),n=e?e.dom:null;if(i.dom.classList.add("cm-tooltip"),t.arrow&&!i.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let t=document.createElement("div");t.className="cm-tooltip-arrow",i.dom.appendChild(t)}return i.dom.style.position=this.position,i.dom.style.top=Dr,i.dom.style.left="0px",this.container.insertBefore(i.dom,n),i.mount&&i.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(i.dom),i}destroy(){var t,e,i;this.view.win.removeEventListener("resize",this.measureSoon);for(let e of this.manager.tooltipViews)e.dom.remove(),null===(t=e.destroy)||void 0===t||t.call(e);this.parent&&this.container.remove(),null===(e=this.resizeObserver)||void 0===e||e.disconnect(),null===(i=this.intersectionObserver)||void 0===i||i.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let t=1,e=1,i=!1;if("fixed"==this.position&&this.manager.tooltipViews.length){let{dom:t}=this.manager.tooltipViews[0];if(fi.safari){let e=t.getBoundingClientRect();i=Math.abs(e.top+1e4)>1||Math.abs(e.left)>1}else i=!!t.offsetParent&&t.offsetParent!=this.container.ownerDocument.body}if(i||"absolute"==this.position)if(this.parent){let i=this.parent.getBoundingClientRect();i.width&&i.height&&(t=i.width/this.parent.offsetWidth,e=i.height/this.parent.offsetHeight)}else({scaleX:t,scaleY:e}=this.view.viewState);let n=this.view.scrollDOM.getBoundingClientRect(),s=hs(this.view);return{visible:{left:n.left+s.left,top:n.top+s.top,right:n.right-s.right,bottom:n.bottom-s.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((t,e)=>{let i=this.manager.tooltipViews[e];return i.getCoords?i.getCoords(t.pos):this.view.coordsAtPos(t.pos)}),size:this.manager.tooltipViews.map(({dom:t})=>t.getBoundingClientRect()),space:this.view.state.facet(Pr).tooltipSpace(this.view),scaleX:t,scaleY:e,makeAbsolute:i}}writeMeasure(t){var e;if(t.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let t of this.manager.tooltipViews)t.dom.style.position="absolute"}let{visible:i,space:n,scaleX:s,scaleY:o}=t,r=[];for(let l=0;l<this.manager.tooltips.length;l++){let a=this.manager.tooltips[l],h=this.manager.tooltipViews[l],{dom:c}=h,f=t.pos[l],d=t.size[l];if(!f||!1!==a.clip&&(f.bottom<=Math.max(i.top,n.top)||f.top>=Math.min(i.bottom,n.bottom)||f.right<Math.max(i.left,n.left)-.1||f.left>Math.min(i.right,n.right)+.1)){c.style.top=Dr;continue}let u=a.arrow?h.dom.querySelector(".cm-tooltip-arrow"):null,p=u?7:0,m=d.right-d.left,g=null!==(e=Br.get(h))&&void 0!==e?e:d.bottom-d.top,w=h.offset||jr,v=this.view.textDirection==mn.LTR,b=d.width>n.right-n.left?v?n.left:n.right-d.width:v?Math.max(n.left,Math.min(f.left-(u?14:0)+w.x,n.right-m)):Math.min(Math.max(n.left,f.left-m+(u?14:0)-w.x),n.right-m),y=this.above[l];!a.strictSide&&(y?f.top-g-p-w.y<n.top:f.bottom+g+p+w.y>n.bottom)&&y==n.bottom-f.bottom>f.top-n.top&&(y=this.above[l]=!y);let x=(y?f.top-n.top:n.bottom-f.bottom)-p;if(x<g&&!1!==h.resize){if(x<this.view.defaultLineHeight){c.style.top=Dr;continue}Br.set(h,g),c.style.height=(g=x)/o+"px"}else c.style.height&&(c.style.height="");let k=y?f.top-g-p-w.y:f.bottom+p+w.y,S=b+m;if(!0!==h.overlap)for(let t of r)t.left<S&&t.right>b&&t.top<k+g&&t.bottom>k&&(k=y?t.top-g-2-p:t.bottom+p+2);if("absolute"==this.position?(c.style.top=(k-t.parent.top)/o+"px",Nr(c,(b-t.parent.left)/s)):(c.style.top=k/o+"px",Nr(c,b/s)),u){let t=f.left+(v?w.x:-w.x)-(b+14-7);u.style.left=t/s+"px"}!0!==h.overlap&&r.push({left:b,top:k,right:S,bottom:k+g}),c.classList.toggle("cm-tooltip-above",y),c.classList.toggle("cm-tooltip-below",!y),h.positioned&&h.positioned(t.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let t of this.manager.tooltipViews)t.dom.style.top=Dr}},{eventObservers:{scroll(){this.maybeMeasure()}}});function Nr(t,e){let i=parseInt(t.style.left,10);(isNaN(i)||Math.abs(e-i)>1)&&(t.style.left=e+"px")}const Ir=nr.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:"14px",position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),jr={x:0,y:0},Hr=Bt.define({enables:[Rr,Ir]}),Vr=Bt.define({combine:t=>t.reduce((t,e)=>t.concat(e),[])});class Fr{static create(t){return new Fr(t)}constructor(t){this.view=t,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new Lr(t,Vr,(t,e)=>this.createHostedView(t,e),t=>t.dom.remove())}createHostedView(t,e){let i=t.create(this.view);return i.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(i.dom,e?e.dom.nextSibling:this.dom.firstChild),this.mounted&&i.mount&&i.mount(this.view),i}mount(t){for(let e of this.manager.tooltipViews)e.mount&&e.mount(t);this.mounted=!0}positioned(t){for(let e of this.manager.tooltipViews)e.positioned&&e.positioned(t)}update(t){this.manager.update(t)}destroy(){var t;for(let e of this.manager.tooltipViews)null===(t=e.destroy)||void 0===t||t.call(e)}passProp(t){let e;for(let i of this.manager.tooltipViews){let n=i[t];if(void 0!==n)if(void 0===e)e=n;else if(e!==n)return}return e}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}}const zr=Hr.compute([Vr],t=>{let e=t.facet(Vr);return 0===e.length?null:{pos:Math.min(...e.map(t=>t.pos)),end:Math.max(...e.map(t=>{var e;return null!==(e=t.end)&&void 0!==e?e:t.pos})),create:Fr.create,above:e[0].above,arrow:e.some(t=>t.arrow)}});class Wr{constructor(t,e,i,n,s){this.view=t,this.source=e,this.field=i,this.setHover=n,this.hoverTime=s,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:t.dom,time:0},this.checkHover=this.checkHover.bind(this),t.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),t.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let t=Date.now()-this.lastMove.time;t<this.hoverTime?this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-t):this.startHover()}startHover(){clearTimeout(this.restartTimeout);let{view:t,lastMove:e}=this,i=t.docView.nearest(e.target);if(!i)return;let n,s=1;if(i instanceof qi)n=i.posAtStart;else{if(n=t.posAtCoords(e),null==n)return;let i=t.coordsAtPos(n);if(!i||e.y<i.top||e.y>i.bottom||e.x<i.left-t.defaultCharacterWidth||e.x>i.right+t.defaultCharacterWidth)return;let o=t.bidiSpans(t.state.doc.lineAt(n)).find(t=>t.from<=n&&t.to>=n),r=o&&o.dir==mn.RTL?-1:1;s=e.x<i.left?-r:r}let o=this.source(t,n,s);if(null==o?void 0:o.then){let e=this.pending={pos:n};o.then(i=>{this.pending==e&&(this.pending=null,!i||Array.isArray(i)&&!i.length||t.dispatch({effects:this.setHover.of(Array.isArray(i)?i:[i])}))},e=>Yn(t.state,e,"hover tooltip"))}else!o||Array.isArray(o)&&!o.length||t.dispatch({effects:this.setHover.of(Array.isArray(o)?o:[o])})}get tooltip(){let t=this.view.plugin(Rr),e=t?t.manager.tooltips.findIndex(t=>t.create==Fr.create):-1;return e>-1?t.manager.tooltipViews[e]:null}mousemove(t){var e,i;this.lastMove={x:t.clientX,y:t.clientY,target:t.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:n,tooltip:s}=this;if(n.length&&s&&!function(t,e){let i,{left:n,right:s,top:o,bottom:r}=t.getBoundingClientRect();if(i=t.querySelector(".cm-tooltip-arrow")){let t=i.getBoundingClientRect();o=Math.min(t.top,o),r=Math.max(t.bottom,r)}return e.clientX>=n-qr&&e.clientX<=s+qr&&e.clientY>=o-qr&&e.clientY<=r+qr}(s.dom,t)||this.pending){let{pos:s}=n[0]||this.pending,o=null!==(i=null===(e=n[0])||void 0===e?void 0:e.end)&&void 0!==i?i:s;(s==o?this.view.posAtCoords(this.lastMove)==s:function(t,e,i,n,s){let o=t.scrollDOM.getBoundingClientRect(),r=t.documentTop+t.documentPadding.top+t.contentHeight;if(o.left>n||o.right<n||o.top>s||Math.min(o.bottom,r)<s)return!1;let l=t.posAtCoords({x:n,y:s},!1);return l>=e&&l<=i}(this.view,s,o,t.clientX,t.clientY))||(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(t){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:e}=this;if(e.length){let{tooltip:e}=this;e&&e.dom.contains(t.relatedTarget)?this.watchTooltipLeave(e.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(t){let e=i=>{t.removeEventListener("mouseleave",e),this.active.length&&!this.view.dom.contains(i.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};t.addEventListener("mouseleave",e)}destroy(){clearTimeout(this.hoverTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}const qr=4;function _r(t,e={}){let i=he.define(),n=Ft.define({create:()=>[],update(t,n){if(t.length&&(e.hideOnChange&&(n.docChanged||n.selection)?t=[]:e.hideOn&&(t=t.filter(t=>!e.hideOn(n,t))),n.docChanged)){let e=[];for(let i of t){let t=n.changes.mapPos(i.pos,-1,yt.TrackDel);if(null!=t){let s=Object.assign(Object.create(null),i);s.pos=t,null!=s.end&&(s.end=n.changes.mapPos(s.end)),e.push(s)}}t=e}for(let e of n.effects)e.is(i)&&(t=e.value),e.is(Kr)&&(t=[]);return t},provide:t=>Vr.from(t)});return{active:n,extension:[n,Zn.define(s=>new Wr(s,t,n,i,e.hoverTime||300)),zr]}}const Kr=he.define(),$r=Bt.define({combine(t){let e,i;for(let n of t)e=e||n.topContainer,i=i||n.bottomContainer;return{topContainer:e,bottomContainer:i}}});const Ur=Zn.fromClass(class{constructor(t){this.input=t.state.facet(Jr),this.specs=this.input.filter(t=>t),this.panels=this.specs.map(e=>e(t));let e=t.state.facet($r);this.top=new Gr(t,!0,e.topContainer),this.bottom=new Gr(t,!1,e.bottomContainer),this.top.sync(this.panels.filter(t=>t.top)),this.bottom.sync(this.panels.filter(t=>!t.top));for(let t of this.panels)t.dom.classList.add("cm-panel"),t.mount&&t.mount()}update(t){let e=t.state.facet($r);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new Gr(t.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new Gr(t.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let i=t.state.facet(Jr);if(i!=this.input){let e=i.filter(t=>t),n=[],s=[],o=[],r=[];for(let i of e){let e,l=this.specs.indexOf(i);l<0?(e=i(t.view),r.push(e)):(e=this.panels[l],e.update&&e.update(t)),n.push(e),(e.top?s:o).push(e)}this.specs=e,this.panels=n,this.top.sync(s),this.bottom.sync(o);for(let t of r)t.dom.classList.add("cm-panel"),t.mount&&t.mount()}else for(let e of this.panels)e.update&&e.update(t)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:t=>nr.scrollMargins.of(e=>{let i=e.plugin(t);return i&&{top:i.top.scrollMargin(),bottom:i.bottom.scrollMargin()}})});class Gr{constructor(t,e,i){this.view=t,this.top=e,this.container=i,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(t){for(let e of this.panels)e.destroy&&t.indexOf(e)<0&&e.destroy();this.panels=t,this.syncDOM()}syncDOM(){if(0==this.panels.length)return void(this.dom&&(this.dom.remove(),this.dom=void 0));if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom",this.dom.style[this.top?"top":"bottom"]="0";let t=this.container||this.view.dom;t.insertBefore(this.dom,this.top?t.firstChild:null)}let t=this.dom.firstChild;for(let e of this.panels)if(e.dom.parentNode==this.dom){for(;t!=e.dom;)t=Yr(t);t=t.nextSibling}else this.dom.insertBefore(e.dom,t);for(;t;)t=Yr(t)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(this.container&&this.classes!=this.view.themeClasses){for(let t of this.classes.split(" "))t&&this.container.classList.remove(t);for(let t of(this.classes=this.view.themeClasses).split(" "))t&&this.container.classList.add(t)}}}function Yr(t){let e=t.nextSibling;return t.remove(),e}const Jr=Bt.define({enables:Ur});class Xr extends Se{compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}eq(t){return!1}destroy(t){}}Xr.prototype.elementClass="",Xr.prototype.toDOM=void 0,Xr.prototype.mapMode=yt.TrackBefore,Xr.prototype.startSide=Xr.prototype.endSide=-1,Xr.prototype.point=!0;const Qr=Bt.define(),Zr=Bt.define(),tl={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>Te.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:"before"},el=Bt.define();function il(t){return[sl(),el.of({...tl,...t})]}const nl=Bt.define({combine:t=>t.some(t=>t)});function sl(t){return[ol]}const ol=Zn.fromClass(class{constructor(t){this.view=t,this.domAfter=null,this.prevViewport=t.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=t.state.facet(el).map(e=>new hl(t,e)),this.fixed=!t.state.facet(nl);for(let t of this.gutters)"after"==t.config.side?this.getDOMAfter().appendChild(t.dom):this.dom.appendChild(t.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),t.scrollDOM.insertBefore(this.dom,t.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(t){if(this.updateGutters(t)){let e=this.prevViewport,i=t.view.viewport,n=Math.min(e.to,i.to)-Math.max(e.from,i.from);this.syncGutters(n<.8*(i.to-i.from))}if(t.geometryChanged){let t=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=t,this.domAfter&&(this.domAfter.style.minHeight=t)}this.view.state.facet(nl)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=t.view.viewport}syncGutters(t){let e=this.dom.nextSibling;t&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let i=Te.iter(this.view.state.facet(Qr),this.view.viewport.from),n=[],s=this.gutters.map(t=>new al(t,this.view.viewport,-this.view.documentPadding.top));for(let t of this.view.viewportLineBlocks)if(n.length&&(n=[]),Array.isArray(t.type)){let e=!0;for(let o of t.type)if(o.type==en.Text&&e){ll(i,n,o.from);for(let t of s)t.line(this.view,o,n);e=!1}else if(o.widget)for(let t of s)t.widget(this.view,o)}else if(t.type==en.Text){ll(i,n,t.from);for(let e of s)e.line(this.view,t,n)}else if(t.widget)for(let e of s)e.widget(this.view,t);for(let t of s)t.finish();t&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(t){let e=t.startState.facet(el),i=t.state.facet(el),n=t.docChanged||t.heightChanged||t.viewportChanged||!Te.eq(t.startState.facet(Qr),t.state.facet(Qr),t.view.viewport.from,t.view.viewport.to);if(e==i)for(let e of this.gutters)e.update(t)&&(n=!0);else{n=!0;let s=[];for(let n of i){let i=e.indexOf(n);i<0?s.push(new hl(this.view,n)):(this.gutters[i].update(t),s.push(this.gutters[i]))}for(let t of this.gutters)t.dom.remove(),s.indexOf(t)<0&&t.destroy();for(let t of s)"after"==t.config.side?this.getDOMAfter().appendChild(t.dom):this.dom.appendChild(t.dom);this.gutters=s}return n}destroy(){for(let t of this.gutters)t.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:t=>nr.scrollMargins.of(e=>{let i=e.plugin(t);if(!i||0==i.gutters.length||!i.fixed)return null;let n=i.dom.offsetWidth*e.scaleX,s=i.domAfter?i.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==mn.LTR?{left:n,right:s}:{right:n,left:s}})});function rl(t){return Array.isArray(t)?t:[t]}function ll(t,e,i){for(;t.value&&t.from<=i;)t.from==i&&e.push(t.value),t.next()}class al{constructor(t,e,i){this.gutter=t,this.height=i,this.i=0,this.cursor=Te.iter(t.markers,e.from)}addElement(t,e,i){let{gutter:n}=this,s=(e.top-this.height)/t.scaleY,o=e.height/t.scaleY;if(this.i==n.elements.length){let e=new cl(t,o,s,i);n.elements.push(e),n.dom.appendChild(e.dom)}else n.elements[this.i].update(t,o,s,i);this.height=e.bottom,this.i++}line(t,e,i){let n=[];ll(this.cursor,n,e.from),i.length&&(n=n.concat(i));let s=this.gutter.config.lineMarker(t,e,n);s&&n.unshift(s);let o=this.gutter;(0!=n.length||o.config.renderEmptyElements)&&this.addElement(t,e,n)}widget(t,e){let i=this.gutter.config.widgetMarker(t,e.widget,e),n=i?[i]:null;for(let i of t.state.facet(Zr)){let s=i(t,e.widget,e);s&&(n||(n=[])).push(s)}n&&this.addElement(t,e,n)}finish(){let t=this.gutter;for(;t.elements.length>this.i;){let e=t.elements.pop();t.dom.removeChild(e.dom),e.destroy()}}}class hl{constructor(t,e){this.view=t,this.config=e,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let i in e.domEventHandlers)this.dom.addEventListener(i,n=>{let s,o=n.target;if(o!=this.dom&&this.dom.contains(o)){for(;o.parentNode!=this.dom;)o=o.parentNode;let t=o.getBoundingClientRect();s=(t.top+t.bottom)/2}else s=n.clientY;let r=t.lineBlockAtHeight(s-t.documentTop);e.domEventHandlers[i](t,r,n)&&n.preventDefault()});this.markers=rl(e.markers(t)),e.initialSpacer&&(this.spacer=new cl(t,0,0,[e.initialSpacer(t)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(t){let e=this.markers;if(this.markers=rl(this.config.markers(t.view)),this.spacer&&this.config.updateSpacer){let e=this.config.updateSpacer(this.spacer.markers[0],t);e!=this.spacer.markers[0]&&this.spacer.update(t.view,0,0,[e])}let i=t.view.viewport;return!Te.eq(this.markers,e,i.from,i.to)||!!this.config.lineMarkerChange&&this.config.lineMarkerChange(t)}destroy(){for(let t of this.elements)t.destroy()}}class cl{constructor(t,e,i,n){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(t,e,i,n)}update(t,e,i,n){this.height!=e&&(this.height=e,this.dom.style.height=e+"px"),this.above!=i&&(this.dom.style.marginTop=(this.above=i)?i+"px":""),function(t,e){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++)if(!t[i].compare(e[i]))return!1;return!0}(this.markers,n)||this.setMarkers(t,n)}setMarkers(t,e){let i="cm-gutterElement",n=this.dom.firstChild;for(let s=0,o=0;;){let r=o,l=s<e.length?e[s++]:null,a=!1;if(l){let t=l.elementClass;t&&(i+=" "+t);for(let t=o;t<this.markers.length;t++)if(this.markers[t].compare(l)){r=t,a=!0;break}}else r=this.markers.length;for(;o<r;){let t=this.markers[o++];if(t.toDOM){t.destroy(n);let e=n.nextSibling;n.remove(),n=e}}if(!l)break;l.toDOM&&(a?n=n.nextSibling:this.dom.insertBefore(l.toDOM(t),n)),a&&o++}this.dom.className=i,this.markers=e}destroy(){this.setMarkers(null,[])}}const fl=Bt.define(),dl=Bt.define(),ul=Bt.define({combine:t=>ke(t,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(t,e){let i=Object.assign({},t);for(let t in e){let n=i[t],s=e[t];i[t]=n?(t,e,i)=>n(t,e,i)||s(t,e,i):s}return i}})});class pl extends Xr{constructor(t){super(),this.number=t}eq(t){return this.number==t.number}toDOM(){return document.createTextNode(this.number)}}function ml(t,e){return t.state.facet(ul).formatNumber(e,t.state)}const gl=el.compute([ul],t=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers:t=>t.state.facet(fl),lineMarker:(t,e,i)=>i.some(t=>t.toDOM)?null:new pl(ml(t,t.state.doc.lineAt(e.from).number)),widgetMarker:(t,e,i)=>{for(let n of t.state.facet(dl)){let s=n(t,e,i);if(s)return s}return null},lineMarkerChange:t=>t.startState.facet(ul)!=t.state.facet(ul),initialSpacer:t=>new pl(ml(t,vl(t.state.doc.lines))),updateSpacer(t,e){let i=ml(e.view,vl(e.view.state.doc.lines));return i==t.number?t:new pl(i)},domEventHandlers:t.facet(ul).domEventHandlers,side:"before"}));function wl(t={}){return[ul.of(t),sl(),gl]}function vl(t){let e=9;for(;e<t;)e=10*e+9;return e}let bl=0;class yl{constructor(t,e,i,n){this.name=t,this.set=e,this.base=i,this.modified=n,this.id=bl++}toString(){let{name:t}=this;for(let e of this.modified)e.name&&(t=`${e.name}(${t})`);return t}static define(t,e){let i="string"==typeof t?t:"?";if(t instanceof yl&&(e=t),null==e?void 0:e.base)throw new Error("Can not derive from a modified tag");let n=new yl(i,[],null,[]);if(n.set.push(n),e)for(let t of e.set)n.set.push(t);return n}static defineModifier(t){let e=new kl(t);return t=>t.modified.indexOf(e)>-1?t:kl.get(t.base||t,t.modified.concat(e).sort((t,e)=>t.id-e.id))}}let xl=0;class kl{constructor(t){this.name=t,this.instances=[],this.id=xl++}static get(t,e){if(!e.length)return t;let i=e[0].instances.find(i=>{return i.base==t&&(n=e,s=i.modified,n.length==s.length&&n.every((t,e)=>t==s[e]));var n,s});if(i)return i;let n=[],s=new yl(t.name,n,t,e);for(let t of e)t.instances.push(s);let o=function(t){let e=[[]];for(let i=0;i<t.length;i++)for(let n=0,s=e.length;n<s;n++)e.push(e[n].concat(t[i]));return e.sort((t,e)=>e.length-t.length)}(e);for(let e of t.set)if(!e.modified.length)for(let t of o)n.push(kl.get(e,t));return s}}function Sl(t){let e=Object.create(null);for(let i in t){let n=t[i];Array.isArray(n)||(n=[n]);for(let t of i.split(" "))if(t){let i=[],s=2,o=t;for(let e=0;;){if("..."==o&&e>0&&e+3==t.length){s=1;break}let n=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(o);if(!n)throw new RangeError("Invalid path: "+t);if(i.push("*"==n[0]?"":'"'==n[0][0]?JSON.parse(n[0]):n[0]),e+=n[0].length,e==t.length)break;let r=t[e++];if(e==t.length&&"!"==r){s=0;break}if("/"!=r)throw new RangeError("Invalid path: "+t);o=t.slice(e)}let r=i.length-1,l=i[r];if(!l)throw new RangeError("Invalid path: "+t);let a=new Al(n,s,r>0?i.slice(0,r):null);e[l]=a.sort(e[l])}}return Cl.add(e)}const Cl=new o({combine(t,e){let i,n,s;for(;t||e;){if(!t||e&&t.depth>=e.depth?(s=e,e=e.next):(s=t,t=t.next),i&&i.mode==s.mode&&!s.context&&!i.context)continue;let o=new Al(s.tags,s.mode,s.context);i?i.next=o:n=o,i=o}return n}});class Al{constructor(t,e,i,n){this.tags=t,this.mode=e,this.context=i,this.next=n}get opaque(){return 0==this.mode}get inherit(){return 1==this.mode}sort(t){return!t||t.depth<this.depth?(this.next=t,this):(t.next=this.sort(t.next),t)}get depth(){return this.context?this.context.length:0}}function Ml(t,e){let i=Object.create(null);for(let e of t)if(Array.isArray(e.tag))for(let t of e.tag)i[t.id]=e.class;else i[e.tag.id]=e.class;let{scope:n,all:s=null}=e||{};return{style:t=>{let e=s;for(let n of t)for(let t of n.set){let n=i[t.id];if(n){e=e?e+" "+n:n;break}}return e},scope:n}}function Tl(t,e,i,n=0,s=t.length){let o=new Ol(n,Array.isArray(e)?e:[e],i);o.highlightRange(t.cursor(),n,s,"",o.highlighters),o.flush(s)}Al.empty=new Al([],2,null);class Ol{constructor(t,e,i){this.at=t,this.highlighters=e,this.span=i,this.class=""}startSpan(t,e){e!=this.class&&(this.flush(t),t>this.at&&(this.at=t),this.class=e)}flush(t){t>this.at&&this.class&&this.span(this.at,t,this.class)}highlightRange(t,e,i,n,s){let{type:r,from:l,to:a}=t;if(l>=i||a<=e)return;r.isTop&&(s=this.highlighters.filter(t=>!t.scope||t.scope(r)));let h=n,c=function(t){let e=t.type.prop(Cl);for(;e&&e.context&&!t.matchContext(e.context);)e=e.next;return e||null}(t)||Al.empty,f=function(t,e){let i=null;for(let n of t){let t=n.style(e);t&&(i=i?i+" "+t:t)}return i}(s,c.tags);if(f&&(h&&(h+=" "),h+=f,1==c.mode&&(n+=(n?" ":"")+f)),this.startSpan(Math.max(e,l),h),c.opaque)return;let d=t.tree&&t.tree.prop(o.mounted);if(d&&d.overlay){let o=t.node.enter(d.overlay[0].from+l,1),r=this.highlighters.filter(t=>!t.scope||t.scope(d.tree.type)),c=t.firstChild();for(let f=0,u=l;;f++){let p=f<d.overlay.length?d.overlay[f]:null,m=p?p.from+l:a,g=Math.max(e,u),w=Math.min(i,m);if(g<w&&c)for(;t.from<w&&(this.highlightRange(t,g,w,n,s),this.startSpan(Math.min(w,t.to),h),!(t.to>=m)&&t.nextSibling()););if(!p||m>i)break;u=p.to+l,u>e&&(this.highlightRange(o.cursor(),Math.max(e,p.from+l),Math.min(i,u),"",r),this.startSpan(Math.min(i,u),h))}c&&t.parent()}else if(t.firstChild()){d&&(n="");do{if(!(t.to<=e)){if(t.from>=i)break;this.highlightRange(t,e,i,n,s),this.startSpan(Math.min(i,t.to),h)}}while(t.nextSibling());t.parent()}}}const Dl=yl.define,Ll=Dl(),El=Dl(),Pl=Dl(El),Bl=Dl(El),Rl=Dl(),Nl=Dl(Rl),Il=Dl(Rl),jl=Dl(),Hl=Dl(jl),Vl=Dl(),Fl=Dl(),zl=Dl(),Wl=Dl(zl),ql=Dl(),_l={comment:Ll,lineComment:Dl(Ll),blockComment:Dl(Ll),docComment:Dl(Ll),name:El,variableName:Dl(El),typeName:Pl,tagName:Dl(Pl),propertyName:Bl,attributeName:Dl(Bl),className:Dl(El),labelName:Dl(El),namespace:Dl(El),macroName:Dl(El),literal:Rl,string:Nl,docString:Dl(Nl),character:Dl(Nl),attributeValue:Dl(Nl),number:Il,integer:Dl(Il),float:Dl(Il),bool:Dl(Rl),regexp:Dl(Rl),escape:Dl(Rl),color:Dl(Rl),url:Dl(Rl),keyword:Vl,self:Dl(Vl),null:Dl(Vl),atom:Dl(Vl),unit:Dl(Vl),modifier:Dl(Vl),operatorKeyword:Dl(Vl),controlKeyword:Dl(Vl),definitionKeyword:Dl(Vl),moduleKeyword:Dl(Vl),operator:Fl,derefOperator:Dl(Fl),arithmeticOperator:Dl(Fl),logicOperator:Dl(Fl),bitwiseOperator:Dl(Fl),compareOperator:Dl(Fl),updateOperator:Dl(Fl),definitionOperator:Dl(Fl),typeOperator:Dl(Fl),controlOperator:Dl(Fl),punctuation:zl,separator:Dl(zl),bracket:Wl,angleBracket:Dl(Wl),squareBracket:Dl(Wl),paren:Dl(Wl),brace:Dl(Wl),content:jl,heading:Hl,heading1:Dl(Hl),heading2:Dl(Hl),heading3:Dl(Hl),heading4:Dl(Hl),heading5:Dl(Hl),heading6:Dl(Hl),contentSeparator:Dl(jl),list:Dl(jl),quote:Dl(jl),emphasis:Dl(jl),strong:Dl(jl),link:Dl(jl),monospace:Dl(jl),strikethrough:Dl(jl),inserted:Dl(),deleted:Dl(),changed:Dl(),invalid:Dl(),meta:ql,documentMeta:Dl(ql),annotation:Dl(ql),processingInstruction:Dl(ql),definition:yl.defineModifier("definition"),constant:yl.defineModifier("constant"),function:yl.defineModifier("function"),standard:yl.defineModifier("standard"),local:yl.defineModifier("local"),special:yl.defineModifier("special")};for(let t in _l){let e=_l[t];e instanceof yl&&(e.name=t)}var Kl;Ml([{tag:_l.link,class:"tok-link"},{tag:_l.heading,class:"tok-heading"},{tag:_l.emphasis,class:"tok-emphasis"},{tag:_l.strong,class:"tok-strong"},{tag:_l.keyword,class:"tok-keyword"},{tag:_l.atom,class:"tok-atom"},{tag:_l.bool,class:"tok-bool"},{tag:_l.url,class:"tok-url"},{tag:_l.labelName,class:"tok-labelName"},{tag:_l.inserted,class:"tok-inserted"},{tag:_l.deleted,class:"tok-deleted"},{tag:_l.literal,class:"tok-literal"},{tag:_l.string,class:"tok-string"},{tag:_l.number,class:"tok-number"},{tag:[_l.regexp,_l.escape,_l.special(_l.string)],class:"tok-string2"},{tag:_l.variableName,class:"tok-variableName"},{tag:_l.local(_l.variableName),class:"tok-variableName tok-local"},{tag:_l.definition(_l.variableName),class:"tok-variableName tok-definition"},{tag:_l.special(_l.variableName),class:"tok-variableName2"},{tag:_l.definition(_l.propertyName),class:"tok-propertyName tok-definition"},{tag:_l.typeName,class:"tok-typeName"},{tag:_l.namespace,class:"tok-namespace"},{tag:_l.className,class:"tok-className"},{tag:_l.macroName,class:"tok-macroName"},{tag:_l.propertyName,class:"tok-propertyName"},{tag:_l.operator,class:"tok-operator"},{tag:_l.comment,class:"tok-comment"},{tag:_l.meta,class:"tok-meta"},{tag:_l.invalid,class:"tok-invalid"},{tag:_l.punctuation,class:"tok-punctuation"}]);const $l=new o;function Ul(t){return Bt.define({combine:t?e=>e.concat(t):void 0})}const Gl=new o;class Yl{constructor(t,e,i=[],n=""){this.data=t,this.name=n,xe.prototype.hasOwnProperty("tree")||Object.defineProperty(xe.prototype,"tree",{get(){return Ql(this)}}),this.parser=e,this.extension=[la.of(this),xe.languageData.of((t,e,i)=>{let n=Jl(t,e,i),s=n.type.prop($l);if(!s)return[];let o=t.facet(s),r=n.type.prop(Gl);if(r){let s=n.resolve(e-n.from,i);for(let e of r)if(e.test(s,t)){let i=t.facet(e.facet);return"replace"==e.type?i:i.concat(o)}}return o})].concat(i)}isActiveAt(t,e,i=-1){return Jl(t,e,i).type.prop($l)==this.data}findRegions(t){let e=t.facet(la);if((null==e?void 0:e.data)==this.data)return[{from:0,to:t.doc.length}];if(!e||!e.allowsNesting)return[];let i=[],n=(t,e)=>{if(t.prop($l)==this.data)return void i.push({from:e,to:e+t.length});let s=t.prop(o.mounted);if(s){if(s.tree.prop($l)==this.data){if(s.overlay)for(let t of s.overlay)i.push({from:t.from+e,to:t.to+e});else i.push({from:e,to:e+t.length});return}if(s.overlay){let t=i.length;if(n(s.tree,s.overlay[0].from+e),i.length>t)return}}for(let i=0;i<t.children.length;i++){let s=t.children[i];s instanceof u&&n(s,t.positions[i]+e)}};return n(Ql(t),0),i}get allowsNesting(){return!0}}function Jl(t,e,i){let n=t.facet(la),s=Ql(t).topNode;if(!n||n.allowsNesting)for(let t=s;t;t=t.enter(e,i,d.ExcludeBuffers))t.type.isTop&&(s=t);return s}Yl.setState=he.define();class Xl extends Yl{constructor(t,e,i){super(t,e,[],i),this.parser=e}static define(t){let e=Ul(t.languageData);return new Xl(e,t.parser.configure({props:[$l.add(t=>t.isTop?e:void 0)]}),t.name)}configure(t,e){return new Xl(this.data,this.parser.configure(t),e||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function Ql(t){let e=t.field(Yl.state,!1);return e?e.tree:u.empty}class Zl{constructor(t){this.doc=t,this.cursorPos=0,this.string="",this.cursor=t.iter()}get length(){return this.doc.length}syncTo(t){return this.string=this.cursor.next(t-this.cursorPos).value,this.cursorPos=t+this.string.length,this.cursorPos-this.string.length}chunk(t){return this.syncTo(t),this.string}get lineChunks(){return!0}read(t,e){let i=this.cursorPos-this.string.length;return t<i||e>=this.cursorPos?this.doc.sliceString(t,e):this.string.slice(t-i,e-i)}}let ta=null;class ea{constructor(t,e,i=[],n,s,o,r,l){this.parser=t,this.state=e,this.fragments=i,this.tree=n,this.treeLen=s,this.viewport=o,this.skipped=r,this.scheduleOn=l,this.parse=null,this.tempSkipped=[]}static create(t,e,i){return new ea(t,e,[],u.empty,0,i,[],null)}startParse(){return this.parser.startParse(new Zl(this.state.doc),this.fragments)}work(t,e){return null!=e&&e>=this.state.doc.length&&(e=void 0),this.tree!=u.empty&&this.isDone(null!=e?e:this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var i;if("number"==typeof t){let e=Date.now()+t;t=()=>Date.now()>e}for(this.parse||(this.parse=this.startParse()),null!=e&&(null==this.parse.stoppedAt||this.parse.stoppedAt>e)&&e<this.state.doc.length&&this.parse.stopAt(e);;){let n=this.parse.advance();if(n){if(this.fragments=this.withoutTempSkipped(P.addTree(n,this.fragments,null!=this.parse.stoppedAt)),this.treeLen=null!==(i=this.parse.stoppedAt)&&void 0!==i?i:this.state.doc.length,this.tree=n,this.parse=null,!(this.treeLen<(null!=e?e:this.state.doc.length)))return!0;this.parse=this.startParse()}if(t())return!1}})}takeTree(){let t,e;this.parse&&(t=this.parse.parsedPos)>=this.treeLen&&((null==this.parse.stoppedAt||this.parse.stoppedAt>t)&&this.parse.stopAt(t),this.withContext(()=>{for(;!(e=this.parse.advance()););}),this.treeLen=t,this.tree=e,this.fragments=this.withoutTempSkipped(P.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(t){let e=ta;ta=this;try{return t()}finally{ta=e}}withoutTempSkipped(t){for(let e;e=this.tempSkipped.pop();)t=ia(t,e.from,e.to);return t}changes(t,e){let{fragments:i,tree:n,treeLen:s,viewport:o,skipped:r}=this;if(this.takeTree(),!t.empty){let e=[];if(t.iterChangedRanges((t,i,n,s)=>e.push({fromA:t,toA:i,fromB:n,toB:s})),i=P.applyChanges(i,e),n=u.empty,s=0,o={from:t.mapPos(o.from,-1),to:t.mapPos(o.to,1)},this.skipped.length){r=[];for(let e of this.skipped){let i=t.mapPos(e.from,1),n=t.mapPos(e.to,-1);i<n&&r.push({from:i,to:n})}}}return new ea(this.parser,e,i,n,s,o,r,this.scheduleOn)}updateViewport(t){if(this.viewport.from==t.from&&this.viewport.to==t.to)return!1;this.viewport=t;let e=this.skipped.length;for(let e=0;e<this.skipped.length;e++){let{from:i,to:n}=this.skipped[e];i<t.to&&n>t.from&&(this.fragments=ia(this.fragments,i,n),this.skipped.splice(e--,1))}return!(this.skipped.length>=e)&&(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(t,e){this.skipped.push({from:t,to:e})}static getSkippingParser(t){return new class extends B{createParse(e,i,n){let s=n[0].from,o=n[n.length-1].to;return{parsedPos:s,advance(){let e=ta;if(e){for(let t of n)e.tempSkipped.push(t);t&&(e.scheduleOn=e.scheduleOn?Promise.all([e.scheduleOn,t]):t)}return this.parsedPos=o,new u(a.none,[],[],o-s)},stoppedAt:null,stopAt(){}}}}}isDone(t){t=Math.min(t,this.state.doc.length);let e=this.fragments;return this.treeLen>=t&&e.length&&0==e[0].from&&e[0].to>=t}static get(){return ta}}function ia(t,e,i){return P.applyChanges(t,[{fromA:e,toA:i,fromB:e,toB:i}])}class na{constructor(t){this.context=t,this.tree=t.tree}apply(t){if(!t.docChanged&&this.tree==this.context.tree)return this;let e=this.context.changes(t.changes,t.state),i=this.context.treeLen==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.treeLen),e.viewport.to);return e.work(20,i)||e.takeTree(),new na(e)}static init(t){let e=Math.min(3e3,t.doc.length),i=ea.create(t.facet(la).parser,t,{from:0,to:e});return i.work(20,e)||i.takeTree(),new na(i)}}Yl.state=Ft.define({create:na.init,update(t,e){for(let t of e.effects)if(t.is(Yl.setState))return t.value;return e.startState.facet(la)!=e.state.facet(la)?na.init(e.state):t.apply(e)}});let sa=t=>{let e=setTimeout(()=>t(),500);return()=>clearTimeout(e)};"undefined"!=typeof requestIdleCallback&&(sa=t=>{let e=-1,i=setTimeout(()=>{e=requestIdleCallback(t,{timeout:400})},100);return()=>e<0?clearTimeout(i):cancelIdleCallback(e)});const oa="undefined"!=typeof navigator&&(null===(Kl=navigator.scheduling)||void 0===Kl?void 0:Kl.isInputPending)?()=>navigator.scheduling.isInputPending():null,ra=Zn.fromClass(class{constructor(t){this.view=t,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(t){let e=this.view.state.field(Yl.state).context;(e.updateViewport(t.view.viewport)||this.view.viewport.to>e.treeLen)&&this.scheduleWork(),(t.docChanged||t.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(e)}scheduleWork(){if(this.working)return;let{state:t}=this.view,e=t.field(Yl.state);e.tree==e.context.tree&&e.context.isDone(t.doc.length)||(this.working=sa(this.work))}work(t){this.working=null;let e=Date.now();if(this.chunkEnd<e&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=e+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:i,viewport:{to:n}}=this.view,s=i.field(Yl.state);if(s.tree==s.context.tree&&s.context.isDone(n+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,t&&!oa?Math.max(25,t.timeRemaining()-5):1e9),r=s.context.treeLen<n&&i.doc.length>n+1e3,l=s.context.work(()=>oa&&oa()||Date.now()>o,n+(r?0:1e5));this.chunkBudget-=Date.now()-e,(l||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:Yl.setState.of(new na(s.context))})),this.chunkBudget>0&&(!l||r)&&this.scheduleWork(),this.checkAsyncSchedule(s.context)}checkAsyncSchedule(t){t.scheduleOn&&(this.workScheduled++,t.scheduleOn.then(()=>this.scheduleWork()).catch(t=>Yn(this.view.state,t)).then(()=>this.workScheduled--),t.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),la=Bt.define({combine:t=>t.length?t[0]:null,enables:t=>[Yl.state,ra,nr.contentAttributes.compute([t],e=>{let i=e.facet(t);return i&&i.name?{"data-language":i.name}:{}})]});class aa{constructor(t,e=[]){this.language=t,this.support=e,this.extension=[t,e]}}class ha{constructor(t,e,i,n,s,o=void 0){this.name=t,this.alias=e,this.extensions=i,this.filename=n,this.loadFunc=s,this.support=o,this.loading=null}load(){return this.loading||(this.loading=this.loadFunc().then(t=>this.support=t,t=>{throw this.loading=null,t}))}static of(t){let{load:e,support:i}=t;if(!e){if(!i)throw new RangeError("Must pass either 'load' or 'support' to LanguageDescription.of");e=()=>Promise.resolve(i)}return new ha(t.name,(t.alias||[]).concat(t.name).map(t=>t.toLowerCase()),t.extensions||[],t.filename,e,i)}static matchFilename(t,e){for(let i of t)if(i.filename&&i.filename.test(e))return i;let i=/\.([^.]+)$/.exec(e);if(i)for(let e of t)if(e.extensions.indexOf(i[1])>-1)return e;return null}static matchLanguageName(t,e,i=!0){e=e.toLowerCase();for(let i of t)if(i.alias.some(t=>t==e))return i;if(i)for(let i of t)for(let t of i.alias){let n=e.indexOf(t);if(n>-1&&(t.length>2||!/\w/.test(e[n-1])&&!/\w/.test(e[n+t.length])))return i}return null}}const ca=Bt.define(),fa=Bt.define({combine:t=>{if(!t.length)return" ";let e=t[0];if(!e||/\S/.test(e)||Array.from(e).some(t=>t!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(t[0]));return e}});function da(t){let e=t.facet(fa);return 9==e.charCodeAt(0)?t.tabSize*e.length:e.length}function ua(t,e){let i="",n=t.tabSize,s=t.facet(fa)[0];if("\t"==s){for(;e>=n;)i+="\t",e-=n;s=" "}for(let t=0;t<e;t++)i+=s;return i}function pa(t,e){t instanceof xe&&(t=new ma(t));for(let i of t.state.facet(ca)){let n=i(t,e);if(void 0!==n)return n}let i=Ql(t.state);return i.length>=e?function(t,e,i){let n=e.resolveStack(i),s=e.resolveInner(i,-1).resolve(i,0).enterUnfinishedNodesBefore(i);if(s!=n.node){let t=[];for(let e=s;e&&!(e.from<n.node.from||e.to>n.node.to||e.from==n.node.from&&e.type==n.node.type);e=e.parent)t.push(e);for(let e=t.length-1;e>=0;e--)n={node:t[e],next:n}}return wa(n,t,i)}(t,i,e):null}class ma{constructor(t,e={}){this.state=t,this.options=e,this.unit=da(t)}lineAt(t,e=1){let i=this.state.doc.lineAt(t),{simulateBreak:n,simulateDoubleBreak:s}=this.options;return null!=n&&n>=i.from&&n<=i.to?s&&n==t?{text:"",from:t}:(e<0?n<t:n<=t)?{text:i.text.slice(n-i.from),from:n}:{text:i.text.slice(0,n-i.from),from:i.from}:i}textAfterPos(t,e=1){if(this.options.simulateDoubleBreak&&t==this.options.simulateBreak)return"";let{text:i,from:n}=this.lineAt(t,e);return i.slice(t-n,Math.min(i.length,t+100-n))}column(t,e=1){let{text:i,from:n}=this.lineAt(t,e),s=this.countColumn(i,t-n),o=this.options.overrideIndentation?this.options.overrideIndentation(n):-1;return o>-1&&(s+=o-this.countColumn(i,i.search(/\S|$/))),s}countColumn(t,e=t.length){return Ve(t,this.state.tabSize,e)}lineIndent(t,e=1){let{text:i,from:n}=this.lineAt(t,e),s=this.options.overrideIndentation;if(s){let t=s(n);if(t>-1)return t}return this.countColumn(i,i.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const ga=new o;function wa(t,e,i){for(let n=t;n;n=n.next){let t=va(n.node);if(t)return t(ya.create(e,i,n))}return 0}function va(t){let e=t.type.prop(ga);if(e)return e;let i,n=t.firstChild;if(n&&(i=n.type.prop(o.closedBy))){let e=t.lastChild,n=e&&i.indexOf(e.name)>-1;return t=>Sa(t,!0,1,void 0,n&&!function(t){return t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak}(t)?e.from:void 0)}return null==t.parent?ba:null}function ba(){return 0}class ya extends ma{constructor(t,e,i){super(t.state,t.options),this.base=t,this.pos=e,this.context=i}get node(){return this.context.node}static create(t,e,i){return new ya(t,e,i)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(t){let e=this.state.doc.lineAt(t.from);for(;;){let i=t.resolve(e.from);for(;i.parent&&i.parent.from==i.from;)i=i.parent;if(xa(i,t))break;e=this.state.doc.lineAt(i.from)}return this.lineIndent(e.from)}continue(){return wa(this.context.next,this.base,this.pos)}}function xa(t,e){for(let i=e;i;i=i.parent)if(t==i)return!0;return!1}function ka({closing:t,align:e=!0,units:i=1}){return n=>Sa(n,e,i,t)}function Sa(t,e,i,n,s){let o=t.textAfter,r=o.match(/^\s*/)[0].length,l=n&&o.slice(r,r+n.length)==n||s==t.pos+r,a=e?function(t){let e=t.node,i=e.childAfter(e.from),n=e.lastChild;if(!i)return null;let s=t.options.simulateBreak,o=t.state.doc.lineAt(i.from),r=null==s||s<=o.from?o.to:Math.min(o.to,s);for(let t=i.to;;){let s=e.childAfter(t);if(!s||s==n)return null;if(!s.type.isSkipped){if(s.from>=r)return null;let t=/^ */.exec(o.text.slice(i.to-o.from))[0].length;return{from:i.from,to:i.to+t}}t=s.to}}(t):null;return a?l?t.column(a.from):t.column(a.to):t.baseIndent+(l?0:t.unit*i)}const Ca=t=>t.baseIndent;function Aa({except:t,units:e=1}={}){return i=>{let n=t&&t.test(i.textAfter);return i.baseIndent+(n?0:e*i.unit)}}const Ma=Bt.define(),Ta=new o;function Oa(t){let e=t.firstChild,i=t.lastChild;return e&&e.to<i.from?{from:e.to,to:i.type.isError?t.to:i.from}:null}function Da(t){let e=t.lastChild;return e&&e.to==t.to&&e.type.isError}function La(t,e,i){for(let n of t.facet(Ma)){let s=n(t,e,i);if(s)return s}return function(t,e,i){let n=Ql(t);if(n.length<i)return null;let s=null;for(let o=n.resolveStack(i,1);o;o=o.next){let r=o.node;if(r.to<=i||r.from>i)continue;if(s&&r.from<e)break;let l=r.type.prop(Ta);if(l&&(r.to<n.length-50||n.length==t.doc.length||!Da(r))){let n=l(r,t);n&&n.from<=i&&n.from>=e&&n.to>i&&(s=n)}}return s}(t,e,i)}function Ea(t,e){let i=e.mapPos(t.from,1),n=e.mapPos(t.to,-1);return i>=n?void 0:{from:i,to:n}}const Pa=he.define({map:Ea}),Ba=he.define({map:Ea});function Ra(t){let e=[];for(let{head:i}of t.state.selection.ranges)e.some(t=>t.from<=i&&t.to>=i)||e.push(t.lineBlockAt(i));return e}const Na=Ft.define({create:()=>nn.none,update(t,e){e.isUserEvent("delete")&&e.changes.iterChangedRanges((e,i)=>t=Ia(t,e,i)),t=t.map(e.changes);for(let i of e.effects)if(i.is(Pa)&&!Ha(t,i.value.from,i.value.to)){let{preparePlaceholder:n}=e.state.facet(qa),s=n?nn.replace({widget:new Ua(n(e.state,i.value))}):$a;t=t.update({add:[s.range(i.value.from,i.value.to)]})}else i.is(Ba)&&(t=t.update({filter:(t,e)=>i.value.from!=t||i.value.to!=e,filterFrom:i.value.from,filterTo:i.value.to}));return e.selection&&(t=Ia(t,e.selection.main.head)),t},provide:t=>nr.decorations.from(t),toJSON(t,e){let i=[];return t.between(0,e.doc.length,(t,e)=>{i.push(t,e)}),i},fromJSON(t){if(!Array.isArray(t)||t.length%2)throw new RangeError("Invalid JSON for fold state");let e=[];for(let i=0;i<t.length;){let n=t[i++],s=t[i++];if("number"!=typeof n||"number"!=typeof s)throw new RangeError("Invalid JSON for fold state");e.push($a.range(n,s))}return nn.set(e,!0)}});function Ia(t,e,i=e){let n=!1;return t.between(e,i,(t,s)=>{t<i&&s>e&&(n=!0)}),n?t.update({filterFrom:e,filterTo:i,filter:(t,n)=>t>=i||n<=e}):t}function ja(t,e,i){var n;let s=null;return null===(n=t.field(Na,!1))||void 0===n||n.between(e,i,(t,e)=>{(!s||s.from>t)&&(s={from:t,to:e})}),s}function Ha(t,e,i){let n=!1;return t.between(e,e,(t,s)=>{t==e&&s==i&&(n=!0)}),n}function Va(t,e){return t.field(Na,!1)?e:e.concat(he.appendConfig.of(_a()))}function Fa(t,e,i=!0){let n=t.state.doc.lineAt(e.from).number,s=t.state.doc.lineAt(e.to).number;return nr.announce.of(`${t.state.phrase(i?"Folded lines":"Unfolded lines")} ${n} ${t.state.phrase("to")} ${s}.`)}const za=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:t=>{for(let e of Ra(t)){let i=La(t.state,e.from,e.to);if(i)return t.dispatch({effects:Va(t.state,[Pa.of(i),Fa(t,i)])}),!0}return!1}},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:t=>{if(!t.state.field(Na,!1))return!1;let e=[];for(let i of Ra(t)){let n=ja(t.state,i.from,i.to);n&&e.push(Ba.of(n),Fa(t,n,!1))}return e.length&&t.dispatch({effects:e}),e.length>0}},{key:"Ctrl-Alt-[",run:t=>{let{state:e}=t,i=[];for(let n=0;n<e.doc.length;){let s=t.lineBlockAt(n),o=La(e,s.from,s.to);o&&i.push(Pa.of(o)),n=(o?t.lineBlockAt(o.to):s).to+1}return i.length&&t.dispatch({effects:Va(t.state,i)}),!!i.length}},{key:"Ctrl-Alt-]",run:t=>{let e=t.state.field(Na,!1);if(!e||!e.size)return!1;let i=[];return e.between(0,t.state.doc.length,(t,e)=>{i.push(Ba.of({from:t,to:e}))}),t.dispatch({effects:i}),!0}}],Wa={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},qa=Bt.define({combine:t=>ke(t,Wa)});function _a(t){return[Na,Xa]}function Ka(t,e){let{state:i}=t,n=i.facet(qa),s=e=>{let i=t.lineBlockAt(t.posAtDOM(e.target)),n=ja(t.state,i.from,i.to);n&&t.dispatch({effects:Ba.of(n)}),e.preventDefault()};if(n.placeholderDOM)return n.placeholderDOM(t,s,e);let o=document.createElement("span");return o.textContent=n.placeholderText,o.setAttribute("aria-label",i.phrase("folded code")),o.title=i.phrase("unfold"),o.className="cm-foldPlaceholder",o.onclick=s,o}const $a=nn.replace({widget:new class extends tn{toDOM(t){return Ka(t,null)}}});class Ua extends tn{constructor(t){super(),this.value=t}eq(t){return this.value==t.value}toDOM(t){return Ka(t,this.value)}}const Ga={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class Ya extends Xr{constructor(t,e){super(),this.config=t,this.open=e}eq(t){return this.config==t.config&&this.open==t.open}toDOM(t){if(this.config.markerDOM)return this.config.markerDOM(this.open);let e=document.createElement("span");return e.textContent=this.open?this.config.openText:this.config.closedText,e.title=t.state.phrase(this.open?"Fold line":"Unfold line"),e}}function Ja(t={}){let e={...Ga,...t},i=new Ya(e,!0),n=new Ya(e,!1),s=Zn.fromClass(class{constructor(t){this.from=t.viewport.from,this.markers=this.buildMarkers(t)}update(t){(t.docChanged||t.viewportChanged||t.startState.facet(la)!=t.state.facet(la)||t.startState.field(Na,!1)!=t.state.field(Na,!1)||Ql(t.startState)!=Ql(t.state)||e.foldingChanged(t))&&(this.markers=this.buildMarkers(t.view))}buildMarkers(t){let e=new Oe;for(let s of t.viewportLineBlocks){let o=ja(t.state,s.from,s.to)?n:La(t.state,s.from,s.to)?i:null;o&&e.add(s.from,s.from,o)}return e.finish()}}),{domEventHandlers:o}=e;return[s,il({class:"cm-foldGutter",markers(t){var e;return(null===(e=t.plugin(s))||void 0===e?void 0:e.markers)||Te.empty},initialSpacer:()=>new Ya(e,!1),domEventHandlers:{...o,click:(t,e,i)=>{if(o.click&&o.click(t,e,i))return!0;let n=ja(t.state,e.from,e.to);if(n)return t.dispatch({effects:Ba.of(n)}),!0;let s=La(t.state,e.from,e.to);return!!s&&(t.dispatch({effects:Pa.of(s)}),!0)}}}),_a()]}const Xa=nr.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}});class Qa{constructor(t,e){let i;function n(t){let e=qe.newName();return(i||(i=Object.create(null)))["."+e]=t,e}this.specs=t;const s="string"==typeof e.all?e.all:e.all?n(e.all):void 0,o=e.scope;this.scope=o instanceof Yl?t=>t.prop($l)==o.data:o?t=>t==o:void 0,this.style=Ml(t.map(t=>({tag:t.tag,class:t.class||n(Object.assign({},t,{tag:null}))})),{all:s}).style,this.module=i?new qe(i):null,this.themeType=e.themeType}static define(t,e){return new Qa(t,e||{})}}const Za=Bt.define(),th=Bt.define({combine:t=>t.length?[t[0]]:null});function eh(t){let e=t.facet(Za);return e.length?e:t.facet(th)}function ih(t,e){let i,n=[sh];return t instanceof Qa&&(t.module&&n.push(nr.styleModule.of(t.module)),i=t.themeType),(null==e?void 0:e.fallback)?n.push(th.of(t)):i?n.push(Za.computeN([nr.darkTheme],e=>e.facet(nr.darkTheme)==("dark"==i)?[t]:[])):n.push(Za.of(t)),n}class nh{constructor(t){this.markCache=Object.create(null),this.tree=Ql(t.state),this.decorations=this.buildDeco(t,eh(t.state)),this.decoratedTo=t.viewport.to}update(t){let e=Ql(t.state),i=eh(t.state),n=i!=eh(t.startState),{viewport:s}=t.view,o=t.changes.mapPos(this.decoratedTo,1);e.length<s.to&&!n&&e.type==this.tree.type&&o>=s.to?(this.decorations=this.decorations.map(t.changes),this.decoratedTo=o):(e!=this.tree||t.viewportChanged||n)&&(this.tree=e,this.decorations=this.buildDeco(t.view,i),this.decoratedTo=s.to)}buildDeco(t,e){if(!e||!this.tree.length)return nn.none;let i=new Oe;for(let{from:n,to:s}of t.visibleRanges)Tl(this.tree,e,(t,e,n)=>{i.add(t,e,this.markCache[n]||(this.markCache[n]=nn.mark({class:n})))},n,s);return i.finish()}}const sh=$t.high(Zn.fromClass(nh,{decorations:t=>t.decorations})),oh=Qa.define([{tag:_l.meta,color:"#404740"},{tag:_l.link,textDecoration:"underline"},{tag:_l.heading,textDecoration:"underline",fontWeight:"bold"},{tag:_l.emphasis,fontStyle:"italic"},{tag:_l.strong,fontWeight:"bold"},{tag:_l.strikethrough,textDecoration:"line-through"},{tag:_l.keyword,color:"#708"},{tag:[_l.atom,_l.bool,_l.url,_l.contentSeparator,_l.labelName],color:"#219"},{tag:[_l.literal,_l.inserted],color:"#164"},{tag:[_l.string,_l.deleted],color:"#a11"},{tag:[_l.regexp,_l.escape,_l.special(_l.string)],color:"#e40"},{tag:_l.definition(_l.variableName),color:"#00f"},{tag:_l.local(_l.variableName),color:"#30a"},{tag:[_l.typeName,_l.namespace],color:"#085"},{tag:_l.className,color:"#167"},{tag:[_l.special(_l.variableName),_l.macroName],color:"#256"},{tag:_l.definition(_l.propertyName),color:"#00c"},{tag:_l.comment,color:"#940"},{tag:_l.invalid,color:"#f00"}]),rh=new o;function lh(t,e,i){let n=t.prop(e<0?o.openedBy:o.closedBy);if(n)return n;if(1==t.name.length){let n=i.indexOf(t.name);if(n>-1&&n%2==(e<0?1:0))return[i[n+e]]}return null}function ah(t){let e=t.type.prop(rh);return e?e(t.node):t}function hh(t,e,i,n={}){let s=n.maxScanDistance||1e4,o=n.brackets||"()[]{}",r=Ql(t),l=r.resolveInner(e,i);for(let n=l;n;n=n.parent){let s=lh(n.type,i,o);if(s&&n.from<n.to){let r=ah(n);if(r&&(i>0?e>=r.from&&e<r.to:e>r.from&&e<=r.to))return ch(t,e,i,n,r,s,o)}}return function(t,e,i,n,s,o,r){let l=i<0?t.sliceDoc(e-1,e):t.sliceDoc(e,e+1),a=r.indexOf(l);if(a<0||a%2==0!=i>0)return null;let h={from:i<0?e-1:e,to:i>0?e+1:e},c=t.doc.iterRange(e,i>0?t.doc.length:0),f=0;for(let t=0;!c.next().done&&t<=o;){let o=c.value;i<0&&(t+=o.length);let l=e+t*i;for(let t=i>0?0:o.length-1,e=i>0?o.length:-1;t!=e;t+=i){let e=r.indexOf(o[t]);if(!(e<0||n.resolveInner(l+t,1).type!=s))if(e%2==0==i>0)f++;else{if(1==f)return{start:h,end:{from:l+t,to:l+t+1},matched:e>>1==a>>1};f--}}i>0&&(t+=o.length)}return c.done?{start:h,matched:!1}:null}(t,e,i,r,l.type,s,o)}function ch(t,e,i,n,s,o,r){let l=n.parent,a={from:s.from,to:s.to},h=0,c=null==l?void 0:l.cursor();if(c&&(i<0?c.childBefore(n.from):c.childAfter(n.to)))do{if(i<0?c.to<=n.from:c.from>=n.to){if(0==h&&o.indexOf(c.type.name)>-1&&c.from<c.to){let t=ah(c);return{start:a,end:t?{from:t.from,to:t.to}:void 0,matched:!0}}if(lh(c.type,i,r))h++;else if(lh(c.type,-i,r)){if(0==h){let t=ah(c);return{start:a,end:t&&t.from<t.to?{from:t.from,to:t.to}:void 0,matched:!1}}h--}}}while(i<0?c.prevSibling():c.nextSibling());return{start:a,matched:!1}}function fh(t,e,i,n=0,s=0){null==e&&-1==(e=t.search(/[^\s\u00a0]/))&&(e=t.length);let o=s;for(let s=n;s<e;s++)9==t.charCodeAt(s)?o+=i-o%i:o++;return o}class dh{constructor(t,e,i,n){this.string=t,this.tabSize=e,this.indentUnit=i,this.overrideIndent=n,this.pos=0,this.start=0,this.lastColumnPos=0,this.lastColumnValue=0}eol(){return this.pos>=this.string.length}sol(){return 0==this.pos}peek(){return this.string.charAt(this.pos)||void 0}next(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)}eat(t){let e,i=this.string.charAt(this.pos);if(e="string"==typeof t?i==t:i&&(t instanceof RegExp?t.test(i):t(i)),e)return++this.pos,i}eatWhile(t){let e=this.pos;for(;this.eat(t););return this.pos>e}eatSpace(){let t=this.pos;for(;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>t}skipToEnd(){this.pos=this.string.length}skipTo(t){let e=this.string.indexOf(t,this.pos);if(e>-1)return this.pos=e,!0}backUp(t){this.pos-=t}column(){return this.lastColumnPos<this.start&&(this.lastColumnValue=fh(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue}indentation(){var t;return null!==(t=this.overrideIndent)&&void 0!==t?t:fh(this.string,null,this.tabSize)}match(t,e,i){if("string"==typeof t){let n=t=>i?t.toLowerCase():t;return n(this.string.substr(this.pos,t.length))==n(t)?(!1!==e&&(this.pos+=t.length),!0):null}{let i=this.string.slice(this.pos).match(t);return i&&i.index>0?null:(i&&!1!==e&&(this.pos+=i[0].length),i)}}current(){return this.string.slice(this.start,this.pos)}}function uh(t){if("object"!=typeof t)return t;let e={};for(let i in t){let n=t[i];e[i]=n instanceof Array?n.slice():n}return e}const ph=new WeakMap;class mh extends Yl{constructor(t){let e,i=Ul(t.languageData),n={name:(s=t).name||"",token:s.token,blankLine:s.blankLine||(()=>{}),startState:s.startState||(()=>!0),copyState:s.copyState||uh,indent:s.indent||(()=>null),languageData:s.languageData||{},tokenTable:s.tokenTable||yh,mergeTokens:!1!==s.mergeTokens};var s;super(i,new class extends B{createParse(t,i,n){return new vh(e,t,i,n)}},[],t.name),this.topNode=function(t,e){let i=a.define({id:xh.length,name:"Document",props:[$l.add(()=>t),ga.add(()=>t=>e.getIndent(t))],top:!0});return xh.push(i),i}(i,this),e=this,this.streamParser=n,this.stateAfter=new o({perNode:!0}),this.tokenTable=t.tokenTable?new Mh(n.tokenTable):Th}static define(t){return new mh(t)}getIndent(t){let e,{overrideIndentation:i}=t.options;i&&(e=ph.get(t.state),null!=e&&e<t.pos-1e4&&(e=void 0));let n,s,o=gh(this,t.node.tree,t.node.from,t.node.from,null!=e?e:t.pos);if(o?(s=o.state,n=o.pos+1):(s=this.streamParser.startState(t.unit),n=t.node.from),t.pos-n>1e4)return null;for(;n<t.pos;){let e=t.state.doc.lineAt(n),o=Math.min(t.pos,e.to);if(e.length){let n=i?i(e.from):-1,r=new dh(e.text,t.state.tabSize,t.unit,n<0?void 0:n);for(;r.pos<o-e.from;)bh(this.streamParser.token,r,s)}else this.streamParser.blankLine(s,t.unit);if(o==t.pos)break;n=e.to+1}let r=t.lineAt(t.pos);return i&&null==e&&ph.set(t.state,r.from),this.streamParser.indent(s,/^\s*(.*)/.exec(r.text)[1],t)}get allowsNesting(){return!1}}function gh(t,e,i,n,s){let o=i>=n&&i+e.length<=s&&e.prop(t.stateAfter);if(o)return{state:t.streamParser.copyState(o),pos:i+e.length};for(let o=e.children.length-1;o>=0;o--){let r=e.children[o],l=i+e.positions[o],a=r instanceof u&&l<s&&gh(t,r,l,n,s);if(a)return a}return null}function wh(t,e,i,n,s){if(s&&i<=0&&n>=e.length)return e;s||0!=i||e.type!=t.topNode||(s=!0);for(let o=e.children.length-1;o>=0;o--){let r,l=e.positions[o],a=e.children[o];if(l<n&&a instanceof u){if(!(r=wh(t,a,i-l,n-l,s)))break;return s?new u(e.type,e.children.slice(0,o).concat(r),e.positions.slice(0,o+1),l+r.length):r}}return null}class vh{constructor(t,e,i,n){this.lang=t,this.input=e,this.fragments=i,this.ranges=n,this.stoppedAt=null,this.chunks=[],this.chunkPos=[],this.chunk=[],this.chunkReused=void 0,this.rangeIndex=0,this.to=n[n.length-1].to;let s=ea.get(),o=n[0].from,{state:r,tree:l}=function(t,e,i,n,s){for(let s of e){let e,o=s.from+(s.openStart?25:0),r=s.to-(s.openEnd?25:0),l=o<=i&&r>i&&gh(t,s.tree,0-s.offset,i,r);if(l&&l.pos<=n&&(e=wh(t,s.tree,i+s.offset,l.pos+s.offset,!1)))return{state:l.state,tree:e}}return{state:t.streamParser.startState(s?da(s):4),tree:u.empty}}(t,i,o,this.to,null==s?void 0:s.state);this.state=r,this.parsedPos=this.chunkStart=o+l.length;for(let t=0;t<l.children.length;t++)this.chunks.push(l.children[t]),this.chunkPos.push(l.positions[t]);s&&this.parsedPos<s.viewport.from-1e5&&n.some(t=>t.from<=s.viewport.from&&t.to>=s.viewport.from)&&(this.state=this.lang.streamParser.startState(da(s.state)),s.skipUntilInView(this.parsedPos,s.viewport.from),this.parsedPos=s.viewport.from),this.moveRangeIndex()}advance(){let t=ea.get(),e=null==this.stoppedAt?this.to:Math.min(this.to,this.stoppedAt),i=Math.min(e,this.chunkStart+512);for(t&&(i=Math.min(i,t.viewport.to));this.parsedPos<i;)this.parseLine(t);return this.chunkStart<this.parsedPos&&this.finishChunk(),this.parsedPos>=e?this.finish():t&&this.parsedPos>=t.viewport.to?(t.skipUntilInView(this.parsedPos,e),this.finish()):null}stopAt(t){this.stoppedAt=t}lineAfter(t){let e=this.input.chunk(t);if(this.input.lineChunks)"\n"==e&&(e="");else{let t=e.indexOf("\n");t>-1&&(e=e.slice(0,t))}return t+e.length<=this.to?e:e.slice(0,this.to-t)}nextLine(){let t=this.parsedPos,e=this.lineAfter(t),i=t+e.length;for(let t=this.rangeIndex;;){let n=this.ranges[t].to;if(n>=i)break;if(e=e.slice(0,n-(i-e.length)),t++,t==this.ranges.length)break;let s=this.ranges[t].from,o=this.lineAfter(s);e+=o,i=s+o.length}return{line:e,end:i}}skipGapsTo(t,e,i){for(;;){let n=this.ranges[this.rangeIndex].to,s=t+e;if(i>0?n>s:n>=s)break;e+=this.ranges[++this.rangeIndex].from-n}return e}moveRangeIndex(){for(;this.ranges[this.rangeIndex].to<this.parsedPos;)this.rangeIndex++}emitToken(t,e,i,n){let s=4;if(this.ranges.length>1){e+=n=this.skipGapsTo(e,n,1);let t=this.chunk.length;i+=n=this.skipGapsTo(i,n,-1),s+=this.chunk.length-t}let o=this.chunk.length-4;return this.lang.streamParser.mergeTokens&&4==s&&o>=0&&this.chunk[o]==t&&this.chunk[o+2]==e?this.chunk[o+2]=i:this.chunk.push(t,e,i,s),n}parseLine(t){let{line:e,end:i}=this.nextLine(),n=0,{streamParser:s}=this.lang,o=new dh(e,t?t.state.tabSize:4,t?da(t.state):2);if(o.eol())s.blankLine(this.state,o.indentUnit);else for(;!o.eol();){let t=bh(s.token,o,this.state);if(t&&(n=this.emitToken(this.lang.tokenTable.resolve(t),this.parsedPos+o.start,this.parsedPos+o.pos,n)),o.start>1e4)break}this.parsedPos=i,this.moveRangeIndex(),this.parsedPos<this.to&&this.parsedPos++}finishChunk(){let t=u.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:kh,topID:0,maxBufferLength:512,reused:this.chunkReused});t=new u(t.type,t.children,t.positions,t.length,[[this.lang.stateAfter,this.lang.streamParser.copyState(this.state)]]),this.chunks.push(t),this.chunkPos.push(this.chunkStart-this.ranges[0].from),this.chunk=[],this.chunkReused=void 0,this.chunkStart=this.parsedPos}finish(){return new u(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}}function bh(t,e,i){e.start=e.pos;for(let n=0;n<10;n++){let n=t(e,i);if(e.pos>e.start)return n}throw new Error("Stream parser failed to advance stream.")}const yh=Object.create(null),xh=[a.none],kh=new h(xh),Sh=[],Ch=Object.create(null),Ah=Object.create(null);for(let[t,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])Ah[t]=Dh(yh,e);class Mh{constructor(t){this.extra=t,this.table=Object.assign(Object.create(null),Ah)}resolve(t){return t?this.table[t]||(this.table[t]=Dh(this.extra,t)):0}}const Th=new Mh(yh);function Oh(t,e){Sh.indexOf(t)>-1||(Sh.push(t),console.warn(e))}function Dh(t,e){let i=[];for(let n of e.split(" ")){let e=[];for(let i of n.split(".")){let n=t[i]||_l[i];n?"function"==typeof n?e.length?e=e.map(n):Oh(i,`Modifier ${i} used at start of tag`):e.length?Oh(i,`Tag ${i} used as modifier`):e=Array.isArray(n)?n:[n]:Oh(i,`Unknown highlighting tag ${i}`)}for(let t of e)i.push(t)}if(!i.length)return 0;let n=e.replace(/ /g,"_"),s=n+" "+i.map(t=>t.id),o=Ch[s];if(o)return o.id;let r=Ch[s]=a.define({id:xh.length,name:n,props:[Sl({[n]:i})]});return xh.push(r),r.id}
|
|
92
92
|
/*
|
|
93
93
|
* Copyright IBM Corp. 2025
|
|
94
94
|
*
|
|
@@ -97,7 +97,7 @@ import{t}from"./throttle-Yp_y_3mg.js";import{_ as e}from"./radio-group-manager-N
|
|
|
97
97
|
*
|
|
98
98
|
* @license
|
|
99
99
|
*/
|
|
100
|
-
function Lh(t){return new aa(mh.define(t))}function Eh(t){return import("./index-PudNB5nC.js").then(e=>e.sql({dialect:e[t]}))}mn.RTL,mn.LTR;const Ph=[ha.of({name:"C",extensions:["c","h","ino"],load:()=>import("./index-DAE055Cu.js").then(t=>t.cpp())}),ha.of({name:"C++",alias:["cpp"],extensions:["cpp","c++","cc","cxx","hpp","h++","hh","hxx"],load:()=>import("./index-DAE055Cu.js").then(t=>t.cpp())}),ha.of({name:"CQL",alias:["cassandra"],extensions:["cql"],load:()=>Eh("Cassandra")}),ha.of({name:"CSS",extensions:["css"],load:()=>import("./index-CLun6lGz.js").then(t=>t.css())}),ha.of({name:"Go",extensions:["go"],load:()=>import("./index-BkOGOowl.js").then(t=>t.go())}),ha.of({name:"HTML",alias:["xhtml"],extensions:["html","htm","handlebars","hbs"],load:()=>import("./index-DBeVfXDs.js").then(t=>t.html())}),ha.of({name:"Java",extensions:["java"],load:()=>import("./index-Cv8hjf43.js").then(t=>t.java())}),ha.of({name:"JavaScript",alias:["ecmascript","js","node"],extensions:["js","mjs","cjs"],load:()=>import("./index-BfrNY07c.js").then(t=>t.javascript())}),ha.of({name:"Jinja",extensions:["j2","jinja","jinja2"],load:()=>import("./index-DMHecuNR.js").then(t=>t.jinja())}),ha.of({name:"JSON",alias:["json5"],extensions:["json","map"],load:()=>import("./index-DOyxM-mj.js").then(t=>t.json())}),ha.of({name:"JSX",extensions:["jsx"],load:()=>import("./index-BfrNY07c.js").then(t=>t.javascript({jsx:!0}))}),ha.of({name:"LESS",extensions:["less"],load:()=>import("./index-CoHvpVb0.js").then(t=>t.less())}),ha.of({name:"Liquid",extensions:["liquid"],load:()=>import("./index-CwJXiNAs.js").then(t=>t.liquid())}),ha.of({name:"MariaDB SQL",load:()=>Eh("MariaSQL")}),ha.of({name:"Markdown",extensions:["md","markdown","mkd"],load:()=>import("./index-BvNnbnhR.js").then(t=>t.markdown())}),ha.of({name:"MS SQL",load:()=>Eh("MSSQL")}),ha.of({name:"MySQL",load:()=>Eh("MySQL")}),ha.of({name:"PHP",extensions:["php","php3","php4","php5","php7","phtml"],load:()=>import("./index-yVLVhp6V.js").then(t=>t.php())}),ha.of({name:"PLSQL",extensions:["pls"],load:()=>Eh("PLSQL")}),ha.of({name:"PostgreSQL",load:()=>Eh("PostgreSQL")}),ha.of({name:"Python",extensions:["BUILD","bzl","py","pyw"],filename:/^(BUCK|BUILD)$/,load:()=>import("./index-8KclZ0nm.js").then(t=>t.python())}),ha.of({name:"Rust",extensions:["rs"],load:()=>import("./index-6Jr9D3_B.js").then(t=>t.rust())}),ha.of({name:"Sass",extensions:["sass"],load:()=>import("./index-DAFvuacj.js").then(t=>t.sass({indented:!0}))}),ha.of({name:"SCSS",extensions:["scss"],load:()=>import("./index-DAFvuacj.js").then(t=>t.sass())}),ha.of({name:"SQL",extensions:["sql"],load:()=>Eh("StandardSQL")}),ha.of({name:"SQLite",load:()=>Eh("SQLite")}),ha.of({name:"TSX",extensions:["tsx"],load:()=>import("./index-BfrNY07c.js").then(t=>t.javascript({jsx:!0,typescript:!0}))}),ha.of({name:"TypeScript",alias:["ts"],extensions:["ts","mts","cts"],load:()=>import("./index-BfrNY07c.js").then(t=>t.javascript({typescript:!0}))}),ha.of({name:"WebAssembly",extensions:["wat","wast"],load:()=>import("./index-CRQ_c60v.js").then(t=>t.wast())}),ha.of({name:"XML",alias:["rss","wsdl","xsd"],extensions:["xml","xsl","xsd","svg"],load:()=>import("./index-BUcHzgqY.js").then(t=>t.xml())}),ha.of({name:"YAML",alias:["yml"],extensions:["yaml","yml"],load:()=>import("./index-BIipjmyi.js").then(t=>t.yaml())}),ha.of({name:"APL",extensions:["dyalog","apl"],load:()=>import("./apl-efZAUIfn.js").then(t=>Lh(t.apl))}),ha.of({name:"PGP",alias:["asciiarmor"],extensions:["asc","pgp","sig"],load:()=>import("./asciiarmor-DSPxllJn.js").then(t=>Lh(t.asciiArmor))}),ha.of({name:"ASN.1",extensions:["asn","asn1"],load:()=>import("./asn1-DrA2u-JN.js").then(t=>Lh(t.asn1({})))}),ha.of({name:"Asterisk",filename:/^extensions\.conf$/i,load:()=>import("./asterisk-Bd48VInq.js").then(t=>Lh(t.asterisk))}),ha.of({name:"Cobol",extensions:["cob","cpy"],load:()=>import("./cobol-CFDSE9dZ.js").then(t=>Lh(t.cobol))}),ha.of({name:"C#",alias:["csharp","cs"],extensions:["cs"],load:()=>import("./clike-BcRI5X0E.js").then(t=>Lh(t.csharp))}),ha.of({name:"Clojure",extensions:["clj","cljc","cljx"],load:()=>import("./clojure-C2IHkUPA.js").then(t=>Lh(t.clojure))}),ha.of({name:"ClojureScript",extensions:["cljs"],load:()=>import("./clojure-C2IHkUPA.js").then(t=>Lh(t.clojure))}),ha.of({name:"Closure Stylesheets (GSS)",extensions:["gss"],load:()=>import("./css-BypXLy0l.js").then(t=>Lh(t.gss))}),ha.of({name:"CMake",extensions:["cmake","cmake.in"],filename:/^CMakeLists\.txt$/,load:()=>import("./cmake-CJhCxpap.js").then(t=>Lh(t.cmake))}),ha.of({name:"CoffeeScript",alias:["coffee","coffee-script"],extensions:["coffee"],load:()=>import("./coffeescript-CURj13L6.js").then(t=>Lh(t.coffeeScript))}),ha.of({name:"Common Lisp",alias:["lisp"],extensions:["cl","lisp","el"],load:()=>import("./commonlisp-DLkoJfhj.js").then(t=>Lh(t.commonLisp))}),ha.of({name:"Cypher",extensions:["cyp","cypher"],load:()=>import("./cypher-BlL-7Ae0.js").then(t=>Lh(t.cypher))}),ha.of({name:"Cython",extensions:["pyx","pxd","pxi"],load:()=>import("./python-CmvkgikI.js").then(t=>Lh(t.cython))}),ha.of({name:"Crystal",extensions:["cr"],load:()=>import("./crystal-DedS5Vzh.js").then(t=>Lh(t.crystal))}),ha.of({name:"D",extensions:["d"],load:()=>import("./d-ComvWfj7.js").then(t=>Lh(t.d))}),ha.of({name:"Dart",extensions:["dart"],load:()=>import("./clike-BcRI5X0E.js").then(t=>Lh(t.dart))}),ha.of({name:"diff",extensions:["diff","patch"],load:()=>import("./diff-BoSIXa2o.js").then(t=>Lh(t.diff))}),ha.of({name:"Dockerfile",filename:/^Dockerfile$/,load:()=>import("./dockerfile-BvZrCdwA.js").then(t=>Lh(t.dockerFile))}),ha.of({name:"DTD",extensions:["dtd"],load:()=>import("./dtd-C_ndqcjb.js").then(t=>Lh(t.dtd))}),ha.of({name:"Dylan",extensions:["dylan","dyl","intr"],load:()=>import("./dylan-D7jWxiNW.js").then(t=>Lh(t.dylan))}),ha.of({name:"EBNF",load:()=>import("./ebnf-Cdzhx-3O.js").then(t=>Lh(t.ebnf))}),ha.of({name:"ECL",extensions:["ecl"],load:()=>import("./ecl-CjIaslgI.js").then(t=>Lh(t.ecl))}),ha.of({name:"edn",extensions:["edn"],load:()=>import("./clojure-C2IHkUPA.js").then(t=>Lh(t.clojure))}),ha.of({name:"Eiffel",extensions:["e"],load:()=>import("./eiffel-hCXL6Hzk.js").then(t=>Lh(t.eiffel))}),ha.of({name:"Elm",extensions:["elm"],load:()=>import("./elm-B2FABL8h.js").then(t=>Lh(t.elm))}),ha.of({name:"Erlang",extensions:["erl"],load:()=>import("./erlang-ClnyfmZz.js").then(t=>Lh(t.erlang))}),ha.of({name:"Esper",load:()=>import("./sql-v0_lDusO.js").then(t=>Lh(t.esper))}),ha.of({name:"Factor",extensions:["factor"],load:()=>import("./factor-C-o9WMfc.js").then(t=>Lh(t.factor))}),ha.of({name:"FCL",load:()=>import("./fcl-CBMB3lji.js").then(t=>Lh(t.fcl))}),ha.of({name:"Forth",extensions:["forth","fth","4th"],load:()=>import("./forth-DgWLtPeN.js").then(t=>Lh(t.forth))}),ha.of({name:"Fortran",extensions:["f","for","f77","f90","f95"],load:()=>import("./fortran-Cg40eZO_.js").then(t=>Lh(t.fortran))}),ha.of({name:"F#",alias:["fsharp"],extensions:["fs"],load:()=>import("./mllike-BLsWzAfZ.js").then(t=>Lh(t.fSharp))}),ha.of({name:"Gas",extensions:["s"],load:()=>import("./gas-CEhqqWlu.js").then(t=>Lh(t.gas))}),ha.of({name:"Gherkin",extensions:["feature"],load:()=>import("./gherkin-D5qmKtXD.js").then(t=>Lh(t.gherkin))}),ha.of({name:"Groovy",extensions:["groovy","gradle"],filename:/^Jenkinsfile$/,load:()=>import("./groovy-BRxJpyHw.js").then(t=>Lh(t.groovy))}),ha.of({name:"Haskell",extensions:["hs"],load:()=>import("./haskell-5r5d3GWp.js").then(t=>Lh(t.haskell))}),ha.of({name:"Haxe",extensions:["hx"],load:()=>import("./haxe-BXDNjS-F.js").then(t=>Lh(t.haxe))}),ha.of({name:"HXML",extensions:["hxml"],load:()=>import("./haxe-BXDNjS-F.js").then(t=>Lh(t.hxml))}),ha.of({name:"HTTP",load:()=>import("./http-RMcNtqTE.js").then(t=>Lh(t.http))}),ha.of({name:"IDL",extensions:["pro"],load:()=>import("./idl-Khw9YfYf.js").then(t=>Lh(t.idl))}),ha.of({name:"JSON-LD",alias:["jsonld"],extensions:["jsonld"],load:()=>import("./javascript-DNcQn7za.js").then(t=>Lh(t.jsonld))}),ha.of({name:"Julia",extensions:["jl"],load:()=>import("./julia-CoEZVOJ2.js").then(t=>Lh(t.julia))}),ha.of({name:"Kotlin",extensions:["kt","kts"],load:()=>import("./clike-BcRI5X0E.js").then(t=>Lh(t.kotlin))}),ha.of({name:"LiveScript",alias:["ls"],extensions:["ls"],load:()=>import("./livescript-CMAVg7yW.js").then(t=>Lh(t.liveScript))}),ha.of({name:"Lua",extensions:["lua"],load:()=>import("./lua-BQ_ols-d.js").then(t=>Lh(t.lua))}),ha.of({name:"mIRC",extensions:["mrc"],load:()=>import("./mirc-DHtAJyAO.js").then(t=>Lh(t.mirc))}),ha.of({name:"Mathematica",extensions:["m","nb","wl","wls"],load:()=>import("./mathematica-BZCuRavb.js").then(t=>Lh(t.mathematica))}),ha.of({name:"Modelica",extensions:["mo"],load:()=>import("./modelica-B276R2MG.js").then(t=>Lh(t.modelica))}),ha.of({name:"MUMPS",extensions:["mps"],load:()=>import("./mumps-DDBLeXPz.js").then(t=>Lh(t.mumps))}),ha.of({name:"Mbox",extensions:["mbox"],load:()=>import("./mbox-BB3SftKu.js").then(t=>Lh(t.mbox))}),ha.of({name:"Nginx",filename:/nginx.*\.conf$/i,load:()=>import("./nginx-mb-Aga98.js").then(t=>Lh(t.nginx))}),ha.of({name:"NSIS",extensions:["nsh","nsi"],load:()=>import("./nsis-dTUTRg0D.js").then(t=>Lh(t.nsis))}),ha.of({name:"NTriples",extensions:["nt","nq"],load:()=>import("./ntriples-fhwVir-C.js").then(t=>Lh(t.ntriples))}),ha.of({name:"Objective-C",alias:["objective-c","objc"],extensions:["m"],load:()=>import("./clike-BcRI5X0E.js").then(t=>Lh(t.objectiveC))}),ha.of({name:"Objective-C++",alias:["objective-c++","objc++"],extensions:["mm"],load:()=>import("./clike-BcRI5X0E.js").then(t=>Lh(t.objectiveCpp))}),ha.of({name:"OCaml",extensions:["ml","mli","mll","mly"],load:()=>import("./mllike-BLsWzAfZ.js").then(t=>Lh(t.oCaml))}),ha.of({name:"Octave",extensions:["m"],load:()=>import("./octave-CaylO_Vc.js").then(t=>Lh(t.octave))}),ha.of({name:"Oz",extensions:["oz"],load:()=>import("./oz-Dh05qSSW.js").then(t=>Lh(t.oz))}),ha.of({name:"Pascal",extensions:["p","pas"],load:()=>import("./pascal-63zXOTpO.js").then(t=>Lh(t.pascal))}),ha.of({name:"Perl",extensions:["pl","pm"],load:()=>import("./perl-YLBat7Y_.js").then(t=>Lh(t.perl))}),ha.of({name:"Pig",extensions:["pig"],load:()=>import("./pig-CpUGLxE0.js").then(t=>Lh(t.pig))}),ha.of({name:"PowerShell",extensions:["ps1","psd1","psm1"],load:()=>import("./powershell-D-0C_k0n.js").then(t=>Lh(t.powerShell))}),ha.of({name:"Properties files",alias:["ini","properties"],extensions:["properties","ini","in"],load:()=>import("./properties-DD0PUgdh.js").then(t=>Lh(t.properties))}),ha.of({name:"ProtoBuf",extensions:["proto"],load:()=>import("./protobuf-CZ1s_eBQ.js").then(t=>Lh(t.protobuf))}),ha.of({name:"Pug",alias:["jade"],extensions:["pug","jade"],load:()=>import("./pug-dysr1PFn.js").then(t=>Lh(t.pug))}),ha.of({name:"Puppet",extensions:["pp"],load:()=>import("./puppet-CwcTPQbC.js").then(t=>Lh(t.puppet))}),ha.of({name:"Q",extensions:["q"],load:()=>import("./q-BWyI6IDo.js").then(t=>Lh(t.q))}),ha.of({name:"R",alias:["rscript"],extensions:["r","R"],load:()=>import("./r-kSNVbRo5.js").then(t=>Lh(t.r))}),ha.of({name:"RPM Changes",load:()=>import("./rpm-qSrPkZZG.js").then(t=>Lh(t.rpmChanges))}),ha.of({name:"RPM Spec",extensions:["spec"],load:()=>import("./rpm-qSrPkZZG.js").then(t=>Lh(t.rpmSpec))}),ha.of({name:"Ruby",alias:["jruby","macruby","rake","rb","rbx"],extensions:["rb"],filename:/^(Gemfile|Rakefile)$/,load:()=>import("./ruby-P6s3XPo8.js").then(t=>Lh(t.ruby))}),ha.of({name:"SAS",extensions:["sas"],load:()=>import("./sas-BQWlj8o3.js").then(t=>Lh(t.sas))}),ha.of({name:"Scala",extensions:["scala"],load:()=>import("./clike-BcRI5X0E.js").then(t=>Lh(t.scala))}),ha.of({name:"Scheme",extensions:["scm","ss"],load:()=>import("./scheme-DQ-rMZD6.js").then(t=>Lh(t.scheme))}),ha.of({name:"Shell",alias:["bash","sh","zsh"],extensions:["sh","ksh","bash"],filename:/^PKGBUILD$/,load:()=>import("./shell-BtjXl0_5.js").then(t=>Lh(t.shell))}),ha.of({name:"Sieve",extensions:["siv","sieve"],load:()=>import("./sieve-DZ5JhAHC.js").then(t=>Lh(t.sieve))}),ha.of({name:"Smalltalk",extensions:["st"],load:()=>import("./smalltalk-CwL8Wq0t.js").then(t=>Lh(t.smalltalk))}),ha.of({name:"Solr",load:()=>import("./solr-uusPPpvv.js").then(t=>Lh(t.solr))}),ha.of({name:"SML",extensions:["sml","sig","fun","smackspec"],load:()=>import("./mllike-BLsWzAfZ.js").then(t=>Lh(t.sml))}),ha.of({name:"SPARQL",alias:["sparul"],extensions:["rq","sparql"],load:()=>import("./sparql-DSknSqv4.js").then(t=>Lh(t.sparql))}),ha.of({name:"Spreadsheet",alias:["excel","formula"],load:()=>import("./spreadsheet-CdCA4zLR.js").then(t=>Lh(t.spreadsheet))}),ha.of({name:"Squirrel",extensions:["nut"],load:()=>import("./clike-BcRI5X0E.js").then(t=>Lh(t.squirrel))}),ha.of({name:"Stylus",extensions:["styl"],load:()=>import("./stylus-Dl16Npcf.js").then(t=>Lh(t.stylus))}),ha.of({name:"Swift",extensions:["swift"],load:()=>import("./swift-DSgSX742.js").then(t=>Lh(t.swift))}),ha.of({name:"sTeX",load:()=>import("./stex-EBy3ayec.js").then(t=>Lh(t.stex))}),ha.of({name:"LaTeX",alias:["tex"],extensions:["text","ltx","tex"],load:()=>import("./stex-EBy3ayec.js").then(t=>Lh(t.stex))}),ha.of({name:"SystemVerilog",extensions:["v","sv","svh"],load:()=>import("./verilog-FKqktXcv.js").then(t=>Lh(t.verilog))}),ha.of({name:"Tcl",extensions:["tcl"],load:()=>import("./tcl-Cikwf4s-.js").then(t=>Lh(t.tcl))}),ha.of({name:"Textile",extensions:["textile"],load:()=>import("./textile-BYnRCuKw.js").then(t=>Lh(t.textile))}),ha.of({name:"TiddlyWiki",load:()=>import("./tiddlywiki-DfaFDhWw.js").then(t=>Lh(t.tiddlyWiki))}),ha.of({name:"Tiki wiki",load:()=>import("./tiki-B4Xv4zUI.js").then(t=>Lh(t.tiki))}),ha.of({name:"TOML",extensions:["toml"],load:()=>import("./toml-BmBzmufK.js").then(t=>Lh(t.toml))}),ha.of({name:"Troff",extensions:["1","2","3","4","5","6","7","8","9"],load:()=>import("./troff-hEGKg6bv.js").then(t=>Lh(t.troff))}),ha.of({name:"TTCN",extensions:["ttcn","ttcn3","ttcnpp"],load:()=>import("./ttcn-J3U6ow4d.js").then(t=>Lh(t.ttcn))}),ha.of({name:"TTCN_CFG",extensions:["cfg"],load:()=>import("./ttcn-cfg-s_dlQaOf.js").then(t=>Lh(t.ttcnCfg))}),ha.of({name:"Turtle",extensions:["ttl"],load:()=>import("./turtle-DetvELcp.js").then(t=>Lh(t.turtle))}),ha.of({name:"Web IDL",extensions:["webidl"],load:()=>import("./webidl-9OF0eUyD.js").then(t=>Lh(t.webIDL))}),ha.of({name:"VB.NET",extensions:["vb"],load:()=>import("./vb-CgyK0Pzn.js").then(t=>Lh(t.vb))}),ha.of({name:"VBScript",extensions:["vbs"],load:()=>import("./vbscript-VBj1G19a.js").then(t=>Lh(t.vbScript))}),ha.of({name:"Velocity",extensions:["vtl"],load:()=>import("./velocity-BGZcyv0R.js").then(t=>Lh(t.velocity))}),ha.of({name:"Verilog",extensions:["v"],load:()=>import("./verilog-FKqktXcv.js").then(t=>Lh(t.verilog))}),ha.of({name:"VHDL",extensions:["vhd","vhdl"],load:()=>import("./vhdl-Co-SIqiJ.js").then(t=>Lh(t.vhdl))}),ha.of({name:"XQuery",extensions:["xy","xquery","xq","xqm","xqy"],load:()=>import("./xquery-DtgT47pa.js").then(t=>Lh(t.xQuery))}),ha.of({name:"Yacas",extensions:["ys"],load:()=>import("./yacas-CejZbYou.js").then(t=>Lh(t.yacas))}),ha.of({name:"Z80",extensions:["z80"],load:()=>import("./z80-CQ0L9hHY.js").then(t=>Lh(t.z80))}),ha.of({name:"MscGen",extensions:["mscgen","mscin","msc"],load:()=>import("./mscgen-BDqesV2g.js").then(t=>Lh(t.mscgen))}),ha.of({name:"Xù",extensions:["xu"],load:()=>import("./mscgen-BDqesV2g.js").then(t=>Lh(t.xu))}),ha.of({name:"MsGenny",extensions:["msgenny"],load:()=>import("./mscgen-BDqesV2g.js").then(t=>Lh(t.msgenny))}),ha.of({name:"Vue",extensions:["vue"],load:()=>import("./index-GIcY4W_W.js").then(t=>t.vue())}),ha.of({name:"Angular Template",load:()=>import("./index-DXBfzR2s.js").then(t=>t.angular())})];
|
|
100
|
+
function Lh(t){return new aa(mh.define(t))}function Eh(t){return import("./index-C8bEg5Uj.js").then(e=>e.sql({dialect:e[t]}))}mn.RTL,mn.LTR;const Ph=[ha.of({name:"C",extensions:["c","h","ino"],load:()=>import("./index-Bu9gWUiF.js").then(t=>t.cpp())}),ha.of({name:"C++",alias:["cpp"],extensions:["cpp","c++","cc","cxx","hpp","h++","hh","hxx"],load:()=>import("./index-Bu9gWUiF.js").then(t=>t.cpp())}),ha.of({name:"CQL",alias:["cassandra"],extensions:["cql"],load:()=>Eh("Cassandra")}),ha.of({name:"CSS",extensions:["css"],load:()=>import("./index-4jRdBit9.js").then(t=>t.css())}),ha.of({name:"Go",extensions:["go"],load:()=>import("./index-CSEyeHT9.js").then(t=>t.go())}),ha.of({name:"HTML",alias:["xhtml"],extensions:["html","htm","handlebars","hbs"],load:()=>import("./index-tnMbrHKo.js").then(t=>t.html())}),ha.of({name:"Java",extensions:["java"],load:()=>import("./index-Cy4O64oM.js").then(t=>t.java())}),ha.of({name:"JavaScript",alias:["ecmascript","js","node"],extensions:["js","mjs","cjs"],load:()=>import("./index-CmkRN7JA.js").then(t=>t.javascript())}),ha.of({name:"Jinja",extensions:["j2","jinja","jinja2"],load:()=>import("./index-muXVkugt.js").then(t=>t.jinja())}),ha.of({name:"JSON",alias:["json5"],extensions:["json","map"],load:()=>import("./index-EHu0fYXl.js").then(t=>t.json())}),ha.of({name:"JSX",extensions:["jsx"],load:()=>import("./index-CmkRN7JA.js").then(t=>t.javascript({jsx:!0}))}),ha.of({name:"LESS",extensions:["less"],load:()=>import("./index-Ci2IAejb.js").then(t=>t.less())}),ha.of({name:"Liquid",extensions:["liquid"],load:()=>import("./index-BOh_nBln.js").then(t=>t.liquid())}),ha.of({name:"MariaDB SQL",load:()=>Eh("MariaSQL")}),ha.of({name:"Markdown",extensions:["md","markdown","mkd"],load:()=>import("./index-DiiLbFxH.js").then(t=>t.markdown())}),ha.of({name:"MS SQL",load:()=>Eh("MSSQL")}),ha.of({name:"MySQL",load:()=>Eh("MySQL")}),ha.of({name:"PHP",extensions:["php","php3","php4","php5","php7","phtml"],load:()=>import("./index-COYOBWaJ.js").then(t=>t.php())}),ha.of({name:"PLSQL",extensions:["pls"],load:()=>Eh("PLSQL")}),ha.of({name:"PostgreSQL",load:()=>Eh("PostgreSQL")}),ha.of({name:"Python",extensions:["BUILD","bzl","py","pyw"],filename:/^(BUCK|BUILD)$/,load:()=>import("./index-DBxz4i7M.js").then(t=>t.python())}),ha.of({name:"Rust",extensions:["rs"],load:()=>import("./index-D2t8pNSN.js").then(t=>t.rust())}),ha.of({name:"Sass",extensions:["sass"],load:()=>import("./index-DebFxHTs.js").then(t=>t.sass({indented:!0}))}),ha.of({name:"SCSS",extensions:["scss"],load:()=>import("./index-DebFxHTs.js").then(t=>t.sass())}),ha.of({name:"SQL",extensions:["sql"],load:()=>Eh("StandardSQL")}),ha.of({name:"SQLite",load:()=>Eh("SQLite")}),ha.of({name:"TSX",extensions:["tsx"],load:()=>import("./index-CmkRN7JA.js").then(t=>t.javascript({jsx:!0,typescript:!0}))}),ha.of({name:"TypeScript",alias:["ts"],extensions:["ts","mts","cts"],load:()=>import("./index-CmkRN7JA.js").then(t=>t.javascript({typescript:!0}))}),ha.of({name:"WebAssembly",extensions:["wat","wast"],load:()=>import("./index-BM41YEqq.js").then(t=>t.wast())}),ha.of({name:"XML",alias:["rss","wsdl","xsd"],extensions:["xml","xsl","xsd","svg"],load:()=>import("./index-DXc2fPMn.js").then(t=>t.xml())}),ha.of({name:"YAML",alias:["yml"],extensions:["yaml","yml"],load:()=>import("./index-DcP0S8R8.js").then(t=>t.yaml())}),ha.of({name:"APL",extensions:["dyalog","apl"],load:()=>import("./apl-DqPKPgQT.js").then(t=>Lh(t.apl))}),ha.of({name:"PGP",alias:["asciiarmor"],extensions:["asc","pgp","sig"],load:()=>import("./asciiarmor-D-S0VxwT.js").then(t=>Lh(t.asciiArmor))}),ha.of({name:"ASN.1",extensions:["asn","asn1"],load:()=>import("./asn1-CFFEZSZ_.js").then(t=>Lh(t.asn1({})))}),ha.of({name:"Asterisk",filename:/^extensions\.conf$/i,load:()=>import("./asterisk-C3IDaiGv.js").then(t=>Lh(t.asterisk))}),ha.of({name:"Cobol",extensions:["cob","cpy"],load:()=>import("./cobol-CefNQ_w0.js").then(t=>Lh(t.cobol))}),ha.of({name:"C#",alias:["csharp","cs"],extensions:["cs"],load:()=>import("./clike-CWAiRpcw.js").then(t=>Lh(t.csharp))}),ha.of({name:"Clojure",extensions:["clj","cljc","cljx"],load:()=>import("./clojure-Ch3ZXkHC.js").then(t=>Lh(t.clojure))}),ha.of({name:"ClojureScript",extensions:["cljs"],load:()=>import("./clojure-Ch3ZXkHC.js").then(t=>Lh(t.clojure))}),ha.of({name:"Closure Stylesheets (GSS)",extensions:["gss"],load:()=>import("./css-BhqlouBq.js").then(t=>Lh(t.gss))}),ha.of({name:"CMake",extensions:["cmake","cmake.in"],filename:/^CMakeLists\.txt$/,load:()=>import("./cmake-DJ6-M7RZ.js").then(t=>Lh(t.cmake))}),ha.of({name:"CoffeeScript",alias:["coffee","coffee-script"],extensions:["coffee"],load:()=>import("./coffeescript-4qvUnmrT.js").then(t=>Lh(t.coffeeScript))}),ha.of({name:"Common Lisp",alias:["lisp"],extensions:["cl","lisp","el"],load:()=>import("./commonlisp-k5lBHlrn.js").then(t=>Lh(t.commonLisp))}),ha.of({name:"Cypher",extensions:["cyp","cypher"],load:()=>import("./cypher-BlVNs-s1.js").then(t=>Lh(t.cypher))}),ha.of({name:"Cython",extensions:["pyx","pxd","pxi"],load:()=>import("./python-CngGfBf0.js").then(t=>Lh(t.cython))}),ha.of({name:"Crystal",extensions:["cr"],load:()=>import("./crystal-DFd4Ih4u.js").then(t=>Lh(t.crystal))}),ha.of({name:"D",extensions:["d"],load:()=>import("./d-CM_npLQV.js").then(t=>Lh(t.d))}),ha.of({name:"Dart",extensions:["dart"],load:()=>import("./clike-CWAiRpcw.js").then(t=>Lh(t.dart))}),ha.of({name:"diff",extensions:["diff","patch"],load:()=>import("./diff-7P1q5HUO.js").then(t=>Lh(t.diff))}),ha.of({name:"Dockerfile",filename:/^Dockerfile$/,load:()=>import("./dockerfile-DqeVY5Wu.js").then(t=>Lh(t.dockerFile))}),ha.of({name:"DTD",extensions:["dtd"],load:()=>import("./dtd-CWbJaDIV.js").then(t=>Lh(t.dtd))}),ha.of({name:"Dylan",extensions:["dylan","dyl","intr"],load:()=>import("./dylan-EbE5y8Qm.js").then(t=>Lh(t.dylan))}),ha.of({name:"EBNF",load:()=>import("./ebnf-DbYI1jy4.js").then(t=>Lh(t.ebnf))}),ha.of({name:"ECL",extensions:["ecl"],load:()=>import("./ecl-CFSa7Lym.js").then(t=>Lh(t.ecl))}),ha.of({name:"edn",extensions:["edn"],load:()=>import("./clojure-Ch3ZXkHC.js").then(t=>Lh(t.clojure))}),ha.of({name:"Eiffel",extensions:["e"],load:()=>import("./eiffel-9Wtpmi2K.js").then(t=>Lh(t.eiffel))}),ha.of({name:"Elm",extensions:["elm"],load:()=>import("./elm-DWhcgMBd.js").then(t=>Lh(t.elm))}),ha.of({name:"Erlang",extensions:["erl"],load:()=>import("./erlang-CR1HJySh.js").then(t=>Lh(t.erlang))}),ha.of({name:"Esper",load:()=>import("./sql-DoWohZH_.js").then(t=>Lh(t.esper))}),ha.of({name:"Factor",extensions:["factor"],load:()=>import("./factor-DT3csLlE.js").then(t=>Lh(t.factor))}),ha.of({name:"FCL",load:()=>import("./fcl-CbvOTRm9.js").then(t=>Lh(t.fcl))}),ha.of({name:"Forth",extensions:["forth","fth","4th"],load:()=>import("./forth-BsE0kFPn.js").then(t=>Lh(t.forth))}),ha.of({name:"Fortran",extensions:["f","for","f77","f90","f95"],load:()=>import("./fortran-AWWy4gQC.js").then(t=>Lh(t.fortran))}),ha.of({name:"F#",alias:["fsharp"],extensions:["fs"],load:()=>import("./mllike-l-LEbnhM.js").then(t=>Lh(t.fSharp))}),ha.of({name:"Gas",extensions:["s"],load:()=>import("./gas-DjE-0YRJ.js").then(t=>Lh(t.gas))}),ha.of({name:"Gherkin",extensions:["feature"],load:()=>import("./gherkin-G3xXRA7g.js").then(t=>Lh(t.gherkin))}),ha.of({name:"Groovy",extensions:["groovy","gradle"],filename:/^Jenkinsfile$/,load:()=>import("./groovy-CNwvtTN8.js").then(t=>Lh(t.groovy))}),ha.of({name:"Haskell",extensions:["hs"],load:()=>import("./haskell-B--9zNgZ.js").then(t=>Lh(t.haskell))}),ha.of({name:"Haxe",extensions:["hx"],load:()=>import("./haxe-BH6QOKpD.js").then(t=>Lh(t.haxe))}),ha.of({name:"HXML",extensions:["hxml"],load:()=>import("./haxe-BH6QOKpD.js").then(t=>Lh(t.hxml))}),ha.of({name:"HTTP",load:()=>import("./http-ZbVY0uts.js").then(t=>Lh(t.http))}),ha.of({name:"IDL",extensions:["pro"],load:()=>import("./idl-D7fBoMHw.js").then(t=>Lh(t.idl))}),ha.of({name:"JSON-LD",alias:["jsonld"],extensions:["jsonld"],load:()=>import("./javascript-BynWom2t.js").then(t=>Lh(t.jsonld))}),ha.of({name:"Julia",extensions:["jl"],load:()=>import("./julia-BgwMKKt8.js").then(t=>Lh(t.julia))}),ha.of({name:"Kotlin",extensions:["kt","kts"],load:()=>import("./clike-CWAiRpcw.js").then(t=>Lh(t.kotlin))}),ha.of({name:"LiveScript",alias:["ls"],extensions:["ls"],load:()=>import("./livescript-CfylQWC2.js").then(t=>Lh(t.liveScript))}),ha.of({name:"Lua",extensions:["lua"],load:()=>import("./lua-bFmn3AKO.js").then(t=>Lh(t.lua))}),ha.of({name:"mIRC",extensions:["mrc"],load:()=>import("./mirc-XnPCL3O-.js").then(t=>Lh(t.mirc))}),ha.of({name:"Mathematica",extensions:["m","nb","wl","wls"],load:()=>import("./mathematica-Dws9P2fA.js").then(t=>Lh(t.mathematica))}),ha.of({name:"Modelica",extensions:["mo"],load:()=>import("./modelica-BbO92hea.js").then(t=>Lh(t.modelica))}),ha.of({name:"MUMPS",extensions:["mps"],load:()=>import("./mumps-CktIo_vc.js").then(t=>Lh(t.mumps))}),ha.of({name:"Mbox",extensions:["mbox"],load:()=>import("./mbox-BIh2BjAu.js").then(t=>Lh(t.mbox))}),ha.of({name:"Nginx",filename:/nginx.*\.conf$/i,load:()=>import("./nginx-BOcx_Qcw.js").then(t=>Lh(t.nginx))}),ha.of({name:"NSIS",extensions:["nsh","nsi"],load:()=>import("./nsis-B-vzq3eT.js").then(t=>Lh(t.nsis))}),ha.of({name:"NTriples",extensions:["nt","nq"],load:()=>import("./ntriples-C1FRJSj6.js").then(t=>Lh(t.ntriples))}),ha.of({name:"Objective-C",alias:["objective-c","objc"],extensions:["m"],load:()=>import("./clike-CWAiRpcw.js").then(t=>Lh(t.objectiveC))}),ha.of({name:"Objective-C++",alias:["objective-c++","objc++"],extensions:["mm"],load:()=>import("./clike-CWAiRpcw.js").then(t=>Lh(t.objectiveCpp))}),ha.of({name:"OCaml",extensions:["ml","mli","mll","mly"],load:()=>import("./mllike-l-LEbnhM.js").then(t=>Lh(t.oCaml))}),ha.of({name:"Octave",extensions:["m"],load:()=>import("./octave-BOQo3ezn.js").then(t=>Lh(t.octave))}),ha.of({name:"Oz",extensions:["oz"],load:()=>import("./oz-OnSdrfM9.js").then(t=>Lh(t.oz))}),ha.of({name:"Pascal",extensions:["p","pas"],load:()=>import("./pascal-4g6TYfFw.js").then(t=>Lh(t.pascal))}),ha.of({name:"Perl",extensions:["pl","pm"],load:()=>import("./perl-Dgr-ngbg.js").then(t=>Lh(t.perl))}),ha.of({name:"Pig",extensions:["pig"],load:()=>import("./pig-CZMi3-8m.js").then(t=>Lh(t.pig))}),ha.of({name:"PowerShell",extensions:["ps1","psd1","psm1"],load:()=>import("./powershell-DXvQ4x1m.js").then(t=>Lh(t.powerShell))}),ha.of({name:"Properties files",alias:["ini","properties"],extensions:["properties","ini","in"],load:()=>import("./properties-FpKoskXV.js").then(t=>Lh(t.properties))}),ha.of({name:"ProtoBuf",extensions:["proto"],load:()=>import("./protobuf-MCw-m64T.js").then(t=>Lh(t.protobuf))}),ha.of({name:"Pug",alias:["jade"],extensions:["pug","jade"],load:()=>import("./pug-Flk_Hgat.js").then(t=>Lh(t.pug))}),ha.of({name:"Puppet",extensions:["pp"],load:()=>import("./puppet-6S-P5OOW.js").then(t=>Lh(t.puppet))}),ha.of({name:"Q",extensions:["q"],load:()=>import("./q-44edCNj4.js").then(t=>Lh(t.q))}),ha.of({name:"R",alias:["rscript"],extensions:["r","R"],load:()=>import("./r-DIR8PHAo.js").then(t=>Lh(t.r))}),ha.of({name:"RPM Changes",load:()=>import("./rpm-BRQLtgp3.js").then(t=>Lh(t.rpmChanges))}),ha.of({name:"RPM Spec",extensions:["spec"],load:()=>import("./rpm-BRQLtgp3.js").then(t=>Lh(t.rpmSpec))}),ha.of({name:"Ruby",alias:["jruby","macruby","rake","rb","rbx"],extensions:["rb"],filename:/^(Gemfile|Rakefile)$/,load:()=>import("./ruby-D8RNHeY9.js").then(t=>Lh(t.ruby))}),ha.of({name:"SAS",extensions:["sas"],load:()=>import("./sas-D5OczIPs.js").then(t=>Lh(t.sas))}),ha.of({name:"Scala",extensions:["scala"],load:()=>import("./clike-CWAiRpcw.js").then(t=>Lh(t.scala))}),ha.of({name:"Scheme",extensions:["scm","ss"],load:()=>import("./scheme-B8-CRLJA.js").then(t=>Lh(t.scheme))}),ha.of({name:"Shell",alias:["bash","sh","zsh"],extensions:["sh","ksh","bash"],filename:/^PKGBUILD$/,load:()=>import("./shell-D8CunHXO.js").then(t=>Lh(t.shell))}),ha.of({name:"Sieve",extensions:["siv","sieve"],load:()=>import("./sieve-Bf_yZtZi.js").then(t=>Lh(t.sieve))}),ha.of({name:"Smalltalk",extensions:["st"],load:()=>import("./smalltalk-NwhojTAP.js").then(t=>Lh(t.smalltalk))}),ha.of({name:"Solr",load:()=>import("./solr-DpsSZ9SG.js").then(t=>Lh(t.solr))}),ha.of({name:"SML",extensions:["sml","sig","fun","smackspec"],load:()=>import("./mllike-l-LEbnhM.js").then(t=>Lh(t.sml))}),ha.of({name:"SPARQL",alias:["sparul"],extensions:["rq","sparql"],load:()=>import("./sparql-ClZP4ej6.js").then(t=>Lh(t.sparql))}),ha.of({name:"Spreadsheet",alias:["excel","formula"],load:()=>import("./spreadsheet-DnW91EGa.js").then(t=>Lh(t.spreadsheet))}),ha.of({name:"Squirrel",extensions:["nut"],load:()=>import("./clike-CWAiRpcw.js").then(t=>Lh(t.squirrel))}),ha.of({name:"Stylus",extensions:["styl"],load:()=>import("./stylus-C8jtBncI.js").then(t=>Lh(t.stylus))}),ha.of({name:"Swift",extensions:["swift"],load:()=>import("./swift-CaGCX2Dw.js").then(t=>Lh(t.swift))}),ha.of({name:"sTeX",load:()=>import("./stex-CyIvgWqs.js").then(t=>Lh(t.stex))}),ha.of({name:"LaTeX",alias:["tex"],extensions:["text","ltx","tex"],load:()=>import("./stex-CyIvgWqs.js").then(t=>Lh(t.stex))}),ha.of({name:"SystemVerilog",extensions:["v","sv","svh"],load:()=>import("./verilog-Dld4vhaQ.js").then(t=>Lh(t.verilog))}),ha.of({name:"Tcl",extensions:["tcl"],load:()=>import("./tcl-CZLOxvIM.js").then(t=>Lh(t.tcl))}),ha.of({name:"Textile",extensions:["textile"],load:()=>import("./textile-MK6Fa0rE.js").then(t=>Lh(t.textile))}),ha.of({name:"TiddlyWiki",load:()=>import("./tiddlywiki-DUbhySn3.js").then(t=>Lh(t.tiddlyWiki))}),ha.of({name:"Tiki wiki",load:()=>import("./tiki-DaH-6R3-.js").then(t=>Lh(t.tiki))}),ha.of({name:"TOML",extensions:["toml"],load:()=>import("./toml-SjzHK0kN.js").then(t=>Lh(t.toml))}),ha.of({name:"Troff",extensions:["1","2","3","4","5","6","7","8","9"],load:()=>import("./troff-Bz5Iai1v.js").then(t=>Lh(t.troff))}),ha.of({name:"TTCN",extensions:["ttcn","ttcn3","ttcnpp"],load:()=>import("./ttcn-C4gOnQYH.js").then(t=>Lh(t.ttcn))}),ha.of({name:"TTCN_CFG",extensions:["cfg"],load:()=>import("./ttcn-cfg-C8jO5Cys.js").then(t=>Lh(t.ttcnCfg))}),ha.of({name:"Turtle",extensions:["ttl"],load:()=>import("./turtle-C8Ccmmmk.js").then(t=>Lh(t.turtle))}),ha.of({name:"Web IDL",extensions:["webidl"],load:()=>import("./webidl-BgptLqNm.js").then(t=>Lh(t.webIDL))}),ha.of({name:"VB.NET",extensions:["vb"],load:()=>import("./vb-Cwma-1KF.js").then(t=>Lh(t.vb))}),ha.of({name:"VBScript",extensions:["vbs"],load:()=>import("./vbscript-DMhmzc0h.js").then(t=>Lh(t.vbScript))}),ha.of({name:"Velocity",extensions:["vtl"],load:()=>import("./velocity-RZxqTCZo.js").then(t=>Lh(t.velocity))}),ha.of({name:"Verilog",extensions:["v"],load:()=>import("./verilog-Dld4vhaQ.js").then(t=>Lh(t.verilog))}),ha.of({name:"VHDL",extensions:["vhd","vhdl"],load:()=>import("./vhdl-DMOFQvtW.js").then(t=>Lh(t.vhdl))}),ha.of({name:"XQuery",extensions:["xy","xquery","xq","xqm","xqy"],load:()=>import("./xquery-8Z_FGC6j.js").then(t=>Lh(t.xQuery))}),ha.of({name:"Yacas",extensions:["ys"],load:()=>import("./yacas-C3ZexFYq.js").then(t=>Lh(t.yacas))}),ha.of({name:"Z80",extensions:["z80"],load:()=>import("./z80-Dz8lvJzy.js").then(t=>Lh(t.z80))}),ha.of({name:"MscGen",extensions:["mscgen","mscin","msc"],load:()=>import("./mscgen-CQJIxZ4W.js").then(t=>Lh(t.mscgen))}),ha.of({name:"Xù",extensions:["xu"],load:()=>import("./mscgen-CQJIxZ4W.js").then(t=>Lh(t.xu))}),ha.of({name:"MsGenny",extensions:["msgenny"],load:()=>import("./mscgen-CQJIxZ4W.js").then(t=>Lh(t.msgenny))}),ha.of({name:"Vue",extensions:["vue"],load:()=>import("./index-DWCU-zPy.js").then(t=>t.vue())}),ha.of({name:"Angular Template",load:()=>import("./index-C8xRVVPE.js").then(t=>t.angular())})];
|
|
101
101
|
/*!
|
|
102
102
|
* program-language-detector v0.0.12
|
|
103
103
|
* (c) 2018-present ULIVZ <chl814@foxmail.com>
|