varOS;!function(t){lete,i;!function(e){leti;!function(e){classiextendst.API.VFS.BaseFileHandle{constructor(t){super(""),this.path=`${t[0].path} -> ${t[1].path}`,this.cache=t,this.basename=`${t[0].basename} -> ${t[1].basename}`,this.info={type:"file",mime:void0,size:0,name:this.basename,path:this.path},this.ready=!0}meta(){returnnewPromise(async(t,e)=>{try{awaitPromise.all([this.cache[0].meta(),this.cache[1].meta]),t({result:this.info,error:!1})}catch(t){e(t)}})}_rd(t){returnnewPromise(async(t,e)=>{try{this.cache[0].cache=awaitthis.cache[0].read(),this.cache[1].cache=awaitthis.cache[1].read(),t(this.cache)}catch(t){e(t)}})}_wr(t){returnnewPromise((t,e)=>{t({result:!0,error:!1})})}setPath(t){}}e.DiffEditorFileHandle=i}(i=e.VFS||(e.VFS={}))}(e=t.API||(t.API={})),function(t){t.BaseEditorModel=class{constructor(t,e,i){this.container=i,this.currfile="Untitled".asFileHandle(),this.tabbar=e,this.editorSetup(i),this.app=t,this.editormux=!1,this.onstatuschange=void0,this.on("focus",()=>{this.onstatuschange&&this.onstatuschange(this.getEditorStatus())}),this.on("input",()=>this.editormux?(this.editormux=!1,!1):this.currfile.dirty?void0:(this.currfile.dirty=!0,this.currfile.text+="*",this.tabbar.update(void0))),this.on("changeCursor",()=>{this.onstatuschange&&this.onstatuschange(this.getEditorStatus())}),this.tabbar.ontabselect=t=>this.selecteTab($(t.data.item).index()),this.tabbar.ontabclose=t=>{conste=t.data.item;return!!e&&(e.data.dirty?(this.app.openDialog("YesNoDialog",{title:__("Close tab"),text:__("Close without saving ?")}).then(t=>t?this.closeTab(e):this.focus()),!1):this.closeTab(e))}}findTabByFile(t){conste=this.tabbar.items,i=(()=>{consti=[];for(leta=0;a<e.length;a++)e[a].hash()===t.hash()&&i.push(a);returni})();return0===i.length?-1:i[0]}newTab(t){t.text=t.basename?t.basename:t.path,t.cache||(t.cache=""),t.textModel=this.newTextModelFrom(t),this.currfile.selected=!1,t.selected=!0;conste=this.tabbar.push(t);this.app.trigger("tab-opened",e)}closeTab(t){this.tabbar.delete(t);conste=this.tabbar.items.length;return0===e?(this.openFile("Untitled".asFileHandle()),!1):(this.tabbar.selected=e-1,!1)}selecteTab(t){conste=this.tabbar.items[t];e&&(this.currfile!==e&&(this.currfile.textModel=this.getTexModel(),this.currfile.selected=!1,this.currfile=e),this.setTextModel(e.textModel),this.focus())}selectFile(t){conste=this.findTabByFile(t.asFileHandle());-1!==e&&(this.tabbar.selected=e)}openFile(t){conste=this.findTabByFile(t);-1===e?"Untitled"!==t.path.toString()?t.read().then(e=>(t.cache=e||"",this.newTab(t))).catch(e=>this.app.error(__("Unable to open: {0}",t.path),e)):this.newTab(t):this.tabbar.selected=e}write(){this.currfile.cache=this.getValue(),this.currfile.write("text/plain").then(t=>{this.currfile.dirty=!1,this.currfile.text=this.currfile.basename,this.tabbar.update(void0)}).catch(t=>this.app.error(__("Unable to save file: {0}",this.currfile.path),t))}save(){returnthis.currfile.cache=this.getValue(),this.currfile.basename?this.write():this.saveAs()}reload(){returnnewPromise(async(t,e)=>{try{if("Untitled"===this.currfile.path.toString())returnt(!0);if(this.currfile.dirty&&!awaitthis.app.openDialog("YesNoDialog",{title:__("File modified"),text:__("Continue without saving ?")}))returnt(!0);conste=awaitthis.currfile.read();this.currfile.cache=e||"",this.currfile.dirty=!1,this.currfile.text=this.currfile.basename?this.currfile.basename:this.currfile.path,this.editormux=!0,this.setValue(this.currfile.cache),this.tabbar.update(void0)}catch(t){this.app.error(__("Unable to open: {0}",this.currfile.path),t),e(t)}})}saveAs(){this.app.openDialog("FileDialog",{title:__("Save as"),file:this.currfile}).then(t=>{lete=t.file.path.asFileHandle();"file"===t.file.type&&(e=e.parent()),this.currfile.setPath(`${e.path}/${t.name}`),this.write()})}dirties(){constt=[];for(leteofArray.from(this.tabbar.items))e.dirty&&t.push(e);returnt}setcontextmenuHandle(t){this.container.contextmenuHandle=t}closeAll(){this.tabbar.items=[],this.openFile("Untitled".asFileHandle()),this.resetEditor()}isDirty(){returnth