@waku/core 0.0.9 → 0.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/CHANGELOG.md +78 -2
  2. package/bundle/browser-2f1afe46.js +726 -0
  3. package/bundle/index.js +9166 -12074
  4. package/bundle/lib/base_protocol.js +108 -0
  5. package/bundle/lib/message/topic_only_message.js +3 -2
  6. package/bundle/lib/message/version_0.js +3 -2
  7. package/bundle/peer_exchange-1229c8b0.js +4302 -0
  8. package/bundle/{topic_only_message-ece0fef9.js → topic_only_message-e8406994.js} +12 -8
  9. package/bundle/{version_0-b1fc527d.js → version_0-e9a6cfb0.js} +35 -35
  10. package/dist/.tsbuildinfo +1 -0
  11. package/dist/index.d.ts +4 -1
  12. package/dist/index.js +3 -1
  13. package/dist/index.js.map +1 -1
  14. package/dist/lib/base_protocol.d.ts +21 -0
  15. package/dist/lib/base_protocol.js +33 -0
  16. package/dist/lib/base_protocol.js.map +1 -0
  17. package/dist/lib/connection_manager.d.ts +31 -0
  18. package/dist/lib/connection_manager.js +146 -0
  19. package/dist/lib/connection_manager.js.map +1 -0
  20. package/dist/lib/filter/filter_rpc.d.ts +8 -8
  21. package/dist/lib/filter/filter_rpc.js +6 -6
  22. package/dist/lib/filter/index.d.ts +5 -22
  23. package/dist/lib/filter/index.js +31 -86
  24. package/dist/lib/filter/index.js.map +1 -1
  25. package/dist/lib/group_by.d.ts +1 -1
  26. package/dist/lib/group_by.js.map +1 -1
  27. package/dist/lib/keep_alive_manager.d.ts +17 -0
  28. package/dist/lib/keep_alive_manager.js +62 -0
  29. package/dist/lib/keep_alive_manager.js.map +1 -0
  30. package/dist/lib/light_push/index.d.ts +3 -19
  31. package/dist/lib/light_push/index.js +13 -39
  32. package/dist/lib/light_push/index.js.map +1 -1
  33. package/dist/lib/light_push/push_rpc.d.ts +5 -5
  34. package/dist/lib/light_push/push_rpc.js +6 -6
  35. package/dist/lib/message/topic_only_message.d.ts +5 -3
  36. package/dist/lib/message/topic_only_message.js +8 -5
  37. package/dist/lib/message/topic_only_message.js.map +1 -1
  38. package/dist/lib/message/version_0.d.ts +12 -12
  39. package/dist/lib/message/version_0.js +29 -30
  40. package/dist/lib/message/version_0.js.map +1 -1
  41. package/dist/lib/predefined_bootstrap_nodes.js +1 -1
  42. package/dist/lib/predefined_bootstrap_nodes.js.map +1 -1
  43. package/dist/lib/relay/index.d.ts +4 -18
  44. package/dist/lib/relay/index.js +47 -26
  45. package/dist/lib/relay/index.js.map +1 -1
  46. package/dist/lib/relay/message_validator.d.ts +4 -0
  47. package/dist/lib/relay/message_validator.js +25 -0
  48. package/dist/lib/relay/message_validator.js.map +1 -0
  49. package/dist/lib/store/history_rpc.d.ts +4 -4
  50. package/dist/lib/store/history_rpc.js +9 -9
  51. package/dist/lib/store/history_rpc.js.map +1 -1
  52. package/dist/lib/store/index.d.ts +4 -25
  53. package/dist/lib/store/index.js +20 -37
  54. package/dist/lib/store/index.js.map +1 -1
  55. package/dist/lib/to_proto_message.js +3 -2
  56. package/dist/lib/to_proto_message.js.map +1 -1
  57. package/dist/lib/wait_for_remote_peer.js +12 -23
  58. package/dist/lib/wait_for_remote_peer.js.map +1 -1
  59. package/dist/lib/waku.d.ts +8 -15
  60. package/dist/lib/waku.js +34 -97
  61. package/dist/lib/waku.js.map +1 -1
  62. package/package.json +50 -61
  63. package/src/index.ts +11 -3
  64. package/src/lib/base_protocol.ts +47 -0
  65. package/src/lib/connection_manager.ts +220 -0
  66. package/src/lib/filter/filter_rpc.ts +10 -10
  67. package/src/lib/filter/index.ts +52 -147
  68. package/src/lib/group_by.ts +1 -1
  69. package/src/lib/keep_alive_manager.ts +89 -0
  70. package/src/lib/light_push/index.ts +17 -78
  71. package/src/lib/light_push/push_rpc.ts +9 -9
  72. package/src/lib/message/topic_only_message.ts +11 -5
  73. package/src/lib/message/version_0.ts +42 -37
  74. package/src/lib/predefined_bootstrap_nodes.ts +1 -1
  75. package/src/lib/relay/index.ts +77 -52
  76. package/src/lib/relay/message_validator.ts +35 -0
  77. package/src/lib/store/history_rpc.ts +12 -12
  78. package/src/lib/store/index.ts +30 -84
  79. package/src/lib/to_proto_message.ts +3 -2
  80. package/src/lib/wait_for_remote_peer.ts +13 -29
  81. package/src/lib/waku.ts +54 -136
  82. package/bundle/peer_exchange-53df2b11.js +0 -11824
  83. package/dist/lib/random_subset.d.ts +0 -4
  84. package/dist/lib/random_subset.js +0 -25
  85. package/dist/lib/random_subset.js.map +0 -1
  86. package/src/lib/random_subset.ts +0 -30
