texlite 0.6.9 → 0.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/assets/{BinaryModule-Aj1vLnwf-BMr5UOlk.js → BinaryModule-Aj1vLnwf-wAe5fMVe.js} +1 -1
- package/dist/client/assets/GitDialog-b7cWzpdJ.js +3 -0
- package/dist/client/assets/{HistoryDialog-C2ibyUF6.js → HistoryDialog-F8tDuD3v.js} +1 -1
- package/dist/client/assets/LatexEditor-BT2E5IIK.js +59 -0
- package/dist/client/assets/PdfPreview-C2tw6xhu.js +1 -0
- package/dist/client/assets/{ProjectNavigationDialogs-BqzwJl7t.js → ProjectNavigationDialogs-CzrF5eh5.js} +1 -1
- package/dist/client/assets/{SystemMetricsDialog-CGyldSTF.js → SystemMetricsDialog-OAoXCVVy.js} +1 -1
- package/dist/client/assets/binary-CWru8eff.js +1 -0
- package/dist/client/assets/index-BLOqf18q.js +62 -0
- package/dist/client/assets/index-CwGialPz.css +1 -0
- package/dist/client/assets/{index-Cjwy6IYP.js → index-JmuE6_j5.js} +1 -1
- package/dist/client/assets/minus-D0DZYQR6.js +1 -0
- package/dist/client/assets/{spellCheck-DOSHWRcE.js → spellCheck-TTrb0uqA.js} +3 -3
- package/dist/client/index.html +2 -2
- package/dist/server/app.js +315 -2
- package/dist/server/citationLibrary.js +174 -0
- package/dist/server/db.js +37 -0
- package/package.json +2 -1
- package/dist/client/assets/GitDialog-8QrVaeyZ.js +0 -3
- package/dist/client/assets/LatexEditor-DaGzADFz.js +0 -59
- package/dist/client/assets/PdfPreview-BBQ4llIA.js +0 -1
- package/dist/client/assets/binary-Ds0O2e5F.js +0 -1
- package/dist/client/assets/index-CISv_aup.js +0 -17
- package/dist/client/assets/index-DdrajKQB.css +0 -1
- package/dist/client/assets/plus-DQ34kKNC.js +0 -1
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import{u as si,r as Y,j as Pe}from"./react-CsO_xvbl.js";import{s as zr,E as se,V as ct,D as ee,a as Pt,R as li,P as Qr,S as vt,b as Se,f as ci,M as qr,m as Er,i as ui,c as fi,d as hi,e as di,g as pi,h as gi,j as Rr,k as Jr,l as mt,n as vi,o as mi,p as yi,q as Ci,r as ki,t as wi,u as Si,v as xi,w as bi,x as Mi,y as tt,F as Wt,A as Ut,z as Li,W as Zr,B as Yr,C as Or,G as Tr,H as Nt,I as Ai,J as Ei,K as Ri,L as Oi,N as Ti,O as Ii,Q as Ni,T as Bi,U as Pi,X as Di,Y as _i,Z as Ki,_ as Fi,$ as $i,a0 as Hi,a1 as Vi,a2 as ji,a3 as Wi,a4 as Ui,a5 as zt,a6 as zi,a7 as Qi,a8 as qi,a9 as Ji,aa as we,ab as Zi,ac as Yi}from"./editor-DMLs-XWi.js";import{r as Ir,c as lt,U as Xr,a as Dt,b as _t,d as Nr,m as Xi,e as Gi,f as Bt,t as pt,g as gt,h as eo}from"./index-BLOqf18q.js";function to(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 u=[{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),v=u.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"}],S=Zt("");function x(e){e.setOption("disableInput",!0),e.setOption("showCursorWhenSelecting",!1),s.signal(e,"vim-mode-change",{mode:"normal"}),e.on("cursorActivity",Sr),Re(e),s.on(e.getInputField(),"paste",R(e))}function T(e){e.setOption("disableInput",!1),e.off("cursorActivity",Sr),s.off(e.getInputField(),"paste",R(e)),e.state.vim=null,at&&clearTimeout(at)}function R(e){var t=e.state.vim;return t.onPasteFn||(t.onPasteFn=function(){t.insertMode||(e.setCursor(ne(e.getCursor(),0,1)),qe.enterInsertMode(e,{},t))}),t.onPasteFn}var M=/[\d]/,P=[s.isWordChar,function(e){return e&&!s.isWordChar(e)&&!/\s/.test(e)}],D=[function(e){return/\S/.test(e)}],F=["<",">"],U=["-",'"',".",":","_","/","+"],Q=/^\w$/,j=/^[A-Z]$/;try{j=new RegExp("^[\\p{Lu}]$","u")}catch{}function oe(e,t){return t>=e.firstLine()&&t<=e.lastLine()}function te(e){return/^[a-z]$/.test(e)}function J(e){return"()[]{}".indexOf(e)!=-1}function ce(e){return M.test(e)}function ge(e){return j.test(e)}function ae(e){return/^\s*$/.test(e)}function _e(e){return".?!".indexOf(e)!=-1}function Ye(e,t){for(var r=0;r<t.length;r++)if(t[r]==e)return!0;return!1}var xe={};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"),xe[e]={type:r,defaultValue:t,callback:o},n)for(var a=0;a<n.length;a++)xe[n[a]]=xe[e];t&&ze(e,t)}function ze(e,t,r,n){var o=xe[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 de(e,t,r){var n=xe[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 ut=function(){var e=100,t=-1,r=0,n=0,o=new Array(e);function a(h,p,g){var y=t%e,C=o[y];function k(b){var L=++t%e,I=o[L];I&&I.clear(),o[L]=h.setBookmark(b)}if(C){var m=C.find();m&&!be(m,p)&&k(p)}else k(p);k(g),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 g=o[(e+t)%e];if(g&&!g.find()){var y=p>0?1:-1,C,k=h.getCursor();do if(t+=y,g=o[(e+t)%e],g&&(C=g.find())&&!be(k,C))break;while(t<r&&t>n)}return g}function f(h,p){var g=t,y=c(h,p);return t=g,y&&y.find()}return{cachedCursor:void 0,add:a,find:f,move:c}},je=function(e){return e?{changes:e.changes,expectCursorActivityForChange:e.expectCursorActivityForChange}:{changes:[],expectCursorActivityForChange:!1}};class kt{constructor(){this.latestRegister=void 0,this.isPlaying=!1,this.isRecording=!1,this.replaySearchQueries=[],this.onRecordingDone=void 0,this.lastInsertModeChanges=je()}exitMacroRecordMode(){var t=A.macroModeState;t.onRecordingDone&&t.onRecordingDone(),t.onRecordingDone=void 0,t.isRecording=!1}enterMacroRecordMode(t,r){var n=A.registerController.getRegister(r);if(n){if(n.clear(),this.latestRegister=r,t.openDialog){var o=Ae("span",{class:"cm-vim-message"},"recording @"+r);this.onRecordingDone=t.openDialog(o,function(){},{bottom:!0})}this.isRecording=!0}}}function Re(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 A;function Fe(){A={searchQuery:null,searchIsReversed:!1,lastSubstituteReplacePart:void 0,jumpList:ut(),macroModeState:new kt,lastCharacterSearch:{increment:0,forward:!0,selectedCharacter:""},registerController:new mn({}),searchHistoryController:new Xt,exCommandHistoryController:new Xt};for(var e in xe){var t=xe[e];t.value=t.defaultValue}}class Xe{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 N,z={enterVimMode:x,leaveVimMode:T,buildKeyMap:function(){},getRegisterController:function(){return A.registerController},resetVimGlobalState_:Fe,getVimGlobalState_:function(){return A},maybeInitVimState_:Re,suppressErrorLogging:!1,InsertModeKey:Xe,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=u.length,r=v,n=u.slice(0,t-r);if(u=u.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 f in c)if(c[f]!==e){var h=Object.assign({},a);h.context=c[f],this._mapCommand(h)}}}},langmap:Jt,vimKeyFromEvent:it,setOption:ze,getOption:de,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:ai,findKey:function(e,t,r){var n=Re(e),o=e;function a(){var g=A.macroModeState;if(g.isRecording){if(t=="q")return g.exitMacroRecordMode(),le(o),!0;r!="mapping"&&ni(g,t)}}function c(){if(t=="<Esc>"){if(n.visualMode)Ne(o);else if(n.insertMode)Ue(o);else return;return le(o),!0}}function f(){if(c())return!0;n.inputState.keyBuffer.push(t);var g=n.inputState.keyBuffer.join(""),y=t.length==1,C=Qe.matchCommand(g,u,n.inputState,"insert"),k=n.inputState.changeQueue;if(C.type=="none")return le(o),!1;if(C.type=="partial"){if(C.expectLiteralNext&&(n.expectLiteralNext=!0),N&&window.clearTimeout(N),N=y&&window.setTimeout(function(){n.insertMode&&n.inputState.keyBuffer.length&&le(o)},de("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 L=me(m[b].anchor,m[b].head),I=We(m[b].anchor,m[b].head),E=o.getRange(L,o.state.overwrite?ne(I,0,1):I);k.removed[b]=(k.removed[b]||"")+E}}return!y}else C.type=="full"&&(n.inputState.keyBuffer.length=0);if(n.expectLiteralNext=!1,N&&window.clearTimeout(N),C.command&&k){for(var m=o.listSelections(),b=0;b<m.length;b++){var O=m[b].head;o.replaceRange(k.removed[b]||"",ne(O,0,-k.inserted.length),O,"+input")}A.macroModeState.lastInsertModeChanges.changes.pop()}return C.command||le(o),C.command}function h(){if(a()||c())return!0;n.inputState.keyBuffer.push(t);var g=n.inputState.keyBuffer.join("");if(/^[1-9]\d*$/.test(g))return!0;var y=/^(\d*)(.*)$/.exec(g);if(!y)return le(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=Qe.matchCommand(k,u,n.inputState,C);return m.type=="none"?(le(o),!1):m.type=="partial"?(m.expectLiteralNext&&(n.expectLiteralNext=!0),!0):m.type=="clear"?(le(o),!0):(n.expectLiteralNext=!1,n.inputState.keyBuffer.length=0,y=/^(\d*)(.*)$/.exec(g),y&&y[1]&&y[1]!="0"&&n.inputState.pushRepeatDigit(y[1]),m.command)}var p=n.insertMode?f():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"?$e(o,p.toKeys,p):Qe.processCommand(o,n,p)}catch(g){throw o.state.vim=void 0,Re(o),z.suppressErrorLogging||console.log(g),g}return!0})}},handleEx:function(e,t){ye.processCommand(e,t)},defineMotion:yn,defineAction:kn,defineOperator:Cn,mapCommand:ti,_mapCommand:Rt,defineRegister:vn,exitVisualMode:Ne,exitInsertMode:Ue},B=[],Z=!1,_;function Oe(e){if(!_)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(He[t]){var n=_.value||"",o={key:He[t],target:{value:n,selectionEnd:n.length,selectionStart:n.length}};_.onKeyDown&&_.onKeyDown(o,_.value,c),_&&_.onKeyUp&&_.onKeyUp(o,_.value,c);return}}if(e==`
|
|
3
|
+
`){var a=_;_=null,a.onClose&&a.onClose(a.value)}else _.value=(_.value||"")+e;function c(f){_&&(typeof f=="string"?_.value=f:_=null)}}function $e(e,t,r){var n=Z;if(r){if(B.indexOf(r)!=-1)return;B.push(r),Z=r.noremap!=!1}try{for(var o=Re(e),a=/<(?:[CSMA]-)*\w+>|./gi,c;c=a.exec(t);){var f=c[0],h=o.insertMode;if(_){Oe(f);continue}var p=z.handleKey(e,f,"mapping");if(!p&&h&&o.insertMode){if(f[0]=="<"){var g=f.toLowerCase().slice(1,-1),y=g.split("-");if(g=y.pop()||"",g=="lt")f="<";else if(g=="space")f=" ";else if(g=="cr")f=`
|
|
4
|
+
`;else if(He.hasOwnProperty(g)){f=He[g],Lr(e,f);continue}else f=f[0],a.lastIndex=c.index+1}e.replaceSelection(f)}}}finally{if(B.pop(),Z=B.length?n:!1,!B.length&&_){var C=_;_=null,ht(e,C)}}}var nt={Return:"CR",Backspace:"BS",Delete:"Del",Escape:"Esc",Insert:"Ins",ArrowLeft:"Left",ArrowRight:"Right",ArrowUp:"Up",ArrowDown:"Down",Enter:"CR"," ":"Space"},wt={Shift:1,Alt:1,Command:1,Control:1,CapsLock:1,AltGraph:1,Dead:1,Unidentified:1},He={};"Left|Right|Up|Down|End|Home".split("|").concat(Object.keys(nt)).forEach(function(e){He[(nt[e]||"").toLowerCase()]=He[e.toLowerCase()]=e});function it(e,t){var r=e.key;if(!wt[r]){r.length>1&&r[0]=="n"&&(r=r.replace("Numpad","")),r=nt[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(S.keymap&&r in S.keymap)(S.remapCtrl!=!1||!n)&&(r=S.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 Jt(e,t){S.string!==e&&(S=Zt(e)),S.remapCtrl=t}function Zt(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 f=0;f<a.length;++f)t[a[f]]=c[f]}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 S.string;Jt(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 le(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 Te{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(je(t))}pushSearchQuery(t){this.searchQueries.push(t)}clear(){this.keyBuffer=[],this.insertModeChanges=[],this.searchQueries=[],this.linewise=!1}toString(){return this.keyBuffer.join("")}}function vn(e,t){var r=A.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,U.push(e)}class mn{constructor(t){this.registers=t,this.unnamedRegister=t['"']=new Te,t["."]=new Te,t[":"]=new Te,t["/"]=new Te,t["+"]=new Te}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 Te(n,o,a);break;case"delete":case"change":n.indexOf(`
|
|
8
|
+
`)==-1?this.registers["-"]=new Te(n,o):(this.shiftNumericRegisters_(),this.registers[1]=new Te(n,o));break}this.unnamedRegister.setText(n,o,a);return}var f=ge(t);f?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 Te),this.registers[t]):this.unnamedRegister}isValidRegister(t){return t&&(Ye(t,U)||Q.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],f=0;f<=c.length;f++)if(this.initialPrefix==c.substring(0,f))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 Qe={matchCommand:function(e,t,r,n){var o=wn(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=xn(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=ft(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 le(e);n.operator=r.operator,n.operatorArgs=ft(r.operatorArgs),r.keys.length>1&&(n.operatorShortcut=r.keys),r.exitVisualBlock&&(t.visualBlock=!1,Ge(e)),t.visualMode&&this.evalInput(e,t)},processOperatorMotion:function(e,t,r){var n=t.visualMode,o=ft(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=ft(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,le(e),t.lastMotion=null,r.isEdit&&this.recordLastEdit(t,n,r),qe[r.action](e,c,t)},processSearch:function(e,t,r){if(!e.getSearchCursor)return;var n=r.searchArgs.forward,o=r.searchArgs.wholeWordOnly;Le(e).setReversed(!n);var a=n?"/":"?",c=Le(e).getQuery(),f=e.getScrollInfo(),h="";function p(E,O,K){A.searchHistoryController.pushInput(E),A.searchHistoryController.reset();try{ot(e,E,O,K)}catch{q(e,"Invalid regex: "+E),le(e);return}Qe.processMotion(e,t,{keys:"",type:"motion",motion:"findNext",motionArgs:{forward:!0,toJumplist:r.searchArgs.toJumplist}})}function g(E){e.scrollTo(f.left,f.top),p(E,!0,!0);var O=A.macroModeState;O.isRecording&&oi(O,E)}function y(){return de("pcre")?"(JavaScript regexp: set pcre)":"(Vim regexp: set nopcre)"}function C(E,O,K){var H=it(E),ie,G;H=="<Up>"||H=="<Down>"?(ie=H=="<Up>",G=E.target?E.target.selectionEnd:0,O=A.searchHistoryController.nextMatch(O,ie)||"",K(O),G&&E.target&&(E.target.selectionEnd=E.target.selectionStart=Math.min(G,E.target.value.length))):H&&H!="<Left>"&&H!="<Right>"&&A.searchHistoryController.reset(),h=O,k()}function k(){var E;try{E=ot(e,h,!0,!0)}catch{}E?e.scrollIntoView(yr(e,!n,E),30):(et(e),e.scrollTo(f.left,f.top))}function m(E,O,K){var H=it(E);H=="<Esc>"||H=="<C-c>"||H=="<C-[>"||H=="<BS>"&&O==""?(A.searchHistoryController.pushInput(O),A.searchHistoryController.reset(),ot(e,c?.source||""),et(e),e.scrollTo(f.left,f.top),s.e_stop(E),le(e),K(),e.focus()):H=="<Up>"||H=="<Down>"?s.e_stop(E):H=="<C-u>"&&(s.e_stop(E),K(""))}switch(r.searchArgs.querySrc){case"prompt":var b=A.macroModeState;if(b.isPlaying){let O=b.replaySearchQueries.shift();p(O||"",!0,!1)}else ht(e,{onClose:g,prefix:a,desc:Ae("span",{$cursor:"pointer",onmousedown:function(O){O.preventDefault(),ze("pcre",!de("pcre")),this.textContent=y(),k()}},y()),onKeyUp:C,onKeyDown:m});break;case"wordUnderCursor":var L=Mt(e,{noSymbol:!0}),I=!0;if(L||(L=Mt(e,{noSymbol:!1}),I=!1),!L){q(e,"No word under cursor"),le(e);return}let E=e.getLine(L.start.line).substring(L.start.ch,L.end.ch);I&&o?E="\\b"+E+"\\b":E=bn(E),A.jumpList.cachedCursor=e.getCursor(),e.setCursor(L.start),p(E,!0,!1);break}},processEx:function(e,t,r){function n(h){A.exCommandHistoryController.pushInput(h),A.exCommandHistoryController.reset(),ye.processCommand(e,h),e.state.vim&&le(e),et(e)}function o(h,p,g){var y=it(h),C,k;(y=="<Esc>"||y=="<C-c>"||y=="<C-[>"||y=="<BS>"&&p=="")&&(A.exCommandHistoryController.pushInput(p),A.exCommandHistoryController.reset(),s.e_stop(h),le(e),et(e),g(),e.focus()),y=="<Up>"||y=="<Down>"?(s.e_stop(h),C=y=="<Up>",k=h.target?h.target.selectionEnd:0,p=A.exCommandHistoryController.nextMatch(p,C)||"",g(p),k&&h.target&&(h.target.selectionEnd=h.target.selectionStart=Math.min(k,h.target.value.length))):y=="<C-u>"?(s.e_stop(h),g("")):y&&y!="<Left>"&&y!="<Right>"&&A.exCommandHistoryController.reset()}function a(h,p){var g=new s.StringStream(p),y={};try{if(ye.parseInput_(e,g,y),y.commandName!="s"){et(e);return}var C=ye.matchCommand_(y.commandName);if(!C||(ye.parseCommandArgs_(g,y,C),!y.argString))return;var k=mr(y.argString.slice(1),!0,!0);k&&At(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 f=t.inputState.getRepeat();f>1&&(c.value=".,.+"+(f-1),c.selectValueOnOpen=!1)}ht(e,c)}},evalInput:function(e,t){var r=t.inputState,n=r.motion,o=r.motionArgs||{repeat:1},a=r.operator,c=r.operatorArgs||{},f=r.registerName,h=t.sel,p=X(t.visualMode?ve(e,h.head):e.getCursor("head")),g=X(t.visualMode?ve(e,h.anchor):e.getCursor("anchor")),y=X(p),C=X(g),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,le(e),n){var L=Ie[n](e,p,o,t,r);if(t.lastMotion=Ie[n],!L)return;if(o.toJumplist){var I=A.jumpList,E=I.cachedCursor;E?(or(e,E,L),delete I.cachedCursor):or(e,p,L)}L instanceof Array?(m=L[0],k=L[1]):k=L,k||(k=X(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,Ge(e),Ve(e,t,"<",re(m,k)?m:k),Ve(e,t,">",re(m,k)?k:m)):a||(k=ve(e,k,y),e.setCursor(k.line,k.ch))}if(a){if(c.lastSel){m=C;var O=c.lastSel,K=Math.abs(O.head.line-O.anchor.line),H=Math.abs(O.head.ch-O.anchor.ch);O.visualLine?k=new i(C.line+K,C.ch):O.visualBlock?k=new i(C.line+K,C.ch+H):O.head.line==O.anchor.line?k=new i(C.line,C.ch+H):k=new i(C.line+K,C.ch),t.visualMode=!0,t.visualLine=O.visualLine,t.visualBlock=O.visualBlock,h=t.sel={anchor:m,head:k},Ge(e)}else t.visualMode&&(c.lastSel={anchor:X(h.anchor),head:X(h.head),visualBlock:t.visualBlock,visualLine:t.visualLine});var ie,G,ue,W,$;if(t.visualMode){ie=me(h.head,h.anchor),G=We(h.head,h.anchor),ue=t.visualLine||c.linewise,W=t.visualBlock?"block":ue?"line":"char";var Ce=l(e,ie,G);if($=bt(e,{anchor:Ce.start,head:Ce.end},W),ue){var fe=$.ranges;if(W=="block")for(var he=0;he<fe.length;he++)fe[he].head.ch=pe(e,fe[he].head.line);else W=="line"&&(fe[0].head=new i(fe[0].head.line+1,0))}}else{if(ie=X(m||C),G=X(k||y),re(G,ie)){var Je=ie;ie=G,G=Je}ue=o.linewise||c.linewise,ue?Tn(e,ie,G):o.forward&&On(e,ie,G),W="char";var Tt=!o.inclusive||ue,Ce=l(e,ie,G);$=bt(e,{anchor:Ce.start,head:Ce.end},W,Tt)}e.setSelections($.ranges,$.primary),t.lastMotion=null,c.repeat=b,c.registerName=f,c.linewise=ue;var It=St[a](e,c,$.ranges,C,k);t.visualMode&&Ne(e,It!=null),It&&e.setCursor(It)}},recordLastEdit:function(e,t,r){var n=A.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)}},Ie={moveToTopLine:function(e,t,r){var n=Et(e).top+r.repeat-1;return new i(n,Be(e.getLine(n)))},moveToMiddleLine:function(e){var t=Et(e),r=Math.floor((t.top+t.bottom)*.5);return new i(r,Be(e.getLine(r)))},moveToBottomLine:function(e,t,r){var n=Et(e).bottom-r.repeat+1;return new i(n,Be(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=Le(e),o=n.getQuery();if(o){var a=!r.forward;a=n.isReversed()?!a:a,At(e,o);var c=yr(e,a,o,r.repeat);return c||q(e,"No match found "+o+(de("pcre")?" (set nopcre to use Vim regexps)":"")),c}},findAndSelectNextInclusive:function(e,t,r,n,o){var a=Le(e),c=a.getQuery();if(c){var f=!r.forward;f=a.isReversed()?!f:f;var h=Jn(e,f,c,r.repeat,n);if(h){if(o.operator)return h;var p=h[0],g=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,g]:r.forward?[y,g]:[y,p]}else n.visualMode=!0,n.visualLine=!1,n.visualBlock=!1,s.signal(e,"vim-mode-change",{mode:"visual",subMode:""});return f?[g,p]:[p,g]}}},goToMark:function(e,t,r,n){var o=dt(e,n,r.selectedCharacter||"");return o?r.linewise?{line:o.line,ch:Be(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 f in n.marks)if(te(f)){var h=n.marks[f].find(),p=r.forward?re(h,c):re(c,h);if(!p&&!(r.linewise&&h.line==c.line)){var g=be(c,o),y=r.forward?tr(c,h,o):tr(o,h,c);(g||y)&&(o=h)}}}return r.linewise&&(o=new i(o.line,Be(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),f=r.forward?o.line+c:o.line-c,h=e.firstLine(),p=e.lastLine(),g=e.findPosV(o,r.forward?c:-c,"line",n.lastHSPos),y=r.forward?g.line>f:g.line<f;return y&&(f=g.line,a=g.ch),f<h&&o.line==h?this.moveToStartOfLine(e,t,r,n):f>p&&o.line==p?cr(e,t,r,n,!0):(r.toFirstChar&&(a=Be(e.getLine(f)),n.lastHPos=a),n.lastHSPos=e.charCoords(new i(f,a),"div").left,new i(f,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 f=e.findPosV(o,r.forward?1:-1,"line",n.lastHSPos);if(f.hitSide)break;o=f}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 ur(e,t,r.repeat,n).start},moveBySentence:function(e,t,r){var n=r.forward?1:-1;return Kn(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 f=e.charCoords(t,"local");if(r.repeat=c,a=Ie.moveByDisplayLines(e,t,r,n),!a)return null;var h=e.charCoords(a,"local");return e.scrollTo(null,o.top+h.top-f.top),a},moveByWords:function(e,t,r){return Pn(e,t,r.repeat,!!r.forward,!!r.wordEnd,!!r.bigWord)},moveTillCharacter:function(e,t,r){var n=r.repeat,o=Lt(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),Lt(e,n,r.forward,r.selectedCharacter,t)||t},moveToSymbol:function(e,t,r){var n=r.repeat;return r.selectedCharacter&&Bn(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,Dn(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,Be(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 f=e.getTokenTypeAt(new i(n,o+1));if(f!=="string"&&f!=="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,Be(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 f=!r.textObjectInner,h,p;if(o[c]){if(p=!0,h=hr(e,t,c,f),!h){var g=e.getSearchCursor(new RegExp("\\"+c,"g"),t);g.find()&&(h=hr(e,g.from(),c,f))}}else if(a[c])p=!0,h=Fn(e,t,c,f);else if(c==="W"||c==="w")for(var y=r.repeat||1;y-- >0;){var C=Mt(e,{inclusive:f,innerWord:!f,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=ur(e,t,r.repeat,0,f),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=In(e,t,f);else if(c==="s"){var m=e.getLine(t.line);t.ch>0&&_e(m[t.ch])&&(t.ch-=1);var b=fr(e,t,r.repeat,1,f),L=fr(e,t,r.repeat,-1,f);ae(e.getLine(L.line)[L.ch])&&ae(e.getLine(b.line)[b.ch-1])&&(L={line:L.line,ch:L.ch+1}),h={start:L,end:b}}return h?e.state.vim.visualMode?En(e,h.start,h.end,p):[h.start,h.end]:null},repeatLastCharacterSearch:function(e,t,r){var n=A.lastCharacterSearch,o=r.repeat,a=r.forward===n.forward,c=(n.increment?1:0)*(a?-1:1);r.inclusive=!!a;var f=Lt(e,o,a,n.selectedCharacter,ne(t,0,-c));return f?(f.ch+=c,f):t}};function yn(e,t){Ie[e]=t}function Gt(e,t){for(var r=[],n=0;n<t;n++)r.push(e);return r}var St={change:function(e,t,r){var n,o,a=e.state.vim,c=r[0].anchor,f=r[0].head;if(a.visualMode)if(t.fullLine)f.ch=Number.MAX_VALUE,f.line--,e.setSelection(c,f),o=e.getSelection(),e.replaceSelection(""),n=c;else{o=e.getSelection();var g=Gt("",r.length);e.replaceSelections(g),n=me(r[0].head,r[0].anchor)}else{o=e.getRange(c,f);var h=a.lastEditInputState;if(h?.motion=="moveByWords"&&!ae(o)){var p=/\s+$/.exec(o);p&&h.motionArgs&&h.motionArgs.forward&&(f=ne(f,0,-p[0].length),o=o.slice(0,-p[0].length))}t.linewise&&(c=new i(c.line,Be(e.getLine(c.line))),f.line>c.line&&(f=new i(f.line-1,Number.MAX_VALUE))),e.replaceRange("",c,f),n=c}A.registerController.pushText(t.registerName,"change",o,t.linewise,r.length>1),qe.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=me(r[0].head,r[0].anchor)}else{var c=r[0].anchor,f=r[0].head;t.linewise&&f.line!=e.firstLine()&&c.line==e.lastLine()&&c.line==f.line-1&&(c.line==e.firstLine()?c.ch=0:c=new i(c.line-1,pe(e,c.line-1))),o=e.getRange(c,f),e.replaceRange("",c,f),n=c,t.linewise&&(n=Ie.moveToFirstNonWhiteSpaceCharacter(e,c))}return A.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),f,h=r.length-1;h>=0;h--)if(f=me(r[h].anchor,r[h].head),t.indentRight)e.replaceRange(c.repeat(o),f,f);else{for(var p=e.getLine(f.line),g=0,y=0;y<o;y++){var C=p[f.ch+g];if(C==" ")g++;else if(C==" "){g++;for(var k=1;k<c.length&&(C=p[f.ch+g],C===" ");k++)g++}else break}e.replaceRange("",f,ne(f,0,g))}return f}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 Ie.moveToFirstNonWhiteSpaceCharacter(e,r[0].anchor)},indentAuto:function(e,t,r){return e.execCommand("indentAuto"),Ie.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=[],f=t.toLower,h=0;h<a.length;h++){var p=a[h],g="";if(f===!0)g=p.toLowerCase();else if(f===!1)g=p.toUpperCase();else for(var y=0;y<p.length;y++){var C=p.charAt(y);g+=ge(C)?C.toLowerCase():C.toUpperCase()}c.push(g)}return e.replaceSelections(c),t.shouldMoveCursor?o:!e.state.vim.visualMode&&t.linewise&&r[0].anchor.line+1==r[0].head.line?Ie.moveToFirstNonWhiteSpaceCharacter(e,n):t.linewise?n:me(r[0].anchor,r[0].head)},yank:function(e,t,r,n){var o=e.state.vim,a=e.getSelection(),c=o.visualMode?me(o.sel.anchor,o.sel.head,r[0].head,r[0].anchor):n;A.registerController.pushText(t.registerName,"yank",a,t.linewise,o.visualBlock);var f=Math.abs(e.getCursor("end").line-e.getCursor("start").line)||1;return q(e,f+" lines yanked"+(t.registerName?' into "'+t.registerName:""),!1,1500),c},rot13:function(e,t,r,n,o){for(var a=e.getSelections(),c=[],f=0;f<a.length;f++){const h=a[f].split("").map(p=>{const g=p.charCodeAt(0);return g>=65&&g<=90?String.fromCharCode(65+(g-65+13)%26):g>=97&&g<=122?String.fromCharCode(97+(g-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?Ie.moveToFirstNonWhiteSpaceCharacter(e,n):t.linewise?n:me(r[0].anchor,r[0].head)}};function Cn(e,t){St[e]=t}var qe={jumpListWalk:function(e,t,r){if(!r.visualMode){var n=t.repeat||1,o=t.forward,a=A.jumpList,c=a.move(e,o?n:-n),f=c?c.find():void 0;f=f||e.getCursor(),e.setCursor(f)}},scroll:function(e,t,r){if(!r.visualMode){var n=t.repeat||1,o=e.defaultTextHeight(),a=e.getScrollInfo().top,c=o*n,f=t.forward?a+c:a-c,h=X(e.getCursor()),p=e.charCoords(h,"local");if(t.forward)f>p.top?(h.line+=(f-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,f);else{var g=f+e.getScrollInfo().clientHeight;g<p.bottom?(h.line-=(p.bottom-g)/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,f)}}},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),f=e.charCoords(c,"local"),h=f.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=A.macroModeState;for(n=="@"?n=a.latestRegister||"":a.latestRegister=n;o--;)ri(e,r,a,n)},enterMacroRecordMode:function(e,t){var r=A.macroModeState,n=t.selectedCharacter;A.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,pe(e,a.line));else if(n=="bol")a=new i(a.line,0);else if(n=="charAfter"){var f=l(e,a,ne(a,0,1));a=f.end}else if(n=="firstNonBlank"){var f=l(e,a,Ie.moveToFirstNonWhiteSpaceCharacter(e,a));a=f.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=ne(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"})),A.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&&Ne(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":""}),Ge(e)):Ne(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":""}),Ge(e),Ve(e,r,"<",me(o,a)),Ve(e,r,">",We(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,Ge(e),Ve(e,r,"<",me(o,a)),Ve(e,r,">",We(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"),re(o,n)){var a=o;o=n,n=a}o.ch=pe(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 f=0,h=n.line;h<o.line;h++){f=pe(e,n.line);var p="",g=0;if(!t.keepSpaces){var y=e.getLine(n.line+1);g=y.search(/\S/),g==-1?g=y.length:p=" "}e.replaceRange(p,new i(n.line,f),new i(n.line+1,g))}var C=ve(e,new i(n.line,f));r.visualMode&&Ne(e,!1),e.setCursor(C)},newLineAndEnterInsertMode:function(e,t,r){r.insertMode=!0;var n=X(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=pe(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=A.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=X(e.getCursor());if(n){if(t.matchIndent){var c=e.getOption("tabSize"),f=function(fe){var he=fe.split(" ").length-1,Je=fe.split(" ").length-1;return he*c+Je*1},h=e.getLine(e.getCursor().line),p=f(h.match(/^\s*/)[0]),g=n.replace(/\n$/,""),y=n!==g,C=f(n.match(/^\s*/)[0]),n=g.replace(/^\s*/gm,function(fe){var he=p+(f(fe)-C);if(he<0)return"";if(e.getOption("indentWithTabs")){var Je=Math.floor(he/c);return Array(Je+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 L=0;L<b.length;L++)b[L]=b[L]==""?" ":b[L];a.ch+=t.after?1:0,a.ch=Math.min(pe(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=pe(e,a.line)):a.ch=0:a.ch+=t.after?1:0;var I;if(r.visualMode){r.lastPastedText=n;var E,O=An(e),K=O[0],H=O[1],ie=e.getSelection(),G=e.listSelections(),ue=new Array(G.length).join("1").split("1");r.lastSelection&&(E=r.lastSelection.headMark.find()),A.registerController.unnamedRegister.setText(ie),m?(e.replaceSelections(ue),H=new i(K.line+n.length-1,K.ch),e.setCursor(K),rr(e,H),e.replaceSelections(n),I=K):r.visualBlock?(e.replaceSelections(ue),e.setCursor(K),e.replaceRange(n,K,K),I=K):(e.replaceRange(n,K,H),I=e.posFromIndex(e.indexFromPos(K)+n.length-1)),E&&(r.lastSelection.headMark=e.setBookmark(E)),k&&(I.ch=0)}else if(m&&b){e.setCursor(a);for(var L=0;L<b.length;L++){var W=a.line+L;W>e.lastLine()&&e.replaceRange(`
|
|
15
|
+
`,new i(W,0));var $=pe(e,W);$<a.ch&&Mn(e,W,a.ch)}e.setCursor(a),rr(e,new i(a.line+b.length-1,a.ch)),e.replaceSelections(b),I=a}else if(e.replaceRange(n,a),k){var W=t.after?a.line+1:a.line;I=new i(W,Be(e.getLine(W)))}else I=X(a),/\n/.test(n)||(I.ch+=n.length-(t.after?1:0));r.visualMode&&Ne(e,!1),e.setCursor(I)}},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=A.registerController.getRegister(n),a=o&&o.toString();a&&e.replaceSelection(a)},oneNormalCommand:function(e,t,r){Ue(e,!0),r.insertModeReturn=!0,s.on(e,"vim-command-done",function n(){r.visualMode||(r.insertModeReturn&&(r.insertModeReturn=!1,r.insertMode||qe.enterInsertMode(e,{},r)),s.off(e,"vim-command-done",n))})},setMark:function(e,t,r){var n=t.selectedCharacter;n&&Ve(e,r,n,e.getCursor())},replace:function(e,t,r){var n=t.selectedCharacter||"",o=e.getCursor(),a,c,f=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 g=e.getRange(o,c);if(g=g.replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,n),g=g.replace(/[^\n]/g,n),r.visualBlock){var y=new Array(e.getOption("tabSize")+1).join(" ");g=e.getSelection(),g=g.replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,n);var C=g.replace(/\t/g,y).replace(/[^\n]/g,n).split(`
|
|
17
|
+
`);e.replaceSelections(C)}else e.replaceRange(g,o,c);r.visualMode?(o=re(f[0].anchor,f[0].head)?f[0].anchor:f[0].head,e.setCursor(o),Ne(e,!1)):e.setCursor(ne(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,f,h;(a=o.exec(n))!==null&&(c=a.index,f=c+a[0].length,!(r.ch<f)););if(!(!t.backtrack&&f<=r.ch)){if(a){var p=a[2]||a[4],g=a[3]||a[5],y=t.increase?1:-1,C={"0b":2,0:8,"":10,"0x":16}[p.toLowerCase()],k=parseInt(a[1]+g,C)+y*t.repeat;h=k.toString(C);var m=p?new Array(g.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),L=new i(r.line,f);e.replaceRange(h,b,L)}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){Ue(e)}};function kn(e,t){qe[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),f=c.length-1+ +!!o,h=Math.min(Math.max(0,t.ch),f),p=c.charCodeAt(h);if(56320<=p&&p<=57343){var g=1;r&&r.line==a&&r.ch>h&&(g=-1),h+=g,h>f&&(h-=2)}return new i(a,h)}function ft(e){var t={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}function ne(e,t,r){return typeof t=="object"&&(r=t.ch,t=t.line),new i(e.line+t,e.ch+r)}function wn(e,t,r,n){n.operator&&(r="operatorPending");for(var o,a=[],c=[],f=Z?t.length-v:0,h=f;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 xn(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 X(e){return new i(e.line,e.ch)}function be(e,t){return e.ch==t.ch&&e.line==t.line}function re(e,t){return e.line<t.line||e.line==t.line&&e.ch<t.ch}function me(e,t){return arguments.length>2&&(t=me.apply(void 0,Array.prototype.slice.call(arguments,1))),re(e,t)?e:t}function We(e,t){return arguments.length>2&&(t=We.apply(void 0,Array.prototype.slice.call(arguments,1))),re(e,t)?t:e}function tr(e,t,r){var n=re(e,t),o=re(t,r);return n&&o}function pe(e,t){return e.getLine(t).length}function xt(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}function bn(e){return e.replace(/([.?*+$\[\]\/\\(){}|\-])/g,"\\$1")}function Mn(e,t,r){var n=pe(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=X(e.clipPos(t)),a=!be(t,o),c=e.getCursor("head"),f=Ln(n,c),h=be(n[f].head,n[f].anchor),p=n.length-1,g=p-f>f?p:0,y=n[g].anchor,C=Math.min(y.line,o.line),k=Math.max(y.line,o.line),m=y.ch,b=o.ch,L=n[g].head.ch-m,I=b-m;L>0&&I<=0?(m++,a||b--):L<0&&I>=0?(m--,h||b++):L<0&&I==-1&&(m--,b++);for(var E=C;E<=k;E++){var O={anchor:new i(E,m),head:new i(E,b)};r.push(O)}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=ne(t,o,0);n.push({anchor:a,head:a})}e.setSelections(n,0)}function Ln(e,t,r){for(var n=0;n<e.length;n++){var o=be(e[n].anchor,t),a=be(e[n].head,t);if(o||a)return n}return-1}function An(e,t){var r=e.listSelections(),n=r[0],o=r[r.length-1],a=re(n.anchor,n.head)?n.anchor:n.head,c=re(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:X(r),head:X(n),visualMode:t.visualMode,visualLine:t.visualLine,visualBlock:t.visualBlock}}function En(e,t,r,n){var o=e.state.vim.sel,a=n?t:o.head,c=n?t:o.anchor,f;return re(r,t)&&(f=r,r=t,t=f),re(a,c)?(a=me(t,a),c=We(c,r)):(c=me(t,c),a=We(a,r),a=ne(a,0,-1),a.ch==-1&&a.line!=e.firstLine()&&(a=new i(a.line-1,pe(e,a.line-1)))),[c,a]}function Ge(e,t,r){var n=e.state.vim;t=t||n.sel,r||(r=n.visualLine?"line":n.visualBlock?"block":"char");var o=bt(e,t,r);e.setSelections(o.ranges,o.primary)}function bt(e,t,r,n){var o=X(t.head),a=X(t.anchor);if(r=="char"){var c=!n&&!re(t.head,t.anchor)?1:0,f=re(t.head,t.anchor)?1:0;return o=ne(t.head,0,c),a=ne(t.anchor,0,f),{ranges:[{anchor:a,head:o}],primary:0}}else if(r=="line"){if(re(t.head,t.anchor))o.ch=0,a.ch=pe(e,a.line);else{a.ch=0;var h=e.lastLine();o.line>h&&(o.line=h),o.ch=pe(e,o.line)}return{ranges:[{anchor:a,head:o}],primary:0}}else if(r=="block"){var p=Math.min(a.line,o.line),g=a.ch,y=Math.max(a.line,o.line),C=o.ch;g<C?C+=1:g+=1;for(var k=y-p+1,m=o.line==p?0:k-1,b=[],L=0;L<k;L++)b.push({anchor:new i(p+L,g),head:new i(p+L,C)});return{ranges:b,primary:m}}throw"never happens"}function Rn(e){var t=e.getCursor("head");return e.getSelection().length==1&&(t=me(t,e.getCursor("anchor"))),t}function Ne(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 On(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&&ae(a);a=o.pop())r.line--,r.ch=0;a?(r.line--,r.ch=pe(e,r.line)):r.ch=0}}function Tn(e,t,r){t.ch=0,r.ch=0,r.line++}function Be(e){if(!e)return 0;var t=e.search(/\S/);return t==-1?e.length:t}function Mt(e,{inclusive:t,innerWord:r,bigWord:n,noSymbol:o,multiline:a},c){var f=c||Rn(e),h=e.getLine(f.line),p=h,g=f.line,y=g,C=f.ch,k,m=o?P[0]:D[0];if(r&&/\s/.test(h.charAt(C)))m=function(K){return/\s/.test(K)};else{for(;!m(h.charAt(C));)if(C++,C>=h.length){if(!a)return null;C--,k=lr(e,f,!0,n,!0);break}n?m=D[0]:(m=P[0],m(h.charAt(C))||(m=P[1]))}for(var b=C,L=C;m(h.charAt(L))&&L>=0;)L--;if(L++,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 I=b,E=f.ch<=L&&/\s/.test(h.charAt(f.ch));if(!E)for(;/\s/.test(p.charAt(b))&&b<p.length;)b++;if(I==b||E){for(var O=L;/\s/.test(h.charAt(L-1))&&L>0;)L--;!L&&!E&&(L=O)}}return{start:new i(g,L),end:new i(y,b)}}function In(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){be(t,r)||A.jumpList.add(e,t,r)}function ar(e,t){A.lastCharacterSearch.increment=e,A.lastCharacterSearch.forward=t.forward,A.lastCharacterSearch.selectedCharacter=t.selectedCharacter}var Nn={"(":"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 Bn(e,t,r,n){var o=X(e.getCursor()),a=r?1:-1,c=r?e.lineCount():-1,f=o.ch,h=o.line,p=e.getLine(h),g={lineText:p,nextCh:p.charAt(f),lastCh:null,index:f,symb:n,reverseSymb:(r?{")":"(","}":"{"}:{"(":")","{":"}"})[n],forward:r,depth:0,curMoveThrough:!1},y=Nn[n];if(!y)return o;var C=sr[y].init,k=sr[y].isComplete;for(C&&C(g);h!==c&&t;){if(g.index+=a,g.nextCh=g.lineText.charAt(g.index),!g.nextCh){if(h+=a,g.lineText=e.getLine(h)||"",a>0)g.index=0;else{var m=g.lineText.length;g.index=m>0?m-1:0}g.nextCh=g.lineText.charAt(g.index)}k(g)&&(o.line=h,o.ch=g.index,t--)}return g.nextCh||g.curMoveThrough?new i(h,g.index):o}function lr(e,t,r,n,o){var a=t.line,c=t.ch,f=e.getLine(a),h=r?1:-1,p=n?D:P;if(o&&f==""){if(a+=h,f=e.getLine(a),!oe(e,a))return null;c=r?0:f.length}for(;;){if(o&&f=="")return{from:0,to:0,line:a};for(var g=h>0?f.length:-1,y=g,C=g;c!=g;){for(var k=!1,m=0;m<p.length&&!k;++m)if(p[m](f.charAt(c))){for(y=c;c!=g&&p[m](f.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,!oe(e,a))return null;f=e.getLine(a),c=h>0?0:f.length}}function Pn(e,t,r,n,o,a){var c=X(t),f=[];(n&&!o||!n&&o)&&r++;for(var h=!(n&&o),p=0;p<r;p++){var g=lr(e,t,n,a,h);if(!g){var y=pe(e,e.lastLine());f.push(n?{line:e.lastLine(),from:y,to:y}:{line:0,from:0,to:0});break}f.push(g),t=new i(g.line,n?g.to-1:g.from)}var C=f.length!=r,k=f[0],m=f.pop();return n&&!o?(!C&&(k.from!=c.ch||k.line!=c.line)&&(m=f.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=f.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),f=e.clipPos(c);return f.ch--,o||(n.lastHPos=1/0,n.lastHSPos=e.charCoords(f,"div").left),c}function Lt(e,t,r,n,o){if(n){for(var a=o||e.getCursor(),c=a.ch,f,h=0;h<t;h++){var p=e.getLine(a.line);if(f=_n(c,p,n,r),f==-1)return;c=f}if(f!=null)return new i(e.getCursor().line,f)}}function Dn(e,t){var r=e.getCursor().line;return ve(e,new i(r,t-1))}function Ve(e,t,r,n){!Ye(r,F)&&!Q.test(r)||(t.marks[r]&&t.marks[r].clear(),t.marks[r]=e.setBookmark(n))}function _n(e,t,r,n,o){var a;return n?a=t.indexOf(r,e+1):a=t.lastIndexOf(r,e-1),a}function ur(e,t,r,n,o){var a=t.line,c=e.firstLine(),f=e.lastLine(),h,p,g=a;function y(L){return!e.getLine(L)}function C(L,I,E){return E?y(L)!=y(L+I):!y(L)&&y(L+I)}if(n){for(;c<=g&&g<=f&&r>0;)C(g,n)&&r--,g+=n;return{start:new i(g,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(g=a;g<=f&&r;g++)C(g,1,!0)&&(!o||y(g)!=b)&&r--;for(p=new i(g,0),g>f&&!b?b=!0:o=!1,g=a;g>c&&!((!o||y(g)==b||g==a)&&C(g,-1,!0));g--);return h=new i(g,0),{start:h,end:p}}function fr(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,g,y,C){var k=p.getLine(g),m={line:k,ln:g,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&&ae(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 f(p,g,y,C){var k=p.getLine(g),m={line:k,ln:g,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(!ae(m.line[m.pos])&&!_e(m.line[m.pos]))b=m.pos;else if(_e(m.line[m.pos]))return o?ae(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&&ae(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=f(e,h.ln,h.pos,n):h=c(e,h.ln,h.pos,n),r--;return new i(h.ln,h.pos)}function Kn(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,!oe(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,g,y){var L=h.getLine(p),C=L==="",k={line:L,ln:p,pos:g,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!==""&&!ae(k.line[k.pos]))return{ln:k.ln,pos:k.pos};_e(k.line[k.pos])&&!C&&(k.pos===k.line.length-1||ae(k.line[k.pos+1]))&&(C=!0),o(h,k)}var L=h.getLine(m.ln);m.pos=0;for(var I=L.length-1;I>=0;--I)if(!ae(L[I])){m.pos=I;break}return m}function c(h,p,g,y){var L=h.getLine(p),C={line:L,ln:p,pos:g,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!==""&&!ae(C.line[C.pos])&&(b=!1,k=C.ln,m=C.pos),o(h,C)}var L=h.getLine(k);m=0;for(var I=0;I<L.length;++I)if(!ae(L[I])){m=I;break}return{ln:k,pos:m}}for(var f={ln:t.line,pos:t.ch};r>0;)n<0?f=c(e,f.ln,f.pos,n):f=a(e,f.ln,f.pos,n),r--;return new i(f.ln,f.pos)}function hr(e,t,r,n){var o=t,a={"(":/[()]/,")":/[()]/,"[":/[[\]]/,"]":/[[\]]/,"{":/[{}]/,"}":/[{}]/,"<":/[<>]/,">":/[<>]/}[r],c={"(":"(",")":"(","[":"[","]":"[","{":"{","}":"{","<":"<",">":"<"}[r],f=e.getLine(o.line).charAt(o.ch),h=f===c?1:0,p=e.scanForBracket(new i(o.line,o.ch+h),-1,void 0,{bracketRegex:a}),g=e.scanForBracket(new i(o.line,o.ch+h),1,void 0,{bracketRegex:a});if(!p||!g)return null;var y=p.pos,C=g.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=X(t),a=e.getLine(o.line),c=a.split(""),f,h,p,g,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(ne(t,0,1))),k=/string/.test(e.getTokenTypeAt(t)),m=C&&!k;m||(h=o.ch,--o.ch)}if(c[o.ch]==r&&!h)f=o.ch+1;else for(p=o.ch;p>-1&&!f;p--)c[p]==r&&(f=p+1);if(f&&!h)for(p=f,g=c.length;p<g&&!h;p++)c[p]==r&&(h=p);return!f||!h?{start:o,end:o}:(n&&(--f,++h),{start:new i(o.line,f),end:new i(o.line,h)})}Ke("pcre",!0,"boolean");class $n{constructor(){this.highlightTimeout}getQuery(){return A.query}setQuery(t){A.query=t}getOverlay(){return this.searchOverlay}setOverlay(t){this.searchOverlay=t}isReversed(){return A.isReversed}setReversed(t){A.isReversed=t}getScrollbarAnnotate(){return this.annotate}setScrollbarAnnotate(t){this.annotate=t}}function Le(e){var t=e.state.vim;return t.searchState_||(t.searchState_=new $n)}function Hn(e){return dr(e,"/")}function Vn(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 jn(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 f=c[1];return f==="}"||n.indexOf(f)!=-1?f:f in t?(n=t[f],""):f in r?r[f]: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 gr={"\\n":`
|
|
20
|
+
`,"\\r":"\r","\\t":" "};function Wn(e){for(var t=!1,r=[],n=-1;n<e.length;n++){var o=e.charAt(n)||"",a=e.charAt(n+1)||"";gr[o+a]?(r.push(gr[o+a]),n++):t?(r.push(o),t=!1):o==="\\"?(t=!0,ce(a)||a==="$"?r.push("$"):a!=="/"&&a!=="\\"&&r.push("\\")):(o==="$"&&r.push("$"),r.push(o),a==="/"&&r.push("\\"))}return r.join("")}var vr={"\\/":"/","\\\\":"\\","\\n":`
|
|
21
|
+
`,"\\r":"\r","\\t":" ","\\&":"&"};function Un(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 vr)if(t.match(o,!0)){n=!0,r.push(vr[o]);break}n||r.push(t.next())}return r.join("")}function mr(e,t,r){var n=A.registerController.getRegister("/");n.setText(e);var o=Vn(e),a,c;if(!o.length)a=e;else{a=e.substring(0,o[0]);var f=e.substring(o[0]);c=f.indexOf("i")!=-1}if(!a)return null;de("pcre")||(a=jn(a)),r&&(t=/^[^A-Z]*$/.test(a));var h=new RegExp(a,t||c?"im":"m");return h}function Ae(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=Ae("div",{$color:"red",$whiteSpace:"pre",class:"cm-vim-message"},t);e.openNotification?r?(o=Ae("div",{},o,Ae("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 zn(e,t){return Ae("div",{$display:"flex",$flex:1},Ae("span",{$fontFamily:"monospace",$whiteSpace:"pre",$flex:1,$display:"flex"},e,Ae("input",{type:"text",autocorrect:"off",autocapitalize:"off",spellcheck:"false",$flex:1})),t&&Ae("span",{$color:"#888"},t))}function ht(e,t){if(B.length){t.value||(t.value=""),_=t;return}var r=zn(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 Qn(e,t){return e instanceof RegExp&&t instanceof RegExp?e.flags==t.flags&&e.source==t.source:!1}function ot(e,t,r,n){if(t){var o=Le(e),a=mr(t,!!r,!!n);if(a)return At(e,a),Qn(a,o.getQuery())||o.setQuery(a),a}}function qn(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 at=0;function At(e,t){clearTimeout(at);var r=Le(e);r.highlightTimeout=at,at=setTimeout(function(){if(e.state.vim){var n=Le(e);n.highlightTimeout=void 0;var o=n.getOverlay();(!o||t!=o.query)&&(o&&e.removeOverlay(o),o=qn(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 f=a.find(t);if(c==0&&f&&be(a.from(),o)){var h=t?a.from():a.to();f=a.find(t),f&&!f[0]&&be(a.from(),h)&&e.getLine(h.line).length==h.ch&&(f=a.find(t))}if(!f&&(a=e.getSearchCursor(r,t?new i(e.lastLine()):new i(e.firstLine(),0)),!a.find(t)))return}return a.from()})}function Jn(e,t,r,n,o){return e.operation(function(){n===void 0&&(n=1);var a=e.getCursor(),c=e.getSearchCursor(r,a),f=c.find(!t);!o.visualMode&&f&&be(c.from(),a)&&c.find(!t);for(var h=0;h<n;h++)if(f=c.find(t),!f&&(c=e.getSearchCursor(r,t?new i(e.lastLine()):new i(e.firstLine(),0)),!c.find(t)))return;var p=c.from(),g=c.to();return p&&g&&[p,g]})}function et(e){var t=Le(e);t.highlightTimeout&&(clearTimeout(t.highlightTimeout),t.highlightTimeout=void 0),e.removeOverlay(Le(e).getOverlay()),t.setOverlay(null),t.getScrollbarAnnotate()&&(t.getScrollbarAnnotate().clear(),t.setScrollbarAnnotate(null))}function Zn(e,t,r){return typeof e!="number"&&(e=e.line),t instanceof Array?Ye(e,t):typeof r=="number"?e>=t&&e<=r:e==t}function Et(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 dt(e,t,r){if(r=="'"||r=="`")return A.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 X(t[r].changes[0].to)}class Yn{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=A.registerController.getRegister(":"),c=a.toString(),f=new s.StringStream(r);a.setText(r);var h=n||{};h.input=r;try{this.parseInput_(t,f,h)}catch(y){q(t,y+"");return}o.visualMode&&Ne(t);var p,g;if(!h.commandName)h.line!==void 0&&(g="move");else if(p=this.matchCommand_(h.commandName),p){if(g=p.name,p.excludeFromCommandHistory&&a.setText(c),this.parseCommandArgs_(f,h,p),p.type=="exToKey"){$e(t,p.toKeys||"",p);return}else if(p.type=="exToEx"){this.processCommand(t,p.toInput||"");return}}if(!g){q(t,'Not an editor command ":'+r+'"');return}try{kr[g](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=dt(t,t.state.vim,"<")?.line,n.selectionLineEnd=dt(t,t.state.vim,">")?.line):n.selectionLine=t.getCursor().line:(n.selectionLine=n.line,n.selectionLineEnd=n.lineEnd),r.eatSpace();var f=r.match(/^(\w+|!!|@@|[!#&*<=>@~])/);return f?n.commandName=f[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=dt(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 f=r.match(c?/^([^\/\\]|\\\/)*/:/^([^\/\?]|\\\?)*/);r.match(c?/^\/?/:/^\??/),a=f&&f[0]}a||(a=A.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 g=p.from();if(!g)throw new Error("Pattern not found"+h);n=g.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),Rt(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<u.length;a++)if(o==u[a].keys&&u[a].context===r)return u.splice(a,1),ei(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){z.mapclear()},imapclear:function(e,t){z.mapclear("insert")},nmapclear:function(e,t){z.mapclear("normal")},vmapclear:function(e,t){z.mapclear("visual")},omapclear:function(e,t){z.mapclear("operatorPending")},move:function(e,t){Qe.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,f=!1,h=!1;if(a.charAt(a.length-1)=="?"){if(c)throw Error("Trailing characters: "+t.argString);a=a.substring(0,a.length-1),f=!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=xe[a]&&xe[a].type=="boolean";if(p&&(h?c=!de(a,e,n):c==null&&(c=!0)),!p&&c===void 0||f){var g=de(a,e,n);g instanceof Error?q(e,g.message):g===!0||g===!1?q(e," "+(g?"":"no")+a):q(e," "+a+"="+g)}else{var y=ze(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=A.registerController.registers,o=`----------Registers----------
|
|
22
|
+
|
|
23
|
+
`;if(r)for(var f=r.join(""),h=0;h<f.length;h++){var a=f.charAt(h);if(A.registerController.isValidRegister(a)){var p=n[a]||new Te;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 f=r.join(""),h=0;h<f.length;h++){var a=f.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,f;function h(){if(t.argString){var W=new s.StringStream(t.argString);if(W.eat("!")&&(r=!0),W.eol())return;if(!W.eatSpace())return"Invalid arguments";var $=W.match(/([dinuoxr]+)?\s*(\/.+\/)?\s*/);if(!$||!W.eol())return"Invalid arguments";if($[1]){f=$[1].indexOf("r")!=-1,n=$[1].indexOf("i")!=-1,o=$[1].indexOf("u")!=-1;var Ce=$[1].indexOf("d")!=-1||$[1].indexOf("n")!=-1,fe=$[1].indexOf("x")!=-1,he=$[1].indexOf("o")!=-1;if(Number(Ce)+Number(fe)+Number(he)>1)return"Invalid arguments";a=Ce&&"decimal"||fe&&"hex"||he&&"octal"}$[2]&&(c=new RegExp($[2].substr(1,$[2].length-2),n?"i":""))}}var p=h();if(p){q(e,p+": "+t.argString);return}var g=t.line||e.firstLine(),y=t.lineEnd||t.line||e.lastLine();if(g==y)return;var C=new i(g,0),k=new i(y,pe(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,L=a=="decimal"?10:a=="hex"?16:a=="octal"?8:void 0,I=[],E=[];if(a||c)for(var O=0;O<m.length;O++){var K=c?m[O].match(c):null;K&&K.index!=null&&!f&&(K[0]=m[O].slice(K.index+K[0].length)),K&&K[0]!=""?I.push(K):b&&b.exec(m[O])?I.push(m[O]):E.push(m[O])}else E=m;function H(W,$){if(r){var Ce;Ce=W,W=$,$=Ce}n&&(W=W.toLowerCase(),$=$.toLowerCase());var fe=b&&b.exec(W),he=b&&b.exec($);if(!fe||!he)return W<$?-1:1;var Je=parseInt((fe[1]+fe[2]).toLowerCase(),L),Tt=parseInt((he[1]+he[2]).toLowerCase(),L);return Je-Tt}function ie(W,$){if(r){var Ce;Ce=W,W=$,$=Ce}return n&&(W[0]=W[0].toLowerCase(),$[0]=$[0].toLowerCase()),W[0]<$[0]?-1:1}if(I.sort(c?ie:H),c)for(var O=0;O<I.length;O++)I[O]=I[O].input;else a||E.sort(H);if(m=r?I.concat(E):E.concat(I),o){var G=m,ue;m=[];for(var O=0;O<G.length;O++)G[O]!=ue&&m.push(G[O]),ue=G[O]}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),$e(e,t.argString.trimStart(),{noremap:r}),e.state.vim.insertMode&&Ue(e,!0);else $e(e,t.argString.trimStart(),{noremap:r}),e.state.vim.insertMode&&Ue(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=Hn(r),f=r,h="";if(c&&c.length&&(f=c[0],h=c.slice(1,c.length).join("/")),f)try{ot(e,f,!0,!0)}catch{q(e,"Invalid regex: "+f);return}for(var p=Le(e).getQuery(),g=[],y=o;y<=a;y++){var C=e.getLine(y),k=p.test(C);k!==n&&g.push(h?e.getLineHandle(y):C)}if(!h){q(e,g.join(`
|
|
33
|
+
`));return}var m=0,b=function(){if(m<g.length){var L=g[m++],I=e.getLineNumber(L);if(I==null){b();return}var E=I+1+h;ye.processCommand(e,E,{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,f,h,p=!1,g=!1;if(n&&n.length)o=n[0],de("pcre")&&o!==""&&(o=new RegExp(o).source),a=n[1],a!==void 0&&(de("pcre")?a=Un(a.replace(/([^\\])&/g,"$1$$&")):a=Wn(a),A.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&&(f=c[0],h=parseInt(c[1]),f&&(f.indexOf("c")!=-1&&(p=!0),f.indexOf("g")!=-1&&(g=!0),de("pcre")?o=o+"/"+f:o=o.replace(/\//g,"\\/")+"/"+f)),o)try{ot(e,o,!0,!0)}catch{q(e,"Invalid regex: "+o);return}if(a=a||A.lastSubstituteReplacePart,a===void 0){q(e,"No previous substitute regular expression");return}var y=Le(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)),L=e.getSearchCursor(C,b);Xn(e,p,g,k,m,L,C,a,t.callback)},startinsert:function(e,t){$e(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){et(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";A.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)),qe.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;St.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)),qe.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,f=n.next();if(c&&f&&te(c)==te(f)){var h=c.charCodeAt(0),p=f.charCodeAt(0);if(h>=p){q(e,"Invalid argument: "+t.argString.substring(o));return}for(var g=0;g<=p-h;g++){var y=String.fromCharCode(h+g);delete r.marks[y]}}else{q(e,"Invalid argument: "+c+"-");return}}else a&&delete r.marks[a]}}},ye=new Yn;z.defineEx("version","ve",e=>{q(e,"Codemirror-vim version: <DEV>")});function Xn(e,t,r,n,o,a,c,f,h){e.state.vim.exMode=!0;var p=!1,g=0,y,C,k;function m(){e.operation(function(){for(;!p;)b(),I();E()})}function b(){var K="",H=a.match||a.pos&&a.pos.match;if(H)K=f.replace(/\$(\d{1,3}|[$&])/g,function(ue,W){if(W=="$")return"$";if(W=="&")return H[0];for(var $=W;parseInt($)>=H.length&&$.length>0;)$=$.slice(0,$.length-1);return $?H[$]+W.slice($.length,W.length):ue});else{var ie=e.getRange(a.from(),a.to());K=ie.replace(c,f)}var G=a.to().line;a.replace(K),C=a.to().line,o+=C-G,k=C<G}function L(){var K=y&&X(a.to()),H=a.findNext();return H&&!H[0]&&K&&be(a.from(),K)&&(H=a.findNext()),H&&g++,H}function I(){for(;L()&&Zn(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 E(K){if(K&&K(),e.focus(),y){e.setCursor(y);var H=e.state.vim;H.exMode=!1,H.lastHPos=H.lastHSPos=y.ch}h?h():p&&q(e,(g?"Found "+g+" matches":"No matches found")+" for pattern: "+c+(de("pcre")?" (set nopcre to use Vim regexps)":""))}function O(K,H,ie){s.e_stop(K);var G=it(K);switch(G){case"y":b(),I();break;case"n":I();break;case"a":var ue=h;h=void 0,e.operation(m),h=ue;break;case"l":b();case"q":case"<Esc>":case"<C-c>":case"<C-[>":E(ie);break}return p&&E(ie),!0}if(I(),p){q(e,"No matches for "+c+(de("pcre")?" (set nopcre to use vim regexps)":""));return}if(!t){m(),h&&h();return}ht(e,{prefix:Ae("span","replace with ",Ae("strong",f)," (y/n/a/q/l)"),onKeyDown:O})}function Ue(e,t){var r=e.state.vim,n=A.macroModeState,o=A.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&&ii(n)}function Rt(e){u.unshift(e),e.keys&&Gn(e.keys)}function Gn(e){e.split(/(<(?:[CSMA]-)*\w+>|.)/i).forEach(function(t){t&&(d[t]||(d[t]=0),d[t]++)})}function ei(e){e.split(/(<(?:[CSMA]-)*\w+>|.)/i).forEach(function(t){d[t]&&d[t]--})}function ti(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];Rt(a)}Ke("insertModeEscKeysTimeout",200,"number");function ri(e,t,r,n){var o=A.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 f=0;f<a.length;f++)for(var h=a[f],p,g,y=/<(?:[CSMA]-)*\w+>|./gi;p=y.exec(h);)if(g=p[0],z.handleKey(e,g,"macro"),t.insertMode){var C=o.insertModeChanges[c++].changes;A.macroModeState.lastInsertModeChanges.changes=C,Ar(e,C,1),Ue(e)}r.isPlaying=!1}function ni(e,t){if(!e.isPlaying){var r=e.latestRegister,n=A.registerController.getRegister(r);n&&n.pushText(t)}}function ii(e){if(!e.isPlaying){var t=e.latestRegister,r=A.registerController.getRegister(t);r&&r.pushInsertModeChanges&&r.pushInsertModeChanges(e.lastInsertModeChanges)}}function oi(e,t){if(!e.isPlaying){var r=e.latestRegister,n=A.registerController.getRegister(r);n&&n.pushSearchQuery&&n.pushSearchQuery(t)}}function wr(e,t){var r=A.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 f=o&&o.insertEnd&&o.insertEnd.find(),h=e.getCursor();if(f&&f.line==h.line){var p=f.ch-h.ch;p>0&&p<c.length&&(n.changes.push([c,p]),c="")}}c&&n.changes.push(c)}}t=t.next}}function Sr(e){var t=e.state.vim;if(t.insertMode){var r=A.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||xr(e,t)}function xr(e,t){var r=e.getCursor("anchor"),n=e.getCursor("head");if(t.visualMode&&!e.somethingSelected()?Ne(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=re(n,r)?0:-1,a=re(n,r)?-1:0;n=ne(n,0,o),r=ne(r,0,a),t.sel={anchor:r,head:n},Ve(e,t,"<",me(n,r)),Ve(e,t,">",We(n,r))}else t.insertMode||(t.lastHPos=e.getCursor().ch)}function br(e){var t=A.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 Xe(n,e)))}function Mr(e,t,r,n){var o=A.macroModeState;o.isPlaying=!0;var a=t.lastEditActionCommand,c=t.inputState;function f(){a?Qe.processAction(e,t,a):Qe.evalInput(e,t)}function h(g){if(o.lastInsertModeChanges.changes.length>0){g=t.lastEditActionCommand?g:1;var y=o.lastInsertModeChanges;Ar(e,y.changes,g)}}if(t.inputState=t.lastEditInputState,a&&a.interlaceInsertRepeat)for(var p=0;p<r;p++)f(),h(1);else n||f(),h(r);t.inputState=c,t.insertMode&&!n&&Ue(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=A.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(ne(n,a,0));for(var c=0;c<t.length;c++){var f=t[c];if(f instanceof Xe)Lr(e,f.keyName);else if(typeof f=="string")e.replaceSelection(f);else{var h=e.getCursor(),p=ne(h,0,f[0].length-(f[1]||0));e.replaceRange(f[0],h,f[1]?h:p),e.setCursor(p)}}}o&&e.setCursor(ne(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&&X(e.sel.head),anchor:e.sel.anchor&&X(e.sel.anchor)}),t}function ai(e,t,r){var a=Re(e),n=e,o=!1,a=z.maybeInitVimState_(n),c=a.visualBlock||a.wasInVisualBlock;if(n.state.closeVimNotification){var f=n.state.closeVimNotification;if(n.state.closeVimNotification=null,f(),t=="<CR>")return le(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>")le(n);else if(c||!h||n.inVirtualSelectionMode)o=z.handleKey(n,t,r);else{var p=Ot(a),g=a.inputState.changeQueueList||[];n.operation(function(){n.curOp&&(n.curOp.isVimOp=!0);var y=0;n.forEachSelection(function(){n.state.vim.inputState.changeQueue=g[y];var C=n.getCursor("head"),k=n.getCursor("anchor"),m=re(C,k)?0:-1,b=re(C,k)?-1:0;C=ne(C,0,m),k=ne(k,0,b),n.state.vim.sel.head=C,n.state.vim.sel.anchor=k,o=z.handleKey(n,t,r),n.virtualSelection&&(g[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=g,a.inputState.changeQueue=null},!0)}return o&&!a.visualMode&&!a.insertMode&&a.visualMode!=n.somethingSelected()&&xr(n,a),o}return Fe(),z}function ke(s,i){var l=i.ch,u=i.line+1;u<1&&(u=1,l=0),u>s.lines&&(u=s.lines,l=Number.MAX_VALUE);var d=s.line(u);return Math.min(d.from+Math.max(0,l),d.to)}function Me(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 Gr(s,i,l){if(s.addEventListener)s.addEventListener(i,l,!1);else{var u=s._handlers||(s._handlers={});u[i]=(u[i]||[]).concat(l)}}function en(s,i,l){if(s.removeEventListener)s.removeEventListener(i,l,!1);else{var u=s._handlers,d=u&&u[i];if(d){var v=d.indexOf(l);v>-1&&(u[i]=d.slice(0,v).concat(d.slice(v+1)))}}}function tn(s,i,...l){var u,d=(u=s._handlers)===null||u===void 0?void 0:u[i];if(d)for(var v=0;v<d.length;++v)d[v](...l)}function Br(s,...i){if(s)for(var l=0;l<s.length;++l)s[l](...i)}let Kt;try{Kt=new RegExp("[\\w\\p{Alphabetic}\\p{Number}_]","u")}catch{Kt=/[\w]/}function st(s,i){var l=s.cm6;if(!l.state.readOnly){var u="input.type.compose";if(s.curOp&&(s.curOp.lastChange||(u="input.type.compose.start")),i.annotations)try{i.annotations.some(function(d){d.value=="input"&&(d.value=u)})}catch(d){console.error(d)}else i.userEvent=u;return l.dispatch(i)}}function Pr(s,i){var l;s.curOp&&(s.curOp.$changeStart=void 0),(i?bi:Mi)(s.cm6);let u=(l=s.curOp)===null||l===void 0?void 0:l.$changeStart;u!=null&&s.cm6.dispatch({selection:{anchor:u}})}var ro={Left:s=>tt(s.cm6,{key:"Left"},"editor"),Right:s=>tt(s.cm6,{key:"Right"},"editor"),Up:s=>tt(s.cm6,{key:"Up"},"editor"),Down:s=>tt(s.cm6,{key:"Down"},"editor"),Backspace:s=>tt(s.cm6,{key:"Backspace"},"editor"),Delete:s=>tt(s.cm6,{key:"Delete"},"editor")};class V{openDialog(i,l,u){return io(this,i,l,u)}openNotification(i,l){return no(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){Gr(this,i,l)}off(i,l){en(this,i,l)}signal(i,l,u){tn(this,i,l,u)}indexFromPos(i){return ke(this.cm6.state.doc,i)}posFromIndex(i){return Me(this.cm6.state.doc,i)}foldCode(i){let l=this.cm6,u=l.state.selection.ranges,d=this.cm6.state.doc,v=ke(d,i),w=Se.create([Se.range(v,v)],0).ranges;l.state.selection.ranges=w,ci(l),l.state.selection.ranges=u}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 u=ke(this.cm6.state.doc,{line:i,ch:l||0});this.cm6.dispatch({selection:{anchor:u}},{scrollIntoView:!this.curOp}),this.curOp&&!this.curOp.isVimOp&&this.onBeforeEndOperation()}getCursor(i){var l=this.cm6.state.selection.main,u=i=="head"||!i?l.head:i=="anchor"?l.anchor:i=="start"?l.from:i=="end"?l.to:null;if(u==null)throw new Error("Invalid cursor type");return this.posFromIndex(u)}listSelections(){var i=this.cm6.state.doc;return this.cm6.state.selection.ranges.map(l=>({anchor:Me(i,l.anchor),head:Me(i,l.head)}))}setSelections(i,l){var u=this.cm6.state.doc,d=i.map(v=>{var w=ke(u,v.head),S=ke(u,v.anchor);return w==S?Se.cursor(w,1):Se.range(S,w)});this.cm6.dispatch({selection:Se.create(d,l)})}setSelection(i,l,u){this.setSelections([{anchor:i,head:l}],0),u&&u.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 u=i.index,d=0;d<l.length;d++)if(u=l[d].changes.mapPos(u,1,qr.TrackAfter),u==null)return null;var v=this.posFromIndex(u);return v.ch==0?v.line:null}releaseLineHandles(){this.$lineHandleChanges=void 0}getRange(i,l){var u=this.cm6.state.doc;return this.cm6.state.sliceDoc(ke(u,i),ke(u,l))}replaceRange(i,l,u,d){u||(u=l);var v=this.cm6.state.doc,w=ke(v,l),S=ke(v,u);st(this,{changes:{from:w,to:S,insert:i}})}replaceSelection(i){st(this,this.cm6.state.replaceSelection(i))}replaceSelections(i){var l=this.cm6.state.selection.ranges,u=l.map((d,v)=>({from:d.from,to:d.to,insert:i[v]||""}));st(this,{changes:u})}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,u=i.ch,d=i.line+1;d<1&&(d=1,u=0),d>l.lines&&(d=l.lines,u=Number.MAX_VALUE);var v=l.line(d);return u=Math.min(Math.max(0,u),v.to-v.from),new De(d-1,u)}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 u=this.cm6.state,d=ke(u.doc,i),v=Er(u,d+1,-1);return v&&v.end?{to:Me(u.doc,v.end.from)}:(v=Er(u,d,1),v&&v.end?{to:Me(u.doc,v.end.from)}:{to:void 0})}scanForBracket(i,l,u,d){return so(this,i,l,u,d)}indentLine(i,l){l?this.indentMore():this.indentLess()}indentMore(){ui(this.cm6)}indentLess(){fi(this.cm6)}execCommand(i){if(V.commands.hasOwnProperty(i))V.commands[i](this);else if(i=="goLineLeft")hi(this.cm6);else if(i=="goLineRight"){di(this.cm6);let l=this.cm6.state,u=l.selection.main.head;u<l.doc.length&&l.sliceDoc(u,u+1)!==`
|
|
36
|
+
`&&pi(this.cm6)}else console.log(i+" is not implemented")}setBookmark(i,l){var u=l?.insertLeft?1:-1,d=this.indexFromPos(i),v=new uo(this,d,u);return v}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 u=Pt.of(l);return this.cm6.dispatch({effects:u}),l}}removeOverlay(i){if(!this.cm6Query)return;this.cm6Query.forVim=!1;let l=Pt.of(this.cm6Query);this.cm6.dispatch({effects:l})}getSearchCursor(i,l){var u=this,d=null,v=null,w=!1;l.ch==null&&(l.ch=Number.MAX_VALUE);var S=ke(u.cm6.state.doc,l),x=i.source.replace(/(\\.|{(?:\d+(?:,\d*)?|,\d+)})|[{}]/g,function(D,F){return F||"\\"+D});function T(D,F=0,U=D.length){return new mi(D,x,{ignoreCase:i.ignoreCase},F,U)}function R(D){var F=u.cm6.state.doc;if(D>F.length)return null;let U=T(F,D).next();return U.done?null:U.value}var M=1e4;function P(D,F){var U=u.cm6.state.doc;for(let Q=1;;Q++){let j=Math.max(D,F-Q*M),oe=T(U,j,F),te=null;for(;!oe.next().done;)te=oe.value;if(te&&(j==D||te.from>j+10))return te;if(j==D)return null}}return{findNext:function(){return this.find(!1)},findPrevious:function(){return this.find(!0)},find:function(D){var F=u.cm6.state.doc;if(D){let U=d?w?d.to-1:d.from:S;d=P(0,U)}else{let U=d?w?d.to+1:d.to:S;d=R(U)}return v=d&&{from:Me(F,d.from),to:Me(F,d.to),match:d.match},w=d?d.from==d.to:!1,d&&d.match},from:function(){return v?.from},to:function(){return v?.to},replace:function(D){d&&(st(u,{changes:{from:d.from,to:d.to,insert:D}}),d.to=d.from+D.length,v&&(v.to=Me(u.cm6.state.doc,d.to)))},get match(){return v&&v.match}}}findPosV(i,l,u,d){let{cm6:v}=this;const w=v.state.doc;let S=u=="page"?v.dom.clientHeight:0;const x=ke(w,i);let T=Se.cursor(x,1,void 0,d),R=Math.round(Math.abs(l));for(let P=0;P<R;P++)u=="page"?T=v.moveVertically(T,l>0,S):u=="line"&&(T=v.moveVertically(T,l>0));let M=Me(w,T.head);return(l<0&&T.head==0&&d!=0&&i.line==0&&i.ch!=0||l>0&&T.head==w.length&&M.ch!=d&&i.line==M.line)&&(M.hitSide=!0),M}charCoords(i,l){var u=this.cm6.contentDOM.getBoundingClientRect(),d=ke(this.cm6.state.doc,i),v=this.cm6.coordsAtPos(d),w=-u.top;return{left:(v?.left||0)-u.left,top:(v?.top||0)+w,bottom:(v?.bottom||0)+w}}coordsChar(i,l){var u=this.cm6.contentDOM.getBoundingClientRect(),d=this.cm6.posAtCoords({x:i.left+u.left,y:i.top+u.top})||0;return Me(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 u=this.indexFromPos(i);this.cm6.dispatch({effects:se.scrollIntoView(u)})}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 u in this.marks)this.marks[u].update(i.changes);this.virtualSelection&&(this.virtualSelection.ranges=this.virtualSelection.ranges.map(u=>u.map(i.changes)));var l=this.curOp=this.curOp||{};i.changes.iterChanges((u,d,v,w,S)=>{(l.$changeStart==null||l.$changeStart>v)&&(l.$changeStart=v),this.$lastChangeEndOffset=w;var x={text:S.toJSON()};l.lastChange?l.lastChange.next=l.lastChange=x:l.lastChange=l.change=x},!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 u=i()}finally{this.curOp&&(this.curOp.$d--,this.curOp.$d||this.onBeforeEndOperation())}return u}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 u=this.getCursor();this.setCursor(u.line,u.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(Rr)==" ";case"indentUnit":return this.cm6.state.facet(Rr).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,u=this.indexFromPos(i),d=Jr(this.cm6.state,u),v=d?.resolve(u),w=((l=v?.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,u=this.cm6.state.selection,d=u.ranges.map(v=>{if(v.empty){var w=v.to<l.length?l.sliceString(v.from,v.to+1):"";if(w&&!/\n/.test(w))return Se.range(v.from,v.to+1)}return v});this.cm6.dispatch({selection:Se.create(d,u.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 u=0;u<this.virtualSelection.ranges.length;u++){var d=this.virtualSelection.ranges[u];d&&(this.cm6.dispatch({selection:Se.create([d])}),i(),this.virtualSelection.ranges[u]=this.cm6.state.selection.ranges[0])}this.cm6.dispatch({selection:this.virtualSelection}),this.virtualSelection=null}hardWrap(i){return fo(this,i)}}V.isMac=typeof navigator<"u"&&/Mac/.test(navigator.platform);V.Pos=De;V.StringStream=Ci;V.commands={toggleLineComment:function(s){xi(s.cm6)},cursorCharLeft:function(s){Si(s.cm6)},redo:function(s){Pr(s,!1)},undo:function(s){Pr(s,!0)},newlineAndIndent:function(s){wi({state:s.cm6.state,dispatch:i=>st(s,i)})},indentAuto:function(s){ki(s.cm6)},newlineAndIndentContinueComment:void 0,save:void 0};V.isWordChar=function(s){return Kt.test(s)};V.keys=ro;V.addClass=function(s,i){};V.rmClass=function(s,i){};V.e_preventDefault=function(s){s.preventDefault()};V.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)};V.lookupKey=function(i,l,u){var d=V.keys[i];!d&&/^Arrow/.test(i)&&(d=V.keys[i.slice(5)]),d&&u(d)};V.on=Gr;V.off=en;V.signal=tn;V.findMatchingTag=lo;V.findEnclosingTag=co;V.keyName=void 0;function rn(s,i,l){var u=document.createElement("div");return u.appendChild(i),u}function nn(s,i){s.state.currentNotificationClose&&s.state.currentNotificationClose(),s.state.currentNotificationClose=i}function no(s,i,l){nn(s,S);var u=rn(s,i,l&&l.bottom),d=!1,v,w=l&&typeof l.duration<"u"?l.duration:5e3;function S(){d||(d=!0,clearTimeout(v),u.remove(),an(s,u))}return u.onclick=function(x){x.preventDefault(),S()},on(s,u),w&&(v=setTimeout(S,w)),S}function on(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(),V.signal(s,"dialog"))}function an(s,i){s.state.dialog==i&&(s.state.dialog=null,V.signal(s,"dialog"))}function io(s,i,l,u){u||(u={}),nn(s,void 0);var d=rn(s,i,u.bottom),v=!1;on(s,d);function w(x){if(typeof x=="string")S.value=x;else{if(v)return;v=!0,an(s,d),s.state.dialog||s.focus(),u.onClose&&u.onClose(d)}}var S=d.getElementsByTagName("input")[0];return S&&(u.value&&(S.value=u.value,u.selectValueOnOpen!==!1&&S.select()),u.onInput&&V.on(S,"input",function(x){u.onInput(x,S.value,w)}),u.onKeyUp&&V.on(S,"keyup",function(x){u.onKeyUp(x,S.value,w)}),V.on(S,"keydown",function(x){u&&u.onKeyDown&&u.onKeyDown(x,S.value,w)||(x.keyCode==13&&l&&l(S.value),(x.keyCode==27||u.closeOnEnter!==!1&&x.keyCode==13)&&(S.blur(),V.e_stop(x),w()))}),u.closeOnBlur!==!1&&V.on(S,"blur",function(){setTimeout(function(){document.activeElement!==S&&w()})}),S.focus()),w}var oo={"(":")>",")":"(<","[":"]>","]":"[<","{":"}>","}":"{<","<":">>",">":"<<"};function ao(s){return s&&s.bracketRegex||/[(){}[\]]/}function so(s,i,l,u,d){for(var v=d&&d.maxScanLineLength||1e4,w=d&&d.maxScanLines||1e3,S=[],x=ao(d),T=l>0?Math.min(i.line+w,s.lastLine()+1):Math.max(s.firstLine()-1,i.line-w),R=i.line;R!=T;R+=l){var M=s.getLine(R);if(M){var P=l>0?0:M.length-1,D=l>0?M.length:-1;if(!(M.length>v))for(R==i.line&&(P=i.ch-(l<0?1:0));P!=D;P+=l){var F=M.charAt(P);if(x.test(F)){var U=oo[F];if(U&&U.charAt(1)==">"==l>0)S.push(F);else if(S.length)S.pop();else return{pos:new De(R,P),ch:F}}}}}return R-l==(l>0?s.lastLine():s.firstLine())?!1:null}function lo(s,i){return null}function co(s,i){var l,u,d=s.cm6.state,v=s.indexFromPos(i);if(v<d.doc.length){var w=d.sliceDoc(v,v+1);w=="<"&&v++}for(var S=Jr(d,v),x=S?.resolve(v)||null;x;){if(((l=x.firstChild)===null||l===void 0?void 0:l.type.name)=="OpenTag"&&((u=x.lastChild)===null||u===void 0?void 0:u.type.name)=="CloseTag")return{open:Dr(d.doc,x.firstChild),close:Dr(d.doc,x.lastChild)};x=x.parent}}function Dr(s,i){return{from:Me(s,i.from),to:Me(s,i.to)}}class uo{constructor(i,l,u){this.cm=i,this.id=i.$mid++,this.offset=l,this.assoc=u,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,qr.TrackDel))}}function fo(s,i){for(var l,u=i.column||s.getOption("textwidth")||80,d=i.allowMerge!=!1,v=Math.min(i.from,i.to),w=Math.max(i.from,i.to);v<=w;){var S=s.getLine(v);if(S.length>u){var x=F(S,u,5);if(x){var T=(l=/^\s*/.exec(S))===null||l===void 0?void 0:l[0];s.replaceRange(`
|
|
37
|
+
`+T,new De(v,x.start),new De(v,x.end))}w++}else if(d&&/\S/.test(S)&&v!=w){var R=s.getLine(v+1);if(R&&/\S/.test(R)){var M=S.replace(/\s+$/,""),P=R.replace(/^\s+/,""),D=M+" "+P,x=F(D,u,5);x&&x.start>M.length||D.length<u?(s.replaceRange(" ",new De(v,M.length),new De(v+1,R.length-P.length)),v--,w--):M.length<S.length&&s.replaceRange("",new De(v,M.length),new De(v,S.length))}}v++}return v;function F(U,Q,j){if(!(U.length<Q)){var oe=U.slice(0,Q),te=U.slice(Q),J=/^(?:(\s+)|(\S+)(\s+))/.exec(te),ce=/(?:(\s+)|(\s+)(\S+))$/.exec(oe),ge=0,ae=0;if(ce&&!ce[2]&&(ge=Q-ce[1].length,ae=Q),J&&!J[2]&&(ge||(ge=Q),ae=Q+J[1].length),ge)return{start:ge,end:ae};if(ce&&ce[2]&&ce.index>j)return{start:ce.index,end:ce.index+ce[2].length};if(J&&J[2])return ge=Q+J[2].length,{start:ge,end:ge+J[3].length}}}}let Ft=vi||(function(){let s={cursorBlinkRate:1200};return function(){return s}})();class ho{constructor(i,l,u,d,v,w,S,x,T,R){this.left=i,this.top=l,this.height=u,this.fontFamily=d,this.fontSize=v,this.fontWeight=w,this.color=S,this.className=x,this.letter=T,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 po{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=Ft(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"),go(i)&&this.setBlinkRate()}scheduleRedraw(){this.view.requestMeasure(this.measureReq)}readPos(){let{state:i}=this.view,l=[];for(let u of i.selection.ranges){let d=u==i.selection.main,v=Co(this.cm,this.view,u,d);v&&l.push(v)}return{cursors:l}}drawSel({cursors:i}){if(i.length!=this.cursors.length||i.some((l,u)=>!l.eq(this.cursors[u]))){let l=this.cursorLayer.children;if(l.length!==i.length){this.cursorLayer.textContent="";for(const u of i)this.cursorLayer.appendChild(u.draw())}else i.forEach((u,d)=>u.adjust(l[d]));this.cursors=i}}destroy(){this.cursorLayer.remove()}}function go(s){return Ft(s.startState)!=Ft(s.state)}const vo={".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"}},mo=Qr.highest(se.theme(vo));function yo(s){let i=s.scrollDOM.getBoundingClientRect();return{left:(s.textDirection==yi.LTR?i.left:i.right-s.scrollDOM.clientWidth)-s.scrollDOM.scrollLeft*s.scaleX,top:i.top-s.scrollDOM.scrollTop*s.scaleY}}function Co(s,i,l,u){var d,v,w,S;let x=l.head,T=!1,R=1,M=s.state.vim;if(M&&(!M.insertMode||s.state.overwrite)){if(T=!0,M.visualBlock&&!u)return null;l.anchor<l.head&&(x<i.state.doc.length&&i.state.sliceDoc(x,x+1))!=`
|
|
38
|
+
`&&x--,s.state.overwrite?R=.2:M.status&&(R=.5)}if(T){let D=x<i.state.doc.length&&i.state.sliceDoc(x,x+1);D&&/[\uDC00-\uDFFF]/.test(D)&&x>1&&(x--,D=i.state.sliceDoc(x,x+1));let F=i.coordsAtPos(x,1);if(!F)return null;let U=yo(i),Q=i.domAtPos(x),j=Q?Q.node:i.contentDOM;for(j instanceof Text&&Q.offset>=j.data.length&&!((d=j.parentElement)===null||d===void 0)&&d.nextSibling&&(j=(v=j.parentElement)===null||v===void 0?void 0:v.nextSibling,Q={node:j,offset:0});Q&&Q.node instanceof HTMLElement;)j=Q.node,Q={node:Q.node.childNodes[Q.offset],offset:0};if(!(j instanceof HTMLElement)){if(!j.parentNode)return null;j=j.parentNode}let oe=getComputedStyle(j),te=F.left,J=(S=(w=i).coordsForChar)===null||S===void 0?void 0:S.call(w,x);if(J&&(te=J.left),!D||D==`
|
|
39
|
+
`||D=="\r")D=" ";else if(D==" "){D=" ";var P=i.coordsAtPos(x+1,-1);P&&(te=P.left-(P.left-F.left)/parseInt(oe.tabSize))}else/[\uD800-\uDBFF]/.test(D)&&x<i.state.doc.length-1&&(D+=i.state.sliceDoc(x+1,x+2));let ce=F.bottom-F.top;return new ho((te-U.left)/i.scaleX,(F.top-U.top+ce*(1-R))/i.scaleY,ce*R/i.scaleY,oe.fontFamily,oe.fontSize,oe.fontWeight,oe.color,u?"cm-fat-cursor cm-cursor-primary":"cm-fat-cursor cm-cursor-secondary",D,R!=1)}else return null}var ko=typeof navigator<"u"&&/linux/i.test(navigator.platform)&&/ Gecko\/\d+/.exec(navigator.userAgent);const Ee=to(V),wo=250,So=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"}}),xo=ct.fromClass(class{constructor(s){this.status="",this.query=null,this.decorations=ee.none,this.waitForCopy=!1,this.lastKeydown="",this.useNextTextInput=!1,this.compositionText="",this.view=s;const i=this.cm=new V(s);Ee.enterVimMode(this.cm),this.view.cm=this.cm,this.cm.state.vimPlugin=this,this.blockCursor=new po(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:sn.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=>{Ee.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 u of l.effects)if(u.is(Pt))if(!((i=u.value)===null||i===void 0?void 0:i.forVim))this.highlight(null);else{let v=u.value.create();this.highlight(v)}}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 u=(i.mode||"normal").toUpperCase();i.insertModeReturn&&(u+="(C-O)"),this.statusButton.textContent=`--${u}--`,s.appendChild(this.statusButton),s.appendChild(this.spacer)}this.dom.textContent=i.status,s.appendChild(this.dom)}destroy(){Ee.leaveVimMode(this.cm),this.updateClass(),this.blockCursor.destroy(),delete this.view.cm}highlight(s){if(this.query=s,!s)return this.decorations=ee.none;let{view:i}=this,l=new li;for(let u=0,d=i.visibleRanges,v=d.length;u<v;u++){let{from:w,to:S}=d[u];for(;u<v-1&&S>d[u+1].from-2*wo;)S=d[++u].to;s.highlight(i.state,w,S,(x,T)=>{l.add(x,T,Mo)})}return this.decorations=l.finish()}handleKey(s,i){const l=this.cm;let u=l.state.vim;if(!u)return;const d=Ee.vimKeyFromEvent(s,u);if(V.signal(this.cm,"inputEvent",{type:"handleKey",key:d}),!d)return;if(d=="<Esc>"&&!u.insertMode&&!u.visualMode&&this.query){const S=u.searchState_;S&&(l.removeOverlay(S.getOverlay()),S.setOverlay(null))}if(d==="<C-c>"&&!V.isMac&&l.somethingSelected())return this.waitForCopy=!0,!0;u.status=(u.status||"")+d;let w=Ee.multiSelectHandleKey(l,d,"user");return u=Ee.maybeInitVimState_(l),!w&&u.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,V.commands.cursorCharLeft(l))),w&&(V.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,u=l.state.vim;u&&(u.insertMode?l.setSelection(l.getCursor(),l.getCursor()):l.operation(()=>{l.curOp&&(l.curOp.isVimOp=!0),Ee.handleKey(l,"<Esc>","user")}))}))},compositionstart:function(s,i){this.useNextTextInput=!0,V.signal(this.cm,"inputEvent",s)},compositionupdate:function(s,i){V.signal(this.cm,"inputEvent",s)},compositionend:function(s,i){V.signal(this.cm,"inputEvent",s)},keypress:function(s,i){V.signal(this.cm,"inputEvent",s),this.lastKeydown=="Dead"&&this.handleKey(s,i)},keydown:function(s,i){V.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,u)=>{var d,v,w=ln(s);if(!w)return!1;var S=(d=w.state)===null||d===void 0?void 0:d.vim,x=w.state.vimPlugin;if(S&&!S.insertMode&&!(!((v=w.curOp)===null||v===void 0)&&v.isVimOp)){if(u==="\0\0")return!0;if(V.signal(w,"inputEvent",{type:"text",text:u,from:i,to:l}),u.length==1&&x.useNextTextInput){if(S.expectLiteralNext&&s.composing)return x.compositionText=u,!1;if(x.compositionText){var T=x.compositionText;x.compositionText="";var R=s.state.selection.main.head,M=s.state.sliceDoc(R-T.length,R);if(T===M){var P=w.getCursor();w.replaceRange("",w.posFromIndex(R-T.length),P)}}return x.handleKey({key:u,preventDefault:()=>{},stopPropagation:()=>{}}),bo(s),!0}}return!1})],decorations:s=>s.decorations});function bo(s){var i=s.scrollDOM.parentElement;if(i){if(ko){s.contentDOM.textContent="\0\0",s.contentDOM.dispatchEvent(new CustomEvent("compositionend"));return}var l=s.scrollDOM.nextSibling,u=window.getSelection(),d=u&&{anchorNode:u.anchorNode,anchorOffset:u.anchorOffset,focusNode:u.focusNode,focusOffset:u.focusOffset};s.scrollDOM.remove(),i.insertBefore(s.scrollDOM,l);try{d&&u&&(u.setPosition(d.anchorNode,d.anchorOffset),d.focusNode&&u.extend(d.focusNode,d.focusOffset))}catch(v){console.error(v)}s.focus(),s.contentDOM.dispatchEvent(new CustomEvent("compositionend"))}}const Mo=ee.mark({class:"cm-searchMatch"}),sn=mt.define(),Lo=vt.define({create:()=>!1,update(s,i){for(let l of i.effects)l.is(sn)&&(s=l.value);return s},provide:s=>zr.from(s,i=>i?Ao:null)});function Ao(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 Eo(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[So,xo,mo,s.status?zr.of(Eo):Lo]}function ln(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(lt(i.yanchor),lt(i.yhead))}}class Ro{constructor(i,l){this.ytext=i,this.awareness=l,this.undoManager=new Xr(i)}toYPos(i,l=0){return Dt(this.ytext,i,l)}fromYPos(i){const l=_t(lt(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,u=this.toYPos(i.anchor,l),d=this.toYPos(i.head,l);return new Qt(u,d)}fromYRange(i){const l=this.fromYPos(i.yanchor),u=this.fromYPos(i.yhead);return l.pos===u.pos?Se.cursor(u.pos,u.assoc):Se.range(l.pos,u.pos)}}const yt=Wt.define({combine(s){return s[s.length-1]}}),$t=Ut.define();class Oo{constructor(i){this.view=i,this.conf=i.state.facet(yt),this._observer=(l,u)=>{if(u.origin!==this.conf){const d=l.delta,v=[];let w=0;for(let S=0;S<d.length;S++){const x=d[S];x.insert!=null?v.push({from:w,to:w,insert:x.insert}):x.delete!=null?(v.push({from:w,to:w+x.delete,insert:""}),w+=x.delete):w+=x.retain}i.dispatch({changes:v,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 u=0;i.changes.iterChanges((d,v,w,S,x)=>{const T=x.sliceString(0,x.length,`
|
|
40
|
+
`);d!==v&&l.delete(d+u,v-d),T.length>0&&l.insert(d+u,T),u+=T.length-(v-d)})},this.conf)}destroy(){this._ytext.unobserve(this._observer)}}const To=ct.fromClass(Oo),Io=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"}}),No=Ut.define();class Bo extends Zr{constructor(i,l){super(),this.color=i,this.name=l}toDOM(){return Bt("span",[gt("class","cm-ySelectionCaret"),gt("style",`background-color: ${this.color}; border-color: ${this.color}`)],[pt(""),Bt("div",[gt("class","cm-ySelectionCaretDot")]),pt(""),Bt("div",[gt("class","cm-ySelectionInfo")],[pt(this.name)]),pt("")])}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 Po{constructor(i){this.conf=i.state.facet(yt),this._listener=({added:l,updated:u,removed:d},v,w)=>{l.concat(u).concat(d).findIndex(x=>x!==this.conf.awareness.doc.clientID)>=0&&i.dispatch({annotations:[No.of([])]})},this._awareness=this.conf.awareness,this._awareness.on("change",this._listener),this.decorations=Li.of([])}destroy(){this._awareness.off("change",this._listener)}update(i){const l=this.conf.ytext,u=l.doc,d=this.conf.awareness,v=[],w=this.conf.awareness.getLocalState();if(w!=null){const S=i.view.hasFocus&&i.view.dom.ownerDocument.hasFocus(),x=S?i.state.selection.main:null,T=w.cursor==null?null:lt(w.cursor.anchor),R=w.cursor==null?null:lt(w.cursor.head);if(x!=null){const M=Dt(l,x.anchor),P=Dt(l,x.head);(w.cursor==null||!Nr(T,M)||!Nr(R,P))&&d.setLocalStateField("cursor",{anchor:M,head:P})}else w.cursor!=null&&S&&d.setLocalStateField("cursor",null)}d.getStates().forEach((S,x)=>{if(x===d.doc.clientID)return;const T=S.cursor;if(T==null||T.anchor==null||T.head==null)return;const R=_t(T.anchor,u),M=_t(T.head,u);if(R==null||M==null||R.type!==l||M.type!==l)return;const{color:P="#30bced",name:D="Anonymous"}=S.user||{},F=S.user&&S.user.colorLight||P+"33",U=Xi(R.index,M.index),Q=Gi(R.index,M.index),j=i.view.state.doc.lineAt(U),oe=i.view.state.doc.lineAt(Q);if(j.number===oe.number)v.push({from:U,to:Q,value:ee.mark({attributes:{style:`background-color: ${F}`},class:"cm-ySelection"})});else{v.push({from:U,to:j.from+j.length,value:ee.mark({attributes:{style:`background-color: ${F}`},class:"cm-ySelection"})}),v.push({from:oe.from,to:Q,value:ee.mark({attributes:{style:`background-color: ${F}`},class:"cm-ySelection"})});for(let te=j.number+1;te<oe.number;te++){const J=i.view.state.doc.line(te).from;v.push({from:J,to:J,value:ee.line({attributes:{style:`background-color: ${F}`,class:"cm-yLineSelection"}})})}}v.push({from:M.index,to:M.index,value:ee.widget({side:M.index-R.index>0?-1:1,block:!1,widget:new Bo(P,D)})})}),this.decorations=ee.set(v,!0)}}const Do=ct.fromClass(Po,{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 Ko{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=Wt.define({combine(s){return s[s.length-1]}});class Fo{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:u})=>{u.has(this.syncConf.ytext)&&this._beforeChangeSelection&&!l.meta.has(this)&&l.meta.set(this,this._beforeChangeSelection)},this._onStackItemPopped=({stackItem:l})=>{const u=l.meta.get(this);if(u){const d=this.syncConf.fromYRange(u);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 $o=ct.fromClass(Fo),cn=({state:s,dispatch:i})=>s.facet(Ct).undo()||!0,Ht=({state:s,dispatch:i})=>s.facet(Ct).redo()||!0,Ho=[{key:"Mod-z",run:cn,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:Ht,preventDefault:!0},{key:"Mod-Shift-z",run:Ht,preventDefault:!0}],Vo=(s,i,{undoManager:l=new Xr(s)}={})=>{const u=new Ro(s,i),d=[yt.of(u),To];return i&&d.push(Io,Do),l!==!1&&d.push(Ct.of(new Ko(l)),$o,se.domEventHandlers({beforeinput(v,w){return v.inputType==="historyUndo"?cn(w):v.inputType==="historyRedo"?Ht(w):!1}})),d};function jo(s,i){if(!i.valid||!i.search)return 0;let l=0;const u=i.getCursor(s);for(;!u.next().done;)l+=1;return l}function Wo(s){return JSON.stringify([s.search,s.caseSensitive,s.literal,s.regexp,s.wholeWord])}const Uo=new Set(["(",")","[","]","{","}"]),zo={...Or,token(s,i){const l=s.pos,u=Or.token(s,i),d=s.string.slice(l,s.pos);return Uo.has(d)?"bracket":u}},Qo=Yr.define(zo),qo={startState:()=>({quoted:!1}),token(s,i){if(i.quoted){let u=!1;for(;!s.eol();){const d=s.next();if(d==='"'&&!u){i.quoted=!1;break}d==="\\"&&!u?u=!0:u=!1}return"string"}if(s.eatSpace())return null;if(s.peek()==="%")return s.skipToEnd(),"comment";if(s.match(/^@[A-Za-z][A-Za-z0-9_-]*/))return"keyword";if(s.match(/^[A-Za-z][A-Za-z0-9_-]*(?=\s*=)/))return"propertyName";if(s.match(/^\\[A-Za-z@][A-Za-z@0-9:_-]*/))return"meta";if(s.match(/^\d+(?:\.\d+)?/))return"number";const l=s.next();return l==='"'?(i.quoted=!0,"string"):l==="{"||l==="}"||l==="("||l===")"?"bracket":l==="="||l==="#"?"operator":l===","?"separator":(s.eatWhile(/[A-Za-z0-9_.:/+*?!-]/),"string")}},Jo=Yr.define(qo);function un(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 Zo(s){const i=".+?^$()[]{}|\\";return[...s].map(l=>i.includes(l)?"\\"+l:l).join("")}function fn(s,i,l){const u=s.slice(0,i)+l+s.slice(i),d=i+l.length,v=u.lastIndexOf(`
|
|
41
|
+
`,Math.max(0,d-1))+1,w=u.indexOf(`
|
|
42
|
+
`,d);return{nextSource:u,cursor:d,prefix:u.slice(v,d),suffix:u.slice(d,w<0?u.length:w)}}function hn(s){const i=s.prefix.match(/^([ \t]*)\\begin\s*\{\s*([A-Za-z][A-Za-z0-9*:_-]*)\s*\}\s*$/);if(!i||s.suffix.trim()||un(s.prefix))return null;const l=i[2],u=Zo(l);if(new RegExp("^[ \\t]*\\n[ \\t]*\\\\end\\s*\\{\\s*"+u+"\\s*\\}").test(s.nextSource.slice(s.cursor)))return null;const v=i[1]+" ";return{insert:`
|
|
43
|
+
`+v+`
|
|
44
|
+
`+i[1]+"\\end{"+l+"}",cursorOffset:1+v.length,kind:"environment"}}function dn(s){if(s.suffix.trim()||un(s.prefix))return null;const i=s.prefix.match(/^(.*\\left\s*)(\\[{}]|[()[\]|.])\s*$/);if(!i)return null;const u={"(":"\\right)",")":"\\right(","[":"\\right]","]":"\\right[","|":"\\right|",".":"\\right.","\\{":"\\right\\}","\\}":"\\right\\{"}[i[2]];return u?{insert:u,cursorOffset:0,kind:"delimiter"}:null}function Yo(s,i,l,u){if(i!==l||!u)return null;const d=fn(s,i,u);return hn(d)??dn(d)}function Xo(s,i){if(i<0||i>s.length)return null;const l=fn(s,i,"");return hn(l)??dn(l)}const Vt=mt.define(),Kr=Ut.define(),Go={undo:()=>!1,redo:()=>!1},qt=Wt.define({combine:s=>s.at(-1)??Go});Ee.defineAction("texliteUndo",s=>{s.cm6.state.facet(qt).undo()||s.execCommand("undo")});Ee.defineAction("texliteRedo",s=>{s.cm6.state.facet(qt).redo()||s.execCommand("redo")});Ee.mapCommand("u","action","texliteUndo",{},{context:"normal"});Ee.mapCommand("<C-r>","action","texliteRedo",{},{context:"normal"});const ea=vt.define({create:()=>ee.none,update(s,i){let l=s.map(i.changes);for(const u of i.effects)u.is(Vt)&&(l=ya(u.value,i.state.doc.length));return l},provide:s=>se.decorations.from(s)}),pn=mt.define(),ta=vt.define({create:()=>ee.none,update(s,i){let l=s.map(i.changes);i.docChanged&&(l=ee.none);for(const u of i.effects)u.is(pn)&&(l=ma(u.value,i.state.doc.length));return l},provide:s=>se.decorations.from(s)}),jt=mt.define(),ra=ee.mark({class:"cm-spell-error-active"}),na=vt.define({create:()=>ee.none,update(s,i){let l=s.map(i.changes);i.docChanged&&(l=ee.none);for(const u of i.effects){if(!u.is(jt))continue;const d=u.value;l=d&&d.to>d.from?ee.set([ra.range(d.from,d.to)]):ee.none}return l},provide:s=>se.decorations.from(s)}),ia=["\\noindent","\\indent","\\par","\\leavevmode","\\newline","\\linebreak","\\nolinebreak","\\pagebreak","\\nopagebreak","\\newpage","\\clearpage","\\cleardoublepage","\\smallskip","\\medskip","\\bigskip","\\smallbreak","\\medbreak","\\bigbreak","\\hfill","\\hfil","\\vfill","\\vfil","\\thinspace","\\negthinspace","\\quad","\\qquad","\\enspace","\\enskip","\\,","\\:","\\;","\\!","\\centering","\\raggedright","\\raggedleft","\\raggedbottom","\\flushbottom","\\maketitle","\\tableofcontents","\\listoffigures","\\listoftables","\\appendix","\\bfseries","\\mdseries","\\rmfamily","\\sffamily","\\ttfamily","\\upshape","\\itshape","\\slshape","\\scshape","\\normalfont","\\tiny","\\scriptsize","\\footnotesize","\\small","\\normalsize","\\large","\\Large","\\LARGE","\\huge","\\Huge","\\displaystyle","\\textstyle","\\scriptstyle","\\scriptscriptstyle","\\limits","\\nolimits","\\sum","\\prod","\\coprod","\\int","\\iint","\\iiint","\\oint","\\bigcap","\\bigcup","\\bigvee","\\bigwedge","\\lim","\\limsup","\\liminf","\\sin","\\cos","\\tan","\\cot","\\log","\\ln","\\exp","\\max","\\min","\\sup","\\inf","\\det","\\dim","\\gcd","\\ker","\\Pr","\\ldots","\\cdots","\\vdots","\\ddots","\\dotsb","\\dotsc","\\dotsm","\\dotso","\\alpha","\\beta","\\gamma","\\delta","\\epsilon","\\varepsilon","\\theta","\\vartheta","\\lambda","\\mu","\\pi","\\varpi","\\rho","\\sigma","\\tau","\\phi","\\varphi","\\omega","\\Gamma","\\Delta","\\Theta","\\Lambda","\\Xi","\\Pi","\\Sigma","\\Upsilon","\\Phi","\\Psi","\\Omega","\\pm","\\mp","\\times","\\div","\\cdot","\\leq","\\geq","\\neq","\\approx","\\equiv","\\sim","\\simeq","\\propto","\\in","\\notin","\\subset","\\subseteq","\\supset","\\supseteq","\\cup","\\cap","\\emptyset","\\varnothing","\\forall","\\exists","\\nexists","\\infty","\\partial","\\nabla","\\angle","\\parallel","\\perp","\\mid","\\LaTeX","\\TeX","\\today","\\protect","\\nocite","\\footnotemark","\\hrule","\\verb","\\verb*"];function oa(){return[...ia.map(s=>({label:s,type:"keyword"})),we("\\section{${title}}",{label:"\\section"}),we("\\subsection{${title}}",{label:"\\subsection"}),we("\\textbf{${text}}",{label:"\\textbf"}),we("\\emph{${text}}",{label:"\\emph"}),we("\\cite{${key}}",{label:"\\cite"}),we("\\ref{${label}}",{label:"\\ref"}),we("\\label{${label}}",{label:"\\label"}),we("\\includegraphics[width=${0.8}\\textwidth]{${file}}",{label:"\\includegraphics"}),we(`\\begin{itemize}
|
|
45
|
+
\\item \${item}
|
|
46
|
+
\\end{itemize}`,{label:"\\begin{itemize}"}),we(`\\begin{enumerate}
|
|
47
|
+
\\item \${item}
|
|
48
|
+
\\end{enumerate}`,{label:"\\begin{enumerate}"}),we(`\\begin{equation}
|
|
49
|
+
\${equation}
|
|
50
|
+
\\end{equation}`,{label:"\\begin{equation}"}),we(`\\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=[],u=[],d=[],v=[],w=[],S=s.split(`
|
|
56
|
+
`).map(M=>M.replace(/(^|[^\\])%.*$/,"$1")).join(`
|
|
57
|
+
`),x=(M,P)=>{if(P<=0)return;const D=F=>`\${${F}}`;return M+Array.from({length:P},(F,U)=>`{${D(U+1)}}`).join("")},T=M=>[...M.matchAll(/[moOrRdDsStvb]/g)].length,R=(M,P,D,F,U)=>{P&&!M.some(Q=>Q.label===P)&&M.push({label:P,detail:D,kind:F,source:"Current file",...U?{apply:U}:{}})};for(const M of S.matchAll(/\\(?:newcommand|renewcommand|providecommand|DeclareRobustCommand)\s*\*?\s*(?:\{\s*)?\\([A-Za-z@][A-Za-z@0-9:_]*)\s*(?:\})?\s*(?:\[(\d+)\])?/g)){const P=Number.parseInt(M[2]??"0",10);R(i,`\\${M[1]}`,"Project command","function",x(`\\${M[1]}`,P))}for(const M of S.matchAll(/\\(?:NewDocumentCommand|RenewDocumentCommand|ProvideDocumentCommand|DeclareDocumentCommand|DeclareExpandableDocumentCommand|RenewExpandableDocumentCommand|ProvideExpandableDocumentCommand)\s*\{\s*\\([A-Za-z@][A-Za-z@0-9:_]*)\s*\}\s*\{([^}]*)\}/g)){const P=T(M[2]);R(i,`\\${M[1]}`,"Project command","function",x(`\\${M[1]}`,P))}for(const M of S.matchAll(/\\(?:def|gdef|edef|xdef)\s*\\([A-Za-z@][A-Za-z@0-9:_]*)((?:\s*#\d+)*)/g)){const P=[...(M[2]??"").matchAll(/#\d+/g)].length;R(i,`\\${M[1]}`,"Project macro","function",x(`\\${M[1]}`,P))}for(const M of S.matchAll(/\\DeclarePairedDelimiter\s*\{?\\([A-Za-z@][A-Za-z@0-9:_]*)\}?/g))R(i,`\\${M[1]}`,"Project math delimiter","function");for(const M of S.matchAll(/\\cs_(?:new|set|gset|provide|generate)(?:_protected)?\:[A-Za-z]+\s+\\([A-Za-z@][A-Za-z@0-9:_]*)/g))R(i,`\\${M[1]}`,"Expl3 project command","function");for(const M of S.matchAll(/\\(?:newenvironment|renewenvironment|NewDocumentEnvironment|RenewDocumentEnvironment|DeclareDocumentEnvironment)\s*\*?\s*\{([^}]+)\}/g))R(l,M[1].trim(),"Project environment","keyword");for(const M of S.matchAll(/\\(?:label|hypertarget)\s*\{([^}]+)\}/g))R(u,M[1].trim(),"Label","constant");for(const M of S.matchAll(/\\(?:usepackage|RequirePackage)\s*(?:\[[^]]*\])?\s*\{([^}]+)\}/g))for(const P of M[1].split(","))R(v,P.trim(),"Package","text");for(const M of S.matchAll(/\\(?:input|include|subfile)\s*(?:\{([^}]+)\}|\s+([^\s%]+))/g))R(w,(M[1]??M[2]??"").trim(),"Project file","text");for(const M of S.matchAll(/\\(?:cite|citep|citet|parencite|textcite|autocite|footcite)(?:\w*)?\s*(?:\[[^]]*\])?\s*\{([^}]+)\}/g))for(const P of M[1].split(","))R(d,P.trim(),"Citation key","constant");return{commands:i,environments:l,labels:u,citations:d,packages:v,files:w}}const Fr=new WeakMap;function sa(s){const i=s.state.doc,l=Fr.get(i);if(l)return l;const u=aa(s.state.doc.toString());return Fr.set(i,u),u}const $r={"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 u=$r[s.detail],d=s.source?$r[s.source]:void 0,v=s.detail.match(/^Project command \((\d+) arguments?\)$/),w=s.source==="LaTeX"?"":v?i("completions.projectCommandArgs",{count:Number(v[1])}):u?i(`completions.${u}`):s.source==="LaTeX"?i("completions.standard"):s.detail,S=s.source==="LaTeX"?"":d?i(`completions.${d}`):s.source,x=S&&w?`${w} · ${S}`:w||S||void 0,T={label:s.label,type:s.kind,...x?{detail:x}:{},...s.info?{info:s.info}:{}};return l&&s.apply?we(s.apply,T):T}function Ze(s,...i){const l=[],u=new Set;for(const d of i)for(const v of d){const w="kind"in v?la(v,s):v;u.has(w.label)||(u.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 rt(s,i){const u=s.state.sliceDoc(0,s.pos).match(i);return!u||u.index===void 0?null:{from:s.pos-u[1].length,query:u[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 ua(s){const i=s.state.doc.lineAt(s.pos);let l=0;for(let u=0;u<s.pos-i.from;u+=1){const d=i.text[u];if(d==="\\"){l+=1;continue}if(d==="%"&&l%2===0)return!0;l=0}return!1}function fa(s){return{...s,apply(i,l,u,d){const w=i.state.doc.lineAt(u).text.match(/^\s*/)?.[0]??"",S=l.label,x=S+`}
|
|
58
|
+
`+w+`
|
|
59
|
+
`+w+"\\end{"+S+"}",T=u+S.length+1+1+w.length+1,R=i.state.sliceDoc(d,d+1)==="}"?1:0;i.dispatch({changes:{from:u,to:d+R,insert:x},selection:{anchor:T},annotations:[Zi.of(l),zt.userEvent.of("input.complete")]})}}}function ha(s,i,l,u,d){const v=Yo(s.state.doc.toString(),i,l,u);if(!v)return!1;s.dispatch(d());const w=i+u.length;return s.dispatch({changes:{from:w,insert:v.insert},selection:{anchor:w+v.cursorOffset},annotations:zt.userEvent.of("input.complete")}),!0}function da(s,i,l){if(ua(s))return null;const u=sa(s),d=s.matchBefore(/\\(?:[A-Za-z@0-9:_]*(?:\*)?|[,;!:])$/);if(d||s.explicit)return{from:d?.from??s.pos,options:Hr(Ze(i,u.commands,l?.commands??[],oa())),validFor:/^\\(?:[A-Za-z@0-9:_]*(?:\*)?|[,;!:])$/};const v=ca(s);if(v){const M=Ze(i,Vr(u.environments),Vr(l?.environments??[]));return{from:v.from,options:Hr(v.command==="begin"?M.map(fa):M),validFor:/^[A-Za-z0-9*:_-]*$/}}const w=rt(s,/\\(?:ref|pageref|autoref|nameref|cref|Cref|eqref|vref)\s*(?:\[[^]]*\])?\{([^{}]*)$/)??rt(s,/\\hyperref\[([^\[\]]*)$/);if(w)return{from:w.from,options:Ze(i,u.labels,l?.labels??[]),validFor:/^[^{}]*$/};const S=rt(s,/\\(?:cite|citep|citet|parencite|textcite|autocite|footcite)(?:\w*)?(?:\[[^]]*\])?\{([^{}]*)$/);if(S)return{from:S.from,options:Ze(i,u.citations,l?.citations??[]),validFor:/^[^{}]*$/};const x=rt(s,/\\(?:input|include|subfile|includegraphics|bibliography|addbibresource)\s*(?:\[[^]]*\])?\{([^{}]*)$/);if(x)return{from:x.from,options:Ze(i,u.files,l?.files??[]),validFor:/^[^{}]*$/};const T=rt(s,/\\(?:usepackage|RequirePackage)\s*(?:\[[^]]*\])?\{([^{}]*)$/);if(T)return{from:T.from,options:Ze(i,u.packages,l?.packages??[]),validFor:/^[^{}]*$/};const R=rt(s,/\\documentclass\s*(?:\[[^]]*\])?\{([^{}]*)$/);return R?{from:R.from,options:Ze(i,l?.files??[]),validFor:/^[^{}]*$/}:null}const pa=Qi.of((s,i)=>{const l=s.doc.lineAt(i),u=l.text.match(/\\begin\{([^}]+)\}/);if(u){let v=1;for(let w=l.number+1;w<=s.doc.lines;w+=1){const S=s.doc.line(w),x=u[1].replace(/[.*+?^${}()|[\]\\]/g,"\\$&");if(v+=(S.text.match(new RegExp(`\\\\begin\\{${x}\\}`,"g"))??[]).length,v-=(S.text.match(new RegExp(`\\\\end\\{${x}\\}`,"g"))??[]).length,v===0&&S.from>l.to)return{from:l.to,to:S.from}}}const d=l.text.match(/^\s*\\(part|chapter|section|subsection|subsubsection)\*?/);if(d){const v={part:0,chapter:0,section:1,subsection:2,subsubsection:3},w=v[d[1]];for(let S=l.number+1;S<=s.doc.lines;S+=1){const x=s.doc.line(S),T=x.text.match(/^\s*\\(part|chapter|section|subsection|subsubsection)\*?/);if(T&&v[T[1]]<=w)return{from:l.to,to:Math.max(l.to,x.from-1)}}if(l.to<s.doc.length)return{from:l.to,to:s.doc.length}}return null});function Sa({value:s,filePath:i,readOnly:l,comments:u,focusComment:d,preferences:v,completionIndex:w,jumpTo:S,searchRequest:x,spellCheckIssues:T,spellCheckJump:R,collaboration:M,onChange:P,onSelection:D,onCommentClick:F,onSpellCheckReplace:U,onCursor:Q}){const{t:j,i18n:oe}=si(),te=Y.useRef(null),J=Y.useRef(null),ce=Y.useRef(P),ge=Y.useRef(D),ae=Y.useRef(F),_e=Y.useRef(U),Ye=Y.useRef(Q),xe=Y.useRef(T),Ke=Y.useRef(x),ze=Y.useRef(w),de=Y.useRef(new Tr),ut=Y.useRef(new Tr),je=Y.useRef(null),[kt,Re]=Y.useState(v.vimMode?"NORMAL":""),[A,Fe]=Y.useState(null);ce.current=P,ge.current=D,ae.current=F,_e.current=U,Ye.current=Q,xe.current=T,ze.current=w;const Xe=(N,z)=>{if(je.current?.(),je.current=null,!z){Re("");return}const B=ln(N);if(!B){Re("NORMAL");return}const Z=()=>{const _=B.state.vim?.mode??(B.state.vim?.insertMode?"insert":"normal");Re(_.toUpperCase())};Z(),B.on("vim-mode-change",Z),je.current=()=>B.off("vim-mode-change",Z)};return Y.useEffect(()=>{if(!te.current)return;const N=M&&!l?M.undoManager??null:null,z=Nt.create({doc:M?.text.toString()??s,extensions:[Ai(),Ei(),...M?[]:[Ri()],Oi(),Ti(),Ii(),/\.bib$/i.test(i)?Jo:Qo,Ni(Ji),Bi(),Qr.high(se.inputHandler.of(ha)),Pi(),Di(),pa,ea,ta,na,_i({top:!1}),va(j),Nt.phrases.of(ga(j)),Ki({override:[B=>da(B,j,ze.current)],activateOnTyping:!0}),...N?[qt.of({undo:()=>N.undo()!==null,redo:()=>N.redo()!==null})]:[],ut.current.of(v.vimMode?_r():[]),Fi.of([...$i,...Hi,...Vi,...ji,...M&&!l?Ho:[],...Wi,...M?[]:Ui]),...M?[Vo(M.text,M.awareness,{undoManager:N??!1})]:[],Nt.readOnly.of(l),de.current.of(jr(v)),se.domEventHandlers({click(B){const Z=B.target.closest("[data-comment-id]");return Z?.dataset.commentId&&ae.current(Z.dataset.commentId),!1},contextmenu(B){const Z=B.target.closest("[data-spell-error]");if(!Z)return!1;const _=Number(Z.dataset.spellFrom),Oe=Number(Z.dataset.spellTo),$e=xe.current.find(He=>He.from===_&&He.to===Oe);if(!$e)return!1;B.preventDefault();const nt=250,wt=Math.min(300,100+$e.suggestions.length*34);return Fe({issue:$e,left:Math.max(8,Math.min(B.clientX,window.innerWidth-nt-8)),top:Math.max(8,Math.min(B.clientY,window.innerHeight-wt-8))}),!0},blur(B,Z){const _=Z.state.selection.main;return ge.current(Z.state.sliceDoc(_.from,_.to),_.from,_.to),M?.awareness.setLocalStateField("cursor",null),!1}}),se.updateListener.of(B=>{const Z=B.transactions.some(_=>_.annotation(Kr));if(B.docChanged&&!Z&&ce.current(B.state.doc.toString()),B.docChanged&&Fe(null),B.selectionSet&&!B.docChanged&&B.transactions.some(_=>_.isUserEvent("input"))){const _=B.state.selection.main.head,Oe=Xo(B.state.doc.toString(),_);Oe&&B.view.dispatch({changes:{from:_,insert:Oe.insert},selection:{anchor:_+Oe.cursorOffset},annotations:zt.userEvent.of("input.complete")})}if(B.selectionSet||B.docChanged){const _=B.state.selection.main;ge.current(B.state.sliceDoc(_.from,_.to),_.from,_.to);const Oe=B.state.doc.lineAt(_.head);Ye.current(Oe.number,_.head-Oe.from+1,_.head)}})]});return J.current=new se({state:z,parent:te.current}),Xe(J.current,v.vimMode),J.current.dispatch({effects:Vt.of(Wr(u))}),()=>{je.current?.(),je.current=null,J.current?.destroy(),J.current=null}},[i,l,oe.resolvedLanguage,M?.text]),Y.useEffect(()=>{const N=J.current;N&&(N.dispatch({effects:[de.current.reconfigure(jr(v)),ut.current.reconfigure(v.vimMode?_r():[])]}),Xe(N,v.vimMode))},[v]),Y.useEffect(()=>{const N=J.current;if(!N)return;const z=N.state.doc.toString(),B=T.filter(Z=>Z.from>=0&&Z.to<=z.length&&Z.to>Z.from);N.dispatch({effects:[pn.of(B),jt.of(null)]})},[T]),Y.useEffect(()=>{Fe(null)},[T]),Y.useEffect(()=>{if(!A)return;const N=B=>{B.target instanceof Element&&B.target.closest(".spell-suggestions-menu")||Fe(null)},z=B=>{B.key==="Escape"&&Fe(null)};return document.addEventListener("mousedown",N,!0),document.addEventListener("keydown",z,!0),()=>{document.removeEventListener("mousedown",N,!0),document.removeEventListener("keydown",z,!0)}},[A]),Y.useEffect(()=>{const N=J.current;M||!N||N.state.doc.toString()===s||N.dispatch({changes:{from:0,to:N.state.doc.length,insert:s},annotations:Kr.of(!0)})},[s,M]),Y.useEffect(()=>{J.current?.dispatch({effects:Vt.of(Wr(u))})},[u]),Y.useEffect(()=>{const N=J.current;if(!N||!d||d.orphaned)return;const z=Math.min(d.startOffset,N.state.doc.length),B=Math.min(Math.max(z,d.endOffset),N.state.doc.length);N.dispatch({selection:{anchor:z,head:B},effects:se.scrollIntoView(z,{y:"center"})}),N.focus()},[d]),Y.useEffect(()=>{const N=J.current;if(!N||!S)return;const z=Math.max(1,Math.min(N.state.doc.lines,S.line)),B=N.state.doc.line(z),Z=Math.min(B.to,B.from+Math.max(0,S.column-1));N.dispatch({selection:{anchor:B.from,head:B.to},effects:se.scrollIntoView(Z,{y:"center",yMargin:60})}),N.focus()},[S?.nonce]),Y.useEffect(()=>{const N=J.current;if(!N||!R)return;const z=Math.max(0,Math.min(R.from,N.state.doc.length)),B=Math.max(z,Math.min(R.to,N.state.doc.length));N.dispatch({selection:{anchor:z},effects:[jt.of({from:z,to:B}),se.scrollIntoView(z,{y:"center",yMargin:60})]}),N.focus()},[R?.nonce]),Y.useEffect(()=>{const N=J.current;!N||x===0||x===Ke.current||(Ke.current=x,zi(N))},[x]),Pe.jsxs("div",{className:"editor-shell",style:{fontFamily:eo(v.font),fontSize:`${v.fontSize}px`,lineHeight:v.lineHeight},children:[Pe.jsx("div",{className:"editor-host",ref:te}),A&&Pe.jsxs("div",{className:"spell-suggestions-menu",role:"menu","aria-label":j("editor.writingSuggestions"),onMouseDown:N=>N.stopPropagation(),children:[Pe.jsx("div",{className:"spell-suggestions-title",children:j("editor.writingSuggestions")}),A.issue.message&&Pe.jsx("div",{className:"spell-suggestions-message",children:A.issue.message}),A.issue.suggestions.map((N,z)=>Pe.jsx("button",{type:"button",role:"menuitem",disabled:l,title:l?j("editor.spellCheckReadOnly"):j("editor.replaceWith",{word:N||j("editor.removeText")}),onClick:()=>{_e.current(A.issue,N),Fe(null)},children:N||j("editor.removeText")},`${N}-${z}`)),A.issue.suggestions.length===0&&Pe.jsx("span",{className:"spell-suggestions-empty",children:j("editor.noWritingSuggestions")}),l&&A.issue.suggestions.length>0&&Pe.jsx("span",{className:"spell-suggestions-readonly",children:j("editor.spellCheckReadOnly")})]}),v.vimMode&&Pe.jsx("div",{className:"vim-editor-status",role:"status","aria-live":"polite",children:Pe.jsxs("span",{children:["--",kt||"NORMAL","--"]})})]})}function ga(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 va(s){return ct.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 v=i.querySelector("[name=close]");i.insertBefore(l,v)}const u=Yi(this.view.state),d=Wo(u);(this.document!==this.view.state.doc||this.signature!==d)&&(this.document=this.view.state.doc,this.signature=d,this.count=jo(this.view.state,u)),l.textContent=u.search?u.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 ma(s,i){const l=s.map(u=>({from:Math.max(0,Math.min(i,u.from)),to:Math.max(0,Math.min(i,u.to)),word:u.word,kind:u.kind,message:u.message})).filter(u=>u.to>u.from).sort((u,d)=>u.from-d.from||u.to-d.to);return ee.set(l.map(u=>ee.mark({class:u.kind==="spelling"?"cm-spell-error":"cm-grammar-warning",attributes:{title:u.message||u.word,"data-spell-error":"true","data-spell-kind":u.kind,"data-spell-from":String(u.from),"data-spell-to":String(u.to)}}).range(u.from,u.to)),!0)}function Wr(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(u=>!u.orphaned).flatMap(u=>{const d=Math.max(0,Math.min(i,u.from)),v=Math.max(d,Math.min(i,u.to)),w=`cm-source-comment${u.resolved?" cm-source-comment-resolved":""}`;return d===v?[ee.widget({widget:new Ur(u.id,w),side:1}).range(d)]:[ee.mark({class:w}).range(d,v),ee.widget({widget:new Ur(u.id,w),side:1}).range(v)]});return ee.set(l,!0)}class Ur extends Zr{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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{u as Z,r as i,j as n}from"./react-CsO_xvbl.js";import{g as O,P as U,w as Y,G as F}from"./pdf-DPnwNQHb.js";import{M as X,a as H}from"./minus-D0DZYQR6.js";import{P as q,L as T}from"./index-BLOqf18q.js";F.workerSrc=Y;const G=new U;function re({url:y,target:u,compiling:N=!1,onViewportLocation:S,onDoubleClickLocation:h}){const{t}=Z(),p=i.useRef(null),[f,L]=i.useState(null),[v,x]=i.useState(0),[o,m]=i.useState(100),[R,M]=i.useState(""),z=i.useRef(new Map),j=i.useCallback((e,r)=>{r?z.current.set(e,r):z.current.delete(e)},[]),E=async e=>{if(!f||e==null)return;let r=e;if(typeof e=="string"&&(r=await f.getDestination(e).catch(()=>null)),!Array.isArray(r)||r.length===0)return;const d=r[0];let l=null;if(typeof d=="number"&&Number.isInteger(d))l=d;else if(d!=null)try{l=await f.getPageIndex(d)}catch{return}l==null||l<0||l>=f.numPages||z.current.get(l+1)?.scrollIntoView({behavior:"smooth",block:"start",inline:"nearest"})},w=()=>{const e=p.current;if(!e)return;const r=e.getBoundingClientRect(),d=r.left+r.width/2,l=r.top+r.height/2,D=[...e.querySelectorAll(".pdf-page")],s=D.find(P=>{const C=P.getBoundingClientRect();return l>=C.top&&l<=C.bottom})??D.reduce((P,C)=>{if(!P)return C;const $=Math.abs(C.getBoundingClientRect().top-l),B=Math.abs(P.getBoundingClientRect().top-l);return $<B?C:P},null);if(!s)return;const a=s.getBoundingClientRect(),c=Number(s.dataset.scale)||1,k=Number(s.dataset.page),W=Math.max(0,Math.min(a.width,d-a.left))/c,I=Math.max(0,Math.min(a.height,l-a.top))/c;k&&S(k,W,I)};i.useEffect(()=>{const e=p.current;if(!e)return;const r=()=>x(e.clientWidth);r();const d=new ResizeObserver(r);return d.observe(e),()=>d.disconnect()},[]),i.useEffect(()=>{let e=!1;L(null),M("");const r=O({url:y,worker:G});return r.promise.then(d=>{e||L(d)}).catch(()=>{e||M(t("editor.pdfLoadFailed"))}),()=>{e=!0,r.destroy()}},[y]),i.useEffect(()=>{o>100||!p.current||(p.current.scrollLeft=0)},[o,v,f]);const g=e=>m(r=>Math.min(200,Math.max(50,r+e))),A=()=>{p.current&&(p.current.scrollLeft=0),m(100)},b=e=>{!e.shiftKey||Math.abs(e.deltaX)>Math.abs(e.deltaY)||(e.preventDefault(),e.currentTarget.scrollLeft+=e.deltaY,w())};return n.jsxs("div",{className:"pdf-viewer",children:[n.jsxs("div",{className:"pdf-toolbar",role:"toolbar","aria-label":t("editor.pdfZoomControls"),children:[n.jsx("button",{disabled:o<=50,title:t("editor.pdfZoomOut"),"aria-label":t("editor.pdfZoomOut"),onClick:()=>g(-10),children:n.jsx(X,{size:14})}),n.jsxs("span",{className:"pdf-zoom-value","aria-live":"polite",children:[o,"%"]}),n.jsx("button",{disabled:o>=200,title:t("editor.pdfZoomIn"),"aria-label":t("editor.pdfZoomIn"),onClick:()=>g(10),children:n.jsx(q,{size:14})}),n.jsxs("button",{className:"pdf-fit-width",title:t("editor.pdfFitWidth"),onClick:A,children:[n.jsx(H,{size:13}),t("editor.pdfFitWidth")]})]}),N&&n.jsxs("div",{className:"pdf-compiling-overlay",role:"status","aria-live":"polite",children:[n.jsx(T,{className:"spin",size:20}),n.jsx("span",{children:t("editor.compiling")})]}),n.jsx("div",{className:"pdf-document",ref:p,onScroll:w,onWheel:b,children:n.jsxs("div",{className:"pdf-pages",style:{width:`${Math.max(1,v-28)*Math.max(1,o/100)}px`},children:[!f&&!R&&n.jsxs("div",{className:"pdf-loading",role:"status","aria-live":"polite",children:[n.jsx(T,{className:"spin",size:24}),n.jsx("span",{children:t("editor.loadingPdf")})]}),R&&n.jsx("div",{className:"preview-empty",children:n.jsx("strong",{children:R})}),f&&v>0&&Array.from({length:f.numPages},(e,r)=>n.jsx(_,{document:f,pageNumber:r+1,availableWidth:v-28,zoom:o/100,target:u?.page===r+1?u:null,onReady:w,onPageElement:j,onInternalLink:E,onDoubleClickLocation:h},r+1))]})})]})}function _({document:y,pageNumber:u,availableWidth:N,zoom:S,target:h,onReady:t,onPageElement:p,onInternalLink:f,onDoubleClickLocation:L}){const v=i.useRef(null),x=i.useRef(null),o=i.useRef(null),[m,R]=i.useState(1),[M,z]=i.useState({width:0,height:0}),[j,E]=i.useState(u===1),[w,g]=i.useState(!1),[A,b]=i.useState(null),[e,r]=i.useState([]);i.useEffect(()=>{const s=v.current;if(!s||j)return;if(!("IntersectionObserver"in window)){E(!0);return}const a=new IntersectionObserver(c=>{c.some(k=>k.isIntersecting)&&(E(!0),a.disconnect())},{rootMargin:"900px 0px"});return a.observe(s),()=>a.disconnect()},[j]),i.useEffect(()=>{h&&E(!0)},[h?.nonce]),i.useEffect(()=>{if(!j)return;let s=!1,a=null;return g(!1),b(null),r([]),y.getPage(u).then(c=>{if(s)return;const k=c.getViewport({scale:1}),W=N/k.width,I=Math.min(3.3,Math.max(.175,W*S)),P=c.getViewport({scale:I});if(R(I),z({width:P.width,height:P.height}),b(P),c.getAnnotations({intent:"display"}).then(B=>{s||r(B)}).catch(()=>{s||r([])}),!x.current)return;const C=Math.max(1,window.devicePixelRatio||1),$=c.getViewport({scale:I*C});return x.current.width=Math.floor($.width),x.current.height=Math.floor($.height),a=c.render({canvas:x.current,viewport:$}),a.promise.then(()=>{s||(g(!0),window.requestAnimationFrame(t))})}).catch(()=>{}),()=>{s=!0,a?.cancel()}},[y,u,N,S,j]),i.useEffect(()=>{!h||!o.current||o.current.scrollIntoView({behavior:"smooth",block:"center",inline:"center"})},[h?.nonce,m]);const d=s=>{if(!L||!w||s.target instanceof HTMLElement&&s.target.closest("a"))return;const a=x.current;if(!a)return;const c=a.getBoundingClientRect();if(s.clientX<c.left||s.clientX>c.right||s.clientY<c.top||s.clientY>c.bottom)return;const k=m||1,W=Math.max(0,Math.min(c.width,s.clientX-c.left))/k,I=Math.max(0,Math.min(c.height,s.clientY-c.top))/k;L(u,W,I)},l=Math.max(1,N*S),D=l*(792/612);return n.jsxs("figure",{ref:s=>{v.current=s,p(u,s)},onDoubleClick:d,className:`pdf-page${w?" rendered":" loading"}`,"data-page":u,"data-scale":m,style:{width:`${M.width||l}px`,minHeight:`${M.height||D}px`},children:[n.jsx("canvas",{ref:x,style:{width:`${M.width||l}px`,height:`${M.height||D}px`}}),w&&A&&n.jsx(K,{annotations:e,viewport:A,onInternalLink:f}),h&&n.jsx("span",{ref:o,className:"pdf-sync-marker",style:{left:h.x*m,top:h.y*m}}),n.jsx("figcaption",{children:u})]})}function K({annotations:y,viewport:u,onInternalLink:N}){const{t:S}=Z(),h=S("editor.pdfLink");return n.jsx("div",{className:"pdf-annotation-layer","aria-label":S("editor.pdfLinks"),children:y.filter(t=>t.subtype==="Link"&&Array.isArray(t.rect)&&t.rect.length>=4).map((t,p)=>{const[f,L]=u.convertToViewportPoint(t.rect[0],t.rect[1]),[v,x]=u.convertToViewportPoint(t.rect[2],t.rect[3]),o=[f,L,v,x],m=Math.min(o[0],o[2]),R=Math.min(o[1],o[3]),M=Math.abs(o[2]-o[0]),z=Math.abs(o[3]-o[1]),j=typeof t.title=="string"?t.title.trim():"",E=typeof t.unsafeUrl=="string"?t.unsafeUrl.trim():"",w=typeof t.url=="string"?t.url.trim():"",g=V(w)?w:V(E)?E:"",A=t.dest;if(!g&&A==null)return null;const b=!!g;return n.jsx("a",{className:"pdf-annotation-link",href:g||"#",target:b?"_blank":void 0,rel:b?"noreferrer":void 0,title:j||(b?g:h),"aria-label":j||(b?g:h),style:{left:m,top:R,width:M,height:z},onClick:b?void 0:e=>{e.preventDefault(),N(A)}},`${p}-${m}-${R}`)})})}function V(y){return/^(?:https?|mailto|ftp):/i.test(y)}export{re as PdfPreview};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as A,r,j as e}from"./react-CsO_xvbl.js";import{i as B,k as R,M as F,n as $,L as I,o as J,l as K,F as V,p as G}from"./index-
|
|
1
|
+
import{u as A,r,j as e}from"./react-CsO_xvbl.js";import{i as B,k as R,M as F,n as $,L as I,o as J,l as K,F as V,p as G}from"./index-BLOqf18q.js";const L=B("Replace",[["path",{d:"M14 4a2 2 0 0 1 2-2",key:"1w2hp7"}],["path",{d:"M16 10a2 2 0 0 1-2-2",key:"shjach"}],["path",{d:"M20 2a2 2 0 0 1 2 2",key:"188mtx"}],["path",{d:"M22 8a2 2 0 0 1-2 2",key:"ddf4tu"}],["path",{d:"m3 7 3 3 3-3",key:"x25e72"}],["path",{d:"M6 10V5a3 3 0 0 1 3-3h1",key:"3y3t5z"}],["rect",{x:"2",y:"14",width:"8",height:"8",rx:"2",key:"4rksxw"}]]);function Z({open:i,files:u,onOpenChange:l,onOpenFile:p}){const{t:a}=A(),[n,m]=r.useState(""),[d,o]=r.useState(0),f=r.useRef(null),h=r.useMemo(()=>u.filter(t=>t.type==="file").map(t=>({entry:t,score:H(t.path,n)})).filter(t=>t.score>=0).sort((t,c)=>c.score-t.score||t.entry.path.localeCompare(c.entry.path)).slice(0,100),[u,n]);r.useEffect(()=>{i&&(m(""),o(0),window.setTimeout(()=>f.current?.focus(),0))},[i]),r.useEffect(()=>o(t=>Math.min(t,Math.max(0,h.length-1))),[h.length]);const x=t=>{p(t),l(!1)};return e.jsx(F,{open:i,wide:!0,title:a("navigation.quickOpen"),description:a("navigation.quickOpenDescription"),onOpenChange:l,children:e.jsxs("div",{className:"quick-open-dialog",children:[e.jsxs("label",{children:[e.jsx($,{size:16}),e.jsx("input",{ref:f,value:n,placeholder:a("navigation.filePlaceholder"),onChange:t=>{m(t.target.value),o(0)},onKeyDown:t=>{t.key==="ArrowDown"&&(t.preventDefault(),o(c=>Math.min(h.length-1,c+1))),t.key==="ArrowUp"&&(t.preventDefault(),o(c=>Math.max(0,c-1))),t.key==="Enter"&&h[d]&&(t.preventDefault(),x(h[d].entry.path))}})]}),e.jsxs("div",{className:"quick-open-results",children:[h.map(({entry:t},c)=>e.jsxs("button",{className:c===d?"active":"",onMouseEnter:()=>o(c),onClick:()=>x(t.path),children:[e.jsx(V,{size:14}),e.jsx("span",{children:t.path}),c===d&&e.jsx(G,{size:13})]},t.path)),h.length===0&&e.jsx("p",{className:"muted padded",children:a("navigation.noFiles")})]})]})})}function _({open:i,project:u,onOpenChange:l,onJump:p}){const{t:a}=A(),[n,m]=r.useState(""),[d,o]=r.useState(""),[f,h]=r.useState(!1),[x,t]=r.useState(!1),[c,w]=r.useState([]),[v,C]=r.useState(0),[P,D]=r.useState(!1),[b,S]=r.useState(!1),[W,N]=r.useState(!1),[z,M]=r.useState(""),[q,k]=r.useState(""),[O,Q]=r.useState(0),y=r.useRef(null);r.useEffect(()=>{if(!i){y.current?.abort();return}if(M(""),k(""),!n.trim()){w([]),C(0),D(!1);return}const s=window.setTimeout(()=>{y.current?.abort();const j=new AbortController;y.current=j,S(!0);const E=new URLSearchParams({q:n});f&&E.set("caseSensitive","1"),x&&E.set("wholeWord","1"),R(`/api/projects/${u.id}/search?${E}`,{signal:j.signal}).then(g=>{w(g.matches),C(g.total),D(g.truncated)}).catch(g=>{g instanceof DOMException&&g.name==="AbortError"||k(T(g))}).finally(()=>{y.current===j&&(y.current=null,S(!1))})},250);return()=>window.clearTimeout(s)},[i,u.id,n,f,x,O]);const U=async()=>{N(!1),S(!0),k(""),M("");try{const s=await R(`/api/projects/${u.id}/search/replace`,{method:"POST",body:JSON.stringify({query:n,replacement:d,caseSensitive:f,wholeWord:x})});M(a("navigation.replaced",{count:s.replacements,files:s.files.length})),w([]),C(0),Q(j=>j+1)}catch(s){k(T(s))}finally{S(!1)}};return e.jsxs(e.Fragment,{children:[e.jsx(F,{open:i,extraWide:!0,title:a("navigation.projectSearch"),description:a("navigation.projectSearchDescription"),onOpenChange:l,footer:e.jsx("button",{onClick:()=>l(!1),children:a("common.close")}),children:e.jsxs("div",{className:"project-search-dialog",children:[q&&e.jsx("p",{className:"error",children:q}),z&&e.jsx("p",{className:"success",children:z}),e.jsxs("div",{className:"project-search-form",children:[e.jsxs("label",{className:"project-search-query",children:[e.jsx($,{size:16}),e.jsx("input",{autoFocus:!0,value:n,placeholder:a("navigation.searchPlaceholder"),onChange:s=>m(s.target.value)})]}),u.permission!=="read"&&e.jsxs("label",{className:"project-search-query",children:[e.jsx(L,{size:16}),e.jsx("input",{value:d,placeholder:a("navigation.replacePlaceholder"),onChange:s=>o(s.target.value)})]}),e.jsxs("div",{className:"project-search-options",children:[e.jsxs("label",{children:[e.jsx("input",{type:"checkbox",checked:f,onChange:s=>h(s.target.checked)}),a("editor.search.matchCase")]}),e.jsxs("label",{children:[e.jsx("input",{type:"checkbox",checked:x,onChange:s=>t(s.target.checked)}),a("editor.search.wholeWord")]}),u.permission!=="read"&&e.jsxs("button",{className:"danger-text",disabled:!n.trim()||v===0||b,onClick:()=>N(!0),children:[e.jsx(L,{size:13}),a("navigation.replaceAll",{count:v})]})]})]}),e.jsxs("div",{className:"project-search-summary",children:[e.jsx("span",{children:b?e.jsxs(e.Fragment,{children:[e.jsx(I,{className:"spin",size:13}),a("common.loading")]}):a("navigation.matchSummary",{count:v})}),P&&e.jsx("small",{children:a("navigation.truncated",{count:c.length})})]}),e.jsxs("div",{className:"project-search-results",children:[c.map((s,j)=>e.jsxs("button",{onClick:()=>{p(s.path,s.line,s.column),l(!1)},children:[e.jsx(J,{size:14}),e.jsxs("span",{children:[e.jsxs("strong",{children:[s.path,e.jsxs("small",{children:[":",s.line,":",s.column]})]}),e.jsxs("code",{children:[s.preview.slice(0,s.matchStart),e.jsx("mark",{children:s.preview.slice(s.matchStart,s.matchEnd)}),s.preview.slice(s.matchEnd)]})]})]},`${s.path}-${s.line}-${s.column}-${j}`)),!b&&n.trim()&&c.length===0&&e.jsx("p",{className:"muted padded",children:a("editor.search.noMatches")})]})]})}),e.jsx(K,{open:W,title:a("navigation.replaceConfirmTitle"),description:a("navigation.replaceConfirmDescription",{count:v}),confirmLabel:a("navigation.replaceAll",{count:v}),danger:!0,onCancel:()=>N(!1),onConfirm:()=>{U()}})]})}function H(i,u){const l=i.toLocaleLowerCase(),p=u.trim().toLocaleLowerCase();if(!p)return 1;const a=l.indexOf(p);if(a>=0)return 1e4-a-l.length;let n=0,m=0;for(const d of p){const o=l.indexOf(d,n);if(o<0)return-1;m+=o===n?5:1,n=o+1}return m-l.length/100}function T(i){return i instanceof Error?i.message:String(i)}export{_ as ProjectSearchDialog,Z as QuickOpenDialog};
|
package/dist/client/assets/{SystemMetricsDialog-CGyldSTF.js → SystemMetricsDialog-OAoXCVVy.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as f,r as n,j as e}from"./react-CsO_xvbl.js";import{i as y,k as M,M as b,A as v}from"./index-
|
|
1
|
+
import{u as f,r as n,j as e}from"./react-CsO_xvbl.js";import{i as y,k as M,M as b,A as v}from"./index-BLOqf18q.js";const $=y("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);function k({open:t,onOpenChange:c}){const{t:s}=f(),[r,p]=n.useState(null),[u,x]=n.useState(!1),[m,j]=n.useState(""),o=n.useCallback(async()=>{x(!0);try{p(await M("/api/health/metrics")),j("")}catch(i){j(i instanceof Error?i.message:s("errors.generic"))}finally{x(!1)}},[s]);return n.useEffect(()=>{if(!t)return;o();const i=window.setInterval(()=>{o()},5e3);return()=>window.clearInterval(i)},[t,o]),e.jsxs(b,{open:t,onOpenChange:c,wide:!0,title:s("metrics.title"),description:s("metrics.description"),footer:e.jsxs("button",{onClick:()=>{o()},disabled:u,children:[e.jsx($,{size:14,className:u?"spin":""}),s("metrics.refresh")]}),children:[m&&e.jsx("p",{className:"error",children:m}),!r&&!m&&e.jsx("p",{className:"muted",children:s("common.loading")}),r&&e.jsxs("div",{className:"system-metrics",children:[e.jsxs("div",{className:"metric-summary-grid",children:[e.jsx(l,{label:s("metrics.uptime"),value:g(r.uptimeSeconds)}),e.jsx(l,{label:s("metrics.memory"),value:`${h(r.memory.rssBytes)} RSS`,detail:`${h(r.memory.heapUsedBytes)} / ${h(r.memory.heapTotalBytes)} ${s("metrics.heap")}`}),e.jsx(l,{label:s("metrics.compileQueue"),value:`${r.compileQueue.running} / ${r.compileQueue.concurrency}`,detail:s("metrics.pending",{count:r.compileQueue.pending})}),e.jsx(l,{label:s("metrics.collaboration"),value:s("metrics.sessions",{count:r.collaboration.sessions}),detail:s("metrics.roomsAndDirty",{rooms:r.collaboration.rooms,dirty:r.collaboration.dirtyFiles})})]}),e.jsxs("section",{className:"metric-section",children:[e.jsxs("h3",{children:[e.jsx(v,{size:15}),s("metrics.eventLoop")]}),e.jsx("p",{children:s("metrics.latencySummary",r.eventLoopDelay)})]}),e.jsxs("section",{className:"metric-section",children:[e.jsx("h3",{children:s("metrics.operationDurations")}),Object.keys(r.durationsMs).length===0?e.jsx("p",{className:"muted",children:s("metrics.noSamples")}):e.jsx("div",{className:"metric-table-wrap",children:e.jsxs("table",{className:"metric-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:s("metrics.operation")}),e.jsx("th",{children:s("metrics.samples")}),e.jsx("th",{children:s("metrics.last")}),e.jsx("th",{children:"P50"}),e.jsx("th",{children:"P95"}),e.jsx("th",{children:s("metrics.max")})]})}),e.jsx("tbody",{children:Object.entries(r.durationsMs).sort(([i],[a])=>i.localeCompare(a)).map(([i,a])=>e.jsxs("tr",{children:[e.jsx("td",{children:N(i,s)}),e.jsx("td",{children:a.count}),e.jsx("td",{children:d(a.last)}),e.jsx("td",{children:d(a.p50)}),e.jsx("td",{children:d(a.p95)}),e.jsx("td",{children:d(a.max)})]},i))})]})})]})]})]})}function l({label:t,value:c,detail:s}){return e.jsxs("article",{className:"metric-card",children:[e.jsx("span",{children:t}),e.jsx("strong",{children:c}),s&&e.jsx("small",{children:s})]})}function h(t){return`${Math.round(t/1024/1024*10)/10} MB`}function g(t){const c=Math.floor(t/86400),s=Math.floor(t%86400/3600),r=Math.floor(t%3600/60);return c?`${c}d ${s}h`:s?`${s}h ${r}m`:`${r}m`}function d(t){return t>=1e3?`${Math.round(t/100)/10}s`:`${Math.round(t*10)/10}ms`}function N(t,c){return c(`metrics.operations.${t}`,{defaultValue:t})}export{k as SystemMetricsDialog};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{B as r}from"./BinaryModule-Aj1vLnwf-wAe5fMVe.js";import"./index-BLOqf18q.js";import"./react-CsO_xvbl.js";const a=""+new URL("/assets/harper_wasm_bg-LWXDb7Ll.wasm",import.meta.url).href,o=r.create(a,"full");export{o as binary};
|