varOS;!function(e){lett;!function(t){leti;!function(i){leta={"gdv://":{id:"root",mime:"dir"}};classrextendsi.BaseFileHandle{constructor(t){super(t),r.API_META?(this.isRoot()&&(this.gid="root"),this.cache="",this.local_copy=void0):e.announcer.oserror(__("Unknown API setting for GAPI"),e.API.throwe("OS.VFS"))}fields(){return"webContentLink, id, name,mimeType,description, kind, parents, properties, iconLink, createdTime, modifiedTime, owners, permissions, fullFileExtension, fileExtension, size, version"}isFolder(){return"application/vnd.google-apps.folder"===this.info.mimeType}load(e){returnt.Task(async(t,i)=>{try{returnt(awaite)}catch(e){returni(__e(e))}})}sync(t){returnnewPromise(async(a,r)=>{try{if(this.info&&this.info.version==t.version||"application/vnd.google-apps.folder"===t.mimeType)a(!0);else{awaiti.mkdirAll(["home://.gdv_cache","home://.gdv_cache/"+t.id],!0);lete=`home://.gdv_cache/${t.id}/${t.version}.${t.fullFileExtension}`.asFileHandle();try{awaite.onready()}catch(a){await("home://.gdv_cache/"+t.id).asFileHandle().remove(),awaiti.mkdirAll(["home://.gdv_cache/"+t.id]);letr=awaitthis.load(gapi.client.drive.files.get({fileId:t.id,alt:"media"}));if(!r.body)thrownewError(__("VFS cannot download file : {0}",this.path).__());e.cache=newBlob([r.body.asUint8Array()],{type:"octet/stream"}),awaite.write(t.mimeType)}this.local_copy=e,a(!0)}}catch(t){e.announcer.oserror(t.toString(),t),r(__e(t))}})}meta(){returnnewPromise(async(t,i)=>{try{if(awaitthis.oninit(),a[this.path]&&(this.gid=a[this.path].id),this.gid){lete=awaitthis.load(gapi.client.drive.files.get({fileId:this.gid,fields:this.fields()}));if(!e.result)thrownewError(__("VFS cannot get meta data for {0}",this.gid).__());e.result.mime=e.result.mimeType,awaitthis.load(this.sync(e.result)),t(e)}else{conste=this.parent().asFileHandle(),i=(awaite.meta()).result;a[e.path]={id:i.id,mime:i.mimeType};letr=awaitthis.load(gapi.client.drive.files.list({q:`name = '${this.basename}' and '${i.id}' in parents and trashed = false`,fields:`files(${this.fields()})`}));if(!(r.result.files&&r.result.files.length>0))thrownewError(__("VFS cannot get meta data for {0}",this.path).__());a[this.path]={id:r.result.files[0].id,mime:r.result.files[0].mimeType},r.result.files[0].mime=r.result.files[0].mimeType,this.gid=a[this.path].id,awaitthis.load(this.sync(r.result.files[0])),t({result:r.result.files[0],error:!1})}}catch(t){e.announcer.oserror(t.toString(),t),i(__e(t))}})}oninit(){returnnewPromise(async(i,n)=>{consto=asyncfunction(e){if(e)returni(!0);a={"gdv://":{id:"root",mime:"dir"}};try{lete=awaitgapi.auth2.getAuthInstance().signIn();i(e)}catch(e){n(__e(e))}};try{if(!r.API_META)thrownewError(__("No GAPI meta found").__());if(t.libready(r.API_META.apilink))gapi.auth2.getAuthInstance().isSignedIn.listen(e=>o(e)),o(gapi.auth2.getAuthInstance().isSignedIn.get());else{if(awaitthis.load(t.requires(r.API_META.apilink,!1)),awaitthis.load(newPromise((e,t)=>{gapi.load("client:auth2",e)})),awaitthis.load(gapi.client.init({apiKey:r.API_META.API_KEY,clientId:r.API_META.CLIENT_ID,discoveryDocs:r.API_META.DISCOVERY_DOCS,scope:r.API_META.SCOPES})),gapi.auth2.getAuthInstance().isSignedIn.listen(e=>o(e)),!awaite.GUI.openDialog("YesNoDialog",{title:__("Authentication"),text:__("Would you like to login to GoogleDrive?")}))thrownewError(__("User abort the authentication").__());o(gapi.auth2.getAuthInstance().isSignedIn.get())}}catch(t){e.announcer.oserror(t.toString(),t),n(__e(t))}})}getlink(){if(this.local_copy)returnthis.local_copy.getlink()}child(e){if(this.isFolder())return`${this.path}/${e}`}_rd(t){returnnewPromise(async(i,r)=>{try{if(!this.info.id)thrownewError(__("File ID is not valid").__());if(this.isFolder()){lete=awaitthis.load(gapi.client.drive.files.list({q:`'${this.info.id}' in parents and trashed = false`,fields:`files(${this.fields()})`}));if(!e.result.files)thrownewError(__("File {0} not found",this.info.id).__());for(lettofe.result.files)t.path=this.child(t.name),t.mime=t.mimeType,t.filename=t.name,t.type="file",t.gid=t.id,"ap