6f998048b6
Guacamole connect() 追加 ?hostname= 会破坏 ?token= 导致 403。 Co-authored-by: Cursor <cursoragent@cursor.com>
1 line
83 KiB
JavaScript
1 line
83 KiB
JavaScript
import{n as e,t}from"./useSnackbar-BFeYjAzp.js";import{n,t as r}from"./VRow-ZHldweuW.js";import{$r as i,Cr as a,Er as o,F as s,I as c,Ir as l,Or as u,P as d,Rr as f,Sr as p,Tr as m,Ur as h,Vr as g,Xt as _,Yr as v,Z as y,Zr as b,_ as x,an as S,br as C,di as w,en as T,gr as E,hi as D,ii as O,in as k,l as A,m as j,oi as M,v as N,w as ee,xr as P,y as te,yr as F}from"./index-BKLG6eUi.js";import{t as I}from"./_plugin-vue_export-helper-BDNMzG2s.js";import{S as ne,_ as L,b as re,t as R,v as ie}from"./VTextField-Bs8XQAKI.js";import{t as z}from"./apiError-C9ZCize-.js";import{t as ae}from"./VSkeletonLoader-0xYOvLhE.js";import{t as B}from"./VDialog-CfMJJXmK.js";import{r as V}from"./validation-BMzYTJL4.js";import{t as H}from"./wsUrl-CqmqkTTE.js";import{t as U}from"./VTextarea-BT8Danjf.js";var oe=u({__name:`RdpHostFormDialog`,props:{modelValue:{type:Boolean},form:{},editingId:{},passwordSet:{type:Boolean},saving:{type:Boolean}},emits:[`update:modelValue`,`save`],setup(e,{emit:t}){let i=e,a=t,s=O({...i.form});v(()=>i.modelValue,e=>{e&&(s.value={...i.form})}),v(()=>i.form,e=>{i.modelValue&&(s.value={...e})},{deep:!0});function l(){let e=s.value;!e.name.trim()||!e.host.trim()||!e.username.trim()||!i.editingId&&!e.password.trim()||a(`save`,{...e})}return(t,i)=>(g(),P(B,{"model-value":e.modelValue,"max-width":`520`,persistent:``,"onUpdate:modelValue":i[7]||=e=>a(`update:modelValue`,e)},{default:b(()=>[o(L,{border:``},{default:b(()=>[o(re,null,{default:b(()=>[m(D(e.editingId?`编辑 RDP 主机`:`添加 RDP 主机`),1)]),_:1}),o(N),o(ie,{class:`pt-4`},{default:b(()=>[o(R,{modelValue:s.value.name,"onUpdate:modelValue":i[0]||=e=>s.value.name=e,label:`名称`,variant:`outlined`,density:`compact`,rules:[w(V)(`名称`)],class:`mb-2`},null,8,[`modelValue`,`rules`]),o(R,{modelValue:s.value.host,"onUpdate:modelValue":i[1]||=e=>s.value.host=e,label:`IP / 域名`,variant:`outlined`,density:`compact`,placeholder:`例:192.168.1.100`,rules:[w(V)(`IP 或域名`)],class:`mb-2`},null,8,[`modelValue`,`rules`]),o(r,{dense:``},{default:b(()=>[o(n,{cols:`5`},{default:b(()=>[o(R,{modelValue:s.value.port,"onUpdate:modelValue":i[2]||=e=>s.value.port=e,modelModifiers:{number:!0},label:`端口`,type:`number`,variant:`outlined`,density:`compact`},null,8,[`modelValue`])]),_:1}),o(n,{cols:`7`},{default:b(()=>[o(R,{modelValue:s.value.username,"onUpdate:modelValue":i[3]||=e=>s.value.username=e,label:`用户名`,variant:`outlined`,density:`compact`,rules:[w(V)(`用户名`)]},null,8,[`modelValue`,`rules`])]),_:1})]),_:1}),o(R,{modelValue:s.value.password,"onUpdate:modelValue":i[4]||=e=>s.value.password=e,label:`密码`,type:`password`,variant:`outlined`,density:`compact`,placeholder:e.editingId&&e.passwordSet?`留空则不修改`:``,hint:e.editingId&&e.passwordSet?`已设置密码;留空保持不变`:`连接远程桌面必需`,"persistent-hint":``,class:`mb-2`},null,8,[`modelValue`,`placeholder`,`hint`]),o(U,{modelValue:s.value.description,"onUpdate:modelValue":i[5]||=e=>s.value.description=e,label:`备注(可选)`,variant:`outlined`,density:`compact`,rows:`2`,"auto-grow":``},null,8,[`modelValue`])]),_:1}),o(N),o(ne,{class:`pa-4`},{default:b(()=>[o(x),o(c,{variant:`text`,disabled:e.saving,onClick:i[6]||=e=>a(`update:modelValue`,!1)},{default:b(()=>[...i[8]||=[m(`取消`,-1)]]),_:1},8,[`disabled`]),o(c,{color:`primary`,variant:`flat`,loading:e.saving,onClick:l},{default:b(()=>[...i[9]||=[m(`保存`,-1)]]),_:1},8,[`loading`])]),_:1})]),_:1})]),_:1},8,[`model-value`]))}}),W=W||{};W.ArrayBufferReader=function(e){var t=this;e.onblob=function(e){for(var n=window.atob(e),r=new ArrayBuffer(n.length),i=new Uint8Array(r),a=0;a<n.length;a++)i[a]=n.charCodeAt(a);t.ondata&&t.ondata(r)},e.onend=function(){t.onend&&t.onend()},this.ondata=null,this.onend=null};var W=W||{};W.ArrayBufferWriter=function(e){var t=this;e.onack=function(e){t.onack&&t.onack(e)};function n(t){for(var n=``,r=0;r<t.byteLength;r++)n+=String.fromCharCode(t[r]);e.sendBlob(window.btoa(n))}this.blobLength=W.ArrayBufferWriter.DEFAULT_BLOB_LENGTH,this.sendData=function(e){var r=new Uint8Array(e);if(r.length<=t.blobLength)n(r);else for(var i=0;i<r.length;i+=t.blobLength)n(r.subarray(i,i+t.blobLength))},this.sendEnd=function(){e.sendEnd()},this.onack=null},W.ArrayBufferWriter.DEFAULT_BLOB_LENGTH=6048;var W=W||{};W.AudioContextFactory={singleton:null,getAudioContext:function(){var e=window.AudioContext||window.webkitAudioContext;if(e)try{return W.AudioContextFactory.singleton||(W.AudioContextFactory.singleton=new e),W.AudioContextFactory.singleton}catch{}return null}};var W=W||{};W.AudioPlayer=function(){this.sync=function(){}},W.AudioPlayer.isSupportedType=function(e){return W.RawAudioPlayer.isSupportedType(e)},W.AudioPlayer.getSupportedTypes=function(){return W.RawAudioPlayer.getSupportedTypes()},W.AudioPlayer.getInstance=function(e,t){return W.RawAudioPlayer.isSupportedType(t)?new W.RawAudioPlayer(e,t):null},W.RawAudioPlayer=function(e,t){var n=W.RawAudioFormat.parse(t),r=W.AudioContextFactory.getAudioContext(),i=r.currentTime,a=new W.ArrayBufferReader(e),o=.02,s=.3,c=n.bytesPerSample===1?window.Int8Array:window.Int16Array,l=n.bytesPerSample===1?128:32768,u=[],d=function(e){if(e.length<=1)return e[0];var t=0;e.forEach(function(e){t+=e.length});var n=0,r=new c(t);return e.forEach(function(e){r.set(e,n),n+=e.length}),r},f=function(e){for(var t=Number.MAX_VALUE,r=e.length,i=Math.floor(e.length/n.channels),a=Math.floor(n.rate*o),s=Math.max(n.channels*a,n.channels*(i-a));s<e.length;s+=n.channels){for(var l=0,u=0;u<n.channels;u++)l+=Math.abs(e[s+u]);l<=t&&(r=s+n.channels,t=l)}return r===e.length?[e]:[new c(e.buffer.slice(0,r*n.bytesPerSample)),new c(e.buffer.slice(r*n.bytesPerSample))]},p=function(e){u.push(new c(e))},m=function(){var e=d(u);return e?(u=f(e),e=u.shift(),e):null},h=function(e){var t=e.length/n.channels,a=r.currentTime;i<a&&(i=a);for(var o=r.createBuffer(n.channels,t,n.rate),s=0;s<n.channels;s++)for(var c=o.getChannelData(s),u=s,d=0;d<t;d++)c[d]=e[u]/l,u+=n.channels;return o};a.ondata=function(e){p(new c(e));var t=m();if(t){var a=r.currentTime;i<a&&(i=a);var o=r.createBufferSource();o.connect(r.destination),o.start||=o.noteOn,o.buffer=h(t),o.start(i),i+=t.length/n.channels/n.rate}},this.sync=function(){var e=r.currentTime;i=Math.min(i,e+s)}},W.RawAudioPlayer.prototype=new W.AudioPlayer,W.RawAudioPlayer.isSupportedType=function(e){return W.AudioContextFactory.getAudioContext()?W.RawAudioFormat.parse(e)!==null:!1},W.RawAudioPlayer.getSupportedTypes=function(){return W.AudioContextFactory.getAudioContext()?[`audio/L8`,`audio/L16`]:[]};var W=W||{};W.AudioRecorder=function(){this.onclose=null,this.onerror=null},W.AudioRecorder.isSupportedType=function(e){return W.RawAudioRecorder.isSupportedType(e)},W.AudioRecorder.getSupportedTypes=function(){return W.RawAudioRecorder.getSupportedTypes()},W.AudioRecorder.getInstance=function(e,t){return W.RawAudioRecorder.isSupportedType(t)?new W.RawAudioRecorder(e,t):null},W.RawAudioRecorder=function(e,t){var n=this,r=2048,i=3,a=W.RawAudioFormat.parse(t),o=W.AudioContextFactory.getAudioContext();navigator.mediaDevices||(navigator.mediaDevices={}),navigator.mediaDevices.getUserMedia||(navigator.mediaDevices.getUserMedia=(navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia).bind(navigator));var s=new W.ArrayBufferWriter(e),c=a.bytesPerSample===1?window.Int8Array:window.Int16Array,l=a.bytesPerSample===1?128:32768,u=0,d=0,f=null,p=null,m=null,h=function(e){if(e===0)return 1;var t=Math.PI*e;return Math.sin(t)/t},g=function(e,t){return-t<e&&e<t?h(e)*h(e/t):0},_=function(e,t){for(var n=(e.length-1)*t,r=Math.floor(n)-i+1,a=Math.floor(n)+i,o=0,s=r;s<=a;s++)o+=(e[s]||0)*g(n-s,i);return o},v=function(e){var t=e.length;u+=t;var n=Math.round(u*a.rate/e.sampleRate)-d;d+=n;for(var r=new c(n*a.channels),i=0;i<a.channels;i++)for(var o=e.getChannelData(i),s=i,f=0;f<n;f++)r[s]=_(o,f/(n-1))*l,s+=a.channels;return r},y=function(e){m=o.createScriptProcessor(r,a.channels,a.channels),m.connect(o.destination),m.onaudioprocess=function(e){s.sendData(v(e.inputBuffer).buffer)},p=o.createMediaStreamSource(e),p.connect(m),o.state===`suspended`&&o.resume(),f=e},b=function(){s.sendEnd(),n.onerror&&n.onerror()},x=function(){var e=navigator.mediaDevices.getUserMedia({audio:!0},y,b);e&&e.then&&e.then(y,b)},S=function(){if(p&&p.disconnect(),m&&m.disconnect(),f)for(var e=f.getTracks(),t=0;t<e.length;t++)e[t].stop();m=null,p=null,f=null,s.sendEnd()};s.onack=function(e){e.code===W.Status.Code.SUCCESS&&!f?x():(S(),s.onack=null,e.code===W.Status.Code.RESOURCE_CLOSED?n.onclose&&n.onclose():n.onerror&&n.onerror())}},W.RawAudioRecorder.prototype=new W.AudioRecorder,W.RawAudioRecorder.isSupportedType=function(e){return W.AudioContextFactory.getAudioContext()?W.RawAudioFormat.parse(e)!==null:!1},W.RawAudioRecorder.getSupportedTypes=function(){return W.AudioContextFactory.getAudioContext()?[`audio/L8`,`audio/L16`]:[]};var W=W||{};W.BlobReader=function(e,t){var n=this,r=0,i=window.BlobBuilder?new BlobBuilder:window.WebKitBlobBuilder?new WebKitBlobBuilder:window.MozBlobBuilder?new MozBlobBuilder:new(function(){var e=[];this.append=function(n){e.push(new Blob([n],{type:t}))},this.getBlob=function(){return new Blob(e,{type:t})}});e.onblob=function(t){for(var a=window.atob(t),o=new ArrayBuffer(a.length),s=new Uint8Array(o),c=0;c<a.length;c++)s[c]=a.charCodeAt(c);i.append(o),r+=o.byteLength,n.onprogress&&n.onprogress(o.byteLength),e.sendAck(`OK`,0)},e.onend=function(){n.onend&&n.onend()},this.getLength=function(){return r},this.getBlob=function(){return i.getBlob()},this.onprogress=null,this.onend=null};var W=W||{};W.BlobWriter=function(e){var t=this,n=new W.ArrayBufferWriter(e);n.onack=function(e){t.onack&&t.onack(e)};var r=function(e,t,n){var r=(e.slice||e.webkitSlice||e.mozSlice).bind(e),i=n-t;if(i!==n){var a=r(t,i);if(a.size===i)return a}return r(t,n)};this.sendBlob=function(e){var i=0,a=new FileReader,o=function(){if(i>=e.size){t.oncomplete&&t.oncomplete(e);return}var o=r(e,i,i+n.blobLength);i+=n.blobLength,a.readAsArrayBuffer(o)};a.onload=function(){n.sendData(a.result),n.onack=function(r){t.onack&&t.onack(r),!r.isError()&&(t.onprogress&&t.onprogress(e,i-n.blobLength),o())}},a.onerror=function(){t.onerror&&t.onerror(e,i,a.error)},o()},this.sendEnd=function(){n.sendEnd()},this.onack=null,this.onerror=null,this.onprogress=null,this.oncomplete=null};var W=W||{};W.Client=function(e){var t=this,n=W.Client.State.IDLE,r=0,i=5e3,a=null,o=0,s={0:`butt`,1:`round`,2:`square`},c={0:`bevel`,1:`miter`,2:`round`},l=new W.Display,u={},d={},f={},p=[],m=[],h=[],g=new W.IntegerPool,_=[];function v(e){e!=n&&(n=e,t.onstatechange&&t.onstatechange(n))}function y(){return n==W.Client.State.CONNECTED||n==W.Client.State.WAITING}this.exportState=function(e){var t={currentState:n,currentTimestamp:r,layers:{}},i={};for(var a in u)i[a]=u[a];l.flush(function(){for(var n in i){var r=parseInt(n),a=i[n],o=a.toCanvas(),s={width:a.width,height:a.height};a.width&&a.height&&(s.url=o.toDataURL(`image/png`)),r>0&&(s.x=a.x,s.y=a.y,s.z=a.z,s.alpha=a.alpha,s.matrix=a.matrix,s.parent=x(a.parent)),t.layers[n]=s}e(t)})},this.importState=function(e,t){var i,a;for(i in n=e.currentState,r=e.currentTimestamp,l.cancel(),u)a=parseInt(i),a>0&&u[i].dispose();for(i in u={},e.layers){a=parseInt(i);var o=e.layers[i],s=b(a);if(l.resize(s,o.width,o.height),o.url&&(l.setChannelMask(s,W.Layer.SRC),l.draw(s,0,0,o.url)),a>0&&o.parent>=0){var c=b(o.parent);l.move(s,c,o.x,o.y,o.z),l.shade(s,o.alpha);var d=o.matrix;l.distort(s,d[0],d[1],d[2],d[3],d[4],d[5])}}l.flush(t)},this.getDisplay=function(){return l},this.sendSize=function(t,n){y()&&e.sendMessage(`size`,t,n)},this.sendKeyEvent=function(t,n){y()&&e.sendMessage(`key`,n,t)},this.sendMouseState=function(t,n){if(y()){var r=t.x,i=t.y;n&&(r/=l.getScale(),i/=l.getScale()),l.moveCursor(Math.floor(r),Math.floor(i));var a=0;t.left&&(a|=1),t.middle&&(a|=2),t.right&&(a|=4),t.up&&(a|=8),t.down&&(a|=16),e.sendMessage(`mouse`,Math.floor(r),Math.floor(i),a)}},this.sendTouchState=function(t,n){if(y()){var r=t.x,i=t.y;n&&(r/=l.getScale(),i/=l.getScale()),e.sendMessage(`touch`,t.id,Math.floor(r),Math.floor(i),Math.floor(t.radiusX),Math.floor(t.radiusY),t.angle,t.force)}},this.createOutputStream=function(){var e=g.next();return _[e]=new W.OutputStream(t,e)},this.createAudioStream=function(n){var r=t.createOutputStream();return e.sendMessage(`audio`,r.index,n),r},this.createFileStream=function(n,r){var i=t.createOutputStream();return e.sendMessage(`file`,i.index,n,r),i},this.createPipeStream=function(n,r){var i=t.createOutputStream();return e.sendMessage(`pipe`,i.index,n,r),i},this.createClipboardStream=function(n){var r=t.createOutputStream();return e.sendMessage(`clipboard`,r.index,n),r},this.createArgumentValueStream=function(n,r){var i=t.createOutputStream();return e.sendMessage(`argv`,i.index,n,r),i},this.createObjectOutputStream=function(n,r,i){var a=t.createOutputStream();return e.sendMessage(`put`,n,a.index,r,i),a},this.requestObjectInputStream=function(t,n){y()&&e.sendMessage(`get`,t,n)},this.sendAck=function(t,n,r){y()&&e.sendMessage(`ack`,t,n,r)},this.sendBlob=function(t,n){y()&&e.sendMessage(`blob`,t,n)},this.endStream=function(t){y()&&(e.sendMessage(`end`,t),_[t]&&(g.free(t),delete _[t]))},this.onstatechange=null,this.onname=null,this.onerror=null,this.onmsg=null,this.onjoin=null,this.onleave=null,this.onaudio=null,this.onvideo=null,this.onmultitouch=null,this.onargv=null,this.onclipboard=null,this.onfile=null,this.onfilesystem=null,this.onpipe=null,this.onrequired=null,this.onsync=null;var b=function(e){var t=u[e];return t||(t=e===0?l.getDefaultLayer():e>0?l.createLayer():l.createBuffer(),u[e]=t),t},x=function(e){if(!e)return null;for(var t in u)if(e===u[t])return parseInt(t);return null};function S(t){var n=p[t];return n??(n=p[t]=new W.Parser,n.oninstruction=e.oninstruction),n}var C={"miter-limit":function(e,t){l.setMiterLimit(e,parseFloat(t))},"multi-touch":function(e,n){t.onmultitouch&&e instanceof W.Display.VisibleLayer&&t.onmultitouch(e,parseInt(n))}},w={ack:function(e){var t=parseInt(e[0]),n=e[1],r=parseInt(e[2]),i=_[t];i&&(i.onack&&i.onack(new W.Status(r,n)),r>=256&&_[t]===i&&(g.free(t),delete _[t]))},arc:function(e){var t=b(parseInt(e[0])),n=parseInt(e[1]),r=parseInt(e[2]),i=parseInt(e[3]),a=parseFloat(e[4]),o=parseFloat(e[5]),s=parseInt(e[6]);l.arc(t,n,r,i,a,o,s!=0)},argv:function(e){var n=parseInt(e[0]),r=e[1],i=e[2];if(t.onargv){var a=m[n]=new W.InputStream(t,n);t.onargv(a,r,i)}else t.sendAck(n,`Receiving argument values unsupported`,256)},audio:function(e){var n=parseInt(e[0]),r=e[1],i=m[n]=new W.InputStream(t,n),a=null;t.onaudio&&(a=t.onaudio(i,r)),a||=W.AudioPlayer.getInstance(i,r),a?(d[n]=a,t.sendAck(n,`OK`,0)):t.sendAck(n,`BAD TYPE`,783)},blob:function(e){var t=parseInt(e[0]),n=e[1],r=m[t];r&&r.onblob&&r.onblob(n)},body:function(e){var n=h[parseInt(e[0])],r=parseInt(e[1]),i=e[2],a=e[3];if(n&&n.onbody){var o=m[r]=new W.InputStream(t,r);n.onbody(o,i,a)}else t.sendAck(r,`Receipt of body unsupported`,256)},cfill:function(e){var t=parseInt(e[0]),n=b(parseInt(e[1])),r=parseInt(e[2]),i=parseInt(e[3]),a=parseInt(e[4]),o=parseInt(e[5]);l.setChannelMask(n,t),l.fillColor(n,r,i,a,o)},clip:function(e){var t=b(parseInt(e[0]));l.clip(t)},clipboard:function(e){var n=parseInt(e[0]),r=e[1];if(t.onclipboard){var i=m[n]=new W.InputStream(t,n);t.onclipboard(i,r)}else t.sendAck(n,`Clipboard unsupported`,256)},close:function(e){var t=b(parseInt(e[0]));l.close(t)},copy:function(e){var t=b(parseInt(e[0])),n=parseInt(e[1]),r=parseInt(e[2]),i=parseInt(e[3]),a=parseInt(e[4]),o=parseInt(e[5]),s=b(parseInt(e[6])),c=parseInt(e[7]),u=parseInt(e[8]);l.setChannelMask(s,o),l.copy(t,n,r,i,a,s,c,u)},cstroke:function(e){var t=parseInt(e[0]),n=b(parseInt(e[1])),r=s[parseInt(e[2])],i=c[parseInt(e[3])],a=parseInt(e[4]),o=parseInt(e[5]),u=parseInt(e[6]),d=parseInt(e[7]),f=parseInt(e[8]);l.setChannelMask(n,t),l.strokeColor(n,r,i,a,o,u,d,f)},cursor:function(e){var t=parseInt(e[0]),n=parseInt(e[1]),r=b(parseInt(e[2])),i=parseInt(e[3]),a=parseInt(e[4]),o=parseInt(e[5]),s=parseInt(e[6]);l.setCursor(t,n,r,i,a,o,s)},curve:function(e){var t=b(parseInt(e[0])),n=parseInt(e[1]),r=parseInt(e[2]),i=parseInt(e[3]),a=parseInt(e[4]),o=parseInt(e[5]),s=parseInt(e[6]);l.curveTo(t,n,r,i,a,o,s)},disconnect:function(e){t.disconnect()},dispose:function(e){var t=parseInt(e[0]);if(t>0){var n=b(t);l.dispose(n),delete u[t]}else t<0&&delete u[t]},distort:function(e){var t=parseInt(e[0]),n=parseFloat(e[1]),r=parseFloat(e[2]),i=parseFloat(e[3]),a=parseFloat(e[4]),o=parseFloat(e[5]),s=parseFloat(e[6]);if(t>=0){var c=b(t);l.distort(c,n,r,i,a,o,s)}},error:function(e){var n=e[0],r=parseInt(e[1]);t.onerror&&t.onerror(new W.Status(r,n)),t.disconnect()},end:function(e){var t=parseInt(e[0]),n=m[t];n&&(n.onend&&n.onend(),delete m[t])},file:function(e){var n=parseInt(e[0]),r=e[1],i=e[2];if(t.onfile){var a=m[n]=new W.InputStream(t,n);t.onfile(a,r,i)}else t.sendAck(n,`File transfer unsupported`,256)},filesystem:function(e){var n=parseInt(e[0]),r=e[1];if(t.onfilesystem){var i=h[n]=new W.Object(t,n);t.onfilesystem(i,r)}},identity:function(e){var t=b(parseInt(e[0]));l.setTransform(t,1,0,0,1,0,0)},img:function(e){var n=parseInt(e[0]),r=parseInt(e[1]),i=b(parseInt(e[2])),a=e[3],o=parseInt(e[4]),s=parseInt(e[5]),c=m[n]=new W.InputStream(t,n);l.setChannelMask(i,r),l.drawStream(i,o,s,c,a)},jpeg:function(e){var t=parseInt(e[0]),n=b(parseInt(e[1])),r=parseInt(e[2]),i=parseInt(e[3]),a=e[4];l.setChannelMask(n,t),l.draw(n,r,i,`data:image/jpeg;base64,`+a)},lfill:function(e){var t=parseInt(e[0]),n=b(parseInt(e[1])),r=b(parseInt(e[2]));l.setChannelMask(n,t),l.fillLayer(n,r)},line:function(e){var t=b(parseInt(e[0])),n=parseInt(e[1]),r=parseInt(e[2]);l.lineTo(t,n,r)},lstroke:function(e){var t=parseInt(e[0]),n=b(parseInt(e[1])),r=b(parseInt(e[2]));l.setChannelMask(n,t),l.strokeLayer(n,r)},mouse:function(e){var t=parseInt(e[0]),n=parseInt(e[1]);l.showCursor(!0),l.moveCursor(t,n)},move:function(e){var t=parseInt(e[0]),n=parseInt(e[1]),r=parseInt(e[2]),i=parseInt(e[3]),a=parseInt(e[4]);if(t>0&&n>=0){var o=b(t),s=b(n);l.move(o,s,r,i,a)}},msg:function(e){var n,r,i=!0,a=parseInt(e[0]);if(t.onmsg&&(i=t.onmsg(a,e.slice(1)),i===void 0&&(i=!0)),i)switch(a){case W.Client.Message.USER_JOINED:n=e[1],r=e[2],t.onjoin&&t.onjoin(n,r);break;case W.Client.Message.USER_LEFT:n=e[1],r=e[2],t.onleave&&t.onleave(n,r);break}},name:function(e){t.onname&&t.onname(e[0])},nest:function(e){S(parseInt(e[0])).receive(e[1])},pipe:function(e){var n=parseInt(e[0]),r=e[1],i=e[2];if(t.onpipe){var a=m[n]=new W.InputStream(t,n);t.onpipe(a,r,i)}else t.sendAck(n,`Named pipes unsupported`,256)},png:function(e){var t=parseInt(e[0]),n=b(parseInt(e[1])),r=parseInt(e[2]),i=parseInt(e[3]),a=e[4];l.setChannelMask(n,t),l.draw(n,r,i,`data:image/png;base64,`+a)},pop:function(e){var t=b(parseInt(e[0]));l.pop(t)},push:function(e){var t=b(parseInt(e[0]));l.push(t)},rect:function(e){var t=b(parseInt(e[0])),n=parseInt(e[1]),r=parseInt(e[2]),i=parseInt(e[3]),a=parseInt(e[4]);l.rect(t,n,r,i,a)},required:function(e){t.onrequired&&t.onrequired(e)},reset:function(e){var t=b(parseInt(e[0]));l.reset(t)},set:function(e){var t=b(parseInt(e[0])),n=e[1],r=e[2],i=C[n];i&&i(t,r)},shade:function(e){var t=parseInt(e[0]),n=parseInt(e[1]);if(t>=0){var r=b(t);l.shade(r,n)}},size:function(e){var t=b(parseInt(e[0])),n=parseInt(e[1]),r=parseInt(e[2]);l.resize(t,n,r)},start:function(e){var t=b(parseInt(e[0])),n=parseInt(e[1]),r=parseInt(e[2]);l.moveTo(t,n,r)},sync:function(i){var a=parseInt(i[0]),o=i[1]?parseInt(i[1]):0;l.flush(function(){for(var t in d){var n=d[t];n&&n.sync()}a!==r&&(e.sendMessage(`sync`,a),r=a)},a,o),n===W.Client.State.WAITING&&v(W.Client.State.CONNECTED),t.onsync&&t.onsync(a,o)},transfer:function(e){var t=b(parseInt(e[0])),n=parseInt(e[1]),r=parseInt(e[2]),i=parseInt(e[3]),a=parseInt(e[4]),o=parseInt(e[5]),s=b(parseInt(e[6])),c=parseInt(e[7]),u=parseInt(e[8]);o===3?l.put(t,n,r,i,a,s,c,u):o!==5&&l.transfer(t,n,r,i,a,s,c,u,W.Client.DefaultTransferFunction[o])},transform:function(e){var t=b(parseInt(e[0])),n=parseFloat(e[1]),r=parseFloat(e[2]),i=parseFloat(e[3]),a=parseFloat(e[4]),o=parseFloat(e[5]),s=parseFloat(e[6]);l.transform(t,n,r,i,a,o,s)},undefine:function(e){var t=h[parseInt(e[0])];t&&t.onundefine&&t.onundefine()},video:function(e){var n=parseInt(e[0]),r=b(parseInt(e[1])),i=e[2],a=m[n]=new W.InputStream(t,n),o=null;t.onvideo&&(o=t.onvideo(a,r,i)),o||=W.VideoPlayer.getInstance(a,r,i),o?(f[n]=o,t.sendAck(n,`OK`,0)):t.sendAck(n,`BAD TYPE`,783)}},T=function(){e.sendMessage(`nop`),o=new Date().getTime()},E=function(){window.clearTimeout(a);var e=new Date().getTime(),t=Math.max(o+i-e,0);t>0?a=window.setTimeout(T,t):T()},D=function(){window.clearTimeout(a)};e.oninstruction=function(e,t){var n=w[e];n&&n(t),E()},this.disconnect=function(){n!=W.Client.State.DISCONNECTED&&n!=W.Client.State.DISCONNECTING&&(v(W.Client.State.DISCONNECTING),D(),e.sendMessage(`disconnect`),e.disconnect(),v(W.Client.State.DISCONNECTED))},this.connect=function(t){v(W.Client.State.CONNECTING);try{e.connect(t)}catch(e){throw v(W.Client.State.IDLE),e}E(),v(W.Client.State.WAITING)}},W.Client.State={IDLE:0,CONNECTING:1,WAITING:2,CONNECTED:3,DISCONNECTING:4,DISCONNECTED:5},W.Client.DefaultTransferFunction={0:function(e,t){t.red=t.green=t.blue=0},15:function(e,t){t.red=t.green=t.blue=255},3:function(e,t){t.red=e.red,t.green=e.green,t.blue=e.blue,t.alpha=e.alpha},5:function(e,t){},12:function(e,t){t.red=255&~e.red,t.green=255&~e.green,t.blue=255&~e.blue,t.alpha=e.alpha},10:function(e,t){t.red=255&~t.red,t.green=255&~t.green,t.blue=255&~t.blue},1:function(e,t){t.red=e.red&t.red,t.green=e.green&t.green,t.blue=e.blue&t.blue},14:function(e,t){t.red=255&~(e.red&t.red),t.green=255&~(e.green&t.green),t.blue=255&~(e.blue&t.blue)},7:function(e,t){t.red=e.red|t.red,t.green=e.green|t.green,t.blue=e.blue|t.blue},8:function(e,t){t.red=255&~(e.red|t.red),t.green=255&~(e.green|t.green),t.blue=255&~(e.blue|t.blue)},6:function(e,t){t.red=e.red^t.red,t.green=e.green^t.green,t.blue=e.blue^t.blue},9:function(e,t){t.red=255&~(e.red^t.red),t.green=255&~(e.green^t.green),t.blue=255&~(e.blue^t.blue)},4:function(e,t){t.red=255&(~e.red&t.red),t.green=255&(~e.green&t.green),t.blue=255&(~e.blue&t.blue)},13:function(e,t){t.red=255&(~e.red|t.red),t.green=255&(~e.green|t.green),t.blue=255&(~e.blue|t.blue)},2:function(e,t){t.red=255&(e.red&~t.red),t.green=255&(e.green&~t.green),t.blue=255&(e.blue&~t.blue)},11:function(e,t){t.red=255&(e.red|~t.red),t.green=255&(e.green|~t.green),t.blue=255&(e.blue|~t.blue)}},W.Client.Message={USER_JOINED:1,USER_LEFT:2};var W=W||{};W.DataURIReader=function(e,t){var n=this,r=`data:`+t+`;base64,`;e.onblob=function(e){r+=e},e.onend=function(){n.onend&&n.onend()},this.getURI=function(){return r},this.onend=null};var W=W||{};W.Display=function(){var e=this,t=0,n=0,r=1,i=document.createElement(`div`);i.style.position=`relative`,i.style.width=t+`px`,i.style.height=n+`px`,i.style.transformOrigin=i.style.webkitTransformOrigin=i.style.MozTransformOrigin=i.style.OTransformOrigin=i.style.msTransformOrigin=`0 0`;var a=new W.Display.VisibleLayer(t,n),o=new W.Display.VisibleLayer(0,0);o.setChannelMask(W.Layer.SRC),i.appendChild(a.getElement()),i.appendChild(o.getElement());var s=document.createElement(`div`);s.style.position=`relative`,s.style.width=t*r+`px`,s.style.height=n*r+`px`,s.appendChild(i),this.cursorHotspotX=0,this.cursorHotspotY=0,this.cursorX=0,this.cursorY=0,this.statisticWindow=0,this.onresize=null,this.oncursor=null,this.onstatistics=null;var c=[],l=[],u=null,d=function(){for(var e=0,t=0,n=0,r=0;r<l.length;){var i=l[r];if(!i.isReady())break;i.flush(),e=i.localTimestamp,t=i.remoteTimestamp,n+=i.logicalFrames,r++}l.splice(0,r),r&&m(e,t,n)},f=function(){u||=window.requestAnimationFrame(function e(){if(u=null,l.length){if(l[0].isReady()){var t=l.shift();t.flush(),m(t.localTimestamp,t.remoteTimestamp,t.logicalFrames)}l.length&&(u=window.requestAnimationFrame(e))}})},p=[],m=function(t,n,r){if(e.statisticWindow){for(var i=new Date().getTime(),a=0;a<p.length&&!(i-p[a].timestamp<=e.statisticWindow);a++);p.splice(0,a-1),p.push({localTimestamp:t,remoteTimestamp:n,timestamp:i,frames:r});var o=(p[p.length-1].timestamp-p[0].timestamp)/1e3,s=(p[p.length-1].remoteTimestamp-p[0].remoteTimestamp)/1e3,c=p.length,l=p.reduce(function(e,t){return e+t.frames},0),u=p.reduce(function(e,t){return e+Math.max(0,t.frames-1)},0),d=new W.Display.Statistics({processingLag:i-t,desktopFps:s&&l?l/s:null,clientFps:o?c/o:null,serverFps:s?c/s:null,dropRate:s?u/s:null});e.onstatistics&&e.onstatistics(d)}};window.addEventListener(`blur`,function(){u&&!document.hasFocus()&&(window.cancelAnimationFrame(u),u=null,d())},!0);function h(){window.requestAnimationFrame&&document.hasFocus()?f():d()}var g=function(e,t,n,r){this.localTimestamp=new Date().getTime(),this.remoteTimestamp=n||this.localTimestamp,this.logicalFrames=r||0,this.cancel=function(){e=null,t.forEach(function(e){e.cancel()}),t=[]},this.isReady=function(){for(var e=0;e<t.length;e++)if(t[e].blocked)return!1;return!0},this.flush=function(){for(var n=0;n<t.length;n++)t[n].execute();e&&e()}};function _(e,t){var n=this;this.blocked=t,this.cancel=function(){n.blocked=!1,e=null},this.unblock=function(){n.blocked&&(n.blocked=!1,h())},this.execute=function(){e&&e()}}function v(e,t){var n=new _(e,t);return c.push(n),n}this.getElement=function(){return s},this.getWidth=function(){return t},this.getHeight=function(){return n},this.getDefaultLayer=function(){return a},this.getCursorLayer=function(){return o},this.createLayer=function(){var e=new W.Display.VisibleLayer(t,n);return e.move(a,0,0,0),e},this.createBuffer=function(){var e=new W.Layer(0,0);return e.autosize=1,e},this.flush=function(e,t,n){l.push(new g(e,c,t,n)),c=[],h()},this.cancel=function(){l.forEach(function(e){e.cancel()}),l=[],c.forEach(function(e){e.cancel()}),c=[]},this.setCursor=function(t,n,r,i,a,s,c){v(function(){e.cursorHotspotX=t,e.cursorHotspotY=n,o.resize(s,c),o.copy(r,i,a,s,c,0,0),e.moveCursor(e.cursorX,e.cursorY),e.oncursor&&e.oncursor(o.toCanvas(),t,n)})},this.showCursor=function(e){var t=o.getElement(),n=t.parentNode;e===!1?n&&n.removeChild(t):n!==i&&i.appendChild(t)},this.moveCursor=function(t,n){o.translate(t-e.cursorHotspotX,n-e.cursorHotspotY),e.cursorX=t,e.cursorY=n},this.resize=function(o,c,l){v(function(){o.resize(c,l),o===a&&(t=c,n=l,i.style.width=t+`px`,i.style.height=n+`px`,s.style.width=t*r+`px`,s.style.height=n*r+`px`,e.onresize&&e.onresize(c,l))})},this.drawImage=function(e,t,n,r){v(function(){e.drawImage(t,n,r)})},this.drawBlob=function(e,t,n,r){var i;if(window.createImageBitmap){var a;i=v(function(){e.drawImage(t,n,a)},!0),window.createImageBitmap(r).then(function(e){a=e,i.unblock()})}else{var o=URL.createObjectURL(r);i=v(function(){s.width&&s.height&&e.drawImage(t,n,s),URL.revokeObjectURL(o)},!0);var s=new Image;s.onload=i.unblock,s.onerror=i.unblock,s.src=o}},this.drawStream=function(t,n,r,i,a){if(window.createImageBitmap){var o=new W.BlobReader(i,a);o.onend=function(){e.drawBlob(t,n,r,o.getBlob())}}else{var o=new W.DataURIReader(i,a);o.onend=function(){e.draw(t,n,r,o.getURI())}}},this.draw=function(e,t,n,r){var i=v(function(){a.width&&a.height&&e.drawImage(t,n,a)},!0),a=new Image;a.onload=i.unblock,a.onerror=i.unblock,a.src=r},this.play=function(e,t,n,r){var i=document.createElement(`video`);i.type=t,i.src=r,i.addEventListener(`play`,function(){function t(){e.drawImage(0,0,i),i.ended||window.setTimeout(t,20)}t()},!1),v(i.play)},this.transfer=function(e,t,n,r,i,a,o,s,c){v(function(){a.transfer(e,t,n,r,i,o,s,c)})},this.put=function(e,t,n,r,i,a,o,s){v(function(){a.put(e,t,n,r,i,o,s)})},this.copy=function(e,t,n,r,i,a,o,s){v(function(){a.copy(e,t,n,r,i,o,s)})},this.moveTo=function(e,t,n){v(function(){e.moveTo(t,n)})},this.lineTo=function(e,t,n){v(function(){e.lineTo(t,n)})},this.arc=function(e,t,n,r,i,a,o){v(function(){e.arc(t,n,r,i,a,o)})},this.curveTo=function(e,t,n,r,i,a,o){v(function(){e.curveTo(t,n,r,i,a,o)})},this.close=function(e){v(function(){e.close()})},this.rect=function(e,t,n,r,i){v(function(){e.rect(t,n,r,i)})},this.clip=function(e){v(function(){e.clip()})},this.strokeColor=function(e,t,n,r,i,a,o,s){v(function(){e.strokeColor(t,n,r,i,a,o,s)})},this.fillColor=function(e,t,n,r,i){v(function(){e.fillColor(t,n,r,i)})},this.strokeLayer=function(e,t,n,r,i){v(function(){e.strokeLayer(t,n,r,i)})},this.fillLayer=function(e,t){v(function(){e.fillLayer(t)})},this.push=function(e){v(function(){e.push()})},this.pop=function(e){v(function(){e.pop()})},this.reset=function(e){v(function(){e.reset()})},this.setTransform=function(e,t,n,r,i,a,o){v(function(){e.setTransform(t,n,r,i,a,o)})},this.transform=function(e,t,n,r,i,a,o){v(function(){e.transform(t,n,r,i,a,o)})},this.setChannelMask=function(e,t){v(function(){e.setChannelMask(t)})},this.setMiterLimit=function(e,t){v(function(){e.setMiterLimit(t)})},this.dispose=function(e){v(function(){e.dispose()})},this.distort=function(e,t,n,r,i,a,o){v(function(){e.distort(t,n,r,i,a,o)})},this.move=function(e,t,n,r,i){v(function(){e.move(t,n,r,i)})},this.shade=function(e,t){v(function(){e.shade(t)})},this.scale=function(e){i.style.transform=i.style.WebkitTransform=i.style.MozTransform=i.style.OTransform=i.style.msTransform=`scale(`+e+`,`+e+`)`,r=e,s.style.width=t*r+`px`,s.style.height=n*r+`px`},this.getScale=function(){return r},this.flatten=function(){var e=document.createElement(`canvas`);e.width=a.width,e.height=a.height;var t=e.getContext(`2d`);function n(e){var t=[];for(var n in e.children)t.push(e.children[n]);return t.sort(function(e,t){var n=e.z-t.z;if(n!==0)return n;var r=e.getElement(),i=t.getElement().compareDocumentPosition(r);return i&Node.DOCUMENT_POSITION_PRECEDING?-1:i&Node.DOCUMENT_POSITION_FOLLOWING?1:0}),t}function r(e,i,a){if(e.width>0&&e.height>0){var o=t.globalAlpha;t.globalAlpha*=e.alpha/255,t.drawImage(e.getCanvas(),i,a);for(var s=n(e),c=0;c<s.length;c++){var l=s[c];r(l,i+l.x,a+l.y)}t.globalAlpha=o}}return r(a,0,0),e}},W.Display.VisibleLayer=function(e,t){W.Layer.apply(this,[e,t]);var n=this;this.__unique_id=W.Display.VisibleLayer.__next_id++,this.alpha=255,this.x=0,this.y=0,this.z=0,this.matrix=[1,0,0,1,0,0],this.parent=null,this.children={};var r=n.getCanvas();r.style.position=`absolute`,r.style.left=`0px`,r.style.top=`0px`;var i=document.createElement(`div`);i.appendChild(r),i.style.width=e+`px`,i.style.height=t+`px`,i.style.position=`absolute`,i.style.left=`0px`,i.style.top=`0px`,i.style.overflow=`hidden`;var a=this.resize;this.resize=function(e,t){i.style.width=e+`px`,i.style.height=t+`px`,a(e,t)},this.getElement=function(){return i};var o=`translate(0px, 0px)`,s=`matrix(1, 0, 0, 1, 0, 0)`;this.translate=function(e,t){n.x=e,n.y=t,o=`translate(`+e+`px,`+t+`px)`,i.style.transform=i.style.WebkitTransform=i.style.MozTransform=i.style.OTransform=i.style.msTransform=o+` `+s},this.move=function(e,t,r,a){n.parent!==e&&(n.parent&&delete n.parent.children[n.__unique_id],n.parent=e,e.children[n.__unique_id]=n,e.getElement().appendChild(i)),n.translate(t,r),n.z=a,i.style.zIndex=a},this.shade=function(e){n.alpha=e,i.style.opacity=e/255},this.dispose=function(){n.parent&&=(delete n.parent.children[n.__unique_id],null),i.parentNode&&i.parentNode.removeChild(i)},this.distort=function(e,t,r,a,c,l){n.matrix=[e,t,r,a,c,l],s=`matrix(`+e+`,`+t+`,`+r+`,`+a+`,`+c+`,`+l+`)`,i.style.transform=i.style.WebkitTransform=i.style.MozTransform=i.style.OTransform=i.style.msTransform=o+` `+s}},W.Display.VisibleLayer.__next_id=0,W.Display.Statistics=function(e){e||={},this.processingLag=e.processingLag,this.desktopFps=e.desktopFps,this.serverFps=e.serverFps,this.clientFps=e.clientFps,this.dropRate=e.dropRate};var W=W||{};W.Event=function(e){this.type=e,this.timestamp=new Date().getTime(),this.getAge=function(){return new Date().getTime()-this.timestamp},this.invokeLegacyHandler=function(e){}},W.Event.DOMEvent=function(e,t){W.Event.call(this,e),t||=[],Array.isArray(t)||(t=[t]),this.preventDefault=function(){t.forEach(function(e){e.preventDefault&&e.preventDefault(),e.returnValue=!1})},this.stopPropagation=function(){t.forEach(function(e){e.stopPropagation()})}},W.Event.DOMEvent.cancelEvent=function(e){e.stopPropagation(),e.preventDefault&&e.preventDefault(),e.returnValue=!1},W.Event.Target=function(){var e={};this.on=function(t,n){var r=e[t];r||(e[t]=r=[]),r.push(n)},this.onEach=function(e,t){e.forEach(function(e){this.on(e,t)},this)},this.dispatch=function(t){t.invokeLegacyHandler(this);var n=e[t.type];if(n)for(var r=0;r<n.length;r++)n[r](t,this)},this.off=function(t,n){var r=e[t];if(!r)return!1;for(var i=0;i<r.length;i++)if(r[i]===n)return r.splice(i,1),!0;return!1},this.offEach=function(e,t){var n=!1;return e.forEach(function(e){n|=this.off(e,t)},this),n}};var W=W||{};W.InputSink=function(){var e=this,t=document.createElement(`textarea`);t.style.position=`fixed`,t.style.outline=`none`,t.style.border=`none`,t.style.margin=`0`,t.style.padding=`0`,t.style.height=`0`,t.style.width=`0`,t.style.left=`0`,t.style.bottom=`0`,t.style.resize=`none`,t.style.background=`transparent`,t.style.color=`transparent`,t.addEventListener(`keypress`,function(e){t.value=``},!1),t.addEventListener(`compositionend`,function(e){e.data&&(t.value=``)},!1),t.addEventListener(`input`,function(e){e.data&&!e.isComposing&&(t.value=``)},!1),t.addEventListener(`focus`,function(){window.setTimeout(function(){t.click(),t.select()},0)},!0),this.focus=function(){window.setTimeout(function(){t.focus()},0)},this.getElement=function(){return t},document.addEventListener(`keydown`,function(t){var n=document.activeElement;if(n&&n!==document.body){var r=n.getBoundingClientRect();if(r.left+r.width>0&&r.top+r.height>0)return}e.focus()},!0)};var W=W||{};W.InputStream=function(e,t){var n=this;this.index=t,this.onblob=null,this.onend=null,this.sendAck=function(t,r){e.sendAck(n.index,t,r)}};var W=W||{};W.IntegerPool=function(){var e=this,t=[];this.next_int=0,this.next=function(){return t.length>0?t.shift():e.next_int++},this.free=function(e){t.push(e)}};var W=W||{};W.JSONReader=function(e){var t=this,n=new W.StringReader(e),r=``;this.getLength=function(){return r.length},this.getJSON=function(){return JSON.parse(r)},n.ontext=function(e){r+=e,t.onprogress&&t.onprogress(e.length)},n.onend=function(){t.onend&&t.onend()},this.onprogress=null,this.onend=null};var W=W||{};W.Keyboard=function(e){var t=this,n=`_GUAC_KEYBOARD_HANDLED_BY_`+ W.Keyboard._nextID++;this.onkeydown=null,this.onkeyup=null;var r={keyupUnreliable:!1,altIsTypableOnly:!1,capsLockKeyupUnreliable:!1};navigator&&navigator.platform&&(navigator.platform.match(/ipad|iphone|ipod/i)?r.keyupUnreliable=!0:navigator.platform.match(/^mac/i)&&(r.altIsTypableOnly=!0,r.capsLockKeyupUnreliable=!0));var i=function(e){var t=this;this.keyCode=e?e.which||e.keyCode:0,this.keyIdentifier=e&&e.keyIdentifier,this.key=e&&e.key,this.location=e?A(e):0,this.modifiers=e?W.Keyboard.ModifierState.fromKeyboardEvent(e):new W.Keyboard.ModifierState,this.timestamp=new Date().getTime(),this.defaultPrevented=!1,this.keysym=null,this.reliable=!1,this.getAge=function(){return new Date().getTime()-t.timestamp}},a=function(e){i.call(this,e),this.keysym=y(this.key,this.location)||S(this.keyCode,this.location),this.keyupReliable=!r.keyupUnreliable,this.keysym&&!v(this.keysym)&&(this.reliable=!0),!this.keysym&&C(this.keyCode,this.keyIdentifier)&&(this.keysym=y(this.keyIdentifier,this.location,this.modifiers.shift)),(this.modifiers.meta&&this.keysym!==65511&&this.keysym!==65512||this.keysym===65509&&r.capsLockKeyupUnreliable)&&(this.keyupReliable=!1);var t=!this.modifiers.ctrl&&!r.altIsTypableOnly;(!this.modifiers.alt&&this.modifiers.ctrl||t&&this.modifiers.alt||this.modifiers.meta||this.modifiers.hyper)&&(this.reliable=!0),m[this.keyCode]=this.keysym};a.prototype=new i;var o=function(e){i.call(this,e),this.keysym=x(this.keyCode),this.reliable=!0};o.prototype=new i;var s=function(e){i.call(this,e),this.keysym=S(this.keyCode,this.location)||y(this.key,this.location),t.pressed[this.keysym]||(this.keysym=m[this.keyCode]||this.keysym),this.reliable=!0};s.prototype=new i;var c=[],l={8:[65288],9:[65289],12:[65291,65291,65291,65461],13:[65293],16:[65505,65505,65506],17:[65507,65507,65508],18:[65513,65513,65027],19:[65299],20:[65509],27:[65307],32:[32],33:[65365,65365,65365,65465],34:[65366,65366,65366,65459],35:[65367,65367,65367,65457],36:[65360,65360,65360,65463],37:[65361,65361,65361,65460],38:[65362,65362,65362,65464],39:[65363,65363,65363,65462],40:[65364,65364,65364,65458],45:[65379,65379,65379,65456],46:[65535,65535,65535,65454],91:[65511],92:[65512],93:[65383],96:[65456],97:[65457],98:[65458],99:[65459],100:[65460],101:[65461],102:[65462],103:[65463],104:[65464],105:[65465],106:[65450],107:[65451],109:[65453],110:[65454],111:[65455],112:[65470],113:[65471],114:[65472],115:[65473],116:[65474],117:[65475],118:[65476],119:[65477],120:[65478],121:[65479],122:[65480],123:[65481],144:[65407],145:[65300],225:[65027]},u={Again:[65382],AllCandidates:[65341],Alphanumeric:[65328],Alt:[65513,65513,65027],Attn:[64782],AltGraph:[65027],ArrowDown:[65364],ArrowLeft:[65361],ArrowRight:[65363],ArrowUp:[65362],Backspace:[65288],CapsLock:[65509],Cancel:[65385],Clear:[65291],Convert:[65313],Copy:[64789],Crsel:[64796],CrSel:[64796],CodeInput:[65335],Compose:[65312],Control:[65507,65507,65508],ContextMenu:[65383],Delete:[65535],Down:[65364],End:[65367],Enter:[65293],EraseEof:[64774],Escape:[65307],Execute:[65378],Exsel:[64797],ExSel:[64797],F1:[65470],F2:[65471],F3:[65472],F4:[65473],F5:[65474],F6:[65475],F7:[65476],F8:[65477],F9:[65478],F10:[65479],F11:[65480],F12:[65481],F13:[65482],F14:[65483],F15:[65484],F16:[65485],F17:[65486],F18:[65487],F19:[65488],F20:[65489],F21:[65490],F22:[65491],F23:[65492],F24:[65493],Find:[65384],GroupFirst:[65036],GroupLast:[65038],GroupNext:[65032],GroupPrevious:[65034],FullWidth:null,HalfWidth:null,HangulMode:[65329],Hankaku:[65321],HanjaMode:[65332],Help:[65386],Hiragana:[65317],HiraganaKatakana:[65319],Home:[65360],Hyper:[65517,65517,65518],Insert:[65379],JapaneseHiragana:[65317],JapaneseKatakana:[65318],JapaneseRomaji:[65316],JunjaMode:[65336],KanaMode:[65325],KanjiMode:[65313],Katakana:[65318],Left:[65361],Meta:[65511,65511,65512],ModeChange:[65406],NumLock:[65407],PageDown:[65366],PageUp:[65365],Pause:[65299],Play:[64790],PreviousCandidate:[65342],PrintScreen:[65377],Redo:[65382],Right:[65363],RomanCharacters:null,Scroll:[65300],Select:[65376],Separator:[65452],Shift:[65505,65505,65506],SingleCandidate:[65340],Super:[65515,65515,65516],Tab:[65289],UIKeyInputDownArrow:[65364],UIKeyInputEscape:[65307],UIKeyInputLeftArrow:[65361],UIKeyInputRightArrow:[65363],UIKeyInputUpArrow:[65362],Up:[65362],Undo:[65381],Win:[65511,65511,65512],Zenkaku:[65320],ZenkakuHankaku:[65322]},d={65027:!0,65505:!0,65506:!0,65507:!0,65508:!0,65509:!0,65511:!0,65512:!0,65513:!0,65514:!0,65515:!0,65516:!0};this.modifiers=new W.Keyboard.ModifierState,this.pressed={};var f={},p={},m={},h=null,g=null,_=function(e,t){return e?e[t]||e[0]:null},v=function(e){return e>=0&&e<=255||(e&4294901760)==16777216};function y(e,t,n){if(!e)return null;var r,i=e.indexOf(`U+`);if(i>=0){var a=e.substring(i+2);r=String.fromCharCode(parseInt(a,16))}else if(e.length===1&&t!==3)r=e;else return _(u[e],t);return n===!0?r=r.toUpperCase():n===!1&&(r=r.toLowerCase()),x(r.charCodeAt(0))}function b(e){return e<=31||e>=127&&e<=159}function x(e){return b(e)?65280|e:e>=0&&e<=255?e:e>=256&&e<=1114111?16777216|e:null}function S(e,t){return _(l[e],t)}var C=function(e,t){if(!t)return!1;var n=t.indexOf(`U+`);return n===-1||e!==parseInt(t.substring(n+2),16)||e>=65&&e<=90||e>=48&&e<=57};this.press=function(e){if(e!==null){if(!t.pressed[e]&&(t.pressed[e]=!0,t.onkeydown)){var n=t.onkeydown(e);return p[e]=n,window.clearTimeout(h),window.clearInterval(g),d[e]||(h=window.setTimeout(function(){g=window.setInterval(function(){t.onkeyup(e),t.onkeydown(e)},50)},500)),n}return p[e]||!1}},this.release=function(e){t.pressed[e]&&(delete t.pressed[e],delete f[e],window.clearTimeout(h),window.clearInterval(g),e!==null&&t.onkeyup&&t.onkeyup(e))},this.type=function(e){for(var n=0;n<e.length;n++){var r=x(e.codePointAt?e.codePointAt(n):e.charCodeAt(n));t.press(r),t.release(r)}},this.reset=function(){for(var e in t.pressed)t.release(parseInt(e));c=[]};var w=function(e,n,r){var i=r.modifiers[e],a=t.modifiers[e],o;if(n.indexOf(r.keysym)===-1){if(a&&i===!1)for(o=0;o<n.length;o++)t.release(n[o]);else if(!a&&i){for(o=0;o<n.length;o++)if(t.pressed[n[o]])return;var s=n[0];r.keysym&&(f[s]=!0),t.press(s)}}},T=function(e){w(`alt`,[65513,65514,65027],e),w(`shift`,[65505,65506],e),w(`ctrl`,[65507,65508],e),w(`meta`,[65511,65512],e),w(`hyper`,[65515,65516],e),t.modifiers=e.modifiers},E=function(){for(var e in t.pressed)if(!f[e])return!1;return!0};function D(){var e=k();if(!e)return!1;var n;do n=e,e=k();while(e!==null);return E()&&t.reset(),n.defaultPrevented}var O=function(e){!t.modifiers.ctrl||!t.modifiers.alt||e>=65&&e<=90||e>=97&&e<=122||(e<=255||(e&4278190080)==16777216)&&(t.release(65507),t.release(65508),t.release(65513),t.release(65514))},k=function(){var e=c[0];if(!e)return null;if(e instanceof a){var n=null,i=[];if(e.keysym===65511||e.keysym===65512){if(c.length===1)return null;if(c[1].keysym!==e.keysym){if(!c[1].modifiers.meta)return c.shift()}else if(c[1]instanceof a)return c.shift()}if(e.reliable?(n=e.keysym,i=c.splice(0,1)):c[1]instanceof o?(n=c[1].keysym,i=c.splice(0,2)):c[1]&&(n=e.keysym,i=c.splice(0,1)),i.length>0){if(T(e),n){O(n);var l=!t.press(n);m[e.keyCode]=n,e.keyupReliable||t.release(n);for(var u=0;u<i.length;u++)i[u].defaultPrevented=l}return e}}else if(e instanceof s&&!r.keyupUnreliable){var n=e.keysym;if(n)t.release(n),delete m[e.keyCode],e.defaultPrevented=!0;else return t.reset(),e;return T(e),c.shift()}else return c.shift();return null},A=function(e){return`location`in e?e.location:`keyLocation`in e?e.keyLocation:0},j=function(e){return e[n]?!1:(e[n]=!0,!0)};this.listenTo=function(e){e.addEventListener(`keydown`,function(e){if(t.onkeydown&&j(e)){var n=new a(e);n.keyCode!==229&&(c.push(n),D()&&e.preventDefault())}},!0),e.addEventListener(`keypress`,function(e){!t.onkeydown&&!t.onkeyup||j(e)&&(c.push(new o(e)),D()&&e.preventDefault())},!0),e.addEventListener(`keyup`,function(e){t.onkeyup&&j(e)&&(e.preventDefault(),c.push(new s(e)),D())},!0);var n=function(n){!t.onkeydown&&!t.onkeyup||j(n)&&n.data&&!n.isComposing&&(e.removeEventListener(`compositionend`,r,!1),t.type(n.data))},r=function(r){!t.onkeydown&&!t.onkeyup||j(r)&&r.data&&(e.removeEventListener(`input`,n,!1),t.type(r.data))};e.addEventListener(`input`,n,!1),e.addEventListener(`compositionend`,r,!1)},e&&t.listenTo(e)},W.Keyboard._nextID=0,W.Keyboard.ModifierState=function(){this.shift=!1,this.ctrl=!1,this.alt=!1,this.meta=!1,this.hyper=!1},W.Keyboard.ModifierState.fromKeyboardEvent=function(e){var t=new W.Keyboard.ModifierState;return t.shift=e.shiftKey,t.ctrl=e.ctrlKey,t.alt=e.altKey,t.meta=e.metaKey,e.getModifierState&&(t.hyper=e.getModifierState(`OS`)||e.getModifierState(`Super`)||e.getModifierState(`Hyper`)||e.getModifierState(`Win`)),t};var W=W||{};W.Layer=function(e,t){var n=this,r=64,i=document.createElement(`canvas`),a=i.getContext(`2d`);a.save();var o=!0,s=!0,c=0,l={1:`destination-in`,2:`destination-out`,4:`source-in`,6:`source-atop`,8:`source-out`,9:`destination-atop`,10:`xor`,11:`destination-over`,12:`copy`,14:`source-over`,15:`lighter`},u=function(e,t){e||=0,t||=0;var s=Math.ceil(e/r)*r,l=Math.ceil(t/r)*r;if(i.width!==s||i.height!==l){var u=null;!o&&i.width!==0&&i.height!==0&&(u=document.createElement(`canvas`),u.width=Math.min(n.width,e),u.height=Math.min(n.height,t),u.getContext(`2d`).drawImage(i,0,0,u.width,u.height,0,0,u.width,u.height));var d=a.globalCompositeOperation;i.width=s,i.height=l,u&&a.drawImage(u,0,0,u.width,u.height,0,0,u.width,u.height),a.globalCompositeOperation=d,c=0,a.save()}else n.reset();n.width=e,n.height=t};function d(e,t,r,i){var a=r+e,o=i+t,s=a>n.width?a:n.width,c=o>n.height?o:n.height;n.resize(s,c)}this.autosize=!1,this.width=e,this.height=t,this.getCanvas=function(){return i},this.toCanvas=function(){var e=document.createElement(`canvas`);return e.width=n.width,e.height=n.height,e.getContext(`2d`).drawImage(n.getCanvas(),0,0),e},this.resize=function(e,t){(e!==n.width||t!==n.height)&&u(e,t)},this.drawImage=function(e,t,r){n.autosize&&d(e,t,r.width,r.height),a.drawImage(r,e,t),o=!1},this.transfer=function(e,t,r,i,s,c,l,u){var f=e.getCanvas();if(!(t>=f.width||r>=f.height)&&(t+i>f.width&&(i=f.width-t),r+s>f.height&&(s=f.height-r),!(i===0||s===0))){n.autosize&&d(c,l,i,s);for(var p=e.getCanvas().getContext(`2d`).getImageData(t,r,i,s),m=a.getImageData(c,l,i,s),h=0;h<i*s*4;h+=4){var g=new W.Layer.Pixel(p.data[h],p.data[h+1],p.data[h+2],p.data[h+3]),_=new W.Layer.Pixel(m.data[h],m.data[h+1],m.data[h+2],m.data[h+3]);u(g,_),m.data[h]=_.red,m.data[h+1]=_.green,m.data[h+2]=_.blue,m.data[h+3]=_.alpha}a.putImageData(m,c,l),o=!1}},this.put=function(e,t,r,i,s,c,l){var u=e.getCanvas();if(!(t>=u.width||r>=u.height)&&(t+i>u.width&&(i=u.width-t),r+s>u.height&&(s=u.height-r),!(i===0||s===0))){n.autosize&&d(c,l,i,s);var f=e.getCanvas().getContext(`2d`).getImageData(t,r,i,s);a.putImageData(f,c,l),o=!1}},this.copy=function(e,t,r,i,s,c,l){var u=e.getCanvas();t>=u.width||r>=u.height||(t+i>u.width&&(i=u.width-t),r+s>u.height&&(s=u.height-r),!(i===0||s===0)&&(n.autosize&&d(c,l,i,s),a.drawImage(u,t,r,i,s,c,l,i,s),o=!1))},this.moveTo=function(e,t){s&&=(a.beginPath(),!1),n.autosize&&d(e,t,0,0),a.moveTo(e,t)},this.lineTo=function(e,t){s&&=(a.beginPath(),!1),n.autosize&&d(e,t,0,0),a.lineTo(e,t)},this.arc=function(e,t,r,i,o,c){s&&=(a.beginPath(),!1),n.autosize&&d(e,t,0,0),a.arc(e,t,r,i,o,c)},this.curveTo=function(e,t,r,i,o,c){s&&=(a.beginPath(),!1),n.autosize&&d(o,c,0,0),a.bezierCurveTo(e,t,r,i,o,c)},this.close=function(){a.closePath(),s=!0},this.rect=function(e,t,r,i){s&&=(a.beginPath(),!1),n.autosize&&d(e,t,r,i),a.rect(e,t,r,i)},this.clip=function(){a.clip(),s=!0},this.strokeColor=function(e,t,n,r,i,c,l){a.lineCap=e,a.lineJoin=t,a.lineWidth=n,a.strokeStyle=`rgba(`+r+`,`+i+`,`+c+`,`+l/255+`)`,a.stroke(),o=!1,s=!0},this.fillColor=function(e,t,n,r){a.fillStyle=`rgba(`+e+`,`+t+`,`+n+`,`+r/255+`)`,a.fill(),o=!1,s=!0},this.strokeLayer=function(e,t,n,r){a.lineCap=e,a.lineJoin=t,a.lineWidth=n,a.strokeStyle=a.createPattern(r.getCanvas(),`repeat`),a.stroke(),o=!1,s=!0},this.fillLayer=function(e){a.fillStyle=a.createPattern(e.getCanvas(),`repeat`),a.fill(),o=!1,s=!0},this.push=function(){a.save(),c++},this.pop=function(){c>0&&(a.restore(),c--)},this.reset=function(){for(;c>0;)a.restore(),c--;a.restore(),a.save(),a.beginPath(),s=!1},this.setTransform=function(e,t,n,r,i,o){a.setTransform(e,t,n,r,i,o)},this.transform=function(e,t,n,r,i,o){a.transform(e,t,n,r,i,o)},this.setChannelMask=function(e){a.globalCompositeOperation=l[e]},this.setMiterLimit=function(e){a.miterLimit=e},u(e,t),i.style.zIndex=-1},W.Layer.ROUT=2,W.Layer.ATOP=6,W.Layer.XOR=10,W.Layer.ROVER=11,W.Layer.OVER=14,W.Layer.PLUS=15,W.Layer.RIN=1,W.Layer.IN=4,W.Layer.OUT=8,W.Layer.RATOP=9,W.Layer.SRC=12,W.Layer.Pixel=function(e,t,n,r){this.red=e,this.green=t,this.blue=n,this.alpha=r};var W=W||{};W.Mouse=function(e){W.Mouse.Event.Target.call(this);var t=this;this.touchMouseThreshold=3,this.scrollThreshold=53,this.PIXELS_PER_LINE=18,this.PIXELS_PER_PAGE=this.PIXELS_PER_LINE*16;var n=[W.Mouse.State.Buttons.LEFT,W.Mouse.State.Buttons.MIDDLE,W.Mouse.State.Buttons.RIGHT],r=0,i=0;e.addEventListener(`contextmenu`,function(e){W.Event.DOMEvent.cancelEvent(e)},!1),e.addEventListener(`mousemove`,function(n){if(r){W.Event.DOMEvent.cancelEvent(n),r--;return}t.move(W.Position.fromClientPosition(e,n.clientX,n.clientY),n)},!1),e.addEventListener(`mousedown`,function(e){if(r){W.Event.DOMEvent.cancelEvent(e);return}var i=n[e.button];i&&t.press(i,e)},!1),e.addEventListener(`mouseup`,function(e){if(r){W.Event.DOMEvent.cancelEvent(e);return}var i=n[e.button];i&&t.release(i,e)},!1),e.addEventListener(`mouseout`,function(n){n||=window.event;for(var r=n.relatedTarget||n.toElement;r;){if(r===e)return;r=r.parentNode}t.reset(n),t.out(n)},!1),e.addEventListener(`selectstart`,function(e){W.Event.DOMEvent.cancelEvent(e)},!1);function a(){r=t.touchMouseThreshold}e.addEventListener(`touchmove`,a,!1),e.addEventListener(`touchstart`,a,!1),e.addEventListener(`touchend`,a,!1);function o(e){var n=e.deltaY||-e.wheelDeltaY||-e.wheelDelta;if(n?e.deltaMode===1?n=e.deltaY*t.PIXELS_PER_LINE:e.deltaMode===2&&(n=e.deltaY*t.PIXELS_PER_PAGE):n=e.detail*t.PIXELS_PER_LINE,i+=n,i<=-t.scrollThreshold){do t.click(W.Mouse.State.Buttons.UP),i+=t.scrollThreshold;while(i<=-t.scrollThreshold);i=0}if(i>=t.scrollThreshold){do t.click(W.Mouse.State.Buttons.DOWN),i-=t.scrollThreshold;while(i>=t.scrollThreshold);i=0}W.Event.DOMEvent.cancelEvent(e)}e.addEventListener(`DOMMouseScroll`,o,!1),e.addEventListener(`mousewheel`,o,!1),e.addEventListener(`wheel`,o,!1);var s=(function(){var e=document.createElement(`div`);if(!(`cursor`in e.style))return!1;try{e.style.cursor=`url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEX///+nxBvIAAAACklEQVQI12NgAAAAAgAB4iG8MwAAAABJRU5ErkJggg==) 0 0, auto`}catch{return!1}return/\burl\([^()]*\)\s+0\s+0\b/.test(e.style.cursor||``)})();this.setCursor=function(t,n,r){if(s){var i=t.toDataURL(`image/png`);return e.style.cursor=`url(`+i+`) `+n+` `+r+`, auto`,!0}return!1}},W.Mouse.State=function(e){arguments.length>1?e=function(e,t,n,r,i,a,o){return{x:e,y:t,left:n,middle:r,right:i,up:a,down:o}}.apply(this,arguments):e||={},W.Position.call(this,e),this.left=e.left||!1,this.middle=e.middle||!1,this.right=e.right||!1,this.up=e.up||!1,this.down=e.down||!1},W.Mouse.State.Buttons={LEFT:`left`,MIDDLE:`middle`,RIGHT:`right`,UP:`up`,DOWN:`down`},W.Mouse.Event=function(e,t,n){W.Event.DOMEvent.call(this,e,n);var r=`on`+this.type;this.state=t,this.invokeLegacyHandler=function(e){e[r]&&(this.preventDefault(),this.stopPropagation(),e[r](this.state))}},W.Mouse.Event.Target=function(){W.Event.Target.call(this),this.currentState=new W.Mouse.State,this.press=function(e,t){this.currentState[e]||(this.currentState[e]=!0,this.dispatch(new W.Mouse.Event(`mousedown`,this.currentState,t)))},this.release=function(e,t){this.currentState[e]&&(this.currentState[e]=!1,this.dispatch(new W.Mouse.Event(`mouseup`,this.currentState,t)))},this.click=function(e,t){this.press(e,t),this.release(e,t)},this.move=function(e,t){(this.currentState.x!==e.x||this.currentState.y!==e.y)&&(this.currentState.x=e.x,this.currentState.y=e.y,this.dispatch(new W.Mouse.Event(`mousemove`,this.currentState,t)))},this.out=function(e){this.dispatch(new W.Mouse.Event(`mouseout`,this.currentState,e))},this.reset=function(e){for(var t in W.Mouse.State.Buttons)this.release(W.Mouse.State.Buttons[t],e)}},W.Mouse.Touchpad=function(e){W.Mouse.Event.Target.call(this);var t=this;this.scrollThreshold=20*(window.devicePixelRatio||1),this.clickTimingThreshold=250,this.clickMoveThreshold=10*(window.devicePixelRatio||1),this.currentState=new W.Mouse.State;var n=0,r=0,i=0,a=0,o=0,s={1:`left`,2:`right`,3:`middle`},c=!1,l=null;e.addEventListener(`touchend`,function(e){if(e.preventDefault(),c&&e.touches.length===0){var r=new Date().getTime(),i=s[n];t.currentState[i]&&(t.release(i,e),l&&=(window.clearTimeout(l),null)),r-a<=t.clickTimingThreshold&&o<t.clickMoveThreshold&&(t.press(i,e),l=window.setTimeout(function(){t.release(i,e),c=!1},t.clickTimingThreshold)),l||(c=!1)}},!1),e.addEventListener(`touchstart`,function(e){if(e.preventDefault(),n=Math.min(e.touches.length,3),l&&=(window.clearTimeout(l),null),!c){c=!0;var t=e.touches[0];r=t.clientX,i=t.clientY,a=new Date().getTime(),o=0}},!1),e.addEventListener(`touchmove`,function(s){s.preventDefault();var c=s.touches[0],l=c.clientX-r,u=c.clientY-i;if(o+=Math.abs(l)+Math.abs(u),n===1){var d=1+o/(new Date().getTime()-a),f=new W.Position(t.currentState);f.x+=l*d,f.y+=u*d,f.x=Math.min(Math.max(0,f.x),e.offsetWidth-1),f.y=Math.min(Math.max(0,f.y),e.offsetHeight-1),t.move(f,s),r=c.clientX,i=c.clientY}else if(n===2&&Math.abs(u)>=t.scrollThreshold){var p=u>0?`down`:`up`;t.click(p,s),r=c.clientX,i=c.clientY}},!1)},W.Mouse.Touchscreen=function(e){W.Mouse.Event.Target.call(this);var t=this,n=!1,r=null,i=null,a=null,o=null;this.scrollThreshold=20*(window.devicePixelRatio||1),this.clickTimingThreshold=250,this.clickMoveThreshold=16*(window.devicePixelRatio||1),this.longPressThreshold=500;function s(e){var n=e.touches[0]||e.changedTouches[0],a=n.clientX-r,o=n.clientY-i;return Math.sqrt(a*a+o*o)>=t.clickMoveThreshold}function c(e){var t=e.touches[0];n=!0,r=t.clientX,i=t.clientY}function l(){window.clearTimeout(a),window.clearTimeout(o),n=!1}e.addEventListener(`touchend`,function(r){if(n){if(r.touches.length!==0||r.changedTouches.length!==1){l();return}if(window.clearTimeout(o),t.release(W.Mouse.State.Buttons.LEFT,r),!s(r)&&(r.preventDefault(),!t.currentState.left)){var i=r.changedTouches[0];t.move(W.Position.fromClientPosition(e,i.clientX,i.clientY)),t.press(W.Mouse.State.Buttons.LEFT,r),a=window.setTimeout(function(){t.release(W.Mouse.State.Buttons.LEFT,r),l()},t.clickTimingThreshold)}}},!1),e.addEventListener(`touchstart`,function(n){if(n.touches.length!==1){l();return}n.preventDefault(),c(n),window.clearTimeout(a),o=window.setTimeout(function(){var r=n.touches[0];t.move(W.Position.fromClientPosition(e,r.clientX,r.clientY)),t.click(W.Mouse.State.Buttons.RIGHT,n),l()},t.longPressThreshold)},!1),e.addEventListener(`touchmove`,function(r){if(n){if(s(r)&&window.clearTimeout(o),r.touches.length!==1){l();return}if(t.currentState.left){r.preventDefault();var i=r.touches[0];t.move(W.Position.fromClientPosition(e,i.clientX,i.clientY),r)}}},!1)};var W=W||{},W=W||{};W.Object=function(e,t){var n=this,r={},i=function(e){var t=r[e];if(!t)return null;var n=t.shift();return t.length===0&&delete r[e],n},a=function(e,t){var n=r[e];n||(n=[],r[e]=n),n.push(t)};this.index=t,this.onbody=function(e,t,n){var r=i(n);r&&r(e,t)},this.onundefine=null,this.requestInputStream=function(t,r){r&&a(t,r),e.requestObjectInputStream(n.index,t)},this.createOutputStream=function(t,r){return e.createObjectOutputStream(n.index,t,r)}},W.Object.ROOT_STREAM=`/`,W.Object.STREAM_INDEX_MIMETYPE=`application/vnd.glyptodon.guacamole.stream-index+json`;var W=W||{};W.OnScreenKeyboard=function(e){var t=this,n={},r={},i=[],a=function(e,t){e.classList?e.classList.add(t):e.className+=` `+t},o=function(e,t){e.classList?e.classList.remove(t):e.className=e.className.replace(/([^ ]+)[ ]*/g,function(e,n){return n===t?``:e})},s=0,c=function(e,t,n,r){this.width=t,this.height=n,this.scale=function(i){e.style.width=t*i+`px`,e.style.height=n*i+`px`,r&&(e.style.lineHeight=n*i+`px`,e.style.fontSize=i+`px`)}},l=function(e){for(var t=0;t<e.length;t++)if(!(e[t]in n))return!1;return!0},u=function(e){var n=t.keys[e];if(!n)return null;for(var r=n.length-1;r>=0;r--){var i=n[r];if(l(i.requires))return i}return null},d=function(e,i){if(!r[e]){a(i,`guac-keyboard-pressed`);var s=u(e);if(s.modifier){var c=`guac-keyboard-modifier-`+g(s.modifier),l=n[s.modifier];l===void 0?(a(p,c),n[s.modifier]=s.keysym,s.keysym&&t.onkeydown&&t.onkeydown(s.keysym)):(o(p,c),delete n[s.modifier],l&&t.onkeyup&&t.onkeyup(l))}else t.onkeydown&&t.onkeydown(s.keysym);r[e]=!0}},f=function(e,n){if(r[e]){o(n,`guac-keyboard-pressed`);var i=u(e);!i.modifier&&t.onkeyup&&t.onkeyup(i.keysym),r[e]=!1}},p=document.createElement(`div`);p.className=`guac-keyboard`,p.onselectstart=p.onmousemove=p.onmouseup=p.onmousedown=function(e){return s&&s--,e.stopPropagation(),!1},this.touchMouseThreshold=3,this.onkeydown=null,this.onkeyup=null,this.layout=new W.OnScreenKeyboard.Layout(e),this.getElement=function(){return p},this.resize=function(e){for(var n=Math.floor(e*10/t.layout.width)/10,r=0;r<i.length;r++)i[r].scale(n)};var m=function(e,t){if(t instanceof Array){for(var n=[],r=0;r<t.length;r++)n.push(new W.OnScreenKeyboard.Key(t[r],e));return n}return typeof t==`number`?[new W.OnScreenKeyboard.Key({name:e,keysym:t})]:typeof t==`string`?[new W.OnScreenKeyboard.Key({name:e,title:t})]:[new W.OnScreenKeyboard.Key(t,e)]},h=function(t){var n={};for(var r in e.keys)n[r]=m(r,t[r]);return n};this.keys=h(e.keys);var g=function(e){return e.replace(/([a-z])([A-Z])/g,`$1-$2`).replace(/[^A-Za-z0-9]+/g,`-`).toLowerCase()};(function e(n,r,o){var l,u=document.createElement(`div`);if(o&&a(u,`guac-keyboard-`+g(o)),r instanceof Array)for(a(u,`guac-keyboard-group`),l=0;l<r.length;l++)e(u,r[l]);else if(r instanceof Object){a(u,`guac-keyboard-group`);var p=Object.keys(r).sort();for(l=0;l<p.length;l++){var o=p[l];e(u,r[o],o)}}else if(typeof r==`number`)a(u,`guac-keyboard-gap`),i.push(new c(u,r,r));else if(typeof r==`string`){var m=r;m.length===1&&(m=`0x`+m.charCodeAt(0).toString(16)),a(u,`guac-keyboard-key-container`);var h=document.createElement(`div`);h.className=`guac-keyboard-key guac-keyboard-key-`+g(m);var _=t.keys[r];if(_)for(l=0;l<_.length;l++){var v=_[l],y=document.createElement(`div`);y.className=`guac-keyboard-cap`,y.textContent=v.title;for(var b=0;b<v.requires.length;b++){var x=v.requires[b];a(y,`guac-keyboard-requires-`+g(x)),a(h,`guac-keyboard-uses-`+g(x))}h.appendChild(y)}u.appendChild(h),i.push(new c(u,t.layout.keyWidths[r]||1,1,!0));var S=function(e){e.preventDefault(),s=t.touchMouseThreshold,d(r,h)},C=function(e){e.preventDefault(),s=t.touchMouseThreshold,f(r,h)},w=function(e){e.preventDefault(),s===0&&d(r,h)},T=function(e){e.preventDefault(),s===0&&f(r,h)};h.addEventListener(`touchstart`,S,!0),h.addEventListener(`touchend`,C,!0),h.addEventListener(`mousedown`,w,!0),h.addEventListener(`mouseup`,T,!0),h.addEventListener(`mouseout`,T,!0)}n.appendChild(u)})(p,e.layout)},W.OnScreenKeyboard.Layout=function(e){this.language=e.language,this.type=e.type,this.keys=e.keys,this.layout=e.layout,this.width=e.width,this.keyWidths=e.keyWidths||{}},W.OnScreenKeyboard.Key=function(e,t){this.name=t||e.name,this.title=e.title||this.name,this.keysym=e.keysym||(function(e){if(!e||e.length!==1)return null;var t=e.charCodeAt(0);return t>=0&&t<=255?t:t>=256&&t<=1114111?16777216|t:null})(this.title),this.modifier=e.modifier,this.requires=e.requires||[]};var W=W||{};W.OutputStream=function(e,t){var n=this;this.index=t,this.onack=null,this.sendBlob=function(t){e.sendBlob(n.index,t)},this.sendEnd=function(){e.endStream(n.index)}};var W=W||{};W.Parser=function(){var e=this,t=``,n=[],r=-1,i=0;this.receive=function(a){for(i>4096&&r>=i&&(t=t.substring(i),r-=i,i=0),t+=a;r<t.length;){if(r>=i){var o=t.substring(i,r),s=t.substring(r,r+1);if(n.push(o),s==`;`){var c=n.shift();e.oninstruction!=null&&e.oninstruction(c,n),n.length=0}else if(s!=`,`)throw Error(`Illegal terminator.`);i=r+1}var l=t.indexOf(`.`,i);if(l!=-1){var u=parseInt(t.substring(r+1,l));if(isNaN(u))throw Error(`Non-numeric character in element length.`);i=l+1,r=i+u}else{i=t.length;break}}},this.oninstruction=null};var W=W||{};W.Position=function(e){e||={},this.x=e.x||0,this.y=e.y||0,this.fromClientPosition=function(e,t,n){this.x=t-e.offsetLeft,this.y=n-e.offsetTop;for(var r=e.offsetParent;r&&r!==document.body;)this.x-=r.offsetLeft-r.scrollLeft,this.y-=r.offsetTop-r.scrollTop,r=r.offsetParent;if(r){var i=document.body.scrollLeft||document.documentElement.scrollLeft,a=document.body.scrollTop||document.documentElement.scrollTop;this.x-=r.offsetLeft-i,this.y-=r.offsetTop-a}}},W.Position.fromClientPosition=function(e,t,n){var r=new W.Position;return r.fromClientPosition(e,t,n),r};var W=W||{};W.RawAudioFormat=function(e){this.bytesPerSample=e.bytesPerSample,this.channels=e.channels,this.rate=e.rate},W.RawAudioFormat.parse=function(e){var t,n=null,r=1;if(e.substring(0,9)===`audio/L8;`)e=e.substring(9),t=1;else if(e.substring(0,10)===`audio/L16;`)e=e.substring(10),t=2;else return null;for(var i=e.split(`,`),a=0;a<i.length;a++){var o=i[a],s=o.indexOf(`=`);if(s===-1)return null;var c=o.substring(0,s),l=o.substring(s+1);switch(c){case`channels`:r=parseInt(l);break;case`rate`:n=parseInt(l);break;default:return null}}return n===null?null:new W.RawAudioFormat({bytesPerSample:t,channels:r,rate:n})};var W=W||{};W.SessionRecording=function(e){var t=this,n,r=null,i=262144,a=16384,o=5e3,s=[],c=0,l=new W.SessionRecording._PlaybackTunnel,u=new W.Client(l),d=-1,f=null,p=null,m=null,h=0,g=0,_=!1,v=null,y=function(e,r,a){if(!(_&&e===n)){var o=new W.Parser;o.oninstruction=r;var s=0,c=new FileReader,l=function(){if(!(_&&e===n)){if(c.readyState===2)try{o.receive(c.result)}catch(e){t.onerror&&t.onerror(e.message);return}if(s>=e.size)a&&a();else{var r=e.slice(s,s+i);s+=r.size,c.readAsText(r)}}};c.onload=l,l()}},b=function(e){for(var t=e.length,n=t+3;t>=10;)n++,t=Math.floor(t/10);return n};u.connect(),u.getDisplay().showCursor(!1);var x=function(e,n){g+=b(e);for(var r=0;r<n.length;r++)g+=b(n[r]);if(e===`sync`){var i=parseInt(n[0]),l=new W.SessionRecording._Frame(i,h,g);s.push(l),h=g,(s.length===1||g-s[c].start>=a&&i-s[c].timestamp>=o)&&(l.keyframe=!0,c=s.length-1),t.onprogress&&t.onprogress(t.getDuration(),g)}},S=function(){t.onload&&t.onload()};if(e instanceof Blob)y(n,x,S);else{r=e,n=new Blob;var C=!1,w=``;r.oninstruction=function(e,t){w+=e.length+`.`+e,t.forEach(function(e){w+=`,`+e.length+`.`+e}),w+=`;`,w.length>=i&&(n=new Blob([n,w]),w=``),x(e,t)},r.onerror=function(e){C=!0,t.onerror&&t.onerror(e.message)},r.onstatechange=function(e){e===W.Tunnel.State.CLOSED&&(w.length&&(n=new Blob([n,w]),w=``),C||S())}}var T=function(e){return s.length===0?0:e-s[0].timestamp},E=function e(t,n,r){if(t===n)return t;var i=Math.floor((t+n)/2),a=T(s[i].timestamp);return r<a&&i>t?e(t,i-1,r):r>a&&i<n?e(i+1,n,r):i},D=function(e,t){var r=s[e];y(n.slice(r.start,r.end),function(e,t){l.receiveInstruction(e,t)},function(){r.keyframe&&!r.clientState&&u.exportState(function(e){r.clientState=new Blob([JSON.stringify(e)])}),d=e,t&&t()})},O=function(e,n,r){k();for(var i=m={aborted:!1},a=e,o=function r(){t.onseek&&d>a&&t.onseek(T(s[d].timestamp),d-a,e-a),!i.aborted&&(d<e?D(d+1,r):n())},c=function(){var e=r?Math.max(r-new Date().getTime(),0):0;e?window.setTimeout(o,e):o()};a>=0;a--){var l=s[a];if(a===d)break;if(l.clientState){l.clientState.text().then(function(e){u.importState(JSON.parse(e)),d=a,c()});return}}c()},k=function(){m&&=(m.aborted=!0,null)},A=function e(){if(d+1<s.length){var n=s[d+1].timestamp-f+p;O(d+1,function(){e()},n)}else t.pause()};this.onload=null,this.onerror=null,this.onabort=null,this.onprogress=null,this.onplay=null,this.onpause=null,this.onseek=null,this.connect=function(e){r&&r.connect(e)},this.disconnect=function(){r&&r.disconnect()},this.abort=function(){_||(_=!0,t.onabort&&t.onabort(),r&&r.disconnect())},this.getDisplay=function(){return u.getDisplay()},this.isPlaying=function(){return!!f},this.getPosition=function(){return d===-1?0:T(s[d].timestamp)},this.getDuration=function(){return s.length===0?0:T(s[s.length-1].timestamp)},this.play=function(){!t.isPlaying()&&d+1<s.length&&(t.onplay&&t.onplay(),f=s[d+1].timestamp,p=new Date().getTime(),A())},this.seek=function(e,n){if(s.length!==0){t.cancel();var r=t.isPlaying();t.pause(),v=function(){v=null,r&&=(t.play(),null),n&&n()},O(E(0,s.length-1,e),v)}},this.cancel=function(){v&&(k(),v())},this.pause=function(){k(),t.isPlaying()&&(t.onpause&&t.onpause(),f=null,p=null)}},W.SessionRecording._Frame=function(e,t,n){this.keyframe=!1,this.timestamp=e,this.start=t,this.end=n,this.clientState=null},W.SessionRecording._PlaybackTunnel=function(){var e=this;this.connect=function(e){},this.sendMessage=function(e){},this.disconnect=function(){},this.receiveInstruction=function(t,n){e.oninstruction&&e.oninstruction(t,n)}};var W=W||{};W.Status=function(e,t){var n=this;this.code=e,this.message=t,this.isError=function(){return n.code<0||n.code>255}},W.Status.Code={SUCCESS:0,UNSUPPORTED:256,SERVER_ERROR:512,SERVER_BUSY:513,UPSTREAM_TIMEOUT:514,UPSTREAM_ERROR:515,RESOURCE_NOT_FOUND:516,RESOURCE_CONFLICT:517,RESOURCE_CLOSED:518,UPSTREAM_NOT_FOUND:519,UPSTREAM_UNAVAILABLE:520,SESSION_CONFLICT:521,SESSION_TIMEOUT:522,SESSION_CLOSED:523,CLIENT_BAD_REQUEST:768,CLIENT_UNAUTHORIZED:769,CLIENT_FORBIDDEN:771,CLIENT_TIMEOUT:776,CLIENT_OVERRUN:781,CLIENT_BAD_TYPE:783,CLIENT_TOO_MANY:797},W.Status.Code.fromHTTPCode=function(e){switch(e){case 400:return W.Status.Code.CLIENT_BAD_REQUEST;case 403:return W.Status.Code.CLIENT_FORBIDDEN;case 404:return W.Status.Code.RESOURCE_NOT_FOUND;case 429:return W.Status.Code.CLIENT_TOO_MANY;case 503:return W.Status.Code.SERVER_BUSY}return W.Status.Code.SERVER_ERROR},W.Status.Code.fromWebSocketCode=function(e){switch(e){case 1e3:return W.Status.Code.SUCCESS;case 1006:case 1015:return W.Status.Code.UPSTREAM_NOT_FOUND;case 1001:case 1012:case 1013:case 1014:return W.Status.Code.UPSTREAM_UNAVAILABLE}return W.Status.Code.SERVER_ERROR};var W=W||{};W.StringReader=function(e){var t=this,n=new W.UTF8Parser,r=new W.ArrayBufferReader(e);r.ondata=function(e){var r=n.decode(e);t.ontext&&t.ontext(r)},r.onend=function(){t.onend&&t.onend()},this.ontext=null,this.onend=null};var W=W||{};W.StringWriter=function(e){var t=this,n=new W.ArrayBufferWriter(e),r=new Uint8Array(8192),i=0;n.onack=function(e){t.onack&&t.onack(e)};function a(e){if(i+e>=r.length){var t=new Uint8Array((i+e)*2);t.set(r),r=t}i+=e}function o(e){var t,n;if(e<=127)t=0,n=1;else if(e<=2047)t=192,n=2;else if(e<=65535)t=224,n=3;else if(e<=2097151)t=240,n=4;else{o(65533);return}a(n);for(var s=i-1,c=1;c<n;c++)r[s--]=128|e&63,e>>=6;r[s]=t|e}function s(e){for(var t=0;t<e.length;t++)o(e.charCodeAt(t));if(i>0){var n=r.subarray(0,i);return i=0,n}}this.sendText=function(e){e.length&&n.sendData(s(e))},this.sendEnd=function(){n.sendEnd()},this.onack=null};var W=W||{};W.Touch=function(e){W.Event.Target.call(this);var t=this,n=Math.floor(16*window.devicePixelRatio);this.touches={},this.activeTouches=0,e.addEventListener(`touchstart`,function(r){for(var i=0;i<r.changedTouches.length;i++){var a=r.changedTouches[i],o=a.identifier;if(!t.touches[o]){var s=t.touches[o]=new W.Touch.State({id:o,radiusX:a.radiusX||n,radiusY:a.radiusY||n,angle:a.angle||0,force:a.force||1});t.activeTouches++,s.fromClientPosition(e,a.clientX,a.clientY),t.dispatch(new W.Touch.Event(`touchmove`,r,s))}}},!1),e.addEventListener(`touchmove`,function(r){for(var i=0;i<r.changedTouches.length;i++){var a=r.changedTouches[i],o=a.identifier,s=t.touches[o];s&&(a.force&&(s.force=a.force),s.angle=a.angle||0,s.radiusX=a.radiusX||n,s.radiusY=a.radiusY||n,s.fromClientPosition(e,a.clientX,a.clientY),t.dispatch(new W.Touch.Event(`touchmove`,r,s)))}},!1),e.addEventListener(`touchend`,function(n){for(var r=0;r<n.changedTouches.length;r++){var i=n.changedTouches[r],a=i.identifier,o=t.touches[a];o&&(delete t.touches[a],t.activeTouches--,o.force=0,o.fromClientPosition(e,i.clientX,i.clientY),t.dispatch(new W.Touch.Event(`touchend`,n,o)))}},!1)},W.Touch.State=function(e){e||={},W.Position.call(this,e),this.id=e.id||0,this.radiusX=e.radiusX||0,this.radiusY=e.radiusY||0,this.angle=e.angle||0,this.force=e.force||1},W.Touch.Event=function(e,t,n){W.Event.DOMEvent.call(this,e,[t]),this.state=n};var W=W||{};W.Tunnel=function(){this.connect=function(e){},this.disconnect=function(){},this.sendMessage=function(e){},this.setState=function(e){e!==this.state&&(this.state=e,this.onstatechange&&this.onstatechange(e))},this.setUUID=function(e){this.uuid=e,this.onuuid&&this.onuuid(e)},this.isConnected=function(){return this.state===W.Tunnel.State.OPEN||this.state===W.Tunnel.State.UNSTABLE},this.state=W.Tunnel.State.CLOSED,this.receiveTimeout=15e3,this.unstableThreshold=1500,this.uuid=null,this.onuuid=null,this.onerror=null,this.onstatechange=null,this.oninstruction=null},W.Tunnel.INTERNAL_DATA_OPCODE=``,W.Tunnel.State={CONNECTING:0,OPEN:1,CLOSED:2,UNSTABLE:3},W.HTTPTunnel=function(e,t,n){var r=this,i=e+`?connect`,a=e+`?read:`,o=e+`?write:`,s=1,c=0,l=s,u=!1,d=``,f=!!t,p=null,m=null,h=null,g=500,_=n||{},v=`Guacamole-Tunnel-Token`,y=null;function b(e,t){for(var n in t)e.setRequestHeader(n,t[n])}var x=function(){window.clearTimeout(p),window.clearTimeout(m),r.state===W.Tunnel.State.UNSTABLE&&r.setState(W.Tunnel.State.OPEN),p=window.setTimeout(function(){S(new W.Status(W.Status.Code.UPSTREAM_TIMEOUT,`Server timeout.`))},r.receiveTimeout),m=window.setTimeout(function(){r.setState(W.Tunnel.State.UNSTABLE)},r.unstableThreshold)};function S(e){window.clearTimeout(p),window.clearTimeout(m),window.clearInterval(h),r.state!==W.Tunnel.State.CLOSED&&(e.code!==W.Status.Code.SUCCESS&&r.onerror&&(r.state===W.Tunnel.State.CONNECTING||e.code!==W.Status.Code.RESOURCE_NOT_FOUND)&&r.onerror(e),u=!1,r.setState(W.Tunnel.State.CLOSED))}this.sendMessage=function(){if(!r.isConnected()||arguments.length===0)return;function e(e){var t=new String(e);return t.length+`.`+t}for(var t=e(arguments[0]),n=1;n<arguments.length;n++)t+=`,`+e(arguments[n]);t+=`;`,d+=t,u||C()};function C(){if(r.isConnected())if(d.length>0){u=!0;var e=new XMLHttpRequest;e.open(`POST`,o+r.uuid),e.withCredentials=f,b(e,_),e.setRequestHeader(`Content-type`,`application/octet-stream`),e.setRequestHeader(v,y),e.onreadystatechange=function(){e.readyState===4&&(x(),e.status===200?C():w(e))},e.send(d),d=``}else u=!1}function w(e){var t=parseInt(e.getResponseHeader(`Guacamole-Status-Code`));if(t){var n=e.getResponseHeader(`Guacamole-Error-Message`);S(new W.Status(t,n))}else e.status?S(new W.Status(W.Status.Code.fromHTTPCode(e.status),e.statusText)):S(new W.Status(W.Status.Code.UPSTREAM_NOT_FOUND))}function T(e){var t=null,n=null,i=0,a=-1,o=0,u=[];function d(){if(!r.isConnected()){t!==null&&clearInterval(t);return}if(!(e.readyState<2)){var i;try{i=e.status}catch{i=200}if(!n&&i===200&&(n=D()),e.readyState===3||e.readyState===4){if(x(),l===s&&(e.readyState===3&&!t?t=setInterval(d,30):e.readyState===4&&t&&clearInterval(t)),e.status===0){r.disconnect();return}else if(e.status!==200){w(e);return}var c;try{c=e.responseText}catch{return}for(;a<c.length;){if(a>=o){var f=c.substring(o,a),p=c.substring(a,a+1);if(u.push(f),p===`;`){var m=u.shift();r.oninstruction&&r.oninstruction(m,u),u.length=0}o=a+1}var h=c.indexOf(`.`,o);if(h!==-1){var g=parseInt(c.substring(a+1,h));if(g===0){t&&clearInterval(t),e.onreadystatechange=null,e.abort(),n&&T(n);break}o=h+1,a=o+g}else{o=c.length;break}}}}}l===s?e.onreadystatechange=function(){e.readyState===3&&(i++,i>=2&&(l=c,e.onreadystatechange=d)),d()}:e.onreadystatechange=d,d()}var E=0;function D(){var e=new XMLHttpRequest;return e.open(`GET`,a+r.uuid+`:`+ E++),e.setRequestHeader(v,y),e.withCredentials=f,b(e,_),e.send(null),e}this.connect=function(e){x(),r.setState(W.Tunnel.State.CONNECTING);var t=new XMLHttpRequest;t.onreadystatechange=function(){if(t.readyState===4){if(t.status!==200){w(t);return}if(x(),r.setUUID(t.responseText),y=t.getResponseHeader(v),!y){S(new W.Status(W.Status.Code.UPSTREAM_NOT_FOUND));return}r.setState(W.Tunnel.State.OPEN),h=setInterval(function(){r.sendMessage(`nop`)},g),T(D())}},t.open(`POST`,i,!0),t.withCredentials=f,b(t,_),t.setRequestHeader(`Content-type`,`application/x-www-form-urlencoded; charset=UTF-8`),t.send(e)},this.disconnect=function(){S(new W.Status(W.Status.Code.SUCCESS,`Manually closed.`))}},W.HTTPTunnel.prototype=new W.Tunnel,W.WebSocketTunnel=function(e){var t=this,n=null,r=null,i=null,a=null,o={"http:":`ws:`,"https:":`wss:`},s=500,c=0;if(e.substring(0,3)!==`ws:`&&e.substring(0,4)!==`wss:`){var l=o[window.location.protocol];if(e.substring(0,1)===`/`)e=l+`//`+window.location.host+e;else{var u=window.location.pathname.lastIndexOf(`/`),d=window.location.pathname.substring(0,u+1);e=l+`//`+window.location.host+d+e}}var f=function(){var e=new Date().getTime();t.sendMessage(W.Tunnel.INTERNAL_DATA_OPCODE,`ping`,e),c=e},p=function(){window.clearTimeout(r),window.clearTimeout(i),window.clearTimeout(a),t.state===W.Tunnel.State.UNSTABLE&&t.setState(W.Tunnel.State.OPEN),r=window.setTimeout(function(){m(new W.Status(W.Status.Code.UPSTREAM_TIMEOUT,`Server timeout.`))},t.receiveTimeout),i=window.setTimeout(function(){t.setState(W.Tunnel.State.UNSTABLE)},t.unstableThreshold);var e=new Date().getTime(),n=Math.max(c+s-e,0);n>0?a=window.setTimeout(f,n):f()};function m(e){window.clearTimeout(r),window.clearTimeout(i),window.clearTimeout(a),t.state!==W.Tunnel.State.CLOSED&&(e.code!==W.Status.Code.SUCCESS&&t.onerror&&t.onerror(e),t.setState(W.Tunnel.State.CLOSED),n.close())}this.sendMessage=function(e){if(!t.isConnected()||arguments.length===0)return;function r(e){var t=new String(e);return t.length+`.`+t}for(var i=r(arguments[0]),a=1;a<arguments.length;a++)i+=`,`+r(arguments[a]);i+=`;`,n.send(i)},this.connect=function(r){p(),t.setState(W.Tunnel.State.CONNECTING),n=new WebSocket(e+`?`+r,`guacamole`),n.onopen=function(e){p()},n.onclose=function(e){e.reason?m(new W.Status(parseInt(e.reason),e.reason)):e.code?m(new W.Status(W.Status.Code.fromWebSocketCode(e.code))):m(new W.Status(W.Status.Code.UPSTREAM_NOT_FOUND))},n.onmessage=function(e){p();var n=e.data,r=0,i,a=[];do{var o=n.indexOf(`.`,r);if(o!==-1){var s=parseInt(n.substring(i+1,o));r=o+1,i=r+s}else m(new W.Status(W.Status.Code.SERVER_ERROR,`Incomplete instruction.`));var c=n.substring(r,i),l=n.substring(i,i+1);if(a.push(c),l===`;`){var u=a.shift();t.uuid===null&&(u===W.Tunnel.INTERNAL_DATA_OPCODE&&a.length===1&&t.setUUID(a[0]),t.setState(W.Tunnel.State.OPEN)),u!==W.Tunnel.INTERNAL_DATA_OPCODE&&t.oninstruction&&t.oninstruction(u,a),a.length=0}r=i+1}while(r<n.length)}},this.disconnect=function(){m(new W.Status(W.Status.Code.SUCCESS,`Manually closed.`))}},W.WebSocketTunnel.prototype=new W.Tunnel,W.ChainedTunnel=function(e){for(var t=this,n,r=[],i=null,a=0;a<arguments.length;a++)r.push(arguments[a]);function o(e){t.disconnect=e.disconnect,t.sendMessage=e.sendMessage;var a=function(t){if(t&&t.code===W.Status.Code.UPSTREAM_TIMEOUT)return r=[],null;var n=r.shift();return n&&(e.onerror=null,e.oninstruction=null,e.onstatechange=null,o(n)),n};function s(){e.onstatechange=t.onstatechange,e.oninstruction=t.oninstruction,e.onerror=t.onerror,e.uuid&&t.setUUID(e.uuid),e.onuuid=function(e){t.setUUID(e)},i=e}e.onstatechange=function(e){switch(e){case W.Tunnel.State.OPEN:s(),t.onstatechange&&t.onstatechange(e);break;case W.Tunnel.State.CLOSED:!a()&&t.onstatechange&&t.onstatechange(e);break}},e.oninstruction=function(e,n){s(),t.oninstruction&&t.oninstruction(e,n)},e.onerror=function(e){!a(e)&&t.onerror&&t.onerror(e)},e.connect(n)}this.connect=function(e){n=e;var a=i||r.shift();a?o(a):t.onerror&&t.onerror(W.Status.Code.SERVER_ERROR,`No tunnels to try.`)}},W.ChainedTunnel.prototype=new W.Tunnel,W.StaticHTTPTunnel=function(e,t,n){var r=this,i=null,a=n||{};this.size=null,this.sendMessage=function(e){},this.connect=function(n){r.disconnect(),r.setState(W.Tunnel.State.CONNECTING);var o=new W.Parser,s=new W.UTF8Parser;o.oninstruction=function(e,t){r.oninstruction&&r.oninstruction(e,t)},i=new AbortController,fetch(e,{headers:a,credentials:t?`include`:`same-origin`,signal:i.signal}).then(function(e){if(!e.ok){r.onerror&&r.onerror(new W.Status(W.Status.Code.fromHTTPCode(e.status),e.statusText)),r.disconnect();return}r.size=e.headers.get(`Content-Length`),r.setState(W.Tunnel.State.OPEN);var t=e.body.getReader();t.read().then(function e(n){if(n.done){r.disconnect();return}o.receive(s.decode(n.value)),t.read().then(e)})})},this.disconnect=function(){i&&=(i.abort(),null),r.setState(W.Tunnel.State.CLOSED)}},W.StaticHTTPTunnel.prototype=new W.Tunnel;var W=W||{};W.UTF8Parser=function(){var e=0,t=0;this.decode=function(n){for(var r=``,i=new Uint8Array(n),a=0;a<i.length;a++){var o=i[a];e===0?(o|127)==127?r+=String.fromCharCode(o):(o|31)==223?(t=o&31,e=1):(o|15)==239?(t=o&15,e=2):(o|7)==247?(t=o&7,e=3):r+=`�`:(o|63)==191?(t=t<<6|o&63,e--,e===0&&(r+=String.fromCharCode(t))):(e=0,r+=`�`)}return r}};var W=W||{};W.API_VERSION=`1.5.0`;var W=W||{};W.VideoPlayer=function(){this.sync=function(){}},W.VideoPlayer.isSupportedType=function(e){return!1},W.VideoPlayer.getSupportedTypes=function(){return[]},W.VideoPlayer.getInstance=function(e,t,n){return null};var G=W;function K(e){return[[`hostname`,e.hostname],[`port`,String(e.port)],[`username`,e.username],[`password`,e.password],[`security`,`any`],[`ignore-cert`,`true`],[`disable-wallpaper`,`true`],[`disable-theming`,`true`],[`enable-font-smoothing`,`true`]].map(([e,t])=>`${e}=${encodeURIComponent(t)}`).join(`&`)}function se(){let e=O(`idle`),t=O(``),n=O(``),r=M(null),i=null,a=null,o=null,s=null;function c(){o?.disconnect(),o=null,s&&r.value?.parentElement===s&&(s.innerHTML=``),r.value=null}function u(){c();try{i?.disconnect()}catch{}i=null,a=null,e.value!==`error`&&(e.value=`disconnected`)}function d(){if(!i||!s)return;let e=Math.max(640,s.clientWidth||1024),t=Math.max(480,s.clientHeight||768);i.sendSize(e,t)}async function f(c,l){u(),s=l,e.value=`loading`,t.value=``;let f=_();if(!f.token){e.value=`error`,t.value=`未登录`;return}let p;try{p=await T.get(`/rdp/hosts/${c}/connect`)}catch(n){e.value=`error`,t.value=z(n,`加载 RDP 连接参数失败`);return}n.value=p.name,e.value=`connecting`;let m=H(`/ws/rdp/hosts/${c}/tunnel/${encodeURIComponent(f.token)}`);a=new G.WebSocketTunnel(m);let h=new G.Client(a);i=h,h.onerror=n=>{e.value=`error`,t.value=n?.message||`RDP 错误 (${n?.code??`unknown`})`,u()},h.onstatechange=t=>{if(t===G.Client.STATE_CONNECTED){e.value=`connected`;let t=h.getDisplay().getElement();t&&s&&(s.innerHTML=``,s.appendChild(t),r.value=t,d(),o=new ResizeObserver(()=>d()),o.observe(s))}else t===G.Client.STATE_DISCONNECTED&&e.value!==`error`&&(e.value=`disconnected`)};let g=h.getDisplay();g.onresize=()=>d(),h.connect(K(p))}return l(()=>u()),{status:e,errorMessage:t,serverName:n,connect:f,disconnect:u,sendDisplaySize:d}}function ce(){return{name:``,host:``,port:3389,username:`Administrator`,password:``,description:``}}function le(){let e=t(),n=O([]),r=O(``),i=O(!1),a=O(!1),o=F(()=>{let e=r.value.trim().toLowerCase();return e?n.value.filter(t=>t.name.toLowerCase().includes(e)||t.host.toLowerCase().includes(e)||t.username.toLowerCase().includes(e)):n.value});async function s(){i.value=!0;try{n.value=(await T.get(`/rdp/hosts/`)).items||[]}catch(t){n.value=[],e(z(t,`加载 RDP 主机列表失败`),`warning`)}finally{i.value=!1}}async function c(t){a.value=!0;try{let n=await T.post(`/rdp/hosts/`,{name:t.name.trim(),host:t.host.trim(),port:Number(t.port)||3389,username:t.username.trim(),password:t.password,description:t.description.trim()||void 0});return await s(),e(`已添加 RDP 主机`,`success`),n}catch(t){return e(z(t,`添加失败`),`error`),null}finally{a.value=!1}}async function l(t,n,r){a.value=!0;try{let i={name:n.name.trim(),host:n.host.trim(),port:Number(n.port)||3389,username:n.username.trim(),description:n.description.trim()||``};if(n.password.trim())i.password=n.password.trim();else if(!r)return e(`请填写 RDP 密码`,`error`),!1;return await T.put(`/rdp/hosts/${t}`,i),await s(),e(`已保存`,`success`),!0}catch(t){return e(z(t,`保存失败`),`error`),!1}finally{a.value=!1}}async function u(t,n){a.value=!0;try{return await T.delete(`/rdp/hosts/${t}`),await s(),e(`已删除「${n}」`,`success`),!0}catch(t){return e(z(t,`删除失败`),`error`),!1}finally{a.value=!1}}return{hosts:n,search:r,filteredHosts:o,loading:i,saving:a,loadHosts:s,createHost:c,updateHost:l,deleteHost:u}}var ue={key:0,class:`text-medium-emphasis`},de={key:0,class:`rdp-list-panel`},fe={class:`d-flex align-center ga-2 mb-3`,style:{"max-width":`640px`,width:`100%`}},pe={key:1,class:`rdp-placeholder`},me={class:`text-medium-emphasis mt-3`},he={key:2,class:`rdp-placeholder`},q=I(u({name:`RdpPage`,__name:`RdpPage`,setup(t){let n=k(),r=S(),l=O(null),{status:u,errorMessage:_,serverName:T,connect:M,disconnect:N}=se(),{search:I,filteredHosts:z,loading:V,saving:H,loadHosts:U,createHost:W,updateHost:G,deleteHost:K}=le(),q=O(!1),J=O(ce()),Y=O(null),X=O(!1),Z=O(!1),Q=O(null),$=F(()=>{let e=n.query.host_id,t=Number(Array.isArray(e)?e[0]:e);return Number.isFinite(t)&&t>0?t:null}),ge=F(()=>!$.value&&(u.value===`idle`||u.value===`disconnected`)),_e=F(()=>{switch(u.value){case`loading`:return`加载中`;case`connecting`:return`连接中`;case`connected`:return`已连接`;case`error`:return`失败`;case`disconnected`:return`已断开`;default:return``}}),ve=F(()=>{switch(u.value){case`connected`:return`success`;case`error`:return`error`;case`connecting`:case`loading`:return`warning`;default:return`default`}});function ye(e){r.push({path:`/rdp`,query:{host_id:String(e)}})}function be(){N(),r.replace({path:`/rdp`})}function xe(){N(),$.value&&r.replace({path:`/rdp`})}function Se(){Y.value=null,X.value=!1,J.value=ce(),q.value=!0}function Ce(e){Y.value=e.id,X.value=e.password_set,J.value={name:e.name,host:e.host,port:e.port,username:e.username,password:``,description:e.description||``},q.value=!0}async function we(e){if(Y.value!=null){await G(Y.value,e,X.value)&&(q.value=!1);return}let t=await W(e);t&&(q.value=!1,ye(t.id))}function Te(e){Q.value=e,Z.value=!0}async function Ee(){let e=Q.value;e&&await K(e.id,e.name)&&(Z.value=!1,Q.value=null)}async function De(){let e=$.value,t=l.value;!e||!t||await M(e,t)}return v($,(e,t)=>{if(e!==t){if(!e){N();return}De()}}),f(async()=>{await U(),$.value&&De()}),(t,n)=>(g(),P(e,{fluid:``,class:`pa-0 d-flex flex-column rdp-root`},{default:b(()=>[o(ee,{density:`compact`,color:`surface`,border:``},{default:b(()=>[o(d,{class:`text-body-1 font-weight-medium`},{default:b(()=>[n[4]||=m(` 3389远程 `,-1),w(T)?(g(),a(`span`,ue,` — `+D(w(T)),1)):p(``,!0)]),_:1}),o(x),w(u)===`idle`?p(``,!0):(g(),P(te,{key:0,size:`small`,variant:`tonal`,color:ve.value,label:``,class:`mr-2`},{default:b(()=>[m(D(_e.value),1)]),_:1},8,[`color`])),$.value?(g(),P(c,{key:1,variant:`text`,size:`small`,class:`mr-1`,onClick:be},{default:b(()=>[...n[5]||=[m(` 返回列表 `,-1)]]),_:1})):p(``,!0),o(c,{variant:`tonal`,color:`error`,size:`small`,disabled:w(u)===`idle`||w(u)===`disconnected`,onClick:xe},{default:b(()=>[...n[6]||=[m(` 断开 `,-1)]]),_:1},8,[`disabled`])]),_:1}),C(`div`,{ref_key:`displayHost`,ref:l,class:`rdp-display-host flex-grow-1`},[ge.value?(g(),a(`div`,de,[C(`div`,fe,[o(R,{modelValue:w(I),"onUpdate:modelValue":n[0]||=e=>i(I)?I.value=e:null,"prepend-inner-icon":`mdi-magnify`,placeholder:`搜索名称、地址…`,variant:`outlined`,density:`compact`,"hide-details":``,class:`flex-grow-1`},null,8,[`modelValue`]),o(c,{color:`primary`,variant:`flat`,"prepend-icon":`mdi-plus`,onClick:Se},{default:b(()=>[...n[7]||=[m(` 添加 `,-1)]]),_:1})]),w(V)?(g(),P(ae,{key:0,type:`list-item@4`,"max-width":`640`,width:`100%`})):(g(),P(L,{key:1,border:``,rounded:`lg`,"max-width":`640`,width:`100%`},{default:b(()=>[o(A,{density:`comfortable`,nav:``},{default:b(()=>[(g(!0),a(E,null,h(w(z),e=>(g(),P(j,{key:e.id,title:e.name,subtitle:`${e.host}:${e.port} · ${e.username}`,rounded:`lg`},{append:b(()=>[o(c,{color:`primary`,variant:`tonal`,size:`small`,class:`mr-1`,onClick:t=>ye(e.id)},{default:b(()=>[...n[8]||=[m(` 连接 `,-1)]]),_:1},8,[`onClick`]),o(c,{icon:`mdi-pencil`,variant:`text`,size:`small`,onClick:t=>Ce(e)},null,8,[`onClick`]),o(c,{icon:`mdi-delete`,variant:`text`,size:`small`,color:`error`,onClick:t=>Te(e)},null,8,[`onClick`])]),_:2},1032,[`title`,`subtitle`]))),128)),w(z).length===0?(g(),P(j,{key:0,class:`text-medium-emphasis`},{default:b(()=>[...n[9]||=[m(` 暂无 RDP 主机,点击「添加」录入 Windows 远程地址 `,-1)]]),_:1})):p(``,!0)]),_:1})]),_:1}))])):w(u)===`loading`||w(u)===`connecting`?(g(),a(`div`,pe,[o(y,{indeterminate:``,color:`primary`,size:`40`}),C(`p`,me,D(w(u)===`loading`?`加载连接参数…`:`正在连接远程桌面…`),1)])):w(u)===`error`?(g(),a(`div`,he,[o(s,{type:`error`,variant:`tonal`,"max-width":`480`},{default:b(()=>[m(D(w(_)),1)]),_:1}),o(c,{variant:`flat`,color:`primary`,class:`mt-3`,onClick:be},{default:b(()=>[...n[10]||=[m(`返回列表`,-1)]]),_:1})])):p(``,!0)],512),o(oe,{modelValue:q.value,"onUpdate:modelValue":n[1]||=e=>q.value=e,form:J.value,"editing-id":Y.value,"password-set":X.value,saving:w(H),onSave:we},null,8,[`modelValue`,`form`,`editing-id`,`password-set`,`saving`]),o(B,{modelValue:Z.value,"onUpdate:modelValue":n[3]||=e=>Z.value=e,"max-width":`400`},{default:b(()=>[o(L,null,{default:b(()=>[o(re,null,{default:b(()=>[...n[11]||=[m(`删除 RDP 主机`,-1)]]),_:1}),o(ie,null,{default:b(()=>[m(`确定删除「`+D(Q.value?.name)+`」?`,1)]),_:1}),o(ne,null,{default:b(()=>[o(x),o(c,{variant:`text`,onClick:n[2]||=e=>Z.value=!1},{default:b(()=>[...n[12]||=[m(`取消`,-1)]]),_:1}),o(c,{color:`error`,variant:`flat`,loading:w(H),onClick:Ee},{default:b(()=>[...n[13]||=[m(`删除`,-1)]]),_:1},8,[`loading`])]),_:1})]),_:1})]),_:1},8,[`modelValue`])]),_:1}))}}),[[`__scopeId`,`data-v-8bf2089d`]]);export{q as default}; |