"use strict";(self.webpackChunk_jupyter_lsp_jupyterlab_lsp=self.webpackChunk_jupyter_lsp_jupyterlab_lsp||[]).push([[240,624],{5240:(t,e,o)=>{o.r(e),o.d(e,{CodeJumper:()=>a,FileEditorJumper:()=>h,NotebookJumper:()=>p});const i=[];class n{store(t){i.push(t)}recollect(){return i.pop()}}var s=o(4352),r=o(424);const l=["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"],d=["Alt","AltGraph","Control","Shift"],c=["F1","F2","F3","F4","F5","F6","F7","F8","F9","F10","F11","F12","ContextMenu"];class a{goToPosition(t,e,o,i,n=0){let s,r={line:i,column:o};s=new(u.get(e))(t,this.documentManager);let l=s.getJumpPosition(r,n);s.jump(l)}_globalJump(t){let e=this.documentManager.openOrReveal(t.contentsPath);if(!e)return void console.log("Widget failed to open for jump");let o=t.isSymlink;e.revealed.then((()=>{this.goToPosition(e,t.contentsPath.endsWith(".ipynb")?"notebook":"fileeditor",t.column,t.line,t.editorIndex),o&&this.protectFromAccidentalEditing(e)})).catch(console.warn)}protectFromAccidentalEditing(t){let e=t.content.editor,o=!0;e.injectExtension(s.EditorView.domEventHandlers({keydown:t=>!!o&&(-1===l.indexOf(t.key)&&-1===d.indexOf(t.key)&&-1===c.indexOf(t.key)&&(("c"!==t.key||!t.ctrlKey)&&((0,r.showDialog)({title:"Edit external file?",body:"This file is located outside of the root of the JupyterLab start directory. do you really wish to edit it?",buttons:[r.Dialog.cancelButton({label:"Cancel"}),r.Dialog.warnButton({label:"Edit anyway"})]}).then((t=>{t.button.accept&&(o=!1)})).catch(console.warn),!0)))}))}globalJumpBack(){let t=this.history.recollect();t&&this._globalJump(t)}globalJump(t){const e=this.getCurrentPosition();this.history.store(e),this._globalJump(t)}}let u=new Map;class h extends a{constructor(t,e){super(),this.widget=t,this.documentManager=e,this.editor=t.content,this.history=new n}get path(){return this.widget.context.path}get editors(){return[this.editor.editor]}jump(t){let{token:e}=t,o=this.editor.editor.getPositionAt(e.offset);this.editor.editor.setSelection({start:o,end:o}),this.editor.editor.focus()}getOffset(t){return this.editor.editor.getOffsetAt(t)}getJumpPosition(t){return{token:{offset:this.getOffset(t),value:""},index:0}}getCurrentPosition(){let t=this.editor.editor.getCursorPosition();return{editorIndex:0,line:t.line,column:t.column,contentsPath:this.editor.context.path,isSymlink:!1}}}u.set("fileeditor",h);class p extends a{constructor(t,e){super(),this.widget=t,this.notebook=t.content,this.history=new n,this.documentManager=e}get editors(){return this.notebook.widgets.map((t=>t.editor))}jump(t){let{token:e,index:o}=t;setTimeout((()=>{this.notebook.deselectAll(),this.notebook.activeCellIndex=o,function(t,e=!1){let o=t.activeCell;"edit"===t.mode&&o&&o.editor&&(o.editor.hasFocus()||o.editor.focus()),e&&!t.node.contains(document.activeElement)&&t.node.focus()}(this.notebook),this.notebook.mode="edit";let t=this.notebook.activeCell.editor,i=t.getPositionAt(e.offset);t.setSelection({start:i,end:i})}),0)}getOffset(t,e=0){return this.editors[e].getOffsetAt(t)}getCurrentPosition(){let t=this.editors[this.notebook.activeCellIndex].getCursorPosition();return{editorIndex:this.notebook.activeCellIndex,line:t.line,column:t.column,contentsPath:this.widget.context.path,isSymlink:!1}}getJumpPosition(t,e){return{token:{offset:this.getOffset(t,e),value:""},index:e}}}u.set("notebook",p)}}]);
//# sourceMappingURL=240.134dfe868d23d9df1461.js.map?v=134dfe868d23d9df1461