"use strict" !function(){function e(){var e=this e.$$config={lazy:!1,reconnect:!0,reconnectInterval:2e3,mock:!1,enqueue:!1,protocols:null},e.$setup=function(n){return n=n||{},e.$$config=angular.extend({},e.$$config,n),e},e.$get=["$http",function(t){return new n(e.$$config,t)}]}function n(e,n){var o=this o.$$websocketList={},o.$$config=e||{},o.$get=function(e){return o.$$websocketList[e]},o.$new=function(e){e=e||{},"string"==typeof e&&(e={url:e},arguments.length>1&&("string"==typeof arguments[1]&&arguments[1].length>0?e.protocols=[arguments[1]]:"object"==typeof arguments[1]&&arguments[1].length>0&&(e.protocols=arguments[1]))) var r=o.$get(e.url) if("undefined"==typeof r){var $=angular.extend({},o.$$config,e) r=new t($,n),o.$$websocketList[$.url]=r}return r}}function t(e,n){var t=this if("undefined"==typeof e||"object"==typeof e&&"undefined"==typeof e.url)throw new Error("An url must be specified for WebSocket") return t.$$eventMap={},t.$$ws=void 0,t.$$reconnectTask=void 0,t.$$reconnectCopy=!0,t.$$queue=[],t.$$config={url:void 0,lazy:!1,reconnect:!0,reconnectInterval:2e3,enqueue:!1,mock:!1,protocols:null},t.$$fireEvent=function(){var e=[] Array.prototype.push.apply(e,arguments) var n=e.shift(),o=t.$$eventMap[n] if("undefined"!=typeof o)for(var r=0;r0)for(;t.$$queue.length>0&&t.$ready();)t.$$send(t.$$queue.shift()) t.$$fireEvent("$open")},t.$$ws.onclose=function(){t.$$config.reconnect&&!t.$$reconnectTask&&(t.$$reconnectTask=setInterval(function(){t.$status()===t.$CLOSED&&t.$open()},t.$$config.reconnectInterval)),t.$$fireEvent("$close")},t},t.$CONNECTING=0,t.$OPEN=1,t.$CLOSING=2,t.$CLOSED=3,t.$on=function(){var e=[] Array.prototype.push.apply(e,arguments) var n=e.shift() if("string"!=typeof n||0===e.length)throw new Error("$on accept two parameters at least: a String and a Function or an array of Functions") t.$$eventMap[n]=t.$$eventMap[n]||[] for(var o=0;o0){var e=a.shift(),n=JSON.parse(e) switch(n.event){case"$close":t.close() break default:"undefined"!=typeof c[n.event]&&(n.data=c[n.event].data||n.data,n.event=c[n.event].event||n.event),e=JSON.stringify(n),t.onmessage({data:e})}}},$) var i=function(e){e=e||{},e=e instanceof Error?{}:e,c=e,setTimeout(function(){t.readyState=t.OPEN,t.onopen()},o)} return"string"==typeof c?n.get(c).success(i).error(i):i(c),t}angular.module("ngWebsocket",[]).provider("$websocket",e)}()