texlite 0.10.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DESIGN.md +44 -26
- package/OPERATIONS.md +12 -6
- package/README.md +9 -4
- package/README.zh-CN.md +7 -4
- package/dist/client/assets/AdminUsers-DMsBqC48.js +1 -0
- package/dist/client/assets/{CitationLibraryDialog-CU2b0xtm.js → CitationLibraryDialog-C_333dTc.js} +1 -1
- package/dist/client/assets/Dashboard-EOaNnS1A.js +2 -0
- package/dist/client/assets/GitDialog-DU-sVP-o.js +3 -0
- package/dist/client/assets/GitHubAccountDialog-IrB3M7nt.js +1 -0
- package/dist/client/assets/HistoryDialog-CDUbT7yG.js +7 -0
- package/dist/client/assets/LatexEditor-BYgW2otE.js +138 -0
- package/dist/client/assets/PdfPreview--HsIb8Fn.js +1 -0
- package/dist/client/assets/ProjectIconPickerDialog-CaF7Kkda.js +1 -0
- package/dist/client/assets/{ProjectNavigationDialogs-_JY0yVob.js → ProjectNavigationDialogs-3Ce7-tVp.js} +1 -1
- package/dist/client/assets/ProjectSettings-9hYSUKDo.js +1 -0
- package/dist/client/assets/ProjectWorkspace-D9zmy0KR.js +32 -0
- package/dist/client/assets/{SelectionHistoryDialog-D8CeqjLD.js → SelectionHistoryDialog-COpXO4kL.js} +2 -2
- package/dist/client/assets/SystemMetricsDialog-D9dthbAB.js +1 -0
- package/dist/client/assets/{TagManagementDialog-4R1Gs43j.js → TagManagementDialog-S8zDQAaB.js} +1 -1
- package/dist/client/assets/{WordCountDialog-C-MCscAu.js → WordCountDialog-CMsFa_pM.js} +1 -1
- package/dist/client/assets/check-Hv1kodh8.js +1 -0
- package/dist/client/assets/chktex-BFELQm91.js +3 -0
- package/dist/client/assets/{editor-B9HNwtsd.js → editor-taw1iptB.js} +1 -1
- package/dist/client/assets/external-link-C2GCFJxP.js +1 -0
- package/dist/client/assets/github-B_Eh2y6s.js +1 -0
- package/dist/client/assets/{hard-drive-Bsk-RETn.js → hard-drive-bzz70DQ5.js} +1 -1
- package/dist/client/assets/{index-Csp5J5aI.js → index-CXtmuEUm.js} +1 -1
- package/dist/client/assets/index-CxrDisif.css +1 -0
- package/dist/client/assets/index-Dik-2GCl.js +10 -0
- package/dist/client/assets/{minimize-2-92UqFWI9.js → minimize-2-CmPZ9Iwp.js} +1 -1
- package/dist/client/assets/{minus-bx4ZLZnb.js → minus-Dzy8rgfA.js} +1 -1
- package/dist/client/assets/{plus-DQg_bV50.js → plus-DlX82JCl.js} +1 -1
- package/dist/client/assets/{refresh-cw-BoMEkk5J.js → refresh-cw-BWndInnG.js} +1 -1
- package/dist/client/assets/{search-UZspmceH.js → search-DMqOy-Ex.js} +1 -1
- package/dist/client/assets/{sigma-C0IvFdKV.js → sigma-B0zOJKVj.js} +1 -1
- package/dist/client/assets/{spellCheck-DyKIHf5C.js → spellCheck-BjkrQxRU.js} +1 -1
- package/dist/client/assets/{tags-BTUtvaAc.js → tags-XvdXg-yc.js} +1 -1
- package/dist/client/assets/{type-XvvfEJRs.js → type-DsGlKUKR.js} +1 -1
- package/dist/client/assets/{user-plus-Chr9T97G.js → user-plus-Bcq_EsqH.js} +1 -1
- package/dist/client/assets/{x-DlFXD9Vl.js → x-BJOMjm8Z.js} +1 -1
- package/dist/client/index.html +3 -3
- package/dist/server/app.js +8 -0
- package/dist/server/chktex.js +377 -0
- package/dist/server/collaboration.js +6 -0
- package/dist/server/db.js +35 -1
- package/dist/server/environment.js +1 -0
- package/dist/server/git.js +64 -29
- package/dist/server/harper.js +14 -0
- package/dist/server/history.js +18 -9
- package/dist/server/i18n.js +14 -4
- package/dist/server/projectImportUploads.js +133 -0
- package/dist/server/routes/projectFiles.js +3 -0
- package/dist/server/routes/projectGit.js +10 -11
- package/dist/server/routes/projectHistory.js +32 -5
- package/dist/server/routes/projectMembers.js +0 -5
- package/dist/server/routes/projectShared.js +1 -0
- package/dist/server/routes/projects.js +97 -15
- package/dist/server/routes/users.js +0 -2
- package/dist/shared/historyFiles.js +6 -0
- package/dist/shared/writingChecks.js +4 -0
- package/package.json +1 -1
- package/dist/client/assets/AdminUsers-C7oU_1Y_.js +0 -1
- package/dist/client/assets/Dashboard-BB4RO4x2.js +0 -2
- package/dist/client/assets/GitDialog-C2Np1i8v.js +0 -3
- package/dist/client/assets/HistoryDialog-CdoYeLyX.js +0 -7
- package/dist/client/assets/LatexEditor-Dmy6_gqt.js +0 -138
- package/dist/client/assets/PdfPreview-fDxKh6hP.js +0 -1
- package/dist/client/assets/ProjectIconPickerDialog-CsjMKq7h.js +0 -1
- package/dist/client/assets/ProjectSettings-DXGA-lmB.js +0 -1
- package/dist/client/assets/ProjectWorkspace-mCYjyc6e.js +0 -32
- package/dist/client/assets/SystemMetricsDialog-BZx7ZMQt.js +0 -1
- package/dist/client/assets/check-Jf8WBxDX.js +0 -1
- package/dist/client/assets/index-B6rP7QsM.js +0 -12
- package/dist/client/assets/index-DGZNAyxW.css +0 -1
- package/dist/client/assets/key-round-DqptHHKC.js +0 -1
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./katex-D9PXdmFF.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{u as To,r as Y,j as Ve}from"./react-BVUjbTTn.js";import{s as Hr,E as pe,V as dt,D as J,a as ln,R as Ro,P as Wr,S as Ct,b as Le,f as Ao,M as Zr,m as ur,i as Po,c as No,d as Do,e as Bo,g as Fo,h as Io,j as fr,k as wn,l as It,n as $o,o as Vo,p as _o,q as Qo,r as jo,t as Ko,u as qo,v as zo,w as Uo,x as Xo,y as ut,F as $t,A as Sn,z as cn,W as Yr,B as Gr,L as Ho,C as Wo,G as Zo,H as Yo,I as ft,J as Go,K as ae,N as Jo,O as Vt,Q as Jr,T as ie,U as ea,X as ei,Y as Xe,Z as ta,_ as Bt,$ as ti,a0 as na,a1 as ra,a2 as At,a3 as ia,a4 as oa,a5 as aa,a6 as sa,a7 as la,a8 as dr,a9 as ca,aa as ua,ab as fa,ac as da,ad as ha,ae as pa,af as ma,ag as ga,ah as va,ai as ya,aj as ba,ak as ka,al as Oa,am as Ca,an as wa,ao as Sa,ap as xa,aq as Ma}from"./editor-B9HNwtsd.js";import{r as hr,a as bt,U as ni,b as un,d as fn,e as pr,m as Ea,f as La,g as tn,t as Pt,h as Nt,i as xn,l as Mn,j as _t,k as En,n as ri,o as ii,p as Ft,q as Ln,u as Ta,v as dn,w as oi,x as nn,y as Ra,z as Aa}from"./ProjectWorkspace-mCYjyc6e.js";import{_ as mr}from"./index-B6rP7QsM.js";import"./check-Jf8WBxDX.js";import"./x-DlFXD9Vl.js";import"./search-UZspmceH.js";import"./user-plus-Chr9T97G.js";import"./refresh-cw-BoMEkk5J.js";function Pa(t){var n=t.Pos;function o(e,r,i){if(r.line===i.line&&r.ch>=i.ch-1){var a=e.getLine(r.line),l=a.charCodeAt(r.ch);55296<=l&&l<=55551&&(i.ch+=1)}return{start:r,end:i}}var s=[{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"}],c=Object.create(null),f=s.length,m=[{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"}],g=ue("");function b(e){e.setOption("disableInput",!0),e.setOption("showCursorWhenSelecting",!1),t.signal(e,"vim-mode-change",{mode:"normal"}),e.on("cursorActivity",ir),qe(e),t.on(e.getInputField(),"paste",M(e))}function S(e){e.setOption("disableInput",!1),e.off("cursorActivity",ir),t.off(e.getInputField(),"paste",M(e)),e.state.vim=null,vt&&clearTimeout(vt)}function M(e){var r=e.state.vim;return r.onPasteFn||(r.onPasteFn=function(){r.insertMode||(e.setCursor(de(e.getCursor(),0,1)),rt.enterInsertMode(e,{},r))}),r.onPasteFn}var A=/[\d]/,P=[t.isWordChar,function(e){return e&&!t.isWordChar(e)&&!/\s/.test(e)}],E=[function(e){return/\S/.test(e)}],T=["<",">"],R=["-",'"',".",":","_","/","+"],_=/^\w$/,U=/^[A-Z]$/;try{U=new RegExp("^[\\p{Lu}]$","u")}catch{}function ee(e,r){return r>=e.firstLine()&&r<=e.lastLine()}function te(e){return/^[a-z]$/.test(e)}function q(e){return"()[]{}".indexOf(e)!=-1}function le(e){return A.test(e)}function Oe(e){return U.test(e)}function H(e){return/^\s*$/.test(e)}function je(e){return".?!".indexOf(e)!=-1}function et(e,r){for(var i=0;i<r.length;i++)if(r[i]==e)return!0;return!1}var Te={};function Ke(e,r,i,a,l){if(r===void 0&&!l)throw Error("defaultValue is required unless callback is provided");if(i||(i="string"),Te[e]={type:i,defaultValue:r,callback:l},a)for(var u=0;u<a.length;u++)Te[a[u]]=Te[e];r&&tt(e,r)}function tt(e,r,i,a){var l=Te[e];a=a||{};var u=a.scope;if(!l)return new Error("Unknown option: "+e);if(l.type=="boolean"){if(r&&r!==!0)return new Error("Invalid argument: "+e+"="+r);r!==!1&&(r=!0)}l.callback?(u!=="local"&&l.callback(r,void 0),u!=="global"&&i&&l.callback(r,i)):(u!=="local"&&(l.value=l.type=="boolean"?!!r:r),u!=="global"&&i&&(i.state.vim.options[e]={value:r}))}function be(e,r,i){var a=Te[e];i=i||{};var l=i.scope;if(!a)return new Error("Unknown option: "+e);if(a.callback){let u=r&&a.callback(void 0,r);return l!=="global"&&u!==void 0?u:l!=="local"?a.callback():void 0}else return(l!=="global"&&r&&r.state.vim.options[e]||l!=="local"&&a||{}).value}Ke("filetype",void 0,"string",["ft"],function(e,r){if(r!==void 0)if(e===void 0){let i=r.getOption("mode");return i=="null"?"":i}else{let i=e==""?"null":e;r.setOption("mode",i)}}),Ke("textwidth",80,"number",["tw"],function(e,r){if(r!==void 0)if(e===void 0){var i=r.getOption("textwidth");return i}else{var a=Math.round(e);a>1&&r.setOption("textwidth",a)}});var xt=function(){var e=100,r=-1,i=0,a=0,l=new Array(e);function u(p,v,y){var O=r%e,C=l[O];function w(x){var L=++r%e,F=l[L];F&&F.clear(),l[L]=p.setBookmark(x)}if(C){var k=C.find();k&&!Ae(k,v)&&w(v)}else w(v);w(y),i=r,a=r-e+1,a<0&&(a=0)}function d(p,v){r+=v,r>i?r=i:r<a&&(r=a);var y=l[(e+r)%e];if(y&&!y.find()){var O=v>0?1:-1,C,w=p.getCursor();do if(r+=O,y=l[(e+r)%e],y&&(C=y.find())&&!Ae(w,C))break;while(r<i&&r>a)}return y}function h(p,v){var y=r,O=d(p,v);return r=y,O&&O.find()}return{cachedCursor:void 0,add:u,find:h,move:d}},ht=function(e){return e?{changes:e.changes,expectCursorActivityForChange:e.expectCursorActivityForChange}:{changes:[],expectCursorActivityForChange:!1}};class Mt{constructor(){this.latestRegister=void 0,this.isPlaying=!1,this.isRecording=!1,this.replaySearchQueries=[],this.onRecordingDone=void 0,this.lastInsertModeChanges=ht()}exitMacroRecordMode(){var r=N.macroModeState;r.onRecordingDone&&r.onRecordingDone(),r.onRecordingDone=void 0,r.isRecording=!1}enterMacroRecordMode(r,i){var a=N.registerController.getRegister(i);if(a){if(a.clear(),this.latestRegister=i,r.openDialog){var l=De("span",{class:"cm-vim-message"},"recording @"+i);this.onRecordingDone=r.openDialog(l,function(){},{bottom:!0})}this.isRecording=!0}}}function qe(e){return e.state.vim||(e.state.vim={inputState:new fe,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 n(0,0),head:new n(0,0)},options:{},expectLiteralNext:!1,status:""}),e.state.vim}var N;function pt(){N={searchQuery:null,searchIsReversed:!1,lastSubstituteReplacePart:void 0,jumpList:xt(),macroModeState:new Mt,lastCharacterSearch:{increment:0,forward:!0,selectedCharacter:""},registerController:new Et({}),searchHistoryController:new Dn,exCommandHistoryController:new Dn};for(var e in Te){var r=Te[e];r.value=r.defaultValue}}class st{constructor(r,i){this.keyName=r,this.key=i.key,this.ctrlKey=i.ctrlKey,this.altKey=i.altKey,this.metaKey=i.metaKey,this.shiftKey=i.shiftKey}}var He,me={enterVimMode:b,leaveVimMode:S,buildKeyMap:function(){},getRegisterController:function(){return N.registerController},resetVimGlobalState_:pt,getVimGlobalState_:function(){return N},maybeInitVimState_:qe,suppressErrorLogging:!1,InsertModeKey:st,map:function(e,r,i){Se.map(e,r,i)},unmap:function(e,r){return Se.unmap(e,r)},noremap:function(e,r,i){Se.map(e,r,i,!0)},mapclear:function(e){var r=s.length,i=f,a=s.slice(0,r-i);if(s=s.slice(r-i),e)for(var l=a.length-1;l>=0;l--){var u=a[l];if(e!==u.context)if(u.context)this._mapCommand(u);else{var d=["normal","insert","visual"];for(var h in d)if(d[h]!==e){var p=Object.assign({},u);p.context=d[h],this._mapCommand(p)}}}},langmap:Q,vimKeyFromEvent:ce,setOption:tt,getOption:be,defineOption:Ke,defineEx:function(e,r,i){if(!r)r=e;else if(e.indexOf(r)!==0)throw new Error('(Vim.defineEx) "'+r+'" is not a prefix of "'+e+'", command not registered');nr[e]=i,Se.commandMap_[r]={name:e,shortName:r,type:"api"}},handleKey:function(e,r,i){var a=this.findKey(e,r,i);if(typeof a=="function")return a()},multiSelectHandleKey:Lo,findKey:function(e,r,i){var a=qe(e),l=e;function u(){var y=N.macroModeState;if(y.isRecording){if(r=="q")return y.exitMacroRecordMode(),oe(l),!0;i!="mapping"&&xo(y,r)}}function d(){if(r=="<Esc>"){if(a.visualMode)Ie(l);else if(a.insertMode)Je(l);else return;return oe(l),!0}}function h(){if(d())return!0;a.inputState.keyBuffer.push(r);var y=a.inputState.keyBuffer.join(""),O=r.length==1,C=nt.matchCommand(y,s,a.inputState,"insert"),w=a.inputState.changeQueue;if(C.type=="none")return oe(l),!1;if(C.type=="partial"){if(C.expectLiteralNext&&(a.expectLiteralNext=!0),He&&window.clearTimeout(He),He=O&&window.setTimeout(function(){a.insertMode&&a.inputState.keyBuffer.length&&oe(l)},be("insertModeEscKeysTimeout")),O){var k=l.listSelections();(!w||w.removed.length!=k.length)&&(w=a.inputState.changeQueue=new mt),w.inserted+=r;for(var x=0;x<k.length;x++){var L=we(k[x].anchor,k[x].head),F=Ge(k[x].anchor,k[x].head),D=l.getRange(L,l.state.overwrite?de(F,0,1):F);w.removed[x]=(w.removed[x]||"")+D}}return!O}else C.type=="full"&&(a.inputState.keyBuffer.length=0);if(a.expectLiteralNext=!1,He&&window.clearTimeout(He),C.command&&w){for(var k=l.listSelections(),x=0;x<k.length;x++){var B=k[x].head;l.replaceRange(w.removed[x]||"",de(B,0,-w.inserted.length),B,"+input")}N.macroModeState.lastInsertModeChanges.changes.pop()}return C.command||oe(l),C.command}function p(){if(u()||d())return!0;a.inputState.keyBuffer.push(r);var y=a.inputState.keyBuffer.join("");if(/^[1-9]\d*$/.test(y))return!0;var O=/^(\d*)(.*)$/.exec(y);if(!O)return oe(l),!1;var C=a.visualMode?"visual":"normal",w=O[2]||O[1];a.inputState.operatorShortcut&&a.inputState.operatorShortcut.slice(-1)==w&&(w=a.inputState.operatorShortcut);var k=nt.matchCommand(w,s,a.inputState,C);return k.type=="none"?(oe(l),!1):k.type=="partial"?(k.expectLiteralNext&&(a.expectLiteralNext=!0),!0):k.type=="clear"?(oe(l),!0):(a.expectLiteralNext=!1,a.inputState.keyBuffer.length=0,O=/^(\d*)(.*)$/.exec(y),O&&O[1]&&O[1]!="0"&&a.inputState.pushRepeatDigit(O[1]),k.command)}var v=a.insertMode?h():p();if(v===!1)return!a.insertMode&&(r.length===1||t.isMac&&/<A-.>/.test(r))?function(){return!0}:void 0;if(v===!0)return function(){return!0};if(v)return function(){return l.operation(function(){l.curOp.isVimOp=!0;try{if(typeof v!="object")return;v.type=="keyToKey"?Ye(l,v.toKeys,v):nt.processCommand(l,a,v)}catch(y){throw l.state.vim=void 0,qe(l),me.suppressErrorLogging||console.log(y),y}return!0})}},handleEx:function(e,r){Se.processCommand(e,r)},defineMotion:Vi,defineAction:Qi,defineOperator:_i,mapCommand:wo,_mapCommand:Yt,defineRegister:Kt,exitVisualMode:Ie,exitInsertMode:Je},We=[],Ze=!1,W;function ze(e){if(!W)throw new Error("No prompt to send key to");if(e[0]=="<"){var r=e.toLowerCase().slice(1,-1),i=r.split("-");if(r=i.pop()||"",r=="lt")e="<";else if(r=="space")e=" ";else if(r=="cr")e=`
|
|
3
|
-
`;else if(Z[r]){var a=W.value||"",l={key:Z[r],target:{value:a,selectionEnd:a.length,selectionStart:a.length}};W.onKeyDown&&W.onKeyDown(l,W.value,d),W&&W.onKeyUp&&W.onKeyUp(l,W.value,d);return}}if(e==`
|
|
4
|
-
`){var u=W;W=null,u.onClose&&u.onClose(u.value)}else W.value=(W.value||"")+e;function d(h){W&&(typeof h=="string"?W.value=h:W=null)}}function Ye(e,r,i){var a=Ze;if(i){if(We.indexOf(i)!=-1)return;We.push(i),Ze=i.noremap!=!1}try{for(var l=qe(e),u=/<(?:[CSMA]-)*\w+>|./gi,d;d=u.exec(r);){var h=d[0],p=l.insertMode;if(W){ze(h);continue}var v=me.handleKey(e,h,"mapping");if(!v&&p&&l.insertMode){if(h[0]=="<"){var y=h.toLowerCase().slice(1,-1),O=y.split("-");if(y=O.pop()||"",y=="lt")h="<";else if(y=="space")h=" ";else if(y=="cr")h=`
|
|
5
|
-
`;else if(Z.hasOwnProperty(y)){h=Z[y],lr(e,h);continue}else h=h[0],u.lastIndex=d.index+1}e.replaceSelection(h)}}}finally{if(We.pop(),Ze=We.length?a:!1,!We.length&&W){var C=W;W=null,Tt(e,C)}}}var I={Return:"CR",Backspace:"BS",Delete:"Del",Escape:"Esc",Insert:"Ins",ArrowLeft:"Left",ArrowRight:"Right",ArrowUp:"Up",ArrowDown:"Down",Enter:"CR"," ":"Space"},G={Shift:1,Alt:1,Command:1,Control:1,CapsLock:1,AltGraph:1,Dead:1,Unidentified:1},Z={};"Left|Right|Up|Down|End|Home".split("|").concat(Object.keys(I)).forEach(function(e){Z[(I[e]||"").toLowerCase()]=Z[e.toLowerCase()]=e});function ce(e,r){var i=e.key;if(!G[i]){i.length>1&&i[0]=="n"&&(i=i.replace("Numpad","")),i=I[i]||i;var a="";if(e.ctrlKey&&(a+="C-"),e.altKey&&(a+="A-"),e.metaKey&&(a+="M-"),t.isMac&&a=="A-"&&i.length==1&&(a=a.slice(2)),(a||i.length>1)&&e.shiftKey&&(a+="S-"),r&&!r.expectLiteralNext&&i.length==1){if(g.keymap&&i in g.keymap)(g.remapCtrl!=!1||!a)&&(i=g.keymap[i]);else if(i.charCodeAt(0)>128&&!c[i]){var l=e.code?.slice(-1)||"";e.shiftKey||(l=l.toLowerCase()),l&&(i=l,!a&&e.altKey&&(a="A-"))}}return a+=i,a.length>1&&(a="<"+a+">"),a}}function Q(e,r){g.string!==e&&(g=ue(e)),g.remapCtrl=r}function ue(e){let r={};if(!e)return{keymap:r,string:""};function i(a){return a.split(/\\?(.)/).filter(Boolean)}return e.split(/((?:[^\\,]|\\.)+),/).map(a=>{if(!a)return;const l=a.split(/((?:[^\\;]|\\.)+);/);if(l.length==3){const u=i(l[1]),d=i(l[2]);if(u.length!==d.length)return;for(let h=0;h<u.length;++h)r[u[h]]=d[h]}else if(l.length==1){const u=i(a);if(u.length%2!==0)return;for(let d=0;d<u.length;d+=2)r[u[d]]=u[d+1]}}),{keymap:r,string:e}}Ke("langmap",void 0,"string",["lmap"],function(e,r){if(e===void 0)return g.string;Q(e)});class fe{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(r){this.operator?this.motionRepeat=this.motionRepeat.concat(r):this.prefixRepeat=this.prefixRepeat.concat(r)}getRepeat(){var r=0;return(this.prefixRepeat.length>0||this.motionRepeat.length>0)&&(r=1,this.prefixRepeat.length>0&&(r*=parseInt(this.prefixRepeat.join(""),10)),this.motionRepeat.length>0&&(r*=parseInt(this.motionRepeat.join(""),10))),r}}function oe(e,r){e.state.vim.inputState=new fe,e.state.vim.expectLiteralNext=!1,t.signal(e,"vim-command-done",r)}function mt(){this.removed=[],this.inserted=""}class Re{constructor(r,i,a){this.clear(),this.keyBuffer=[r||""],this.insertModeChanges=[],this.searchQueries=[],this.linewise=!!i,this.blockwise=!!a}setText(r,i,a){this.keyBuffer=[r||""],this.linewise=!!i,this.blockwise=!!a}pushText(r,i){i&&(this.linewise||this.keyBuffer.push(`
|
|
6
|
-
`),this.linewise=!0),this.keyBuffer.push(r)}pushInsertModeChanges(r){this.insertModeChanges.push(ht(r))}pushSearchQuery(r){this.searchQueries.push(r)}clear(){this.keyBuffer=[],this.insertModeChanges=[],this.searchQueries=[],this.linewise=!1}toString(){return this.keyBuffer.join("")}}function Kt(e,r){var i=N.registerController.registers;if(!e||e.length!=1)throw Error("Register name must be 1 character");if(i[e])throw Error("Register already defined "+e);i[e]=r,R.push(e)}class Et{constructor(r){this.registers=r,this.unnamedRegister=r['"']=new Re,r["."]=new Re,r[":"]=new Re,r["/"]=new Re,r["+"]=new Re}pushText(r,i,a,l,u){if(r!=="_"){l&&a.charAt(a.length-1)!==`
|
|
7
|
-
`&&(a+=`
|
|
8
|
-
`);var d=this.isValidRegister(r)?this.getRegister(r):null;if(!d||!r){switch(i){case"yank":this.registers[0]=new Re(a,l,u);break;case"delete":case"change":a.indexOf(`
|
|
9
|
-
`)==-1?this.registers["-"]=new Re(a,l):(this.shiftNumericRegisters_(),this.registers[1]=new Re(a,l));break}this.unnamedRegister.setText(a,l,u);return}var h=Oe(r);h?d.pushText(a,l):d.setText(a,l,u),r==="+"&&navigator.clipboard.writeText(a),this.unnamedRegister.setText(d.toString(),l)}}getRegister(r){return this.isValidRegister(r)?(r=r.toLowerCase(),this.registers[r]||(this.registers[r]=new Re),this.registers[r]):this.unnamedRegister}isValidRegister(r){return r&&(et(r,R)||_.test(r))}shiftNumericRegisters_(){for(var r=9;r>=2;r--)this.registers[r]=this.getRegister(""+(r-1))}}class Dn{constructor(){this.historyBuffer=[],this.iterator=0,this.initialPrefix=null}nextMatch(r,i){var a=this.historyBuffer,l=i?-1:1;this.initialPrefix===null&&(this.initialPrefix=r);for(var u=this.iterator+l;i?u>=0:u<a.length;u+=l)for(var d=a[u],h=0;h<=d.length;h++)if(this.initialPrefix==d.substring(0,h))return this.iterator=u,d;if(u>=a.length)return this.iterator=a.length,this.initialPrefix;if(u<0)return r}pushInput(r){var i=this.historyBuffer.indexOf(r);i>-1&&this.historyBuffer.splice(i,1),r.length&&this.historyBuffer.push(r)}reset(){this.initialPrefix=null,this.iterator=this.historyBuffer.length}}var nt={matchCommand:function(e,r,i,a){var l=ji(e,r,a,i),u=l.full[0];if(!u)return l.partial.length?{type:"partial",expectLiteralNext:l.partial.length==1&&l.partial[0].keys.slice(-11)=="<character>"}:{type:"none"};if(u.keys.slice(-11)=="<character>"||u.keys.slice(-10)=="<register>"){var d=qi(e);if(!d||d.length>1)return{type:"clear"};i.selectedCharacter=d}return{type:"full",command:u}},processCommand:function(e,r,i){switch(r.inputState.repeatOverride=i.repeatOverride,i.type){case"motion":this.processMotion(e,r,i);break;case"operator":this.processOperator(e,r,i);break;case"operatorMotion":this.processOperatorMotion(e,r,i);break;case"action":this.processAction(e,r,i);break;case"search":this.processSearch(e,r,i);break;case"ex":case"keyToEx":this.processEx(e,r,i);break}},processMotion:function(e,r,i){r.inputState.motion=i.motion,r.inputState.motionArgs=Lt(i.motionArgs),this.evalInput(e,r)},processOperator:function(e,r,i){var a=r.inputState;if(a.operator)if(a.operator==i.operator){a.motion="expandToLine",a.motionArgs={linewise:!0,repeat:1},this.evalInput(e,r);return}else oe(e);a.operator=i.operator,a.operatorArgs=Lt(i.operatorArgs),i.keys.length>1&&(a.operatorShortcut=i.keys),i.exitVisualBlock&&(r.visualBlock=!1,lt(e)),r.visualMode&&this.evalInput(e,r)},processOperatorMotion:function(e,r,i){var a=r.visualMode,l=Lt(i.operatorMotionArgs);l&&a&&l.visualLine&&(r.visualLine=!0),this.processOperator(e,r,i),a||this.processMotion(e,r,i)},processAction:function(e,r,i){var a=r.inputState,l=a.getRepeat(),u=!!l,d=Lt(i.actionArgs)||{repeat:1};a.selectedCharacter&&(d.selectedCharacter=a.selectedCharacter),i.operator&&this.processOperator(e,r,i),i.motion&&this.processMotion(e,r,i),(i.motion||i.operator)&&this.evalInput(e,r),d.repeat=l||1,d.repeatIsExplicit=u,d.registerName=a.registerName,oe(e),r.lastMotion=null,i.isEdit&&this.recordLastEdit(r,a,i),rt[i.action](e,d,r)},processSearch:function(e,r,i){if(!e.getSearchCursor)return;var a=i.searchArgs.forward,l=i.searchArgs.wholeWordOnly;Ne(e).setReversed(!a);var u=a?"/":"?",d=Ne(e).getQuery(),h=e.getScrollInfo(),p="";function v(D,B,$){N.searchHistoryController.pushInput(D),N.searchHistoryController.reset();try{gt(e,D,B,$)}catch{X(e,"Invalid regex: "+D),oe(e);return}nt.processMotion(e,r,{keys:"",type:"motion",motion:"findNext",motionArgs:{forward:!0,toJumplist:i.searchArgs.toJumplist}})}function y(D){e.scrollTo(h.left,h.top),v(D,!0,!0);var B=N.macroModeState;B.isRecording&&Eo(B,D)}function O(){return be("pcre")?"(JavaScript regexp: set pcre)":"(Vim regexp: set nopcre)"}function C(D,B,$){var j=ce(D),he,re;j=="<Up>"||j=="<Down>"?(he=j=="<Up>",re=D.target?D.target.selectionEnd:0,B=N.searchHistoryController.nextMatch(B,he)||"",$(B),re&&D.target&&(D.target.selectionEnd=D.target.selectionStart=Math.min(re,D.target.value.length))):j&&j!="<Left>"&&j!="<Right>"&&N.searchHistoryController.reset(),p=B,w()}function w(){var D;try{D=gt(e,p,!0,!0)}catch{}D?e.scrollIntoView(er(e,!a,D),30):(ct(e),e.scrollTo(h.left,h.top))}function k(D,B,$){var j=ce(D);j=="<Esc>"||j=="<C-c>"||j=="<C-[>"||j=="<BS>"&&B==""?(N.searchHistoryController.pushInput(B),N.searchHistoryController.reset(),gt(e,d?.source||""),ct(e),e.scrollTo(h.left,h.top),t.e_stop(D),oe(e),$(),e.focus()):j=="<Up>"||j=="<Down>"?t.e_stop(D):j=="<C-u>"&&(t.e_stop(D),$(""))}switch(i.searchArgs.querySrc){case"prompt":var x=N.macroModeState;if(x.isPlaying){let B=x.replaySearchQueries.shift();v(B||"",!0,!1)}else Tt(e,{onClose:y,prefix:u,desc:De("span",{$cursor:"pointer",onmousedown:function(B){B.preventDefault(),tt("pcre",!be("pcre")),this.textContent=O(),w()}},O()),onKeyUp:C,onKeyDown:k});break;case"wordUnderCursor":var L=Xt(e,{noSymbol:!0}),F=!0;if(L||(L=Xt(e,{noSymbol:!1}),F=!1),!L){X(e,"No word under cursor"),oe(e);return}let D=e.getLine(L.start.line).substring(L.start.ch,L.end.ch);F&&l?D="\\b"+D+"\\b":D=zi(D),N.jumpList.cachedCursor=e.getCursor(),e.setCursor(L.start),v(D,!0,!1);break}},processEx:function(e,r,i){function a(p){N.exCommandHistoryController.pushInput(p),N.exCommandHistoryController.reset(),Se.processCommand(e,p),e.state.vim&&oe(e),ct(e)}function l(p,v,y){var O=ce(p),C,w;(O=="<Esc>"||O=="<C-c>"||O=="<C-[>"||O=="<BS>"&&v=="")&&(N.exCommandHistoryController.pushInput(v),N.exCommandHistoryController.reset(),t.e_stop(p),oe(e),ct(e),y(),e.focus()),O=="<Up>"||O=="<Down>"?(t.e_stop(p),C=O=="<Up>",w=p.target?p.target.selectionEnd:0,v=N.exCommandHistoryController.nextMatch(v,C)||"",y(v),w&&p.target&&(p.target.selectionEnd=p.target.selectionStart=Math.min(w,p.target.value.length))):O=="<C-u>"?(t.e_stop(p),y("")):O&&O!="<Left>"&&O!="<Right>"&&N.exCommandHistoryController.reset()}function u(p,v){var y=new t.StringStream(v),O={};try{if(Se.parseInput_(e,y,O),O.commandName!="s"){ct(e);return}var C=Se.matchCommand_(O.commandName);if(!C||(Se.parseCommandArgs_(y,O,C),!O.argString))return;var w=Jn(O.argString.slice(1),!0,!0);w&&Wt(e,w)}catch{}}if(i.type=="keyToEx")Se.processCommand(e,i.exArgs.input);else{var d={onClose:a,onKeyDown:l,onKeyUp:u,prefix:":"};if(r.visualMode)d.value="'<,'>",d.selectValueOnOpen=!1;else{var h=r.inputState.getRepeat();h>1&&(d.value=".,.+"+(h-1),d.selectValueOnOpen=!1)}Tt(e,d)}},evalInput:function(e,r){var i=r.inputState,a=i.motion,l=i.motionArgs||{repeat:1},u=i.operator,d=i.operatorArgs||{},h=i.registerName,p=r.sel,v=ne(r.visualMode?Ce(e,p.head):e.getCursor("head")),y=ne(r.visualMode?Ce(e,p.anchor):e.getCursor("anchor")),O=ne(v),C=ne(y),w,k,x;if(u&&this.recordLastEdit(r,i),i.repeatOverride!==void 0?x=i.repeatOverride:x=i.getRepeat(),x>0&&l.explicitRepeat?l.repeatIsExplicit=!0:(l.noRepeat||!l.explicitRepeat&&x===0)&&(x=1,l.repeatIsExplicit=!1),i.selectedCharacter&&(l.selectedCharacter=d.selectedCharacter=i.selectedCharacter),l.repeat=x,oe(e),a){var L=Fe[a](e,v,l,r,i);if(r.lastMotion=Fe[a],!L)return;if(l.toJumplist){var F=N.jumpList,D=F.cachedCursor;D?(Qn(e,D,L),delete F.cachedCursor):Qn(e,v,L)}L instanceof Array?(k=L[0],w=L[1]):w=L,w||(w=ne(v)),r.visualMode?(r.visualBlock&&w.ch===1/0||(w=Ce(e,w,O)),k&&(k=Ce(e,k)),k=k||C,p.anchor=k,p.head=w,lt(e),Ue(e,r,"<",se(k,w)?k:w),Ue(e,r,">",se(k,w)?w:k)):u||(w=Ce(e,w,O),e.setCursor(w.line,w.ch))}if(u){if(d.lastSel){k=C;var B=d.lastSel,$=Math.abs(B.head.line-B.anchor.line),j=Math.abs(B.head.ch-B.anchor.ch);B.visualLine?w=new n(C.line+$,C.ch):B.visualBlock?w=new n(C.line+$,C.ch+j):B.head.line==B.anchor.line?w=new n(C.line,C.ch+j):w=new n(C.line+$,C.ch),r.visualMode=!0,r.visualLine=B.visualLine,r.visualBlock=B.visualBlock,p=r.sel={anchor:k,head:w},lt(e)}else r.visualMode&&(d.lastSel={anchor:ne(p.anchor),head:ne(p.head),visualBlock:r.visualBlock,visualLine:r.visualLine});var he,re,ge,z,V;if(r.visualMode){he=we(p.head,p.anchor),re=Ge(p.head,p.anchor),ge=r.visualLine||d.linewise,z=r.visualBlock?"block":ge?"line":"char";var xe=o(e,he,re);if(V=Ut(e,{anchor:xe.start,head:xe.end},z),ge){var ve=V.ranges;if(z=="block")for(var ye=0;ye<ve.length;ye++)ve[ye].head.ch=ke(e,ve[ye].head.line);else z=="line"&&(ve[0].head=new n(ve[0].head.line+1,0))}}else{if(he=ne(k||C),re=ne(w||O),se(re,he)){var it=he;he=re,re=it}ge=l.linewise||d.linewise,ge?Gi(e,he,re):l.forward&&Yi(e,he,re),z="char";var Jt=!l.inclusive||ge,xe=o(e,he,re);V=Ut(e,{anchor:xe.start,head:xe.end},z,Jt)}e.setSelections(V.ranges,V.primary),r.lastMotion=null,d.repeat=x,d.registerName=h,d.linewise=ge;var en=qt[u](e,d,V.ranges,C,w);r.visualMode&&Ie(e,en!=null),en&&e.setCursor(en)}},recordLastEdit:function(e,r,i){var a=N.macroModeState;a.isPlaying||(e.lastEditInputState=r,e.lastEditActionCommand=i,a.lastInsertModeChanges.changes=[],a.lastInsertModeChanges.expectCursorActivityForChange=!1,a.lastInsertModeChanges.visualBlock=e.visualBlock?e.sel.head.line-e.sel.anchor.line:0)}},Fe={moveToTopLine:function(e,r,i){var a=Zt(e).top+i.repeat-1;return new n(a,$e(e.getLine(a)))},moveToMiddleLine:function(e){var r=Zt(e),i=Math.floor((r.top+r.bottom)*.5);return new n(i,$e(e.getLine(i)))},moveToBottomLine:function(e,r,i){var a=Zt(e).bottom-i.repeat+1;return new n(a,$e(e.getLine(a)))},expandToLine:function(e,r,i){var a=r;return new n(a.line+i.repeat-1,1/0)},findNext:function(e,r,i){var a=Ne(e),l=a.getQuery();if(l){var u=!i.forward;u=a.isReversed()?!u:u,Wt(e,l);var d=er(e,u,l,i.repeat);return d||X(e,"No match found "+l+(be("pcre")?" (set nopcre to use Vim regexps)":"")),d}},findAndSelectNextInclusive:function(e,r,i,a,l){var u=Ne(e),d=u.getQuery();if(d){var h=!i.forward;h=u.isReversed()?!h:h;var p=vo(e,h,d,i.repeat,a);if(p){if(l.operator)return p;var v=p[0],y=new n(p[1].line,p[1].ch-1);if(a.visualMode){(a.visualLine||a.visualBlock)&&(a.visualLine=!1,a.visualBlock=!1,t.signal(e,"vim-mode-change",{mode:"visual",subMode:""}));var O=a.sel.anchor;if(O)return u.isReversed()?i.forward?[O,v]:[O,y]:i.forward?[O,y]:[O,v]}else a.visualMode=!0,a.visualLine=!1,a.visualBlock=!1,t.signal(e,"vim-mode-change",{mode:"visual",subMode:""});return h?[y,v]:[v,y]}}},goToMark:function(e,r,i,a){var l=Rt(e,a,i.selectedCharacter||"");return l?i.linewise?{line:l.line,ch:$e(e.getLine(l.line))}:l:null},moveToOtherHighlightedEnd:function(e,r,i,a){var l=a.sel;return a.visualBlock&&i.sameLine?[Ce(e,new n(l.anchor.line,l.head.ch)),Ce(e,new n(l.head.line,l.anchor.ch))]:[l.head,l.anchor]},jumpToMark:function(e,r,i,a){for(var l=r,u=0;u<i.repeat;u++){var d=l;for(var h in a.marks)if(te(h)){var p=a.marks[h].find(),v=i.forward?se(p,d):se(d,p);if(!v&&!(i.linewise&&p.line==d.line)){var y=Ae(d,l),O=i.forward?In(d,p,l):In(l,p,d);(y||O)&&(l=p)}}}return i.linewise&&(l=new n(l.line,$e(e.getLine(l.line)))),l},moveByCharacters:function(e,r,i){var a=r,l=i.repeat,u=i.forward?a.ch+l:a.ch-l;return new n(a.line,u)},moveByLines:function(e,r,i,a){var l=r,u=l.ch;switch(a.lastMotion){case this.moveByLines:case this.moveByDisplayLines:case this.moveByScroll:case this.moveToColumn:case this.moveToEol:u=a.lastHPos;break;default:a.lastHPos=u}var d=i.repeat+(i.repeatOffset||0),h=i.forward?l.line+d:l.line-d,p=e.firstLine(),v=e.lastLine(),y=e.findPosV(l,i.forward?d:-d,"line",a.lastHSPos),O=i.forward?y.line>h:y.line<h;return O&&(h=y.line,u=y.ch),h<p&&l.line==p?this.moveToStartOfLine(e,r,i,a):h>v&&l.line==v?zn(e,r,i,a,!0):(i.toFirstChar&&(u=$e(e.getLine(h)),a.lastHPos=u),a.lastHSPos=e.charCoords(new n(h,u),"div").left,new n(h,u))},moveByDisplayLines:function(e,r,i,a){var l=r;switch(a.lastMotion){case this.moveByDisplayLines:case this.moveByScroll:case this.moveByLines:case this.moveToColumn:case this.moveToEol:break;default:a.lastHSPos=e.charCoords(l,"div").left}for(var u=Math.round(i.repeat),d=0;d<u;d++){var h=e.findPosV(l,i.forward?1:-1,"line",a.lastHSPos);if(h.hitSide)break;l=h}return l!=r&&(a.lastHPos=l.ch),l},moveByPage:function(e,r,i){var a=r,l=i.repeat;return e.findPosV(a,i.forward?l:-l,"page")},moveByParagraph:function(e,r,i){var a=i.forward?1:-1;return Un(e,r,i.repeat,a).start},moveBySentence:function(e,r,i){var a=i.forward?1:-1;return oo(e,r,i.repeat,a)},moveByScroll:function(e,r,i,a){var l=e.getScrollInfo(),u=null,d=i.repeat;d||(d=l.clientHeight/(2*e.defaultTextHeight()));var h=e.charCoords(r,"local");if(i.repeat=d,u=Fe.moveByDisplayLines(e,r,i,a),!u)return null;var p=e.charCoords(u,"local");return e.scrollTo(null,l.top+p.top-h.top),u},moveByWords:function(e,r,i){return no(e,r,i.repeat,!!i.forward,!!i.wordEnd,!!i.bigWord)},moveTillCharacter:function(e,r,i){var a=i.repeat,l=Ht(e,a,i.forward,i.selectedCharacter,r),u=i.forward?-1:1;return jn(u,i),l?(l.ch+=u,l):null},moveToCharacter:function(e,r,i){var a=i.repeat;return jn(0,i),Ht(e,a,i.forward,i.selectedCharacter,r)||r},moveToSymbol:function(e,r,i){var a=i.repeat;return i.selectedCharacter&&to(e,a,i.forward,i.selectedCharacter)||r},moveToColumn:function(e,r,i,a){var l=i.repeat;return a.lastHPos=l-1,a.lastHSPos=e.charCoords(r,"div").left,ro(e,l)},moveToEol:function(e,r,i,a){return zn(e,r,i,a,!1)},moveToFirstNonWhiteSpaceCharacter:function(e,r){var i=r;return new n(i.line,$e(e.getLine(i.line)))},moveToMatchedSymbol:function(e,r){for(var i=r,a=i.line,l=i.ch,u=e.getLine(a),d;l<u.length;l++)if(d=u.charAt(l),d&&q(d)){var h=e.getTokenTypeAt(new n(a,l+1));if(h!=="string"&&h!=="comment")break}if(l<u.length){var p=d==="<"||d===">"?/[(){}[\]<>]/:/[(){}[\]]/,v=e.findMatchingBracket(new n(a,l),{bracketRegex:p});return v.to}else return i},moveToStartOfLine:function(e,r){return new n(r.line,0)},moveToLineOrEdgeOfDocument:function(e,r,i){var a=i.forward?e.lastLine():e.firstLine();return i.repeatIsExplicit&&(a=i.repeat-e.getOption("firstLineNumber")),new n(a,$e(e.getLine(a)))},moveToStartOfDisplayLine:function(e){return e.execCommand("goLineLeft"),e.getCursor()},moveToEndOfDisplayLine:function(e){e.execCommand("goLineRight");var r=e.getCursor();return r.sticky=="before"&&r.ch--,r},textObjectManipulation:function(e,r,i,a){var l={"(":")",")":"(","{":"}","}":"{","[":"]","]":"[","<":">",">":"<"},u={"'":!0,'"':!0,"`":!0},d=i.selectedCharacter||"";d=="b"?d="(":d=="B"&&(d="{");var h=!i.textObjectInner,p,v;if(l[d]){if(v=!0,p=Hn(e,r,d,h),!p){var y=e.getSearchCursor(new RegExp("\\"+d,"g"),r);y.find()&&(p=Hn(e,y.from(),d,h))}}else if(u[d])v=!0,p=ao(e,r,d,h);else if(d==="W"||d==="w")for(var O=i.repeat||1;O-- >0;){var C=Xt(e,{inclusive:h,innerWord:!h,bigWord:d==="W",noSymbol:d==="W",multiline:!0},p&&p.end);C&&(p||(p=C),p.end=C.end)}else if(d==="p")if(p=Un(e,r,i.repeat,0,h),i.linewise=!0,a.visualMode)a.visualLine||(a.visualLine=!0);else{var w=a.inputState.operatorArgs;w&&(w.linewise=!0),p.end.line--}else if(d==="t")p=Ji(e,r,h);else if(d==="s"){var k=e.getLine(r.line);r.ch>0&&je(k[r.ch])&&(r.ch-=1);var x=Xn(e,r,i.repeat,1,h),L=Xn(e,r,i.repeat,-1,h);H(e.getLine(L.line)[L.ch])&&H(e.getLine(x.line)[x.ch-1])&&(L={line:L.line,ch:L.ch+1}),p={start:L,end:x}}return p?e.state.vim.visualMode?Wi(e,p.start,p.end,v):[p.start,p.end]:null},repeatLastCharacterSearch:function(e,r,i){var a=N.lastCharacterSearch,l=i.repeat,u=i.forward===a.forward,d=(a.increment?1:0)*(u?-1:1);i.inclusive=!!u;var h=Ht(e,l,u,a.selectedCharacter,de(r,0,-d));return h?(h.ch+=d,h):r}};function Vi(e,r){Fe[e]=r}function Bn(e,r){for(var i=[],a=0;a<r;a++)i.push(e);return i}var qt={change:function(e,r,i){var a,l,u=e.state.vim,d=i[0].anchor,h=i[0].head;if(u.visualMode)if(r.fullLine)h.ch=Number.MAX_VALUE,h.line--,e.setSelection(d,h),l=e.getSelection(),e.replaceSelection(""),a=d;else{l=e.getSelection();var y=Bn("",i.length);e.replaceSelections(y),a=we(i[0].head,i[0].anchor)}else{l=e.getRange(d,h);var p=u.lastEditInputState;if(p?.motion=="moveByWords"&&!H(l)){var v=/\s+$/.exec(l);v&&p.motionArgs&&p.motionArgs.forward&&(h=de(h,0,-v[0].length),l=l.slice(0,-v[0].length))}r.linewise&&(d=new n(d.line,$e(e.getLine(d.line))),h.line>d.line&&(h=new n(h.line-1,Number.MAX_VALUE))),e.replaceRange("",d,h),a=d}N.registerController.pushText(r.registerName,"change",l,r.linewise,i.length>1),rt.enterInsertMode(e,{head:a},e.state.vim)},delete:function(e,r,i){var a,l,u=e.state.vim;if(u.visualBlock){l=e.getSelection();var p=Bn("",i.length);e.replaceSelections(p),a=we(i[0].head,i[0].anchor)}else{var d=i[0].anchor,h=i[0].head;r.linewise&&h.line!=e.firstLine()&&d.line==e.lastLine()&&d.line==h.line-1&&(d.line==e.firstLine()?d.ch=0:d=new n(d.line-1,ke(e,d.line-1))),l=e.getRange(d,h),e.replaceRange("",d,h),a=d,r.linewise&&(a=Fe.moveToFirstNonWhiteSpaceCharacter(e,d))}return N.registerController.pushText(r.registerName,"delete",l,r.linewise,u.visualBlock),Ce(e,a)},indent:function(e,r,i){var a=e.state.vim,l=a.visualMode&&r.repeat||1;if(a.visualBlock){for(var u=e.getOption("tabSize"),d=e.getOption("indentWithTabs")?" ":" ".repeat(u),h,p=i.length-1;p>=0;p--)if(h=we(i[p].anchor,i[p].head),r.indentRight)e.replaceRange(d.repeat(l),h,h);else{for(var v=e.getLine(h.line),y=0,O=0;O<l;O++){var C=v[h.ch+y];if(C==" ")y++;else if(C==" "){y++;for(var w=1;w<d.length&&(C=v[h.ch+y],C===" ");w++)y++}else break}e.replaceRange("",h,de(h,0,y))}return h}else if(e.indentMore)for(var O=0;O<l;O++)r.indentRight?e.indentMore():e.indentLess();else{var k=i[0].anchor.line,x=a.visualBlock?i[i.length-1].anchor.line:i[0].head.line;r.linewise&&x--;for(var p=k;p<=x;p++)for(var O=0;O<l;O++)e.indentLine(p,r.indentRight)}return Fe.moveToFirstNonWhiteSpaceCharacter(e,i[0].anchor)},indentAuto:function(e,r,i){return e.execCommand("indentAuto"),Fe.moveToFirstNonWhiteSpaceCharacter(e,i[0].anchor)},hardWrap:function(e,r,i,a){if(e.hardWrap){var l=i[0].anchor.line,u=i[0].head.line;r.linewise&&u--;var d=e.hardWrap({from:l,to:u});return d>l&&r.linewise&&d--,r.keepCursor?a:new n(d,0)}},toggleComment:function(e,r,i,a,l){return e.execCommand("toggleLineComment"),l},changeCase:function(e,r,i,a,l){for(var u=e.getSelections(),d=[],h=r.toLower,p=0;p<u.length;p++){var v=u[p],y="";if(h===!0)y=v.toLowerCase();else if(h===!1)y=v.toUpperCase();else for(var O=0;O<v.length;O++){var C=v.charAt(O);y+=Oe(C)?C.toLowerCase():C.toUpperCase()}d.push(y)}return e.replaceSelections(d),r.shouldMoveCursor?l:!e.state.vim.visualMode&&r.linewise&&i[0].anchor.line+1==i[0].head.line?Fe.moveToFirstNonWhiteSpaceCharacter(e,a):r.linewise?a:we(i[0].anchor,i[0].head)},yank:function(e,r,i,a){var l=e.state.vim,u=e.getSelection(),d=l.visualMode?we(l.sel.anchor,l.sel.head,i[0].head,i[0].anchor):a;N.registerController.pushText(r.registerName,"yank",u,r.linewise,l.visualBlock);var h=Math.abs(e.getCursor("end").line-e.getCursor("start").line)||1;return X(e,h+" lines yanked"+(r.registerName?' into "'+r.registerName:""),!1,1500),d},rot13:function(e,r,i,a,l){for(var u=e.getSelections(),d=[],h=0;h<u.length;h++){const p=u[h].split("").map(v=>{const y=v.charCodeAt(0);return y>=65&&y<=90?String.fromCharCode(65+(y-65+13)%26):y>=97&&y<=122?String.fromCharCode(97+(y-97+13)%26):v}).join("");d.push(p)}return e.replaceSelections(d),r.shouldMoveCursor?l:!e.state.vim.visualMode&&r.linewise&&i[0].anchor.line+1==i[0].head.line?Fe.moveToFirstNonWhiteSpaceCharacter(e,a):r.linewise?a:we(i[0].anchor,i[0].head)}};function _i(e,r){qt[e]=r}var rt={jumpListWalk:function(e,r,i){if(!i.visualMode){var a=r.repeat||1,l=r.forward,u=N.jumpList,d=u.move(e,l?a:-a),h=d?d.find():void 0;h=h||e.getCursor(),e.setCursor(h)}},scroll:function(e,r,i){if(!i.visualMode){var a=r.repeat||1,l=e.defaultTextHeight(),u=e.getScrollInfo().top,d=l*a,h=r.forward?u+d:u-d,p=ne(e.getCursor()),v=e.charCoords(p,"local");if(r.forward)h>v.top?(p.line+=(h-v.top)/l,p.line=Math.ceil(p.line),e.setCursor(p),v=e.charCoords(p,"local"),e.scrollTo(null,v.top)):e.scrollTo(null,h);else{var y=h+e.getScrollInfo().clientHeight;y<v.bottom?(p.line-=(v.bottom-y)/l,p.line=Math.floor(p.line),e.setCursor(p),v=e.charCoords(p,"local"),e.scrollTo(null,v.bottom-e.getScrollInfo().clientHeight)):e.scrollTo(null,h)}}},scrollToCursor:function(e,r){var i=e.getCursor().line,a=e.charCoords(new n(i,0),"local"),l=e.getScrollInfo().clientHeight,u=a.top;switch(r.position){case"center":u=a.bottom-l/2;break;case"bottom":var d=new n(i,e.getLine(i).length-1),h=e.charCoords(d,"local"),p=h.bottom-u;u=u-l+p;break}e.scrollTo(null,u)},replayMacro:function(e,r,i){var a=r.selectedCharacter||"",l=r.repeat||1,u=N.macroModeState;for(a=="@"?a=u.latestRegister||"":u.latestRegister=a;l--;)So(e,i,u,a)},enterMacroRecordMode:function(e,r){var i=N.macroModeState,a=r.selectedCharacter;N.registerController.isValidRegister(a)&&i.enterMacroRecordMode(e,a)},toggleOverwrite:function(e){e.state.overwrite?(e.toggleOverwrite(!1),e.setOption("keyMap","vim-insert"),t.signal(e,"vim-mode-change",{mode:"insert"})):(e.toggleOverwrite(!0),e.setOption("keyMap","vim-replace"),t.signal(e,"vim-mode-change",{mode:"replace"}))},enterInsertMode:function(e,r,i){if(!e.getOption("readOnly")){i.insertMode=!0,i.insertModeRepeat=r&&r.repeat||1;var a=r?r.insertAt:null,l=i.sel,u=r.head||e.getCursor("head"),d=e.listSelections().length;if(a=="eol")u=new n(u.line,ke(e,u.line));else if(a=="bol")u=new n(u.line,0);else if(a=="charAfter"){var h=o(e,u,de(u,0,1));u=h.end}else if(a=="firstNonBlank"){var h=o(e,u,Fe.moveToFirstNonWhiteSpaceCharacter(e,u));u=h.end}else if(a=="startOfSelectedArea"){if(!i.visualMode)return;i.visualBlock?(u=new n(Math.min(l.head.line,l.anchor.line),Math.min(l.head.ch,l.anchor.ch)),d=Math.abs(l.head.line-l.anchor.line)+1):l.head.line<l.anchor.line?u=l.head:u=new n(l.anchor.line,0)}else if(a=="endOfSelectedArea"){if(!i.visualMode)return;i.visualBlock?(u=new n(Math.min(l.head.line,l.anchor.line),Math.max(l.head.ch,l.anchor.ch)+1),d=Math.abs(l.head.line-l.anchor.line)+1):l.head.line>=l.anchor.line?u=de(l.head,0,1):u=new n(l.anchor.line,0)}else if(a=="inplace"){if(i.visualMode)return}else a=="lastEdit"&&(u=tr(e)||u);e.setOption("disableInput",!1),r&&r.replace?(e.toggleOverwrite(!0),e.setOption("keyMap","vim-replace"),t.signal(e,"vim-mode-change",{mode:"replace"})):(e.toggleOverwrite(!1),e.setOption("keyMap","vim-insert"),t.signal(e,"vim-mode-change",{mode:"insert"})),N.macroModeState.isPlaying||(e.on("change",rr),i.insertEnd&&i.insertEnd.clear(),i.insertEnd=e.setBookmark(u,{insertLeft:!0}),t.on(e.getInputField(),"keydown",ar)),i.visualMode&&Ie(e),Vn(e,u,d)}},toggleVisualMode:function(e,r,i){var a=r.repeat,l=e.getCursor(),u;if(i.visualMode)i.visualLine!=!!r.linewise||i.visualBlock!=!!r.blockwise?(i.visualLine=!!r.linewise,i.visualBlock=!!r.blockwise,t.signal(e,"vim-mode-change",{mode:"visual",subMode:i.visualLine?"linewise":i.visualBlock?"blockwise":""}),lt(e)):Ie(e);else{i.visualMode=!0,i.visualLine=!!r.linewise,i.visualBlock=!!r.blockwise,u=Ce(e,new n(l.line,l.ch+a-1));var d=o(e,l,u);i.sel={anchor:d.start,head:d.end},t.signal(e,"vim-mode-change",{mode:"visual",subMode:i.visualLine?"linewise":i.visualBlock?"blockwise":""}),lt(e),Ue(e,i,"<",we(l,u)),Ue(e,i,">",Ge(l,u))}},reselectLastSelection:function(e,r,i){var a=i.lastSelection;if(i.visualMode&&_n(e,i),a){var l=a.anchorMark.find(),u=a.headMark.find();if(!l||!u)return;i.sel={anchor:l,head:u},i.visualMode=!0,i.visualLine=a.visualLine,i.visualBlock=a.visualBlock,lt(e),Ue(e,i,"<",we(l,u)),Ue(e,i,">",Ge(l,u)),t.signal(e,"vim-mode-change",{mode:"visual",subMode:i.visualLine?"linewise":i.visualBlock?"blockwise":""})}},joinLines:function(e,r,i){var a,l;if(i.visualMode){if(a=e.getCursor("anchor"),l=e.getCursor("head"),se(l,a)){var u=l;l=a,a=u}l.ch=ke(e,l.line)-1}else{var d=Math.max(r.repeat,2);a=e.getCursor(),l=Ce(e,new n(a.line+d-1,1/0))}for(var h=0,p=a.line;p<l.line;p++){h=ke(e,a.line);var v="",y=0;if(!r.keepSpaces){var O=e.getLine(a.line+1);y=O.search(/\S/),y==-1?y=O.length:v=" "}e.replaceRange(v,new n(a.line,h),new n(a.line+1,y))}var C=Ce(e,new n(a.line,h));i.visualMode&&Ie(e,!1),e.setCursor(C)},newLineAndEnterInsertMode:function(e,r,i){i.insertMode=!0;var a=ne(e.getCursor());if(a.line===e.firstLine()&&!r.after)e.replaceRange(`
|
|
10
|
-
`,new n(e.firstLine(),0)),e.setCursor(e.firstLine(),0);else{a.line=r.after?a.line:a.line-1,a.ch=ke(e,a.line),e.setCursor(a);var l=t.commands.newlineAndIndentContinueComment||t.commands.newlineAndIndent;l(e)}this.enterInsertMode(e,{repeat:r.repeat},i)},paste:function(e,r,i){var a=N.registerController.getRegister(r.registerName);if(r.registerName==="+")navigator.clipboard.readText().then(u=>{this.continuePaste(e,r,i,u,a)});else{var l=a.toString();this.continuePaste(e,r,i,l,a)}},continuePaste:function(e,r,i,a,l){var u=ne(e.getCursor());if(a){if(r.matchIndent){var d=e.getOption("tabSize"),h=function(ve){var ye=ve.split(" ").length-1,it=ve.split(" ").length-1;return ye*d+it*1},p=e.getLine(e.getCursor().line),v=h(p.match(/^\s*/)[0]),y=a.replace(/\n$/,""),O=a!==y,C=h(a.match(/^\s*/)[0]),a=y.replace(/^\s*/gm,function(ve){var ye=v+(h(ve)-C);if(ye<0)return"";if(e.getOption("indentWithTabs")){var it=Math.floor(ye/d);return Array(it+1).join(" ")}else return Array(ye+1).join(" ")});a+=O?`
|
|
11
|
-
`:""}r.repeat>1&&(a=Array(r.repeat+1).join(a));var w=r.linewise==null?l.linewise:r.linewise,k=l.blockwise,x=k?a.split(`
|
|
12
|
-
`):void 0;if(x){w&&x.pop();for(var L=0;L<x.length;L++)x[L]=x[L]==""?" ":x[L];u.ch+=r.after?1:0,u.ch=Math.min(ke(e,u.line),u.ch)}else w?i.visualMode?a=i.visualLine?a.slice(0,-1):`
|
|
13
|
-
`+a.slice(0,a.length-1)+`
|
|
14
|
-
`:r.after?(a=`
|
|
15
|
-
`+a.slice(0,a.length-1),u.ch=ke(e,u.line)):u.ch=0:u.ch+=r.after?1:0;var F;if(i.visualMode){i.lastPastedText=a;var D,B=Hi(e),$=B[0],j=B[1],he=e.getSelection(),re=e.listSelections(),ge=new Array(re.length).join("1").split("1");i.lastSelection&&(D=i.lastSelection.headMark.find()),N.registerController.unnamedRegister.setText(he),k?(e.replaceSelections(ge),j=new n($.line+a.length-1,$.ch),e.setCursor($),$n(e,j),e.replaceSelections(a),F=$):i.visualBlock?(e.replaceSelections(ge),e.setCursor($),e.replaceRange(a,$,$),F=$):(e.replaceRange(a,$,j),F=e.posFromIndex(e.indexFromPos($)+a.length-1)),D&&(i.lastSelection.headMark=e.setBookmark(D)),w&&(F.ch=0)}else if(k&&x){e.setCursor(u);for(var L=0;L<x.length;L++){var z=u.line+L;z>e.lastLine()&&e.replaceRange(`
|
|
16
|
-
`,new n(z,0));var V=ke(e,z);V<u.ch&&Ui(e,z,u.ch)}e.setCursor(u),$n(e,new n(u.line+x.length-1,u.ch)),e.replaceSelections(x),F=u}else if(e.replaceRange(a,u),w){var z=r.after?u.line+1:u.line;F=new n(z,$e(e.getLine(z)))}else F=ne(u),/\n/.test(a)||(F.ch+=a.length-(r.after?1:0));i.visualMode&&Ie(e,!1),e.setCursor(F)}},undo:function(e,r){e.operation(function(){Fn(e,t.commands.undo,r.repeat)(),e.setCursor(Ce(e,e.getCursor("start")))})},redo:function(e,r){Fn(e,t.commands.redo,r.repeat)()},setRegister:function(e,r,i){i.inputState.registerName=r.selectedCharacter},insertRegister:function(e,r,i){var a=r.selectedCharacter,l=N.registerController.getRegister(a),u=l&&l.toString();u&&e.replaceSelection(u)},oneNormalCommand:function(e,r,i){Je(e,!0),i.insertModeReturn=!0,t.on(e,"vim-command-done",function a(){i.visualMode||(i.insertModeReturn&&(i.insertModeReturn=!1,i.insertMode||rt.enterInsertMode(e,{},i)),t.off(e,"vim-command-done",a))})},setMark:function(e,r,i){var a=r.selectedCharacter;a&&Ue(e,i,a,e.getCursor())},replace:function(e,r,i){var a=r.selectedCharacter||"",l=e.getCursor(),u,d,h=e.listSelections();if(i.visualMode)l=e.getCursor("start"),d=e.getCursor("end");else{var p=e.getLine(l.line);u=l.ch+r.repeat,u>p.length&&(u=p.length),d=new n(l.line,u)}var v=o(e,l,d);if(l=v.start,d=v.end,a==`
|
|
17
|
-
`)i.visualMode||e.replaceRange("",l,d),(t.commands.newlineAndIndentContinueComment||t.commands.newlineAndIndent)(e);else{var y=e.getRange(l,d);if(y=y.replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,a),y=y.replace(/[^\n]/g,a),i.visualBlock){var O=new Array(e.getOption("tabSize")+1).join(" ");y=e.getSelection(),y=y.replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,a);var C=y.replace(/\t/g,O).replace(/[^\n]/g,a).split(`
|
|
18
|
-
`);e.replaceSelections(C)}else e.replaceRange(y,l,d);i.visualMode?(l=se(h[0].anchor,h[0].head)?h[0].anchor:h[0].head,e.setCursor(l),Ie(e,!1)):e.setCursor(de(d,0,-1))}},incrementNumberToken:function(e,r){for(var i=e.getCursor(),a=e.getLine(i.line),l=/(-?)(?:(0x)([\da-f]+)|(0b|0|)(\d+))/gi,u,d,h,p;(u=l.exec(a))!==null&&(d=u.index,h=d+u[0].length,!(i.ch<h)););if(!(!r.backtrack&&h<=i.ch)){if(u){var v=u[2]||u[4],y=u[3]||u[5],O=r.increase?1:-1,C={"0b":2,0:8,"":10,"0x":16}[v.toLowerCase()],w=parseInt(u[1]+y,C)+O*r.repeat;p=w.toString(C);var k=v?new Array(y.length-p.length+1+u[1].length).join("0"):"";p.charAt(0)==="-"?p="-"+v+k+p.substr(1):p=v+k+p;var x=new n(i.line,d),L=new n(i.line,h);e.replaceRange(p,x,L)}else return;e.setCursor(new n(i.line,d+p.length-1))}},repeatLastEdit:function(e,r,i){var a=i.lastEditInputState;if(a){var l=r.repeat;l&&r.repeatIsExplicit?a.repeatOverride=l:l=a.repeatOverride||l,sr(e,i,l,!1)}},indent:function(e,r){e.indentLine(e.getCursor().line,r.indentRight)},exitInsertMode:function(e,r){Je(e)}};function Qi(e,r){rt[e]=r}function Ce(e,r,i){var a=e.state.vim,l=a.insertMode||a.visualMode,u=Math.min(Math.max(e.firstLine(),r.line),e.lastLine()),d=e.getLine(u),h=d.length-1+ +!!l,p=Math.min(Math.max(0,r.ch),h),v=d.charCodeAt(p);if(56320<=v&&v<=57343){var y=1;i&&i.line==u&&i.ch>p&&(y=-1),p+=y,p>h&&(p-=2)}return new n(u,p)}function Lt(e){var r={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(r[i]=e[i]);return r}function de(e,r,i){return typeof r=="object"&&(i=r.ch,r=r.line),new n(e.line+r,e.ch+i)}function ji(e,r,i,a){a.operator&&(i="operatorPending");for(var l,u=[],d=[],h=Ze?r.length-f:0,p=h;p<r.length;p++){var v=r[p];i=="insert"&&v.context!="insert"||v.context&&v.context!=i||a.operator&&v.type=="action"||!(l=Ki(e,v.keys))||(l=="partial"&&u.push(v),l=="full"&&d.push(v))}return{partial:u,full:d}}function Ki(e,r){const i=r.slice(-11)=="<character>",a=r.slice(-10)=="<register>";if(i||a){var l=r.length-(i?11:10),u=e.slice(0,l),d=r.slice(0,l);return u==d&&e.length>l?"full":d.indexOf(u)==0?"partial":!1}else return e==r?"full":r.indexOf(e)==0?"partial":!1}function qi(e){var r=/^.*(<[^>]+>)$/.exec(e),i=r?r[1]:e.slice(-1);if(i.length>1)switch(i){case"<CR>":case"<S-CR>":i=`
|
|
19
|
-
`;break;case"<Space>":case"<S-Space>":i=" ";break;default:i="";break}return i}function Fn(e,r,i){return function(){for(var a=0;a<i;a++)r(e)}}function ne(e){return new n(e.line,e.ch)}function Ae(e,r){return e.ch==r.ch&&e.line==r.line}function se(e,r){return e.line<r.line||e.line==r.line&&e.ch<r.ch}function we(e,r){return arguments.length>2&&(r=we.apply(void 0,Array.prototype.slice.call(arguments,1))),se(e,r)?e:r}function Ge(e,r){return arguments.length>2&&(r=Ge.apply(void 0,Array.prototype.slice.call(arguments,1))),se(e,r)?r:e}function In(e,r,i){var a=se(e,r),l=se(r,i);return a&&l}function ke(e,r){return e.getLine(r).length}function zt(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}function zi(e){return e.replace(/([.?*+$\[\]\/\\(){}|\-])/g,"\\$1")}function Ui(e,r,i){var a=ke(e,r),l=new Array(i-a+1).join(" ");e.setCursor(new n(r,a)),e.replaceRange(l,e.getCursor())}function $n(e,r){var i=[],a=e.listSelections(),l=ne(e.clipPos(r)),u=!Ae(r,l),d=e.getCursor("head"),h=Xi(a,d),p=Ae(a[h].head,a[h].anchor),v=a.length-1,y=v-h>h?v:0,O=a[y].anchor,C=Math.min(O.line,l.line),w=Math.max(O.line,l.line),k=O.ch,x=l.ch,L=a[y].head.ch-k,F=x-k;L>0&&F<=0?(k++,u||x--):L<0&&F>=0?(k--,p||x++):L<0&&F==-1&&(k--,x++);for(var D=C;D<=w;D++){var B={anchor:new n(D,k),head:new n(D,x)};i.push(B)}return e.setSelections(i),r.ch=x,O.ch=k,O}function Vn(e,r,i){for(var a=[],l=0;l<i;l++){var u=de(r,l,0);a.push({anchor:u,head:u})}e.setSelections(a,0)}function Xi(e,r,i){for(var a=0;a<e.length;a++){var l=Ae(e[a].anchor,r),u=Ae(e[a].head,r);if(l||u)return a}return-1}function Hi(e,r){var i=e.listSelections(),a=i[0],l=i[i.length-1],u=se(a.anchor,a.head)?a.anchor:a.head,d=se(l.anchor,l.head)?l.head:l.anchor;return[u,d]}function _n(e,r){var i=r.sel.anchor,a=r.sel.head;r.lastPastedText&&(a=e.posFromIndex(e.indexFromPos(i)+r.lastPastedText.length),r.lastPastedText=void 0),r.lastSelection={anchorMark:e.setBookmark(i),headMark:e.setBookmark(a),anchor:ne(i),head:ne(a),visualMode:r.visualMode,visualLine:r.visualLine,visualBlock:r.visualBlock}}function Wi(e,r,i,a){var l=e.state.vim.sel,u=a?r:l.head,d=a?r:l.anchor,h;return se(i,r)&&(h=i,i=r,r=h),se(u,d)?(u=we(r,u),d=Ge(d,i)):(d=we(r,d),u=Ge(u,i),u=de(u,0,-1),u.ch==-1&&u.line!=e.firstLine()&&(u=new n(u.line-1,ke(e,u.line-1)))),[d,u]}function lt(e,r,i){var a=e.state.vim;r=r||a.sel,i||(i=a.visualLine?"line":a.visualBlock?"block":"char");var l=Ut(e,r,i);e.setSelections(l.ranges,l.primary)}function Ut(e,r,i,a){var l=ne(r.head),u=ne(r.anchor);if(i=="char"){var d=!a&&!se(r.head,r.anchor)?1:0,h=se(r.head,r.anchor)?1:0;return l=de(r.head,0,d),u=de(r.anchor,0,h),{ranges:[{anchor:u,head:l}],primary:0}}else if(i=="line"){if(se(r.head,r.anchor))l.ch=0,u.ch=ke(e,u.line);else{u.ch=0;var p=e.lastLine();l.line>p&&(l.line=p),l.ch=ke(e,l.line)}return{ranges:[{anchor:u,head:l}],primary:0}}else if(i=="block"){var v=Math.min(u.line,l.line),y=u.ch,O=Math.max(u.line,l.line),C=l.ch;y<C?C+=1:y+=1;for(var w=O-v+1,k=l.line==v?0:w-1,x=[],L=0;L<w;L++)x.push({anchor:new n(v+L,y),head:new n(v+L,C)});return{ranges:x,primary:k}}throw"never happens"}function Zi(e){var r=e.getCursor("head");return e.getSelection().length==1&&(r=we(r,e.getCursor("anchor"))),r}function Ie(e,r){var i=e.state.vim;r!==!1&&e.setCursor(Ce(e,i.sel.head)),_n(e,i),i.visualMode=!1,i.visualLine=!1,i.visualBlock=!1,i.insertMode||t.signal(e,"vim-mode-change",{mode:"normal"})}function Yi(e,r,i){var a=e.getRange(r,i);if(/\n\s*$/.test(a)){var l=a.split(`
|
|
20
|
-
`);l.pop();for(var u=l.pop();l.length>0&&u&&H(u);u=l.pop())i.line--,i.ch=0;u?(i.line--,i.ch=ke(e,i.line)):i.ch=0}}function Gi(e,r,i){r.ch=0,i.ch=0,i.line++}function $e(e){if(!e)return 0;var r=e.search(/\S/);return r==-1?e.length:r}function Xt(e,{inclusive:r,innerWord:i,bigWord:a,noSymbol:l,multiline:u},d){var h=d||Zi(e),p=e.getLine(h.line),v=p,y=h.line,O=y,C=h.ch,w,k=l?P[0]:E[0];if(i&&/\s/.test(p.charAt(C)))k=function($){return/\s/.test($)};else{for(;!k(p.charAt(C));)if(C++,C>=p.length){if(!u)return null;C--,w=qn(e,h,!0,a,!0);break}a?k=E[0]:(k=P[0],k(p.charAt(C))||(k=P[1]))}for(var x=C,L=C;k(p.charAt(L))&&L>=0;)L--;if(L++,w)x=w.to,O=w.line,v=e.getLine(O),!v&&x==0&&x++;else for(;k(p.charAt(x))&&x<p.length;)x++;if(r){var F=x,D=h.ch<=L&&/\s/.test(p.charAt(h.ch));if(!D)for(;/\s/.test(v.charAt(x))&&x<v.length;)x++;if(F==x||D){for(var B=L;/\s/.test(p.charAt(L-1))&&L>0;)L--;!L&&!D&&(L=B)}}return{start:new n(y,L),end:new n(O,x)}}function Ji(e,r,i){var a=r;if(!t.findMatchingTag||!t.findEnclosingTag)return{start:a,end:a};var l=t.findMatchingTag(e,r)||t.findEnclosingTag(e,r);return!l||!l.open||!l.close?{start:a,end:a}:i?{start:l.open.from,end:l.close.to}:{start:l.open.to,end:l.close.from}}function Qn(e,r,i){Ae(r,i)||N.jumpList.add(e,r,i)}function jn(e,r){N.lastCharacterSearch.increment=e,N.lastCharacterSearch.forward=r.forward,N.lastCharacterSearch.selectedCharacter=r.selectedCharacter}var eo={"(":"bracket",")":"bracket","{":"bracket","}":"bracket","[":"section","]":"section","*":"comment","/":"comment",m:"method",M:"method","#":"preprocess"},Kn={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 r=e.lastCh==="*"&&e.nextCh==="/";return e.lastCh=e.nextCh,r}},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 r=e.lineText.match(/^#(\w+)/)?.[1];if(r==="endif"){if(e.forward&&e.depth===0)return!0;e.depth++}else if(r==="if"){if(!e.forward&&e.depth===0)return!0;e.depth--}if(r==="else"&&e.depth===0)return!0}return!1}}};function to(e,r,i,a){var l=ne(e.getCursor()),u=i?1:-1,d=i?e.lineCount():-1,h=l.ch,p=l.line,v=e.getLine(p),y={lineText:v,nextCh:v.charAt(h),lastCh:null,index:h,symb:a,reverseSymb:(i?{")":"(","}":"{"}:{"(":")","{":"}"})[a],forward:i,depth:0,curMoveThrough:!1},O=eo[a];if(!O)return l;var C=Kn[O].init,w=Kn[O].isComplete;for(C&&C(y);p!==d&&r;){if(y.index+=u,y.nextCh=y.lineText.charAt(y.index),!y.nextCh){if(p+=u,y.lineText=e.getLine(p)||"",u>0)y.index=0;else{var k=y.lineText.length;y.index=k>0?k-1:0}y.nextCh=y.lineText.charAt(y.index)}w(y)&&(l.line=p,l.ch=y.index,r--)}return y.nextCh||y.curMoveThrough?new n(p,y.index):l}function qn(e,r,i,a,l){var u=r.line,d=r.ch,h=e.getLine(u),p=i?1:-1,v=a?E:P;if(l&&h==""){if(u+=p,h=e.getLine(u),!ee(e,u))return null;d=i?0:h.length}for(;;){if(l&&h=="")return{from:0,to:0,line:u};for(var y=p>0?h.length:-1,O=y,C=y;d!=y;){for(var w=!1,k=0;k<v.length&&!w;++k)if(v[k](h.charAt(d))){for(O=d;d!=y&&v[k](h.charAt(d));)d+=p;if(C=d,w=O!=C,O==r.ch&&u==r.line&&C==O+p)continue;return{from:Math.min(O,C+1),to:Math.max(O,C),line:u}}w||(d+=p)}if(u+=p,!ee(e,u))return null;h=e.getLine(u),d=p>0?0:h.length}}function no(e,r,i,a,l,u){var d=ne(r),h=[];(a&&!l||!a&&l)&&i++;for(var p=!(a&&l),v=0;v<i;v++){var y=qn(e,r,a,u,p);if(!y){var O=ke(e,e.lastLine());h.push(a?{line:e.lastLine(),from:O,to:O}:{line:0,from:0,to:0});break}h.push(y),r=new n(y.line,a?y.to-1:y.from)}var C=h.length!=i,w=h[0],k=h.pop();return a&&!l?(!C&&(w.from!=d.ch||w.line!=d.line)&&(k=h.pop()),k&&new n(k.line,k.from)):a&&l?k&&new n(k.line,k.to-1):!a&&l?(!C&&(w.to!=d.ch||w.line!=d.line)&&(k=h.pop()),k&&new n(k.line,k.to)):k&&new n(k.line,k.from)}function zn(e,r,i,a,l){var u=r,d=new n(u.line+i.repeat-1,1/0),h=e.clipPos(d);return h.ch--,l||(a.lastHPos=1/0,a.lastHSPos=e.charCoords(h,"div").left),d}function Ht(e,r,i,a,l){if(a){for(var u=l||e.getCursor(),d=u.ch,h,p=0;p<r;p++){var v=e.getLine(u.line);if(h=io(d,v,a,i),h==-1)return;d=h}if(h!=null)return new n(e.getCursor().line,h)}}function ro(e,r){var i=e.getCursor().line;return Ce(e,new n(i,r-1))}function Ue(e,r,i,a){!et(i,T)&&!_.test(i)||(r.marks[i]&&r.marks[i].clear(),r.marks[i]=e.setBookmark(a))}function io(e,r,i,a,l){var u;return a?u=r.indexOf(i,e+1):u=r.lastIndexOf(i,e-1),u}function Un(e,r,i,a,l){var u=r.line,d=e.firstLine(),h=e.lastLine(),p,v,y=u;function O(L){return!e.getLine(L)}function C(L,F,D){return D?O(L)!=O(L+F):!O(L)&&O(L+F)}if(a){for(;d<=y&&y<=h&&i>0;)C(y,a)&&i--,y+=a;return{start:new n(y,0),end:r}}var w=e.state.vim;if(w.visualLine&&C(u,1,!0)){var k=w.sel.anchor;C(k.line,-1,!0)&&(!l||k.line!=u)&&(u+=1)}var x=O(u);for(y=u;y<=h&&i;y++)C(y,1,!0)&&(!l||O(y)!=x)&&i--;for(v=new n(y,0),y>h&&!x?x=!0:l=!1,y=u;y>d&&!((!l||O(y)==x||y==u)&&C(y,-1,!0));y--);return p=new n(y,0),{start:p,end:v}}function Xn(e,r,i,a,l){function u(v){v.line!==null&&(v.pos+v.dir<0||v.pos+v.dir>=v.line.length?v.line=null:v.pos+=v.dir)}function d(v,y,O,C){var w=v.getLine(y),k={line:w,ln:y,pos:O,dir:C};if(k.line==="")return{ln:k.ln,pos:k.pos};var x=k.pos;for(u(k);k.line!==null;){if(x=k.pos,je(k.line[k.pos]))if(l){for(u(k);k.line!==null&&H(k.line[k.pos]);)x=k.pos,u(k);return{ln:k.ln,pos:x+1}}else return{ln:k.ln,pos:k.pos+1};u(k)}return{ln:k.ln,pos:x+1}}function h(v,y,O,C){var w=v.getLine(y),k={line:w,ln:y,pos:O,dir:C};if(k.line==="")return{ln:k.ln,pos:k.pos};var x=k.pos;for(u(k);k.line!==null;){if(!H(k.line[k.pos])&&!je(k.line[k.pos]))x=k.pos;else if(je(k.line[k.pos]))return l?H(k.line[k.pos+1])?{ln:k.ln,pos:k.pos+1}:{ln:k.ln,pos:x}:{ln:k.ln,pos:x};u(k)}return k.line=w,l&&H(k.line[k.pos])?{ln:k.ln,pos:k.pos}:{ln:k.ln,pos:x}}for(var p={ln:r.line,pos:r.ch};i>0;)a<0?p=h(e,p.ln,p.pos,a):p=d(e,p.ln,p.pos,a),i--;return new n(p.ln,p.pos)}function oo(e,r,i,a){function l(p,v){if(v.line!==null)if(v.pos+v.dir<0||v.pos+v.dir>=v.line.length){if(v.ln+=v.dir,!ee(p,v.ln)){v.line=null;return}v.line=p.getLine(v.ln),v.pos=v.dir>0?0:v.line.length-1}else v.pos+=v.dir}function u(p,v,y,O){var L=p.getLine(v),C=L==="",w={line:L,ln:v,pos:y,dir:O},k={ln:w.ln,pos:w.pos},x=w.line==="";for(l(p,w);w.line!==null;){if(k.ln=w.ln,k.pos=w.pos,w.line===""&&!x)return{ln:w.ln,pos:w.pos};if(C&&w.line!==""&&!H(w.line[w.pos]))return{ln:w.ln,pos:w.pos};je(w.line[w.pos])&&!C&&(w.pos===w.line.length-1||H(w.line[w.pos+1]))&&(C=!0),l(p,w)}var L=p.getLine(k.ln);k.pos=0;for(var F=L.length-1;F>=0;--F)if(!H(L[F])){k.pos=F;break}return k}function d(p,v,y,O){var L=p.getLine(v),C={line:L,ln:v,pos:y,dir:O},w=C.ln,k=null,x=C.line==="";for(l(p,C);C.line!==null;){if(C.line===""&&!x)return k!==null?{ln:w,pos:k}:{ln:C.ln,pos:C.pos};if(je(C.line[C.pos])&&k!==null&&!(C.ln===w&&C.pos+1===k))return{ln:w,pos:k};C.line!==""&&!H(C.line[C.pos])&&(x=!1,w=C.ln,k=C.pos),l(p,C)}var L=p.getLine(w);k=0;for(var F=0;F<L.length;++F)if(!H(L[F])){k=F;break}return{ln:w,pos:k}}for(var h={ln:r.line,pos:r.ch};i>0;)a<0?h=d(e,h.ln,h.pos,a):h=u(e,h.ln,h.pos,a),i--;return new n(h.ln,h.pos)}function Hn(e,r,i,a){var l=r,u={"(":/[()]/,")":/[()]/,"[":/[[\]]/,"]":/[[\]]/,"{":/[{}]/,"}":/[{}]/,"<":/[<>]/,">":/[<>]/}[i],d={"(":"(",")":"(","[":"[","]":"[","{":"{","}":"{","<":"<",">":"<"}[i],h=e.getLine(l.line).charAt(l.ch),p=h===d?1:0,v=e.scanForBracket(new n(l.line,l.ch+p),-1,void 0,{bracketRegex:u}),y=e.scanForBracket(new n(l.line,l.ch+p),1,void 0,{bracketRegex:u});if(!v||!y)return null;var O=v.pos,C=y.pos;if(O.line==C.line&&O.ch>C.ch||O.line>C.line){var w=O;O=C,C=w}return a?C.ch+=1:O.ch+=1,{start:O,end:C}}function ao(e,r,i,a){var l=ne(r),u=e.getLine(l.line),d=u.split(""),h,p,v,y,O=d.indexOf(i);if(l.ch<O)l.ch=O;else if(O<l.ch&&d[l.ch]==i){var C=/string/.test(e.getTokenTypeAt(de(r,0,1))),w=/string/.test(e.getTokenTypeAt(r)),k=C&&!w;k||(p=l.ch,--l.ch)}if(d[l.ch]==i&&!p)h=l.ch+1;else for(v=l.ch;v>-1&&!h;v--)d[v]==i&&(h=v+1);if(h&&!p)for(v=h,y=d.length;v<y&&!p;v++)d[v]==i&&(p=v);return!h||!p?{start:l,end:l}:(a&&(--h,++p),{start:new n(l.line,h),end:new n(l.line,p)})}Ke("pcre",!0,"boolean");class so{constructor(){this.highlightTimeout}getQuery(){return N.query}setQuery(r){N.query=r}getOverlay(){return this.searchOverlay}setOverlay(r){this.searchOverlay=r}isReversed(){return N.isReversed}setReversed(r){N.isReversed=r}getScrollbarAnnotate(){return this.annotate}setScrollbarAnnotate(r){this.annotate=r}}function Ne(e){var r=e.state.vim;return r.searchState_||(r.searchState_=new so)}function lo(e){return Wn(e,"/")}function co(e){return Zn(e,"/")}function Wn(e,r){var i=Zn(e,r)||[];if(!i.length)return[];var a=[];if(i[0]===0){for(var l=0;l<i.length;l++)typeof i[l]=="number"&&a.push(e.substring(i[l]+1,i[l+1]));return a}}function Zn(e,r){r||(r="/");for(var i=!1,a=[],l=0;l<e.length;l++){var u=e.charAt(l);!i&&u==r&&a.push(l),i=!i&&u=="\\"}return a}function uo(e){var r={V:"|(){+?*.[$^",M:"|(){+?*.[",m:"|(){+?",v:"<>"},i={">":"(?<=[\\w])(?=[^\\w]|$)","<":"(?<=[^\\w]|^)(?=[\\w])"},a=r.m,l=e.replace(/\\.|[\[|(){+*?.$^<>]/g,function(d){if(d[0]==="\\"){var h=d[1];return h==="}"||a.indexOf(h)!=-1?h:h in r?(a=r[h],""):h in i?i[h]:d}else return a.indexOf(d)!=-1?i[d]||"\\"+d:d}),u=l.indexOf("\\zs");return u!=-1&&(l="(?<="+l.slice(0,u)+")"+l.slice(u+3)),u=l.indexOf("\\ze"),u!=-1&&(l=l.slice(0,u)+"(?="+l.slice(u+3)+")"),l}var Yn={"\\n":`
|
|
21
|
-
`,"\\r":"\r","\\t":" "};function fo(e){for(var r=!1,i=[],a=-1;a<e.length;a++){var l=e.charAt(a)||"",u=e.charAt(a+1)||"";Yn[l+u]?(i.push(Yn[l+u]),a++):r?(i.push(l),r=!1):l==="\\"?(r=!0,le(u)||u==="$"?i.push("$"):u!=="/"&&u!=="\\"&&i.push("\\")):(l==="$"&&i.push("$"),i.push(l),u==="/"&&i.push("\\"))}return i.join("")}var Gn={"\\/":"/","\\\\":"\\","\\n":`
|
|
22
|
-
`,"\\r":"\r","\\t":" ","\\&":"&"};function ho(e){for(var r=new t.StringStream(e),i=[];!r.eol();){for(;r.peek()&&r.peek()!="\\";)i.push(r.next());var a=!1;for(var l in Gn)if(r.match(l,!0)){a=!0,i.push(Gn[l]);break}a||i.push(r.next())}return i.join("")}function Jn(e,r,i){var a=N.registerController.getRegister("/");a.setText(e);var l=co(e),u,d;if(!l.length)u=e;else{u=e.substring(0,l[0]);var h=e.substring(l[0]);d=h.indexOf("i")!=-1}if(!u)return null;be("pcre")||(u=uo(u)),i&&(r=/^[^A-Z]*$/.test(u));var p=new RegExp(u,r||d?"im":"m");return p}function De(e){typeof e=="string"&&(e=document.createElement(e));for(var r=1;r<arguments.length;r++){var i=arguments[r];if(i)if(typeof i!="object"&&(i=document.createTextNode(i)),i.nodeType)e.appendChild(i);else for(var a in i)Object.prototype.hasOwnProperty.call(i,a)&&(a[0]==="$"?e.style[a.slice(1)]=i[a]:typeof i[a]=="function"?e[a]=i[a]:e.setAttribute(a,i[a]))}return e}function X(e,r,i,a){var l=De("div",{$color:"red",$whiteSpace:"pre",class:"cm-vim-message"},r);e.openNotification?i?(l=De("div",{},l,De("div",{},"Press ENTER or type command to continue")),e.state.closeVimNotification&&e.state.closeVimNotification(),e.state.closeVimNotification=e.openNotification(l,{bottom:!0,duration:0})):e.openNotification(l,{bottom:!0,duration:a||15e3}):a||alert(l.innerText)}function po(e,r){return De("div",{$display:"flex",$flex:1},De("span",{$fontFamily:"monospace",$whiteSpace:"pre",$flex:1,$display:"flex"},e,De("input",{type:"text",autocorrect:"off",autocapitalize:"off",spellcheck:"false",$flex:1})),r&&De("span",{$color:"#888"},r))}function Tt(e,r){if(We.length){r.value||(r.value=""),W=r;return}var i=po(r.prefix,r.desc);if(e.openDialog)e.openDialog(i,r.onClose,{onKeyDown:r.onKeyDown,onKeyUp:r.onKeyUp,bottom:!0,selectValueOnOpen:!1,value:r.value});else{var a="";typeof r.prefix!="string"&&r.prefix&&(a+=r.prefix.textContent),r.desc&&(a+=" "+r.desc),r.onClose?.(prompt(a,""))}}function mo(e,r){return e instanceof RegExp&&r instanceof RegExp?e.flags==r.flags&&e.source==r.source:!1}function gt(e,r,i,a){if(r){var l=Ne(e),u=Jn(r,!!i,!!a);if(u)return Wt(e,u),mo(u,l.getQuery())||l.setQuery(u),u}}function go(e){if(e.source.charAt(0)=="^")var r=!0;return{token:function(i){if(r&&!i.sol()){i.skipToEnd();return}var a=i.match(e,!1);if(a)return a[0].length==0?(i.next(),"searching"):!i.sol()&&(i.backUp(1),!e.exec(i.next()+a[0]))?(i.next(),null):(i.match(e),"searching");for(;!i.eol()&&(i.next(),!i.match(e,!1)););},query:e}}var vt=0;function Wt(e,r){clearTimeout(vt);var i=Ne(e);i.highlightTimeout=vt,vt=setTimeout(function(){if(e.state.vim){var a=Ne(e);a.highlightTimeout=void 0;var l=a.getOverlay();(!l||r!=l.query)&&(l&&e.removeOverlay(l),l=go(r),e.addOverlay(l),e.showMatchesOnScrollbar&&(a.getScrollbarAnnotate()&&a.getScrollbarAnnotate().clear(),a.setScrollbarAnnotate(e.showMatchesOnScrollbar(r))),a.setOverlay(l))}},50)}function er(e,r,i,a){return e.operation(function(){a===void 0&&(a=1);for(var l=e.getCursor(),u=e.getSearchCursor(i,l),d=0;d<a;d++){var h=u.find(r);if(d==0&&h&&Ae(u.from(),l)){var p=r?u.from():u.to();h=u.find(r),h&&!h[0]&&Ae(u.from(),p)&&e.getLine(p.line).length==p.ch&&(h=u.find(r))}if(!h&&(u=e.getSearchCursor(i,r?new n(e.lastLine()):new n(e.firstLine(),0)),!u.find(r)))return}return u.from()})}function vo(e,r,i,a,l){return e.operation(function(){a===void 0&&(a=1);var u=e.getCursor(),d=e.getSearchCursor(i,u),h=d.find(!r);!l.visualMode&&h&&Ae(d.from(),u)&&d.find(!r);for(var p=0;p<a;p++)if(h=d.find(r),!h&&(d=e.getSearchCursor(i,r?new n(e.lastLine()):new n(e.firstLine(),0)),!d.find(r)))return;var v=d.from(),y=d.to();return v&&y&&[v,y]})}function ct(e){var r=Ne(e);r.highlightTimeout&&(clearTimeout(r.highlightTimeout),r.highlightTimeout=void 0),e.removeOverlay(Ne(e).getOverlay()),r.setOverlay(null),r.getScrollbarAnnotate()&&(r.getScrollbarAnnotate().clear(),r.setScrollbarAnnotate(null))}function yo(e,r,i){return typeof e!="number"&&(e=e.line),r instanceof Array?et(e,r):typeof i=="number"?e>=r&&e<=i:e==r}function Zt(e){var r=e.getScrollInfo(),i=6,a=10,l=e.coordsChar({left:0,top:i+r.top},"local"),u=r.clientHeight-a+r.top,d=e.coordsChar({left:0,top:u},"local");return{top:l.line,bottom:d.line}}function Rt(e,r,i){if(i=="'"||i=="`")return N.jumpList.find(e,-1)||new n(0,0);if(i==".")return tr(e);var a=r.marks[i];return a&&a.find()}function tr(e){if(e.getLastEditEnd)return e.getLastEditEnd();for(var r=e.doc.history.done,i=r.length;i--;)if(r[i].changes)return ne(r[i].changes[0].to)}class bo{constructor(){this.commandMap_,this.buildCommandMap_()}processCommand(r,i,a){var l=this;r.operation(function(){r.curOp&&(r.curOp.isVimOp=!0),l._processCommand(r,i,a)})}_processCommand(r,i,a){var l=r.state.vim,u=N.registerController.getRegister(":"),d=u.toString(),h=new t.StringStream(i);u.setText(i);var p=a||{};p.input=i;try{this.parseInput_(r,h,p)}catch(O){X(r,O+"");return}l.visualMode&&Ie(r);var v,y;if(!p.commandName)p.line!==void 0&&(y="move");else if(v=this.matchCommand_(p.commandName),v){if(y=v.name,v.excludeFromCommandHistory&&u.setText(d),this.parseCommandArgs_(h,p,v),v.type=="exToKey"){Ye(r,v.toKeys||"",v);return}else if(v.type=="exToEx"){this.processCommand(r,v.toInput||"");return}}if(!y){X(r,'Not an editor command ":'+i+'"');return}try{nr[y](r,p),(!v||!v.possiblyAsync)&&p.callback&&p.callback()}catch(O){throw X(r,O+""),O}}parseInput_(r,i,a){if(i.eatWhile(":"),i.eat("%"))a.line=r.firstLine(),a.lineEnd=r.lastLine();else if(i.eat("*")){var l=r.state.vim.lastSelection,u=l?.anchorMark.find()?.line||0,d=l?.headMark.find()?.line||0;a.line=Math.max(u,d),a.lineEnd=Math.min(u,d)}else a.line=this.parseLineSpec_(r,i),a.line!==void 0&&i.eat(",")&&(a.lineEnd=this.parseLineSpec_(r,i));a.line==null?r.state.vim.visualMode?(a.selectionLine=Rt(r,r.state.vim,"<")?.line,a.selectionLineEnd=Rt(r,r.state.vim,">")?.line):a.selectionLine=r.getCursor().line:(a.selectionLine=a.line,a.selectionLineEnd=a.lineEnd),i.eatSpace();var h=i.match(/^(\w+|!!|@@|[!#&*<=>@~])/);return h?a.commandName=h[1]:a.commandName=(i.match(/.*/)||[""])[0],a}parseLineSpec_(r,i){var a=i.match(/^([\d]+)/);if(a)return this.parseLineSpecOffset_(r,i,parseInt(a[1],10)-1);switch(i.next()){case".":return this.parseLineSpecOffset_(r,i,r.getCursor().line);case"$":return this.parseLineSpecOffset_(r,i,r.lastLine());case"'":var l=i.next()||"",u=Rt(r,r.state.vim,l);if(!u)throw new Error("Mark not set");return this.parseLineSpecOffset_(r,i,u.line);case"-":case"+":case"/":case"?":return i.backUp(1),this.parseLineSpecOffset_(r,i,r.getCursor().line);default:i.backUp(1);return}}parseLineSpecOffset_(r,i,a){for(;;){var l=i.match(/^([\/\?]|\\[\?\/])|([+-]?)(\d*)/);if(!l||!l[0])break;if(l[1]){var u="",d=!l[1].endsWith("?");if(l[1].length==1){var h=i.match(d?/^([^\/\\]|\\\/)*/:/^([^\/\?]|\\\?)*/);i.match(d?/^\/?/:/^\??/),u=h&&h[0]}u||(u=N.registerController.getRegister("/")?.toString()||"");var p=new RegExp(u),v=r.getSearchCursor(p,new n(a+(d?1:0),0));d?v.findNext():v.findPrevious();var y=v.from();if(!y)throw new Error("Pattern not found"+p);a=y.line}else{var O=parseInt(l[2]+(l[3]||"1"),10);a+=O}}return a}parseCommandArgs_(r,i,a){if(!r.eol()){i.argString=r.match(/.*/)?.[0];var l=a.argDelimiter||/\s+/,u=zt(i.argString||"").split(l);u.length&&u[0]&&(i.args=u)}}matchCommand_(r){for(var i=r.length;i>0;i--){var a=r.substring(0,i);if(this.commandMap_[a]){var l=this.commandMap_[a];if(l.name.indexOf(r)===0)return l}}}buildCommandMap_(){this.commandMap_={};for(var r=0;r<m.length;r++){var i=m[r],a=i.shortName||i.name;this.commandMap_[a]=i}}map(r,i,a,l){if(r!=":"&&r.charAt(0)==":"){if(a)throw Error("Mode not supported for ex mappings");var u=r.substring(1);i!=":"&&i.charAt(0)==":"?this.commandMap_[u]={name:u,type:"exToEx",toInput:i.substring(1),user:!0}:this.commandMap_[u]={name:u,type:"exToKey",toKeys:i,user:!0}}else{var d={keys:r,type:"keyToKey",toKeys:i,noremap:!!l};a&&(d.context=a),Yt(d)}}unmap(r,i){if(r!=":"&&r.charAt(0)==":"){if(i)throw Error("Mode not supported for ex mappings");var a=r.substring(1);if(this.commandMap_[a]&&this.commandMap_[a].user)return delete this.commandMap_[a],!0}else for(var l=r,u=0;u<s.length;u++)if(l==s[u].keys&&s[u].context===i)return s.splice(u,1),Co(l),!0}}var nr={colorscheme:function(e,r){if(!r.args||r.args.length<1){X(e,e.getOption("theme"));return}e.setOption("theme",r.args[0])},map:function(e,r,i,a){var l=r.args;if(!l||l.length<2){e&&X(e,"Invalid mapping: "+r.input);return}Se.map(l[0],l[1],i,a)},imap:function(e,r){this.map(e,r,"insert")},nmap:function(e,r){this.map(e,r,"normal")},vmap:function(e,r){this.map(e,r,"visual")},omap:function(e,r){this.map(e,r,"operatorPending")},noremap:function(e,r){this.map(e,r,void 0,!0)},inoremap:function(e,r){this.map(e,r,"insert",!0)},nnoremap:function(e,r){this.map(e,r,"normal",!0)},vnoremap:function(e,r){this.map(e,r,"visual",!0)},onoremap:function(e,r){this.map(e,r,"operatorPending",!0)},unmap:function(e,r,i){var a=r.args;(!a||a.length<1||!Se.unmap(a[0],i))&&e&&X(e,"No such mapping: "+r.input)},mapclear:function(e,r){me.mapclear()},imapclear:function(e,r){me.mapclear("insert")},nmapclear:function(e,r){me.mapclear("normal")},vmapclear:function(e,r){me.mapclear("visual")},omapclear:function(e,r){me.mapclear("operatorPending")},move:function(e,r){nt.processCommand(e,e.state.vim,{keys:"",type:"motion",motion:"moveToLineOrEdgeOfDocument",motionArgs:{forward:!1,explicitRepeat:!0,linewise:!0},repeatOverride:r.line+1})},set:function(e,r){var i=r.args,a=r.setCfg||{};if(!i||i.length<1){e&&X(e,"Invalid mapping: "+r.input);return}var l=i[0].split("="),u=l.shift()||"",d=l.length>0?l.join("="):void 0,h=!1,p=!1;if(u.charAt(u.length-1)=="?"){if(d)throw Error("Trailing characters: "+r.argString);u=u.substring(0,u.length-1),h=!0}else u.charAt(u.length-1)=="!"&&(u=u.substring(0,u.length-1),p=!0);d===void 0&&u.substring(0,2)=="no"&&(u=u.substring(2),d=!1);var v=Te[u]&&Te[u].type=="boolean";if(v&&(p?d=!be(u,e,a):d==null&&(d=!0)),!v&&d===void 0||h){var y=be(u,e,a);y instanceof Error?X(e,y.message):y===!0||y===!1?X(e," "+(y?"":"no")+u):X(e," "+u+"="+y)}else{var O=tt(u,d,e,a);O instanceof Error&&X(e,O.message)}},setlocal:function(e,r){r.setCfg={scope:"local"},this.set(e,r)},setglobal:function(e,r){r.setCfg={scope:"global"},this.set(e,r)},registers:function(e,r){var i=r.args,a=N.registerController.registers,l=`----------Registers----------
|
|
23
|
-
|
|
24
|
-
`;if(i)for(var h=i.join(""),p=0;p<h.length;p++){var u=h.charAt(p);if(N.registerController.isValidRegister(u)){var v=a[u]||new Re;l+='"'+u+" "+v.toString()+`
|
|
25
|
-
`}}else for(var u in a){var d=a[u].toString();d.length&&(l+='"'+u+" "+d+`
|
|
26
|
-
`)}X(e,l,!0)},marks:function(e,r){var i=r.args,a=e.state.vim.marks,l=`-----------Marks-----------
|
|
27
|
-
mark line col
|
|
28
|
-
|
|
29
|
-
`;if(i)for(var h=i.join(""),p=0;p<h.length;p++){var u=h.charAt(p),d=a[u]&&a[u].find();d&&(l+=u+" "+d.line+" "+d.ch+`
|
|
30
|
-
`)}else for(var u in a){var d=a[u]&&a[u].find();d&&(l+=u+" "+d.line+" "+d.ch+`
|
|
31
|
-
`)}X(e,l,!0)},sort:function(e,r){var i,a,l,u,d,h;function p(){if(r.argString){var z=new t.StringStream(r.argString);if(z.eat("!")&&(i=!0),z.eol())return;if(!z.eatSpace())return"Invalid arguments";var V=z.match(/([dinuoxr]+)?\s*(\/.+\/)?\s*/);if(!V||!z.eol())return"Invalid arguments";if(V[1]){h=V[1].indexOf("r")!=-1,a=V[1].indexOf("i")!=-1,l=V[1].indexOf("u")!=-1;var xe=V[1].indexOf("d")!=-1||V[1].indexOf("n")!=-1,ve=V[1].indexOf("x")!=-1,ye=V[1].indexOf("o")!=-1;if(Number(xe)+Number(ve)+Number(ye)>1)return"Invalid arguments";u=xe&&"decimal"||ve&&"hex"||ye&&"octal"}V[2]&&(d=new RegExp(V[2].substr(1,V[2].length-2),a?"i":""))}}var v=p();if(v){X(e,v+": "+r.argString);return}var y=r.line||e.firstLine(),O=r.lineEnd||r.line||e.lastLine();if(y==O)return;var C=new n(y,0),w=new n(O,ke(e,O)),k=e.getRange(C,w).split(`
|
|
32
|
-
`),x=u=="decimal"?/(-?)([\d]+)/:u=="hex"?/(-?)(?:0x)?([0-9a-f]+)/i:u=="octal"?/([0-7]+)/:null,L=u=="decimal"?10:u=="hex"?16:u=="octal"?8:void 0,F=[],D=[];if(u||d)for(var B=0;B<k.length;B++){var $=d?k[B].match(d):null;$&&$.index!=null&&!h&&($[0]=k[B].slice($.index+$[0].length)),$&&$[0]!=""?F.push($):x&&x.exec(k[B])?F.push(k[B]):D.push(k[B])}else D=k;function j(z,V){if(i){var xe;xe=z,z=V,V=xe}a&&(z=z.toLowerCase(),V=V.toLowerCase());var ve=x&&x.exec(z),ye=x&&x.exec(V);if(!ve||!ye)return z<V?-1:1;var it=parseInt((ve[1]+ve[2]).toLowerCase(),L),Jt=parseInt((ye[1]+ye[2]).toLowerCase(),L);return it-Jt}function he(z,V){if(i){var xe;xe=z,z=V,V=xe}return a&&(z[0]=z[0].toLowerCase(),V[0]=V[0].toLowerCase()),z[0]<V[0]?-1:1}if(F.sort(d?he:j),d)for(var B=0;B<F.length;B++)F[B]=F[B].input;else u||D.sort(j);if(k=i?F.concat(D):D.concat(F),l){var re=k,ge;k=[];for(var B=0;B<re.length;B++)re[B]!=ge&&k.push(re[B]),ge=re[B]}e.replaceRange(k.join(`
|
|
33
|
-
`),C,w)},vglobal:function(e,r){this.global(e,r)},normal:function(e,r){var i=!1,a=r.argString;if(a&&a[0]=="!"&&(a=a.slice(1),i=!0),a=a.trimStart(),!a){X(e,"Argument is required.");return}var l=r.line;if(typeof l=="number")for(var u=isNaN(r.lineEnd)?l:r.lineEnd,d=l;d<=u;d++)e.setCursor(d,0),Ye(e,r.argString.trimStart(),{noremap:i}),e.state.vim.insertMode&&Je(e,!0);else Ye(e,r.argString.trimStart(),{noremap:i}),e.state.vim.insertMode&&Je(e,!0)},global:function(e,r){var i=r.argString;if(!i){X(e,"Regular Expression missing from global");return}var a=r.commandName[0]==="v";i[0]==="!"&&r.commandName[0]==="g"&&(a=!0,i=i.slice(1));var l=r.line!==void 0?r.line:e.firstLine(),u=r.lineEnd||r.line||e.lastLine(),d=lo(i),h=i,p="";if(d&&d.length&&(h=d[0],p=d.slice(1,d.length).join("/")),h)try{gt(e,h,!0,!0)}catch{X(e,"Invalid regex: "+h);return}for(var v=Ne(e).getQuery(),y=[],O=l;O<=u;O++){var C=e.getLine(O),w=v.test(C);w!==a&&y.push(p?e.getLineHandle(O):C)}if(!p){X(e,y.join(`
|
|
34
|
-
`));return}var k=0,x=function(){if(k<y.length){var L=y[k++],F=e.getLineNumber(L);if(F==null){x();return}var D=F+1+p;Se.processCommand(e,D,{callback:x})}else e.releaseLineHandles&&e.releaseLineHandles()};x()},substitute:function(e,r){if(!e.getSearchCursor)throw new Error("Search feature not available. Requires searchcursor.js or any other getSearchCursor implementation.");var i=r.argString,a=i?Wn(i,i[0]):[],l="",u="",d,h,p,v=!1,y=!1;if(a&&a.length)l=a[0],be("pcre")&&l!==""&&(l=new RegExp(l).source),u=a[1],u!==void 0&&(be("pcre")?u=ho(u.replace(/([^\\])&/g,"$1$$&")):u=fo(u),N.lastSubstituteReplacePart=u),d=a[2]?a[2].split(" "):[];else if(i&&i.length){X(e,"Substitutions should be of the form :s/pattern/replace/");return}if(d&&(h=d[0],p=parseInt(d[1]),h&&(h.indexOf("c")!=-1&&(v=!0),h.indexOf("g")!=-1&&(y=!0),be("pcre")?l=l+"/"+h:l=l.replace(/\//g,"\\/")+"/"+h)),l)try{gt(e,l,!0,!0)}catch{X(e,"Invalid regex: "+l);return}if(u=u||N.lastSubstituteReplacePart,u===void 0){X(e,"No previous substitute regular expression");return}var O=Ne(e),C=O.getQuery(),w=r.line!==void 0?r.line:e.getCursor().line,k=r.lineEnd||w;w==e.firstLine()&&k==e.lastLine()&&(k=1/0),p&&(w=k,k=w+p-1);var x=Ce(e,new n(w,0)),L=e.getSearchCursor(C,x);ko(e,v,y,w,k,L,C,u,r.callback)},startinsert:function(e,r){Ye(e,r.argString=="!"?"A":"i",{})},redo:t.commands.redo,undo:t.commands.undo,write:function(e){t.commands.save?t.commands.save(e):e.save&&e.save()},nohlsearch:function(e){ct(e)},yank:function(e,r){var i=r.selectionLine,a=isNaN(r.selectionLineEnd)?i:r.selectionLineEnd;if(a<i){var l=a;a=i,i=l}var u=e.getRange(new n(i,0),new n(a+1,0)),d=r.args&&r.args[0]?r.args[0]:"0";N.registerController.pushText(d,"yank",u,!0,!1),X(e,a+1-i+" lines yanked"+(d?' into "'+d:""),!1,1500)},put:function(e,r,i){var a={after:!0,isEdit:!0,matchIndent:!!i,repeat:1,lineWise:!0,registerName:""},l=r.args||[];l[0]=="!"&&(a.after=!1,l.shift()),l[0]&&(a.registerName=l[0]);var u=r.selectionLine;u!=null&&e.setCursor(new n(u,0)),rt.paste(e,a,e.state.vim)},iput:function(e,r){this.put(e,r,!0)},delete:function(e,r){var i=r.selectionLine,a=isNaN(r.selectionLineEnd)?i:r.selectionLineEnd;qt.delete(e,{linewise:!0},[{anchor:new n(i,0),head:new n(a+1,0)}])},join:function(e,r){var i=r.selectionLine,a=isNaN(r.selectionLineEnd)?i:r.selectionLineEnd;e.setCursor(new n(i,0)),rt.joinLines(e,{repeat:a-i},e.state.vim)},delmarks:function(e,r){if(!r.argString||!zt(r.argString)){X(e,"Argument required");return}for(var i=e.state.vim,a=new t.StringStream(zt(r.argString));!a.eol();){a.eatSpace();var l=a.pos;if(!a.match(/[a-zA-Z]/,!1)){X(e,"Invalid argument: "+r.argString.substring(l));return}var u=a.next();if(a.match("-",!0)){if(!a.match(/[a-zA-Z]/,!1)){X(e,"Invalid argument: "+r.argString.substring(l));return}var d=u,h=a.next();if(d&&h&&te(d)==te(h)){var p=d.charCodeAt(0),v=h.charCodeAt(0);if(p>=v){X(e,"Invalid argument: "+r.argString.substring(l));return}for(var y=0;y<=v-p;y++){var O=String.fromCharCode(p+y);delete i.marks[O]}}else{X(e,"Invalid argument: "+d+"-");return}}else u&&delete i.marks[u]}}},Se=new bo;me.defineEx("version","ve",e=>{X(e,"Codemirror-vim version: <DEV>")});function ko(e,r,i,a,l,u,d,h,p){e.state.vim.exMode=!0;var v=!1,y=0,O,C,w;function k(){e.operation(function(){for(;!v;)x(),F();D()})}function x(){var $="",j=u.match||u.pos&&u.pos.match;if(j)$=h.replace(/\$(\d{1,3}|[$&])/g,function(ge,z){if(z=="$")return"$";if(z=="&")return j[0];for(var V=z;parseInt(V)>=j.length&&V.length>0;)V=V.slice(0,V.length-1);return V?j[V]+z.slice(V.length,z.length):ge});else{var he=e.getRange(u.from(),u.to());$=he.replace(d,h)}var re=u.to().line;u.replace($),C=u.to().line,l+=C-re,w=C<re}function L(){var $=O&&ne(u.to()),j=u.findNext();return j&&!j[0]&&$&&Ae(u.from(),$)&&(j=u.findNext()),j&&y++,j}function F(){for(;L()&&yo(u.from(),a,l);)if(!(!i&&u.from().line==C&&!w)){e.scrollIntoView(u.from(),30),e.setSelection(u.from(),u.to()),O=u.from(),v=!1;return}v=!0}function D($){if($&&$(),e.focus(),O){e.setCursor(O);var j=e.state.vim;j.exMode=!1,j.lastHPos=j.lastHSPos=O.ch}p?p():v&&X(e,(y?"Found "+y+" matches":"No matches found")+" for pattern: "+d+(be("pcre")?" (set nopcre to use Vim regexps)":""))}function B($,j,he){t.e_stop($);var re=ce($);switch(re){case"y":x(),F();break;case"n":F();break;case"a":var ge=p;p=void 0,e.operation(k),p=ge;break;case"l":x();case"q":case"<Esc>":case"<C-c>":case"<C-[>":D(he);break}return v&&D(he),!0}if(F(),v){X(e,"No matches for "+d+(be("pcre")?" (set nopcre to use vim regexps)":""));return}if(!r){k(),p&&p();return}Tt(e,{prefix:De("span","replace with ",De("strong",h)," (y/n/a/q/l)"),onKeyDown:B})}function Je(e,r){var i=e.state.vim,a=N.macroModeState,l=N.registerController.getRegister("."),u=a.isPlaying,d=a.lastInsertModeChanges;u||(e.off("change",rr),i.insertEnd&&i.insertEnd.clear(),i.insertEnd=void 0,t.off(e.getInputField(),"keydown",ar)),!u&&i.insertModeRepeat&&i.insertModeRepeat>1&&(sr(e,i,i.insertModeRepeat-1,!0),i.lastEditInputState.repeatOverride=i.insertModeRepeat),delete i.insertModeRepeat,i.insertMode=!1,r||e.setCursor(e.getCursor().line,e.getCursor().ch-1),e.setOption("keyMap","vim"),e.setOption("disableInput",!0),e.toggleOverwrite(!1),l.setText(d.changes.join("")),t.signal(e,"vim-mode-change",{mode:"normal"}),a.isRecording&&Mo(a)}function Yt(e){s.unshift(e),e.keys&&Oo(e.keys)}function Oo(e){e.split(/(<(?:[CSMA]-)*\w+>|.)/i).forEach(function(r){r&&(c[r]||(c[r]=0),c[r]++)})}function Co(e){e.split(/(<(?:[CSMA]-)*\w+>|.)/i).forEach(function(r){c[r]&&c[r]--})}function wo(e,r,i,a,l){var u={keys:e,type:r};u[r]=i,u[r+"Args"]=a;for(var d in l)u[d]=l[d];Yt(u)}Ke("insertModeEscKeysTimeout",200,"number");function So(e,r,i,a){var l=N.registerController.getRegister(a);if(a==":"){l.keyBuffer[0]&&Se.processCommand(e,l.keyBuffer[0]),i.isPlaying=!1;return}var u=l.keyBuffer,d=0;i.isPlaying=!0,i.replaySearchQueries=l.searchQueries.slice(0);for(var h=0;h<u.length;h++)for(var p=u[h],v,y,O=/<(?:[CSMA]-)*\w+>|./gi;v=O.exec(p);)if(y=v[0],me.handleKey(e,y,"macro"),r.insertMode){var C=l.insertModeChanges[d++].changes;N.macroModeState.lastInsertModeChanges.changes=C,cr(e,C,1),Je(e)}i.isPlaying=!1}function xo(e,r){if(!e.isPlaying){var i=e.latestRegister,a=N.registerController.getRegister(i);a&&a.pushText(r)}}function Mo(e){if(!e.isPlaying){var r=e.latestRegister,i=N.registerController.getRegister(r);i&&i.pushInsertModeChanges&&i.pushInsertModeChanges(e.lastInsertModeChanges)}}function Eo(e,r){if(!e.isPlaying){var i=e.latestRegister,a=N.registerController.getRegister(i);a&&a.pushSearchQuery&&a.pushSearchQuery(r)}}function rr(e,r){var i=N.macroModeState,a=i.lastInsertModeChanges;if(!i.isPlaying)for(var l=e.state.vim;r;){if(a.expectCursorActivityForChange=!0,a.ignoreCount>1)a.ignoreCount--;else if(r.origin=="+input"||r.origin=="paste"||r.origin===void 0){var u=e.listSelections().length;u>1&&(a.ignoreCount=u);var d=r.text.join(`
|
|
35
|
-
`);if(a.maybeReset&&(a.changes=[],a.maybeReset=!1),d)if(e.state.overwrite&&!/\n/.test(d))a.changes.push([d]);else{if(d.length>1){var h=l&&l.insertEnd&&l.insertEnd.find(),p=e.getCursor();if(h&&h.line==p.line){var v=h.ch-p.ch;v>0&&v<d.length&&(a.changes.push([d,v]),d="")}}d&&a.changes.push(d)}}r=r.next}}function ir(e){var r=e.state.vim;if(r.insertMode){var i=N.macroModeState;if(i.isPlaying)return;var a=i.lastInsertModeChanges;a.expectCursorActivityForChange?a.expectCursorActivityForChange=!1:(a.maybeReset=!0,r.insertEnd&&r.insertEnd.clear(),r.insertEnd=e.setBookmark(e.getCursor(),{insertLeft:!0}))}else e.curOp?.isVimOp||or(e,r)}function or(e,r){var i=e.getCursor("anchor"),a=e.getCursor("head");if(r.visualMode&&!e.somethingSelected()?Ie(e,!1):!r.visualMode&&!r.insertMode&&e.somethingSelected()&&(r.visualMode=!0,r.visualLine=!1,t.signal(e,"vim-mode-change",{mode:"visual"})),r.visualMode){var l=se(a,i)?0:-1,u=se(a,i)?-1:0;a=de(a,0,l),i=de(i,0,u),r.sel={anchor:i,head:a},Ue(e,r,"<",we(a,i)),Ue(e,r,">",Ge(a,i))}else r.insertMode||(r.lastHPos=e.getCursor().ch)}function ar(e){var r=N.macroModeState,i=r.lastInsertModeChanges,a=t.keyName?t.keyName(e):e.key;a&&(a.indexOf("Delete")!=-1||a.indexOf("Backspace")!=-1)&&(i.maybeReset&&(i.changes=[],i.maybeReset=!1),i.changes.push(new st(a,e)))}function sr(e,r,i,a){var l=N.macroModeState;l.isPlaying=!0;var u=r.lastEditActionCommand,d=r.inputState;function h(){u?nt.processAction(e,r,u):nt.evalInput(e,r)}function p(y){if(l.lastInsertModeChanges.changes.length>0){y=r.lastEditActionCommand?y:1;var O=l.lastInsertModeChanges;cr(e,O.changes,y)}}if(r.inputState=r.lastEditInputState,u&&u.interlaceInsertRepeat)for(var v=0;v<i;v++)h(),p(1);else a||h(),p(i);r.inputState=d,r.insertMode&&!a&&Je(e),l.isPlaying=!1}function lr(e,r){t.lookupKey(r,"vim-insert",function(a){return typeof a=="string"?t.commands[a](e):a(e),!0})}function cr(e,r,i){var a=e.getCursor("head"),l=N.macroModeState.lastInsertModeChanges.visualBlock;l&&(Vn(e,a,l+1),i=e.listSelections().length,e.setCursor(a));for(var u=0;u<i;u++){l&&e.setCursor(de(a,u,0));for(var d=0;d<r.length;d++){var h=r[d];if(h instanceof st)lr(e,h.keyName);else if(typeof h=="string")e.replaceSelection(h);else{var p=e.getCursor(),v=de(p,0,h[0].length-(h[1]||0));e.replaceRange(h[0],p,h[1]?p:v),e.setCursor(v)}}}l&&e.setCursor(de(a,0,1))}function Gt(e){var r=new e.constructor;return Object.keys(e).forEach(function(i){if(i!="insertEnd"){var a=e[i];Array.isArray(a)?a=a.slice():a&&typeof a=="object"&&a.constructor!=Object&&(a=Gt(a)),r[i]=a}}),e.sel&&(r.sel={head:e.sel.head&&ne(e.sel.head),anchor:e.sel.anchor&&ne(e.sel.anchor)}),r}function Lo(e,r,i){var u=qe(e),a=e,l=!1,u=me.maybeInitVimState_(a),d=u.visualBlock||u.wasInVisualBlock;if(a.state.closeVimNotification){var h=a.state.closeVimNotification;if(a.state.closeVimNotification=null,h(),r=="<CR>")return oe(a),!0}var p=a.isInMultiSelectMode();if(u.wasInVisualBlock&&!p?u.wasInVisualBlock=!1:p&&u.visualBlock&&(u.wasInVisualBlock=!0),r=="<Esc>"&&!u.insertMode&&!u.visualMode&&p&&u.status=="<Esc>")oe(a);else if(d||!p||a.inVirtualSelectionMode)l=me.handleKey(a,r,i);else{var v=Gt(u),y=u.inputState.changeQueueList||[];a.operation(function(){a.curOp&&(a.curOp.isVimOp=!0);var O=0;a.forEachSelection(function(){a.state.vim.inputState.changeQueue=y[O];var C=a.getCursor("head"),w=a.getCursor("anchor"),k=se(C,w)?0:-1,x=se(C,w)?-1:0;C=de(C,0,k),w=de(w,0,x),a.state.vim.sel.head=C,a.state.vim.sel.anchor=w,l=me.handleKey(a,r,i),a.virtualSelection&&(y[O]=a.state.vim.inputState.changeQueue,a.state.vim=Gt(v)),O++}),a.curOp?.cursorActivity&&!l&&(a.curOp.cursorActivity=!1),a.state.vim=u,u.inputState.changeQueueList=y,u.inputState.changeQueue=null},!0)}return l&&!u.visualMode&&!u.insertMode&&u.visualMode!=a.somethingSelected()&&or(a,u),l}return pt(),me}function Ee(t,n){var o=n.ch,s=n.line+1;s<1&&(s=1,o=0),s>t.lines&&(s=t.lines,o=Number.MAX_VALUE);var c=t.line(s);return Math.min(c.from+Math.max(0,o),c.to)}function Pe(t,n){let o=t.lineAt(n);return{line:o.number-1,ch:n-o.from}}class _e{constructor(n,o){this.line=n,this.ch=o}}function ai(t,n,o){if(t.addEventListener)t.addEventListener(n,o,!1);else{var s=t._handlers||(t._handlers={});s[n]=(s[n]||[]).concat(o)}}function si(t,n,o){if(t.removeEventListener)t.removeEventListener(n,o,!1);else{var s=t._handlers,c=s&&s[n];if(c){var f=c.indexOf(o);f>-1&&(s[n]=c.slice(0,f).concat(c.slice(f+1)))}}}function li(t,n,...o){var s,c=(s=t._handlers)===null||s===void 0?void 0:s[n];if(c)for(var f=0;f<c.length;++f)c[f](...o)}function gr(t,...n){if(t)for(var o=0;o<t.length;++o)t[o](...n)}let hn;try{hn=new RegExp("[\\w\\p{Alphabetic}\\p{Number}_]","u")}catch{hn=/[\w]/}function yt(t,n){var o=t.cm6;if(!o.state.readOnly){var s="input.type.compose";if(t.curOp&&(t.curOp.lastChange||(s="input.type.compose.start")),n.annotations)try{n.annotations.some(function(c){c.value=="input"&&(c.value=s)})}catch(c){console.error(c)}else n.userEvent=s;return o.dispatch(n)}}function vr(t,n){var o;t.curOp&&(t.curOp.$changeStart=void 0),(n?Uo:Xo)(t.cm6);let s=(o=t.curOp)===null||o===void 0?void 0:o.$changeStart;s!=null&&t.cm6.dispatch({selection:{anchor:s}})}var Na={Left:t=>ut(t.cm6,{key:"Left"},"editor"),Right:t=>ut(t.cm6,{key:"Right"},"editor"),Up:t=>ut(t.cm6,{key:"Up"},"editor"),Down:t=>ut(t.cm6,{key:"Down"},"editor"),Backspace:t=>ut(t.cm6,{key:"Backspace"},"editor"),Delete:t=>ut(t.cm6,{key:"Delete"},"editor")};class K{openDialog(n,o,s){return Ba(this,n,o,s)}openNotification(n,o){return Da(this,n,o)}constructor(n){this.state={},this.marks=Object.create(null),this.$mid=0,this.options={},this._handlers={},this.$lastChangeEndOffset=0,this.virtualSelection=null,this.cm6=n,this.onChange=this.onChange.bind(this),this.onSelectionChange=this.onSelectionChange.bind(this)}on(n,o){ai(this,n,o)}off(n,o){si(this,n,o)}signal(n,o,s){li(this,n,o,s)}indexFromPos(n){return Ee(this.cm6.state.doc,n)}posFromIndex(n){return Pe(this.cm6.state.doc,n)}foldCode(n){let o=this.cm6,s=o.state.selection.ranges,c=this.cm6.state.doc,f=Ee(c,n),m=Le.create([Le.range(f,f)],0).ranges;o.state.selection.ranges=m,Ao(o),o.state.selection.ranges=s}firstLine(){return 0}lastLine(){return this.cm6.state.doc.lines-1}lineCount(){return this.cm6.state.doc.lines}setCursor(n,o){typeof n=="object"&&(o=n.ch,n=n.line);var s=Ee(this.cm6.state.doc,{line:n,ch:o||0});this.cm6.dispatch({selection:{anchor:s}},{scrollIntoView:!this.curOp}),this.curOp&&!this.curOp.isVimOp&&this.onBeforeEndOperation()}getCursor(n){var o=this.cm6.state.selection.main,s=n=="head"||!n?o.head:n=="anchor"?o.anchor:n=="start"?o.from:n=="end"?o.to:null;if(s==null)throw new Error("Invalid cursor type");return this.posFromIndex(s)}listSelections(){var n=this.cm6.state.doc;return this.cm6.state.selection.ranges.map(o=>({anchor:Pe(n,o.anchor),head:Pe(n,o.head)}))}setSelections(n,o){var s=this.cm6.state.doc,c=n.map(f=>{var m=Ee(s,f.head),g=Ee(s,f.anchor);return m==g?Le.cursor(m,1):Le.range(g,m)});this.cm6.dispatch({selection:Le.create(c,o)})}setSelection(n,o,s){this.setSelections([{anchor:n,head:o}],0),s&&s.origin=="*mouse"&&this.onBeforeEndOperation()}getLine(n){var o=this.cm6.state.doc;return n<0||n>=o.lines?"":this.cm6.state.doc.line(n+1).text}getLineHandle(n){return this.$lineHandleChanges||(this.$lineHandleChanges=[]),{row:n,index:this.indexFromPos(new _e(n,0))}}getLineNumber(n){var o=this.$lineHandleChanges;if(!o)return null;for(var s=n.index,c=0;c<o.length;c++)if(s=o[c].changes.mapPos(s,1,Zr.TrackAfter),s==null)return null;var f=this.posFromIndex(s);return f.ch==0?f.line:null}releaseLineHandles(){this.$lineHandleChanges=void 0}getRange(n,o){var s=this.cm6.state.doc;return this.cm6.state.sliceDoc(Ee(s,n),Ee(s,o))}replaceRange(n,o,s,c){s||(s=o);var f=this.cm6.state.doc,m=Ee(f,o),g=Ee(f,s);yt(this,{changes:{from:m,to:g,insert:n}})}replaceSelection(n){yt(this,this.cm6.state.replaceSelection(n))}replaceSelections(n){var o=this.cm6.state.selection.ranges,s=o.map((c,f)=>({from:c.from,to:c.to,insert:n[f]||""}));yt(this,{changes:s})}getSelection(){return this.getSelections().join(`
|
|
36
|
-
`)}getSelections(){var n=this.cm6;return n.state.selection.ranges.map(o=>n.state.sliceDoc(o.from,o.to))}somethingSelected(){return this.cm6.state.selection.ranges.some(n=>!n.empty)}getInputField(){return this.cm6.contentDOM}clipPos(n){var o=this.cm6.state.doc,s=n.ch,c=n.line+1;c<1&&(c=1,s=0),c>o.lines&&(c=o.lines,s=Number.MAX_VALUE);var f=o.line(c);return s=Math.min(Math.max(0,s),f.to-f.from),new _e(c-1,s)}getValue(){return this.cm6.state.doc.toString()}setValue(n){var o=this.cm6;return o.dispatch({changes:{from:0,to:o.state.doc.length,insert:n},selection:Le.range(0,0)})}focus(){return this.cm6.focus()}blur(){return this.cm6.contentDOM.blur()}defaultTextHeight(){return this.cm6.defaultLineHeight}findMatchingBracket(n,o){var s=this.cm6.state,c=Ee(s.doc,n),f=ur(s,c+1,-1);return f&&f.end?{to:Pe(s.doc,f.end.from)}:(f=ur(s,c,1),f&&f.end?{to:Pe(s.doc,f.end.from)}:{to:void 0})}scanForBracket(n,o,s,c){return $a(this,n,o,s,c)}indentLine(n,o){o?this.indentMore():this.indentLess()}indentMore(){Po(this.cm6)}indentLess(){No(this.cm6)}execCommand(n){if(K.commands.hasOwnProperty(n))K.commands[n](this);else if(n=="goLineLeft")Do(this.cm6);else if(n=="goLineRight"){Bo(this.cm6);let o=this.cm6.state,s=o.selection.main.head;s<o.doc.length&&o.sliceDoc(s,s+1)!==`
|
|
37
|
-
`&&Fo(this.cm6)}else console.log(n+" is not implemented")}setBookmark(n,o){var s=o?.insertLeft?1:-1,c=this.indexFromPos(n),f=new Qa(this,c,s);return f}addOverlay({query:n}){let o=new Io({regexp:!0,search:n.source,caseSensitive:!/i/.test(n.flags)});if(o.valid){o.forVim=!0,this.cm6Query=o;let s=ln.of(o);return this.cm6.dispatch({effects:s}),o}}removeOverlay(n){if(!this.cm6Query)return;this.cm6Query.forVim=!1;let o=ln.of(this.cm6Query);this.cm6.dispatch({effects:o})}getSearchCursor(n,o){var s=this,c=null,f=null,m=!1;o.ch==null&&(o.ch=Number.MAX_VALUE);var g=Ee(s.cm6.state.doc,o),b=n.source.replace(/(\\.|{(?:\d+(?:,\d*)?|,\d+)})|[{}]/g,function(E,T){return T||"\\"+E});function S(E,T=0,R=E.length){return new Vo(E,b,{ignoreCase:n.ignoreCase},T,R)}function M(E){var T=s.cm6.state.doc;if(E>T.length)return null;let R=S(T,E).next();return R.done?null:R.value}var A=1e4;function P(E,T){var R=s.cm6.state.doc;for(let _=1;;_++){let U=Math.max(E,T-_*A),ee=S(R,U,T),te=null;for(;!ee.next().done;)te=ee.value;if(te&&(U==E||te.from>U+10))return te;if(U==E)return null}}return{findNext:function(){return this.find(!1)},findPrevious:function(){return this.find(!0)},find:function(E){var T=s.cm6.state.doc;if(E){let R=c?m?c.to-1:c.from:g;c=P(0,R)}else{let R=c?m?c.to+1:c.to:g;c=M(R)}return f=c&&{from:Pe(T,c.from),to:Pe(T,c.to),match:c.match},m=c?c.from==c.to:!1,c&&c.match},from:function(){return f?.from},to:function(){return f?.to},replace:function(E){c&&(yt(s,{changes:{from:c.from,to:c.to,insert:E}}),c.to=c.from+E.length,f&&(f.to=Pe(s.cm6.state.doc,c.to)))},get match(){return f&&f.match}}}findPosV(n,o,s,c){let{cm6:f}=this;const m=f.state.doc;let g=s=="page"?f.dom.clientHeight:0;const b=Ee(m,n);let S=Le.cursor(b,1,void 0,c),M=Math.round(Math.abs(o));for(let P=0;P<M;P++)s=="page"?S=f.moveVertically(S,o>0,g):s=="line"&&(S=f.moveVertically(S,o>0));let A=Pe(m,S.head);return(o<0&&S.head==0&&c!=0&&n.line==0&&n.ch!=0||o>0&&S.head==m.length&&A.ch!=c&&n.line==A.line)&&(A.hitSide=!0),A}charCoords(n,o){var s=this.cm6.contentDOM.getBoundingClientRect(),c=Ee(this.cm6.state.doc,n),f=this.cm6.coordsAtPos(c),m=-s.top;return{left:(f?.left||0)-s.left,top:(f?.top||0)+m,bottom:(f?.bottom||0)+m}}coordsChar(n,o){var s=this.cm6.contentDOM.getBoundingClientRect(),c=this.cm6.posAtCoords({x:n.left+s.left,y:n.top+s.top})||0;return Pe(this.cm6.state.doc,c)}getScrollInfo(){var n=this.cm6.scrollDOM;return{left:n.scrollLeft,top:n.scrollTop,height:n.scrollHeight,width:n.scrollWidth,clientHeight:n.clientHeight,clientWidth:n.clientWidth}}scrollTo(n,o){n!=null&&(this.cm6.scrollDOM.scrollLeft=n),o!=null&&(this.cm6.scrollDOM.scrollTop=o)}scrollIntoView(n,o){if(n){var s=this.indexFromPos(n);this.cm6.dispatch({effects:pe.scrollIntoView(s)})}else this.cm6.dispatch({scrollIntoView:!0,userEvent:"scroll"})}getWrapperElement(){return this.cm6.dom}getMode(){return{name:this.getOption("mode")}}setSize(n,o){this.cm6.dom.style.width=n+4+"px",this.cm6.dom.style.height=o+"px",this.refresh()}refresh(){this.cm6.measure()}destroy(){this.removeOverlay()}getLastEditEnd(){return this.posFromIndex(this.$lastChangeEndOffset)}onChange(n){this.$lineHandleChanges&&this.$lineHandleChanges.push(n);for(let s in this.marks)this.marks[s].update(n.changes);this.virtualSelection&&(this.virtualSelection.ranges=this.virtualSelection.ranges.map(s=>s.map(n.changes)));var o=this.curOp=this.curOp||{};n.changes.iterChanges((s,c,f,m,g)=>{(o.$changeStart==null||o.$changeStart>f)&&(o.$changeStart=f),this.$lastChangeEndOffset=m;var b={text:g.toJSON()};o.lastChange?o.lastChange.next=o.lastChange=b:o.lastChange=o.change=b},!0),o.changeHandlers||(o.changeHandlers=this._handlers.change&&this._handlers.change.slice())}onSelectionChange(){var n=this.curOp=this.curOp||{};n.cursorActivityHandlers||(n.cursorActivityHandlers=this._handlers.cursorActivity&&this._handlers.cursorActivity.slice()),this.curOp.cursorActivity=!0}operation(n,o){this.curOp||(this.curOp={$d:0}),this.curOp.$d++;try{var s=n()}finally{this.curOp&&(this.curOp.$d--,this.curOp.$d||this.onBeforeEndOperation())}return s}onBeforeEndOperation(){var n=this.curOp,o=!1;n&&(n.change&&gr(n.changeHandlers,this,n.change),n&&n.cursorActivity&&(gr(n.cursorActivityHandlers,this,null),n.isVimOp&&(o=!0)),this.curOp=null),o&&this.scrollIntoView()}moveH(n,o){if(o=="char"){var s=this.getCursor();this.setCursor(s.line,s.ch+n)}}setOption(n,o){switch(n){case"keyMap":this.state.keyMap=o;break;case"textwidth":this.state.textwidth=o;break}}getOption(n){switch(n){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(fr)==" ";case"indentUnit":return this.cm6.state.facet(fr).length||2;case"textwidth":return this.state.textwidth;case"keyMap":return this.state.keyMap||"vim"}}toggleOverwrite(n){this.state.overwrite=n}getTokenTypeAt(n){var o,s=this.indexFromPos(n),c=wn(this.cm6.state,s),f=c?.resolve(s),m=((o=f?.type)===null||o===void 0?void 0:o.name)||"";return/comment/i.test(m)?"comment":/string/i.test(m)?"string":""}overWriteSelection(n){var o=this.cm6.state.doc,s=this.cm6.state.selection,c=s.ranges.map(f=>{if(f.empty){var m=f.to<o.length?o.sliceString(f.from,f.to+1):"";if(m&&!/\n/.test(m))return Le.range(f.from,f.to+1)}return f});this.cm6.dispatch({selection:Le.create(c,s.mainIndex)}),this.replaceSelection(n)}isInMultiSelectMode(){return this.cm6.state.selection.ranges.length>1}virtualSelectionMode(){return!!this.virtualSelection}forEachSelection(n){var o=this.cm6.state.selection;this.virtualSelection=Le.create(o.ranges,o.mainIndex);for(var s=0;s<this.virtualSelection.ranges.length;s++){var c=this.virtualSelection.ranges[s];c&&(this.cm6.dispatch({selection:Le.create([c])}),n(),this.virtualSelection.ranges[s]=this.cm6.state.selection.ranges[0])}this.cm6.dispatch({selection:this.virtualSelection}),this.virtualSelection=null}hardWrap(n){return ja(this,n)}}K.isMac=typeof navigator<"u"&&/Mac/.test(navigator.platform);K.Pos=_e;K.StringStream=Qo;K.commands={toggleLineComment:function(t){zo(t.cm6)},cursorCharLeft:function(t){qo(t.cm6)},redo:function(t){vr(t,!1)},undo:function(t){vr(t,!0)},newlineAndIndent:function(t){Ko({state:t.cm6.state,dispatch:n=>yt(t,n)})},indentAuto:function(t){jo(t.cm6)},newlineAndIndentContinueComment:void 0,save:void 0};K.isWordChar=function(t){return hn.test(t)};K.keys=Na;K.addClass=function(t,n){};K.rmClass=function(t,n){};K.e_preventDefault=function(t){t.preventDefault()};K.e_stop=function(t){var n,o;(n=t?.stopPropagation)===null||n===void 0||n.call(t),(o=t?.preventDefault)===null||o===void 0||o.call(t)};K.lookupKey=function(n,o,s){var c=K.keys[n];!c&&/^Arrow/.test(n)&&(c=K.keys[n.slice(5)]),c&&s(c)};K.on=ai;K.off=si;K.signal=li;K.findMatchingTag=Va;K.findEnclosingTag=_a;K.keyName=void 0;function ci(t,n,o){var s=document.createElement("div");return s.appendChild(n),s}function ui(t,n){t.state.currentNotificationClose&&t.state.currentNotificationClose(),t.state.currentNotificationClose=n}function Da(t,n,o){ui(t,g);var s=ci(t,n,o&&o.bottom),c=!1,f,m=o&&typeof o.duration<"u"?o.duration:5e3;function g(){c||(c=!0,clearTimeout(f),s.remove(),di(t,s))}return s.onclick=function(b){b.preventDefault(),g()},fi(t,s),m&&(f=setTimeout(g,m)),g}function fi(t,n){var o=t.state.dialog;t.state.dialog=n,n.style.flex="1",n&&o!==n&&(o&&o.contains(document.activeElement)&&t.focus(),o&&o.parentElement?o.parentElement.replaceChild(n,o):o&&o.remove(),K.signal(t,"dialog"))}function di(t,n){t.state.dialog==n&&(t.state.dialog=null,K.signal(t,"dialog"))}function Ba(t,n,o,s){s||(s={}),ui(t,void 0);var c=ci(t,n,s.bottom),f=!1;fi(t,c);function m(b){if(typeof b=="string")g.value=b;else{if(f)return;f=!0,di(t,c),t.state.dialog||t.focus(),s.onClose&&s.onClose(c)}}var g=c.getElementsByTagName("input")[0];return g&&(s.value&&(g.value=s.value,s.selectValueOnOpen!==!1&&g.select()),s.onInput&&K.on(g,"input",function(b){s.onInput(b,g.value,m)}),s.onKeyUp&&K.on(g,"keyup",function(b){s.onKeyUp(b,g.value,m)}),K.on(g,"keydown",function(b){s&&s.onKeyDown&&s.onKeyDown(b,g.value,m)||(b.keyCode==13&&o&&o(g.value),(b.keyCode==27||s.closeOnEnter!==!1&&b.keyCode==13)&&(g.blur(),K.e_stop(b),m()))}),s.closeOnBlur!==!1&&K.on(g,"blur",function(){setTimeout(function(){document.activeElement!==g&&m()})}),g.focus()),m}var Fa={"(":")>",")":"(<","[":"]>","]":"[<","{":"}>","}":"{<","<":">>",">":"<<"};function Ia(t){return t&&t.bracketRegex||/[(){}[\]]/}function $a(t,n,o,s,c){for(var f=c&&c.maxScanLineLength||1e4,m=c&&c.maxScanLines||1e3,g=[],b=Ia(c),S=o>0?Math.min(n.line+m,t.lastLine()+1):Math.max(t.firstLine()-1,n.line-m),M=n.line;M!=S;M+=o){var A=t.getLine(M);if(A){var P=o>0?0:A.length-1,E=o>0?A.length:-1;if(!(A.length>f))for(M==n.line&&(P=n.ch-(o<0?1:0));P!=E;P+=o){var T=A.charAt(P);if(b.test(T)){var R=Fa[T];if(R&&R.charAt(1)==">"==o>0)g.push(T);else if(g.length)g.pop();else return{pos:new _e(M,P),ch:T}}}}}return M-o==(o>0?t.lastLine():t.firstLine())?!1:null}function Va(t,n){return null}function _a(t,n){var o,s,c=t.cm6.state,f=t.indexFromPos(n);if(f<c.doc.length){var m=c.sliceDoc(f,f+1);m=="<"&&f++}for(var g=wn(c,f),b=g?.resolve(f)||null;b;){if(((o=b.firstChild)===null||o===void 0?void 0:o.type.name)=="OpenTag"&&((s=b.lastChild)===null||s===void 0?void 0:s.type.name)=="CloseTag")return{open:yr(c.doc,b.firstChild),close:yr(c.doc,b.lastChild)};b=b.parent}}function yr(t,n){return{from:Pe(t,n.from),to:Pe(t,n.to)}}class Qa{constructor(n,o,s){this.cm=n,this.id=n.$mid++,this.offset=o,this.assoc=s,n.marks[this.id]=this}clear(){delete this.cm.marks[this.id]}find(){return this.offset==null?null:this.cm.posFromIndex(this.offset)}update(n){this.offset!=null&&(this.offset=n.mapPos(this.offset,this.assoc,Zr.TrackDel))}}function ja(t,n){for(var o,s=n.column||t.getOption("textwidth")||80,c=n.allowMerge!=!1,f=Math.min(n.from,n.to),m=Math.max(n.from,n.to);f<=m;){var g=t.getLine(f);if(g.length>s){var b=T(g,s,5);if(b){var S=(o=/^\s*/.exec(g))===null||o===void 0?void 0:o[0];t.replaceRange(`
|
|
38
|
-
`+S,new _e(f,b.start),new _e(f,b.end))}m++}else if(c&&/\S/.test(g)&&f!=m){var M=t.getLine(f+1);if(M&&/\S/.test(M)){var A=g.replace(/\s+$/,""),P=M.replace(/^\s+/,""),E=A+" "+P,b=T(E,s,5);b&&b.start>A.length||E.length<s?(t.replaceRange(" ",new _e(f,A.length),new _e(f+1,M.length-P.length)),f--,m--):A.length<g.length&&t.replaceRange("",new _e(f,A.length),new _e(f,g.length))}}f++}return f;function T(R,_,U){if(!(R.length<_)){var ee=R.slice(0,_),te=R.slice(_),q=/^(?:(\s+)|(\S+)(\s+))/.exec(te),le=/(?:(\s+)|(\s+)(\S+))$/.exec(ee),Oe=0,H=0;if(le&&!le[2]&&(Oe=_-le[1].length,H=_),q&&!q[2]&&(Oe||(Oe=_),H=_+q[1].length),Oe)return{start:Oe,end:H};if(le&&le[2]&&le.index>U)return{start:le.index,end:le.index+le[2].length};if(q&&q[2])return Oe=_+q[2].length,{start:Oe,end:Oe+q[3].length}}}}let pn=$o||(function(){let t={cursorBlinkRate:1200};return function(){return t}})();class Ka{constructor(n,o,s,c,f,m,g,b,S,M){this.left=n,this.top=o,this.height=s,this.fontFamily=c,this.fontSize=f,this.fontWeight=m,this.color=g,this.className=b,this.letter=S,this.partial=M}draw(){let n=document.createElement("div");return n.className=this.className,this.adjust(n),n}adjust(n){n.style.left=this.left+"px",n.style.top=this.top+"px",n.style.height=this.height+"px",n.style.lineHeight=this.height+"px",n.style.fontFamily=this.fontFamily,n.style.fontSize=this.fontSize,n.style.fontWeight=this.fontWeight,n.style.color=this.partial?"transparent":this.color,n.className=this.className,n.textContent=this.letter}eq(n){return this.left==n.left&&this.top==n.top&&this.height==n.height&&this.fontFamily==n.fontFamily&&this.fontSize==n.fontSize&&this.fontWeight==n.fontWeight&&this.color==n.color&&this.className==n.className&&this.letter==n.letter}}class qa{constructor(n,o){this.view=n,this.rangePieces=[],this.cursors=[],this.cm=o,this.measureReq={read:this.readPos.bind(this),write:this.drawSel.bind(this)},this.cursorLayer=n.scrollDOM.appendChild(document.createElement("div")),this.cursorLayer.className="cm-cursorLayer cm-vimCursorLayer",this.cursorLayer.setAttribute("aria-hidden","true"),n.requestMeasure(this.measureReq),this.setBlinkRate()}setBlinkRate(){let o=pn(this.cm.cm6.state).cursorBlinkRate;this.cursorLayer.style.animationDuration=o+"ms"}update(n){(n.selectionSet||n.geometryChanged||n.viewportChanged)&&(this.view.requestMeasure(this.measureReq),this.cursorLayer.style.animationName=this.cursorLayer.style.animationName=="cm-blink"?"cm-blink2":"cm-blink"),za(n)&&this.setBlinkRate()}scheduleRedraw(){this.view.requestMeasure(this.measureReq)}readPos(){let{state:n}=this.view,o=[];for(let s of n.selection.ranges){let c=s==n.selection.main,f=Wa(this.cm,this.view,s,c);f&&o.push(f)}return{cursors:o}}drawSel({cursors:n}){if(n.length!=this.cursors.length||n.some((o,s)=>!o.eq(this.cursors[s]))){let o=this.cursorLayer.children;if(o.length!==n.length){this.cursorLayer.textContent="";for(const s of n)this.cursorLayer.appendChild(s.draw())}else n.forEach((s,c)=>s.adjust(o[c]));this.cursors=n}}destroy(){this.cursorLayer.remove()}}function za(t){return pn(t.startState)!=pn(t.state)}const Ua={".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"}},Xa=Wr.highest(pe.theme(Ua));function Ha(t){let n=t.scrollDOM.getBoundingClientRect();return{left:(t.textDirection==_o.LTR?n.left:n.right-t.scrollDOM.clientWidth)-t.scrollDOM.scrollLeft*t.scaleX,top:n.top-t.scrollDOM.scrollTop*t.scaleY}}function Wa(t,n,o,s){var c,f,m,g;let b=o.head,S=!1,M=1,A=t.state.vim;if(A&&(!A.insertMode||t.state.overwrite)){if(S=!0,A.visualBlock&&!s)return null;o.anchor<o.head&&(b<n.state.doc.length&&n.state.sliceDoc(b,b+1))!=`
|
|
39
|
-
`&&b--,t.state.overwrite?M=.2:A.status&&(M=.5)}if(S){let E=b<n.state.doc.length&&n.state.sliceDoc(b,b+1);E&&/[\uDC00-\uDFFF]/.test(E)&&b>1&&(b--,E=n.state.sliceDoc(b,b+1));let T=n.coordsAtPos(b,1);if(!T)return null;let R=Ha(n),_=n.domAtPos(b),U=_?_.node:n.contentDOM;for(U instanceof Text&&_.offset>=U.data.length&&!((c=U.parentElement)===null||c===void 0)&&c.nextSibling&&(U=(f=U.parentElement)===null||f===void 0?void 0:f.nextSibling,_={node:U,offset:0});_&&_.node instanceof HTMLElement;)U=_.node,_={node:_.node.childNodes[_.offset],offset:0};if(!(U instanceof HTMLElement)){if(!U.parentNode)return null;U=U.parentNode}let ee=getComputedStyle(U),te=T.left,q=(g=(m=n).coordsForChar)===null||g===void 0?void 0:g.call(m,b);if(q&&(te=q.left),!E||E==`
|
|
40
|
-
`||E=="\r")E=" ";else if(E==" "){E=" ";var P=n.coordsAtPos(b+1,-1);P&&(te=P.left-(P.left-T.left)/parseInt(ee.tabSize))}else/[\uD800-\uDBFF]/.test(E)&&b<n.state.doc.length-1&&(E+=n.state.sliceDoc(b+1,b+2));let le=T.bottom-T.top;return new Ka((te-R.left)/n.scaleX,(T.top-R.top+le*(1-M))/n.scaleY,le*M/n.scaleY,ee.fontFamily,ee.fontSize,ee.fontWeight,ee.color,s?"cm-fat-cursor cm-cursor-primary":"cm-fat-cursor cm-cursor-secondary",E,M!=1)}else return null}var Za=typeof navigator<"u"&&/linux/i.test(navigator.platform)&&/ Gecko\/\d+/.exec(navigator.userAgent);const Be=Pa(K),Ya=250,Ga=pe.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"}}),Ja=dt.fromClass(class{constructor(t){this.status="",this.query=null,this.decorations=J.none,this.waitForCopy=!1,this.lastKeydown="",this.useNextTextInput=!1,this.compositionText="",this.view=t;const n=this.cm=new K(t);Be.enterVimMode(this.cm),this.view.cm=this.cm,this.cm.state.vimPlugin=this,this.blockCursor=new qa(t,n),this.updateClass(),this.cm.on("vim-command-done",()=>{n.state.vim&&(n.state.vim.status=""),this.blockCursor.scheduleRedraw(),this.updateStatus()}),this.cm.on("vim-mode-change",o=>{n.state.vim&&(n.state.vim.mode=o.mode,o.subMode&&(n.state.vim.mode+=o.subMode==="linewise"?" line":" block"),n.state.vim.status="",this.blockCursor.scheduleRedraw(),this.updateClass(),this.updateStatus())}),this.cm.on("dialog",()=>{this.cm.state.statusbar?this.updateStatus():t.dispatch({effects:hi.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=o=>{Be.handleKey(this.cm,"<Esc>","user"),this.cm.focus()},this.statusButton.style.cssText="cursor: pointer"}update(t){var n;if((t.viewportChanged||t.docChanged)&&this.query&&this.highlight(this.query),t.docChanged&&this.cm.onChange(t),t.selectionSet&&this.cm.onSelectionChange(),t.viewportChanged,this.cm.curOp&&!this.cm.curOp.isVimOp&&this.cm.onBeforeEndOperation(),t.transactions){for(let o of t.transactions)for(let s of o.effects)if(s.is(ln))if(!((n=s.value)===null||n===void 0?void 0:n.forVim))this.highlight(null);else{let f=s.value.create();this.highlight(f)}}this.blockCursor.update(t)}updateClass(){const t=this.cm.state;!t.vim||t.vim.insertMode&&!t.overwrite?this.view.scrollDOM.classList.remove("cm-vimMode"):this.view.scrollDOM.classList.add("cm-vimMode")}updateStatus(){let t=this.cm.state.statusbar,n=this.cm.state.vim;if(!t||!n)return;let o=this.cm.state.dialog;if(o)o.parentElement!=t&&(t.textContent="",t.appendChild(o));else{t.textContent="";var s=(n.mode||"normal").toUpperCase();n.insertModeReturn&&(s+="(C-O)"),this.statusButton.textContent=`--${s}--`,t.appendChild(this.statusButton),t.appendChild(this.spacer)}this.dom.textContent=n.status,t.appendChild(this.dom)}destroy(){Be.leaveVimMode(this.cm),this.updateClass(),this.blockCursor.destroy(),delete this.view.cm}highlight(t){if(this.query=t,!t)return this.decorations=J.none;let{view:n}=this,o=new Ro;for(let s=0,c=n.visibleRanges,f=c.length;s<f;s++){let{from:m,to:g}=c[s];for(;s<f-1&&g>c[s+1].from-2*Ya;)g=c[++s].to;t.highlight(n.state,m,g,(b,S)=>{o.add(b,S,ts)})}return this.decorations=o.finish()}handleKey(t,n){const o=this.cm;let s=o.state.vim;if(!s)return;const c=Be.vimKeyFromEvent(t,s);if(K.signal(this.cm,"inputEvent",{type:"handleKey",key:c}),!c)return;if(c=="<Esc>"&&!s.insertMode&&!s.visualMode&&this.query){const g=s.searchState_;g&&(o.removeOverlay(g.getOverlay()),g.setOverlay(null))}if(c==="<C-c>"&&!K.isMac&&o.somethingSelected())return this.waitForCopy=!0,!0;s.status=(s.status||"")+c;let m=Be.multiSelectHandleKey(o,c,"user");return s=Be.maybeInitVimState_(o),!m&&s.insertMode&&o.state.overwrite&&(t.key&&t.key.length==1&&!/\n/.test(t.key)?(m=!0,o.overWriteSelection(t.key)):t.key=="Backspace"&&(m=!0,K.commands.cursorCharLeft(o))),m&&(K.signal(this.cm,"vim-keypress",c),t.preventDefault(),t.stopPropagation(),this.blockCursor.scheduleRedraw()),this.updateStatus(),!!m}},{eventHandlers:{copy:function(t,n){this.waitForCopy&&(this.waitForCopy=!1,Promise.resolve().then(()=>{var o=this.cm,s=o.state.vim;s&&(s.insertMode?o.setSelection(o.getCursor(),o.getCursor()):o.operation(()=>{o.curOp&&(o.curOp.isVimOp=!0),Be.handleKey(o,"<Esc>","user")}))}))},compositionstart:function(t,n){this.useNextTextInput=!0,K.signal(this.cm,"inputEvent",t)},compositionupdate:function(t,n){K.signal(this.cm,"inputEvent",t)},compositionend:function(t,n){K.signal(this.cm,"inputEvent",t)},keypress:function(t,n){K.signal(this.cm,"inputEvent",t),this.lastKeydown=="Dead"&&this.handleKey(t,n)},keydown:function(t,n){K.signal(this.cm,"inputEvent",t),this.lastKeydown=t.key,this.lastKeydown=="Unidentified"||this.lastKeydown=="Process"||this.lastKeydown=="Dead"?this.useNextTextInput=!0:(this.useNextTextInput=!1,this.handleKey(t,n))}},provide:()=>[pe.inputHandler.of((t,n,o,s)=>{var c,f,m=pi(t);if(!m)return!1;var g=(c=m.state)===null||c===void 0?void 0:c.vim,b=m.state.vimPlugin;if(g&&!g.insertMode&&!(!((f=m.curOp)===null||f===void 0)&&f.isVimOp)){if(s==="\0\0")return!0;if(K.signal(m,"inputEvent",{type:"text",text:s,from:n,to:o}),s.length==1&&b.useNextTextInput){if(g.expectLiteralNext&&t.composing)return b.compositionText=s,!1;if(b.compositionText){var S=b.compositionText;b.compositionText="";var M=t.state.selection.main.head,A=t.state.sliceDoc(M-S.length,M);if(S===A){var P=m.getCursor();m.replaceRange("",m.posFromIndex(M-S.length),P)}}return b.handleKey({key:s,preventDefault:()=>{},stopPropagation:()=>{}}),es(t),!0}}return!1})],decorations:t=>t.decorations});function es(t){var n=t.scrollDOM.parentElement;if(n){if(Za){t.contentDOM.textContent="\0\0",t.contentDOM.dispatchEvent(new CustomEvent("compositionend"));return}var o=t.scrollDOM.nextSibling,s=window.getSelection(),c=s&&{anchorNode:s.anchorNode,anchorOffset:s.anchorOffset,focusNode:s.focusNode,focusOffset:s.focusOffset};t.scrollDOM.remove(),n.insertBefore(t.scrollDOM,o);try{c&&s&&(s.setPosition(c.anchorNode,c.anchorOffset),c.focusNode&&s.extend(c.focusNode,c.focusOffset))}catch(f){console.error(f)}t.focus(),t.contentDOM.dispatchEvent(new CustomEvent("compositionend"))}}const ts=J.mark({class:"cm-searchMatch"}),hi=It.define(),ns=Ct.define({create:()=>!1,update(t,n){for(let o of n.effects)o.is(hi)&&(t=o.value);return t},provide:t=>Hr.from(t,n=>n?rs:null)});function rs(t){let n=document.createElement("div");n.className="cm-vim-panel";let o=t.cm;return o.state.dialog&&n.appendChild(o.state.dialog),{top:!1,dom:n}}function is(t){let n=document.createElement("div");n.className="cm-vim-panel";let o=t.cm;return o.state.statusbar=n,o.state.vimPlugin.updateStatus(),{dom:n}}function br(t={}){return[Ga,Ja,Xa,t.status?Hr.of(is):ns]}function pi(t){return t.cm||null}class Tn{constructor(n,o){this.yanchor=n,this.yhead=o}toJSON(){return{yanchor:hr(this.yanchor),yhead:hr(this.yhead)}}static fromJSON(n){return new Tn(bt(n.yanchor),bt(n.yhead))}}class os{constructor(n,o){this.ytext=n,this.awareness=o,this.undoManager=new ni(n)}toYPos(n,o=0){return un(this.ytext,n,o)}fromYPos(n){const o=fn(bt(n),this.ytext.doc);if(o==null||o.type!==this.ytext)throw new Error("[y-codemirror] The position you want to retrieve was created by a different document");return{pos:o.index,assoc:o.assoc}}toYRange(n){const o=n.assoc,s=this.toYPos(n.anchor,o),c=this.toYPos(n.head,o);return new Tn(s,c)}fromYRange(n){const o=this.fromYPos(n.yanchor),s=this.fromYPos(n.yhead);return o.pos===s.pos?Le.cursor(s.pos,s.assoc):Le.range(o.pos,s.pos)}}const Qt=$t.define({combine(t){return t[t.length-1]}}),mn=Sn.define();class as{constructor(n){this.view=n,this.conf=n.state.facet(Qt),this._observer=(o,s)=>{if(s.origin!==this.conf){const c=o.delta,f=[];let m=0;for(let g=0;g<c.length;g++){const b=c[g];b.insert!=null?f.push({from:m,to:m,insert:b.insert}):b.delete!=null?(f.push({from:m,to:m+b.delete,insert:""}),m+=b.delete):m+=b.retain}n.dispatch({changes:f,annotations:[mn.of(this.conf)]})}},this._ytext=this.conf.ytext,this._ytext.observe(this._observer)}update(n){if(!n.docChanged||n.transactions.length>0&&n.transactions[0].annotation(mn)===this.conf)return;const o=this.conf.ytext;o.doc.transact(()=>{let s=0;n.changes.iterChanges((c,f,m,g,b)=>{const S=b.sliceString(0,b.length,`
|
|
41
|
-
`);c!==f&&o.delete(c+s,f-c),S.length>0&&o.insert(c+s,S),s+=S.length-(f-c)})},this.conf)}destroy(){this._ytext.unobserve(this._observer)}}const ss=dt.fromClass(as),ls=pe.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"}}),cs=Sn.define();class us extends Yr{constructor(n,o){super(),this.color=n,this.name=o}toDOM(){return tn("span",[Nt("class","cm-ySelectionCaret"),Nt("style",`background-color: ${this.color}; border-color: ${this.color}`)],[Pt(""),tn("div",[Nt("class","cm-ySelectionCaretDot")]),Pt(""),tn("div",[Nt("class","cm-ySelectionInfo")],[Pt(this.name)]),Pt("")])}eq(n){return n.color===this.color}compare(n){return n.color===this.color}updateDOM(){return!1}get estimatedHeight(){return-1}ignoreEvent(){return!0}}class fs{constructor(n){this.conf=n.state.facet(Qt),this._listener=({added:o,updated:s,removed:c},f,m)=>{o.concat(s).concat(c).findIndex(b=>b!==this.conf.awareness.doc.clientID)>=0&&n.dispatch({annotations:[cs.of([])]})},this._awareness=this.conf.awareness,this._awareness.on("change",this._listener),this.decorations=cn.of([])}destroy(){this._awareness.off("change",this._listener)}update(n){const o=this.conf.ytext,s=o.doc,c=this.conf.awareness,f=[],m=this.conf.awareness.getLocalState();if(m!=null){const g=n.view.hasFocus&&n.view.dom.ownerDocument.hasFocus(),b=g?n.state.selection.main:null,S=m.cursor==null?null:bt(m.cursor.anchor),M=m.cursor==null?null:bt(m.cursor.head);if(b!=null){const A=un(o,b.anchor),P=un(o,b.head);(m.cursor==null||!pr(S,A)||!pr(M,P))&&c.setLocalStateField("cursor",{anchor:A,head:P})}else m.cursor!=null&&g&&c.setLocalStateField("cursor",null)}c.getStates().forEach((g,b)=>{if(b===c.doc.clientID)return;const S=g.cursor;if(S==null||S.anchor==null||S.head==null)return;const M=fn(S.anchor,s),A=fn(S.head,s);if(M==null||A==null||M.type!==o||A.type!==o)return;const{color:P="#30bced",name:E="Anonymous"}=g.user||{},T=g.user&&g.user.colorLight||P+"33",R=Ea(M.index,A.index),_=La(M.index,A.index),U=n.view.state.doc.lineAt(R),ee=n.view.state.doc.lineAt(_);if(U.number===ee.number)f.push({from:R,to:_,value:J.mark({attributes:{style:`background-color: ${T}`},class:"cm-ySelection"})});else{f.push({from:R,to:U.from+U.length,value:J.mark({attributes:{style:`background-color: ${T}`},class:"cm-ySelection"})}),f.push({from:ee.from,to:_,value:J.mark({attributes:{style:`background-color: ${T}`},class:"cm-ySelection"})});for(let te=U.number+1;te<ee.number;te++){const q=n.view.state.doc.line(te).from;f.push({from:q,to:q,value:J.line({attributes:{style:`background-color: ${T}`,class:"cm-yLineSelection"}})})}}f.push({from:A.index,to:A.index,value:J.widget({side:A.index-M.index>0?-1:1,block:!1,widget:new us(P,E)})})}),this.decorations=J.set(f,!0)}}const ds=dt.fromClass(fs,{decorations:t=>t.decorations}),hs=()=>{let t=!0;return(n,o)=>{if(t){t=!1;try{n()}finally{t=!0}}else o!==void 0&&o()}};class ps{constructor(n){this.undoManager=n}addTrackedOrigin(n){this.undoManager.addTrackedOrigin(n)}removeTrackedOrigin(n){this.undoManager.removeTrackedOrigin(n)}undo(){return this.undoManager.undo()!=null}redo(){return this.undoManager.redo()!=null}}const jt=$t.define({combine(t){return t[t.length-1]}});class ms{constructor(n){this.view=n,this.conf=n.state.facet(jt),this._undoManager=this.conf.undoManager,this.syncConf=n.state.facet(Qt),this._beforeChangeSelection=null,this._mux=hs(),this._onStackItemAdded=({stackItem:o,changedParentTypes:s})=>{s.has(this.syncConf.ytext)&&this._beforeChangeSelection&&!o.meta.has(this)&&o.meta.set(this,this._beforeChangeSelection)},this._onStackItemPopped=({stackItem:o})=>{const s=o.meta.get(this);if(s){const c=this.syncConf.fromYRange(s);n.dispatch(n.state.update({selection:c,effects:[pe.scrollIntoView(c)]})),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(n){n.selectionSet&&(n.transactions.length===0||n.transactions[0].annotation(mn)!==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 gs=dt.fromClass(ms),mi=({state:t,dispatch:n})=>t.facet(jt).undo()||!0,gn=({state:t,dispatch:n})=>t.facet(jt).redo()||!0,vs=[{key:"Mod-z",run:mi,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:gn,preventDefault:!0},{key:"Mod-Shift-z",run:gn,preventDefault:!0}],ys=(t,n,{undoManager:o=new ni(t)}={})=>{const s=new os(t,n),c=[Qt.of(s),ss];return n&&c.push(ls,ds),o!==!1&&c.push(jt.of(new ps(o)),gs,pe.domEventHandlers({beforeinput(f,m){return f.inputType==="historyUndo"?mi(m):f.inputType==="historyRedo"?gn(m):!1}})),c};function bs(t,n){if(!n.valid||!n.search)return 0;let o=0;const s=n.getCursor(t);for(;!s.next().done;)o+=1;return o}function ks(t){return JSON.stringify([t.search,t.caseSensitive,t.literal,t.regexp,t.wholeWord])}const Os=new Set(["ENTRY","EXECUTE","FUNCTION","INTEGERS","ITERATE","MACRO","READ","REVERSE","SORT","STRINGS"]),Cs=new Set(["add.period$","call.type$","change.case$","chr.to.int$","cite$","duplicate$","empty$","format.name$","if$","int.to.chr$","int.to.str$","missing$","newline$","num.names$","pop$","preamble$","purify$","quote$","skip$","stack$","substring$","swap$","text.length$","text.prefix$","top$","type$","warning$","while$","width$","write$"]);function ws(t){for(;!t.eol()&&t.next()!=='"';);return"string"}const Ss={name:"bibtex-style",startState(){return{}},languageData:{commentTokens:{line:"%"},closeBrackets:{brackets:["{","(","[",'"']}},token(t,n){if(t.eatSpace())return null;const o=t.peek();if(o==="%")return t.skipToEnd(),"comment";if(o==='"')return t.next(),ws(t);if(o&&"{}[]()".includes(o))return t.next(),"bracket";if(t.match(/#-?\d+/))return"number";if(o==="'")return t.next(),"operator";if(t.match(/:=|[=<>+*/-]/))return"operator";if(o&&/[A-Za-z]/.test(o)){t.eatWhile(/[A-Za-z0-9_.$:-]/);const s=t.current();return Os.has(s.toUpperCase())?"keyword":Cs.has(s.toLowerCase())?"builtin":"variable"}return t.next(),null}},xs=Gr.define(Ss),Ms=1,Es=2,Ls=3;function kr(t){switch(t.toLowerCase()){case"@string":return Ms;case"@preamble":return Es;case"@comment":return Ls;default:return-1}}const Ts=Ho.deserialize({version:14,states:"-nQYQPOOOhQPO'#CbOhQPO'#CrOpQPO'#CsOhQPO'#C{OOQO'#D['#D[OOQO'#DQ'#DQQYQPOOOOQO'#Cc'#CcOOQO'#Cp'#CpOxQPO,58|OxQPO,58|O}QPO,59^O}QPO,59^OOOO'#Cu'#CuO!]OQO'#CtOOOO'#Cx'#CxO!kOSO'#CwOOQO,59_,59_O!yQWO,59gO!yQWO,59gOOQO-E7O-E7OOOQO'#Cd'#CdO#OQPO1G.hO#TQPO1G.hO#YOQO'#CgO#kO`O'#CkOOQO'#Cm'#CmOOQO'#Cf'#CfO#|QPO'#CeO$[QPO1G.xO$aQPO1G.xOOOO'#Dh'#DhOOOO'#DU'#DUO!]OQO,59`OOQO'#Cv'#CvOOQO,59`,59`O$fOSO'#CyOOOO'#Di'#DiOOOO'#DV'#DVO!kOSO,59cOOQO'#Cz'#CzOOQO,59c,59cOOQO'#C}'#C}O$tQPO1G/RO$|QPO1G/RO}QPO7+$SO}QPO7+$SO%UOQO'#ChOOOO'#D`'#D`OOOO'#DR'#DRO%gOQO,59ROOQO,59R,59ROOOO'#Dd'#DdOOOO'#DS'#DSO%xO`O,59VOOQO,59V,59VO}QPO'#DTO&ZQPO,59POOQO'#Co'#CoOOQO7+$d7+$dOOQO'#Cq'#CqOOOO-E7S-E7SOOQO1G.z1G.zOOOO,59e,59eO&iOSO,59eOOOO-E7T-E7TOOQO1G.}1G.}O&wQPO7+$mO'PQPO7+$mOOQO7+$m7+$mO'XQPO7+$mO'aQPO7+$mO$[QPO<<GnO$aQPO<<GnOOOO,59S,59SO'iOQO,59SOOOO-E7P-E7POOQO1G.m1G.mOOOO-E7Q-E7QOOQO1G.q1G.qOOQO,59o,59oOOQO-E7R-E7ROOOO1G/P1G/POOQO'#DP'#DPO'zQPO'#DOOOQO,59r,59rOOQO<<HX<<HXO&wQPO<<HXOOQO-E7U-E7UO'XQPO<<HXOOQOAN=YAN=YOOOO1G.n1G.nO}QPO,59jOOQOAN=sAN=sP(PQPO'#DWOOQO1G/U1G/U",stateData:"([~O}OSSOS~OPPOQQORROpSO~O!PWO!YXO~O!P^O!Y`O~O!QfO~O`lO!PiO!QkO!VjO~O^pO!PiO!TsO!UpO~O^vO!YuO!ZyO!^vO~O!_{O~O!R!OO~O!R!PO~O]!RO^!RO!P!QO!T!UO!U!RO~O]!VO^!VO!P!QO!V!YO!X!VO~Ob!ZO!TXX!ZXX!`XX~O!T!]O~O!Z!_O~O^vO!YuO!Z!bO!^vO~O!T!]O!`!fO~O!Z!_O!`!iO~O]!RO^!RO!P!QO!T!mO!U!RO~O]!RO^!RO!P!QO!T!pO!U!RO~O]!VO^!VO!P!QO!V!rO!X!VO~Ob!ZO!TXa!ZXa!`Xa~O^vO!YuO!Z!uO!^vO~O!Q!vO!T!]O~O!T!]O!`!zO~O!Q!vO!Z!_O~O!Z!_O!`!|O~O]!RO^!RO!P!QO!T#OO!U!RO~O!R#PO~O!Q!vO~O]^!U!X!U~",goto:"'i!^PPPPPP!_!c!l!r#R#]#iPP#sP#sP#{$]$f!_!_$v$y$|$v%S%V%]!_P%c%i%p%w%}&X&_&e&k&uPPP'PPPP'TPPP'ZPPP'_'cTTOVQYPQ[QRcSQgYRhZQn[Qo]Q!k!OQ!l!PR#S#PYm[]!O!P#PR!s!Z[l[]!O!P!Z#PTp_rW!Ri!Q!T!nT!Vj!X]l[]!O!P!Z#PQ!^nQ!h|S!y!f!gQ!}!kR#Q!zQZPQ]QRdSQ!^oQ!h}S!y!i!jQ!}!lR#Q!|RbRR_RQt_R!arRaRXvaux!cQzaR!exQ|cR}dZ!x!f!i!z!|#RZ!w!f!i!z!|#RQVOReVQ!TiQ!n!QT!o!T!nQ!XjR!q!XQ![mR!t![Qr_R!`rQxaQ!cuT!dx!cQ!g|Q!j}T!{!g!jTUOVX!Si!Q!T!nT!Wj!XTq_rXwaux!c",nodeNames:"⚠ EntryType EntryType EntryType LineComment File StringEntry EntryBraceOpen StringName Value ValueAtom BracedValue NestedBracedValue Command Escape QuotedValue Number StringRef Concat EntryBraceClose EntryParenOpen EntryParenClose PreambleEntry CommentEntry CommentBracedBlock CommentBraceOpen CommentBraceClose CommentParenBlock CommentParenOpen CommentParenValue CommentParenClose Entry EntryType EntryKey Field FieldName",maxTerm:62,skippedNodes:[0,4],repeatNodeCount:7,tokenData:"IaoRtOX#cXY+}YZ+}Z]#c]^+}^p#cpq+}qr#crs-est/Rtu#cuv0wvx#cxy6zyz7mz|#c|}8`}!Q#c!Q![9a![!_#c!_!`;]!`!b#c!b!c=R!c!}@}!}#O#c#O#PC]#P#R#c#R#S@}#S#T#c#T#o@}#o#pHc#p#q#c#q#rHy#r;'S#c;'S;=`+w<%lO#cn#ng!_W!^S!UQ!X`OX#cXZ%VZ]#c]^%V^p#cpq%Vqr#crs)Xsu#cuv%Vvx#cxz([z|#c|}%V}#O#c#O#P*s#P#o#c#o#p'j#p#q#c#q#r'j#r;'S#c;'S;=`+w<%lO#cf%`[!^S!UQ!X`Or%Vrs&Usx%Vxz([z#O%V#P#o%V#o#p'j#p#q%V#q#r'j#r;'S%V;'S;=`)R<%lO%VU&]Y!^S!UQOx&Uxz&{z#O&U#P#o&U#o#p'j#p#q&U#q#r'j#r;'S&U;'S;=`(U<%lO&UQ'QU!UQO#O&{#P#o&{#p#q&{#r;'S&{;'S;=`'d<%lO&{Q'gP;=`<%l&{S'oT!^SOx'jz#O'j#P;'S'j;'S;=`(O<%lO'jS(RP;=`<%l'jU(XP;=`<%l&Ub(cW!UQ!X`Or([rs&{s#O([#P#o([#p#q([#r;'S([;'S;=`({<%lO([b)OP;=`<%l([f)UP;=`<%l%V^)be!_W!^S!UQOX)XXZ&UZ])X]^&U^p)Xpq&Uqu)Xuv&Uvx)Xxz&{z|)X|}&U}#O)X#O#P*s#P#o)X#o#p'j#p#q)X#q#r'j#r;'S)X;'S;=`+q<%lO)XW*xZ!_WOX*sZ]*s^p*squ*svx*sz|*s}#o*s#p#q*s#r;'S*s;'S;=`+k<%lO*sW+nP;=`<%l*s^+tP;=`<%l)Xn+zP;=`<%l#co,Yc!^S}X!UQ!X`OX%VXY+}YZ+}Z]%V]^+}^p%Vpq+}qr%Vrs&Usx%Vxz([z#O%V#P#o%V#o#p'j#p#q%V#q#r'j#r;'S%V;'S;=`)R<%lO%Vo-pe!Va!_W!^S!UQOX)XXZ&UZ])X]^&U^p)Xpq&Uqu)Xuv&Uvx)Xxz&{z|)X|}&U}#O)X#O#P*s#P#o)X#o#p'j#p#q)X#q#r'j#r;'S)X;'S;=`+q<%lO)Xo/`gbP!_W!^S!UQ!X`OX#cXZ%VZ]#c]^%V^p#cpq%Vqr#crs)Xsu#cuv%Vvx#cxz([z|#c|}%V}#O#c#O#P*s#P#o#c#o#p'j#p#q#c#q#r'j#r;'S#c;'S;=`+w<%lO#co1S_SX!^S!UQ!X`OY0wYZ%VZr0wrs2Rsx0wxz5lz#O0w#O#P3}#P#o0w#o#p4l#p#q0w#q#r4l#r;'S0w;'S;=`6t<%lO0w_2[]SX!^S!UQOY2RYZ&UZx2Rxz3Tz#O2R#O#P3}#P#o2R#o#p4l#p#q2R#q#r4l#r;'S2R;'S;=`5f<%lO2RZ3[ZSX!UQOY3TYZ&{Z#O3T#O#P3}#P#o3T#o#p3}#p#q3T#q#r3}#r;'S3T;'S;=`4f<%lO3TX4SSSXOY3}Z;'S3};'S;=`4`<%lO3}X4cP;=`<%l3}Z4iP;=`<%l3T]4sXSX!^SOY4lYZ'jZx4lxz3}z#O4l#O#P3}#P;'S4l;'S;=`5`<%lO4l]5cP;=`<%l4l_5iP;=`<%l2Rk5u]SX!UQ!X`OY5lYZ([Zr5lrs3Ts#O5l#O#P3}#P#o5l#o#p3}#p#q5l#q#r3}#r;'S5l;'S;=`6n<%lO5lk6qP;=`<%l5lo6wP;=`<%l0wg7TW!YT!UQ!X`Or([rs&{s#O([#P#o([#p#q([#r;'S([;'S;=`({<%lO([g7vW!ZT!UQ!X`Or([rs&{s#O([#P#o([#p#q([#r;'S([;'S;=`({<%lO([g8k[!`P!^S!UQ!X`Or%Vrs&Usx%Vxz([z#O%V#P#o%V#o#p'j#p#q%V#q#r'j#r;'S%V;'S;=`)R<%lO%Vo9ni`P!_W!^S!UQ!X`OX#cXZ%VZ]#c]^%V^p#cpq%Vqr#crs)Xsu#cuv%Vvx#cxz([z|#c|}%V}!Q#c!Q![9a![#O#c#O#P*s#P#o#c#o#p'j#p#q#c#q#r'j#r;'S#c;'S;=`+w<%lO#co;jg!RP!_W!^S!UQ!X`OX#cXZ%VZ]#c]^%V^p#cpq%Vqr#crs)Xsu#cuv%Vvx#cxz([z|#c|}%V}#O#c#O#P*s#P#o#c#o#p'j#p#q#c#q#r'j#r;'S#c;'S;=`+w<%lO#co=^j!_W!^S!UQ!X`OX#cXZ%VZ]#c]^%V^p#cpq%Vqr#crs)Xsu#cuv%Vvx#cxz([z|#c|}%V}!c#c!c!}?O!}#O#c#O#P*s#P#T#c#T#o?O#o#p'j#p#q#c#q#r'j#r;'S#c;'S;=`+w<%lO#co?]jpP!_W!^S!UQ!X`OX#cXZ%VZ]#c]^%V^p#cpq%Vqr#crs)Xsu#cuv%Vvx#cxz([z|#c|}%V}!c#c!c!}?O!}#O#c#O#P*s#P#T#c#T#o?O#o#p'j#p#q#c#q#r'j#r;'S#c;'S;=`+w<%lO#coA[o!_W!QP!^S!UQ!X`OX#cXZ%VZ]#c]^%V^p#cpq%Vqr#crs)Xsu#cuv%Vvx#cxz([z|#c|}%V}!O@}!O!Q#c!Q![@}![!c#c!c!}@}!}#O#c#O#P*s#P#R#c#R#S@}#S#T#c#T#o@}#o#p'j#p#q#c#q#r'j#r;'S#c;'S;=`+w<%lO#cnCbh!_WOXD|XZEvZ]D|]^Ev^pD|pqEvquD|uvEvvxD|xzEvz|D||}Ev}!bD|!b!cE{!c!}E{!}#TD|#T#oE{#o#pEv#p#qD|#q#rEv#r;'SD|;'S;=`HZ;=`<%lEv<%lOD|nETZ!_W^fOX*sZ]*s^p*squ*svx*sz|*s}#o*s#p#q*s#r;'S*s;'S;=`+k<%lO*sfE{O^fnFU_!_W]b^fOX*sZ]*s^p*squ*svx*sz|*s}!b*s!b!cGT!c!}GT!}#T*s#T#oGT#p#q*s#r;'S*s;'S;=`+k<%lO*sjG[_!_W]bOX*sZ]*s^p*squ*svx*sz|*s}!b*s!b!cGT!c!}GT!}#T*s#T#oGT#p#q*s#r;'S*s;'S;=`+k<%lO*snH`P^f;=`<%lD|gHjT!Pc!^SOx'jz#O'j#P;'S'j;'S;=`(O<%lO'jVIQT!TR!^SOx'jz#O'j#P;'S'j;'S;=`(O<%lO'j",tokenizers:[0,1,2,3,4],topRules:{File:[0,5]},specialized:[{term:32,get:(t,n)=>kr(t)<<1,external:kr}],tokenPrec:328}),Rs=Wo.define({name:"bibtex",parser:Ts.configure({props:[Zo.add({Entry:t=>t.baseIndent+t.unit,StringEntry:t=>t.baseIndent+t.unit,PreambleEntry:t=>t.baseIndent+t.unit,BracedValue:t=>t.baseIndent+t.unit}),Yo.add({Entry:ft,StringEntry:ft,PreambleEntry:ft,CommentBracedBlock:ft,CommentParenBlock:ft,BracedValue:ft}),Go({EntryType:ae.definitionKeyword,StringEntryType:ae.definitionKeyword,PreambleEntryType:ae.definitionKeyword,CommentEntryType:ae.definitionKeyword,EntryKey:ae.atom,FieldName:ae.propertyName,StringName:ae.propertyName,StringRef:ae.variableName,Number:ae.number,Concat:ae.operator,BracedValue:ae.string,QuotedValue:ae.string,NestedBracedValue:ae.special(ae.string),Command:ae.macroName,Escape:ae.escape,LineComment:ae.lineComment,CommentEntry:ae.blockComment,CommentBracedBlock:ae.blockComment,CommentParenBlock:ae.blockComment})]}),languageData:{commentTokens:{line:"%"},closeBrackets:{brackets:["{",'"']}}}),As=Jo.define([{tag:ae.macroName,color:"#176b8f"},{tag:ae.special(ae.string),color:"#8a5a16"}]),Ps={author:"authors",editor:"editors",journal:"journals",journaltitle:"journals",shortjournal:"journals",publisher:"publishers",origpublisher:"publishers",school:"schools",institution:"institutions",organization:"organizations",address:"addresses",location:"addresses",origlocation:"addresses",year:"years",origyear:"years"},Or=new WeakMap;function gi(t){const n=[];let o=0;for(let s=0;s<t.length;s++){const c=t[s];if(c==="\\"){s++;continue}if(c==="{"){o++;continue}if(c==="}"){o=Math.max(0,o-1);continue}if(o!==0||t.slice(s,s+3).toLowerCase()!=="and")continue;const f=t[s-1],m=t[s+3];if(!f||!/\s/.test(f)||m!==void 0&&!/\s/.test(m))continue;let g=s;for(;g>0&&/\s/.test(t[g-1]);)g--;let b=s+3;for(;b<t.length&&/\s/.test(t[b]);)b++;n.push({from:g,to:b}),s+=2}return n}function vi(t){const n=gi(t),o=n.at(-1),s=o&&t.slice(o.to).trim()===""?o.from:t.length,c=[];let f=0;for(const g of n){if(g.from>=s)break;const b=t.slice(f,g.from).trim();b&&c.push(b),f=g.to}const m=t.slice(f,s).trim();return m&&c.push(m),c}function Ns(t){const n=t.trim();return n.startsWith("{")&&n.endsWith("}")||n.startsWith('"')&&n.endsWith('"')?n.slice(1,-1).trim():n}function Ds(t){const n=Vt(t),o=t.doc,s=Or.get(o);if(s?.tree===n)return s.values;const c={authors:new Set,editors:new Set,journals:new Set,publishers:new Set,schools:new Set,institutions:new Set,organizations:new Set,addresses:new Set,years:new Set,stringMacros:new Set,keys:new Set,byField:new Map};return n.cursor().iterate(f=>{if(f.name==="StringEntry"){const b=f.node.getChild("StringName");return b&&c.stringMacros.add(o.sliceString(b.from,b.to)),!1}if(f.name!=="Entry")return;const m=f.node,g=m.getChild("EntryKey");g&&c.keys.add(o.sliceString(g.from,g.to));for(const b of m.getChildren("Field")){const S=b.getChild("FieldName"),M=b.getChild("Value");if(!S||!M||M.getChild("Concat"))continue;const A=o.sliceString(S.from,S.to).toLowerCase(),P=Ns(o.sliceString(M.from,M.to));if(!P)continue;c.byField.has(A)||c.byField.set(A,new Set),c.byField.get(A).add(P);const E=Ps[A];if(E==="authors"||E==="editors")for(const T of vi(P))c[E].add(T);else E&&c[E].add(P)}return!1}),Or.set(o,{tree:n,values:c}),c}const Rn={syntaxError:()=>"Syntax error",duplicatePerson:(t,n)=>`Duplicate name in ${t}: ${n}`,unknownEntryType:t=>`Unknown entry type: @${t}`,duplicateEntryKey:t=>`Duplicate entry key: ${t}`,duplicateField:t=>`Duplicate field '${t}' in entry`,unknownField:t=>`Unknown field: ${t}`,invalidFieldValue:t=>`Syntax error in value for field '${t}'`,emptyFieldValue:t=>`Empty value for field '${t}'`,verifyInheritedFields:(t,n)=>`Verify '${t}' provides: ${n}`,missingRequiredFields:t=>`Missing required fields: ${t}`,missingRecommendedFields:t=>`Recommended fields missing: ${t}`,entryDescription:t=>`BibTeX entry type @${t}.`,fieldDescription:t=>`${t} is a BibTeX field.`,requiredFields:t=>`Required: ${t}`,optionalFields:t=>`Optional: ${t}`,exampleLabel:()=>"Example",noteLabel:()=>"Note",authorsNote:()=>"Use “and” to separate multiple authors or editors.",pagesNote:()=>"Use a double dash (--) for a page range.",monthNote:()=>"Use a three-letter abbreviation without quotes."},yi=new Set(["remote-id","external-id"]),bi=new Set(["article","book","mvbook","inbook","bookinbook","suppbook","booklet","collection","mvcollection","incollection","suppcollection","manual","misc","online","webpage","patent","periodical","suppperiodical","proceedings","mvproceedings","inproceedings","conference","reference","mvreference","inreference","report","techreport","thesis","mastersthesis","phdthesis","unpublished","software","dataset","letter","set","xdata"]),An=new Set(["abstract","addendum","address","afterword","annotation","annote","annotator","archiveprefix","author","authortype","bookauthor","bookpagination","booksubtitle","booktitle","booktitleaddon","chapter","commentator","crossref","date","doi","edition","editor","editora","editorb","editorc","editortype","editoratype","editorbtype","editorctype","eid","entryset","eprint","eprintclass","eprinttype","eventdate","eventtitle","eventtitleaddon","execute","file","foreword","gender","holder","howpublished","hyphenation","indexsorttitle","indextitle","institution","introduction","isan","isbn","ismn","isrn","issn","issue","issuesubtitle","issuetitle","iswc","journal","journalsubtitle","journaltitle","key","keywords","label","langid","langidopts","language","library","location","mainsubtitle","maintitle","maintitleaddon","month","nameaddon","note","number","organization","origdate","origlanguage","origlocation","origpublisher","origtitle","origyear","options","pages","pagetotal","pagination","part","presort","primaryclass","publisher","pubstate","related","relatedoptions","relatedstring","relatedtype","reprinttitle","school","series","shortauthor","shorteditor","shorthand","shorthandintro","shortjournal","shortseries","shorttitle","sortkey","sortname","sortshorthand","sorttitle","sortyear","subtitle","title","titleaddon","translator","type","url","urldate","usera","userb","userc","userd","usere","userf","venue","verba","verbb","verbc","version","volume","volumes","xdata","xref","year"]),Pn={article:{required:["author","title"],alternatives:[["date","year"],{fields:["journaltitle","journal"],severity:"warning"}],optional:["translator","editor","subtitle","titleaddon","volume","number","eid","issue","pages","note","issn","doi","eprint","url","urldate","series"]},book:{required:["title"],alternatives:[["date","year"],{fields:["author","editor"],severity:"warning"}],optional:["publisher","location","address","edition","volume","volumes","series","number","isbn","pagetotal","note","doi","url","urldate","subtitle","titleaddon","maintitle","mainsubtitle","translator","commentator","annotator","introduction","foreword","afterword"]},mvbook:{required:["title","volumes"],alternatives:[["author","editor"],["date","year"]],optional:["publisher","location","edition","series","number","isbn","note","subtitle","titleaddon"]},inbook:{required:["title","booktitle"],alternatives:[["author","editor"],["date","year"]],optional:["bookauthor","editor","pages","chapter","publisher","location","edition","volume","series","number","maintitle","note","doi","url","urldate"]},booklet:{required:["title"],alternatives:[["author","editor"]],optional:["howpublished","location","date","year","month","note","url"]},collection:{required:["title"],alternatives:[["date","year"],{fields:["editor"],severity:"warning"}],optional:["publisher","location","edition","volume","volumes","series","number","isbn","note","subtitle","titleaddon"]},mvcollection:{required:["editor","title"],alternatives:[["date","year"]],optional:["publisher","location","edition","volumes","series","number","isbn","note"]},incollection:{required:["author","title","booktitle"],alternatives:[["date","year"]],optional:["editor","pages","publisher","location","edition","volume","series","number","maintitle","note","doi","url"]},inproceedings:{required:["author","title","booktitle"],alternatives:[["date","year"]],optional:["editor","pages","publisher","organization","location","venue","eventdate","eventtitle","series","volume","number","note","doi","url"]},conference:{required:["author","title","booktitle"],alternatives:[["date","year"]],optional:["editor","pages","publisher","organization","location","series","volume","number","note"]},proceedings:{required:["title"],alternatives:[["date","year"]],optional:["editor","publisher","organization","location","venue","eventdate","eventtitle","series","volume","number","note"]},manual:{required:["title"],optional:["author","editor","organization","edition","location","date","year","month","note","url"]},misc:{required:["title"],optional:["author","editor","howpublished","date","year","month","note","url","urldate"]},online:{required:["title"],alternatives:[["date","year"],{fields:["url","doi","eprint"],severity:"warning"}],optional:["author","editor","month","urldate","note","organization","version"]},webpage:{required:["title","url"],optional:["author","date","year","urldate","note"]},patent:{required:["author","title","number"],alternatives:[["date","year"]],optional:["holder","type","location","note","url"]},periodical:{required:["title"],alternatives:[["date","year"],{fields:["editor"],severity:"warning"}],optional:["subtitle","issuetitle","issuesubtitle","series","volume","number","issue","issn","note"]},thesis:{required:["author","title","type","institution"],alternatives:[["date","year"]],optional:["location","note","url","doi","school"]},phdthesis:{required:["author","title","school"],alternatives:[["date","year"]],optional:["location","address","type","note","url","doi","month"]},mastersthesis:{required:["author","title","school"],alternatives:[["date","year"]],optional:["location","address","type","note","url","doi","month"]},report:{required:["author","title","type","institution"],alternatives:[["date","year"]],optional:["number","location","note","url","doi"]},techreport:{required:["author","title","institution"],alternatives:[["date","year"]],optional:["type","number","location","address","note","url","month"]},unpublished:{required:["author","title"],alternatives:[["date","year"]],optional:["note","month","url"]},dataset:{required:["title"],alternatives:[["date","year"]],optional:["author","editor","publisher","version","doi","url","urldate","note"]},software:{required:["title"],alternatives:[["date","year"]],optional:["author","editor","publisher","version","url","urldate","note"]},set:{required:["entryset"],optional:[]}},Bs={checkRequiredFields:!0,checkUnknownFields:!0,checkDuplicateKeys:!0,checkFieldSyntax:!0,checkEntryTypes:!0},Fs=500;function Is(t,n,o){const s=new Set;t.cursor().iterate(c=>{if(!c.type.isError||s.has(c.from))return;s.add(c.from);const f=c.to>c.from?c.to:c.from+1;n.push({from:c.from,to:f,severity:"error",message:o.syntaxError(),source:"BibTeX"})})}function $s(t,n,o,s){const c=ki(n.sliceString(t.valueFrom,t.valueTo)),f=new Set;for(const m of vi(c)){const g=m.toLowerCase();f.has(g)?o.push({from:t.valueFrom,to:t.valueTo,severity:"warning",message:s.duplicatePerson(t.name,m),source:"BibTeX"}):f.add(g)}}function Vs(t={}){const{messages:n=Rn,...o}=t,s={...Bs,...o};return c=>{const f=[],m=c.state.doc,g=wn(c.state,m.length,Fs)??Vt(c.state),b=g.length>=m.length,S=new Map;return g.cursor().iterate(M=>{if(M.name==="Entry")return _s(M.node,m,f,S,s,b,n),!1}),s.checkFieldSyntax&&b&&Is(g,f,n),f}}function _s(t,n,o,s,c,f,m){const g=t.getChild("EntryType"),b=t.getChild("EntryKey");if(!g)return;const M=n.sliceString(g.from,g.to).replace(/^@/,"").toLowerCase();if(c.checkEntryTypes&&!bi.has(M)&&o.push({from:g.from,to:g.to,severity:"warning",message:m.unknownEntryType(M),source:"BibTeX"}),c.checkDuplicateKeys&&b){const E=n.sliceString(b.from,b.to).trim();if(E){const T=s.get(E);T?(o.push({from:b.from,to:b.to,severity:"error",message:m.duplicateEntryKey(E),source:"BibTeX"}),T.flagged||(o.push({from:T.from,to:T.to,severity:"error",message:m.duplicateEntryKey(E),source:"BibTeX"}),T.flagged=!0)):s.set(E,{from:b.from,to:b.to,flagged:!1})}}const A=Qs(t,n),P=new Set(A.map(E=>E.name.toLowerCase()));if(c.checkRequiredFields&&f){const E=Pn[M];if(E){const T=["crossref","xref","xdata","related"].find(R=>P.has(R));js(t,P,E,o,T,m)}}if(c.checkUnknownFields||c.checkFieldSyntax||c.checkDuplicateKeys){const E=new Map;for(const T of A){const R=T.name.toLowerCase();yi.has(R)||(c.checkDuplicateKeys&&(E.has(R)?o.push({from:T.nameFrom,to:T.nameTo,severity:"warning",message:m.duplicateField(T.name),source:"BibTeX"}):E.set(R,T.nameFrom),(R==="author"||R==="editor")&&$s(T,n,o,m)),c.checkUnknownFields&&!An.has(R)&&o.push({from:T.nameFrom,to:T.nameTo,severity:"warning",message:m.unknownField(T.name),source:"BibTeX"}),c.checkFieldSyntax&&(T.hasError?o.push({from:T.valueFrom,to:T.valueTo,severity:"error",message:m.invalidFieldValue(T.name),source:"BibTeX"}):T.isEmpty&&o.push({from:T.valueFrom,to:T.valueTo,severity:"warning",message:m.emptyFieldValue(T.name),source:"BibTeX"})))}}}function Qs(t,n){const o=[];for(const s of t.getChildren("Field")){const c=s.getChild("FieldName"),f=s.getChild("Value");if(!c)continue;const m=f?f.from:c.to,g=f?f.to:c.to,b=f?n.sliceString(f.from,f.to):"";o.push({name:n.sliceString(c.from,c.to),nameFrom:c.from,nameTo:c.to,valueFrom:m,valueTo:g,isEmpty:!f||ki(b).trim()==="",hasError:f?Ks(f):!1})}return o}function js(t,n,o,s,c,f){const m=[],g=[];for(const b of o.required)n.has(b)||m.push(b);if(o.alternatives)for(const b of o.alternatives){const S=Array.isArray(b)?b:b.fields,M=Array.isArray(b)?"error":b.severity;if(!S.some(A=>n.has(A))){const A=S.join(" or ");M==="warning"?g.push(A):m.push(A)}}if(c){if(m.length>0||g.length>0){const b=[...m,...g];s.push({from:t.from,to:t.to,severity:"info",message:f.verifyInheritedFields(c,b.join(", ")),source:"BibTeX"})}return}m.length>0&&s.push({from:t.from,to:t.to,severity:"error",message:f.missingRequiredFields(m.join(", ")),source:"BibTeX"}),g.length>0&&s.push({from:t.from,to:t.to,severity:"warning",message:f.missingRecommendedFields(g.join(", ")),source:"BibTeX"})}function Ks(t){let n=!1;return t.cursor().iterate(o=>{if(n)return!1;if(o.type.isError)return n=!0,!1}),n}function ki(t){const n=t.trim();return n.startsWith("{")&&n.endsWith("}")||n.startsWith('"')&&n.endsWith('"')?n.slice(1,-1):n}const qs={article:`@article{key,
|
|
42
|
-
author = {John Doe},
|
|
43
|
-
title = {Sample Article},
|
|
44
|
-
journal = {Journal Name},
|
|
45
|
-
year = {2023}
|
|
46
|
-
}`,book:`@book{key,
|
|
47
|
-
author = {Jane Smith},
|
|
48
|
-
title = {Book Title},
|
|
49
|
-
publisher = {Publisher},
|
|
50
|
-
year = {2023}
|
|
51
|
-
}`,inproceedings:`@inproceedings{key,
|
|
52
|
-
author = {Author Name},
|
|
53
|
-
title = {Paper Title},
|
|
54
|
-
booktitle = {Conference Proceedings},
|
|
55
|
-
year = {2023}
|
|
56
|
-
}`},zs={author:"John Doe and Jane Smith",title:"A Great Discovery in Science",journal:"Nature",year:"2023",publisher:"Academic Press",booktitle:"Proceedings of the International Conference",editor:"John Editor and Jane Editor",pages:"123--145",volume:"42",number:"3",month:"jan",note:"In press",doi:"10.1000/182",url:"https://example.com/paper.pdf",urldate:"2023-12-01",address:"New York, NY",edition:"2nd",series:"Lecture Notes in Computer Science",school:"MIT",institution:"Stanford University",organization:"IEEE",type:"PhD thesis",howpublished:"Self-published",chapter:"7",key:"Anonymous99",crossref:"conf2023",isbn:"978-0-123456-78-9",issn:"1234-5678",keywords:"machine learning, artificial intelligence",abstract:"This paper presents..."};function Us(t){const n=Pn[t];if(!n)return{requiredFields:[],optionalFields:[]};const o=[...n.required];for(const s of n.alternatives??[]){const c=Array.isArray(s)?s:s.fields;o.push(c.join(" or "))}return{requiredFields:o,optionalFields:n.optional}}function Xs(t,n,o=1){const s=Vt(t).resolveInner(n,o);if(s.name==="EntryType"){const m=t.sliceDoc(s.from+1,s.to).toLowerCase();return bi.has(m)?{kind:"entry",entryType:m,from:s.from,to:s.to,...Us(m),example:qs[m]}:null}if(s.name!=="FieldName")return null;const c=t.sliceDoc(s.from,s.to).toLowerCase();if(yi.has(c)||!An.has(c))return null;const f=c==="author"||c==="editor"?"authors":c==="pages"?"pages":c==="month"?"month":void 0;return{kind:"field",field:c,from:s.from,to:s.to,example:zs[c],note:f}}function Qe(t,n,o){const s=document.createElement("div");s.className=n,s.textContent=o,t.appendChild(s)}function Hs(t,n,o){Qe(t,"cm-bibtex-tooltip-example-label",o.exampleLabel());const s=document.createElement("pre");s.className="cm-bibtex-tooltip-example",s.textContent=n,t.appendChild(s)}function Ws(t,n){return{pos:t.from,end:t.to,above:!0,create(){const o=document.createElement("div");return o.className="cm-bibtex-tooltip",Qe(o,"cm-bibtex-tooltip-description",n.entryDescription(t.entryType)),t.requiredFields.length>0&&Qe(o,"cm-bibtex-tooltip-required",n.requiredFields(t.requiredFields.join(", "))),t.optionalFields.length>0&&Qe(o,"cm-bibtex-tooltip-optional",n.optionalFields(t.optionalFields.join(", "))),t.example&&Hs(o,t.example,n),{dom:o}}}}function Zs(t,n){return{pos:t.from,end:t.to,above:!0,create(){const o=document.createElement("div");return o.className="cm-bibtex-tooltip",Qe(o,"cm-bibtex-tooltip-field-name",t.field),Qe(o,"cm-bibtex-tooltip-description",n.fieldDescription(t.field)),t.example&&Qe(o,"cm-bibtex-tooltip-example-inline",`${n.exampleLabel()}: ${t.example}`),t.note==="authors"&&Qe(o,"cm-bibtex-tooltip-note",`${n.noteLabel()}: ${n.authorsNote()}`),t.note==="pages"&&Qe(o,"cm-bibtex-tooltip-note",`${n.noteLabel()}: ${n.pagesNote()}`),t.note==="month"&&Qe(o,"cm-bibtex-tooltip-note",`${n.noteLabel()}: ${n.monthNote()}`),{dom:o}}}}function Oi(t=Rn){return Jr((n,o,s)=>{const c=Xs(n.state,o,s);return c?c.kind==="entry"?Ws(c,t):Zs(c,t):null})}Oi();const Ys=["article","book","booklet","conference","inbook","incollection","inproceedings","manual","mastersthesis","misc","online","phdthesis","proceedings","techreport","unpublished","webpage"],Gs=Array.from(An),Cr=["jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec"],Js=["Nature","Science","Cell","PNAS","J. Am. Chem. Soc.","Phys. Rev. Lett.","IEEE Trans.","ACM Trans.","Commun. ACM"],el=[ie(`@article{#{key},
|
|
57
|
-
author = {#{author}},
|
|
58
|
-
title = {#{title}},
|
|
59
|
-
journal = {#{journal}},
|
|
60
|
-
year = {#{year}},
|
|
61
|
-
volume = {#{volume}},
|
|
62
|
-
number = {#{number}},
|
|
63
|
-
pages = {#{pages}}
|
|
64
|
-
}`,{label:"@article",type:"keyword",detail:"Journal article"}),ie(`@book{#{key},
|
|
65
|
-
author = {#{author}},
|
|
66
|
-
title = {#{title}},
|
|
67
|
-
publisher = {#{publisher}},
|
|
68
|
-
year = {#{year}},
|
|
69
|
-
address = {#{address}}
|
|
70
|
-
}`,{label:"@book",type:"keyword",detail:"Book"}),ie(`@inproceedings{#{key},
|
|
71
|
-
author = {#{author}},
|
|
72
|
-
title = {#{title}},
|
|
73
|
-
booktitle = {#{booktitle}},
|
|
74
|
-
year = {#{year}},
|
|
75
|
-
pages = {#{pages}}
|
|
76
|
-
}`,{label:"@inproceedings",type:"keyword",detail:"Conference paper"}),ie(`@incollection{#{key},
|
|
77
|
-
author = {#{author}},
|
|
78
|
-
title = {#{title}},
|
|
79
|
-
booktitle = {#{booktitle}},
|
|
80
|
-
editor = {#{editor}},
|
|
81
|
-
publisher = {#{publisher}},
|
|
82
|
-
year = {#{year}},
|
|
83
|
-
pages = {#{pages}}
|
|
84
|
-
}`,{label:"@incollection",type:"keyword",detail:"Book chapter"}),ie(`@phdthesis{#{key},
|
|
85
|
-
author = {#{author}},
|
|
86
|
-
title = {#{title}},
|
|
87
|
-
school = {#{school}},
|
|
88
|
-
year = {#{year}}
|
|
89
|
-
}`,{label:"@phdthesis",type:"keyword",detail:"PhD thesis"}),ie(`@mastersthesis{#{key},
|
|
90
|
-
author = {#{author}},
|
|
91
|
-
title = {#{title}},
|
|
92
|
-
school = {#{school}},
|
|
93
|
-
year = {#{year}}
|
|
94
|
-
}`,{label:"@mastersthesis",type:"keyword",detail:"Master's thesis"}),ie(`@online{#{key},
|
|
95
|
-
author = {#{author}},
|
|
96
|
-
title = {#{title}},
|
|
97
|
-
url = {#{url}},
|
|
98
|
-
urldate = {#{urldate}},
|
|
99
|
-
year = {#{year}}
|
|
100
|
-
}`,{label:"@online",type:"keyword",detail:"Online resource (BibLaTeX)"}),ie(`@misc{#{key},
|
|
101
|
-
title = {#{title}},
|
|
102
|
-
author = {#{author}},
|
|
103
|
-
year = {#{year}},
|
|
104
|
-
note = {#{note}}
|
|
105
|
-
}`,{label:"@misc",type:"keyword",detail:"Miscellaneous"}),ie(`@manual{#{key},
|
|
106
|
-
title = {#{title}},
|
|
107
|
-
author = {#{author}},
|
|
108
|
-
organization = {#{organization}},
|
|
109
|
-
year = {#{year}}
|
|
110
|
-
}`,{label:"@manual",type:"keyword",detail:"Manual"}),ie(`@techreport{#{key},
|
|
111
|
-
author = {#{author}},
|
|
112
|
-
title = {#{title}},
|
|
113
|
-
institution = {#{institution}},
|
|
114
|
-
year = {#{year}},
|
|
115
|
-
number = {#{number}}
|
|
116
|
-
}`,{label:"@techreport",type:"keyword",detail:"Technical report"})],tl=new Set(["Value","ValueAtom","BracedValue","QuotedValue","Number","StringRef"]),nl={author:"authors",editor:"editors",journal:"journals",journaltitle:"journals",shortjournal:"journals",publisher:"publishers",school:"schools",institution:"institutions",organization:"organizations",address:"addresses",location:"addresses",year:"years",date:"years",origyear:"years"};function at(t,n){let o=t;for(;o;){if(o.name===n)return o;o=o.parent}return null}function rl(t,n){let o=t;for(;o;){if(n.has(o.name))return o;o=o.parent}return null}function il(t){const n=new Set(["BracedValue","QuotedValue","Number","StringRef"]);let o=t;for(;o;){if(n.has(o.name))return o;if(o.name==="Value"||o.name==="Field"||o.name==="Entry")return null;o=o.parent}return null}function ol(t,n){const o=at(t,"Field");if(!o)return null;const s=o.getChild("FieldName");return s?n.sliceString(s.from,s.to).toLowerCase():null}function al(t,n){const o=at(t,"Entry");if(!o)return null;const s=o.getChild("EntryType");return s?n.sliceString(s.from,s.to).replace(/^@/,"").toLowerCase():null}function sl(t,n){const o=new Set,s=at(t,"Entry");if(!s)return o;for(const c of s.getChildren("Field")){const f=c.getChild("FieldName");f&&o.add(n.sliceString(f.from,f.to).toLowerCase())}return o}function ll(t,n,o){return/^(?:\s|%[^\n]*(?:\n|$))*=/.test(t.sliceString(n.to,o.to))}function cl(t){let n="",o=0;for(const s of t)s==='"'&&o%2===0&&(n+="\\"),n+=s,o=s==="\\"?o+1:0;return n}function wr(t){const n=t.matchBefore(/@[a-zA-Z]*/);if(!n||n.from===n.to&&!t.explicit)return null;const o=t.state.doc.lineAt(n.from).from,c=t.state.sliceDoc(o,n.from).trim()==="",f=Ys.map(g=>({label:"@"+g,type:"keyword",apply:"@"+g,boost:1})),m=c?[...f,...el.map(g=>({...g,boost:.5}))]:f;return{from:n.from,options:m,validFor:/^@?[a-zA-Z]*$/}}function ul(t,n){const o=t.matchBefore(/[a-zA-Z_]*/);if(!o)return null;const s=t.state.doc,c=sl(n,s),f=at(n,"Field"),m=f?.getChild("FieldName")??null,g=!!(m&&t.pos>=m.from&&t.pos<=m.to&&ll(s,m,f));g&&m&&c.delete(s.sliceString(m.from,m.to).toLowerCase());const b=al(n,s),S=b?Pn[b]:void 0,M=new Set(S?.required??[]),A=new Set(S?.optional??[]);if(S?.alternatives)for(const E of S.alternatives){const T=Array.isArray(E)?E:E.fields;for(const R of T)M.add(R)}const P=[];for(const E of Gs){if(c.has(E.toLowerCase()))continue;let T=.5;M.has(E)?T=2:A.has(E)&&(T=1),P.push(g?{label:E,type:"property",apply:E,boost:T}:ie(`${E} = {\${value}}`,{label:E,type:"property",boost:T}))}return{from:g&&m?m.from:o.from,to:g&&m?m.to:void 0,options:P,validFor:/^[a-zA-Z_]*$/}}function Sr(t,n){const o=t.state.doc,s=ol(n,o);if(!s)return null;const c=s==="author"||s==="editor",f=il(n);if(c&&(!f||f.name!=="BracedValue"&&f.name!=="QuotedValue"))return null;let m,g=t.pos;if(c&&f){const R=f.from+1,_=f.to-(o.sliceString(f.to-1,f.to)===(f.name==="BracedValue"?"}":'"')?1:0);if(t.pos<R||t.pos>_)return null;const U=gi(o.sliceString(R,_)),ee=t.pos-R,te=[...U].reverse().find(le=>le.to<=ee),q=U.find(le=>le.from>=ee);m=R+(te?.to??0),g=R+(q?.from??_-R)}else if(f&&(f.name==="BracedValue"||f.name==="QuotedValue")){const R=f.from+1,_=f.to-(o.sliceString(f.to-1,f.to)===(f.name==="BracedValue"?"}":'"')?1:0);m=R,g=_}else if(f)m=f.from,g=f.to;else{const R=t.matchBefore(/[A-Za-z0-9_:.\-/]*/);m=R?R.from:t.pos}const b=Ds(t.state),S=[],M=new Set,A=new Set([...b.stringMacros].map(R=>R.toLowerCase())),P=R=>s==="month"&&Cr.includes(R.toLowerCase()),E=(R,_,U=1)=>{if(!R||M.has(R))return;M.add(R);const ee=f?.name==="BracedValue"||f?.name==="QuotedValue",te=f?.name==="QuotedValue"?cl(R):ee||P(R)||A.has(R.toLowerCase())?R:`{${R}}`;S.push({label:R,type:_,apply:te,boost:U})};if(!c)for(const R of b.stringMacros)E(R,"constant",2.5);const T=nl[s];if(T)for(const R of b[T])E(R,"text",2);if(!c){const R=b.byField.get(s);if(R)for(const _ of R)E(_,"text",1.5)}if(s==="month")for(const R of Cr)E(R,"constant",1);if(s==="journal"||s==="journaltitle"||s==="shortjournal")for(const R of Js)E(R,"constant",.5);if(s==="crossref"||s==="xref")for(const R of b.keys)E(R,"constant",1);return S.length===0?null:{from:m,to:g,options:S,validFor:/^[^"{}\n]*$/}}function fl(t){const o=Vt(t.state).resolveInner(t.pos,-1),s=rl(o,tl);if(s&&at(s,"Field"))return Sr(t,o);const c=at(o,"Field"),f=c?.getChild("FieldName");if(c&&f&&/^\s*=\s*$/.test(t.state.sliceDoc(f.to,t.pos)))return Sr(t,o);if(at(o,"Entry")){const g=t.state.sliceDoc(Math.max(0,t.pos-1),t.pos);return t.matchBefore(/@[a-zA-Z]*$/)?wr(t):o.name==="EntryKey"||o.name==="EntryType"||!t.explicit&&!/[a-zA-Z_,{\s]/.test(g)?null:ul(t,o)}return wr(t)}function dl(t){return{syntaxError:()=>t("bibtex.diagnostics.syntaxError"),duplicatePerson:(n,o)=>t("bibtex.diagnostics.duplicatePerson",{field:n,person:o}),unknownEntryType:n=>t("bibtex.diagnostics.unknownEntryType",{entryType:n}),duplicateEntryKey:n=>t("bibtex.diagnostics.duplicateEntryKey",{key:n}),duplicateField:n=>t("bibtex.diagnostics.duplicateField",{field:n}),unknownField:n=>t("bibtex.diagnostics.unknownField",{field:n}),invalidFieldValue:n=>t("bibtex.diagnostics.invalidFieldValue",{field:n}),emptyFieldValue:n=>t("bibtex.diagnostics.emptyFieldValue",{field:n}),verifyInheritedFields:(n,o)=>t("bibtex.diagnostics.verifyInheritedFields",{field:n,fields:o}),missingRequiredFields:n=>t("bibtex.diagnostics.missingRequiredFields",{fields:n}),missingRecommendedFields:n=>t("bibtex.diagnostics.missingRecommendedFields",{fields:n}),entryDescription:n=>t("bibtex.hover.entryDescription",{entryType:`@${n}`}),fieldDescription:n=>t("bibtex.hover.fieldDescription",{field:n}),requiredFields:n=>t("bibtex.hover.requiredFields",{fields:n}),optionalFields:n=>t("bibtex.hover.optionalFields",{fields:n}),exampleLabel:()=>t("bibtex.hover.example"),noteLabel:()=>t("bibtex.hover.note"),authorsNote:()=>t("bibtex.hover.authorsNote"),pagesNote:()=>t("bibtex.hover.pagesNote"),monthNote:()=>t("bibtex.hover.monthNote")}}const hl=Rs,pl=ei({brackets:"()[]{}"});function Ci(t=Rn){return[pl,ea(Vs({messages:t})),Oi(t)]}Ci();const ml=new Set(["(",")","[","]","{","}"]),gl=/^\d[\w.]*(?=%)/,xr=/^\\begin\s*\{\s*([A-Za-z0-9@:_*.\-]+)\s*\}/;function vl(t){const n=t.match(xr,!1);return!n||typeof n=="boolean"||!_t(n[1])?null:(t.match(xr),n[1])}function yl(t,n){const o=Mn(t.string,t.pos,n);return o?o.from>t.pos?(t.pos=o.from,"string"):(t.pos=o.to,"tag"):(t.skipToEnd(),"string")}function bl(t){const n=t.match(gl);return!!(n&&typeof n!="boolean")}function kl(t){const n=Xe.copyState?.(t)??t;if(!n||typeof n!="object")return n;const o=n;return Array.isArray(o.cmdState)?{...o,cmdState:o.cmdState.map(s=>!s||typeof s!="object"?s:Object.assign(Object.create(Object.getPrototypeOf(s)),s))}:n}const Ol={name:Xe.name,startState(t){return{stexState:Xe.startState?.(t)??{},literalEnvironment:null}},copyState(t){return{stexState:kl(t.stexState),literalEnvironment:t.literalEnvironment}},blankLine(t,n){t.literalEnvironment||Xe.blankLine?.(t.stexState,n)},indent(t,n,o){return t.literalEnvironment?null:Xe.indent?.(t.stexState,n,o)??null},languageData:Xe.languageData,tokenTable:Xe.tokenTable,mergeTokens:Xe.mergeTokens,token(t,n){if(n.literalEnvironment){const g=yl(t,n.literalEnvironment);return g==="tag"&&(n.literalEnvironment=null),g}const o=vl(t);if(o)return n.literalEnvironment=o,"tag";const s=xn(t.string,t.pos);if(s!==null)return t.pos=s,"string";if(bl(t))return"atom";const c=t.pos,f=Xe.token(t,n.stexState),m=t.string.slice(c,t.pos);return ml.has(m)?"bracket":f}},Cl=Gr.define(Ol),wl=new Set(["math","displaymath","equation","align","alignat","flalign","gather","multline","split","aligned","alignedat","gathered","matrix","pmatrix","bmatrix","vmatrix","cases","dcases","rcases","smallmatrix","subarray","array"]);function Me(t,n){let o=0;for(let s=n-1;s>=0&&t[s]==="\\";s-=1)o+=1;return o%2===1}function wt(t,n){const o=t.indexOf(`
|
|
117
|
-
`,n);return o<0?t.length:o+1}function wi(t){return t.replace(/\*$/,"").toLowerCase()}function Si(t,n){if(t[n]!=="\\"||Me(t,n))return null;const o=/^\\(begin|end)[ \t]*\{[ \t]*([^{}\s]+)[ \t]*\}/.exec(t.slice(n));return o?{type:o[1],name:o[2],end:n+o[0].length}:null}function xi(t,n){return t[n]!=="\\"||Me(t,n)?null:xn(t,n)}function Mr(t,n,o,s=!1){for(let c=n;c<t.length;c+=1){if(s&&(t[c]===`
|
|
118
|
-
`&&/^[\t \r]*\n/.test(t.slice(c+1))||t[c]==="\\"&&!Me(t,c)&&/^\\par(?![A-Za-z@])/.test(t.slice(c))))return-1;if(t[c]==="%"&&!Me(t,c)){c=wt(t,c)-1;continue}if(o==="dollar"&&t[c]==="$"&&!Me(t,c)||o==="paren"&&t[c]==="\\"&&t[c+1]===")"&&!Me(t,c)||o==="bracket"&&t[c]==="\\"&&t[c+1]==="]"&&!Me(t,c))return c}return-1}function Sl(t,n){for(let o=n;o<t.length-1;o+=1){if(t[o]==="%"&&!Me(t,o)){o=wt(t,o)-1;continue}if(t[o]==="$"&&t[o+1]==="$"&&!Me(t,o))return o}return-1}function xl(t,n,o){let s=1;for(let c=n;c<t.length;c+=1){if(t[c]==="%"&&!Me(t,c)){c=wt(t,c)-1;continue}const f=xi(t,c);if(f!==null){c=f-1;continue}const m=Si(t,c);if(!(!m||m.name!==o)){if(m.type==="begin")s+=1;else if(--s===0)return{from:c,to:m.end};c=m.end-1}}return null}function rn(t,n,o){return n>=t.from&&(n<t.to||n===t.to&&o<0)}function vn(t){let n="";for(let o=0;o<t.length;o+=1){if(t[o]==="%"&&!Me(t,o)){const s=wt(t,o);s>o&&t[s-1]===`
|
|
119
|
-
`&&(n+=`
|
|
120
|
-
`),o=s-1;continue}n+=t[o]}return n.replace(/\\(?:label|notag|nonumber)\b(?:[ \t]*\{[^{}]*\})?/g,"")}function Ml(t,n,o,s){let c=vn(t.slice(o,s));const f=wi(n);return f==="equation"||f==="displaymath"?c:f==="align"||f==="flalign"?`\\begin{aligned}${c}\\end{aligned}`:f==="alignat"?(c=c.replace(/^\s*\{[^{}]*\}/,""),`\\begin{aligned}${c}\\end{aligned}`):f==="gather"||f==="multline"?`\\begin{gathered}${c}\\end{gathered}`:vn(t)}function Er(t,n,o,s){return{from:t,to:n,source:vn(o),displayMode:s}}function Lr(t){return/\.(?:tex|ltx|sty|cls)$/i.test(t)}function El(t,n,o=1){const s=Math.max(0,Math.min(t.length,n));for(let c=0;c<t.length&&c<=s;c+=1){if(t[c]==="%"&&!Me(t,c)){c=wt(t,c)-1;continue}const f=xi(t,c);if(f!==null){c=f-1;continue}const m=Si(t,c);if(m?.type==="begin"){const A=wi(m.name),P=_t(m.name),E=wl.has(A);if(!P&&!E)continue;const T=P?Mn(t,m.end,m.name):xl(t,m.end,m.name);if(P){T?c=T.to-1:c=t.length;continue}if(E&&T){const R={from:c,to:T.to,source:Ml(t.slice(c,T.to),m.name,m.end-c,T.from-c),displayMode:!0};if(rn(R,s,o))return R;c=T.to-1;continue}}if(t[c]==="\\"&&!Me(t,c)&&(t[c+1]==="("||t[c+1]==="[")){const A=t[c+1]==="[",P=Mr(t,c+2,A?"bracket":"paren");if(P>=0){const E=Er(c,P+2,t.slice(c+2,P),A);if(rn(E,s,o))return E;c=E.to-1;continue}}if(t[c]!=="$"||Me(t,c))continue;const g=t[c+1]==="$",b=g?2:1,S=g?Sl(t,c+2):Mr(t,c+1,"dollar",!0);if(S<0)continue;if(!g&&t[S+1]==="$"){c=S;continue}const M=Er(c,S+b,t.slice(c+b,S),g);if(rn(M,s,o))return M;c=M.to-1}return null}let Dt=null;function Ll(){return Dt||(Dt=Promise.all([mr(()=>import("./katex-COYOr4nK.js"),[],import.meta.url),mr(()=>Promise.resolve({}),__vite__mapDeps([0]),import.meta.url)]).then(([t])=>t.default).catch(t=>{throw Dt=null,t})),Dt}function Tl(t,n,o,s,c){let f=!1;return{pos:n,end:o,above:!0,arrow:!0,create(){const m=document.createElement("div");return m.className=`texlite-math-hover${s?" display":" inline"}`,m.setAttribute("role","status"),m.setAttribute("aria-label",c.preview),m.textContent=c.loading,Ll().then(g=>{if(!f){m.replaceChildren();try{g.render(t,m,{displayMode:s,throwOnError:!0,strict:"ignore",trust:!1})}catch{m.textContent=c.unavailable,m.classList.add("texlite-math-hover-error")}}}).catch(()=>{f||(m.textContent=c.unavailable,m.classList.add("texlite-math-hover-error"))}),{dom:m,destroy(){f=!0}}}}}function Tr(t){return Jr((n,o,s)=>{const c=El(n.state.doc.toString(),o,s);return!c||!c.source.trim()||c.source.length>32*1024?null:Tl(c.source,c.from,c.to,c.displayMode,t)},{hoverTime:350,hideOnChange:!0})}const Rl=/^\\(begin|end)\s*\{\s*([A-Za-z0-9@:_*.\-]+)\s*\}/,Al=/\\begin\s*\{\s*[A-Za-z0-9@:_*.\-]*\s*\}?$/,Rr=/^\s*\\(part|chapter|section|subsection|subsubsection)(?![A-Za-z@])\*?/,Ar={part:0,chapter:0,section:1,subsection:2,subsubsection:3};function yn(t,n){let o=0;for(let s=n-1;s>=0&&t[s]==="\\";s-=1)o+=1;return o%2===1}function Pr(t){for(let n=0;n<t.length;n+=1)if(t[n]==="%"&&!yn(t,n))return n;return t.length}function kt(t,n=0,o={name:null}){const s=t.length,c=[];let f=n;for(;f<s;){if(o.name){const S=Mn(t,f,o.name);if(!S)break;c.push({kind:"end",name:o.name,from:S.from,to:S.to}),o.name=null,f=S.to;continue}if(t[f]==="%"&&!yn(t,f))break;if(t[f]!=="\\"||yn(t,f)){f+=1;continue}const m=xn(t,f,s);if(m!==null){f=m;continue}const g=Rl.exec(t.slice(f,s));if(!g){f+=1;continue}const b=f+g[0].length;c.push({kind:g[1],name:g[2],from:f,to:b}),g[1]==="begin"&&_t(g[2])&&(o.name=g[2]),f=b}return c}function Mi(t,n,o){let s=t.lineAt(Math.min(n,t.length)),c=Math.max(0,n-s.from),f=1;const m={name:_t(o)?o:null};for(let g=s.number;g<=t.lines;g+=1){s=t.line(g);const b=kt(s.text,c,m);c=0;for(const S of b)if(S.name===o){if(S.kind==="begin"){f+=1;continue}if(f-=1,f===0)return{from:s.from+S.from,to:s.from+S.to}}}return null}function Ei(t,n){const o=t.lineAt(Math.min(n,t.length)),s=o.text.slice(0,Math.max(0,n-o.from)),c=Al.exec(s);return c?o.from+c.index:null}function Pl(t,n,o,s){const c=[],f={name:null};for(let m=1;m<=t.lines;m+=1){const g=t.line(m),b=kt(g.text,0,f);for(const S of b){const M=g.from+S.from;if(M>=o)return c.at(-1)?.name===s&&(c.at(-1)?.from??n)<n;M===n&&S.kind==="begin"||(S.kind==="begin"?c.push({name:S.name,from:M}):c.at(-1)?.name===S.name&&c.pop())}}return!1}function Li(t,n,o,s){const c=Mi(t,o,s);return!c||Pl(t,n,c.from,s)?null:c}function Nl(t,n){const o=t.doc.lineAt(n),s=Rr.exec(o.text.slice(0,Pr(o.text)));if(!s)return null;const c=Ar[s[1]],f={name:null};kt(o.text,0,f);for(let m=o.number+1;m<=t.doc.lines;m+=1){const g=t.doc.line(m),b=f.name!==null;if(kt(g.text,0,f),b||f.name)continue;const S=Rr.exec(g.text.slice(0,Pr(g.text)));if(S&&Ar[S[1]]<=c)return{from:o.to,to:Math.max(o.to,g.from-1)}}return o.to<t.doc.length?{from:o.to,to:t.doc.length}:null}function Dl(t,n){const o=t.doc.lineAt(n),s=kt(o.text).find(c=>c.kind==="begin");if(s){const c=Mi(t.doc,o.from+s.to,s.name);if(c&&c.from>o.to)return{from:o.to,to:c.from}}return Nl(t,n)}const Bl=ta.of((t,n)=>Dl(t,n));function Ti(t,n,o){const s=t.slice(0,n)+o+t.slice(n),c=n+o.length,f=s.lastIndexOf(`
|
|
121
|
-
`,Math.max(0,c-1))+1,m=s.indexOf(`
|
|
122
|
-
`,c);return{nextSource:s,cursor:c,prefix:s.slice(f,c),suffix:s.slice(c,m<0?s.length:m)}}function Ri(t){return t.suffix.trim()?null:t.prefix.match(/^([ \t]*)\\begin\s*\{\s*([A-Za-z][A-Za-z0-9*:_-]*)\s*\}\s*$/)}function Ai(t,n){const o=n[2],s=na.of(t.nextSource.split(`
|
|
123
|
-
`)),c=Ei(s,t.cursor);if(c!==null&&Li(s,c,t.cursor,o))return null;const f=n[1]+" ";return{insert:`
|
|
124
|
-
`+f+`
|
|
125
|
-
`+n[1]+"\\end{"+o+"}",cursorOffset:1+f.length,kind:"environment"}}function Pi(t){return t.suffix.trim()?null:t.prefix.match(/^(.*\\left\s*)(\\[{}]|[()[\]|.])\s*$/)}function Ni(t){const o={"(":"\\right)",")":"\\right(","[":"\\right]","]":"\\right[","|":"\\right|","\\{":"\\right\\}","\\}":"\\right\\{"}[t[2]];return o?{insert:o,cursorOffset:0,kind:"delimiter"}:null}function Fl(t,n,o,s){if(n!==o||!s)return null;const c=Ti(t,n,s),f=Ri(c),m=f?null:Pi(c);return!f&&!m||En(c.nextSource,c.cursor)?null:f?Ai(c,f):m?Ni(m):null}function Il(t,n){if(n<0||n>t.length)return null;const o=Ti(t,n,""),s=Ri(o),c=s?null:Pi(o);return!s&&!c||En(o.nextSource,o.cursor)?null:s?Ai(o,s):c?Ni(c):null}function $l(t,n,o,s,c){if(t.state.readOnly||t.composing||t.state.selection.ranges.length!==1)return!1;const f=Fl(t.state.doc.toString(),n,o,s);if(!f)return!1;const m=c();if(!m.docChanged)return!1;const g=m.newSelection.main.head;return t.dispatch(t.state.update(m,{sequential:!0,changes:{from:g,insert:f.insert},selection:{anchor:g+f.cursorOffset},annotations:ti.userEvent.of("input.type")})),!0}const Vl=Bt.transactionFilter.of(t=>{if(t.docChanged||!t.selection||!t.isUserEvent("input")||t.startState.readOnly||t.newSelection.ranges.length!==1||!t.newSelection.main.empty)return t;const n=t.newSelection.main.head,o=Il(t.newDoc.toString(),n);return o?[t,{sequential:!0,changes:{from:n,insert:o.insert},selection:{anchor:n+o.cursorOffset},userEvent:"input.complete"}]:t});function _l(t,n){const o=t[n],s=o==="{"?"}":")";if(o!=="{"&&o!=="(")return null;let c=0,f=0,m=!1;for(let g=n;g<t.length;g+=1){const b=t[g];if(b==="\\"&&g+1<t.length){g+=1;continue}if(o==="{"){if(b==="{"){c+=1;continue}if(b!=="}")continue;if(c-=1,c===0)return{from:n,to:g+1,contentFrom:n+1,contentTo:g};continue}if(m){b==='"'&&(m=!1);continue}if(f>0){b==="{"?f+=1:b==="}"&&(f-=1);continue}if(b==="{"){f=1;continue}if(b==='"'){m=!0;continue}if(b==="("){c+=1;continue}if(b===s&&(c-=1,c===0))return{from:n,to:g+1,contentFrom:n+1,contentTo:g}}return null}function Ql(t,n){let o=n.contentFrom;for(;o<n.contentTo&&/\s/.test(t[o]);)o+=1;if(o>=n.contentTo)return null;let s=o;for(;s<n.contentTo&&t[s]!==","&&!/\s/.test(t[s]);)s+=1;let c=s;for(;c>o&&/\s/.test(t[c-1]);)c-=1;if(c<=o)return null;const f=Ft(t,s);return f<n.contentTo&&t[f]!==","?null:{key:t.slice(o,c),from:o,to:c}}function jl(t){const n=[];let o=0;for(;o<t.length;){if(ri(t,o)){o=ii(t,o);continue}if(t[o]!=="@"){o+=1;continue}let s=o+1;for(;s<t.length&&/[A-Za-z]/.test(t[s]);)s+=1;if(s===o+1){o+=1;continue}let c=s;for(;c<t.length&&/\s/.test(t[c]);)c+=1;const f=_l(t,c);if(!f){o=s;continue}const m=t.slice(o+1,s).toLowerCase();if(m!=="string"&&m!=="preamble"&&m!=="comment"){const g=Ql(t,f);g&&n.push({...g,entryFrom:o,entryTo:f.to})}o=f.to}return n}const Kl={kind:"citation",argumentKind:"mandatory",maximumArguments:1},ql={kind:"citation",argumentKind:"mandatory",maximumArguments:Number.MAX_SAFE_INTEGER},zl={kind:"label",argumentKind:"mandatory",maximumArguments:1},Ul={kind:"label",argumentKind:"mandatory",maximumArguments:2},Xl={kind:"label",argumentKind:"optional",maximumArguments:1},Nr={href:null,hyperref:Xl,crefrange:Ul,citestyle:null,setcitestyle:null,newcites:null,citetext:null,declarecitecommand:null,declaremulticitecommand:null,declareautocitecommand:null,declarecitewrappercommand:null,declarecitepunctuation:null,declarecitedelimiter:null,declarecitedriver:null,declarecitealias:null,ateverycite:null,ateverycitekey:null,atnextcite:null,atnextcitekey:null};function Di(t){const n=t.toLowerCase();return Object.prototype.hasOwnProperty.call(Nr,n)?Nr[n]??null:n==="nocite"||n.includes("cite")?n.endsWith("cites")?ql:Kl:n==="ref"||n.endsWith("ref")?zl:null}function bn(t,n){const o=[],s=oi(t.slice(n.contentFrom,n.contentTo));let c=0;for(let f=0;f<=s.length;f+=1){if(f!==s.length&&s[f]!==",")continue;let m=c,g=f;for(;m<g&&/\s/.test(s[m]);)m+=1;for(;g>m&&/\s/.test(s[g-1]);)g-=1;if(g>m){const b=n.contentFrom+m,S=n.contentFrom+g;o.push({key:t.slice(b,S),from:b,to:S})}c=f+1}return o}function Hl(t,n,o){let s=n;for(let c=0;c<o.maximumArguments;c+=1){if(s=Ft(t,s),o.argumentKind==="optional"){if(t[s]!=="[")return null;const m=nn(t,s,"[","]");if(!m)return s+1;s=m.to;continue}for(;t[s]==="[";){const m=nn(t,s,"[","]");if(!m)return null;s=Ft(t,m.to)}if(t[s]!=="{")return null;const f=nn(t,s,"{","}");if(!f)return s+1;s=f.to}return null}function Wl(t,n){let o=n;for(let c=n;c<t.length;c+=1){if(ri(t,c)){c=ii(t,c)-1;continue}t[c]===","&&(o=c+1)}const s=Ft(t,o);return{from:s,query:t.slice(s)}}function Bi(t,n){let o=null;return Ln(t,s=>{const c=Di(s.name);if(!c||c.kind!==n)return;const f=Hl(t,s.to,c);f!==null&&(o=f)}),o===null?null:Wl(t,o)}function Zl(t){return Bi(t,"citation")}function Yl(t){return Bi(t,"label")}function Fi(t){const n=[];return Ln(t,o=>{const s=Di(o.name);if(!s)return;const c=s.argumentKind==="optional"?Ta(t,o.to,s.maximumArguments):dn(t,o.to,s.maximumArguments);for(const f of c)for(const m of bn(t,f))n.push({kind:s.kind,command:o.name,...m})}),n.sort((o,s)=>o.from-s.from||o.to-s.to)}function Gl(t,n){const o=[];return Ln(t,s=>{if(n==="label"&&(s.name==="label"||s.name==="hypertarget")){const c=dn(t,s.to,1)[0];if(!c)return;for(const f of bn(t,c))o.push({key:f.key,command:s.name,targetFrom:s.from,targetTo:c.to,source:"label"});return}if(n==="citation"&&s.name==="bibitem"){const c=dn(t,s.to,1)[0];if(!c)return;for(const f of bn(t,c))o.push({key:f.key,command:s.name,targetFrom:s.from,targetTo:c.to,source:"bibitem"})}}),o}function Jl(t){return jl(t).map(n=>({key:n.key,command:"bibtex",targetFrom:n.entryFrom,targetTo:n.entryTo,source:"bibtex"}))}function Dr(t,n,o=!1){return o?n==="citation"?Jl(t):[]:Gl(t,n)}const Br=new WeakMap;function St(t){let n=Br.get(t);return n===void 0&&(n=t.state.sliceDoc(0,t.pos),Br.set(t,n)),n}function ec(t){return St(t)}function on(t,n,o=!1){const c=St(t).match(n);if(!c||c.index===void 0)return null;const f={from:t.pos-c[1].length,query:c[1]};return o?ic(f):f}function tc(t){const o=St(t).match(/\\(begin|end)\s*\{([^{}]*)$/);return!o||o.index===void 0?null:{from:t.pos-o[2].length,query:o[2],command:o[1]}}function nc(t){return Zl(St(t))}function rc(t){return Yl(St(t))}function ic(t){const n=t.query.lastIndexOf(","),o=t.query.slice(n+1),s=o.match(/^\s*/)?.[0].length??0;return{from:t.from+n+1+s,query:o.slice(s)}}function oc(t,n,o,s,c="begin"){const f=t.sliceString(o,o+1)==="}"?1:0,m=`${s}}`,g=Ei(t,n),b=g===null?null:Li(t,g,o+f,s);if(c==="end"||b)return{to:o+f,insert:m,cursor:n+m.length,reusesExistingEnd:!0};const M=t.lineAt(n).text.match(/^\s*/)?.[0]??"";return{to:o+f,insert:`${m}
|
|
126
|
-
${M}
|
|
127
|
-
${M}\\end{${s}}`,cursor:n+m.length+1+M.length+1,reusesExistingEnd:!1}}function ac(t,n){let o=n;for(;/[ \t\r\n]/.test(t[o]??"");)o+=1;return o}function kn(t,n,o="{",s="}"){const c=ac(t,n);if(t[c]!==o)return null;let f=1;for(let m=c+1;m<t.length;m+=1){if(t[m]==="\\"){m+=1;continue}if(t[m]===o)f+=1;else if(t[m]===s&&--f===0)return{from:c,to:m+1,content:t.slice(c+1,m)}}return null}function an(t,n){if(n.length!==0)return t+n.map((o,s)=>{const c=`\${${s+1}}`;return o.optional?`[${c}]`:`{${c}}`}).join("")}function Fr(t,n){return!Number.isFinite(t)||t<=0?[]:n?[{optional:!0},...Array.from({length:Math.max(0,t-1)},()=>({optional:!1}))]:Array.from({length:t},()=>({optional:!1}))}function sc(t){const n=[];for(let o=0;o<t.length;){const s=t[o];if(/[ \t\r\n+\-!]/.test(s)){o+=1;continue}if(s==="m"){n.push({optional:!1}),o+=1;continue}if(s==="o"){n.push({optional:!0}),o+=1;continue}if(s==="O"){const c=kn(t,o+1);if(!c)return null;n.push({optional:!0}),o=c.to;continue}return null}return n}const lc=/\\(?:NewDocumentCommand|RenewDocumentCommand|ProvideDocumentCommand|DeclareDocumentCommand|DeclareExpandableDocumentCommand|RenewExpandableDocumentCommand|ProvideExpandableDocumentCommand)\b/g;function cc(t){const n=[];for(const o of t.matchAll(lc)){const s=kn(t,o.index+o[0].length);if(!s)continue;const c=/^\s*\\([A-Za-z@][A-Za-z@0-9:_]*)\s*$/.exec(s.content)?.[1];if(!c)continue;const f=kn(t,s.to);f&&n.push({name:c,specification:f.content})}return n}const uc=["\\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 fc(){return[...uc.map(t=>({label:t,type:"keyword"})),ie("\\section{${title}}",{label:"\\section"}),ie("\\subsection{${title}}",{label:"\\subsection"}),ie("\\textbf{${text}}",{label:"\\textbf"}),ie("\\emph{${text}}",{label:"\\emph"}),ie("\\cite{${key}}",{label:"\\cite"}),ie("\\ref{${label}}",{label:"\\ref"}),ie("\\label{${label}}",{label:"\\label"}),ie("\\includegraphics[width=${0.8}\\textwidth]{${file}}",{label:"\\includegraphics"}),ie(`\\begin{itemize}
|
|
128
|
-
\\item \${item}
|
|
129
|
-
\\end{itemize}`,{label:"\\begin{itemize}"}),ie(`\\begin{enumerate}
|
|
130
|
-
\\item \${item}
|
|
131
|
-
\\end{enumerate}`,{label:"\\begin{enumerate}"}),ie(`\\begin{equation}
|
|
132
|
-
\${equation}
|
|
133
|
-
\\end{equation}`,{label:"\\begin{equation}"}),ie(`\\begin{figure}[htbp]
|
|
134
|
-
\\centering
|
|
135
|
-
\${content}
|
|
136
|
-
\\caption{\${caption}}
|
|
137
|
-
\\label{fig:\${label}}
|
|
138
|
-
\\end{figure}`,{label:"\\begin{figure}"})]}function dc(t){const n=[],o=[],s=[],c=[],f=[],m=[],g=oi(Ra(t)),b=(S,M,A,P,E)=>{M&&!S.some(T=>T.label===M)&&S.push({label:M,detail:A,kind:P,source:"Current file",...E?{apply:E}:{}})};for(const S of g.matchAll(/\\(?:newcommand|renewcommand|providecommand|DeclareRobustCommand)\s*\*?\s*(?:\{\s*)?\\([A-Za-z@][A-Za-z@0-9:_]*)\s*(?:\})?\s*(?:\[(\d+)\])?(?:\s*(\[[^\]]*\]))?/g)){const M=Fr(Number.parseInt(S[2]??"0",10),!!S[3]);b(n,`\\${S[1]}`,"Project command","function",an(`\\${S[1]}`,M))}for(const S of cc(g)){const M=sc(S.specification);b(n,`\\${S.name}`,"Project command","function",M?an(`\\${S.name}`,M):void 0)}for(const S of g.matchAll(/\\(?:def|gdef|edef|xdef)\s*\\([A-Za-z@][A-Za-z@0-9:_]*)((?:\s*#\d+)*)/g)){const M=[...(S[2]??"").matchAll(/#\d+/g)].length;b(n,`\\${S[1]}`,"Project macro","function",an(`\\${S[1]}`,Fr(M,!1)))}for(const S of g.matchAll(/\\DeclarePairedDelimiter\s*\{?\\([A-Za-z@][A-Za-z@0-9:_]*)\}?/g))b(n,`\\${S[1]}`,"Project math delimiter","function");for(const S of g.matchAll(/\\cs_(?:new|set|gset|provide|generate)(?:_protected)?\:[A-Za-z]+\s+\\([A-Za-z@][A-Za-z@0-9:_]*)/g))b(n,`\\${S[1]}`,"Expl3 project command","function");for(const S of g.matchAll(/\\(?:newenvironment|renewenvironment|NewDocumentEnvironment|RenewDocumentEnvironment|DeclareDocumentEnvironment)\s*\*?\s*\{([^}]+)\}/g))b(o,S[1].trim(),"Project environment","keyword");for(const S of Dr(t,"label"))S.source==="label"&&b(s,S.key,"Label","constant");for(const S of g.matchAll(/\\(?:usepackage|RequirePackage)\s*(?:\[[^\]]*\])?\s*\{([^}]+)\}/g))for(const M of S[1].split(","))b(f,M.trim(),"Package","text");for(const S of g.matchAll(/\\(?:input|include|subfile)\s*(?:\{([^}]+)\}|\s+([^\s%]+))/g))b(m,(S[1]??S[2]??"").trim(),"Project file","text");for(const S of Dr(t,"citation"))S.source==="bibitem"&&b(c,S.key,"Bibliography key","constant");return{commands:n,environments:o,labels:s,citations:c,packages:f,classes:[],files:m}}function hc(t){return(t?.citations??[]).filter(n=>/\.bib$/i.test(n.source??""))}const Ir=new WeakMap;function pc(t){const n=t.state.doc,o=Ir.get(n);if(o)return o;const s=dc(t.state.doc.toString());return Ir.set(n,s),s}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 mc(t,n,o=!0){const s=$r[t.detail],c=t.source?$r[t.source]:void 0,f=t.detail.match(/^Project command \((\d+) arguments?\)$/),m=t.source==="LaTeX"?"":f?n("completions.projectCommandArgs",{count:Number(f[1])}):s?n(`completions.${s}`):t.source==="LaTeX"?n("completions.standard"):t.detail,g=t.source==="LaTeX"?"":c?n(`completions.${c}`):t.source,b=g&&m?`${m} · ${g}`:m||g||void 0,S={label:t.label,type:t.kind,...b?{detail:b}:{},...t.info?{info:t.info}:{}};return o&&t.apply?ie(t.apply,S):S}function ot(t,...n){const o=[],s=new Set;for(const c of n)for(const f of c){const m="kind"in f?mc(f,t):f;s.has(m.label)||(s.add(m.label),o.push(m))}return o}function Vr(t){return t.map(({detail:n,...o})=>o)}function _r(t){return t.map(({apply:n,...o})=>o)}function gc(t,n){return{...t,apply(o,s,c,f){const m=s.label,g=oc(o.state.doc,c,f,m,n);o.dispatch({changes:{from:c,to:g.to,insert:g.insert},selection:{anchor:g.cursor},annotations:[ra.of(s),ti.userEvent.of("input.complete")]})}}}function vc(t,n,o){const s=()=>pc(t),c=()=>En(ec(t),t.pos)!==null,f=tc(t);if(f){if(c())return null;const P=ot(n,_r(s().environments),_r(o?.environments??[]));return{from:f.from,options:Vr(P.map(E=>gc(E,f.command))),validFor:/^[A-Za-z0-9*:_-]*$/}}const m=rc(t);if(m&&c())return null;if(m)return{from:m.from,options:ot(n,s().labels,o?.labels??[]),validFor:/^[^,{}\s]*$/};const g=nc(t);if(g&&c())return null;if(g)return{from:g.from,options:ot(n,s().citations,hc(o)),validFor:/^[^,{}\s]*$/};const b=on(t,/\\(?:input|include|subfile|includegraphics|bibliography|addbibresource)(?:\s*\[[^\]]*\])*\s*\{([^{}]*)$/);if(b&&c())return null;if(b)return{from:b.from,options:ot(n,s().files,o?.files??[]),validFor:/^[^{}]*$/};const S=on(t,/\\(?:usepackage|RequirePackage)(?:\s*\[[^\]]*\])*\s*\{([^{}]*)$/,!0);if(S&&c())return null;if(S)return{from:S.from,options:ot(n,s().packages,o?.packages??[]),validFor:/^[^,{}\s]*$/};const M=on(t,/\\documentclass(?:\s*\[[^\]]*\])*\s*\{([^{}]*)$/);if(M&&c())return null;if(M)return{from:M.from,options:ot(n,o?.classes??[]),validFor:/^[^{}]*$/};const A=t.matchBefore(/\\(?:[A-Za-z@0-9:_]*(?:\*)?|[,;!:])$/);return(A||t.explicit)&&c()?null:A||t.explicit?{from:A?.from??t.pos,options:Vr(ot(n,s().commands,o?.commands??[],fc())),validFor:/^\\(?:[A-Za-z@0-9:_]*(?:\*)?|[,;!:])$/}:null}class yc{constructor(n=Fi){this.scan=n}scan;document=null;references=[];referencesFor(n){return n!==this.document&&(this.document=n,this.references=this.scan(n.toString())),this.references}referencesIn(n,o){return Ii(this.referencesFor(n),o)}clear(){this.document=null,this.references=[]}}function bc(t,n,o=1024){if(t.length===0)return[];const s=(n.length?n:[{from:0,to:t.length}]).map(f=>{const m=Math.max(0,f.from-o),g=Math.min(t.length,f.to+o),b=t.lineAt(m).from,S=Math.max(m,Math.max(0,g-1)),M=t.lineAt(S).to;return{from:b,to:M}}).sort((f,m)=>f.from-m.from),c=[];for(const f of s){const m=c.at(-1);m&&f.from<=m.to?m.to=Math.max(m.to,f.to):c.push(f)}return c}function Ii(t,n){if(t.length===0||n.length===0)return[];const o=[];for(const s of n)for(let c=kc(t,s.from);c<t.length;c+=1){const f=t[c];if(f.from>=s.to)break;f.to<=s.to&&o.push(f)}return o}function kc(t,n){let o=0,s=t.length;for(;o<s;){const c=o+Math.floor((s-o)/2);t[c].from<n?o=c+1:s=c}return o}const On=It.define(),Qr=Sn.define();class Oc extends xa{constructor(n){super(),this.label=n}label;toDOM(){const n=document.createElement("button");n.type="button",n.tabIndex=-1,n.className="cm-comment-add-button",n.dataset.commentAdd="true",n.dataset.texliteTooltipAlways="true",n.title=this.label,n.setAttribute("aria-label",this.label);const o=document.createElementNS("http://www.w3.org/2000/svg","svg");o.setAttribute("viewBox","0 0 24 24"),o.setAttribute("aria-hidden","true");const s=document.createElementNS("http://www.w3.org/2000/svg","path");return s.setAttribute("d","M20 3H4a2 2 0 0 0-2 2v14l4-4h14a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2Zm-3 7h-4v4h-2v-4H7V8h4V4h2v4h4v2Z"),o.append(s),n.append(o),n}}function jr(t,n){const o=t.selection.main;return o.empty?cn.empty:cn.of([n.range(t.doc.lineAt(o.from).from)])}function Cc(t,n){const o=new Oc(t);return[Ct.define({create:c=>jr(c,o),update:(c,f)=>f.selection||f.docChanged?jr(f.state,o):c,provide:c=>Oa.from(c)}),Ca({domEventHandlers:{mousedown(c,f,m){const g=m.target;if(!(g instanceof Element)||!g.closest("[data-comment-add]"))return!1;const b=c.state.selection.main;return b.empty?!1:(n(c.state.sliceDoc(b.from,b.to),b.from,b.to,c.state.doc.toString()),!0)}}})]}const wc={undo:()=>!1,redo:()=>!1},Nn=$t.define({combine:t=>t.at(-1)??wc});Be.defineAction("texliteUndo",t=>{t.cm6.state.facet(Nn).undo()||t.execCommand("undo")});Be.defineAction("texliteRedo",t=>{t.cm6.state.facet(Nn).redo()||t.execCommand("redo")});Be.mapCommand("u","action","texliteUndo",{},{context:"normal"});Be.mapCommand("<C-r>","action","texliteRedo",{},{context:"normal"});const Sc=Ct.define({create:()=>J.none,update(t,n){let o=t.map(n.changes);for(const s of n.effects)s.is(On)&&(o=Nc(s.value,n.state.doc.length));return o},provide:t=>pe.decorations.from(t)}),$i=It.define(),xc=Ct.define({create:()=>J.none,update(t,n){let o=t.map(n.changes);n.docChanged&&(o=J.none);for(const s of n.effects)s.is($i)&&(o=Pc(s.value,n.state.doc.length));return o},provide:t=>pe.decorations.from(t)}),Cn=It.define(),Mc=J.mark({class:"cm-spell-error-active"}),Ec=Ct.define({create:()=>J.none,update(t,n){let o=t.map(n.changes);n.docChanged&&(o=J.none);for(const s of n.effects){if(!s.is(Cn))continue;const c=s.value;o=c&&c.to>c.from?J.set([Mc.range(c.from,c.to)]):J.none}return o},provide:t=>pe.decorations.from(t)}),Lc={enabled:!1,title:()=>""},Ot=$t.define({combine:t=>t.at(-1)??Lc}),Tc=dt.fromClass(class{constructor(t){this.view=t,this.scrollTop=t.scrollDOM.scrollTop,this.scrollLeft=t.scrollDOM.scrollLeft,this.decorations=sn(t,null)}view;decorations;cache=null;viewportDocument=null;viewportChanges=0;scrollTop;scrollLeft;update(t){const n=t.startState.facet(Ot)!==t.state.facet(Ot);if(!t.docChanged&&!t.viewportChanged&&!n)return;const o=t.viewportChanged&&(this.view.scrollDOM.scrollTop!==this.scrollTop||this.view.scrollDOM.scrollLeft!==this.scrollLeft);if(this.scrollTop=this.view.scrollDOM.scrollTop,this.scrollLeft=this.view.scrollDOM.scrollLeft,t.docChanged){this.cache?.clear(),this.cache=null,this.viewportDocument=null,this.viewportChanges=0,this.decorations=sn(this.view,null);return}o&&(this.viewportDocument!==t.state.doc&&(this.viewportDocument=t.state.doc,this.viewportChanges=0),this.viewportChanges+=1,this.viewportChanges>=2&&(this.cache??=new yc)),this.decorations=sn(this.view,this.cache)}},{decorations:t=>t.decorations});function sn(t,n){const o=t.state.facet(Ot);if(!o.enabled||t.state.doc.length===0)return J.none;const s=bc(t.state.doc,t.visibleRanges),c=n?n.referencesIn(t.state.doc,s):Ii(Fi(t.state.sliceDoc(0,s.reduce((g,b)=>Math.max(g,b.to),0))),s),f=[],m=new Set;for(const g of c){const b=g.from,S=g.to,M=[g.kind,g.key,String(b),String(S)].join(":");m.has(M)||S<=b||(m.add(M),f.push(J.mark({class:g.kind==="citation"?"cm-latex-citation-key":"cm-latex-label-key",attributes:{title:o.title(g),spellcheck:"false","data-latex-reference-kind":g.kind,"data-latex-reference-key":g.key,"data-latex-reference-from":String(b),"data-latex-reference-to":String(S),"data-latex-reference-command":g.command}}).range(b,S)))}return f.length?J.set(f,!0):J.none}function Kr(t){if(!(t instanceof HTMLElement))return null;const n=t.closest("[data-latex-reference-kind][data-latex-reference-key]"),o=n?.dataset.latexReferenceKind,s=n?.dataset.latexReferenceKey;return o!=="citation"&&o!=="label"||!s?null:{kind:o,key:s,from:Number(n.dataset.latexReferenceFrom)||0,to:Number(n.dataset.latexReferenceTo)||0,command:n.dataset.latexReferenceCommand??""}}function Kc({value:t,filePath:n,readOnly:o,comments:s,focusComment:c,preferences:f,completionIndex:m,jumpTo:g,searchRequest:b,nativeSpellCheck:S,spellCheckIssues:M,spellCheckJump:A,collaboration:P,onChange:E,onSelection:T,onAddComment:R,onCommentClick:_,onSpellCheckReplace:U,onReferenceNavigate:ee,onCursor:te}){const{t:q,i18n:le}=To(),Oe=Y.useRef(null),H=Y.useRef(null),je=Y.useRef(E),et=Y.useRef(T),Te=Y.useRef(R),Ke=Y.useRef(_),tt=Y.useRef(U),be=Y.useRef(ee),xt=Y.useRef(te),ht=Y.useRef(M),Mt=Y.useRef(b),qe=Y.useRef(m),N=Y.useRef(new At),pt=Y.useRef(new At),st=Y.useRef(new At),He=Y.useRef(new At),me=Y.useRef(null),[We,Ze]=Y.useState(f.vimMode?"NORMAL":""),[W,ze]=Y.useState(null);je.current=E,et.current=T,Te.current=R,Ke.current=_,tt.current=U,be.current=ee,xt.current=te,ht.current=M,qe.current=m;const Ye=(I,G)=>{if(me.current?.(),me.current=null,!G){Ze("");return}const Z=pi(I);if(!Z){Ze("NORMAL");return}const ce=()=>{const Q=Z.state.vim?.mode??(Z.state.vim?.insertMode?"insert":"normal");Ze(Q.toUpperCase())};ce(),Z.on("vim-mode-change",ce),me.current=()=>Z.off("vim-mode-change",ce)};return Y.useEffect(()=>{if(!Oe.current)return;const I=/\.bib$/i.test(n),G=/\.bst$/i.test(n),Z=P&&!o?P.undoManager??null:null,ce=Bt.create({doc:P?.text.toString()??t,extensions:[Cc(q("editor.addComment"),(...Q)=>Te.current(...Q)),ia(),...P?[]:[oa()],aa(),sa(),la(),I?[hl,...Ci(dl(q))]:G?xs:Cl,dr(Sa),...I?[dr(As)]:[],...I?[]:[ei(),...G?[]:[Wr.high(pe.inputHandler.of($l)),Vl,Bl]],ca(),ua(),Sc,xc,Ec,pt.current.of(G?[]:Ot.of(zr(n,q))),...G?[]:[Tc],st.current.of(f.mathPreviewOnHover&&Lr(n)?Tr({loading:q("editor.mathPreviewLoading"),unavailable:q("editor.mathPreviewUnavailable"),preview:q("editor.mathPreview")}):[]),fa({top:!1}),Ac(q),Bt.phrases.of(Rc(q)),da({override:I?[fl]:G?[]:[Q=>vc(Q,q,qe.current)],activateOnTyping:!0}),...Z?[Nn.of({undo:()=>Z.undo()!==null,redo:()=>Z.redo()!==null})]:[],He.current.of(f.vimMode?br():[]),ha.of([...pa,...ma,...ga,...va,...P&&!o?vs:[],...ya,...P?[]:ba]),...P?[ys(P.text,P.awareness,{undoManager:Z??!1})]:[],Bt.readOnly.of(o),N.current.of(qr(f,S)),pe.domEventHandlers({mousedown(Q){const ue=Kr(Q.target);return!ue||!(Q.ctrlKey||Q.metaKey)?!1:(Q.preventDefault(),be.current(ue),!0)},mousemove(Q,ue){const fe=Kr(Q.target);return ue.dom.classList.toggle("cm-reference-navigation-active",!!(fe&&(Q.ctrlKey||Q.metaKey))),!1},mouseleave(Q,ue){return ue.dom.classList.remove("cm-reference-navigation-active"),!1},click(Q){const ue=Q.target.closest("[data-comment-id]");return ue?.dataset.commentId&&Ke.current(ue.dataset.commentId),!1},contextmenu(Q){const ue=Q.target.closest("[data-spell-error]");if(!ue)return!1;const fe=Number(ue.dataset.spellFrom),oe=Number(ue.dataset.spellTo),mt=ht.current.find(Et=>Et.from===fe&&Et.to===oe);if(!mt)return!1;Q.preventDefault();const Re=250,Kt=Math.min(300,100+mt.suggestions.length*34);return ze({issue:mt,left:Math.max(8,Math.min(Q.clientX,window.innerWidth-Re-8)),top:Math.max(8,Math.min(Q.clientY,window.innerHeight-Kt-8))}),!0},blur(Q,ue){const fe=ue.state.selection.main;return et.current(ue.state.sliceDoc(fe.from,fe.to),fe.from,fe.to),P?.awareness.setLocalStateField("cursor",null),!1}}),pe.updateListener.of(Q=>{const ue=Q.transactions.some(fe=>fe.annotation(Qr));if(Q.docChanged&&!ue&&!P&&je.current(Q.state.doc.toString()),Q.docChanged&&ze(null),Q.selectionSet||Q.docChanged){const fe=Q.state.selection.main;et.current(Q.state.sliceDoc(fe.from,fe.to),fe.from,fe.to);const oe=Q.state.doc.lineAt(fe.head);xt.current(oe.number,fe.head-oe.from+1,fe.head)}})]});return H.current=new pe({state:ce,parent:Oe.current}),Ye(H.current,f.vimMode),H.current.dispatch({effects:On.of(Ur(s,n))}),()=>{me.current?.(),me.current=null,H.current?.destroy(),H.current=null}},[n,o,le.resolvedLanguage,P?.text]),Y.useEffect(()=>{const I=H.current;I&&(I.dispatch({effects:[N.current.reconfigure(qr(f,S)),pt.current.reconfigure(/\.bst$/i.test(n)?[]:Ot.of(zr(n,q))),st.current.reconfigure(f.mathPreviewOnHover&&Lr(n)?Tr({loading:q("editor.mathPreviewLoading"),unavailable:q("editor.mathPreviewUnavailable"),preview:q("editor.mathPreview")}):[]),He.current.reconfigure(f.vimMode?br():[])]}),Ye(I,f.vimMode))},[f,S,n,le.resolvedLanguage]),Y.useEffect(()=>{const I=H.current;if(!I)return;const G=I.state.doc.toString(),Z=M.filter(ce=>ce.from>=0&&ce.to<=G.length&&ce.to>ce.from);I.dispatch({effects:[$i.of(Z),Cn.of(null)]})},[M]),Y.useEffect(()=>{ze(null)},[M]),Y.useEffect(()=>{if(!W)return;const I=H.current,G=Q=>{Q.target instanceof Element&&Q.target.closest(".spell-suggestions-menu")||ze(null)},Z=Q=>{Q.key==="Escape"&&ze(null)},ce=()=>ze(null);return document.addEventListener("mousedown",G,!0),document.addEventListener("keydown",Z,!0),I?.scrollDOM.addEventListener("scroll",ce,{passive:!0}),()=>{document.removeEventListener("mousedown",G,!0),document.removeEventListener("keydown",Z,!0),I?.scrollDOM.removeEventListener("scroll",ce)}},[W,n]),Y.useEffect(()=>{const I=H.current;P||!I||I.state.doc.toString()===t||I.dispatch({changes:{from:0,to:I.state.doc.length,insert:t},annotations:Qr.of(!0)})},[t,P]),Y.useEffect(()=>{H.current?.dispatch({effects:On.of(Ur(s,n))})},[s,n]),Y.useEffect(()=>{const I=H.current;if(!I||!c||c.filePath!==n||c.orphaned)return;const G=Math.min(c.startOffset,I.state.doc.length),Z=Math.min(Math.max(G,c.endOffset),I.state.doc.length);I.dispatch({selection:{anchor:G,head:Z},effects:pe.scrollIntoView(G,{y:"center"})}),I.focus()},[n,c]),Y.useEffect(()=>{const I=H.current;if(!I||!g)return;const G=Math.max(1,Math.min(I.state.doc.lines,g.line)),Z=I.state.doc.line(G),ce=Math.min(Z.to,Z.from+Math.max(0,g.column-1));I.dispatch({selection:{anchor:Z.from,head:Z.to},effects:pe.scrollIntoView(ce,{y:"center",yMargin:60})}),I.focus()},[g?.nonce]),Y.useEffect(()=>{const I=H.current;if(!I||!A)return;const G=Math.max(0,Math.min(A.from,I.state.doc.length)),Z=Math.max(G,Math.min(A.to,I.state.doc.length));I.dispatch({selection:{anchor:G},effects:[Cn.of({from:G,to:Z}),pe.scrollIntoView(G,{y:"center",yMargin:60})]}),I.focus()},[A?.nonce]),Y.useEffect(()=>{const I=H.current;!I||b===0||b===Mt.current||(Mt.current=b,ka(I))},[b]),Ve.jsxs("div",{className:"editor-shell",style:{fontFamily:Aa(f.font),fontSize:`${f.fontSize}px`,lineHeight:f.lineHeight},children:[Ve.jsx("div",{className:"editor-host",ref:Oe}),W&&Ve.jsxs("div",{className:"spell-suggestions-menu",role:"menu","aria-label":q("editor.writingSuggestions"),onMouseDown:I=>I.stopPropagation(),children:[Ve.jsx("div",{className:"spell-suggestions-title",children:q("editor.writingSuggestions")}),W.issue.message&&Ve.jsx("div",{className:"spell-suggestions-message",children:W.issue.message}),W.issue.suggestions.map((I,G)=>Ve.jsx("button",{type:"button",role:"menuitem",disabled:o,title:o?q("editor.spellCheckReadOnly"):q("editor.replaceWith",{word:I||q("editor.removeText")}),onClick:()=>{tt.current(W.issue,I),ze(null)},children:I||q("editor.removeText")},`${I}-${G}`)),W.issue.suggestions.length===0&&Ve.jsx("span",{className:"spell-suggestions-empty",children:q("editor.noWritingSuggestions")}),o&&W.issue.suggestions.length>0&&Ve.jsx("span",{className:"spell-suggestions-readonly",children:q("editor.spellCheckReadOnly")})]}),f.vimMode&&Ve.jsx("div",{className:"vim-editor-status",role:"status","aria-live":"polite",children:Ve.jsxs("span",{children:["--",We||"NORMAL","--"]})})]})}function Rc(t){return{Find:t("editor.search.find"),Replace:t("editor.search.replace"),next:t("editor.search.next"),previous:t("editor.search.previous"),all:t("editor.search.all"),"match case":t("editor.search.matchCase"),regexp:t("editor.search.regexp"),"by word":t("editor.search.wholeWord"),replace:t("editor.search.replaceNext"),"replace all":t("editor.search.replaceAll"),close:t("common.close"),"current match":t("editor.search.currentMatch"),"on line":t("editor.search.onLine"),"replaced match on line $":t("editor.search.replacedMatchOnLine"),"replaced $ matches":t("editor.search.replacedMatches"),"Go to line":t("editor.search.goToLine"),go:t("editor.search.go")}}function Ac(t){return dt.fromClass(class{constructor(n){this.view=n,this.document=n.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(!wa(this.view.state))return;const n=this.view.dom.querySelector(".cm-panel.cm-search");if(!n)return;let o=n.querySelector(".cm-search-count");if(!o){o=document.createElement("span"),o.className="cm-search-count",o.setAttribute("role","status"),o.setAttribute("aria-live","polite");const f=n.querySelector("[name=close]");n.insertBefore(o,f)}const s=Ma(this.view.state),c=ks(s);(this.document!==this.view.state.doc||this.signature!==c)&&(this.document=this.view.state.doc,this.signature=c,this.count=bs(this.view.state,s)),o.textContent=s.search?s.valid?this.count===0?t("editor.search.noMatches"):t("editor.search.matchCount",{count:this.count}):t("editor.search.invalidQuery"):""}})}function qr(t,n){return[pe.contentAttributes.of({spellcheck:n?"true":"false",autocorrect:"off",autocapitalize:"off",autocomplete:"off",lang:"en-US"}),pe.theme({"&":{fontSize:`${t.fontSize}px`},".cm-scroller":{fontFamily:"inherit",lineHeight:"inherit"},".cm-content":{fontFamily:"inherit",fontSize:"inherit"},".cm-gutters":{fontFamily:"inherit",fontSize:"inherit"}}),t.lineWrapping?pe.lineWrapping:[]]}function zr(t,n){return{enabled:/\.(?:tex|sty|cls)$/i.test(t),title:s=>s.kind==="citation"?n("editor.citationJumpHint",{key:s.key}):n("editor.labelJumpHint",{key:s.key})}}function Pc(t,n){const o=t.map(s=>({from:Math.max(0,Math.min(n,s.from)),to:Math.max(0,Math.min(n,s.to)),word:s.word,kind:s.kind,message:s.message})).filter(s=>s.to>s.from).sort((s,c)=>s.from-c.from||s.to-c.to);return J.set(o.map(s=>J.mark({class:s.kind==="spelling"?"cm-spell-error":"cm-grammar-warning",attributes:{title:s.message||s.word,"data-spell-error":"true","data-spell-kind":s.kind,"data-spell-from":String(s.from),"data-spell-to":String(s.to)}}).range(s.from,s.to)),!0)}function Ur(t,n){return t.filter(o=>o.filePath===n).map(o=>({id:o.id,from:o.startOffset,to:o.endOffset,resolved:o.resolved,orphaned:o.orphaned}))}function Nc(t,n){const o=t.filter(s=>!s.orphaned&&!s.resolved).flatMap(s=>{const c=Math.max(0,Math.min(n,s.from)),f=Math.max(c,Math.min(n,s.to)),m="cm-source-comment";return c===f?[J.widget({widget:new Xr(s.id,m),side:1}).range(c)]:[J.mark({class:m}).range(c,f),J.widget({widget:new Xr(s.id,m),side:1}).range(f)]});return J.set(o,!0)}class Xr extends Yr{constructor(n,o){super(),this.id=n,this.className=o}id;className;toDOM(){const n=document.createElement("span");return n.className=`${this.className} cm-comment-pin`,n.dataset.commentId=this.id,n.textContent="●",n}}export{Kc as LatexEditor};
|