texlite 0.4.2 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (24) hide show
  1. package/dist/client/assets/BinaryModule-Aj1vLnwf-CqJDurFy.js +4 -0
  2. package/dist/client/assets/{GitDialog-D0pEkGqy.js → GitDialog-BkY6SFSC.js} +1 -1
  3. package/dist/client/assets/{HistoryDialog-DOJFrwFC.js → HistoryDialog-BwGvEITC.js} +1 -1
  4. package/dist/client/assets/LatexEditor-CbjDmoi7.js +59 -0
  5. package/dist/client/assets/{PdfPreview-CbIGckAy.js → PdfPreview-KsQWdlGK.js} +1 -1
  6. package/dist/client/assets/{ProjectNavigationDialogs-Db30cBn8.js → ProjectNavigationDialogs-DmHrXhIU.js} +1 -1
  7. package/dist/client/assets/{SystemMetricsDialog-BYkZHclO.js → SystemMetricsDialog-CAJqAWmA.js} +1 -1
  8. package/dist/client/assets/__vite-browser-external-BIHI7g3E.js +1 -0
  9. package/dist/client/assets/binary-DhyLq3C-.js +1 -0
  10. package/dist/client/assets/harper_wasm_bg-LWXDb7Ll.wasm +0 -0
  11. package/dist/client/assets/index-BDbf4yIq.js +3456 -0
  12. package/dist/client/assets/index-BLh_AgbG.js +17 -0
  13. package/dist/client/assets/index-bVUcyCfK.css +1 -0
  14. package/dist/client/assets/{plus-DEJ8OiaX.js → plus-CymJUapL.js} +1 -1
  15. package/dist/client/assets/spellCheck-BDmECWDN.js +5 -0
  16. package/dist/client/index.html +2 -2
  17. package/dist/server/compiler.js +49 -1
  18. package/dist/server/latexCompletion.js +30 -7
  19. package/dist/server/routes/compile.js +50 -2
  20. package/package.json +2 -3
  21. package/dist/client/assets/LatexEditor-B3d-UgFI.js +0 -61
  22. package/dist/client/assets/index-DmEQ69cM.css +0 -1
  23. package/dist/client/assets/index-Q1afBno7.js +0 -17
  24. package/dist/client/assets/spellCheck-ClNG2x_t.js +0 -49783
