(function(){var t,e,i;(t=class t extends this.OS.GUI.BasicDialog{constructor(){super("ConnectionDialog",t.scheme)}main(){return super.main(),this.find("bbp").data=[{text:"16 bits",value:16,selected:!0},{text:"32 bits",value:32}],this.find("compression").data=[{text:"No compression",value:0},{text:"JPEG",value:1,selected:!0}],this.find("jq").value=40,this.find("bt-ok").onbtclick=t=>{var e;if(this.handle)return e={wvnc:this.find("txtWVNC").value,server:this.find("txtServer").value,bbp:this.find("bbp").selectedItem.data.value,flag:this.find("compression").selectedItem.data.value,quality:this.find("jq").value},this.handle(e),this.quit()},this.find("bt-cancel").onbtclick=t=>this.quit()}}).scheme='\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n',(e=class t extends this.OS.GUI.BasicDialog{constructor(){super("CredentialDialog",t.scheme)}main(){return this.find("bt-ok").onbtclick=()=>{var t;return this.handle?(t={username:this.find("txtUser").value,password:this.find("txtPass").value},this.handle(t),this.quit()):this.quit()},this.find("bt-cancel").onbtclick=()=>this.quit()}}).scheme='\n \n \n \n \n \n \n \n \n \n \n\n',(i=class extends this.OS.application.BaseApplication{constructor(t){super("RemoteDesktop",t)}main(){return this.canvas=this.find("screen"),this.container=this.find("container"),this.client=new WVNC({element:this.canvas,libjpeg:"pkg://libjpeg/jpg.js".asFileHandle().getlink()}),this.client.onerror=t=>(this.error(t),this.showConnectionDialog()),this.client.onresize=()=>this.setScale(),this.client.onpassword=()=>new Promise((t,e)=>this.openDialog("PromptDialog",{title:__("VNC password"),label:__("VNC password"),value:"password",type:"password"}).then((function(e){return t(e)}))),this.client.oncredential=()=>new Promise((t,i)=>this.openDialog(new e,{title:__("User credential")}).then((function(e){return t(e.username,e.password)}))),this.on("resize",t=>this.setScale()),this.on("focus",t=>$(this.canvas).focus()),this.client.init().then(()=>this.showConnectionDialog())}setScale(){var t,e,i,a;if(this.client&&this.client.resolution)return a=$(this.container).width(),t=$(this.container).height(),(e=a/this.client.resolution.w)>(i=t/this.client.resolution.h)?this.client.setScale(i):this.client.setScale(e)}menu(){return[{text:"__(Connection)",nodes:[{text:"__(New Connection)",dataid:this.name+"-new"},{text:"__(Disconnect)",dataid:this.name+"-close"}],onchildselect:t=>this.actionConnection()}]}actionConnection(t){return this.client&&this.client.disconnect(!1),this.showConnectionDialog()}showConnectionDialog(){return this.openDialog(new t,{title:__("Connection")}).then(t=>(this.client.ws=t.wvnc,this.client.connect(t.server,t)))}cleanup(){if(this.client)return this.client.disconnect(!0)}}).dependencies=["pkg://libwvnc/main.js"],this.OS.register("RemoteDesktop",i)}).call(this);