diff --git a/resources/dist/codemirror.js b/resources/dist/codemirror.js index f5910a5..9283c91 100644 --- a/resources/dist/codemirror.js +++ b/resources/dist/codemirror.js @@ -1 +1 @@ -"use strict";var e=require("ext.CodeMirror.v6.lib"),t=function(){return e._createClass((function t(r){e._classCallCheck(this,t),this.view=r,this.$cmDom=$(r.dom)}),[{key:"getContents",value:function(){return this.view.state.doc.toString()}},{key:"setContents",value:function(e){return this.view.dispatch({changes:{from:0,to:this.view.state.doc.length,insert:e}}),this.$cmDom}},{key:"getCaretPosition",value:function(e){return e.startAndEnd?[this.view.state.selection.main.from,this.view.state.selection.main.to]:this.view.state.selection.main.head}},{key:"scrollToCaretPosition",value:function(){var t=e.EditorView.scrollIntoView(this.view.state.selection.main.head);return t.value.isSnapshot=!0,this.view.dispatch({effects:t}),this.$cmDom}},{key:"getSelection",value:function(){return this.view.state.sliceDoc(this.view.state.selection.main.from,this.view.state.selection.main.to)}},{key:"setSelection",value:function(e){return this.view.dispatch({selection:{anchor:e.start,head:e.end||e.start}}),this.view.focus(),this.$cmDom}},{key:"replaceSelection",value:function(e){return this.view.dispatch(this.view.state.replaceSelection(e)),this.$cmDom}},{key:"encapsulateSelection",value:function(t){var r,i=!1;this.view.focus(),void 0!==t.selectionStart&&this.setSelection({start:t.selectionStart,end:t.selectionEnd||t.selectionStart}),r=this.getSelection();var o=this.getCaretPosition({startAndEnd:!0}),s=e._slicedToArray(o,1)[0];!function(){if(r)if(t.replace)r=t.peri;else{for(;" "===r.charAt(r.length-1);)r=r.slice(0,-1),t.post+=" ";for(;" "===r.charAt(0);)r=r.slice(1),t.pre=" "+t.pre}else r=t.peri,i=!0}();var n=t.pre+r+t.post;return this.view.state.selection.ranges.length>1?(this.view.dispatch(this.view.state.changeByRange((function(r){return{changes:[{from:r.from,insert:t.pre},{from:r.to,insert:t.post}],range:e.EditorSelection.range(r.to+t.pre.length+t.post.length,r.to+t.pre.length+t.post.length)}}))),this.$cmDom):(this.replaceSelection(n),i&&t.selectPeri?this.setSelection({start:s+t.pre.length,end:s+t.pre.length+r.length}):this.setSelection({start:s+n.length}),this.$cmDom)}}])}();require("../ext.CodeMirror.data.js");var r=function(){return e._createClass((function t(r){e._classCallCheck(this,t),this.$textarea=$(r),this.view=null,this.state=null,this.readOnly=this.$textarea.prop("readonly"),this.editRecoveryHandler=null,this.textSelection=null}),[{key:"defaultExtensions",get:function(){var t=this,r=[this.contentAttributesExtension,this.phrasesExtension,this.specialCharsExtension,this.heightExtension,e.bracketMatching(),e.EditorState.readOnly.of(this.readOnly),e.keymap.of([].concat(e._toConsumableArray(e.defaultKeymap),e._toConsumableArray(e.searchKeymap))),e.EditorState.allowMultipleSelections.of(!0),e.drawSelection(),e.rectangularSelection(),e.crosshairCursor()];if(!this.readOnly){r.push(e.EditorView.updateListener.of((function(e){e.docChanged&&"function"==typeof t.editRecoveryHandler&&t.editRecoveryHandler()}))),r.push(e.history());var i=[].concat(e._toConsumableArray(e.historyKeymap),[{win:"Ctrl-Shift-z",preventDefault:!0,run:e.redo}]);r.push(e.keymap.of(i))}var o=mw.config.get("extCodeMirrorConfig").lineNumberingNamespaces;return o&&!o.includes(mw.config.get("wgNamespaceNumber"))||r.push(e.lineNumbers()),r}},{key:"heightExtension",get:function(){return e.EditorView.theme({"&":{height:"".concat(this.$textarea.outerHeight(),"px")},".cm-scroller":{overflow:"auto"}})}},{key:"contentAttributesExtension",get:function(){var t=[],r=Array.from(this.$textarea[0].classList).find((function(e){return e.startsWith("mw-editfont-")}));return r&&t.push(r),mw.user.options.get("usecodemirror-colorblind")&&"wikitext"===mw.config.get("wgPageContentModel")&&t.push("cm-mw-colorblind-colors"),[e.EditorView.contentAttributes.of({accesskey:this.$textarea.attr("accesskey"),class:t.join(" "),spellcheck:"true"}),e.EditorView.editorAttributes.of({dir:this.$textarea.attr("dir"),lang:this.$textarea.attr("lang")})]}},{key:"phrasesExtension",get:function(){return e.EditorState.phrases.of({Find:mw.msg("codemirror-find"),next:mw.msg("codemirror-next"),previous:mw.msg("codemirror-previous"),all:mw.msg("codemirror-all"),"match case":mw.msg("codemirror-match-case"),regexp:mw.msg("codemirror-regexp"),"by word":mw.msg("codemirror-by-word"),replace:mw.msg("codemirror-replace"),Replace:mw.msg("codemirror-replace-placeholder"),"replace all":mw.msg("codemirror-replace-all"),"Control character":mw.msg("codemirror-control-character"),close:mw.msg("codemirror-search-done")})}},{key:"specialCharsExtension",get:function(){var t={0:mw.msg("codemirror-special-char-null"),7:mw.msg("codemirror-special-char-bell"),8:mw.msg("codemirror-special-char-backspace"),10:mw.msg("codemirror-special-char-newline"),11:mw.msg("codemirror-special-char-vertical-tab"),13:mw.msg("codemirror-special-char-carriage-return"),27:mw.msg("codemirror-special-char-escape"),160:mw.msg("codemirror-special-char-nbsp"),8203:mw.msg("codemirror-special-char-zero-width-space"),8204:mw.msg("codemirror-special-char-zero-width-non-joiner"),8205:mw.msg("codemirror-special-char-zero-width-joiner"),8206:mw.msg("codemirror-special-char-left-to-right-mark"),8207:mw.msg("codemirror-special-char-right-to-left-mark"),8232:mw.msg("codemirror-special-char-line-separator"),8237:mw.msg("codemirror-special-char-left-to-right-override"),8238:mw.msg("codemirror-special-char-right-to-left-override"),8239:mw.msg("codemirror-special-char-narrow-nbsp"),8294:mw.msg("codemirror-special-char-left-to-right-isolate"),8295:mw.msg("codemirror-special-char-right-to-left-isolate"),8297:mw.msg("codemirror-special-char-pop-directional-isolate"),8233:mw.msg("codemirror-special-char-paragraph-separator"),65279:mw.msg("codemirror-special-char-zero-width-no-break-space"),65532:mw.msg("codemirror-special-char-object-replacement")};return e.highlightSpecialChars({render:function(e,r,i){r=t[e]||mw.msg("codemirror-control-character",e);var o=document.createElement("span");return o.className="cm-specialChar",160!==e&&8239!==e||(i="·",o.className="cm-special-char-nbsp"),o.textContent=i,o.title=r,o.setAttribute("aria-label",r),o},addSpecialChars:/[\u00a0\u202f]/g})}},{key:"initialize",value:function(){var t=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.defaultExtensions;mw.hook("ext.CodeMirror.initialize").fire(this.$textarea),mw.hook("editRecovery.loadEnd").add((function(e){t.editRecoveryHandler=e.fieldChangeHandler})),this.state=e.EditorState.create({doc:this.$textarea.textSelection("getContents"),extensions:r}),this.view=new e.EditorView({state:this.state,parent:this.$textarea.parent()[0]}),this.$textarea.hide(),this.$textarea[0].form&&this.$textarea[0].form.addEventListener("submit",(function(){t.$textarea.val(t.view.state.doc.toString());var e=document.getElementById("wpScrolltop");e&&(e.value=t.view.scrollDOM.scrollTop)})),$(this.view.dom).textSelection("register",this.cmTextSelection),this.$textarea.textSelection("register",this.cmTextSelection)}},{key:"logUsage",value:function(e){var t=Object.assign({session_token:mw.user.sessionId(),user_id:mw.user.getId()},e),r=mw.config.get("wgUserEditCountBucket");null!==r&&(t.user_edit_count_bucket=r),mw.track("event.CodeMirrorUsage",t)}},{key:"setCodeMirrorPreference",value:function(e){mw.user.isAnon()||((new mw.Api).saveOption("usecodemirror",e?1:0),mw.user.options.set("usecodemirror",e?1:0))}},{key:"cmTextSelection",get:function(){var e=this;return this.textSelection=new t(this.view),{getContents:function(){return e.textSelection.getContents()},setContents:function(t){return e.textSelection.setContents(t)},getCaretPosition:function(t){return e.textSelection.getCaretPosition(t)},scrollToCaretPosition:function(){return e.textSelection.scrollToCaretPosition()},getSelection:function(){return e.textSelection.getSelection()},setSelection:function(t){return e.textSelection.setSelection(t)},replaceSelection:function(t){return e.textSelection.replaceSelection(t)},encapsulateSelection:function(t){return e.textSelection.encapsulateSelection(t)}}}}])}();module.exports=r; +"use strict";var e=require("ext.CodeMirror.v6.lib");class t{constructor(e){this.view=e,this.$cmDom=$(e.dom)}getContents(){return this.view.state.doc.toString()}setContents(e){return this.view.dispatch({changes:{from:0,to:this.view.state.doc.length,insert:e}}),this.$cmDom}getCaretPosition(e){return e.startAndEnd?[this.view.state.selection.main.from,this.view.state.selection.main.to]:this.view.state.selection.main.head}scrollToCaretPosition(){const t=e.EditorView.scrollIntoView(this.view.state.selection.main.head);return t.value.isSnapshot=!0,this.view.dispatch({effects:t}),this.$cmDom}getSelection(){return this.view.state.sliceDoc(this.view.state.selection.main.from,this.view.state.selection.main.to)}setSelection(e){return this.view.dispatch({selection:{anchor:e.start,head:e.end||e.start}}),this.view.focus(),this.$cmDom}replaceSelection(e){return this.view.dispatch(this.view.state.replaceSelection(e)),this.$cmDom}encapsulateSelection(t){let r,i=!1;this.view.focus(),void 0!==t.selectionStart&&this.setSelection({start:t.selectionStart,end:t.selectionEnd||t.selectionStart}),r=this.getSelection();const[s]=this.getCaretPosition({startAndEnd:!0});(()=>{if(r)if(t.replace)r=t.peri;else{for(;" "===r.charAt(r.length-1);)r=r.slice(0,-1),t.post+=" ";for(;" "===r.charAt(0);)r=r.slice(1),t.pre=" "+t.pre}else r=t.peri,i=!0})();const o=t.pre+r+t.post;return this.view.state.selection.ranges.length>1?(this.view.dispatch(this.view.state.changeByRange((r=>({changes:[{from:r.from,insert:t.pre},{from:r.to,insert:t.post}],range:e.EditorSelection.range(r.to+t.pre.length+t.post.length,r.to+t.pre.length+t.post.length)})))),this.$cmDom):(this.replaceSelection(o),i&&t.selectPeri?this.setSelection({start:s+t.pre.length,end:s+t.pre.length+r.length}):this.setSelection({start:s+o.length}),this.$cmDom)}}require("../ext.CodeMirror.data.js");module.exports=class{constructor(e){this.$textarea=$(e),this.view=null,this.state=null,this.readOnly=this.$textarea.prop("readonly"),this.editRecoveryHandler=null,this.textSelection=null}get defaultExtensions(){const t=[this.contentAttributesExtension,this.phrasesExtension,this.specialCharsExtension,this.heightExtension,e.bracketMatching(),e.EditorState.readOnly.of(this.readOnly),e.keymap.of([...e.defaultKeymap,...e.searchKeymap]),e.EditorState.allowMultipleSelections.of(!0),e.drawSelection(),e.rectangularSelection(),e.crosshairCursor()];if(!this.readOnly){t.push(e.EditorView.updateListener.of((e=>{e.docChanged&&"function"==typeof this.editRecoveryHandler&&this.editRecoveryHandler()}))),t.push(e.history());const r=[...e.historyKeymap,{win:"Ctrl-Shift-z",preventDefault:!0,run:e.redo}];t.push(e.keymap.of(r))}const r=mw.config.get("extCodeMirrorConfig").lineNumberingNamespaces;return r&&!r.includes(mw.config.get("wgNamespaceNumber"))||t.push(e.lineNumbers()),t}get heightExtension(){return e.EditorView.theme({"&":{height:`${this.$textarea.outerHeight()}px`},".cm-scroller":{overflow:"auto"}})}get contentAttributesExtension(){const t=[],r=Array.from(this.$textarea[0].classList).find((e=>e.startsWith("mw-editfont-")));return r&&t.push(r),mw.user.options.get("usecodemirror-colorblind")&&"wikitext"===mw.config.get("wgPageContentModel")&&t.push("cm-mw-colorblind-colors"),[e.EditorView.contentAttributes.of({accesskey:this.$textarea.attr("accesskey"),class:t.join(" "),spellcheck:"true"}),e.EditorView.editorAttributes.of({dir:this.$textarea.attr("dir"),lang:this.$textarea.attr("lang")})]}get phrasesExtension(){return e.EditorState.phrases.of({Find:mw.msg("codemirror-find"),next:mw.msg("codemirror-next"),previous:mw.msg("codemirror-previous"),all:mw.msg("codemirror-all"),"match case":mw.msg("codemirror-match-case"),regexp:mw.msg("codemirror-regexp"),"by word":mw.msg("codemirror-by-word"),replace:mw.msg("codemirror-replace"),Replace:mw.msg("codemirror-replace-placeholder"),"replace all":mw.msg("codemirror-replace-all"),"Control character":mw.msg("codemirror-control-character"),close:mw.msg("codemirror-search-done")})}get specialCharsExtension(){const t={0:mw.msg("codemirror-special-char-null"),7:mw.msg("codemirror-special-char-bell"),8:mw.msg("codemirror-special-char-backspace"),10:mw.msg("codemirror-special-char-newline"),11:mw.msg("codemirror-special-char-vertical-tab"),13:mw.msg("codemirror-special-char-carriage-return"),27:mw.msg("codemirror-special-char-escape"),160:mw.msg("codemirror-special-char-nbsp"),8203:mw.msg("codemirror-special-char-zero-width-space"),8204:mw.msg("codemirror-special-char-zero-width-non-joiner"),8205:mw.msg("codemirror-special-char-zero-width-joiner"),8206:mw.msg("codemirror-special-char-left-to-right-mark"),8207:mw.msg("codemirror-special-char-right-to-left-mark"),8232:mw.msg("codemirror-special-char-line-separator"),8237:mw.msg("codemirror-special-char-left-to-right-override"),8238:mw.msg("codemirror-special-char-right-to-left-override"),8239:mw.msg("codemirror-special-char-narrow-nbsp"),8294:mw.msg("codemirror-special-char-left-to-right-isolate"),8295:mw.msg("codemirror-special-char-right-to-left-isolate"),8297:mw.msg("codemirror-special-char-pop-directional-isolate"),8233:mw.msg("codemirror-special-char-paragraph-separator"),65279:mw.msg("codemirror-special-char-zero-width-no-break-space"),65532:mw.msg("codemirror-special-char-object-replacement")};return e.highlightSpecialChars({render:(e,r,i)=>{r=t[e]||mw.msg("codemirror-control-character",e);const s=document.createElement("span");return s.className="cm-specialChar",160!==e&&8239!==e||(i="·",s.className="cm-special-char-nbsp"),s.textContent=i,s.title=r,s.setAttribute("aria-label",r),s},addSpecialChars:/[\u00a0\u202f]/g})}initialize(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.defaultExtensions;mw.hook("ext.CodeMirror.initialize").fire(this.$textarea),mw.hook("editRecovery.loadEnd").add((e=>{this.editRecoveryHandler=e.fieldChangeHandler})),this.state=e.EditorState.create({doc:this.$textarea.textSelection("getContents"),extensions:t}),this.view=new e.EditorView({state:this.state,parent:this.$textarea.parent()[0]}),this.$textarea.hide(),this.$textarea[0].form&&this.$textarea[0].form.addEventListener("submit",(()=>{this.$textarea.val(this.view.state.doc.toString());const e=document.getElementById("wpScrolltop");e&&(e.value=this.view.scrollDOM.scrollTop)})),$(this.view.dom).textSelection("register",this.cmTextSelection),this.$textarea.textSelection("register",this.cmTextSelection)}logUsage(e){const t=Object.assign({session_token:mw.user.sessionId(),user_id:mw.user.getId()},e),r=mw.config.get("wgUserEditCountBucket");null!==r&&(t.user_edit_count_bucket=r),mw.track("event.CodeMirrorUsage",t)}setCodeMirrorPreference(e){mw.user.isAnon()||((new mw.Api).saveOption("usecodemirror",e?1:0),mw.user.options.set("usecodemirror",e?1:0))}get cmTextSelection(){return this.textSelection=new t(this.view),{getContents:()=>this.textSelection.getContents(),setContents:e=>this.textSelection.setContents(e),getCaretPosition:e=>this.textSelection.getCaretPosition(e),scrollToCaretPosition:()=>this.textSelection.scrollToCaretPosition(),getSelection:()=>this.textSelection.getSelection(),setSelection:e=>this.textSelection.setSelection(e),replaceSelection:e=>this.textSelection.replaceSelection(e),encapsulateSelection:e=>this.textSelection.encapsulateSelection(e)}}}; diff --git a/resources/dist/codemirror.mode.mediawiki.js b/resources/dist/codemirror.mode.mediawiki.js index 9b59af3..141997b 100644 --- a/resources/dist/codemirror.mode.mediawiki.js +++ b/resources/dist/codemirror.mode.mediawiki.js @@ -1 +1 @@ -"use strict";var t=require("ext.CodeMirror.v6.lib"),e=new WeakSet;function a(t){return{em:"mw-em",error:"mw-error",extNowiki:"mw-ext-nowiki",extPre:"mw-ext-pre",extTag:"mw-exttag",extTagAttribute:"mw-exttag-attribute",extTagBracket:"mw-exttag-bracket",extTagName:"mw-exttag-name",freeExtLink:"mw-free-extlink",freeExtLinkProtocol:"mw-free-extlink-protocol",htmlEntity:"mw-html-entity",link:"mw-link",linkPageName:"mw-link-pagename",nowiki:"mw-tag-nowiki",pageName:"mw-pagename",pre:"mw-tag-pre",section:"mw-section",skipFormatting:"mw-skipformatting",strong:"mw-strong",tableCaption:"mw-table-caption",templateVariableDelimiter:"mw-templatevariable-delimiter"}}var i=new(function(){return t._createClass((function a(){t._classCallCheck(this,a),t._classPrivateMethodInitSpec(this,e),this.extHighlightStyles=[],this.tokenTable=this.defaultTokenTable}),[{key:"addTag",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this.tokenTable["mw-tag-".concat(t)]||(this.addToken("mw-tag-".concat(t),e),this.addToken("mw-ext-".concat(t),e))}},{key:"addToken",value:function(e){var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this.tokenTable[e]||(this.tokenTable[e]=t.Tag.define(a),this.extHighlightStyles.push({tag:this.tokenTable[e],class:"cm-".concat(e)}))}},{key:"permittedHtmlTags",get:function(){return{b:!0,bdi:!0,del:!0,i:!0,ins:!0,u:!0,font:!0,big:!0,small:!0,sub:!0,sup:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,cite:!0,code:!0,em:!0,s:!0,strike:!0,strong:!0,tt:!0,var:!0,div:!0,center:!0,blockquote:!0,q:!0,ol:!0,ul:!0,dl:!0,table:!0,caption:!0,pre:!0,ruby:!0,rb:!0,rp:!0,rt:!0,rtc:!0,p:!0,span:!0,abbr:!0,dfn:!0,kbd:!0,samp:!0,data:!0,time:!0,mark:!0,br:!0,wbr:!0,hr:!0,li:!0,dt:!0,dd:!0,td:!0,th:!0,tr:!0,noinclude:!0,includeonly:!0,onlyinclude:!0}}},{key:"implicitlyClosedHtmlTags",get:function(){return{br:!0,hr:!0,wbr:!0}}},{key:"tags",get:function(){return t._objectSpread2({apostrophes:"character",apostrophesBold:"strong",apostrophesItalic:"emphasis",comment:"comment",doubleUnderscore:"controlKeyword",extLink:"url",extLinkBracket:"modifier",extLinkProtocol:"namespace",extLinkText:"labelName",hr:"contentSeparator",htmlTagAttribute:"attributeName",htmlTagBracket:"angleBracket",htmlTagName:"tagName",indenting:"operatorKeyword",linkBracket:"squareBracket",linkDelimiter:"operator",linkText:"string",linkToSection:"className",list:"list",parserFunction:"unit",parserFunctionBracket:"paren",parserFunctionDelimiter:"punctuation",parserFunctionName:"keyword",sectionHeader:"heading",sectionHeader1:"heading1",sectionHeader2:"heading2",sectionHeader3:"heading3",sectionHeader4:"heading4",sectionHeader5:"heading5",sectionHeader6:"heading6",signature:"quote",tableBracket:"null",tableDefinition:"definitionOperator",tableDelimiter:"typeOperator",template:"attributeValue",templateArgumentName:"definitionKeyword",templateBracket:"bracket",templateDelimiter:"separator",templateName:"moduleKeyword",templateVariable:"atom",templateVariableBracket:"brace",templateVariableName:"variableName"},t._classPrivateGetter(e,this,a))}},{key:"defaultTokenTable",get:function(){var e;return e={},t._defineProperty(t._defineProperty(t._defineProperty(t._defineProperty(t._defineProperty(t._defineProperty(t._defineProperty(t._defineProperty(t._defineProperty(t._defineProperty(e,this.tags.em,t.Tag.define()),this.tags.error,t.Tag.define()),this.tags.extNowiki,t.Tag.define()),this.tags.extPre,t.Tag.define()),this.tags.extTag,t.Tag.define()),this.tags.extTagAttribute,t.Tag.define()),this.tags.extTagBracket,t.Tag.define()),this.tags.extTagName,t.Tag.define()),this.tags.freeExtLink,t.Tag.define()),this.tags.freeExtLinkProtocol,t.Tag.define()),t._defineProperty(t._defineProperty(t._defineProperty(t._defineProperty(t._defineProperty(t._defineProperty(t._defineProperty(t._defineProperty(t._defineProperty(t._defineProperty(e,this.tags.htmlEntity,t.Tag.define()),this.tags.link,t.Tag.define()),this.tags.linkPageName,t.Tag.define()),this.tags.nowiki,t.Tag.define()),this.tags.pageName,t.Tag.define()),this.tags.pre,t.Tag.define()),this.tags.section,t.Tag.define()),this.tags.skipFormatting,t.Tag.define()),this.tags.strong,t.Tag.define()),this.tags.tableCaption,t.Tag.define()),t._defineProperty(e,this.tags.templateVariableDelimiter,t.Tag.define())}},{key:"getTagStyles",value:function(e){return[{tag:t.tags[this.tags.apostrophes],class:"cm-mw-apostrophes"},{tag:t.tags[this.tags.apostrophesBold],class:"cm-mw-apostrophes-bold"},{tag:t.tags[this.tags.apostrophesItalic],class:"cm-mw-apostrophes-italic"},{tag:t.tags[this.tags.comment],class:"cm-mw-comment"},{tag:t.tags[this.tags.doubleUnderscore],class:"cm-mw-double-underscore"},{tag:t.tags[this.tags.extLink],class:"cm-mw-extlink"},{tag:t.tags[this.tags.extLinkBracket],class:"cm-mw-extlink-bracket"},{tag:t.tags[this.tags.extLinkProtocol],class:"cm-mw-extlink-protocol"},{tag:t.tags[this.tags.extLinkText],class:"cm-mw-extlink-text"},{tag:t.tags[this.tags.hr],class:"cm-mw-hr"},{tag:t.tags[this.tags.htmlTagAttribute],class:"cm-mw-htmltag-attribute"},{tag:t.tags[this.tags.htmlTagBracket],class:"cm-mw-htmltag-bracket"},{tag:t.tags[this.tags.htmlTagName],class:"cm-mw-htmltag-name"},{tag:t.tags[this.tags.indenting],class:"cm-mw-indenting"},{tag:t.tags[this.tags.linkBracket],class:"cm-mw-link-bracket"},{tag:t.tags[this.tags.linkDelimiter],class:"cm-mw-link-delimiter"},{tag:t.tags[this.tags.linkText],class:"cm-mw-link-text"},{tag:t.tags[this.tags.linkToSection],class:"cm-mw-link-tosection"},{tag:t.tags[this.tags.list],class:"cm-mw-list"},{tag:t.tags[this.tags.parserFunction],class:"cm-mw-parserfunction"},{tag:t.tags[this.tags.parserFunctionBracket],class:"cm-mw-parserfunction-bracket"},{tag:t.tags[this.tags.parserFunctionDelimiter],class:"cm-mw-parserfunction-delimiter"},{tag:t.tags[this.tags.parserFunctionName],class:"cm-mw-parserfunction-name"},{tag:t.tags[this.tags.sectionHeader],class:"cm-mw-section-header"},{tag:t.tags[this.tags.sectionHeader1],class:"cm-mw-section-1"},{tag:t.tags[this.tags.sectionHeader2],class:"cm-mw-section-2"},{tag:t.tags[this.tags.sectionHeader3],class:"cm-mw-section-3"},{tag:t.tags[this.tags.sectionHeader4],class:"cm-mw-section-4"},{tag:t.tags[this.tags.sectionHeader5],class:"cm-mw-section-5"},{tag:t.tags[this.tags.sectionHeader6],class:"cm-mw-section-6"},{tag:t.tags[this.tags.signature],class:"cm-mw-signature"},{tag:t.tags[this.tags.tableBracket],class:"cm-mw-table-bracket"},{tag:t.tags[this.tags.tableDefinition],class:"cm-mw-table-definition"},{tag:t.tags[this.tags.tableDelimiter],class:"cm-mw-table-delimiter"},{tag:t.tags[this.tags.template],class:"cm-mw-template"},{tag:t.tags[this.tags.templateArgumentName],class:"cm-mw-template-argument-name"},{tag:t.tags[this.tags.templateBracket],class:"cm-mw-template-bracket"},{tag:t.tags[this.tags.templateDelimiter],class:"cm-mw-template-delimiter"},{tag:t.tags[this.tags.templateName],class:"cm-mw-pagename cm-mw-template-name"},{tag:t.tags[this.tags.templateVariable],class:"cm-mw-templatevariable"},{tag:t.tags[this.tags.templateVariableBracket],class:"cm-mw-templatevariable-bracket"},{tag:t.tags[this.tags.templateVariableName],class:"cm-mw-templatevariable-name"},{tag:e.tokenTable[this.tags.em],class:"cm-mw-em"},{tag:e.tokenTable[this.tags.error],class:"cm-mw-error"},{tag:e.tokenTable[this.tags.extNowiki],class:"cm-mw-ext-nowiki"},{tag:e.tokenTable[this.tags.extPre],class:"cm-mw-ext-pre"},{tag:e.tokenTable[this.tags.extTagBracket],class:"cm-mw-exttag-bracket"},{tag:e.tokenTable[this.tags.extTag],class:"cm-mw-exttag"},{tag:e.tokenTable[this.tags.extTagAttribute],class:"cm-mw-exttag-attribute"},{tag:e.tokenTable[this.tags.extTagName],class:"cm-mw-exttag-name"},{tag:e.tokenTable[this.tags.freeExtLink],class:"cm-mw-free-extlink"},{tag:e.tokenTable[this.tags.freeExtLinkProtocol],class:"cm-mw-free-extlink-protocol"},{tag:e.tokenTable[this.tags.htmlEntity],class:"cm-mw-html-entity"},{tag:e.tokenTable[this.tags.linkPageName],class:"cm-mw-link-pagename"},{tag:e.tokenTable[this.tags.nowiki],class:"cm-mw-tag-nowiki"},{tag:e.tokenTable[this.tags.pageName],class:"cm-mw-pagename"},{tag:e.tokenTable[this.tags.pre],class:"cm-mw-tag-pre"},{tag:e.tokenTable[this.tags.section],class:"cm-mw-section"},{tag:e.tokenTable[this.tags.skipFormatting],class:"cm-mw-skipformatting"},{tag:e.tokenTable[this.tags.strong],class:"cm-mw-strong"},{tag:e.tokenTable[this.tags.tableCaption],class:"cm-mw-table-caption"},{tag:e.tokenTable[this.tags.templateVariableDelimiter],class:"cm-mw-templatevariable-delimiter"}].concat(t._toConsumableArray(this.extHighlightStyles))}}])}()),n=function(t){return t.name.split("_").includes(i.tags.templateBracket)},s=function(t){return t.name.split("_").includes(i.tags.templateDelimiter)},r=function(t){return/\x2Dtemplate[\x2D0-9a-z]+ground/.test(t.name)&&!n(t)},o=function(t,e){return"{"===t.sliceDoc(e.from,e.from+1)?1:-1},l=function(e,a,i){if("number"==typeof a&&(i=t.ensureSyntaxTree(e,a)),!i)return null;var l;if("number"==typeof a?(l=i.resolve(a,-1),r(l)||(l=i.resolve(a,1))):l=a,!r(l))return null;for(var c=l,m=c.prevSibling,g=c.nextSibling,k=1,u=s(l)?l:null;g;){if(n(g)){if(0===(k+=o(e,g)))break}else!u&&1===k&&s(g)&&(u=g);g=g.nextSibling}if(!g)return null;for(k=-1;m;){if(n(m)){if(0===(k+=o(e,m)))break}else-1===k&&s(m)&&(u=m);m=m.prevSibling}var h=u&&u.to,p=g.from;return h&&h0){var f=e.dom.querySelector(".cm-tooltip-fold");return f&&f.remove(),e.dispatch({effects:s,selection:{anchor:c}}),!0}return!1}},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:function(e){var a,i=e.state,n=i.selection,s=[],r=t.foldedRanges(i),o=t._createForOfIteratorHelper(n.ranges);try{for(o.s();!(a=o.n()).done;){var l=a.value,c=l.from,m=l.to;r.between(c,m,(function(e,a){s.push(t.unfoldEffect.of({from:e,to:a}))}))}}catch(t){o.e(t)}finally{o.f()}return s.length>0&&(e.dispatch({effects:s,selection:n}),!0)}},{key:"Ctrl-Alt-]",run:t.unfoldAll}],g=[t.codeFolding({placeholderDOM:function(e){var a=document.createElement("span");return a.textContent="…",a.setAttribute("aria-label",mw.msg("codemirror-folded-code")),a.title=mw.msg("codemirror-unfold"),a.className="cm-foldPlaceholder",a.onclick=function(a){var i=a.target,n=e.posAtDOM(i),s=e.state,r=s.selection;t.foldedRanges(s).between(n,n,(function(a,i){a===n&&e.dispatch({effects:t.unfoldEffect.of({from:a,to:i}),selection:r})}))},a}}),t.StateField.define({create:c,update:function(t,e){var a=e.state,i=e.docChanged,n=e.selection;return i||n?c(a):t},provide:function(e){return t.showTooltip.from(e)}}),t.keymap.of(m)],k=t.Decoration.mark({class:"cm-bidi-isolate",bidiIsolate:t.Direction.LTR});function u(e){var a,n=new t.RangeSetBuilder,s=t._createForOfIteratorHelper(e.visibleRanges);try{var r=function(){var s,r=a.value,o=r.from,l=r.to;t.syntaxTree(e.state).iterate({from:o,to:l,enter:function(t){var e=t.name.split("_").some((function(t){return[i.tags.htmlTagBracket,i.tags.extTagBracket].includes(t)}));!s&&e?s=t.from:e&&(n.add(s,t.to,k),s=null)}})};for(s.s();!(a=s.n()).done;)r()}catch(t){s.e(t)}finally{s.f()}return n.finish()}var h=function(){return t._createClass((function e(a){t._classCallCheck(this,e),this.isolates=u(a),this.tree=t.syntaxTree(a.state)}),[{key:"update",value:function(e){(e.docChanged||e.viewportChanged||t.syntaxTree(e.state)!==this.tree)&&(this.isolates=u(e.view),this.tree=t.syntaxTree(e.state))}}])}(),p={provide:function(e){var a=function(a){return a.plugin(e)&&a.plugin(e).isolates||t.Decoration.none};return t.Prec.lowest([t.EditorView.decorations.of(a),t.EditorView.bidiIsolatedRanges.of(a)])}},f=t.ViewPlugin.fromClass(h,p),d=function(){return t._createClass((function e(a){t._classCallCheck(this,e),this.config=a,this.urlProtocols=new RegExp("^(?:".concat(this.config.urlProtocols,")(?=[^\\s {[\\]<>~).,'])"),"i"),this.isBold=!1,this.wasBold=!1,this.isItalic=!1,this.wasItalic=!1,this.firstSingleLetterWord=null,this.firstMultiLetterWord=null,this.firstSpace=null,this.oldStyle=null,this.tokens=[],this.oldTokens=[],this.tokenTable=i.tokenTable,this.registerGroundTokens(),Object.keys(this.config.tags).forEach((function(t){return i.addTag(t)}))}),[{key:"registerGroundTokens",value:function(){["mw-ext-ground","mw-ext-link-ground","mw-ext2-ground","mw-ext2-link-ground","mw-ext3-ground","mw-ext3-link-ground","mw-link-ground","mw-template-ext-ground","mw-template-ext-link-ground","mw-template-ext2-ground","mw-template-ext2-link-ground","mw-template-ext3-ground","mw-template-ext3-link-ground","mw-template-ground","mw-template-link-ground","mw-template2-ext-ground","mw-template2-ext-link-ground","mw-template2-ext2-ground","mw-template2-ext2-link-ground","mw-template2-ext3-ground","mw-template2-ext3-link-ground","mw-template2-ground","mw-template2-link-ground","mw-template3-ext-ground","mw-template3-ext-link-ground","mw-template3-ext2-ground","mw-template3-ext2-link-ground","mw-template3-ext3-ground","mw-template3-ext3-link-ground","mw-template3-ground","mw-template3-link-ground"].forEach((function(t){return i.addToken(t)}))}},{key:"eatHtmlEntity",value:function(t,e){return(t.eat("#")?t.eat("x")?t.eatWhile(/[a-fA-F\d]/)&&t.eat(";"):t.eatWhile(/[\d]/)&&t.eat(";"):t.eatWhile(/[\w.\-:]/)&&t.eat(";"))?i.tags.htmlEntity:e}},{key:"makeStyle",value:function(t,e,a){return this.isBold&&(t+=" "+i.tags.strong),this.isItalic&&(t+=" "+i.tags.em),this.makeLocalStyle(t,e,a)}},{key:"makeLocalStyle",value:function(t,e,a){var i="";switch(e.nTemplate){case 0:break;case 1:i+="-template";break;case 2:i+="-template2";break;default:i+="-template3"}switch(e.nExt){case 0:break;case 1:i+="-ext";break;case 2:i+="-ext2";break;default:i+="-ext3"}return e.nLink>0&&(i+="-link"),""!==i&&(t="mw".concat(i,"-ground ").concat(t)),a&&e[a]--,t.trim()}},{key:"eatBlock",value:function(t,e,a){var i=this;return function(n,s){return n.skipTo(e)?(!1!==a&&n.match(e),s.tokenize=s.stack.pop()):n.skipToEnd(),i.makeLocalStyle(t,s)}}},{key:"eatEnd",value:function(t){var e=this;return function(a,i){return a.skipToEnd(),i.tokenize=i.stack.pop(),e.makeLocalStyle(t,i)}}},{key:"eatChar",value:function(t,e){var a=this;return function(n,s){return s.tokenize=s.stack.pop(),n.eat(t)?a.makeLocalStyle(e,s):a.makeLocalStyle(i.tags.error,s)}}},{key:"eatSectionHeader",value:function(t){var e=this;return function(a,n){return a.match(/^[^&<[{~]+/)?(a.eol()?(a.backUp(t),n.tokenize=e.eatEnd(i.tags.sectionHeader)):a.match(/^.*?=)/,!1)&&(a.backUp(t),n.tokenize=e.eatBlock(i.tags.sectionHeader,"\x3c!--",!1)),i.tags.section):e.eatWikiText(i.tags.section)(a,n)}}},{key:"inVariable",value:function(t,e){return t.match(/^[^{}|]+/)?this.makeLocalStyle(i.tags.templateVariableName,e):t.eat("|")?(e.tokenize=this.inVariableDefault.bind(this),this.makeLocalStyle(i.tags.templateVariableDelimiter,e)):t.match("}}}")?(e.tokenize=e.stack.pop(),this.makeLocalStyle(i.tags.templateVariableBracket,e)):t.match("{{{")?(e.stack.push(e.tokenize),this.makeLocalStyle(i.tags.templateVariableBracket,e)):(t.next(),this.makeLocalStyle(i.tags.templateVariableName,e))}},{key:"inVariableDefault",value:function(t,e){return t.match(/^[^{}[<&~]+/)?this.makeLocalStyle(i.tags.templateVariable,e):t.match("}}}")?(e.tokenize=e.stack.pop(),this.makeLocalStyle(i.tags.templateVariableBracket,e)):this.eatWikiText(i.tags.templateVariable)(t,e)}},{key:"inParserFunctionName",value:function(t,e){return t.match(/^#?[^:}{~]+/)?this.makeLocalStyle(i.tags.parserFunctionName,e):t.eat(":")?(e.tokenize=this.inParserFunctionArguments.bind(this),this.makeLocalStyle(i.tags.parserFunctionDelimiter,e)):t.match("}}")?(e.tokenize=e.stack.pop(),this.makeLocalStyle(i.tags.parserFunctionBracket,e,"nExt")):this.eatWikiText(i.tags.parserFunction)(t,e)}},{key:"inParserFunctionArguments",value:function(t,e){return t.match(/^[^|}{[<&~]+/)?this.makeLocalStyle(i.tags.parserFunction,e):t.eat("|")?this.makeLocalStyle(i.tags.parserFunctionDelimiter,e):t.match("}}")?(e.tokenize=e.stack.pop(),this.makeLocalStyle(i.tags.parserFunctionBracket,e,"nExt")):this.eatWikiText(i.tags.parserFunction)(t,e)}},{key:"eatTemplatePageName",value:function(t){var e=this;return function(a,n){return a.match(/^[\s\u00a0]*\|[\s\u00a0]*/)?(n.tokenize=e.eatTemplateArgument(!0),e.makeLocalStyle(i.tags.templateDelimiter,n)):a.match(/^[\s\u00a0]*\}\}/)?(n.tokenize=n.stack.pop(),e.makeLocalStyle(i.tags.templateBracket,n,"nTemplate")):a.match(/^[\s\u00a0]*/)?e.makeLocalStyle(i.tags.comment,n):t&&a.sol()?(n.nTemplate--,void(n.tokenize=n.stack.pop())):a.match(/^[\s\u00a0]*[^\s\u00a0|}<{&~]+/)?(n.tokenize=e.eatTemplatePageName(!0),e.makeLocalStyle(i.tags.templateName,n)):a.eatSpace()?(a.eol(),e.makeLocalStyle(i.tags.templateName,n)):e.eatWikiText(i.tags.templateName)(a,n)}}},{key:"eatTemplateArgument",value:function(t){var e=this;return function(a,n){return t&&a.eatWhile(/[^=|}{[<&~]/)?a.eat("=")?(n.tokenize=e.eatTemplateArgument(!1),e.makeLocalStyle(i.tags.templateArgumentName,n)):e.makeLocalStyle(i.tags.template,n):a.eatWhile(/[^|}{[<&~]/)?e.makeLocalStyle(i.tags.template,n):a.eat("|")?(n.tokenize=e.eatTemplateArgument(!0),e.makeLocalStyle(i.tags.templateDelimiter,n)):a.match("}}")?(n.tokenize=n.stack.pop(),e.makeLocalStyle(i.tags.templateBracket,n,"nTemplate")):e.eatWikiText(i.tags.template)(a,n)}}},{key:"eatExternalLinkProtocol",value:function(t){var e=this;return function(a,n){for(;t>0;)t--,a.next();return a.eol()?(n.nLink--,n.tokenize=n.stack.pop()):n.tokenize=e.inExternalLink.bind(e),e.makeLocalStyle(i.tags.extLinkProtocol,n)}}},{key:"inExternalLink",value:function(t,e){return t.sol()?(e.nLink--,void(e.tokenize=e.stack.pop())):t.match(/^[\s\u00a0]*\]/)?(e.tokenize=e.stack.pop(),this.makeLocalStyle(i.tags.extLinkBracket,e,"nLink")):t.eatSpace()?(e.tokenize=this.inExternalLinkText.bind(this),this.makeStyle("",e)):t.match(/^[^\s\u00a0\]{&~']+/)||t.eatSpace()?("'"===t.peek()&&(t.match("''",!1)?e.tokenize=this.inExternalLinkText.bind(this):t.next()),this.makeStyle(i.tags.extLink,e)):this.eatWikiText(i.tags.extLink)(t,e)}},{key:"inExternalLinkText",value:function(t,e){return t.sol()?(e.nLink--,void(e.tokenize=e.stack.pop())):t.eat("]")?(e.tokenize=e.stack.pop(),this.makeLocalStyle(i.tags.extLinkBracket,e,"nLink")):t.match(/^[^'\]{&~<]+/)?this.makeStyle(i.tags.extLinkText,e):this.eatWikiText(i.tags.extLinkText)(t,e)}},{key:"inLink",value:function(t,e){return t.sol()?(e.nLink--,void(e.tokenize=e.stack.pop())):t.match(/^[\s\u00a0]*#[\s\u00a0]*/)?(e.tokenize=this.inLinkToSection.bind(this),this.makeLocalStyle(i.tags.link,e)):t.match(/^[\s\u00a0]*\|[\s\u00a0]*/)?(e.tokenize=this.eatLinkText(),this.makeLocalStyle(i.tags.linkDelimiter,e)):t.match(/^[\s\u00a0]*\]\]/)?(e.tokenize=e.stack.pop(),this.makeLocalStyle(i.tags.linkBracket,e,"nLink")):t.match(/^[\s\u00a0]*[^\s\u00a0#|\]&~{]+/)||t.eatSpace()?this.makeStyle("".concat(i.tags.linkPageName," ").concat(i.tags.pageName),e):this.eatWikiText("".concat(i.tags.linkPageName," ").concat(i.tags.pageName))(t,e)}},{key:"inLinkToSection",value:function(t,e){return t.sol()?(e.nLink--,void(e.tokenize=e.stack.pop())):t.match(/^[^|\]&~{}]+/)?this.makeLocalStyle(i.tags.linkToSection,e):t.eat("|")?(e.tokenize=this.eatLinkText(),this.makeLocalStyle(i.tags.linkDelimiter,e)):t.match("]]")?(e.tokenize=e.stack.pop(),this.makeLocalStyle(i.tags.linkBracket,e,"nLink")):this.eatWikiText(i.tags.linkToSection)(t,e)}},{key:"eatLinkText",value:function(){var t,e,a=this;return function(n,s){var r;return n.match("]]")?(s.tokenize=s.stack.pop(),a.makeLocalStyle(i.tags.linkBracket,s,"nLink")):n.match("'''")?(t=!t,a.makeLocalStyle("".concat(i.tags.linkText," ").concat(i.tags.apostrophes),s)):n.match("''")?(e=!e,a.makeLocalStyle("".concat(i.tags.linkText," ").concat(i.tags.apostrophes),s)):(r=i.tags.linkText,t&&(r+=" "+i.tags.strong),e&&(r+=" "+i.tags.em),n.match(/^[^'\]{&~<]+/)?a.makeStyle(r,s):a.eatWikiText(r)(n,s))}}},{key:"eatTagName",value:function(t,e,a){var n=this;return function(s,r){for(var o="";t>0;)t--,o+=s.next();return s.eatSpace(),o=o.toLowerCase(),a?(e&&!i.implicitlyClosedHtmlTags[o]?r.tokenize=n.eatChar(">",i.tags.htmlTagBracket):r.tokenize=n.eatHtmlTagAttribute(o),n.makeLocalStyle(i.tags.htmlTagName,r)):(r.tokenize=e?n.eatChar(">","".concat(i.tags.extTagBracket," mw-ext-").concat(o)):n.eatExtTagAttribute(o),n.makeLocalStyle("".concat(i.tags.extTagName," mw-ext-").concat(o),r))}}},{key:"eatHtmlTagAttribute",value:function(t){var e=this;return function(a,n){return a.match(/^(?:"[^<">]*"|'[^<'>]*'|[^>/<{&~])+/)?e.makeLocalStyle(i.tags.htmlTagAttribute,n):a.eat(">")?(t in i.implicitlyClosedHtmlTags||n.inHtmlTag.push(t),n.tokenize=n.stack.pop(),e.makeLocalStyle(i.tags.htmlTagBracket,n)):a.match("/>")?(n.tokenize=n.stack.pop(),e.makeLocalStyle(i.tags.htmlTagBracket,n)):e.eatWikiText(i.tags.htmlTagAttribute)(a,n)}}},{key:"eatNowiki",value:function(){var t=this;return function(e){return e.match(/^[^&]+/)?"":(e.next(),t.eatHtmlEntity(e,""))}}},{key:"eatExtTagAttribute",value:function(t){var e=this;return function(a,n){if(a.match(/^(?:"[^">]*"|'[^'>]*'|[^>/<{&~])+/))return e.makeLocalStyle("".concat(i.tags.extTagAttribute," mw-ext-").concat(t),n);if(a.eat(">")){if(n.extName=t,"nowiki"===t||"pre"===t)n.extMode={startState:function(){},copyState:function(){},token:e.eatNowiki()};else if(t in e.config.tagModes){var s=e.config.tagModes[t];"mediawiki"!==s&&"text/mediawiki"!==s||(n.extMode=e.mediawiki,n.extState=n.extMode.startState())}return n.tokenize=e.eatExtTagArea(t),e.makeLocalStyle("".concat(i.tags.extTagBracket," mw-ext-").concat(t),n)}return a.match("/>")?(n.tokenize=n.stack.pop(),e.makeLocalStyle("".concat(i.tags.extTagBracket," mw-ext-").concat(t),n)):e.eatWikiText("".concat(i.tags.extTagAttribute," mw-ext-").concat(t))(a,n)}}},{key:"eatExtTagArea",value:function(t){var e=this;return function(a,i){var n,s=a.pos,r=new RegExp(""),"i").exec(s?a.string.slice(s):a.string),o=!1;if(r){if(0===r.index)return i.tokenize=e.eatExtCloseTag(t),i.extName=!1,!1!==i.extMode&&(i.extMode=!1,i.extState=!1),i.tokenize(a,i);n=r.index+s,o=a.string,a.string=o.slice(0,n)}return i.stack.push(i.tokenize),i.tokenize=e.eatExtTokens(o),i.tokenize(a,i)}}},{key:"eatExtCloseTag",value:function(t){var e=this;return function(a,n){return a.next(),a.next(),n.tokenize=e.eatTagName(t.length,!0,!1),e.makeLocalStyle("".concat(i.tags.extTagBracket," mw-ext-").concat(t),n)}}},{key:"eatExtTokens",value:function(t){var e=this;return function(a,n){var s;return!1===n.extMode?(s=i.tags.extTag,a.skipToEnd()):s="mw-tag-".concat(n.extName," ")+n.extMode.token(a,n.extState,!1===t),a.eol()&&(!1!==t&&(a.string=t),n.tokenize=n.stack.pop()),e.makeLocalStyle(s,n)}}},{key:"eatStartTable",value:function(t,e){return t.match("{|"),t.eatSpace(),e.tokenize=this.inTableDefinition.bind(this),i.tags.tableBracket}},{key:"inTableDefinition",value:function(t,e){return t.sol()?(e.tokenize=this.inTable.bind(this),this.inTable(t,e)):this.eatWikiText(i.tags.tableDefinition)(t,e)}},{key:"inTable",value:function(t,e){if(t.sol()){if(t.eatSpace(),t.eat("|"))return t.eat("-")?(t.eatSpace(),e.tokenize=this.inTableDefinition.bind(this),this.makeLocalStyle(i.tags.tableDelimiter,e)):t.eat("+")?(t.eatSpace(),e.tokenize=this.eatTableRow(!0,!1,!0),this.makeLocalStyle(i.tags.tableDelimiter,e)):t.eat("}")?(e.tokenize=e.stack.pop(),this.makeLocalStyle(i.tags.tableBracket,e)):(t.eatSpace(),e.tokenize=this.eatTableRow(!0,!1),this.makeLocalStyle(i.tags.tableDelimiter,e));if(t.eat("!"))return t.eatSpace(),e.tokenize=this.eatTableRow(!0,!0),this.makeLocalStyle(i.tags.tableDelimiter,e)}return this.eatWikiText("")(t,e)}},{key:"eatTableRow",value:function(t,e,a){var n=this,s="";return a?s=i.tags.tableCaption:e&&(s=i.tags.strong),function(r,o){if(r.sol()){if(r.match(/^[\s\u00a0]*[|!]/,!1))return o.tokenize=n.inTable.bind(n),n.inTable(r,o)}else{if(r.match(/^[^'|{[<&~!]+/))return n.makeStyle(s,o);if(r.match("||")||e&&r.match("!!"))return n.isBold=!1,n.isItalic=!1,o.tokenize=n.eatTableRow(!0,e,a),n.makeLocalStyle(i.tags.tableDelimiter,o);if(t&&r.eat("|"))return o.tokenize=n.eatTableRow(!1,e,a),n.makeLocalStyle(i.tags.tableDelimiter,o)}return n.eatWikiText(s)(r,o)}}},{key:"eatFreeExternalLinkProtocol",value:function(t,e){return t.match(this.urlProtocols),e.tokenize=this.eatFreeExternalLink.bind(this),this.makeLocalStyle(i.tags.freeExtLinkProtocol,e)}},{key:"eatFreeExternalLink",value:function(t,e){if(t.eol());else if(t.match(/^[^\s\u00a0{[\]<>~).,']*/))if("~"===t.peek()){if(!t.match(/^~~~+/,!1))return t.match(/^~*/),this.makeLocalStyle(i.tags.freeExtLink,e)}else if("{"===t.peek()){if(!t.match("{{",!1))return t.next(),this.makeLocalStyle(i.tags.freeExtLink,e)}else if("'"===t.peek()){if(!t.match("''",!1))return t.next(),this.makeLocalStyle(i.tags.freeExtLink,e)}else if(t.match(/^[).,]+(?=[^\s\u00a0{[\]<>~).,])/))return this.makeLocalStyle(i.tags.freeExtLink,e);return e.tokenize=e.stack.pop(),this.makeLocalStyle(i.tags.freeExtLink,e)}},{key:"eatWikiText",value:function(t){var e=this;return function(a,n){var s,r,o,l,c,m,g;if(a.sol()){if(!a.match("//",!1)&&a.match(e.urlProtocols))return n.stack.push(n.tokenize),n.tokenize=e.eatFreeExternalLink.bind(e),e.makeLocalStyle(i.tags.freeExtLinkProtocol,n);switch(s=a.next()){case"-":if(a.match(/^---+/))return i.tags.hr;break;case"=":if(r=a.match(/^(={0,5})(.+?(=\1\s*)(.*\S).*?)?)$/))return a.backUp(r[2].length),n.stack.push(n.tokenize),n.tokenize=e.eatSectionHeader(r[3].length),i.tags.sectionHeader+" "+i.tags["sectionHeader".concat(r[1].length+1)];break;case"*":case"#":case";":return a.match(/^[*#;:]*/),i.tags.list;case":":return a.match(/^:*{\|/,!1)&&(n.stack.push(n.tokenize),n.tokenize=e.eatStartTable.bind(e)),a.match(/^[*#;:]*/),i.tags.indenting;case" ":if(!a.match(/^[\s\u00a0]*:*{\|/,!1))return i.tags.skipFormatting;if(a.eatSpace(),a.match(/^:+/))return n.stack.push(n.tokenize),n.tokenize=e.eatStartTable.bind(e),i.tags.indenting;a.eat("{");case"{":if(a.eat("|"))return a.eatSpace(),n.stack.push(n.tokenize),n.tokenize=e.inTableDefinition.bind(e),i.tags.tableBracket}}else s=a.next();switch(s){case"&":return e.makeStyle(e.eatHtmlEntity(a,t),n);case"'":if(a.match(/^'*(?=''''')/)||a.match(/^'''(?!')/,!1))break;if(a.match("''"))return e.firstSingleLetterWord||a.match("''",!1)||e.prepareItalicForCorrection(a),e.isBold=!e.isBold,e.makeLocalStyle(i.tags.apostrophesBold,n);if(a.eat("'"))return e.isItalic=!e.isItalic,e.makeLocalStyle(i.tags.apostrophesItalic,n);break;case"[":if(a.eat("[")){if(a.eatSpace(),/[^\]|[]/.test(a.peek()))return n.nLink++,n.stack.push(n.tokenize),n.tokenize=e.inLink.bind(e),e.makeLocalStyle(i.tags.linkBracket,n)}else if(o=a.match(e.urlProtocols))return n.nLink++,a.backUp(o[0].length),n.stack.push(n.tokenize),n.tokenize=e.eatExternalLinkProtocol(o[0].length),e.makeLocalStyle(i.tags.extLinkBracket,n);break;case"{":if(a.match(/^{{(?!{|[^{}]*}}(?!}))/))return a.eatSpace(),n.stack.push(n.tokenize),n.tokenize=e.inVariable.bind(e),e.makeLocalStyle(i.tags.templateVariableBracket,n);if(a.match(/^{(?!{(?!{))[\s\u00a0]*/))return"#"===a.peek()?(n.nExt++,n.stack.push(n.tokenize),n.tokenize=e.inParserFunctionName.bind(e),e.makeLocalStyle(i.tags.parserFunctionBracket,n)):!(l=a.match(/^([^\s\u00a0}[\]<{'|&:]+)(:|[\s\u00a0]*)(\}\}?)?(.)?/))||(a.backUp(l[0].length),":"!==l[2]&&void 0!==l[4]&&"}}"!==l[3]||!(l[1].toLowerCase()in e.config.functionSynonyms[0])&&!(l[1]in e.config.functionSynonyms[1]))?(n.nTemplate++,n.stack.push(n.tokenize),n.tokenize=e.eatTemplatePageName(!1),e.makeLocalStyle(i.tags.templateBracket,n)):(n.nExt++,n.stack.push(n.tokenize),n.tokenize=e.inParserFunctionName.bind(e),e.makeLocalStyle(i.tags.parserFunctionBracket,n));break;case"<":if(c=!!a.eat("/"),m=a.match(/^[^>/\s\u00a0.*,[\]{}$^+?|/\\'`~<=!@#%&()-]+[^>/\s\u00a0.*,[\]{}$^+?|/\\'`~<=!@#%&()]*/),a.match("!--"))return g=e.eatBlock(i.tags.comment,"--\x3e"),n.stack.push(n.tokenize),n.tokenize=g,g(a,n);if(m){if((m=m[0].toLowerCase())in e.config.tags)return!0===c?i.tags.error:(a.backUp(m.length),n.stack.push(n.tokenize),n.tokenize=e.eatTagName(m.length,c,!1),e.makeLocalStyle("".concat(i.tags.extTagBracket," mw-ext-").concat(m),n));if(m in i.permittedHtmlTags)return!0===c&&m!==n.inHtmlTag.pop()?(a.pos++,i.tags.error):!0===c&&m in i.implicitlyClosedHtmlTags?i.tags.error:(a.backUp(m.length),n.stack.push(n.tokenize),n.tokenize=e.eatTagName(m.length,c||m in i.implicitlyClosedHtmlTags,!0),e.makeLocalStyle(i.tags.htmlTagBracket,n));a.backUp(m.length)}break;case"~":if(a.match(/^~{2,4}/))return i.tags.signature;break;case"_":for(r=1;a.eat("_");)r++;if(r>2)return a.eol()||a.backUp(2),e.makeStyle(t,n);if(2===r&&(l=a.match(/^([^\s\u00a0>}[\]<{'|&:~]+?)__/))&&l[0])return"__"+l[0].toLowerCase()in e.config.doubleUnderscore[0]||"__"+l[0]in e.config.doubleUnderscore[1]?i.tags.doubleUnderscore:(a.eol()||a.backUp(2),e.makeStyle(t,n));break;default:if(/[\s\u00a0]/.test(s)&&(a.eatSpace(),a.match(e.urlProtocols,!1)&&!a.match("//")))return n.stack.push(n.tokenize),n.tokenize=e.eatFreeExternalLinkProtocol.bind(e),e.makeStyle(t,n)}return a.match(/^[^\s\u00a0_>}[\]<{'|&:~=]+/),e.makeStyle(t,n)}}},{key:"prepareItalicForCorrection",value:function(t){var e=t.pos,a=t.string.slice(0,e-3),i=a.slice(-1),n=a.slice(-2,-1);if(" "===i){if(this.firstMultiLetterWord||this.firstSpace)return;this.firstSpace=e}else if(" "===n)this.firstSingleLetterWord=e;else{if(this.firstMultiLetterWord)return;this.firstMultiLetterWord=e}this.wasBold=this.isBold,this.wasItalic=this.isItalic}},{key:"mediawiki",get:function(){var t=this;return{name:"mediawiki",startState:function(){return{tokenize:t.eatWikiText(""),stack:[],inHtmlTag:[],extName:!1,extMode:!1,extState:!1,nTemplate:0,nLink:0,nExt:0}},copyState:function(t){return{tokenize:t.tokenize,stack:t.stack.concat([]),inHtmlTag:t.inHtmlTag.concat([]),extName:t.extName,extMode:t.extMode,extState:!1!==t.extMode&&t.extMode.copyState(t.extState),nTemplate:t.nTemplate,nLink:t.nLink,nExt:t.nExt}},token:function(e,a){var i,n,s,r,o=[],l=[];if(t.oldTokens.length>0)return s=t.oldTokens.shift(),e.pos=s.pos,a=s.state,s.style;e.sol()&&(t.isBold=!1,t.isItalic=!1,t.firstSingleLetterWord=null,t.firstMultiLetterWord=null,t.firstSpace=null);do{if(i=a.tokenize(e,a),!(r=t.firstSingleLetterWord||t.firstMultiLetterWord||t.firstSpace))return t.oldStyle=i,i;r!==n&&(n=r,l.length>0&&(o=o.concat(l),l=[])),l.push({pos:e.pos,style:i,state:(a.extMode||t.mediawiki).copyState(a)})}while(!e.eol());if(t.isBold&&t.isItalic){if(t.isItalic=t.wasItalic,t.isBold=t.wasBold,t.firstSingleLetterWord=null,t.firstMultiLetterWord=null,t.firstSpace=null,!(o.length>0))return e.pos=l[0].pos-2,t.oldStyle;o[o.length-1].pos++,t.oldTokens=o}else t.oldTokens=o.concat(l);return s=t.oldTokens.shift(),e.pos=s.pos,a=s.state,s.style},blankLine:function(t){t.extMode&&t.extMode.blankLine&&t.extMode.blankLine(t.extState)},tokenTable:this.tokenTable}}}])}();module.exports=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{bidiIsolation:!1},a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;a=a||mw.config.get("extCodeMirrorConfig");var n=new d(a).mediawiki,s=t.StreamLanguage.define(n),r=[t.syntaxHighlighting(t.HighlightStyle.define(i.getTagStyles(n)))],o=a.templateFoldingNamespaces;return!mw.config.get("wgCodeMirrorV6TemplateFolding")||o&&!o.includes(mw.config.get("wgNamespaceNumber"))||r.push(g),e.bidiIsolation&&r.push(f),new t.LanguageSupport(s,r)}; +"use strict";var t=require("ext.CodeMirror.v6.lib"),e=new WeakSet;function a(t){return{em:"mw-em",error:"mw-error",extNowiki:"mw-ext-nowiki",extPre:"mw-ext-pre",extTag:"mw-exttag",extTagAttribute:"mw-exttag-attribute",extTagBracket:"mw-exttag-bracket",extTagName:"mw-exttag-name",freeExtLink:"mw-free-extlink",freeExtLinkProtocol:"mw-free-extlink-protocol",htmlEntity:"mw-html-entity",link:"mw-link",linkPageName:"mw-link-pagename",nowiki:"mw-tag-nowiki",pageName:"mw-pagename",pre:"mw-tag-pre",section:"mw-section",skipFormatting:"mw-skipformatting",strong:"mw-strong",tableCaption:"mw-table-caption",templateVariableDelimiter:"mw-templatevariable-delimiter"}}const i=new class{constructor(){t._classPrivateMethodInitSpec(this,e),this.extHighlightStyles=[],this.tokenTable=this.defaultTokenTable}addTag(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this.tokenTable[`mw-tag-${t}`]||(this.addToken(`mw-tag-${t}`,e),this.addToken(`mw-ext-${t}`,e))}addToken(e){let a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this.tokenTable[e]||(this.tokenTable[e]=t.Tag.define(a),this.extHighlightStyles.push({tag:this.tokenTable[e],class:`cm-${e}`}))}get permittedHtmlTags(){return{b:!0,bdi:!0,del:!0,i:!0,ins:!0,u:!0,font:!0,big:!0,small:!0,sub:!0,sup:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,cite:!0,code:!0,em:!0,s:!0,strike:!0,strong:!0,tt:!0,var:!0,div:!0,center:!0,blockquote:!0,q:!0,ol:!0,ul:!0,dl:!0,table:!0,caption:!0,pre:!0,ruby:!0,rb:!0,rp:!0,rt:!0,rtc:!0,p:!0,span:!0,abbr:!0,dfn:!0,kbd:!0,samp:!0,data:!0,time:!0,mark:!0,br:!0,wbr:!0,hr:!0,li:!0,dt:!0,dd:!0,td:!0,th:!0,tr:!0,noinclude:!0,includeonly:!0,onlyinclude:!0}}get implicitlyClosedHtmlTags(){return{br:!0,hr:!0,wbr:!0}}get tags(){return{apostrophes:"character",apostrophesBold:"strong",apostrophesItalic:"emphasis",comment:"comment",doubleUnderscore:"controlKeyword",extLink:"url",extLinkBracket:"modifier",extLinkProtocol:"namespace",extLinkText:"labelName",hr:"contentSeparator",htmlTagAttribute:"attributeName",htmlTagBracket:"angleBracket",htmlTagName:"tagName",indenting:"operatorKeyword",linkBracket:"squareBracket",linkDelimiter:"operator",linkText:"string",linkToSection:"className",list:"list",parserFunction:"unit",parserFunctionBracket:"paren",parserFunctionDelimiter:"punctuation",parserFunctionName:"keyword",sectionHeader:"heading",sectionHeader1:"heading1",sectionHeader2:"heading2",sectionHeader3:"heading3",sectionHeader4:"heading4",sectionHeader5:"heading5",sectionHeader6:"heading6",signature:"quote",tableBracket:"null",tableDefinition:"definitionOperator",tableDelimiter:"typeOperator",template:"attributeValue",templateArgumentName:"definitionKeyword",templateBracket:"bracket",templateDelimiter:"separator",templateName:"moduleKeyword",templateVariable:"atom",templateVariableBracket:"brace",templateVariableName:"variableName",...t._classPrivateGetter(e,this,a)}}get defaultTokenTable(){return{[this.tags.em]:t.Tag.define(),[this.tags.error]:t.Tag.define(),[this.tags.extNowiki]:t.Tag.define(),[this.tags.extPre]:t.Tag.define(),[this.tags.extTag]:t.Tag.define(),[this.tags.extTagAttribute]:t.Tag.define(),[this.tags.extTagBracket]:t.Tag.define(),[this.tags.extTagName]:t.Tag.define(),[this.tags.freeExtLink]:t.Tag.define(),[this.tags.freeExtLinkProtocol]:t.Tag.define(),[this.tags.htmlEntity]:t.Tag.define(),[this.tags.link]:t.Tag.define(),[this.tags.linkPageName]:t.Tag.define(),[this.tags.nowiki]:t.Tag.define(),[this.tags.pageName]:t.Tag.define(),[this.tags.pre]:t.Tag.define(),[this.tags.section]:t.Tag.define(),[this.tags.skipFormatting]:t.Tag.define(),[this.tags.strong]:t.Tag.define(),[this.tags.tableCaption]:t.Tag.define(),[this.tags.templateVariableDelimiter]:t.Tag.define()}}getTagStyles(e){return[{tag:t.tags[this.tags.apostrophes],class:"cm-mw-apostrophes"},{tag:t.tags[this.tags.apostrophesBold],class:"cm-mw-apostrophes-bold"},{tag:t.tags[this.tags.apostrophesItalic],class:"cm-mw-apostrophes-italic"},{tag:t.tags[this.tags.comment],class:"cm-mw-comment"},{tag:t.tags[this.tags.doubleUnderscore],class:"cm-mw-double-underscore"},{tag:t.tags[this.tags.extLink],class:"cm-mw-extlink"},{tag:t.tags[this.tags.extLinkBracket],class:"cm-mw-extlink-bracket"},{tag:t.tags[this.tags.extLinkProtocol],class:"cm-mw-extlink-protocol"},{tag:t.tags[this.tags.extLinkText],class:"cm-mw-extlink-text"},{tag:t.tags[this.tags.hr],class:"cm-mw-hr"},{tag:t.tags[this.tags.htmlTagAttribute],class:"cm-mw-htmltag-attribute"},{tag:t.tags[this.tags.htmlTagBracket],class:"cm-mw-htmltag-bracket"},{tag:t.tags[this.tags.htmlTagName],class:"cm-mw-htmltag-name"},{tag:t.tags[this.tags.indenting],class:"cm-mw-indenting"},{tag:t.tags[this.tags.linkBracket],class:"cm-mw-link-bracket"},{tag:t.tags[this.tags.linkDelimiter],class:"cm-mw-link-delimiter"},{tag:t.tags[this.tags.linkText],class:"cm-mw-link-text"},{tag:t.tags[this.tags.linkToSection],class:"cm-mw-link-tosection"},{tag:t.tags[this.tags.list],class:"cm-mw-list"},{tag:t.tags[this.tags.parserFunction],class:"cm-mw-parserfunction"},{tag:t.tags[this.tags.parserFunctionBracket],class:"cm-mw-parserfunction-bracket"},{tag:t.tags[this.tags.parserFunctionDelimiter],class:"cm-mw-parserfunction-delimiter"},{tag:t.tags[this.tags.parserFunctionName],class:"cm-mw-parserfunction-name"},{tag:t.tags[this.tags.sectionHeader],class:"cm-mw-section-header"},{tag:t.tags[this.tags.sectionHeader1],class:"cm-mw-section-1"},{tag:t.tags[this.tags.sectionHeader2],class:"cm-mw-section-2"},{tag:t.tags[this.tags.sectionHeader3],class:"cm-mw-section-3"},{tag:t.tags[this.tags.sectionHeader4],class:"cm-mw-section-4"},{tag:t.tags[this.tags.sectionHeader5],class:"cm-mw-section-5"},{tag:t.tags[this.tags.sectionHeader6],class:"cm-mw-section-6"},{tag:t.tags[this.tags.signature],class:"cm-mw-signature"},{tag:t.tags[this.tags.tableBracket],class:"cm-mw-table-bracket"},{tag:t.tags[this.tags.tableDefinition],class:"cm-mw-table-definition"},{tag:t.tags[this.tags.tableDelimiter],class:"cm-mw-table-delimiter"},{tag:t.tags[this.tags.template],class:"cm-mw-template"},{tag:t.tags[this.tags.templateArgumentName],class:"cm-mw-template-argument-name"},{tag:t.tags[this.tags.templateBracket],class:"cm-mw-template-bracket"},{tag:t.tags[this.tags.templateDelimiter],class:"cm-mw-template-delimiter"},{tag:t.tags[this.tags.templateName],class:"cm-mw-pagename cm-mw-template-name"},{tag:t.tags[this.tags.templateVariable],class:"cm-mw-templatevariable"},{tag:t.tags[this.tags.templateVariableBracket],class:"cm-mw-templatevariable-bracket"},{tag:t.tags[this.tags.templateVariableName],class:"cm-mw-templatevariable-name"},{tag:e.tokenTable[this.tags.em],class:"cm-mw-em"},{tag:e.tokenTable[this.tags.error],class:"cm-mw-error"},{tag:e.tokenTable[this.tags.extNowiki],class:"cm-mw-ext-nowiki"},{tag:e.tokenTable[this.tags.extPre],class:"cm-mw-ext-pre"},{tag:e.tokenTable[this.tags.extTagBracket],class:"cm-mw-exttag-bracket"},{tag:e.tokenTable[this.tags.extTag],class:"cm-mw-exttag"},{tag:e.tokenTable[this.tags.extTagAttribute],class:"cm-mw-exttag-attribute"},{tag:e.tokenTable[this.tags.extTagName],class:"cm-mw-exttag-name"},{tag:e.tokenTable[this.tags.freeExtLink],class:"cm-mw-free-extlink"},{tag:e.tokenTable[this.tags.freeExtLinkProtocol],class:"cm-mw-free-extlink-protocol"},{tag:e.tokenTable[this.tags.htmlEntity],class:"cm-mw-html-entity"},{tag:e.tokenTable[this.tags.linkPageName],class:"cm-mw-link-pagename"},{tag:e.tokenTable[this.tags.nowiki],class:"cm-mw-tag-nowiki"},{tag:e.tokenTable[this.tags.pageName],class:"cm-mw-pagename"},{tag:e.tokenTable[this.tags.pre],class:"cm-mw-tag-pre"},{tag:e.tokenTable[this.tags.section],class:"cm-mw-section"},{tag:e.tokenTable[this.tags.skipFormatting],class:"cm-mw-skipformatting"},{tag:e.tokenTable[this.tags.strong],class:"cm-mw-strong"},{tag:e.tokenTable[this.tags.tableCaption],class:"cm-mw-table-caption"},{tag:e.tokenTable[this.tags.templateVariableDelimiter],class:"cm-mw-templatevariable-delimiter"},...this.extHighlightStyles]}},s=t=>t.name.split("_").includes(i.tags.templateBracket),n=t=>t.name.split("_").includes(i.tags.templateDelimiter),l=t=>/-template[a-z\d-]+ground/u.test(t.name)&&!s(t),o=(t,e)=>"{"===t.sliceDoc(e.from,e.from+1)?1:-1,r=(e,a,i)=>{if("number"==typeof a&&(i=t.ensureSyntaxTree(e,a)),!i)return null;let r;if("number"==typeof a?(r=i.resolve(a,-1),l(r)||(r=i.resolve(a,1))):r=a,!l(r))return null;let{prevSibling:c,nextSibling:m}=r,g=1,h=n(r)?r:null;for(;m;){if(s(m)){if(g+=o(e,m),0===g)break}else!h&&1===g&&n(m)&&(h=m);({nextSibling:m}=m)}if(!m)return null;for(g=-1;c;){if(s(c)){if(g+=o(e,c),0===g)break}else-1===g&&n(c)&&(h=c);({prevSibling:c}=c)}const k=h&&h.to,p=m.from;return k&&k{const{selection:{main:{head:a}}}=e,i=r(e,a);if(i){const{from:s,to:n}=i;let l=!1;return t.foldedRanges(e).between(s,n,((t,e)=>{t===s&&e===n&&(l=!0)})),l?null:{pos:a,above:!0,create(e){const a=document.createElement("div");return a.className="cm-tooltip-fold",a.textContent="-",a.title=mw.msg("codemirror-fold-template"),a.onclick=()=>{e.dispatch({effects:t.foldEffect.of({from:s,to:n}),selection:{anchor:n}}),a.remove()},{dom:a}}}}return null},m=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run(e){const{state:a}=e,i=t.ensureSyntaxTree(a,e.viewport.to);if(!i)return!1;const s=[],{selection:{ranges:n}}=a;let o=Math.max(...n.map((t=>{let{to:e}=t;return e})));for(const{from:e,to:c}of n){let n;for(e===c&&(n=i.resolve(e,-1)),n&&l(n)||(n=i.resolve(e,1));n&&n.from<=c;){const e=r(a,n,i);e?(s.push(t.foldEffect.of(e)),n=i.resolve(e.to,1),o=Math.max(o,e.to)):n=n.nextSibling}}if(s.length>0){const t=e.dom.querySelector(".cm-tooltip-fold");return t&&t.remove(),e.dispatch({effects:s,selection:{anchor:o}}),!0}return!1}},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run(e){const{state:a}=e,{selection:i}=a,s=[],n=t.foldedRanges(a);for(const{from:e,to:a}of i.ranges)n.between(e,a,((e,a)=>{s.push(t.unfoldEffect.of({from:e,to:a}))}));return s.length>0&&(e.dispatch({effects:s,selection:i}),!0)}},{key:"Ctrl-Alt-]",run:t.unfoldAll}];var g=[t.codeFolding({placeholderDOM(e){const a=document.createElement("span");return a.textContent="…",a.setAttribute("aria-label",mw.msg("codemirror-folded-code")),a.title=mw.msg("codemirror-unfold"),a.className="cm-foldPlaceholder",a.onclick=a=>{let{target:i}=a;const s=e.posAtDOM(i),{state:n}=e,{selection:l}=n;t.foldedRanges(n).between(s,s,((a,i)=>{a===s&&e.dispatch({effects:t.unfoldEffect.of({from:a,to:i}),selection:l})}))},a}}),t.StateField.define({create:c,update(t,e){let{state:a,docChanged:i,selection:s}=e;return i||s?c(a):t},provide:e=>t.showTooltip.from(e)}),t.keymap.of(m)];const h=t.Decoration.mark({class:"cm-bidi-isolate",bidiIsolate:t.Direction.LTR});function k(e){const a=new t.RangeSetBuilder;for(const{from:s,to:n}of e.visibleRanges){let l;t.syntaxTree(e.state).iterate({from:s,to:n,enter(t){const e=t.name.split("_").some((t=>[i.tags.htmlTagBracket,i.tags.extTagBracket].includes(t)));!l&&e?l=t.from:e&&(a.add(l,t.to,h),l=null)}})}return a.finish()}const p={provide:e=>{const a=a=>a.plugin(e)&&a.plugin(e).isolates||t.Decoration.none;return t.Prec.lowest([t.EditorView.decorations.of(a),t.EditorView.bidiIsolatedRanges.of(a)])}};var u=t.ViewPlugin.fromClass(class{constructor(e){this.isolates=k(e),this.tree=t.syntaxTree(e.state)}update(e){(e.docChanged||e.viewportChanged||t.syntaxTree(e.state)!==this.tree)&&(this.isolates=k(e.view),this.tree=t.syntaxTree(e.state))}},p);class d{constructor(t){this.config=t,this.urlProtocols=new RegExp(`^(?:${this.config.urlProtocols})(?=[^\\s {[\\]<>~).,'])`,"i"),this.isBold=!1,this.wasBold=!1,this.isItalic=!1,this.wasItalic=!1,this.firstSingleLetterWord=null,this.firstMultiLetterWord=null,this.firstSpace=null,this.oldStyle=null,this.tokens=[],this.oldTokens=[],this.tokenTable=i.tokenTable,this.registerGroundTokens(),Object.keys(this.config.tags).forEach((t=>i.addTag(t)))}registerGroundTokens(){["mw-ext-ground","mw-ext-link-ground","mw-ext2-ground","mw-ext2-link-ground","mw-ext3-ground","mw-ext3-link-ground","mw-link-ground","mw-template-ext-ground","mw-template-ext-link-ground","mw-template-ext2-ground","mw-template-ext2-link-ground","mw-template-ext3-ground","mw-template-ext3-link-ground","mw-template-ground","mw-template-link-ground","mw-template2-ext-ground","mw-template2-ext-link-ground","mw-template2-ext2-ground","mw-template2-ext2-link-ground","mw-template2-ext3-ground","mw-template2-ext3-link-ground","mw-template2-ground","mw-template2-link-ground","mw-template3-ext-ground","mw-template3-ext-link-ground","mw-template3-ext2-ground","mw-template3-ext2-link-ground","mw-template3-ext3-ground","mw-template3-ext3-link-ground","mw-template3-ground","mw-template3-link-ground"].forEach((t=>i.addToken(t)))}eatHtmlEntity(t,e){let a;return a=t.eat("#")?t.eat("x")?t.eatWhile(/[a-fA-F\d]/)&&t.eat(";"):t.eatWhile(/[\d]/)&&t.eat(";"):t.eatWhile(/[\w.\-:]/)&&t.eat(";"),a?i.tags.htmlEntity:e}makeStyle(t,e,a){return this.isBold&&(t+=" "+i.tags.strong),this.isItalic&&(t+=" "+i.tags.em),this.makeLocalStyle(t,e,a)}makeLocalStyle(t,e,a){let i="";switch(e.nTemplate){case 0:break;case 1:i+="-template";break;case 2:i+="-template2";break;default:i+="-template3"}switch(e.nExt){case 0:break;case 1:i+="-ext";break;case 2:i+="-ext2";break;default:i+="-ext3"}return e.nLink>0&&(i+="-link"),""!==i&&(t=`mw${i}-ground ${t}`),a&&e[a]--,t.trim()}eatBlock(t,e,a){return(i,s)=>(i.skipTo(e)?(!1!==a&&i.match(e),s.tokenize=s.stack.pop()):i.skipToEnd(),this.makeLocalStyle(t,s))}eatEnd(t){return(e,a)=>(e.skipToEnd(),a.tokenize=a.stack.pop(),this.makeLocalStyle(t,a))}eatChar(t,e){return(a,s)=>(s.tokenize=s.stack.pop(),a.eat(t)?this.makeLocalStyle(e,s):this.makeLocalStyle(i.tags.error,s))}eatSectionHeader(t){return(e,a)=>e.match(/^[^&<[{~]+/)?(e.eol()?(e.backUp(t),a.tokenize=this.eatEnd(i.tags.sectionHeader)):e.match(/^.*?=)/,!1)&&(e.backUp(t),a.tokenize=this.eatBlock(i.tags.sectionHeader,"\x3c!--",!1)),i.tags.section):this.eatWikiText(i.tags.section)(e,a)}inVariable(t,e){return t.match(/^[^{}|]+/)?this.makeLocalStyle(i.tags.templateVariableName,e):t.eat("|")?(e.tokenize=this.inVariableDefault.bind(this),this.makeLocalStyle(i.tags.templateVariableDelimiter,e)):t.match("}}}")?(e.tokenize=e.stack.pop(),this.makeLocalStyle(i.tags.templateVariableBracket,e)):t.match("{{{")?(e.stack.push(e.tokenize),this.makeLocalStyle(i.tags.templateVariableBracket,e)):(t.next(),this.makeLocalStyle(i.tags.templateVariableName,e))}inVariableDefault(t,e){return t.match(/^[^{}[<&~]+/)?this.makeLocalStyle(i.tags.templateVariable,e):t.match("}}}")?(e.tokenize=e.stack.pop(),this.makeLocalStyle(i.tags.templateVariableBracket,e)):this.eatWikiText(i.tags.templateVariable)(t,e)}inParserFunctionName(t,e){return t.match(/^#?[^:}{~]+/)?this.makeLocalStyle(i.tags.parserFunctionName,e):t.eat(":")?(e.tokenize=this.inParserFunctionArguments.bind(this),this.makeLocalStyle(i.tags.parserFunctionDelimiter,e)):t.match("}}")?(e.tokenize=e.stack.pop(),this.makeLocalStyle(i.tags.parserFunctionBracket,e,"nExt")):this.eatWikiText(i.tags.parserFunction)(t,e)}inParserFunctionArguments(t,e){return t.match(/^[^|}{[<&~]+/)?this.makeLocalStyle(i.tags.parserFunction,e):t.eat("|")?this.makeLocalStyle(i.tags.parserFunctionDelimiter,e):t.match("}}")?(e.tokenize=e.stack.pop(),this.makeLocalStyle(i.tags.parserFunctionBracket,e,"nExt")):this.eatWikiText(i.tags.parserFunction)(t,e)}eatTemplatePageName(t){return(e,a)=>e.match(/^[\s\u00a0]*\|[\s\u00a0]*/)?(a.tokenize=this.eatTemplateArgument(!0),this.makeLocalStyle(i.tags.templateDelimiter,a)):e.match(/^[\s\u00a0]*\}\}/)?(a.tokenize=a.stack.pop(),this.makeLocalStyle(i.tags.templateBracket,a,"nTemplate")):e.match(/^[\s\u00a0]*/)?this.makeLocalStyle(i.tags.comment,a):t&&e.sol()?(a.nTemplate--,void(a.tokenize=a.stack.pop())):e.match(/^[\s\u00a0]*[^\s\u00a0|}<{&~]+/)?(a.tokenize=this.eatTemplatePageName(!0),this.makeLocalStyle(i.tags.templateName,a)):e.eatSpace()?(e.eol(),this.makeLocalStyle(i.tags.templateName,a)):this.eatWikiText(i.tags.templateName)(e,a)}eatTemplateArgument(t){return(e,a)=>t&&e.eatWhile(/[^=|}{[<&~]/)?e.eat("=")?(a.tokenize=this.eatTemplateArgument(!1),this.makeLocalStyle(i.tags.templateArgumentName,a)):this.makeLocalStyle(i.tags.template,a):e.eatWhile(/[^|}{[<&~]/)?this.makeLocalStyle(i.tags.template,a):e.eat("|")?(a.tokenize=this.eatTemplateArgument(!0),this.makeLocalStyle(i.tags.templateDelimiter,a)):e.match("}}")?(a.tokenize=a.stack.pop(),this.makeLocalStyle(i.tags.templateBracket,a,"nTemplate")):this.eatWikiText(i.tags.template)(e,a)}eatExternalLinkProtocol(t){return(e,a)=>{for(;t>0;)t--,e.next();return e.eol()?(a.nLink--,a.tokenize=a.stack.pop()):a.tokenize=this.inExternalLink.bind(this),this.makeLocalStyle(i.tags.extLinkProtocol,a)}}inExternalLink(t,e){return t.sol()?(e.nLink--,void(e.tokenize=e.stack.pop())):t.match(/^[\s\u00a0]*\]/)?(e.tokenize=e.stack.pop(),this.makeLocalStyle(i.tags.extLinkBracket,e,"nLink")):t.eatSpace()?(e.tokenize=this.inExternalLinkText.bind(this),this.makeStyle("",e)):t.match(/^[^\s\u00a0\]{&~']+/)||t.eatSpace()?("'"===t.peek()&&(t.match("''",!1)?e.tokenize=this.inExternalLinkText.bind(this):t.next()),this.makeStyle(i.tags.extLink,e)):this.eatWikiText(i.tags.extLink)(t,e)}inExternalLinkText(t,e){return t.sol()?(e.nLink--,void(e.tokenize=e.stack.pop())):t.eat("]")?(e.tokenize=e.stack.pop(),this.makeLocalStyle(i.tags.extLinkBracket,e,"nLink")):t.match(/^[^'\]{&~<]+/)?this.makeStyle(i.tags.extLinkText,e):this.eatWikiText(i.tags.extLinkText)(t,e)}inLink(t,e){return t.sol()?(e.nLink--,void(e.tokenize=e.stack.pop())):t.match(/^[\s\u00a0]*#[\s\u00a0]*/)?(e.tokenize=this.inLinkToSection.bind(this),this.makeLocalStyle(i.tags.link,e)):t.match(/^[\s\u00a0]*\|[\s\u00a0]*/)?(e.tokenize=this.eatLinkText(),this.makeLocalStyle(i.tags.linkDelimiter,e)):t.match(/^[\s\u00a0]*\]\]/)?(e.tokenize=e.stack.pop(),this.makeLocalStyle(i.tags.linkBracket,e,"nLink")):t.match(/^[\s\u00a0]*[^\s\u00a0#|\]&~{]+/)||t.eatSpace()?this.makeStyle(`${i.tags.linkPageName} ${i.tags.pageName}`,e):this.eatWikiText(`${i.tags.linkPageName} ${i.tags.pageName}`)(t,e)}inLinkToSection(t,e){return t.sol()?(e.nLink--,void(e.tokenize=e.stack.pop())):t.match(/^[^|\]&~{}]+/)?this.makeLocalStyle(i.tags.linkToSection,e):t.eat("|")?(e.tokenize=this.eatLinkText(),this.makeLocalStyle(i.tags.linkDelimiter,e)):t.match("]]")?(e.tokenize=e.stack.pop(),this.makeLocalStyle(i.tags.linkBracket,e,"nLink")):this.eatWikiText(i.tags.linkToSection)(t,e)}eatLinkText(){let t,e;return(a,s)=>{let n;return a.match("]]")?(s.tokenize=s.stack.pop(),this.makeLocalStyle(i.tags.linkBracket,s,"nLink")):a.match("'''")?(t=!t,this.makeLocalStyle(`${i.tags.linkText} ${i.tags.apostrophes}`,s)):a.match("''")?(e=!e,this.makeLocalStyle(`${i.tags.linkText} ${i.tags.apostrophes}`,s)):(n=i.tags.linkText,t&&(n+=" "+i.tags.strong),e&&(n+=" "+i.tags.em),a.match(/^[^'\]{&~<]+/)?this.makeStyle(n,s):this.eatWikiText(n)(a,s))}}eatTagName(t,e,a){return(s,n)=>{let l="";for(;t>0;)t--,l+=s.next();return s.eatSpace(),l=l.toLowerCase(),a?(e&&!i.implicitlyClosedHtmlTags[l]?n.tokenize=this.eatChar(">",i.tags.htmlTagBracket):n.tokenize=this.eatHtmlTagAttribute(l),this.makeLocalStyle(i.tags.htmlTagName,n)):(n.tokenize=e?this.eatChar(">",`${i.tags.extTagBracket} mw-ext-${l}`):this.eatExtTagAttribute(l),this.makeLocalStyle(`${i.tags.extTagName} mw-ext-${l}`,n))}}eatHtmlTagAttribute(t){return(e,a)=>e.match(/^(?:"[^<">]*"|'[^<'>]*'|[^>/<{&~])+/)?this.makeLocalStyle(i.tags.htmlTagAttribute,a):e.eat(">")?(t in i.implicitlyClosedHtmlTags||a.inHtmlTag.push(t),a.tokenize=a.stack.pop(),this.makeLocalStyle(i.tags.htmlTagBracket,a)):e.match("/>")?(a.tokenize=a.stack.pop(),this.makeLocalStyle(i.tags.htmlTagBracket,a)):this.eatWikiText(i.tags.htmlTagAttribute)(e,a)}eatNowiki(){return t=>t.match(/^[^&]+/)?"":(t.next(),this.eatHtmlEntity(t,""))}eatExtTagAttribute(t){return(e,a)=>{if(e.match(/^(?:"[^">]*"|'[^'>]*'|[^>/<{&~])+/))return this.makeLocalStyle(`${i.tags.extTagAttribute} mw-ext-${t}`,a);if(e.eat(">")){if(a.extName=t,"nowiki"===t||"pre"===t)a.extMode={startState:()=>{},copyState:()=>{},token:this.eatNowiki()};else if(t in this.config.tagModes){const e=this.config.tagModes[t];"mediawiki"!==e&&"text/mediawiki"!==e||(a.extMode=this.mediawiki,a.extState=a.extMode.startState())}return a.tokenize=this.eatExtTagArea(t),this.makeLocalStyle(`${i.tags.extTagBracket} mw-ext-${t}`,a)}return e.match("/>")?(a.tokenize=a.stack.pop(),this.makeLocalStyle(`${i.tags.extTagBracket} mw-ext-${t}`,a)):this.eatWikiText(`${i.tags.extTagAttribute} mw-ext-${t}`)(e,a)}}eatExtTagArea(t){return(e,a)=>{const i=e.pos,s=new RegExp(``,"i").exec(i?e.string.slice(i):e.string);let n,l=!1;if(s){if(0===s.index)return a.tokenize=this.eatExtCloseTag(t),a.extName=!1,!1!==a.extMode&&(a.extMode=!1,a.extState=!1),a.tokenize(e,a);n=s.index+i,l=e.string,e.string=l.slice(0,n)}return a.stack.push(a.tokenize),a.tokenize=this.eatExtTokens(l),a.tokenize(e,a)}}eatExtCloseTag(t){return(e,a)=>(e.next(),e.next(),a.tokenize=this.eatTagName(t.length,!0,!1),this.makeLocalStyle(`${i.tags.extTagBracket} mw-ext-${t}`,a))}eatExtTokens(t){return(e,a)=>{let s;return!1===a.extMode?(s=i.tags.extTag,e.skipToEnd()):s=`mw-tag-${a.extName} `+a.extMode.token(e,a.extState,!1===t),e.eol()&&(!1!==t&&(e.string=t),a.tokenize=a.stack.pop()),this.makeLocalStyle(s,a)}}eatStartTable(t,e){return t.match("{|"),t.eatSpace(),e.tokenize=this.inTableDefinition.bind(this),i.tags.tableBracket}inTableDefinition(t,e){return t.sol()?(e.tokenize=this.inTable.bind(this),this.inTable(t,e)):this.eatWikiText(i.tags.tableDefinition)(t,e)}inTable(t,e){if(t.sol()){if(t.eatSpace(),t.eat("|"))return t.eat("-")?(t.eatSpace(),e.tokenize=this.inTableDefinition.bind(this),this.makeLocalStyle(i.tags.tableDelimiter,e)):t.eat("+")?(t.eatSpace(),e.tokenize=this.eatTableRow(!0,!1,!0),this.makeLocalStyle(i.tags.tableDelimiter,e)):t.eat("}")?(e.tokenize=e.stack.pop(),this.makeLocalStyle(i.tags.tableBracket,e)):(t.eatSpace(),e.tokenize=this.eatTableRow(!0,!1),this.makeLocalStyle(i.tags.tableDelimiter,e));if(t.eat("!"))return t.eatSpace(),e.tokenize=this.eatTableRow(!0,!0),this.makeLocalStyle(i.tags.tableDelimiter,e)}return this.eatWikiText("")(t,e)}eatTableRow(t,e,a){let s="";return a?s=i.tags.tableCaption:e&&(s=i.tags.strong),(n,l)=>{if(n.sol()){if(n.match(/^[\s\u00a0]*[|!]/,!1))return l.tokenize=this.inTable.bind(this),this.inTable(n,l)}else{if(n.match(/^[^'|{[<&~!]+/))return this.makeStyle(s,l);if(n.match("||")||e&&n.match("!!"))return this.isBold=!1,this.isItalic=!1,l.tokenize=this.eatTableRow(!0,e,a),this.makeLocalStyle(i.tags.tableDelimiter,l);if(t&&n.eat("|"))return l.tokenize=this.eatTableRow(!1,e,a),this.makeLocalStyle(i.tags.tableDelimiter,l)}return this.eatWikiText(s)(n,l)}}eatFreeExternalLinkProtocol(t,e){return t.match(this.urlProtocols),e.tokenize=this.eatFreeExternalLink.bind(this),this.makeLocalStyle(i.tags.freeExtLinkProtocol,e)}eatFreeExternalLink(t,e){if(t.eol());else if(t.match(/^[^\s\u00a0{[\]<>~).,']*/))if("~"===t.peek()){if(!t.match(/^~~~+/,!1))return t.match(/^~*/),this.makeLocalStyle(i.tags.freeExtLink,e)}else if("{"===t.peek()){if(!t.match("{{",!1))return t.next(),this.makeLocalStyle(i.tags.freeExtLink,e)}else if("'"===t.peek()){if(!t.match("''",!1))return t.next(),this.makeLocalStyle(i.tags.freeExtLink,e)}else if(t.match(/^[).,]+(?=[^\s\u00a0{[\]<>~).,])/))return this.makeLocalStyle(i.tags.freeExtLink,e);return e.tokenize=e.stack.pop(),this.makeLocalStyle(i.tags.freeExtLink,e)}eatWikiText(t){return(e,a)=>{let s,n,l,o,r,c;if(e.sol()){if(!e.match("//",!1)&&e.match(this.urlProtocols))return a.stack.push(a.tokenize),a.tokenize=this.eatFreeExternalLink.bind(this),this.makeLocalStyle(i.tags.freeExtLinkProtocol,a);switch(s=e.next(),s){case"-":if(e.match(/^---+/))return i.tags.hr;break;case"=":if(n=e.match(/^(={0,5})(.+?(=\1\s*)(.*\S).*?)?)$/),n)return e.backUp(n[2].length),a.stack.push(a.tokenize),a.tokenize=this.eatSectionHeader(n[3].length),i.tags.sectionHeader+" "+i.tags[`sectionHeader${n[1].length+1}`];break;case"*":case"#":case";":return e.match(/^[*#;:]*/),i.tags.list;case":":return e.match(/^:*{\|/,!1)&&(a.stack.push(a.tokenize),a.tokenize=this.eatStartTable.bind(this)),e.match(/^[*#;:]*/),i.tags.indenting;case" ":if(!e.match(/^[\s\u00a0]*:*{\|/,!1))return i.tags.skipFormatting;if(e.eatSpace(),e.match(/^:+/))return a.stack.push(a.tokenize),a.tokenize=this.eatStartTable.bind(this),i.tags.indenting;e.eat("{");case"{":if(e.eat("|"))return e.eatSpace(),a.stack.push(a.tokenize),a.tokenize=this.inTableDefinition.bind(this),i.tags.tableBracket}}else s=e.next();switch(s){case"&":return this.makeStyle(this.eatHtmlEntity(e,t),a);case"'":if(e.match(/^'*(?=''''')/)||e.match(/^'''(?!')/,!1))break;if(e.match("''"))return this.firstSingleLetterWord||e.match("''",!1)||this.prepareItalicForCorrection(e),this.isBold=!this.isBold,this.makeLocalStyle(i.tags.apostrophesBold,a);if(e.eat("'"))return this.isItalic=!this.isItalic,this.makeLocalStyle(i.tags.apostrophesItalic,a);break;case"[":if(e.eat("[")){if(e.eatSpace(),/[^\]|[]/.test(e.peek()))return a.nLink++,a.stack.push(a.tokenize),a.tokenize=this.inLink.bind(this),this.makeLocalStyle(i.tags.linkBracket,a)}else if(l=e.match(this.urlProtocols),l)return a.nLink++,e.backUp(l[0].length),a.stack.push(a.tokenize),a.tokenize=this.eatExternalLinkProtocol(l[0].length),this.makeLocalStyle(i.tags.extLinkBracket,a);break;case"{":if(e.match(/^{{(?!{|[^{}]*}}(?!}))/))return e.eatSpace(),a.stack.push(a.tokenize),a.tokenize=this.inVariable.bind(this),this.makeLocalStyle(i.tags.templateVariableBracket,a);if(e.match(/^{(?!{(?!{))[\s\u00a0]*/))return"#"===e.peek()?(a.nExt++,a.stack.push(a.tokenize),a.tokenize=this.inParserFunctionName.bind(this),this.makeLocalStyle(i.tags.parserFunctionBracket,a)):(o=e.match(/^([^\s\u00a0}[\]<{'|&:]+)(:|[\s\u00a0]*)(\}\}?)?(.)?/),!o||(e.backUp(o[0].length),":"!==o[2]&&void 0!==o[4]&&"}}"!==o[3]||!(o[1].toLowerCase()in this.config.functionSynonyms[0])&&!(o[1]in this.config.functionSynonyms[1]))?(a.nTemplate++,a.stack.push(a.tokenize),a.tokenize=this.eatTemplatePageName(!1),this.makeLocalStyle(i.tags.templateBracket,a)):(a.nExt++,a.stack.push(a.tokenize),a.tokenize=this.inParserFunctionName.bind(this),this.makeLocalStyle(i.tags.parserFunctionBracket,a)));break;case"<":if(r=!!e.eat("/"),c=e.match(/^[^>/\s\u00a0.*,[\]{}$^+?|/\\'`~<=!@#%&()-]+[^>/\s\u00a0.*,[\]{}$^+?|/\\'`~<=!@#%&()]*/),e.match("!--"))return m=this.eatBlock(i.tags.comment,"--\x3e"),a.stack.push(a.tokenize),a.tokenize=m,m(e,a);if(c){if(c=c[0].toLowerCase(),c in this.config.tags)return!0===r?i.tags.error:(e.backUp(c.length),a.stack.push(a.tokenize),a.tokenize=this.eatTagName(c.length,r,!1),this.makeLocalStyle(`${i.tags.extTagBracket} mw-ext-${c}`,a));if(c in i.permittedHtmlTags)return!0===r&&c!==a.inHtmlTag.pop()?(e.pos++,i.tags.error):!0===r&&c in i.implicitlyClosedHtmlTags?i.tags.error:(e.backUp(c.length),a.stack.push(a.tokenize),a.tokenize=this.eatTagName(c.length,r||c in i.implicitlyClosedHtmlTags,!0),this.makeLocalStyle(i.tags.htmlTagBracket,a));e.backUp(c.length)}break;case"~":if(e.match(/^~{2,4}/))return i.tags.signature;break;case"_":for(n=1;e.eat("_");)n++;if(n>2)return e.eol()||e.backUp(2),this.makeStyle(t,a);if(2===n&&(o=e.match(/^([^\s\u00a0>}[\]<{'|&:~]+?)__/),o&&o[0]))return"__"+o[0].toLowerCase()in this.config.doubleUnderscore[0]||"__"+o[0]in this.config.doubleUnderscore[1]?i.tags.doubleUnderscore:(e.eol()||e.backUp(2),this.makeStyle(t,a));break;default:if(/[\s\u00a0]/.test(s)&&(e.eatSpace(),e.match(this.urlProtocols,!1)&&!e.match("//")))return a.stack.push(a.tokenize),a.tokenize=this.eatFreeExternalLinkProtocol.bind(this),this.makeStyle(t,a)}var m;return e.match(/^[^\s\u00a0_>}[\]<{'|&:~=]+/),this.makeStyle(t,a)}}prepareItalicForCorrection(t){const e=t.pos,a=t.string.slice(0,e-3),i=a.slice(-1),s=a.slice(-2,-1);if(" "===i){if(this.firstMultiLetterWord||this.firstSpace)return;this.firstSpace=e}else if(" "===s)this.firstSingleLetterWord=e;else{if(this.firstMultiLetterWord)return;this.firstMultiLetterWord=e}this.wasBold=this.isBold,this.wasItalic=this.isItalic}get mediawiki(){return{name:"mediawiki",startState:()=>({tokenize:this.eatWikiText(""),stack:[],inHtmlTag:[],extName:!1,extMode:!1,extState:!1,nTemplate:0,nLink:0,nExt:0}),copyState:t=>({tokenize:t.tokenize,stack:t.stack.concat([]),inHtmlTag:t.inHtmlTag.concat([]),extName:t.extName,extMode:t.extMode,extState:!1!==t.extMode&&t.extMode.copyState(t.extState),nTemplate:t.nTemplate,nLink:t.nLink,nExt:t.nExt}),token:(t,e)=>{let a,i,s,n,l=[],o=[];if(this.oldTokens.length>0)return s=this.oldTokens.shift(),t.pos=s.pos,e=s.state,s.style;t.sol()&&(this.isBold=!1,this.isItalic=!1,this.firstSingleLetterWord=null,this.firstMultiLetterWord=null,this.firstSpace=null);do{if(a=e.tokenize(t,e),n=this.firstSingleLetterWord||this.firstMultiLetterWord||this.firstSpace,!n)return this.oldStyle=a,a;n!==i&&(i=n,o.length>0&&(l=l.concat(o),o=[])),o.push({pos:t.pos,style:a,state:(e.extMode||this.mediawiki).copyState(e)})}while(!t.eol());if(this.isBold&&this.isItalic){if(this.isItalic=this.wasItalic,this.isBold=this.wasBold,this.firstSingleLetterWord=null,this.firstMultiLetterWord=null,this.firstSpace=null,!(l.length>0))return t.pos=o[0].pos-2,this.oldStyle;l[l.length-1].pos++,this.oldTokens=l}else this.oldTokens=l.concat(o);return s=this.oldTokens.shift(),t.pos=s.pos,e=s.state,s.style},blankLine:t=>{t.extMode&&t.extMode.blankLine&&t.extMode.blankLine(t.extState)},tokenTable:this.tokenTable}}}module.exports=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{bidiIsolation:!1},a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;a=a||mw.config.get("extCodeMirrorConfig");const s=new d(a).mediawiki,n=t.StreamLanguage.define(s),l=[t.syntaxHighlighting(t.HighlightStyle.define(i.getTagStyles(s)))],o=a.templateFoldingNamespaces;return!mw.config.get("wgCodeMirrorV6TemplateFolding")||o&&!o.includes(mw.config.get("wgNamespaceNumber"))||l.push(g),e.bidiIsolation&&l.push(u),new t.LanguageSupport(n,l)}; diff --git a/resources/dist/codemirror.wikieditor.mediawiki.js b/resources/dist/codemirror.wikieditor.mediawiki.js index 00fc3dd..82f24ac 100644 --- a/resources/dist/codemirror.wikieditor.mediawiki.js +++ b/resources/dist/codemirror.wikieditor.mediawiki.js @@ -1 +1 @@ -"use strict";var e=require("ext.CodeMirror.v6.lib"),t=require("ext.CodeMirror.v6"),r=require("ext.CodeMirror.v6.mode.mediawiki"),i=function(t){function r(t,i){var o;return e._classCallCheck(this,r),(o=e._callSuper(this,r,[t])).langExtension=i,o.useCodeMirror=mw.user.options.get("usecodemirror")>0,o}return e._inherits(r,t),e._createClass(r,[{key:"setCodeMirrorPreference",value:function(t){this.useCodeMirror=t,e._get(e._getPrototypeOf(r.prototype),"setCodeMirrorPreference",this).call(this,t)}},{key:"enableCodeMirror",value:function(){var t=this;if(!this.view){var r=this.$textarea.prop("selectionStart"),i=this.$textarea.prop("selectionEnd"),o=this.$textarea.scrollTop(),s=this.$textarea.is(":focus"),a=[this.defaultExtensions,this.langExtension,e.search({top:!0}),e.EditorView.domEventHandlers({blur:function(){return t.$textarea.triggerHandler("blur")},focus:function(){return t.$textarea.triggerHandler("focus")},keydown:function(e,t){if("Tab"===e.key){e.preventDefault();var r=$("#wpSummary");r.length&&r.trigger("focus")}if("Shift"===e.key){e.preventDefault();var i=t.state.selection.main.head,o=t.coordsAtPos(i),s=t.dom.getBoundingClientRect();(o.tops.bottom)&&$(t.dom).textSelection("scrollToCaretPosition")}return!1}}),e.EditorView.lineWrapping];if(this.initialize(a),$(".group-search a").on("click",(function(){e.openSearchPanel(t.view)})),setTimeout((function(){t.view.scrollDOM.scrollTop=o})),this.view.scrollDOM.style.height="".concat(this.$textarea.height(),"px"),0!==r||0!==i){var n=e.EditorSelection.range(r,i),d=e.EditorView.scrollIntoView(n);d.value.isSnapshot=!0,this.view.dispatch({selection:e.EditorSelection.create([n]),effects:d})}s&&this.view.focus(),mw.hook("ext.CodeMirror.switch").fire(!0,$(this.view.dom))}}},{key:"addCodeMirrorToWikiEditor",value:function(){var e=this,t=this.$textarea.data("wikiEditor-context"),r=t&&t.modules&&t.modules.toolbar;r&&(this.$textarea.wikiEditor("addToToolbar",{section:"main",groups:{codemirror:{tools:{CodeMirror:{label:mw.msg("codemirror-toggle-label"),type:"toggle",oouiIcon:"highlight",action:{type:"callback",execute:function(){return e.switchCodeMirror()}}}}}}}),r.$toolbar.find(".tool[rel=CodeMirror]").attr("id","mw-editbutton-codemirror"),this.readOnly&&this.$textarea.data("wikiEditor-context").$ui.addClass("ext-codemirror-readonly"),this.useCodeMirror&&this.enableCodeMirror(),this.updateToolbarButton(),this.logUsage({editor:"wikitext",enabled:this.useCodeMirror,toggled:!1,edit_start_ts_ms:1e3*parseInt($('input[name="wpStarttime"]').val(),10)||0}))}},{key:"updateToolbarButton",value:function(){var e=$("#mw-editbutton-codemirror");e.toggleClass("mw-editbutton-codemirror-active",this.useCodeMirror),e.data("setActive")&&e.data("setActive")(this.useCodeMirror)}},{key:"switchCodeMirror",value:function(){if(this.view){this.setCodeMirrorPreference(!1);var e=this.view.scrollDOM.scrollTop,t=this.view.hasFocus,r=this.view.state.selection.ranges[0],i=r.from,o=r.to;$(this.view.dom).textSelection("unregister"),this.$textarea.textSelection("unregister"),this.$textarea.val(this.view.state.doc.toString()),this.view.destroy(),this.view=null,this.textSelection=null,this.$textarea.show(),t&&this.$textarea.trigger("focus"),this.$textarea.prop("selectionStart",Math.min(i,o)).prop("selectionEnd",Math.max(o,i)),this.$textarea.scrollTop(e),mw.hook("ext.CodeMirror.switch").fire(!1,this.$textarea)}else this.enableCodeMirror(),this.setCodeMirrorPreference(!0);this.updateToolbarButton(),this.logUsage({editor:"wikitext",enabled:this.useCodeMirror,toggled:!0,edit_start_ts_ms:1e3*parseInt($('input[name="wpStarttime"]').val(),10)||0})}}])}(t);mw.loader.getState("ext.wikiEditor")&&mw.hook("wikiEditor.toolbarReady").add((function(e){(window.WikiEditorCodeMirror=new i(e,r({bidiIsolation:"rtl"===e.attr("dir")}))).addCodeMirrorToWikiEditor()})),window.registerCodeMirrorKeyHandler=function(t){var r=e.EditorView.domEventHandlers({keydown:function(e,r){return t(e,r)}});window.WikiEditorCodeMirror.view.dispatch({effects:e.StateEffect.appendConfig.of(e.Prec.high(r))})},window.registerCodeMirrorScrollHandler=function(t){var r=e.EditorView.domEventHandlers({scroll:function(e,r){return t(e,r)}});window.WikiEditorCodeMirror.view.dispatch({effects:e.StateEffect.appendConfig.of(r)})}; +"use strict";var e=require("ext.CodeMirror.v6.lib"),t=require("ext.CodeMirror.v6"),i=require("ext.CodeMirror.v6.mode.mediawiki");class r extends t{constructor(e,t){super(e),this.langExtension=t,this.useCodeMirror=mw.user.options.get("usecodemirror")>0}setCodeMirrorPreference(e){this.useCodeMirror=e,super.setCodeMirrorPreference(e)}enableCodeMirror(){if(this.view)return;const t=this.$textarea.prop("selectionStart"),i=this.$textarea.prop("selectionEnd"),r=this.$textarea.scrollTop(),o=this.$textarea.is(":focus"),s=[this.defaultExtensions,this.langExtension,e.search({top:!0}),e.EditorView.domEventHandlers({blur:()=>this.$textarea.triggerHandler("blur"),focus:()=>this.$textarea.triggerHandler("focus"),keydown(e,t){if("Tab"===e.key){e.preventDefault();const t=$("#wpSummary");t.length&&t.trigger("focus")}if("Shift"===e.key){e.preventDefault();const i=t.state.selection.main.head,r=t.coordsAtPos(i),o=t.dom.getBoundingClientRect();(r.topo.bottom)&&$(t.dom).textSelection("scrollToCaretPosition")}return!1}}),e.EditorView.lineWrapping];if(this.initialize(s),$(".group-search a").on("click",(()=>{e.openSearchPanel(this.view)})),setTimeout((()=>{this.view.scrollDOM.scrollTop=r})),this.view.scrollDOM.style.height=`${this.$textarea.height()}px`,0!==t||0!==i){const r=e.EditorSelection.range(t,i),o=e.EditorView.scrollIntoView(r);o.value.isSnapshot=!0,this.view.dispatch({selection:e.EditorSelection.create([r]),effects:o})}o&&this.view.focus(),mw.hook("ext.CodeMirror.switch").fire(!0,$(this.view.dom))}addCodeMirrorToWikiEditor(){const e=this.$textarea.data("wikiEditor-context"),t=e&&e.modules&&e.modules.toolbar;if(!t)return;this.$textarea.wikiEditor("addToToolbar",{section:"main",groups:{codemirror:{tools:{CodeMirror:{label:mw.msg("codemirror-toggle-label"),type:"toggle",oouiIcon:"highlight",action:{type:"callback",execute:()=>this.switchCodeMirror()}}}}}});t.$toolbar.find(".tool[rel=CodeMirror]").attr("id","mw-editbutton-codemirror"),this.readOnly&&this.$textarea.data("wikiEditor-context").$ui.addClass("ext-codemirror-readonly"),this.useCodeMirror&&this.enableCodeMirror(),this.updateToolbarButton(),this.logUsage({editor:"wikitext",enabled:this.useCodeMirror,toggled:!1,edit_start_ts_ms:1e3*parseInt($('input[name="wpStarttime"]').val(),10)||0})}updateToolbarButton(){const e=$("#mw-editbutton-codemirror");e.toggleClass("mw-editbutton-codemirror-active",this.useCodeMirror),e.data("setActive")&&e.data("setActive")(this.useCodeMirror)}switchCodeMirror(){if(this.view){this.setCodeMirrorPreference(!1);const e=this.view.scrollDOM.scrollTop,t=this.view.hasFocus,{from:i,to:r}=this.view.state.selection.ranges[0];$(this.view.dom).textSelection("unregister"),this.$textarea.textSelection("unregister"),this.$textarea.val(this.view.state.doc.toString()),this.view.destroy(),this.view=null,this.textSelection=null,this.$textarea.show(),t&&this.$textarea.trigger("focus"),this.$textarea.prop("selectionStart",Math.min(i,r)).prop("selectionEnd",Math.max(r,i)),this.$textarea.scrollTop(e),mw.hook("ext.CodeMirror.switch").fire(!1,this.$textarea)}else this.enableCodeMirror(),this.setCodeMirrorPreference(!0);this.updateToolbarButton(),this.logUsage({editor:"wikitext",enabled:this.useCodeMirror,toggled:!0,edit_start_ts_ms:1e3*parseInt($('input[name="wpStarttime"]').val(),10)||0})}}mw.loader.getState("ext.wikiEditor")&&mw.hook("wikiEditor.toolbarReady").add((e=>{(window.WikiEditorCodeMirror=new r(e,i({bidiIsolation:"rtl"===e.attr("dir")}))).addCodeMirrorToWikiEditor()})),window.registerCodeMirrorKeyHandler=function(t){const i=e.EditorView.domEventHandlers({keydown:(e,i)=>t(e,i)});window.WikiEditorCodeMirror.view.dispatch({effects:e.StateEffect.appendConfig.of(e.Prec.high(i))})},window.registerCodeMirrorScrollHandler=function(t){const i=e.EditorView.domEventHandlers({scroll:(e,i)=>t(e,i)});window.WikiEditorCodeMirror.view.dispatch({effects:e.StateEffect.appendConfig.of(i)})}; diff --git a/resources/dist/ve.ui.CodeMirrorAction.js b/resources/dist/ve.ui.CodeMirrorAction.js index bcdf92b..b12dea3 100644 --- a/resources/dist/ve.ui.CodeMirrorAction.js +++ b/resources/dist/ve.ui.CodeMirrorAction.js @@ -1 +1 @@ -"use strict";var e=require("ext.CodeMirror.v6.mode.mediawiki"),t=require("ext.CodeMirror.v6.lib"),r=function(){return t._createClass((function e(r,i){t._classCallCheck(this,e),this.surface=r,this.langExtension=i,this.view=null,this.state=null,this.useCodeMirror=mw.user.options.get("usecodemirror")>0}),[{key:"defaultExtensions",get:function(){var e=[this.contentAttributesExtension],r=mw.config.get("wgCodeMirrorLineNumberingNamespaces");return r&&!r.includes(mw.config.get("wgNamespaceNumber"))||e.push(t.lineNumbers()),e}},{key:"contentAttributesExtension",get:function(){return t.EditorView.contentAttributes.of({dir:$(this.surface.getView()[0]).attr("dir"),lang:$(this.surface.getView()[0]).attr("lang")})}},{key:"initialize",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.defaultExtensions;this.state=t.EditorState.create({doc:this.surface.getDom(),extensions:e}),this.view=new t.EditorView({state:this.state,parent:this.surface.getView().$element[0]}),this.view.viewState.printing=!0,mw.hook("ext.CodeMirror.switch").fire(!0,$(this.view.dom))}},{key:"logUsage",value:function(e){var t=Object.assign({session_token:mw.user.sessionId(),user_id:mw.user.getId()},e),r=mw.config.get("wgUserEditCountBucket");null!==r&&(t.user_edit_count_bucket=r),mw.track("event.CodeMirrorUsage",t)}},{key:"setCodeMirrorPreference",value:function(e){mw.user.isAnon()||((new mw.Api).saveOption("usecodemirror",e?1:0),mw.user.options.set("usecodemirror",e?1:0))}},{key:"enableCodeMirror",value:function(){var e=this;if(!this.view){var r=[].concat(t._toConsumableArray(this.defaultExtensions),[this.langExtension,t.bracketMatching(),t.history(),t.EditorView.contentAttributes.of({spellcheck:"true"}),t.EditorView.updateListener.of((function(t){t.docChanged&&"function"==typeof e.editRecoveryHandler&&e.editRecoveryHandler()})),t.EditorView.lineWrapping]);mw.hook("editRecovery.loadEnd").add((function(t){e.editRecoveryHandler=t.fieldChangeHandler}));var i=$.client.profile(),o="WebkitTextFillColor"in document.body.style&&!("gecko"===i.layout&&"mac"===i.platform);this.surface.getView().$documentNode.addClass(o?"ve-ce-documentNode-codeEditor-webkit-hide":"ve-ce-documentNode-codeEditor-hide"),this.initialize(r)}}}])}();ve.ui.CodeMirrorAction=function(){ve.ui.CodeMirrorAction.super.apply(this,arguments)},OO.inheritClass(ve.ui.CodeMirrorAction,ve.ui.Action),ve.ui.CodeMirrorAction.static.name="codeMirror",ve.ui.CodeMirrorAction.static.methods=["toggle"],ve.ui.CodeMirrorAction.static.isLineNumbering=function(){if(/Android\b/.test(navigator.userAgent))return!1;var e=mw.config.get("wgCodeMirrorLineNumberingNamespaces");return!e||-1!==e.indexOf(mw.config.get("wgNamespaceNumber"))},ve.ui.CodeMirrorAction.prototype.toggle=function(t){var i=this.surface,o=i.getView(),n=i.getModel().getDocument();if(i.mirror&&i.mirror.view||!1===t)i.mirror&&!0!==t&&(n.off("precommit",i.mirror.veTransactionListener),o.$element.removeClass("mw-editfont-monospace").addClass("mw-editfont-"+mw.user.options.get("editfont")),o.$documentNode.removeClass("ve-ce-documentNode-codeEditor-webkit-hide ve-ce-documentNode-codeEditor-hide"),o.$documentNode.css("margin-left",""),i.mirror.view.destroy(),i.mirror.view=null);else{i.mirror=window.VisualEditorCodeMirror=new r(i,e()),i.mirror.enableCodeMirror();var s=parseInt(document.querySelector(".cm-gutters").offsetWidth);o.$documentNode.css("margin-left",s-5),i.mirror.veTransactionListener=this.onDocumentPrecommit.bind(this),n.on("precommit",i.mirror.veTransactionListener)}return!0},ve.ui.CodeMirrorAction.prototype.onSelect=function(e){var t=e.getCoveringRange();t&&t.isCollapsed()&&this.surface.mirror.setSelection(this.getPosFromOffset(t.from))},ve.ui.CodeMirrorAction.prototype.onLangChange=function(){var e=this.surface,t=e.getView().getDocument(),r=t.getDir(),i=t.getLang();e.mirror.setOption("direction",r),e.mirror.getWrapperElement().setAttribute("lang",i)},ve.ui.CodeMirrorAction.prototype.onDocumentPrecommit=function(e){var t=0,r=[],i=this,o=this.surface.getModel().getDocument().getStore(),n=this.surface.mirror.view,s=document.querySelector(".ve-ce-documentNode"),c=parseInt(document.querySelector(".cm-gutters").offsetWidth);s.style.marginLeft=c-5+"px",e.operations.forEach((function(e){"retain"===e.type?t+=e.length:"replace"===e.type&&(r.push({start:"replace"===e.type?i.getPosFromOffset(t):void 0,end:e.remove.length?i.getPosFromOffset(t+e.remove.length):void 0,data:new ve.dm.ElementLinearData(o,e.insert).getSourceText()}),t+=e.remove.length)}));for(var a=r.length-1;a>=0;a--)n.dispatch({changes:{from:r[a].start,to:r[a].end,insert:r[a].data}})},ve.ui.CodeMirrorAction.prototype.getPosFromOffset=function(e){return this.surface.getModel().getSourceOffsetFromOffset(e)},ve.ui.actionFactory.register(ve.ui.CodeMirrorAction); +"use strict";var e=require("ext.CodeMirror.v6.mode.mediawiki"),t=require("ext.CodeMirror.v6.lib");class r{constructor(e,t){this.surface=e,this.langExtension=t,this.view=null,this.state=null,this.useCodeMirror=mw.user.options.get("usecodemirror")>0}get defaultExtensions(){const e=[this.contentAttributesExtension],r=mw.config.get("wgCodeMirrorLineNumberingNamespaces");return r&&!r.includes(mw.config.get("wgNamespaceNumber"))||e.push(t.lineNumbers()),e}get contentAttributesExtension(){return t.EditorView.contentAttributes.of({dir:$(this.surface.getView()[0]).attr("dir"),lang:$(this.surface.getView()[0]).attr("lang")})}initialize(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.defaultExtensions;this.state=t.EditorState.create({doc:this.surface.getDom(),extensions:e}),this.view=new t.EditorView({state:this.state,parent:this.surface.getView().$element[0]}),this.view.viewState.printing=!0,mw.hook("ext.CodeMirror.switch").fire(!0,$(this.view.dom))}logUsage(e){const t=Object.assign({session_token:mw.user.sessionId(),user_id:mw.user.getId()},e),r=mw.config.get("wgUserEditCountBucket");null!==r&&(t.user_edit_count_bucket=r),mw.track("event.CodeMirrorUsage",t)}setCodeMirrorPreference(e){mw.user.isAnon()||((new mw.Api).saveOption("usecodemirror",e?1:0),mw.user.options.set("usecodemirror",e?1:0))}enableCodeMirror(){if(this.view)return;const e=[...this.defaultExtensions,this.langExtension,t.bracketMatching(),t.history(),t.EditorView.contentAttributes.of({spellcheck:"true"}),t.EditorView.updateListener.of((e=>{e.docChanged&&"function"==typeof this.editRecoveryHandler&&this.editRecoveryHandler()})),t.EditorView.lineWrapping];mw.hook("editRecovery.loadEnd").add((e=>{this.editRecoveryHandler=e.fieldChangeHandler}));const r=$.client.profile(),o="WebkitTextFillColor"in document.body.style&&!("gecko"===r.layout&&"mac"===r.platform);this.surface.getView().$documentNode.addClass(o?"ve-ce-documentNode-codeEditor-webkit-hide":"ve-ce-documentNode-codeEditor-hide"),this.initialize(e)}}ve.ui.CodeMirrorAction=function(){ve.ui.CodeMirrorAction.super.apply(this,arguments)},OO.inheritClass(ve.ui.CodeMirrorAction,ve.ui.Action),ve.ui.CodeMirrorAction.static.name="codeMirror",ve.ui.CodeMirrorAction.static.methods=["toggle"],ve.ui.CodeMirrorAction.static.isLineNumbering=function(){if(/Android\b/.test(navigator.userAgent))return!1;const e=mw.config.get("wgCodeMirrorLineNumberingNamespaces");return!e||-1!==e.indexOf(mw.config.get("wgNamespaceNumber"))},ve.ui.CodeMirrorAction.prototype.toggle=function(t){const o=this,i=this.surface,n=i.getView(),s=i.getModel().getDocument();return i.mirror&&i.mirror.view||!1===t?i.mirror&&!0!==t&&(s.off("precommit",i.mirror.veTransactionListener),s.off("transact",i.mirror.vePostTransactionListener),n.$element.removeClass("mw-editfont-monospace").addClass("mw-editfont-"+mw.user.options.get("editfont")),n.$documentNode.removeClass("ve-ce-documentNode-codeEditor-webkit-hide ve-ce-documentNode-codeEditor-hide"),n.$documentNode.css("margin-left",""),i.mirror.view.destroy(),i.mirror.view=null):(i.mirror=window.VisualEditorCodeMirror=new r(i,e()),i.mirror.enableCodeMirror(),o.onTransact(),i.mirror.veTransactionListener=o.onDocumentPrecommit.bind(o),i.mirror.vePostTransactionListener=o.onTransact.bind(o),s.on("precommit",i.mirror.veTransactionListener),s.on("transact",i.mirror.vePostTransactionListener)),!0},ve.ui.CodeMirrorAction.prototype.onSelect=function(e){const t=e.getCoveringRange();t&&t.isCollapsed()&&this.surface.mirror.setSelection(this.getPosFromOffset(t.from))},ve.ui.CodeMirrorAction.prototype.onLangChange=function(){const e=this.surface,t=e.getView().getDocument(),r=t.getDir(),o=t.getLang();e.mirror.setOption("direction",r),e.mirror.getWrapperElement().setAttribute("lang",o)},ve.ui.CodeMirrorAction.prototype.onDocumentPrecommit=function(e){let t=0;const r=[],o=this,i=this.surface.getModel().getDocument().getStore(),n=this.surface.mirror.view;e.operations.forEach((function(e){"retain"===e.type?t+=e.length:"replace"===e.type&&(r.push({start:"replace"===e.type?o.getPosFromOffset(t):void 0,end:e.remove.length?o.getPosFromOffset(t+e.remove.length):void 0,data:new ve.dm.ElementLinearData(i,e.insert).getSourceText()}),t+=e.remove.length)}));for(let e=r.length-1;e>=0;e--)n.dispatch({changes:{from:r[e].start,to:r[e].end,insert:r[e].data}})},ve.ui.CodeMirrorAction.prototype.onTransact=function(){const e=this.surface.getView(),t=e.$element.find(".cm-gutters").outerWidth(!0);e.$documentNode.css("margin-left",`${t}px`)},ve.ui.CodeMirrorAction.prototype.getPosFromOffset=function(e){return this.surface.getModel().getSourceOffsetFromOffset(e)},ve.ui.actionFactory.register(ve.ui.CodeMirrorAction); diff --git a/resources/dist/ve.ui.CodeMirrorTool.js b/resources/dist/ve.ui.CodeMirrorTool.js index 4687972..199de83 100644 --- a/resources/dist/ve.ui.CodeMirrorTool.js +++ b/resources/dist/ve.ui.CodeMirrorTool.js @@ -1 +1 @@ -"use strict";ve.ui.CodeMirrorTool=function(){ve.ui.CodeMirrorTool.super.apply(this,arguments),this.toolbar.connect(this,{surfaceChange:"onSurfaceChange"})},OO.inheritClass(ve.ui.CodeMirrorTool,ve.ui.Tool),ve.ui.CodeMirrorTool.static.name="codeMirror",ve.ui.CodeMirrorTool.static.autoAddToCatchall=!1,ve.ui.CodeMirrorTool.static.title=OO.ui.deferMsg("codemirror-toggle-label"),ve.ui.CodeMirrorTool.static.icon="highlight",ve.ui.CodeMirrorTool.static.group="utility",ve.ui.CodeMirrorTool.static.commandName="codeMirror",ve.ui.CodeMirrorTool.static.deactivateOnSelect=!1,ve.ui.CodeMirrorTool.prototype.onSelect=function(){ve.ui.CodeMirrorTool.super.prototype.onSelect.apply(this,arguments);var o=this.toolbar.surface.mirror,e=!(!o||!o.view);this.setActive(e),o.setCodeMirrorPreference(e),o.logUsage({editor:"wikitext-2017",enabled:e,toggled:!0,edit_start_ts_ms:1e3*this.toolbar.target.startTimeStamp||0})},ve.ui.CodeMirrorTool.prototype.onSurfaceChange=function(o,e){var r="source"!==e.getMode();if(this.setDisabled(r),!r){var t=this.getCommand(),i=this.toolbar.getSurface(),a=mw.user.options.get("usecodemirror")>0;t.execute(i,[a]),this.setActive(a),this.toolbar.target.startTimeStamp&&this.toolbar.surface.mirror.logUsage({editor:"wikitext-2017",enabled:a,toggled:!1,edit_start_ts_ms:1e3*this.toolbar.target.startTimeStamp||0})}},ve.ui.CodeMirrorTool.prototype.onUpdateState=function(){},ve.ui.toolFactory.register(ve.ui.CodeMirrorTool),ve.ui.commandRegistry.register(new ve.ui.Command("codeMirror","codeMirror","toggle")); +"use strict";ve.ui.CodeMirrorTool=function(){ve.ui.CodeMirrorTool.super.apply(this,arguments),this.toolbar.connect(this,{surfaceChange:"onSurfaceChange"})},OO.inheritClass(ve.ui.CodeMirrorTool,ve.ui.Tool),ve.ui.CodeMirrorTool.static.name="codeMirror",ve.ui.CodeMirrorTool.static.autoAddToCatchall=!1,ve.ui.CodeMirrorTool.static.title=OO.ui.deferMsg("codemirror-toggle-label"),ve.ui.CodeMirrorTool.static.icon="highlight",ve.ui.CodeMirrorTool.static.group="utility",ve.ui.CodeMirrorTool.static.commandName="codeMirror",ve.ui.CodeMirrorTool.static.deactivateOnSelect=!1,ve.ui.CodeMirrorTool.prototype.onSelect=function(){ve.ui.CodeMirrorTool.super.prototype.onSelect.apply(this,arguments);const o=this.toolbar.surface.mirror,e=!(!o||!o.view);this.setActive(e),o.setCodeMirrorPreference(e),o.logUsage({editor:"wikitext-2017",enabled:e,toggled:!0,edit_start_ts_ms:1e3*this.toolbar.target.startTimeStamp||0})},ve.ui.CodeMirrorTool.prototype.onSurfaceChange=function(o,e){const t="source"!==e.getMode();if(this.setDisabled(t),!t){const o=this.getCommand(),e=this.toolbar.getSurface(),t=mw.user.options.get("usecodemirror")>0;o.execute(e,[t]),this.setActive(t),this.toolbar.target.startTimeStamp&&this.toolbar.surface.mirror.logUsage({editor:"wikitext-2017",enabled:t,toggled:!1,edit_start_ts_ms:1e3*this.toolbar.target.startTimeStamp||0})}},ve.ui.CodeMirrorTool.prototype.onUpdateState=function(){},ve.ui.toolFactory.register(ve.ui.CodeMirrorTool),ve.ui.commandRegistry.register(new ve.ui.Command("codeMirror","codeMirror","toggle")); diff --git a/resources/dist/vendor.js b/resources/dist/vendor.js index 9446666..8013aaa 100644 --- a/resources/dist/vendor.js +++ b/resources/dist/vendor.js @@ -1 +1 @@ -"use strict";function t(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(t=function(){return!!e})()}function e(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),i.push.apply(i,n)}return i}function i(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var n=i.call(t,e||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}function n(t,e){for(var n=0;nt.length)&&(e=t.length);for(var i=0,n=new Array(e);ithis.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]=y(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),f.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]=y(this,t,e);let i=[];return this.decompose(t,e,i,0),f.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 g(this),r=new g(t);for(let t=e,s=e;;){if(n.next(t),r.next(t),t=0,n.lineBreak!=r.lineBreak||n.done!=r.done||n.value!=r.value)return!1;if(s+=n.value.length,n.done||s>=i)return!0}}iter(t=1){return new g(this,t)}iterRange(t,e=this.length){return new m(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 v(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 u(t):f.from(u.split(t,[])):c.empty}}class u extends c{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 r=0;;r++){let s=this.text[r],o=n+s.length;if((e?i:o)>=t)return new w(n,o,i,s);n=o+1,i++}}decompose(t,e,i,n){let r=t<=0&&e>=this.length?this:new u(p(this.text,t,e),Math.min(e,this.length)-Math.max(0,t));if(1&n){let t=i.pop(),e=d(r.text,t.text.slice(),0,r.length);if(e.length<=32)i.push(new u(e,t.length+r.length));else{let t=e.length>>1;i.push(new u(e.slice(0,t)),new u(e.slice(t)))}}else i.push(r)}replace(t,e,i){if(!(i instanceof u))return super.replace(t,e,i);[t,e]=y(this,t,e);let n=d(this.text,d(i.text,p(this.text,0,t)),e),r=this.length+i.length-(e-t);return n.length<=32?new u(n,r):f.from(u.split(n,[]),r)}sliceString(t,e=this.length,i="\n"){[t,e]=y(this,t,e);let n="";for(let r=0,s=0;r<=e&&st&&s&&(n+=i),tr&&(n+=o.slice(Math.max(0,t-r),e-r)),r=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 r of t)i.push(r),n+=r.length+1,32==i.length&&(e.push(new u(i,n)),i=[],n=-1);return n>-1&&e.push(new u(i,n)),e}}class f extends c{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 r=0;;r++){let s=this.children[r],o=n+s.length,l=i+s.lines-1;if((e?l:o)>=t)return s.lineInner(t,e,i,n);n=o+1,i=l+1}}decompose(t,e,i,n){for(let r=0,s=0;s<=e&&r=s){let r=n&((s<=t?1:0)|(l>=e?2:0));s>=t&&l<=e&&!r?i.push(o):o.decompose(t-s,e-s,i,r)}s=l+1}}replace(t,e,i){if([t,e]=y(this,t,e),i.lines=r&&e<=o){let l=s.replace(t-r,e-r,i),h=this.lines-s.lines+l.lines;if(l.lines>4&&l.lines>h>>6){let r=this.children.slice();return r[n]=l,new f(r,this.length-(e-t)+i.length)}return super.replace(r,o,l)}r=o+1}return super.replace(t,e,i)}sliceString(t,e=this.length,i="\n"){[t,e]=y(this,t,e);let n="";for(let r=0,s=0;rt&&r&&(n+=i),ts&&(n+=o.sliceString(t-s,e-s,i)),s=l+1}return n}flatten(t){for(let e of this.children)e.flatten(t)}scanIdentical(t,e){if(!(t instanceof f))return 0;let i=0,[n,r,s,o]=e>0?[0,0,this.children.length,t.children.length]:[this.children.length-1,t.children.length-1,-1,-1];for(;;n+=e,r+=e){if(n==s||r==o)return i;let l=this.children[n],h=t.children[r];if(l!=h)return i+l.scanIdentical(h,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 u(i,e)}let n=Math.max(32,i>>5),r=n<<1,s=n>>1,o=[],l=0,h=-1,a=[];function c(t){let e;if(t.lines>r&&t instanceof f)for(let e of t.children)c(e);else t.lines>s&&(l>s||!l)?(d(),o.push(t)):t instanceof u&&l&&(e=a[a.length-1])instanceof u&&t.lines+e.lines<=32?(l+=t.lines,h+=t.length+1,a[a.length-1]=new u(e.text.concat(t.text),e.length+1+t.length)):(l+t.lines>n&&d(),l+=t.lines,h+=t.length+1,a.push(t))}function d(){0!=l&&(o.push(1==a.length?a[0]:f.from(a,h)),h=-1,l=a.length=0)}for(let e of t)c(e);return d(),1==o.length?o[0]:new f(o,e)}}function d(t,e,i=0,n=1e9){for(let r=0,s=0,o=!0;s=i&&(h>n&&(l=l.slice(0,n-r)),r0?1:(t instanceof u?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],r=this.offsets[i],s=r>>1,o=n instanceof u?n.text.length:n.children.length;if(s==(e>0?o: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&r)==(e>0?0:1)){if(this.offsets[i]+=e,0==t)return this.lineBreak=!0,this.value="\n",this;t--}else if(n instanceof u){let r=n.text[s+(e<0?-1:0)];if(this.offsets[i]+=e,r.length>Math.max(0,t))return this.value=0==t?r:e>0?r.slice(t):r.slice(0,r.length-t),this;t-=r.length}else{let r=n.children[s+(e<0?-1:0)];t>r.length?(t-=r.length,this.offsets[i]+=e):(e<0&&this.offsets[i]--,this.nodes.push(r),this.offsets.push(e>0?1:(r instanceof u?r.text.length:r.children.length)<<1))}}}next(t=0){return t<0&&(this.nextInner(-t,-this.dir),t=this.value.length),this.nextInner(t,this.dir)}}class m{constructor(t,e,i){this.value="",this.done=!1,this.cursor=new g(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 v{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&&(c.prototype[Symbol.iterator]=function(){return this.iter()},g.prototype[Symbol.iterator]=m.prototype[Symbol.iterator]=v.prototype[Symbol.iterator]=function(){return this});class w{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 y(t,e,i){return[e=Math.max(0,Math.min(t.length,e)),Math.max(e,Math.min(t.length,i))]}let b="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 t=1;tt)return b[e-1]<=t;return!1}function k(t){return t>=127462&&t<=127487}const S=8205;function A(t,e,i=!0,n=!0){return(i?M:C)(t,e,n)}function M(t,e,i){if(e==t.length)return e;e&&O(t.charCodeAt(e))&&D(t.charCodeAt(e-1))&&e--;let n=T(t,e);for(e+=R(n);e=0&&k(T(t,n));)i++,n-=2;if(i%2==0)break;e+=2}}}return e}function C(t,e,i){for(;e>0;){let n=M(t,e-2,i);if(n=56320&&t<57344}function D(t){return t>=55296&&t<56320}function T(t,e){let i=t.charCodeAt(e);if(!D(i)||e+1==t.length)return i;let n=t.charCodeAt(e+1);return O(n)?n-56320+(i-55296<<10)+65536:i}function E(t){return t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode(55296+(t>>10),56320+(1023&t)))}function R(t){return t<65536?1:2}const P=/\r\n?|\n/;var B=function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t}(B||(B={}));class L{constructor(t){this.sections=t}get length(){let t=0;for(let e=0;et)return r+(t-n);r+=o}else{if(i!=B.Simple&&h>=t&&(i==B.TrackDel&&nt||i==B.TrackBefore&&nt))return null;if(h>t||h==t&&e<0&&!o)return t==n||e<0?r:r+l;r+=l}n=h}if(t>n)throw new RangeError(`Position ${t} is out of range for changeset of length ${n}`);return r}touchesRange(t,e=t){for(let i=0,n=0;i=0&&n<=e&&r>=t)return!(ne)||"cover";n=r}return!1}toString(){let t="";for(let e=0;e=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 L(t)}static create(t){return new L(t)}}class N extends L{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 H(this,((e,i,n,r,s)=>t=t.replace(n,n+(i-e),s)),!1),t}mapDesc(t,e=!1){return W(this,t,e,!0)}invert(t){let e=this.sections.slice(),i=[];for(let n=0,r=0;n=0){e[n]=o,e[n+1]=s;let l=n>>1;for(;i.length0&&V(i,e,r.text),r.forward(t),o+=t}let h=t[s++];for(;o>1].toJSON()))}return t}static of(t,e,i){let n=[],r=[],s=0,o=null;function l(t=!1){if(!t&&!n.length)return;so||t<0||o>e)throw new RangeError(`Invalid change range ${t} to ${o} (in doc of length ${e})`);let u=a?"string"==typeof a?c.of(a.split(i||P)):a:c.empty,f=u.length;if(t==o&&0==f)return;ts&&I(n,t-s,-1),I(n,o-t,f),V(r,n,u),s=o}}(t),l(!o),o}static empty(t){return new N(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;ne&&"string"!=typeof t)))throw new RangeError("Invalid JSON representation of ChangeSet");if(1==r.length)e.push(r[0],0);else{for(;i.length=0&&i<=0&&i==t[r+1]?t[r]+=e:0==e&&0==t[r]?t[r+1]+=i:n?(t[r]+=e,t[r+1]+=i):t.push(e,i)}function V(t,e,i){if(0==i.length)return;let n=e.length-2>>1;if(n>1])),!(i||o==t.sections.length||t.sections[o+1]<0);)l=t.sections[o++],h=t.sections[o++];e(r,a,s,u,f),r=a,s=u}}}function W(t,e,i,n=!1){let r=[],s=n?[]:null,o=new F(t),l=new F(e);for(let t=-1;;)if(-1==o.ins&&-1==l.ins){let t=Math.min(o.len,l.len);I(r,t,-1),o.forward(t),l.forward(t)}else if(l.ins>=0&&(o.ins<0||t==o.i||0==o.off&&(l.len=0&&t=0)){if(o.done&&l.done)return s?N.createSet(r,s):L.create(r);throw new Error("Mismatched change set lengths")}{let e=0,i=o.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.lene||o.ins>=0&&o.len>e)&&(t||n.length>i),s.forward2(e),o.forward(e)}}else I(n,0,o.ins,t),r&&V(r,n,o.text),o.next()}}class F{constructor(t){this.set=t,this.i=0,this.next()}next(){let{sections:t}=this.set;this.i>1;return e>=t.length?c.empty:t[e]}textBit(t){let{inserted:e}=this.set,i=this.i-2>>1;return i>=e.length&&!t?c.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 q{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 q(i,n,this.flags)}extend(t,e=t){if(t<=this.anchor&&e>=this.anchor)return _.range(t,e);let i=Math.abs(t-this.anchor)>Math.abs(e-this.anchor)?t:e;return _.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 _.range(t.anchor,t.head)}static create(t,e,i){return new q(t,e,i)}}class _{constructor(t,e){this.ranges=t,this.mainIndex=e}map(t,e=-1){return t.empty?this:_.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;it.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 _(t.ranges.map((t=>q.fromJSON(t))),t.main)}static single(t,e=t){return new _([_.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;nt?8:0)|r)}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;in.head?_.range(o,s):_.range(s,o))}}return new _(t,e)}}function j(t,e){for(let i of t.ranges)if(i.to>e)throw new RangeError("Selection points outside of document")}let K=0;class ${constructor(t,e,i,n,r){this.combine=t,this.compareInput=e,this.compare=i,this.isStatic=n,this.id=K++,this.default=t([]),this.extensions="function"==typeof r?r(this):r}get reader(){return this}static define(t={}){return new $(t.combine||(t=>t),t.compareInput||((t,e)=>t===e),t.compare||(t.combine?(t,e)=>t===e:U),!!t.static,t.enables)}of(t){return new G([],this,0,t)}compute(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new G(t,this,1,e)}computeN(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new G(t,this,2,e)}from(t,e){return e||(e=t=>t),this.compute([t],(i=>e(i.field(t))))}}function U(t,e){return t==e||t.length==e.length&&t.every(((t,i)=>t===e[i]))}class G{constructor(t,e,i,n){this.dependencies=t,this.facet=e,this.type=i,this.value=n,this.id=K++}dynamicSlot(t){var e;let i=this.value,n=this.facet.compareInput,r=this.id,s=t[r]>>1,o=2==this.type,l=!1,h=!1,a=[];for(let i of this.dependencies)"doc"==i?l=!0:"selection"==i?h=!0:1&(null!==(e=t[i.id])&&void 0!==e?e:1)||a.push(t[i.id]);return{create:t=>(t.values[s]=i(t),1),update(t,e){if(l&&e.docChanged||h&&(e.docChanged||e.selection)||Y(t,a)){let e=i(t);if(o?!J(e,t.values[s],n):!n(e,t.values[s]))return t.values[s]=e,1}return 0},reconfigure:(t,e)=>{let l,h=e.config.address[r];if(null!=h){let r=ut(e,h);if(this.dependencies.every((i=>i instanceof $?e.facet(i)===t.facet(i):!(i instanceof Z)||e.field(i,!1)==t.field(i,!1)))||(o?J(l=i(t),r,n):n(l=i(t),r)))return t.values[s]=r,0}else l=i(t);return t.values[s]=l,1}}}}function J(t,e,i){if(t.length!=e.length)return!1;for(let n=0;nt[e.id])),r=i.map((t=>t.type)),s=n.filter((t=>!(1&t))),o=t[e.id]>>1;function l(t){let i=[];for(let e=0;et===e),t);return t.provide&&(e.provides=t.provide(e)),e}create(t){let e=t.facet(Q).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],r=this.updateF(n,i);return this.compareF(n,r)?0:(t.values[e]=r,1)},reconfigure:(t,i)=>null!=i.config.address[this.id]?(t.values[e]=i.field(this),0):(t.values[e]=this.create(t),1)}}init(t){return[this,Q.of({field:this,create:t})]}get extension(){return this}}const tt=4,et=3,it=2,nt=1;function rt(t){return e=>new ot(e,t)}const st={highest:rt(0),high:rt(nt),default:rt(it),low:rt(et),lowest:rt(tt)};class ot{constructor(t,e){this.inner=t,this.prec=e}}class lt{of(t){return new ht(this,t)}reconfigure(t){return lt.reconfigure.of({compartment:this,extension:t})}get(t){return t.config.compartments.get(this)}}class ht{constructor(t,e){this.compartment=t,this.inner=e}}class at{constructor(t,e,i,n,r,s){for(this.base=t,this.compartments=e,this.dynamicSlots=i,this.address=n,this.staticValues=r,this.facets=s,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(t,e,i){let n=[],r=Object.create(null),s=new Map;for(let i of function(t,e,i){let n=[[],[],[],[],[]],r=new Map;function s(t,o){let l=r.get(t);if(null!=l){if(l<=o)return;let e=n[l].indexOf(t);e>-1&&n[l].splice(e,1),t instanceof ht&&i.delete(t.compartment)}if(r.set(t,o),Array.isArray(t))for(let e of t)s(e,o);else if(t instanceof ht){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),s(n,o)}else if(t instanceof ot)s(t.inner,t.prec);else if(t instanceof Z)n[o].push(t),t.provides&&s(t.provides,o);else if(t instanceof G)n[o].push(t),t.facet.extensions&&s(t.facet.extensions,it);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.`);s(e,o)}}return s(t,it),n.reduce(((t,e)=>t.concat(e)))}(t,e,s))i instanceof Z?n.push(i):(r[i.facet.id]||(r[i.facet.id]=[])).push(i);let o=Object.create(null),l=[],h=[];for(let t of n)o[t.id]=h.length<<1,h.push((e=>t.slot(e)));let a=null==i?void 0:i.config.facets;for(let t in r){let e=r[t],n=e[0].facet,s=a&&a[t]||[];if(e.every((t=>0==t.type)))if(o[n.id]=l.length<<1|1,U(s,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?(o[t.id]=l.length<<1|1,l.push(t.value)):(o[t.id]=h.length<<1,h.push((e=>t.dynamicSlot(e))));o[n.id]=h.length<<1,h.push((t=>X(t,n,e)))}}let c=h.map((t=>t(o)));return new at(t,s,c,o,l,r)}}function ct(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 r=t.computeSlot(t,t.config.dynamicSlots[i]);return t.status[i]=2|r}function ut(t,e){return 1&e?t.config.staticValues[e>>1]:t.values[e>>1]}const ft=$.define(),dt=$.define({combine:t=>t.some((t=>t)),static:!0}),pt=$.define({combine:t=>t.length?t[0]:void 0,static:!0}),gt=$.define(),mt=$.define(),vt=$.define(),wt=$.define({combine:t=>!!t.length&&t[0]});class yt{constructor(t,e){this.type=t,this.value=e}static define(){return new bt}}class bt{of(t){return new yt(this,t)}}class xt{constructor(t){this.map=t}of(t){return new kt(this,t)}}class kt{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 kt(this.type,e)}is(t){return this.type==t}static define(t={}){return new xt(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}}kt.reconfigure=kt.define(),kt.appendConfig=kt.define();class St{constructor(t,e,i,n,r,s){this.startState=t,this.changes=e,this.selection=i,this.effects=n,this.annotations=r,this.scrollIntoView=s,this._doc=null,this._state=null,i&&j(i,e.newLength),r.some((t=>t.type==St.time))||(this.annotations=r.concat(St.time.of(Date.now())))}static create(t,e,i,n,r,s){return new St(t,e,i,n,r,s)}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(St.userEvent);return!(!e||!(e==t||e.length>t.length&&e.slice(0,t.length)==t&&"."==e[t.length]))}}function At(t,e){let i=[];for(let n=0,r=0;;){let s,o;if(n=t[n]))s=t[n++],o=t[n++];else{if(!(r=0;r--){let s=i[r](t);s&&Object.keys(s).length&&(n=Mt(n,Ct(e,s,t.changes.newLength),!0))}return n==t?t:St.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(gt)){let e=n(t);if(!1===e){i=!1;break}Array.isArray(e)&&(i=!0===i?e:At(i,e))}if(!0!==i){let n,r;if(!1===i)r=t.changes.invertedDesc,n=N.empty(e.doc.length);else{let e=t.changes.filter(i);n=e.changes,r=e.filtered.mapDesc(e.changes).invertedDesc}t=St.create(e,n,t.selection&&t.selection.map(r),kt.mapEffects(t.effects,r),t.annotations,t.scrollIntoView)}let n=e.facet(mt);for(let i=n.length-1;i>=0;i--){let r=n[i](t);t=r instanceof St?r:Array.isArray(r)&&1==r.length&&r[0]instanceof St?r[0]:Ot(e,Tt(r),!1)}return t}(r):r)}St.time=yt.define(),St.userEvent=yt.define(),St.addToHistory=yt.define(),St.remote=yt.define();const Dt=[];function Tt(t){return null==t?Dt:Array.isArray(t)?t:[t]}var Et=function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t}(Et||(Et={}));const Rt=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let Pt;try{Pt=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch(t){}function Bt(t){return e=>{if(!/\S/.test(e))return Et.Space;if(function(t){if(Pt)return Pt.test(t);for(let e=0;e"€"&&(i.toUpperCase()!=i.toLowerCase()||Rt.test(i)))return!0}return!1}(e))return Et.Word;for(let i=0;i-1)return Et.Word;return Et.Other}}class Lt{constructor(t,e,i,n,r,s){this.config=t,this.doc=e,this.selection=i,this.values=n,this.status=t.statusTemplate.slice(),this.computeSlot=r,s&&(s._state=this);for(let t=0;tr.set(e,t))),i=null),r.set(e.value.compartment,e.value.extension)):e.is(kt.reconfigure)?(i=null,n=e.value):e.is(kt.appendConfig)&&(i=null,n=Tt(n).concat(e.value));if(i)e=t.startState.values.slice();else{i=at.resolve(n,r,this),e=new Lt(i,this.doc,this.selection,i.dynamicSlots.map((()=>null)),((t,e)=>e.reconfigure(t,this)),null).values}let s=t.startState.facet(dt)?t.newSelection:t.newSelection.asSingle();new Lt(i,t.newDoc,s,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:_.cursor(e.from+t.length)})))}changeByRange(t){let e=this.selection,i=t(e.ranges[0]),n=this.changes(i.changes),r=[i.range],s=Tt(i.effects);for(let i=1;ir.spec.fromJSON(s,t))))}return Lt.create({doc:t.doc,selection:_.fromJSON(t.selection),extensions:e.extensions?n.concat([e.extensions]):n})}static create(t={}){let e=at.resolve(t.extensions||[],new Map),i=t.doc instanceof c?t.doc:c.of((t.doc||"").split(e.staticFacet(Lt.lineSeparator)||P)),n=t.selection?t.selection instanceof _?t.selection:_.single(t.selection.anchor,t.selection.head):_.single(0);return j(n,i.length),e.staticFacet(dt)||(n=n.asSingle()),new Lt(e,i,n,e.dynamicSlots.map((()=>null)),((t,e)=>e.create(t)),null)}get tabSize(){return this.facet(Lt.tabSize)}get lineBreak(){return this.facet(Lt.lineSeparator)||"\n"}get readOnly(){return this.facet(wt)}phrase(t,...e){for(let e of this.facet(Lt.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 r of this.facet(ft))for(let s of r(this,e,i))Object.prototype.hasOwnProperty.call(s,t)&&n.push(s[t]);return n}charCategorizer(t){return Bt(this.languageDataAt("wordChars",t).join(""))}wordAt(t){let{text:e,from:i,length:n}=this.doc.lineAt(t),r=this.charCategorizer(t),s=t-i,o=t-i;for(;s>0;){let t=A(e,s,!1);if(r(e.slice(t,s))!=Et.Word)break;s=t}for(;ot.length?t[0]:4}),Lt.lineSeparator=pt,Lt.readOnly=wt,Lt.phrases=$.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]))}}),Lt.languageData=ft,Lt.changeFilter=gt,Lt.transactionFilter=mt,Lt.transactionExtender=vt,lt.reconfigure=kt.define();class It{eq(t){return this==t}range(t,e=t){return Vt.create(t,e,this)}}It.prototype.startSide=It.prototype.endSide=0,It.prototype.point=!1,It.prototype.mapMode=B.TrackDel;let Vt=class t{constructor(t,e,i){this.from=t,this.to=e,this.value=i}static create(e,i,n){return new t(e,i,n)}};function Ht(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class Wt{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 r=i?this.to:this.from;for(let s=n,o=r.length;;){if(s==o)return s;let n=s+o>>1,l=r[n]-t||(i?this.value[n].endSide:this.value[n].startSide)-e;if(n==s)return l>=0?s:o;l>=0?o=n:s=n+1}}between(t,e,i,n){for(let r=this.findIndex(e,-1e9,!0),s=this.findIndex(i,1e9,!1,r);ra||h==a&&c.startSide>0&&c.endSide<=0)continue;(a-h||c.endSide-c.startSide)<0||(s<0&&(s=h),c.point&&(o=Math.max(o,a-h)),i.push(c),n.push(h-s),r.push(a-s))}return{mapped:i.length?new Wt(n,r,i,o):null,pos:s}}}class zt{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 zt(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:r=this.length}=t,s=t.filter;if(0==e.length&&!s)return this;if(i&&(e=e.slice().sort(Ht)),this.isEmpty)return e.length?zt.of(e):this;let o=new _t(this,null,-1).goto(0),l=0,h=[],a=new Ft;for(;o.value||l=0){let t=e[l++];a.addInner(t.from,t.to,t.value)||h.push(t)}else 1==o.rangeIndex&&o.chunkIndexthis.chunkEnd(o.chunkIndex)||ro.to||r=r&&t<=r+s.length&&!1===s.between(r,t-r,e-r,i))return}this.nextLayer.between(t,e,i)}}iter(t=0){return jt.from([this]).goto(t)}get isEmpty(){return this.nextLayer==this}static iter(t,e=0){return jt.from(t).goto(e)}static compare(t,e,i,n,r=-1){let s=t.filter((t=>t.maxPoint>0||!t.isEmpty&&t.maxPoint>=r)),o=e.filter((t=>t.maxPoint>0||!t.isEmpty&&t.maxPoint>=r)),l=qt(s,o,i),h=new $t(s,l,r),a=new $t(o,l,r);i.iterGaps(((t,e,i)=>Ut(h,t,a,e,i,n))),i.empty&&0==i.length&&Ut(h,0,a,0,0,n)}static eq(t,e,i=0,n){null==n&&(n=999999999);let r=t.filter((t=>!t.isEmpty&&e.indexOf(t)<0)),s=e.filter((e=>!e.isEmpty&&t.indexOf(e)<0));if(r.length!=s.length)return!1;if(!r.length)return!0;let o=qt(r,s),l=new $t(r,o,0).goto(i),h=new $t(s,o,0).goto(i);for(;;){if(l.to!=h.to||!Gt(l.active,h.active)||l.point&&(!h.point||!l.point.eq(h.point)))return!1;if(l.to>n)return!0;l.next(),h.next()}}static spans(t,e,i,n,r=-1){let s=new $t(t,null,r).goto(e),o=e,l=s.openStart;for(;;){let t=Math.min(s.to,i);if(s.point){let i=s.activeForPoint(s.to),r=s.pointFromo&&(n.span(o,t,s.active,l),l=s.openEnd(t));if(s.to>i)return l+(s.point&&s.to>i?1:0);o=s.to,s.next()}}static of(t,e=!1){let i=new Ft;for(let n of t instanceof Vt?[t]:e?function(t){if(t.length>1)for(let e=t[0],i=1;i0)return t.slice().sort(Ht);e=n}return t}(t):t)i.add(n.from,n.to,n.value);return i.finish()}static join(t){if(!t.length)return zt.empty;let e=t[t.length-1];for(let i=t.length-2;i>=0;i--)for(let n=t[i];n!=zt.empty;n=n.nextLayer)e=new zt(n.chunkPos,n.chunk,e,Math.max(n.maxPoint,e.maxPoint));return e}}zt.empty=new zt([],[],null,-1),zt.empty.nextLayer=zt.empty;class Ft{finishChunk(t){this.chunks.push(new Wt(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 Ft)).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(zt.empty)}finishInner(t){if(this.from.length&&this.finishChunk(!1),0==this.chunks.length)return t;let e=zt.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(t):t,this.setMaxPoint);return this.from=null,e}}function qt(t,e,i){let n=new Map;for(let e of t)for(let t=0;t=this.minPoint)break}}}setRangeIndex(t){if(t==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex=i&&n.push(new _t(s,e,i,r));return 1==n.length?n[0]:new jt(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--)Kt(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--)Kt(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(),Kt(this.heap,0)}}}function Kt(t,e){for(let i=t[e];;){let n=1+(e<<1);if(n>=t.length)break;let r=t[n];if(n+1=0&&(r=t[n+1],n++),i.compare(r)<0)break;t[n]=i,t[e]=r,e=n}}class $t{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=jt.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){Jt(this.active,t),Jt(this.activeTo,t),Jt(this.activeRank,t),this.minActive=Xt(this.active,this.activeTo)}addActive(t){let e=0,{value:i,to:n,rank:r}=this.cursor;for(;e0;)e++;Yt(this.active,e,i),Yt(this.activeTo,e,n),Yt(this.activeRank,e,r),t&&Yt(t,e,this.cursor.from),this.minActive=Xt(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&&Jt(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=0&&i[e]=0&&!(this.activeRank[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 Ut(t,e,i,n,r,s){t.goto(e),i.goto(n);let o=n+r,l=n,h=n-e;for(;;){let e=t.to+h-i.to||t.endSide-i.endSide,n=e<0?t.to+h:i.to,r=Math.min(n,o);if(t.point||i.point?t.point&&i.point&&(t.point==i.point||t.point.eq(i.point))&&Gt(t.activeForPoint(t.to),i.activeForPoint(i.to))||s.comparePoint(l,r,t.point,i.point):r>l&&!Gt(t.active,i.active)&&s.compareRange(l,r,t.active,i.active),n>o)break;l=n,e<=0&&t.next(),e>=0&&i.next()}}function Gt(t,e){if(t.length!=e.length)return!1;for(let i=0;i=e;i--)t[i+1]=t[i];t[e]=i}function Xt(t,e){let i=-1,n=1e9;for(let r=0;r=e)return n;if(n==t.length)break;r+=9==t.charCodeAt(n)?i-r%i:1,n=A(t,n)}return!0===n?-1:t.length}const te="undefined"==typeof Symbol?"__ͼ":Symbol.for("ͼ"),ee="undefined"==typeof Symbol?"__styleSet"+Math.floor(1e8*Math.random()):Symbol("styleSet"),ie="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:{};class ne{constructor(t,e){this.rules=[];let{finish:i}=e||{};function n(t){return/^@/.test(t)?[t]:t.split(/,\s*/)}function r(t,e,s,o){let l=[],h=/^@(\w+)\b/.exec(t[0]),a=h&&"keyframes"==h[1];if(h&&null==e)return s.push(t[0]+";");for(let i in e){let o=e[i];if(/&/.test(i))r(i.split(/,\s*/).map((e=>t.map((t=>e.replace(/&/,t))))).reduce(((t,e)=>t.concat(e))),o,s);else if(o&&"object"==typeof o){if(!h)throw new RangeError("The value of a property ("+i+") should be a primitive value.");r(n(i),o,l,a)}else null!=o&&l.push(i.replace(/_.*/,"").replace(/[A-Z]/g,(t=>"-"+t.toLowerCase()))+": "+o+";")}(l.length||a)&&s.push((!i||h||o?t:t.map(i)).join(", ")+" {"+l.join(" ")+"}")}for(let e in t)r(n(e),t[e],this.rules)}getRules(){return this.rules.join("\n")}static newName(){let t=ie[te]||1;return ie[te]=t+1,"ͼ"+t.toString(36)}static mount(t,e,i){let n=t[ee],r=i&&i.nonce;n?r&&n.setNonce(r):n=new se(t,r),n.mount(Array.isArray(e)?e:[e],t)}}let re=new Map;class se{constructor(t,e){let i=t.ownerDocument||t,n=i.defaultView;if(!t.head&&t.adoptedStyleSheets&&n.CSSStyleSheet){let e=re.get(i);if(e)return t[ee]=e;this.sheet=new n.CSSStyleSheet,re.set(i,this)}else this.styleTag=i.createElement("style"),e&&this.styleTag.setAttribute("nonce",e);this.modules=[],t[ee]=this}mount(t,e){let i=this.sheet,n=0,r=0;for(let e=0;e-1&&(this.modules.splice(o,1),r--,o=-1),-1==o){if(this.modules.splice(r++,0,s),i)for(let t=0;t",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},he="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),ae="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),ce=0;ce<10;ce++)oe[48+ce]=oe[96+ce]=String(ce);for(ce=1;ce<=24;ce++)oe[ce+111]="F"+ce;for(ce=65;ce<=90;ce++)oe[ce]=String.fromCharCode(ce+32),le[ce]=String.fromCharCode(ce);for(var ue in oe)le.hasOwnProperty(ue)||(le[ue]=oe[ue]);function fe(t){let e;return e=11==t.nodeType?t.getSelection?t:t.ownerDocument:t,e.getSelection()}function de(t,e){return!!e&&(t==e||t.contains(1!=e.nodeType?e.parentNode:e))}function pe(t,e){if(!e.anchorNode)return!1;try{return de(t,e.anchorNode)}catch(t){return!1}}function ge(t){return 3==t.nodeType?De(t,0,t.nodeValue.length).getClientRects():1==t.nodeType?t.getClientRects():[]}function me(t,e,i,n){return!!i&&(ye(t,e,i,n,-1)||ye(t,e,i,n,1))}function ve(t){for(var e=0;;e++)if(!(t=t.previousSibling))return e}function we(t){return 1==t.nodeType&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}function ye(t,e,i,n,r){for(;;){if(t==i&&e==n)return!0;if(e==(r<0?0:be(t))){if("DIV"==t.nodeName)return!1;let i=t.parentNode;if(!i||1!=i.nodeType)return!1;e=ve(t)+(r<0?0:1),t=i}else{if(1!=t.nodeType)return!1;if(1==(t=t.childNodes[e+(r<0?-1:0)]).nodeType&&"false"==t.contentEditable)return!1;e=r<0?be(t):0}}}function be(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function xe(t,e){let i=e?t.left:t.right;return{left:i,right:i,top:t.top,bottom:t.bottom}}function ke(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 Se(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 Ae{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?be(e):0),i,Math.min(t.focusOffset,i?be(i):0))}set(t,e,i,n){this.anchorNode=t,this.anchorOffset=e,this.focusNode=i,this.focusOffset=n}}let Me,Ce=null;function Oe(t){if(t.setActive)return t.setActive();if(Ce)return t.focus(Ce);let e=[];for(let i=t;i&&(e.push(i,i.scrollTop,i.scrollLeft),i!=i.ownerDocument);i=i.parentNode);if(t.focus(null==Ce?{get preventScroll(){return Ce={preventScroll:!0},!0}}:void 0),!Ce){Ce=!1;for(let t=0;tMath.max(1,t.scrollHeight-t.clientHeight-4)}function Pe(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=be(i)}else{if(!i.parentNode||we(i))return null;n=ve(i),i=i.parentNode}}}function Be(t,e){for(let i=t,n=e;;){if(3==i.nodeType&&ne)return i.domBoundsAround(t,e,h);if(c>=t&&-1==n&&(n=l,r=h),h>e&&i.dom.parentNode==this.dom){s=l,o=a;break}a=c,h=c+i.breakAfter}return{from:r,to:o<0?i+this.length:o,startDOM:(n?this.children[n-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:s=0?this.children[s].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=Ne){this.markDirty();for(let n=t;nthis.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 We(t,e,i,n,r,s,o,l,h){let{children:a}=t,c=a.length?a[e]:null,u=s.length?s[s.length-1]:null,f=u?u.breakAfter:o;if(!(e==n&&c&&!o&&!f&&s.length<2&&c.merge(i,r,s.length?u:null,0==i,l,h))){if(n0&&(!o&&s.length&&c.merge(i,c.length,s[0],!1,l,0)?c.breakAfter=s.shift().breakAfter:(i2);var Qe={mac:Xe||/Mac/.test(Fe.platform),windows:/Win/.test(Fe.platform),linux:/Linux|X11/.test(Fe.platform),ie:$e,ie_version:je?qe.documentMode||6:Ke?+Ke[1]:_e?+_e[1]:0,gecko:Ue,gecko_version:Ue?+(/Firefox\/(\d+)/.exec(Fe.userAgent)||[0,0])[1]:0,chrome:!!Ge,chrome_version:Ge?+Ge[1]:0,ios:Xe,android:/Android\b/.test(Fe.userAgent),webkit:Je,safari:Ye,webkit_version:Je?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0,tabSize:null!=qe.documentElement.style.tabSize?"tab-size":"-moz-tab-size"};class Ze extends Ie{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 Ze)||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 Ze(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 Le(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 r=e,s=e,o=0;0==e&&i<0||e==n&&i>=0?Qe.chrome||Qe.gecko||(e?(r--,o=1):s=0)?0:l.length-1];Qe.safari&&!o&&0==h.width&&(h=Array.prototype.find.call(l,(t=>t.width))||h);return o?xe(h,o<0):h||null}(this.dom,t,e)}}class ti extends Ie{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(Ee(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,r,s){return(!i||!(!(i instanceof ti&&i.mark.eq(this.mark))||t&&r<=0||et&&e.push(i=t&&(n=r),i=o,r++}let s=this.length-t;return this.length=t,n>-1&&(this.children.length=n,this.markDirty()),new ti(this.mark,e,s)}domAtPos(t){return ni(this,t)}coordsAt(t,e){return si(this,t,e)}}class ei extends Ie{static create(t,e,i){return new ei(t,e,i)}constructor(t,e,i){super(),this.widget=t,this.length=e,this.side=i,this.prevWidget=null}split(t){let e=ei.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,r,s){return!(i&&(!(i instanceof ei&&this.widget.compare(i.widget))||t>0&&r<=0||e0)?Le.before(this.dom):Le.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(),r=null;if(!n.length)return null;let s=this.side?this.side<0:t>0;for(let e=s?n.length-1:0;r=n[e],!(t>0?0==e:e==n.length-1||r.top0?Le.before(this.dom):Le.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(t){return this.dom.getBoundingClientRect()}get overrideDOMText(){return c.empty}get isHidden(){return!0}}function ni(t,e){let i=t.dom,{children:n}=t,r=0;for(let t=0;rt&&e0;t--){let e=n[t-1];if(e.dom.parentNode==i)return e.domAtPos(e.length)}for(let t=r;t0&&e instanceof ti&&r.length&&(n=r[r.length-1])instanceof ti&&n.mark.eq(e.mark)?ri(n,e.children[0],i-1):(r.push(e),e.setParent(t)),t.length+=e.length}function si(t,e,i){let n=null,r=-1,s=null,o=-1;!function t(e,l){for(let h=0,a=0;h=l&&(c.children.length?t(c,l-a):(!s||s.isHidden&&i>0)&&(u>l||a==u&&c.getSide()>0)?(s=c,o=l-a):(a-1?1:0)!=r.length-(i&&r.indexOf(i)>-1?1:0))return!1;for(let s of n)if(s!=i&&(-1==r.indexOf(s)||t[s]!==e[s]))return!1;return!0}function ai(t,e,i){let n=!1;if(e)for(let r in e)i&&r in i||(n=!0,"style"==r?t.style.cssText="":t.removeAttribute(r));if(i)for(let r in i)e&&e[r]==i[r]||(n=!0,"style"==r?t.style.cssText=i[r]:t.setAttribute(r,i[r]));return n}function ci(t){let e=Object.create(null);for(let i=0;i0&&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){hi(this.attrs,t)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=t)}append(t,e){ri(this,t,e)}addLineDeco(t){let e=t.spec.attributes,i=t.spec.class;e&&(this.attrs=oi(e,this.attrs||{})),i&&(this.attrs=oi({class:i},this.attrs||{}))}domAtPos(t){return ni(this,t)}reuseDOM(t){"DIV"==t.nodeName&&(this.setDOM(t),this.flags|=6)}sync(t,e){var i;this.dom?4&this.flags&&(Ee(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&&(ai(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&&Ie.get(n)instanceof ti;)n=n.lastChild;if(!(n&&this.length&&("BR"==n.nodeName||0!=(null===(i=Ie.get(n))||void 0===i?void 0:i.isEditable)||Qe.ios&&this.children.some((t=>t instanceof Ze))))){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 Ze)||/[^ -~]/.test(i.text))return null;let n=ge(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=si(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){if(r instanceof ui)return r;if(s>e)break}n=s+r.breakAfter}return null}}class fi extends Ie{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,r,s){return!(i&&(!(i instanceof fi&&this.widget.compare(i.widget))||t>0&&r<=0||e0)}}class di{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 pi=function(t){return t[t.Text=0]="Text",t[t.WidgetBefore=1]="WidgetBefore",t[t.WidgetAfter=2]="WidgetAfter",t[t.WidgetRange=3]="WidgetRange",t}(pi||(pi={}));class gi extends It{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 mi(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 wi(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:r,end:s}=yi(t,n);e=(r?n?-3e8:-1:5e8)-1,i=1+(s?n?2e8:1:-6e8)}return new wi(t,e,i,n,t.widget||null,!0)}static line(t){return new vi(t)}static set(t,e=!1){return zt.of(t,e)}hasHeight(){return!!this.widget&&this.widget.estimatedHeight>-1}}gi.none=zt.empty;class mi extends gi{constructor(t){let{start:e,end:i}=yi(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 mi&&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))&&hi(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)}}mi.prototype.point=!1;class vi extends gi{constructor(t){super(-2e8,-2e8,null,t)}eq(t){return t instanceof vi&&this.spec.class==t.spec.class&&hi(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)}}vi.prototype.mapMode=B.TrackBefore,vi.prototype.point=!0;class wi extends gi{constructor(t,e,i,n,r,s){super(e,i,r,t),this.block=n,this.isReplace=s,this.mapMode=n?e<=0?B.TrackBefore:B.TrackAfter:B.TrackDel}get type(){return this.startSide!=this.endSide?pi.WidgetRange:this.startSide<=0?pi.WidgetBefore:pi.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(t){return t instanceof wi&&(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 yi(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 bi(t,e,i,n=0){let r=i.length-1;r>=0&&i[r]+n>=t?i[r]=Math.max(i[r],e):i.push(t,e)}wi.prototype.point=!0;class xi{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 fi&&t.deco.endSide<0)}getLine(){return this.curLine||(this.content.push(this.curLine=new ui),this.atCursorPos=!0),this.curLine}flushBuffer(t=this.bufferMarks){this.pendingBuffer&&(this.curLine.append(ki(new ii(-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 fi||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,512);this.flushBuffer(e.slice(e.length-i)),this.getLine().append(ki(new Ze(this.text.slice(this.textOff,this.textOff+n)),e),i),this.atCursorPos=!0,this.textOff+=n,t-=n,i=0}}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,r,s){if(this.disallowBlockEffectsFor[s]&&i instanceof wi){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 o=e-t;if(i instanceof wi)if(i.block)i.startSide>0&&!this.posCovered()&&this.getLine(),this.addBlockWidget(new fi(i.widget||Si.block,o,i));else{let s=ei.create(i.widget||Si.inline,o,o?0:i.startSide),l=this.atCursorPos&&!s.isEditable&&r<=n.length&&(t0),h=!s.isEditable&&(tn.length||i.startSide<=0),a=this.getLine();2!=this.pendingBuffer||l||s.isEditable||(this.pendingBuffer=0),this.flushBuffer(n),l&&(a.append(ki(new ii(1),n),r),r=n.length+Math.max(0,r-n.length)),a.append(ki(s,n),r),this.atCursorPos=h,this.pendingBuffer=h?tn.length?1:2:0,this.pendingBuffer&&(this.bufferMarks=n.slice())}else this.doc.lineAt(this.pos).from==this.pos&&this.getLine().addLineDeco(i);o&&(this.textOff+o<=this.text.length?this.textOff+=o:(this.skip+=o-(this.text.length-this.textOff),this.text="",this.textOff=0),this.pos=e),this.openStart<0&&(this.openStart=r)}static build(t,e,i,n,r){let s=new xi(t,e,i,r);return s.openEnd=zt.spans(n,e,i,s),s.openStart<0&&(s.openStart=s.openEnd),s.finish(s.openEnd),s}}function ki(t,e){for(let i of e)t=new ti(i,[t],t.length);return t}class Si extends di{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}}Si.inline=new Si("span"),Si.block=new Si("div"),exports.Direction=function(t){return t[t.LTR=0]="LTR",t[t.RTL=1]="RTL",t}(exports.Direction||(exports.Direction={}));const Ai=exports.Direction.LTR,Mi=exports.Direction.RTL;function Ci(t){let e=[];for(let i=0;i=e){if(o.level==i)return s;(r<0||(0!=n?n<0?o.frome:t[r].level>o.level))&&(r=s)}}if(r<0)throw new RangeError("Index out of range");return r}}function Li(t,e){if(t.length!=e.length)return!1;for(let i=0;ih&&o.push(new Bi(h,p.from,f)),Vi(t,p.direction==Ai!=!(f%2)?n+1:n,r,p.inner,p.from,p.to,o),h=p.to}d=p.to}else{if(d==i||(e?Ni[d]!=l:Ni[d]==l))break;d++}u?Ii(t,h,d,n+1,r,u,o):he;){let i=!0,c=!1;if(!a||h>s[a-1].to){let t=Ni[h-1];t!=l&&(i=!1,c=16==t)}let u=i||1!=l?null:[],f=i?n:n+1,d=h;t:for(;;)if(a&&d==s[a-1].to){if(c)break t;let p=s[--a];if(!i)for(let t=p.from,i=a;;){if(t==e)break t;if(!i||s[i-1].to!=t){if(Ni[t-1]==l)break t;break}t=s[--i].from}if(u)u.push(p);else{p.to=0;t-=3)if(Ei[t+1]==-i){let e=Ei[t+2],i=2&e?r:4&e?1&e?s:r:0;i&&(Ni[o]=Ni[Ei[t]]=i),l=t;break}}else{if(189==Ei.length)break;Ei[l++]=o,Ei[l++]=e,Ei[l++]=h}else if(2==(n=Ni[o])||1==n){let t=n==r;h=t?0:1;for(let e=l-3;e>=0;e-=3){let i=Ei[e+2];if(2&i)break;if(t)Ei[e+2]|=2;else{if(4&i)break;Ei[e+2]|=4}}}}}(t,r,s,n,l),function(t,e,i,n){for(let r=0,s=n;r<=i.length;r++){let o=r?i[r-1].to:t,l=rh;)e==s&&(e=i[--n].from,s=n?i[n-1].to:t),Ni[--e]=c;h=o}else s=o,h++}}}(r,s,n,l),Ii(t,r,s,e,i,n,o)}function Hi(t){return[new Bi(0,t,0)]}let Wi="";function zi(t,e,i,n,r){var s;let o=n.head-t.from,l=Bi.find(e,o,null!==(s=n.bidiLevel)&&void 0!==s?s:-1,n.assoc),h=e[l],a=h.side(r,i);if(o==a){let t=l+=r?1:-1;if(t<0||t>=e.length)return null;h=e[l=t],o=h.side(!r,i),a=h.side(r,i)}let c=A(t.text,o,h.forward(r,i));(ch.to)&&(c=a),Wi=t.text.slice(Math.min(o,c),Math.max(o,c));let u=l==(r?e.length-1:0)?null:e[l+(r?1:-1)];return u&&c==a&&u.level+(r?0:1)t.some((t=>t))}),Yi=$.define({combine:t=>t.some((t=>t))}),Xi=$.define();class Qi{constructor(t,e="nearest",i="nearest",n=5,r=5,s=!1){this.range=t,this.y=e,this.x=i,this.yMargin=n,this.xMargin=r,this.isSnapshot=s}map(t){return t.empty?this:new Qi(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 Qi(_.cursor(t.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const Zi=kt.define({map:(t,e)=>t.map(e)});function tn(t,e,i){let n=t.facet(Ki);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 en=$.define({combine:t=>!t.length||t[0]});let nn=0;const rn=$.define();class sn{constructor(t,e,i,n,r){this.id=t,this.create=e,this.domEventHandlers=i,this.domEventObservers=n,this.extension=r(this)}static define(t,e){const{eventHandlers:i,eventObservers:n,provide:r,decorations:s}=e||{};return new sn(nn++,t,i,n,(t=>{let e=[rn.of(t)];return s&&e.push(an.of((e=>{let i=e.plugin(t);return i?s(i):gi.none}))),r&&e.push(r(t)),e}))}static fromClass(t,e){return sn.define((e=>new t(e)),e)}}class on{constructor(t){this.spec=t,this.mustUpdate=null,this.value=null}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(tn(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.create(t)}catch(e){tn(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){tn(t.state,e,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const ln=$.define(),hn=$.define(),an=$.define(),cn=$.define(),un=$.define(),fn=$.define();function dn(t,e){let i=t.state.facet(fn);if(!i.length)return i;let n=i.map((e=>e instanceof Function?e(t):e)),r=[];return zt.spans(n,e.from,e.to,{point(){},span(t,i,n,s){let o=t-e.from,l=i-e.from,h=r;for(let t=n.length-1;t>=0;t--,s--){let i,r=n[t].spec.bidiIsolate;if(null==r&&(r=Fi(e.text,o,l)),s>0&&h.length&&(i=h[h.length-1]).to==o&&i.direction==r)i.to=l,h=i.inner;else{let t={from:o,to:l,direction:r,inner:[]};h.push(t),h=t.inner}}}}),r}const pn=$.define();function gn(t){let e=0,i=0,n=0,r=0;for(let s of t.state.facet(pn)){let o=s(t);o&&(null!=o.left&&(e=Math.max(e,o.left)),null!=o.right&&(i=Math.max(i,o.right)),null!=o.top&&(n=Math.max(n,o.top)),null!=o.bottom&&(r=Math.max(r,o.bottom)))}return{left:e,right:i,top:n,bottom:r}}const mn=$.define();class vn{constructor(t,e,i,n){this.fromA=t,this.toA=e,this.fromB=i,this.toB=n}join(t){return new vn(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.toAa)break;r+=2}if(!l)return i;new vn(l.fromA,l.toA,l.fromB,l.toB).addToSet(i),s=l.toA,o=l.toB}}}class wn{constructor(t,e,i){this.view=t,this.state=e,this.transactions=i,this.flags=0,this.startState=t.state,this.changes=N.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,r)=>n.push(new vn(t,e,i,r)))),this.changedRanges=n}static create(t,e,i){return new wn(t,e,i)}get viewportChanged(){return(4&this.flags)>0}get heightChanged(){return(2&this.flags)>0}get geometryChanged(){return this.docChanged||(10&this.flags)>0}get focusChanged(){return(1&this.flags)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some((t=>t.selection))}get empty(){return 0==this.flags&&0==this.transactions.length}}class yn extends Ie{get length(){return this.view.state.doc.length}constructor(t){super(),this.view=t,this.decorations=[],this.dynamicDecorationMap=[],this.domChanged=null,this.hasComposition=null,this.markedForComposition=new Set,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 ui],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new vn(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})=>ethis.minWidthTo))?(this.minWidthFrom=t.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=t.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0);let n=-1;this.view.inputState.composing>=0&&((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)=>{te.from&&(i=!0)}));return i}(t.changes,this.hasComposition)||t.selectionSet||(n=t.state.selection.main.head));let r=n>-1?function(t,e,i){let n=xn(t,i);if(!n)return null;let{node:r,from:s,to:o}=n,l=r.nodeValue;if(/[\n\r]/.test(l))return null;if(t.state.doc.sliceString(n.from,n.to)!=l)return null;let h=e.invertedDesc,a=new vn(h.mapPos(s),h.mapPos(o),s,o),c=[];for(let e=r.parentNode;;e=e.parentNode){let i=Ie.get(e);if(i instanceof ti)c.push({node:e,deco:i.mark});else{if(i instanceof ui||"DIV"==e.nodeName&&e.parentNode==t.contentDOM)return{range:a,text:r,marks:c,line:e};if(e==t.contentDOM)return null;c.push({node:e,deco:new mi({inclusive:!0,attributes:ci(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 vn(e,n,t.changes.mapPos(e,-1),t.changes.mapPos(n,1)).addToSet(i.slice())}this.hasComposition=r?{from:r.range.fromB,to:r.range.toB}:null,(Qe.ie||Qe.chrome)&&!r&&t&&t.state.doc.lines!=t.startState.doc.lines&&(this.forceSelection=!0);let s=function(t,e,i){let n=new kn;return zt.compare(t,e,i,n),n.changes}(this.decorations,this.updateDeco(),t.changes);return i=vn.extendWithRanges(i,s),!!(7&this.flags||0!=i.length)&&(this.updateInner(i,t.startState.doc.length,r),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=Qe.chrome||Qe.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 r=[];if(this.view.viewport.from||this.view.viewport.to=0?n[t]:null;if(!e)break;let s,o,l,h,{fromA:a,toA:c,fromB:u,toB:f}=e;if(i&&i.range.fromBu){let t=xi.build(this.view.state.doc,u,i.range.fromB,this.decorations,this.dynamicDecorationMap),e=xi.build(this.view.state.doc,i.range.toB,f,this.decorations,this.dynamicDecorationMap);o=t.breakAtStart,l=t.openStart,h=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(),s=t.content.concat(n).concat(e.content)}else({content:s,breakAtStart:o,openStart:l,openEnd:h}=xi.build(this.view.state.doc,u,f,this.decorations,this.dynamicDecorationMap));let{i:d,off:p}=r.findPos(c,1),{i:g,off:m}=r.findPos(a,-1);We(this,g,m,d,p,s,o,l,h)}i&&this.fixCompositionDOM(i)}compositionView(t){let e=new Ze(t.text.nodeValue);e.flags|=8;for(let{deco:i}of t.marks)e=new ti(i,[e],e.length);let i=new ui;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=Ie.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 r=t.marks.length-1;r>=-1;r--)i=n.childPos(i.off,1),n=n.children[i.i],e(r>=0?t.marks[r].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,r=!n&&pe(this.dom,this.view.observer.selectionRange)&&!(i&&this.dom.contains(i));if(!(n||e||r))return;let s=this.forceSelection;this.forceSelection=!1;let o=this.view.state.selection.main,l=this.moveToLine(this.domAtPos(o.anchor)),h=o.empty?l:this.moveToLine(this.domAtPos(o.head));if(Qe.gecko&&o.empty&&!this.hasComposition&&(1==(a=l).node.nodeType&&a.node.firstChild&&(0==a.offset||"false"==a.node.childNodes[a.offset-1].contentEditable)&&(a.offset==a.node.childNodes.length||"false"==a.node.childNodes[a.offset].contentEditable))){let t=document.createTextNode("");this.view.observer.ignore((()=>l.node.insertBefore(t,l.node.childNodes[l.offset]||null))),l=h=new Le(t,0),s=!0}var a;let c=this.view.observer.selectionRange;!s&&c.focusNode&&(me(l.node,l.offset,c.anchorNode,c.anchorOffset)&&me(h.node,h.offset,c.focusNode,c.focusOffset)||this.suppressWidgetCursorChange(c,o))||(this.view.observer.ignore((()=>{Qe.android&&Qe.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=fe(this.view.root);if(t)if(o.empty){if(Qe.gecko){let t=(e=l.node,n=l.offset,1!=e.nodeType?0:(n&&"false"==e.childNodes[n-1].contentEditable?1:0)|(no.head&&([l,h]=[h,l]),e.setEnd(h.node,h.offset),e.setStart(l.node,l.offset),t.removeAllRanges(),t.addRange(e)}else;var e,n;r&&this.view.root.activeElement==this.dom&&(this.dom.blur(),i&&i.focus())})),this.view.observer.setSelectionRange(l,h)),this.impreciseAnchor=l.precise?null:new Le(c.anchorNode,c.anchorOffset),this.impreciseHead=h.precise?null:new Le(c.focusNode,c.focusOffset)}suppressWidgetCursorChange(t,e){return this.hasComposition&&e.empty&&me(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=fe(t.root),{anchorNode:n,anchorOffset:r}=t.observer.selectionRange;if(!(i&&e.empty&&e.assoc&&i.modify))return;let s=ui.find(this,e.head);if(!s)return;let o=s.posAtStart;if(e.head==o||e.head==o+s.length)return;let l=this.coordsAt(e.head,-1),h=this.coordsAt(e.head,1);if(!l||!h||l.bottom>h.top)return;let a=this.domAtPos(e.head+e.assoc);i.collapse(a.node,a.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,r)}moveToLine(t){let e,i=this.dom;if(t.node!=i)return t;for(let n=t.offset;!e&&n=0;n--){let t=Ie.get(i.childNodes[n]);t instanceof ui&&(e=t.domAtPos(t.length))}return e?new Le(e.node,e.offset,!0):t}nearest(t){for(let e=t;e;){let t=Ie.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=0;s--){let o=this.children[s],l=r-o.breakAfter,h=l-o.length;if(lt||o.covers(1))&&(!i||o instanceof ui&&!(i instanceof ui&&e>=0))&&(i=o,n=h),r=h}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 ui))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 Ze))return null;let r=A(n.text,i);if(r==i)return null;let s=De(n.dom,i,r).getClientRects();for(let t=0;tMath.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,o=-1,l=this.view.textDirection==exports.Direction.LTR;for(let t=0,h=0;hn)break;if(t>=i){let i=a.dom.getBoundingClientRect();if(e.push(i.height),s){let e=a.dom.lastChild,n=e?ge(e):[];if(n.length){let e=n[n.length-1],s=l?e.right-i.left:i.right-e.left;s>o&&(o=s,this.minWidth=r,this.minWidthFrom=t,this.minWidthTo=c)}}}t=c+a.breakAfter}return e}textDirectionAt(t){let{i:e}=this.childPos(t,1);return"rtl"==getComputedStyle(this.children[e].dom).direction?exports.Direction.RTL:exports.Direction.LTR}measureTextSize(){for(let t of this.children)if(t instanceof ui){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 r=ge(n.firstChild)[0];t=n.getBoundingClientRect().height,e=r?r.width/27:7,i=r?r.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 He(this.children,t,e)}computeBlockGapDeco(){let t=[],e=this.view.viewState;for(let i=0,n=0;;n++){let r=n==e.viewports.length?null:e.viewports[n],s=r?r.from-1:this.length;if(s>i){let n=(e.lineBlockAt(s).bottom-e.lineBlockAt(i).top)/this.view.scaleY;t.push(gi.replace({widget:new bn(n),block:!0,inclusive:!0,isBlockGap:!0}).range(i,s))}if(!r)break;i=r.to+1}return gi.set(t)}updateDeco(){let t=0,e=this.view.state.facet(an).map((e=>(this.dynamicDecorationMap[t++]="function"==typeof e)?e(this.view):e)),i=!1,n=this.view.state.facet(cn).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(zt.join(n))),this.decorations=[...e,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];ti.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 r=gn(this.view),s={left:n.left-r.left,top:n.top-r.top,right:n.right+r.right,bottom:n.bottom+r.bottom},{offsetWidth:o,offsetHeight:l}=this.view.scrollDOM;!function(t,e,i,n,r,s,o,l){let h=t.ownerDocument,a=h.defaultView||window;for(let c=t,u=!1;c&&!u;)if(1==c.nodeType){let t,f=c==h.body,d=1,p=1;if(f)t=ke(a);else{if(/^(fixed|sticky)$/.test(getComputedStyle(c).position)&&(u=!0),c.scrollHeight<=c.clientHeight&&c.scrollWidth<=c.clientWidth){c=c.assignedSlot||c.parentNode;continue}let e=c.getBoundingClientRect();({scaleX:d,scaleY:p}=Se(c,e)),t={left:e.left,right:e.left+c.clientWidth*d,top:e.top,bottom:e.top+c.clientHeight*p}}let g=0,m=0;if("nearest"==r)e.top0&&e.bottom>t.bottom+m&&(m=e.bottom-t.bottom+m+o)):e.bottom>t.bottom&&(m=e.bottom-t.bottom+o,i<0&&e.top-m0&&e.right>t.right+g&&(g=e.right-t.right+g+s)):e.right>t.right&&(g=e.right-t.right+s,i<0&&e.leftt?e.left-t:Math.max(0,t-e.right)}function An(t,e){return e.top>t?e.top-t:Math.max(0,t-e.bottom)}function Mn(t,e){return t.tope.top+1}function Cn(t,e){return et.bottom?{top:t.top,left:t.left,right:t.right,bottom:e}:t}function Dn(t,e,i){let n,r,s,o,l,h,a,c,u=!1;for(let f=t.firstChild;f;f=f.nextSibling){let t=ge(f);for(let d=0;dm||o==m&&s>g){n=f,r=p,s=g,o=m;let l=m?i0?d0)}0==g?i>p.bottom&&(!a||a.bottomp.top)&&(h=f,c=p):a&&Mn(a,p)?a=On(a,p.bottom):c&&Mn(c,p)&&(c=Cn(c,p.top))}}if(a&&a.bottom>=i?(n=l,r=a):c&&c.top<=i&&(n=h,r=c),!n)return{node:t,offset:0};let f=Math.max(r.left,Math.min(r.right,e));return 3==n.nodeType?Tn(n,f,i):u&&"false"!=n.contentEditable?Dn(n,f,i):{node:t,offset:Array.prototype.indexOf.call(t.childNodes,n)+(e>=(r.left+r.right)/2?1:0)}}function Tn(t,e,i){let n=t.nodeValue.length,r=-1,s=1e9,o=0;for(let l=0;li?a.top-i:i-a.bottom)-1;if(a.left-1<=e&&a.right+1>=e&&c=(a.left+a.right)/2,n=i;if(Qe.chrome||Qe.gecko){De(t,l).getBoundingClientRect().left==a.right&&(n=!i)}if(c<=0)return{node:t,offset:l+(n?1:0)};r=l+(n?1:0),s=c}}}return{node:t,offset:r>-1?r:o>0?t.nodeValue.length:0}}function En(t,e,i,n=-1){var r,s;let o,l=t.contentDOM.getBoundingClientRect(),h=l.top+t.viewState.paddingTop,{docHeight:a}=t.viewState,{x:c,y:u}=e,f=u-h;if(f<0)return 0;if(f>a)return t.state.doc.length;for(let e=t.viewState.heightOracle.textHeight/2,r=!1;o=t.elementAtHeight(f),o.type!=pi.Text;)for(;f=n>0?o.bottom+e:o.top-e,!(f>=0&&f<=a);){if(r)return i?null:0;r=!0,n=-n}u=h+f;let d=o.from;if(dt.viewport.to)return t.viewport.to==t.state.doc.length?t.state.doc.length:i?null:Rn(t,l,o,c,u);let p=t.dom.ownerDocument,g=t.root.elementFromPoint?t.root:p,m=g.elementFromPoint(c,u);m&&!t.contentDOM.contains(m)&&(m=null),m||(c=Math.max(l.left+1,Math.min(l.right-1,c)),m=g.elementFromPoint(c,u),m&&!t.contentDOM.contains(m)&&(m=null));let v,w=-1;if(m&&0!=(null===(r=t.docView.nearest(m))||void 0===r?void 0:r.isEditable))if(p.caretPositionFromPoint){let t=p.caretPositionFromPoint(c,u);t&&({offsetNode:v,offset:w}=t)}else if(p.caretRangeFromPoint){let e=p.caretRangeFromPoint(c,u);e&&(({startContainer:v,startOffset:w}=e),(!t.contentDOM.contains(v)||Qe.safari&&function(t,e,i){let n;if(3!=t.nodeType||e!=(n=t.nodeValue.length))return!1;for(let e=t.nextSibling;e;e=e.nextSibling)if(1!=e.nodeType||"BR"!=e.nodeName)return!1;return De(t,n-1,n).getBoundingClientRect().left>i}(v,w,c)||Qe.chrome&&function(t,e,i){if(0!=e)return!1;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():De(t,0,Math.max(t.nodeValue.length,1)).getBoundingClientRect();return i-n.left>5}(v,w,c))&&(v=void 0))}if(!v||!t.docView.dom.contains(v)){let e=ui.find(t.docView,d);if(!e)return f>o.top+o.height/2?o.to:o.from;({node:v,offset:w}=Dn(e.dom,c,u))}let y=t.docView.nearest(v);if(!y)return null;if(y.isWidget&&1==(null===(s=y.dom)||void 0===s?void 0:s.nodeType)){let t=y.dom.getBoundingClientRect();return e.y1.5*t.defaultLineHeight){let e=t.viewState.heightOracle.textHeight;s+=Math.floor((r-i.top-.5*(t.defaultLineHeight-e))/e)*t.viewState.heightOracle.lineLength}let o=t.state.sliceDoc(i.from,i.to);return i.from+Zt(o,s,t.state.tabSize)}function Pn(t,e){let i=t.lineBlockAt(e);if(Array.isArray(i.type))for(let t of i.type)if(t.to>e||t.to==e&&(t.to==i.to||t.type==pi.Text))return t;return i}function Bn(t,e,i,n){let r=t.state.doc.lineAt(e.head),s=t.bidiSpans(r),o=t.textDirectionAt(r.from);for(let l=e,h=null;;){let e=zi(r,s,o,l,i),a=Wi;if(!e){if(r.number==(i?t.state.doc.lines:1))return l;a="\n",r=t.state.doc.line(r.number+(i?1:-1)),s=t.bidiSpans(r),e=t.visualLineSide(r,!i)}if(h){if(!h(a))return l}else{if(!n)return e;h=n(a)}l=e}}function Ln(t,e,i){for(;;){let n=0;for(let r of t)r.between(e-1,e+1,((t,r,s)=>{if(e>t&&ee(t))),i.from,e.head>i.from?-1:1);return n==i.from?i:_.cursor(n,nnull)),Qe.gecko&&function(t){ar.has(t)||(ar.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=Ie.get(n))&&i.ignoreEvent(e))return!1;return!0})(this.view,t)&&!this.ignoreDuringComposition(t)&&("keydown"==t.type&&this.keydown(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=Hn(t),i=this.handlers,n=this.view.contentDOM;for(let t in e)if("scroll"!=t){let r=!e[t].handlers.length,s=i[t];s&&r!=!s.handlers.length&&(n.removeEventListener(t,this.handleEvent),s=null),s||n.addEventListener(t,this.handleEvent,{passive:r})}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&&Date.now()e.keyCode==t.keyCode)))&&!t.ctrlKey||zn.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.from0||!!(Qe.safari&&!Qe.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.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 Vn(t,e){return(i,n)=>{try{return e.call(t,n,i)}catch(t){tn(i.state,t)}}}function Hn(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;if(t&&t.domEventHandlers)for(let n in t.domEventHandlers){let r=t.domEventHandlers[n];r&&i(n).handlers.push(Vn(e.value,r))}if(t&&t.domEventObservers)for(let n in t.domEventObservers){let r=t.domEventObservers[n];r&&i(n).observers.push(Vn(e.value,r))}}for(let t in jn)i(t).handlers.push(jn[t]);for(let t in Kn)i(t).observers.push(Kn[t]);return e}const Wn=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],zn="dthko",Fn=[16,17,18,20,91,92,224,225];function qn(t){return.7*Math.max(0,t)+8}class _n{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.scrollParent=function(t){let e=t.ownerDocument;for(let i=t.parentNode;i&&i!=e.body;)if(1==i.nodeType){if(i.scrollHeight>i.clientHeight||i.scrollWidth>i.clientWidth)return i;i=i.assignedSlot||i.parentNode}else{if(11!=i.nodeType)break;i=i.host}return null}(t.contentDOM),this.atoms=t.state.facet(un).map((e=>e(t)));let r=t.contentDOM.ownerDocument;r.addEventListener("mousemove",this.move=this.move.bind(this)),r.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=e.shiftKey,this.multiple=t.state.facet(Lt.allowMultipleSelections)&&function(t,e){let i=t.state.facet(qi);return i.length?i[0](e):Qe.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=fe(t.root);if(!n||0==n.rangeCount)return!0;let r=n.getRangeAt(0).getClientRects();for(let t=0;t=e.clientX&&i.top<=e.clientY&&i.bottom>=e.clientY)return!0}return!1}(t,e)||1!=nr(e))&&null}start(t){!1===this.dragging&&this.select(t)}move(t){var e,i,n;if(0==t.buttons)return this.destroy();if(this.dragging||null==this.dragging&&(i=this.startEvent,n=t,Math.max(Math.abs(i.clientX-n.clientX),Math.abs(i.clientY-n.clientY))<10))return;this.select(this.lastEvent=t);let r=0,s=0,o=(null===(e=this.scrollParent)||void 0===e?void 0:e.getBoundingClientRect())||{left:0,top:0,right:this.view.win.innerWidth,bottom:this.view.win.innerHeight},l=gn(this.view);t.clientX-l.left<=o.left+6?r=-qn(o.left-t.clientX):t.clientX+l.right>=o.right-6&&(r=qn(t.clientX-o.right)),t.clientY-l.top<=o.top+6?s=-qn(o.top-t.clientY):t.clientY+l.bottom>=o.bottom-6&&(s=qn(t.clientY-o.bottom)),this.setScrollSpeed(r,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(){this.scrollParent?(this.scrollParent.scrollLeft+=this.scrollSpeed.x,this.scrollParent.scrollTop+=this.scrollSpeed.y):this.view.win.scrollBy(this.scrollSpeed.x,this.scrollSpeed.y),!1===this.dragging&&this.select(this.lastEvent)}skipAtoms(t){let e=null;for(let i=0;ithis.select(this.lastEvent)),20)}}const jn=Object.create(null),Kn=Object.create(null),$n=Qe.ie&&Qe.ie_version<15||Qe.ios&&Qe.webkit_version<604;function Un(t,e){let i,{state:n}=t,r=1,s=n.toText(e),o=s.lines==n.selection.ranges.length;if(null!=sr&&n.selection.ranges.every((t=>t.empty))&&sr==s.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 h=n.toText((o?s.line(r++).text:e)+n.lineBreak);return{changes:{from:l.from,insert:h},range:_.cursor(i.from+h.length)}}))}else i=o?n.changeByRange((t=>{let e=s.line(r++);return{changes:{from:t.from,to:t.to,insert:e.text},range:_.cursor(t.from+e.length)}})):n.replaceSelection(s);t.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}function Gn(t,e,i,n){if(1==n)return _.cursor(e,i);if(2==n)return function(t,e,i=1){let n=t.charCategorizer(e),r=t.doc.lineAt(e),s=e-r.from;if(0==r.length)return _.cursor(e);0==s?i=1:s==r.length&&(i=-1);let o=s,l=s;i<0?o=A(r.text,s,!1):l=A(r.text,s);let h=n(r.text.slice(o,l));for(;o>0;){let t=A(r.text,o,!1);if(n(r.text.slice(t,o))!=h)break;o=t}for(;l{t.inputState.lastScrollTop=t.scrollDOM.scrollTop,t.inputState.lastScrollLeft=t.scrollDOM.scrollLeft},jn.keydown=(t,e)=>(t.inputState.setSelectionOrigin("select"),27==e.keyCode&&(t.inputState.lastEscPress=Date.now()),!1),Kn.touchstart=(t,e)=>{t.inputState.lastTouchTime=Date.now(),t.inputState.setSelectionOrigin("select.pointer")},Kn.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")},jn.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(ji))if(i=n(t,e),i)break;if(i||0!=e.button||(i=function(t,e){let i=Qn(t,e),n=nr(e),r=t.state.selection;return{update(t){t.docChanged&&(i.pos=t.changes.mapPos(i.pos),r=r.map(t.changes))},get(e,s,o){let l,h=Qn(t,e),a=Gn(t,h.pos,h.bias,n);if(i.pos!=h.pos&&!s){let e=Gn(t,i.pos,i.bias,n),r=Math.min(e.from,a.from),s=Math.max(e.to,a.to);a=r1&&(l=function(t,e){for(let i=0;i=e)return _.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}(r,h.pos))?l:o?r.addRange(a):_.create([a])}}}(t,e)),i){let n=!t.hasFocus;t.inputState.startMouseSelection(new _n(t,e,i,n)),n&&t.observer.ignore((()=>Oe(t.contentDOM)));let r=t.inputState.mouseSelection;if(r)return r.start(e),!1===r.dragging}return!1};let Jn=(t,e)=>t>=e.top&&t<=e.bottom,Yn=(t,e,i)=>Jn(e,i)&&t>=i.left&&t<=i.right;function Xn(t,e,i,n){let r=ui.find(t.docView,e);if(!r)return 1;let s=e-r.posAtStart;if(0==s)return 1;if(s==r.length)return-1;let o=r.coordsAt(s,-1);if(o&&Yn(i,n,o))return-1;let l=r.coordsAt(s,1);return l&&Yn(i,n,l)?1:o&&Jn(n,o)?-1:1}function Qn(t,e){let i=t.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:i,bias:Xn(t,i,e.clientX,e.clientY)}}const Zn=Qe.ie&&Qe.ie_version<=11;let tr=null,er=0,ir=0;function nr(t){if(!Zn)return t.detail;let e=tr,i=ir;return tr=t,ir=Date.now(),er=!e||i>Date.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(er+1)%3:1}function rr(t,e,i,n){if(!i)return;let r=t.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:s}=t.inputState,o=n&&s&&function(t,e){let i=t.state.facet(_i);return i.length?i[0](e):Qe.mac?!e.altKey:!e.ctrlKey}(t,e)?{from:s.from,to:s.to}:null,l={from:r,insert:i},h=t.state.changes(o?[o,l]:l);t.focus(),t.dispatch({changes:h,selection:{anchor:h.mapPos(r,-1),head:h.mapPos(r,1)},userEvent:o?"move.drop":"input.drop"}),t.inputState.draggedContent=null}jn.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=_.range(t,e))}}let{inputState:n}=t;return n.mouseSelection&&(n.mouseSelection.dragging=!0),n.draggedContent=i,e.dataTransfer&&(e.dataTransfer.setData("Text",t.state.sliceDoc(i.from,i.to)),e.dataTransfer.effectAllowed="copyMove"),!1},jn.dragend=t=>(t.inputState.draggedContent=null,!1),jn.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),r=0,s=()=>{++r==i.length&&rr(t,e,n.filter((t=>null!=t)).join(t.state.lineBreak),!1)};for(let t=0;t{/[\x00-\x08\x0e-\x1f]{2}/.test(e.result)||(n[t]=e.result),s()},e.readAsText(i[t])}return!0}{let i=e.dataTransfer.getData("Text");if(i)return rr(t,e,i,!0),!0}return!1},jn.paste=(t,e)=>{if(t.state.readOnly)return!0;t.observer.flush();let i=$n?null:e.clipboardData;return i?(Un(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(),Un(t,i.value)}),50)}(t),!1)};let sr=null;jn.copy=jn.cut=(t,e)=>{let{text:i,ranges:n,linewise:r}=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 r=-1;for(let{from:n}of t.selection.ranges){let s=t.doc.lineAt(n);s.number>r&&(e.push(s.text),i.push({from:s.from,to:Math.min(t.doc.length,s.to+1)})),r=s.number}n=!0}return{text:e.join(t.lineBreak),ranges:i,linewise:n}}(t.state);if(!i&&!r)return!1;sr=r?i:null,"cut"!=e.type||t.state.readOnly||t.dispatch({changes:n,scrollIntoView:!0,userEvent:"delete.cut"});let s=$n?null:e.clipboardData;return s?(s.clearData(),s.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 or=yt.define();function lr(t,e){let i=[];for(let n of t.facet(Gi)){let r=n(t,e);r&&i.push(r)}return i?t.update({effects:i,annotations:or.of(!0)}):null}function hr(t){setTimeout((()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let i=lr(t.state,e);i?t.dispatch(i):t.update([])}}),10)}Kn.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),hr(t)},Kn.blur=t=>{t.observer.clearSelectionRange(),hr(t)},Kn.compositionstart=Kn.compositionupdate=t=>{null==t.inputState.compositionFirstChange&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0)},Kn.compositionend=t=>{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,Qe.chrome&&Qe.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then((()=>t.observer.flush())):setTimeout((()=>{t.inputState.composing<0&&t.docView.hasComposition&&t.update([])}),50)},Kn.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()},jn.beforeinput=(t,e)=>{var i;let n;if(Qe.chrome&&Qe.android&&(n=Wn.find((t=>t.inputType==e.inputType)))&&(t.observer.delayAndroidKey(n.key,n.keyCode),"Backspace"==n.key||"Delete"==n.key)){let e=(null===(i=window.visualViewport)||void 0===i?void 0:i.height)||0;setTimeout((()=>{var i;((null===(i=window.visualViewport)||void 0===i?void 0:i.height)||0)>e+10&&t.hasFocus&&(t.contentDOM.blur(),t.focus())}),100)}return Qe.ios&&"deleteContentForward"==e.inputType&&t.observer.flushSoon(),Qe.safari&&"insertText"==e.inputType&&t.inputState.composing>=0&&setTimeout((()=>Kn.compositionend(t,e)),20),!1};const ar=new Set;const cr=["pre-wrap","normal","pre-line","break-spaces"];class ur{constructor(t){this.lineWrapping=t,this.doc=c.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30,this.heightChanged=!1}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)/(this.lineLength-5))))*this.lineHeight}setDoc(t){return this.doc=t,this}mustRefreshForWrapping(t){return cr.indexOf(t)>-1!=this.lineWrapping}mustRefreshForHeights(t){let e=!1;for(let i=0;i-1,l=Math.round(e)!=Math.round(this.lineHeight)||this.lineWrapping!=o;if(this.lineWrapping=o,this.lineHeight=e,this.charWidth=i,this.textHeight=n,this.lineLength=r,l){this.heightSamples={};for(let t=0;t0}set outdated(t){this.flags=(t?2:0)|-3&this.flags}setHeight(t,e){this.height!=e&&(Math.abs(this.height-e)>gr&&(t.heightChanged=!0),this.height=e)}replace(t,e,i){return mr.of(i)}decomposeLeft(t,e){e.push(this)}decomposeRight(t,e){e.push(this)}applyChanges(t,e,i,n){let r=this,s=i.doc;for(let o=n.length-1;o>=0;o--){let{fromA:l,toA:h,fromB:a,toB:c}=n[o],u=r.lineAt(l,pr.ByPosNoHeight,i.setDoc(e),0,0),f=u.to>=h?u:r.lineAt(h,pr.ByPosNoHeight,i,0,0);for(c+=f.to-h,h=f.to;o>0&&u.from<=n[o-1].toA;)l=n[o-1].fromA,a=n[o-1].fromB,o--,l2*r){let r=t[e-1];r.break?t.splice(--e,1,r.left,null,r.right):t.splice(--e,1,r.left,r.right),i+=1+r.break,n-=r.size}else{if(!(r>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,r-=e.size}}else if(n=r&&s(this.blockAt(0,i,n,r))}updateHeight(t,e=0,i=!1,n){return n&&n.from<=e&&n.more&&this.setHeight(t,n.heights[n.index++]),this.outdated=!1,this}toString(){return`block(${this.length})`}}class wr extends vr{constructor(t,e){super(t,e,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(t,e,i,n){return new dr(n,this.length,i,this.height,this.breaks)}replace(t,e,i){let n=i[0];return 1==i.length&&(n instanceof wr||n instanceof yr&&4&n.flags)&&Math.abs(this.length-n.length)<10?(n instanceof yr?n=new wr(n.length,this.height):n.height=this.height,this.outdated||(n.outdated=!1),n):mr.of(i)}updateHeight(t,e=0,i=!1,n){return n&&n.from<=e&&n.more?this.setHeight(t,n.heights[n.index++]):(i||this.outdated)&&this.setHeight(t,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 yr extends mr{constructor(t){super(t,0)}heightMetrics(t,e){let i,n=t.doc.lineAt(e).number,r=t.doc.lineAt(e+this.length).number,s=r-n+1,o=0;if(t.lineWrapping){let e=Math.min(this.height,t.lineHeight*s);i=e/s,this.length>s+1&&(o=(this.height-e)/(this.length-s-1))}else i=this.height/s;return{firstLine:n,lastLine:r,perLine:i,perChar:o}}blockAt(t,e,i,n){let{firstLine:r,lastLine:s,perLine:o,perChar:l}=this.heightMetrics(e,n);if(e.lineWrapping){let r=n+(t0){let t=i[i.length-1];t instanceof yr?i[i.length-1]=new yr(t.length+n):i.push(null,new yr(n-1))}if(t>0){let e=i[0];e instanceof yr?i[0]=new yr(t+e.length):i.unshift(new yr(t-1),null)}return mr.of(i)}decomposeLeft(t,e){e.push(new yr(t-1),null)}decomposeRight(t,e){e.push(null,new yr(this.length-t-1))}updateHeight(t,e=0,i=!1,n){let r=e+this.length;if(n&&n.from<=e+this.length&&n.more){let i=[],s=Math.max(e,n.from),o=-1;for(n.from>e&&i.push(new yr(n.from-e-1).updateHeight(t,e));s<=r&&n.more;){let e=t.doc.lineAt(s).length;i.length&&i.push(null);let r=n.heights[n.index++];-1==o?o=r:Math.abs(r-o)>=gr&&(o=-2);let l=new wr(e,r);l.outdated=!1,i.push(l),s+=e+1}s<=r&&i.push(null,new yr(r-s).updateHeight(t,s));let l=mr.of(i);return(o<0||Math.abs(l.height-this.height)>=gr||Math.abs(o-this.heightMetrics(t,e).perLine)>=gr)&&(t.heightChanged=!0),l}return(i||this.outdated)&&(this.setHeight(t,t.heightForGap(e,e+this.length)),this.outdated=!1),this}toString(){return`gap(${this.length})`}}class br extends mr{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 r=i+this.left.height;return to))return h;let a=e==pr.ByPosNoHeight?pr.ByPosNoHeight:pr.ByPos;return l?h.join(this.right.lineAt(o,a,i,s,o)):this.left.lineAt(o,a,i,n,r).join(h)}forEachLine(t,e,i,n,r,s){let o=n+this.left.height,l=r+this.left.length+this.break;if(this.break)t=l&&this.right.forEachLine(t,e,i,o,l,s);else{let h=this.lineAt(l,pr.ByPos,i,n,r);t=t&&h.from<=e&&s(h),e>h.to&&this.right.forEachLine(h.to+1,e,i,o,l,s)}}replace(t,e,i){let n=this.left.length+this.break;if(ethis.left.length)return this.balanced(this.left,this.right.replace(t-n,e-n,i));let r=[];t>0&&this.decomposeLeft(t,r);let s=r.length;for(let t of i)r.push(t);if(t>0&&xr(r,s-1),e=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);t2*e.size||e.size>2*t.size?mr.of(this.break?[t,null,e]:[t,e]):(this.left=t,this.right=e,this.height=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:r,right:s}=this,o=e+r.length+this.break,l=null;return n&&n.from<=e+r.length&&n.more?l=r=r.updateHeight(t,e,i,n):r.updateHeight(t,e,i),n&&n.from<=o+s.length&&n.more?l=s=s.updateHeight(t,o,i,n):s.updateHeight(t,o,i),l?this.balanced(r,s):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function xr(t,e){let i,n;null==t[e]&&(i=t[e-1])instanceof yr&&(n=t[e+1])instanceof yr&&t.splice(e-1,3,new yr(i.length+1+n.length))}class kr{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 wr?i.length+=t-this.pos:(t>this.pos||!this.isCovered)&&this.nodes.push(new wr(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=5)&&this.addLineDeco(n,r,s)}else e>t&&this.span(t,e);this.lineEnd>-1&&this.lineEnd-1)return;let{from:t,to:e}=this.oracle.doc.lineAt(this.pos);this.lineStart=t,this.lineEnd=e,this.writtenTot&&this.nodes.push(new wr(this.pos-t,-1)),this.writtenTo=this.pos}blankContent(t,e){let i=new yr(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 wr)return t;let e=new wr(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 wr||this.isCovered?(this.writtenToi.clientHeight||i.scrollWidth>i.clientWidth)&&"visible"!=n.overflow){let n=i.getBoundingClientRect();s=Math.max(s,n.left),o=Math.min(o,n.right),l=Math.max(l,n.top),h=e==t.parentNode?n.bottom:Math.min(h,n.bottom)}e="absolute"==n.position||"fixed"==n.position?i.offsetParent:i.parentNode}else{if(11!=e.nodeType)break;e=e.host}return{left:s-i.left,right:Math.max(s,o)-i.left,top:l-(i.top+e),bottom:Math.max(l,h)-(i.top+e)}}function Mr(t,e){let i=t.getBoundingClientRect();return{left:0,right:i.right-i.left,top:e,bottom:i.bottom-(i.top+e)}}class Cr{constructor(t,e,i){this.from=t,this.to=e,this.size=i}static same(t,e){if(t.length!=e.length)return!1;for(let i=0;i"function"!=typeof t&&"cm-lineWrapping"==t.class));this.heightOracle=new ur(e),this.stateDeco=t.facet(an).filter((t=>"function"!=typeof t)),this.heightMap=mr.empty().applyChanges(this.stateDeco,c.empty,this.heightOracle.setDoc(t.doc),[new vn(0,0,0,t.doc.length)]),this.viewport=this.getViewport(0,null),this.updateViewportLines(),this.updateForViewport(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=gi.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 Tr(e,i))}}this.viewports=t.sort(((t,e)=>t.from-e.from)),this.scaler=this.heightMap.height<=7e6?Br:new Lr(this.heightOracle,this.heightMap,this.viewports)}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,(t=>{this.viewportLines.push(1==this.scaler.scale?t:Nr(t,this.scaler))}))}update(t,e=null){this.state=t.state;let i=this.stateDeco;this.stateDeco=this.state.facet(an).filter((t=>"function"!=typeof t));let n=t.changedRanges,r=vn.extendWithRanges(n,function(t,e,i){let n=new Sr;return zt.compare(t,e,i,n,0),n.changes}(i,this.stateDeco,t?t.changes:N.empty(this.state.doc.length))),s=this.heightMap.height,o=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);this.heightMap=this.heightMap.applyChanges(this.stateDeco,t.startState.doc,this.heightOracle.setDoc(this.state.doc),r),this.heightMap.height!=s&&(t.flags|=2),o?(this.scrollAnchorPos=t.changes.mapPos(o.from,-1),this.scrollAnchorHeight=o.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=this.heightMap.height);let l=r.length?this.mapViewport(this.viewport,t.changes):this.viewport;(e&&(e.range.headl.to)||!this.viewportIsAppropriate(l))&&(l=this.getViewport(0,e));let h=!t.changes.empty||2&t.flags||l.from!=this.viewport.from||l.to!=this.viewport.to;this.viewport=l,this.updateForViewport(),h&&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(),e&&(this.scrollTarget=e),!this.mustEnforceCursorAssoc&&t.selectionSet&&t.view.lineWrapping&&t.state.selection.main.empty&&t.state.selection.main.assoc&&!t.state.facet(Yi)&&(this.mustEnforceCursorAssoc=!0)}measure(t){let e=t.contentDOM,i=window.getComputedStyle(e),n=this.heightOracle,r=i.whiteSpace;this.defaultTextDirection="rtl"==i.direction?exports.Direction.RTL:exports.Direction.LTR;let s=this.heightOracle.mustRefreshForWrapping(r),o=e.getBoundingClientRect(),l=s||this.mustMeasureContent||this.contentDOMHeight!=o.height;this.contentDOMHeight=o.height,this.mustMeasureContent=!1;let h=0,a=0;if(o.width&&o.height){let{scaleX:t,scaleY:i}=Se(e,o);(t>.005&&Math.abs(this.scaleX-t)>.005||i>.005&&Math.abs(this.scaleY-i)>.005)&&(this.scaleX=t,this.scaleY=i,h|=8,s=l=!0)}let u=(parseInt(i.paddingTop)||0)*this.scaleY,f=(parseInt(i.paddingBottom)||0)*this.scaleY;this.paddingTop==u&&this.paddingBottom==f||(this.paddingTop=u,this.paddingBottom=f,h|=10),this.editorWidth!=t.scrollDOM.clientWidth&&(n.lineWrapping&&(l=!0),this.editorWidth=t.scrollDOM.clientWidth,h|=8);let d=t.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=d&&(this.scrollAnchorHeight=-1,this.scrollTop=d),this.scrolledToBottom=Re(t.scrollDOM);let p=(this.printing?Mr:Ar)(e,this.paddingTop),g=p.top-this.pixelViewport.top,m=p.bottom-this.pixelViewport.bottom;this.pixelViewport=p;let v=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(v!=this.inView&&(this.inView=v,v&&(l=!0)),!this.inView&&!this.scrollTarget)return 0;let w=o.width;if(this.contentDOMWidth==w&&this.editorHeight==t.scrollDOM.clientHeight||(this.contentDOMWidth=o.width,this.editorHeight=t.scrollDOM.clientHeight,h|=8),l){let e=t.docView.measureVisibleLineHeights(this.viewport);if(n.mustRefreshForHeights(e)&&(s=!0),s||n.lineWrapping&&Math.abs(w-this.contentDOMWidth)>n.charWidth){let{lineHeight:i,charWidth:o,textHeight:l}=t.docView.measureTextSize();s=i>0&&n.refresh(r,i,o,l,w/o,e),s&&(t.docView.minWidth=0,h|=8)}g>0&&m>0?a=Math.max(g,m):g<0&&m<0&&(a=Math.min(g,m)),n.heightChanged=!1;for(let i of this.viewports){let r=i.from==this.viewport.from?e:t.docView.measureVisibleLineHeights(i);this.heightMap=(s?mr.empty().applyChanges(this.stateDeco,c.empty,this.heightOracle,[new vn(0,0,0,t.state.doc.length)]):this.heightMap).updateHeight(n,0,s,new fr(i.from,r))}n.heightChanged&&(h|=2)}let y=!this.viewportIsAppropriate(this.viewport,a)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return y&&(this.viewport=this.getViewport(a,this.scrollTarget)),this.updateForViewport(),(2&h||y)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(s?[]:this.lineGaps,t)),h|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,t.docView.enforceCursorAssoc()),h}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,r=this.heightOracle,{visibleTop:s,visibleBottom:o}=this,l=new Tr(n.lineAt(s-1e3*i,pr.ByHeight,r,0,0).from,n.lineAt(o+1e3*(1-i),pr.ByHeight,r,0,0).to);if(e){let{head:t}=e.range;if(tl.to){let i,s=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),o=n.lineAt(t,pr.ByPos,r,0,0);i="center"==e.y?(o.top+o.bottom)/2-s/2:"start"==e.y||"nearest"==e.y&&t=o+Math.max(10,Math.min(i,250)))&&n>s-2e3&&r>1,s=n<<1;if(this.defaultTextDirection!=exports.Direction.LTR&&!i)return[];let o=[],l=(n,s,h,a)=>{if(s-nn&&tt.from>=h.from&&t.to<=h.to&&Math.abs(t.from-n)t.frome))));if(!f){if(st.from<=s&&t.to>=s))){let t=e.moveToLineBoundary(_.cursor(s),!1,!0).head;t>n&&(s=t)}f=new Cr(n,s,this.gapSize(h,n,s,a))}o.push(f)};for(let t of this.viewportLines){if(t.lengtht.from&&l(t.from,r,t,e),ot.draw(this,this.heightOracle.lineWrapping)))))}computeVisibleRanges(){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let e=[];zt.spans(t,this.viewport.from,this.viewport.to,{span(t,i){e.push({from:t,to:i})},point(){}},20);let i=e.length!=this.visibleRanges.length||this.visibleRanges.some(((t,i)=>t.from!=e[i].from||t.to!=e[i].to));return this.visibleRanges=e,i?4:0}lineBlockAt(t){return t>=this.viewport.from&&t<=this.viewport.to&&this.viewportLines.find((e=>e.from<=t&&e.to>=t))||Nr(this.heightMap.lineAt(t,pr.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(t){return Nr(this.heightMap.lineAt(this.scaler.fromDOM(t),pr.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 Nr(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 Tr{constructor(t,e){this.from=t,this.to=e}}function Er(t,e,i){let n=[],r=t,s=0;return zt.spans(i,t,e,{span(){},point(t,e){t>r&&(n.push({from:r,to:t}),s+=t-r),r=e}},20),r=1)return e[e.length-1].to;let n=Math.floor(t*i);for(let t=0;;t++){let{from:i,to:r}=e[t],s=r-i;if(n<=s)return i+n;n-=s}}function Pr(t,e){let i=0;for(let{from:n,to:r}of t.ranges){if(e<=r){i+=e-n;break}i+=r-n}return i/t.total}const Br={toDOM:t=>t,fromDOM:t=>t,scale:1};class Lr{constructor(t,e,i){let n=0,r=0,s=0;this.viewports=i.map((({from:i,to:r})=>{let s=e.lineAt(i,pr.ByPos,t,0,0).top,o=e.lineAt(r,pr.ByPos,t,0,0).bottom;return n+=o-s,{from:i,to:r,top:s,bottom:o,domTop:0,domBottom:0}})),this.scale=(7e6-n)/(e.height-n);for(let t of this.viewports)t.domTop=s+(t.top-r)*this.scale,s=t.domBottom=t.domTop+(t.bottom-t.top),r=t.bottom}toDOM(t){for(let e=0,i=0,n=0;;e++){let r=eNr(t,e))):t._content)}const Ir=$.define({combine:t=>t.join(" ")}),Vr=$.define({combine:t=>t.indexOf(!0)>-1}),Hr=ne.newName(),Wr=ne.newName(),zr=ne.newName(),Fr={"&light":"."+Wr,"&dark":"."+zr};function qr(t,e,i){return new ne(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 _r=qr("."+Hr,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0},".cm-content":{margin:0,flexGrow:2,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:"#444"},".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",insetInlineStart:0,zIndex:200},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",borderRight:"1px solid #ddd"},"&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},"&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-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"},".cm-highlightSpace:before":{content:"attr(data-display)",position:"absolute",pointerEvents:"none",color:"#888"},".cm-highlightTab":{backgroundImage:'url(\'data:image/svg+xml,\')',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"}},Fr),jr="￿";class Kr{constructor(t,e){this.points=t,this.text="",this.lineSeparator=e.facet(Lt.lineSeparator)}append(t){this.text+=t}lineBreak(){this.text+=jr}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 r=n.nextSibling;if(r==e)break;let s=Ie.get(n),o=Ie.get(r);(s&&o?s.breakAfter:(s?s.breakAfter:we(n))||we(r)&&("BR"!=n.nodeName||n.cmIgnore)&&this.text.length>t)&&this.lineBreak(),n=r}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 r,s=-1,o=1;if(this.lineSeparator?(s=e.indexOf(this.lineSeparator,i),o=this.lineSeparator.length):(r=n.exec(e))&&(s=r.index,o=r[0].length),this.append(e.slice(i,s<0?e.length:s)),s<0)break;if(this.lineBreak(),o>1)for(let e of this.points)e.node==t&&e.pos>this.text.length&&(e.pos-=o-1);i=s+o}}readNode(t){if(t.cmIgnore)return;let e=Ie.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+($r(t,i.node,i.offset)?e:0))}}function $r(t,e,i){for(;;){if(!e||i-1)this.newSel=null;else if(e>-1&&(this.bounds=t.docView.domBoundsAround(e,i,0))){let e=r||s?[]:function(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:i,anchorOffset:n,focusNode:r,focusOffset:s}=t.observer.selectionRange;i&&(e.push(new Ur(i,n)),r==i&&s==n||e.push(new Ur(r,s)));return e}(t),i=new Kr(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?_.single(i+e,n+e):null}(e,this.bounds.from)}else{let e=t.observer.selectionRange,i=r&&r.node==e.focusNode&&r.offset==e.focusOffset||!de(t.contentDOM,e.focusNode)?t.state.selection.main.head:t.docView.posFromDOM(e.focusNode,e.focusOffset),n=s&&s.node==e.anchorNode&&s.offset==e.anchorOffset||!de(t.contentDOM,e.anchorNode)?t.state.selection.main.anchor:t.docView.posFromDOM(e.anchorNode,e.anchorOffset),o=t.viewport;if((Qe.ios||Qe.chrome)&&t.state.selection.main.empty&&i!=n&&(o.from>0||o.toDate.now()-100?t.inputState.lastKeyCode:-1;if(e.bounds){let{from:n,to:o}=e.bounds,l=r.from,h=null;(8===s||Qe.android&&e.text.length0&&l>0&&t.charCodeAt(o-1)==e.charCodeAt(l-1);)o--,l--;if("end"==n){i-=o+Math.max(0,s-Math.min(o,l))-s}if(o=o?s-i:0,l=s+(l-o),o=s}else if(l=l?s-i:0,o=s+(o-l),l=s}return{from:s,toA:o,toB:l}}(t.state.doc.sliceString(n,o,jr),e.text,l-n,h);a&&(Qe.chrome&&13==s&&a.toB==a.from+2&&e.text.slice(a.from,a.toB)==jr+jr&&a.toB--,i={from:n+a.from,to:n+a.toA,insert:c.of(e.text.slice(a.from,a.toB).split(jr))})}else n&&(!t.hasFocus&&t.state.facet(en)||n.main.eq(r))&&(n=null);if(!i&&!n)return!1;if(!i&&e.typeOver&&!r.empty&&n&&n.main.empty?i={from:r.from,to:r.to,insert:t.state.doc.slice(r.from,r.to)}:i&&i.from>=r.from&&i.to<=r.to&&(i.from!=r.from||i.to!=r.to)&&r.to-r.from-(i.to-i.from)<=4?i={from:r.from,to:r.to,insert:t.state.doc.slice(r.from,i.from).append(i.insert).append(t.state.doc.slice(i.to,r.to))}:(Qe.mac||Qe.android)&&i&&i.from==i.to&&i.from==r.head-1&&/^\. ?$/.test(i.insert.toString())&&"off"==t.contentDOM.getAttribute("autocorrect")?(n&&2==i.insert.length&&(n=_.single(n.main.anchor-1,n.main.head-1)),i={from:r.from,to:r.to,insert:c.of([" "])}):Qe.chrome&&i&&i.from==i.to&&i.from==r.head&&"\n "==i.insert.toString()&&t.lineWrapping&&(n&&(n=_.single(n.main.anchor-1,n.main.head-1)),i={from:r.from,to:r.to,insert:c.of([" "])}),i){if(Qe.ios&&t.inputState.flushIOSKey(i))return!0;if(Qe.android&&(i.to==r.to&&(i.from==r.from||i.from==r.from-1&&" "==t.state.sliceDoc(i.from,r.from))&&1==i.insert.length&&2==i.insert.lines&&Te(t.contentDOM,"Enter",13)||(i.from==r.from-1&&i.to==r.to&&0==i.insert.length||8==s&&i.insert.lengthr.head)&&Te(t.contentDOM,"Backspace",8)||i.from==r.from&&i.to==r.to+1&&0==i.insert.length&&Te(t.contentDOM,"Delete",46)))return!0;let e,o=i.insert.toString();t.inputState.composing>=0&&t.inputState.composing++;let l=()=>e||(e=function(t,e,i){let n,r=t.state,s=r.selection.main;if(e.from>=s.from&&e.to<=s.to&&e.to-e.from>=(s.to-s.from)/3&&(!i||i.main.empty&&i.main.from==e.from+e.insert.length)&&t.inputState.composing<0){let i=s.frome.to?r.sliceDoc(e.to,s.to):"";n=r.replaceSelection(t.state.toText(i+e.insert.sliceString(0,void 0,t.state.lineBreak)+o))}else{let o=r.changes(e),l=i&&i.main.to<=o.newLength?i.main:void 0;if(r.selection.ranges.length>1&&t.inputState.composing>=0&&e.to<=s.to&&e.to>=s.to-10){let h,a=t.state.sliceDoc(e.from,e.to),c=i&&xn(t,i.main.head);if(c){let t=e.insert.length-(e.to-e.from);h={from:c.from,to:c.to-t}}else h=t.state.doc.lineAt(s.head);let u=s.to-e.to,f=s.to-s.from;n=r.changeByRange((i=>{if(i.from==s.from&&i.to==s.to)return{changes:o,range:l||i.map(o)};let n=i.to-u,c=n-a.length;if(i.to-i.from!=f||t.state.sliceDoc(c,n)!=a||i.to>=h.from&&i.from<=h.to)return{range:i};let d=r.changes({from:c,to:n,insert:e.insert}),p=i.to-s.to;return{changes:d,range:l?_.range(Math.max(0,l.anchor+p),Math.max(0,l.head+p)):i.map(d)}}))}else n={changes:o,selection:l&&r.selection.replaceRange(l)}}let o="input.type";(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,o+=".compose",t.inputState.compositionFirstChange&&(o+=".start",t.inputState.compositionFirstChange=!1));return r.update(n,{userEvent:o,scrollIntoView:!0})}(t,i,n));return t.state.facet(Ui).some((e=>e(t,i.from,i.to,o,l)))||t.dispatch(l()),!0}if(n&&!n.main.eq(r)){let e=!1,i="select";return t.inputState.lastSelectionTime>Date.now()-50&&("select"==t.inputState.lastSelectionOrigin&&(e=!0),i=t.inputState.lastSelectionOrigin),t.dispatch({selection:n,scrollIntoView:e,userEvent:i}),!0}return!1}const Yr={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Xr=Qe.ie&&Qe.ie_version<=11;class Qr{constructor(t){this.view=t,this.active=!1,this.selectionRange=new Ae,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);(Qe.ie&&Qe.ie_version<=11||Qe.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()})),Xr&&(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){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.onScrollChanged(t)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout((()=>{this.resizeTimeout=-1,this.view.requestMeasure()}),50))}onPrint(t){("change"!=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(en)?i.root.activeElement!=this.dom:!pe(i.dom,n))return;let r=n.anchorNode&&i.docView.nearest(n.anchorNode);r&&r.ignoreEvent(t)?e||(this.selectionChanged=!1):(Qe.ie&&Qe.ie_version<=11||Qe.android&&Qe.chrome)&&!i.state.selection.main.empty&&n.focusNode&&me(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:t}=this,e=fe(t.root);if(!e)return!1;let i=Qe.safari&&11==t.root.nodeType&&function(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}(this.dom.ownerDocument)==this.dom&&function(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return ts(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?ts(t,i):null}(this.view,e)||e;if(!i||this.selectionRange.eq(i))return!1;let n=pe(this.dom,i);return n&&!this.selectionChanged&&t.inputState.lastFocusTime>Date.now()-200&&t.inputState.lastTouchTime{let t=this.delayedAndroidKey;if(t){this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=t.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&t.force&&Te(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{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 r of t){let t=this.readMutation(r);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&&pe(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 r=new Gr(this.view,t,e,i);return this.view.docView.domChanged={newSel:r.newSel?r.newSel.main:null},r}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=Jr(this.view,e);return this.view.state==i&&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=Zr(e,t.previousSibling||t.target.previousSibling,-1),n=Zr(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("change",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("change",this.onPrint):t.removeEventListener("beforeprint",this.onPrint),t.document.removeEventListener("selectionchange",this.onSelectionChange)}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)}}function Zr(t,e,i){for(;e;){let n=Ie.get(e);if(n&&n.parent==t)return n;let r=e.parentNode;e=r!=t.dom?r:i>0?e.nextSibling:e.previousSibling}return null}function ts(t,e){let i=e.startContainer,n=e.startOffset,r=e.endContainer,s=e.endOffset,o=t.docView.domAtPos(t.state.selection.main.anchor);return me(o.node,o.offset,r,s)&&([i,n,r,s]=[r,s,i,n]),{anchorNode:i,anchorOffset:n,focusNode:r,focusOffset:s}}class es{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return this.inputState.composing>0}get compositionStarted(){return this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(t={}){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:e}=t;this.dispatchTransactions=t.dispatchTransactions||e&&(t=>t.forEach((t=>e(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 Dr(t.state||Lt.create(t)),t.scrollTo&&t.scrollTo.is(Zi)&&(this.viewState.scrollTarget=t.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(rn).map((t=>new on(t)));for(let t of this.plugins)t.update(this);this.observer=new Qr(this),this.inputState=new In(this),this.inputState.ensureHandlers(this.plugins),this.docView=new yn(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure()}dispatch(...t){let e=1==t.length&&t[0]instanceof St?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,r=this.state;for(let e of t){if(e.startState!=r)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");r=e.state}if(this.destroyed)return void(this.viewState.state=r);let s=this.hasFocus,o=0,l=null;t.some((t=>t.annotation(or)))?(this.inputState.notifiedFocused=s,o=1):s!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=s,l=lr(r,s),l||(o=1));let h=this.observer.delayedAndroidKey,a=null;if(h?(this.observer.clearDelayedAndroidKey(),a=this.observer.readChange(),(a&&!this.state.doc.eq(r.doc)||!this.state.selection.eq(r.selection))&&(a=null)):this.observer.clear(),r.facet(Lt.phrases)!=this.state.facet(Lt.phrases))return this.setState(r);e=wn.create(this,r,t),e.flags|=o;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 Qi(t.empty?t:_.cursor(t.head,t.head>t.anchor?-1:1))}for(let t of e.effects)t.is(Zi)&&(c=t.value.clip(this.state))}this.viewState.update(e,c),this.bidiCache=rs.update(this.bidiCache,e.changes),e.empty||(this.updatePlugins(e),this.inputState.update(e)),i=this.docView.update(e),this.state.facet(mn)!=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(Ir)!=e.state.facet(Ir)&&(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($i))try{t(e)}catch(t){tn(this.state,t,"update listener")}(l||a)&&Promise.resolve().then((()=>{l&&this.state==l.startState&&this.dispatch(l),a&&!Jr(this,a)&&h.force&&Te(this.contentDOM,h.key,h.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 Dr(t),this.plugins=t.facet(rn).map((t=>new on(t))),this.pluginMap.clear();for(let t of this.plugins)t.update(this);this.docView.destroy(),this.docView=new yn(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(rn),i=t.state.facet(rn);if(e!=i){let n=[];for(let r of i){let i=e.indexOf(r);if(i<0)n.push(new on(r));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-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:r,scrollAnchorHeight:s}=this.viewState;Math.abs(n-this.viewState.scrollTop)>1&&(s=-1),this.viewState.scrollAnchorHeight=-1;try{for(let t=0;;t++){if(s<0)if(Re(i))r=-1,s=this.viewState.heightMap.height;else{let t=this.viewState.scrollAnchorAt(n);r=t.from,s=t.top}this.updateState=1;let o=this.viewState.measure(this);if(!o&&!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&o||([this.measureRequests,l]=[l,this.measureRequests]);let h=l.map((t=>{try{return t.read(this)}catch(t){return tn(this.state,t),ns}})),a=wn.create(this,this.state,[]),c=!1;a.flags|=o,e?e.flags|=o:e=a,this.updateState=2,a.empty||(this.updatePlugins(a),this.inputState.update(a),this.updateAttrs(),c=this.docView.update(a),c&&this.docViewUpdate());for(let t=0;t1||t<-1){n+=t,i.scrollTop=n/this.scaleY,s=-1;continue}}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(e&&!e.empty)for(let t of this.state.facet($i))t(e)}get themeClasses(){return Hr+" "+(this.state.facet(Vr)?zr:Wr)+" "+this.state.facet(Ir)}updateAttrs(){let t=ss(this,ln,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),e={spellcheck:"false",autocorrect:"off",autocapitalize:"off",translate:"no",contenteditable:this.state.facet(en)?"true":"false",class:"cm-content",style:`${Qe.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(e["aria-readonly"]="true"),ss(this,hn,e);let i=this.observer.ignore((()=>{let i=ai(this.contentDOM,this.contentAttrs,e),n=ai(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(es.announce)){e&&(this.announceDOM.textContent=""),e=!1,this.announceDOM.appendChild(document.createElement("div")).textContent=t.value}}mountStyles(){this.styleModules=this.state.facet(mn);let t=this.state.facet(es.cspNonce);ne.mount(this.root,this.styleModules.concat(_r).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;ee.spec==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 Nn(this,t,Bn(this,t,e,i))}moveByGroup(t,e){return Nn(this,t,Bn(this,t,e,(e=>function(t,e,i){let n=t.state.charCategorizer(e),r=n(i);return t=>{let e=n(t);return r==Et.Space&&(r=e),r==e}}(this,t.head,e))))}visualLineSide(t,e){let i=this.bidiSpans(t),n=this.textDirectionAt(t.from),r=i[e?i.length-1:0];return _.cursor(r.side(e,n)+t.from,r.forward(!e,n)?1:-1)}moveToLineBoundary(t,e,i=!0){return function(t,e,i,n){let r=Pn(t,e.head),s=n&&r.type==pi.Text&&(t.lineWrapping||r.widgetLineBreaks)?t.coordsAtPos(e.assoc<0&&e.head>r.from?e.head-1:e.head):null;if(s){let e=t.dom.getBoundingClientRect(),n=t.textDirectionAt(r.from),o=t.posAtCoords({x:i==(n==exports.Direction.LTR)?e.right-1:e.left+1,y:(s.top+s.bottom)/2});if(null!=o)return _.cursor(o,i?-1:1)}return _.cursor(i?r.to:r.from,i?-1:1)}(this,t,e,i)}moveVertically(t,e,i){return Nn(this,t,function(t,e,i,n){let r=e.head,s=i?1:-1;if(r==(i?t.state.doc.length:0))return _.cursor(r,e.assoc);let o,l=e.goalColumn,h=t.contentDOM.getBoundingClientRect(),a=t.coordsAtPos(r,e.assoc||-1),c=t.documentTop;if(a)null==l&&(l=a.left-h.left),o=s<0?a.top:a.bottom;else{let e=t.viewState.lineBlockAt(r);null==l&&(l=Math.min(h.right-h.left,t.defaultCharacterWidth*(r-e.from))),o=(s<0?e.top:e.bottom)+c}let u=h.left+l,f=null!=n?n:t.viewState.heightOracle.textHeight>>1;for(let e=0;;e+=10){let i=o+(f+e)*s,n=En(t,{x:u,y:i},!1,s);if(ih.bottom||(s<0?nr)){let e=t.docView.coordsForChar(n),r=!e||i0)}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(Ji)||tthis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(t))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(t){if(t.length>is)return Hi(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||Li(n.isolates,e=dn(this,t))))return n.order;e||(e=dn(this,t));let n=function(t,e,i){if(!t)return[new Bi(0,0,e==Mi?1:0)];if(e==Ai&&!i.length&&!Pi.test(t))return Hi(t.length);if(i.length)for(;t.length>Ni.length;)Ni[Ni.length]=256;let n=[],r=e==Ai?0:1;return Vi(t,r,r,i,0,t.length,n),n}(t.text,i,e);return this.bidiCache.push(new rs(t.from,t.to,i,e,!0,n)),n}get hasFocus(){var t;return(this.dom.ownerDocument.hasFocus()||Qe.safari&&(null===(t=this.inputState)||void 0===t?void 0:t.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore((()=>{Oe(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(){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 Zi.of(new Qi("number"==typeof t?_.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 Zi.of(new Qi(_.cursor(i.from),"start","start",i.top-t,e,!0))}static domEventHandlers(t){return sn.define((()=>({})),{eventHandlers:t})}static domEventObservers(t){return sn.define((()=>({})),{eventObservers:t})}static theme(t,e){let i=ne.newName(),n=[Ir.of(i),mn.of(qr(`.${i}`,t))];return e&&e.dark&&n.push(Vr.of(!0)),n}static baseTheme(t){return st.lowest(mn.of(qr("."+Hr,t,Fr)))}static findFromDOM(t){var e;let i=t.querySelector(".cm-content"),n=i&&Ie.get(i)||Ie.get(t);return(null===(e=null==n?void 0:n.rootView)||void 0===e?void 0:e.view)||null}}es.styleModule=mn,es.inputHandler=Ui,es.scrollHandler=Xi,es.focusChangeEffect=Gi,es.perLineTextDirection=Ji,es.exceptionSink=Ki,es.updateListener=$i,es.editable=en,es.mouseSelectionStyle=ji,es.dragMovesSelection=_i,es.clickAddsSelectionRange=qi,es.decorations=an,es.outerDecorations=cn,es.atomicRanges=un,es.bidiIsolatedRanges=fn,es.scrollMargins=pn,es.darkTheme=Vr,es.cspNonce=$.define({combine:t=>t.length?t[0]:""}),es.contentAttributes=hn,es.editorAttributes=ln,es.lineWrapping=es.contentAttributes.of({class:"cm-lineWrapping"}),es.announce=kt.define();const is=4096,ns={};class rs{constructor(t,e,i,n,r,s){this.from=t,this.to=e,this.dir=i,this.isolates=n,this.fresh=r,this.order=s}static update(t,e){if(e.empty&&!t.some((t=>t.fresh)))return t;let i=[],n=t.length?t[t.length-1].dir:exports.Direction.LTR;for(let r=Math.max(0,t.length-10);r=0;r--){let e=n[r],s="function"==typeof e?e(t):e;s&&oi(s,i)}return i}const os=Qe.mac?"mac":Qe.windows?"win":Qe.linux?"linux":"key";function ls(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 hs=st.default(es.domEventHandlers({keydown:(t,e)=>ps(us(e.state),t,e,"editor")})),as=$.define({enables:hs}),cs=new WeakMap;function us(t){let e=t.facet(as),i=cs.get(e);return i||cs.set(e,i=function(t,e=os){let i=Object.create(null),n=Object.create(null),r=(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")},s=(t,n,s,o,l)=>{var h,a;let c=i[t]||(i[t]=Object.create(null)),u=n.split(/ (?!$)/).map((t=>function(t,e){const i=t.split(/-(?!$)/);let n,r,s,o,l=i[i.length-1];"Space"==l&&(l=" ");for(let t=0;t{let n=fs={view:e,prefix:i,scope:t};return setTimeout((()=>{fs==n&&(fs=null)}),ds),!0}]})}let f=u.join(" ");r(f,!1);let d=c[f]||(c[f]={preventDefault:!1,stopPropagation:!1,run:(null===(a=null===(h=c._any)||void 0===h?void 0:h.run)||void 0===a?void 0:a.slice())||[]});s&&d.run.push(s),o&&(d.preventDefault=!0),l&&(d.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:[]});for(let e in t)t[e].run.push(n.any)}let r=n[e]||n.key;if(r)for(let e of t)s(e,r,n.run,n.preventDefault,n.stopPropagation),n.shift&&s(e,"Shift-"+r,n.shift,n.preventDefault,n.stopPropagation)}return i}(e.reduce(((t,e)=>t.concat(e)),[]))),i}let fs=null;const ds=4e3;function ps(t,e,i,n){let r=function(t){var e=!(he&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||ae&&t.shiftKey&&t.key&&1==t.key.length||"Unidentified"==t.key)&&t.key||(t.shiftKey?le:oe)[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),s=R(T(r,0))==r.length&&" "!=r,o="",l=!1,h=!1,a=!1;fs&&fs.view==i&&fs.scope==n&&(o=fs.prefix+" ",Fn.indexOf(e.keyCode)<0&&(h=!0,fs=null));let c,u,f=new Set,d=t=>{if(t){for(let n of t.run)if(!f.has(n)&&(f.add(n),n(i,e)))return t.stopPropagation&&(a=!0),!0;t.preventDefault&&(t.stopPropagation&&(a=!0),h=!0)}return!1},p=t[n];return p&&(d(p[o+ls(r,e,!s)])?l=!0:s&&(e.altKey||e.metaKey||e.ctrlKey)&&!(Qe.windows&&e.ctrlKey&&e.altKey)&&(c=oe[e.keyCode])&&c!=r?(d(p[o+ls(c,e,!0)])||e.shiftKey&&(u=le[e.keyCode])!=r&&u!=c&&d(p[o+ls(u,e,!1)]))&&(l=!0):s&&e.shiftKey&&d(p[o+ls(r,e,!0)])&&(l=!0),!l&&d(p._any)&&(l=!0)),h&&(l=!0),l&&a&&e.stopPropagation(),l}class gs{constructor(t,e,i,n,r){this.className=t,this.left=e,this.top=i,this.width=n,this.height=r}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 r=ms(t);return[new gs(e,n.left-r.left,n.top-r.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),r=Math.min(i.to,t.viewport.to),s=t.textDirection==exports.Direction.LTR,o=t.contentDOM,l=o.getBoundingClientRect(),h=ms(t),a=o.querySelector(".cm-line"),c=a&&window.getComputedStyle(a),u=l.left+(c?parseInt(c.paddingLeft)+Math.min(0,parseInt(c.textIndent)):0),f=l.right-(c?parseInt(c.paddingRight):0),d=Pn(t,n),p=Pn(t,r),g=d.type==pi.Text?d:null,m=p.type==pi.Text?p:null;g&&(t.lineWrapping||d.widgetLineBreaks)&&(g=vs(t,n,g));m&&(t.lineWrapping||p.widgetLineBreaks)&&(m=vs(t,r,m));if(g&&m&&g.from==m.from)return w(y(i.from,i.to,g));{let e=g?y(i.from,null,g):b(d,!1),n=m?y(null,i.to,m):b(p,!0),r=[];return(g||d).to<(m||p).from-(g&&m?1:0)||d.widgetLineBreaks>1&&e.bottom+t.defaultLineHeight/2a&&n.from=s)break;l>r&&h(Math.max(t,r),null==e&&t<=a,Math.min(l,s),null==i&&l>=c,o.dir)}if(r=n.to+1,r>=s)break}return 0==l.length&&h(a,null==e,c,null==i,t.textDirection),{top:r,bottom:o,horizontal:l}}function b(t,e){let i=l.top+(e?t.top:t.bottom);return{top:i,bottom:i,horizontal:[]}}}(t,e,i)}}function ms(t){let e=t.scrollDOM.getBoundingClientRect();return{left:(t.textDirection==exports.Direction.LTR?e.left:e.right-t.scrollDOM.clientWidth*t.scaleX)-t.scrollDOM.scrollLeft*t.scaleX,top:e.top-t.scrollDOM.scrollTop*t.scaleY}}function vs(t,e,i){let n=_.cursor(e);return{from:Math.max(i.from,t.moveToLineBoundary(n,!1,!0).from),to:Math.min(i.to,t.moveToLineBoundary(n,!0,!0).from),type:pi.Text}}class ws{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(ys)!=t.state.facet(ys)&&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(ys);for(;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}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const ys=$.define();function bs(t){return[sn.define((e=>new ws(e,t))),ys.of(t)]}const xs=!Qe.ios,ks=$.define({combine:t=>Nt(t,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(t,e)=>Math.min(t,e),drawRangeCursor:(t,e)=>t||e})});function Ss(t){return t.startState.facet(ks)!=t.state.facet(ks)}const As=bs({above:!0,markers(t){let{state:e}=t,i=e.facet(ks),n=[];for(let r of e.selection.ranges){let s=r==e.selection.main;if(r.empty?!s||xs:i.drawRangeCursor){let e=s?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",i=r.empty?r:_.cursor(r.head,r.head>r.anchor?-1:1);for(let r of gs.forRange(t,e,i))n.push(r)}}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=Ss(t);return i&&Ms(t.state,e),t.docChanged||t.selectionSet||i},mount(t,e){Ms(e.state,t)},class:"cm-cursorLayer"});function Ms(t,e){e.style.animationDuration=t.facet(ks).cursorBlinkRate+"ms"}const Cs=bs({above:!1,markers:t=>t.state.selection.ranges.map((e=>e.empty?[]:gs.forRange(t,"cm-selectionBackground",e))).reduce(((t,e)=>t.concat(e))),update:(t,e)=>t.docChanged||t.selectionSet||t.viewportChanged||Ss(t),class:"cm-selectionLayer"}),Os={".cm-line":{"& ::selection":{backgroundColor:"transparent !important"},"&::selection":{backgroundColor:"transparent !important"}}};xs&&(Os[".cm-line"].caretColor="transparent !important",Os[".cm-content"]={caretColor:"transparent !important"});const Ds=st.highest(es.theme(Os));function Ts(t,e,i,n,r){e.lastIndex=0;for(let s,o=t.iterRange(i,n),l=i;!o.next().done;l+=o.value.length)if(!o.lineBreak)for(;s=e.exec(o.value);)r(l+s.index,s)}class Es{constructor(t){const{regexp:e,decoration:i,decorate:n,boundary:r,maxLength:s=1e3}=t;if(!e.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=e,n)this.addMatch=(t,e,i,r)=>n(r,i,i+t[0].length,t,e);else if("function"==typeof i)this.addMatch=(t,e,n,r)=>{let s=i(t,e,n);s&&r(n,n+t[0].length,s)};else{if(!i)throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.addMatch=(t,e,n,r)=>r(n,n+t[0].length,i)}this.boundary=r,this.maxLength=s}createDeco(t){let e=new Ft,i=e.add.bind(e);for(let{from:e,to:n}of function(t,e){let i=t.visibleRanges;if(1==i.length&&i[0].from==t.viewport.from&&i[0].to==t.viewport.to)return i;let n=[];for(let{from:r,to:s}of i)r=Math.max(t.state.doc.lineAt(r).from,r-e),s=Math.min(t.state.doc.lineAt(s).to,s+e),n.length&&n[n.length-1].to>=r?n[n.length-1].to=s:n.push({from:r,to:s});return n}(t,this.maxLength))Ts(t.state.doc,this.regexp,e,n,((e,n)=>this.addMatch(n,t,e,i)));return e.finish()}updateDeco(t,e){let i=1e9,n=-1;return t.docChanged&&t.changes.iterChanges(((e,r,s,o)=>{o>t.view.viewport.from&&s1e3?this.createDeco(t.view):n>-1?this.updateRange(t.view,e.map(t.changes),i,n):e}updateRange(t,e,i,n){for(let r of t.visibleRanges){let s=Math.max(r.from,i),o=Math.min(r.to,n);if(o>s){let i=t.state.doc.lineAt(s),n=i.toi.from;s--)if(this.boundary.test(i.text[s-1-i.from])){l=s;break}for(;oc.push(i.range(t,e));if(i==n)for(this.regexp.lastIndex=l-i.from;(a=this.regexp.exec(i.text))&&a.indexthis.addMatch(i,t,e,u)));e=e.update({filterFrom:l,filterTo:h,filter:(t,e)=>th,add:c})}}return e}}const Rs=null!=/x/.unicode?"gu":"g",Ps=new RegExp("[\0-\b\n--Ÿ­؜​‎‏\u2028\u2029‭‮⁦⁧⁩\ufeff-]",Rs),Bs={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"};let Ls=null;const Ns=$.define({combine(t){let e=Nt(t,{render:null,specialChars:Ps,addSpecialChars:null});return(e.replaceTabs=!function(){var t;if(null==Ls&&"undefined"!=typeof document&&document.body){let e=document.body.style;Ls=null!=(null!==(t=e.tabSize)&&void 0!==t?t:e.MozTabSize)}return Ls||!1}())&&(e.specialChars=new RegExp("\t|"+e.specialChars.source,Rs)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,Rs)),e}});let Is=null;class Vs extends di{constructor(t,e){super(),this.options=t,this.code=e}eq(t){return t.code==this.code}toDOM(t){let e=function(t){return t>=32?"•":10==t?"␤":String.fromCharCode(9216+t)}(this.code),i=t.state.phrase("Control character")+" "+(Bs[this.code]||"0x"+this.code.toString(16)),n=this.options.render&&this.options.render(this.code,i,e);if(n)return n;let r=document.createElement("span");return r.textContent=e,r.title=i,r.setAttribute("aria-label",i),r.className="cm-specialChar",r}ignoreEvent(){return!1}}class Hs extends di{constructor(t){super(),this.width=t}eq(t){return t.width==this.width}toDOM(){let t=document.createElement("span");return t.textContent="\t",t.className="cm-tab",t.style.width=this.width+"px",t}ignoreEvent(){return!1}}const Ws=2e3;function zs(t,e){let i=t.posAtCoords({x:e.clientX,y:e.clientY},!1),n=t.state.doc.lineAt(i),r=i-n.from,s=r>Ws?-1:r==n.length?function(t,e){let i=t.coordsAtPos(t.viewport.from);return i?Math.round(Math.abs((i.left-e)/t.defaultCharacterWidth)):-1}(t,e.clientX):Qt(n.text,t.state.tabSize,i-n.from);return{line:n.number,col:s,off:r}}function Fs(t,e){let i=zs(t,e),n=t.state.selection;return i?{update(t){if(t.docChanged){let e=t.changes.mapPos(t.startState.doc.line(i.line).from),r=t.state.doc.lineAt(e);i={line:r.number,col:i.col,off:Math.min(i.off,r.length)},n=n.map(t.changes)}},get(e,r,s){let o=zs(t,e);if(!o)return n;let l=function(t,e,i){let n=Math.min(e.line,i.line),r=Math.max(e.line,i.line),s=[];if(e.off>Ws||i.off>Ws||e.col<0||i.col<0){let o=Math.min(e.off,i.off),l=Math.max(e.off,i.off);for(let e=n;e<=r;e++){let i=t.doc.line(e);i.length<=l&&s.push(_.range(i.from+o,i.to+l))}}else{let o=Math.min(e.col,i.col),l=Math.max(e.col,i.col);for(let e=n;e<=r;e++){let i=t.doc.line(e),n=Zt(i.text,o,t.tabSize,!0);if(n<0)s.push(_.cursor(i.to));else{let e=Zt(i.text,l,t.tabSize);s.push(_.range(i.from+n,i.from+e))}}}return s}(t.state,i,o);return l.length?s?_.create(l.concat(n.ranges)):_.create(l):n}}:null}const qs={Alt:[18,t=>!!t.altKey],Control:[17,t=>!!t.ctrlKey],Shift:[16,t=>!!t.shiftKey],Meta:[91,t=>!!t.metaKey]},_s={style:"cursor: crosshair"};const js="-10000px";class Ks{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 r=null;this.tooltipViews=this.tooltips.map((t=>r=i(t,r)))}update(t,e){var i;let n=t.state.facet(this.facet),r=n.filter((t=>t));if(n===this.input){for(let e of this.tooltipViews)e.update&&e.update(t);return!1}let s=[],o=e?[]:null;for(let i=0;ie[i]=t)),e.length=o.length),this.input=n,this.tooltips=r,this.tooltipViews=s,!0}}function $s(t){let{win:e}=t;return{top:0,left:0,bottom:e.innerHeight,right:e.innerWidth}}const Us=$.define({combine:t=>{var e,i,n;return{position:Qe.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)||$s}}}),Gs=new WeakMap,Js=sn.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(Us);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 Ks(t,Qs,((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(Us);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=js,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=this.view.dom.getBoundingClientRect(),e=1,i=1,n=!1;if("fixed"==this.position&&this.manager.tooltipViews.length){let{dom:t}=this.manager.tooltipViews[0];if(Qe.gecko)n=t.offsetParent!=this.container.ownerDocument.body;else if(t.style.top==js&&"0px"==t.style.left){let e=t.getBoundingClientRect();n=Math.abs(e.top+1e4)>1||Math.abs(e.left)>1}}if(n||"absolute"==this.position)if(this.parent){let t=this.parent.getBoundingClientRect();t.width&&t.height&&(e=t.width/this.parent.offsetWidth,i=t.height/this.parent.offsetHeight)}else({scaleX:e,scaleY:i}=this.view.viewState);return{editor:t,parent:this.parent?this.container.getBoundingClientRect():t,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(Us).tooltipSpace(this.view),scaleX:e,scaleY:i,makeAbsolute:n}}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{editor:i,space:n,scaleX:r,scaleY:s}=t,o=[];for(let l=0;l=Math.min(i.bottom,n.bottom)||u.rightMath.min(i.right,n.right)+.1){c.style.top=js;continue}let d=h.arrow?a.dom.querySelector(".cm-tooltip-arrow"):null,p=d?7:0,g=f.right-f.left,m=null!==(e=Gs.get(a))&&void 0!==e?e:f.bottom-f.top,v=a.offset||Xs,w=this.view.textDirection==exports.Direction.LTR,y=f.width>n.right-n.left?w?n.left:n.right-f.width:w?Math.min(u.left-(d?14:0)+v.x,n.right-g):Math.max(n.left,u.left-g+(d?14:0)-v.x),b=this.above[l];!h.strictSide&&(b?u.top-(f.bottom-f.top)-v.yn.bottom)&&b==n.bottom-u.bottom>u.top-n.top&&(b=this.above[l]=!b);let x=(b?u.top-n.top:n.bottom-u.bottom)-p;if(xy&&t.topk&&(k=b?t.top-m-2-p:t.bottom+p+2);if("absolute"==this.position?(c.style.top=(k-t.parent.top)/s+"px",c.style.left=(y-t.parent.left)/r+"px"):(c.style.top=k/s+"px",c.style.left=y/r+"px"),d){let t=u.left+(w?v.x:-v.x)-(y+14-7);d.style.left=t/r+"px"}!0!==a.overlap&&o.push({left:y,top:k,right:S,bottom:k+m}),c.classList.toggle("cm-tooltip-above",b),c.classList.toggle("cm-tooltip-below",!b),a.positioned&&a.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=js}},{eventObservers:{scroll(){this.maybeMeasure()}}}),Ys=es.baseTheme({".cm-tooltip":{zIndex:100,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"}}}),Xs={x:0,y:0},Qs=$.define({enables:[Js,Ys]}),Zs=$.define({combine(t){let e,i;for(let n of t)e=e||n.topContainer,i=i||n.bottomContainer;return{topContainer:e,bottomContainer:i}}});function to(t,e){let i=t.plugin(eo),n=i?i.specs.indexOf(e):-1;return n>-1?i.panels[n]:null}const eo=sn.fromClass(class{constructor(t){this.input=t.state.facet(ro),this.specs=this.input.filter((t=>t)),this.panels=this.specs.map((e=>e(t)));let e=t.state.facet(Zs);this.top=new io(t,!0,e.topContainer),this.bottom=new io(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(Zs);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new io(t.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new io(t.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let i=t.state.facet(ro);if(i!=this.input){let e=i.filter((t=>t)),n=[],r=[],s=[],o=[];for(let i of e){let e,l=this.specs.indexOf(i);l<0?(e=i(t.view),o.push(e)):(e=this.panels[l],e.update&&e.update(t)),n.push(e),(e.top?r:s).push(e)}this.specs=e,this.panels=n,this.top.sync(r),this.bottom.sync(s);for(let t of o)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=>es.scrollMargins.of((e=>{let i=e.plugin(t);return i&&{top:i.top.scrollMargin(),bottom:i.bottom.scrollMargin()}}))});class io{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=no(t);t=t.nextSibling}else this.dom.insertBefore(e.dom,t);for(;t;)t=no(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 no(t){let e=t.nextSibling;return t.remove(),e}const ro=$.define({enables:eo});class so extends It{compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}eq(t){return!1}destroy(t){}}so.prototype.elementClass="",so.prototype.toDOM=void 0,so.prototype.mapMode=B.TrackBefore,so.prototype.startSide=so.prototype.endSide=-1,so.prototype.point=!0;const oo=$.define(),lo=$.define(),ho=$.define({combine:t=>t.some((t=>t))});function ao(t){let e=[co];return t&&!1===t.fixed&&e.push(ho.of(!0)),e}const co=sn.fromClass(class{constructor(t){this.view=t,this.prevViewport=t.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=t.state.facet(lo).map((e=>new go(t,e)));for(let t of this.gutters)this.dom.appendChild(t.dom);this.fixed=!t.state.facet(ho),this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),t.scrollDOM.insertBefore(this.dom,t.contentDOM)}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))}t.geometryChanged&&(this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px"),this.view.state.facet(ho)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":""),this.prevViewport=t.view.viewport}syncGutters(t){let e=this.dom.nextSibling;t&&this.dom.remove();let i=zt.iter(this.view.state.facet(oo),this.view.viewport.from),n=[],r=this.gutters.map((t=>new po(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 s of t.type)if(s.type==pi.Text&&e){fo(i,n,s.from);for(let t of r)t.line(this.view,s,n);e=!1}else if(s.widget)for(let t of r)t.widget(this.view,s)}else if(t.type==pi.Text){fo(i,n,t.from);for(let e of r)e.line(this.view,t,n)}else if(t.widget)for(let e of r)e.widget(this.view,t);for(let t of r)t.finish();t&&this.view.scrollDOM.insertBefore(this.dom,e)}updateGutters(t){let e=t.startState.facet(lo),i=t.state.facet(lo),n=t.docChanged||t.heightChanged||t.viewportChanged||!zt.eq(t.startState.facet(oo),t.state.facet(oo),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 r=[];for(let n of i){let i=e.indexOf(n);i<0?r.push(new go(this.view,n)):(this.gutters[i].update(t),r.push(this.gutters[i]))}for(let t of this.gutters)t.dom.remove(),r.indexOf(t)<0&&t.destroy();for(let t of r)this.dom.appendChild(t.dom);this.gutters=r}return n}destroy(){for(let t of this.gutters)t.destroy();this.dom.remove()}},{provide:t=>es.scrollMargins.of((e=>{let i=e.plugin(t);return i&&0!=i.gutters.length&&i.fixed?e.textDirection==exports.Direction.LTR?{left:i.dom.offsetWidth*e.scaleX}:{right:i.dom.offsetWidth*e.scaleX}:null}))});function uo(t){return Array.isArray(t)?t:[t]}function fo(t,e,i){for(;t.value&&t.from<=i;)t.from==i&&e.push(t.value),t.next()}class po{constructor(t,e,i){this.gutter=t,this.height=i,this.i=0,this.cursor=zt.iter(t.markers,e.from)}addElement(t,e,i){let{gutter:n}=this,r=(e.top-this.height)/t.scaleY,s=e.height/t.scaleY;if(this.i==n.elements.length){let e=new mo(t,s,r,i);n.elements.push(e),n.dom.appendChild(e.dom)}else n.elements[this.i].update(t,s,r,i);this.height=e.bottom,this.i++}line(t,e,i){let n=[];fo(this.cursor,n,e.from),i.length&&(n=n.concat(i));let r=this.gutter.config.lineMarker(t,e,n);r&&n.unshift(r);let s=this.gutter;(0!=n.length||s.config.renderEmptyElements)&&this.addElement(t,e,n)}widget(t,e){let i=this.gutter.config.widgetMarker(t,e.widget,e);i&&this.addElement(t,e,[i])}finish(){let t=this.gutter;for(;t.elements.length>this.i;){let e=t.elements.pop();t.dom.removeChild(e.dom),e.destroy()}}}class go{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 r,s=n.target;if(s!=this.dom&&this.dom.contains(s)){for(;s.parentNode!=this.dom;)s=s.parentNode;let t=s.getBoundingClientRect();r=(t.top+t.bottom)/2}else r=n.clientY;let o=t.lineBlockAtHeight(r-t.documentTop);e.domEventHandlers[i](t,o,n)&&n.preventDefault()}));this.markers=uo(e.markers(t)),e.initialSpacer&&(this.spacer=new mo(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=uo(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!zt.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 mo{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;iNt(t,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(t,e){let i=Object.assign({},t);for(let t in e){let n=i[t],r=e[t];i[t]=n?(t,e,i)=>n(t,e,i)||r(t,e,i):r}return i}})});class yo extends so{constructor(t){super(),this.number=t}eq(t){return this.number==t.number}toDOM(){return document.createTextNode(this.number)}}function bo(t,e){return t.state.facet(wo).formatNumber(e,t.state)}const xo=lo.compute([wo],(t=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers:t=>t.state.facet(vo),lineMarker:(t,e,i)=>i.some((t=>t.toDOM))?null:new yo(bo(t,t.state.doc.lineAt(e.from).number)),widgetMarker:()=>null,lineMarkerChange:t=>t.startState.facet(wo)!=t.state.facet(wo),initialSpacer:t=>new yo(bo(t,ko(t.state.doc.lines))),updateSpacer(t,e){let i=bo(e.view,ko(e.view.state.doc.lines));return i==t.number?t:new yo(i)},domEventHandlers:t.facet(wo).domEventHandlers})));function ko(t){let e=9;for(;e{throw new Error("This node type doesn't define a deserialize function")})}add(t){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return"function"!=typeof t&&(t=To.match(t)),e=>{let i=t(e);return void 0===i?null:[this,i]}}}Co.closedBy=new Co({deserialize:t=>t.split(" ")}),Co.openedBy=new Co({deserialize:t=>t.split(" ")}),Co.group=new Co({deserialize:t=>t.split(" ")}),Co.isolate=new Co({deserialize:t=>{if(t&&"rtl"!=t&&"ltr"!=t&&"auto"!=t)throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}}),Co.contextHash=new Co({perNode:!0}),Co.lookAhead=new Co({perNode:!0}),Co.mounted=new Co({perNode:!0});class Oo{constructor(t,e,i){this.tree=t,this.overlay=e,this.parser=i}static get(t){return t&&t.props&&t.props[Co.mounted.id]}}const Do=Object.create(null);class To{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):Do,i=(t.top?1:0)|(t.skipped?2:0)|(t.error?4:0)|(null==t.name?8:0),n=new To(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(Co.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(Co.group),n=-1;n<(i?i.length:0);n++){let r=e[n<0?t.name:i[n]];if(r)return r}}}}To.none=new To("",Object.create(null),0,8);class Eo{constructor(t){this.types=t;for(let e=0;e=e){let o=new zo(s.tree,s.overlay[0].from+t.from,-1,t);(r||(r=[n])).push(Ho(o,e,i,!1))}}return r?Ko(r):n}(this,t,e)}iterate(t){let{enter:e,leave:i,from:n=0,to:r=this.length}=t,s=t.mode||0,o=(s&Bo.IncludeAnonymous)>0;for(let t=this.cursor(s|Bo.IncludeAnonymous);;){let s=!1;if(t.from<=r&&t.to>=n&&(!o&&t.type.isAnonymous||!1!==e(t))){if(t.firstChild())continue;s=!0}for(;s&&i&&(o||!t.type.isAnonymous)&&i(t),!t.nextSibling();){if(!t.parent())return;s=!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:Xo(To.none,this.children,this.positions,0,this.children.length,0,this.length,((t,e,i)=>new Lo(this.type,t,e,i,this.propValues)),t.makeTree||((t,e,i)=>new Lo(To.none,t,e,i)))}static build(t){return function(t){var e;let{buffer:i,nodeSet:n,maxBufferLength:r=So,reused:s=[],minRepeatType:o=n.types.length}=t,l=Array.isArray(i)?new No(i,i.length):i,h=n.types,a=0,c=0;function u(t,e,i,w,y,b){let{id:x,start:k,end:S,size:A}=l,M=c;for(;A<0;){if(l.next(),-1==A){let e=s[x];return i.push(e),void w.push(k-t)}if(-3==A)return void(a=x);if(-4==A)return void(c=x);throw new RangeError(`Unrecognized record size: ${A}`)}let C,O,D=h[x],T=k-t;if(S-k<=r&&(O=m(l.pos-e,y))){let e=new Uint16Array(O.size-O.skip),i=l.pos-O.size,r=e.length;for(;l.pos>i;)r=v(O.start,e,r);C=new Io(e,S-O.start,n),T=O.start-t}else{let t=l.pos-A;l.next();let e=[],i=[],n=x>=o?x:-1,s=0,h=S;for(;l.pos>t;)n>=0&&l.id==n&&l.size>=0?(l.end<=h-r&&(p(e,i,k,s,l.end,h,n,M),s=e.length,h=l.end),l.next()):b>2500?f(k,t,e,i):u(k,t,e,i,n,b+1);if(n>=0&&s>0&&s-1&&s>0){let t=d(D);C=Xo(D,e,i,0,e.length,0,S-k,t,t)}else C=g(D,e,i,S-k,M-S)}i.push(C),w.push(T)}function f(t,e,i,s){let o=[],h=0,a=-1;for(;l.pos>e;){let{id:t,start:e,end:i,size:n}=l;if(n>4)l.next();else{if(a>-1&&e=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 Io(e,o[2]-r,n)),s.push(r-t)}}function d(t){return(e,i,n)=>{let r,s,o=0,l=e.length-1;if(l>=0&&(r=e[l])instanceof Lo){if(!l&&r.type==t&&r.length==n)return r;(s=r.prop(Co.lookAhead))&&(o=i[l]+r.length+s)}return g(t,e,i,n,o)}}function p(t,e,i,r,s,o,l,h){let a=[],c=[];for(;t.length>r;)a.push(t.pop()),c.push(e.pop()+i-s);t.push(g(n.types[l],a,c,o-s,h-o)),e.push(s-i)}function g(t,e,i,n,r=0,s){if(a){let t=[Co.contextHash,a];s=s?[t].concat(s):[t]}if(r>25){let t=[Co.lookAhead,r];s=s?[t].concat(s):[t]}return new Lo(t,e,i,n,s)}function m(t,e){let i=l.fork(),n=0,s=0,h=0,a=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=h,h+=4,n+=4,i.next();continue}let l=i.pos-t;if(t<0||l=o?4:0,f=i.start;for(i.next();i.pos>l;){if(i.size<0){if(-3!=i.size)break t;u+=4}else i.id>=o&&(u+=4);i.next()}s=f,n+=t,h+=u}return(e<0||n==t)&&(c.size=n,c.start=s,c.skip=h),c.size>4?c:void 0}function v(t,e,i){let{id:n,start:r,end:s,size:h}=l;if(l.next(),h>=0&&n4){let n=l.pos-(h-4);for(;l.pos>n;)i=v(t,e,i)}e[--i]=o,e[--i]=s-t,e[--i]=r-t,e[--i]=n}else-3==h?a=n:-4==h&&(c=n);return i}let w=[],y=[];for(;l.pos>0;)u(t.start||0,t.bufferStart||0,w,y,-1,0);let b=null!==(e=t.length)&&void 0!==e?e:w.length?y[0]+w[0].length:0;return new Lo(h[t.topID],w.reverse(),y.reverse(),b)}(t)}}Lo.empty=new Lo(To.none,[],[],0);class No{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 No(this.buffer,this.index)}}class Io{constructor(t,e,i){this.buffer=t,this.length=e,this.set=i}get type(){return To.none}toString(){let t=[];for(let e=0;e0));l=s[l+3]);return o}slice(t,e,i){let n=this.buffer,r=new Uint16Array(e-t),s=0;for(let o=t,l=0;o=e&&ie;case 1:return i<=e&&n>e;case 2:return n>e;case 4:return!0}}function Ho(t,e,i,n){for(var r;t.from==t.to||(i<1?t.from>=e:t.from>e)||(i>-1?t.to<=e:t.to0?o.length:-1;t!=h;t+=e){let h=o[t],a=l[t]+s.from;if(Vo(n,i,a,a+h.length))if(h instanceof Io){if(r&Bo.ExcludeBuffers)continue;let o=h.findChild(0,h.buffer.length,e,i-a,n);if(o>-1)return new jo(new _o(s,h,t,a),null,o)}else if(r&Bo.IncludeAnonymous||!h.type.isAnonymous||Go(h)){let o;if(!(r&Bo.IgnoreMounts)&&(o=Oo.get(h))&&!o.overlay)return new zo(o.tree,a,t,s);let l=new zo(h,a,t,s);return r&Bo.IncludeAnonymous||!l.type.isAnonymous?l:l.nextChild(e<0?h.children.length-1:0,e,i,n)}}if(r&Bo.IncludeAnonymous||!s.type.isAnonymous)return null;if(t=s.index>=0?s.index+e:e<0?-1:s._parent._tree.children.length,s=s._parent,!s)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)}enter(t,e,i=0){let n;if(!(i&Bo.IgnoreOverlays)&&(n=Oo.get(this._tree))&&n.overlay){let i=t-this.from;for(let{from:t,to:r}of n.overlay)if((e>0?t<=i:t=i:r>i))return new zo(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 Fo(t,e,i,n){let r=t.cursor(),s=[];if(!r.firstChild())return s;if(null!=i)for(let t=!1;!t;)if(t=r.type.is(i),!r.nextSibling())return s;for(;;){if(null!=n&&r.type.is(n))return s;if(r.type.is(e)&&s.push(r.node),!r.nextSibling())return null==n?s:[]}}function qo(t,e,i=e.length-1){for(let n=t.parent;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 _o{constructor(t,e,i,n){this.parent=t,this.buffer=e,this.index=i,this.start=n}}class jo extends Wo{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,r=n.findChild(this.index+4,n.buffer[this.index+3],t,e-this.context.start,i);return r<0?null:new jo(this.context,this,r)}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)}enter(t,e,i=0){if(i&Bo.ExcludeBuffers)return null;let{buffer:n}=this.context,r=n.findChild(this.index+4,n.buffer[this.index+3],e>0?1:-1,t-this.context.start,e);return r<0?null:new jo(this.context,this,r)}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 jo(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 jo(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,r=i.buffer[this.index+3];if(r>n){let s=i.buffer[this.index+1];t.push(i.slice(n,r,s)),e.push(0)}return new Lo(this.type,t,e,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function Ko(t){if(!t.length)return null;let e=0,i=t[0];for(let n=1;ni.from||r.to0){if(this.index-1)for(let n=e+t,r=t<0?-1:i._tree.children.length;n!=r;n+=t){let t=i._tree.children[n];if(this.mode&Bo.IncludeAnonymous||t instanceof Io||!t.type.isAnonymous||Go(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=0;){for(let s=t;s;s=s._parent)if(s.index==n){if(n==this.index)return s;e=s,i=r+1;break t}n=this.stack[--r]}for(let t=i;t=0;r--){if(r<0)return qo(this.node,t,n);let s=i[e.buffer[this.stack[r]]];if(!s.isAnonymous){if(t[n]&&t[n]!=s.name)return!1;n--}}return!0}}function Go(t){return t.children.some((t=>t instanceof Io||!t.type.isAnonymous||Go(t)))}const Jo=new WeakMap;function Yo(t,e){if(!t.isAnonymous||e instanceof Io||e.type!=t)return 1;let i=Jo.get(e);if(null==i){i=1;for(let n of e.children){if(n.type!=t||!(n instanceof Lo)){i=1;break}i+=Yo(t,n)}Jo.set(e,i)}return i}function Xo(t,e,i,n,r,s,o,l,h){let a=0;for(let i=n;i=c)break;p+=e}if(a==r+1){if(p>c){let t=i[r];e(t.children,t.positions,0,t.children.length,n[r]+l);continue}u.push(i[r])}else{let e=n[a-1]+i[a-1].length-d;u.push(Xo(t,i,n,r,a,d,e,null,h))}f.push(d+l-s)}}(e,i,n,r,0),(l||h)(u,f,o)}class Qo{constructor(t,e,i,n,r=!1,s=!1){this.from=t,this.to=e,this.tree=i,this.offset=n,this.open=(r?1:0)|(s?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 Qo(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=[],r=1,s=t.length?t[0]:null;for(let o=0,l=0,h=0;;o++){let a=o=i)for(;s&&s.from=e.from||c<=e.to||h){let t=Math.max(e.from,l)-h,i=Math.min(e.to,c)-h;e=t>=i?null:new Qo(t,i,e.tree,e.offset+h,o>0,!!a)}if(e&&n.push(e),s.to>c)break;s=rnew Mo(t.from,t.to))):[new Mo(0,0)]:[new Mo(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 tl{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)}}new Co({perNode:!0});let el=0;class il{constructor(t,e,i){this.set=t,this.base=e,this.modified=i,this.id=el++}static define(t){if(null==t?void 0:t.base)throw new Error("Can not derive from a modified tag");let e=new il([],null,[]);if(e.set.push(e),t)for(let i of t.set)e.set.push(i);return e}static defineModifier(){let t=new rl;return e=>e.modified.indexOf(t)>-1?e:rl.get(e.base||e,e.modified.concat(t).sort(((t,e)=>t.id-e.id)))}}let nl=0;class rl{constructor(){this.instances=[],this.id=nl++}static get(t,e){if(!e.length)return t;let i=e[0].instances.find((i=>{return i.base==t&&(n=e,r=i.modified,n.length==r.length&&n.every(((t,e)=>t==r[e])));var n,r}));if(i)return i;let n=[],r=new il(n,t,e);for(let t of e)t.instances.push(r);let s=function(t){let e=[[]];for(let i=0;ie.length-t.length))}(e);for(let e of t.set)if(!e.modified.length)for(let t of s)n.push(rl.get(e,t));return r}}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=[],r=2,s=t;for(let e=0;;){if("..."==s&&e>0&&e+3==t.length){r=1;break}let n=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(s);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 o=t[e++];if(e==t.length&&"!"==o){r=0;break}if("/"!=o)throw new RangeError("Invalid path: "+t);s=t.slice(e)}let o=i.length-1,l=i[o];if(!l)throw new RangeError("Invalid path: "+t);let h=new ll(n,r,o>0?i.slice(0,o):null);e[l]=h.sort(e[l])}}return ol.add(e)}const ol=new Co;class ll{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{let e=r;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 al(t,e,i,n=0,r=t.length){let s=new cl(n,Array.isArray(e)?e:[e],i);s.highlightRange(t.cursor(),n,r,"",s.highlighters),s.flush(r)}ll.empty=new ll([],2,null);class cl{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,r){let{type:s,from:o,to:l}=t;if(o>=i||l<=e)return;s.isTop&&(r=this.highlighters.filter((t=>!t.scope||t.scope(s))));let h=n,a=function(t){let e=t.type.prop(ol);for(;e&&e.context&&!t.matchContext(e.context);)e=e.next;return e||null}(t)||ll.empty,c=function(t,e){let i=null;for(let n of t){let t=n.style(e);t&&(i=i?i+" "+t:t)}return i}(r,a.tags);if(c&&(h&&(h+=" "),h+=c,1==a.mode&&(n+=(n?" ":"")+c)),this.startSpan(Math.max(e,o),h),a.opaque)return;let u=t.tree&&t.tree.prop(Co.mounted);if(u&&u.overlay){let s=t.node.enter(u.overlay[0].from+o,1),a=this.highlighters.filter((t=>!t.scope||t.scope(u.tree.type))),c=t.firstChild();for(let f=0,d=o;;f++){let p=f=g)&&t.nextSibling()););if(!p||g>i)break;d=p.to+o,d>e&&(this.highlightRange(s.cursor(),Math.max(e,p.from+o),Math.min(i,d),"",a),this.startSpan(Math.min(i,d),h))}c&&t.parent()}else if(t.firstChild()){u&&(n="");do{if(!(t.to<=e)){if(t.from>=i)break;this.highlightRange(t,e,i,n,r),this.startSpan(Math.min(i,t.to),h)}}while(t.nextSibling());t.parent()}}}const ul=il.define,fl=ul(),dl=ul(),pl=ul(dl),gl=ul(dl),ml=ul(),vl=ul(ml),wl=ul(ml),yl=ul(),bl=ul(yl),xl=ul(),kl=ul(),Sl=ul(),Al=ul(Sl),Ml=ul(),Cl={comment:fl,lineComment:ul(fl),blockComment:ul(fl),docComment:ul(fl),name:dl,variableName:ul(dl),typeName:pl,tagName:ul(pl),propertyName:gl,attributeName:ul(gl),className:ul(dl),labelName:ul(dl),namespace:ul(dl),macroName:ul(dl),literal:ml,string:vl,docString:ul(vl),character:ul(vl),attributeValue:ul(vl),number:wl,integer:ul(wl),float:ul(wl),bool:ul(ml),regexp:ul(ml),escape:ul(ml),color:ul(ml),url:ul(ml),keyword:xl,self:ul(xl),null:ul(xl),atom:ul(xl),unit:ul(xl),modifier:ul(xl),operatorKeyword:ul(xl),controlKeyword:ul(xl),definitionKeyword:ul(xl),moduleKeyword:ul(xl),operator:kl,derefOperator:ul(kl),arithmeticOperator:ul(kl),logicOperator:ul(kl),bitwiseOperator:ul(kl),compareOperator:ul(kl),updateOperator:ul(kl),definitionOperator:ul(kl),typeOperator:ul(kl),controlOperator:ul(kl),punctuation:Sl,separator:ul(Sl),bracket:Al,angleBracket:ul(Al),squareBracket:ul(Al),paren:ul(Al),brace:ul(Al),content:yl,heading:bl,heading1:ul(bl),heading2:ul(bl),heading3:ul(bl),heading4:ul(bl),heading5:ul(bl),heading6:ul(bl),contentSeparator:ul(yl),list:ul(yl),quote:ul(yl),emphasis:ul(yl),strong:ul(yl),link:ul(yl),monospace:ul(yl),strikethrough:ul(yl),inserted:ul(),deleted:ul(),changed:ul(),invalid:ul(),meta:Ml,documentMeta:ul(Ml),annotation:ul(Ml),processingInstruction:ul(Ml),definition:il.defineModifier(),constant:il.defineModifier(),function:il.defineModifier(),standard:il.defineModifier(),local:il.defineModifier(),special:il.defineModifier()};var Ol;hl([{tag:Cl.link,class:"tok-link"},{tag:Cl.heading,class:"tok-heading"},{tag:Cl.emphasis,class:"tok-emphasis"},{tag:Cl.strong,class:"tok-strong"},{tag:Cl.keyword,class:"tok-keyword"},{tag:Cl.atom,class:"tok-atom"},{tag:Cl.bool,class:"tok-bool"},{tag:Cl.url,class:"tok-url"},{tag:Cl.labelName,class:"tok-labelName"},{tag:Cl.inserted,class:"tok-inserted"},{tag:Cl.deleted,class:"tok-deleted"},{tag:Cl.literal,class:"tok-literal"},{tag:Cl.string,class:"tok-string"},{tag:Cl.number,class:"tok-number"},{tag:[Cl.regexp,Cl.escape,Cl.special(Cl.string)],class:"tok-string2"},{tag:Cl.variableName,class:"tok-variableName"},{tag:Cl.local(Cl.variableName),class:"tok-variableName tok-local"},{tag:Cl.definition(Cl.variableName),class:"tok-variableName tok-definition"},{tag:Cl.special(Cl.variableName),class:"tok-variableName2"},{tag:Cl.definition(Cl.propertyName),class:"tok-propertyName tok-definition"},{tag:Cl.typeName,class:"tok-typeName"},{tag:Cl.namespace,class:"tok-namespace"},{tag:Cl.className,class:"tok-className"},{tag:Cl.macroName,class:"tok-macroName"},{tag:Cl.propertyName,class:"tok-propertyName"},{tag:Cl.operator,class:"tok-operator"},{tag:Cl.comment,class:"tok-comment"},{tag:Cl.meta,class:"tok-meta"},{tag:Cl.invalid,class:"tok-invalid"},{tag:Cl.punctuation,class:"tok-punctuation"}]);const Dl=new Co;const Tl=new Co;class El{constructor(t,e,i=[],n=""){this.data=t,this.name=n,Lt.prototype.hasOwnProperty("tree")||Object.defineProperty(Lt.prototype,"tree",{get(){return Pl(this)}}),this.parser=e,this.extension=[Fl.of(this),Lt.languageData.of(((t,e,i)=>{let n=Rl(t,e,i),r=n.type.prop(Dl);if(!r)return[];let s=t.facet(r),o=n.type.prop(Tl);if(o){let r=n.resolve(e-n.from,i);for(let e of o)if(e.test(r,t)){let i=t.facet(e.facet);return"replace"==e.type?i:i.concat(s)}}return s}))].concat(i)}isActiveAt(t,e,i=-1){return Rl(t,e,i).type.prop(Dl)==this.data}findRegions(t){let e=t.facet(Fl);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(Dl)==this.data)return void i.push({from:e,to:e+t.length});let r=t.prop(Co.mounted);if(r){if(r.tree.prop(Dl)==this.data){if(r.overlay)for(let t of r.overlay)i.push({from:t.from+e,to:t.to+e});else i.push({from:e,to:e+t.length});return}if(r.overlay){let t=i.length;if(n(r.tree,r.overlay[0].from+e),i.length>t)return}}for(let i=0;i=this.cursorPos?this.doc.sliceString(t,e):this.string.slice(t-i,e-i)}}let Ll=null;class Nl{constructor(t,e,i=[],n,r,s,o,l){this.parser=t,this.state=e,this.fragments=i,this.tree=n,this.treeLen=r,this.viewport=s,this.skipped=o,this.scheduleOn=l,this.parse=null,this.tempSkipped=[]}static create(t,e,i){return new Nl(t,e,[],Lo.empty,0,i,[],null)}startParse(){return this.parser.startParse(new Bl(this.state.doc),this.fragments)}work(t,e){return null!=e&&e>=this.state.doc.length&&(e=void 0),this.tree!=Lo.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.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(Qo.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(t){let e=Ll;Ll=this;try{return t()}finally{Ll=e}}withoutTempSkipped(t){for(let e;e=this.tempSkipped.pop();)t=Il(t,e.from,e.to);return t}changes(t,e){let{fragments:i,tree:n,treeLen:r,viewport:s,skipped:o}=this;if(this.takeTree(),!t.empty){let e=[];if(t.iterChangedRanges(((t,i,n,r)=>e.push({fromA:t,toA:i,fromB:n,toB:r}))),i=Qo.applyChanges(i,e),n=Lo.empty,r=0,s={from:t.mapPos(s.from,-1),to:t.mapPos(s.to,1)},this.skipped.length){o=[];for(let e of this.skipped){let i=t.mapPos(e.from,1),n=t.mapPos(e.to,-1);it.from&&(this.fragments=Il(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 Zo{createParse(e,i,n){let r=n[0].from,s=n[n.length-1].to;return{parsedPos:r,advance(){let e=Ll;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=s,new Lo(To.none,[],[],s-r)},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 Ll}}function Il(t,e,i){return Qo.applyChanges(t,[{fromA:e,toA:i,fromB:e,toB:i}])}class Vl{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 Vl(e)}static init(t){let e=Math.min(3e3,t.doc.length),i=Nl.create(t.facet(Fl).parser,t,{from:0,to:e});return i.work(20,e)||i.takeTree(),new Vl(i)}}El.state=Z.define({create:Vl.init,update(t,e){for(let t of e.effects)if(t.is(El.setState))return t.value;return e.startState.facet(Fl)!=e.state.facet(Fl)?Vl.init(e.state):t.apply(e)}});let Hl=t=>{let e=setTimeout((()=>t()),500);return()=>clearTimeout(e)};"undefined"!=typeof requestIdleCallback&&(Hl=t=>{let e=-1,i=setTimeout((()=>{e=requestIdleCallback(t,{timeout:400})}),100);return()=>e<0?clearTimeout(i):cancelIdleCallback(e)});const Wl="undefined"!=typeof navigator&&(null===(Ol=navigator.scheduling)||void 0===Ol?void 0:Ol.isInputPending)?()=>navigator.scheduling.isInputPending():null,zl=sn.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(El.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(El.state);e.tree==e.context.tree&&e.context.isDone(t.doc.length)||(this.working=Hl(this.work))}work(t){this.working=null;let e=Date.now();if(this.chunkEndn+1e3,l=r.context.work((()=>Wl&&Wl()||Date.now()>s),n+(o?0:1e5));this.chunkBudget-=Date.now()-e,(l||this.chunkBudget<=0)&&(r.context.takeTree(),this.view.dispatch({effects:El.setState.of(new Vl(r.context))})),this.chunkBudget>0&&(!l||o)&&this.scheduleWork(),this.checkAsyncSchedule(r.context)}checkAsyncSchedule(t){t.scheduleOn&&(this.workScheduled++,t.scheduleOn.then((()=>this.scheduleWork())).catch((t=>tn(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()}}}),Fl=$.define({combine:t=>t.length?t[0]:null,enables:t=>[El.state,zl,es.contentAttributes.compute([t],(e=>{let i=e.facet(t);return i&&i.name?{"data-language":i.name}:{}}))]});const ql=$.define(),_l=$.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 jl(t){let e=t.facet(_l);return 9==e.charCodeAt(0)?t.tabSize*e.length:e.length}function Kl(t,e){let i="",n=t.tabSize,r=t.facet(_l)[0];if("\t"==r){for(;e>=n;)i+="\t",e-=n;r=" "}for(let t=0;t=e?function(t,e,i){let n=e.resolveStack(i),r=n.node.enterUnfinishedNodesBefore(i);if(r!=n.node){let t=[];for(let e=r;e!=n.node;e=e.parent)t.push(e);for(let e=t.length-1;e>=0;e--)n={node:t[e],next:n}}return Jl(n,t,i)}(t,i,e):null}class Ul{constructor(t,e={}){this.state=t,this.options=e,this.unit=jl(t)}lineAt(t,e=1){let i=this.state.doc.lineAt(t),{simulateBreak:n,simulateDoubleBreak:r}=this.options;return null!=n&&n>=i.from&&n<=i.to?r&&n==t?{text:"",from:t}:(e<0?n-1&&(r+=s-this.countColumn(i,i.search(/\S|$/))),r}countColumn(t,e=t.length){return Qt(t,this.state.tabSize,e)}lineIndent(t,e=1){let{text:i,from:n}=this.lineAt(t,e),r=this.options.overrideIndentation;if(r){let t=r(n);if(t>-1)return t}return this.countColumn(i,i.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const Gl=new Co;function Jl(t,e,i){for(let n=t;n;n=n.next){let t=Yl(n.node);if(t)return t(Ql.create(e,i,n))}return 0}function Yl(t){let e=t.type.prop(Gl);if(e)return e;let i,n=t.firstChild;if(n&&(i=n.type.prop(Co.closedBy))){let e=t.lastChild,n=e&&i.indexOf(e.name)>-1;return t=>function(t,e,i,n,r){let s=t.textAfter,o=s.match(/^\s*/)[0].length,l=n&&s.slice(o,o+n.length)==n||r==t.pos+o,h=e?function(t){let e=t.node,i=e.childAfter(e.from),n=e.lastChild;if(!i)return null;let r=t.options.simulateBreak,s=t.state.doc.lineAt(i.from),o=null==r||r<=s.from?s.to:Math.min(s.to,r);for(let t=i.to;;){let r=e.childAfter(t);if(!r||r==n)return null;if(!r.type.isSkipped)return r.from=n?void 0:{from:i,to:n}}const eh=kt.define({map:th}),ih=kt.define({map:th}),nh=Z.define({create:()=>gi.none,update(t,e){t=t.map(e.changes);for(let i of e.effects)if(i.is(eh)&&!rh(t,i.value.from,i.value.to)){let{preparePlaceholder:n}=e.state.facet(oh),r=n?gi.replace({widget:new ah(n(e.state,i.value))}):hh;t=t.update({add:[r.range(i.value.from,i.value.to)]})}else i.is(ih)&&(t=t.update({filter:(t,e)=>i.value.from!=t||i.value.to!=e,filterFrom:i.value.from,filterTo:i.value.to}));if(e.selection){let i=!1,{head:n}=e.selection.main;t.between(n,n,((t,e)=>{tn&&(i=!0)})),i&&(t=t.update({filterFrom:n,filterTo:n,filter:(t,e)=>e<=n||t>=n}))}return t},provide:t=>es.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==e&&r==i&&(n=!0)})),n}const sh={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},oh=$.define({combine:t=>Nt(t,sh)});function lh(t,e){let{state:i}=t,n=i.facet(oh),r=e=>{let i=t.lineBlockAt(t.posAtDOM(e.target)),n=function(t,e,i){var n;let r=null;return null===(n=t.field(nh,!1))||void 0===n||n.between(e,i,((t,e)=>{(!r||r.from>t)&&(r={from:t,to:e})})),r}(t.state,i.from,i.to);n&&t.dispatch({effects:ih.of(n)}),e.preventDefault()};if(n.placeholderDOM)return n.placeholderDOM(t,r,e);let s=document.createElement("span");return s.textContent=n.placeholderText,s.setAttribute("aria-label",i.phrase("folded code")),s.title=i.phrase("unfold"),s.className="cm-foldPlaceholder",s.onclick=r,s}const hh=gi.replace({widget:new class extends di{toDOM(t){return lh(t,null)}}});class ah extends di{constructor(t){super(),this.value=t}eq(t){return this.value==t.value}toDOM(t){return lh(t,this.value)}}const ch=es.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 uh{constructor(t,e){let i;function n(t){let e=ne.newName();return(i||(i=Object.create(null)))["."+e]=t,e}this.specs=t;const r="string"==typeof e.all?e.all:e.all?n(e.all):void 0,s=e.scope;this.scope=s instanceof El?t=>t.prop(Dl)==s.data:s?t=>t==s:void 0,this.style=hl(t.map((t=>({tag:t.tag,class:t.class||n(Object.assign({},t,{tag:null}))}))),{all:r}).style,this.module=i?new ne(i):null,this.themeType=e.themeType}static define(t,e){return new uh(t,e||{})}}const fh=$.define(),dh=$.define({combine:t=>t.length?[t[0]]:null});function ph(t){let e=t.facet(fh);return e.length?e:t.facet(dh)}class gh{constructor(t){this.markCache=Object.create(null),this.tree=Pl(t.state),this.decorations=this.buildDeco(t,ph(t.state)),this.decoratedTo=t.viewport.to}update(t){let e=Pl(t.state),i=ph(t.state),n=i!=ph(t.startState),{viewport:r}=t.view,s=t.changes.mapPos(this.decoratedTo,1);e.length=r.to?(this.decorations=this.decorations.map(t.changes),this.decoratedTo=s):(e!=this.tree||t.viewportChanged||n)&&(this.tree=e,this.decorations=this.buildDeco(t.view,i),this.decoratedTo=r.to)}buildDeco(t,e){if(!e||!this.tree.length)return gi.none;let i=new Ft;for(let{from:n,to:r}of t.visibleRanges)al(this.tree,e,((t,e,n)=>{i.add(t,e,this.markCache[n]||(this.markCache[n]=gi.mark({class:n})))}),n,r);return i.finish()}}const mh=st.high(sn.fromClass(gh,{decorations:t=>t.decorations})),vh=es.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),wh=1e4,yh="()[]{}",bh=$.define({combine:t=>Nt(t,{afterCursor:!0,brackets:yh,maxScanDistance:wh,renderMatch:Sh})}),xh=gi.mark({class:"cm-matchingBracket"}),kh=gi.mark({class:"cm-nonmatchingBracket"});function Sh(t){let e=[],i=t.matched?xh:kh;return e.push(i.range(t.start.from,t.start.to)),t.end&&e.push(i.range(t.end.from,t.end.to)),e}const Ah=Z.define({create:()=>gi.none,update(t,e){if(!e.docChanged&&!e.selection)return t;let i=[],n=e.state.facet(bh);for(let t of e.state.selection.ranges){if(!t.empty)continue;let r=Th(e.state,t.head,-1,n)||t.head>0&&Th(e.state,t.head-1,1,n)||n.afterCursor&&(Th(e.state,t.head,1,n)||t.heades.decorations.from(t)}),Mh=[Ah,vh];const Ch=new Co;function Oh(t,e,i){let n=t.prop(e<0?Co.openedBy:Co.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 Dh(t){let e=t.type.prop(Ch);return e?e(t.node):t}function Th(t,e,i,n={}){let r=n.maxScanDistance||wh,s=n.brackets||yh,o=Pl(t),l=o.resolveInner(e,i);for(let n=l;n;n=n.parent){let r=Oh(n.type,i,s);if(r&&n.from0?e>=o.from&&eo.from&&e<=o.to))return Eh(t,e,i,n,o,r,s)}}return function(t,e,i,n,r,s,o){let l=i<0?t.sliceDoc(e-1,e):t.sliceDoc(e,e+1),h=o.indexOf(l);if(h<0||h%2==0!=i>0)return null;let a={from:i<0?e-1:e,to:i>0?e+1:e},c=t.doc.iterRange(e,i>0?t.doc.length:0),u=0;for(let t=0;!c.next().done&&t<=s;){let s=c.value;i<0&&(t+=s.length);let l=e+t*i;for(let t=i>0?0:s.length-1,e=i>0?s.length:-1;t!=e;t+=i){let e=o.indexOf(s[t]);if(!(e<0||n.resolveInner(l+t,1).type!=r))if(e%2==0==i>0)u++;else{if(1==u)return{start:a,end:{from:l+t,to:l+t+1},matched:e>>1==h>>1};u--}}i>0&&(t+=s.length)}return c.done?{start:a,matched:!1}:null}(t,e,i,o,l.type,r,s)}function Eh(t,e,i,n,r,s,o){let l=n.parent,h={from:r.from,to:r.to},a=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==a&&s.indexOf(c.type.name)>-1&&c.from=this.string.length}sol(){return 0==this.pos}peek(){return this.string.charAt(this.pos)||void 0}next(){if(this.pose}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.lastColumnPosi?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 Bh(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 Lh=new WeakMap;class Nh extends El{constructor(t){let e=(i=t.languageData,$.define({combine:i?t=>t.concat(i):void 0}));var i;let n,r={name:(s=t).name||"",token:s.token,blankLine:s.blankLine||(()=>{}),startState:s.startState||(()=>!0),copyState:s.copyState||Bh,indent:s.indent||(()=>null),languageData:s.languageData||{},tokenTable:s.tokenTable||zh};var s;super(e,new class extends Zo{createParse(t,e,i){return new Hh(n,t,e,i)}},[ql.of(((t,e)=>this.getIndent(t,e)))],t.name),this.topNode=function(t){let e=To.define({id:Fh.length,name:"Document",props:[Dl.add((()=>t))],top:!0});return Fh.push(e),e}(e),n=this,this.streamParser=r,this.stateAfter=new Co({perNode:!0}),this.tokenTable=t.tokenTable?new $h(r.tokenTable):Uh}static define(t){return new Nh(t)}getIndent(t,e){let i,n=Pl(t.state),r=n.resolve(e);for(;r&&r.type!=this.topNode;)r=r.parent;if(!r)return null;let{overrideIndentation:s}=t.options;s&&(i=Lh.get(t.state),null!=i&&i1e4)return null;for(;o=n&&i+e.length<=r&&e.prop(t.stateAfter);if(s)return{state:t.streamParser.copyState(s),pos:i+e.length};for(let s=e.children.length-1;s>=0;s--){let o=e.children[s],l=i+e.positions[s],h=o instanceof Lo&&l=e.length)return e;r||e.type!=t.topNode||(r=!0);for(let s=e.children.length-1;s>=0;s--){let o,l=e.positions[s],h=e.children[s];if(li&&Ih(t,n.tree,0-n.offset,i,s);if(o&&(e=Vh(t,n.tree,i+n.offset,o.pos+n.offset,!1)))return{state:o.state,tree:e}}return{state:t.streamParser.startState(n?jl(n):4),tree:Lo.empty}}(t,i,s,null==r?void 0:r.state);this.state=o,this.parsedPos=this.chunkStart=s+l.length;for(let t=0;t=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 r=this.ranges[t].from,s=this.lineAfter(r);e+=s,i=r+s.length}return{line:e,end:i}}skipGapsTo(t,e,i){for(;;){let n=this.ranges[this.rangeIndex].to,r=t+e;if(i>0?n>r:n>=r)break;e+=this.ranges[++this.rangeIndex].from-n}return e}moveRangeIndex(){for(;this.ranges[this.rangeIndex].to1){e+=r=this.skipGapsTo(e,r,1);let t=this.chunk.length;i+=r=this.skipGapsTo(i,r,-1),n+=this.chunk.length-t}return this.chunk.push(t,e,i,n),r}parseLine(t){let{line:e,end:i}=this.nextLine(),n=0,{streamParser:r}=this.lang,s=new Ph(e,t?t.state.tabSize:4,t?jl(t.state):2);if(s.eol())r.blankLine(this.state,s.indentUnit);else for(;!s.eol();){let t=Wh(r.token,s,this.state);if(t&&(n=this.emitToken(this.lang.tokenTable.resolve(t),this.parsedPos+s.start,this.parsedPos+s.pos,4,n)),s.start>1e4)break}this.parsedPos=i,this.moveRangeIndex(),this.parsedPose.start)return n}throw new Error("Stream parser failed to advance stream.")}const zh=Object.create(null),Fh=[To.none],qh=new Eo(Fh),_h=[],jh=Object.create(null),Kh=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"]])Kh[t]=Jh(zh,e);class $h{constructor(t){this.extra=t,this.table=Object.assign(Object.create(null),Kh)}resolve(t){return t?this.table[t]||(this.table[t]=Jh(this.extra,t)):0}}const Uh=new $h(zh);function Gh(t,e){_h.indexOf(t)>-1||(_h.push(t),console.warn(e))}function Jh(t,e){let i=[];for(let n of e.split(" ")){let e=[];for(let i of n.split(".")){let n=t[i]||Cl[i];n?"function"==typeof n?e.length?e=e.map(n):Gh(i,`Modifier ${i} used at start of tag`):e.length?Gh(i,`Tag ${i} used as modifier`):e=Array.isArray(n)?n:[n]:Gh(i,`Unknown highlighting tag ${i}`)}for(let t of e)i.push(t)}if(!i.length)return 0;let n=e.replace(/ /g,"_"),r=n+" "+i.map((t=>t.id)),s=jh[r];if(s)return s.id;let o=jh[r]=To.define({id:Fh.length,name:n,props:[sl({[n]:i})]});return Fh.push(o),o.id}exports.Direction.RTL,exports.Direction.LTR;function Yh(t,e){return({state:i,dispatch:n})=>{if(i.readOnly)return!1;let r=t(e,i);return!!r&&(n(i.update(r)),!0)}}const Xh=Yh(na,0),Qh=Yh(ia,0),Zh=Yh(((t,e)=>ia(t,e,function(t){let e=[];for(let i of t.selection.ranges){let n=t.doc.lineAt(i.from),r=i.to<=n.to?n:t.doc.lineAt(i.to),s=e.length-1;s>=0&&e[s].to>n.from?e[s].to=r.to:e.push({from:n.from+/^\s*/.exec(n.text)[0].length,to:r.to})}return e}(e))),0);function ta(t,e){let i=t.languageDataAt("commentTokens",e);return i.length?i[0]:{}}const ea=50;function ia(t,e,i=e.selection.ranges){let n=i.map((t=>ta(e,t.from).block));if(!n.every((t=>t)))return null;let r=i.map(((t,i)=>function(t,{open:e,close:i},n,r){let s,o,l=t.sliceDoc(n-ea,n),h=t.sliceDoc(r,r+ea),a=/\s*$/.exec(l)[0].length,c=/^\s*/.exec(h)[0].length,u=l.length-a;if(l.slice(u-e.length,u)==e&&h.slice(c,c+i.length)==i)return{open:{pos:n-a,margin:a&&1},close:{pos:r+c,margin:c&&1}};r-n<=2*ea?s=o=t.sliceDoc(n,r):(s=t.sliceDoc(n,n+ea),o=t.sliceDoc(r-ea,r));let f=/^\s*/.exec(s)[0].length,d=/\s*$/.exec(o)[0].length,p=o.length-d-i.length;return s.slice(f,f+e.length)==e&&o.slice(p,p+i.length)==i?{open:{pos:n+f+e.length,margin:/\s/.test(s.charAt(f+e.length))?1:0},close:{pos:r-d-i.length,margin:/\s/.test(o.charAt(p-1))?1:0}}:null}(e,n[i],t.from,t.to)));if(2!=t&&!r.every((t=>t)))return{changes:e.changes(i.map(((t,e)=>r[e]?[]:[{from:t.from,insert:n[e].open+" "},{from:t.to,insert:" "+n[e].close}])))};if(1!=t&&r.some((t=>t))){let t=[];for(let e,i=0;ir&&(t==s||s>h.from)){r=h.from;let t=/^\s*/.exec(h.text)[0].length,e=t==h.length,i=h.text.slice(t,t+l.length)==l?t:-1;tt.comment<0&&(!t.empty||t.single)))){let t=[];for(let{line:e,token:i,indent:r,empty:s,single:o}of n)!o&&s||t.push({from:e.from+r,insert:i+" "});let i=e.changes(t);return{changes:i,selection:e.selection.map(i,1)}}if(1!=t&&n.some((t=>t.comment>=0))){let t=[];for(let{line:e,comment:i,token:r}of n)if(i>=0){let n=e.from+i,s=n+r.length;" "==e.text[s-e.from]&&s++,t.push({from:n,to:s})}return{changes:t}}return null}const ra=yt.define(),sa=yt.define(),oa=$.define(),la=$.define({combine:t=>Nt(t,{minDepth:100,newGroupDelay:500,joinToEvent:(t,e)=>e},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(t,e)=>(i,n)=>t(i,n)||e(i,n)})}),ha=Z.define({create:()=>Aa.empty,update(t,e){let i=e.state.facet(la),n=e.annotation(ra);if(n){let r=pa.fromTransaction(e,n.selection),s=n.side,o=0==s?t.undone:t.done;return o=r?ga(o,o.length,i.minDepth,r):ya(o,e.startState.selection),new Aa(0==s?n.rest:o,0==s?o:n.rest)}let r=e.annotation(sa);if("full"!=r&&"before"!=r||(t=t.isolate()),!1===e.annotation(St.addToHistory))return e.changes.empty?t:t.addMapping(e.changes.desc);let s=pa.fromTransaction(e),o=e.annotation(St.time),l=e.annotation(St.userEvent);return s?t=t.addChanges(s,o,l,i,e):e.selection&&(t=t.addSelection(e.startState.selection,o,l,i.newGroupDelay)),"full"!=r&&"after"!=r||(t=t.isolate()),t},toJSON:t=>({done:t.done.map((t=>t.toJSON())),undone:t.undone.map((t=>t.toJSON()))}),fromJSON:t=>new Aa(t.done.map(pa.fromJSON),t.undone.map(pa.fromJSON))});function aa(t,e){return function({state:i,dispatch:n}){if(!e&&i.readOnly)return!1;let r=i.field(ha,!1);if(!r)return!1;let s=r.pop(t,i,e);return!!s&&(n(s),!0)}}const ca=aa(0,!1),ua=aa(1,!1),fa=aa(0,!0),da=aa(1,!0);class pa{constructor(t,e,i,n,r){this.changes=t,this.effects=e,this.mapped=i,this.startSelection=n,this.selectionsAfter=r}setSelAfter(t){return new pa(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){var t,e,i;return{changes:null===(t=this.changes)||void 0===t?void 0:t.toJSON(),mapped:null===(e=this.mapped)||void 0===e?void 0:e.toJSON(),startSelection:null===(i=this.startSelection)||void 0===i?void 0:i.toJSON(),selectionsAfter:this.selectionsAfter.map((t=>t.toJSON()))}}static fromJSON(t){return new pa(t.changes&&N.fromJSON(t.changes),[],t.mapped&&L.fromJSON(t.mapped),t.startSelection&&_.fromJSON(t.startSelection),t.selectionsAfter.map(_.fromJSON))}static fromTransaction(t,e){let i=va;for(let e of t.startState.facet(oa)){let n=e(t);n.length&&(i=i.concat(n))}return!i.length&&t.changes.empty?null:new pa(t.changes.invert(t.startState.doc),i,void 0,e||t.startState.selection,va)}static selection(t){return new pa(void 0,va,void 0,void 0,t)}}function ga(t,e,i,n){let r=e+1>i+20?e-i-1:0,s=t.slice(r,e);return s.push(n),s}function ma(t,e){return t.length?e.length?t.concat(e):t:e}const va=[],wa=200;function ya(t,e){if(t.length){let i=t[t.length-1],n=i.selectionsAfter.slice(Math.max(0,i.selectionsAfter.length-wa));return n.length&&n[n.length-1].eq(e)?t:(n.push(e),ga(t,t.length-1,1e9,i.setSelAfter(n)))}return[pa.selection([e])]}function ba(t){let e=t[t.length-1],i=t.slice();return i[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),i}function xa(t,e){if(!t.length)return t;let i=t.length,n=va;for(;i;){let r=ka(t[i-1],e,n);if(r.changes&&!r.changes.empty||r.effects.length){let e=t.slice(0,i);return e[i-1]=r,e}e=r.mapped,i--,n=r.selectionsAfter}return n.length?[pa.selection(n)]:va}function ka(t,e,i){let n=ma(t.selectionsAfter.length?t.selectionsAfter.map((t=>t.map(e))):va,i);if(!t.changes)return pa.selection(n);let r=t.changes.map(e),s=e.mapDesc(t.changes,!0),o=t.mapped?t.mapped.composeDesc(s):s;return new pa(r,kt.mapEffects(t.effects,e),o,t.startSelection.map(s),n)}const Sa=/^(input\.type|delete)($|\.)/;class Aa{constructor(t,e,i=0,n=void 0){this.done=t,this.undone=e,this.prevTime=i,this.prevUserEvent=n}isolate(){return this.prevTime?new Aa(this.done,this.undone):this}addChanges(t,e,i,n,r){let s=this.done,o=s[s.length-1];return s=o&&o.changes&&!o.changes.empty&&t.changes&&(!i||Sa.test(i))&&(!o.selectionsAfter.length&&e-this.prevTimei.push(t,e))),e.iterChangedRanges(((t,e,r,s)=>{for(let t=0;t=e&&r<=o&&(n=!0)}})),n}(o.changes,t.changes))||"input.type.compose"==i)?ga(s,s.length-1,n.minDepth,new pa(t.changes.compose(o.changes),ma(t.effects,o.effects),o.mapped,o.startSelection,va)):ga(s,s.length,n.minDepth,t),new Aa(s,va,e,i)}addSelection(t,e,i,n){let r=this.done.length?this.done[this.done.length-1].selectionsAfter:va;return r.length>0&&e-this.prevTimet.empty!=o.ranges[e].empty)).length)?this:new Aa(ya(this.done,t),this.undone,e,i);var s,o}addMapping(t){return new Aa(xa(this.done,t),xa(this.undone,t),this.prevTime,this.prevUserEvent)}pop(t,e,i){let n=0==t?this.done:this.undone;if(0==n.length)return null;let r=n[n.length-1],s=r.selectionsAfter[0]||e.selection;if(i&&r.selectionsAfter.length)return e.update({selection:r.selectionsAfter[r.selectionsAfter.length-1],annotations:ra.of({side:t,rest:ba(n),selection:s}),userEvent:0==t?"select.undo":"select.redo",scrollIntoView:!0});if(r.changes){let i=1==n.length?va:n.slice(0,n.length-1);return r.mapped&&(i=xa(i,r.mapped)),e.update({changes:r.changes,selection:r.startSelection,effects:r.effects,annotations:ra.of({side:t,rest:i,selection:s}),filter:!1,userEvent:0==t?"undo":"redo",scrollIntoView:!0})}return null}}Aa.empty=new Aa(va,va);const Ma=[{key:"Mod-z",run:ca,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:ua,preventDefault:!0},{linux:"Ctrl-Shift-z",run:ua,preventDefault:!0},{key:"Mod-u",run:fa,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:da,preventDefault:!0}];function Ca(t,e){return _.create(t.ranges.map(e),t.mainIndex)}function Oa(t,e){return t.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function Da({state:t,dispatch:e},i){let n=Ca(t.selection,i);return!n.eq(t.selection,!0)&&(e(Oa(t,n)),!0)}function Ta(t,e){return _.cursor(e?t.to:t.from)}function Ea(t,e){return Da(t,(i=>i.empty?t.moveByChar(i,e):Ta(i,e)))}function Ra(t){return t.textDirectionAt(t.state.selection.main.head)==exports.Direction.LTR}const Pa=t=>Ea(t,!Ra(t)),Ba=t=>Ea(t,Ra(t));function La(t,e){return Da(t,(i=>i.empty?t.moveByGroup(i,e):Ta(i,e)))}function Na(t,e,i){if(e.type.prop(i))return!0;let n=e.to-e.from;return n&&(n>2||/[^\s,.;:]/.test(t.sliceDoc(e.from,e.to)))||e.firstChild}function Ia(t,e,i){let n,r,s=Pl(t).resolveInner(e.head),o=i?Co.closedBy:Co.openedBy;for(let n=e.head;;){let e=i?s.childAfter(n):s.childBefore(n);if(!e)break;Na(t,e,o)?s=e:n=i?e.to:e.from}return r=s.type.prop(o)&&(n=i?Th(t,s.from,1):Th(t,s.to,-1))&&n.matched?i?n.end.to:n.end.from:i?s.to:s.from,_.cursor(r,i?-1:1)}function Va(t,e){return Da(t,(i=>{if(!i.empty)return Ta(i,e);let n=t.moveVertically(i,e);return n.head!=i.head?n:t.moveToLineBoundary(i,e)}))}const Ha=t=>Va(t,!1),Wa=t=>Va(t,!0);function za(t){let e,i=t.scrollDOM.clientHeighti.empty?t.moveVertically(i,e,n.height):Ta(i,e)));if(s.eq(r.selection))return!1;if(n.selfScroll){let e=t.coordsAtPos(r.selection.main.head),o=t.scrollDOM.getBoundingClientRect(),l=o.top+n.marginTop,h=o.bottom-n.marginBottom;e&&e.top>l&&e.bottomFa(t,!1),_a=t=>Fa(t,!0);function ja(t,e,i){let n=t.lineBlockAt(e.head),r=t.moveToLineBoundary(e,i);if(r.head==e.head&&r.head!=(i?n.to:n.from)&&(r=t.moveToLineBoundary(e,i,!1)),!i&&r.head==n.from&&n.length){let i=/^\s*/.exec(t.state.sliceDoc(n.from,Math.min(n.from+100,n.to)))[0].length;i&&e.head!=n.from+i&&(r=_.cursor(n.from+i))}return r}function Ka(t,e){let i=Ca(t.state.selection,(t=>{let i=e(t);return _.range(t.anchor,i.head,i.goalColumn,i.bidiLevel||void 0)}));return!i.eq(t.state.selection)&&(t.dispatch(Oa(t.state,i)),!0)}function $a(t,e){return Ka(t,(i=>t.moveByChar(i,e)))}const Ua=t=>$a(t,!Ra(t)),Ga=t=>$a(t,Ra(t));function Ja(t,e){return Ka(t,(i=>t.moveByGroup(i,e)))}function Ya(t,e){return Ka(t,(i=>t.moveVertically(i,e)))}const Xa=t=>Ya(t,!1),Qa=t=>Ya(t,!0);function Za(t,e){return Ka(t,(i=>t.moveVertically(i,e,za(t).height)))}const tc=t=>Za(t,!1),ec=t=>Za(t,!0),ic=({state:t,dispatch:e})=>(e(Oa(t,{anchor:0})),!0),nc=({state:t,dispatch:e})=>(e(Oa(t,{anchor:t.doc.length})),!0),rc=({state:t,dispatch:e})=>(e(Oa(t,{anchor:t.selection.main.anchor,head:0})),!0),sc=({state:t,dispatch:e})=>(e(Oa(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0);function oc(t,e){if(t.state.readOnly)return!1;let i="delete.selection",{state:n}=t,r=n.changeByRange((n=>{let{from:r,to:s}=n;if(r==s){let o=e(n);or&&(i="delete.forward",o=lc(t,o,!0)),r=Math.min(r,o),s=Math.max(s,o)}else r=lc(t,r,!1),s=lc(t,s,!0);return r==s?{range:n}:{changes:{from:r,to:s},range:_.cursor(r,re(t))))n.between(e,e,((t,n)=>{te&&(e=i?n:t)}));return e}const hc=(t,e,i)=>oc(t,(n=>{let r,s,o=n.from,{state:l}=t,h=l.doc.lineAt(o);if(i&&!e&&o>h.from&&ohc(t,!1,!0),cc=t=>hc(t,!0,!1),uc=(t,e)=>oc(t,(i=>{let n=i.head,{state:r}=t,s=r.doc.lineAt(n),o=r.charCategorizer(n);for(let t=null;;){if(n==(e?s.to:s.from)){n==i.head&&s.number!=(e?r.doc.lines:1)&&(n+=e?1:-1);break}let l=A(s.text,n-s.from,e)+s.from,h=s.text.slice(Math.min(n,l)-s.from,Math.max(n,l)-s.from),a=o(h);if(null!=t&&a!=t)break;" "==h&&n==i.head||(t=a),n=l}return n})),fc=t=>uc(t,!1);function dc(t){let e=[],i=-1;for(let n of t.selection.ranges){let r=t.doc.lineAt(n.from),s=t.doc.lineAt(n.to);if(n.empty||n.to!=s.from||(s=t.doc.lineAt(n.to-1)),i>=r.number){let t=e[e.length-1];t.to=s.to,t.ranges.push(n)}else e.push({from:r.from,to:s.to,ranges:[n]});i=s.number+1}return e}function pc(t,e,i){if(t.readOnly)return!1;let n=[],r=[];for(let e of dc(t)){if(i?e.to==t.doc.length:0==e.from)continue;let s=t.doc.lineAt(i?e.to+1:e.from-1),o=s.length+1;if(i){n.push({from:e.to,to:s.to},{from:e.from,insert:s.text+t.lineBreak});for(let i of e.ranges)r.push(_.range(Math.min(t.doc.length,i.anchor+o),Math.min(t.doc.length,i.head+o)))}else{n.push({from:s.from,to:e.from},{from:e.to,insert:t.lineBreak+s.text});for(let t of e.ranges)r.push(_.range(t.anchor-o,t.head-o))}}return!!n.length&&(e(t.update({changes:n,scrollIntoView:!0,selection:_.create(r,t.selection.mainIndex),userEvent:"move.line"})),!0)}function gc(t,e,i){if(t.readOnly)return!1;let n=[];for(let e of dc(t))i?n.push({from:e.from,insert:t.doc.slice(e.from,e.to)+t.lineBreak}):n.push({from:e.to,insert:t.lineBreak+t.doc.slice(e.from,e.to)});return e(t.update({changes:n,scrollIntoView:!0,userEvent:"input.copyline"})),!0}const mc=vc(!1);function vc(t){return({state:e,dispatch:i})=>{if(e.readOnly)return!1;let n=e.changeByRange((i=>{let{from:n,to:r}=i,s=e.doc.lineAt(n),o=!t&&n==r&&function(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let i,n=Pl(t).resolveInner(e),r=n.childBefore(e),s=n.childAfter(e);return r&&s&&r.to<=e&&s.from>=e&&(i=r.type.prop(Co.closedBy))&&i.indexOf(s.name)>-1&&t.doc.lineAt(r.to).from==t.doc.lineAt(s.from).from&&!/\S/.test(t.sliceDoc(r.to,s.from))?{from:r.to,to:s.from}:null}(e,n);t&&(n=r=(r<=s.to?s:e.doc.lineAt(r)).to);let l=new Ul(e,{simulateBreak:n,simulateDoubleBreak:!!o}),h=$l(l,n);for(null==h&&(h=Qt(/^\s*/.exec(e.doc.lineAt(n).text)[0],e.tabSize));rs.from&&n{let r=[];for(let s=n.from;s<=n.to;){let o=t.doc.lineAt(s);o.number>i&&(n.empty||n.to>o.from)&&(e(o,r,n),i=o.number),s=o.to+1}let s=t.changes(r);return{changes:r,range:_.range(s.mapPos(n.anchor,1),s.mapPos(n.head,1))}}))}const yc=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:t=>Da(t,(e=>Ia(t.state,e,!Ra(t)))),shift:t=>Ka(t,(e=>Ia(t.state,e,!Ra(t))))},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:t=>Da(t,(e=>Ia(t.state,e,Ra(t)))),shift:t=>Ka(t,(e=>Ia(t.state,e,Ra(t))))},{key:"Alt-ArrowUp",run:({state:t,dispatch:e})=>pc(t,e,!1)},{key:"Shift-Alt-ArrowUp",run:({state:t,dispatch:e})=>gc(t,e,!1)},{key:"Alt-ArrowDown",run:({state:t,dispatch:e})=>pc(t,e,!0)},{key:"Shift-Alt-ArrowDown",run:({state:t,dispatch:e})=>gc(t,e,!0)},{key:"Escape",run:({state:t,dispatch:e})=>{let i=t.selection,n=null;return i.ranges.length>1?n=_.create([i.main]):i.main.empty||(n=_.create([_.cursor(i.main.head)])),!!n&&(e(Oa(t,n)),!0)}},{key:"Mod-Enter",run:vc(!0)},{key:"Alt-l",mac:"Ctrl-l",run:({state:t,dispatch:e})=>{let i=dc(t).map((({from:e,to:i})=>_.range(e,Math.min(i+1,t.doc.length))));return e(t.update({selection:_.create(i),userEvent:"select"})),!0}},{key:"Mod-i",run:({state:t,dispatch:e})=>{let i=Ca(t.selection,(e=>{var i;for(let n=Pl(t).resolveStack(e.from,1);n;n=n.next){let{node:t}=n;if((t.from=e.to||t.to>e.to&&t.from<=e.from)&&(null===(i=t.parent)||void 0===i?void 0:i.parent))return _.range(t.to,t.from)}return e}));return e(Oa(t,i)),!0},preventDefault:!0},{key:"Mod-[",run:({state:t,dispatch:e})=>!t.readOnly&&(e(t.update(wc(t,((e,i)=>{let n=/^\s*/.exec(e.text)[0];if(!n)return;let r=Qt(n,t.tabSize),s=0,o=Kl(t,Math.max(0,r-jl(t)));for(;s!t.readOnly&&(e(t.update(wc(t,((e,i)=>{i.push({from:e.from,insert:t.facet(_l)})})),{userEvent:"input.indent"})),!0)},{key:"Mod-Alt-\\",run:({state:t,dispatch:e})=>{if(t.readOnly)return!1;let i=Object.create(null),n=new Ul(t,{overrideIndentation:t=>{let e=i[t];return null==e?-1:e}}),r=wc(t,((e,r,s)=>{let o=$l(n,e.from);if(null==o)return;/\S/.test(e.text)||(o=0);let l=/^\s*/.exec(e.text)[0],h=Kl(t,o);(l!=h||s.from{if(t.state.readOnly)return!1;let{state:e}=t,i=e.changes(dc(e).map((({from:t,to:i})=>(t>0?t--:i{let i;if(t.lineWrapping){let n=t.lineBlockAt(e.head),r=t.coordsAtPos(e.head,e.assoc||1);r&&(i=n.bottom+t.documentTop-r.bottom+t.defaultLineHeight/2)}return t.moveVertically(e,!0,i)})).map(i);return t.dispatch({changes:i,selection:n,scrollIntoView:!0,userEvent:"delete.line"}),!0}},{key:"Shift-Mod-\\",run:({state:t,dispatch:e})=>function(t,e,i){let n=!1,r=Ca(t.selection,(e=>{let r=Th(t,e.head,-1)||Th(t,e.head,1)||e.head>0&&Th(t,e.head-1,1)||e.head{let{state:e}=t,i=e.doc.lineAt(e.selection.main.from),n=ta(t.state,i.from);return n.line?Xh(t):!!n.block&&Zh(t)}},{key:"Alt-A",run:Qh}].concat([{key:"ArrowLeft",run:Pa,shift:Ua,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:t=>La(t,!Ra(t)),shift:t=>Ja(t,!Ra(t)),preventDefault:!0},{mac:"Cmd-ArrowLeft",run:t=>Da(t,(e=>ja(t,e,!Ra(t)))),shift:t=>Ka(t,(e=>ja(t,e,!Ra(t)))),preventDefault:!0},{key:"ArrowRight",run:Ba,shift:Ga,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:t=>La(t,Ra(t)),shift:t=>Ja(t,Ra(t)),preventDefault:!0},{mac:"Cmd-ArrowRight",run:t=>Da(t,(e=>ja(t,e,Ra(t)))),shift:t=>Ka(t,(e=>ja(t,e,Ra(t)))),preventDefault:!0},{key:"ArrowUp",run:Ha,shift:Xa,preventDefault:!0},{mac:"Cmd-ArrowUp",run:ic,shift:rc},{mac:"Ctrl-ArrowUp",run:qa,shift:tc},{key:"ArrowDown",run:Wa,shift:Qa,preventDefault:!0},{mac:"Cmd-ArrowDown",run:nc,shift:sc},{mac:"Ctrl-ArrowDown",run:_a,shift:ec},{key:"PageUp",run:qa,shift:tc},{key:"PageDown",run:_a,shift:ec},{key:"Home",run:t=>Da(t,(e=>ja(t,e,!1))),shift:t=>Ka(t,(e=>ja(t,e,!1))),preventDefault:!0},{key:"Mod-Home",run:ic,shift:rc},{key:"End",run:t=>Da(t,(e=>ja(t,e,!0))),shift:t=>Ka(t,(e=>ja(t,e,!0))),preventDefault:!0},{key:"Mod-End",run:nc,shift:sc},{key:"Enter",run:mc},{key:"Mod-a",run:({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0)},{key:"Backspace",run:ac,shift:ac},{key:"Delete",run:cc},{key:"Mod-Backspace",mac:"Alt-Backspace",run:fc},{key:"Mod-Delete",mac:"Alt-Delete",run:t=>uc(t,!0)},{mac:"Mod-Backspace",run:t=>oc(t,(e=>{let i=t.moveToLineBoundary(e,!1).head;return e.head>i?i:Math.max(0,e.head-1)}))},{mac:"Mod-Delete",run:t=>oc(t,(e=>{let i=t.moveToLineBoundary(e,!0).head;return e.headDa(t,(e=>_.cursor(t.lineBlockAt(e.head).from,1))),shift:t=>Ka(t,(e=>_.cursor(t.lineBlockAt(e.head).from)))},{key:"Ctrl-e",run:t=>Da(t,(e=>_.cursor(t.lineBlockAt(e.head).to,-1))),shift:t=>Ka(t,(e=>_.cursor(t.lineBlockAt(e.head).to)))},{key:"Ctrl-d",run:cc},{key:"Ctrl-h",run:ac},{key:"Ctrl-k",run:t=>oc(t,(e=>{let i=t.lineBlockAt(e.head).to;return e.head{if(t.readOnly)return!1;let i=t.changeByRange((t=>({changes:{from:t.from,to:t.to,insert:c.of(["",""])},range:_.cursor(t.from)})));return e(t.update(i,{scrollIntoView:!0,userEvent:"input"})),!0}},{key:"Ctrl-t",run:({state:t,dispatch:e})=>{if(t.readOnly)return!1;let i=t.changeByRange((e=>{if(!e.empty||0==e.from||e.from==t.doc.length)return{range:e};let i=e.from,n=t.doc.lineAt(i),r=i==n.from?i-1:A(n.text,i-n.from,!1)+n.from,s=i==n.to?i+1:A(n.text,i-n.from,!0)+n.from;return{changes:{from:r,to:s,insert:t.doc.slice(i,s).append(t.doc.slice(r,i))},range:_.cursor(s)}}));return!i.changes.empty&&(e(t.update(i,{scrollIntoView:!0,userEvent:"move.character"})),!0)}},{key:"Ctrl-v",run:_a}].map((t=>({mac:t.key,run:t.run,shift:t.shift})))));function bc(){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 r=i[n];"string"==typeof r?t.setAttribute(n,r):null!=r&&(t[n]=r)}e++}for(;et.normalize("NFKD"):t=>t;class Sc{constructor(t,e,i=0,n=t.length,r,s){this.test=s,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=t.iterRange(i,n),this.bufferStart=i,this.normalize=r?t=>r(kc(t)):kc,this.query=this.normalize(e)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return T(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let t=this.peek();if(t<0)return this.done=!0,this;let e=E(t),i=this.bufferStart+this.bufferPos;this.bufferPos+=R(t);let n=this.normalize(e);for(let t=0,r=i;;t++){let s=n.charCodeAt(t),o=this.match(s,r,this.bufferPos+this.bufferStart);if(t==n.length-1){if(o)return this.value=o,this;break}r==i&&tthis.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let t=this.matchPos-this.curLineStart;;){this.re.lastIndex=t;let e=this.matchPos<=this.to&&this.re.exec(this.curLine);if(e){let i=this.curLineStart+e.index,n=i+e[0].length;if(this.matchPos=Ec(this.text,n+(i==n?1:0)),i==this.curLineStart+this.curLine.length&&this.nextLine(),(ithis.value.to)&&(!this.test||this.test(i,n,e)))return this.value={from:i,to:n,match:e},this;t=this.matchPos-this.curLineStart}else{if(!(this.curLineStart+this.curLine.length=i||n.to<=e){let n=new Dc(e,t.sliceString(e,i));return Oc.set(t,n),n}if(n.from==e&&n.to==i)return n;let{text:r,from:s}=n;return s>e&&(r=t.sliceString(e,s)+r,s=e),n.to=this.to?this.to:this.text.lineAt(t).to}next(){for(;;){let t=this.re.lastIndex=this.matchPos-this.flat.from,e=this.re.exec(this.flat.text);if(e&&!e[0]&&e.index==t&&(this.re.lastIndex=t+1,e=this.re.exec(this.flat.text)),e){let t=this.flat.from+e.index,i=t+e[0].length;if((this.flat.to>=this.to||e.index+e[0].length<=this.flat.text.length-10)&&(!this.test||this.test(t,i,e)))return this.value={from:t,to:i,match:e},this.matchPos=Ec(this.text,i+(t==i?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=Dc.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+2*this.flat.text.length))}}}function Ec(t,e){if(e>=t.length)return e;let i,n=t.lineAt(e);for(;e=56320&&i<57344;)e++;return e}function Rc(t){let e=bc("input",{class:"cm-textfield",name:"line",value:String(t.state.doc.lineAt(t.state.selection.main.head).number)});function i(){let i=/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(e.value);if(!i)return;let{state:n}=t,r=n.doc.lineAt(n.selection.main.head),[,s,o,l,h]=i,a=l?+l.slice(1):0,c=o?+o:r.number;if(o&&h){let t=c/100;s&&(t=t*("-"==s?-1:1)+r.number/n.doc.lines),c=Math.round(n.doc.lines*t)}else o&&s&&(c=c*("-"==s?-1:1)+r.number);let u=n.doc.line(Math.max(1,Math.min(n.doc.lines,c))),f=_.cursor(u.from+Math.max(0,Math.min(a,u.length)));t.dispatch({effects:[Pc.of(!1),es.scrollIntoView(f.from,{y:"center"})],selection:f}),t.focus()}return{dom:bc("form",{class:"cm-gotoLine",onkeydown:e=>{27==e.keyCode?(e.preventDefault(),t.dispatch({effects:Pc.of(!1)}),t.focus()):13==e.keyCode&&(e.preventDefault(),i())},onsubmit:t=>{t.preventDefault(),i()}},bc("label",t.state.phrase("Go to line"),": ",e)," ",bc("button",{class:"cm-button",type:"submit"},t.state.phrase("go")))}}"undefined"!=typeof Symbol&&(Cc.prototype[Symbol.iterator]=Tc.prototype[Symbol.iterator]=function(){return this});const Pc=kt.define(),Bc=Z.define({create:()=>!0,update(t,e){for(let i of e.effects)i.is(Pc)&&(t=i.value);return t},provide:t=>ro.from(t,(t=>t?Rc:null))}),Lc=es.baseTheme({".cm-panel.cm-gotoLine":{padding:"2px 6px 4px","& label":{fontSize:"80%"}}});const Nc=$.define({combine:t=>Nt(t,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:t=>new cu(t),scrollToMatch:t=>es.scrollIntoView(t)})});class Ic{constructor(t){this.search=t.search,this.caseSensitive=!!t.caseSensitive,this.literal=!!t.literal,this.regexp=!!t.regexp,this.replace=t.replace||"",this.valid=!!this.search&&(!this.regexp||function(t){try{return new RegExp(t,Mc),!0}catch(t){return!1}}(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!t.wholeWord}unquote(t){return this.literal?t:t.replace(/\\([nrt\\])/g,((t,e)=>"n"==e?"\n":"r"==e?"\r":"t"==e?"\t":"\\"))}eq(t){return this.search==t.search&&this.replace==t.replace&&this.caseSensitive==t.caseSensitive&&this.regexp==t.regexp&&this.wholeWord==t.wholeWord}create(){return this.regexp?new _c(this):new Wc(this)}getCursor(t,e=0,i){let n=t.doc?t:Lt.create({doc:t});return null==i&&(i=n.doc.length),this.regexp?zc(this,n,e,i):Hc(this,n,e,i)}}class Vc{constructor(t){this.spec=t}}function Hc(t,e,i,n){return new Sc(e.doc,t.unquoted,i,n,t.caseSensitive?void 0:t=>t.toLowerCase(),t.wholeWord?function(t,e){return(i,n,r,s)=>((s>i||s+r.length=e)return null;n.push(i.value)}return n}highlight(t,e,i,n){let r=Hc(this.spec,t,Math.max(0,e-this.spec.unquoted.length),Math.min(i+this.spec.unquoted.length,t.doc.length));for(;!r.next().done;)n(r.value.from,r.value.to)}}function zc(t,e,i,n){return new Cc(e.doc,t.search,{ignoreCase:!t.caseSensitive,test:t.wholeWord?(r=e.charCategorizer(e.selection.main.head),(t,e,i)=>!i[0].length||(r(Fc(i.input,i.index))!=Et.Word||r(qc(i.input,i.index))!=Et.Word)&&(r(qc(i.input,i.index+i[0].length))!=Et.Word||r(Fc(i.input,i.index+i[0].length))!=Et.Word)):void 0},i,n);var r}function Fc(t,e){return t.slice(A(t,e,!1),e)}function qc(t,e){return t.slice(e,A(t,e))}class _c extends Vc{nextMatch(t,e,i){let n=zc(this.spec,t,i,t.doc.length).next();return n.done&&(n=zc(this.spec,t,0,e).next()),n.done?null:n.value}prevMatchInRange(t,e,i){for(let n=1;;n++){let r=Math.max(e,i-1e4*n),s=zc(this.spec,t,r,i),o=null;for(;!s.next().done;)o=s.value;if(o&&(r==e||o.from>r+10))return o;if(r==e)return null}}prevMatch(t,e,i){return this.prevMatchInRange(t,0,e)||this.prevMatchInRange(t,i,t.doc.length)}getReplacement(t){return this.spec.unquote(this.spec.replace).replace(/\$([$&\d+])/g,((e,i)=>"$"==i?"$":"&"==i?t.match[0]:"0"!=i&&+i=e)return null;n.push(i.value)}return n}highlight(t,e,i,n){let r=zc(this.spec,t,Math.max(0,e-250),Math.min(i+250,t.doc.length));for(;!r.next().done;)n(r.value.from,r.value.to)}}const jc=kt.define(),Kc=kt.define(),$c=Z.define({create:t=>new Uc(ru(t).create(),null),update(t,e){for(let i of e.effects)i.is(jc)?t=new Uc(i.value.create(),t.panel):i.is(Kc)&&(t=new Uc(t.query,i.value?nu:null));return t},provide:t=>ro.from(t,(t=>t.panel))});class Uc{constructor(t,e){this.query=t,this.panel=e}}const Gc=gi.mark({class:"cm-searchMatch"}),Jc=gi.mark({class:"cm-searchMatch cm-searchMatch-selected"}),Yc=sn.fromClass(class{constructor(t){this.view=t,this.decorations=this.highlight(t.state.field($c))}update(t){let e=t.state.field($c);(e!=t.startState.field($c)||t.docChanged||t.selectionSet||t.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:t,panel:e}){if(!e||!t.spec.valid)return gi.none;let{view:i}=this,n=new Ft;for(let e=0,r=i.visibleRanges,s=r.length;er[e+1].from-500;)l=r[++e].to;t.highlight(i.state,o,l,((t,e)=>{let r=i.state.selection.ranges.some((i=>i.from==t&&i.to==e));n.add(t,e,r?Jc:Gc)}))}return n.finish()}},{decorations:t=>t.decorations});function Xc(t){return e=>{let i=e.state.field($c,!1);return i&&i.query.spec.valid?t(e,i):lu(e)}}const Qc=Xc(((t,{query:e})=>{let{to:i}=t.state.selection.main,n=e.nextMatch(t.state,i,i);if(!n)return!1;let r=_.single(n.from,n.to),s=t.state.facet(Nc);return t.dispatch({selection:r,effects:[pu(t,n),s.scrollToMatch(r.main,t)],userEvent:"select.search"}),ou(t),!0})),Zc=Xc(((t,{query:e})=>{let{state:i}=t,{from:n}=i.selection.main,r=e.prevMatch(i,n,n);if(!r)return!1;let s=_.single(r.from,r.to),o=t.state.facet(Nc);return t.dispatch({selection:s,effects:[pu(t,r),o.scrollToMatch(s.main,t)],userEvent:"select.search"}),ou(t),!0})),tu=Xc(((t,{query:e})=>{let i=e.matchAll(t.state,1e3);return!(!i||!i.length)&&(t.dispatch({selection:_.create(i.map((t=>_.range(t.from,t.to)))),userEvent:"select.search.matches"}),!0)})),eu=Xc(((t,{query:e})=>{let{state:i}=t,{from:n,to:r}=i.selection.main;if(i.readOnly)return!1;let s=e.nextMatch(i,n,n);if(!s)return!1;let o,l,h=[],a=[];if(s.from==n&&s.to==r&&(l=i.toText(e.getReplacement(s)),h.push({from:s.from,to:s.to,insert:l}),s=e.nextMatch(i,s.from,s.to),a.push(es.announce.of(i.phrase("replaced match on line $",i.doc.lineAt(n).number)+"."))),s){let e=0==h.length||h[0].from>=s.to?0:s.to-s.from-l.length;o=_.single(s.from-e,s.to-e),a.push(pu(t,s)),a.push(i.facet(Nc).scrollToMatch(o.main,t))}return t.dispatch({changes:h,selection:o,effects:a,userEvent:"input.replace"}),!0})),iu=Xc(((t,{query:e})=>{if(t.state.readOnly)return!1;let i=e.matchAll(t.state,1e9).map((t=>{let{from:i,to:n}=t;return{from:i,to:n,insert:e.getReplacement(t)}}));if(!i.length)return!1;let n=t.state.phrase("replaced $ matches",i.length)+".";return t.dispatch({changes:i,effects:es.announce.of(n),userEvent:"input.replace.all"}),!0}));function nu(t){return t.state.facet(Nc).createPanel(t)}function ru(t,e){var i,n,r,s,o;let l=t.selection.main,h=l.empty||l.to>l.from+100?"":t.sliceDoc(l.from,l.to);if(e&&!h)return e;let a=t.facet(Nc);return new Ic({search:(null!==(i=null==e?void 0:e.literal)&&void 0!==i?i:a.literal)?h:h.replace(/\n/g,"\\n"),caseSensitive:null!==(n=null==e?void 0:e.caseSensitive)&&void 0!==n?n:a.caseSensitive,literal:null!==(r=null==e?void 0:e.literal)&&void 0!==r?r:a.literal,regexp:null!==(s=null==e?void 0:e.regexp)&&void 0!==s?s:a.regexp,wholeWord:null!==(o=null==e?void 0:e.wholeWord)&&void 0!==o?o:a.wholeWord})}function su(t){let e=to(t,nu);return e&&e.dom.querySelector("[main-field]")}function ou(t){let e=su(t);e&&e==t.root.activeElement&&e.select()}const lu=t=>{let e=t.state.field($c,!1);if(e&&e.panel){let i=su(t);if(i&&i!=t.root.activeElement){let n=ru(t.state,e.query.spec);n.valid&&t.dispatch({effects:jc.of(n)}),i.focus(),i.select()}}else t.dispatch({effects:[Kc.of(!0),e?jc.of(ru(t.state,e.query.spec)):kt.appendConfig.of(mu)]});return!0},hu=t=>{let e=t.state.field($c,!1);if(!e||!e.panel)return!1;let i=to(t,nu);return i&&i.dom.contains(t.root.activeElement)&&t.focus(),t.dispatch({effects:Kc.of(!1)}),!0},au=[{key:"Mod-f",run:lu,scope:"editor search-panel"},{key:"F3",run:Qc,shift:Zc,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:Qc,shift:Zc,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:hu,scope:"editor search-panel"},{key:"Mod-Shift-l",run:({state:t,dispatch:e})=>{let i=t.selection;if(i.ranges.length>1||i.main.empty)return!1;let{from:n,to:r}=i.main,s=[],o=0;for(let e=new Sc(t.doc,t.sliceDoc(n,r));!e.next().done;){if(s.length>1e3)return!1;e.value.from==n&&(o=s.length),s.push(_.range(e.value.from,e.value.to))}return e(t.update({selection:_.create(s,o),userEvent:"select.search.matches"})),!0}},{key:"Mod-Alt-g",run:t=>{let e=to(t,Rc);if(!e){let i=[Pc.of(!0)];null==t.state.field(Bc,!1)&&i.push(kt.appendConfig.of([Bc,Lc])),t.dispatch({effects:i}),e=to(t,Rc)}return e&&e.dom.querySelector("input").select(),!0}},{key:"Mod-d",run:({state:t,dispatch:e})=>{let{ranges:i}=t.selection;if(i.some((t=>t.from===t.to)))return(({state:t,dispatch:e})=>{let{selection:i}=t,n=_.create(i.ranges.map((e=>t.wordAt(e.head)||_.cursor(e.head))),i.mainIndex);return!n.eq(i)&&(e(t.update({selection:n})),!0)})({state:t,dispatch:e});let n=t.sliceDoc(i[0].from,i[0].to);if(t.selection.ranges.some((e=>t.sliceDoc(e.from,e.to)!=n)))return!1;let r=function(t,e){let{main:i,ranges:n}=t.selection,r=t.wordAt(i.head),s=r&&r.from==i.from&&r.to==i.to;for(let i=!1,r=new Sc(t.doc,e,n[n.length-1].to);;){if(r.next(),!r.done){if(i&&n.some((t=>t.from==r.value.from)))continue;if(s){let e=t.wordAt(r.value.from);if(!e||e.from!=r.value.from||e.to!=r.value.to)continue}return r.value}if(i)return null;r=new Sc(t.doc,e,0,Math.max(0,n[n.length-1].from-1)),i=!0}}(t,n);return!!r&&(e(t.update({selection:t.selection.addRange(_.range(r.from,r.to),!1),effects:es.scrollIntoView(r.to)})),!0)},preventDefault:!0}];class cu{constructor(t){this.view=t;let e=this.query=t.state.field($c).query.spec;function i(t,e,i){return bc("button",{class:"cm-button",name:t,onclick:e,type:"button"},i)}this.commit=this.commit.bind(this),this.searchField=bc("input",{value:e.search,placeholder:uu(t,"Find"),"aria-label":uu(t,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=bc("input",{value:e.replace,placeholder:uu(t,"Replace"),"aria-label":uu(t,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=bc("input",{type:"checkbox",name:"case",form:"",checked:e.caseSensitive,onchange:this.commit}),this.reField=bc("input",{type:"checkbox",name:"re",form:"",checked:e.regexp,onchange:this.commit}),this.wordField=bc("input",{type:"checkbox",name:"word",form:"",checked:e.wholeWord,onchange:this.commit}),this.dom=bc("div",{onkeydown:t=>this.keydown(t),class:"cm-search"},[this.searchField,i("next",(()=>Qc(t)),[uu(t,"next")]),i("prev",(()=>Zc(t)),[uu(t,"previous")]),i("select",(()=>tu(t)),[uu(t,"all")]),bc("label",null,[this.caseField,uu(t,"match case")]),bc("label",null,[this.reField,uu(t,"regexp")]),bc("label",null,[this.wordField,uu(t,"by word")]),...t.state.readOnly?[]:[bc("br"),this.replaceField,i("replace",(()=>eu(t)),[uu(t,"replace")]),i("replaceAll",(()=>iu(t)),[uu(t,"replace all")])],bc("button",{name:"close",onclick:()=>hu(t),"aria-label":uu(t,"close"),type:"button"},["×"])])}commit(){let t=new Ic({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});t.eq(this.query)||(this.query=t,this.view.dispatch({effects:jc.of(t)}))}keydown(t){var e,i,n;e=this.view,i=t,n="search-panel",ps(us(e.state),i,e,n)?t.preventDefault():13==t.keyCode&&t.target==this.searchField?(t.preventDefault(),(t.shiftKey?Zc:Qc)(this.view)):13==t.keyCode&&t.target==this.replaceField&&(t.preventDefault(),eu(this.view))}update(t){for(let e of t.transactions)for(let t of e.effects)t.is(jc)&&!t.value.eq(this.query)&&this.setQuery(t.value)}setQuery(t){this.query=t,this.searchField.value=t.search,this.replaceField.value=t.replace,this.caseField.checked=t.caseSensitive,this.reField.checked=t.regexp,this.wordField.checked=t.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(Nc).top}}function uu(t,e){return t.state.phrase(e)}const fu=30,du=/[\s\.,:;?!]/;function pu(t,{from:e,to:i}){let n=t.state.doc.lineAt(e),r=t.state.doc.lineAt(i).to,s=Math.max(n.from,e-fu),o=Math.min(r,i+fu),l=t.state.sliceDoc(s,o);if(s!=n.from)for(let t=0;tl.length-fu;t--)if(!du.test(l[t-1])&&du.test(l[t])){l=l.slice(0,t);break}return es.announce.of(`${t.state.phrase("current match")}. ${l} ${t.state.phrase("on line")} ${n.number}.`)}const gu=es.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),mu=[$c,st.low(Yc),gu];exports.Decoration=gi,exports.EditorSelection=_,exports.EditorState=Lt,exports.EditorView=es,exports.HighlightStyle=uh,exports.LanguageSupport=class{constructor(t,e=[]){this.language=t,this.support=e,this.extension=[t,e]}},exports.Prec=st,exports.RangeSetBuilder=Ft,exports.StateEffect=kt,exports.StateField=Z,exports.StreamLanguage=Nh,exports.Tag=il,exports.ViewPlugin=sn,exports._callSuper=function(e,i,n){return i=s(i),function(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(e,t()?Reflect.construct(i,n||[],s(e).constructor):i.apply(e,n))},exports._classCallCheck=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},exports._classPrivateGetter=function(t,e,i){return i(function(t,e,i){if("function"==typeof t?t===e:t.has(e))return arguments.length<3?e:i;throw new TypeError("Private element is not present on this object")}(t,e))},exports._classPrivateMethodInitSpec=function(t,e){!function(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")}(t,e),e.add(t)},exports._createClass=function(t,e,i){return e&&n(t.prototype,e),i&&n(t,i),Object.defineProperty(t,"prototype",{writable:!1}),t},exports._createForOfIteratorHelper=function(t,e){var i="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!i){if(Array.isArray(t)||(i=h(t))||e&&t&&"number"==typeof t.length){i&&(t=i);var n=0,r=function(){};return{s:r,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,o=!0,l=!1;return{s:function(){i=i.call(t)},n:function(){var t=i.next();return o=t.done,t},e:function(t){l=!0,s=t},f:function(){try{o||null==i.return||i.return()}finally{if(l)throw s}}}},exports._defineProperty=r,exports._get=l,exports._getPrototypeOf=s,exports._inherits=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&o(t,e)},exports._objectSpread2=function(t){for(var i=1;i{var e;return(null===(e=t.plugin(n))||void 0===e?void 0:e.isDown)?_s:null}))]},exports.defaultKeymap=yc,exports.drawSelection=function(t={}){return[ks.of(t),As,Cs,Ds,Yi.of(!0)]},exports.ensureSyntaxTree=function(t,e,i=50){var n;let r=null===(n=t.field(El.state,!1))||void 0===n?void 0:n.context;if(!r)return null;let s=r.viewport;r.updateViewport({from:0,to:e});let o=r.isDone(e)||r.work(i,e)?r.tree:null;return r.updateViewport(s),o},exports.foldEffect=eh,exports.foldedRanges=function(t){return t.field(nh,!1)||zt.empty},exports.highlightSpecialChars=function(t={}){return[Ns.of(t),Is||(Is=sn.fromClass(class{constructor(t){this.view=t,this.decorations=gi.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(t.state.facet(Ns)),this.decorations=this.decorator.createDeco(t)}makeDecorator(t){return new Es({regexp:t.specialChars,decoration:(e,i,n)=>{let{doc:r}=i.state,s=T(e[0],0);if(9==s){let t=r.lineAt(n),e=i.state.tabSize,s=Qt(t.text,e,n-t.from);return gi.replace({widget:new Hs((e-s%e)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[s]||(this.decorationCache[s]=gi.replace({widget:new Vs(t,s)}))},boundary:t.replaceTabs?void 0:/[^]/})}update(t){let e=t.state.facet(Ns);t.startState.facet(Ns)!=e?(this.decorator=this.makeDecorator(e),this.decorations=this.decorator.createDeco(t.view)):this.decorations=this.decorator.updateDeco(t,this.decorations)}},{decorations:t=>t.decorations}))]},exports.history=function(t={}){return[ha,la.of(t),es.domEventHandlers({beforeinput(t,e){let i="historyUndo"==t.inputType?ca:"historyRedo"==t.inputType?ua:null;return!!i&&(t.preventDefault(),i(e))}})]},exports.historyKeymap=Ma,exports.keymap=as,exports.lineNumbers=function(t={}){return[wo.of(t),ao(),xo]},exports.openSearchPanel=lu,exports.rectangularSelection=function(t){let e=(null==t?void 0:t.eventFilter)||(t=>t.altKey&&0==t.button);return es.mouseSelectionStyle.of(((t,i)=>e(i)?Fs(t,i):null))},exports.redo=ua,exports.search=function(t){return t?[Nc.of(t),mu]:mu},exports.searchKeymap=au,exports.showTooltip=Qs,exports.syntaxHighlighting=function(t,e){let i,n=[mh];return t instanceof uh&&(t.module&&n.push(es.styleModule.of(t.module)),i=t.themeType),(null==e?void 0:e.fallback)?n.push(dh.of(t)):i?n.push(fh.computeN([es.darkTheme],(e=>e.facet(es.darkTheme)==("dark"==i)?[t]:[]))):n.push(fh.of(t)),n},exports.syntaxTree=Pl,exports.tags=Cl,exports.unfoldAll=t=>{let e=t.state.field(nh,!1);if(!e||!e.size)return!1;let i=[];return e.between(0,t.state.doc.length,((t,e)=>{i.push(ih.of({from:t,to:e}))})),t.dispatch({effects:i}),!0},exports.unfoldEffect=ih; +"use strict";class t{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,n){[t,e]=a(this,t,e);let s=[];return this.decompose(0,t,s,2),n.length&&n.decompose(0,n.length,s,3),this.decompose(e,this.length,s,1),i.from(s,this.length-(e-t)+n.length)}append(t){return this.replace(this.length,this.length,t)}slice(t,e=this.length){[t,e]=a(this,t,e);let n=[];return this.decompose(t,e,n,0),i.from(n,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 r(this),s=new r(t);for(let t=e,r=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(r+=n.value.length,n.done||r>=i)return!0}}iter(t=1){return new r(this,t)}iterRange(t,e=this.length){return new o(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 l(i)}toString(){return this.sliceString(0)}toJSON(){let t=[];return this.flatten(t),t}constructor(){}static of(n){if(0==n.length)throw new RangeError("A document must have at least one line");return 1!=n.length||n[0]?n.length<=32?new e(n):i.from(e.split(n,[])):t.empty}}class e extends t{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 r=this.text[s],o=n+r.length;if((e?i:o)>=t)return new h(n,o,i,r);n=o+1,i++}}decompose(t,i,r,o){let l=t<=0&&i>=this.length?this:new e(s(this.text,t,i),Math.min(i,this.length)-Math.max(0,t));if(1&o){let t=r.pop(),i=n(l.text,t.text.slice(),0,l.length);if(i.length<=32)r.push(new e(i,t.length+l.length));else{let t=i.length>>1;r.push(new e(i.slice(0,t)),new e(i.slice(t)))}}else r.push(l)}replace(t,r,o){if(!(o instanceof e))return super.replace(t,r,o);[t,r]=a(this,t,r);let l=n(this.text,n(o.text,s(this.text,0,t)),r),h=this.length+o.length-(r-t);return l.length<=32?new e(l,h):i.from(e.split(l,[]),h)}sliceString(t,e=this.length,i="\n"){[t,e]=a(this,t,e);let n="";for(let s=0,r=0;s<=e&&rt&&r&&(n+=i),ts&&(n+=o.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,i){let n=[],s=-1;for(let r of t)n.push(r),s+=r.length+1,32==n.length&&(i.push(new e(n,s)),n=[],s=-1);return s>-1&&i.push(new e(n,s)),i}}class i extends t{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 r=this.children[s],o=n+r.length,l=i+r.lines-1;if((e?l:o)>=t)return r.lineInner(t,e,i,n);n=o+1,i=l+1}}decompose(t,e,i,n){for(let s=0,r=0;r<=e&&s=r){let s=n&((r<=t?1:0)|(l>=e?2:0));r>=t&&l<=e&&!s?i.push(o):o.decompose(t-r,e-r,i,s)}r=l+1}}replace(t,e,n){if([t,e]=a(this,t,e),n.lines=r&&e<=l){let h=o.replace(t-r,e-r,n),a=this.lines-o.lines+h.lines;if(h.lines>4&&h.lines>a>>6){let r=this.children.slice();return r[s]=h,new i(r,this.length-(e-t)+n.length)}return super.replace(r,l,h)}r=l+1}return super.replace(t,e,n)}sliceString(t,e=this.length,i="\n"){[t,e]=a(this,t,e);let n="";for(let s=0,r=0;st&&s&&(n+=i),tr&&(n+=o.sliceString(t-r,e-r,i)),r=l+1}return n}flatten(t){for(let e of this.children)e.flatten(t)}scanIdentical(t,e){if(!(t instanceof i))return 0;let n=0,[s,r,o,l]=e>0?[0,0,this.children.length,t.children.length]:[this.children.length-1,t.children.length-1,-1,-1];for(;;s+=e,r+=e){if(s==o||r==l)return n;let i=this.children[s],h=t.children[r];if(i!=h)return n+i.scanIdentical(h,e);n+=i.length+1}}static from(t,n=t.reduce(((t,e)=>t+e.length+1),-1)){let s=0;for(let e of t)s+=e.lines;if(s<32){let i=[];for(let e of t)e.flatten(i);return new e(i,n)}let r=Math.max(32,s>>5),o=r<<1,l=r>>1,h=[],a=0,c=-1,u=[];function f(t){let n;if(t.lines>o&&t instanceof i)for(let e of t.children)f(e);else t.lines>l&&(a>l||!a)?(d(),h.push(t)):t instanceof e&&a&&(n=u[u.length-1])instanceof e&&t.lines+n.lines<=32?(a+=t.lines,c+=t.length+1,u[u.length-1]=new e(n.text.concat(t.text),n.length+1+t.length)):(a+t.lines>r&&d(),a+=t.lines,c+=t.length+1,u.push(t))}function d(){0!=a&&(h.push(1==u.length?u[0]:i.from(u,c)),c=-1,a=u.length=0)}for(let e of t)f(e);return d(),1==h.length?h[0]:new i(h,n)}}function n(t,e,i=0,n=1e9){for(let s=0,r=0,o=!0;r=i&&(h>n&&(l=l.slice(0,n-s)),s0?1:(t instanceof e?t.text.length:t.children.length)<<1]}nextInner(t,i){for(this.done=this.lineBreak=!1;;){let n=this.nodes.length-1,s=this.nodes[n],r=this.offsets[n],o=r>>1,l=s instanceof e?s.text.length:s.children.length;if(o==(i>0?l:0)){if(0==n)return this.done=!0,this.value="",this;i>0&&this.offsets[n-1]++,this.nodes.pop(),this.offsets.pop()}else if((1&r)==(i>0?0:1)){if(this.offsets[n]+=i,0==t)return this.lineBreak=!0,this.value="\n",this;t--}else if(s instanceof e){let e=s.text[o+(i<0?-1:0)];if(this.offsets[n]+=i,e.length>Math.max(0,t))return this.value=0==t?e:i>0?e.slice(t):e.slice(0,e.length-t),this;t-=e.length}else{let r=s.children[o+(i<0?-1:0)];t>r.length?(t-=r.length,this.offsets[n]+=i):(i<0&&this.offsets[n]--,this.nodes.push(r),this.offsets.push(i>0?1:(r instanceof e?r.text.length:r.children.length)<<1))}}}next(t=0){return t<0&&(this.nextInner(-t,-this.dir),t=this.value.length),this.nextInner(t,this.dir)}}class o{constructor(t,e,i){this.value="",this.done=!1,this.cursor=new r(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 l{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&&(t.prototype[Symbol.iterator]=function(){return this.iter()},r.prototype[Symbol.iterator]=o.prototype[Symbol.iterator]=l.prototype[Symbol.iterator]=function(){return this});class h{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 a(t,e,i){return[e=Math.max(0,Math.min(t.length,e)),Math.max(e,Math.min(t.length,i))]}let c="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 t=1;tt)return c[e-1]<=t;return!1}function f(t){return t>=127462&&t<=127487}const d=8205;function p(t,e,i=!0,n=!0){return(i?g:m)(t,e,n)}function g(t,e,i){if(e==t.length)return e;e&&v(t.charCodeAt(e))&&w(t.charCodeAt(e-1))&&e--;let n=y(t,e);for(e+=x(n);e=0&&f(y(t,n));)i++,n-=2;if(i%2==0)break;e+=2}}}return e}function m(t,e,i){for(;e>0;){let n=g(t,e-2,i);if(n=56320&&t<57344}function w(t){return t>=55296&&t<56320}function y(t,e){let i=t.charCodeAt(e);if(!w(i)||e+1==t.length)return i;let n=t.charCodeAt(e+1);return v(n)?n-56320+(i-55296<<10)+65536:i}function b(t){return t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode(55296+(t>>10),56320+(1023&t)))}function x(t){return t<65536?1:2}const k=/\r\n?|\n/;var S=function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t}(S||(S={}));class A{constructor(t){this.sections=t}get length(){let t=0;for(let e=0;et)return s+(t-n);s+=o}else{if(i!=S.Simple&&h>=t&&(i==S.TrackDel&&nt||i==S.TrackBefore&&nt))return null;if(h>t||h==t&&e<0&&!o)return t==n||e<0?s:s+l;s+=l}n=h}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=0&&n<=e&&s>=t)return!(ne)||"cover";n=s}return!1}toString(){let t="";for(let e=0;e=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 A(t)}static create(t){return new A(t)}}class M extends A{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 O(this,((e,i,n,s,r)=>t=t.replace(n,n+(i-e),r)),!1),t}mapDesc(t,e=!1){return T(this,t,e,!0)}invert(e){let i=this.sections.slice(),n=[];for(let s=0,r=0;s=0){i[s]=l,i[s+1]=o;let h=s>>1;for(;n.length0&&D(i,e,s.text),s.forward(t),o+=t}let h=t[r++];for(;o>1].toJSON()))}return t}static of(e,i,n){let s=[],r=[],o=0,l=null;function h(t=!1){if(!t&&!s.length)return;ol||e<0||l>i)throw new RangeError(`Invalid change range ${e} to ${l} (in doc of length ${i})`);let u=c?"string"==typeof c?t.of(c.split(n||k)):c:t.empty,f=u.length;if(e==l&&0==f)return;eo&&C(s,e-o,-1),C(s,l-e,f),D(r,s,u),o=l}}(e),h(!l),l}static empty(t){return new M(t?[t,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let i=[],n=[];for(let s=0;se&&"string"!=typeof t)))throw new RangeError("Invalid JSON representation of ChangeSet");if(1==r.length)i.push(r[0],0);else{for(;n.length=0&&i<=0&&i==t[s+1]?t[s]+=e:0==e&&0==t[s]?t[s+1]+=i:n?(t[s]+=e,t[s+1]+=i):t.push(e,i)}function D(e,i,n){if(0==n.length)return;let s=i.length-2>>1;if(s>1])),!(n||l==e.sections.length||e.sections[l+1]<0);)h=e.sections[l++],a=e.sections[l++];i(r,c,o,u,f),r=c,o=u}}}function T(t,e,i,n=!1){let s=[],r=n?[]:null,o=new R(t),l=new R(e);for(let t=-1;;)if(-1==o.ins&&-1==l.ins){let t=Math.min(o.len,l.len);C(s,t,-1),o.forward(t),l.forward(t)}else if(l.ins>=0&&(o.ins<0||t==o.i||0==o.off&&(l.len=0&&t=0)){if(o.done&&l.done)return r?M.createSet(s,r):A.create(s);throw new Error("Mismatched change set lengths")}{let e=0,i=o.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.lene||o.ins>=0&&o.len>e)&&(t||n.length>i),r.forward2(e),o.forward(e)}}else C(n,0,o.ins,t),s&&D(s,n,o.text),o.next()}}class R{constructor(t){this.set=t,this.i=0,this.next()}next(){let{sections:t}=this.set;this.i>1;return i>=e.length?t.empty:e[i]}textBit(e){let{inserted:i}=this.set,n=this.i-2>>1;return n>=i.length&&!e?t.empty:i[n].slice(this.off,null==e?void 0:this.off+e)}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 B{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 B(i,n,this.flags)}extend(t,e=t){if(t<=this.anchor&&e>=this.anchor)return P.range(t,e);let i=Math.abs(t-this.anchor)>Math.abs(e-this.anchor)?t:e;return P.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 P.range(t.anchor,t.head)}static create(t,e,i){return new B(t,e,i)}}class P{constructor(t,e){this.ranges=t,this.mainIndex=e}map(t,e=-1){return t.empty?this:P.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;it.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 P(t.ranges.map((t=>B.fromJSON(t))),t.main)}static single(t,e=t){return new P([P.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;nt?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;in.head?P.range(o,r):P.range(r,o))}}return new P(t,e)}}function L(t,e){for(let i of t.ranges)if(i.to>e)throw new RangeError("Selection points outside of document")}let N=0;class I{constructor(t,e,i,n,s){this.combine=t,this.compareInput=e,this.compare=i,this.isStatic=n,this.id=N++,this.default=t([]),this.extensions="function"==typeof s?s(this):s}get reader(){return this}static define(t={}){return new I(t.combine||(t=>t),t.compareInput||((t,e)=>t===e),t.compare||(t.combine?(t,e)=>t===e:V),!!t.static,t.enables)}of(t){return new H([],this,0,t)}compute(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new H(t,this,1,e)}computeN(t,e){if(this.isStatic)throw new Error("Can't compute a static facet");return new H(t,this,2,e)}from(t,e){return e||(e=t=>t),this.compute([t],(i=>e(i.field(t))))}}function V(t,e){return t==e||t.length==e.length&&t.every(((t,i)=>t===e[i]))}class H{constructor(t,e,i,n){this.dependencies=t,this.facet=e,this.type=i,this.value=n,this.id=N++}dynamicSlot(t){var e;let i=this.value,n=this.facet.compareInput,s=this.id,r=t[s]>>1,o=2==this.type,l=!1,h=!1,a=[];for(let i of this.dependencies)"doc"==i?l=!0:"selection"==i?h=!0:1&(null!==(e=t[i.id])&&void 0!==e?e:1)||a.push(t[i.id]);return{create:t=>(t.values[r]=i(t),1),update(t,e){if(l&&e.docChanged||h&&(e.docChanged||e.selection)||z(t,a)){let e=i(t);if(o?!W(e,t.values[r],n):!n(e,t.values[r]))return t.values[r]=e,1}return 0},reconfigure:(t,e)=>{let l,h=e.config.address[s];if(null!=h){let s=et(e,h);if(this.dependencies.every((i=>i instanceof I?e.facet(i)===t.facet(i):!(i instanceof _)||e.field(i,!1)==t.field(i,!1)))||(o?W(l=i(t),s,n):n(l=i(t),s)))return t.values[r]=s,0}else l=i(t);return t.values[r]=l,1}}}}function W(t,e,i){if(t.length!=e.length)return!1;for(let n=0;nt[e.id])),s=i.map((t=>t.type)),r=n.filter((t=>!(1&t))),o=t[e.id]>>1;function l(t){let i=[];for(let e=0;et===e),t);return t.provide&&(e.provides=t.provide(e)),e}create(t){let e=t.facet(q).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)=>null!=i.config.address[this.id]?(t.values[e]=i.field(this),0):(t.values[e]=this.create(t),1)}}init(t){return[this,q.of({field:this,create:t})]}get extension(){return this}}const K=4,j=3,$=2,U=1;function G(t){return e=>new Y(e,t)}const J={highest:G(0),high:G(U),default:G($),low:G(j),lowest:G(K)};class Y{constructor(t,e){this.inner=t,this.prec=e}}class X{of(t){return new Q(this,t)}reconfigure(t){return X.reconfigure.of({compartment:this,extension:t})}get(t){return t.config.compartments.get(this)}}class Q{constructor(t,e){this.compartment=t,this.inner=e}}class Z{constructor(t,e,i,n,s,r){for(this.base=t,this.compartments=e,this.dynamicSlots=i,this.address=n,this.staticValues=s,this.facets=r,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(t,e,i){let n=[],s=Object.create(null),r=new Map;for(let i of function(t,e,i){let n=[[],[],[],[],[]],s=new Map;function r(t,o){let l=s.get(t);if(null!=l){if(l<=o)return;let e=n[l].indexOf(t);e>-1&&n[l].splice(e,1),t instanceof Q&&i.delete(t.compartment)}if(s.set(t,o),Array.isArray(t))for(let e of t)r(e,o);else if(t instanceof Q){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),r(n,o)}else if(t instanceof Y)r(t.inner,t.prec);else if(t instanceof _)n[o].push(t),t.provides&&r(t.provides,o);else if(t instanceof H)n[o].push(t),t.facet.extensions&&r(t.facet.extensions,$);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.`);r(e,o)}}return r(t,$),n.reduce(((t,e)=>t.concat(e)))}(t,e,r))i instanceof _?n.push(i):(s[i.facet.id]||(s[i.facet.id]=[])).push(i);let o=Object.create(null),l=[],h=[];for(let t of n)o[t.id]=h.length<<1,h.push((e=>t.slot(e)));let a=null==i?void 0:i.config.facets;for(let t in s){let e=s[t],n=e[0].facet,r=a&&a[t]||[];if(e.every((t=>0==t.type)))if(o[n.id]=l.length<<1|1,V(r,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?(o[t.id]=l.length<<1|1,l.push(t.value)):(o[t.id]=h.length<<1,h.push((e=>t.dynamicSlot(e))));o[n.id]=h.length<<1,h.push((t=>F(t,n,e)))}}let c=h.map((t=>t(o)));return new Z(t,r,c,o,l,s)}}function tt(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 et(t,e){return 1&e?t.config.staticValues[e>>1]:t.values[e>>1]}const it=I.define(),nt=I.define({combine:t=>t.some((t=>t)),static:!0}),st=I.define({combine:t=>t.length?t[0]:void 0,static:!0}),rt=I.define(),ot=I.define(),lt=I.define(),ht=I.define({combine:t=>!!t.length&&t[0]});class at{constructor(t,e){this.type=t,this.value=e}static define(){return new ct}}class ct{of(t){return new at(this,t)}}class ut{constructor(t){this.map=t}of(t){return new ft(this,t)}}class ft{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 ft(this.type,e)}is(t){return this.type==t}static define(t={}){return new ut(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}}ft.reconfigure=ft.define(),ft.appendConfig=ft.define();class dt{constructor(t,e,i,n,s,r){this.startState=t,this.changes=e,this.selection=i,this.effects=n,this.annotations=s,this.scrollIntoView=r,this._doc=null,this._state=null,i&&L(i,e.newLength),s.some((t=>t.type==dt.time))||(this.annotations=s.concat(dt.time.of(Date.now())))}static create(t,e,i,n,s,r){return new dt(t,e,i,n,s,r)}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(dt.userEvent);return!(!e||!(e==t||e.length>t.length&&e.slice(0,t.length)==t&&"."==e[t.length]))}}function pt(t,e){let i=[];for(let n=0,s=0;;){let r,o;if(n=t[n]))r=t[n++],o=t[n++];else{if(!(s=0;s--){let r=i[s](t);r&&Object.keys(r).length&&(n=gt(n,mt(e,r,t.changes.newLength),!0))}return n==t?t:dt.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(rt)){let e=n(t);if(!1===e){i=!1;break}Array.isArray(e)&&(i=!0===i?e:pt(i,e))}if(!0!==i){let n,s;if(!1===i)s=t.changes.invertedDesc,n=M.empty(e.doc.length);else{let e=t.changes.filter(i);n=e.changes,s=e.filtered.mapDesc(e.changes).invertedDesc}t=dt.create(e,n,t.selection&&t.selection.map(s),ft.mapEffects(t.effects,s),t.annotations,t.scrollIntoView)}let n=e.facet(ot);for(let i=n.length-1;i>=0;i--){let s=n[i](t);t=s instanceof dt?s:Array.isArray(s)&&1==s.length&&s[0]instanceof dt?s[0]:vt(e,yt(s),!1)}return t}(s):s)}dt.time=at.define(),dt.userEvent=at.define(),dt.addToHistory=at.define(),dt.remote=at.define();const wt=[];function yt(t){return null==t?wt:Array.isArray(t)?t:[t]}var bt=function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t}(bt||(bt={}));const xt=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let kt;try{kt=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch(t){}function St(t){return e=>{if(!/\S/.test(e))return bt.Space;if(function(t){if(kt)return kt.test(t);for(let e=0;e"€"&&(i.toUpperCase()!=i.toLowerCase()||xt.test(i)))return!0}return!1}(e))return bt.Word;for(let i=0;i-1)return bt.Word;return bt.Other}}class At{constructor(t,e,i,n,s,r){this.config=t,this.doc=e,this.selection=i,this.values=n,this.status=t.statusTemplate.slice(),this.computeSlot=s,r&&(r._state=this);for(let t=0;ts.set(e,t))),i=null),s.set(e.value.compartment,e.value.extension)):e.is(ft.reconfigure)?(i=null,n=e.value):e.is(ft.appendConfig)&&(i=null,n=yt(n).concat(e.value));if(i)e=t.startState.values.slice();else{i=Z.resolve(n,s,this),e=new At(i,this.doc,this.selection,i.dynamicSlots.map((()=>null)),((t,e)=>e.reconfigure(t,this)),null).values}let r=t.startState.facet(nt)?t.newSelection:t.newSelection.asSingle();new At(i,t.newDoc,r,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:P.cursor(e.from+t.length)})))}changeByRange(t){let e=this.selection,i=t(e.ranges[0]),n=this.changes(i.changes),s=[i.range],r=yt(i.effects);for(let i=1;is.spec.fromJSON(r,t))))}return At.create({doc:t.doc,selection:P.fromJSON(t.selection),extensions:e.extensions?n.concat([e.extensions]):n})}static create(e={}){let i=Z.resolve(e.extensions||[],new Map),n=e.doc instanceof t?e.doc:t.of((e.doc||"").split(i.staticFacet(At.lineSeparator)||k)),s=e.selection?e.selection instanceof P?e.selection:P.single(e.selection.anchor,e.selection.head):P.single(0);return L(s,n.length),i.staticFacet(nt)||(s=s.asSingle()),new At(i,n,s,i.dynamicSlots.map((()=>null)),((t,e)=>e.create(t)),null)}get tabSize(){return this.facet(At.tabSize)}get lineBreak(){return this.facet(At.lineSeparator)||"\n"}get readOnly(){return this.facet(ht)}phrase(t,...e){for(let e of this.facet(At.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(it))for(let r of s(this,e,i))Object.prototype.hasOwnProperty.call(r,t)&&n.push(r[t]);return n}charCategorizer(t){return St(this.languageDataAt("wordChars",t).join(""))}wordAt(t){let{text:e,from:i,length:n}=this.doc.lineAt(t),s=this.charCategorizer(t),r=t-i,o=t-i;for(;r>0;){let t=p(e,r,!1);if(s(e.slice(t,r))!=bt.Word)break;r=t}for(;ot.length?t[0]:4}),At.lineSeparator=st,At.readOnly=ht,At.phrases=I.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]))}}),At.languageData=it,At.changeFilter=rt,At.transactionFilter=ot,At.transactionExtender=lt,X.reconfigure=ft.define();class Ct{eq(t){return this==t}range(t,e=t){return Dt.create(t,e,this)}}Ct.prototype.startSide=Ct.prototype.endSide=0,Ct.prototype.point=!1,Ct.prototype.mapMode=S.TrackDel;let Dt=class t{constructor(t,e,i){this.from=t,this.to=e,this.value=i}static create(e,i,n){return new t(e,i,n)}};function Ot(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class Tt{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 r=n,o=s.length;;){if(r==o)return r;let n=r+o>>1,l=s[n]-t||(i?this.value[n].endSide:this.value[n].startSide)-e;if(n==r)return l>=0?r:o;l>=0?o=n:r=n+1}}between(t,e,i,n){for(let s=this.findIndex(e,-1e9,!0),r=this.findIndex(i,1e9,!1,s);sa||h==a&&c.startSide>0&&c.endSide<=0)continue;(a-h||c.endSide-c.startSide)<0||(r<0&&(r=h),c.point&&(o=Math.max(o,a-h)),i.push(c),n.push(h-r),s.push(a-r))}return{mapped:i.length?new Tt(n,s,i,o):null,pos:r}}}class Et{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 Et(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,r=t.filter;if(0==e.length&&!r)return this;if(i&&(e=e.slice().sort(Ot)),this.isEmpty)return e.length?Et.of(e):this;let o=new Pt(this,null,-1).goto(0),l=0,h=[],a=new Rt;for(;o.value||l=0){let t=e[l++];a.addInner(t.from,t.to,t.value)||h.push(t)}else 1==o.rangeIndex&&o.chunkIndexthis.chunkEnd(o.chunkIndex)||so.to||s=s&&t<=s+r.length&&!1===r.between(s,t-s,e-s,i))return}this.nextLayer.between(t,e,i)}}iter(t=0){return Lt.from([this]).goto(t)}get isEmpty(){return this.nextLayer==this}static iter(t,e=0){return Lt.from(t).goto(e)}static compare(t,e,i,n,s=-1){let r=t.filter((t=>t.maxPoint>0||!t.isEmpty&&t.maxPoint>=s)),o=e.filter((t=>t.maxPoint>0||!t.isEmpty&&t.maxPoint>=s)),l=Bt(r,o,i),h=new It(r,l,s),a=new It(o,l,s);i.iterGaps(((t,e,i)=>Vt(h,t,a,e,i,n))),i.empty&&0==i.length&&Vt(h,0,a,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)),r=e.filter((e=>!e.isEmpty&&t.indexOf(e)<0));if(s.length!=r.length)return!1;if(!s.length)return!0;let o=Bt(s,r),l=new It(s,o,0).goto(i),h=new It(r,o,0).goto(i);for(;;){if(l.to!=h.to||!Ht(l.active,h.active)||l.point&&(!h.point||!l.point.eq(h.point)))return!1;if(l.to>n)return!0;l.next(),h.next()}}static spans(t,e,i,n,s=-1){let r=new It(t,null,s).goto(e),o=e,l=r.openStart;for(;;){let t=Math.min(r.to,i);if(r.point){let i=r.activeForPoint(r.to),s=r.pointFromo&&(n.span(o,t,r.active,l),l=r.openEnd(t));if(r.to>i)return l+(r.point&&r.to>i?1:0);o=r.to,r.next()}}static of(t,e=!1){let i=new Rt;for(let n of t instanceof Dt?[t]:e?function(t){if(t.length>1)for(let e=t[0],i=1;i0)return t.slice().sort(Ot);e=n}return t}(t):t)i.add(n.from,n.to,n.value);return i.finish()}static join(t){if(!t.length)return Et.empty;let e=t[t.length-1];for(let i=t.length-2;i>=0;i--)for(let n=t[i];n!=Et.empty;n=n.nextLayer)e=new Et(n.chunkPos,n.chunk,e,Math.max(n.maxPoint,e.maxPoint));return e}}Et.empty=new Et([],[],null,-1),Et.empty.nextLayer=Et.empty;class Rt{finishChunk(t){this.chunks.push(new Tt(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 Rt)).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(Et.empty)}finishInner(t){if(this.from.length&&this.finishChunk(!1),0==this.chunks.length)return t;let e=Et.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(t):t,this.setMaxPoint);return this.from=null,e}}function Bt(t,e,i){let n=new Map;for(let e of t)for(let t=0;t=this.minPoint)break}}}setRangeIndex(t){if(t==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex=i&&n.push(new Pt(r,e,i,s));return 1==n.length?n[0]:new Lt(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--)Nt(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--)Nt(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(),Nt(this.heap,0)}}}function Nt(t,e){for(let i=t[e];;){let n=1+(e<<1);if(n>=t.length)break;let s=t[n];if(n+1=0&&(s=t[n+1],n++),i.compare(s)<0)break;t[n]=i,t[e]=s,e=n}}class It{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=Lt.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){Wt(this.active,t),Wt(this.activeTo,t),Wt(this.activeRank,t),this.minActive=Ft(this.active,this.activeTo)}addActive(t){let e=0,{value:i,to:n,rank:s}=this.cursor;for(;e0;)e++;zt(this.active,e,i),zt(this.activeTo,e,n),zt(this.activeRank,e,s),t&&zt(t,e,this.cursor.from),this.minActive=Ft(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&&Wt(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=0&&i[e]=0&&!(this.activeRank[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 Vt(t,e,i,n,s,r){t.goto(e),i.goto(n);let o=n+s,l=n,h=n-e;for(;;){let e=t.to+h-i.to||t.endSide-i.endSide,n=e<0?t.to+h:i.to,s=Math.min(n,o);if(t.point||i.point?t.point&&i.point&&(t.point==i.point||t.point.eq(i.point))&&Ht(t.activeForPoint(t.to),i.activeForPoint(i.to))||r.comparePoint(l,s,t.point,i.point):s>l&&!Ht(t.active,i.active)&&r.compareRange(l,s,t.active,i.active),n>o)break;l=n,e<=0&&t.next(),e>=0&&i.next()}}function Ht(t,e){if(t.length!=e.length)return!1;for(let i=0;i=e;i--)t[i+1]=t[i];t[e]=i}function Ft(t,e){let i=-1,n=1e9;for(let s=0;s=e)return n;if(n==t.length)break;s+=9==t.charCodeAt(n)?i-s%i:1,n=p(t,n)}return!0===n?-1:t.length}const Kt="undefined"==typeof Symbol?"__ͼ":Symbol.for("ͼ"),jt="undefined"==typeof Symbol?"__styleSet"+Math.floor(1e8*Math.random()):Symbol("styleSet"),$t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:{};class Ut{constructor(t,e){this.rules=[];let{finish:i}=e||{};function n(t){return/^@/.test(t)?[t]:t.split(/,\s*/)}function s(t,e,r,o){let l=[],h=/^@(\w+)\b/.exec(t[0]),a=h&&"keyframes"==h[1];if(h&&null==e)return r.push(t[0]+";");for(let i in e){let o=e[i];if(/&/.test(i))s(i.split(/,\s*/).map((e=>t.map((t=>e.replace(/&/,t))))).reduce(((t,e)=>t.concat(e))),o,r);else if(o&&"object"==typeof o){if(!h)throw new RangeError("The value of a property ("+i+") should be a primitive value.");s(n(i),o,l,a)}else null!=o&&l.push(i.replace(/_.*/,"").replace(/[A-Z]/g,(t=>"-"+t.toLowerCase()))+": "+o+";")}(l.length||a)&&r.push((!i||h||o?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=$t[Kt]||1;return $t[Kt]=t+1,"ͼ"+t.toString(36)}static mount(t,e,i){let n=t[jt],s=i&&i.nonce;n?s&&n.setNonce(s):n=new Jt(t,s),n.mount(Array.isArray(e)?e:[e],t)}}let Gt=new Map;class Jt{constructor(t,e){let i=t.ownerDocument||t,n=i.defaultView;if(!t.head&&t.adoptedStyleSheets&&n.CSSStyleSheet){let e=Gt.get(i);if(e)return t[jt]=e;this.sheet=new n.CSSStyleSheet,Gt.set(i,this)}else this.styleTag=i.createElement("style"),e&&this.styleTag.setAttribute("nonce",e);this.modules=[],t[jt]=this}mount(t,e){let i=this.sheet,n=0,s=0;for(let e=0;e-1&&(this.modules.splice(o,1),s--,o=-1),-1==o){if(this.modules.splice(s++,0,r),i)for(let t=0;t",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Qt="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),Zt="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),te=0;te<10;te++)Yt[48+te]=Yt[96+te]=String(te);for(te=1;te<=24;te++)Yt[te+111]="F"+te;for(te=65;te<=90;te++)Yt[te]=String.fromCharCode(te+32),Xt[te]=String.fromCharCode(te);for(var ee in Yt)Xt.hasOwnProperty(ee)||(Xt[ee]=Yt[ee]);function ie(t){let e;return e=11==t.nodeType?t.getSelection?t:t.ownerDocument:t,e.getSelection()}function ne(t,e){return!!e&&(t==e||t.contains(1!=e.nodeType?e.parentNode:e))}function se(t,e){if(!e.anchorNode)return!1;try{return ne(t,e.anchorNode)}catch(t){return!1}}function re(t){return 3==t.nodeType?we(t,0,t.nodeValue.length).getClientRects():1==t.nodeType?t.getClientRects():[]}function oe(t,e,i,n){return!!i&&(ae(t,e,i,n,-1)||ae(t,e,i,n,1))}function le(t){for(var e=0;;e++)if(!(t=t.previousSibling))return e}function he(t){return 1==t.nodeType&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}function ae(t,e,i,n,s){for(;;){if(t==i&&e==n)return!0;if(e==(s<0?0:ce(t))){if("DIV"==t.nodeName)return!1;let i=t.parentNode;if(!i||1!=i.nodeType)return!1;e=le(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?ce(t):0}}}function ce(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function ue(t,e){let i=e?t.left:t.right;return{left:i,right:i,top:t.top,bottom:t.bottom}}function fe(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 de(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 pe{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?ce(e):0),i,Math.min(t.focusOffset,i?ce(i):0))}set(t,e,i,n){this.anchorNode=t,this.anchorOffset=e,this.focusNode=i,this.focusOffset=n}}let ge,me=null;function ve(t){if(t.setActive)return t.setActive();if(me)return t.focus(me);let e=[];for(let i=t;i&&(e.push(i,i.scrollTop,i.scrollLeft),i!=i.ownerDocument);i=i.parentNode);if(t.focus(null==me?{get preventScroll(){return me={preventScroll:!0},!0}}:void 0),!me){me=!1;for(let t=0;tMath.max(1,t.scrollHeight-t.clientHeight-4)}function ke(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=ce(i)}else{if(!i.parentNode||he(i))return null;n=le(i),i=i.parentNode}}}function Se(t,e){for(let i=t,n=e;;){if(3==i.nodeType&&ne)return i.domBoundsAround(t,e,h);if(c>=t&&-1==n&&(n=l,s=h),h>e&&i.dom.parentNode==this.dom){r=l,o=a;break}a=c,h=c+i.breakAfter}return{from:s,to:o<0?i+this.length:o,startDOM:(n?this.children[n-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:r=0?this.children[r].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=Me){this.markDirty();for(let n=t;nthis.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 Te(t,e,i,n,s,r,o,l,h){let{children:a}=t,c=a.length?a[e]:null,u=r.length?r[r.length-1]:null,f=u?u.breakAfter:o;if(!(e==n&&c&&!o&&!f&&r.length<2&&c.merge(i,s,r.length?u:null,0==i,l,h))){if(n0&&(!o&&r.length&&c.merge(i,c.length,r[0],!1,l,0)?c.breakAfter=r.shift().breakAfter:(i2);var qe={mac:Fe||/Mac/.test(Re.platform),windows:/Win/.test(Re.platform),linux:/Linux|X11/.test(Re.platform),ie:Ie,ie_version:Le?Be.documentMode||6:Ne?+Ne[1]:Pe?+Pe[1]:0,gecko:Ve,gecko_version:Ve?+(/Firefox\/(\d+)/.exec(Re.userAgent)||[0,0])[1]:0,chrome:!!He,chrome_version:He?+He[1]:0,ios:Fe,android:/Android\b/.test(Re.userAgent),webkit:We,safari:ze,webkit_version:We?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0,tabSize:null!=Be.documentElement.style.tabSize?"tab-size":"-moz-tab-size"};class _e extends Ce{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 _e)||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 _e(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 Ae(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,r=e,o=0;0==e&&i<0||e==n&&i>=0?qe.chrome||qe.gecko||(e?(s--,o=1):r=0)?0:l.length-1];qe.safari&&!o&&0==h.width&&(h=Array.prototype.find.call(l,(t=>t.width))||h);return o?ue(h,o<0):h||null}(this.dom,t,e)}}class Ke extends Ce{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(be(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,r){return(!i||!(!(i instanceof Ke&&i.mark.eq(this.mark))||t&&s<=0||et&&e.push(i=t&&(n=s),i=o,s++}let r=this.length-t;return this.length=t,n>-1&&(this.children.length=n,this.markDirty()),new Ke(this.mark,e,r)}domAtPos(t){return Ue(this,t)}coordsAt(t,e){return Je(this,t,e)}}class je extends Ce{static create(t,e,i){return new je(t,e,i)}constructor(t,e,i){super(),this.widget=t,this.length=e,this.side=i,this.prevWidget=null}split(t){let e=je.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,r){return!(i&&(!(i instanceof je&&this.widget.compare(i.widget))||t>0&&s<=0||e0)?Ae.before(this.dom):Ae.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 r=this.side?this.side<0:t>0;for(let e=r?n.length-1:0;s=n[e],!(t>0?0==e:e==n.length-1||s.top0?Ae.before(this.dom):Ae.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(t){return this.dom.getBoundingClientRect()}get overrideDOMText(){return t.empty}get isHidden(){return!0}}function Ue(t,e){let i=t.dom,{children:n}=t,s=0;for(let t=0;st&&e0;t--){let e=n[t-1];if(e.dom.parentNode==i)return e.domAtPos(e.length)}for(let t=s;t0&&e instanceof Ke&&s.length&&(n=s[s.length-1])instanceof Ke&&n.mark.eq(e.mark)?Ge(n,e.children[0],i-1):(s.push(e),e.setParent(t)),t.length+=e.length}function Je(t,e,i){let n=null,s=-1,r=null,o=-1;!function t(e,l){for(let h=0,a=0;h=l&&(c.children.length?t(c,l-a):(!r||r.isHidden&&i>0)&&(u>l||a==u&&c.getSide()>0)?(r=c,o=l-a):(a-1?1:0)!=s.length-(i&&s.indexOf(i)>-1?1:0))return!1;for(let r of n)if(r!=i&&(-1==s.indexOf(r)||t[r]!==e[r]))return!1;return!0}function Ze(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 ti(t){let e=Object.create(null);for(let i=0;i0&&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){Qe(this.attrs,t)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=t)}append(t,e){Ge(this,t,e)}addLineDeco(t){let e=t.spec.attributes,i=t.spec.class;e&&(this.attrs=Ye(e,this.attrs||{})),i&&(this.attrs=Ye({class:i},this.attrs||{}))}domAtPos(t){return Ue(this,t)}reuseDOM(t){"DIV"==t.nodeName&&(this.setDOM(t),this.flags|=6)}sync(t,e){var i;this.dom?4&this.flags&&(be(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&&(Ze(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&&Ce.get(n)instanceof Ke;)n=n.lastChild;if(!(n&&this.length&&("BR"==n.nodeName||0!=(null===(i=Ce.get(n))||void 0===i?void 0:i.isEditable)||qe.ios&&this.children.some((t=>t instanceof _e))))){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 _e)||/[^ -~]/.test(i.text))return null;let n=re(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=Je(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){if(s instanceof ei)return s;if(r>e)break}n=r+s.breakAfter}return null}}class ii extends Ce{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,r){return!(i&&(!(i instanceof ii&&this.widget.compare(i.widget))||t>0&&s<=0||e0)}}class ni{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 si=function(t){return t[t.Text=0]="Text",t[t.WidgetBefore=1]="WidgetBefore",t[t.WidgetAfter=2]="WidgetAfter",t[t.WidgetRange=3]="WidgetRange",t}(si||(si={}));class ri extends Ct{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 oi(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 hi(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:r}=ai(t,n);e=(s?n?-3e8:-1:5e8)-1,i=1+(r?n?2e8:1:-6e8)}return new hi(t,e,i,n,t.widget||null,!0)}static line(t){return new li(t)}static set(t,e=!1){return Et.of(t,e)}hasHeight(){return!!this.widget&&this.widget.estimatedHeight>-1}}ri.none=Et.empty;class oi extends ri{constructor(t){let{start:e,end:i}=ai(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 oi&&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))&&Qe(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)}}oi.prototype.point=!1;class li extends ri{constructor(t){super(-2e8,-2e8,null,t)}eq(t){return t instanceof li&&this.spec.class==t.spec.class&&Qe(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)}}li.prototype.mapMode=S.TrackBefore,li.prototype.point=!0;class hi extends ri{constructor(t,e,i,n,s,r){super(e,i,s,t),this.block=n,this.isReplace=r,this.mapMode=n?e<=0?S.TrackBefore:S.TrackAfter:S.TrackDel}get type(){return this.startSide!=this.endSide?si.WidgetRange:this.startSide<=0?si.WidgetBefore:si.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(t){return t instanceof hi&&(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 ai(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 ci(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)}hi.prototype.point=!0;class ui{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 ii&&t.deco.endSide<0)}getLine(){return this.curLine||(this.content.push(this.curLine=new ei),this.atCursorPos=!0),this.curLine}flushBuffer(t=this.bufferMarks){this.pendingBuffer&&(this.curLine.append(fi(new $e(-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 ii||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,512);this.flushBuffer(e.slice(e.length-i)),this.getLine().append(fi(new _e(this.text.slice(this.textOff,this.textOff+n)),e),i),this.atCursorPos=!0,this.textOff+=n,t-=n,i=0}}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,r){if(this.disallowBlockEffectsFor[r]&&i instanceof hi){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 o=e-t;if(i instanceof hi)if(i.block)i.startSide>0&&!this.posCovered()&&this.getLine(),this.addBlockWidget(new ii(i.widget||di.block,o,i));else{let r=je.create(i.widget||di.inline,o,o?0:i.startSide),l=this.atCursorPos&&!r.isEditable&&s<=n.length&&(t0),h=!r.isEditable&&(tn.length||i.startSide<=0),a=this.getLine();2!=this.pendingBuffer||l||r.isEditable||(this.pendingBuffer=0),this.flushBuffer(n),l&&(a.append(fi(new $e(1),n),s),s=n.length+Math.max(0,s-n.length)),a.append(fi(r,n),s),this.atCursorPos=h,this.pendingBuffer=h?tn.length?1:2:0,this.pendingBuffer&&(this.bufferMarks=n.slice())}else this.doc.lineAt(this.pos).from==this.pos&&this.getLine().addLineDeco(i);o&&(this.textOff+o<=this.text.length?this.textOff+=o:(this.skip+=o-(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 r=new ui(t,e,i,s);return r.openEnd=Et.spans(n,e,i,r),r.openStart<0&&(r.openStart=r.openEnd),r.finish(r.openEnd),r}}function fi(t,e){for(let i of e)t=new Ke(i,[t],t.length);return t}class di extends ni{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}}di.inline=new di("span"),di.block=new di("div"),exports.Direction=function(t){return t[t.LTR=0]="LTR",t[t.RTL=1]="RTL",t}(exports.Direction||(exports.Direction={}));const pi=exports.Direction.LTR,gi=exports.Direction.RTL;function mi(t){let e=[];for(let i=0;i=e){if(o.level==i)return r;(s<0||(0!=n?n<0?o.frome:t[s].level>o.level))&&(s=r)}}if(s<0)throw new RangeError("Index out of range");return s}}function Ai(t,e){if(t.length!=e.length)return!1;for(let i=0;ih&&o.push(new Si(h,p.from,f)),Di(t,p.direction==pi!=!(f%2)?n+1:n,s,p.inner,p.from,p.to,o),h=p.to}d=p.to}else{if(d==i||(e?Mi[d]!=l:Mi[d]==l))break;d++}u?Ci(t,h,d,n+1,s,u,o):he;){let i=!0,c=!1;if(!a||h>r[a-1].to){let t=Mi[h-1];t!=l&&(i=!1,c=16==t)}let u=i||1!=l?null:[],f=i?n:n+1,d=h;t:for(;;)if(a&&d==r[a-1].to){if(c)break t;let p=r[--a];if(!i)for(let t=p.from,i=a;;){if(t==e)break t;if(!i||r[i-1].to!=t){if(Mi[t-1]==l)break t;break}t=r[--i].from}if(u)u.push(p);else{p.to=0;t-=3)if(bi[t+1]==-i){let e=bi[t+2],i=2&e?s:4&e?1&e?r:s:0;i&&(Mi[o]=Mi[bi[t]]=i),l=t;break}}else{if(189==bi.length)break;bi[l++]=o,bi[l++]=e,bi[l++]=h}else if(2==(n=Mi[o])||1==n){let t=n==s;h=t?0:1;for(let e=l-3;e>=0;e-=3){let i=bi[e+2];if(2&i)break;if(t)bi[e+2]|=2;else{if(4&i)break;bi[e+2]|=4}}}}}(t,s,r,n,l),function(t,e,i,n){for(let s=0,r=n;s<=i.length;s++){let o=s?i[s-1].to:t,l=sh;)e==r&&(e=i[--n].from,r=n?i[n-1].to:t),Mi[--e]=c;h=o}else r=o,h++}}}(s,r,n,l),Ci(t,s,r,e,i,n,o)}function Oi(t){return[new Si(0,t,0)]}let Ti="";function Ei(t,e,i,n,s){var r;let o=n.head-t.from,l=Si.find(e,o,null!==(r=n.bidiLevel)&&void 0!==r?r:-1,n.assoc),h=e[l],a=h.side(s,i);if(o==a){let t=l+=s?1:-1;if(t<0||t>=e.length)return null;h=e[l=t],o=h.side(!s,i),a=h.side(s,i)}let c=p(t.text,o,h.forward(s,i));(ch.to)&&(c=a),Ti=t.text.slice(Math.min(o,c),Math.max(o,c));let u=l==(s?e.length-1:0)?null:e[l+(s?1:-1)];return u&&c==a&&u.level+(s?0:1)t.some((t=>t))}),zi=I.define({combine:t=>t.some((t=>t))}),Fi=I.define();class qi{constructor(t,e="nearest",i="nearest",n=5,s=5,r=!1){this.range=t,this.y=e,this.x=i,this.yMargin=n,this.xMargin=s,this.isSnapshot=r}map(t){return t.empty?this:new qi(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 qi(P.cursor(t.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const _i=ft.define({map:(t,e)=>t.map(e)});function Ki(t,e,i){let n=t.facet(Ni);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 ji=I.define({combine:t=>!t.length||t[0]});let $i=0;const Ui=I.define();class Gi{constructor(t,e,i,n,s){this.id=t,this.create=e,this.domEventHandlers=i,this.domEventObservers=n,this.extension=s(this)}static define(t,e){const{eventHandlers:i,eventObservers:n,provide:s,decorations:r}=e||{};return new Gi($i++,t,i,n,(t=>{let e=[Ui.of(t)];return r&&e.push(Qi.of((e=>{let i=e.plugin(t);return i?r(i):ri.none}))),s&&e.push(s(t)),e}))}static fromClass(t,e){return Gi.define((e=>new t(e)),e)}}class Ji{constructor(t){this.spec=t,this.mustUpdate=null,this.value=null}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(Ki(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.create(t)}catch(e){Ki(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){Ki(t.state,e,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const Yi=I.define(),Xi=I.define(),Qi=I.define(),Zi=I.define(),tn=I.define(),en=I.define();function nn(t,e){let i=t.state.facet(en);if(!i.length)return i;let n=i.map((e=>e instanceof Function?e(t):e)),s=[];return Et.spans(n,e.from,e.to,{point(){},span(t,i,n,r){let o=t-e.from,l=i-e.from,h=s;for(let t=n.length-1;t>=0;t--,r--){let i,s=n[t].spec.bidiIsolate;if(null==s&&(s=Ri(e.text,o,l)),r>0&&h.length&&(i=h[h.length-1]).to==o&&i.direction==s)i.to=l,h=i.inner;else{let t={from:o,to:l,direction:s,inner:[]};h.push(t),h=t.inner}}}}),s}const sn=I.define();function rn(t){let e=0,i=0,n=0,s=0;for(let r of t.state.facet(sn)){let o=r(t);o&&(null!=o.left&&(e=Math.max(e,o.left)),null!=o.right&&(i=Math.max(i,o.right)),null!=o.top&&(n=Math.max(n,o.top)),null!=o.bottom&&(s=Math.max(s,o.bottom)))}return{left:e,right:i,top:n,bottom:s}}const on=I.define();class ln{constructor(t,e,i,n){this.fromA=t,this.toA=e,this.fromB=i,this.toB=n}join(t){return new ln(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.toAa)break;s+=2}if(!l)return i;new ln(l.fromA,l.toA,l.fromB,l.toB).addToSet(i),r=l.toA,o=l.toB}}}class hn{constructor(t,e,i){this.view=t,this.state=e,this.transactions=i,this.flags=0,this.startState=t.state,this.changes=M.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 ln(t,e,i,s)))),this.changedRanges=n}static create(t,e,i){return new hn(t,e,i)}get viewportChanged(){return(4&this.flags)>0}get heightChanged(){return(2&this.flags)>0}get geometryChanged(){return this.docChanged||(10&this.flags)>0}get focusChanged(){return(1&this.flags)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some((t=>t.selection))}get empty(){return 0==this.flags&&0==this.transactions.length}}class an extends Ce{get length(){return this.view.state.doc.length}constructor(t){super(),this.view=t,this.decorations=[],this.dynamicDecorationMap=[],this.domChanged=null,this.hasComposition=null,this.markedForComposition=new Set,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 ei],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new ln(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})=>ethis.minWidthTo))?(this.minWidthFrom=t.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=t.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0);let n=-1;this.view.inputState.composing>=0&&((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)=>{te.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=un(t,i);if(!n)return null;let{node:s,from:r,to:o}=n,l=s.nodeValue;if(/[\n\r]/.test(l))return null;if(t.state.doc.sliceString(n.from,n.to)!=l)return null;let h=e.invertedDesc,a=new ln(h.mapPos(r),h.mapPos(o),r,o),c=[];for(let e=s.parentNode;;e=e.parentNode){let i=Ce.get(e);if(i instanceof Ke)c.push({node:e,deco:i.mark});else{if(i instanceof ei||"DIV"==e.nodeName&&e.parentNode==t.contentDOM)return{range:a,text:s,marks:c,line:e};if(e==t.contentDOM)return null;c.push({node:e,deco:new oi({inclusive:!0,attributes:ti(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 ln(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,(qe.ie||qe.chrome)&&!s&&t&&t.state.doc.lines!=t.startState.doc.lines&&(this.forceSelection=!0);let r=function(t,e,i){let n=new fn;return Et.compare(t,e,i,n),n.changes}(this.decorations,this.updateDeco(),t.changes);return i=ln.extendWithRanges(i,r),!!(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=qe.chrome||qe.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=0?n[t]:null;if(!e)break;let r,o,l,h,{fromA:a,toA:c,fromB:u,toB:f}=e;if(i&&i.range.fromBu){let t=ui.build(this.view.state.doc,u,i.range.fromB,this.decorations,this.dynamicDecorationMap),e=ui.build(this.view.state.doc,i.range.toB,f,this.decorations,this.dynamicDecorationMap);o=t.breakAtStart,l=t.openStart,h=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(),r=t.content.concat(n).concat(e.content)}else({content:r,breakAtStart:o,openStart:l,openEnd:h}=ui.build(this.view.state.doc,u,f,this.decorations,this.dynamicDecorationMap));let{i:d,off:p}=s.findPos(c,1),{i:g,off:m}=s.findPos(a,-1);Te(this,g,m,d,p,r,o,l,h)}i&&this.fixCompositionDOM(i)}compositionView(t){let e=new _e(t.text.nodeValue);e.flags|=8;for(let{deco:i}of t.marks)e=new Ke(i,[e],e.length);let i=new ei;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=Ce.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&&se(this.dom,this.view.observer.selectionRange)&&!(i&&this.dom.contains(i));if(!(n||e||s))return;let r=this.forceSelection;this.forceSelection=!1;let o=this.view.state.selection.main,l=this.moveToLine(this.domAtPos(o.anchor)),h=o.empty?l:this.moveToLine(this.domAtPos(o.head));if(qe.gecko&&o.empty&&!this.hasComposition&&(1==(a=l).node.nodeType&&a.node.firstChild&&(0==a.offset||"false"==a.node.childNodes[a.offset-1].contentEditable)&&(a.offset==a.node.childNodes.length||"false"==a.node.childNodes[a.offset].contentEditable))){let t=document.createTextNode("");this.view.observer.ignore((()=>l.node.insertBefore(t,l.node.childNodes[l.offset]||null))),l=h=new Ae(t,0),r=!0}var a;let c=this.view.observer.selectionRange;!r&&c.focusNode&&(oe(l.node,l.offset,c.anchorNode,c.anchorOffset)&&oe(h.node,h.offset,c.focusNode,c.focusOffset)||this.suppressWidgetCursorChange(c,o))||(this.view.observer.ignore((()=>{qe.android&&qe.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=ie(this.view.root);if(t)if(o.empty){if(qe.gecko){let t=(e=l.node,n=l.offset,1!=e.nodeType?0:(n&&"false"==e.childNodes[n-1].contentEditable?1:0)|(no.head&&([l,h]=[h,l]),e.setEnd(h.node,h.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,h)),this.impreciseAnchor=l.precise?null:new Ae(c.anchorNode,c.anchorOffset),this.impreciseHead=h.precise?null:new Ae(c.focusNode,c.focusOffset)}suppressWidgetCursorChange(t,e){return this.hasComposition&&e.empty&&oe(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=ie(t.root),{anchorNode:n,anchorOffset:s}=t.observer.selectionRange;if(!(i&&e.empty&&e.assoc&&i.modify))return;let r=ei.find(this,e.head);if(!r)return;let o=r.posAtStart;if(e.head==o||e.head==o+r.length)return;let l=this.coordsAt(e.head,-1),h=this.coordsAt(e.head,1);if(!l||!h||l.bottom>h.top)return;let a=this.domAtPos(e.head+e.assoc);i.collapse(a.node,a.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=0;n--){let t=Ce.get(i.childNodes[n]);t instanceof ei&&(e=t.domAtPos(t.length))}return e?new Ae(e.node,e.offset,!0):t}nearest(t){for(let e=t;e;){let t=Ce.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=0;r--){let o=this.children[r],l=s-o.breakAfter,h=l-o.length;if(lt||o.covers(1))&&(!i||o instanceof ei&&!(i instanceof ei&&e>=0))&&(i=o,n=h),s=h}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 ei))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 _e))return null;let s=p(n.text,i);if(s==i)return null;let r=we(n.dom,i,s).getClientRects();for(let t=0;tMath.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,o=-1,l=this.view.textDirection==exports.Direction.LTR;for(let t=0,h=0;hn)break;if(t>=i){let i=a.dom.getBoundingClientRect();if(e.push(i.height),r){let e=a.dom.lastChild,n=e?re(e):[];if(n.length){let e=n[n.length-1],r=l?e.right-i.left:i.right-e.left;r>o&&(o=r,this.minWidth=s,this.minWidthFrom=t,this.minWidthTo=c)}}}t=c+a.breakAfter}return e}textDirectionAt(t){let{i:e}=this.childPos(t,1);return"rtl"==getComputedStyle(this.children[e].dom).direction?exports.Direction.RTL:exports.Direction.LTR}measureTextSize(){for(let t of this.children)if(t instanceof ei){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=re(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 Oe(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],r=s?s.from-1:this.length;if(r>i){let n=(e.lineBlockAt(r).bottom-e.lineBlockAt(i).top)/this.view.scaleY;t.push(ri.replace({widget:new cn(n),block:!0,inclusive:!0,isBlockGap:!0}).range(i,r))}if(!s)break;i=s.to+1}return ri.set(t)}updateDeco(){let t=0,e=this.view.state.facet(Qi).map((e=>(this.dynamicDecorationMap[t++]="function"==typeof e)?e(this.view):e)),i=!1,n=this.view.state.facet(Zi).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(Et.join(n))),this.decorations=[...e,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];ti.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=rn(this.view),r={left:n.left-s.left,top:n.top-s.top,right:n.right+s.right,bottom:n.bottom+s.bottom},{offsetWidth:o,offsetHeight:l}=this.view.scrollDOM;!function(t,e,i,n,s,r,o,l){let h=t.ownerDocument,a=h.defaultView||window;for(let c=t,u=!1;c&&!u;)if(1==c.nodeType){let t,f=c==h.body,d=1,p=1;if(f)t=fe(a);else{if(/^(fixed|sticky)$/.test(getComputedStyle(c).position)&&(u=!0),c.scrollHeight<=c.clientHeight&&c.scrollWidth<=c.clientWidth){c=c.assignedSlot||c.parentNode;continue}let e=c.getBoundingClientRect();({scaleX:d,scaleY:p}=de(c,e)),t={left:e.left,right:e.left+c.clientWidth*d,top:e.top,bottom:e.top+c.clientHeight*p}}let g=0,m=0;if("nearest"==s)e.top0&&e.bottom>t.bottom+m&&(m=e.bottom-t.bottom+m+o)):e.bottom>t.bottom&&(m=e.bottom-t.bottom+o,i<0&&e.top-m0&&e.right>t.right+g&&(g=e.right-t.right+g+r)):e.right>t.right&&(g=e.right-t.right+r,i<0&&e.leftt?e.left-t:Math.max(0,t-e.right)}function pn(t,e){return e.top>t?e.top-t:Math.max(0,t-e.bottom)}function gn(t,e){return t.tope.top+1}function mn(t,e){return et.bottom?{top:t.top,left:t.left,right:t.right,bottom:e}:t}function wn(t,e,i){let n,s,r,o,l,h,a,c,u=!1;for(let f=t.firstChild;f;f=f.nextSibling){let t=re(f);for(let d=0;dm||o==m&&r>g){n=f,s=p,r=g,o=m;let l=m?i0?d0)}0==g?i>p.bottom&&(!a||a.bottomp.top)&&(h=f,c=p):a&&gn(a,p)?a=vn(a,p.bottom):c&&gn(c,p)&&(c=mn(c,p.top))}}if(a&&a.bottom>=i?(n=l,s=a):c&&c.top<=i&&(n=h,s=c),!n)return{node:t,offset:0};let f=Math.max(s.left,Math.min(s.right,e));return 3==n.nodeType?yn(n,f,i):u&&"false"!=n.contentEditable?wn(n,f,i):{node:t,offset:Array.prototype.indexOf.call(t.childNodes,n)+(e>=(s.left+s.right)/2?1:0)}}function yn(t,e,i){let n=t.nodeValue.length,s=-1,r=1e9,o=0;for(let l=0;li?a.top-i:i-a.bottom)-1;if(a.left-1<=e&&a.right+1>=e&&c=(a.left+a.right)/2,n=i;if(qe.chrome||qe.gecko){we(t,l).getBoundingClientRect().left==a.right&&(n=!i)}if(c<=0)return{node:t,offset:l+(n?1:0)};s=l+(n?1:0),r=c}}}return{node:t,offset:s>-1?s:o>0?t.nodeValue.length:0}}function bn(t,e,i,n=-1){var s,r;let o,l=t.contentDOM.getBoundingClientRect(),h=l.top+t.viewState.paddingTop,{docHeight:a}=t.viewState,{x:c,y:u}=e,f=u-h;if(f<0)return 0;if(f>a)return t.state.doc.length;for(let e=t.viewState.heightOracle.textHeight/2,s=!1;o=t.elementAtHeight(f),o.type!=si.Text;)for(;f=n>0?o.bottom+e:o.top-e,!(f>=0&&f<=a);){if(s)return i?null:0;s=!0,n=-n}u=h+f;let d=o.from;if(dt.viewport.to)return t.viewport.to==t.state.doc.length?t.state.doc.length:i?null:xn(t,l,o,c,u);let p=t.dom.ownerDocument,g=t.root.elementFromPoint?t.root:p,m=g.elementFromPoint(c,u);m&&!t.contentDOM.contains(m)&&(m=null),m||(c=Math.max(l.left+1,Math.min(l.right-1,c)),m=g.elementFromPoint(c,u),m&&!t.contentDOM.contains(m)&&(m=null));let v,w=-1;if(m&&0!=(null===(s=t.docView.nearest(m))||void 0===s?void 0:s.isEditable))if(p.caretPositionFromPoint){let t=p.caretPositionFromPoint(c,u);t&&({offsetNode:v,offset:w}=t)}else if(p.caretRangeFromPoint){let e=p.caretRangeFromPoint(c,u);e&&(({startContainer:v,startOffset:w}=e),(!t.contentDOM.contains(v)||qe.safari&&function(t,e,i){let n;if(3!=t.nodeType||e!=(n=t.nodeValue.length))return!1;for(let e=t.nextSibling;e;e=e.nextSibling)if(1!=e.nodeType||"BR"!=e.nodeName)return!1;return we(t,n-1,n).getBoundingClientRect().left>i}(v,w,c)||qe.chrome&&function(t,e,i){if(0!=e)return!1;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():we(t,0,Math.max(t.nodeValue.length,1)).getBoundingClientRect();return i-n.left>5}(v,w,c))&&(v=void 0))}if(!v||!t.docView.dom.contains(v)){let e=ei.find(t.docView,d);if(!e)return f>o.top+o.height/2?o.to:o.from;({node:v,offset:w}=wn(e.dom,c,u))}let y=t.docView.nearest(v);if(!y)return null;if(y.isWidget&&1==(null===(r=y.dom)||void 0===r?void 0:r.nodeType)){let t=y.dom.getBoundingClientRect();return e.y1.5*t.defaultLineHeight){let e=t.viewState.heightOracle.textHeight;r+=Math.floor((s-i.top-.5*(t.defaultLineHeight-e))/e)*t.viewState.heightOracle.lineLength}let o=t.state.sliceDoc(i.from,i.to);return i.from+_t(o,r,t.state.tabSize)}function kn(t,e){let i=t.lineBlockAt(e);if(Array.isArray(i.type))for(let t of i.type)if(t.to>e||t.to==e&&(t.to==i.to||t.type==si.Text))return t;return i}function Sn(t,e,i,n){let s=t.state.doc.lineAt(e.head),r=t.bidiSpans(s),o=t.textDirectionAt(s.from);for(let l=e,h=null;;){let e=Ei(s,r,o,l,i),a=Ti;if(!e){if(s.number==(i?t.state.doc.lines:1))return l;a="\n",s=t.state.doc.line(s.number+(i?1:-1)),r=t.bidiSpans(s),e=t.visualLineSide(s,!i)}if(h){if(!h(a))return l}else{if(!n)return e;h=n(a)}l=e}}function An(t,e,i){for(;;){let n=0;for(let s of t)s.between(e-1,e+1,((t,s,r)=>{if(e>t&&ee(t))),i.from,e.head>i.from?-1:1);return n==i.from?i:P.cursor(n,nnull)),qe.gecko&&function(t){Zn.has(t)||(Zn.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=Ce.get(n))&&i.ignoreEvent(e))return!1;return!0})(this.view,t)&&!this.ignoreDuringComposition(t)&&("keydown"==t.type&&this.keydown(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=On(t),i=this.handlers,n=this.view.contentDOM;for(let t in e)if("scroll"!=t){let s=!e[t].handlers.length,r=i[t];r&&s!=!r.handlers.length&&(n.removeEventListener(t,this.handleEvent),r=null),r||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&&Date.now()e.keyCode==t.keyCode)))&&!t.ctrlKey||En.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.from0||!!(qe.safari&&!qe.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.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 Dn(t,e){return(i,n)=>{try{return e.call(t,n,i)}catch(t){Ki(i.state,t)}}}function On(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;if(t&&t.domEventHandlers)for(let n in t.domEventHandlers){let s=t.domEventHandlers[n];s&&i(n).handlers.push(Dn(e.value,s))}if(t&&t.domEventObservers)for(let n in t.domEventObservers){let s=t.domEventObservers[n];s&&i(n).observers.push(Dn(e.value,s))}}for(let t in Ln)i(t).handlers.push(Ln[t]);for(let t in Nn)i(t).observers.push(Nn[t]);return e}const Tn=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],En="dthko",Rn=[16,17,18,20,91,92,224,225];function Bn(t){return.7*Math.max(0,t)+8}class Pn{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.scrollParent=function(t){let e=t.ownerDocument;for(let i=t.parentNode;i&&i!=e.body;)if(1==i.nodeType){if(i.scrollHeight>i.clientHeight||i.scrollWidth>i.clientWidth)return i;i=i.assignedSlot||i.parentNode}else{if(11!=i.nodeType)break;i=i.host}return null}(t.contentDOM),this.atoms=t.state.facet(tn).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(At.allowMultipleSelections)&&function(t,e){let i=t.state.facet(Bi);return i.length?i[0](e):qe.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=ie(t.root);if(!n||0==n.rangeCount)return!0;let s=n.getRangeAt(0).getClientRects();for(let t=0;t=e.clientX&&i.top<=e.clientY&&i.bottom>=e.clientY)return!0}return!1}(t,e)||1!=Un(e))&&null}start(t){!1===this.dragging&&this.select(t)}move(t){var e,i,n;if(0==t.buttons)return this.destroy();if(this.dragging||null==this.dragging&&(i=this.startEvent,n=t,Math.max(Math.abs(i.clientX-n.clientX),Math.abs(i.clientY-n.clientY))<10))return;this.select(this.lastEvent=t);let s=0,r=0,o=(null===(e=this.scrollParent)||void 0===e?void 0:e.getBoundingClientRect())||{left:0,top:0,right:this.view.win.innerWidth,bottom:this.view.win.innerHeight},l=rn(this.view);t.clientX-l.left<=o.left+6?s=-Bn(o.left-t.clientX):t.clientX+l.right>=o.right-6&&(s=Bn(t.clientX-o.right)),t.clientY-l.top<=o.top+6?r=-Bn(o.top-t.clientY):t.clientY+l.bottom>=o.bottom-6&&(r=Bn(t.clientY-o.bottom)),this.setScrollSpeed(s,r)}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(){this.scrollParent?(this.scrollParent.scrollLeft+=this.scrollSpeed.x,this.scrollParent.scrollTop+=this.scrollSpeed.y):this.view.win.scrollBy(this.scrollSpeed.x,this.scrollSpeed.y),!1===this.dragging&&this.select(this.lastEvent)}skipAtoms(t){let e=null;for(let i=0;ithis.select(this.lastEvent)),20)}}const Ln=Object.create(null),Nn=Object.create(null),In=qe.ie&&qe.ie_version<15||qe.ios&&qe.webkit_version<604;function Vn(t,e){let i,{state:n}=t,s=1,r=n.toText(e),o=r.lines==n.selection.ranges.length;if(null!=Jn&&n.selection.ranges.every((t=>t.empty))&&Jn==r.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 h=n.toText((o?r.line(s++).text:e)+n.lineBreak);return{changes:{from:l.from,insert:h},range:P.cursor(i.from+h.length)}}))}else i=o?n.changeByRange((t=>{let e=r.line(s++);return{changes:{from:t.from,to:t.to,insert:e.text},range:P.cursor(t.from+e.length)}})):n.replaceSelection(r);t.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}function Hn(t,e,i,n){if(1==n)return P.cursor(e,i);if(2==n)return function(t,e,i=1){let n=t.charCategorizer(e),s=t.doc.lineAt(e),r=e-s.from;if(0==s.length)return P.cursor(e);0==r?i=1:r==s.length&&(i=-1);let o=r,l=r;i<0?o=p(s.text,r,!1):l=p(s.text,r);let h=n(s.text.slice(o,l));for(;o>0;){let t=p(s.text,o,!1);if(n(s.text.slice(t,o))!=h)break;o=t}for(;l{t.inputState.lastScrollTop=t.scrollDOM.scrollTop,t.inputState.lastScrollLeft=t.scrollDOM.scrollLeft},Ln.keydown=(t,e)=>(t.inputState.setSelectionOrigin("select"),27==e.keyCode&&(t.inputState.lastEscPress=Date.now()),!1),Nn.touchstart=(t,e)=>{t.inputState.lastTouchTime=Date.now(),t.inputState.setSelectionOrigin("select.pointer")},Nn.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")},Ln.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(Li))if(i=n(t,e),i)break;if(i||0!=e.button||(i=function(t,e){let i=qn(t,e),n=Un(e),s=t.state.selection;return{update(t){t.docChanged&&(i.pos=t.changes.mapPos(i.pos),s=s.map(t.changes))},get(e,r,o){let l,h=qn(t,e),a=Hn(t,h.pos,h.bias,n);if(i.pos!=h.pos&&!r){let e=Hn(t,i.pos,i.bias,n),s=Math.min(e.from,a.from),r=Math.max(e.to,a.to);a=s1&&(l=function(t,e){for(let i=0;i=e)return P.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,h.pos))?l:o?s.addRange(a):P.create([a])}}}(t,e)),i){let n=!t.hasFocus;t.inputState.startMouseSelection(new Pn(t,e,i,n)),n&&t.observer.ignore((()=>ve(t.contentDOM)));let s=t.inputState.mouseSelection;if(s)return s.start(e),!1===s.dragging}return!1};let Wn=(t,e)=>t>=e.top&&t<=e.bottom,zn=(t,e,i)=>Wn(e,i)&&t>=i.left&&t<=i.right;function Fn(t,e,i,n){let s=ei.find(t.docView,e);if(!s)return 1;let r=e-s.posAtStart;if(0==r)return 1;if(r==s.length)return-1;let o=s.coordsAt(r,-1);if(o&&zn(i,n,o))return-1;let l=s.coordsAt(r,1);return l&&zn(i,n,l)?1:o&&Wn(n,o)?-1:1}function qn(t,e){let i=t.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:i,bias:Fn(t,i,e.clientX,e.clientY)}}const _n=qe.ie&&qe.ie_version<=11;let Kn=null,jn=0,$n=0;function Un(t){if(!_n)return t.detail;let e=Kn,i=$n;return Kn=t,$n=Date.now(),jn=!e||i>Date.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(jn+1)%3:1}function Gn(t,e,i,n){if(!i)return;let s=t.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:r}=t.inputState,o=n&&r&&function(t,e){let i=t.state.facet(Pi);return i.length?i[0](e):qe.mac?!e.altKey:!e.ctrlKey}(t,e)?{from:r.from,to:r.to}:null,l={from:s,insert:i},h=t.state.changes(o?[o,l]:l);t.focus(),t.dispatch({changes:h,selection:{anchor:h.mapPos(s,-1),head:h.mapPos(s,1)},userEvent:o?"move.drop":"input.drop"}),t.inputState.draggedContent=null}Ln.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=P.range(t,e))}}let{inputState:n}=t;return n.mouseSelection&&(n.mouseSelection.dragging=!0),n.draggedContent=i,e.dataTransfer&&(e.dataTransfer.setData("Text",t.state.sliceDoc(i.from,i.to)),e.dataTransfer.effectAllowed="copyMove"),!1},Ln.dragend=t=>(t.inputState.draggedContent=null,!1),Ln.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,r=()=>{++s==i.length&&Gn(t,e,n.filter((t=>null!=t)).join(t.state.lineBreak),!1)};for(let t=0;t{/[\x00-\x08\x0e-\x1f]{2}/.test(e.result)||(n[t]=e.result),r()},e.readAsText(i[t])}return!0}{let i=e.dataTransfer.getData("Text");if(i)return Gn(t,e,i,!0),!0}return!1},Ln.paste=(t,e)=>{if(t.state.readOnly)return!0;t.observer.flush();let i=In?null:e.clipboardData;return i?(Vn(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(),Vn(t,i.value)}),50)}(t),!1)};let Jn=null;Ln.copy=Ln.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 r=t.doc.lineAt(n);r.number>s&&(e.push(r.text),i.push({from:r.from,to:Math.min(t.doc.length,r.to+1)})),s=r.number}n=!0}return{text:e.join(t.lineBreak),ranges:i,linewise:n}}(t.state);if(!i&&!s)return!1;Jn=s?i:null,"cut"!=e.type||t.state.readOnly||t.dispatch({changes:n,scrollIntoView:!0,userEvent:"delete.cut"});let r=In?null:e.clipboardData;return r?(r.clearData(),r.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 Yn=at.define();function Xn(t,e){let i=[];for(let n of t.facet(Hi)){let s=n(t,e);s&&i.push(s)}return i?t.update({effects:i,annotations:Yn.of(!0)}):null}function Qn(t){setTimeout((()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let i=Xn(t.state,e);i?t.dispatch(i):t.update([])}}),10)}Nn.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),Qn(t)},Nn.blur=t=>{t.observer.clearSelectionRange(),Qn(t)},Nn.compositionstart=Nn.compositionupdate=t=>{null==t.inputState.compositionFirstChange&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0)},Nn.compositionend=t=>{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,qe.chrome&&qe.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then((()=>t.observer.flush())):setTimeout((()=>{t.inputState.composing<0&&t.docView.hasComposition&&t.update([])}),50)},Nn.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()},Ln.beforeinput=(t,e)=>{var i;let n;if(qe.chrome&&qe.android&&(n=Tn.find((t=>t.inputType==e.inputType)))&&(t.observer.delayAndroidKey(n.key,n.keyCode),"Backspace"==n.key||"Delete"==n.key)){let e=(null===(i=window.visualViewport)||void 0===i?void 0:i.height)||0;setTimeout((()=>{var i;((null===(i=window.visualViewport)||void 0===i?void 0:i.height)||0)>e+10&&t.hasFocus&&(t.contentDOM.blur(),t.focus())}),100)}return qe.ios&&"deleteContentForward"==e.inputType&&t.observer.flushSoon(),qe.safari&&"insertText"==e.inputType&&t.inputState.composing>=0&&setTimeout((()=>Nn.compositionend(t,e)),20),!1};const Zn=new Set;const ts=["pre-wrap","normal","pre-line","break-spaces"];class es{constructor(e){this.lineWrapping=e,this.doc=t.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30,this.heightChanged=!1}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)/(this.lineLength-5))))*this.lineHeight}setDoc(t){return this.doc=t,this}mustRefreshForWrapping(t){return ts.indexOf(t)>-1!=this.lineWrapping}mustRefreshForHeights(t){let e=!1;for(let i=0;i-1,l=Math.round(e)!=Math.round(this.lineHeight)||this.lineWrapping!=o;if(this.lineWrapping=o,this.lineHeight=e,this.charWidth=i,this.textHeight=n,this.lineLength=s,l){this.heightSamples={};for(let t=0;t0}set outdated(t){this.flags=(t?2:0)|-3&this.flags}setHeight(t,e){this.height!=e&&(Math.abs(this.height-e)>rs&&(t.heightChanged=!0),this.height=e)}replace(t,e,i){return os.of(i)}decomposeLeft(t,e){e.push(this)}decomposeRight(t,e){e.push(this)}applyChanges(t,e,i,n){let s=this,r=i.doc;for(let o=n.length-1;o>=0;o--){let{fromA:l,toA:h,fromB:a,toB:c}=n[o],u=s.lineAt(l,ss.ByPosNoHeight,i.setDoc(e),0,0),f=u.to>=h?u:s.lineAt(h,ss.ByPosNoHeight,i,0,0);for(c+=f.to-h,h=f.to;o>0&&u.from<=n[o-1].toA;)l=n[o-1].fromA,a=n[o-1].fromB,o--,l2*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&&r(this.blockAt(0,i,n,s))}updateHeight(t,e=0,i=!1,n){return n&&n.from<=e&&n.more&&this.setHeight(t,n.heights[n.index++]),this.outdated=!1,this}toString(){return`block(${this.length})`}}class hs extends ls{constructor(t,e){super(t,e,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(t,e,i,n){return new ns(n,this.length,i,this.height,this.breaks)}replace(t,e,i){let n=i[0];return 1==i.length&&(n instanceof hs||n instanceof as&&4&n.flags)&&Math.abs(this.length-n.length)<10?(n instanceof as?n=new hs(n.length,this.height):n.height=this.height,this.outdated||(n.outdated=!1),n):os.of(i)}updateHeight(t,e=0,i=!1,n){return n&&n.from<=e&&n.more?this.setHeight(t,n.heights[n.index++]):(i||this.outdated)&&this.setHeight(t,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 as extends os{constructor(t){super(t,0)}heightMetrics(t,e){let i,n=t.doc.lineAt(e).number,s=t.doc.lineAt(e+this.length).number,r=s-n+1,o=0;if(t.lineWrapping){let e=Math.min(this.height,t.lineHeight*r);i=e/r,this.length>r+1&&(o=(this.height-e)/(this.length-r-1))}else i=this.height/r;return{firstLine:n,lastLine:s,perLine:i,perChar:o}}blockAt(t,e,i,n){let{firstLine:s,lastLine:r,perLine:o,perChar:l}=this.heightMetrics(e,n);if(e.lineWrapping){let s=n+(t0){let t=i[i.length-1];t instanceof as?i[i.length-1]=new as(t.length+n):i.push(null,new as(n-1))}if(t>0){let e=i[0];e instanceof as?i[0]=new as(t+e.length):i.unshift(new as(t-1),null)}return os.of(i)}decomposeLeft(t,e){e.push(new as(t-1),null)}decomposeRight(t,e){e.push(null,new as(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=[],r=Math.max(e,n.from),o=-1;for(n.from>e&&i.push(new as(n.from-e-1).updateHeight(t,e));r<=s&&n.more;){let e=t.doc.lineAt(r).length;i.length&&i.push(null);let s=n.heights[n.index++];-1==o?o=s:Math.abs(s-o)>=rs&&(o=-2);let l=new hs(e,s);l.outdated=!1,i.push(l),r+=e+1}r<=s&&i.push(null,new as(s-r).updateHeight(t,r));let l=os.of(i);return(o<0||Math.abs(l.height-this.height)>=rs||Math.abs(o-this.heightMetrics(t,e).perLine)>=rs)&&(t.heightChanged=!0),l}return(i||this.outdated)&&(this.setHeight(t,t.heightForGap(e,e+this.length)),this.outdated=!1),this}toString(){return`gap(${this.length})`}}class cs extends os{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 to))return h;let a=e==ss.ByPosNoHeight?ss.ByPosNoHeight:ss.ByPos;return l?h.join(this.right.lineAt(o,a,i,r,o)):this.left.lineAt(o,a,i,n,s).join(h)}forEachLine(t,e,i,n,s,r){let o=n+this.left.height,l=s+this.left.length+this.break;if(this.break)t=l&&this.right.forEachLine(t,e,i,o,l,r);else{let h=this.lineAt(l,ss.ByPos,i,n,s);t=t&&h.from<=e&&r(h),e>h.to&&this.right.forEachLine(h.to+1,e,i,o,l,r)}}replace(t,e,i){let n=this.left.length+this.break;if(ethis.left.length)return this.balanced(this.left,this.right.replace(t-n,e-n,i));let s=[];t>0&&this.decomposeLeft(t,s);let r=s.length;for(let t of i)s.push(t);if(t>0&&us(s,r-1),e=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);t2*e.size||e.size>2*t.size?os.of(this.break?[t,null,e]:[t,e]):(this.left=t,this.right=e,this.height=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:r}=this,o=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<=o+r.length&&n.more?l=r=r.updateHeight(t,o,i,n):r.updateHeight(t,o,i),l?this.balanced(s,r):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function us(t,e){let i,n;null==t[e]&&(i=t[e-1])instanceof as&&(n=t[e+1])instanceof as&&t.splice(e-1,3,new as(i.length+1+n.length))}class fs{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 hs?i.length+=t-this.pos:(t>this.pos||!this.isCovered)&&this.nodes.push(new hs(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=5)&&this.addLineDeco(n,s,r)}else e>t&&this.span(t,e);this.lineEnd>-1&&this.lineEnd-1)return;let{from:t,to:e}=this.oracle.doc.lineAt(this.pos);this.lineStart=t,this.lineEnd=e,this.writtenTot&&this.nodes.push(new hs(this.pos-t,-1)),this.writtenTo=this.pos}blankContent(t,e){let i=new as(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 hs)return t;let e=new hs(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 hs||this.isCovered?(this.writtenToi.clientHeight||i.scrollWidth>i.clientWidth)&&"visible"!=n.overflow){let n=i.getBoundingClientRect();r=Math.max(r,n.left),o=Math.min(o,n.right),l=Math.max(l,n.top),h=e==t.parentNode?n.bottom:Math.min(h,n.bottom)}e="absolute"==n.position||"fixed"==n.position?i.offsetParent:i.parentNode}else{if(11!=e.nodeType)break;e=e.host}return{left:r-i.left,right:Math.max(r,o)-i.left,top:l-(i.top+e),bottom:Math.max(l,h)-(i.top+e)}}function gs(t,e){let i=t.getBoundingClientRect();return{left:0,right:i.right-i.left,top:e,bottom:i.bottom-(i.top+e)}}class ms{constructor(t,e,i){this.from=t,this.to=e,this.size=i}static same(t,e){if(t.length!=e.length)return!1;for(let i=0;i"function"!=typeof t&&"cm-lineWrapping"==t.class));this.heightOracle=new es(i),this.stateDeco=e.facet(Qi).filter((t=>"function"!=typeof t)),this.heightMap=os.empty().applyChanges(this.stateDeco,t.empty,this.heightOracle.setDoc(e.doc),[new ln(0,0,0,e.doc.length)]),this.viewport=this.getViewport(0,null),this.updateViewportLines(),this.updateForViewport(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=ri.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 ys(e,i))}}this.viewports=t.sort(((t,e)=>t.from-e.from)),this.scaler=this.heightMap.height<=7e6?Ss:new As(this.heightOracle,this.heightMap,this.viewports)}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,(t=>{this.viewportLines.push(1==this.scaler.scale?t:Ms(t,this.scaler))}))}update(t,e=null){this.state=t.state;let i=this.stateDeco;this.stateDeco=this.state.facet(Qi).filter((t=>"function"!=typeof t));let n=t.changedRanges,s=ln.extendWithRanges(n,function(t,e,i){let n=new ds;return Et.compare(t,e,i,n,0),n.changes}(i,this.stateDeco,t?t.changes:M.empty(this.state.doc.length))),r=this.heightMap.height,o=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);this.heightMap=this.heightMap.applyChanges(this.stateDeco,t.startState.doc,this.heightOracle.setDoc(this.state.doc),s),this.heightMap.height!=r&&(t.flags|=2),o?(this.scrollAnchorPos=t.changes.mapPos(o.from,-1),this.scrollAnchorHeight=o.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=this.heightMap.height);let l=s.length?this.mapViewport(this.viewport,t.changes):this.viewport;(e&&(e.range.headl.to)||!this.viewportIsAppropriate(l))&&(l=this.getViewport(0,e));let h=!t.changes.empty||2&t.flags||l.from!=this.viewport.from||l.to!=this.viewport.to;this.viewport=l,this.updateForViewport(),h&&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(),e&&(this.scrollTarget=e),!this.mustEnforceCursorAssoc&&t.selectionSet&&t.view.lineWrapping&&t.state.selection.main.empty&&t.state.selection.main.assoc&&!t.state.facet(zi)&&(this.mustEnforceCursorAssoc=!0)}measure(e){let i=e.contentDOM,n=window.getComputedStyle(i),s=this.heightOracle,r=n.whiteSpace;this.defaultTextDirection="rtl"==n.direction?exports.Direction.RTL:exports.Direction.LTR;let o=this.heightOracle.mustRefreshForWrapping(r),l=i.getBoundingClientRect(),h=o||this.mustMeasureContent||this.contentDOMHeight!=l.height;this.contentDOMHeight=l.height,this.mustMeasureContent=!1;let a=0,c=0;if(l.width&&l.height){let{scaleX:t,scaleY:e}=de(i,l);(t>.005&&Math.abs(this.scaleX-t)>.005||e>.005&&Math.abs(this.scaleY-e)>.005)&&(this.scaleX=t,this.scaleY=e,a|=8,o=h=!0)}let u=(parseInt(n.paddingTop)||0)*this.scaleY,f=(parseInt(n.paddingBottom)||0)*this.scaleY;this.paddingTop==u&&this.paddingBottom==f||(this.paddingTop=u,this.paddingBottom=f,a|=10),this.editorWidth!=e.scrollDOM.clientWidth&&(s.lineWrapping&&(h=!0),this.editorWidth=e.scrollDOM.clientWidth,a|=8);let d=e.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=d&&(this.scrollAnchorHeight=-1,this.scrollTop=d),this.scrolledToBottom=xe(e.scrollDOM);let p=(this.printing?gs:ps)(i,this.paddingTop),g=p.top-this.pixelViewport.top,m=p.bottom-this.pixelViewport.bottom;this.pixelViewport=p;let v=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(v!=this.inView&&(this.inView=v,v&&(h=!0)),!this.inView&&!this.scrollTarget)return 0;let w=l.width;if(this.contentDOMWidth==w&&this.editorHeight==e.scrollDOM.clientHeight||(this.contentDOMWidth=l.width,this.editorHeight=e.scrollDOM.clientHeight,a|=8),h){let i=e.docView.measureVisibleLineHeights(this.viewport);if(s.mustRefreshForHeights(i)&&(o=!0),o||s.lineWrapping&&Math.abs(w-this.contentDOMWidth)>s.charWidth){let{lineHeight:t,charWidth:n,textHeight:l}=e.docView.measureTextSize();o=t>0&&s.refresh(r,t,n,l,w/n,i),o&&(e.docView.minWidth=0,a|=8)}g>0&&m>0?c=Math.max(g,m):g<0&&m<0&&(c=Math.min(g,m)),s.heightChanged=!1;for(let n of this.viewports){let r=n.from==this.viewport.from?i:e.docView.measureVisibleLineHeights(n);this.heightMap=(o?os.empty().applyChanges(this.stateDeco,t.empty,this.heightOracle,[new ln(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(s,0,o,new is(n.from,r))}s.heightChanged&&(a|=2)}let y=!this.viewportIsAppropriate(this.viewport,c)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return y&&(this.viewport=this.getViewport(c,this.scrollTarget)),this.updateForViewport(),(2&a||y)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,e)),a|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),a}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(t,e){let i=.5-Math.max(-.5,Math.min(.5,t/1e3/2)),n=this.heightMap,s=this.heightOracle,{visibleTop:r,visibleBottom:o}=this,l=new ys(n.lineAt(r-1e3*i,ss.ByHeight,s,0,0).from,n.lineAt(o+1e3*(1-i),ss.ByHeight,s,0,0).to);if(e){let{head:t}=e.range;if(tl.to){let i,r=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),o=n.lineAt(t,ss.ByPos,s,0,0);i="center"==e.y?(o.top+o.bottom)/2-r/2:"start"==e.y||"nearest"==e.y&&t=o+Math.max(10,Math.min(i,250)))&&n>r-2e3&&s>1,r=n<<1;if(this.defaultTextDirection!=exports.Direction.LTR&&!i)return[];let o=[],l=(n,r,h,a)=>{if(r-nn&&tt.from>=h.from&&t.to<=h.to&&Math.abs(t.from-n)t.frome))));if(!f){if(rt.from<=r&&t.to>=r))){let t=e.moveToLineBoundary(P.cursor(r),!1,!0).head;t>n&&(r=t)}f=new ms(n,r,this.gapSize(h,n,r,a))}o.push(f)};for(let t of this.viewportLines){if(t.lengtht.from&&l(t.from,s,t,e),ot.draw(this,this.heightOracle.lineWrapping)))))}computeVisibleRanges(){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let e=[];Et.spans(t,this.viewport.from,this.viewport.to,{span(t,i){e.push({from:t,to:i})},point(){}},20);let i=e.length!=this.visibleRanges.length||this.visibleRanges.some(((t,i)=>t.from!=e[i].from||t.to!=e[i].to));return this.visibleRanges=e,i?4:0}lineBlockAt(t){return t>=this.viewport.from&&t<=this.viewport.to&&this.viewportLines.find((e=>e.from<=t&&e.to>=t))||Ms(this.heightMap.lineAt(t,ss.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(t){return Ms(this.heightMap.lineAt(this.scaler.fromDOM(t),ss.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 Ms(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 ys{constructor(t,e){this.from=t,this.to=e}}function bs(t,e,i){let n=[],s=t,r=0;return Et.spans(i,t,e,{span(){},point(t,e){t>s&&(n.push({from:s,to:t}),r+=t-s),s=e}},20),s=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],r=s-i;if(n<=r)return i+n;n-=r}}function ks(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 Ss={toDOM:t=>t,fromDOM:t=>t,scale:1};class As{constructor(t,e,i){let n=0,s=0,r=0;this.viewports=i.map((({from:i,to:s})=>{let r=e.lineAt(i,ss.ByPos,t,0,0).top,o=e.lineAt(s,ss.ByPos,t,0,0).bottom;return n+=o-r,{from:i,to:s,top:r,bottom:o,domTop:0,domBottom:0}})),this.scale=(7e6-n)/(e.height-n);for(let t of this.viewports)t.domTop=r+(t.top-s)*this.scale,r=t.domBottom=t.domTop+(t.bottom-t.top),s=t.bottom}toDOM(t){for(let e=0,i=0,n=0;;e++){let s=eMs(t,e))):t._content)}const Cs=I.define({combine:t=>t.join(" ")}),Ds=I.define({combine:t=>t.indexOf(!0)>-1}),Os=Ut.newName(),Ts=Ut.newName(),Es=Ut.newName(),Rs={"&light":"."+Ts,"&dark":"."+Es};function Bs(t,e,i){return new Ut(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 Ps=Bs("."+Os,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0},".cm-content":{margin:0,flexGrow:2,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:"#444"},".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",insetInlineStart:0,zIndex:200},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",borderRight:"1px solid #ddd"},"&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},"&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-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"},".cm-highlightSpace:before":{content:"attr(data-display)",position:"absolute",pointerEvents:"none",color:"#888"},".cm-highlightTab":{backgroundImage:'url(\'data:image/svg+xml,\')',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"}},Rs),Ls="￿";class Ns{constructor(t,e){this.points=t,this.text="",this.lineSeparator=e.facet(At.lineSeparator)}append(t){this.text+=t}lineBreak(){this.text+=Ls}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 r=Ce.get(n),o=Ce.get(s);(r&&o?r.breakAfter:(r?r.breakAfter:he(n))||he(s)&&("BR"!=n.nodeName||n.cmIgnore)&&this.text.length>t)&&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,r=-1,o=1;if(this.lineSeparator?(r=e.indexOf(this.lineSeparator,i),o=this.lineSeparator.length):(s=n.exec(e))&&(r=s.index,o=s[0].length),this.append(e.slice(i,r<0?e.length:r)),r<0)break;if(this.lineBreak(),o>1)for(let e of this.points)e.node==t&&e.pos>this.text.length&&(e.pos-=o-1);i=r+o}}readNode(t){if(t.cmIgnore)return;let e=Ce.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+(Is(t,i.node,i.offset)?e:0))}}function Is(t,e,i){for(;;){if(!e||i-1)this.newSel=null;else if(e>-1&&(this.bounds=t.docView.domBoundsAround(e,i,0))){let e=s||r?[]:function(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:i,anchorOffset:n,focusNode:s,focusOffset:r}=t.observer.selectionRange;i&&(e.push(new Vs(i,n)),s==i&&r==n||e.push(new Vs(s,r)));return e}(t),i=new Ns(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?P.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||!ne(t.contentDOM,e.focusNode)?t.state.selection.main.head:t.docView.posFromDOM(e.focusNode,e.focusOffset),n=r&&r.node==e.anchorNode&&r.offset==e.anchorOffset||!ne(t.contentDOM,e.anchorNode)?t.state.selection.main.anchor:t.docView.posFromDOM(e.anchorNode,e.anchorOffset),o=t.viewport;if((qe.ios||qe.chrome)&&t.state.selection.main.empty&&i!=n&&(o.from>0||o.toDate.now()-100?e.inputState.lastKeyCode:-1;if(i.bounds){let{from:s,to:l}=i.bounds,h=r.from,a=null;(8===o||qe.android&&i.text.length0&&l>0&&t.charCodeAt(o-1)==e.charCodeAt(l-1);)o--,l--;if("end"==n){i-=o+Math.max(0,r-Math.min(o,l))-r}if(o=o?r-i:0,l=r+(l-o),o=r}else if(l=l?r-i:0,o=r+(o-l),l=r}return{from:r,toA:o,toB:l}}(e.state.doc.sliceString(s,l,Ls),i.text,h-s,a);c&&(qe.chrome&&13==o&&c.toB==c.from+2&&i.text.slice(c.from,c.toB)==Ls+Ls&&c.toB--,n={from:s+c.from,to:s+c.toA,insert:t.of(i.text.slice(c.from,c.toB).split(Ls))})}else s&&(!e.hasFocus&&e.state.facet(ji)||s.main.eq(r))&&(s=null);if(!n&&!s)return!1;if(!n&&i.typeOver&&!r.empty&&s&&s.main.empty?n={from:r.from,to:r.to,insert:e.state.doc.slice(r.from,r.to)}:n&&n.from>=r.from&&n.to<=r.to&&(n.from!=r.from||n.to!=r.to)&&r.to-r.from-(n.to-n.from)<=4?n={from:r.from,to:r.to,insert:e.state.doc.slice(r.from,n.from).append(n.insert).append(e.state.doc.slice(n.to,r.to))}:(qe.mac||qe.android)&&n&&n.from==n.to&&n.from==r.head-1&&/^\. ?$/.test(n.insert.toString())&&"off"==e.contentDOM.getAttribute("autocorrect")?(s&&2==n.insert.length&&(s=P.single(s.main.anchor-1,s.main.head-1)),n={from:r.from,to:r.to,insert:t.of([" "])}):qe.chrome&&n&&n.from==n.to&&n.from==r.head&&"\n "==n.insert.toString()&&e.lineWrapping&&(s&&(s=P.single(s.main.anchor-1,s.main.head-1)),n={from:r.from,to:r.to,insert:t.of([" "])}),n){if(qe.ios&&e.inputState.flushIOSKey(n))return!0;if(qe.android&&(n.to==r.to&&(n.from==r.from||n.from==r.from-1&&" "==e.state.sliceDoc(n.from,r.from))&&1==n.insert.length&&2==n.insert.lines&&ye(e.contentDOM,"Enter",13)||(n.from==r.from-1&&n.to==r.to&&0==n.insert.length||8==o&&n.insert.lengthr.head)&&ye(e.contentDOM,"Backspace",8)||n.from==r.from&&n.to==r.to+1&&0==n.insert.length&&ye(e.contentDOM,"Delete",46)))return!0;let t,i=n.insert.toString();e.inputState.composing>=0&&e.inputState.composing++;let l=()=>t||(t=function(t,e,i){let n,s=t.state,r=s.selection.main;if(e.from>=r.from&&e.to<=r.to&&e.to-e.from>=(r.to-r.from)/3&&(!i||i.main.empty&&i.main.from==e.from+e.insert.length)&&t.inputState.composing<0){let i=r.frome.to?s.sliceDoc(e.to,r.to):"";n=s.replaceSelection(t.state.toText(i+e.insert.sliceString(0,void 0,t.state.lineBreak)+o))}else{let o=s.changes(e),l=i&&i.main.to<=o.newLength?i.main:void 0;if(s.selection.ranges.length>1&&t.inputState.composing>=0&&e.to<=r.to&&e.to>=r.to-10){let h,a=t.state.sliceDoc(e.from,e.to),c=i&&un(t,i.main.head);if(c){let t=e.insert.length-(e.to-e.from);h={from:c.from,to:c.to-t}}else h=t.state.doc.lineAt(r.head);let u=r.to-e.to,f=r.to-r.from;n=s.changeByRange((i=>{if(i.from==r.from&&i.to==r.to)return{changes:o,range:l||i.map(o)};let n=i.to-u,c=n-a.length;if(i.to-i.from!=f||t.state.sliceDoc(c,n)!=a||i.to>=h.from&&i.from<=h.to)return{range:i};let d=s.changes({from:c,to:n,insert:e.insert}),p=i.to-r.to;return{changes:d,range:l?P.range(Math.max(0,l.anchor+p),Math.max(0,l.head+p)):i.map(d)}}))}else n={changes:o,selection:l&&s.selection.replaceRange(l)}}let o="input.type";(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,o+=".compose",t.inputState.compositionFirstChange&&(o+=".start",t.inputState.compositionFirstChange=!1));return s.update(n,{userEvent:o,scrollIntoView:!0})}(e,n,s));return e.state.facet(Vi).some((t=>t(e,n.from,n.to,i,l)))||e.dispatch(l()),!0}if(s&&!s.main.eq(r)){let t=!1,i="select";return e.inputState.lastSelectionTime>Date.now()-50&&("select"==e.inputState.lastSelectionOrigin&&(t=!0),i=e.inputState.lastSelectionOrigin),e.dispatch({selection:s,scrollIntoView:t,userEvent:i}),!0}return!1}const zs={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Fs=qe.ie&&qe.ie_version<=11;class qs{constructor(t){this.view=t,this.active=!1,this.selectionRange=new pe,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);(qe.ie&&qe.ie_version<=11||qe.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()})),Fs&&(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){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.onScrollChanged(t)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout((()=>{this.resizeTimeout=-1,this.view.requestMeasure()}),50))}onPrint(t){("change"!=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(ji)?i.root.activeElement!=this.dom:!se(i.dom,n))return;let s=n.anchorNode&&i.docView.nearest(n.anchorNode);s&&s.ignoreEvent(t)?e||(this.selectionChanged=!1):(qe.ie&&qe.ie_version<=11||qe.android&&qe.chrome)&&!i.state.selection.main.empty&&n.focusNode&&oe(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:t}=this,e=ie(t.root);if(!e)return!1;let i=qe.safari&&11==t.root.nodeType&&function(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}(this.dom.ownerDocument)==this.dom&&function(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return Ks(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?Ks(t,i):null}(this.view,e)||e;if(!i||this.selectionRange.eq(i))return!1;let n=se(this.dom,i);return n&&!this.selectionChanged&&t.inputState.lastFocusTime>Date.now()-200&&t.inputState.lastTouchTime{let t=this.delayedAndroidKey;if(t){this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=t.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&t.force&&ye(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{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&&se(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 Hs(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=Ws(this.view,e);return this.view.state==i&&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=_s(e,t.previousSibling||t.target.previousSibling,-1),n=_s(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("change",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("change",this.onPrint):t.removeEventListener("beforeprint",this.onPrint),t.document.removeEventListener("selectionchange",this.onSelectionChange)}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)}}function _s(t,e,i){for(;e;){let n=Ce.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 Ks(t,e){let i=e.startContainer,n=e.startOffset,s=e.endContainer,r=e.endOffset,o=t.docView.domAtPos(t.state.selection.main.anchor);return oe(o.node,o.offset,s,r)&&([i,n,s,r]=[s,r,i,n]),{anchorNode:i,anchorOffset:n,focusNode:s,focusOffset:r}}class js{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return this.inputState.composing>0}get compositionStarted(){return this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(t={}){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:e}=t;this.dispatchTransactions=t.dispatchTransactions||e&&(t=>t.forEach((t=>e(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 ws(t.state||At.create(t)),t.scrollTo&&t.scrollTo.is(_i)&&(this.viewState.scrollTarget=t.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Ui).map((t=>new Ji(t)));for(let t of this.plugins)t.update(this);this.observer=new qs(this),this.inputState=new Cn(this),this.inputState.ensureHandlers(this.plugins),this.docView=new an(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure()}dispatch(...t){let e=1==t.length&&t[0]instanceof dt?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 r=this.hasFocus,o=0,l=null;t.some((t=>t.annotation(Yn)))?(this.inputState.notifiedFocused=r,o=1):r!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=r,l=Xn(s,r),l||(o=1));let h=this.observer.delayedAndroidKey,a=null;if(h?(this.observer.clearDelayedAndroidKey(),a=this.observer.readChange(),(a&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(a=null)):this.observer.clear(),s.facet(At.phrases)!=this.state.facet(At.phrases))return this.setState(s);e=hn.create(this,s,t),e.flags|=o;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 qi(t.empty?t:P.cursor(t.head,t.head>t.anchor?-1:1))}for(let t of e.effects)t.is(_i)&&(c=t.value.clip(this.state))}this.viewState.update(e,c),this.bidiCache=Gs.update(this.bidiCache,e.changes),e.empty||(this.updatePlugins(e),this.inputState.update(e)),i=this.docView.update(e),this.state.facet(on)!=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(Cs)!=e.state.facet(Cs)&&(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(Ii))try{t(e)}catch(t){Ki(this.state,t,"update listener")}(l||a)&&Promise.resolve().then((()=>{l&&this.state==l.startState&&this.dispatch(l),a&&!Ws(this,a)&&h.force&&ye(this.contentDOM,h.key,h.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 ws(t),this.plugins=t.facet(Ui).map((t=>new Ji(t))),this.pluginMap.clear();for(let t of this.plugins)t.update(this);this.docView.destroy(),this.docView=new an(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(Ui),i=t.state.facet(Ui);if(e!=i){let n=[];for(let s of i){let i=e.indexOf(s);if(i<0)n.push(new Ji(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-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:r}=this.viewState;Math.abs(n-this.viewState.scrollTop)>1&&(r=-1),this.viewState.scrollAnchorHeight=-1;try{for(let t=0;;t++){if(r<0)if(xe(i))s=-1,r=this.viewState.heightMap.height;else{let t=this.viewState.scrollAnchorAt(n);s=t.from,r=t.top}this.updateState=1;let o=this.viewState.measure(this);if(!o&&!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&o||([this.measureRequests,l]=[l,this.measureRequests]);let h=l.map((t=>{try{return t.read(this)}catch(t){return Ki(this.state,t),Us}})),a=hn.create(this,this.state,[]),c=!1;a.flags|=o,e?e.flags|=o:e=a,this.updateState=2,a.empty||(this.updatePlugins(a),this.inputState.update(a),this.updateAttrs(),c=this.docView.update(a),c&&this.docViewUpdate());for(let t=0;t1||t<-1){n+=t,i.scrollTop=n/this.scaleY,r=-1;continue}}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(e&&!e.empty)for(let t of this.state.facet(Ii))t(e)}get themeClasses(){return Os+" "+(this.state.facet(Ds)?Es:Ts)+" "+this.state.facet(Cs)}updateAttrs(){let t=Js(this,Yi,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),e={spellcheck:"false",autocorrect:"off",autocapitalize:"off",translate:"no",contenteditable:this.state.facet(ji)?"true":"false",class:"cm-content",style:`${qe.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(e["aria-readonly"]="true"),Js(this,Xi,e);let i=this.observer.ignore((()=>{let i=Ze(this.contentDOM,this.contentAttrs,e),n=Ze(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(js.announce)){e&&(this.announceDOM.textContent=""),e=!1,this.announceDOM.appendChild(document.createElement("div")).textContent=t.value}}mountStyles(){this.styleModules=this.state.facet(on);let t=this.state.facet(js.cspNonce);Ut.mount(this.root,this.styleModules.concat(Ps).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;ee.spec==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 Mn(this,t,Sn(this,t,e,i))}moveByGroup(t,e){return Mn(this,t,Sn(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==bt.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 P.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=kn(t,e.head),r=n&&s.type==si.Text&&(t.lineWrapping||s.widgetLineBreaks)?t.coordsAtPos(e.assoc<0&&e.head>s.from?e.head-1:e.head):null;if(r){let e=t.dom.getBoundingClientRect(),n=t.textDirectionAt(s.from),o=t.posAtCoords({x:i==(n==exports.Direction.LTR)?e.right-1:e.left+1,y:(r.top+r.bottom)/2});if(null!=o)return P.cursor(o,i?-1:1)}return P.cursor(i?s.to:s.from,i?-1:1)}(this,t,e,i)}moveVertically(t,e,i){return Mn(this,t,function(t,e,i,n){let s=e.head,r=i?1:-1;if(s==(i?t.state.doc.length:0))return P.cursor(s,e.assoc);let o,l=e.goalColumn,h=t.contentDOM.getBoundingClientRect(),a=t.coordsAtPos(s,e.assoc||-1),c=t.documentTop;if(a)null==l&&(l=a.left-h.left),o=r<0?a.top:a.bottom;else{let e=t.viewState.lineBlockAt(s);null==l&&(l=Math.min(h.right-h.left,t.defaultCharacterWidth*(s-e.from))),o=(r<0?e.top:e.bottom)+c}let u=h.left+l,f=null!=n?n:t.viewState.heightOracle.textHeight>>1;for(let e=0;;e+=10){let i=o+(f+e)*r,n=bn(t,{x:u,y:i},!1,r);if(ih.bottom||(r<0?ns)){let e=t.docView.coordsForChar(n),s=!e||i0)}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(Wi)||tthis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(t))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(t){if(t.length>$s)return Oi(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||Ai(n.isolates,e=nn(this,t))))return n.order;e||(e=nn(this,t));let n=function(t,e,i){if(!t)return[new Si(0,0,e==gi?1:0)];if(e==pi&&!i.length&&!ki.test(t))return Oi(t.length);if(i.length)for(;t.length>Mi.length;)Mi[Mi.length]=256;let n=[],s=e==pi?0:1;return Di(t,s,s,i,0,t.length,n),n}(t.text,i,e);return this.bidiCache.push(new Gs(t.from,t.to,i,e,!0,n)),n}get hasFocus(){var t;return(this.dom.ownerDocument.hasFocus()||qe.safari&&(null===(t=this.inputState)||void 0===t?void 0:t.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore((()=>{ve(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(){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 _i.of(new qi("number"==typeof t?P.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 _i.of(new qi(P.cursor(i.from),"start","start",i.top-t,e,!0))}static domEventHandlers(t){return Gi.define((()=>({})),{eventHandlers:t})}static domEventObservers(t){return Gi.define((()=>({})),{eventObservers:t})}static theme(t,e){let i=Ut.newName(),n=[Cs.of(i),on.of(Bs(`.${i}`,t))];return e&&e.dark&&n.push(Ds.of(!0)),n}static baseTheme(t){return J.lowest(on.of(Bs("."+Os,t,Rs)))}static findFromDOM(t){var e;let i=t.querySelector(".cm-content"),n=i&&Ce.get(i)||Ce.get(t);return(null===(e=null==n?void 0:n.rootView)||void 0===e?void 0:e.view)||null}}js.styleModule=on,js.inputHandler=Vi,js.scrollHandler=Fi,js.focusChangeEffect=Hi,js.perLineTextDirection=Wi,js.exceptionSink=Ni,js.updateListener=Ii,js.editable=ji,js.mouseSelectionStyle=Li,js.dragMovesSelection=Pi,js.clickAddsSelectionRange=Bi,js.decorations=Qi,js.outerDecorations=Zi,js.atomicRanges=tn,js.bidiIsolatedRanges=en,js.scrollMargins=sn,js.darkTheme=Ds,js.cspNonce=I.define({combine:t=>t.length?t[0]:""}),js.contentAttributes=Xi,js.editorAttributes=Yi,js.lineWrapping=js.contentAttributes.of({class:"cm-lineWrapping"}),js.announce=ft.define();const $s=4096,Us={};class Gs{constructor(t,e,i,n,s,r){this.from=t,this.to=e,this.dir=i,this.isolates=n,this.fresh=s,this.order=r}static update(t,e){if(e.empty&&!t.some((t=>t.fresh)))return t;let i=[],n=t.length?t[t.length-1].dir:exports.Direction.LTR;for(let s=Math.max(0,t.length-10);s=0;s--){let e=n[s],r="function"==typeof e?e(t):e;r&&Ye(r,i)}return i}const Ys=qe.mac?"mac":qe.windows?"win":qe.linux?"linux":"key";function Xs(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 Qs=J.default(js.domEventHandlers({keydown:(t,e)=>sr(er(e.state),t,e,"editor")})),Zs=I.define({enables:Qs}),tr=new WeakMap;function er(t){let e=t.facet(Zs),i=tr.get(e);return i||tr.set(e,i=function(t,e=Ys){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")},r=(t,n,r,o,l)=>{var h,a;let c=i[t]||(i[t]=Object.create(null)),u=n.split(/ (?!$)/).map((t=>function(t,e){const i=t.split(/-(?!$)/);let n,s,r,o,l=i[i.length-1];"Space"==l&&(l=" ");for(let t=0;t{let n=ir={view:e,prefix:i,scope:t};return setTimeout((()=>{ir==n&&(ir=null)}),nr),!0}]})}let f=u.join(" ");s(f,!1);let d=c[f]||(c[f]={preventDefault:!1,stopPropagation:!1,run:(null===(a=null===(h=c._any)||void 0===h?void 0:h.run)||void 0===a?void 0:a.slice())||[]});r&&d.run.push(r),o&&(d.preventDefault=!0),l&&(d.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:[]});for(let e in t)t[e].run.push(n.any)}let s=n[e]||n.key;if(s)for(let e of t)r(e,s,n.run,n.preventDefault,n.stopPropagation),n.shift&&r(e,"Shift-"+s,n.shift,n.preventDefault,n.stopPropagation)}return i}(e.reduce(((t,e)=>t.concat(e)),[]))),i}let ir=null;const nr=4e3;function sr(t,e,i,n){let s=function(t){var e=!(Qt&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||Zt&&t.shiftKey&&t.key&&1==t.key.length||"Unidentified"==t.key)&&t.key||(t.shiftKey?Xt:Yt)[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),r=x(y(s,0))==s.length&&" "!=s,o="",l=!1,h=!1,a=!1;ir&&ir.view==i&&ir.scope==n&&(o=ir.prefix+" ",Rn.indexOf(e.keyCode)<0&&(h=!0,ir=null));let c,u,f=new Set,d=t=>{if(t){for(let n of t.run)if(!f.has(n)&&(f.add(n),n(i,e)))return t.stopPropagation&&(a=!0),!0;t.preventDefault&&(t.stopPropagation&&(a=!0),h=!0)}return!1},p=t[n];return p&&(d(p[o+Xs(s,e,!r)])?l=!0:r&&(e.altKey||e.metaKey||e.ctrlKey)&&!(qe.windows&&e.ctrlKey&&e.altKey)&&(c=Yt[e.keyCode])&&c!=s?(d(p[o+Xs(c,e,!0)])||e.shiftKey&&(u=Xt[e.keyCode])!=s&&u!=c&&d(p[o+Xs(u,e,!1)]))&&(l=!0):r&&e.shiftKey&&d(p[o+Xs(s,e,!0)])&&(l=!0),!l&&d(p._any)&&(l=!0)),h&&(l=!0),l&&a&&e.stopPropagation(),l}class rr{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=or(t);return[new rr(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),r=t.textDirection==exports.Direction.LTR,o=t.contentDOM,l=o.getBoundingClientRect(),h=or(t),a=o.querySelector(".cm-line"),c=a&&window.getComputedStyle(a),u=l.left+(c?parseInt(c.paddingLeft)+Math.min(0,parseInt(c.textIndent)):0),f=l.right-(c?parseInt(c.paddingRight):0),d=kn(t,n),p=kn(t,s),g=d.type==si.Text?d:null,m=p.type==si.Text?p:null;g&&(t.lineWrapping||d.widgetLineBreaks)&&(g=lr(t,n,g));m&&(t.lineWrapping||p.widgetLineBreaks)&&(m=lr(t,s,m));if(g&&m&&g.from==m.from)return w(y(i.from,i.to,g));{let e=g?y(i.from,null,g):b(d,!1),n=m?y(null,i.to,m):b(p,!0),s=[];return(g||d).to<(m||p).from-(g&&m?1:0)||d.widgetLineBreaks>1&&e.bottom+t.defaultLineHeight/2a&&n.from=r)break;l>s&&h(Math.max(t,s),null==e&&t<=a,Math.min(l,r),null==i&&l>=c,o.dir)}if(s=n.to+1,s>=r)break}return 0==l.length&&h(a,null==e,c,null==i,t.textDirection),{top:s,bottom:o,horizontal:l}}function b(t,e){let i=l.top+(e?t.top:t.bottom);return{top:i,bottom:i,horizontal:[]}}}(t,e,i)}}function or(t){let e=t.scrollDOM.getBoundingClientRect();return{left:(t.textDirection==exports.Direction.LTR?e.left:e.right-t.scrollDOM.clientWidth*t.scaleX)-t.scrollDOM.scrollLeft*t.scaleX,top:e.top-t.scrollDOM.scrollTop*t.scaleY}}function lr(t,e,i){let n=P.cursor(e);return{from:Math.max(i.from,t.moveToLineBoundary(n,!1,!0).from),to:Math.min(i.to,t.moveToLineBoundary(n,!0,!0).from),type:si.Text}}class hr{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(ar)!=t.state.facet(ar)&&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(ar);for(;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}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const ar=I.define();function cr(t){return[Gi.define((e=>new hr(e,t))),ar.of(t)]}const ur=!qe.ios,fr=I.define({combine:t=>Mt(t,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(t,e)=>Math.min(t,e),drawRangeCursor:(t,e)=>t||e})});function dr(t){return t.startState.facet(fr)!=t.state.facet(fr)}const pr=cr({above:!0,markers(t){let{state:e}=t,i=e.facet(fr),n=[];for(let s of e.selection.ranges){let r=s==e.selection.main;if(s.empty?!r||ur:i.drawRangeCursor){let e=r?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",i=s.empty?s:P.cursor(s.head,s.head>s.anchor?-1:1);for(let s of rr.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=dr(t);return i&&gr(t.state,e),t.docChanged||t.selectionSet||i},mount(t,e){gr(e.state,t)},class:"cm-cursorLayer"});function gr(t,e){e.style.animationDuration=t.facet(fr).cursorBlinkRate+"ms"}const mr=cr({above:!1,markers:t=>t.state.selection.ranges.map((e=>e.empty?[]:rr.forRange(t,"cm-selectionBackground",e))).reduce(((t,e)=>t.concat(e))),update:(t,e)=>t.docChanged||t.selectionSet||t.viewportChanged||dr(t),class:"cm-selectionLayer"}),vr={".cm-line":{"& ::selection":{backgroundColor:"transparent !important"},"&::selection":{backgroundColor:"transparent !important"}}};ur&&(vr[".cm-line"].caretColor="transparent !important",vr[".cm-content"]={caretColor:"transparent !important"});const wr=J.highest(js.theme(vr));function yr(t,e,i,n,s){e.lastIndex=0;for(let r,o=t.iterRange(i,n),l=i;!o.next().done;l+=o.value.length)if(!o.lineBreak)for(;r=e.exec(o.value);)s(l+r.index,r)}class br{constructor(t){const{regexp:e,decoration:i,decorate:n,boundary:s,maxLength:r=1e3}=t;if(!e.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=e,n)this.addMatch=(t,e,i,s)=>n(s,i,i+t[0].length,t,e);else if("function"==typeof i)this.addMatch=(t,e,n,s)=>{let r=i(t,e,n);r&&s(n,n+t[0].length,r)};else{if(!i)throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.addMatch=(t,e,n,s)=>s(n,n+t[0].length,i)}this.boundary=s,this.maxLength=r}createDeco(t){let e=new Rt,i=e.add.bind(e);for(let{from:e,to:n}of function(t,e){let i=t.visibleRanges;if(1==i.length&&i[0].from==t.viewport.from&&i[0].to==t.viewport.to)return i;let n=[];for(let{from:s,to:r}of i)s=Math.max(t.state.doc.lineAt(s).from,s-e),r=Math.min(t.state.doc.lineAt(r).to,r+e),n.length&&n[n.length-1].to>=s?n[n.length-1].to=r:n.push({from:s,to:r});return n}(t,this.maxLength))yr(t.state.doc,this.regexp,e,n,((e,n)=>this.addMatch(n,t,e,i)));return e.finish()}updateDeco(t,e){let i=1e9,n=-1;return t.docChanged&&t.changes.iterChanges(((e,s,r,o)=>{o>t.view.viewport.from&&r1e3?this.createDeco(t.view):n>-1?this.updateRange(t.view,e.map(t.changes),i,n):e}updateRange(t,e,i,n){for(let s of t.visibleRanges){let r=Math.max(s.from,i),o=Math.min(s.to,n);if(o>r){let i=t.state.doc.lineAt(r),n=i.toi.from;r--)if(this.boundary.test(i.text[r-1-i.from])){l=r;break}for(;oc.push(i.range(t,e));if(i==n)for(this.regexp.lastIndex=l-i.from;(a=this.regexp.exec(i.text))&&a.indexthis.addMatch(i,t,e,u)));e=e.update({filterFrom:l,filterTo:h,filter:(t,e)=>th,add:c})}}return e}}const xr=null!=/x/.unicode?"gu":"g",kr=new RegExp("[\0-\b\n--Ÿ­؜​‎‏\u2028\u2029‭‮⁦⁧⁩\ufeff-]",xr),Sr={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"};let Ar=null;const Mr=I.define({combine(t){let e=Mt(t,{render:null,specialChars:kr,addSpecialChars:null});return(e.replaceTabs=!function(){var t;if(null==Ar&&"undefined"!=typeof document&&document.body){let e=document.body.style;Ar=null!=(null!==(t=e.tabSize)&&void 0!==t?t:e.MozTabSize)}return Ar||!1}())&&(e.specialChars=new RegExp("\t|"+e.specialChars.source,xr)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,xr)),e}});let Cr=null;class Dr extends ni{constructor(t,e){super(),this.options=t,this.code=e}eq(t){return t.code==this.code}toDOM(t){let e=function(t){return t>=32?"•":10==t?"␤":String.fromCharCode(9216+t)}(this.code),i=t.state.phrase("Control character")+" "+(Sr[this.code]||"0x"+this.code.toString(16)),n=this.options.render&&this.options.render(this.code,i,e);if(n)return n;let s=document.createElement("span");return s.textContent=e,s.title=i,s.setAttribute("aria-label",i),s.className="cm-specialChar",s}ignoreEvent(){return!1}}class Or extends ni{constructor(t){super(),this.width=t}eq(t){return t.width==this.width}toDOM(){let t=document.createElement("span");return t.textContent="\t",t.className="cm-tab",t.style.width=this.width+"px",t}ignoreEvent(){return!1}}const Tr=2e3;function Er(t,e){let i=t.posAtCoords({x:e.clientX,y:e.clientY},!1),n=t.state.doc.lineAt(i),s=i-n.from,r=s>Tr?-1:s==n.length?function(t,e){let i=t.coordsAtPos(t.viewport.from);return i?Math.round(Math.abs((i.left-e)/t.defaultCharacterWidth)):-1}(t,e.clientX):qt(n.text,t.state.tabSize,i-n.from);return{line:n.number,col:r,off:s}}function Rr(t,e){let i=Er(t,e),n=t.state.selection;return i?{update(t){if(t.docChanged){let e=t.changes.mapPos(t.startState.doc.line(i.line).from),s=t.state.doc.lineAt(e);i={line:s.number,col:i.col,off:Math.min(i.off,s.length)},n=n.map(t.changes)}},get(e,s,r){let o=Er(t,e);if(!o)return n;let l=function(t,e,i){let n=Math.min(e.line,i.line),s=Math.max(e.line,i.line),r=[];if(e.off>Tr||i.off>Tr||e.col<0||i.col<0){let o=Math.min(e.off,i.off),l=Math.max(e.off,i.off);for(let e=n;e<=s;e++){let i=t.doc.line(e);i.length<=l&&r.push(P.range(i.from+o,i.to+l))}}else{let o=Math.min(e.col,i.col),l=Math.max(e.col,i.col);for(let e=n;e<=s;e++){let i=t.doc.line(e),n=_t(i.text,o,t.tabSize,!0);if(n<0)r.push(P.cursor(i.to));else{let e=_t(i.text,l,t.tabSize);r.push(P.range(i.from+n,i.from+e))}}}return r}(t.state,i,o);return l.length?r?P.create(l.concat(n.ranges)):P.create(l):n}}:null}const Br={Alt:[18,t=>!!t.altKey],Control:[17,t=>!!t.ctrlKey],Shift:[16,t=>!!t.shiftKey],Meta:[91,t=>!!t.metaKey]},Pr={style:"cursor: crosshair"};const Lr="-10000px";class Nr{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 r=[],o=e?[]:null;for(let i=0;ie[i]=t)),e.length=o.length),this.input=n,this.tooltips=s,this.tooltipViews=r,!0}}function Ir(t){let{win:e}=t;return{top:0,left:0,bottom:e.innerHeight,right:e.innerWidth}}const Vr=I.define({combine:t=>{var e,i,n;return{position:qe.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)||Ir}}}),Hr=new WeakMap,Wr=Gi.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(Vr);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 Nr(t,qr,((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(Vr);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=Lr,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=this.view.dom.getBoundingClientRect(),e=1,i=1,n=!1;if("fixed"==this.position&&this.manager.tooltipViews.length){let{dom:t}=this.manager.tooltipViews[0];if(qe.gecko)n=t.offsetParent!=this.container.ownerDocument.body;else if(t.style.top==Lr&&"0px"==t.style.left){let e=t.getBoundingClientRect();n=Math.abs(e.top+1e4)>1||Math.abs(e.left)>1}}if(n||"absolute"==this.position)if(this.parent){let t=this.parent.getBoundingClientRect();t.width&&t.height&&(e=t.width/this.parent.offsetWidth,i=t.height/this.parent.offsetHeight)}else({scaleX:e,scaleY:i}=this.view.viewState);return{editor:t,parent:this.parent?this.container.getBoundingClientRect():t,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(Vr).tooltipSpace(this.view),scaleX:e,scaleY:i,makeAbsolute:n}}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{editor:i,space:n,scaleX:s,scaleY:r}=t,o=[];for(let l=0;l=Math.min(i.bottom,n.bottom)||u.rightMath.min(i.right,n.right)+.1){c.style.top=Lr;continue}let d=h.arrow?a.dom.querySelector(".cm-tooltip-arrow"):null,p=d?7:0,g=f.right-f.left,m=null!==(e=Hr.get(a))&&void 0!==e?e:f.bottom-f.top,v=a.offset||Fr,w=this.view.textDirection==exports.Direction.LTR,y=f.width>n.right-n.left?w?n.left:n.right-f.width:w?Math.min(u.left-(d?14:0)+v.x,n.right-g):Math.max(n.left,u.left-g+(d?14:0)-v.x),b=this.above[l];!h.strictSide&&(b?u.top-(f.bottom-f.top)-v.yn.bottom)&&b==n.bottom-u.bottom>u.top-n.top&&(b=this.above[l]=!b);let x=(b?u.top-n.top:n.bottom-u.bottom)-p;if(xy&&t.topk&&(k=b?t.top-m-2-p:t.bottom+p+2);if("absolute"==this.position?(c.style.top=(k-t.parent.top)/r+"px",c.style.left=(y-t.parent.left)/s+"px"):(c.style.top=k/r+"px",c.style.left=y/s+"px"),d){let t=u.left+(w?v.x:-v.x)-(y+14-7);d.style.left=t/s+"px"}!0!==a.overlap&&o.push({left:y,top:k,right:S,bottom:k+m}),c.classList.toggle("cm-tooltip-above",b),c.classList.toggle("cm-tooltip-below",!b),a.positioned&&a.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=Lr}},{eventObservers:{scroll(){this.maybeMeasure()}}}),zr=js.baseTheme({".cm-tooltip":{zIndex:100,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"}}}),Fr={x:0,y:0},qr=I.define({enables:[Wr,zr]}),_r=I.define({combine(t){let e,i;for(let n of t)e=e||n.topContainer,i=i||n.bottomContainer;return{topContainer:e,bottomContainer:i}}});function Kr(t,e){let i=t.plugin(jr),n=i?i.specs.indexOf(e):-1;return n>-1?i.panels[n]:null}const jr=Gi.fromClass(class{constructor(t){this.input=t.state.facet(Gr),this.specs=this.input.filter((t=>t)),this.panels=this.specs.map((e=>e(t)));let e=t.state.facet(_r);this.top=new $r(t,!0,e.topContainer),this.bottom=new $r(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 $r(t.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new $r(t.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let i=t.state.facet(Gr);if(i!=this.input){let e=i.filter((t=>t)),n=[],s=[],r=[],o=[];for(let i of e){let e,l=this.specs.indexOf(i);l<0?(e=i(t.view),o.push(e)):(e=this.panels[l],e.update&&e.update(t)),n.push(e),(e.top?s:r).push(e)}this.specs=e,this.panels=n,this.top.sync(s),this.bottom.sync(r);for(let t of o)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=>js.scrollMargins.of((e=>{let i=e.plugin(t);return i&&{top:i.top.scrollMargin(),bottom:i.bottom.scrollMargin()}}))});class $r{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=Ur(t);t=t.nextSibling}else this.dom.insertBefore(e.dom,t);for(;t;)t=Ur(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 Ur(t){let e=t.nextSibling;return t.remove(),e}const Gr=I.define({enables:jr});class Jr extends Ct{compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}eq(t){return!1}destroy(t){}}Jr.prototype.elementClass="",Jr.prototype.toDOM=void 0,Jr.prototype.mapMode=S.TrackBefore,Jr.prototype.startSide=Jr.prototype.endSide=-1,Jr.prototype.point=!0;const Yr=I.define(),Xr=I.define(),Qr=I.define({combine:t=>t.some((t=>t))});function Zr(t){let e=[to];return t&&!1===t.fixed&&e.push(Qr.of(!0)),e}const to=Gi.fromClass(class{constructor(t){this.view=t,this.prevViewport=t.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=t.state.facet(Xr).map((e=>new so(t,e)));for(let t of this.gutters)this.dom.appendChild(t.dom);this.fixed=!t.state.facet(Qr),this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),t.scrollDOM.insertBefore(this.dom,t.contentDOM)}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))}t.geometryChanged&&(this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px"),this.view.state.facet(Qr)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":""),this.prevViewport=t.view.viewport}syncGutters(t){let e=this.dom.nextSibling;t&&this.dom.remove();let i=Et.iter(this.view.state.facet(Yr),this.view.viewport.from),n=[],s=this.gutters.map((t=>new no(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 r of t.type)if(r.type==si.Text&&e){io(i,n,r.from);for(let t of s)t.line(this.view,r,n);e=!1}else if(r.widget)for(let t of s)t.widget(this.view,r)}else if(t.type==si.Text){io(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)}updateGutters(t){let e=t.startState.facet(Xr),i=t.state.facet(Xr),n=t.docChanged||t.heightChanged||t.viewportChanged||!Et.eq(t.startState.facet(Yr),t.state.facet(Yr),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 so(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)this.dom.appendChild(t.dom);this.gutters=s}return n}destroy(){for(let t of this.gutters)t.destroy();this.dom.remove()}},{provide:t=>js.scrollMargins.of((e=>{let i=e.plugin(t);return i&&0!=i.gutters.length&&i.fixed?e.textDirection==exports.Direction.LTR?{left:i.dom.offsetWidth*e.scaleX}:{right:i.dom.offsetWidth*e.scaleX}:null}))});function eo(t){return Array.isArray(t)?t:[t]}function io(t,e,i){for(;t.value&&t.from<=i;)t.from==i&&e.push(t.value),t.next()}class no{constructor(t,e,i){this.gutter=t,this.height=i,this.i=0,this.cursor=Et.iter(t.markers,e.from)}addElement(t,e,i){let{gutter:n}=this,s=(e.top-this.height)/t.scaleY,r=e.height/t.scaleY;if(this.i==n.elements.length){let e=new ro(t,r,s,i);n.elements.push(e),n.dom.appendChild(e.dom)}else n.elements[this.i].update(t,r,s,i);this.height=e.bottom,this.i++}line(t,e,i){let n=[];io(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 r=this.gutter;(0!=n.length||r.config.renderEmptyElements)&&this.addElement(t,e,n)}widget(t,e){let i=this.gutter.config.widgetMarker(t,e.widget,e);i&&this.addElement(t,e,[i])}finish(){let t=this.gutter;for(;t.elements.length>this.i;){let e=t.elements.pop();t.dom.removeChild(e.dom),e.destroy()}}}class so{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,r=n.target;if(r!=this.dom&&this.dom.contains(r)){for(;r.parentNode!=this.dom;)r=r.parentNode;let t=r.getBoundingClientRect();s=(t.top+t.bottom)/2}else s=n.clientY;let o=t.lineBlockAtHeight(s-t.documentTop);e.domEventHandlers[i](t,o,n)&&n.preventDefault()}));this.markers=eo(e.markers(t)),e.initialSpacer&&(this.spacer=new ro(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=eo(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!Et.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 ro{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;iMt(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 ho extends Jr{constructor(t){super(),this.number=t}eq(t){return this.number==t.number}toDOM(){return document.createTextNode(this.number)}}function ao(t,e){return t.state.facet(lo).formatNumber(e,t.state)}const co=Xr.compute([lo],(t=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers:t=>t.state.facet(oo),lineMarker:(t,e,i)=>i.some((t=>t.toDOM))?null:new ho(ao(t,t.state.doc.lineAt(e.from).number)),widgetMarker:()=>null,lineMarkerChange:t=>t.startState.facet(lo)!=t.state.facet(lo),initialSpacer:t=>new ho(ao(t,uo(t.state.doc.lines))),updateSpacer(t,e){let i=ao(e.view,uo(e.view.state.doc.lines));return i==t.number?t:new ho(i)},domEventHandlers:t.facet(lo).domEventHandlers})));function uo(t){let e=9;for(;e{throw new Error("This node type doesn't define a deserialize function")})}add(t){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return"function"!=typeof t&&(t=yo.match(t)),e=>{let i=t(e);return void 0===i?null:[this,i]}}}mo.closedBy=new mo({deserialize:t=>t.split(" ")}),mo.openedBy=new mo({deserialize:t=>t.split(" ")}),mo.group=new mo({deserialize:t=>t.split(" ")}),mo.isolate=new mo({deserialize:t=>{if(t&&"rtl"!=t&&"ltr"!=t&&"auto"!=t)throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}}),mo.contextHash=new mo({perNode:!0}),mo.lookAhead=new mo({perNode:!0}),mo.mounted=new mo({perNode:!0});class vo{constructor(t,e,i){this.tree=t,this.overlay=e,this.parser=i}static get(t){return t&&t.props&&t.props[mo.mounted.id]}}const wo=Object.create(null);class yo{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):wo,i=(t.top?1:0)|(t.skipped?2:0)|(t.error?4:0)|(null==t.name?8:0),n=new yo(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(mo.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(mo.group),n=-1;n<(i?i.length:0);n++){let s=e[n<0?t.name:i[n]];if(s)return s}}}}yo.none=new yo("",Object.create(null),0,8);class bo{constructor(t){this.types=t;for(let e=0;e=e){let o=new Eo(r.tree,r.overlay[0].from+t.from,-1,t);(s||(s=[n])).push(Oo(o,e,i,!1))}}return s?No(s):n}(this,t,e)}iterate(t){let{enter:e,leave:i,from:n=0,to:s=this.length}=t,r=t.mode||0,o=(r&So.IncludeAnonymous)>0;for(let t=this.cursor(r|So.IncludeAnonymous);;){let r=!1;if(t.from<=s&&t.to>=n&&(!o&&t.type.isAnonymous||!1!==e(t))){if(t.firstChild())continue;r=!0}for(;r&&i&&(o||!t.type.isAnonymous)&&i(t),!t.nextSibling();){if(!t.parent())return;r=!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:Fo(yo.none,this.children,this.positions,0,this.children.length,0,this.length,((t,e,i)=>new Ao(this.type,t,e,i,this.propValues)),t.makeTree||((t,e,i)=>new Ao(yo.none,t,e,i)))}static build(t){return function(t){var e;let{buffer:i,nodeSet:n,maxBufferLength:s=fo,reused:r=[],minRepeatType:o=n.types.length}=t,l=Array.isArray(i)?new Mo(i,i.length):i,h=n.types,a=0,c=0;function u(t,e,i,w,y,b){let{id:x,start:k,end:S,size:A}=l,M=c;for(;A<0;){if(l.next(),-1==A){let e=r[x];return i.push(e),void w.push(k-t)}if(-3==A)return void(a=x);if(-4==A)return void(c=x);throw new RangeError(`Unrecognized record size: ${A}`)}let C,D,O=h[x],T=k-t;if(S-k<=s&&(D=m(l.pos-e,y))){let e=new Uint16Array(D.size-D.skip),i=l.pos-D.size,s=e.length;for(;l.pos>i;)s=v(D.start,e,s);C=new Co(e,S-D.start,n),T=D.start-t}else{let t=l.pos-A;l.next();let e=[],i=[],n=x>=o?x:-1,r=0,h=S;for(;l.pos>t;)n>=0&&l.id==n&&l.size>=0?(l.end<=h-s&&(p(e,i,k,r,l.end,h,n,M),r=e.length,h=l.end),l.next()):b>2500?f(k,t,e,i):u(k,t,e,i,n,b+1);if(n>=0&&r>0&&r-1&&r>0){let t=d(O);C=Fo(O,e,i,0,e.length,0,S-k,t,t)}else C=g(O,e,i,S-k,M-S)}i.push(C),w.push(T)}function f(t,e,i,r){let o=[],h=0,a=-1;for(;l.pos>e;){let{id:t,start:e,end:i,size:n}=l;if(n>4)l.next();else{if(a>-1&&e=0;t-=3)e[i++]=o[t],e[i++]=o[t+1]-s,e[i++]=o[t+2]-s,e[i++]=i;i.push(new Co(e,o[2]-s,n)),r.push(s-t)}}function d(t){return(e,i,n)=>{let s,r,o=0,l=e.length-1;if(l>=0&&(s=e[l])instanceof Ao){if(!l&&s.type==t&&s.length==n)return s;(r=s.prop(mo.lookAhead))&&(o=i[l]+s.length+r)}return g(t,e,i,n,o)}}function p(t,e,i,s,r,o,l,h){let a=[],c=[];for(;t.length>s;)a.push(t.pop()),c.push(e.pop()+i-r);t.push(g(n.types[l],a,c,o-r,h-o)),e.push(r-i)}function g(t,e,i,n,s=0,r){if(a){let t=[mo.contextHash,a];r=r?[t].concat(r):[t]}if(s>25){let t=[mo.lookAhead,s];r=r?[t].concat(r):[t]}return new Ao(t,e,i,n,r)}function m(t,e){let i=l.fork(),n=0,r=0,h=0,a=i.end-s,c={size:0,start:0,skip:0};t:for(let s=i.pos-t;i.pos>s;){let t=i.size;if(i.id==e&&t>=0){c.size=n,c.start=r,c.skip=h,h+=4,n+=4,i.next();continue}let l=i.pos-t;if(t<0||l=o?4:0,f=i.start;for(i.next();i.pos>l;){if(i.size<0){if(-3!=i.size)break t;u+=4}else i.id>=o&&(u+=4);i.next()}r=f,n+=t,h+=u}return(e<0||n==t)&&(c.size=n,c.start=r,c.skip=h),c.size>4?c:void 0}function v(t,e,i){let{id:n,start:s,end:r,size:h}=l;if(l.next(),h>=0&&n4){let n=l.pos-(h-4);for(;l.pos>n;)i=v(t,e,i)}e[--i]=o,e[--i]=r-t,e[--i]=s-t,e[--i]=n}else-3==h?a=n:-4==h&&(c=n);return i}let w=[],y=[];for(;l.pos>0;)u(t.start||0,t.bufferStart||0,w,y,-1,0);let b=null!==(e=t.length)&&void 0!==e?e:w.length?y[0]+w[0].length:0;return new Ao(h[t.topID],w.reverse(),y.reverse(),b)}(t)}}Ao.empty=new Ao(yo.none,[],[],0);class Mo{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 Mo(this.buffer,this.index)}}class Co{constructor(t,e,i){this.buffer=t,this.length=e,this.set=i}get type(){return yo.none}toString(){let t=[];for(let e=0;e0));l=r[l+3]);return o}slice(t,e,i){let n=this.buffer,s=new Uint16Array(e-t),r=0;for(let o=t,l=0;o=e&&ie;case 1:return i<=e&&n>e;case 2:return n>e;case 4:return!0}}function Oo(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.to0?o.length:-1;t!=h;t+=e){let h=o[t],a=l[t]+r.from;if(Do(n,i,a,a+h.length))if(h instanceof Co){if(s&So.ExcludeBuffers)continue;let o=h.findChild(0,h.buffer.length,e,i-a,n);if(o>-1)return new Lo(new Po(r,h,t,a),null,o)}else if(s&So.IncludeAnonymous||!h.type.isAnonymous||Ho(h)){let o;if(!(s&So.IgnoreMounts)&&(o=vo.get(h))&&!o.overlay)return new Eo(o.tree,a,t,r);let l=new Eo(h,a,t,r);return s&So.IncludeAnonymous||!l.type.isAnonymous?l:l.nextChild(e<0?h.children.length-1:0,e,i,n)}}if(s&So.IncludeAnonymous||!r.type.isAnonymous)return null;if(t=r.index>=0?r.index+e:e<0?-1:r._parent._tree.children.length,r=r._parent,!r)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)}enter(t,e,i=0){let n;if(!(i&So.IgnoreOverlays)&&(n=vo.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:s>i))return new Eo(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 Ro(t,e,i,n){let s=t.cursor(),r=[];if(!s.firstChild())return r;if(null!=i)for(let t=!1;!t;)if(t=s.type.is(i),!s.nextSibling())return r;for(;;){if(null!=n&&s.type.is(n))return r;if(s.type.is(e)&&r.push(s.node),!s.nextSibling())return null==n?r:[]}}function Bo(t,e,i=e.length-1){for(let n=t.parent;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 Po{constructor(t,e,i,n){this.parent=t,this.buffer=e,this.index=i,this.start=n}}class Lo extends To{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 Lo(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)}enter(t,e,i=0){if(i&So.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 Lo(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 Lo(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 Lo(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 r=i.buffer[this.index+1];t.push(i.slice(n,s,r)),e.push(0)}return new Ao(this.type,t,e,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function No(t){if(!t.length)return null;let e=0,i=t[0];for(let n=1;ni.from||s.to0){if(this.index-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&So.IncludeAnonymous||t instanceof Co||!t.type.isAnonymous||Ho(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=0;){for(let r=t;r;r=r._parent)if(r.index==n){if(n==this.index)return r;e=r,i=s+1;break t}n=this.stack[--s]}for(let t=i;t=0;s--){if(s<0)return Bo(this.node,t,n);let r=i[e.buffer[this.stack[s]]];if(!r.isAnonymous){if(t[n]&&t[n]!=r.name)return!1;n--}}return!0}}function Ho(t){return t.children.some((t=>t instanceof Co||!t.type.isAnonymous||Ho(t)))}const Wo=new WeakMap;function zo(t,e){if(!t.isAnonymous||e instanceof Co||e.type!=t)return 1;let i=Wo.get(e);if(null==i){i=1;for(let n of e.children){if(n.type!=t||!(n instanceof Ao)){i=1;break}i+=zo(t,n)}Wo.set(e,i)}return i}function Fo(t,e,i,n,s,r,o,l,h){let a=0;for(let i=n;i=c)break;p+=e}if(a==s+1){if(p>c){let t=i[s];e(t.children,t.positions,0,t.children.length,n[s]+l);continue}u.push(i[s])}else{let e=n[a-1]+i[a-1].length-d;u.push(Fo(t,i,n,s,a,d,e,null,h))}f.push(d+l-r)}}(e,i,n,s,0),(l||h)(u,f,o)}class qo{constructor(t,e,i,n,s=!1,r=!1){this.from=t,this.to=e,this.tree=i,this.offset=n,this.open=(s?1:0)|(r?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 qo(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,r=t.length?t[0]:null;for(let o=0,l=0,h=0;;o++){let a=o=i)for(;r&&r.from=e.from||c<=e.to||h){let t=Math.max(e.from,l)-h,i=Math.min(e.to,c)-h;e=t>=i?null:new qo(t,i,e.tree,e.offset+h,o>0,!!a)}if(e&&n.push(e),r.to>c)break;r=snew go(t.from,t.to))):[new go(0,0)]:[new go(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 Ko{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)}}new mo({perNode:!0});let jo=0;class $o{constructor(t,e,i){this.set=t,this.base=e,this.modified=i,this.id=jo++}static define(t){if(null==t?void 0:t.base)throw new Error("Can not derive from a modified tag");let e=new $o([],null,[]);if(e.set.push(e),t)for(let i of t.set)e.set.push(i);return e}static defineModifier(){let t=new Go;return e=>e.modified.indexOf(t)>-1?e:Go.get(e.base||e,e.modified.concat(t).sort(((t,e)=>t.id-e.id)))}}let Uo=0;class Go{constructor(){this.instances=[],this.id=Uo++}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 $o(n,t,e);for(let t of e)t.instances.push(s);let r=function(t){let e=[[]];for(let i=0;ie.length-t.length))}(e);for(let e of t.set)if(!e.modified.length)for(let t of r)n.push(Go.get(e,t));return s}}function Jo(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,r=t;for(let e=0;;){if("..."==r&&e>0&&e+3==t.length){s=1;break}let n=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(r);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 o=t[e++];if(e==t.length&&"!"==o){s=0;break}if("/"!=o)throw new RangeError("Invalid path: "+t);r=t.slice(e)}let o=i.length-1,l=i[o];if(!l)throw new RangeError("Invalid path: "+t);let h=new Xo(n,s,o>0?i.slice(0,o):null);e[l]=h.sort(e[l])}}return Yo.add(e)}const Yo=new mo;class Xo{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{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 Zo(t,e,i,n=0,s=t.length){let r=new tl(n,Array.isArray(e)?e:[e],i);r.highlightRange(t.cursor(),n,s,"",r.highlighters),r.flush(s)}Xo.empty=new Xo([],2,null);class tl{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:o,to:l}=t;if(o>=i||l<=e)return;r.isTop&&(s=this.highlighters.filter((t=>!t.scope||t.scope(r))));let h=n,a=function(t){let e=t.type.prop(Yo);for(;e&&e.context&&!t.matchContext(e.context);)e=e.next;return e||null}(t)||Xo.empty,c=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,a.tags);if(c&&(h&&(h+=" "),h+=c,1==a.mode&&(n+=(n?" ":"")+c)),this.startSpan(Math.max(e,o),h),a.opaque)return;let u=t.tree&&t.tree.prop(mo.mounted);if(u&&u.overlay){let r=t.node.enter(u.overlay[0].from+o,1),a=this.highlighters.filter((t=>!t.scope||t.scope(u.tree.type))),c=t.firstChild();for(let f=0,d=o;;f++){let p=f=g)&&t.nextSibling()););if(!p||g>i)break;d=p.to+o,d>e&&(this.highlightRange(r.cursor(),Math.max(e,p.from+o),Math.min(i,d),"",a),this.startSpan(Math.min(i,d),h))}c&&t.parent()}else if(t.firstChild()){u&&(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 el=$o.define,il=el(),nl=el(),sl=el(nl),rl=el(nl),ol=el(),ll=el(ol),hl=el(ol),al=el(),cl=el(al),ul=el(),fl=el(),dl=el(),pl=el(dl),gl=el(),ml={comment:il,lineComment:el(il),blockComment:el(il),docComment:el(il),name:nl,variableName:el(nl),typeName:sl,tagName:el(sl),propertyName:rl,attributeName:el(rl),className:el(nl),labelName:el(nl),namespace:el(nl),macroName:el(nl),literal:ol,string:ll,docString:el(ll),character:el(ll),attributeValue:el(ll),number:hl,integer:el(hl),float:el(hl),bool:el(ol),regexp:el(ol),escape:el(ol),color:el(ol),url:el(ol),keyword:ul,self:el(ul),null:el(ul),atom:el(ul),unit:el(ul),modifier:el(ul),operatorKeyword:el(ul),controlKeyword:el(ul),definitionKeyword:el(ul),moduleKeyword:el(ul),operator:fl,derefOperator:el(fl),arithmeticOperator:el(fl),logicOperator:el(fl),bitwiseOperator:el(fl),compareOperator:el(fl),updateOperator:el(fl),definitionOperator:el(fl),typeOperator:el(fl),controlOperator:el(fl),punctuation:dl,separator:el(dl),bracket:pl,angleBracket:el(pl),squareBracket:el(pl),paren:el(pl),brace:el(pl),content:al,heading:cl,heading1:el(cl),heading2:el(cl),heading3:el(cl),heading4:el(cl),heading5:el(cl),heading6:el(cl),contentSeparator:el(al),list:el(al),quote:el(al),emphasis:el(al),strong:el(al),link:el(al),monospace:el(al),strikethrough:el(al),inserted:el(),deleted:el(),changed:el(),invalid:el(),meta:gl,documentMeta:el(gl),annotation:el(gl),processingInstruction:el(gl),definition:$o.defineModifier(),constant:$o.defineModifier(),function:$o.defineModifier(),standard:$o.defineModifier(),local:$o.defineModifier(),special:$o.defineModifier()};var vl;Qo([{tag:ml.link,class:"tok-link"},{tag:ml.heading,class:"tok-heading"},{tag:ml.emphasis,class:"tok-emphasis"},{tag:ml.strong,class:"tok-strong"},{tag:ml.keyword,class:"tok-keyword"},{tag:ml.atom,class:"tok-atom"},{tag:ml.bool,class:"tok-bool"},{tag:ml.url,class:"tok-url"},{tag:ml.labelName,class:"tok-labelName"},{tag:ml.inserted,class:"tok-inserted"},{tag:ml.deleted,class:"tok-deleted"},{tag:ml.literal,class:"tok-literal"},{tag:ml.string,class:"tok-string"},{tag:ml.number,class:"tok-number"},{tag:[ml.regexp,ml.escape,ml.special(ml.string)],class:"tok-string2"},{tag:ml.variableName,class:"tok-variableName"},{tag:ml.local(ml.variableName),class:"tok-variableName tok-local"},{tag:ml.definition(ml.variableName),class:"tok-variableName tok-definition"},{tag:ml.special(ml.variableName),class:"tok-variableName2"},{tag:ml.definition(ml.propertyName),class:"tok-propertyName tok-definition"},{tag:ml.typeName,class:"tok-typeName"},{tag:ml.namespace,class:"tok-namespace"},{tag:ml.className,class:"tok-className"},{tag:ml.macroName,class:"tok-macroName"},{tag:ml.propertyName,class:"tok-propertyName"},{tag:ml.operator,class:"tok-operator"},{tag:ml.comment,class:"tok-comment"},{tag:ml.meta,class:"tok-meta"},{tag:ml.invalid,class:"tok-invalid"},{tag:ml.punctuation,class:"tok-punctuation"}]);const wl=new mo;const yl=new mo;class bl{constructor(t,e,i=[],n=""){this.data=t,this.name=n,At.prototype.hasOwnProperty("tree")||Object.defineProperty(At.prototype,"tree",{get(){return kl(this)}}),this.parser=e,this.extension=[Rl.of(this),At.languageData.of(((t,e,i)=>{let n=xl(t,e,i),s=n.type.prop(wl);if(!s)return[];let r=t.facet(s),o=n.type.prop(yl);if(o){let s=n.resolve(e-n.from,i);for(let e of o)if(e.test(s,t)){let i=t.facet(e.facet);return"replace"==e.type?i:i.concat(r)}}return r}))].concat(i)}isActiveAt(t,e,i=-1){return xl(t,e,i).type.prop(wl)==this.data}findRegions(t){let e=t.facet(Rl);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(wl)==this.data)return void i.push({from:e,to:e+t.length});let s=t.prop(mo.mounted);if(s){if(s.tree.prop(wl)==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=this.cursorPos?this.doc.sliceString(t,e):this.string.slice(t-i,e-i)}}let Al=null;class Ml{constructor(t,e,i=[],n,s,r,o,l){this.parser=t,this.state=e,this.fragments=i,this.tree=n,this.treeLen=s,this.viewport=r,this.skipped=o,this.scheduleOn=l,this.parse=null,this.tempSkipped=[]}static create(t,e,i){return new Ml(t,e,[],Ao.empty,0,i,[],null)}startParse(){return this.parser.startParse(new Sl(this.state.doc),this.fragments)}work(t,e){return null!=e&&e>=this.state.doc.length&&(e=void 0),this.tree!=Ao.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.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(qo.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(t){let e=Al;Al=this;try{return t()}finally{Al=e}}withoutTempSkipped(t){for(let e;e=this.tempSkipped.pop();)t=Cl(t,e.from,e.to);return t}changes(t,e){let{fragments:i,tree:n,treeLen:s,viewport:r,skipped:o}=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=qo.applyChanges(i,e),n=Ao.empty,s=0,r={from:t.mapPos(r.from,-1),to:t.mapPos(r.to,1)},this.skipped.length){o=[];for(let e of this.skipped){let i=t.mapPos(e.from,1),n=t.mapPos(e.to,-1);it.from&&(this.fragments=Cl(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 _o{createParse(e,i,n){let s=n[0].from,r=n[n.length-1].to;return{parsedPos:s,advance(){let e=Al;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=r,new Ao(yo.none,[],[],r-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 Al}}function Cl(t,e,i){return qo.applyChanges(t,[{fromA:e,toA:i,fromB:e,toB:i}])}class Dl{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 Dl(e)}static init(t){let e=Math.min(3e3,t.doc.length),i=Ml.create(t.facet(Rl).parser,t,{from:0,to:e});return i.work(20,e)||i.takeTree(),new Dl(i)}}bl.state=_.define({create:Dl.init,update(t,e){for(let t of e.effects)if(t.is(bl.setState))return t.value;return e.startState.facet(Rl)!=e.state.facet(Rl)?Dl.init(e.state):t.apply(e)}});let Ol=t=>{let e=setTimeout((()=>t()),500);return()=>clearTimeout(e)};"undefined"!=typeof requestIdleCallback&&(Ol=t=>{let e=-1,i=setTimeout((()=>{e=requestIdleCallback(t,{timeout:400})}),100);return()=>e<0?clearTimeout(i):cancelIdleCallback(e)});const Tl="undefined"!=typeof navigator&&(null===(vl=navigator.scheduling)||void 0===vl?void 0:vl.isInputPending)?()=>navigator.scheduling.isInputPending():null,El=Gi.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(bl.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(bl.state);e.tree==e.context.tree&&e.context.isDone(t.doc.length)||(this.working=Ol(this.work))}work(t){this.working=null;let e=Date.now();if(this.chunkEndn+1e3,l=s.context.work((()=>Tl&&Tl()||Date.now()>r),n+(o?0:1e5));this.chunkBudget-=Date.now()-e,(l||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:bl.setState.of(new Dl(s.context))})),this.chunkBudget>0&&(!l||o)&&this.scheduleWork(),this.checkAsyncSchedule(s.context)}checkAsyncSchedule(t){t.scheduleOn&&(this.workScheduled++,t.scheduleOn.then((()=>this.scheduleWork())).catch((t=>Ki(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()}}}),Rl=I.define({combine:t=>t.length?t[0]:null,enables:t=>[bl.state,El,js.contentAttributes.compute([t],(e=>{let i=e.facet(t);return i&&i.name?{"data-language":i.name}:{}}))]});const Bl=I.define(),Pl=I.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 Ll(t){let e=t.facet(Pl);return 9==e.charCodeAt(0)?t.tabSize*e.length:e.length}function Nl(t,e){let i="",n=t.tabSize,s=t.facet(Pl)[0];if("\t"==s){for(;e>=n;)i+="\t",e-=n;s=" "}for(let t=0;t=e?function(t,e,i){let n=e.resolveStack(i),s=n.node.enterUnfinishedNodesBefore(i);if(s!=n.node){let t=[];for(let e=s;e!=n.node;e=e.parent)t.push(e);for(let e=t.length-1;e>=0;e--)n={node:t[e],next:n}}return Wl(n,t,i)}(t,i,e):null}class Vl{constructor(t,e={}){this.state=t,this.options=e,this.unit=Ll(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-1&&(s+=r-this.countColumn(i,i.search(/\S|$/))),s}countColumn(t,e=t.length){return qt(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 Hl=new mo;function Wl(t,e,i){for(let n=t;n;n=n.next){let t=zl(n.node);if(t)return t(ql.create(e,i,n))}return 0}function zl(t){let e=t.type.prop(Hl);if(e)return e;let i,n=t.firstChild;if(n&&(i=n.type.prop(mo.closedBy))){let e=t.lastChild,n=e&&i.indexOf(e.name)>-1;return t=>function(t,e,i,n,s){let r=t.textAfter,o=r.match(/^\s*/)[0].length,l=n&&r.slice(o,o+n.length)==n||s==t.pos+o,h=e?function(t){let e=t.node,i=e.childAfter(e.from),n=e.lastChild;if(!i)return null;let s=t.options.simulateBreak,r=t.state.doc.lineAt(i.from),o=null==s||s<=r.from?r.to:Math.min(r.to,s);for(let t=i.to;;){let s=e.childAfter(t);if(!s||s==n)return null;if(!s.type.isSkipped)return s.from=n?void 0:{from:i,to:n}}const jl=ft.define({map:Kl}),$l=ft.define({map:Kl}),Ul=_.define({create:()=>ri.none,update(t,e){t=t.map(e.changes);for(let i of e.effects)if(i.is(jl)&&!Gl(t,i.value.from,i.value.to)){let{preparePlaceholder:n}=e.state.facet(Yl),s=n?ri.replace({widget:new Zl(n(e.state,i.value))}):Ql;t=t.update({add:[s.range(i.value.from,i.value.to)]})}else i.is($l)&&(t=t.update({filter:(t,e)=>i.value.from!=t||i.value.to!=e,filterFrom:i.value.from,filterTo:i.value.to}));if(e.selection){let i=!1,{head:n}=e.selection.main;t.between(n,n,((t,e)=>{tn&&(i=!0)})),i&&(t=t.update({filterFrom:n,filterTo:n,filter:(t,e)=>e<=n||t>=n}))}return t},provide:t=>js.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==e&&s==i&&(n=!0)})),n}const Jl={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},Yl=I.define({combine:t=>Mt(t,Jl)});function Xl(t,e){let{state:i}=t,n=i.facet(Yl),s=e=>{let i=t.lineBlockAt(t.posAtDOM(e.target)),n=function(t,e,i){var n;let s=null;return null===(n=t.field(Ul,!1))||void 0===n||n.between(e,i,((t,e)=>{(!s||s.from>t)&&(s={from:t,to:e})})),s}(t.state,i.from,i.to);n&&t.dispatch({effects:$l.of(n)}),e.preventDefault()};if(n.placeholderDOM)return n.placeholderDOM(t,s,e);let r=document.createElement("span");return r.textContent=n.placeholderText,r.setAttribute("aria-label",i.phrase("folded code")),r.title=i.phrase("unfold"),r.className="cm-foldPlaceholder",r.onclick=s,r}const Ql=ri.replace({widget:new class extends ni{toDOM(t){return Xl(t,null)}}});class Zl extends ni{constructor(t){super(),this.value=t}eq(t){return this.value==t.value}toDOM(t){return Xl(t,this.value)}}const th=js.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 eh{constructor(t,e){let i;function n(t){let e=Ut.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,r=e.scope;this.scope=r instanceof bl?t=>t.prop(wl)==r.data:r?t=>t==r:void 0,this.style=Qo(t.map((t=>({tag:t.tag,class:t.class||n(Object.assign({},t,{tag:null}))}))),{all:s}).style,this.module=i?new Ut(i):null,this.themeType=e.themeType}static define(t,e){return new eh(t,e||{})}}const ih=I.define(),nh=I.define({combine:t=>t.length?[t[0]]:null});function sh(t){let e=t.facet(ih);return e.length?e:t.facet(nh)}class rh{constructor(t){this.markCache=Object.create(null),this.tree=kl(t.state),this.decorations=this.buildDeco(t,sh(t.state)),this.decoratedTo=t.viewport.to}update(t){let e=kl(t.state),i=sh(t.state),n=i!=sh(t.startState),{viewport:s}=t.view,r=t.changes.mapPos(this.decoratedTo,1);e.length=s.to?(this.decorations=this.decorations.map(t.changes),this.decoratedTo=r):(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 ri.none;let i=new Rt;for(let{from:n,to:s}of t.visibleRanges)Zo(this.tree,e,((t,e,n)=>{i.add(t,e,this.markCache[n]||(this.markCache[n]=ri.mark({class:n})))}),n,s);return i.finish()}}const oh=J.high(Gi.fromClass(rh,{decorations:t=>t.decorations})),lh=js.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),hh=1e4,ah="()[]{}",ch=I.define({combine:t=>Mt(t,{afterCursor:!0,brackets:ah,maxScanDistance:hh,renderMatch:dh})}),uh=ri.mark({class:"cm-matchingBracket"}),fh=ri.mark({class:"cm-nonmatchingBracket"});function dh(t){let e=[],i=t.matched?uh:fh;return e.push(i.range(t.start.from,t.start.to)),t.end&&e.push(i.range(t.end.from,t.end.to)),e}const ph=_.define({create:()=>ri.none,update(t,e){if(!e.docChanged&&!e.selection)return t;let i=[],n=e.state.facet(ch);for(let t of e.state.selection.ranges){if(!t.empty)continue;let s=yh(e.state,t.head,-1,n)||t.head>0&&yh(e.state,t.head-1,1,n)||n.afterCursor&&(yh(e.state,t.head,1,n)||t.headjs.decorations.from(t)}),gh=[ph,lh];const mh=new mo;function vh(t,e,i){let n=t.prop(e<0?mo.openedBy:mo.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 wh(t){let e=t.type.prop(mh);return e?e(t.node):t}function yh(t,e,i,n={}){let s=n.maxScanDistance||hh,r=n.brackets||ah,o=kl(t),l=o.resolveInner(e,i);for(let n=l;n;n=n.parent){let s=vh(n.type,i,r);if(s&&n.from0?e>=o.from&&eo.from&&e<=o.to))return bh(t,e,i,n,o,s,r)}}return function(t,e,i,n,s,r,o){let l=i<0?t.sliceDoc(e-1,e):t.sliceDoc(e,e+1),h=o.indexOf(l);if(h<0||h%2==0!=i>0)return null;let a={from:i<0?e-1:e,to:i>0?e+1:e},c=t.doc.iterRange(e,i>0?t.doc.length:0),u=0;for(let t=0;!c.next().done&&t<=r;){let r=c.value;i<0&&(t+=r.length);let l=e+t*i;for(let t=i>0?0:r.length-1,e=i>0?r.length:-1;t!=e;t+=i){let e=o.indexOf(r[t]);if(!(e<0||n.resolveInner(l+t,1).type!=s))if(e%2==0==i>0)u++;else{if(1==u)return{start:a,end:{from:l+t,to:l+t+1},matched:e>>1==h>>1};u--}}i>0&&(t+=r.length)}return c.done?{start:a,matched:!1}:null}(t,e,i,o,l.type,s,r)}function bh(t,e,i,n,s,r,o){let l=n.parent,h={from:s.from,to:s.to},a=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==a&&r.indexOf(c.type.name)>-1&&c.from=this.string.length}sol(){return 0==this.pos}peek(){return this.string.charAt(this.pos)||void 0}next(){if(this.pose}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.lastColumnPosi?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 Sh(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 Ah=new WeakMap;class Mh extends bl{constructor(t){let e=(i=t.languageData,I.define({combine:i?t=>t.concat(i):void 0}));var i;let n,s={name:(r=t).name||"",token:r.token,blankLine:r.blankLine||(()=>{}),startState:r.startState||(()=>!0),copyState:r.copyState||Sh,indent:r.indent||(()=>null),languageData:r.languageData||{},tokenTable:r.tokenTable||Eh};var r;super(e,new class extends _o{createParse(t,e,i){return new Oh(n,t,e,i)}},[Bl.of(((t,e)=>this.getIndent(t,e)))],t.name),this.topNode=function(t){let e=yo.define({id:Rh.length,name:"Document",props:[wl.add((()=>t))],top:!0});return Rh.push(e),e}(e),n=this,this.streamParser=s,this.stateAfter=new mo({perNode:!0}),this.tokenTable=t.tokenTable?new Ih(s.tokenTable):Vh}static define(t){return new Mh(t)}getIndent(t,e){let i,n=kl(t.state),s=n.resolve(e);for(;s&&s.type!=this.topNode;)s=s.parent;if(!s)return null;let{overrideIndentation:r}=t.options;r&&(i=Ah.get(t.state),null!=i&&i1e4)return null;for(;o=n&&i+e.length<=s&&e.prop(t.stateAfter);if(r)return{state:t.streamParser.copyState(r),pos:i+e.length};for(let r=e.children.length-1;r>=0;r--){let o=e.children[r],l=i+e.positions[r],h=o instanceof Ao&&l=e.length)return e;s||e.type!=t.topNode||(s=!0);for(let r=e.children.length-1;r>=0;r--){let o,l=e.positions[r],h=e.children[r];if(li&&Ch(t,n.tree,0-n.offset,i,r);if(o&&(e=Dh(t,n.tree,i+n.offset,o.pos+n.offset,!1)))return{state:o.state,tree:e}}return{state:t.streamParser.startState(n?Ll(n):4),tree:Ao.empty}}(t,i,r,null==s?void 0:s.state);this.state=o,this.parsedPos=this.chunkStart=r+l.length;for(let t=0;t=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,r=this.lineAfter(s);e+=r,i=s+r.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].to1){e+=s=this.skipGapsTo(e,s,1);let t=this.chunk.length;i+=s=this.skipGapsTo(i,s,-1),n+=this.chunk.length-t}return this.chunk.push(t,e,i,n),s}parseLine(t){let{line:e,end:i}=this.nextLine(),n=0,{streamParser:s}=this.lang,r=new kh(e,t?t.state.tabSize:4,t?Ll(t.state):2);if(r.eol())s.blankLine(this.state,r.indentUnit);else for(;!r.eol();){let t=Th(s.token,r,this.state);if(t&&(n=this.emitToken(this.lang.tokenTable.resolve(t),this.parsedPos+r.start,this.parsedPos+r.pos,4,n)),r.start>1e4)break}this.parsedPos=i,this.moveRangeIndex(),this.parsedPose.start)return n}throw new Error("Stream parser failed to advance stream.")}const Eh=Object.create(null),Rh=[yo.none],Bh=new bo(Rh),Ph=[],Lh=Object.create(null),Nh=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"]])Nh[t]=Wh(Eh,e);class Ih{constructor(t){this.extra=t,this.table=Object.assign(Object.create(null),Nh)}resolve(t){return t?this.table[t]||(this.table[t]=Wh(this.extra,t)):0}}const Vh=new Ih(Eh);function Hh(t,e){Ph.indexOf(t)>-1||(Ph.push(t),console.warn(e))}function Wh(t,e){let i=[];for(let n of e.split(" ")){let e=[];for(let i of n.split(".")){let n=t[i]||ml[i];n?"function"==typeof n?e.length?e=e.map(n):Hh(i,`Modifier ${i} used at start of tag`):e.length?Hh(i,`Tag ${i} used as modifier`):e=Array.isArray(n)?n:[n]:Hh(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)),r=Lh[s];if(r)return r.id;let o=Lh[s]=yo.define({id:Rh.length,name:n,props:[Jo({[n]:i})]});return Rh.push(o),o.id}exports.Direction.RTL,exports.Direction.LTR;function zh(t,e){return({state:i,dispatch:n})=>{if(i.readOnly)return!1;let s=t(e,i);return!!s&&(n(i.update(s)),!0)}}const Fh=zh(Uh,0),qh=zh($h,0),_h=zh(((t,e)=>$h(t,e,function(t){let e=[];for(let i of t.selection.ranges){let n=t.doc.lineAt(i.from),s=i.to<=n.to?n:t.doc.lineAt(i.to),r=e.length-1;r>=0&&e[r].to>n.from?e[r].to=s.to:e.push({from:n.from+/^\s*/.exec(n.text)[0].length,to:s.to})}return e}(e))),0);function Kh(t,e){let i=t.languageDataAt("commentTokens",e);return i.length?i[0]:{}}const jh=50;function $h(t,e,i=e.selection.ranges){let n=i.map((t=>Kh(e,t.from).block));if(!n.every((t=>t)))return null;let s=i.map(((t,i)=>function(t,{open:e,close:i},n,s){let r,o,l=t.sliceDoc(n-jh,n),h=t.sliceDoc(s,s+jh),a=/\s*$/.exec(l)[0].length,c=/^\s*/.exec(h)[0].length,u=l.length-a;if(l.slice(u-e.length,u)==e&&h.slice(c,c+i.length)==i)return{open:{pos:n-a,margin:a&&1},close:{pos:s+c,margin:c&&1}};s-n<=2*jh?r=o=t.sliceDoc(n,s):(r=t.sliceDoc(n,n+jh),o=t.sliceDoc(s-jh,s));let f=/^\s*/.exec(r)[0].length,d=/\s*$/.exec(o)[0].length,p=o.length-d-i.length;return r.slice(f,f+e.length)==e&&o.slice(p,p+i.length)==i?{open:{pos:n+f+e.length,margin:/\s/.test(r.charAt(f+e.length))?1:0},close:{pos:s-d-i.length,margin:/\s/.test(o.charAt(p-1))?1:0}}:null}(e,n[i],t.from,t.to)));if(2!=t&&!s.every((t=>t)))return{changes:e.changes(i.map(((t,e)=>s[e]?[]:[{from:t.from,insert:n[e].open+" "},{from:t.to,insert:" "+n[e].close}])))};if(1!=t&&s.some((t=>t))){let t=[];for(let e,i=0;is&&(t==r||r>h.from)){s=h.from;let t=/^\s*/.exec(h.text)[0].length,e=t==h.length,i=h.text.slice(t,t+l.length)==l?t:-1;tt.comment<0&&(!t.empty||t.single)))){let t=[];for(let{line:e,token:i,indent:s,empty:r,single:o}of n)!o&&r||t.push({from:e.from+s,insert:i+" "});let i=e.changes(t);return{changes:i,selection:e.selection.map(i,1)}}if(1!=t&&n.some((t=>t.comment>=0))){let t=[];for(let{line:e,comment:i,token:s}of n)if(i>=0){let n=e.from+i,r=n+s.length;" "==e.text[r-e.from]&&r++,t.push({from:n,to:r})}return{changes:t}}return null}const Gh=at.define(),Jh=at.define(),Yh=I.define(),Xh=I.define({combine:t=>Mt(t,{minDepth:100,newGroupDelay:500,joinToEvent:(t,e)=>e},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(t,e)=>(i,n)=>t(i,n)||e(i,n)})}),Qh=_.define({create:()=>pa.empty,update(t,e){let i=e.state.facet(Xh),n=e.annotation(Gh);if(n){let s=sa.fromTransaction(e,n.selection),r=n.side,o=0==r?t.undone:t.done;return o=s?ra(o,o.length,i.minDepth,s):aa(o,e.startState.selection),new pa(0==r?n.rest:o,0==r?o:n.rest)}let s=e.annotation(Jh);if("full"!=s&&"before"!=s||(t=t.isolate()),!1===e.annotation(dt.addToHistory))return e.changes.empty?t:t.addMapping(e.changes.desc);let r=sa.fromTransaction(e),o=e.annotation(dt.time),l=e.annotation(dt.userEvent);return r?t=t.addChanges(r,o,l,i,e):e.selection&&(t=t.addSelection(e.startState.selection,o,l,i.newGroupDelay)),"full"!=s&&"after"!=s||(t=t.isolate()),t},toJSON:t=>({done:t.done.map((t=>t.toJSON())),undone:t.undone.map((t=>t.toJSON()))}),fromJSON:t=>new pa(t.done.map(sa.fromJSON),t.undone.map(sa.fromJSON))});function Zh(t,e){return function({state:i,dispatch:n}){if(!e&&i.readOnly)return!1;let s=i.field(Qh,!1);if(!s)return!1;let r=s.pop(t,i,e);return!!r&&(n(r),!0)}}const ta=Zh(0,!1),ea=Zh(1,!1),ia=Zh(0,!0),na=Zh(1,!0);class sa{constructor(t,e,i,n,s){this.changes=t,this.effects=e,this.mapped=i,this.startSelection=n,this.selectionsAfter=s}setSelAfter(t){return new sa(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){var t,e,i;return{changes:null===(t=this.changes)||void 0===t?void 0:t.toJSON(),mapped:null===(e=this.mapped)||void 0===e?void 0:e.toJSON(),startSelection:null===(i=this.startSelection)||void 0===i?void 0:i.toJSON(),selectionsAfter:this.selectionsAfter.map((t=>t.toJSON()))}}static fromJSON(t){return new sa(t.changes&&M.fromJSON(t.changes),[],t.mapped&&A.fromJSON(t.mapped),t.startSelection&&P.fromJSON(t.startSelection),t.selectionsAfter.map(P.fromJSON))}static fromTransaction(t,e){let i=la;for(let e of t.startState.facet(Yh)){let n=e(t);n.length&&(i=i.concat(n))}return!i.length&&t.changes.empty?null:new sa(t.changes.invert(t.startState.doc),i,void 0,e||t.startState.selection,la)}static selection(t){return new sa(void 0,la,void 0,void 0,t)}}function ra(t,e,i,n){let s=e+1>i+20?e-i-1:0,r=t.slice(s,e);return r.push(n),r}function oa(t,e){return t.length?e.length?t.concat(e):t:e}const la=[],ha=200;function aa(t,e){if(t.length){let i=t[t.length-1],n=i.selectionsAfter.slice(Math.max(0,i.selectionsAfter.length-ha));return n.length&&n[n.length-1].eq(e)?t:(n.push(e),ra(t,t.length-1,1e9,i.setSelAfter(n)))}return[sa.selection([e])]}function ca(t){let e=t[t.length-1],i=t.slice();return i[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),i}function ua(t,e){if(!t.length)return t;let i=t.length,n=la;for(;i;){let s=fa(t[i-1],e,n);if(s.changes&&!s.changes.empty||s.effects.length){let e=t.slice(0,i);return e[i-1]=s,e}e=s.mapped,i--,n=s.selectionsAfter}return n.length?[sa.selection(n)]:la}function fa(t,e,i){let n=oa(t.selectionsAfter.length?t.selectionsAfter.map((t=>t.map(e))):la,i);if(!t.changes)return sa.selection(n);let s=t.changes.map(e),r=e.mapDesc(t.changes,!0),o=t.mapped?t.mapped.composeDesc(r):r;return new sa(s,ft.mapEffects(t.effects,e),o,t.startSelection.map(r),n)}const da=/^(input\.type|delete)($|\.)/;class pa{constructor(t,e,i=0,n=void 0){this.done=t,this.undone=e,this.prevTime=i,this.prevUserEvent=n}isolate(){return this.prevTime?new pa(this.done,this.undone):this}addChanges(t,e,i,n,s){let r=this.done,o=r[r.length-1];return r=o&&o.changes&&!o.changes.empty&&t.changes&&(!i||da.test(i))&&(!o.selectionsAfter.length&&e-this.prevTimei.push(t,e))),e.iterChangedRanges(((t,e,s,r)=>{for(let t=0;t=e&&s<=o&&(n=!0)}})),n}(o.changes,t.changes))||"input.type.compose"==i)?ra(r,r.length-1,n.minDepth,new sa(t.changes.compose(o.changes),oa(t.effects,o.effects),o.mapped,o.startSelection,la)):ra(r,r.length,n.minDepth,t),new pa(r,la,e,i)}addSelection(t,e,i,n){let s=this.done.length?this.done[this.done.length-1].selectionsAfter:la;return s.length>0&&e-this.prevTimet.empty!=o.ranges[e].empty)).length)?this:new pa(aa(this.done,t),this.undone,e,i);var r,o}addMapping(t){return new pa(ua(this.done,t),ua(this.undone,t),this.prevTime,this.prevUserEvent)}pop(t,e,i){let n=0==t?this.done:this.undone;if(0==n.length)return null;let s=n[n.length-1],r=s.selectionsAfter[0]||e.selection;if(i&&s.selectionsAfter.length)return e.update({selection:s.selectionsAfter[s.selectionsAfter.length-1],annotations:Gh.of({side:t,rest:ca(n),selection:r}),userEvent:0==t?"select.undo":"select.redo",scrollIntoView:!0});if(s.changes){let i=1==n.length?la:n.slice(0,n.length-1);return s.mapped&&(i=ua(i,s.mapped)),e.update({changes:s.changes,selection:s.startSelection,effects:s.effects,annotations:Gh.of({side:t,rest:i,selection:r}),filter:!1,userEvent:0==t?"undo":"redo",scrollIntoView:!0})}return null}}pa.empty=new pa(la,la);const ga=[{key:"Mod-z",run:ta,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:ea,preventDefault:!0},{linux:"Ctrl-Shift-z",run:ea,preventDefault:!0},{key:"Mod-u",run:ia,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:na,preventDefault:!0}];function ma(t,e){return P.create(t.ranges.map(e),t.mainIndex)}function va(t,e){return t.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function wa({state:t,dispatch:e},i){let n=ma(t.selection,i);return!n.eq(t.selection,!0)&&(e(va(t,n)),!0)}function ya(t,e){return P.cursor(e?t.to:t.from)}function ba(t,e){return wa(t,(i=>i.empty?t.moveByChar(i,e):ya(i,e)))}function xa(t){return t.textDirectionAt(t.state.selection.main.head)==exports.Direction.LTR}const ka=t=>ba(t,!xa(t)),Sa=t=>ba(t,xa(t));function Aa(t,e){return wa(t,(i=>i.empty?t.moveByGroup(i,e):ya(i,e)))}function Ma(t,e,i){if(e.type.prop(i))return!0;let n=e.to-e.from;return n&&(n>2||/[^\s,.;:]/.test(t.sliceDoc(e.from,e.to)))||e.firstChild}function Ca(t,e,i){let n,s,r=kl(t).resolveInner(e.head),o=i?mo.closedBy:mo.openedBy;for(let n=e.head;;){let e=i?r.childAfter(n):r.childBefore(n);if(!e)break;Ma(t,e,o)?r=e:n=i?e.to:e.from}return s=r.type.prop(o)&&(n=i?yh(t,r.from,1):yh(t,r.to,-1))&&n.matched?i?n.end.to:n.end.from:i?r.to:r.from,P.cursor(s,i?-1:1)}function Da(t,e){return wa(t,(i=>{if(!i.empty)return ya(i,e);let n=t.moveVertically(i,e);return n.head!=i.head?n:t.moveToLineBoundary(i,e)}))}const Oa=t=>Da(t,!1),Ta=t=>Da(t,!0);function Ea(t){let e,i=t.scrollDOM.clientHeighti.empty?t.moveVertically(i,e,n.height):ya(i,e)));if(r.eq(s.selection))return!1;if(n.selfScroll){let e=t.coordsAtPos(s.selection.main.head),o=t.scrollDOM.getBoundingClientRect(),l=o.top+n.marginTop,h=o.bottom-n.marginBottom;e&&e.top>l&&e.bottomRa(t,!1),Pa=t=>Ra(t,!0);function La(t,e,i){let n=t.lineBlockAt(e.head),s=t.moveToLineBoundary(e,i);if(s.head==e.head&&s.head!=(i?n.to:n.from)&&(s=t.moveToLineBoundary(e,i,!1)),!i&&s.head==n.from&&n.length){let i=/^\s*/.exec(t.state.sliceDoc(n.from,Math.min(n.from+100,n.to)))[0].length;i&&e.head!=n.from+i&&(s=P.cursor(n.from+i))}return s}function Na(t,e){let i=ma(t.state.selection,(t=>{let i=e(t);return P.range(t.anchor,i.head,i.goalColumn,i.bidiLevel||void 0)}));return!i.eq(t.state.selection)&&(t.dispatch(va(t.state,i)),!0)}function Ia(t,e){return Na(t,(i=>t.moveByChar(i,e)))}const Va=t=>Ia(t,!xa(t)),Ha=t=>Ia(t,xa(t));function Wa(t,e){return Na(t,(i=>t.moveByGroup(i,e)))}function za(t,e){return Na(t,(i=>t.moveVertically(i,e)))}const Fa=t=>za(t,!1),qa=t=>za(t,!0);function _a(t,e){return Na(t,(i=>t.moveVertically(i,e,Ea(t).height)))}const Ka=t=>_a(t,!1),ja=t=>_a(t,!0),$a=({state:t,dispatch:e})=>(e(va(t,{anchor:0})),!0),Ua=({state:t,dispatch:e})=>(e(va(t,{anchor:t.doc.length})),!0),Ga=({state:t,dispatch:e})=>(e(va(t,{anchor:t.selection.main.anchor,head:0})),!0),Ja=({state:t,dispatch:e})=>(e(va(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0);function Ya(t,e){if(t.state.readOnly)return!1;let i="delete.selection",{state:n}=t,s=n.changeByRange((n=>{let{from:s,to:r}=n;if(s==r){let o=e(n);os&&(i="delete.forward",o=Xa(t,o,!0)),s=Math.min(s,o),r=Math.max(r,o)}else s=Xa(t,s,!1),r=Xa(t,r,!0);return s==r?{range:n}:{changes:{from:s,to:r},range:P.cursor(s,se(t))))n.between(e,e,((t,n)=>{te&&(e=i?n:t)}));return e}const Qa=(t,e,i)=>Ya(t,(n=>{let s,r,o=n.from,{state:l}=t,h=l.doc.lineAt(o);if(i&&!e&&o>h.from&&oQa(t,!1,!0),tc=t=>Qa(t,!0,!1),ec=(t,e)=>Ya(t,(i=>{let n=i.head,{state:s}=t,r=s.doc.lineAt(n),o=s.charCategorizer(n);for(let t=null;;){if(n==(e?r.to:r.from)){n==i.head&&r.number!=(e?s.doc.lines:1)&&(n+=e?1:-1);break}let l=p(r.text,n-r.from,e)+r.from,h=r.text.slice(Math.min(n,l)-r.from,Math.max(n,l)-r.from),a=o(h);if(null!=t&&a!=t)break;" "==h&&n==i.head||(t=a),n=l}return n})),ic=t=>ec(t,!1);function nc(t){let e=[],i=-1;for(let n of t.selection.ranges){let s=t.doc.lineAt(n.from),r=t.doc.lineAt(n.to);if(n.empty||n.to!=r.from||(r=t.doc.lineAt(n.to-1)),i>=s.number){let t=e[e.length-1];t.to=r.to,t.ranges.push(n)}else e.push({from:s.from,to:r.to,ranges:[n]});i=r.number+1}return e}function sc(t,e,i){if(t.readOnly)return!1;let n=[],s=[];for(let e of nc(t)){if(i?e.to==t.doc.length:0==e.from)continue;let r=t.doc.lineAt(i?e.to+1:e.from-1),o=r.length+1;if(i){n.push({from:e.to,to:r.to},{from:e.from,insert:r.text+t.lineBreak});for(let i of e.ranges)s.push(P.range(Math.min(t.doc.length,i.anchor+o),Math.min(t.doc.length,i.head+o)))}else{n.push({from:r.from,to:e.from},{from:e.to,insert:t.lineBreak+r.text});for(let t of e.ranges)s.push(P.range(t.anchor-o,t.head-o))}}return!!n.length&&(e(t.update({changes:n,scrollIntoView:!0,selection:P.create(s,t.selection.mainIndex),userEvent:"move.line"})),!0)}function rc(t,e,i){if(t.readOnly)return!1;let n=[];for(let e of nc(t))i?n.push({from:e.from,insert:t.doc.slice(e.from,e.to)+t.lineBreak}):n.push({from:e.to,insert:t.lineBreak+t.doc.slice(e.from,e.to)});return e(t.update({changes:n,scrollIntoView:!0,userEvent:"input.copyline"})),!0}const oc=lc(!1);function lc(e){return({state:i,dispatch:n})=>{if(i.readOnly)return!1;let s=i.changeByRange((n=>{let{from:s,to:r}=n,o=i.doc.lineAt(s),l=!e&&s==r&&function(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let i,n=kl(t).resolveInner(e),s=n.childBefore(e),r=n.childAfter(e);return s&&r&&s.to<=e&&r.from>=e&&(i=s.type.prop(mo.closedBy))&&i.indexOf(r.name)>-1&&t.doc.lineAt(s.to).from==t.doc.lineAt(r.from).from&&!/\S/.test(t.sliceDoc(s.to,r.from))?{from:s.to,to:r.from}:null}(i,s);e&&(s=r=(r<=o.to?o:i.doc.lineAt(r)).to);let h=new Vl(i,{simulateBreak:s,simulateDoubleBreak:!!l}),a=Il(h,s);for(null==a&&(a=qt(/^\s*/.exec(i.doc.lineAt(s).text)[0],i.tabSize));ro.from&&s{let s=[];for(let r=n.from;r<=n.to;){let o=t.doc.lineAt(r);o.number>i&&(n.empty||n.to>o.from)&&(e(o,s,n),i=o.number),r=o.to+1}let r=t.changes(s);return{changes:s,range:P.range(r.mapPos(n.anchor,1),r.mapPos(n.head,1))}}))}const ac=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:t=>wa(t,(e=>Ca(t.state,e,!xa(t)))),shift:t=>Na(t,(e=>Ca(t.state,e,!xa(t))))},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:t=>wa(t,(e=>Ca(t.state,e,xa(t)))),shift:t=>Na(t,(e=>Ca(t.state,e,xa(t))))},{key:"Alt-ArrowUp",run:({state:t,dispatch:e})=>sc(t,e,!1)},{key:"Shift-Alt-ArrowUp",run:({state:t,dispatch:e})=>rc(t,e,!1)},{key:"Alt-ArrowDown",run:({state:t,dispatch:e})=>sc(t,e,!0)},{key:"Shift-Alt-ArrowDown",run:({state:t,dispatch:e})=>rc(t,e,!0)},{key:"Escape",run:({state:t,dispatch:e})=>{let i=t.selection,n=null;return i.ranges.length>1?n=P.create([i.main]):i.main.empty||(n=P.create([P.cursor(i.main.head)])),!!n&&(e(va(t,n)),!0)}},{key:"Mod-Enter",run:lc(!0)},{key:"Alt-l",mac:"Ctrl-l",run:({state:t,dispatch:e})=>{let i=nc(t).map((({from:e,to:i})=>P.range(e,Math.min(i+1,t.doc.length))));return e(t.update({selection:P.create(i),userEvent:"select"})),!0}},{key:"Mod-i",run:({state:t,dispatch:e})=>{let i=ma(t.selection,(e=>{var i;for(let n=kl(t).resolveStack(e.from,1);n;n=n.next){let{node:t}=n;if((t.from=e.to||t.to>e.to&&t.from<=e.from)&&(null===(i=t.parent)||void 0===i?void 0:i.parent))return P.range(t.to,t.from)}return e}));return e(va(t,i)),!0},preventDefault:!0},{key:"Mod-[",run:({state:t,dispatch:e})=>!t.readOnly&&(e(t.update(hc(t,((e,i)=>{let n=/^\s*/.exec(e.text)[0];if(!n)return;let s=qt(n,t.tabSize),r=0,o=Nl(t,Math.max(0,s-Ll(t)));for(;r!t.readOnly&&(e(t.update(hc(t,((e,i)=>{i.push({from:e.from,insert:t.facet(Pl)})})),{userEvent:"input.indent"})),!0)},{key:"Mod-Alt-\\",run:({state:t,dispatch:e})=>{if(t.readOnly)return!1;let i=Object.create(null),n=new Vl(t,{overrideIndentation:t=>{let e=i[t];return null==e?-1:e}}),s=hc(t,((e,s,r)=>{let o=Il(n,e.from);if(null==o)return;/\S/.test(e.text)||(o=0);let l=/^\s*/.exec(e.text)[0],h=Nl(t,o);(l!=h||r.from{if(t.state.readOnly)return!1;let{state:e}=t,i=e.changes(nc(e).map((({from:t,to:i})=>(t>0?t--:i{let i;if(t.lineWrapping){let n=t.lineBlockAt(e.head),s=t.coordsAtPos(e.head,e.assoc||1);s&&(i=n.bottom+t.documentTop-s.bottom+t.defaultLineHeight/2)}return t.moveVertically(e,!0,i)})).map(i);return t.dispatch({changes:i,selection:n,scrollIntoView:!0,userEvent:"delete.line"}),!0}},{key:"Shift-Mod-\\",run:({state:t,dispatch:e})=>function(t,e,i){let n=!1,s=ma(t.selection,(e=>{let s=yh(t,e.head,-1)||yh(t,e.head,1)||e.head>0&&yh(t,e.head-1,1)||e.head{let{state:e}=t,i=e.doc.lineAt(e.selection.main.from),n=Kh(t.state,i.from);return n.line?Fh(t):!!n.block&&_h(t)}},{key:"Alt-A",run:qh}].concat([{key:"ArrowLeft",run:ka,shift:Va,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:t=>Aa(t,!xa(t)),shift:t=>Wa(t,!xa(t)),preventDefault:!0},{mac:"Cmd-ArrowLeft",run:t=>wa(t,(e=>La(t,e,!xa(t)))),shift:t=>Na(t,(e=>La(t,e,!xa(t)))),preventDefault:!0},{key:"ArrowRight",run:Sa,shift:Ha,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:t=>Aa(t,xa(t)),shift:t=>Wa(t,xa(t)),preventDefault:!0},{mac:"Cmd-ArrowRight",run:t=>wa(t,(e=>La(t,e,xa(t)))),shift:t=>Na(t,(e=>La(t,e,xa(t)))),preventDefault:!0},{key:"ArrowUp",run:Oa,shift:Fa,preventDefault:!0},{mac:"Cmd-ArrowUp",run:$a,shift:Ga},{mac:"Ctrl-ArrowUp",run:Ba,shift:Ka},{key:"ArrowDown",run:Ta,shift:qa,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Ua,shift:Ja},{mac:"Ctrl-ArrowDown",run:Pa,shift:ja},{key:"PageUp",run:Ba,shift:Ka},{key:"PageDown",run:Pa,shift:ja},{key:"Home",run:t=>wa(t,(e=>La(t,e,!1))),shift:t=>Na(t,(e=>La(t,e,!1))),preventDefault:!0},{key:"Mod-Home",run:$a,shift:Ga},{key:"End",run:t=>wa(t,(e=>La(t,e,!0))),shift:t=>Na(t,(e=>La(t,e,!0))),preventDefault:!0},{key:"Mod-End",run:Ua,shift:Ja},{key:"Enter",run:oc},{key:"Mod-a",run:({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0)},{key:"Backspace",run:Za,shift:Za},{key:"Delete",run:tc},{key:"Mod-Backspace",mac:"Alt-Backspace",run:ic},{key:"Mod-Delete",mac:"Alt-Delete",run:t=>ec(t,!0)},{mac:"Mod-Backspace",run:t=>Ya(t,(e=>{let i=t.moveToLineBoundary(e,!1).head;return e.head>i?i:Math.max(0,e.head-1)}))},{mac:"Mod-Delete",run:t=>Ya(t,(e=>{let i=t.moveToLineBoundary(e,!0).head;return e.headwa(t,(e=>P.cursor(t.lineBlockAt(e.head).from,1))),shift:t=>Na(t,(e=>P.cursor(t.lineBlockAt(e.head).from)))},{key:"Ctrl-e",run:t=>wa(t,(e=>P.cursor(t.lineBlockAt(e.head).to,-1))),shift:t=>Na(t,(e=>P.cursor(t.lineBlockAt(e.head).to)))},{key:"Ctrl-d",run:tc},{key:"Ctrl-h",run:Za},{key:"Ctrl-k",run:t=>Ya(t,(e=>{let i=t.lineBlockAt(e.head).to;return e.head{if(e.readOnly)return!1;let n=e.changeByRange((e=>({changes:{from:e.from,to:e.to,insert:t.of(["",""])},range:P.cursor(e.from)})));return i(e.update(n,{scrollIntoView:!0,userEvent:"input"})),!0}},{key:"Ctrl-t",run:({state:t,dispatch:e})=>{if(t.readOnly)return!1;let i=t.changeByRange((e=>{if(!e.empty||0==e.from||e.from==t.doc.length)return{range:e};let i=e.from,n=t.doc.lineAt(i),s=i==n.from?i-1:p(n.text,i-n.from,!1)+n.from,r=i==n.to?i+1:p(n.text,i-n.from,!0)+n.from;return{changes:{from:s,to:r,insert:t.doc.slice(i,r).append(t.doc.slice(s,i))},range:P.cursor(r)}}));return!i.changes.empty&&(e(t.update(i,{scrollIntoView:!0,userEvent:"move.character"})),!0)}},{key:"Ctrl-v",run:Pa}].map((t=>({mac:t.key,run:t.run,shift:t.shift})))));function cc(){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(;et.normalize("NFKD"):t=>t;class dc{constructor(t,e,i=0,n=t.length,s,r){this.test=r,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=t.iterRange(i,n),this.bufferStart=i,this.normalize=s?t=>s(fc(t)):fc,this.query=this.normalize(e)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return y(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let t=this.peek();if(t<0)return this.done=!0,this;let e=b(t),i=this.bufferStart+this.bufferPos;this.bufferPos+=x(t);let n=this.normalize(e);for(let t=0,s=i;;t++){let r=n.charCodeAt(t),o=this.match(r,s,this.bufferPos+this.bufferStart);if(t==n.length-1){if(o)return this.value=o,this;break}s==i&&tthis.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let t=this.matchPos-this.curLineStart;;){this.re.lastIndex=t;let e=this.matchPos<=this.to&&this.re.exec(this.curLine);if(e){let i=this.curLineStart+e.index,n=i+e[0].length;if(this.matchPos=bc(this.text,n+(i==n?1:0)),i==this.curLineStart+this.curLine.length&&this.nextLine(),(ithis.value.to)&&(!this.test||this.test(i,n,e)))return this.value={from:i,to:n,match:e},this;t=this.matchPos-this.curLineStart}else{if(!(this.curLineStart+this.curLine.length=i||n.to<=e){let n=new wc(e,t.sliceString(e,i));return vc.set(t,n),n}if(n.from==e&&n.to==i)return n;let{text:s,from:r}=n;return r>e&&(s=t.sliceString(e,r)+s,r=e),n.to=this.to?this.to:this.text.lineAt(t).to}next(){for(;;){let t=this.re.lastIndex=this.matchPos-this.flat.from,e=this.re.exec(this.flat.text);if(e&&!e[0]&&e.index==t&&(this.re.lastIndex=t+1,e=this.re.exec(this.flat.text)),e){let t=this.flat.from+e.index,i=t+e[0].length;if((this.flat.to>=this.to||e.index+e[0].length<=this.flat.text.length-10)&&(!this.test||this.test(t,i,e)))return this.value={from:t,to:i,match:e},this.matchPos=bc(this.text,i+(t==i?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=wc.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+2*this.flat.text.length))}}}function bc(t,e){if(e>=t.length)return e;let i,n=t.lineAt(e);for(;e=56320&&i<57344;)e++;return e}function xc(t){let e=cc("input",{class:"cm-textfield",name:"line",value:String(t.state.doc.lineAt(t.state.selection.main.head).number)});function i(){let i=/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(e.value);if(!i)return;let{state:n}=t,s=n.doc.lineAt(n.selection.main.head),[,r,o,l,h]=i,a=l?+l.slice(1):0,c=o?+o:s.number;if(o&&h){let t=c/100;r&&(t=t*("-"==r?-1:1)+s.number/n.doc.lines),c=Math.round(n.doc.lines*t)}else o&&r&&(c=c*("-"==r?-1:1)+s.number);let u=n.doc.line(Math.max(1,Math.min(n.doc.lines,c))),f=P.cursor(u.from+Math.max(0,Math.min(a,u.length)));t.dispatch({effects:[kc.of(!1),js.scrollIntoView(f.from,{y:"center"})],selection:f}),t.focus()}return{dom:cc("form",{class:"cm-gotoLine",onkeydown:e=>{27==e.keyCode?(e.preventDefault(),t.dispatch({effects:kc.of(!1)}),t.focus()):13==e.keyCode&&(e.preventDefault(),i())},onsubmit:t=>{t.preventDefault(),i()}},cc("label",t.state.phrase("Go to line"),": ",e)," ",cc("button",{class:"cm-button",type:"submit"},t.state.phrase("go")))}}"undefined"!=typeof Symbol&&(mc.prototype[Symbol.iterator]=yc.prototype[Symbol.iterator]=function(){return this});const kc=ft.define(),Sc=_.define({create:()=>!0,update(t,e){for(let i of e.effects)i.is(kc)&&(t=i.value);return t},provide:t=>Gr.from(t,(t=>t?xc:null))}),Ac=js.baseTheme({".cm-panel.cm-gotoLine":{padding:"2px 6px 4px","& label":{fontSize:"80%"}}});const Mc=I.define({combine:t=>Mt(t,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:t=>new tu(t),scrollToMatch:t=>js.scrollIntoView(t)})});class Cc{constructor(t){this.search=t.search,this.caseSensitive=!!t.caseSensitive,this.literal=!!t.literal,this.regexp=!!t.regexp,this.replace=t.replace||"",this.valid=!!this.search&&(!this.regexp||function(t){try{return new RegExp(t,gc),!0}catch(t){return!1}}(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!t.wholeWord}unquote(t){return this.literal?t:t.replace(/\\([nrt\\])/g,((t,e)=>"n"==e?"\n":"r"==e?"\r":"t"==e?"\t":"\\"))}eq(t){return this.search==t.search&&this.replace==t.replace&&this.caseSensitive==t.caseSensitive&&this.regexp==t.regexp&&this.wholeWord==t.wholeWord}create(){return this.regexp?new Pc(this):new Tc(this)}getCursor(t,e=0,i){let n=t.doc?t:At.create({doc:t});return null==i&&(i=n.doc.length),this.regexp?Ec(this,n,e,i):Oc(this,n,e,i)}}class Dc{constructor(t){this.spec=t}}function Oc(t,e,i,n){return new dc(e.doc,t.unquoted,i,n,t.caseSensitive?void 0:t=>t.toLowerCase(),t.wholeWord?function(t,e){return(i,n,s,r)=>((r>i||r+s.length=e)return null;n.push(i.value)}return n}highlight(t,e,i,n){let s=Oc(this.spec,t,Math.max(0,e-this.spec.unquoted.length),Math.min(i+this.spec.unquoted.length,t.doc.length));for(;!s.next().done;)n(s.value.from,s.value.to)}}function Ec(t,e,i,n){return new mc(e.doc,t.search,{ignoreCase:!t.caseSensitive,test:t.wholeWord?(s=e.charCategorizer(e.selection.main.head),(t,e,i)=>!i[0].length||(s(Rc(i.input,i.index))!=bt.Word||s(Bc(i.input,i.index))!=bt.Word)&&(s(Bc(i.input,i.index+i[0].length))!=bt.Word||s(Rc(i.input,i.index+i[0].length))!=bt.Word)):void 0},i,n);var s}function Rc(t,e){return t.slice(p(t,e,!1),e)}function Bc(t,e){return t.slice(e,p(t,e))}class Pc extends Dc{nextMatch(t,e,i){let n=Ec(this.spec,t,i,t.doc.length).next();return n.done&&(n=Ec(this.spec,t,0,e).next()),n.done?null:n.value}prevMatchInRange(t,e,i){for(let n=1;;n++){let s=Math.max(e,i-1e4*n),r=Ec(this.spec,t,s,i),o=null;for(;!r.next().done;)o=r.value;if(o&&(s==e||o.from>s+10))return o;if(s==e)return null}}prevMatch(t,e,i){return this.prevMatchInRange(t,0,e)||this.prevMatchInRange(t,i,t.doc.length)}getReplacement(t){return this.spec.unquote(this.spec.replace).replace(/\$([$&\d+])/g,((e,i)=>"$"==i?"$":"&"==i?t.match[0]:"0"!=i&&+i=e)return null;n.push(i.value)}return n}highlight(t,e,i,n){let s=Ec(this.spec,t,Math.max(0,e-250),Math.min(i+250,t.doc.length));for(;!s.next().done;)n(s.value.from,s.value.to)}}const Lc=ft.define(),Nc=ft.define(),Ic=_.define({create:t=>new Vc(Gc(t).create(),null),update(t,e){for(let i of e.effects)i.is(Lc)?t=new Vc(i.value.create(),t.panel):i.is(Nc)&&(t=new Vc(t.query,i.value?Uc:null));return t},provide:t=>Gr.from(t,(t=>t.panel))});class Vc{constructor(t,e){this.query=t,this.panel=e}}const Hc=ri.mark({class:"cm-searchMatch"}),Wc=ri.mark({class:"cm-searchMatch cm-searchMatch-selected"}),zc=Gi.fromClass(class{constructor(t){this.view=t,this.decorations=this.highlight(t.state.field(Ic))}update(t){let e=t.state.field(Ic);(e!=t.startState.field(Ic)||t.docChanged||t.selectionSet||t.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:t,panel:e}){if(!e||!t.spec.valid)return ri.none;let{view:i}=this,n=new Rt;for(let e=0,s=i.visibleRanges,r=s.length;es[e+1].from-500;)l=s[++e].to;t.highlight(i.state,o,l,((t,e)=>{let s=i.state.selection.ranges.some((i=>i.from==t&&i.to==e));n.add(t,e,s?Wc:Hc)}))}return n.finish()}},{decorations:t=>t.decorations});function Fc(t){return e=>{let i=e.state.field(Ic,!1);return i&&i.query.spec.valid?t(e,i):Xc(e)}}const qc=Fc(((t,{query:e})=>{let{to:i}=t.state.selection.main,n=e.nextMatch(t.state,i,i);if(!n)return!1;let s=P.single(n.from,n.to),r=t.state.facet(Mc);return t.dispatch({selection:s,effects:[su(t,n),r.scrollToMatch(s.main,t)],userEvent:"select.search"}),Yc(t),!0})),_c=Fc(((t,{query:e})=>{let{state:i}=t,{from:n}=i.selection.main,s=e.prevMatch(i,n,n);if(!s)return!1;let r=P.single(s.from,s.to),o=t.state.facet(Mc);return t.dispatch({selection:r,effects:[su(t,s),o.scrollToMatch(r.main,t)],userEvent:"select.search"}),Yc(t),!0})),Kc=Fc(((t,{query:e})=>{let i=e.matchAll(t.state,1e3);return!(!i||!i.length)&&(t.dispatch({selection:P.create(i.map((t=>P.range(t.from,t.to)))),userEvent:"select.search.matches"}),!0)})),jc=Fc(((t,{query:e})=>{let{state:i}=t,{from:n,to:s}=i.selection.main;if(i.readOnly)return!1;let r=e.nextMatch(i,n,n);if(!r)return!1;let o,l,h=[],a=[];if(r.from==n&&r.to==s&&(l=i.toText(e.getReplacement(r)),h.push({from:r.from,to:r.to,insert:l}),r=e.nextMatch(i,r.from,r.to),a.push(js.announce.of(i.phrase("replaced match on line $",i.doc.lineAt(n).number)+"."))),r){let e=0==h.length||h[0].from>=r.to?0:r.to-r.from-l.length;o=P.single(r.from-e,r.to-e),a.push(su(t,r)),a.push(i.facet(Mc).scrollToMatch(o.main,t))}return t.dispatch({changes:h,selection:o,effects:a,userEvent:"input.replace"}),!0})),$c=Fc(((t,{query:e})=>{if(t.state.readOnly)return!1;let i=e.matchAll(t.state,1e9).map((t=>{let{from:i,to:n}=t;return{from:i,to:n,insert:e.getReplacement(t)}}));if(!i.length)return!1;let n=t.state.phrase("replaced $ matches",i.length)+".";return t.dispatch({changes:i,effects:js.announce.of(n),userEvent:"input.replace.all"}),!0}));function Uc(t){return t.state.facet(Mc).createPanel(t)}function Gc(t,e){var i,n,s,r,o;let l=t.selection.main,h=l.empty||l.to>l.from+100?"":t.sliceDoc(l.from,l.to);if(e&&!h)return e;let a=t.facet(Mc);return new Cc({search:(null!==(i=null==e?void 0:e.literal)&&void 0!==i?i:a.literal)?h:h.replace(/\n/g,"\\n"),caseSensitive:null!==(n=null==e?void 0:e.caseSensitive)&&void 0!==n?n:a.caseSensitive,literal:null!==(s=null==e?void 0:e.literal)&&void 0!==s?s:a.literal,regexp:null!==(r=null==e?void 0:e.regexp)&&void 0!==r?r:a.regexp,wholeWord:null!==(o=null==e?void 0:e.wholeWord)&&void 0!==o?o:a.wholeWord})}function Jc(t){let e=Kr(t,Uc);return e&&e.dom.querySelector("[main-field]")}function Yc(t){let e=Jc(t);e&&e==t.root.activeElement&&e.select()}const Xc=t=>{let e=t.state.field(Ic,!1);if(e&&e.panel){let i=Jc(t);if(i&&i!=t.root.activeElement){let n=Gc(t.state,e.query.spec);n.valid&&t.dispatch({effects:Lc.of(n)}),i.focus(),i.select()}}else t.dispatch({effects:[Nc.of(!0),e?Lc.of(Gc(t.state,e.query.spec)):ft.appendConfig.of(ou)]});return!0},Qc=t=>{let e=t.state.field(Ic,!1);if(!e||!e.panel)return!1;let i=Kr(t,Uc);return i&&i.dom.contains(t.root.activeElement)&&t.focus(),t.dispatch({effects:Nc.of(!1)}),!0},Zc=[{key:"Mod-f",run:Xc,scope:"editor search-panel"},{key:"F3",run:qc,shift:_c,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:qc,shift:_c,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:Qc,scope:"editor search-panel"},{key:"Mod-Shift-l",run:({state:t,dispatch:e})=>{let i=t.selection;if(i.ranges.length>1||i.main.empty)return!1;let{from:n,to:s}=i.main,r=[],o=0;for(let e=new dc(t.doc,t.sliceDoc(n,s));!e.next().done;){if(r.length>1e3)return!1;e.value.from==n&&(o=r.length),r.push(P.range(e.value.from,e.value.to))}return e(t.update({selection:P.create(r,o),userEvent:"select.search.matches"})),!0}},{key:"Mod-Alt-g",run:t=>{let e=Kr(t,xc);if(!e){let i=[kc.of(!0)];null==t.state.field(Sc,!1)&&i.push(ft.appendConfig.of([Sc,Ac])),t.dispatch({effects:i}),e=Kr(t,xc)}return e&&e.dom.querySelector("input").select(),!0}},{key:"Mod-d",run:({state:t,dispatch:e})=>{let{ranges:i}=t.selection;if(i.some((t=>t.from===t.to)))return(({state:t,dispatch:e})=>{let{selection:i}=t,n=P.create(i.ranges.map((e=>t.wordAt(e.head)||P.cursor(e.head))),i.mainIndex);return!n.eq(i)&&(e(t.update({selection:n})),!0)})({state:t,dispatch:e});let n=t.sliceDoc(i[0].from,i[0].to);if(t.selection.ranges.some((e=>t.sliceDoc(e.from,e.to)!=n)))return!1;let s=function(t,e){let{main:i,ranges:n}=t.selection,s=t.wordAt(i.head),r=s&&s.from==i.from&&s.to==i.to;for(let i=!1,s=new dc(t.doc,e,n[n.length-1].to);;){if(s.next(),!s.done){if(i&&n.some((t=>t.from==s.value.from)))continue;if(r){let e=t.wordAt(s.value.from);if(!e||e.from!=s.value.from||e.to!=s.value.to)continue}return s.value}if(i)return null;s=new dc(t.doc,e,0,Math.max(0,n[n.length-1].from-1)),i=!0}}(t,n);return!!s&&(e(t.update({selection:t.selection.addRange(P.range(s.from,s.to),!1),effects:js.scrollIntoView(s.to)})),!0)},preventDefault:!0}];class tu{constructor(t){this.view=t;let e=this.query=t.state.field(Ic).query.spec;function i(t,e,i){return cc("button",{class:"cm-button",name:t,onclick:e,type:"button"},i)}this.commit=this.commit.bind(this),this.searchField=cc("input",{value:e.search,placeholder:eu(t,"Find"),"aria-label":eu(t,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=cc("input",{value:e.replace,placeholder:eu(t,"Replace"),"aria-label":eu(t,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=cc("input",{type:"checkbox",name:"case",form:"",checked:e.caseSensitive,onchange:this.commit}),this.reField=cc("input",{type:"checkbox",name:"re",form:"",checked:e.regexp,onchange:this.commit}),this.wordField=cc("input",{type:"checkbox",name:"word",form:"",checked:e.wholeWord,onchange:this.commit}),this.dom=cc("div",{onkeydown:t=>this.keydown(t),class:"cm-search"},[this.searchField,i("next",(()=>qc(t)),[eu(t,"next")]),i("prev",(()=>_c(t)),[eu(t,"previous")]),i("select",(()=>Kc(t)),[eu(t,"all")]),cc("label",null,[this.caseField,eu(t,"match case")]),cc("label",null,[this.reField,eu(t,"regexp")]),cc("label",null,[this.wordField,eu(t,"by word")]),...t.state.readOnly?[]:[cc("br"),this.replaceField,i("replace",(()=>jc(t)),[eu(t,"replace")]),i("replaceAll",(()=>$c(t)),[eu(t,"replace all")])],cc("button",{name:"close",onclick:()=>Qc(t),"aria-label":eu(t,"close"),type:"button"},["×"])])}commit(){let t=new Cc({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});t.eq(this.query)||(this.query=t,this.view.dispatch({effects:Lc.of(t)}))}keydown(t){var e,i,n;e=this.view,i=t,n="search-panel",sr(er(e.state),i,e,n)?t.preventDefault():13==t.keyCode&&t.target==this.searchField?(t.preventDefault(),(t.shiftKey?_c:qc)(this.view)):13==t.keyCode&&t.target==this.replaceField&&(t.preventDefault(),jc(this.view))}update(t){for(let e of t.transactions)for(let t of e.effects)t.is(Lc)&&!t.value.eq(this.query)&&this.setQuery(t.value)}setQuery(t){this.query=t,this.searchField.value=t.search,this.replaceField.value=t.replace,this.caseField.checked=t.caseSensitive,this.reField.checked=t.regexp,this.wordField.checked=t.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(Mc).top}}function eu(t,e){return t.state.phrase(e)}const iu=30,nu=/[\s\.,:;?!]/;function su(t,{from:e,to:i}){let n=t.state.doc.lineAt(e),s=t.state.doc.lineAt(i).to,r=Math.max(n.from,e-iu),o=Math.min(s,i+iu),l=t.state.sliceDoc(r,o);if(r!=n.from)for(let t=0;tl.length-iu;t--)if(!nu.test(l[t-1])&&nu.test(l[t])){l=l.slice(0,t);break}return js.announce.of(`${t.state.phrase("current match")}. ${l} ${t.state.phrase("on line")} ${n.number}.`)}const ru=js.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),ou=[Ic,J.low(zc),ru];exports.Decoration=ri,exports.EditorSelection=P,exports.EditorState=At,exports.EditorView=js,exports.HighlightStyle=eh,exports.LanguageSupport=class{constructor(t,e=[]){this.language=t,this.support=e,this.extension=[t,e]}},exports.Prec=J,exports.RangeSetBuilder=Rt,exports.StateEffect=ft,exports.StateField=_,exports.StreamLanguage=Mh,exports.Tag=$o,exports.ViewPlugin=Gi,exports._classPrivateGetter=function(t,e,i){return i(function(t,e,i){if("function"==typeof t?t===e:t.has(e))return arguments.length<3?e:i;throw new TypeError("Private element is not present on this object")}(t,e))},exports._classPrivateMethodInitSpec=function(t,e){!function(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")}(t,e),e.add(t)},exports.bracketMatching=function(t={}){return[ch.of(t),gh]},exports.codeFolding=function(t){let e=[Ul,th];return t&&e.push(Yl.of(t)),e},exports.crosshairCursor=function(t={}){let[e,i]=Br[t.key||"Alt"],n=Gi.fromClass(class{constructor(t){this.view=t,this.isDown=!1}set(t){this.isDown!=t&&(this.isDown=t,this.view.update([]))}},{eventObservers:{keydown(t){this.set(t.keyCode==e||i(t))},keyup(t){t.keyCode!=e&&i(t)||this.set(!1)},mousemove(t){this.set(i(t))}}});return[n,js.contentAttributes.of((t=>{var e;return(null===(e=t.plugin(n))||void 0===e?void 0:e.isDown)?Pr:null}))]},exports.defaultKeymap=ac,exports.drawSelection=function(t={}){return[fr.of(t),pr,mr,wr,zi.of(!0)]},exports.ensureSyntaxTree=function(t,e,i=50){var n;let s=null===(n=t.field(bl.state,!1))||void 0===n?void 0:n.context;if(!s)return null;let r=s.viewport;s.updateViewport({from:0,to:e});let o=s.isDone(e)||s.work(i,e)?s.tree:null;return s.updateViewport(r),o},exports.foldEffect=jl,exports.foldedRanges=function(t){return t.field(Ul,!1)||Et.empty},exports.highlightSpecialChars=function(t={}){return[Mr.of(t),Cr||(Cr=Gi.fromClass(class{constructor(t){this.view=t,this.decorations=ri.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(t.state.facet(Mr)),this.decorations=this.decorator.createDeco(t)}makeDecorator(t){return new br({regexp:t.specialChars,decoration:(e,i,n)=>{let{doc:s}=i.state,r=y(e[0],0);if(9==r){let t=s.lineAt(n),e=i.state.tabSize,r=qt(t.text,e,n-t.from);return ri.replace({widget:new Or((e-r%e)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[r]||(this.decorationCache[r]=ri.replace({widget:new Dr(t,r)}))},boundary:t.replaceTabs?void 0:/[^]/})}update(t){let e=t.state.facet(Mr);t.startState.facet(Mr)!=e?(this.decorator=this.makeDecorator(e),this.decorations=this.decorator.createDeco(t.view)):this.decorations=this.decorator.updateDeco(t,this.decorations)}},{decorations:t=>t.decorations}))]},exports.history=function(t={}){return[Qh,Xh.of(t),js.domEventHandlers({beforeinput(t,e){let i="historyUndo"==t.inputType?ta:"historyRedo"==t.inputType?ea:null;return!!i&&(t.preventDefault(),i(e))}})]},exports.historyKeymap=ga,exports.keymap=Zs,exports.lineNumbers=function(t={}){return[lo.of(t),Zr(),co]},exports.openSearchPanel=Xc,exports.rectangularSelection=function(t){let e=(null==t?void 0:t.eventFilter)||(t=>t.altKey&&0==t.button);return js.mouseSelectionStyle.of(((t,i)=>e(i)?Rr(t,i):null))},exports.redo=ea,exports.search=function(t){return t?[Mc.of(t),ou]:ou},exports.searchKeymap=Zc,exports.showTooltip=qr,exports.syntaxHighlighting=function(t,e){let i,n=[oh];return t instanceof eh&&(t.module&&n.push(js.styleModule.of(t.module)),i=t.themeType),(null==e?void 0:e.fallback)?n.push(nh.of(t)):i?n.push(ih.computeN([js.darkTheme],(e=>e.facet(js.darkTheme)==("dark"==i)?[t]:[]))):n.push(ih.of(t)),n},exports.syntaxTree=kl,exports.tags=ml,exports.unfoldAll=t=>{let e=t.state.field(Ul,!1);if(!e||!e.size)return!1;let i=[];return e.between(0,t.state.doc.length,((t,e)=>{i.push($l.of({from:t,to:e}))})),t.dispatch({effects:i}),!0},exports.unfoldEffect=$l; diff --git a/resources/ext.CodeMirror.v6.less b/resources/ext.CodeMirror.v6.less index 50f19ae..bece762 100644 --- a/resources/ext.CodeMirror.v6.less +++ b/resources/ext.CodeMirror.v6.less @@ -25,20 +25,20 @@ unicode-bidi: isolate; } -.cm-scroller .cm-content { - padding: 0; +.cm-scroller { + line-height: inherit !important; + + .cm-content { + padding: 0; + } } .cm-content .cm-line { - line-height: 21px; + line-height: inherit; white-space-collapse: preserve; padding: 0; } -.cm-gutters .cm-lineNumbers .cm-gutterElement { - padding: 1.5px 3px 0 5px; -} - // Hide all buttons except CodeMirror on read only pages (T301615) // This is the same hack that CodeEditor uses to customize the toolbar. // WikiEditor should be updated to better handle read only pages (T188817). diff --git a/resources/modules/ve-cm/ve.ui.CodeMirror.v6.less b/resources/modules/ve-cm/ve.ui.CodeMirror.v6.less index 111c2cd..04b66bc 100644 --- a/resources/modules/ve-cm/ve.ui.CodeMirror.v6.less +++ b/resources/modules/ve-cm/ve.ui.CodeMirror.v6.less @@ -7,7 +7,7 @@ .cm-editor { height: 100%; - z-index: -1; + z-index: 1; position: absolute !important; top: 0; left: 0; @@ -52,11 +52,6 @@ .cm-gutters { border-right: 0; - padding-right: 8px; - - .skin-fandomdesktop & { - padding-right: 7px; - } .cm-gutter { .cm-gutterElement { @@ -99,10 +94,6 @@ line-break: initial; } - .ve-ce-paragraphNode { - margin-left: 6px !important; /* stylelint-disable-line declaration-no-important */ - } - .cm-activeLineGutter { background-color: transparent; border-right: 0; diff --git a/src/modules/ve-cm/ve.ui.CodeMirrorAction.js b/src/modules/ve-cm/ve.ui.CodeMirrorAction.js index 9581d68..9724776 100644 --- a/src/modules/ve-cm/ve.ui.CodeMirrorAction.js +++ b/src/modules/ve-cm/ve.ui.CodeMirrorAction.js @@ -51,18 +51,21 @@ ve.ui.CodeMirrorAction.prototype.toggle = function ( enable ) { surface.mirror = window.VisualEditorCodeMirror = new CodeMirrorVisualEditor( surface, mediaWikiLang() ); surface.mirror.enableCodeMirror(); - const guttersWidth = parseInt( document.querySelector( '.cm-gutters' ).offsetWidth ); - surfaceView.$documentNode.css( 'margin-left', guttersWidth - 5 ); + // Set correct margin on documentNode after initialization + action.onTransact(); /* Events */ // As the action is regenerated each time, we need to store bound listeners // in the mirror for later disconnection. surface.mirror.veTransactionListener = action.onDocumentPrecommit.bind( action ); + surface.mirror.vePostTransactionListener = action.onTransact.bind( action ); doc.on( 'precommit', surface.mirror.veTransactionListener ); + doc.on( 'transact', surface.mirror.vePostTransactionListener ); } else if ( surface.mirror && enable !== true ) { doc.off( 'precommit', surface.mirror.veTransactionListener ); + doc.off( 'transact', surface.mirror.vePostTransactionListener ); surfaceView.$element.removeClass( 'mw-editfont-monospace' ).addClass( 'mw-editfont-' + mw.user.options.get( 'editfont' ) ); surfaceView.$documentNode.removeClass( @@ -114,11 +117,6 @@ ve.ui.CodeMirrorAction.prototype.onDocumentPrecommit = function ( tx ) { store = this.surface.getModel().getDocument().getStore(), codeMirrorView = this.surface.mirror.view; - const documentNode = document.querySelector( '.ve-ce-documentNode' ); - const guttersWidth = parseInt( document.querySelector( '.cm-gutters' ).offsetWidth ); - - documentNode.style.marginLeft = ( guttersWidth - 5 ) + 'px'; - tx.operations.forEach( function ( op ) { if ( op.type === 'retain' ) { offset += op.length; @@ -145,6 +143,12 @@ ve.ui.CodeMirrorAction.prototype.onDocumentPrecommit = function ( tx ) { } }; +ve.ui.CodeMirrorAction.prototype.onTransact = function () { + const surfaceView = this.surface.getView(); + const guttersTrueWidth = surfaceView.$element.find( '.cm-gutters' ).outerWidth( true ); + surfaceView.$documentNode.css( 'margin-left', `${ guttersTrueWidth }px` ); +}; + /** * Convert a VE offset to a 2D CodeMirror position *