uniapp,h5

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607
  1. var __defProp = Object.defineProperty;
  2. var __export = (target, all) => {
  3. for (var name in all)
  4. __defProp(target, name, { get: all[name], enumerable: true });
  5. };
  6. // ../../../../Newweb/starter/node_modules/engine.io-parser/build/esm/commons.js
  7. var PACKET_TYPES = /* @__PURE__ */ Object.create(null);
  8. PACKET_TYPES["open"] = "0";
  9. PACKET_TYPES["close"] = "1";
  10. PACKET_TYPES["ping"] = "2";
  11. PACKET_TYPES["pong"] = "3";
  12. PACKET_TYPES["message"] = "4";
  13. PACKET_TYPES["upgrade"] = "5";
  14. PACKET_TYPES["noop"] = "6";
  15. var PACKET_TYPES_REVERSE = /* @__PURE__ */ Object.create(null);
  16. Object.keys(PACKET_TYPES).forEach((key) => {
  17. PACKET_TYPES_REVERSE[PACKET_TYPES[key]] = key;
  18. });
  19. var ERROR_PACKET = { type: "error", data: "parser error" };
  20. // ../../../../Newweb/starter/node_modules/engine.io-parser/build/esm/encodePacket.browser.js
  21. var withNativeBlob = typeof Blob === "function" || typeof Blob !== "undefined" && Object.prototype.toString.call(Blob) === "[object BlobConstructor]";
  22. var withNativeArrayBuffer = typeof ArrayBuffer === "function";
  23. var isView = (obj) => {
  24. return typeof ArrayBuffer.isView === "function" ? ArrayBuffer.isView(obj) : obj && obj.buffer instanceof ArrayBuffer;
  25. };
  26. var encodePacket = ({ type, data }, supportsBinary, callback) => {
  27. if (withNativeBlob && data instanceof Blob) {
  28. if (supportsBinary) {
  29. return callback(data);
  30. } else {
  31. return encodeBlobAsBase64(data, callback);
  32. }
  33. } else if (withNativeArrayBuffer && (data instanceof ArrayBuffer || isView(data))) {
  34. if (supportsBinary) {
  35. return callback(data);
  36. } else {
  37. return encodeBlobAsBase64(new Blob([data]), callback);
  38. }
  39. }
  40. return callback(PACKET_TYPES[type] + (data || ""));
  41. };
  42. var encodeBlobAsBase64 = (data, callback) => {
  43. const fileReader = new FileReader();
  44. fileReader.onload = function() {
  45. const content = fileReader.result.split(",")[1];
  46. callback("b" + (content || ""));
  47. };
  48. return fileReader.readAsDataURL(data);
  49. };
  50. function toArray(data) {
  51. if (data instanceof Uint8Array) {
  52. return data;
  53. } else if (data instanceof ArrayBuffer) {
  54. return new Uint8Array(data);
  55. } else {
  56. return new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
  57. }
  58. }
  59. var TEXT_ENCODER;
  60. function encodePacketToBinary(packet, callback) {
  61. if (withNativeBlob && packet.data instanceof Blob) {
  62. return packet.data.arrayBuffer().then(toArray).then(callback);
  63. } else if (withNativeArrayBuffer && (packet.data instanceof ArrayBuffer || isView(packet.data))) {
  64. return callback(toArray(packet.data));
  65. }
  66. encodePacket(packet, false, (encoded) => {
  67. if (!TEXT_ENCODER) {
  68. TEXT_ENCODER = new TextEncoder();
  69. }
  70. callback(TEXT_ENCODER.encode(encoded));
  71. });
  72. }
  73. // ../../../../Newweb/starter/node_modules/engine.io-parser/build/esm/contrib/base64-arraybuffer.js
  74. var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  75. var lookup = typeof Uint8Array === "undefined" ? [] : new Uint8Array(256);
  76. for (let i = 0; i < chars.length; i++) {
  77. lookup[chars.charCodeAt(i)] = i;
  78. }
  79. var decode = (base64) => {
  80. let bufferLength = base64.length * 0.75, len = base64.length, i, p = 0, encoded1, encoded2, encoded3, encoded4;
  81. if (base64[base64.length - 1] === "=") {
  82. bufferLength--;
  83. if (base64[base64.length - 2] === "=") {
  84. bufferLength--;
  85. }
  86. }
  87. const arraybuffer = new ArrayBuffer(bufferLength), bytes = new Uint8Array(arraybuffer);
  88. for (i = 0; i < len; i += 4) {
  89. encoded1 = lookup[base64.charCodeAt(i)];
  90. encoded2 = lookup[base64.charCodeAt(i + 1)];
  91. encoded3 = lookup[base64.charCodeAt(i + 2)];
  92. encoded4 = lookup[base64.charCodeAt(i + 3)];
  93. bytes[p++] = encoded1 << 2 | encoded2 >> 4;
  94. bytes[p++] = (encoded2 & 15) << 4 | encoded3 >> 2;
  95. bytes[p++] = (encoded3 & 3) << 6 | encoded4 & 63;
  96. }
  97. return arraybuffer;
  98. };
  99. // ../../../../Newweb/starter/node_modules/engine.io-parser/build/esm/decodePacket.browser.js
  100. var withNativeArrayBuffer2 = typeof ArrayBuffer === "function";
  101. var decodePacket = (encodedPacket, binaryType) => {
  102. if (typeof encodedPacket !== "string") {
  103. return {
  104. type: "message",
  105. data: mapBinary(encodedPacket, binaryType)
  106. };
  107. }
  108. const type = encodedPacket.charAt(0);
  109. if (type === "b") {
  110. return {
  111. type: "message",
  112. data: decodeBase64Packet(encodedPacket.substring(1), binaryType)
  113. };
  114. }
  115. const packetType = PACKET_TYPES_REVERSE[type];
  116. if (!packetType) {
  117. return ERROR_PACKET;
  118. }
  119. return encodedPacket.length > 1 ? {
  120. type: PACKET_TYPES_REVERSE[type],
  121. data: encodedPacket.substring(1)
  122. } : {
  123. type: PACKET_TYPES_REVERSE[type]
  124. };
  125. };
  126. var decodeBase64Packet = (data, binaryType) => {
  127. if (withNativeArrayBuffer2) {
  128. const decoded = decode(data);
  129. return mapBinary(decoded, binaryType);
  130. } else {
  131. return { base64: true, data };
  132. }
  133. };
  134. var mapBinary = (data, binaryType) => {
  135. switch (binaryType) {
  136. case "blob":
  137. if (data instanceof Blob) {
  138. return data;
  139. } else {
  140. return new Blob([data]);
  141. }
  142. case "arraybuffer":
  143. default:
  144. if (data instanceof ArrayBuffer) {
  145. return data;
  146. } else {
  147. return data.buffer;
  148. }
  149. }
  150. };
  151. // ../../../../Newweb/starter/node_modules/engine.io-parser/build/esm/index.js
  152. var SEPARATOR = String.fromCharCode(30);
  153. var encodePayload = (packets, callback) => {
  154. const length = packets.length;
  155. const encodedPackets = new Array(length);
  156. let count = 0;
  157. packets.forEach((packet, i) => {
  158. encodePacket(packet, false, (encodedPacket) => {
  159. encodedPackets[i] = encodedPacket;
  160. if (++count === length) {
  161. callback(encodedPackets.join(SEPARATOR));
  162. }
  163. });
  164. });
  165. };
  166. var decodePayload = (encodedPayload, binaryType) => {
  167. const encodedPackets = encodedPayload.split(SEPARATOR);
  168. const packets = [];
  169. for (let i = 0; i < encodedPackets.length; i++) {
  170. const decodedPacket = decodePacket(encodedPackets[i], binaryType);
  171. packets.push(decodedPacket);
  172. if (decodedPacket.type === "error") {
  173. break;
  174. }
  175. }
  176. return packets;
  177. };
  178. function createPacketEncoderStream() {
  179. return new TransformStream({
  180. transform(packet, controller) {
  181. encodePacketToBinary(packet, (encodedPacket) => {
  182. const payloadLength = encodedPacket.length;
  183. let header;
  184. if (payloadLength < 126) {
  185. header = new Uint8Array(1);
  186. new DataView(header.buffer).setUint8(0, payloadLength);
  187. } else if (payloadLength < 65536) {
  188. header = new Uint8Array(3);
  189. const view = new DataView(header.buffer);
  190. view.setUint8(0, 126);
  191. view.setUint16(1, payloadLength);
  192. } else {
  193. header = new Uint8Array(9);
  194. const view = new DataView(header.buffer);
  195. view.setUint8(0, 127);
  196. view.setBigUint64(1, BigInt(payloadLength));
  197. }
  198. if (packet.data && typeof packet.data !== "string") {
  199. header[0] |= 128;
  200. }
  201. controller.enqueue(header);
  202. controller.enqueue(encodedPacket);
  203. });
  204. }
  205. });
  206. }
  207. var TEXT_DECODER;
  208. function totalLength(chunks) {
  209. return chunks.reduce((acc, chunk) => acc + chunk.length, 0);
  210. }
  211. function concatChunks(chunks, size) {
  212. if (chunks[0].length === size) {
  213. return chunks.shift();
  214. }
  215. const buffer = new Uint8Array(size);
  216. let j = 0;
  217. for (let i = 0; i < size; i++) {
  218. buffer[i] = chunks[0][j++];
  219. if (j === chunks[0].length) {
  220. chunks.shift();
  221. j = 0;
  222. }
  223. }
  224. if (chunks.length && j < chunks[0].length) {
  225. chunks[0] = chunks[0].slice(j);
  226. }
  227. return buffer;
  228. }
  229. function createPacketDecoderStream(maxPayload, binaryType) {
  230. if (!TEXT_DECODER) {
  231. TEXT_DECODER = new TextDecoder();
  232. }
  233. const chunks = [];
  234. let state = 0;
  235. let expectedLength = -1;
  236. let isBinary2 = false;
  237. return new TransformStream({
  238. transform(chunk, controller) {
  239. chunks.push(chunk);
  240. while (true) {
  241. if (state === 0) {
  242. if (totalLength(chunks) < 1) {
  243. break;
  244. }
  245. const header = concatChunks(chunks, 1);
  246. isBinary2 = (header[0] & 128) === 128;
  247. expectedLength = header[0] & 127;
  248. if (expectedLength < 126) {
  249. state = 3;
  250. } else if (expectedLength === 126) {
  251. state = 1;
  252. } else {
  253. state = 2;
  254. }
  255. } else if (state === 1) {
  256. if (totalLength(chunks) < 2) {
  257. break;
  258. }
  259. const headerArray = concatChunks(chunks, 2);
  260. expectedLength = new DataView(headerArray.buffer, headerArray.byteOffset, headerArray.length).getUint16(0);
  261. state = 3;
  262. } else if (state === 2) {
  263. if (totalLength(chunks) < 8) {
  264. break;
  265. }
  266. const headerArray = concatChunks(chunks, 8);
  267. const view = new DataView(headerArray.buffer, headerArray.byteOffset, headerArray.length);
  268. const n = view.getUint32(0);
  269. if (n > Math.pow(2, 53 - 32) - 1) {
  270. controller.enqueue(ERROR_PACKET);
  271. break;
  272. }
  273. expectedLength = n * Math.pow(2, 32) + view.getUint32(4);
  274. state = 3;
  275. } else {
  276. if (totalLength(chunks) < expectedLength) {
  277. break;
  278. }
  279. const data = concatChunks(chunks, expectedLength);
  280. controller.enqueue(decodePacket(isBinary2 ? data : TEXT_DECODER.decode(data), binaryType));
  281. state = 0;
  282. }
  283. if (expectedLength === 0 || expectedLength > maxPayload) {
  284. controller.enqueue(ERROR_PACKET);
  285. break;
  286. }
  287. }
  288. }
  289. });
  290. }
  291. var protocol = 4;
  292. // ../../../../Newweb/starter/node_modules/@socket.io/component-emitter/lib/esm/index.js
  293. function Emitter(obj) {
  294. if (obj)
  295. return mixin(obj);
  296. }
  297. function mixin(obj) {
  298. for (var key in Emitter.prototype) {
  299. obj[key] = Emitter.prototype[key];
  300. }
  301. return obj;
  302. }
  303. Emitter.prototype.on = Emitter.prototype.addEventListener = function(event, fn) {
  304. this._callbacks = this._callbacks || {};
  305. (this._callbacks["$" + event] = this._callbacks["$" + event] || []).push(fn);
  306. return this;
  307. };
  308. Emitter.prototype.once = function(event, fn) {
  309. function on2() {
  310. this.off(event, on2);
  311. fn.apply(this, arguments);
  312. }
  313. on2.fn = fn;
  314. this.on(event, on2);
  315. return this;
  316. };
  317. Emitter.prototype.off = Emitter.prototype.removeListener = Emitter.prototype.removeAllListeners = Emitter.prototype.removeEventListener = function(event, fn) {
  318. this._callbacks = this._callbacks || {};
  319. if (arguments.length == 0) {
  320. this._callbacks = {};
  321. return this;
  322. }
  323. var callbacks = this._callbacks["$" + event];
  324. if (!callbacks)
  325. return this;
  326. if (arguments.length == 1) {
  327. delete this._callbacks["$" + event];
  328. return this;
  329. }
  330. var cb;
  331. for (var i = 0; i < callbacks.length; i++) {
  332. cb = callbacks[i];
  333. if (cb === fn || cb.fn === fn) {
  334. callbacks.splice(i, 1);
  335. break;
  336. }
  337. }
  338. if (callbacks.length === 0) {
  339. delete this._callbacks["$" + event];
  340. }
  341. return this;
  342. };
  343. Emitter.prototype.emit = function(event) {
  344. this._callbacks = this._callbacks || {};
  345. var args = new Array(arguments.length - 1), callbacks = this._callbacks["$" + event];
  346. for (var i = 1; i < arguments.length; i++) {
  347. args[i - 1] = arguments[i];
  348. }
  349. if (callbacks) {
  350. callbacks = callbacks.slice(0);
  351. for (var i = 0, len = callbacks.length; i < len; ++i) {
  352. callbacks[i].apply(this, args);
  353. }
  354. }
  355. return this;
  356. };
  357. Emitter.prototype.emitReserved = Emitter.prototype.emit;
  358. Emitter.prototype.listeners = function(event) {
  359. this._callbacks = this._callbacks || {};
  360. return this._callbacks["$" + event] || [];
  361. };
  362. Emitter.prototype.hasListeners = function(event) {
  363. return !!this.listeners(event).length;
  364. };
  365. // ../../../../Newweb/starter/node_modules/engine.io-client/build/esm/globals.js
  366. var nextTick = (() => {
  367. const isPromiseAvailable = typeof Promise === "function" && typeof Promise.resolve === "function";
  368. if (isPromiseAvailable) {
  369. return (cb) => Promise.resolve().then(cb);
  370. } else {
  371. return (cb, setTimeoutFn) => setTimeoutFn(cb, 0);
  372. }
  373. })();
  374. var globalThisShim = (() => {
  375. if (typeof self !== "undefined") {
  376. return self;
  377. } else if (typeof window !== "undefined") {
  378. return window;
  379. } else {
  380. return Function("return this")();
  381. }
  382. })();
  383. var defaultBinaryType = "arraybuffer";
  384. function createCookieJar() {
  385. }
  386. // ../../../../Newweb/starter/node_modules/engine.io-client/build/esm/util.js
  387. function pick(obj, ...attr) {
  388. return attr.reduce((acc, k) => {
  389. if (obj.hasOwnProperty(k)) {
  390. acc[k] = obj[k];
  391. }
  392. return acc;
  393. }, {});
  394. }
  395. var NATIVE_SET_TIMEOUT = globalThisShim.setTimeout;
  396. var NATIVE_CLEAR_TIMEOUT = globalThisShim.clearTimeout;
  397. function installTimerFunctions(obj, opts) {
  398. if (opts.useNativeTimers) {
  399. obj.setTimeoutFn = NATIVE_SET_TIMEOUT.bind(globalThisShim);
  400. obj.clearTimeoutFn = NATIVE_CLEAR_TIMEOUT.bind(globalThisShim);
  401. } else {
  402. obj.setTimeoutFn = globalThisShim.setTimeout.bind(globalThisShim);
  403. obj.clearTimeoutFn = globalThisShim.clearTimeout.bind(globalThisShim);
  404. }
  405. }
  406. var BASE64_OVERHEAD = 1.33;
  407. function byteLength(obj) {
  408. if (typeof obj === "string") {
  409. return utf8Length(obj);
  410. }
  411. return Math.ceil((obj.byteLength || obj.size) * BASE64_OVERHEAD);
  412. }
  413. function utf8Length(str) {
  414. let c = 0, length = 0;
  415. for (let i = 0, l = str.length; i < l; i++) {
  416. c = str.charCodeAt(i);
  417. if (c < 128) {
  418. length += 1;
  419. } else if (c < 2048) {
  420. length += 2;
  421. } else if (c < 55296 || c >= 57344) {
  422. length += 3;
  423. } else {
  424. i++;
  425. length += 4;
  426. }
  427. }
  428. return length;
  429. }
  430. function randomString() {
  431. return Date.now().toString(36).substring(3) + Math.random().toString(36).substring(2, 5);
  432. }
  433. // ../../../../Newweb/starter/node_modules/engine.io-client/build/esm/contrib/parseqs.js
  434. function encode(obj) {
  435. let str = "";
  436. for (let i in obj) {
  437. if (obj.hasOwnProperty(i)) {
  438. if (str.length)
  439. str += "&";
  440. str += encodeURIComponent(i) + "=" + encodeURIComponent(obj[i]);
  441. }
  442. }
  443. return str;
  444. }
  445. function decode2(qs) {
  446. let qry = {};
  447. let pairs = qs.split("&");
  448. for (let i = 0, l = pairs.length; i < l; i++) {
  449. let pair = pairs[i].split("=");
  450. qry[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]);
  451. }
  452. return qry;
  453. }
  454. // ../../../../Newweb/starter/node_modules/engine.io-client/build/esm/transport.js
  455. var TransportError = class extends Error {
  456. constructor(reason, description, context) {
  457. super(reason);
  458. this.description = description;
  459. this.context = context;
  460. this.type = "TransportError";
  461. }
  462. };
  463. var Transport = class extends Emitter {
  464. constructor(opts) {
  465. super();
  466. this.writable = false;
  467. installTimerFunctions(this, opts);
  468. this.opts = opts;
  469. this.query = opts.query;
  470. this.socket = opts.socket;
  471. this.supportsBinary = !opts.forceBase64;
  472. }
  473. onError(reason, description, context) {
  474. super.emitReserved("error", new TransportError(reason, description, context));
  475. return this;
  476. }
  477. open() {
  478. this.readyState = "opening";
  479. this.doOpen();
  480. return this;
  481. }
  482. close() {
  483. if (this.readyState === "opening" || this.readyState === "open") {
  484. this.doClose();
  485. this.onClose();
  486. }
  487. return this;
  488. }
  489. send(packets) {
  490. if (this.readyState === "open") {
  491. this.write(packets);
  492. } else {
  493. }
  494. }
  495. onOpen() {
  496. this.readyState = "open";
  497. this.writable = true;
  498. super.emitReserved("open");
  499. }
  500. onData(data) {
  501. const packet = decodePacket(data, this.socket.binaryType);
  502. this.onPacket(packet);
  503. }
  504. onPacket(packet) {
  505. super.emitReserved("packet", packet);
  506. }
  507. onClose(details) {
  508. this.readyState = "closed";
  509. super.emitReserved("close", details);
  510. }
  511. pause(onPause) {
  512. }
  513. createUri(schema, query = {}) {
  514. return schema + "://" + this._hostname() + this._port() + this.opts.path + this._query(query);
  515. }
  516. _hostname() {
  517. const hostname = this.opts.hostname;
  518. return hostname.indexOf(":") === -1 ? hostname : "[" + hostname + "]";
  519. }
  520. _port() {
  521. if (this.opts.port && (this.opts.secure && Number(this.opts.port !== 443) || !this.opts.secure && Number(this.opts.port) !== 80)) {
  522. return ":" + this.opts.port;
  523. } else {
  524. return "";
  525. }
  526. }
  527. _query(query) {
  528. const encodedQuery = encode(query);
  529. return encodedQuery.length ? "?" + encodedQuery : "";
  530. }
  531. };
  532. // ../../../../Newweb/starter/node_modules/engine.io-client/build/esm/transports/polling.js
  533. var Polling = class extends Transport {
  534. constructor() {
  535. super(...arguments);
  536. this._polling = false;
  537. }
  538. get name() {
  539. return "polling";
  540. }
  541. doOpen() {
  542. this._poll();
  543. }
  544. pause(onPause) {
  545. this.readyState = "pausing";
  546. const pause = () => {
  547. this.readyState = "paused";
  548. onPause();
  549. };
  550. if (this._polling || !this.writable) {
  551. let total = 0;
  552. if (this._polling) {
  553. total++;
  554. this.once("pollComplete", function() {
  555. --total || pause();
  556. });
  557. }
  558. if (!this.writable) {
  559. total++;
  560. this.once("drain", function() {
  561. --total || pause();
  562. });
  563. }
  564. } else {
  565. pause();
  566. }
  567. }
  568. _poll() {
  569. this._polling = true;
  570. this.doPoll();
  571. this.emitReserved("poll");
  572. }
  573. onData(data) {
  574. const callback = (packet) => {
  575. if (this.readyState === "opening" && packet.type === "open") {
  576. this.onOpen();
  577. }
  578. if (packet.type === "close") {
  579. this.onClose({ description: "transport closed by the server" });
  580. return false;
  581. }
  582. this.onPacket(packet);
  583. };
  584. decodePayload(data, this.socket.binaryType).forEach(callback);
  585. if (this.readyState !== "closed") {
  586. this._polling = false;
  587. this.emitReserved("pollComplete");
  588. if (this.readyState === "open") {
  589. this._poll();
  590. } else {
  591. }
  592. }
  593. }
  594. doClose() {
  595. const close = () => {
  596. this.write([{ type: "close" }]);
  597. };
  598. if (this.readyState === "open") {
  599. close();
  600. } else {
  601. this.once("open", close);
  602. }
  603. }
  604. write(packets) {
  605. this.writable = false;
  606. encodePayload(packets, (data) => {
  607. this.doWrite(data, () => {
  608. this.writable = true;
  609. this.emitReserved("drain");
  610. });
  611. });
  612. }
  613. uri() {
  614. const schema = this.opts.secure ? "https" : "http";
  615. const query = this.query || {};
  616. if (this.opts.timestampRequests !== false) {
  617. query[this.opts.timestampParam] = randomString();
  618. }
  619. if (!this.supportsBinary && !query.sid) {
  620. query.b64 = 1;
  621. }
  622. return this.createUri(schema, query);
  623. }
  624. };
  625. // ../../../../Newweb/starter/node_modules/engine.io-client/build/esm/contrib/has-cors.js
  626. var value = false;
  627. try {
  628. value = typeof XMLHttpRequest !== "undefined" && "withCredentials" in new XMLHttpRequest();
  629. } catch (err) {
  630. }
  631. var hasCORS = value;
  632. // ../../../../Newweb/starter/node_modules/engine.io-client/build/esm/transports/polling-xhr.js
  633. function empty() {
  634. }
  635. var BaseXHR = class extends Polling {
  636. constructor(opts) {
  637. super(opts);
  638. if (typeof location !== "undefined") {
  639. const isSSL = location.protocol === "https:";
  640. let port = location.port;
  641. if (!port) {
  642. port = isSSL ? "443" : "80";
  643. }
  644. this.xd = typeof location !== "undefined" && opts.hostname !== location.hostname || port !== opts.port;
  645. }
  646. }
  647. doWrite(data, fn) {
  648. const req = this.request({
  649. method: "POST",
  650. data
  651. });
  652. req.on("success", fn);
  653. req.on("error", (xhrStatus, context) => {
  654. this.onError("xhr post error", xhrStatus, context);
  655. });
  656. }
  657. doPoll() {
  658. const req = this.request();
  659. req.on("data", this.onData.bind(this));
  660. req.on("error", (xhrStatus, context) => {
  661. this.onError("xhr poll error", xhrStatus, context);
  662. });
  663. this.pollXhr = req;
  664. }
  665. };
  666. var Request = class extends Emitter {
  667. constructor(createRequest, uri, opts) {
  668. super();
  669. this.createRequest = createRequest;
  670. installTimerFunctions(this, opts);
  671. this._opts = opts;
  672. this._method = opts.method || "GET";
  673. this._uri = uri;
  674. this._data = opts.data !== void 0 ? opts.data : null;
  675. this._create();
  676. }
  677. _create() {
  678. var _a;
  679. const opts = pick(this._opts, "agent", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "autoUnref");
  680. opts.xdomain = !!this._opts.xd;
  681. const xhr = this._xhr = this.createRequest(opts);
  682. try {
  683. xhr.open(this._method, this._uri, true);
  684. try {
  685. if (this._opts.extraHeaders) {
  686. xhr.setDisableHeaderCheck && xhr.setDisableHeaderCheck(true);
  687. for (let i in this._opts.extraHeaders) {
  688. if (this._opts.extraHeaders.hasOwnProperty(i)) {
  689. xhr.setRequestHeader(i, this._opts.extraHeaders[i]);
  690. }
  691. }
  692. }
  693. } catch (e) {
  694. }
  695. if (this._method === "POST") {
  696. try {
  697. xhr.setRequestHeader("Content-type", "text/plain;charset=UTF-8");
  698. } catch (e) {
  699. }
  700. }
  701. try {
  702. xhr.setRequestHeader("Accept", "*/*");
  703. } catch (e) {
  704. }
  705. (_a = this._opts.cookieJar) === null || _a === void 0 ? void 0 : _a.addCookies(xhr);
  706. if ("withCredentials" in xhr) {
  707. xhr.withCredentials = this._opts.withCredentials;
  708. }
  709. if (this._opts.requestTimeout) {
  710. xhr.timeout = this._opts.requestTimeout;
  711. }
  712. xhr.onreadystatechange = () => {
  713. var _a2;
  714. if (xhr.readyState === 3) {
  715. (_a2 = this._opts.cookieJar) === null || _a2 === void 0 ? void 0 : _a2.parseCookies(xhr.getResponseHeader("set-cookie"));
  716. }
  717. if (xhr.readyState !== 4)
  718. return;
  719. if (xhr.status === 200 || xhr.status === 1223) {
  720. this._onLoad();
  721. } else {
  722. this.setTimeoutFn(() => {
  723. this._onError(typeof xhr.status === "number" ? xhr.status : 0);
  724. }, 0);
  725. }
  726. };
  727. xhr.send(this._data);
  728. } catch (e) {
  729. this.setTimeoutFn(() => {
  730. this._onError(e);
  731. }, 0);
  732. return;
  733. }
  734. if (typeof document !== "undefined") {
  735. this._index = Request.requestsCount++;
  736. Request.requests[this._index] = this;
  737. }
  738. }
  739. _onError(err) {
  740. this.emitReserved("error", err, this._xhr);
  741. this._cleanup(true);
  742. }
  743. _cleanup(fromError) {
  744. if (typeof this._xhr === "undefined" || this._xhr === null) {
  745. return;
  746. }
  747. this._xhr.onreadystatechange = empty;
  748. if (fromError) {
  749. try {
  750. this._xhr.abort();
  751. } catch (e) {
  752. }
  753. }
  754. if (typeof document !== "undefined") {
  755. delete Request.requests[this._index];
  756. }
  757. this._xhr = null;
  758. }
  759. _onLoad() {
  760. const data = this._xhr.responseText;
  761. if (data !== null) {
  762. this.emitReserved("data", data);
  763. this.emitReserved("success");
  764. this._cleanup();
  765. }
  766. }
  767. abort() {
  768. this._cleanup();
  769. }
  770. };
  771. Request.requestsCount = 0;
  772. Request.requests = {};
  773. if (typeof document !== "undefined") {
  774. if (typeof attachEvent === "function") {
  775. attachEvent("onunload", unloadHandler);
  776. } else if (typeof addEventListener === "function") {
  777. const terminationEvent = "onpagehide" in globalThisShim ? "pagehide" : "unload";
  778. addEventListener(terminationEvent, unloadHandler, false);
  779. }
  780. }
  781. function unloadHandler() {
  782. for (let i in Request.requests) {
  783. if (Request.requests.hasOwnProperty(i)) {
  784. Request.requests[i].abort();
  785. }
  786. }
  787. }
  788. var hasXHR2 = function() {
  789. const xhr = newRequest({
  790. xdomain: false
  791. });
  792. return xhr && xhr.responseType !== null;
  793. }();
  794. var XHR = class extends BaseXHR {
  795. constructor(opts) {
  796. super(opts);
  797. const forceBase64 = opts && opts.forceBase64;
  798. this.supportsBinary = hasXHR2 && !forceBase64;
  799. }
  800. request(opts = {}) {
  801. Object.assign(opts, { xd: this.xd }, this.opts);
  802. return new Request(newRequest, this.uri(), opts);
  803. }
  804. };
  805. function newRequest(opts) {
  806. const xdomain = opts.xdomain;
  807. try {
  808. if (typeof XMLHttpRequest !== "undefined" && (!xdomain || hasCORS)) {
  809. return new XMLHttpRequest();
  810. }
  811. } catch (e) {
  812. }
  813. if (!xdomain) {
  814. try {
  815. return new globalThisShim[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP");
  816. } catch (e) {
  817. }
  818. }
  819. }
  820. // ../../../../Newweb/starter/node_modules/engine.io-client/build/esm/transports/websocket.js
  821. var isReactNative = typeof navigator !== "undefined" && typeof navigator.product === "string" && navigator.product.toLowerCase() === "reactnative";
  822. var BaseWS = class extends Transport {
  823. get name() {
  824. return "websocket";
  825. }
  826. doOpen() {
  827. const uri = this.uri();
  828. const protocols = this.opts.protocols;
  829. const opts = isReactNative ? {} : pick(this.opts, "agent", "perMessageDeflate", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "localAddress", "protocolVersion", "origin", "maxPayload", "family", "checkServerIdentity");
  830. if (this.opts.extraHeaders) {
  831. opts.headers = this.opts.extraHeaders;
  832. }
  833. try {
  834. this.ws = this.createSocket(uri, protocols, opts);
  835. } catch (err) {
  836. return this.emitReserved("error", err);
  837. }
  838. this.ws.binaryType = this.socket.binaryType;
  839. this.addEventListeners();
  840. }
  841. addEventListeners() {
  842. this.ws.onopen = () => {
  843. if (this.opts.autoUnref) {
  844. this.ws._socket.unref();
  845. }
  846. this.onOpen();
  847. };
  848. this.ws.onclose = (closeEvent) => this.onClose({
  849. description: "websocket connection closed",
  850. context: closeEvent
  851. });
  852. this.ws.onmessage = (ev) => this.onData(ev.data);
  853. this.ws.onerror = (e) => this.onError("websocket error", e);
  854. }
  855. write(packets) {
  856. this.writable = false;
  857. for (let i = 0; i < packets.length; i++) {
  858. const packet = packets[i];
  859. const lastPacket = i === packets.length - 1;
  860. encodePacket(packet, this.supportsBinary, (data) => {
  861. try {
  862. this.doWrite(packet, data);
  863. } catch (e) {
  864. }
  865. if (lastPacket) {
  866. nextTick(() => {
  867. this.writable = true;
  868. this.emitReserved("drain");
  869. }, this.setTimeoutFn);
  870. }
  871. });
  872. }
  873. }
  874. doClose() {
  875. if (typeof this.ws !== "undefined") {
  876. this.ws.close();
  877. this.ws = null;
  878. }
  879. }
  880. uri() {
  881. const schema = this.opts.secure ? "wss" : "ws";
  882. const query = this.query || {};
  883. if (this.opts.timestampRequests) {
  884. query[this.opts.timestampParam] = randomString();
  885. }
  886. if (!this.supportsBinary) {
  887. query.b64 = 1;
  888. }
  889. return this.createUri(schema, query);
  890. }
  891. };
  892. var WebSocketCtor = globalThisShim.WebSocket || globalThisShim.MozWebSocket;
  893. var WS = class extends BaseWS {
  894. createSocket(uri, protocols, opts) {
  895. return !isReactNative ? protocols ? new WebSocketCtor(uri, protocols) : new WebSocketCtor(uri) : new WebSocketCtor(uri, protocols, opts);
  896. }
  897. doWrite(_packet, data) {
  898. this.ws.send(data);
  899. }
  900. };
  901. // ../../../../Newweb/starter/node_modules/engine.io-client/build/esm/transports/webtransport.js
  902. var WT = class extends Transport {
  903. get name() {
  904. return "webtransport";
  905. }
  906. doOpen() {
  907. try {
  908. this._transport = new WebTransport(this.createUri("https"), this.opts.transportOptions[this.name]);
  909. } catch (err) {
  910. return this.emitReserved("error", err);
  911. }
  912. this._transport.closed.then(() => {
  913. this.onClose();
  914. }).catch((err) => {
  915. this.onError("webtransport error", err);
  916. });
  917. this._transport.ready.then(() => {
  918. this._transport.createBidirectionalStream().then((stream) => {
  919. const decoderStream = createPacketDecoderStream(Number.MAX_SAFE_INTEGER, this.socket.binaryType);
  920. const reader = stream.readable.pipeThrough(decoderStream).getReader();
  921. const encoderStream = createPacketEncoderStream();
  922. encoderStream.readable.pipeTo(stream.writable);
  923. this._writer = encoderStream.writable.getWriter();
  924. const read = () => {
  925. reader.read().then(({ done, value: value2 }) => {
  926. if (done) {
  927. return;
  928. }
  929. this.onPacket(value2);
  930. read();
  931. }).catch((err) => {
  932. });
  933. };
  934. read();
  935. const packet = { type: "open" };
  936. if (this.query.sid) {
  937. packet.data = `{"sid":"${this.query.sid}"}`;
  938. }
  939. this._writer.write(packet).then(() => this.onOpen());
  940. });
  941. });
  942. }
  943. write(packets) {
  944. this.writable = false;
  945. for (let i = 0; i < packets.length; i++) {
  946. const packet = packets[i];
  947. const lastPacket = i === packets.length - 1;
  948. this._writer.write(packet).then(() => {
  949. if (lastPacket) {
  950. nextTick(() => {
  951. this.writable = true;
  952. this.emitReserved("drain");
  953. }, this.setTimeoutFn);
  954. }
  955. });
  956. }
  957. }
  958. doClose() {
  959. var _a;
  960. (_a = this._transport) === null || _a === void 0 ? void 0 : _a.close();
  961. }
  962. };
  963. // ../../../../Newweb/starter/node_modules/engine.io-client/build/esm/transports/index.js
  964. var transports = {
  965. websocket: WS,
  966. webtransport: WT,
  967. polling: XHR
  968. };
  969. // ../../../../Newweb/starter/node_modules/engine.io-client/build/esm/contrib/parseuri.js
  970. var re = /^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/;
  971. var parts = [
  972. "source",
  973. "protocol",
  974. "authority",
  975. "userInfo",
  976. "user",
  977. "password",
  978. "host",
  979. "port",
  980. "relative",
  981. "path",
  982. "directory",
  983. "file",
  984. "query",
  985. "anchor"
  986. ];
  987. function parse(str) {
  988. if (str.length > 8e3) {
  989. throw "URI too long";
  990. }
  991. const src = str, b = str.indexOf("["), e = str.indexOf("]");
  992. if (b != -1 && e != -1) {
  993. str = str.substring(0, b) + str.substring(b, e).replace(/:/g, ";") + str.substring(e, str.length);
  994. }
  995. let m = re.exec(str || ""), uri = {}, i = 14;
  996. while (i--) {
  997. uri[parts[i]] = m[i] || "";
  998. }
  999. if (b != -1 && e != -1) {
  1000. uri.source = src;
  1001. uri.host = uri.host.substring(1, uri.host.length - 1).replace(/;/g, ":");
  1002. uri.authority = uri.authority.replace("[", "").replace("]", "").replace(/;/g, ":");
  1003. uri.ipv6uri = true;
  1004. }
  1005. uri.pathNames = pathNames(uri, uri["path"]);
  1006. uri.queryKey = queryKey(uri, uri["query"]);
  1007. return uri;
  1008. }
  1009. function pathNames(obj, path) {
  1010. const regx = /\/{2,9}/g, names = path.replace(regx, "/").split("/");
  1011. if (path.slice(0, 1) == "/" || path.length === 0) {
  1012. names.splice(0, 1);
  1013. }
  1014. if (path.slice(-1) == "/") {
  1015. names.splice(names.length - 1, 1);
  1016. }
  1017. return names;
  1018. }
  1019. function queryKey(uri, query) {
  1020. const data = {};
  1021. query.replace(/(?:^|&)([^&=]*)=?([^&]*)/g, function($0, $1, $2) {
  1022. if ($1) {
  1023. data[$1] = $2;
  1024. }
  1025. });
  1026. return data;
  1027. }
  1028. // ../../../../Newweb/starter/node_modules/engine.io-client/build/esm/socket.js
  1029. var withEventListeners = typeof addEventListener === "function" && typeof removeEventListener === "function";
  1030. var OFFLINE_EVENT_LISTENERS = [];
  1031. if (withEventListeners) {
  1032. addEventListener("offline", () => {
  1033. OFFLINE_EVENT_LISTENERS.forEach((listener) => listener());
  1034. }, false);
  1035. }
  1036. var SocketWithoutUpgrade = class extends Emitter {
  1037. constructor(uri, opts) {
  1038. super();
  1039. this.binaryType = defaultBinaryType;
  1040. this.writeBuffer = [];
  1041. this._prevBufferLen = 0;
  1042. this._pingInterval = -1;
  1043. this._pingTimeout = -1;
  1044. this._maxPayload = -1;
  1045. this._pingTimeoutTime = Infinity;
  1046. if (uri && typeof uri === "object") {
  1047. opts = uri;
  1048. uri = null;
  1049. }
  1050. if (uri) {
  1051. const parsedUri = parse(uri);
  1052. opts.hostname = parsedUri.host;
  1053. opts.secure = parsedUri.protocol === "https" || parsedUri.protocol === "wss";
  1054. opts.port = parsedUri.port;
  1055. if (parsedUri.query)
  1056. opts.query = parsedUri.query;
  1057. } else if (opts.host) {
  1058. opts.hostname = parse(opts.host).host;
  1059. }
  1060. installTimerFunctions(this, opts);
  1061. this.secure = opts.secure != null ? opts.secure : typeof location !== "undefined" && location.protocol === "https:";
  1062. if (opts.hostname && !opts.port) {
  1063. opts.port = this.secure ? "443" : "80";
  1064. }
  1065. this.hostname = opts.hostname || (typeof location !== "undefined" ? location.hostname : "localhost");
  1066. this.port = opts.port || (typeof location !== "undefined" && location.port ? location.port : this.secure ? "443" : "80");
  1067. this.transports = [];
  1068. this._transportsByName = {};
  1069. opts.transports.forEach((t) => {
  1070. const transportName = t.prototype.name;
  1071. this.transports.push(transportName);
  1072. this._transportsByName[transportName] = t;
  1073. });
  1074. this.opts = Object.assign({
  1075. path: "/engine.io",
  1076. agent: false,
  1077. withCredentials: false,
  1078. upgrade: true,
  1079. timestampParam: "t",
  1080. rememberUpgrade: false,
  1081. addTrailingSlash: true,
  1082. rejectUnauthorized: true,
  1083. perMessageDeflate: {
  1084. threshold: 1024
  1085. },
  1086. transportOptions: {},
  1087. closeOnBeforeunload: false
  1088. }, opts);
  1089. this.opts.path = this.opts.path.replace(/\/$/, "") + (this.opts.addTrailingSlash ? "/" : "");
  1090. if (typeof this.opts.query === "string") {
  1091. this.opts.query = decode2(this.opts.query);
  1092. }
  1093. if (withEventListeners) {
  1094. if (this.opts.closeOnBeforeunload) {
  1095. this._beforeunloadEventListener = () => {
  1096. if (this.transport) {
  1097. this.transport.removeAllListeners();
  1098. this.transport.close();
  1099. }
  1100. };
  1101. addEventListener("beforeunload", this._beforeunloadEventListener, false);
  1102. }
  1103. if (this.hostname !== "localhost") {
  1104. this._offlineEventListener = () => {
  1105. this._onClose("transport close", {
  1106. description: "network connection lost"
  1107. });
  1108. };
  1109. OFFLINE_EVENT_LISTENERS.push(this._offlineEventListener);
  1110. }
  1111. }
  1112. if (this.opts.withCredentials) {
  1113. this._cookieJar = createCookieJar();
  1114. }
  1115. this._open();
  1116. }
  1117. createTransport(name) {
  1118. const query = Object.assign({}, this.opts.query);
  1119. query.EIO = protocol;
  1120. query.transport = name;
  1121. if (this.id)
  1122. query.sid = this.id;
  1123. const opts = Object.assign({}, this.opts, {
  1124. query,
  1125. socket: this,
  1126. hostname: this.hostname,
  1127. secure: this.secure,
  1128. port: this.port
  1129. }, this.opts.transportOptions[name]);
  1130. return new this._transportsByName[name](opts);
  1131. }
  1132. _open() {
  1133. if (this.transports.length === 0) {
  1134. this.setTimeoutFn(() => {
  1135. this.emitReserved("error", "No transports available");
  1136. }, 0);
  1137. return;
  1138. }
  1139. const transportName = this.opts.rememberUpgrade && SocketWithoutUpgrade.priorWebsocketSuccess && this.transports.indexOf("websocket") !== -1 ? "websocket" : this.transports[0];
  1140. this.readyState = "opening";
  1141. const transport = this.createTransport(transportName);
  1142. transport.open();
  1143. this.setTransport(transport);
  1144. }
  1145. setTransport(transport) {
  1146. if (this.transport) {
  1147. this.transport.removeAllListeners();
  1148. }
  1149. this.transport = transport;
  1150. transport.on("drain", this._onDrain.bind(this)).on("packet", this._onPacket.bind(this)).on("error", this._onError.bind(this)).on("close", (reason) => this._onClose("transport close", reason));
  1151. }
  1152. onOpen() {
  1153. this.readyState = "open";
  1154. SocketWithoutUpgrade.priorWebsocketSuccess = this.transport.name === "websocket";
  1155. this.emitReserved("open");
  1156. this.flush();
  1157. }
  1158. _onPacket(packet) {
  1159. if (this.readyState === "opening" || this.readyState === "open" || this.readyState === "closing") {
  1160. this.emitReserved("packet", packet);
  1161. this.emitReserved("heartbeat");
  1162. switch (packet.type) {
  1163. case "open":
  1164. this.onHandshake(JSON.parse(packet.data));
  1165. break;
  1166. case "ping":
  1167. this._sendPacket("pong");
  1168. this.emitReserved("ping");
  1169. this.emitReserved("pong");
  1170. this._resetPingTimeout();
  1171. break;
  1172. case "error":
  1173. const err = new Error("server error");
  1174. err.code = packet.data;
  1175. this._onError(err);
  1176. break;
  1177. case "message":
  1178. this.emitReserved("data", packet.data);
  1179. this.emitReserved("message", packet.data);
  1180. break;
  1181. }
  1182. } else {
  1183. }
  1184. }
  1185. onHandshake(data) {
  1186. this.emitReserved("handshake", data);
  1187. this.id = data.sid;
  1188. this.transport.query.sid = data.sid;
  1189. this._pingInterval = data.pingInterval;
  1190. this._pingTimeout = data.pingTimeout;
  1191. this._maxPayload = data.maxPayload;
  1192. this.onOpen();
  1193. if (this.readyState === "closed")
  1194. return;
  1195. this._resetPingTimeout();
  1196. }
  1197. _resetPingTimeout() {
  1198. this.clearTimeoutFn(this._pingTimeoutTimer);
  1199. const delay = this._pingInterval + this._pingTimeout;
  1200. this._pingTimeoutTime = Date.now() + delay;
  1201. this._pingTimeoutTimer = this.setTimeoutFn(() => {
  1202. this._onClose("ping timeout");
  1203. }, delay);
  1204. if (this.opts.autoUnref) {
  1205. this._pingTimeoutTimer.unref();
  1206. }
  1207. }
  1208. _onDrain() {
  1209. this.writeBuffer.splice(0, this._prevBufferLen);
  1210. this._prevBufferLen = 0;
  1211. if (this.writeBuffer.length === 0) {
  1212. this.emitReserved("drain");
  1213. } else {
  1214. this.flush();
  1215. }
  1216. }
  1217. flush() {
  1218. if (this.readyState !== "closed" && this.transport.writable && !this.upgrading && this.writeBuffer.length) {
  1219. const packets = this._getWritablePackets();
  1220. this.transport.send(packets);
  1221. this._prevBufferLen = packets.length;
  1222. this.emitReserved("flush");
  1223. }
  1224. }
  1225. _getWritablePackets() {
  1226. const shouldCheckPayloadSize = this._maxPayload && this.transport.name === "polling" && this.writeBuffer.length > 1;
  1227. if (!shouldCheckPayloadSize) {
  1228. return this.writeBuffer;
  1229. }
  1230. let payloadSize = 1;
  1231. for (let i = 0; i < this.writeBuffer.length; i++) {
  1232. const data = this.writeBuffer[i].data;
  1233. if (data) {
  1234. payloadSize += byteLength(data);
  1235. }
  1236. if (i > 0 && payloadSize > this._maxPayload) {
  1237. return this.writeBuffer.slice(0, i);
  1238. }
  1239. payloadSize += 2;
  1240. }
  1241. return this.writeBuffer;
  1242. }
  1243. _hasPingExpired() {
  1244. if (!this._pingTimeoutTime)
  1245. return true;
  1246. const hasExpired = Date.now() > this._pingTimeoutTime;
  1247. if (hasExpired) {
  1248. this._pingTimeoutTime = 0;
  1249. nextTick(() => {
  1250. this._onClose("ping timeout");
  1251. }, this.setTimeoutFn);
  1252. }
  1253. return hasExpired;
  1254. }
  1255. write(msg, options, fn) {
  1256. this._sendPacket("message", msg, options, fn);
  1257. return this;
  1258. }
  1259. send(msg, options, fn) {
  1260. this._sendPacket("message", msg, options, fn);
  1261. return this;
  1262. }
  1263. _sendPacket(type, data, options, fn) {
  1264. if (typeof data === "function") {
  1265. fn = data;
  1266. data = void 0;
  1267. }
  1268. if (typeof options === "function") {
  1269. fn = options;
  1270. options = null;
  1271. }
  1272. if (this.readyState === "closing" || this.readyState === "closed") {
  1273. return;
  1274. }
  1275. options = options || {};
  1276. options.compress = options.compress !== false;
  1277. const packet = {
  1278. type,
  1279. data,
  1280. options
  1281. };
  1282. this.emitReserved("packetCreate", packet);
  1283. this.writeBuffer.push(packet);
  1284. if (fn)
  1285. this.once("flush", fn);
  1286. this.flush();
  1287. }
  1288. close() {
  1289. const close = () => {
  1290. this._onClose("forced close");
  1291. this.transport.close();
  1292. };
  1293. const cleanupAndClose = () => {
  1294. this.off("upgrade", cleanupAndClose);
  1295. this.off("upgradeError", cleanupAndClose);
  1296. close();
  1297. };
  1298. const waitForUpgrade = () => {
  1299. this.once("upgrade", cleanupAndClose);
  1300. this.once("upgradeError", cleanupAndClose);
  1301. };
  1302. if (this.readyState === "opening" || this.readyState === "open") {
  1303. this.readyState = "closing";
  1304. if (this.writeBuffer.length) {
  1305. this.once("drain", () => {
  1306. if (this.upgrading) {
  1307. waitForUpgrade();
  1308. } else {
  1309. close();
  1310. }
  1311. });
  1312. } else if (this.upgrading) {
  1313. waitForUpgrade();
  1314. } else {
  1315. close();
  1316. }
  1317. }
  1318. return this;
  1319. }
  1320. _onError(err) {
  1321. SocketWithoutUpgrade.priorWebsocketSuccess = false;
  1322. if (this.opts.tryAllTransports && this.transports.length > 1 && this.readyState === "opening") {
  1323. this.transports.shift();
  1324. return this._open();
  1325. }
  1326. this.emitReserved("error", err);
  1327. this._onClose("transport error", err);
  1328. }
  1329. _onClose(reason, description) {
  1330. if (this.readyState === "opening" || this.readyState === "open" || this.readyState === "closing") {
  1331. this.clearTimeoutFn(this._pingTimeoutTimer);
  1332. this.transport.removeAllListeners("close");
  1333. this.transport.close();
  1334. this.transport.removeAllListeners();
  1335. if (withEventListeners) {
  1336. if (this._beforeunloadEventListener) {
  1337. removeEventListener("beforeunload", this._beforeunloadEventListener, false);
  1338. }
  1339. if (this._offlineEventListener) {
  1340. const i = OFFLINE_EVENT_LISTENERS.indexOf(this._offlineEventListener);
  1341. if (i !== -1) {
  1342. OFFLINE_EVENT_LISTENERS.splice(i, 1);
  1343. }
  1344. }
  1345. }
  1346. this.readyState = "closed";
  1347. this.id = null;
  1348. this.emitReserved("close", reason, description);
  1349. this.writeBuffer = [];
  1350. this._prevBufferLen = 0;
  1351. }
  1352. }
  1353. };
  1354. SocketWithoutUpgrade.protocol = protocol;
  1355. var SocketWithUpgrade = class extends SocketWithoutUpgrade {
  1356. constructor() {
  1357. super(...arguments);
  1358. this._upgrades = [];
  1359. }
  1360. onOpen() {
  1361. super.onOpen();
  1362. if (this.readyState === "open" && this.opts.upgrade) {
  1363. for (let i = 0; i < this._upgrades.length; i++) {
  1364. this._probe(this._upgrades[i]);
  1365. }
  1366. }
  1367. }
  1368. _probe(name) {
  1369. let transport = this.createTransport(name);
  1370. let failed = false;
  1371. SocketWithoutUpgrade.priorWebsocketSuccess = false;
  1372. const onTransportOpen = () => {
  1373. if (failed)
  1374. return;
  1375. transport.send([{ type: "ping", data: "probe" }]);
  1376. transport.once("packet", (msg) => {
  1377. if (failed)
  1378. return;
  1379. if (msg.type === "pong" && msg.data === "probe") {
  1380. this.upgrading = true;
  1381. this.emitReserved("upgrading", transport);
  1382. if (!transport)
  1383. return;
  1384. SocketWithoutUpgrade.priorWebsocketSuccess = transport.name === "websocket";
  1385. this.transport.pause(() => {
  1386. if (failed)
  1387. return;
  1388. if (this.readyState === "closed")
  1389. return;
  1390. cleanup();
  1391. this.setTransport(transport);
  1392. transport.send([{ type: "upgrade" }]);
  1393. this.emitReserved("upgrade", transport);
  1394. transport = null;
  1395. this.upgrading = false;
  1396. this.flush();
  1397. });
  1398. } else {
  1399. const err = new Error("probe error");
  1400. err.transport = transport.name;
  1401. this.emitReserved("upgradeError", err);
  1402. }
  1403. });
  1404. };
  1405. function freezeTransport() {
  1406. if (failed)
  1407. return;
  1408. failed = true;
  1409. cleanup();
  1410. transport.close();
  1411. transport = null;
  1412. }
  1413. const onerror = (err) => {
  1414. const error = new Error("probe error: " + err);
  1415. error.transport = transport.name;
  1416. freezeTransport();
  1417. this.emitReserved("upgradeError", error);
  1418. };
  1419. function onTransportClose() {
  1420. onerror("transport closed");
  1421. }
  1422. function onclose() {
  1423. onerror("socket closed");
  1424. }
  1425. function onupgrade(to) {
  1426. if (transport && to.name !== transport.name) {
  1427. freezeTransport();
  1428. }
  1429. }
  1430. const cleanup = () => {
  1431. transport.removeListener("open", onTransportOpen);
  1432. transport.removeListener("error", onerror);
  1433. transport.removeListener("close", onTransportClose);
  1434. this.off("close", onclose);
  1435. this.off("upgrading", onupgrade);
  1436. };
  1437. transport.once("open", onTransportOpen);
  1438. transport.once("error", onerror);
  1439. transport.once("close", onTransportClose);
  1440. this.once("close", onclose);
  1441. this.once("upgrading", onupgrade);
  1442. if (this._upgrades.indexOf("webtransport") !== -1 && name !== "webtransport") {
  1443. this.setTimeoutFn(() => {
  1444. if (!failed) {
  1445. transport.open();
  1446. }
  1447. }, 200);
  1448. } else {
  1449. transport.open();
  1450. }
  1451. }
  1452. onHandshake(data) {
  1453. this._upgrades = this._filterUpgrades(data.upgrades);
  1454. super.onHandshake(data);
  1455. }
  1456. _filterUpgrades(upgrades) {
  1457. const filteredUpgrades = [];
  1458. for (let i = 0; i < upgrades.length; i++) {
  1459. if (~this.transports.indexOf(upgrades[i]))
  1460. filteredUpgrades.push(upgrades[i]);
  1461. }
  1462. return filteredUpgrades;
  1463. }
  1464. };
  1465. var Socket = class extends SocketWithUpgrade {
  1466. constructor(uri, opts = {}) {
  1467. const o = typeof uri === "object" ? uri : opts;
  1468. if (!o.transports || o.transports && typeof o.transports[0] === "string") {
  1469. o.transports = (o.transports || ["polling", "websocket", "webtransport"]).map((transportName) => transports[transportName]).filter((t) => !!t);
  1470. }
  1471. super(uri, o);
  1472. }
  1473. };
  1474. // ../../../../Newweb/starter/node_modules/engine.io-client/build/esm/index.js
  1475. var protocol2 = Socket.protocol;
  1476. // ../../../../Newweb/starter/node_modules/socket.io-client/build/esm/url.js
  1477. function url(uri, path = "", loc) {
  1478. let obj = uri;
  1479. loc = loc || typeof location !== "undefined" && location;
  1480. if (uri == null)
  1481. uri = loc.protocol + "//" + loc.host;
  1482. if (typeof uri === "string") {
  1483. if (uri.charAt(0) === "/") {
  1484. if (uri.charAt(1) === "/") {
  1485. uri = loc.protocol + uri;
  1486. } else {
  1487. uri = loc.host + uri;
  1488. }
  1489. }
  1490. if (!/^(https?|wss?):\/\//.test(uri)) {
  1491. if (typeof loc !== "undefined") {
  1492. uri = loc.protocol + "//" + uri;
  1493. } else {
  1494. uri = "https://" + uri;
  1495. }
  1496. }
  1497. obj = parse(uri);
  1498. }
  1499. if (!obj.port) {
  1500. if (/^(http|ws)$/.test(obj.protocol)) {
  1501. obj.port = "80";
  1502. } else if (/^(http|ws)s$/.test(obj.protocol)) {
  1503. obj.port = "443";
  1504. }
  1505. }
  1506. obj.path = obj.path || "/";
  1507. const ipv6 = obj.host.indexOf(":") !== -1;
  1508. const host = ipv6 ? "[" + obj.host + "]" : obj.host;
  1509. obj.id = obj.protocol + "://" + host + ":" + obj.port + path;
  1510. obj.href = obj.protocol + "://" + host + (loc && loc.port === obj.port ? "" : ":" + obj.port);
  1511. return obj;
  1512. }
  1513. // ../../../../Newweb/starter/node_modules/socket.io-parser/build/esm/index.js
  1514. var esm_exports = {};
  1515. __export(esm_exports, {
  1516. Decoder: () => Decoder,
  1517. Encoder: () => Encoder,
  1518. PacketType: () => PacketType,
  1519. protocol: () => protocol3
  1520. });
  1521. // ../../../../Newweb/starter/node_modules/socket.io-parser/build/esm/is-binary.js
  1522. var withNativeArrayBuffer3 = typeof ArrayBuffer === "function";
  1523. var isView2 = (obj) => {
  1524. return typeof ArrayBuffer.isView === "function" ? ArrayBuffer.isView(obj) : obj.buffer instanceof ArrayBuffer;
  1525. };
  1526. var toString = Object.prototype.toString;
  1527. var withNativeBlob2 = typeof Blob === "function" || typeof Blob !== "undefined" && toString.call(Blob) === "[object BlobConstructor]";
  1528. var withNativeFile = typeof File === "function" || typeof File !== "undefined" && toString.call(File) === "[object FileConstructor]";
  1529. function isBinary(obj) {
  1530. return withNativeArrayBuffer3 && (obj instanceof ArrayBuffer || isView2(obj)) || withNativeBlob2 && obj instanceof Blob || withNativeFile && obj instanceof File;
  1531. }
  1532. function hasBinary(obj, toJSON) {
  1533. if (!obj || typeof obj !== "object") {
  1534. return false;
  1535. }
  1536. if (Array.isArray(obj)) {
  1537. for (let i = 0, l = obj.length; i < l; i++) {
  1538. if (hasBinary(obj[i])) {
  1539. return true;
  1540. }
  1541. }
  1542. return false;
  1543. }
  1544. if (isBinary(obj)) {
  1545. return true;
  1546. }
  1547. if (obj.toJSON && typeof obj.toJSON === "function" && arguments.length === 1) {
  1548. return hasBinary(obj.toJSON(), true);
  1549. }
  1550. for (const key in obj) {
  1551. if (Object.prototype.hasOwnProperty.call(obj, key) && hasBinary(obj[key])) {
  1552. return true;
  1553. }
  1554. }
  1555. return false;
  1556. }
  1557. // ../../../../Newweb/starter/node_modules/socket.io-parser/build/esm/binary.js
  1558. function deconstructPacket(packet) {
  1559. const buffers = [];
  1560. const packetData = packet.data;
  1561. const pack = packet;
  1562. pack.data = _deconstructPacket(packetData, buffers);
  1563. pack.attachments = buffers.length;
  1564. return { packet: pack, buffers };
  1565. }
  1566. function _deconstructPacket(data, buffers) {
  1567. if (!data)
  1568. return data;
  1569. if (isBinary(data)) {
  1570. const placeholder = { _placeholder: true, num: buffers.length };
  1571. buffers.push(data);
  1572. return placeholder;
  1573. } else if (Array.isArray(data)) {
  1574. const newData = new Array(data.length);
  1575. for (let i = 0; i < data.length; i++) {
  1576. newData[i] = _deconstructPacket(data[i], buffers);
  1577. }
  1578. return newData;
  1579. } else if (typeof data === "object" && !(data instanceof Date)) {
  1580. const newData = {};
  1581. for (const key in data) {
  1582. if (Object.prototype.hasOwnProperty.call(data, key)) {
  1583. newData[key] = _deconstructPacket(data[key], buffers);
  1584. }
  1585. }
  1586. return newData;
  1587. }
  1588. return data;
  1589. }
  1590. function reconstructPacket(packet, buffers) {
  1591. packet.data = _reconstructPacket(packet.data, buffers);
  1592. delete packet.attachments;
  1593. return packet;
  1594. }
  1595. function _reconstructPacket(data, buffers) {
  1596. if (!data)
  1597. return data;
  1598. if (data && data._placeholder === true) {
  1599. const isIndexValid = typeof data.num === "number" && data.num >= 0 && data.num < buffers.length;
  1600. if (isIndexValid) {
  1601. return buffers[data.num];
  1602. } else {
  1603. throw new Error("illegal attachments");
  1604. }
  1605. } else if (Array.isArray(data)) {
  1606. for (let i = 0; i < data.length; i++) {
  1607. data[i] = _reconstructPacket(data[i], buffers);
  1608. }
  1609. } else if (typeof data === "object") {
  1610. for (const key in data) {
  1611. if (Object.prototype.hasOwnProperty.call(data, key)) {
  1612. data[key] = _reconstructPacket(data[key], buffers);
  1613. }
  1614. }
  1615. }
  1616. return data;
  1617. }
  1618. // ../../../../Newweb/starter/node_modules/socket.io-parser/build/esm/index.js
  1619. var RESERVED_EVENTS = [
  1620. "connect",
  1621. "connect_error",
  1622. "disconnect",
  1623. "disconnecting",
  1624. "newListener",
  1625. "removeListener"
  1626. ];
  1627. var protocol3 = 5;
  1628. var PacketType;
  1629. (function(PacketType2) {
  1630. PacketType2[PacketType2["CONNECT"] = 0] = "CONNECT";
  1631. PacketType2[PacketType2["DISCONNECT"] = 1] = "DISCONNECT";
  1632. PacketType2[PacketType2["EVENT"] = 2] = "EVENT";
  1633. PacketType2[PacketType2["ACK"] = 3] = "ACK";
  1634. PacketType2[PacketType2["CONNECT_ERROR"] = 4] = "CONNECT_ERROR";
  1635. PacketType2[PacketType2["BINARY_EVENT"] = 5] = "BINARY_EVENT";
  1636. PacketType2[PacketType2["BINARY_ACK"] = 6] = "BINARY_ACK";
  1637. })(PacketType || (PacketType = {}));
  1638. var Encoder = class {
  1639. constructor(replacer) {
  1640. this.replacer = replacer;
  1641. }
  1642. encode(obj) {
  1643. if (obj.type === PacketType.EVENT || obj.type === PacketType.ACK) {
  1644. if (hasBinary(obj)) {
  1645. return this.encodeAsBinary({
  1646. type: obj.type === PacketType.EVENT ? PacketType.BINARY_EVENT : PacketType.BINARY_ACK,
  1647. nsp: obj.nsp,
  1648. data: obj.data,
  1649. id: obj.id
  1650. });
  1651. }
  1652. }
  1653. return [this.encodeAsString(obj)];
  1654. }
  1655. encodeAsString(obj) {
  1656. let str = "" + obj.type;
  1657. if (obj.type === PacketType.BINARY_EVENT || obj.type === PacketType.BINARY_ACK) {
  1658. str += obj.attachments + "-";
  1659. }
  1660. if (obj.nsp && obj.nsp !== "/") {
  1661. str += obj.nsp + ",";
  1662. }
  1663. if (obj.id != null) {
  1664. str += obj.id;
  1665. }
  1666. if (obj.data != null) {
  1667. str += JSON.stringify(obj.data, this.replacer);
  1668. }
  1669. return str;
  1670. }
  1671. encodeAsBinary(obj) {
  1672. const deconstruction = deconstructPacket(obj);
  1673. const pack = this.encodeAsString(deconstruction.packet);
  1674. const buffers = deconstruction.buffers;
  1675. buffers.unshift(pack);
  1676. return buffers;
  1677. }
  1678. };
  1679. function isObject(value2) {
  1680. return Object.prototype.toString.call(value2) === "[object Object]";
  1681. }
  1682. var Decoder = class extends Emitter {
  1683. constructor(reviver) {
  1684. super();
  1685. this.reviver = reviver;
  1686. }
  1687. add(obj) {
  1688. let packet;
  1689. if (typeof obj === "string") {
  1690. if (this.reconstructor) {
  1691. throw new Error("got plaintext data when reconstructing a packet");
  1692. }
  1693. packet = this.decodeString(obj);
  1694. const isBinaryEvent = packet.type === PacketType.BINARY_EVENT;
  1695. if (isBinaryEvent || packet.type === PacketType.BINARY_ACK) {
  1696. packet.type = isBinaryEvent ? PacketType.EVENT : PacketType.ACK;
  1697. this.reconstructor = new BinaryReconstructor(packet);
  1698. if (packet.attachments === 0) {
  1699. super.emitReserved("decoded", packet);
  1700. }
  1701. } else {
  1702. super.emitReserved("decoded", packet);
  1703. }
  1704. } else if (isBinary(obj) || obj.base64) {
  1705. if (!this.reconstructor) {
  1706. throw new Error("got binary data when not reconstructing a packet");
  1707. } else {
  1708. packet = this.reconstructor.takeBinaryData(obj);
  1709. if (packet) {
  1710. this.reconstructor = null;
  1711. super.emitReserved("decoded", packet);
  1712. }
  1713. }
  1714. } else {
  1715. throw new Error("Unknown type: " + obj);
  1716. }
  1717. }
  1718. decodeString(str) {
  1719. let i = 0;
  1720. const p = {
  1721. type: Number(str.charAt(0))
  1722. };
  1723. if (PacketType[p.type] === void 0) {
  1724. throw new Error("unknown packet type " + p.type);
  1725. }
  1726. if (p.type === PacketType.BINARY_EVENT || p.type === PacketType.BINARY_ACK) {
  1727. const start = i + 1;
  1728. while (str.charAt(++i) !== "-" && i != str.length) {
  1729. }
  1730. const buf = str.substring(start, i);
  1731. if (buf != Number(buf) || str.charAt(i) !== "-") {
  1732. throw new Error("Illegal attachments");
  1733. }
  1734. p.attachments = Number(buf);
  1735. }
  1736. if (str.charAt(i + 1) === "/") {
  1737. const start = i + 1;
  1738. while (++i) {
  1739. const c = str.charAt(i);
  1740. if (c === ",")
  1741. break;
  1742. if (i === str.length)
  1743. break;
  1744. }
  1745. p.nsp = str.substring(start, i);
  1746. } else {
  1747. p.nsp = "/";
  1748. }
  1749. const next = str.charAt(i + 1);
  1750. if (next !== "" && Number(next) == next) {
  1751. const start = i + 1;
  1752. while (++i) {
  1753. const c = str.charAt(i);
  1754. if (c == null || Number(c) != c) {
  1755. --i;
  1756. break;
  1757. }
  1758. if (i === str.length)
  1759. break;
  1760. }
  1761. p.id = Number(str.substring(start, i + 1));
  1762. }
  1763. if (str.charAt(++i)) {
  1764. const payload = this.tryParse(str.substr(i));
  1765. if (Decoder.isPayloadValid(p.type, payload)) {
  1766. p.data = payload;
  1767. } else {
  1768. throw new Error("invalid payload");
  1769. }
  1770. }
  1771. return p;
  1772. }
  1773. tryParse(str) {
  1774. try {
  1775. return JSON.parse(str, this.reviver);
  1776. } catch (e) {
  1777. return false;
  1778. }
  1779. }
  1780. static isPayloadValid(type, payload) {
  1781. switch (type) {
  1782. case PacketType.CONNECT:
  1783. return isObject(payload);
  1784. case PacketType.DISCONNECT:
  1785. return payload === void 0;
  1786. case PacketType.CONNECT_ERROR:
  1787. return typeof payload === "string" || isObject(payload);
  1788. case PacketType.EVENT:
  1789. case PacketType.BINARY_EVENT:
  1790. return Array.isArray(payload) && (typeof payload[0] === "number" || typeof payload[0] === "string" && RESERVED_EVENTS.indexOf(payload[0]) === -1);
  1791. case PacketType.ACK:
  1792. case PacketType.BINARY_ACK:
  1793. return Array.isArray(payload);
  1794. }
  1795. }
  1796. destroy() {
  1797. if (this.reconstructor) {
  1798. this.reconstructor.finishedReconstruction();
  1799. this.reconstructor = null;
  1800. }
  1801. }
  1802. };
  1803. var BinaryReconstructor = class {
  1804. constructor(packet) {
  1805. this.packet = packet;
  1806. this.buffers = [];
  1807. this.reconPack = packet;
  1808. }
  1809. takeBinaryData(binData) {
  1810. this.buffers.push(binData);
  1811. if (this.buffers.length === this.reconPack.attachments) {
  1812. const packet = reconstructPacket(this.reconPack, this.buffers);
  1813. this.finishedReconstruction();
  1814. return packet;
  1815. }
  1816. return null;
  1817. }
  1818. finishedReconstruction() {
  1819. this.reconPack = null;
  1820. this.buffers = [];
  1821. }
  1822. };
  1823. // ../../../../Newweb/starter/node_modules/socket.io-client/build/esm/on.js
  1824. function on(obj, ev, fn) {
  1825. obj.on(ev, fn);
  1826. return function subDestroy() {
  1827. obj.off(ev, fn);
  1828. };
  1829. }
  1830. // ../../../../Newweb/starter/node_modules/socket.io-client/build/esm/socket.js
  1831. var RESERVED_EVENTS2 = Object.freeze({
  1832. connect: 1,
  1833. connect_error: 1,
  1834. disconnect: 1,
  1835. disconnecting: 1,
  1836. newListener: 1,
  1837. removeListener: 1
  1838. });
  1839. var Socket2 = class extends Emitter {
  1840. constructor(io, nsp, opts) {
  1841. super();
  1842. this.connected = false;
  1843. this.recovered = false;
  1844. this.receiveBuffer = [];
  1845. this.sendBuffer = [];
  1846. this._queue = [];
  1847. this._queueSeq = 0;
  1848. this.ids = 0;
  1849. this.acks = {};
  1850. this.flags = {};
  1851. this.io = io;
  1852. this.nsp = nsp;
  1853. if (opts && opts.auth) {
  1854. this.auth = opts.auth;
  1855. }
  1856. this._opts = Object.assign({}, opts);
  1857. if (this.io._autoConnect)
  1858. this.open();
  1859. }
  1860. get disconnected() {
  1861. return !this.connected;
  1862. }
  1863. subEvents() {
  1864. if (this.subs)
  1865. return;
  1866. const io = this.io;
  1867. this.subs = [
  1868. on(io, "open", this.onopen.bind(this)),
  1869. on(io, "packet", this.onpacket.bind(this)),
  1870. on(io, "error", this.onerror.bind(this)),
  1871. on(io, "close", this.onclose.bind(this))
  1872. ];
  1873. }
  1874. get active() {
  1875. return !!this.subs;
  1876. }
  1877. connect() {
  1878. if (this.connected)
  1879. return this;
  1880. this.subEvents();
  1881. if (!this.io["_reconnecting"])
  1882. this.io.open();
  1883. if (this.io._readyState === "open")
  1884. this.onopen();
  1885. return this;
  1886. }
  1887. open() {
  1888. return this.connect();
  1889. }
  1890. send(...args) {
  1891. args.unshift("message");
  1892. this.emit.apply(this, args);
  1893. return this;
  1894. }
  1895. emit(ev, ...args) {
  1896. var _a, _b, _c;
  1897. if (RESERVED_EVENTS2.hasOwnProperty(ev)) {
  1898. throw new Error('"' + ev.toString() + '" is a reserved event name');
  1899. }
  1900. args.unshift(ev);
  1901. if (this._opts.retries && !this.flags.fromQueue && !this.flags.volatile) {
  1902. this._addToQueue(args);
  1903. return this;
  1904. }
  1905. const packet = {
  1906. type: PacketType.EVENT,
  1907. data: args
  1908. };
  1909. packet.options = {};
  1910. packet.options.compress = this.flags.compress !== false;
  1911. if (typeof args[args.length - 1] === "function") {
  1912. const id = this.ids++;
  1913. const ack = args.pop();
  1914. this._registerAckCallback(id, ack);
  1915. packet.id = id;
  1916. }
  1917. const isTransportWritable = (_b = (_a = this.io.engine) === null || _a === void 0 ? void 0 : _a.transport) === null || _b === void 0 ? void 0 : _b.writable;
  1918. const isConnected = this.connected && !((_c = this.io.engine) === null || _c === void 0 ? void 0 : _c._hasPingExpired());
  1919. const discardPacket = this.flags.volatile && !isTransportWritable;
  1920. if (discardPacket) {
  1921. } else if (isConnected) {
  1922. this.notifyOutgoingListeners(packet);
  1923. this.packet(packet);
  1924. } else {
  1925. this.sendBuffer.push(packet);
  1926. }
  1927. this.flags = {};
  1928. return this;
  1929. }
  1930. _registerAckCallback(id, ack) {
  1931. var _a;
  1932. const timeout = (_a = this.flags.timeout) !== null && _a !== void 0 ? _a : this._opts.ackTimeout;
  1933. if (timeout === void 0) {
  1934. this.acks[id] = ack;
  1935. return;
  1936. }
  1937. const timer = this.io.setTimeoutFn(() => {
  1938. delete this.acks[id];
  1939. for (let i = 0; i < this.sendBuffer.length; i++) {
  1940. if (this.sendBuffer[i].id === id) {
  1941. this.sendBuffer.splice(i, 1);
  1942. }
  1943. }
  1944. ack.call(this, new Error("operation has timed out"));
  1945. }, timeout);
  1946. const fn = (...args) => {
  1947. this.io.clearTimeoutFn(timer);
  1948. ack.apply(this, args);
  1949. };
  1950. fn.withError = true;
  1951. this.acks[id] = fn;
  1952. }
  1953. emitWithAck(ev, ...args) {
  1954. return new Promise((resolve, reject) => {
  1955. const fn = (arg1, arg2) => {
  1956. return arg1 ? reject(arg1) : resolve(arg2);
  1957. };
  1958. fn.withError = true;
  1959. args.push(fn);
  1960. this.emit(ev, ...args);
  1961. });
  1962. }
  1963. _addToQueue(args) {
  1964. let ack;
  1965. if (typeof args[args.length - 1] === "function") {
  1966. ack = args.pop();
  1967. }
  1968. const packet = {
  1969. id: this._queueSeq++,
  1970. tryCount: 0,
  1971. pending: false,
  1972. args,
  1973. flags: Object.assign({ fromQueue: true }, this.flags)
  1974. };
  1975. args.push((err, ...responseArgs) => {
  1976. if (packet !== this._queue[0]) {
  1977. return;
  1978. }
  1979. const hasError = err !== null;
  1980. if (hasError) {
  1981. if (packet.tryCount > this._opts.retries) {
  1982. this._queue.shift();
  1983. if (ack) {
  1984. ack(err);
  1985. }
  1986. }
  1987. } else {
  1988. this._queue.shift();
  1989. if (ack) {
  1990. ack(null, ...responseArgs);
  1991. }
  1992. }
  1993. packet.pending = false;
  1994. return this._drainQueue();
  1995. });
  1996. this._queue.push(packet);
  1997. this._drainQueue();
  1998. }
  1999. _drainQueue(force = false) {
  2000. if (!this.connected || this._queue.length === 0) {
  2001. return;
  2002. }
  2003. const packet = this._queue[0];
  2004. if (packet.pending && !force) {
  2005. return;
  2006. }
  2007. packet.pending = true;
  2008. packet.tryCount++;
  2009. this.flags = packet.flags;
  2010. this.emit.apply(this, packet.args);
  2011. }
  2012. packet(packet) {
  2013. packet.nsp = this.nsp;
  2014. this.io._packet(packet);
  2015. }
  2016. onopen() {
  2017. if (typeof this.auth == "function") {
  2018. this.auth((data) => {
  2019. this._sendConnectPacket(data);
  2020. });
  2021. } else {
  2022. this._sendConnectPacket(this.auth);
  2023. }
  2024. }
  2025. _sendConnectPacket(data) {
  2026. this.packet({
  2027. type: PacketType.CONNECT,
  2028. data: this._pid ? Object.assign({ pid: this._pid, offset: this._lastOffset }, data) : data
  2029. });
  2030. }
  2031. onerror(err) {
  2032. if (!this.connected) {
  2033. this.emitReserved("connect_error", err);
  2034. }
  2035. }
  2036. onclose(reason, description) {
  2037. this.connected = false;
  2038. delete this.id;
  2039. this.emitReserved("disconnect", reason, description);
  2040. this._clearAcks();
  2041. }
  2042. _clearAcks() {
  2043. Object.keys(this.acks).forEach((id) => {
  2044. const isBuffered = this.sendBuffer.some((packet) => String(packet.id) === id);
  2045. if (!isBuffered) {
  2046. const ack = this.acks[id];
  2047. delete this.acks[id];
  2048. if (ack.withError) {
  2049. ack.call(this, new Error("socket has been disconnected"));
  2050. }
  2051. }
  2052. });
  2053. }
  2054. onpacket(packet) {
  2055. const sameNamespace = packet.nsp === this.nsp;
  2056. if (!sameNamespace)
  2057. return;
  2058. switch (packet.type) {
  2059. case PacketType.CONNECT:
  2060. if (packet.data && packet.data.sid) {
  2061. this.onconnect(packet.data.sid, packet.data.pid);
  2062. } else {
  2063. this.emitReserved("connect_error", new Error("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/)"));
  2064. }
  2065. break;
  2066. case PacketType.EVENT:
  2067. case PacketType.BINARY_EVENT:
  2068. this.onevent(packet);
  2069. break;
  2070. case PacketType.ACK:
  2071. case PacketType.BINARY_ACK:
  2072. this.onack(packet);
  2073. break;
  2074. case PacketType.DISCONNECT:
  2075. this.ondisconnect();
  2076. break;
  2077. case PacketType.CONNECT_ERROR:
  2078. this.destroy();
  2079. const err = new Error(packet.data.message);
  2080. err.data = packet.data.data;
  2081. this.emitReserved("connect_error", err);
  2082. break;
  2083. }
  2084. }
  2085. onevent(packet) {
  2086. const args = packet.data || [];
  2087. if (packet.id != null) {
  2088. args.push(this.ack(packet.id));
  2089. }
  2090. if (this.connected) {
  2091. this.emitEvent(args);
  2092. } else {
  2093. this.receiveBuffer.push(Object.freeze(args));
  2094. }
  2095. }
  2096. emitEvent(args) {
  2097. if (this._anyListeners && this._anyListeners.length) {
  2098. const listeners = this._anyListeners.slice();
  2099. for (const listener of listeners) {
  2100. listener.apply(this, args);
  2101. }
  2102. }
  2103. super.emit.apply(this, args);
  2104. if (this._pid && args.length && typeof args[args.length - 1] === "string") {
  2105. this._lastOffset = args[args.length - 1];
  2106. }
  2107. }
  2108. ack(id) {
  2109. const self2 = this;
  2110. let sent = false;
  2111. return function(...args) {
  2112. if (sent)
  2113. return;
  2114. sent = true;
  2115. self2.packet({
  2116. type: PacketType.ACK,
  2117. id,
  2118. data: args
  2119. });
  2120. };
  2121. }
  2122. onack(packet) {
  2123. const ack = this.acks[packet.id];
  2124. if (typeof ack !== "function") {
  2125. return;
  2126. }
  2127. delete this.acks[packet.id];
  2128. if (ack.withError) {
  2129. packet.data.unshift(null);
  2130. }
  2131. ack.apply(this, packet.data);
  2132. }
  2133. onconnect(id, pid) {
  2134. this.id = id;
  2135. this.recovered = pid && this._pid === pid;
  2136. this._pid = pid;
  2137. this.connected = true;
  2138. this.emitBuffered();
  2139. this.emitReserved("connect");
  2140. this._drainQueue(true);
  2141. }
  2142. emitBuffered() {
  2143. this.receiveBuffer.forEach((args) => this.emitEvent(args));
  2144. this.receiveBuffer = [];
  2145. this.sendBuffer.forEach((packet) => {
  2146. this.notifyOutgoingListeners(packet);
  2147. this.packet(packet);
  2148. });
  2149. this.sendBuffer = [];
  2150. }
  2151. ondisconnect() {
  2152. this.destroy();
  2153. this.onclose("io server disconnect");
  2154. }
  2155. destroy() {
  2156. if (this.subs) {
  2157. this.subs.forEach((subDestroy) => subDestroy());
  2158. this.subs = void 0;
  2159. }
  2160. this.io["_destroy"](this);
  2161. }
  2162. disconnect() {
  2163. if (this.connected) {
  2164. this.packet({ type: PacketType.DISCONNECT });
  2165. }
  2166. this.destroy();
  2167. if (this.connected) {
  2168. this.onclose("io client disconnect");
  2169. }
  2170. return this;
  2171. }
  2172. close() {
  2173. return this.disconnect();
  2174. }
  2175. compress(compress) {
  2176. this.flags.compress = compress;
  2177. return this;
  2178. }
  2179. get volatile() {
  2180. this.flags.volatile = true;
  2181. return this;
  2182. }
  2183. timeout(timeout) {
  2184. this.flags.timeout = timeout;
  2185. return this;
  2186. }
  2187. onAny(listener) {
  2188. this._anyListeners = this._anyListeners || [];
  2189. this._anyListeners.push(listener);
  2190. return this;
  2191. }
  2192. prependAny(listener) {
  2193. this._anyListeners = this._anyListeners || [];
  2194. this._anyListeners.unshift(listener);
  2195. return this;
  2196. }
  2197. offAny(listener) {
  2198. if (!this._anyListeners) {
  2199. return this;
  2200. }
  2201. if (listener) {
  2202. const listeners = this._anyListeners;
  2203. for (let i = 0; i < listeners.length; i++) {
  2204. if (listener === listeners[i]) {
  2205. listeners.splice(i, 1);
  2206. return this;
  2207. }
  2208. }
  2209. } else {
  2210. this._anyListeners = [];
  2211. }
  2212. return this;
  2213. }
  2214. listenersAny() {
  2215. return this._anyListeners || [];
  2216. }
  2217. onAnyOutgoing(listener) {
  2218. this._anyOutgoingListeners = this._anyOutgoingListeners || [];
  2219. this._anyOutgoingListeners.push(listener);
  2220. return this;
  2221. }
  2222. prependAnyOutgoing(listener) {
  2223. this._anyOutgoingListeners = this._anyOutgoingListeners || [];
  2224. this._anyOutgoingListeners.unshift(listener);
  2225. return this;
  2226. }
  2227. offAnyOutgoing(listener) {
  2228. if (!this._anyOutgoingListeners) {
  2229. return this;
  2230. }
  2231. if (listener) {
  2232. const listeners = this._anyOutgoingListeners;
  2233. for (let i = 0; i < listeners.length; i++) {
  2234. if (listener === listeners[i]) {
  2235. listeners.splice(i, 1);
  2236. return this;
  2237. }
  2238. }
  2239. } else {
  2240. this._anyOutgoingListeners = [];
  2241. }
  2242. return this;
  2243. }
  2244. listenersAnyOutgoing() {
  2245. return this._anyOutgoingListeners || [];
  2246. }
  2247. notifyOutgoingListeners(packet) {
  2248. if (this._anyOutgoingListeners && this._anyOutgoingListeners.length) {
  2249. const listeners = this._anyOutgoingListeners.slice();
  2250. for (const listener of listeners) {
  2251. listener.apply(this, packet.data);
  2252. }
  2253. }
  2254. }
  2255. };
  2256. // ../../../../Newweb/starter/node_modules/socket.io-client/build/esm/contrib/backo2.js
  2257. function Backoff(opts) {
  2258. opts = opts || {};
  2259. this.ms = opts.min || 100;
  2260. this.max = opts.max || 1e4;
  2261. this.factor = opts.factor || 2;
  2262. this.jitter = opts.jitter > 0 && opts.jitter <= 1 ? opts.jitter : 0;
  2263. this.attempts = 0;
  2264. }
  2265. Backoff.prototype.duration = function() {
  2266. var ms = this.ms * Math.pow(this.factor, this.attempts++);
  2267. if (this.jitter) {
  2268. var rand = Math.random();
  2269. var deviation = Math.floor(rand * this.jitter * ms);
  2270. ms = (Math.floor(rand * 10) & 1) == 0 ? ms - deviation : ms + deviation;
  2271. }
  2272. return Math.min(ms, this.max) | 0;
  2273. };
  2274. Backoff.prototype.reset = function() {
  2275. this.attempts = 0;
  2276. };
  2277. Backoff.prototype.setMin = function(min) {
  2278. this.ms = min;
  2279. };
  2280. Backoff.prototype.setMax = function(max) {
  2281. this.max = max;
  2282. };
  2283. Backoff.prototype.setJitter = function(jitter) {
  2284. this.jitter = jitter;
  2285. };
  2286. // ../../../../Newweb/starter/node_modules/socket.io-client/build/esm/manager.js
  2287. var Manager = class extends Emitter {
  2288. constructor(uri, opts) {
  2289. var _a;
  2290. super();
  2291. this.nsps = {};
  2292. this.subs = [];
  2293. if (uri && typeof uri === "object") {
  2294. opts = uri;
  2295. uri = void 0;
  2296. }
  2297. opts = opts || {};
  2298. opts.path = opts.path || "/socket.io";
  2299. this.opts = opts;
  2300. installTimerFunctions(this, opts);
  2301. this.reconnection(opts.reconnection !== false);
  2302. this.reconnectionAttempts(opts.reconnectionAttempts || Infinity);
  2303. this.reconnectionDelay(opts.reconnectionDelay || 1e3);
  2304. this.reconnectionDelayMax(opts.reconnectionDelayMax || 5e3);
  2305. this.randomizationFactor((_a = opts.randomizationFactor) !== null && _a !== void 0 ? _a : 0.5);
  2306. this.backoff = new Backoff({
  2307. min: this.reconnectionDelay(),
  2308. max: this.reconnectionDelayMax(),
  2309. jitter: this.randomizationFactor()
  2310. });
  2311. this.timeout(opts.timeout == null ? 2e4 : opts.timeout);
  2312. this._readyState = "closed";
  2313. this.uri = uri;
  2314. const _parser = opts.parser || esm_exports;
  2315. this.encoder = new _parser.Encoder();
  2316. this.decoder = new _parser.Decoder();
  2317. this._autoConnect = opts.autoConnect !== false;
  2318. if (this._autoConnect)
  2319. this.open();
  2320. }
  2321. reconnection(v) {
  2322. if (!arguments.length)
  2323. return this._reconnection;
  2324. this._reconnection = !!v;
  2325. if (!v) {
  2326. this.skipReconnect = true;
  2327. }
  2328. return this;
  2329. }
  2330. reconnectionAttempts(v) {
  2331. if (v === void 0)
  2332. return this._reconnectionAttempts;
  2333. this._reconnectionAttempts = v;
  2334. return this;
  2335. }
  2336. reconnectionDelay(v) {
  2337. var _a;
  2338. if (v === void 0)
  2339. return this._reconnectionDelay;
  2340. this._reconnectionDelay = v;
  2341. (_a = this.backoff) === null || _a === void 0 ? void 0 : _a.setMin(v);
  2342. return this;
  2343. }
  2344. randomizationFactor(v) {
  2345. var _a;
  2346. if (v === void 0)
  2347. return this._randomizationFactor;
  2348. this._randomizationFactor = v;
  2349. (_a = this.backoff) === null || _a === void 0 ? void 0 : _a.setJitter(v);
  2350. return this;
  2351. }
  2352. reconnectionDelayMax(v) {
  2353. var _a;
  2354. if (v === void 0)
  2355. return this._reconnectionDelayMax;
  2356. this._reconnectionDelayMax = v;
  2357. (_a = this.backoff) === null || _a === void 0 ? void 0 : _a.setMax(v);
  2358. return this;
  2359. }
  2360. timeout(v) {
  2361. if (!arguments.length)
  2362. return this._timeout;
  2363. this._timeout = v;
  2364. return this;
  2365. }
  2366. maybeReconnectOnOpen() {
  2367. if (!this._reconnecting && this._reconnection && this.backoff.attempts === 0) {
  2368. this.reconnect();
  2369. }
  2370. }
  2371. open(fn) {
  2372. if (~this._readyState.indexOf("open"))
  2373. return this;
  2374. this.engine = new Socket(this.uri, this.opts);
  2375. const socket = this.engine;
  2376. const self2 = this;
  2377. this._readyState = "opening";
  2378. this.skipReconnect = false;
  2379. const openSubDestroy = on(socket, "open", function() {
  2380. self2.onopen();
  2381. fn && fn();
  2382. });
  2383. const onError = (err) => {
  2384. this.cleanup();
  2385. this._readyState = "closed";
  2386. this.emitReserved("error", err);
  2387. if (fn) {
  2388. fn(err);
  2389. } else {
  2390. this.maybeReconnectOnOpen();
  2391. }
  2392. };
  2393. const errorSub = on(socket, "error", onError);
  2394. if (this._timeout !== false) {
  2395. const timeout = this._timeout;
  2396. const timer = this.setTimeoutFn(() => {
  2397. openSubDestroy();
  2398. onError(new Error("timeout"));
  2399. socket.close();
  2400. }, timeout);
  2401. if (this.opts.autoUnref) {
  2402. timer.unref();
  2403. }
  2404. this.subs.push(() => {
  2405. this.clearTimeoutFn(timer);
  2406. });
  2407. }
  2408. this.subs.push(openSubDestroy);
  2409. this.subs.push(errorSub);
  2410. return this;
  2411. }
  2412. connect(fn) {
  2413. return this.open(fn);
  2414. }
  2415. onopen() {
  2416. this.cleanup();
  2417. this._readyState = "open";
  2418. this.emitReserved("open");
  2419. const socket = this.engine;
  2420. this.subs.push(on(socket, "ping", this.onping.bind(this)), on(socket, "data", this.ondata.bind(this)), on(socket, "error", this.onerror.bind(this)), on(socket, "close", this.onclose.bind(this)), on(this.decoder, "decoded", this.ondecoded.bind(this)));
  2421. }
  2422. onping() {
  2423. this.emitReserved("ping");
  2424. }
  2425. ondata(data) {
  2426. try {
  2427. this.decoder.add(data);
  2428. } catch (e) {
  2429. this.onclose("parse error", e);
  2430. }
  2431. }
  2432. ondecoded(packet) {
  2433. nextTick(() => {
  2434. this.emitReserved("packet", packet);
  2435. }, this.setTimeoutFn);
  2436. }
  2437. onerror(err) {
  2438. this.emitReserved("error", err);
  2439. }
  2440. socket(nsp, opts) {
  2441. let socket = this.nsps[nsp];
  2442. if (!socket) {
  2443. socket = new Socket2(this, nsp, opts);
  2444. this.nsps[nsp] = socket;
  2445. } else if (this._autoConnect && !socket.active) {
  2446. socket.connect();
  2447. }
  2448. return socket;
  2449. }
  2450. _destroy(socket) {
  2451. const nsps = Object.keys(this.nsps);
  2452. for (const nsp of nsps) {
  2453. const socket2 = this.nsps[nsp];
  2454. if (socket2.active) {
  2455. return;
  2456. }
  2457. }
  2458. this._close();
  2459. }
  2460. _packet(packet) {
  2461. const encodedPackets = this.encoder.encode(packet);
  2462. for (let i = 0; i < encodedPackets.length; i++) {
  2463. this.engine.write(encodedPackets[i], packet.options);
  2464. }
  2465. }
  2466. cleanup() {
  2467. this.subs.forEach((subDestroy) => subDestroy());
  2468. this.subs.length = 0;
  2469. this.decoder.destroy();
  2470. }
  2471. _close() {
  2472. this.skipReconnect = true;
  2473. this._reconnecting = false;
  2474. this.onclose("forced close");
  2475. }
  2476. disconnect() {
  2477. return this._close();
  2478. }
  2479. onclose(reason, description) {
  2480. var _a;
  2481. this.cleanup();
  2482. (_a = this.engine) === null || _a === void 0 ? void 0 : _a.close();
  2483. this.backoff.reset();
  2484. this._readyState = "closed";
  2485. this.emitReserved("close", reason, description);
  2486. if (this._reconnection && !this.skipReconnect) {
  2487. this.reconnect();
  2488. }
  2489. }
  2490. reconnect() {
  2491. if (this._reconnecting || this.skipReconnect)
  2492. return this;
  2493. const self2 = this;
  2494. if (this.backoff.attempts >= this._reconnectionAttempts) {
  2495. this.backoff.reset();
  2496. this.emitReserved("reconnect_failed");
  2497. this._reconnecting = false;
  2498. } else {
  2499. const delay = this.backoff.duration();
  2500. this._reconnecting = true;
  2501. const timer = this.setTimeoutFn(() => {
  2502. if (self2.skipReconnect)
  2503. return;
  2504. this.emitReserved("reconnect_attempt", self2.backoff.attempts);
  2505. if (self2.skipReconnect)
  2506. return;
  2507. self2.open((err) => {
  2508. if (err) {
  2509. self2._reconnecting = false;
  2510. self2.reconnect();
  2511. this.emitReserved("reconnect_error", err);
  2512. } else {
  2513. self2.onreconnect();
  2514. }
  2515. });
  2516. }, delay);
  2517. if (this.opts.autoUnref) {
  2518. timer.unref();
  2519. }
  2520. this.subs.push(() => {
  2521. this.clearTimeoutFn(timer);
  2522. });
  2523. }
  2524. }
  2525. onreconnect() {
  2526. const attempt = this.backoff.attempts;
  2527. this._reconnecting = false;
  2528. this.backoff.reset();
  2529. this.emitReserved("reconnect", attempt);
  2530. }
  2531. };
  2532. // ../../../../Newweb/starter/node_modules/socket.io-client/build/esm/index.js
  2533. var cache = {};
  2534. function lookup2(uri, opts) {
  2535. if (typeof uri === "object") {
  2536. opts = uri;
  2537. uri = void 0;
  2538. }
  2539. opts = opts || {};
  2540. const parsed = url(uri, opts.path || "/socket.io");
  2541. const source = parsed.source;
  2542. const id = parsed.id;
  2543. const path = parsed.path;
  2544. const sameNamespace = cache[id] && path in cache[id]["nsps"];
  2545. const newConnection = opts.forceNew || opts["force new connection"] || opts.multiplex === false || sameNamespace;
  2546. let io;
  2547. if (newConnection) {
  2548. io = new Manager(source, opts);
  2549. } else {
  2550. if (!cache[id]) {
  2551. cache[id] = new Manager(source, opts);
  2552. }
  2553. io = cache[id];
  2554. }
  2555. if (parsed.query && !opts.query) {
  2556. opts.query = parsed.queryKey;
  2557. }
  2558. return io.socket(parsed.path, opts);
  2559. }
  2560. Object.assign(lookup2, {
  2561. Manager,
  2562. Socket: Socket2,
  2563. io: lookup2,
  2564. connect: lookup2
  2565. });
  2566. // dep:socket_io-client
  2567. var socket_io_client_default = lookup2;
  2568. export {
  2569. Manager,
  2570. Socket2 as Socket,
  2571. lookup2 as connect,
  2572. socket_io_client_default as default,
  2573. lookup2 as io,
  2574. protocol3 as protocol
  2575. };
  2576. //# sourceMappingURL=socket_io-client.js.map