@citrixcloud/ucsdk
Version:
Citrix UCSDK for developing optimized WebRTC applications
80 lines (76 loc) • 36.7 kB
JavaScript
//===============================================
// By using these Developer Materials, you accept and agree to comply with
// the terms of the Cloud Software Group Developer Terms of Use found here
// (https://www.cloud.com/legal)
//===============================================
(function(t,q){"object"===typeof exports&&"object"===typeof module?module.exports=q():"function"===typeof define&&define.amd?define([],q):"object"===typeof exports?exports.CitrixBootstrap=q():t.CitrixBootstrap=q()})(self,function(){return function(){function t(h){var a=u[h];if(void 0!==a)return a.exports;a=u[h]={exports:{}};q[h].call(a.exports,a,a.exports,t);return a.exports}var q={491:function(h,a,e){Object.defineProperty(a,"__esModule",{value:!0});a.Bootstrap=a.BootstrapCommand=a.getTitleAccessor=
a.TitleAccessor=void 0;var g=e(648),l=e(784),k=e(33);h=function(){function b(){}b.prototype.getWindowTitle=function(){return document.title};b.prototype.setWindowTitle=function(c){document.title=c};return b}();a.TitleAccessor=h;var f=new h;a.getTitleAccessor=function(){return f};var d;(function(b){b.EnsureConnected="EnsureConnected";b.GetRedirectionState="GetRedirectionState";b.GetWindowHandle="GetWindowHandle"})(d=a.BootstrapCommand||(a.BootstrapCommand={}));h=function(){function b(){this.isConnected_=
!1;this.deferredActionsMap_=new Map;this.commandInProgress_=new Map;for(var c in d)this.deferredActionsMap_.set(c,[]),this.commandInProgress_.set(c,!1)}b.prototype.user_friendly_id=function(){return"Bootstrap"};b.prototype.setIsConnected=function(c){g.logger.info(this.user_friendly_id()+".setIsConnected isConnected = "+c);this.isConnected_=c};b.prototype.establishConnection=function(){return this.ensureConnected()};b.prototype.disconnect=function(){l.getBootstrapProtocol().disconnect();this.setIsConnected(!1)};
b.prototype.ensureConnected=function(){var c=this,a=this,n=++b.connectRequestNumber_;return new Promise(function(b,f){g.logger.info(a.user_friendly_id()+".ensureConnected called. isConnected_ = "+a.isConnected_+", commandInProgress_ = "+a.commandInProgress_.get(d.EnsureConnected)+", requestNum = "+n);a.isConnected_?b():c.processCommand(d.EnsureConnected,b,f,function(){l.getBootstrapProtocol().establishConnection().then(function(){g.logger.info(a.user_friendly_id()+".ensureConnected Connection Successful. requestNum = "+
n);a.setIsConnected(!0);a.completeCommand(d.EnsureConnected,!0)})["catch"](function(){g.logger.info(a.user_friendly_id()+".ensureConnected Connection Failed. requestNum = "+n);a.setIsConnected(!1);a.completeCommand(d.EnsureConnected,!1)})})})};b.prototype.processCommand=function(c,b,a,d){b=new k.deferred_action(b,a,"Bootstrap_"+c);(a=this.deferredActionsMap_.get(c))?(a.push(b),this.commandInProgress_.get(c)?g.logger.info(this.user_friendly_id()+".processCommand command already in progress so deferring cmd = "+
c):(g.logger.info(this.user_friendly_id()+".processCommand command not already in progress so starting cmd = "+c),this.commandInProgress_.set(c,!0),d())):g.logger.error(this.user_friendly_id()+".processCommand called with unknown cmd: "+c)};b.prototype.completeCommand=function(c,b,a){var d=this.deferredActionsMap_.get(c);if(d)for(this.commandInProgress_.set(c,!1);0<d.length;)(c=d.shift())&&(void 0!=a?c.postWithResult(b,a):c.post(b));else g.logger.error(this.user_friendly_id()+".completeCommand called with unknown cmd: "+
c)};Object.defineProperty(b.prototype,"onRedirectionStateChanged",{set:function(c){l.getBootstrapProtocol().setRedirectionStateChangedCB(c)},enumerable:!1,configurable:!0});b.prototype.getRedirectionState=function(){var c=this;g.logger.info(this.user_friendly_id()+".getRedirectionState() called.");var b=this;return new Promise(function(a){b.ensureConnected().then(function(){b.processCommand(d.GetRedirectionState,a,a,function(){l.getBootstrapProtocol().getRedirectionState().then(function(a){g.logger.info(c.user_friendly_id()+
".getRedirectionState() returning data:"+JSON.stringify(a));b.completeCommand(d.GetRedirectionState,!0,a.state)})["catch"](function(a){g.logger.error(c.user_friendly_id()+".getRedirectionState() rejected with errorCode:"+a);b.completeCommand(d.GetRedirectionState,!0,l.RedirectionState.SessionInactive)})})})["catch"](function(){g.logger.error(c.user_friendly_id()+".getRedirectionState() connection failed. Returning SessionInactive(-1).");a(l.RedirectionState.SessionInactive)})})};b.prototype.getWindowHandle=
function(){var b=this;g.logger.info(this.user_friendly_id()+".getWindowHandle() called.");var a=this;return new Promise(function(f){a.ensureConnected().then(function(){a.processCommand(d.GetWindowHandle,f,f,function(){a.processGetWindowHandle().then(function(f){g.logger.info(b.user_friendly_id()+".getWindowHandle() returning data:"+JSON.stringify(f));a.completeCommand(d.GetWindowHandle,!0,f)})["catch"](function(f){g.logger.error(b.user_friendly_id()+".getWindowHandle() rejected with errorCode:"+f);
a.completeCommand(d.GetWindowHandle,!0,"")})})})["catch"](function(){g.logger.error(b.user_friendly_id()+".getWindowHandle() connection failed. Returning empty string.");f("")})})};b.prototype.processGetWindowHandle=function(){var c=this;return new Promise(function(a,d){var e=f.getWindowTitle();f.setWindowTitle(b.WindowHandleProcedureTag);var k=new l.WindowHandleCmdData(b.WindowHandleProcedureTag);l.getBootstrapProtocol().getWindowHandle(k).then(function(b){g.logger.info(c.user_friendly_id()+".processGetWindowHandle() returning:"+
b.windowHandle);f.setWindowTitle(e);a(b.windowHandle)})["catch"](function(b){g.logger.error(c.user_friendly_id()+".processGetWindowHandle() rejected with errorCode:"+b);f.setWindowTitle(e);d(b)})})};b.connectRequestNumber_=0;b.WindowHandleProcedureTag="WindowHandleProcedureTag";return b}();a.Bootstrap=h},784:function(h,a,e){var g=this&&this.__extends||function(){var b=function(c,a){b=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(b,c){b.__proto__=c}||function(b,c){for(var a in c)c.hasOwnProperty(a)&&
(b[a]=c[a])};return b(c,a)};return function(c,a){function d(){this.constructor=c}b(c,a);c.prototype=null===a?Object.create(a):(d.prototype=a.prototype,new d)}}();Object.defineProperty(a,"__esModule",{value:!0});a.getRedirector=a.getBootstrapProtocol=a.BootstrapProtocol=a.WindowHandleResponseData=a.WindowHandleCmdData=a.RedirectionStateResponseData=a.RedirectionState=a.BootstrapState=a.bootstrap_cmd=void 0;var l=e(174),k=e(726),f=e(648),d=e(147),b;(function(b){b.Unknown="unknown";b.GetRedirectionState=
"redirection_state";b.GetWindowHandle="window_handle";b.RedirectionStateChanged="redirection_state_changed";b.Capabilities="capabilities"})(b=a.bootstrap_cmd||(a.bootstrap_cmd={}));var c;(function(b){b[b.Unknown=0]="Unknown";b[b.Initialized=1]="Initialized";b[b.Error=2]="Error"})(c=a.BootstrapState||(a.BootstrapState={}));(function(b){b[b.SessionInactive=-1]="SessionInactive";b[b.RedirectionNotSupported=0]="RedirectionNotSupported";b[b.RedirectionSupported=1]="RedirectionSupported"})(a.RedirectionState||
(a.RedirectionState={}));var m=function(){return function(b){this.state=b}}();a.RedirectionStateResponseData=m;h=function(){return function(b){this.tag=b}}();a.WindowHandleCmdData=h;var n=function(){return function(b){this.windowHandle=b}}();a.WindowHandleResponseData=n;var p=function(){return function(b){this.caps=b}}();h=function(a){function e(){var b=a.call(this)||this;b.name="bootstrap";b.state_=c.Unknown;b.onRedirectionStateChanged_=null;b.vdaFeatures_=[];b.vdaCapabilities_=[];b.shimCapabilities_=
[];b.establishConnectionCompletion_=null;b.commandTimeoutInMilliSecs=2E4;b.agentConnection_=new k.HdxAgentConnection;b.agentConnection_.onConnectionEvent=function(c){b.onAgentConnectionEvent(c)};d.protocol_handler_manager.addProtocolHandler(b);b.featuresProtocolHandler_=new l.FeaturesProtocolHandler;return b}g(e,a);e.prototype.init=function(b){this.vdaFeatures_=b};e.prototype.deinit=function(){this.state_=c.Unknown;this.clearRequests();this.clearCallbacks()};e.prototype.user_friendly_id=function(){return"BootstrapProtocol"};
e.prototype.getState=function(){return this.state_};e.prototype.establishConnection=function(){var b=this;return new Promise(function(c,a){b.establishConnectionCompletion_=new d.completion_base(c,a);b.agentConnection_.connect(!0)["catch"](function(){b.onEstablishConnectionSequenceCompleted(!1)})})};e.prototype.disconnect=function(){this.agentConnection_.disconnectFromAgent()};e.prototype.onEstablishConnectionSequenceCompleted=function(b){b?(this.establishConnectionCompletion_&&(this.establishConnectionCompletion_.resolve(),
this.establishConnectionCompletion_=null),this.state_=c.Initialized):(this.state_=c.Error,this.clearRequests(),this.establishConnectionCompletion_&&(this.establishConnectionCompletion_.reject(),this.establishConnectionCompletion_=null))};e.prototype.onAgentConnectionEvent=function(b){f.logger.info(this.user_friendly_id()+".onAgentConnectionEvent(): state:"+this.stateString()+" e:"+b);this.onEstablishConnectionSequenceCompleted(b==k.AgentConnectionEvent.Ready)};e.prototype.IsVDAFeatureSupported=function(b){return void 0!==
this.vdaFeatures_.find(function(c){return c.name===b})?!0:!1};e.prototype.IsVDACapabilitySupported=function(b){return void 0!==this.vdaCapabilities_.find(function(c){return c===b})?!0:!1};Object.defineProperty(e.prototype,"shimCapabilities",{get:function(){return this.shimCapabilities_},set:function(b){this.shimCapabilities_=b},enumerable:!1,configurable:!0});e.prototype.stateString=function(){return this.state_===c.Initialized?"Initialized":this.state_===c.Error?"Error":"Unknown"};e.prototype.finalizeCmd=
function(b,c,a,d){f.logger.info(this.user_friendly_id()+".finalizeCmd() called. id="+b+" command="+c);var m=this.processResponseEx(b);void 0!=m?0===a?void 0!=d?m.resolve(d):m.resolve():m.reject(a):f.logger.warning(this.user_friendly_id()+".finalizeCmd(). completion_base not found. id="+b+" command="+c)};e.prototype.onError=function(b,a){f.logger.error(this.user_friendly_id()+".onError(): state: "+this.stateString());this.state_==c.Unknown?(this.state_=c.Error,this.clearRequests()):this.state_==c.Initialized&&
this.finalizeCmd(b,a,1)};e.prototype.getRedirectionState=function(){var b=this;return new Promise(function(a,d){if(b.state_!=c.Error){var f=b.processRequestEx(a,d,b.commandTimeoutInMilliSecs);b.WSSendRedirectionStateCmd(f)}else d()})};e.prototype.onRedirectionStateResponse=function(b,c,a,d){d=new m(d.redirection_state);this.finalizeCmd(b,c,a,d)};e.prototype.setRedirectionStateChangedCB=function(b){this.onRedirectionStateChanged_=b};e.prototype.onRedirectionStateChangedCmd=function(b){if(this.onRedirectionStateChanged_)this.onRedirectionStateChanged_(b)};
e.prototype.getWindowHandle=function(b){var a=this;return new Promise(function(d,f){if(a.state_!=c.Error){var m=a.processRequestEx(d,f,a.commandTimeoutInMilliSecs);a.WSSendWindowHandleCmd(m,b)}else f()})};e.prototype.onWindowHandleResponse=function(b,c,a,d){d=new n(d.windowHandle);this.finalizeCmd(b,c,a,d)};e.prototype.onCapabilitiesCmd=function(b,c){this.vdaCapabilities_=(new p(c.caps)).caps;f.logger.info(this.user_friendly_id()+".onCapabilitiesCmd capabilities: ["+this.vdaCapabilities_+"]");this.WSSendCapabilitiesResponse(b,
0,this.shimCapabilities_);this.agentConnection_.onWSBindingCompleted(!0)};e.prototype.WSSendRedirectionStateCmd=function(c){try{this.WSSendObject({v:this.name,hdr:{command:b.GetRedirectionState,id:c},data:{}})}catch(a){f.logger.error(a)}};e.prototype.WSSendWindowHandleCmd=function(c,a){try{this.WSSendObject({v:this.name,hdr:{command:b.GetWindowHandle,id:c},data:{tag:a.tag}})}catch(d){f.logger.error(d)}};e.prototype.WSSendCapabilitiesResponse=function(c,a,d){try{this.WSSendObject({v:this.name,hdr:{command:b.Capabilities,
id:c},status:a,data:{caps:d}})}catch(m){f.logger.error(m)}};e.prototype.WSSendObject=function(b){if("v"in b){b=JSON.stringify(b);try{this.agentConnection_.sendMessage(b)}catch(c){f.logger.error(this.user_friendly_id()+"WSSendObject(): exception: "+c.message)}}else f.logger.error(this.user_friendly_id()+"Unknown protocol: '"+JSON.stringify(b)+"'")};e.prototype.on_message=function(c){var a=c.hdr.command,d=c.hdr.id;if(void 0!=a&&void 0!=d)if(a==b.GetRedirectionState){f.logger.info(this.user_friendly_id()+
"GetRedirectionState response received");var m=c.data;this.onRedirectionStateResponse(d,a,c.status,m)}else if(a==b.RedirectionStateChanged)f.logger.info(this.user_friendly_id()+"RedirectionStateChanged cmd received"),m=c.data,this.onRedirectionStateChangedCmd(m);else if(a==b.GetWindowHandle){f.logger.info(this.user_friendly_id()+"GetWindowHandle response received");var e=c.status,m=c.data;this.onWindowHandleResponse(d,a,e,m)}else a==b.Capabilities?(f.logger.info(this.user_friendly_id()+"Capabilities cmd received"),
m=c.data,this.onCapabilitiesCmd(d,m)):(f.logger.info(this.user_friendly_id()+"unknown command id:"+a),this.onError(d,a));else f.logger.info(this.user_friendly_id()+"Message received is missing command or id. Ignoring message. command:"+a+", id: "+d)};return e}(d.protocol_base);a.BootstrapProtocol=h;var r=new h;a.getBootstrapProtocol=function(){return r};a.getRedirector=function(){return r}},33:function(h,a,e){Object.defineProperty(a,"__esModule",{value:!0});a.deferred_action=void 0;var g=e(648);h=
function(){function a(e,f,d){this.resolve=e;this.reject=f;this.name_=d}Object.defineProperty(a.prototype,"name",{get:function(){return this.name_},enumerable:!1,configurable:!0});a.prototype.post=function(a){1==a?(g.logger.info('deferred_action.post(): resolving "'+this.name_+'"'),this.resolve()):(g.logger.info('deferred_action.post(): rejecting "'+this.name_+'"'),this.reject())};a.prototype.postWithResult=function(a,f){1==a?(g.logger.info('deferred_action.post(): resolving "'+this.name_+'"'),this.resolve(f)):
(g.logger.info('deferred_action.post(): rejecting "'+this.name_+'"'),this.reject())};a.prototype.postResolve=function(a){this.resolve(a)};a.prototype.postReject=function(a){void 0==a?this.reject():this.reject(a)};return a}();a.deferred_action=h},174:function(h,a,e){var g=this&&this.__extends||function(){var a=function(b,c){a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(b,c){b.__proto__=c}||function(b,c){for(var a in c)c.hasOwnProperty(a)&&(b[a]=c[a])};return a(b,c)};return function(b,
c){function m(){this.constructor=b}a(b,c);b.prototype=null===c?Object.create(c):(m.prototype=c.prototype,new m)}}();Object.defineProperty(a,"__esModule",{value:!0});a.FeaturesProtocolHandler=a.FeaturesProtocolCommands=void 0;var l=e(648),k=e(147),f;(f=a.FeaturesProtocolCommands||(a.FeaturesProtocolCommands={})).FeatureSupport="feature-support";h=function(a){function b(){var b=a.call(this)||this;b.name="features";b.vdaFeaturesReceived_=!1;b.vdaFeatures_=[];k.protocol_handler_manager.addProtocolHandler(b);
return b}g(b,a);b.prototype.init=function(b,a){};b.prototype.deinit=function(){};b.prototype.user_friendly_id=function(){return"FeaturesProtocolHandler"};Object.defineProperty(b.prototype,"vdaFeatures",{get:function(){return this.vdaFeatures_},enumerable:!1,configurable:!0});b.prototype.haveVdaFeaturesBeenReceived=function(){return this.vdaFeaturesReceived_};b.prototype.on_message=function(b){var a=b.command,d=b.agent_version;a==f.FeatureSupport?(b=b.features,l.logger.info(this.user_friendly_id()+
"feature-support command received, version: "+d+" features:"+b),b&&(this.vdaFeatures_=b,this.vdaFeaturesReceived_=!0,k.protocol_handler_manager.oninit([],this.vdaFeatures_))):l.logger.info(this.user_friendly_id()+" unknown command id:"+a)};return b}(k.protocol_base);a.FeaturesProtocolHandler=h},726:function(h,a,e){Object.defineProperty(a,"__esModule",{value:!0});a.HdxAgentConnection=a.WebSocketFactory=a.AgentConnectionEvent=a.AgentConnectionStatus=void 0;var g=e(648),l=e(33),k=e(147),f;(function(b){b.Disconnected=
"Disconnected";b.Connecting="Connecting";b.Binding="Binding";b.Connected="Connected"})(f=a.AgentConnectionStatus||(a.AgentConnectionStatus={}));var d;(function(b){b[b.Ready=0]="Ready";b[b.Error=1]="Error"})(d=a.AgentConnectionEvent||(a.AgentConnectionEvent={}));var b=function(){function b(){}b.createWebSocket=function(b,c){return new WebSocket(b,c)};return b}();a.WebSocketFactory=b;h=function(){function c(){this.connectionStatus_=f.Disconnected;this.deferredActions_=[];this.connectionTimeoutInMilliSecs_=
2E4;this.onConnectionEvent=null}c.prototype.user_friendly_id=function(){return"HdxAgentConnection"};c.prototype.setConnectionStatus=function(b,c){g.logger.info(this.user_friendly_id()+".setConnectionStatus status: "+b+", Caller: "+c);this.connectionStatus_=b};c.prototype.connect=function(a){var d=this,e=++c.connectRequestNumber_;g.logger.info(d.user_friendly_id()+".connect() called. requestNum:"+e);return new Promise(function(c,k){if(d.connectionStatus_==f.Connected)g.logger.info(d.user_friendly_id()+
"connect() called when already connected. Caller= "+e),c();else if(d.connectionStatus_==f.Disconnected){d.setConnectionStatus(f.Connecting,"connect() requestNum:"+e);try{var h=b.createWebSocket("wss://127.0.0.1:9002/bootstrap");d.websocket_=h;d.websocket_.onmessage=function(b){d.onWSMessage(b)};d.websocket_.onclose=function(b){d.onWSClose(b)};d.websocket_.onopen=function(){d.onWSOpen();c()};d.websocket_.onerror=function(b){d.onWSError("websocket.onerror called Error = "+JSON.stringify(b)+", url = "+
d.websocket_.url);k()};a&&d.startConnectionTimer(k)}catch(v){g.logger.error(d.user_friendly_id()+".connect() exception thrown when creating WebSocket. err="+v),k()}}else if(d.connectionStatus_==f.Connecting||d.connectionStatus_==f.Binding)g.logger.info(d.user_friendly_id()+"Deferring Agent connection status: Connecting... Caller= "+e),d.deferredActions_.push(new l.deferred_action(c,k,"HdxAgentConnection_"+e))})};c.prototype.startConnectionTimer=function(b){var c=this;this.stopConnectionTimer();this.timerId_=
setTimeout(function(){c.onWSError("timed out waiting for response to connection.");b()},this.connectionTimeoutInMilliSecs_)};c.prototype.stopConnectionTimer=function(){this.timerId_&&(clearTimeout(this.timerId_),this.timerId_=void 0)};c.prototype.disconnectFromAgent=function(b){void 0===b&&(b=1E3);g.logger.info(this.user_friendly_id()+"disconnectFromAgent. reason="+b);void 0==this.websocket_||this.websocket_.readyState!=this.websocket_.CONNECTING&&this.websocket_.readyState!=this.websocket_.OPEN||
this.websocket_.close(b)};c.prototype.onWSOpen=function(){g.logger.info(this.user_friendly_id()+".onWSOpen opened websocket service");this.setConnectionStatus(f.Binding,"onWSOpen")};c.prototype.completeDeferedActions=function(){for(this.stopConnectionTimer();0<this.deferredActions_.length;){var b=this.deferredActions_.shift();b&&b.post(this.connectionStatus_==f.Connected)}};c.prototype.onWSBindingCompleted=function(b){g.logger.info(this.user_friendly_id()+"websocket service bind complete, ready:"+
b);if(b){if(this.setConnectionStatus(f.Connected,"onWSBindingCompleted"),this.onConnectionEvent)this.onConnectionEvent(d.Ready)}else this.disconnectFromAgent();this.completeDeferedActions()};c.prototype.onWSClose=function(b){if(this.connectionStatus_!=f.Disconnected){g.logger.info(this.user_friendly_id()+"disconnected from websocket service. closeEvent = "+JSON.stringify(b));this.setConnectionStatus(f.Disconnected,"onWSClose");if(this.onConnectionEvent)this.onConnectionEvent(d.Error);this.completeDeferedActions()}};
c.prototype.onWSError=function(b){if(this.connectionStatus_!=f.Disconnected){g.logger.error(this.user_friendly_id()+".onWSError "+b);this.setConnectionStatus(f.Disconnected,"onWSError");if(this.onConnectionEvent)this.onConnectionEvent(d.Error);this.completeDeferedActions()}};c.prototype.onWSMessage=function(b){b=b.data;g.logger.trace(this.user_friendly_id()+"onWSMessage: <<< "+b+"'");var c;try{c=JSON.parse(b)}catch(a){g.logger.error(this.user_friendly_id()+" - invalid JSON!!! err = "+a);return}var d=
k.protocol_handler_manager.findHandler(c.v);if(void 0!=d)d.on_message(c);else g.logger.warning("HDXMS: onWSMessage: Unknown protocol: "+b+"'")};c.prototype.sendMessage=function(b){this.websocket_&&this.websocket_.readyState==this.websocket_.OPEN&&this.websocket_.send(b)};c.connectRequestNumber_=0;return c}();a.HdxAgentConnection=h},648:function(h,a,e){Object.defineProperty(a,"__esModule",{value:!0});a.logger=a.Logger=void 0;var g=e(543),l=e(295),k=e(99),f=l.LogLevel.Info;h=function(){function a(b){var c=
this;void 0===b&&(b="[HdxWebRTC.js]");this.enabled_=!0;this.mslogger_=void 0;this.level_=f;this.enable_timestamp_=this.configuration_received_=!1;this.deferredLogs_=[];this.buffer_size_max_=10;this.intervalID_=0;this.flush=function(){0<c.deferredLogs_.length&&(c.protocol_.log(c.deferredLogs_),c.deferredLogs_=[])};this.tag_=b;g.BUILD_TYPE_SDK&&(this.enable_timestamp_=!0);this.protocol_=new k.LoggingProtocol(function(b){c.info(c.user_friendly_id()+" - Received Capabilities Cmd with caps = "+JSON.stringify(b));
c.protocol_.configure(c.appInfo_).then(function(b){var a=b.level,d=b.delay;b=b.buffer_size_max;c.info(c.user_friendly_id()+"- Configure Response received with level = "+a+", delay = "+d+", buffer_size_max = "+b);c.configuration_received_=!0;c.level_=a;c.deferredLogs_=c.deferredLogs_.filter(function(b){return b.level>=c.level_});c.delay_=d;c.buffer_size_max_=b;c.intervalID_=setInterval(c.flush,1E3*c.delay_)})["catch"](function(b){c.error(b)})},function(){clearInterval(c.intervalID_);c.deferredLogs_=
[];c.level_=f})}a.prototype.setInstanceId=function(b){this.instanceId_=b};a.prototype.user_friendly_id=function(){return this.constructor.name+"["+this.instanceId_+"]"};a.prototype.log=function(b){for(var a=[],d=1;d<arguments.length;d++)a[d-1]=arguments[d];if(this.enabled_&&!(b<this.level_)){var a=this.tag_+" "+a,f=new Date,d=f.getTime(),f=f.toISOString();this.protocol_.isEnabled()&&(this.deferredLogs_.push({level:b,msg:"["+d+"] "+f+" "+l.LogLevel[b].toUpperCase()+" "+a}),this.configuration_received_&&
this.deferredLogs_.length>this.buffer_size_max_&&this.flush());this.enable_timestamp_&&(a="["+d+"] "+f+" "+a);void 0!==this.mslogger_?this.mslogger_.info(a):console.log(a)}};a.prototype.setMSLogger=function(b,a){this.mslogger_=b;void 0!=a&&(this.enable_timestamp_=a)};Object.defineProperty(a.prototype,"appInfo",{set:function(b){this.appInfo_=b},enumerable:!1,configurable:!0});Object.defineProperty(a.prototype,"level",{set:function(b){this.level_=b},enumerable:!1,configurable:!0});Object.defineProperty(a.prototype,
"enable",{set:function(b){this.enabled_=b},enumerable:!1,configurable:!0});a.prototype.trace=function(){for(var b=[],a=0;a<arguments.length;a++)b[a]=arguments[a];this.log(l.LogLevel.Trace,b)};a.prototype.debug=function(){for(var b=[],a=0;a<arguments.length;a++)b[a]=arguments[a];this.log(l.LogLevel.Debug,b)};a.prototype.info=function(){for(var b=[],a=0;a<arguments.length;a++)b[a]=arguments[a];this.log(l.LogLevel.Info,b)};a.prototype.warning=function(){for(var b=[],a=0;a<arguments.length;a++)b[a]=arguments[a];
this.log(l.LogLevel.Warning,b)};a.prototype.error=function(){for(var b=[],a=0;a<arguments.length;a++)b[a]=arguments[a];this.log(l.LogLevel.Error,b)};a.prototype.cleanup=function(){this.flush()};return a}();a.Logger=h;a.logger=new h},295:function(h,a){Object.defineProperty(a,"__esModule",{value:!0});a.LogLevel=void 0;var e=a.LogLevel||(a.LogLevel={});e[e.Trace=0]="Trace";e[e.Debug=1]="Debug";e[e.Info=2]="Info";e[e.Warning=3]="Warning";e[e.Error=4]="Error"},99:function(h,a,e){var g=this&&this.__extends||
function(){var a=function(b,c){a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(b,a){b.__proto__=a}||function(b,a){for(var c in a)a.hasOwnProperty(c)&&(b[c]=a[c])};return a(b,c)};return function(b,c){function f(){this.constructor=b}a(b,c);b.prototype=null===c?Object.create(c):(f.prototype=c.prototype,new f)}}();Object.defineProperty(a,"__esModule",{value:!0});a.LoggingProtocol=void 0;var l=e(784),k=e(147),f;(function(a){a[a.UNINITIALIZED=0]="UNINITIALIZED";a[a.ENABLED=1]="ENABLED";
a[a.DISABLED=2]="DISABLED"})(f||(f={}));h=function(a){function b(b,e){var g=a.call(this)||this;g.name="logging";g.state_=f.UNINITIALIZED;g.handleFailedHandshake=function(){g.state_===f.UNINITIALIZED&&g.disable()};k.protocol_handler_manager.addProtocolHandler(g);g.onCapsReceivedCb=b;g.onDisableCb=e;return g}g(b,a);b.prototype.disable=function(){this.state_=f.DISABLED;this.onDisableCb()};b.prototype.init=function(b,a){var d=this;void 0===a.find(function(b){return b===d.name})&&this.disable()};b.prototype.deinit=
function(){this.clearRequests();this.clearCallbacks()};b.prototype.on_message=function(b){if("capabilities"===b.command)l.getRedirector().WSSendObject({v:this.name,command:"capabilities",caps:[]}),this.onCapsReceivedCb(b.caps);else if("configure"===b.command){var a=this.processResponseEx(Number(b.req_id));void 0!==a?!0===b.status?(this.state_=f.ENABLED,a.resolve({level:b.level,delay:b.delay,buffer_size_max:b.buffer_size_max})):(this.disable(),a.reject("failed to configure logging protocol on agent!")):
this.disable()}else"shutdown"===b.command&&this.disable()};b.prototype.isEnabled=function(){return this.state_===f.UNINITIALIZED||this.state_===f.ENABLED};b.prototype.configure=function(b){var a=this;return new Promise(function(d,f){var e=a.processRequestEx(d,f);l.getRedirector().WSSendObject({v:a.name,command:"configure",req_id:String(e),client_info:b.clientInfo,vendor_name:b.vendorName});setTimeout(a.handleFailedHandshake,6E4)})};b.prototype.log=function(b){l.getRedirector().WSSendObject({v:this.name,
command:"log",data:b})};return b}(k.protocol_base);a.LoggingProtocol=h},383:function(h,a,e){Object.defineProperty(a,"__esModule",{value:!0});a.number_allocator=void 0;var g=e(648);h=function(){function a(e,f,d){this.min_=e<a.BOUND_LOW||e>a.BOUND_HIGH?a.DEF_MIN:e;this.max_=f<a.BOUND_LOW||f>a.BOUND_HIGH?a.DEF_MAX:f;this.interval_=d<a.BOUND_LOW||d>a.BOUND_HIGH?a.DEF_INTERVAL:d;this.numbers_=new Map;this.numbers_.set(this.min_,this.max_)}Object.defineProperty(a.prototype,"max",{get:function(){return this.max_},
enumerable:!1,configurable:!0});Object.defineProperty(a.prototype,"min",{get:function(){return this.min_},enumerable:!1,configurable:!0});Object.defineProperty(a.prototype,"interval",{get:function(){return this.interval_},enumerable:!1,configurable:!0});Object.defineProperty(a.prototype,"numbers",{get:function(){return this.numbers_},enumerable:!1,configurable:!0});a.prototype.allocate=function(){var a=-1;if(0<this.numbers_.size){var f=Array.from(this.numbers_.keys()).sort(function(b,a){return b-
a})[0],d=this.numbers_.get(f);g.logger.debug("low="+f+" this.min="+this.min_+" this.interval="+this.interval_);a=this.min_+(f-this.min_)*this.interval_;this.numbers_["delete"](f);f+=1;f<d&&this.numbers_.set(f,d)}return a};a.prototype.deallocate=function(a){var f=Array.from(this.numbers_.keys()).sort(function(b,a){return b-a});a=(a-this.min_)/this.interval_;for(var d=!1,b=0;b<f.length&&(f[b]==a+1?(this.numbers_.set(a,this.numbers_.get(f[b])),this.numbers_["delete"](f[b]),d=!0):this.numbers_.get(f[b])==
a&&(this.numbers_.set(f[b],a+1),b+1<f.length&&f[b+1]==a+1&&(this.numbers_.set(f[b],this.numbers_.get(f[b+1])),this.numbers_["delete"](f[b+1])),d=!0),!d);b++);d||this.numbers_.set(a,a+1)};a.BOUND_LOW=0;a.BOUND_HIGH=4294967295;a.DEF_MIN=0;a.DEF_MAX=1024;a.DEF_INTERVAL=1;return a}();a.number_allocator=h},147:function(h,a,e){Object.defineProperty(a,"__esModule",{value:!0});a.protocol_handler_manager=a.protocol_base=a.callback_base=a.completion_base=void 0;var g=e(648),l=e(383),k=function(){return function(a,
b,c,f,e){this.resolve=a;this.reject=b;this.reqid=e;this.cbid=c;this.completion_cb=f}}();a.completion_base=k;var f=function(){function a(b){this.id=b}a.prototype.resolve=function(b){g.logger.trace("callback.resolve() called. [id="+this.id+"]");null!=this.handler&&this.handler(b)};a.prototype.reject=function(b){null!=this.err_handler&&this.err_handler(b)};a.prototype.then=function(b){this.handler=b};a.prototype.prom=function(){var b=this;return new Promise(function(a,d){b.handler=a;b.err_handler=d})};
return a}();a.callback_base=f;h=function(){function a(){this.reqs_=[];this.ID_MAX=4294967296;this.cbid_allocator_=new l.number_allocator(0,this.ID_MAX,1);this.reqid_allocator_=new l.number_allocator(0,this.ID_MAX,1);this.reqs_w_id_=new Map;this.cbs_=new Map;this.cbidmap_=new Map}a.prototype.user_friendly_id=function(){return this.constructor.name};a.prototype.processRequestEx=function(b,a,d){void 0===d&&(d=-1);var f=this.reqid_allocator_.allocate();b=new k(b,a,void 0,null,f);this.reqs_w_id_.set(f,
b);0<=d&&this.startCommandTimoutTimer(b,d);return f};a.prototype.processResponseEx=function(b){var a;this.reqid_allocator_.deallocate(b);this.reqs_w_id_.has(b)?(a=this.reqs_w_id_.get(b),this.reqs_w_id_["delete"](b)):g.logger.warning(this.user_friendly_id()+".processResponse(). reqid="+b+" Cant find request!!!!");a&&this.stopCommandTimoutTimer(a);return a};a.prototype.startCommandTimoutTimer=function(b,a){var d=this,f=setTimeout(function(){b.timerId=void 0;d.processResponseEx(b.reqid);b.reject()},
a);b.timerId=f};a.prototype.stopCommandTimoutTimer=function(b){b.timerId&&(clearTimeout(b.timerId),b.timerId=void 0)};a.prototype.processRequest=function(b,a){var d=new k(b,a);this.reqs_.push(d)};a.prototype.processResponse=function(){return this.reqs_.shift()};a.prototype.clearRequests=function(){var b=this;this.reqs_w_id_.forEach(function(a,d){a.reject();b.cbid_allocator_.deallocate(d)});this.reqs_w_id_.clear();this.reqs_.forEach(function(b,a){b.reject()});this.reqs_=[]};a.prototype.registerCallback=
function(b){var a=this,d=this.cbid_allocator_.allocate();b&&this.unregisterCallback(b);this.cbidmap_.set(b,d);b=new f(d);0>d&&g.logger.warning(this.user_friendly_id()+".registerCallback(). !!!! ran out of cbid !!!!");g.logger.debug(this.user_friendly_id()+".registerCallback(). cbid="+d);b.completion_cb=function(b){a.unregisterCallback(b)};var e=new k(b.resolve.bind(b),b.reject.bind(b),b.id,b.completion_cb);this.cbs_.set(d,e);return b};a.prototype.unregisterCallback=function(b){var a;"string"==typeof b&&
this.cbidmap_.has(b)?(a=this.cbidmap_.get(b),this.cbidmap_["delete"](b)):"number"==typeof b&&(a=b);this.cbs_.has(a)&&(this.cbid_allocator_.deallocate(a),this.cbs_["delete"](a))};a.prototype.clearCallbacks=function(){var b=this;g.logger.info(this.user_friendly_id()+".clearCallbacks().");this.cbs_.forEach(function(a,d){a.reject();b.cbid_allocator_.deallocate(d)});this.cbs_.clear();this.cbidmap_.clear()};a.prototype.getCallback=function(b){if("string"==typeof b&&this.cbidmap_.has(b))b=this.cbidmap_.get(b);
else if("number"!=typeof b){g.logger.warning(this.user_friendly_id()+".getCallback(). !!!! invalid cbid !!!!");return}return this.cbs_.get(b)};return a}();a.protocol_base=h;h=function(){function a(){}a.findHandler=function(b){return a.handlers_.find(function(a){return a.name==b})};a.addProtocolHandler=function(b){void 0==a.handlers_.find(function(a){return a.name==b.name})&&a.handlers_.push(b)};a.oninit=function(b,c){a.handlers_.forEach(function(a,d){a.init(b,c)})};a.ondeinit=function(){a.handlers_.forEach(function(b,
a){b.deinit()})};a.removeAllHandlers=function(){a.handlers_.splice(0,a.handlers_.length)};a.removeProtocolHandler=function(b){var c=a.handlers_.findIndex(function(a){return a.name==b});0<=c&&a.handlers_.splice(c,1)};a.handlers_=[];return a}();a.protocol_handler_manager=h},617:function(h,a,e){(function(a,e){a.CitrixBootstrap=e()})("undefined"!==typeof self?self:this,function(){function a(){return"[vdiCitrixBootstrap] "}function l(){n||(n=new c.Bootstrap,n.onRedirectionStateChanged=function(c){if(h)try{h(Object.assign({event:"vdiRedirectionStateChanged"},
c))}catch(d){b.info(a()+"Exception onVMBootstrapEvent(), eventName:vdiRedirectionStateChanged message:"+d.message)}});return n}function k(a){if(!p)throw b.info("VDI Shim "+a+": throwing exception: not initialized!!"),new DOMException("Bootstrap is not initialized!!!");}function f(){k("getRedirectionState");b.info(a()+"VDI Shim getRedirectionState");return l().getRedirectionState()}function d(){k("getRedirectionState");b.info(a()+"VDI Shim getWindowHandle");return l().getWindowHandle()}var b=e(648).logger;
b.setInstanceId("Bootstrap");var c=e(491),h=void 0,n=null,p=!1,r=void 0;return{initBootstrap:function(a){b.info("VDI Shim initBootstrap vendor:"+a);if(p)throw b.error("VDI Shim initBootstrap: throwing exception: Already initialized."),new DOMException("Bootstrap is already initialized.");var c;"string"===typeof a&&(c=a.trim());if(void 0===c||0===c.length)throw b.error("VDI Shim initUCSDK: throwing exception: vendor info cannot be empty!!!"),new DOMException("vendor info cannot be empty, please pass vendor info string!!!");
r=c;b.appInfo={clientInfo:"CitrixWebRTCSDK",vendorName:r};window.getCitrixWebrtcRedir=function(){return f()};window.getWindowHandleAsHex=function(){return d()};p=!0},deinitBootstrap:function(){b.info("VDI Shim deinitBootstrap");p&&(window.getCitrixWebrtcRedir=void 0,window.getWindowHandleAsHex=void 0,l().disconnect(),n=null,r=void 0,p=!1)},initLog:function(c,d){b.setMSLogger(c,d);b.info(a()+"VDI init logger")},getRedirectionState:f,getWindowHandle:d}})},488:function(h,a,e){Object.defineProperty(a,
"__esModule",{value:!0});a.vdaFeatureNameMap=a.FEATURE_vda_bootstrap=a.class_lib_info=a.HDXBOOT_VERSION=a.BUILD_TYPE_SDK=void 0;var g=e(912);Object.defineProperty(a,"FeatureData",{enumerable:!0,get:function(){return g.FeatureData}});a.BUILD_TYPE_SDK=!0;a.HDXBOOT_VERSION="4.0.2";a.class_lib_info=null;a.FEATURE_vda_bootstrap="bootstrap_connection";a.vdaFeatureNameMap={};a.vdaFeatureNameMap[a.FEATURE_vda_bootstrap]=[a.FEATURE_vda_bootstrap]},912:function(h,a){Object.defineProperty(a,"__esModule",{value:!0});
a.HardwareInfo=a.MemoryInfo=a.GPUInfo=a.GPU=a.CPUInfo=a.WebrpcClassLibInfo=a.WebrpcClassInfo=a.WebrpcMethodInfo=a.EndpointId=a.OSInfo=a.WebrpcFeatureInfo=a.FeatureData=a.VersionData=a.FEATURE_unsupported=a.FEATURE_ms_teams_redirection=void 0;a.FEATURE_ms_teams_redirection="ms_teams_redirection";a.FEATURE_unsupported="unsupported";var e=function(){return function(a,e,k,f){this.major=a;this.minor=e;this.revision=k;this.build=f}}();a.VersionData=e;e=function(){return function(){}}();a.FeatureData=e;
e=function(){return function(a,e){this.fature=a;this.version=e}}();a.WebrpcFeatureInfo=e;e=function(){return function(a,e,k,f,d){this.family=a;this.version=e;this.architecture=k;this.distro=f;this.edition=d}}();a.OSInfo=e;e=function(){return function(a,e){this.machine_id=a;this.user_id=e}}();a.EndpointId=e;e=function(){return function(e,h,k,f,d){void 0===d&&(d=a.FEATURE_ms_teams_redirection);this.iid=e;this.mid=h;this.name=k;this.isprop=f;this.feature=d}}();a.WebrpcMethodInfo=e;e=function(){return function(a,
e,h){this.id=a;this.name=e;this.methods=h}}();a.WebrpcClassInfo=e;e=function(){return function(a,e){this.name=a;this.classes=e}}();a.WebrpcClassLibInfo=e;e=function(){return function(a,e){this.cpumodel=a;this.numberofprocessors=e}}();a.CPUInfo=e;e=function(){return function(a,e){this.name=a;this.driver=e}}();a.GPU=e;e=function(){return function(a){this.gpus=a}}();a.GPUInfo=e;e=function(){return function(a){this.totalmemory=a}}();a.MemoryInfo=e;e=function(){return function(a,e,h){this.cpu_info=a;this.gpu_info=
e;this.memory_info=h}}();a.HardwareInfo=e},543:function(h,a,e){var g=this&&this.__createBinding||(Object.create?function(a,e,d,b){void 0===b&&(b=d);Object.defineProperty(a,b,{enumerable:!0,get:function(){return e[d]}})}:function(a,e,d,b){void 0===b&&(b=d);a[b]=e[d]});h=this&&this.__exportStar||function(a,e){for(var d in a)"default"===d||e.hasOwnProperty(d)||g(e,a,d)};Object.defineProperty(a,"__esModule",{value:!0});a.WebrpcClassLibInfoUtil=void 0;var l=e(488);h(e(488),a);e=function(){function a(){}
a.getInterfaceByid=function(a){for(var d=0,b=l.class_lib_info.classes;d<b.length;d++){var c=b[d];if(c.id==a)return c}return null};a.getMethodByid=function(a,d){var b=this.getInterfaceByid(a);if(null!=b)for(var c=0,b=b.methods;c<b.length;c++){var e=b[c];if(e.mid==d)return e}return null};a.getMethodFeatureByid=function(a,d){var b=this.getInterfaceByid(a);if(null!=b)for(var c=0,b=b.methods;c<b.length;c++){var e=b[c];if(e.mid==d)return e.feature}return null};a.composeClassInfoData=function(a){a=a.hdr;
if(void 0==a)return"*** Invalid packet: Couldn't find hdr object ***";var d=a.proc;if(void 0==d)return"";a=d.iid;for(var d=d.methodid,b=0,c=l.class_lib_info.classes;b<c.length;b++){var e=c[b];if(e.id==a)for(var g=0,h=e.methods;g<h.length;g++){var k=h[g];if(k.mid==d)return e.name+"::"+k.name}}return""};return a}();a.WebrpcClassLibInfoUtil=e}},u={};return t(617)}()});