mediawiki-extensions-CodeMi.../resources/dist/main.js.map.json
MusikAnimal 880c690a10 CodeMirror6: add new modules, feature flag, and URL query parameter
Add a new $wgCodeMirrorV6 temporary feature flag that when enabled,
will load the 'ext.CodeMirror.v6.WikiEditor' module that is built
against CodeMirror 6. You can also pass in the ?cm6enable=1 query
parameter to force use of CodeMirror 6. This is currently only
implemented for the 2010 editor.

Due to packaging constraints with CodeMirror 6, we now use Webpack to
bundle the files, which are then used by ResourceLoader. This is similar
to what is done for Extension:Popups, MobileFrontend, among other
extensions.

A new generic class CodeMirror can be used on other areas where syntax
highlighting is desirable, but not necessarily for editing (i.e. without
WikiEditor).

This commit merely lays the foundation for CodeMirror 6 and updates
WikiEditor to use it. The actual MediaWiki syntax highlighting will come
with a future commit.

With the new Webpack build, the Gruntfile was removed and the tasks
moved to npm commands.

Bug: T317243
Change-Id: I2239d2449b2db3b638551f847eb4eff1aafa6276
2023-10-09 19:51:24 -04:00

1 line
1.3 MiB
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{"version":3,"sources":["/w/extensions/CodeMirror/webpack/bootstrap","/w/extensions/CodeMirror/./node_modules/@codemirror/state/dist/index.js","/w/extensions/CodeMirror/./node_modules/style-mod/src/style-mod.js","/w/extensions/CodeMirror/./node_modules/w3c-keyname/index.js","/w/extensions/CodeMirror/./node_modules/@codemirror/view/dist/index.js","/w/extensions/CodeMirror/./src/codemirror.js","/w/extensions/CodeMirror/./node_modules/@lezer/common/dist/index.js","/w/extensions/CodeMirror/./node_modules/@lezer/highlight/dist/index.js","/w/extensions/CodeMirror/./node_modules/@codemirror/language/dist/index.js","/w/extensions/CodeMirror/./node_modules/@codemirror/commands/dist/index.js","/w/extensions/CodeMirror/./node_modules/crelt/index.js","/w/extensions/CodeMirror/./node_modules/@codemirror/search/dist/index.js","/w/extensions/CodeMirror/./src/codemirror.wikieditor.js","/w/extensions/CodeMirror/./src/codemirror.wikieditor.init.js"],"names":["installedModules","__webpack_require__","moduleId","exports","module","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","Text","pos","this","length","RangeError","lineInner","lines","from","to","text","parts","decompose","TextNode","other","replace","start","scanIdentical","end","a","RawTextCursor","b","skip","next","lineBreak","done","dir","PartialTextCursor","inner","iter","line","iterRange","Math","max","LineCursor","sliceString","flatten","TextLeaf","split","empty","textLength","super","target","isLine","offset","string","Line","open","sliceText","min","prev","pop","joined","appendText","slice","push","mid","newLen","lineSep","result","part","len","children","child","endLine","childOpen","updated","totalLines","copy","iA","iB","eA","eB","chA","chB","reduce","ch","flat","chunk","maxChunk","minChunk","chunked","currentLines","currentLen","currentChunk","add","last","node","flush","concat","first","nodes","offsets","top","offsetValue","size","nextInner","cursor","limit","afterBreak","iterator","number","map","parseInt","isExtendingChar","code","isRegionalIndicator","findClusterBreak","str","forward","includeExtending","nextClusterBreak","prevClusterBreak","surrogateLow","charCodeAt","surrogateHigh","codePointAt","codePointSize","countBefore","found","code0","code1","DefaultSplit","MapMode","ChangeDesc","sections","ins","f","posA","posB","individual","iterChanges","composeSets","before","mapSet","assoc","Simple","endA","TrackDel","TrackBefore","TrackAfter","json","Array","isArray","some","ChangeSet","inserted","doc","fromA","toA","fromB","_toB","index","ranges","resultSections","resultInserted","filteredSections","SectionIter","addSection","off","addInsert","changes","filtered","toJSON","total","force","set","compose","process","spec","sub","insert","insText","of","insLen","e","forceJoin","values","append","desc","endB","setA","setB","mkSet","piece","createSet","Error","left","len2","sectionLen","insB","textBit","forward2","undefined","SelectionRange","flags","level","change","mapPos","anchor","EditorSelection","range","head","abs","mainIndex","eq","main","which","fromJSON","normalized","bidiLevel","goalColumn","sort","indexOf","splice","checkSelection","selection","docLength","nextID","Facet","combine","compareInput","compare","isStatic","enables","id","default","extensions","config","sameArray","static","FacetProvider","deps","field","x","compute","state","every","dependencies","facet","type","addresses","_a","idx","multi","depDoc","depSel","depAddrs","dep","tr","docChanged","ensureAll","newVal","compareArray","reconfigure","oldState","oldAddr","address","oldVal","getAddr","StateField","addrs","changed","addr","ensureAddr","dynamicFacetSlot","providers","providerAddrs","providerTypes","dynamic","filter","val","depChanged","oldProviders","facets","oldValue","initField","define","createF","updateF","compareF","provides","update","provide","init","find","Prec_","prec","ext","PrecExtension","Prec","highest","high","low","lowest","Compartment","CompartmentInstance","content","compartment","extension","compartments","Configuration","base","dynamicSlots","staticValues","statusTemplate","fields","newCompartments","Map","seen","known","delete","has","slot","oldFacets","dynamicSlot","status","computeSlot","languageData","allowMultipleSelections","v","lineSeparator","changeFilter","transactionFilter","transactionExtender","readOnly","Annotation","AnnotationType","StateEffectType","StateEffect","mapping","mapped","effects","effect","appendConfig","Transaction","startState","annotations","scrollIntoView","_doc","_state","newLength","time","Date","now","apply","applyTransaction","ann","event","annotation","userEvent","joinRanges","mergeTransaction","sequential","mapForA","mapForB","mapDesc","mapEffects","resolveTransactionInner","docSize","sel","asArray","single","resolveTransaction","specs","seq","extenders","keys","extendTransaction","back","invertedDesc","filters","filterTransaction","addToHistory","remote","none","CharCategory","nonASCIISingleCaseWordChar","wordChar","RegExp","_","makeCategorizer","wordChars","char","test","Space","toUpperCase","toLowerCase","hasWordChar","Word","Other","EditorState","require","startValues","conf","is","forEach","resolve","newDoc","newSelection","toText","changeByRange","result1","newChanges","newMapped","j","mapBy","sliceDoc","prop","fieldInit","configuration","staticFacet","asSingle","tabSize","phrase","phrases","side","provider","at","languageDataAt","join","lineAt","cat","charCategorizer","combineConfig","configs","defaults","current","kA","kB","k","RangeValue","Range","startSide","endSide","point","mapMode","cmpRange","Chunk","maxPoint","startAt","arr","lo","hi","diff","findIndex","newPos","newFrom","newTo","curFrom","curTo","RangeSet","chunkPos","nextLayer","chunkEnd","isEmpty","updateSpec","filterFrom","filterTo","cur","LayerCursor","goto","spill","builder","RangeSetBuilder","addInner","rangeIndex","chunkIndex","addChunk","nextChunk","finishInner","chunks","touch","touchesRange","between","HeapCursor","sets","oldSets","newSets","textDiff","comparator","minPointSize","sharedChunks","findSharedChunks","sideA","SpanCursor","sideB","iterGaps","sameValues","active","openRanges","openStart","activeForPoint","openCount","pointFrom","pointRank","openEnd","span","build","lazySort","finish","newArrays","chunkStart","setMaxPoint","lastFrom","lastTo","finishChunk","inA","shared","Set","layer","minPoint","rank","gotoInner","setRangeIndex","heap","heapBubble","childIndex","activeTo","activeRank","minActive","removeActive","remove","findMinIndex","trackOpen","wasPoint","nextVal","addActive","reverse","startA","startB","dPos","clipEnd","comparePoint","compareRange","array","foundPos","countColumn","findColumn","col","strict","COUNT","for","SET","floor","random","globalThis","window","StyleModule","options","rules","splitSelector","selector","render","selectors","isKeyframes","local","isAt","exec","keyframes","toString","root","nonce","setNonce","StyleSet","mount","adoptedSet","ownerDocument","win","defaultView","adoptedStyleSheets","CSSStyleSheet","adopted","sheet","styleTag","createElement","setAttribute","insertBefore","firstChild","mod","insertRule","getRules","textContent","getAttribute","8","9","10","12","13","16","17","18","20","27","32","33","34","35","36","37","38","39","40","44","45","46","59","61","91","92","106","107","108","109","110","111","144","145","160","161","162","163","164","165","173","186","187","188","189","190","191","192","219","220","221","222","shift","48","49","50","51","52","53","54","55","56","57","mac","navigator","platform","ie","userAgent","String","fromCharCode","getSelection","nodeType","contains","dom","parentNode","hasSelection","anchorNode","clientRectsFor","textRange","nodeValue","getClientRects","isEquivalentPosition","targetNode","targetOff","scanFor","domIndex","previousSibling","maxOffset","nodeName","parent","childNodes","contentEditable","flattenRect","rect","right","bottom","windowRect","innerWidth","innerHeight","DOMSelectionState","anchorOffset","focusNode","focusOffset","domSel","scratchRange","preventScrollSupported","focusPreventScroll","setActive","focus","stack","scrollTop","scrollLeft","preventScroll","elt","document","createRange","setEnd","setStart","dispatchKey","keyCode","cancelable","down","KeyboardEvent","synthetic","dispatchEvent","up","defaultPrevented","clearAttributes","attributes","removeAttributeNode","isScrolledToBottom","scrollHeight","clientHeight","DOMPos","precise","noChildren","ContentView","posBefore","posAtStart","view","breakAfter","track","nextSibling","contentView","canReuseDOM","reuseDOM","sync","written","rm$1","_dom","after","bias","lastChild","fromI","fromStart","toI","toEnd","prevEnd","domBoundsAround","startDOM","endDOM","andParent","markParentsDirty","childList","cmView","markDirty","destroy","setParent","_rec","_event","ChildCursor","childCursor","findPos","constructor","source","hasStart","removeChild","replaceRange","fromOff","toOff","breakAtStart","breakAtEnd","merge","become","replaceChildren","mergeChildrenInto","dLen","nav","vendor","documentElement","style","ie_edge","ie_upto10","ie_11up","gecko","chrome","webkit","safari","ios","maxTouchPoints","browser","windows","linux","ie_version","documentMode","gecko_version","chrome_version","android","webkit_version","TextView","textDOM","setDOM","createTextNode","createDOM","_from","_to","rects","width","textCoords","MarkView","mark","class","className","attrs","tagName","setAttrs","_hasStart","detachFrom","inlineDOMAtPos","coordsInChildren","widget","prevWidget","updateDOM","toDOM","ignoreEvent","custom","coordsAt","fromBack","isHidden","getBoundingClientRect","getSide","domAtPos","beforePos","afterPos","scan","fallbackRect","combineAttrs","noAttrs","attrsEq","ignore","keysA","keysB","updateAttrs","cssText","removeAttribute","getAttrs","attr","WidgetType","BlockType","MarkDecoration","block","inlineOrder","isBlockGap","getInclusive","LineDecoration","estimatedHeight","_b","isReplace","WidgetRange","WidgetBefore","WidgetAfter","lineBreaks","inclusiveStart","inclusiveEnd","inclusive","addRange","margin","LineView","arguments","prevAttrs","transferDOM","setDeco","childPos","joinInlineInto","deco","cls","classList","isEditable","hack","cmIgnore","appendChild","textHeight","totalWidth","height","lineHeight","charWidth","heightOracle","viewState","dist","_other","docView","_takeDeco","posAtEnd","disallowBlockEffectsFor","curLine","pendingBuffer","bufferMarks","atCursorPos","textOff","wrapMarks","flushBuffer","posCovered","getLine","take","buildText","addBlockWidget","NullWidget","cursorBefore","cursorAfter","addLineDeco","decorations","dynamicDecorationMap","spans","tag","clickAddsSelectionRange","dragMovesSelection$1","mouseSelectionStyle","exceptionSink","updateListener","inputHandler","focusChangeEffect","perLineTextDirection","nativeSelectionHidden","ScrollTarget","y","yMargin","xMargin","logException","exception","context","handler","onerror","console","error","editable","nextPluginID","viewPlugin","ViewPlugin","domEventHandlers","buildExtensions","eventHandlers","plugin","pluginInst","PluginInstance","mustUpdate","deactivate","editorAttributes","contentAttributes","atomicRanges","bidiIsolatedRanges","getIsolatedRanges","isolates","Function","iso","bidiIsolate","direction","scrollMargins","getScrollMargins","styleModule","ChangedRange","toB","me","dI","rI","addToSet","transactions","changedRanges","iterChangedRanges","Direction","LTR","RTL","dec","LowTypes","ArabicTypes","Brackets","BracketStack","BidiRE","BidiSpan","order","maybe","isolatesEq","types","computeSectionOrder","baseLevel","outerType","rFrom","rTo","iI","prevType","prevStrong","computeCharTypes","oppositeType","sI","br","sJ","embed","processBracketPairs","beforeL","jI","fromJ","processNeutrals","emitSpans","ourType","iCh","sameDir","isNum","recurse","localLevel","iScan","run","upto","computeOrder","trivialOrder","movedOver","moveVisually","startIndex","spanI","indexForward","nextIndex","nextSpan","domChanged","hasComposition","markedForComposition","minWidth","minWidthFrom","minWidthTo","impreciseAnchor","impreciseHead","forceSelection","lastUpdate","contentDOM","updateDeco","updateInner","readCompositionAt","inputState","composing","newSel","composition","touched","touchesComposition","selectionSet","headPos","findCompositionNode","textNode","inv","marks","parentView","findCompositionRange","clear","decoDiff","comp","findChangedDeco","extendWithRanges","oldLength","mustMeasureContent","updateChildren","observer","contentHeight","scaleY","flexBasis","selectionRange","cView","gaps","viewport","BlockGapWidget","updateGaps","compLine","compositionView","fixCompositionDOM","fix","mustRead","fromPointer","readSelectionRange","activeElt","activeElement","focused","selectionNotFocus","moveToLine","dummy","inside","assignedSlot","inUneditable","blur","rawSel","nextTo","nearbyTextNode","collapse","caretBidiLevel","extend","removeAllRanges","setSelectionRange","modify","lineStart","newRange","posFromDOM","domView","rootView","nearest","localPosFromDOM","childOff","contentWidth","clientWidth","isWider","scrollDOM","widest","ltr","textDirection","childRect","getComputedStyle","measure","measureTextSize","position","vs","viewports","lineBlockAt","allDeco","computeBlockGapDeco","lineGapDeco","margins","targetRect","stop","bounding","body","scaleX","scrollWidth","offsetWidth","offsetHeight","moveX","moveY","rectHeight","boundingHeight","scrollBy","movedX","movedY","host","scrollRectIntoView","startNode","startOffset","getdx","getdy","yOverlap","upTop","upBot","domPosInText","closestOffset","closestDY","generalSide","dy","posAtCoords","coords","docTop","paddingTop","docHeight","yOffset","halfLine","bounced","elementAtHeight","posAtCoordsImprecise","elementFromPoint","element","caretPositionFromPoint","offsetNode","caretRangeFromPoint","startContainer","isSuspiciousSafariCaretResult","isSuspiciousChromeCaretResult","domPosAtCoords","closest","closestRect","closestX","closestY","above","below","aboveRect","belowRect","closestOverlap","dx","clipX","isWidget","contentRect","into","round","defaultCharacterWidth","lineWrapping","defaultLineHeight","lineLength","blockAt","moveByChar","by","bidiSpans","textDirectionAt","check","skipAtomicRanges","atoms","moved","skipAtoms","oldPos","InputState","origin","lastSelectionOrigin","lastSelectionTime","lastKeyCode","lastKeyTime","lastTouchTime","lastFocusTime","lastScrollTop","lastScrollLeft","chromeScrollHack","pendingIOSKey","lastEscPress","lastContextMenu","scrollHandlers","registeredEvents","customHandlers","compositionFirstChange","compositionEndedAt","compositionPendingKey","compositionPendingChange","mouseSelection","handleEvent","ignoreDuringComposition","keydown","mustFlushObserver","forceFlush","runCustomHandlers","preventDefault","handlers","addEventListener","eventBelongsToEditor","handlerOptions","clientY","mousedown","button","minHeight","setTimeout","drop","pointerEvents","clearTimeout","passive","notifiedFocused","hasFocus","appliedFirefoxHack","plugins","scroll","modifierCodes","delayAndroidKey","pending","altKey","metaKey","PendingKeys","ctrlKey","EmacsyPendingKeys","shiftKey","flushIOSKey","inputType","dragScrollSpeed","startEvent","mustSelect","scrollSpeed","scrolling","lastEvent","scrollParent","scrollableParent","move","multiple","addsSelectionRange","dragging","rangeCount","getRangeAt","clientX","isInPrimarySelection","getClickType","select","buttons","sx","sy","setScrollSpeed","removeEventListener","setInterval","clearInterval","dispatch","bubbles","brokenClipboardAPI","doPaste","input","byLine","lastLinewiseCopy","lastLine","replaceSelection","rangeForClick","categorize","linePos","groupAt","visual","setSelectionOrigin","touchstart","touchmove","makeStyle","queryPos","startSel","removed","startRange","removeRangeAround","basicMouseSelection","mustFocus","startMouseSelection","insideY","findPositionSide","BadMouseDetail","lastMouseDown","lastMouseDownCount","lastMouseDownTime","detail","lastTime","dropText","direct","dropPos","del","dragMovesSelection","dragstart","dataTransfer","setData","effectAllowed","files","read","finishFile","reader","FileReader","onload","readAsText","getData","paste","data","clipboardData","capturePaste","cut","linewise","copiedRange","clearData","selectionEnd","selectionStart","captureCopy","isFocusChange","focusChangeTransaction","getEffect","updateForFocusChange","clearSelectionRange","compositionstart","compositionupdate","compositionend","pendingRecords","flushSoon","Promise","then","contextmenu","beforeinput","startViewHeight","visualViewport","wrappingWhiteSpace","heightSamples","heightChanged","ceil","whiteSpace","lineHeights","newHeight","h","knownHeights","MeasuredHeights","heights","BlockInfo","_content","QueryType","HeightMap","oracle","oldDoc","ByPosNoHeight","setDoc","updateHeight","HeightMapText","break","brk","HeightMapBranch","HeightMapBlock","_height","_oracle","_value","_type","_force","measured","more","setHeight","outdated","collapsed","widgetHeight","breaks","HeightMapGap","heightForLine","perLine","firstLine","perChar","totalPerLine","heightMetrics","guess","lineTop","ByHeight","linesAbove","unshift","singleHeight","heightForGap","rightTop","rightOffset","subQuery","ByPos","forEachLine","rightStart","balanced","decomposeLeft","mergeGaps","decomposeRight","rebalance","around","lineEnd","covering","writtenTo","isCovered","heightRelevant","addBlock","blankContent","gap","enterLine","ensureLine","DecorationComparator","visiblePixelRange","overflow","parentRect","offsetParent","fullPixelRange","LineGap","gA","gB","wrapping","LineGapWidget","vertical","display","pixelViewport","inView","paddingBottom","contentDOMWidth","contentDOMHeight","editorHeight","editorWidth","scrolledToBottom","scrollAnchorPos","scrollAnchorHeight","scaler","IdScaler","scrollTarget","printing","defaultTextDirection","visibleRanges","mustEnforceCursorAssoc","guessWrapping","stateDeco","heightMap","applyChanges","getViewport","updateViewportLines","updateForViewport","lineGaps","ensureLineGaps","draw","computeVisibleRanges","Viewport","BigScaler","viewportLines","scale","scaleBlock","prevDeco","contentChanges","heightChanges","heightRelevantDecoChanges","prevHeight","scrollAnchor","scrollAnchorAt","mapViewport","viewportIsAppropriate","updateLines","updateLineGaps","mapLineGaps","refresh","mustRefreshForWrapping","domRect","measureContent","dTop","dBottom","measureVisibleLineHeights","mustRefreshForHeights","vp","viewportChange","enforceCursorAssoc","fromDOM","marginTop","visibleTop","visibleBottom","topPos","viewHeight","mayMeasure","halfMargin","doubleMargin","addGap","structure","avoid","moveToLineBoundary","gapSize","lineStructure","viewFrom","viewTo","bot","marginHeight","targetFrac","findFraction","spaceFrac","findPosition","marginWidth","fraction","same","lineBlockAtHeight","ratio","counted","vpHeight","domBase","domTop","domBottom","obj","bTop","bBottom","theme","strs","darkTheme","baseThemeID","newName","baseLightID","baseDarkID","lightDarkIDs","buildTheme","scopes","baseTheme$1","boxSizing","outline","flexDirection","alignItems","fontFamily","overflowX","zIndex","flexGrow","flexShrink","wordWrap","padding","WebkitUserModify","whiteSpace_fallback","wordBreak","overflowWrap","caretColor","contain","background","animation","opacity","borderLeft","marginLeft","borderLeftColor","backgroundColor","color","insetInlineStart","borderRight","textAlign","borderBottom","borderTop","verticalAlign","backgroundImage","backgroundSize","backgroundPosition","backgroundRepeat","fontSize","borderRadius","border","points","findPointBefore","oldLen","readNode","nextView","isBlockElement","re","nextBreak","breakSize","fromView","overrideDOMText","findPointInside","readTextNode","readRange","maxLen","DOMPoint","typeOver","bounds","iHead","iAnchor","selPoints","selectionPoints","selectionFromPoints","applyDOMChange","domChange","lastKey","preferredPos","preferredSide","minLen","adjust","findDiff","LineBreakPlaceholder","defaultTr","defaultInsert","mainSel","compositionRange","replaced","rangeChanges","selOff","applyDefaultInsert","observeOptions","characterData","subtree","characterDataOldValue","useCharData","DOMObserver","selectionChanged","delayedFlush","resizeTimeout","queue","delayedAndroidKey","flushingAndroidKey","lastChange","scrollTargets","intersection","resizeScroll","resizeContent","intersecting","gapIntersection","parentCheck","MutationObserver","mutations","mut","removedNodes","onCharData","prevValue","onSelectionChange","onResize","onPrint","onScroll","ResizeObserver","observe","requestMeasure","addWindowListeners","IntersectionObserver","entries","listenForScroll","intersectionRatio","onScrollChanged","createEvent","threshold","runScrollHandlers","g","disconnect","wasChanged","shadowRoot","deepActiveElement","stopImmediatePropagation","getTargetRanges","execCommand","endContainer","endOffset","curAnchor","safariSelectionRangeHack","atElementStart","updateSelection","setRange","processRecords","clearDelayedAndroidKey","requestAnimationFrame","cancelAnimationFrame","takeRecords","records","record","readMutation","readSelection","readChange","handled","rec","ignoreMutation","childBefore","findChild","childAfter","posAfter","removeWindowListeners","_c","_d","curView","_root","pluginMap","editorAttrs","contentAttrs","bidiCache","destroyed","updateState","measureScheduled","measureRequests","tabIndex","announceDOM","dispatchTransactions","trs","getRoot","ensureHandlers","mountStyles","redrawn","attrsChanged","focusFlag","dispatchFocus","pendingKey","setState","CachedOrder","updatePlugins","styleModules","showAnnouncements","isUserEvent","listener","newState","hadFocus","prevSpecs","newPlugins","sDOM","warn","measuring","BadMeasure","write","viewportChanged","attrsFromFacet","themeClasses","spellcheck","autocorrect","autocapitalize","translate","contenteditable","role","changedContent","changedEditor","announce","cspNonce","request","readMeasured","initial","nextCat","byGroup","includeWrap","widgetLineBreaks","coordsAtPos","editorRect","distance","startPos","startY","goal","startCoords","documentTop","resolvedGoal","extra","curY","moveVertically","coordsForChar","MaxBidiLine","entry","fresh","setWindow","prefix","dark","querySelector","cache","lastDir","sources","currentPlatform","modifiers","handleKeyEvents","runHandlers","getKeymap","keymap","Keymaps","WeakMap","bindings","bound","isPrefix","checkPrefix","scope","command","stopPropagation","scopeObj","alt","ctrl","meta","normalizeKeyName","ourObj","storedPrefix","full","binding","_any","any","buildKeymap","keyName","isChar","prevented","baseName","shiftName","ran","runFor","cmd","CanHidePrimary","themeSpec","panelConfig","topContainer","bottomContainer","getPanel","panel","panelPlugin","panels","fromClass","showPanel","PanelGroup","container","syncClasses","scrollMargin","classes","syncDOM","curDOM","rm","elementClass","gutterLineClass","activeGutters","unfixGutters","gutters","gutterView","fixed","prevViewport","gutter","syncGutters","updateGutters","vpA","vpB","vpOverlap","geometryChanged","detach","lineClasses","classSet","contexts","documentPadding","viewportLineBlocks","advanceCursor","cx","collect","markers","elements","newElt","GutterElement","extraMarkers","localMarkers","forLine","lineMarker","renderEmptyElements","addElement","marker","widgetMarker","spacer","initialSpacer","prevMarkers","updateSpacer","lineMarkerChange","sameMarkers","setMarkers","domPos","iNew","iOld","skipTo","matched","lineNumberMarkers","lineNumberConfig","formatNumber","assign","exists","NumberMarker","lineNumberGutter","others","maxLineNumber","CodeMirror","$textarea","_classCallCheck","namespaces","mw","includes","lineNumbers","_this","defaultExtensions","textSelection","EditorView","hide","form","$","cmTextSelection","hook","fire","session_token","user","sessionId","user_id","getId","editCountBucket","user_edit_count_bucket","prefValue","isNamed","Api","saveOption","_this2","$cmDom","getContents","setContents","setSelection","getCaretPosition","startAndEnd","scrollToCaretPosition","DefaultBufferLength","nextPropID","NodeProp","perNode","deserialize","match","NodeType","closedBy","openedBy","group","contextHash","lookAhead","mounted","MountedTree","tree","overlay","parser","props","noProps","skipped","src","groups","CachedNode","CachedInnerNode","IterMode","Tree","positions","isError","JSON","stringify","TreeCursor","topNode","moveTo","_tree","TreeNode","resolveNode","resolveInner","layers","iterStack","stackIterator","enter","leave","anon","IncludeAnonymous","entered","isAnonymous","balanceRange","propValues","makeTree","buffer","nodeSet","maxBufferLength","reused","minRepeatType","FlatBufferCursor","takeNode","parentStart","minPos","inRepeat","lookAheadAtStart","maxSize","fork","minStart","nodeSize","localSkipped","nodeStart","findBufferSize","Uint16Array","endPos","copyToBuffer","TreeBuffer","localChildren","localPositions","localInRepeat","lastGroup","lastEnd","makeRepeatLeaf","make","lookAheadProp","lastI","makeBalanced","pair","bufferStart","topID","buildTree","childString","endIndex","pick","checkSide","startI","endI","overlays","IgnoreOverlays","BaseNode","getChildren","matchNodeContext","prevSibling","_parent","ExcludeBuffers","BufferNode","BufferContext","hasChild","IgnoreMounts","nextChild","rPos","nextSignificantParent","externalSibling","heads","picked","newHeads","StackIterator","bufferNode","yieldNode","yieldBuf","yield","enterChild","sibling","atLastNode","depth","mustLeave","nodeSizeCache","balanceType","mkTop","mkTree","maxChild","divide","groupFrom","groupStart","groupSize","nextSize","only","TreeFragment","fragments","partial","minGap","fI","nextF","cI","nextC","nextPos","fFrom","fTo","Parser","StringInput","createParse","parse","startParse","advance","nextTagID","Tag","modified","Modifier","nextModifierID","instances","mods","powerSet","styleTags","byName","tags","pieces","rest","rule","Rule","ruleNodeProp","tagHighlighter","all","tagClass","comment","typeName","propertyName","literal","heading","keyword","operator","punctuation","lineComment","blockComment","docComment","variableName","attributeName","labelName","namespace","macroName","docString","character","attributeValue","integer","float","bool","regexp","escape","url","self","null","atom","unit","modifier","operatorKeyword","controlKeyword","definitionKeyword","moduleKeyword","derefOperator","arithmeticOperator","logicOperator","bitwiseOperator","compareOperator","updateOperator","definitionOperator","typeOperator","controlOperator","separator","bracket","angleBracket","squareBracket","paren","brace","heading1","heading2","heading3","heading4","heading5","heading6","contentSeparator","list","quote","emphasis","strong","link","monospace","strikethrough","deleted","invalid","documentMeta","processingInstruction","definition","defineModifier","constant","function","standard","special","languageDataProp","sublanguageProp","extraExtensions","syntaxTree","topNodeAt","innerNode","sublang","lang","allowsNesting","explore","topLang","isTop","DocInput","cursorPos","syncTo","stringStart","currentContext","treeLen","scheduleOn","tempSkipped","until","isDone","takeTree","withContext","endTime","stoppedAt","stopAt","withoutTempSkipped","addTree","parsedPos","cutFragments","startLen","reset","frags","LanguageState","newCx","work","vpTo","parseState","requestIdle","callback","timeout","requestIdleCallback","idle","cancelIdleCallback","isInputPending","scheduling","parseWorker","working","workScheduled","chunkBudget","scheduleWork","updateViewport","checkAsyncSchedule","deadline","timeRemaining","viewportFirst","catch","err","languages","language","indentService","indentUnit","getIndentUnit","indentString","cols","ts","getIndentation","service","ast","resolveStack","enterUnfinishedNodesBefore","indentFor","syntaxIndentation","simulateBreak","simulateDoubleBreak","override","overrideIndentation","search","overriden","indentNodeProp","strategy","indentStrategy","TreeIndentContext","close","closed","delimitedStrategy","ignoreClosed","topIndent","textAfterPos","baseIndentFor","atBreak","isParent","lineIndent","align","units","closing","closedAt","textAfter","space","aligned","openToken","sim","openLine","isSkipped","bracketedAligned","column","baseIndent","modSpec","def","scopeOpt","themeType","bracketMatchingHandle","matchingNodes","brackets","byProp","findHandle","hasHandle","matchBrackets","maxScanDistance","matches","handle","matchMarkedBrackets","tokenType","startCh","startToken","basePos","matchPlainBrackets","_pos","token","matching","firstToken","endHandle","noTokens","typeArray","warned","defaultTable","legacyName","createTokenType","warnForPart","msg","tagStr","option","toggleLineComment","changeLineComment","toggleBlockComment","changeBlockComment","toggleBlockCommentByLine","fromLine","toLine","selectedLineRanges","getConfig","tokens","comments","startText","endText","textBefore","spaceBefore","spaceAfter","beforeOff","startSpace","endSpace","endOff","charAt","findBlockComment","prevLine","minIndent","indent","changeSet","fromHistory","isolateHistory","invertedEffects","historyConfig","minDepth","newGroupDelay","joinToEvent","_t","isAdjacent","adj","historyField_","HistoryState","fromHist","changeEnd","item","fromTransaction","undone","updateBranch","addSelection","isolate","addMapping","addChanges","undo","redo","historyState","undoSelection","redoSelection","startSelection","selectionsAfter","invert","selections","branch","newEvent","newBranch","conc","sels","setSelAfter","popSelection","addMappingToBranch","mapEvent","extraSelections","mappedChanges","fullMapping","composeDesc","joinableUserEvent","prevTime","prevUserEvent","_f","historyKeymap","updateSel","setSel","moveSel","how","rangeEnd","cursorByChar","ltrAtCursor","cursorCharLeft","cursorCharRight","cursorByGroup","moveByGroup","Intl","Segmenter","interestingNode","bracketProp","moveBySyntax","cursorByLine","cursorLineUp","cursorLineDown","pageInfo","selfScroll","marginBottom","cursorByPage","page","scrollRect","scrollBottom","cursorPageUp","cursorPageDown","moveByLineBoundary","toMatchingBracket","extendSel","selectByChar","selectCharLeft","selectCharRight","selectByGroup","selectByLine","selectLineUp","selectLineDown","selectByPage","selectPageUp","selectPageDown","cursorDocStart","cursorDocEnd","selectDocStart","selectDocEnd","deleteBy","towards","skipAtomic","deleteByChar","targetPos","deleteCharBackward","deleteCharForward","deleteByGroup","nextChar","deleteGroupBackward","deleteToLineEnd","selectedLineBlocks","blocks","startLine","moveLine","nextLine","copyLine","insertNewlineAndIndent","newlineAndIndent","atEof","explode","isBetweenBrackets","changeBySelectedLine","atLine","indentMore","indentLess","keep","defaultKeymap","norm","crelt","basicNormalize","normalize","query","bufferPos","nextOverlapping","peek","baseFlags","unicode","RegExpCursor","MultilineRegExpCursor","ignoreCase","curLineStart","matchPos","toCharEnd","lastIndex","flattened","FlattenedDoc","cached","cachedFrom","createLineDialog","go","sign","ln","cl","percent","pc","docLine","dialogEffect","onkeydown","onsubmit","dialogField","baseTheme","searchConfigFacet","caseSensitive","wholeWord","createPanel","scrollToMatch","valid","validRegExp","unquoted","unquote","RegExpQuery","StringQuery","st","regexpCursor","stringCursor","categorizer","buf","bufPos","charBefore","charAfter","prevMatchInRange","_result","setSearchQuery","togglePanel","searchState","SearchState","defaultQuery","createSearchPanel","matchMark","selectedMatchMark","searchHighlighter","highlight","selected","searchCommand","openSearchPanel","findNext","nextMatch","announceMatch","selectSearchInput","findPrevious","prevMatch","selectMatches","matchAll","replaceNext","replacement","getReplacement","replaceAll","announceText","fallback","_e","selText","getSearchInput","searchInput","searchExtensions","closeSearchPanel","searchKeymap","wordAt","selectWord","searchedText","word","fullWord","cycled","findNextOccurrence","onclick","commit","searchField","placeholder","onchange","onkeyup","replaceField","caseField","checked","reField","wordField","setQuery","Break","font","marginRight","CodeMirrorWikiEditor","_CodeMirror","_inherits","_super","_createSuper","realtimePreviewHandler","useCodeMirror","editRecoveryHandler","_get","_getPrototypeOf","_toConsumableArray","history","accesskey","triggerHandler","fieldChangeHandler","initialize","_this3","toolbar","wikiEditor","section","codemirror","tools","label","oouiIcon","action","execute","switchCodeMirror","$toolbar","enableCodeMirror","updateToolbarButton","logUsage","editor","enabled","toggled","edit_start_ts_ms","$button","toggleClass","setCodeMirrorPreference","_this$view$state$sele","show","trigger","$textbox1","loader","getState","addCodeMirrorToWikiEditor"],"mappings":"aACE,IAAIA,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUC,QAGnC,IAAIC,EAASJ,EAAiBE,GAAY,CACzCG,EAAGH,EACHI,GAAG,EACHH,QAAS,IAUV,OANAI,EAAQL,GAAUM,KAAKJ,EAAOD,QAASC,EAAQA,EAAOD,QAASF,GAG/DG,EAAOE,GAAI,EAGJF,EAAOD,QAKfF,EAAoBQ,EAAIF,EAGxBN,EAAoBS,EAAIV,EAGxBC,EAAoBU,EAAI,SAASR,EAASS,EAAMC,GAC3CZ,EAAoBa,EAAEX,EAASS,IAClCG,OAAOC,eAAeb,EAASS,EAAM,CAAEK,YAAY,EAAMC,IAAKL,KAKhEZ,EAAoBkB,EAAI,SAAShB,GACX,oBAAXiB,QAA0BA,OAAOC,aAC1CN,OAAOC,eAAeb,EAASiB,OAAOC,YAAa,CAAEC,MAAO,WAE7DP,OAAOC,eAAeb,EAAS,aAAc,CAAEmB,OAAO,KAQvDrB,EAAoBsB,EAAI,SAASD,EAAOE,GAEvC,GADU,EAAPA,IAAUF,EAAQrB,EAAoBqB,IAC/B,EAAPE,EAAU,OAAOF,EACpB,GAAW,EAAPE,GAA8B,iBAAVF,GAAsBA,GAASA,EAAMG,WAAY,OAAOH,EAChF,IAAII,EAAKX,OAAOY,OAAO,MAGvB,GAFA1B,EAAoBkB,EAAEO,GACtBX,OAAOC,eAAeU,EAAI,UAAW,CAAET,YAAY,EAAMK,MAAOA,IACtD,EAAPE,GAA4B,iBAATF,EAAmB,IAAI,IAAIM,KAAON,EAAOrB,EAAoBU,EAAEe,EAAIE,EAAK,SAASA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AAKwiF,yBAAyB,GAC9B,IAAMr3D,EAAYnrB,KAAKgtB,KAAKsX,UAAUnZ,UAChC4hB,EAAW/sC,KAAKgtB,KAAK+f,SAC3B01C,EAAqBziF,KAAKgtB,KAAKve,MAAMpB,UAAU/D,OAAQ,GAA/CjJ,EAAIoiF,EAAJpiF,KAAMC,EAAEmiF,EAAFniF,GACdo2D,EAAG12D,KAAKgtB,KAAKlE,KAAMwtC,cAAe,cAClCt2D,KAAK81D,UAAUQ,cAAe,cAC9Bt2D,KAAKgtB,KAAK2B,UACV3uB,KAAKgtB,KAAO,KACZhtB,KAAK81D,UAAU4sB,OACV31C,GACJ/sC,KAAK81D,UAAU6sB,QAAS,SAEzB3iF,KAAK81D,UAAUz8C,KAAM,iBAAkBxX,KAAKiB,IAAKzC,EAAMC,IACrD+Y,KAAM,eAAgBxX,KAAKC,IAAKxB,EAAID,IACtCL,KAAK81D,UAAU3qC,UAAWA,GAC1B8qC,GAAGW,KAAM,yBAA0BC,MAAM,EAAO72D,KAAK4iF,gBAErD5iF,KAAK+hF,mBACL/hF,KAAKwiF,yBAAyB,GAE/BxiF,KAAKgiF,sBAELhiF,KAAKiiF,SAAU,CACdC,OAAQ,WACRC,QAASniF,KAAKygF,cACd2B,SAAS,EAETC,iBAA2E,IAAzDj8E,SAAUswD,EAAG,6BAA8B9lD,MAAO,KAAe,S,gFAEpFuvE,EAnLuC,CAAStqB,ICP7CI,GAAG4sB,OAAOC,SAAU,mBACxB7sB,GAAGW,KAAM,2BAA4B1xD,KAAK,SAAE4wD,GAC9B,IAAIqqB,GAAsBrqB,GAClCitB","file":"main.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = \"./src/codemirror.wikieditor.init.js\");\n","/**\nThe data structure for documents. @nonabstract\n*/\nclass Text {\n /**\n Get the line description around the given position.\n */\n lineAt(pos) {\n if (pos < 0 || pos > this.length)\n throw new RangeError(`Invalid position ${pos} in document of length ${this.length}`);\n return this.lineInner(pos, false, 1, 0);\n }\n /**\n Get the description for the given (1-based) line number.\n */\n line(n) {\n if (n < 1 || n > this.lines)\n throw new RangeError(`Invalid line number ${n} in ${this.lines}-line document`);\n return this.lineInner(n, true, 1, 0);\n }\n /**\n Replace a range of the text with the given content.\n */\n replace(from, to, text) {\n let parts = [];\n this.decompose(0, from, parts, 2 /* Open.To */);\n if (text.length)\n text.decompose(0, text.length, parts, 1 /* Open.From */ | 2 /* Open.To */);\n this.decompose(to, this.length, parts, 1 /* Open.From */);\n return TextNode.from(parts, this.length - (to - from) + text.length);\n }\n /**\n Append another document to this one.\n */\n append(other) {\n return this.replace(this.length, this.length, other);\n }\n /**\n Retrieve the text between the given points.\n */\n slice(from, to = this.length) {\n let parts = [];\n this.decompose(from, to, parts, 0);\n return TextNode.from(parts, to - from);\n }\n /**\n Test whether this text is equal to another instance.\n */\n eq(other) {\n if (other == this)\n return true;\n if (other.length != this.length || other.lines != this.lines)\n return false;\n let start = this.scanIdentical(other, 1), end = this.length - this.scanIdentical(other, -1);\n let a = new RawTextCursor(this), b = new RawTextCursor(other);\n for (let skip = start, pos = start;;) {\n a.next(skip);\n b.next(skip);\n skip = 0;\n if (a.lineBreak != b.lineBreak || a.done != b.done || a.value != b.value)\n return false;\n pos += a.value.length;\n if (a.done || pos >= end)\n return true;\n }\n }\n /**\n Iterate over the text. When `dir` is `-1`, iteration happens\n from end to start. This will return lines and the breaks between\n them as separate strings.\n */\n iter(dir = 1) { return new RawTextCursor(this, dir); }\n /**\n Iterate over a range of the text. When `from` > `to`, the\n iterator will run in reverse.\n */\n iterRange(from, to = this.length) { return new PartialTextCursor(this, from, to); }\n /**\n Return a cursor that iterates over the given range of lines,\n _without_ returning the line breaks between, and yielding empty\n strings for empty lines.\n \n When `from` and `to` are given, they should be 1-based line numbers.\n */\n iterLines(from, to) {\n let inner;\n if (from == null) {\n inner = this.iter();\n }\n else {\n if (to == null)\n to = this.lines + 1;\n let start = this.line(from).from;\n inner = this.iterRange(start, Math.max(start, to == this.lines + 1 ? this.length : to <= 1 ? 0 : this.line(to - 1).to));\n }\n return new LineCursor(inner);\n }\n /**\n Return the document as a string, using newline characters to\n separate lines.\n */\n toString() { return this.sliceString(0); }\n /**\n Convert the document to an array of lines (which can be\n deserialized again via [`Text.of`](https://codemirror.net/6/docs/ref/#state.Text^of)).\n */\n toJSON() {\n let lines = [];\n this.flatten(lines);\n return lines;\n }\n /**\n @internal\n */\n constructor() { }\n /**\n Create a `Text` instance for the given array of lines.\n */\n static of(text) {\n if (text.length == 0)\n throw new RangeError(\"A document must have at least one line\");\n if (text.length == 1 && !text[0])\n return Text.empty;\n return text.length <= 32 /* Tree.Branch */ ? new TextLeaf(text) : TextNode.from(TextLeaf.split(text, []));\n }\n}\n// Leaves store an array of line strings. There are always line breaks\n// between these strings. Leaves are limited in size and have to be\n// contained in TextNode instances for bigger documents.\nclass TextLeaf extends Text {\n constructor(text, length = textLength(text)) {\n super();\n this.text = text;\n this.length = length;\n }\n get lines() { return this.text.length; }\n get children() { return null; }\n lineInner(target, isLine, line, offset) {\n for (let i = 0;; i++) {\n let string = this.text[i], end = offset + string.length;\n if ((isLine ? line : end) >= target)\n return new Line(offset, end, line, string);\n offset = end + 1;\n line++;\n }\n }\n decompose(from, to, target, open) {\n let text = from <= 0 && to >= this.length ? this\n : new TextLeaf(sliceText(this.text, from, to), Math.min(to, this.length) - Math.max(0, from));\n if (open & 1 /* Open.From */) {\n let prev = target.pop();\n let joined = appendText(text.text, prev.text.slice(), 0, text.length);\n if (joined.length <= 32 /* Tree.Branch */) {\n target.push(new TextLeaf(joined, prev.length + text.length));\n }\n else {\n let mid = joined.length >> 1;\n target.push(new TextLeaf(joined.slice(0, mid)), new TextLeaf(joined.slice(mid)));\n }\n }\n else {\n target.push(text);\n }\n }\n replace(from, to, text) {\n if (!(text instanceof TextLeaf))\n return super.replace(from, to, text);\n let lines = appendText(this.text, appendText(text.text, sliceText(this.text, 0, from)), to);\n let newLen = this.length + text.length - (to - from);\n if (lines.length <= 32 /* Tree.Branch */)\n return new TextLeaf(lines, newLen);\n return TextNode.from(TextLeaf.split(lines, []), newLen);\n }\n sliceString(from, to = this.length, lineSep = \"\\n\") {\n let result = \"\";\n for (let pos = 0, i = 0; pos <= to && i < this.text.length; i++) {\n let line = this.text[i], end = pos + line.length;\n if (pos > from && i)\n result += lineSep;\n if (from < end && to > pos)\n result += line.slice(Math.max(0, from - pos), to - pos);\n pos = end + 1;\n }\n return result;\n }\n flatten(target) {\n for (let line of this.text)\n target.push(line);\n }\n scanIdentical() { return 0; }\n static split(text, target) {\n let part = [], len = -1;\n for (let line of text) {\n part.push(line);\n len += line.length + 1;\n if (part.length == 32 /* Tree.Branch */) {\n target.push(new TextLeaf(part, len));\n part = [];\n len = -1;\n }\n }\n if (len > -1)\n target.push(new TextLeaf(part, len));\n return target;\n }\n}\n// Nodes provide the tree structure of the `Text` type. They store a\n// number of other nodes or leaves, taking care to balance themselves\n// on changes. There are implied line breaks _between_ the children of\n// a node (but not before the first or after the last child).\nclass TextNode extends Text {\n constructor(children, length) {\n super();\n this.children = children;\n this.length = length;\n this.lines = 0;\n for (let child of children)\n this.lines += child.lines;\n }\n lineInner(target, isLine, line, offset) {\n for (let i = 0;; i++) {\n let child = this.children[i], end = offset + child.length, endLine = line + child.lines - 1;\n if ((isLine ? endLine : end) >= target)\n return child.lineInner(target, isLine, line, offset);\n offset = end + 1;\n line = endLine + 1;\n }\n }\n decompose(from, to, target, open) {\n for (let i = 0, pos = 0; pos <= to && i < this.children.length; i++) {\n let child = this.children[i], end = pos + child.length;\n if (from <= end && to >= pos) {\n let childOpen = open & ((pos <= from ? 1 /* Open.From */ : 0) | (end >= to ? 2 /* Open.To */ : 0));\n if (pos >= from && end <= to && !childOpen)\n target.push(child);\n else\n child.decompose(from - pos, to - pos, target, childOpen);\n }\n pos = end + 1;\n }\n }\n replace(from, to, text) {\n if (text.lines < this.lines)\n for (let i = 0, pos = 0; i < this.children.length; i++) {\n let child = this.children[i], end = pos + child.length;\n // Fast path: if the change only affects one child and the\n // child's size remains in the acceptable range, only update\n // that child\n if (from >= pos && to <= end) {\n let updated = child.replace(from - pos, to - pos, text);\n let totalLines = this.lines - child.lines + updated.lines;\n if (updated.lines < (totalLines >> (5 /* Tree.BranchShift */ - 1)) &&\n updated.lines > (totalLines >> (5 /* Tree.BranchShift */ + 1))) {\n let copy = this.children.slice();\n copy[i] = updated;\n return new TextNode(copy, this.length - (to - from) + text.length);\n }\n return super.replace(pos, end, updated);\n }\n pos = end + 1;\n }\n return super.replace(from, to, text);\n }\n sliceString(from, to = this.length, lineSep = \"\\n\") {\n let result = \"\";\n for (let i = 0, pos = 0; i < this.children.length && pos <= to; i++) {\n let child = this.children[i], end = pos + child.length;\n if (pos > from && i)\n result += lineSep;\n if (from < end && to > pos)\n result += child.sliceString(from - pos, to - pos, lineSep);\n pos = end + 1;\n }\n return result;\n }\n flatten(target) {\n for (let child of this.children)\n child.flatten(target);\n }\n scanIdentical(other, dir) {\n if (!(other instanceof TextNode))\n return 0;\n let length = 0;\n let [iA, iB, eA, eB] = dir > 0 ? [0, 0, this.children.length, other.children.length]\n : [this.children.length - 1, other.children.length - 1, -1, -1];\n for (;; iA += dir, iB += dir) {\n if (iA == eA || iB == eB)\n return length;\n let chA = this.children[iA], chB = other.children[iB];\n if (chA != chB)\n return length + chA.scanIdentical(chB, dir);\n length += chA.length + 1;\n }\n }\n static from(children, length = children.reduce((l, ch) => l + ch.length + 1, -1)) {\n let lines = 0;\n for (let ch of children)\n lines += ch.lines;\n if (lines < 32 /* Tree.Branch */) {\n let flat = [];\n for (let ch of children)\n ch.flatten(flat);\n return new TextLeaf(flat, length);\n }\n let chunk = Math.max(32 /* Tree.Branch */, lines >> 5 /* Tree.BranchShift */), maxChunk = chunk << 1, minChunk = chunk >> 1;\n let chunked = [], currentLines = 0, currentLen = -1, currentChunk = [];\n function add(child) {\n let last;\n if (child.lines > maxChunk && child instanceof TextNode) {\n for (let node of child.children)\n add(node);\n }\n else if (child.lines > minChunk && (currentLines > minChunk || !currentLines)) {\n flush();\n chunked.push(child);\n }\n else if (child instanceof TextLeaf && currentLines &&\n (last = currentChunk[currentChunk.length - 1]) instanceof TextLeaf &&\n child.lines + last.lines <= 32 /* Tree.Branch */) {\n currentLines += child.lines;\n currentLen += child.length + 1;\n currentChunk[currentChunk.length - 1] = new TextLeaf(last.text.concat(child.text), last.length + 1 + child.length);\n }\n else {\n if (currentLines + child.lines > chunk)\n flush();\n currentLines += child.lines;\n currentLen += child.length + 1;\n currentChunk.push(child);\n }\n }\n function flush() {\n if (currentLines == 0)\n return;\n chunked.push(currentChunk.length == 1 ? currentChunk[0] : TextNode.from(currentChunk, currentLen));\n currentLen = -1;\n currentLines = currentChunk.length = 0;\n }\n for (let child of children)\n add(child);\n flush();\n return chunked.length == 1 ? chunked[0] : new TextNode(chunked, length);\n }\n}\nText.empty = /*@__PURE__*/new TextLeaf([\"\"], 0);\nfunction textLength(text) {\n let length = -1;\n for (let line of text)\n length += line.length + 1;\n return length;\n}\nfunction appendText(text, target, from = 0, to = 1e9) {\n for (let pos = 0, i = 0, first = true; i < text.length && pos <= to; i++) {\n let line = text[i], end = pos + line.length;\n if (end >= from) {\n if (end > to)\n line = line.slice(0, to - pos);\n if (pos < from)\n line = line.slice(from - pos);\n if (first) {\n target[target.length - 1] += line;\n first = false;\n }\n else\n target.push(line);\n }\n pos = end + 1;\n }\n return target;\n}\nfunction sliceText(text, from, to) {\n return appendText(text, [\"\"], from, to);\n}\nclass RawTextCursor {\n constructor(text, dir = 1) {\n this.dir = dir;\n this.done = false;\n this.lineBreak = false;\n this.value = \"\";\n this.nodes = [text];\n this.offsets = [dir > 0 ? 1 : (text instanceof TextLeaf ? text.text.length : text.children.length) << 1];\n }\n nextInner(skip, dir) {\n this.done = this.lineBreak = false;\n for (;;) {\n let last = this.nodes.length - 1;\n let top = this.nodes[last], offsetValue = this.offsets[last], offset = offsetValue >> 1;\n let size = top instanceof TextLeaf ? top.text.length : top.children.length;\n if (offset == (dir > 0 ? size : 0)) {\n if (last == 0) {\n this.done = true;\n this.value = \"\";\n return this;\n }\n if (dir > 0)\n this.offsets[last - 1]++;\n this.nodes.pop();\n this.offsets.pop();\n }\n else if ((offsetValue & 1) == (dir > 0 ? 0 : 1)) {\n this.offsets[last] += dir;\n if (skip == 0) {\n this.lineBreak = true;\n this.value = \"\\n\";\n return this;\n }\n skip--;\n }\n else if (top instanceof TextLeaf) {\n // Move to the next string\n let next = top.text[offset + (dir < 0 ? -1 : 0)];\n this.offsets[last] += dir;\n if (next.length > Math.max(0, skip)) {\n this.value = skip == 0 ? next : dir > 0 ? next.slice(skip) : next.slice(0, next.length - skip);\n return this;\n }\n skip -= next.length;\n }\n else {\n let next = top.children[offset + (dir < 0 ? -1 : 0)];\n if (skip > next.length) {\n skip -= next.length;\n this.offsets[last] += dir;\n }\n else {\n if (dir < 0)\n this.offsets[last]--;\n this.nodes.push(next);\n this.offsets.push(dir > 0 ? 1 : (next instanceof TextLeaf ? next.text.length : next.children.length) << 1);\n }\n }\n }\n }\n next(skip = 0) {\n if (skip < 0) {\n this.nextInner(-skip, (-this.dir));\n skip = this.value.length;\n }\n return this.nextInner(skip, this.dir);\n }\n}\nclass PartialTextCursor {\n constructor(text, start, end) {\n this.value = \"\";\n this.done = false;\n this.cursor = new RawTextCursor(text, start > end ? -1 : 1);\n this.pos = start > end ? text.length : 0;\n this.from = Math.min(start, end);\n this.to = Math.max(start, end);\n }\n nextInner(skip, dir) {\n if (dir < 0 ? this.pos <= this.from : this.pos >= this.to) {\n this.value = \"\";\n this.done = true;\n return this;\n }\n skip += Math.max(0, dir < 0 ? this.pos - this.to : this.from - this.pos);\n let limit = dir < 0 ? this.pos - this.from : this.to - this.pos;\n if (skip > limit)\n skip = limit;\n limit -= skip;\n let { value } = this.cursor.next(skip);\n this.pos += (value.length + skip) * dir;\n this.value = value.length <= limit ? value : dir < 0 ? value.slice(value.length - limit) : value.slice(0, limit);\n this.done = !this.value;\n return this;\n }\n next(skip = 0) {\n if (skip < 0)\n skip = Math.max(skip, this.from - this.pos);\n else if (skip > 0)\n skip = Math.min(skip, this.to - this.pos);\n return this.nextInner(skip, this.cursor.dir);\n }\n get lineBreak() { return this.cursor.lineBreak && this.value != \"\"; }\n}\nclass LineCursor {\n constructor(inner) {\n this.inner = inner;\n this.afterBreak = true;\n this.value = \"\";\n this.done = false;\n }\n next(skip = 0) {\n let { done, lineBreak, value } = this.inner.next(skip);\n if (done) {\n this.done = true;\n this.value = \"\";\n }\n else if (lineBreak) {\n if (this.afterBreak) {\n this.value = \"\";\n }\n else {\n this.afterBreak = true;\n this.next();\n }\n }\n else {\n this.value = value;\n this.afterBreak = false;\n }\n return this;\n }\n get lineBreak() { return false; }\n}\nif (typeof Symbol != \"undefined\") {\n Text.prototype[Symbol.iterator] = function () { return this.iter(); };\n RawTextCursor.prototype[Symbol.iterator] = PartialTextCursor.prototype[Symbol.iterator] =\n LineCursor.prototype[Symbol.iterator] = function () { return this; };\n}\n/**\nThis type describes a line in the document. It is created\non-demand when lines are [queried](https://codemirror.net/6/docs/ref/#state.Text.lineAt).\n*/\nclass Line {\n /**\n @internal\n */\n constructor(\n /**\n The position of the start of the line.\n */\n from, \n /**\n The position at the end of the line (_before_ the line break,\n or at the end of document for the last line).\n */\n to, \n /**\n This line's line number (1-based).\n */\n number, \n /**\n The line's content.\n */\n text) {\n this.from = from;\n this.to = to;\n this.number = number;\n this.text = text;\n }\n /**\n The length of the line (not including any line break after it).\n */\n get length() { return this.to - this.from; }\n}\n\n// Compressed representation of the Grapheme_Cluster_Break=Extend\n// information from\n// http://www.unicode.org/Public/13.0.0/ucd/auxiliary/GraphemeBreakProperty.txt.\n// Each pair of elements represents a range, as an offet from the\n// previous range and a length. Numbers are in base-36, with the empty\n// string being a shorthand for 1.\nlet extend = /*@__PURE__*/\"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(s => s ? parseInt(s, 36) : 1);\n// Convert offsets into absolute values\nfor (let i = 1; i < extend.length; i++)\n extend[i] += extend[i - 1];\nfunction isExtendingChar(code) {\n for (let i = 1; i < extend.length; i += 2)\n if (extend[i] > code)\n return extend[i - 1] <= code;\n return false;\n}\nfunction isRegionalIndicator(code) {\n return code >= 0x1F1E6 && code <= 0x1F1FF;\n}\nconst ZWJ = 0x200d;\n/**\nReturns a next grapheme cluster break _after_ (not equal to)\n`pos`, if `forward` is true, or before otherwise. Returns `pos`\nitself if no further cluster break is available in the string.\nMoves across surrogate pairs, extending characters (when\n`includeExtending` is true), characters joined with zero-width\njoiners, and flag emoji.\n*/\nfunction findClusterBreak(str, pos, forward = true, includeExtending = true) {\n return (forward ? nextClusterBreak : prevClusterBreak)(str, pos, includeExtending);\n}\nfunction nextClusterBreak(str, pos, includeExtending) {\n if (pos == str.length)\n return pos;\n // If pos is in the middle of a surrogate pair, move to its start\n if (pos && surrogateLow(str.charCodeAt(pos)) && surrogateHigh(str.charCodeAt(pos - 1)))\n pos--;\n let prev = codePointAt(str, pos);\n pos += codePointSize(prev);\n while (pos < str.length) {\n let next = codePointAt(str, pos);\n if (prev == ZWJ || next == ZWJ || includeExtending && isExtendingChar(next)) {\n pos += codePointSize(next);\n prev = next;\n }\n else if (isRegionalIndicator(next)) {\n let countBefore = 0, i = pos - 2;\n while (i >= 0 && isRegionalIndicator(codePointAt(str, i))) {\n countBefore++;\n i -= 2;\n }\n if (countBefore % 2 == 0)\n break;\n else\n pos += 2;\n }\n else {\n break;\n }\n }\n return pos;\n}\nfunction prevClusterBreak(str, pos, includeExtending) {\n while (pos > 0) {\n let found = nextClusterBreak(str, pos - 2, includeExtending);\n if (found < pos)\n return found;\n pos--;\n }\n return 0;\n}\nfunction surrogateLow(ch) { return ch >= 0xDC00 && ch < 0xE000; }\nfunction surrogateHigh(ch) { return ch >= 0xD800 && ch < 0xDC00; }\n/**\nFind the code point at the given position in a string (like the\n[`codePointAt`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/codePointAt)\nstring method).\n*/\nfunction codePointAt(str, pos) {\n let code0 = str.charCodeAt(pos);\n if (!surrogateHigh(code0) || pos + 1 == str.length)\n return code0;\n let code1 = str.charCodeAt(pos + 1);\n if (!surrogateLow(code1))\n return code0;\n return ((code0 - 0xd800) << 10) + (code1 - 0xdc00) + 0x10000;\n}\n/**\nGiven a Unicode codepoint, return the JavaScript string that\nrespresents it (like\n[`String.fromCodePoint`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint)).\n*/\nfunction fromCodePoint(code) {\n if (code <= 0xffff)\n return String.fromCharCode(code);\n code -= 0x10000;\n return String.fromCharCode((code >> 10) + 0xd800, (code & 1023) + 0xdc00);\n}\n/**\nThe amount of positions a character takes up a JavaScript string.\n*/\nfunction codePointSize(code) { return code < 0x10000 ? 1 : 2; }\n\nconst DefaultSplit = /\\r\\n?|\\n/;\n/**\nDistinguishes different ways in which positions can be mapped.\n*/\nvar MapMode = /*@__PURE__*/(function (MapMode) {\n /**\n Map a position to a valid new position, even when its context\n was deleted.\n */\n MapMode[MapMode[\"Simple\"] = 0] = \"Simple\";\n /**\n Return null if deletion happens across the position.\n */\n MapMode[MapMode[\"TrackDel\"] = 1] = \"TrackDel\";\n /**\n Return null if the character _before_ the position is deleted.\n */\n MapMode[MapMode[\"TrackBefore\"] = 2] = \"TrackBefore\";\n /**\n Return null if the character _after_ the position is deleted.\n */\n MapMode[MapMode[\"TrackAfter\"] = 3] = \"TrackAfter\";\nreturn MapMode})(MapMode || (MapMode = {}));\n/**\nA change description is a variant of [change set](https://codemirror.net/6/docs/ref/#state.ChangeSet)\nthat doesn't store the inserted text. As such, it can't be\napplied, but is cheaper to store and manipulate.\n*/\nclass ChangeDesc {\n // Sections are encoded as pairs of integers. The first is the\n // length in the current document, and the second is -1 for\n // unaffected sections, and the length of the replacement content\n // otherwise. So an insertion would be (0, n>0), a deletion (n>0,\n // 0), and a replacement two positive numbers.\n /**\n @internal\n */\n constructor(\n /**\n @internal\n */\n sections) {\n this.sections = sections;\n }\n /**\n The length of the document before the change.\n */\n get length() {\n let result = 0;\n for (let i = 0; i < this.sections.length; i += 2)\n result += this.sections[i];\n return result;\n }\n /**\n The length of the document after the change.\n */\n get newLength() {\n let result = 0;\n for (let i = 0; i < this.sections.length; i += 2) {\n let ins = this.sections[i + 1];\n result += ins < 0 ? this.sections[i] : ins;\n }\n return result;\n }\n /**\n False when there are actual changes in this set.\n */\n get empty() { return this.sections.length == 0 || this.sections.length == 2 && this.sections[1] < 0; }\n /**\n Iterate over the unchanged parts left by these changes. `posA`\n provides the position of the range in the old document, `posB`\n the new position in the changed document.\n */\n iterGaps(f) {\n for (let i = 0, posA = 0, posB = 0; i < this.sections.length;) {\n let len = this.sections[i++], ins = this.sections[i++];\n if (ins < 0) {\n f(posA, posB, len);\n posB += len;\n }\n else {\n posB += ins;\n }\n posA += len;\n }\n }\n /**\n Iterate over the ranges changed by these changes. (See\n [`ChangeSet.iterChanges`](https://codemirror.net/6/docs/ref/#state.ChangeSet.iterChanges) for a\n variant that also provides you with the inserted text.)\n `fromA`/`toA` provides the extent of the change in the starting\n document, `fromB`/`toB` the extent of the replacement in the\n changed document.\n \n When `individual` is true, adjacent changes (which are kept\n separate for [position mapping](https://codemirror.net/6/docs/ref/#state.ChangeDesc.mapPos)) are\n reported separately.\n */\n iterChangedRanges(f, individual = false) {\n iterChanges(this, f, individual);\n }\n /**\n Get a description of the inverted form of these changes.\n */\n get invertedDesc() {\n let sections = [];\n for (let i = 0; i < this.sections.length;) {\n let len = this.sections[i++], ins = this.sections[i++];\n if (ins < 0)\n sections.push(len, ins);\n else\n sections.push(ins, len);\n }\n return new ChangeDesc(sections);\n }\n /**\n Compute the combined effect of applying another set of changes\n after this one. The length of the document after this set should\n match the length before `other`.\n */\n composeDesc(other) { return this.empty ? other : other.empty ? this : composeSets(this, other); }\n /**\n Map this description, which should start with the same document\n as `other`, over another set of changes, so that it can be\n applied after it. When `before` is true, map as if the changes\n in `other` happened before the ones in `this`.\n */\n mapDesc(other, before = false) { return other.empty ? this : mapSet(this, other, before); }\n mapPos(pos, assoc = -1, mode = MapMode.Simple) {\n let posA = 0, posB = 0;\n for (let i = 0; i < this.sections.length;) {\n let len = this.sections[i++], ins = this.sections[i++], endA = posA + len;\n if (ins < 0) {\n if (endA > pos)\n return posB + (pos - posA);\n posB += len;\n }\n else {\n if (mode != MapMode.Simple && endA >= pos &&\n (mode == MapMode.TrackDel && posA < pos && endA > pos ||\n mode == MapMode.TrackBefore && posA < pos ||\n mode == MapMode.TrackAfter && endA > pos))\n return null;\n if (endA > pos || endA == pos && assoc < 0 && !len)\n return pos == posA || assoc < 0 ? posB : posB + ins;\n posB += ins;\n }\n posA = endA;\n }\n if (pos > posA)\n throw new RangeError(`Position ${pos} is out of range for changeset of length ${posA}`);\n return posB;\n }\n /**\n Check whether these changes touch a given range. When one of the\n changes entirely covers the range, the string `\"cover\"` is\n returned.\n */\n touchesRange(from, to = from) {\n for (let i = 0, pos = 0; i < this.sections.length && pos <= to;) {\n let len = this.sections[i++], ins = this.sections[i++], end = pos + len;\n if (ins >= 0 && pos <= to && end >= from)\n return pos < from && end > to ? \"cover\" : true;\n pos = end;\n }\n return false;\n }\n /**\n @internal\n */\n toString() {\n let result = \"\";\n for (let i = 0; i < this.sections.length;) {\n let len = this.sections[i++], ins = this.sections[i++];\n result += (result ? \" \" : \"\") + len + (ins >= 0 ? \":\" + ins : \"\");\n }\n return result;\n }\n /**\n Serialize this change desc to a JSON-representable value.\n */\n toJSON() { return this.sections; }\n /**\n Create a change desc from its JSON representation (as produced\n by [`toJSON`](https://codemirror.net/6/docs/ref/#state.ChangeDesc.toJSON).\n */\n static fromJSON(json) {\n if (!Array.isArray(json) || json.length % 2 || json.some(a => typeof a != \"number\"))\n throw new RangeError(\"Invalid JSON representation of ChangeDesc\");\n return new ChangeDesc(json);\n }\n /**\n @internal\n */\n static create(sections) { return new ChangeDesc(sections); }\n}\n/**\nA change set represents a group of modifications to a document. It\nstores the document length, and can only be applied to documents\nwith exactly that length.\n*/\nclass ChangeSet extends ChangeDesc {\n constructor(sections, \n /**\n @internal\n */\n inserted) {\n super(sections);\n this.inserted = inserted;\n }\n /**\n Apply the changes to a document, returning the modified\n document.\n */\n apply(doc) {\n if (this.length != doc.length)\n throw new RangeError(\"Applying change set to a document with the wrong length\");\n iterChanges(this, (fromA, toA, fromB, _toB, text) => doc = doc.replace(fromB, fromB + (toA - fromA), text), false);\n return doc;\n }\n mapDesc(other, before = false) { return mapSet(this, other, before, true); }\n /**\n Given the document as it existed _before_ the changes, return a\n change set that represents the inverse of this set, which could\n be used to go from the document created by the changes back to\n the document as it existed before the changes.\n */\n invert(doc) {\n let sections = this.sections.slice(), inserted = [];\n for (let i = 0, pos = 0; i < sections.length; i += 2) {\n let len = sections[i], ins = sections[i + 1];\n if (ins >= 0) {\n sections[i] = ins;\n sections[i + 1] = len;\n let index = i >> 1;\n while (inserted.length < index)\n inserted.push(Text.empty);\n inserted.push(len ? doc.slice(pos, pos + len) : Text.empty);\n }\n pos += len;\n }\n return new ChangeSet(sections, inserted);\n }\n /**\n Combine two subsequent change sets into a single set. `other`\n must start in the document produced by `this`. If `this` goes\n `docA` → `docB` and `other` represents `docB` → `docC`, the\n returned value will represent the change `docA` → `docC`.\n */\n compose(other) { return this.empty ? other : other.empty ? this : composeSets(this, other, true); }\n /**\n Given another change set starting in the same document, maps this\n change set over the other, producing a new change set that can be\n applied to the document produced by applying `other`. When\n `before` is `true`, order changes as if `this` comes before\n `other`, otherwise (the default) treat `other` as coming first.\n \n Given two changes `A` and `B`, `A.compose(B.map(A))` and\n `B.compose(A.map(B, true))` will produce the same document. This\n provides a basic form of [operational\n transformation](https://en.wikipedia.org/wiki/Operational_transformation),\n and can be used for collaborative editing.\n */\n map(other, before = false) { return other.empty ? this : mapSet(this, other, before, true); }\n /**\n Iterate over the changed ranges in the document, calling `f` for\n each, with the range in the original document (`fromA`-`toA`)\n and the range that replaces it in the new document\n (`fromB`-`toB`).\n \n When `individual` is true, adjacent changes are reported\n separately.\n */\n iterChanges(f, individual = false) {\n iterChanges(this, f, individual);\n }\n /**\n Get a [change description](https://codemirror.net/6/docs/ref/#state.ChangeDesc) for this change\n set.\n */\n get desc() { return ChangeDesc.create(this.sections); }\n /**\n @internal\n */\n filter(ranges) {\n let resultSections = [], resultInserted = [], filteredSections = [];\n let iter = new SectionIter(this);\n done: for (let i = 0, pos = 0;;) {\n let next = i == ranges.length ? 1e9 : ranges[i++];\n while (pos < next || pos == next && iter.len == 0) {\n if (iter.done)\n break done;\n let len = Math.min(iter.len, next - pos);\n addSection(filteredSections, len, -1);\n let ins = iter.ins == -1 ? -1 : iter.off == 0 ? iter.ins : 0;\n addSection(resultSections, len, ins);\n if (ins > 0)\n addInsert(resultInserted, resultSections, iter.text);\n iter.forward(len);\n pos += len;\n }\n let end = ranges[i++];\n while (pos < end) {\n if (iter.done)\n break done;\n let len = Math.min(iter.len, end - pos);\n addSection(resultSections, len, -1);\n addSection(filteredSections, len, iter.ins == -1 ? -1 : iter.off == 0 ? iter.ins : 0);\n iter.forward(len);\n pos += len;\n }\n }\n return { changes: new ChangeSet(resultSections, resultInserted),\n filtered: ChangeDesc.create(filteredSections) };\n }\n /**\n Serialize this change set to a JSON-representable value.\n */\n toJSON() {\n let parts = [];\n for (let i = 0; i < this.sections.length; i += 2) {\n let len = this.sections[i], ins = this.sections[i + 1];\n if (ins < 0)\n parts.push(len);\n else if (ins == 0)\n parts.push([len]);\n else\n parts.push([len].concat(this.inserted[i >> 1].toJSON()));\n }\n return parts;\n }\n /**\n Create a change set for the given changes, for a document of the\n given length, using `lineSep` as line separator.\n */\n static of(changes, length, lineSep) {\n let sections = [], inserted = [], pos = 0;\n let total = null;\n function flush(force = false) {\n if (!force && !sections.length)\n return;\n if (pos < length)\n addSection(sections, length - pos, -1);\n let set = new ChangeSet(sections, inserted);\n total = total ? total.compose(set.map(total)) : set;\n sections = [];\n inserted = [];\n pos = 0;\n }\n function process(spec) {\n if (Array.isArray(spec)) {\n for (let sub of spec)\n process(sub);\n }\n else if (spec instanceof ChangeSet) {\n if (spec.length != length)\n throw new RangeError(`Mismatched change set length (got ${spec.length}, expected ${length})`);\n flush();\n total = total ? total.compose(spec.map(total)) : spec;\n }\n else {\n let { from, to = from, insert } = spec;\n if (from > to || from < 0 || to > length)\n throw new RangeError(`Invalid change range ${from} to ${to} (in doc of length ${length})`);\n let insText = !insert ? Text.empty : typeof insert == \"string\" ? Text.of(insert.split(lineSep || DefaultSplit)) : insert;\n let insLen = insText.length;\n if (from == to && insLen == 0)\n return;\n if (from < pos)\n flush();\n if (from > pos)\n addSection(sections, from - pos, -1);\n addSection(sections, to - from, insLen);\n addInsert(inserted, sections, insText);\n pos = to;\n }\n }\n process(changes);\n flush(!total);\n return total;\n }\n /**\n Create an empty changeset of the given length.\n */\n static empty(length) {\n return new ChangeSet(length ? [length, -1] : [], []);\n }\n /**\n Create a changeset from its JSON representation (as produced by\n [`toJSON`](https://codemirror.net/6/docs/ref/#state.ChangeSet.toJSON).\n */\n static fromJSON(json) {\n if (!Array.isArray(json))\n throw new RangeError(\"Invalid JSON representation of ChangeSet\");\n let sections = [], inserted = [];\n for (let i = 0; i < json.length; i++) {\n let part = json[i];\n if (typeof part == \"number\") {\n sections.push(part, -1);\n }\n else if (!Array.isArray(part) || typeof part[0] != \"number\" || part.some((e, i) => i && typeof e != \"string\")) {\n throw new RangeError(\"Invalid JSON representation of ChangeSet\");\n }\n else if (part.length == 1) {\n sections.push(part[0], 0);\n }\n else {\n while (inserted.length < i)\n inserted.push(Text.empty);\n inserted[i] = Text.of(part.slice(1));\n sections.push(part[0], inserted[i].length);\n }\n }\n return new ChangeSet(sections, inserted);\n }\n /**\n @internal\n */\n static createSet(sections, inserted) {\n return new ChangeSet(sections, inserted);\n }\n}\nfunction addSection(sections, len, ins, forceJoin = false) {\n if (len == 0 && ins <= 0)\n return;\n let last = sections.length - 2;\n if (last >= 0 && ins <= 0 && ins == sections[last + 1])\n sections[last] += len;\n else if (len == 0 && sections[last] == 0)\n sections[last + 1] += ins;\n else if (forceJoin) {\n sections[last] += len;\n sections[last + 1] += ins;\n }\n else\n sections.push(len, ins);\n}\nfunction addInsert(values, sections, value) {\n if (value.length == 0)\n return;\n let index = (sections.length - 2) >> 1;\n if (index < values.length) {\n values[values.length - 1] = values[values.length - 1].append(value);\n }\n else {\n while (values.length < index)\n values.push(Text.empty);\n values.push(value);\n }\n}\nfunction iterChanges(desc, f, individual) {\n let inserted = desc.inserted;\n for (let posA = 0, posB = 0, i = 0; i < desc.sections.length;) {\n let len = desc.sections[i++], ins = desc.sections[i++];\n if (ins < 0) {\n posA += len;\n posB += len;\n }\n else {\n let endA = posA, endB = posB, text = Text.empty;\n for (;;) {\n endA += len;\n endB += ins;\n if (ins && inserted)\n text = text.append(inserted[(i - 2) >> 1]);\n if (individual || i == desc.sections.length || desc.sections[i + 1] < 0)\n break;\n len = desc.sections[i++];\n ins = desc.sections[i++];\n }\n f(posA, endA, posB, endB, text);\n posA = endA;\n posB = endB;\n }\n }\n}\nfunction mapSet(setA, setB, before, mkSet = false) {\n // Produce a copy of setA that applies to the document after setB\n // has been applied (assuming both start at the same document).\n let sections = [], insert = mkSet ? [] : null;\n let a = new SectionIter(setA), b = new SectionIter(setB);\n // Iterate over both sets in parallel. inserted tracks, for changes\n // in A that have to be processed piece-by-piece, whether their\n // content has been inserted already, and refers to the section\n // index.\n for (let inserted = -1;;) {\n if (a.ins == -1 && b.ins == -1) {\n // Move across ranges skipped by both sets.\n let len = Math.min(a.len, b.len);\n addSection(sections, len, -1);\n a.forward(len);\n b.forward(len);\n }\n else if (b.ins >= 0 && (a.ins < 0 || inserted == a.i || a.off == 0 && (b.len < a.len || b.len == a.len && !before))) {\n // If there's a change in B that comes before the next change in\n // A (ordered by start pos, then len, then before flag), skip\n // that (and process any changes in A it covers).\n let len = b.len;\n addSection(sections, b.ins, -1);\n while (len) {\n let piece = Math.min(a.len, len);\n if (a.ins >= 0 && inserted < a.i && a.len <= piece) {\n addSection(sections, 0, a.ins);\n if (insert)\n addInsert(insert, sections, a.text);\n inserted = a.i;\n }\n a.forward(piece);\n len -= piece;\n }\n b.next();\n }\n else if (a.ins >= 0) {\n // Process the part of a change in A up to the start of the next\n // non-deletion change in B (if overlapping).\n let len = 0, left = a.len;\n while (left) {\n if (b.ins == -1) {\n let piece = Math.min(left, b.len);\n len += piece;\n left -= piece;\n b.forward(piece);\n }\n else if (b.ins == 0 && b.len < left) {\n left -= b.len;\n b.next();\n }\n else {\n break;\n }\n }\n addSection(sections, len, inserted < a.i ? a.ins : 0);\n if (insert && inserted < a.i)\n addInsert(insert, sections, a.text);\n inserted = a.i;\n a.forward(a.len - left);\n }\n else if (a.done && b.done) {\n return insert ? ChangeSet.createSet(sections, insert) : ChangeDesc.create(sections);\n }\n else {\n throw new Error(\"Mismatched change set lengths\");\n }\n }\n}\nfunction composeSets(setA, setB, mkSet = false) {\n let sections = [];\n let insert = mkSet ? [] : null;\n let a = new SectionIter(setA), b = new SectionIter(setB);\n for (let open = false;;) {\n if (a.done && b.done) {\n return insert ? ChangeSet.createSet(sections, insert) : ChangeDesc.create(sections);\n }\n else if (a.ins == 0) { // Deletion in A\n addSection(sections, a.len, 0, open);\n a.next();\n }\n else if (b.len == 0 && !b.done) { // Insertion in B\n addSection(sections, 0, b.ins, open);\n if (insert)\n addInsert(insert, sections, b.text);\n b.next();\n }\n else if (a.done || b.done) {\n throw new Error(\"Mismatched change set lengths\");\n }\n else {\n let len = Math.min(a.len2, b.len), sectionLen = sections.length;\n if (a.ins == -1) {\n let insB = b.ins == -1 ? -1 : b.off ? 0 : b.ins;\n addSection(sections, len, insB, open);\n if (insert && insB)\n addInsert(insert, sections, b.text);\n }\n else if (b.ins == -1) {\n addSection(sections, a.off ? 0 : a.len, len, open);\n if (insert)\n addInsert(insert, sections, a.textBit(len));\n }\n else {\n addSection(sections, a.off ? 0 : a.len, b.off ? 0 : b.ins, open);\n if (insert && !b.off)\n addInsert(insert, sections, b.text);\n }\n open = (a.ins > len || b.ins >= 0 && b.len > len) && (open || sections.length > sectionLen);\n a.forward2(len);\n b.forward(len);\n }\n }\n}\nclass SectionIter {\n constructor(set) {\n this.set = set;\n this.i = 0;\n this.next();\n }\n next() {\n let { sections } = this.set;\n if (this.i < sections.length) {\n this.len = sections[this.i++];\n this.ins = sections[this.i++];\n }\n else {\n this.len = 0;\n this.ins = -2;\n }\n this.off = 0;\n }\n get done() { return this.ins == -2; }\n get len2() { return this.ins < 0 ? this.len : this.ins; }\n get text() {\n let { inserted } = this.set, index = (this.i - 2) >> 1;\n return index >= inserted.length ? Text.empty : inserted[index];\n }\n textBit(len) {\n let { inserted } = this.set, index = (this.i - 2) >> 1;\n return index >= inserted.length && !len ? Text.empty\n : inserted[index].slice(this.off, len == null ? undefined : this.off + len);\n }\n forward(len) {\n if (len == this.len)\n this.next();\n else {\n this.len -= len;\n this.off += len;\n }\n }\n forward2(len) {\n if (this.ins == -1)\n this.forward(len);\n else if (len == this.ins)\n this.next();\n else {\n this.ins -= len;\n this.off += len;\n }\n }\n}\n\n/**\nA single selection range. When\n[`allowMultipleSelections`](https://codemirror.net/6/docs/ref/#state.EditorState^allowMultipleSelections)\nis enabled, a [selection](https://codemirror.net/6/docs/ref/#state.EditorSelection) may hold\nmultiple ranges. By default, selections hold exactly one range.\n*/\nclass SelectionRange {\n constructor(\n /**\n The lower boundary of the range.\n */\n from, \n /**\n The upper boundary of the range.\n */\n to, flags) {\n this.from = from;\n this.to = to;\n this.flags = flags;\n }\n /**\n The anchor of the range—the side that doesn't move when you\n extend it.\n */\n get anchor() { return this.flags & 16 /* RangeFlag.Inverted */ ? this.to : this.from; }\n /**\n The head of the range, which is moved when the range is\n [extended](https://codemirror.net/6/docs/ref/#state.SelectionRange.extend).\n */\n get head() { return this.flags & 16 /* RangeFlag.Inverted */ ? this.from : this.to; }\n /**\n True when `anchor` and `head` are at the same position.\n */\n get empty() { return this.from == this.to; }\n /**\n If this is a cursor that is explicitly associated with the\n character on one of its sides, this returns the side. -1 means\n the character before its position, 1 the character after, and 0\n means no association.\n */\n get assoc() { return this.flags & 4 /* RangeFlag.AssocBefore */ ? -1 : this.flags & 8 /* RangeFlag.AssocAfter */ ? 1 : 0; }\n /**\n The bidirectional text level associated with this cursor, if\n any.\n */\n get bidiLevel() {\n let level = this.flags & 3 /* RangeFlag.BidiLevelMask */;\n return level == 3 ? null : level;\n }\n /**\n The goal column (stored vertical offset) associated with a\n cursor. This is used to preserve the vertical position when\n [moving](https://codemirror.net/6/docs/ref/#view.EditorView.moveVertically) across\n lines of different length.\n */\n get goalColumn() {\n let value = this.flags >> 5 /* RangeFlag.GoalColumnOffset */;\n return value == 33554431 /* RangeFlag.NoGoalColumn */ ? undefined : value;\n }\n /**\n Map this range through a change, producing a valid range in the\n updated document.\n */\n map(change, assoc = -1) {\n let from, to;\n if (this.empty) {\n from = to = change.mapPos(this.from, assoc);\n }\n else {\n from = change.mapPos(this.from, 1);\n to = change.mapPos(this.to, -1);\n }\n return from == this.from && to == this.to ? this : new SelectionRange(from, to, this.flags);\n }\n /**\n Extend this range to cover at least `from` to `to`.\n */\n extend(from, to = from) {\n if (from <= this.anchor && to >= this.anchor)\n return EditorSelection.range(from, to);\n let head = Math.abs(from - this.anchor) > Math.abs(to - this.anchor) ? from : to;\n return EditorSelection.range(this.anchor, head);\n }\n /**\n Compare this range to another range.\n */\n eq(other) {\n return this.anchor == other.anchor && this.head == other.head;\n }\n /**\n Return a JSON-serializable object representing the range.\n */\n toJSON() { return { anchor: this.anchor, head: this.head }; }\n /**\n Convert a JSON representation of a range to a `SelectionRange`\n instance.\n */\n static fromJSON(json) {\n if (!json || typeof json.anchor != \"number\" || typeof json.head != \"number\")\n throw new RangeError(\"Invalid JSON representation for SelectionRange\");\n return EditorSelection.range(json.anchor, json.head);\n }\n /**\n @internal\n */\n static create(from, to, flags) {\n return new SelectionRange(from, to, flags);\n }\n}\n/**\nAn editor selection holds one or more selection ranges.\n*/\nclass EditorSelection {\n constructor(\n /**\n The ranges in the selection, sorted by position. Ranges cannot\n overlap (but they may touch, if they aren't empty).\n */\n ranges, \n /**\n The index of the _main_ range in the selection (which is\n usually the range that was added last).\n */\n mainIndex) {\n this.ranges = ranges;\n this.mainIndex = mainIndex;\n }\n /**\n Map a selection through a change. Used to adjust the selection\n position for changes.\n */\n map(change, assoc = -1) {\n if (change.empty)\n return this;\n return EditorSelection.create(this.ranges.map(r => r.map(change, assoc)), this.mainIndex);\n }\n /**\n Compare this selection to another selection.\n */\n eq(other) {\n if (this.ranges.length != other.ranges.length ||\n this.mainIndex != other.mainIndex)\n return false;\n for (let i = 0; i < this.ranges.length; i++)\n if (!this.ranges[i].eq(other.ranges[i]))\n return false;\n return true;\n }\n /**\n Get the primary selection range. Usually, you should make sure\n your code applies to _all_ ranges, by using methods like\n [`changeByRange`](https://codemirror.net/6/docs/ref/#state.EditorState.changeByRange).\n */\n get main() { return this.ranges[this.mainIndex]; }\n /**\n Make sure the selection only has one range. Returns a selection\n holding only the main range from this selection.\n */\n asSingle() {\n return this.ranges.length == 1 ? this : new EditorSelection([this.main], 0);\n }\n /**\n Extend this selection with an extra range.\n */\n addRange(range, main = true) {\n return EditorSelection.create([range].concat(this.ranges), main ? 0 : this.mainIndex + 1);\n }\n /**\n Replace a given range with another range, and then normalize the\n selection to merge and sort ranges if necessary.\n */\n replaceRange(range, which = this.mainIndex) {\n let ranges = this.ranges.slice();\n ranges[which] = range;\n return EditorSelection.create(ranges, this.mainIndex);\n }\n /**\n Convert this selection to an object that can be serialized to\n JSON.\n */\n toJSON() {\n return { ranges: this.ranges.map(r => r.toJSON()), main: this.mainIndex };\n }\n /**\n Create a selection from a JSON representation.\n */\n static fromJSON(json) {\n if (!json || !Array.isArray(json.ranges) || typeof json.main != \"number\" || json.main >= json.ranges.length)\n throw new RangeError(\"Invalid JSON representation for EditorSelection\");\n return new EditorSelection(json.ranges.map((r) => SelectionRange.fromJSON(r)), json.main);\n }\n /**\n Create a selection holding a single range.\n */\n static single(anchor, head = anchor) {\n return new EditorSelection([EditorSelection.range(anchor, head)], 0);\n }\n /**\n Sort and merge the given set of ranges, creating a valid\n selection.\n */\n static create(ranges, mainIndex = 0) {\n if (ranges.length == 0)\n throw new RangeError(\"A selection needs at least one range\");\n for (let pos = 0, i = 0; i < ranges.length; i++) {\n let range = ranges[i];\n if (range.empty ? range.from <= pos : range.from < pos)\n return EditorSelection.normalized(ranges.slice(), mainIndex);\n pos = range.to;\n }\n return new EditorSelection(ranges, mainIndex);\n }\n /**\n Create a cursor selection range at the given position. You can\n safely ignore the optional arguments in most situations.\n */\n static cursor(pos, assoc = 0, bidiLevel, goalColumn) {\n return SelectionRange.create(pos, pos, (assoc == 0 ? 0 : assoc < 0 ? 4 /* RangeFlag.AssocBefore */ : 8 /* RangeFlag.AssocAfter */) |\n (bidiLevel == null ? 3 : Math.min(2, bidiLevel)) |\n ((goalColumn !== null && goalColumn !== void 0 ? goalColumn : 33554431 /* RangeFlag.NoGoalColumn */) << 5 /* RangeFlag.GoalColumnOffset */));\n }\n /**\n Create a selection range.\n */\n static range(anchor, head, goalColumn, bidiLevel) {\n let flags = ((goalColumn !== null && goalColumn !== void 0 ? goalColumn : 33554431 /* RangeFlag.NoGoalColumn */) << 5 /* RangeFlag.GoalColumnOffset */) |\n (bidiLevel == null ? 3 : Math.min(2, bidiLevel));\n return head < anchor ? SelectionRange.create(head, anchor, 16 /* RangeFlag.Inverted */ | 8 /* RangeFlag.AssocAfter */ | flags)\n : SelectionRange.create(anchor, head, (head > anchor ? 4 /* RangeFlag.AssocBefore */ : 0) | flags);\n }\n /**\n @internal\n */\n static normalized(ranges, mainIndex = 0) {\n let main = ranges[mainIndex];\n ranges.sort((a, b) => a.from - b.from);\n mainIndex = ranges.indexOf(main);\n for (let i = 1; i < ranges.length; i++) {\n let range = ranges[i], prev = ranges[i - 1];\n if (range.empty ? range.from <= prev.to : range.from < prev.to) {\n let from = prev.from, to = Math.max(range.to, prev.to);\n if (i <= mainIndex)\n mainIndex--;\n ranges.splice(--i, 2, range.anchor > range.head ? EditorSelection.range(to, from) : EditorSelection.range(from, to));\n }\n }\n return new EditorSelection(ranges, mainIndex);\n }\n}\nfunction checkSelection(selection, docLength) {\n for (let range of selection.ranges)\n if (range.to > docLength)\n throw new RangeError(\"Selection points outside of document\");\n}\n\nlet nextID = 0;\n/**\nA facet is a labeled value that is associated with an editor\nstate. It takes inputs from any number of extensions, and combines\nthose into a single output value.\n\nExamples of uses of facets are the [tab\nsize](https://codemirror.net/6/docs/ref/#state.EditorState^tabSize), [editor\nattributes](https://codemirror.net/6/docs/ref/#view.EditorView^editorAttributes), and [update\nlisteners](https://codemirror.net/6/docs/ref/#view.EditorView^updateListener).\n*/\nclass Facet {\n constructor(\n /**\n @internal\n */\n combine, \n /**\n @internal\n */\n compareInput, \n /**\n @internal\n */\n compare, isStatic, enables) {\n this.combine = combine;\n this.compareInput = compareInput;\n this.compare = compare;\n this.isStatic = isStatic;\n /**\n @internal\n */\n this.id = nextID++;\n this.default = combine([]);\n this.extensions = typeof enables == \"function\" ? enables(this) : enables;\n }\n /**\n Define a new facet.\n */\n static define(config = {}) {\n return new Facet(config.combine || ((a) => a), config.compareInput || ((a, b) => a === b), config.compare || (!config.combine ? sameArray : (a, b) => a === b), !!config.static, config.enables);\n }\n /**\n Returns an extension that adds the given value to this facet.\n */\n of(value) {\n return new FacetProvider([], this, 0 /* Provider.Static */, value);\n }\n /**\n Create an extension that computes a value for the facet from a\n state. You must take care to declare the parts of the state that\n this value depends on, since your function is only called again\n for a new state when one of those parts changed.\n \n In cases where your value depends only on a single field, you'll\n want to use the [`from`](https://codemirror.net/6/docs/ref/#state.Facet.from) method instead.\n */\n compute(deps, get) {\n if (this.isStatic)\n throw new Error(\"Can't compute a static facet\");\n return new FacetProvider(deps, this, 1 /* Provider.Single */, get);\n }\n /**\n Create an extension that computes zero or more values for this\n facet from a state.\n */\n computeN(deps, get) {\n if (this.isStatic)\n throw new Error(\"Can't compute a static facet\");\n return new FacetProvider(deps, this, 2 /* Provider.Multi */, get);\n }\n from(field, get) {\n if (!get)\n get = x => x;\n return this.compute([field], state => get(state.field(field)));\n }\n}\nfunction sameArray(a, b) {\n return a == b || a.length == b.length && a.every((e, i) => e === b[i]);\n}\nclass FacetProvider {\n constructor(dependencies, facet, type, value) {\n this.dependencies = dependencies;\n this.facet = facet;\n this.type = type;\n this.value = value;\n this.id = nextID++;\n }\n dynamicSlot(addresses) {\n var _a;\n let getter = this.value;\n let compare = this.facet.compareInput;\n let id = this.id, idx = addresses[id] >> 1, multi = this.type == 2 /* Provider.Multi */;\n let depDoc = false, depSel = false, depAddrs = [];\n for (let dep of this.dependencies) {\n if (dep == \"doc\")\n depDoc = true;\n else if (dep == \"selection\")\n depSel = true;\n else if ((((_a = addresses[dep.id]) !== null && _a !== void 0 ? _a : 1) & 1) == 0)\n depAddrs.push(addresses[dep.id]);\n }\n return {\n create(state) {\n state.values[idx] = getter(state);\n return 1 /* SlotStatus.Changed */;\n },\n update(state, tr) {\n if ((depDoc && tr.docChanged) || (depSel && (tr.docChanged || tr.selection)) || ensureAll(state, depAddrs)) {\n let newVal = getter(state);\n if (multi ? !compareArray(newVal, state.values[idx], compare) : !compare(newVal, state.values[idx])) {\n state.values[idx] = newVal;\n return 1 /* SlotStatus.Changed */;\n }\n }\n return 0;\n },\n reconfigure: (state, oldState) => {\n let newVal, oldAddr = oldState.config.address[id];\n if (oldAddr != null) {\n let oldVal = getAddr(oldState, oldAddr);\n if (this.dependencies.every(dep => {\n return dep instanceof Facet ? oldState.facet(dep) === state.facet(dep) :\n dep instanceof StateField ? oldState.field(dep, false) == state.field(dep, false) : true;\n }) || (multi ? compareArray(newVal = getter(state), oldVal, compare) : compare(newVal = getter(state), oldVal))) {\n state.values[idx] = oldVal;\n return 0;\n }\n }\n else {\n newVal = getter(state);\n }\n state.values[idx] = newVal;\n return 1 /* SlotStatus.Changed */;\n }\n };\n }\n}\nfunction compareArray(a, b, compare) {\n if (a.length != b.length)\n return false;\n for (let i = 0; i < a.length; i++)\n if (!compare(a[i], b[i]))\n return false;\n return true;\n}\nfunction ensureAll(state, addrs) {\n let changed = false;\n for (let addr of addrs)\n if (ensureAddr(state, addr) & 1 /* SlotStatus.Changed */)\n changed = true;\n return changed;\n}\nfunction dynamicFacetSlot(addresses, facet, providers) {\n let providerAddrs = providers.map(p => addresses[p.id]);\n let providerTypes = providers.map(p => p.type);\n let dynamic = providerAddrs.filter(p => !(p & 1));\n let idx = addresses[facet.id] >> 1;\n function get(state) {\n let values = [];\n for (let i = 0; i < providerAddrs.length; i++) {\n let value = getAddr(state, providerAddrs[i]);\n if (providerTypes[i] == 2 /* Provider.Multi */)\n for (let val of value)\n values.push(val);\n else\n values.push(value);\n }\n return facet.combine(values);\n }\n return {\n create(state) {\n for (let addr of providerAddrs)\n ensureAddr(state, addr);\n state.values[idx] = get(state);\n return 1 /* SlotStatus.Changed */;\n },\n update(state, tr) {\n if (!ensureAll(state, dynamic))\n return 0;\n let value = get(state);\n if (facet.compare(value, state.values[idx]))\n return 0;\n state.values[idx] = value;\n return 1 /* SlotStatus.Changed */;\n },\n reconfigure(state, oldState) {\n let depChanged = ensureAll(state, providerAddrs);\n let oldProviders = oldState.config.facets[facet.id], oldValue = oldState.facet(facet);\n if (oldProviders && !depChanged && sameArray(providers, oldProviders)) {\n state.values[idx] = oldValue;\n return 0;\n }\n let value = get(state);\n if (facet.compare(value, oldValue)) {\n state.values[idx] = oldValue;\n return 0;\n }\n state.values[idx] = value;\n return 1 /* SlotStatus.Changed */;\n }\n };\n}\nconst initField = /*@__PURE__*/Facet.define({ static: true });\n/**\nFields can store additional information in an editor state, and\nkeep it in sync with the rest of the state.\n*/\nclass StateField {\n constructor(\n /**\n @internal\n */\n id, createF, updateF, compareF, \n /**\n @internal\n */\n spec) {\n this.id = id;\n this.createF = createF;\n this.updateF = updateF;\n this.compareF = compareF;\n this.spec = spec;\n /**\n @internal\n */\n this.provides = undefined;\n }\n /**\n Define a state field.\n */\n static define(config) {\n let field = new StateField(nextID++, config.create, config.update, config.compare || ((a, b) => a === b), config);\n if (config.provide)\n field.provides = config.provide(field);\n return field;\n }\n create(state) {\n let init = state.facet(initField).find(i => i.field == this);\n return ((init === null || init === void 0 ? void 0 : init.create) || this.createF)(state);\n }\n /**\n @internal\n */\n slot(addresses) {\n let idx = addresses[this.id] >> 1;\n return {\n create: (state) => {\n state.values[idx] = this.create(state);\n return 1 /* SlotStatus.Changed */;\n },\n update: (state, tr) => {\n let oldVal = state.values[idx];\n let value = this.updateF(oldVal, tr);\n if (this.compareF(oldVal, value))\n return 0;\n state.values[idx] = value;\n return 1 /* SlotStatus.Changed */;\n },\n reconfigure: (state, oldState) => {\n if (oldState.config.address[this.id] != null) {\n state.values[idx] = oldState.field(this);\n return 0;\n }\n state.values[idx] = this.create(state);\n return 1 /* SlotStatus.Changed */;\n }\n };\n }\n /**\n Returns an extension that enables this field and overrides the\n way it is initialized. Can be useful when you need to provide a\n non-default starting value for the field.\n */\n init(create) {\n return [this, initField.of({ field: this, create })];\n }\n /**\n State field instances can be used as\n [`Extension`](https://codemirror.net/6/docs/ref/#state.Extension) values to enable the field in a\n given state.\n */\n get extension() { return this; }\n}\nconst Prec_ = { lowest: 4, low: 3, default: 2, high: 1, highest: 0 };\nfunction prec(value) {\n return (ext) => new PrecExtension(ext, value);\n}\n/**\nBy default extensions are registered in the order they are found\nin the flattened form of nested array that was provided.\nIndividual extension values can be assigned a precedence to\noverride this. Extensions that do not have a precedence set get\nthe precedence of the nearest parent with a precedence, or\n[`default`](https://codemirror.net/6/docs/ref/#state.Prec.default) if there is no such parent. The\nfinal ordering of extensions is determined by first sorting by\nprecedence and then by order within each precedence.\n*/\nconst Prec = {\n /**\n The highest precedence level, for extensions that should end up\n near the start of the precedence ordering.\n */\n highest: /*@__PURE__*/prec(Prec_.highest),\n /**\n A higher-than-default precedence, for extensions that should\n come before those with default precedence.\n */\n high: /*@__PURE__*/prec(Prec_.high),\n /**\n The default precedence, which is also used for extensions\n without an explicit precedence.\n */\n default: /*@__PURE__*/prec(Prec_.default),\n /**\n A lower-than-default precedence.\n */\n low: /*@__PURE__*/prec(Prec_.low),\n /**\n The lowest precedence level. Meant for things that should end up\n near the end of the extension order.\n */\n lowest: /*@__PURE__*/prec(Prec_.lowest)\n};\nclass PrecExtension {\n constructor(inner, prec) {\n this.inner = inner;\n this.prec = prec;\n }\n}\n/**\nExtension compartments can be used to make a configuration\ndynamic. By [wrapping](https://codemirror.net/6/docs/ref/#state.Compartment.of) part of your\nconfiguration in a compartment, you can later\n[replace](https://codemirror.net/6/docs/ref/#state.Compartment.reconfigure) that part through a\ntransaction.\n*/\nclass Compartment {\n /**\n Create an instance of this compartment to add to your [state\n configuration](https://codemirror.net/6/docs/ref/#state.EditorStateConfig.extensions).\n */\n of(ext) { return new CompartmentInstance(this, ext); }\n /**\n Create an [effect](https://codemirror.net/6/docs/ref/#state.TransactionSpec.effects) that\n reconfigures this compartment.\n */\n reconfigure(content) {\n return Compartment.reconfigure.of({ compartment: this, extension: content });\n }\n /**\n Get the current content of the compartment in the state, or\n `undefined` if it isn't present.\n */\n get(state) {\n return state.config.compartments.get(this);\n }\n}\nclass CompartmentInstance {\n constructor(compartment, inner) {\n this.compartment = compartment;\n this.inner = inner;\n }\n}\nclass Configuration {\n constructor(base, compartments, dynamicSlots, address, staticValues, facets) {\n this.base = base;\n this.compartments = compartments;\n this.dynamicSlots = dynamicSlots;\n this.address = address;\n this.staticValues = staticValues;\n this.facets = facets;\n this.statusTemplate = [];\n while (this.statusTemplate.length < dynamicSlots.length)\n this.statusTemplate.push(0 /* SlotStatus.Unresolved */);\n }\n staticFacet(facet) {\n let addr = this.address[facet.id];\n return addr == null ? facet.default : this.staticValues[addr >> 1];\n }\n static resolve(base, compartments, oldState) {\n let fields = [];\n let facets = Object.create(null);\n let newCompartments = new Map();\n for (let ext of flatten(base, compartments, newCompartments)) {\n if (ext instanceof StateField)\n fields.push(ext);\n else\n (facets[ext.facet.id] || (facets[ext.facet.id] = [])).push(ext);\n }\n let address = Object.create(null);\n let staticValues = [];\n let dynamicSlots = [];\n for (let field of fields) {\n address[field.id] = dynamicSlots.length << 1;\n dynamicSlots.push(a => field.slot(a));\n }\n let oldFacets = oldState === null || oldState === void 0 ? void 0 : oldState.config.facets;\n for (let id in facets) {\n let providers = facets[id], facet = providers[0].facet;\n let oldProviders = oldFacets && oldFacets[id] || [];\n if (providers.every(p => p.type == 0 /* Provider.Static */)) {\n address[facet.id] = (staticValues.length << 1) | 1;\n if (sameArray(oldProviders, providers)) {\n staticValues.push(oldState.facet(facet));\n }\n else {\n let value = facet.combine(providers.map(p => p.value));\n staticValues.push(oldState && facet.compare(value, oldState.facet(facet)) ? oldState.facet(facet) : value);\n }\n }\n else {\n for (let p of providers) {\n if (p.type == 0 /* Provider.Static */) {\n address[p.id] = (staticValues.length << 1) | 1;\n staticValues.push(p.value);\n }\n else {\n address[p.id] = dynamicSlots.length << 1;\n dynamicSlots.push(a => p.dynamicSlot(a));\n }\n }\n address[facet.id] = dynamicSlots.length << 1;\n dynamicSlots.push(a => dynamicFacetSlot(a, facet, providers));\n }\n }\n let dynamic = dynamicSlots.map(f => f(address));\n return new Configuration(base, newCompartments, dynamic, address, staticValues, facets);\n }\n}\nfunction flatten(extension, compartments, newCompartments) {\n let result = [[], [], [], [], []];\n let seen = new Map();\n function inner(ext, prec) {\n let known = seen.get(ext);\n if (known != null) {\n if (known <= prec)\n return;\n let found = result[known].indexOf(ext);\n if (found > -1)\n result[known].splice(found, 1);\n if (ext instanceof CompartmentInstance)\n newCompartments.delete(ext.compartment);\n }\n seen.set(ext, prec);\n if (Array.isArray(ext)) {\n for (let e of ext)\n inner(e, prec);\n }\n else if (ext instanceof CompartmentInstance) {\n if (newCompartments.has(ext.compartment))\n throw new RangeError(`Duplicate use of compartment in extensions`);\n let content = compartments.get(ext.compartment) || ext.inner;\n newCompartments.set(ext.compartment, content);\n inner(content, prec);\n }\n else if (ext instanceof PrecExtension) {\n inner(ext.inner, ext.prec);\n }\n else if (ext instanceof StateField) {\n result[prec].push(ext);\n if (ext.provides)\n inner(ext.provides, prec);\n }\n else if (ext instanceof FacetProvider) {\n result[prec].push(ext);\n if (ext.facet.extensions)\n inner(ext.facet.extensions, Prec_.default);\n }\n else {\n let content = ext.extension;\n if (!content)\n throw new Error(`Unrecognized extension value in extension set (${ext}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);\n inner(content, prec);\n }\n }\n inner(extension, Prec_.default);\n return result.reduce((a, b) => a.concat(b));\n}\nfunction ensureAddr(state, addr) {\n if (addr & 1)\n return 2 /* SlotStatus.Computed */;\n let idx = addr >> 1;\n let status = state.status[idx];\n if (status == 4 /* SlotStatus.Computing */)\n throw new Error(\"Cyclic dependency between fields and/or facets\");\n if (status & 2 /* SlotStatus.Computed */)\n return status;\n state.status[idx] = 4 /* SlotStatus.Computing */;\n let changed = state.computeSlot(state, state.config.dynamicSlots[idx]);\n return state.status[idx] = 2 /* SlotStatus.Computed */ | changed;\n}\nfunction getAddr(state, addr) {\n return addr & 1 ? state.config.staticValues[addr >> 1] : state.values[addr >> 1];\n}\n\nconst languageData = /*@__PURE__*/Facet.define();\nconst allowMultipleSelections = /*@__PURE__*/Facet.define({\n combine: values => values.some(v => v),\n static: true\n});\nconst lineSeparator = /*@__PURE__*/Facet.define({\n combine: values => values.length ? values[0] : undefined,\n static: true\n});\nconst changeFilter = /*@__PURE__*/Facet.define();\nconst transactionFilter = /*@__PURE__*/Facet.define();\nconst transactionExtender = /*@__PURE__*/Facet.define();\nconst readOnly = /*@__PURE__*/Facet.define({\n combine: values => values.length ? values[0] : false\n});\n\n/**\nAnnotations are tagged values that are used to add metadata to\ntransactions in an extensible way. They should be used to model\nthings that effect the entire transaction (such as its [time\nstamp](https://codemirror.net/6/docs/ref/#state.Transaction^time) or information about its\n[origin](https://codemirror.net/6/docs/ref/#state.Transaction^userEvent)). For effects that happen\n_alongside_ the other changes made by the transaction, [state\neffects](https://codemirror.net/6/docs/ref/#state.StateEffect) are more appropriate.\n*/\nclass Annotation {\n /**\n @internal\n */\n constructor(\n /**\n The annotation type.\n */\n type, \n /**\n The value of this annotation.\n */\n value) {\n this.type = type;\n this.value = value;\n }\n /**\n Define a new type of annotation.\n */\n static define() { return new AnnotationType(); }\n}\n/**\nMarker that identifies a type of [annotation](https://codemirror.net/6/docs/ref/#state.Annotation).\n*/\nclass AnnotationType {\n /**\n Create an instance of this annotation.\n */\n of(value) { return new Annotation(this, value); }\n}\n/**\nRepresentation of a type of state effect. Defined with\n[`StateEffect.define`](https://codemirror.net/6/docs/ref/#state.StateEffect^define).\n*/\nclass StateEffectType {\n /**\n @internal\n */\n constructor(\n // The `any` types in these function types are there to work\n // around TypeScript issue #37631, where the type guard on\n // `StateEffect.is` mysteriously stops working when these properly\n // have type `Value`.\n /**\n @internal\n */\n map) {\n this.map = map;\n }\n /**\n Create a [state effect](https://codemirror.net/6/docs/ref/#state.StateEffect) instance of this\n type.\n */\n of(value) { return new StateEffect(this, value); }\n}\n/**\nState effects can be used to represent additional effects\nassociated with a [transaction](https://codemirror.net/6/docs/ref/#state.Transaction.effects). They\nare often useful to model changes to custom [state\nfields](https://codemirror.net/6/docs/ref/#state.StateField), when those changes aren't implicit in\ndocument or selection changes.\n*/\nclass StateEffect {\n /**\n @internal\n */\n constructor(\n /**\n @internal\n */\n type, \n /**\n The value of this effect.\n */\n value) {\n this.type = type;\n this.value = value;\n }\n /**\n Map this effect through a position mapping. Will return\n `undefined` when that ends up deleting the effect.\n */\n map(mapping) {\n let mapped = this.type.map(this.value, mapping);\n return mapped === undefined ? undefined : mapped == this.value ? this : new StateEffect(this.type, mapped);\n }\n /**\n Tells you whether this effect object is of a given\n [type](https://codemirror.net/6/docs/ref/#state.StateEffectType).\n */\n is(type) { return this.type == type; }\n /**\n Define a new effect type. The type parameter indicates the type\n of values that his effect holds. It should be a type that\n doesn't include `undefined`, since that is used in\n [mapping](https://codemirror.net/6/docs/ref/#state.StateEffect.map) to indicate that an effect is\n removed.\n */\n static define(spec = {}) {\n return new StateEffectType(spec.map || (v => v));\n }\n /**\n Map an array of effects through a change set.\n */\n static mapEffects(effects, mapping) {\n if (!effects.length)\n return effects;\n let result = [];\n for (let effect of effects) {\n let mapped = effect.map(mapping);\n if (mapped)\n result.push(mapped);\n }\n return result;\n }\n}\n/**\nThis effect can be used to reconfigure the root extensions of\nthe editor. Doing this will discard any extensions\n[appended](https://codemirror.net/6/docs/ref/#state.StateEffect^appendConfig), but does not reset\nthe content of [reconfigured](https://codemirror.net/6/docs/ref/#state.Compartment.reconfigure)\ncompartments.\n*/\nStateEffect.reconfigure = /*@__PURE__*/StateEffect.define();\n/**\nAppend extensions to the top-level configuration of the editor.\n*/\nStateEffect.appendConfig = /*@__PURE__*/StateEffect.define();\n/**\nChanges to the editor state are grouped into transactions.\nTypically, a user action creates a single transaction, which may\ncontain any number of document changes, may change the selection,\nor have other effects. Create a transaction by calling\n[`EditorState.update`](https://codemirror.net/6/docs/ref/#state.EditorState.update), or immediately\ndispatch one by calling\n[`EditorView.dispatch`](https://codemirror.net/6/docs/ref/#view.EditorView.dispatch).\n*/\nclass Transaction {\n constructor(\n /**\n The state from which the transaction starts.\n */\n startState, \n /**\n The document changes made by this transaction.\n */\n changes, \n /**\n The selection set by this transaction, or undefined if it\n doesn't explicitly set a selection.\n */\n selection, \n /**\n The effects added to the transaction.\n */\n effects, \n /**\n @internal\n */\n annotations, \n /**\n Whether the selection should be scrolled into view after this\n transaction is dispatched.\n */\n scrollIntoView) {\n this.startState = startState;\n this.changes = changes;\n this.selection = selection;\n this.effects = effects;\n this.annotations = annotations;\n this.scrollIntoView = scrollIntoView;\n /**\n @internal\n */\n this._doc = null;\n /**\n @internal\n */\n this._state = null;\n if (selection)\n checkSelection(selection, changes.newLength);\n if (!annotations.some((a) => a.type == Transaction.time))\n this.annotations = annotations.concat(Transaction.time.of(Date.now()));\n }\n /**\n @internal\n */\n static create(startState, changes, selection, effects, annotations, scrollIntoView) {\n return new Transaction(startState, changes, selection, effects, annotations, scrollIntoView);\n }\n /**\n The new document produced by the transaction. Contrary to\n [`.state`](https://codemirror.net/6/docs/ref/#state.Transaction.state)`.doc`, accessing this won't\n force the entire new state to be computed right away, so it is\n recommended that [transaction\n filters](https://codemirror.net/6/docs/ref/#state.EditorState^transactionFilter) use this getter\n when they need to look at the new document.\n */\n get newDoc() {\n return this._doc || (this._doc = this.changes.apply(this.startState.doc));\n }\n /**\n The new selection produced by the transaction. If\n [`this.selection`](https://codemirror.net/6/docs/ref/#state.Transaction.selection) is undefined,\n this will [map](https://codemirror.net/6/docs/ref/#state.EditorSelection.map) the start state's\n current selection through the changes made by the transaction.\n */\n get newSelection() {\n return this.selection || this.startState.selection.map(this.changes);\n }\n /**\n The new state created by the transaction. Computed on demand\n (but retained for subsequent access), so it is recommended not to\n access it in [transaction\n filters](https://codemirror.net/6/docs/ref/#state.EditorState^transactionFilter) when possible.\n */\n get state() {\n if (!this._state)\n this.startState.applyTransaction(this);\n return this._state;\n }\n /**\n Get the value of the given annotation type, if any.\n */\n annotation(type) {\n for (let ann of this.annotations)\n if (ann.type == type)\n return ann.value;\n return undefined;\n }\n /**\n Indicates whether the transaction changed the document.\n */\n get docChanged() { return !this.changes.empty; }\n /**\n Indicates whether this transaction reconfigures the state\n (through a [configuration compartment](https://codemirror.net/6/docs/ref/#state.Compartment) or\n with a top-level configuration\n [effect](https://codemirror.net/6/docs/ref/#state.StateEffect^reconfigure).\n */\n get reconfigured() { return this.startState.config != this.state.config; }\n /**\n Returns true if the transaction has a [user\n event](https://codemirror.net/6/docs/ref/#state.Transaction^userEvent) annotation that is equal to\n or more specific than `event`. For example, if the transaction\n has `\"select.pointer\"` as user event, `\"select\"` and\n `\"select.pointer\"` will match it.\n */\n isUserEvent(event) {\n let e = this.annotation(Transaction.userEvent);\n return !!(e && (e == event || e.length > event.length && e.slice(0, event.length) == event && e[event.length] == \".\"));\n }\n}\n/**\nAnnotation used to store transaction timestamps. Automatically\nadded to every transaction, holding `Date.now()`.\n*/\nTransaction.time = /*@__PURE__*/Annotation.define();\n/**\nAnnotation used to associate a transaction with a user interface\nevent. Holds a string identifying the event, using a\ndot-separated format to support attaching more specific\ninformation. The events used by the core libraries are:\n\n - `\"input\"` when content is entered\n - `\"input.type\"` for typed input\n - `\"input.type.compose\"` for composition\n - `\"input.paste\"` for pasted input\n - `\"input.drop\"` when adding content with drag-and-drop\n - `\"input.complete\"` when autocompleting\n - `\"delete\"` when the user deletes content\n - `\"delete.selection\"` when deleting the selection\n - `\"delete.forward\"` when deleting forward from the selection\n - `\"delete.backward\"` when deleting backward from the selection\n - `\"delete.cut\"` when cutting to the clipboard\n - `\"move\"` when content is moved\n - `\"move.drop\"` when content is moved within the editor through drag-and-drop\n - `\"select\"` when explicitly changing the selection\n - `\"select.pointer\"` when selecting with a mouse or other pointing device\n - `\"undo\"` and `\"redo\"` for history actions\n\nUse [`isUserEvent`](https://codemirror.net/6/docs/ref/#state.Transaction.isUserEvent) to check\nwhether the annotation matches a given event.\n*/\nTransaction.userEvent = /*@__PURE__*/Annotation.define();\n/**\nAnnotation indicating whether a transaction should be added to\nthe undo history or not.\n*/\nTransaction.addToHistory = /*@__PURE__*/Annotation.define();\n/**\nAnnotation indicating (when present and true) that a transaction\nrepresents a change made by some other actor, not the user. This\nis used, for example, to tag other people's changes in\ncollaborative editing.\n*/\nTransaction.remote = /*@__PURE__*/Annotation.define();\nfunction joinRanges(a, b) {\n let result = [];\n for (let iA = 0, iB = 0;;) {\n let from, to;\n if (iA < a.length && (iB == b.length || b[iB] >= a[iA])) {\n from = a[iA++];\n to = a[iA++];\n }\n else if (iB < b.length) {\n from = b[iB++];\n to = b[iB++];\n }\n else\n return result;\n if (!result.length || result[result.length - 1] < from)\n result.push(from, to);\n else if (result[result.length - 1] < to)\n result[result.length - 1] = to;\n }\n}\nfunction mergeTransaction(a, b, sequential) {\n var _a;\n let mapForA, mapForB, changes;\n if (sequential) {\n mapForA = b.changes;\n mapForB = ChangeSet.empty(b.changes.length);\n changes = a.changes.compose(b.changes);\n }\n else {\n mapForA = b.changes.map(a.changes);\n mapForB = a.changes.mapDesc(b.changes, true);\n changes = a.changes.compose(mapForA);\n }\n return {\n changes,\n selection: b.selection ? b.selection.map(mapForB) : (_a = a.selection) === null || _a === void 0 ? void 0 : _a.map(mapForA),\n effects: StateEffect.mapEffects(a.effects, mapForA).concat(StateEffect.mapEffects(b.effects, mapForB)),\n annotations: a.annotations.length ? a.annotations.concat(b.annotations) : b.annotations,\n scrollIntoView: a.scrollIntoView || b.scrollIntoView\n };\n}\nfunction resolveTransactionInner(state, spec, docSize) {\n let sel = spec.selection, annotations = asArray(spec.annotations);\n if (spec.userEvent)\n annotations = annotations.concat(Transaction.userEvent.of(spec.userEvent));\n return {\n changes: spec.changes instanceof ChangeSet ? spec.changes\n : ChangeSet.of(spec.changes || [], docSize, state.facet(lineSeparator)),\n selection: sel && (sel instanceof EditorSelection ? sel : EditorSelection.single(sel.anchor, sel.head)),\n effects: asArray(spec.effects),\n annotations,\n scrollIntoView: !!spec.scrollIntoView\n };\n}\nfunction resolveTransaction(state, specs, filter) {\n let s = resolveTransactionInner(state, specs.length ? specs[0] : {}, state.doc.length);\n if (specs.length && specs[0].filter === false)\n filter = false;\n for (let i = 1; i < specs.length; i++) {\n if (specs[i].filter === false)\n filter = false;\n let seq = !!specs[i].sequential;\n s = mergeTransaction(s, resolveTransactionInner(state, specs[i], seq ? s.changes.newLength : state.doc.length), seq);\n }\n let tr = Transaction.create(state, s.changes, s.selection, s.effects, s.annotations, s.scrollIntoView);\n return extendTransaction(filter ? filterTransaction(tr) : tr);\n}\n// Finish a transaction by applying filters if necessary.\nfunction filterTransaction(tr) {\n let state = tr.startState;\n // Change filters\n let result = true;\n for (let filter of state.facet(changeFilter)) {\n let value = filter(tr);\n if (value === false) {\n result = false;\n break;\n }\n if (Array.isArray(value))\n result = result === true ? value : joinRanges(result, value);\n }\n if (result !== true) {\n let changes, back;\n if (result === false) {\n back = tr.changes.invertedDesc;\n changes = ChangeSet.empty(state.doc.length);\n }\n else {\n let filtered = tr.changes.filter(result);\n changes = filtered.changes;\n back = filtered.filtered.mapDesc(filtered.changes).invertedDesc;\n }\n tr = Transaction.create(state, changes, tr.selection && tr.selection.map(back), StateEffect.mapEffects(tr.effects, back), tr.annotations, tr.scrollIntoView);\n }\n // Transaction filters\n let filters = state.facet(transactionFilter);\n for (let i = filters.length - 1; i >= 0; i--) {\n let filtered = filters[i](tr);\n if (filtered instanceof Transaction)\n tr = filtered;\n else if (Array.isArray(filtered) && filtered.length == 1 && filtered[0] instanceof Transaction)\n tr = filtered[0];\n else\n tr = resolveTransaction(state, asArray(filtered), false);\n }\n return tr;\n}\nfunction extendTransaction(tr) {\n let state = tr.startState, extenders = state.facet(transactionExtender), spec = tr;\n for (let i = extenders.length - 1; i >= 0; i--) {\n let extension = extenders[i](tr);\n if (extension && Object.keys(extension).length)\n spec = mergeTransaction(spec, resolveTransactionInner(state, extension, tr.changes.newLength), true);\n }\n return spec == tr ? tr : Transaction.create(state, tr.changes, tr.selection, spec.effects, spec.annotations, spec.scrollIntoView);\n}\nconst none = [];\nfunction asArray(value) {\n return value == null ? none : Array.isArray(value) ? value : [value];\n}\n\n/**\nThe categories produced by a [character\ncategorizer](https://codemirror.net/6/docs/ref/#state.EditorState.charCategorizer). These are used\ndo things like selecting by word.\n*/\nvar CharCategory = /*@__PURE__*/(function (CharCategory) {\n /**\n Word characters.\n */\n CharCategory[CharCategory[\"Word\"] = 0] = \"Word\";\n /**\n Whitespace.\n */\n CharCategory[CharCategory[\"Space\"] = 1] = \"Space\";\n /**\n Anything else.\n */\n CharCategory[CharCategory[\"Other\"] = 2] = \"Other\";\nreturn CharCategory})(CharCategory || (CharCategory = {}));\nconst nonASCIISingleCaseWordChar = /[\\u00df\\u0587\\u0590-\\u05f4\\u0600-\\u06ff\\u3040-\\u309f\\u30a0-\\u30ff\\u3400-\\u4db5\\u4e00-\\u9fcc\\uac00-\\ud7af]/;\nlet wordChar;\ntry {\n wordChar = /*@__PURE__*/new RegExp(\"[\\\\p{Alphabetic}\\\\p{Number}_]\", \"u\");\n}\ncatch (_) { }\nfunction hasWordChar(str) {\n if (wordChar)\n return wordChar.test(str);\n for (let i = 0; i < str.length; i++) {\n let ch = str[i];\n if (/\\w/.test(ch) || ch > \"\\x80\" && (ch.toUpperCase() != ch.toLowerCase() || nonASCIISingleCaseWordChar.test(ch)))\n return true;\n }\n return false;\n}\nfunction makeCategorizer(wordChars) {\n return (char) => {\n if (!/\\S/.test(char))\n return CharCategory.Space;\n if (hasWordChar(char))\n return CharCategory.Word;\n for (let i = 0; i < wordChars.length; i++)\n if (char.indexOf(wordChars[i]) > -1)\n return CharCategory.Word;\n return CharCategory.Other;\n };\n}\n\n/**\nThe editor state class is a persistent (immutable) data structure.\nTo update a state, you [create](https://codemirror.net/6/docs/ref/#state.EditorState.update) a\n[transaction](https://codemirror.net/6/docs/ref/#state.Transaction), which produces a _new_ state\ninstance, without modifying the original object.\n\nAs such, _never_ mutate properties of a state directly. That'll\njust break things.\n*/\nclass EditorState {\n constructor(\n /**\n @internal\n */\n config, \n /**\n The current document.\n */\n doc, \n /**\n The current selection.\n */\n selection, \n /**\n @internal\n */\n values, computeSlot, tr) {\n this.config = config;\n this.doc = doc;\n this.selection = selection;\n this.values = values;\n this.status = config.statusTemplate.slice();\n this.computeSlot = computeSlot;\n // Fill in the computed state immediately, so that further queries\n // for it made during the update return this state\n if (tr)\n tr._state = this;\n for (let i = 0; i < this.config.dynamicSlots.length; i++)\n ensureAddr(this, i << 1);\n this.computeSlot = null;\n }\n field(field, require = true) {\n let addr = this.config.address[field.id];\n if (addr == null) {\n if (require)\n throw new RangeError(\"Field is not present in this state\");\n return undefined;\n }\n ensureAddr(this, addr);\n return getAddr(this, addr);\n }\n /**\n Create a [transaction](https://codemirror.net/6/docs/ref/#state.Transaction) that updates this\n state. Any number of [transaction specs](https://codemirror.net/6/docs/ref/#state.TransactionSpec)\n can be passed. Unless\n [`sequential`](https://codemirror.net/6/docs/ref/#state.TransactionSpec.sequential) is set, the\n [changes](https://codemirror.net/6/docs/ref/#state.TransactionSpec.changes) (if any) of each spec\n are assumed to start in the _current_ document (not the document\n produced by previous specs), and its\n [selection](https://codemirror.net/6/docs/ref/#state.TransactionSpec.selection) and\n [effects](https://codemirror.net/6/docs/ref/#state.TransactionSpec.effects) are assumed to refer\n to the document created by its _own_ changes. The resulting\n transaction contains the combined effect of all the different\n specs. For [selection](https://codemirror.net/6/docs/ref/#state.TransactionSpec.selection), later\n specs take precedence over earlier ones.\n */\n update(...specs) {\n return resolveTransaction(this, specs, true);\n }\n /**\n @internal\n */\n applyTransaction(tr) {\n let conf = this.config, { base, compartments } = conf;\n for (let effect of tr.effects) {\n if (effect.is(Compartment.reconfigure)) {\n if (conf) {\n compartments = new Map;\n conf.compartments.forEach((val, key) => compartments.set(key, val));\n conf = null;\n }\n compartments.set(effect.value.compartment, effect.value.extension);\n }\n else if (effect.is(StateEffect.reconfigure)) {\n conf = null;\n base = effect.value;\n }\n else if (effect.is(StateEffect.appendConfig)) {\n conf = null;\n base = asArray(base).concat(effect.value);\n }\n }\n let startValues;\n if (!conf) {\n conf = Configuration.resolve(base, compartments, this);\n let intermediateState = new EditorState(conf, this.doc, this.selection, conf.dynamicSlots.map(() => null), (state, slot) => slot.reconfigure(state, this), null);\n startValues = intermediateState.values;\n }\n else {\n startValues = tr.startState.values.slice();\n }\n new EditorState(conf, tr.newDoc, tr.newSelection, startValues, (state, slot) => slot.update(state, tr), tr);\n }\n /**\n Create a [transaction spec](https://codemirror.net/6/docs/ref/#state.TransactionSpec) that\n replaces every selection range with the given content.\n */\n replaceSelection(text) {\n if (typeof text == \"string\")\n text = this.toText(text);\n return this.changeByRange(range => ({ changes: { from: range.from, to: range.to, insert: text },\n range: EditorSelection.cursor(range.from + text.length) }));\n }\n /**\n Create a set of changes and a new selection by running the given\n function for each range in the active selection. The function\n can return an optional set of changes (in the coordinate space\n of the start document), plus an updated range (in the coordinate\n space of the document produced by the call's own changes). This\n method will merge all the changes and ranges into a single\n changeset and selection, and return it as a [transaction\n spec](https://codemirror.net/6/docs/ref/#state.TransactionSpec), which can be passed to\n [`update`](https://codemirror.net/6/docs/ref/#state.EditorState.update).\n */\n changeByRange(f) {\n let sel = this.selection;\n let result1 = f(sel.ranges[0]);\n let changes = this.changes(result1.changes), ranges = [result1.range];\n let effects = asArray(result1.effects);\n for (let i = 1; i < sel.ranges.length; i++) {\n let result = f(sel.ranges[i]);\n let newChanges = this.changes(result.changes), newMapped = newChanges.map(changes);\n for (let j = 0; j < i; j++)\n ranges[j] = ranges[j].map(newMapped);\n let mapBy = changes.mapDesc(newChanges, true);\n ranges.push(result.range.map(mapBy));\n changes = changes.compose(newMapped);\n effects = StateEffect.mapEffects(effects, newMapped).concat(StateEffect.mapEffects(asArray(result.effects), mapBy));\n }\n return {\n changes,\n selection: EditorSelection.create(ranges, sel.mainIndex),\n effects\n };\n }\n /**\n Create a [change set](https://codemirror.net/6/docs/ref/#state.ChangeSet) from the given change\n description, taking the state's document length and line\n separator into account.\n */\n changes(spec = []) {\n if (spec instanceof ChangeSet)\n return spec;\n return ChangeSet.of(spec, this.doc.length, this.facet(EditorState.lineSeparator));\n }\n /**\n Using the state's [line\n separator](https://codemirror.net/6/docs/ref/#state.EditorState^lineSeparator), create a\n [`Text`](https://codemirror.net/6/docs/ref/#state.Text) instance from the given string.\n */\n toText(string) {\n return Text.of(string.split(this.facet(EditorState.lineSeparator) || DefaultSplit));\n }\n /**\n Return the given range of the document as a string.\n */\n sliceDoc(from = 0, to = this.doc.length) {\n return this.doc.sliceString(from, to, this.lineBreak);\n }\n /**\n Get the value of a state [facet](https://codemirror.net/6/docs/ref/#state.Facet).\n */\n facet(facet) {\n let addr = this.config.address[facet.id];\n if (addr == null)\n return facet.default;\n ensureAddr(this, addr);\n return getAddr(this, addr);\n }\n /**\n Convert this state to a JSON-serializable object. When custom\n fields should be serialized, you can pass them in as an object\n mapping property names (in the resulting object, which should\n not use `doc` or `selection`) to fields.\n */\n toJSON(fields) {\n let result = {\n doc: this.sliceDoc(),\n selection: this.selection.toJSON()\n };\n if (fields)\n for (let prop in fields) {\n let value = fields[prop];\n if (value instanceof StateField && this.config.address[value.id] != null)\n result[prop] = value.spec.toJSON(this.field(fields[prop]), this);\n }\n return result;\n }\n /**\n Deserialize a state from its JSON representation. When custom\n fields should be deserialized, pass the same object you passed\n to [`toJSON`](https://codemirror.net/6/docs/ref/#state.EditorState.toJSON) when serializing as\n third argument.\n */\n static fromJSON(json, config = {}, fields) {\n if (!json || typeof json.doc != \"string\")\n throw new RangeError(\"Invalid JSON representation for EditorState\");\n let fieldInit = [];\n if (fields)\n for (let prop in fields) {\n if (Object.prototype.hasOwnProperty.call(json, prop)) {\n let field = fields[prop], value = json[prop];\n fieldInit.push(field.init(state => field.spec.fromJSON(value, state)));\n }\n }\n return EditorState.create({\n doc: json.doc,\n selection: EditorSelection.fromJSON(json.selection),\n extensions: config.extensions ? fieldInit.concat([config.extensions]) : fieldInit\n });\n }\n /**\n Create a new state. You'll usually only need this when\n initializing an editor—updated states are created by applying\n transactions.\n */\n static create(config = {}) {\n let configuration = Configuration.resolve(config.extensions || [], new Map);\n let doc = config.doc instanceof Text ? config.doc\n : Text.of((config.doc || \"\").split(configuration.staticFacet(EditorState.lineSeparator) || DefaultSplit));\n let selection = !config.selection ? EditorSelection.single(0)\n : config.selection instanceof EditorSelection ? config.selection\n : EditorSelection.single(config.selection.anchor, config.selection.head);\n checkSelection(selection, doc.length);\n if (!configuration.staticFacet(allowMultipleSelections))\n selection = selection.asSingle();\n return new EditorState(configuration, doc, selection, configuration.dynamicSlots.map(() => null), (state, slot) => slot.create(state), null);\n }\n /**\n The size (in columns) of a tab in the document, determined by\n the [`tabSize`](https://codemirror.net/6/docs/ref/#state.EditorState^tabSize) facet.\n */\n get tabSize() { return this.facet(EditorState.tabSize); }\n /**\n Get the proper [line-break](https://codemirror.net/6/docs/ref/#state.EditorState^lineSeparator)\n string for this state.\n */\n get lineBreak() { return this.facet(EditorState.lineSeparator) || \"\\n\"; }\n /**\n Returns true when the editor is\n [configured](https://codemirror.net/6/docs/ref/#state.EditorState^readOnly) to be read-only.\n */\n get readOnly() { return this.facet(readOnly); }\n /**\n Look up a translation for the given phrase (via the\n [`phrases`](https://codemirror.net/6/docs/ref/#state.EditorState^phrases) facet), or return the\n original string if no translation is found.\n \n If additional arguments are passed, they will be inserted in\n place of markers like `$1` (for the first value) and `$2`, etc.\n A single `$` is equivalent to `$1`, and `$$` will produce a\n literal dollar sign.\n */\n phrase(phrase, ...insert) {\n for (let map of this.facet(EditorState.phrases))\n if (Object.prototype.hasOwnProperty.call(map, phrase)) {\n phrase = map[phrase];\n break;\n }\n if (insert.length)\n phrase = phrase.replace(/\\$(\\$|\\d*)/g, (m, i) => {\n if (i == \"$\")\n return \"$\";\n let n = +(i || 1);\n return !n || n > insert.length ? m : insert[n - 1];\n });\n return phrase;\n }\n /**\n Find the values for a given language data field, provided by the\n the [`languageData`](https://codemirror.net/6/docs/ref/#state.EditorState^languageData) facet.\n \n Examples of language data fields are...\n \n - [`\"commentTokens\"`](https://codemirror.net/6/docs/ref/#commands.CommentTokens) for specifying\n comment syntax.\n - [`\"autocomplete\"`](https://codemirror.net/6/docs/ref/#autocomplete.autocompletion^config.override)\n for providing language-specific completion sources.\n - [`\"wordChars\"`](https://codemirror.net/6/docs/ref/#state.EditorState.charCategorizer) for adding\n characters that should be considered part of words in this\n language.\n - [`\"closeBrackets\"`](https://codemirror.net/6/docs/ref/#autocomplete.CloseBracketConfig) controls\n bracket closing behavior.\n */\n languageDataAt(name, pos, side = -1) {\n let values = [];\n for (let provider of this.facet(languageData)) {\n for (let result of provider(this, pos, side)) {\n if (Object.prototype.hasOwnProperty.call(result, name))\n values.push(result[name]);\n }\n }\n return values;\n }\n /**\n Return a function that can categorize strings (expected to\n represent a single [grapheme cluster](https://codemirror.net/6/docs/ref/#state.findClusterBreak))\n into one of:\n \n - Word (contains an alphanumeric character or a character\n explicitly listed in the local language's `\"wordChars\"`\n language data, which should be a string)\n - Space (contains only whitespace)\n - Other (anything else)\n */\n charCategorizer(at) {\n return makeCategorizer(this.languageDataAt(\"wordChars\", at).join(\"\"));\n }\n /**\n Find the word at the given position, meaning the range\n containing all [word](https://codemirror.net/6/docs/ref/#state.CharCategory.Word) characters\n around it. If no word characters are adjacent to the position,\n this returns null.\n */\n wordAt(pos) {\n let { text, from, length } = this.doc.lineAt(pos);\n let cat = this.charCategorizer(pos);\n let start = pos - from, end = pos - from;\n while (start > 0) {\n let prev = findClusterBreak(text, start, false);\n if (cat(text.slice(prev, start)) != CharCategory.Word)\n break;\n start = prev;\n }\n while (end < length) {\n let next = findClusterBreak(text, end);\n if (cat(text.slice(end, next)) != CharCategory.Word)\n break;\n end = next;\n }\n return start == end ? null : EditorSelection.range(start + from, end + from);\n }\n}\n/**\nA facet that, when enabled, causes the editor to allow multiple\nranges to be selected. Be careful though, because by default the\neditor relies on the native DOM selection, which cannot handle\nmultiple selections. An extension like\n[`drawSelection`](https://codemirror.net/6/docs/ref/#view.drawSelection) can be used to make\nsecondary selections visible to the user.\n*/\nEditorState.allowMultipleSelections = allowMultipleSelections;\n/**\nConfigures the tab size to use in this state. The first\n(highest-precedence) value of the facet is used. If no value is\ngiven, this defaults to 4.\n*/\nEditorState.tabSize = /*@__PURE__*/Facet.define({\n combine: values => values.length ? values[0] : 4\n});\n/**\nThe line separator to use. By default, any of `\"\\n\"`, `\"\\r\\n\"`\nand `\"\\r\"` is treated as a separator when splitting lines, and\nlines are joined with `\"\\n\"`.\n\nWhen you configure a value here, only that precise separator\nwill be used, allowing you to round-trip documents through the\neditor without normalizing line separators.\n*/\nEditorState.lineSeparator = lineSeparator;\n/**\nThis facet controls the value of the\n[`readOnly`](https://codemirror.net/6/docs/ref/#state.EditorState.readOnly) getter, which is\nconsulted by commands and extensions that implement editing\nfunctionality to determine whether they should apply. It\ndefaults to false, but when its highest-precedence value is\n`true`, such functionality disables itself.\n\nNot to be confused with\n[`EditorView.editable`](https://codemirror.net/6/docs/ref/#view.EditorView^editable), which\ncontrols whether the editor's DOM is set to be editable (and\nthus focusable).\n*/\nEditorState.readOnly = readOnly;\n/**\nRegisters translation phrases. The\n[`phrase`](https://codemirror.net/6/docs/ref/#state.EditorState.phrase) method will look through\nall objects registered with this facet to find translations for\nits argument.\n*/\nEditorState.phrases = /*@__PURE__*/Facet.define({\n compare(a, b) {\n let kA = Object.keys(a), kB = Object.keys(b);\n return kA.length == kB.length && kA.every(k => a[k] == b[k]);\n }\n});\n/**\nA facet used to register [language\ndata](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt) providers.\n*/\nEditorState.languageData = languageData;\n/**\nFacet used to register change filters, which are called for each\ntransaction (unless explicitly\n[disabled](https://codemirror.net/6/docs/ref/#state.TransactionSpec.filter)), and can suppress\npart of the transaction's changes.\n\nSuch a function can return `true` to indicate that it doesn't\nwant to do anything, `false` to completely stop the changes in\nthe transaction, or a set of ranges in which changes should be\nsuppressed. Such ranges are represented as an array of numbers,\nwith each pair of two numbers indicating the start and end of a\nrange. So for example `[10, 20, 100, 110]` suppresses changes\nbetween 10 and 20, and between 100 and 110.\n*/\nEditorState.changeFilter = changeFilter;\n/**\nFacet used to register a hook that gets a chance to update or\nreplace transaction specs before they are applied. This will\nonly be applied for transactions that don't have\n[`filter`](https://codemirror.net/6/docs/ref/#state.TransactionSpec.filter) set to `false`. You\ncan either return a single transaction spec (possibly the input\ntransaction), or an array of specs (which will be combined in\nthe same way as the arguments to\n[`EditorState.update`](https://codemirror.net/6/docs/ref/#state.EditorState.update)).\n\nWhen possible, it is recommended to avoid accessing\n[`Transaction.state`](https://codemirror.net/6/docs/ref/#state.Transaction.state) in a filter,\nsince it will force creation of a state that will then be\ndiscarded again, if the transaction is actually filtered.\n\n(This functionality should be used with care. Indiscriminately\nmodifying transaction is likely to break something or degrade\nthe user experience.)\n*/\nEditorState.transactionFilter = transactionFilter;\n/**\nThis is a more limited form of\n[`transactionFilter`](https://codemirror.net/6/docs/ref/#state.EditorState^transactionFilter),\nwhich can only add\n[annotations](https://codemirror.net/6/docs/ref/#state.TransactionSpec.annotations) and\n[effects](https://codemirror.net/6/docs/ref/#state.TransactionSpec.effects). _But_, this type\nof filter runs even if the transaction has disabled regular\n[filtering](https://codemirror.net/6/docs/ref/#state.TransactionSpec.filter), making it suitable\nfor effects that don't need to touch the changes or selection,\nbut do want to process every transaction.\n\nExtenders run _after_ filters, when both are present.\n*/\nEditorState.transactionExtender = transactionExtender;\nCompartment.reconfigure = /*@__PURE__*/StateEffect.define();\n\n/**\nUtility function for combining behaviors to fill in a config\nobject from an array of provided configs. `defaults` should hold\ndefault values for all optional fields in `Config`.\n\nThe function will, by default, error\nwhen a field gets two values that aren't `===`-equal, but you can\nprovide combine functions per field to do something else.\n*/\nfunction combineConfig(configs, defaults, // Should hold only the optional properties of Config, but I haven't managed to express that\ncombine = {}) {\n let result = {};\n for (let config of configs)\n for (let key of Object.keys(config)) {\n let value = config[key], current = result[key];\n if (current === undefined)\n result[key] = value;\n else if (current === value || value === undefined) ; // No conflict\n else if (Object.hasOwnProperty.call(combine, key))\n result[key] = combine[key](current, value);\n else\n throw new Error(\"Config merge conflict for field \" + key);\n }\n for (let key in defaults)\n if (result[key] === undefined)\n result[key] = defaults[key];\n return result;\n}\n\n/**\nEach range is associated with a value, which must inherit from\nthis class.\n*/\nclass RangeValue {\n /**\n Compare this value with another value. Used when comparing\n rangesets. The default implementation compares by identity.\n Unless you are only creating a fixed number of unique instances\n of your value type, it is a good idea to implement this\n properly.\n */\n eq(other) { return this == other; }\n /**\n Create a [range](https://codemirror.net/6/docs/ref/#state.Range) with this value.\n */\n range(from, to = from) { return Range.create(from, to, this); }\n}\nRangeValue.prototype.startSide = RangeValue.prototype.endSide = 0;\nRangeValue.prototype.point = false;\nRangeValue.prototype.mapMode = MapMode.TrackDel;\n/**\nA range associates a value with a range of positions.\n*/\nclass Range {\n constructor(\n /**\n The range's start position.\n */\n from, \n /**\n Its end position.\n */\n to, \n /**\n The value associated with this range.\n */\n value) {\n this.from = from;\n this.to = to;\n this.value = value;\n }\n /**\n @internal\n */\n static create(from, to, value) {\n return new Range(from, to, value);\n }\n}\nfunction cmpRange(a, b) {\n return a.from - b.from || a.value.startSide - b.value.startSide;\n}\nclass Chunk {\n constructor(from, to, value, \n // Chunks are marked with the largest point that occurs\n // in them (or -1 for no points), so that scans that are\n // only interested in points (such as the\n // heightmap-related logic) can skip range-only chunks.\n maxPoint) {\n this.from = from;\n this.to = to;\n this.value = value;\n this.maxPoint = maxPoint;\n }\n get length() { return this.to[this.to.length - 1]; }\n // Find the index of the given position and side. Use the ranges'\n // `from` pos when `end == false`, `to` when `end == true`.\n findIndex(pos, side, end, startAt = 0) {\n let arr = end ? this.to : this.from;\n for (let lo = startAt, hi = arr.length;;) {\n if (lo == hi)\n return lo;\n let mid = (lo + hi) >> 1;\n let diff = arr[mid] - pos || (end ? this.value[mid].endSide : this.value[mid].startSide) - side;\n if (mid == lo)\n return diff >= 0 ? lo : hi;\n if (diff >= 0)\n hi = mid;\n else\n lo = mid + 1;\n }\n }\n between(offset, from, to, f) {\n for (let i = this.findIndex(from, -1000000000 /* C.Far */, true), e = this.findIndex(to, 1000000000 /* C.Far */, false, i); i < e; i++)\n if (f(this.from[i] + offset, this.to[i] + offset, this.value[i]) === false)\n return false;\n }\n map(offset, changes) {\n let value = [], from = [], to = [], newPos = -1, maxPoint = -1;\n for (let i = 0; i < this.value.length; i++) {\n let val = this.value[i], curFrom = this.from[i] + offset, curTo = this.to[i] + offset, newFrom, newTo;\n if (curFrom == curTo) {\n let mapped = changes.mapPos(curFrom, val.startSide, val.mapMode);\n if (mapped == null)\n continue;\n newFrom = newTo = mapped;\n if (val.startSide != val.endSide) {\n newTo = changes.mapPos(curFrom, val.endSide);\n if (newTo < newFrom)\n continue;\n }\n }\n else {\n newFrom = changes.mapPos(curFrom, val.startSide);\n newTo = changes.mapPos(curTo, val.endSide);\n if (newFrom > newTo || newFrom == newTo && val.startSide > 0 && val.endSide <= 0)\n continue;\n }\n if ((newTo - newFrom || val.endSide - val.startSide) < 0)\n continue;\n if (newPos < 0)\n newPos = newFrom;\n if (val.point)\n maxPoint = Math.max(maxPoint, newTo - newFrom);\n value.push(val);\n from.push(newFrom - newPos);\n to.push(newTo - newPos);\n }\n return { mapped: value.length ? new Chunk(from, to, value, maxPoint) : null, pos: newPos };\n }\n}\n/**\nA range set stores a collection of [ranges](https://codemirror.net/6/docs/ref/#state.Range) in a\nway that makes them efficient to [map](https://codemirror.net/6/docs/ref/#state.RangeSet.map) and\n[update](https://codemirror.net/6/docs/ref/#state.RangeSet.update). This is an immutable data\nstructure.\n*/\nclass RangeSet {\n constructor(\n /**\n @internal\n */\n chunkPos, \n /**\n @internal\n */\n chunk, \n /**\n @internal\n */\n nextLayer, \n /**\n @internal\n */\n maxPoint) {\n this.chunkPos = chunkPos;\n this.chunk = chunk;\n this.nextLayer = nextLayer;\n this.maxPoint = maxPoint;\n }\n /**\n @internal\n */\n static create(chunkPos, chunk, nextLayer, maxPoint) {\n return new RangeSet(chunkPos, chunk, nextLayer, maxPoint);\n }\n /**\n @internal\n */\n get length() {\n let last = this.chunk.length - 1;\n return last < 0 ? 0 : Math.max(this.chunkEnd(last), this.nextLayer.length);\n }\n /**\n The number of ranges in the set.\n */\n get size() {\n if (this.isEmpty)\n return 0;\n let size = this.nextLayer.size;\n for (let chunk of this.chunk)\n size += chunk.value.length;\n return size;\n }\n /**\n @internal\n */\n chunkEnd(index) {\n return this.chunkPos[index] + this.chunk[index].length;\n }\n /**\n Update the range set, optionally adding new ranges or filtering\n out existing ones.\n \n (Note: The type parameter is just there as a kludge to work\n around TypeScript variance issues that prevented `RangeSet<X>`\n from being a subtype of `RangeSet<Y>` when `X` is a subtype of\n `Y`.)\n */\n update(updateSpec) {\n let { add = [], sort = false, filterFrom = 0, filterTo = this.length } = updateSpec;\n let filter = updateSpec.filter;\n if (add.length == 0 && !filter)\n return this;\n if (sort)\n add = add.slice().sort(cmpRange);\n if (this.isEmpty)\n return add.length ? RangeSet.of(add) : this;\n let cur = new LayerCursor(this, null, -1).goto(0), i = 0, spill = [];\n let builder = new RangeSetBuilder();\n while (cur.value || i < add.length) {\n if (i < add.length && (cur.from - add[i].from || cur.startSide - add[i].value.startSide) >= 0) {\n let range = add[i++];\n if (!builder.addInner(range.from, range.to, range.value))\n spill.push(range);\n }\n else if (cur.rangeIndex == 1 && cur.chunkIndex < this.chunk.length &&\n (i == add.length || this.chunkEnd(cur.chunkIndex) < add[i].from) &&\n (!filter || filterFrom > this.chunkEnd(cur.chunkIndex) || filterTo < this.chunkPos[cur.chunkIndex]) &&\n builder.addChunk(this.chunkPos[cur.chunkIndex], this.chunk[cur.chunkIndex])) {\n cur.nextChunk();\n }\n else {\n if (!filter || filterFrom > cur.to || filterTo < cur.from || filter(cur.from, cur.to, cur.value)) {\n if (!builder.addInner(cur.from, cur.to, cur.value))\n spill.push(Range.create(cur.from, cur.to, cur.value));\n }\n cur.next();\n }\n }\n return builder.finishInner(this.nextLayer.isEmpty && !spill.length ? RangeSet.empty\n : this.nextLayer.update({ add: spill, filter, filterFrom, filterTo }));\n }\n /**\n Map this range set through a set of changes, return the new set.\n */\n map(changes) {\n if (changes.empty || this.isEmpty)\n return this;\n let chunks = [], chunkPos = [], maxPoint = -1;\n for (let i = 0; i < this.chunk.length; i++) {\n let start = this.chunkPos[i], chunk = this.chunk[i];\n let touch = changes.touchesRange(start, start + chunk.length);\n if (touch === false) {\n maxPoint = Math.max(maxPoint, chunk.maxPoint);\n chunks.push(chunk);\n chunkPos.push(changes.mapPos(start));\n }\n else if (touch === true) {\n let { mapped, pos } = chunk.map(start, changes);\n if (mapped) {\n maxPoint = Math.max(maxPoint, mapped.maxPoint);\n chunks.push(mapped);\n chunkPos.push(pos);\n }\n }\n }\n let next = this.nextLayer.map(changes);\n return chunks.length == 0 ? next : new RangeSet(chunkPos, chunks, next || RangeSet.empty, maxPoint);\n }\n /**\n Iterate over the ranges that touch the region `from` to `to`,\n calling `f` for each. There is no guarantee that the ranges will\n be reported in any specific order. When the callback returns\n `false`, iteration stops.\n */\n between(from, to, f) {\n if (this.isEmpty)\n return;\n for (let i = 0; i < this.chunk.length; i++) {\n let start = this.chunkPos[i], chunk = this.chunk[i];\n if (to >= start && from <= start + chunk.length &&\n chunk.between(start, from - start, to - start, f) === false)\n return;\n }\n this.nextLayer.between(from, to, f);\n }\n /**\n Iterate over the ranges in this set, in order, including all\n ranges that end at or after `from`.\n */\n iter(from = 0) {\n return HeapCursor.from([this]).goto(from);\n }\n /**\n @internal\n */\n get isEmpty() { return this.nextLayer == this; }\n /**\n Iterate over the ranges in a collection of sets, in order,\n starting from `from`.\n */\n static iter(sets, from = 0) {\n return HeapCursor.from(sets).goto(from);\n }\n /**\n Iterate over two groups of sets, calling methods on `comparator`\n to notify it of possible differences.\n */\n static compare(oldSets, newSets, \n /**\n This indicates how the underlying data changed between these\n ranges, and is needed to synchronize the iteration.\n */\n textDiff, comparator, \n /**\n Can be used to ignore all non-point ranges, and points below\n the given size. When -1, all ranges are compared.\n */\n minPointSize = -1) {\n let a = oldSets.filter(set => set.maxPoint > 0 || !set.isEmpty && set.maxPoint >= minPointSize);\n let b = newSets.filter(set => set.maxPoint > 0 || !set.isEmpty && set.maxPoint >= minPointSize);\n let sharedChunks = findSharedChunks(a, b, textDiff);\n let sideA = new SpanCursor(a, sharedChunks, minPointSize);\n let sideB = new SpanCursor(b, sharedChunks, minPointSize);\n textDiff.iterGaps((fromA, fromB, length) => compare(sideA, fromA, sideB, fromB, length, comparator));\n if (textDiff.empty && textDiff.length == 0)\n compare(sideA, 0, sideB, 0, 0, comparator);\n }\n /**\n Compare the contents of two groups of range sets, returning true\n if they are equivalent in the given range.\n */\n static eq(oldSets, newSets, from = 0, to) {\n if (to == null)\n to = 1000000000 /* C.Far */ - 1;\n let a = oldSets.filter(set => !set.isEmpty && newSets.indexOf(set) < 0);\n let b = newSets.filter(set => !set.isEmpty && oldSets.indexOf(set) < 0);\n if (a.length != b.length)\n return false;\n if (!a.length)\n return true;\n let sharedChunks = findSharedChunks(a, b);\n let sideA = new SpanCursor(a, sharedChunks, 0).goto(from), sideB = new SpanCursor(b, sharedChunks, 0).goto(from);\n for (;;) {\n if (sideA.to != sideB.to ||\n !sameValues(sideA.active, sideB.active) ||\n sideA.point && (!sideB.point || !sideA.point.eq(sideB.point)))\n return false;\n if (sideA.to > to)\n return true;\n sideA.next();\n sideB.next();\n }\n }\n /**\n Iterate over a group of range sets at the same time, notifying\n the iterator about the ranges covering every given piece of\n content. Returns the open count (see\n [`SpanIterator.span`](https://codemirror.net/6/docs/ref/#state.SpanIterator.span)) at the end\n of the iteration.\n */\n static spans(sets, from, to, iterator, \n /**\n When given and greater than -1, only points of at least this\n size are taken into account.\n */\n minPointSize = -1) {\n let cursor = new SpanCursor(sets, null, minPointSize).goto(from), pos = from;\n let openRanges = cursor.openStart;\n for (;;) {\n let curTo = Math.min(cursor.to, to);\n if (cursor.point) {\n let active = cursor.activeForPoint(cursor.to);\n let openCount = cursor.pointFrom < from ? active.length + 1 : Math.min(active.length, openRanges);\n iterator.point(pos, curTo, cursor.point, active, openCount, cursor.pointRank);\n openRanges = Math.min(cursor.openEnd(curTo), active.length);\n }\n else if (curTo > pos) {\n iterator.span(pos, curTo, cursor.active, openRanges);\n openRanges = cursor.openEnd(curTo);\n }\n if (cursor.to > to)\n return openRanges + (cursor.point && cursor.to > to ? 1 : 0);\n pos = cursor.to;\n cursor.next();\n }\n }\n /**\n Create a range set for the given range or array of ranges. By\n default, this expects the ranges to be _sorted_ (by start\n position and, if two start at the same position,\n `value.startSide`). You can pass `true` as second argument to\n cause the method to sort them.\n */\n static of(ranges, sort = false) {\n let build = new RangeSetBuilder();\n for (let range of ranges instanceof Range ? [ranges] : sort ? lazySort(ranges) : ranges)\n build.add(range.from, range.to, range.value);\n return build.finish();\n }\n}\n/**\nThe empty set of ranges.\n*/\nRangeSet.empty = /*@__PURE__*/new RangeSet([], [], null, -1);\nfunction lazySort(ranges) {\n if (ranges.length > 1)\n for (let prev = ranges[0], i = 1; i < ranges.length; i++) {\n let cur = ranges[i];\n if (cmpRange(prev, cur) > 0)\n return ranges.slice().sort(cmpRange);\n prev = cur;\n }\n return ranges;\n}\nRangeSet.empty.nextLayer = RangeSet.empty;\n/**\nA range set builder is a data structure that helps build up a\n[range set](https://codemirror.net/6/docs/ref/#state.RangeSet) directly, without first allocating\nan array of [`Range`](https://codemirror.net/6/docs/ref/#state.Range) objects.\n*/\nclass RangeSetBuilder {\n finishChunk(newArrays) {\n this.chunks.push(new Chunk(this.from, this.to, this.value, this.maxPoint));\n this.chunkPos.push(this.chunkStart);\n this.chunkStart = -1;\n this.setMaxPoint = Math.max(this.setMaxPoint, this.maxPoint);\n this.maxPoint = -1;\n if (newArrays) {\n this.from = [];\n this.to = [];\n this.value = [];\n }\n }\n /**\n Create an empty builder.\n */\n constructor() {\n this.chunks = [];\n this.chunkPos = [];\n this.chunkStart = -1;\n this.last = null;\n this.lastFrom = -1000000000 /* C.Far */;\n this.lastTo = -1000000000 /* C.Far */;\n this.from = [];\n this.to = [];\n this.value = [];\n this.maxPoint = -1;\n this.setMaxPoint = -1;\n this.nextLayer = null;\n }\n /**\n Add a range. Ranges should be added in sorted (by `from` and\n `value.startSide`) order.\n */\n add(from, to, value) {\n if (!this.addInner(from, to, value))\n (this.nextLayer || (this.nextLayer = new RangeSetBuilder)).add(from, to, value);\n }\n /**\n @internal\n */\n addInner(from, to, value) {\n let diff = from - this.lastTo || value.startSide - this.last.endSide;\n if (diff <= 0 && (from - this.lastFrom || value.startSide - this.last.startSide) < 0)\n throw new Error(\"Ranges must be added sorted by `from` position and `startSide`\");\n if (diff < 0)\n return false;\n if (this.from.length == 250 /* C.ChunkSize */)\n this.finishChunk(true);\n if (this.chunkStart < 0)\n this.chunkStart = from;\n this.from.push(from - this.chunkStart);\n this.to.push(to - this.chunkStart);\n this.last = value;\n this.lastFrom = from;\n this.lastTo = to;\n this.value.push(value);\n if (value.point)\n this.maxPoint = Math.max(this.maxPoint, to - from);\n return true;\n }\n /**\n @internal\n */\n addChunk(from, chunk) {\n if ((from - this.lastTo || chunk.value[0].startSide - this.last.endSide) < 0)\n return false;\n if (this.from.length)\n this.finishChunk(true);\n this.setMaxPoint = Math.max(this.setMaxPoint, chunk.maxPoint);\n this.chunks.push(chunk);\n this.chunkPos.push(from);\n let last = chunk.value.length - 1;\n this.last = chunk.value[last];\n this.lastFrom = chunk.from[last] + from;\n this.lastTo = chunk.to[last] + from;\n return true;\n }\n /**\n Finish the range set. Returns the new set. The builder can't be\n used anymore after this has been called.\n */\n finish() { return this.finishInner(RangeSet.empty); }\n /**\n @internal\n */\n finishInner(next) {\n if (this.from.length)\n this.finishChunk(false);\n if (this.chunks.length == 0)\n return next;\n let result = RangeSet.create(this.chunkPos, this.chunks, this.nextLayer ? this.nextLayer.finishInner(next) : next, this.setMaxPoint);\n this.from = null; // Make sure further `add` calls produce errors\n return result;\n }\n}\nfunction findSharedChunks(a, b, textDiff) {\n let inA = new Map();\n for (let set of a)\n for (let i = 0; i < set.chunk.length; i++)\n if (set.chunk[i].maxPoint <= 0)\n inA.set(set.chunk[i], set.chunkPos[i]);\n let shared = new Set();\n for (let set of b)\n for (let i = 0; i < set.chunk.length; i++) {\n let known = inA.get(set.chunk[i]);\n if (known != null && (textDiff ? textDiff.mapPos(known) : known) == set.chunkPos[i] &&\n !(textDiff === null || textDiff === void 0 ? void 0 : textDiff.touchesRange(known, known + set.chunk[i].length)))\n shared.add(set.chunk[i]);\n }\n return shared;\n}\nclass LayerCursor {\n constructor(layer, skip, minPoint, rank = 0) {\n this.layer = layer;\n this.skip = skip;\n this.minPoint = minPoint;\n this.rank = rank;\n }\n get startSide() { return this.value ? this.value.startSide : 0; }\n get endSide() { return this.value ? this.value.endSide : 0; }\n goto(pos, side = -1000000000 /* C.Far */) {\n this.chunkIndex = this.rangeIndex = 0;\n this.gotoInner(pos, side, false);\n return this;\n }\n gotoInner(pos, side, forward) {\n while (this.chunkIndex < this.layer.chunk.length) {\n let next = this.layer.chunk[this.chunkIndex];\n if (!(this.skip && this.skip.has(next) ||\n this.layer.chunkEnd(this.chunkIndex) < pos ||\n next.maxPoint < this.minPoint))\n break;\n this.chunkIndex++;\n forward = false;\n }\n if (this.chunkIndex < this.layer.chunk.length) {\n let rangeIndex = this.layer.chunk[this.chunkIndex].findIndex(pos - this.layer.chunkPos[this.chunkIndex], side, true);\n if (!forward || this.rangeIndex < rangeIndex)\n this.setRangeIndex(rangeIndex);\n }\n this.next();\n }\n forward(pos, side) {\n if ((this.to - pos || this.endSide - side) < 0)\n this.gotoInner(pos, side, true);\n }\n next() {\n for (;;) {\n if (this.chunkIndex == this.layer.chunk.length) {\n this.from = this.to = 1000000000 /* C.Far */;\n this.value = null;\n break;\n }\n else {\n let chunkPos = this.layer.chunkPos[this.chunkIndex], chunk = this.layer.chunk[this.chunkIndex];\n let from = chunkPos + chunk.from[this.rangeIndex];\n this.from = from;\n this.to = chunkPos + chunk.to[this.rangeIndex];\n this.value = chunk.value[this.rangeIndex];\n this.setRangeIndex(this.rangeIndex + 1);\n if (this.minPoint < 0 || this.value.point && this.to - this.from >= this.minPoint)\n break;\n }\n }\n }\n setRangeIndex(index) {\n if (index == this.layer.chunk[this.chunkIndex].value.length) {\n this.chunkIndex++;\n if (this.skip) {\n while (this.chunkIndex < this.layer.chunk.length && this.skip.has(this.layer.chunk[this.chunkIndex]))\n this.chunkIndex++;\n }\n this.rangeIndex = 0;\n }\n else {\n this.rangeIndex = index;\n }\n }\n nextChunk() {\n this.chunkIndex++;\n this.rangeIndex = 0;\n this.next();\n }\n compare(other) {\n return this.from - other.from || this.startSide - other.startSide || this.rank - other.rank ||\n this.to - other.to || this.endSide - other.endSide;\n }\n}\nclass HeapCursor {\n constructor(heap) {\n this.heap = heap;\n }\n static from(sets, skip = null, minPoint = -1) {\n let heap = [];\n for (let i = 0; i < sets.length; i++) {\n for (let cur = sets[i]; !cur.isEmpty; cur = cur.nextLayer) {\n if (cur.maxPoint >= minPoint)\n heap.push(new LayerCursor(cur, skip, minPoint, i));\n }\n }\n return heap.length == 1 ? heap[0] : new HeapCursor(heap);\n }\n get startSide() { return this.value ? this.value.startSide : 0; }\n goto(pos, side = -1000000000 /* C.Far */) {\n for (let cur of this.heap)\n cur.goto(pos, side);\n for (let i = this.heap.length >> 1; i >= 0; i--)\n heapBubble(this.heap, i);\n this.next();\n return this;\n }\n forward(pos, side) {\n for (let cur of this.heap)\n cur.forward(pos, side);\n for (let i = this.heap.length >> 1; i >= 0; i--)\n heapBubble(this.heap, i);\n if ((this.to - pos || this.value.endSide - side) < 0)\n this.next();\n }\n next() {\n if (this.heap.length == 0) {\n this.from = this.to = 1000000000 /* C.Far */;\n this.value = null;\n this.rank = -1;\n }\n else {\n let top = this.heap[0];\n this.from = top.from;\n this.to = top.to;\n this.value = top.value;\n this.rank = top.rank;\n if (top.value)\n top.next();\n heapBubble(this.heap, 0);\n }\n }\n}\nfunction heapBubble(heap, index) {\n for (let cur = heap[index];;) {\n let childIndex = (index << 1) + 1;\n if (childIndex >= heap.length)\n break;\n let child = heap[childIndex];\n if (childIndex + 1 < heap.length && child.compare(heap[childIndex + 1]) >= 0) {\n child = heap[childIndex + 1];\n childIndex++;\n }\n if (cur.compare(child) < 0)\n break;\n heap[childIndex] = cur;\n heap[index] = child;\n index = childIndex;\n }\n}\nclass SpanCursor {\n constructor(sets, skip, minPoint) {\n this.minPoint = minPoint;\n this.active = [];\n this.activeTo = [];\n this.activeRank = [];\n this.minActive = -1;\n // A currently active point range, if any\n this.point = null;\n this.pointFrom = 0;\n this.pointRank = 0;\n this.to = -1000000000 /* C.Far */;\n this.endSide = 0;\n // The amount of open active ranges at the start of the iterator.\n // Not including points.\n this.openStart = -1;\n this.cursor = HeapCursor.from(sets, skip, minPoint);\n }\n goto(pos, side = -1000000000 /* C.Far */) {\n this.cursor.goto(pos, side);\n this.active.length = this.activeTo.length = this.activeRank.length = 0;\n this.minActive = -1;\n this.to = pos;\n this.endSide = side;\n this.openStart = -1;\n this.next();\n return this;\n }\n forward(pos, side) {\n while (this.minActive > -1 && (this.activeTo[this.minActive] - pos || this.active[this.minActive].endSide - side) < 0)\n this.removeActive(this.minActive);\n this.cursor.forward(pos, side);\n }\n removeActive(index) {\n remove(this.active, index);\n remove(this.activeTo, index);\n remove(this.activeRank, index);\n this.minActive = findMinIndex(this.active, this.activeTo);\n }\n addActive(trackOpen) {\n let i = 0, { value, to, rank } = this.cursor;\n while (i < this.activeRank.length && this.activeRank[i] <= rank)\n i++;\n insert(this.active, i, value);\n insert(this.activeTo, i, to);\n insert(this.activeRank, i, rank);\n if (trackOpen)\n insert(trackOpen, i, this.cursor.from);\n this.minActive = findMinIndex(this.active, this.activeTo);\n }\n // After calling this, if `this.point` != null, the next range is a\n // point. Otherwise, it's a regular range, covered by `this.active`.\n next() {\n let from = this.to, wasPoint = this.point;\n this.point = null;\n let trackOpen = this.openStart < 0 ? [] : null;\n for (;;) {\n let a = this.minActive;\n if (a > -1 && (this.activeTo[a] - this.cursor.from || this.active[a].endSide - this.cursor.startSide) < 0) {\n if (this.activeTo[a] > from) {\n this.to = this.activeTo[a];\n this.endSide = this.active[a].endSide;\n break;\n }\n this.removeActive(a);\n if (trackOpen)\n remove(trackOpen, a);\n }\n else if (!this.cursor.value) {\n this.to = this.endSide = 1000000000 /* C.Far */;\n break;\n }\n else if (this.cursor.from > from) {\n this.to = this.cursor.from;\n this.endSide = this.cursor.startSide;\n break;\n }\n else {\n let nextVal = this.cursor.value;\n if (!nextVal.point) { // Opening a range\n this.addActive(trackOpen);\n this.cursor.next();\n }\n else if (wasPoint && this.cursor.to == this.to && this.cursor.from < this.cursor.to) {\n // Ignore any non-empty points that end precisely at the end of the prev point\n this.cursor.next();\n }\n else { // New point\n this.point = nextVal;\n this.pointFrom = this.cursor.from;\n this.pointRank = this.cursor.rank;\n this.to = this.cursor.to;\n this.endSide = nextVal.endSide;\n this.cursor.next();\n this.forward(this.to, this.endSide);\n break;\n }\n }\n }\n if (trackOpen) {\n this.openStart = 0;\n for (let i = trackOpen.length - 1; i >= 0 && trackOpen[i] < from; i--)\n this.openStart++;\n }\n }\n activeForPoint(to) {\n if (!this.active.length)\n return this.active;\n let active = [];\n for (let i = this.active.length - 1; i >= 0; i--) {\n if (this.activeRank[i] < this.pointRank)\n break;\n if (this.activeTo[i] > to || this.activeTo[i] == to && this.active[i].endSide >= this.point.endSide)\n active.push(this.active[i]);\n }\n return active.reverse();\n }\n openEnd(to) {\n let open = 0;\n for (let i = this.activeTo.length - 1; i >= 0 && this.activeTo[i] > to; i--)\n open++;\n return open;\n }\n}\nfunction compare(a, startA, b, startB, length, comparator) {\n a.goto(startA);\n b.goto(startB);\n let endB = startB + length;\n let pos = startB, dPos = startB - startA;\n for (;;) {\n let diff = (a.to + dPos) - b.to || a.endSide - b.endSide;\n let end = diff < 0 ? a.to + dPos : b.to, clipEnd = Math.min(end, endB);\n if (a.point || b.point) {\n if (!(a.point && b.point && (a.point == b.point || a.point.eq(b.point)) &&\n sameValues(a.activeForPoint(a.to), b.activeForPoint(b.to))))\n comparator.comparePoint(pos, clipEnd, a.point, b.point);\n }\n else {\n if (clipEnd > pos && !sameValues(a.active, b.active))\n comparator.compareRange(pos, clipEnd, a.active, b.active);\n }\n if (end > endB)\n break;\n pos = end;\n if (diff <= 0)\n a.next();\n if (diff >= 0)\n b.next();\n }\n}\nfunction sameValues(a, b) {\n if (a.length != b.length)\n return false;\n for (let i = 0; i < a.length; i++)\n if (a[i] != b[i] && !a[i].eq(b[i]))\n return false;\n return true;\n}\nfunction remove(array, index) {\n for (let i = index, e = array.length - 1; i < e; i++)\n array[i] = array[i + 1];\n array.pop();\n}\nfunction insert(array, index, value) {\n for (let i = array.length - 1; i >= index; i--)\n array[i + 1] = array[i];\n array[index] = value;\n}\nfunction findMinIndex(value, array) {\n let found = -1, foundPos = 1000000000 /* C.Far */;\n for (let i = 0; i < array.length; i++)\n if ((array[i] - foundPos || value[i].endSide - value[found].endSide) < 0) {\n found = i;\n foundPos = array[i];\n }\n return found;\n}\n\n/**\nCount the column position at the given offset into the string,\ntaking extending characters and tab size into account.\n*/\nfunction countColumn(string, tabSize, to = string.length) {\n let n = 0;\n for (let i = 0; i < to;) {\n if (string.charCodeAt(i) == 9) {\n n += tabSize - (n % tabSize);\n i++;\n }\n else {\n n++;\n i = findClusterBreak(string, i);\n }\n }\n return n;\n}\n/**\nFind the offset that corresponds to the given column position in a\nstring, taking extending characters and tab size into account. By\ndefault, the string length is returned when it is too short to\nreach the column. Pass `strict` true to make it return -1 in that\nsituation.\n*/\nfunction findColumn(string, col, tabSize, strict) {\n for (let i = 0, n = 0;;) {\n if (n >= col)\n return i;\n if (i == string.length)\n break;\n n += string.charCodeAt(i) == 9 ? tabSize - (n % tabSize) : 1;\n i = findClusterBreak(string, i);\n }\n return strict === true ? -1 : string.length;\n}\n\nexport { Annotation, AnnotationType, ChangeDesc, ChangeSet, CharCategory, Compartment, EditorSelection, EditorState, Facet, Line, MapMode, Prec, Range, RangeSet, RangeSetBuilder, RangeValue, SelectionRange, StateEffect, StateEffectType, StateField, Text, Transaction, codePointAt, codePointSize, combineConfig, countColumn, findClusterBreak, findColumn, fromCodePoint };\n","const C = \"\\u037c\"\nconst COUNT = typeof Symbol == \"undefined\" ? \"__\" + C : Symbol.for(C)\nconst SET = typeof Symbol == \"undefined\" ? \"__styleSet\" + Math.floor(Math.random() * 1e8) : Symbol(\"styleSet\")\nconst top = typeof globalThis != \"undefined\" ? globalThis : typeof window != \"undefined\" ? window : {}\n\n// :: - Style modules encapsulate a set of CSS rules defined from\n// JavaScript. Their definitions are only available in a given DOM\n// root after it has been _mounted_ there with `StyleModule.mount`.\n//\n// Style modules should be created once and stored somewhere, as\n// opposed to re-creating them every time you need them. The amount of\n// CSS rules generated for a given DOM root is bounded by the amount\n// of style modules that were used. So to avoid leaking rules, don't\n// create these dynamically, but treat them as one-time allocations.\nexport class StyleModule {\n // :: (Object<Style>, ?{finish: ?(string) → string})\n // Create a style module from the given spec.\n //\n // When `finish` is given, it is called on regular (non-`@`)\n // selectors (after `&` expansion) to compute the final selector.\n constructor(spec, options) {\n this.rules = []\n let {finish} = options || {}\n\n function splitSelector(selector) {\n return /^@/.test(selector) ? [selector] : selector.split(/,\\s*/)\n }\n\n function render(selectors, spec, target, isKeyframes) {\n let local = [], isAt = /^@(\\w+)\\b/.exec(selectors[0]), keyframes = isAt && isAt[1] == \"keyframes\"\n if (isAt && spec == null) return target.push(selectors[0] + \";\")\n for (let prop in spec) {\n let value = spec[prop]\n if (/&/.test(prop)) {\n render(prop.split(/,\\s*/).map(part => selectors.map(sel => part.replace(/&/, sel))).reduce((a, b) => a.concat(b)),\n value, target)\n } else if (value && typeof value == \"object\") {\n if (!isAt) throw new RangeError(\"The value of a property (\" + prop + \") should be a primitive value.\")\n render(splitSelector(prop), value, local, keyframes)\n } else if (value != null) {\n local.push(prop.replace(/_.*/, \"\").replace(/[A-Z]/g, l => \"-\" + l.toLowerCase()) + \": \" + value + \";\")\n }\n }\n if (local.length || keyframes) {\n target.push((finish && !isAt && !isKeyframes ? selectors.map(finish) : selectors).join(\", \") +\n \" {\" + local.join(\" \") + \"}\")\n }\n }\n\n for (let prop in spec) render(splitSelector(prop), spec[prop], this.rules)\n }\n\n // :: () → string\n // Returns a string containing the module's CSS rules.\n getRules() { return this.rules.join(\"\\n\") }\n\n // :: () → string\n // Generate a new unique CSS class name.\n static newName() {\n let id = top[COUNT] || 1\n top[COUNT] = id + 1\n return C + id.toString(36)\n }\n\n // :: (union<Document, ShadowRoot>, union<[StyleModule], StyleModule>, ?{nonce: ?string})\n //\n // Mount the given set of modules in the given DOM root, which ensures\n // that the CSS rules defined by the module are available in that\n // context.\n //\n // Rules are only added to the document once per root.\n //\n // Rule order will follow the order of the modules, so that rules from\n // modules later in the array take precedence of those from earlier\n // modules. If you call this function multiple times for the same root\n // in a way that changes the order of already mounted modules, the old\n // order will be changed.\n //\n // If a Content Security Policy nonce is provided, it is added to\n // the `<style>` tag generated by the library.\n static mount(root, modules, options) {\n let set = root[SET], nonce = options && options.nonce\n if (!set) set = new StyleSet(root, nonce)\n else if (nonce) set.setNonce(nonce)\n set.mount(Array.isArray(modules) ? modules : [modules])\n }\n}\n\nlet adoptedSet = new Map //<Document, StyleSet>\n\nclass StyleSet {\n constructor(root, nonce) {\n let doc = root.ownerDocument || root, win = doc.defaultView\n if (!root.head && root.adoptedStyleSheets && win.CSSStyleSheet) {\n let adopted = adoptedSet.get(doc)\n if (adopted) {\n root.adoptedStyleSheets = [adopted.sheet, ...root.adoptedStyleSheets]\n return root[SET] = adopted\n }\n this.sheet = new win.CSSStyleSheet\n root.adoptedStyleSheets = [this.sheet, ...root.adoptedStyleSheets]\n adoptedSet.set(doc, this)\n } else {\n this.styleTag = doc.createElement(\"style\")\n if (nonce) this.styleTag.setAttribute(\"nonce\", nonce)\n let target = root.head || root\n target.insertBefore(this.styleTag, target.firstChild)\n }\n this.modules = []\n root[SET] = this\n }\n\n mount(modules) {\n let sheet = this.sheet\n let pos = 0 /* Current rule offset */, j = 0 /* Index into this.modules */\n for (let i = 0; i < modules.length; i++) {\n let mod = modules[i], index = this.modules.indexOf(mod)\n if (index < j && index > -1) { // Ordering conflict\n this.modules.splice(index, 1)\n j--\n index = -1\n }\n if (index == -1) {\n this.modules.splice(j++, 0, mod)\n if (sheet) for (let k = 0; k < mod.rules.length; k++)\n sheet.insertRule(mod.rules[k], pos++)\n } else {\n while (j < index) pos += this.modules[j++].rules.length\n pos += mod.rules.length\n j++\n }\n }\n\n if (!sheet) {\n let text = \"\"\n for (let i = 0; i < this.modules.length; i++)\n text += this.modules[i].getRules() + \"\\n\"\n this.styleTag.textContent = text\n }\n }\n\n setNonce(nonce) {\n if (this.styleTag && this.styleTag.getAttribute(\"nonce\") != nonce)\n this.styleTag.setAttribute(\"nonce\", nonce)\n }\n}\n\n// Style::Object<union<Style,string>>\n//\n// A style is an object that, in the simple case, maps CSS property\n// names to strings holding their values, as in `{color: \"red\",\n// fontWeight: \"bold\"}`. The property names can be given in\n// camel-case—the library will insert a dash before capital letters\n// when converting them to CSS.\n//\n// If you include an underscore in a property name, it and everything\n// after it will be removed from the output, which can be useful when\n// providing a property multiple times, for browser compatibility\n// reasons.\n//\n// A property in a style object can also be a sub-selector, which\n// extends the current context to add a pseudo-selector or a child\n// selector. Such a property should contain a `&` character, which\n// will be replaced by the current selector. For example `{\"&:before\":\n// {content: '\"hi\"'}}`. Sub-selectors and regular properties can\n// freely be mixed in a given object. Any property containing a `&` is\n// assumed to be a sub-selector.\n//\n// Finally, a property can specify an @-block to be wrapped around the\n// styles defined inside the object that's the property's value. For\n// example to create a media query you can do `{\"@media screen and\n// (min-width: 400px)\": {...}}`.\n","export var base = {\n 8: \"Backspace\",\n 9: \"Tab\",\n 10: \"Enter\",\n 12: \"NumLock\",\n 13: \"Enter\",\n 16: \"Shift\",\n 17: \"Control\",\n 18: \"Alt\",\n 20: \"CapsLock\",\n 27: \"Escape\",\n 32: \" \",\n 33: \"PageUp\",\n 34: \"PageDown\",\n 35: \"End\",\n 36: \"Home\",\n 37: \"ArrowLeft\",\n 38: \"ArrowUp\",\n 39: \"ArrowRight\",\n 40: \"ArrowDown\",\n 44: \"PrintScreen\",\n 45: \"Insert\",\n 46: \"Delete\",\n 59: \";\",\n 61: \"=\",\n 91: \"Meta\",\n 92: \"Meta\",\n 106: \"*\",\n 107: \"+\",\n 108: \",\",\n 109: \"-\",\n 110: \".\",\n 111: \"/\",\n 144: \"NumLock\",\n 145: \"ScrollLock\",\n 160: \"Shift\",\n 161: \"Shift\",\n 162: \"Control\",\n 163: \"Control\",\n 164: \"Alt\",\n 165: \"Alt\",\n 173: \"-\",\n 186: \";\",\n 187: \"=\",\n 188: \",\",\n 189: \"-\",\n 190: \".\",\n 191: \"/\",\n 192: \"`\",\n 219: \"[\",\n 220: \"\\\\\",\n 221: \"]\",\n 222: \"'\"\n}\n\nexport var shift = {\n 48: \")\",\n 49: \"!\",\n 50: \"@\",\n 51: \"#\",\n 52: \"$\",\n 53: \"%\",\n 54: \"^\",\n 55: \"&\",\n 56: \"*\",\n 57: \"(\",\n 59: \":\",\n 61: \"+\",\n 173: \"_\",\n 186: \":\",\n 187: \"+\",\n 188: \"<\",\n 189: \"_\",\n 190: \">\",\n 191: \"?\",\n 192: \"~\",\n 219: \"{\",\n 220: \"|\",\n 221: \"}\",\n 222: \"\\\"\"\n}\n\nvar mac = typeof navigator != \"undefined\" && /Mac/.test(navigator.platform)\nvar ie = typeof navigator != \"undefined\" && /MSIE \\d|Trident\\/(?:[7-9]|\\d{2,})\\..*rv:(\\d+)/.exec(navigator.userAgent)\n\n// Fill in the digit keys\nfor (var i = 0; i < 10; i++) base[48 + i] = base[96 + i] = String(i)\n\n// The function keys\nfor (var i = 1; i <= 24; i++) base[i + 111] = \"F\" + i\n\n// And the alphabetic keys\nfor (var i = 65; i <= 90; i++) {\n base[i] = String.fromCharCode(i + 32)\n shift[i] = String.fromCharCode(i)\n}\n\n// For each code that doesn't have a shift-equivalent, copy the base name\nfor (var code in base) if (!shift.hasOwnProperty(code)) shift[code] = base[code]\n\nexport function keyName(event) {\n // On macOS, keys held with Shift and Cmd don't reflect the effect of Shift in `.key`.\n // On IE, shift effect is never included in `.key`.\n var ignoreKey = mac && event.metaKey && event.shiftKey && !event.ctrlKey && !event.altKey ||\n ie && event.shiftKey && event.key && event.key.length == 1 ||\n event.key == \"Unidentified\"\n var name = (!ignoreKey && event.key) ||\n (event.shiftKey ? shift : base)[event.keyCode] ||\n event.key || \"Unidentified\"\n // Edge sometimes produces wrong names (Issue #3)\n if (name == \"Esc\") name = \"Escape\"\n if (name == \"Del\") name = \"Delete\"\n // https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/8860571/\n if (name == \"Left\") name = \"ArrowLeft\"\n if (name == \"Up\") name = \"ArrowUp\"\n if (name == \"Right\") name = \"ArrowRight\"\n if (name == \"Down\") name = \"ArrowDown\"\n return name\n}\n","import { Text, RangeSet, MapMode, RangeValue, Facet, StateEffect, ChangeSet, findClusterBreak, EditorSelection, findColumn, CharCategory, Annotation, EditorState, Transaction, Prec, codePointAt, codePointSize, combineConfig, StateField, RangeSetBuilder, countColumn } from '@codemirror/state';\nimport { StyleModule } from 'style-mod';\nimport { keyName, base, shift } from 'w3c-keyname';\n\nfunction getSelection(root) {\n let target;\n // Browsers differ on whether shadow roots have a getSelection\n // method. If it exists, use that, otherwise, call it on the\n // document.\n if (root.nodeType == 11) { // Shadow root\n target = root.getSelection ? root : root.ownerDocument;\n }\n else {\n target = root;\n }\n return target.getSelection();\n}\nfunction contains(dom, node) {\n return node ? dom == node || dom.contains(node.nodeType != 1 ? node.parentNode : node) : false;\n}\nfunction deepActiveElement(doc) {\n let elt = doc.activeElement;\n while (elt && elt.shadowRoot)\n elt = elt.shadowRoot.activeElement;\n return elt;\n}\nfunction hasSelection(dom, selection) {\n if (!selection.anchorNode)\n return false;\n try {\n // Firefox will raise 'permission denied' errors when accessing\n // properties of `sel.anchorNode` when it's in a generated CSS\n // element.\n return contains(dom, selection.anchorNode);\n }\n catch (_) {\n return false;\n }\n}\nfunction clientRectsFor(dom) {\n if (dom.nodeType == 3)\n return textRange(dom, 0, dom.nodeValue.length).getClientRects();\n else if (dom.nodeType == 1)\n return dom.getClientRects();\n else\n return [];\n}\n// Scans forward and backward through DOM positions equivalent to the\n// given one to see if the two are in the same place (i.e. after a\n// text node vs at the end of that text node)\nfunction isEquivalentPosition(node, off, targetNode, targetOff) {\n return targetNode ? (scanFor(node, off, targetNode, targetOff, -1) ||\n scanFor(node, off, targetNode, targetOff, 1)) : false;\n}\nfunction domIndex(node) {\n for (var index = 0;; index++) {\n node = node.previousSibling;\n if (!node)\n return index;\n }\n}\nfunction scanFor(node, off, targetNode, targetOff, dir) {\n for (;;) {\n if (node == targetNode && off == targetOff)\n return true;\n if (off == (dir < 0 ? 0 : maxOffset(node))) {\n if (node.nodeName == \"DIV\")\n return false;\n let parent = node.parentNode;\n if (!parent || parent.nodeType != 1)\n return false;\n off = domIndex(node) + (dir < 0 ? 0 : 1);\n node = parent;\n }\n else if (node.nodeType == 1) {\n node = node.childNodes[off + (dir < 0 ? -1 : 0)];\n if (node.nodeType == 1 && node.contentEditable == \"false\")\n return false;\n off = dir < 0 ? maxOffset(node) : 0;\n }\n else {\n return false;\n }\n }\n}\nfunction maxOffset(node) {\n return node.nodeType == 3 ? node.nodeValue.length : node.childNodes.length;\n}\nfunction flattenRect(rect, left) {\n let x = left ? rect.left : rect.right;\n return { left: x, right: x, top: rect.top, bottom: rect.bottom };\n}\nfunction windowRect(win) {\n return { left: 0, right: win.innerWidth,\n top: 0, bottom: win.innerHeight };\n}\nfunction scrollRectIntoView(dom, rect, side, x, y, xMargin, yMargin, ltr) {\n let doc = dom.ownerDocument, win = doc.defaultView || window;\n for (let cur = dom, stop = false; cur && !stop;) {\n if (cur.nodeType == 1) { // Element\n let bounding, top = cur == doc.body;\n let scaleX = 1, scaleY = 1;\n if (top) {\n bounding = windowRect(win);\n }\n else {\n if (/^(fixed|sticky)$/.test(getComputedStyle(cur).position))\n stop = true;\n if (cur.scrollHeight <= cur.clientHeight && cur.scrollWidth <= cur.clientWidth) {\n cur = cur.assignedSlot || cur.parentNode;\n continue;\n }\n let rect = cur.getBoundingClientRect();\n scaleX = rect.width / cur.offsetWidth;\n scaleY = rect.height / cur.offsetHeight;\n // Make sure scrollbar width isn't included in the rectangle\n bounding = { left: rect.left, right: rect.left + cur.clientWidth * scaleX,\n top: rect.top, bottom: rect.top + cur.clientHeight * scaleY };\n }\n let moveX = 0, moveY = 0;\n if (y == \"nearest\") {\n if (rect.top < bounding.top) {\n moveY = -(bounding.top - rect.top + yMargin);\n if (side > 0 && rect.bottom > bounding.bottom + moveY)\n moveY = rect.bottom - bounding.bottom + moveY + yMargin;\n }\n else if (rect.bottom > bounding.bottom) {\n moveY = rect.bottom - bounding.bottom + yMargin;\n if (side < 0 && (rect.top - moveY) < bounding.top)\n moveY = -(bounding.top + moveY - rect.top + yMargin);\n }\n }\n else {\n let rectHeight = rect.bottom - rect.top, boundingHeight = bounding.bottom - bounding.top;\n let targetTop = y == \"center\" && rectHeight <= boundingHeight ? rect.top + rectHeight / 2 - boundingHeight / 2 :\n y == \"start\" || y == \"center\" && side < 0 ? rect.top - yMargin :\n rect.bottom - boundingHeight + yMargin;\n moveY = targetTop - bounding.top;\n }\n if (x == \"nearest\") {\n if (rect.left < bounding.left) {\n moveX = -(bounding.left - rect.left + xMargin);\n if (side > 0 && rect.right > bounding.right + moveX)\n moveX = rect.right - bounding.right + moveX + xMargin;\n }\n else if (rect.right > bounding.right) {\n moveX = rect.right - bounding.right + xMargin;\n if (side < 0 && rect.left < bounding.left + moveX)\n moveX = -(bounding.left + moveX - rect.left + xMargin);\n }\n }\n else {\n let targetLeft = x == \"center\" ? rect.left + (rect.right - rect.left) / 2 - (bounding.right - bounding.left) / 2 :\n (x == \"start\") == ltr ? rect.left - xMargin :\n rect.right - (bounding.right - bounding.left) + xMargin;\n moveX = targetLeft - bounding.left;\n }\n if (moveX || moveY) {\n if (top) {\n win.scrollBy(moveX, moveY);\n }\n else {\n let movedX = 0, movedY = 0;\n if (moveY) {\n let start = cur.scrollTop;\n cur.scrollTop += moveY / scaleY;\n movedY = (cur.scrollTop - start) * scaleY;\n }\n if (moveX) {\n let start = cur.scrollLeft;\n cur.scrollLeft += moveX / scaleX;\n movedX = (cur.scrollLeft - start) * scaleX;\n }\n rect = { left: rect.left - movedX, top: rect.top - movedY,\n right: rect.right - movedX, bottom: rect.bottom - movedY };\n if (movedX && Math.abs(movedX - moveX) < 1)\n x = \"nearest\";\n if (movedY && Math.abs(movedY - moveY) < 1)\n y = \"nearest\";\n }\n }\n if (top)\n break;\n cur = cur.assignedSlot || cur.parentNode;\n }\n else if (cur.nodeType == 11) { // A shadow root\n cur = cur.host;\n }\n else {\n break;\n }\n }\n}\nfunction scrollableParent(dom) {\n let doc = dom.ownerDocument;\n for (let cur = dom.parentNode; cur;) {\n if (cur == doc.body) {\n break;\n }\n else if (cur.nodeType == 1) {\n if (cur.scrollHeight > cur.clientHeight || cur.scrollWidth > cur.clientWidth)\n return cur;\n cur = cur.assignedSlot || cur.parentNode;\n }\n else if (cur.nodeType == 11) {\n cur = cur.host;\n }\n else {\n break;\n }\n }\n return null;\n}\nclass DOMSelectionState {\n constructor() {\n this.anchorNode = null;\n this.anchorOffset = 0;\n this.focusNode = null;\n this.focusOffset = 0;\n }\n eq(domSel) {\n return this.anchorNode == domSel.anchorNode && this.anchorOffset == domSel.anchorOffset &&\n this.focusNode == domSel.focusNode && this.focusOffset == domSel.focusOffset;\n }\n setRange(range) {\n let { anchorNode, focusNode } = range;\n // Clip offsets to node size to avoid crashes when Safari reports bogus offsets (#1152)\n this.set(anchorNode, Math.min(range.anchorOffset, anchorNode ? maxOffset(anchorNode) : 0), focusNode, Math.min(range.focusOffset, focusNode ? maxOffset(focusNode) : 0));\n }\n set(anchorNode, anchorOffset, focusNode, focusOffset) {\n this.anchorNode = anchorNode;\n this.anchorOffset = anchorOffset;\n this.focusNode = focusNode;\n this.focusOffset = focusOffset;\n }\n}\nlet preventScrollSupported = null;\n// Feature-detects support for .focus({preventScroll: true}), and uses\n// a fallback kludge when not supported.\nfunction focusPreventScroll(dom) {\n if (dom.setActive)\n return dom.setActive(); // in IE\n if (preventScrollSupported)\n return dom.focus(preventScrollSupported);\n let stack = [];\n for (let cur = dom; cur; cur = cur.parentNode) {\n stack.push(cur, cur.scrollTop, cur.scrollLeft);\n if (cur == cur.ownerDocument)\n break;\n }\n dom.focus(preventScrollSupported == null ? {\n get preventScroll() {\n preventScrollSupported = { preventScroll: true };\n return true;\n }\n } : undefined);\n if (!preventScrollSupported) {\n preventScrollSupported = false;\n for (let i = 0; i < stack.length;) {\n let elt = stack[i++], top = stack[i++], left = stack[i++];\n if (elt.scrollTop != top)\n elt.scrollTop = top;\n if (elt.scrollLeft != left)\n elt.scrollLeft = left;\n }\n }\n}\nlet scratchRange;\nfunction textRange(node, from, to = from) {\n let range = scratchRange || (scratchRange = document.createRange());\n range.setEnd(node, to);\n range.setStart(node, from);\n return range;\n}\nfunction dispatchKey(elt, name, code) {\n let options = { key: name, code: name, keyCode: code, which: code, cancelable: true };\n let down = new KeyboardEvent(\"keydown\", options);\n down.synthetic = true;\n elt.dispatchEvent(down);\n let up = new KeyboardEvent(\"keyup\", options);\n up.synthetic = true;\n elt.dispatchEvent(up);\n return down.defaultPrevented || up.defaultPrevented;\n}\nfunction getRoot(node) {\n while (node) {\n if (node && (node.nodeType == 9 || node.nodeType == 11 && node.host))\n return node;\n node = node.assignedSlot || node.parentNode;\n }\n return null;\n}\nfunction clearAttributes(node) {\n while (node.attributes.length)\n node.removeAttributeNode(node.attributes[0]);\n}\nfunction atElementStart(doc, selection) {\n let node = selection.focusNode, offset = selection.focusOffset;\n if (!node || selection.anchorNode != node || selection.anchorOffset != offset)\n return false;\n // Safari can report bogus offsets (#1152)\n offset = Math.min(offset, maxOffset(node));\n for (;;) {\n if (offset) {\n if (node.nodeType != 1)\n return false;\n let prev = node.childNodes[offset - 1];\n if (prev.contentEditable == \"false\")\n offset--;\n else {\n node = prev;\n offset = maxOffset(node);\n }\n }\n else if (node == doc) {\n return true;\n }\n else {\n offset = domIndex(node);\n node = node.parentNode;\n }\n }\n}\nfunction isScrolledToBottom(elt) {\n return elt.scrollTop > Math.max(1, elt.scrollHeight - elt.clientHeight - 4);\n}\n\nclass DOMPos {\n constructor(node, offset, precise = true) {\n this.node = node;\n this.offset = offset;\n this.precise = precise;\n }\n static before(dom, precise) { return new DOMPos(dom.parentNode, domIndex(dom), precise); }\n static after(dom, precise) { return new DOMPos(dom.parentNode, domIndex(dom) + 1, precise); }\n}\nconst noChildren = [];\nclass ContentView {\n constructor() {\n this.parent = null;\n this.dom = null;\n this.flags = 2 /* ViewFlag.NodeDirty */;\n }\n get overrideDOMText() { return null; }\n get posAtStart() {\n return this.parent ? this.parent.posBefore(this) : 0;\n }\n get posAtEnd() {\n return this.posAtStart + this.length;\n }\n posBefore(view) {\n let pos = this.posAtStart;\n for (let child of this.children) {\n if (child == view)\n return pos;\n pos += child.length + child.breakAfter;\n }\n throw new RangeError(\"Invalid child in posBefore\");\n }\n posAfter(view) {\n return this.posBefore(view) + view.length;\n }\n sync(view, track) {\n if (this.flags & 2 /* ViewFlag.NodeDirty */) {\n let parent = this.dom;\n let prev = null, next;\n for (let child of this.children) {\n if (child.flags & 7 /* ViewFlag.Dirty */) {\n if (!child.dom && (next = prev ? prev.nextSibling : parent.firstChild)) {\n let contentView = ContentView.get(next);\n if (!contentView || !contentView.parent && contentView.canReuseDOM(child))\n child.reuseDOM(next);\n }\n child.sync(view, track);\n child.flags &= ~7 /* ViewFlag.Dirty */;\n }\n next = prev ? prev.nextSibling : parent.firstChild;\n if (track && !track.written && track.node == parent && next != child.dom)\n track.written = true;\n if (child.dom.parentNode == parent) {\n while (next && next != child.dom)\n next = rm$1(next);\n }\n else {\n parent.insertBefore(child.dom, next);\n }\n prev = child.dom;\n }\n next = prev ? prev.nextSibling : parent.firstChild;\n if (next && track && track.node == parent)\n track.written = true;\n while (next)\n next = rm$1(next);\n }\n else if (this.flags & 1 /* ViewFlag.ChildDirty */) {\n for (let child of this.children)\n if (child.flags & 7 /* ViewFlag.Dirty */) {\n child.sync(view, track);\n child.flags &= ~7 /* ViewFlag.Dirty */;\n }\n }\n }\n reuseDOM(_dom) { }\n localPosFromDOM(node, offset) {\n let after;\n if (node == this.dom) {\n after = this.dom.childNodes[offset];\n }\n else {\n let bias = maxOffset(node) == 0 ? 0 : offset == 0 ? -1 : 1;\n for (;;) {\n let parent = node.parentNode;\n if (parent == this.dom)\n break;\n if (bias == 0 && parent.firstChild != parent.lastChild) {\n if (node == parent.firstChild)\n bias = -1;\n else\n bias = 1;\n }\n node = parent;\n }\n if (bias < 0)\n after = node;\n else\n after = node.nextSibling;\n }\n if (after == this.dom.firstChild)\n return 0;\n while (after && !ContentView.get(after))\n after = after.nextSibling;\n if (!after)\n return this.length;\n for (let i = 0, pos = 0;; i++) {\n let child = this.children[i];\n if (child.dom == after)\n return pos;\n pos += child.length + child.breakAfter;\n }\n }\n domBoundsAround(from, to, offset = 0) {\n let fromI = -1, fromStart = -1, toI = -1, toEnd = -1;\n for (let i = 0, pos = offset, prevEnd = offset; i < this.children.length; i++) {\n let child = this.children[i], end = pos + child.length;\n if (pos < from && end > to)\n return child.domBoundsAround(from, to, pos);\n if (end >= from && fromI == -1) {\n fromI = i;\n fromStart = pos;\n }\n if (pos > to && child.dom.parentNode == this.dom) {\n toI = i;\n toEnd = prevEnd;\n break;\n }\n prevEnd = end;\n pos = end + child.breakAfter;\n }\n return { from: fromStart, to: toEnd < 0 ? offset + this.length : toEnd,\n startDOM: (fromI ? this.children[fromI - 1].dom.nextSibling : null) || this.dom.firstChild,\n endDOM: toI < this.children.length && toI >= 0 ? this.children[toI].dom : null };\n }\n markDirty(andParent = false) {\n this.flags |= 2 /* ViewFlag.NodeDirty */;\n this.markParentsDirty(andParent);\n }\n markParentsDirty(childList) {\n for (let parent = this.parent; parent; parent = parent.parent) {\n if (childList)\n parent.flags |= 2 /* ViewFlag.NodeDirty */;\n if (parent.flags & 1 /* ViewFlag.ChildDirty */)\n return;\n parent.flags |= 1 /* ViewFlag.ChildDirty */;\n childList = false;\n }\n }\n setParent(parent) {\n if (this.parent != parent) {\n this.parent = parent;\n if (this.flags & 7 /* ViewFlag.Dirty */)\n this.markParentsDirty(true);\n }\n }\n setDOM(dom) {\n if (this.dom == dom)\n return;\n if (this.dom)\n this.dom.cmView = null;\n this.dom = dom;\n dom.cmView = this;\n }\n get rootView() {\n for (let v = this;;) {\n let parent = v.parent;\n if (!parent)\n return v;\n v = parent;\n }\n }\n replaceChildren(from, to, children = noChildren) {\n this.markDirty();\n for (let i = from; i < to; i++) {\n let child = this.children[i];\n if (child.parent == this)\n child.destroy();\n }\n this.children.splice(from, to - from, ...children);\n for (let i = 0; i < children.length; i++)\n children[i].setParent(this);\n }\n ignoreMutation(_rec) { return false; }\n ignoreEvent(_event) { return false; }\n childCursor(pos = this.length) {\n return new ChildCursor(this.children, pos, this.children.length);\n }\n childPos(pos, bias = 1) {\n return this.childCursor().findPos(pos, bias);\n }\n toString() {\n let name = this.constructor.name.replace(\"View\", \"\");\n return name + (this.children.length ? \"(\" + this.children.join() + \")\" :\n this.length ? \"[\" + (name == \"Text\" ? this.text : this.length) + \"]\" : \"\") +\n (this.breakAfter ? \"#\" : \"\");\n }\n static get(node) { return node.cmView; }\n get isEditable() { return true; }\n get isWidget() { return false; }\n get isHidden() { return false; }\n merge(from, to, source, hasStart, openStart, openEnd) {\n return false;\n }\n become(other) { return false; }\n canReuseDOM(other) {\n return other.constructor == this.constructor && !((this.flags | other.flags) & 8 /* ViewFlag.Composition */);\n }\n // When this is a zero-length view with a side, this should return a\n // number <= 0 to indicate it is before its position, or a\n // number > 0 when after its position.\n getSide() { return 0; }\n destroy() {\n this.parent = null;\n }\n}\nContentView.prototype.breakAfter = 0;\n// Remove a DOM node and return its next sibling.\nfunction rm$1(dom) {\n let next = dom.nextSibling;\n dom.parentNode.removeChild(dom);\n return next;\n}\nclass ChildCursor {\n constructor(children, pos, i) {\n this.children = children;\n this.pos = pos;\n this.i = i;\n this.off = 0;\n }\n findPos(pos, bias = 1) {\n for (;;) {\n if (pos > this.pos || pos == this.pos &&\n (bias > 0 || this.i == 0 || this.children[this.i - 1].breakAfter)) {\n this.off = pos - this.pos;\n return this;\n }\n let next = this.children[--this.i];\n this.pos -= next.length + next.breakAfter;\n }\n }\n}\nfunction replaceRange(parent, fromI, fromOff, toI, toOff, insert, breakAtStart, openStart, openEnd) {\n let { children } = parent;\n let before = children.length ? children[fromI] : null;\n let last = insert.length ? insert[insert.length - 1] : null;\n let breakAtEnd = last ? last.breakAfter : breakAtStart;\n // Change within a single child\n if (fromI == toI && before && !breakAtStart && !breakAtEnd && insert.length < 2 &&\n before.merge(fromOff, toOff, insert.length ? last : null, fromOff == 0, openStart, openEnd))\n return;\n if (toI < children.length) {\n let after = children[toI];\n // Make sure the end of the child after the update is preserved in `after`\n if (after && toOff < after.length) {\n // If we're splitting a child, separate part of it to avoid that\n // being mangled when updating the child before the update.\n if (fromI == toI) {\n after = after.split(toOff);\n toOff = 0;\n }\n // If the element after the replacement should be merged with\n // the last replacing element, update `content`\n if (!breakAtEnd && last && after.merge(0, toOff, last, true, 0, openEnd)) {\n insert[insert.length - 1] = after;\n }\n else {\n // Remove the start of the after element, if necessary, and\n // add it to `content`.\n if (toOff)\n after.merge(0, toOff, null, false, 0, openEnd);\n insert.push(after);\n }\n }\n else if (after === null || after === void 0 ? void 0 : after.breakAfter) {\n // The element at `toI` is entirely covered by this range.\n // Preserve its line break, if any.\n if (last)\n last.breakAfter = 1;\n else\n breakAtStart = 1;\n }\n // Since we've handled the next element from the current elements\n // now, make sure `toI` points after that.\n toI++;\n }\n if (before) {\n before.breakAfter = breakAtStart;\n if (fromOff > 0) {\n if (!breakAtStart && insert.length && before.merge(fromOff, before.length, insert[0], false, openStart, 0)) {\n before.breakAfter = insert.shift().breakAfter;\n }\n else if (fromOff < before.length || before.children.length && before.children[before.children.length - 1].length == 0) {\n before.merge(fromOff, before.length, null, false, openStart, 0);\n }\n fromI++;\n }\n }\n // Try to merge widgets on the boundaries of the replacement\n while (fromI < toI && insert.length) {\n if (children[toI - 1].become(insert[insert.length - 1])) {\n toI--;\n insert.pop();\n openEnd = insert.length ? 0 : openStart;\n }\n else if (children[fromI].become(insert[0])) {\n fromI++;\n insert.shift();\n openStart = insert.length ? 0 : openEnd;\n }\n else {\n break;\n }\n }\n if (!insert.length && fromI && toI < children.length && !children[fromI - 1].breakAfter &&\n children[toI].merge(0, 0, children[fromI - 1], false, openStart, openEnd))\n fromI--;\n if (fromI < toI || insert.length)\n parent.replaceChildren(fromI, toI, insert);\n}\nfunction mergeChildrenInto(parent, from, to, insert, openStart, openEnd) {\n let cur = parent.childCursor();\n let { i: toI, off: toOff } = cur.findPos(to, 1);\n let { i: fromI, off: fromOff } = cur.findPos(from, -1);\n let dLen = from - to;\n for (let view of insert)\n dLen += view.length;\n parent.length += dLen;\n replaceRange(parent, fromI, fromOff, toI, toOff, insert, 0, openStart, openEnd);\n}\n\nlet nav = typeof navigator != \"undefined\" ? navigator : { userAgent: \"\", vendor: \"\", platform: \"\" };\nlet doc = typeof document != \"undefined\" ? document : { documentElement: { style: {} } };\nconst ie_edge = /*@__PURE__*//Edge\\/(\\d+)/.exec(nav.userAgent);\nconst ie_upto10 = /*@__PURE__*//MSIE \\d/.test(nav.userAgent);\nconst ie_11up = /*@__PURE__*//Trident\\/(?:[7-9]|\\d{2,})\\..*rv:(\\d+)/.exec(nav.userAgent);\nconst ie = !!(ie_upto10 || ie_11up || ie_edge);\nconst gecko = !ie && /*@__PURE__*//gecko\\/(\\d+)/i.test(nav.userAgent);\nconst chrome = !ie && /*@__PURE__*//Chrome\\/(\\d+)/.exec(nav.userAgent);\nconst webkit = \"webkitFontSmoothing\" in doc.documentElement.style;\nconst safari = !ie && /*@__PURE__*//Apple Computer/.test(nav.vendor);\nconst ios = safari && (/*@__PURE__*//Mobile\\/\\w+/.test(nav.userAgent) || nav.maxTouchPoints > 2);\nvar browser = {\n mac: ios || /*@__PURE__*//Mac/.test(nav.platform),\n windows: /*@__PURE__*//Win/.test(nav.platform),\n linux: /*@__PURE__*//Linux|X11/.test(nav.platform),\n ie,\n ie_version: ie_upto10 ? doc.documentMode || 6 : ie_11up ? +ie_11up[1] : ie_edge ? +ie_edge[1] : 0,\n gecko,\n gecko_version: gecko ? +(/*@__PURE__*//Firefox\\/(\\d+)/.exec(nav.userAgent) || [0, 0])[1] : 0,\n chrome: !!chrome,\n chrome_version: chrome ? +chrome[1] : 0,\n ios,\n android: /*@__PURE__*//Android\\b/.test(nav.userAgent),\n webkit,\n safari,\n webkit_version: webkit ? +(/*@__PURE__*//\\bAppleWebKit\\/(\\d+)/.exec(navigator.userAgent) || [0, 0])[1] : 0,\n tabSize: doc.documentElement.style.tabSize != null ? \"tab-size\" : \"-moz-tab-size\"\n};\n\nconst MaxJoinLen = 256;\nclass TextView extends ContentView {\n constructor(text) {\n super();\n this.text = text;\n }\n get length() { return this.text.length; }\n createDOM(textDOM) {\n this.setDOM(textDOM || document.createTextNode(this.text));\n }\n sync(view, track) {\n if (!this.dom)\n this.createDOM();\n if (this.dom.nodeValue != this.text) {\n if (track && track.node == this.dom)\n track.written = true;\n this.dom.nodeValue = this.text;\n }\n }\n reuseDOM(dom) {\n if (dom.nodeType == 3)\n this.createDOM(dom);\n }\n merge(from, to, source) {\n if ((this.flags & 8 /* ViewFlag.Composition */) ||\n source && (!(source instanceof TextView) ||\n this.length - (to - from) + source.length > MaxJoinLen ||\n (source.flags & 8 /* ViewFlag.Composition */)))\n return false;\n this.text = this.text.slice(0, from) + (source ? source.text : \"\") + this.text.slice(to);\n this.markDirty();\n return true;\n }\n split(from) {\n let result = new TextView(this.text.slice(from));\n this.text = this.text.slice(0, from);\n this.markDirty();\n result.flags |= this.flags & 8 /* ViewFlag.Composition */;\n return result;\n }\n localPosFromDOM(node, offset) {\n return node == this.dom ? offset : offset ? this.text.length : 0;\n }\n domAtPos(pos) { return new DOMPos(this.dom, pos); }\n domBoundsAround(_from, _to, offset) {\n return { from: offset, to: offset + this.length, startDOM: this.dom, endDOM: this.dom.nextSibling };\n }\n coordsAt(pos, side) {\n return textCoords(this.dom, pos, side);\n }\n}\nclass MarkView extends ContentView {\n constructor(mark, children = [], length = 0) {\n super();\n this.mark = mark;\n this.children = children;\n this.length = length;\n for (let ch of children)\n ch.setParent(this);\n }\n setAttrs(dom) {\n clearAttributes(dom);\n if (this.mark.class)\n dom.className = this.mark.class;\n if (this.mark.attrs)\n for (let name in this.mark.attrs)\n dom.setAttribute(name, this.mark.attrs[name]);\n return dom;\n }\n canReuseDOM(other) {\n return super.canReuseDOM(other) && !((this.flags | other.flags) & 8 /* ViewFlag.Composition */);\n }\n reuseDOM(node) {\n if (node.nodeName == this.mark.tagName.toUpperCase()) {\n this.setDOM(node);\n this.flags |= 4 /* ViewFlag.AttrsDirty */ | 2 /* ViewFlag.NodeDirty */;\n }\n }\n sync(view, track) {\n if (!this.dom)\n this.setDOM(this.setAttrs(document.createElement(this.mark.tagName)));\n else if (this.flags & 4 /* ViewFlag.AttrsDirty */)\n this.setAttrs(this.dom);\n super.sync(view, track);\n }\n merge(from, to, source, _hasStart, openStart, openEnd) {\n if (source && (!(source instanceof MarkView && source.mark.eq(this.mark)) ||\n (from && openStart <= 0) || (to < this.length && openEnd <= 0)))\n return false;\n mergeChildrenInto(this, from, to, source ? source.children : [], openStart - 1, openEnd - 1);\n this.markDirty();\n return true;\n }\n split(from) {\n let result = [], off = 0, detachFrom = -1, i = 0;\n for (let elt of this.children) {\n let end = off + elt.length;\n if (end > from)\n result.push(off < from ? elt.split(from - off) : elt);\n if (detachFrom < 0 && off >= from)\n detachFrom = i;\n off = end;\n i++;\n }\n let length = this.length - from;\n this.length = from;\n if (detachFrom > -1) {\n this.children.length = detachFrom;\n this.markDirty();\n }\n return new MarkView(this.mark, result, length);\n }\n domAtPos(pos) {\n return inlineDOMAtPos(this, pos);\n }\n coordsAt(pos, side) {\n return coordsInChildren(this, pos, side);\n }\n}\nfunction textCoords(text, pos, side) {\n let length = text.nodeValue.length;\n if (pos > length)\n pos = length;\n let from = pos, to = pos, flatten = 0;\n if (pos == 0 && side < 0 || pos == length && side >= 0) {\n if (!(browser.chrome || browser.gecko)) { // These browsers reliably return valid rectangles for empty ranges\n if (pos) {\n from--;\n flatten = 1;\n } // FIXME this is wrong in RTL text\n else if (to < length) {\n to++;\n flatten = -1;\n }\n }\n }\n else {\n if (side < 0)\n from--;\n else if (to < length)\n to++;\n }\n let rects = textRange(text, from, to).getClientRects();\n if (!rects.length)\n return null;\n let rect = rects[(flatten ? flatten < 0 : side >= 0) ? 0 : rects.length - 1];\n if (browser.safari && !flatten && rect.width == 0)\n rect = Array.prototype.find.call(rects, r => r.width) || rect;\n return flatten ? flattenRect(rect, flatten < 0) : rect || null;\n}\n// Also used for collapsed ranges that don't have a placeholder widget!\nclass WidgetView extends ContentView {\n static create(widget, length, side) {\n return new WidgetView(widget, length, side);\n }\n constructor(widget, length, side) {\n super();\n this.widget = widget;\n this.length = length;\n this.side = side;\n this.prevWidget = null;\n }\n split(from) {\n let result = WidgetView.create(this.widget, this.length - from, this.side);\n this.length -= from;\n return result;\n }\n sync(view) {\n if (!this.dom || !this.widget.updateDOM(this.dom, view)) {\n if (this.dom && this.prevWidget)\n this.prevWidget.destroy(this.dom);\n this.prevWidget = null;\n this.setDOM(this.widget.toDOM(view));\n this.dom.contentEditable = \"false\";\n }\n }\n getSide() { return this.side; }\n merge(from, to, source, hasStart, openStart, openEnd) {\n if (source && (!(source instanceof WidgetView) || !this.widget.compare(source.widget) ||\n from > 0 && openStart <= 0 || to < this.length && openEnd <= 0))\n return false;\n this.length = from + (source ? source.length : 0) + (this.length - to);\n return true;\n }\n become(other) {\n if (other instanceof WidgetView && other.side == this.side &&\n this.widget.constructor == other.widget.constructor) {\n if (!this.widget.compare(other.widget))\n this.markDirty(true);\n if (this.dom && !this.prevWidget)\n this.prevWidget = this.widget;\n this.widget = other.widget;\n this.length = other.length;\n return true;\n }\n return false;\n }\n ignoreMutation() { return true; }\n ignoreEvent(event) { return this.widget.ignoreEvent(event); }\n get overrideDOMText() {\n if (this.length == 0)\n return Text.empty;\n let top = this;\n while (top.parent)\n top = top.parent;\n let { view } = top, text = view && view.state.doc, start = this.posAtStart;\n return text ? text.slice(start, start + this.length) : Text.empty;\n }\n domAtPos(pos) {\n return (this.length ? pos == 0 : this.side > 0)\n ? DOMPos.before(this.dom)\n : DOMPos.after(this.dom, pos == this.length);\n }\n domBoundsAround() { return null; }\n coordsAt(pos, side) {\n let custom = this.widget.coordsAt(this.dom, pos, side);\n if (custom)\n return custom;\n let rects = this.dom.getClientRects(), rect = null;\n if (!rects.length)\n return null;\n let fromBack = this.side ? this.side < 0 : pos > 0;\n for (let i = fromBack ? rects.length - 1 : 0;; i += (fromBack ? -1 : 1)) {\n rect = rects[i];\n if (pos > 0 ? i == 0 : i == rects.length - 1 || rect.top < rect.bottom)\n break;\n }\n return flattenRect(rect, !fromBack);\n }\n get isEditable() { return false; }\n get isWidget() { return true; }\n get isHidden() { return this.widget.isHidden; }\n destroy() {\n super.destroy();\n if (this.dom)\n this.widget.destroy(this.dom);\n }\n}\n// These are drawn around uneditable widgets to avoid a number of\n// browser bugs that show up when the cursor is directly next to\n// uneditable inline content.\nclass WidgetBufferView extends ContentView {\n constructor(side) {\n super();\n this.side = side;\n }\n get length() { return 0; }\n merge() { return false; }\n become(other) {\n return other instanceof WidgetBufferView && other.side == this.side;\n }\n split() { return new WidgetBufferView(this.side); }\n sync() {\n if (!this.dom) {\n let dom = document.createElement(\"img\");\n dom.className = \"cm-widgetBuffer\";\n dom.setAttribute(\"aria-hidden\", \"true\");\n this.setDOM(dom);\n }\n }\n getSide() { return this.side; }\n domAtPos(pos) { return this.side > 0 ? DOMPos.before(this.dom) : DOMPos.after(this.dom); }\n localPosFromDOM() { return 0; }\n domBoundsAround() { return null; }\n coordsAt(pos) {\n return this.dom.getBoundingClientRect();\n }\n get overrideDOMText() {\n return Text.empty;\n }\n get isHidden() { return true; }\n}\nTextView.prototype.children = WidgetView.prototype.children = WidgetBufferView.prototype.children = noChildren;\nfunction inlineDOMAtPos(parent, pos) {\n let dom = parent.dom, { children } = parent, i = 0;\n for (let off = 0; i < children.length; i++) {\n let child = children[i], end = off + child.length;\n if (end == off && child.getSide() <= 0)\n continue;\n if (pos > off && pos < end && child.dom.parentNode == dom)\n return child.domAtPos(pos - off);\n if (pos <= off)\n break;\n off = end;\n }\n for (let j = i; j > 0; j--) {\n let prev = children[j - 1];\n if (prev.dom.parentNode == dom)\n return prev.domAtPos(prev.length);\n }\n for (let j = i; j < children.length; j++) {\n let next = children[j];\n if (next.dom.parentNode == dom)\n return next.domAtPos(0);\n }\n return new DOMPos(dom, 0);\n}\n// Assumes `view`, if a mark view, has precisely 1 child.\nfunction joinInlineInto(parent, view, open) {\n let last, { children } = parent;\n if (open > 0 && view instanceof MarkView && children.length &&\n (last = children[children.length - 1]) instanceof MarkView && last.mark.eq(view.mark)) {\n joinInlineInto(last, view.children[0], open - 1);\n }\n else {\n children.push(view);\n view.setParent(parent);\n }\n parent.length += view.length;\n}\nfunction coordsInChildren(view, pos, side) {\n let before = null, beforePos = -1, after = null, afterPos = -1;\n function scan(view, pos) {\n for (let i = 0, off = 0; i < view.children.length && off <= pos; i++) {\n let child = view.children[i], end = off + child.length;\n if (end >= pos) {\n if (child.children.length) {\n scan(child, pos - off);\n }\n else if ((!after || after.isHidden && side > 0) &&\n (end > pos || off == end && child.getSide() > 0)) {\n after = child;\n afterPos = pos - off;\n }\n else if (off < pos || (off == end && child.getSide() < 0) && !child.isHidden) {\n before = child;\n beforePos = pos - off;\n }\n }\n off = end;\n }\n }\n scan(view, pos);\n let target = (side < 0 ? before : after) || before || after;\n if (target)\n return target.coordsAt(Math.max(0, target == before ? beforePos : afterPos), side);\n return fallbackRect(view);\n}\nfunction fallbackRect(view) {\n let last = view.dom.lastChild;\n if (!last)\n return view.dom.getBoundingClientRect();\n let rects = clientRectsFor(last);\n return rects[rects.length - 1] || null;\n}\n\nfunction combineAttrs(source, target) {\n for (let name in source) {\n if (name == \"class\" && target.class)\n target.class += \" \" + source.class;\n else if (name == \"style\" && target.style)\n target.style += \";\" + source.style;\n else\n target[name] = source[name];\n }\n return target;\n}\nconst noAttrs = /*@__PURE__*/Object.create(null);\nfunction attrsEq(a, b, ignore) {\n if (a == b)\n return true;\n if (!a)\n a = noAttrs;\n if (!b)\n b = noAttrs;\n let keysA = Object.keys(a), keysB = Object.keys(b);\n if (keysA.length - (ignore && keysA.indexOf(ignore) > -1 ? 1 : 0) !=\n keysB.length - (ignore && keysB.indexOf(ignore) > -1 ? 1 : 0))\n return false;\n for (let key of keysA) {\n if (key != ignore && (keysB.indexOf(key) == -1 || a[key] !== b[key]))\n return false;\n }\n return true;\n}\nfunction updateAttrs(dom, prev, attrs) {\n let changed = false;\n if (prev)\n for (let name in prev)\n if (!(attrs && name in attrs)) {\n changed = true;\n if (name == \"style\")\n dom.style.cssText = \"\";\n else\n dom.removeAttribute(name);\n }\n if (attrs)\n for (let name in attrs)\n if (!(prev && prev[name] == attrs[name])) {\n changed = true;\n if (name == \"style\")\n dom.style.cssText = attrs[name];\n else\n dom.setAttribute(name, attrs[name]);\n }\n return changed;\n}\nfunction getAttrs(dom) {\n let attrs = Object.create(null);\n for (let i = 0; i < dom.attributes.length; i++) {\n let attr = dom.attributes[i];\n attrs[attr.name] = attr.value;\n }\n return attrs;\n}\n\n/**\nWidgets added to the content are described by subclasses of this\nclass. Using a description object like that makes it possible to\ndelay creating of the DOM structure for a widget until it is\nneeded, and to avoid redrawing widgets even if the decorations\nthat define them are recreated.\n*/\nclass WidgetType {\n /**\n Compare this instance to another instance of the same type.\n (TypeScript can't express this, but only instances of the same\n specific class will be passed to this method.) This is used to\n avoid redrawing widgets when they are replaced by a new\n decoration of the same type. The default implementation just\n returns `false`, which will cause new instances of the widget to\n always be redrawn.\n */\n eq(widget) { return false; }\n /**\n Update a DOM element created by a widget of the same type (but\n different, non-`eq` content) to reflect this widget. May return\n true to indicate that it could update, false to indicate it\n couldn't (in which case the widget will be redrawn). The default\n implementation just returns false.\n */\n updateDOM(dom, view) { return false; }\n /**\n @internal\n */\n compare(other) {\n return this == other || this.constructor == other.constructor && this.eq(other);\n }\n /**\n The estimated height this widget will have, to be used when\n estimating the height of content that hasn't been drawn. May\n return -1 to indicate you don't know. The default implementation\n returns -1.\n */\n get estimatedHeight() { return -1; }\n /**\n For inline widgets that are displayed inline (as opposed to\n `inline-block`) and introduce line breaks (through `<br>` tags\n or textual newlines), this must indicate the amount of line\n breaks they introduce. Defaults to 0.\n */\n get lineBreaks() { return 0; }\n /**\n Can be used to configure which kinds of events inside the widget\n should be ignored by the editor. The default is to ignore all\n events.\n */\n ignoreEvent(event) { return true; }\n /**\n Override the way screen coordinates for positions at/in the\n widget are found. `pos` will be the offset into the widget, and\n `side` the side of the position that is being queried—less than\n zero for before, greater than zero for after, and zero for\n directly at that position.\n */\n coordsAt(dom, pos, side) { return null; }\n /**\n @internal\n */\n get isHidden() { return false; }\n /**\n This is called when the an instance of the widget is removed\n from the editor view.\n */\n destroy(dom) { }\n}\n/**\nThe different types of blocks that can occur in an editor view.\n*/\nvar BlockType = /*@__PURE__*/(function (BlockType) {\n /**\n A line of text.\n */\n BlockType[BlockType[\"Text\"] = 0] = \"Text\";\n /**\n A block widget associated with the position after it.\n */\n BlockType[BlockType[\"WidgetBefore\"] = 1] = \"WidgetBefore\";\n /**\n A block widget associated with the position before it.\n */\n BlockType[BlockType[\"WidgetAfter\"] = 2] = \"WidgetAfter\";\n /**\n A block widget [replacing](https://codemirror.net/6/docs/ref/#view.Decoration^replace) a range of content.\n */\n BlockType[BlockType[\"WidgetRange\"] = 3] = \"WidgetRange\";\nreturn BlockType})(BlockType || (BlockType = {}));\n/**\nA decoration provides information on how to draw or style a piece\nof content. You'll usually use it wrapped in a\n[`Range`](https://codemirror.net/6/docs/ref/#state.Range), which adds a start and end position.\n@nonabstract\n*/\nclass Decoration extends RangeValue {\n constructor(\n /**\n @internal\n */\n startSide, \n /**\n @internal\n */\n endSide, \n /**\n @internal\n */\n widget, \n /**\n The config object used to create this decoration. You can\n include additional properties in there to store metadata about\n your decoration.\n */\n spec) {\n super();\n this.startSide = startSide;\n this.endSide = endSide;\n this.widget = widget;\n this.spec = spec;\n }\n /**\n @internal\n */\n get heightRelevant() { return false; }\n /**\n Create a mark decoration, which influences the styling of the\n content in its range. Nested mark decorations will cause nested\n DOM elements to be created. Nesting order is determined by\n precedence of the [facet](https://codemirror.net/6/docs/ref/#view.EditorView^decorations), with\n the higher-precedence decorations creating the inner DOM nodes.\n Such elements are split on line boundaries and on the boundaries\n of lower-precedence decorations.\n */\n static mark(spec) {\n return new MarkDecoration(spec);\n }\n /**\n Create a widget decoration, which displays a DOM element at the\n given position.\n */\n static widget(spec) {\n let side = Math.max(-10000, Math.min(10000, spec.side || 0)), block = !!spec.block;\n side += (block && !spec.inlineOrder)\n ? (side > 0 ? 300000000 /* Side.BlockAfter */ : -400000000 /* Side.BlockBefore */)\n : (side > 0 ? 100000000 /* Side.InlineAfter */ : -100000000 /* Side.InlineBefore */);\n return new PointDecoration(spec, side, side, block, spec.widget || null, false);\n }\n /**\n Create a replace decoration which replaces the given range with\n a widget, or simply hides it.\n */\n static replace(spec) {\n let block = !!spec.block, startSide, endSide;\n if (spec.isBlockGap) {\n startSide = -500000000 /* Side.GapStart */;\n endSide = 400000000 /* Side.GapEnd */;\n }\n else {\n let { start, end } = getInclusive(spec, block);\n startSide = (start ? (block ? -300000000 /* Side.BlockIncStart */ : -1 /* Side.InlineIncStart */) : 500000000 /* Side.NonIncStart */) - 1;\n endSide = (end ? (block ? 200000000 /* Side.BlockIncEnd */ : 1 /* Side.InlineIncEnd */) : -600000000 /* Side.NonIncEnd */) + 1;\n }\n return new PointDecoration(spec, startSide, endSide, block, spec.widget || null, true);\n }\n /**\n Create a line decoration, which can add DOM attributes to the\n line starting at the given position.\n */\n static line(spec) {\n return new LineDecoration(spec);\n }\n /**\n Build a [`DecorationSet`](https://codemirror.net/6/docs/ref/#view.DecorationSet) from the given\n decorated range or ranges. If the ranges aren't already sorted,\n pass `true` for `sort` to make the library sort them for you.\n */\n static set(of, sort = false) {\n return RangeSet.of(of, sort);\n }\n /**\n @internal\n */\n hasHeight() { return this.widget ? this.widget.estimatedHeight > -1 : false; }\n}\n/**\nThe empty set of decorations.\n*/\nDecoration.none = RangeSet.empty;\nclass MarkDecoration extends Decoration {\n constructor(spec) {\n let { start, end } = getInclusive(spec);\n super(start ? -1 /* Side.InlineIncStart */ : 500000000 /* Side.NonIncStart */, end ? 1 /* Side.InlineIncEnd */ : -600000000 /* Side.NonIncEnd */, null, spec);\n this.tagName = spec.tagName || \"span\";\n this.class = spec.class || \"\";\n this.attrs = spec.attributes || null;\n }\n eq(other) {\n var _a, _b;\n return this == other ||\n other instanceof MarkDecoration &&\n this.tagName == other.tagName &&\n (this.class || ((_a = this.attrs) === null || _a === void 0 ? void 0 : _a.class)) == (other.class || ((_b = other.attrs) === null || _b === void 0 ? void 0 : _b.class)) &&\n attrsEq(this.attrs, other.attrs, \"class\");\n }\n range(from, to = from) {\n if (from >= to)\n throw new RangeError(\"Mark decorations may not be empty\");\n return super.range(from, to);\n }\n}\nMarkDecoration.prototype.point = false;\nclass LineDecoration extends Decoration {\n constructor(spec) {\n super(-200000000 /* Side.Line */, -200000000 /* Side.Line */, null, spec);\n }\n eq(other) {\n return other instanceof LineDecoration &&\n this.spec.class == other.spec.class &&\n attrsEq(this.spec.attributes, other.spec.attributes);\n }\n range(from, to = from) {\n if (to != from)\n throw new RangeError(\"Line decoration ranges must be zero-length\");\n return super.range(from, to);\n }\n}\nLineDecoration.prototype.mapMode = MapMode.TrackBefore;\nLineDecoration.prototype.point = true;\nclass PointDecoration extends Decoration {\n constructor(spec, startSide, endSide, block, widget, isReplace) {\n super(startSide, endSide, widget, spec);\n this.block = block;\n this.isReplace = isReplace;\n this.mapMode = !block ? MapMode.TrackDel : startSide <= 0 ? MapMode.TrackBefore : MapMode.TrackAfter;\n }\n // Only relevant when this.block == true\n get type() {\n return this.startSide < this.endSide ? BlockType.WidgetRange\n : this.startSide <= 0 ? BlockType.WidgetBefore : BlockType.WidgetAfter;\n }\n get heightRelevant() {\n return this.block || !!this.widget && (this.widget.estimatedHeight >= 5 || this.widget.lineBreaks > 0);\n }\n eq(other) {\n return other instanceof PointDecoration &&\n widgetsEq(this.widget, other.widget) &&\n this.block == other.block &&\n this.startSide == other.startSide && this.endSide == other.endSide;\n }\n range(from, to = from) {\n if (this.isReplace && (from > to || (from == to && this.startSide > 0 && this.endSide <= 0)))\n throw new RangeError(\"Invalid range for replacement decoration\");\n if (!this.isReplace && to != from)\n throw new RangeError(\"Widget decorations can only have zero-length ranges\");\n return super.range(from, to);\n }\n}\nPointDecoration.prototype.point = true;\nfunction getInclusive(spec, block = false) {\n let { inclusiveStart: start, inclusiveEnd: end } = spec;\n if (start == null)\n start = spec.inclusive;\n if (end == null)\n end = spec.inclusive;\n return { start: start !== null && start !== void 0 ? start : block, end: end !== null && end !== void 0 ? end : block };\n}\nfunction widgetsEq(a, b) {\n return a == b || !!(a && b && a.compare(b));\n}\nfunction addRange(from, to, ranges, margin = 0) {\n let last = ranges.length - 1;\n if (last >= 0 && ranges[last] + margin >= from)\n ranges[last] = Math.max(ranges[last], to);\n else\n ranges.push(from, to);\n}\n\nclass LineView extends ContentView {\n constructor() {\n super(...arguments);\n this.children = [];\n this.length = 0;\n this.prevAttrs = undefined;\n this.attrs = null;\n this.breakAfter = 0;\n }\n // Consumes source\n merge(from, to, source, hasStart, openStart, openEnd) {\n if (source) {\n if (!(source instanceof LineView))\n return false;\n if (!this.dom)\n source.transferDOM(this); // Reuse source.dom when appropriate\n }\n if (hasStart)\n this.setDeco(source ? source.attrs : null);\n mergeChildrenInto(this, from, to, source ? source.children : [], openStart, openEnd);\n return true;\n }\n split(at) {\n let end = new LineView;\n end.breakAfter = this.breakAfter;\n if (this.length == 0)\n return end;\n let { i, off } = this.childPos(at);\n if (off) {\n end.append(this.children[i].split(off), 0);\n this.children[i].merge(off, this.children[i].length, null, false, 0, 0);\n i++;\n }\n for (let j = i; j < this.children.length; j++)\n end.append(this.children[j], 0);\n while (i > 0 && this.children[i - 1].length == 0)\n this.children[--i].destroy();\n this.children.length = i;\n this.markDirty();\n this.length = at;\n return end;\n }\n transferDOM(other) {\n if (!this.dom)\n return;\n this.markDirty();\n other.setDOM(this.dom);\n other.prevAttrs = this.prevAttrs === undefined ? this.attrs : this.prevAttrs;\n this.prevAttrs = undefined;\n this.dom = null;\n }\n setDeco(attrs) {\n if (!attrsEq(this.attrs, attrs)) {\n if (this.dom) {\n this.prevAttrs = this.attrs;\n this.markDirty();\n }\n this.attrs = attrs;\n }\n }\n append(child, openStart) {\n joinInlineInto(this, child, openStart);\n }\n // Only called when building a line view in ContentBuilder\n addLineDeco(deco) {\n let attrs = deco.spec.attributes, cls = deco.spec.class;\n if (attrs)\n this.attrs = combineAttrs(attrs, this.attrs || {});\n if (cls)\n this.attrs = combineAttrs({ class: cls }, this.attrs || {});\n }\n domAtPos(pos) {\n return inlineDOMAtPos(this, pos);\n }\n reuseDOM(node) {\n if (node.nodeName == \"DIV\") {\n this.setDOM(node);\n this.flags |= 4 /* ViewFlag.AttrsDirty */ | 2 /* ViewFlag.NodeDirty */;\n }\n }\n sync(view, track) {\n var _a;\n if (!this.dom) {\n this.setDOM(document.createElement(\"div\"));\n this.dom.className = \"cm-line\";\n this.prevAttrs = this.attrs ? null : undefined;\n }\n else if (this.flags & 4 /* ViewFlag.AttrsDirty */) {\n clearAttributes(this.dom);\n this.dom.className = \"cm-line\";\n this.prevAttrs = this.attrs ? null : undefined;\n }\n if (this.prevAttrs !== undefined) {\n updateAttrs(this.dom, this.prevAttrs, this.attrs);\n this.dom.classList.add(\"cm-line\");\n this.prevAttrs = undefined;\n }\n super.sync(view, track);\n let last = this.dom.lastChild;\n while (last && ContentView.get(last) instanceof MarkView)\n last = last.lastChild;\n if (!last || !this.length ||\n last.nodeName != \"BR\" && ((_a = ContentView.get(last)) === null || _a === void 0 ? void 0 : _a.isEditable) == false &&\n (!browser.ios || !this.children.some(ch => ch instanceof TextView))) {\n let hack = document.createElement(\"BR\");\n hack.cmIgnore = true;\n this.dom.appendChild(hack);\n }\n }\n measureTextSize() {\n if (this.children.length == 0 || this.length > 20)\n return null;\n let totalWidth = 0, textHeight;\n for (let child of this.children) {\n if (!(child instanceof TextView) || /[^ -~]/.test(child.text))\n return null;\n let rects = clientRectsFor(child.dom);\n if (rects.length != 1)\n return null;\n totalWidth += rects[0].width;\n textHeight = rects[0].height;\n }\n return !totalWidth ? null : {\n lineHeight: this.dom.getBoundingClientRect().height,\n charWidth: totalWidth / this.length,\n textHeight\n };\n }\n coordsAt(pos, side) {\n let rect = coordsInChildren(this, pos, side);\n // Correct rectangle height for empty lines when the returned\n // height is larger than the text height.\n if (!this.children.length && rect && this.parent) {\n let { heightOracle } = this.parent.view.viewState, height = rect.bottom - rect.top;\n if (Math.abs(height - heightOracle.lineHeight) < 2 && heightOracle.textHeight < height) {\n let dist = (height - heightOracle.textHeight) / 2;\n return { top: rect.top + dist, bottom: rect.bottom - dist, left: rect.left, right: rect.left };\n }\n }\n return rect;\n }\n become(_other) { return false; }\n get type() { return BlockType.Text; }\n static find(docView, pos) {\n for (let i = 0, off = 0; i < docView.children.length; i++) {\n let block = docView.children[i], end = off + block.length;\n if (end >= pos) {\n if (block instanceof LineView)\n return block;\n if (end > pos)\n break;\n }\n off = end + block.breakAfter;\n }\n return null;\n }\n}\nclass BlockWidgetView extends ContentView {\n constructor(widget, length, type) {\n super();\n this.widget = widget;\n this.length = length;\n this.type = type;\n this.breakAfter = 0;\n this.prevWidget = null;\n }\n merge(from, to, source, _takeDeco, openStart, openEnd) {\n if (source && (!(source instanceof BlockWidgetView) || !this.widget.compare(source.widget) ||\n from > 0 && openStart <= 0 || to < this.length && openEnd <= 0))\n return false;\n this.length = from + (source ? source.length : 0) + (this.length - to);\n return true;\n }\n domAtPos(pos) {\n return pos == 0 ? DOMPos.before(this.dom) : DOMPos.after(this.dom, pos == this.length);\n }\n split(at) {\n let len = this.length - at;\n this.length = at;\n let end = new BlockWidgetView(this.widget, len, this.type);\n end.breakAfter = this.breakAfter;\n return end;\n }\n get children() { return noChildren; }\n sync(view) {\n if (!this.dom || !this.widget.updateDOM(this.dom, view)) {\n if (this.dom && this.prevWidget)\n this.prevWidget.destroy(this.dom);\n this.prevWidget = null;\n this.setDOM(this.widget.toDOM(view));\n this.dom.contentEditable = \"false\";\n }\n }\n get overrideDOMText() {\n return this.parent ? this.parent.view.state.doc.slice(this.posAtStart, this.posAtEnd) : Text.empty;\n }\n domBoundsAround() { return null; }\n become(other) {\n if (other instanceof BlockWidgetView &&\n other.widget.constructor == this.widget.constructor) {\n if (!other.widget.compare(this.widget))\n this.markDirty(true);\n if (this.dom && !this.prevWidget)\n this.prevWidget = this.widget;\n this.widget = other.widget;\n this.length = other.length;\n this.type = other.type;\n this.breakAfter = other.breakAfter;\n return true;\n }\n return false;\n }\n ignoreMutation() { return true; }\n ignoreEvent(event) { return this.widget.ignoreEvent(event); }\n get isEditable() { return false; }\n get isWidget() { return true; }\n coordsAt(pos, side) {\n return this.widget.coordsAt(this.dom, pos, side);\n }\n destroy() {\n super.destroy();\n if (this.dom)\n this.widget.destroy(this.dom);\n }\n}\n\nclass ContentBuilder {\n constructor(doc, pos, end, disallowBlockEffectsFor) {\n this.doc = doc;\n this.pos = pos;\n this.end = end;\n this.disallowBlockEffectsFor = disallowBlockEffectsFor;\n this.content = [];\n this.curLine = null;\n this.breakAtStart = 0;\n this.pendingBuffer = 0 /* Buf.No */;\n this.bufferMarks = [];\n // Set to false directly after a widget that covers the position after it\n this.atCursorPos = true;\n this.openStart = -1;\n this.openEnd = -1;\n this.text = \"\";\n this.textOff = 0;\n this.cursor = doc.iter();\n this.skip = pos;\n }\n posCovered() {\n if (this.content.length == 0)\n return !this.breakAtStart && this.doc.lineAt(this.pos).from != this.pos;\n let last = this.content[this.content.length - 1];\n return !last.breakAfter && !(last instanceof BlockWidgetView && last.type == BlockType.WidgetBefore);\n }\n getLine() {\n if (!this.curLine) {\n this.content.push(this.curLine = new LineView);\n this.atCursorPos = true;\n }\n return this.curLine;\n }\n flushBuffer(active = this.bufferMarks) {\n if (this.pendingBuffer) {\n this.curLine.append(wrapMarks(new WidgetBufferView(-1), active), active.length);\n this.pendingBuffer = 0 /* Buf.No */;\n }\n }\n addBlockWidget(view) {\n this.flushBuffer();\n this.curLine = null;\n this.content.push(view);\n }\n finish(openEnd) {\n if (this.pendingBuffer && openEnd <= this.bufferMarks.length)\n this.flushBuffer();\n else\n this.pendingBuffer = 0 /* Buf.No */;\n if (!this.posCovered())\n this.getLine();\n }\n buildText(length, active, openStart) {\n while (length > 0) {\n if (this.textOff == this.text.length) {\n let { value, lineBreak, done } = this.cursor.next(this.skip);\n this.skip = 0;\n if (done)\n throw new Error(\"Ran out of text content when drawing inline views\");\n if (lineBreak) {\n if (!this.posCovered())\n this.getLine();\n if (this.content.length)\n this.content[this.content.length - 1].breakAfter = 1;\n else\n this.breakAtStart = 1;\n this.flushBuffer();\n this.curLine = null;\n this.atCursorPos = true;\n length--;\n continue;\n }\n else {\n this.text = value;\n this.textOff = 0;\n }\n }\n let take = Math.min(this.text.length - this.textOff, length, 512 /* T.Chunk */);\n this.flushBuffer(active.slice(active.length - openStart));\n this.getLine().append(wrapMarks(new TextView(this.text.slice(this.textOff, this.textOff + take)), active), openStart);\n this.atCursorPos = true;\n this.textOff += take;\n length -= take;\n openStart = 0;\n }\n }\n span(from, to, active, openStart) {\n this.buildText(to - from, active, openStart);\n this.pos = to;\n if (this.openStart < 0)\n this.openStart = openStart;\n }\n point(from, to, deco, active, openStart, index) {\n if (this.disallowBlockEffectsFor[index] && deco instanceof PointDecoration) {\n if (deco.block)\n throw new RangeError(\"Block decorations may not be specified via plugins\");\n if (to > this.doc.lineAt(this.pos).to)\n throw new RangeError(\"Decorations that replace line breaks may not be specified via plugins\");\n }\n let len = to - from;\n if (deco instanceof PointDecoration) {\n if (deco.block) {\n let { type } = deco;\n if (type == BlockType.WidgetAfter && !this.posCovered())\n this.getLine();\n this.addBlockWidget(new BlockWidgetView(deco.widget || new NullWidget(\"div\"), len, type));\n }\n else {\n let view = WidgetView.create(deco.widget || new NullWidget(\"span\"), len, len ? 0 : deco.startSide);\n let cursorBefore = this.atCursorPos && !view.isEditable && openStart <= active.length &&\n (from < to || deco.startSide > 0);\n let cursorAfter = !view.isEditable && (from < to || openStart > active.length || deco.startSide <= 0);\n let line = this.getLine();\n if (this.pendingBuffer == 2 /* Buf.IfCursor */ && !cursorBefore && !view.isEditable)\n this.pendingBuffer = 0 /* Buf.No */;\n this.flushBuffer(active);\n if (cursorBefore) {\n line.append(wrapMarks(new WidgetBufferView(1), active), openStart);\n openStart = active.length + Math.max(0, openStart - active.length);\n }\n line.append(wrapMarks(view, active), openStart);\n this.atCursorPos = cursorAfter;\n this.pendingBuffer = !cursorAfter ? 0 /* Buf.No */ : from < to || openStart > active.length ? 1 /* Buf.Yes */ : 2 /* Buf.IfCursor */;\n if (this.pendingBuffer)\n this.bufferMarks = active.slice();\n }\n }\n else if (this.doc.lineAt(this.pos).from == this.pos) { // Line decoration\n this.getLine().addLineDeco(deco);\n }\n if (len) {\n // Advance the iterator past the replaced content\n if (this.textOff + len <= this.text.length) {\n this.textOff += len;\n }\n else {\n this.skip += len - (this.text.length - this.textOff);\n this.text = \"\";\n this.textOff = 0;\n }\n this.pos = to;\n }\n if (this.openStart < 0)\n this.openStart = openStart;\n }\n static build(text, from, to, decorations, dynamicDecorationMap) {\n let builder = new ContentBuilder(text, from, to, dynamicDecorationMap);\n builder.openEnd = RangeSet.spans(decorations, from, to, builder);\n if (builder.openStart < 0)\n builder.openStart = builder.openEnd;\n builder.finish(builder.openEnd);\n return builder;\n }\n}\nfunction wrapMarks(view, active) {\n for (let mark of active)\n view = new MarkView(mark, [view], view.length);\n return view;\n}\nclass NullWidget extends WidgetType {\n constructor(tag) {\n super();\n this.tag = tag;\n }\n eq(other) { return other.tag == this.tag; }\n toDOM() { return document.createElement(this.tag); }\n updateDOM(elt) { return elt.nodeName.toLowerCase() == this.tag; }\n get isHidden() { return true; }\n}\n\nconst clickAddsSelectionRange = /*@__PURE__*/Facet.define();\nconst dragMovesSelection$1 = /*@__PURE__*/Facet.define();\nconst mouseSelectionStyle = /*@__PURE__*/Facet.define();\nconst exceptionSink = /*@__PURE__*/Facet.define();\nconst updateListener = /*@__PURE__*/Facet.define();\nconst inputHandler = /*@__PURE__*/Facet.define();\nconst focusChangeEffect = /*@__PURE__*/Facet.define();\nconst perLineTextDirection = /*@__PURE__*/Facet.define({\n combine: values => values.some(x => x)\n});\nconst nativeSelectionHidden = /*@__PURE__*/Facet.define({\n combine: values => values.some(x => x)\n});\nclass ScrollTarget {\n constructor(range, y = \"nearest\", x = \"nearest\", yMargin = 5, xMargin = 5) {\n this.range = range;\n this.y = y;\n this.x = x;\n this.yMargin = yMargin;\n this.xMargin = xMargin;\n }\n map(changes) {\n return changes.empty ? this : new ScrollTarget(this.range.map(changes), this.y, this.x, this.yMargin, this.xMargin);\n }\n}\nconst scrollIntoView = /*@__PURE__*/StateEffect.define({ map: (t, ch) => t.map(ch) });\n/**\nLog or report an unhandled exception in client code. Should\nprobably only be used by extension code that allows client code to\nprovide functions, and calls those functions in a context where an\nexception can't be propagated to calling code in a reasonable way\n(for example when in an event handler).\n\nEither calls a handler registered with\n[`EditorView.exceptionSink`](https://codemirror.net/6/docs/ref/#view.EditorView^exceptionSink),\n`window.onerror`, if defined, or `console.error` (in which case\nit'll pass `context`, when given, as first argument).\n*/\nfunction logException(state, exception, context) {\n let handler = state.facet(exceptionSink);\n if (handler.length)\n handler[0](exception);\n else if (window.onerror)\n window.onerror(String(exception), context, undefined, undefined, exception);\n else if (context)\n console.error(context + \":\", exception);\n else\n console.error(exception);\n}\nconst editable = /*@__PURE__*/Facet.define({ combine: values => values.length ? values[0] : true });\nlet nextPluginID = 0;\nconst viewPlugin = /*@__PURE__*/Facet.define();\n/**\nView plugins associate stateful values with a view. They can\ninfluence the way the content is drawn, and are notified of things\nthat happen in the view.\n*/\nclass ViewPlugin {\n constructor(\n /**\n @internal\n */\n id, \n /**\n @internal\n */\n create, \n /**\n @internal\n */\n domEventHandlers, buildExtensions) {\n this.id = id;\n this.create = create;\n this.domEventHandlers = domEventHandlers;\n this.extension = buildExtensions(this);\n }\n /**\n Define a plugin from a constructor function that creates the\n plugin's value, given an editor view.\n */\n static define(create, spec) {\n const { eventHandlers, provide, decorations: deco } = spec || {};\n return new ViewPlugin(nextPluginID++, create, eventHandlers, plugin => {\n let ext = [viewPlugin.of(plugin)];\n if (deco)\n ext.push(decorations.of(view => {\n let pluginInst = view.plugin(plugin);\n return pluginInst ? deco(pluginInst) : Decoration.none;\n }));\n if (provide)\n ext.push(provide(plugin));\n return ext;\n });\n }\n /**\n Create a plugin for a class whose constructor takes a single\n editor view as argument.\n */\n static fromClass(cls, spec) {\n return ViewPlugin.define(view => new cls(view), spec);\n }\n}\nclass PluginInstance {\n constructor(spec) {\n this.spec = spec;\n // When starting an update, all plugins have this field set to the\n // update object, indicating they need to be updated. When finished\n // updating, it is set to `false`. Retrieving a plugin that needs to\n // be updated with `view.plugin` forces an eager update.\n this.mustUpdate = null;\n // This is null when the plugin is initially created, but\n // initialized on the first update.\n this.value = null;\n }\n update(view) {\n if (!this.value) {\n if (this.spec) {\n try {\n this.value = this.spec.create(view);\n }\n catch (e) {\n logException(view.state, e, \"CodeMirror plugin crashed\");\n this.deactivate();\n }\n }\n }\n else if (this.mustUpdate) {\n let update = this.mustUpdate;\n this.mustUpdate = null;\n if (this.value.update) {\n try {\n this.value.update(update);\n }\n catch (e) {\n logException(update.state, e, \"CodeMirror plugin crashed\");\n if (this.value.destroy)\n try {\n this.value.destroy();\n }\n catch (_) { }\n this.deactivate();\n }\n }\n }\n return this;\n }\n destroy(view) {\n var _a;\n if ((_a = this.value) === null || _a === void 0 ? void 0 : _a.destroy) {\n try {\n this.value.destroy();\n }\n catch (e) {\n logException(view.state, e, \"CodeMirror plugin crashed\");\n }\n }\n }\n deactivate() {\n this.spec = this.value = null;\n }\n}\nconst editorAttributes = /*@__PURE__*/Facet.define();\nconst contentAttributes = /*@__PURE__*/Facet.define();\n// Provide decorations\nconst decorations = /*@__PURE__*/Facet.define();\nconst atomicRanges = /*@__PURE__*/Facet.define();\nconst bidiIsolatedRanges = /*@__PURE__*/Facet.define();\nfunction getIsolatedRanges(view, from, to) {\n let isolates = view.state.facet(bidiIsolatedRanges);\n if (!isolates.length)\n return isolates;\n let sets = isolates.map(i => i instanceof Function ? i(view) : i);\n let result = [];\n RangeSet.spans(sets, from, to, {\n point() { },\n span(from, to, active, open) {\n let level = result;\n for (let i = active.length - 1; i >= 0; i--, open--) {\n let iso = active[i].spec.bidiIsolate, update;\n if (iso == null)\n continue;\n if (open > 0 && level.length &&\n (update = level[level.length - 1]).to == from && update.direction == iso) {\n update.to = to;\n level = update.inner;\n }\n else {\n let add = { from, to, direction: iso, inner: [] };\n level.push(add);\n level = add.inner;\n }\n }\n }\n });\n return result;\n}\nconst scrollMargins = /*@__PURE__*/Facet.define();\nfunction getScrollMargins(view) {\n let left = 0, right = 0, top = 0, bottom = 0;\n for (let source of view.state.facet(scrollMargins)) {\n let m = source(view);\n if (m) {\n if (m.left != null)\n left = Math.max(left, m.left);\n if (m.right != null)\n right = Math.max(right, m.right);\n if (m.top != null)\n top = Math.max(top, m.top);\n if (m.bottom != null)\n bottom = Math.max(bottom, m.bottom);\n }\n }\n return { left, right, top, bottom };\n}\nconst styleModule = /*@__PURE__*/Facet.define();\nclass ChangedRange {\n constructor(fromA, toA, fromB, toB) {\n this.fromA = fromA;\n this.toA = toA;\n this.fromB = fromB;\n this.toB = toB;\n }\n join(other) {\n return new ChangedRange(Math.min(this.fromA, other.fromA), Math.max(this.toA, other.toA), Math.min(this.fromB, other.fromB), Math.max(this.toB, other.toB));\n }\n addToSet(set) {\n let i = set.length, me = this;\n for (; i > 0; i--) {\n let range = set[i - 1];\n if (range.fromA > me.toA)\n continue;\n if (range.toA < me.fromA)\n break;\n me = me.join(range);\n set.splice(i - 1, 1);\n }\n set.splice(i, 0, me);\n return set;\n }\n static extendWithRanges(diff, ranges) {\n if (ranges.length == 0)\n return diff;\n let result = [];\n for (let dI = 0, rI = 0, posA = 0, posB = 0;; dI++) {\n let next = dI == diff.length ? null : diff[dI], off = posA - posB;\n let end = next ? next.fromB : 1e9;\n while (rI < ranges.length && ranges[rI] < end) {\n let from = ranges[rI], to = ranges[rI + 1];\n let fromB = Math.max(posB, from), toB = Math.min(end, to);\n if (fromB <= toB)\n new ChangedRange(fromB + off, toB + off, fromB, toB).addToSet(result);\n if (to > end)\n break;\n else\n rI += 2;\n }\n if (!next)\n return result;\n new ChangedRange(next.fromA, next.toA, next.fromB, next.toB).addToSet(result);\n posA = next.toA;\n posB = next.toB;\n }\n }\n}\n/**\nView [plugins](https://codemirror.net/6/docs/ref/#view.ViewPlugin) are given instances of this\nclass, which describe what happened, whenever the view is updated.\n*/\nclass ViewUpdate {\n constructor(\n /**\n The editor view that the update is associated with.\n */\n view, \n /**\n The new editor state.\n */\n state, \n /**\n The transactions involved in the update. May be empty.\n */\n transactions) {\n this.view = view;\n this.state = state;\n this.transactions = transactions;\n /**\n @internal\n */\n this.flags = 0;\n this.startState = view.state;\n this.changes = ChangeSet.empty(this.startState.doc.length);\n for (let tr of transactions)\n this.changes = this.changes.compose(tr.changes);\n let changedRanges = [];\n this.changes.iterChangedRanges((fromA, toA, fromB, toB) => changedRanges.push(new ChangedRange(fromA, toA, fromB, toB)));\n this.changedRanges = changedRanges;\n }\n /**\n @internal\n */\n static create(view, state, transactions) {\n return new ViewUpdate(view, state, transactions);\n }\n /**\n Tells you whether the [viewport](https://codemirror.net/6/docs/ref/#view.EditorView.viewport) or\n [visible ranges](https://codemirror.net/6/docs/ref/#view.EditorView.visibleRanges) changed in this\n update.\n */\n get viewportChanged() {\n return (this.flags & 4 /* UpdateFlag.Viewport */) > 0;\n }\n /**\n Indicates whether the height of a block element in the editor\n changed in this update.\n */\n get heightChanged() {\n return (this.flags & 2 /* UpdateFlag.Height */) > 0;\n }\n /**\n Returns true when the document was modified or the size of the\n editor, or elements within the editor, changed.\n */\n get geometryChanged() {\n return this.docChanged || (this.flags & (8 /* UpdateFlag.Geometry */ | 2 /* UpdateFlag.Height */)) > 0;\n }\n /**\n True when this update indicates a focus change.\n */\n get focusChanged() {\n return (this.flags & 1 /* UpdateFlag.Focus */) > 0;\n }\n /**\n Whether the document changed in this update.\n */\n get docChanged() {\n return !this.changes.empty;\n }\n /**\n Whether the selection was explicitly set in this update.\n */\n get selectionSet() {\n return this.transactions.some(tr => tr.selection);\n }\n /**\n @internal\n */\n get empty() { return this.flags == 0 && this.transactions.length == 0; }\n}\n\n/**\nUsed to indicate [text direction](https://codemirror.net/6/docs/ref/#view.EditorView.textDirection).\n*/\nvar Direction = /*@__PURE__*/(function (Direction) {\n // (These are chosen to match the base levels, in bidi algorithm\n // terms, of spans in that direction.)\n /**\n Left-to-right.\n */\n Direction[Direction[\"LTR\"] = 0] = \"LTR\";\n /**\n Right-to-left.\n */\n Direction[Direction[\"RTL\"] = 1] = \"RTL\";\nreturn Direction})(Direction || (Direction = {}));\nconst LTR = Direction.LTR, RTL = Direction.RTL;\n// Decode a string with each type encoded as log2(type)\nfunction dec(str) {\n let result = [];\n for (let i = 0; i < str.length; i++)\n result.push(1 << +str[i]);\n return result;\n}\n// Character types for codepoints 0 to 0xf8\nconst LowTypes = /*@__PURE__*/dec(\"88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008\");\n// Character types for codepoints 0x600 to 0x6f9\nconst ArabicTypes = /*@__PURE__*/dec(\"4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333\");\nconst Brackets = /*@__PURE__*/Object.create(null), BracketStack = [];\n// There's a lot more in\n// https://www.unicode.org/Public/UCD/latest/ucd/BidiBrackets.txt,\n// which are left out to keep code size down.\nfor (let p of [\"()\", \"[]\", \"{}\"]) {\n let l = /*@__PURE__*/p.charCodeAt(0), r = /*@__PURE__*/p.charCodeAt(1);\n Brackets[l] = r;\n Brackets[r] = -l;\n}\nfunction charType(ch) {\n return ch <= 0xf7 ? LowTypes[ch] :\n 0x590 <= ch && ch <= 0x5f4 ? 2 /* T.R */ :\n 0x600 <= ch && ch <= 0x6f9 ? ArabicTypes[ch - 0x600] :\n 0x6ee <= ch && ch <= 0x8ac ? 4 /* T.AL */ :\n 0x2000 <= ch && ch <= 0x200b ? 256 /* T.NI */ :\n 0xfb50 <= ch && ch <= 0xfdff ? 4 /* T.AL */ :\n ch == 0x200c ? 256 /* T.NI */ : 1 /* T.L */;\n}\nconst BidiRE = /[\\u0590-\\u05f4\\u0600-\\u06ff\\u0700-\\u08ac\\ufb50-\\ufdff]/;\n/**\nRepresents a contiguous range of text that has a single direction\n(as in left-to-right or right-to-left).\n*/\nclass BidiSpan {\n /**\n The direction of this span.\n */\n get dir() { return this.level % 2 ? RTL : LTR; }\n /**\n @internal\n */\n constructor(\n /**\n The start of the span (relative to the start of the line).\n */\n from, \n /**\n The end of the span.\n */\n to, \n /**\n The [\"bidi\n level\"](https://unicode.org/reports/tr9/#Basic_Display_Algorithm)\n of the span (in this context, 0 means\n left-to-right, 1 means right-to-left, 2 means left-to-right\n number inside right-to-left text).\n */\n level) {\n this.from = from;\n this.to = to;\n this.level = level;\n }\n /**\n @internal\n */\n side(end, dir) { return (this.dir == dir) == end ? this.to : this.from; }\n /**\n @internal\n */\n static find(order, index, level, assoc) {\n let maybe = -1;\n for (let i = 0; i < order.length; i++) {\n let span = order[i];\n if (span.from <= index && span.to >= index) {\n if (span.level == level)\n return i;\n // When multiple spans match, if assoc != 0, take the one that\n // covers that side, otherwise take the one with the minimum\n // level.\n if (maybe < 0 || (assoc != 0 ? (assoc < 0 ? span.from < index : span.to > index) : order[maybe].level > span.level))\n maybe = i;\n }\n }\n if (maybe < 0)\n throw new RangeError(\"Index out of range\");\n return maybe;\n }\n}\nfunction isolatesEq(a, b) {\n if (a.length != b.length)\n return false;\n for (let i = 0; i < a.length; i++) {\n let iA = a[i], iB = b[i];\n if (iA.from != iB.from || iA.to != iB.to || iA.direction != iB.direction || !isolatesEq(iA.inner, iB.inner))\n return false;\n }\n return true;\n}\n// Reused array of character types\nconst types = [];\n// Fill in the character types (in `types`) from `from` to `to` and\n// apply W normalization rules.\nfunction computeCharTypes(line, rFrom, rTo, isolates, outerType) {\n for (let iI = 0; iI <= isolates.length; iI++) {\n let from = iI ? isolates[iI - 1].to : rFrom, to = iI < isolates.length ? isolates[iI].from : rTo;\n let prevType = iI ? 256 /* T.NI */ : outerType;\n // W1. Examine each non-spacing mark (NSM) in the level run, and\n // change the type of the NSM to the type of the previous\n // character. If the NSM is at the start of the level run, it will\n // get the type of sor.\n // W2. Search backwards from each instance of a European number\n // until the first strong type (R, L, AL, or sor) is found. If an\n // AL is found, change the type of the European number to Arabic\n // number.\n // W3. Change all ALs to R.\n // (Left after this: L, R, EN, AN, ET, CS, NI)\n for (let i = from, prev = prevType, prevStrong = prevType; i < to; i++) {\n let type = charType(line.charCodeAt(i));\n if (type == 512 /* T.NSM */)\n type = prev;\n else if (type == 8 /* T.EN */ && prevStrong == 4 /* T.AL */)\n type = 16 /* T.AN */;\n types[i] = type == 4 /* T.AL */ ? 2 /* T.R */ : type;\n if (type & 7 /* T.Strong */)\n prevStrong = type;\n prev = type;\n }\n // W5. A sequence of European terminators adjacent to European\n // numbers changes to all European numbers.\n // W6. Otherwise, separators and terminators change to Other\n // Neutral.\n // W7. Search backwards from each instance of a European number\n // until the first strong type (R, L, or sor) is found. If an L is\n // found, then change the type of the European number to L.\n // (Left after this: L, R, EN+AN, NI)\n for (let i = from, prev = prevType, prevStrong = prevType; i < to; i++) {\n let type = types[i];\n if (type == 128 /* T.CS */) {\n if (i < to - 1 && prev == types[i + 1] && (prev & 24 /* T.Num */))\n type = types[i] = prev;\n else\n types[i] = 256 /* T.NI */;\n }\n else if (type == 64 /* T.ET */) {\n let end = i + 1;\n while (end < to && types[end] == 64 /* T.ET */)\n end++;\n let replace = (i && prev == 8 /* T.EN */) || (end < rTo && types[end] == 8 /* T.EN */) ? (prevStrong == 1 /* T.L */ ? 1 /* T.L */ : 8 /* T.EN */) : 256 /* T.NI */;\n for (let j = i; j < end; j++)\n types[j] = replace;\n i = end - 1;\n }\n else if (type == 8 /* T.EN */ && prevStrong == 1 /* T.L */) {\n types[i] = 1 /* T.L */;\n }\n prev = type;\n if (type & 7 /* T.Strong */)\n prevStrong = type;\n }\n }\n}\n// Process brackets throughout a run sequence.\nfunction processBracketPairs(line, rFrom, rTo, isolates, outerType) {\n let oppositeType = outerType == 1 /* T.L */ ? 2 /* T.R */ : 1 /* T.L */;\n for (let iI = 0, sI = 0, context = 0; iI <= isolates.length; iI++) {\n let from = iI ? isolates[iI - 1].to : rFrom, to = iI < isolates.length ? isolates[iI].from : rTo;\n // N0. Process bracket pairs in an isolating run sequence\n // sequentially in the logical order of the text positions of the\n // opening paired brackets using the logic given below. Within this\n // scope, bidirectional types EN and AN are treated as R.\n for (let i = from, ch, br, type; i < to; i++) {\n // Keeps [startIndex, type, strongSeen] triples for each open\n // bracket on BracketStack.\n if (br = Brackets[ch = line.charCodeAt(i)]) {\n if (br < 0) { // Closing bracket\n for (let sJ = sI - 3; sJ >= 0; sJ -= 3) {\n if (BracketStack[sJ + 1] == -br) {\n let flags = BracketStack[sJ + 2];\n let type = (flags & 2 /* Bracketed.EmbedInside */) ? outerType :\n !(flags & 4 /* Bracketed.OppositeInside */) ? 0 :\n (flags & 1 /* Bracketed.OppositeBefore */) ? oppositeType : outerType;\n if (type)\n types[i] = types[BracketStack[sJ]] = type;\n sI = sJ;\n break;\n }\n }\n }\n else if (BracketStack.length == 189 /* Bracketed.MaxDepth */) {\n break;\n }\n else {\n BracketStack[sI++] = i;\n BracketStack[sI++] = ch;\n BracketStack[sI++] = context;\n }\n }\n else if ((type = types[i]) == 2 /* T.R */ || type == 1 /* T.L */) {\n let embed = type == outerType;\n context = embed ? 0 : 1 /* Bracketed.OppositeBefore */;\n for (let sJ = sI - 3; sJ >= 0; sJ -= 3) {\n let cur = BracketStack[sJ + 2];\n if (cur & 2 /* Bracketed.EmbedInside */)\n break;\n if (embed) {\n BracketStack[sJ + 2] |= 2 /* Bracketed.EmbedInside */;\n }\n else {\n if (cur & 4 /* Bracketed.OppositeInside */)\n break;\n BracketStack[sJ + 2] |= 4 /* Bracketed.OppositeInside */;\n }\n }\n }\n }\n }\n}\nfunction processNeutrals(rFrom, rTo, isolates, outerType) {\n for (let iI = 0, prev = outerType; iI <= isolates.length; iI++) {\n let from = iI ? isolates[iI - 1].to : rFrom, to = iI < isolates.length ? isolates[iI].from : rTo;\n // N1. A sequence of neutrals takes the direction of the\n // surrounding strong text if the text on both sides has the same\n // direction. European and Arabic numbers act as if they were R in\n // terms of their influence on neutrals. Start-of-level-run (sor)\n // and end-of-level-run (eor) are used at level run boundaries.\n // N2. Any remaining neutrals take the embedding direction.\n // (Left after this: L, R, EN+AN)\n for (let i = from; i < to;) {\n let type = types[i];\n if (type == 256 /* T.NI */) {\n let end = i + 1;\n for (;;) {\n if (end == to) {\n if (iI == isolates.length)\n break;\n end = isolates[iI++].to;\n to = iI < isolates.length ? isolates[iI].from : rTo;\n }\n else if (types[end] == 256 /* T.NI */) {\n end++;\n }\n else {\n break;\n }\n }\n let beforeL = prev == 1 /* T.L */;\n let afterL = (end < rTo ? types[end] : outerType) == 1 /* T.L */;\n let replace = beforeL == afterL ? (beforeL ? 1 /* T.L */ : 2 /* T.R */) : outerType;\n for (let j = end, jI = iI, fromJ = jI ? isolates[jI - 1].to : rFrom; j > i;) {\n if (j == fromJ) {\n j = isolates[--jI].from;\n fromJ = jI ? isolates[jI - 1].to : rFrom;\n }\n types[--j] = replace;\n }\n i = end;\n }\n else {\n prev = type;\n i++;\n }\n }\n }\n}\n// Find the contiguous ranges of character types in a given range, and\n// emit spans for them. Flip the order of the spans as appropriate\n// based on the level, and call through to compute the spans for\n// isolates at the proper point.\nfunction emitSpans(line, from, to, level, baseLevel, isolates, order) {\n let ourType = level % 2 ? 2 /* T.R */ : 1 /* T.L */;\n if ((level % 2) == (baseLevel % 2)) { // Same dir as base direction, don't flip\n for (let iCh = from, iI = 0; iCh < to;) {\n // Scan a section of characters in direction ourType, unless\n // there's another type of char right after iCh, in which case\n // we scan a section of other characters (which, if ourType ==\n // T.L, may contain both T.R and T.AN chars).\n let sameDir = true, isNum = false;\n if (iI == isolates.length || iCh < isolates[iI].from) {\n let next = types[iCh];\n if (next != ourType) {\n sameDir = false;\n isNum = next == 16 /* T.AN */;\n }\n }\n // Holds an array of isolates to pass to a recursive call if we\n // must recurse (to distinguish T.AN inside an RTL section in\n // LTR text), null if we can emit directly\n let recurse = !sameDir && ourType == 1 /* T.L */ ? [] : null;\n let localLevel = sameDir ? level : level + 1;\n let iScan = iCh;\n run: for (;;) {\n if (iI < isolates.length && iScan == isolates[iI].from) {\n if (isNum)\n break run;\n let iso = isolates[iI];\n // Scan ahead to verify that there is another char in this dir after the isolate(s)\n if (!sameDir)\n for (let upto = iso.to, jI = iI + 1;;) {\n if (upto == to)\n break run;\n if (jI < isolates.length && isolates[jI].from == upto)\n upto = isolates[jI++].to;\n else if (types[upto] == ourType)\n break run;\n else\n break;\n }\n iI++;\n if (recurse) {\n recurse.push(iso);\n }\n else {\n if (iso.from > iCh)\n order.push(new BidiSpan(iCh, iso.from, localLevel));\n let dirSwap = (iso.direction == LTR) != !(localLevel % 2);\n computeSectionOrder(line, dirSwap ? level + 1 : level, baseLevel, iso.inner, iso.from, iso.to, order);\n iCh = iso.to;\n }\n iScan = iso.to;\n }\n else if (iScan == to || (sameDir ? types[iScan] != ourType : types[iScan] == ourType)) {\n break;\n }\n else {\n iScan++;\n }\n }\n if (recurse)\n emitSpans(line, iCh, iScan, level + 1, baseLevel, recurse, order);\n else if (iCh < iScan)\n order.push(new BidiSpan(iCh, iScan, localLevel));\n iCh = iScan;\n }\n }\n else {\n // Iterate in reverse to flip the span order. Same code again, but\n // going from the back of the section to the front\n for (let iCh = to, iI = isolates.length; iCh > from;) {\n let sameDir = true, isNum = false;\n if (!iI || iCh > isolates[iI - 1].to) {\n let next = types[iCh - 1];\n if (next != ourType) {\n sameDir = false;\n isNum = next == 16 /* T.AN */;\n }\n }\n let recurse = !sameDir && ourType == 1 /* T.L */ ? [] : null;\n let localLevel = sameDir ? level : level + 1;\n let iScan = iCh;\n run: for (;;) {\n if (iI && iScan == isolates[iI - 1].to) {\n if (isNum)\n break run;\n let iso = isolates[--iI];\n // Scan ahead to verify that there is another char in this dir after the isolate(s)\n if (!sameDir)\n for (let upto = iso.from, jI = iI;;) {\n if (upto == from)\n break run;\n if (jI && isolates[jI - 1].to == upto)\n upto = isolates[--jI].from;\n else if (types[upto - 1] == ourType)\n break run;\n else\n break;\n }\n if (recurse) {\n recurse.push(iso);\n }\n else {\n if (iso.to < iCh)\n order.push(new BidiSpan(iso.to, iCh, localLevel));\n let dirSwap = (iso.direction == LTR) != !(localLevel % 2);\n computeSectionOrder(line, dirSwap ? level + 1 : level, baseLevel, iso.inner, iso.from, iso.to, order);\n iCh = iso.from;\n }\n iScan = iso.from;\n }\n else if (iScan == from || (sameDir ? types[iScan - 1] != ourType : types[iScan - 1] == ourType)) {\n break;\n }\n else {\n iScan--;\n }\n }\n if (recurse)\n emitSpans(line, iScan, iCh, level + 1, baseLevel, recurse, order);\n else if (iScan < iCh)\n order.push(new BidiSpan(iScan, iCh, localLevel));\n iCh = iScan;\n }\n }\n}\nfunction computeSectionOrder(line, level, baseLevel, isolates, from, to, order) {\n let outerType = (level % 2 ? 2 /* T.R */ : 1 /* T.L */);\n computeCharTypes(line, from, to, isolates, outerType);\n processBracketPairs(line, from, to, isolates, outerType);\n processNeutrals(from, to, isolates, outerType);\n emitSpans(line, from, to, level, baseLevel, isolates, order);\n}\nfunction computeOrder(line, direction, isolates) {\n if (!line)\n return [new BidiSpan(0, 0, direction == RTL ? 1 : 0)];\n if (direction == LTR && !isolates.length && !BidiRE.test(line))\n return trivialOrder(line.length);\n if (isolates.length)\n while (line.length > types.length)\n types[types.length] = 256 /* T.NI */; // Make sure types array has no gaps\n let order = [], level = direction == LTR ? 0 : 1;\n computeSectionOrder(line, level, level, isolates, 0, line.length, order);\n return order;\n}\nfunction trivialOrder(length) {\n return [new BidiSpan(0, length, 0)];\n}\nlet movedOver = \"\";\nfunction moveVisually(line, order, dir, start, forward) {\n var _a;\n let startIndex = start.head - line.from, spanI = -1;\n if (startIndex == 0) {\n if (!forward || !line.length)\n return null;\n if (order[0].level != dir) {\n startIndex = order[0].side(false, dir);\n spanI = 0;\n }\n }\n else if (startIndex == line.length) {\n if (forward)\n return null;\n let last = order[order.length - 1];\n if (last.level != dir) {\n startIndex = last.side(true, dir);\n spanI = order.length - 1;\n }\n }\n if (spanI < 0)\n spanI = BidiSpan.find(order, startIndex, (_a = start.bidiLevel) !== null && _a !== void 0 ? _a : -1, start.assoc);\n let span = order[spanI];\n // End of span. (But not end of line--that was checked for above.)\n if (startIndex == span.side(forward, dir)) {\n span = order[spanI += forward ? 1 : -1];\n startIndex = span.side(!forward, dir);\n }\n let indexForward = forward == (span.dir == dir);\n let nextIndex = findClusterBreak(line.text, startIndex, indexForward);\n movedOver = line.text.slice(Math.min(startIndex, nextIndex), Math.max(startIndex, nextIndex));\n if (nextIndex != span.side(forward, dir))\n return EditorSelection.cursor(nextIndex + line.from, indexForward ? -1 : 1, span.level);\n let nextSpan = spanI == (forward ? order.length - 1 : 0) ? null : order[spanI + (forward ? 1 : -1)];\n if (!nextSpan && span.level != dir)\n return EditorSelection.cursor(forward ? line.to : line.from, forward ? -1 : 1, dir);\n if (nextSpan && nextSpan.level < span.level)\n return EditorSelection.cursor(nextSpan.side(!forward, dir) + line.from, forward ? 1 : -1, nextSpan.level);\n return EditorSelection.cursor(nextIndex + line.from, forward ? -1 : 1, span.level);\n}\n\nclass DocView extends ContentView {\n get length() { return this.view.state.doc.length; }\n constructor(view) {\n super();\n this.view = view;\n this.decorations = [];\n this.dynamicDecorationMap = [];\n this.domChanged = null;\n this.hasComposition = null;\n this.markedForComposition = new Set;\n // Track a minimum width for the editor. When measuring sizes in\n // measureVisibleLineHeights, this is updated to point at the width\n // of a given element and its extent in the document. When a change\n // happens in that range, these are reset. That way, once we've seen\n // a line/element of a given length, we keep the editor wide enough\n // to fit at least that element, until it is changed, at which point\n // we forget it again.\n this.minWidth = 0;\n this.minWidthFrom = 0;\n this.minWidthTo = 0;\n // Track whether the DOM selection was set in a lossy way, so that\n // we don't mess it up when reading it back it\n this.impreciseAnchor = null;\n this.impreciseHead = null;\n this.forceSelection = false;\n // Used by the resize observer to ignore resizes that we caused\n // ourselves\n this.lastUpdate = Date.now();\n this.setDOM(view.contentDOM);\n this.children = [new LineView];\n this.children[0].setParent(this);\n this.updateDeco();\n this.updateInner([new ChangedRange(0, 0, 0, view.state.doc.length)], 0, null);\n }\n // Update the document view to a given state.\n update(update) {\n var _a;\n let changedRanges = update.changedRanges;\n if (this.minWidth > 0 && changedRanges.length) {\n if (!changedRanges.every(({ fromA, toA }) => toA < this.minWidthFrom || fromA > this.minWidthTo)) {\n this.minWidth = this.minWidthFrom = this.minWidthTo = 0;\n }\n else {\n this.minWidthFrom = update.changes.mapPos(this.minWidthFrom, 1);\n this.minWidthTo = update.changes.mapPos(this.minWidthTo, 1);\n }\n }\n let readCompositionAt = -1;\n if (this.view.inputState.composing >= 0) {\n if ((_a = this.domChanged) === null || _a === void 0 ? void 0 : _a.newSel)\n readCompositionAt = this.domChanged.newSel.head;\n else if (!touchesComposition(update.changes, this.hasComposition) && !update.selectionSet)\n readCompositionAt = update.state.selection.main.head;\n }\n let composition = readCompositionAt > -1 ? findCompositionRange(this.view, update.changes, readCompositionAt) : null;\n this.domChanged = null;\n if (this.hasComposition) {\n this.markedForComposition.clear();\n let { from, to } = this.hasComposition;\n changedRanges = new ChangedRange(from, to, update.changes.mapPos(from, -1), update.changes.mapPos(to, 1))\n .addToSet(changedRanges.slice());\n }\n this.hasComposition = composition ? { from: composition.range.fromB, to: composition.range.toB } : null;\n // When the DOM nodes around the selection are moved to another\n // parent, Chrome sometimes reports a different selection through\n // getSelection than the one that it actually shows to the user.\n // This forces a selection update when lines are joined to work\n // around that. Issue #54\n if ((browser.ie || browser.chrome) && !composition && update &&\n update.state.doc.lines != update.startState.doc.lines)\n this.forceSelection = true;\n let prevDeco = this.decorations, deco = this.updateDeco();\n let decoDiff = findChangedDeco(prevDeco, deco, update.changes);\n changedRanges = ChangedRange.extendWithRanges(changedRanges, decoDiff);\n if (!(this.flags & 7 /* ViewFlag.Dirty */) && changedRanges.length == 0) {\n return false;\n }\n else {\n this.updateInner(changedRanges, update.startState.doc.length, composition);\n if (update.transactions.length)\n this.lastUpdate = Date.now();\n return true;\n }\n }\n // Used by update and the constructor do perform the actual DOM\n // update\n updateInner(changes, oldLength, composition) {\n this.view.viewState.mustMeasureContent = true;\n this.updateChildren(changes, oldLength, composition);\n let { observer } = this.view;\n observer.ignore(() => {\n // Lock the height during redrawing, since Chrome sometimes\n // messes with the scroll position during DOM mutation (though\n // no relayout is triggered and I cannot imagine how it can\n // recompute the scroll position without a layout)\n this.dom.style.height = this.view.viewState.contentHeight / this.view.scaleY + \"px\";\n this.dom.style.flexBasis = this.minWidth ? this.minWidth + \"px\" : \"\";\n // Chrome will sometimes, when DOM mutations occur directly\n // around the selection, get confused and report a different\n // selection from the one it displays (issue #218). This tries\n // to detect that situation.\n let track = browser.chrome || browser.ios ? { node: observer.selectionRange.focusNode, written: false } : undefined;\n this.sync(this.view, track);\n this.flags &= ~7 /* ViewFlag.Dirty */;\n if (track && (track.written || observer.selectionRange.focusNode != track.node))\n this.forceSelection = true;\n this.dom.style.height = \"\";\n });\n this.markedForComposition.forEach(cView => cView.flags &= ~8 /* ViewFlag.Composition */);\n let gaps = [];\n if (this.view.viewport.from || this.view.viewport.to < this.view.state.doc.length)\n for (let child of this.children)\n if (child instanceof BlockWidgetView && child.widget instanceof BlockGapWidget)\n gaps.push(child.dom);\n observer.updateGaps(gaps);\n }\n updateChildren(changes, oldLength, composition) {\n let ranges = composition ? composition.range.addToSet(changes.slice()) : changes;\n let cursor = this.childCursor(oldLength);\n for (let i = ranges.length - 1;; i--) {\n let next = i >= 0 ? ranges[i] : null;\n if (!next)\n break;\n let { fromA, toA, fromB, toB } = next, content, breakAtStart, openStart, openEnd;\n if (composition && composition.range.fromB < toB && composition.range.toB > fromB) {\n let before = ContentBuilder.build(this.view.state.doc, fromB, composition.range.fromB, this.decorations, this.dynamicDecorationMap);\n let after = ContentBuilder.build(this.view.state.doc, composition.range.toB, toB, this.decorations, this.dynamicDecorationMap);\n breakAtStart = before.breakAtStart;\n openStart = before.openStart;\n openEnd = after.openEnd;\n let compLine = this.compositionView(composition);\n if (after.breakAtStart) {\n compLine.breakAfter = 1;\n }\n else if (after.content.length &&\n compLine.merge(compLine.length, compLine.length, after.content[0], false, after.openStart, 0)) {\n compLine.breakAfter = after.content[0].breakAfter;\n after.content.shift();\n }\n if (before.content.length &&\n compLine.merge(0, 0, before.content[before.content.length - 1], true, 0, before.openEnd)) {\n before.content.pop();\n }\n content = before.content.concat(compLine).concat(after.content);\n }\n else {\n ({ content, breakAtStart, openStart, openEnd } =\n ContentBuilder.build(this.view.state.doc, fromB, toB, this.decorations, this.dynamicDecorationMap));\n }\n let { i: toI, off: toOff } = cursor.findPos(toA, 1);\n let { i: fromI, off: fromOff } = cursor.findPos(fromA, -1);\n replaceRange(this, fromI, fromOff, toI, toOff, content, breakAtStart, openStart, openEnd);\n }\n if (composition)\n this.fixCompositionDOM(composition);\n }\n compositionView(composition) {\n let cur = new TextView(composition.text.nodeValue);\n cur.flags |= 8 /* ViewFlag.Composition */;\n for (let { deco } of composition.marks)\n cur = new MarkView(deco, [cur], cur.length);\n let line = new LineView;\n line.append(cur, 0);\n return line;\n }\n fixCompositionDOM(composition) {\n let fix = (dom, cView) => {\n cView.flags |= 8 /* ViewFlag.Composition */ | (cView.children.some(c => c.flags & 7 /* ViewFlag.Dirty */) ? 1 /* ViewFlag.ChildDirty */ : 0);\n this.markedForComposition.add(cView);\n let prev = ContentView.get(dom);\n if (prev && prev != cView)\n prev.dom = null;\n cView.setDOM(dom);\n };\n let pos = this.childPos(composition.range.fromB, 1);\n let cView = this.children[pos.i];\n fix(composition.line, cView);\n for (let i = composition.marks.length - 1; i >= -1; i--) {\n pos = cView.childPos(pos.off, 1);\n cView = cView.children[pos.i];\n fix(i >= 0 ? composition.marks[i].node : composition.text, cView);\n }\n }\n // Sync the DOM selection to this.state.selection\n updateSelection(mustRead = false, fromPointer = false) {\n if (mustRead || !this.view.observer.selectionRange.focusNode)\n this.view.observer.readSelectionRange();\n let activeElt = this.view.root.activeElement, focused = activeElt == this.dom;\n let selectionNotFocus = !focused &&\n hasSelection(this.dom, this.view.observer.selectionRange) && !(activeElt && this.dom.contains(activeElt));\n if (!(focused || fromPointer || selectionNotFocus))\n return;\n let force = this.forceSelection;\n this.forceSelection = false;\n let main = this.view.state.selection.main;\n let anchor = this.moveToLine(this.domAtPos(main.anchor));\n let head = main.empty ? anchor : this.moveToLine(this.domAtPos(main.head));\n // Always reset on Firefox when next to an uneditable node to\n // avoid invisible cursor bugs (#111)\n if (browser.gecko && main.empty && !this.hasComposition && betweenUneditable(anchor)) {\n let dummy = document.createTextNode(\"\");\n this.view.observer.ignore(() => anchor.node.insertBefore(dummy, anchor.node.childNodes[anchor.offset] || null));\n anchor = head = new DOMPos(dummy, 0);\n force = true;\n }\n let domSel = this.view.observer.selectionRange;\n // If the selection is already here, or in an equivalent position, don't touch it\n if (force || !domSel.focusNode ||\n !isEquivalentPosition(anchor.node, anchor.offset, domSel.anchorNode, domSel.anchorOffset) ||\n !isEquivalentPosition(head.node, head.offset, domSel.focusNode, domSel.focusOffset)) {\n this.view.observer.ignore(() => {\n // Chrome Android will hide the virtual keyboard when tapping\n // inside an uneditable node, and not bring it back when we\n // move the cursor to its proper position. This tries to\n // restore the keyboard by cycling focus.\n if (browser.android && browser.chrome && this.dom.contains(domSel.focusNode) &&\n inUneditable(domSel.focusNode, this.dom)) {\n this.dom.blur();\n this.dom.focus({ preventScroll: true });\n }\n let rawSel = getSelection(this.view.root);\n if (!rawSel) ;\n else if (main.empty) {\n // Work around https://bugzilla.mozilla.org/show_bug.cgi?id=1612076\n if (browser.gecko) {\n let nextTo = nextToUneditable(anchor.node, anchor.offset);\n if (nextTo && nextTo != (1 /* NextTo.Before */ | 2 /* NextTo.After */)) {\n let text = nearbyTextNode(anchor.node, anchor.offset, nextTo == 1 /* NextTo.Before */ ? 1 : -1);\n if (text)\n anchor = new DOMPos(text.node, text.offset);\n }\n }\n rawSel.collapse(anchor.node, anchor.offset);\n if (main.bidiLevel != null && rawSel.caretBidiLevel !== undefined)\n rawSel.caretBidiLevel = main.bidiLevel;\n }\n else if (rawSel.extend) {\n // Selection.extend can be used to create an 'inverted' selection\n // (one where the focus is before the anchor), but not all\n // browsers support it yet.\n rawSel.collapse(anchor.node, anchor.offset);\n // Safari will ignore the call above when the editor is\n // hidden, and then raise an error on the call to extend\n // (#940).\n try {\n rawSel.extend(head.node, head.offset);\n }\n catch (_) { }\n }\n else {\n // Primitive (IE) way\n let range = document.createRange();\n if (main.anchor > main.head)\n [anchor, head] = [head, anchor];\n range.setEnd(head.node, head.offset);\n range.setStart(anchor.node, anchor.offset);\n rawSel.removeAllRanges();\n rawSel.addRange(range);\n }\n if (selectionNotFocus && this.view.root.activeElement == this.dom) {\n this.dom.blur();\n if (activeElt)\n activeElt.focus();\n }\n });\n this.view.observer.setSelectionRange(anchor, head);\n }\n this.impreciseAnchor = anchor.precise ? null : new DOMPos(domSel.anchorNode, domSel.anchorOffset);\n this.impreciseHead = head.precise ? null : new DOMPos(domSel.focusNode, domSel.focusOffset);\n }\n enforceCursorAssoc() {\n if (this.hasComposition)\n return;\n let { view } = this, cursor = view.state.selection.main;\n let sel = getSelection(view.root);\n let { anchorNode, anchorOffset } = view.observer.selectionRange;\n if (!sel || !cursor.empty || !cursor.assoc || !sel.modify)\n return;\n let line = LineView.find(this, cursor.head);\n if (!line)\n return;\n let lineStart = line.posAtStart;\n if (cursor.head == lineStart || cursor.head == lineStart + line.length)\n return;\n let before = this.coordsAt(cursor.head, -1), after = this.coordsAt(cursor.head, 1);\n if (!before || !after || before.bottom > after.top)\n return;\n let dom = this.domAtPos(cursor.head + cursor.assoc);\n sel.collapse(dom.node, dom.offset);\n sel.modify(\"move\", cursor.assoc < 0 ? \"forward\" : \"backward\", \"lineboundary\");\n // This can go wrong in corner cases like single-character lines,\n // so check and reset if necessary.\n view.observer.readSelectionRange();\n let newRange = view.observer.selectionRange;\n if (view.docView.posFromDOM(newRange.anchorNode, newRange.anchorOffset) != cursor.from)\n sel.collapse(anchorNode, anchorOffset);\n }\n // If a position is in/near a block widget, move it to a nearby text\n // line, since we don't want the cursor inside a block widget.\n moveToLine(pos) {\n // Block widgets will return positions before/after them, which\n // are thus directly in the document DOM element.\n let dom = this.dom, newPos;\n if (pos.node != dom)\n return pos;\n for (let i = pos.offset; !newPos && i < dom.childNodes.length; i++) {\n let view = ContentView.get(dom.childNodes[i]);\n if (view instanceof LineView)\n newPos = view.domAtPos(0);\n }\n for (let i = pos.offset - 1; !newPos && i >= 0; i--) {\n let view = ContentView.get(dom.childNodes[i]);\n if (view instanceof LineView)\n newPos = view.domAtPos(view.length);\n }\n return newPos ? new DOMPos(newPos.node, newPos.offset, true) : pos;\n }\n nearest(dom) {\n for (let cur = dom; cur;) {\n let domView = ContentView.get(cur);\n if (domView && domView.rootView == this)\n return domView;\n cur = cur.parentNode;\n }\n return null;\n }\n posFromDOM(node, offset) {\n let view = this.nearest(node);\n if (!view)\n throw new RangeError(\"Trying to find position for a DOM position outside of the document\");\n return view.localPosFromDOM(node, offset) + view.posAtStart;\n }\n domAtPos(pos) {\n let { i, off } = this.childCursor().findPos(pos, -1);\n for (; i < this.children.length - 1;) {\n let child = this.children[i];\n if (off < child.length || child instanceof LineView)\n break;\n i++;\n off = 0;\n }\n return this.children[i].domAtPos(off);\n }\n coordsAt(pos, side) {\n for (let off = this.length, i = this.children.length - 1;; i--) {\n let child = this.children[i], start = off - child.breakAfter - child.length;\n if (pos > start ||\n (pos == start && child.type != BlockType.WidgetBefore && child.type != BlockType.WidgetAfter &&\n (!i || side == 2 || this.children[i - 1].breakAfter ||\n (this.children[i - 1].type == BlockType.WidgetBefore && side > -2))))\n return child.coordsAt(pos - start, side);\n off = start;\n }\n }\n coordsForChar(pos) {\n let { i, off } = this.childPos(pos, 1), child = this.children[i];\n if (!(child instanceof LineView))\n return null;\n while (child.children.length) {\n let { i, off: childOff } = child.childPos(off, 1);\n for (;; i++) {\n if (i == child.children.length)\n return null;\n if ((child = child.children[i]).length)\n break;\n }\n off = childOff;\n }\n if (!(child instanceof TextView))\n return null;\n let end = findClusterBreak(child.text, off);\n if (end == off)\n return null;\n let rects = textRange(child.dom, off, end).getClientRects();\n return !rects.length || rects[0].top >= rects[0].bottom ? null : rects[0];\n }\n measureVisibleLineHeights(viewport) {\n let result = [], { from, to } = viewport;\n let contentWidth = this.view.contentDOM.clientWidth;\n let isWider = contentWidth > Math.max(this.view.scrollDOM.clientWidth, this.minWidth) + 1;\n let widest = -1, ltr = this.view.textDirection == Direction.LTR;\n for (let pos = 0, i = 0; i < this.children.length; i++) {\n let child = this.children[i], end = pos + child.length;\n if (end > to)\n break;\n if (pos >= from) {\n let childRect = child.dom.getBoundingClientRect();\n result.push(childRect.height);\n if (isWider) {\n let last = child.dom.lastChild;\n let rects = last ? clientRectsFor(last) : [];\n if (rects.length) {\n let rect = rects[rects.length - 1];\n let width = ltr ? rect.right - childRect.left : childRect.right - rect.left;\n if (width > widest) {\n widest = width;\n this.minWidth = contentWidth;\n this.minWidthFrom = pos;\n this.minWidthTo = end;\n }\n }\n }\n }\n pos = end + child.breakAfter;\n }\n return result;\n }\n textDirectionAt(pos) {\n let { i } = this.childPos(pos, 1);\n return getComputedStyle(this.children[i].dom).direction == \"rtl\" ? Direction.RTL : Direction.LTR;\n }\n measureTextSize() {\n for (let child of this.children) {\n if (child instanceof LineView) {\n let measure = child.measureTextSize();\n if (measure)\n return measure;\n }\n }\n // If no workable line exists, force a layout of a measurable element\n let dummy = document.createElement(\"div\"), lineHeight, charWidth, textHeight;\n dummy.className = \"cm-line\";\n dummy.style.width = \"99999px\";\n dummy.style.position = \"absolute\";\n dummy.textContent = \"abc def ghi jkl mno pqr stu\";\n this.view.observer.ignore(() => {\n this.dom.appendChild(dummy);\n let rect = clientRectsFor(dummy.firstChild)[0];\n lineHeight = dummy.getBoundingClientRect().height;\n charWidth = rect ? rect.width / 27 : 7;\n textHeight = rect ? rect.height : lineHeight;\n dummy.remove();\n });\n return { lineHeight, charWidth, textHeight };\n }\n childCursor(pos = this.length) {\n // Move back to start of last element when possible, so that\n // `ChildCursor.findPos` doesn't have to deal with the edge case\n // of being after the last element.\n let i = this.children.length;\n if (i)\n pos -= this.children[--i].length;\n return new ChildCursor(this.children, pos, i);\n }\n computeBlockGapDeco() {\n let deco = [], vs = this.view.viewState;\n for (let pos = 0, i = 0;; i++) {\n let next = i == vs.viewports.length ? null : vs.viewports[i];\n let end = next ? next.from - 1 : this.length;\n if (end > pos) {\n let height = (vs.lineBlockAt(end).bottom - vs.lineBlockAt(pos).top) / this.view.scaleY;\n deco.push(Decoration.replace({\n widget: new BlockGapWidget(height),\n block: true,\n inclusive: true,\n isBlockGap: true,\n }).range(pos, end));\n }\n if (!next)\n break;\n pos = next.to + 1;\n }\n return Decoration.set(deco);\n }\n updateDeco() {\n let allDeco = this.view.state.facet(decorations).map((d, i) => {\n let dynamic = this.dynamicDecorationMap[i] = typeof d == \"function\";\n return dynamic ? d(this.view) : d;\n });\n for (let i = allDeco.length; i < allDeco.length + 3; i++)\n this.dynamicDecorationMap[i] = false;\n return this.decorations = [\n ...allDeco,\n this.computeBlockGapDeco(),\n this.view.viewState.lineGapDeco\n ];\n }\n scrollIntoView(target) {\n let { range } = target;\n let rect = this.coordsAt(range.head, range.empty ? range.assoc : range.head > range.anchor ? -1 : 1), other;\n if (!rect)\n return;\n if (!range.empty && (other = this.coordsAt(range.anchor, range.anchor > range.head ? -1 : 1)))\n rect = { left: Math.min(rect.left, other.left), top: Math.min(rect.top, other.top),\n right: Math.max(rect.right, other.right), bottom: Math.max(rect.bottom, other.bottom) };\n let margins = getScrollMargins(this.view);\n let targetRect = {\n left: rect.left - margins.left, top: rect.top - margins.top,\n right: rect.right + margins.right, bottom: rect.bottom + margins.bottom\n };\n scrollRectIntoView(this.view.scrollDOM, targetRect, range.head < range.anchor ? -1 : 1, target.x, target.y, target.xMargin, target.yMargin, this.view.textDirection == Direction.LTR);\n }\n}\nfunction betweenUneditable(pos) {\n return pos.node.nodeType == 1 && pos.node.firstChild &&\n (pos.offset == 0 || pos.node.childNodes[pos.offset - 1].contentEditable == \"false\") &&\n (pos.offset == pos.node.childNodes.length || pos.node.childNodes[pos.offset].contentEditable == \"false\");\n}\nclass BlockGapWidget extends WidgetType {\n constructor(height) {\n super();\n this.height = height;\n }\n toDOM() {\n let elt = document.createElement(\"div\");\n this.updateDOM(elt);\n return elt;\n }\n eq(other) { return other.height == this.height; }\n updateDOM(elt) {\n elt.style.height = this.height + \"px\";\n return true;\n }\n get estimatedHeight() { return this.height; }\n}\nfunction findCompositionNode(view, headPos) {\n let sel = view.observer.selectionRange;\n let textNode = sel.focusNode && nearbyTextNode(sel.focusNode, sel.focusOffset, 0);\n if (!textNode)\n return null;\n let from = headPos - textNode.offset;\n return { from, to: from + textNode.node.nodeValue.length, node: textNode.node };\n}\nfunction findCompositionRange(view, changes, headPos) {\n let found = findCompositionNode(view, headPos);\n if (!found)\n return null;\n let { node: textNode, from, to } = found, text = textNode.nodeValue;\n // Don't try to preserve multi-line compositions\n if (/[\\n\\r]/.test(text))\n return null;\n if (view.state.doc.sliceString(found.from, found.to) != text)\n return null;\n let inv = changes.invertedDesc;\n let range = new ChangedRange(inv.mapPos(from), inv.mapPos(to), from, to);\n let marks = [];\n for (let parent = textNode.parentNode;; parent = parent.parentNode) {\n let parentView = ContentView.get(parent);\n if (parentView instanceof MarkView)\n marks.push({ node: parent, deco: parentView.mark });\n else if (parentView instanceof LineView || parent.nodeName == \"DIV\" && parent.parentNode == view.contentDOM)\n return { range, text: textNode, marks, line: parent };\n else if (parent != view.contentDOM)\n marks.push({ node: parent, deco: new MarkDecoration({\n inclusive: true,\n attributes: getAttrs(parent),\n tagName: parent.tagName.toLowerCase()\n }) });\n else\n return null;\n }\n}\nfunction nearbyTextNode(startNode, startOffset, side) {\n if (side <= 0)\n for (let node = startNode, offset = startOffset;;) {\n if (node.nodeType == 3)\n return { node: node, offset: offset };\n if (node.nodeType == 1 && offset > 0) {\n node = node.childNodes[offset - 1];\n offset = maxOffset(node);\n }\n else {\n break;\n }\n }\n if (side >= 0)\n for (let node = startNode, offset = startOffset;;) {\n if (node.nodeType == 3)\n return { node: node, offset: offset };\n if (node.nodeType == 1 && offset < node.childNodes.length && side >= 0) {\n node = node.childNodes[offset];\n offset = 0;\n }\n else {\n break;\n }\n }\n return null;\n}\nfunction nextToUneditable(node, offset) {\n if (node.nodeType != 1)\n return 0;\n return (offset && node.childNodes[offset - 1].contentEditable == \"false\" ? 1 /* NextTo.Before */ : 0) |\n (offset < node.childNodes.length && node.childNodes[offset].contentEditable == \"false\" ? 2 /* NextTo.After */ : 0);\n}\nlet DecorationComparator$1 = class DecorationComparator {\n constructor() {\n this.changes = [];\n }\n compareRange(from, to) { addRange(from, to, this.changes); }\n comparePoint(from, to) { addRange(from, to, this.changes); }\n};\nfunction findChangedDeco(a, b, diff) {\n let comp = new DecorationComparator$1;\n RangeSet.compare(a, b, diff, comp);\n return comp.changes;\n}\nfunction inUneditable(node, inside) {\n for (let cur = node; cur && cur != inside; cur = cur.assignedSlot || cur.parentNode) {\n if (cur.nodeType == 1 && cur.contentEditable == 'false') {\n return true;\n }\n }\n return false;\n}\nfunction touchesComposition(changes, composition) {\n let touched = false;\n if (composition)\n changes.iterChangedRanges((from, to) => {\n if (from < composition.to && to > composition.from)\n touched = true;\n });\n return touched;\n}\n\nfunction groupAt(state, pos, bias = 1) {\n let categorize = state.charCategorizer(pos);\n let line = state.doc.lineAt(pos), linePos = pos - line.from;\n if (line.length == 0)\n return EditorSelection.cursor(pos);\n if (linePos == 0)\n bias = 1;\n else if (linePos == line.length)\n bias = -1;\n let from = linePos, to = linePos;\n if (bias < 0)\n from = findClusterBreak(line.text, linePos, false);\n else\n to = findClusterBreak(line.text, linePos);\n let cat = categorize(line.text.slice(from, to));\n while (from > 0) {\n let prev = findClusterBreak(line.text, from, false);\n if (categorize(line.text.slice(prev, from)) != cat)\n break;\n from = prev;\n }\n while (to < line.length) {\n let next = findClusterBreak(line.text, to);\n if (categorize(line.text.slice(to, next)) != cat)\n break;\n to = next;\n }\n return EditorSelection.range(from + line.from, to + line.from);\n}\n// Search the DOM for the {node, offset} position closest to the given\n// coordinates. Very inefficient and crude, but can usually be avoided\n// by calling caret(Position|Range)FromPoint instead.\nfunction getdx(x, rect) {\n return rect.left > x ? rect.left - x : Math.max(0, x - rect.right);\n}\nfunction getdy(y, rect) {\n return rect.top > y ? rect.top - y : Math.max(0, y - rect.bottom);\n}\nfunction yOverlap(a, b) {\n return a.top < b.bottom - 1 && a.bottom > b.top + 1;\n}\nfunction upTop(rect, top) {\n return top < rect.top ? { top, left: rect.left, right: rect.right, bottom: rect.bottom } : rect;\n}\nfunction upBot(rect, bottom) {\n return bottom > rect.bottom ? { top: rect.top, left: rect.left, right: rect.right, bottom } : rect;\n}\nfunction domPosAtCoords(parent, x, y) {\n let closest, closestRect, closestX, closestY, closestOverlap = false;\n let above, below, aboveRect, belowRect;\n for (let child = parent.firstChild; child; child = child.nextSibling) {\n let rects = clientRectsFor(child);\n for (let i = 0; i < rects.length; i++) {\n let rect = rects[i];\n if (closestRect && yOverlap(closestRect, rect))\n rect = upTop(upBot(rect, closestRect.bottom), closestRect.top);\n let dx = getdx(x, rect), dy = getdy(y, rect);\n if (dx == 0 && dy == 0)\n return child.nodeType == 3 ? domPosInText(child, x, y) : domPosAtCoords(child, x, y);\n if (!closest || closestY > dy || closestY == dy && closestX > dx) {\n closest = child;\n closestRect = rect;\n closestX = dx;\n closestY = dy;\n let side = dy ? (y < rect.top ? -1 : 1) : dx ? (x < rect.left ? -1 : 1) : 0;\n closestOverlap = !side || (side > 0 ? i < rects.length - 1 : i > 0);\n }\n if (dx == 0) {\n if (y > rect.bottom && (!aboveRect || aboveRect.bottom < rect.bottom)) {\n above = child;\n aboveRect = rect;\n }\n else if (y < rect.top && (!belowRect || belowRect.top > rect.top)) {\n below = child;\n belowRect = rect;\n }\n }\n else if (aboveRect && yOverlap(aboveRect, rect)) {\n aboveRect = upBot(aboveRect, rect.bottom);\n }\n else if (belowRect && yOverlap(belowRect, rect)) {\n belowRect = upTop(belowRect, rect.top);\n }\n }\n }\n if (aboveRect && aboveRect.bottom >= y) {\n closest = above;\n closestRect = aboveRect;\n }\n else if (belowRect && belowRect.top <= y) {\n closest = below;\n closestRect = belowRect;\n }\n if (!closest)\n return { node: parent, offset: 0 };\n let clipX = Math.max(closestRect.left, Math.min(closestRect.right, x));\n if (closest.nodeType == 3)\n return domPosInText(closest, clipX, y);\n if (closestOverlap && closest.contentEditable != \"false\")\n return domPosAtCoords(closest, clipX, y);\n let offset = Array.prototype.indexOf.call(parent.childNodes, closest) +\n (x >= (closestRect.left + closestRect.right) / 2 ? 1 : 0);\n return { node: parent, offset };\n}\nfunction domPosInText(node, x, y) {\n let len = node.nodeValue.length;\n let closestOffset = -1, closestDY = 1e9, generalSide = 0;\n for (let i = 0; i < len; i++) {\n let rects = textRange(node, i, i + 1).getClientRects();\n for (let j = 0; j < rects.length; j++) {\n let rect = rects[j];\n if (rect.top == rect.bottom)\n continue;\n if (!generalSide)\n generalSide = x - rect.left;\n let dy = (rect.top > y ? rect.top - y : y - rect.bottom) - 1;\n if (rect.left - 1 <= x && rect.right + 1 >= x && dy < closestDY) {\n let right = x >= (rect.left + rect.right) / 2, after = right;\n if (browser.chrome || browser.gecko) {\n // Check for RTL on browsers that support getting client\n // rects for empty ranges.\n let rectBefore = textRange(node, i).getBoundingClientRect();\n if (rectBefore.left == rect.right)\n after = !right;\n }\n if (dy <= 0)\n return { node, offset: i + (after ? 1 : 0) };\n closestOffset = i + (after ? 1 : 0);\n closestDY = dy;\n }\n }\n }\n return { node, offset: closestOffset > -1 ? closestOffset : generalSide > 0 ? node.nodeValue.length : 0 };\n}\nfunction posAtCoords(view, coords, precise, bias = -1) {\n var _a, _b;\n let content = view.contentDOM.getBoundingClientRect(), docTop = content.top + view.viewState.paddingTop;\n let block, { docHeight } = view.viewState;\n let { x, y } = coords, yOffset = y - docTop;\n if (yOffset < 0)\n return 0;\n if (yOffset > docHeight)\n return view.state.doc.length;\n // Scan for a text block near the queried y position\n for (let halfLine = view.viewState.heightOracle.textHeight / 2, bounced = false;;) {\n block = view.elementAtHeight(yOffset);\n if (block.type == BlockType.Text)\n break;\n for (;;) {\n // Move the y position out of this block\n yOffset = bias > 0 ? block.bottom + halfLine : block.top - halfLine;\n if (yOffset >= 0 && yOffset <= docHeight)\n break;\n // If the document consists entirely of replaced widgets, we\n // won't find a text block, so return 0\n if (bounced)\n return precise ? null : 0;\n bounced = true;\n bias = -bias;\n }\n }\n y = docTop + yOffset;\n let lineStart = block.from;\n // If this is outside of the rendered viewport, we can't determine a position\n if (lineStart < view.viewport.from)\n return view.viewport.from == 0 ? 0 : precise ? null : posAtCoordsImprecise(view, content, block, x, y);\n if (lineStart > view.viewport.to)\n return view.viewport.to == view.state.doc.length ? view.state.doc.length :\n precise ? null : posAtCoordsImprecise(view, content, block, x, y);\n // Prefer ShadowRootOrDocument.elementFromPoint if present, fall back to document if not\n let doc = view.dom.ownerDocument;\n let root = view.root.elementFromPoint ? view.root : doc;\n let element = root.elementFromPoint(x, y);\n if (element && !view.contentDOM.contains(element))\n element = null;\n // If the element is unexpected, clip x at the sides of the content area and try again\n if (!element) {\n x = Math.max(content.left + 1, Math.min(content.right - 1, x));\n element = root.elementFromPoint(x, y);\n if (element && !view.contentDOM.contains(element))\n element = null;\n }\n // There's visible editor content under the point, so we can try\n // using caret(Position|Range)FromPoint as a shortcut\n let node, offset = -1;\n if (element && ((_a = view.docView.nearest(element)) === null || _a === void 0 ? void 0 : _a.isEditable) != false) {\n if (doc.caretPositionFromPoint) {\n let pos = doc.caretPositionFromPoint(x, y);\n if (pos)\n ({ offsetNode: node, offset } = pos);\n }\n else if (doc.caretRangeFromPoint) {\n let range = doc.caretRangeFromPoint(x, y);\n if (range) {\n ({ startContainer: node, startOffset: offset } = range);\n if (!view.contentDOM.contains(node) ||\n browser.safari && isSuspiciousSafariCaretResult(node, offset, x) ||\n browser.chrome && isSuspiciousChromeCaretResult(node, offset, x))\n node = undefined;\n }\n }\n }\n // No luck, do our own (potentially expensive) search\n if (!node || !view.docView.dom.contains(node)) {\n let line = LineView.find(view.docView, lineStart);\n if (!line)\n return yOffset > block.top + block.height / 2 ? block.to : block.from;\n ({ node, offset } = domPosAtCoords(line.dom, x, y));\n }\n let nearest = view.docView.nearest(node);\n if (!nearest)\n return null;\n if (nearest.isWidget && ((_b = nearest.dom) === null || _b === void 0 ? void 0 : _b.nodeType) == 1) {\n let rect = nearest.dom.getBoundingClientRect();\n return coords.y < rect.top || coords.y <= rect.bottom && coords.x <= (rect.left + rect.right) / 2\n ? nearest.posAtStart : nearest.posAtEnd;\n }\n else {\n return nearest.localPosFromDOM(node, offset) + nearest.posAtStart;\n }\n}\nfunction posAtCoordsImprecise(view, contentRect, block, x, y) {\n let into = Math.round((x - contentRect.left) * view.defaultCharacterWidth);\n if (view.lineWrapping && block.height > view.defaultLineHeight * 1.5) {\n let textHeight = view.viewState.heightOracle.textHeight;\n let line = Math.floor((y - block.top - (view.defaultLineHeight - textHeight) * 0.5) / textHeight);\n into += line * view.viewState.heightOracle.lineLength;\n }\n let content = view.state.sliceDoc(block.from, block.to);\n return block.from + findColumn(content, into, view.state.tabSize);\n}\n// In case of a high line height, Safari's caretRangeFromPoint treats\n// the space between lines as belonging to the last character of the\n// line before. This is used to detect such a result so that it can be\n// ignored (issue #401).\nfunction isSuspiciousSafariCaretResult(node, offset, x) {\n let len;\n if (node.nodeType != 3 || offset != (len = node.nodeValue.length))\n return false;\n for (let next = node.nextSibling; next; next = next.nextSibling)\n if (next.nodeType != 1 || next.nodeName != \"BR\")\n return false;\n return textRange(node, len - 1, len).getBoundingClientRect().left > x;\n}\n// Chrome will move positions between lines to the start of the next line\nfunction isSuspiciousChromeCaretResult(node, offset, x) {\n if (offset != 0)\n return false;\n for (let cur = node;;) {\n let parent = cur.parentNode;\n if (!parent || parent.nodeType != 1 || parent.firstChild != cur)\n return false;\n if (parent.classList.contains(\"cm-line\"))\n break;\n cur = parent;\n }\n let rect = node.nodeType == 1 ? node.getBoundingClientRect()\n : textRange(node, 0, Math.max(node.nodeValue.length, 1)).getBoundingClientRect();\n return x - rect.left > 5;\n}\nfunction blockAt(view, pos) {\n let line = view.lineBlockAt(pos);\n if (Array.isArray(line.type))\n for (let l of line.type) {\n if (l.to > pos || l.to == pos && (l.to == line.to || l.type == BlockType.Text))\n return l;\n }\n return line;\n}\nfunction moveToLineBoundary(view, start, forward, includeWrap) {\n let line = blockAt(view, start.head);\n let coords = !includeWrap || line.type != BlockType.Text || !(view.lineWrapping || line.widgetLineBreaks) ? null\n : view.coordsAtPos(start.assoc < 0 && start.head > line.from ? start.head - 1 : start.head);\n if (coords) {\n let editorRect = view.dom.getBoundingClientRect();\n let direction = view.textDirectionAt(line.from);\n let pos = view.posAtCoords({ x: forward == (direction == Direction.LTR) ? editorRect.right - 1 : editorRect.left + 1,\n y: (coords.top + coords.bottom) / 2 });\n if (pos != null)\n return EditorSelection.cursor(pos, forward ? -1 : 1);\n }\n return EditorSelection.cursor(forward ? line.to : line.from, forward ? -1 : 1);\n}\nfunction moveByChar(view, start, forward, by) {\n let line = view.state.doc.lineAt(start.head), spans = view.bidiSpans(line);\n let direction = view.textDirectionAt(line.from);\n for (let cur = start, check = null;;) {\n let next = moveVisually(line, spans, direction, cur, forward), char = movedOver;\n if (!next) {\n if (line.number == (forward ? view.state.doc.lines : 1))\n return cur;\n char = \"\\n\";\n line = view.state.doc.line(line.number + (forward ? 1 : -1));\n spans = view.bidiSpans(line);\n next = EditorSelection.cursor(forward ? line.from : line.to);\n }\n if (!check) {\n if (!by)\n return next;\n check = by(char);\n }\n else if (!check(char)) {\n return cur;\n }\n cur = next;\n }\n}\nfunction byGroup(view, pos, start) {\n let categorize = view.state.charCategorizer(pos);\n let cat = categorize(start);\n return (next) => {\n let nextCat = categorize(next);\n if (cat == CharCategory.Space)\n cat = nextCat;\n return cat == nextCat;\n };\n}\nfunction moveVertically(view, start, forward, distance) {\n let startPos = start.head, dir = forward ? 1 : -1;\n if (startPos == (forward ? view.state.doc.length : 0))\n return EditorSelection.cursor(startPos, start.assoc);\n let goal = start.goalColumn, startY;\n let rect = view.contentDOM.getBoundingClientRect();\n let startCoords = view.coordsAtPos(startPos), docTop = view.documentTop;\n if (startCoords) {\n if (goal == null)\n goal = startCoords.left - rect.left;\n startY = dir < 0 ? startCoords.top : startCoords.bottom;\n }\n else {\n let line = view.viewState.lineBlockAt(startPos);\n if (goal == null)\n goal = Math.min(rect.right - rect.left, view.defaultCharacterWidth * (startPos - line.from));\n startY = (dir < 0 ? line.top : line.bottom) + docTop;\n }\n let resolvedGoal = rect.left + goal;\n let dist = distance !== null && distance !== void 0 ? distance : (view.viewState.heightOracle.textHeight >> 1);\n for (let extra = 0;; extra += 10) {\n let curY = startY + (dist + extra) * dir;\n let pos = posAtCoords(view, { x: resolvedGoal, y: curY }, false, dir);\n if (curY < rect.top || curY > rect.bottom || (dir < 0 ? pos < startPos : pos > startPos))\n return EditorSelection.cursor(pos, start.assoc, undefined, goal);\n }\n}\nfunction skipAtomicRanges(atoms, pos, bias) {\n for (;;) {\n let moved = 0;\n for (let set of atoms) {\n set.between(pos - 1, pos + 1, (from, to, value) => {\n if (pos > from && pos < to) {\n let side = moved || bias || (pos - from < to - pos ? -1 : 1);\n pos = side < 0 ? from : to;\n moved = side;\n }\n });\n }\n if (!moved)\n return pos;\n }\n}\nfunction skipAtoms(view, oldPos, pos) {\n let newPos = skipAtomicRanges(view.state.facet(atomicRanges).map(f => f(view)), pos.from, oldPos.head > pos.from ? -1 : 1);\n return newPos == pos.from ? pos : EditorSelection.cursor(newPos, newPos < pos.from ? 1 : -1);\n}\n\n// This will also be where dragging info and such goes\nclass InputState {\n setSelectionOrigin(origin) {\n this.lastSelectionOrigin = origin;\n this.lastSelectionTime = Date.now();\n }\n constructor(view) {\n this.lastKeyCode = 0;\n this.lastKeyTime = 0;\n this.lastTouchTime = 0;\n this.lastFocusTime = 0;\n this.lastScrollTop = 0;\n this.lastScrollLeft = 0;\n this.chromeScrollHack = -1;\n // On iOS, some keys need to have their default behavior happen\n // (after which we retroactively handle them and reset the DOM) to\n // avoid messing up the virtual keyboard state.\n this.pendingIOSKey = undefined;\n this.lastSelectionOrigin = null;\n this.lastSelectionTime = 0;\n this.lastEscPress = 0;\n this.lastContextMenu = 0;\n this.scrollHandlers = [];\n this.registeredEvents = [];\n this.customHandlers = [];\n // -1 means not in a composition. Otherwise, this counts the number\n // of changes made during the composition. The count is used to\n // avoid treating the start state of the composition, before any\n // changes have been made, as part of the composition.\n this.composing = -1;\n // Tracks whether the next change should be marked as starting the\n // composition (null means no composition, true means next is the\n // first, false means first has already been marked for this\n // composition)\n this.compositionFirstChange = null;\n // End time of the previous composition\n this.compositionEndedAt = 0;\n // Used in a kludge to detect when an Enter keypress should be\n // considered part of the composition on Safari, which fires events\n // in the wrong order\n this.compositionPendingKey = false;\n // Used to categorize changes as part of a composition, even when\n // the mutation events fire shortly after the compositionend event\n this.compositionPendingChange = false;\n this.mouseSelection = null;\n let handleEvent = (handler, event) => {\n if (this.ignoreDuringComposition(event))\n return;\n if (event.type == \"keydown\" && this.keydown(view, event))\n return;\n if (this.mustFlushObserver(event))\n view.observer.forceFlush();\n if (this.runCustomHandlers(event.type, view, event))\n event.preventDefault();\n else\n handler(view, event);\n };\n for (let type in handlers) {\n let handler = handlers[type];\n view.contentDOM.addEventListener(type, event => {\n if (eventBelongsToEditor(view, event))\n handleEvent(handler, event);\n }, handlerOptions[type]);\n this.registeredEvents.push(type);\n }\n view.scrollDOM.addEventListener(\"mousedown\", (event) => {\n if (event.target == view.scrollDOM && event.clientY > view.contentDOM.getBoundingClientRect().bottom) {\n handleEvent(handlers.mousedown, event);\n if (!event.defaultPrevented && event.button == 2) {\n // Make sure the content covers the entire scroller height, in order\n // to catch a native context menu click below it\n let start = view.contentDOM.style.minHeight;\n view.contentDOM.style.minHeight = \"100%\";\n setTimeout(() => view.contentDOM.style.minHeight = start, 200);\n }\n }\n });\n view.scrollDOM.addEventListener(\"drop\", (event) => {\n if (event.target == view.scrollDOM && event.clientY > view.contentDOM.getBoundingClientRect().bottom)\n handleEvent(handlers.drop, event);\n });\n if (browser.chrome && browser.chrome_version == 102) { // FIXME remove at some point\n // On Chrome 102, viewport updates somehow stop wheel-based\n // scrolling. Turning off pointer events during the scroll seems\n // to avoid the issue.\n view.scrollDOM.addEventListener(\"wheel\", () => {\n if (this.chromeScrollHack < 0)\n view.contentDOM.style.pointerEvents = \"none\";\n else\n window.clearTimeout(this.chromeScrollHack);\n this.chromeScrollHack = setTimeout(() => {\n this.chromeScrollHack = -1;\n view.contentDOM.style.pointerEvents = \"\";\n }, 100);\n }, { passive: true });\n }\n this.notifiedFocused = view.hasFocus;\n // On Safari adding an input event handler somehow prevents an\n // issue where the composition vanishes when you press enter.\n if (browser.safari)\n view.contentDOM.addEventListener(\"input\", () => null);\n if (browser.gecko)\n firefoxCopyCutHack(view.contentDOM.ownerDocument);\n }\n ensureHandlers(view, plugins) {\n var _a;\n let handlers;\n this.customHandlers = [];\n for (let plugin of plugins)\n if (handlers = (_a = plugin.update(view).spec) === null || _a === void 0 ? void 0 : _a.domEventHandlers) {\n this.customHandlers.push({ plugin: plugin.value, handlers });\n for (let type in handlers)\n if (this.registeredEvents.indexOf(type) < 0 && type != \"scroll\") {\n this.registeredEvents.push(type);\n view.contentDOM.addEventListener(type, (event) => {\n if (!eventBelongsToEditor(view, event))\n return;\n if (this.runCustomHandlers(type, view, event))\n event.preventDefault();\n });\n }\n }\n }\n runCustomHandlers(type, view, event) {\n for (let set of this.customHandlers) {\n let handler = set.handlers[type];\n if (handler) {\n try {\n if (handler.call(set.plugin, event, view) || event.defaultPrevented)\n return true;\n }\n catch (e) {\n logException(view.state, e);\n }\n }\n }\n return false;\n }\n runScrollHandlers(view, event) {\n this.lastScrollTop = view.scrollDOM.scrollTop;\n this.lastScrollLeft = view.scrollDOM.scrollLeft;\n for (let set of this.customHandlers) {\n let handler = set.handlers.scroll;\n if (handler) {\n try {\n handler.call(set.plugin, event, view);\n }\n catch (e) {\n logException(view.state, e);\n }\n }\n }\n }\n keydown(view, event) {\n // Must always run, even if a custom handler handled the event\n this.lastKeyCode = event.keyCode;\n this.lastKeyTime = Date.now();\n if (event.keyCode == 9 && Date.now() < this.lastEscPress + 2000)\n return true;\n if (event.keyCode != 27 && modifierCodes.indexOf(event.keyCode) < 0)\n view.inputState.lastEscPress = 0;\n // Chrome for Android usually doesn't fire proper key events, but\n // occasionally does, usually surrounded by a bunch of complicated\n // composition changes. When an enter or backspace key event is\n // seen, hold off on handling DOM events for a bit, and then\n // dispatch it.\n if (browser.android && browser.chrome && !event.synthetic &&\n (event.keyCode == 13 || event.keyCode == 8)) {\n view.observer.delayAndroidKey(event.key, event.keyCode);\n return true;\n }\n // Prevent the default behavior of Enter on iOS makes the\n // virtual keyboard get stuck in the wrong (lowercase)\n // state. So we let it go through, and then, in\n // applyDOMChange, notify key handlers of it and reset to\n // the state they produce.\n let pending;\n if (browser.ios && !event.synthetic && !event.altKey && !event.metaKey &&\n ((pending = PendingKeys.find(key => key.keyCode == event.keyCode)) && !event.ctrlKey ||\n EmacsyPendingKeys.indexOf(event.key) > -1 && event.ctrlKey && !event.shiftKey)) {\n this.pendingIOSKey = pending || event;\n setTimeout(() => this.flushIOSKey(view), 250);\n return true;\n }\n return false;\n }\n flushIOSKey(view) {\n let key = this.pendingIOSKey;\n if (!key)\n return false;\n this.pendingIOSKey = undefined;\n return dispatchKey(view.contentDOM, key.key, key.keyCode);\n }\n ignoreDuringComposition(event) {\n if (!/^key/.test(event.type))\n return false;\n if (this.composing > 0)\n return true;\n // See https://www.stum.de/2016/06/24/handling-ime-events-in-javascript/.\n // On some input method editors (IMEs), the Enter key is used to\n // confirm character selection. On Safari, when Enter is pressed,\n // compositionend and keydown events are sometimes emitted in the\n // wrong order. The key event should still be ignored, even when\n // it happens after the compositionend event.\n if (browser.safari && !browser.ios && this.compositionPendingKey && Date.now() - this.compositionEndedAt < 100) {\n this.compositionPendingKey = false;\n return true;\n }\n return false;\n }\n mustFlushObserver(event) {\n return event.type == \"keydown\" && event.keyCode != 229;\n }\n startMouseSelection(mouseSelection) {\n if (this.mouseSelection)\n this.mouseSelection.destroy();\n this.mouseSelection = mouseSelection;\n }\n update(update) {\n if (this.mouseSelection)\n this.mouseSelection.update(update);\n if (update.transactions.length)\n this.lastKeyCode = this.lastSelectionTime = 0;\n }\n destroy() {\n if (this.mouseSelection)\n this.mouseSelection.destroy();\n }\n}\nconst PendingKeys = [\n { key: \"Backspace\", keyCode: 8, inputType: \"deleteContentBackward\" },\n { key: \"Enter\", keyCode: 13, inputType: \"insertParagraph\" },\n { key: \"Enter\", keyCode: 13, inputType: \"insertLineBreak\" },\n { key: \"Delete\", keyCode: 46, inputType: \"deleteContentForward\" }\n];\nconst EmacsyPendingKeys = \"dthko\";\n// Key codes for modifier keys\nconst modifierCodes = [16, 17, 18, 20, 91, 92, 224, 225];\nconst dragScrollMargin = 6;\nfunction dragScrollSpeed(dist) {\n return Math.max(0, dist) * 0.7 + 8;\n}\nfunction dist(a, b) {\n return Math.max(Math.abs(a.clientX - b.clientX), Math.abs(a.clientY - b.clientY));\n}\nclass MouseSelection {\n constructor(view, startEvent, style, mustSelect) {\n this.view = view;\n this.startEvent = startEvent;\n this.style = style;\n this.mustSelect = mustSelect;\n this.scrollSpeed = { x: 0, y: 0 };\n this.scrolling = -1;\n this.lastEvent = startEvent;\n this.scrollParent = scrollableParent(view.contentDOM);\n this.atoms = view.state.facet(atomicRanges).map(f => f(view));\n let doc = view.contentDOM.ownerDocument;\n doc.addEventListener(\"mousemove\", this.move = this.move.bind(this));\n doc.addEventListener(\"mouseup\", this.up = this.up.bind(this));\n this.extend = startEvent.shiftKey;\n this.multiple = view.state.facet(EditorState.allowMultipleSelections) && addsSelectionRange(view, startEvent);\n this.dragging = isInPrimarySelection(view, startEvent) && getClickType(startEvent) == 1 ? null : false;\n }\n start(event) {\n // When clicking outside of the selection, immediately apply the\n // effect of starting the selection\n if (this.dragging === false) {\n event.preventDefault();\n this.select(event);\n }\n }\n move(event) {\n var _a;\n if (event.buttons == 0)\n return this.destroy();\n if (this.dragging || this.dragging == null && dist(this.startEvent, event) < 10)\n return;\n this.select(this.lastEvent = event);\n let sx = 0, sy = 0;\n let rect = ((_a = this.scrollParent) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect())\n || { left: 0, top: 0, right: this.view.win.innerWidth, bottom: this.view.win.innerHeight };\n let margins = getScrollMargins(this.view);\n if (event.clientX - margins.left <= rect.left + dragScrollMargin)\n sx = -dragScrollSpeed(rect.left - event.clientX);\n else if (event.clientX + margins.right >= rect.right - dragScrollMargin)\n sx = dragScrollSpeed(event.clientX - rect.right);\n if (event.clientY - margins.top <= rect.top + dragScrollMargin)\n sy = -dragScrollSpeed(rect.top - event.clientY);\n else if (event.clientY + margins.bottom >= rect.bottom - dragScrollMargin)\n sy = dragScrollSpeed(event.clientY - rect.bottom);\n this.setScrollSpeed(sx, sy);\n }\n up(event) {\n if (this.dragging == null)\n this.select(this.lastEvent);\n if (!this.dragging)\n event.preventDefault();\n this.destroy();\n }\n destroy() {\n this.setScrollSpeed(0, 0);\n let doc = this.view.contentDOM.ownerDocument;\n doc.removeEventListener(\"mousemove\", this.move);\n doc.removeEventListener(\"mouseup\", this.up);\n this.view.inputState.mouseSelection = null;\n }\n setScrollSpeed(sx, sy) {\n this.scrollSpeed = { x: sx, y: sy };\n if (sx || sy) {\n if (this.scrolling < 0)\n this.scrolling = setInterval(() => this.scroll(), 50);\n }\n else if (this.scrolling > -1) {\n clearInterval(this.scrolling);\n this.scrolling = -1;\n }\n }\n scroll() {\n if (this.scrollParent) {\n this.scrollParent.scrollLeft += this.scrollSpeed.x;\n this.scrollParent.scrollTop += this.scrollSpeed.y;\n }\n else {\n this.view.win.scrollBy(this.scrollSpeed.x, this.scrollSpeed.y);\n }\n if (this.dragging === false)\n this.select(this.lastEvent);\n }\n skipAtoms(sel) {\n let ranges = null;\n for (let i = 0; i < sel.ranges.length; i++) {\n let range = sel.ranges[i], updated = null;\n if (range.empty) {\n let pos = skipAtomicRanges(this.atoms, range.from, 0);\n if (pos != range.from)\n updated = EditorSelection.cursor(pos, -1);\n }\n else {\n let from = skipAtomicRanges(this.atoms, range.from, -1);\n let to = skipAtomicRanges(this.atoms, range.to, 1);\n if (from != range.from || to != range.to)\n updated = EditorSelection.range(range.from == range.anchor ? from : to, range.from == range.head ? from : to);\n }\n if (updated) {\n if (!ranges)\n ranges = sel.ranges.slice();\n ranges[i] = updated;\n }\n }\n return ranges ? EditorSelection.create(ranges, sel.mainIndex) : sel;\n }\n select(event) {\n let { view } = this, selection = this.skipAtoms(this.style.get(event, this.extend, this.multiple));\n if (this.mustSelect || !selection.eq(view.state.selection) ||\n selection.main.assoc != view.state.selection.main.assoc && this.dragging === false)\n this.view.dispatch({\n selection,\n userEvent: \"select.pointer\"\n });\n this.mustSelect = false;\n }\n update(update) {\n if (update.docChanged && this.dragging)\n this.dragging = this.dragging.map(update.changes);\n if (this.style.update(update))\n setTimeout(() => this.select(this.lastEvent), 20);\n }\n}\nfunction addsSelectionRange(view, event) {\n let facet = view.state.facet(clickAddsSelectionRange);\n return facet.length ? facet[0](event) : browser.mac ? event.metaKey : event.ctrlKey;\n}\nfunction dragMovesSelection(view, event) {\n let facet = view.state.facet(dragMovesSelection$1);\n return facet.length ? facet[0](event) : browser.mac ? !event.altKey : !event.ctrlKey;\n}\nfunction isInPrimarySelection(view, event) {\n let { main } = view.state.selection;\n if (main.empty)\n return false;\n // On boundary clicks, check whether the coordinates are inside the\n // selection's client rectangles\n let sel = getSelection(view.root);\n if (!sel || sel.rangeCount == 0)\n return true;\n let rects = sel.getRangeAt(0).getClientRects();\n for (let i = 0; i < rects.length; i++) {\n let rect = rects[i];\n if (rect.left <= event.clientX && rect.right >= event.clientX &&\n rect.top <= event.clientY && rect.bottom >= event.clientY)\n return true;\n }\n return false;\n}\nfunction eventBelongsToEditor(view, event) {\n if (!event.bubbles)\n return true;\n if (event.defaultPrevented)\n return false;\n for (let node = event.target, cView; node != view.contentDOM; node = node.parentNode)\n if (!node || node.nodeType == 11 || ((cView = ContentView.get(node)) && cView.ignoreEvent(event)))\n return false;\n return true;\n}\nconst handlers = /*@__PURE__*/Object.create(null);\nconst handlerOptions = /*@__PURE__*/Object.create(null);\n// This is very crude, but unfortunately both these browsers _pretend_\n// that they have a clipboard API—all the objects and methods are\n// there, they just don't work, and they are hard to test.\nconst brokenClipboardAPI = (browser.ie && browser.ie_version < 15) ||\n (browser.ios && browser.webkit_version < 604);\nfunction capturePaste(view) {\n let parent = view.dom.parentNode;\n if (!parent)\n return;\n let target = parent.appendChild(document.createElement(\"textarea\"));\n target.style.cssText = \"position: fixed; left: -10000px; top: 10px\";\n target.focus();\n setTimeout(() => {\n view.focus();\n target.remove();\n doPaste(view, target.value);\n }, 50);\n}\nfunction doPaste(view, input) {\n let { state } = view, changes, i = 1, text = state.toText(input);\n let byLine = text.lines == state.selection.ranges.length;\n let linewise = lastLinewiseCopy != null && state.selection.ranges.every(r => r.empty) && lastLinewiseCopy == text.toString();\n if (linewise) {\n let lastLine = -1;\n changes = state.changeByRange(range => {\n let line = state.doc.lineAt(range.from);\n if (line.from == lastLine)\n return { range };\n lastLine = line.from;\n let insert = state.toText((byLine ? text.line(i++).text : input) + state.lineBreak);\n return { changes: { from: line.from, insert },\n range: EditorSelection.cursor(range.from + insert.length) };\n });\n }\n else if (byLine) {\n changes = state.changeByRange(range => {\n let line = text.line(i++);\n return { changes: { from: range.from, to: range.to, insert: line.text },\n range: EditorSelection.cursor(range.from + line.length) };\n });\n }\n else {\n changes = state.replaceSelection(text);\n }\n view.dispatch(changes, {\n userEvent: \"input.paste\",\n scrollIntoView: true\n });\n}\nhandlers.keydown = (view, event) => {\n view.inputState.setSelectionOrigin(\"select\");\n if (event.keyCode == 27)\n view.inputState.lastEscPress = Date.now();\n};\nhandlers.touchstart = (view, e) => {\n view.inputState.lastTouchTime = Date.now();\n view.inputState.setSelectionOrigin(\"select.pointer\");\n};\nhandlers.touchmove = view => {\n view.inputState.setSelectionOrigin(\"select.pointer\");\n};\nhandlerOptions.touchstart = handlerOptions.touchmove = { passive: true };\nhandlers.mousedown = (view, event) => {\n view.observer.flush();\n if (view.inputState.lastTouchTime > Date.now() - 2000)\n return; // Ignore touch interaction\n let style = null;\n for (let makeStyle of view.state.facet(mouseSelectionStyle)) {\n style = makeStyle(view, event);\n if (style)\n break;\n }\n if (!style && event.button == 0)\n style = basicMouseSelection(view, event);\n if (style) {\n let mustFocus = !view.hasFocus;\n view.inputState.startMouseSelection(new MouseSelection(view, event, style, mustFocus));\n if (mustFocus)\n view.observer.ignore(() => focusPreventScroll(view.contentDOM));\n if (view.inputState.mouseSelection)\n view.inputState.mouseSelection.start(event);\n }\n};\nfunction rangeForClick(view, pos, bias, type) {\n if (type == 1) { // Single click\n return EditorSelection.cursor(pos, bias);\n }\n else if (type == 2) { // Double click\n return groupAt(view.state, pos, bias);\n }\n else { // Triple click\n let visual = LineView.find(view.docView, pos), line = view.state.doc.lineAt(visual ? visual.posAtEnd : pos);\n let from = visual ? visual.posAtStart : line.from, to = visual ? visual.posAtEnd : line.to;\n if (to < view.state.doc.length && to == line.to)\n to++;\n return EditorSelection.range(from, to);\n }\n}\nlet insideY = (y, rect) => y >= rect.top && y <= rect.bottom;\nlet inside = (x, y, rect) => insideY(y, rect) && x >= rect.left && x <= rect.right;\n// Try to determine, for the given coordinates, associated with the\n// given position, whether they are related to the element before or\n// the element after the position.\nfunction findPositionSide(view, pos, x, y) {\n let line = LineView.find(view.docView, pos);\n if (!line)\n return 1;\n let off = pos - line.posAtStart;\n // Line boundaries point into the line\n if (off == 0)\n return 1;\n if (off == line.length)\n return -1;\n // Positions on top of an element point at that element\n let before = line.coordsAt(off, -1);\n if (before && inside(x, y, before))\n return -1;\n let after = line.coordsAt(off, 1);\n if (after && inside(x, y, after))\n return 1;\n // This is probably a line wrap point. Pick before if the point is\n // beside it.\n return before && insideY(y, before) ? -1 : 1;\n}\nfunction queryPos(view, event) {\n let pos = view.posAtCoords({ x: event.clientX, y: event.clientY }, false);\n return { pos, bias: findPositionSide(view, pos, event.clientX, event.clientY) };\n}\nconst BadMouseDetail = browser.ie && browser.ie_version <= 11;\nlet lastMouseDown = null, lastMouseDownCount = 0, lastMouseDownTime = 0;\nfunction getClickType(event) {\n if (!BadMouseDetail)\n return event.detail;\n let last = lastMouseDown, lastTime = lastMouseDownTime;\n lastMouseDown = event;\n lastMouseDownTime = Date.now();\n return lastMouseDownCount = !last || (lastTime > Date.now() - 400 && Math.abs(last.clientX - event.clientX) < 2 &&\n Math.abs(last.clientY - event.clientY) < 2) ? (lastMouseDownCount + 1) % 3 : 1;\n}\nfunction basicMouseSelection(view, event) {\n let start = queryPos(view, event), type = getClickType(event);\n let startSel = view.state.selection;\n return {\n update(update) {\n if (update.docChanged) {\n start.pos = update.changes.mapPos(start.pos);\n startSel = startSel.map(update.changes);\n }\n },\n get(event, extend, multiple) {\n let cur = queryPos(view, event), removed;\n let range = rangeForClick(view, cur.pos, cur.bias, type);\n if (start.pos != cur.pos && !extend) {\n let startRange = rangeForClick(view, start.pos, start.bias, type);\n let from = Math.min(startRange.from, range.from), to = Math.max(startRange.to, range.to);\n range = from < range.from ? EditorSelection.range(from, to) : EditorSelection.range(to, from);\n }\n if (extend)\n return startSel.replaceRange(startSel.main.extend(range.from, range.to));\n else if (multiple && type == 1 && startSel.ranges.length > 1 && (removed = removeRangeAround(startSel, cur.pos)))\n return removed;\n else if (multiple)\n return startSel.addRange(range);\n else\n return EditorSelection.create([range]);\n }\n };\n}\nfunction removeRangeAround(sel, pos) {\n for (let i = 0; i < sel.ranges.length; i++) {\n let { from, to } = sel.ranges[i];\n if (from <= pos && to >= pos)\n return EditorSelection.create(sel.ranges.slice(0, i).concat(sel.ranges.slice(i + 1)), sel.mainIndex == i ? 0 : sel.mainIndex - (sel.mainIndex > i ? 1 : 0));\n }\n return null;\n}\nhandlers.dragstart = (view, event) => {\n let { selection: { main } } = view.state;\n let { mouseSelection } = view.inputState;\n if (mouseSelection)\n mouseSelection.dragging = main;\n if (event.dataTransfer) {\n event.dataTransfer.setData(\"Text\", view.state.sliceDoc(main.from, main.to));\n event.dataTransfer.effectAllowed = \"copyMove\";\n }\n};\nfunction dropText(view, event, text, direct) {\n if (!text)\n return;\n let dropPos = view.posAtCoords({ x: event.clientX, y: event.clientY }, false);\n event.preventDefault();\n let { mouseSelection } = view.inputState;\n let del = direct && mouseSelection && mouseSelection.dragging && dragMovesSelection(view, event) ?\n { from: mouseSelection.dragging.from, to: mouseSelection.dragging.to } : null;\n let ins = { from: dropPos, insert: text };\n let changes = view.state.changes(del ? [del, ins] : ins);\n view.focus();\n view.dispatch({\n changes,\n selection: { anchor: changes.mapPos(dropPos, -1), head: changes.mapPos(dropPos, 1) },\n userEvent: del ? \"move.drop\" : \"input.drop\"\n });\n}\nhandlers.drop = (view, event) => {\n if (!event.dataTransfer)\n return;\n if (view.state.readOnly)\n return event.preventDefault();\n let files = event.dataTransfer.files;\n if (files && files.length) { // For a file drop, read the file's text.\n event.preventDefault();\n let text = Array(files.length), read = 0;\n let finishFile = () => {\n if (++read == files.length)\n dropText(view, event, text.filter(s => s != null).join(view.state.lineBreak), false);\n };\n for (let i = 0; i < files.length; i++) {\n let reader = new FileReader;\n reader.onerror = finishFile;\n reader.onload = () => {\n if (!/[\\x00-\\x08\\x0e-\\x1f]{2}/.test(reader.result))\n text[i] = reader.result;\n finishFile();\n };\n reader.readAsText(files[i]);\n }\n }\n else {\n dropText(view, event, event.dataTransfer.getData(\"Text\"), true);\n }\n};\nhandlers.paste = (view, event) => {\n if (view.state.readOnly)\n return event.preventDefault();\n view.observer.flush();\n let data = brokenClipboardAPI ? null : event.clipboardData;\n if (data) {\n doPaste(view, data.getData(\"text/plain\") || data.getData(\"text/uri-text\"));\n event.preventDefault();\n }\n else {\n capturePaste(view);\n }\n};\nfunction captureCopy(view, text) {\n // The extra wrapper is somehow necessary on IE/Edge to prevent the\n // content from being mangled when it is put onto the clipboard\n let parent = view.dom.parentNode;\n if (!parent)\n return;\n let target = parent.appendChild(document.createElement(\"textarea\"));\n target.style.cssText = \"position: fixed; left: -10000px; top: 10px\";\n target.value = text;\n target.focus();\n target.selectionEnd = text.length;\n target.selectionStart = 0;\n setTimeout(() => {\n target.remove();\n view.focus();\n }, 50);\n}\nfunction copiedRange(state) {\n let content = [], ranges = [], linewise = false;\n for (let range of state.selection.ranges)\n if (!range.empty) {\n content.push(state.sliceDoc(range.from, range.to));\n ranges.push(range);\n }\n if (!content.length) {\n // Nothing selected, do a line-wise copy\n let upto = -1;\n for (let { from } of state.selection.ranges) {\n let line = state.doc.lineAt(from);\n if (line.number > upto) {\n content.push(line.text);\n ranges.push({ from: line.from, to: Math.min(state.doc.length, line.to + 1) });\n }\n upto = line.number;\n }\n linewise = true;\n }\n return { text: content.join(state.lineBreak), ranges, linewise };\n}\nlet lastLinewiseCopy = null;\nhandlers.copy = handlers.cut = (view, event) => {\n let { text, ranges, linewise } = copiedRange(view.state);\n if (!text && !linewise)\n return;\n lastLinewiseCopy = linewise ? text : null;\n let data = brokenClipboardAPI ? null : event.clipboardData;\n if (data) {\n event.preventDefault();\n data.clearData();\n data.setData(\"text/plain\", text);\n }\n else {\n captureCopy(view, text);\n }\n if (event.type == \"cut\" && !view.state.readOnly)\n view.dispatch({\n changes: ranges,\n scrollIntoView: true,\n userEvent: \"delete.cut\"\n });\n};\nconst isFocusChange = /*@__PURE__*/Annotation.define();\nfunction focusChangeTransaction(state, focus) {\n let effects = [];\n for (let getEffect of state.facet(focusChangeEffect)) {\n let effect = getEffect(state, focus);\n if (effect)\n effects.push(effect);\n }\n return effects ? state.update({ effects, annotations: isFocusChange.of(true) }) : null;\n}\nfunction updateForFocusChange(view) {\n setTimeout(() => {\n let focus = view.hasFocus;\n if (focus != view.inputState.notifiedFocused) {\n let tr = focusChangeTransaction(view.state, focus);\n if (tr)\n view.dispatch(tr);\n else\n view.update([]);\n }\n }, 10);\n}\nhandlers.focus = view => {\n view.inputState.lastFocusTime = Date.now();\n // When focusing reset the scroll position, move it back to where it was\n if (!view.scrollDOM.scrollTop && (view.inputState.lastScrollTop || view.inputState.lastScrollLeft)) {\n view.scrollDOM.scrollTop = view.inputState.lastScrollTop;\n view.scrollDOM.scrollLeft = view.inputState.lastScrollLeft;\n }\n updateForFocusChange(view);\n};\nhandlers.blur = view => {\n view.observer.clearSelectionRange();\n updateForFocusChange(view);\n};\nhandlers.compositionstart = handlers.compositionupdate = view => {\n if (view.inputState.compositionFirstChange == null)\n view.inputState.compositionFirstChange = true;\n if (view.inputState.composing < 0) {\n // FIXME possibly set a timeout to clear it again on Android\n view.inputState.composing = 0;\n }\n};\nhandlers.compositionend = view => {\n view.inputState.composing = -1;\n view.inputState.compositionEndedAt = Date.now();\n view.inputState.compositionPendingKey = true;\n view.inputState.compositionPendingChange = view.observer.pendingRecords().length > 0;\n view.inputState.compositionFirstChange = null;\n if (browser.chrome && browser.android) {\n // Delay flushing for a bit on Android because it'll often fire a\n // bunch of contradictory changes in a row at end of compositon\n view.observer.flushSoon();\n }\n else if (view.inputState.compositionPendingChange) {\n // If we found pending records, schedule a flush.\n Promise.resolve().then(() => view.observer.flush());\n }\n else {\n // Otherwise, make sure that, if no changes come in soon, the\n // composition view is cleared.\n setTimeout(() => {\n if (view.inputState.composing < 0 && view.docView.hasComposition)\n view.update([]);\n }, 50);\n }\n};\nhandlers.contextmenu = view => {\n view.inputState.lastContextMenu = Date.now();\n};\nhandlers.beforeinput = (view, event) => {\n var _a;\n // Because Chrome Android doesn't fire useful key events, use\n // beforeinput to detect backspace (and possibly enter and delete,\n // but those usually don't even seem to fire beforeinput events at\n // the moment) and fake a key event for it.\n //\n // (preventDefault on beforeinput, though supported in the spec,\n // seems to do nothing at all on Chrome).\n let pending;\n if (browser.chrome && browser.android && (pending = PendingKeys.find(key => key.inputType == event.inputType))) {\n view.observer.delayAndroidKey(pending.key, pending.keyCode);\n if (pending.key == \"Backspace\" || pending.key == \"Delete\") {\n let startViewHeight = ((_a = window.visualViewport) === null || _a === void 0 ? void 0 : _a.height) || 0;\n setTimeout(() => {\n var _a;\n // Backspacing near uneditable nodes on Chrome Android sometimes\n // closes the virtual keyboard. This tries to crudely detect\n // that and refocus to get it back.\n if ((((_a = window.visualViewport) === null || _a === void 0 ? void 0 : _a.height) || 0) > startViewHeight + 10 && view.hasFocus) {\n view.contentDOM.blur();\n view.focus();\n }\n }, 100);\n }\n }\n};\nconst appliedFirefoxHack = /*@__PURE__*/new Set;\n// In Firefox, when cut/copy handlers are added to the document, that\n// somehow avoids a bug where those events aren't fired when the\n// selection is empty. See https://github.com/codemirror/dev/issues/1082\n// and https://bugzilla.mozilla.org/show_bug.cgi?id=995961\nfunction firefoxCopyCutHack(doc) {\n if (!appliedFirefoxHack.has(doc)) {\n appliedFirefoxHack.add(doc);\n doc.addEventListener(\"copy\", () => { });\n doc.addEventListener(\"cut\", () => { });\n }\n}\n\nconst wrappingWhiteSpace = [\"pre-wrap\", \"normal\", \"pre-line\", \"break-spaces\"];\nclass HeightOracle {\n constructor(lineWrapping) {\n this.lineWrapping = lineWrapping;\n this.doc = Text.empty;\n this.heightSamples = {};\n this.lineHeight = 14; // The height of an entire line (line-height)\n this.charWidth = 7;\n this.textHeight = 14; // The height of the actual font (font-size)\n this.lineLength = 30;\n // Used to track, during updateHeight, if any actual heights changed\n this.heightChanged = false;\n }\n heightForGap(from, to) {\n let lines = this.doc.lineAt(to).number - this.doc.lineAt(from).number + 1;\n if (this.lineWrapping)\n lines += Math.max(0, Math.ceil(((to - from) - (lines * this.lineLength * 0.5)) / this.lineLength));\n return this.lineHeight * lines;\n }\n heightForLine(length) {\n if (!this.lineWrapping)\n return this.lineHeight;\n let lines = 1 + Math.max(0, Math.ceil((length - this.lineLength) / (this.lineLength - 5)));\n return lines * this.lineHeight;\n }\n setDoc(doc) { this.doc = doc; return this; }\n mustRefreshForWrapping(whiteSpace) {\n return (wrappingWhiteSpace.indexOf(whiteSpace) > -1) != this.lineWrapping;\n }\n mustRefreshForHeights(lineHeights) {\n let newHeight = false;\n for (let i = 0; i < lineHeights.length; i++) {\n let h = lineHeights[i];\n if (h < 0) {\n i++;\n }\n else if (!this.heightSamples[Math.floor(h * 10)]) { // Round to .1 pixels\n newHeight = true;\n this.heightSamples[Math.floor(h * 10)] = true;\n }\n }\n return newHeight;\n }\n refresh(whiteSpace, lineHeight, charWidth, textHeight, lineLength, knownHeights) {\n let lineWrapping = wrappingWhiteSpace.indexOf(whiteSpace) > -1;\n let changed = Math.round(lineHeight) != Math.round(this.lineHeight) || this.lineWrapping != lineWrapping;\n this.lineWrapping = lineWrapping;\n this.lineHeight = lineHeight;\n this.charWidth = charWidth;\n this.textHeight = textHeight;\n this.lineLength = lineLength;\n if (changed) {\n this.heightSamples = {};\n for (let i = 0; i < knownHeights.length; i++) {\n let h = knownHeights[i];\n if (h < 0)\n i++;\n else\n this.heightSamples[Math.floor(h * 10)] = true;\n }\n }\n return changed;\n }\n}\n// This object is used by `updateHeight` to make DOM measurements\n// arrive at the right nides. The `heights` array is a sequence of\n// block heights, starting from position `from`.\nclass MeasuredHeights {\n constructor(from, heights) {\n this.from = from;\n this.heights = heights;\n this.index = 0;\n }\n get more() { return this.index < this.heights.length; }\n}\n/**\nRecord used to represent information about a block-level element\nin the editor view.\n*/\nclass BlockInfo {\n /**\n @internal\n */\n constructor(\n /**\n The start of the element in the document.\n */\n from, \n /**\n The length of the element.\n */\n length, \n /**\n The top position of the element (relative to the top of the\n document).\n */\n top, \n /**\n Its height.\n */\n height, \n /**\n @internal Weird packed field that holds an array of children\n for composite blocks, a decoration for block widgets, and a\n number indicating the amount of widget-create line breaks for\n text blocks.\n */\n _content) {\n this.from = from;\n this.length = length;\n this.top = top;\n this.height = height;\n this._content = _content;\n }\n /**\n The type of element this is. When querying lines, this may be\n an array of all the blocks that make up the line.\n */\n get type() {\n return typeof this._content == \"number\" ? BlockType.Text :\n Array.isArray(this._content) ? this._content : this._content.type;\n }\n /**\n The end of the element as a document position.\n */\n get to() { return this.from + this.length; }\n /**\n The bottom position of the element.\n */\n get bottom() { return this.top + this.height; }\n /**\n If this is a widget block, this will return the widget\n associated with it.\n */\n get widget() {\n return this._content instanceof PointDecoration ? this._content.widget : null;\n }\n /**\n If this is a textblock, this holds the number of line breaks\n that appear in widgets inside the block.\n */\n get widgetLineBreaks() {\n return typeof this._content == \"number\" ? this._content : 0;\n }\n /**\n @internal\n */\n join(other) {\n let content = (Array.isArray(this._content) ? this._content : [this])\n .concat(Array.isArray(other._content) ? other._content : [other]);\n return new BlockInfo(this.from, this.length + other.length, this.top, this.height + other.height, content);\n }\n}\nvar QueryType = /*@__PURE__*/(function (QueryType) {\n QueryType[QueryType[\"ByPos\"] = 0] = \"ByPos\";\n QueryType[QueryType[\"ByHeight\"] = 1] = \"ByHeight\";\n QueryType[QueryType[\"ByPosNoHeight\"] = 2] = \"ByPosNoHeight\";\nreturn QueryType})(QueryType || (QueryType = {}));\nconst Epsilon = 1e-3;\nclass HeightMap {\n constructor(length, // The number of characters covered\n height, // Height of this part of the document\n flags = 2 /* Flag.Outdated */) {\n this.length = length;\n this.height = height;\n this.flags = flags;\n }\n get outdated() { return (this.flags & 2 /* Flag.Outdated */) > 0; }\n set outdated(value) { this.flags = (value ? 2 /* Flag.Outdated */ : 0) | (this.flags & ~2 /* Flag.Outdated */); }\n setHeight(oracle, height) {\n if (this.height != height) {\n if (Math.abs(this.height - height) > Epsilon)\n oracle.heightChanged = true;\n this.height = height;\n }\n }\n // Base case is to replace a leaf node, which simply builds a tree\n // from the new nodes and returns that (HeightMapBranch and\n // HeightMapGap override this to actually use from/to)\n replace(_from, _to, nodes) {\n return HeightMap.of(nodes);\n }\n // Again, these are base cases, and are overridden for branch and gap nodes.\n decomposeLeft(_to, result) { result.push(this); }\n decomposeRight(_from, result) { result.push(this); }\n applyChanges(decorations, oldDoc, oracle, changes) {\n let me = this, doc = oracle.doc;\n for (let i = changes.length - 1; i >= 0; i--) {\n let { fromA, toA, fromB, toB } = changes[i];\n let start = me.lineAt(fromA, QueryType.ByPosNoHeight, oracle.setDoc(oldDoc), 0, 0);\n let end = start.to >= toA ? start : me.lineAt(toA, QueryType.ByPosNoHeight, oracle, 0, 0);\n toB += end.to - toA;\n toA = end.to;\n while (i > 0 && start.from <= changes[i - 1].toA) {\n fromA = changes[i - 1].fromA;\n fromB = changes[i - 1].fromB;\n i--;\n if (fromA < start.from)\n start = me.lineAt(fromA, QueryType.ByPosNoHeight, oracle, 0, 0);\n }\n fromB += start.from - fromA;\n fromA = start.from;\n let nodes = NodeBuilder.build(oracle.setDoc(doc), decorations, fromB, toB);\n me = me.replace(fromA, toA, nodes);\n }\n return me.updateHeight(oracle, 0);\n }\n static empty() { return new HeightMapText(0, 0); }\n // nodes uses null values to indicate the position of line breaks.\n // There are never line breaks at the start or end of the array, or\n // two line breaks next to each other, and the array isn't allowed\n // to be empty (same restrictions as return value from the builder).\n static of(nodes) {\n if (nodes.length == 1)\n return nodes[0];\n let i = 0, j = nodes.length, before = 0, after = 0;\n for (;;) {\n if (i == j) {\n if (before > after * 2) {\n let split = nodes[i - 1];\n if (split.break)\n nodes.splice(--i, 1, split.left, null, split.right);\n else\n nodes.splice(--i, 1, split.left, split.right);\n j += 1 + split.break;\n before -= split.size;\n }\n else if (after > before * 2) {\n let split = nodes[j];\n if (split.break)\n nodes.splice(j, 1, split.left, null, split.right);\n else\n nodes.splice(j, 1, split.left, split.right);\n j += 2 + split.break;\n after -= split.size;\n }\n else {\n break;\n }\n }\n else if (before < after) {\n let next = nodes[i++];\n if (next)\n before += next.size;\n }\n else {\n let next = nodes[--j];\n if (next)\n after += next.size;\n }\n }\n let brk = 0;\n if (nodes[i - 1] == null) {\n brk = 1;\n i--;\n }\n else if (nodes[i] == null) {\n brk = 1;\n j++;\n }\n return new HeightMapBranch(HeightMap.of(nodes.slice(0, i)), brk, HeightMap.of(nodes.slice(j)));\n }\n}\nHeightMap.prototype.size = 1;\nclass HeightMapBlock extends HeightMap {\n constructor(length, height, deco) {\n super(length, height);\n this.deco = deco;\n }\n blockAt(_height, _oracle, top, offset) {\n return new BlockInfo(offset, this.length, top, this.height, this.deco || 0);\n }\n lineAt(_value, _type, oracle, top, offset) {\n return this.blockAt(0, oracle, top, offset);\n }\n forEachLine(from, to, oracle, top, offset, f) {\n if (from <= offset + this.length && to >= offset)\n f(this.blockAt(0, oracle, top, offset));\n }\n updateHeight(oracle, offset = 0, _force = false, measured) {\n if (measured && measured.from <= offset && measured.more)\n this.setHeight(oracle, measured.heights[measured.index++]);\n this.outdated = false;\n return this;\n }\n toString() { return `block(${this.length})`; }\n}\nclass HeightMapText extends HeightMapBlock {\n constructor(length, height) {\n super(length, height, null);\n this.collapsed = 0; // Amount of collapsed content in the line\n this.widgetHeight = 0; // Maximum inline widget height\n this.breaks = 0; // Number of widget-introduced line breaks on the line\n }\n blockAt(_height, _oracle, top, offset) {\n return new BlockInfo(offset, this.length, top, this.height, this.breaks);\n }\n replace(_from, _to, nodes) {\n let node = nodes[0];\n if (nodes.length == 1 && (node instanceof HeightMapText || node instanceof HeightMapGap && (node.flags & 4 /* Flag.SingleLine */)) &&\n Math.abs(this.length - node.length) < 10) {\n if (node instanceof HeightMapGap)\n node = new HeightMapText(node.length, this.height);\n else\n node.height = this.height;\n if (!this.outdated)\n node.outdated = false;\n return node;\n }\n else {\n return HeightMap.of(nodes);\n }\n }\n updateHeight(oracle, offset = 0, force = false, measured) {\n if (measured && measured.from <= offset && measured.more)\n this.setHeight(oracle, measured.heights[measured.index++]);\n else if (force || this.outdated)\n this.setHeight(oracle, Math.max(this.widgetHeight, oracle.heightForLine(this.length - this.collapsed)) +\n this.breaks * oracle.lineHeight);\n this.outdated = false;\n return this;\n }\n toString() {\n return `line(${this.length}${this.collapsed ? -this.collapsed : \"\"}${this.widgetHeight ? \":\" + this.widgetHeight : \"\"})`;\n }\n}\nclass HeightMapGap extends HeightMap {\n constructor(length) { super(length, 0); }\n heightMetrics(oracle, offset) {\n let firstLine = oracle.doc.lineAt(offset).number, lastLine = oracle.doc.lineAt(offset + this.length).number;\n let lines = lastLine - firstLine + 1;\n let perLine, perChar = 0;\n if (oracle.lineWrapping) {\n let totalPerLine = Math.min(this.height, oracle.lineHeight * lines);\n perLine = totalPerLine / lines;\n if (this.length > lines + 1)\n perChar = (this.height - totalPerLine) / (this.length - lines - 1);\n }\n else {\n perLine = this.height / lines;\n }\n return { firstLine, lastLine, perLine, perChar };\n }\n blockAt(height, oracle, top, offset) {\n let { firstLine, lastLine, perLine, perChar } = this.heightMetrics(oracle, offset);\n if (oracle.lineWrapping) {\n let guess = offset + Math.round(Math.max(0, Math.min(1, (height - top) / this.height)) * this.length);\n let line = oracle.doc.lineAt(guess), lineHeight = perLine + line.length * perChar;\n let lineTop = Math.max(top, height - lineHeight / 2);\n return new BlockInfo(line.from, line.length, lineTop, lineHeight, 0);\n }\n else {\n let line = Math.max(0, Math.min(lastLine - firstLine, Math.floor((height - top) / perLine)));\n let { from, length } = oracle.doc.line(firstLine + line);\n return new BlockInfo(from, length, top + perLine * line, perLine, 0);\n }\n }\n lineAt(value, type, oracle, top, offset) {\n if (type == QueryType.ByHeight)\n return this.blockAt(value, oracle, top, offset);\n if (type == QueryType.ByPosNoHeight) {\n let { from, to } = oracle.doc.lineAt(value);\n return new BlockInfo(from, to - from, 0, 0, 0);\n }\n let { firstLine, perLine, perChar } = this.heightMetrics(oracle, offset);\n let line = oracle.doc.lineAt(value), lineHeight = perLine + line.length * perChar;\n let linesAbove = line.number - firstLine;\n let lineTop = top + perLine * linesAbove + perChar * (line.from - offset - linesAbove);\n return new BlockInfo(line.from, line.length, Math.max(top, Math.min(lineTop, top + this.height - lineHeight)), lineHeight, 0);\n }\n forEachLine(from, to, oracle, top, offset, f) {\n from = Math.max(from, offset);\n to = Math.min(to, offset + this.length);\n let { firstLine, perLine, perChar } = this.heightMetrics(oracle, offset);\n for (let pos = from, lineTop = top; pos <= to;) {\n let line = oracle.doc.lineAt(pos);\n if (pos == from) {\n let linesAbove = line.number - firstLine;\n lineTop += perLine * linesAbove + perChar * (from - offset - linesAbove);\n }\n let lineHeight = perLine + perChar * line.length;\n f(new BlockInfo(line.from, line.length, lineTop, lineHeight, 0));\n lineTop += lineHeight;\n pos = line.to + 1;\n }\n }\n replace(from, to, nodes) {\n let after = this.length - to;\n if (after > 0) {\n let last = nodes[nodes.length - 1];\n if (last instanceof HeightMapGap)\n nodes[nodes.length - 1] = new HeightMapGap(last.length + after);\n else\n nodes.push(null, new HeightMapGap(after - 1));\n }\n if (from > 0) {\n let first = nodes[0];\n if (first instanceof HeightMapGap)\n nodes[0] = new HeightMapGap(from + first.length);\n else\n nodes.unshift(new HeightMapGap(from - 1), null);\n }\n return HeightMap.of(nodes);\n }\n decomposeLeft(to, result) {\n result.push(new HeightMapGap(to - 1), null);\n }\n decomposeRight(from, result) {\n result.push(null, new HeightMapGap(this.length - from - 1));\n }\n updateHeight(oracle, offset = 0, force = false, measured) {\n let end = offset + this.length;\n if (measured && measured.from <= offset + this.length && measured.more) {\n // Fill in part of this gap with measured lines. We know there\n // can't be widgets or collapsed ranges in those lines, because\n // they would already have been added to the heightmap (gaps\n // only contain plain text).\n let nodes = [], pos = Math.max(offset, measured.from), singleHeight = -1;\n if (measured.from > offset)\n nodes.push(new HeightMapGap(measured.from - offset - 1).updateHeight(oracle, offset));\n while (pos <= end && measured.more) {\n let len = oracle.doc.lineAt(pos).length;\n if (nodes.length)\n nodes.push(null);\n let height = measured.heights[measured.index++];\n if (singleHeight == -1)\n singleHeight = height;\n else if (Math.abs(height - singleHeight) >= Epsilon)\n singleHeight = -2;\n let line = new HeightMapText(len, height);\n line.outdated = false;\n nodes.push(line);\n pos += len + 1;\n }\n if (pos <= end)\n nodes.push(null, new HeightMapGap(end - pos).updateHeight(oracle, pos));\n let result = HeightMap.of(nodes);\n if (singleHeight < 0 || Math.abs(result.height - this.height) >= Epsilon ||\n Math.abs(singleHeight - this.heightMetrics(oracle, offset).perLine) >= Epsilon)\n oracle.heightChanged = true;\n return result;\n }\n else if (force || this.outdated) {\n this.setHeight(oracle, oracle.heightForGap(offset, offset + this.length));\n this.outdated = false;\n }\n return this;\n }\n toString() { return `gap(${this.length})`; }\n}\nclass HeightMapBranch extends HeightMap {\n constructor(left, brk, right) {\n super(left.length + brk + right.length, left.height + right.height, brk | (left.outdated || right.outdated ? 2 /* Flag.Outdated */ : 0));\n this.left = left;\n this.right = right;\n this.size = left.size + right.size;\n }\n get break() { return this.flags & 1 /* Flag.Break */; }\n blockAt(height, oracle, top, offset) {\n let mid = top + this.left.height;\n return height < mid ? this.left.blockAt(height, oracle, top, offset)\n : this.right.blockAt(height, oracle, mid, offset + this.left.length + this.break);\n }\n lineAt(value, type, oracle, top, offset) {\n let rightTop = top + this.left.height, rightOffset = offset + this.left.length + this.break;\n let left = type == QueryType.ByHeight ? value < rightTop : value < rightOffset;\n let base = left ? this.left.lineAt(value, type, oracle, top, offset)\n : this.right.lineAt(value, type, oracle, rightTop, rightOffset);\n if (this.break || (left ? base.to < rightOffset : base.from > rightOffset))\n return base;\n let subQuery = type == QueryType.ByPosNoHeight ? QueryType.ByPosNoHeight : QueryType.ByPos;\n if (left)\n return base.join(this.right.lineAt(rightOffset, subQuery, oracle, rightTop, rightOffset));\n else\n return this.left.lineAt(rightOffset, subQuery, oracle, top, offset).join(base);\n }\n forEachLine(from, to, oracle, top, offset, f) {\n let rightTop = top + this.left.height, rightOffset = offset + this.left.length + this.break;\n if (this.break) {\n if (from < rightOffset)\n this.left.forEachLine(from, to, oracle, top, offset, f);\n if (to >= rightOffset)\n this.right.forEachLine(from, to, oracle, rightTop, rightOffset, f);\n }\n else {\n let mid = this.lineAt(rightOffset, QueryType.ByPos, oracle, top, offset);\n if (from < mid.from)\n this.left.forEachLine(from, mid.from - 1, oracle, top, offset, f);\n if (mid.to >= from && mid.from <= to)\n f(mid);\n if (to > mid.to)\n this.right.forEachLine(mid.to + 1, to, oracle, rightTop, rightOffset, f);\n }\n }\n replace(from, to, nodes) {\n let rightStart = this.left.length + this.break;\n if (to < rightStart)\n return this.balanced(this.left.replace(from, to, nodes), this.right);\n if (from > this.left.length)\n return this.balanced(this.left, this.right.replace(from - rightStart, to - rightStart, nodes));\n let result = [];\n if (from > 0)\n this.decomposeLeft(from, result);\n let left = result.length;\n for (let node of nodes)\n result.push(node);\n if (from > 0)\n mergeGaps(result, left - 1);\n if (to < this.length) {\n let right = result.length;\n this.decomposeRight(to, result);\n mergeGaps(result, right);\n }\n return HeightMap.of(result);\n }\n decomposeLeft(to, result) {\n let left = this.left.length;\n if (to <= left)\n return this.left.decomposeLeft(to, result);\n result.push(this.left);\n if (this.break) {\n left++;\n if (to >= left)\n result.push(null);\n }\n if (to > left)\n this.right.decomposeLeft(to - left, result);\n }\n decomposeRight(from, result) {\n let left = this.left.length, right = left + this.break;\n if (from >= right)\n return this.right.decomposeRight(from - right, result);\n if (from < left)\n this.left.decomposeRight(from, result);\n if (this.break && from < right)\n result.push(null);\n result.push(this.right);\n }\n balanced(left, right) {\n if (left.size > 2 * right.size || right.size > 2 * left.size)\n return HeightMap.of(this.break ? [left, null, right] : [left, right]);\n this.left = left;\n this.right = right;\n this.height = left.height + right.height;\n this.outdated = left.outdated || right.outdated;\n this.size = left.size + right.size;\n this.length = left.length + this.break + right.length;\n return this;\n }\n updateHeight(oracle, offset = 0, force = false, measured) {\n let { left, right } = this, rightStart = offset + left.length + this.break, rebalance = null;\n if (measured && measured.from <= offset + left.length && measured.more)\n rebalance = left = left.updateHeight(oracle, offset, force, measured);\n else\n left.updateHeight(oracle, offset, force);\n if (measured && measured.from <= rightStart + right.length && measured.more)\n rebalance = right = right.updateHeight(oracle, rightStart, force, measured);\n else\n right.updateHeight(oracle, rightStart, force);\n if (rebalance)\n return this.balanced(left, right);\n this.height = this.left.height + this.right.height;\n this.outdated = false;\n return this;\n }\n toString() { return this.left + (this.break ? \" \" : \"-\") + this.right; }\n}\nfunction mergeGaps(nodes, around) {\n let before, after;\n if (nodes[around] == null &&\n (before = nodes[around - 1]) instanceof HeightMapGap &&\n (after = nodes[around + 1]) instanceof HeightMapGap)\n nodes.splice(around - 1, 3, new HeightMapGap(before.length + 1 + after.length));\n}\nconst relevantWidgetHeight = 5;\nclass NodeBuilder {\n constructor(pos, oracle) {\n this.pos = pos;\n this.oracle = oracle;\n this.nodes = [];\n this.lineStart = -1;\n this.lineEnd = -1;\n this.covering = null;\n this.writtenTo = pos;\n }\n get isCovered() {\n return this.covering && this.nodes[this.nodes.length - 1] == this.covering;\n }\n span(_from, to) {\n if (this.lineStart > -1) {\n let end = Math.min(to, this.lineEnd), last = this.nodes[this.nodes.length - 1];\n if (last instanceof HeightMapText)\n last.length += end - this.pos;\n else if (end > this.pos || !this.isCovered)\n this.nodes.push(new HeightMapText(end - this.pos, -1));\n this.writtenTo = end;\n if (to > end) {\n this.nodes.push(null);\n this.writtenTo++;\n this.lineStart = -1;\n }\n }\n this.pos = to;\n }\n point(from, to, deco) {\n if (from < to || deco.heightRelevant) {\n let height = deco.widget ? deco.widget.estimatedHeight : 0;\n let breaks = deco.widget ? deco.widget.lineBreaks : 0;\n if (height < 0)\n height = this.oracle.lineHeight;\n let len = to - from;\n if (deco.block) {\n this.addBlock(new HeightMapBlock(len, height, deco));\n }\n else if (len || breaks || height >= relevantWidgetHeight) {\n this.addLineDeco(height, breaks, len);\n }\n }\n else if (to > from) {\n this.span(from, to);\n }\n if (this.lineEnd > -1 && this.lineEnd < this.pos)\n this.lineEnd = this.oracle.doc.lineAt(this.pos).to;\n }\n enterLine() {\n if (this.lineStart > -1)\n return;\n let { from, to } = this.oracle.doc.lineAt(this.pos);\n this.lineStart = from;\n this.lineEnd = to;\n if (this.writtenTo < from) {\n if (this.writtenTo < from - 1 || this.nodes[this.nodes.length - 1] == null)\n this.nodes.push(this.blankContent(this.writtenTo, from - 1));\n this.nodes.push(null);\n }\n if (this.pos > from)\n this.nodes.push(new HeightMapText(this.pos - from, -1));\n this.writtenTo = this.pos;\n }\n blankContent(from, to) {\n let gap = new HeightMapGap(to - from);\n if (this.oracle.doc.lineAt(from).to == to)\n gap.flags |= 4 /* Flag.SingleLine */;\n return gap;\n }\n ensureLine() {\n this.enterLine();\n let last = this.nodes.length ? this.nodes[this.nodes.length - 1] : null;\n if (last instanceof HeightMapText)\n return last;\n let line = new HeightMapText(0, -1);\n this.nodes.push(line);\n return line;\n }\n addBlock(block) {\n var _a;\n this.enterLine();\n let type = (_a = block.deco) === null || _a === void 0 ? void 0 : _a.type;\n if (type == BlockType.WidgetAfter && !this.isCovered)\n this.ensureLine();\n this.nodes.push(block);\n this.writtenTo = this.pos = this.pos + block.length;\n if (type != BlockType.WidgetBefore)\n this.covering = block;\n }\n addLineDeco(height, breaks, length) {\n let line = this.ensureLine();\n line.length += length;\n line.collapsed += length;\n line.widgetHeight = Math.max(line.widgetHeight, height);\n line.breaks += breaks;\n this.writtenTo = this.pos = this.pos + length;\n }\n finish(from) {\n let last = this.nodes.length == 0 ? null : this.nodes[this.nodes.length - 1];\n if (this.lineStart > -1 && !(last instanceof HeightMapText) && !this.isCovered)\n this.nodes.push(new HeightMapText(0, -1));\n else if (this.writtenTo < this.pos || last == null)\n this.nodes.push(this.blankContent(this.writtenTo, this.pos));\n let pos = from;\n for (let node of this.nodes) {\n if (node instanceof HeightMapText)\n node.updateHeight(this.oracle, pos);\n pos += node ? node.length : 1;\n }\n return this.nodes;\n }\n // Always called with a region that on both sides either stretches\n // to a line break or the end of the document.\n // The returned array uses null to indicate line breaks, but never\n // starts or ends in a line break, or has multiple line breaks next\n // to each other.\n static build(oracle, decorations, from, to) {\n let builder = new NodeBuilder(from, oracle);\n RangeSet.spans(decorations, from, to, builder, 0);\n return builder.finish(from);\n }\n}\nfunction heightRelevantDecoChanges(a, b, diff) {\n let comp = new DecorationComparator;\n RangeSet.compare(a, b, diff, comp, 0);\n return comp.changes;\n}\nclass DecorationComparator {\n constructor() {\n this.changes = [];\n }\n compareRange() { }\n comparePoint(from, to, a, b) {\n if (from < to || a && a.heightRelevant || b && b.heightRelevant)\n addRange(from, to, this.changes, 5);\n }\n}\n\nfunction visiblePixelRange(dom, paddingTop) {\n let rect = dom.getBoundingClientRect();\n let doc = dom.ownerDocument, win = doc.defaultView || window;\n let left = Math.max(0, rect.left), right = Math.min(win.innerWidth, rect.right);\n let top = Math.max(0, rect.top), bottom = Math.min(win.innerHeight, rect.bottom);\n for (let parent = dom.parentNode; parent && parent != doc.body;) {\n if (parent.nodeType == 1) {\n let elt = parent;\n let style = window.getComputedStyle(elt);\n if ((elt.scrollHeight > elt.clientHeight || elt.scrollWidth > elt.clientWidth) &&\n style.overflow != \"visible\") {\n let parentRect = elt.getBoundingClientRect();\n left = Math.max(left, parentRect.left);\n right = Math.min(right, parentRect.right);\n top = Math.max(top, parentRect.top);\n bottom = parent == dom.parentNode ? parentRect.bottom : Math.min(bottom, parentRect.bottom);\n }\n parent = style.position == \"absolute\" || style.position == \"fixed\" ? elt.offsetParent : elt.parentNode;\n }\n else if (parent.nodeType == 11) { // Shadow root\n parent = parent.host;\n }\n else {\n break;\n }\n }\n return { left: left - rect.left, right: Math.max(left, right) - rect.left,\n top: top - (rect.top + paddingTop), bottom: Math.max(top, bottom) - (rect.top + paddingTop) };\n}\nfunction fullPixelRange(dom, paddingTop) {\n let rect = dom.getBoundingClientRect();\n return { left: 0, right: rect.right - rect.left,\n top: paddingTop, bottom: rect.bottom - (rect.top + paddingTop) };\n}\n// Line gaps are placeholder widgets used to hide pieces of overlong\n// lines within the viewport, as a kludge to keep the editor\n// responsive when a ridiculously long line is loaded into it.\nclass LineGap {\n constructor(from, to, size) {\n this.from = from;\n this.to = to;\n this.size = size;\n }\n static same(a, b) {\n if (a.length != b.length)\n return false;\n for (let i = 0; i < a.length; i++) {\n let gA = a[i], gB = b[i];\n if (gA.from != gB.from || gA.to != gB.to || gA.size != gB.size)\n return false;\n }\n return true;\n }\n draw(viewState, wrapping) {\n return Decoration.replace({\n widget: new LineGapWidget(this.size * (wrapping ? viewState.scaleY : viewState.scaleX), wrapping)\n }).range(this.from, this.to);\n }\n}\nclass LineGapWidget extends WidgetType {\n constructor(size, vertical) {\n super();\n this.size = size;\n this.vertical = vertical;\n }\n eq(other) { return other.size == this.size && other.vertical == this.vertical; }\n toDOM() {\n let elt = document.createElement(\"div\");\n if (this.vertical) {\n elt.style.height = this.size + \"px\";\n }\n else {\n elt.style.width = this.size + \"px\";\n elt.style.height = \"2px\";\n elt.style.display = \"inline-block\";\n }\n return elt;\n }\n get estimatedHeight() { return this.vertical ? this.size : -1; }\n}\nclass ViewState {\n constructor(state) {\n this.state = state;\n // These are contentDOM-local coordinates\n this.pixelViewport = { left: 0, right: window.innerWidth, top: 0, bottom: 0 };\n this.inView = true;\n this.paddingTop = 0; // Padding above the document, scaled\n this.paddingBottom = 0; // Padding below the document, scaled\n this.contentDOMWidth = 0; // contentDOM.getBoundingClientRect().width\n this.contentDOMHeight = 0; // contentDOM.getBoundingClientRect().height\n this.editorHeight = 0; // scrollDOM.clientHeight, unscaled\n this.editorWidth = 0; // scrollDOM.clientWidth, unscaled\n this.scrollTop = 0; // Last seen scrollDOM.scrollTop, scaled\n this.scrolledToBottom = true;\n // The CSS-transformation scale of the editor (transformed size /\n // concrete size)\n this.scaleX = 1;\n this.scaleY = 1;\n // The vertical position (document-relative) to which to anchor the\n // scroll position. -1 means anchor to the end of the document.\n this.scrollAnchorPos = 0;\n // The height at the anchor position. Set by the DOM update phase.\n // -1 means no height available.\n this.scrollAnchorHeight = -1;\n // See VP.MaxDOMHeight\n this.scaler = IdScaler;\n this.scrollTarget = null;\n // Briefly set to true when printing, to disable viewport limiting\n this.printing = false;\n // Flag set when editor content was redrawn, so that the next\n // measure stage knows it must read DOM layout\n this.mustMeasureContent = true;\n this.defaultTextDirection = Direction.LTR;\n this.visibleRanges = [];\n // Cursor 'assoc' is only significant when the cursor is on a line\n // wrap point, where it must stick to the character that it is\n // associated with. Since browsers don't provide a reasonable\n // interface to set or query this, when a selection is set that\n // might cause this to be significant, this flag is set. The next\n // measure phase will check whether the cursor is on a line-wrapping\n // boundary and, if so, reset it to make sure it is positioned in\n // the right place.\n this.mustEnforceCursorAssoc = false;\n let guessWrapping = state.facet(contentAttributes).some(v => typeof v != \"function\" && v.class == \"cm-lineWrapping\");\n this.heightOracle = new HeightOracle(guessWrapping);\n this.stateDeco = state.facet(decorations).filter(d => typeof d != \"function\");\n this.heightMap = HeightMap.empty().applyChanges(this.stateDeco, Text.empty, this.heightOracle.setDoc(state.doc), [new ChangedRange(0, 0, 0, state.doc.length)]);\n this.viewport = this.getViewport(0, null);\n this.updateViewportLines();\n this.updateForViewport();\n this.lineGaps = this.ensureLineGaps([]);\n this.lineGapDeco = Decoration.set(this.lineGaps.map(gap => gap.draw(this, false)));\n this.computeVisibleRanges();\n }\n updateForViewport() {\n let viewports = [this.viewport], { main } = this.state.selection;\n for (let i = 0; i <= 1; i++) {\n let pos = i ? main.head : main.anchor;\n if (!viewports.some(({ from, to }) => pos >= from && pos <= to)) {\n let { from, to } = this.lineBlockAt(pos);\n viewports.push(new Viewport(from, to));\n }\n }\n this.viewports = viewports.sort((a, b) => a.from - b.from);\n this.scaler = this.heightMap.height <= 7000000 /* VP.MaxDOMHeight */ ? IdScaler :\n new BigScaler(this.heightOracle, this.heightMap, this.viewports);\n }\n updateViewportLines() {\n this.viewportLines = [];\n this.heightMap.forEachLine(this.viewport.from, this.viewport.to, this.heightOracle.setDoc(this.state.doc), 0, 0, block => {\n this.viewportLines.push(this.scaler.scale == 1 ? block : scaleBlock(block, this.scaler));\n });\n }\n update(update, scrollTarget = null) {\n this.state = update.state;\n let prevDeco = this.stateDeco;\n this.stateDeco = this.state.facet(decorations).filter(d => typeof d != \"function\");\n let contentChanges = update.changedRanges;\n let heightChanges = ChangedRange.extendWithRanges(contentChanges, heightRelevantDecoChanges(prevDeco, this.stateDeco, update ? update.changes : ChangeSet.empty(this.state.doc.length)));\n let prevHeight = this.heightMap.height;\n let scrollAnchor = this.scrolledToBottom ? null : this.scrollAnchorAt(this.scrollTop);\n this.heightMap = this.heightMap.applyChanges(this.stateDeco, update.startState.doc, this.heightOracle.setDoc(this.state.doc), heightChanges);\n if (this.heightMap.height != prevHeight)\n update.flags |= 2 /* UpdateFlag.Height */;\n if (scrollAnchor) {\n this.scrollAnchorPos = update.changes.mapPos(scrollAnchor.from, -1);\n this.scrollAnchorHeight = scrollAnchor.top;\n }\n else {\n this.scrollAnchorPos = -1;\n this.scrollAnchorHeight = this.heightMap.height;\n }\n let viewport = heightChanges.length ? this.mapViewport(this.viewport, update.changes) : this.viewport;\n if (scrollTarget && (scrollTarget.range.head < viewport.from || scrollTarget.range.head > viewport.to) ||\n !this.viewportIsAppropriate(viewport))\n viewport = this.getViewport(0, scrollTarget);\n let updateLines = !update.changes.empty || (update.flags & 2 /* UpdateFlag.Height */) ||\n viewport.from != this.viewport.from || viewport.to != this.viewport.to;\n this.viewport = viewport;\n this.updateForViewport();\n if (updateLines)\n this.updateViewportLines();\n if (this.lineGaps.length || this.viewport.to - this.viewport.from > (2000 /* LG.Margin */ << 1))\n this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps, update.changes)));\n update.flags |= this.computeVisibleRanges();\n if (scrollTarget)\n this.scrollTarget = scrollTarget;\n if (!this.mustEnforceCursorAssoc && update.selectionSet && update.view.lineWrapping &&\n update.state.selection.main.empty && update.state.selection.main.assoc &&\n !update.state.facet(nativeSelectionHidden))\n this.mustEnforceCursorAssoc = true;\n }\n measure(view) {\n let dom = view.contentDOM, style = window.getComputedStyle(dom);\n let oracle = this.heightOracle;\n let whiteSpace = style.whiteSpace;\n this.defaultTextDirection = style.direction == \"rtl\" ? Direction.RTL : Direction.LTR;\n let refresh = this.heightOracle.mustRefreshForWrapping(whiteSpace);\n let domRect = dom.getBoundingClientRect();\n let measureContent = refresh || this.mustMeasureContent || this.contentDOMHeight != domRect.height;\n this.contentDOMHeight = domRect.height;\n this.mustMeasureContent = false;\n let result = 0, bias = 0;\n if (domRect.width && domRect.height) {\n let scaleX = domRect.width / dom.offsetWidth;\n let scaleY = domRect.height / dom.offsetHeight;\n if (scaleX > 0.995 && scaleX < 1.005)\n scaleX = 1;\n if (scaleY > 0.995 && scaleY < 1.005)\n scaleY = 1;\n if (this.scaleX != scaleX || this.scaleY != scaleY) {\n this.scaleX = scaleX;\n this.scaleY = scaleY;\n result |= 8 /* UpdateFlag.Geometry */;\n refresh = measureContent = true;\n }\n }\n // Vertical padding\n let paddingTop = (parseInt(style.paddingTop) || 0) * this.scaleY;\n let paddingBottom = (parseInt(style.paddingBottom) || 0) * this.scaleY;\n if (this.paddingTop != paddingTop || this.paddingBottom != paddingBottom) {\n this.paddingTop = paddingTop;\n this.paddingBottom = paddingBottom;\n result |= 8 /* UpdateFlag.Geometry */ | 2 /* UpdateFlag.Height */;\n }\n if (this.editorWidth != view.scrollDOM.clientWidth) {\n if (oracle.lineWrapping)\n measureContent = true;\n this.editorWidth = view.scrollDOM.clientWidth;\n result |= 8 /* UpdateFlag.Geometry */;\n }\n let scrollTop = view.scrollDOM.scrollTop * this.scaleY;\n if (this.scrollTop != scrollTop) {\n this.scrollAnchorHeight = -1;\n this.scrollTop = scrollTop;\n }\n this.scrolledToBottom = isScrolledToBottom(view.scrollDOM);\n // Pixel viewport\n let pixelViewport = (this.printing ? fullPixelRange : visiblePixelRange)(dom, this.paddingTop);\n let dTop = pixelViewport.top - this.pixelViewport.top, dBottom = pixelViewport.bottom - this.pixelViewport.bottom;\n this.pixelViewport = pixelViewport;\n let inView = this.pixelViewport.bottom > this.pixelViewport.top && this.pixelViewport.right > this.pixelViewport.left;\n if (inView != this.inView) {\n this.inView = inView;\n if (inView)\n measureContent = true;\n }\n if (!this.inView && !this.scrollTarget)\n return 0;\n let contentWidth = domRect.width;\n if (this.contentDOMWidth != contentWidth || this.editorHeight != view.scrollDOM.clientHeight) {\n this.contentDOMWidth = domRect.width;\n this.editorHeight = view.scrollDOM.clientHeight;\n result |= 8 /* UpdateFlag.Geometry */;\n }\n if (measureContent) {\n let lineHeights = view.docView.measureVisibleLineHeights(this.viewport);\n if (oracle.mustRefreshForHeights(lineHeights))\n refresh = true;\n if (refresh || oracle.lineWrapping && Math.abs(contentWidth - this.contentDOMWidth) > oracle.charWidth) {\n let { lineHeight, charWidth, textHeight } = view.docView.measureTextSize();\n refresh = lineHeight > 0 && oracle.refresh(whiteSpace, lineHeight, charWidth, textHeight, contentWidth / charWidth, lineHeights);\n if (refresh) {\n view.docView.minWidth = 0;\n result |= 8 /* UpdateFlag.Geometry */;\n }\n }\n if (dTop > 0 && dBottom > 0)\n bias = Math.max(dTop, dBottom);\n else if (dTop < 0 && dBottom < 0)\n bias = Math.min(dTop, dBottom);\n oracle.heightChanged = false;\n for (let vp of this.viewports) {\n let heights = vp.from == this.viewport.from ? lineHeights : view.docView.measureVisibleLineHeights(vp);\n this.heightMap = (refresh ? HeightMap.empty().applyChanges(this.stateDeco, Text.empty, this.heightOracle, [new ChangedRange(0, 0, 0, view.state.doc.length)]) : this.heightMap).updateHeight(oracle, 0, refresh, new MeasuredHeights(vp.from, heights));\n }\n if (oracle.heightChanged)\n result |= 2 /* UpdateFlag.Height */;\n }\n let viewportChange = !this.viewportIsAppropriate(this.viewport, bias) ||\n this.scrollTarget && (this.scrollTarget.range.head < this.viewport.from ||\n this.scrollTarget.range.head > this.viewport.to);\n if (viewportChange)\n this.viewport = this.getViewport(bias, this.scrollTarget);\n this.updateForViewport();\n if ((result & 2 /* UpdateFlag.Height */) || viewportChange)\n this.updateViewportLines();\n if (this.lineGaps.length || this.viewport.to - this.viewport.from > (2000 /* LG.Margin */ << 1))\n this.updateLineGaps(this.ensureLineGaps(refresh ? [] : this.lineGaps, view));\n result |= this.computeVisibleRanges();\n if (this.mustEnforceCursorAssoc) {\n this.mustEnforceCursorAssoc = false;\n // This is done in the read stage, because moving the selection\n // to a line end is going to trigger a layout anyway, so it\n // can't be a pure write. It should be rare that it does any\n // writing.\n view.docView.enforceCursorAssoc();\n }\n return result;\n }\n get visibleTop() { return this.scaler.fromDOM(this.pixelViewport.top); }\n get visibleBottom() { return this.scaler.fromDOM(this.pixelViewport.bottom); }\n getViewport(bias, scrollTarget) {\n // This will divide VP.Margin between the top and the\n // bottom, depending on the bias (the change in viewport position\n // since the last update). It'll hold a number between 0 and 1\n let marginTop = 0.5 - Math.max(-0.5, Math.min(0.5, bias / 1000 /* VP.Margin */ / 2));\n let map = this.heightMap, oracle = this.heightOracle;\n let { visibleTop, visibleBottom } = this;\n let viewport = new Viewport(map.lineAt(visibleTop - marginTop * 1000 /* VP.Margin */, QueryType.ByHeight, oracle, 0, 0).from, map.lineAt(visibleBottom + (1 - marginTop) * 1000 /* VP.Margin */, QueryType.ByHeight, oracle, 0, 0).to);\n // If scrollTarget is given, make sure the viewport includes that position\n if (scrollTarget) {\n let { head } = scrollTarget.range;\n if (head < viewport.from || head > viewport.to) {\n let viewHeight = Math.min(this.editorHeight, this.pixelViewport.bottom - this.pixelViewport.top);\n let block = map.lineAt(head, QueryType.ByPos, oracle, 0, 0), topPos;\n if (scrollTarget.y == \"center\")\n topPos = (block.top + block.bottom) / 2 - viewHeight / 2;\n else if (scrollTarget.y == \"start\" || scrollTarget.y == \"nearest\" && head < viewport.from)\n topPos = block.top;\n else\n topPos = block.bottom - viewHeight;\n viewport = new Viewport(map.lineAt(topPos - 1000 /* VP.Margin */ / 2, QueryType.ByHeight, oracle, 0, 0).from, map.lineAt(topPos + viewHeight + 1000 /* VP.Margin */ / 2, QueryType.ByHeight, oracle, 0, 0).to);\n }\n }\n return viewport;\n }\n mapViewport(viewport, changes) {\n let from = changes.mapPos(viewport.from, -1), to = changes.mapPos(viewport.to, 1);\n return new Viewport(this.heightMap.lineAt(from, QueryType.ByPos, this.heightOracle, 0, 0).from, this.heightMap.lineAt(to, QueryType.ByPos, this.heightOracle, 0, 0).to);\n }\n // Checks if a given viewport covers the visible part of the\n // document and not too much beyond that.\n viewportIsAppropriate({ from, to }, bias = 0) {\n if (!this.inView)\n return true;\n let { top } = this.heightMap.lineAt(from, QueryType.ByPos, this.heightOracle, 0, 0);\n let { bottom } = this.heightMap.lineAt(to, QueryType.ByPos, this.heightOracle, 0, 0);\n let { visibleTop, visibleBottom } = this;\n return (from == 0 || top <= visibleTop - Math.max(10 /* VP.MinCoverMargin */, Math.min(-bias, 250 /* VP.MaxCoverMargin */))) &&\n (to == this.state.doc.length ||\n bottom >= visibleBottom + Math.max(10 /* VP.MinCoverMargin */, Math.min(bias, 250 /* VP.MaxCoverMargin */))) &&\n (top > visibleTop - 2 * 1000 /* VP.Margin */ && bottom < visibleBottom + 2 * 1000 /* VP.Margin */);\n }\n mapLineGaps(gaps, changes) {\n if (!gaps.length || changes.empty)\n return gaps;\n let mapped = [];\n for (let gap of gaps)\n if (!changes.touchesRange(gap.from, gap.to))\n mapped.push(new LineGap(changes.mapPos(gap.from), changes.mapPos(gap.to), gap.size));\n return mapped;\n }\n // Computes positions in the viewport where the start or end of a\n // line should be hidden, trying to reuse existing line gaps when\n // appropriate to avoid unneccesary redraws.\n // Uses crude character-counting for the positioning and sizing,\n // since actual DOM coordinates aren't always available and\n // predictable. Relies on generous margins (see LG.Margin) to hide\n // the artifacts this might produce from the user.\n ensureLineGaps(current, mayMeasure) {\n let wrapping = this.heightOracle.lineWrapping;\n let margin = wrapping ? 10000 /* LG.MarginWrap */ : 2000 /* LG.Margin */, halfMargin = margin >> 1, doubleMargin = margin << 1;\n // The non-wrapping logic won't work at all in predominantly right-to-left text.\n if (this.defaultTextDirection != Direction.LTR && !wrapping)\n return [];\n let gaps = [];\n let addGap = (from, to, line, structure) => {\n if (to - from < halfMargin)\n return;\n let sel = this.state.selection.main, avoid = [sel.from];\n if (!sel.empty)\n avoid.push(sel.to);\n for (let pos of avoid) {\n if (pos > from && pos < to) {\n addGap(from, pos - 10 /* LG.SelectionMargin */, line, structure);\n addGap(pos + 10 /* LG.SelectionMargin */, to, line, structure);\n return;\n }\n }\n let gap = find(current, gap => gap.from >= line.from && gap.to <= line.to &&\n Math.abs(gap.from - from) < halfMargin && Math.abs(gap.to - to) < halfMargin &&\n !avoid.some(pos => gap.from < pos && gap.to > pos));\n if (!gap) {\n // When scrolling down, snap gap ends to line starts to avoid shifts in wrapping\n if (to < line.to && mayMeasure && wrapping &&\n mayMeasure.visibleRanges.some(r => r.from <= to && r.to >= to)) {\n let lineStart = mayMeasure.moveToLineBoundary(EditorSelection.cursor(to), false, true).head;\n if (lineStart > from)\n to = lineStart;\n }\n gap = new LineGap(from, to, this.gapSize(line, from, to, structure));\n }\n gaps.push(gap);\n };\n for (let line of this.viewportLines) {\n if (line.length < doubleMargin)\n continue;\n let structure = lineStructure(line.from, line.to, this.stateDeco);\n if (structure.total < doubleMargin)\n continue;\n let target = this.scrollTarget ? this.scrollTarget.range.head : null;\n let viewFrom, viewTo;\n if (wrapping) {\n let marginHeight = (margin / this.heightOracle.lineLength) * this.heightOracle.lineHeight;\n let top, bot;\n if (target != null) {\n let targetFrac = findFraction(structure, target);\n let spaceFrac = ((this.visibleBottom - this.visibleTop) / 2 + marginHeight) / line.height;\n top = targetFrac - spaceFrac;\n bot = targetFrac + spaceFrac;\n }\n else {\n top = (this.visibleTop - line.top - marginHeight) / line.height;\n bot = (this.visibleBottom - line.top + marginHeight) / line.height;\n }\n viewFrom = findPosition(structure, top);\n viewTo = findPosition(structure, bot);\n }\n else {\n let totalWidth = structure.total * this.heightOracle.charWidth;\n let marginWidth = margin * this.heightOracle.charWidth;\n let left, right;\n if (target != null) {\n let targetFrac = findFraction(structure, target);\n let spaceFrac = ((this.pixelViewport.right - this.pixelViewport.left) / 2 + marginWidth) / totalWidth;\n left = targetFrac - spaceFrac;\n right = targetFrac + spaceFrac;\n }\n else {\n left = (this.pixelViewport.left - marginWidth) / totalWidth;\n right = (this.pixelViewport.right + marginWidth) / totalWidth;\n }\n viewFrom = findPosition(structure, left);\n viewTo = findPosition(structure, right);\n }\n if (viewFrom > line.from)\n addGap(line.from, viewFrom, line, structure);\n if (viewTo < line.to)\n addGap(viewTo, line.to, line, structure);\n }\n return gaps;\n }\n gapSize(line, from, to, structure) {\n let fraction = findFraction(structure, to) - findFraction(structure, from);\n if (this.heightOracle.lineWrapping) {\n return line.height * fraction;\n }\n else {\n return structure.total * this.heightOracle.charWidth * fraction;\n }\n }\n updateLineGaps(gaps) {\n if (!LineGap.same(gaps, this.lineGaps)) {\n this.lineGaps = gaps;\n this.lineGapDeco = Decoration.set(gaps.map(gap => gap.draw(this, this.heightOracle.lineWrapping)));\n }\n }\n computeVisibleRanges() {\n let deco = this.stateDeco;\n if (this.lineGaps.length)\n deco = deco.concat(this.lineGapDeco);\n let ranges = [];\n RangeSet.spans(deco, this.viewport.from, this.viewport.to, {\n span(from, to) { ranges.push({ from, to }); },\n point() { }\n }, 20);\n let changed = ranges.length != this.visibleRanges.length ||\n this.visibleRanges.some((r, i) => r.from != ranges[i].from || r.to != ranges[i].to);\n this.visibleRanges = ranges;\n return changed ? 4 /* UpdateFlag.Viewport */ : 0;\n }\n lineBlockAt(pos) {\n return (pos >= this.viewport.from && pos <= this.viewport.to && this.viewportLines.find(b => b.from <= pos && b.to >= pos)) ||\n scaleBlock(this.heightMap.lineAt(pos, QueryType.ByPos, this.heightOracle, 0, 0), this.scaler);\n }\n lineBlockAtHeight(height) {\n return scaleBlock(this.heightMap.lineAt(this.scaler.fromDOM(height), QueryType.ByHeight, this.heightOracle, 0, 0), this.scaler);\n }\n scrollAnchorAt(scrollTop) {\n let block = this.lineBlockAtHeight(scrollTop + 8);\n return block.from >= this.viewport.from || this.viewportLines[0].top - scrollTop > 200 ? block : this.viewportLines[0];\n }\n elementAtHeight(height) {\n return scaleBlock(this.heightMap.blockAt(this.scaler.fromDOM(height), this.heightOracle, 0, 0), this.scaler);\n }\n get docHeight() {\n return this.scaler.toDOM(this.heightMap.height);\n }\n get contentHeight() {\n return this.docHeight + this.paddingTop + this.paddingBottom;\n }\n}\nclass Viewport {\n constructor(from, to) {\n this.from = from;\n this.to = to;\n }\n}\nfunction lineStructure(from, to, stateDeco) {\n let ranges = [], pos = from, total = 0;\n RangeSet.spans(stateDeco, from, to, {\n span() { },\n point(from, to) {\n if (from > pos) {\n ranges.push({ from: pos, to: from });\n total += from - pos;\n }\n pos = to;\n }\n }, 20); // We're only interested in collapsed ranges of a significant size\n if (pos < to) {\n ranges.push({ from: pos, to });\n total += to - pos;\n }\n return { total, ranges };\n}\nfunction findPosition({ total, ranges }, ratio) {\n if (ratio <= 0)\n return ranges[0].from;\n if (ratio >= 1)\n return ranges[ranges.length - 1].to;\n let dist = Math.floor(total * ratio);\n for (let i = 0;; i++) {\n let { from, to } = ranges[i], size = to - from;\n if (dist <= size)\n return from + dist;\n dist -= size;\n }\n}\nfunction findFraction(structure, pos) {\n let counted = 0;\n for (let { from, to } of structure.ranges) {\n if (pos <= to) {\n counted += pos - from;\n break;\n }\n counted += to - from;\n }\n return counted / structure.total;\n}\nfunction find(array, f) {\n for (let val of array)\n if (f(val))\n return val;\n return undefined;\n}\n// Don't scale when the document height is within the range of what\n// the DOM can handle.\nconst IdScaler = {\n toDOM(n) { return n; },\n fromDOM(n) { return n; },\n scale: 1\n};\n// When the height is too big (> VP.MaxDOMHeight), scale down the\n// regions outside the viewports so that the total height is\n// VP.MaxDOMHeight.\nclass BigScaler {\n constructor(oracle, heightMap, viewports) {\n let vpHeight = 0, base = 0, domBase = 0;\n this.viewports = viewports.map(({ from, to }) => {\n let top = heightMap.lineAt(from, QueryType.ByPos, oracle, 0, 0).top;\n let bottom = heightMap.lineAt(to, QueryType.ByPos, oracle, 0, 0).bottom;\n vpHeight += bottom - top;\n return { from, to, top, bottom, domTop: 0, domBottom: 0 };\n });\n this.scale = (7000000 /* VP.MaxDOMHeight */ - vpHeight) / (heightMap.height - vpHeight);\n for (let obj of this.viewports) {\n obj.domTop = domBase + (obj.top - base) * this.scale;\n domBase = obj.domBottom = obj.domTop + (obj.bottom - obj.top);\n base = obj.bottom;\n }\n }\n toDOM(n) {\n for (let i = 0, base = 0, domBase = 0;; i++) {\n let vp = i < this.viewports.length ? this.viewports[i] : null;\n if (!vp || n < vp.top)\n return domBase + (n - base) * this.scale;\n if (n <= vp.bottom)\n return vp.domTop + (n - vp.top);\n base = vp.bottom;\n domBase = vp.domBottom;\n }\n }\n fromDOM(n) {\n for (let i = 0, base = 0, domBase = 0;; i++) {\n let vp = i < this.viewports.length ? this.viewports[i] : null;\n if (!vp || n < vp.domTop)\n return base + (n - domBase) / this.scale;\n if (n <= vp.domBottom)\n return vp.top + (n - vp.domTop);\n base = vp.bottom;\n domBase = vp.domBottom;\n }\n }\n}\nfunction scaleBlock(block, scaler) {\n if (scaler.scale == 1)\n return block;\n let bTop = scaler.toDOM(block.top), bBottom = scaler.toDOM(block.bottom);\n return new BlockInfo(block.from, block.length, bTop, bBottom - bTop, Array.isArray(block._content) ? block._content.map(b => scaleBlock(b, scaler)) : block._content);\n}\n\nconst theme = /*@__PURE__*/Facet.define({ combine: strs => strs.join(\" \") });\nconst darkTheme = /*@__PURE__*/Facet.define({ combine: values => values.indexOf(true) > -1 });\nconst baseThemeID = /*@__PURE__*/StyleModule.newName(), baseLightID = /*@__PURE__*/StyleModule.newName(), baseDarkID = /*@__PURE__*/StyleModule.newName();\nconst lightDarkIDs = { \"&light\": \".\" + baseLightID, \"&dark\": \".\" + baseDarkID };\nfunction buildTheme(main, spec, scopes) {\n return new StyleModule(spec, {\n finish(sel) {\n return /&/.test(sel) ? sel.replace(/&\\w*/, m => {\n if (m == \"&\")\n return main;\n if (!scopes || !scopes[m])\n throw new RangeError(`Unsupported selector: ${m}`);\n return scopes[m];\n }) : main + \" \" + sel;\n }\n });\n}\nconst baseTheme$1 = /*@__PURE__*/buildTheme(\".\" + baseThemeID, {\n \"&\": {\n position: \"relative !important\",\n boxSizing: \"border-box\",\n \"&.cm-focused\": {\n // Provide a simple default outline to make sure a focused\n // editor is visually distinct. Can't leave the default behavior\n // because that will apply to the content element, which is\n // inside the scrollable container and doesn't include the\n // gutters. We also can't use an 'auto' outline, since those\n // are, for some reason, drawn behind the element content, which\n // will cause things like the active line background to cover\n // the outline (#297).\n outline: \"1px dotted #212121\"\n },\n display: \"flex !important\",\n flexDirection: \"column\"\n },\n \".cm-scroller\": {\n display: \"flex !important\",\n alignItems: \"flex-start !important\",\n fontFamily: \"monospace\",\n lineHeight: 1.4,\n height: \"100%\",\n overflowX: \"auto\",\n position: \"relative\",\n zIndex: 0\n },\n \".cm-content\": {\n margin: 0,\n flexGrow: 2,\n flexShrink: 0,\n display: \"block\",\n whiteSpace: \"pre\",\n wordWrap: \"normal\",\n boxSizing: \"border-box\",\n padding: \"4px 0\",\n outline: \"none\",\n \"&[contenteditable=true]\": {\n WebkitUserModify: \"read-write-plaintext-only\",\n }\n },\n \".cm-lineWrapping\": {\n whiteSpace_fallback: \"pre-wrap\",\n whiteSpace: \"break-spaces\",\n wordBreak: \"break-word\",\n overflowWrap: \"anywhere\",\n flexShrink: 1\n },\n \"&light .cm-content\": { caretColor: \"black\" },\n \"&dark .cm-content\": { caretColor: \"white\" },\n \".cm-line\": {\n display: \"block\",\n padding: \"0 2px 0 6px\"\n },\n \".cm-layer\": {\n position: \"absolute\",\n left: 0,\n top: 0,\n contain: \"size style\",\n \"& > *\": {\n position: \"absolute\"\n }\n },\n \"&light .cm-selectionBackground\": {\n background: \"#d9d9d9\"\n },\n \"&dark .cm-selectionBackground\": {\n background: \"#222\"\n },\n \"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground\": {\n background: \"#d7d4f0\"\n },\n \"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground\": {\n background: \"#233\"\n },\n \".cm-cursorLayer\": {\n pointerEvents: \"none\"\n },\n \"&.cm-focused > .cm-scroller > .cm-cursorLayer\": {\n animation: \"steps(1) cm-blink 1.2s infinite\"\n },\n // Two animations defined so that we can switch between them to\n // restart the animation without forcing another style\n // recomputation.\n \"@keyframes cm-blink\": { \"0%\": {}, \"50%\": { opacity: 0 }, \"100%\": {} },\n \"@keyframes cm-blink2\": { \"0%\": {}, \"50%\": { opacity: 0 }, \"100%\": {} },\n \".cm-cursor, .cm-dropCursor\": {\n borderLeft: \"1.2px solid black\",\n marginLeft: \"-0.6px\",\n pointerEvents: \"none\",\n },\n \".cm-cursor\": {\n display: \"none\"\n },\n \"&dark .cm-cursor\": {\n borderLeftColor: \"#444\"\n },\n \".cm-dropCursor\": {\n position: \"absolute\"\n },\n \"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor\": {\n display: \"block\"\n },\n \"&light .cm-activeLine\": { backgroundColor: \"#cceeff44\" },\n \"&dark .cm-activeLine\": { backgroundColor: \"#99eeff33\" },\n \"&light .cm-specialChar\": { color: \"red\" },\n \"&dark .cm-specialChar\": { color: \"#f78\" },\n \".cm-gutters\": {\n flexShrink: 0,\n display: \"flex\",\n height: \"100%\",\n boxSizing: \"border-box\",\n insetInlineStart: 0,\n zIndex: 200\n },\n \"&light .cm-gutters\": {\n backgroundColor: \"#f5f5f5\",\n color: \"#6c6c6c\",\n borderRight: \"1px solid #ddd\"\n },\n \"&dark .cm-gutters\": {\n backgroundColor: \"#333338\",\n color: \"#ccc\"\n },\n \".cm-gutter\": {\n display: \"flex !important\",\n flexDirection: \"column\",\n flexShrink: 0,\n boxSizing: \"border-box\",\n minHeight: \"100%\",\n overflow: \"hidden\"\n },\n \".cm-gutterElement\": {\n boxSizing: \"border-box\"\n },\n \".cm-lineNumbers .cm-gutterElement\": {\n padding: \"0 3px 0 5px\",\n minWidth: \"20px\",\n textAlign: \"right\",\n whiteSpace: \"nowrap\"\n },\n \"&light .cm-activeLineGutter\": {\n backgroundColor: \"#e2f2ff\"\n },\n \"&dark .cm-activeLineGutter\": {\n backgroundColor: \"#222227\"\n },\n \".cm-panels\": {\n boxSizing: \"border-box\",\n position: \"sticky\",\n left: 0,\n right: 0\n },\n \"&light .cm-panels\": {\n backgroundColor: \"#f5f5f5\",\n color: \"black\"\n },\n \"&light .cm-panels-top\": {\n borderBottom: \"1px solid #ddd\"\n },\n \"&light .cm-panels-bottom\": {\n borderTop: \"1px solid #ddd\"\n },\n \"&dark .cm-panels\": {\n backgroundColor: \"#333338\",\n color: \"white\"\n },\n \".cm-tab\": {\n display: \"inline-block\",\n overflow: \"hidden\",\n verticalAlign: \"bottom\"\n },\n \".cm-widgetBuffer\": {\n verticalAlign: \"text-top\",\n height: \"1em\",\n width: 0,\n display: \"inline\"\n },\n \".cm-placeholder\": {\n color: \"#888\",\n display: \"inline-block\",\n verticalAlign: \"top\",\n },\n \".cm-highlightSpace:before\": {\n content: \"attr(data-display)\",\n position: \"absolute\",\n pointerEvents: \"none\",\n color: \"#888\"\n },\n \".cm-highlightTab\": {\n backgroundImage: `url('data:image/svg+xml,<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"200\" height=\"20\"><path stroke=\"%23888\" stroke-width=\"1\" fill=\"none\" d=\"M1 10H196L190 5M190 15L196 10M197 4L197 16\"/></svg>')`,\n backgroundSize: \"auto 100%\",\n backgroundPosition: \"right 90%\",\n backgroundRepeat: \"no-repeat\"\n },\n \".cm-trailingSpace\": {\n backgroundColor: \"#ff332255\"\n },\n \".cm-button\": {\n verticalAlign: \"middle\",\n color: \"inherit\",\n fontSize: \"70%\",\n padding: \".2em 1em\",\n borderRadius: \"1px\"\n },\n \"&light .cm-button\": {\n backgroundImage: \"linear-gradient(#eff1f5, #d9d9df)\",\n border: \"1px solid #888\",\n \"&:active\": {\n backgroundImage: \"linear-gradient(#b4b4b4, #d0d3d6)\"\n }\n },\n \"&dark .cm-button\": {\n backgroundImage: \"linear-gradient(#393939, #111)\",\n border: \"1px solid #888\",\n \"&:active\": {\n backgroundImage: \"linear-gradient(#111, #333)\"\n }\n },\n \".cm-textfield\": {\n verticalAlign: \"middle\",\n color: \"inherit\",\n fontSize: \"70%\",\n border: \"1px solid silver\",\n padding: \".2em .5em\"\n },\n \"&light .cm-textfield\": {\n backgroundColor: \"white\"\n },\n \"&dark .cm-textfield\": {\n border: \"1px solid #555\",\n backgroundColor: \"inherit\"\n }\n}, lightDarkIDs);\n\nconst LineBreakPlaceholder = \"\\uffff\";\nclass DOMReader {\n constructor(points, state) {\n this.points = points;\n this.text = \"\";\n this.lineSeparator = state.facet(EditorState.lineSeparator);\n }\n append(text) {\n this.text += text;\n }\n lineBreak() {\n this.text += LineBreakPlaceholder;\n }\n readRange(start, end) {\n if (!start)\n return this;\n let parent = start.parentNode;\n for (let cur = start;;) {\n this.findPointBefore(parent, cur);\n let oldLen = this.text.length;\n this.readNode(cur);\n let next = cur.nextSibling;\n if (next == end)\n break;\n let view = ContentView.get(cur), nextView = ContentView.get(next);\n if (view && nextView ? view.breakAfter :\n (view ? view.breakAfter : isBlockElement(cur)) ||\n (isBlockElement(next) && (cur.nodeName != \"BR\" || cur.cmIgnore) && this.text.length > oldLen))\n this.lineBreak();\n cur = next;\n }\n this.findPointBefore(parent, end);\n return this;\n }\n readTextNode(node) {\n let text = node.nodeValue;\n for (let point of this.points)\n if (point.node == node)\n point.pos = this.text.length + Math.min(point.offset, text.length);\n for (let off = 0, re = this.lineSeparator ? null : /\\r\\n?|\\n/g;;) {\n let nextBreak = -1, breakSize = 1, m;\n if (this.lineSeparator) {\n nextBreak = text.indexOf(this.lineSeparator, off);\n breakSize = this.lineSeparator.length;\n }\n else if (m = re.exec(text)) {\n nextBreak = m.index;\n breakSize = m[0].length;\n }\n this.append(text.slice(off, nextBreak < 0 ? text.length : nextBreak));\n if (nextBreak < 0)\n break;\n this.lineBreak();\n if (breakSize > 1)\n for (let point of this.points)\n if (point.node == node && point.pos > this.text.length)\n point.pos -= breakSize - 1;\n off = nextBreak + breakSize;\n }\n }\n readNode(node) {\n if (node.cmIgnore)\n return;\n let view = ContentView.get(node);\n let fromView = view && view.overrideDOMText;\n if (fromView != null) {\n this.findPointInside(node, fromView.length);\n for (let i = fromView.iter(); !i.next().done;) {\n if (i.lineBreak)\n this.lineBreak();\n else\n this.append(i.value);\n }\n }\n else if (node.nodeType == 3) {\n this.readTextNode(node);\n }\n else if (node.nodeName == \"BR\") {\n if (node.nextSibling)\n this.lineBreak();\n }\n else if (node.nodeType == 1) {\n this.readRange(node.firstChild, null);\n }\n }\n findPointBefore(node, next) {\n for (let point of this.points)\n if (point.node == node && node.childNodes[point.offset] == next)\n point.pos = this.text.length;\n }\n findPointInside(node, maxLen) {\n for (let point of this.points)\n if (node.nodeType == 3 ? point.node == node : node.contains(point.node))\n point.pos = this.text.length + Math.min(maxLen, point.offset);\n }\n}\nfunction isBlockElement(node) {\n return node.nodeType == 1 && /^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\\d|SECTION|PRE)$/.test(node.nodeName);\n}\nclass DOMPoint {\n constructor(node, offset) {\n this.node = node;\n this.offset = offset;\n this.pos = -1;\n }\n}\n\nclass DOMChange {\n constructor(view, start, end, typeOver) {\n this.typeOver = typeOver;\n this.bounds = null;\n this.text = \"\";\n let { impreciseHead: iHead, impreciseAnchor: iAnchor } = view.docView;\n if (view.state.readOnly && start > -1) {\n // Ignore changes when the editor is read-only\n this.newSel = null;\n }\n else if (start > -1 && (this.bounds = view.docView.domBoundsAround(start, end, 0))) {\n let selPoints = iHead || iAnchor ? [] : selectionPoints(view);\n let reader = new DOMReader(selPoints, view.state);\n reader.readRange(this.bounds.startDOM, this.bounds.endDOM);\n this.text = reader.text;\n this.newSel = selectionFromPoints(selPoints, this.bounds.from);\n }\n else {\n let domSel = view.observer.selectionRange;\n let head = iHead && iHead.node == domSel.focusNode && iHead.offset == domSel.focusOffset ||\n !contains(view.contentDOM, domSel.focusNode)\n ? view.state.selection.main.head\n : view.docView.posFromDOM(domSel.focusNode, domSel.focusOffset);\n let anchor = iAnchor && iAnchor.node == domSel.anchorNode && iAnchor.offset == domSel.anchorOffset ||\n !contains(view.contentDOM, domSel.anchorNode)\n ? view.state.selection.main.anchor\n : view.docView.posFromDOM(domSel.anchorNode, domSel.anchorOffset);\n this.newSel = EditorSelection.single(anchor, head);\n }\n }\n}\nfunction applyDOMChange(view, domChange) {\n let change;\n let { newSel } = domChange, sel = view.state.selection.main;\n let lastKey = view.inputState.lastKeyTime > Date.now() - 100 ? view.inputState.lastKeyCode : -1;\n if (domChange.bounds) {\n let { from, to } = domChange.bounds;\n let preferredPos = sel.from, preferredSide = null;\n // Prefer anchoring to end when Backspace is pressed (or, on\n // Android, when something was deleted)\n if (lastKey === 8 || browser.android && domChange.text.length < to - from) {\n preferredPos = sel.to;\n preferredSide = \"end\";\n }\n let diff = findDiff(view.state.doc.sliceString(from, to, LineBreakPlaceholder), domChange.text, preferredPos - from, preferredSide);\n if (diff) {\n // Chrome inserts two newlines when pressing shift-enter at the\n // end of a line. DomChange drops one of those.\n if (browser.chrome && lastKey == 13 &&\n diff.toB == diff.from + 2 && domChange.text.slice(diff.from, diff.toB) == LineBreakPlaceholder + LineBreakPlaceholder)\n diff.toB--;\n change = { from: from + diff.from, to: from + diff.toA,\n insert: Text.of(domChange.text.slice(diff.from, diff.toB).split(LineBreakPlaceholder)) };\n }\n }\n else if (newSel && (!view.hasFocus && view.state.facet(editable) || newSel.main.eq(sel))) {\n newSel = null;\n }\n if (!change && !newSel)\n return false;\n if (!change && domChange.typeOver && !sel.empty && newSel && newSel.main.empty) {\n // Heuristic to notice typing over a selected character\n change = { from: sel.from, to: sel.to, insert: view.state.doc.slice(sel.from, sel.to) };\n }\n else if (change && change.from >= sel.from && change.to <= sel.to &&\n (change.from != sel.from || change.to != sel.to) &&\n (sel.to - sel.from) - (change.to - change.from) <= 4) {\n // If the change is inside the selection and covers most of it,\n // assume it is a selection replace (with identical characters at\n // the start/end not included in the diff)\n change = {\n from: sel.from, to: sel.to,\n insert: view.state.doc.slice(sel.from, change.from).append(change.insert).append(view.state.doc.slice(change.to, sel.to))\n };\n }\n else if ((browser.mac || browser.android) && change && change.from == change.to && change.from == sel.head - 1 &&\n /^\\. ?$/.test(change.insert.toString()) && view.contentDOM.getAttribute(\"autocorrect\") == \"off\") {\n // Detect insert-period-on-double-space Mac and Android behavior,\n // and transform it into a regular space insert.\n if (newSel && change.insert.length == 2)\n newSel = EditorSelection.single(newSel.main.anchor - 1, newSel.main.head - 1);\n change = { from: sel.from, to: sel.to, insert: Text.of([\" \"]) };\n }\n else if (browser.chrome && change && change.from == change.to && change.from == sel.head &&\n change.insert.toString() == \"\\n \" && view.lineWrapping) {\n // In Chrome, if you insert a space at the start of a wrapped\n // line, it will actually insert a newline and a space, causing a\n // bogus new line to be created in CodeMirror (#968)\n if (newSel)\n newSel = EditorSelection.single(newSel.main.anchor - 1, newSel.main.head - 1);\n change = { from: sel.from, to: sel.to, insert: Text.of([\" \"]) };\n }\n if (change) {\n if (browser.ios && view.inputState.flushIOSKey(view))\n return true;\n // Android browsers don't fire reasonable key events for enter,\n // backspace, or delete. So this detects changes that look like\n // they're caused by those keys, and reinterprets them as key\n // events. (Some of these keys are also handled by beforeinput\n // events and the pendingAndroidKey mechanism, but that's not\n // reliable in all situations.)\n if (browser.android &&\n ((change.from == sel.from && change.to == sel.to &&\n change.insert.length == 1 && change.insert.lines == 2 &&\n dispatchKey(view.contentDOM, \"Enter\", 13)) ||\n ((change.from == sel.from - 1 && change.to == sel.to && change.insert.length == 0 ||\n lastKey == 8 && change.insert.length < change.to - change.from && change.to > sel.head) &&\n dispatchKey(view.contentDOM, \"Backspace\", 8)) ||\n (change.from == sel.from && change.to == sel.to + 1 && change.insert.length == 0 &&\n dispatchKey(view.contentDOM, \"Delete\", 46))))\n return true;\n let text = change.insert.toString();\n if (view.inputState.composing >= 0)\n view.inputState.composing++;\n let defaultTr;\n let defaultInsert = () => defaultTr || (defaultTr = applyDefaultInsert(view, change, newSel));\n if (!view.state.facet(inputHandler).some(h => h(view, change.from, change.to, text, defaultInsert)))\n view.dispatch(defaultInsert());\n return true;\n }\n else if (newSel && !newSel.main.eq(sel)) {\n let scrollIntoView = false, userEvent = \"select\";\n if (view.inputState.lastSelectionTime > Date.now() - 50) {\n if (view.inputState.lastSelectionOrigin == \"select\")\n scrollIntoView = true;\n userEvent = view.inputState.lastSelectionOrigin;\n }\n view.dispatch({ selection: newSel, scrollIntoView, userEvent });\n return true;\n }\n else {\n return false;\n }\n}\nfunction applyDefaultInsert(view, change, newSel) {\n let tr, startState = view.state, sel = startState.selection.main;\n if (change.from >= sel.from && change.to <= sel.to && change.to - change.from >= (sel.to - sel.from) / 3 &&\n (!newSel || newSel.main.empty && newSel.main.from == change.from + change.insert.length) &&\n view.inputState.composing < 0) {\n let before = sel.from < change.from ? startState.sliceDoc(sel.from, change.from) : \"\";\n let after = sel.to > change.to ? startState.sliceDoc(change.to, sel.to) : \"\";\n tr = startState.replaceSelection(view.state.toText(before + change.insert.sliceString(0, undefined, view.state.lineBreak) + after));\n }\n else {\n let changes = startState.changes(change);\n let mainSel = newSel && newSel.main.to <= changes.newLength ? newSel.main : undefined;\n // Try to apply a composition change to all cursors\n if (startState.selection.ranges.length > 1 && view.inputState.composing >= 0 &&\n change.to <= sel.to && change.to >= sel.to - 10) {\n let replaced = view.state.sliceDoc(change.from, change.to);\n let compositionRange, composition = newSel && findCompositionNode(view, newSel.main.head);\n if (composition) {\n let dLen = change.insert.length - (change.to - change.from);\n compositionRange = { from: composition.from, to: composition.to - dLen };\n }\n else {\n compositionRange = view.state.doc.lineAt(sel.head);\n }\n let offset = sel.to - change.to, size = sel.to - sel.from;\n tr = startState.changeByRange(range => {\n if (range.from == sel.from && range.to == sel.to)\n return { changes, range: mainSel || range.map(changes) };\n let to = range.to - offset, from = to - replaced.length;\n if (range.to - range.from != size || view.state.sliceDoc(from, to) != replaced ||\n // Unfortunately, there's no way to make multiple\n // changes in the same node work without aborting\n // composition, so cursors in the composition range are\n // ignored.\n range.to >= compositionRange.from && range.from <= compositionRange.to)\n return { range };\n let rangeChanges = startState.changes({ from, to, insert: change.insert }), selOff = range.to - sel.to;\n return {\n changes: rangeChanges,\n range: !mainSel ? range.map(rangeChanges) :\n EditorSelection.range(Math.max(0, mainSel.anchor + selOff), Math.max(0, mainSel.head + selOff))\n };\n });\n }\n else {\n tr = {\n changes,\n selection: mainSel && startState.selection.replaceRange(mainSel)\n };\n }\n }\n let userEvent = \"input.type\";\n if (view.composing ||\n view.inputState.compositionPendingChange && view.inputState.compositionEndedAt > Date.now() - 50) {\n view.inputState.compositionPendingChange = false;\n userEvent += \".compose\";\n if (view.inputState.compositionFirstChange) {\n userEvent += \".start\";\n view.inputState.compositionFirstChange = false;\n }\n }\n return startState.update(tr, { userEvent, scrollIntoView: true });\n}\nfunction findDiff(a, b, preferredPos, preferredSide) {\n let minLen = Math.min(a.length, b.length);\n let from = 0;\n while (from < minLen && a.charCodeAt(from) == b.charCodeAt(from))\n from++;\n if (from == minLen && a.length == b.length)\n return null;\n let toA = a.length, toB = b.length;\n while (toA > 0 && toB > 0 && a.charCodeAt(toA - 1) == b.charCodeAt(toB - 1)) {\n toA--;\n toB--;\n }\n if (preferredSide == \"end\") {\n let adjust = Math.max(0, from - Math.min(toA, toB));\n preferredPos -= toA + adjust - from;\n }\n if (toA < from && a.length < b.length) {\n let move = preferredPos <= from && preferredPos >= toA ? from - preferredPos : 0;\n from -= move;\n toB = from + (toB - toA);\n toA = from;\n }\n else if (toB < from) {\n let move = preferredPos <= from && preferredPos >= toB ? from - preferredPos : 0;\n from -= move;\n toA = from + (toA - toB);\n toB = from;\n }\n return { from, toA, toB };\n}\nfunction selectionPoints(view) {\n let result = [];\n if (view.root.activeElement != view.contentDOM)\n return result;\n let { anchorNode, anchorOffset, focusNode, focusOffset } = view.observer.selectionRange;\n if (anchorNode) {\n result.push(new DOMPoint(anchorNode, anchorOffset));\n if (focusNode != anchorNode || focusOffset != anchorOffset)\n result.push(new DOMPoint(focusNode, focusOffset));\n }\n return result;\n}\nfunction selectionFromPoints(points, base) {\n if (points.length == 0)\n return null;\n let anchor = points[0].pos, head = points.length == 2 ? points[1].pos : anchor;\n return anchor > -1 && head > -1 ? EditorSelection.single(anchor + base, head + base) : null;\n}\n\nconst observeOptions = {\n childList: true,\n characterData: true,\n subtree: true,\n attributes: true,\n characterDataOldValue: true\n};\n// IE11 has very broken mutation observers, so we also listen to\n// DOMCharacterDataModified there\nconst useCharData = browser.ie && browser.ie_version <= 11;\nclass DOMObserver {\n constructor(view) {\n this.view = view;\n this.active = false;\n // The known selection. Kept in our own object, as opposed to just\n // directly accessing the selection because:\n // - Safari doesn't report the right selection in shadow DOM\n // - Reading from the selection forces a DOM layout\n // - This way, we can ignore selectionchange events if we have\n // already seen the 'new' selection\n this.selectionRange = new DOMSelectionState;\n // Set when a selection change is detected, cleared on flush\n this.selectionChanged = false;\n this.delayedFlush = -1;\n this.resizeTimeout = -1;\n this.queue = [];\n this.delayedAndroidKey = null;\n this.flushingAndroidKey = -1;\n this.lastChange = 0;\n this.scrollTargets = [];\n this.intersection = null;\n this.resizeScroll = null;\n this.resizeContent = null;\n this.intersecting = false;\n this.gapIntersection = null;\n this.gaps = [];\n // Timeout for scheduling check of the parents that need scroll handlers\n this.parentCheck = -1;\n this.dom = view.contentDOM;\n this.observer = new MutationObserver(mutations => {\n for (let mut of mutations)\n this.queue.push(mut);\n // IE11 will sometimes (on typing over a selection or\n // backspacing out a single character text node) call the\n // observer callback before actually updating the DOM.\n //\n // Unrelatedly, iOS Safari will, when ending a composition,\n // sometimes first clear it, deliver the mutations, and then\n // reinsert the finished text. CodeMirror's handling of the\n // deletion will prevent the reinsertion from happening,\n // breaking composition.\n if ((browser.ie && browser.ie_version <= 11 || browser.ios && view.composing) &&\n mutations.some(m => m.type == \"childList\" && m.removedNodes.length ||\n m.type == \"characterData\" && m.oldValue.length > m.target.nodeValue.length))\n this.flushSoon();\n else\n this.flush();\n });\n if (useCharData)\n this.onCharData = (event) => {\n this.queue.push({ target: event.target,\n type: \"characterData\",\n oldValue: event.prevValue });\n this.flushSoon();\n };\n this.onSelectionChange = this.onSelectionChange.bind(this);\n this.onResize = this.onResize.bind(this);\n this.onPrint = this.onPrint.bind(this);\n this.onScroll = this.onScroll.bind(this);\n if (typeof ResizeObserver == \"function\") {\n this.resizeScroll = new ResizeObserver(() => {\n var _a;\n if (((_a = this.view.docView) === null || _a === void 0 ? void 0 : _a.lastUpdate) < Date.now() - 75)\n this.onResize();\n });\n this.resizeScroll.observe(view.scrollDOM);\n this.resizeContent = new ResizeObserver(() => this.view.requestMeasure());\n this.resizeContent.observe(view.contentDOM);\n }\n this.addWindowListeners(this.win = view.win);\n this.start();\n if (typeof IntersectionObserver == \"function\") {\n this.intersection = new IntersectionObserver(entries => {\n if (this.parentCheck < 0)\n this.parentCheck = setTimeout(this.listenForScroll.bind(this), 1000);\n if (entries.length > 0 && (entries[entries.length - 1].intersectionRatio > 0) != this.intersecting) {\n this.intersecting = !this.intersecting;\n if (this.intersecting != this.view.inView)\n this.onScrollChanged(document.createEvent(\"Event\"));\n }\n }, { threshold: [0, .001] });\n this.intersection.observe(this.dom);\n this.gapIntersection = new IntersectionObserver(entries => {\n if (entries.length > 0 && entries[entries.length - 1].intersectionRatio > 0)\n this.onScrollChanged(document.createEvent(\"Event\"));\n }, {});\n }\n this.listenForScroll();\n this.readSelectionRange();\n }\n onScrollChanged(e) {\n this.view.inputState.runScrollHandlers(this.view, e);\n if (this.intersecting)\n this.view.measure();\n }\n onScroll(e) {\n if (this.intersecting)\n this.flush(false);\n this.onScrollChanged(e);\n }\n onResize() {\n if (this.resizeTimeout < 0)\n this.resizeTimeout = setTimeout(() => {\n this.resizeTimeout = -1;\n this.view.requestMeasure();\n }, 50);\n }\n onPrint() {\n this.view.viewState.printing = true;\n this.view.measure();\n setTimeout(() => {\n this.view.viewState.printing = false;\n this.view.requestMeasure();\n }, 500);\n }\n updateGaps(gaps) {\n if (this.gapIntersection && (gaps.length != this.gaps.length || this.gaps.some((g, i) => g != gaps[i]))) {\n this.gapIntersection.disconnect();\n for (let gap of gaps)\n this.gapIntersection.observe(gap);\n this.gaps = gaps;\n }\n }\n onSelectionChange(event) {\n let wasChanged = this.selectionChanged;\n if (!this.readSelectionRange() || this.delayedAndroidKey)\n return;\n let { view } = this, sel = this.selectionRange;\n if (view.state.facet(editable) ? view.root.activeElement != this.dom : !hasSelection(view.dom, sel))\n return;\n let context = sel.anchorNode && view.docView.nearest(sel.anchorNode);\n if (context && context.ignoreEvent(event)) {\n if (!wasChanged)\n this.selectionChanged = false;\n return;\n }\n // Deletions on IE11 fire their events in the wrong order, giving\n // us a selection change event before the DOM changes are\n // reported.\n // Chrome Android has a similar issue when backspacing out a\n // selection (#645).\n if ((browser.ie && browser.ie_version <= 11 || browser.android && browser.chrome) && !view.state.selection.main.empty &&\n // (Selection.isCollapsed isn't reliable on IE)\n sel.focusNode && isEquivalentPosition(sel.focusNode, sel.focusOffset, sel.anchorNode, sel.anchorOffset))\n this.flushSoon();\n else\n this.flush(false);\n }\n readSelectionRange() {\n let { view } = this;\n // The Selection object is broken in shadow roots in Safari. See\n // https://github.com/codemirror/dev/issues/414\n let range = browser.safari && view.root.nodeType == 11 &&\n deepActiveElement(this.dom.ownerDocument) == this.dom &&\n safariSelectionRangeHack(this.view) || getSelection(view.root);\n if (!range || this.selectionRange.eq(range))\n return false;\n let local = hasSelection(this.dom, range);\n // Detect the situation where the browser has, on focus, moved the\n // selection to the start of the content element. Reset it to the\n // position from the editor state.\n if (local && !this.selectionChanged &&\n view.inputState.lastFocusTime > Date.now() - 200 &&\n view.inputState.lastTouchTime < Date.now() - 300 &&\n atElementStart(this.dom, range)) {\n this.view.inputState.lastFocusTime = 0;\n view.docView.updateSelection();\n return false;\n }\n this.selectionRange.setRange(range);\n if (local)\n this.selectionChanged = true;\n return true;\n }\n setSelectionRange(anchor, head) {\n this.selectionRange.set(anchor.node, anchor.offset, head.node, head.offset);\n this.selectionChanged = false;\n }\n clearSelectionRange() {\n this.selectionRange.set(null, 0, null, 0);\n }\n listenForScroll() {\n this.parentCheck = -1;\n let i = 0, changed = null;\n for (let dom = this.dom; dom;) {\n if (dom.nodeType == 1) {\n if (!changed && i < this.scrollTargets.length && this.scrollTargets[i] == dom)\n i++;\n else if (!changed)\n changed = this.scrollTargets.slice(0, i);\n if (changed)\n changed.push(dom);\n dom = dom.assignedSlot || dom.parentNode;\n }\n else if (dom.nodeType == 11) { // Shadow root\n dom = dom.host;\n }\n else {\n break;\n }\n }\n if (i < this.scrollTargets.length && !changed)\n changed = this.scrollTargets.slice(0, i);\n if (changed) {\n for (let dom of this.scrollTargets)\n dom.removeEventListener(\"scroll\", this.onScroll);\n for (let dom of this.scrollTargets = changed)\n dom.addEventListener(\"scroll\", this.onScroll);\n }\n }\n ignore(f) {\n if (!this.active)\n return f();\n try {\n this.stop();\n return f();\n }\n finally {\n this.start();\n this.clear();\n }\n }\n start() {\n if (this.active)\n return;\n this.observer.observe(this.dom, observeOptions);\n if (useCharData)\n this.dom.addEventListener(\"DOMCharacterDataModified\", this.onCharData);\n this.active = true;\n }\n stop() {\n if (!this.active)\n return;\n this.active = false;\n this.observer.disconnect();\n if (useCharData)\n this.dom.removeEventListener(\"DOMCharacterDataModified\", this.onCharData);\n }\n // Throw away any pending changes\n clear() {\n this.processRecords();\n this.queue.length = 0;\n this.selectionChanged = false;\n }\n // Chrome Android, especially in combination with GBoard, not only\n // doesn't reliably fire regular key events, but also often\n // surrounds the effect of enter or backspace with a bunch of\n // composition events that, when interrupted, cause text duplication\n // or other kinds of corruption. This hack makes the editor back off\n // from handling DOM changes for a moment when such a key is\n // detected (via beforeinput or keydown), and then tries to flush\n // them or, if that has no effect, dispatches the given key.\n delayAndroidKey(key, keyCode) {\n var _a;\n if (!this.delayedAndroidKey) {\n let flush = () => {\n let key = this.delayedAndroidKey;\n if (key) {\n this.clearDelayedAndroidKey();\n this.view.inputState.lastKeyCode = key.keyCode;\n this.view.inputState.lastKeyTime = Date.now();\n let flushed = this.flush();\n if (!flushed && key.force)\n dispatchKey(this.dom, key.key, key.keyCode);\n }\n };\n this.flushingAndroidKey = this.view.win.requestAnimationFrame(flush);\n }\n // Since backspace beforeinput is sometimes signalled spuriously,\n // Enter always takes precedence.\n if (!this.delayedAndroidKey || key == \"Enter\")\n this.delayedAndroidKey = {\n key, keyCode,\n // Only run the key handler when no changes are detected if\n // this isn't coming right after another change, in which case\n // it is probably part of a weird chain of updates, and should\n // be ignored if it returns the DOM to its previous state.\n force: this.lastChange < Date.now() - 50 || !!((_a = this.delayedAndroidKey) === null || _a === void 0 ? void 0 : _a.force)\n };\n }\n clearDelayedAndroidKey() {\n this.win.cancelAnimationFrame(this.flushingAndroidKey);\n this.delayedAndroidKey = null;\n this.flushingAndroidKey = -1;\n }\n flushSoon() {\n if (this.delayedFlush < 0)\n this.delayedFlush = this.view.win.requestAnimationFrame(() => { this.delayedFlush = -1; this.flush(); });\n }\n forceFlush() {\n if (this.delayedFlush >= 0) {\n this.view.win.cancelAnimationFrame(this.delayedFlush);\n this.delayedFlush = -1;\n }\n this.flush();\n }\n pendingRecords() {\n for (let mut of this.observer.takeRecords())\n this.queue.push(mut);\n return this.queue;\n }\n processRecords() {\n let records = this.pendingRecords();\n if (records.length)\n this.queue = [];\n let from = -1, to = -1, typeOver = false;\n for (let record of records) {\n let range = this.readMutation(record);\n if (!range)\n continue;\n if (range.typeOver)\n typeOver = true;\n if (from == -1) {\n ({ from, to } = range);\n }\n else {\n from = Math.min(range.from, from);\n to = Math.max(range.to, to);\n }\n }\n return { from, to, typeOver };\n }\n readChange() {\n let { from, to, typeOver } = this.processRecords();\n let newSel = this.selectionChanged && hasSelection(this.dom, this.selectionRange);\n if (from < 0 && !newSel)\n return null;\n if (from > -1)\n this.lastChange = Date.now();\n this.view.inputState.lastFocusTime = 0;\n this.selectionChanged = false;\n let change = new DOMChange(this.view, from, to, typeOver);\n this.view.docView.domChanged = { newSel: change.newSel ? change.newSel.main : null };\n return change;\n }\n // Apply pending changes, if any\n flush(readSelection = true) {\n // Completely hold off flushing when pending keys are set—the code\n // managing those will make sure processRecords is called and the\n // view is resynchronized after\n if (this.delayedFlush >= 0 || this.delayedAndroidKey)\n return false;\n if (readSelection)\n this.readSelectionRange();\n let domChange = this.readChange();\n if (!domChange)\n return false;\n let startState = this.view.state;\n let handled = applyDOMChange(this.view, domChange);\n // The view wasn't updated\n if (this.view.state == startState)\n this.view.update([]);\n return handled;\n }\n readMutation(rec) {\n let cView = this.view.docView.nearest(rec.target);\n if (!cView || cView.ignoreMutation(rec))\n return null;\n cView.markDirty(rec.type == \"attributes\");\n if (rec.type == \"attributes\")\n cView.flags |= 4 /* ViewFlag.AttrsDirty */;\n if (rec.type == \"childList\") {\n let childBefore = findChild(cView, rec.previousSibling || rec.target.previousSibling, -1);\n let childAfter = findChild(cView, rec.nextSibling || rec.target.nextSibling, 1);\n return { from: childBefore ? cView.posAfter(childBefore) : cView.posAtStart,\n to: childAfter ? cView.posBefore(childAfter) : cView.posAtEnd, typeOver: false };\n }\n else if (rec.type == \"characterData\") {\n return { from: cView.posAtStart, to: cView.posAtEnd, typeOver: rec.target.nodeValue == rec.oldValue };\n }\n else {\n return null;\n }\n }\n setWindow(win) {\n if (win != this.win) {\n this.removeWindowListeners(this.win);\n this.win = win;\n this.addWindowListeners(this.win);\n }\n }\n addWindowListeners(win) {\n win.addEventListener(\"resize\", this.onResize);\n win.addEventListener(\"beforeprint\", this.onPrint);\n win.addEventListener(\"scroll\", this.onScroll);\n win.document.addEventListener(\"selectionchange\", this.onSelectionChange);\n }\n removeWindowListeners(win) {\n win.removeEventListener(\"scroll\", this.onScroll);\n win.removeEventListener(\"resize\", this.onResize);\n win.removeEventListener(\"beforeprint\", this.onPrint);\n win.document.removeEventListener(\"selectionchange\", this.onSelectionChange);\n }\n destroy() {\n var _a, _b, _c, _d;\n this.stop();\n (_a = this.intersection) === null || _a === void 0 ? void 0 : _a.disconnect();\n (_b = this.gapIntersection) === null || _b === void 0 ? void 0 : _b.disconnect();\n (_c = this.resizeScroll) === null || _c === void 0 ? void 0 : _c.disconnect();\n (_d = this.resizeContent) === null || _d === void 0 ? void 0 : _d.disconnect();\n for (let dom of this.scrollTargets)\n dom.removeEventListener(\"scroll\", this.onScroll);\n this.removeWindowListeners(this.win);\n clearTimeout(this.parentCheck);\n clearTimeout(this.resizeTimeout);\n this.win.cancelAnimationFrame(this.delayedFlush);\n this.win.cancelAnimationFrame(this.flushingAndroidKey);\n }\n}\nfunction findChild(cView, dom, dir) {\n while (dom) {\n let curView = ContentView.get(dom);\n if (curView && curView.parent == cView)\n return curView;\n let parent = dom.parentNode;\n dom = parent != cView.dom ? parent : dir > 0 ? dom.nextSibling : dom.previousSibling;\n }\n return null;\n}\n// Used to work around a Safari Selection/shadow DOM bug (#414)\nfunction safariSelectionRangeHack(view) {\n let found = null;\n // Because Safari (at least in 2018-2021) doesn't provide regular\n // access to the selection inside a shadowroot, we have to perform a\n // ridiculous hack to get at it—using `execCommand` to trigger a\n // `beforeInput` event so that we can read the target range from the\n // event.\n function read(event) {\n event.preventDefault();\n event.stopImmediatePropagation();\n found = event.getTargetRanges()[0];\n }\n view.contentDOM.addEventListener(\"beforeinput\", read, true);\n view.dom.ownerDocument.execCommand(\"indent\");\n view.contentDOM.removeEventListener(\"beforeinput\", read, true);\n if (!found)\n return null;\n let anchorNode = found.startContainer, anchorOffset = found.startOffset;\n let focusNode = found.endContainer, focusOffset = found.endOffset;\n let curAnchor = view.docView.domAtPos(view.state.selection.main.anchor);\n // Since such a range doesn't distinguish between anchor and head,\n // use a heuristic that flips it around if its end matches the\n // current anchor.\n if (isEquivalentPosition(curAnchor.node, curAnchor.offset, focusNode, focusOffset))\n [anchorNode, anchorOffset, focusNode, focusOffset] = [focusNode, focusOffset, anchorNode, anchorOffset];\n return { anchorNode, anchorOffset, focusNode, focusOffset };\n}\n\n// The editor's update state machine looks something like this:\n//\n// Idle → Updating ⇆ Idle (unchecked) → Measuring → Idle\n// ↑ ↓\n// Updating (measure)\n//\n// The difference between 'Idle' and 'Idle (unchecked)' lies in\n// whether a layout check has been scheduled. A regular update through\n// the `update` method updates the DOM in a write-only fashion, and\n// relies on a check (scheduled with `requestAnimationFrame`) to make\n// sure everything is where it should be and the viewport covers the\n// visible code. That check continues to measure and then optionally\n// update until it reaches a coherent state.\n/**\nAn editor view represents the editor's user interface. It holds\nthe editable DOM surface, and possibly other elements such as the\nline number gutter. It handles events and dispatches state\ntransactions for editing actions.\n*/\nclass EditorView {\n /**\n The current editor state.\n */\n get state() { return this.viewState.state; }\n /**\n To be able to display large documents without consuming too much\n memory or overloading the browser, CodeMirror only draws the\n code that is visible (plus a margin around it) to the DOM. This\n property tells you the extent of the current drawn viewport, in\n document positions.\n */\n get viewport() { return this.viewState.viewport; }\n /**\n When there are, for example, large collapsed ranges in the\n viewport, its size can be a lot bigger than the actual visible\n content. Thus, if you are doing something like styling the\n content in the viewport, it is preferable to only do so for\n these ranges, which are the subset of the viewport that is\n actually drawn.\n */\n get visibleRanges() { return this.viewState.visibleRanges; }\n /**\n Returns false when the editor is entirely scrolled out of view\n or otherwise hidden.\n */\n get inView() { return this.viewState.inView; }\n /**\n Indicates whether the user is currently composing text via\n [IME](https://en.wikipedia.org/wiki/Input_method), and at least\n one change has been made in the current composition.\n */\n get composing() { return this.inputState.composing > 0; }\n /**\n Indicates whether the user is currently in composing state. Note\n that on some platforms, like Android, this will be the case a\n lot, since just putting the cursor on a word starts a\n composition there.\n */\n get compositionStarted() { return this.inputState.composing >= 0; }\n /**\n The document or shadow root that the view lives in.\n */\n get root() { return this._root; }\n /**\n @internal\n */\n get win() { return this.dom.ownerDocument.defaultView || window; }\n /**\n Construct a new view. You'll want to either provide a `parent`\n option, or put `view.dom` into your document after creating a\n view, so that the user can see the editor.\n */\n constructor(config = {}) {\n this.plugins = [];\n this.pluginMap = new Map;\n this.editorAttrs = {};\n this.contentAttrs = {};\n this.bidiCache = [];\n this.destroyed = false;\n /**\n @internal\n */\n this.updateState = 2 /* UpdateState.Updating */;\n /**\n @internal\n */\n this.measureScheduled = -1;\n /**\n @internal\n */\n this.measureRequests = [];\n this.contentDOM = document.createElement(\"div\");\n this.scrollDOM = document.createElement(\"div\");\n this.scrollDOM.tabIndex = -1;\n this.scrollDOM.className = \"cm-scroller\";\n this.scrollDOM.appendChild(this.contentDOM);\n this.announceDOM = document.createElement(\"div\");\n this.announceDOM.style.cssText = \"position: fixed; top: -10000px\";\n this.announceDOM.setAttribute(\"aria-live\", \"polite\");\n this.dom = document.createElement(\"div\");\n this.dom.appendChild(this.announceDOM);\n this.dom.appendChild(this.scrollDOM);\n let { dispatch } = config;\n this.dispatchTransactions = config.dispatchTransactions ||\n (dispatch && ((trs) => trs.forEach(tr => dispatch(tr, this)))) ||\n ((trs) => this.update(trs));\n this.dispatch = this.dispatch.bind(this);\n this._root = (config.root || getRoot(config.parent) || document);\n this.viewState = new ViewState(config.state || EditorState.create(config));\n this.plugins = this.state.facet(viewPlugin).map(spec => new PluginInstance(spec));\n for (let plugin of this.plugins)\n plugin.update(this);\n this.observer = new DOMObserver(this);\n this.inputState = new InputState(this);\n this.inputState.ensureHandlers(this, this.plugins);\n this.docView = new DocView(this);\n this.mountStyles();\n this.updateAttrs();\n this.updateState = 0 /* UpdateState.Idle */;\n this.requestMeasure();\n if (config.parent)\n config.parent.appendChild(this.dom);\n }\n dispatch(...input) {\n let trs = input.length == 1 && input[0] instanceof Transaction ? input\n : input.length == 1 && Array.isArray(input[0]) ? input[0]\n : [this.state.update(...input)];\n this.dispatchTransactions(trs, this);\n }\n /**\n Update the view for the given array of transactions. This will\n update the visible document and selection to match the state\n produced by the transactions, and notify view plugins of the\n change. You should usually call\n [`dispatch`](https://codemirror.net/6/docs/ref/#view.EditorView.dispatch) instead, which uses this\n as a primitive.\n */\n update(transactions) {\n if (this.updateState != 0 /* UpdateState.Idle */)\n throw new Error(\"Calls to EditorView.update are not allowed while an update is in progress\");\n let redrawn = false, attrsChanged = false, update;\n let state = this.state;\n for (let tr of transactions) {\n if (tr.startState != state)\n throw new RangeError(\"Trying to update state with a transaction that doesn't start from the previous state.\");\n state = tr.state;\n }\n if (this.destroyed) {\n this.viewState.state = state;\n return;\n }\n let focus = this.hasFocus, focusFlag = 0, dispatchFocus = null;\n if (transactions.some(tr => tr.annotation(isFocusChange))) {\n this.inputState.notifiedFocused = focus;\n // If a focus-change transaction is being dispatched, set this update flag.\n focusFlag = 1 /* UpdateFlag.Focus */;\n }\n else if (focus != this.inputState.notifiedFocused) {\n this.inputState.notifiedFocused = focus;\n // Schedule a separate focus transaction if necessary, otherwise\n // add a flag to this update\n dispatchFocus = focusChangeTransaction(state, focus);\n if (!dispatchFocus)\n focusFlag = 1 /* UpdateFlag.Focus */;\n }\n // If there was a pending DOM change, eagerly read it and try to\n // apply it after the given transactions.\n let pendingKey = this.observer.delayedAndroidKey, domChange = null;\n if (pendingKey) {\n this.observer.clearDelayedAndroidKey();\n domChange = this.observer.readChange();\n // Only try to apply DOM changes if the transactions didn't\n // change the doc or selection.\n if (domChange && !this.state.doc.eq(state.doc) || !this.state.selection.eq(state.selection))\n domChange = null;\n }\n else {\n this.observer.clear();\n }\n // When the phrases change, redraw the editor\n if (state.facet(EditorState.phrases) != this.state.facet(EditorState.phrases))\n return this.setState(state);\n update = ViewUpdate.create(this, state, transactions);\n update.flags |= focusFlag;\n let scrollTarget = this.viewState.scrollTarget;\n try {\n this.updateState = 2 /* UpdateState.Updating */;\n for (let tr of transactions) {\n if (scrollTarget)\n scrollTarget = scrollTarget.map(tr.changes);\n if (tr.scrollIntoView) {\n let { main } = tr.state.selection;\n scrollTarget = new ScrollTarget(main.empty ? main : EditorSelection.cursor(main.head, main.head > main.anchor ? -1 : 1));\n }\n for (let e of tr.effects)\n if (e.is(scrollIntoView))\n scrollTarget = e.value;\n }\n this.viewState.update(update, scrollTarget);\n this.bidiCache = CachedOrder.update(this.bidiCache, update.changes);\n if (!update.empty) {\n this.updatePlugins(update);\n this.inputState.update(update);\n }\n redrawn = this.docView.update(update);\n if (this.state.facet(styleModule) != this.styleModules)\n this.mountStyles();\n attrsChanged = this.updateAttrs();\n this.showAnnouncements(transactions);\n this.docView.updateSelection(redrawn, transactions.some(tr => tr.isUserEvent(\"select.pointer\")));\n }\n finally {\n this.updateState = 0 /* UpdateState.Idle */;\n }\n if (update.startState.facet(theme) != update.state.facet(theme))\n this.viewState.mustMeasureContent = true;\n if (redrawn || attrsChanged || scrollTarget || this.viewState.mustEnforceCursorAssoc || this.viewState.mustMeasureContent)\n this.requestMeasure();\n if (!update.empty)\n for (let listener of this.state.facet(updateListener))\n listener(update);\n if (dispatchFocus || domChange)\n Promise.resolve().then(() => {\n if (dispatchFocus && this.state == dispatchFocus.startState)\n this.dispatch(dispatchFocus);\n if (domChange) {\n if (!applyDOMChange(this, domChange) && pendingKey.force)\n dispatchKey(this.contentDOM, pendingKey.key, pendingKey.keyCode);\n }\n });\n }\n /**\n Reset the view to the given state. (This will cause the entire\n document to be redrawn and all view plugins to be reinitialized,\n so you should probably only use it when the new state isn't\n derived from the old state. Otherwise, use\n [`dispatch`](https://codemirror.net/6/docs/ref/#view.EditorView.dispatch) instead.)\n */\n setState(newState) {\n if (this.updateState != 0 /* UpdateState.Idle */)\n throw new Error(\"Calls to EditorView.setState are not allowed while an update is in progress\");\n if (this.destroyed) {\n this.viewState.state = newState;\n return;\n }\n this.updateState = 2 /* UpdateState.Updating */;\n let hadFocus = this.hasFocus;\n try {\n for (let plugin of this.plugins)\n plugin.destroy(this);\n this.viewState = new ViewState(newState);\n this.plugins = newState.facet(viewPlugin).map(spec => new PluginInstance(spec));\n this.pluginMap.clear();\n for (let plugin of this.plugins)\n plugin.update(this);\n this.docView = new DocView(this);\n this.inputState.ensureHandlers(this, this.plugins);\n this.mountStyles();\n this.updateAttrs();\n this.bidiCache = [];\n }\n finally {\n this.updateState = 0 /* UpdateState.Idle */;\n }\n if (hadFocus)\n this.focus();\n this.requestMeasure();\n }\n updatePlugins(update) {\n let prevSpecs = update.startState.facet(viewPlugin), specs = update.state.facet(viewPlugin);\n if (prevSpecs != specs) {\n let newPlugins = [];\n for (let spec of specs) {\n let found = prevSpecs.indexOf(spec);\n if (found < 0) {\n newPlugins.push(new PluginInstance(spec));\n }\n else {\n let plugin = this.plugins[found];\n plugin.mustUpdate = update;\n newPlugins.push(plugin);\n }\n }\n for (let plugin of this.plugins)\n if (plugin.mustUpdate != update)\n plugin.destroy(this);\n this.plugins = newPlugins;\n this.pluginMap.clear();\n this.inputState.ensureHandlers(this, this.plugins);\n }\n else {\n for (let p of this.plugins)\n p.mustUpdate = update;\n }\n for (let i = 0; i < this.plugins.length; i++)\n this.plugins[i].update(this);\n }\n /**\n @internal\n */\n measure(flush = true) {\n if (this.destroyed)\n return;\n if (this.measureScheduled > -1)\n this.win.cancelAnimationFrame(this.measureScheduled);\n if (this.observer.delayedAndroidKey) {\n this.measureScheduled = -1;\n this.requestMeasure();\n return;\n }\n this.measureScheduled = 0; // Prevent requestMeasure calls from scheduling another animation frame\n if (flush)\n this.observer.forceFlush();\n let updated = null;\n let sDOM = this.scrollDOM, scrollTop = sDOM.scrollTop * this.scaleY;\n let { scrollAnchorPos, scrollAnchorHeight } = this.viewState;\n if (Math.abs(scrollTop - this.viewState.scrollTop) > 1)\n scrollAnchorHeight = -1;\n this.viewState.scrollAnchorHeight = -1;\n try {\n for (let i = 0;; i++) {\n if (scrollAnchorHeight < 0) {\n if (isScrolledToBottom(sDOM)) {\n scrollAnchorPos = -1;\n scrollAnchorHeight = this.viewState.heightMap.height;\n }\n else {\n let block = this.viewState.scrollAnchorAt(scrollTop);\n scrollAnchorPos = block.from;\n scrollAnchorHeight = block.top;\n }\n }\n this.updateState = 1 /* UpdateState.Measuring */;\n let changed = this.viewState.measure(this);\n if (!changed && !this.measureRequests.length && this.viewState.scrollTarget == null)\n break;\n if (i > 5) {\n console.warn(this.measureRequests.length\n ? \"Measure loop restarted more than 5 times\"\n : \"Viewport failed to stabilize\");\n break;\n }\n let measuring = [];\n // Only run measure requests in this cycle when the viewport didn't change\n if (!(changed & 4 /* UpdateFlag.Viewport */))\n [this.measureRequests, measuring] = [measuring, this.measureRequests];\n let measured = measuring.map(m => {\n try {\n return m.read(this);\n }\n catch (e) {\n logException(this.state, e);\n return BadMeasure;\n }\n });\n let update = ViewUpdate.create(this, this.state, []), redrawn = false;\n update.flags |= changed;\n if (!updated)\n updated = update;\n else\n updated.flags |= changed;\n this.updateState = 2 /* UpdateState.Updating */;\n if (!update.empty) {\n this.updatePlugins(update);\n this.inputState.update(update);\n this.updateAttrs();\n redrawn = this.docView.update(update);\n }\n for (let i = 0; i < measuring.length; i++)\n if (measured[i] != BadMeasure) {\n try {\n let m = measuring[i];\n if (m.write)\n m.write(measured[i], this);\n }\n catch (e) {\n logException(this.state, e);\n }\n }\n if (redrawn)\n this.docView.updateSelection(true);\n if (!update.viewportChanged && this.measureRequests.length == 0) {\n if (this.viewState.editorHeight) {\n if (this.viewState.scrollTarget) {\n this.docView.scrollIntoView(this.viewState.scrollTarget);\n this.viewState.scrollTarget = null;\n continue;\n }\n else {\n let newAnchorHeight = scrollAnchorPos < 0 ? this.viewState.heightMap.height :\n this.viewState.lineBlockAt(scrollAnchorPos).top;\n let diff = newAnchorHeight - scrollAnchorHeight;\n if (diff > 1 || diff < -1) {\n scrollTop = scrollTop + diff;\n sDOM.scrollTop = scrollTop / this.scaleY;\n scrollAnchorHeight = -1;\n continue;\n }\n }\n }\n break;\n }\n }\n }\n finally {\n this.updateState = 0 /* UpdateState.Idle */;\n this.measureScheduled = -1;\n }\n if (updated && !updated.empty)\n for (let listener of this.state.facet(updateListener))\n listener(updated);\n }\n /**\n Get the CSS classes for the currently active editor themes.\n */\n get themeClasses() {\n return baseThemeID + \" \" +\n (this.state.facet(darkTheme) ? baseDarkID : baseLightID) + \" \" +\n this.state.facet(theme);\n }\n updateAttrs() {\n let editorAttrs = attrsFromFacet(this, editorAttributes, {\n class: \"cm-editor\" + (this.hasFocus ? \" cm-focused \" : \" \") + this.themeClasses\n });\n let contentAttrs = {\n spellcheck: \"false\",\n autocorrect: \"off\",\n autocapitalize: \"off\",\n translate: \"no\",\n contenteditable: !this.state.facet(editable) ? \"false\" : \"true\",\n class: \"cm-content\",\n style: `${browser.tabSize}: ${this.state.tabSize}`,\n role: \"textbox\",\n \"aria-multiline\": \"true\"\n };\n if (this.state.readOnly)\n contentAttrs[\"aria-readonly\"] = \"true\";\n attrsFromFacet(this, contentAttributes, contentAttrs);\n let changed = this.observer.ignore(() => {\n let changedContent = updateAttrs(this.contentDOM, this.contentAttrs, contentAttrs);\n let changedEditor = updateAttrs(this.dom, this.editorAttrs, editorAttrs);\n return changedContent || changedEditor;\n });\n this.editorAttrs = editorAttrs;\n this.contentAttrs = contentAttrs;\n return changed;\n }\n showAnnouncements(trs) {\n let first = true;\n for (let tr of trs)\n for (let effect of tr.effects)\n if (effect.is(EditorView.announce)) {\n if (first)\n this.announceDOM.textContent = \"\";\n first = false;\n let div = this.announceDOM.appendChild(document.createElement(\"div\"));\n div.textContent = effect.value;\n }\n }\n mountStyles() {\n this.styleModules = this.state.facet(styleModule);\n let nonce = this.state.facet(EditorView.cspNonce);\n StyleModule.mount(this.root, this.styleModules.concat(baseTheme$1).reverse(), nonce ? { nonce } : undefined);\n }\n readMeasured() {\n if (this.updateState == 2 /* UpdateState.Updating */)\n throw new Error(\"Reading the editor layout isn't allowed during an update\");\n if (this.updateState == 0 /* UpdateState.Idle */ && this.measureScheduled > -1)\n this.measure(false);\n }\n /**\n Schedule a layout measurement, optionally providing callbacks to\n do custom DOM measuring followed by a DOM write phase. Using\n this is preferable reading DOM layout directly from, for\n example, an event handler, because it'll make sure measuring and\n drawing done by other components is synchronized, avoiding\n unnecessary DOM layout computations.\n */\n requestMeasure(request) {\n if (this.measureScheduled < 0)\n this.measureScheduled = this.win.requestAnimationFrame(() => this.measure());\n if (request) {\n if (this.measureRequests.indexOf(request) > -1)\n return;\n if (request.key != null)\n for (let i = 0; i < this.measureRequests.length; i++) {\n if (this.measureRequests[i].key === request.key) {\n this.measureRequests[i] = request;\n return;\n }\n }\n this.measureRequests.push(request);\n }\n }\n /**\n Get the value of a specific plugin, if present. Note that\n plugins that crash can be dropped from a view, so even when you\n know you registered a given plugin, it is recommended to check\n the return value of this method.\n */\n plugin(plugin) {\n let known = this.pluginMap.get(plugin);\n if (known === undefined || known && known.spec != plugin)\n this.pluginMap.set(plugin, known = this.plugins.find(p => p.spec == plugin) || null);\n return known && known.update(this).value;\n }\n /**\n The top position of the document, in screen coordinates. This\n may be negative when the editor is scrolled down. Points\n directly to the top of the first line, not above the padding.\n */\n get documentTop() {\n return this.contentDOM.getBoundingClientRect().top + this.viewState.paddingTop;\n }\n /**\n Reports the padding above and below the document.\n */\n get documentPadding() {\n return { top: this.viewState.paddingTop, bottom: this.viewState.paddingBottom };\n }\n /**\n If the editor is transformed with CSS, this provides the scale\n along the X axis. Otherwise, it will just be 1. Note that\n transforms other than translation and scaling are not supported.\n */\n get scaleX() { return this.viewState.scaleX; }\n /**\n Provide the CSS transformed scale along the Y axis.\n */\n get scaleY() { return this.viewState.scaleY; }\n /**\n Find the text line or block widget at the given vertical\n position (which is interpreted as relative to the [top of the\n document](https://codemirror.net/6/docs/ref/#view.EditorView.documentTop)).\n */\n elementAtHeight(height) {\n this.readMeasured();\n return this.viewState.elementAtHeight(height);\n }\n /**\n Find the line block (see\n [`lineBlockAt`](https://codemirror.net/6/docs/ref/#view.EditorView.lineBlockAt) at the given\n height, again interpreted relative to the [top of the\n document](https://codemirror.net/6/docs/ref/#view.EditorView.documentTop).\n */\n lineBlockAtHeight(height) {\n this.readMeasured();\n return this.viewState.lineBlockAtHeight(height);\n }\n /**\n Get the extent and vertical position of all [line\n blocks](https://codemirror.net/6/docs/ref/#view.EditorView.lineBlockAt) in the viewport. Positions\n are relative to the [top of the\n document](https://codemirror.net/6/docs/ref/#view.EditorView.documentTop);\n */\n get viewportLineBlocks() {\n return this.viewState.viewportLines;\n }\n /**\n Find the line block around the given document position. A line\n block is a range delimited on both sides by either a\n non-[hidden](https://codemirror.net/6/docs/ref/#view.Decoration^replace) line breaks, or the\n start/end of the document. It will usually just hold a line of\n text, but may be broken into multiple textblocks by block\n widgets.\n */\n lineBlockAt(pos) {\n return this.viewState.lineBlockAt(pos);\n }\n /**\n The editor's total content height.\n */\n get contentHeight() {\n return this.viewState.contentHeight;\n }\n /**\n Move a cursor position by [grapheme\n cluster](https://codemirror.net/6/docs/ref/#state.findClusterBreak). `forward` determines whether\n the motion is away from the line start, or towards it. In\n bidirectional text, the line is traversed in visual order, using\n the editor's [text direction](https://codemirror.net/6/docs/ref/#view.EditorView.textDirection).\n When the start position was the last one on the line, the\n returned position will be across the line break. If there is no\n further line, the original position is returned.\n \n By default, this method moves over a single cluster. The\n optional `by` argument can be used to move across more. It will\n be called with the first cluster as argument, and should return\n a predicate that determines, for each subsequent cluster,\n whether it should also be moved over.\n */\n moveByChar(start, forward, by) {\n return skipAtoms(this, start, moveByChar(this, start, forward, by));\n }\n /**\n Move a cursor position across the next group of either\n [letters](https://codemirror.net/6/docs/ref/#state.EditorState.charCategorizer) or non-letter\n non-whitespace characters.\n */\n moveByGroup(start, forward) {\n return skipAtoms(this, start, moveByChar(this, start, forward, initial => byGroup(this, start.head, initial)));\n }\n /**\n Move to the next line boundary in the given direction. If\n `includeWrap` is true, line wrapping is on, and there is a\n further wrap point on the current line, the wrap point will be\n returned. Otherwise this function will return the start or end\n of the line.\n */\n moveToLineBoundary(start, forward, includeWrap = true) {\n return moveToLineBoundary(this, start, forward, includeWrap);\n }\n /**\n Move a cursor position vertically. When `distance` isn't given,\n it defaults to moving to the next line (including wrapped\n lines). Otherwise, `distance` should provide a positive distance\n in pixels.\n \n When `start` has a\n [`goalColumn`](https://codemirror.net/6/docs/ref/#state.SelectionRange.goalColumn), the vertical\n motion will use that as a target horizontal position. Otherwise,\n the cursor's own horizontal position is used. The returned\n cursor will have its goal column set to whichever column was\n used.\n */\n moveVertically(start, forward, distance) {\n return skipAtoms(this, start, moveVertically(this, start, forward, distance));\n }\n /**\n Find the DOM parent node and offset (child offset if `node` is\n an element, character offset when it is a text node) at the\n given document position.\n \n Note that for positions that aren't currently in\n `visibleRanges`, the resulting DOM position isn't necessarily\n meaningful (it may just point before or after a placeholder\n element).\n */\n domAtPos(pos) {\n return this.docView.domAtPos(pos);\n }\n /**\n Find the document position at the given DOM node. Can be useful\n for associating positions with DOM events. Will raise an error\n when `node` isn't part of the editor content.\n */\n posAtDOM(node, offset = 0) {\n return this.docView.posFromDOM(node, offset);\n }\n posAtCoords(coords, precise = true) {\n this.readMeasured();\n return posAtCoords(this, coords, precise);\n }\n /**\n Get the screen coordinates at the given document position.\n `side` determines whether the coordinates are based on the\n element before (-1) or after (1) the position (if no element is\n available on the given side, the method will transparently use\n another strategy to get reasonable coordinates).\n */\n coordsAtPos(pos, side = 1) {\n this.readMeasured();\n let rect = this.docView.coordsAt(pos, side);\n if (!rect || rect.left == rect.right)\n return rect;\n let line = this.state.doc.lineAt(pos), order = this.bidiSpans(line);\n let span = order[BidiSpan.find(order, pos - line.from, -1, side)];\n return flattenRect(rect, (span.dir == Direction.LTR) == (side > 0));\n }\n /**\n Return the rectangle around a given character. If `pos` does not\n point in front of a character that is in the viewport and\n rendered (i.e. not replaced, not a line break), this will return\n null. For space characters that are a line wrap point, this will\n return the position before the line break.\n */\n coordsForChar(pos) {\n this.readMeasured();\n return this.docView.coordsForChar(pos);\n }\n /**\n The default width of a character in the editor. May not\n accurately reflect the width of all characters (given variable\n width fonts or styling of invididual ranges).\n */\n get defaultCharacterWidth() { return this.viewState.heightOracle.charWidth; }\n /**\n The default height of a line in the editor. May not be accurate\n for all lines.\n */\n get defaultLineHeight() { return this.viewState.heightOracle.lineHeight; }\n /**\n The text direction\n ([`direction`](https://developer.mozilla.org/en-US/docs/Web/CSS/direction)\n CSS property) of the editor's content element.\n */\n get textDirection() { return this.viewState.defaultTextDirection; }\n /**\n Find the text direction of the block at the given position, as\n assigned by CSS. If\n [`perLineTextDirection`](https://codemirror.net/6/docs/ref/#view.EditorView^perLineTextDirection)\n isn't enabled, or the given position is outside of the viewport,\n this will always return the same as\n [`textDirection`](https://codemirror.net/6/docs/ref/#view.EditorView.textDirection). Note that\n this may trigger a DOM layout.\n */\n textDirectionAt(pos) {\n let perLine = this.state.facet(perLineTextDirection);\n if (!perLine || pos < this.viewport.from || pos > this.viewport.to)\n return this.textDirection;\n this.readMeasured();\n return this.docView.textDirectionAt(pos);\n }\n /**\n Whether this editor [wraps lines](https://codemirror.net/6/docs/ref/#view.EditorView.lineWrapping)\n (as determined by the\n [`white-space`](https://developer.mozilla.org/en-US/docs/Web/CSS/white-space)\n CSS property of its content element).\n */\n get lineWrapping() { return this.viewState.heightOracle.lineWrapping; }\n /**\n Returns the bidirectional text structure of the given line\n (which should be in the current document) as an array of span\n objects. The order of these spans matches the [text\n direction](https://codemirror.net/6/docs/ref/#view.EditorView.textDirection)—if that is\n left-to-right, the leftmost spans come first, otherwise the\n rightmost spans come first.\n */\n bidiSpans(line) {\n if (line.length > MaxBidiLine)\n return trivialOrder(line.length);\n let dir = this.textDirectionAt(line.from), isolates;\n for (let entry of this.bidiCache) {\n if (entry.from == line.from && entry.dir == dir &&\n (entry.fresh || isolatesEq(entry.isolates, isolates = getIsolatedRanges(this, line.from, line.to))))\n return entry.order;\n }\n if (!isolates)\n isolates = getIsolatedRanges(this, line.from, line.to);\n let order = computeOrder(line.text, dir, isolates);\n this.bidiCache.push(new CachedOrder(line.from, line.to, dir, isolates, true, order));\n return order;\n }\n /**\n Check whether the editor has focus.\n */\n get hasFocus() {\n var _a;\n // Safari return false for hasFocus when the context menu is open\n // or closing, which leads us to ignore selection changes from the\n // context menu because it looks like the editor isn't focused.\n // This kludges around that.\n return (this.dom.ownerDocument.hasFocus() || browser.safari && ((_a = this.inputState) === null || _a === void 0 ? void 0 : _a.lastContextMenu) > Date.now() - 3e4) &&\n this.root.activeElement == this.contentDOM;\n }\n /**\n Put focus on the editor.\n */\n focus() {\n this.observer.ignore(() => {\n focusPreventScroll(this.contentDOM);\n this.docView.updateSelection();\n });\n }\n /**\n Update the [root](https://codemirror.net/6/docs/ref/##view.EditorViewConfig.root) in which the editor lives. This is only\n necessary when moving the editor's existing DOM to a new window or shadow root.\n */\n setRoot(root) {\n if (this._root != root) {\n this._root = root;\n this.observer.setWindow((root.nodeType == 9 ? root : root.ownerDocument).defaultView || window);\n this.mountStyles();\n }\n }\n /**\n Clean up this editor view, removing its element from the\n document, unregistering event handlers, and notifying\n plugins. The view instance can no longer be used after\n calling this.\n */\n destroy() {\n for (let plugin of this.plugins)\n plugin.destroy(this);\n this.plugins = [];\n this.inputState.destroy();\n this.dom.remove();\n this.observer.destroy();\n if (this.measureScheduled > -1)\n this.win.cancelAnimationFrame(this.measureScheduled);\n this.destroyed = true;\n }\n /**\n Returns an effect that can be\n [added](https://codemirror.net/6/docs/ref/#state.TransactionSpec.effects) to a transaction to\n cause it to scroll the given position or range into view.\n */\n static scrollIntoView(pos, options = {}) {\n return scrollIntoView.of(new ScrollTarget(typeof pos == \"number\" ? EditorSelection.cursor(pos) : pos, options.y, options.x, options.yMargin, options.xMargin));\n }\n /**\n Returns an extension that can be used to add DOM event handlers.\n The value should be an object mapping event names to handler\n functions. For any given event, such functions are ordered by\n extension precedence, and the first handler to return true will\n be assumed to have handled that event, and no other handlers or\n built-in behavior will be activated for it. These are registered\n on the [content element](https://codemirror.net/6/docs/ref/#view.EditorView.contentDOM), except\n for `scroll` handlers, which will be called any time the\n editor's [scroll element](https://codemirror.net/6/docs/ref/#view.EditorView.scrollDOM) or one of\n its parent nodes is scrolled.\n */\n static domEventHandlers(handlers) {\n return ViewPlugin.define(() => ({}), { eventHandlers: handlers });\n }\n /**\n Create a theme extension. The first argument can be a\n [`style-mod`](https://github.com/marijnh/style-mod#documentation)\n style spec providing the styles for the theme. These will be\n prefixed with a generated class for the style.\n \n Because the selectors will be prefixed with a scope class, rule\n that directly match the editor's [wrapper\n element](https://codemirror.net/6/docs/ref/#view.EditorView.dom)—to which the scope class will be\n added—need to be explicitly differentiated by adding an `&` to\n the selector for that element—for example\n `&.cm-focused`.\n \n When `dark` is set to true, the theme will be marked as dark,\n which will cause the `&dark` rules from [base\n themes](https://codemirror.net/6/docs/ref/#view.EditorView^baseTheme) to be used (as opposed to\n `&light` when a light theme is active).\n */\n static theme(spec, options) {\n let prefix = StyleModule.newName();\n let result = [theme.of(prefix), styleModule.of(buildTheme(`.${prefix}`, spec))];\n if (options && options.dark)\n result.push(darkTheme.of(true));\n return result;\n }\n /**\n Create an extension that adds styles to the base theme. Like\n with [`theme`](https://codemirror.net/6/docs/ref/#view.EditorView^theme), use `&` to indicate the\n place of the editor wrapper element when directly targeting\n that. You can also use `&dark` or `&light` instead to only\n target editors with a dark or light theme.\n */\n static baseTheme(spec) {\n return Prec.lowest(styleModule.of(buildTheme(\".\" + baseThemeID, spec, lightDarkIDs)));\n }\n /**\n Retrieve an editor view instance from the view's DOM\n representation.\n */\n static findFromDOM(dom) {\n var _a;\n let content = dom.querySelector(\".cm-content\");\n let cView = content && ContentView.get(content) || ContentView.get(dom);\n return ((_a = cView === null || cView === void 0 ? void 0 : cView.rootView) === null || _a === void 0 ? void 0 : _a.view) || null;\n }\n}\n/**\nFacet to add a [style\nmodule](https://github.com/marijnh/style-mod#documentation) to\nan editor view. The view will ensure that the module is\nmounted in its [document\nroot](https://codemirror.net/6/docs/ref/#view.EditorView.constructor^config.root).\n*/\nEditorView.styleModule = styleModule;\n/**\nAn input handler can override the way changes to the editable\nDOM content are handled. Handlers are passed the document\npositions between which the change was found, and the new\ncontent. When one returns true, no further input handlers are\ncalled and the default behavior is prevented.\n\nThe `insert` argument can be used to get the default transaction\nthat would be applied for this input. This can be useful when\ndispatching the custom behavior as a separate transaction.\n*/\nEditorView.inputHandler = inputHandler;\n/**\nThis facet can be used to provide functions that create effects\nto be dispatched when the editor's focus state changes.\n*/\nEditorView.focusChangeEffect = focusChangeEffect;\n/**\nBy default, the editor assumes all its content has the same\n[text direction](https://codemirror.net/6/docs/ref/#view.Direction). Configure this with a `true`\nvalue to make it read the text direction of every (rendered)\nline separately.\n*/\nEditorView.perLineTextDirection = perLineTextDirection;\n/**\nAllows you to provide a function that should be called when the\nlibrary catches an exception from an extension (mostly from view\nplugins, but may be used by other extensions to route exceptions\nfrom user-code-provided callbacks). This is mostly useful for\ndebugging and logging. See [`logException`](https://codemirror.net/6/docs/ref/#view.logException).\n*/\nEditorView.exceptionSink = exceptionSink;\n/**\nA facet that can be used to register a function to be called\nevery time the view updates.\n*/\nEditorView.updateListener = updateListener;\n/**\nFacet that controls whether the editor content DOM is editable.\nWhen its highest-precedence value is `false`, the element will\nnot have its `contenteditable` attribute set. (Note that this\ndoesn't affect API calls that change the editor content, even\nwhen those are bound to keys or buttons. See the\n[`readOnly`](https://codemirror.net/6/docs/ref/#state.EditorState.readOnly) facet for that.)\n*/\nEditorView.editable = editable;\n/**\nAllows you to influence the way mouse selection happens. The\nfunctions in this facet will be called for a `mousedown` event\non the editor, and can return an object that overrides the way a\nselection is computed from that mouse click or drag.\n*/\nEditorView.mouseSelectionStyle = mouseSelectionStyle;\n/**\nFacet used to configure whether a given selection drag event\nshould move or copy the selection. The given predicate will be\ncalled with the `mousedown` event, and can return `true` when\nthe drag should move the content.\n*/\nEditorView.dragMovesSelection = dragMovesSelection$1;\n/**\nFacet used to configure whether a given selecting click adds a\nnew range to the existing selection or replaces it entirely. The\ndefault behavior is to check `event.metaKey` on macOS, and\n`event.ctrlKey` elsewhere.\n*/\nEditorView.clickAddsSelectionRange = clickAddsSelectionRange;\n/**\nA facet that determines which [decorations](https://codemirror.net/6/docs/ref/#view.Decoration)\nare shown in the view. Decorations can be provided in two\nways—directly, or via a function that takes an editor view.\n\nOnly decoration sets provided directly are allowed to influence\nthe editor's vertical layout structure. The ones provided as\nfunctions are called _after_ the new viewport has been computed,\nand thus **must not** introduce block widgets or replacing\ndecorations that cover line breaks.\n\nIf you want decorated ranges to behave like atomic units for\ncursor motion and deletion purposes, also provide the range set\ncontaining the decorations to\n[`EditorView.atomicRanges`](https://codemirror.net/6/docs/ref/#view.EditorView^atomicRanges).\n*/\nEditorView.decorations = decorations;\n/**\nUsed to provide ranges that should be treated as atoms as far as\ncursor motion is concerned. This causes methods like\n[`moveByChar`](https://codemirror.net/6/docs/ref/#view.EditorView.moveByChar) and\n[`moveVertically`](https://codemirror.net/6/docs/ref/#view.EditorView.moveVertically) (and the\ncommands built on top of them) to skip across such regions when\na selection endpoint would enter them. This does _not_ prevent\ndirect programmatic [selection\nupdates](https://codemirror.net/6/docs/ref/#state.TransactionSpec.selection) from moving into such\nregions.\n*/\nEditorView.atomicRanges = atomicRanges;\n/**\nWhen range decorations add a `unicode-bidi: isolate` style, they\nshould also include a\n[`bidiIsolate`](https://codemirror.net/6/docs/ref/#view.MarkDecorationSpec.bidiIsolate) property\nin their decoration spec, and be exposed through this facet, so\nthat the editor can compute the proper text order. (Other values\nfor `unicode-bidi`, except of course `normal`, are not\nsupported.)\n*/\nEditorView.bidiIsolatedRanges = bidiIsolatedRanges;\n/**\nFacet that allows extensions to provide additional scroll\nmargins (space around the sides of the scrolling element that\nshould be considered invisible). This can be useful when the\nplugin introduces elements that cover part of that element (for\nexample a horizontally fixed gutter).\n*/\nEditorView.scrollMargins = scrollMargins;\n/**\nThis facet records whether a dark theme is active. The extension\nreturned by [`theme`](https://codemirror.net/6/docs/ref/#view.EditorView^theme) automatically\nincludes an instance of this when the `dark` option is set to\ntrue.\n*/\nEditorView.darkTheme = darkTheme;\n/**\nProvides a Content Security Policy nonce to use when creating\nthe style sheets for the editor. Holds the empty string when no\nnonce has been provided.\n*/\nEditorView.cspNonce = /*@__PURE__*/Facet.define({ combine: values => values.length ? values[0] : \"\" });\n/**\nFacet that provides additional DOM attributes for the editor's\neditable DOM element.\n*/\nEditorView.contentAttributes = contentAttributes;\n/**\nFacet that provides DOM attributes for the editor's outer\nelement.\n*/\nEditorView.editorAttributes = editorAttributes;\n/**\nAn extension that enables line wrapping in the editor (by\nsetting CSS `white-space` to `pre-wrap` in the content).\n*/\nEditorView.lineWrapping = /*@__PURE__*/EditorView.contentAttributes.of({ \"class\": \"cm-lineWrapping\" });\n/**\nState effect used to include screen reader announcements in a\ntransaction. These will be added to the DOM in a visually hidden\nelement with `aria-live=\"polite\"` set, and should be used to\ndescribe effects that are visually obvious but may not be\nnoticed by screen reader users (such as moving to the next\nsearch match).\n*/\nEditorView.announce = /*@__PURE__*/StateEffect.define();\n// Maximum line length for which we compute accurate bidi info\nconst MaxBidiLine = 4096;\nconst BadMeasure = {};\nclass CachedOrder {\n constructor(from, to, dir, isolates, fresh, order) {\n this.from = from;\n this.to = to;\n this.dir = dir;\n this.isolates = isolates;\n this.fresh = fresh;\n this.order = order;\n }\n static update(cache, changes) {\n if (changes.empty && !cache.some(c => c.fresh))\n return cache;\n let result = [], lastDir = cache.length ? cache[cache.length - 1].dir : Direction.LTR;\n for (let i = Math.max(0, cache.length - 10); i < cache.length; i++) {\n let entry = cache[i];\n if (entry.dir == lastDir && !changes.touchesRange(entry.from, entry.to))\n result.push(new CachedOrder(changes.mapPos(entry.from, 1), changes.mapPos(entry.to, -1), entry.dir, entry.isolates, false, entry.order));\n }\n return result;\n }\n}\nfunction attrsFromFacet(view, facet, base) {\n for (let sources = view.state.facet(facet), i = sources.length - 1; i >= 0; i--) {\n let source = sources[i], value = typeof source == \"function\" ? source(view) : source;\n if (value)\n combineAttrs(value, base);\n }\n return base;\n}\n\nconst currentPlatform = browser.mac ? \"mac\" : browser.windows ? \"win\" : browser.linux ? \"linux\" : \"key\";\nfunction normalizeKeyName(name, platform) {\n const parts = name.split(/-(?!$)/);\n let result = parts[parts.length - 1];\n if (result == \"Space\")\n result = \" \";\n let alt, ctrl, shift, meta;\n for (let i = 0; i < parts.length - 1; ++i) {\n const mod = parts[i];\n if (/^(cmd|meta|m)$/i.test(mod))\n meta = true;\n else if (/^a(lt)?$/i.test(mod))\n alt = true;\n else if (/^(c|ctrl|control)$/i.test(mod))\n ctrl = true;\n else if (/^s(hift)?$/i.test(mod))\n shift = true;\n else if (/^mod$/i.test(mod)) {\n if (platform == \"mac\")\n meta = true;\n else\n ctrl = true;\n }\n else\n throw new Error(\"Unrecognized modifier name: \" + mod);\n }\n if (alt)\n result = \"Alt-\" + result;\n if (ctrl)\n result = \"Ctrl-\" + result;\n if (meta)\n result = \"Meta-\" + result;\n if (shift)\n result = \"Shift-\" + result;\n return result;\n}\nfunction modifiers(name, event, shift) {\n if (event.altKey)\n name = \"Alt-\" + name;\n if (event.ctrlKey)\n name = \"Ctrl-\" + name;\n if (event.metaKey)\n name = \"Meta-\" + name;\n if (shift !== false && event.shiftKey)\n name = \"Shift-\" + name;\n return name;\n}\nconst handleKeyEvents = /*@__PURE__*/Prec.default(/*@__PURE__*/EditorView.domEventHandlers({\n keydown(event, view) {\n return runHandlers(getKeymap(view.state), event, view, \"editor\");\n }\n}));\n/**\nFacet used for registering keymaps.\n\nYou can add multiple keymaps to an editor. Their priorities\ndetermine their precedence (the ones specified early or with high\npriority get checked first). When a handler has returned `true`\nfor a given key, no further handlers are called.\n*/\nconst keymap = /*@__PURE__*/Facet.define({ enables: handleKeyEvents });\nconst Keymaps = /*@__PURE__*/new WeakMap();\n// This is hidden behind an indirection, rather than directly computed\n// by the facet, to keep internal types out of the facet's type.\nfunction getKeymap(state) {\n let bindings = state.facet(keymap);\n let map = Keymaps.get(bindings);\n if (!map)\n Keymaps.set(bindings, map = buildKeymap(bindings.reduce((a, b) => a.concat(b), [])));\n return map;\n}\n/**\nRun the key handlers registered for a given scope. The event\nobject should be a `\"keydown\"` event. Returns true if any of the\nhandlers handled it.\n*/\nfunction runScopeHandlers(view, event, scope) {\n return runHandlers(getKeymap(view.state), event, view, scope);\n}\nlet storedPrefix = null;\nconst PrefixTimeout = 4000;\nfunction buildKeymap(bindings, platform = currentPlatform) {\n let bound = Object.create(null);\n let isPrefix = Object.create(null);\n let checkPrefix = (name, is) => {\n let current = isPrefix[name];\n if (current == null)\n isPrefix[name] = is;\n else if (current != is)\n throw new Error(\"Key binding \" + name + \" is used both as a regular binding and as a multi-stroke prefix\");\n };\n let add = (scope, key, command, preventDefault, stopPropagation) => {\n var _a, _b;\n let scopeObj = bound[scope] || (bound[scope] = Object.create(null));\n let parts = key.split(/ (?!$)/).map(k => normalizeKeyName(k, platform));\n for (let i = 1; i < parts.length; i++) {\n let prefix = parts.slice(0, i).join(\" \");\n checkPrefix(prefix, true);\n if (!scopeObj[prefix])\n scopeObj[prefix] = {\n preventDefault: true,\n stopPropagation: false,\n run: [(view) => {\n let ourObj = storedPrefix = { view, prefix, scope };\n setTimeout(() => { if (storedPrefix == ourObj)\n storedPrefix = null; }, PrefixTimeout);\n return true;\n }]\n };\n }\n let full = parts.join(\" \");\n checkPrefix(full, false);\n let binding = scopeObj[full] || (scopeObj[full] = {\n preventDefault: false,\n stopPropagation: false,\n run: ((_b = (_a = scopeObj._any) === null || _a === void 0 ? void 0 : _a.run) === null || _b === void 0 ? void 0 : _b.slice()) || []\n });\n if (command)\n binding.run.push(command);\n if (preventDefault)\n binding.preventDefault = true;\n if (stopPropagation)\n binding.stopPropagation = true;\n };\n for (let b of bindings) {\n let scopes = b.scope ? b.scope.split(\" \") : [\"editor\"];\n if (b.any)\n for (let scope of scopes) {\n let scopeObj = bound[scope] || (bound[scope] = Object.create(null));\n if (!scopeObj._any)\n scopeObj._any = { preventDefault: false, stopPropagation: false, run: [] };\n for (let key in scopeObj)\n scopeObj[key].run.push(b.any);\n }\n let name = b[platform] || b.key;\n if (!name)\n continue;\n for (let scope of scopes) {\n add(scope, name, b.run, b.preventDefault, b.stopPropagation);\n if (b.shift)\n add(scope, \"Shift-\" + name, b.shift, b.preventDefault, b.stopPropagation);\n }\n }\n return bound;\n}\nfunction runHandlers(map, event, view, scope) {\n let name = keyName(event);\n let charCode = codePointAt(name, 0), isChar = codePointSize(charCode) == name.length && name != \" \";\n let prefix = \"\", handled = false, prevented = false, stopPropagation = false;\n if (storedPrefix && storedPrefix.view == view && storedPrefix.scope == scope) {\n prefix = storedPrefix.prefix + \" \";\n if (modifierCodes.indexOf(event.keyCode) < 0) {\n prevented = true;\n storedPrefix = null;\n }\n }\n let ran = new Set;\n let runFor = (binding) => {\n if (binding) {\n for (let cmd of binding.run)\n if (!ran.has(cmd)) {\n ran.add(cmd);\n if (cmd(view, event)) {\n if (binding.stopPropagation)\n stopPropagation = true;\n return true;\n }\n }\n if (binding.preventDefault) {\n if (binding.stopPropagation)\n stopPropagation = true;\n prevented = true;\n }\n }\n return false;\n };\n let scopeObj = map[scope], baseName, shiftName;\n if (scopeObj) {\n if (runFor(scopeObj[prefix + modifiers(name, event, !isChar)])) {\n handled = true;\n }\n else if (isChar && (event.altKey || event.metaKey || event.ctrlKey) &&\n // Ctrl-Alt may be used for AltGr on Windows\n !(browser.windows && event.ctrlKey && event.altKey) &&\n (baseName = base[event.keyCode]) && baseName != name) {\n if (runFor(scopeObj[prefix + modifiers(baseName, event, true)])) {\n handled = true;\n }\n else if (event.shiftKey && (shiftName = shift[event.keyCode]) != name && shiftName != baseName &&\n runFor(scopeObj[prefix + modifiers(shiftName, event, false)])) {\n handled = true;\n }\n }\n else if (isChar && event.shiftKey &&\n runFor(scopeObj[prefix + modifiers(name, event, true)])) {\n handled = true;\n }\n if (!handled && runFor(scopeObj._any))\n handled = true;\n }\n if (prevented)\n handled = true;\n if (handled && stopPropagation)\n event.stopPropagation();\n return handled;\n}\n\n/**\nImplementation of [`LayerMarker`](https://codemirror.net/6/docs/ref/#view.LayerMarker) that creates\na rectangle at a given set of coordinates.\n*/\nclass RectangleMarker {\n /**\n Create a marker with the given class and dimensions. If `width`\n is null, the DOM element will get no width style.\n */\n constructor(className, left, top, width, height) {\n this.className = className;\n this.left = left;\n this.top = top;\n this.width = width;\n this.height = height;\n }\n draw() {\n let elt = document.createElement(\"div\");\n elt.className = this.className;\n this.adjust(elt);\n return elt;\n }\n update(elt, prev) {\n if (prev.className != this.className)\n return false;\n this.adjust(elt);\n return true;\n }\n adjust(elt) {\n elt.style.left = this.left + \"px\";\n elt.style.top = this.top + \"px\";\n if (this.width != null)\n elt.style.width = this.width + \"px\";\n elt.style.height = this.height + \"px\";\n }\n eq(p) {\n return this.left == p.left && this.top == p.top && this.width == p.width && this.height == p.height &&\n this.className == p.className;\n }\n /**\n Create a set of rectangles for the given selection range,\n assigning them theclass`className`. Will create a single\n rectangle for empty ranges, and a set of selection-style\n rectangles covering the range's content (in a bidi-aware\n way) for non-empty ones.\n */\n static forRange(view, className, range) {\n if (range.empty) {\n let pos = view.coordsAtPos(range.head, range.assoc || 1);\n if (!pos)\n return [];\n let base = getBase(view);\n return [new RectangleMarker(className, pos.left - base.left, pos.top - base.top, null, pos.bottom - pos.top)];\n }\n else {\n return rectanglesForRange(view, className, range);\n }\n }\n}\nfunction getBase(view) {\n let rect = view.scrollDOM.getBoundingClientRect();\n let left = view.textDirection == Direction.LTR ? rect.left : rect.right - view.scrollDOM.clientWidth * view.scaleX;\n return { left: left - view.scrollDOM.scrollLeft * view.scaleX, top: rect.top - view.scrollDOM.scrollTop * view.scaleY };\n}\nfunction wrappedLine(view, pos, inside) {\n let range = EditorSelection.cursor(pos);\n return { from: Math.max(inside.from, view.moveToLineBoundary(range, false, true).from),\n to: Math.min(inside.to, view.moveToLineBoundary(range, true, true).from),\n type: BlockType.Text };\n}\nfunction rectanglesForRange(view, className, range) {\n if (range.to <= view.viewport.from || range.from >= view.viewport.to)\n return [];\n let from = Math.max(range.from, view.viewport.from), to = Math.min(range.to, view.viewport.to);\n let ltr = view.textDirection == Direction.LTR;\n let content = view.contentDOM, contentRect = content.getBoundingClientRect(), base = getBase(view);\n let lineElt = content.querySelector(\".cm-line\"), lineStyle = lineElt && window.getComputedStyle(lineElt);\n let leftSide = contentRect.left +\n (lineStyle ? parseInt(lineStyle.paddingLeft) + Math.min(0, parseInt(lineStyle.textIndent)) : 0);\n let rightSide = contentRect.right - (lineStyle ? parseInt(lineStyle.paddingRight) : 0);\n let startBlock = blockAt(view, from), endBlock = blockAt(view, to);\n let visualStart = startBlock.type == BlockType.Text ? startBlock : null;\n let visualEnd = endBlock.type == BlockType.Text ? endBlock : null;\n if (visualStart && (view.lineWrapping || startBlock.widgetLineBreaks))\n visualStart = wrappedLine(view, from, visualStart);\n if (visualEnd && (view.lineWrapping || endBlock.widgetLineBreaks))\n visualEnd = wrappedLine(view, to, visualEnd);\n if (visualStart && visualEnd && visualStart.from == visualEnd.from) {\n return pieces(drawForLine(range.from, range.to, visualStart));\n }\n else {\n let top = visualStart ? drawForLine(range.from, null, visualStart) : drawForWidget(startBlock, false);\n let bottom = visualEnd ? drawForLine(null, range.to, visualEnd) : drawForWidget(endBlock, true);\n let between = [];\n if ((visualStart || startBlock).to < (visualEnd || endBlock).from - (visualStart && visualEnd ? 1 : 0) ||\n startBlock.widgetLineBreaks > 1 && top.bottom + view.defaultLineHeight / 2 < bottom.top)\n between.push(piece(leftSide, top.bottom, rightSide, bottom.top));\n else if (top.bottom < bottom.top && view.elementAtHeight((top.bottom + bottom.top) / 2).type == BlockType.Text)\n top.bottom = bottom.top = (top.bottom + bottom.top) / 2;\n return pieces(top).concat(between).concat(pieces(bottom));\n }\n function piece(left, top, right, bottom) {\n return new RectangleMarker(className, left - base.left, top - base.top - 0.01 /* C.Epsilon */, right - left, bottom - top + 0.01 /* C.Epsilon */);\n }\n function pieces({ top, bottom, horizontal }) {\n let pieces = [];\n for (let i = 0; i < horizontal.length; i += 2)\n pieces.push(piece(horizontal[i], top, horizontal[i + 1], bottom));\n return pieces;\n }\n // Gets passed from/to in line-local positions\n function drawForLine(from, to, line) {\n let top = 1e9, bottom = -1e9, horizontal = [];\n function addSpan(from, fromOpen, to, toOpen, dir) {\n // Passing 2/-2 is a kludge to force the view to return\n // coordinates on the proper side of block widgets, since\n // normalizing the side there, though appropriate for most\n // coordsAtPos queries, would break selection drawing.\n let fromCoords = view.coordsAtPos(from, (from == line.to ? -2 : 2));\n let toCoords = view.coordsAtPos(to, (to == line.from ? 2 : -2));\n if (!fromCoords || !toCoords)\n return;\n top = Math.min(fromCoords.top, toCoords.top, top);\n bottom = Math.max(fromCoords.bottom, toCoords.bottom, bottom);\n if (dir == Direction.LTR)\n horizontal.push(ltr && fromOpen ? leftSide : fromCoords.left, ltr && toOpen ? rightSide : toCoords.right);\n else\n horizontal.push(!ltr && toOpen ? leftSide : toCoords.left, !ltr && fromOpen ? rightSide : fromCoords.right);\n }\n let start = from !== null && from !== void 0 ? from : line.from, end = to !== null && to !== void 0 ? to : line.to;\n // Split the range by visible range and document line\n for (let r of view.visibleRanges)\n if (r.to > start && r.from < end) {\n for (let pos = Math.max(r.from, start), endPos = Math.min(r.to, end);;) {\n let docLine = view.state.doc.lineAt(pos);\n for (let span of view.bidiSpans(docLine)) {\n let spanFrom = span.from + docLine.from, spanTo = span.to + docLine.from;\n if (spanFrom >= endPos)\n break;\n if (spanTo > pos)\n addSpan(Math.max(spanFrom, pos), from == null && spanFrom <= start, Math.min(spanTo, endPos), to == null && spanTo >= end, span.dir);\n }\n pos = docLine.to + 1;\n if (pos >= endPos)\n break;\n }\n }\n if (horizontal.length == 0)\n addSpan(start, from == null, end, to == null, view.textDirection);\n return { top, bottom, horizontal };\n }\n function drawForWidget(block, top) {\n let y = contentRect.top + (top ? block.top : block.bottom);\n return { top: y, bottom: y, horizontal: [] };\n }\n}\nfunction sameMarker(a, b) {\n return a.constructor == b.constructor && a.eq(b);\n}\nclass LayerView {\n constructor(view, layer) {\n this.view = view;\n this.layer = layer;\n this.drawn = [];\n this.scaleX = 1;\n this.scaleY = 1;\n this.measureReq = { read: this.measure.bind(this), write: this.draw.bind(this) };\n this.dom = view.scrollDOM.appendChild(document.createElement(\"div\"));\n this.dom.classList.add(\"cm-layer\");\n if (layer.above)\n this.dom.classList.add(\"cm-layer-above\");\n if (layer.class)\n this.dom.classList.add(layer.class);\n this.scale();\n this.dom.setAttribute(\"aria-hidden\", \"true\");\n this.setOrder(view.state);\n view.requestMeasure(this.measureReq);\n if (layer.mount)\n layer.mount(this.dom, view);\n }\n update(update) {\n if (update.startState.facet(layerOrder) != update.state.facet(layerOrder))\n this.setOrder(update.state);\n if (this.layer.update(update, this.dom) || update.geometryChanged) {\n this.scale();\n update.view.requestMeasure(this.measureReq);\n }\n }\n setOrder(state) {\n let pos = 0, order = state.facet(layerOrder);\n while (pos < order.length && order[pos] != this.layer)\n pos++;\n this.dom.style.zIndex = String((this.layer.above ? 150 : -1) - pos);\n }\n measure() {\n return this.layer.markers(this.view);\n }\n scale() {\n let { scaleX, scaleY } = this.view;\n if (scaleX != this.scaleX || scaleY != this.scaleY) {\n this.scaleX = scaleX;\n this.scaleY = scaleY;\n this.dom.style.transform = `scale(${1 / scaleX}, ${1 / scaleY})`;\n }\n }\n draw(markers) {\n if (markers.length != this.drawn.length || markers.some((p, i) => !sameMarker(p, this.drawn[i]))) {\n let old = this.dom.firstChild, oldI = 0;\n for (let marker of markers) {\n if (marker.update && old && marker.constructor && this.drawn[oldI].constructor &&\n marker.update(old, this.drawn[oldI])) {\n old = old.nextSibling;\n oldI++;\n }\n else {\n this.dom.insertBefore(marker.draw(), old);\n }\n }\n while (old) {\n let next = old.nextSibling;\n old.remove();\n old = next;\n }\n this.drawn = markers;\n }\n }\n destroy() {\n if (this.layer.destroy)\n this.layer.destroy(this.dom, this.view);\n this.dom.remove();\n }\n}\nconst layerOrder = /*@__PURE__*/Facet.define();\n/**\nDefine a layer.\n*/\nfunction layer(config) {\n return [\n ViewPlugin.define(v => new LayerView(v, config)),\n layerOrder.of(config)\n ];\n}\n\nconst CanHidePrimary = !browser.ios; // FIXME test IE\nconst selectionConfig = /*@__PURE__*/Facet.define({\n combine(configs) {\n return combineConfig(configs, {\n cursorBlinkRate: 1200,\n drawRangeCursor: true\n }, {\n cursorBlinkRate: (a, b) => Math.min(a, b),\n drawRangeCursor: (a, b) => a || b\n });\n }\n});\n/**\nReturns an extension that hides the browser's native selection and\ncursor, replacing the selection with a background behind the text\n(with the `cm-selectionBackground` class), and the\ncursors with elements overlaid over the code (using\n`cm-cursor-primary` and `cm-cursor-secondary`).\n\nThis allows the editor to display secondary selection ranges, and\ntends to produce a type of selection more in line with that users\nexpect in a text editor (the native selection styling will often\nleave gaps between lines and won't fill the horizontal space after\na line when the selection continues past it).\n\nIt does have a performance cost, in that it requires an extra DOM\nlayout cycle for many updates (the selection is drawn based on DOM\nlayout information that's only available after laying out the\ncontent).\n*/\nfunction drawSelection(config = {}) {\n return [\n selectionConfig.of(config),\n cursorLayer,\n selectionLayer,\n hideNativeSelection,\n nativeSelectionHidden.of(true)\n ];\n}\nfunction configChanged(update) {\n return update.startState.facet(selectionConfig) != update.state.facet(selectionConfig);\n}\nconst cursorLayer = /*@__PURE__*/layer({\n above: true,\n markers(view) {\n let { state } = view, conf = state.facet(selectionConfig);\n let cursors = [];\n for (let r of state.selection.ranges) {\n let prim = r == state.selection.main;\n if (r.empty ? !prim || CanHidePrimary : conf.drawRangeCursor) {\n let className = prim ? \"cm-cursor cm-cursor-primary\" : \"cm-cursor cm-cursor-secondary\";\n let cursor = r.empty ? r : EditorSelection.cursor(r.head, r.head > r.anchor ? -1 : 1);\n for (let piece of RectangleMarker.forRange(view, className, cursor))\n cursors.push(piece);\n }\n }\n return cursors;\n },\n update(update, dom) {\n if (update.transactions.some(tr => tr.selection))\n dom.style.animationName = dom.style.animationName == \"cm-blink\" ? \"cm-blink2\" : \"cm-blink\";\n let confChange = configChanged(update);\n if (confChange)\n setBlinkRate(update.state, dom);\n return update.docChanged || update.selectionSet || confChange;\n },\n mount(dom, view) {\n setBlinkRate(view.state, dom);\n },\n class: \"cm-cursorLayer\"\n});\nfunction setBlinkRate(state, dom) {\n dom.style.animationDuration = state.facet(selectionConfig).cursorBlinkRate + \"ms\";\n}\nconst selectionLayer = /*@__PURE__*/layer({\n above: false,\n markers(view) {\n return view.state.selection.ranges.map(r => r.empty ? [] : RectangleMarker.forRange(view, \"cm-selectionBackground\", r))\n .reduce((a, b) => a.concat(b));\n },\n update(update, dom) {\n return update.docChanged || update.selectionSet || update.viewportChanged || configChanged(update);\n },\n class: \"cm-selectionLayer\"\n});\nconst themeSpec = {\n \".cm-line\": {\n \"& ::selection\": { backgroundColor: \"transparent !important\" },\n \"&::selection\": { backgroundColor: \"transparent !important\" }\n }\n};\nif (CanHidePrimary)\n themeSpec[\".cm-line\"].caretColor = \"transparent !important\";\nconst hideNativeSelection = /*@__PURE__*/Prec.highest(/*@__PURE__*/EditorView.theme(themeSpec));\n\nconst setDropCursorPos = /*@__PURE__*/StateEffect.define({\n map(pos, mapping) { return pos == null ? null : mapping.mapPos(pos); }\n});\nconst dropCursorPos = /*@__PURE__*/StateField.define({\n create() { return null; },\n update(pos, tr) {\n if (pos != null)\n pos = tr.changes.mapPos(pos);\n return tr.effects.reduce((pos, e) => e.is(setDropCursorPos) ? e.value : pos, pos);\n }\n});\nconst drawDropCursor = /*@__PURE__*/ViewPlugin.fromClass(class {\n constructor(view) {\n this.view = view;\n this.cursor = null;\n this.measureReq = { read: this.readPos.bind(this), write: this.drawCursor.bind(this) };\n }\n update(update) {\n var _a;\n let cursorPos = update.state.field(dropCursorPos);\n if (cursorPos == null) {\n if (this.cursor != null) {\n (_a = this.cursor) === null || _a === void 0 ? void 0 : _a.remove();\n this.cursor = null;\n }\n }\n else {\n if (!this.cursor) {\n this.cursor = this.view.scrollDOM.appendChild(document.createElement(\"div\"));\n this.cursor.className = \"cm-dropCursor\";\n }\n if (update.startState.field(dropCursorPos) != cursorPos || update.docChanged || update.geometryChanged)\n this.view.requestMeasure(this.measureReq);\n }\n }\n readPos() {\n let { view } = this;\n let pos = view.state.field(dropCursorPos);\n let rect = pos != null && view.coordsAtPos(pos);\n if (!rect)\n return null;\n let outer = view.scrollDOM.getBoundingClientRect();\n return {\n left: rect.left - outer.left + view.scrollDOM.scrollLeft * view.scaleX,\n top: rect.top - outer.top + view.scrollDOM.scrollTop * view.scaleY,\n height: rect.bottom - rect.top\n };\n }\n drawCursor(pos) {\n if (this.cursor) {\n let { scaleX, scaleY } = this.view;\n if (pos) {\n this.cursor.style.left = pos.left / scaleX + \"px\";\n this.cursor.style.top = pos.top / scaleY + \"px\";\n this.cursor.style.height = pos.height / scaleY + \"px\";\n }\n else {\n this.cursor.style.left = \"-100000px\";\n }\n }\n }\n destroy() {\n if (this.cursor)\n this.cursor.remove();\n }\n setDropPos(pos) {\n if (this.view.state.field(dropCursorPos) != pos)\n this.view.dispatch({ effects: setDropCursorPos.of(pos) });\n }\n}, {\n eventHandlers: {\n dragover(event) {\n this.setDropPos(this.view.posAtCoords({ x: event.clientX, y: event.clientY }));\n },\n dragleave(event) {\n if (event.target == this.view.contentDOM || !this.view.contentDOM.contains(event.relatedTarget))\n this.setDropPos(null);\n },\n dragend() {\n this.setDropPos(null);\n },\n drop() {\n this.setDropPos(null);\n }\n }\n});\n/**\nDraws a cursor at the current drop position when something is\ndragged over the editor.\n*/\nfunction dropCursor() {\n return [dropCursorPos, drawDropCursor];\n}\n\nfunction iterMatches(doc, re, from, to, f) {\n re.lastIndex = 0;\n for (let cursor = doc.iterRange(from, to), pos = from, m; !cursor.next().done; pos += cursor.value.length) {\n if (!cursor.lineBreak)\n while (m = re.exec(cursor.value))\n f(pos + m.index, m);\n }\n}\nfunction matchRanges(view, maxLength) {\n let visible = view.visibleRanges;\n if (visible.length == 1 && visible[0].from == view.viewport.from &&\n visible[0].to == view.viewport.to)\n return visible;\n let result = [];\n for (let { from, to } of visible) {\n from = Math.max(view.state.doc.lineAt(from).from, from - maxLength);\n to = Math.min(view.state.doc.lineAt(to).to, to + maxLength);\n if (result.length && result[result.length - 1].to >= from)\n result[result.length - 1].to = to;\n else\n result.push({ from, to });\n }\n return result;\n}\n/**\nHelper class used to make it easier to maintain decorations on\nvisible code that matches a given regular expression. To be used\nin a [view plugin](https://codemirror.net/6/docs/ref/#view.ViewPlugin). Instances of this object\nrepresent a matching configuration.\n*/\nclass MatchDecorator {\n /**\n Create a decorator.\n */\n constructor(config) {\n const { regexp, decoration, decorate, boundary, maxLength = 1000 } = config;\n if (!regexp.global)\n throw new RangeError(\"The regular expression given to MatchDecorator should have its 'g' flag set\");\n this.regexp = regexp;\n if (decorate) {\n this.addMatch = (match, view, from, add) => decorate(add, from, from + match[0].length, match, view);\n }\n else if (typeof decoration == \"function\") {\n this.addMatch = (match, view, from, add) => {\n let deco = decoration(match, view, from);\n if (deco)\n add(from, from + match[0].length, deco);\n };\n }\n else if (decoration) {\n this.addMatch = (match, _view, from, add) => add(from, from + match[0].length, decoration);\n }\n else {\n throw new RangeError(\"Either 'decorate' or 'decoration' should be provided to MatchDecorator\");\n }\n this.boundary = boundary;\n this.maxLength = maxLength;\n }\n /**\n Compute the full set of decorations for matches in the given\n view's viewport. You'll want to call this when initializing your\n plugin.\n */\n createDeco(view) {\n let build = new RangeSetBuilder(), add = build.add.bind(build);\n for (let { from, to } of matchRanges(view, this.maxLength))\n iterMatches(view.state.doc, this.regexp, from, to, (from, m) => this.addMatch(m, view, from, add));\n return build.finish();\n }\n /**\n Update a set of decorations for a view update. `deco` _must_ be\n the set of decorations produced by _this_ `MatchDecorator` for\n the view state before the update.\n */\n updateDeco(update, deco) {\n let changeFrom = 1e9, changeTo = -1;\n if (update.docChanged)\n update.changes.iterChanges((_f, _t, from, to) => {\n if (to > update.view.viewport.from && from < update.view.viewport.to) {\n changeFrom = Math.min(from, changeFrom);\n changeTo = Math.max(to, changeTo);\n }\n });\n if (update.viewportChanged || changeTo - changeFrom > 1000)\n return this.createDeco(update.view);\n if (changeTo > -1)\n return this.updateRange(update.view, deco.map(update.changes), changeFrom, changeTo);\n return deco;\n }\n updateRange(view, deco, updateFrom, updateTo) {\n for (let r of view.visibleRanges) {\n let from = Math.max(r.from, updateFrom), to = Math.min(r.to, updateTo);\n if (to > from) {\n let fromLine = view.state.doc.lineAt(from), toLine = fromLine.to < to ? view.state.doc.lineAt(to) : fromLine;\n let start = Math.max(r.from, fromLine.from), end = Math.min(r.to, toLine.to);\n if (this.boundary) {\n for (; from > fromLine.from; from--)\n if (this.boundary.test(fromLine.text[from - 1 - fromLine.from])) {\n start = from;\n break;\n }\n for (; to < toLine.to; to++)\n if (this.boundary.test(toLine.text[to - toLine.from])) {\n end = to;\n break;\n }\n }\n let ranges = [], m;\n let add = (from, to, deco) => ranges.push(deco.range(from, to));\n if (fromLine == toLine) {\n this.regexp.lastIndex = start - fromLine.from;\n while ((m = this.regexp.exec(fromLine.text)) && m.index < end - fromLine.from)\n this.addMatch(m, view, m.index + fromLine.from, add);\n }\n else {\n iterMatches(view.state.doc, this.regexp, start, end, (from, m) => this.addMatch(m, view, from, add));\n }\n deco = deco.update({ filterFrom: start, filterTo: end, filter: (from, to) => from < start || to > end, add: ranges });\n }\n }\n return deco;\n }\n}\n\nconst UnicodeRegexpSupport = /x/.unicode != null ? \"gu\" : \"g\";\nconst Specials = /*@__PURE__*/new RegExp(\"[\\u0000-\\u0008\\u000a-\\u001f\\u007f-\\u009f\\u00ad\\u061c\\u200b\\u200e\\u200f\\u2028\\u2029\\u202d\\u202e\\u2066\\u2067\\u2069\\ufeff\\ufff9-\\ufffc]\", UnicodeRegexpSupport);\nconst Names = {\n 0: \"null\",\n 7: \"bell\",\n 8: \"backspace\",\n 10: \"newline\",\n 11: \"vertical tab\",\n 13: \"carriage return\",\n 27: \"escape\",\n 8203: \"zero width space\",\n 8204: \"zero width non-joiner\",\n 8205: \"zero width joiner\",\n 8206: \"left-to-right mark\",\n 8207: \"right-to-left mark\",\n 8232: \"line separator\",\n 8237: \"left-to-right override\",\n 8238: \"right-to-left override\",\n 8294: \"left-to-right isolate\",\n 8295: \"right-to-left isolate\",\n 8297: \"pop directional isolate\",\n 8233: \"paragraph separator\",\n 65279: \"zero width no-break space\",\n 65532: \"object replacement\"\n};\nlet _supportsTabSize = null;\nfunction supportsTabSize() {\n var _a;\n if (_supportsTabSize == null && typeof document != \"undefined\" && document.body) {\n let styles = document.body.style;\n _supportsTabSize = ((_a = styles.tabSize) !== null && _a !== void 0 ? _a : styles.MozTabSize) != null;\n }\n return _supportsTabSize || false;\n}\nconst specialCharConfig = /*@__PURE__*/Facet.define({\n combine(configs) {\n let config = combineConfig(configs, {\n render: null,\n specialChars: Specials,\n addSpecialChars: null\n });\n if (config.replaceTabs = !supportsTabSize())\n config.specialChars = new RegExp(\"\\t|\" + config.specialChars.source, UnicodeRegexpSupport);\n if (config.addSpecialChars)\n config.specialChars = new RegExp(config.specialChars.source + \"|\" + config.addSpecialChars.source, UnicodeRegexpSupport);\n return config;\n }\n});\n/**\nReturns an extension that installs highlighting of special\ncharacters.\n*/\nfunction highlightSpecialChars(\n/**\nConfiguration options.\n*/\nconfig = {}) {\n return [specialCharConfig.of(config), specialCharPlugin()];\n}\nlet _plugin = null;\nfunction specialCharPlugin() {\n return _plugin || (_plugin = ViewPlugin.fromClass(class {\n constructor(view) {\n this.view = view;\n this.decorations = Decoration.none;\n this.decorationCache = Object.create(null);\n this.decorator = this.makeDecorator(view.state.facet(specialCharConfig));\n this.decorations = this.decorator.createDeco(view);\n }\n makeDecorator(conf) {\n return new MatchDecorator({\n regexp: conf.specialChars,\n decoration: (m, view, pos) => {\n let { doc } = view.state;\n let code = codePointAt(m[0], 0);\n if (code == 9) {\n let line = doc.lineAt(pos);\n let size = view.state.tabSize, col = countColumn(line.text, size, pos - line.from);\n return Decoration.replace({\n widget: new TabWidget((size - (col % size)) * this.view.defaultCharacterWidth / this.view.scaleX)\n });\n }\n return this.decorationCache[code] ||\n (this.decorationCache[code] = Decoration.replace({ widget: new SpecialCharWidget(conf, code) }));\n },\n boundary: conf.replaceTabs ? undefined : /[^]/\n });\n }\n update(update) {\n let conf = update.state.facet(specialCharConfig);\n if (update.startState.facet(specialCharConfig) != conf) {\n this.decorator = this.makeDecorator(conf);\n this.decorations = this.decorator.createDeco(update.view);\n }\n else {\n this.decorations = this.decorator.updateDeco(update, this.decorations);\n }\n }\n }, {\n decorations: v => v.decorations\n }));\n}\nconst DefaultPlaceholder = \"\\u2022\";\n// Assigns placeholder characters from the Control Pictures block to\n// ASCII control characters\nfunction placeholder$1(code) {\n if (code >= 32)\n return DefaultPlaceholder;\n if (code == 10)\n return \"\\u2424\";\n return String.fromCharCode(9216 + code);\n}\nclass SpecialCharWidget extends WidgetType {\n constructor(options, code) {\n super();\n this.options = options;\n this.code = code;\n }\n eq(other) { return other.code == this.code; }\n toDOM(view) {\n let ph = placeholder$1(this.code);\n let desc = view.state.phrase(\"Control character\") + \" \" + (Names[this.code] || \"0x\" + this.code.toString(16));\n let custom = this.options.render && this.options.render(this.code, desc, ph);\n if (custom)\n return custom;\n let span = document.createElement(\"span\");\n span.textContent = ph;\n span.title = desc;\n span.setAttribute(\"aria-label\", desc);\n span.className = \"cm-specialChar\";\n return span;\n }\n ignoreEvent() { return false; }\n}\nclass TabWidget extends WidgetType {\n constructor(width) {\n super();\n this.width = width;\n }\n eq(other) { return other.width == this.width; }\n toDOM() {\n let span = document.createElement(\"span\");\n span.textContent = \"\\t\";\n span.className = \"cm-tab\";\n span.style.width = this.width + \"px\";\n return span;\n }\n ignoreEvent() { return false; }\n}\n\nconst plugin = /*@__PURE__*/ViewPlugin.fromClass(class {\n constructor() {\n this.height = 1000;\n this.attrs = { style: \"padding-bottom: 1000px\" };\n }\n update(update) {\n let { view } = update;\n let height = view.viewState.editorHeight * view.scaleY -\n view.defaultLineHeight - view.documentPadding.top - 0.5;\n if (height >= 0 && height != this.height) {\n this.height = height;\n this.attrs = { style: `padding-bottom: ${height}px` };\n }\n }\n});\n/**\nReturns an extension that makes sure the content has a bottom\nmargin equivalent to the height of the editor, minus one line\nheight, so that every line in the document can be scrolled to the\ntop of the editor.\n\nThis is only meaningful when the editor is scrollable, and should\nnot be enabled in editors that take the size of their content.\n*/\nfunction scrollPastEnd() {\n return [plugin, contentAttributes.of(view => { var _a; return ((_a = view.plugin(plugin)) === null || _a === void 0 ? void 0 : _a.attrs) || null; })];\n}\n\n/**\nMark lines that have a cursor on them with the `\"cm-activeLine\"`\nDOM class.\n*/\nfunction highlightActiveLine() {\n return activeLineHighlighter;\n}\nconst lineDeco = /*@__PURE__*/Decoration.line({ class: \"cm-activeLine\" });\nconst activeLineHighlighter = /*@__PURE__*/ViewPlugin.fromClass(class {\n constructor(view) {\n this.decorations = this.getDeco(view);\n }\n update(update) {\n if (update.docChanged || update.selectionSet)\n this.decorations = this.getDeco(update.view);\n }\n getDeco(view) {\n let lastLineStart = -1, deco = [];\n for (let r of view.state.selection.ranges) {\n let line = view.lineBlockAt(r.head);\n if (line.from > lastLineStart) {\n deco.push(lineDeco.range(line.from));\n lastLineStart = line.from;\n }\n }\n return Decoration.set(deco);\n }\n}, {\n decorations: v => v.decorations\n});\n\nclass Placeholder extends WidgetType {\n constructor(content) {\n super();\n this.content = content;\n }\n toDOM() {\n let wrap = document.createElement(\"span\");\n wrap.className = \"cm-placeholder\";\n wrap.style.pointerEvents = \"none\";\n wrap.appendChild(typeof this.content == \"string\" ? document.createTextNode(this.content) : this.content);\n if (typeof this.content == \"string\")\n wrap.setAttribute(\"aria-label\", \"placeholder \" + this.content);\n else\n wrap.setAttribute(\"aria-hidden\", \"true\");\n return wrap;\n }\n coordsAt(dom) {\n let rects = dom.firstChild ? clientRectsFor(dom.firstChild) : [];\n if (!rects.length)\n return null;\n let style = window.getComputedStyle(dom.parentNode);\n let rect = flattenRect(rects[0], style.direction != \"rtl\");\n let lineHeight = parseInt(style.lineHeight);\n if (rect.bottom - rect.top > lineHeight * 1.5)\n return { left: rect.left, right: rect.right, top: rect.top, bottom: rect.top + lineHeight };\n return rect;\n }\n ignoreEvent() { return false; }\n}\n/**\nExtension that enables a placeholder—a piece of example content\nto show when the editor is empty.\n*/\nfunction placeholder(content) {\n return ViewPlugin.fromClass(class {\n constructor(view) {\n this.view = view;\n this.placeholder = content\n ? Decoration.set([Decoration.widget({ widget: new Placeholder(content), side: 1 }).range(0)])\n : Decoration.none;\n }\n get decorations() { return this.view.state.doc.length ? Decoration.none : this.placeholder; }\n }, { decorations: v => v.decorations });\n}\n\n// Don't compute precise column positions for line offsets above this\n// (since it could get expensive). Assume offset==column for them.\nconst MaxOff = 2000;\nfunction rectangleFor(state, a, b) {\n let startLine = Math.min(a.line, b.line), endLine = Math.max(a.line, b.line);\n let ranges = [];\n if (a.off > MaxOff || b.off > MaxOff || a.col < 0 || b.col < 0) {\n let startOff = Math.min(a.off, b.off), endOff = Math.max(a.off, b.off);\n for (let i = startLine; i <= endLine; i++) {\n let line = state.doc.line(i);\n if (line.length <= endOff)\n ranges.push(EditorSelection.range(line.from + startOff, line.to + endOff));\n }\n }\n else {\n let startCol = Math.min(a.col, b.col), endCol = Math.max(a.col, b.col);\n for (let i = startLine; i <= endLine; i++) {\n let line = state.doc.line(i);\n let start = findColumn(line.text, startCol, state.tabSize, true);\n if (start < 0) {\n ranges.push(EditorSelection.cursor(line.to));\n }\n else {\n let end = findColumn(line.text, endCol, state.tabSize);\n ranges.push(EditorSelection.range(line.from + start, line.from + end));\n }\n }\n }\n return ranges;\n}\nfunction absoluteColumn(view, x) {\n let ref = view.coordsAtPos(view.viewport.from);\n return ref ? Math.round(Math.abs((ref.left - x) / view.defaultCharacterWidth)) : -1;\n}\nfunction getPos(view, event) {\n let offset = view.posAtCoords({ x: event.clientX, y: event.clientY }, false);\n let line = view.state.doc.lineAt(offset), off = offset - line.from;\n let col = off > MaxOff ? -1\n : off == line.length ? absoluteColumn(view, event.clientX)\n : countColumn(line.text, view.state.tabSize, offset - line.from);\n return { line: line.number, col, off };\n}\nfunction rectangleSelectionStyle(view, event) {\n let start = getPos(view, event), startSel = view.state.selection;\n if (!start)\n return null;\n return {\n update(update) {\n if (update.docChanged) {\n let newStart = update.changes.mapPos(update.startState.doc.line(start.line).from);\n let newLine = update.state.doc.lineAt(newStart);\n start = { line: newLine.number, col: start.col, off: Math.min(start.off, newLine.length) };\n startSel = startSel.map(update.changes);\n }\n },\n get(event, _extend, multiple) {\n let cur = getPos(view, event);\n if (!cur)\n return startSel;\n let ranges = rectangleFor(view.state, start, cur);\n if (!ranges.length)\n return startSel;\n if (multiple)\n return EditorSelection.create(ranges.concat(startSel.ranges));\n else\n return EditorSelection.create(ranges);\n }\n };\n}\n/**\nCreate an extension that enables rectangular selections. By\ndefault, it will react to left mouse drag with the Alt key held\ndown. When such a selection occurs, the text within the rectangle\nthat was dragged over will be selected, as one selection\n[range](https://codemirror.net/6/docs/ref/#state.SelectionRange) per line.\n*/\nfunction rectangularSelection(options) {\n let filter = (options === null || options === void 0 ? void 0 : options.eventFilter) || (e => e.altKey && e.button == 0);\n return EditorView.mouseSelectionStyle.of((view, event) => filter(event) ? rectangleSelectionStyle(view, event) : null);\n}\nconst keys = {\n Alt: [18, e => !!e.altKey],\n Control: [17, e => !!e.ctrlKey],\n Shift: [16, e => !!e.shiftKey],\n Meta: [91, e => !!e.metaKey]\n};\nconst showCrosshair = { style: \"cursor: crosshair\" };\n/**\nReturns an extension that turns the pointer cursor into a\ncrosshair when a given modifier key, defaulting to Alt, is held\ndown. Can serve as a visual hint that rectangular selection is\ngoing to happen when paired with\n[`rectangularSelection`](https://codemirror.net/6/docs/ref/#view.rectangularSelection).\n*/\nfunction crosshairCursor(options = {}) {\n let [code, getter] = keys[options.key || \"Alt\"];\n let plugin = ViewPlugin.fromClass(class {\n constructor(view) {\n this.view = view;\n this.isDown = false;\n }\n set(isDown) {\n if (this.isDown != isDown) {\n this.isDown = isDown;\n this.view.update([]);\n }\n }\n }, {\n eventHandlers: {\n keydown(e) {\n this.set(e.keyCode == code || getter(e));\n },\n keyup(e) {\n if (e.keyCode == code || !getter(e))\n this.set(false);\n },\n mousemove(e) {\n this.set(getter(e));\n }\n }\n });\n return [\n plugin,\n EditorView.contentAttributes.of(view => { var _a; return ((_a = view.plugin(plugin)) === null || _a === void 0 ? void 0 : _a.isDown) ? showCrosshair : null; })\n ];\n}\n\nconst Outside = \"-10000px\";\nclass TooltipViewManager {\n constructor(view, facet, createTooltipView) {\n this.facet = facet;\n this.createTooltipView = createTooltipView;\n this.input = view.state.facet(facet);\n this.tooltips = this.input.filter(t => t);\n this.tooltipViews = this.tooltips.map(createTooltipView);\n }\n update(update) {\n var _a;\n let input = update.state.facet(this.facet);\n let tooltips = input.filter(x => x);\n if (input === this.input) {\n for (let t of this.tooltipViews)\n if (t.update)\n t.update(update);\n return false;\n }\n let tooltipViews = [];\n for (let i = 0; i < tooltips.length; i++) {\n let tip = tooltips[i], known = -1;\n if (!tip)\n continue;\n for (let i = 0; i < this.tooltips.length; i++) {\n let other = this.tooltips[i];\n if (other && other.create == tip.create)\n known = i;\n }\n if (known < 0) {\n tooltipViews[i] = this.createTooltipView(tip);\n }\n else {\n let tooltipView = tooltipViews[i] = this.tooltipViews[known];\n if (tooltipView.update)\n tooltipView.update(update);\n }\n }\n for (let t of this.tooltipViews)\n if (tooltipViews.indexOf(t) < 0) {\n t.dom.remove();\n (_a = t.destroy) === null || _a === void 0 ? void 0 : _a.call(t);\n }\n this.input = input;\n this.tooltips = tooltips;\n this.tooltipViews = tooltipViews;\n return true;\n }\n}\n/**\nCreates an extension that configures tooltip behavior.\n*/\nfunction tooltips(config = {}) {\n return tooltipConfig.of(config);\n}\nfunction windowSpace(view) {\n let { win } = view;\n return { top: 0, left: 0, bottom: win.innerHeight, right: win.innerWidth };\n}\nconst tooltipConfig = /*@__PURE__*/Facet.define({\n combine: values => {\n var _a, _b, _c;\n return ({\n position: browser.ios ? \"absolute\" : ((_a = values.find(conf => conf.position)) === null || _a === void 0 ? void 0 : _a.position) || \"fixed\",\n parent: ((_b = values.find(conf => conf.parent)) === null || _b === void 0 ? void 0 : _b.parent) || null,\n tooltipSpace: ((_c = values.find(conf => conf.tooltipSpace)) === null || _c === void 0 ? void 0 : _c.tooltipSpace) || windowSpace,\n });\n }\n});\nconst knownHeight = /*@__PURE__*/new WeakMap();\nconst tooltipPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {\n constructor(view) {\n this.view = view;\n this.inView = true;\n this.madeAbsolute = false;\n this.lastTransaction = 0;\n this.measureTimeout = -1;\n let config = view.state.facet(tooltipConfig);\n this.position = config.position;\n this.parent = config.parent;\n this.classes = view.themeClasses;\n this.createContainer();\n this.measureReq = { read: this.readMeasure.bind(this), write: this.writeMeasure.bind(this), key: this };\n this.manager = new TooltipViewManager(view, showTooltip, t => this.createTooltip(t));\n this.intersectionObserver = typeof IntersectionObserver == \"function\" ? new IntersectionObserver(entries => {\n if (Date.now() > this.lastTransaction - 50 &&\n entries.length > 0 && entries[entries.length - 1].intersectionRatio < 1)\n this.measureSoon();\n }, { threshold: [1] }) : null;\n this.observeIntersection();\n view.win.addEventListener(\"resize\", this.measureSoon = this.measureSoon.bind(this));\n this.maybeMeasure();\n }\n createContainer() {\n if (this.parent) {\n this.container = document.createElement(\"div\");\n this.container.style.position = \"relative\";\n this.container.className = this.view.themeClasses;\n this.parent.appendChild(this.container);\n }\n else {\n this.container = this.view.dom;\n }\n }\n observeIntersection() {\n if (this.intersectionObserver) {\n this.intersectionObserver.disconnect();\n for (let tooltip of this.manager.tooltipViews)\n this.intersectionObserver.observe(tooltip.dom);\n }\n }\n measureSoon() {\n if (this.measureTimeout < 0)\n this.measureTimeout = setTimeout(() => {\n this.measureTimeout = -1;\n this.maybeMeasure();\n }, 50);\n }\n update(update) {\n if (update.transactions.length)\n this.lastTransaction = Date.now();\n let updated = this.manager.update(update);\n if (updated)\n this.observeIntersection();\n let shouldMeasure = updated || update.geometryChanged;\n let newConfig = update.state.facet(tooltipConfig);\n if (newConfig.position != this.position && !this.madeAbsolute) {\n this.position = newConfig.position;\n for (let t of this.manager.tooltipViews)\n t.dom.style.position = this.position;\n shouldMeasure = true;\n }\n if (newConfig.parent != this.parent) {\n if (this.parent)\n this.container.remove();\n this.parent = newConfig.parent;\n this.createContainer();\n for (let t of this.manager.tooltipViews)\n this.container.appendChild(t.dom);\n shouldMeasure = true;\n }\n else if (this.parent && this.view.themeClasses != this.classes) {\n this.classes = this.container.className = this.view.themeClasses;\n }\n if (shouldMeasure)\n this.maybeMeasure();\n }\n createTooltip(tooltip) {\n let tooltipView = tooltip.create(this.view);\n tooltipView.dom.classList.add(\"cm-tooltip\");\n if (tooltip.arrow && !tooltipView.dom.querySelector(\".cm-tooltip > .cm-tooltip-arrow\")) {\n let arrow = document.createElement(\"div\");\n arrow.className = \"cm-tooltip-arrow\";\n tooltipView.dom.appendChild(arrow);\n }\n tooltipView.dom.style.position = this.position;\n tooltipView.dom.style.top = Outside;\n this.container.appendChild(tooltipView.dom);\n if (tooltipView.mount)\n tooltipView.mount(this.view);\n return tooltipView;\n }\n destroy() {\n var _a, _b;\n this.view.win.removeEventListener(\"resize\", this.measureSoon);\n for (let tooltipView of this.manager.tooltipViews) {\n tooltipView.dom.remove();\n (_a = tooltipView.destroy) === null || _a === void 0 ? void 0 : _a.call(tooltipView);\n }\n (_b = this.intersectionObserver) === null || _b === void 0 ? void 0 : _b.disconnect();\n clearTimeout(this.measureTimeout);\n }\n readMeasure() {\n let editor = this.view.dom.getBoundingClientRect();\n let scaleX = 1, scaleY = 1, makeAbsolute = false;\n if (this.position == \"fixed\") {\n let views = this.manager.tooltipViews;\n // When the dialog's offset parent isn't the body, we are\n // probably in a transformed container, and should use absolute\n // positioning instead, since fixed positioning inside a\n // transform works in a very broken way.\n makeAbsolute = views.length > 0 && views[0].dom.offsetParent != this.container.ownerDocument.body;\n }\n if (makeAbsolute || this.position == \"absolute\") {\n if (this.parent) {\n let rect = this.parent.getBoundingClientRect();\n if (rect.width && rect.height) {\n scaleX = rect.width / this.parent.offsetWidth;\n scaleY = rect.height / this.parent.offsetHeight;\n }\n }\n else {\n ({ scaleX, scaleY } = this.view.viewState);\n }\n }\n return {\n editor,\n parent: this.parent ? this.container.getBoundingClientRect() : editor,\n pos: this.manager.tooltips.map((t, i) => {\n let tv = this.manager.tooltipViews[i];\n return tv.getCoords ? tv.getCoords(t.pos) : this.view.coordsAtPos(t.pos);\n }),\n size: this.manager.tooltipViews.map(({ dom }) => dom.getBoundingClientRect()),\n space: this.view.state.facet(tooltipConfig).tooltipSpace(this.view),\n scaleX, scaleY, makeAbsolute\n };\n }\n writeMeasure(measured) {\n var _a;\n if (measured.makeAbsolute) {\n this.madeAbsolute = true;\n this.position = \"absolute\";\n for (let t of this.manager.tooltipViews)\n t.dom.style.position = \"absolute\";\n }\n let { editor, space, scaleX, scaleY } = measured;\n let others = [];\n for (let i = 0; i < this.manager.tooltips.length; i++) {\n let tooltip = this.manager.tooltips[i], tView = this.manager.tooltipViews[i], { dom } = tView;\n let pos = measured.pos[i], size = measured.size[i];\n // Hide tooltips that are outside of the editor.\n if (!pos || pos.bottom <= Math.max(editor.top, space.top) ||\n pos.top >= Math.min(editor.bottom, space.bottom) ||\n pos.right < Math.max(editor.left, space.left) - .1 ||\n pos.left > Math.min(editor.right, space.right) + .1) {\n dom.style.top = Outside;\n continue;\n }\n let arrow = tooltip.arrow ? tView.dom.querySelector(\".cm-tooltip-arrow\") : null;\n let arrowHeight = arrow ? 7 /* Arrow.Size */ : 0;\n let width = size.right - size.left, height = (_a = knownHeight.get(tView)) !== null && _a !== void 0 ? _a : size.bottom - size.top;\n let offset = tView.offset || noOffset, ltr = this.view.textDirection == Direction.LTR;\n let left = size.width > space.right - space.left ? (ltr ? space.left : space.right - size.width)\n : ltr ? Math.min(pos.left - (arrow ? 14 /* Arrow.Offset */ : 0) + offset.x, space.right - width)\n : Math.max(space.left, pos.left - width + (arrow ? 14 /* Arrow.Offset */ : 0) - offset.x);\n let above = !!tooltip.above;\n if (!tooltip.strictSide && (above\n ? pos.top - (size.bottom - size.top) - offset.y < space.top\n : pos.bottom + (size.bottom - size.top) + offset.y > space.bottom) &&\n above == (space.bottom - pos.bottom > pos.top - space.top))\n above = !above;\n let spaceVert = (above ? pos.top - space.top : space.bottom - pos.bottom) - arrowHeight;\n if (spaceVert < height && tView.resize !== false) {\n if (spaceVert < this.view.defaultLineHeight) {\n dom.style.top = Outside;\n continue;\n }\n knownHeight.set(tView, height);\n dom.style.height = (height = spaceVert) / scaleY + \"px\";\n }\n else if (dom.style.height) {\n dom.style.height = \"\";\n }\n let top = above ? pos.top - height - arrowHeight - offset.y : pos.bottom + arrowHeight + offset.y;\n let right = left + width;\n if (tView.overlap !== true)\n for (let r of others)\n if (r.left < right && r.right > left && r.top < top + height && r.bottom > top)\n top = above ? r.top - height - 2 - arrowHeight : r.bottom + arrowHeight + 2;\n if (this.position == \"absolute\") {\n dom.style.top = (top - measured.parent.top) / scaleY + \"px\";\n dom.style.left = (left - measured.parent.left) / scaleX + \"px\";\n }\n else {\n dom.style.top = top / scaleY + \"px\";\n dom.style.left = left / scaleX + \"px\";\n }\n if (arrow) {\n let arrowLeft = pos.left + (ltr ? offset.x : -offset.x) - (left + 14 /* Arrow.Offset */ - 7 /* Arrow.Size */);\n arrow.style.left = arrowLeft / scaleX + \"px\";\n }\n if (tView.overlap !== true)\n others.push({ left, top, right, bottom: top + height });\n dom.classList.toggle(\"cm-tooltip-above\", above);\n dom.classList.toggle(\"cm-tooltip-below\", !above);\n if (tView.positioned)\n tView.positioned(measured.space);\n }\n }\n maybeMeasure() {\n if (this.manager.tooltips.length) {\n if (this.view.inView)\n this.view.requestMeasure(this.measureReq);\n if (this.inView != this.view.inView) {\n this.inView = this.view.inView;\n if (!this.inView)\n for (let tv of this.manager.tooltipViews)\n tv.dom.style.top = Outside;\n }\n }\n }\n}, {\n eventHandlers: {\n scroll() { this.maybeMeasure(); }\n }\n});\nconst baseTheme = /*@__PURE__*/EditorView.baseTheme({\n \".cm-tooltip\": {\n zIndex: 100,\n boxSizing: \"border-box\"\n },\n \"&light .cm-tooltip\": {\n border: \"1px solid #bbb\",\n backgroundColor: \"#f5f5f5\"\n },\n \"&light .cm-tooltip-section:not(:first-child)\": {\n borderTop: \"1px solid #bbb\",\n },\n \"&dark .cm-tooltip\": {\n backgroundColor: \"#333338\",\n color: \"white\"\n },\n \".cm-tooltip-arrow\": {\n height: `${7 /* Arrow.Size */}px`,\n width: `${7 /* Arrow.Size */ * 2}px`,\n position: \"absolute\",\n zIndex: -1,\n overflow: \"hidden\",\n \"&:before, &:after\": {\n content: \"''\",\n position: \"absolute\",\n width: 0,\n height: 0,\n borderLeft: `${7 /* Arrow.Size */}px solid transparent`,\n borderRight: `${7 /* Arrow.Size */}px solid transparent`,\n },\n \".cm-tooltip-above &\": {\n bottom: `-${7 /* Arrow.Size */}px`,\n \"&:before\": {\n borderTop: `${7 /* Arrow.Size */}px solid #bbb`,\n },\n \"&:after\": {\n borderTop: `${7 /* Arrow.Size */}px solid #f5f5f5`,\n bottom: \"1px\"\n }\n },\n \".cm-tooltip-below &\": {\n top: `-${7 /* Arrow.Size */}px`,\n \"&:before\": {\n borderBottom: `${7 /* Arrow.Size */}px solid #bbb`,\n },\n \"&:after\": {\n borderBottom: `${7 /* Arrow.Size */}px solid #f5f5f5`,\n top: \"1px\"\n }\n },\n },\n \"&dark .cm-tooltip .cm-tooltip-arrow\": {\n \"&:before\": {\n borderTopColor: \"#333338\",\n borderBottomColor: \"#333338\"\n },\n \"&:after\": {\n borderTopColor: \"transparent\",\n borderBottomColor: \"transparent\"\n }\n }\n});\nconst noOffset = { x: 0, y: 0 };\n/**\nFacet to which an extension can add a value to show a tooltip.\n*/\nconst showTooltip = /*@__PURE__*/Facet.define({\n enables: [tooltipPlugin, baseTheme]\n});\nconst showHoverTooltip = /*@__PURE__*/Facet.define();\nclass HoverTooltipHost {\n // Needs to be static so that host tooltip instances always match\n static create(view) {\n return new HoverTooltipHost(view);\n }\n constructor(view) {\n this.view = view;\n this.mounted = false;\n this.dom = document.createElement(\"div\");\n this.dom.classList.add(\"cm-tooltip-hover\");\n this.manager = new TooltipViewManager(view, showHoverTooltip, t => this.createHostedView(t));\n }\n createHostedView(tooltip) {\n let hostedView = tooltip.create(this.view);\n hostedView.dom.classList.add(\"cm-tooltip-section\");\n this.dom.appendChild(hostedView.dom);\n if (this.mounted && hostedView.mount)\n hostedView.mount(this.view);\n return hostedView;\n }\n mount(view) {\n for (let hostedView of this.manager.tooltipViews) {\n if (hostedView.mount)\n hostedView.mount(view);\n }\n this.mounted = true;\n }\n positioned(space) {\n for (let hostedView of this.manager.tooltipViews) {\n if (hostedView.positioned)\n hostedView.positioned(space);\n }\n }\n update(update) {\n this.manager.update(update);\n }\n destroy() {\n var _a;\n for (let t of this.manager.tooltipViews)\n (_a = t.destroy) === null || _a === void 0 ? void 0 : _a.call(t);\n }\n}\nconst showHoverTooltipHost = /*@__PURE__*/showTooltip.compute([showHoverTooltip], state => {\n let tooltips = state.facet(showHoverTooltip).filter(t => t);\n if (tooltips.length === 0)\n return null;\n return {\n pos: Math.min(...tooltips.map(t => t.pos)),\n end: Math.max(...tooltips.filter(t => t.end != null).map(t => t.end)),\n create: HoverTooltipHost.create,\n above: tooltips[0].above,\n arrow: tooltips.some(t => t.arrow),\n };\n});\nclass HoverPlugin {\n constructor(view, source, field, setHover, hoverTime) {\n this.view = view;\n this.source = source;\n this.field = field;\n this.setHover = setHover;\n this.hoverTime = hoverTime;\n this.hoverTimeout = -1;\n this.restartTimeout = -1;\n this.pending = null;\n this.lastMove = { x: 0, y: 0, target: view.dom, time: 0 };\n this.checkHover = this.checkHover.bind(this);\n view.dom.addEventListener(\"mouseleave\", this.mouseleave = this.mouseleave.bind(this));\n view.dom.addEventListener(\"mousemove\", this.mousemove = this.mousemove.bind(this));\n }\n update() {\n if (this.pending) {\n this.pending = null;\n clearTimeout(this.restartTimeout);\n this.restartTimeout = setTimeout(() => this.startHover(), 20);\n }\n }\n get active() {\n return this.view.state.field(this.field);\n }\n checkHover() {\n this.hoverTimeout = -1;\n if (this.active)\n return;\n let hovered = Date.now() - this.lastMove.time;\n if (hovered < this.hoverTime)\n this.hoverTimeout = setTimeout(this.checkHover, this.hoverTime - hovered);\n else\n this.startHover();\n }\n startHover() {\n clearTimeout(this.restartTimeout);\n let { view, lastMove } = this;\n let desc = view.docView.nearest(lastMove.target);\n if (!desc)\n return;\n let pos, side = 1;\n if (desc instanceof WidgetView) {\n pos = desc.posAtStart;\n }\n else {\n pos = view.posAtCoords(lastMove);\n if (pos == null)\n return;\n let posCoords = view.coordsAtPos(pos);\n if (!posCoords ||\n lastMove.y < posCoords.top || lastMove.y > posCoords.bottom ||\n lastMove.x < posCoords.left - view.defaultCharacterWidth ||\n lastMove.x > posCoords.right + view.defaultCharacterWidth)\n return;\n let bidi = view.bidiSpans(view.state.doc.lineAt(pos)).find(s => s.from <= pos && s.to >= pos);\n let rtl = bidi && bidi.dir == Direction.RTL ? -1 : 1;\n side = (lastMove.x < posCoords.left ? -rtl : rtl);\n }\n let open = this.source(view, pos, side);\n if (open === null || open === void 0 ? void 0 : open.then) {\n let pending = this.pending = { pos };\n open.then(result => {\n if (this.pending == pending) {\n this.pending = null;\n if (result)\n view.dispatch({ effects: this.setHover.of(result) });\n }\n }, e => logException(view.state, e, \"hover tooltip\"));\n }\n else if (open) {\n view.dispatch({ effects: this.setHover.of(open) });\n }\n }\n mousemove(event) {\n var _a;\n this.lastMove = { x: event.clientX, y: event.clientY, target: event.target, time: Date.now() };\n if (this.hoverTimeout < 0)\n this.hoverTimeout = setTimeout(this.checkHover, this.hoverTime);\n let tooltip = this.active;\n if (tooltip && !isInTooltip(this.lastMove.target) || this.pending) {\n let { pos } = tooltip || this.pending, end = (_a = tooltip === null || tooltip === void 0 ? void 0 : tooltip.end) !== null && _a !== void 0 ? _a : pos;\n if ((pos == end ? this.view.posAtCoords(this.lastMove) != pos\n : !isOverRange(this.view, pos, end, event.clientX, event.clientY))) {\n this.view.dispatch({ effects: this.setHover.of(null) });\n this.pending = null;\n }\n }\n }\n mouseleave(e) {\n clearTimeout(this.hoverTimeout);\n this.hoverTimeout = -1;\n if (this.active && !isInTooltip(e.relatedTarget))\n this.view.dispatch({ effects: this.setHover.of(null) });\n }\n destroy() {\n clearTimeout(this.hoverTimeout);\n this.view.dom.removeEventListener(\"mouseleave\", this.mouseleave);\n this.view.dom.removeEventListener(\"mousemove\", this.mousemove);\n }\n}\nfunction isInTooltip(elt) {\n for (let cur = elt; cur; cur = cur.parentNode)\n if (cur.nodeType == 1 && cur.classList.contains(\"cm-tooltip\"))\n return true;\n return false;\n}\nfunction isOverRange(view, from, to, x, y, margin) {\n let rect = view.scrollDOM.getBoundingClientRect();\n let docBottom = view.documentTop + view.documentPadding.top + view.contentHeight;\n if (rect.left > x || rect.right < x || rect.top > y || Math.min(rect.bottom, docBottom) < y)\n return false;\n let pos = view.posAtCoords({ x, y }, false);\n return pos >= from && pos <= to;\n}\n/**\nSet up a hover tooltip, which shows up when the pointer hovers\nover ranges of text. The callback is called when the mouse hovers\nover the document text. It should, if there is a tooltip\nassociated with position `pos`, return the tooltip description\n(either directly or in a promise). The `side` argument indicates\non which side of the position the pointer is—it will be -1 if the\npointer is before the position, 1 if after the position.\n\nNote that all hover tooltips are hosted within a single tooltip\ncontainer element. This allows multiple tooltips over the same\nrange to be \"merged\" together without overlapping.\n*/\nfunction hoverTooltip(source, options = {}) {\n let setHover = StateEffect.define();\n let hoverState = StateField.define({\n create() { return null; },\n update(value, tr) {\n if (value && (options.hideOnChange && (tr.docChanged || tr.selection) ||\n options.hideOn && options.hideOn(tr, value)))\n return null;\n if (value && tr.docChanged) {\n let newPos = tr.changes.mapPos(value.pos, -1, MapMode.TrackDel);\n if (newPos == null)\n return null;\n let copy = Object.assign(Object.create(null), value);\n copy.pos = newPos;\n if (value.end != null)\n copy.end = tr.changes.mapPos(value.end);\n value = copy;\n }\n for (let effect of tr.effects) {\n if (effect.is(setHover))\n value = effect.value;\n if (effect.is(closeHoverTooltipEffect))\n value = null;\n }\n return value;\n },\n provide: f => showHoverTooltip.from(f)\n });\n return [\n hoverState,\n ViewPlugin.define(view => new HoverPlugin(view, source, hoverState, setHover, options.hoverTime || 300 /* Hover.Time */)),\n showHoverTooltipHost\n ];\n}\n/**\nGet the active tooltip view for a given tooltip, if available.\n*/\nfunction getTooltip(view, tooltip) {\n let plugin = view.plugin(tooltipPlugin);\n if (!plugin)\n return null;\n let found = plugin.manager.tooltips.indexOf(tooltip);\n return found < 0 ? null : plugin.manager.tooltipViews[found];\n}\n/**\nReturns true if any hover tooltips are currently active.\n*/\nfunction hasHoverTooltips(state) {\n return state.facet(showHoverTooltip).some(x => x);\n}\nconst closeHoverTooltipEffect = /*@__PURE__*/StateEffect.define();\n/**\nTransaction effect that closes all hover tooltips.\n*/\nconst closeHoverTooltips = /*@__PURE__*/closeHoverTooltipEffect.of(null);\n/**\nTell the tooltip extension to recompute the position of the active\ntooltips. This can be useful when something happens (such as a\nre-positioning or CSS change affecting the editor) that could\ninvalidate the existing tooltip positions.\n*/\nfunction repositionTooltips(view) {\n var _a;\n (_a = view.plugin(tooltipPlugin)) === null || _a === void 0 ? void 0 : _a.maybeMeasure();\n}\n\nconst panelConfig = /*@__PURE__*/Facet.define({\n combine(configs) {\n let topContainer, bottomContainer;\n for (let c of configs) {\n topContainer = topContainer || c.topContainer;\n bottomContainer = bottomContainer || c.bottomContainer;\n }\n return { topContainer, bottomContainer };\n }\n});\n/**\nConfigures the panel-managing extension.\n*/\nfunction panels(config) {\n return config ? [panelConfig.of(config)] : [];\n}\n/**\nGet the active panel created by the given constructor, if any.\nThis can be useful when you need access to your panels' DOM\nstructure.\n*/\nfunction getPanel(view, panel) {\n let plugin = view.plugin(panelPlugin);\n let index = plugin ? plugin.specs.indexOf(panel) : -1;\n return index > -1 ? plugin.panels[index] : null;\n}\nconst panelPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {\n constructor(view) {\n this.input = view.state.facet(showPanel);\n this.specs = this.input.filter(s => s);\n this.panels = this.specs.map(spec => spec(view));\n let conf = view.state.facet(panelConfig);\n this.top = new PanelGroup(view, true, conf.topContainer);\n this.bottom = new PanelGroup(view, false, conf.bottomContainer);\n this.top.sync(this.panels.filter(p => p.top));\n this.bottom.sync(this.panels.filter(p => !p.top));\n for (let p of this.panels) {\n p.dom.classList.add(\"cm-panel\");\n if (p.mount)\n p.mount();\n }\n }\n update(update) {\n let conf = update.state.facet(panelConfig);\n if (this.top.container != conf.topContainer) {\n this.top.sync([]);\n this.top = new PanelGroup(update.view, true, conf.topContainer);\n }\n if (this.bottom.container != conf.bottomContainer) {\n this.bottom.sync([]);\n this.bottom = new PanelGroup(update.view, false, conf.bottomContainer);\n }\n this.top.syncClasses();\n this.bottom.syncClasses();\n let input = update.state.facet(showPanel);\n if (input != this.input) {\n let specs = input.filter(x => x);\n let panels = [], top = [], bottom = [], mount = [];\n for (let spec of specs) {\n let known = this.specs.indexOf(spec), panel;\n if (known < 0) {\n panel = spec(update.view);\n mount.push(panel);\n }\n else {\n panel = this.panels[known];\n if (panel.update)\n panel.update(update);\n }\n panels.push(panel);\n (panel.top ? top : bottom).push(panel);\n }\n this.specs = specs;\n this.panels = panels;\n this.top.sync(top);\n this.bottom.sync(bottom);\n for (let p of mount) {\n p.dom.classList.add(\"cm-panel\");\n if (p.mount)\n p.mount();\n }\n }\n else {\n for (let p of this.panels)\n if (p.update)\n p.update(update);\n }\n }\n destroy() {\n this.top.sync([]);\n this.bottom.sync([]);\n }\n}, {\n provide: plugin => EditorView.scrollMargins.of(view => {\n let value = view.plugin(plugin);\n return value && { top: value.top.scrollMargin(), bottom: value.bottom.scrollMargin() };\n })\n});\nclass PanelGroup {\n constructor(view, top, container) {\n this.view = view;\n this.top = top;\n this.container = container;\n this.dom = undefined;\n this.classes = \"\";\n this.panels = [];\n this.syncClasses();\n }\n sync(panels) {\n for (let p of this.panels)\n if (p.destroy && panels.indexOf(p) < 0)\n p.destroy();\n this.panels = panels;\n this.syncDOM();\n }\n syncDOM() {\n if (this.panels.length == 0) {\n if (this.dom) {\n this.dom.remove();\n this.dom = undefined;\n }\n return;\n }\n if (!this.dom) {\n this.dom = document.createElement(\"div\");\n this.dom.className = this.top ? \"cm-panels cm-panels-top\" : \"cm-panels cm-panels-bottom\";\n this.dom.style[this.top ? \"top\" : \"bottom\"] = \"0\";\n let parent = this.container || this.view.dom;\n parent.insertBefore(this.dom, this.top ? parent.firstChild : null);\n }\n let curDOM = this.dom.firstChild;\n for (let panel of this.panels) {\n if (panel.dom.parentNode == this.dom) {\n while (curDOM != panel.dom)\n curDOM = rm(curDOM);\n curDOM = curDOM.nextSibling;\n }\n else {\n this.dom.insertBefore(panel.dom, curDOM);\n }\n }\n while (curDOM)\n curDOM = rm(curDOM);\n }\n scrollMargin() {\n return !this.dom || this.container ? 0\n : Math.max(0, this.top ?\n this.dom.getBoundingClientRect().bottom - Math.max(0, this.view.scrollDOM.getBoundingClientRect().top) :\n Math.min(innerHeight, this.view.scrollDOM.getBoundingClientRect().bottom) - this.dom.getBoundingClientRect().top);\n }\n syncClasses() {\n if (!this.container || this.classes == this.view.themeClasses)\n return;\n for (let cls of this.classes.split(\" \"))\n if (cls)\n this.container.classList.remove(cls);\n for (let cls of (this.classes = this.view.themeClasses).split(\" \"))\n if (cls)\n this.container.classList.add(cls);\n }\n}\nfunction rm(node) {\n let next = node.nextSibling;\n node.remove();\n return next;\n}\n/**\nOpening a panel is done by providing a constructor function for\nthe panel through this facet. (The panel is closed again when its\nconstructor is no longer provided.) Values of `null` are ignored.\n*/\nconst showPanel = /*@__PURE__*/Facet.define({\n enables: panelPlugin\n});\n\n/**\nA gutter marker represents a bit of information attached to a line\nin a specific gutter. Your own custom markers have to extend this\nclass.\n*/\nclass GutterMarker extends RangeValue {\n /**\n @internal\n */\n compare(other) {\n return this == other || this.constructor == other.constructor && this.eq(other);\n }\n /**\n Compare this marker to another marker of the same type.\n */\n eq(other) { return false; }\n /**\n Called if the marker has a `toDOM` method and its representation\n was removed from a gutter.\n */\n destroy(dom) { }\n}\nGutterMarker.prototype.elementClass = \"\";\nGutterMarker.prototype.toDOM = undefined;\nGutterMarker.prototype.mapMode = MapMode.TrackBefore;\nGutterMarker.prototype.startSide = GutterMarker.prototype.endSide = -1;\nGutterMarker.prototype.point = true;\n/**\nFacet used to add a class to all gutter elements for a given line.\nMarkers given to this facet should _only_ define an\n[`elementclass`](https://codemirror.net/6/docs/ref/#view.GutterMarker.elementClass), not a\n[`toDOM`](https://codemirror.net/6/docs/ref/#view.GutterMarker.toDOM) (or the marker will appear\nin all gutters for the line).\n*/\nconst gutterLineClass = /*@__PURE__*/Facet.define();\nconst defaults = {\n class: \"\",\n renderEmptyElements: false,\n elementStyle: \"\",\n markers: () => RangeSet.empty,\n lineMarker: () => null,\n widgetMarker: () => null,\n lineMarkerChange: null,\n initialSpacer: null,\n updateSpacer: null,\n domEventHandlers: {}\n};\nconst activeGutters = /*@__PURE__*/Facet.define();\n/**\nDefine an editor gutter. The order in which the gutters appear is\ndetermined by their extension priority.\n*/\nfunction gutter(config) {\n return [gutters(), activeGutters.of(Object.assign(Object.assign({}, defaults), config))];\n}\nconst unfixGutters = /*@__PURE__*/Facet.define({\n combine: values => values.some(x => x)\n});\n/**\nThe gutter-drawing plugin is automatically enabled when you add a\ngutter, but you can use this function to explicitly configure it.\n\nUnless `fixed` is explicitly set to `false`, the gutters are\nfixed, meaning they don't scroll along with the content\nhorizontally (except on Internet Explorer, which doesn't support\nCSS [`position:\nsticky`](https://developer.mozilla.org/en-US/docs/Web/CSS/position#sticky)).\n*/\nfunction gutters(config) {\n let result = [\n gutterView,\n ];\n if (config && config.fixed === false)\n result.push(unfixGutters.of(true));\n return result;\n}\nconst gutterView = /*@__PURE__*/ViewPlugin.fromClass(class {\n constructor(view) {\n this.view = view;\n this.prevViewport = view.viewport;\n this.dom = document.createElement(\"div\");\n this.dom.className = \"cm-gutters\";\n this.dom.setAttribute(\"aria-hidden\", \"true\");\n this.dom.style.minHeight = (this.view.contentHeight / this.view.scaleY) + \"px\";\n this.gutters = view.state.facet(activeGutters).map(conf => new SingleGutterView(view, conf));\n for (let gutter of this.gutters)\n this.dom.appendChild(gutter.dom);\n this.fixed = !view.state.facet(unfixGutters);\n if (this.fixed) {\n // FIXME IE11 fallback, which doesn't support position: sticky,\n // by using position: relative + event handlers that realign the\n // gutter (or just force fixed=false on IE11?)\n this.dom.style.position = \"sticky\";\n }\n this.syncGutters(false);\n view.scrollDOM.insertBefore(this.dom, view.contentDOM);\n }\n update(update) {\n if (this.updateGutters(update)) {\n // Detach during sync when the viewport changed significantly\n // (such as during scrolling), since for large updates that is\n // faster.\n let vpA = this.prevViewport, vpB = update.view.viewport;\n let vpOverlap = Math.min(vpA.to, vpB.to) - Math.max(vpA.from, vpB.from);\n this.syncGutters(vpOverlap < (vpB.to - vpB.from) * 0.8);\n }\n if (update.geometryChanged)\n this.dom.style.minHeight = this.view.contentHeight + \"px\";\n if (this.view.state.facet(unfixGutters) != !this.fixed) {\n this.fixed = !this.fixed;\n this.dom.style.position = this.fixed ? \"sticky\" : \"\";\n }\n this.prevViewport = update.view.viewport;\n }\n syncGutters(detach) {\n let after = this.dom.nextSibling;\n if (detach)\n this.dom.remove();\n let lineClasses = RangeSet.iter(this.view.state.facet(gutterLineClass), this.view.viewport.from);\n let classSet = [];\n let contexts = this.gutters.map(gutter => new UpdateContext(gutter, this.view.viewport, -this.view.documentPadding.top));\n for (let line of this.view.viewportLineBlocks) {\n if (classSet.length)\n classSet = [];\n if (Array.isArray(line.type)) {\n let first = true;\n for (let b of line.type) {\n if (b.type == BlockType.Text && first) {\n advanceCursor(lineClasses, classSet, b.from);\n for (let cx of contexts)\n cx.line(this.view, b, classSet);\n first = false;\n }\n else if (b.widget) {\n for (let cx of contexts)\n cx.widget(this.view, b);\n }\n }\n }\n else if (line.type == BlockType.Text) {\n advanceCursor(lineClasses, classSet, line.from);\n for (let cx of contexts)\n cx.line(this.view, line, classSet);\n }\n else if (line.widget) {\n for (let cx of contexts)\n cx.widget(this.view, line);\n }\n }\n for (let cx of contexts)\n cx.finish();\n if (detach)\n this.view.scrollDOM.insertBefore(this.dom, after);\n }\n updateGutters(update) {\n let prev = update.startState.facet(activeGutters), cur = update.state.facet(activeGutters);\n let change = update.docChanged || update.heightChanged || update.viewportChanged ||\n !RangeSet.eq(update.startState.facet(gutterLineClass), update.state.facet(gutterLineClass), update.view.viewport.from, update.view.viewport.to);\n if (prev == cur) {\n for (let gutter of this.gutters)\n if (gutter.update(update))\n change = true;\n }\n else {\n change = true;\n let gutters = [];\n for (let conf of cur) {\n let known = prev.indexOf(conf);\n if (known < 0) {\n gutters.push(new SingleGutterView(this.view, conf));\n }\n else {\n this.gutters[known].update(update);\n gutters.push(this.gutters[known]);\n }\n }\n for (let g of this.gutters) {\n g.dom.remove();\n if (gutters.indexOf(g) < 0)\n g.destroy();\n }\n for (let g of gutters)\n this.dom.appendChild(g.dom);\n this.gutters = gutters;\n }\n return change;\n }\n destroy() {\n for (let view of this.gutters)\n view.destroy();\n this.dom.remove();\n }\n}, {\n provide: plugin => EditorView.scrollMargins.of(view => {\n let value = view.plugin(plugin);\n if (!value || value.gutters.length == 0 || !value.fixed)\n return null;\n return view.textDirection == Direction.LTR\n ? { left: value.dom.offsetWidth * view.scaleX }\n : { right: value.dom.offsetWidth * view.scaleX };\n })\n});\nfunction asArray(val) { return (Array.isArray(val) ? val : [val]); }\nfunction advanceCursor(cursor, collect, pos) {\n while (cursor.value && cursor.from <= pos) {\n if (cursor.from == pos)\n collect.push(cursor.value);\n cursor.next();\n }\n}\nclass UpdateContext {\n constructor(gutter, viewport, height) {\n this.gutter = gutter;\n this.height = height;\n this.i = 0;\n this.cursor = RangeSet.iter(gutter.markers, viewport.from);\n }\n addElement(view, block, markers) {\n let { gutter } = this, above = block.top - this.height;\n if (this.i == gutter.elements.length) {\n let newElt = new GutterElement(view, block.height, above, markers);\n gutter.elements.push(newElt);\n gutter.dom.appendChild(newElt.dom);\n }\n else {\n gutter.elements[this.i].update(view, block.height, above, markers);\n }\n this.height = block.bottom;\n this.i++;\n }\n line(view, line, extraMarkers) {\n let localMarkers = [];\n advanceCursor(this.cursor, localMarkers, line.from);\n if (extraMarkers.length)\n localMarkers = localMarkers.concat(extraMarkers);\n let forLine = this.gutter.config.lineMarker(view, line, localMarkers);\n if (forLine)\n localMarkers.unshift(forLine);\n let gutter = this.gutter;\n if (localMarkers.length == 0 && !gutter.config.renderEmptyElements)\n return;\n this.addElement(view, line, localMarkers);\n }\n widget(view, block) {\n let marker = this.gutter.config.widgetMarker(view, block.widget, block);\n if (marker)\n this.addElement(view, block, [marker]);\n }\n finish() {\n let gutter = this.gutter;\n while (gutter.elements.length > this.i) {\n let last = gutter.elements.pop();\n gutter.dom.removeChild(last.dom);\n last.destroy();\n }\n }\n}\nclass SingleGutterView {\n constructor(view, config) {\n this.view = view;\n this.config = config;\n this.elements = [];\n this.spacer = null;\n this.dom = document.createElement(\"div\");\n this.dom.className = \"cm-gutter\" + (this.config.class ? \" \" + this.config.class : \"\");\n for (let prop in config.domEventHandlers) {\n this.dom.addEventListener(prop, (event) => {\n let target = event.target, y;\n if (target != this.dom && this.dom.contains(target)) {\n while (target.parentNode != this.dom)\n target = target.parentNode;\n let rect = target.getBoundingClientRect();\n y = (rect.top + rect.bottom) / 2;\n }\n else {\n y = event.clientY;\n }\n let line = view.lineBlockAtHeight(y - view.documentTop);\n if (config.domEventHandlers[prop](view, line, event))\n event.preventDefault();\n });\n }\n this.markers = asArray(config.markers(view));\n if (config.initialSpacer) {\n this.spacer = new GutterElement(view, 0, 0, [config.initialSpacer(view)]);\n this.dom.appendChild(this.spacer.dom);\n this.spacer.dom.style.cssText += \"visibility: hidden; pointer-events: none\";\n }\n }\n update(update) {\n let prevMarkers = this.markers;\n this.markers = asArray(this.config.markers(update.view));\n if (this.spacer && this.config.updateSpacer) {\n let updated = this.config.updateSpacer(this.spacer.markers[0], update);\n if (updated != this.spacer.markers[0])\n this.spacer.update(update.view, 0, 0, [updated]);\n }\n let vp = update.view.viewport;\n return !RangeSet.eq(this.markers, prevMarkers, vp.from, vp.to) ||\n (this.config.lineMarkerChange ? this.config.lineMarkerChange(update) : false);\n }\n destroy() {\n for (let elt of this.elements)\n elt.destroy();\n }\n}\nclass GutterElement {\n constructor(view, height, above, markers) {\n this.height = -1;\n this.above = 0;\n this.markers = [];\n this.dom = document.createElement(\"div\");\n this.dom.className = \"cm-gutterElement\";\n this.update(view, height, above, markers);\n }\n update(view, height, above, markers) {\n if (this.height != height) {\n this.height = height;\n this.dom.style.height = height / view.scaleY + \"px\";\n }\n if (this.above != above)\n this.dom.style.marginTop = (this.above = above) ? above / view.scaleY + \"px\" : \"\";\n if (!sameMarkers(this.markers, markers))\n this.setMarkers(view, markers);\n }\n setMarkers(view, markers) {\n let cls = \"cm-gutterElement\", domPos = this.dom.firstChild;\n for (let iNew = 0, iOld = 0;;) {\n let skipTo = iOld, marker = iNew < markers.length ? markers[iNew++] : null, matched = false;\n if (marker) {\n let c = marker.elementClass;\n if (c)\n cls += \" \" + c;\n for (let i = iOld; i < this.markers.length; i++)\n if (this.markers[i].compare(marker)) {\n skipTo = i;\n matched = true;\n break;\n }\n }\n else {\n skipTo = this.markers.length;\n }\n while (iOld < skipTo) {\n let next = this.markers[iOld++];\n if (next.toDOM) {\n next.destroy(domPos);\n let after = domPos.nextSibling;\n domPos.remove();\n domPos = after;\n }\n }\n if (!marker)\n break;\n if (marker.toDOM) {\n if (matched)\n domPos = domPos.nextSibling;\n else\n this.dom.insertBefore(marker.toDOM(view), domPos);\n }\n if (matched)\n iOld++;\n }\n this.dom.className = cls;\n this.markers = markers;\n }\n destroy() {\n this.setMarkers(null, []); // First argument not used unless creating markers\n }\n}\nfunction sameMarkers(a, b) {\n if (a.length != b.length)\n return false;\n for (let i = 0; i < a.length; i++)\n if (!a[i].compare(b[i]))\n return false;\n return true;\n}\n/**\nFacet used to provide markers to the line number gutter.\n*/\nconst lineNumberMarkers = /*@__PURE__*/Facet.define();\nconst lineNumberConfig = /*@__PURE__*/Facet.define({\n combine(values) {\n return combineConfig(values, { formatNumber: String, domEventHandlers: {} }, {\n domEventHandlers(a, b) {\n let result = Object.assign({}, a);\n for (let event in b) {\n let exists = result[event], add = b[event];\n result[event] = exists ? (view, line, event) => exists(view, line, event) || add(view, line, event) : add;\n }\n return result;\n }\n });\n }\n});\nclass NumberMarker extends GutterMarker {\n constructor(number) {\n super();\n this.number = number;\n }\n eq(other) { return this.number == other.number; }\n toDOM() { return document.createTextNode(this.number); }\n}\nfunction formatNumber(view, number) {\n return view.state.facet(lineNumberConfig).formatNumber(number, view.state);\n}\nconst lineNumberGutter = /*@__PURE__*/activeGutters.compute([lineNumberConfig], state => ({\n class: \"cm-lineNumbers\",\n renderEmptyElements: false,\n markers(view) { return view.state.facet(lineNumberMarkers); },\n lineMarker(view, line, others) {\n if (others.some(m => m.toDOM))\n return null;\n return new NumberMarker(formatNumber(view, view.state.doc.lineAt(line.from).number));\n },\n widgetMarker: () => null,\n lineMarkerChange: update => update.startState.facet(lineNumberConfig) != update.state.facet(lineNumberConfig),\n initialSpacer(view) {\n return new NumberMarker(formatNumber(view, maxLineNumber(view.state.doc.lines)));\n },\n updateSpacer(spacer, update) {\n let max = formatNumber(update.view, maxLineNumber(update.view.state.doc.lines));\n return max == spacer.number ? spacer : new NumberMarker(max);\n },\n domEventHandlers: state.facet(lineNumberConfig).domEventHandlers\n}));\n/**\nCreate a line number gutter extension.\n*/\nfunction lineNumbers(config = {}) {\n return [\n lineNumberConfig.of(config),\n gutters(),\n lineNumberGutter\n ];\n}\nfunction maxLineNumber(lines) {\n let last = 9;\n while (last < lines)\n last = last * 10 + 9;\n return last;\n}\nconst activeLineGutterMarker = /*@__PURE__*/new class extends GutterMarker {\n constructor() {\n super(...arguments);\n this.elementClass = \"cm-activeLineGutter\";\n }\n};\nconst activeLineGutterHighlighter = /*@__PURE__*/gutterLineClass.compute([\"selection\"], state => {\n let marks = [], last = -1;\n for (let range of state.selection.ranges) {\n let linePos = state.doc.lineAt(range.head).from;\n if (linePos > last) {\n last = linePos;\n marks.push(activeLineGutterMarker.range(linePos));\n }\n }\n return RangeSet.of(marks);\n});\n/**\nReturns an extension that adds a `cm-activeLineGutter` class to\nall gutter elements on the [active\nline](https://codemirror.net/6/docs/ref/#view.highlightActiveLine).\n*/\nfunction highlightActiveLineGutter() {\n return activeLineGutterHighlighter;\n}\n\nconst WhitespaceDeco = /*@__PURE__*/new Map();\nfunction getWhitespaceDeco(space) {\n let deco = WhitespaceDeco.get(space);\n if (!deco)\n WhitespaceDeco.set(space, deco = Decoration.mark({\n attributes: space === \"\\t\" ? {\n class: \"cm-highlightTab\",\n } : {\n class: \"cm-highlightSpace\",\n \"data-display\": space.replace(/ /g, \"·\")\n }\n }));\n return deco;\n}\nfunction matcher(decorator) {\n return ViewPlugin.define(view => ({\n decorations: decorator.createDeco(view),\n update(u) {\n this.decorations = decorator.updateDeco(u, this.decorations);\n },\n }), {\n decorations: v => v.decorations\n });\n}\nconst whitespaceHighlighter = /*@__PURE__*/matcher(/*@__PURE__*/new MatchDecorator({\n regexp: /\\t| +/g,\n decoration: match => getWhitespaceDeco(match[0]),\n boundary: /\\S/,\n}));\n/**\nReturns an extension that highlights whitespace, adding a\n`cm-highlightSpace` class to stretches of spaces, and a\n`cm-highlightTab` class to individual tab characters. By default,\nthe former are shown as faint dots, and the latter as arrows.\n*/\nfunction highlightWhitespace() {\n return whitespaceHighlighter;\n}\nconst trailingHighlighter = /*@__PURE__*/matcher(/*@__PURE__*/new MatchDecorator({\n regexp: /\\s+$/g,\n decoration: /*@__PURE__*/Decoration.mark({ class: \"cm-trailingSpace\" }),\n boundary: /\\S/,\n}));\n/**\nReturns an extension that adds a `cm-trailingSpace` class to all\ntrailing whitespace.\n*/\nfunction highlightTrailingWhitespace() {\n return trailingHighlighter;\n}\n\n/**\n@internal\n*/\nconst __test = { HeightMap, HeightOracle, MeasuredHeights, QueryType, ChangedRange, computeOrder, moveVisually };\n\nexport { BidiSpan, BlockInfo, BlockType, Decoration, Direction, EditorView, GutterMarker, MatchDecorator, RectangleMarker, ViewPlugin, ViewUpdate, WidgetType, __test, closeHoverTooltips, crosshairCursor, drawSelection, dropCursor, getPanel, getTooltip, gutter, gutterLineClass, gutters, hasHoverTooltips, highlightActiveLine, highlightActiveLineGutter, highlightSpecialChars, highlightTrailingWhitespace, highlightWhitespace, hoverTooltip, keymap, layer, lineNumberMarkers, lineNumbers, logException, panels, placeholder, rectangularSelection, repositionTooltips, runScopeHandlers, scrollPastEnd, showPanel, showTooltip, tooltips };\n","import { EditorState, Extension } from '@codemirror/state';\nimport { EditorView, lineNumbers } from '@codemirror/view';\n\n/**\n * @class CodeMirror\n */\nexport default class CodeMirror {\n\t/**\n\t * @constructor\n\t * @param {jQuery} $textarea Textarea to add syntax highlighting to.\n\t */\n\tconstructor( $textarea ) {\n\t\tthis.$textarea = $textarea;\n\t\tthis.view = null;\n\t\tthis.state = null;\n\t}\n\n\t/**\n\t * Extensions here should be applicable to all theoretical uses of CodeMirror in MediaWiki.\n\t * Don't assume CodeMirror is used for editing (i.e. \"View source\" of a protected page).\n\t * Subclasses are safe to override this method if needed.\n\t *\n\t * @return {Extension[]}\n\t */\n\tget defaultExtensions() {\n\t\tconst extensions = [];\n\t\tconst namespaces = mw.config.get( 'wgCodeMirrorLineNumberingNamespaces' );\n\n\t\t// Set to [] to disable everywhere, or null to enable everywhere\n\t\tif ( !namespaces || namespaces.includes( mw.config.get( 'wgNamespaceNumber' ) ) ) {\n\t\t\textensions.push( lineNumbers() );\n\t\t}\n\t\treturn extensions;\n\t}\n\n\t/**\n\t * Setup CodeMirror and add it to the DOM. This will hide the original textarea.\n\t *\n\t * @param {Extension[]} extensions\n\t */\n\tinitialize( extensions = this.defaultExtensions ) {\n\t\t// Set up the initial EditorState of CodeMirror with contents of the native textarea.\n\t\tthis.state = EditorState.create( {\n\t\t\tdoc: this.$textarea.textSelection( 'getContents' ),\n\t\t\textensions\n\t\t} );\n\n\t\t// Add CodeMirror view to the DOM.\n\t\tthis.view = new EditorView( {\n\t\t\tstate: this.state,\n\t\t\tparent: this.$textarea.parent()[ 0 ]\n\t\t} );\n\n\t\t// Hide native textarea and sync CodeMirror contents upon submission.\n\t\tthis.$textarea.hide();\n\t\tif ( this.$textarea[ 0 ].form ) {\n\t\t\tthis.$textarea[ 0 ].form.addEventListener( 'submit', () => {\n\t\t\t\tthis.$textarea.val( this.view.state.doc.toString() );\n\t\t\t} );\n\t\t}\n\n\t\t// Register $.textSelection() on the .cm-editor element.\n\t\t$( this.view.dom ).textSelection( 'register', this.cmTextSelection );\n\t\t// Also override textSelection() functions for the \"real\" hidden textarea to route to\n\t\t// CodeMirror. We unregister this when switching to normal textarea mode.\n\t\tthis.$textarea.textSelection( 'register', this.cmTextSelection );\n\n\t\tmw.hook( 'ext.CodeMirror.switch' ).fire( true, $( this.view.dom ) );\n\t}\n\n\t/**\n\t * Log usage of CodeMirror.\n\t *\n\t * @param {Object} data\n\t */\n\tlogUsage( data ) {\n\t\t/* eslint-disable camelcase */\n\t\tconst event = Object.assign( {\n\t\t\tsession_token: mw.user.sessionId(),\n\t\t\tuser_id: mw.user.getId()\n\t\t}, data );\n\t\tconst editCountBucket = mw.config.get( 'wgUserEditCountBucket' );\n\t\tif ( editCountBucket !== null ) {\n\t\t\tevent.user_edit_count_bucket = editCountBucket;\n\t\t}\n\t\t/* eslint-enable camelcase */\n\t\tmw.track( 'event.CodeMirrorUsage', event );\n\t}\n\n\t/**\n\t * Save CodeMirror enabled preference.\n\t *\n\t * @param {boolean} prefValue True, if CodeMirror should be enabled by default, otherwise false.\n\t */\n\tsetCodeMirrorPreference( prefValue ) {\n\t\tif ( !mw.user.isNamed() ) { // Skip it for unnamed users\n\t\t\treturn;\n\t\t}\n\t\tnew mw.Api().saveOption( 'usecodemirror', prefValue ? 1 : 0 );\n\t\tmw.user.options.set( 'usecodemirror', prefValue ? 1 : 0 );\n\t}\n\n\t/**\n\t * jQuery.textSelection overrides for CodeMirror.\n\t *\n\t * @see https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/jQuery.plugin.textSelection\n\t * @return {Object}\n\t */\n\tget cmTextSelection() {\n\t\tconst $cmDom = $( this.view.dom );\n\t\treturn {\n\t\t\tgetContents: () => this.view.state.doc.toString(),\n\t\t\tsetContents: ( content ) => {\n\t\t\t\tthis.view.dispatch( {\n\t\t\t\t\tchanges: {\n\t\t\t\t\t\tfrom: 0,\n\t\t\t\t\t\tto: this.view.state.doc.length,\n\t\t\t\t\t\tinsert: content\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t\treturn $cmDom;\n\t\t\t},\n\t\t\tgetSelection: () => {\n\t\t\t\treturn this.view.state.sliceDoc(\n\t\t\t\t\tthis.view.state.selection.main.from,\n\t\t\t\t\tthis.view.state.selection.main.to\n\t\t\t\t);\n\t\t\t},\n\t\t\tsetSelection: ( options = { start: 0, end: 0 } ) => {\n\t\t\t\tthis.view.dispatch( {\n\t\t\t\t\tselection: { anchor: options.start, head: ( options.end || options.start ) }\n\t\t\t\t} );\n\t\t\t\tthis.view.focus();\n\t\t\t\treturn $cmDom;\n\t\t\t},\n\t\t\treplaceSelection: ( value ) => {\n\t\t\t\tthis.view.dispatch(\n\t\t\t\t\tthis.view.state.replaceSelection( value )\n\t\t\t\t);\n\t\t\t\treturn $cmDom;\n\t\t\t},\n\t\t\tgetCaretPosition: ( options ) => {\n\t\t\t\tif ( !options.startAndEnd ) {\n\t\t\t\t\treturn this.view.state.selection.main.head;\n\t\t\t\t}\n\t\t\t\treturn [\n\t\t\t\t\tthis.view.state.selection.main.from,\n\t\t\t\t\tthis.view.state.selection.main.to\n\t\t\t\t];\n\t\t\t},\n\t\t\tscrollToCaretPosition: () => {\n\t\t\t\tthis.view.scrollIntoView( this.view.state.selection.main.head );\n\t\t\t\treturn $cmDom;\n\t\t\t}\n\t\t};\n\t}\n}\n","/**\nThe default maximum length of a `TreeBuffer` node.\n*/\nconst DefaultBufferLength = 1024;\nlet nextPropID = 0;\nclass Range {\n constructor(from, to) {\n this.from = from;\n this.to = to;\n }\n}\n/**\nEach [node type](#common.NodeType) or [individual tree](#common.Tree)\ncan have metadata associated with it in props. Instances of this\nclass represent prop names.\n*/\nclass NodeProp {\n /**\n Create a new node prop type.\n */\n constructor(config = {}) {\n this.id = nextPropID++;\n this.perNode = !!config.perNode;\n this.deserialize = config.deserialize || (() => {\n throw new Error(\"This node type doesn't define a deserialize function\");\n });\n }\n /**\n This is meant to be used with\n [`NodeSet.extend`](#common.NodeSet.extend) or\n [`LRParser.configure`](#lr.ParserConfig.props) to compute\n prop values for each node type in the set. Takes a [match\n object](#common.NodeType^match) or function that returns undefined\n if the node type doesn't get this prop, and the prop's value if\n it does.\n */\n add(match) {\n if (this.perNode)\n throw new RangeError(\"Can't add per-node props to node types\");\n if (typeof match != \"function\")\n match = NodeType.match(match);\n return (type) => {\n let result = match(type);\n return result === undefined ? null : [this, result];\n };\n }\n}\n/**\nProp that is used to describe matching delimiters. For opening\ndelimiters, this holds an array of node names (written as a\nspace-separated string when declaring this prop in a grammar)\nfor the node types of closing delimiters that match it.\n*/\nNodeProp.closedBy = new NodeProp({ deserialize: str => str.split(\" \") });\n/**\nThe inverse of [`closedBy`](#common.NodeProp^closedBy). This is\nattached to closing delimiters, holding an array of node names\nof types of matching opening delimiters.\n*/\nNodeProp.openedBy = new NodeProp({ deserialize: str => str.split(\" \") });\n/**\nUsed to assign node types to groups (for example, all node\ntypes that represent an expression could be tagged with an\n`\"Expression\"` group).\n*/\nNodeProp.group = new NodeProp({ deserialize: str => str.split(\" \") });\n/**\nThe hash of the [context](#lr.ContextTracker.constructor)\nthat the node was parsed in, if any. Used to limit reuse of\ncontextual nodes.\n*/\nNodeProp.contextHash = new NodeProp({ perNode: true });\n/**\nThe distance beyond the end of the node that the tokenizer\nlooked ahead for any of the tokens inside the node. (The LR\nparser only stores this when it is larger than 25, for\nefficiency reasons.)\n*/\nNodeProp.lookAhead = new NodeProp({ perNode: true });\n/**\nThis per-node prop is used to replace a given node, or part of a\nnode, with another tree. This is useful to include trees from\ndifferent languages in mixed-language parsers.\n*/\nNodeProp.mounted = new NodeProp({ perNode: true });\n/**\nA mounted tree, which can be [stored](#common.NodeProp^mounted) on\na tree node to indicate that parts of its content are\nrepresented by another tree.\n*/\nclass MountedTree {\n constructor(\n /**\n The inner tree.\n */\n tree, \n /**\n If this is null, this tree replaces the entire node (it will\n be included in the regular iteration instead of its host\n node). If not, only the given ranges are considered to be\n covered by this tree. This is used for trees that are mixed in\n a way that isn't strictly hierarchical. Such mounted trees are\n only entered by [`resolveInner`](#common.Tree.resolveInner)\n and [`enter`](#common.SyntaxNode.enter).\n */\n overlay, \n /**\n The parser used to create this subtree.\n */\n parser) {\n this.tree = tree;\n this.overlay = overlay;\n this.parser = parser;\n }\n /**\n @internal\n */\n static get(tree) {\n return tree && tree.props && tree.props[NodeProp.mounted.id];\n }\n}\nconst noProps = Object.create(null);\n/**\nEach node in a syntax tree has a node type associated with it.\n*/\nclass NodeType {\n /**\n @internal\n */\n constructor(\n /**\n The name of the node type. Not necessarily unique, but if the\n grammar was written properly, different node types with the\n same name within a node set should play the same semantic\n role.\n */\n name, \n /**\n @internal\n */\n props, \n /**\n The id of this node in its set. Corresponds to the term ids\n used in the parser.\n */\n id, \n /**\n @internal\n */\n flags = 0) {\n this.name = name;\n this.props = props;\n this.id = id;\n this.flags = flags;\n }\n /**\n Define a node type.\n */\n static define(spec) {\n let props = spec.props && spec.props.length ? Object.create(null) : noProps;\n let flags = (spec.top ? 1 /* NodeFlag.Top */ : 0) | (spec.skipped ? 2 /* NodeFlag.Skipped */ : 0) |\n (spec.error ? 4 /* NodeFlag.Error */ : 0) | (spec.name == null ? 8 /* NodeFlag.Anonymous */ : 0);\n let type = new NodeType(spec.name || \"\", props, spec.id, flags);\n if (spec.props)\n for (let src of spec.props) {\n if (!Array.isArray(src))\n src = src(type);\n if (src) {\n if (src[0].perNode)\n throw new RangeError(\"Can't store a per-node prop on a node type\");\n props[src[0].id] = src[1];\n }\n }\n return type;\n }\n /**\n Retrieves a node prop for this type. Will return `undefined` if\n the prop isn't present on this node.\n */\n prop(prop) { return this.props[prop.id]; }\n /**\n True when this is the top node of a grammar.\n */\n get isTop() { return (this.flags & 1 /* NodeFlag.Top */) > 0; }\n /**\n True when this node is produced by a skip rule.\n */\n get isSkipped() { return (this.flags & 2 /* NodeFlag.Skipped */) > 0; }\n /**\n Indicates whether this is an error node.\n */\n get isError() { return (this.flags & 4 /* NodeFlag.Error */) > 0; }\n /**\n When true, this node type doesn't correspond to a user-declared\n named node, for example because it is used to cache repetition.\n */\n get isAnonymous() { return (this.flags & 8 /* NodeFlag.Anonymous */) > 0; }\n /**\n Returns true when this node's name or one of its\n [groups](#common.NodeProp^group) matches the given string.\n */\n is(name) {\n if (typeof name == 'string') {\n if (this.name == name)\n return true;\n let group = this.prop(NodeProp.group);\n return group ? group.indexOf(name) > -1 : false;\n }\n return this.id == name;\n }\n /**\n Create a function from node types to arbitrary values by\n specifying an object whose property names are node or\n [group](#common.NodeProp^group) names. Often useful with\n [`NodeProp.add`](#common.NodeProp.add). You can put multiple\n names, separated by spaces, in a single property name to map\n multiple node names to a single value.\n */\n static match(map) {\n let direct = Object.create(null);\n for (let prop in map)\n for (let name of prop.split(\" \"))\n direct[name] = map[prop];\n return (node) => {\n for (let groups = node.prop(NodeProp.group), i = -1; i < (groups ? groups.length : 0); i++) {\n let found = direct[i < 0 ? node.name : groups[i]];\n if (found)\n return found;\n }\n };\n }\n}\n/**\nAn empty dummy node type to use when no actual type is available.\n*/\nNodeType.none = new NodeType(\"\", Object.create(null), 0, 8 /* NodeFlag.Anonymous */);\n/**\nA node set holds a collection of node types. It is used to\ncompactly represent trees by storing their type ids, rather than a\nfull pointer to the type object, in a numeric array. Each parser\n[has](#lr.LRParser.nodeSet) a node set, and [tree\nbuffers](#common.TreeBuffer) can only store collections of nodes\nfrom the same set. A set can have a maximum of 2**16 (65536) node\ntypes in it, so that the ids fit into 16-bit typed array slots.\n*/\nclass NodeSet {\n /**\n Create a set with the given types. The `id` property of each\n type should correspond to its position within the array.\n */\n constructor(\n /**\n The node types in this set, by id.\n */\n types) {\n this.types = types;\n for (let i = 0; i < types.length; i++)\n if (types[i].id != i)\n throw new RangeError(\"Node type ids should correspond to array positions when creating a node set\");\n }\n /**\n Create a copy of this set with some node properties added. The\n arguments to this method can be created with\n [`NodeProp.add`](#common.NodeProp.add).\n */\n extend(...props) {\n let newTypes = [];\n for (let type of this.types) {\n let newProps = null;\n for (let source of props) {\n let add = source(type);\n if (add) {\n if (!newProps)\n newProps = Object.assign({}, type.props);\n newProps[add[0].id] = add[1];\n }\n }\n newTypes.push(newProps ? new NodeType(type.name, newProps, type.id, type.flags) : type);\n }\n return new NodeSet(newTypes);\n }\n}\nconst CachedNode = new WeakMap(), CachedInnerNode = new WeakMap();\n/**\nOptions that control iteration. Can be combined with the `|`\noperator to enable multiple ones.\n*/\nvar IterMode;\n(function (IterMode) {\n /**\n When enabled, iteration will only visit [`Tree`](#common.Tree)\n objects, not nodes packed into\n [`TreeBuffer`](#common.TreeBuffer)s.\n */\n IterMode[IterMode[\"ExcludeBuffers\"] = 1] = \"ExcludeBuffers\";\n /**\n Enable this to make iteration include anonymous nodes (such as\n the nodes that wrap repeated grammar constructs into a balanced\n tree).\n */\n IterMode[IterMode[\"IncludeAnonymous\"] = 2] = \"IncludeAnonymous\";\n /**\n By default, regular [mounted](#common.NodeProp^mounted) nodes\n replace their base node in iteration. Enable this to ignore them\n instead.\n */\n IterMode[IterMode[\"IgnoreMounts\"] = 4] = \"IgnoreMounts\";\n /**\n This option only applies in\n [`enter`](#common.SyntaxNode.enter)-style methods. It tells the\n library to not enter mounted overlays if one covers the given\n position.\n */\n IterMode[IterMode[\"IgnoreOverlays\"] = 8] = \"IgnoreOverlays\";\n})(IterMode || (IterMode = {}));\n/**\nA piece of syntax tree. There are two ways to approach these\ntrees: the way they are actually stored in memory, and the\nconvenient way.\n\nSyntax trees are stored as a tree of `Tree` and `TreeBuffer`\nobjects. By packing detail information into `TreeBuffer` leaf\nnodes, the representation is made a lot more memory-efficient.\n\nHowever, when you want to actually work with tree nodes, this\nrepresentation is very awkward, so most client code will want to\nuse the [`TreeCursor`](#common.TreeCursor) or\n[`SyntaxNode`](#common.SyntaxNode) interface instead, which provides\na view on some part of this data structure, and can be used to\nmove around to adjacent nodes.\n*/\nclass Tree {\n /**\n Construct a new tree. See also [`Tree.build`](#common.Tree^build).\n */\n constructor(\n /**\n The type of the top node.\n */\n type, \n /**\n This node's child nodes.\n */\n children, \n /**\n The positions (offsets relative to the start of this tree) of\n the children.\n */\n positions, \n /**\n The total length of this tree\n */\n length, \n /**\n Per-node [node props](#common.NodeProp) to associate with this node.\n */\n props) {\n this.type = type;\n this.children = children;\n this.positions = positions;\n this.length = length;\n /**\n @internal\n */\n this.props = null;\n if (props && props.length) {\n this.props = Object.create(null);\n for (let [prop, value] of props)\n this.props[typeof prop == \"number\" ? prop : prop.id] = value;\n }\n }\n /**\n @internal\n */\n toString() {\n let mounted = MountedTree.get(this);\n if (mounted && !mounted.overlay)\n return mounted.tree.toString();\n let children = \"\";\n for (let ch of this.children) {\n let str = ch.toString();\n if (str) {\n if (children)\n children += \",\";\n children += str;\n }\n }\n return !this.type.name ? children :\n (/\\W/.test(this.type.name) && !this.type.isError ? JSON.stringify(this.type.name) : this.type.name) +\n (children.length ? \"(\" + children + \")\" : \"\");\n }\n /**\n Get a [tree cursor](#common.TreeCursor) positioned at the top of\n the tree. Mode can be used to [control](#common.IterMode) which\n nodes the cursor visits.\n */\n cursor(mode = 0) {\n return new TreeCursor(this.topNode, mode);\n }\n /**\n Get a [tree cursor](#common.TreeCursor) pointing into this tree\n at the given position and side (see\n [`moveTo`](#common.TreeCursor.moveTo).\n */\n cursorAt(pos, side = 0, mode = 0) {\n let scope = CachedNode.get(this) || this.topNode;\n let cursor = new TreeCursor(scope);\n cursor.moveTo(pos, side);\n CachedNode.set(this, cursor._tree);\n return cursor;\n }\n /**\n Get a [syntax node](#common.SyntaxNode) object for the top of the\n tree.\n */\n get topNode() {\n return new TreeNode(this, 0, 0, null);\n }\n /**\n Get the [syntax node](#common.SyntaxNode) at the given position.\n If `side` is -1, this will move into nodes that end at the\n position. If 1, it'll move into nodes that start at the\n position. With 0, it'll only enter nodes that cover the position\n from both sides.\n \n Note that this will not enter\n [overlays](#common.MountedTree.overlay), and you often want\n [`resolveInner`](#common.Tree.resolveInner) instead.\n */\n resolve(pos, side = 0) {\n let node = resolveNode(CachedNode.get(this) || this.topNode, pos, side, false);\n CachedNode.set(this, node);\n return node;\n }\n /**\n Like [`resolve`](#common.Tree.resolve), but will enter\n [overlaid](#common.MountedTree.overlay) nodes, producing a syntax node\n pointing into the innermost overlaid tree at the given position\n (with parent links going through all parent structure, including\n the host trees).\n */\n resolveInner(pos, side = 0) {\n let node = resolveNode(CachedInnerNode.get(this) || this.topNode, pos, side, true);\n CachedInnerNode.set(this, node);\n return node;\n }\n /**\n In some situations, it can be useful to iterate through all\n nodes around a position, including those in overlays that don't\n directly cover the position. This method gives you an iterator\n that will produce all nodes, from small to big, around the given\n position.\n */\n resolveStack(pos, side = 0) {\n return stackIterator(this, pos, side);\n }\n /**\n Iterate over the tree and its children, calling `enter` for any\n node that touches the `from`/`to` region (if given) before\n running over such a node's children, and `leave` (if given) when\n leaving the node. When `enter` returns `false`, that node will\n not have its children iterated over (or `leave` called).\n */\n iterate(spec) {\n let { enter, leave, from = 0, to = this.length } = spec;\n let mode = spec.mode || 0, anon = (mode & IterMode.IncludeAnonymous) > 0;\n for (let c = this.cursor(mode | IterMode.IncludeAnonymous);;) {\n let entered = false;\n if (c.from <= to && c.to >= from && (!anon && c.type.isAnonymous || enter(c) !== false)) {\n if (c.firstChild())\n continue;\n entered = true;\n }\n for (;;) {\n if (entered && leave && (anon || !c.type.isAnonymous))\n leave(c);\n if (c.nextSibling())\n break;\n if (!c.parent())\n return;\n entered = true;\n }\n }\n }\n /**\n Get the value of the given [node prop](#common.NodeProp) for this\n node. Works with both per-node and per-type props.\n */\n prop(prop) {\n return !prop.perNode ? this.type.prop(prop) : this.props ? this.props[prop.id] : undefined;\n }\n /**\n Returns the node's [per-node props](#common.NodeProp.perNode) in a\n format that can be passed to the [`Tree`](#common.Tree)\n constructor.\n */\n get propValues() {\n let result = [];\n if (this.props)\n for (let id in this.props)\n result.push([+id, this.props[id]]);\n return result;\n }\n /**\n Balance the direct children of this tree, producing a copy of\n which may have children grouped into subtrees with type\n [`NodeType.none`](#common.NodeType^none).\n */\n balance(config = {}) {\n return this.children.length <= 8 /* Balance.BranchFactor */ ? this :\n balanceRange(NodeType.none, this.children, this.positions, 0, this.children.length, 0, this.length, (children, positions, length) => new Tree(this.type, children, positions, length, this.propValues), config.makeTree || ((children, positions, length) => new Tree(NodeType.none, children, positions, length)));\n }\n /**\n Build a tree from a postfix-ordered buffer of node information,\n or a cursor over such a buffer.\n */\n static build(data) { return buildTree(data); }\n}\n/**\nThe empty tree\n*/\nTree.empty = new Tree(NodeType.none, [], [], 0);\nclass FlatBufferCursor {\n constructor(buffer, index) {\n this.buffer = buffer;\n this.index = index;\n }\n get id() { return this.buffer[this.index - 4]; }\n get start() { return this.buffer[this.index - 3]; }\n get end() { return this.buffer[this.index - 2]; }\n get size() { return this.buffer[this.index - 1]; }\n get pos() { return this.index; }\n next() { this.index -= 4; }\n fork() { return new FlatBufferCursor(this.buffer, this.index); }\n}\n/**\nTree buffers contain (type, start, end, endIndex) quads for each\nnode. In such a buffer, nodes are stored in prefix order (parents\nbefore children, with the endIndex of the parent indicating which\nchildren belong to it).\n*/\nclass TreeBuffer {\n /**\n Create a tree buffer.\n */\n constructor(\n /**\n The buffer's content.\n */\n buffer, \n /**\n The total length of the group of nodes in the buffer.\n */\n length, \n /**\n The node set used in this buffer.\n */\n set) {\n this.buffer = buffer;\n this.length = length;\n this.set = set;\n }\n /**\n @internal\n */\n get type() { return NodeType.none; }\n /**\n @internal\n */\n toString() {\n let result = [];\n for (let index = 0; index < this.buffer.length;) {\n result.push(this.childString(index));\n index = this.buffer[index + 3];\n }\n return result.join(\",\");\n }\n /**\n @internal\n */\n childString(index) {\n let id = this.buffer[index], endIndex = this.buffer[index + 3];\n let type = this.set.types[id], result = type.name;\n if (/\\W/.test(result) && !type.isError)\n result = JSON.stringify(result);\n index += 4;\n if (endIndex == index)\n return result;\n let children = [];\n while (index < endIndex) {\n children.push(this.childString(index));\n index = this.buffer[index + 3];\n }\n return result + \"(\" + children.join(\",\") + \")\";\n }\n /**\n @internal\n */\n findChild(startIndex, endIndex, dir, pos, side) {\n let { buffer } = this, pick = -1;\n for (let i = startIndex; i != endIndex; i = buffer[i + 3]) {\n if (checkSide(side, pos, buffer[i + 1], buffer[i + 2])) {\n pick = i;\n if (dir > 0)\n break;\n }\n }\n return pick;\n }\n /**\n @internal\n */\n slice(startI, endI, from) {\n let b = this.buffer;\n let copy = new Uint16Array(endI - startI), len = 0;\n for (let i = startI, j = 0; i < endI;) {\n copy[j++] = b[i++];\n copy[j++] = b[i++] - from;\n let to = copy[j++] = b[i++] - from;\n copy[j++] = b[i++] - startI;\n len = Math.max(len, to);\n }\n return new TreeBuffer(copy, len, this.set);\n }\n}\nfunction checkSide(side, pos, from, to) {\n switch (side) {\n case -2 /* Side.Before */: return from < pos;\n case -1 /* Side.AtOrBefore */: return to >= pos && from < pos;\n case 0 /* Side.Around */: return from < pos && to > pos;\n case 1 /* Side.AtOrAfter */: return from <= pos && to > pos;\n case 2 /* Side.After */: return to > pos;\n case 4 /* Side.DontCare */: return true;\n }\n}\nfunction resolveNode(node, pos, side, overlays) {\n var _a;\n // Move up to a node that actually holds the position, if possible\n while (node.from == node.to ||\n (side < 1 ? node.from >= pos : node.from > pos) ||\n (side > -1 ? node.to <= pos : node.to < pos)) {\n let parent = !overlays && node instanceof TreeNode && node.index < 0 ? null : node.parent;\n if (!parent)\n return node;\n node = parent;\n }\n let mode = overlays ? 0 : IterMode.IgnoreOverlays;\n // Must go up out of overlays when those do not overlap with pos\n if (overlays)\n for (let scan = node, parent = scan.parent; parent; scan = parent, parent = scan.parent) {\n if (scan instanceof TreeNode && scan.index < 0 && ((_a = parent.enter(pos, side, mode)) === null || _a === void 0 ? void 0 : _a.from) != scan.from)\n node = parent;\n }\n for (;;) {\n let inner = node.enter(pos, side, mode);\n if (!inner)\n return node;\n node = inner;\n }\n}\nclass BaseNode {\n cursor(mode = 0) { return new TreeCursor(this, mode); }\n getChild(type, before = null, after = null) {\n let r = getChildren(this, type, before, after);\n return r.length ? r[0] : null;\n }\n getChildren(type, before = null, after = null) {\n return getChildren(this, type, before, after);\n }\n resolve(pos, side = 0) {\n return resolveNode(this, pos, side, false);\n }\n resolveInner(pos, side = 0) {\n return resolveNode(this, pos, side, true);\n }\n matchContext(context) {\n return matchNodeContext(this, context);\n }\n enterUnfinishedNodesBefore(pos) {\n let scan = this.childBefore(pos), node = this;\n while (scan) {\n let last = scan.lastChild;\n if (!last || last.to != scan.to)\n break;\n if (last.type.isError && last.from == last.to) {\n node = scan;\n scan = last.prevSibling;\n }\n else {\n scan = last;\n }\n }\n return node;\n }\n get node() { return this; }\n get next() { return this.parent; }\n}\nclass TreeNode extends BaseNode {\n constructor(_tree, from, \n // Index in parent node, set to -1 if the node is not a direct child of _parent.node (overlay)\n index, _parent) {\n super();\n this._tree = _tree;\n this.from = from;\n this.index = index;\n this._parent = _parent;\n }\n get type() { return this._tree.type; }\n get name() { return this._tree.type.name; }\n get to() { return this.from + this._tree.length; }\n nextChild(i, dir, pos, side, mode = 0) {\n for (let parent = this;;) {\n for (let { children, positions } = parent._tree, e = dir > 0 ? children.length : -1; i != e; i += dir) {\n let next = children[i], start = positions[i] + parent.from;\n if (!checkSide(side, pos, start, start + next.length))\n continue;\n if (next instanceof TreeBuffer) {\n if (mode & IterMode.ExcludeBuffers)\n continue;\n let index = next.findChild(0, next.buffer.length, dir, pos - start, side);\n if (index > -1)\n return new BufferNode(new BufferContext(parent, next, i, start), null, index);\n }\n else if ((mode & IterMode.IncludeAnonymous) || (!next.type.isAnonymous || hasChild(next))) {\n let mounted;\n if (!(mode & IterMode.IgnoreMounts) && (mounted = MountedTree.get(next)) && !mounted.overlay)\n return new TreeNode(mounted.tree, start, i, parent);\n let inner = new TreeNode(next, start, i, parent);\n return (mode & IterMode.IncludeAnonymous) || !inner.type.isAnonymous ? inner\n : inner.nextChild(dir < 0 ? next.children.length - 1 : 0, dir, pos, side);\n }\n }\n if ((mode & IterMode.IncludeAnonymous) || !parent.type.isAnonymous)\n return null;\n if (parent.index >= 0)\n i = parent.index + dir;\n else\n i = dir < 0 ? -1 : parent._parent._tree.children.length;\n parent = parent._parent;\n if (!parent)\n return null;\n }\n }\n get firstChild() { return this.nextChild(0, 1, 0, 4 /* Side.DontCare */); }\n get lastChild() { return this.nextChild(this._tree.children.length - 1, -1, 0, 4 /* Side.DontCare */); }\n childAfter(pos) { return this.nextChild(0, 1, pos, 2 /* Side.After */); }\n childBefore(pos) { return this.nextChild(this._tree.children.length - 1, -1, pos, -2 /* Side.Before */); }\n enter(pos, side, mode = 0) {\n let mounted;\n if (!(mode & IterMode.IgnoreOverlays) && (mounted = MountedTree.get(this._tree)) && mounted.overlay) {\n let rPos = pos - this.from;\n for (let { from, to } of mounted.overlay) {\n if ((side > 0 ? from <= rPos : from < rPos) &&\n (side < 0 ? to >= rPos : to > rPos))\n return new TreeNode(mounted.tree, mounted.overlay[0].from + this.from, -1, this);\n }\n }\n return this.nextChild(0, 1, pos, side, mode);\n }\n nextSignificantParent() {\n let val = this;\n while (val.type.isAnonymous && val._parent)\n val = val._parent;\n return val;\n }\n get parent() {\n return this._parent ? this._parent.nextSignificantParent() : null;\n }\n get nextSibling() {\n return this._parent && this.index >= 0 ? this._parent.nextChild(this.index + 1, 1, 0, 4 /* Side.DontCare */) : null;\n }\n get prevSibling() {\n return this._parent && this.index >= 0 ? this._parent.nextChild(this.index - 1, -1, 0, 4 /* Side.DontCare */) : null;\n }\n get tree() { return this._tree; }\n toTree() { return this._tree; }\n /**\n @internal\n */\n toString() { return this._tree.toString(); }\n}\nfunction getChildren(node, type, before, after) {\n let cur = node.cursor(), result = [];\n if (!cur.firstChild())\n return result;\n if (before != null)\n while (!cur.type.is(before))\n if (!cur.nextSibling())\n return result;\n for (;;) {\n if (after != null && cur.type.is(after))\n return result;\n if (cur.type.is(type))\n result.push(cur.node);\n if (!cur.nextSibling())\n return after == null ? result : [];\n }\n}\nfunction matchNodeContext(node, context, i = context.length - 1) {\n for (let p = node.parent; i >= 0; p = p.parent) {\n if (!p)\n return false;\n if (!p.type.isAnonymous) {\n if (context[i] && context[i] != p.name)\n return false;\n i--;\n }\n }\n return true;\n}\nclass BufferContext {\n constructor(parent, buffer, index, start) {\n this.parent = parent;\n this.buffer = buffer;\n this.index = index;\n this.start = start;\n }\n}\nclass BufferNode extends BaseNode {\n get name() { return this.type.name; }\n get from() { return this.context.start + this.context.buffer.buffer[this.index + 1]; }\n get to() { return this.context.start + this.context.buffer.buffer[this.index + 2]; }\n constructor(context, _parent, index) {\n super();\n this.context = context;\n this._parent = _parent;\n this.index = index;\n this.type = context.buffer.set.types[context.buffer.buffer[index]];\n }\n child(dir, pos, side) {\n let { buffer } = this.context;\n let index = buffer.findChild(this.index + 4, buffer.buffer[this.index + 3], dir, pos - this.context.start, side);\n return index < 0 ? null : new BufferNode(this.context, this, index);\n }\n get firstChild() { return this.child(1, 0, 4 /* Side.DontCare */); }\n get lastChild() { return this.child(-1, 0, 4 /* Side.DontCare */); }\n childAfter(pos) { return this.child(1, pos, 2 /* Side.After */); }\n childBefore(pos) { return this.child(-1, pos, -2 /* Side.Before */); }\n enter(pos, side, mode = 0) {\n if (mode & IterMode.ExcludeBuffers)\n return null;\n let { buffer } = this.context;\n let index = buffer.findChild(this.index + 4, buffer.buffer[this.index + 3], side > 0 ? 1 : -1, pos - this.context.start, side);\n return index < 0 ? null : new BufferNode(this.context, this, index);\n }\n get parent() {\n return this._parent || this.context.parent.nextSignificantParent();\n }\n externalSibling(dir) {\n return this._parent ? null : this.context.parent.nextChild(this.context.index + dir, dir, 0, 4 /* Side.DontCare */);\n }\n get nextSibling() {\n let { buffer } = this.context;\n let after = buffer.buffer[this.index + 3];\n if (after < (this._parent ? buffer.buffer[this._parent.index + 3] : buffer.buffer.length))\n return new BufferNode(this.context, this._parent, after);\n return this.externalSibling(1);\n }\n get prevSibling() {\n let { buffer } = this.context;\n let parentStart = this._parent ? this._parent.index + 4 : 0;\n if (this.index == parentStart)\n return this.externalSibling(-1);\n return new BufferNode(this.context, this._parent, buffer.findChild(parentStart, this.index, -1, 0, 4 /* Side.DontCare */));\n }\n get tree() { return null; }\n toTree() {\n let children = [], positions = [];\n let { buffer } = this.context;\n let startI = this.index + 4, endI = buffer.buffer[this.index + 3];\n if (endI > startI) {\n let from = buffer.buffer[this.index + 1];\n children.push(buffer.slice(startI, endI, from));\n positions.push(0);\n }\n return new Tree(this.type, children, positions, this.to - this.from);\n }\n /**\n @internal\n */\n toString() { return this.context.buffer.childString(this.index); }\n}\nfunction iterStack(heads) {\n if (!heads.length)\n return null;\n if (heads.length == 1)\n return heads[0];\n let pick = 0, picked = heads[0];\n for (let i = 1; i < heads.length; i++) {\n let node = heads[i];\n if (node.from > picked.from || node.to < picked.to) {\n picked = node;\n pick = i;\n }\n }\n let next = picked instanceof TreeNode && picked.index < 0 ? null : picked.parent;\n let newHeads = heads.slice();\n if (next)\n newHeads[pick] = next;\n else\n newHeads.splice(pick, 1);\n return new StackIterator(newHeads, picked);\n}\nclass StackIterator {\n constructor(heads, node) {\n this.heads = heads;\n this.node = node;\n }\n get next() { return iterStack(this.heads); }\n}\nfunction stackIterator(tree, pos, side) {\n let inner = tree.resolveInner(pos, side), layers = null;\n for (let scan = inner instanceof TreeNode ? inner : inner.context.parent; scan; scan = scan.parent) {\n if (scan.index < 0) { // This is an overlay root\n let parent = scan.parent;\n (layers || (layers = [inner])).push(parent.resolve(pos, side));\n scan = parent;\n }\n else {\n let mount = MountedTree.get(scan.tree);\n // Relevant overlay branching off\n if (mount && mount.overlay && mount.overlay[0].from <= pos && mount.overlay[mount.overlay.length - 1].to >= pos) {\n let root = new TreeNode(mount.tree, mount.overlay[0].from + scan.from, 0, null);\n (layers || (layers = [inner])).push(resolveNode(root, pos, side, false));\n }\n }\n }\n return layers ? iterStack(layers) : inner;\n}\n/**\nA tree cursor object focuses on a given node in a syntax tree, and\nallows you to move to adjacent nodes.\n*/\nclass TreeCursor {\n /**\n Shorthand for `.type.name`.\n */\n get name() { return this.type.name; }\n /**\n @internal\n */\n constructor(node, \n /**\n @internal\n */\n mode = 0) {\n this.mode = mode;\n /**\n @internal\n */\n this.buffer = null;\n this.stack = [];\n /**\n @internal\n */\n this.index = 0;\n this.bufferNode = null;\n if (node instanceof TreeNode) {\n this.yieldNode(node);\n }\n else {\n this._tree = node.context.parent;\n this.buffer = node.context;\n for (let n = node._parent; n; n = n._parent)\n this.stack.unshift(n.index);\n this.bufferNode = node;\n this.yieldBuf(node.index);\n }\n }\n yieldNode(node) {\n if (!node)\n return false;\n this._tree = node;\n this.type = node.type;\n this.from = node.from;\n this.to = node.to;\n return true;\n }\n yieldBuf(index, type) {\n this.index = index;\n let { start, buffer } = this.buffer;\n this.type = type || buffer.set.types[buffer.buffer[index]];\n this.from = start + buffer.buffer[index + 1];\n this.to = start + buffer.buffer[index + 2];\n return true;\n }\n yield(node) {\n if (!node)\n return false;\n if (node instanceof TreeNode) {\n this.buffer = null;\n return this.yieldNode(node);\n }\n this.buffer = node.context;\n return this.yieldBuf(node.index, node.type);\n }\n /**\n @internal\n */\n toString() {\n return this.buffer ? this.buffer.buffer.childString(this.index) : this._tree.toString();\n }\n /**\n @internal\n */\n enterChild(dir, pos, side) {\n if (!this.buffer)\n return this.yield(this._tree.nextChild(dir < 0 ? this._tree._tree.children.length - 1 : 0, dir, pos, side, this.mode));\n let { buffer } = this.buffer;\n let index = buffer.findChild(this.index + 4, buffer.buffer[this.index + 3], dir, pos - this.buffer.start, side);\n if (index < 0)\n return false;\n this.stack.push(this.index);\n return this.yieldBuf(index);\n }\n /**\n Move the cursor to this node's first child. When this returns\n false, the node has no child, and the cursor has not been moved.\n */\n firstChild() { return this.enterChild(1, 0, 4 /* Side.DontCare */); }\n /**\n Move the cursor to this node's last child.\n */\n lastChild() { return this.enterChild(-1, 0, 4 /* Side.DontCare */); }\n /**\n Move the cursor to the first child that ends after `pos`.\n */\n childAfter(pos) { return this.enterChild(1, pos, 2 /* Side.After */); }\n /**\n Move to the last child that starts before `pos`.\n */\n childBefore(pos) { return this.enterChild(-1, pos, -2 /* Side.Before */); }\n /**\n Move the cursor to the child around `pos`. If side is -1 the\n child may end at that position, when 1 it may start there. This\n will also enter [overlaid](#common.MountedTree.overlay)\n [mounted](#common.NodeProp^mounted) trees unless `overlays` is\n set to false.\n */\n enter(pos, side, mode = this.mode) {\n if (!this.buffer)\n return this.yield(this._tree.enter(pos, side, mode));\n return mode & IterMode.ExcludeBuffers ? false : this.enterChild(1, pos, side);\n }\n /**\n Move to the node's parent node, if this isn't the top node.\n */\n parent() {\n if (!this.buffer)\n return this.yieldNode((this.mode & IterMode.IncludeAnonymous) ? this._tree._parent : this._tree.parent);\n if (this.stack.length)\n return this.yieldBuf(this.stack.pop());\n let parent = (this.mode & IterMode.IncludeAnonymous) ? this.buffer.parent : this.buffer.parent.nextSignificantParent();\n this.buffer = null;\n return this.yieldNode(parent);\n }\n /**\n @internal\n */\n sibling(dir) {\n if (!this.buffer)\n return !this._tree._parent ? false\n : this.yield(this._tree.index < 0 ? null\n : this._tree._parent.nextChild(this._tree.index + dir, dir, 0, 4 /* Side.DontCare */, this.mode));\n let { buffer } = this.buffer, d = this.stack.length - 1;\n if (dir < 0) {\n let parentStart = d < 0 ? 0 : this.stack[d] + 4;\n if (this.index != parentStart)\n return this.yieldBuf(buffer.findChild(parentStart, this.index, -1, 0, 4 /* Side.DontCare */));\n }\n else {\n let after = buffer.buffer[this.index + 3];\n if (after < (d < 0 ? buffer.buffer.length : buffer.buffer[this.stack[d] + 3]))\n return this.yieldBuf(after);\n }\n return d < 0 ? this.yield(this.buffer.parent.nextChild(this.buffer.index + dir, dir, 0, 4 /* Side.DontCare */, this.mode)) : false;\n }\n /**\n Move to this node's next sibling, if any.\n */\n nextSibling() { return this.sibling(1); }\n /**\n Move to this node's previous sibling, if any.\n */\n prevSibling() { return this.sibling(-1); }\n atLastNode(dir) {\n let index, parent, { buffer } = this;\n if (buffer) {\n if (dir > 0) {\n if (this.index < buffer.buffer.buffer.length)\n return false;\n }\n else {\n for (let i = 0; i < this.index; i++)\n if (buffer.buffer.buffer[i + 3] < this.index)\n return false;\n }\n ({ index, parent } = buffer);\n }\n else {\n ({ index, _parent: parent } = this._tree);\n }\n for (; parent; { index, _parent: parent } = parent) {\n if (index > -1)\n for (let i = index + dir, e = dir < 0 ? -1 : parent._tree.children.length; i != e; i += dir) {\n let child = parent._tree.children[i];\n if ((this.mode & IterMode.IncludeAnonymous) ||\n child instanceof TreeBuffer ||\n !child.type.isAnonymous ||\n hasChild(child))\n return false;\n }\n }\n return true;\n }\n move(dir, enter) {\n if (enter && this.enterChild(dir, 0, 4 /* Side.DontCare */))\n return true;\n for (;;) {\n if (this.sibling(dir))\n return true;\n if (this.atLastNode(dir) || !this.parent())\n return false;\n }\n }\n /**\n Move to the next node in a\n [pre-order](https://en.wikipedia.org/wiki/Tree_traversal#Pre-order,_NLR)\n traversal, going from a node to its first child or, if the\n current node is empty or `enter` is false, its next sibling or\n the next sibling of the first parent node that has one.\n */\n next(enter = true) { return this.move(1, enter); }\n /**\n Move to the next node in a last-to-first pre-order traveral. A\n node is followed by its last child or, if it has none, its\n previous sibling or the previous sibling of the first parent\n node that has one.\n */\n prev(enter = true) { return this.move(-1, enter); }\n /**\n Move the cursor to the innermost node that covers `pos`. If\n `side` is -1, it will enter nodes that end at `pos`. If it is 1,\n it will enter nodes that start at `pos`.\n */\n moveTo(pos, side = 0) {\n // Move up to a node that actually holds the position, if possible\n while (this.from == this.to ||\n (side < 1 ? this.from >= pos : this.from > pos) ||\n (side > -1 ? this.to <= pos : this.to < pos))\n if (!this.parent())\n break;\n // Then scan down into child nodes as far as possible\n while (this.enterChild(1, pos, side)) { }\n return this;\n }\n /**\n Get a [syntax node](#common.SyntaxNode) at the cursor's current\n position.\n */\n get node() {\n if (!this.buffer)\n return this._tree;\n let cache = this.bufferNode, result = null, depth = 0;\n if (cache && cache.context == this.buffer) {\n scan: for (let index = this.index, d = this.stack.length; d >= 0;) {\n for (let c = cache; c; c = c._parent)\n if (c.index == index) {\n if (index == this.index)\n return c;\n result = c;\n depth = d + 1;\n break scan;\n }\n index = this.stack[--d];\n }\n }\n for (let i = depth; i < this.stack.length; i++)\n result = new BufferNode(this.buffer, result, this.stack[i]);\n return this.bufferNode = new BufferNode(this.buffer, result, this.index);\n }\n /**\n Get the [tree](#common.Tree) that represents the current node, if\n any. Will return null when the node is in a [tree\n buffer](#common.TreeBuffer).\n */\n get tree() {\n return this.buffer ? null : this._tree._tree;\n }\n /**\n Iterate over the current node and all its descendants, calling\n `enter` when entering a node and `leave`, if given, when leaving\n one. When `enter` returns `false`, any children of that node are\n skipped, and `leave` isn't called for it.\n */\n iterate(enter, leave) {\n for (let depth = 0;;) {\n let mustLeave = false;\n if (this.type.isAnonymous || enter(this) !== false) {\n if (this.firstChild()) {\n depth++;\n continue;\n }\n if (!this.type.isAnonymous)\n mustLeave = true;\n }\n for (;;) {\n if (mustLeave && leave)\n leave(this);\n mustLeave = this.type.isAnonymous;\n if (this.nextSibling())\n break;\n if (!depth)\n return;\n this.parent();\n depth--;\n mustLeave = true;\n }\n }\n }\n /**\n Test whether the current node matches a given context—a sequence\n of direct parent node names. Empty strings in the context array\n are treated as wildcards.\n */\n matchContext(context) {\n if (!this.buffer)\n return matchNodeContext(this.node, context);\n let { buffer } = this.buffer, { types } = buffer.set;\n for (let i = context.length - 1, d = this.stack.length - 1; i >= 0; d--) {\n if (d < 0)\n return matchNodeContext(this.node, context, i);\n let type = types[buffer.buffer[this.stack[d]]];\n if (!type.isAnonymous) {\n if (context[i] && context[i] != type.name)\n return false;\n i--;\n }\n }\n return true;\n }\n}\nfunction hasChild(tree) {\n return tree.children.some(ch => ch instanceof TreeBuffer || !ch.type.isAnonymous || hasChild(ch));\n}\nfunction buildTree(data) {\n var _a;\n let { buffer, nodeSet, maxBufferLength = DefaultBufferLength, reused = [], minRepeatType = nodeSet.types.length } = data;\n let cursor = Array.isArray(buffer) ? new FlatBufferCursor(buffer, buffer.length) : buffer;\n let types = nodeSet.types;\n let contextHash = 0, lookAhead = 0;\n function takeNode(parentStart, minPos, children, positions, inRepeat) {\n let { id, start, end, size } = cursor;\n let lookAheadAtStart = lookAhead;\n while (size < 0) {\n cursor.next();\n if (size == -1 /* SpecialRecord.Reuse */) {\n let node = reused[id];\n children.push(node);\n positions.push(start - parentStart);\n return;\n }\n else if (size == -3 /* SpecialRecord.ContextChange */) { // Context change\n contextHash = id;\n return;\n }\n else if (size == -4 /* SpecialRecord.LookAhead */) {\n lookAhead = id;\n return;\n }\n else {\n throw new RangeError(`Unrecognized record size: ${size}`);\n }\n }\n let type = types[id], node, buffer;\n let startPos = start - parentStart;\n if (end - start <= maxBufferLength && (buffer = findBufferSize(cursor.pos - minPos, inRepeat))) {\n // Small enough for a buffer, and no reused nodes inside\n let data = new Uint16Array(buffer.size - buffer.skip);\n let endPos = cursor.pos - buffer.size, index = data.length;\n while (cursor.pos > endPos)\n index = copyToBuffer(buffer.start, data, index);\n node = new TreeBuffer(data, end - buffer.start, nodeSet);\n startPos = buffer.start - parentStart;\n }\n else { // Make it a node\n let endPos = cursor.pos - size;\n cursor.next();\n let localChildren = [], localPositions = [];\n let localInRepeat = id >= minRepeatType ? id : -1;\n let lastGroup = 0, lastEnd = end;\n while (cursor.pos > endPos) {\n if (localInRepeat >= 0 && cursor.id == localInRepeat && cursor.size >= 0) {\n if (cursor.end <= lastEnd - maxBufferLength) {\n makeRepeatLeaf(localChildren, localPositions, start, lastGroup, cursor.end, lastEnd, localInRepeat, lookAheadAtStart);\n lastGroup = localChildren.length;\n lastEnd = cursor.end;\n }\n cursor.next();\n }\n else {\n takeNode(start, endPos, localChildren, localPositions, localInRepeat);\n }\n }\n if (localInRepeat >= 0 && lastGroup > 0 && lastGroup < localChildren.length)\n makeRepeatLeaf(localChildren, localPositions, start, lastGroup, start, lastEnd, localInRepeat, lookAheadAtStart);\n localChildren.reverse();\n localPositions.reverse();\n if (localInRepeat > -1 && lastGroup > 0) {\n let make = makeBalanced(type);\n node = balanceRange(type, localChildren, localPositions, 0, localChildren.length, 0, end - start, make, make);\n }\n else {\n node = makeTree(type, localChildren, localPositions, end - start, lookAheadAtStart - end);\n }\n }\n children.push(node);\n positions.push(startPos);\n }\n function makeBalanced(type) {\n return (children, positions, length) => {\n let lookAhead = 0, lastI = children.length - 1, last, lookAheadProp;\n if (lastI >= 0 && (last = children[lastI]) instanceof Tree) {\n if (!lastI && last.type == type && last.length == length)\n return last;\n if (lookAheadProp = last.prop(NodeProp.lookAhead))\n lookAhead = positions[lastI] + last.length + lookAheadProp;\n }\n return makeTree(type, children, positions, length, lookAhead);\n };\n }\n function makeRepeatLeaf(children, positions, base, i, from, to, type, lookAhead) {\n let localChildren = [], localPositions = [];\n while (children.length > i) {\n localChildren.push(children.pop());\n localPositions.push(positions.pop() + base - from);\n }\n children.push(makeTree(nodeSet.types[type], localChildren, localPositions, to - from, lookAhead - to));\n positions.push(from - base);\n }\n function makeTree(type, children, positions, length, lookAhead = 0, props) {\n if (contextHash) {\n let pair = [NodeProp.contextHash, contextHash];\n props = props ? [pair].concat(props) : [pair];\n }\n if (lookAhead > 25) {\n let pair = [NodeProp.lookAhead, lookAhead];\n props = props ? [pair].concat(props) : [pair];\n }\n return new Tree(type, children, positions, length, props);\n }\n function findBufferSize(maxSize, inRepeat) {\n // Scan through the buffer to find previous siblings that fit\n // together in a TreeBuffer, and don't contain any reused nodes\n // (which can't be stored in a buffer).\n // If `inRepeat` is > -1, ignore node boundaries of that type for\n // nesting, but make sure the end falls either at the start\n // (`maxSize`) or before such a node.\n let fork = cursor.fork();\n let size = 0, start = 0, skip = 0, minStart = fork.end - maxBufferLength;\n let result = { size: 0, start: 0, skip: 0 };\n scan: for (let minPos = fork.pos - maxSize; fork.pos > minPos;) {\n let nodeSize = fork.size;\n // Pretend nested repeat nodes of the same type don't exist\n if (fork.id == inRepeat && nodeSize >= 0) {\n // Except that we store the current state as a valid return\n // value.\n result.size = size;\n result.start = start;\n result.skip = skip;\n skip += 4;\n size += 4;\n fork.next();\n continue;\n }\n let startPos = fork.pos - nodeSize;\n if (nodeSize < 0 || startPos < minPos || fork.start < minStart)\n break;\n let localSkipped = fork.id >= minRepeatType ? 4 : 0;\n let nodeStart = fork.start;\n fork.next();\n while (fork.pos > startPos) {\n if (fork.size < 0) {\n if (fork.size == -3 /* SpecialRecord.ContextChange */)\n localSkipped += 4;\n else\n break scan;\n }\n else if (fork.id >= minRepeatType) {\n localSkipped += 4;\n }\n fork.next();\n }\n start = nodeStart;\n size += nodeSize;\n skip += localSkipped;\n }\n if (inRepeat < 0 || size == maxSize) {\n result.size = size;\n result.start = start;\n result.skip = skip;\n }\n return result.size > 4 ? result : undefined;\n }\n function copyToBuffer(bufferStart, buffer, index) {\n let { id, start, end, size } = cursor;\n cursor.next();\n if (size >= 0 && id < minRepeatType) {\n let startIndex = index;\n if (size > 4) {\n let endPos = cursor.pos - (size - 4);\n while (cursor.pos > endPos)\n index = copyToBuffer(bufferStart, buffer, index);\n }\n buffer[--index] = startIndex;\n buffer[--index] = end - bufferStart;\n buffer[--index] = start - bufferStart;\n buffer[--index] = id;\n }\n else if (size == -3 /* SpecialRecord.ContextChange */) {\n contextHash = id;\n }\n else if (size == -4 /* SpecialRecord.LookAhead */) {\n lookAhead = id;\n }\n return index;\n }\n let children = [], positions = [];\n while (cursor.pos > 0)\n takeNode(data.start || 0, data.bufferStart || 0, children, positions, -1);\n let length = (_a = data.length) !== null && _a !== void 0 ? _a : (children.length ? positions[0] + children[0].length : 0);\n return new Tree(types[data.topID], children.reverse(), positions.reverse(), length);\n}\nconst nodeSizeCache = new WeakMap;\nfunction nodeSize(balanceType, node) {\n if (!balanceType.isAnonymous || node instanceof TreeBuffer || node.type != balanceType)\n return 1;\n let size = nodeSizeCache.get(node);\n if (size == null) {\n size = 1;\n for (let child of node.children) {\n if (child.type != balanceType || !(child instanceof Tree)) {\n size = 1;\n break;\n }\n size += nodeSize(balanceType, child);\n }\n nodeSizeCache.set(node, size);\n }\n return size;\n}\nfunction balanceRange(\n// The type the balanced tree's inner nodes.\nbalanceType, \n// The direct children and their positions\nchildren, positions, \n// The index range in children/positions to use\nfrom, to, \n// The start position of the nodes, relative to their parent.\nstart, \n// Length of the outer node\nlength, \n// Function to build the top node of the balanced tree\nmkTop, \n// Function to build internal nodes for the balanced tree\nmkTree) {\n let total = 0;\n for (let i = from; i < to; i++)\n total += nodeSize(balanceType, children[i]);\n let maxChild = Math.ceil((total * 1.5) / 8 /* Balance.BranchFactor */);\n let localChildren = [], localPositions = [];\n function divide(children, positions, from, to, offset) {\n for (let i = from; i < to;) {\n let groupFrom = i, groupStart = positions[i], groupSize = nodeSize(balanceType, children[i]);\n i++;\n for (; i < to; i++) {\n let nextSize = nodeSize(balanceType, children[i]);\n if (groupSize + nextSize >= maxChild)\n break;\n groupSize += nextSize;\n }\n if (i == groupFrom + 1) {\n if (groupSize > maxChild) {\n let only = children[groupFrom]; // Only trees can have a size > 1\n divide(only.children, only.positions, 0, only.children.length, positions[groupFrom] + offset);\n continue;\n }\n localChildren.push(children[groupFrom]);\n }\n else {\n let length = positions[i - 1] + children[i - 1].length - groupStart;\n localChildren.push(balanceRange(balanceType, children, positions, groupFrom, i, groupStart, length, null, mkTree));\n }\n localPositions.push(groupStart + offset - start);\n }\n }\n divide(children, positions, from, to, 0);\n return (mkTop || mkTree)(localChildren, localPositions, length);\n}\n/**\nProvides a way to associate values with pieces of trees. As long\nas that part of the tree is reused, the associated values can be\nretrieved from an updated tree.\n*/\nclass NodeWeakMap {\n constructor() {\n this.map = new WeakMap();\n }\n setBuffer(buffer, index, value) {\n let inner = this.map.get(buffer);\n if (!inner)\n this.map.set(buffer, inner = new Map);\n inner.set(index, value);\n }\n getBuffer(buffer, index) {\n let inner = this.map.get(buffer);\n return inner && inner.get(index);\n }\n /**\n Set the value for this syntax node.\n */\n set(node, value) {\n if (node instanceof BufferNode)\n this.setBuffer(node.context.buffer, node.index, value);\n else if (node instanceof TreeNode)\n this.map.set(node.tree, value);\n }\n /**\n Retrieve value for this syntax node, if it exists in the map.\n */\n get(node) {\n return node instanceof BufferNode ? this.getBuffer(node.context.buffer, node.index)\n : node instanceof TreeNode ? this.map.get(node.tree) : undefined;\n }\n /**\n Set the value for the node that a cursor currently points to.\n */\n cursorSet(cursor, value) {\n if (cursor.buffer)\n this.setBuffer(cursor.buffer.buffer, cursor.index, value);\n else\n this.map.set(cursor.tree, value);\n }\n /**\n Retrieve the value for the node that a cursor currently points\n to.\n */\n cursorGet(cursor) {\n return cursor.buffer ? this.getBuffer(cursor.buffer.buffer, cursor.index) : this.map.get(cursor.tree);\n }\n}\n\n/**\nTree fragments are used during [incremental\nparsing](#common.Parser.startParse) to track parts of old trees\nthat can be reused in a new parse. An array of fragments is used\nto track regions of an old tree whose nodes might be reused in new\nparses. Use the static\n[`applyChanges`](#common.TreeFragment^applyChanges) method to\nupdate fragments for document changes.\n*/\nclass TreeFragment {\n /**\n Construct a tree fragment. You'll usually want to use\n [`addTree`](#common.TreeFragment^addTree) and\n [`applyChanges`](#common.TreeFragment^applyChanges) instead of\n calling this directly.\n */\n constructor(\n /**\n The start of the unchanged range pointed to by this fragment.\n This refers to an offset in the _updated_ document (as opposed\n to the original tree).\n */\n from, \n /**\n The end of the unchanged range.\n */\n to, \n /**\n The tree that this fragment is based on.\n */\n tree, \n /**\n The offset between the fragment's tree and the document that\n this fragment can be used against. Add this when going from\n document to tree positions, subtract it to go from tree to\n document positions.\n */\n offset, openStart = false, openEnd = false) {\n this.from = from;\n this.to = to;\n this.tree = tree;\n this.offset = offset;\n this.open = (openStart ? 1 /* Open.Start */ : 0) | (openEnd ? 2 /* Open.End */ : 0);\n }\n /**\n Whether the start of the fragment represents the start of a\n parse, or the end of a change. (In the second case, it may not\n be safe to reuse some nodes at the start, depending on the\n parsing algorithm.)\n */\n get openStart() { return (this.open & 1 /* Open.Start */) > 0; }\n /**\n Whether the end of the fragment represents the end of a\n full-document parse, or the start of a change.\n */\n get openEnd() { return (this.open & 2 /* Open.End */) > 0; }\n /**\n Create a set of fragments from a freshly parsed tree, or update\n an existing set of fragments by replacing the ones that overlap\n with a tree with content from the new tree. When `partial` is\n true, the parse is treated as incomplete, and the resulting\n fragment has [`openEnd`](#common.TreeFragment.openEnd) set to\n true.\n */\n static addTree(tree, fragments = [], partial = false) {\n let result = [new TreeFragment(0, tree.length, tree, 0, false, partial)];\n for (let f of fragments)\n if (f.to > tree.length)\n result.push(f);\n return result;\n }\n /**\n Apply a set of edits to an array of fragments, removing or\n splitting fragments as necessary to remove edited ranges, and\n adjusting offsets for fragments that moved.\n */\n static applyChanges(fragments, changes, minGap = 128) {\n if (!changes.length)\n return fragments;\n let result = [];\n let fI = 1, nextF = fragments.length ? fragments[0] : null;\n for (let cI = 0, pos = 0, off = 0;; cI++) {\n let nextC = cI < changes.length ? changes[cI] : null;\n let nextPos = nextC ? nextC.fromA : 1e9;\n if (nextPos - pos >= minGap)\n while (nextF && nextF.from < nextPos) {\n let cut = nextF;\n if (pos >= cut.from || nextPos <= cut.to || off) {\n let fFrom = Math.max(cut.from, pos) - off, fTo = Math.min(cut.to, nextPos) - off;\n cut = fFrom >= fTo ? null : new TreeFragment(fFrom, fTo, cut.tree, cut.offset + off, cI > 0, !!nextC);\n }\n if (cut)\n result.push(cut);\n if (nextF.to > nextPos)\n break;\n nextF = fI < fragments.length ? fragments[fI++] : null;\n }\n if (!nextC)\n break;\n pos = nextC.toA;\n off = nextC.toA - nextC.toB;\n }\n return result;\n }\n}\n/**\nA superclass that parsers should extend.\n*/\nclass Parser {\n /**\n Start a parse, returning a [partial parse](#common.PartialParse)\n object. [`fragments`](#common.TreeFragment) can be passed in to\n make the parse incremental.\n \n By default, the entire input is parsed. You can pass `ranges`,\n which should be a sorted array of non-empty, non-overlapping\n ranges, to parse only those ranges. The tree returned in that\n case will start at `ranges[0].from`.\n */\n startParse(input, fragments, ranges) {\n if (typeof input == \"string\")\n input = new StringInput(input);\n ranges = !ranges ? [new Range(0, input.length)] : ranges.length ? ranges.map(r => new Range(r.from, r.to)) : [new Range(0, 0)];\n return this.createParse(input, fragments || [], ranges);\n }\n /**\n Run a full parse, returning the resulting tree.\n */\n parse(input, fragments, ranges) {\n let parse = this.startParse(input, fragments, ranges);\n for (;;) {\n let done = parse.advance();\n if (done)\n return done;\n }\n }\n}\nclass StringInput {\n constructor(string) {\n this.string = string;\n }\n get length() { return this.string.length; }\n chunk(from) { return this.string.slice(from); }\n get lineChunks() { return false; }\n read(from, to) { return this.string.slice(from, to); }\n}\n\n/**\nCreate a parse wrapper that, after the inner parse completes,\nscans its tree for mixed language regions with the `nest`\nfunction, runs the resulting [inner parses](#common.NestedParse),\nand then [mounts](#common.NodeProp^mounted) their results onto the\ntree.\n*/\nfunction parseMixed(nest) {\n return (parse, input, fragments, ranges) => new MixedParse(parse, nest, input, fragments, ranges);\n}\nclass InnerParse {\n constructor(parser, parse, overlay, target, ranges) {\n this.parser = parser;\n this.parse = parse;\n this.overlay = overlay;\n this.target = target;\n this.ranges = ranges;\n if (!ranges.length || ranges.some(r => r.from >= r.to))\n throw new RangeError(\"Invalid inner parse ranges given: \" + JSON.stringify(ranges));\n }\n}\nclass ActiveOverlay {\n constructor(parser, predicate, mounts, index, start, target, prev) {\n this.parser = parser;\n this.predicate = predicate;\n this.mounts = mounts;\n this.index = index;\n this.start = start;\n this.target = target;\n this.prev = prev;\n this.depth = 0;\n this.ranges = [];\n }\n}\nconst stoppedInner = new NodeProp({ perNode: true });\nclass MixedParse {\n constructor(base, nest, input, fragments, ranges) {\n this.nest = nest;\n this.input = input;\n this.fragments = fragments;\n this.ranges = ranges;\n this.inner = [];\n this.innerDone = 0;\n this.baseTree = null;\n this.stoppedAt = null;\n this.baseParse = base;\n }\n advance() {\n if (this.baseParse) {\n let done = this.baseParse.advance();\n if (!done)\n return null;\n this.baseParse = null;\n this.baseTree = done;\n this.startInner();\n if (this.stoppedAt != null)\n for (let inner of this.inner)\n inner.parse.stopAt(this.stoppedAt);\n }\n if (this.innerDone == this.inner.length) {\n let result = this.baseTree;\n if (this.stoppedAt != null)\n result = new Tree(result.type, result.children, result.positions, result.length, result.propValues.concat([[stoppedInner, this.stoppedAt]]));\n return result;\n }\n let inner = this.inner[this.innerDone], done = inner.parse.advance();\n if (done) {\n this.innerDone++;\n // This is a somewhat dodgy but super helpful hack where we\n // patch up nodes created by the inner parse (and thus\n // presumably not aliased anywhere else) to hold the information\n // about the inner parse.\n let props = Object.assign(Object.create(null), inner.target.props);\n props[NodeProp.mounted.id] = new MountedTree(done, inner.overlay, inner.parser);\n inner.target.props = props;\n }\n return null;\n }\n get parsedPos() {\n if (this.baseParse)\n return 0;\n let pos = this.input.length;\n for (let i = this.innerDone; i < this.inner.length; i++) {\n if (this.inner[i].ranges[0].from < pos)\n pos = Math.min(pos, this.inner[i].parse.parsedPos);\n }\n return pos;\n }\n stopAt(pos) {\n this.stoppedAt = pos;\n if (this.baseParse)\n this.baseParse.stopAt(pos);\n else\n for (let i = this.innerDone; i < this.inner.length; i++)\n this.inner[i].parse.stopAt(pos);\n }\n startInner() {\n let fragmentCursor = new FragmentCursor(this.fragments);\n let overlay = null;\n let covered = null;\n let cursor = new TreeCursor(new TreeNode(this.baseTree, this.ranges[0].from, 0, null), IterMode.IncludeAnonymous | IterMode.IgnoreMounts);\n scan: for (let nest, isCovered; this.stoppedAt == null || cursor.from < this.stoppedAt;) {\n let enter = true, range;\n if (fragmentCursor.hasNode(cursor)) {\n if (overlay) {\n let match = overlay.mounts.find(m => m.frag.from <= cursor.from && m.frag.to >= cursor.to && m.mount.overlay);\n if (match)\n for (let r of match.mount.overlay) {\n let from = r.from + match.pos, to = r.to + match.pos;\n if (from >= cursor.from && to <= cursor.to && !overlay.ranges.some(r => r.from < to && r.to > from))\n overlay.ranges.push({ from, to });\n }\n }\n enter = false;\n }\n else if (covered && (isCovered = checkCover(covered.ranges, cursor.from, cursor.to))) {\n enter = isCovered != 2 /* Cover.Full */;\n }\n else if (!cursor.type.isAnonymous && cursor.from < cursor.to && (nest = this.nest(cursor, this.input))) {\n if (!cursor.tree)\n materialize(cursor);\n let oldMounts = fragmentCursor.findMounts(cursor.from, nest.parser);\n if (typeof nest.overlay == \"function\") {\n overlay = new ActiveOverlay(nest.parser, nest.overlay, oldMounts, this.inner.length, cursor.from, cursor.tree, overlay);\n }\n else {\n let ranges = punchRanges(this.ranges, nest.overlay || [new Range(cursor.from, cursor.to)]);\n if (ranges.length)\n this.inner.push(new InnerParse(nest.parser, nest.parser.startParse(this.input, enterFragments(oldMounts, ranges), ranges), nest.overlay ? nest.overlay.map(r => new Range(r.from - cursor.from, r.to - cursor.from)) : null, cursor.tree, ranges));\n if (!nest.overlay)\n enter = false;\n else if (ranges.length)\n covered = { ranges, depth: 0, prev: covered };\n }\n }\n else if (overlay && (range = overlay.predicate(cursor))) {\n if (range === true)\n range = new Range(cursor.from, cursor.to);\n if (range.from < range.to)\n overlay.ranges.push(range);\n }\n if (enter && cursor.firstChild()) {\n if (overlay)\n overlay.depth++;\n if (covered)\n covered.depth++;\n }\n else {\n for (;;) {\n if (cursor.nextSibling())\n break;\n if (!cursor.parent())\n break scan;\n if (overlay && !--overlay.depth) {\n let ranges = punchRanges(this.ranges, overlay.ranges);\n if (ranges.length)\n this.inner.splice(overlay.index, 0, new InnerParse(overlay.parser, overlay.parser.startParse(this.input, enterFragments(overlay.mounts, ranges), ranges), overlay.ranges.map(r => new Range(r.from - overlay.start, r.to - overlay.start)), overlay.target, ranges));\n overlay = overlay.prev;\n }\n if (covered && !--covered.depth)\n covered = covered.prev;\n }\n }\n }\n }\n}\nfunction checkCover(covered, from, to) {\n for (let range of covered) {\n if (range.from >= to)\n break;\n if (range.to > from)\n return range.from <= from && range.to >= to ? 2 /* Cover.Full */ : 1 /* Cover.Partial */;\n }\n return 0 /* Cover.None */;\n}\n// Take a piece of buffer and convert it into a stand-alone\n// TreeBuffer.\nfunction sliceBuf(buf, startI, endI, nodes, positions, off) {\n if (startI < endI) {\n let from = buf.buffer[startI + 1];\n nodes.push(buf.slice(startI, endI, from));\n positions.push(from - off);\n }\n}\n// This function takes a node that's in a buffer, and converts it, and\n// its parent buffer nodes, into a Tree. This is again acting on the\n// assumption that the trees and buffers have been constructed by the\n// parse that was ran via the mix parser, and thus aren't shared with\n// any other code, making violations of the immutability safe.\nfunction materialize(cursor) {\n let { node } = cursor, depth = 0;\n // Scan up to the nearest tree\n do {\n cursor.parent();\n depth++;\n } while (!cursor.tree);\n // Find the index of the buffer in that tree\n let i = 0, base = cursor.tree, off = 0;\n for (;; i++) {\n off = base.positions[i] + cursor.from;\n if (off <= node.from && off + base.children[i].length >= node.to)\n break;\n }\n let buf = base.children[i], b = buf.buffer;\n // Split a level in the buffer, putting the nodes before and after\n // the child that contains `node` into new buffers.\n function split(startI, endI, type, innerOffset, length) {\n let i = startI;\n while (b[i + 2] + off <= node.from)\n i = b[i + 3];\n let children = [], positions = [];\n sliceBuf(buf, startI, i, children, positions, innerOffset);\n let from = b[i + 1], to = b[i + 2];\n let isTarget = from + off == node.from && to + off == node.to && b[i] == node.type.id;\n children.push(isTarget ? node.toTree() : split(i + 4, b[i + 3], buf.set.types[b[i]], from, to - from));\n positions.push(from - innerOffset);\n sliceBuf(buf, b[i + 3], endI, children, positions, innerOffset);\n return new Tree(type, children, positions, length);\n }\n base.children[i] = split(0, b.length, NodeType.none, 0, buf.length);\n // Move the cursor back to the target node\n for (let d = 0; d <= depth; d++)\n cursor.childAfter(node.from);\n}\nclass StructureCursor {\n constructor(root, offset) {\n this.offset = offset;\n this.done = false;\n this.cursor = root.cursor(IterMode.IncludeAnonymous | IterMode.IgnoreMounts);\n }\n // Move to the first node (in pre-order) that starts at or after `pos`.\n moveTo(pos) {\n let { cursor } = this, p = pos - this.offset;\n while (!this.done && cursor.from < p) {\n if (cursor.to >= pos && cursor.enter(p, 1, IterMode.IgnoreOverlays | IterMode.ExcludeBuffers)) ;\n else if (!cursor.next(false))\n this.done = true;\n }\n }\n hasNode(cursor) {\n this.moveTo(cursor.from);\n if (!this.done && this.cursor.from + this.offset == cursor.from && this.cursor.tree) {\n for (let tree = this.cursor.tree;;) {\n if (tree == cursor.tree)\n return true;\n if (tree.children.length && tree.positions[0] == 0 && tree.children[0] instanceof Tree)\n tree = tree.children[0];\n else\n break;\n }\n }\n return false;\n }\n}\nclass FragmentCursor {\n constructor(fragments) {\n var _a;\n this.fragments = fragments;\n this.curTo = 0;\n this.fragI = 0;\n if (fragments.length) {\n let first = this.curFrag = fragments[0];\n this.curTo = (_a = first.tree.prop(stoppedInner)) !== null && _a !== void 0 ? _a : first.to;\n this.inner = new StructureCursor(first.tree, -first.offset);\n }\n else {\n this.curFrag = this.inner = null;\n }\n }\n hasNode(node) {\n while (this.curFrag && node.from >= this.curTo)\n this.nextFrag();\n return this.curFrag && this.curFrag.from <= node.from && this.curTo >= node.to && this.inner.hasNode(node);\n }\n nextFrag() {\n var _a;\n this.fragI++;\n if (this.fragI == this.fragments.length) {\n this.curFrag = this.inner = null;\n }\n else {\n let frag = this.curFrag = this.fragments[this.fragI];\n this.curTo = (_a = frag.tree.prop(stoppedInner)) !== null && _a !== void 0 ? _a : frag.to;\n this.inner = new StructureCursor(frag.tree, -frag.offset);\n }\n }\n findMounts(pos, parser) {\n var _a;\n let result = [];\n if (this.inner) {\n this.inner.cursor.moveTo(pos, 1);\n for (let pos = this.inner.cursor.node; pos; pos = pos.parent) {\n let mount = (_a = pos.tree) === null || _a === void 0 ? void 0 : _a.prop(NodeProp.mounted);\n if (mount && mount.parser == parser) {\n for (let i = this.fragI; i < this.fragments.length; i++) {\n let frag = this.fragments[i];\n if (frag.from >= pos.to)\n break;\n if (frag.tree == this.curFrag.tree)\n result.push({\n frag,\n pos: pos.from - frag.offset,\n mount\n });\n }\n }\n }\n }\n return result;\n }\n}\nfunction punchRanges(outer, ranges) {\n let copy = null, current = ranges;\n for (let i = 1, j = 0; i < outer.length; i++) {\n let gapFrom = outer[i - 1].to, gapTo = outer[i].from;\n for (; j < current.length; j++) {\n let r = current[j];\n if (r.from >= gapTo)\n break;\n if (r.to <= gapFrom)\n continue;\n if (!copy)\n current = copy = ranges.slice();\n if (r.from < gapFrom) {\n copy[j] = new Range(r.from, gapFrom);\n if (r.to > gapTo)\n copy.splice(j + 1, 0, new Range(gapTo, r.to));\n }\n else if (r.to > gapTo) {\n copy[j--] = new Range(gapTo, r.to);\n }\n else {\n copy.splice(j--, 1);\n }\n }\n }\n return current;\n}\nfunction findCoverChanges(a, b, from, to) {\n let iA = 0, iB = 0, inA = false, inB = false, pos = -1e9;\n let result = [];\n for (;;) {\n let nextA = iA == a.length ? 1e9 : inA ? a[iA].to : a[iA].from;\n let nextB = iB == b.length ? 1e9 : inB ? b[iB].to : b[iB].from;\n if (inA != inB) {\n let start = Math.max(pos, from), end = Math.min(nextA, nextB, to);\n if (start < end)\n result.push(new Range(start, end));\n }\n pos = Math.min(nextA, nextB);\n if (pos == 1e9)\n break;\n if (nextA == pos) {\n if (!inA)\n inA = true;\n else {\n inA = false;\n iA++;\n }\n }\n if (nextB == pos) {\n if (!inB)\n inB = true;\n else {\n inB = false;\n iB++;\n }\n }\n }\n return result;\n}\n// Given a number of fragments for the outer tree, and a set of ranges\n// to parse, find fragments for inner trees mounted around those\n// ranges, if any.\nfunction enterFragments(mounts, ranges) {\n let result = [];\n for (let { pos, mount, frag } of mounts) {\n let startPos = pos + (mount.overlay ? mount.overlay[0].from : 0), endPos = startPos + mount.tree.length;\n let from = Math.max(frag.from, startPos), to = Math.min(frag.to, endPos);\n if (mount.overlay) {\n let overlay = mount.overlay.map(r => new Range(r.from + pos, r.to + pos));\n let changes = findCoverChanges(ranges, overlay, from, to);\n for (let i = 0, pos = from;; i++) {\n let last = i == changes.length, end = last ? to : changes[i].from;\n if (end > pos)\n result.push(new TreeFragment(pos, end, mount.tree, -startPos, frag.from >= pos || frag.openStart, frag.to <= end || frag.openEnd));\n if (last)\n break;\n pos = changes[i].to;\n }\n }\n else {\n result.push(new TreeFragment(from, to, mount.tree, -startPos, frag.from >= startPos || frag.openStart, frag.to <= endPos || frag.openEnd));\n }\n }\n return result;\n}\n\nexport { DefaultBufferLength, IterMode, MountedTree, NodeProp, NodeSet, NodeType, NodeWeakMap, Parser, Tree, TreeBuffer, TreeCursor, TreeFragment, parseMixed };\n","import { NodeProp } from '@lezer/common';\n\nlet nextTagID = 0;\n/**\nHighlighting tags are markers that denote a highlighting category.\nThey are [associated](#highlight.styleTags) with parts of a syntax\ntree by a language mode, and then mapped to an actual CSS style by\na [highlighter](#highlight.Highlighter).\n\nBecause syntax tree node types and highlight styles have to be\nable to talk the same language, CodeMirror uses a mostly _closed_\n[vocabulary](#highlight.tags) of syntax tags (as opposed to\ntraditional open string-based systems, which make it hard for\nhighlighting themes to cover all the tokens produced by the\nvarious languages).\n\nIt _is_ possible to [define](#highlight.Tag^define) your own\nhighlighting tags for system-internal use (where you control both\nthe language package and the highlighter), but such tags will not\nbe picked up by regular highlighters (though you can derive them\nfrom standard tags to allow highlighters to fall back to those).\n*/\nclass Tag {\n /**\n @internal\n */\n constructor(\n /**\n The set of this tag and all its parent tags, starting with\n this one itself and sorted in order of decreasing specificity.\n */\n set, \n /**\n The base unmodified tag that this one is based on, if it's\n modified @internal\n */\n base, \n /**\n The modifiers applied to this.base @internal\n */\n modified) {\n this.set = set;\n this.base = base;\n this.modified = modified;\n /**\n @internal\n */\n this.id = nextTagID++;\n }\n /**\n Define a new tag. If `parent` is given, the tag is treated as a\n sub-tag of that parent, and\n [highlighters](#highlight.tagHighlighter) that don't mention\n this tag will try to fall back to the parent tag (or grandparent\n tag, etc).\n */\n static define(parent) {\n if (parent === null || parent === void 0 ? void 0 : parent.base)\n throw new Error(\"Can not derive from a modified tag\");\n let tag = new Tag([], null, []);\n tag.set.push(tag);\n if (parent)\n for (let t of parent.set)\n tag.set.push(t);\n return tag;\n }\n /**\n Define a tag _modifier_, which is a function that, given a tag,\n will return a tag that is a subtag of the original. Applying the\n same modifier to a twice tag will return the same value (`m1(t1)\n == m1(t1)`) and applying multiple modifiers will, regardless or\n order, produce the same tag (`m1(m2(t1)) == m2(m1(t1))`).\n \n When multiple modifiers are applied to a given base tag, each\n smaller set of modifiers is registered as a parent, so that for\n example `m1(m2(m3(t1)))` is a subtype of `m1(m2(t1))`,\n `m1(m3(t1)`, and so on.\n */\n static defineModifier() {\n let mod = new Modifier;\n return (tag) => {\n if (tag.modified.indexOf(mod) > -1)\n return tag;\n return Modifier.get(tag.base || tag, tag.modified.concat(mod).sort((a, b) => a.id - b.id));\n };\n }\n}\nlet nextModifierID = 0;\nclass Modifier {\n constructor() {\n this.instances = [];\n this.id = nextModifierID++;\n }\n static get(base, mods) {\n if (!mods.length)\n return base;\n let exists = mods[0].instances.find(t => t.base == base && sameArray(mods, t.modified));\n if (exists)\n return exists;\n let set = [], tag = new Tag(set, base, mods);\n for (let m of mods)\n m.instances.push(tag);\n let configs = powerSet(mods);\n for (let parent of base.set)\n if (!parent.modified.length)\n for (let config of configs)\n set.push(Modifier.get(parent, config));\n return tag;\n }\n}\nfunction sameArray(a, b) {\n return a.length == b.length && a.every((x, i) => x == b[i]);\n}\nfunction powerSet(array) {\n let sets = [[]];\n for (let i = 0; i < array.length; i++) {\n for (let j = 0, e = sets.length; j < e; j++) {\n sets.push(sets[j].concat(array[i]));\n }\n }\n return sets.sort((a, b) => b.length - a.length);\n}\n/**\nThis function is used to add a set of tags to a language syntax\nvia [`NodeSet.extend`](#common.NodeSet.extend) or\n[`LRParser.configure`](#lr.LRParser.configure).\n\nThe argument object maps node selectors to [highlighting\ntags](#highlight.Tag) or arrays of tags.\n\nNode selectors may hold one or more (space-separated) node paths.\nSuch a path can be a [node name](#common.NodeType.name), or\nmultiple node names (or `*` wildcards) separated by slash\ncharacters, as in `\"Block/Declaration/VariableName\"`. Such a path\nmatches the final node but only if its direct parent nodes are the\nother nodes mentioned. A `*` in such a path matches any parent,\nbut only a single level—wildcards that match multiple parents\naren't supported, both for efficiency reasons and because Lezer\ntrees make it rather hard to reason about what they would match.)\n\nA path can be ended with `/...` to indicate that the tag assigned\nto the node should also apply to all child nodes, even if they\nmatch their own style (by default, only the innermost style is\nused).\n\nWhen a path ends in `!`, as in `Attribute!`, no further matching\nhappens for the node's child nodes, and the entire node gets the\ngiven style.\n\nIn this notation, node names that contain `/`, `!`, `*`, or `...`\nmust be quoted as JSON strings.\n\nFor example:\n\n```javascript\nparser.withProps(\n styleTags({\n // Style Number and BigNumber nodes\n \"Number BigNumber\": tags.number,\n // Style Escape nodes whose parent is String\n \"String/Escape\": tags.escape,\n // Style anything inside Attributes nodes\n \"Attributes!\": tags.meta,\n // Add a style to all content inside Italic nodes\n \"Italic/...\": tags.emphasis,\n // Style InvalidString nodes as both `string` and `invalid`\n \"InvalidString\": [tags.string, tags.invalid],\n // Style the node named \"/\" as punctuation\n '\"/\"': tags.punctuation\n })\n)\n```\n*/\nfunction styleTags(spec) {\n let byName = Object.create(null);\n for (let prop in spec) {\n let tags = spec[prop];\n if (!Array.isArray(tags))\n tags = [tags];\n for (let part of prop.split(\" \"))\n if (part) {\n let pieces = [], mode = 2 /* Normal */, rest = part;\n for (let pos = 0;;) {\n if (rest == \"...\" && pos > 0 && pos + 3 == part.length) {\n mode = 1 /* Inherit */;\n break;\n }\n let m = /^\"(?:[^\"\\\\]|\\\\.)*?\"|[^\\/!]+/.exec(rest);\n if (!m)\n throw new RangeError(\"Invalid path: \" + part);\n pieces.push(m[0] == \"*\" ? \"\" : m[0][0] == '\"' ? JSON.parse(m[0]) : m[0]);\n pos += m[0].length;\n if (pos == part.length)\n break;\n let next = part[pos++];\n if (pos == part.length && next == \"!\") {\n mode = 0 /* Opaque */;\n break;\n }\n if (next != \"/\")\n throw new RangeError(\"Invalid path: \" + part);\n rest = part.slice(pos);\n }\n let last = pieces.length - 1, inner = pieces[last];\n if (!inner)\n throw new RangeError(\"Invalid path: \" + part);\n let rule = new Rule(tags, mode, last > 0 ? pieces.slice(0, last) : null);\n byName[inner] = rule.sort(byName[inner]);\n }\n }\n return ruleNodeProp.add(byName);\n}\nconst ruleNodeProp = new NodeProp();\nclass Rule {\n constructor(tags, mode, context, next) {\n this.tags = tags;\n this.mode = mode;\n this.context = context;\n this.next = next;\n }\n get opaque() { return this.mode == 0 /* Opaque */; }\n get inherit() { return this.mode == 1 /* Inherit */; }\n sort(other) {\n if (!other || other.depth < this.depth) {\n this.next = other;\n return this;\n }\n other.next = this.sort(other.next);\n return other;\n }\n get depth() { return this.context ? this.context.length : 0; }\n}\nRule.empty = new Rule([], 2 /* Normal */, null);\n/**\nDefine a [highlighter](#highlight.Highlighter) from an array of\ntag/class pairs. Classes associated with more specific tags will\ntake precedence.\n*/\nfunction tagHighlighter(tags, options) {\n let map = Object.create(null);\n for (let style of tags) {\n if (!Array.isArray(style.tag))\n map[style.tag.id] = style.class;\n else\n for (let tag of style.tag)\n map[tag.id] = style.class;\n }\n let { scope, all = null } = options || {};\n return {\n style: (tags) => {\n let cls = all;\n for (let tag of tags) {\n for (let sub of tag.set) {\n let tagClass = map[sub.id];\n if (tagClass) {\n cls = cls ? cls + \" \" + tagClass : tagClass;\n break;\n }\n }\n }\n return cls;\n },\n scope\n };\n}\nfunction highlightTags(highlighters, tags) {\n let result = null;\n for (let highlighter of highlighters) {\n let value = highlighter.style(tags);\n if (value)\n result = result ? result + \" \" + value : value;\n }\n return result;\n}\n/**\nHighlight the given [tree](#common.Tree) with the given\n[highlighter](#highlight.Highlighter).\n*/\nfunction highlightTree(tree, highlighter, \n/**\nAssign styling to a region of the text. Will be called, in order\nof position, for any ranges where more than zero classes apply.\n`classes` is a space separated string of CSS classes.\n*/\nputStyle, \n/**\nThe start of the range to highlight.\n*/\nfrom = 0, \n/**\nThe end of the range.\n*/\nto = tree.length) {\n let builder = new HighlightBuilder(from, Array.isArray(highlighter) ? highlighter : [highlighter], putStyle);\n builder.highlightRange(tree.cursor(), from, to, \"\", builder.highlighters);\n builder.flush(to);\n}\nclass HighlightBuilder {\n constructor(at, highlighters, span) {\n this.at = at;\n this.highlighters = highlighters;\n this.span = span;\n this.class = \"\";\n }\n startSpan(at, cls) {\n if (cls != this.class) {\n this.flush(at);\n if (at > this.at)\n this.at = at;\n this.class = cls;\n }\n }\n flush(to) {\n if (to > this.at && this.class)\n this.span(this.at, to, this.class);\n }\n highlightRange(cursor, from, to, inheritedClass, highlighters) {\n let { type, from: start, to: end } = cursor;\n if (start >= to || end <= from)\n return;\n if (type.isTop)\n highlighters = this.highlighters.filter(h => !h.scope || h.scope(type));\n let cls = inheritedClass;\n let rule = getStyleTags(cursor) || Rule.empty;\n let tagCls = highlightTags(highlighters, rule.tags);\n if (tagCls) {\n if (cls)\n cls += \" \";\n cls += tagCls;\n if (rule.mode == 1 /* Inherit */)\n inheritedClass += (inheritedClass ? \" \" : \"\") + tagCls;\n }\n this.startSpan(Math.max(from, start), cls);\n if (rule.opaque)\n return;\n let mounted = cursor.tree && cursor.tree.prop(NodeProp.mounted);\n if (mounted && mounted.overlay) {\n let inner = cursor.node.enter(mounted.overlay[0].from + start, 1);\n let innerHighlighters = this.highlighters.filter(h => !h.scope || h.scope(mounted.tree.type));\n let hasChild = cursor.firstChild();\n for (let i = 0, pos = start;; i++) {\n let next = i < mounted.overlay.length ? mounted.overlay[i] : null;\n let nextPos = next ? next.from + start : end;\n let rangeFrom = Math.max(from, pos), rangeTo = Math.min(to, nextPos);\n if (rangeFrom < rangeTo && hasChild) {\n while (cursor.from < rangeTo) {\n this.highlightRange(cursor, rangeFrom, rangeTo, inheritedClass, highlighters);\n this.startSpan(Math.min(rangeTo, cursor.to), cls);\n if (cursor.to >= nextPos || !cursor.nextSibling())\n break;\n }\n }\n if (!next || nextPos > to)\n break;\n pos = next.to + start;\n if (pos > from) {\n this.highlightRange(inner.cursor(), Math.max(from, next.from + start), Math.min(to, pos), \"\", innerHighlighters);\n this.startSpan(Math.min(to, pos), cls);\n }\n }\n if (hasChild)\n cursor.parent();\n }\n else if (cursor.firstChild()) {\n if (mounted)\n inheritedClass = \"\";\n do {\n if (cursor.to <= from)\n continue;\n if (cursor.from >= to)\n break;\n this.highlightRange(cursor, from, to, inheritedClass, highlighters);\n this.startSpan(Math.min(to, cursor.to), cls);\n } while (cursor.nextSibling());\n cursor.parent();\n }\n }\n}\n/**\nMatch a syntax node's [highlight rules](#highlight.styleTags). If\nthere's a match, return its set of tags, and whether it is\nopaque (uses a `!`) or applies to all child nodes (`/...`).\n*/\nfunction getStyleTags(node) {\n let rule = node.type.prop(ruleNodeProp);\n while (rule && rule.context && !node.matchContext(rule.context))\n rule = rule.next;\n return rule || null;\n}\nconst t = Tag.define;\nconst comment = t(), name = t(), typeName = t(name), propertyName = t(name), literal = t(), string = t(literal), number = t(literal), content = t(), heading = t(content), keyword = t(), operator = t(), punctuation = t(), bracket = t(punctuation), meta = t();\n/**\nThe default set of highlighting [tags](#highlight.Tag).\n\nThis collection is heavily biased towards programming languages,\nand necessarily incomplete. A full ontology of syntactic\nconstructs would fill a stack of books, and be impractical to\nwrite themes for. So try to make do with this set. If all else\nfails, [open an\nissue](https://github.com/codemirror/codemirror.next) to propose a\nnew tag, or [define](#highlight.Tag^define) a local custom tag for\nyour use case.\n\nNote that it is not obligatory to always attach the most specific\ntag possible to an element—if your grammar can't easily\ndistinguish a certain type of element (such as a local variable),\nit is okay to style it as its more general variant (a variable).\n\nFor tags that extend some parent tag, the documentation links to\nthe parent.\n*/\nconst tags = {\n /**\n A comment.\n */\n comment,\n /**\n A line [comment](#highlight.tags.comment).\n */\n lineComment: t(comment),\n /**\n A block [comment](#highlight.tags.comment).\n */\n blockComment: t(comment),\n /**\n A documentation [comment](#highlight.tags.comment).\n */\n docComment: t(comment),\n /**\n Any kind of identifier.\n */\n name,\n /**\n The [name](#highlight.tags.name) of a variable.\n */\n variableName: t(name),\n /**\n A type [name](#highlight.tags.name).\n */\n typeName: typeName,\n /**\n A tag name (subtag of [`typeName`](#highlight.tags.typeName)).\n */\n tagName: t(typeName),\n /**\n A property or field [name](#highlight.tags.name).\n */\n propertyName: propertyName,\n /**\n An attribute name (subtag of [`propertyName`](#highlight.tags.propertyName)).\n */\n attributeName: t(propertyName),\n /**\n The [name](#highlight.tags.name) of a class.\n */\n className: t(name),\n /**\n A label [name](#highlight.tags.name).\n */\n labelName: t(name),\n /**\n A namespace [name](#highlight.tags.name).\n */\n namespace: t(name),\n /**\n The [name](#highlight.tags.name) of a macro.\n */\n macroName: t(name),\n /**\n A literal value.\n */\n literal,\n /**\n A string [literal](#highlight.tags.literal).\n */\n string,\n /**\n A documentation [string](#highlight.tags.string).\n */\n docString: t(string),\n /**\n A character literal (subtag of [string](#highlight.tags.string)).\n */\n character: t(string),\n /**\n An attribute value (subtag of [string](#highlight.tags.string)).\n */\n attributeValue: t(string),\n /**\n A number [literal](#highlight.tags.literal).\n */\n number,\n /**\n An integer [number](#highlight.tags.number) literal.\n */\n integer: t(number),\n /**\n A floating-point [number](#highlight.tags.number) literal.\n */\n float: t(number),\n /**\n A boolean [literal](#highlight.tags.literal).\n */\n bool: t(literal),\n /**\n Regular expression [literal](#highlight.tags.literal).\n */\n regexp: t(literal),\n /**\n An escape [literal](#highlight.tags.literal), for example a\n backslash escape in a string.\n */\n escape: t(literal),\n /**\n A color [literal](#highlight.tags.literal).\n */\n color: t(literal),\n /**\n A URL [literal](#highlight.tags.literal).\n */\n url: t(literal),\n /**\n A language keyword.\n */\n keyword,\n /**\n The [keyword](#highlight.tags.keyword) for the self or this\n object.\n */\n self: t(keyword),\n /**\n The [keyword](#highlight.tags.keyword) for null.\n */\n null: t(keyword),\n /**\n A [keyword](#highlight.tags.keyword) denoting some atomic value.\n */\n atom: t(keyword),\n /**\n A [keyword](#highlight.tags.keyword) that represents a unit.\n */\n unit: t(keyword),\n /**\n A modifier [keyword](#highlight.tags.keyword).\n */\n modifier: t(keyword),\n /**\n A [keyword](#highlight.tags.keyword) that acts as an operator.\n */\n operatorKeyword: t(keyword),\n /**\n A control-flow related [keyword](#highlight.tags.keyword).\n */\n controlKeyword: t(keyword),\n /**\n A [keyword](#highlight.tags.keyword) that defines something.\n */\n definitionKeyword: t(keyword),\n /**\n A [keyword](#highlight.tags.keyword) related to defining or\n interfacing with modules.\n */\n moduleKeyword: t(keyword),\n /**\n An operator.\n */\n operator,\n /**\n An [operator](#highlight.tags.operator) that dereferences something.\n */\n derefOperator: t(operator),\n /**\n Arithmetic-related [operator](#highlight.tags.operator).\n */\n arithmeticOperator: t(operator),\n /**\n Logical [operator](#highlight.tags.operator).\n */\n logicOperator: t(operator),\n /**\n Bit [operator](#highlight.tags.operator).\n */\n bitwiseOperator: t(operator),\n /**\n Comparison [operator](#highlight.tags.operator).\n */\n compareOperator: t(operator),\n /**\n [Operator](#highlight.tags.operator) that updates its operand.\n */\n updateOperator: t(operator),\n /**\n [Operator](#highlight.tags.operator) that defines something.\n */\n definitionOperator: t(operator),\n /**\n Type-related [operator](#highlight.tags.operator).\n */\n typeOperator: t(operator),\n /**\n Control-flow [operator](#highlight.tags.operator).\n */\n controlOperator: t(operator),\n /**\n Program or markup punctuation.\n */\n punctuation,\n /**\n [Punctuation](#highlight.tags.punctuation) that separates\n things.\n */\n separator: t(punctuation),\n /**\n Bracket-style [punctuation](#highlight.tags.punctuation).\n */\n bracket,\n /**\n Angle [brackets](#highlight.tags.bracket) (usually `<` and `>`\n tokens).\n */\n angleBracket: t(bracket),\n /**\n Square [brackets](#highlight.tags.bracket) (usually `[` and `]`\n tokens).\n */\n squareBracket: t(bracket),\n /**\n Parentheses (usually `(` and `)` tokens). Subtag of\n [bracket](#highlight.tags.bracket).\n */\n paren: t(bracket),\n /**\n Braces (usually `{` and `}` tokens). Subtag of\n [bracket](#highlight.tags.bracket).\n */\n brace: t(bracket),\n /**\n Content, for example plain text in XML or markup documents.\n */\n content,\n /**\n [Content](#highlight.tags.content) that represents a heading.\n */\n heading,\n /**\n A level 1 [heading](#highlight.tags.heading).\n */\n heading1: t(heading),\n /**\n A level 2 [heading](#highlight.tags.heading).\n */\n heading2: t(heading),\n /**\n A level 3 [heading](#highlight.tags.heading).\n */\n heading3: t(heading),\n /**\n A level 4 [heading](#highlight.tags.heading).\n */\n heading4: t(heading),\n /**\n A level 5 [heading](#highlight.tags.heading).\n */\n heading5: t(heading),\n /**\n A level 6 [heading](#highlight.tags.heading).\n */\n heading6: t(heading),\n /**\n A prose separator (such as a horizontal rule).\n */\n contentSeparator: t(content),\n /**\n [Content](#highlight.tags.content) that represents a list.\n */\n list: t(content),\n /**\n [Content](#highlight.tags.content) that represents a quote.\n */\n quote: t(content),\n /**\n [Content](#highlight.tags.content) that is emphasized.\n */\n emphasis: t(content),\n /**\n [Content](#highlight.tags.content) that is styled strong.\n */\n strong: t(content),\n /**\n [Content](#highlight.tags.content) that is part of a link.\n */\n link: t(content),\n /**\n [Content](#highlight.tags.content) that is styled as code or\n monospace.\n */\n monospace: t(content),\n /**\n [Content](#highlight.tags.content) that has a strike-through\n style.\n */\n strikethrough: t(content),\n /**\n Inserted text in a change-tracking format.\n */\n inserted: t(),\n /**\n Deleted text.\n */\n deleted: t(),\n /**\n Changed text.\n */\n changed: t(),\n /**\n An invalid or unsyntactic element.\n */\n invalid: t(),\n /**\n Metadata or meta-instruction.\n */\n meta,\n /**\n [Metadata](#highlight.tags.meta) that applies to the entire\n document.\n */\n documentMeta: t(meta),\n /**\n [Metadata](#highlight.tags.meta) that annotates or adds\n attributes to a given syntactic element.\n */\n annotation: t(meta),\n /**\n Processing instruction or preprocessor directive. Subtag of\n [meta](#highlight.tags.meta).\n */\n processingInstruction: t(meta),\n /**\n [Modifier](#highlight.Tag^defineModifier) that indicates that a\n given element is being defined. Expected to be used with the\n various [name](#highlight.tags.name) tags.\n */\n definition: Tag.defineModifier(),\n /**\n [Modifier](#highlight.Tag^defineModifier) that indicates that\n something is constant. Mostly expected to be used with\n [variable names](#highlight.tags.variableName).\n */\n constant: Tag.defineModifier(),\n /**\n [Modifier](#highlight.Tag^defineModifier) used to indicate that\n a [variable](#highlight.tags.variableName) or [property\n name](#highlight.tags.propertyName) is being called or defined\n as a function.\n */\n function: Tag.defineModifier(),\n /**\n [Modifier](#highlight.Tag^defineModifier) that can be applied to\n [names](#highlight.tags.name) to indicate that they belong to\n the language's standard environment.\n */\n standard: Tag.defineModifier(),\n /**\n [Modifier](#highlight.Tag^defineModifier) that indicates a given\n [names](#highlight.tags.name) is local to some scope.\n */\n local: Tag.defineModifier(),\n /**\n A generic variant [modifier](#highlight.Tag^defineModifier) that\n can be used to tag language-specific alternative variants of\n some common tag. It is recommended for themes to define special\n forms of at least the [string](#highlight.tags.string) and\n [variable name](#highlight.tags.variableName) tags, since those\n come up a lot.\n */\n special: Tag.defineModifier()\n};\n/**\nThis is a highlighter that adds stable, predictable classes to\ntokens, for styling with external CSS.\n\nThe following tags are mapped to their name prefixed with `\"tok-\"`\n(for example `\"tok-comment\"`):\n\n* [`link`](#highlight.tags.link)\n* [`heading`](#highlight.tags.heading)\n* [`emphasis`](#highlight.tags.emphasis)\n* [`strong`](#highlight.tags.strong)\n* [`keyword`](#highlight.tags.keyword)\n* [`atom`](#highlight.tags.atom)\n* [`bool`](#highlight.tags.bool)\n* [`url`](#highlight.tags.url)\n* [`labelName`](#highlight.tags.labelName)\n* [`inserted`](#highlight.tags.inserted)\n* [`deleted`](#highlight.tags.deleted)\n* [`literal`](#highlight.tags.literal)\n* [`string`](#highlight.tags.string)\n* [`number`](#highlight.tags.number)\n* [`variableName`](#highlight.tags.variableName)\n* [`typeName`](#highlight.tags.typeName)\n* [`namespace`](#highlight.tags.namespace)\n* [`className`](#highlight.tags.className)\n* [`macroName`](#highlight.tags.macroName)\n* [`propertyName`](#highlight.tags.propertyName)\n* [`operator`](#highlight.tags.operator)\n* [`comment`](#highlight.tags.comment)\n* [`meta`](#highlight.tags.meta)\n* [`punctuation`](#highlight.tags.punctuation)\n* [`invalid`](#highlight.tags.invalid)\n\nIn addition, these mappings are provided:\n\n* [`regexp`](#highlight.tags.regexp),\n [`escape`](#highlight.tags.escape), and\n [`special`](#highlight.tags.special)[`(string)`](#highlight.tags.string)\n are mapped to `\"tok-string2\"`\n* [`special`](#highlight.tags.special)[`(variableName)`](#highlight.tags.variableName)\n to `\"tok-variableName2\"`\n* [`local`](#highlight.tags.local)[`(variableName)`](#highlight.tags.variableName)\n to `\"tok-variableName tok-local\"`\n* [`definition`](#highlight.tags.definition)[`(variableName)`](#highlight.tags.variableName)\n to `\"tok-variableName tok-definition\"`\n* [`definition`](#highlight.tags.definition)[`(propertyName)`](#highlight.tags.propertyName)\n to `\"tok-propertyName tok-definition\"`\n*/\nconst classHighlighter = tagHighlighter([\n { tag: tags.link, class: \"tok-link\" },\n { tag: tags.heading, class: \"tok-heading\" },\n { tag: tags.emphasis, class: \"tok-emphasis\" },\n { tag: tags.strong, class: \"tok-strong\" },\n { tag: tags.keyword, class: \"tok-keyword\" },\n { tag: tags.atom, class: \"tok-atom\" },\n { tag: tags.bool, class: \"tok-bool\" },\n { tag: tags.url, class: \"tok-url\" },\n { tag: tags.labelName, class: \"tok-labelName\" },\n { tag: tags.inserted, class: \"tok-inserted\" },\n { tag: tags.deleted, class: \"tok-deleted\" },\n { tag: tags.literal, class: \"tok-literal\" },\n { tag: tags.string, class: \"tok-string\" },\n { tag: tags.number, class: \"tok-number\" },\n { tag: [tags.regexp, tags.escape, tags.special(tags.string)], class: \"tok-string2\" },\n { tag: tags.variableName, class: \"tok-variableName\" },\n { tag: tags.local(tags.variableName), class: \"tok-variableName tok-local\" },\n { tag: tags.definition(tags.variableName), class: \"tok-variableName tok-definition\" },\n { tag: tags.special(tags.variableName), class: \"tok-variableName2\" },\n { tag: tags.definition(tags.propertyName), class: \"tok-propertyName tok-definition\" },\n { tag: tags.typeName, class: \"tok-typeName\" },\n { tag: tags.namespace, class: \"tok-namespace\" },\n { tag: tags.className, class: \"tok-className\" },\n { tag: tags.macroName, class: \"tok-macroName\" },\n { tag: tags.propertyName, class: \"tok-propertyName\" },\n { tag: tags.operator, class: \"tok-operator\" },\n { tag: tags.comment, class: \"tok-comment\" },\n { tag: tags.meta, class: \"tok-meta\" },\n { tag: tags.invalid, class: \"tok-invalid\" },\n { tag: tags.punctuation, class: \"tok-punctuation\" }\n]);\n\nexport { Tag, classHighlighter, getStyleTags, highlightTree, styleTags, tagHighlighter, tags };\n","import { NodeProp, IterMode, Tree, TreeFragment, Parser, NodeType, NodeSet } from '@lezer/common';\nimport { StateEffect, StateField, Facet, EditorState, countColumn, combineConfig, RangeSet, RangeSetBuilder, Prec } from '@codemirror/state';\nimport { ViewPlugin, logException, EditorView, Decoration, WidgetType, gutter, GutterMarker } from '@codemirror/view';\nimport { tags, tagHighlighter, highlightTree, styleTags } from '@lezer/highlight';\nimport { StyleModule } from 'style-mod';\n\nvar _a;\n/**\nNode prop stored in a parser's top syntax node to provide the\nfacet that stores language-specific data for that language.\n*/\nconst languageDataProp = /*@__PURE__*/new NodeProp();\n/**\nHelper function to define a facet (to be added to the top syntax\nnode(s) for a language via\n[`languageDataProp`](https://codemirror.net/6/docs/ref/#language.languageDataProp)), that will be\nused to associate language data with the language. You\nprobably only need this when subclassing\n[`Language`](https://codemirror.net/6/docs/ref/#language.Language).\n*/\nfunction defineLanguageFacet(baseData) {\n return Facet.define({\n combine: baseData ? values => values.concat(baseData) : undefined\n });\n}\n/**\nSyntax node prop used to register sublanguages. Should be added to\nthe top level node type for the language.\n*/\nconst sublanguageProp = /*@__PURE__*/new NodeProp();\n/**\nA language object manages parsing and per-language\n[metadata](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt). Parse data is\nmanaged as a [Lezer](https://lezer.codemirror.net) tree. The class\ncan be used directly, via the [`LRLanguage`](https://codemirror.net/6/docs/ref/#language.LRLanguage)\nsubclass for [Lezer](https://lezer.codemirror.net/) LR parsers, or\nvia the [`StreamLanguage`](https://codemirror.net/6/docs/ref/#language.StreamLanguage) subclass\nfor stream parsers.\n*/\nclass Language {\n /**\n Construct a language object. If you need to invoke this\n directly, first define a data facet with\n [`defineLanguageFacet`](https://codemirror.net/6/docs/ref/#language.defineLanguageFacet), and then\n configure your parser to [attach](https://codemirror.net/6/docs/ref/#language.languageDataProp) it\n to the language's outer syntax node.\n */\n constructor(\n /**\n The [language data](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt) facet\n used for this language.\n */\n data, parser, extraExtensions = [], \n /**\n A language name.\n */\n name = \"\") {\n this.data = data;\n this.name = name;\n // Kludge to define EditorState.tree as a debugging helper,\n // without the EditorState package actually knowing about\n // languages and lezer trees.\n if (!EditorState.prototype.hasOwnProperty(\"tree\"))\n Object.defineProperty(EditorState.prototype, \"tree\", { get() { return syntaxTree(this); } });\n this.parser = parser;\n this.extension = [\n language.of(this),\n EditorState.languageData.of((state, pos, side) => {\n let top = topNodeAt(state, pos, side), data = top.type.prop(languageDataProp);\n if (!data)\n return [];\n let base = state.facet(data), sub = top.type.prop(sublanguageProp);\n if (sub) {\n let innerNode = top.resolve(pos - top.from, side);\n for (let sublang of sub)\n if (sublang.test(innerNode, state)) {\n let data = state.facet(sublang.facet);\n return sublang.type == \"replace\" ? data : data.concat(base);\n }\n }\n return base;\n })\n ].concat(extraExtensions);\n }\n /**\n Query whether this language is active at the given position.\n */\n isActiveAt(state, pos, side = -1) {\n return topNodeAt(state, pos, side).type.prop(languageDataProp) == this.data;\n }\n /**\n Find the document regions that were parsed using this language.\n The returned regions will _include_ any nested languages rooted\n in this language, when those exist.\n */\n findRegions(state) {\n let lang = state.facet(language);\n if ((lang === null || lang === void 0 ? void 0 : lang.data) == this.data)\n return [{ from: 0, to: state.doc.length }];\n if (!lang || !lang.allowsNesting)\n return [];\n let result = [];\n let explore = (tree, from) => {\n if (tree.prop(languageDataProp) == this.data) {\n result.push({ from, to: from + tree.length });\n return;\n }\n let mount = tree.prop(NodeProp.mounted);\n if (mount) {\n if (mount.tree.prop(languageDataProp) == this.data) {\n if (mount.overlay)\n for (let r of mount.overlay)\n result.push({ from: r.from + from, to: r.to + from });\n else\n result.push({ from: from, to: from + tree.length });\n return;\n }\n else if (mount.overlay) {\n let size = result.length;\n explore(mount.tree, mount.overlay[0].from + from);\n if (result.length > size)\n return;\n }\n }\n for (let i = 0; i < tree.children.length; i++) {\n let ch = tree.children[i];\n if (ch instanceof Tree)\n explore(ch, tree.positions[i] + from);\n }\n };\n explore(syntaxTree(state), 0);\n return result;\n }\n /**\n Indicates whether this language allows nested languages. The\n default implementation returns true.\n */\n get allowsNesting() { return true; }\n}\n/**\n@internal\n*/\nLanguage.setState = /*@__PURE__*/StateEffect.define();\nfunction topNodeAt(state, pos, side) {\n let topLang = state.facet(language), tree = syntaxTree(state).topNode;\n if (!topLang || topLang.allowsNesting) {\n for (let node = tree; node; node = node.enter(pos, side, IterMode.ExcludeBuffers))\n if (node.type.isTop)\n tree = node;\n }\n return tree;\n}\n/**\nA subclass of [`Language`](https://codemirror.net/6/docs/ref/#language.Language) for use with Lezer\n[LR parsers](https://lezer.codemirror.net/docs/ref#lr.LRParser)\nparsers.\n*/\nclass LRLanguage extends Language {\n constructor(data, parser, name) {\n super(data, parser, [], name);\n this.parser = parser;\n }\n /**\n Define a language from a parser.\n */\n static define(spec) {\n let data = defineLanguageFacet(spec.languageData);\n return new LRLanguage(data, spec.parser.configure({\n props: [languageDataProp.add(type => type.isTop ? data : undefined)]\n }), spec.name);\n }\n /**\n Create a new instance of this language with a reconfigured\n version of its parser and optionally a new name.\n */\n configure(options, name) {\n return new LRLanguage(this.data, this.parser.configure(options), name || this.name);\n }\n get allowsNesting() { return this.parser.hasWrappers(); }\n}\n/**\nGet the syntax tree for a state, which is the current (possibly\nincomplete) parse tree of the active\n[language](https://codemirror.net/6/docs/ref/#language.Language), or the empty tree if there is no\nlanguage available.\n*/\nfunction syntaxTree(state) {\n let field = state.field(Language.state, false);\n return field ? field.tree : Tree.empty;\n}\n/**\nTry to get a parse tree that spans at least up to `upto`. The\nmethod will do at most `timeout` milliseconds of work to parse\nup to that point if the tree isn't already available.\n*/\nfunction ensureSyntaxTree(state, upto, timeout = 50) {\n var _a;\n let parse = (_a = state.field(Language.state, false)) === null || _a === void 0 ? void 0 : _a.context;\n if (!parse)\n return null;\n let oldVieport = parse.viewport;\n parse.updateViewport({ from: 0, to: upto });\n let result = parse.isDone(upto) || parse.work(timeout, upto) ? parse.tree : null;\n parse.updateViewport(oldVieport);\n return result;\n}\n/**\nQueries whether there is a full syntax tree available up to the\ngiven document position. If there isn't, the background parse\nprocess _might_ still be working and update the tree further, but\nthere is no guarantee of that—the parser will [stop\nworking](https://codemirror.net/6/docs/ref/#language.syntaxParserRunning) when it has spent a\ncertain amount of time or has moved beyond the visible viewport.\nAlways returns false if no language has been enabled.\n*/\nfunction syntaxTreeAvailable(state, upto = state.doc.length) {\n var _a;\n return ((_a = state.field(Language.state, false)) === null || _a === void 0 ? void 0 : _a.context.isDone(upto)) || false;\n}\n/**\nMove parsing forward, and update the editor state afterwards to\nreflect the new tree. Will work for at most `timeout`\nmilliseconds. Returns true if the parser managed get to the given\nposition in that time.\n*/\nfunction forceParsing(view, upto = view.viewport.to, timeout = 100) {\n let success = ensureSyntaxTree(view.state, upto, timeout);\n if (success != syntaxTree(view.state))\n view.dispatch({});\n return !!success;\n}\n/**\nTells you whether the language parser is planning to do more\nparsing work (in a `requestIdleCallback` pseudo-thread) or has\nstopped running, either because it parsed the entire document,\nbecause it spent too much time and was cut off, or because there\nis no language parser enabled.\n*/\nfunction syntaxParserRunning(view) {\n var _a;\n return ((_a = view.plugin(parseWorker)) === null || _a === void 0 ? void 0 : _a.isWorking()) || false;\n}\n/**\nLezer-style\n[`Input`](https://lezer.codemirror.net/docs/ref#common.Input)\nobject for a [`Text`](https://codemirror.net/6/docs/ref/#state.Text) object.\n*/\nclass DocInput {\n /**\n Create an input object for the given document.\n */\n constructor(doc) {\n this.doc = doc;\n this.cursorPos = 0;\n this.string = \"\";\n this.cursor = doc.iter();\n }\n get length() { return this.doc.length; }\n syncTo(pos) {\n this.string = this.cursor.next(pos - this.cursorPos).value;\n this.cursorPos = pos + this.string.length;\n return this.cursorPos - this.string.length;\n }\n chunk(pos) {\n this.syncTo(pos);\n return this.string;\n }\n get lineChunks() { return true; }\n read(from, to) {\n let stringStart = this.cursorPos - this.string.length;\n if (from < stringStart || to >= this.cursorPos)\n return this.doc.sliceString(from, to);\n else\n return this.string.slice(from - stringStart, to - stringStart);\n }\n}\nlet currentContext = null;\n/**\nA parse context provided to parsers working on the editor content.\n*/\nclass ParseContext {\n constructor(parser, \n /**\n The current editor state.\n */\n state, \n /**\n Tree fragments that can be reused by incremental re-parses.\n */\n fragments = [], \n /**\n @internal\n */\n tree, \n /**\n @internal\n */\n treeLen, \n /**\n The current editor viewport (or some overapproximation\n thereof). Intended to be used for opportunistically avoiding\n work (in which case\n [`skipUntilInView`](https://codemirror.net/6/docs/ref/#language.ParseContext.skipUntilInView)\n should be called to make sure the parser is restarted when the\n skipped region becomes visible).\n */\n viewport, \n /**\n @internal\n */\n skipped, \n /**\n This is where skipping parsers can register a promise that,\n when resolved, will schedule a new parse. It is cleared when\n the parse worker picks up the promise. @internal\n */\n scheduleOn) {\n this.parser = parser;\n this.state = state;\n this.fragments = fragments;\n this.tree = tree;\n this.treeLen = treeLen;\n this.viewport = viewport;\n this.skipped = skipped;\n this.scheduleOn = scheduleOn;\n this.parse = null;\n /**\n @internal\n */\n this.tempSkipped = [];\n }\n /**\n @internal\n */\n static create(parser, state, viewport) {\n return new ParseContext(parser, state, [], Tree.empty, 0, viewport, [], null);\n }\n startParse() {\n return this.parser.startParse(new DocInput(this.state.doc), this.fragments);\n }\n /**\n @internal\n */\n work(until, upto) {\n if (upto != null && upto >= this.state.doc.length)\n upto = undefined;\n if (this.tree != Tree.empty && this.isDone(upto !== null && upto !== void 0 ? upto : this.state.doc.length)) {\n this.takeTree();\n return true;\n }\n return this.withContext(() => {\n var _a;\n if (typeof until == \"number\") {\n let endTime = Date.now() + until;\n until = () => Date.now() > endTime;\n }\n if (!this.parse)\n this.parse = this.startParse();\n if (upto != null && (this.parse.stoppedAt == null || this.parse.stoppedAt > upto) &&\n upto < this.state.doc.length)\n this.parse.stopAt(upto);\n for (;;) {\n let done = this.parse.advance();\n if (done) {\n this.fragments = this.withoutTempSkipped(TreeFragment.addTree(done, this.fragments, this.parse.stoppedAt != null));\n this.treeLen = (_a = this.parse.stoppedAt) !== null && _a !== void 0 ? _a : this.state.doc.length;\n this.tree = done;\n this.parse = null;\n if (this.treeLen < (upto !== null && upto !== void 0 ? upto : this.state.doc.length))\n this.parse = this.startParse();\n else\n return true;\n }\n if (until())\n return false;\n }\n });\n }\n /**\n @internal\n */\n takeTree() {\n let pos, tree;\n if (this.parse && (pos = this.parse.parsedPos) >= this.treeLen) {\n if (this.parse.stoppedAt == null || this.parse.stoppedAt > pos)\n this.parse.stopAt(pos);\n this.withContext(() => { while (!(tree = this.parse.advance())) { } });\n this.treeLen = pos;\n this.tree = tree;\n this.fragments = this.withoutTempSkipped(TreeFragment.addTree(this.tree, this.fragments, true));\n this.parse = null;\n }\n }\n withContext(f) {\n let prev = currentContext;\n currentContext = this;\n try {\n return f();\n }\n finally {\n currentContext = prev;\n }\n }\n withoutTempSkipped(fragments) {\n for (let r; r = this.tempSkipped.pop();)\n fragments = cutFragments(fragments, r.from, r.to);\n return fragments;\n }\n /**\n @internal\n */\n changes(changes, newState) {\n let { fragments, tree, treeLen, viewport, skipped } = this;\n this.takeTree();\n if (!changes.empty) {\n let ranges = [];\n changes.iterChangedRanges((fromA, toA, fromB, toB) => ranges.push({ fromA, toA, fromB, toB }));\n fragments = TreeFragment.applyChanges(fragments, ranges);\n tree = Tree.empty;\n treeLen = 0;\n viewport = { from: changes.mapPos(viewport.from, -1), to: changes.mapPos(viewport.to, 1) };\n if (this.skipped.length) {\n skipped = [];\n for (let r of this.skipped) {\n let from = changes.mapPos(r.from, 1), to = changes.mapPos(r.to, -1);\n if (from < to)\n skipped.push({ from, to });\n }\n }\n }\n return new ParseContext(this.parser, newState, fragments, tree, treeLen, viewport, skipped, this.scheduleOn);\n }\n /**\n @internal\n */\n updateViewport(viewport) {\n if (this.viewport.from == viewport.from && this.viewport.to == viewport.to)\n return false;\n this.viewport = viewport;\n let startLen = this.skipped.length;\n for (let i = 0; i < this.skipped.length; i++) {\n let { from, to } = this.skipped[i];\n if (from < viewport.to && to > viewport.from) {\n this.fragments = cutFragments(this.fragments, from, to);\n this.skipped.splice(i--, 1);\n }\n }\n if (this.skipped.length >= startLen)\n return false;\n this.reset();\n return true;\n }\n /**\n @internal\n */\n reset() {\n if (this.parse) {\n this.takeTree();\n this.parse = null;\n }\n }\n /**\n Notify the parse scheduler that the given region was skipped\n because it wasn't in view, and the parse should be restarted\n when it comes into view.\n */\n skipUntilInView(from, to) {\n this.skipped.push({ from, to });\n }\n /**\n Returns a parser intended to be used as placeholder when\n asynchronously loading a nested parser. It'll skip its input and\n mark it as not-really-parsed, so that the next update will parse\n it again.\n \n When `until` is given, a reparse will be scheduled when that\n promise resolves.\n */\n static getSkippingParser(until) {\n return new class extends Parser {\n createParse(input, fragments, ranges) {\n let from = ranges[0].from, to = ranges[ranges.length - 1].to;\n let parser = {\n parsedPos: from,\n advance() {\n let cx = currentContext;\n if (cx) {\n for (let r of ranges)\n cx.tempSkipped.push(r);\n if (until)\n cx.scheduleOn = cx.scheduleOn ? Promise.all([cx.scheduleOn, until]) : until;\n }\n this.parsedPos = to;\n return new Tree(NodeType.none, [], [], to - from);\n },\n stoppedAt: null,\n stopAt() { }\n };\n return parser;\n }\n };\n }\n /**\n @internal\n */\n isDone(upto) {\n upto = Math.min(upto, this.state.doc.length);\n let frags = this.fragments;\n return this.treeLen >= upto && frags.length && frags[0].from == 0 && frags[0].to >= upto;\n }\n /**\n Get the context for the current parse, or `null` if no editor\n parse is in progress.\n */\n static get() { return currentContext; }\n}\nfunction cutFragments(fragments, from, to) {\n return TreeFragment.applyChanges(fragments, [{ fromA: from, toA: to, fromB: from, toB: to }]);\n}\nclass LanguageState {\n constructor(\n // A mutable parse state that is used to preserve work done during\n // the lifetime of a state when moving to the next state.\n context) {\n this.context = context;\n this.tree = context.tree;\n }\n apply(tr) {\n if (!tr.docChanged && this.tree == this.context.tree)\n return this;\n let newCx = this.context.changes(tr.changes, tr.state);\n // If the previous parse wasn't done, go forward only up to its\n // end position or the end of the viewport, to avoid slowing down\n // state updates with parse work beyond the viewport.\n let upto = this.context.treeLen == tr.startState.doc.length ? undefined\n : Math.max(tr.changes.mapPos(this.context.treeLen), newCx.viewport.to);\n if (!newCx.work(20 /* Work.Apply */, upto))\n newCx.takeTree();\n return new LanguageState(newCx);\n }\n static init(state) {\n let vpTo = Math.min(3000 /* Work.InitViewport */, state.doc.length);\n let parseState = ParseContext.create(state.facet(language).parser, state, { from: 0, to: vpTo });\n if (!parseState.work(20 /* Work.Apply */, vpTo))\n parseState.takeTree();\n return new LanguageState(parseState);\n }\n}\nLanguage.state = /*@__PURE__*/StateField.define({\n create: LanguageState.init,\n update(value, tr) {\n for (let e of tr.effects)\n if (e.is(Language.setState))\n return e.value;\n if (tr.startState.facet(language) != tr.state.facet(language))\n return LanguageState.init(tr.state);\n return value.apply(tr);\n }\n});\nlet requestIdle = (callback) => {\n let timeout = setTimeout(() => callback(), 500 /* Work.MaxPause */);\n return () => clearTimeout(timeout);\n};\nif (typeof requestIdleCallback != \"undefined\")\n requestIdle = (callback) => {\n let idle = -1, timeout = setTimeout(() => {\n idle = requestIdleCallback(callback, { timeout: 500 /* Work.MaxPause */ - 100 /* Work.MinPause */ });\n }, 100 /* Work.MinPause */);\n return () => idle < 0 ? clearTimeout(timeout) : cancelIdleCallback(idle);\n };\nconst isInputPending = typeof navigator != \"undefined\" && ((_a = navigator.scheduling) === null || _a === void 0 ? void 0 : _a.isInputPending)\n ? () => navigator.scheduling.isInputPending() : null;\nconst parseWorker = /*@__PURE__*/ViewPlugin.fromClass(class ParseWorker {\n constructor(view) {\n this.view = view;\n this.working = null;\n this.workScheduled = 0;\n // End of the current time chunk\n this.chunkEnd = -1;\n // Milliseconds of budget left for this chunk\n this.chunkBudget = -1;\n this.work = this.work.bind(this);\n this.scheduleWork();\n }\n update(update) {\n let cx = this.view.state.field(Language.state).context;\n if (cx.updateViewport(update.view.viewport) || this.view.viewport.to > cx.treeLen)\n this.scheduleWork();\n if (update.docChanged || update.selectionSet) {\n if (this.view.hasFocus)\n this.chunkBudget += 50 /* Work.ChangeBonus */;\n this.scheduleWork();\n }\n this.checkAsyncSchedule(cx);\n }\n scheduleWork() {\n if (this.working)\n return;\n let { state } = this.view, field = state.field(Language.state);\n if (field.tree != field.context.tree || !field.context.isDone(state.doc.length))\n this.working = requestIdle(this.work);\n }\n work(deadline) {\n this.working = null;\n let now = Date.now();\n if (this.chunkEnd < now && (this.chunkEnd < 0 || this.view.hasFocus)) { // Start a new chunk\n this.chunkEnd = now + 30000 /* Work.ChunkTime */;\n this.chunkBudget = 3000 /* Work.ChunkBudget */;\n }\n if (this.chunkBudget <= 0)\n return; // No more budget\n let { state, viewport: { to: vpTo } } = this.view, field = state.field(Language.state);\n if (field.tree == field.context.tree && field.context.isDone(vpTo + 100000 /* Work.MaxParseAhead */))\n return;\n let endTime = Date.now() + Math.min(this.chunkBudget, 100 /* Work.Slice */, deadline && !isInputPending ? Math.max(25 /* Work.MinSlice */, deadline.timeRemaining() - 5) : 1e9);\n let viewportFirst = field.context.treeLen < vpTo && state.doc.length > vpTo + 1000;\n let done = field.context.work(() => {\n return isInputPending && isInputPending() || Date.now() > endTime;\n }, vpTo + (viewportFirst ? 0 : 100000 /* Work.MaxParseAhead */));\n this.chunkBudget -= Date.now() - now;\n if (done || this.chunkBudget <= 0) {\n field.context.takeTree();\n this.view.dispatch({ effects: Language.setState.of(new LanguageState(field.context)) });\n }\n if (this.chunkBudget > 0 && !(done && !viewportFirst))\n this.scheduleWork();\n this.checkAsyncSchedule(field.context);\n }\n checkAsyncSchedule(cx) {\n if (cx.scheduleOn) {\n this.workScheduled++;\n cx.scheduleOn\n .then(() => this.scheduleWork())\n .catch(err => logException(this.view.state, err))\n .then(() => this.workScheduled--);\n cx.scheduleOn = null;\n }\n }\n destroy() {\n if (this.working)\n this.working();\n }\n isWorking() {\n return !!(this.working || this.workScheduled > 0);\n }\n}, {\n eventHandlers: { focus() { this.scheduleWork(); } }\n});\n/**\nThe facet used to associate a language with an editor state. Used\nby `Language` object's `extension` property (so you don't need to\nmanually wrap your languages in this). Can be used to access the\ncurrent language on a state.\n*/\nconst language = /*@__PURE__*/Facet.define({\n combine(languages) { return languages.length ? languages[0] : null; },\n enables: language => [\n Language.state,\n parseWorker,\n EditorView.contentAttributes.compute([language], state => {\n let lang = state.facet(language);\n return lang && lang.name ? { \"data-language\": lang.name } : {};\n })\n ]\n});\n/**\nThis class bundles a [language](https://codemirror.net/6/docs/ref/#language.Language) with an\noptional set of supporting extensions. Language packages are\nencouraged to export a function that optionally takes a\nconfiguration object and returns a `LanguageSupport` instance, as\nthe main way for client code to use the package.\n*/\nclass LanguageSupport {\n /**\n Create a language support object.\n */\n constructor(\n /**\n The language object.\n */\n language, \n /**\n An optional set of supporting extensions. When nesting a\n language in another language, the outer language is encouraged\n to include the supporting extensions for its inner languages\n in its own set of support extensions.\n */\n support = []) {\n this.language = language;\n this.support = support;\n this.extension = [language, support];\n }\n}\n/**\nLanguage descriptions are used to store metadata about languages\nand to dynamically load them. Their main role is finding the\nappropriate language for a filename or dynamically loading nested\nparsers.\n*/\nclass LanguageDescription {\n constructor(\n /**\n The name of this language.\n */\n name, \n /**\n Alternative names for the mode (lowercased, includes `this.name`).\n */\n alias, \n /**\n File extensions associated with this language.\n */\n extensions, \n /**\n Optional filename pattern that should be associated with this\n language.\n */\n filename, loadFunc, \n /**\n If the language has been loaded, this will hold its value.\n */\n support = undefined) {\n this.name = name;\n this.alias = alias;\n this.extensions = extensions;\n this.filename = filename;\n this.loadFunc = loadFunc;\n this.support = support;\n this.loading = null;\n }\n /**\n Start loading the the language. Will return a promise that\n resolves to a [`LanguageSupport`](https://codemirror.net/6/docs/ref/#language.LanguageSupport)\n object when the language successfully loads.\n */\n load() {\n return this.loading || (this.loading = this.loadFunc().then(support => this.support = support, err => { this.loading = null; throw err; }));\n }\n /**\n Create a language description.\n */\n static of(spec) {\n let { load, support } = spec;\n if (!load) {\n if (!support)\n throw new RangeError(\"Must pass either 'load' or 'support' to LanguageDescription.of\");\n load = () => Promise.resolve(support);\n }\n return new LanguageDescription(spec.name, (spec.alias || []).concat(spec.name).map(s => s.toLowerCase()), spec.extensions || [], spec.filename, load, support);\n }\n /**\n Look for a language in the given array of descriptions that\n matches the filename. Will first match\n [`filename`](https://codemirror.net/6/docs/ref/#language.LanguageDescription.filename) patterns,\n and then [extensions](https://codemirror.net/6/docs/ref/#language.LanguageDescription.extensions),\n and return the first language that matches.\n */\n static matchFilename(descs, filename) {\n for (let d of descs)\n if (d.filename && d.filename.test(filename))\n return d;\n let ext = /\\.([^.]+)$/.exec(filename);\n if (ext)\n for (let d of descs)\n if (d.extensions.indexOf(ext[1]) > -1)\n return d;\n return null;\n }\n /**\n Look for a language whose name or alias matches the the given\n name (case-insensitively). If `fuzzy` is true, and no direct\n matchs is found, this'll also search for a language whose name\n or alias occurs in the string (for names shorter than three\n characters, only when surrounded by non-word characters).\n */\n static matchLanguageName(descs, name, fuzzy = true) {\n name = name.toLowerCase();\n for (let d of descs)\n if (d.alias.some(a => a == name))\n return d;\n if (fuzzy)\n for (let d of descs)\n for (let a of d.alias) {\n let found = name.indexOf(a);\n if (found > -1 && (a.length > 2 || !/\\w/.test(name[found - 1]) && !/\\w/.test(name[found + a.length])))\n return d;\n }\n return null;\n }\n}\n\n/**\nFacet that defines a way to provide a function that computes the\nappropriate indentation depth, as a column number (see\n[`indentString`](https://codemirror.net/6/docs/ref/#language.indentString)), at the start of a given\nline. A return value of `null` indicates no indentation can be\ndetermined, and the line should inherit the indentation of the one\nabove it. A return value of `undefined` defers to the next indent\nservice.\n*/\nconst indentService = /*@__PURE__*/Facet.define();\n/**\nFacet for overriding the unit by which indentation happens. Should\nbe a string consisting either entirely of the same whitespace\ncharacter. When not set, this defaults to 2 spaces.\n*/\nconst indentUnit = /*@__PURE__*/Facet.define({\n combine: values => {\n if (!values.length)\n return \" \";\n let unit = values[0];\n if (!unit || /\\S/.test(unit) || Array.from(unit).some(e => e != unit[0]))\n throw new Error(\"Invalid indent unit: \" + JSON.stringify(values[0]));\n return unit;\n }\n});\n/**\nReturn the _column width_ of an indent unit in the state.\nDetermined by the [`indentUnit`](https://codemirror.net/6/docs/ref/#language.indentUnit)\nfacet, and [`tabSize`](https://codemirror.net/6/docs/ref/#state.EditorState^tabSize) when that\ncontains tabs.\n*/\nfunction getIndentUnit(state) {\n let unit = state.facet(indentUnit);\n return unit.charCodeAt(0) == 9 ? state.tabSize * unit.length : unit.length;\n}\n/**\nCreate an indentation string that covers columns 0 to `cols`.\nWill use tabs for as much of the columns as possible when the\n[`indentUnit`](https://codemirror.net/6/docs/ref/#language.indentUnit) facet contains\ntabs.\n*/\nfunction indentString(state, cols) {\n let result = \"\", ts = state.tabSize, ch = state.facet(indentUnit)[0];\n if (ch == \"\\t\") {\n while (cols >= ts) {\n result += \"\\t\";\n cols -= ts;\n }\n ch = \" \";\n }\n for (let i = 0; i < cols; i++)\n result += ch;\n return result;\n}\n/**\nGet the indentation, as a column number, at the given position.\nWill first consult any [indent services](https://codemirror.net/6/docs/ref/#language.indentService)\nthat are registered, and if none of those return an indentation,\nthis will check the syntax tree for the [indent node\nprop](https://codemirror.net/6/docs/ref/#language.indentNodeProp) and use that if found. Returns a\nnumber when an indentation could be determined, and null\notherwise.\n*/\nfunction getIndentation(context, pos) {\n if (context instanceof EditorState)\n context = new IndentContext(context);\n for (let service of context.state.facet(indentService)) {\n let result = service(context, pos);\n if (result !== undefined)\n return result;\n }\n let tree = syntaxTree(context.state);\n return tree.length >= pos ? syntaxIndentation(context, tree, pos) : null;\n}\n/**\nCreate a change set that auto-indents all lines touched by the\ngiven document range.\n*/\nfunction indentRange(state, from, to) {\n let updated = Object.create(null);\n let context = new IndentContext(state, { overrideIndentation: start => { var _a; return (_a = updated[start]) !== null && _a !== void 0 ? _a : -1; } });\n let changes = [];\n for (let pos = from; pos <= to;) {\n let line = state.doc.lineAt(pos);\n pos = line.to + 1;\n let indent = getIndentation(context, line.from);\n if (indent == null)\n continue;\n if (!/\\S/.test(line.text))\n indent = 0;\n let cur = /^\\s*/.exec(line.text)[0];\n let norm = indentString(state, indent);\n if (cur != norm) {\n updated[line.from] = indent;\n changes.push({ from: line.from, to: line.from + cur.length, insert: norm });\n }\n }\n return state.changes(changes);\n}\n/**\nIndentation contexts are used when calling [indentation\nservices](https://codemirror.net/6/docs/ref/#language.indentService). They provide helper utilities\nuseful in indentation logic, and can selectively override the\nindentation reported for some lines.\n*/\nclass IndentContext {\n /**\n Create an indent context.\n */\n constructor(\n /**\n The editor state.\n */\n state, \n /**\n @internal\n */\n options = {}) {\n this.state = state;\n this.options = options;\n this.unit = getIndentUnit(state);\n }\n /**\n Get a description of the line at the given position, taking\n [simulated line\n breaks](https://codemirror.net/6/docs/ref/#language.IndentContext.constructor^options.simulateBreak)\n into account. If there is such a break at `pos`, the `bias`\n argument determines whether the part of the line line before or\n after the break is used.\n */\n lineAt(pos, bias = 1) {\n let line = this.state.doc.lineAt(pos);\n let { simulateBreak, simulateDoubleBreak } = this.options;\n if (simulateBreak != null && simulateBreak >= line.from && simulateBreak <= line.to) {\n if (simulateDoubleBreak && simulateBreak == pos)\n return { text: \"\", from: pos };\n else if (bias < 0 ? simulateBreak < pos : simulateBreak <= pos)\n return { text: line.text.slice(simulateBreak - line.from), from: simulateBreak };\n else\n return { text: line.text.slice(0, simulateBreak - line.from), from: line.from };\n }\n return line;\n }\n /**\n Get the text directly after `pos`, either the entire line\n or the next 100 characters, whichever is shorter.\n */\n textAfterPos(pos, bias = 1) {\n if (this.options.simulateDoubleBreak && pos == this.options.simulateBreak)\n return \"\";\n let { text, from } = this.lineAt(pos, bias);\n return text.slice(pos - from, Math.min(text.length, pos + 100 - from));\n }\n /**\n Find the column for the given position.\n */\n column(pos, bias = 1) {\n let { text, from } = this.lineAt(pos, bias);\n let result = this.countColumn(text, pos - from);\n let override = this.options.overrideIndentation ? this.options.overrideIndentation(from) : -1;\n if (override > -1)\n result += override - this.countColumn(text, text.search(/\\S|$/));\n return result;\n }\n /**\n Find the column position (taking tabs into account) of the given\n position in the given string.\n */\n countColumn(line, pos = line.length) {\n return countColumn(line, this.state.tabSize, pos);\n }\n /**\n Find the indentation column of the line at the given point.\n */\n lineIndent(pos, bias = 1) {\n let { text, from } = this.lineAt(pos, bias);\n let override = this.options.overrideIndentation;\n if (override) {\n let overriden = override(from);\n if (overriden > -1)\n return overriden;\n }\n return this.countColumn(text, text.search(/\\S|$/));\n }\n /**\n Returns the [simulated line\n break](https://codemirror.net/6/docs/ref/#language.IndentContext.constructor^options.simulateBreak)\n for this context, if any.\n */\n get simulatedBreak() {\n return this.options.simulateBreak || null;\n }\n}\n/**\nA syntax tree node prop used to associate indentation strategies\nwith node types. Such a strategy is a function from an indentation\ncontext to a column number (see also\n[`indentString`](https://codemirror.net/6/docs/ref/#language.indentString)) or null, where null\nindicates that no definitive indentation can be determined.\n*/\nconst indentNodeProp = /*@__PURE__*/new NodeProp();\n// Compute the indentation for a given position from the syntax tree.\nfunction syntaxIndentation(cx, ast, pos) {\n let stack = ast.resolveStack(pos);\n let inner = stack.node.enterUnfinishedNodesBefore(pos);\n if (inner != stack.node) {\n let add = [];\n for (let cur = inner; cur != stack.node; cur = cur.parent)\n add.push(cur);\n for (let i = add.length - 1; i >= 0; i--)\n stack = { node: add[i], next: stack };\n }\n return indentFor(stack, cx, pos);\n}\nfunction indentFor(stack, cx, pos) {\n for (let cur = stack; cur; cur = cur.next) {\n let strategy = indentStrategy(cur.node);\n if (strategy)\n return strategy(TreeIndentContext.create(cx, pos, cur));\n }\n return 0;\n}\nfunction ignoreClosed(cx) {\n return cx.pos == cx.options.simulateBreak && cx.options.simulateDoubleBreak;\n}\nfunction indentStrategy(tree) {\n let strategy = tree.type.prop(indentNodeProp);\n if (strategy)\n return strategy;\n let first = tree.firstChild, close;\n if (first && (close = first.type.prop(NodeProp.closedBy))) {\n let last = tree.lastChild, closed = last && close.indexOf(last.name) > -1;\n return cx => delimitedStrategy(cx, true, 1, undefined, closed && !ignoreClosed(cx) ? last.from : undefined);\n }\n return tree.parent == null ? topIndent : null;\n}\nfunction topIndent() { return 0; }\n/**\nObjects of this type provide context information and helper\nmethods to indentation functions registered on syntax nodes.\n*/\nclass TreeIndentContext extends IndentContext {\n constructor(base, \n /**\n The position at which indentation is being computed.\n */\n pos, \n /**\n @internal\n */\n context) {\n super(base.state, base.options);\n this.base = base;\n this.pos = pos;\n this.context = context;\n }\n /**\n The syntax tree node to which the indentation strategy\n applies.\n */\n get node() { return this.context.node; }\n /**\n @internal\n */\n static create(base, pos, context) {\n return new TreeIndentContext(base, pos, context);\n }\n /**\n Get the text directly after `this.pos`, either the entire line\n or the next 100 characters, whichever is shorter.\n */\n get textAfter() {\n return this.textAfterPos(this.pos);\n }\n /**\n Get the indentation at the reference line for `this.node`, which\n is the line on which it starts, unless there is a node that is\n _not_ a parent of this node covering the start of that line. If\n so, the line at the start of that node is tried, again skipping\n on if it is covered by another such node.\n */\n get baseIndent() {\n return this.baseIndentFor(this.node);\n }\n /**\n Get the indentation for the reference line of the given node\n (see [`baseIndent`](https://codemirror.net/6/docs/ref/#language.TreeIndentContext.baseIndent)).\n */\n baseIndentFor(node) {\n let line = this.state.doc.lineAt(node.from);\n // Skip line starts that are covered by a sibling (or cousin, etc)\n for (;;) {\n let atBreak = node.resolve(line.from);\n while (atBreak.parent && atBreak.parent.from == atBreak.from)\n atBreak = atBreak.parent;\n if (isParent(atBreak, node))\n break;\n line = this.state.doc.lineAt(atBreak.from);\n }\n return this.lineIndent(line.from);\n }\n /**\n Continue looking for indentations in the node's parent nodes,\n and return the result of that.\n */\n continue() {\n return indentFor(this.context.next, this.base, this.pos);\n }\n}\nfunction isParent(parent, of) {\n for (let cur = of; cur; cur = cur.parent)\n if (parent == cur)\n return true;\n return false;\n}\n// Check whether a delimited node is aligned (meaning there are\n// non-skipped nodes on the same line as the opening delimiter). And\n// if so, return the opening token.\nfunction bracketedAligned(context) {\n let tree = context.node;\n let openToken = tree.childAfter(tree.from), last = tree.lastChild;\n if (!openToken)\n return null;\n let sim = context.options.simulateBreak;\n let openLine = context.state.doc.lineAt(openToken.from);\n let lineEnd = sim == null || sim <= openLine.from ? openLine.to : Math.min(openLine.to, sim);\n for (let pos = openToken.to;;) {\n let next = tree.childAfter(pos);\n if (!next || next == last)\n return null;\n if (!next.type.isSkipped)\n return next.from < lineEnd ? openToken : null;\n pos = next.to;\n }\n}\n/**\nAn indentation strategy for delimited (usually bracketed) nodes.\nWill, by default, indent one unit more than the parent's base\nindent unless the line starts with a closing token. When `align`\nis true and there are non-skipped nodes on the node's opening\nline, the content of the node will be aligned with the end of the\nopening node, like this:\n\n foo(bar,\n baz)\n*/\nfunction delimitedIndent({ closing, align = true, units = 1 }) {\n return (context) => delimitedStrategy(context, align, units, closing);\n}\nfunction delimitedStrategy(context, align, units, closing, closedAt) {\n let after = context.textAfter, space = after.match(/^\\s*/)[0].length;\n let closed = closing && after.slice(space, space + closing.length) == closing || closedAt == context.pos + space;\n let aligned = align ? bracketedAligned(context) : null;\n if (aligned)\n return closed ? context.column(aligned.from) : context.column(aligned.to);\n return context.baseIndent + (closed ? 0 : context.unit * units);\n}\n/**\nAn indentation strategy that aligns a node's content to its base\nindentation.\n*/\nconst flatIndent = (context) => context.baseIndent;\n/**\nCreates an indentation strategy that, by default, indents\ncontinued lines one unit more than the node's base indentation.\nYou can provide `except` to prevent indentation of lines that\nmatch a pattern (for example `/^else\\b/` in `if`/`else`\nconstructs), and you can change the amount of units used with the\n`units` option.\n*/\nfunction continuedIndent({ except, units = 1 } = {}) {\n return (context) => {\n let matchExcept = except && except.test(context.textAfter);\n return context.baseIndent + (matchExcept ? 0 : units * context.unit);\n };\n}\nconst DontIndentBeyond = 200;\n/**\nEnables reindentation on input. When a language defines an\n`indentOnInput` field in its [language\ndata](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt), which must hold a regular\nexpression, the line at the cursor will be reindented whenever new\ntext is typed and the input from the start of the line up to the\ncursor matches that regexp.\n\nTo avoid unneccesary reindents, it is recommended to start the\nregexp with `^` (usually followed by `\\s*`), and end it with `$`.\nFor example, `/^\\s*\\}$/` will reindent when a closing brace is\nadded at the start of a line.\n*/\nfunction indentOnInput() {\n return EditorState.transactionFilter.of(tr => {\n if (!tr.docChanged || !tr.isUserEvent(\"input.type\") && !tr.isUserEvent(\"input.complete\"))\n return tr;\n let rules = tr.startState.languageDataAt(\"indentOnInput\", tr.startState.selection.main.head);\n if (!rules.length)\n return tr;\n let doc = tr.newDoc, { head } = tr.newSelection.main, line = doc.lineAt(head);\n if (head > line.from + DontIndentBeyond)\n return tr;\n let lineStart = doc.sliceString(line.from, head);\n if (!rules.some(r => r.test(lineStart)))\n return tr;\n let { state } = tr, last = -1, changes = [];\n for (let { head } of state.selection.ranges) {\n let line = state.doc.lineAt(head);\n if (line.from == last)\n continue;\n last = line.from;\n let indent = getIndentation(state, line.from);\n if (indent == null)\n continue;\n let cur = /^\\s*/.exec(line.text)[0];\n let norm = indentString(state, indent);\n if (cur != norm)\n changes.push({ from: line.from, to: line.from + cur.length, insert: norm });\n }\n return changes.length ? [tr, { changes, sequential: true }] : tr;\n });\n}\n\n/**\nA facet that registers a code folding service. When called with\nthe extent of a line, such a function should return a foldable\nrange that starts on that line (but continues beyond it), if one\ncan be found.\n*/\nconst foldService = /*@__PURE__*/Facet.define();\n/**\nThis node prop is used to associate folding information with\nsyntax node types. Given a syntax node, it should check whether\nthat tree is foldable and return the range that can be collapsed\nwhen it is.\n*/\nconst foldNodeProp = /*@__PURE__*/new NodeProp();\n/**\n[Fold](https://codemirror.net/6/docs/ref/#language.foldNodeProp) function that folds everything but\nthe first and the last child of a syntax node. Useful for nodes\nthat start and end with delimiters.\n*/\nfunction foldInside(node) {\n let first = node.firstChild, last = node.lastChild;\n return first && first.to < last.from ? { from: first.to, to: last.type.isError ? node.to : last.from } : null;\n}\nfunction syntaxFolding(state, start, end) {\n let tree = syntaxTree(state);\n if (tree.length < end)\n return null;\n let stack = tree.resolveStack(end, 1);\n let found = null;\n for (let iter = stack; iter; iter = iter.next) {\n let cur = iter.node;\n if (cur.to <= end || cur.from > end)\n continue;\n if (found && cur.from < start)\n break;\n let prop = cur.type.prop(foldNodeProp);\n if (prop && (cur.to < tree.length - 50 || tree.length == state.doc.length || !isUnfinished(cur))) {\n let value = prop(cur, state);\n if (value && value.from <= end && value.from >= start && value.to > end)\n found = value;\n }\n }\n return found;\n}\nfunction isUnfinished(node) {\n let ch = node.lastChild;\n return ch && ch.to == node.to && ch.type.isError;\n}\n/**\nCheck whether the given line is foldable. First asks any fold\nservices registered through\n[`foldService`](https://codemirror.net/6/docs/ref/#language.foldService), and if none of them return\na result, tries to query the [fold node\nprop](https://codemirror.net/6/docs/ref/#language.foldNodeProp) of syntax nodes that cover the end\nof the line.\n*/\nfunction foldable(state, lineStart, lineEnd) {\n for (let service of state.facet(foldService)) {\n let result = service(state, lineStart, lineEnd);\n if (result)\n return result;\n }\n return syntaxFolding(state, lineStart, lineEnd);\n}\nfunction mapRange(range, mapping) {\n let from = mapping.mapPos(range.from, 1), to = mapping.mapPos(range.to, -1);\n return from >= to ? undefined : { from, to };\n}\n/**\nState effect that can be attached to a transaction to fold the\ngiven range. (You probably only need this in exceptional\ncircumstances—usually you'll just want to let\n[`foldCode`](https://codemirror.net/6/docs/ref/#language.foldCode) and the [fold\ngutter](https://codemirror.net/6/docs/ref/#language.foldGutter) create the transactions.)\n*/\nconst foldEffect = /*@__PURE__*/StateEffect.define({ map: mapRange });\n/**\nState effect that unfolds the given range (if it was folded).\n*/\nconst unfoldEffect = /*@__PURE__*/StateEffect.define({ map: mapRange });\nfunction selectedLines(view) {\n let lines = [];\n for (let { head } of view.state.selection.ranges) {\n if (lines.some(l => l.from <= head && l.to >= head))\n continue;\n lines.push(view.lineBlockAt(head));\n }\n return lines;\n}\n/**\nThe state field that stores the folded ranges (as a [decoration\nset](https://codemirror.net/6/docs/ref/#view.DecorationSet)). Can be passed to\n[`EditorState.toJSON`](https://codemirror.net/6/docs/ref/#state.EditorState.toJSON) and\n[`fromJSON`](https://codemirror.net/6/docs/ref/#state.EditorState^fromJSON) to serialize the fold\nstate.\n*/\nconst foldState = /*@__PURE__*/StateField.define({\n create() {\n return Decoration.none;\n },\n update(folded, tr) {\n folded = folded.map(tr.changes);\n for (let e of tr.effects) {\n if (e.is(foldEffect) && !foldExists(folded, e.value.from, e.value.to)) {\n let { preparePlaceholder } = tr.state.facet(foldConfig);\n let widget = !preparePlaceholder ? foldWidget :\n Decoration.replace({ widget: new PreparedFoldWidget(preparePlaceholder(tr.state, e.value)) });\n folded = folded.update({ add: [widget.range(e.value.from, e.value.to)] });\n }\n else if (e.is(unfoldEffect)) {\n folded = folded.update({ filter: (from, to) => e.value.from != from || e.value.to != to,\n filterFrom: e.value.from, filterTo: e.value.to });\n }\n }\n // Clear folded ranges that cover the selection head\n if (tr.selection) {\n let onSelection = false, { head } = tr.selection.main;\n folded.between(head, head, (a, b) => { if (a < head && b > head)\n onSelection = true; });\n if (onSelection)\n folded = folded.update({\n filterFrom: head,\n filterTo: head,\n filter: (a, b) => b <= head || a >= head\n });\n }\n return folded;\n },\n provide: f => EditorView.decorations.from(f),\n toJSON(folded, state) {\n let ranges = [];\n folded.between(0, state.doc.length, (from, to) => { ranges.push(from, to); });\n return ranges;\n },\n fromJSON(value) {\n if (!Array.isArray(value) || value.length % 2)\n throw new RangeError(\"Invalid JSON for fold state\");\n let ranges = [];\n for (let i = 0; i < value.length;) {\n let from = value[i++], to = value[i++];\n if (typeof from != \"number\" || typeof to != \"number\")\n throw new RangeError(\"Invalid JSON for fold state\");\n ranges.push(foldWidget.range(from, to));\n }\n return Decoration.set(ranges, true);\n }\n});\n/**\nGet a [range set](https://codemirror.net/6/docs/ref/#state.RangeSet) containing the folded ranges\nin the given state.\n*/\nfunction foldedRanges(state) {\n return state.field(foldState, false) || RangeSet.empty;\n}\nfunction findFold(state, from, to) {\n var _a;\n let found = null;\n (_a = state.field(foldState, false)) === null || _a === void 0 ? void 0 : _a.between(from, to, (from, to) => {\n if (!found || found.from > from)\n found = { from, to };\n });\n return found;\n}\nfunction foldExists(folded, from, to) {\n let found = false;\n folded.between(from, from, (a, b) => { if (a == from && b == to)\n found = true; });\n return found;\n}\nfunction maybeEnable(state, other) {\n return state.field(foldState, false) ? other : other.concat(StateEffect.appendConfig.of(codeFolding()));\n}\n/**\nFold the lines that are selected, if possible.\n*/\nconst foldCode = view => {\n for (let line of selectedLines(view)) {\n let range = foldable(view.state, line.from, line.to);\n if (range) {\n view.dispatch({ effects: maybeEnable(view.state, [foldEffect.of(range), announceFold(view, range)]) });\n return true;\n }\n }\n return false;\n};\n/**\nUnfold folded ranges on selected lines.\n*/\nconst unfoldCode = view => {\n if (!view.state.field(foldState, false))\n return false;\n let effects = [];\n for (let line of selectedLines(view)) {\n let folded = findFold(view.state, line.from, line.to);\n if (folded)\n effects.push(unfoldEffect.of(folded), announceFold(view, folded, false));\n }\n if (effects.length)\n view.dispatch({ effects });\n return effects.length > 0;\n};\nfunction announceFold(view, range, fold = true) {\n let lineFrom = view.state.doc.lineAt(range.from).number, lineTo = view.state.doc.lineAt(range.to).number;\n return EditorView.announce.of(`${view.state.phrase(fold ? \"Folded lines\" : \"Unfolded lines\")} ${lineFrom} ${view.state.phrase(\"to\")} ${lineTo}.`);\n}\n/**\nFold all top-level foldable ranges. Note that, in most cases,\nfolding information will depend on the [syntax\ntree](https://codemirror.net/6/docs/ref/#language.syntaxTree), and folding everything may not work\nreliably when the document hasn't been fully parsed (either\nbecause the editor state was only just initialized, or because the\ndocument is so big that the parser decided not to parse it\nentirely).\n*/\nconst foldAll = view => {\n let { state } = view, effects = [];\n for (let pos = 0; pos < state.doc.length;) {\n let line = view.lineBlockAt(pos), range = foldable(state, line.from, line.to);\n if (range)\n effects.push(foldEffect.of(range));\n pos = (range ? view.lineBlockAt(range.to) : line).to + 1;\n }\n if (effects.length)\n view.dispatch({ effects: maybeEnable(view.state, effects) });\n return !!effects.length;\n};\n/**\nUnfold all folded code.\n*/\nconst unfoldAll = view => {\n let field = view.state.field(foldState, false);\n if (!field || !field.size)\n return false;\n let effects = [];\n field.between(0, view.state.doc.length, (from, to) => { effects.push(unfoldEffect.of({ from, to })); });\n view.dispatch({ effects });\n return true;\n};\n// Find the foldable region containing the given line, if one exists\nfunction foldableContainer(view, lineBlock) {\n // Look backwards through line blocks until we find a foldable region that\n // intersects with the line\n for (let line = lineBlock;;) {\n let foldableRegion = foldable(view.state, line.from, line.to);\n if (foldableRegion && foldableRegion.to > lineBlock.from)\n return foldableRegion;\n if (!line.from)\n return null;\n line = view.lineBlockAt(line.from - 1);\n }\n}\n/**\nToggle folding at cursors. Unfolds if there is an existing fold\nstarting in that line, tries to find a foldable range around it\notherwise.\n*/\nconst toggleFold = (view) => {\n let effects = [];\n for (let line of selectedLines(view)) {\n let folded = findFold(view.state, line.from, line.to);\n if (folded) {\n effects.push(unfoldEffect.of(folded), announceFold(view, folded, false));\n }\n else {\n let foldRange = foldableContainer(view, line);\n if (foldRange)\n effects.push(foldEffect.of(foldRange), announceFold(view, foldRange));\n }\n }\n if (effects.length > 0)\n view.dispatch({ effects: maybeEnable(view.state, effects) });\n return !!effects.length;\n};\n/**\nDefault fold-related key bindings.\n\n - Ctrl-Shift-[ (Cmd-Alt-[ on macOS): [`foldCode`](https://codemirror.net/6/docs/ref/#language.foldCode).\n - Ctrl-Shift-] (Cmd-Alt-] on macOS): [`unfoldCode`](https://codemirror.net/6/docs/ref/#language.unfoldCode).\n - Ctrl-Alt-[: [`foldAll`](https://codemirror.net/6/docs/ref/#language.foldAll).\n - Ctrl-Alt-]: [`unfoldAll`](https://codemirror.net/6/docs/ref/#language.unfoldAll).\n*/\nconst foldKeymap = [\n { key: \"Ctrl-Shift-[\", mac: \"Cmd-Alt-[\", run: foldCode },\n { key: \"Ctrl-Shift-]\", mac: \"Cmd-Alt-]\", run: unfoldCode },\n { key: \"Ctrl-Alt-[\", run: foldAll },\n { key: \"Ctrl-Alt-]\", run: unfoldAll }\n];\nconst defaultConfig = {\n placeholderDOM: null,\n preparePlaceholder: null,\n placeholderText: \"…\"\n};\nconst foldConfig = /*@__PURE__*/Facet.define({\n combine(values) { return combineConfig(values, defaultConfig); }\n});\n/**\nCreate an extension that configures code folding.\n*/\nfunction codeFolding(config) {\n let result = [foldState, baseTheme$1];\n if (config)\n result.push(foldConfig.of(config));\n return result;\n}\nfunction widgetToDOM(view, prepared) {\n let { state } = view, conf = state.facet(foldConfig);\n let onclick = (event) => {\n let line = view.lineBlockAt(view.posAtDOM(event.target));\n let folded = findFold(view.state, line.from, line.to);\n if (folded)\n view.dispatch({ effects: unfoldEffect.of(folded) });\n event.preventDefault();\n };\n if (conf.placeholderDOM)\n return conf.placeholderDOM(view, onclick, prepared);\n let element = document.createElement(\"span\");\n element.textContent = conf.placeholderText;\n element.setAttribute(\"aria-label\", state.phrase(\"folded code\"));\n element.title = state.phrase(\"unfold\");\n element.className = \"cm-foldPlaceholder\";\n element.onclick = onclick;\n return element;\n}\nconst foldWidget = /*@__PURE__*/Decoration.replace({ widget: /*@__PURE__*/new class extends WidgetType {\n toDOM(view) { return widgetToDOM(view, null); }\n } });\nclass PreparedFoldWidget extends WidgetType {\n constructor(value) {\n super();\n this.value = value;\n }\n eq(other) { return this.value == other.value; }\n toDOM(view) { return widgetToDOM(view, this.value); }\n}\nconst foldGutterDefaults = {\n openText: \"⌄\",\n closedText: \"\",\n markerDOM: null,\n domEventHandlers: {},\n foldingChanged: () => false\n};\nclass FoldMarker extends GutterMarker {\n constructor(config, open) {\n super();\n this.config = config;\n this.open = open;\n }\n eq(other) { return this.config == other.config && this.open == other.open; }\n toDOM(view) {\n if (this.config.markerDOM)\n return this.config.markerDOM(this.open);\n let span = document.createElement(\"span\");\n span.textContent = this.open ? this.config.openText : this.config.closedText;\n span.title = view.state.phrase(this.open ? \"Fold line\" : \"Unfold line\");\n return span;\n }\n}\n/**\nCreate an extension that registers a fold gutter, which shows a\nfold status indicator before foldable lines (which can be clicked\nto fold or unfold the line).\n*/\nfunction foldGutter(config = {}) {\n let fullConfig = Object.assign(Object.assign({}, foldGutterDefaults), config);\n let canFold = new FoldMarker(fullConfig, true), canUnfold = new FoldMarker(fullConfig, false);\n let markers = ViewPlugin.fromClass(class {\n constructor(view) {\n this.from = view.viewport.from;\n this.markers = this.buildMarkers(view);\n }\n update(update) {\n if (update.docChanged || update.viewportChanged ||\n update.startState.facet(language) != update.state.facet(language) ||\n update.startState.field(foldState, false) != update.state.field(foldState, false) ||\n syntaxTree(update.startState) != syntaxTree(update.state) ||\n fullConfig.foldingChanged(update))\n this.markers = this.buildMarkers(update.view);\n }\n buildMarkers(view) {\n let builder = new RangeSetBuilder();\n for (let line of view.viewportLineBlocks) {\n let mark = findFold(view.state, line.from, line.to) ? canUnfold\n : foldable(view.state, line.from, line.to) ? canFold : null;\n if (mark)\n builder.add(line.from, line.from, mark);\n }\n return builder.finish();\n }\n });\n let { domEventHandlers } = fullConfig;\n return [\n markers,\n gutter({\n class: \"cm-foldGutter\",\n markers(view) { var _a; return ((_a = view.plugin(markers)) === null || _a === void 0 ? void 0 : _a.markers) || RangeSet.empty; },\n initialSpacer() {\n return new FoldMarker(fullConfig, false);\n },\n domEventHandlers: Object.assign(Object.assign({}, domEventHandlers), { click: (view, line, event) => {\n if (domEventHandlers.click && domEventHandlers.click(view, line, event))\n return true;\n let folded = findFold(view.state, line.from, line.to);\n if (folded) {\n view.dispatch({ effects: unfoldEffect.of(folded) });\n return true;\n }\n let range = foldable(view.state, line.from, line.to);\n if (range) {\n view.dispatch({ effects: foldEffect.of(range) });\n return true;\n }\n return false;\n } })\n }),\n codeFolding()\n ];\n}\nconst baseTheme$1 = /*@__PURE__*/EditorView.baseTheme({\n \".cm-foldPlaceholder\": {\n backgroundColor: \"#eee\",\n border: \"1px solid #ddd\",\n color: \"#888\",\n borderRadius: \".2em\",\n margin: \"0 1px\",\n padding: \"0 1px\",\n cursor: \"pointer\"\n },\n \".cm-foldGutter span\": {\n padding: \"0 1px\",\n cursor: \"pointer\"\n }\n});\n\n/**\nA highlight style associates CSS styles with higlighting\n[tags](https://lezer.codemirror.net/docs/ref#highlight.Tag).\n*/\nclass HighlightStyle {\n constructor(\n /**\n The tag styles used to create this highlight style.\n */\n specs, options) {\n this.specs = specs;\n let modSpec;\n function def(spec) {\n let cls = StyleModule.newName();\n (modSpec || (modSpec = Object.create(null)))[\".\" + cls] = spec;\n return cls;\n }\n const all = typeof options.all == \"string\" ? options.all : options.all ? def(options.all) : undefined;\n const scopeOpt = options.scope;\n this.scope = scopeOpt instanceof Language ? (type) => type.prop(languageDataProp) == scopeOpt.data\n : scopeOpt ? (type) => type == scopeOpt : undefined;\n this.style = tagHighlighter(specs.map(style => ({\n tag: style.tag,\n class: style.class || def(Object.assign({}, style, { tag: null }))\n })), {\n all,\n }).style;\n this.module = modSpec ? new StyleModule(modSpec) : null;\n this.themeType = options.themeType;\n }\n /**\n Create a highlighter style that associates the given styles to\n the given tags. The specs must be objects that hold a style tag\n or array of tags in their `tag` property, and either a single\n `class` property providing a static CSS class (for highlighter\n that rely on external styling), or a\n [`style-mod`](https://github.com/marijnh/style-mod#documentation)-style\n set of CSS properties (which define the styling for those tags).\n \n The CSS rules created for a highlighter will be emitted in the\n order of the spec's properties. That means that for elements that\n have multiple tags associated with them, styles defined further\n down in the list will have a higher CSS precedence than styles\n defined earlier.\n */\n static define(specs, options) {\n return new HighlightStyle(specs, options || {});\n }\n}\nconst highlighterFacet = /*@__PURE__*/Facet.define();\nconst fallbackHighlighter = /*@__PURE__*/Facet.define({\n combine(values) { return values.length ? [values[0]] : null; }\n});\nfunction getHighlighters(state) {\n let main = state.facet(highlighterFacet);\n return main.length ? main : state.facet(fallbackHighlighter);\n}\n/**\nWrap a highlighter in an editor extension that uses it to apply\nsyntax highlighting to the editor content.\n\nWhen multiple (non-fallback) styles are provided, the styling\napplied is the union of the classes they emit.\n*/\nfunction syntaxHighlighting(highlighter, options) {\n let ext = [treeHighlighter], themeType;\n if (highlighter instanceof HighlightStyle) {\n if (highlighter.module)\n ext.push(EditorView.styleModule.of(highlighter.module));\n themeType = highlighter.themeType;\n }\n if (options === null || options === void 0 ? void 0 : options.fallback)\n ext.push(fallbackHighlighter.of(highlighter));\n else if (themeType)\n ext.push(highlighterFacet.computeN([EditorView.darkTheme], state => {\n return state.facet(EditorView.darkTheme) == (themeType == \"dark\") ? [highlighter] : [];\n }));\n else\n ext.push(highlighterFacet.of(highlighter));\n return ext;\n}\n/**\nReturns the CSS classes (if any) that the highlighters active in\nthe state would assign to the given style\n[tags](https://lezer.codemirror.net/docs/ref#highlight.Tag) and\n(optional) language\n[scope](https://codemirror.net/6/docs/ref/#language.HighlightStyle^define^options.scope).\n*/\nfunction highlightingFor(state, tags, scope) {\n let highlighters = getHighlighters(state);\n let result = null;\n if (highlighters)\n for (let highlighter of highlighters) {\n if (!highlighter.scope || scope && highlighter.scope(scope)) {\n let cls = highlighter.style(tags);\n if (cls)\n result = result ? result + \" \" + cls : cls;\n }\n }\n return result;\n}\nclass TreeHighlighter {\n constructor(view) {\n this.markCache = Object.create(null);\n this.tree = syntaxTree(view.state);\n this.decorations = this.buildDeco(view, getHighlighters(view.state));\n }\n update(update) {\n let tree = syntaxTree(update.state), highlighters = getHighlighters(update.state);\n let styleChange = highlighters != getHighlighters(update.startState);\n if (tree.length < update.view.viewport.to && !styleChange && tree.type == this.tree.type) {\n this.decorations = this.decorations.map(update.changes);\n }\n else if (tree != this.tree || update.viewportChanged || styleChange) {\n this.tree = tree;\n this.decorations = this.buildDeco(update.view, highlighters);\n }\n }\n buildDeco(view, highlighters) {\n if (!highlighters || !this.tree.length)\n return Decoration.none;\n let builder = new RangeSetBuilder();\n for (let { from, to } of view.visibleRanges) {\n highlightTree(this.tree, highlighters, (from, to, style) => {\n builder.add(from, to, this.markCache[style] || (this.markCache[style] = Decoration.mark({ class: style })));\n }, from, to);\n }\n return builder.finish();\n }\n}\nconst treeHighlighter = /*@__PURE__*/Prec.high(/*@__PURE__*/ViewPlugin.fromClass(TreeHighlighter, {\n decorations: v => v.decorations\n}));\n/**\nA default highlight style (works well with light themes).\n*/\nconst defaultHighlightStyle = /*@__PURE__*/HighlightStyle.define([\n { tag: tags.meta,\n color: \"#404740\" },\n { tag: tags.link,\n textDecoration: \"underline\" },\n { tag: tags.heading,\n textDecoration: \"underline\",\n fontWeight: \"bold\" },\n { tag: tags.emphasis,\n fontStyle: \"italic\" },\n { tag: tags.strong,\n fontWeight: \"bold\" },\n { tag: tags.strikethrough,\n textDecoration: \"line-through\" },\n { tag: tags.keyword,\n color: \"#708\" },\n { tag: [tags.atom, tags.bool, tags.url, tags.contentSeparator, tags.labelName],\n color: \"#219\" },\n { tag: [tags.literal, tags.inserted],\n color: \"#164\" },\n { tag: [tags.string, tags.deleted],\n color: \"#a11\" },\n { tag: [tags.regexp, tags.escape, /*@__PURE__*/tags.special(tags.string)],\n color: \"#e40\" },\n { tag: /*@__PURE__*/tags.definition(tags.variableName),\n color: \"#00f\" },\n { tag: /*@__PURE__*/tags.local(tags.variableName),\n color: \"#30a\" },\n { tag: [tags.typeName, tags.namespace],\n color: \"#085\" },\n { tag: tags.className,\n color: \"#167\" },\n { tag: [/*@__PURE__*/tags.special(tags.variableName), tags.macroName],\n color: \"#256\" },\n { tag: /*@__PURE__*/tags.definition(tags.propertyName),\n color: \"#00c\" },\n { tag: tags.comment,\n color: \"#940\" },\n { tag: tags.invalid,\n color: \"#f00\" }\n]);\n\nconst baseTheme = /*@__PURE__*/EditorView.baseTheme({\n \"&.cm-focused .cm-matchingBracket\": { backgroundColor: \"#328c8252\" },\n \"&.cm-focused .cm-nonmatchingBracket\": { backgroundColor: \"#bb555544\" }\n});\nconst DefaultScanDist = 10000, DefaultBrackets = \"()[]{}\";\nconst bracketMatchingConfig = /*@__PURE__*/Facet.define({\n combine(configs) {\n return combineConfig(configs, {\n afterCursor: true,\n brackets: DefaultBrackets,\n maxScanDistance: DefaultScanDist,\n renderMatch: defaultRenderMatch\n });\n }\n});\nconst matchingMark = /*@__PURE__*/Decoration.mark({ class: \"cm-matchingBracket\" }), nonmatchingMark = /*@__PURE__*/Decoration.mark({ class: \"cm-nonmatchingBracket\" });\nfunction defaultRenderMatch(match) {\n let decorations = [];\n let mark = match.matched ? matchingMark : nonmatchingMark;\n decorations.push(mark.range(match.start.from, match.start.to));\n if (match.end)\n decorations.push(mark.range(match.end.from, match.end.to));\n return decorations;\n}\nconst bracketMatchingState = /*@__PURE__*/StateField.define({\n create() { return Decoration.none; },\n update(deco, tr) {\n if (!tr.docChanged && !tr.selection)\n return deco;\n let decorations = [];\n let config = tr.state.facet(bracketMatchingConfig);\n for (let range of tr.state.selection.ranges) {\n if (!range.empty)\n continue;\n let match = matchBrackets(tr.state, range.head, -1, config)\n || (range.head > 0 && matchBrackets(tr.state, range.head - 1, 1, config))\n || (config.afterCursor &&\n (matchBrackets(tr.state, range.head, 1, config) ||\n (range.head < tr.state.doc.length && matchBrackets(tr.state, range.head + 1, -1, config))));\n if (match)\n decorations = decorations.concat(config.renderMatch(match, tr.state));\n }\n return Decoration.set(decorations, true);\n },\n provide: f => EditorView.decorations.from(f)\n});\nconst bracketMatchingUnique = [\n bracketMatchingState,\n baseTheme\n];\n/**\nCreate an extension that enables bracket matching. Whenever the\ncursor is next to a bracket, that bracket and the one it matches\nare highlighted. Or, when no matching bracket is found, another\nhighlighting style is used to indicate this.\n*/\nfunction bracketMatching(config = {}) {\n return [bracketMatchingConfig.of(config), bracketMatchingUnique];\n}\n/**\nWhen larger syntax nodes, such as HTML tags, are marked as\nopening/closing, it can be a bit messy to treat the whole node as\na matchable bracket. This node prop allows you to define, for such\na node, a handle—the part of the node that is highlighted, and\nthat the cursor must be on to activate highlighting in the first\nplace.\n*/\nconst bracketMatchingHandle = /*@__PURE__*/new NodeProp();\nfunction matchingNodes(node, dir, brackets) {\n let byProp = node.prop(dir < 0 ? NodeProp.openedBy : NodeProp.closedBy);\n if (byProp)\n return byProp;\n if (node.name.length == 1) {\n let index = brackets.indexOf(node.name);\n if (index > -1 && index % 2 == (dir < 0 ? 1 : 0))\n return [brackets[index + dir]];\n }\n return null;\n}\nfunction findHandle(node) {\n let hasHandle = node.type.prop(bracketMatchingHandle);\n return hasHandle ? hasHandle(node.node) : node;\n}\n/**\nFind the matching bracket for the token at `pos`, scanning\ndirection `dir`. Only the `brackets` and `maxScanDistance`\nproperties are used from `config`, if given. Returns null if no\nbracket was found at `pos`, or a match result otherwise.\n*/\nfunction matchBrackets(state, pos, dir, config = {}) {\n let maxScanDistance = config.maxScanDistance || DefaultScanDist, brackets = config.brackets || DefaultBrackets;\n let tree = syntaxTree(state), node = tree.resolveInner(pos, dir);\n for (let cur = node; cur; cur = cur.parent) {\n let matches = matchingNodes(cur.type, dir, brackets);\n if (matches && cur.from < cur.to) {\n let handle = findHandle(cur);\n if (handle && (dir > 0 ? pos >= handle.from && pos < handle.to : pos > handle.from && pos <= handle.to))\n return matchMarkedBrackets(state, pos, dir, cur, handle, matches, brackets);\n }\n }\n return matchPlainBrackets(state, pos, dir, tree, node.type, maxScanDistance, brackets);\n}\nfunction matchMarkedBrackets(_state, _pos, dir, token, handle, matching, brackets) {\n let parent = token.parent, firstToken = { from: handle.from, to: handle.to };\n let depth = 0, cursor = parent === null || parent === void 0 ? void 0 : parent.cursor();\n if (cursor && (dir < 0 ? cursor.childBefore(token.from) : cursor.childAfter(token.to)))\n do {\n if (dir < 0 ? cursor.to <= token.from : cursor.from >= token.to) {\n if (depth == 0 && matching.indexOf(cursor.type.name) > -1 && cursor.from < cursor.to) {\n let endHandle = findHandle(cursor);\n return { start: firstToken, end: endHandle ? { from: endHandle.from, to: endHandle.to } : undefined, matched: true };\n }\n else if (matchingNodes(cursor.type, dir, brackets)) {\n depth++;\n }\n else if (matchingNodes(cursor.type, -dir, brackets)) {\n if (depth == 0) {\n let endHandle = findHandle(cursor);\n return {\n start: firstToken,\n end: endHandle && endHandle.from < endHandle.to ? { from: endHandle.from, to: endHandle.to } : undefined,\n matched: false\n };\n }\n depth--;\n }\n }\n } while (dir < 0 ? cursor.prevSibling() : cursor.nextSibling());\n return { start: firstToken, matched: false };\n}\nfunction matchPlainBrackets(state, pos, dir, tree, tokenType, maxScanDistance, brackets) {\n let startCh = dir < 0 ? state.sliceDoc(pos - 1, pos) : state.sliceDoc(pos, pos + 1);\n let bracket = brackets.indexOf(startCh);\n if (bracket < 0 || (bracket % 2 == 0) != (dir > 0))\n return null;\n let startToken = { from: dir < 0 ? pos - 1 : pos, to: dir > 0 ? pos + 1 : pos };\n let iter = state.doc.iterRange(pos, dir > 0 ? state.doc.length : 0), depth = 0;\n for (let distance = 0; !(iter.next()).done && distance <= maxScanDistance;) {\n let text = iter.value;\n if (dir < 0)\n distance += text.length;\n let basePos = pos + distance * dir;\n for (let pos = dir > 0 ? 0 : text.length - 1, end = dir > 0 ? text.length : -1; pos != end; pos += dir) {\n let found = brackets.indexOf(text[pos]);\n if (found < 0 || tree.resolveInner(basePos + pos, 1).type != tokenType)\n continue;\n if ((found % 2 == 0) == (dir > 0)) {\n depth++;\n }\n else if (depth == 1) { // Closing\n return { start: startToken, end: { from: basePos + pos, to: basePos + pos + 1 }, matched: (found >> 1) == (bracket >> 1) };\n }\n else {\n depth--;\n }\n }\n if (dir > 0)\n distance += text.length;\n }\n return iter.done ? { start: startToken, matched: false } : null;\n}\n\n// Counts the column offset in a string, taking tabs into account.\n// Used mostly to find indentation.\nfunction countCol(string, end, tabSize, startIndex = 0, startValue = 0) {\n if (end == null) {\n end = string.search(/[^\\s\\u00a0]/);\n if (end == -1)\n end = string.length;\n }\n let n = startValue;\n for (let i = startIndex; i < end; i++) {\n if (string.charCodeAt(i) == 9)\n n += tabSize - (n % tabSize);\n else\n n++;\n }\n return n;\n}\n/**\nEncapsulates a single line of input. Given to stream syntax code,\nwhich uses it to tokenize the content.\n*/\nclass StringStream {\n /**\n Create a stream.\n */\n constructor(\n /**\n The line.\n */\n string, tabSize, \n /**\n The current indent unit size.\n */\n indentUnit, overrideIndent) {\n this.string = string;\n this.tabSize = tabSize;\n this.indentUnit = indentUnit;\n this.overrideIndent = overrideIndent;\n /**\n The current position on the line.\n */\n this.pos = 0;\n /**\n The start position of the current token.\n */\n this.start = 0;\n this.lastColumnPos = 0;\n this.lastColumnValue = 0;\n }\n /**\n True if we are at the end of the line.\n */\n eol() { return this.pos >= this.string.length; }\n /**\n True if we are at the start of the line.\n */\n sol() { return this.pos == 0; }\n /**\n Get the next code unit after the current position, or undefined\n if we're at the end of the line.\n */\n peek() { return this.string.charAt(this.pos) || undefined; }\n /**\n Read the next code unit and advance `this.pos`.\n */\n next() {\n if (this.pos < this.string.length)\n return this.string.charAt(this.pos++);\n }\n /**\n Match the next character against the given string, regular\n expression, or predicate. Consume and return it if it matches.\n */\n eat(match) {\n let ch = this.string.charAt(this.pos);\n let ok;\n if (typeof match == \"string\")\n ok = ch == match;\n else\n ok = ch && (match instanceof RegExp ? match.test(ch) : match(ch));\n if (ok) {\n ++this.pos;\n return ch;\n }\n }\n /**\n Continue matching characters that match the given string,\n regular expression, or predicate function. Return true if any\n characters were consumed.\n */\n eatWhile(match) {\n let start = this.pos;\n while (this.eat(match)) { }\n return this.pos > start;\n }\n /**\n Consume whitespace ahead of `this.pos`. Return true if any was\n found.\n */\n eatSpace() {\n let start = this.pos;\n while (/[\\s\\u00a0]/.test(this.string.charAt(this.pos)))\n ++this.pos;\n return this.pos > start;\n }\n /**\n Move to the end of the line.\n */\n skipToEnd() { this.pos = this.string.length; }\n /**\n Move to directly before the given character, if found on the\n current line.\n */\n skipTo(ch) {\n let found = this.string.indexOf(ch, this.pos);\n if (found > -1) {\n this.pos = found;\n return true;\n }\n }\n /**\n Move back `n` characters.\n */\n backUp(n) { this.pos -= n; }\n /**\n Get the column position at `this.pos`.\n */\n column() {\n if (this.lastColumnPos < this.start) {\n this.lastColumnValue = countCol(this.string, this.start, this.tabSize, this.lastColumnPos, this.lastColumnValue);\n this.lastColumnPos = this.start;\n }\n return this.lastColumnValue;\n }\n /**\n Get the indentation column of the current line.\n */\n indentation() {\n var _a;\n return (_a = this.overrideIndent) !== null && _a !== void 0 ? _a : countCol(this.string, null, this.tabSize);\n }\n /**\n Match the input against the given string or regular expression\n (which should start with a `^`). Return true or the regexp match\n if it matches.\n \n Unless `consume` is set to `false`, this will move `this.pos`\n past the matched text.\n \n When matching a string `caseInsensitive` can be set to true to\n make the match case-insensitive.\n */\n match(pattern, consume, caseInsensitive) {\n if (typeof pattern == \"string\") {\n let cased = (str) => caseInsensitive ? str.toLowerCase() : str;\n let substr = this.string.substr(this.pos, pattern.length);\n if (cased(substr) == cased(pattern)) {\n if (consume !== false)\n this.pos += pattern.length;\n return true;\n }\n else\n return null;\n }\n else {\n let match = this.string.slice(this.pos).match(pattern);\n if (match && match.index > 0)\n return null;\n if (match && consume !== false)\n this.pos += match[0].length;\n return match;\n }\n }\n /**\n Get the current token.\n */\n current() { return this.string.slice(this.start, this.pos); }\n}\n\nfunction fullParser(spec) {\n return {\n name: spec.name || \"\",\n token: spec.token,\n blankLine: spec.blankLine || (() => { }),\n startState: spec.startState || (() => true),\n copyState: spec.copyState || defaultCopyState,\n indent: spec.indent || (() => null),\n languageData: spec.languageData || {},\n tokenTable: spec.tokenTable || noTokens\n };\n}\nfunction defaultCopyState(state) {\n if (typeof state != \"object\")\n return state;\n let newState = {};\n for (let prop in state) {\n let val = state[prop];\n newState[prop] = (val instanceof Array ? val.slice() : val);\n }\n return newState;\n}\nconst IndentedFrom = /*@__PURE__*/new WeakMap();\n/**\nA [language](https://codemirror.net/6/docs/ref/#language.Language) class based on a CodeMirror\n5-style [streaming parser](https://codemirror.net/6/docs/ref/#language.StreamParser).\n*/\nclass StreamLanguage extends Language {\n constructor(parser) {\n let data = defineLanguageFacet(parser.languageData);\n let p = fullParser(parser), self;\n let impl = new class extends Parser {\n createParse(input, fragments, ranges) {\n return new Parse(self, input, fragments, ranges);\n }\n };\n super(data, impl, [indentService.of((cx, pos) => this.getIndent(cx, pos))], parser.name);\n this.topNode = docID(data);\n self = this;\n this.streamParser = p;\n this.stateAfter = new NodeProp({ perNode: true });\n this.tokenTable = parser.tokenTable ? new TokenTable(p.tokenTable) : defaultTokenTable;\n }\n /**\n Define a stream language.\n */\n static define(spec) { return new StreamLanguage(spec); }\n getIndent(cx, pos) {\n let tree = syntaxTree(cx.state), at = tree.resolve(pos);\n while (at && at.type != this.topNode)\n at = at.parent;\n if (!at)\n return null;\n let from = undefined;\n let { overrideIndentation } = cx.options;\n if (overrideIndentation) {\n from = IndentedFrom.get(cx.state);\n if (from != null && from < pos - 1e4)\n from = undefined;\n }\n let start = findState(this, tree, 0, at.from, from !== null && from !== void 0 ? from : pos), statePos, state;\n if (start) {\n state = start.state;\n statePos = start.pos + 1;\n }\n else {\n state = this.streamParser.startState(cx.unit);\n statePos = 0;\n }\n if (pos - statePos > 10000 /* C.MaxIndentScanDist */)\n return null;\n while (statePos < pos) {\n let line = cx.state.doc.lineAt(statePos), end = Math.min(pos, line.to);\n if (line.length) {\n let indentation = overrideIndentation ? overrideIndentation(line.from) : -1;\n let stream = new StringStream(line.text, cx.state.tabSize, cx.unit, indentation < 0 ? undefined : indentation);\n while (stream.pos < end - line.from)\n readToken(this.streamParser.token, stream, state);\n }\n else {\n this.streamParser.blankLine(state, cx.unit);\n }\n if (end == pos)\n break;\n statePos = line.to + 1;\n }\n let line = cx.lineAt(pos);\n if (overrideIndentation && from == null)\n IndentedFrom.set(cx.state, line.from);\n return this.streamParser.indent(state, /^\\s*(.*)/.exec(line.text)[1], cx);\n }\n get allowsNesting() { return false; }\n}\nfunction findState(lang, tree, off, startPos, before) {\n let state = off >= startPos && off + tree.length <= before && tree.prop(lang.stateAfter);\n if (state)\n return { state: lang.streamParser.copyState(state), pos: off + tree.length };\n for (let i = tree.children.length - 1; i >= 0; i--) {\n let child = tree.children[i], pos = off + tree.positions[i];\n let found = child instanceof Tree && pos < before && findState(lang, child, pos, startPos, before);\n if (found)\n return found;\n }\n return null;\n}\nfunction cutTree(lang, tree, from, to, inside) {\n if (inside && from <= 0 && to >= tree.length)\n return tree;\n if (!inside && tree.type == lang.topNode)\n inside = true;\n for (let i = tree.children.length - 1; i >= 0; i--) {\n let pos = tree.positions[i], child = tree.children[i], inner;\n if (pos < to && child instanceof Tree) {\n if (!(inner = cutTree(lang, child, from - pos, to - pos, inside)))\n break;\n return !inside ? inner\n : new Tree(tree.type, tree.children.slice(0, i).concat(inner), tree.positions.slice(0, i + 1), pos + inner.length);\n }\n }\n return null;\n}\nfunction findStartInFragments(lang, fragments, startPos, editorState) {\n for (let f of fragments) {\n let from = f.from + (f.openStart ? 25 : 0), to = f.to - (f.openEnd ? 25 : 0);\n let found = from <= startPos && to > startPos && findState(lang, f.tree, 0 - f.offset, startPos, to), tree;\n if (found && (tree = cutTree(lang, f.tree, startPos + f.offset, found.pos + f.offset, false)))\n return { state: found.state, tree };\n }\n return { state: lang.streamParser.startState(editorState ? getIndentUnit(editorState) : 4), tree: Tree.empty };\n}\nclass Parse {\n constructor(lang, input, fragments, ranges) {\n this.lang = lang;\n this.input = input;\n this.fragments = fragments;\n this.ranges = ranges;\n this.stoppedAt = null;\n this.chunks = [];\n this.chunkPos = [];\n this.chunk = [];\n this.chunkReused = undefined;\n this.rangeIndex = 0;\n this.to = ranges[ranges.length - 1].to;\n let context = ParseContext.get(), from = ranges[0].from;\n let { state, tree } = findStartInFragments(lang, fragments, from, context === null || context === void 0 ? void 0 : context.state);\n this.state = state;\n this.parsedPos = this.chunkStart = from + tree.length;\n for (let i = 0; i < tree.children.length; i++) {\n this.chunks.push(tree.children[i]);\n this.chunkPos.push(tree.positions[i]);\n }\n if (context && this.parsedPos < context.viewport.from - 100000 /* C.MaxDistanceBeforeViewport */) {\n this.state = this.lang.streamParser.startState(getIndentUnit(context.state));\n context.skipUntilInView(this.parsedPos, context.viewport.from);\n this.parsedPos = context.viewport.from;\n }\n this.moveRangeIndex();\n }\n advance() {\n let context = ParseContext.get();\n let parseEnd = this.stoppedAt == null ? this.to : Math.min(this.to, this.stoppedAt);\n let end = Math.min(parseEnd, this.chunkStart + 2048 /* C.ChunkSize */);\n if (context)\n end = Math.min(end, context.viewport.to);\n while (this.parsedPos < end)\n this.parseLine(context);\n if (this.chunkStart < this.parsedPos)\n this.finishChunk();\n if (this.parsedPos >= parseEnd)\n return this.finish();\n if (context && this.parsedPos >= context.viewport.to) {\n context.skipUntilInView(this.parsedPos, parseEnd);\n return this.finish();\n }\n return null;\n }\n stopAt(pos) {\n this.stoppedAt = pos;\n }\n lineAfter(pos) {\n let chunk = this.input.chunk(pos);\n if (!this.input.lineChunks) {\n let eol = chunk.indexOf(\"\\n\");\n if (eol > -1)\n chunk = chunk.slice(0, eol);\n }\n else if (chunk == \"\\n\") {\n chunk = \"\";\n }\n return pos + chunk.length <= this.to ? chunk : chunk.slice(0, this.to - pos);\n }\n nextLine() {\n let from = this.parsedPos, line = this.lineAfter(from), end = from + line.length;\n for (let index = this.rangeIndex;;) {\n let rangeEnd = this.ranges[index].to;\n if (rangeEnd >= end)\n break;\n line = line.slice(0, rangeEnd - (end - line.length));\n index++;\n if (index == this.ranges.length)\n break;\n let rangeStart = this.ranges[index].from;\n let after = this.lineAfter(rangeStart);\n line += after;\n end = rangeStart + after.length;\n }\n return { line, end };\n }\n skipGapsTo(pos, offset, side) {\n for (;;) {\n let end = this.ranges[this.rangeIndex].to, offPos = pos + offset;\n if (side > 0 ? end > offPos : end >= offPos)\n break;\n let start = this.ranges[++this.rangeIndex].from;\n offset += start - end;\n }\n return offset;\n }\n moveRangeIndex() {\n while (this.ranges[this.rangeIndex].to < this.parsedPos)\n this.rangeIndex++;\n }\n emitToken(id, from, to, size, offset) {\n if (this.ranges.length > 1) {\n offset = this.skipGapsTo(from, offset, 1);\n from += offset;\n let len0 = this.chunk.length;\n offset = this.skipGapsTo(to, offset, -1);\n to += offset;\n size += this.chunk.length - len0;\n }\n this.chunk.push(id, from, to, size);\n return offset;\n }\n parseLine(context) {\n let { line, end } = this.nextLine(), offset = 0, { streamParser } = this.lang;\n let stream = new StringStream(line, context ? context.state.tabSize : 4, context ? getIndentUnit(context.state) : 2);\n if (stream.eol()) {\n streamParser.blankLine(this.state, stream.indentUnit);\n }\n else {\n while (!stream.eol()) {\n let token = readToken(streamParser.token, stream, this.state);\n if (token)\n offset = this.emitToken(this.lang.tokenTable.resolve(token), this.parsedPos + stream.start, this.parsedPos + stream.pos, 4, offset);\n if (stream.start > 10000 /* C.MaxLineLength */)\n break;\n }\n }\n this.parsedPos = end;\n this.moveRangeIndex();\n if (this.parsedPos < this.to)\n this.parsedPos++;\n }\n finishChunk() {\n let tree = Tree.build({\n buffer: this.chunk,\n start: this.chunkStart,\n length: this.parsedPos - this.chunkStart,\n nodeSet,\n topID: 0,\n maxBufferLength: 2048 /* C.ChunkSize */,\n reused: this.chunkReused\n });\n tree = new Tree(tree.type, tree.children, tree.positions, tree.length, [[this.lang.stateAfter, this.lang.streamParser.copyState(this.state)]]);\n this.chunks.push(tree);\n this.chunkPos.push(this.chunkStart - this.ranges[0].from);\n this.chunk = [];\n this.chunkReused = undefined;\n this.chunkStart = this.parsedPos;\n }\n finish() {\n return new Tree(this.lang.topNode, this.chunks, this.chunkPos, this.parsedPos - this.ranges[0].from).balance();\n }\n}\nfunction readToken(token, stream, state) {\n stream.start = stream.pos;\n for (let i = 0; i < 10; i++) {\n let result = token(stream, state);\n if (stream.pos > stream.start)\n return result;\n }\n throw new Error(\"Stream parser failed to advance stream.\");\n}\nconst noTokens = /*@__PURE__*/Object.create(null);\nconst typeArray = [NodeType.none];\nconst nodeSet = /*@__PURE__*/new NodeSet(typeArray);\nconst warned = [];\nconst defaultTable = /*@__PURE__*/Object.create(null);\nfor (let [legacyName, name] of [\n [\"variable\", \"variableName\"],\n [\"variable-2\", \"variableName.special\"],\n [\"string-2\", \"string.special\"],\n [\"def\", \"variableName.definition\"],\n [\"tag\", \"tagName\"],\n [\"attribute\", \"attributeName\"],\n [\"type\", \"typeName\"],\n [\"builtin\", \"variableName.standard\"],\n [\"qualifier\", \"modifier\"],\n [\"error\", \"invalid\"],\n [\"header\", \"heading\"],\n [\"property\", \"propertyName\"]\n])\n defaultTable[legacyName] = /*@__PURE__*/createTokenType(noTokens, name);\nclass TokenTable {\n constructor(extra) {\n this.extra = extra;\n this.table = Object.assign(Object.create(null), defaultTable);\n }\n resolve(tag) {\n return !tag ? 0 : this.table[tag] || (this.table[tag] = createTokenType(this.extra, tag));\n }\n}\nconst defaultTokenTable = /*@__PURE__*/new TokenTable(noTokens);\nfunction warnForPart(part, msg) {\n if (warned.indexOf(part) > -1)\n return;\n warned.push(part);\n console.warn(msg);\n}\nfunction createTokenType(extra, tagStr) {\n let tag = null;\n for (let part of tagStr.split(\".\")) {\n let value = (extra[part] || tags[part]);\n if (!value) {\n warnForPart(part, `Unknown highlighting tag ${part}`);\n }\n else if (typeof value == \"function\") {\n if (!tag)\n warnForPart(part, `Modifier ${part} used at start of tag`);\n else\n tag = value(tag);\n }\n else {\n if (tag)\n warnForPart(part, `Tag ${part} used as modifier`);\n else\n tag = value;\n }\n }\n if (!tag)\n return 0;\n let name = tagStr.replace(/ /g, \"_\"), type = NodeType.define({\n id: typeArray.length,\n name,\n props: [styleTags({ [name]: tag })]\n });\n typeArray.push(type);\n return type.id;\n}\nfunction docID(data) {\n let type = NodeType.define({ id: typeArray.length, name: \"Document\", props: [languageDataProp.add(() => data)], top: true });\n typeArray.push(type);\n return type;\n}\n\nexport { DocInput, HighlightStyle, IndentContext, LRLanguage, Language, LanguageDescription, LanguageSupport, ParseContext, StreamLanguage, StringStream, TreeIndentContext, bracketMatching, bracketMatchingHandle, codeFolding, continuedIndent, defaultHighlightStyle, defineLanguageFacet, delimitedIndent, ensureSyntaxTree, flatIndent, foldAll, foldCode, foldEffect, foldGutter, foldInside, foldKeymap, foldNodeProp, foldService, foldState, foldable, foldedRanges, forceParsing, getIndentUnit, getIndentation, highlightingFor, indentNodeProp, indentOnInput, indentRange, indentService, indentString, indentUnit, language, languageDataProp, matchBrackets, sublanguageProp, syntaxHighlighting, syntaxParserRunning, syntaxTree, syntaxTreeAvailable, toggleFold, unfoldAll, unfoldCode, unfoldEffect };\n","import { Annotation, Facet, combineConfig, StateField, EditorSelection, Transaction, ChangeSet, ChangeDesc, StateEffect, Text, findClusterBreak, countColumn, CharCategory } from '@codemirror/state';\nimport { EditorView, Direction } from '@codemirror/view';\nimport { IndentContext, getIndentation, indentString, matchBrackets, syntaxTree, getIndentUnit, indentUnit } from '@codemirror/language';\nimport { NodeProp } from '@lezer/common';\n\n/**\nComment or uncomment the current selection. Will use line comments\nif available, otherwise falling back to block comments.\n*/\nconst toggleComment = target => {\n let { state } = target, line = state.doc.lineAt(state.selection.main.from), config = getConfig(target.state, line.from);\n return config.line ? toggleLineComment(target) : config.block ? toggleBlockCommentByLine(target) : false;\n};\nfunction command(f, option) {\n return ({ state, dispatch }) => {\n if (state.readOnly)\n return false;\n let tr = f(option, state);\n if (!tr)\n return false;\n dispatch(state.update(tr));\n return true;\n };\n}\n/**\nComment or uncomment the current selection using line comments.\nThe line comment syntax is taken from the\n[`commentTokens`](https://codemirror.net/6/docs/ref/#commands.CommentTokens) [language\ndata](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt).\n*/\nconst toggleLineComment = /*@__PURE__*/command(changeLineComment, 0 /* CommentOption.Toggle */);\n/**\nComment the current selection using line comments.\n*/\nconst lineComment = /*@__PURE__*/command(changeLineComment, 1 /* CommentOption.Comment */);\n/**\nUncomment the current selection using line comments.\n*/\nconst lineUncomment = /*@__PURE__*/command(changeLineComment, 2 /* CommentOption.Uncomment */);\n/**\nComment or uncomment the current selection using block comments.\nThe block comment syntax is taken from the\n[`commentTokens`](https://codemirror.net/6/docs/ref/#commands.CommentTokens) [language\ndata](https://codemirror.net/6/docs/ref/#state.EditorState.languageDataAt).\n*/\nconst toggleBlockComment = /*@__PURE__*/command(changeBlockComment, 0 /* CommentOption.Toggle */);\n/**\nComment the current selection using block comments.\n*/\nconst blockComment = /*@__PURE__*/command(changeBlockComment, 1 /* CommentOption.Comment */);\n/**\nUncomment the current selection using block comments.\n*/\nconst blockUncomment = /*@__PURE__*/command(changeBlockComment, 2 /* CommentOption.Uncomment */);\n/**\nComment or uncomment the lines around the current selection using\nblock comments.\n*/\nconst toggleBlockCommentByLine = /*@__PURE__*/command((o, s) => changeBlockComment(o, s, selectedLineRanges(s)), 0 /* CommentOption.Toggle */);\nfunction getConfig(state, pos) {\n let data = state.languageDataAt(\"commentTokens\", pos);\n return data.length ? data[0] : {};\n}\nconst SearchMargin = 50;\n/**\nDetermines if the given range is block-commented in the given\nstate.\n*/\nfunction findBlockComment(state, { open, close }, from, to) {\n let textBefore = state.sliceDoc(from - SearchMargin, from);\n let textAfter = state.sliceDoc(to, to + SearchMargin);\n let spaceBefore = /\\s*$/.exec(textBefore)[0].length, spaceAfter = /^\\s*/.exec(textAfter)[0].length;\n let beforeOff = textBefore.length - spaceBefore;\n if (textBefore.slice(beforeOff - open.length, beforeOff) == open &&\n textAfter.slice(spaceAfter, spaceAfter + close.length) == close) {\n return { open: { pos: from - spaceBefore, margin: spaceBefore && 1 },\n close: { pos: to + spaceAfter, margin: spaceAfter && 1 } };\n }\n let startText, endText;\n if (to - from <= 2 * SearchMargin) {\n startText = endText = state.sliceDoc(from, to);\n }\n else {\n startText = state.sliceDoc(from, from + SearchMargin);\n endText = state.sliceDoc(to - SearchMargin, to);\n }\n let startSpace = /^\\s*/.exec(startText)[0].length, endSpace = /\\s*$/.exec(endText)[0].length;\n let endOff = endText.length - endSpace - close.length;\n if (startText.slice(startSpace, startSpace + open.length) == open &&\n endText.slice(endOff, endOff + close.length) == close) {\n return { open: { pos: from + startSpace + open.length,\n margin: /\\s/.test(startText.charAt(startSpace + open.length)) ? 1 : 0 },\n close: { pos: to - endSpace - close.length,\n margin: /\\s/.test(endText.charAt(endOff - 1)) ? 1 : 0 } };\n }\n return null;\n}\nfunction selectedLineRanges(state) {\n let ranges = [];\n for (let r of state.selection.ranges) {\n let fromLine = state.doc.lineAt(r.from);\n let toLine = r.to <= fromLine.to ? fromLine : state.doc.lineAt(r.to);\n let last = ranges.length - 1;\n if (last >= 0 && ranges[last].to > fromLine.from)\n ranges[last].to = toLine.to;\n else\n ranges.push({ from: fromLine.from + /^\\s*/.exec(fromLine.text)[0].length, to: toLine.to });\n }\n return ranges;\n}\n// Performs toggle, comment and uncomment of block comments in\n// languages that support them.\nfunction changeBlockComment(option, state, ranges = state.selection.ranges) {\n let tokens = ranges.map(r => getConfig(state, r.from).block);\n if (!tokens.every(c => c))\n return null;\n let comments = ranges.map((r, i) => findBlockComment(state, tokens[i], r.from, r.to));\n if (option != 2 /* CommentOption.Uncomment */ && !comments.every(c => c)) {\n return { changes: state.changes(ranges.map((range, i) => {\n if (comments[i])\n return [];\n return [{ from: range.from, insert: tokens[i].open + \" \" }, { from: range.to, insert: \" \" + tokens[i].close }];\n })) };\n }\n else if (option != 1 /* CommentOption.Comment */ && comments.some(c => c)) {\n let changes = [];\n for (let i = 0, comment; i < comments.length; i++)\n if (comment = comments[i]) {\n let token = tokens[i], { open, close } = comment;\n changes.push({ from: open.pos - token.open.length, to: open.pos + open.margin }, { from: close.pos - close.margin, to: close.pos + token.close.length });\n }\n return { changes };\n }\n return null;\n}\n// Performs toggle, comment and uncomment of line comments.\nfunction changeLineComment(option, state, ranges = state.selection.ranges) {\n let lines = [];\n let prevLine = -1;\n for (let { from, to } of ranges) {\n let startI = lines.length, minIndent = 1e9;\n let token = getConfig(state, from).line;\n if (!token)\n continue;\n for (let pos = from; pos <= to;) {\n let line = state.doc.lineAt(pos);\n if (line.from > prevLine && (from == to || to > line.from)) {\n prevLine = line.from;\n let indent = /^\\s*/.exec(line.text)[0].length;\n let empty = indent == line.length;\n let comment = line.text.slice(indent, indent + token.length) == token ? indent : -1;\n if (indent < line.text.length && indent < minIndent)\n minIndent = indent;\n lines.push({ line, comment, token, indent, empty, single: false });\n }\n pos = line.to + 1;\n }\n if (minIndent < 1e9)\n for (let i = startI; i < lines.length; i++)\n if (lines[i].indent < lines[i].line.text.length)\n lines[i].indent = minIndent;\n if (lines.length == startI + 1)\n lines[startI].single = true;\n }\n if (option != 2 /* CommentOption.Uncomment */ && lines.some(l => l.comment < 0 && (!l.empty || l.single))) {\n let changes = [];\n for (let { line, token, indent, empty, single } of lines)\n if (single || !empty)\n changes.push({ from: line.from + indent, insert: token + \" \" });\n let changeSet = state.changes(changes);\n return { changes: changeSet, selection: state.selection.map(changeSet, 1) };\n }\n else if (option != 1 /* CommentOption.Comment */ && lines.some(l => l.comment >= 0)) {\n let changes = [];\n for (let { line, comment, token } of lines)\n if (comment >= 0) {\n let from = line.from + comment, to = from + token.length;\n if (line.text[to - line.from] == \" \")\n to++;\n changes.push({ from, to });\n }\n return { changes };\n }\n return null;\n}\n\nconst fromHistory = /*@__PURE__*/Annotation.define();\n/**\nTransaction annotation that will prevent that transaction from\nbeing combined with other transactions in the undo history. Given\n`\"before\"`, it'll prevent merging with previous transactions. With\n`\"after\"`, subsequent transactions won't be combined with this\none. With `\"full\"`, the transaction is isolated on both sides.\n*/\nconst isolateHistory = /*@__PURE__*/Annotation.define();\n/**\nThis facet provides a way to register functions that, given a\ntransaction, provide a set of effects that the history should\nstore when inverting the transaction. This can be used to\nintegrate some kinds of effects in the history, so that they can\nbe undone (and redone again).\n*/\nconst invertedEffects = /*@__PURE__*/Facet.define();\nconst historyConfig = /*@__PURE__*/Facet.define({\n combine(configs) {\n return combineConfig(configs, {\n minDepth: 100,\n newGroupDelay: 500,\n joinToEvent: (_t, isAdjacent) => isAdjacent,\n }, {\n minDepth: Math.max,\n newGroupDelay: Math.min,\n joinToEvent: (a, b) => (tr, adj) => a(tr, adj) || b(tr, adj)\n });\n }\n});\nfunction changeEnd(changes) {\n let end = 0;\n changes.iterChangedRanges((_, to) => end = to);\n return end;\n}\nconst historyField_ = /*@__PURE__*/StateField.define({\n create() {\n return HistoryState.empty;\n },\n update(state, tr) {\n let config = tr.state.facet(historyConfig);\n let fromHist = tr.annotation(fromHistory);\n if (fromHist) {\n let selection = tr.docChanged ? EditorSelection.single(changeEnd(tr.changes)) : undefined;\n let item = HistEvent.fromTransaction(tr, selection), from = fromHist.side;\n let other = from == 0 /* BranchName.Done */ ? state.undone : state.done;\n if (item)\n other = updateBranch(other, other.length, config.minDepth, item);\n else\n other = addSelection(other, tr.startState.selection);\n return new HistoryState(from == 0 /* BranchName.Done */ ? fromHist.rest : other, from == 0 /* BranchName.Done */ ? other : fromHist.rest);\n }\n let isolate = tr.annotation(isolateHistory);\n if (isolate == \"full\" || isolate == \"before\")\n state = state.isolate();\n if (tr.annotation(Transaction.addToHistory) === false)\n return !tr.changes.empty ? state.addMapping(tr.changes.desc) : state;\n let event = HistEvent.fromTransaction(tr);\n let time = tr.annotation(Transaction.time), userEvent = tr.annotation(Transaction.userEvent);\n if (event)\n state = state.addChanges(event, time, userEvent, config, tr);\n else if (tr.selection)\n state = state.addSelection(tr.startState.selection, time, userEvent, config.newGroupDelay);\n if (isolate == \"full\" || isolate == \"after\")\n state = state.isolate();\n return state;\n },\n toJSON(value) {\n return { done: value.done.map(e => e.toJSON()), undone: value.undone.map(e => e.toJSON()) };\n },\n fromJSON(json) {\n return new HistoryState(json.done.map(HistEvent.fromJSON), json.undone.map(HistEvent.fromJSON));\n }\n});\n/**\nCreate a history extension with the given configuration.\n*/\nfunction history(config = {}) {\n return [\n historyField_,\n historyConfig.of(config),\n EditorView.domEventHandlers({\n beforeinput(e, view) {\n let command = e.inputType == \"historyUndo\" ? undo : e.inputType == \"historyRedo\" ? redo : null;\n if (!command)\n return false;\n e.preventDefault();\n return command(view);\n }\n })\n ];\n}\n/**\nThe state field used to store the history data. Should probably\nonly be used when you want to\n[serialize](https://codemirror.net/6/docs/ref/#state.EditorState.toJSON) or\n[deserialize](https://codemirror.net/6/docs/ref/#state.EditorState^fromJSON) state objects in a way\nthat preserves history.\n*/\nconst historyField = historyField_;\nfunction cmd(side, selection) {\n return function ({ state, dispatch }) {\n if (!selection && state.readOnly)\n return false;\n let historyState = state.field(historyField_, false);\n if (!historyState)\n return false;\n let tr = historyState.pop(side, state, selection);\n if (!tr)\n return false;\n dispatch(tr);\n return true;\n };\n}\n/**\nUndo a single group of history events. Returns false if no group\nwas available.\n*/\nconst undo = /*@__PURE__*/cmd(0 /* BranchName.Done */, false);\n/**\nRedo a group of history events. Returns false if no group was\navailable.\n*/\nconst redo = /*@__PURE__*/cmd(1 /* BranchName.Undone */, false);\n/**\nUndo a change or selection change.\n*/\nconst undoSelection = /*@__PURE__*/cmd(0 /* BranchName.Done */, true);\n/**\nRedo a change or selection change.\n*/\nconst redoSelection = /*@__PURE__*/cmd(1 /* BranchName.Undone */, true);\nfunction depth(side) {\n return function (state) {\n let histState = state.field(historyField_, false);\n if (!histState)\n return 0;\n let branch = side == 0 /* BranchName.Done */ ? histState.done : histState.undone;\n return branch.length - (branch.length && !branch[0].changes ? 1 : 0);\n };\n}\n/**\nThe amount of undoable change events available in a given state.\n*/\nconst undoDepth = /*@__PURE__*/depth(0 /* BranchName.Done */);\n/**\nThe amount of redoable change events available in a given state.\n*/\nconst redoDepth = /*@__PURE__*/depth(1 /* BranchName.Undone */);\n// History events store groups of changes or effects that need to be\n// undone/redone together.\nclass HistEvent {\n constructor(\n // The changes in this event. Normal events hold at least one\n // change or effect. But it may be necessary to store selection\n // events before the first change, in which case a special type of\n // instance is created which doesn't hold any changes, with\n // changes == startSelection == undefined\n changes, \n // The effects associated with this event\n effects, \n // Accumulated mapping (from addToHistory==false) that should be\n // applied to events below this one.\n mapped, \n // The selection before this event\n startSelection, \n // Stores selection changes after this event, to be used for\n // selection undo/redo.\n selectionsAfter) {\n this.changes = changes;\n this.effects = effects;\n this.mapped = mapped;\n this.startSelection = startSelection;\n this.selectionsAfter = selectionsAfter;\n }\n setSelAfter(after) {\n return new HistEvent(this.changes, this.effects, this.mapped, this.startSelection, after);\n }\n toJSON() {\n var _a, _b, _c;\n return {\n changes: (_a = this.changes) === null || _a === void 0 ? void 0 : _a.toJSON(),\n mapped: (_b = this.mapped) === null || _b === void 0 ? void 0 : _b.toJSON(),\n startSelection: (_c = this.startSelection) === null || _c === void 0 ? void 0 : _c.toJSON(),\n selectionsAfter: this.selectionsAfter.map(s => s.toJSON())\n };\n }\n static fromJSON(json) {\n return new HistEvent(json.changes && ChangeSet.fromJSON(json.changes), [], json.mapped && ChangeDesc.fromJSON(json.mapped), json.startSelection && EditorSelection.fromJSON(json.startSelection), json.selectionsAfter.map(EditorSelection.fromJSON));\n }\n // This does not check `addToHistory` and such, it assumes the\n // transaction needs to be converted to an item. Returns null when\n // there are no changes or effects in the transaction.\n static fromTransaction(tr, selection) {\n let effects = none;\n for (let invert of tr.startState.facet(invertedEffects)) {\n let result = invert(tr);\n if (result.length)\n effects = effects.concat(result);\n }\n if (!effects.length && tr.changes.empty)\n return null;\n return new HistEvent(tr.changes.invert(tr.startState.doc), effects, undefined, selection || tr.startState.selection, none);\n }\n static selection(selections) {\n return new HistEvent(undefined, none, undefined, undefined, selections);\n }\n}\nfunction updateBranch(branch, to, maxLen, newEvent) {\n let start = to + 1 > maxLen + 20 ? to - maxLen - 1 : 0;\n let newBranch = branch.slice(start, to);\n newBranch.push(newEvent);\n return newBranch;\n}\nfunction isAdjacent(a, b) {\n let ranges = [], isAdjacent = false;\n a.iterChangedRanges((f, t) => ranges.push(f, t));\n b.iterChangedRanges((_f, _t, f, t) => {\n for (let i = 0; i < ranges.length;) {\n let from = ranges[i++], to = ranges[i++];\n if (t >= from && f <= to)\n isAdjacent = true;\n }\n });\n return isAdjacent;\n}\nfunction eqSelectionShape(a, b) {\n return a.ranges.length == b.ranges.length &&\n a.ranges.filter((r, i) => r.empty != b.ranges[i].empty).length === 0;\n}\nfunction conc(a, b) {\n return !a.length ? b : !b.length ? a : a.concat(b);\n}\nconst none = [];\nconst MaxSelectionsPerEvent = 200;\nfunction addSelection(branch, selection) {\n if (!branch.length) {\n return [HistEvent.selection([selection])];\n }\n else {\n let lastEvent = branch[branch.length - 1];\n let sels = lastEvent.selectionsAfter.slice(Math.max(0, lastEvent.selectionsAfter.length - MaxSelectionsPerEvent));\n if (sels.length && sels[sels.length - 1].eq(selection))\n return branch;\n sels.push(selection);\n return updateBranch(branch, branch.length - 1, 1e9, lastEvent.setSelAfter(sels));\n }\n}\n// Assumes the top item has one or more selectionAfter values\nfunction popSelection(branch) {\n let last = branch[branch.length - 1];\n let newBranch = branch.slice();\n newBranch[branch.length - 1] = last.setSelAfter(last.selectionsAfter.slice(0, last.selectionsAfter.length - 1));\n return newBranch;\n}\n// Add a mapping to the top event in the given branch. If this maps\n// away all the changes and effects in that item, drop it and\n// propagate the mapping to the next item.\nfunction addMappingToBranch(branch, mapping) {\n if (!branch.length)\n return branch;\n let length = branch.length, selections = none;\n while (length) {\n let event = mapEvent(branch[length - 1], mapping, selections);\n if (event.changes && !event.changes.empty || event.effects.length) { // Event survived mapping\n let result = branch.slice(0, length);\n result[length - 1] = event;\n return result;\n }\n else { // Drop this event, since there's no changes or effects left\n mapping = event.mapped;\n length--;\n selections = event.selectionsAfter;\n }\n }\n return selections.length ? [HistEvent.selection(selections)] : none;\n}\nfunction mapEvent(event, mapping, extraSelections) {\n let selections = conc(event.selectionsAfter.length ? event.selectionsAfter.map(s => s.map(mapping)) : none, extraSelections);\n // Change-less events don't store mappings (they are always the last event in a branch)\n if (!event.changes)\n return HistEvent.selection(selections);\n let mappedChanges = event.changes.map(mapping), before = mapping.mapDesc(event.changes, true);\n let fullMapping = event.mapped ? event.mapped.composeDesc(before) : before;\n return new HistEvent(mappedChanges, StateEffect.mapEffects(event.effects, mapping), fullMapping, event.startSelection.map(before), selections);\n}\nconst joinableUserEvent = /^(input\\.type|delete)($|\\.)/;\nclass HistoryState {\n constructor(done, undone, prevTime = 0, prevUserEvent = undefined) {\n this.done = done;\n this.undone = undone;\n this.prevTime = prevTime;\n this.prevUserEvent = prevUserEvent;\n }\n isolate() {\n return this.prevTime ? new HistoryState(this.done, this.undone) : this;\n }\n addChanges(event, time, userEvent, config, tr) {\n let done = this.done, lastEvent = done[done.length - 1];\n if (lastEvent && lastEvent.changes && !lastEvent.changes.empty && event.changes &&\n (!userEvent || joinableUserEvent.test(userEvent)) &&\n ((!lastEvent.selectionsAfter.length &&\n time - this.prevTime < config.newGroupDelay &&\n config.joinToEvent(tr, isAdjacent(lastEvent.changes, event.changes))) ||\n // For compose (but not compose.start) events, always join with previous event\n userEvent == \"input.type.compose\")) {\n done = updateBranch(done, done.length - 1, config.minDepth, new HistEvent(event.changes.compose(lastEvent.changes), conc(event.effects, lastEvent.effects), lastEvent.mapped, lastEvent.startSelection, none));\n }\n else {\n done = updateBranch(done, done.length, config.minDepth, event);\n }\n return new HistoryState(done, none, time, userEvent);\n }\n addSelection(selection, time, userEvent, newGroupDelay) {\n let last = this.done.length ? this.done[this.done.length - 1].selectionsAfter : none;\n if (last.length > 0 &&\n time - this.prevTime < newGroupDelay &&\n userEvent == this.prevUserEvent && userEvent && /^select($|\\.)/.test(userEvent) &&\n eqSelectionShape(last[last.length - 1], selection))\n return this;\n return new HistoryState(addSelection(this.done, selection), this.undone, time, userEvent);\n }\n addMapping(mapping) {\n return new HistoryState(addMappingToBranch(this.done, mapping), addMappingToBranch(this.undone, mapping), this.prevTime, this.prevUserEvent);\n }\n pop(side, state, selection) {\n let branch = side == 0 /* BranchName.Done */ ? this.done : this.undone;\n if (branch.length == 0)\n return null;\n let event = branch[branch.length - 1];\n if (selection && event.selectionsAfter.length) {\n return state.update({\n selection: event.selectionsAfter[event.selectionsAfter.length - 1],\n annotations: fromHistory.of({ side, rest: popSelection(branch) }),\n userEvent: side == 0 /* BranchName.Done */ ? \"select.undo\" : \"select.redo\",\n scrollIntoView: true\n });\n }\n else if (!event.changes) {\n return null;\n }\n else {\n let rest = branch.length == 1 ? none : branch.slice(0, branch.length - 1);\n if (event.mapped)\n rest = addMappingToBranch(rest, event.mapped);\n return state.update({\n changes: event.changes,\n selection: event.startSelection,\n effects: event.effects,\n annotations: fromHistory.of({ side, rest }),\n filter: false,\n userEvent: side == 0 /* BranchName.Done */ ? \"undo\" : \"redo\",\n scrollIntoView: true\n });\n }\n }\n}\nHistoryState.empty = /*@__PURE__*/new HistoryState(none, none);\n/**\nDefault key bindings for the undo history.\n\n- Mod-z: [`undo`](https://codemirror.net/6/docs/ref/#commands.undo).\n- Mod-y (Mod-Shift-z on macOS) + Ctrl-Shift-z on Linux: [`redo`](https://codemirror.net/6/docs/ref/#commands.redo).\n- Mod-u: [`undoSelection`](https://codemirror.net/6/docs/ref/#commands.undoSelection).\n- Alt-u (Mod-Shift-u on macOS): [`redoSelection`](https://codemirror.net/6/docs/ref/#commands.redoSelection).\n*/\nconst historyKeymap = [\n { key: \"Mod-z\", run: undo, preventDefault: true },\n { key: \"Mod-y\", mac: \"Mod-Shift-z\", run: redo, preventDefault: true },\n { linux: \"Ctrl-Shift-z\", run: redo, preventDefault: true },\n { key: \"Mod-u\", run: undoSelection, preventDefault: true },\n { key: \"Alt-u\", mac: \"Mod-Shift-u\", run: redoSelection, preventDefault: true }\n];\n\nfunction updateSel(sel, by) {\n return EditorSelection.create(sel.ranges.map(by), sel.mainIndex);\n}\nfunction setSel(state, selection) {\n return state.update({ selection, scrollIntoView: true, userEvent: \"select\" });\n}\nfunction moveSel({ state, dispatch }, how) {\n let selection = updateSel(state.selection, how);\n if (selection.eq(state.selection))\n return false;\n dispatch(setSel(state, selection));\n return true;\n}\nfunction rangeEnd(range, forward) {\n return EditorSelection.cursor(forward ? range.to : range.from);\n}\nfunction cursorByChar(view, forward) {\n return moveSel(view, range => range.empty ? view.moveByChar(range, forward) : rangeEnd(range, forward));\n}\nfunction ltrAtCursor(view) {\n return view.textDirectionAt(view.state.selection.main.head) == Direction.LTR;\n}\n/**\nMove the selection one character to the left (which is backward in\nleft-to-right text, forward in right-to-left text).\n*/\nconst cursorCharLeft = view => cursorByChar(view, !ltrAtCursor(view));\n/**\nMove the selection one character to the right.\n*/\nconst cursorCharRight = view => cursorByChar(view, ltrAtCursor(view));\n/**\nMove the selection one character forward.\n*/\nconst cursorCharForward = view => cursorByChar(view, true);\n/**\nMove the selection one character backward.\n*/\nconst cursorCharBackward = view => cursorByChar(view, false);\nfunction cursorByGroup(view, forward) {\n return moveSel(view, range => range.empty ? view.moveByGroup(range, forward) : rangeEnd(range, forward));\n}\n/**\nMove the selection to the left across one group of word or\nnon-word (but also non-space) characters.\n*/\nconst cursorGroupLeft = view => cursorByGroup(view, !ltrAtCursor(view));\n/**\nMove the selection one group to the right.\n*/\nconst cursorGroupRight = view => cursorByGroup(view, ltrAtCursor(view));\n/**\nMove the selection one group forward.\n*/\nconst cursorGroupForward = view => cursorByGroup(view, true);\n/**\nMove the selection one group backward.\n*/\nconst cursorGroupBackward = view => cursorByGroup(view, false);\nconst segmenter = typeof Intl != \"undefined\" && Intl.Segmenter ?\n /*@__PURE__*/new (Intl.Segmenter)(undefined, { granularity: \"word\" }) : null;\nfunction moveBySubword(view, range, forward) {\n let categorize = view.state.charCategorizer(range.from);\n let cat = CharCategory.Space, pos = range.from, steps = 0;\n let done = false, sawUpper = false, sawLower = false;\n let step = (next) => {\n if (done)\n return false;\n pos += forward ? next.length : -next.length;\n let nextCat = categorize(next), ahead;\n if (nextCat == CharCategory.Word && next.charCodeAt(0) < 128 && /[\\W_]/.test(next))\n nextCat = -1; // Treat word punctuation specially\n if (cat == CharCategory.Space)\n cat = nextCat;\n if (cat != nextCat)\n return false;\n if (cat == CharCategory.Word) {\n if (next.toLowerCase() == next) {\n if (!forward && sawUpper)\n return false;\n sawLower = true;\n }\n else if (sawLower) {\n if (forward)\n return false;\n done = true;\n }\n else {\n if (sawUpper && forward && categorize(ahead = view.state.sliceDoc(pos, pos + 1)) == CharCategory.Word &&\n ahead.toLowerCase() == ahead)\n return false;\n sawUpper = true;\n }\n }\n steps++;\n return true;\n };\n let end = view.moveByChar(range, forward, start => {\n step(start);\n return step;\n });\n if (segmenter && cat == CharCategory.Word && end.from == range.from + steps * (forward ? 1 : -1)) {\n let from = Math.min(range.head, end.head), to = Math.max(range.head, end.head);\n let skipped = view.state.sliceDoc(from, to);\n if (skipped.length > 1 && /[\\u4E00-\\uffff]/.test(skipped)) {\n let segments = Array.from(segmenter.segment(skipped));\n if (segments.length > 1) {\n if (forward)\n return EditorSelection.cursor(range.head + segments[1].index, -1);\n return EditorSelection.cursor(end.head + segments[segments.length - 1].index, 1);\n }\n }\n }\n return end;\n}\nfunction cursorBySubword(view, forward) {\n return moveSel(view, range => range.empty ? moveBySubword(view, range, forward) : rangeEnd(range, forward));\n}\n/**\nMove the selection one group or camel-case subword forward.\n*/\nconst cursorSubwordForward = view => cursorBySubword(view, true);\n/**\nMove the selection one group or camel-case subword backward.\n*/\nconst cursorSubwordBackward = view => cursorBySubword(view, false);\nfunction interestingNode(state, node, bracketProp) {\n if (node.type.prop(bracketProp))\n return true;\n let len = node.to - node.from;\n return len && (len > 2 || /[^\\s,.;:]/.test(state.sliceDoc(node.from, node.to))) || node.firstChild;\n}\nfunction moveBySyntax(state, start, forward) {\n let pos = syntaxTree(state).resolveInner(start.head);\n let bracketProp = forward ? NodeProp.closedBy : NodeProp.openedBy;\n // Scan forward through child nodes to see if there's an interesting\n // node ahead.\n for (let at = start.head;;) {\n let next = forward ? pos.childAfter(at) : pos.childBefore(at);\n if (!next)\n break;\n if (interestingNode(state, next, bracketProp))\n pos = next;\n else\n at = forward ? next.to : next.from;\n }\n let bracket = pos.type.prop(bracketProp), match, newPos;\n if (bracket && (match = forward ? matchBrackets(state, pos.from, 1) : matchBrackets(state, pos.to, -1)) && match.matched)\n newPos = forward ? match.end.to : match.end.from;\n else\n newPos = forward ? pos.to : pos.from;\n return EditorSelection.cursor(newPos, forward ? -1 : 1);\n}\n/**\nMove the cursor over the next syntactic element to the left.\n*/\nconst cursorSyntaxLeft = view => moveSel(view, range => moveBySyntax(view.state, range, !ltrAtCursor(view)));\n/**\nMove the cursor over the next syntactic element to the right.\n*/\nconst cursorSyntaxRight = view => moveSel(view, range => moveBySyntax(view.state, range, ltrAtCursor(view)));\nfunction cursorByLine(view, forward) {\n return moveSel(view, range => {\n if (!range.empty)\n return rangeEnd(range, forward);\n let moved = view.moveVertically(range, forward);\n return moved.head != range.head ? moved : view.moveToLineBoundary(range, forward);\n });\n}\n/**\nMove the selection one line up.\n*/\nconst cursorLineUp = view => cursorByLine(view, false);\n/**\nMove the selection one line down.\n*/\nconst cursorLineDown = view => cursorByLine(view, true);\nfunction pageInfo(view) {\n let selfScroll = view.scrollDOM.clientHeight < view.scrollDOM.scrollHeight - 2;\n let marginTop = 0, marginBottom = 0, height;\n if (selfScroll) {\n for (let source of view.state.facet(EditorView.scrollMargins)) {\n let margins = source(view);\n if (margins === null || margins === void 0 ? void 0 : margins.top)\n marginTop = Math.max(margins === null || margins === void 0 ? void 0 : margins.top, marginTop);\n if (margins === null || margins === void 0 ? void 0 : margins.bottom)\n marginBottom = Math.max(margins === null || margins === void 0 ? void 0 : margins.bottom, marginBottom);\n }\n height = view.scrollDOM.clientHeight - marginTop - marginBottom;\n }\n else {\n height = (view.dom.ownerDocument.defaultView || window).innerHeight;\n }\n return { marginTop, marginBottom, selfScroll,\n height: Math.max(view.defaultLineHeight, height - 5) };\n}\nfunction cursorByPage(view, forward) {\n let page = pageInfo(view);\n let { state } = view, selection = updateSel(state.selection, range => {\n return range.empty ? view.moveVertically(range, forward, page.height)\n : rangeEnd(range, forward);\n });\n if (selection.eq(state.selection))\n return false;\n let effect;\n if (page.selfScroll) {\n let startPos = view.coordsAtPos(state.selection.main.head);\n let scrollRect = view.scrollDOM.getBoundingClientRect();\n let scrollTop = scrollRect.top + page.marginTop, scrollBottom = scrollRect.bottom - page.marginBottom;\n if (startPos && startPos.top > scrollTop && startPos.bottom < scrollBottom)\n effect = EditorView.scrollIntoView(selection.main.head, { y: \"start\", yMargin: startPos.top - scrollTop });\n }\n view.dispatch(setSel(state, selection), { effects: effect });\n return true;\n}\n/**\nMove the selection one page up.\n*/\nconst cursorPageUp = view => cursorByPage(view, false);\n/**\nMove the selection one page down.\n*/\nconst cursorPageDown = view => cursorByPage(view, true);\nfunction moveByLineBoundary(view, start, forward) {\n let line = view.lineBlockAt(start.head), moved = view.moveToLineBoundary(start, forward);\n if (moved.head == start.head && moved.head != (forward ? line.to : line.from))\n moved = view.moveToLineBoundary(start, forward, false);\n if (!forward && moved.head == line.from && line.length) {\n let space = /^\\s*/.exec(view.state.sliceDoc(line.from, Math.min(line.from + 100, line.to)))[0].length;\n if (space && start.head != line.from + space)\n moved = EditorSelection.cursor(line.from + space);\n }\n return moved;\n}\n/**\nMove the selection to the next line wrap point, or to the end of\nthe line if there isn't one left on this line.\n*/\nconst cursorLineBoundaryForward = view => moveSel(view, range => moveByLineBoundary(view, range, true));\n/**\nMove the selection to previous line wrap point, or failing that to\nthe start of the line. If the line is indented, and the cursor\nisn't already at the end of the indentation, this will move to the\nend of the indentation instead of the start of the line.\n*/\nconst cursorLineBoundaryBackward = view => moveSel(view, range => moveByLineBoundary(view, range, false));\n/**\nMove the selection one line wrap point to the left.\n*/\nconst cursorLineBoundaryLeft = view => moveSel(view, range => moveByLineBoundary(view, range, !ltrAtCursor(view)));\n/**\nMove the selection one line wrap point to the right.\n*/\nconst cursorLineBoundaryRight = view => moveSel(view, range => moveByLineBoundary(view, range, ltrAtCursor(view)));\n/**\nMove the selection to the start of the line.\n*/\nconst cursorLineStart = view => moveSel(view, range => EditorSelection.cursor(view.lineBlockAt(range.head).from, 1));\n/**\nMove the selection to the end of the line.\n*/\nconst cursorLineEnd = view => moveSel(view, range => EditorSelection.cursor(view.lineBlockAt(range.head).to, -1));\nfunction toMatchingBracket(state, dispatch, extend) {\n let found = false, selection = updateSel(state.selection, range => {\n let matching = matchBrackets(state, range.head, -1)\n || matchBrackets(state, range.head, 1)\n || (range.head > 0 && matchBrackets(state, range.head - 1, 1))\n || (range.head < state.doc.length && matchBrackets(state, range.head + 1, -1));\n if (!matching || !matching.end)\n return range;\n found = true;\n let head = matching.start.from == range.head ? matching.end.to : matching.end.from;\n return extend ? EditorSelection.range(range.anchor, head) : EditorSelection.cursor(head);\n });\n if (!found)\n return false;\n dispatch(setSel(state, selection));\n return true;\n}\n/**\nMove the selection to the bracket matching the one it is currently\non, if any.\n*/\nconst cursorMatchingBracket = ({ state, dispatch }) => toMatchingBracket(state, dispatch, false);\n/**\nExtend the selection to the bracket matching the one the selection\nhead is currently on, if any.\n*/\nconst selectMatchingBracket = ({ state, dispatch }) => toMatchingBracket(state, dispatch, true);\nfunction extendSel(view, how) {\n let selection = updateSel(view.state.selection, range => {\n let head = how(range);\n return EditorSelection.range(range.anchor, head.head, head.goalColumn, head.bidiLevel || undefined);\n });\n if (selection.eq(view.state.selection))\n return false;\n view.dispatch(setSel(view.state, selection));\n return true;\n}\nfunction selectByChar(view, forward) {\n return extendSel(view, range => view.moveByChar(range, forward));\n}\n/**\nMove the selection head one character to the left, while leaving\nthe anchor in place.\n*/\nconst selectCharLeft = view => selectByChar(view, !ltrAtCursor(view));\n/**\nMove the selection head one character to the right.\n*/\nconst selectCharRight = view => selectByChar(view, ltrAtCursor(view));\n/**\nMove the selection head one character forward.\n*/\nconst selectCharForward = view => selectByChar(view, true);\n/**\nMove the selection head one character backward.\n*/\nconst selectCharBackward = view => selectByChar(view, false);\nfunction selectByGroup(view, forward) {\n return extendSel(view, range => view.moveByGroup(range, forward));\n}\n/**\nMove the selection head one [group](https://codemirror.net/6/docs/ref/#commands.cursorGroupLeft) to\nthe left.\n*/\nconst selectGroupLeft = view => selectByGroup(view, !ltrAtCursor(view));\n/**\nMove the selection head one group to the right.\n*/\nconst selectGroupRight = view => selectByGroup(view, ltrAtCursor(view));\n/**\nMove the selection head one group forward.\n*/\nconst selectGroupForward = view => selectByGroup(view, true);\n/**\nMove the selection head one group backward.\n*/\nconst selectGroupBackward = view => selectByGroup(view, false);\nfunction selectBySubword(view, forward) {\n return extendSel(view, range => moveBySubword(view, range, forward));\n}\n/**\nMove the selection head one group or camel-case subword forward.\n*/\nconst selectSubwordForward = view => selectBySubword(view, true);\n/**\nMove the selection head one group or subword backward.\n*/\nconst selectSubwordBackward = view => selectBySubword(view, false);\n/**\nMove the selection head over the next syntactic element to the left.\n*/\nconst selectSyntaxLeft = view => extendSel(view, range => moveBySyntax(view.state, range, !ltrAtCursor(view)));\n/**\nMove the selection head over the next syntactic element to the right.\n*/\nconst selectSyntaxRight = view => extendSel(view, range => moveBySyntax(view.state, range, ltrAtCursor(view)));\nfunction selectByLine(view, forward) {\n return extendSel(view, range => view.moveVertically(range, forward));\n}\n/**\nMove the selection head one line up.\n*/\nconst selectLineUp = view => selectByLine(view, false);\n/**\nMove the selection head one line down.\n*/\nconst selectLineDown = view => selectByLine(view, true);\nfunction selectByPage(view, forward) {\n return extendSel(view, range => view.moveVertically(range, forward, pageInfo(view).height));\n}\n/**\nMove the selection head one page up.\n*/\nconst selectPageUp = view => selectByPage(view, false);\n/**\nMove the selection head one page down.\n*/\nconst selectPageDown = view => selectByPage(view, true);\n/**\nMove the selection head to the next line boundary.\n*/\nconst selectLineBoundaryForward = view => extendSel(view, range => moveByLineBoundary(view, range, true));\n/**\nMove the selection head to the previous line boundary.\n*/\nconst selectLineBoundaryBackward = view => extendSel(view, range => moveByLineBoundary(view, range, false));\n/**\nMove the selection head one line boundary to the left.\n*/\nconst selectLineBoundaryLeft = view => extendSel(view, range => moveByLineBoundary(view, range, !ltrAtCursor(view)));\n/**\nMove the selection head one line boundary to the right.\n*/\nconst selectLineBoundaryRight = view => extendSel(view, range => moveByLineBoundary(view, range, ltrAtCursor(view)));\n/**\nMove the selection head to the start of the line.\n*/\nconst selectLineStart = view => extendSel(view, range => EditorSelection.cursor(view.lineBlockAt(range.head).from));\n/**\nMove the selection head to the end of the line.\n*/\nconst selectLineEnd = view => extendSel(view, range => EditorSelection.cursor(view.lineBlockAt(range.head).to));\n/**\nMove the selection to the start of the document.\n*/\nconst cursorDocStart = ({ state, dispatch }) => {\n dispatch(setSel(state, { anchor: 0 }));\n return true;\n};\n/**\nMove the selection to the end of the document.\n*/\nconst cursorDocEnd = ({ state, dispatch }) => {\n dispatch(setSel(state, { anchor: state.doc.length }));\n return true;\n};\n/**\nMove the selection head to the start of the document.\n*/\nconst selectDocStart = ({ state, dispatch }) => {\n dispatch(setSel(state, { anchor: state.selection.main.anchor, head: 0 }));\n return true;\n};\n/**\nMove the selection head to the end of the document.\n*/\nconst selectDocEnd = ({ state, dispatch }) => {\n dispatch(setSel(state, { anchor: state.selection.main.anchor, head: state.doc.length }));\n return true;\n};\n/**\nSelect the entire document.\n*/\nconst selectAll = ({ state, dispatch }) => {\n dispatch(state.update({ selection: { anchor: 0, head: state.doc.length }, userEvent: \"select\" }));\n return true;\n};\n/**\nExpand the selection to cover entire lines.\n*/\nconst selectLine = ({ state, dispatch }) => {\n let ranges = selectedLineBlocks(state).map(({ from, to }) => EditorSelection.range(from, Math.min(to + 1, state.doc.length)));\n dispatch(state.update({ selection: EditorSelection.create(ranges), userEvent: \"select\" }));\n return true;\n};\n/**\nSelect the next syntactic construct that is larger than the\nselection. Note that this will only work insofar as the language\n[provider](https://codemirror.net/6/docs/ref/#language.language) you use builds up a full\nsyntax tree.\n*/\nconst selectParentSyntax = ({ state, dispatch }) => {\n let selection = updateSel(state.selection, range => {\n var _a;\n let context = syntaxTree(state).resolveInner(range.head, 1);\n while (!((context.from < range.from && context.to >= range.to) ||\n (context.to > range.to && context.from <= range.from) ||\n !((_a = context.parent) === null || _a === void 0 ? void 0 : _a.parent)))\n context = context.parent;\n return EditorSelection.range(context.to, context.from);\n });\n dispatch(setSel(state, selection));\n return true;\n};\n/**\nSimplify the current selection. When multiple ranges are selected,\nreduce it to its main range. Otherwise, if the selection is\nnon-empty, convert it to a cursor selection.\n*/\nconst simplifySelection = ({ state, dispatch }) => {\n let cur = state.selection, selection = null;\n if (cur.ranges.length > 1)\n selection = EditorSelection.create([cur.main]);\n else if (!cur.main.empty)\n selection = EditorSelection.create([EditorSelection.cursor(cur.main.head)]);\n if (!selection)\n return false;\n dispatch(setSel(state, selection));\n return true;\n};\nfunction deleteBy(target, by) {\n if (target.state.readOnly)\n return false;\n let event = \"delete.selection\", { state } = target;\n let changes = state.changeByRange(range => {\n let { from, to } = range;\n if (from == to) {\n let towards = by(from);\n if (towards < from) {\n event = \"delete.backward\";\n towards = skipAtomic(target, towards, false);\n }\n else if (towards > from) {\n event = \"delete.forward\";\n towards = skipAtomic(target, towards, true);\n }\n from = Math.min(from, towards);\n to = Math.max(to, towards);\n }\n else {\n from = skipAtomic(target, from, false);\n to = skipAtomic(target, to, true);\n }\n return from == to ? { range } : { changes: { from, to }, range: EditorSelection.cursor(from) };\n });\n if (changes.changes.empty)\n return false;\n target.dispatch(state.update(changes, {\n scrollIntoView: true,\n userEvent: event,\n effects: event == \"delete.selection\" ? EditorView.announce.of(state.phrase(\"Selection deleted\")) : undefined\n }));\n return true;\n}\nfunction skipAtomic(target, pos, forward) {\n if (target instanceof EditorView)\n for (let ranges of target.state.facet(EditorView.atomicRanges).map(f => f(target)))\n ranges.between(pos, pos, (from, to) => {\n if (from < pos && to > pos)\n pos = forward ? to : from;\n });\n return pos;\n}\nconst deleteByChar = (target, forward) => deleteBy(target, pos => {\n let { state } = target, line = state.doc.lineAt(pos), before, targetPos;\n if (!forward && pos > line.from && pos < line.from + 200 &&\n !/[^ \\t]/.test(before = line.text.slice(0, pos - line.from))) {\n if (before[before.length - 1] == \"\\t\")\n return pos - 1;\n let col = countColumn(before, state.tabSize), drop = col % getIndentUnit(state) || getIndentUnit(state);\n for (let i = 0; i < drop && before[before.length - 1 - i] == \" \"; i++)\n pos--;\n targetPos = pos;\n }\n else {\n targetPos = findClusterBreak(line.text, pos - line.from, forward, forward) + line.from;\n if (targetPos == pos && line.number != (forward ? state.doc.lines : 1))\n targetPos += forward ? 1 : -1;\n }\n return targetPos;\n});\n/**\nDelete the selection, or, for cursor selections, the character\nbefore the cursor.\n*/\nconst deleteCharBackward = view => deleteByChar(view, false);\n/**\nDelete the selection or the character after the cursor.\n*/\nconst deleteCharForward = view => deleteByChar(view, true);\nconst deleteByGroup = (target, forward) => deleteBy(target, start => {\n let pos = start, { state } = target, line = state.doc.lineAt(pos);\n let categorize = state.charCategorizer(pos);\n for (let cat = null;;) {\n if (pos == (forward ? line.to : line.from)) {\n if (pos == start && line.number != (forward ? state.doc.lines : 1))\n pos += forward ? 1 : -1;\n break;\n }\n let next = findClusterBreak(line.text, pos - line.from, forward) + line.from;\n let nextChar = line.text.slice(Math.min(pos, next) - line.from, Math.max(pos, next) - line.from);\n let nextCat = categorize(nextChar);\n if (cat != null && nextCat != cat)\n break;\n if (nextChar != \" \" || pos != start)\n cat = nextCat;\n pos = next;\n }\n return pos;\n});\n/**\nDelete the selection or backward until the end of the next\n[group](https://codemirror.net/6/docs/ref/#view.EditorView.moveByGroup), only skipping groups of\nwhitespace when they consist of a single space.\n*/\nconst deleteGroupBackward = target => deleteByGroup(target, false);\n/**\nDelete the selection or forward until the end of the next group.\n*/\nconst deleteGroupForward = target => deleteByGroup(target, true);\n/**\nDelete the selection, or, if it is a cursor selection, delete to\nthe end of the line. If the cursor is directly at the end of the\nline, delete the line break after it.\n*/\nconst deleteToLineEnd = view => deleteBy(view, pos => {\n let lineEnd = view.lineBlockAt(pos).to;\n return pos < lineEnd ? lineEnd : Math.min(view.state.doc.length, pos + 1);\n});\n/**\nDelete the selection, or, if it is a cursor selection, delete to\nthe start of the line. If the cursor is directly at the start of the\nline, delete the line break before it.\n*/\nconst deleteToLineStart = view => deleteBy(view, pos => {\n let lineStart = view.lineBlockAt(pos).from;\n return pos > lineStart ? lineStart : Math.max(0, pos - 1);\n});\n/**\nDelete all whitespace directly before a line end from the\ndocument.\n*/\nconst deleteTrailingWhitespace = ({ state, dispatch }) => {\n if (state.readOnly)\n return false;\n let changes = [];\n for (let pos = 0, prev = \"\", iter = state.doc.iter();;) {\n iter.next();\n if (iter.lineBreak || iter.done) {\n let trailing = prev.search(/\\s+$/);\n if (trailing > -1)\n changes.push({ from: pos - (prev.length - trailing), to: pos });\n if (iter.done)\n break;\n prev = \"\";\n }\n else {\n prev = iter.value;\n }\n pos += iter.value.length;\n }\n if (!changes.length)\n return false;\n dispatch(state.update({ changes, userEvent: \"delete\" }));\n return true;\n};\n/**\nReplace each selection range with a line break, leaving the cursor\non the line before the break.\n*/\nconst splitLine = ({ state, dispatch }) => {\n if (state.readOnly)\n return false;\n let changes = state.changeByRange(range => {\n return { changes: { from: range.from, to: range.to, insert: Text.of([\"\", \"\"]) },\n range: EditorSelection.cursor(range.from) };\n });\n dispatch(state.update(changes, { scrollIntoView: true, userEvent: \"input\" }));\n return true;\n};\n/**\nFlip the characters before and after the cursor(s).\n*/\nconst transposeChars = ({ state, dispatch }) => {\n if (state.readOnly)\n return false;\n let changes = state.changeByRange(range => {\n if (!range.empty || range.from == 0 || range.from == state.doc.length)\n return { range };\n let pos = range.from, line = state.doc.lineAt(pos);\n let from = pos == line.from ? pos - 1 : findClusterBreak(line.text, pos - line.from, false) + line.from;\n let to = pos == line.to ? pos + 1 : findClusterBreak(line.text, pos - line.from, true) + line.from;\n return { changes: { from, to, insert: state.doc.slice(pos, to).append(state.doc.slice(from, pos)) },\n range: EditorSelection.cursor(to) };\n });\n if (changes.changes.empty)\n return false;\n dispatch(state.update(changes, { scrollIntoView: true, userEvent: \"move.character\" }));\n return true;\n};\nfunction selectedLineBlocks(state) {\n let blocks = [], upto = -1;\n for (let range of state.selection.ranges) {\n let startLine = state.doc.lineAt(range.from), endLine = state.doc.lineAt(range.to);\n if (!range.empty && range.to == endLine.from)\n endLine = state.doc.lineAt(range.to - 1);\n if (upto >= startLine.number) {\n let prev = blocks[blocks.length - 1];\n prev.to = endLine.to;\n prev.ranges.push(range);\n }\n else {\n blocks.push({ from: startLine.from, to: endLine.to, ranges: [range] });\n }\n upto = endLine.number + 1;\n }\n return blocks;\n}\nfunction moveLine(state, dispatch, forward) {\n if (state.readOnly)\n return false;\n let changes = [], ranges = [];\n for (let block of selectedLineBlocks(state)) {\n if (forward ? block.to == state.doc.length : block.from == 0)\n continue;\n let nextLine = state.doc.lineAt(forward ? block.to + 1 : block.from - 1);\n let size = nextLine.length + 1;\n if (forward) {\n changes.push({ from: block.to, to: nextLine.to }, { from: block.from, insert: nextLine.text + state.lineBreak });\n for (let r of block.ranges)\n ranges.push(EditorSelection.range(Math.min(state.doc.length, r.anchor + size), Math.min(state.doc.length, r.head + size)));\n }\n else {\n changes.push({ from: nextLine.from, to: block.from }, { from: block.to, insert: state.lineBreak + nextLine.text });\n for (let r of block.ranges)\n ranges.push(EditorSelection.range(r.anchor - size, r.head - size));\n }\n }\n if (!changes.length)\n return false;\n dispatch(state.update({\n changes,\n scrollIntoView: true,\n selection: EditorSelection.create(ranges, state.selection.mainIndex),\n userEvent: \"move.line\"\n }));\n return true;\n}\n/**\nMove the selected lines up one line.\n*/\nconst moveLineUp = ({ state, dispatch }) => moveLine(state, dispatch, false);\n/**\nMove the selected lines down one line.\n*/\nconst moveLineDown = ({ state, dispatch }) => moveLine(state, dispatch, true);\nfunction copyLine(state, dispatch, forward) {\n if (state.readOnly)\n return false;\n let changes = [];\n for (let block of selectedLineBlocks(state)) {\n if (forward)\n changes.push({ from: block.from, insert: state.doc.slice(block.from, block.to) + state.lineBreak });\n else\n changes.push({ from: block.to, insert: state.lineBreak + state.doc.slice(block.from, block.to) });\n }\n dispatch(state.update({ changes, scrollIntoView: true, userEvent: \"input.copyline\" }));\n return true;\n}\n/**\nCreate a copy of the selected lines. Keep the selection in the top copy.\n*/\nconst copyLineUp = ({ state, dispatch }) => copyLine(state, dispatch, false);\n/**\nCreate a copy of the selected lines. Keep the selection in the bottom copy.\n*/\nconst copyLineDown = ({ state, dispatch }) => copyLine(state, dispatch, true);\n/**\nDelete selected lines.\n*/\nconst deleteLine = view => {\n if (view.state.readOnly)\n return false;\n let { state } = view, changes = state.changes(selectedLineBlocks(state).map(({ from, to }) => {\n if (from > 0)\n from--;\n else if (to < state.doc.length)\n to++;\n return { from, to };\n }));\n let selection = updateSel(state.selection, range => view.moveVertically(range, true)).map(changes);\n view.dispatch({ changes, selection, scrollIntoView: true, userEvent: \"delete.line\" });\n return true;\n};\n/**\nReplace the selection with a newline.\n*/\nconst insertNewline = ({ state, dispatch }) => {\n dispatch(state.update(state.replaceSelection(state.lineBreak), { scrollIntoView: true, userEvent: \"input\" }));\n return true;\n};\nfunction isBetweenBrackets(state, pos) {\n if (/\\(\\)|\\[\\]|\\{\\}/.test(state.sliceDoc(pos - 1, pos + 1)))\n return { from: pos, to: pos };\n let context = syntaxTree(state).resolveInner(pos);\n let before = context.childBefore(pos), after = context.childAfter(pos), closedBy;\n if (before && after && before.to <= pos && after.from >= pos &&\n (closedBy = before.type.prop(NodeProp.closedBy)) && closedBy.indexOf(after.name) > -1 &&\n state.doc.lineAt(before.to).from == state.doc.lineAt(after.from).from &&\n !/\\S/.test(state.sliceDoc(before.to, after.from)))\n return { from: before.to, to: after.from };\n return null;\n}\n/**\nReplace the selection with a newline and indent the newly created\nline(s). If the current line consists only of whitespace, this\nwill also delete that whitespace. When the cursor is between\nmatching brackets, an additional newline will be inserted after\nthe cursor.\n*/\nconst insertNewlineAndIndent = /*@__PURE__*/newlineAndIndent(false);\n/**\nCreate a blank, indented line below the current line.\n*/\nconst insertBlankLine = /*@__PURE__*/newlineAndIndent(true);\nfunction newlineAndIndent(atEof) {\n return ({ state, dispatch }) => {\n if (state.readOnly)\n return false;\n let changes = state.changeByRange(range => {\n let { from, to } = range, line = state.doc.lineAt(from);\n let explode = !atEof && from == to && isBetweenBrackets(state, from);\n if (atEof)\n from = to = (to <= line.to ? line : state.doc.lineAt(to)).to;\n let cx = new IndentContext(state, { simulateBreak: from, simulateDoubleBreak: !!explode });\n let indent = getIndentation(cx, from);\n if (indent == null)\n indent = countColumn(/^\\s*/.exec(state.doc.lineAt(from).text)[0], state.tabSize);\n while (to < line.to && /\\s/.test(line.text[to - line.from]))\n to++;\n if (explode)\n ({ from, to } = explode);\n else if (from > line.from && from < line.from + 100 && !/\\S/.test(line.text.slice(0, from)))\n from = line.from;\n let insert = [\"\", indentString(state, indent)];\n if (explode)\n insert.push(indentString(state, cx.lineIndent(line.from, -1)));\n return { changes: { from, to, insert: Text.of(insert) },\n range: EditorSelection.cursor(from + 1 + insert[1].length) };\n });\n dispatch(state.update(changes, { scrollIntoView: true, userEvent: \"input\" }));\n return true;\n };\n}\nfunction changeBySelectedLine(state, f) {\n let atLine = -1;\n return state.changeByRange(range => {\n let changes = [];\n for (let pos = range.from; pos <= range.to;) {\n let line = state.doc.lineAt(pos);\n if (line.number > atLine && (range.empty || range.to > line.from)) {\n f(line, changes, range);\n atLine = line.number;\n }\n pos = line.to + 1;\n }\n let changeSet = state.changes(changes);\n return { changes,\n range: EditorSelection.range(changeSet.mapPos(range.anchor, 1), changeSet.mapPos(range.head, 1)) };\n });\n}\n/**\nAuto-indent the selected lines. This uses the [indentation service\nfacet](https://codemirror.net/6/docs/ref/#language.indentService) as source for auto-indent\ninformation.\n*/\nconst indentSelection = ({ state, dispatch }) => {\n if (state.readOnly)\n return false;\n let updated = Object.create(null);\n let context = new IndentContext(state, { overrideIndentation: start => {\n let found = updated[start];\n return found == null ? -1 : found;\n } });\n let changes = changeBySelectedLine(state, (line, changes, range) => {\n let indent = getIndentation(context, line.from);\n if (indent == null)\n return;\n if (!/\\S/.test(line.text))\n indent = 0;\n let cur = /^\\s*/.exec(line.text)[0];\n let norm = indentString(state, indent);\n if (cur != norm || range.from < line.from + cur.length) {\n updated[line.from] = indent;\n changes.push({ from: line.from, to: line.from + cur.length, insert: norm });\n }\n });\n if (!changes.changes.empty)\n dispatch(state.update(changes, { userEvent: \"indent\" }));\n return true;\n};\n/**\nAdd a [unit](https://codemirror.net/6/docs/ref/#language.indentUnit) of indentation to all selected\nlines.\n*/\nconst indentMore = ({ state, dispatch }) => {\n if (state.readOnly)\n return false;\n dispatch(state.update(changeBySelectedLine(state, (line, changes) => {\n changes.push({ from: line.from, insert: state.facet(indentUnit) });\n }), { userEvent: \"input.indent\" }));\n return true;\n};\n/**\nRemove a [unit](https://codemirror.net/6/docs/ref/#language.indentUnit) of indentation from all\nselected lines.\n*/\nconst indentLess = ({ state, dispatch }) => {\n if (state.readOnly)\n return false;\n dispatch(state.update(changeBySelectedLine(state, (line, changes) => {\n let space = /^\\s*/.exec(line.text)[0];\n if (!space)\n return;\n let col = countColumn(space, state.tabSize), keep = 0;\n let insert = indentString(state, Math.max(0, col - getIndentUnit(state)));\n while (keep < space.length && keep < insert.length && space.charCodeAt(keep) == insert.charCodeAt(keep))\n keep++;\n changes.push({ from: line.from + keep, to: line.from + space.length, insert: insert.slice(keep) });\n }), { userEvent: \"delete.dedent\" }));\n return true;\n};\n/**\nInsert a tab character at the cursor or, if something is selected,\nuse [`indentMore`](https://codemirror.net/6/docs/ref/#commands.indentMore) to indent the entire\nselection.\n*/\nconst insertTab = ({ state, dispatch }) => {\n if (state.selection.ranges.some(r => !r.empty))\n return indentMore({ state, dispatch });\n dispatch(state.update(state.replaceSelection(\"\\t\"), { scrollIntoView: true, userEvent: \"input\" }));\n return true;\n};\n/**\nArray of key bindings containing the Emacs-style bindings that are\navailable on macOS by default.\n\n - Ctrl-b: [`cursorCharLeft`](https://codemirror.net/6/docs/ref/#commands.cursorCharLeft) ([`selectCharLeft`](https://codemirror.net/6/docs/ref/#commands.selectCharLeft) with Shift)\n - Ctrl-f: [`cursorCharRight`](https://codemirror.net/6/docs/ref/#commands.cursorCharRight) ([`selectCharRight`](https://codemirror.net/6/docs/ref/#commands.selectCharRight) with Shift)\n - Ctrl-p: [`cursorLineUp`](https://codemirror.net/6/docs/ref/#commands.cursorLineUp) ([`selectLineUp`](https://codemirror.net/6/docs/ref/#commands.selectLineUp) with Shift)\n - Ctrl-n: [`cursorLineDown`](https://codemirror.net/6/docs/ref/#commands.cursorLineDown) ([`selectLineDown`](https://codemirror.net/6/docs/ref/#commands.selectLineDown) with Shift)\n - Ctrl-a: [`cursorLineStart`](https://codemirror.net/6/docs/ref/#commands.cursorLineStart) ([`selectLineStart`](https://codemirror.net/6/docs/ref/#commands.selectLineStart) with Shift)\n - Ctrl-e: [`cursorLineEnd`](https://codemirror.net/6/docs/ref/#commands.cursorLineEnd) ([`selectLineEnd`](https://codemirror.net/6/docs/ref/#commands.selectLineEnd) with Shift)\n - Ctrl-d: [`deleteCharForward`](https://codemirror.net/6/docs/ref/#commands.deleteCharForward)\n - Ctrl-h: [`deleteCharBackward`](https://codemirror.net/6/docs/ref/#commands.deleteCharBackward)\n - Ctrl-k: [`deleteToLineEnd`](https://codemirror.net/6/docs/ref/#commands.deleteToLineEnd)\n - Ctrl-Alt-h: [`deleteGroupBackward`](https://codemirror.net/6/docs/ref/#commands.deleteGroupBackward)\n - Ctrl-o: [`splitLine`](https://codemirror.net/6/docs/ref/#commands.splitLine)\n - Ctrl-t: [`transposeChars`](https://codemirror.net/6/docs/ref/#commands.transposeChars)\n - Ctrl-v: [`cursorPageDown`](https://codemirror.net/6/docs/ref/#commands.cursorPageDown)\n - Alt-v: [`cursorPageUp`](https://codemirror.net/6/docs/ref/#commands.cursorPageUp)\n*/\nconst emacsStyleKeymap = [\n { key: \"Ctrl-b\", run: cursorCharLeft, shift: selectCharLeft, preventDefault: true },\n { key: \"Ctrl-f\", run: cursorCharRight, shift: selectCharRight },\n { key: \"Ctrl-p\", run: cursorLineUp, shift: selectLineUp },\n { key: \"Ctrl-n\", run: cursorLineDown, shift: selectLineDown },\n { key: \"Ctrl-a\", run: cursorLineStart, shift: selectLineStart },\n { key: \"Ctrl-e\", run: cursorLineEnd, shift: selectLineEnd },\n { key: \"Ctrl-d\", run: deleteCharForward },\n { key: \"Ctrl-h\", run: deleteCharBackward },\n { key: \"Ctrl-k\", run: deleteToLineEnd },\n { key: \"Ctrl-Alt-h\", run: deleteGroupBackward },\n { key: \"Ctrl-o\", run: splitLine },\n { key: \"Ctrl-t\", run: transposeChars },\n { key: \"Ctrl-v\", run: cursorPageDown },\n];\n/**\nAn array of key bindings closely sticking to platform-standard or\nwidely used bindings. (This includes the bindings from\n[`emacsStyleKeymap`](https://codemirror.net/6/docs/ref/#commands.emacsStyleKeymap), with their `key`\nproperty changed to `mac`.)\n\n - ArrowLeft: [`cursorCharLeft`](https://codemirror.net/6/docs/ref/#commands.cursorCharLeft) ([`selectCharLeft`](https://codemirror.net/6/docs/ref/#commands.selectCharLeft) with Shift)\n - ArrowRight: [`cursorCharRight`](https://codemirror.net/6/docs/ref/#commands.cursorCharRight) ([`selectCharRight`](https://codemirror.net/6/docs/ref/#commands.selectCharRight) with Shift)\n - Ctrl-ArrowLeft (Alt-ArrowLeft on macOS): [`cursorGroupLeft`](https://codemirror.net/6/docs/ref/#commands.cursorGroupLeft) ([`selectGroupLeft`](https://codemirror.net/6/docs/ref/#commands.selectGroupLeft) with Shift)\n - Ctrl-ArrowRight (Alt-ArrowRight on macOS): [`cursorGroupRight`](https://codemirror.net/6/docs/ref/#commands.cursorGroupRight) ([`selectGroupRight`](https://codemirror.net/6/docs/ref/#commands.selectGroupRight) with Shift)\n - Cmd-ArrowLeft (on macOS): [`cursorLineStart`](https://codemirror.net/6/docs/ref/#commands.cursorLineStart) ([`selectLineStart`](https://codemirror.net/6/docs/ref/#commands.selectLineStart) with Shift)\n - Cmd-ArrowRight (on macOS): [`cursorLineEnd`](https://codemirror.net/6/docs/ref/#commands.cursorLineEnd) ([`selectLineEnd`](https://codemirror.net/6/docs/ref/#commands.selectLineEnd) with Shift)\n - ArrowUp: [`cursorLineUp`](https://codemirror.net/6/docs/ref/#commands.cursorLineUp) ([`selectLineUp`](https://codemirror.net/6/docs/ref/#commands.selectLineUp) with Shift)\n - ArrowDown: [`cursorLineDown`](https://codemirror.net/6/docs/ref/#commands.cursorLineDown) ([`selectLineDown`](https://codemirror.net/6/docs/ref/#commands.selectLineDown) with Shift)\n - Cmd-ArrowUp (on macOS): [`cursorDocStart`](https://codemirror.net/6/docs/ref/#commands.cursorDocStart) ([`selectDocStart`](https://codemirror.net/6/docs/ref/#commands.selectDocStart) with Shift)\n - Cmd-ArrowDown (on macOS): [`cursorDocEnd`](https://codemirror.net/6/docs/ref/#commands.cursorDocEnd) ([`selectDocEnd`](https://codemirror.net/6/docs/ref/#commands.selectDocEnd) with Shift)\n - Ctrl-ArrowUp (on macOS): [`cursorPageUp`](https://codemirror.net/6/docs/ref/#commands.cursorPageUp) ([`selectPageUp`](https://codemirror.net/6/docs/ref/#commands.selectPageUp) with Shift)\n - Ctrl-ArrowDown (on macOS): [`cursorPageDown`](https://codemirror.net/6/docs/ref/#commands.cursorPageDown) ([`selectPageDown`](https://codemirror.net/6/docs/ref/#commands.selectPageDown) with Shift)\n - PageUp: [`cursorPageUp`](https://codemirror.net/6/docs/ref/#commands.cursorPageUp) ([`selectPageUp`](https://codemirror.net/6/docs/ref/#commands.selectPageUp) with Shift)\n - PageDown: [`cursorPageDown`](https://codemirror.net/6/docs/ref/#commands.cursorPageDown) ([`selectPageDown`](https://codemirror.net/6/docs/ref/#commands.selectPageDown) with Shift)\n - Home: [`cursorLineBoundaryBackward`](https://codemirror.net/6/docs/ref/#commands.cursorLineBoundaryBackward) ([`selectLineBoundaryBackward`](https://codemirror.net/6/docs/ref/#commands.selectLineBoundaryBackward) with Shift)\n - End: [`cursorLineBoundaryForward`](https://codemirror.net/6/docs/ref/#commands.cursorLineBoundaryForward) ([`selectLineBoundaryForward`](https://codemirror.net/6/docs/ref/#commands.selectLineBoundaryForward) with Shift)\n - Ctrl-Home (Cmd-Home on macOS): [`cursorDocStart`](https://codemirror.net/6/docs/ref/#commands.cursorDocStart) ([`selectDocStart`](https://codemirror.net/6/docs/ref/#commands.selectDocStart) with Shift)\n - Ctrl-End (Cmd-Home on macOS): [`cursorDocEnd`](https://codemirror.net/6/docs/ref/#commands.cursorDocEnd) ([`selectDocEnd`](https://codemirror.net/6/docs/ref/#commands.selectDocEnd) with Shift)\n - Enter: [`insertNewlineAndIndent`](https://codemirror.net/6/docs/ref/#commands.insertNewlineAndIndent)\n - Ctrl-a (Cmd-a on macOS): [`selectAll`](https://codemirror.net/6/docs/ref/#commands.selectAll)\n - Backspace: [`deleteCharBackward`](https://codemirror.net/6/docs/ref/#commands.deleteCharBackward)\n - Delete: [`deleteCharForward`](https://codemirror.net/6/docs/ref/#commands.deleteCharForward)\n - Ctrl-Backspace (Alt-Backspace on macOS): [`deleteGroupBackward`](https://codemirror.net/6/docs/ref/#commands.deleteGroupBackward)\n - Ctrl-Delete (Alt-Delete on macOS): [`deleteGroupForward`](https://codemirror.net/6/docs/ref/#commands.deleteGroupForward)\n - Cmd-Backspace (macOS): [`deleteToLineStart`](https://codemirror.net/6/docs/ref/#commands.deleteToLineStart).\n - Cmd-Delete (macOS): [`deleteToLineEnd`](https://codemirror.net/6/docs/ref/#commands.deleteToLineEnd).\n*/\nconst standardKeymap = /*@__PURE__*/[\n { key: \"ArrowLeft\", run: cursorCharLeft, shift: selectCharLeft, preventDefault: true },\n { key: \"Mod-ArrowLeft\", mac: \"Alt-ArrowLeft\", run: cursorGroupLeft, shift: selectGroupLeft, preventDefault: true },\n { mac: \"Cmd-ArrowLeft\", run: cursorLineBoundaryLeft, shift: selectLineBoundaryLeft, preventDefault: true },\n { key: \"ArrowRight\", run: cursorCharRight, shift: selectCharRight, preventDefault: true },\n { key: \"Mod-ArrowRight\", mac: \"Alt-ArrowRight\", run: cursorGroupRight, shift: selectGroupRight, preventDefault: true },\n { mac: \"Cmd-ArrowRight\", run: cursorLineBoundaryRight, shift: selectLineBoundaryRight, preventDefault: true },\n { key: \"ArrowUp\", run: cursorLineUp, shift: selectLineUp, preventDefault: true },\n { mac: \"Cmd-ArrowUp\", run: cursorDocStart, shift: selectDocStart },\n { mac: \"Ctrl-ArrowUp\", run: cursorPageUp, shift: selectPageUp },\n { key: \"ArrowDown\", run: cursorLineDown, shift: selectLineDown, preventDefault: true },\n { mac: \"Cmd-ArrowDown\", run: cursorDocEnd, shift: selectDocEnd },\n { mac: \"Ctrl-ArrowDown\", run: cursorPageDown, shift: selectPageDown },\n { key: \"PageUp\", run: cursorPageUp, shift: selectPageUp },\n { key: \"PageDown\", run: cursorPageDown, shift: selectPageDown },\n { key: \"Home\", run: cursorLineBoundaryBackward, shift: selectLineBoundaryBackward, preventDefault: true },\n { key: \"Mod-Home\", run: cursorDocStart, shift: selectDocStart },\n { key: \"End\", run: cursorLineBoundaryForward, shift: selectLineBoundaryForward, preventDefault: true },\n { key: \"Mod-End\", run: cursorDocEnd, shift: selectDocEnd },\n { key: \"Enter\", run: insertNewlineAndIndent },\n { key: \"Mod-a\", run: selectAll },\n { key: \"Backspace\", run: deleteCharBackward, shift: deleteCharBackward },\n { key: \"Delete\", run: deleteCharForward },\n { key: \"Mod-Backspace\", mac: \"Alt-Backspace\", run: deleteGroupBackward },\n { key: \"Mod-Delete\", mac: \"Alt-Delete\", run: deleteGroupForward },\n { mac: \"Mod-Backspace\", run: deleteToLineStart },\n { mac: \"Mod-Delete\", run: deleteToLineEnd }\n].concat(/*@__PURE__*/emacsStyleKeymap.map(b => ({ mac: b.key, run: b.run, shift: b.shift })));\n/**\nThe default keymap. Includes all bindings from\n[`standardKeymap`](https://codemirror.net/6/docs/ref/#commands.standardKeymap) plus the following:\n\n- Alt-ArrowLeft (Ctrl-ArrowLeft on macOS): [`cursorSyntaxLeft`](https://codemirror.net/6/docs/ref/#commands.cursorSyntaxLeft) ([`selectSyntaxLeft`](https://codemirror.net/6/docs/ref/#commands.selectSyntaxLeft) with Shift)\n- Alt-ArrowRight (Ctrl-ArrowRight on macOS): [`cursorSyntaxRight`](https://codemirror.net/6/docs/ref/#commands.cursorSyntaxRight) ([`selectSyntaxRight`](https://codemirror.net/6/docs/ref/#commands.selectSyntaxRight) with Shift)\n- Alt-ArrowUp: [`moveLineUp`](https://codemirror.net/6/docs/ref/#commands.moveLineUp)\n- Alt-ArrowDown: [`moveLineDown`](https://codemirror.net/6/docs/ref/#commands.moveLineDown)\n- Shift-Alt-ArrowUp: [`copyLineUp`](https://codemirror.net/6/docs/ref/#commands.copyLineUp)\n- Shift-Alt-ArrowDown: [`copyLineDown`](https://codemirror.net/6/docs/ref/#commands.copyLineDown)\n- Escape: [`simplifySelection`](https://codemirror.net/6/docs/ref/#commands.simplifySelection)\n- Ctrl-Enter (Cmd-Enter on macOS): [`insertBlankLine`](https://codemirror.net/6/docs/ref/#commands.insertBlankLine)\n- Alt-l (Ctrl-l on macOS): [`selectLine`](https://codemirror.net/6/docs/ref/#commands.selectLine)\n- Ctrl-i (Cmd-i on macOS): [`selectParentSyntax`](https://codemirror.net/6/docs/ref/#commands.selectParentSyntax)\n- Ctrl-[ (Cmd-[ on macOS): [`indentLess`](https://codemirror.net/6/docs/ref/#commands.indentLess)\n- Ctrl-] (Cmd-] on macOS): [`indentMore`](https://codemirror.net/6/docs/ref/#commands.indentMore)\n- Ctrl-Alt-\\\\ (Cmd-Alt-\\\\ on macOS): [`indentSelection`](https://codemirror.net/6/docs/ref/#commands.indentSelection)\n- Shift-Ctrl-k (Shift-Cmd-k on macOS): [`deleteLine`](https://codemirror.net/6/docs/ref/#commands.deleteLine)\n- Shift-Ctrl-\\\\ (Shift-Cmd-\\\\ on macOS): [`cursorMatchingBracket`](https://codemirror.net/6/docs/ref/#commands.cursorMatchingBracket)\n- Ctrl-/ (Cmd-/ on macOS): [`toggleComment`](https://codemirror.net/6/docs/ref/#commands.toggleComment).\n- Shift-Alt-a: [`toggleBlockComment`](https://codemirror.net/6/docs/ref/#commands.toggleBlockComment).\n*/\nconst defaultKeymap = /*@__PURE__*/[\n { key: \"Alt-ArrowLeft\", mac: \"Ctrl-ArrowLeft\", run: cursorSyntaxLeft, shift: selectSyntaxLeft },\n { key: \"Alt-ArrowRight\", mac: \"Ctrl-ArrowRight\", run: cursorSyntaxRight, shift: selectSyntaxRight },\n { key: \"Alt-ArrowUp\", run: moveLineUp },\n { key: \"Shift-Alt-ArrowUp\", run: copyLineUp },\n { key: \"Alt-ArrowDown\", run: moveLineDown },\n { key: \"Shift-Alt-ArrowDown\", run: copyLineDown },\n { key: \"Escape\", run: simplifySelection },\n { key: \"Mod-Enter\", run: insertBlankLine },\n { key: \"Alt-l\", mac: \"Ctrl-l\", run: selectLine },\n { key: \"Mod-i\", run: selectParentSyntax, preventDefault: true },\n { key: \"Mod-[\", run: indentLess },\n { key: \"Mod-]\", run: indentMore },\n { key: \"Mod-Alt-\\\\\", run: indentSelection },\n { key: \"Shift-Mod-k\", run: deleteLine },\n { key: \"Shift-Mod-\\\\\", run: cursorMatchingBracket },\n { key: \"Mod-/\", run: toggleComment },\n { key: \"Alt-A\", run: toggleBlockComment }\n].concat(standardKeymap);\n/**\nA binding that binds Tab to [`indentMore`](https://codemirror.net/6/docs/ref/#commands.indentMore) and\nShift-Tab to [`indentLess`](https://codemirror.net/6/docs/ref/#commands.indentLess).\nPlease see the [Tab example](../../examples/tab/) before using\nthis.\n*/\nconst indentWithTab = { key: \"Tab\", run: indentMore, shift: indentLess };\n\nexport { blockComment, blockUncomment, copyLineDown, copyLineUp, cursorCharBackward, cursorCharForward, cursorCharLeft, cursorCharRight, cursorDocEnd, cursorDocStart, cursorGroupBackward, cursorGroupForward, cursorGroupLeft, cursorGroupRight, cursorLineBoundaryBackward, cursorLineBoundaryForward, cursorLineBoundaryLeft, cursorLineBoundaryRight, cursorLineDown, cursorLineEnd, cursorLineStart, cursorLineUp, cursorMatchingBracket, cursorPageDown, cursorPageUp, cursorSubwordBackward, cursorSubwordForward, cursorSyntaxLeft, cursorSyntaxRight, defaultKeymap, deleteCharBackward, deleteCharForward, deleteGroupBackward, deleteGroupForward, deleteLine, deleteToLineEnd, deleteToLineStart, deleteTrailingWhitespace, emacsStyleKeymap, history, historyField, historyKeymap, indentLess, indentMore, indentSelection, indentWithTab, insertBlankLine, insertNewline, insertNewlineAndIndent, insertTab, invertedEffects, isolateHistory, lineComment, lineUncomment, moveLineDown, moveLineUp, redo, redoDepth, redoSelection, selectAll, selectCharBackward, selectCharForward, selectCharLeft, selectCharRight, selectDocEnd, selectDocStart, selectGroupBackward, selectGroupForward, selectGroupLeft, selectGroupRight, selectLine, selectLineBoundaryBackward, selectLineBoundaryForward, selectLineBoundaryLeft, selectLineBoundaryRight, selectLineDown, selectLineEnd, selectLineStart, selectLineUp, selectMatchingBracket, selectPageDown, selectPageUp, selectParentSyntax, selectSubwordBackward, selectSubwordForward, selectSyntaxLeft, selectSyntaxRight, simplifySelection, splitLine, standardKeymap, toggleBlockComment, toggleBlockCommentByLine, toggleComment, toggleLineComment, transposeChars, undo, undoDepth, undoSelection };\n","export default function crelt() {\n var elt = arguments[0]\n if (typeof elt == \"string\") elt = document.createElement(elt)\n var i = 1, next = arguments[1]\n if (next && typeof next == \"object\" && next.nodeType == null && !Array.isArray(next)) {\n for (var name in next) if (Object.prototype.hasOwnProperty.call(next, name)) {\n var value = next[name]\n if (typeof value == \"string\") elt.setAttribute(name, value)\n else if (value != null) elt[name] = value\n }\n i++\n }\n for (; i < arguments.length; i++) add(elt, arguments[i])\n return elt\n}\n\nfunction add(elt, child) {\n if (typeof child == \"string\") {\n elt.appendChild(document.createTextNode(child))\n } else if (child == null) {\n } else if (child.nodeType != null) {\n elt.appendChild(child)\n } else if (Array.isArray(child)) {\n for (var i = 0; i < child.length; i++) add(elt, child[i])\n } else {\n throw new RangeError(\"Unsupported child node: \" + child)\n }\n}\n","import { showPanel, EditorView, getPanel, Decoration, ViewPlugin, runScopeHandlers } from '@codemirror/view';\nimport { codePointAt, fromCodePoint, codePointSize, StateEffect, StateField, EditorSelection, Facet, combineConfig, CharCategory, RangeSetBuilder, Prec, EditorState, findClusterBreak } from '@codemirror/state';\nimport elt from 'crelt';\n\nconst basicNormalize = typeof String.prototype.normalize == \"function\"\n ? x => x.normalize(\"NFKD\") : x => x;\n/**\nA search cursor provides an iterator over text matches in a\ndocument.\n*/\nclass SearchCursor {\n /**\n Create a text cursor. The query is the search string, `from` to\n `to` provides the region to search.\n \n When `normalize` is given, it will be called, on both the query\n string and the content it is matched against, before comparing.\n You can, for example, create a case-insensitive search by\n passing `s => s.toLowerCase()`.\n \n Text is always normalized with\n [`.normalize(\"NFKD\")`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize)\n (when supported).\n */\n constructor(text, query, from = 0, to = text.length, normalize, test) {\n this.test = test;\n /**\n The current match (only holds a meaningful value after\n [`next`](https://codemirror.net/6/docs/ref/#search.SearchCursor.next) has been called and when\n `done` is false).\n */\n this.value = { from: 0, to: 0 };\n /**\n Whether the end of the iterated region has been reached.\n */\n this.done = false;\n this.matches = [];\n this.buffer = \"\";\n this.bufferPos = 0;\n this.iter = text.iterRange(from, to);\n this.bufferStart = from;\n this.normalize = normalize ? x => normalize(basicNormalize(x)) : basicNormalize;\n this.query = this.normalize(query);\n }\n peek() {\n if (this.bufferPos == this.buffer.length) {\n this.bufferStart += this.buffer.length;\n this.iter.next();\n if (this.iter.done)\n return -1;\n this.bufferPos = 0;\n this.buffer = this.iter.value;\n }\n return codePointAt(this.buffer, this.bufferPos);\n }\n /**\n Look for the next match. Updates the iterator's\n [`value`](https://codemirror.net/6/docs/ref/#search.SearchCursor.value) and\n [`done`](https://codemirror.net/6/docs/ref/#search.SearchCursor.done) properties. Should be called\n at least once before using the cursor.\n */\n next() {\n while (this.matches.length)\n this.matches.pop();\n return this.nextOverlapping();\n }\n /**\n The `next` method will ignore matches that partially overlap a\n previous match. This method behaves like `next`, but includes\n such matches.\n */\n nextOverlapping() {\n for (;;) {\n let next = this.peek();\n if (next < 0) {\n this.done = true;\n return this;\n }\n let str = fromCodePoint(next), start = this.bufferStart + this.bufferPos;\n this.bufferPos += codePointSize(next);\n let norm = this.normalize(str);\n for (let i = 0, pos = start;; i++) {\n let code = norm.charCodeAt(i);\n let match = this.match(code, pos);\n if (i == norm.length - 1) {\n if (match) {\n this.value = match;\n return this;\n }\n break;\n }\n if (pos == start && i < str.length && str.charCodeAt(i) == code)\n pos++;\n }\n }\n }\n match(code, pos) {\n let match = null;\n for (let i = 0; i < this.matches.length; i += 2) {\n let index = this.matches[i], keep = false;\n if (this.query.charCodeAt(index) == code) {\n if (index == this.query.length - 1) {\n match = { from: this.matches[i + 1], to: pos + 1 };\n }\n else {\n this.matches[i]++;\n keep = true;\n }\n }\n if (!keep) {\n this.matches.splice(i, 2);\n i -= 2;\n }\n }\n if (this.query.charCodeAt(0) == code) {\n if (this.query.length == 1)\n match = { from: pos, to: pos + 1 };\n else\n this.matches.push(1, pos);\n }\n if (match && this.test && !this.test(match.from, match.to, this.buffer, this.bufferStart))\n match = null;\n return match;\n }\n}\nif (typeof Symbol != \"undefined\")\n SearchCursor.prototype[Symbol.iterator] = function () { return this; };\n\nconst empty = { from: -1, to: -1, match: /*@__PURE__*//.*/.exec(\"\") };\nconst baseFlags = \"gm\" + (/x/.unicode == null ? \"\" : \"u\");\n/**\nThis class is similar to [`SearchCursor`](https://codemirror.net/6/docs/ref/#search.SearchCursor)\nbut searches for a regular expression pattern instead of a plain\nstring.\n*/\nclass RegExpCursor {\n /**\n Create a cursor that will search the given range in the given\n document. `query` should be the raw pattern (as you'd pass it to\n `new RegExp`).\n */\n constructor(text, query, options, from = 0, to = text.length) {\n this.text = text;\n this.to = to;\n this.curLine = \"\";\n /**\n Set to `true` when the cursor has reached the end of the search\n range.\n */\n this.done = false;\n /**\n Will contain an object with the extent of the match and the\n match object when [`next`](https://codemirror.net/6/docs/ref/#search.RegExpCursor.next)\n sucessfully finds a match.\n */\n this.value = empty;\n if (/\\\\[sWDnr]|\\n|\\r|\\[\\^/.test(query))\n return new MultilineRegExpCursor(text, query, options, from, to);\n this.re = new RegExp(query, baseFlags + ((options === null || options === void 0 ? void 0 : options.ignoreCase) ? \"i\" : \"\"));\n this.test = options === null || options === void 0 ? void 0 : options.test;\n this.iter = text.iter();\n let startLine = text.lineAt(from);\n this.curLineStart = startLine.from;\n this.matchPos = toCharEnd(text, from);\n this.getLine(this.curLineStart);\n }\n getLine(skip) {\n this.iter.next(skip);\n if (this.iter.lineBreak) {\n this.curLine = \"\";\n }\n else {\n this.curLine = this.iter.value;\n if (this.curLineStart + this.curLine.length > this.to)\n this.curLine = this.curLine.slice(0, this.to - this.curLineStart);\n this.iter.next();\n }\n }\n nextLine() {\n this.curLineStart = this.curLineStart + this.curLine.length + 1;\n if (this.curLineStart > this.to)\n this.curLine = \"\";\n else\n this.getLine(0);\n }\n /**\n Move to the next match, if there is one.\n */\n next() {\n for (let off = this.matchPos - this.curLineStart;;) {\n this.re.lastIndex = off;\n let match = this.matchPos <= this.to && this.re.exec(this.curLine);\n if (match) {\n let from = this.curLineStart + match.index, to = from + match[0].length;\n this.matchPos = toCharEnd(this.text, to + (from == to ? 1 : 0));\n if (from == this.curLineStart + this.curLine.length)\n this.nextLine();\n if ((from < to || from > this.value.to) && (!this.test || this.test(from, to, match))) {\n this.value = { from, to, match };\n return this;\n }\n off = this.matchPos - this.curLineStart;\n }\n else if (this.curLineStart + this.curLine.length < this.to) {\n this.nextLine();\n off = 0;\n }\n else {\n this.done = true;\n return this;\n }\n }\n }\n}\nconst flattened = /*@__PURE__*/new WeakMap();\n// Reusable (partially) flattened document strings\nclass FlattenedDoc {\n constructor(from, text) {\n this.from = from;\n this.text = text;\n }\n get to() { return this.from + this.text.length; }\n static get(doc, from, to) {\n let cached = flattened.get(doc);\n if (!cached || cached.from >= to || cached.to <= from) {\n let flat = new FlattenedDoc(from, doc.sliceString(from, to));\n flattened.set(doc, flat);\n return flat;\n }\n if (cached.from == from && cached.to == to)\n return cached;\n let { text, from: cachedFrom } = cached;\n if (cachedFrom > from) {\n text = doc.sliceString(from, cachedFrom) + text;\n cachedFrom = from;\n }\n if (cached.to < to)\n text += doc.sliceString(cached.to, to);\n flattened.set(doc, new FlattenedDoc(cachedFrom, text));\n return new FlattenedDoc(from, text.slice(from - cachedFrom, to - cachedFrom));\n }\n}\nclass MultilineRegExpCursor {\n constructor(text, query, options, from, to) {\n this.text = text;\n this.to = to;\n this.done = false;\n this.value = empty;\n this.matchPos = toCharEnd(text, from);\n this.re = new RegExp(query, baseFlags + ((options === null || options === void 0 ? void 0 : options.ignoreCase) ? \"i\" : \"\"));\n this.test = options === null || options === void 0 ? void 0 : options.test;\n this.flat = FlattenedDoc.get(text, from, this.chunkEnd(from + 5000 /* Chunk.Base */));\n }\n chunkEnd(pos) {\n return pos >= this.to ? this.to : this.text.lineAt(pos).to;\n }\n next() {\n for (;;) {\n let off = this.re.lastIndex = this.matchPos - this.flat.from;\n let match = this.re.exec(this.flat.text);\n // Skip empty matches directly after the last match\n if (match && !match[0] && match.index == off) {\n this.re.lastIndex = off + 1;\n match = this.re.exec(this.flat.text);\n }\n if (match) {\n let from = this.flat.from + match.index, to = from + match[0].length;\n // If a match goes almost to the end of a noncomplete chunk, try\n // again, since it'll likely be able to match more\n if ((this.flat.to >= this.to || match.index + match[0].length <= this.flat.text.length - 10) &&\n (!this.test || this.test(from, to, match))) {\n this.value = { from, to, match };\n this.matchPos = toCharEnd(this.text, to + (from == to ? 1 : 0));\n return this;\n }\n }\n if (this.flat.to == this.to) {\n this.done = true;\n return this;\n }\n // Grow the flattened doc\n this.flat = FlattenedDoc.get(this.text, this.flat.from, this.chunkEnd(this.flat.from + this.flat.text.length * 2));\n }\n }\n}\nif (typeof Symbol != \"undefined\") {\n RegExpCursor.prototype[Symbol.iterator] = MultilineRegExpCursor.prototype[Symbol.iterator] =\n function () { return this; };\n}\nfunction validRegExp(source) {\n try {\n new RegExp(source, baseFlags);\n return true;\n }\n catch (_a) {\n return false;\n }\n}\nfunction toCharEnd(text, pos) {\n if (pos >= text.length)\n return pos;\n let line = text.lineAt(pos), next;\n while (pos < line.to && (next = line.text.charCodeAt(pos - line.from)) >= 0xDC00 && next < 0xE000)\n pos++;\n return pos;\n}\n\nfunction createLineDialog(view) {\n let line = String(view.state.doc.lineAt(view.state.selection.main.head).number);\n let input = elt(\"input\", { class: \"cm-textfield\", name: \"line\", value: line });\n let dom = elt(\"form\", {\n class: \"cm-gotoLine\",\n onkeydown: (event) => {\n if (event.keyCode == 27) { // Escape\n event.preventDefault();\n view.dispatch({ effects: dialogEffect.of(false) });\n view.focus();\n }\n else if (event.keyCode == 13) { // Enter\n event.preventDefault();\n go();\n }\n },\n onsubmit: (event) => {\n event.preventDefault();\n go();\n }\n }, elt(\"label\", view.state.phrase(\"Go to line\"), \": \", input), \" \", elt(\"button\", { class: \"cm-button\", type: \"submit\" }, view.state.phrase(\"go\")));\n function go() {\n let match = /^([+-])?(\\d+)?(:\\d+)?(%)?$/.exec(input.value);\n if (!match)\n return;\n let { state } = view, startLine = state.doc.lineAt(state.selection.main.head);\n let [, sign, ln, cl, percent] = match;\n let col = cl ? +cl.slice(1) : 0;\n let line = ln ? +ln : startLine.number;\n if (ln && percent) {\n let pc = line / 100;\n if (sign)\n pc = pc * (sign == \"-\" ? -1 : 1) + (startLine.number / state.doc.lines);\n line = Math.round(state.doc.lines * pc);\n }\n else if (ln && sign) {\n line = line * (sign == \"-\" ? -1 : 1) + startLine.number;\n }\n let docLine = state.doc.line(Math.max(1, Math.min(state.doc.lines, line)));\n let selection = EditorSelection.cursor(docLine.from + Math.max(0, Math.min(col, docLine.length)));\n view.dispatch({\n effects: [dialogEffect.of(false), EditorView.scrollIntoView(selection.from, { y: 'center' })],\n selection,\n });\n view.focus();\n }\n return { dom };\n}\nconst dialogEffect = /*@__PURE__*/StateEffect.define();\nconst dialogField = /*@__PURE__*/StateField.define({\n create() { return true; },\n update(value, tr) {\n for (let e of tr.effects)\n if (e.is(dialogEffect))\n value = e.value;\n return value;\n },\n provide: f => showPanel.from(f, val => val ? createLineDialog : null)\n});\n/**\nCommand that shows a dialog asking the user for a line number, and\nwhen a valid position is provided, moves the cursor to that line.\n\nSupports line numbers, relative line offsets prefixed with `+` or\n`-`, document percentages suffixed with `%`, and an optional\ncolumn position by adding `:` and a second number after the line\nnumber.\n*/\nconst gotoLine = view => {\n let panel = getPanel(view, createLineDialog);\n if (!panel) {\n let effects = [dialogEffect.of(true)];\n if (view.state.field(dialogField, false) == null)\n effects.push(StateEffect.appendConfig.of([dialogField, baseTheme$1]));\n view.dispatch({ effects });\n panel = getPanel(view, createLineDialog);\n }\n if (panel)\n panel.dom.querySelector(\"input\").select();\n return true;\n};\nconst baseTheme$1 = /*@__PURE__*/EditorView.baseTheme({\n \".cm-panel.cm-gotoLine\": {\n padding: \"2px 6px 4px\",\n \"& label\": { fontSize: \"80%\" }\n }\n});\n\nconst defaultHighlightOptions = {\n highlightWordAroundCursor: false,\n minSelectionLength: 1,\n maxMatches: 100,\n wholeWords: false\n};\nconst highlightConfig = /*@__PURE__*/Facet.define({\n combine(options) {\n return combineConfig(options, defaultHighlightOptions, {\n highlightWordAroundCursor: (a, b) => a || b,\n minSelectionLength: Math.min,\n maxMatches: Math.min\n });\n }\n});\n/**\nThis extension highlights text that matches the selection. It uses\nthe `\"cm-selectionMatch\"` class for the highlighting. When\n`highlightWordAroundCursor` is enabled, the word at the cursor\nitself will be highlighted with `\"cm-selectionMatch-main\"`.\n*/\nfunction highlightSelectionMatches(options) {\n let ext = [defaultTheme, matchHighlighter];\n if (options)\n ext.push(highlightConfig.of(options));\n return ext;\n}\nconst matchDeco = /*@__PURE__*/Decoration.mark({ class: \"cm-selectionMatch\" });\nconst mainMatchDeco = /*@__PURE__*/Decoration.mark({ class: \"cm-selectionMatch cm-selectionMatch-main\" });\n// Whether the characters directly outside the given positions are non-word characters\nfunction insideWordBoundaries(check, state, from, to) {\n return (from == 0 || check(state.sliceDoc(from - 1, from)) != CharCategory.Word) &&\n (to == state.doc.length || check(state.sliceDoc(to, to + 1)) != CharCategory.Word);\n}\n// Whether the characters directly at the given positions are word characters\nfunction insideWord(check, state, from, to) {\n return check(state.sliceDoc(from, from + 1)) == CharCategory.Word\n && check(state.sliceDoc(to - 1, to)) == CharCategory.Word;\n}\nconst matchHighlighter = /*@__PURE__*/ViewPlugin.fromClass(class {\n constructor(view) {\n this.decorations = this.getDeco(view);\n }\n update(update) {\n if (update.selectionSet || update.docChanged || update.viewportChanged)\n this.decorations = this.getDeco(update.view);\n }\n getDeco(view) {\n let conf = view.state.facet(highlightConfig);\n let { state } = view, sel = state.selection;\n if (sel.ranges.length > 1)\n return Decoration.none;\n let range = sel.main, query, check = null;\n if (range.empty) {\n if (!conf.highlightWordAroundCursor)\n return Decoration.none;\n let word = state.wordAt(range.head);\n if (!word)\n return Decoration.none;\n check = state.charCategorizer(range.head);\n query = state.sliceDoc(word.from, word.to);\n }\n else {\n let len = range.to - range.from;\n if (len < conf.minSelectionLength || len > 200)\n return Decoration.none;\n if (conf.wholeWords) {\n query = state.sliceDoc(range.from, range.to); // TODO: allow and include leading/trailing space?\n check = state.charCategorizer(range.head);\n if (!(insideWordBoundaries(check, state, range.from, range.to)\n && insideWord(check, state, range.from, range.to)))\n return Decoration.none;\n }\n else {\n query = state.sliceDoc(range.from, range.to).trim();\n if (!query)\n return Decoration.none;\n }\n }\n let deco = [];\n for (let part of view.visibleRanges) {\n let cursor = new SearchCursor(state.doc, query, part.from, part.to);\n while (!cursor.next().done) {\n let { from, to } = cursor.value;\n if (!check || insideWordBoundaries(check, state, from, to)) {\n if (range.empty && from <= range.from && to >= range.to)\n deco.push(mainMatchDeco.range(from, to));\n else if (from >= range.to || to <= range.from)\n deco.push(matchDeco.range(from, to));\n if (deco.length > conf.maxMatches)\n return Decoration.none;\n }\n }\n }\n return Decoration.set(deco);\n }\n}, {\n decorations: v => v.decorations\n});\nconst defaultTheme = /*@__PURE__*/EditorView.baseTheme({\n \".cm-selectionMatch\": { backgroundColor: \"#99ff7780\" },\n \".cm-searchMatch .cm-selectionMatch\": { backgroundColor: \"transparent\" }\n});\n// Select the words around the cursors.\nconst selectWord = ({ state, dispatch }) => {\n let { selection } = state;\n let newSel = EditorSelection.create(selection.ranges.map(range => state.wordAt(range.head) || EditorSelection.cursor(range.head)), selection.mainIndex);\n if (newSel.eq(selection))\n return false;\n dispatch(state.update({ selection: newSel }));\n return true;\n};\n// Find next occurrence of query relative to last cursor. Wrap around\n// the document if there are no more matches.\nfunction findNextOccurrence(state, query) {\n let { main, ranges } = state.selection;\n let word = state.wordAt(main.head), fullWord = word && word.from == main.from && word.to == main.to;\n for (let cycled = false, cursor = new SearchCursor(state.doc, query, ranges[ranges.length - 1].to);;) {\n cursor.next();\n if (cursor.done) {\n if (cycled)\n return null;\n cursor = new SearchCursor(state.doc, query, 0, Math.max(0, ranges[ranges.length - 1].from - 1));\n cycled = true;\n }\n else {\n if (cycled && ranges.some(r => r.from == cursor.value.from))\n continue;\n if (fullWord) {\n let word = state.wordAt(cursor.value.from);\n if (!word || word.from != cursor.value.from || word.to != cursor.value.to)\n continue;\n }\n return cursor.value;\n }\n }\n}\n/**\nSelect next occurrence of the current selection. Expand selection\nto the surrounding word when the selection is empty.\n*/\nconst selectNextOccurrence = ({ state, dispatch }) => {\n let { ranges } = state.selection;\n if (ranges.some(sel => sel.from === sel.to))\n return selectWord({ state, dispatch });\n let searchedText = state.sliceDoc(ranges[0].from, ranges[0].to);\n if (state.selection.ranges.some(r => state.sliceDoc(r.from, r.to) != searchedText))\n return false;\n let range = findNextOccurrence(state, searchedText);\n if (!range)\n return false;\n dispatch(state.update({\n selection: state.selection.addRange(EditorSelection.range(range.from, range.to), false),\n effects: EditorView.scrollIntoView(range.to)\n }));\n return true;\n};\n\nconst searchConfigFacet = /*@__PURE__*/Facet.define({\n combine(configs) {\n return combineConfig(configs, {\n top: false,\n caseSensitive: false,\n literal: false,\n regexp: false,\n wholeWord: false,\n createPanel: view => new SearchPanel(view),\n scrollToMatch: range => EditorView.scrollIntoView(range)\n });\n }\n});\n/**\nAdd search state to the editor configuration, and optionally\nconfigure the search extension.\n([`openSearchPanel`](https://codemirror.net/6/docs/ref/#search.openSearchPanel) will automatically\nenable this if it isn't already on).\n*/\nfunction search(config) {\n return config ? [searchConfigFacet.of(config), searchExtensions] : searchExtensions;\n}\n/**\nA search query. Part of the editor's search state.\n*/\nclass SearchQuery {\n /**\n Create a query object.\n */\n constructor(config) {\n this.search = config.search;\n this.caseSensitive = !!config.caseSensitive;\n this.literal = !!config.literal;\n this.regexp = !!config.regexp;\n this.replace = config.replace || \"\";\n this.valid = !!this.search && (!this.regexp || validRegExp(this.search));\n this.unquoted = this.unquote(this.search);\n this.wholeWord = !!config.wholeWord;\n }\n /**\n @internal\n */\n unquote(text) {\n return this.literal ? text :\n text.replace(/\\\\([nrt\\\\])/g, (_, ch) => ch == \"n\" ? \"\\n\" : ch == \"r\" ? \"\\r\" : ch == \"t\" ? \"\\t\" : \"\\\\\");\n }\n /**\n Compare this query to another query.\n */\n eq(other) {\n return this.search == other.search && this.replace == other.replace &&\n this.caseSensitive == other.caseSensitive && this.regexp == other.regexp &&\n this.wholeWord == other.wholeWord;\n }\n /**\n @internal\n */\n create() {\n return this.regexp ? new RegExpQuery(this) : new StringQuery(this);\n }\n /**\n Get a search cursor for this query, searching through the given\n range in the given state.\n */\n getCursor(state, from = 0, to) {\n let st = state.doc ? state : EditorState.create({ doc: state });\n if (to == null)\n to = st.doc.length;\n return this.regexp ? regexpCursor(this, st, from, to) : stringCursor(this, st, from, to);\n }\n}\nclass QueryType {\n constructor(spec) {\n this.spec = spec;\n }\n}\nfunction stringCursor(spec, state, from, to) {\n return new SearchCursor(state.doc, spec.unquoted, from, to, spec.caseSensitive ? undefined : x => x.toLowerCase(), spec.wholeWord ? stringWordTest(state.doc, state.charCategorizer(state.selection.main.head)) : undefined);\n}\nfunction stringWordTest(doc, categorizer) {\n return (from, to, buf, bufPos) => {\n if (bufPos > from || bufPos + buf.length < to) {\n bufPos = Math.max(0, from - 2);\n buf = doc.sliceString(bufPos, Math.min(doc.length, to + 2));\n }\n return (categorizer(charBefore(buf, from - bufPos)) != CharCategory.Word ||\n categorizer(charAfter(buf, from - bufPos)) != CharCategory.Word) &&\n (categorizer(charAfter(buf, to - bufPos)) != CharCategory.Word ||\n categorizer(charBefore(buf, to - bufPos)) != CharCategory.Word);\n };\n}\nclass StringQuery extends QueryType {\n constructor(spec) {\n super(spec);\n }\n nextMatch(state, curFrom, curTo) {\n let cursor = stringCursor(this.spec, state, curTo, state.doc.length).nextOverlapping();\n if (cursor.done)\n cursor = stringCursor(this.spec, state, 0, curFrom).nextOverlapping();\n return cursor.done ? null : cursor.value;\n }\n // Searching in reverse is, rather than implementing an inverted search\n // cursor, done by scanning chunk after chunk forward.\n prevMatchInRange(state, from, to) {\n for (let pos = to;;) {\n let start = Math.max(from, pos - 10000 /* FindPrev.ChunkSize */ - this.spec.unquoted.length);\n let cursor = stringCursor(this.spec, state, start, pos), range = null;\n while (!cursor.nextOverlapping().done)\n range = cursor.value;\n if (range)\n return range;\n if (start == from)\n return null;\n pos -= 10000 /* FindPrev.ChunkSize */;\n }\n }\n prevMatch(state, curFrom, curTo) {\n return this.prevMatchInRange(state, 0, curFrom) ||\n this.prevMatchInRange(state, curTo, state.doc.length);\n }\n getReplacement(_result) { return this.spec.unquote(this.spec.replace); }\n matchAll(state, limit) {\n let cursor = stringCursor(this.spec, state, 0, state.doc.length), ranges = [];\n while (!cursor.next().done) {\n if (ranges.length >= limit)\n return null;\n ranges.push(cursor.value);\n }\n return ranges;\n }\n highlight(state, from, to, add) {\n let cursor = stringCursor(this.spec, state, Math.max(0, from - this.spec.unquoted.length), Math.min(to + this.spec.unquoted.length, state.doc.length));\n while (!cursor.next().done)\n add(cursor.value.from, cursor.value.to);\n }\n}\nfunction regexpCursor(spec, state, from, to) {\n return new RegExpCursor(state.doc, spec.search, {\n ignoreCase: !spec.caseSensitive,\n test: spec.wholeWord ? regexpWordTest(state.charCategorizer(state.selection.main.head)) : undefined\n }, from, to);\n}\nfunction charBefore(str, index) {\n return str.slice(findClusterBreak(str, index, false), index);\n}\nfunction charAfter(str, index) {\n return str.slice(index, findClusterBreak(str, index));\n}\nfunction regexpWordTest(categorizer) {\n return (_from, _to, match) => !match[0].length ||\n (categorizer(charBefore(match.input, match.index)) != CharCategory.Word ||\n categorizer(charAfter(match.input, match.index)) != CharCategory.Word) &&\n (categorizer(charAfter(match.input, match.index + match[0].length)) != CharCategory.Word ||\n categorizer(charBefore(match.input, match.index + match[0].length)) != CharCategory.Word);\n}\nclass RegExpQuery extends QueryType {\n nextMatch(state, curFrom, curTo) {\n let cursor = regexpCursor(this.spec, state, curTo, state.doc.length).next();\n if (cursor.done)\n cursor = regexpCursor(this.spec, state, 0, curFrom).next();\n return cursor.done ? null : cursor.value;\n }\n prevMatchInRange(state, from, to) {\n for (let size = 1;; size++) {\n let start = Math.max(from, to - size * 10000 /* FindPrev.ChunkSize */);\n let cursor = regexpCursor(this.spec, state, start, to), range = null;\n while (!cursor.next().done)\n range = cursor.value;\n if (range && (start == from || range.from > start + 10))\n return range;\n if (start == from)\n return null;\n }\n }\n prevMatch(state, curFrom, curTo) {\n return this.prevMatchInRange(state, 0, curFrom) ||\n this.prevMatchInRange(state, curTo, state.doc.length);\n }\n getReplacement(result) {\n return this.spec.unquote(this.spec.replace.replace(/\\$([$&\\d+])/g, (m, i) => i == \"$\" ? \"$\"\n : i == \"&\" ? result.match[0]\n : i != \"0\" && +i < result.match.length ? result.match[i]\n : m));\n }\n matchAll(state, limit) {\n let cursor = regexpCursor(this.spec, state, 0, state.doc.length), ranges = [];\n while (!cursor.next().done) {\n if (ranges.length >= limit)\n return null;\n ranges.push(cursor.value);\n }\n return ranges;\n }\n highlight(state, from, to, add) {\n let cursor = regexpCursor(this.spec, state, Math.max(0, from - 250 /* RegExp.HighlightMargin */), Math.min(to + 250 /* RegExp.HighlightMargin */, state.doc.length));\n while (!cursor.next().done)\n add(cursor.value.from, cursor.value.to);\n }\n}\n/**\nA state effect that updates the current search query. Note that\nthis only has an effect if the search state has been initialized\n(by including [`search`](https://codemirror.net/6/docs/ref/#search.search) in your configuration or\nby running [`openSearchPanel`](https://codemirror.net/6/docs/ref/#search.openSearchPanel) at least\nonce).\n*/\nconst setSearchQuery = /*@__PURE__*/StateEffect.define();\nconst togglePanel = /*@__PURE__*/StateEffect.define();\nconst searchState = /*@__PURE__*/StateField.define({\n create(state) {\n return new SearchState(defaultQuery(state).create(), null);\n },\n update(value, tr) {\n for (let effect of tr.effects) {\n if (effect.is(setSearchQuery))\n value = new SearchState(effect.value.create(), value.panel);\n else if (effect.is(togglePanel))\n value = new SearchState(value.query, effect.value ? createSearchPanel : null);\n }\n return value;\n },\n provide: f => showPanel.from(f, val => val.panel)\n});\n/**\nGet the current search query from an editor state.\n*/\nfunction getSearchQuery(state) {\n let curState = state.field(searchState, false);\n return curState ? curState.query.spec : defaultQuery(state);\n}\n/**\nQuery whether the search panel is open in the given editor state.\n*/\nfunction searchPanelOpen(state) {\n var _a;\n return ((_a = state.field(searchState, false)) === null || _a === void 0 ? void 0 : _a.panel) != null;\n}\nclass SearchState {\n constructor(query, panel) {\n this.query = query;\n this.panel = panel;\n }\n}\nconst matchMark = /*@__PURE__*/Decoration.mark({ class: \"cm-searchMatch\" }), selectedMatchMark = /*@__PURE__*/Decoration.mark({ class: \"cm-searchMatch cm-searchMatch-selected\" });\nconst searchHighlighter = /*@__PURE__*/ViewPlugin.fromClass(class {\n constructor(view) {\n this.view = view;\n this.decorations = this.highlight(view.state.field(searchState));\n }\n update(update) {\n let state = update.state.field(searchState);\n if (state != update.startState.field(searchState) || update.docChanged || update.selectionSet || update.viewportChanged)\n this.decorations = this.highlight(state);\n }\n highlight({ query, panel }) {\n if (!panel || !query.spec.valid)\n return Decoration.none;\n let { view } = this;\n let builder = new RangeSetBuilder();\n for (let i = 0, ranges = view.visibleRanges, l = ranges.length; i < l; i++) {\n let { from, to } = ranges[i];\n while (i < l - 1 && to > ranges[i + 1].from - 2 * 250 /* RegExp.HighlightMargin */)\n to = ranges[++i].to;\n query.highlight(view.state, from, to, (from, to) => {\n let selected = view.state.selection.ranges.some(r => r.from == from && r.to == to);\n builder.add(from, to, selected ? selectedMatchMark : matchMark);\n });\n }\n return builder.finish();\n }\n}, {\n decorations: v => v.decorations\n});\nfunction searchCommand(f) {\n return view => {\n let state = view.state.field(searchState, false);\n return state && state.query.spec.valid ? f(view, state) : openSearchPanel(view);\n };\n}\n/**\nOpen the search panel if it isn't already open, and move the\nselection to the first match after the current main selection.\nWill wrap around to the start of the document when it reaches the\nend.\n*/\nconst findNext = /*@__PURE__*/searchCommand((view, { query }) => {\n let { to } = view.state.selection.main;\n let next = query.nextMatch(view.state, to, to);\n if (!next)\n return false;\n let selection = EditorSelection.single(next.from, next.to);\n let config = view.state.facet(searchConfigFacet);\n view.dispatch({\n selection,\n effects: [announceMatch(view, next), config.scrollToMatch(selection.main, view)],\n userEvent: \"select.search\"\n });\n selectSearchInput(view);\n return true;\n});\n/**\nMove the selection to the previous instance of the search query,\nbefore the current main selection. Will wrap past the start\nof the document to start searching at the end again.\n*/\nconst findPrevious = /*@__PURE__*/searchCommand((view, { query }) => {\n let { state } = view, { from } = state.selection.main;\n let prev = query.prevMatch(state, from, from);\n if (!prev)\n return false;\n let selection = EditorSelection.single(prev.from, prev.to);\n let config = view.state.facet(searchConfigFacet);\n view.dispatch({\n selection,\n effects: [announceMatch(view, prev), config.scrollToMatch(selection.main, view)],\n userEvent: \"select.search\"\n });\n selectSearchInput(view);\n return true;\n});\n/**\nSelect all instances of the search query.\n*/\nconst selectMatches = /*@__PURE__*/searchCommand((view, { query }) => {\n let ranges = query.matchAll(view.state, 1000);\n if (!ranges || !ranges.length)\n return false;\n view.dispatch({\n selection: EditorSelection.create(ranges.map(r => EditorSelection.range(r.from, r.to))),\n userEvent: \"select.search.matches\"\n });\n return true;\n});\n/**\nSelect all instances of the currently selected text.\n*/\nconst selectSelectionMatches = ({ state, dispatch }) => {\n let sel = state.selection;\n if (sel.ranges.length > 1 || sel.main.empty)\n return false;\n let { from, to } = sel.main;\n let ranges = [], main = 0;\n for (let cur = new SearchCursor(state.doc, state.sliceDoc(from, to)); !cur.next().done;) {\n if (ranges.length > 1000)\n return false;\n if (cur.value.from == from)\n main = ranges.length;\n ranges.push(EditorSelection.range(cur.value.from, cur.value.to));\n }\n dispatch(state.update({\n selection: EditorSelection.create(ranges, main),\n userEvent: \"select.search.matches\"\n }));\n return true;\n};\n/**\nReplace the current match of the search query.\n*/\nconst replaceNext = /*@__PURE__*/searchCommand((view, { query }) => {\n let { state } = view, { from, to } = state.selection.main;\n if (state.readOnly)\n return false;\n let next = query.nextMatch(state, from, from);\n if (!next)\n return false;\n let changes = [], selection, replacement;\n let effects = [];\n if (next.from == from && next.to == to) {\n replacement = state.toText(query.getReplacement(next));\n changes.push({ from: next.from, to: next.to, insert: replacement });\n next = query.nextMatch(state, next.from, next.to);\n effects.push(EditorView.announce.of(state.phrase(\"replaced match on line $\", state.doc.lineAt(from).number) + \".\"));\n }\n if (next) {\n let off = changes.length == 0 || changes[0].from >= next.to ? 0 : next.to - next.from - replacement.length;\n selection = EditorSelection.single(next.from - off, next.to - off);\n effects.push(announceMatch(view, next));\n effects.push(state.facet(searchConfigFacet).scrollToMatch(selection.main, view));\n }\n view.dispatch({\n changes, selection, effects,\n userEvent: \"input.replace\"\n });\n return true;\n});\n/**\nReplace all instances of the search query with the given\nreplacement.\n*/\nconst replaceAll = /*@__PURE__*/searchCommand((view, { query }) => {\n if (view.state.readOnly)\n return false;\n let changes = query.matchAll(view.state, 1e9).map(match => {\n let { from, to } = match;\n return { from, to, insert: query.getReplacement(match) };\n });\n if (!changes.length)\n return false;\n let announceText = view.state.phrase(\"replaced $ matches\", changes.length) + \".\";\n view.dispatch({\n changes,\n effects: EditorView.announce.of(announceText),\n userEvent: \"input.replace.all\"\n });\n return true;\n});\nfunction createSearchPanel(view) {\n return view.state.facet(searchConfigFacet).createPanel(view);\n}\nfunction defaultQuery(state, fallback) {\n var _a, _b, _c, _d, _e;\n let sel = state.selection.main;\n let selText = sel.empty || sel.to > sel.from + 100 ? \"\" : state.sliceDoc(sel.from, sel.to);\n if (fallback && !selText)\n return fallback;\n let config = state.facet(searchConfigFacet);\n return new SearchQuery({\n search: ((_a = fallback === null || fallback === void 0 ? void 0 : fallback.literal) !== null && _a !== void 0 ? _a : config.literal) ? selText : selText.replace(/\\n/g, \"\\\\n\"),\n caseSensitive: (_b = fallback === null || fallback === void 0 ? void 0 : fallback.caseSensitive) !== null && _b !== void 0 ? _b : config.caseSensitive,\n literal: (_c = fallback === null || fallback === void 0 ? void 0 : fallback.literal) !== null && _c !== void 0 ? _c : config.literal,\n regexp: (_d = fallback === null || fallback === void 0 ? void 0 : fallback.regexp) !== null && _d !== void 0 ? _d : config.regexp,\n wholeWord: (_e = fallback === null || fallback === void 0 ? void 0 : fallback.wholeWord) !== null && _e !== void 0 ? _e : config.wholeWord\n });\n}\nfunction getSearchInput(view) {\n let panel = getPanel(view, createSearchPanel);\n return panel && panel.dom.querySelector(\"[main-field]\");\n}\nfunction selectSearchInput(view) {\n let input = getSearchInput(view);\n if (input && input == view.root.activeElement)\n input.select();\n}\n/**\nMake sure the search panel is open and focused.\n*/\nconst openSearchPanel = view => {\n let state = view.state.field(searchState, false);\n if (state && state.panel) {\n let searchInput = getSearchInput(view);\n if (searchInput && searchInput != view.root.activeElement) {\n let query = defaultQuery(view.state, state.query.spec);\n if (query.valid)\n view.dispatch({ effects: setSearchQuery.of(query) });\n searchInput.focus();\n searchInput.select();\n }\n }\n else {\n view.dispatch({ effects: [\n togglePanel.of(true),\n state ? setSearchQuery.of(defaultQuery(view.state, state.query.spec)) : StateEffect.appendConfig.of(searchExtensions)\n ] });\n }\n return true;\n};\n/**\nClose the search panel.\n*/\nconst closeSearchPanel = view => {\n let state = view.state.field(searchState, false);\n if (!state || !state.panel)\n return false;\n let panel = getPanel(view, createSearchPanel);\n if (panel && panel.dom.contains(view.root.activeElement))\n view.focus();\n view.dispatch({ effects: togglePanel.of(false) });\n return true;\n};\n/**\nDefault search-related key bindings.\n\n - Mod-f: [`openSearchPanel`](https://codemirror.net/6/docs/ref/#search.openSearchPanel)\n - F3, Mod-g: [`findNext`](https://codemirror.net/6/docs/ref/#search.findNext)\n - Shift-F3, Shift-Mod-g: [`findPrevious`](https://codemirror.net/6/docs/ref/#search.findPrevious)\n - Alt-g: [`gotoLine`](https://codemirror.net/6/docs/ref/#search.gotoLine)\n - Mod-d: [`selectNextOccurrence`](https://codemirror.net/6/docs/ref/#search.selectNextOccurrence)\n*/\nconst searchKeymap = [\n { key: \"Mod-f\", run: openSearchPanel, scope: \"editor search-panel\" },\n { key: \"F3\", run: findNext, shift: findPrevious, scope: \"editor search-panel\", preventDefault: true },\n { key: \"Mod-g\", run: findNext, shift: findPrevious, scope: \"editor search-panel\", preventDefault: true },\n { key: \"Escape\", run: closeSearchPanel, scope: \"editor search-panel\" },\n { key: \"Mod-Shift-l\", run: selectSelectionMatches },\n { key: \"Alt-g\", run: gotoLine },\n { key: \"Mod-d\", run: selectNextOccurrence, preventDefault: true },\n];\nclass SearchPanel {\n constructor(view) {\n this.view = view;\n let query = this.query = view.state.field(searchState).query.spec;\n this.commit = this.commit.bind(this);\n this.searchField = elt(\"input\", {\n value: query.search,\n placeholder: phrase(view, \"Find\"),\n \"aria-label\": phrase(view, \"Find\"),\n class: \"cm-textfield\",\n name: \"search\",\n form: \"\",\n \"main-field\": \"true\",\n onchange: this.commit,\n onkeyup: this.commit\n });\n this.replaceField = elt(\"input\", {\n value: query.replace,\n placeholder: phrase(view, \"Replace\"),\n \"aria-label\": phrase(view, \"Replace\"),\n class: \"cm-textfield\",\n name: \"replace\",\n form: \"\",\n onchange: this.commit,\n onkeyup: this.commit\n });\n this.caseField = elt(\"input\", {\n type: \"checkbox\",\n name: \"case\",\n form: \"\",\n checked: query.caseSensitive,\n onchange: this.commit\n });\n this.reField = elt(\"input\", {\n type: \"checkbox\",\n name: \"re\",\n form: \"\",\n checked: query.regexp,\n onchange: this.commit\n });\n this.wordField = elt(\"input\", {\n type: \"checkbox\",\n name: \"word\",\n form: \"\",\n checked: query.wholeWord,\n onchange: this.commit\n });\n function button(name, onclick, content) {\n return elt(\"button\", { class: \"cm-button\", name, onclick, type: \"button\" }, content);\n }\n this.dom = elt(\"div\", { onkeydown: (e) => this.keydown(e), class: \"cm-search\" }, [\n this.searchField,\n button(\"next\", () => findNext(view), [phrase(view, \"next\")]),\n button(\"prev\", () => findPrevious(view), [phrase(view, \"previous\")]),\n button(\"select\", () => selectMatches(view), [phrase(view, \"all\")]),\n elt(\"label\", null, [this.caseField, phrase(view, \"match case\")]),\n elt(\"label\", null, [this.reField, phrase(view, \"regexp\")]),\n elt(\"label\", null, [this.wordField, phrase(view, \"by word\")]),\n ...view.state.readOnly ? [] : [\n elt(\"br\"),\n this.replaceField,\n button(\"replace\", () => replaceNext(view), [phrase(view, \"replace\")]),\n button(\"replaceAll\", () => replaceAll(view), [phrase(view, \"replace all\")])\n ],\n elt(\"button\", {\n name: \"close\",\n onclick: () => closeSearchPanel(view),\n \"aria-label\": phrase(view, \"close\"),\n type: \"button\"\n }, [\"×\"])\n ]);\n }\n commit() {\n let query = new SearchQuery({\n search: this.searchField.value,\n caseSensitive: this.caseField.checked,\n regexp: this.reField.checked,\n wholeWord: this.wordField.checked,\n replace: this.replaceField.value,\n });\n if (!query.eq(this.query)) {\n this.query = query;\n this.view.dispatch({ effects: setSearchQuery.of(query) });\n }\n }\n keydown(e) {\n if (runScopeHandlers(this.view, e, \"search-panel\")) {\n e.preventDefault();\n }\n else if (e.keyCode == 13 && e.target == this.searchField) {\n e.preventDefault();\n (e.shiftKey ? findPrevious : findNext)(this.view);\n }\n else if (e.keyCode == 13 && e.target == this.replaceField) {\n e.preventDefault();\n replaceNext(this.view);\n }\n }\n update(update) {\n for (let tr of update.transactions)\n for (let effect of tr.effects) {\n if (effect.is(setSearchQuery) && !effect.value.eq(this.query))\n this.setQuery(effect.value);\n }\n }\n setQuery(query) {\n this.query = query;\n this.searchField.value = query.search;\n this.replaceField.value = query.replace;\n this.caseField.checked = query.caseSensitive;\n this.reField.checked = query.regexp;\n this.wordField.checked = query.wholeWord;\n }\n mount() {\n this.searchField.select();\n }\n get pos() { return 80; }\n get top() { return this.view.state.facet(searchConfigFacet).top; }\n}\nfunction phrase(view, phrase) { return view.state.phrase(phrase); }\nconst AnnounceMargin = 30;\nconst Break = /[\\s\\.,:;?!]/;\nfunction announceMatch(view, { from, to }) {\n let line = view.state.doc.lineAt(from), lineEnd = view.state.doc.lineAt(to).to;\n let start = Math.max(line.from, from - AnnounceMargin), end = Math.min(lineEnd, to + AnnounceMargin);\n let text = view.state.sliceDoc(start, end);\n if (start != line.from) {\n for (let i = 0; i < AnnounceMargin; i++)\n if (!Break.test(text[i + 1]) && Break.test(text[i])) {\n text = text.slice(i);\n break;\n }\n }\n if (end != lineEnd) {\n for (let i = text.length - 1; i > text.length - AnnounceMargin; i--)\n if (!Break.test(text[i - 1]) && Break.test(text[i])) {\n text = text.slice(0, i);\n break;\n }\n }\n return EditorView.announce.of(`${view.state.phrase(\"current match\")}. ${text} ${view.state.phrase(\"on line\")} ${line.number}.`);\n}\nconst baseTheme = /*@__PURE__*/EditorView.baseTheme({\n \".cm-panel.cm-search\": {\n padding: \"2px 6px 4px\",\n position: \"relative\",\n \"& [name=close]\": {\n position: \"absolute\",\n top: \"0\",\n right: \"4px\",\n backgroundColor: \"inherit\",\n border: \"none\",\n font: \"inherit\",\n padding: 0,\n margin: 0\n },\n \"& input, & button, & label\": {\n margin: \".2em .6em .2em 0\"\n },\n \"& input[type=checkbox]\": {\n marginRight: \".2em\"\n },\n \"& label\": {\n fontSize: \"80%\",\n whiteSpace: \"pre\"\n }\n },\n \"&light .cm-searchMatch\": { backgroundColor: \"#ffff0054\" },\n \"&dark .cm-searchMatch\": { backgroundColor: \"#00ffff8a\" },\n \"&light .cm-searchMatch-selected\": { backgroundColor: \"#ff6a0054\" },\n \"&dark .cm-searchMatch-selected\": { backgroundColor: \"#ff00ff8a\" }\n});\nconst searchExtensions = [\n searchState,\n /*@__PURE__*/Prec.low(searchHighlighter),\n baseTheme\n];\n\nexport { RegExpCursor, SearchCursor, SearchQuery, closeSearchPanel, findNext, findPrevious, getSearchQuery, gotoLine, highlightSelectionMatches, openSearchPanel, replaceAll, replaceNext, search, searchKeymap, searchPanelOpen, selectMatches, selectNextOccurrence, selectSelectionMatches, setSearchQuery };\n","import CodeMirror from './codemirror';\nimport { EditorSelection } from '@codemirror/state';\nimport { EditorView, keymap } from '@codemirror/view';\nimport { defaultKeymap, history, historyKeymap } from '@codemirror/commands';\nimport { searchKeymap } from '@codemirror/search';\n\n/**\n * @class CodeMirrorWikiEditor\n */\nexport default class CodeMirrorWikiEditor extends CodeMirror {\n\tconstructor( $textarea ) {\n\t\tsuper( $textarea );\n\t\tthis.realtimePreviewHandler = null;\n\t\tthis.useCodeMirror = mw.user.options.get( 'usecodemirror' ) > 0;\n\t\tthis.editRecoveryHandler = null;\n\t}\n\n\t/**\n\t * @inheritDoc\n\t */\n\tsetCodeMirrorPreference( prefValue ) {\n\t\tthis.useCodeMirror = prefValue; // Save state for function updateToolbarButton()\n\t\tsuper.setCodeMirrorPreference( prefValue );\n\t}\n\n\t/**\n\t * Replaces the default textarea with CodeMirror\n\t */\n\tenableCodeMirror() {\n\t\t// If CodeMirror is already loaded or wikEd gadget is enabled, abort. See T178348.\n\t\t// FIXME: Would be good to replace the wikEd check with something more generic.\n\t\tif ( this.view || mw.user.options.get( 'gadget-wikEd' ) > 0 ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst selectionStart = this.$textarea.prop( 'selectionStart' ),\n\t\t\tselectionEnd = this.$textarea.prop( 'selectionEnd' ),\n\t\t\tscrollTop = this.$textarea.scrollTop(),\n\t\t\thasFocus = this.$textarea.is( ':focus' );\n\n\t\t/*\n\t\t * Default configuration, which we may conditionally add to later.\n\t\t * @see https://codemirror.net/docs/ref/#state.Extension\n\t\t */\n\t\tconst extensions = [\n\t\t\t...this.defaultExtensions,\n\t\t\thistory(),\n\t\t\t// These are HTML attributes on the .cm-content element.\n\t\t\tEditorView.contentAttributes.of( {\n\t\t\t\tspellcheck: 'true',\n\t\t\t\t// T259347: Use accesskey of the original textbox\n\t\t\t\taccesskey: this.$textarea.attr( 'accesskey' )\n\t\t\t} ),\n\t\t\tEditorView.domEventHandlers( {\n\t\t\t\tblur: () => this.$textarea.triggerHandler( 'blur' ),\n\t\t\t\tfocus: () => this.$textarea.triggerHandler( 'focus' )\n\t\t\t} ),\n\t\t\tEditorView.updateListener.of( ( update ) => {\n\t\t\t\tif ( update.docChanged && typeof this.editRecoveryHandler === 'function' ) {\n\t\t\t\t\tthis.editRecoveryHandler();\n\t\t\t\t}\n\t\t\t} ),\n\t\t\tEditorView.lineWrapping,\n\t\t\tkeymap.of( [\n\t\t\t\t...defaultKeymap,\n\t\t\t\t...searchKeymap,\n\t\t\t\t...historyKeymap\n\t\t\t] )\n\t\t];\n\n\t\tmw.hook( 'editRecovery.loadEnd' ).add( ( data ) => {\n\t\t\tthis.editRecoveryHandler = data.fieldChangeHandler;\n\t\t} );\n\n\t\tthis.initialize( extensions );\n\n\t\t// Sync scroll position, selections, and focus state.\n\t\tthis.view.scrollDOM.scrollTop = scrollTop;\n\t\tthis.view.dispatch( {\n\t\t\tselection: EditorSelection.create( [\n\t\t\t\tEditorSelection.range( selectionStart, selectionEnd )\n\t\t\t] )\n\t\t} );\n\t\tif ( hasFocus ) {\n\t\t\tthis.view.focus();\n\t\t}\n\t}\n\n\t/**\n\t * Adds the CodeMirror button to WikiEditor\n\t */\n\taddCodeMirrorToWikiEditor() {\n\t\tconst context = this.$textarea.data( 'wikiEditor-context' );\n\t\tconst toolbar = context && context.modules && context.modules.toolbar;\n\n\t\t// Guard against something having removed WikiEditor (T271457)\n\t\tif ( !toolbar ) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.$textarea.wikiEditor(\n\t\t\t'addToToolbar',\n\t\t\t{\n\t\t\t\tsection: 'main',\n\t\t\t\tgroups: {\n\t\t\t\t\tcodemirror: {\n\t\t\t\t\t\ttools: {\n\t\t\t\t\t\t\tCodeMirror: {\n\t\t\t\t\t\t\t\tlabel: mw.msg( 'codemirror-toggle-label' ),\n\t\t\t\t\t\t\t\ttype: 'toggle',\n\t\t\t\t\t\t\t\toouiIcon: 'highlight',\n\t\t\t\t\t\t\t\taction: {\n\t\t\t\t\t\t\t\t\ttype: 'callback',\n\t\t\t\t\t\t\t\t\texecute: () => this.switchCodeMirror()\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\n\t\tconst $codeMirrorButton = toolbar.$toolbar.find( '.tool[rel=CodeMirror]' );\n\t\t$codeMirrorButton\n\t\t\t.attr( 'id', 'mw-editbutton-codemirror' );\n\n\t\tif ( this.useCodeMirror ) {\n\t\t\tthis.enableCodeMirror();\n\t\t}\n\t\tthis.updateToolbarButton();\n\n\t\tthis.logUsage( {\n\t\t\teditor: 'wikitext',\n\t\t\tenabled: this.useCodeMirror,\n\t\t\ttoggled: false,\n\t\t\t// eslint-disable-next-line no-jquery/no-global-selector,camelcase\n\t\t\tedit_start_ts_ms: parseInt( $( 'input[name=\"wpStarttime\"]' ).val(), 10 ) * 1000 || 0\n\t\t} );\n\t}\n\n\t/**\n\t * Updates CodeMirror button on the toolbar according to the current state (on/off)\n\t */\n\tupdateToolbarButton() {\n\t\t// eslint-disable-next-line no-jquery/no-global-selector\n\t\tconst $button = $( '#mw-editbutton-codemirror' );\n\t\t$button.toggleClass( 'mw-editbutton-codemirror-active', this.useCodeMirror );\n\n\t\t// WikiEditor2010 OOUI ToggleButtonWidget\n\t\tif ( $button.data( 'setActive' ) ) {\n\t\t\t$button.data( 'setActive' )( this.useCodeMirror );\n\t\t}\n\t}\n\n\t/**\n\t * Enables or disables CodeMirror\n\t */\n\tswitchCodeMirror() {\n\t\tif ( this.view ) {\n\t\t\tthis.setCodeMirrorPreference( false );\n\t\t\tconst scrollTop = this.view.scrollDOM.scrollTop;\n\t\t\tconst hasFocus = this.view.hasFocus;\n\t\t\tconst { from, to } = this.view.state.selection.ranges[ 0 ];\n\t\t\t$( this.view.dom ).textSelection( 'unregister' );\n\t\t\tthis.$textarea.textSelection( 'unregister' );\n\t\t\tthis.view.destroy();\n\t\t\tthis.view = null;\n\t\t\tthis.$textarea.show();\n\t\t\tif ( hasFocus ) {\n\t\t\t\tthis.$textarea.trigger( 'focus' );\n\t\t\t}\n\t\t\tthis.$textarea.prop( 'selectionStart', Math.min( from, to ) )\n\t\t\t\t.prop( 'selectionEnd', Math.max( to, from ) );\n\t\t\tthis.$textarea.scrollTop( scrollTop );\n\t\t\tmw.hook( 'ext.CodeMirror.switch' ).fire( false, this.$textbox1 );\n\t\t} else {\n\t\t\tthis.enableCodeMirror();\n\t\t\tthis.setCodeMirrorPreference( true );\n\t\t}\n\t\tthis.updateToolbarButton();\n\n\t\tthis.logUsage( {\n\t\t\teditor: 'wikitext',\n\t\t\tenabled: this.useCodeMirror,\n\t\t\ttoggled: true,\n\t\t\t// eslint-disable-next-line no-jquery/no-global-selector,camelcase\n\t\t\tedit_start_ts_ms: parseInt( $( 'input[name=\"wpStarttime\"]' ).val(), 10 ) * 1000 || 0\n\t\t} );\n\t}\n}\n","import CodeMirrorWikiEditor from './codemirror.wikieditor';\n\nif ( mw.loader.getState( 'ext.wikiEditor' ) ) {\n\tmw.hook( 'wikiEditor.toolbarReady' ).add( ( $textarea ) => {\n\t\tconst cmWE = new CodeMirrorWikiEditor( $textarea );\n\t\tcmWE.addCodeMirrorToWikiEditor();\n\t} );\n}\n"],"sourceRoot":""}