@@ -1,61 +0,0 @@
1
- import{u as li,r as re,j as vt}from"./react-CsO_xvbl.js";import{s as zr,E as se,V as lt,D as G,a as Bt,R as ci,P as Qr,S as ct,b as Se,f as fi,M as Jr,m as Er,i as ui,c as hi,d as di,e as pi,g as vi,h as gi,j as Or,k as Zr,l as ft,n as mi,o as yi,p as Ci,q as ki,r as wi,t as xi,u as Si,v as bi,w as Mi,x as Li,y as Xe,F as jt,A as Wt,z as Ai,W as qr,B as Ei,C as Rr,G as Tr,H as It,I as Oi,J as Ri,K as Ti,L as Ii,N as Ni,O as Bi,Q as Pi,T as Di,U as _i,X as Ki,Y as $i,Z as Fi,_ as Hi,$ as Vi,a0 as ji,a1 as Wi,a2 as Ui,a3 as zi,a4 as Qi,a5 as Ut,a6 as Ji,a7 as Zi,a8 as qi,a9 as Yi,aa as xe,ab as Xi,ac as Gi}from"./editor-DMLs-XWi.js";import{r as Ir,c as st,U as zt,a as Pt,b as Dt,d as Nr,m as eo,e as to,f as Nt,t as gt,g as mt,h as ro}from"./index-Q1afBno7.js";function no(s){var i=s.Pos;function l(e,t,r){if(t.line===r.line&&t.ch>=r.ch-1){var n=e.getLine(t.line),o=n.charCodeAt(t.ch);55296<=o&&o<=55551&&(r.ch+=1)}return{start:t,end:r}}var f=[{keys:"<Left>",type:"keyToKey",toKeys:"h"},{keys:"<Right>",type:"keyToKey",toKeys:"l"},{keys:"<Up>",type:"keyToKey",toKeys:"k"},{keys:"<Down>",type:"keyToKey",toKeys:"j"},{keys:"g<Up>",type:"keyToKey",toKeys:"gk"},{keys:"g<Down>",type:"keyToKey",toKeys:"gj"},{keys:"<Space>",type:"keyToKey",toKeys:"l"},{keys:"<BS>",type:"keyToKey",toKeys:"h"},{keys:"<Del>",type:"keyToKey",toKeys:"x"},{keys:"<C-Space>",type:"keyToKey",toKeys:"W"},{keys:"<C-BS>",type:"keyToKey",toKeys:"B"},{keys:"<S-Space>",type:"keyToKey",toKeys:"w"},{keys:"<S-BS>",type:"keyToKey",toKeys:"b"},{keys:"<C-n>",type:"keyToKey",toKeys:"j"},{keys:"<C-p>",type:"keyToKey",toKeys:"k"},{keys:"<C-[>",type:"keyToKey",toKeys:"<Esc>"},{keys:"<C-c>",type:"keyToKey",toKeys:"<Esc>"},{keys:"<C-[>",type:"keyToKey",toKeys:"<Esc>",context:"insert"},{keys:"<C-c>",type:"keyToKey",toKeys:"<Esc>",context:"insert"},{keys:"<C-Esc>",type:"keyToKey",toKeys:"<Esc>"},{keys:"<C-Esc>",type:"keyToKey",toKeys:"<Esc>",context:"insert"},{keys:"s",type:"keyToKey",toKeys:"cl",context:"normal"},{keys:"s",type:"keyToKey",toKeys:"c",context:"visual"},{keys:"S",type:"keyToKey",toKeys:"cc",context:"normal"},{keys:"S",type:"keyToKey",toKeys:"VdO",context:"visual"},{keys:"<Home>",type:"keyToKey",toKeys:"0"},{keys:"<End>",type:"keyToKey",toKeys:"$"},{keys:"<PageUp>",type:"keyToKey",toKeys:"<C-b>"},{keys:"<PageDown>",type:"keyToKey",toKeys:"<C-f>"},{keys:"<CR>",type:"keyToKey",toKeys:"j^",context:"normal"},{keys:"<Ins>",type:"keyToKey",toKeys:"i",context:"normal"},{keys:"<Ins>",type:"action",action:"toggleOverwrite",context:"insert"},{keys:"H",type:"motion",motion:"moveToTopLine",motionArgs:{linewise:!0,toJumplist:!0}},{keys:"M",type:"motion",motion:"moveToMiddleLine",motionArgs:{linewise:!0,toJumplist:!0}},{keys:"L",type:"motion",motion:"moveToBottomLine",motionArgs:{linewise:!0,toJumplist:!0}},{keys:"h",type:"motion",motion:"moveByCharacters",motionArgs:{forward:!1}},{keys:"l",type:"motion",motion:"moveByCharacters",motionArgs:{forward:!0}},{keys:"j",type:"motion",motion:"moveByLines",motionArgs:{forward:!0,linewise:!0}},{keys:"k",type:"motion",motion:"moveByLines",motionArgs:{forward:!1,linewise:!0}},{keys:"gj",type:"motion",motion:"moveByDisplayLines",motionArgs:{forward:!0}},{keys:"gk",type:"motion",motion:"moveByDisplayLines",motionArgs:{forward:!1}},{keys:"w",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!1}},{keys:"W",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!1,bigWord:!0}},{keys:"e",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!0,inclusive:!0}},{keys:"E",type:"motion",motion:"moveByWords",motionArgs:{forward:!0,wordEnd:!0,bigWord:!0,inclusive:!0}},{keys:"b",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!1}},{keys:"B",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!1,bigWord:!0}},{keys:"ge",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!0,inclusive:!0}},{keys:"gE",type:"motion",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!0,bigWord:!0,inclusive:!0}},{keys:"{",type:"motion",motion:"moveByParagraph",motionArgs:{forward:!1,toJumplist:!0}},{keys:"}",type:"motion",motion:"moveByParagraph",motionArgs:{forward:!0,toJumplist:!0}},{keys:"(",type:"motion",motion:"moveBySentence",motionArgs:{forward:!1}},{keys:")",type:"motion",motion:"moveBySentence",motionArgs:{forward:!0}},{keys:"<C-f>",type:"motion",motion:"moveByPage",motionArgs:{forward:!0}},{keys:"<C-b>",type:"motion",motion:"moveByPage",motionArgs:{forward:!1}},{keys:"<C-d>",type:"motion",motion:"moveByScroll",motionArgs:{forward:!0,explicitRepeat:!0}},{keys:"<C-u>",type:"motion",motion:"moveByScroll",motionArgs:{forward:!1,explicitRepeat:!0}},{keys:"gg",type:"motion",motion:"moveToLineOrEdgeOfDocument",motionArgs:{forward:!1,explicitRepeat:!0,linewise:!0,toJumplist:!0}},{keys:"G",type:"motion",motion:"moveToLineOrEdgeOfDocument",motionArgs:{forward:!0,explicitRepeat:!0,linewise:!0,toJumplist:!0}},{keys:"g$",type:"motion",motion:"moveToEndOfDisplayLine"},{keys:"g^",type:"motion",motion:"moveToStartOfDisplayLine"},{keys:"g0",type:"motion",motion:"moveToStartOfDisplayLine"},{keys:"0",type:"motion",motion:"moveToStartOfLine"},{keys:"^",type:"motion",motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:"+",type:"motion",motion:"moveByLines",motionArgs:{forward:!0,toFirstChar:!0}},{keys:"-",type:"motion",motion:"moveByLines",motionArgs:{forward:!1,toFirstChar:!0}},{keys:"_",type:"motion",motion:"moveByLines",motionArgs:{forward:!0,toFirstChar:!0,repeatOffset:-1}},{keys:"$",type:"motion",motion:"moveToEol",motionArgs:{inclusive:!0}},{keys:"%",type:"motion",motion:"moveToMatchedSymbol",motionArgs:{inclusive:!0,toJumplist:!0}},{keys:"f<character>",type:"motion",motion:"moveToCharacter",motionArgs:{forward:!0,inclusive:!0}},{keys:"F<character>",type:"motion",motion:"moveToCharacter",motionArgs:{forward:!1}},{keys:"t<character>",type:"motion",motion:"moveTillCharacter",motionArgs:{forward:!0,inclusive:!0}},{keys:"T<character>",type:"motion",motion:"moveTillCharacter",motionArgs:{forward:!1}},{keys:";",type:"motion",motion:"repeatLastCharacterSearch",motionArgs:{forward:!0}},{keys:",",type:"motion",motion:"repeatLastCharacterSearch",motionArgs:{forward:!1}},{keys:"'<register>",type:"motion",motion:"goToMark",motionArgs:{toJumplist:!0,linewise:!0}},{keys:"`<register>",type:"motion",motion:"goToMark",motionArgs:{toJumplist:!0}},{keys:"]`",type:"motion",motion:"jumpToMark",motionArgs:{forward:!0}},{keys:"[`",type:"motion",motion:"jumpToMark",motionArgs:{forward:!1}},{keys:"]'",type:"motion",motion:"jumpToMark",motionArgs:{forward:!0,linewise:!0}},{keys:"['",type:"motion",motion:"jumpToMark",motionArgs:{forward:!1,linewise:!0}},{keys:"]p",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!0,isEdit:!0,matchIndent:!0}},{keys:"[p",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!1,isEdit:!0,matchIndent:!0}},{keys:"]<character>",type:"motion",motion:"moveToSymbol",motionArgs:{forward:!0,toJumplist:!0}},{keys:"[<character>",type:"motion",motion:"moveToSymbol",motionArgs:{forward:!1,toJumplist:!0}},{keys:"|",type:"motion",motion:"moveToColumn"},{keys:"o",type:"motion",motion:"moveToOtherHighlightedEnd",context:"visual"},{keys:"O",type:"motion",motion:"moveToOtherHighlightedEnd",motionArgs:{sameLine:!0},context:"visual"},{keys:"d",type:"operator",operator:"delete"},{keys:"y",type:"operator",operator:"yank"},{keys:"c",type:"operator",operator:"change"},{keys:"=",type:"operator",operator:"indentAuto"},{keys:">",type:"operator",operator:"indent",operatorArgs:{indentRight:!0}},{keys:"<",type:"operator",operator:"indent",operatorArgs:{indentRight:!1}},{keys:"g~",type:"operator",operator:"changeCase"},{keys:"gu",type:"operator",operator:"changeCase",operatorArgs:{toLower:!0},isEdit:!0},{keys:"gU",type:"operator",operator:"changeCase",operatorArgs:{toLower:!1},isEdit:!0},{keys:"gc",type:"operator",operator:"toggleComment",isEdit:!0},{keys:"n",type:"motion",motion:"findNext",motionArgs:{forward:!0,toJumplist:!0}},{keys:"N",type:"motion",motion:"findNext",motionArgs:{forward:!1,toJumplist:!0}},{keys:"gn",type:"motion",motion:"findAndSelectNextInclusive",motionArgs:{forward:!0}},{keys:"gN",type:"motion",motion:"findAndSelectNextInclusive",motionArgs:{forward:!1}},{keys:"gq",type:"operator",operator:"hardWrap"},{keys:"gw",type:"operator",operator:"hardWrap",operatorArgs:{keepCursor:!0}},{keys:"g?",type:"operator",operator:"rot13"},{keys:"x",type:"operatorMotion",operator:"delete",motion:"moveByCharacters",motionArgs:{forward:!0},operatorMotionArgs:{visualLine:!1}},{keys:"X",type:"operatorMotion",operator:"delete",motion:"moveByCharacters",motionArgs:{forward:!1},operatorMotionArgs:{visualLine:!0}},{keys:"D",type:"operatorMotion",operator:"delete",motion:"moveToEol",motionArgs:{inclusive:!0},context:"normal"},{keys:"D",type:"operator",operator:"delete",operatorArgs:{linewise:!0},context:"visual"},{keys:"Y",type:"operatorMotion",operator:"yank",motion:"expandToLine",motionArgs:{linewise:!0},context:"normal"},{keys:"Y",type:"operator",operator:"yank",operatorArgs:{linewise:!0},context:"visual"},{keys:"C",type:"operatorMotion",operator:"change",motion:"moveToEol",motionArgs:{inclusive:!0},context:"normal"},{keys:"C",type:"operator",operator:"change",operatorArgs:{linewise:!0},context:"visual"},{keys:"~",type:"operatorMotion",operator:"changeCase",motion:"moveByCharacters",motionArgs:{forward:!0},operatorArgs:{shouldMoveCursor:!0},context:"normal"},{keys:"~",type:"operator",operator:"changeCase",context:"visual"},{keys:"<C-u>",type:"operatorMotion",operator:"delete",motion:"moveToStartOfLine",context:"insert"},{keys:"<C-w>",type:"operatorMotion",operator:"delete",motion:"moveByWords",motionArgs:{forward:!1,wordEnd:!1},context:"insert"},{keys:"<C-w>",type:"idle",context:"normal"},{keys:"<C-i>",type:"action",action:"jumpListWalk",actionArgs:{forward:!0}},{keys:"<C-o>",type:"action",action:"jumpListWalk",actionArgs:{forward:!1}},{keys:"<C-e>",type:"action",action:"scroll",actionArgs:{forward:!0,linewise:!0}},{keys:"<C-y>",type:"action",action:"scroll",actionArgs:{forward:!1,linewise:!0}},{keys:"a",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"charAfter"},context:"normal"},{keys:"A",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"eol"},context:"normal"},{keys:"A",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"endOfSelectedArea"},context:"visual"},{keys:"i",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"inplace"},context:"normal"},{keys:"gi",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"lastEdit"},context:"normal"},{keys:"I",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"firstNonBlank"},context:"normal"},{keys:"gI",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"bol"},context:"normal"},{keys:"I",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{insertAt:"startOfSelectedArea"},context:"visual"},{keys:"o",type:"action",action:"newLineAndEnterInsertMode",isEdit:!0,interlaceInsertRepeat:!0,actionArgs:{after:!0},context:"normal"},{keys:"O",type:"action",action:"newLineAndEnterInsertMode",isEdit:!0,interlaceInsertRepeat:!0,actionArgs:{after:!1},context:"normal"},{keys:"v",type:"action",action:"toggleVisualMode"},{keys:"V",type:"action",action:"toggleVisualMode",actionArgs:{linewise:!0}},{keys:"<C-v>",type:"action",action:"toggleVisualMode",actionArgs:{blockwise:!0}},{keys:"<C-q>",type:"action",action:"toggleVisualMode",actionArgs:{blockwise:!0}},{keys:"gv",type:"action",action:"reselectLastSelection"},{keys:"J",type:"action",action:"joinLines",isEdit:!0},{keys:"gJ",type:"action",action:"joinLines",actionArgs:{keepSpaces:!0},isEdit:!0},{keys:"p",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!0,isEdit:!0}},{keys:"P",type:"action",action:"paste",isEdit:!0,actionArgs:{after:!1,isEdit:!0}},{keys:"r<character>",type:"action",action:"replace",isEdit:!0},{keys:"@<register>",type:"action",action:"replayMacro"},{keys:"q<register>",type:"action",action:"enterMacroRecordMode"},{keys:"R",type:"action",action:"enterInsertMode",isEdit:!0,actionArgs:{replace:!0},context:"normal"},{keys:"R",type:"operator",operator:"change",operatorArgs:{linewise:!0,fullLine:!0},context:"visual",exitVisualBlock:!0},{keys:"u",type:"action",action:"undo",context:"normal"},{keys:"u",type:"operator",operator:"changeCase",operatorArgs:{toLower:!0},context:"visual",isEdit:!0},{keys:"U",type:"operator",operator:"changeCase",operatorArgs:{toLower:!1},context:"visual",isEdit:!0},{keys:"<C-r>",type:"action",action:"redo"},{keys:"m<register>",type:"action",action:"setMark"},{keys:'"<register>',type:"action",action:"setRegister"},{keys:"<C-r><register>",type:"action",action:"insertRegister",context:"insert",isEdit:!0},{keys:"<C-o>",type:"action",action:"oneNormalCommand",context:"insert"},{keys:"zz",type:"action",action:"scrollToCursor",actionArgs:{position:"center"}},{keys:"z.",type:"action",action:"scrollToCursor",actionArgs:{position:"center"},motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:"zt",type:"action",action:"scrollToCursor",actionArgs:{position:"top"}},{keys:"z<CR>",type:"action",action:"scrollToCursor",actionArgs:{position:"top"},motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:"zb",type:"action",action:"scrollToCursor",actionArgs:{position:"bottom"}},{keys:"z-",type:"action",action:"scrollToCursor",actionArgs:{position:"bottom"},motion:"moveToFirstNonWhiteSpaceCharacter"},{keys:".",type:"action",action:"repeatLastEdit"},{keys:"<C-a>",type:"action",action:"incrementNumberToken",isEdit:!0,actionArgs:{increase:!0,backtrack:!1}},{keys:"<C-x>",type:"action",action:"incrementNumberToken",isEdit:!0,actionArgs:{increase:!1,backtrack:!1}},{keys:"<C-t>",type:"action",action:"indent",actionArgs:{indentRight:!0},context:"insert"},{keys:"<C-d>",type:"action",action:"indent",actionArgs:{indentRight:!1},context:"insert"},{keys:"a<register>",type:"motion",motion:"textObjectManipulation"},{keys:"i<register>",type:"motion",motion:"textObjectManipulation",motionArgs:{textObjectInner:!0}},{keys:"/",type:"search",searchArgs:{forward:!0,querySrc:"prompt",toJumplist:!0}},{keys:"?",type:"search",searchArgs:{forward:!1,querySrc:"prompt",toJumplist:!0}},{keys:"*",type:"search",searchArgs:{forward:!0,querySrc:"wordUnderCursor",wholeWordOnly:!0,toJumplist:!0}},{keys:"#",type:"search",searchArgs:{forward:!1,querySrc:"wordUnderCursor",wholeWordOnly:!0,toJumplist:!0}},{keys:"g*",type:"search",searchArgs:{forward:!0,querySrc:"wordUnderCursor",toJumplist:!0}},{keys:"g#",type:"search",searchArgs:{forward:!1,querySrc:"wordUnderCursor",toJumplist:!0}},{keys:":",type:"ex"}],d=Object.create(null),g=f.length,w=[{name:"colorscheme",shortName:"colo"},{name:"map"},{name:"imap",shortName:"im"},{name:"nmap",shortName:"nm"},{name:"vmap",shortName:"vm"},{name:"omap",shortName:"om"},{name:"noremap",shortName:"no"},{name:"nnoremap",shortName:"nn"},{name:"vnoremap",shortName:"vn"},{name:"inoremap",shortName:"ino"},{name:"onoremap",shortName:"ono"},{name:"unmap"},{name:"mapclear",shortName:"mapc"},{name:"nmapclear",shortName:"nmapc"},{name:"vmapclear",shortName:"vmapc"},{name:"imapclear",shortName:"imapc"},{name:"omapclear",shortName:"omapc"},{name:"write",shortName:"w"},{name:"undo",shortName:"u"},{name:"redo",shortName:"red"},{name:"set",shortName:"se"},{name:"setlocal",shortName:"setl"},{name:"setglobal",shortName:"setg"},{name:"sort",shortName:"sor"},{name:"substitute",shortName:"s",possiblyAsync:!0},{name:"startinsert",shortName:"start"},{name:"nohlsearch",shortName:"noh"},{name:"yank",shortName:"y"},{name:"put",shortName:"pu"},{name:"delmarks",shortName:"delm"},{name:"marks",excludeFromCommandHistory:!0},{name:"registers",shortName:"reg",excludeFromCommandHistory:!0},{name:"vglobal",shortName:"v"},{name:"delete",shortName:"d"},{name:"join",shortName:"j"},{name:"normal",shortName:"norm"},{name:"global",shortName:"g"}],x=qt("");function S(e){e.setOption("disableInput",!0),e.setOption("showCursorWhenSelecting",!1),s.signal(e,"vim-mode-change",{mode:"normal"}),e.on("cursorActivity",xr),ee(e),s.on(e.getInputField(),"paste",R(e))}function B(e){e.setOption("disableInput",!1),e.off("cursorActivity",xr),s.off(e.getInputField(),"paste",R(e)),e.state.vim=null,ot&&clearTimeout(ot)}function R(e){var t=e.state.vim;return t.onPasteFn||(t.onPasteFn=function(){t.insertMode||(e.setCursor(oe(e.getCursor(),0,1)),We.enterInsertMode(e,{},t))}),t.onPasteFn}var A=/[\d]/,_=[s.isWordChar,function(e){return e&&!s.isWordChar(e)&&!/\s/.test(e)}],L=[function(e){return/\S/.test(e)}],O=["<",">"],P=["-",'"',".",":","_","/","+"],$=/^\w$/,K=/^[A-Z]$/;try{K=new RegExp("^[\\p{Lu}]$","u")}catch{}function D(e,t){return t>=e.firstLine()&&t<=e.lastLine()}function H(e){return/^[a-z]$/.test(e)}function J(e){return"()[]{}".indexOf(e)!=-1}function Z(e){return A.test(e)}function me(e){return K.test(e)}function le(e){return/^\s*$/.test(e)}function _e(e){return".?!".indexOf(e)!=-1}function Qe(e,t){for(var r=0;r<t.length;r++)if(t[r]==e)return!0;return!1}var be={};function Ke(e,t,r,n,o){if(t===void 0&&!o)throw Error("defaultValue is required unless callback is provided");if(r||(r="string"),be[e]={type:r,defaultValue:t,callback:o},n)for(var a=0;a<n.length;a++)be[n[a]]=be[e];t&&Te(e,t)}function Te(e,t,r,n){var o=be[e];n=n||{};var a=n.scope;if(!o)return new Error("Unknown option: "+e);if(o.type=="boolean"){if(t&&t!==!0)return new Error("Invalid argument: "+e+"="+t);t!==!1&&(t=!0)}o.callback?(a!=="local"&&o.callback(t,void 0),a!=="global"&&r&&o.callback(t,r)):(a!=="local"&&(o.value=o.type=="boolean"?!!t:t),a!=="global"&&r&&(r.state.vim.options[e]={value:t}))}function pe(e,t,r){var n=be[e];r=r||{};var o=r.scope;if(!n)return new Error("Unknown option: "+e);if(n.callback){let a=t&&n.callback(void 0,t);return o!=="global"&&a!==void 0?a:o!=="local"?n.callback():void 0}else return(o!=="global"&&t&&t.state.vim.options[e]||o!=="local"&&n||{}).value}Ke("filetype",void 0,"string",["ft"],function(e,t){if(t!==void 0)if(e===void 0){let r=t.getOption("mode");return r=="null"?"":r}else{let r=e==""?"null":e;t.setOption("mode",r)}}),Ke("textwidth",80,"number",["tw"],function(e,t){if(t!==void 0)if(e===void 0){var r=t.getOption("textwidth");return r}else{var n=Math.round(e);n>1&&t.setOption("textwidth",n)}});var et=function(){var e=100,t=-1,r=0,n=0,o=new Array(e);function a(h,p,v){var y=t%e,C=o[y];function k(b){var E=++t%e,N=o[E];N&&N.clear(),o[E]=h.setBookmark(b)}if(C){var m=C.find();m&&!Le(m,p)&&k(p)}else k(p);k(v),r=t,n=t-e+1,n<0&&(n=0)}function c(h,p){t+=p,t>r?t=r:t<n&&(t=n);var v=o[(e+t)%e];if(v&&!v.find()){var y=p>0?1:-1,C,k=h.getCursor();do if(t+=y,v=o[(e+t)%e],v&&(C=v.find())&&!Le(k,C))break;while(t<r&&t>n)}return v}function u(h,p){var v=t,y=c(h,p);return t=v,y&&y.find()}return{cachedCursor:void 0,add:a,find:u,move:c}},tt=function(e){return e?{changes:e.changes,expectCursorActivityForChange:e.expectCursorActivityForChange}:{changes:[],expectCursorActivityForChange:!1}};class j{constructor(){this.latestRegister=void 0,this.isPlaying=!1,this.isRecording=!1,this.replaySearchQueries=[],this.onRecordingDone=void 0,this.lastInsertModeChanges=tt()}exitMacroRecordMode(){var t=M.macroModeState;t.onRecordingDone&&t.onRecordingDone(),t.onRecordingDone=void 0,t.isRecording=!1}enterMacroRecordMode(t,r){var n=M.registerController.getRegister(r);if(n){if(n.clear(),this.latestRegister=r,t.openDialog){var o=Oe("span",{class:"cm-vim-message"},"recording @"+r);this.onRecordingDone=t.openDialog(o,function(){},{bottom:!0})}this.isRecording=!0}}}function ee(e){return e.state.vim||(e.state.vim={inputState:new Yt,lastEditInputState:void 0,lastEditActionCommand:void 0,lastHPos:-1,lastHSPos:-1,lastMotion:null,marks:{},insertMode:!1,insertModeReturn:!1,insertModeRepeat:void 0,visualMode:!1,visualLine:!1,visualBlock:!1,lastSelection:null,lastPastedText:void 0,sel:{anchor:new i(0,0),head:new i(0,0)},options:{},expectLiteralNext:!1,status:""}),e.state.vim}var M;function ne(){M={searchQuery:null,searchIsReversed:!1,lastSubstituteReplacePart:void 0,jumpList:et(),macroModeState:new j,lastCharacterSearch:{increment:0,forward:!0,selectedCharacter:""},registerController:new yn({}),searchHistoryController:new Xt,exCommandHistoryController:new Xt};for(var e in be){var t=be[e];t.value=t.defaultValue}}class q{constructor(t,r){this.keyName=t,this.key=r.key,this.ctrlKey=r.ctrlKey,this.altKey=r.altKey,this.metaKey=r.metaKey,this.shiftKey=r.shiftKey}}var Me,ke={enterVimMode:S,leaveVimMode:B,buildKeyMap:function(){},getRegisterController:function(){return M.registerController},resetVimGlobalState_:ne,getVimGlobalState_:function(){return M},maybeInitVimState_:ee,suppressErrorLogging:!1,InsertModeKey:q,map:function(e,t,r){ye.map(e,t,r)},unmap:function(e,t){return ye.unmap(e,t)},noremap:function(e,t,r){ye.map(e,t,r,!0)},mapclear:function(e){var t=f.length,r=g,n=f.slice(0,t-r);if(f=f.slice(t-r),e)for(var o=n.length-1;o>=0;o--){var a=n[o];if(e!==a.context)if(a.context)this._mapCommand(a);else{var c=["normal","insert","visual"];for(var u in c)if(c[u]!==e){var h=Object.assign({},a);h.context=c[u],this._mapCommand(h)}}}},langmap:Zt,vimKeyFromEvent:nt,setOption:Te,getOption:pe,defineOption:Ke,defineEx:function(e,t,r){if(!t)t=e;else if(e.indexOf(t)!==0)throw new Error('(Vim.defineEx) "'+t+'" is not a prefix of "'+e+'", command not registered');kr[e]=r,ye.commandMap_[t]={name:e,shortName:t,type:"api"}},handleKey:function(e,t,r){var n=this.findKey(e,t,r);if(typeof n=="function")return n()},multiSelectHandleKey:si,findKey:function(e,t,r){var n=ee(e),o=e;function a(){var v=M.macroModeState;if(v.isRecording){if(t=="q")return v.exitMacroRecordMode(),ce(o),!0;r!="mapping"&&ii(v,t)}}function c(){if(t=="<Esc>"){if(n.visualMode)Be(o);else if(n.insertMode)He(o);else return;return ce(o),!0}}function u(){if(c())return!0;n.inputState.keyBuffer.push(t);var v=n.inputState.keyBuffer.join(""),y=t.length==1,C=je.matchCommand(v,f,n.inputState,"insert"),k=n.inputState.changeQueue;if(C.type=="none")return ce(o),!1;if(C.type=="partial"){if(C.expectLiteralNext&&(n.expectLiteralNext=!0),Me&&window.clearTimeout(Me),Me=y&&window.setTimeout(function(){n.insertMode&&n.inputState.keyBuffer.length&&ce(o)},pe("insertModeEscKeysTimeout")),y){var m=o.listSelections();(!k||k.removed.length!=m.length)&&(k=n.inputState.changeQueue=new gn),k.inserted+=t;for(var b=0;b<m.length;b++){var E=ge(m[b].anchor,m[b].head),N=Fe(m[b].anchor,m[b].head),T=o.getRange(E,o.state.overwrite?oe(N,0,1):N);k.removed[b]=(k.removed[b]||"")+T}}return!y}else C.type=="full"&&(n.inputState.keyBuffer.length=0);if(n.expectLiteralNext=!1,Me&&window.clearTimeout(Me),C.command&&k){for(var m=o.listSelections(),b=0;b<m.length;b++){var I=m[b].head;o.replaceRange(k.removed[b]||"",oe(I,0,-k.inserted.length),I,"+input")}M.macroModeState.lastInsertModeChanges.changes.pop()}return C.command||ce(o),C.command}function h(){if(a()||c())return!0;n.inputState.keyBuffer.push(t);var v=n.inputState.keyBuffer.join("");if(/^[1-9]\d*$/.test(v))return!0;var y=/^(\d*)(.*)$/.exec(v);if(!y)return ce(o),!1;var C=n.visualMode?"visual":"normal",k=y[2]||y[1];n.inputState.operatorShortcut&&n.inputState.operatorShortcut.slice(-1)==k&&(k=n.inputState.operatorShortcut);var m=je.matchCommand(k,f,n.inputState,C);return m.type=="none"?(ce(o),!1):m.type=="partial"?(m.expectLiteralNext&&(n.expectLiteralNext=!0),!0):m.type=="clear"?(ce(o),!0):(n.expectLiteralNext=!1,n.inputState.keyBuffer.length=0,y=/^(\d*)(.*)$/.exec(v),y&&y[1]&&y[1]!="0"&&n.inputState.pushRepeatDigit(y[1]),m.command)}var p=n.insertMode?u():h();if(p===!1)return!n.insertMode&&(t.length===1||s.isMac&&/<A-.>/.test(t))?function(){return!0}:void 0;if(p===!0)return function(){return!0};if(p)return function(){return o.operation(function(){o.curOp.isVimOp=!0;try{if(typeof p!="object")return;p.type=="keyToKey"?rt(o,p.toKeys,p):je.processCommand(o,n,p)}catch(v){throw o.state.vim=void 0,ee(o),ke.suppressErrorLogging||console.log(v),v}return!0})}},handleEx:function(e,t){ye.processCommand(e,t)},defineMotion:Cn,defineAction:wn,defineOperator:kn,mapCommand:ri,_mapCommand:Et,defineRegister:mn,exitVisualMode:Be,exitInsertMode:He},Je=[],ut=!1,ie;function pn(e){if(!ie)throw new Error("No prompt to send key to");if(e[0]=="<"){var t=e.toLowerCase().slice(1,-1),r=t.split("-");if(t=r.pop()||"",t=="lt")e="<";else if(t=="space")e=" ";else if(t=="cr")e=`
2
- `;else if(Ze[t]){var n=ie.value||"",o={key:Ze[t],target:{value:n,selectionEnd:n.length,selectionStart:n.length}};ie.onKeyDown&&ie.onKeyDown(o,ie.value,c),ie&&ie.onKeyUp&&ie.onKeyUp(o,ie.value,c);return}}if(e==`
3
- `){var a=ie;ie=null,a.onClose&&a.onClose(a.value)}else ie.value=(ie.value||"")+e;function c(u){ie&&(typeof u=="string"?ie.value=u:ie=null)}}function rt(e,t,r){var n=ut;if(r){if(Je.indexOf(r)!=-1)return;Je.push(r),ut=r.noremap!=!1}try{for(var o=ee(e),a=/<(?:[CSMA]-)*\w+>|./gi,c;c=a.exec(t);){var u=c[0],h=o.insertMode;if(ie){pn(u);continue}var p=ke.handleKey(e,u,"mapping");if(!p&&h&&o.insertMode){if(u[0]=="<"){var v=u.toLowerCase().slice(1,-1),y=v.split("-");if(v=y.pop()||"",v=="lt")u="<";else if(v=="space")u=" ";else if(v=="cr")u=`
4
- `;else if(Ze.hasOwnProperty(v)){u=Ze[v],Lr(e,u);continue}else u=u[0],a.lastIndex=c.index+1}e.replaceSelection(u)}}}finally{if(Je.pop(),ut=Je.length?n:!1,!Je.length&&ie){var C=ie;ie=null,dt(e,C)}}}var kt={Return:"CR",Backspace:"BS",Delete:"Del",Escape:"Esc",Insert:"Ins",ArrowLeft:"Left",ArrowRight:"Right",ArrowUp:"Up",ArrowDown:"Down",Enter:"CR"," ":"Space"},vn={Shift:1,Alt:1,Command:1,Control:1,CapsLock:1,AltGraph:1,Dead:1,Unidentified:1},Ze={};"Left|Right|Up|Down|End|Home".split("|").concat(Object.keys(kt)).forEach(function(e){Ze[(kt[e]||"").toLowerCase()]=Ze[e.toLowerCase()]=e});function nt(e,t){var r=e.key;if(!vn[r]){r.length>1&&r[0]=="n"&&(r=r.replace("Numpad","")),r=kt[r]||r;var n="";if(e.ctrlKey&&(n+="C-"),e.altKey&&(n+="A-"),e.metaKey&&(n+="M-"),s.isMac&&n=="A-"&&r.length==1&&(n=n.slice(2)),(n||r.length>1)&&e.shiftKey&&(n+="S-"),t&&!t.expectLiteralNext&&r.length==1){if(x.keymap&&r in x.keymap)(x.remapCtrl!=!1||!n)&&(r=x.keymap[r]);else if(r.charCodeAt(0)>128&&!d[r]){var o=e.code?.slice(-1)||"";e.shiftKey||(o=o.toLowerCase()),o&&(r=o,!n&&e.altKey&&(n="A-"))}}return n+=r,n.length>1&&(n="<"+n+">"),n}}function Zt(e,t){x.string!==e&&(x=qt(e)),x.remapCtrl=t}function qt(e){let t={};if(!e)return{keymap:t,string:""};function r(n){return n.split(/\\?(.)/).filter(Boolean)}return e.split(/((?:[^\\,]|\\.)+),/).map(n=>{if(!n)return;const o=n.split(/((?:[^\\;]|\\.)+);/);if(o.length==3){const a=r(o[1]),c=r(o[2]);if(a.length!==c.length)return;for(let u=0;u<a.length;++u)t[a[u]]=c[u]}else if(o.length==1){const a=r(n);if(a.length%2!==0)return;for(let c=0;c<a.length;c+=2)t[a[c]]=a[c+1]}}),{keymap:t,string:e}}Ke("langmap",void 0,"string",["lmap"],function(e,t){if(e===void 0)return x.string;Zt(e)});class Yt{constructor(){this.prefixRepeat=[],this.motionRepeat=[],this.operator=null,this.operatorArgs=null,this.motion=null,this.motionArgs=null,this.keyBuffer=[],this.registerName=void 0,this.changeQueue=null}pushRepeatDigit(t){this.operator?this.motionRepeat=this.motionRepeat.concat(t):this.prefixRepeat=this.prefixRepeat.concat(t)}getRepeat(){var t=0;return(this.prefixRepeat.length>0||this.motionRepeat.length>0)&&(t=1,this.prefixRepeat.length>0&&(t*=parseInt(this.prefixRepeat.join(""),10)),this.motionRepeat.length>0&&(t*=parseInt(this.motionRepeat.join(""),10))),t}}function ce(e,t){e.state.vim.inputState=new Yt,e.state.vim.expectLiteralNext=!1,s.signal(e,"vim-command-done",t)}function gn(){this.removed=[],this.inserted=""}class Ie{constructor(t,r,n){this.clear(),this.keyBuffer=[t||""],this.insertModeChanges=[],this.searchQueries=[],this.linewise=!!r,this.blockwise=!!n}setText(t,r,n){this.keyBuffer=[t||""],this.linewise=!!r,this.blockwise=!!n}pushText(t,r){r&&(this.linewise||this.keyBuffer.push(`
5
- `),this.linewise=!0),this.keyBuffer.push(t)}pushInsertModeChanges(t){this.insertModeChanges.push(tt(t))}pushSearchQuery(t){this.searchQueries.push(t)}clear(){this.keyBuffer=[],this.insertModeChanges=[],this.searchQueries=[],this.linewise=!1}toString(){return this.keyBuffer.join("")}}function mn(e,t){var r=M.registerController.registers;if(!e||e.length!=1)throw Error("Register name must be 1 character");if(r[e])throw Error("Register already defined "+e);r[e]=t,P.push(e)}class yn{constructor(t){this.registers=t,this.unnamedRegister=t['"']=new Ie,t["."]=new Ie,t[":"]=new Ie,t["/"]=new Ie,t["+"]=new Ie}pushText(t,r,n,o,a){if(t!=="_"){o&&n.charAt(n.length-1)!==`
6
- `&&(n+=`
7
- `);var c=this.isValidRegister(t)?this.getRegister(t):null;if(!c||!t){switch(r){case"yank":this.registers[0]=new Ie(n,o,a);break;case"delete":case"change":n.indexOf(`
8
- `)==-1?this.registers["-"]=new Ie(n,o):(this.shiftNumericRegisters_(),this.registers[1]=new Ie(n,o));break}this.unnamedRegister.setText(n,o,a);return}var u=me(t);u?c.pushText(n,o):c.setText(n,o,a),t==="+"&&navigator.clipboard.writeText(n),this.unnamedRegister.setText(c.toString(),o)}}getRegister(t){return this.isValidRegister(t)?(t=t.toLowerCase(),this.registers[t]||(this.registers[t]=new Ie),this.registers[t]):this.unnamedRegister}isValidRegister(t){return t&&(Qe(t,P)||$.test(t))}shiftNumericRegisters_(){for(var t=9;t>=2;t--)this.registers[t]=this.getRegister(""+(t-1))}}class Xt{constructor(){this.historyBuffer=[],this.iterator=0,this.initialPrefix=null}nextMatch(t,r){var n=this.historyBuffer,o=r?-1:1;this.initialPrefix===null&&(this.initialPrefix=t);for(var a=this.iterator+o;r?a>=0:a<n.length;a+=o)for(var c=n[a],u=0;u<=c.length;u++)if(this.initialPrefix==c.substring(0,u))return this.iterator=a,c;if(a>=n.length)return this.iterator=n.length,this.initialPrefix;if(a<0)return t}pushInput(t){var r=this.historyBuffer.indexOf(t);r>-1&&this.historyBuffer.splice(r,1),t.length&&this.historyBuffer.push(t)}reset(){this.initialPrefix=null,this.iterator=this.historyBuffer.length}}var je={matchCommand:function(e,t,r,n){var o=xn(e,t,n,r),a=o.full[0];if(!a)return o.partial.length?{type:"partial",expectLiteralNext:o.partial.length==1&&o.partial[0].keys.slice(-11)=="<character>"}:{type:"none"};if(a.keys.slice(-11)=="<character>"||a.keys.slice(-10)=="<register>"){var c=bn(e);if(!c||c.length>1)return{type:"clear"};r.selectedCharacter=c}return{type:"full",command:a}},processCommand:function(e,t,r){switch(t.inputState.repeatOverride=r.repeatOverride,r.type){case"motion":this.processMotion(e,t,r);break;case"operator":this.processOperator(e,t,r);break;case"operatorMotion":this.processOperatorMotion(e,t,r);break;case"action":this.processAction(e,t,r);break;case"search":this.processSearch(e,t,r);break;case"ex":case"keyToEx":this.processEx(e,t,r);break}},processMotion:function(e,t,r){t.inputState.motion=r.motion,t.inputState.motionArgs=ht(r.motionArgs),this.evalInput(e,t)},processOperator:function(e,t,r){var n=t.inputState;if(n.operator)if(n.operator==r.operator){n.motion="expandToLine",n.motionArgs={linewise:!0,repeat:1},this.evalInput(e,t);return}else ce(e);n.operator=r.operator,n.operatorArgs=ht(r.operatorArgs),r.keys.length>1&&(n.operatorShortcut=r.keys),r.exitVisualBlock&&(t.visualBlock=!1,qe(e)),t.visualMode&&this.evalInput(e,t)},processOperatorMotion:function(e,t,r){var n=t.visualMode,o=ht(r.operatorMotionArgs);o&&n&&o.visualLine&&(t.visualLine=!0),this.processOperator(e,t,r),n||this.processMotion(e,t,r)},processAction:function(e,t,r){var n=t.inputState,o=n.getRepeat(),a=!!o,c=ht(r.actionArgs)||{repeat:1};n.selectedCharacter&&(c.selectedCharacter=n.selectedCharacter),r.operator&&this.processOperator(e,t,r),r.motion&&this.processMotion(e,t,r),(r.motion||r.operator)&&this.evalInput(e,t),c.repeat=o||1,c.repeatIsExplicit=a,c.registerName=n.registerName,ce(e),t.lastMotion=null,r.isEdit&&this.recordLastEdit(t,n,r),We[r.action](e,c,t)},processSearch:function(e,t,r){if(!e.getSearchCursor)return;var n=r.searchArgs.forward,o=r.searchArgs.wholeWordOnly;Ee(e).setReversed(!n);var a=n?"/":"?",c=Ee(e).getQuery(),u=e.getScrollInfo(),h="";function p(T,I,F){M.searchHistoryController.pushInput(T),M.searchHistoryController.reset();try{it(e,T,I,F)}catch{Q(e,"Invalid regex: "+T),ce(e);return}je.processMotion(e,t,{keys:"",type:"motion",motion:"findNext",motionArgs:{forward:!0,toJumplist:r.searchArgs.toJumplist}})}function v(T){e.scrollTo(u.left,u.top),p(T,!0,!0);var I=M.macroModeState;I.isRecording&&ai(I,T)}function y(){return pe("pcre")?"(JavaScript regexp: set pcre)":"(Vim regexp: set nopcre)"}function C(T,I,F){var W=nt(T),ae,X;W=="<Up>"||W=="<Down>"?(ae=W=="<Up>",X=T.target?T.target.selectionEnd:0,I=M.searchHistoryController.nextMatch(I,ae)||"",F(I),X&&T.target&&(T.target.selectionEnd=T.target.selectionStart=Math.min(X,T.target.value.length))):W&&W!="<Left>"&&W!="<Right>"&&M.searchHistoryController.reset(),h=I,k()}function k(){var T;try{T=it(e,h,!0,!0)}catch{}T?e.scrollIntoView(yr(e,!n,T),30):(Ye(e),e.scrollTo(u.left,u.top))}function m(T,I,F){var W=nt(T);W=="<Esc>"||W=="<C-c>"||W=="<C-[>"||W=="<BS>"&&I==""?(M.searchHistoryController.pushInput(I),M.searchHistoryController.reset(),it(e,c?.source||""),Ye(e),e.scrollTo(u.left,u.top),s.e_stop(T),ce(e),F(),e.focus()):W=="<Up>"||W=="<Down>"?s.e_stop(T):W=="<C-u>"&&(s.e_stop(T),F(""))}switch(r.searchArgs.querySrc){case"prompt":var b=M.macroModeState;if(b.isPlaying){let I=b.replaySearchQueries.shift();p(I||"",!0,!1)}else dt(e,{onClose:v,prefix:a,desc:Oe("span",{$cursor:"pointer",onmousedown:function(I){I.preventDefault(),Te("pcre",!pe("pcre")),this.textContent=y(),k()}},y()),onKeyUp:C,onKeyDown:m});break;case"wordUnderCursor":var E=bt(e,{noSymbol:!0}),N=!0;if(E||(E=bt(e,{noSymbol:!1}),N=!1),!E){Q(e,"No word under cursor"),ce(e);return}let T=e.getLine(E.start.line).substring(E.start.ch,E.end.ch);N&&o?T="\\b"+T+"\\b":T=Mn(T),M.jumpList.cachedCursor=e.getCursor(),e.setCursor(E.start),p(T,!0,!1);break}},processEx:function(e,t,r){function n(h){M.exCommandHistoryController.pushInput(h),M.exCommandHistoryController.reset(),ye.processCommand(e,h),e.state.vim&&ce(e),Ye(e)}function o(h,p,v){var y=nt(h),C,k;(y=="<Esc>"||y=="<C-c>"||y=="<C-[>"||y=="<BS>"&&p=="")&&(M.exCommandHistoryController.pushInput(p),M.exCommandHistoryController.reset(),s.e_stop(h),ce(e),Ye(e),v(),e.focus()),y=="<Up>"||y=="<Down>"?(s.e_stop(h),C=y=="<Up>",k=h.target?h.target.selectionEnd:0,p=M.exCommandHistoryController.nextMatch(p,C)||"",v(p),k&&h.target&&(h.target.selectionEnd=h.target.selectionStart=Math.min(k,h.target.value.length))):y=="<C-u>"?(s.e_stop(h),v("")):y&&y!="<Left>"&&y!="<Right>"&&M.exCommandHistoryController.reset()}function a(h,p){var v=new s.StringStream(p),y={};try{if(ye.parseInput_(e,v,y),y.commandName!="s"){Ye(e);return}var C=ye.matchCommand_(y.commandName);if(!C||(ye.parseCommandArgs_(v,y,C),!y.argString))return;var k=mr(y.argString.slice(1),!0,!0);k&&Lt(e,k)}catch{}}if(r.type=="keyToEx")ye.processCommand(e,r.exArgs.input);else{var c={onClose:n,onKeyDown:o,onKeyUp:a,prefix:":"};if(t.visualMode)c.value="'<,'>",c.selectValueOnOpen=!1;else{var u=t.inputState.getRepeat();u>1&&(c.value=".,.+"+(u-1),c.selectValueOnOpen=!1)}dt(e,c)}},evalInput:function(e,t){var r=t.inputState,n=r.motion,o=r.motionArgs||{repeat:1},a=r.operator,c=r.operatorArgs||{},u=r.registerName,h=t.sel,p=Y(t.visualMode?ve(e,h.head):e.getCursor("head")),v=Y(t.visualMode?ve(e,h.anchor):e.getCursor("anchor")),y=Y(p),C=Y(v),k,m,b;if(a&&this.recordLastEdit(t,r),r.repeatOverride!==void 0?b=r.repeatOverride:b=r.getRepeat(),b>0&&o.explicitRepeat?o.repeatIsExplicit=!0:(o.noRepeat||!o.explicitRepeat&&b===0)&&(b=1,o.repeatIsExplicit=!1),r.selectedCharacter&&(o.selectedCharacter=c.selectedCharacter=r.selectedCharacter),o.repeat=b,ce(e),n){var E=Ne[n](e,p,o,t,r);if(t.lastMotion=Ne[n],!E)return;if(o.toJumplist){var N=M.jumpList,T=N.cachedCursor;T?(or(e,T,E),delete N.cachedCursor):or(e,p,E)}E instanceof Array?(m=E[0],k=E[1]):k=E,k||(k=Y(p)),t.visualMode?(t.visualBlock&&k.ch===1/0||(k=ve(e,k,y)),m&&(m=ve(e,m)),m=m||C,h.anchor=m,h.head=k,qe(e),$e(e,t,"<",te(m,k)?m:k),$e(e,t,">",te(m,k)?k:m)):a||(k=ve(e,k,y),e.setCursor(k.line,k.ch))}if(a){if(c.lastSel){m=C;var I=c.lastSel,F=Math.abs(I.head.line-I.anchor.line),W=Math.abs(I.head.ch-I.anchor.ch);I.visualLine?k=new i(C.line+F,C.ch):I.visualBlock?k=new i(C.line+F,C.ch+W):I.head.line==I.anchor.line?k=new i(C.line,C.ch+W):k=new i(C.line+F,C.ch),t.visualMode=!0,t.visualLine=I.visualLine,t.visualBlock=I.visualBlock,h=t.sel={anchor:m,head:k},qe(e)}else t.visualMode&&(c.lastSel={anchor:Y(h.anchor),head:Y(h.head),visualBlock:t.visualBlock,visualLine:t.visualLine});var ae,X,fe,z,V;if(t.visualMode){ae=ge(h.head,h.anchor),X=Fe(h.head,h.anchor),fe=t.visualLine||c.linewise,z=t.visualBlock?"block":fe?"line":"char";var Ce=l(e,ae,X);if(V=St(e,{anchor:Ce.start,head:Ce.end},z),fe){var ue=V.ranges;if(z=="block")for(var he=0;he<ue.length;he++)ue[he].head.ch=de(e,ue[he].head.line);else z=="line"&&(ue[0].head=new i(ue[0].head.line+1,0))}}else{if(ae=Y(m||C),X=Y(k||y),te(X,ae)){var Ue=ae;ae=X,X=Ue}fe=o.linewise||c.linewise,fe?In(e,ae,X):o.forward&&Tn(e,ae,X),z="char";var Rt=!o.inclusive||fe,Ce=l(e,ae,X);V=St(e,{anchor:Ce.start,head:Ce.end},z,Rt)}e.setSelections(V.ranges,V.primary),t.lastMotion=null,c.repeat=b,c.registerName=u,c.linewise=fe;var Tt=wt[a](e,c,V.ranges,C,k);t.visualMode&&Be(e,Tt!=null),Tt&&e.setCursor(Tt)}},recordLastEdit:function(e,t,r){var n=M.macroModeState;n.isPlaying||(e.lastEditInputState=t,e.lastEditActionCommand=r,n.lastInsertModeChanges.changes=[],n.lastInsertModeChanges.expectCursorActivityForChange=!1,n.lastInsertModeChanges.visualBlock=e.visualBlock?e.sel.head.line-e.sel.anchor.line:0)}},Ne={moveToTopLine:function(e,t,r){var n=At(e).top+r.repeat-1;return new i(n,Pe(e.getLine(n)))},moveToMiddleLine:function(e){var t=At(e),r=Math.floor((t.top+t.bottom)*.5);return new i(r,Pe(e.getLine(r)))},moveToBottomLine:function(e,t,r){var n=At(e).bottom-r.repeat+1;return new i(n,Pe(e.getLine(n)))},expandToLine:function(e,t,r){var n=t;return new i(n.line+r.repeat-1,1/0)},findNext:function(e,t,r){var n=Ee(e),o=n.getQuery();if(o){var a=!r.forward;a=n.isReversed()?!a:a,Lt(e,o);var c=yr(e,a,o,r.repeat);return c||Q(e,"No match found "+o+(pe("pcre")?" (set nopcre to use Vim regexps)":"")),c}},findAndSelectNextInclusive:function(e,t,r,n,o){var a=Ee(e),c=a.getQuery();if(c){var u=!r.forward;u=a.isReversed()?!u:u;var h=qn(e,u,c,r.repeat,n);if(h){if(o.operator)return h;var p=h[0],v=new i(h[1].line,h[1].ch-1);if(n.visualMode){(n.visualLine||n.visualBlock)&&(n.visualLine=!1,n.visualBlock=!1,s.signal(e,"vim-mode-change",{mode:"visual",subMode:""}));var y=n.sel.anchor;if(y)return a.isReversed()?r.forward?[y,p]:[y,v]:r.forward?[y,v]:[y,p]}else n.visualMode=!0,n.visualLine=!1,n.visualBlock=!1,s.signal(e,"vim-mode-change",{mode:"visual",subMode:""});return u?[v,p]:[p,v]}}},goToMark:function(e,t,r,n){var o=pt(e,n,r.selectedCharacter||"");return o?r.linewise?{line:o.line,ch:Pe(e.getLine(o.line))}:o:null},moveToOtherHighlightedEnd:function(e,t,r,n){var o=n.sel;return n.visualBlock&&r.sameLine?[ve(e,new i(o.anchor.line,o.head.ch)),ve(e,new i(o.head.line,o.anchor.ch))]:[o.head,o.anchor]},jumpToMark:function(e,t,r,n){for(var o=t,a=0;a<r.repeat;a++){var c=o;for(var u in n.marks)if(H(u)){var h=n.marks[u].find(),p=r.forward?te(h,c):te(c,h);if(!p&&!(r.linewise&&h.line==c.line)){var v=Le(c,o),y=r.forward?tr(c,h,o):tr(o,h,c);(v||y)&&(o=h)}}}return r.linewise&&(o=new i(o.line,Pe(e.getLine(o.line)))),o},moveByCharacters:function(e,t,r){var n=t,o=r.repeat,a=r.forward?n.ch+o:n.ch-o;return new i(n.line,a)},moveByLines:function(e,t,r,n){var o=t,a=o.ch;switch(n.lastMotion){case this.moveByLines:case this.moveByDisplayLines:case this.moveByScroll:case this.moveToColumn:case this.moveToEol:a=n.lastHPos;break;default:n.lastHPos=a}var c=r.repeat+(r.repeatOffset||0),u=r.forward?o.line+c:o.line-c,h=e.firstLine(),p=e.lastLine(),v=e.findPosV(o,r.forward?c:-c,"line",n.lastHSPos),y=r.forward?v.line>u:v.line<u;return y&&(u=v.line,a=v.ch),u<h&&o.line==h?this.moveToStartOfLine(e,t,r,n):u>p&&o.line==p?cr(e,t,r,n,!0):(r.toFirstChar&&(a=Pe(e.getLine(u)),n.lastHPos=a),n.lastHSPos=e.charCoords(new i(u,a),"div").left,new i(u,a))},moveByDisplayLines:function(e,t,r,n){var o=t;switch(n.lastMotion){case this.moveByDisplayLines:case this.moveByScroll:case this.moveByLines:case this.moveToColumn:case this.moveToEol:break;default:n.lastHSPos=e.charCoords(o,"div").left}for(var a=Math.round(r.repeat),c=0;c<a;c++){var u=e.findPosV(o,r.forward?1:-1,"line",n.lastHSPos);if(u.hitSide)break;o=u}return o!=t&&(n.lastHPos=o.ch),o},moveByPage:function(e,t,r){var n=t,o=r.repeat;return e.findPosV(n,r.forward?o:-o,"page")},moveByParagraph:function(e,t,r){var n=r.forward?1:-1;return fr(e,t,r.repeat,n).start},moveBySentence:function(e,t,r){var n=r.forward?1:-1;return $n(e,t,r.repeat,n)},moveByScroll:function(e,t,r,n){var o=e.getScrollInfo(),a=null,c=r.repeat;c||(c=o.clientHeight/(2*e.defaultTextHeight()));var u=e.charCoords(t,"local");if(r.repeat=c,a=Ne.moveByDisplayLines(e,t,r,n),!a)return null;var h=e.charCoords(a,"local");return e.scrollTo(null,o.top+h.top-u.top),a},moveByWords:function(e,t,r){return Dn(e,t,r.repeat,!!r.forward,!!r.wordEnd,!!r.bigWord)},moveTillCharacter:function(e,t,r){var n=r.repeat,o=Mt(e,n,r.forward,r.selectedCharacter,t),a=r.forward?-1:1;return ar(a,r),o?(o.ch+=a,o):null},moveToCharacter:function(e,t,r){var n=r.repeat;return ar(0,r),Mt(e,n,r.forward,r.selectedCharacter,t)||t},moveToSymbol:function(e,t,r){var n=r.repeat;return r.selectedCharacter&&Pn(e,n,r.forward,r.selectedCharacter)||t},moveToColumn:function(e,t,r,n){var o=r.repeat;return n.lastHPos=o-1,n.lastHSPos=e.charCoords(t,"div").left,_n(e,o)},moveToEol:function(e,t,r,n){return cr(e,t,r,n,!1)},moveToFirstNonWhiteSpaceCharacter:function(e,t){var r=t;return new i(r.line,Pe(e.getLine(r.line)))},moveToMatchedSymbol:function(e,t){for(var r=t,n=r.line,o=r.ch,a=e.getLine(n),c;o<a.length;o++)if(c=a.charAt(o),c&&J(c)){var u=e.getTokenTypeAt(new i(n,o+1));if(u!=="string"&&u!=="comment")break}if(o<a.length){var h=c==="<"||c===">"?/[(){}[\]<>]/:/[(){}[\]]/,p=e.findMatchingBracket(new i(n,o),{bracketRegex:h});return p.to}else return r},moveToStartOfLine:function(e,t){return new i(t.line,0)},moveToLineOrEdgeOfDocument:function(e,t,r){var n=r.forward?e.lastLine():e.firstLine();return r.repeatIsExplicit&&(n=r.repeat-e.getOption("firstLineNumber")),new i(n,Pe(e.getLine(n)))},moveToStartOfDisplayLine:function(e){return e.execCommand("goLineLeft"),e.getCursor()},moveToEndOfDisplayLine:function(e){e.execCommand("goLineRight");var t=e.getCursor();return t.sticky=="before"&&t.ch--,t},textObjectManipulation:function(e,t,r,n){var o={"(":")",")":"(","{":"}","}":"{","[":"]","]":"[","<":">",">":"<"},a={"'":!0,'"':!0,"`":!0},c=r.selectedCharacter||"";c=="b"?c="(":c=="B"&&(c="{");var u=!r.textObjectInner,h,p;if(o[c]){if(p=!0,h=hr(e,t,c,u),!h){var v=e.getSearchCursor(new RegExp("\\"+c,"g"),t);v.find()&&(h=hr(e,v.from(),c,u))}}else if(a[c])p=!0,h=Fn(e,t,c,u);else if(c==="W"||c==="w")for(var y=r.repeat||1;y-- >0;){var C=bt(e,{inclusive:u,innerWord:!u,bigWord:c==="W",noSymbol:c==="W",multiline:!0},h&&h.end);C&&(h||(h=C),h.end=C.end)}else if(c==="p")if(h=fr(e,t,r.repeat,0,u),r.linewise=!0,n.visualMode)n.visualLine||(n.visualLine=!0);else{var k=n.inputState.operatorArgs;k&&(k.linewise=!0),h.end.line--}else if(c==="t")h=Nn(e,t,u);else if(c==="s"){var m=e.getLine(t.line);t.ch>0&&_e(m[t.ch])&&(t.ch-=1);var b=ur(e,t,r.repeat,1,u),E=ur(e,t,r.repeat,-1,u);le(e.getLine(E.line)[E.ch])&&le(e.getLine(b.line)[b.ch-1])&&(E={line:E.line,ch:E.ch+1}),h={start:E,end:b}}return h?e.state.vim.visualMode?On(e,h.start,h.end,p):[h.start,h.end]:null},repeatLastCharacterSearch:function(e,t,r){var n=M.lastCharacterSearch,o=r.repeat,a=r.forward===n.forward,c=(n.increment?1:0)*(a?-1:1);r.inclusive=!!a;var u=Mt(e,o,a,n.selectedCharacter,oe(t,0,-c));return u?(u.ch+=c,u):t}};function Cn(e,t){Ne[e]=t}function Gt(e,t){for(var r=[],n=0;n<t;n++)r.push(e);return r}var wt={change:function(e,t,r){var n,o,a=e.state.vim,c=r[0].anchor,u=r[0].head;if(a.visualMode)if(t.fullLine)u.ch=Number.MAX_VALUE,u.line--,e.setSelection(c,u),o=e.getSelection(),e.replaceSelection(""),n=c;else{o=e.getSelection();var v=Gt("",r.length);e.replaceSelections(v),n=ge(r[0].head,r[0].anchor)}else{o=e.getRange(c,u);var h=a.lastEditInputState;if(h?.motion=="moveByWords"&&!le(o)){var p=/\s+$/.exec(o);p&&h.motionArgs&&h.motionArgs.forward&&(u=oe(u,0,-p[0].length),o=o.slice(0,-p[0].length))}t.linewise&&(c=new i(c.line,Pe(e.getLine(c.line))),u.line>c.line&&(u=new i(u.line-1,Number.MAX_VALUE))),e.replaceRange("",c,u),n=c}M.registerController.pushText(t.registerName,"change",o,t.linewise,r.length>1),We.enterInsertMode(e,{head:n},e.state.vim)},delete:function(e,t,r){var n,o,a=e.state.vim;if(a.visualBlock){o=e.getSelection();var h=Gt("",r.length);e.replaceSelections(h),n=ge(r[0].head,r[0].anchor)}else{var c=r[0].anchor,u=r[0].head;t.linewise&&u.line!=e.firstLine()&&c.line==e.lastLine()&&c.line==u.line-1&&(c.line==e.firstLine()?c.ch=0:c=new i(c.line-1,de(e,c.line-1))),o=e.getRange(c,u),e.replaceRange("",c,u),n=c,t.linewise&&(n=Ne.moveToFirstNonWhiteSpaceCharacter(e,c))}return M.registerController.pushText(t.registerName,"delete",o,t.linewise,a.visualBlock),ve(e,n)},indent:function(e,t,r){var n=e.state.vim,o=n.visualMode&&t.repeat||1;if(n.visualBlock){for(var a=e.getOption("tabSize"),c=e.getOption("indentWithTabs")?" ":" ".repeat(a),u,h=r.length-1;h>=0;h--)if(u=ge(r[h].anchor,r[h].head),t.indentRight)e.replaceRange(c.repeat(o),u,u);else{for(var p=e.getLine(u.line),v=0,y=0;y<o;y++){var C=p[u.ch+v];if(C==" ")v++;else if(C==" "){v++;for(var k=1;k<c.length&&(C=p[u.ch+v],C===" ");k++)v++}else break}e.replaceRange("",u,oe(u,0,v))}return u}else if(e.indentMore)for(var y=0;y<o;y++)t.indentRight?e.indentMore():e.indentLess();else{var m=r[0].anchor.line,b=n.visualBlock?r[r.length-1].anchor.line:r[0].head.line;t.linewise&&b--;for(var h=m;h<=b;h++)for(var y=0;y<o;y++)e.indentLine(h,t.indentRight)}return Ne.moveToFirstNonWhiteSpaceCharacter(e,r[0].anchor)},indentAuto:function(e,t,r){return e.execCommand("indentAuto"),Ne.moveToFirstNonWhiteSpaceCharacter(e,r[0].anchor)},hardWrap:function(e,t,r,n){if(e.hardWrap){var o=r[0].anchor.line,a=r[0].head.line;t.linewise&&a--;var c=e.hardWrap({from:o,to:a});return c>o&&t.linewise&&c--,t.keepCursor?n:new i(c,0)}},toggleComment:function(e,t,r,n,o){return e.execCommand("toggleLineComment"),o},changeCase:function(e,t,r,n,o){for(var a=e.getSelections(),c=[],u=t.toLower,h=0;h<a.length;h++){var p=a[h],v="";if(u===!0)v=p.toLowerCase();else if(u===!1)v=p.toUpperCase();else for(var y=0;y<p.length;y++){var C=p.charAt(y);v+=me(C)?C.toLowerCase():C.toUpperCase()}c.push(v)}return e.replaceSelections(c),t.shouldMoveCursor?o:!e.state.vim.visualMode&&t.linewise&&r[0].anchor.line+1==r[0].head.line?Ne.moveToFirstNonWhiteSpaceCharacter(e,n):t.linewise?n:ge(r[0].anchor,r[0].head)},yank:function(e,t,r,n){var o=e.state.vim,a=e.getSelection(),c=o.visualMode?ge(o.sel.anchor,o.sel.head,r[0].head,r[0].anchor):n;M.registerController.pushText(t.registerName,"yank",a,t.linewise,o.visualBlock);var u=Math.abs(e.getCursor("end").line-e.getCursor("start").line)||1;return Q(e,u+" lines yanked"+(t.registerName?' into "'+t.registerName:""),!1,1500),c},rot13:function(e,t,r,n,o){for(var a=e.getSelections(),c=[],u=0;u<a.length;u++){const h=a[u].split("").map(p=>{const v=p.charCodeAt(0);return v>=65&&v<=90?String.fromCharCode(65+(v-65+13)%26):v>=97&&v<=122?String.fromCharCode(97+(v-97+13)%26):p}).join("");c.push(h)}return e.replaceSelections(c),t.shouldMoveCursor?o:!e.state.vim.visualMode&&t.linewise&&r[0].anchor.line+1==r[0].head.line?Ne.moveToFirstNonWhiteSpaceCharacter(e,n):t.linewise?n:ge(r[0].anchor,r[0].head)}};function kn(e,t){wt[e]=t}var We={jumpListWalk:function(e,t,r){if(!r.visualMode){var n=t.repeat||1,o=t.forward,a=M.jumpList,c=a.move(e,o?n:-n),u=c?c.find():void 0;u=u||e.getCursor(),e.setCursor(u)}},scroll:function(e,t,r){if(!r.visualMode){var n=t.repeat||1,o=e.defaultTextHeight(),a=e.getScrollInfo().top,c=o*n,u=t.forward?a+c:a-c,h=Y(e.getCursor()),p=e.charCoords(h,"local");if(t.forward)u>p.top?(h.line+=(u-p.top)/o,h.line=Math.ceil(h.line),e.setCursor(h),p=e.charCoords(h,"local"),e.scrollTo(null,p.top)):e.scrollTo(null,u);else{var v=u+e.getScrollInfo().clientHeight;v<p.bottom?(h.line-=(p.bottom-v)/o,h.line=Math.floor(h.line),e.setCursor(h),p=e.charCoords(h,"local"),e.scrollTo(null,p.bottom-e.getScrollInfo().clientHeight)):e.scrollTo(null,u)}}},scrollToCursor:function(e,t){var r=e.getCursor().line,n=e.charCoords(new i(r,0),"local"),o=e.getScrollInfo().clientHeight,a=n.top;switch(t.position){case"center":a=n.bottom-o/2;break;case"bottom":var c=new i(r,e.getLine(r).length-1),u=e.charCoords(c,"local"),h=u.bottom-a;a=a-o+h;break}e.scrollTo(null,a)},replayMacro:function(e,t,r){var n=t.selectedCharacter||"",o=t.repeat||1,a=M.macroModeState;for(n=="@"?n=a.latestRegister||"":a.latestRegister=n;o--;)ni(e,r,a,n)},enterMacroRecordMode:function(e,t){var r=M.macroModeState,n=t.selectedCharacter;M.registerController.isValidRegister(n)&&r.enterMacroRecordMode(e,n)},toggleOverwrite:function(e){e.state.overwrite?(e.toggleOverwrite(!1),e.setOption("keyMap","vim-insert"),s.signal(e,"vim-mode-change",{mode:"insert"})):(e.toggleOverwrite(!0),e.setOption("keyMap","vim-replace"),s.signal(e,"vim-mode-change",{mode:"replace"}))},enterInsertMode:function(e,t,r){if(!e.getOption("readOnly")){r.insertMode=!0,r.insertModeRepeat=t&&t.repeat||1;var n=t?t.insertAt:null,o=r.sel,a=t.head||e.getCursor("head"),c=e.listSelections().length;if(n=="eol")a=new i(a.line,de(e,a.line));else if(n=="bol")a=new i(a.line,0);else if(n=="charAfter"){var u=l(e,a,oe(a,0,1));a=u.end}else if(n=="firstNonBlank"){var u=l(e,a,Ne.moveToFirstNonWhiteSpaceCharacter(e,a));a=u.end}else if(n=="startOfSelectedArea"){if(!r.visualMode)return;r.visualBlock?(a=new i(Math.min(o.head.line,o.anchor.line),Math.min(o.head.ch,o.anchor.ch)),c=Math.abs(o.head.line-o.anchor.line)+1):o.head.line<o.anchor.line?a=o.head:a=new i(o.anchor.line,0)}else if(n=="endOfSelectedArea"){if(!r.visualMode)return;r.visualBlock?(a=new i(Math.min(o.head.line,o.anchor.line),Math.max(o.head.ch,o.anchor.ch)+1),c=Math.abs(o.head.line-o.anchor.line)+1):o.head.line>=o.anchor.line?a=oe(o.head,0,1):a=new i(o.anchor.line,0)}else if(n=="inplace"){if(r.visualMode)return}else n=="lastEdit"&&(a=Cr(e)||a);e.setOption("disableInput",!1),t&&t.replace?(e.toggleOverwrite(!0),e.setOption("keyMap","vim-replace"),s.signal(e,"vim-mode-change",{mode:"replace"})):(e.toggleOverwrite(!1),e.setOption("keyMap","vim-insert"),s.signal(e,"vim-mode-change",{mode:"insert"})),M.macroModeState.isPlaying||(e.on("change",wr),r.insertEnd&&r.insertEnd.clear(),r.insertEnd=e.setBookmark(a,{insertLeft:!0}),s.on(e.getInputField(),"keydown",br)),r.visualMode&&Be(e),nr(e,a,c)}},toggleVisualMode:function(e,t,r){var n=t.repeat,o=e.getCursor(),a;if(r.visualMode)r.visualLine!=!!t.linewise||r.visualBlock!=!!t.blockwise?(r.visualLine=!!t.linewise,r.visualBlock=!!t.blockwise,s.signal(e,"vim-mode-change",{mode:"visual",subMode:r.visualLine?"linewise":r.visualBlock?"blockwise":""}),qe(e)):Be(e);else{r.visualMode=!0,r.visualLine=!!t.linewise,r.visualBlock=!!t.blockwise,a=ve(e,new i(o.line,o.ch+n-1));var c=l(e,o,a);r.sel={anchor:c.start,head:c.end},s.signal(e,"vim-mode-change",{mode:"visual",subMode:r.visualLine?"linewise":r.visualBlock?"blockwise":""}),qe(e),$e(e,r,"<",ge(o,a)),$e(e,r,">",Fe(o,a))}},reselectLastSelection:function(e,t,r){var n=r.lastSelection;if(r.visualMode&&ir(e,r),n){var o=n.anchorMark.find(),a=n.headMark.find();if(!o||!a)return;r.sel={anchor:o,head:a},r.visualMode=!0,r.visualLine=n.visualLine,r.visualBlock=n.visualBlock,qe(e),$e(e,r,"<",ge(o,a)),$e(e,r,">",Fe(o,a)),s.signal(e,"vim-mode-change",{mode:"visual",subMode:r.visualLine?"linewise":r.visualBlock?"blockwise":""})}},joinLines:function(e,t,r){var n,o;if(r.visualMode){if(n=e.getCursor("anchor"),o=e.getCursor("head"),te(o,n)){var a=o;o=n,n=a}o.ch=de(e,o.line)-1}else{var c=Math.max(t.repeat,2);n=e.getCursor(),o=ve(e,new i(n.line+c-1,1/0))}for(var u=0,h=n.line;h<o.line;h++){u=de(e,n.line);var p="",v=0;if(!t.keepSpaces){var y=e.getLine(n.line+1);v=y.search(/\S/),v==-1?v=y.length:p=" "}e.replaceRange(p,new i(n.line,u),new i(n.line+1,v))}var C=ve(e,new i(n.line,u));r.visualMode&&Be(e,!1),e.setCursor(C)},newLineAndEnterInsertMode:function(e,t,r){r.insertMode=!0;var n=Y(e.getCursor());if(n.line===e.firstLine()&&!t.after)e.replaceRange(`
9
- `,new i(e.firstLine(),0)),e.setCursor(e.firstLine(),0);else{n.line=t.after?n.line:n.line-1,n.ch=de(e,n.line),e.setCursor(n);var o=s.commands.newlineAndIndentContinueComment||s.commands.newlineAndIndent;o(e)}this.enterInsertMode(e,{repeat:t.repeat},r)},paste:function(e,t,r){var n=M.registerController.getRegister(t.registerName);if(t.registerName==="+")navigator.clipboard.readText().then(a=>{this.continuePaste(e,t,r,a,n)});else{var o=n.toString();this.continuePaste(e,t,r,o,n)}},continuePaste:function(e,t,r,n,o){var a=Y(e.getCursor());if(n){if(t.matchIndent){var c=e.getOption("tabSize"),u=function(ue){var he=ue.split(" ").length-1,Ue=ue.split(" ").length-1;return he*c+Ue*1},h=e.getLine(e.getCursor().line),p=u(h.match(/^\s*/)[0]),v=n.replace(/\n$/,""),y=n!==v,C=u(n.match(/^\s*/)[0]),n=v.replace(/^\s*/gm,function(ue){var he=p+(u(ue)-C);if(he<0)return"";if(e.getOption("indentWithTabs")){var Ue=Math.floor(he/c);return Array(Ue+1).join(" ")}else return Array(he+1).join(" ")});n+=y?`
10
- `:""}t.repeat>1&&(n=Array(t.repeat+1).join(n));var k=t.linewise==null?o.linewise:t.linewise,m=o.blockwise,b=m?n.split(`
11
- `):void 0;if(b){k&&b.pop();for(var E=0;E<b.length;E++)b[E]=b[E]==""?" ":b[E];a.ch+=t.after?1:0,a.ch=Math.min(de(e,a.line),a.ch)}else k?r.visualMode?n=r.visualLine?n.slice(0,-1):`
12
- `+n.slice(0,n.length-1)+`
13
- `:t.after?(n=`
14
- `+n.slice(0,n.length-1),a.ch=de(e,a.line)):a.ch=0:a.ch+=t.after?1:0;var N;if(r.visualMode){r.lastPastedText=n;var T,I=En(e),F=I[0],W=I[1],ae=e.getSelection(),X=e.listSelections(),fe=new Array(X.length).join("1").split("1");r.lastSelection&&(T=r.lastSelection.headMark.find()),M.registerController.unnamedRegister.setText(ae),m?(e.replaceSelections(fe),W=new i(F.line+n.length-1,F.ch),e.setCursor(F),rr(e,W),e.replaceSelections(n),N=F):r.visualBlock?(e.replaceSelections(fe),e.setCursor(F),e.replaceRange(n,F,F),N=F):(e.replaceRange(n,F,W),N=e.posFromIndex(e.indexFromPos(F)+n.length-1)),T&&(r.lastSelection.headMark=e.setBookmark(T)),k&&(N.ch=0)}else if(m&&b){e.setCursor(a);for(var E=0;E<b.length;E++){var z=a.line+E;z>e.lastLine()&&e.replaceRange(`
15
- `,new i(z,0));var V=de(e,z);V<a.ch&&Ln(e,z,a.ch)}e.setCursor(a),rr(e,new i(a.line+b.length-1,a.ch)),e.replaceSelections(b),N=a}else if(e.replaceRange(n,a),k){var z=t.after?a.line+1:a.line;N=new i(z,Pe(e.getLine(z)))}else N=Y(a),/\n/.test(n)||(N.ch+=n.length-(t.after?1:0));r.visualMode&&Be(e,!1),e.setCursor(N)}},undo:function(e,t){e.operation(function(){er(e,s.commands.undo,t.repeat)(),e.setCursor(ve(e,e.getCursor("start")))})},redo:function(e,t){er(e,s.commands.redo,t.repeat)()},setRegister:function(e,t,r){r.inputState.registerName=t.selectedCharacter},insertRegister:function(e,t,r){var n=t.selectedCharacter,o=M.registerController.getRegister(n),a=o&&o.toString();a&&e.replaceSelection(a)},oneNormalCommand:function(e,t,r){He(e,!0),r.insertModeReturn=!0,s.on(e,"vim-command-done",function n(){r.visualMode||(r.insertModeReturn&&(r.insertModeReturn=!1,r.insertMode||We.enterInsertMode(e,{},r)),s.off(e,"vim-command-done",n))})},setMark:function(e,t,r){var n=t.selectedCharacter;n&&$e(e,r,n,e.getCursor())},replace:function(e,t,r){var n=t.selectedCharacter||"",o=e.getCursor(),a,c,u=e.listSelections();if(r.visualMode)o=e.getCursor("start"),c=e.getCursor("end");else{var h=e.getLine(o.line);a=o.ch+t.repeat,a>h.length&&(a=h.length),c=new i(o.line,a)}var p=l(e,o,c);if(o=p.start,c=p.end,n==`
16
- `)r.visualMode||e.replaceRange("",o,c),(s.commands.newlineAndIndentContinueComment||s.commands.newlineAndIndent)(e);else{var v=e.getRange(o,c);if(v=v.replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,n),v=v.replace(/[^\n]/g,n),r.visualBlock){var y=new Array(e.getOption("tabSize")+1).join(" ");v=e.getSelection(),v=v.replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,n);var C=v.replace(/\t/g,y).replace(/[^\n]/g,n).split(`
17
- `);e.replaceSelections(C)}else e.replaceRange(v,o,c);r.visualMode?(o=te(u[0].anchor,u[0].head)?u[0].anchor:u[0].head,e.setCursor(o),Be(e,!1)):e.setCursor(oe(c,0,-1))}},incrementNumberToken:function(e,t){for(var r=e.getCursor(),n=e.getLine(r.line),o=/(-?)(?:(0x)([\da-f]+)|(0b|0|)(\d+))/gi,a,c,u,h;(a=o.exec(n))!==null&&(c=a.index,u=c+a[0].length,!(r.ch<u)););if(!(!t.backtrack&&u<=r.ch)){if(a){var p=a[2]||a[4],v=a[3]||a[5],y=t.increase?1:-1,C={"0b":2,0:8,"":10,"0x":16}[p.toLowerCase()],k=parseInt(a[1]+v,C)+y*t.repeat;h=k.toString(C);var m=p?new Array(v.length-h.length+1+a[1].length).join("0"):"";h.charAt(0)==="-"?h="-"+p+m+h.substr(1):h=p+m+h;var b=new i(r.line,c),E=new i(r.line,u);e.replaceRange(h,b,E)}else return;e.setCursor(new i(r.line,c+h.length-1))}},repeatLastEdit:function(e,t,r){var n=r.lastEditInputState;if(n){var o=t.repeat;o&&t.repeatIsExplicit?n.repeatOverride=o:o=n.repeatOverride||o,Mr(e,r,o,!1)}},indent:function(e,t){e.indentLine(e.getCursor().line,t.indentRight)},exitInsertMode:function(e,t){He(e)}};function wn(e,t){We[e]=t}function ve(e,t,r){var n=e.state.vim,o=n.insertMode||n.visualMode,a=Math.min(Math.max(e.firstLine(),t.line),e.lastLine()),c=e.getLine(a),u=c.length-1+ +!!o,h=Math.min(Math.max(0,t.ch),u),p=c.charCodeAt(h);if(56320<=p&&p<=57343){var v=1;r&&r.line==a&&r.ch>h&&(v=-1),h+=v,h>u&&(h-=2)}return new i(a,h)}function ht(e){var t={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}function oe(e,t,r){return typeof t=="object"&&(r=t.ch,t=t.line),new i(e.line+t,e.ch+r)}function xn(e,t,r,n){n.operator&&(r="operatorPending");for(var o,a=[],c=[],u=ut?t.length-g:0,h=u;h<t.length;h++){var p=t[h];r=="insert"&&p.context!="insert"||p.context&&p.context!=r||n.operator&&p.type=="action"||!(o=Sn(e,p.keys))||(o=="partial"&&a.push(p),o=="full"&&c.push(p))}return{partial:a,full:c}}function Sn(e,t){const r=t.slice(-11)=="<character>",n=t.slice(-10)=="<register>";if(r||n){var o=t.length-(r?11:10),a=e.slice(0,o),c=t.slice(0,o);return a==c&&e.length>o?"full":c.indexOf(a)==0?"partial":!1}else return e==t?"full":t.indexOf(e)==0?"partial":!1}function bn(e){var t=/^.*(<[^>]+>)$/.exec(e),r=t?t[1]:e.slice(-1);if(r.length>1)switch(r){case"<CR>":case"<S-CR>":r=`
18
- `;break;case"<Space>":case"<S-Space>":r=" ";break;default:r="";break}return r}function er(e,t,r){return function(){for(var n=0;n<r;n++)t(e)}}function Y(e){return new i(e.line,e.ch)}function Le(e,t){return e.ch==t.ch&&e.line==t.line}function te(e,t){return e.line<t.line||e.line==t.line&&e.ch<t.ch}function ge(e,t){return arguments.length>2&&(t=ge.apply(void 0,Array.prototype.slice.call(arguments,1))),te(e,t)?e:t}function Fe(e,t){return arguments.length>2&&(t=Fe.apply(void 0,Array.prototype.slice.call(arguments,1))),te(e,t)?t:e}function tr(e,t,r){var n=te(e,t),o=te(t,r);return n&&o}function de(e,t){return e.getLine(t).length}function xt(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}function Mn(e){return e.replace(/([.?*+$\[\]\/\\(){}|\-])/g,"\\$1")}function Ln(e,t,r){var n=de(e,t),o=new Array(r-n+1).join(" ");e.setCursor(new i(t,n)),e.replaceRange(o,e.getCursor())}function rr(e,t){var r=[],n=e.listSelections(),o=Y(e.clipPos(t)),a=!Le(t,o),c=e.getCursor("head"),u=An(n,c),h=Le(n[u].head,n[u].anchor),p=n.length-1,v=p-u>u?p:0,y=n[v].anchor,C=Math.min(y.line,o.line),k=Math.max(y.line,o.line),m=y.ch,b=o.ch,E=n[v].head.ch-m,N=b-m;E>0&&N<=0?(m++,a||b--):E<0&&N>=0?(m--,h||b++):E<0&&N==-1&&(m--,b++);for(var T=C;T<=k;T++){var I={anchor:new i(T,m),head:new i(T,b)};r.push(I)}return e.setSelections(r),t.ch=b,y.ch=m,y}function nr(e,t,r){for(var n=[],o=0;o<r;o++){var a=oe(t,o,0);n.push({anchor:a,head:a})}e.setSelections(n,0)}function An(e,t,r){for(var n=0;n<e.length;n++){var o=Le(e[n].anchor,t),a=Le(e[n].head,t);if(o||a)return n}return-1}function En(e,t){var r=e.listSelections(),n=r[0],o=r[r.length-1],a=te(n.anchor,n.head)?n.anchor:n.head,c=te(o.anchor,o.head)?o.head:o.anchor;return[a,c]}function ir(e,t){var r=t.sel.anchor,n=t.sel.head;t.lastPastedText&&(n=e.posFromIndex(e.indexFromPos(r)+t.lastPastedText.length),t.lastPastedText=void 0),t.lastSelection={anchorMark:e.setBookmark(r),headMark:e.setBookmark(n),anchor:Y(r),head:Y(n),visualMode:t.visualMode,visualLine:t.visualLine,visualBlock:t.visualBlock}}function On(e,t,r,n){var o=e.state.vim.sel,a=n?t:o.head,c=n?t:o.anchor,u;return te(r,t)&&(u=r,r=t,t=u),te(a,c)?(a=ge(t,a),c=Fe(c,r)):(c=ge(t,c),a=Fe(a,r),a=oe(a,0,-1),a.ch==-1&&a.line!=e.firstLine()&&(a=new i(a.line-1,de(e,a.line-1)))),[c,a]}function qe(e,t,r){var n=e.state.vim;t=t||n.sel,r||(r=n.visualLine?"line":n.visualBlock?"block":"char");var o=St(e,t,r);e.setSelections(o.ranges,o.primary)}function St(e,t,r,n){var o=Y(t.head),a=Y(t.anchor);if(r=="char"){var c=!n&&!te(t.head,t.anchor)?1:0,u=te(t.head,t.anchor)?1:0;return o=oe(t.head,0,c),a=oe(t.anchor,0,u),{ranges:[{anchor:a,head:o}],primary:0}}else if(r=="line"){if(te(t.head,t.anchor))o.ch=0,a.ch=de(e,a.line);else{a.ch=0;var h=e.lastLine();o.line>h&&(o.line=h),o.ch=de(e,o.line)}return{ranges:[{anchor:a,head:o}],primary:0}}else if(r=="block"){var p=Math.min(a.line,o.line),v=a.ch,y=Math.max(a.line,o.line),C=o.ch;v<C?C+=1:v+=1;for(var k=y-p+1,m=o.line==p?0:k-1,b=[],E=0;E<k;E++)b.push({anchor:new i(p+E,v),head:new i(p+E,C)});return{ranges:b,primary:m}}throw"never happens"}function Rn(e){var t=e.getCursor("head");return e.getSelection().length==1&&(t=ge(t,e.getCursor("anchor"))),t}function Be(e,t){var r=e.state.vim;t!==!1&&e.setCursor(ve(e,r.sel.head)),ir(e,r),r.visualMode=!1,r.visualLine=!1,r.visualBlock=!1,r.insertMode||s.signal(e,"vim-mode-change",{mode:"normal"})}function Tn(e,t,r){var n=e.getRange(t,r);if(/\n\s*$/.test(n)){var o=n.split(`
19
- `);o.pop();for(var a=o.pop();o.length>0&&a&&le(a);a=o.pop())r.line--,r.ch=0;a?(r.line--,r.ch=de(e,r.line)):r.ch=0}}function In(e,t,r){t.ch=0,r.ch=0,r.line++}function Pe(e){if(!e)return 0;var t=e.search(/\S/);return t==-1?e.length:t}function bt(e,{inclusive:t,innerWord:r,bigWord:n,noSymbol:o,multiline:a},c){var u=c||Rn(e),h=e.getLine(u.line),p=h,v=u.line,y=v,C=u.ch,k,m=o?_[0]:L[0];if(r&&/\s/.test(h.charAt(C)))m=function(F){return/\s/.test(F)};else{for(;!m(h.charAt(C));)if(C++,C>=h.length){if(!a)return null;C--,k=lr(e,u,!0,n,!0);break}n?m=L[0]:(m=_[0],m(h.charAt(C))||(m=_[1]))}for(var b=C,E=C;m(h.charAt(E))&&E>=0;)E--;if(E++,k)b=k.to,y=k.line,p=e.getLine(y),!p&&b==0&&b++;else for(;m(h.charAt(b))&&b<h.length;)b++;if(t){var N=b,T=u.ch<=E&&/\s/.test(h.charAt(u.ch));if(!T)for(;/\s/.test(p.charAt(b))&&b<p.length;)b++;if(N==b||T){for(var I=E;/\s/.test(h.charAt(E-1))&&E>0;)E--;!E&&!T&&(E=I)}}return{start:new i(v,E),end:new i(y,b)}}function Nn(e,t,r){var n=t;if(!s.findMatchingTag||!s.findEnclosingTag)return{start:n,end:n};var o=s.findMatchingTag(e,t)||s.findEnclosingTag(e,t);return!o||!o.open||!o.close?{start:n,end:n}:r?{start:o.open.from,end:o.close.to}:{start:o.open.to,end:o.close.from}}function or(e,t,r){Le(t,r)||M.jumpList.add(e,t,r)}function ar(e,t){M.lastCharacterSearch.increment=e,M.lastCharacterSearch.forward=t.forward,M.lastCharacterSearch.selectedCharacter=t.selectedCharacter}var Bn={"(":"bracket",")":"bracket","{":"bracket","}":"bracket","[":"section","]":"section","*":"comment","/":"comment",m:"method",M:"method","#":"preprocess"},sr={bracket:{isComplete:function(e){if(e.nextCh===e.symb){if(e.depth++,e.depth>=1)return!0}else e.nextCh===e.reverseSymb&&e.depth--;return!1}},section:{init:function(e){e.curMoveThrough=!0,e.symb=(e.forward?"]":"[")===e.symb?"{":"}"},isComplete:function(e){return e.index===0&&e.nextCh===e.symb}},comment:{isComplete:function(e){var t=e.lastCh==="*"&&e.nextCh==="/";return e.lastCh=e.nextCh,t}},method:{init:function(e){e.symb=e.symb==="m"?"{":"}",e.reverseSymb=e.symb==="{"?"}":"{"},isComplete:function(e){return e.nextCh===e.symb}},preprocess:{init:function(e){e.index=0},isComplete:function(e){if(e.nextCh==="#"){var t=e.lineText.match(/^#(\w+)/)?.[1];if(t==="endif"){if(e.forward&&e.depth===0)return!0;e.depth++}else if(t==="if"){if(!e.forward&&e.depth===0)return!0;e.depth--}if(t==="else"&&e.depth===0)return!0}return!1}}};function Pn(e,t,r,n){var o=Y(e.getCursor()),a=r?1:-1,c=r?e.lineCount():-1,u=o.ch,h=o.line,p=e.getLine(h),v={lineText:p,nextCh:p.charAt(u),lastCh:null,index:u,symb:n,reverseSymb:(r?{")":"(","}":"{"}:{"(":")","{":"}"})[n],forward:r,depth:0,curMoveThrough:!1},y=Bn[n];if(!y)return o;var C=sr[y].init,k=sr[y].isComplete;for(C&&C(v);h!==c&&t;){if(v.index+=a,v.nextCh=v.lineText.charAt(v.index),!v.nextCh){if(h+=a,v.lineText=e.getLine(h)||"",a>0)v.index=0;else{var m=v.lineText.length;v.index=m>0?m-1:0}v.nextCh=v.lineText.charAt(v.index)}k(v)&&(o.line=h,o.ch=v.index,t--)}return v.nextCh||v.curMoveThrough?new i(h,v.index):o}function lr(e,t,r,n,o){var a=t.line,c=t.ch,u=e.getLine(a),h=r?1:-1,p=n?L:_;if(o&&u==""){if(a+=h,u=e.getLine(a),!D(e,a))return null;c=r?0:u.length}for(;;){if(o&&u=="")return{from:0,to:0,line:a};for(var v=h>0?u.length:-1,y=v,C=v;c!=v;){for(var k=!1,m=0;m<p.length&&!k;++m)if(p[m](u.charAt(c))){for(y=c;c!=v&&p[m](u.charAt(c));)c+=h;if(C=c,k=y!=C,y==t.ch&&a==t.line&&C==y+h)continue;return{from:Math.min(y,C+1),to:Math.max(y,C),line:a}}k||(c+=h)}if(a+=h,!D(e,a))return null;u=e.getLine(a),c=h>0?0:u.length}}function Dn(e,t,r,n,o,a){var c=Y(t),u=[];(n&&!o||!n&&o)&&r++;for(var h=!(n&&o),p=0;p<r;p++){var v=lr(e,t,n,a,h);if(!v){var y=de(e,e.lastLine());u.push(n?{line:e.lastLine(),from:y,to:y}:{line:0,from:0,to:0});break}u.push(v),t=new i(v.line,n?v.to-1:v.from)}var C=u.length!=r,k=u[0],m=u.pop();return n&&!o?(!C&&(k.from!=c.ch||k.line!=c.line)&&(m=u.pop()),m&&new i(m.line,m.from)):n&&o?m&&new i(m.line,m.to-1):!n&&o?(!C&&(k.to!=c.ch||k.line!=c.line)&&(m=u.pop()),m&&new i(m.line,m.to)):m&&new i(m.line,m.from)}function cr(e,t,r,n,o){var a=t,c=new i(a.line+r.repeat-1,1/0),u=e.clipPos(c);return u.ch--,o||(n.lastHPos=1/0,n.lastHSPos=e.charCoords(u,"div").left),c}function Mt(e,t,r,n,o){if(n){for(var a=o||e.getCursor(),c=a.ch,u,h=0;h<t;h++){var p=e.getLine(a.line);if(u=Kn(c,p,n,r),u==-1)return;c=u}if(u!=null)return new i(e.getCursor().line,u)}}function _n(e,t){var r=e.getCursor().line;return ve(e,new i(r,t-1))}function $e(e,t,r,n){!Qe(r,O)&&!$.test(r)||(t.marks[r]&&t.marks[r].clear(),t.marks[r]=e.setBookmark(n))}function Kn(e,t,r,n,o){var a;return n?a=t.indexOf(r,e+1):a=t.lastIndexOf(r,e-1),a}function fr(e,t,r,n,o){var a=t.line,c=e.firstLine(),u=e.lastLine(),h,p,v=a;function y(E){return!e.getLine(E)}function C(E,N,T){return T?y(E)!=y(E+N):!y(E)&&y(E+N)}if(n){for(;c<=v&&v<=u&&r>0;)C(v,n)&&r--,v+=n;return{start:new i(v,0),end:t}}var k=e.state.vim;if(k.visualLine&&C(a,1,!0)){var m=k.sel.anchor;C(m.line,-1,!0)&&(!o||m.line!=a)&&(a+=1)}var b=y(a);for(v=a;v<=u&&r;v++)C(v,1,!0)&&(!o||y(v)!=b)&&r--;for(p=new i(v,0),v>u&&!b?b=!0:o=!1,v=a;v>c&&!((!o||y(v)==b||v==a)&&C(v,-1,!0));v--);return h=new i(v,0),{start:h,end:p}}function ur(e,t,r,n,o){function a(p){p.line!==null&&(p.pos+p.dir<0||p.pos+p.dir>=p.line.length?p.line=null:p.pos+=p.dir)}function c(p,v,y,C){var k=p.getLine(v),m={line:k,ln:v,pos:y,dir:C};if(m.line==="")return{ln:m.ln,pos:m.pos};var b=m.pos;for(a(m);m.line!==null;){if(b=m.pos,_e(m.line[m.pos]))if(o){for(a(m);m.line!==null&&le(m.line[m.pos]);)b=m.pos,a(m);return{ln:m.ln,pos:b+1}}else return{ln:m.ln,pos:m.pos+1};a(m)}return{ln:m.ln,pos:b+1}}function u(p,v,y,C){var k=p.getLine(v),m={line:k,ln:v,pos:y,dir:C};if(m.line==="")return{ln:m.ln,pos:m.pos};var b=m.pos;for(a(m);m.line!==null;){if(!le(m.line[m.pos])&&!_e(m.line[m.pos]))b=m.pos;else if(_e(m.line[m.pos]))return o?le(m.line[m.pos+1])?{ln:m.ln,pos:m.pos+1}:{ln:m.ln,pos:b}:{ln:m.ln,pos:b};a(m)}return m.line=k,o&&le(m.line[m.pos])?{ln:m.ln,pos:m.pos}:{ln:m.ln,pos:b}}for(var h={ln:t.line,pos:t.ch};r>0;)n<0?h=u(e,h.ln,h.pos,n):h=c(e,h.ln,h.pos,n),r--;return new i(h.ln,h.pos)}function $n(e,t,r,n){function o(h,p){if(p.line!==null)if(p.pos+p.dir<0||p.pos+p.dir>=p.line.length){if(p.ln+=p.dir,!D(h,p.ln)){p.line=null;return}p.line=h.getLine(p.ln),p.pos=p.dir>0?0:p.line.length-1}else p.pos+=p.dir}function a(h,p,v,y){var E=h.getLine(p),C=E==="",k={line:E,ln:p,pos:v,dir:y},m={ln:k.ln,pos:k.pos},b=k.line==="";for(o(h,k);k.line!==null;){if(m.ln=k.ln,m.pos=k.pos,k.line===""&&!b)return{ln:k.ln,pos:k.pos};if(C&&k.line!==""&&!le(k.line[k.pos]))return{ln:k.ln,pos:k.pos};_e(k.line[k.pos])&&!C&&(k.pos===k.line.length-1||le(k.line[k.pos+1]))&&(C=!0),o(h,k)}var E=h.getLine(m.ln);m.pos=0;for(var N=E.length-1;N>=0;--N)if(!le(E[N])){m.pos=N;break}return m}function c(h,p,v,y){var E=h.getLine(p),C={line:E,ln:p,pos:v,dir:y},k=C.ln,m=null,b=C.line==="";for(o(h,C);C.line!==null;){if(C.line===""&&!b)return m!==null?{ln:k,pos:m}:{ln:C.ln,pos:C.pos};if(_e(C.line[C.pos])&&m!==null&&!(C.ln===k&&C.pos+1===m))return{ln:k,pos:m};C.line!==""&&!le(C.line[C.pos])&&(b=!1,k=C.ln,m=C.pos),o(h,C)}var E=h.getLine(k);m=0;for(var N=0;N<E.length;++N)if(!le(E[N])){m=N;break}return{ln:k,pos:m}}for(var u={ln:t.line,pos:t.ch};r>0;)n<0?u=c(e,u.ln,u.pos,n):u=a(e,u.ln,u.pos,n),r--;return new i(u.ln,u.pos)}function hr(e,t,r,n){var o=t,a={"(":/[()]/,")":/[()]/,"[":/[[\]]/,"]":/[[\]]/,"{":/[{}]/,"}":/[{}]/,"<":/[<>]/,">":/[<>]/}[r],c={"(":"(",")":"(","[":"[","]":"[","{":"{","}":"{","<":"<",">":"<"}[r],u=e.getLine(o.line).charAt(o.ch),h=u===c?1:0,p=e.scanForBracket(new i(o.line,o.ch+h),-1,void 0,{bracketRegex:a}),v=e.scanForBracket(new i(o.line,o.ch+h),1,void 0,{bracketRegex:a});if(!p||!v)return null;var y=p.pos,C=v.pos;if(y.line==C.line&&y.ch>C.ch||y.line>C.line){var k=y;y=C,C=k}return n?C.ch+=1:y.ch+=1,{start:y,end:C}}function Fn(e,t,r,n){var o=Y(t),a=e.getLine(o.line),c=a.split(""),u,h,p,v,y=c.indexOf(r);if(o.ch<y)o.ch=y;else if(y<o.ch&&c[o.ch]==r){var C=/string/.test(e.getTokenTypeAt(oe(t,0,1))),k=/string/.test(e.getTokenTypeAt(t)),m=C&&!k;m||(h=o.ch,--o.ch)}if(c[o.ch]==r&&!h)u=o.ch+1;else for(p=o.ch;p>-1&&!u;p--)c[p]==r&&(u=p+1);if(u&&!h)for(p=u,v=c.length;p<v&&!h;p++)c[p]==r&&(h=p);return!u||!h?{start:o,end:o}:(n&&(--u,++h),{start:new i(o.line,u),end:new i(o.line,h)})}Ke("pcre",!0,"boolean");class Hn{constructor(){this.highlightTimeout}getQuery(){return M.query}setQuery(t){M.query=t}getOverlay(){return this.searchOverlay}setOverlay(t){this.searchOverlay=t}isReversed(){return M.isReversed}setReversed(t){M.isReversed=t}getScrollbarAnnotate(){return this.annotate}setScrollbarAnnotate(t){this.annotate=t}}function Ee(e){var t=e.state.vim;return t.searchState_||(t.searchState_=new Hn)}function Vn(e){return dr(e,"/")}function jn(e){return pr(e,"/")}function dr(e,t){var r=pr(e,t)||[];if(!r.length)return[];var n=[];if(r[0]===0){for(var o=0;o<r.length;o++)typeof r[o]=="number"&&n.push(e.substring(r[o]+1,r[o+1]));return n}}function pr(e,t){t||(t="/");for(var r=!1,n=[],o=0;o<e.length;o++){var a=e.charAt(o);!r&&a==t&&n.push(o),r=!r&&a=="\\"}return n}function Wn(e){var t={V:"|(){+?*.[$^",M:"|(){+?*.[",m:"|(){+?",v:"<>"},r={">":"(?<=[\\w])(?=[^\\w]|$)","<":"(?<=[^\\w]|^)(?=[\\w])"},n=t.m,o=e.replace(/\\.|[\[|(){+*?.$^<>]/g,function(c){if(c[0]==="\\"){var u=c[1];return u==="}"||n.indexOf(u)!=-1?u:u in t?(n=t[u],""):u in r?r[u]:c}else return n.indexOf(c)!=-1?r[c]||"\\"+c:c}),a=o.indexOf("\\zs");return a!=-1&&(o="(?<="+o.slice(0,a)+")"+o.slice(a+3)),a=o.indexOf("\\ze"),a!=-1&&(o=o.slice(0,a)+"(?="+o.slice(a+3)+")"),o}var vr={"\\n":`
20
- `,"\\r":"\r","\\t":" "};function Un(e){for(var t=!1,r=[],n=-1;n<e.length;n++){var o=e.charAt(n)||"",a=e.charAt(n+1)||"";vr[o+a]?(r.push(vr[o+a]),n++):t?(r.push(o),t=!1):o==="\\"?(t=!0,Z(a)||a==="$"?r.push("$"):a!=="/"&&a!=="\\"&&r.push("\\")):(o==="$"&&r.push("$"),r.push(o),a==="/"&&r.push("\\"))}return r.join("")}var gr={"\\/":"/","\\\\":"\\","\\n":`
21
- `,"\\r":"\r","\\t":" ","\\&":"&"};function zn(e){for(var t=new s.StringStream(e),r=[];!t.eol();){for(;t.peek()&&t.peek()!="\\";)r.push(t.next());var n=!1;for(var o in gr)if(t.match(o,!0)){n=!0,r.push(gr[o]);break}n||r.push(t.next())}return r.join("")}function mr(e,t,r){var n=M.registerController.getRegister("/");n.setText(e);var o=jn(e),a,c;if(!o.length)a=e;else{a=e.substring(0,o[0]);var u=e.substring(o[0]);c=u.indexOf("i")!=-1}if(!a)return null;pe("pcre")||(a=Wn(a)),r&&(t=/^[^A-Z]*$/.test(a));var h=new RegExp(a,t||c?"im":"m");return h}function Oe(e){typeof e=="string"&&(e=document.createElement(e));for(var t=1;t<arguments.length;t++){var r=arguments[t];if(r)if(typeof r!="object"&&(r=document.createTextNode(r)),r.nodeType)e.appendChild(r);else for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(n[0]==="$"?e.style[n.slice(1)]=r[n]:typeof r[n]=="function"?e[n]=r[n]:e.setAttribute(n,r[n]))}return e}function Q(e,t,r,n){var o=Oe("div",{$color:"red",$whiteSpace:"pre",class:"cm-vim-message"},t);e.openNotification?r?(o=Oe("div",{},o,Oe("div",{},"Press ENTER or type command to continue")),e.state.closeVimNotification&&e.state.closeVimNotification(),e.state.closeVimNotification=e.openNotification(o,{bottom:!0,duration:0})):e.openNotification(o,{bottom:!0,duration:n||15e3}):n||alert(o.innerText)}function Qn(e,t){return Oe("div",{$display:"flex",$flex:1},Oe("span",{$fontFamily:"monospace",$whiteSpace:"pre",$flex:1,$display:"flex"},e,Oe("input",{type:"text",autocorrect:"off",autocapitalize:"off",spellcheck:"false",$flex:1})),t&&Oe("span",{$color:"#888"},t))}function dt(e,t){if(Je.length){t.value||(t.value=""),ie=t;return}var r=Qn(t.prefix,t.desc);if(e.openDialog)e.openDialog(r,t.onClose,{onKeyDown:t.onKeyDown,onKeyUp:t.onKeyUp,bottom:!0,selectValueOnOpen:!1,value:t.value});else{var n="";typeof t.prefix!="string"&&t.prefix&&(n+=t.prefix.textContent),t.desc&&(n+=" "+t.desc),t.onClose?.(prompt(n,""))}}function Jn(e,t){return e instanceof RegExp&&t instanceof RegExp?e.flags==t.flags&&e.source==t.source:!1}function it(e,t,r,n){if(t){var o=Ee(e),a=mr(t,!!r,!!n);if(a)return Lt(e,a),Jn(a,o.getQuery())||o.setQuery(a),a}}function Zn(e){if(e.source.charAt(0)=="^")var t=!0;return{token:function(r){if(t&&!r.sol()){r.skipToEnd();return}var n=r.match(e,!1);if(n)return n[0].length==0?(r.next(),"searching"):!r.sol()&&(r.backUp(1),!e.exec(r.next()+n[0]))?(r.next(),null):(r.match(e),"searching");for(;!r.eol()&&(r.next(),!r.match(e,!1)););},query:e}}var ot=0;function Lt(e,t){clearTimeout(ot);var r=Ee(e);r.highlightTimeout=ot,ot=setTimeout(function(){if(e.state.vim){var n=Ee(e);n.highlightTimeout=void 0;var o=n.getOverlay();(!o||t!=o.query)&&(o&&e.removeOverlay(o),o=Zn(t),e.addOverlay(o),e.showMatchesOnScrollbar&&(n.getScrollbarAnnotate()&&n.getScrollbarAnnotate().clear(),n.setScrollbarAnnotate(e.showMatchesOnScrollbar(t))),n.setOverlay(o))}},50)}function yr(e,t,r,n){return e.operation(function(){n===void 0&&(n=1);for(var o=e.getCursor(),a=e.getSearchCursor(r,o),c=0;c<n;c++){var u=a.find(t);if(c==0&&u&&Le(a.from(),o)){var h=t?a.from():a.to();u=a.find(t),u&&!u[0]&&Le(a.from(),h)&&e.getLine(h.line).length==h.ch&&(u=a.find(t))}if(!u&&(a=e.getSearchCursor(r,t?new i(e.lastLine()):new i(e.firstLine(),0)),!a.find(t)))return}return a.from()})}function qn(e,t,r,n,o){return e.operation(function(){n===void 0&&(n=1);var a=e.getCursor(),c=e.getSearchCursor(r,a),u=c.find(!t);!o.visualMode&&u&&Le(c.from(),a)&&c.find(!t);for(var h=0;h<n;h++)if(u=c.find(t),!u&&(c=e.getSearchCursor(r,t?new i(e.lastLine()):new i(e.firstLine(),0)),!c.find(t)))return;var p=c.from(),v=c.to();return p&&v&&[p,v]})}function Ye(e){var t=Ee(e);t.highlightTimeout&&(clearTimeout(t.highlightTimeout),t.highlightTimeout=void 0),e.removeOverlay(Ee(e).getOverlay()),t.setOverlay(null),t.getScrollbarAnnotate()&&(t.getScrollbarAnnotate().clear(),t.setScrollbarAnnotate(null))}function Yn(e,t,r){return typeof e!="number"&&(e=e.line),t instanceof Array?Qe(e,t):typeof r=="number"?e>=t&&e<=r:e==t}function At(e){var t=e.getScrollInfo(),r=6,n=10,o=e.coordsChar({left:0,top:r+t.top},"local"),a=t.clientHeight-n+t.top,c=e.coordsChar({left:0,top:a},"local");return{top:o.line,bottom:c.line}}function pt(e,t,r){if(r=="'"||r=="`")return M.jumpList.find(e,-1)||new i(0,0);if(r==".")return Cr(e);var n=t.marks[r];return n&&n.find()}function Cr(e){if(e.getLastEditEnd)return e.getLastEditEnd();for(var t=e.doc.history.done,r=t.length;r--;)if(t[r].changes)return Y(t[r].changes[0].to)}class Xn{constructor(){this.commandMap_,this.buildCommandMap_()}processCommand(t,r,n){var o=this;t.operation(function(){t.curOp&&(t.curOp.isVimOp=!0),o._processCommand(t,r,n)})}_processCommand(t,r,n){var o=t.state.vim,a=M.registerController.getRegister(":"),c=a.toString(),u=new s.StringStream(r);a.setText(r);var h=n||{};h.input=r;try{this.parseInput_(t,u,h)}catch(y){Q(t,y+"");return}o.visualMode&&Be(t);var p,v;if(!h.commandName)h.line!==void 0&&(v="move");else if(p=this.matchCommand_(h.commandName),p){if(v=p.name,p.excludeFromCommandHistory&&a.setText(c),this.parseCommandArgs_(u,h,p),p.type=="exToKey"){rt(t,p.toKeys||"",p);return}else if(p.type=="exToEx"){this.processCommand(t,p.toInput||"");return}}if(!v){Q(t,'Not an editor command ":'+r+'"');return}try{kr[v](t,h),(!p||!p.possiblyAsync)&&h.callback&&h.callback()}catch(y){throw Q(t,y+""),y}}parseInput_(t,r,n){if(r.eatWhile(":"),r.eat("%"))n.line=t.firstLine(),n.lineEnd=t.lastLine();else if(r.eat("*")){var o=t.state.vim.lastSelection,a=o?.anchorMark.find()?.line||0,c=o?.headMark.find()?.line||0;n.line=Math.max(a,c),n.lineEnd=Math.min(a,c)}else n.line=this.parseLineSpec_(t,r),n.line!==void 0&&r.eat(",")&&(n.lineEnd=this.parseLineSpec_(t,r));n.line==null?t.state.vim.visualMode?(n.selectionLine=pt(t,t.state.vim,"<")?.line,n.selectionLineEnd=pt(t,t.state.vim,">")?.line):n.selectionLine=t.getCursor().line:(n.selectionLine=n.line,n.selectionLineEnd=n.lineEnd),r.eatSpace();var u=r.match(/^(\w+|!!|@@|[!#&*<=>@~])/);return u?n.commandName=u[1]:n.commandName=(r.match(/.*/)||[""])[0],n}parseLineSpec_(t,r){var n=r.match(/^([\d]+)/);if(n)return this.parseLineSpecOffset_(t,r,parseInt(n[1],10)-1);switch(r.next()){case".":return this.parseLineSpecOffset_(t,r,t.getCursor().line);case"$":return this.parseLineSpecOffset_(t,r,t.lastLine());case"'":var o=r.next()||"",a=pt(t,t.state.vim,o);if(!a)throw new Error("Mark not set");return this.parseLineSpecOffset_(t,r,a.line);case"-":case"+":case"/":case"?":return r.backUp(1),this.parseLineSpecOffset_(t,r,t.getCursor().line);default:r.backUp(1);return}}parseLineSpecOffset_(t,r,n){for(;;){var o=r.match(/^([\/\?]|\\[\?\/])|([+-]?)(\d*)/);if(!o||!o[0])break;if(o[1]){var a="",c=!o[1].endsWith("?");if(o[1].length==1){var u=r.match(c?/^([^\/\\]|\\\/)*/:/^([^\/\?]|\\\?)*/);r.match(c?/^\/?/:/^\??/),a=u&&u[0]}a||(a=M.registerController.getRegister("/")?.toString()||"");var h=new RegExp(a),p=t.getSearchCursor(h,new i(n+(c?1:0),0));c?p.findNext():p.findPrevious();var v=p.from();if(!v)throw new Error("Pattern not found"+h);n=v.line}else{var y=parseInt(o[2]+(o[3]||"1"),10);n+=y}}return n}parseCommandArgs_(t,r,n){if(!t.eol()){r.argString=t.match(/.*/)?.[0];var o=n.argDelimiter||/\s+/,a=xt(r.argString||"").split(o);a.length&&a[0]&&(r.args=a)}}matchCommand_(t){for(var r=t.length;r>0;r--){var n=t.substring(0,r);if(this.commandMap_[n]){var o=this.commandMap_[n];if(o.name.indexOf(t)===0)return o}}}buildCommandMap_(){this.commandMap_={};for(var t=0;t<w.length;t++){var r=w[t],n=r.shortName||r.name;this.commandMap_[n]=r}}map(t,r,n,o){if(t!=":"&&t.charAt(0)==":"){if(n)throw Error("Mode not supported for ex mappings");var a=t.substring(1);r!=":"&&r.charAt(0)==":"?this.commandMap_[a]={name:a,type:"exToEx",toInput:r.substring(1),user:!0}:this.commandMap_[a]={name:a,type:"exToKey",toKeys:r,user:!0}}else{var c={keys:t,type:"keyToKey",toKeys:r,noremap:!!o};n&&(c.context=n),Et(c)}}unmap(t,r){if(t!=":"&&t.charAt(0)==":"){if(r)throw Error("Mode not supported for ex mappings");var n=t.substring(1);if(this.commandMap_[n]&&this.commandMap_[n].user)return delete this.commandMap_[n],!0}else for(var o=t,a=0;a<f.length;a++)if(o==f[a].keys&&f[a].context===r)return f.splice(a,1),ti(o),!0}}var kr={colorscheme:function(e,t){if(!t.args||t.args.length<1){Q(e,e.getOption("theme"));return}e.setOption("theme",t.args[0])},map:function(e,t,r,n){var o=t.args;if(!o||o.length<2){e&&Q(e,"Invalid mapping: "+t.input);return}ye.map(o[0],o[1],r,n)},imap:function(e,t){this.map(e,t,"insert")},nmap:function(e,t){this.map(e,t,"normal")},vmap:function(e,t){this.map(e,t,"visual")},omap:function(e,t){this.map(e,t,"operatorPending")},noremap:function(e,t){this.map(e,t,void 0,!0)},inoremap:function(e,t){this.map(e,t,"insert",!0)},nnoremap:function(e,t){this.map(e,t,"normal",!0)},vnoremap:function(e,t){this.map(e,t,"visual",!0)},onoremap:function(e,t){this.map(e,t,"operatorPending",!0)},unmap:function(e,t,r){var n=t.args;(!n||n.length<1||!ye.unmap(n[0],r))&&e&&Q(e,"No such mapping: "+t.input)},mapclear:function(e,t){ke.mapclear()},imapclear:function(e,t){ke.mapclear("insert")},nmapclear:function(e,t){ke.mapclear("normal")},vmapclear:function(e,t){ke.mapclear("visual")},omapclear:function(e,t){ke.mapclear("operatorPending")},move:function(e,t){je.processCommand(e,e.state.vim,{keys:"",type:"motion",motion:"moveToLineOrEdgeOfDocument",motionArgs:{forward:!1,explicitRepeat:!0,linewise:!0},repeatOverride:t.line+1})},set:function(e,t){var r=t.args,n=t.setCfg||{};if(!r||r.length<1){e&&Q(e,"Invalid mapping: "+t.input);return}var o=r[0].split("="),a=o.shift()||"",c=o.length>0?o.join("="):void 0,u=!1,h=!1;if(a.charAt(a.length-1)=="?"){if(c)throw Error("Trailing characters: "+t.argString);a=a.substring(0,a.length-1),u=!0}else a.charAt(a.length-1)=="!"&&(a=a.substring(0,a.length-1),h=!0);c===void 0&&a.substring(0,2)=="no"&&(a=a.substring(2),c=!1);var p=be[a]&&be[a].type=="boolean";if(p&&(h?c=!pe(a,e,n):c==null&&(c=!0)),!p&&c===void 0||u){var v=pe(a,e,n);v instanceof Error?Q(e,v.message):v===!0||v===!1?Q(e," "+(v?"":"no")+a):Q(e," "+a+"="+v)}else{var y=Te(a,c,e,n);y instanceof Error&&Q(e,y.message)}},setlocal:function(e,t){t.setCfg={scope:"local"},this.set(e,t)},setglobal:function(e,t){t.setCfg={scope:"global"},this.set(e,t)},registers:function(e,t){var r=t.args,n=M.registerController.registers,o=`----------Registers----------
22
-
23
- `;if(r)for(var u=r.join(""),h=0;h<u.length;h++){var a=u.charAt(h);if(M.registerController.isValidRegister(a)){var p=n[a]||new Ie;o+='"'+a+" "+p.toString()+`
24
- `}}else for(var a in n){var c=n[a].toString();c.length&&(o+='"'+a+" "+c+`
25
- `)}Q(e,o,!0)},marks:function(e,t){var r=t.args,n=e.state.vim.marks,o=`-----------Marks-----------
26
- mark line col
27
-
28
- `;if(r)for(var u=r.join(""),h=0;h<u.length;h++){var a=u.charAt(h),c=n[a]&&n[a].find();c&&(o+=a+" "+c.line+" "+c.ch+`
29
- `)}else for(var a in n){var c=n[a]&&n[a].find();c&&(o+=a+" "+c.line+" "+c.ch+`
30
- `)}Q(e,o,!0)},sort:function(e,t){var r,n,o,a,c,u;function h(){if(t.argString){var z=new s.StringStream(t.argString);if(z.eat("!")&&(r=!0),z.eol())return;if(!z.eatSpace())return"Invalid arguments";var V=z.match(/([dinuoxr]+)?\s*(\/.+\/)?\s*/);if(!V||!z.eol())return"Invalid arguments";if(V[1]){u=V[1].indexOf("r")!=-1,n=V[1].indexOf("i")!=-1,o=V[1].indexOf("u")!=-1;var Ce=V[1].indexOf("d")!=-1||V[1].indexOf("n")!=-1,ue=V[1].indexOf("x")!=-1,he=V[1].indexOf("o")!=-1;if(Number(Ce)+Number(ue)+Number(he)>1)return"Invalid arguments";a=Ce&&"decimal"||ue&&"hex"||he&&"octal"}V[2]&&(c=new RegExp(V[2].substr(1,V[2].length-2),n?"i":""))}}var p=h();if(p){Q(e,p+": "+t.argString);return}var v=t.line||e.firstLine(),y=t.lineEnd||t.line||e.lastLine();if(v==y)return;var C=new i(v,0),k=new i(y,de(e,y)),m=e.getRange(C,k).split(`
31
- `),b=a=="decimal"?/(-?)([\d]+)/:a=="hex"?/(-?)(?:0x)?([0-9a-f]+)/i:a=="octal"?/([0-7]+)/:null,E=a=="decimal"?10:a=="hex"?16:a=="octal"?8:void 0,N=[],T=[];if(a||c)for(var I=0;I<m.length;I++){var F=c?m[I].match(c):null;F&&F.index!=null&&!u&&(F[0]=m[I].slice(F.index+F[0].length)),F&&F[0]!=""?N.push(F):b&&b.exec(m[I])?N.push(m[I]):T.push(m[I])}else T=m;function W(z,V){if(r){var Ce;Ce=z,z=V,V=Ce}n&&(z=z.toLowerCase(),V=V.toLowerCase());var ue=b&&b.exec(z),he=b&&b.exec(V);if(!ue||!he)return z<V?-1:1;var Ue=parseInt((ue[1]+ue[2]).toLowerCase(),E),Rt=parseInt((he[1]+he[2]).toLowerCase(),E);return Ue-Rt}function ae(z,V){if(r){var Ce;Ce=z,z=V,V=Ce}return n&&(z[0]=z[0].toLowerCase(),V[0]=V[0].toLowerCase()),z[0]<V[0]?-1:1}if(N.sort(c?ae:W),c)for(var I=0;I<N.length;I++)N[I]=N[I].input;else a||T.sort(W);if(m=r?N.concat(T):T.concat(N),o){var X=m,fe;m=[];for(var I=0;I<X.length;I++)X[I]!=fe&&m.push(X[I]),fe=X[I]}e.replaceRange(m.join(`
32
- `),C,k)},vglobal:function(e,t){this.global(e,t)},normal:function(e,t){var r=!1,n=t.argString;if(n&&n[0]=="!"&&(n=n.slice(1),r=!0),n=n.trimStart(),!n){Q(e,"Argument is required.");return}var o=t.line;if(typeof o=="number")for(var a=isNaN(t.lineEnd)?o:t.lineEnd,c=o;c<=a;c++)e.setCursor(c,0),rt(e,t.argString.trimStart(),{noremap:r}),e.state.vim.insertMode&&He(e,!0);else rt(e,t.argString.trimStart(),{noremap:r}),e.state.vim.insertMode&&He(e,!0)},global:function(e,t){var r=t.argString;if(!r){Q(e,"Regular Expression missing from global");return}var n=t.commandName[0]==="v";r[0]==="!"&&t.commandName[0]==="g"&&(n=!0,r=r.slice(1));var o=t.line!==void 0?t.line:e.firstLine(),a=t.lineEnd||t.line||e.lastLine(),c=Vn(r),u=r,h="";if(c&&c.length&&(u=c[0],h=c.slice(1,c.length).join("/")),u)try{it(e,u,!0,!0)}catch{Q(e,"Invalid regex: "+u);return}for(var p=Ee(e).getQuery(),v=[],y=o;y<=a;y++){var C=e.getLine(y),k=p.test(C);k!==n&&v.push(h?e.getLineHandle(y):C)}if(!h){Q(e,v.join(`
33
- `));return}var m=0,b=function(){if(m<v.length){var E=v[m++],N=e.getLineNumber(E);if(N==null){b();return}var T=N+1+h;ye.processCommand(e,T,{callback:b})}else e.releaseLineHandles&&e.releaseLineHandles()};b()},substitute:function(e,t){if(!e.getSearchCursor)throw new Error("Search feature not available. Requires searchcursor.js or any other getSearchCursor implementation.");var r=t.argString,n=r?dr(r,r[0]):[],o="",a="",c,u,h,p=!1,v=!1;if(n&&n.length)o=n[0],pe("pcre")&&o!==""&&(o=new RegExp(o).source),a=n[1],a!==void 0&&(pe("pcre")?a=zn(a.replace(/([^\\])&/g,"$1$$&")):a=Un(a),M.lastSubstituteReplacePart=a),c=n[2]?n[2].split(" "):[];else if(r&&r.length){Q(e,"Substitutions should be of the form :s/pattern/replace/");return}if(c&&(u=c[0],h=parseInt(c[1]),u&&(u.indexOf("c")!=-1&&(p=!0),u.indexOf("g")!=-1&&(v=!0),pe("pcre")?o=o+"/"+u:o=o.replace(/\//g,"\\/")+"/"+u)),o)try{it(e,o,!0,!0)}catch{Q(e,"Invalid regex: "+o);return}if(a=a||M.lastSubstituteReplacePart,a===void 0){Q(e,"No previous substitute regular expression");return}var y=Ee(e),C=y.getQuery(),k=t.line!==void 0?t.line:e.getCursor().line,m=t.lineEnd||k;k==e.firstLine()&&m==e.lastLine()&&(m=1/0),h&&(k=m,m=k+h-1);var b=ve(e,new i(k,0)),E=e.getSearchCursor(C,b);Gn(e,p,v,k,m,E,C,a,t.callback)},startinsert:function(e,t){rt(e,t.argString=="!"?"A":"i",{})},redo:s.commands.redo,undo:s.commands.undo,write:function(e){s.commands.save?s.commands.save(e):e.save&&e.save()},nohlsearch:function(e){Ye(e)},yank:function(e,t){var r=t.selectionLine,n=isNaN(t.selectionLineEnd)?r:t.selectionLineEnd;if(n<r){var o=n;n=r,r=o}var a=e.getRange(new i(r,0),new i(n+1,0)),c=t.args&&t.args[0]?t.args[0]:"0";M.registerController.pushText(c,"yank",a,!0,!1),Q(e,n+1-r+" lines yanked"+(c?' into "'+c:""),!1,1500)},put:function(e,t,r){var n={after:!0,isEdit:!0,matchIndent:!!r,repeat:1,lineWise:!0,registerName:""},o=t.args||[];o[0]=="!"&&(n.after=!1,o.shift()),o[0]&&(n.registerName=o[0]);var a=t.selectionLine;a!=null&&e.setCursor(new i(a,0)),We.paste(e,n,e.state.vim)},iput:function(e,t){this.put(e,t,!0)},delete:function(e,t){var r=t.selectionLine,n=isNaN(t.selectionLineEnd)?r:t.selectionLineEnd;wt.delete(e,{linewise:!0},[{anchor:new i(r,0),head:new i(n+1,0)}])},join:function(e,t){var r=t.selectionLine,n=isNaN(t.selectionLineEnd)?r:t.selectionLineEnd;e.setCursor(new i(r,0)),We.joinLines(e,{repeat:n-r},e.state.vim)},delmarks:function(e,t){if(!t.argString||!xt(t.argString)){Q(e,"Argument required");return}for(var r=e.state.vim,n=new s.StringStream(xt(t.argString));!n.eol();){n.eatSpace();var o=n.pos;if(!n.match(/[a-zA-Z]/,!1)){Q(e,"Invalid argument: "+t.argString.substring(o));return}var a=n.next();if(n.match("-",!0)){if(!n.match(/[a-zA-Z]/,!1)){Q(e,"Invalid argument: "+t.argString.substring(o));return}var c=a,u=n.next();if(c&&u&&H(c)==H(u)){var h=c.charCodeAt(0),p=u.charCodeAt(0);if(h>=p){Q(e,"Invalid argument: "+t.argString.substring(o));return}for(var v=0;v<=p-h;v++){var y=String.fromCharCode(h+v);delete r.marks[y]}}else{Q(e,"Invalid argument: "+c+"-");return}}else a&&delete r.marks[a]}}},ye=new Xn;ke.defineEx("version","ve",e=>{Q(e,"Codemirror-vim version: <DEV>")});function Gn(e,t,r,n,o,a,c,u,h){e.state.vim.exMode=!0;var p=!1,v=0,y,C,k;function m(){e.operation(function(){for(;!p;)b(),N();T()})}function b(){var F="",W=a.match||a.pos&&a.pos.match;if(W)F=u.replace(/\$(\d{1,3}|[$&])/g,function(fe,z){if(z=="$")return"$";if(z=="&")return W[0];for(var V=z;parseInt(V)>=W.length&&V.length>0;)V=V.slice(0,V.length-1);return V?W[V]+z.slice(V.length,z.length):fe});else{var ae=e.getRange(a.from(),a.to());F=ae.replace(c,u)}var X=a.to().line;a.replace(F),C=a.to().line,o+=C-X,k=C<X}function E(){var F=y&&Y(a.to()),W=a.findNext();return W&&!W[0]&&F&&Le(a.from(),F)&&(W=a.findNext()),W&&v++,W}function N(){for(;E()&&Yn(a.from(),n,o);)if(!(!r&&a.from().line==C&&!k)){e.scrollIntoView(a.from(),30),e.setSelection(a.from(),a.to()),y=a.from(),p=!1;return}p=!0}function T(F){if(F&&F(),e.focus(),y){e.setCursor(y);var W=e.state.vim;W.exMode=!1,W.lastHPos=W.lastHSPos=y.ch}h?h():p&&Q(e,(v?"Found "+v+" matches":"No matches found")+" for pattern: "+c+(pe("pcre")?" (set nopcre to use Vim regexps)":""))}function I(F,W,ae){s.e_stop(F);var X=nt(F);switch(X){case"y":b(),N();break;case"n":N();break;case"a":var fe=h;h=void 0,e.operation(m),h=fe;break;case"l":b();case"q":case"<Esc>":case"<C-c>":case"<C-[>":T(ae);break}return p&&T(ae),!0}if(N(),p){Q(e,"No matches for "+c+(pe("pcre")?" (set nopcre to use vim regexps)":""));return}if(!t){m(),h&&h();return}dt(e,{prefix:Oe("span","replace with ",Oe("strong",u)," (y/n/a/q/l)"),onKeyDown:I})}function He(e,t){var r=e.state.vim,n=M.macroModeState,o=M.registerController.getRegister("."),a=n.isPlaying,c=n.lastInsertModeChanges;a||(e.off("change",wr),r.insertEnd&&r.insertEnd.clear(),r.insertEnd=void 0,s.off(e.getInputField(),"keydown",br)),!a&&r.insertModeRepeat&&r.insertModeRepeat>1&&(Mr(e,r,r.insertModeRepeat-1,!0),r.lastEditInputState.repeatOverride=r.insertModeRepeat),delete r.insertModeRepeat,r.insertMode=!1,t||e.setCursor(e.getCursor().line,e.getCursor().ch-1),e.setOption("keyMap","vim"),e.setOption("disableInput",!0),e.toggleOverwrite(!1),o.setText(c.changes.join("")),s.signal(e,"vim-mode-change",{mode:"normal"}),n.isRecording&&oi(n)}function Et(e){f.unshift(e),e.keys&&ei(e.keys)}function ei(e){e.split(/(<(?:[CSMA]-)*\w+>|.)/i).forEach(function(t){t&&(d[t]||(d[t]=0),d[t]++)})}function ti(e){e.split(/(<(?:[CSMA]-)*\w+>|.)/i).forEach(function(t){d[t]&&d[t]--})}function ri(e,t,r,n,o){var a={keys:e,type:t};a[t]=r,a[t+"Args"]=n;for(var c in o)a[c]=o[c];Et(a)}Ke("insertModeEscKeysTimeout",200,"number");function ni(e,t,r,n){var o=M.registerController.getRegister(n);if(n==":"){o.keyBuffer[0]&&ye.processCommand(e,o.keyBuffer[0]),r.isPlaying=!1;return}var a=o.keyBuffer,c=0;r.isPlaying=!0,r.replaySearchQueries=o.searchQueries.slice(0);for(var u=0;u<a.length;u++)for(var h=a[u],p,v,y=/<(?:[CSMA]-)*\w+>|./gi;p=y.exec(h);)if(v=p[0],ke.handleKey(e,v,"macro"),t.insertMode){var C=o.insertModeChanges[c++].changes;M.macroModeState.lastInsertModeChanges.changes=C,Ar(e,C,1),He(e)}r.isPlaying=!1}function ii(e,t){if(!e.isPlaying){var r=e.latestRegister,n=M.registerController.getRegister(r);n&&n.pushText(t)}}function oi(e){if(!e.isPlaying){var t=e.latestRegister,r=M.registerController.getRegister(t);r&&r.pushInsertModeChanges&&r.pushInsertModeChanges(e.lastInsertModeChanges)}}function ai(e,t){if(!e.isPlaying){var r=e.latestRegister,n=M.registerController.getRegister(r);n&&n.pushSearchQuery&&n.pushSearchQuery(t)}}function wr(e,t){var r=M.macroModeState,n=r.lastInsertModeChanges;if(!r.isPlaying)for(var o=e.state.vim;t;){if(n.expectCursorActivityForChange=!0,n.ignoreCount>1)n.ignoreCount--;else if(t.origin=="+input"||t.origin=="paste"||t.origin===void 0){var a=e.listSelections().length;a>1&&(n.ignoreCount=a);var c=t.text.join(`
34
- `);if(n.maybeReset&&(n.changes=[],n.maybeReset=!1),c)if(e.state.overwrite&&!/\n/.test(c))n.changes.push([c]);else{if(c.length>1){var u=o&&o.insertEnd&&o.insertEnd.find(),h=e.getCursor();if(u&&u.line==h.line){var p=u.ch-h.ch;p>0&&p<c.length&&(n.changes.push([c,p]),c="")}}c&&n.changes.push(c)}}t=t.next}}function xr(e){var t=e.state.vim;if(t.insertMode){var r=M.macroModeState;if(r.isPlaying)return;var n=r.lastInsertModeChanges;n.expectCursorActivityForChange?n.expectCursorActivityForChange=!1:(n.maybeReset=!0,t.insertEnd&&t.insertEnd.clear(),t.insertEnd=e.setBookmark(e.getCursor(),{insertLeft:!0}))}else e.curOp?.isVimOp||Sr(e,t)}function Sr(e,t){var r=e.getCursor("anchor"),n=e.getCursor("head");if(t.visualMode&&!e.somethingSelected()?Be(e,!1):!t.visualMode&&!t.insertMode&&e.somethingSelected()&&(t.visualMode=!0,t.visualLine=!1,s.signal(e,"vim-mode-change",{mode:"visual"})),t.visualMode){var o=te(n,r)?0:-1,a=te(n,r)?-1:0;n=oe(n,0,o),r=oe(r,0,a),t.sel={anchor:r,head:n},$e(e,t,"<",ge(n,r)),$e(e,t,">",Fe(n,r))}else t.insertMode||(t.lastHPos=e.getCursor().ch)}function br(e){var t=M.macroModeState,r=t.lastInsertModeChanges,n=s.keyName?s.keyName(e):e.key;n&&(n.indexOf("Delete")!=-1||n.indexOf("Backspace")!=-1)&&(r.maybeReset&&(r.changes=[],r.maybeReset=!1),r.changes.push(new q(n,e)))}function Mr(e,t,r,n){var o=M.macroModeState;o.isPlaying=!0;var a=t.lastEditActionCommand,c=t.inputState;function u(){a?je.processAction(e,t,a):je.evalInput(e,t)}function h(v){if(o.lastInsertModeChanges.changes.length>0){v=t.lastEditActionCommand?v:1;var y=o.lastInsertModeChanges;Ar(e,y.changes,v)}}if(t.inputState=t.lastEditInputState,a&&a.interlaceInsertRepeat)for(var p=0;p<r;p++)u(),h(1);else n||u(),h(r);t.inputState=c,t.insertMode&&!n&&He(e),o.isPlaying=!1}function Lr(e,t){s.lookupKey(t,"vim-insert",function(n){return typeof n=="string"?s.commands[n](e):n(e),!0})}function Ar(e,t,r){var n=e.getCursor("head"),o=M.macroModeState.lastInsertModeChanges.visualBlock;o&&(nr(e,n,o+1),r=e.listSelections().length,e.setCursor(n));for(var a=0;a<r;a++){o&&e.setCursor(oe(n,a,0));for(var c=0;c<t.length;c++){var u=t[c];if(u instanceof q)Lr(e,u.keyName);else if(typeof u=="string")e.replaceSelection(u);else{var h=e.getCursor(),p=oe(h,0,u[0].length-(u[1]||0));e.replaceRange(u[0],h,u[1]?h:p),e.setCursor(p)}}}o&&e.setCursor(oe(n,0,1))}function Ot(e){var t=new e.constructor;return Object.keys(e).forEach(function(r){if(r!="insertEnd"){var n=e[r];Array.isArray(n)?n=n.slice():n&&typeof n=="object"&&n.constructor!=Object&&(n=Ot(n)),t[r]=n}}),e.sel&&(t.sel={head:e.sel.head&&Y(e.sel.head),anchor:e.sel.anchor&&Y(e.sel.anchor)}),t}function si(e,t,r){var a=ee(e),n=e,o=!1,a=ke.maybeInitVimState_(n),c=a.visualBlock||a.wasInVisualBlock;if(n.state.closeVimNotification){var u=n.state.closeVimNotification;if(n.state.closeVimNotification=null,u(),t=="<CR>")return ce(n),!0}var h=n.isInMultiSelectMode();if(a.wasInVisualBlock&&!h?a.wasInVisualBlock=!1:h&&a.visualBlock&&(a.wasInVisualBlock=!0),t=="<Esc>"&&!a.insertMode&&!a.visualMode&&h&&a.status=="<Esc>")ce(n);else if(c||!h||n.inVirtualSelectionMode)o=ke.handleKey(n,t,r);else{var p=Ot(a),v=a.inputState.changeQueueList||[];n.operation(function(){n.curOp&&(n.curOp.isVimOp=!0);var y=0;n.forEachSelection(function(){n.state.vim.inputState.changeQueue=v[y];var C=n.getCursor("head"),k=n.getCursor("anchor"),m=te(C,k)?0:-1,b=te(C,k)?-1:0;C=oe(C,0,m),k=oe(k,0,b),n.state.vim.sel.head=C,n.state.vim.sel.anchor=k,o=ke.handleKey(n,t,r),n.virtualSelection&&(v[y]=n.state.vim.inputState.changeQueue,n.state.vim=Ot(p)),y++}),n.curOp?.cursorActivity&&!o&&(n.curOp.cursorActivity=!1),n.state.vim=a,a.inputState.changeQueueList=v,a.inputState.changeQueue=null},!0)}return o&&!a.visualMode&&!a.insertMode&&a.visualMode!=n.somethingSelected()&&Sr(n,a),o}return ne(),ke}function we(s,i){var l=i.ch,f=i.line+1;f<1&&(f=1,l=0),f>s.lines&&(f=s.lines,l=Number.MAX_VALUE);var d=s.line(f);return Math.min(d.from+Math.max(0,l),d.to)}function Ae(s,i){let l=s.lineAt(i);return{line:l.number-1,ch:i-l.from}}class De{constructor(i,l){this.line=i,this.ch=l}}function Yr(s,i,l){if(s.addEventListener)s.addEventListener(i,l,!1);else{var f=s._handlers||(s._handlers={});f[i]=(f[i]||[]).concat(l)}}function Xr(s,i,l){if(s.removeEventListener)s.removeEventListener(i,l,!1);else{var f=s._handlers,d=f&&f[i];if(d){var g=d.indexOf(l);g>-1&&(f[i]=d.slice(0,g).concat(d.slice(g+1)))}}}function Gr(s,i,...l){var f,d=(f=s._handlers)===null||f===void 0?void 0:f[i];if(d)for(var g=0;g<d.length;++g)d[g](...l)}function Br(s,...i){if(s)for(var l=0;l<s.length;++l)s[l](...i)}let _t;try{_t=new RegExp("[\\w\\p{Alphabetic}\\p{Number}_]","u")}catch{_t=/[\w]/}function at(s,i){var l=s.cm6;if(!l.state.readOnly){var f="input.type.compose";if(s.curOp&&(s.curOp.lastChange||(f="input.type.compose.start")),i.annotations)try{i.annotations.some(function(d){d.value=="input"&&(d.value=f)})}catch(d){console.error(d)}else i.userEvent=f;return l.dispatch(i)}}function Pr(s,i){var l;s.curOp&&(s.curOp.$changeStart=void 0),(i?Mi:Li)(s.cm6);let f=(l=s.curOp)===null||l===void 0?void 0:l.$changeStart;f!=null&&s.cm6.dispatch({selection:{anchor:f}})}var io={Left:s=>Xe(s.cm6,{key:"Left"},"editor"),Right:s=>Xe(s.cm6,{key:"Right"},"editor"),Up:s=>Xe(s.cm6,{key:"Up"},"editor"),Down:s=>Xe(s.cm6,{key:"Down"},"editor"),Backspace:s=>Xe(s.cm6,{key:"Backspace"},"editor"),Delete:s=>Xe(s.cm6,{key:"Delete"},"editor")};class U{openDialog(i,l,f){return ao(this,i,l,f)}openNotification(i,l){return oo(this,i,l)}constructor(i){this.state={},this.marks=Object.create(null),this.$mid=0,this.options={},this._handlers={},this.$lastChangeEndOffset=0,this.virtualSelection=null,this.cm6=i,this.onChange=this.onChange.bind(this),this.onSelectionChange=this.onSelectionChange.bind(this)}on(i,l){Yr(this,i,l)}off(i,l){Xr(this,i,l)}signal(i,l,f){Gr(this,i,l,f)}indexFromPos(i){return we(this.cm6.state.doc,i)}posFromIndex(i){return Ae(this.cm6.state.doc,i)}foldCode(i){let l=this.cm6,f=l.state.selection.ranges,d=this.cm6.state.doc,g=we(d,i),w=Se.create([Se.range(g,g)],0).ranges;l.state.selection.ranges=w,fi(l),l.state.selection.ranges=f}firstLine(){return 0}lastLine(){return this.cm6.state.doc.lines-1}lineCount(){return this.cm6.state.doc.lines}setCursor(i,l){typeof i=="object"&&(l=i.ch,i=i.line);var f=we(this.cm6.state.doc,{line:i,ch:l||0});this.cm6.dispatch({selection:{anchor:f}},{scrollIntoView:!this.curOp}),this.curOp&&!this.curOp.isVimOp&&this.onBeforeEndOperation()}getCursor(i){var l=this.cm6.state.selection.main,f=i=="head"||!i?l.head:i=="anchor"?l.anchor:i=="start"?l.from:i=="end"?l.to:null;if(f==null)throw new Error("Invalid cursor type");return this.posFromIndex(f)}listSelections(){var i=this.cm6.state.doc;return this.cm6.state.selection.ranges.map(l=>({anchor:Ae(i,l.anchor),head:Ae(i,l.head)}))}setSelections(i,l){var f=this.cm6.state.doc,d=i.map(g=>{var w=we(f,g.head),x=we(f,g.anchor);return w==x?Se.cursor(w,1):Se.range(x,w)});this.cm6.dispatch({selection:Se.create(d,l)})}setSelection(i,l,f){this.setSelections([{anchor:i,head:l}],0),f&&f.origin=="*mouse"&&this.onBeforeEndOperation()}getLine(i){var l=this.cm6.state.doc;return i<0||i>=l.lines?"":this.cm6.state.doc.line(i+1).text}getLineHandle(i){return this.$lineHandleChanges||(this.$lineHandleChanges=[]),{row:i,index:this.indexFromPos(new De(i,0))}}getLineNumber(i){var l=this.$lineHandleChanges;if(!l)return null;for(var f=i.index,d=0;d<l.length;d++)if(f=l[d].changes.mapPos(f,1,Jr.TrackAfter),f==null)return null;var g=this.posFromIndex(f);return g.ch==0?g.line:null}releaseLineHandles(){this.$lineHandleChanges=void 0}getRange(i,l){var f=this.cm6.state.doc;return this.cm6.state.sliceDoc(we(f,i),we(f,l))}replaceRange(i,l,f,d){f||(f=l);var g=this.cm6.state.doc,w=we(g,l),x=we(g,f);at(this,{changes:{from:w,to:x,insert:i}})}replaceSelection(i){at(this,this.cm6.state.replaceSelection(i))}replaceSelections(i){var l=this.cm6.state.selection.ranges,f=l.map((d,g)=>({from:d.from,to:d.to,insert:i[g]||""}));at(this,{changes:f})}getSelection(){return this.getSelections().join(`
35
- `)}getSelections(){var i=this.cm6;return i.state.selection.ranges.map(l=>i.state.sliceDoc(l.from,l.to))}somethingSelected(){return this.cm6.state.selection.ranges.some(i=>!i.empty)}getInputField(){return this.cm6.contentDOM}clipPos(i){var l=this.cm6.state.doc,f=i.ch,d=i.line+1;d<1&&(d=1,f=0),d>l.lines&&(d=l.lines,f=Number.MAX_VALUE);var g=l.line(d);return f=Math.min(Math.max(0,f),g.to-g.from),new De(d-1,f)}getValue(){return this.cm6.state.doc.toString()}setValue(i){var l=this.cm6;return l.dispatch({changes:{from:0,to:l.state.doc.length,insert:i},selection:Se.range(0,0)})}focus(){return this.cm6.focus()}blur(){return this.cm6.contentDOM.blur()}defaultTextHeight(){return this.cm6.defaultLineHeight}findMatchingBracket(i,l){var f=this.cm6.state,d=we(f.doc,i),g=Er(f,d+1,-1);return g&&g.end?{to:Ae(f.doc,g.end.from)}:(g=Er(f,d,1),g&&g.end?{to:Ae(f.doc,g.end.from)}:{to:void 0})}scanForBracket(i,l,f,d){return co(this,i,l,f,d)}indentLine(i,l){l?this.indentMore():this.indentLess()}indentMore(){ui(this.cm6)}indentLess(){hi(this.cm6)}execCommand(i){if(U.commands.hasOwnProperty(i))U.commands[i](this);else if(i=="goLineLeft")di(this.cm6);else if(i=="goLineRight"){pi(this.cm6);let l=this.cm6.state,f=l.selection.main.head;f<l.doc.length&&l.sliceDoc(f,f+1)!==`
36
- `&&vi(this.cm6)}else console.log(i+" is not implemented")}setBookmark(i,l){var f=l?.insertLeft?1:-1,d=this.indexFromPos(i),g=new ho(this,d,f);return g}addOverlay({query:i}){let l=new gi({regexp:!0,search:i.source,caseSensitive:!/i/.test(i.flags)});if(l.valid){l.forVim=!0,this.cm6Query=l;let f=Bt.of(l);return this.cm6.dispatch({effects:f}),l}}removeOverlay(i){if(!this.cm6Query)return;this.cm6Query.forVim=!1;let l=Bt.of(this.cm6Query);this.cm6.dispatch({effects:l})}getSearchCursor(i,l){var f=this,d=null,g=null,w=!1;l.ch==null&&(l.ch=Number.MAX_VALUE);var x=we(f.cm6.state.doc,l),S=i.source.replace(/(\\.|{(?:\d+(?:,\d*)?|,\d+)})|[{}]/g,function(L,O){return O||"\\"+L});function B(L,O=0,P=L.length){return new yi(L,S,{ignoreCase:i.ignoreCase},O,P)}function R(L){var O=f.cm6.state.doc;if(L>O.length)return null;let P=B(O,L).next();return P.done?null:P.value}var A=1e4;function _(L,O){var P=f.cm6.state.doc;for(let $=1;;$++){let K=Math.max(L,O-$*A),D=B(P,K,O),H=null;for(;!D.next().done;)H=D.value;if(H&&(K==L||H.from>K+10))return H;if(K==L)return null}}return{findNext:function(){return this.find(!1)},findPrevious:function(){return this.find(!0)},find:function(L){var O=f.cm6.state.doc;if(L){let P=d?w?d.to-1:d.from:x;d=_(0,P)}else{let P=d?w?d.to+1:d.to:x;d=R(P)}return g=d&&{from:Ae(O,d.from),to:Ae(O,d.to),match:d.match},w=d?d.from==d.to:!1,d&&d.match},from:function(){return g?.from},to:function(){return g?.to},replace:function(L){d&&(at(f,{changes:{from:d.from,to:d.to,insert:L}}),d.to=d.from+L.length,g&&(g.to=Ae(f.cm6.state.doc,d.to)))},get match(){return g&&g.match}}}findPosV(i,l,f,d){let{cm6:g}=this;const w=g.state.doc;let x=f=="page"?g.dom.clientHeight:0;const S=we(w,i);let B=Se.cursor(S,1,void 0,d),R=Math.round(Math.abs(l));for(let _=0;_<R;_++)f=="page"?B=g.moveVertically(B,l>0,x):f=="line"&&(B=g.moveVertically(B,l>0));let A=Ae(w,B.head);return(l<0&&B.head==0&&d!=0&&i.line==0&&i.ch!=0||l>0&&B.head==w.length&&A.ch!=d&&i.line==A.line)&&(A.hitSide=!0),A}charCoords(i,l){var f=this.cm6.contentDOM.getBoundingClientRect(),d=we(this.cm6.state.doc,i),g=this.cm6.coordsAtPos(d),w=-f.top;return{left:(g?.left||0)-f.left,top:(g?.top||0)+w,bottom:(g?.bottom||0)+w}}coordsChar(i,l){var f=this.cm6.contentDOM.getBoundingClientRect(),d=this.cm6.posAtCoords({x:i.left+f.left,y:i.top+f.top})||0;return Ae(this.cm6.state.doc,d)}getScrollInfo(){var i=this.cm6.scrollDOM;return{left:i.scrollLeft,top:i.scrollTop,height:i.scrollHeight,width:i.scrollWidth,clientHeight:i.clientHeight,clientWidth:i.clientWidth}}scrollTo(i,l){i!=null&&(this.cm6.scrollDOM.scrollLeft=i),l!=null&&(this.cm6.scrollDOM.scrollTop=l)}scrollIntoView(i,l){if(i){var f=this.indexFromPos(i);this.cm6.dispatch({effects:se.scrollIntoView(f)})}else this.cm6.dispatch({scrollIntoView:!0,userEvent:"scroll"})}getWrapperElement(){return this.cm6.dom}getMode(){return{name:this.getOption("mode")}}setSize(i,l){this.cm6.dom.style.width=i+4+"px",this.cm6.dom.style.height=l+"px",this.refresh()}refresh(){this.cm6.measure()}destroy(){this.removeOverlay()}getLastEditEnd(){return this.posFromIndex(this.$lastChangeEndOffset)}onChange(i){this.$lineHandleChanges&&this.$lineHandleChanges.push(i);for(let f in this.marks)this.marks[f].update(i.changes);this.virtualSelection&&(this.virtualSelection.ranges=this.virtualSelection.ranges.map(f=>f.map(i.changes)));var l=this.curOp=this.curOp||{};i.changes.iterChanges((f,d,g,w,x)=>{(l.$changeStart==null||l.$changeStart>g)&&(l.$changeStart=g),this.$lastChangeEndOffset=w;var S={text:x.toJSON()};l.lastChange?l.lastChange.next=l.lastChange=S:l.lastChange=l.change=S},!0),l.changeHandlers||(l.changeHandlers=this._handlers.change&&this._handlers.change.slice())}onSelectionChange(){var i=this.curOp=this.curOp||{};i.cursorActivityHandlers||(i.cursorActivityHandlers=this._handlers.cursorActivity&&this._handlers.cursorActivity.slice()),this.curOp.cursorActivity=!0}operation(i,l){this.curOp||(this.curOp={$d:0}),this.curOp.$d++;try{var f=i()}finally{this.curOp&&(this.curOp.$d--,this.curOp.$d||this.onBeforeEndOperation())}return f}onBeforeEndOperation(){var i=this.curOp,l=!1;i&&(i.change&&Br(i.changeHandlers,this,i.change),i&&i.cursorActivity&&(Br(i.cursorActivityHandlers,this,null),i.isVimOp&&(l=!0)),this.curOp=null),l&&this.scrollIntoView()}moveH(i,l){if(l=="char"){var f=this.getCursor();this.setCursor(f.line,f.ch+i)}}setOption(i,l){switch(i){case"keyMap":this.state.keyMap=l;break;case"textwidth":this.state.textwidth=l;break}}getOption(i){switch(i){case"firstLineNumber":return 1;case"tabSize":return this.cm6.state.tabSize||4;case"readOnly":return this.cm6.state.readOnly;case"indentWithTabs":return this.cm6.state.facet(Or)==" ";case"indentUnit":return this.cm6.state.facet(Or).length||2;case"textwidth":return this.state.textwidth;case"keyMap":return this.state.keyMap||"vim"}}toggleOverwrite(i){this.state.overwrite=i}getTokenTypeAt(i){var l,f=this.indexFromPos(i),d=Zr(this.cm6.state,f),g=d?.resolve(f),w=((l=g?.type)===null||l===void 0?void 0:l.name)||"";return/comment/i.test(w)?"comment":/string/i.test(w)?"string":""}overWriteSelection(i){var l=this.cm6.state.doc,f=this.cm6.state.selection,d=f.ranges.map(g=>{if(g.empty){var w=g.to<l.length?l.sliceString(g.from,g.to+1):"";if(w&&!/\n/.test(w))return Se.range(g.from,g.to+1)}return g});this.cm6.dispatch({selection:Se.create(d,f.mainIndex)}),this.replaceSelection(i)}isInMultiSelectMode(){return this.cm6.state.selection.ranges.length>1}virtualSelectionMode(){return!!this.virtualSelection}forEachSelection(i){var l=this.cm6.state.selection;this.virtualSelection=Se.create(l.ranges,l.mainIndex);for(var f=0;f<this.virtualSelection.ranges.length;f++){var d=this.virtualSelection.ranges[f];d&&(this.cm6.dispatch({selection:Se.create([d])}),i(),this.virtualSelection.ranges[f]=this.cm6.state.selection.ranges[0])}this.cm6.dispatch({selection:this.virtualSelection}),this.virtualSelection=null}hardWrap(i){return po(this,i)}}U.isMac=typeof navigator<"u"&&/Mac/.test(navigator.platform);U.Pos=De;U.StringStream=ki;U.commands={toggleLineComment:function(s){bi(s.cm6)},cursorCharLeft:function(s){Si(s.cm6)},redo:function(s){Pr(s,!1)},undo:function(s){Pr(s,!0)},newlineAndIndent:function(s){xi({state:s.cm6.state,dispatch:i=>at(s,i)})},indentAuto:function(s){wi(s.cm6)},newlineAndIndentContinueComment:void 0,save:void 0};U.isWordChar=function(s){return _t.test(s)};U.keys=io;U.addClass=function(s,i){};U.rmClass=function(s,i){};U.e_preventDefault=function(s){s.preventDefault()};U.e_stop=function(s){var i,l;(i=s?.stopPropagation)===null||i===void 0||i.call(s),(l=s?.preventDefault)===null||l===void 0||l.call(s)};U.lookupKey=function(i,l,f){var d=U.keys[i];!d&&/^Arrow/.test(i)&&(d=U.keys[i.slice(5)]),d&&f(d)};U.on=Yr;U.off=Xr;U.signal=Gr;U.findMatchingTag=fo;U.findEnclosingTag=uo;U.keyName=void 0;function en(s,i,l){var f=document.createElement("div");return f.appendChild(i),f}function tn(s,i){s.state.currentNotificationClose&&s.state.currentNotificationClose(),s.state.currentNotificationClose=i}function oo(s,i,l){tn(s,x);var f=en(s,i,l&&l.bottom),d=!1,g,w=l&&typeof l.duration<"u"?l.duration:5e3;function x(){d||(d=!0,clearTimeout(g),f.remove(),nn(s,f))}return f.onclick=function(S){S.preventDefault(),x()},rn(s,f),w&&(g=setTimeout(x,w)),x}function rn(s,i){var l=s.state.dialog;s.state.dialog=i,i.style.flex="1",i&&l!==i&&(l&&l.contains(document.activeElement)&&s.focus(),l&&l.parentElement?l.parentElement.replaceChild(i,l):l&&l.remove(),U.signal(s,"dialog"))}function nn(s,i){s.state.dialog==i&&(s.state.dialog=null,U.signal(s,"dialog"))}function ao(s,i,l,f){f||(f={}),tn(s,void 0);var d=en(s,i,f.bottom),g=!1;rn(s,d);function w(S){if(typeof S=="string")x.value=S;else{if(g)return;g=!0,nn(s,d),s.state.dialog||s.focus(),f.onClose&&f.onClose(d)}}var x=d.getElementsByTagName("input")[0];return x&&(f.value&&(x.value=f.value,f.selectValueOnOpen!==!1&&x.select()),f.onInput&&U.on(x,"input",function(S){f.onInput(S,x.value,w)}),f.onKeyUp&&U.on(x,"keyup",function(S){f.onKeyUp(S,x.value,w)}),U.on(x,"keydown",function(S){f&&f.onKeyDown&&f.onKeyDown(S,x.value,w)||(S.keyCode==13&&l&&l(x.value),(S.keyCode==27||f.closeOnEnter!==!1&&S.keyCode==13)&&(x.blur(),U.e_stop(S),w()))}),f.closeOnBlur!==!1&&U.on(x,"blur",function(){setTimeout(function(){document.activeElement!==x&&w()})}),x.focus()),w}var so={"(":")>",")":"(<","[":"]>","]":"[<","{":"}>","}":"{<","<":">>",">":"<<"};function lo(s){return s&&s.bracketRegex||/[(){}[\]]/}function co(s,i,l,f,d){for(var g=d&&d.maxScanLineLength||1e4,w=d&&d.maxScanLines||1e3,x=[],S=lo(d),B=l>0?Math.min(i.line+w,s.lastLine()+1):Math.max(s.firstLine()-1,i.line-w),R=i.line;R!=B;R+=l){var A=s.getLine(R);if(A){var _=l>0?0:A.length-1,L=l>0?A.length:-1;if(!(A.length>g))for(R==i.line&&(_=i.ch-(l<0?1:0));_!=L;_+=l){var O=A.charAt(_);if(S.test(O)){var P=so[O];if(P&&P.charAt(1)==">"==l>0)x.push(O);else if(x.length)x.pop();else return{pos:new De(R,_),ch:O}}}}}return R-l==(l>0?s.lastLine():s.firstLine())?!1:null}function fo(s,i){return null}function uo(s,i){var l,f,d=s.cm6.state,g=s.indexFromPos(i);if(g<d.doc.length){var w=d.sliceDoc(g,g+1);w=="<"&&g++}for(var x=Zr(d,g),S=x?.resolve(g)||null;S;){if(((l=S.firstChild)===null||l===void 0?void 0:l.type.name)=="OpenTag"&&((f=S.lastChild)===null||f===void 0?void 0:f.type.name)=="CloseTag")return{open:Dr(d.doc,S.firstChild),close:Dr(d.doc,S.lastChild)};S=S.parent}}function Dr(s,i){return{from:Ae(s,i.from),to:Ae(s,i.to)}}class ho{constructor(i,l,f){this.cm=i,this.id=i.$mid++,this.offset=l,this.assoc=f,i.marks[this.id]=this}clear(){delete this.cm.marks[this.id]}find(){return this.offset==null?null:this.cm.posFromIndex(this.offset)}update(i){this.offset!=null&&(this.offset=i.mapPos(this.offset,this.assoc,Jr.TrackDel))}}function po(s,i){for(var l,f=i.column||s.getOption("textwidth")||80,d=i.allowMerge!=!1,g=Math.min(i.from,i.to),w=Math.max(i.from,i.to);g<=w;){var x=s.getLine(g);if(x.length>f){var S=O(x,f,5);if(S){var B=(l=/^\s*/.exec(x))===null||l===void 0?void 0:l[0];s.replaceRange(`
37
- `+B,new De(g,S.start),new De(g,S.end))}w++}else if(d&&/\S/.test(x)&&g!=w){var R=s.getLine(g+1);if(R&&/\S/.test(R)){var A=x.replace(/\s+$/,""),_=R.replace(/^\s+/,""),L=A+" "+_,S=O(L,f,5);S&&S.start>A.length||L.length<f?(s.replaceRange(" ",new De(g,A.length),new De(g+1,R.length-_.length)),g--,w--):A.length<x.length&&s.replaceRange("",new De(g,A.length),new De(g,x.length))}}g++}return g;function O(P,$,K){if(!(P.length<$)){var D=P.slice(0,$),H=P.slice($),J=/^(?:(\s+)|(\S+)(\s+))/.exec(H),Z=/(?:(\s+)|(\s+)(\S+))$/.exec(D),me=0,le=0;if(Z&&!Z[2]&&(me=$-Z[1].length,le=$),J&&!J[2]&&(me||(me=$),le=$+J[1].length),me)return{start:me,end:le};if(Z&&Z[2]&&Z.index>K)return{start:Z.index,end:Z.index+Z[2].length};if(J&&J[2])return me=$+J[2].length,{start:me,end:me+J[3].length}}}}let Kt=mi||(function(){let s={cursorBlinkRate:1200};return function(){return s}})();class vo{constructor(i,l,f,d,g,w,x,S,B,R){this.left=i,this.top=l,this.height=f,this.fontFamily=d,this.fontSize=g,this.fontWeight=w,this.color=x,this.className=S,this.letter=B,this.partial=R}draw(){let i=document.createElement("div");return i.className=this.className,this.adjust(i),i}adjust(i){i.style.left=this.left+"px",i.style.top=this.top+"px",i.style.height=this.height+"px",i.style.lineHeight=this.height+"px",i.style.fontFamily=this.fontFamily,i.style.fontSize=this.fontSize,i.style.fontWeight=this.fontWeight,i.style.color=this.partial?"transparent":this.color,i.className=this.className,i.textContent=this.letter}eq(i){return this.left==i.left&&this.top==i.top&&this.height==i.height&&this.fontFamily==i.fontFamily&&this.fontSize==i.fontSize&&this.fontWeight==i.fontWeight&&this.color==i.color&&this.className==i.className&&this.letter==i.letter}}class go{constructor(i,l){this.view=i,this.rangePieces=[],this.cursors=[],this.cm=l,this.measureReq={read:this.readPos.bind(this),write:this.drawSel.bind(this)},this.cursorLayer=i.scrollDOM.appendChild(document.createElement("div")),this.cursorLayer.className="cm-cursorLayer cm-vimCursorLayer",this.cursorLayer.setAttribute("aria-hidden","true"),i.requestMeasure(this.measureReq),this.setBlinkRate()}setBlinkRate(){let l=Kt(this.cm.cm6.state).cursorBlinkRate;this.cursorLayer.style.animationDuration=l+"ms"}update(i){(i.selectionSet||i.geometryChanged||i.viewportChanged)&&(this.view.requestMeasure(this.measureReq),this.cursorLayer.style.animationName=this.cursorLayer.style.animationName=="cm-blink"?"cm-blink2":"cm-blink"),mo(i)&&this.setBlinkRate()}scheduleRedraw(){this.view.requestMeasure(this.measureReq)}readPos(){let{state:i}=this.view,l=[];for(let f of i.selection.ranges){let d=f==i.selection.main,g=wo(this.cm,this.view,f,d);g&&l.push(g)}return{cursors:l}}drawSel({cursors:i}){if(i.length!=this.cursors.length||i.some((l,f)=>!l.eq(this.cursors[f]))){let l=this.cursorLayer.children;if(l.length!==i.length){this.cursorLayer.textContent="";for(const f of i)this.cursorLayer.appendChild(f.draw())}else i.forEach((f,d)=>f.adjust(l[d]));this.cursors=i}}destroy(){this.cursorLayer.remove()}}function mo(s){return Kt(s.startState)!=Kt(s.state)}const yo={".cm-vimMode .cm-line":{"& ::selection":{backgroundColor:"transparent !important"},"&::selection":{backgroundColor:"transparent !important"},caretColor:"transparent !important"},".cm-fat-cursor":{position:"absolute",background:"#ff9696",border:"none",whiteSpace:"pre"},"&:not(.cm-focused) .cm-fat-cursor":{background:"none",outline:"solid 1px #ff9696",color:"transparent !important"}},Co=Qr.highest(se.theme(yo));function ko(s){let i=s.scrollDOM.getBoundingClientRect();return{left:(s.textDirection==Ci.LTR?i.left:i.right-s.scrollDOM.clientWidth)-s.scrollDOM.scrollLeft*s.scaleX,top:i.top-s.scrollDOM.scrollTop*s.scaleY}}function wo(s,i,l,f){var d,g,w,x;let S=l.head,B=!1,R=1,A=s.state.vim;if(A&&(!A.insertMode||s.state.overwrite)){if(B=!0,A.visualBlock&&!f)return null;l.anchor<l.head&&(S<i.state.doc.length&&i.state.sliceDoc(S,S+1))!=`
38
- `&&S--,s.state.overwrite?R=.2:A.status&&(R=.5)}if(B){let L=S<i.state.doc.length&&i.state.sliceDoc(S,S+1);L&&/[\uDC00-\uDFFF]/.test(L)&&S>1&&(S--,L=i.state.sliceDoc(S,S+1));let O=i.coordsAtPos(S,1);if(!O)return null;let P=ko(i),$=i.domAtPos(S),K=$?$.node:i.contentDOM;for(K instanceof Text&&$.offset>=K.data.length&&!((d=K.parentElement)===null||d===void 0)&&d.nextSibling&&(K=(g=K.parentElement)===null||g===void 0?void 0:g.nextSibling,$={node:K,offset:0});$&&$.node instanceof HTMLElement;)K=$.node,$={node:$.node.childNodes[$.offset],offset:0};if(!(K instanceof HTMLElement)){if(!K.parentNode)return null;K=K.parentNode}let D=getComputedStyle(K),H=O.left,J=(x=(w=i).coordsForChar)===null||x===void 0?void 0:x.call(w,S);if(J&&(H=J.left),!L||L==`
39
- `||L=="\r")L=" ";else if(L==" "){L=" ";var _=i.coordsAtPos(S+1,-1);_&&(H=_.left-(_.left-O.left)/parseInt(D.tabSize))}else/[\uD800-\uDBFF]/.test(L)&&S<i.state.doc.length-1&&(L+=i.state.sliceDoc(S+1,S+2));let Z=O.bottom-O.top;return new vo((H-P.left)/i.scaleX,(O.top-P.top+Z*(1-R))/i.scaleY,Z*R/i.scaleY,D.fontFamily,D.fontSize,D.fontWeight,D.color,f?"cm-fat-cursor cm-cursor-primary":"cm-fat-cursor cm-cursor-secondary",L,R!=1)}else return null}var xo=typeof navigator<"u"&&/linux/i.test(navigator.platform)&&/ Gecko\/\d+/.exec(navigator.userAgent);const Re=no(U),So=250,bo=se.baseTheme({".cm-vimMode .cm-cursorLayer:not(.cm-vimCursorLayer)":{display:"none"},".cm-vim-panel":{padding:"0px 10px",fontFamily:"monospace",minHeight:"1.3em",display:"flex"},".cm-vim-panel input":{border:"none",outline:"none",backgroundColor:"inherit"},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"}}),Mo=lt.fromClass(class{constructor(s){this.status="",this.query=null,this.decorations=G.none,this.waitForCopy=!1,this.lastKeydown="",this.useNextTextInput=!1,this.compositionText="",this.view=s;const i=this.cm=new U(s);Re.enterVimMode(this.cm),this.view.cm=this.cm,this.cm.state.vimPlugin=this,this.blockCursor=new go(s,i),this.updateClass(),this.cm.on("vim-command-done",()=>{i.state.vim&&(i.state.vim.status=""),this.blockCursor.scheduleRedraw(),this.updateStatus()}),this.cm.on("vim-mode-change",l=>{i.state.vim&&(i.state.vim.mode=l.mode,l.subMode&&(i.state.vim.mode+=l.subMode==="linewise"?" line":" block"),i.state.vim.status="",this.blockCursor.scheduleRedraw(),this.updateClass(),this.updateStatus())}),this.cm.on("dialog",()=>{this.cm.state.statusbar?this.updateStatus():s.dispatch({effects:on.of(!!this.cm.state.dialog)})}),this.dom=document.createElement("span"),this.spacer=document.createElement("span"),this.spacer.style.flex="1",this.statusButton=document.createElement("span"),this.statusButton.onclick=l=>{Re.handleKey(this.cm,"<Esc>","user"),this.cm.focus()},this.statusButton.style.cssText="cursor: pointer"}update(s){var i;if((s.viewportChanged||s.docChanged)&&this.query&&this.highlight(this.query),s.docChanged&&this.cm.onChange(s),s.selectionSet&&this.cm.onSelectionChange(),s.viewportChanged,this.cm.curOp&&!this.cm.curOp.isVimOp&&this.cm.onBeforeEndOperation(),s.transactions){for(let l of s.transactions)for(let f of l.effects)if(f.is(Bt))if(!((i=f.value)===null||i===void 0?void 0:i.forVim))this.highlight(null);else{let g=f.value.create();this.highlight(g)}}this.blockCursor.update(s)}updateClass(){const s=this.cm.state;!s.vim||s.vim.insertMode&&!s.overwrite?this.view.scrollDOM.classList.remove("cm-vimMode"):this.view.scrollDOM.classList.add("cm-vimMode")}updateStatus(){let s=this.cm.state.statusbar,i=this.cm.state.vim;if(!s||!i)return;let l=this.cm.state.dialog;if(l)l.parentElement!=s&&(s.textContent="",s.appendChild(l));else{s.textContent="";var f=(i.mode||"normal").toUpperCase();i.insertModeReturn&&(f+="(C-O)"),this.statusButton.textContent=`--${f}--`,s.appendChild(this.statusButton),s.appendChild(this.spacer)}this.dom.textContent=i.status,s.appendChild(this.dom)}destroy(){Re.leaveVimMode(this.cm),this.updateClass(),this.blockCursor.destroy(),delete this.view.cm}highlight(s){if(this.query=s,!s)return this.decorations=G.none;let{view:i}=this,l=new ci;for(let f=0,d=i.visibleRanges,g=d.length;f<g;f++){let{from:w,to:x}=d[f];for(;f<g-1&&x>d[f+1].from-2*So;)x=d[++f].to;s.highlight(i.state,w,x,(S,B)=>{l.add(S,B,Ao)})}return this.decorations=l.finish()}handleKey(s,i){const l=this.cm;let f=l.state.vim;if(!f)return;const d=Re.vimKeyFromEvent(s,f);if(U.signal(this.cm,"inputEvent",{type:"handleKey",key:d}),!d)return;if(d=="<Esc>"&&!f.insertMode&&!f.visualMode&&this.query){const x=f.searchState_;x&&(l.removeOverlay(x.getOverlay()),x.setOverlay(null))}if(d==="<C-c>"&&!U.isMac&&l.somethingSelected())return this.waitForCopy=!0,!0;f.status=(f.status||"")+d;let w=Re.multiSelectHandleKey(l,d,"user");return f=Re.maybeInitVimState_(l),!w&&f.insertMode&&l.state.overwrite&&(s.key&&s.key.length==1&&!/\n/.test(s.key)?(w=!0,l.overWriteSelection(s.key)):s.key=="Backspace"&&(w=!0,U.commands.cursorCharLeft(l))),w&&(U.signal(this.cm,"vim-keypress",d),s.preventDefault(),s.stopPropagation(),this.blockCursor.scheduleRedraw()),this.updateStatus(),!!w}},{eventHandlers:{copy:function(s,i){this.waitForCopy&&(this.waitForCopy=!1,Promise.resolve().then(()=>{var l=this.cm,f=l.state.vim;f&&(f.insertMode?l.setSelection(l.getCursor(),l.getCursor()):l.operation(()=>{l.curOp&&(l.curOp.isVimOp=!0),Re.handleKey(l,"<Esc>","user")}))}))},compositionstart:function(s,i){this.useNextTextInput=!0,U.signal(this.cm,"inputEvent",s)},compositionupdate:function(s,i){U.signal(this.cm,"inputEvent",s)},compositionend:function(s,i){U.signal(this.cm,"inputEvent",s)},keypress:function(s,i){U.signal(this.cm,"inputEvent",s),this.lastKeydown=="Dead"&&this.handleKey(s,i)},keydown:function(s,i){U.signal(this.cm,"inputEvent",s),this.lastKeydown=s.key,this.lastKeydown=="Unidentified"||this.lastKeydown=="Process"||this.lastKeydown=="Dead"?this.useNextTextInput=!0:(this.useNextTextInput=!1,this.handleKey(s,i))}},provide:()=>[se.inputHandler.of((s,i,l,f)=>{var d,g,w=an(s);if(!w)return!1;var x=(d=w.state)===null||d===void 0?void 0:d.vim,S=w.state.vimPlugin;if(x&&!x.insertMode&&!(!((g=w.curOp)===null||g===void 0)&&g.isVimOp)){if(f==="\0\0")return!0;if(U.signal(w,"inputEvent",{type:"text",text:f,from:i,to:l}),f.length==1&&S.useNextTextInput){if(x.expectLiteralNext&&s.composing)return S.compositionText=f,!1;if(S.compositionText){var B=S.compositionText;S.compositionText="";var R=s.state.selection.main.head,A=s.state.sliceDoc(R-B.length,R);if(B===A){var _=w.getCursor();w.replaceRange("",w.posFromIndex(R-B.length),_)}}return S.handleKey({key:f,preventDefault:()=>{},stopPropagation:()=>{}}),Lo(s),!0}}return!1})],decorations:s=>s.decorations});function Lo(s){var i=s.scrollDOM.parentElement;if(i){if(xo){s.contentDOM.textContent="\0\0",s.contentDOM.dispatchEvent(new CustomEvent("compositionend"));return}var l=s.scrollDOM.nextSibling,f=window.getSelection(),d=f&&{anchorNode:f.anchorNode,anchorOffset:f.anchorOffset,focusNode:f.focusNode,focusOffset:f.focusOffset};s.scrollDOM.remove(),i.insertBefore(s.scrollDOM,l);try{d&&f&&(f.setPosition(d.anchorNode,d.anchorOffset),d.focusNode&&f.extend(d.focusNode,d.focusOffset))}catch(g){console.error(g)}s.focus(),s.contentDOM.dispatchEvent(new CustomEvent("compositionend"))}}const Ao=G.mark({class:"cm-searchMatch"}),on=ft.define(),Eo=ct.define({create:()=>!1,update(s,i){for(let l of i.effects)l.is(on)&&(s=l.value);return s},provide:s=>zr.from(s,i=>i?Oo:null)});function Oo(s){let i=document.createElement("div");i.className="cm-vim-panel";let l=s.cm;return l.state.dialog&&i.appendChild(l.state.dialog),{top:!1,dom:i}}function Ro(s){let i=document.createElement("div");i.className="cm-vim-panel";let l=s.cm;return l.state.statusbar=i,l.state.vimPlugin.updateStatus(),{dom:i}}function _r(s={}){return[bo,Mo,Co,s.status?zr.of(Ro):Eo]}function an(s){return s.cm||null}class Qt{constructor(i,l){this.yanchor=i,this.yhead=l}toJSON(){return{yanchor:Ir(this.yanchor),yhead:Ir(this.yhead)}}static fromJSON(i){return new Qt(st(i.yanchor),st(i.yhead))}}class To{constructor(i,l){this.ytext=i,this.awareness=l,this.undoManager=new zt(i)}toYPos(i,l=0){return Pt(this.ytext,i,l)}fromYPos(i){const l=Dt(st(i),this.ytext.doc);if(l==null||l.type!==this.ytext)throw new Error("[y-codemirror] The position you want to retrieve was created by a different document");return{pos:l.index,assoc:l.assoc}}toYRange(i){const l=i.assoc,f=this.toYPos(i.anchor,l),d=this.toYPos(i.head,l);return new Qt(f,d)}fromYRange(i){const l=this.fromYPos(i.yanchor),f=this.fromYPos(i.yhead);return l.pos===f.pos?Se.cursor(f.pos,f.assoc):Se.range(l.pos,f.pos)}}const yt=jt.define({combine(s){return s[s.length-1]}}),$t=Wt.define();class Io{constructor(i){this.view=i,this.conf=i.state.facet(yt),this._observer=(l,f)=>{if(f.origin!==this.conf){const d=l.delta,g=[];let w=0;for(let x=0;x<d.length;x++){const S=d[x];S.insert!=null?g.push({from:w,to:w,insert:S.insert}):S.delete!=null?(g.push({from:w,to:w+S.delete,insert:""}),w+=S.delete):w+=S.retain}i.dispatch({changes:g,annotations:[$t.of(this.conf)]})}},this._ytext=this.conf.ytext,this._ytext.observe(this._observer)}update(i){if(!i.docChanged||i.transactions.length>0&&i.transactions[0].annotation($t)===this.conf)return;const l=this.conf.ytext;l.doc.transact(()=>{let f=0;i.changes.iterChanges((d,g,w,x,S)=>{const B=S.sliceString(0,S.length,`
40
- `);d!==g&&l.delete(d+f,g-d),B.length>0&&l.insert(d+f,B),f+=B.length-(g-d)})},this.conf)}destroy(){this._ytext.unobserve(this._observer)}}const No=lt.fromClass(Io),Bo=se.baseTheme({".cm-ySelection":{},".cm-yLineSelection":{padding:0,margin:"0px 2px 0px 4px"},".cm-ySelectionCaret":{position:"relative",borderLeft:"1px solid black",borderRight:"1px solid black",marginLeft:"-1px",marginRight:"-1px",boxSizing:"border-box",display:"inline"},".cm-ySelectionCaretDot":{borderRadius:"50%",position:"absolute",width:".4em",height:".4em",top:"-.2em",left:"-.2em",backgroundColor:"inherit",transition:"transform .3s ease-in-out",boxSizing:"border-box"},".cm-ySelectionCaret:hover > .cm-ySelectionCaretDot":{transformOrigin:"bottom center",transform:"scale(0)"},".cm-ySelectionInfo":{position:"absolute",top:"-1.05em",left:"-1px",fontSize:".75em",fontFamily:"serif",fontStyle:"normal",fontWeight:"normal",lineHeight:"normal",userSelect:"none",color:"white",paddingLeft:"2px",paddingRight:"2px",zIndex:101,transition:"opacity .3s ease-in-out",backgroundColor:"inherit",opacity:0,transitionDelay:"0s",whiteSpace:"nowrap"},".cm-ySelectionCaret:hover > .cm-ySelectionInfo":{opacity:1,transitionDelay:"0s"}}),Po=Wt.define();class Do extends qr{constructor(i,l){super(),this.color=i,this.name=l}toDOM(){return Nt("span",[mt("class","cm-ySelectionCaret"),mt("style",`background-color: ${this.color}; border-color: ${this.color}`)],[gt("⁠"),Nt("div",[mt("class","cm-ySelectionCaretDot")]),gt("⁠"),Nt("div",[mt("class","cm-ySelectionInfo")],[gt(this.name)]),gt("⁠")])}eq(i){return i.color===this.color}compare(i){return i.color===this.color}updateDOM(){return!1}get estimatedHeight(){return-1}ignoreEvent(){return!0}}class _o{constructor(i){this.conf=i.state.facet(yt),this._listener=({added:l,updated:f,removed:d},g,w)=>{l.concat(f).concat(d).findIndex(S=>S!==this.conf.awareness.doc.clientID)>=0&&i.dispatch({annotations:[Po.of([])]})},this._awareness=this.conf.awareness,this._awareness.on("change",this._listener),this.decorations=Ai.of([])}destroy(){this._awareness.off("change",this._listener)}update(i){const l=this.conf.ytext,f=l.doc,d=this.conf.awareness,g=[],w=this.conf.awareness.getLocalState();if(w!=null){const x=i.view.hasFocus&&i.view.dom.ownerDocument.hasFocus(),S=x?i.state.selection.main:null,B=w.cursor==null?null:st(w.cursor.anchor),R=w.cursor==null?null:st(w.cursor.head);if(S!=null){const A=Pt(l,S.anchor),_=Pt(l,S.head);(w.cursor==null||!Nr(B,A)||!Nr(R,_))&&d.setLocalStateField("cursor",{anchor:A,head:_})}else w.cursor!=null&&x&&d.setLocalStateField("cursor",null)}d.getStates().forEach((x,S)=>{if(S===d.doc.clientID)return;const B=x.cursor;if(B==null||B.anchor==null||B.head==null)return;const R=Dt(B.anchor,f),A=Dt(B.head,f);if(R==null||A==null||R.type!==l||A.type!==l)return;const{color:_="#30bced",name:L="Anonymous"}=x.user||{},O=x.user&&x.user.colorLight||_+"33",P=eo(R.index,A.index),$=to(R.index,A.index),K=i.view.state.doc.lineAt(P),D=i.view.state.doc.lineAt($);if(K.number===D.number)g.push({from:P,to:$,value:G.mark({attributes:{style:`background-color: ${O}`},class:"cm-ySelection"})});else{g.push({from:P,to:K.from+K.length,value:G.mark({attributes:{style:`background-color: ${O}`},class:"cm-ySelection"})}),g.push({from:D.from,to:$,value:G.mark({attributes:{style:`background-color: ${O}`},class:"cm-ySelection"})});for(let H=K.number+1;H<D.number;H++){const J=i.view.state.doc.line(H).from;g.push({from:J,to:J,value:G.line({attributes:{style:`background-color: ${O}`,class:"cm-yLineSelection"}})})}}g.push({from:A.index,to:A.index,value:G.widget({side:A.index-R.index>0?-1:1,block:!1,widget:new Do(_,L)})})}),this.decorations=G.set(g,!0)}}const Ko=lt.fromClass(_o,{decorations:s=>s.decorations}),$o=()=>{let s=!0;return(i,l)=>{if(s){s=!1;try{i()}finally{s=!0}}else l!==void 0&&l()}};class Fo{constructor(i){this.undoManager=i}addTrackedOrigin(i){this.undoManager.addTrackedOrigin(i)}removeTrackedOrigin(i){this.undoManager.removeTrackedOrigin(i)}undo(){return this.undoManager.undo()!=null}redo(){return this.undoManager.redo()!=null}}const Ct=jt.define({combine(s){return s[s.length-1]}});class Ho{constructor(i){this.view=i,this.conf=i.state.facet(Ct),this._undoManager=this.conf.undoManager,this.syncConf=i.state.facet(yt),this._beforeChangeSelection=null,this._mux=$o(),this._onStackItemAdded=({stackItem:l,changedParentTypes:f})=>{f.has(this.syncConf.ytext)&&this._beforeChangeSelection&&!l.meta.has(this)&&l.meta.set(this,this._beforeChangeSelection)},this._onStackItemPopped=({stackItem:l})=>{const f=l.meta.get(this);if(f){const d=this.syncConf.fromYRange(f);i.dispatch(i.state.update({selection:d,effects:[se.scrollIntoView(d)]})),this._storeSelection()}},this._storeSelection=()=>{this._beforeChangeSelection=this.syncConf.toYRange(this.view.state.selection.main)},this._undoManager.on("stack-item-added",this._onStackItemAdded),this._undoManager.on("stack-item-popped",this._onStackItemPopped),this._undoManager.addTrackedOrigin(this.syncConf)}update(i){i.selectionSet&&(i.transactions.length===0||i.transactions[0].annotation($t)!==this.syncConf)&&this._storeSelection()}destroy(){this._undoManager.off("stack-item-added",this._onStackItemAdded),this._undoManager.off("stack-item-popped",this._onStackItemPopped),this._undoManager.removeTrackedOrigin(this.syncConf)}}const Vo=lt.fromClass(Ho),sn=({state:s,dispatch:i})=>s.facet(Ct).undo()||!0,Ft=({state:s,dispatch:i})=>s.facet(Ct).redo()||!0,jo=[{key:"Mod-z",run:sn,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:Ft,preventDefault:!0},{key:"Mod-Shift-z",run:Ft,preventDefault:!0}],Wo=(s,i,{undoManager:l=new zt(s)}={})=>{const f=new To(s,i),d=[yt.of(f),No];return i&&d.push(Bo,Ko),l!==!1&&d.push(Ct.of(new Fo(l)),Vo,se.domEventHandlers({beforeinput(g,w){return g.inputType==="historyUndo"?sn(w):g.inputType==="historyRedo"?Ft(w):!1}})),d};function Uo(s,i){if(!i.valid||!i.search)return 0;let l=0;const f=i.getCursor(s);for(;!f.next().done;)l+=1;return l}function zo(s){return JSON.stringify([s.search,s.caseSensitive,s.literal,s.regexp,s.wholeWord])}const Qo=new Set(["(",")","[","]","{","}"]),Jo={...Rr,token(s,i){const l=s.pos,f=Rr.token(s,i),d=s.string.slice(l,s.pos);return Qo.has(d)?"bracket":f}},Zo=Ei.define(Jo);function ln(s){let i=0;for(const l of s){if(l==="\\"){i+=1;continue}if(l==="%"&&i%2===0)return!0;i=0}return!1}function qo(s){const i=".+?^$()[]{}|\\";return[...s].map(l=>i.includes(l)?"\\"+l:l).join("")}function cn(s,i,l){const f=s.slice(0,i)+l+s.slice(i),d=i+l.length,g=f.lastIndexOf(`
41
- `,Math.max(0,d-1))+1,w=f.indexOf(`
42
- `,d);return{nextSource:f,cursor:d,prefix:f.slice(g,d),suffix:f.slice(d,w<0?f.length:w)}}function fn(s){const i=s.prefix.match(/^([ \t]*)\\begin\s*\{\s*([A-Za-z][A-Za-z0-9*:_-]*)\s*\}\s*$/);if(!i||s.suffix.trim()||ln(s.prefix))return null;const l=i[2],f=qo(l);if(new RegExp("^[ \\t]*\\n[ \\t]*\\\\end\\s*\\{\\s*"+f+"\\s*\\}").test(s.nextSource.slice(s.cursor)))return null;const g=i[1]+" ";return{insert:`
43
- `+g+`
44
- `+i[1]+"\\end{"+l+"}",cursorOffset:1+g.length,kind:"environment"}}function un(s){if(s.suffix.trim()||ln(s.prefix))return null;const i=s.prefix.match(/^(.*\\left\s*)(\\[{}]|[()[\]|.])\s*$/);if(!i)return null;const f={"(":"\\right)",")":"\\right(","[":"\\right]","]":"\\right[","|":"\\right|",".":"\\right.","\\{":"\\right\\}","\\}":"\\right\\{"}[i[2]];return f?{insert:f,cursorOffset:0,kind:"delimiter"}:null}function Yo(s,i,l,f){if(i!==l||!f)return null;const d=cn(s,i,f);return fn(d)??un(d)}function Xo(s,i){if(i<0||i>s.length)return null;const l=cn(s,i,"");return fn(l)??un(l)}const Ht=ft.define(),Kr=Wt.define(),Go={undo:()=>!1,redo:()=>!1},Jt=jt.define({combine:s=>s.at(-1)??Go});Re.defineAction("texliteUndo",s=>{s.cm6.state.facet(Jt).undo()||s.execCommand("undo")});Re.defineAction("texliteRedo",s=>{s.cm6.state.facet(Jt).redo()||s.execCommand("redo")});Re.mapCommand("u","action","texliteUndo",{},{context:"normal"});Re.mapCommand("<C-r>","action","texliteRedo",{},{context:"normal"});const ea=ct.define({create:()=>G.none,update(s,i){let l=s.map(i.changes);for(const f of i.effects)f.is(Ht)&&(l=ya(f.value,i.state.doc.length));return l},provide:s=>se.decorations.from(s)}),hn=ft.define(),ta=ct.define({create:s=>({words:[],decorations:Wr(s.doc.toString(),[])}),update(s,i){let l=s.words;for(const f of i.effects)f.is(hn)&&(l=f.value);return i.docChanged||l!==s.words?{words:l,decorations:Wr(i.state.doc.toString(),l)}:s},provide:s=>se.decorations.from(s,i=>i.decorations)}),dn=ft.define(),ra=ct.define({create:()=>G.none,update(s,i){let l=s.map(i.changes);i.docChanged&&(l=G.none);for(const f of i.effects)f.is(dn)&&(l=ma(f.value,i.state.doc.length));return l},provide:s=>se.decorations.from(s)}),Vt=ft.define(),na=G.mark({class:"cm-spell-error-active"}),ia=ct.define({create:()=>G.none,update(s,i){let l=s.map(i.changes);i.docChanged&&(l=G.none);for(const f of i.effects){if(!f.is(Vt))continue;const d=f.value;l=d&&d.to>d.from?G.set([na.range(d.from,d.to)]):G.none}return l},provide:s=>se.decorations.from(s)});function oa(){return[xe("\\section{${title}}",{label:"\\section"}),xe("\\subsection{${title}}",{label:"\\subsection"}),xe("\\textbf{${text}}",{label:"\\textbf"}),xe("\\emph{${text}}",{label:"\\emph"}),xe("\\cite{${key}}",{label:"\\cite"}),xe("\\ref{${label}}",{label:"\\ref"}),xe("\\label{${label}}",{label:"\\label"}),xe("\\includegraphics[width=${0.8}\\textwidth]{${file}}",{label:"\\includegraphics"}),xe(`\\begin{itemize}
45
- \\item \${item}
46
- \\end{itemize}`,{label:"\\begin{itemize}"}),xe(`\\begin{enumerate}
47
- \\item \${item}
48
- \\end{enumerate}`,{label:"\\begin{enumerate}"}),xe(`\\begin{equation}
49
- \${equation}
50
- \\end{equation}`,{label:"\\begin{equation}"}),xe(`\\begin{figure}[htbp]
51
- \\centering
52
- \${content}
53
- \\caption{\${caption}}
54
- \\label{fig:\${label}}
55
- \\end{figure}`,{label:"\\begin{figure}"})]}function aa(s){const i=[],l=[],f=[],d=[],g=[],w=[],x=s.split(`
56
- `).map(A=>A.replace(/(^|[^\\])%.*$/,"$1")).join(`
57
- `),S=(A,_)=>{if(_<=0)return;const L=O=>`\${${O}}`;return A+Array.from({length:_},(O,P)=>`{${L(P+1)}}`).join("")},B=A=>[...A.matchAll(/[moOrRdDsStvb]/g)].length,R=(A,_,L,O,P)=>{_&&!A.some($=>$.label===_)&&A.push({label:_,detail:L,kind:O,source:"Current file",...P?{apply:P}:{}})};for(const A of x.matchAll(/\\(?:newcommand|renewcommand|providecommand|DeclareRobustCommand)\s*\*?\s*(?:\{\s*)?\\([A-Za-z@][A-Za-z@0-9:_]*)\s*(?:\})?\s*(?:\[(\d+)\])?/g)){const _=Number.parseInt(A[2]??"0",10);R(i,`\\${A[1]}`,"Project command","function",S(`\\${A[1]}`,_))}for(const A of x.matchAll(/\\(?:NewDocumentCommand|RenewDocumentCommand|ProvideDocumentCommand|DeclareDocumentCommand|DeclareExpandableDocumentCommand|RenewExpandableDocumentCommand|ProvideExpandableDocumentCommand)\s*\{\s*\\([A-Za-z@][A-Za-z@0-9:_]*)\s*\}\s*\{([^}]*)\}/g)){const _=B(A[2]);R(i,`\\${A[1]}`,"Project command","function",S(`\\${A[1]}`,_))}for(const A of x.matchAll(/\\(?:def|gdef|edef|xdef)\s*\\([A-Za-z@][A-Za-z@0-9:_]*)((?:\s*#\d+)*)/g)){const _=[...(A[2]??"").matchAll(/#\d+/g)].length;R(i,`\\${A[1]}`,"Project macro","function",S(`\\${A[1]}`,_))}for(const A of x.matchAll(/\\DeclarePairedDelimiter\s*\{?\\([A-Za-z@][A-Za-z@0-9:_]*)\}?/g))R(i,`\\${A[1]}`,"Project math delimiter","function");for(const A of x.matchAll(/\\cs_(?:new|set|gset|provide|generate)(?:_protected)?\:[A-Za-z]+\s+\\([A-Za-z@][A-Za-z@0-9:_]*)/g))R(i,`\\${A[1]}`,"Expl3 project command","function");for(const A of x.matchAll(/\\(?:newenvironment|renewenvironment|NewDocumentEnvironment|RenewDocumentEnvironment|DeclareDocumentEnvironment)\s*\*?\s*\{([^}]+)\}/g))R(l,A[1].trim(),"Project environment","keyword");for(const A of x.matchAll(/\\(?:label|hypertarget)\s*\{([^}]+)\}/g))R(f,A[1].trim(),"Label","constant");for(const A of x.matchAll(/\\(?:usepackage|RequirePackage)\s*(?:\[[^]]*\])?\s*\{([^}]+)\}/g))for(const _ of A[1].split(","))R(g,_.trim(),"Package","text");for(const A of x.matchAll(/\\(?:input|include|subfile)\s*(?:\{([^}]+)\}|\s+([^\s%]+))/g))R(w,(A[1]??A[2]??"").trim(),"Project file","text");for(const A of x.matchAll(/\\(?:cite|citep|citet|parencite|textcite|autocite|footcite)(?:\w*)?\s*(?:\[[^]]*\])?\s*\{([^}]+)\}/g))for(const _ of A[1].split(","))R(d,_.trim(),"Citation key","constant");return{commands:i,environments:l,labels:f,citations:d,packages:g,files:w}}const $r=new WeakMap;function sa(s){const i=s.state.doc,l=$r.get(i);if(l)return l;const f=aa(s.state.doc.toString());return $r.set(i,f),f}const Fr={"Project command":"projectCommand","Project macro":"projectMacro","Expl3 project command":"expl3Command","Project math operator":"mathOperator","Project math delimiter":"mathDelimiter","Project environment":"projectEnvironment","Project file":"projectFile",Package:"package","Document class":"documentClass","Current file":"currentFile",Project:"project",LaTeX:"latex"};function la(s,i,l=!0){const f=Fr[s.detail],d=s.source?Fr[s.source]:void 0,g=s.detail.match(/^Project command \((\d+) arguments?\)$/),w=s.source==="LaTeX"?"":g?i("completions.projectCommandArgs",{count:Number(g[1])}):f?i(`completions.${f}`):s.source==="LaTeX"?i("completions.standard"):s.detail,x=s.source==="LaTeX"?"":d?i(`completions.${d}`):s.source,S=x&&w?`${w} · ${x}`:w||x||void 0,B={label:s.label,type:s.kind,...S?{detail:S}:{},...s.info?{info:s.info}:{}};return l&&s.apply?xe(s.apply,B):B}function ze(s,...i){const l=[],f=new Set;for(const d of i)for(const g of d){const w="kind"in g?la(g,s):g;f.has(w.label)||(f.add(w.label),l.push(w))}return l}function Hr(s){return s.map(({detail:i,...l})=>l)}function Vr(s){return s.map(({apply:i,...l})=>l)}function Ge(s,i){const f=s.state.sliceDoc(0,s.pos).match(i);return!f||f.index===void 0?null:{from:s.pos-f[1].length,query:f[1]}}function ca(s){const l=s.state.sliceDoc(0,s.pos).match(/\\(begin|end)\{([^{}]*)$/);return!l||l.index===void 0?null:{from:s.pos-l[2].length,query:l[2],command:l[1]}}function fa(s){const i=s.state.doc.lineAt(s.pos);let l=0;for(let f=0;f<s.pos-i.from;f+=1){const d=i.text[f];if(d==="\\"){l+=1;continue}if(d==="%"&&l%2===0)return!0;l=0}return!1}function ua(s){return{...s,apply(i,l,f,d){const w=i.state.doc.lineAt(f).text.match(/^\s*/)?.[0]??"",x=l.label,S=x+`}
58
- `+w+`
59
- `+w+"\\end{"+x+"}",B=f+x.length+1+1+w.length+1,R=i.state.sliceDoc(d,d+1)==="}"?1:0;i.dispatch({changes:{from:f,to:d+R,insert:S},selection:{anchor:B},annotations:[Xi.of(l),Ut.userEvent.of("input.complete")]})}}}function ha(s,i,l,f,d){const g=Yo(s.state.doc.toString(),i,l,f);if(!g)return!1;s.dispatch(d());const w=i+f.length;return s.dispatch({changes:{from:w,insert:g.insert},selection:{anchor:w+g.cursorOffset},annotations:Ut.userEvent.of("input.complete")}),!0}function da(s,i,l){if(fa(s))return null;const f=sa(s),d=s.matchBefore(/\\[A-Za-z@0-9:_]*$/);if(d||s.explicit)return{from:d?.from??s.pos,options:Hr(ze(i,f.commands,l?.commands??[],oa())),validFor:/^\\[A-Za-z@0-9:_]*$/};const g=ca(s);if(g){const A=ze(i,Vr(f.environments),Vr(l?.environments??[]));return{from:g.from,options:Hr(g.command==="begin"?A.map(ua):A),validFor:/^[A-Za-z0-9*:_-]*$/}}const w=Ge(s,/\\(?:ref|pageref|autoref|nameref|cref|Cref|eqref|vref)\s*(?:\[[^]]*\])?\{([^{}]*)$/)??Ge(s,/\\hyperref\[([^\[\]]*)$/);if(w)return{from:w.from,options:ze(i,f.labels,l?.labels??[]),validFor:/^[^{}]*$/};const x=Ge(s,/\\(?:cite|citep|citet|parencite|textcite|autocite|footcite)(?:\w*)?(?:\[[^]]*\])?\{([^{}]*)$/);if(x)return{from:x.from,options:ze(i,f.citations,l?.citations??[]),validFor:/^[^{}]*$/};const S=Ge(s,/\\(?:input|include|subfile|includegraphics|bibliography|addbibresource)\s*(?:\[[^]]*\])?\{([^{}]*)$/);if(S)return{from:S.from,options:ze(i,f.files,l?.files??[]),validFor:/^[^{}]*$/};const B=Ge(s,/\\(?:usepackage|RequirePackage)\s*(?:\[[^]]*\])?\{([^{}]*)$/);if(B)return{from:B.from,options:ze(i,f.packages,l?.packages??[]),validFor:/^[^{}]*$/};const R=Ge(s,/\\documentclass\s*(?:\[[^]]*\])?\{([^{}]*)$/);return R?{from:R.from,options:ze(i,l?.files??[]),validFor:/^[^{}]*$/}:null}const pa=Zi.of((s,i)=>{const l=s.doc.lineAt(i),f=l.text.match(/\\begin\{([^}]+)\}/);if(f){let g=1;for(let w=l.number+1;w<=s.doc.lines;w+=1){const x=s.doc.line(w),S=f[1].replace(/[.*+?^${}()|[\]\\]/g,"\\$&");if(g+=(x.text.match(new RegExp(`\\\\begin\\{${S}\\}`,"g"))??[]).length,g-=(x.text.match(new RegExp(`\\\\end\\{${S}\\}`,"g"))??[]).length,g===0&&x.from>l.to)return{from:l.to,to:x.from}}}const d=l.text.match(/^\s*\\(part|chapter|section|subsection|subsubsection)\*?/);if(d){const g={part:0,chapter:0,section:1,subsection:2,subsubsection:3},w=g[d[1]];for(let x=l.number+1;x<=s.doc.lines;x+=1){const S=s.doc.line(x),B=S.text.match(/^\s*\\(part|chapter|section|subsection|subsubsection)\*?/);if(B&&g[B[1]]<=w)return{from:l.to,to:Math.max(l.to,S.from-1)}}if(l.to<s.doc.length)return{from:l.to,to:s.doc.length}}return null});function Sa({value:s,readOnly:i,comments:l,focusComment:f,preferences:d,completionIndex:g,jumpTo:w,searchRequest:x,spellCheckWords:S,spellCheckIssues:B,spellCheckJump:R,collaboration:A,onChange:_,onSelection:L,onCommentClick:O,onCursor:P}){const{t:$,i18n:K}=li(),D=re.useRef(null),H=re.useRef(null),J=re.useRef(_),Z=re.useRef(L),me=re.useRef(O),le=re.useRef(P),_e=re.useRef(x),Qe=re.useRef(g),be=re.useRef(new Tr),Ke=re.useRef(new Tr),Te=re.useRef(null),[pe,et]=re.useState(d.vimMode?"NORMAL":"");J.current=_,Z.current=L,me.current=O,le.current=P,Qe.current=g;const tt=(j,ee)=>{if(Te.current?.(),Te.current=null,!ee){et("");return}const M=an(j);if(!M){et("NORMAL");return}const ne=()=>{const q=M.state.vim?.mode??(M.state.vim?.insertMode?"insert":"normal");et(q.toUpperCase())};ne(),M.on("vim-mode-change",ne),Te.current=()=>M.off("vim-mode-change",ne)};return re.useEffect(()=>{if(!D.current)return;const j=A&&!i?new zt(A.text):null,ee=It.create({doc:A?.text.toString()??s,extensions:[Oi(),Ri(),...A?[]:[Ti()],Ii(),Ni(),Bi(),Zo,Pi(Yi),Di(),Qr.high(se.inputHandler.of(ha)),_i(),Ki(),pa,ea,ta,ra,ia,$i({top:!0}),ga($),It.phrases.of(va($)),Fi({override:[M=>da(M,$,Qe.current)],activateOnTyping:!0}),...j?[Jt.of({undo:()=>j.undo()!==null,redo:()=>j.redo()!==null})]:[],Ke.current.of(d.vimMode?_r():[]),Hi.of([...Vi,...ji,...Wi,...Ui,...A&&!i?jo:[],...zi,...A?[]:Qi]),...A?[Wo(A.text,A.awareness,{undoManager:j??!1})]:[],It.readOnly.of(i),be.current.of(jr(d)),se.domEventHandlers({click(M){const ne=M.target.closest("[data-comment-id]");return ne?.dataset.commentId&&me.current(ne.dataset.commentId),!1},blur(M,ne){const q=ne.state.selection.main;return Z.current(ne.state.sliceDoc(q.from,q.to),q.from,q.to),A?.awareness.setLocalStateField("cursor",null),!1}}),se.updateListener.of(M=>{const ne=M.transactions.some(q=>q.annotation(Kr));if(M.docChanged&&!ne&&J.current(M.state.doc.toString()),M.selectionSet&&!M.docChanged&&M.transactions.some(q=>q.isUserEvent("input"))){const q=M.state.selection.main.head,Me=Xo(M.state.doc.toString(),q);Me&&M.view.dispatch({changes:{from:q,insert:Me.insert},selection:{anchor:q+Me.cursorOffset},annotations:Ut.userEvent.of("input.complete")})}if(M.selectionSet||M.docChanged){const q=M.state.selection.main;Z.current(M.state.sliceDoc(q.from,q.to),q.from,q.to);const Me=M.state.doc.lineAt(q.head);le.current(Me.number,q.head-Me.from+1)}})]});return H.current=new se({state:ee,parent:D.current}),tt(H.current,d.vimMode),H.current.dispatch({effects:Ht.of(Ur(l))}),()=>{Te.current?.(),Te.current=null,H.current?.destroy(),H.current=null}},[i,K.resolvedLanguage,A?.text]),re.useEffect(()=>{const j=H.current;j&&(j.dispatch({effects:[be.current.reconfigure(jr(d)),Ke.current.reconfigure(d.vimMode?_r():[])]}),tt(j,d.vimMode))},[d]),re.useEffect(()=>{H.current?.dispatch({effects:hn.of(S)})},[S]),re.useEffect(()=>{const j=H.current;if(!j)return;const ee=j.state.doc.toString(),M=B.filter(ne=>ne.from>=0&&ne.to<=ee.length&&ne.to>ne.from);j.dispatch({effects:[dn.of(M),Vt.of(null)]})},[B]),re.useEffect(()=>{const j=H.current;A||!j||j.state.doc.toString()===s||j.dispatch({changes:{from:0,to:j.state.doc.length,insert:s},annotations:Kr.of(!0)})},[s,A]),re.useEffect(()=>{H.current?.dispatch({effects:Ht.of(Ur(l))})},[l]),re.useEffect(()=>{const j=H.current;if(!j||!f||f.orphaned)return;const ee=Math.min(f.startOffset,j.state.doc.length),M=Math.min(Math.max(ee,f.endOffset),j.state.doc.length);j.dispatch({selection:{anchor:ee,head:M},effects:se.scrollIntoView(ee,{y:"center"})}),j.focus()},[f]),re.useEffect(()=>{const j=H.current;if(!j||!w)return;const ee=Math.max(1,Math.min(j.state.doc.lines,w.line)),M=j.state.doc.line(ee),ne=Math.min(M.to,M.from+Math.max(0,w.column-1));j.dispatch({selection:{anchor:M.from,head:M.to},effects:se.scrollIntoView(ne,{y:"center",yMargin:60})}),j.focus()},[w?.nonce]),re.useEffect(()=>{const j=H.current;if(!j||!R)return;const ee=Math.max(0,Math.min(R.from,j.state.doc.length)),M=Math.max(ee,Math.min(R.to,j.state.doc.length));j.dispatch({selection:{anchor:ee},effects:[Vt.of({from:ee,to:M}),se.scrollIntoView(ee,{y:"center",yMargin:60})]}),j.focus()},[R?.nonce]),re.useEffect(()=>{const j=H.current;!j||x===0||x===_e.current||(_e.current=x,Ji(j))},[x]),vt.jsxs("div",{className:"editor-shell",style:{fontFamily:ro(d.font),fontSize:`${d.fontSize}px`,lineHeight:d.lineHeight},children:[vt.jsx("div",{className:"editor-host",ref:D}),d.vimMode&&vt.jsx("div",{className:"vim-editor-status",role:"status","aria-live":"polite",children:vt.jsxs("span",{children:["--",pe||"NORMAL","--"]})})]})}function va(s){return{Find:s("editor.search.find"),Replace:s("editor.search.replace"),next:s("editor.search.next"),previous:s("editor.search.previous"),all:s("editor.search.all"),"match case":s("editor.search.matchCase"),regexp:s("editor.search.regexp"),"by word":s("editor.search.wholeWord"),replace:s("editor.search.replaceNext"),"replace all":s("editor.search.replaceAll"),close:s("common.close"),"current match":s("editor.search.currentMatch"),"on line":s("editor.search.onLine"),"replaced match on line $":s("editor.search.replacedMatchOnLine"),"replaced $ matches":s("editor.search.replacedMatches"),"Go to line":s("editor.search.goToLine"),go:s("editor.search.go")}}function ga(s){return lt.fromClass(class{constructor(i){this.view=i,this.document=i.state.doc,this.schedule()}view;frame=null;document;signature="";count=0;update(){this.schedule()}destroy(){this.frame!==null&&cancelAnimationFrame(this.frame)}schedule(){this.frame!==null&&cancelAnimationFrame(this.frame),this.frame=requestAnimationFrame(()=>{this.frame=null,this.render()})}render(){if(!qi(this.view.state))return;const i=this.view.dom.querySelector(".cm-panel.cm-search");if(!i)return;let l=i.querySelector(".cm-search-count");if(!l){l=document.createElement("span"),l.className="cm-search-count",l.setAttribute("role","status"),l.setAttribute("aria-live","polite");const g=i.querySelector("[name=close]");i.insertBefore(l,g)}const f=Gi(this.view.state),d=zo(f);(this.document!==this.view.state.doc||this.signature!==d)&&(this.document=this.view.state.doc,this.signature=d,this.count=Uo(this.view.state,f)),l.textContent=f.search?f.valid?this.count===0?s("editor.search.noMatches"):s("editor.search.matchCount",{count:this.count}):s("editor.search.invalidQuery"):""}})}function jr(s){return[se.contentAttributes.of({spellcheck:"false",autocorrect:"off",autocapitalize:"off",autocomplete:"off",lang:"en-US"}),se.theme({"&":{fontSize:`${s.fontSize}px`},".cm-scroller":{fontFamily:"inherit",lineHeight:"inherit"},".cm-content":{fontFamily:"inherit",fontSize:"inherit"},".cm-gutters":{fontFamily:"inherit",fontSize:"inherit"}}),s.lineWrapping?se.lineWrapping:[]]}function Ve(s,i,l,f){if(s[i]!==l)return null;let d=0;for(let g=i;g<s.length;g+=1){const w=s[g-1]==="\\"&&s[g-2]!=="\\";if(!w&&s[g]===l&&(d+=1),!w&&s[g]===f&&(d-=1,d===0))return{from:i,to:g+1,end:g+1}}return null}function Wr(s,i){const l=[],f=(L,O)=>{O>L&&l.push({from:L,to:O})},d=L=>{for(const O of s.matchAll(L))O.index!==void 0&&f(O.index,O.index+O[0].length)},g=new Set(["tabular","tabularx","tabulary","longtable","array","matrix","pmatrix","bmatrix","Bmatrix","vmatrix","Vmatrix"]),w=new Set(["documentclass","usepackage","RequirePackage","includegraphics","tikzset","pgfplotsset","hypersetup","lstset","definecolor","colorlet","setlength","setcounter","draw","path","fill","filldraw","shade","node","addplot","color","textcolor","colorbox","pagecolor"]),x=new Set(["label","hypertarget","ref","pageref","autoref","nameref","hyperref","index","gls","Gls","glspl","Glspl","cite","citep","citet","citeauthor","citeyear","citenum","parencite","textcite","autocite","footcite"]),S=L=>/[=,!/]/.test(L)||/\b(?:colorbar|legend|width|height|draw|fill|style|domain|samples|anchor|at|axis)\b/.test(L),B=L=>x.has(L)||/^cite[A-Za-z]*/.test(L),R=L=>{let O=L;for(;O<s.length&&/[ \t\r\n]/.test(s[O]);)O+=1;return O},A=L=>{if(s[L]!=="%")return!1;let O=0;for(let P=L-1;P>=0&&s[P]==="\\";P-=1)O+=1;return O%2===0};for(let L=0;L<s.length;L+=1){if(A(L)){const D=s.indexOf(`
60
- `,L);f(L,D<0?s.length:D),L=D<0?s.length:D;continue}if(s[L]!=="\\")continue;const O=L;let P=L+1;if(/[A-Za-z@]/.test(s[P]??""))for(;P<s.length&&/[A-Za-z@0-9:_]/.test(s[P]);)P+=1;else P<s.length&&(P+=1);const $=s.slice(L+1,P);f(O,P);let K=R(P);if($==="begin"||$==="end"){const D=Ve(s,K,"{","}");if(D){f(D.from,D.to);const H=s.slice(D.from+1,D.to-1).trim();if(K=R(D.end),$==="begin"){const J=Ve(s,K,"[","]");if(J&&(f(J.from,J.to),K=R(J.end)),g.has(H)){const Z=Ve(s,K,"{","}");Z&&f(Z.from,Z.to)}}}L=P-1;continue}if(B($))for(s[K]==="*"&&(K=R(K+1));;){const D=Ve(s,K,"[","]")??Ve(s,K,"{","}");if(!D)break;f(D.from,D.to),K=R(D.end)}else{const D=Ve(s,K,"[","]");if(D&&(w.has($)||S(s.slice(D.from+1,D.to-1)))&&(f(D.from,D.to),K=R(D.end)),w.has($)){const H=$==="definecolor"||$==="colorlet"?3:1;for(let J=0;J<H;J+=1){const Z=Ve(s,K,"{","}");if(!Z)break;f(Z.from,Z.to),K=R(Z.end)}}}L=P-1}for(let L=s.indexOf("=");L>=0;L=s.indexOf("=",L+1)){const P=Math.max(...[`
61
- `,"[","{","]","}",",",";"].map(J=>s.lastIndexOf(J,L-1)+1)),K=s.slice(P,L).match(/([A-Za-z][A-Za-z0-9_.:/-]*(?:\s+[A-Za-z][A-Za-z0-9_.:/-]*){0,7})\s*$/);K?.index!==void 0&&f(P+K.index,L);let D=L+1;for(;D<s.length&&/\s/.test(s[D]);)D+=1;let H=D;if(s[D]==="{")H=Ve(s,D,"{","}")?.end??D;else for(;H<s.length&&!/[,\]\}\n]/.test(s[H]);)H+=1;f(D,H)}d(/(?:https?|ftp):\/\/[^\s]+/gi);for(const L of i){if(!L)continue;const O=L.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),P=new RegExp(`(^|[^A-Za-z0-9_])(${O})(?=$|[^A-Za-z0-9_])`,"gi");for(const $ of s.matchAll(P)){if($.index===void 0)continue;const K=$.index+($[1]?.length??0);l.push({from:K,to:K+($[2]?.length??0)})}}l.sort((L,O)=>L.from-O.from||L.to-O.to);const _=[];for(const L of l){const O=_.at(-1);O&&L.from<=O.to?O.to=Math.max(O.to,L.to):_.push({...L})}return G.set(_.map(L=>G.mark({attributes:{spellcheck:"false"}}).range(L.from,L.to)),!0)}function ma(s,i){const l=s.map(f=>({from:Math.max(0,Math.min(i,f.from)),to:Math.max(0,Math.min(i,f.to)),word:f.word})).filter(f=>f.to>f.from).sort((f,d)=>f.from-d.from||f.to-d.to);return G.set(l.map(f=>G.mark({class:"cm-spell-error",attributes:{title:f.word}}).range(f.from,f.to)),!0)}function Ur(s){return s.map(i=>({id:i.id,from:i.startOffset,to:i.endOffset,resolved:i.resolved,orphaned:i.orphaned}))}function ya(s,i){const l=s.filter(f=>!f.orphaned).map(f=>{const d=Math.max(0,Math.min(i,f.from)),g=Math.max(d,Math.min(i,f.to)),w=`cm-source-comment${f.resolved?" cm-source-comment-resolved":""}`;return d===g?G.widget({widget:new Ca(f.id,w),side:1}).range(d):G.mark({class:w,attributes:{"data-comment-id":f.id}}).range(d,g)});return G.set(l,!0)}class Ca extends qr{constructor(i,l){super(),this.id=i,this.className=l}id;className;toDOM(){const i=document.createElement("span");return i.className=`${this.className} cm-comment-pin`,i.dataset.commentId=this.id,i.textContent="●",i}}export{Sa as LatexEditor};