riskonnectwawa.lightning.force.com
Open in
urlscan Pro
13.110.38.194
Public Scan
URL:
https://riskonnectwawa.lightning.force.com/jslibrary/1630617996000/streaming-v2/CometdWorkerJs.js
Submission: On September 09 via manual from US — Scanned from DE
Submission: On September 09 via manual from US — Scanned from DE
Form analysis
0 forms found in the DOMText Content
/* * This code is for Internal Salesforce use only, and subject to change without notice. * Customers shouldn't reference this file in any web pages. */ (function(a,f){"object"===typeof exports?module.exports=f():"function"===typeof define&&define.amd?define([],f):(a.org=a.org||{},a.org.cometd=f())})(this,function(){var a={isString:function(p){return void 0===p||null===p?!1:"string"===typeof p||p instanceof String},isArray:function(p){return void 0===p||null===p?!1:p instanceof Array},inArray:function(p,a){for(var e=0;e<a.length;++e)if(p===a[e])return e;return-1},setTimeout:function(p,a,e){return f().setTimeout(function(){try{p._debug("Invoking timed function", a),a()}catch(b){p._debug("Exception invoking timed function",a,b)}},e)},clearTimeout:function(a){f().clearTimeout(a)}},f=function(){if("undefined"!==typeof self)return self;if("undefined"!==typeof window)return window},I=function(){var a=[],c={};this.getTransportTypes=function(){return a.slice(0)};this.findTransportTypes=function(e,b,q){for(var d=[],h=0;h<a.length;++h){var g=a[h];!0===c[g].accept(e,b,q)&&d.push(g)}return d};this.negotiateTransport=function(e,b,q,d){for(var h=0;h<a.length;++h)for(var g= a[h],z=0;z<e.length;++z)if(g===e[z]){var f=c[g];if(!0===f.accept(b,q,d))return f}return null};this.add=function(e,b,q){for(var d=!1,h=0;h<a.length;++h)if(a[h]===e){d=!0;break}d||("number"!==typeof q?a.push(e):a.splice(q,0,e),c[e]=b);return!d};this.find=function(e){for(var b=0;b<a.length;++b)if(a[b]===e)return c[e];return null};this.remove=function(e){for(var b=0;b<a.length;++b)if(a[b]===e)return a.splice(b,1),b=c[e],delete c[e],b;return null};this.clear=function(){a=[];c={}};this.reset=function(e){for(var b= 0;b<a.length;++b)c[a[b]].reset(e)}},n=function(){var p,c,e;this.registered=function(b,a){p=b;c=a};this.unregistered=function(){c=p=null};this._debug=function(){c._debug.apply(c,arguments)};this._mixin=function(){return c._mixin.apply(c,arguments)};this.getConfiguration=function(){return c.getConfiguration()};this.getAdvice=function(){return c.getAdvice()};this.setTimeout=function(b,e){return a.setTimeout(c,b,e)};this.clearTimeout=function(b){a.clearTimeout(b)};this.convertToMessages=function(b){if(a.isString(b))try{return JSON.parse(b)}catch(e){throw this._debug("Could not convert to JSON the following string", '"'+b+'"'),e;}if(a.isArray(b))return b;if(void 0===b||null===b)return[];if(b instanceof Object)return[b];throw"Conversion Error "+b+", typeof "+typeof b;};this.accept=function(b,a,e){throw"Abstract";};this.getType=function(){return p};this.getURL=function(){return e};this.setURL=function(b){e=b};this.send=function(b,a){throw"Abstract";};this.reset=function(b){this._debug("Transport",p,"reset",b?"initial":"retry")};this.abort=function(){this._debug("Transport",p,"aborted")};this.toString=function(){return this.getType()}}; n.derive=function(a){function c(){}c.prototype=a;return new c};var s=function(){function p(b){for(;0<f.length;){var a=f[0],e=a[0],a=a[1];if(e.url===b.url&&e.sync===b.sync)f.shift(),b.messages=b.messages.concat(e.messages),this._debug("Coalesced",e.messages.length,"messages from request",a.id);else break}}function c(b,a){this.transportSend(b,a);a.expired=!1;if(!b.sync){var e=this.getConfiguration().maxNetworkDelay,d=e;!0===a.metaConnect&&(d+=this.getAdvice().timeout);this._debug("Transport",this.getType(), "waiting at most",d,"ms for the response, maxNetworkDelay",e);var q=this;a.timeout=this.setTimeout(function(){a.expired=!0;var r="Request "+a.id+" of transport "+q.getType()+" exceeded "+d+" ms max network delay",e={reason:r},c=a.xhr;e.httpCode=q.xhrStatus(c);q.abortXHR(c);q._debug(r);q.complete(a,!1,a.metaConnect);b.onFailure(c,b.messages,e)},d)}}function e(b){var a=++h,e={id:a,metaConnect:!1,envelope:b};z.length<this.getConfiguration().maxConnections-1?(z.push(e),c.call(this,b,e)):(this._debug("Transport", this.getType(),"queueing request",a,"envelope",b),f.push([b,e]))}function b(b,d){var q=a.inArray(b,z);0<=q&&z.splice(q,1);if(0<f.length){var q=f.shift(),c=q[0],h=q[1];this._debug("Transport dequeued request",h.id);if(d)this.getConfiguration().autoBatch&&p.call(this,c),e.call(this,c),this._debug("Transport completed request",b.id,c);else{var r=this;this.setTimeout(function(){r.complete(h,!1,h.metaConnect);var b={reason:"Previous request failed"},a=h.xhr;b.httpCode=r.xhrStatus(a);c.onFailure(a,c.messages, b)},0)}}}var q=new n,d=n.derive(q),h=0,g=null,z=[],f=[];d.complete=function(a,e,d){if(d){a=a.id;this._debug("Transport",this.getType(),"metaConnect complete, request",a);if(null!==g&&g.id!==a)throw"Longpoll request mismatch, completing request "+a;g=null}else b.call(this,a,e)};d.transportSend=function(b,a){throw"Abstract";};d.transportSuccess=function(b,a,e){if(!a.expired)if(this.clearTimeout(a.timeout),this.complete(a,!0,a.metaConnect),e&&0<e.length)b.onSuccess(e);else b.onFailure(a.xhr,b.messages, {httpCode:204})};d.transportFailure=function(a,b,e){b.expired||(this.clearTimeout(b.timeout),this.complete(b,!1,b.metaConnect),a.onFailure(b.xhr,a.messages,e))};d.send=function(b,a){if(a){if(null!==g)throw"Concurrent metaConnect requests not allowed, request id\x3d"+g.id+" not yet completed";var d=++h;this._debug("Transport",this.getType(),"metaConnect send, request",d,"envelope",b);d={id:d,metaConnect:!0,envelope:b};c.call(this,b,d);g=d}else e.call(this,b)};d.abort=function(){q.abort();for(var b= 0;b<z.length;++b){var a=z[b];a&&(this._debug("Aborting request",a),this.abortXHR(a.xhr)||this.transportFailure(a.envelope,a,{reason:"abort"}))}if(b=g)this._debug("Aborting metaConnect request",b),this.abortXHR(b.xhr)||this.transportFailure(b.envelope,b,{reason:"abort"});this.reset(!0)};d.reset=function(b){q.reset(b);g=null;z=[];f=[]};d.abortXHR=function(b){if(b)try{var a=b.readyState;b.abort();return a!==XMLHttpRequest.UNSENT}catch(e){this._debug(e)}return!1};d.xhrStatus=function(b){if(b)try{return b.status}catch(a){this._debug(a)}return-1}; return d},t=function(){var a=new s,c=n.derive(a),e=!0;c.accept=function(b,a,d){return e||!a};c.xhrSend=function(b){var a=new XMLHttpRequest;a.withCredentials=!0;a.open("POST",b.url,!0!==b.sync);var e=b.headers;if(e)for(var c in e)e.hasOwnProperty(c)&&a.setRequestHeader(c,e[c]);a.setRequestHeader("Content-Type","application/json;charset\x3dUTF-8");a.onload=function(){if(200===a.status)b.onSuccess(a.responseText);else b.onError(a.statusText)};a.onerror=function(){b.onError(a.statusText)};a.send(b.body); return a};c.transportSend=function(a,c){this._debug("Transport",this.getType(),"sending request",c.id,"envelope",a);var d=this;try{var h=!0;c.xhr=this.xhrSend({transport:this,url:a.url,sync:a.sync,headers:this.getConfiguration().requestHeaders,body:JSON.stringify(a.messages),onSuccess:function(h){d._debug("Transport",d.getType(),"received response",h);var g=!1;try{var p=d.convertToMessages(h);0===p.length?(e=!1,d.transportFailure(a,c,{httpCode:204})):(g=!0,d.transportSuccess(a,c,p))}catch(f){d._debug(f), g||(e=!1,h={exception:f},h.httpCode=d.xhrStatus(c.xhr),d.transportFailure(a,c,h))}},onError:function(g,p){d._debug("Transport",d.getType(),"received error",g,p);e=!1;var f={reason:g,exception:p};f.httpCode=d.xhrStatus(c.xhr);h?d.setTimeout(function(){d.transportFailure(a,c,f)},0):d.transportFailure(a,c,f)}});h=!1}catch(g){e=!1,this.setTimeout(function(){d.transportFailure(a,c,{exception:g})},0)}};c.reset=function(b){a.reset(b);e=!0};return c},A=function(){function a(b,e,d){var c=this;return function(){c.transportFailure(b, e,"error",d)}}var c=new s,c=n.derive(c),e=0;c.accept=function(a,e,d){return!0};c.jsonpSend=function(a){var c=document.getElementsByTagName("head")[0],d=document.createElement("script"),h="_cometd_jsonp_"+e++;window[h]=function(e){c.removeChild(d);delete window[h];a.onSuccess(e)};var g=a.url,g=g+(0>g.indexOf("?")?"?":"\x26"),g=g+("jsonp\x3d"+h)+("\x26message\x3d"+a.body);d.src=g;d.async=!0!==a.sync;d.type="application/javascript";d.onerror=function(e){a.onError("jsonp "+e.type)};c.appendChild(d)}; c.transportSend=function(b,e){for(var c=this,h=0,g=b.messages.length,f=[];0<g;){var n=JSON.stringify(b.messages.slice(h,h+g)),n=b.url.length+encodeURI(n).length,u=this.getConfiguration().maxURILength;if(n>u){if(1===g){f="Bayeux message too big ("+n+" bytes, max is "+u+") for transport "+this.getType();this.setTimeout(a.call(this,b,e,f),0);return}--g}else f.push(g),h+=g,g=b.messages.length-h}var w=b;if(1<f.length){h=0;g=f[0];this._debug("Transport",this.getType(),"split",b.messages.length,"messages into", f.join(" + "));w=this._mixin(!1,{},b);w.messages=b.messages.slice(h,g);w.onSuccess=b.onSuccess;w.onFailure=b.onFailure;for(n=1;n<f.length;++n)u=this._mixin(!1,{},b),h=g,g+=f[n],u.messages=b.messages.slice(h,g),u.onSuccess=b.onSuccess,u.onFailure=b.onFailure,this.send(u,e.metaConnect)}this._debug("Transport",this.getType(),"sending request",e.id,"envelope",w);try{var s=!0;this.jsonpSend({transport:this,url:w.url,sync:w.sync,headers:this.getConfiguration().requestHeaders,body:JSON.stringify(w.messages), onSuccess:function(a){var b=!1;try{var f=c.convertToMessages(a);0===f.length?c.transportFailure(w,e,{httpCode:204}):(b=!0,c.transportSuccess(w,e,f))}catch(g){c._debug(g),b||c.transportFailure(w,e,{exception:g})}},onError:function(a,b){var f={reason:a,exception:b};s?c.setTimeout(function(){c.transportFailure(w,e,f)},0):c.transportFailure(w,e,f)}});s=!1}catch(v){this.setTimeout(function(){c.transportFailure(w,e,{exception:v})},0)}};return c},M=function(){function p(a,b){a&&(this.webSocketClose(a,b.code, b.reason),this.onClose(a,b))}function c(a,b,e){for(var c=[],d=0;d<b.messages.length;++d){var f=b.messages[d];f.id&&c.push(f.id)}a.envelopes[c.join(",")]=[b,e];this._debug("Transport",this.getType(),"stored envelope, envelopes",a.envelopes)}function e(a){if(!t){var b=g.getURL().replace(/^http/,"ws");this._debug("Transport",this.getType(),"connecting to URL",b);try{var e=g.getConfiguration().protocol,c=f();c&&(a.webSocket=e?new c.WebSocket(b,e):new c.WebSocket(b));t=a}catch(d){throw z=!1,this._debug("Exception while creating WebSocket object", d),d;}s=!1!==g.getConfiguration().stickyReconnect;var h=this,q=g.getConfiguration().connectTimeout;0<q&&(a.connectTimer=this.setTimeout(function(){g._debug("Transport",h.getType(),"timed out while connecting to URL",b,":",q,"ms");p.call(h,a,{code:1E3,reason:"Connect Timeout"})},q));var n=function(b){b=b||{code:1E3};g._debug("WebSocket onclose",a,b,"connecting",t,"current",w);a.connectTimer&&h.clearTimeout(a.connectTimer);h.onClose(a,b)};a.webSocket.onopen=function(){g._debug("WebSocket onopen",a); a.connectTimer&&h.clearTimeout(a.connectTimer);a===t||a===w?(t=null,w=a,u=!0,h.onOpen(a)):(g._warn("Closing extra WebSocket connection",this,"active connection",w),p.call(h,a,{code:1E3,reason:"Extra Connection"}))};a.webSocket.onclose=n;a.webSocket.onerror=function(){n({code:1E3,reason:"Error"})};a.webSocket.onmessage=function(b){g._debug("WebSocket onmessage",b,a);h.onMessage(a,b)};this._debug("Transport",this.getType(),"configured callbacks on",a)}}function b(a,b,e){var c=JSON.stringify(b.messages); a.webSocket.send(c);this._debug("Transport",this.getType(),"sent",b,"metaConnect \x3d",e);var d=c=this.getConfiguration().maxNetworkDelay;e&&(d+=this.getAdvice().timeout,v=!0);for(var f=this,h=[],q=0;q<b.messages.length;++q)(function(){var e=b.messages[q];e.id&&(h.push(e.id),a.timeouts[e.id]=f.setTimeout(function(){g._debug("Transport",f.getType(),"timing out message",e.id,"after",d,"on",a);p.call(f,a,{code:1E3,reason:"Message Timeout"})},d))})();this._debug("Transport",this.getType(),"waiting at most", d,"ms for messages",h,"maxNetworkDelay",c,", timeouts:",a.timeouts)}function q(a,d,f){try{null===a?(a=t||{envelopes:{},timeouts:{}},c.call(this,a,d,f),e.call(this,a)):(c.call(this,a,d,f),b.call(this,a,d,f))}catch(h){var g=this;this.setTimeout(function(){p.call(g,a,{code:1E3,reason:"Exception",exception:h})},0)}}var d=new n,h=n.derive(d),g,z=!0,u=!1,s=!0,w=null,t=null,v=!1,A=null;h.reset=function(a){d.reset(a);z=!0;a&&(u=!1);s=!0;t=w=null;v=!1};h._notifySuccess=function(a,b){a.call(this,b)};h._notifyFailure= function(a,b,e,c){a.call(this,b,e,c)};h.onOpen=function(a){var e=a.envelopes;this._debug("Transport",this.getType(),"opened",a,"pending messages",e);for(var c in e)if(e.hasOwnProperty(c)){var d=e[c],f=d[0],d=d[1];A=f.onSuccess;b.call(this,a,f,d)}};h.onMessage=function(b,e){this._debug("Transport",this.getType(),"received websocket message",e,b);for(var c=!1,d=this.convertToMessages(e.data),f=[],h=0;h<d.length;++h){var g=d[h];if((/^\/meta\//.test(g.channel)||void 0===g.data)&&g.id){f.push(g.id);var p= b.timeouts[g.id];p&&(this.clearTimeout(p),delete b.timeouts[g.id],this._debug("Transport",this.getType(),"removed timeout for message",g.id,", timeouts",b.timeouts))}"/meta/connect"===g.channel&&(v=!1);"/meta/disconnect"===g.channel&&!v&&(c=!0)}h=!1;g=b.envelopes;for(p=0;p<f.length;++p){var q=f[p],m;for(m in g)if(g.hasOwnProperty(m)){var C=m.split(","),G=a.inArray(q,C);if(0<=G){h=!0;C.splice(G,1);q=g[m][0];G=g[m][1];delete g[m];0<C.length&&(g[C.join(",")]=[q,G]);break}}}h&&this._debug("Transport", this.getType(),"removed envelope, envelopes",g);this._notifySuccess(A,d);c&&this.webSocketClose(b,1E3,"Disconnect")};h.onClose=function(a,b){this._debug("Transport",this.getType(),"closed",a,b);if(a===t||a===w)z=s&&u,w=t=null;var e=a.timeouts;a.timeouts={};for(var c in e)e.hasOwnProperty(c)&&this.clearTimeout(e[c]);e=a.envelopes;a.envelopes={};for(var d in e)if(e.hasOwnProperty(d)){c=e[d][0];e[d][1]&&(v=!1);var f={websocketCode:b.code,reason:b.reason};b.exception&&(f.exception=b.exception);this._notifyFailure(c.onFailure, a,c.messages,f)}};h.registered=function(a,b){d.registered(a,b);g=b};h.accept=function(a,b,e){this._debug("Transport",this.getType(),"accept, supported:",z);a=f();return z&&a&&!!a.WebSocket&&!1!==g.websocketEnabled};h.send=function(a,b){this._debug("Transport",this.getType(),"sending",a,"metaConnect \x3d",b);q.call(this,w,a,b)};h.webSocketClose=function(a,b,e){try{a.webSocket&&a.webSocket.close(b,e)}catch(c){this._debug(c)}};h.abort=function(){d.abort();p.call(this,w,{code:1E3,reason:"Abort"});this.reset(!0)}; return h},D="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-:+\x3d^!/*?\x26\x3c\x3e()[]{}@%$#".split(""),u=[0,68,0,84,83,82,72,0,75,76,70,65,0,63,62,69,0,1,2,3,4,5,6,7,8,9,64,0,73,66,74,71,81,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,77,0,78,67,0,0,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,79,0,80,0,0];return{CometD:function(p){function c(k,a){try{return k[a]}catch(b){}}function e(k){return void 0===k||null=== k?!1:"function"===typeof k}function b(k,a){for(var b="";0<--a&&!(k>=Math.pow(10,a));)b+="0";return b+k}function q(k,a){var fa=f();if(fa.console){var c=fa.console[k];if(e(c)){var d=new Date;[].splice.call(a,0,0,b(d.getHours(),2)+":"+b(d.getMinutes(),2)+":"+b(d.getSeconds(),2)+"."+b(d.getMilliseconds(),3));c.apply(fa.console,a)}}}function d(k){return/(^https?:\/\/)?(((\[[^\]]+\])|([^:\/\?#]+))(:(\d+))?)?([^\?#]*)(.*)?/.exec(k)}function h(k){if(k){var a=N[k.channel];a&&a[k.id]&&(delete a[k.id],l._debug("Removed", k.listener?"listener":"subscription",k))}}function g(){for(var k in N)if(N.hasOwnProperty(k)){var a=N[k];if(a)for(var b in a)if(a.hasOwnProperty(b)){var e=a[b];e&&!e.listener&&h(e)}}}function n(k){T!==k&&(l._debug("Status",T,"-\x3e",k),T=k)}function u(){return"disconnecting"===T||"disconnected"===T}function s(k,a,b,c,d){try{return a.call(k,c)}catch(m){k=l.onExtensionException;if(e(k)){l._debug("Invoking extension exception handler",b,m);try{k.call(l,m,b,d,c)}catch(f){l._info("Exception during execution of extension exception handler", b,f)}}else l._info("Exception during execution of extension",b,m);return c}}function w(k){for(var a=0;a<H.length&&!(void 0===k||null===k);++a){var b=H[a],c=b.extension.outgoing;e(c)&&(b=s(b.extension,c,b.name,k,!0),k=void 0===b?k:b)}return k}function D(k,a){var b=N[k];if(b)for(var c in b)if(b.hasOwnProperty(c)){var d=b[c];if(d)try{d.callback.call(d.scope,a)}catch(m){var f=l.onListenerException;if(e(f)){l._debug("Invoking listener exception handler",d,m);try{f.call(l,m,d,d.listener,a)}catch(g){l._info("Exception during execution of listener exception handler", d,g)}}else l._info("Exception during execution of listener",d,a,m)}}}function v(k,a){D(k,a);for(var b=k.split("/"),e=b.length-1,c=e;0<c;--c){var d=b.slice(0,c).join("/")+"/*";c===e&&D(d,a);d+="*";D(d,a)}}function aa(k,b){null!==U&&a.clearTimeout(U);U=null;var e=E.interval+b;l._debug("Function scheduled in",e,"ms, interval \x3d",E.interval,"backoff \x3d",J,k);U=a.setTimeout(l,k,e)}function r(k,a,b,e){for(var c=0;c<a.length;++c){var d=a[c],m=d.id;W&&(d.clientId=W);d=w(d);void 0!==d&&null!==d?(d.id= m,a[c]=d):(delete ba[m],a.splice(c--,1))}0!==a.length&&(c=l.getURL(),y.appendMessageTypeToURL&&(c.match(/\/$/)||(c+="/"),e&&(c+=e)),k={url:c,sync:k,messages:a,onSuccess:function(k){try{oa.call(l,k)}catch(a){l._info("Exception during handling of messages",a)}},onFailure:function(k,a,b){try{var e=l.getTransport();b.connectionType=e?e.getType():"unknown";ga.call(l,k,a,b)}catch(Aa){l._info("Exception during handling of failure",Aa)}}},l._debug("Send",k),x.send(k,b))}function F(k){0<Q||!0===$?X.push(k): r(!1,[k],!1)}function R(){var k=X;X=[];0<k.length&&r(!1,k,!1)}function O(k){n("connecting");aa(function(){if(!u()){var k={id:""+ ++V,channel:"/meta/connect",connectionType:x.getType()};ca||(k.advice={timeout:0});n("connecting");l._debug("Connect sent",k);r(!1,[k],!0,"connect");n("connected")}},k)}function B(k){E=l._mixin(!1,{},y.advice,k);l._debug("New advice",E)}function P(k){null!==U&&a.clearTimeout(U);U=null;k&&x&&x.abort();W=null;n("disconnected");J=Q=0;x=null;ca=ha=!1;0<X.length&&(k=X,X=[],ga.call(l, void 0,k,{reason:"Disconnected"}))}function L(k,a,b){var c=l.onTransportException;if(e(c)){l._debug("Invoking transport exception handler",k,a,b);try{c.call(l,b,k,a)}catch(d){l._info("Exception during execution of transport exception handler",d)}}}function S(k,a){e(k)&&(a=k,k=void 0);W=null;g();u()&&(K.reset(!0),B(y.advice));Q=0;$=!0;ia=k;pa=a;var b=l.getURL(),c=K.findTransportTypes("1.0",ja,b),d={id:""+ ++V,version:"1.0",minimumVersion:"1.0",channel:"/meta/handshake",supportedConnectionTypes:c,advice:{timeout:E.timeout, interval:E.interval}},d=l._mixin(!1,{},ia,d);l._putCallback(d.id,a);if(!x&&(x=K.negotiateTransport(c,"1.0",ja,b),!x))throw b="Could not find initial transport among: "+K.getTransportTypes(),l._warn(b),b;l._debug("Initial transport is",x.getType());n("handshaking");l._debug("Handshake sent",d);r(!1,[d],!1,"handshake")}function Z(k){n("handshaking");$=!0;aa(function(){S(ia,pa)},k)}function m(k,a){try{k.call(l,a)}catch(b){var c=l.onCallbackException;if(e(c)){l._debug("Invoking callback exception handler", b);try{c.call(l,b,a)}catch(d){l._info("Exception during execution of callback exception handler",d)}}else l._info("Exception during execution of message callback",b)}}function C(k){var a=l._getCallback([k.id]);e(a)&&(delete ba[k.id],m(a,k))}function G(k){var b=ka[k.id];delete ka[k.id];if(b){l._debug("Handling remote call response for",k,"with context",b);var c=b.timeout;c&&a.clearTimeout(c);b=b.callback;if(e(b))return m(b,k),!0}return!1}function qa(k){l._debug("Transport failure handling",k);k.transport&& (x=k.transport);k.url&&x.setURL(k.url);var a=k.action;k=k.delay||0;switch(a){case "handshake":Z(k);break;case "retry":O(k);break;case "none":P(!0);break;default:throw"Unknown action "+a;}}function la(a,b){C(a);v("/meta/handshake",a);v("/meta/unsuccessful",a);u()&&(b.action="none");l.onTransportFailure.call(l,a,b,qa)}function ra(a,b){v("/meta/connect",a);v("/meta/unsuccessful",a);u()&&(b.action="none");l.onTransportFailure.call(l,a,b,qa)}function sa(a){P(!0);C(a);v("/meta/disconnect",a);v("/meta/unsuccessful", a)}function ta(a){var b=N[a.subscription];if(b)for(var e in b)if(b.hasOwnProperty(e)){var c=b[e];c&&!c.listener&&(delete b[e],l._debug("Removed failed subscription",c))}C(a);v("/meta/subscribe",a);v("/meta/unsuccessful",a)}function ua(a){C(a);v("/meta/unsubscribe",a);v("/meta/unsuccessful",a)}function ma(a){G(a)||(C(a),v("/meta/publish",a),v("/meta/unsuccessful",a))}function va(a){for(var b=da=0;b<H.length&&!(void 0===a||null===a);++b){var c=H[y.reverseIncomingExtensions?H.length-1-b:b],m=c.extension.incoming; e(m)&&(c=s(c.extension,m,c.name,a,!1),a=void 0===c?a:c)}if(!(void 0===a||null===a))switch(B(a.advice),a.channel){case "/meta/handshake":b=l.getURL();if(a.successful)if(c=l._isCrossDomain(d(b)[2]),b=K.negotiateTransport(a.supportedConnectionTypes,a.version,c,b),null===b)a.successful=!1,la(a,{cause:"negotiation",action:"none",transport:null});else switch(x!==b&&(l._debug("Transport",x.getType(),"-\x3e",b.getType()),x=b),W=a.clientId,$=!1,R(),a.reestablish=ha,ha=!0,C(a),v("/meta/handshake",a),Y=a["x-messages"]|| 0,a=u()?"none":E.reconnect||"retry",a){case "retry":J=0;0===Y?O(0):l._debug("Processing",Y,"handshake-delivered messages");break;case "none":P(!0);break;default:throw"Unrecognized advice action "+a;}else la(a,{cause:"unsuccessful",action:E.reconnect||"handshake",transport:x});break;case "/meta/connect":if(ca=a.successful)switch(v("/meta/connect",a),a=u()?"none":E.reconnect||"retry",a){case "retry":J=0;O(J);break;case "none":P(!1);break;default:throw"Unrecognized advice action "+a;}else ra(a,{cause:"unsuccessful", action:E.reconnect||"retry",transport:x});break;case "/meta/disconnect":a.successful?(P(!1),C(a),v("/meta/disconnect",a)):sa(a);break;case "/meta/subscribe":a.successful?(C(a),v("/meta/subscribe",a)):ta(a);break;case "/meta/unsubscribe":a.successful?(C(a),v("/meta/unsubscribe",a)):ua(a);break;default:void 0!==a.data?G(a)||(v(a.channel,a),0<Y&&(--Y,0===Y&&(l._debug("Processed last handshake-delivered message"),O(0)))):void 0===a.successful?l._warn("Unknown Bayeux Message",a):a.successful?(C(a),v("/meta/publish", a)):ma(a)}}function wa(a){if(a=N[a])for(var b in a)if(a.hasOwnProperty(b)&&a[b])return!0;return!1}function xa(b,c){var d={scope:b,method:c};if(e(b))d.scope=void 0,d.method=b;else if(a.isString(c)){if(!b)throw"Invalid scope "+b;d.method=b[c];if(!e(d.method))throw"Invalid callback "+c+" for scope "+b;}else if(!e(c))throw"Invalid callback "+c;return d}function ya(a,b,e,c){e=xa(b,e);l._debug("Adding",c?"listener":"subscription","on",a,"with scope",e.scope,"and callback",e.method);b=++Ba;e={id:b,channel:a, scope:e.scope,callback:e.method,listener:c};var d=N[a];d||(d={},N[a]=d);d[b]=e;l._debug("Added",c?"listener":"subscription",e);return e}var l=this,Ca=p||"default",ja=!1,K=new I,x,T="disconnected",V=0,W=null,Q=0,X=[],$=!1,Ba=0,N={},J=0,U=null,H=[],E={},ia,pa,ba={},ka={},ha=!1,ca=!1,da=0,Y=0,y={protocol:null,stickyReconnect:!0,connectTimeout:0,maxConnections:2,backoffIncrement:1E3,maxBackoff:6E4,logLevel:"info",reverseIncomingExtensions:!0,maxNetworkDelay:1E4,requestHeaders:{},appendMessageTypeToURL:!0, autoBatch:!1,urls:{},maxURILength:2E3,advice:{timeout:6E4,interval:0,reconnect:void 0,maxInterval:0}};this._mixin=function(a,b,e){for(var d=b||{},m=2;m<arguments.length;++m){var f=arguments[m];if(!(void 0===f||null===f))for(var g in f)if(f.hasOwnProperty(g)){var h=c(f,g),G=c(d,g);h!==b&&void 0!==h&&(d[g]=a&&"object"===typeof h&&null!==h?h instanceof Array?this._mixin(a,G instanceof Array?G:[],h):this._mixin(a,"object"===typeof G&&!(G instanceof Array)?G:{},h):h)}}return d};this._warn=function(){q("warn", arguments)};this._info=function(){"warn"!==y.logLevel&&q("info",arguments)};this._debug=function(){"debug"===y.logLevel&&q("debug",arguments)};this._isCrossDomain=function(a){var b=f();return a&&b&&a!==b.location.host};var oa,ga;this.send=F;this._getCallback=function(a){return ba[a]};this._putCallback=function(a,b){var c=this._getCallback(a);e(b)&&(ba[a]=b);return c};this.onTransportFailure=function(a,b,e){this._debug("Transport failure",b,"for",a);var c=this.getTransportRegistry(),m=this.getURL(), f=this._isCrossDomain(d(m)[2]),g=c.findTransportTypes("1.0",f,m);"none"===b.action?"/meta/handshake"===a.channel&&!b.transport&&(c="Could not negotiate transport, client\x3d["+g+"], server\x3d["+a.supportedConnectionTypes+"]",this._warn(c),L(x.getType(),null,{reason:c,connectionType:x.getType(),transport:x})):(b.delay=this.getBackoffPeriod(),"/meta/handshake"===a.channel?(b.transport||((c=c.negotiateTransport(g,"1.0",f,m))?(this._debug("Transport",x.getType(),"-\x3e",c.getType()),L(x.getType(),c.getType(), a.failure),b.action="handshake",b.transport=c):(this._warn("Could not negotiate transport, client\x3d["+g+"]"),L(x.getType(),null,a.failure),b.action="none")),"none"!==b.action&&this.increaseBackoffPeriod()):(a=(new Date).getTime(),0===da&&(da=a),"retry"===b.action&&(b.delay=this.increaseBackoffPeriod(),g=E.maxInterval,0<g&&a-da+J>E.timeout+E.interval+g&&(b.action="handshake")),"handshake"===b.action&&(b.delay=0,c.reset(!1),this.resetBackoffPeriod())));e.call(l,b)};this.receive=va;oa=function(a){l._debug("Received", a);for(var b=0;b<a.length;++b)va(a[b])};ga=function(a,b,e){l._debug("handleFailure",a,b,e);e.transport=a;for(a=0;a<b.length;++a){var c=b[a],d={id:c.id,successful:!1,channel:c.channel,failure:e};e.message=c;switch(c.channel){case "/meta/handshake":la(d,{cause:"failure",action:"handshake",transport:null});break;case "/meta/connect":c=d;ca=!1;ra(c,{cause:"failure",action:"retry",transport:null});break;case "/meta/disconnect":sa(d);break;case "/meta/subscribe":d.subscription=c.subscription;ta(d);break; case "/meta/unsubscribe":d.subscription=c.subscription;ua(d);break;default:ma(d)}}};this.registerTransport=function(a,b,c){if(c=K.add(a,b,c))this._debug("Registered transport",a),e(b.registered)&&b.registered(a,this);return c};this.unregisterTransport=function(a){var b=K.remove(a);null!==b&&(this._debug("Unregistered transport",a),e(b.unregistered)&&b.unregistered());return b};this.unregisterTransports=function(){K.clear()};this.getTransportTypes=function(){return K.getTransportTypes()};this.findTransport= function(a){return K.find(a)};this.getTransportRegistry=function(){return K};this.configure=function(b){l._debug("Configuring cometd object with",b);a.isString(b)&&(b={url:b});b||(b={});y=l._mixin(!1,y,b);b=l.getURL();if(!b)throw"Missing required configuration parameter 'url' specifying the Bayeux server URL";var c=d(b);b=c[8];var e=c[9];ja=l._isCrossDomain(c[2]);y.appendMessageTypeToURL&&(void 0!==e&&0<e.length?(l._info("Appending message type to URI "+b+e+" is not supported, disabling 'appendMessageTypeToURL' configuration"), y.appendMessageTypeToURL=!1):(c=b.split("/"),e=c.length-1,b.match(/\/$/)&&(e-=1),0<=c[e].indexOf(".")&&(l._info("Appending message type to URI "+b+" is not supported, disabling 'appendMessageTypeToURL' configuration"),y.appendMessageTypeToURL=!1)))};this.init=function(a,b){this.configure(a);this.handshake(b)};this.handshake=function(a,b){if("disconnected"!==T)throw"Illegal state: handshaken";S(a,b)};this.disconnect=function(a,b,c){if(!u()){"boolean"!==typeof a&&(c=b,b=a,a=!1);e(b)&&(c=b,b=void 0); var d={id:""+ ++V,channel:"/meta/disconnect"};b=this._mixin(!1,{},b,d);l._putCallback(b.id,c);n("disconnecting");r(!0===a,[b],!1,"disconnect")}};this.startBatch=function(){++Q;l._debug("Starting batch, depth",Q)};this.endBatch=function(){--Q;l._debug("Ending batch, depth",Q);if(0>Q)throw"Calls to startBatch() and endBatch() are not paired";0===Q&&(!u()&&!$)&&R()};this.batch=function(a,b){var c=xa(a,b);this.startBatch();try{c.method.call(c.scope),this.endBatch()}catch(e){throw this._info("Exception during execution of batch", e),this.endBatch(),e;}};this.addListener=function(b,c,e){if(2>arguments.length)throw"Illegal arguments number: required 2, got "+arguments.length;if(!a.isString(b))throw"Illegal argument type: channel must be a string";return ya(b,c,e,!0)};this.removeListener=function(a){if(!a||!a.channel||!("id"in a))throw"Invalid argument: expected subscription, not "+a;h(a)};this.clearListeners=function(){N={}};this.subscribe=function(b,c,d,m,f){if(2>arguments.length)throw"Illegal arguments number: required 2, got "+ arguments.length;if(!a.isString(b))throw"Illegal argument type: channel must be a string";if(u())throw"Illegal state: disconnected";e(c)&&(f=m,m=d,d=c,c=void 0);e(m)&&(f=m,m=void 0);var g=!wa(b),h=ya(b,c,d,!1);g&&(g={id:""+ ++V,channel:"/meta/subscribe",subscription:b},g=this._mixin(!1,{},m,g),l._putCallback(g.id,f),F(g));return h};this.unsubscribe=function(a,b,c){if(1>arguments.length)throw"Illegal arguments number: required 1, got "+arguments.length;if(u())throw"Illegal state: disconnected";e(b)&& (c=b,b=void 0);this.removeListener(a);var d=a.channel;wa(d)||(d={id:""+ ++V,channel:"/meta/unsubscribe",subscription:d},d=this._mixin(!1,{},b,d),l._putCallback(d.id,c),F(d))};this.resubscribe=function(a,b){a&&!a.listener&&h(a);if(a)return this.subscribe(a.channel,a.scope,a.callback,b)};this.clearSubscriptions=function(){g()};this.publish=function(b,c,d,m){if(1>arguments.length)throw"Illegal arguments number: required 1, got "+arguments.length;if(!a.isString(b))throw"Illegal argument type: channel must be a string"; if(/^\/meta\//.test(b))throw"Illegal argument: cannot publish to meta channels";if(u())throw"Illegal state: disconnected";e(c)?(m=c,c={},d=void 0):e(d)&&(m=d,d=void 0);var f={id:""+ ++V,channel:b,data:c},f=this._mixin(!1,{},d,f);l._putCallback(f.id,m);F(f)};this.publishBinary=function(a,b,c,d,m){e(b)?(m=b,b=new ArrayBuffer(0),c=!0,d=void 0):e(c)?(m=c,c=!0,d=void 0):e(d)&&(m=d,d=void 0);this.publish(a,{meta:d,data:b,last:c},{ext:{binary:{}}},m)};this.remoteCall=function(b,c,d,m,f){if(1>arguments.length)throw"Illegal arguments number: required 1, got "+ arguments.length;if(!a.isString(b))throw"Illegal argument type: target must be a string";if(u())throw"Illegal state: disconnected";e(c)?(f=c,c={},d=y.maxNetworkDelay,m=void 0):e(d)?(f=d,d=y.maxNetworkDelay,m=void 0):e(m)&&(f=m,m=void 0);if("number"!==typeof d)throw"Illegal argument type: timeout must be a number";b.match(/^\//)||(b="/"+b);var g={id:""+ ++V,channel:"/service"+b,data:c},h=this._mixin(!1,{},m,g),g={callback:f};0<d&&(g.timeout=a.setTimeout(l,function(){l._debug("Timing out remote call", h,"after",d,"ms");ma({id:h.id,error:"406::timeout",successful:!1,failure:{message:h,reason:"Remote Call Timeout"}})},d),l._debug("Scheduled remote call timeout",h,"in",d,"ms"));ka[h.id]=g;F(h)};this.remoteCallBinary=function(a,b,c,d,m,f){e(b)?(f=b,b=new ArrayBuffer(0),c=!0,d=void 0,m=y.maxNetworkDelay):e(c)?(f=c,c=!0,d=void 0,m=y.maxNetworkDelay):e(d)?(f=d,d=void 0,m=y.maxNetworkDelay):e(m)&&(f=m,m=y.maxNetworkDelay);this.remoteCall(a,{meta:d,data:b,last:c},m,{ext:{binary:{}}},f)};this.getStatus= function(){return T};this.isDisconnected=u;this.setBackoffIncrement=function(a){y.backoffIncrement=a};this.getBackoffIncrement=function(){return y.backoffIncrement};this.getBackoffPeriod=function(){return J};this.increaseBackoffPeriod=function(){J<y.maxBackoff&&(J+=y.backoffIncrement);return J};this.resetBackoffPeriod=function(){J=0};this.setLogLevel=function(a){y.logLevel=a};this.registerExtension=function(b,c){if(2>arguments.length)throw"Illegal arguments number: required 2, got "+arguments.length; if(!a.isString(b))throw"Illegal argument type: extension name must be a string";for(var d=!1,m=0;m<H.length;++m)if(H[m].name===b){d=!0;break}if(d)return this._info("Could not register extension with name",b,"since another extension with the same name already exists"),!1;H.push({name:b,extension:c});this._debug("Registered extension",b);e(c.registered)&&c.registered(b,this);return!0};this.unregisterExtension=function(b){if(!a.isString(b))throw"Illegal argument type: extension name must be a string"; for(var c=!1,d=0;d<H.length;++d){var m=H[d];if(m.name===b){H.splice(d,1);c=!0;this._debug("Unregistered extension",b);b=m.extension;e(b.unregistered)&&b.unregistered();break}}return c};this.getExtension=function(a){for(var b=0;b<H.length;++b){var c=H[b];if(c.name===a)return c.extension}return null};this.getName=function(){return Ca};this.getClientId=function(){return W};this.getURL=function(){if(x){var a=x.getURL();if(a||(a=y.urls[x.getType()]))return a}return y.url};this.getTransport=function(){return x}; this.getConfiguration=function(){return this._mixin(!0,{},y)};this.getAdvice=function(){return this._mixin(!0,{},E)};(p=f())&&p.WebSocket&&this.registerTransport("websocket",new M);this.registerTransport("long-polling",new t);this.registerTransport("callback-polling",new A)},Transport:n,RequestTransport:s,LongPollingTransport:t,CallbackPollingTransport:A,WebSocketTransport:M,Utils:a,Z85:{encode:function(a){var c=null;a instanceof ArrayBuffer?c=a:a.buffer instanceof ArrayBuffer?c=a.buffer:Array.isArray(a)&& (c=(new Uint8Array(a)).buffer);if(null==c)throw"Cannot Z85 encode "+a;a=c.byteLength;for(var e=a%4,e=4-(0===e?4:e),c=new DataView(c),b="",f=0,d=0;d<a+e;++d){var h=d>=a,f=256*f+(h?0:c.getUint8(d));if(0===(d+1)%4){for(var g=52200625,u=5;0<u;--u){if(!h||u>e)b+=D[Math.floor(f/g)%85];g/=85}f=0}}return b},decode:function(a){for(var c=a.length%5,e=5-(0===c?5:c),c=0;c<e;++c)a+=D[D.length-1];for(var c=a.length,e=new ArrayBuffer(4*c/5-e),b=new DataView(e),f=0,d=0,h=0,g=0;g<c;++g){var n=a.charCodeAt(d++)-32, f=85*f+u[n];if(0===d%5){for(n=16777216;1<=n;)h<b.byteLength&&b.setUint8(h++,Math.floor(f/n)%256),n/=256;f=0}}return e}}}});var CometdReplayExtension=function(){this.REPLAY_FROM_KEY="replay";this.EMP_JS_HEADER="empJs";this.CHANNEL_NAME="channelName";this._extensionEnabled=!1;this._channelReplays={};this._channelName=null};CometdReplayExtension.prototype.registered=function(a,f){this._cometd=f};CometdReplayExtension.prototype.clearReplays=function(){this._channelReplays={}}; CometdReplayExtension.prototype.setReplay=function(a,f){var I=this.massageChannelName(a),n=this._channelReplays[I],s=parseInt(f,10);n&&n>s&&(s=n);this._channelReplays[I]=s};CometdReplayExtension.prototype.getReplay=function(a){a=this.massageChannelName(a);return this._channelReplays[a]};CometdReplayExtension.prototype.setChannelName=function(a){this._channelName=a};CometdReplayExtension.prototype.removeReplay=function(a){a=this.massageChannelName(a);this._channelReplays[a]&&delete this._channelReplays[a]}; CometdReplayExtension.prototype.incoming=function(a){"/meta/handshake"===a.channel?a.ext&&!0===a.ext[this.REPLAY_FROM_KEY]&&(this._extensionEnabled=!0):this._channelReplays[this.massageChannelName(a.channel)]&&(a.data&&a.data.event&&a.data.event.replayId)&&(this._channelReplays[this.massageChannelName(a.channel)]=a.data.event.replayId)}; CometdReplayExtension.prototype.outgoing=function(a){var f;"/meta/handshake"===a.channel&&(a.ext||(a.ext={}),a.ext[this.EMP_JS_HEADER]=!0,this._channelName&&(a.ext[this.CHANNEL_NAME]=this._channelName));if("/meta/subscribe"===a.channel&&this._extensionEnabled){a.ext||(a.ext={});var I={};f=this.massageChannelName(a.subscription);I[f]=this._channelReplays[f];a.ext[this.REPLAY_FROM_KEY]=I}"/meta/unsubscribe"===a.channel&&this._extensionEnabled&&(a.ext||(a.ext={}),f=this.massageChannelName(a.subscription), this._channelReplays[f]&&delete this._channelReplays[f])};CometdReplayExtension.prototype.massageChannelName=function(a){try{return-1!==a.indexOf("?")?a.split("?")[0]:a}catch(f){return a}}; (function(a,f){"object"===typeof exports?module.exports=f(require("./cometd")):"function"===typeof define&&define.amd?define(["./cometd"],f):f(a.org.cometd)})(this,function(a){return a.ReloadExtension=function(a){function I(a){a&&("string"===typeof a.cometdState&&(A=JSON.parse(a.cometdState)),D=a.saveCometdStateCallback)}var n,s,t={},A,M=!1,D;this.configure=I;this._receive=function(a){n.receive(a)};this.registered=function(a,f){n=f;s=n._debug};this.unregistered=function(){delete n.reload;n=null}; this.outgoing=function(a){switch(a.channel){case "/meta/handshake":t={};t.url=n.getURL();s("Reload extension found state",A);if(A)try{if(A.handshakeResponse&&t.url===A.url){s("Reload extension restoring state",A);var f=n._getCallback(a.id),c=this;setTimeout(function(){s("Reload extension replaying handshake response",A.handshakeResponse);t.handshakeResponse=A.handshakeResponse;t.transportType=A.transportType;n._putCallback(a.id,f);var b=n._mixin(!0,{},t.handshakeResponse,{id:a.id,ext:{reload:!0}}); b.supportedConnectionTypes=[t.transportType];c._receive(b);s("Reload extension replayed handshake response",b);A=null},0);M||(M=!0,s("Reload: startBatch"),n.startBatch());return null}s("Reload extension could not restore state",A)}catch(e){s("Reload extension error while trying to restore state",e)}break;case "/meta/connect":t.transportType||(t.transportType=a.connectionType,D&&D.call(null,JSON.stringify(t)),s("Reload extension tracked transport type",t.transportType));break;case "/meta/disconnect":t= {}}return a};this.incoming=function(a){if(a.successful)switch(a.channel){case "/meta/handshake":t.handshakeResponse||(t.handshakeResponse=a,s("Reload extension tracked handshake response",a));break;case "/meta/connect":M&&(M=!1,s("Reload: endBatch"),n.endBatch());break;case "/meta/disconnect":t={}}else switch(a.channel){case "/meta/connect":M=!1}return a};I(a)}}); function cometdWorker(){function a(a,b){Object.keys(a).sort().forEach(function(c){var e=a[c];2===b.length?b(c,e):b(e)})}function f(){return O?console:aa}function I(c){a(B,function(a,e){e.channel===c&&B[a]&&(delete B[a],0===Object.keys(B).length&&B.constructor===Object&&(f().log("[cometdWorker:deleteSubscription] No subscribers, disconnecting"),b()))})}function n(b){function c(a){var e=JSON.stringify(b),g=a.nodeId,h=JSON.parse(JSON.stringify(e)),C={};C.id=a.id;d({eventType:"functionCall",nodeId:g, functionName:"onErrorCallback",message:h,listener:C},a.port);f().log("[cometdWorker:onErrorListener] received error",e)}!0!==b.successful&&("/meta/subscribe"===b.channel&&I(b.subscription),a(L,c))}function s(a){!0!==a.successful?n(a):ea()}function t(a){a.successful?(a=JSON.stringify(a),f().log("[cometdWorker:onDisconnectListener] received disconnect",a),d({eventType:"functionCall",functionName:"removeCometdState"}),d({eventType:"functionCall",functionName:"terminateWorker"}),F.clearReplays()):f().log("[cometdWorker:_onDisconnectListener] Disconnect failed ["+ JSON.stringify(msg)+"]")}function A(a){return function(b){var c=b.channel,e=b.replayId,d=a.callback;a.replayId=e;b.successful&&F.setReplay(c,e);d?d(a,b):f().log("Missing callback for channel ["+c+"] of the message ["+JSON.stringify(b)+"]")}}function M(a){return function(b){var c=a.subscribeCallback;c&&c(a,b)}}function D(a){a.cometdSubscription=r.subscribe(a.channel,A(a),M(a))}function u(b){S=!1;b.successful&&(f().log("[cometdWorker] Handshake successful, subscribing."),a(B,D))}function p(a){if(a&& a.sessionId)return a.sessionId;throw Error("Missing [sessionId] field in the config object ["+JSON.stringify(a)+"]");}function c(a){var b={};b.id=a.id;b.channel=a.channel;b.replayId=a.replayId;return b}function e(a){var c;if(c=r){var e;c=p(a);R&&(e=p(R));c=e!==c}c&&(B={},L={},a.cometdState=null,r.isDisconnected()||b(),r=null,f().log("[cometdWorker:initConfig] Detected a different session will clear subscriptions and use new cometd instance"));r&&!r.isDisconnected()?f().log("[cometdWorker:initConfig] non-null cometd", r):(R=a,org.cometd.CometD&&!r&&(r=new org.cometd.CometD("EmpJs"),F=new CometdReplayExtension,r.addListener("/meta/handshake",void 0,n),r.addListener("/meta/connect",void 0,s),r.addListener("/meta/subscribe",void 0,n),r.addListener("/meta/unsubscribe",void 0,n),r.addListener("/meta/disconnect",void 0,t),f().log("[cometdWorker:initConfig] new cometd")))}function b(){r.isDisconnected()||r.disconnect(!0,{})}function q(a,c){function e(d){var g;g=c?"function"===typeof c:!1;g&&c(a,d);d.successful?0===Object.keys(B).length&& B.constructor===Object&&(f().log("[cometdWorker:unsubscribe] No subscribers, disconnecting"),b()):f().log("[cometdWorker:unsubscribe] failed to unsubscribe for subscription",a,d)}P[a.id]=a;delete B[a.id];f().log("[cometdWorker:unsubscribe] No. of subscribers: ",Object.keys(B).length);ea();a.cometdSubscription?r.unsubscribe(a.cometdSubscription,e):f().log("[cometdWorker:unsubscribe] Illegal argument: cometdSubscription is undefined or null")}function d(a,b){var c=self;b?c=b:Z&&(c=Z);c.postMessage(a)} function h(a,b){var e={eventType:"functionCall",nodeId:a.nodeId,functionName:"messageCallback",subscription:c(a),message:b};d(e,a.port)}function g(a,b){var e={eventType:"functionCall",nodeId:a.nodeId,functionName:"subscribeCallback",subscription:c(a),message:JSON.parse(JSON.stringify(b))};d(e,a.port)}function z(a,b){za(a.channel,b)}function za(b,e){a(P,function(a){if(a.channel===b){var f={eventType:"functionCall",nodeId:a.nodeId,functionName:"unsubscribeCallback",subscription:c(a),message:JSON.parse(JSON.stringify(e))}; delete P[a.id];d(f,a.port)}})}function na(a,c){var d,n;Z=c;if(a&&a.data&&"functionCall"===a.data.eventType){"init"===a.data.functionName&&e(a.data.functionParams.config);if("subscribe"===a.data.functionName&&(d=a.data.functionParams.subscription,n=a.data.functionParams.config,d.callback=h,d.subscribeCallback=g,d.nodeId=a.data.nodeId,d.port=c,e(n),n=d.id,!B[n]&&(d.cometdSubscription=null,B[n]=d,f().log("[cometdWorker:subscribe] No. of Subscribers: ",Object.keys(B).length),ea(),F.setReplay(d.channel, d.replayId),F.setChannelName(d.channel),!r.isDisconnected()&&!S&&D(d),r.isDisconnected()))){if((R=d=R)&&d.cometdUrl)n=d.cometdUrl;else{n=location.protocol+"//"+location.hostname+":"+location.port+"/cometd/";var s="40.0";d&&d.apiVersion&&(s=d.apiVersion);n+=s}d=p(d);r.websocketEnabled=!1;var s=F,t=r;null!==t.getExtension("replayFrom")&&t.unregisterExtension("replayFrom",s);t.registerExtension("replayFrom",s);r.isDisconnected()&&!S&&(f().log("[cometdWorker] Initializing cometd."),S=!0,r.init({url:n, requestHeaders:{Authorization:"OAuth "+d},appendMessageTypeToURL:!1,advice:{timeout:11E4},logLevel:O?"debug":"info"},u))}"unsubscribe"===a.data.functionName&&(d=a.data.functionParams.subscription,d=d.id,(d=B[d])&&q(d,z));"disconnect"===a.data.functionName&&b();"setDebugFlag"===a.data.functionName&&(O=a.data.functionParams.debugFlag,r&&r.setLogLevel(O?"debug":"info"));"addOnErrorListener"===a.data.functionName&&(d=a.data.functionParams.listener,d.nodeId=a.data.nodeId,d.port=c,f().log("[cometdWorker:fromMainThread] Received error listener", d,L),L[d.id]=d);"removeOnErrorListener"===a.data.functionName&&(d=a.data.functionParams.listener,d.nodeId=a.data.nodeId,d.port=c,d.id&&L[d.id]&&delete L[d.id])}}function w(a){var b=a.ports[0];b.addEventListener("message",function(a){na(a,b)});b.start()}function ea(){a(B,function(a){f().log("[CometdWorker:SubscriptionState] Id: "+a.id+", Channel: "+a.channel+", ReplayId: "+F.getReplay(a.channel))})}function v(a){na(a,self)}var aa={log:function(){}},r,F,R,O=!1,B={},P={},L={},S=!1,Z;"undefined"!==typeof onconnect? self.onconnect=w:addEventListener("message",v)}cometdWorker(); //# sourceMappingURL=/javascript/1546628668000/streaming-v2/source/CometdWorkerJs.js.map