socket.io.min.v4.msgpack.js 102 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204
  1. /*!
  2. * Socket.IO v4.4.1
  3. * (c) 2014-2022 Guillermo Rauch
  4. * Released under the MIT License.
  5. */
  6. !(function (t, e) {
  7. 'object' == typeof exports && 'undefined' != typeof module
  8. ? (module.exports = e())
  9. : 'function' == typeof define && define.amd
  10. ? define(e)
  11. : ((t = 'undefined' != typeof globalThis ? globalThis : t || self).io = e())
  12. })(this, function () {
  13. 'use strict'
  14. function t(t, e) {
  15. return (
  16. e.forEach(function (e) {
  17. Object.keys(e).forEach(function (n) {
  18. if ('default' !== n && !(n in t)) {
  19. var r = Object.getOwnPropertyDescriptor(e, n)
  20. Object.defineProperty(
  21. t,
  22. n,
  23. r.get
  24. ? r
  25. : {
  26. enumerable: !0,
  27. get: function () {
  28. return e[n]
  29. },
  30. }
  31. )
  32. }
  33. })
  34. }),
  35. Object.freeze(t)
  36. )
  37. }
  38. function e(t) {
  39. return (
  40. (e =
  41. 'function' == typeof Symbol && 'symbol' == typeof Symbol.iterator
  42. ? function (t) {
  43. return typeof t
  44. }
  45. : function (t) {
  46. return t && 'function' == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? 'symbol' : typeof t
  47. }),
  48. e(t)
  49. )
  50. }
  51. function n(t, e) {
  52. if (!(t instanceof e)) throw new TypeError('Cannot call a class as a function')
  53. }
  54. function r(t, e) {
  55. for (var n = 0; n < e.length; n++) {
  56. var r = e[n]
  57. ;(r.enumerable = r.enumerable || !1), (r.configurable = !0), 'value' in r && (r.writable = !0), Object.defineProperty(t, r.key, r)
  58. }
  59. }
  60. function i(t, e, n) {
  61. return e && r(t.prototype, e), n && r(t, n), t
  62. }
  63. function o() {
  64. return (
  65. (o =
  66. Object.assign ||
  67. function (t) {
  68. for (var e = 1; e < arguments.length; e++) {
  69. var n = arguments[e]
  70. for (var r in n) Object.prototype.hasOwnProperty.call(n, r) && (t[r] = n[r])
  71. }
  72. return t
  73. }),
  74. o.apply(this, arguments)
  75. )
  76. }
  77. function s(t, e) {
  78. if ('function' != typeof e && null !== e) throw new TypeError('Super expression must either be null or a function')
  79. ;(t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } })), e && c(t, e)
  80. }
  81. function a(t) {
  82. return (
  83. (a = Object.setPrototypeOf
  84. ? Object.getPrototypeOf
  85. : function (t) {
  86. return t.__proto__ || Object.getPrototypeOf(t)
  87. }),
  88. a(t)
  89. )
  90. }
  91. function c(t, e) {
  92. return (
  93. (c =
  94. Object.setPrototypeOf ||
  95. function (t, e) {
  96. return (t.__proto__ = e), t
  97. }),
  98. c(t, e)
  99. )
  100. }
  101. function h(t) {
  102. if (void 0 === t) throw new ReferenceError("this hasn't been initialised - super() hasn't been called")
  103. return t
  104. }
  105. function u(t, e) {
  106. if (e && ('object' == typeof e || 'function' == typeof e)) return e
  107. if (void 0 !== e) throw new TypeError('Derived constructors may only return object or undefined')
  108. return h(t)
  109. }
  110. function f(t) {
  111. var e = (function () {
  112. if ('undefined' == typeof Reflect || !Reflect.construct) return !1
  113. if (Reflect.construct.sham) return !1
  114. if ('function' == typeof Proxy) return !0
  115. try {
  116. return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})), !0
  117. } catch (t) {
  118. return !1
  119. }
  120. })()
  121. return function () {
  122. var n,
  123. r = a(t)
  124. if (e) {
  125. var i = a(this).constructor
  126. n = Reflect.construct(r, arguments, i)
  127. } else n = r.apply(this, arguments)
  128. return u(this, n)
  129. }
  130. }
  131. function p(t, e, n) {
  132. return (
  133. (p =
  134. 'undefined' != typeof Reflect && Reflect.get
  135. ? Reflect.get
  136. : function (t, e, n) {
  137. var r = (function (t, e) {
  138. for (; !Object.prototype.hasOwnProperty.call(t, e) && null !== (t = a(t)); );
  139. return t
  140. })(t, e)
  141. if (r) {
  142. var i = Object.getOwnPropertyDescriptor(r, e)
  143. return i.get ? i.get.call(n) : i.value
  144. }
  145. }),
  146. p(t, e, n || t)
  147. )
  148. }
  149. function l(t, e) {
  150. ;(null == e || e > t.length) && (e = t.length)
  151. for (var n = 0, r = new Array(e); n < e; n++) r[n] = t[n]
  152. return r
  153. }
  154. function d(t, e) {
  155. var n = ('undefined' != typeof Symbol && t[Symbol.iterator]) || t['@@iterator']
  156. if (!n) {
  157. if (
  158. Array.isArray(t) ||
  159. (n = (function (t, e) {
  160. if (t) {
  161. if ('string' == typeof t) return l(t, e)
  162. var n = Object.prototype.toString.call(t).slice(8, -1)
  163. return (
  164. 'Object' === n && t.constructor && (n = t.constructor.name),
  165. 'Map' === n || 'Set' === n ? Array.from(t) : 'Arguments' === n || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n) ? l(t, e) : void 0
  166. )
  167. }
  168. })(t)) ||
  169. (e && t && 'number' == typeof t.length)
  170. ) {
  171. n && (t = n)
  172. var r = 0,
  173. i = function () {}
  174. return {
  175. s: i,
  176. n: function () {
  177. return r >= t.length ? { done: !0 } : { done: !1, value: t[r++] }
  178. },
  179. e: function (t) {
  180. throw t
  181. },
  182. f: i,
  183. }
  184. }
  185. throw new TypeError('Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.')
  186. }
  187. var o,
  188. s = !0,
  189. a = !1
  190. return {
  191. s: function () {
  192. n = n.call(t)
  193. },
  194. n: function () {
  195. var t = n.next()
  196. return (s = t.done), t
  197. },
  198. e: function (t) {
  199. ;(a = !0), (o = t)
  200. },
  201. f: function () {
  202. try {
  203. s || null == n.return || n.return()
  204. } finally {
  205. if (a) throw o
  206. }
  207. },
  208. }
  209. }
  210. var y =
  211. /^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,
  212. v = ['source', 'protocol', 'authority', 'userInfo', 'user', 'password', 'host', 'port', 'relative', 'path', 'directory', 'file', 'query', 'anchor'],
  213. g = function (t) {
  214. var e = t,
  215. n = t.indexOf('['),
  216. r = t.indexOf(']')
  217. ;-1 != n && -1 != r && (t = t.substring(0, n) + t.substring(n, r).replace(/:/g, ';') + t.substring(r, t.length))
  218. for (var i, o, s = y.exec(t || ''), a = {}, c = 14; c--; ) a[v[c]] = s[c] || ''
  219. return (
  220. -1 != n &&
  221. -1 != r &&
  222. ((a.source = e),
  223. (a.host = a.host.substring(1, a.host.length - 1).replace(/;/g, ':')),
  224. (a.authority = a.authority.replace('[', '').replace(']', '').replace(/;/g, ':')),
  225. (a.ipv6uri = !0)),
  226. (a.pathNames = (function (t, e) {
  227. var n = /\/{2,9}/g,
  228. r = e.replace(n, '/').split('/')
  229. ;('/' != e.substr(0, 1) && 0 !== e.length) || r.splice(0, 1)
  230. '/' == e.substr(e.length - 1, 1) && r.splice(r.length - 1, 1)
  231. return r
  232. })(0, a.path)),
  233. (a.queryKey =
  234. ((i = a.query),
  235. (o = {}),
  236. i.replace(/(?:^|&)([^&=]*)=?([^&]*)/g, function (t, e, n) {
  237. e && (o[e] = n)
  238. }),
  239. o)),
  240. a
  241. )
  242. }
  243. var m = { exports: {} }
  244. try {
  245. m.exports = 'undefined' != typeof XMLHttpRequest && 'withCredentials' in new XMLHttpRequest()
  246. } catch (t) {
  247. m.exports = !1
  248. }
  249. var _ = m.exports,
  250. b = 'undefined' != typeof self ? self : 'undefined' != typeof window ? window : Function('return this')()
  251. function k(t) {
  252. var e = t.xdomain
  253. try {
  254. if ('undefined' != typeof XMLHttpRequest && (!e || _)) return new XMLHttpRequest()
  255. } catch (t) {}
  256. if (!e)
  257. try {
  258. return new b[['Active'].concat('Object').join('X')]('Microsoft.XMLHTTP')
  259. } catch (t) {}
  260. }
  261. function w(t) {
  262. for (var e = arguments.length, n = new Array(e > 1 ? e - 1 : 0), r = 1; r < e; r++) n[r - 1] = arguments[r]
  263. return n.reduce(function (e, n) {
  264. return t.hasOwnProperty(n) && (e[n] = t[n]), e
  265. }, {})
  266. }
  267. var E = setTimeout,
  268. C = clearTimeout
  269. function O(t, e) {
  270. e.useNativeTimers ? ((t.setTimeoutFn = E.bind(b)), (t.clearTimeoutFn = C.bind(b))) : ((t.setTimeoutFn = setTimeout.bind(b)), (t.clearTimeoutFn = clearTimeout.bind(b)))
  271. }
  272. var T = S
  273. function S(t) {
  274. if (t)
  275. return (function (t) {
  276. for (var e in S.prototype) t[e] = S.prototype[e]
  277. return t
  278. })(t)
  279. }
  280. ;(S.prototype.on = S.prototype.addEventListener =
  281. function (t, e) {
  282. return (this._callbacks = this._callbacks || {}), (this._callbacks['$' + t] = this._callbacks['$' + t] || []).push(e), this
  283. }),
  284. (S.prototype.once = function (t, e) {
  285. function n() {
  286. this.off(t, n), e.apply(this, arguments)
  287. }
  288. return (n.fn = e), this.on(t, n), this
  289. }),
  290. (S.prototype.off =
  291. S.prototype.removeListener =
  292. S.prototype.removeAllListeners =
  293. S.prototype.removeEventListener =
  294. function (t, e) {
  295. if (((this._callbacks = this._callbacks || {}), 0 == arguments.length)) return (this._callbacks = {}), this
  296. var n,
  297. r = this._callbacks['$' + t]
  298. if (!r) return this
  299. if (1 == arguments.length) return delete this._callbacks['$' + t], this
  300. for (var i = 0; i < r.length; i++)
  301. if ((n = r[i]) === e || n.fn === e) {
  302. r.splice(i, 1)
  303. break
  304. }
  305. return 0 === r.length && delete this._callbacks['$' + t], this
  306. }),
  307. (S.prototype.emit = function (t) {
  308. this._callbacks = this._callbacks || {}
  309. for (var e = new Array(arguments.length - 1), n = this._callbacks['$' + t], r = 1; r < arguments.length; r++) e[r - 1] = arguments[r]
  310. if (n) {
  311. r = 0
  312. for (var i = (n = n.slice(0)).length; r < i; ++r) n[r].apply(this, e)
  313. }
  314. return this
  315. }),
  316. (S.prototype.emitReserved = S.prototype.emit),
  317. (S.prototype.listeners = function (t) {
  318. return (this._callbacks = this._callbacks || {}), this._callbacks['$' + t] || []
  319. }),
  320. (S.prototype.hasListeners = function (t) {
  321. return !!this.listeners(t).length
  322. })
  323. var R = Object.create(null)
  324. ;(R.open = '0'), (R.close = '1'), (R.ping = '2'), (R.pong = '3'), (R.message = '4'), (R.upgrade = '5'), (R.noop = '6')
  325. var A = Object.create(null)
  326. Object.keys(R).forEach(function (t) {
  327. A[R[t]] = t
  328. })
  329. for (
  330. var x = { type: 'error', data: 'parser error' },
  331. U = 'function' == typeof Blob || ('undefined' != typeof Blob && '[object BlobConstructor]' === Object.prototype.toString.call(Blob)),
  332. L = 'function' == typeof ArrayBuffer,
  333. B = function (t, e, n) {
  334. var r,
  335. i = t.type,
  336. o = t.data
  337. return U && o instanceof Blob
  338. ? e
  339. ? n(o)
  340. : j(o, n)
  341. : L && (o instanceof ArrayBuffer || ((r = o), 'function' == typeof ArrayBuffer.isView ? ArrayBuffer.isView(r) : r && r.buffer instanceof ArrayBuffer))
  342. ? e
  343. ? n(o)
  344. : j(new Blob([o]), n)
  345. : n(R[i] + (o || ''))
  346. },
  347. j = function (t, e) {
  348. var n = new FileReader()
  349. return (
  350. (n.onload = function () {
  351. var t = n.result.split(',')[1]
  352. e('b' + t)
  353. }),
  354. n.readAsDataURL(t)
  355. )
  356. },
  357. N = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/',
  358. P = 'undefined' == typeof Uint8Array ? [] : new Uint8Array(256),
  359. q = 0;
  360. q < N.length;
  361. q++
  362. )
  363. P[N.charCodeAt(q)] = q
  364. var D,
  365. I = 'function' == typeof ArrayBuffer,
  366. M = function (t, e) {
  367. if ('string' != typeof t) return { type: 'message', data: H(t, e) }
  368. var n = t.charAt(0)
  369. return 'b' === n ? { type: 'message', data: F(t.substring(1), e) } : A[n] ? (t.length > 1 ? { type: A[n], data: t.substring(1) } : { type: A[n] }) : x
  370. },
  371. F = function (t, e) {
  372. if (I) {
  373. var n = (function (t) {
  374. var e,
  375. n,
  376. r,
  377. i,
  378. o,
  379. s = 0.75 * t.length,
  380. a = t.length,
  381. c = 0
  382. '=' === t[t.length - 1] && (s--, '=' === t[t.length - 2] && s--)
  383. var h = new ArrayBuffer(s),
  384. u = new Uint8Array(h)
  385. for (e = 0; e < a; e += 4)
  386. (n = P[t.charCodeAt(e)]),
  387. (r = P[t.charCodeAt(e + 1)]),
  388. (i = P[t.charCodeAt(e + 2)]),
  389. (o = P[t.charCodeAt(e + 3)]),
  390. (u[c++] = (n << 2) | (r >> 4)),
  391. (u[c++] = ((15 & r) << 4) | (i >> 2)),
  392. (u[c++] = ((3 & i) << 6) | (63 & o))
  393. return h
  394. })(t)
  395. return H(n, e)
  396. }
  397. return { base64: !0, data: t }
  398. },
  399. H = function (t, e) {
  400. return 'blob' === e && t instanceof ArrayBuffer ? new Blob([t]) : t
  401. },
  402. $ = String.fromCharCode(30),
  403. z = (function (t) {
  404. s(r, t)
  405. var e = f(r)
  406. function r(t) {
  407. var i
  408. return n(this, r), ((i = e.call(this)).writable = !1), O(h(i), t), (i.opts = t), (i.query = t.query), (i.readyState = ''), (i.socket = t.socket), i
  409. }
  410. return (
  411. i(r, [
  412. {
  413. key: 'onError',
  414. value: function (t, e) {
  415. var n = new Error(t)
  416. return (n.type = 'TransportError'), (n.description = e), p(a(r.prototype), 'emit', this).call(this, 'error', n), this
  417. },
  418. },
  419. {
  420. key: 'open',
  421. value: function () {
  422. return ('closed' !== this.readyState && '' !== this.readyState) || ((this.readyState = 'opening'), this.doOpen()), this
  423. },
  424. },
  425. {
  426. key: 'close',
  427. value: function () {
  428. return ('opening' !== this.readyState && 'open' !== this.readyState) || (this.doClose(), this.onClose()), this
  429. },
  430. },
  431. {
  432. key: 'send',
  433. value: function (t) {
  434. 'open' === this.readyState && this.write(t)
  435. },
  436. },
  437. {
  438. key: 'onOpen',
  439. value: function () {
  440. ;(this.readyState = 'open'), (this.writable = !0), p(a(r.prototype), 'emit', this).call(this, 'open')
  441. },
  442. },
  443. {
  444. key: 'onData',
  445. value: function (t) {
  446. var e = M(t, this.socket.binaryType)
  447. this.onPacket(e)
  448. },
  449. },
  450. {
  451. key: 'onPacket',
  452. value: function (t) {
  453. p(a(r.prototype), 'emit', this).call(this, 'packet', t)
  454. },
  455. },
  456. {
  457. key: 'onClose',
  458. value: function () {
  459. ;(this.readyState = 'closed'), p(a(r.prototype), 'emit', this).call(this, 'close')
  460. },
  461. },
  462. ]),
  463. r
  464. )
  465. })(T),
  466. V = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_'.split(''),
  467. W = {},
  468. X = 0,
  469. K = 0
  470. function J(t) {
  471. var e = ''
  472. do {
  473. ;(e = V[t % 64] + e), (t = Math.floor(t / 64))
  474. } while (t > 0)
  475. return e
  476. }
  477. function Y() {
  478. var t = J(+new Date())
  479. return t !== D ? ((X = 0), (D = t)) : t + '.' + J(X++)
  480. }
  481. for (; K < 64; K++) W[V[K]] = K
  482. ;(Y.encode = J),
  483. (Y.decode = function (t) {
  484. var e = 0
  485. for (K = 0; K < t.length; K++) e = 64 * e + W[t.charAt(K)]
  486. return e
  487. })
  488. var G = Y,
  489. Q = {
  490. encode: function (t) {
  491. var e = ''
  492. for (var n in t) t.hasOwnProperty(n) && (e.length && (e += '&'), (e += encodeURIComponent(n) + '=' + encodeURIComponent(t[n])))
  493. return e
  494. },
  495. decode: function (t) {
  496. for (var e = {}, n = t.split('&'), r = 0, i = n.length; r < i; r++) {
  497. var o = n[r].split('=')
  498. e[decodeURIComponent(o[0])] = decodeURIComponent(o[1])
  499. }
  500. return e
  501. },
  502. },
  503. Z = (function (t) {
  504. s(r, t)
  505. var e = f(r)
  506. function r() {
  507. var t
  508. return n(this, r), ((t = e.apply(this, arguments)).polling = !1), t
  509. }
  510. return (
  511. i(r, [
  512. {
  513. key: 'name',
  514. get: function () {
  515. return 'polling'
  516. },
  517. },
  518. {
  519. key: 'doOpen',
  520. value: function () {
  521. this.poll()
  522. },
  523. },
  524. {
  525. key: 'pause',
  526. value: function (t) {
  527. var e = this
  528. this.readyState = 'pausing'
  529. var n = function () {
  530. ;(e.readyState = 'paused'), t()
  531. }
  532. if (this.polling || !this.writable) {
  533. var r = 0
  534. this.polling &&
  535. (r++,
  536. this.once('pollComplete', function () {
  537. --r || n()
  538. })),
  539. this.writable ||
  540. (r++,
  541. this.once('drain', function () {
  542. --r || n()
  543. }))
  544. } else n()
  545. },
  546. },
  547. {
  548. key: 'poll',
  549. value: function () {
  550. ;(this.polling = !0), this.doPoll(), this.emit('poll')
  551. },
  552. },
  553. {
  554. key: 'onData',
  555. value: function (t) {
  556. var e = this
  557. ;(function (t, e) {
  558. for (var n = t.split($), r = [], i = 0; i < n.length; i++) {
  559. var o = M(n[i], e)
  560. if ((r.push(o), 'error' === o.type)) break
  561. }
  562. return r
  563. })(t, this.socket.binaryType).forEach(function (t) {
  564. if (('opening' === e.readyState && 'open' === t.type && e.onOpen(), 'close' === t.type)) return e.onClose(), !1
  565. e.onPacket(t)
  566. }),
  567. 'closed' !== this.readyState && ((this.polling = !1), this.emit('pollComplete'), 'open' === this.readyState && this.poll())
  568. },
  569. },
  570. {
  571. key: 'doClose',
  572. value: function () {
  573. var t = this,
  574. e = function () {
  575. t.write([{ type: 'close' }])
  576. }
  577. 'open' === this.readyState ? e() : this.once('open', e)
  578. },
  579. },
  580. {
  581. key: 'write',
  582. value: function (t) {
  583. var e = this
  584. ;(this.writable = !1),
  585. (function (t, e) {
  586. var n = t.length,
  587. r = new Array(n),
  588. i = 0
  589. t.forEach(function (t, o) {
  590. B(t, !1, function (t) {
  591. ;(r[o] = t), ++i === n && e(r.join($))
  592. })
  593. })
  594. })(t, function (t) {
  595. e.doWrite(t, function () {
  596. ;(e.writable = !0), e.emit('drain')
  597. })
  598. })
  599. },
  600. },
  601. {
  602. key: 'uri',
  603. value: function () {
  604. var t = this.query || {},
  605. e = this.opts.secure ? 'https' : 'http',
  606. n = ''
  607. !1 !== this.opts.timestampRequests && (t[this.opts.timestampParam] = G()),
  608. this.supportsBinary || t.sid || (t.b64 = 1),
  609. this.opts.port && (('https' === e && 443 !== Number(this.opts.port)) || ('http' === e && 80 !== Number(this.opts.port))) && (n = ':' + this.opts.port)
  610. var r = Q.encode(t)
  611. return e + '://' + (-1 !== this.opts.hostname.indexOf(':') ? '[' + this.opts.hostname + ']' : this.opts.hostname) + n + this.opts.path + (r.length ? '?' + r : '')
  612. },
  613. },
  614. ]),
  615. r
  616. )
  617. })(z)
  618. function tt() {}
  619. var et = null != new k({ xdomain: !1 }).responseType,
  620. nt = (function (t) {
  621. s(r, t)
  622. var e = f(r)
  623. function r(t) {
  624. var i
  625. if ((n(this, r), (i = e.call(this, t)), 'undefined' != typeof location)) {
  626. var o = 'https:' === location.protocol,
  627. s = location.port
  628. s || (s = o ? '443' : '80'), (i.xd = ('undefined' != typeof location && t.hostname !== location.hostname) || s !== t.port), (i.xs = t.secure !== o)
  629. }
  630. var a = t && t.forceBase64
  631. return (i.supportsBinary = et && !a), i
  632. }
  633. return (
  634. i(r, [
  635. {
  636. key: 'request',
  637. value: function () {
  638. var t = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {}
  639. return o(t, { xd: this.xd, xs: this.xs }, this.opts), new rt(this.uri(), t)
  640. },
  641. },
  642. {
  643. key: 'doWrite',
  644. value: function (t, e) {
  645. var n = this,
  646. r = this.request({ method: 'POST', data: t })
  647. r.on('success', e),
  648. r.on('error', function (t) {
  649. n.onError('xhr post error', t)
  650. })
  651. },
  652. },
  653. {
  654. key: 'doPoll',
  655. value: function () {
  656. var t = this,
  657. e = this.request()
  658. e.on('data', this.onData.bind(this)),
  659. e.on('error', function (e) {
  660. t.onError('xhr poll error', e)
  661. }),
  662. (this.pollXhr = e)
  663. },
  664. },
  665. ]),
  666. r
  667. )
  668. })(Z),
  669. rt = (function (t) {
  670. s(r, t)
  671. var e = f(r)
  672. function r(t, i) {
  673. var o
  674. return (
  675. n(this, r),
  676. O(h((o = e.call(this))), i),
  677. (o.opts = i),
  678. (o.method = i.method || 'GET'),
  679. (o.uri = t),
  680. (o.async = !1 !== i.async),
  681. (o.data = void 0 !== i.data ? i.data : null),
  682. o.create(),
  683. o
  684. )
  685. }
  686. return (
  687. i(r, [
  688. {
  689. key: 'create',
  690. value: function () {
  691. var t = this,
  692. e = w(this.opts, 'agent', 'pfx', 'key', 'passphrase', 'cert', 'ca', 'ciphers', 'rejectUnauthorized', 'autoUnref')
  693. ;(e.xdomain = !!this.opts.xd), (e.xscheme = !!this.opts.xs)
  694. var n = (this.xhr = new k(e))
  695. try {
  696. n.open(this.method, this.uri, this.async)
  697. try {
  698. if (this.opts.extraHeaders)
  699. for (var i in (n.setDisableHeaderCheck && n.setDisableHeaderCheck(!0), this.opts.extraHeaders))
  700. this.opts.extraHeaders.hasOwnProperty(i) && n.setRequestHeader(i, this.opts.extraHeaders[i])
  701. } catch (t) {}
  702. if ('POST' === this.method)
  703. try {
  704. n.setRequestHeader('Content-type', 'text/plain;charset=UTF-8')
  705. } catch (t) {}
  706. try {
  707. n.setRequestHeader('Accept', '*/*')
  708. } catch (t) {}
  709. 'withCredentials' in n && (n.withCredentials = this.opts.withCredentials),
  710. this.opts.requestTimeout && (n.timeout = this.opts.requestTimeout),
  711. (n.onreadystatechange = function () {
  712. 4 === n.readyState &&
  713. (200 === n.status || 1223 === n.status
  714. ? t.onLoad()
  715. : t.setTimeoutFn(function () {
  716. t.onError('number' == typeof n.status ? n.status : 0)
  717. }, 0))
  718. }),
  719. n.send(this.data)
  720. } catch (e) {
  721. return void this.setTimeoutFn(function () {
  722. t.onError(e)
  723. }, 0)
  724. }
  725. 'undefined' != typeof document && ((this.index = r.requestsCount++), (r.requests[this.index] = this))
  726. },
  727. },
  728. {
  729. key: 'onSuccess',
  730. value: function () {
  731. this.emit('success'), this.cleanup()
  732. },
  733. },
  734. {
  735. key: 'onData',
  736. value: function (t) {
  737. this.emit('data', t), this.onSuccess()
  738. },
  739. },
  740. {
  741. key: 'onError',
  742. value: function (t) {
  743. this.emit('error', t), this.cleanup(!0)
  744. },
  745. },
  746. {
  747. key: 'cleanup',
  748. value: function (t) {
  749. if (void 0 !== this.xhr && null !== this.xhr) {
  750. if (((this.xhr.onreadystatechange = tt), t))
  751. try {
  752. this.xhr.abort()
  753. } catch (t) {}
  754. 'undefined' != typeof document && delete r.requests[this.index], (this.xhr = null)
  755. }
  756. },
  757. },
  758. {
  759. key: 'onLoad',
  760. value: function () {
  761. var t = this.xhr.responseText
  762. null !== t && this.onData(t)
  763. },
  764. },
  765. {
  766. key: 'abort',
  767. value: function () {
  768. this.cleanup()
  769. },
  770. },
  771. ]),
  772. r
  773. )
  774. })(T)
  775. if (((rt.requestsCount = 0), (rt.requests = {}), 'undefined' != typeof document))
  776. if ('function' == typeof attachEvent) attachEvent('onunload', it)
  777. else if ('function' == typeof addEventListener) {
  778. addEventListener('onpagehide' in b ? 'pagehide' : 'unload', it, !1)
  779. }
  780. function it() {
  781. for (var t in rt.requests) rt.requests.hasOwnProperty(t) && rt.requests[t].abort()
  782. }
  783. var ot =
  784. 'function' == typeof Promise && 'function' == typeof Promise.resolve
  785. ? function (t) {
  786. return Promise.resolve().then(t)
  787. }
  788. : function (t, e) {
  789. return e(t, 0)
  790. },
  791. st = b.WebSocket || b.MozWebSocket,
  792. at = 'undefined' != typeof navigator && 'string' == typeof navigator.product && 'reactnative' === navigator.product.toLowerCase(),
  793. ct = (function (t) {
  794. s(r, t)
  795. var e = f(r)
  796. function r(t) {
  797. var i
  798. return n(this, r), ((i = e.call(this, t)).supportsBinary = !t.forceBase64), i
  799. }
  800. return (
  801. i(r, [
  802. {
  803. key: 'name',
  804. get: function () {
  805. return 'websocket'
  806. },
  807. },
  808. {
  809. key: 'doOpen',
  810. value: function () {
  811. if (this.check()) {
  812. var t = this.uri(),
  813. e = this.opts.protocols,
  814. n = at
  815. ? {}
  816. : w(
  817. this.opts,
  818. 'agent',
  819. 'perMessageDeflate',
  820. 'pfx',
  821. 'key',
  822. 'passphrase',
  823. 'cert',
  824. 'ca',
  825. 'ciphers',
  826. 'rejectUnauthorized',
  827. 'localAddress',
  828. 'protocolVersion',
  829. 'origin',
  830. 'maxPayload',
  831. 'family',
  832. 'checkServerIdentity'
  833. )
  834. this.opts.extraHeaders && (n.headers = this.opts.extraHeaders)
  835. try {
  836. this.ws = at ? new st(t, e, n) : e ? new st(t, e) : new st(t)
  837. } catch (t) {
  838. return this.emit('error', t)
  839. }
  840. ;(this.ws.binaryType = this.socket.binaryType || 'arraybuffer'), this.addEventListeners()
  841. }
  842. },
  843. },
  844. {
  845. key: 'addEventListeners',
  846. value: function () {
  847. var t = this
  848. ;(this.ws.onopen = function () {
  849. t.opts.autoUnref && t.ws._socket.unref(), t.onOpen()
  850. }),
  851. (this.ws.onclose = this.onClose.bind(this)),
  852. (this.ws.onmessage = function (e) {
  853. return t.onData(e.data)
  854. }),
  855. (this.ws.onerror = function (e) {
  856. return t.onError('websocket error', e)
  857. })
  858. },
  859. },
  860. {
  861. key: 'write',
  862. value: function (t) {
  863. var e = this
  864. this.writable = !1
  865. for (
  866. var n = function (n) {
  867. var r = t[n],
  868. i = n === t.length - 1
  869. B(r, e.supportsBinary, function (t) {
  870. try {
  871. e.ws.send(t)
  872. } catch (t) {}
  873. i &&
  874. ot(function () {
  875. ;(e.writable = !0), e.emit('drain')
  876. }, e.setTimeoutFn)
  877. })
  878. },
  879. r = 0;
  880. r < t.length;
  881. r++
  882. )
  883. n(r)
  884. },
  885. },
  886. {
  887. key: 'doClose',
  888. value: function () {
  889. void 0 !== this.ws && (this.ws.close(), (this.ws = null))
  890. },
  891. },
  892. {
  893. key: 'uri',
  894. value: function () {
  895. var t = this.query || {},
  896. e = this.opts.secure ? 'wss' : 'ws',
  897. n = ''
  898. this.opts.port && (('wss' === e && 443 !== Number(this.opts.port)) || ('ws' === e && 80 !== Number(this.opts.port))) && (n = ':' + this.opts.port),
  899. this.opts.timestampRequests && (t[this.opts.timestampParam] = G()),
  900. this.supportsBinary || (t.b64 = 1)
  901. var r = Q.encode(t)
  902. return e + '://' + (-1 !== this.opts.hostname.indexOf(':') ? '[' + this.opts.hostname + ']' : this.opts.hostname) + n + this.opts.path + (r.length ? '?' + r : '')
  903. },
  904. },
  905. {
  906. key: 'check',
  907. value: function () {
  908. return !(!st || ('__initialize' in st && this.name === r.prototype.name))
  909. },
  910. },
  911. ]),
  912. r
  913. )
  914. })(z),
  915. ht = { websocket: ct, polling: nt },
  916. ut = (function (t) {
  917. s(a, t)
  918. var r = f(a)
  919. function a(t) {
  920. var i,
  921. s = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {}
  922. return (
  923. n(this, a),
  924. (i = r.call(this)),
  925. t && 'object' === e(t) && ((s = t), (t = null)),
  926. t
  927. ? ((t = g(t)), (s.hostname = t.host), (s.secure = 'https' === t.protocol || 'wss' === t.protocol), (s.port = t.port), t.query && (s.query = t.query))
  928. : s.host && (s.hostname = g(s.host).host),
  929. O(h(i), s),
  930. (i.secure = null != s.secure ? s.secure : 'undefined' != typeof location && 'https:' === location.protocol),
  931. s.hostname && !s.port && (s.port = i.secure ? '443' : '80'),
  932. (i.hostname = s.hostname || ('undefined' != typeof location ? location.hostname : 'localhost')),
  933. (i.port = s.port || ('undefined' != typeof location && location.port ? location.port : i.secure ? '443' : '80')),
  934. (i.transports = s.transports || ['polling', 'websocket']),
  935. (i.readyState = ''),
  936. (i.writeBuffer = []),
  937. (i.prevBufferLen = 0),
  938. (i.opts = o(
  939. {
  940. path: '/engine.io',
  941. agent: !1,
  942. withCredentials: !1,
  943. upgrade: !0,
  944. timestampParam: 't',
  945. rememberUpgrade: !1,
  946. rejectUnauthorized: !0,
  947. perMessageDeflate: { threshold: 1024 },
  948. transportOptions: {},
  949. closeOnBeforeunload: !0,
  950. },
  951. s
  952. )),
  953. (i.opts.path = i.opts.path.replace(/\/$/, '') + '/'),
  954. 'string' == typeof i.opts.query && (i.opts.query = Q.decode(i.opts.query)),
  955. (i.id = null),
  956. (i.upgrades = null),
  957. (i.pingInterval = null),
  958. (i.pingTimeout = null),
  959. (i.pingTimeoutTimer = null),
  960. 'function' == typeof addEventListener &&
  961. (i.opts.closeOnBeforeunload &&
  962. addEventListener(
  963. 'beforeunload',
  964. function () {
  965. i.transport && (i.transport.removeAllListeners(), i.transport.close())
  966. },
  967. !1
  968. ),
  969. 'localhost' !== i.hostname &&
  970. ((i.offlineEventListener = function () {
  971. i.onClose('transport close')
  972. }),
  973. addEventListener('offline', i.offlineEventListener, !1))),
  974. i.open(),
  975. i
  976. )
  977. }
  978. return (
  979. i(a, [
  980. {
  981. key: 'createTransport',
  982. value: function (t) {
  983. var e = (function (t) {
  984. var e = {}
  985. for (var n in t) t.hasOwnProperty(n) && (e[n] = t[n])
  986. return e
  987. })(this.opts.query)
  988. ;(e.EIO = 4), (e.transport = t), this.id && (e.sid = this.id)
  989. var n = o({}, this.opts.transportOptions[t], this.opts, { query: e, socket: this, hostname: this.hostname, secure: this.secure, port: this.port })
  990. return new ht[t](n)
  991. },
  992. },
  993. {
  994. key: 'open',
  995. value: function () {
  996. var t,
  997. e = this
  998. if (this.opts.rememberUpgrade && a.priorWebsocketSuccess && -1 !== this.transports.indexOf('websocket')) t = 'websocket'
  999. else {
  1000. if (0 === this.transports.length)
  1001. return void this.setTimeoutFn(function () {
  1002. e.emitReserved('error', 'No transports available')
  1003. }, 0)
  1004. t = this.transports[0]
  1005. }
  1006. this.readyState = 'opening'
  1007. try {
  1008. t = this.createTransport(t)
  1009. } catch (t) {
  1010. return this.transports.shift(), void this.open()
  1011. }
  1012. t.open(), this.setTransport(t)
  1013. },
  1014. },
  1015. {
  1016. key: 'setTransport',
  1017. value: function (t) {
  1018. var e = this
  1019. this.transport && this.transport.removeAllListeners(),
  1020. (this.transport = t),
  1021. t
  1022. .on('drain', this.onDrain.bind(this))
  1023. .on('packet', this.onPacket.bind(this))
  1024. .on('error', this.onError.bind(this))
  1025. .on('close', function () {
  1026. e.onClose('transport close')
  1027. })
  1028. },
  1029. },
  1030. {
  1031. key: 'probe',
  1032. value: function (t) {
  1033. var e = this,
  1034. n = this.createTransport(t),
  1035. r = !1
  1036. a.priorWebsocketSuccess = !1
  1037. var i = function () {
  1038. r ||
  1039. (n.send([{ type: 'ping', data: 'probe' }]),
  1040. n.once('packet', function (t) {
  1041. if (!r)
  1042. if ('pong' === t.type && 'probe' === t.data) {
  1043. if (((e.upgrading = !0), e.emitReserved('upgrading', n), !n)) return
  1044. ;(a.priorWebsocketSuccess = 'websocket' === n.name),
  1045. e.transport.pause(function () {
  1046. r ||
  1047. ('closed' !== e.readyState &&
  1048. (f(), e.setTransport(n), n.send([{ type: 'upgrade' }]), e.emitReserved('upgrade', n), (n = null), (e.upgrading = !1), e.flush()))
  1049. })
  1050. } else {
  1051. var i = new Error('probe error')
  1052. ;(i.transport = n.name), e.emitReserved('upgradeError', i)
  1053. }
  1054. }))
  1055. }
  1056. function o() {
  1057. r || ((r = !0), f(), n.close(), (n = null))
  1058. }
  1059. var s = function (t) {
  1060. var r = new Error('probe error: ' + t)
  1061. ;(r.transport = n.name), o(), e.emitReserved('upgradeError', r)
  1062. }
  1063. function c() {
  1064. s('transport closed')
  1065. }
  1066. function h() {
  1067. s('socket closed')
  1068. }
  1069. function u(t) {
  1070. n && t.name !== n.name && o()
  1071. }
  1072. var f = function () {
  1073. n.removeListener('open', i), n.removeListener('error', s), n.removeListener('close', c), e.off('close', h), e.off('upgrading', u)
  1074. }
  1075. n.once('open', i), n.once('error', s), n.once('close', c), this.once('close', h), this.once('upgrading', u), n.open()
  1076. },
  1077. },
  1078. {
  1079. key: 'onOpen',
  1080. value: function () {
  1081. if (
  1082. ((this.readyState = 'open'),
  1083. (a.priorWebsocketSuccess = 'websocket' === this.transport.name),
  1084. this.emitReserved('open'),
  1085. this.flush(),
  1086. 'open' === this.readyState && this.opts.upgrade && this.transport.pause)
  1087. )
  1088. for (var t = 0, e = this.upgrades.length; t < e; t++) this.probe(this.upgrades[t])
  1089. },
  1090. },
  1091. {
  1092. key: 'onPacket',
  1093. value: function (t) {
  1094. if ('opening' === this.readyState || 'open' === this.readyState || 'closing' === this.readyState)
  1095. switch ((this.emitReserved('packet', t), this.emitReserved('heartbeat'), t.type)) {
  1096. case 'open':
  1097. this.onHandshake(JSON.parse(t.data))
  1098. break
  1099. case 'ping':
  1100. this.resetPingTimeout(), this.sendPacket('pong'), this.emitReserved('ping'), this.emitReserved('pong')
  1101. break
  1102. case 'error':
  1103. var e = new Error('server error')
  1104. ;(e.code = t.data), this.onError(e)
  1105. break
  1106. case 'message':
  1107. this.emitReserved('data', t.data), this.emitReserved('message', t.data)
  1108. }
  1109. },
  1110. },
  1111. {
  1112. key: 'onHandshake',
  1113. value: function (t) {
  1114. this.emitReserved('handshake', t),
  1115. (this.id = t.sid),
  1116. (this.transport.query.sid = t.sid),
  1117. (this.upgrades = this.filterUpgrades(t.upgrades)),
  1118. (this.pingInterval = t.pingInterval),
  1119. (this.pingTimeout = t.pingTimeout),
  1120. this.onOpen(),
  1121. 'closed' !== this.readyState && this.resetPingTimeout()
  1122. },
  1123. },
  1124. {
  1125. key: 'resetPingTimeout',
  1126. value: function () {
  1127. var t = this
  1128. this.clearTimeoutFn(this.pingTimeoutTimer),
  1129. (this.pingTimeoutTimer = this.setTimeoutFn(function () {
  1130. t.onClose('ping timeout')
  1131. }, this.pingInterval + this.pingTimeout)),
  1132. this.opts.autoUnref && this.pingTimeoutTimer.unref()
  1133. },
  1134. },
  1135. {
  1136. key: 'onDrain',
  1137. value: function () {
  1138. this.writeBuffer.splice(0, this.prevBufferLen), (this.prevBufferLen = 0), 0 === this.writeBuffer.length ? this.emitReserved('drain') : this.flush()
  1139. },
  1140. },
  1141. {
  1142. key: 'flush',
  1143. value: function () {
  1144. 'closed' !== this.readyState &&
  1145. this.transport.writable &&
  1146. !this.upgrading &&
  1147. this.writeBuffer.length &&
  1148. (this.transport.send(this.writeBuffer), (this.prevBufferLen = this.writeBuffer.length), this.emitReserved('flush'))
  1149. },
  1150. },
  1151. {
  1152. key: 'write',
  1153. value: function (t, e, n) {
  1154. return this.sendPacket('message', t, e, n), this
  1155. },
  1156. },
  1157. {
  1158. key: 'send',
  1159. value: function (t, e, n) {
  1160. return this.sendPacket('message', t, e, n), this
  1161. },
  1162. },
  1163. {
  1164. key: 'sendPacket',
  1165. value: function (t, e, n, r) {
  1166. if (('function' == typeof e && ((r = e), (e = void 0)), 'function' == typeof n && ((r = n), (n = null)), 'closing' !== this.readyState && 'closed' !== this.readyState)) {
  1167. ;(n = n || {}).compress = !1 !== n.compress
  1168. var i = { type: t, data: e, options: n }
  1169. this.emitReserved('packetCreate', i), this.writeBuffer.push(i), r && this.once('flush', r), this.flush()
  1170. }
  1171. },
  1172. },
  1173. {
  1174. key: 'close',
  1175. value: function () {
  1176. var t = this,
  1177. e = function () {
  1178. t.onClose('forced close'), t.transport.close()
  1179. },
  1180. n = function n() {
  1181. t.off('upgrade', n), t.off('upgradeError', n), e()
  1182. },
  1183. r = function () {
  1184. t.once('upgrade', n), t.once('upgradeError', n)
  1185. }
  1186. return (
  1187. ('opening' !== this.readyState && 'open' !== this.readyState) ||
  1188. ((this.readyState = 'closing'),
  1189. this.writeBuffer.length
  1190. ? this.once('drain', function () {
  1191. t.upgrading ? r() : e()
  1192. })
  1193. : this.upgrading
  1194. ? r()
  1195. : e()),
  1196. this
  1197. )
  1198. },
  1199. },
  1200. {
  1201. key: 'onError',
  1202. value: function (t) {
  1203. ;(a.priorWebsocketSuccess = !1), this.emitReserved('error', t), this.onClose('transport error', t)
  1204. },
  1205. },
  1206. {
  1207. key: 'onClose',
  1208. value: function (t, e) {
  1209. ;('opening' !== this.readyState && 'open' !== this.readyState && 'closing' !== this.readyState) ||
  1210. (this.clearTimeoutFn(this.pingTimeoutTimer),
  1211. this.transport.removeAllListeners('close'),
  1212. this.transport.close(),
  1213. this.transport.removeAllListeners(),
  1214. 'function' == typeof removeEventListener && removeEventListener('offline', this.offlineEventListener, !1),
  1215. (this.readyState = 'closed'),
  1216. (this.id = null),
  1217. this.emitReserved('close', t, e),
  1218. (this.writeBuffer = []),
  1219. (this.prevBufferLen = 0))
  1220. },
  1221. },
  1222. {
  1223. key: 'filterUpgrades',
  1224. value: function (t) {
  1225. for (var e = [], n = 0, r = t.length; n < r; n++) ~this.transports.indexOf(t[n]) && e.push(t[n])
  1226. return e
  1227. },
  1228. },
  1229. ]),
  1230. a
  1231. )
  1232. })(T)
  1233. ut.protocol = 4
  1234. var ft = {},
  1235. pt = {}
  1236. function lt(t, e, n) {
  1237. for (var r = 0, i = 0, o = n.length; i < o; i++)
  1238. (r = n.charCodeAt(i)) < 128
  1239. ? t.setUint8(e++, r)
  1240. : r < 2048
  1241. ? (t.setUint8(e++, 192 | (r >> 6)), t.setUint8(e++, 128 | (63 & r)))
  1242. : r < 55296 || r >= 57344
  1243. ? (t.setUint8(e++, 224 | (r >> 12)), t.setUint8(e++, 128 | ((r >> 6) & 63)), t.setUint8(e++, 128 | (63 & r)))
  1244. : (i++,
  1245. (r = 65536 + (((1023 & r) << 10) | (1023 & n.charCodeAt(i)))),
  1246. t.setUint8(e++, 240 | (r >> 18)),
  1247. t.setUint8(e++, 128 | ((r >> 12) & 63)),
  1248. t.setUint8(e++, 128 | ((r >> 6) & 63)),
  1249. t.setUint8(e++, 128 | (63 & r)))
  1250. }
  1251. function dt(t, n, r) {
  1252. var i = e(r),
  1253. o = 0,
  1254. s = 0,
  1255. a = 0,
  1256. c = 0,
  1257. h = 0,
  1258. u = 0
  1259. if ('string' === i) {
  1260. if (
  1261. ((h = (function (t) {
  1262. for (var e = 0, n = 0, r = 0, i = t.length; r < i; r++) (e = t.charCodeAt(r)) < 128 ? (n += 1) : e < 2048 ? (n += 2) : e < 55296 || e >= 57344 ? (n += 3) : (r++, (n += 4))
  1263. return n
  1264. })(r)),
  1265. h < 32)
  1266. )
  1267. t.push(160 | h), (u = 1)
  1268. else if (h < 256) t.push(217, h), (u = 2)
  1269. else if (h < 65536) t.push(218, h >> 8, h), (u = 3)
  1270. else {
  1271. if (!(h < 4294967296)) throw new Error('String too long')
  1272. t.push(219, h >> 24, h >> 16, h >> 8, h), (u = 5)
  1273. }
  1274. return n.push({ _str: r, _length: h, _offset: t.length }), u + h
  1275. }
  1276. if ('number' === i)
  1277. return Math.floor(r) === r && isFinite(r)
  1278. ? r >= 0
  1279. ? r < 128
  1280. ? (t.push(r), 1)
  1281. : r < 256
  1282. ? (t.push(204, r), 2)
  1283. : r < 65536
  1284. ? (t.push(205, r >> 8, r), 3)
  1285. : r < 4294967296
  1286. ? (t.push(206, r >> 24, r >> 16, r >> 8, r), 5)
  1287. : ((a = (r / Math.pow(2, 32)) >> 0), (c = r >>> 0), t.push(207, a >> 24, a >> 16, a >> 8, a, c >> 24, c >> 16, c >> 8, c), 9)
  1288. : r >= -32
  1289. ? (t.push(r), 1)
  1290. : r >= -128
  1291. ? (t.push(208, r), 2)
  1292. : r >= -32768
  1293. ? (t.push(209, r >> 8, r), 3)
  1294. : r >= -2147483648
  1295. ? (t.push(210, r >> 24, r >> 16, r >> 8, r), 5)
  1296. : ((a = Math.floor(r / Math.pow(2, 32))), (c = r >>> 0), t.push(211, a >> 24, a >> 16, a >> 8, a, c >> 24, c >> 16, c >> 8, c), 9)
  1297. : (t.push(203), n.push({ _float: r, _length: 8, _offset: t.length }), 9)
  1298. if ('object' === i) {
  1299. if (null === r) return t.push(192), 1
  1300. if (Array.isArray(r)) {
  1301. if ((h = r.length) < 16) t.push(144 | h), (u = 1)
  1302. else if (h < 65536) t.push(220, h >> 8, h), (u = 3)
  1303. else {
  1304. if (!(h < 4294967296)) throw new Error('Array too large')
  1305. t.push(221, h >> 24, h >> 16, h >> 8, h), (u = 5)
  1306. }
  1307. for (o = 0; o < h; o++) u += dt(t, n, r[o])
  1308. return u
  1309. }
  1310. if (r instanceof Date) {
  1311. var f = r.getTime()
  1312. return (a = Math.floor(f / Math.pow(2, 32))), (c = f >>> 0), t.push(215, 0, a >> 24, a >> 16, a >> 8, a, c >> 24, c >> 16, c >> 8, c), 10
  1313. }
  1314. if (r instanceof ArrayBuffer) {
  1315. if ((h = r.byteLength) < 256) t.push(196, h), (u = 2)
  1316. else if (h < 65536) t.push(197, h >> 8, h), (u = 3)
  1317. else {
  1318. if (!(h < 4294967296)) throw new Error('Buffer too large')
  1319. t.push(198, h >> 24, h >> 16, h >> 8, h), (u = 5)
  1320. }
  1321. return n.push({ _bin: r, _length: h, _offset: t.length }), u + h
  1322. }
  1323. if ('function' == typeof r.toJSON) return dt(t, n, r.toJSON())
  1324. var p = [],
  1325. l = '',
  1326. d = Object.keys(r)
  1327. for (o = 0, s = d.length; o < s; o++) 'function' != typeof r[(l = d[o])] && p.push(l)
  1328. if ((h = p.length) < 16) t.push(128 | h), (u = 1)
  1329. else if (h < 65536) t.push(222, h >> 8, h), (u = 3)
  1330. else {
  1331. if (!(h < 4294967296)) throw new Error('Object too large')
  1332. t.push(223, h >> 24, h >> 16, h >> 8, h), (u = 5)
  1333. }
  1334. for (o = 0; o < h; o++) (u += dt(t, n, (l = p[o]))), (u += dt(t, n, r[l]))
  1335. return u
  1336. }
  1337. if ('boolean' === i) return t.push(r ? 195 : 194), 1
  1338. if ('undefined' === i) return t.push(212, 0, 0), 3
  1339. throw new Error('Could not encode')
  1340. }
  1341. var yt = function (t) {
  1342. var e = [],
  1343. n = [],
  1344. r = dt(e, n, t),
  1345. i = new ArrayBuffer(r),
  1346. o = new DataView(i),
  1347. s = 0,
  1348. a = 0,
  1349. c = -1
  1350. n.length > 0 && (c = n[0]._offset)
  1351. for (var h, u = 0, f = 0, p = 0, l = e.length; p < l; p++)
  1352. if ((o.setUint8(a + p, e[p]), p + 1 === c)) {
  1353. if (((u = (h = n[s])._length), (f = a + c), h._bin)) for (var d = new Uint8Array(h._bin), y = 0; y < u; y++) o.setUint8(f + y, d[y])
  1354. else h._str ? lt(o, f, h._str) : void 0 !== h._float && o.setFloat64(f, h._float)
  1355. ;(a += u), n[++s] && (c = n[s]._offset)
  1356. }
  1357. return i
  1358. }
  1359. function vt(t) {
  1360. if (((this._offset = 0), t instanceof ArrayBuffer)) (this._buffer = t), (this._view = new DataView(this._buffer))
  1361. else {
  1362. if (!ArrayBuffer.isView(t)) throw new Error('Invalid argument')
  1363. ;(this._buffer = t.buffer), (this._view = new DataView(this._buffer, t.byteOffset, t.byteLength))
  1364. }
  1365. }
  1366. ;(vt.prototype._array = function (t) {
  1367. for (var e = new Array(t), n = 0; n < t; n++) e[n] = this._parse()
  1368. return e
  1369. }),
  1370. (vt.prototype._map = function (t) {
  1371. for (var e = {}, n = 0; n < t; n++) e[this._parse()] = this._parse()
  1372. return e
  1373. }),
  1374. (vt.prototype._str = function (t) {
  1375. var e = (function (t, e, n) {
  1376. for (var r = '', i = 0, o = e, s = e + n; o < s; o++) {
  1377. var a = t.getUint8(o)
  1378. if (0 != (128 & a))
  1379. if (192 != (224 & a))
  1380. if (224 != (240 & a)) {
  1381. if (240 != (248 & a)) throw new Error('Invalid byte ' + a.toString(16))
  1382. ;(i = ((7 & a) << 18) | ((63 & t.getUint8(++o)) << 12) | ((63 & t.getUint8(++o)) << 6) | ((63 & t.getUint8(++o)) << 0)) >= 65536
  1383. ? ((i -= 65536), (r += String.fromCharCode(55296 + (i >>> 10), 56320 + (1023 & i))))
  1384. : (r += String.fromCharCode(i))
  1385. } else r += String.fromCharCode(((15 & a) << 12) | ((63 & t.getUint8(++o)) << 6) | ((63 & t.getUint8(++o)) << 0))
  1386. else r += String.fromCharCode(((31 & a) << 6) | (63 & t.getUint8(++o)))
  1387. else r += String.fromCharCode(a)
  1388. }
  1389. return r
  1390. })(this._view, this._offset, t)
  1391. return (this._offset += t), e
  1392. }),
  1393. (vt.prototype._bin = function (t) {
  1394. var e = this._buffer.slice(this._offset, this._offset + t)
  1395. return (this._offset += t), e
  1396. }),
  1397. (vt.prototype._parse = function () {
  1398. var t,
  1399. e = this._view.getUint8(this._offset++),
  1400. n = 0,
  1401. r = 0,
  1402. i = 0,
  1403. o = 0
  1404. if (e < 192) return e < 128 ? e : e < 144 ? this._map(15 & e) : e < 160 ? this._array(15 & e) : this._str(31 & e)
  1405. if (e > 223) return -1 * (255 - e + 1)
  1406. switch (e) {
  1407. case 192:
  1408. return null
  1409. case 194:
  1410. return !1
  1411. case 195:
  1412. return !0
  1413. case 196:
  1414. return (n = this._view.getUint8(this._offset)), (this._offset += 1), this._bin(n)
  1415. case 197:
  1416. return (n = this._view.getUint16(this._offset)), (this._offset += 2), this._bin(n)
  1417. case 198:
  1418. return (n = this._view.getUint32(this._offset)), (this._offset += 4), this._bin(n)
  1419. case 199:
  1420. return (n = this._view.getUint8(this._offset)), (r = this._view.getInt8(this._offset + 1)), (this._offset += 2), [r, this._bin(n)]
  1421. case 200:
  1422. return (n = this._view.getUint16(this._offset)), (r = this._view.getInt8(this._offset + 2)), (this._offset += 3), [r, this._bin(n)]
  1423. case 201:
  1424. return (n = this._view.getUint32(this._offset)), (r = this._view.getInt8(this._offset + 4)), (this._offset += 5), [r, this._bin(n)]
  1425. case 202:
  1426. return (t = this._view.getFloat32(this._offset)), (this._offset += 4), t
  1427. case 203:
  1428. return (t = this._view.getFloat64(this._offset)), (this._offset += 8), t
  1429. case 204:
  1430. return (t = this._view.getUint8(this._offset)), (this._offset += 1), t
  1431. case 205:
  1432. return (t = this._view.getUint16(this._offset)), (this._offset += 2), t
  1433. case 206:
  1434. return (t = this._view.getUint32(this._offset)), (this._offset += 4), t
  1435. case 207:
  1436. return (i = this._view.getUint32(this._offset) * Math.pow(2, 32)), (o = this._view.getUint32(this._offset + 4)), (this._offset += 8), i + o
  1437. case 208:
  1438. return (t = this._view.getInt8(this._offset)), (this._offset += 1), t
  1439. case 209:
  1440. return (t = this._view.getInt16(this._offset)), (this._offset += 2), t
  1441. case 210:
  1442. return (t = this._view.getInt32(this._offset)), (this._offset += 4), t
  1443. case 211:
  1444. return (i = this._view.getInt32(this._offset) * Math.pow(2, 32)), (o = this._view.getUint32(this._offset + 4)), (this._offset += 8), i + o
  1445. case 212:
  1446. return (r = this._view.getInt8(this._offset)), (this._offset += 1), 0 === r ? void (this._offset += 1) : [r, this._bin(1)]
  1447. case 213:
  1448. return (r = this._view.getInt8(this._offset)), (this._offset += 1), [r, this._bin(2)]
  1449. case 214:
  1450. return (r = this._view.getInt8(this._offset)), (this._offset += 1), [r, this._bin(4)]
  1451. case 215:
  1452. return (
  1453. (r = this._view.getInt8(this._offset)),
  1454. (this._offset += 1),
  1455. 0 === r ? ((i = this._view.getInt32(this._offset) * Math.pow(2, 32)), (o = this._view.getUint32(this._offset + 4)), (this._offset += 8), new Date(i + o)) : [r, this._bin(8)]
  1456. )
  1457. case 216:
  1458. return (r = this._view.getInt8(this._offset)), (this._offset += 1), [r, this._bin(16)]
  1459. case 217:
  1460. return (n = this._view.getUint8(this._offset)), (this._offset += 1), this._str(n)
  1461. case 218:
  1462. return (n = this._view.getUint16(this._offset)), (this._offset += 2), this._str(n)
  1463. case 219:
  1464. return (n = this._view.getUint32(this._offset)), (this._offset += 4), this._str(n)
  1465. case 220:
  1466. return (n = this._view.getUint16(this._offset)), (this._offset += 2), this._array(n)
  1467. case 221:
  1468. return (n = this._view.getUint32(this._offset)), (this._offset += 4), this._array(n)
  1469. case 222:
  1470. return (n = this._view.getUint16(this._offset)), (this._offset += 2), this._map(n)
  1471. case 223:
  1472. return (n = this._view.getUint32(this._offset)), (this._offset += 4), this._map(n)
  1473. }
  1474. throw new Error('Could not parse')
  1475. })
  1476. var gt = function (t) {
  1477. var e = new vt(t),
  1478. n = e._parse()
  1479. if (e._offset !== t.byteLength) throw new Error(t.byteLength - e._offset + ' trailing bytes')
  1480. return n
  1481. }
  1482. ;(pt.encode = yt), (pt.decode = gt)
  1483. var mt,
  1484. _t = { exports: {} }
  1485. !(function (t) {
  1486. function e(t) {
  1487. if (t)
  1488. return (function (t) {
  1489. for (var n in e.prototype) t[n] = e.prototype[n]
  1490. return t
  1491. })(t)
  1492. }
  1493. ;(t.exports = e),
  1494. (e.prototype.on = e.prototype.addEventListener =
  1495. function (t, e) {
  1496. return (this._callbacks = this._callbacks || {}), (this._callbacks['$' + t] = this._callbacks['$' + t] || []).push(e), this
  1497. }),
  1498. (e.prototype.once = function (t, e) {
  1499. function n() {
  1500. this.off(t, n), e.apply(this, arguments)
  1501. }
  1502. return (n.fn = e), this.on(t, n), this
  1503. }),
  1504. (e.prototype.off =
  1505. e.prototype.removeListener =
  1506. e.prototype.removeAllListeners =
  1507. e.prototype.removeEventListener =
  1508. function (t, e) {
  1509. if (((this._callbacks = this._callbacks || {}), 0 == arguments.length)) return (this._callbacks = {}), this
  1510. var n,
  1511. r = this._callbacks['$' + t]
  1512. if (!r) return this
  1513. if (1 == arguments.length) return delete this._callbacks['$' + t], this
  1514. for (var i = 0; i < r.length; i++)
  1515. if ((n = r[i]) === e || n.fn === e) {
  1516. r.splice(i, 1)
  1517. break
  1518. }
  1519. return 0 === r.length && delete this._callbacks['$' + t], this
  1520. }),
  1521. (e.prototype.emit = function (t) {
  1522. this._callbacks = this._callbacks || {}
  1523. for (var e = new Array(arguments.length - 1), n = this._callbacks['$' + t], r = 1; r < arguments.length; r++) e[r - 1] = arguments[r]
  1524. if (n) {
  1525. r = 0
  1526. for (var i = (n = n.slice(0)).length; r < i; ++r) n[r].apply(this, e)
  1527. }
  1528. return this
  1529. }),
  1530. (e.prototype.listeners = function (t) {
  1531. return (this._callbacks = this._callbacks || {}), this._callbacks['$' + t] || []
  1532. }),
  1533. (e.prototype.hasListeners = function (t) {
  1534. return !!this.listeners(t).length
  1535. })
  1536. })(_t)
  1537. var bt = pt,
  1538. kt = _t.exports,
  1539. wt = (ft.protocol = 5),
  1540. Et = (mt = ft.PacketType = { CONNECT: 0, DISCONNECT: 1, EVENT: 2, ACK: 3, CONNECT_ERROR: 4 }),
  1541. Ct =
  1542. Number.isInteger ||
  1543. function (t) {
  1544. return 'number' == typeof t && isFinite(t) && Math.floor(t) === t
  1545. },
  1546. Ot = function (t) {
  1547. return 'string' == typeof t
  1548. },
  1549. Tt = function (t) {
  1550. return '[object Object]' === Object.prototype.toString.call(t)
  1551. }
  1552. function St() {}
  1553. function Rt() {}
  1554. ;(St.prototype.encode = function (t) {
  1555. return [bt.encode(t)]
  1556. }),
  1557. kt(Rt.prototype),
  1558. (Rt.prototype.add = function (t) {
  1559. var e = bt.decode(t)
  1560. this.checkPacket(e), this.emit('decoded', e)
  1561. }),
  1562. (Rt.prototype.checkPacket = function (t) {
  1563. if (!(Ct(t.type) && t.type >= Et.CONNECT && t.type <= Et.CONNECT_ERROR)) throw new Error('invalid packet type')
  1564. if (!Ot(t.nsp)) throw new Error('invalid namespace')
  1565. if (
  1566. !(function (t) {
  1567. switch (t.type) {
  1568. case Et.CONNECT:
  1569. return void 0 === t.data || Tt(t.data)
  1570. case Et.DISCONNECT:
  1571. return void 0 === t.data
  1572. case Et.CONNECT_ERROR:
  1573. return Ot(t.data) || Tt(t.data)
  1574. default:
  1575. return Array.isArray(t.data)
  1576. }
  1577. })(t)
  1578. )
  1579. throw new Error('invalid payload')
  1580. if (!(void 0 === t.id || Ct(t.id))) throw new Error('invalid packet id')
  1581. }),
  1582. (Rt.prototype.destroy = function () {})
  1583. var At = (ft.Encoder = St),
  1584. xt = (ft.Decoder = Rt),
  1585. Ut = Object.freeze(
  1586. t(
  1587. {
  1588. __proto__: null,
  1589. default: ft,
  1590. protocol: wt,
  1591. get PacketType() {
  1592. return mt
  1593. },
  1594. Encoder: At,
  1595. Decoder: xt,
  1596. },
  1597. [ft]
  1598. )
  1599. )
  1600. function Lt(t, e, n) {
  1601. return (
  1602. t.on(e, n),
  1603. function () {
  1604. t.off(e, n)
  1605. }
  1606. )
  1607. }
  1608. var Bt = Object.freeze({ connect: 1, connect_error: 1, disconnect: 1, disconnecting: 1, newListener: 1, removeListener: 1 }),
  1609. jt = (function (t) {
  1610. s(r, t)
  1611. var e = f(r)
  1612. function r(t, i, o) {
  1613. var s
  1614. return (
  1615. n(this, r),
  1616. ((s = e.call(this)).connected = !1),
  1617. (s.disconnected = !0),
  1618. (s.receiveBuffer = []),
  1619. (s.sendBuffer = []),
  1620. (s.ids = 0),
  1621. (s.acks = {}),
  1622. (s.flags = {}),
  1623. (s.io = t),
  1624. (s.nsp = i),
  1625. o && o.auth && (s.auth = o.auth),
  1626. s.io._autoConnect && s.open(),
  1627. s
  1628. )
  1629. }
  1630. return (
  1631. i(r, [
  1632. {
  1633. key: 'subEvents',
  1634. value: function () {
  1635. if (!this.subs) {
  1636. var t = this.io
  1637. this.subs = [
  1638. Lt(t, 'open', this.onopen.bind(this)),
  1639. Lt(t, 'packet', this.onpacket.bind(this)),
  1640. Lt(t, 'error', this.onerror.bind(this)),
  1641. Lt(t, 'close', this.onclose.bind(this)),
  1642. ]
  1643. }
  1644. },
  1645. },
  1646. {
  1647. key: 'active',
  1648. get: function () {
  1649. return !!this.subs
  1650. },
  1651. },
  1652. {
  1653. key: 'connect',
  1654. value: function () {
  1655. return this.connected || (this.subEvents(), this.io._reconnecting || this.io.open(), 'open' === this.io._readyState && this.onopen()), this
  1656. },
  1657. },
  1658. {
  1659. key: 'open',
  1660. value: function () {
  1661. return this.connect()
  1662. },
  1663. },
  1664. {
  1665. key: 'send',
  1666. value: function () {
  1667. for (var t = arguments.length, e = new Array(t), n = 0; n < t; n++) e[n] = arguments[n]
  1668. return e.unshift('message'), this.emit.apply(this, e), this
  1669. },
  1670. },
  1671. {
  1672. key: 'emit',
  1673. value: function (t) {
  1674. if (Bt.hasOwnProperty(t)) throw new Error('"' + t + '" is a reserved event name')
  1675. for (var e = arguments.length, n = new Array(e > 1 ? e - 1 : 0), r = 1; r < e; r++) n[r - 1] = arguments[r]
  1676. n.unshift(t)
  1677. var i = { type: mt.EVENT, data: n, options: {} }
  1678. if (((i.options.compress = !1 !== this.flags.compress), 'function' == typeof n[n.length - 1])) {
  1679. var o = this.ids++,
  1680. s = n.pop()
  1681. this._registerAckCallback(o, s), (i.id = o)
  1682. }
  1683. var a = this.io.engine && this.io.engine.transport && this.io.engine.transport.writable,
  1684. c = this.flags.volatile && (!a || !this.connected)
  1685. return c || (this.connected ? this.packet(i) : this.sendBuffer.push(i)), (this.flags = {}), this
  1686. },
  1687. },
  1688. {
  1689. key: '_registerAckCallback',
  1690. value: function (t, e) {
  1691. var n = this,
  1692. r = this.flags.timeout
  1693. if (void 0 !== r) {
  1694. var i = this.io.setTimeoutFn(function () {
  1695. delete n.acks[t]
  1696. for (var r = 0; r < n.sendBuffer.length; r++) n.sendBuffer[r].id === t && n.sendBuffer.splice(r, 1)
  1697. e.call(n, new Error('operation has timed out'))
  1698. }, r)
  1699. this.acks[t] = function () {
  1700. n.io.clearTimeoutFn(i)
  1701. for (var t = arguments.length, r = new Array(t), o = 0; o < t; o++) r[o] = arguments[o]
  1702. e.apply(n, [null].concat(r))
  1703. }
  1704. } else this.acks[t] = e
  1705. },
  1706. },
  1707. {
  1708. key: 'packet',
  1709. value: function (t) {
  1710. ;(t.nsp = this.nsp), this.io._packet(t)
  1711. },
  1712. },
  1713. {
  1714. key: 'onopen',
  1715. value: function () {
  1716. var t = this
  1717. 'function' == typeof this.auth
  1718. ? this.auth(function (e) {
  1719. t.packet({ type: mt.CONNECT, data: e })
  1720. })
  1721. : this.packet({ type: mt.CONNECT, data: this.auth })
  1722. },
  1723. },
  1724. {
  1725. key: 'onerror',
  1726. value: function (t) {
  1727. this.connected || this.emitReserved('connect_error', t)
  1728. },
  1729. },
  1730. {
  1731. key: 'onclose',
  1732. value: function (t) {
  1733. ;(this.connected = !1), (this.disconnected = !0), delete this.id, this.emitReserved('disconnect', t)
  1734. },
  1735. },
  1736. {
  1737. key: 'onpacket',
  1738. value: function (t) {
  1739. if (t.nsp === this.nsp)
  1740. switch (t.type) {
  1741. case mt.CONNECT:
  1742. if (t.data && t.data.sid) {
  1743. var e = t.data.sid
  1744. this.onconnect(e)
  1745. } else
  1746. this.emitReserved(
  1747. 'connect_error',
  1748. new Error(
  1749. 'It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)'
  1750. )
  1751. )
  1752. break
  1753. case mt.EVENT:
  1754. case mt.BINARY_EVENT:
  1755. this.onevent(t)
  1756. break
  1757. case mt.ACK:
  1758. case mt.BINARY_ACK:
  1759. this.onack(t)
  1760. break
  1761. case mt.DISCONNECT:
  1762. this.ondisconnect()
  1763. break
  1764. case mt.CONNECT_ERROR:
  1765. this.destroy()
  1766. var n = new Error(t.data.message)
  1767. ;(n.data = t.data.data), this.emitReserved('connect_error', n)
  1768. }
  1769. },
  1770. },
  1771. {
  1772. key: 'onevent',
  1773. value: function (t) {
  1774. var e = t.data || []
  1775. null != t.id && e.push(this.ack(t.id)), this.connected ? this.emitEvent(e) : this.receiveBuffer.push(Object.freeze(e))
  1776. },
  1777. },
  1778. {
  1779. key: 'emitEvent',
  1780. value: function (t) {
  1781. if (this._anyListeners && this._anyListeners.length) {
  1782. var e,
  1783. n = d(this._anyListeners.slice())
  1784. try {
  1785. for (n.s(); !(e = n.n()).done; ) {
  1786. e.value.apply(this, t)
  1787. }
  1788. } catch (t) {
  1789. n.e(t)
  1790. } finally {
  1791. n.f()
  1792. }
  1793. }
  1794. p(a(r.prototype), 'emit', this).apply(this, t)
  1795. },
  1796. },
  1797. {
  1798. key: 'ack',
  1799. value: function (t) {
  1800. var e = this,
  1801. n = !1
  1802. return function () {
  1803. if (!n) {
  1804. n = !0
  1805. for (var r = arguments.length, i = new Array(r), o = 0; o < r; o++) i[o] = arguments[o]
  1806. e.packet({ type: mt.ACK, id: t, data: i })
  1807. }
  1808. }
  1809. },
  1810. },
  1811. {
  1812. key: 'onack',
  1813. value: function (t) {
  1814. var e = this.acks[t.id]
  1815. 'function' == typeof e && (e.apply(this, t.data), delete this.acks[t.id])
  1816. },
  1817. },
  1818. {
  1819. key: 'onconnect',
  1820. value: function (t) {
  1821. ;(this.id = t), (this.connected = !0), (this.disconnected = !1), this.emitBuffered(), this.emitReserved('connect')
  1822. },
  1823. },
  1824. {
  1825. key: 'emitBuffered',
  1826. value: function () {
  1827. var t = this
  1828. this.receiveBuffer.forEach(function (e) {
  1829. return t.emitEvent(e)
  1830. }),
  1831. (this.receiveBuffer = []),
  1832. this.sendBuffer.forEach(function (e) {
  1833. return t.packet(e)
  1834. }),
  1835. (this.sendBuffer = [])
  1836. },
  1837. },
  1838. {
  1839. key: 'ondisconnect',
  1840. value: function () {
  1841. this.destroy(), this.onclose('io server disconnect')
  1842. },
  1843. },
  1844. {
  1845. key: 'destroy',
  1846. value: function () {
  1847. this.subs &&
  1848. (this.subs.forEach(function (t) {
  1849. return t()
  1850. }),
  1851. (this.subs = void 0)),
  1852. this.io._destroy(this)
  1853. },
  1854. },
  1855. {
  1856. key: 'disconnect',
  1857. value: function () {
  1858. return this.connected && this.packet({ type: mt.DISCONNECT }), this.destroy(), this.connected && this.onclose('io client disconnect'), this
  1859. },
  1860. },
  1861. {
  1862. key: 'close',
  1863. value: function () {
  1864. return this.disconnect()
  1865. },
  1866. },
  1867. {
  1868. key: 'compress',
  1869. value: function (t) {
  1870. return (this.flags.compress = t), this
  1871. },
  1872. },
  1873. {
  1874. key: 'volatile',
  1875. get: function () {
  1876. return (this.flags.volatile = !0), this
  1877. },
  1878. },
  1879. {
  1880. key: 'timeout',
  1881. value: function (t) {
  1882. return (this.flags.timeout = t), this
  1883. },
  1884. },
  1885. {
  1886. key: 'onAny',
  1887. value: function (t) {
  1888. return (this._anyListeners = this._anyListeners || []), this._anyListeners.push(t), this
  1889. },
  1890. },
  1891. {
  1892. key: 'prependAny',
  1893. value: function (t) {
  1894. return (this._anyListeners = this._anyListeners || []), this._anyListeners.unshift(t), this
  1895. },
  1896. },
  1897. {
  1898. key: 'offAny',
  1899. value: function (t) {
  1900. if (!this._anyListeners) return this
  1901. if (t) {
  1902. for (var e = this._anyListeners, n = 0; n < e.length; n++) if (t === e[n]) return e.splice(n, 1), this
  1903. } else this._anyListeners = []
  1904. return this
  1905. },
  1906. },
  1907. {
  1908. key: 'listenersAny',
  1909. value: function () {
  1910. return this._anyListeners || []
  1911. },
  1912. },
  1913. ]),
  1914. r
  1915. )
  1916. })(T),
  1917. Nt = Pt
  1918. function Pt(t) {
  1919. ;(t = t || {}), (this.ms = t.min || 100), (this.max = t.max || 1e4), (this.factor = t.factor || 2), (this.jitter = t.jitter > 0 && t.jitter <= 1 ? t.jitter : 0), (this.attempts = 0)
  1920. }
  1921. ;(Pt.prototype.duration = function () {
  1922. var t = this.ms * Math.pow(this.factor, this.attempts++)
  1923. if (this.jitter) {
  1924. var e = Math.random(),
  1925. n = Math.floor(e * this.jitter * t)
  1926. t = 0 == (1 & Math.floor(10 * e)) ? t - n : t + n
  1927. }
  1928. return 0 | Math.min(t, this.max)
  1929. }),
  1930. (Pt.prototype.reset = function () {
  1931. this.attempts = 0
  1932. }),
  1933. (Pt.prototype.setMin = function (t) {
  1934. this.ms = t
  1935. }),
  1936. (Pt.prototype.setMax = function (t) {
  1937. this.max = t
  1938. }),
  1939. (Pt.prototype.setJitter = function (t) {
  1940. this.jitter = t
  1941. })
  1942. var qt = (function (t) {
  1943. s(o, t)
  1944. var r = f(o)
  1945. function o(t, i) {
  1946. var s, a
  1947. n(this, o),
  1948. ((s = r.call(this)).nsps = {}),
  1949. (s.subs = []),
  1950. t && 'object' === e(t) && ((i = t), (t = void 0)),
  1951. ((i = i || {}).path = i.path || '/socket.io'),
  1952. (s.opts = i),
  1953. O(h(s), i),
  1954. s.reconnection(!1 !== i.reconnection),
  1955. s.reconnectionAttempts(i.reconnectionAttempts || 1 / 0),
  1956. s.reconnectionDelay(i.reconnectionDelay || 1e3),
  1957. s.reconnectionDelayMax(i.reconnectionDelayMax || 5e3),
  1958. s.randomizationFactor(null !== (a = i.randomizationFactor) && void 0 !== a ? a : 0.5),
  1959. (s.backoff = new Nt({ min: s.reconnectionDelay(), max: s.reconnectionDelayMax(), jitter: s.randomizationFactor() })),
  1960. s.timeout(null == i.timeout ? 2e4 : i.timeout),
  1961. (s._readyState = 'closed'),
  1962. (s.uri = t)
  1963. var c = i.parser || Ut
  1964. return (s.encoder = new c.Encoder()), (s.decoder = new c.Decoder()), (s._autoConnect = !1 !== i.autoConnect), s._autoConnect && s.open(), s
  1965. }
  1966. return (
  1967. i(o, [
  1968. {
  1969. key: 'reconnection',
  1970. value: function (t) {
  1971. return arguments.length ? ((this._reconnection = !!t), this) : this._reconnection
  1972. },
  1973. },
  1974. {
  1975. key: 'reconnectionAttempts',
  1976. value: function (t) {
  1977. return void 0 === t ? this._reconnectionAttempts : ((this._reconnectionAttempts = t), this)
  1978. },
  1979. },
  1980. {
  1981. key: 'reconnectionDelay',
  1982. value: function (t) {
  1983. var e
  1984. return void 0 === t ? this._reconnectionDelay : ((this._reconnectionDelay = t), null === (e = this.backoff) || void 0 === e || e.setMin(t), this)
  1985. },
  1986. },
  1987. {
  1988. key: 'randomizationFactor',
  1989. value: function (t) {
  1990. var e
  1991. return void 0 === t ? this._randomizationFactor : ((this._randomizationFactor = t), null === (e = this.backoff) || void 0 === e || e.setJitter(t), this)
  1992. },
  1993. },
  1994. {
  1995. key: 'reconnectionDelayMax',
  1996. value: function (t) {
  1997. var e
  1998. return void 0 === t ? this._reconnectionDelayMax : ((this._reconnectionDelayMax = t), null === (e = this.backoff) || void 0 === e || e.setMax(t), this)
  1999. },
  2000. },
  2001. {
  2002. key: 'timeout',
  2003. value: function (t) {
  2004. return arguments.length ? ((this._timeout = t), this) : this._timeout
  2005. },
  2006. },
  2007. {
  2008. key: 'maybeReconnectOnOpen',
  2009. value: function () {
  2010. !this._reconnecting && this._reconnection && 0 === this.backoff.attempts && this.reconnect()
  2011. },
  2012. },
  2013. {
  2014. key: 'open',
  2015. value: function (t) {
  2016. var e = this
  2017. if (~this._readyState.indexOf('open')) return this
  2018. this.engine = new ut(this.uri, this.opts)
  2019. var n = this.engine,
  2020. r = this
  2021. ;(this._readyState = 'opening'), (this.skipReconnect = !1)
  2022. var i = Lt(n, 'open', function () {
  2023. r.onopen(), t && t()
  2024. }),
  2025. o = Lt(n, 'error', function (n) {
  2026. r.cleanup(), (r._readyState = 'closed'), e.emitReserved('error', n), t ? t(n) : r.maybeReconnectOnOpen()
  2027. })
  2028. if (!1 !== this._timeout) {
  2029. var s = this._timeout
  2030. 0 === s && i()
  2031. var a = this.setTimeoutFn(function () {
  2032. i(), n.close(), n.emit('error', new Error('timeout'))
  2033. }, s)
  2034. this.opts.autoUnref && a.unref(),
  2035. this.subs.push(function () {
  2036. clearTimeout(a)
  2037. })
  2038. }
  2039. return this.subs.push(i), this.subs.push(o), this
  2040. },
  2041. },
  2042. {
  2043. key: 'connect',
  2044. value: function (t) {
  2045. return this.open(t)
  2046. },
  2047. },
  2048. {
  2049. key: 'onopen',
  2050. value: function () {
  2051. this.cleanup(), (this._readyState = 'open'), this.emitReserved('open')
  2052. var t = this.engine
  2053. this.subs.push(
  2054. Lt(t, 'ping', this.onping.bind(this)),
  2055. Lt(t, 'data', this.ondata.bind(this)),
  2056. Lt(t, 'error', this.onerror.bind(this)),
  2057. Lt(t, 'close', this.onclose.bind(this)),
  2058. Lt(this.decoder, 'decoded', this.ondecoded.bind(this))
  2059. )
  2060. },
  2061. },
  2062. {
  2063. key: 'onping',
  2064. value: function () {
  2065. this.emitReserved('ping')
  2066. },
  2067. },
  2068. {
  2069. key: 'ondata',
  2070. value: function (t) {
  2071. this.decoder.add(t)
  2072. },
  2073. },
  2074. {
  2075. key: 'ondecoded',
  2076. value: function (t) {
  2077. this.emitReserved('packet', t)
  2078. },
  2079. },
  2080. {
  2081. key: 'onerror',
  2082. value: function (t) {
  2083. this.emitReserved('error', t)
  2084. },
  2085. },
  2086. {
  2087. key: 'socket',
  2088. value: function (t, e) {
  2089. var n = this.nsps[t]
  2090. return n || ((n = new jt(this, t, e)), (this.nsps[t] = n)), n
  2091. },
  2092. },
  2093. {
  2094. key: '_destroy',
  2095. value: function (t) {
  2096. for (var e = 0, n = Object.keys(this.nsps); e < n.length; e++) {
  2097. var r = n[e]
  2098. if (this.nsps[r].active) return
  2099. }
  2100. this._close()
  2101. },
  2102. },
  2103. {
  2104. key: '_packet',
  2105. value: function (t) {
  2106. for (var e = this.encoder.encode(t), n = 0; n < e.length; n++) this.engine.write(e[n], t.options)
  2107. },
  2108. },
  2109. {
  2110. key: 'cleanup',
  2111. value: function () {
  2112. this.subs.forEach(function (t) {
  2113. return t()
  2114. }),
  2115. (this.subs.length = 0),
  2116. this.decoder.destroy()
  2117. },
  2118. },
  2119. {
  2120. key: '_close',
  2121. value: function () {
  2122. ;(this.skipReconnect = !0), (this._reconnecting = !1), this.onclose('forced close'), this.engine && this.engine.close()
  2123. },
  2124. },
  2125. {
  2126. key: 'disconnect',
  2127. value: function () {
  2128. return this._close()
  2129. },
  2130. },
  2131. {
  2132. key: 'onclose',
  2133. value: function (t) {
  2134. this.cleanup(), this.backoff.reset(), (this._readyState = 'closed'), this.emitReserved('close', t), this._reconnection && !this.skipReconnect && this.reconnect()
  2135. },
  2136. },
  2137. {
  2138. key: 'reconnect',
  2139. value: function () {
  2140. var t = this
  2141. if (this._reconnecting || this.skipReconnect) return this
  2142. var e = this
  2143. if (this.backoff.attempts >= this._reconnectionAttempts) this.backoff.reset(), this.emitReserved('reconnect_failed'), (this._reconnecting = !1)
  2144. else {
  2145. var n = this.backoff.duration()
  2146. this._reconnecting = !0
  2147. var r = this.setTimeoutFn(function () {
  2148. e.skipReconnect ||
  2149. (t.emitReserved('reconnect_attempt', e.backoff.attempts),
  2150. e.skipReconnect ||
  2151. e.open(function (n) {
  2152. n ? ((e._reconnecting = !1), e.reconnect(), t.emitReserved('reconnect_error', n)) : e.onreconnect()
  2153. }))
  2154. }, n)
  2155. this.opts.autoUnref && r.unref(),
  2156. this.subs.push(function () {
  2157. clearTimeout(r)
  2158. })
  2159. }
  2160. },
  2161. },
  2162. {
  2163. key: 'onreconnect',
  2164. value: function () {
  2165. var t = this.backoff.attempts
  2166. ;(this._reconnecting = !1), this.backoff.reset(), this.emitReserved('reconnect', t)
  2167. },
  2168. },
  2169. ]),
  2170. o
  2171. )
  2172. })(T),
  2173. Dt = {}
  2174. function It(t, n) {
  2175. 'object' === e(t) && ((n = t), (t = void 0))
  2176. var r,
  2177. i = (function (t) {
  2178. var e = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : '',
  2179. n = arguments.length > 2 ? arguments[2] : void 0,
  2180. r = t
  2181. ;(n = n || ('undefined' != typeof location && location)),
  2182. null == t && (t = n.protocol + '//' + n.host),
  2183. 'string' == typeof t &&
  2184. ('/' === t.charAt(0) && (t = '/' === t.charAt(1) ? n.protocol + t : n.host + t),
  2185. /^(https?|wss?):\/\//.test(t) || (t = void 0 !== n ? n.protocol + '//' + t : 'https://' + t),
  2186. (r = g(t))),
  2187. r.port || (/^(http|ws)$/.test(r.protocol) ? (r.port = '80') : /^(http|ws)s$/.test(r.protocol) && (r.port = '443')),
  2188. (r.path = r.path || '/')
  2189. var i = -1 !== r.host.indexOf(':') ? '[' + r.host + ']' : r.host
  2190. return (r.id = r.protocol + '://' + i + ':' + r.port + e), (r.href = r.protocol + '://' + i + (n && n.port === r.port ? '' : ':' + r.port)), r
  2191. })(t, (n = n || {}).path || '/socket.io'),
  2192. o = i.source,
  2193. s = i.id,
  2194. a = i.path,
  2195. c = Dt[s] && a in Dt[s].nsps
  2196. return (
  2197. n.forceNew || n['force new connection'] || !1 === n.multiplex || c ? (r = new qt(o, n)) : (Dt[s] || (Dt[s] = new qt(o, n)), (r = Dt[s])),
  2198. i.query && !n.query && (n.query = i.queryKey),
  2199. r.socket(i.path, n)
  2200. )
  2201. }
  2202. return o(It, { Manager: qt, Socket: jt, io: It, connect: It }), It
  2203. })
  2204. //# sourceMappingURL=socket.io.msgpack.min.js.map