(function(n,t){"use strict";if(typeof n!="function")throw"SignalR: jQuery not found. Please ensure jQuery is referenced before the SignalR.js file.";if(!t.JSON)throw"SignalR: No JSON parser found. Please ensure json2.js is referenced before the SignalR.js file if you need to support clients without native JSON parsing support, e.g. IE<8.";var i,r;i=function(n){return new i.fn.init(n)},i.fn=i.prototype={init:function(n){this.url=n},start:function(r,u){var f=this,e={transport:"auto"},o;return f.transport?f:(n.type(r)==="function"?u=r:n.type(r)==="object"&&(n.extend(e,r),n.type(e.callback)==="function"&&(u=e.callback)),n.type(u)==="function"&&n(f).bind("onStart",function(){u.call(f)}),o=function(t,r){r=r||0;if(r>=t.length){if(!f.transport)throw"SignalR: No transport could be initialized successfully. Try specifying a different transport or none at all for auto initialization.";return}var u=t[r],e=n.type(u)==="object"?u:i.transports[u];e.start(f,function(){f.transport=e,n(f).trigger("onStart")},function(){o(t,r+1)})},t.setTimeout(function(){n.post(f.url+"/negotiate",{},function(t){f.appRelativeUrl=t.Url,f.clientId=t.ClientId,n(f).trigger("onStarting");var u=[],r=[];n.each(i.transports,function(n){r.push(n)}),n.isArray(e.transport)?n.each(e.transport,function(){var t=this;n.type(t)!=="object"&&(n.type(t)!=="string"||n.inArray(""+t,r)<0)||u.push(n.type(t)==="string"?""+t:t)}):n.type(e.transport)!=="object"&&n.inArray(e.transport,r)<0?u=r:u.push(e.transport),o(u)})},0),f)},starting:function(t){var i=this;return n(i).bind("onStarting",function(){t.call(i)}),i},send:function(n){var t=this;if(!t.transport)throw"SignalR: Connection must be started before data can be sent. Call .start() before .send()";return t.transport.send(t,n),t},sending:function(t){var i=this;return n(i).bind("onSending",function(){t.call(i)}),i},received:function(t){var i=this;return n(i).bind("onReceived",function(n,r){t.call(i,r)}),i},error:function(t){var i=this;return n(i).bind("onError",function(){t.call(i)}),i},stop:function(){var n=this;return n.transport&&(n.transport.stop(n),n.transport=null),n}},i.fn.init.prototype=i.fn,i.transports={webSockets:{send:function(n,t){n.socket.send(t)},start:function(i,r,u){var f,o=!1,e;t.MozWebSocket&&(t.WebSocket=t.MozWebSocket);if(!t.WebSocket){u();return}i.socket||(f=document.location.host+i.appRelativeUrl,n(i).trigger("onSending"),f+=i.data?"?connectionData="+i.data+"&transport=webSockets&clientId="+i.clientId:"?transport=webSockets&clientId="+i.clientId,e=document.location.protocol==="https:"?"wss://":"ws://",i.socket=new t.WebSocket(e+f),i.socket.onopen=function(){o=!0,r&&r()},i.socket.onclose=function(t){o?typeof t.wasClean!="undefined"&&t.wasClean===!1&&n(i).trigger("onError"):u&&u(),i.socket=null},i.socket.onmessage=function(r){var u=t.JSON.parse(r.data);u&&(u.Messages?n.each(u.Messages,function(){n(i).trigger("onReceived",[this])}):n(i).trigger("onReceived",[u]))})},stop:function(n){n.socket!==null&&(n.socket.close(),n.socket=null)}},longPolling:{start:function(i,r){i.pollXhr&&i.stop(),i.messageId=null,t.setTimeout(function(){(function u(i){n(i).trigger("onSending");var r=i.messageId,e=r===null,f=i.url+(e?"/connect":"");i.pollXhr=n.ajax(f,{type:"POST",data:{clientId:i.clientId,messageId:r,connectionData:i.data,transport:"longPolling",groups:(i.groups||[]).toString()},dataType:"json",success:function(r){var f=0;r&&(r.Messages&&n.each(r.Messages,function(){try{n(i).trigger("onReceived",[this])}catch(t){console&&console.log&&console.log("Error raising received "+t)}}),i.messageId=r.MessageId,n.type(r.TransportData.LongPollDelay)==="number"&&(f=r.TransportData.LongPollDelay),i.groups=r.TransportData.Groups),f>0?t.setTimeout(function(){u(i)},f):u(i)},error:function(r,f){if(f==="abort")return;n(i).trigger("onError",[r]),t.setTimeout(function(){u(i)},2e3)}})})(i),setTimeout(r,150)},250)},send:function(t,i){n.ajax(t.url+"/send",{type:"POST",dataType:"json",data:{data:i,transport:"longPolling",clientId:t.clientId},success:function(i){i&&n(t).trigger("onReceived",[i])},error:function(i,r){if(r==="abort")return;n(t).trigger("onError",[i])}})},stop:function(n){n.pollXhr&&(n.pollXhr.abort(),n.pollXhr=null)}}},i.noConflict=function(){return n.connection===i&&(n.connection=r),i},n.connection&&(r=n.connection),n.connection=n.signalR=i})(window.jQuery,window)