@@ -0,0 +1,4302 @@
1
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
2
+
3
+ function getDefaultExportFromCjs (x) {
4
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
5
+ }
6
+
7
+ function getAugmentedNamespace(n) {
8
+ if (n.__esModule) return n;
9
+ var f = n.default;
10
+ if (typeof f == "function") {
11
+ var a = function a () {
12
+ if (this instanceof a) {
13
+ var args = [null];
14
+ args.push.apply(args, arguments);
15
+ var Ctor = Function.bind.apply(f, args);
16
+ return new Ctor();
17
+ }
18
+ return f.apply(this, arguments);
19
+ };
20
+ a.prototype = f.prototype;
21
+ } else a = {};
22
+ Object.defineProperty(a, '__esModule', {value: true});
23
+ Object.keys(n).forEach(function (k) {
24
+ var d = Object.getOwnPropertyDescriptor(n, k);
25
+ Object.defineProperty(a, k, d.get ? d : {
26
+ enumerable: true,
27
+ get: function () {
28
+ return n[k];
29
+ }
30
+ });
31
+ });
32
+ return a;
33
+ }
34
+
35
+ var minimal = {};
36
+
37
+ var aspromise = asPromise;
38
+
39
+ /**
40
+ * Callback as used by {@link util.asPromise}.
41
+ * @typedef asPromiseCallback
42
+ * @type {function}
43
+ * @param {Error|null} error Error, if any
44
+ * @param {...*} params Additional arguments
45
+ * @returns {undefined}
46
+ */
47
+
48
+ /**
49
+ * Returns a promise from a node-style callback function.
50
+ * @memberof util
51
+ * @param {asPromiseCallback} fn Function to call
52
+ * @param {*} ctx Function context
53
+ * @param {...*} params Function arguments
54
+ * @returns {Promise<*>} Promisified function
55
+ */
56
+ function asPromise(fn, ctx/*, varargs */) {
57
+ var params = new Array(arguments.length - 1),
58
+ offset = 0,
59
+ index = 2,
60
+ pending = true;
61
+ while (index < arguments.length)
62
+ params[offset++] = arguments[index++];
63
+ return new Promise(function executor(resolve, reject) {
64
+ params[offset] = function callback(err/*, varargs */) {
65
+ if (pending) {
66
+ pending = false;
67
+ if (err)
68
+ reject(err);
69
+ else {
70
+ var params = new Array(arguments.length - 1),
71
+ offset = 0;
72
+ while (offset < params.length)
73
+ params[offset++] = arguments[offset];
74
+ resolve.apply(null, params);
75
+ }
76
+ }
77
+ };
78
+ try {
79
+ fn.apply(ctx || null, params);
80
+ } catch (err) {
81
+ if (pending) {
82
+ pending = false;
83
+ reject(err);
84
+ }
85
+ }
86
+ });
87
+ }
88
+
89
+ var base64$1 = {};
90
+
91
+ (function (exports) {
92
+
93
+ /**
94
+ * A minimal base64 implementation for number arrays.
95
+ * @memberof util
96
+ * @namespace
97
+ */
98
+ var base64 = exports;
99
+
100
+ /**
101
+ * Calculates the byte length of a base64 encoded string.
102
+ * @param {string} string Base64 encoded string
103
+ * @returns {number} Byte length
104
+ */
105
+ base64.length = function length(string) {
106
+ var p = string.length;
107
+ if (!p)
108
+ return 0;
109
+ var n = 0;
110
+ while (--p % 4 > 1 && string.charAt(p) === "=")
111
+ ++n;
112
+ return Math.ceil(string.length * 3) / 4 - n;
113
+ };
114
+
115
+ // Base64 encoding table
116
+ var b64 = new Array(64);
117
+
118
+ // Base64 decoding table
119
+ var s64 = new Array(123);
120
+
121
+ // 65..90, 97..122, 48..57, 43, 47
122
+ for (var i = 0; i < 64;)
123
+ s64[b64[i] = i < 26 ? i + 65 : i < 52 ? i + 71 : i < 62 ? i - 4 : i - 59 | 43] = i++;
124
+
125
+ /**
126
+ * Encodes a buffer to a base64 encoded string.
127
+ * @param {Uint8Array} buffer Source buffer
128
+ * @param {number} start Source start
129
+ * @param {number} end Source end
130
+ * @returns {string} Base64 encoded string
131
+ */
132
+ base64.encode = function encode(buffer, start, end) {
133
+ var parts = null,
134
+ chunk = [];
135
+ var i = 0, // output index
136
+ j = 0, // goto index
137
+ t; // temporary
138
+ while (start < end) {
139
+ var b = buffer[start++];
140
+ switch (j) {
141
+ case 0:
142
+ chunk[i++] = b64[b >> 2];
143
+ t = (b & 3) << 4;
144
+ j = 1;
145
+ break;
146
+ case 1:
147
+ chunk[i++] = b64[t | b >> 4];
148
+ t = (b & 15) << 2;
149
+ j = 2;
150
+ break;
151
+ case 2:
152
+ chunk[i++] = b64[t | b >> 6];
153
+ chunk[i++] = b64[b & 63];
154
+ j = 0;
155
+ break;
156
+ }
157
+ if (i > 8191) {
158
+ (parts || (parts = [])).push(String.fromCharCode.apply(String, chunk));
159
+ i = 0;
160
+ }
161
+ }
162
+ if (j) {
163
+ chunk[i++] = b64[t];
164
+ chunk[i++] = 61;
165
+ if (j === 1)
166
+ chunk[i++] = 61;
167
+ }
168
+ if (parts) {
169
+ if (i)
170
+ parts.push(String.fromCharCode.apply(String, chunk.slice(0, i)));
171
+ return parts.join("");
172
+ }
173
+ return String.fromCharCode.apply(String, chunk.slice(0, i));
174
+ };
175
+
176
+ var invalidEncoding = "invalid encoding";
177
+
178
+ /**
179
+ * Decodes a base64 encoded string to a buffer.
180
+ * @param {string} string Source string
181
+ * @param {Uint8Array} buffer Destination buffer
182
+ * @param {number} offset Destination offset
183
+ * @returns {number} Number of bytes written
184
+ * @throws {Error} If encoding is invalid
185
+ */
186
+ base64.decode = function decode(string, buffer, offset) {
187
+ var start = offset;
188
+ var j = 0, // goto index
189
+ t; // temporary
190
+ for (var i = 0; i < string.length;) {
191
+ var c = string.charCodeAt(i++);
192
+ if (c === 61 && j > 1)
193
+ break;
194
+ if ((c = s64[c]) === undefined)
195
+ throw Error(invalidEncoding);
196
+ switch (j) {
197
+ case 0:
198
+ t = c;
199
+ j = 1;
200
+ break;
201
+ case 1:
202
+ buffer[offset++] = t << 2 | (c & 48) >> 4;
203
+ t = c;
204
+ j = 2;
205
+ break;
206
+ case 2:
207
+ buffer[offset++] = (t & 15) << 4 | (c & 60) >> 2;
208
+ t = c;
209
+ j = 3;
210
+ break;
211
+ case 3:
212
+ buffer[offset++] = (t & 3) << 6 | c;
213
+ j = 0;
214
+ break;
215
+ }
216
+ }
217
+ if (j === 1)
218
+ throw Error(invalidEncoding);
219
+ return offset - start;
220
+ };
221
+
222
+ /**
223
+ * Tests if the specified string appears to be base64 encoded.
224
+ * @param {string} string String to test
225
+ * @returns {boolean} `true` if probably base64 encoded, otherwise false
226
+ */
227
+ base64.test = function test(string) {
228
+ return /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(string);
229
+ };
230
+ } (base64$1));
231
+
232
+ var eventemitter = EventEmitter;
233
+
234
+ /**
235
+ * Constructs a new event emitter instance.
236
+ * @classdesc A minimal event emitter.
237
+ * @memberof util
238
+ * @constructor
239
+ */
240
+ function EventEmitter() {
241
+
242
+ /**
243
+ * Registered listeners.
244
+ * @type {Object.<string,*>}
245
+ * @private
246
+ */
247
+ this._listeners = {};
248
+ }
249
+
250
+ /**
251
+ * Registers an event listener.
252
+ * @param {string} evt Event name
253
+ * @param {function} fn Listener
254
+ * @param {*} [ctx] Listener context
255
+ * @returns {util.EventEmitter} `this`
256
+ */
257
+ EventEmitter.prototype.on = function on(evt, fn, ctx) {
258
+ (this._listeners[evt] || (this._listeners[evt] = [])).push({
259
+ fn : fn,
260
+ ctx : ctx || this
261
+ });
262
+ return this;
263
+ };
264
+
265
+ /**
266
+ * Removes an event listener or any matching listeners if arguments are omitted.
267
+ * @param {string} [evt] Event name. Removes all listeners if omitted.
268
+ * @param {function} [fn] Listener to remove. Removes all listeners of `evt` if omitted.
269
+ * @returns {util.EventEmitter} `this`
270
+ */
271
+ EventEmitter.prototype.off = function off(evt, fn) {
272
+ if (evt === undefined)
273
+ this._listeners = {};
274
+ else {
275
+ if (fn === undefined)
276
+ this._listeners[evt] = [];
277
+ else {
278
+ var listeners = this._listeners[evt];
279
+ for (var i = 0; i < listeners.length;)
280
+ if (listeners[i].fn === fn)
281
+ listeners.splice(i, 1);
282
+ else
283
+ ++i;
284
+ }
285
+ }
286
+ return this;
287
+ };
288
+
289
+ /**
290
+ * Emits an event by calling its listeners with the specified arguments.
291
+ * @param {string} evt Event name
292
+ * @param {...*} args Arguments
293
+ * @returns {util.EventEmitter} `this`
294
+ */
295
+ EventEmitter.prototype.emit = function emit(evt) {
296
+ var listeners = this._listeners[evt];
297
+ if (listeners) {
298
+ var args = [],
299
+ i = 1;
300
+ for (; i < arguments.length;)
301
+ args.push(arguments[i++]);
302
+ for (i = 0; i < listeners.length;)
303
+ listeners[i].fn.apply(listeners[i++].ctx, args);
304
+ }
305
+ return this;
306
+ };
307
+
308
+ var float = factory(factory);
309
+
310
+ /**
311
+ * Reads / writes floats / doubles from / to buffers.
312
+ * @name util.float
313
+ * @namespace
314
+ */
315
+
316
+ /**
317
+ * Writes a 32 bit float to a buffer using little endian byte order.
318
+ * @name util.float.writeFloatLE
319
+ * @function
320
+ * @param {number} val Value to write
321
+ * @param {Uint8Array} buf Target buffer
322
+ * @param {number} pos Target buffer offset
323
+ * @returns {undefined}
324
+ */
325
+
326
+ /**
327
+ * Writes a 32 bit float to a buffer using big endian byte order.
328
+ * @name util.float.writeFloatBE
329
+ * @function
330
+ * @param {number} val Value to write
331
+ * @param {Uint8Array} buf Target buffer
332
+ * @param {number} pos Target buffer offset
333
+ * @returns {undefined}
334
+ */
335
+
336
+ /**
337
+ * Reads a 32 bit float from a buffer using little endian byte order.
338
+ * @name util.float.readFloatLE
339
+ * @function
340
+ * @param {Uint8Array} buf Source buffer
341
+ * @param {number} pos Source buffer offset
342
+ * @returns {number} Value read
343
+ */
344
+
345
+ /**
346
+ * Reads a 32 bit float from a buffer using big endian byte order.
347
+ * @name util.float.readFloatBE
348
+ * @function
349
+ * @param {Uint8Array} buf Source buffer
350
+ * @param {number} pos Source buffer offset
351
+ * @returns {number} Value read
352
+ */
353
+
354
+ /**
355
+ * Writes a 64 bit double to a buffer using little endian byte order.
356
+ * @name util.float.writeDoubleLE
357
+ * @function
358
+ * @param {number} val Value to write
359
+ * @param {Uint8Array} buf Target buffer
360
+ * @param {number} pos Target buffer offset
361
+ * @returns {undefined}
362
+ */
363
+
364
+ /**
365
+ * Writes a 64 bit double to a buffer using big endian byte order.
366
+ * @name util.float.writeDoubleBE
367
+ * @function
368
+ * @param {number} val Value to write
369
+ * @param {Uint8Array} buf Target buffer
370
+ * @param {number} pos Target buffer offset
371
+ * @returns {undefined}
372
+ */
373
+
374
+ /**
375
+ * Reads a 64 bit double from a buffer using little endian byte order.
376
+ * @name util.float.readDoubleLE
377
+ * @function
378
+ * @param {Uint8Array} buf Source buffer
379
+ * @param {number} pos Source buffer offset
380
+ * @returns {number} Value read
381
+ */
382
+
383
+ /**
384
+ * Reads a 64 bit double from a buffer using big endian byte order.
385
+ * @name util.float.readDoubleBE
386
+ * @function
387
+ * @param {Uint8Array} buf Source buffer
388
+ * @param {number} pos Source buffer offset
389
+ * @returns {number} Value read
390
+ */
391
+
392
+ // Factory function for the purpose of node-based testing in modified global environments
393
+ function factory(exports) {
394
+
395
+ // float: typed array
396
+ if (typeof Float32Array !== "undefined") (function() {
397
+
398
+ var f32 = new Float32Array([ -0 ]),
399
+ f8b = new Uint8Array(f32.buffer),
400
+ le = f8b[3] === 128;
401
+
402
+ function writeFloat_f32_cpy(val, buf, pos) {
403
+ f32[0] = val;
404
+ buf[pos ] = f8b[0];
405
+ buf[pos + 1] = f8b[1];
406
+ buf[pos + 2] = f8b[2];
407
+ buf[pos + 3] = f8b[3];
408
+ }
409
+
410
+ function writeFloat_f32_rev(val, buf, pos) {
411
+ f32[0] = val;
412
+ buf[pos ] = f8b[3];
413
+ buf[pos + 1] = f8b[2];
414
+ buf[pos + 2] = f8b[1];
415
+ buf[pos + 3] = f8b[0];
416
+ }
417
+
418
+ /* istanbul ignore next */
419
+ exports.writeFloatLE = le ? writeFloat_f32_cpy : writeFloat_f32_rev;
420
+ /* istanbul ignore next */
421
+ exports.writeFloatBE = le ? writeFloat_f32_rev : writeFloat_f32_cpy;
422
+
423
+ function readFloat_f32_cpy(buf, pos) {
424
+ f8b[0] = buf[pos ];
425
+ f8b[1] = buf[pos + 1];
426
+ f8b[2] = buf[pos + 2];
427
+ f8b[3] = buf[pos + 3];
428
+ return f32[0];
429
+ }
430
+
431
+ function readFloat_f32_rev(buf, pos) {
432
+ f8b[3] = buf[pos ];
433
+ f8b[2] = buf[pos + 1];
434
+ f8b[1] = buf[pos + 2];
435
+ f8b[0] = buf[pos + 3];
436
+ return f32[0];
437
+ }
438
+
439
+ /* istanbul ignore next */
440
+ exports.readFloatLE = le ? readFloat_f32_cpy : readFloat_f32_rev;
441
+ /* istanbul ignore next */
442
+ exports.readFloatBE = le ? readFloat_f32_rev : readFloat_f32_cpy;
443
+
444
+ // float: ieee754
445
+ })(); else (function() {
446
+
447
+ function writeFloat_ieee754(writeUint, val, buf, pos) {
448
+ var sign = val < 0 ? 1 : 0;
449
+ if (sign)
450
+ val = -val;
451
+ if (val === 0)
452
+ writeUint(1 / val > 0 ? /* positive */ 0 : /* negative 0 */ 2147483648, buf, pos);
453
+ else if (isNaN(val))
454
+ writeUint(2143289344, buf, pos);
455
+ else if (val > 3.4028234663852886e+38) // +-Infinity
456
+ writeUint((sign << 31 | 2139095040) >>> 0, buf, pos);
457
+ else if (val < 1.1754943508222875e-38) // denormal
458
+ writeUint((sign << 31 | Math.round(val / 1.401298464324817e-45)) >>> 0, buf, pos);
459
+ else {
460
+ var exponent = Math.floor(Math.log(val) / Math.LN2),
461
+ mantissa = Math.round(val * Math.pow(2, -exponent) * 8388608) & 8388607;
462
+ writeUint((sign << 31 | exponent + 127 << 23 | mantissa) >>> 0, buf, pos);
463
+ }
464
+ }
465
+
466
+ exports.writeFloatLE = writeFloat_ieee754.bind(null, writeUintLE);
467
+ exports.writeFloatBE = writeFloat_ieee754.bind(null, writeUintBE);
468
+
469
+ function readFloat_ieee754(readUint, buf, pos) {
470
+ var uint = readUint(buf, pos),
471
+ sign = (uint >> 31) * 2 + 1,
472
+ exponent = uint >>> 23 & 255,
473
+ mantissa = uint & 8388607;
474
+ return exponent === 255
475
+ ? mantissa
476
+ ? NaN
477
+ : sign * Infinity
478
+ : exponent === 0 // denormal
479
+ ? sign * 1.401298464324817e-45 * mantissa
480
+ : sign * Math.pow(2, exponent - 150) * (mantissa + 8388608);
481
+ }
482
+
483
+ exports.readFloatLE = readFloat_ieee754.bind(null, readUintLE);
484
+ exports.readFloatBE = readFloat_ieee754.bind(null, readUintBE);
485
+
486
+ })();
487
+
488
+ // double: typed array
489
+ if (typeof Float64Array !== "undefined") (function() {
490
+
491
+ var f64 = new Float64Array([-0]),
492
+ f8b = new Uint8Array(f64.buffer),
493
+ le = f8b[7] === 128;
494
+
495
+ function writeDouble_f64_cpy(val, buf, pos) {
496
+ f64[0] = val;
497
+ buf[pos ] = f8b[0];
498
+ buf[pos + 1] = f8b[1];
499
+ buf[pos + 2] = f8b[2];
500
+ buf[pos + 3] = f8b[3];
501
+ buf[pos + 4] = f8b[4];
502
+ buf[pos + 5] = f8b[5];
503
+ buf[pos + 6] = f8b[6];
504
+ buf[pos + 7] = f8b[7];
505
+ }
506
+
507
+ function writeDouble_f64_rev(val, buf, pos) {
508
+ f64[0] = val;
509
+ buf[pos ] = f8b[7];
510
+ buf[pos + 1] = f8b[6];
511
+ buf[pos + 2] = f8b[5];
512
+ buf[pos + 3] = f8b[4];
513
+ buf[pos + 4] = f8b[3];
514
+ buf[pos + 5] = f8b[2];
515
+ buf[pos + 6] = f8b[1];
516
+ buf[pos + 7] = f8b[0];
517
+ }
518
+
519
+ /* istanbul ignore next */
520
+ exports.writeDoubleLE = le ? writeDouble_f64_cpy : writeDouble_f64_rev;
521
+ /* istanbul ignore next */
522
+ exports.writeDoubleBE = le ? writeDouble_f64_rev : writeDouble_f64_cpy;
523
+
524
+ function readDouble_f64_cpy(buf, pos) {
525
+ f8b[0] = buf[pos ];
526
+ f8b[1] = buf[pos + 1];
527
+ f8b[2] = buf[pos + 2];
528
+ f8b[3] = buf[pos + 3];
529
+ f8b[4] = buf[pos + 4];
530
+ f8b[5] = buf[pos + 5];
531
+ f8b[6] = buf[pos + 6];
532
+ f8b[7] = buf[pos + 7];
533
+ return f64[0];
534
+ }
535
+
536
+ function readDouble_f64_rev(buf, pos) {
537
+ f8b[7] = buf[pos ];
538
+ f8b[6] = buf[pos + 1];
539
+ f8b[5] = buf[pos + 2];
540
+ f8b[4] = buf[pos + 3];
541
+ f8b[3] = buf[pos + 4];
542
+ f8b[2] = buf[pos + 5];
543
+ f8b[1] = buf[pos + 6];
544
+ f8b[0] = buf[pos + 7];
545
+ return f64[0];
546
+ }
547
+
548
+ /* istanbul ignore next */
549
+ exports.readDoubleLE = le ? readDouble_f64_cpy : readDouble_f64_rev;
550
+ /* istanbul ignore next */
551
+ exports.readDoubleBE = le ? readDouble_f64_rev : readDouble_f64_cpy;
552
+
553
+ // double: ieee754
554
+ })(); else (function() {
555
+
556
+ function writeDouble_ieee754(writeUint, off0, off1, val, buf, pos) {
557
+ var sign = val < 0 ? 1 : 0;
558
+ if (sign)
559
+ val = -val;
560
+ if (val === 0) {
561
+ writeUint(0, buf, pos + off0);
562
+ writeUint(1 / val > 0 ? /* positive */ 0 : /* negative 0 */ 2147483648, buf, pos + off1);
563
+ } else if (isNaN(val)) {
564
+ writeUint(0, buf, pos + off0);
565
+ writeUint(2146959360, buf, pos + off1);
566
+ } else if (val > 1.7976931348623157e+308) { // +-Infinity
567
+ writeUint(0, buf, pos + off0);
568
+ writeUint((sign << 31 | 2146435072) >>> 0, buf, pos + off1);
569
+ } else {
570
+ var mantissa;
571
+ if (val < 2.2250738585072014e-308) { // denormal
572
+ mantissa = val / 5e-324;
573
+ writeUint(mantissa >>> 0, buf, pos + off0);
574
+ writeUint((sign << 31 | mantissa / 4294967296) >>> 0, buf, pos + off1);
575
+ } else {
576
+ var exponent = Math.floor(Math.log(val) / Math.LN2);
577
+ if (exponent === 1024)
578
+ exponent = 1023;
579
+ mantissa = val * Math.pow(2, -exponent);
580
+ writeUint(mantissa * 4503599627370496 >>> 0, buf, pos + off0);
581
+ writeUint((sign << 31 | exponent + 1023 << 20 | mantissa * 1048576 & 1048575) >>> 0, buf, pos + off1);
582
+ }
583
+ }
584
+ }
585
+
586
+ exports.writeDoubleLE = writeDouble_ieee754.bind(null, writeUintLE, 0, 4);
587
+ exports.writeDoubleBE = writeDouble_ieee754.bind(null, writeUintBE, 4, 0);
588
+
589
+ function readDouble_ieee754(readUint, off0, off1, buf, pos) {
590
+ var lo = readUint(buf, pos + off0),
591
+ hi = readUint(buf, pos + off1);
592
+ var sign = (hi >> 31) * 2 + 1,
593
+ exponent = hi >>> 20 & 2047,
594
+ mantissa = 4294967296 * (hi & 1048575) + lo;
595
+ return exponent === 2047
596
+ ? mantissa
597
+ ? NaN
598
+ : sign * Infinity
599
+ : exponent === 0 // denormal
600
+ ? sign * 5e-324 * mantissa
601
+ : sign * Math.pow(2, exponent - 1075) * (mantissa + 4503599627370496);
602
+ }
603
+
604
+ exports.readDoubleLE = readDouble_ieee754.bind(null, readUintLE, 0, 4);
605
+ exports.readDoubleBE = readDouble_ieee754.bind(null, readUintBE, 4, 0);
606
+
607
+ })();
608
+
609
+ return exports;
610
+ }
611
+
612
+ // uint helpers
613
+
614
+ function writeUintLE(val, buf, pos) {
615
+ buf[pos ] = val & 255;
616
+ buf[pos + 1] = val >>> 8 & 255;
617
+ buf[pos + 2] = val >>> 16 & 255;
618
+ buf[pos + 3] = val >>> 24;
619
+ }
620
+
621
+ function writeUintBE(val, buf, pos) {
622
+ buf[pos ] = val >>> 24;
623
+ buf[pos + 1] = val >>> 16 & 255;
624
+ buf[pos + 2] = val >>> 8 & 255;
625
+ buf[pos + 3] = val & 255;
626
+ }
627
+
628
+ function readUintLE(buf, pos) {
629
+ return (buf[pos ]
630
+ | buf[pos + 1] << 8
631
+ | buf[pos + 2] << 16
632
+ | buf[pos + 3] << 24) >>> 0;
633
+ }
634
+
635
+ function readUintBE(buf, pos) {
636
+ return (buf[pos ] << 24
637
+ | buf[pos + 1] << 16
638
+ | buf[pos + 2] << 8
639
+ | buf[pos + 3]) >>> 0;
640
+ }
641
+
642
+ var inquire_1 = inquire;
643
+
644
+ /**
645
+ * Requires a module only if available.
646
+ * @memberof util
647
+ * @param {string} moduleName Module to require
648
+ * @returns {?Object} Required module if available and not empty, otherwise `null`
649
+ */
650
+ function inquire(moduleName) {
651
+ try {
652
+ var mod = eval("quire".replace(/^/,"re"))(moduleName); // eslint-disable-line no-eval
653
+ if (mod && (mod.length || Object.keys(mod).length))
654
+ return mod;
655
+ } catch (e) {} // eslint-disable-line no-empty
656
+ return null;
657
+ }
658
+
659
+ var utf8$2 = {};
660
+
661
+ (function (exports) {
662
+
663
+ /**
664
+ * A minimal UTF8 implementation for number arrays.
665
+ * @memberof util
666
+ * @namespace
667
+ */
668
+ var utf8 = exports;
669
+
670
+ /**
671
+ * Calculates the UTF8 byte length of a string.
672
+ * @param {string} string String
673
+ * @returns {number} Byte length
674
+ */
675
+ utf8.length = function utf8_length(string) {
676
+ var len = 0,
677
+ c = 0;
678
+ for (var i = 0; i < string.length; ++i) {
679
+ c = string.charCodeAt(i);
680
+ if (c < 128)
681
+ len += 1;
682
+ else if (c < 2048)
683
+ len += 2;
684
+ else if ((c & 0xFC00) === 0xD800 && (string.charCodeAt(i + 1) & 0xFC00) === 0xDC00) {
685
+ ++i;
686
+ len += 4;
687
+ } else
688
+ len += 3;
689
+ }
690
+ return len;
691
+ };
692
+
693
+ /**
694
+ * Reads UTF8 bytes as a string.
695
+ * @param {Uint8Array} buffer Source buffer
696
+ * @param {number} start Source start
697
+ * @param {number} end Source end
698
+ * @returns {string} String read
699
+ */
700
+ utf8.read = function utf8_read(buffer, start, end) {
701
+ var len = end - start;
702
+ if (len < 1)
703
+ return "";
704
+ var parts = null,
705
+ chunk = [],
706
+ i = 0, // char offset
707
+ t; // temporary
708
+ while (start < end) {
709
+ t = buffer[start++];
710
+ if (t < 128)
711
+ chunk[i++] = t;
712
+ else if (t > 191 && t < 224)
713
+ chunk[i++] = (t & 31) << 6 | buffer[start++] & 63;
714
+ else if (t > 239 && t < 365) {
715
+ t = ((t & 7) << 18 | (buffer[start++] & 63) << 12 | (buffer[start++] & 63) << 6 | buffer[start++] & 63) - 0x10000;
716
+ chunk[i++] = 0xD800 + (t >> 10);
717
+ chunk[i++] = 0xDC00 + (t & 1023);
718
+ } else
719
+ chunk[i++] = (t & 15) << 12 | (buffer[start++] & 63) << 6 | buffer[start++] & 63;
720
+ if (i > 8191) {
721
+ (parts || (parts = [])).push(String.fromCharCode.apply(String, chunk));
722
+ i = 0;
723
+ }
724
+ }
725
+ if (parts) {
726
+ if (i)
727
+ parts.push(String.fromCharCode.apply(String, chunk.slice(0, i)));
728
+ return parts.join("");
729
+ }
730
+ return String.fromCharCode.apply(String, chunk.slice(0, i));
731
+ };
732
+
733
+ /**
734
+ * Writes a string as UTF8 bytes.
735
+ * @param {string} string Source string
736
+ * @param {Uint8Array} buffer Destination buffer
737
+ * @param {number} offset Destination offset
738
+ * @returns {number} Bytes written
739
+ */
740
+ utf8.write = function utf8_write(string, buffer, offset) {
741
+ var start = offset,
742
+ c1, // character 1
743
+ c2; // character 2
744
+ for (var i = 0; i < string.length; ++i) {
745
+ c1 = string.charCodeAt(i);
746
+ if (c1 < 128) {
747
+ buffer[offset++] = c1;
748
+ } else if (c1 < 2048) {
749
+ buffer[offset++] = c1 >> 6 | 192;
750
+ buffer[offset++] = c1 & 63 | 128;
751
+ } else if ((c1 & 0xFC00) === 0xD800 && ((c2 = string.charCodeAt(i + 1)) & 0xFC00) === 0xDC00) {
752
+ c1 = 0x10000 + ((c1 & 0x03FF) << 10) + (c2 & 0x03FF);
753
+ ++i;
754
+ buffer[offset++] = c1 >> 18 | 240;
755
+ buffer[offset++] = c1 >> 12 & 63 | 128;
756
+ buffer[offset++] = c1 >> 6 & 63 | 128;
757
+ buffer[offset++] = c1 & 63 | 128;
758
+ } else {
759
+ buffer[offset++] = c1 >> 12 | 224;
760
+ buffer[offset++] = c1 >> 6 & 63 | 128;
761
+ buffer[offset++] = c1 & 63 | 128;
762
+ }
763
+ }
764
+ return offset - start;
765
+ };
766
+ } (utf8$2));
767
+
768
+ var pool_1 = pool;
769
+
770
+ /**
771
+ * An allocator as used by {@link util.pool}.
772
+ * @typedef PoolAllocator
773
+ * @type {function}
774
+ * @param {number} size Buffer size
775
+ * @returns {Uint8Array} Buffer
776
+ */
777
+
778
+ /**
779
+ * A slicer as used by {@link util.pool}.
780
+ * @typedef PoolSlicer
781
+ * @type {function}
782
+ * @param {number} start Start offset
783
+ * @param {number} end End offset
784
+ * @returns {Uint8Array} Buffer slice
785
+ * @this {Uint8Array}
786
+ */
787
+
788
+ /**
789
+ * A general purpose buffer pool.
790
+ * @memberof util
791
+ * @function
792
+ * @param {PoolAllocator} alloc Allocator
793
+ * @param {PoolSlicer} slice Slicer
794
+ * @param {number} [size=8192] Slab size
795
+ * @returns {PoolAllocator} Pooled allocator
796
+ */
797
+ function pool(alloc, slice, size) {
798
+ var SIZE = size || 8192;
799
+ var MAX = SIZE >>> 1;
800
+ var slab = null;
801
+ var offset = SIZE;
802
+ return function pool_alloc(size) {
803
+ if (size < 1 || size > MAX)
804
+ return alloc(size);
805
+ if (offset + size > SIZE) {
806
+ slab = alloc(SIZE);
807
+ offset = 0;
808
+ }
809
+ var buf = slice.call(slab, offset, offset += size);
810
+ if (offset & 7) // align to 32 bit
811
+ offset = (offset | 7) + 1;
812
+ return buf;
813
+ };
814
+ }
815
+
816
+ var longbits;
817
+ var hasRequiredLongbits;
818
+
819
+ function requireLongbits () {
820
+ if (hasRequiredLongbits) return longbits;
821
+ hasRequiredLongbits = 1;
822
+ longbits = LongBits;
823
+
824
+ var util = requireMinimal();
825
+
826
+ /**
827
+ * Constructs new long bits.
828
+ * @classdesc Helper class for working with the low and high bits of a 64 bit value.
829
+ * @memberof util
830
+ * @constructor
831
+ * @param {number} lo Low 32 bits, unsigned
832
+ * @param {number} hi High 32 bits, unsigned
833
+ */
834
+ function LongBits(lo, hi) {
835
+
836
+ // note that the casts below are theoretically unnecessary as of today, but older statically
837
+ // generated converter code might still call the ctor with signed 32bits. kept for compat.
838
+
839
+ /**
840
+ * Low bits.
841
+ * @type {number}
842
+ */
843
+ this.lo = lo >>> 0;
844
+
845
+ /**
846
+ * High bits.
847
+ * @type {number}
848
+ */
849
+ this.hi = hi >>> 0;
850
+ }
851
+
852
+ /**
853
+ * Zero bits.
854
+ * @memberof util.LongBits
855
+ * @type {util.LongBits}
856
+ */
857
+ var zero = LongBits.zero = new LongBits(0, 0);
858
+
859
+ zero.toNumber = function() { return 0; };
860
+ zero.zzEncode = zero.zzDecode = function() { return this; };
861
+ zero.length = function() { return 1; };
862
+
863
+ /**
864
+ * Zero hash.
865
+ * @memberof util.LongBits
866
+ * @type {string}
867
+ */
868
+ var zeroHash = LongBits.zeroHash = "\0\0\0\0\0\0\0\0";
869
+
870
+ /**
871
+ * Constructs new long bits from the specified number.
872
+ * @param {number} value Value
873
+ * @returns {util.LongBits} Instance
874
+ */
875
+ LongBits.fromNumber = function fromNumber(value) {
876
+ if (value === 0)
877
+ return zero;
878
+ var sign = value < 0;
879
+ if (sign)
880
+ value = -value;
881
+ var lo = value >>> 0,
882
+ hi = (value - lo) / 4294967296 >>> 0;
883
+ if (sign) {
884
+ hi = ~hi >>> 0;
885
+ lo = ~lo >>> 0;
886
+ if (++lo > 4294967295) {
887
+ lo = 0;
888
+ if (++hi > 4294967295)
889
+ hi = 0;
890
+ }
891
+ }
892
+ return new LongBits(lo, hi);
893
+ };
894
+
895
+ /**
896
+ * Constructs new long bits from a number, long or string.
897
+ * @param {Long|number|string} value Value
898
+ * @returns {util.LongBits} Instance
899
+ */
900
+ LongBits.from = function from(value) {
901
+ if (typeof value === "number")
902
+ return LongBits.fromNumber(value);
903
+ if (util.isString(value)) {
904
+ /* istanbul ignore else */
905
+ if (util.Long)
906
+ value = util.Long.fromString(value);
907
+ else
908
+ return LongBits.fromNumber(parseInt(value, 10));
909
+ }
910
+ return value.low || value.high ? new LongBits(value.low >>> 0, value.high >>> 0) : zero;
911
+ };
912
+
913
+ /**
914
+ * Converts this long bits to a possibly unsafe JavaScript number.
915
+ * @param {boolean} [unsigned=false] Whether unsigned or not
916
+ * @returns {number} Possibly unsafe number
917
+ */
918
+ LongBits.prototype.toNumber = function toNumber(unsigned) {
919
+ if (!unsigned && this.hi >>> 31) {
920
+ var lo = ~this.lo + 1 >>> 0,
921
+ hi = ~this.hi >>> 0;
922
+ if (!lo)
923
+ hi = hi + 1 >>> 0;
924
+ return -(lo + hi * 4294967296);
925
+ }
926
+ return this.lo + this.hi * 4294967296;
927
+ };
928
+
929
+ /**
930
+ * Converts this long bits to a long.
931
+ * @param {boolean} [unsigned=false] Whether unsigned or not
932
+ * @returns {Long} Long
933
+ */
934
+ LongBits.prototype.toLong = function toLong(unsigned) {
935
+ return util.Long
936
+ ? new util.Long(this.lo | 0, this.hi | 0, Boolean(unsigned))
937
+ /* istanbul ignore next */
938
+ : { low: this.lo | 0, high: this.hi | 0, unsigned: Boolean(unsigned) };
939
+ };
940
+
941
+ var charCodeAt = String.prototype.charCodeAt;
942
+
943
+ /**
944
+ * Constructs new long bits from the specified 8 characters long hash.
945
+ * @param {string} hash Hash
946
+ * @returns {util.LongBits} Bits
947
+ */
948
+ LongBits.fromHash = function fromHash(hash) {
949
+ if (hash === zeroHash)
950
+ return zero;
951
+ return new LongBits(
952
+ ( charCodeAt.call(hash, 0)
953
+ | charCodeAt.call(hash, 1) << 8
954
+ | charCodeAt.call(hash, 2) << 16
955
+ | charCodeAt.call(hash, 3) << 24) >>> 0
956
+ ,
957
+ ( charCodeAt.call(hash, 4)
958
+ | charCodeAt.call(hash, 5) << 8
959
+ | charCodeAt.call(hash, 6) << 16
960
+ | charCodeAt.call(hash, 7) << 24) >>> 0
961
+ );
962
+ };
963
+
964
+ /**
965
+ * Converts this long bits to a 8 characters long hash.
966
+ * @returns {string} Hash
967
+ */
968
+ LongBits.prototype.toHash = function toHash() {
969
+ return String.fromCharCode(
970
+ this.lo & 255,
971
+ this.lo >>> 8 & 255,
972
+ this.lo >>> 16 & 255,
973
+ this.lo >>> 24 ,
974
+ this.hi & 255,
975
+ this.hi >>> 8 & 255,
976
+ this.hi >>> 16 & 255,
977
+ this.hi >>> 24
978
+ );
979
+ };
980
+
981
+ /**
982
+ * Zig-zag encodes this long bits.
983
+ * @returns {util.LongBits} `this`
984
+ */
985
+ LongBits.prototype.zzEncode = function zzEncode() {
986
+ var mask = this.hi >> 31;
987
+ this.hi = ((this.hi << 1 | this.lo >>> 31) ^ mask) >>> 0;
988
+ this.lo = ( this.lo << 1 ^ mask) >>> 0;
989
+ return this;
990
+ };
991
+
992
+ /**
993
+ * Zig-zag decodes this long bits.
994
+ * @returns {util.LongBits} `this`
995
+ */
996
+ LongBits.prototype.zzDecode = function zzDecode() {
997
+ var mask = -(this.lo & 1);
998
+ this.lo = ((this.lo >>> 1 | this.hi << 31) ^ mask) >>> 0;
999
+ this.hi = ( this.hi >>> 1 ^ mask) >>> 0;
1000
+ return this;
1001
+ };
1002
+
1003
+ /**
1004
+ * Calculates the length of this longbits when encoded as a varint.
1005
+ * @returns {number} Length
1006
+ */
1007
+ LongBits.prototype.length = function length() {
1008
+ var part0 = this.lo,
1009
+ part1 = (this.lo >>> 28 | this.hi << 4) >>> 0,
1010
+ part2 = this.hi >>> 24;
1011
+ return part2 === 0
1012
+ ? part1 === 0
1013
+ ? part0 < 16384
1014
+ ? part0 < 128 ? 1 : 2
1015
+ : part0 < 2097152 ? 3 : 4
1016
+ : part1 < 16384
1017
+ ? part1 < 128 ? 5 : 6
1018
+ : part1 < 2097152 ? 7 : 8
1019
+ : part2 < 128 ? 9 : 10;
1020
+ };
1021
+ return longbits;
1022
+ }
1023
+
1024
+ var hasRequiredMinimal;
1025
+
1026
+ function requireMinimal () {
1027
+ if (hasRequiredMinimal) return minimal;
1028
+ hasRequiredMinimal = 1;
1029
+ (function (exports) {
1030
+ var util = exports;
1031
+
1032
+ // used to return a Promise where callback is omitted
1033
+ util.asPromise = aspromise;
1034
+
1035
+ // converts to / from base64 encoded strings
1036
+ util.base64 = base64$1;
1037
+
1038
+ // base class of rpc.Service
1039
+ util.EventEmitter = eventemitter;
1040
+
1041
+ // float handling accross browsers
1042
+ util.float = float;
1043
+
1044
+ // requires modules optionally and hides the call from bundlers
1045
+ util.inquire = inquire_1;
1046
+
1047
+ // converts to / from utf8 encoded strings
1048
+ util.utf8 = utf8$2;
1049
+
1050
+ // provides a node-like buffer pool in the browser
1051
+ util.pool = pool_1;
1052
+
1053
+ // utility to work with the low and high bits of a 64 bit value
1054
+ util.LongBits = requireLongbits();
1055
+
1056
+ /**
1057
+ * Whether running within node or not.
1058
+ * @memberof util
1059
+ * @type {boolean}
1060
+ */
1061
+ util.isNode = Boolean(typeof commonjsGlobal !== "undefined"
1062
+ && commonjsGlobal
1063
+ && commonjsGlobal.process
1064
+ && commonjsGlobal.process.versions
1065
+ && commonjsGlobal.process.versions.node);
1066
+
1067
+ /**
1068
+ * Global object reference.
1069
+ * @memberof util
1070
+ * @type {Object}
1071
+ */
1072
+ util.global = util.isNode && commonjsGlobal
1073
+ || typeof window !== "undefined" && window
1074
+ || typeof self !== "undefined" && self
1075
+ || commonjsGlobal; // eslint-disable-line no-invalid-this
1076
+
1077
+ /**
1078
+ * An immuable empty array.
1079
+ * @memberof util
1080
+ * @type {Array.<*>}
1081
+ * @const
1082
+ */
1083
+ util.emptyArray = Object.freeze ? Object.freeze([]) : /* istanbul ignore next */ []; // used on prototypes
1084
+
1085
+ /**
1086
+ * An immutable empty object.
1087
+ * @type {Object}
1088
+ * @const
1089
+ */
1090
+ util.emptyObject = Object.freeze ? Object.freeze({}) : /* istanbul ignore next */ {}; // used on prototypes
1091
+
1092
+ /**
1093
+ * Tests if the specified value is an integer.
1094
+ * @function
1095
+ * @param {*} value Value to test
1096
+ * @returns {boolean} `true` if the value is an integer
1097
+ */
1098
+ util.isInteger = Number.isInteger || /* istanbul ignore next */ function isInteger(value) {
1099
+ return typeof value === "number" && isFinite(value) && Math.floor(value) === value;
1100
+ };
1101
+
1102
+ /**
1103
+ * Tests if the specified value is a string.
1104
+ * @param {*} value Value to test
1105
+ * @returns {boolean} `true` if the value is a string
1106
+ */
1107
+ util.isString = function isString(value) {
1108
+ return typeof value === "string" || value instanceof String;
1109
+ };
1110
+
1111
+ /**
1112
+ * Tests if the specified value is a non-null object.
1113
+ * @param {*} value Value to test
1114
+ * @returns {boolean} `true` if the value is a non-null object
1115
+ */
1116
+ util.isObject = function isObject(value) {
1117
+ return value && typeof value === "object";
1118
+ };
1119
+
1120
+ /**
1121
+ * Checks if a property on a message is considered to be present.
1122
+ * This is an alias of {@link util.isSet}.
1123
+ * @function
1124
+ * @param {Object} obj Plain object or message instance
1125
+ * @param {string} prop Property name
1126
+ * @returns {boolean} `true` if considered to be present, otherwise `false`
1127
+ */
1128
+ util.isset =
1129
+
1130
+ /**
1131
+ * Checks if a property on a message is considered to be present.
1132
+ * @param {Object} obj Plain object or message instance
1133
+ * @param {string} prop Property name
1134
+ * @returns {boolean} `true` if considered to be present, otherwise `false`
1135
+ */
1136
+ util.isSet = function isSet(obj, prop) {
1137
+ var value = obj[prop];
1138
+ if (value != null && obj.hasOwnProperty(prop)) // eslint-disable-line eqeqeq, no-prototype-builtins
1139
+ return typeof value !== "object" || (Array.isArray(value) ? value.length : Object.keys(value).length) > 0;
1140
+ return false;
1141
+ };
1142
+
1143
+ /**
1144
+ * Any compatible Buffer instance.
1145
+ * This is a minimal stand-alone definition of a Buffer instance. The actual type is that exported by node's typings.
1146
+ * @interface Buffer
1147
+ * @extends Uint8Array
1148
+ */
1149
+
1150
+ /**
1151
+ * Node's Buffer class if available.
1152
+ * @type {Constructor<Buffer>}
1153
+ */
1154
+ util.Buffer = (function() {
1155
+ try {
1156
+ var Buffer = util.inquire("buffer").Buffer;
1157
+ // refuse to use non-node buffers if not explicitly assigned (perf reasons):
1158
+ return Buffer.prototype.utf8Write ? Buffer : /* istanbul ignore next */ null;
1159
+ } catch (e) {
1160
+ /* istanbul ignore next */
1161
+ return null;
1162
+ }
1163
+ })();
1164
+
1165
+ // Internal alias of or polyfull for Buffer.from.
1166
+ util._Buffer_from = null;
1167
+
1168
+ // Internal alias of or polyfill for Buffer.allocUnsafe.
1169
+ util._Buffer_allocUnsafe = null;
1170
+
1171
+ /**
1172
+ * Creates a new buffer of whatever type supported by the environment.
1173
+ * @param {number|number[]} [sizeOrArray=0] Buffer size or number array
1174
+ * @returns {Uint8Array|Buffer} Buffer
1175
+ */
1176
+ util.newBuffer = function newBuffer(sizeOrArray) {
1177
+ /* istanbul ignore next */
1178
+ return typeof sizeOrArray === "number"
1179
+ ? util.Buffer
1180
+ ? util._Buffer_allocUnsafe(sizeOrArray)
1181
+ : new util.Array(sizeOrArray)
1182
+ : util.Buffer
1183
+ ? util._Buffer_from(sizeOrArray)
1184
+ : typeof Uint8Array === "undefined"
1185
+ ? sizeOrArray
1186
+ : new Uint8Array(sizeOrArray);
1187
+ };
1188
+
1189
+ /**
1190
+ * Array implementation used in the browser. `Uint8Array` if supported, otherwise `Array`.
1191
+ * @type {Constructor<Uint8Array>}
1192
+ */
1193
+ util.Array = typeof Uint8Array !== "undefined" ? Uint8Array /* istanbul ignore next */ : Array;
1194
+
1195
+ /**
1196
+ * Any compatible Long instance.
1197
+ * This is a minimal stand-alone definition of a Long instance. The actual type is that exported by long.js.
1198
+ * @interface Long
1199
+ * @property {number} low Low bits
1200
+ * @property {number} high High bits
1201
+ * @property {boolean} unsigned Whether unsigned or not
1202
+ */
1203
+
1204
+ /**
1205
+ * Long.js's Long class if available.
1206
+ * @type {Constructor<Long>}
1207
+ */
1208
+ util.Long = /* istanbul ignore next */ util.global.dcodeIO && /* istanbul ignore next */ util.global.dcodeIO.Long
1209
+ || /* istanbul ignore next */ util.global.Long
1210
+ || util.inquire("long");
1211
+
1212
+ /**
1213
+ * Regular expression used to verify 2 bit (`bool`) map keys.
1214
+ * @type {RegExp}
1215
+ * @const
1216
+ */
1217
+ util.key2Re = /^true|false|0|1$/;
1218
+
1219
+ /**
1220
+ * Regular expression used to verify 32 bit (`int32` etc.) map keys.
1221
+ * @type {RegExp}
1222
+ * @const
1223
+ */
1224
+ util.key32Re = /^-?(?:0|[1-9][0-9]*)$/;
1225
+
1226
+ /**
1227
+ * Regular expression used to verify 64 bit (`int64` etc.) map keys.
1228
+ * @type {RegExp}
1229
+ * @const
1230
+ */
1231
+ util.key64Re = /^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/;
1232
+
1233
+ /**
1234
+ * Converts a number or long to an 8 characters long hash string.
1235
+ * @param {Long|number} value Value to convert
1236
+ * @returns {string} Hash
1237
+ */
1238
+ util.longToHash = function longToHash(value) {
1239
+ return value
1240
+ ? util.LongBits.from(value).toHash()
1241
+ : util.LongBits.zeroHash;
1242
+ };
1243
+
1244
+ /**
1245
+ * Converts an 8 characters long hash string to a long or number.
1246
+ * @param {string} hash Hash
1247
+ * @param {boolean} [unsigned=false] Whether unsigned or not
1248
+ * @returns {Long|number} Original value
1249
+ */
1250
+ util.longFromHash = function longFromHash(hash, unsigned) {
1251
+ var bits = util.LongBits.fromHash(hash);
1252
+ if (util.Long)
1253
+ return util.Long.fromBits(bits.lo, bits.hi, unsigned);
1254
+ return bits.toNumber(Boolean(unsigned));
1255
+ };
1256
+
1257
+ /**
1258
+ * Merges the properties of the source object into the destination object.
1259
+ * @memberof util
1260
+ * @param {Object.<string,*>} dst Destination object
1261
+ * @param {Object.<string,*>} src Source object
1262
+ * @param {boolean} [ifNotSet=false] Merges only if the key is not already set
1263
+ * @returns {Object.<string,*>} Destination object
1264
+ */
1265
+ function merge(dst, src, ifNotSet) { // used by converters
1266
+ for (var keys = Object.keys(src), i = 0; i < keys.length; ++i)
1267
+ if (dst[keys[i]] === undefined || !ifNotSet)
1268
+ dst[keys[i]] = src[keys[i]];
1269
+ return dst;
1270
+ }
1271
+
1272
+ util.merge = merge;
1273
+
1274
+ /**
1275
+ * Converts the first character of a string to lower case.
1276
+ * @param {string} str String to convert
1277
+ * @returns {string} Converted string
1278
+ */
1279
+ util.lcFirst = function lcFirst(str) {
1280
+ return str.charAt(0).toLowerCase() + str.substring(1);
1281
+ };
1282
+
1283
+ /**
1284
+ * Creates a custom error constructor.
1285
+ * @memberof util
1286
+ * @param {string} name Error name
1287
+ * @returns {Constructor<Error>} Custom error constructor
1288
+ */
1289
+ function newError(name) {
1290
+
1291
+ function CustomError(message, properties) {
1292
+
1293
+ if (!(this instanceof CustomError))
1294
+ return new CustomError(message, properties);
1295
+
1296
+ // Error.call(this, message);
1297
+ // ^ just returns a new error instance because the ctor can be called as a function
1298
+
1299
+ Object.defineProperty(this, "message", { get: function() { return message; } });
1300
+
1301
+ /* istanbul ignore next */
1302
+ if (Error.captureStackTrace) // node
1303
+ Error.captureStackTrace(this, CustomError);
1304
+ else
1305
+ Object.defineProperty(this, "stack", { value: new Error().stack || "" });
1306
+
1307
+ if (properties)
1308
+ merge(this, properties);
1309
+ }
1310
+
1311
+ CustomError.prototype = Object.create(Error.prototype, {
1312
+ constructor: {
1313
+ value: CustomError,
1314
+ writable: true,
1315
+ enumerable: false,
1316
+ configurable: true,
1317
+ },
1318
+ name: {
1319
+ get: function get() { return name; },
1320
+ set: undefined,
1321
+ enumerable: false,
1322
+ // configurable: false would accurately preserve the behavior of
1323
+ // the original, but I'm guessing that was not intentional.
1324
+ // For an actual error subclass, this property would
1325
+ // be configurable.
1326
+ configurable: true,
1327
+ },
1328
+ toString: {
1329
+ value: function value() { return this.name + ": " + this.message; },
1330
+ writable: true,
1331
+ enumerable: false,
1332
+ configurable: true,
1333
+ },
1334
+ });
1335
+
1336
+ return CustomError;
1337
+ }
1338
+
1339
+ util.newError = newError;
1340
+
1341
+ /**
1342
+ * Constructs a new protocol error.
1343
+ * @classdesc Error subclass indicating a protocol specifc error.
1344
+ * @memberof util
1345
+ * @extends Error
1346
+ * @template T extends Message<T>
1347
+ * @constructor
1348
+ * @param {string} message Error message
1349
+ * @param {Object.<string,*>} [properties] Additional properties
1350
+ * @example
1351
+ * try {
1352
+ * MyMessage.decode(someBuffer); // throws if required fields are missing
1353
+ * } catch (e) {
1354
+ * if (e instanceof ProtocolError && e.instance)
1355
+ * console.log("decoded so far: " + JSON.stringify(e.instance));
1356
+ * }
1357
+ */
1358
+ util.ProtocolError = newError("ProtocolError");
1359
+
1360
+ /**
1361
+ * So far decoded message instance.
1362
+ * @name util.ProtocolError#instance
1363
+ * @type {Message<T>}
1364
+ */
1365
+
1366
+ /**
1367
+ * A OneOf getter as returned by {@link util.oneOfGetter}.
1368
+ * @typedef OneOfGetter
1369
+ * @type {function}
1370
+ * @returns {string|undefined} Set field name, if any
1371
+ */
1372
+
1373
+ /**
1374
+ * Builds a getter for a oneof's present field name.
1375
+ * @param {string[]} fieldNames Field names
1376
+ * @returns {OneOfGetter} Unbound getter
1377
+ */
1378
+ util.oneOfGetter = function getOneOf(fieldNames) {
1379
+ var fieldMap = {};
1380
+ for (var i = 0; i < fieldNames.length; ++i)
1381
+ fieldMap[fieldNames[i]] = 1;
1382
+
1383
+ /**
1384
+ * @returns {string|undefined} Set field name, if any
1385
+ * @this Object
1386
+ * @ignore
1387
+ */
1388
+ return function() { // eslint-disable-line consistent-return
1389
+ for (var keys = Object.keys(this), i = keys.length - 1; i > -1; --i)
1390
+ if (fieldMap[keys[i]] === 1 && this[keys[i]] !== undefined && this[keys[i]] !== null)
1391
+ return keys[i];
1392
+ };
1393
+ };
1394
+
1395
+ /**
1396
+ * A OneOf setter as returned by {@link util.oneOfSetter}.
1397
+ * @typedef OneOfSetter
1398
+ * @type {function}
1399
+ * @param {string|undefined} value Field name
1400
+ * @returns {undefined}
1401
+ */
1402
+
1403
+ /**
1404
+ * Builds a setter for a oneof's present field name.
1405
+ * @param {string[]} fieldNames Field names
1406
+ * @returns {OneOfSetter} Unbound setter
1407
+ */
1408
+ util.oneOfSetter = function setOneOf(fieldNames) {
1409
+
1410
+ /**
1411
+ * @param {string} name Field name
1412
+ * @returns {undefined}
1413
+ * @this Object
1414
+ * @ignore
1415
+ */
1416
+ return function(name) {
1417
+ for (var i = 0; i < fieldNames.length; ++i)
1418
+ if (fieldNames[i] !== name)
1419
+ delete this[fieldNames[i]];
1420
+ };
1421
+ };
1422
+
1423
+ /**
1424
+ * Default conversion options used for {@link Message#toJSON} implementations.
1425
+ *
1426
+ * These options are close to proto3's JSON mapping with the exception that internal types like Any are handled just like messages. More precisely:
1427
+ *
1428
+ * - Longs become strings
1429
+ * - Enums become string keys
1430
+ * - Bytes become base64 encoded strings
1431
+ * - (Sub-)Messages become plain objects
1432
+ * - Maps become plain objects with all string keys
1433
+ * - Repeated fields become arrays
1434
+ * - NaN and Infinity for float and double fields become strings
1435
+ *
1436
+ * @type {IConversionOptions}
1437
+ * @see https://developers.google.com/protocol-buffers/docs/proto3?hl=en#json
1438
+ */
1439
+ util.toJSONOptions = {
1440
+ longs: String,
1441
+ enums: String,
1442
+ bytes: String,
1443
+ json: true
1444
+ };
1445
+
1446
+ // Sets up buffer utility according to the environment (called in index-minimal)
1447
+ util._configure = function() {
1448
+ var Buffer = util.Buffer;
1449
+ /* istanbul ignore if */
1450
+ if (!Buffer) {
1451
+ util._Buffer_from = util._Buffer_allocUnsafe = null;
1452
+ return;
1453
+ }
1454
+ // because node 4.x buffers are incompatible & immutable
1455
+ // see: https://github.com/dcodeIO/protobuf.js/pull/665
1456
+ util._Buffer_from = Buffer.from !== Uint8Array.from && Buffer.from ||
1457
+ /* istanbul ignore next */
1458
+ function Buffer_from(value, encoding) {
1459
+ return new Buffer(value, encoding);
1460
+ };
1461
+ util._Buffer_allocUnsafe = Buffer.allocUnsafe ||
1462
+ /* istanbul ignore next */
1463
+ function Buffer_allocUnsafe(size) {
1464
+ return new Buffer(size);
1465
+ };
1466
+ };
1467
+ } (minimal));
1468
+ return minimal;
1469
+ }
1470
+
1471
+ var reader$1 = Reader$1;
1472
+
1473
+ var util$4 = requireMinimal();
1474
+
1475
+ var BufferReader$1; // cyclic
1476
+
1477
+ var LongBits$1 = util$4.LongBits,
1478
+ utf8$1 = util$4.utf8;
1479
+
1480
+ /* istanbul ignore next */
1481
+ function indexOutOfRange(reader, writeLength) {
1482
+ return RangeError("index out of range: " + reader.pos + " + " + (writeLength || 1) + " > " + reader.len);
1483
+ }
1484
+
1485
+ /**
1486
+ * Constructs a new reader instance using the specified buffer.
1487
+ * @classdesc Wire format reader using `Uint8Array` if available, otherwise `Array`.
1488
+ * @constructor
1489
+ * @param {Uint8Array} buffer Buffer to read from
1490
+ */
1491
+ function Reader$1(buffer) {
1492
+
1493
+ /**
1494
+ * Read buffer.
1495
+ * @type {Uint8Array}
1496
+ */
1497
+ this.buf = buffer;
1498
+
1499
+ /**
1500
+ * Read buffer position.
1501
+ * @type {number}
1502
+ */
1503
+ this.pos = 0;
1504
+
1505
+ /**
1506
+ * Read buffer length.
1507
+ * @type {number}
1508
+ */
1509
+ this.len = buffer.length;
1510
+ }
1511
+
1512
+ var create_array = typeof Uint8Array !== "undefined"
1513
+ ? function create_typed_array(buffer) {
1514
+ if (buffer instanceof Uint8Array || Array.isArray(buffer))
1515
+ return new Reader$1(buffer);
1516
+ throw Error("illegal buffer");
1517
+ }
1518
+ /* istanbul ignore next */
1519
+ : function create_array(buffer) {
1520
+ if (Array.isArray(buffer))
1521
+ return new Reader$1(buffer);
1522
+ throw Error("illegal buffer");
1523
+ };
1524
+
1525
+ var create$1 = function create() {
1526
+ return util$4.Buffer
1527
+ ? function create_buffer_setup(buffer) {
1528
+ return (Reader$1.create = function create_buffer(buffer) {
1529
+ return util$4.Buffer.isBuffer(buffer)
1530
+ ? new BufferReader$1(buffer)
1531
+ /* istanbul ignore next */
1532
+ : create_array(buffer);
1533
+ })(buffer);
1534
+ }
1535
+ /* istanbul ignore next */
1536
+ : create_array;
1537
+ };
1538
+
1539
+ /**
1540
+ * Creates a new reader using the specified buffer.
1541
+ * @function
1542
+ * @param {Uint8Array|Buffer} buffer Buffer to read from
1543
+ * @returns {Reader|BufferReader} A {@link BufferReader} if `buffer` is a Buffer, otherwise a {@link Reader}
1544
+ * @throws {Error} If `buffer` is not a valid buffer
1545
+ */
1546
+ Reader$1.create = create$1();
1547
+
1548
+ Reader$1.prototype._slice = util$4.Array.prototype.subarray || /* istanbul ignore next */ util$4.Array.prototype.slice;
1549
+
1550
+ /**
1551
+ * Reads a varint as an unsigned 32 bit value.
1552
+ * @function
1553
+ * @returns {number} Value read
1554
+ */
1555
+ Reader$1.prototype.uint32 = (function read_uint32_setup() {
1556
+ var value = 4294967295; // optimizer type-hint, tends to deopt otherwise (?!)
1557
+ return function read_uint32() {
1558
+ value = ( this.buf[this.pos] & 127 ) >>> 0; if (this.buf[this.pos++] < 128) return value;
1559
+ value = (value | (this.buf[this.pos] & 127) << 7) >>> 0; if (this.buf[this.pos++] < 128) return value;
1560
+ value = (value | (this.buf[this.pos] & 127) << 14) >>> 0; if (this.buf[this.pos++] < 128) return value;
1561
+ value = (value | (this.buf[this.pos] & 127) << 21) >>> 0; if (this.buf[this.pos++] < 128) return value;
1562
+ value = (value | (this.buf[this.pos] & 15) << 28) >>> 0; if (this.buf[this.pos++] < 128) return value;
1563
+
1564
+ /* istanbul ignore if */
1565
+ if ((this.pos += 5) > this.len) {
1566
+ this.pos = this.len;
1567
+ throw indexOutOfRange(this, 10);
1568
+ }
1569
+ return value;
1570
+ };
1571
+ })();
1572
+
1573
+ /**
1574
+ * Reads a varint as a signed 32 bit value.
1575
+ * @returns {number} Value read
1576
+ */
1577
+ Reader$1.prototype.int32 = function read_int32() {
1578
+ return this.uint32() | 0;
1579
+ };
1580
+
1581
+ /**
1582
+ * Reads a zig-zag encoded varint as a signed 32 bit value.
1583
+ * @returns {number} Value read
1584
+ */
1585
+ Reader$1.prototype.sint32 = function read_sint32() {
1586
+ var value = this.uint32();
1587
+ return value >>> 1 ^ -(value & 1) | 0;
1588
+ };
1589
+
1590
+ /* eslint-disable no-invalid-this */
1591
+
1592
+ function readLongVarint() {
1593
+ // tends to deopt with local vars for octet etc.
1594
+ var bits = new LongBits$1(0, 0);
1595
+ var i = 0;
1596
+ if (this.len - this.pos > 4) { // fast route (lo)
1597
+ for (; i < 4; ++i) {
1598
+ // 1st..4th
1599
+ bits.lo = (bits.lo | (this.buf[this.pos] & 127) << i * 7) >>> 0;
1600
+ if (this.buf[this.pos++] < 128)
1601
+ return bits;
1602
+ }
1603
+ // 5th
1604
+ bits.lo = (bits.lo | (this.buf[this.pos] & 127) << 28) >>> 0;
1605
+ bits.hi = (bits.hi | (this.buf[this.pos] & 127) >> 4) >>> 0;
1606
+ if (this.buf[this.pos++] < 128)
1607
+ return bits;
1608
+ i = 0;
1609
+ } else {
1610
+ for (; i < 3; ++i) {
1611
+ /* istanbul ignore if */
1612
+ if (this.pos >= this.len)
1613
+ throw indexOutOfRange(this);
1614
+ // 1st..3th
1615
+ bits.lo = (bits.lo | (this.buf[this.pos] & 127) << i * 7) >>> 0;
1616
+ if (this.buf[this.pos++] < 128)
1617
+ return bits;
1618
+ }
1619
+ // 4th
1620
+ bits.lo = (bits.lo | (this.buf[this.pos++] & 127) << i * 7) >>> 0;
1621
+ return bits;
1622
+ }
1623
+ if (this.len - this.pos > 4) { // fast route (hi)
1624
+ for (; i < 5; ++i) {
1625
+ // 6th..10th
1626
+ bits.hi = (bits.hi | (this.buf[this.pos] & 127) << i * 7 + 3) >>> 0;
1627
+ if (this.buf[this.pos++] < 128)
1628
+ return bits;
1629
+ }
1630
+ } else {
1631
+ for (; i < 5; ++i) {
1632
+ /* istanbul ignore if */
1633
+ if (this.pos >= this.len)
1634
+ throw indexOutOfRange(this);
1635
+ // 6th..10th
1636
+ bits.hi = (bits.hi | (this.buf[this.pos] & 127) << i * 7 + 3) >>> 0;
1637
+ if (this.buf[this.pos++] < 128)
1638
+ return bits;
1639
+ }
1640
+ }
1641
+ /* istanbul ignore next */
1642
+ throw Error("invalid varint encoding");
1643
+ }
1644
+
1645
+ /* eslint-enable no-invalid-this */
1646
+
1647
+ /**
1648
+ * Reads a varint as a signed 64 bit value.
1649
+ * @name Reader#int64
1650
+ * @function
1651
+ * @returns {Long} Value read
1652
+ */
1653
+
1654
+ /**
1655
+ * Reads a varint as an unsigned 64 bit value.
1656
+ * @name Reader#uint64
1657
+ * @function
1658
+ * @returns {Long} Value read
1659
+ */
1660
+
1661
+ /**
1662
+ * Reads a zig-zag encoded varint as a signed 64 bit value.
1663
+ * @name Reader#sint64
1664
+ * @function
1665
+ * @returns {Long} Value read
1666
+ */
1667
+
1668
+ /**
1669
+ * Reads a varint as a boolean.
1670
+ * @returns {boolean} Value read
1671
+ */
1672
+ Reader$1.prototype.bool = function read_bool() {
1673
+ return this.uint32() !== 0;
1674
+ };
1675
+
1676
+ function readFixed32_end(buf, end) { // note that this uses `end`, not `pos`
1677
+ return (buf[end - 4]
1678
+ | buf[end - 3] << 8
1679
+ | buf[end - 2] << 16
1680
+ | buf[end - 1] << 24) >>> 0;
1681
+ }
1682
+
1683
+ /**
1684
+ * Reads fixed 32 bits as an unsigned 32 bit integer.
1685
+ * @returns {number} Value read
1686
+ */
1687
+ Reader$1.prototype.fixed32 = function read_fixed32() {
1688
+
1689
+ /* istanbul ignore if */
1690
+ if (this.pos + 4 > this.len)
1691
+ throw indexOutOfRange(this, 4);
1692
+
1693
+ return readFixed32_end(this.buf, this.pos += 4);
1694
+ };
1695
+
1696
+ /**
1697
+ * Reads fixed 32 bits as a signed 32 bit integer.
1698
+ * @returns {number} Value read
1699
+ */
1700
+ Reader$1.prototype.sfixed32 = function read_sfixed32() {
1701
+
1702
+ /* istanbul ignore if */
1703
+ if (this.pos + 4 > this.len)
1704
+ throw indexOutOfRange(this, 4);
1705
+
1706
+ return readFixed32_end(this.buf, this.pos += 4) | 0;
1707
+ };
1708
+
1709
+ /* eslint-disable no-invalid-this */
1710
+
1711
+ function readFixed64(/* this: Reader */) {
1712
+
1713
+ /* istanbul ignore if */
1714
+ if (this.pos + 8 > this.len)
1715
+ throw indexOutOfRange(this, 8);
1716
+
1717
+ return new LongBits$1(readFixed32_end(this.buf, this.pos += 4), readFixed32_end(this.buf, this.pos += 4));
1718
+ }
1719
+
1720
+ /* eslint-enable no-invalid-this */
1721
+
1722
+ /**
1723
+ * Reads fixed 64 bits.
1724
+ * @name Reader#fixed64
1725
+ * @function
1726
+ * @returns {Long} Value read
1727
+ */
1728
+
1729
+ /**
1730
+ * Reads zig-zag encoded fixed 64 bits.
1731
+ * @name Reader#sfixed64
1732
+ * @function
1733
+ * @returns {Long} Value read
1734
+ */
1735
+
1736
+ /**
1737
+ * Reads a float (32 bit) as a number.
1738
+ * @function
1739
+ * @returns {number} Value read
1740
+ */
1741
+ Reader$1.prototype.float = function read_float() {
1742
+
1743
+ /* istanbul ignore if */
1744
+ if (this.pos + 4 > this.len)
1745
+ throw indexOutOfRange(this, 4);
1746
+
1747
+ var value = util$4.float.readFloatLE(this.buf, this.pos);
1748
+ this.pos += 4;
1749
+ return value;
1750
+ };
1751
+
1752
+ /**
1753
+ * Reads a double (64 bit float) as a number.
1754
+ * @function
1755
+ * @returns {number} Value read
1756
+ */
1757
+ Reader$1.prototype.double = function read_double() {
1758
+
1759
+ /* istanbul ignore if */
1760
+ if (this.pos + 8 > this.len)
1761
+ throw indexOutOfRange(this, 4);
1762
+
1763
+ var value = util$4.float.readDoubleLE(this.buf, this.pos);
1764
+ this.pos += 8;
1765
+ return value;
1766
+ };
1767
+
1768
+ /**
1769
+ * Reads a sequence of bytes preceeded by its length as a varint.
1770
+ * @returns {Uint8Array} Value read
1771
+ */
1772
+ Reader$1.prototype.bytes = function read_bytes() {
1773
+ var length = this.uint32(),
1774
+ start = this.pos,
1775
+ end = this.pos + length;
1776
+
1777
+ /* istanbul ignore if */
1778
+ if (end > this.len)
1779
+ throw indexOutOfRange(this, length);
1780
+
1781
+ this.pos += length;
1782
+ if (Array.isArray(this.buf)) // plain array
1783
+ return this.buf.slice(start, end);
1784
+ return start === end // fix for IE 10/Win8 and others' subarray returning array of size 1
1785
+ ? new this.buf.constructor(0)
1786
+ : this._slice.call(this.buf, start, end);
1787
+ };
1788
+
1789
+ /**
1790
+ * Reads a string preceeded by its byte length as a varint.
1791
+ * @returns {string} Value read
1792
+ */
1793
+ Reader$1.prototype.string = function read_string() {
1794
+ var bytes = this.bytes();
1795
+ return utf8$1.read(bytes, 0, bytes.length);
1796
+ };
1797
+
1798
+ /**
1799
+ * Skips the specified number of bytes if specified, otherwise skips a varint.
1800
+ * @param {number} [length] Length if known, otherwise a varint is assumed
1801
+ * @returns {Reader} `this`
1802
+ */
1803
+ Reader$1.prototype.skip = function skip(length) {
1804
+ if (typeof length === "number") {
1805
+ /* istanbul ignore if */
1806
+ if (this.pos + length > this.len)
1807
+ throw indexOutOfRange(this, length);
1808
+ this.pos += length;
1809
+ } else {
1810
+ do {
1811
+ /* istanbul ignore if */
1812
+ if (this.pos >= this.len)
1813
+ throw indexOutOfRange(this);
1814
+ } while (this.buf[this.pos++] & 128);
1815
+ }
1816
+ return this;
1817
+ };
1818
+
1819
+ /**
1820
+ * Skips the next element of the specified wire type.
1821
+ * @param {number} wireType Wire type received
1822
+ * @returns {Reader} `this`
1823
+ */
1824
+ Reader$1.prototype.skipType = function(wireType) {
1825
+ switch (wireType) {
1826
+ case 0:
1827
+ this.skip();
1828
+ break;
1829
+ case 1:
1830
+ this.skip(8);
1831
+ break;
1832
+ case 2:
1833
+ this.skip(this.uint32());
1834
+ break;
1835
+ case 3:
1836
+ while ((wireType = this.uint32() & 7) !== 4) {
1837
+ this.skipType(wireType);
1838
+ }
1839
+ break;
1840
+ case 5:
1841
+ this.skip(4);
1842
+ break;
1843
+
1844
+ /* istanbul ignore next */
1845
+ default:
1846
+ throw Error("invalid wire type " + wireType + " at offset " + this.pos);
1847
+ }
1848
+ return this;
1849
+ };
1850
+
1851
+ Reader$1._configure = function(BufferReader_) {
1852
+ BufferReader$1 = BufferReader_;
1853
+ Reader$1.create = create$1();
1854
+ BufferReader$1._configure();
1855
+
1856
+ var fn = util$4.Long ? "toLong" : /* istanbul ignore next */ "toNumber";
1857
+ util$4.merge(Reader$1.prototype, {
1858
+
1859
+ int64: function read_int64() {
1860
+ return readLongVarint.call(this)[fn](false);
1861
+ },
1862
+
1863
+ uint64: function read_uint64() {
1864
+ return readLongVarint.call(this)[fn](true);
1865
+ },
1866
+
1867
+ sint64: function read_sint64() {
1868
+ return readLongVarint.call(this).zzDecode()[fn](false);
1869
+ },
1870
+
1871
+ fixed64: function read_fixed64() {
1872
+ return readFixed64.call(this)[fn](true);
1873
+ },
1874
+
1875
+ sfixed64: function read_sfixed64() {
1876
+ return readFixed64.call(this)[fn](false);
1877
+ }
1878
+
1879
+ });
1880
+ };
1881
+
1882
+ var reader_buffer = BufferReader;
1883
+
1884
+ // extends Reader
1885
+ var Reader = reader$1;
1886
+ (BufferReader.prototype = Object.create(Reader.prototype)).constructor = BufferReader;
1887
+
1888
+ var util$3 = requireMinimal();
1889
+
1890
+ /**
1891
+ * Constructs a new buffer reader instance.
1892
+ * @classdesc Wire format reader using node buffers.
1893
+ * @extends Reader
1894
+ * @constructor
1895
+ * @param {Buffer} buffer Buffer to read from
1896
+ */
1897
+ function BufferReader(buffer) {
1898
+ Reader.call(this, buffer);
1899
+
1900
+ /**
1901
+ * Read buffer.
1902
+ * @name BufferReader#buf
1903
+ * @type {Buffer}
1904
+ */
1905
+ }
1906
+
1907
+ BufferReader._configure = function () {
1908
+ /* istanbul ignore else */
1909
+ if (util$3.Buffer)
1910
+ BufferReader.prototype._slice = util$3.Buffer.prototype.slice;
1911
+ };
1912
+
1913
+
1914
+ /**
1915
+ * @override
1916
+ */
1917
+ BufferReader.prototype.string = function read_string_buffer() {
1918
+ var len = this.uint32(); // modifies pos
1919
+ return this.buf.utf8Slice
1920
+ ? this.buf.utf8Slice(this.pos, this.pos = Math.min(this.pos + len, this.len))
1921
+ : this.buf.toString("utf-8", this.pos, this.pos = Math.min(this.pos + len, this.len));
1922
+ };
1923
+
1924
+ /**
1925
+ * Reads a sequence of bytes preceeded by its length as a varint.
1926
+ * @name BufferReader#bytes
1927
+ * @function
1928
+ * @returns {Buffer} Value read
1929
+ */
1930
+
1931
+ BufferReader._configure();
1932
+
1933
+ var minimalExports = requireMinimal();
1934
+ var util$2 = /*@__PURE__*/getDefaultExportFromCjs(minimalExports);
1935
+
1936
+ var writer$1 = Writer$1;
1937
+
1938
+ var util$1 = requireMinimal();
1939
+
1940
+ var BufferWriter$1; // cyclic
1941
+
1942
+ var LongBits = util$1.LongBits,
1943
+ base64 = util$1.base64,
1944
+ utf8 = util$1.utf8;
1945
+
1946
+ /**
1947
+ * Constructs a new writer operation instance.
1948
+ * @classdesc Scheduled writer operation.
1949
+ * @constructor
1950
+ * @param {function(*, Uint8Array, number)} fn Function to call
1951
+ * @param {number} len Value byte length
1952
+ * @param {*} val Value to write
1953
+ * @ignore
1954
+ */
1955
+ function Op(fn, len, val) {
1956
+
1957
+ /**
1958
+ * Function to call.
1959
+ * @type {function(Uint8Array, number, *)}
1960
+ */
1961
+ this.fn = fn;
1962
+
1963
+ /**
1964
+ * Value byte length.
1965
+ * @type {number}
1966
+ */
1967
+ this.len = len;
1968
+
1969
+ /**
1970
+ * Next operation.
1971
+ * @type {Writer.Op|undefined}
1972
+ */
1973
+ this.next = undefined;
1974
+
1975
+ /**
1976
+ * Value to write.
1977
+ * @type {*}
1978
+ */
1979
+ this.val = val; // type varies
1980
+ }
1981
+
1982
+ /* istanbul ignore next */
1983
+ function noop() {} // eslint-disable-line no-empty-function
1984
+
1985
+ /**
1986
+ * Constructs a new writer state instance.
1987
+ * @classdesc Copied writer state.
1988
+ * @memberof Writer
1989
+ * @constructor
1990
+ * @param {Writer} writer Writer to copy state from
1991
+ * @ignore
1992
+ */
1993
+ function State(writer) {
1994
+
1995
+ /**
1996
+ * Current head.
1997
+ * @type {Writer.Op}
1998
+ */
1999
+ this.head = writer.head;
2000
+
2001
+ /**
2002
+ * Current tail.
2003
+ * @type {Writer.Op}
2004
+ */
2005
+ this.tail = writer.tail;
2006
+
2007
+ /**
2008
+ * Current buffer length.
2009
+ * @type {number}
2010
+ */
2011
+ this.len = writer.len;
2012
+
2013
+ /**
2014
+ * Next state.
2015
+ * @type {State|null}
2016
+ */
2017
+ this.next = writer.states;
2018
+ }
2019
+
2020
+ /**
2021
+ * Constructs a new writer instance.
2022
+ * @classdesc Wire format writer using `Uint8Array` if available, otherwise `Array`.
2023
+ * @constructor
2024
+ */
2025
+ function Writer$1() {
2026
+
2027
+ /**
2028
+ * Current length.
2029
+ * @type {number}
2030
+ */
2031
+ this.len = 0;
2032
+
2033
+ /**
2034
+ * Operations head.
2035
+ * @type {Object}
2036
+ */
2037
+ this.head = new Op(noop, 0, 0);
2038
+
2039
+ /**
2040
+ * Operations tail
2041
+ * @type {Object}
2042
+ */
2043
+ this.tail = this.head;
2044
+
2045
+ /**
2046
+ * Linked forked states.
2047
+ * @type {Object|null}
2048
+ */
2049
+ this.states = null;
2050
+
2051
+ // When a value is written, the writer calculates its byte length and puts it into a linked
2052
+ // list of operations to perform when finish() is called. This both allows us to allocate
2053
+ // buffers of the exact required size and reduces the amount of work we have to do compared
2054
+ // to first calculating over objects and then encoding over objects. In our case, the encoding
2055
+ // part is just a linked list walk calling operations with already prepared values.
2056
+ }
2057
+
2058
+ var create = function create() {
2059
+ return util$1.Buffer
2060
+ ? function create_buffer_setup() {
2061
+ return (Writer$1.create = function create_buffer() {
2062
+ return new BufferWriter$1();
2063
+ })();
2064
+ }
2065
+ /* istanbul ignore next */
2066
+ : function create_array() {
2067
+ return new Writer$1();
2068
+ };
2069
+ };
2070
+
2071
+ /**
2072
+ * Creates a new writer.
2073
+ * @function
2074
+ * @returns {BufferWriter|Writer} A {@link BufferWriter} when Buffers are supported, otherwise a {@link Writer}
2075
+ */
2076
+ Writer$1.create = create();
2077
+
2078
+ /**
2079
+ * Allocates a buffer of the specified size.
2080
+ * @param {number} size Buffer size
2081
+ * @returns {Uint8Array} Buffer
2082
+ */
2083
+ Writer$1.alloc = function alloc(size) {
2084
+ return new util$1.Array(size);
2085
+ };
2086
+
2087
+ // Use Uint8Array buffer pool in the browser, just like node does with buffers
2088
+ /* istanbul ignore else */
2089
+ if (util$1.Array !== Array)
2090
+ Writer$1.alloc = util$1.pool(Writer$1.alloc, util$1.Array.prototype.subarray);
2091
+
2092
+ /**
2093
+ * Pushes a new operation to the queue.
2094
+ * @param {function(Uint8Array, number, *)} fn Function to call
2095
+ * @param {number} len Value byte length
2096
+ * @param {number} val Value to write
2097
+ * @returns {Writer} `this`
2098
+ * @private
2099
+ */
2100
+ Writer$1.prototype._push = function push(fn, len, val) {
2101
+ this.tail = this.tail.next = new Op(fn, len, val);
2102
+ this.len += len;
2103
+ return this;
2104
+ };
2105
+
2106
+ function writeByte(val, buf, pos) {
2107
+ buf[pos] = val & 255;
2108
+ }
2109
+
2110
+ function writeVarint32(val, buf, pos) {
2111
+ while (val > 127) {
2112
+ buf[pos++] = val & 127 | 128;
2113
+ val >>>= 7;
2114
+ }
2115
+ buf[pos] = val;
2116
+ }
2117
+
2118
+ /**
2119
+ * Constructs a new varint writer operation instance.
2120
+ * @classdesc Scheduled varint writer operation.
2121
+ * @extends Op
2122
+ * @constructor
2123
+ * @param {number} len Value byte length
2124
+ * @param {number} val Value to write
2125
+ * @ignore
2126
+ */
2127
+ function VarintOp(len, val) {
2128
+ this.len = len;
2129
+ this.next = undefined;
2130
+ this.val = val;
2131
+ }
2132
+
2133
+ VarintOp.prototype = Object.create(Op.prototype);
2134
+ VarintOp.prototype.fn = writeVarint32;
2135
+
2136
+ /**
2137
+ * Writes an unsigned 32 bit value as a varint.
2138
+ * @param {number} value Value to write
2139
+ * @returns {Writer} `this`
2140
+ */
2141
+ Writer$1.prototype.uint32 = function write_uint32(value) {
2142
+ // here, the call to this.push has been inlined and a varint specific Op subclass is used.
2143
+ // uint32 is by far the most frequently used operation and benefits significantly from this.
2144
+ this.len += (this.tail = this.tail.next = new VarintOp(
2145
+ (value = value >>> 0)
2146
+ < 128 ? 1
2147
+ : value < 16384 ? 2
2148
+ : value < 2097152 ? 3
2149
+ : value < 268435456 ? 4
2150
+ : 5,
2151
+ value)).len;
2152
+ return this;
2153
+ };
2154
+
2155
+ /**
2156
+ * Writes a signed 32 bit value as a varint.
2157
+ * @function
2158
+ * @param {number} value Value to write
2159
+ * @returns {Writer} `this`
2160
+ */
2161
+ Writer$1.prototype.int32 = function write_int32(value) {
2162
+ return value < 0
2163
+ ? this._push(writeVarint64, 10, LongBits.fromNumber(value)) // 10 bytes per spec
2164
+ : this.uint32(value);
2165
+ };
2166
+
2167
+ /**
2168
+ * Writes a 32 bit value as a varint, zig-zag encoded.
2169
+ * @param {number} value Value to write
2170
+ * @returns {Writer} `this`
2171
+ */
2172
+ Writer$1.prototype.sint32 = function write_sint32(value) {
2173
+ return this.uint32((value << 1 ^ value >> 31) >>> 0);
2174
+ };
2175
+
2176
+ function writeVarint64(val, buf, pos) {
2177
+ while (val.hi) {
2178
+ buf[pos++] = val.lo & 127 | 128;
2179
+ val.lo = (val.lo >>> 7 | val.hi << 25) >>> 0;
2180
+ val.hi >>>= 7;
2181
+ }
2182
+ while (val.lo > 127) {
2183
+ buf[pos++] = val.lo & 127 | 128;
2184
+ val.lo = val.lo >>> 7;
2185
+ }
2186
+ buf[pos++] = val.lo;
2187
+ }
2188
+
2189
+ /**
2190
+ * Writes an unsigned 64 bit value as a varint.
2191
+ * @param {Long|number|string} value Value to write
2192
+ * @returns {Writer} `this`
2193
+ * @throws {TypeError} If `value` is a string and no long library is present.
2194
+ */
2195
+ Writer$1.prototype.uint64 = function write_uint64(value) {
2196
+ var bits = LongBits.from(value);
2197
+ return this._push(writeVarint64, bits.length(), bits);
2198
+ };
2199
+
2200
+ /**
2201
+ * Writes a signed 64 bit value as a varint.
2202
+ * @function
2203
+ * @param {Long|number|string} value Value to write
2204
+ * @returns {Writer} `this`
2205
+ * @throws {TypeError} If `value` is a string and no long library is present.
2206
+ */
2207
+ Writer$1.prototype.int64 = Writer$1.prototype.uint64;
2208
+
2209
+ /**
2210
+ * Writes a signed 64 bit value as a varint, zig-zag encoded.
2211
+ * @param {Long|number|string} value Value to write
2212
+ * @returns {Writer} `this`
2213
+ * @throws {TypeError} If `value` is a string and no long library is present.
2214
+ */
2215
+ Writer$1.prototype.sint64 = function write_sint64(value) {
2216
+ var bits = LongBits.from(value).zzEncode();
2217
+ return this._push(writeVarint64, bits.length(), bits);
2218
+ };
2219
+
2220
+ /**
2221
+ * Writes a boolish value as a varint.
2222
+ * @param {boolean} value Value to write
2223
+ * @returns {Writer} `this`
2224
+ */
2225
+ Writer$1.prototype.bool = function write_bool(value) {
2226
+ return this._push(writeByte, 1, value ? 1 : 0);
2227
+ };
2228
+
2229
+ function writeFixed32(val, buf, pos) {
2230
+ buf[pos ] = val & 255;
2231
+ buf[pos + 1] = val >>> 8 & 255;
2232
+ buf[pos + 2] = val >>> 16 & 255;
2233
+ buf[pos + 3] = val >>> 24;
2234
+ }
2235
+
2236
+ /**
2237
+ * Writes an unsigned 32 bit value as fixed 32 bits.
2238
+ * @param {number} value Value to write
2239
+ * @returns {Writer} `this`
2240
+ */
2241
+ Writer$1.prototype.fixed32 = function write_fixed32(value) {
2242
+ return this._push(writeFixed32, 4, value >>> 0);
2243
+ };
2244
+
2245
+ /**
2246
+ * Writes a signed 32 bit value as fixed 32 bits.
2247
+ * @function
2248
+ * @param {number} value Value to write
2249
+ * @returns {Writer} `this`
2250
+ */
2251
+ Writer$1.prototype.sfixed32 = Writer$1.prototype.fixed32;
2252
+
2253
+ /**
2254
+ * Writes an unsigned 64 bit value as fixed 64 bits.
2255
+ * @param {Long|number|string} value Value to write
2256
+ * @returns {Writer} `this`
2257
+ * @throws {TypeError} If `value` is a string and no long library is present.
2258
+ */
2259
+ Writer$1.prototype.fixed64 = function write_fixed64(value) {
2260
+ var bits = LongBits.from(value);
2261
+ return this._push(writeFixed32, 4, bits.lo)._push(writeFixed32, 4, bits.hi);
2262
+ };
2263
+
2264
+ /**
2265
+ * Writes a signed 64 bit value as fixed 64 bits.
2266
+ * @function
2267
+ * @param {Long|number|string} value Value to write
2268
+ * @returns {Writer} `this`
2269
+ * @throws {TypeError} If `value` is a string and no long library is present.
2270
+ */
2271
+ Writer$1.prototype.sfixed64 = Writer$1.prototype.fixed64;
2272
+
2273
+ /**
2274
+ * Writes a float (32 bit).
2275
+ * @function
2276
+ * @param {number} value Value to write
2277
+ * @returns {Writer} `this`
2278
+ */
2279
+ Writer$1.prototype.float = function write_float(value) {
2280
+ return this._push(util$1.float.writeFloatLE, 4, value);
2281
+ };
2282
+
2283
+ /**
2284
+ * Writes a double (64 bit float).
2285
+ * @function
2286
+ * @param {number} value Value to write
2287
+ * @returns {Writer} `this`
2288
+ */
2289
+ Writer$1.prototype.double = function write_double(value) {
2290
+ return this._push(util$1.float.writeDoubleLE, 8, value);
2291
+ };
2292
+
2293
+ var writeBytes = util$1.Array.prototype.set
2294
+ ? function writeBytes_set(val, buf, pos) {
2295
+ buf.set(val, pos); // also works for plain array values
2296
+ }
2297
+ /* istanbul ignore next */
2298
+ : function writeBytes_for(val, buf, pos) {
2299
+ for (var i = 0; i < val.length; ++i)
2300
+ buf[pos + i] = val[i];
2301
+ };
2302
+
2303
+ /**
2304
+ * Writes a sequence of bytes.
2305
+ * @param {Uint8Array|string} value Buffer or base64 encoded string to write
2306
+ * @returns {Writer} `this`
2307
+ */
2308
+ Writer$1.prototype.bytes = function write_bytes(value) {
2309
+ var len = value.length >>> 0;
2310
+ if (!len)
2311
+ return this._push(writeByte, 1, 0);
2312
+ if (util$1.isString(value)) {
2313
+ var buf = Writer$1.alloc(len = base64.length(value));
2314
+ base64.decode(value, buf, 0);
2315
+ value = buf;
2316
+ }
2317
+ return this.uint32(len)._push(writeBytes, len, value);
2318
+ };
2319
+
2320
+ /**
2321
+ * Writes a string.
2322
+ * @param {string} value Value to write
2323
+ * @returns {Writer} `this`
2324
+ */
2325
+ Writer$1.prototype.string = function write_string(value) {
2326
+ var len = utf8.length(value);
2327
+ return len
2328
+ ? this.uint32(len)._push(utf8.write, len, value)
2329
+ : this._push(writeByte, 1, 0);
2330
+ };
2331
+
2332
+ /**
2333
+ * Forks this writer's state by pushing it to a stack.
2334
+ * Calling {@link Writer#reset|reset} or {@link Writer#ldelim|ldelim} resets the writer to the previous state.
2335
+ * @returns {Writer} `this`
2336
+ */
2337
+ Writer$1.prototype.fork = function fork() {
2338
+ this.states = new State(this);
2339
+ this.head = this.tail = new Op(noop, 0, 0);
2340
+ this.len = 0;
2341
+ return this;
2342
+ };
2343
+
2344
+ /**
2345
+ * Resets this instance to the last state.
2346
+ * @returns {Writer} `this`
2347
+ */
2348
+ Writer$1.prototype.reset = function reset() {
2349
+ if (this.states) {
2350
+ this.head = this.states.head;
2351
+ this.tail = this.states.tail;
2352
+ this.len = this.states.len;
2353
+ this.states = this.states.next;
2354
+ } else {
2355
+ this.head = this.tail = new Op(noop, 0, 0);
2356
+ this.len = 0;
2357
+ }
2358
+ return this;
2359
+ };
2360
+
2361
+ /**
2362
+ * Resets to the last state and appends the fork state's current write length as a varint followed by its operations.
2363
+ * @returns {Writer} `this`
2364
+ */
2365
+ Writer$1.prototype.ldelim = function ldelim() {
2366
+ var head = this.head,
2367
+ tail = this.tail,
2368
+ len = this.len;
2369
+ this.reset().uint32(len);
2370
+ if (len) {
2371
+ this.tail.next = head.next; // skip noop
2372
+ this.tail = tail;
2373
+ this.len += len;
2374
+ }
2375
+ return this;
2376
+ };
2377
+
2378
+ /**
2379
+ * Finishes the write operation.
2380
+ * @returns {Uint8Array} Finished buffer
2381
+ */
2382
+ Writer$1.prototype.finish = function finish() {
2383
+ var head = this.head.next, // skip noop
2384
+ buf = this.constructor.alloc(this.len),
2385
+ pos = 0;
2386
+ while (head) {
2387
+ head.fn(head.val, buf, pos);
2388
+ pos += head.len;
2389
+ head = head.next;
2390
+ }
2391
+ // this.head = this.tail = null;
2392
+ return buf;
2393
+ };
2394
+
2395
+ Writer$1._configure = function(BufferWriter_) {
2396
+ BufferWriter$1 = BufferWriter_;
2397
+ Writer$1.create = create();
2398
+ BufferWriter$1._configure();
2399
+ };
2400
+
2401
+ var writer_buffer = BufferWriter;
2402
+
2403
+ // extends Writer
2404
+ var Writer = writer$1;
2405
+ (BufferWriter.prototype = Object.create(Writer.prototype)).constructor = BufferWriter;
2406
+
2407
+ var util = requireMinimal();
2408
+
2409
+ /**
2410
+ * Constructs a new buffer writer instance.
2411
+ * @classdesc Wire format writer using node buffers.
2412
+ * @extends Writer
2413
+ * @constructor
2414
+ */
2415
+ function BufferWriter() {
2416
+ Writer.call(this);
2417
+ }
2418
+
2419
+ BufferWriter._configure = function () {
2420
+ /**
2421
+ * Allocates a buffer of the specified size.
2422
+ * @function
2423
+ * @param {number} size Buffer size
2424
+ * @returns {Buffer} Buffer
2425
+ */
2426
+ BufferWriter.alloc = util._Buffer_allocUnsafe;
2427
+
2428
+ BufferWriter.writeBytesBuffer = util.Buffer && util.Buffer.prototype instanceof Uint8Array && util.Buffer.prototype.set.name === "set"
2429
+ ? function writeBytesBuffer_set(val, buf, pos) {
2430
+ buf.set(val, pos); // faster than copy (requires node >= 4 where Buffers extend Uint8Array and set is properly inherited)
2431
+ // also works for plain array values
2432
+ }
2433
+ /* istanbul ignore next */
2434
+ : function writeBytesBuffer_copy(val, buf, pos) {
2435
+ if (val.copy) // Buffer values
2436
+ val.copy(buf, pos, 0, val.length);
2437
+ else for (var i = 0; i < val.length;) // plain array values
2438
+ buf[pos++] = val[i++];
2439
+ };
2440
+ };
2441
+
2442
+
2443
+ /**
2444
+ * @override
2445
+ */
2446
+ BufferWriter.prototype.bytes = function write_bytes_buffer(value) {
2447
+ if (util.isString(value))
2448
+ value = util._Buffer_from(value, "base64");
2449
+ var len = value.length >>> 0;
2450
+ this.uint32(len);
2451
+ if (len)
2452
+ this._push(BufferWriter.writeBytesBuffer, len, value);
2453
+ return this;
2454
+ };
2455
+
2456
+ function writeStringBuffer(val, buf, pos) {
2457
+ if (val.length < 40) // plain js is faster for short strings (probably due to redundant assertions)
2458
+ util.utf8.write(val, buf, pos);
2459
+ else if (buf.utf8Write)
2460
+ buf.utf8Write(val, pos);
2461
+ else
2462
+ buf.write(val, pos);
2463
+ }
2464
+
2465
+ /**
2466
+ * @override
2467
+ */
2468
+ BufferWriter.prototype.string = function write_string_buffer(value) {
2469
+ var len = util.Buffer.byteLength(value);
2470
+ this.uint32(len);
2471
+ if (len)
2472
+ this._push(writeStringBuffer, len, value);
2473
+ return this;
2474
+ };
2475
+
2476
+
2477
+ /**
2478
+ * Finishes the write operation.
2479
+ * @name BufferWriter#finish
2480
+ * @function
2481
+ * @returns {Buffer} Finished buffer
2482
+ */
2483
+
2484
+ BufferWriter._configure();
2485
+
2486
+ // @ts-expect-error no types
2487
+ function configure() {
2488
+ util$2._configure();
2489
+ reader$1._configure(reader_buffer);
2490
+ writer$1._configure(writer_buffer);
2491
+ }
2492
+ // Set up buffer utility according to the environment
2493
+ configure();
2494
+ // monkey patch the reader to add native bigint support
2495
+ const methods = [
2496
+ 'uint64', 'int64', 'sint64', 'fixed64', 'sfixed64'
2497
+ ];
2498
+ function patchReader(obj) {
2499
+ for (const method of methods) {
2500
+ if (obj[method] == null) {
2501
+ continue;
2502
+ }
2503
+ const original = obj[method];
2504
+ obj[method] = function () {
2505
+ return BigInt(original.call(this).toString());
2506
+ };
2507
+ }
2508
+ return obj;
2509
+ }
2510
+ function reader(buf) {
2511
+ return patchReader(new reader$1(buf));
2512
+ }
2513
+ function patchWriter(obj) {
2514
+ for (const method of methods) {
2515
+ if (obj[method] == null) {
2516
+ continue;
2517
+ }
2518
+ const original = obj[method];
2519
+ obj[method] = function (val) {
2520
+ return original.call(this, val.toString());
2521
+ };
2522
+ }
2523
+ return obj;
2524
+ }
2525
+ function writer() {
2526
+ return patchWriter(writer$1.create());
2527
+ }
2528
+
2529
+ function decodeMessage(buf, codec) {
2530
+ const r = reader(buf instanceof Uint8Array ? buf : buf.subarray());
2531
+ return codec.decode(r);
2532
+ }
2533
+
2534
+ function encodeMessage(message, codec) {
2535
+ const w = writer();
2536
+ codec.encode(message, w, {
2537
+ lengthDelimited: false
2538
+ });
2539
+ return w.finish();
2540
+ }
2541
+
2542
+ // https://developers.google.com/protocol-buffers/docs/encoding#structure
2543
+ var CODEC_TYPES;
2544
+ (function (CODEC_TYPES) {
2545
+ CODEC_TYPES[CODEC_TYPES["VARINT"] = 0] = "VARINT";
2546
+ CODEC_TYPES[CODEC_TYPES["BIT64"] = 1] = "BIT64";
2547
+ CODEC_TYPES[CODEC_TYPES["LENGTH_DELIMITED"] = 2] = "LENGTH_DELIMITED";
2548
+ CODEC_TYPES[CODEC_TYPES["START_GROUP"] = 3] = "START_GROUP";
2549
+ CODEC_TYPES[CODEC_TYPES["END_GROUP"] = 4] = "END_GROUP";
2550
+ CODEC_TYPES[CODEC_TYPES["BIT32"] = 5] = "BIT32";
2551
+ })(CODEC_TYPES || (CODEC_TYPES = {}));
2552
+ function createCodec(name, type, encode, decode) {
2553
+ return {
2554
+ name,
2555
+ type,
2556
+ encode,
2557
+ decode
2558
+ };
2559
+ }
2560
+
2561
+ function enumeration(v) {
2562
+ function findValue(val) {
2563
+ // Use the reverse mapping to look up the enum key for the stored value
2564
+ // https://www.typescriptlang.org/docs/handbook/enums.html#reverse-mappings
2565
+ if (v[val.toString()] == null) {
2566
+ throw new Error('Invalid enum value');
2567
+ }
2568
+ return v[val];
2569
+ }
2570
+ const encode = function enumEncode(val, writer) {
2571
+ const enumValue = findValue(val);
2572
+ writer.int32(enumValue);
2573
+ };
2574
+ const decode = function enumDecode(reader) {
2575
+ const val = reader.int32();
2576
+ return findValue(val);
2577
+ };
2578
+ // @ts-expect-error yeah yeah
2579
+ return createCodec('enum', CODEC_TYPES.VARINT, encode, decode);
2580
+ }
2581
+
2582
+ function message$1(encode, decode) {
2583
+ return createCodec('message', CODEC_TYPES.LENGTH_DELIMITED, encode, decode);
2584
+ }
2585
+
2586
+ /* eslint-disable import/export */
2587
+ var RateLimitProof$3;
2588
+ (function (RateLimitProof) {
2589
+ let _codec;
2590
+ RateLimitProof.codec = () => {
2591
+ if (_codec == null) {
2592
+ _codec = message$1((obj, w, opts = {}) => {
2593
+ if (opts.lengthDelimited !== false) {
2594
+ w.fork();
2595
+ }
2596
+ if (obj.proof != null && obj.proof.byteLength > 0) {
2597
+ w.uint32(10);
2598
+ w.bytes(obj.proof);
2599
+ }
2600
+ if (obj.merkleRoot != null && obj.merkleRoot.byteLength > 0) {
2601
+ w.uint32(18);
2602
+ w.bytes(obj.merkleRoot);
2603
+ }
2604
+ if (obj.epoch != null && obj.epoch.byteLength > 0) {
2605
+ w.uint32(26);
2606
+ w.bytes(obj.epoch);
2607
+ }
2608
+ if (obj.shareX != null && obj.shareX.byteLength > 0) {
2609
+ w.uint32(34);
2610
+ w.bytes(obj.shareX);
2611
+ }
2612
+ if (obj.shareY != null && obj.shareY.byteLength > 0) {
2613
+ w.uint32(42);
2614
+ w.bytes(obj.shareY);
2615
+ }
2616
+ if (obj.nullifier != null && obj.nullifier.byteLength > 0) {
2617
+ w.uint32(50);
2618
+ w.bytes(obj.nullifier);
2619
+ }
2620
+ if (obj.rlnIdentifier != null && obj.rlnIdentifier.byteLength > 0) {
2621
+ w.uint32(58);
2622
+ w.bytes(obj.rlnIdentifier);
2623
+ }
2624
+ if (opts.lengthDelimited !== false) {
2625
+ w.ldelim();
2626
+ }
2627
+ }, (reader, length) => {
2628
+ const obj = {
2629
+ proof: new Uint8Array(0),
2630
+ merkleRoot: new Uint8Array(0),
2631
+ epoch: new Uint8Array(0),
2632
+ shareX: new Uint8Array(0),
2633
+ shareY: new Uint8Array(0),
2634
+ nullifier: new Uint8Array(0),
2635
+ rlnIdentifier: new Uint8Array(0),
2636
+ };
2637
+ const end = length == null ? reader.len : reader.pos + length;
2638
+ while (reader.pos < end) {
2639
+ const tag = reader.uint32();
2640
+ switch (tag >>> 3) {
2641
+ case 1:
2642
+ obj.proof = reader.bytes();
2643
+ break;
2644
+ case 2:
2645
+ obj.merkleRoot = reader.bytes();
2646
+ break;
2647
+ case 3:
2648
+ obj.epoch = reader.bytes();
2649
+ break;
2650
+ case 4:
2651
+ obj.shareX = reader.bytes();
2652
+ break;
2653
+ case 5:
2654
+ obj.shareY = reader.bytes();
2655
+ break;
2656
+ case 6:
2657
+ obj.nullifier = reader.bytes();
2658
+ break;
2659
+ case 7:
2660
+ obj.rlnIdentifier = reader.bytes();
2661
+ break;
2662
+ default:
2663
+ reader.skipType(tag & 7);
2664
+ break;
2665
+ }
2666
+ }
2667
+ return obj;
2668
+ });
2669
+ }
2670
+ return _codec;
2671
+ };
2672
+ RateLimitProof.encode = (obj) => {
2673
+ return encodeMessage(obj, RateLimitProof.codec());
2674
+ };
2675
+ RateLimitProof.decode = (buf) => {
2676
+ return decodeMessage(buf, RateLimitProof.codec());
2677
+ };
2678
+ })(RateLimitProof$3 || (RateLimitProof$3 = {}));
2679
+ var WakuMessage$3;
2680
+ (function (WakuMessage) {
2681
+ let _codec;
2682
+ WakuMessage.codec = () => {
2683
+ if (_codec == null) {
2684
+ _codec = message$1((obj, w, opts = {}) => {
2685
+ if (opts.lengthDelimited !== false) {
2686
+ w.fork();
2687
+ }
2688
+ if (obj.payload != null && obj.payload.byteLength > 0) {
2689
+ w.uint32(10);
2690
+ w.bytes(obj.payload);
2691
+ }
2692
+ if (obj.contentTopic != null && obj.contentTopic !== "") {
2693
+ w.uint32(18);
2694
+ w.string(obj.contentTopic);
2695
+ }
2696
+ if (obj.version != null) {
2697
+ w.uint32(24);
2698
+ w.uint32(obj.version);
2699
+ }
2700
+ if (obj.timestamp != null) {
2701
+ w.uint32(80);
2702
+ w.sint64(obj.timestamp);
2703
+ }
2704
+ if (obj.meta != null) {
2705
+ w.uint32(90);
2706
+ w.bytes(obj.meta);
2707
+ }
2708
+ if (obj.rateLimitProof != null) {
2709
+ w.uint32(170);
2710
+ RateLimitProof$3.codec().encode(obj.rateLimitProof, w);
2711
+ }
2712
+ if (obj.ephemeral != null) {
2713
+ w.uint32(248);
2714
+ w.bool(obj.ephemeral);
2715
+ }
2716
+ if (opts.lengthDelimited !== false) {
2717
+ w.ldelim();
2718
+ }
2719
+ }, (reader, length) => {
2720
+ const obj = {
2721
+ payload: new Uint8Array(0),
2722
+ contentTopic: "",
2723
+ };
2724
+ const end = length == null ? reader.len : reader.pos + length;
2725
+ while (reader.pos < end) {
2726
+ const tag = reader.uint32();
2727
+ switch (tag >>> 3) {
2728
+ case 1:
2729
+ obj.payload = reader.bytes();
2730
+ break;
2731
+ case 2:
2732
+ obj.contentTopic = reader.string();
2733
+ break;
2734
+ case 3:
2735
+ obj.version = reader.uint32();
2736
+ break;
2737
+ case 10:
2738
+ obj.timestamp = reader.sint64();
2739
+ break;
2740
+ case 11:
2741
+ obj.meta = reader.bytes();
2742
+ break;
2743
+ case 21:
2744
+ obj.rateLimitProof = RateLimitProof$3.codec().decode(reader, reader.uint32());
2745
+ break;
2746
+ case 31:
2747
+ obj.ephemeral = reader.bool();
2748
+ break;
2749
+ default:
2750
+ reader.skipType(tag & 7);
2751
+ break;
2752
+ }
2753
+ }
2754
+ return obj;
2755
+ });
2756
+ }
2757
+ return _codec;
2758
+ };
2759
+ WakuMessage.encode = (obj) => {
2760
+ return encodeMessage(obj, WakuMessage.codec());
2761
+ };
2762
+ WakuMessage.decode = (buf) => {
2763
+ return decodeMessage(buf, WakuMessage.codec());
2764
+ };
2765
+ })(WakuMessage$3 || (WakuMessage$3 = {}));
2766
+
2767
+ var message = /*#__PURE__*/Object.freeze({
2768
+ __proto__: null,
2769
+ get RateLimitProof () { return RateLimitProof$3; },
2770
+ get WakuMessage () { return WakuMessage$3; }
2771
+ });
2772
+
2773
+ /* eslint-disable import/export */
2774
+ var FilterRequest;
2775
+ (function (FilterRequest) {
2776
+ (function (ContentFilter) {
2777
+ let _codec;
2778
+ ContentFilter.codec = () => {
2779
+ if (_codec == null) {
2780
+ _codec = message$1((obj, w, opts = {}) => {
2781
+ if (opts.lengthDelimited !== false) {
2782
+ w.fork();
2783
+ }
2784
+ if (obj.contentTopic != null && obj.contentTopic !== "") {
2785
+ w.uint32(10);
2786
+ w.string(obj.contentTopic);
2787
+ }
2788
+ if (opts.lengthDelimited !== false) {
2789
+ w.ldelim();
2790
+ }
2791
+ }, (reader, length) => {
2792
+ const obj = {
2793
+ contentTopic: "",
2794
+ };
2795
+ const end = length == null ? reader.len : reader.pos + length;
2796
+ while (reader.pos < end) {
2797
+ const tag = reader.uint32();
2798
+ switch (tag >>> 3) {
2799
+ case 1:
2800
+ obj.contentTopic = reader.string();
2801
+ break;
2802
+ default:
2803
+ reader.skipType(tag & 7);
2804
+ break;
2805
+ }
2806
+ }
2807
+ return obj;
2808
+ });
2809
+ }
2810
+ return _codec;
2811
+ };
2812
+ ContentFilter.encode = (obj) => {
2813
+ return encodeMessage(obj, ContentFilter.codec());
2814
+ };
2815
+ ContentFilter.decode = (buf) => {
2816
+ return decodeMessage(buf, ContentFilter.codec());
2817
+ };
2818
+ })(FilterRequest.ContentFilter || (FilterRequest.ContentFilter = {}));
2819
+ let _codec;
2820
+ FilterRequest.codec = () => {
2821
+ if (_codec == null) {
2822
+ _codec = message$1((obj, w, opts = {}) => {
2823
+ if (opts.lengthDelimited !== false) {
2824
+ w.fork();
2825
+ }
2826
+ if (obj.subscribe != null && obj.subscribe !== false) {
2827
+ w.uint32(8);
2828
+ w.bool(obj.subscribe);
2829
+ }
2830
+ if (obj.topic != null && obj.topic !== "") {
2831
+ w.uint32(18);
2832
+ w.string(obj.topic);
2833
+ }
2834
+ if (obj.contentFilters != null) {
2835
+ for (const value of obj.contentFilters) {
2836
+ w.uint32(26);
2837
+ FilterRequest.ContentFilter.codec().encode(value, w);
2838
+ }
2839
+ }
2840
+ if (opts.lengthDelimited !== false) {
2841
+ w.ldelim();
2842
+ }
2843
+ }, (reader, length) => {
2844
+ const obj = {
2845
+ subscribe: false,
2846
+ topic: "",
2847
+ contentFilters: [],
2848
+ };
2849
+ const end = length == null ? reader.len : reader.pos + length;
2850
+ while (reader.pos < end) {
2851
+ const tag = reader.uint32();
2852
+ switch (tag >>> 3) {
2853
+ case 1:
2854
+ obj.subscribe = reader.bool();
2855
+ break;
2856
+ case 2:
2857
+ obj.topic = reader.string();
2858
+ break;
2859
+ case 3:
2860
+ obj.contentFilters.push(FilterRequest.ContentFilter.codec().decode(reader, reader.uint32()));
2861
+ break;
2862
+ default:
2863
+ reader.skipType(tag & 7);
2864
+ break;
2865
+ }
2866
+ }
2867
+ return obj;
2868
+ });
2869
+ }
2870
+ return _codec;
2871
+ };
2872
+ FilterRequest.encode = (obj) => {
2873
+ return encodeMessage(obj, FilterRequest.codec());
2874
+ };
2875
+ FilterRequest.decode = (buf) => {
2876
+ return decodeMessage(buf, FilterRequest.codec());
2877
+ };
2878
+ })(FilterRequest || (FilterRequest = {}));
2879
+ var MessagePush;
2880
+ (function (MessagePush) {
2881
+ let _codec;
2882
+ MessagePush.codec = () => {
2883
+ if (_codec == null) {
2884
+ _codec = message$1((obj, w, opts = {}) => {
2885
+ if (opts.lengthDelimited !== false) {
2886
+ w.fork();
2887
+ }
2888
+ if (obj.messages != null) {
2889
+ for (const value of obj.messages) {
2890
+ w.uint32(10);
2891
+ WakuMessage$2.codec().encode(value, w);
2892
+ }
2893
+ }
2894
+ if (opts.lengthDelimited !== false) {
2895
+ w.ldelim();
2896
+ }
2897
+ }, (reader, length) => {
2898
+ const obj = {
2899
+ messages: [],
2900
+ };
2901
+ const end = length == null ? reader.len : reader.pos + length;
2902
+ while (reader.pos < end) {
2903
+ const tag = reader.uint32();
2904
+ switch (tag >>> 3) {
2905
+ case 1:
2906
+ obj.messages.push(WakuMessage$2.codec().decode(reader, reader.uint32()));
2907
+ break;
2908
+ default:
2909
+ reader.skipType(tag & 7);
2910
+ break;
2911
+ }
2912
+ }
2913
+ return obj;
2914
+ });
2915
+ }
2916
+ return _codec;
2917
+ };
2918
+ MessagePush.encode = (obj) => {
2919
+ return encodeMessage(obj, MessagePush.codec());
2920
+ };
2921
+ MessagePush.decode = (buf) => {
2922
+ return decodeMessage(buf, MessagePush.codec());
2923
+ };
2924
+ })(MessagePush || (MessagePush = {}));
2925
+ var FilterRpc$1;
2926
+ (function (FilterRpc) {
2927
+ let _codec;
2928
+ FilterRpc.codec = () => {
2929
+ if (_codec == null) {
2930
+ _codec = message$1((obj, w, opts = {}) => {
2931
+ if (opts.lengthDelimited !== false) {
2932
+ w.fork();
2933
+ }
2934
+ if (obj.requestId != null && obj.requestId !== "") {
2935
+ w.uint32(10);
2936
+ w.string(obj.requestId);
2937
+ }
2938
+ if (obj.request != null) {
2939
+ w.uint32(18);
2940
+ FilterRequest.codec().encode(obj.request, w);
2941
+ }
2942
+ if (obj.push != null) {
2943
+ w.uint32(26);
2944
+ MessagePush.codec().encode(obj.push, w);
2945
+ }
2946
+ if (opts.lengthDelimited !== false) {
2947
+ w.ldelim();
2948
+ }
2949
+ }, (reader, length) => {
2950
+ const obj = {
2951
+ requestId: "",
2952
+ };
2953
+ const end = length == null ? reader.len : reader.pos + length;
2954
+ while (reader.pos < end) {
2955
+ const tag = reader.uint32();
2956
+ switch (tag >>> 3) {
2957
+ case 1:
2958
+ obj.requestId = reader.string();
2959
+ break;
2960
+ case 2:
2961
+ obj.request = FilterRequest.codec().decode(reader, reader.uint32());
2962
+ break;
2963
+ case 3:
2964
+ obj.push = MessagePush.codec().decode(reader, reader.uint32());
2965
+ break;
2966
+ default:
2967
+ reader.skipType(tag & 7);
2968
+ break;
2969
+ }
2970
+ }
2971
+ return obj;
2972
+ });
2973
+ }
2974
+ return _codec;
2975
+ };
2976
+ FilterRpc.encode = (obj) => {
2977
+ return encodeMessage(obj, FilterRpc.codec());
2978
+ };
2979
+ FilterRpc.decode = (buf) => {
2980
+ return decodeMessage(buf, FilterRpc.codec());
2981
+ };
2982
+ })(FilterRpc$1 || (FilterRpc$1 = {}));
2983
+ var RateLimitProof$2;
2984
+ (function (RateLimitProof) {
2985
+ let _codec;
2986
+ RateLimitProof.codec = () => {
2987
+ if (_codec == null) {
2988
+ _codec = message$1((obj, w, opts = {}) => {
2989
+ if (opts.lengthDelimited !== false) {
2990
+ w.fork();
2991
+ }
2992
+ if (obj.proof != null && obj.proof.byteLength > 0) {
2993
+ w.uint32(10);
2994
+ w.bytes(obj.proof);
2995
+ }
2996
+ if (obj.merkleRoot != null && obj.merkleRoot.byteLength > 0) {
2997
+ w.uint32(18);
2998
+ w.bytes(obj.merkleRoot);
2999
+ }
3000
+ if (obj.epoch != null && obj.epoch.byteLength > 0) {
3001
+ w.uint32(26);
3002
+ w.bytes(obj.epoch);
3003
+ }
3004
+ if (obj.shareX != null && obj.shareX.byteLength > 0) {
3005
+ w.uint32(34);
3006
+ w.bytes(obj.shareX);
3007
+ }
3008
+ if (obj.shareY != null && obj.shareY.byteLength > 0) {
3009
+ w.uint32(42);
3010
+ w.bytes(obj.shareY);
3011
+ }
3012
+ if (obj.nullifier != null && obj.nullifier.byteLength > 0) {
3013
+ w.uint32(50);
3014
+ w.bytes(obj.nullifier);
3015
+ }
3016
+ if (obj.rlnIdentifier != null && obj.rlnIdentifier.byteLength > 0) {
3017
+ w.uint32(58);
3018
+ w.bytes(obj.rlnIdentifier);
3019
+ }
3020
+ if (opts.lengthDelimited !== false) {
3021
+ w.ldelim();
3022
+ }
3023
+ }, (reader, length) => {
3024
+ const obj = {
3025
+ proof: new Uint8Array(0),
3026
+ merkleRoot: new Uint8Array(0),
3027
+ epoch: new Uint8Array(0),
3028
+ shareX: new Uint8Array(0),
3029
+ shareY: new Uint8Array(0),
3030
+ nullifier: new Uint8Array(0),
3031
+ rlnIdentifier: new Uint8Array(0),
3032
+ };
3033
+ const end = length == null ? reader.len : reader.pos + length;
3034
+ while (reader.pos < end) {
3035
+ const tag = reader.uint32();
3036
+ switch (tag >>> 3) {
3037
+ case 1:
3038
+ obj.proof = reader.bytes();
3039
+ break;
3040
+ case 2:
3041
+ obj.merkleRoot = reader.bytes();
3042
+ break;
3043
+ case 3:
3044
+ obj.epoch = reader.bytes();
3045
+ break;
3046
+ case 4:
3047
+ obj.shareX = reader.bytes();
3048
+ break;
3049
+ case 5:
3050
+ obj.shareY = reader.bytes();
3051
+ break;
3052
+ case 6:
3053
+ obj.nullifier = reader.bytes();
3054
+ break;
3055
+ case 7:
3056
+ obj.rlnIdentifier = reader.bytes();
3057
+ break;
3058
+ default:
3059
+ reader.skipType(tag & 7);
3060
+ break;
3061
+ }
3062
+ }
3063
+ return obj;
3064
+ });
3065
+ }
3066
+ return _codec;
3067
+ };
3068
+ RateLimitProof.encode = (obj) => {
3069
+ return encodeMessage(obj, RateLimitProof.codec());
3070
+ };
3071
+ RateLimitProof.decode = (buf) => {
3072
+ return decodeMessage(buf, RateLimitProof.codec());
3073
+ };
3074
+ })(RateLimitProof$2 || (RateLimitProof$2 = {}));
3075
+ var WakuMessage$2;
3076
+ (function (WakuMessage) {
3077
+ let _codec;
3078
+ WakuMessage.codec = () => {
3079
+ if (_codec == null) {
3080
+ _codec = message$1((obj, w, opts = {}) => {
3081
+ if (opts.lengthDelimited !== false) {
3082
+ w.fork();
3083
+ }
3084
+ if (obj.payload != null && obj.payload.byteLength > 0) {
3085
+ w.uint32(10);
3086
+ w.bytes(obj.payload);
3087
+ }
3088
+ if (obj.contentTopic != null && obj.contentTopic !== "") {
3089
+ w.uint32(18);
3090
+ w.string(obj.contentTopic);
3091
+ }
3092
+ if (obj.version != null) {
3093
+ w.uint32(24);
3094
+ w.uint32(obj.version);
3095
+ }
3096
+ if (obj.timestamp != null) {
3097
+ w.uint32(80);
3098
+ w.sint64(obj.timestamp);
3099
+ }
3100
+ if (obj.meta != null) {
3101
+ w.uint32(90);
3102
+ w.bytes(obj.meta);
3103
+ }
3104
+ if (obj.rateLimitProof != null) {
3105
+ w.uint32(170);
3106
+ RateLimitProof$2.codec().encode(obj.rateLimitProof, w);
3107
+ }
3108
+ if (obj.ephemeral != null) {
3109
+ w.uint32(248);
3110
+ w.bool(obj.ephemeral);
3111
+ }
3112
+ if (opts.lengthDelimited !== false) {
3113
+ w.ldelim();
3114
+ }
3115
+ }, (reader, length) => {
3116
+ const obj = {
3117
+ payload: new Uint8Array(0),
3118
+ contentTopic: "",
3119
+ };
3120
+ const end = length == null ? reader.len : reader.pos + length;
3121
+ while (reader.pos < end) {
3122
+ const tag = reader.uint32();
3123
+ switch (tag >>> 3) {
3124
+ case 1:
3125
+ obj.payload = reader.bytes();
3126
+ break;
3127
+ case 2:
3128
+ obj.contentTopic = reader.string();
3129
+ break;
3130
+ case 3:
3131
+ obj.version = reader.uint32();
3132
+ break;
3133
+ case 10:
3134
+ obj.timestamp = reader.sint64();
3135
+ break;
3136
+ case 11:
3137
+ obj.meta = reader.bytes();
3138
+ break;
3139
+ case 21:
3140
+ obj.rateLimitProof = RateLimitProof$2.codec().decode(reader, reader.uint32());
3141
+ break;
3142
+ case 31:
3143
+ obj.ephemeral = reader.bool();
3144
+ break;
3145
+ default:
3146
+ reader.skipType(tag & 7);
3147
+ break;
3148
+ }
3149
+ }
3150
+ return obj;
3151
+ });
3152
+ }
3153
+ return _codec;
3154
+ };
3155
+ WakuMessage.encode = (obj) => {
3156
+ return encodeMessage(obj, WakuMessage.codec());
3157
+ };
3158
+ WakuMessage.decode = (buf) => {
3159
+ return decodeMessage(buf, WakuMessage.codec());
3160
+ };
3161
+ })(WakuMessage$2 || (WakuMessage$2 = {}));
3162
+
3163
+ /* eslint-disable import/export */
3164
+ var TopicOnlyMessage;
3165
+ (function (TopicOnlyMessage) {
3166
+ let _codec;
3167
+ TopicOnlyMessage.codec = () => {
3168
+ if (_codec == null) {
3169
+ _codec = message$1((obj, w, opts = {}) => {
3170
+ if (opts.lengthDelimited !== false) {
3171
+ w.fork();
3172
+ }
3173
+ if (obj.contentTopic != null && obj.contentTopic !== "") {
3174
+ w.uint32(18);
3175
+ w.string(obj.contentTopic);
3176
+ }
3177
+ if (opts.lengthDelimited !== false) {
3178
+ w.ldelim();
3179
+ }
3180
+ }, (reader, length) => {
3181
+ const obj = {
3182
+ contentTopic: "",
3183
+ };
3184
+ const end = length == null ? reader.len : reader.pos + length;
3185
+ while (reader.pos < end) {
3186
+ const tag = reader.uint32();
3187
+ switch (tag >>> 3) {
3188
+ case 2:
3189
+ obj.contentTopic = reader.string();
3190
+ break;
3191
+ default:
3192
+ reader.skipType(tag & 7);
3193
+ break;
3194
+ }
3195
+ }
3196
+ return obj;
3197
+ });
3198
+ }
3199
+ return _codec;
3200
+ };
3201
+ TopicOnlyMessage.encode = (obj) => {
3202
+ return encodeMessage(obj, TopicOnlyMessage.codec());
3203
+ };
3204
+ TopicOnlyMessage.decode = (buf) => {
3205
+ return decodeMessage(buf, TopicOnlyMessage.codec());
3206
+ };
3207
+ })(TopicOnlyMessage || (TopicOnlyMessage = {}));
3208
+
3209
+ /* eslint-disable import/export */
3210
+ var PushRequest;
3211
+ (function (PushRequest) {
3212
+ let _codec;
3213
+ PushRequest.codec = () => {
3214
+ if (_codec == null) {
3215
+ _codec = message$1((obj, w, opts = {}) => {
3216
+ if (opts.lengthDelimited !== false) {
3217
+ w.fork();
3218
+ }
3219
+ if (obj.pubsubTopic != null && obj.pubsubTopic !== "") {
3220
+ w.uint32(10);
3221
+ w.string(obj.pubsubTopic);
3222
+ }
3223
+ if (obj.message != null) {
3224
+ w.uint32(18);
3225
+ WakuMessage$1.codec().encode(obj.message, w);
3226
+ }
3227
+ if (opts.lengthDelimited !== false) {
3228
+ w.ldelim();
3229
+ }
3230
+ }, (reader, length) => {
3231
+ const obj = {
3232
+ pubsubTopic: "",
3233
+ };
3234
+ const end = length == null ? reader.len : reader.pos + length;
3235
+ while (reader.pos < end) {
3236
+ const tag = reader.uint32();
3237
+ switch (tag >>> 3) {
3238
+ case 1:
3239
+ obj.pubsubTopic = reader.string();
3240
+ break;
3241
+ case 2:
3242
+ obj.message = WakuMessage$1.codec().decode(reader, reader.uint32());
3243
+ break;
3244
+ default:
3245
+ reader.skipType(tag & 7);
3246
+ break;
3247
+ }
3248
+ }
3249
+ return obj;
3250
+ });
3251
+ }
3252
+ return _codec;
3253
+ };
3254
+ PushRequest.encode = (obj) => {
3255
+ return encodeMessage(obj, PushRequest.codec());
3256
+ };
3257
+ PushRequest.decode = (buf) => {
3258
+ return decodeMessage(buf, PushRequest.codec());
3259
+ };
3260
+ })(PushRequest || (PushRequest = {}));
3261
+ var PushResponse;
3262
+ (function (PushResponse) {
3263
+ let _codec;
3264
+ PushResponse.codec = () => {
3265
+ if (_codec == null) {
3266
+ _codec = message$1((obj, w, opts = {}) => {
3267
+ if (opts.lengthDelimited !== false) {
3268
+ w.fork();
3269
+ }
3270
+ if (obj.isSuccess != null && obj.isSuccess !== false) {
3271
+ w.uint32(8);
3272
+ w.bool(obj.isSuccess);
3273
+ }
3274
+ if (obj.info != null) {
3275
+ w.uint32(18);
3276
+ w.string(obj.info);
3277
+ }
3278
+ if (opts.lengthDelimited !== false) {
3279
+ w.ldelim();
3280
+ }
3281
+ }, (reader, length) => {
3282
+ const obj = {
3283
+ isSuccess: false,
3284
+ };
3285
+ const end = length == null ? reader.len : reader.pos + length;
3286
+ while (reader.pos < end) {
3287
+ const tag = reader.uint32();
3288
+ switch (tag >>> 3) {
3289
+ case 1:
3290
+ obj.isSuccess = reader.bool();
3291
+ break;
3292
+ case 2:
3293
+ obj.info = reader.string();
3294
+ break;
3295
+ default:
3296
+ reader.skipType(tag & 7);
3297
+ break;
3298
+ }
3299
+ }
3300
+ return obj;
3301
+ });
3302
+ }
3303
+ return _codec;
3304
+ };
3305
+ PushResponse.encode = (obj) => {
3306
+ return encodeMessage(obj, PushResponse.codec());
3307
+ };
3308
+ PushResponse.decode = (buf) => {
3309
+ return decodeMessage(buf, PushResponse.codec());
3310
+ };
3311
+ })(PushResponse || (PushResponse = {}));
3312
+ var PushRpc$1;
3313
+ (function (PushRpc) {
3314
+ let _codec;
3315
+ PushRpc.codec = () => {
3316
+ if (_codec == null) {
3317
+ _codec = message$1((obj, w, opts = {}) => {
3318
+ if (opts.lengthDelimited !== false) {
3319
+ w.fork();
3320
+ }
3321
+ if (obj.requestId != null && obj.requestId !== "") {
3322
+ w.uint32(10);
3323
+ w.string(obj.requestId);
3324
+ }
3325
+ if (obj.request != null) {
3326
+ w.uint32(18);
3327
+ PushRequest.codec().encode(obj.request, w);
3328
+ }
3329
+ if (obj.response != null) {
3330
+ w.uint32(26);
3331
+ PushResponse.codec().encode(obj.response, w);
3332
+ }
3333
+ if (opts.lengthDelimited !== false) {
3334
+ w.ldelim();
3335
+ }
3336
+ }, (reader, length) => {
3337
+ const obj = {
3338
+ requestId: "",
3339
+ };
3340
+ const end = length == null ? reader.len : reader.pos + length;
3341
+ while (reader.pos < end) {
3342
+ const tag = reader.uint32();
3343
+ switch (tag >>> 3) {
3344
+ case 1:
3345
+ obj.requestId = reader.string();
3346
+ break;
3347
+ case 2:
3348
+ obj.request = PushRequest.codec().decode(reader, reader.uint32());
3349
+ break;
3350
+ case 3:
3351
+ obj.response = PushResponse.codec().decode(reader, reader.uint32());
3352
+ break;
3353
+ default:
3354
+ reader.skipType(tag & 7);
3355
+ break;
3356
+ }
3357
+ }
3358
+ return obj;
3359
+ });
3360
+ }
3361
+ return _codec;
3362
+ };
3363
+ PushRpc.encode = (obj) => {
3364
+ return encodeMessage(obj, PushRpc.codec());
3365
+ };
3366
+ PushRpc.decode = (buf) => {
3367
+ return decodeMessage(buf, PushRpc.codec());
3368
+ };
3369
+ })(PushRpc$1 || (PushRpc$1 = {}));
3370
+ var RateLimitProof$1;
3371
+ (function (RateLimitProof) {
3372
+ let _codec;
3373
+ RateLimitProof.codec = () => {
3374
+ if (_codec == null) {
3375
+ _codec = message$1((obj, w, opts = {}) => {
3376
+ if (opts.lengthDelimited !== false) {
3377
+ w.fork();
3378
+ }
3379
+ if (obj.proof != null && obj.proof.byteLength > 0) {
3380
+ w.uint32(10);
3381
+ w.bytes(obj.proof);
3382
+ }
3383
+ if (obj.merkleRoot != null && obj.merkleRoot.byteLength > 0) {
3384
+ w.uint32(18);
3385
+ w.bytes(obj.merkleRoot);
3386
+ }
3387
+ if (obj.epoch != null && obj.epoch.byteLength > 0) {
3388
+ w.uint32(26);
3389
+ w.bytes(obj.epoch);
3390
+ }
3391
+ if (obj.shareX != null && obj.shareX.byteLength > 0) {
3392
+ w.uint32(34);
3393
+ w.bytes(obj.shareX);
3394
+ }
3395
+ if (obj.shareY != null && obj.shareY.byteLength > 0) {
3396
+ w.uint32(42);
3397
+ w.bytes(obj.shareY);
3398
+ }
3399
+ if (obj.nullifier != null && obj.nullifier.byteLength > 0) {
3400
+ w.uint32(50);
3401
+ w.bytes(obj.nullifier);
3402
+ }
3403
+ if (obj.rlnIdentifier != null && obj.rlnIdentifier.byteLength > 0) {
3404
+ w.uint32(58);
3405
+ w.bytes(obj.rlnIdentifier);
3406
+ }
3407
+ if (opts.lengthDelimited !== false) {
3408
+ w.ldelim();
3409
+ }
3410
+ }, (reader, length) => {
3411
+ const obj = {
3412
+ proof: new Uint8Array(0),
3413
+ merkleRoot: new Uint8Array(0),
3414
+ epoch: new Uint8Array(0),
3415
+ shareX: new Uint8Array(0),
3416
+ shareY: new Uint8Array(0),
3417
+ nullifier: new Uint8Array(0),
3418
+ rlnIdentifier: new Uint8Array(0),
3419
+ };
3420
+ const end = length == null ? reader.len : reader.pos + length;
3421
+ while (reader.pos < end) {
3422
+ const tag = reader.uint32();
3423
+ switch (tag >>> 3) {
3424
+ case 1:
3425
+ obj.proof = reader.bytes();
3426
+ break;
3427
+ case 2:
3428
+ obj.merkleRoot = reader.bytes();
3429
+ break;
3430
+ case 3:
3431
+ obj.epoch = reader.bytes();
3432
+ break;
3433
+ case 4:
3434
+ obj.shareX = reader.bytes();
3435
+ break;
3436
+ case 5:
3437
+ obj.shareY = reader.bytes();
3438
+ break;
3439
+ case 6:
3440
+ obj.nullifier = reader.bytes();
3441
+ break;
3442
+ case 7:
3443
+ obj.rlnIdentifier = reader.bytes();
3444
+ break;
3445
+ default:
3446
+ reader.skipType(tag & 7);
3447
+ break;
3448
+ }
3449
+ }
3450
+ return obj;
3451
+ });
3452
+ }
3453
+ return _codec;
3454
+ };
3455
+ RateLimitProof.encode = (obj) => {
3456
+ return encodeMessage(obj, RateLimitProof.codec());
3457
+ };
3458
+ RateLimitProof.decode = (buf) => {
3459
+ return decodeMessage(buf, RateLimitProof.codec());
3460
+ };
3461
+ })(RateLimitProof$1 || (RateLimitProof$1 = {}));
3462
+ var WakuMessage$1;
3463
+ (function (WakuMessage) {
3464
+ let _codec;
3465
+ WakuMessage.codec = () => {
3466
+ if (_codec == null) {
3467
+ _codec = message$1((obj, w, opts = {}) => {
3468
+ if (opts.lengthDelimited !== false) {
3469
+ w.fork();
3470
+ }
3471
+ if (obj.payload != null && obj.payload.byteLength > 0) {
3472
+ w.uint32(10);
3473
+ w.bytes(obj.payload);
3474
+ }
3475
+ if (obj.contentTopic != null && obj.contentTopic !== "") {
3476
+ w.uint32(18);
3477
+ w.string(obj.contentTopic);
3478
+ }
3479
+ if (obj.version != null) {
3480
+ w.uint32(24);
3481
+ w.uint32(obj.version);
3482
+ }
3483
+ if (obj.timestamp != null) {
3484
+ w.uint32(80);
3485
+ w.sint64(obj.timestamp);
3486
+ }
3487
+ if (obj.meta != null) {
3488
+ w.uint32(90);
3489
+ w.bytes(obj.meta);
3490
+ }
3491
+ if (obj.rateLimitProof != null) {
3492
+ w.uint32(170);
3493
+ RateLimitProof$1.codec().encode(obj.rateLimitProof, w);
3494
+ }
3495
+ if (obj.ephemeral != null) {
3496
+ w.uint32(248);
3497
+ w.bool(obj.ephemeral);
3498
+ }
3499
+ if (opts.lengthDelimited !== false) {
3500
+ w.ldelim();
3501
+ }
3502
+ }, (reader, length) => {
3503
+ const obj = {
3504
+ payload: new Uint8Array(0),
3505
+ contentTopic: "",
3506
+ };
3507
+ const end = length == null ? reader.len : reader.pos + length;
3508
+ while (reader.pos < end) {
3509
+ const tag = reader.uint32();
3510
+ switch (tag >>> 3) {
3511
+ case 1:
3512
+ obj.payload = reader.bytes();
3513
+ break;
3514
+ case 2:
3515
+ obj.contentTopic = reader.string();
3516
+ break;
3517
+ case 3:
3518
+ obj.version = reader.uint32();
3519
+ break;
3520
+ case 10:
3521
+ obj.timestamp = reader.sint64();
3522
+ break;
3523
+ case 11:
3524
+ obj.meta = reader.bytes();
3525
+ break;
3526
+ case 21:
3527
+ obj.rateLimitProof = RateLimitProof$1.codec().decode(reader, reader.uint32());
3528
+ break;
3529
+ case 31:
3530
+ obj.ephemeral = reader.bool();
3531
+ break;
3532
+ default:
3533
+ reader.skipType(tag & 7);
3534
+ break;
3535
+ }
3536
+ }
3537
+ return obj;
3538
+ });
3539
+ }
3540
+ return _codec;
3541
+ };
3542
+ WakuMessage.encode = (obj) => {
3543
+ return encodeMessage(obj, WakuMessage.codec());
3544
+ };
3545
+ WakuMessage.decode = (buf) => {
3546
+ return decodeMessage(buf, WakuMessage.codec());
3547
+ };
3548
+ })(WakuMessage$1 || (WakuMessage$1 = {}));
3549
+
3550
+ /* eslint-disable import/export */
3551
+ var Index;
3552
+ (function (Index) {
3553
+ let _codec;
3554
+ Index.codec = () => {
3555
+ if (_codec == null) {
3556
+ _codec = message$1((obj, w, opts = {}) => {
3557
+ if (opts.lengthDelimited !== false) {
3558
+ w.fork();
3559
+ }
3560
+ if (obj.digest != null && obj.digest.byteLength > 0) {
3561
+ w.uint32(10);
3562
+ w.bytes(obj.digest);
3563
+ }
3564
+ if (obj.receiverTime != null && obj.receiverTime !== 0n) {
3565
+ w.uint32(16);
3566
+ w.sint64(obj.receiverTime);
3567
+ }
3568
+ if (obj.senderTime != null && obj.senderTime !== 0n) {
3569
+ w.uint32(24);
3570
+ w.sint64(obj.senderTime);
3571
+ }
3572
+ if (obj.pubsubTopic != null && obj.pubsubTopic !== "") {
3573
+ w.uint32(34);
3574
+ w.string(obj.pubsubTopic);
3575
+ }
3576
+ if (opts.lengthDelimited !== false) {
3577
+ w.ldelim();
3578
+ }
3579
+ }, (reader, length) => {
3580
+ const obj = {
3581
+ digest: new Uint8Array(0),
3582
+ receiverTime: 0n,
3583
+ senderTime: 0n,
3584
+ pubsubTopic: "",
3585
+ };
3586
+ const end = length == null ? reader.len : reader.pos + length;
3587
+ while (reader.pos < end) {
3588
+ const tag = reader.uint32();
3589
+ switch (tag >>> 3) {
3590
+ case 1:
3591
+ obj.digest = reader.bytes();
3592
+ break;
3593
+ case 2:
3594
+ obj.receiverTime = reader.sint64();
3595
+ break;
3596
+ case 3:
3597
+ obj.senderTime = reader.sint64();
3598
+ break;
3599
+ case 4:
3600
+ obj.pubsubTopic = reader.string();
3601
+ break;
3602
+ default:
3603
+ reader.skipType(tag & 7);
3604
+ break;
3605
+ }
3606
+ }
3607
+ return obj;
3608
+ });
3609
+ }
3610
+ return _codec;
3611
+ };
3612
+ Index.encode = (obj) => {
3613
+ return encodeMessage(obj, Index.codec());
3614
+ };
3615
+ Index.decode = (buf) => {
3616
+ return decodeMessage(buf, Index.codec());
3617
+ };
3618
+ })(Index || (Index = {}));
3619
+ var PagingInfo;
3620
+ (function (PagingInfo) {
3621
+ (function (Direction) {
3622
+ Direction["BACKWARD"] = "BACKWARD";
3623
+ Direction["FORWARD"] = "FORWARD";
3624
+ })(PagingInfo.Direction || (PagingInfo.Direction = {}));
3625
+ let __DirectionValues;
3626
+ (function (__DirectionValues) {
3627
+ __DirectionValues[__DirectionValues["BACKWARD"] = 0] = "BACKWARD";
3628
+ __DirectionValues[__DirectionValues["FORWARD"] = 1] = "FORWARD";
3629
+ })(__DirectionValues || (__DirectionValues = {}));
3630
+ (function (Direction) {
3631
+ Direction.codec = () => {
3632
+ return enumeration(__DirectionValues);
3633
+ };
3634
+ })(PagingInfo.Direction || (PagingInfo.Direction = {}));
3635
+ let _codec;
3636
+ PagingInfo.codec = () => {
3637
+ if (_codec == null) {
3638
+ _codec = message$1((obj, w, opts = {}) => {
3639
+ if (opts.lengthDelimited !== false) {
3640
+ w.fork();
3641
+ }
3642
+ if (obj.pageSize != null) {
3643
+ w.uint32(8);
3644
+ w.uint64(obj.pageSize);
3645
+ }
3646
+ if (obj.cursor != null) {
3647
+ w.uint32(18);
3648
+ Index.codec().encode(obj.cursor, w);
3649
+ }
3650
+ if (obj.direction != null) {
3651
+ w.uint32(24);
3652
+ PagingInfo.Direction.codec().encode(obj.direction, w);
3653
+ }
3654
+ if (opts.lengthDelimited !== false) {
3655
+ w.ldelim();
3656
+ }
3657
+ }, (reader, length) => {
3658
+ const obj = {};
3659
+ const end = length == null ? reader.len : reader.pos + length;
3660
+ while (reader.pos < end) {
3661
+ const tag = reader.uint32();
3662
+ switch (tag >>> 3) {
3663
+ case 1:
3664
+ obj.pageSize = reader.uint64();
3665
+ break;
3666
+ case 2:
3667
+ obj.cursor = Index.codec().decode(reader, reader.uint32());
3668
+ break;
3669
+ case 3:
3670
+ obj.direction = PagingInfo.Direction.codec().decode(reader);
3671
+ break;
3672
+ default:
3673
+ reader.skipType(tag & 7);
3674
+ break;
3675
+ }
3676
+ }
3677
+ return obj;
3678
+ });
3679
+ }
3680
+ return _codec;
3681
+ };
3682
+ PagingInfo.encode = (obj) => {
3683
+ return encodeMessage(obj, PagingInfo.codec());
3684
+ };
3685
+ PagingInfo.decode = (buf) => {
3686
+ return decodeMessage(buf, PagingInfo.codec());
3687
+ };
3688
+ })(PagingInfo || (PagingInfo = {}));
3689
+ var ContentFilter;
3690
+ (function (ContentFilter) {
3691
+ let _codec;
3692
+ ContentFilter.codec = () => {
3693
+ if (_codec == null) {
3694
+ _codec = message$1((obj, w, opts = {}) => {
3695
+ if (opts.lengthDelimited !== false) {
3696
+ w.fork();
3697
+ }
3698
+ if (obj.contentTopic != null && obj.contentTopic !== "") {
3699
+ w.uint32(10);
3700
+ w.string(obj.contentTopic);
3701
+ }
3702
+ if (opts.lengthDelimited !== false) {
3703
+ w.ldelim();
3704
+ }
3705
+ }, (reader, length) => {
3706
+ const obj = {
3707
+ contentTopic: "",
3708
+ };
3709
+ const end = length == null ? reader.len : reader.pos + length;
3710
+ while (reader.pos < end) {
3711
+ const tag = reader.uint32();
3712
+ switch (tag >>> 3) {
3713
+ case 1:
3714
+ obj.contentTopic = reader.string();
3715
+ break;
3716
+ default:
3717
+ reader.skipType(tag & 7);
3718
+ break;
3719
+ }
3720
+ }
3721
+ return obj;
3722
+ });
3723
+ }
3724
+ return _codec;
3725
+ };
3726
+ ContentFilter.encode = (obj) => {
3727
+ return encodeMessage(obj, ContentFilter.codec());
3728
+ };
3729
+ ContentFilter.decode = (buf) => {
3730
+ return decodeMessage(buf, ContentFilter.codec());
3731
+ };
3732
+ })(ContentFilter || (ContentFilter = {}));
3733
+ var HistoryQuery;
3734
+ (function (HistoryQuery) {
3735
+ let _codec;
3736
+ HistoryQuery.codec = () => {
3737
+ if (_codec == null) {
3738
+ _codec = message$1((obj, w, opts = {}) => {
3739
+ if (opts.lengthDelimited !== false) {
3740
+ w.fork();
3741
+ }
3742
+ if (obj.pubsubTopic != null) {
3743
+ w.uint32(18);
3744
+ w.string(obj.pubsubTopic);
3745
+ }
3746
+ if (obj.contentFilters != null) {
3747
+ for (const value of obj.contentFilters) {
3748
+ w.uint32(26);
3749
+ ContentFilter.codec().encode(value, w);
3750
+ }
3751
+ }
3752
+ if (obj.pagingInfo != null) {
3753
+ w.uint32(34);
3754
+ PagingInfo.codec().encode(obj.pagingInfo, w);
3755
+ }
3756
+ if (obj.startTime != null) {
3757
+ w.uint32(40);
3758
+ w.sint64(obj.startTime);
3759
+ }
3760
+ if (obj.endTime != null) {
3761
+ w.uint32(48);
3762
+ w.sint64(obj.endTime);
3763
+ }
3764
+ if (opts.lengthDelimited !== false) {
3765
+ w.ldelim();
3766
+ }
3767
+ }, (reader, length) => {
3768
+ const obj = {
3769
+ contentFilters: [],
3770
+ };
3771
+ const end = length == null ? reader.len : reader.pos + length;
3772
+ while (reader.pos < end) {
3773
+ const tag = reader.uint32();
3774
+ switch (tag >>> 3) {
3775
+ case 2:
3776
+ obj.pubsubTopic = reader.string();
3777
+ break;
3778
+ case 3:
3779
+ obj.contentFilters.push(ContentFilter.codec().decode(reader, reader.uint32()));
3780
+ break;
3781
+ case 4:
3782
+ obj.pagingInfo = PagingInfo.codec().decode(reader, reader.uint32());
3783
+ break;
3784
+ case 5:
3785
+ obj.startTime = reader.sint64();
3786
+ break;
3787
+ case 6:
3788
+ obj.endTime = reader.sint64();
3789
+ break;
3790
+ default:
3791
+ reader.skipType(tag & 7);
3792
+ break;
3793
+ }
3794
+ }
3795
+ return obj;
3796
+ });
3797
+ }
3798
+ return _codec;
3799
+ };
3800
+ HistoryQuery.encode = (obj) => {
3801
+ return encodeMessage(obj, HistoryQuery.codec());
3802
+ };
3803
+ HistoryQuery.decode = (buf) => {
3804
+ return decodeMessage(buf, HistoryQuery.codec());
3805
+ };
3806
+ })(HistoryQuery || (HistoryQuery = {}));
3807
+ var HistoryResponse;
3808
+ (function (HistoryResponse) {
3809
+ let HistoryError;
3810
+ (function (HistoryError) {
3811
+ HistoryError["NONE"] = "NONE";
3812
+ HistoryError["INVALID_CURSOR"] = "INVALID_CURSOR";
3813
+ })(HistoryError = HistoryResponse.HistoryError || (HistoryResponse.HistoryError = {}));
3814
+ let __HistoryErrorValues;
3815
+ (function (__HistoryErrorValues) {
3816
+ __HistoryErrorValues[__HistoryErrorValues["NONE"] = 0] = "NONE";
3817
+ __HistoryErrorValues[__HistoryErrorValues["INVALID_CURSOR"] = 1] = "INVALID_CURSOR";
3818
+ })(__HistoryErrorValues || (__HistoryErrorValues = {}));
3819
+ (function (HistoryError) {
3820
+ HistoryError.codec = () => {
3821
+ return enumeration(__HistoryErrorValues);
3822
+ };
3823
+ })(HistoryError = HistoryResponse.HistoryError || (HistoryResponse.HistoryError = {}));
3824
+ let _codec;
3825
+ HistoryResponse.codec = () => {
3826
+ if (_codec == null) {
3827
+ _codec = message$1((obj, w, opts = {}) => {
3828
+ if (opts.lengthDelimited !== false) {
3829
+ w.fork();
3830
+ }
3831
+ if (obj.messages != null) {
3832
+ for (const value of obj.messages) {
3833
+ w.uint32(18);
3834
+ WakuMessage.codec().encode(value, w);
3835
+ }
3836
+ }
3837
+ if (obj.pagingInfo != null) {
3838
+ w.uint32(26);
3839
+ PagingInfo.codec().encode(obj.pagingInfo, w);
3840
+ }
3841
+ if (obj.error != null && __HistoryErrorValues[obj.error] !== 0) {
3842
+ w.uint32(32);
3843
+ HistoryResponse.HistoryError.codec().encode(obj.error, w);
3844
+ }
3845
+ if (opts.lengthDelimited !== false) {
3846
+ w.ldelim();
3847
+ }
3848
+ }, (reader, length) => {
3849
+ const obj = {
3850
+ messages: [],
3851
+ error: HistoryError.NONE,
3852
+ };
3853
+ const end = length == null ? reader.len : reader.pos + length;
3854
+ while (reader.pos < end) {
3855
+ const tag = reader.uint32();
3856
+ switch (tag >>> 3) {
3857
+ case 2:
3858
+ obj.messages.push(WakuMessage.codec().decode(reader, reader.uint32()));
3859
+ break;
3860
+ case 3:
3861
+ obj.pagingInfo = PagingInfo.codec().decode(reader, reader.uint32());
3862
+ break;
3863
+ case 4:
3864
+ obj.error = HistoryResponse.HistoryError.codec().decode(reader);
3865
+ break;
3866
+ default:
3867
+ reader.skipType(tag & 7);
3868
+ break;
3869
+ }
3870
+ }
3871
+ return obj;
3872
+ });
3873
+ }
3874
+ return _codec;
3875
+ };
3876
+ HistoryResponse.encode = (obj) => {
3877
+ return encodeMessage(obj, HistoryResponse.codec());
3878
+ };
3879
+ HistoryResponse.decode = (buf) => {
3880
+ return decodeMessage(buf, HistoryResponse.codec());
3881
+ };
3882
+ })(HistoryResponse || (HistoryResponse = {}));
3883
+ var HistoryRpc$1;
3884
+ (function (HistoryRpc) {
3885
+ let _codec;
3886
+ HistoryRpc.codec = () => {
3887
+ if (_codec == null) {
3888
+ _codec = message$1((obj, w, opts = {}) => {
3889
+ if (opts.lengthDelimited !== false) {
3890
+ w.fork();
3891
+ }
3892
+ if (obj.requestId != null && obj.requestId !== "") {
3893
+ w.uint32(10);
3894
+ w.string(obj.requestId);
3895
+ }
3896
+ if (obj.query != null) {
3897
+ w.uint32(18);
3898
+ HistoryQuery.codec().encode(obj.query, w);
3899
+ }
3900
+ if (obj.response != null) {
3901
+ w.uint32(26);
3902
+ HistoryResponse.codec().encode(obj.response, w);
3903
+ }
3904
+ if (opts.lengthDelimited !== false) {
3905
+ w.ldelim();
3906
+ }
3907
+ }, (reader, length) => {
3908
+ const obj = {
3909
+ requestId: "",
3910
+ };
3911
+ const end = length == null ? reader.len : reader.pos + length;
3912
+ while (reader.pos < end) {
3913
+ const tag = reader.uint32();
3914
+ switch (tag >>> 3) {
3915
+ case 1:
3916
+ obj.requestId = reader.string();
3917
+ break;
3918
+ case 2:
3919
+ obj.query = HistoryQuery.codec().decode(reader, reader.uint32());
3920
+ break;
3921
+ case 3:
3922
+ obj.response = HistoryResponse.codec().decode(reader, reader.uint32());
3923
+ break;
3924
+ default:
3925
+ reader.skipType(tag & 7);
3926
+ break;
3927
+ }
3928
+ }
3929
+ return obj;
3930
+ });
3931
+ }
3932
+ return _codec;
3933
+ };
3934
+ HistoryRpc.encode = (obj) => {
3935
+ return encodeMessage(obj, HistoryRpc.codec());
3936
+ };
3937
+ HistoryRpc.decode = (buf) => {
3938
+ return decodeMessage(buf, HistoryRpc.codec());
3939
+ };
3940
+ })(HistoryRpc$1 || (HistoryRpc$1 = {}));
3941
+ var RateLimitProof;
3942
+ (function (RateLimitProof) {
3943
+ let _codec;
3944
+ RateLimitProof.codec = () => {
3945
+ if (_codec == null) {
3946
+ _codec = message$1((obj, w, opts = {}) => {
3947
+ if (opts.lengthDelimited !== false) {
3948
+ w.fork();
3949
+ }
3950
+ if (obj.proof != null && obj.proof.byteLength > 0) {
3951
+ w.uint32(10);
3952
+ w.bytes(obj.proof);
3953
+ }
3954
+ if (obj.merkleRoot != null && obj.merkleRoot.byteLength > 0) {
3955
+ w.uint32(18);
3956
+ w.bytes(obj.merkleRoot);
3957
+ }
3958
+ if (obj.epoch != null && obj.epoch.byteLength > 0) {
3959
+ w.uint32(26);
3960
+ w.bytes(obj.epoch);
3961
+ }
3962
+ if (obj.shareX != null && obj.shareX.byteLength > 0) {
3963
+ w.uint32(34);
3964
+ w.bytes(obj.shareX);
3965
+ }
3966
+ if (obj.shareY != null && obj.shareY.byteLength > 0) {
3967
+ w.uint32(42);
3968
+ w.bytes(obj.shareY);
3969
+ }
3970
+ if (obj.nullifier != null && obj.nullifier.byteLength > 0) {
3971
+ w.uint32(50);
3972
+ w.bytes(obj.nullifier);
3973
+ }
3974
+ if (obj.rlnIdentifier != null && obj.rlnIdentifier.byteLength > 0) {
3975
+ w.uint32(58);
3976
+ w.bytes(obj.rlnIdentifier);
3977
+ }
3978
+ if (opts.lengthDelimited !== false) {
3979
+ w.ldelim();
3980
+ }
3981
+ }, (reader, length) => {
3982
+ const obj = {
3983
+ proof: new Uint8Array(0),
3984
+ merkleRoot: new Uint8Array(0),
3985
+ epoch: new Uint8Array(0),
3986
+ shareX: new Uint8Array(0),
3987
+ shareY: new Uint8Array(0),
3988
+ nullifier: new Uint8Array(0),
3989
+ rlnIdentifier: new Uint8Array(0),
3990
+ };
3991
+ const end = length == null ? reader.len : reader.pos + length;
3992
+ while (reader.pos < end) {
3993
+ const tag = reader.uint32();
3994
+ switch (tag >>> 3) {
3995
+ case 1:
3996
+ obj.proof = reader.bytes();
3997
+ break;
3998
+ case 2:
3999
+ obj.merkleRoot = reader.bytes();
4000
+ break;
4001
+ case 3:
4002
+ obj.epoch = reader.bytes();
4003
+ break;
4004
+ case 4:
4005
+ obj.shareX = reader.bytes();
4006
+ break;
4007
+ case 5:
4008
+ obj.shareY = reader.bytes();
4009
+ break;
4010
+ case 6:
4011
+ obj.nullifier = reader.bytes();
4012
+ break;
4013
+ case 7:
4014
+ obj.rlnIdentifier = reader.bytes();
4015
+ break;
4016
+ default:
4017
+ reader.skipType(tag & 7);
4018
+ break;
4019
+ }
4020
+ }
4021
+ return obj;
4022
+ });
4023
+ }
4024
+ return _codec;
4025
+ };
4026
+ RateLimitProof.encode = (obj) => {
4027
+ return encodeMessage(obj, RateLimitProof.codec());
4028
+ };
4029
+ RateLimitProof.decode = (buf) => {
4030
+ return decodeMessage(buf, RateLimitProof.codec());
4031
+ };
4032
+ })(RateLimitProof || (RateLimitProof = {}));
4033
+ var WakuMessage;
4034
+ (function (WakuMessage) {
4035
+ let _codec;
4036
+ WakuMessage.codec = () => {
4037
+ if (_codec == null) {
4038
+ _codec = message$1((obj, w, opts = {}) => {
4039
+ if (opts.lengthDelimited !== false) {
4040
+ w.fork();
4041
+ }
4042
+ if (obj.payload != null && obj.payload.byteLength > 0) {
4043
+ w.uint32(10);
4044
+ w.bytes(obj.payload);
4045
+ }
4046
+ if (obj.contentTopic != null && obj.contentTopic !== "") {
4047
+ w.uint32(18);
4048
+ w.string(obj.contentTopic);
4049
+ }
4050
+ if (obj.version != null) {
4051
+ w.uint32(24);
4052
+ w.uint32(obj.version);
4053
+ }
4054
+ if (obj.timestamp != null) {
4055
+ w.uint32(80);
4056
+ w.sint64(obj.timestamp);
4057
+ }
4058
+ if (obj.meta != null) {
4059
+ w.uint32(90);
4060
+ w.bytes(obj.meta);
4061
+ }
4062
+ if (obj.rateLimitProof != null) {
4063
+ w.uint32(170);
4064
+ RateLimitProof.codec().encode(obj.rateLimitProof, w);
4065
+ }
4066
+ if (obj.ephemeral != null) {
4067
+ w.uint32(248);
4068
+ w.bool(obj.ephemeral);
4069
+ }
4070
+ if (opts.lengthDelimited !== false) {
4071
+ w.ldelim();
4072
+ }
4073
+ }, (reader, length) => {
4074
+ const obj = {
4075
+ payload: new Uint8Array(0),
4076
+ contentTopic: "",
4077
+ };
4078
+ const end = length == null ? reader.len : reader.pos + length;
4079
+ while (reader.pos < end) {
4080
+ const tag = reader.uint32();
4081
+ switch (tag >>> 3) {
4082
+ case 1:
4083
+ obj.payload = reader.bytes();
4084
+ break;
4085
+ case 2:
4086
+ obj.contentTopic = reader.string();
4087
+ break;
4088
+ case 3:
4089
+ obj.version = reader.uint32();
4090
+ break;
4091
+ case 10:
4092
+ obj.timestamp = reader.sint64();
4093
+ break;
4094
+ case 11:
4095
+ obj.meta = reader.bytes();
4096
+ break;
4097
+ case 21:
4098
+ obj.rateLimitProof = RateLimitProof.codec().decode(reader, reader.uint32());
4099
+ break;
4100
+ case 31:
4101
+ obj.ephemeral = reader.bool();
4102
+ break;
4103
+ default:
4104
+ reader.skipType(tag & 7);
4105
+ break;
4106
+ }
4107
+ }
4108
+ return obj;
4109
+ });
4110
+ }
4111
+ return _codec;
4112
+ };
4113
+ WakuMessage.encode = (obj) => {
4114
+ return encodeMessage(obj, WakuMessage.codec());
4115
+ };
4116
+ WakuMessage.decode = (buf) => {
4117
+ return decodeMessage(buf, WakuMessage.codec());
4118
+ };
4119
+ })(WakuMessage || (WakuMessage = {}));
4120
+
4121
+ /* eslint-disable import/export */
4122
+ var PeerInfo;
4123
+ (function (PeerInfo) {
4124
+ let _codec;
4125
+ PeerInfo.codec = () => {
4126
+ if (_codec == null) {
4127
+ _codec = message$1((obj, w, opts = {}) => {
4128
+ if (opts.lengthDelimited !== false) {
4129
+ w.fork();
4130
+ }
4131
+ if (obj.enr != null) {
4132
+ w.uint32(10);
4133
+ w.bytes(obj.enr);
4134
+ }
4135
+ if (opts.lengthDelimited !== false) {
4136
+ w.ldelim();
4137
+ }
4138
+ }, (reader, length) => {
4139
+ const obj = {};
4140
+ const end = length == null ? reader.len : reader.pos + length;
4141
+ while (reader.pos < end) {
4142
+ const tag = reader.uint32();
4143
+ switch (tag >>> 3) {
4144
+ case 1:
4145
+ obj.enr = reader.bytes();
4146
+ break;
4147
+ default:
4148
+ reader.skipType(tag & 7);
4149
+ break;
4150
+ }
4151
+ }
4152
+ return obj;
4153
+ });
4154
+ }
4155
+ return _codec;
4156
+ };
4157
+ PeerInfo.encode = (obj) => {
4158
+ return encodeMessage(obj, PeerInfo.codec());
4159
+ };
4160
+ PeerInfo.decode = (buf) => {
4161
+ return decodeMessage(buf, PeerInfo.codec());
4162
+ };
4163
+ })(PeerInfo || (PeerInfo = {}));
4164
+ var PeerExchangeQuery;
4165
+ (function (PeerExchangeQuery) {
4166
+ let _codec;
4167
+ PeerExchangeQuery.codec = () => {
4168
+ if (_codec == null) {
4169
+ _codec = message$1((obj, w, opts = {}) => {
4170
+ if (opts.lengthDelimited !== false) {
4171
+ w.fork();
4172
+ }
4173
+ if (obj.numPeers != null) {
4174
+ w.uint32(8);
4175
+ w.uint64(obj.numPeers);
4176
+ }
4177
+ if (opts.lengthDelimited !== false) {
4178
+ w.ldelim();
4179
+ }
4180
+ }, (reader, length) => {
4181
+ const obj = {};
4182
+ const end = length == null ? reader.len : reader.pos + length;
4183
+ while (reader.pos < end) {
4184
+ const tag = reader.uint32();
4185
+ switch (tag >>> 3) {
4186
+ case 1:
4187
+ obj.numPeers = reader.uint64();
4188
+ break;
4189
+ default:
4190
+ reader.skipType(tag & 7);
4191
+ break;
4192
+ }
4193
+ }
4194
+ return obj;
4195
+ });
4196
+ }
4197
+ return _codec;
4198
+ };
4199
+ PeerExchangeQuery.encode = (obj) => {
4200
+ return encodeMessage(obj, PeerExchangeQuery.codec());
4201
+ };
4202
+ PeerExchangeQuery.decode = (buf) => {
4203
+ return decodeMessage(buf, PeerExchangeQuery.codec());
4204
+ };
4205
+ })(PeerExchangeQuery || (PeerExchangeQuery = {}));
4206
+ var PeerExchangeResponse;
4207
+ (function (PeerExchangeResponse) {
4208
+ let _codec;
4209
+ PeerExchangeResponse.codec = () => {
4210
+ if (_codec == null) {
4211
+ _codec = message$1((obj, w, opts = {}) => {
4212
+ if (opts.lengthDelimited !== false) {
4213
+ w.fork();
4214
+ }
4215
+ if (obj.peerInfos != null) {
4216
+ for (const value of obj.peerInfos) {
4217
+ w.uint32(10);
4218
+ PeerInfo.codec().encode(value, w);
4219
+ }
4220
+ }
4221
+ if (opts.lengthDelimited !== false) {
4222
+ w.ldelim();
4223
+ }
4224
+ }, (reader, length) => {
4225
+ const obj = {
4226
+ peerInfos: [],
4227
+ };
4228
+ const end = length == null ? reader.len : reader.pos + length;
4229
+ while (reader.pos < end) {
4230
+ const tag = reader.uint32();
4231
+ switch (tag >>> 3) {
4232
+ case 1:
4233
+ obj.peerInfos.push(PeerInfo.codec().decode(reader, reader.uint32()));
4234
+ break;
4235
+ default:
4236
+ reader.skipType(tag & 7);
4237
+ break;
4238
+ }
4239
+ }
4240
+ return obj;
4241
+ });
4242
+ }
4243
+ return _codec;
4244
+ };
4245
+ PeerExchangeResponse.encode = (obj) => {
4246
+ return encodeMessage(obj, PeerExchangeResponse.codec());
4247
+ };
4248
+ PeerExchangeResponse.decode = (buf) => {
4249
+ return decodeMessage(buf, PeerExchangeResponse.codec());
4250
+ };
4251
+ })(PeerExchangeResponse || (PeerExchangeResponse = {}));
4252
+ var PeerExchangeRPC;
4253
+ (function (PeerExchangeRPC) {
4254
+ let _codec;
4255
+ PeerExchangeRPC.codec = () => {
4256
+ if (_codec == null) {
4257
+ _codec = message$1((obj, w, opts = {}) => {
4258
+ if (opts.lengthDelimited !== false) {
4259
+ w.fork();
4260
+ }
4261
+ if (obj.query != null) {
4262
+ w.uint32(10);
4263
+ PeerExchangeQuery.codec().encode(obj.query, w);
4264
+ }
4265
+ if (obj.response != null) {
4266
+ w.uint32(18);
4267
+ PeerExchangeResponse.codec().encode(obj.response, w);
4268
+ }
4269
+ if (opts.lengthDelimited !== false) {
4270
+ w.ldelim();
4271
+ }
4272
+ }, (reader, length) => {
4273
+ const obj = {};
4274
+ const end = length == null ? reader.len : reader.pos + length;
4275
+ while (reader.pos < end) {
4276
+ const tag = reader.uint32();
4277
+ switch (tag >>> 3) {
4278
+ case 1:
4279
+ obj.query = PeerExchangeQuery.codec().decode(reader, reader.uint32());
4280
+ break;
4281
+ case 2:
4282
+ obj.response = PeerExchangeResponse.codec().decode(reader, reader.uint32());
4283
+ break;
4284
+ default:
4285
+ reader.skipType(tag & 7);
4286
+ break;
4287
+ }
4288
+ }
4289
+ return obj;
4290
+ });
4291
+ }
4292
+ return _codec;
4293
+ };
4294
+ PeerExchangeRPC.encode = (obj) => {
4295
+ return encodeMessage(obj, PeerExchangeRPC.codec());
4296
+ };
4297
+ PeerExchangeRPC.decode = (buf) => {
4298
+ return decodeMessage(buf, PeerExchangeRPC.codec());
4299
+ };
4300
+ })(PeerExchangeRPC || (PeerExchangeRPC = {}));
4301
+
4302
+ export { FilterRpc$1 as F, HistoryRpc$1 as H, PushRpc$1 as P, TopicOnlyMessage as T, WakuMessage$3 as W, PushResponse as a, aspromise as b, base64$1 as c, commonjsGlobal as d, eventemitter as e, float as f, getDefaultExportFromCjs as g, getAugmentedNamespace as h, inquire_1 as i, PagingInfo as j, HistoryResponse as k, message as m, pool_1 as p, utf8$2 as u };