kicksdk-js 0.0.0-stage → 0.1.1

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.
package/pkg/kicksdk.js ADDED
@@ -0,0 +1,1485 @@
1
+ /* @ts-self-types="./kicksdk.d.ts" */
2
+
3
+ /**
4
+ * Reconnect delays: 1 s doubling to 30 s.
5
+ */
6
+ export class Backoff {
7
+ __destroy_into_raw() {
8
+ const ptr = this.__wbg_ptr;
9
+ this.__wbg_ptr = 0;
10
+ BackoffFinalization.unregister(this);
11
+ return ptr;
12
+ }
13
+ free() {
14
+ const ptr = this.__destroy_into_raw();
15
+ wasm.__wbg_backoff_free(ptr, 0);
16
+ }
17
+ /**
18
+ * From `initialMs`, doubling to `maxMs`.
19
+ * @param {number | null} [initial_ms]
20
+ * @param {number | null} [max_ms]
21
+ */
22
+ constructor(initial_ms, max_ms) {
23
+ const ret = wasm.backoff_new(!isLikeNone(initial_ms), isLikeNone(initial_ms) ? 0 : initial_ms, !isLikeNone(max_ms), isLikeNone(max_ms) ? 0 : max_ms);
24
+ this.__wbg_ptr = ret;
25
+ BackoffFinalization.register(this, this.__wbg_ptr, this);
26
+ return this;
27
+ }
28
+ /**
29
+ * The next wait, ms.
30
+ * @returns {number}
31
+ */
32
+ nextDelay() {
33
+ const ret = wasm.backoff_nextDelay(this.__wbg_ptr);
34
+ return ret;
35
+ }
36
+ /**
37
+ * A connection worked.
38
+ */
39
+ reset() {
40
+ wasm.backoff_reset(this.__wbg_ptr);
41
+ }
42
+ }
43
+ if (Symbol.dispose) Backoff.prototype[Symbol.dispose] = Backoff.prototype.free;
44
+
45
+ /**
46
+ * One connection's protocol. Each method returns the actions to carry out.
47
+ */
48
+ export class Session {
49
+ __destroy_into_raw() {
50
+ const ptr = this.__wbg_ptr;
51
+ this.__wbg_ptr = 0;
52
+ SessionFinalization.unregister(this);
53
+ return ptr;
54
+ }
55
+ free() {
56
+ const ptr = this.__destroy_into_raw();
57
+ wasm.__wbg_session_free(ptr, 0);
58
+ }
59
+ /**
60
+ * The socket closed.
61
+ * @returns {any}
62
+ */
63
+ closed() {
64
+ const ret = wasm.session_closed(this.__wbg_ptr);
65
+ if (ret[2]) {
66
+ throw takeFromExternrefTable0(ret[1]);
67
+ }
68
+ return takeFromExternrefTable0(ret[0]);
69
+ }
70
+ /**
71
+ * When to call `tick` next, in ms, or undefined.
72
+ * @returns {number | undefined}
73
+ */
74
+ deadline() {
75
+ const ret = wasm.session_deadline(this.__wbg_ptr);
76
+ return ret[0] === 0 ? undefined : ret[1];
77
+ }
78
+ /**
79
+ * Whether Kick accepted the connection.
80
+ * @returns {boolean}
81
+ */
82
+ isConnected() {
83
+ const ret = wasm.session_isConnected(this.__wbg_ptr);
84
+ return ret !== 0;
85
+ }
86
+ /**
87
+ * Whether a feed is subscribed.
88
+ * @param {string} channel
89
+ * @returns {boolean}
90
+ */
91
+ isSubscribed(channel) {
92
+ const ptr0 = passStringToWasm0(channel, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
93
+ const len0 = WASM_VECTOR_LEN;
94
+ const ret = wasm.session_isSubscribed(this.__wbg_ptr, ptr0, len0);
95
+ return ret !== 0;
96
+ }
97
+ /**
98
+ * A session for these feeds.
99
+ * @param {string[]} channels
100
+ */
101
+ constructor(channels) {
102
+ const ptr0 = passArrayJsValueToWasm0(channels, wasm.__wbindgen_malloc);
103
+ const len0 = WASM_VECTOR_LEN;
104
+ const ret = wasm.session_new(ptr0, len0);
105
+ this.__wbg_ptr = ret;
106
+ SessionFinalization.register(this, this.__wbg_ptr, this);
107
+ return this;
108
+ }
109
+ /**
110
+ * The socket opened.
111
+ * @param {string} token
112
+ * @param {number} now
113
+ * @returns {any}
114
+ */
115
+ open(token, now) {
116
+ const ptr0 = passStringToWasm0(token, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
117
+ const len0 = WASM_VECTOR_LEN;
118
+ const ret = wasm.session_open(this.__wbg_ptr, ptr0, len0, now);
119
+ if (ret[2]) {
120
+ throw takeFromExternrefTable0(ret[1]);
121
+ }
122
+ return takeFromExternrefTable0(ret[0]);
123
+ }
124
+ /**
125
+ * A text frame arrived.
126
+ * @param {string} text
127
+ * @param {number} now
128
+ * @returns {any}
129
+ */
130
+ receive(text, now) {
131
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
132
+ const len0 = WASM_VECTOR_LEN;
133
+ const ret = wasm.session_receive(this.__wbg_ptr, ptr0, len0, now);
134
+ if (ret[2]) {
135
+ throw takeFromExternrefTable0(ret[1]);
136
+ }
137
+ return takeFromExternrefTable0(ret[0]);
138
+ }
139
+ /**
140
+ * A new token, after a `refresh_token` action.
141
+ * @param {string} token
142
+ * @param {number} now
143
+ * @returns {any}
144
+ */
145
+ refresh(token, now) {
146
+ const ptr0 = passStringToWasm0(token, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
147
+ const len0 = WASM_VECTOR_LEN;
148
+ const ret = wasm.session_refresh(this.__wbg_ptr, ptr0, len0, now);
149
+ if (ret[2]) {
150
+ throw takeFromExternrefTable0(ret[1]);
151
+ }
152
+ return takeFromExternrefTable0(ret[0]);
153
+ }
154
+ /**
155
+ * The clock reached `deadline()`.
156
+ * @param {number} now
157
+ * @returns {any}
158
+ */
159
+ tick(now) {
160
+ const ret = wasm.session_tick(this.__wbg_ptr, now);
161
+ if (ret[2]) {
162
+ throw takeFromExternrefTable0(ret[1]);
163
+ }
164
+ return takeFromExternrefTable0(ret[0]);
165
+ }
166
+ }
167
+ if (Symbol.dispose) Session.prototype[Symbol.dispose] = Session.prototype.free;
168
+
169
+ /**
170
+ * An app token request (client credentials).
171
+ * @param {string} client_id
172
+ * @param {string} client_secret
173
+ * @param {any} endpoints_
174
+ * @returns {any}
175
+ */
176
+ export function appTokenRequest(client_id, client_secret, endpoints_) {
177
+ const ptr0 = passStringToWasm0(client_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
178
+ const len0 = WASM_VECTOR_LEN;
179
+ const ptr1 = passStringToWasm0(client_secret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
180
+ const len1 = WASM_VECTOR_LEN;
181
+ const ret = wasm.appTokenRequest(ptr0, len0, ptr1, len1, endpoints_);
182
+ if (ret[2]) {
183
+ throw takeFromExternrefTable0(ret[1]);
184
+ }
185
+ return takeFromExternrefTable0(ret[0]);
186
+ }
187
+
188
+ /**
189
+ * Bans a user for good.
190
+ * @param {string} session
191
+ * @param {string} channel_slug
192
+ * @param {string} username
193
+ * @param {any} endpoints_
194
+ * @returns {any}
195
+ */
196
+ export function banRequest(session, channel_slug, username, endpoints_) {
197
+ const ptr0 = passStringToWasm0(session, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
198
+ const len0 = WASM_VECTOR_LEN;
199
+ const ptr1 = passStringToWasm0(channel_slug, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
200
+ const len1 = WASM_VECTOR_LEN;
201
+ const ptr2 = passStringToWasm0(username, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
202
+ const len2 = WASM_VECTOR_LEN;
203
+ const ret = wasm.banRequest(ptr0, len0, ptr1, len1, ptr2, len2, endpoints_);
204
+ if (ret[2]) {
205
+ throw takeFromExternrefTable0(ret[1]);
206
+ }
207
+ return takeFromExternrefTable0(ret[0]);
208
+ }
209
+
210
+ /**
211
+ * A channel by slug (`kick.com/api/v2`): chatroom id, followers, live state.
212
+ * @param {string} slug
213
+ * @param {any} endpoints_
214
+ * @returns {any}
215
+ */
216
+ export function channelRequest(slug, endpoints_) {
217
+ const ptr0 = passStringToWasm0(slug, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
218
+ const len0 = WASM_VECTOR_LEN;
219
+ const ret = wasm.channelRequest(ptr0, len0, endpoints_);
220
+ if (ret[2]) {
221
+ throw takeFromExternrefTable0(ret[1]);
222
+ }
223
+ return takeFromExternrefTable0(ret[0]);
224
+ }
225
+
226
+ /**
227
+ * A user as a channel sees them.
228
+ * @param {string} channel_slug
229
+ * @param {string} username
230
+ * @param {any} endpoints_
231
+ * @returns {any}
232
+ */
233
+ export function channelUserRequest(channel_slug, username, endpoints_) {
234
+ const ptr0 = passStringToWasm0(channel_slug, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
235
+ const len0 = WASM_VECTOR_LEN;
236
+ const ptr1 = passStringToWasm0(username, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
237
+ const len1 = WASM_VECTOR_LEN;
238
+ const ret = wasm.channelUserRequest(ptr0, len0, ptr1, len1, endpoints_);
239
+ if (ret[2]) {
240
+ throw takeFromExternrefTable0(ret[1]);
241
+ }
242
+ return takeFromExternrefTable0(ret[0]);
243
+ }
244
+
245
+ /**
246
+ * `/channels` for up to 50 user ids.
247
+ * @param {string} token
248
+ * @param {Float64Array} user_ids
249
+ * @param {any} endpoints_
250
+ * @returns {any}
251
+ */
252
+ export function channelsByIdsRequest(token, user_ids, endpoints_) {
253
+ const ptr0 = passStringToWasm0(token, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
254
+ const len0 = WASM_VECTOR_LEN;
255
+ const ptr1 = passArrayF64ToWasm0(user_ids, wasm.__wbindgen_malloc);
256
+ const len1 = WASM_VECTOR_LEN;
257
+ const ret = wasm.channelsByIdsRequest(ptr0, len0, ptr1, len1, endpoints_);
258
+ if (ret[2]) {
259
+ throw takeFromExternrefTable0(ret[1]);
260
+ }
261
+ return takeFromExternrefTable0(ret[0]);
262
+ }
263
+
264
+ /**
265
+ * `/channels` for up to 50 slugs (one unknown slug fails them all).
266
+ * @param {string} token
267
+ * @param {string[]} slugs
268
+ * @param {any} endpoints_
269
+ * @returns {any}
270
+ */
271
+ export function channelsBySlugsRequest(token, slugs, endpoints_) {
272
+ const ptr0 = passStringToWasm0(token, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
273
+ const len0 = WASM_VECTOR_LEN;
274
+ const ptr1 = passArrayJsValueToWasm0(slugs, wasm.__wbindgen_malloc);
275
+ const len1 = WASM_VECTOR_LEN;
276
+ const ret = wasm.channelsBySlugsRequest(ptr0, len0, ptr1, len1, endpoints_);
277
+ if (ret[2]) {
278
+ throw takeFromExternrefTable0(ret[1]);
279
+ }
280
+ return takeFromExternrefTable0(ret[0]);
281
+ }
282
+
283
+ /**
284
+ * The feeds for one chat, the chat feed first.
285
+ * @param {number} chatroom_id
286
+ * @param {number | null} [channel_id]
287
+ * @returns {string[]}
288
+ */
289
+ export function chatChannels(chatroom_id, channel_id) {
290
+ const ret = wasm.chatChannels(chatroom_id, !isLikeNone(channel_id), isLikeNone(channel_id) ? 0 : channel_id);
291
+ var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]);
292
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
293
+ return v1;
294
+ }
295
+
296
+ /**
297
+ * Where a channel's chat is served.
298
+ * @param {number} channel_id
299
+ * @param {string} client_id
300
+ * @param {any} endpoints_
301
+ * @returns {any}
302
+ */
303
+ export function chatConnectionRequest(channel_id, client_id, endpoints_) {
304
+ const ptr0 = passStringToWasm0(client_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
305
+ const len0 = WASM_VECTOR_LEN;
306
+ const ret = wasm.chatConnectionRequest(channel_id, ptr0, len0, endpoints_);
307
+ if (ret[2]) {
308
+ throw takeFromExternrefTable0(ret[1]);
309
+ }
310
+ return takeFromExternrefTable0(ret[0]);
311
+ }
312
+
313
+ /**
314
+ * Where Kick's realtime is served in general.
315
+ * @param {string} client_id
316
+ * @param {any} endpoints_
317
+ * @returns {any}
318
+ */
319
+ export function connectionRequest(client_id, endpoints_) {
320
+ const ptr0 = passStringToWasm0(client_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
321
+ const len0 = WASM_VECTOR_LEN;
322
+ const ret = wasm.connectionRequest(ptr0, len0, endpoints_);
323
+ if (ret[2]) {
324
+ throw takeFromExternrefTable0(ret[1]);
325
+ }
326
+ return takeFromExternrefTable0(ret[0]);
327
+ }
328
+
329
+ /**
330
+ * Deletes a message.
331
+ * @param {string} session
332
+ * @param {number} chatroom_id
333
+ * @param {string} message_id
334
+ * @param {any} endpoints_
335
+ * @returns {any}
336
+ */
337
+ export function deleteMessageRequest(session, chatroom_id, message_id, endpoints_) {
338
+ const ptr0 = passStringToWasm0(session, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
339
+ const len0 = WASM_VECTOR_LEN;
340
+ const ptr1 = passStringToWasm0(message_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
341
+ const len1 = WASM_VECTOR_LEN;
342
+ const ret = wasm.deleteMessageRequest(ptr0, len0, chatroom_id, ptr1, len1, endpoints_);
343
+ if (ret[2]) {
344
+ throw takeFromExternrefTable0(ret[1]);
345
+ }
346
+ return takeFromExternrefTable0(ret[0]);
347
+ }
348
+
349
+ /**
350
+ * An emote's image URL.
351
+ * @param {string} id
352
+ * @returns {string}
353
+ */
354
+ export function emoteUrl(id) {
355
+ let deferred2_0;
356
+ let deferred2_1;
357
+ try {
358
+ const ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
359
+ const len0 = WASM_VECTOR_LEN;
360
+ const ret = wasm.emoteUrl(ptr0, len0);
361
+ deferred2_0 = ret[0];
362
+ deferred2_1 = ret[1];
363
+ return getStringFromWasm0(ret[0], ret[1]);
364
+ } finally {
365
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
366
+ }
367
+ }
368
+
369
+ /**
370
+ * Recent chat and the pin, by channel id.
371
+ * @param {number} channel_id
372
+ * @param {any} endpoints_
373
+ * @returns {any}
374
+ */
375
+ export function historyRequest(channel_id, endpoints_) {
376
+ const ret = wasm.historyRequest(channel_id, endpoints_);
377
+ if (ret[2]) {
378
+ throw takeFromExternrefTable0(ret[1]);
379
+ }
380
+ return takeFromExternrefTable0(ret[0]);
381
+ }
382
+
383
+ /**
384
+ * `/livestreams` for any number of user ids: one request per 50.
385
+ * @param {string} token
386
+ * @param {Float64Array} user_ids
387
+ * @param {any} endpoints_
388
+ * @returns {any}
389
+ */
390
+ export function livestreamsRequests(token, user_ids, endpoints_) {
391
+ const ptr0 = passStringToWasm0(token, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
392
+ const len0 = WASM_VECTOR_LEN;
393
+ const ptr1 = passArrayF64ToWasm0(user_ids, wasm.__wbindgen_malloc);
394
+ const len1 = WASM_VECTOR_LEN;
395
+ const ret = wasm.livestreamsRequests(ptr0, len0, ptr1, len1, endpoints_);
396
+ if (ret[2]) {
397
+ throw takeFromExternrefTable0(ret[1]);
398
+ }
399
+ return takeFromExternrefTable0(ret[0]);
400
+ }
401
+
402
+ /**
403
+ * The signed-in viewer's standing on a channel.
404
+ * @param {string} session
405
+ * @param {string} channel_slug
406
+ * @param {any} endpoints_
407
+ * @returns {any}
408
+ */
409
+ export function meRequest(session, channel_slug, endpoints_) {
410
+ const ptr0 = passStringToWasm0(session, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
411
+ const len0 = WASM_VECTOR_LEN;
412
+ const ptr1 = passStringToWasm0(channel_slug, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
413
+ const len1 = WASM_VECTOR_LEN;
414
+ const ret = wasm.meRequest(ptr0, len0, ptr1, len1, endpoints_);
415
+ if (ret[2]) {
416
+ throw takeFromExternrefTable0(ret[1]);
417
+ }
418
+ return takeFromExternrefTable0(ret[0]);
419
+ }
420
+
421
+ /**
422
+ * Whether an acting call worked; throws with `status` if not.
423
+ * @param {number} status
424
+ * @param {string} body
425
+ */
426
+ export function parseAction(status, body) {
427
+ const ptr0 = passStringToWasm0(body, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
428
+ const len0 = WASM_VECTOR_LEN;
429
+ const ret = wasm.parseAction(status, ptr0, len0);
430
+ if (ret[1]) {
431
+ throw takeFromExternrefTable0(ret[0]);
432
+ }
433
+ }
434
+
435
+ /**
436
+ * Reads an app token answer.
437
+ * @param {number} status
438
+ * @param {string} body
439
+ * @returns {any}
440
+ */
441
+ export function parseAppToken(status, body) {
442
+ const ptr0 = passStringToWasm0(body, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
443
+ const len0 = WASM_VECTOR_LEN;
444
+ const ret = wasm.parseAppToken(status, ptr0, len0);
445
+ if (ret[2]) {
446
+ throw takeFromExternrefTable0(ret[1]);
447
+ }
448
+ return takeFromExternrefTable0(ret[0]);
449
+ }
450
+
451
+ /**
452
+ * Reads a website channel answer.
453
+ * @param {number} status
454
+ * @param {string} body
455
+ * @returns {any}
456
+ */
457
+ export function parseChannel(status, body) {
458
+ const ptr0 = passStringToWasm0(body, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
459
+ const len0 = WASM_VECTOR_LEN;
460
+ const ret = wasm.parseChannel(status, ptr0, len0);
461
+ if (ret[2]) {
462
+ throw takeFromExternrefTable0(ret[1]);
463
+ }
464
+ return takeFromExternrefTable0(ret[0]);
465
+ }
466
+
467
+ /**
468
+ * Reads a channel user answer.
469
+ * @param {number} status
470
+ * @param {string} body
471
+ * @returns {any}
472
+ */
473
+ export function parseChannelUser(status, body) {
474
+ const ptr0 = passStringToWasm0(body, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
475
+ const len0 = WASM_VECTOR_LEN;
476
+ const ret = wasm.parseChannelUser(status, ptr0, len0);
477
+ if (ret[2]) {
478
+ throw takeFromExternrefTable0(ret[1]);
479
+ }
480
+ return takeFromExternrefTable0(ret[0]);
481
+ }
482
+
483
+ /**
484
+ * Reads a `/channels` answer.
485
+ * @param {number} status
486
+ * @param {string} body
487
+ * @returns {any}
488
+ */
489
+ export function parseChannels(status, body) {
490
+ const ptr0 = passStringToWasm0(body, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
491
+ const len0 = WASM_VECTOR_LEN;
492
+ const ret = wasm.parseChannels(status, ptr0, len0);
493
+ if (ret[2]) {
494
+ throw takeFromExternrefTable0(ret[1]);
495
+ }
496
+ return takeFromExternrefTable0(ret[0]);
497
+ }
498
+
499
+ /**
500
+ * Reads either connection answer: `[{provider, url}…]`.
501
+ * @param {number} status
502
+ * @param {string} body
503
+ * @returns {any}
504
+ */
505
+ export function parseConnection(status, body) {
506
+ const ptr0 = passStringToWasm0(body, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
507
+ const len0 = WASM_VECTOR_LEN;
508
+ const ret = wasm.parseConnection(status, ptr0, len0);
509
+ if (ret[2]) {
510
+ throw takeFromExternrefTable0(ret[1]);
511
+ }
512
+ return takeFromExternrefTable0(ret[0]);
513
+ }
514
+
515
+ /**
516
+ * A message's text and emotes.
517
+ * @param {string} text
518
+ * @param {boolean} combine
519
+ * @returns {any}
520
+ */
521
+ export function parseContent(text, combine) {
522
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
523
+ const len0 = WASM_VECTOR_LEN;
524
+ const ret = wasm.parseContent(ptr0, len0, combine);
525
+ if (ret[2]) {
526
+ throw takeFromExternrefTable0(ret[1]);
527
+ }
528
+ return takeFromExternrefTable0(ret[0]);
529
+ }
530
+
531
+ /**
532
+ * A feed event, typed: `{type: "chat_message", …}`. `data` as Kick sent it.
533
+ * @param {string} name
534
+ * @param {any} data
535
+ * @returns {any}
536
+ */
537
+ export function parseEvent(name, data) {
538
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
539
+ const len0 = WASM_VECTOR_LEN;
540
+ const ret = wasm.parseEvent(ptr0, len0, data);
541
+ if (ret[2]) {
542
+ throw takeFromExternrefTable0(ret[1]);
543
+ }
544
+ return takeFromExternrefTable0(ret[0]);
545
+ }
546
+
547
+ /**
548
+ * Reads a history answer: `{messages, pinned}`.
549
+ * @param {number} status
550
+ * @param {string} body
551
+ * @returns {any}
552
+ */
553
+ export function parseHistory(status, body) {
554
+ const ptr0 = passStringToWasm0(body, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
555
+ const len0 = WASM_VECTOR_LEN;
556
+ const ret = wasm.parseHistory(status, ptr0, len0);
557
+ if (ret[2]) {
558
+ throw takeFromExternrefTable0(ret[1]);
559
+ }
560
+ return takeFromExternrefTable0(ret[0]);
561
+ }
562
+
563
+ /**
564
+ * Reads a `/livestreams` answer.
565
+ * @param {number} status
566
+ * @param {string} body
567
+ * @returns {any}
568
+ */
569
+ export function parseLivestreams(status, body) {
570
+ const ptr0 = passStringToWasm0(body, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
571
+ const len0 = WASM_VECTOR_LEN;
572
+ const ret = wasm.parseLivestreams(status, ptr0, len0);
573
+ if (ret[2]) {
574
+ throw takeFromExternrefTable0(ret[1]);
575
+ }
576
+ return takeFromExternrefTable0(ret[0]);
577
+ }
578
+
579
+ /**
580
+ * Reads a `me` answer.
581
+ * @param {number} status
582
+ * @param {string} body
583
+ * @returns {any}
584
+ */
585
+ export function parseMe(status, body) {
586
+ const ptr0 = passStringToWasm0(body, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
587
+ const len0 = WASM_VECTOR_LEN;
588
+ const ret = wasm.parseMe(status, ptr0, len0);
589
+ if (ret[2]) {
590
+ throw takeFromExternrefTable0(ret[1]);
591
+ }
592
+ return takeFromExternrefTable0(ret[0]);
593
+ }
594
+
595
+ /**
596
+ * The PEM from a public key answer.
597
+ * @param {number} status
598
+ * @param {string} body
599
+ * @returns {string}
600
+ */
601
+ export function parsePublicKey(status, body) {
602
+ let deferred3_0;
603
+ let deferred3_1;
604
+ try {
605
+ const ptr0 = passStringToWasm0(body, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
606
+ const len0 = WASM_VECTOR_LEN;
607
+ const ret = wasm.parsePublicKey(status, ptr0, len0);
608
+ var ptr2 = ret[0];
609
+ var len2 = ret[1];
610
+ if (ret[3]) {
611
+ ptr2 = 0; len2 = 0;
612
+ throw takeFromExternrefTable0(ret[2]);
613
+ }
614
+ deferred3_0 = ptr2;
615
+ deferred3_1 = len2;
616
+ return getStringFromWasm0(ptr2, len2);
617
+ } finally {
618
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
619
+ }
620
+ }
621
+
622
+ /**
623
+ * Reads a subscriptions answer.
624
+ * @param {number} status
625
+ * @param {string} body
626
+ * @returns {any}
627
+ */
628
+ export function parseSubscriptions(status, body) {
629
+ const ptr0 = passStringToWasm0(body, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
630
+ const len0 = WASM_VECTOR_LEN;
631
+ const ret = wasm.parseSubscriptions(status, ptr0, len0);
632
+ if (ret[2]) {
633
+ throw takeFromExternrefTable0(ret[1]);
634
+ }
635
+ return takeFromExternrefTable0(ret[0]);
636
+ }
637
+
638
+ /**
639
+ * The token from a token answer.
640
+ * @param {number} status
641
+ * @param {string} body
642
+ * @returns {string}
643
+ */
644
+ export function parseToken(status, body) {
645
+ let deferred3_0;
646
+ let deferred3_1;
647
+ try {
648
+ const ptr0 = passStringToWasm0(body, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
649
+ const len0 = WASM_VECTOR_LEN;
650
+ const ret = wasm.parseToken(status, ptr0, len0);
651
+ var ptr2 = ret[0];
652
+ var len2 = ret[1];
653
+ if (ret[3]) {
654
+ ptr2 = 0; len2 = 0;
655
+ throw takeFromExternrefTable0(ret[2]);
656
+ }
657
+ deferred3_0 = ptr2;
658
+ deferred3_1 = len2;
659
+ return getStringFromWasm0(ptr2, len2);
660
+ } finally {
661
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
662
+ }
663
+ }
664
+
665
+ /**
666
+ * Reads a delivery's body by its type header, without checking anything.
667
+ * @param {string} event_type
668
+ * @param {string} body
669
+ * @returns {any}
670
+ */
671
+ export function parseWebhook(event_type, body) {
672
+ const ptr0 = passStringToWasm0(event_type, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
673
+ const len0 = WASM_VECTOR_LEN;
674
+ const ptr1 = passStringToWasm0(body, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
675
+ const len1 = WASM_VECTOR_LEN;
676
+ const ret = wasm.parseWebhook(ptr0, len0, ptr1, len1);
677
+ if (ret[2]) {
678
+ throw takeFromExternrefTable0(ret[1]);
679
+ }
680
+ return takeFromExternrefTable0(ret[0]);
681
+ }
682
+
683
+ /**
684
+ * Pins a message (the feed's data for it, whole) for `minutes`.
685
+ * @param {string} session
686
+ * @param {string} channel_slug
687
+ * @param {any} message
688
+ * @param {number} minutes
689
+ * @param {any} endpoints_
690
+ * @returns {any}
691
+ */
692
+ export function pinRequest(session, channel_slug, message, minutes, endpoints_) {
693
+ const ptr0 = passStringToWasm0(session, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
694
+ const len0 = WASM_VECTOR_LEN;
695
+ const ptr1 = passStringToWasm0(channel_slug, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
696
+ const len1 = WASM_VECTOR_LEN;
697
+ const ret = wasm.pinRequest(ptr0, len0, ptr1, len1, message, minutes, endpoints_);
698
+ if (ret[2]) {
699
+ throw takeFromExternrefTable0(ret[1]);
700
+ }
701
+ return takeFromExternrefTable0(ret[0]);
702
+ }
703
+
704
+ /**
705
+ * The webhook signing key request.
706
+ * @param {any} endpoints_
707
+ * @returns {any}
708
+ */
709
+ export function publicKeyRequest(endpoints_) {
710
+ const ret = wasm.publicKeyRequest(endpoints_);
711
+ if (ret[2]) {
712
+ throw takeFromExternrefTable0(ret[1]);
713
+ }
714
+ return takeFromExternrefTable0(ret[0]);
715
+ }
716
+
717
+ /**
718
+ * Sends a message, or a reply when `replyTo` is
719
+ * `{message_id, content, sender_id, sender_username}`.
720
+ * @param {string} session
721
+ * @param {number} chatroom_id
722
+ * @param {string} text
723
+ * @param {string} message_ref
724
+ * @param {any} reply_to
725
+ * @param {any} endpoints_
726
+ * @returns {any}
727
+ */
728
+ export function sendRequest(session, chatroom_id, text, message_ref, reply_to, endpoints_) {
729
+ const ptr0 = passStringToWasm0(session, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
730
+ const len0 = WASM_VECTOR_LEN;
731
+ const ptr1 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
732
+ const len1 = WASM_VECTOR_LEN;
733
+ const ptr2 = passStringToWasm0(message_ref, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
734
+ const len2 = WASM_VECTOR_LEN;
735
+ const ret = wasm.sendRequest(ptr0, len0, chatroom_id, ptr1, len1, ptr2, len2, reply_to, endpoints_);
736
+ if (ret[2]) {
737
+ throw takeFromExternrefTable0(ret[1]);
738
+ }
739
+ return takeFromExternrefTable0(ret[0]);
740
+ }
741
+
742
+ /**
743
+ * Subscribes the app to webhook `events` (`[{name, version}]`) for one channel.
744
+ * @param {string} token
745
+ * @param {number} broadcaster_user_id
746
+ * @param {any} events
747
+ * @param {any} endpoints_
748
+ * @returns {any}
749
+ */
750
+ export function subscribeRequest(token, broadcaster_user_id, events, endpoints_) {
751
+ const ptr0 = passStringToWasm0(token, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
752
+ const len0 = WASM_VECTOR_LEN;
753
+ const ret = wasm.subscribeRequest(ptr0, len0, broadcaster_user_id, events, endpoints_);
754
+ if (ret[2]) {
755
+ throw takeFromExternrefTable0(ret[1]);
756
+ }
757
+ return takeFromExternrefTable0(ret[0]);
758
+ }
759
+
760
+ /**
761
+ * Every webhook subscription the app has.
762
+ * @param {string} token
763
+ * @param {any} endpoints_
764
+ * @returns {any}
765
+ */
766
+ export function subscriptionsRequest(token, endpoints_) {
767
+ const ptr0 = passStringToWasm0(token, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
768
+ const len0 = WASM_VECTOR_LEN;
769
+ const ret = wasm.subscriptionsRequest(ptr0, len0, endpoints_);
770
+ if (ret[2]) {
771
+ throw takeFromExternrefTable0(ret[1]);
772
+ }
773
+ return takeFromExternrefTable0(ret[0]);
774
+ }
775
+
776
+ /**
777
+ * Times a user out.
778
+ * @param {string} session
779
+ * @param {string} channel_slug
780
+ * @param {string} username
781
+ * @param {number} minutes
782
+ * @param {any} endpoints_
783
+ * @returns {any}
784
+ */
785
+ export function timeoutRequest(session, channel_slug, username, minutes, endpoints_) {
786
+ const ptr0 = passStringToWasm0(session, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
787
+ const len0 = WASM_VECTOR_LEN;
788
+ const ptr1 = passStringToWasm0(channel_slug, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
789
+ const len1 = WASM_VECTOR_LEN;
790
+ const ptr2 = passStringToWasm0(username, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
791
+ const len2 = WASM_VECTOR_LEN;
792
+ const ret = wasm.timeoutRequest(ptr0, len0, ptr1, len1, ptr2, len2, minutes, endpoints_);
793
+ if (ret[2]) {
794
+ throw takeFromExternrefTable0(ret[1]);
795
+ }
796
+ return takeFromExternrefTable0(ret[0]);
797
+ }
798
+
799
+ /**
800
+ * A guest token request for `clientId`.
801
+ * @param {string} client_id
802
+ * @param {any} endpoints_
803
+ * @returns {any}
804
+ */
805
+ export function tokenRequest(client_id, endpoints_) {
806
+ const ptr0 = passStringToWasm0(client_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
807
+ const len0 = WASM_VECTOR_LEN;
808
+ const ret = wasm.tokenRequest(ptr0, len0, endpoints_);
809
+ if (ret[2]) {
810
+ throw takeFromExternrefTable0(ret[1]);
811
+ }
812
+ return takeFromExternrefTable0(ret[0]);
813
+ }
814
+
815
+ /**
816
+ * The top live streams, overall or in a category or language: up to 100.
817
+ * `sort` is `"viewer_count"` (the default) or `"started_at"`.
818
+ * @param {string} token
819
+ * @param {number | null | undefined} category_id
820
+ * @param {string | null | undefined} language
821
+ * @param {string | null | undefined} sort
822
+ * @param {number | null | undefined} limit
823
+ * @param {any} endpoints_
824
+ * @returns {any}
825
+ */
826
+ export function topLivestreamsRequest(token, category_id, language, sort, limit, endpoints_) {
827
+ const ptr0 = passStringToWasm0(token, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
828
+ const len0 = WASM_VECTOR_LEN;
829
+ var ptr1 = isLikeNone(language) ? 0 : passStringToWasm0(language, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
830
+ var len1 = WASM_VECTOR_LEN;
831
+ var ptr2 = isLikeNone(sort) ? 0 : passStringToWasm0(sort, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
832
+ var len2 = WASM_VECTOR_LEN;
833
+ const ret = wasm.topLivestreamsRequest(ptr0, len0, !isLikeNone(category_id), isLikeNone(category_id) ? 0 : category_id, ptr1, len1, ptr2, len2, isLikeNone(limit) ? Number.MAX_SAFE_INTEGER : (limit) >>> 0, endpoints_);
834
+ if (ret[2]) {
835
+ throw takeFromExternrefTable0(ret[1]);
836
+ }
837
+ return takeFromExternrefTable0(ret[0]);
838
+ }
839
+
840
+ /**
841
+ * Lifts a ban or timeout.
842
+ * @param {string} session
843
+ * @param {string} channel_slug
844
+ * @param {string} username
845
+ * @param {any} endpoints_
846
+ * @returns {any}
847
+ */
848
+ export function unbanRequest(session, channel_slug, username, endpoints_) {
849
+ const ptr0 = passStringToWasm0(session, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
850
+ const len0 = WASM_VECTOR_LEN;
851
+ const ptr1 = passStringToWasm0(channel_slug, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
852
+ const len1 = WASM_VECTOR_LEN;
853
+ const ptr2 = passStringToWasm0(username, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
854
+ const len2 = WASM_VECTOR_LEN;
855
+ const ret = wasm.unbanRequest(ptr0, len0, ptr1, len1, ptr2, len2, endpoints_);
856
+ if (ret[2]) {
857
+ throw takeFromExternrefTable0(ret[1]);
858
+ }
859
+ return takeFromExternrefTable0(ret[0]);
860
+ }
861
+
862
+ /**
863
+ * Removes the pin.
864
+ * @param {string} session
865
+ * @param {string} channel_slug
866
+ * @param {any} endpoints_
867
+ * @returns {any}
868
+ */
869
+ export function unpinRequest(session, channel_slug, endpoints_) {
870
+ const ptr0 = passStringToWasm0(session, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
871
+ const len0 = WASM_VECTOR_LEN;
872
+ const ptr1 = passStringToWasm0(channel_slug, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
873
+ const len1 = WASM_VECTOR_LEN;
874
+ const ret = wasm.unpinRequest(ptr0, len0, ptr1, len1, endpoints_);
875
+ if (ret[2]) {
876
+ throw takeFromExternrefTable0(ret[1]);
877
+ }
878
+ return takeFromExternrefTable0(ret[0]);
879
+ }
880
+
881
+ /**
882
+ * Removes subscriptions, 50 per request.
883
+ * @param {string} token
884
+ * @param {string[]} ids
885
+ * @param {any} endpoints_
886
+ * @returns {any}
887
+ */
888
+ export function unsubscribeRequests(token, ids, endpoints_) {
889
+ const ptr0 = passStringToWasm0(token, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
890
+ const len0 = WASM_VECTOR_LEN;
891
+ const ptr1 = passArrayJsValueToWasm0(ids, wasm.__wbindgen_malloc);
892
+ const len1 = WASM_VECTOR_LEN;
893
+ const ret = wasm.unsubscribeRequests(ptr0, len0, ptr1, len1, endpoints_);
894
+ if (ret[2]) {
895
+ throw takeFromExternrefTable0(ret[1]);
896
+ }
897
+ return takeFromExternrefTable0(ret[0]);
898
+ }
899
+
900
+ /**
901
+ * Checks a delivery: `headers` as `[[name, value]…]` or an object, `body` the
902
+ * raw text. Returns the typed event, or throws.
903
+ * @param {string} public_key_pem
904
+ * @param {any} headers
905
+ * @param {string} body
906
+ * @returns {any}
907
+ */
908
+ export function verifyWebhook(public_key_pem, headers, body) {
909
+ const ptr0 = passStringToWasm0(public_key_pem, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
910
+ const len0 = WASM_VECTOR_LEN;
911
+ const ptr1 = passStringToWasm0(body, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
912
+ const len1 = WASM_VECTOR_LEN;
913
+ const ret = wasm.verifyWebhook(ptr0, len0, headers, ptr1, len1);
914
+ if (ret[2]) {
915
+ throw takeFromExternrefTable0(ret[1]);
916
+ }
917
+ return takeFromExternrefTable0(ret[0]);
918
+ }
919
+ function __wbg_get_imports() {
920
+ const import0 = {
921
+ __proto__: null,
922
+ __wbg_Error_30c8987f7c2ed4e2: function(arg0, arg1) {
923
+ const ret = Error(getStringFromWasm0(arg0, arg1));
924
+ return ret;
925
+ },
926
+ __wbg_String_8564e559799eccda: function(arg0, arg1) {
927
+ const ret = String(arg1);
928
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
929
+ const len1 = WASM_VECTOR_LEN;
930
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
931
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
932
+ },
933
+ __wbg___wbindgen_bigint_get_as_i64_a2383202b9353e4c: function(arg0, arg1) {
934
+ const v = arg1;
935
+ const ret = typeof(v) === 'bigint' ? v : undefined;
936
+ getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
937
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
938
+ },
939
+ __wbg___wbindgen_boolean_get_5b446f51afd21013: function(arg0) {
940
+ const v = arg0;
941
+ const ret = typeof(v) === 'boolean' ? v : undefined;
942
+ return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
943
+ },
944
+ __wbg___wbindgen_debug_string_4687d8d8c2017d52: function(arg0, arg1) {
945
+ const ret = debugString(arg1);
946
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
947
+ const len1 = WASM_VECTOR_LEN;
948
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
949
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
950
+ },
951
+ __wbg___wbindgen_in_92f62ee1427d9e49: function(arg0, arg1) {
952
+ const ret = arg0 in arg1;
953
+ return ret;
954
+ },
955
+ __wbg___wbindgen_is_bigint_b123553bed3bb382: function(arg0) {
956
+ const ret = typeof(arg0) === 'bigint';
957
+ return ret;
958
+ },
959
+ __wbg___wbindgen_is_function_1f9d30630b8b1d3d: function(arg0) {
960
+ const ret = typeof(arg0) === 'function';
961
+ return ret;
962
+ },
963
+ __wbg___wbindgen_is_null_e343b7d08827ba72: function(arg0) {
964
+ const ret = arg0 === null;
965
+ return ret;
966
+ },
967
+ __wbg___wbindgen_is_object_3c45d4f2dde4e749: function(arg0) {
968
+ const val = arg0;
969
+ const ret = typeof(val) === 'object' && val !== null;
970
+ return ret;
971
+ },
972
+ __wbg___wbindgen_is_string_90b56bc79aad6f6c: function(arg0) {
973
+ const ret = typeof(arg0) === 'string';
974
+ return ret;
975
+ },
976
+ __wbg___wbindgen_is_undefined_8865fb403f8fe9d8: function(arg0) {
977
+ const ret = arg0 === undefined;
978
+ return ret;
979
+ },
980
+ __wbg___wbindgen_jsval_eq_02babf21faa37971: function(arg0, arg1) {
981
+ const ret = arg0 === arg1;
982
+ return ret;
983
+ },
984
+ __wbg___wbindgen_jsval_loose_eq_677f21e468d6b461: function(arg0, arg1) {
985
+ const ret = arg0 == arg1;
986
+ return ret;
987
+ },
988
+ __wbg___wbindgen_number_get_2e0e7dee9f701a71: function(arg0, arg1) {
989
+ const obj = arg1;
990
+ const ret = typeof(obj) === 'number' ? obj : undefined;
991
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
992
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
993
+ },
994
+ __wbg___wbindgen_string_get_0380ccaa2f57f0d9: function(arg0, arg1) {
995
+ const obj = arg1;
996
+ const ret = typeof(obj) === 'string' ? obj : undefined;
997
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
998
+ var len1 = WASM_VECTOR_LEN;
999
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
1000
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
1001
+ },
1002
+ __wbg___wbindgen_throw_41e9ee4f547fc59a: function(arg0, arg1) {
1003
+ throw new Error(getStringFromWasm0(arg0, arg1));
1004
+ },
1005
+ __wbg_call_6137034ef55c9d0f: function() { return handleError(function (arg0, arg1) {
1006
+ const ret = arg0.call(arg1);
1007
+ return ret;
1008
+ }, arguments); },
1009
+ __wbg_done_b41a1d26cdb37fb6: function(arg0) {
1010
+ const ret = arg0.done;
1011
+ return ret;
1012
+ },
1013
+ __wbg_entries_fb6397112b1de25f: function(arg0) {
1014
+ const ret = Object.entries(arg0);
1015
+ return ret;
1016
+ },
1017
+ __wbg_get_658f6698067d9515: function() { return handleError(function (arg0, arg1) {
1018
+ const ret = Reflect.get(arg0, arg1);
1019
+ return ret;
1020
+ }, arguments); },
1021
+ __wbg_get_6c896e0571ddae51: function(arg0, arg1) {
1022
+ const ret = arg0[arg1 >>> 0];
1023
+ return ret;
1024
+ },
1025
+ __wbg_get_unchecked_288889d017702237: function(arg0, arg1) {
1026
+ const ret = arg0[arg1 >>> 0];
1027
+ return ret;
1028
+ },
1029
+ __wbg_instanceof_ArrayBuffer_a99f175873e5d9b8: function(arg0) {
1030
+ let result;
1031
+ try {
1032
+ result = arg0 instanceof ArrayBuffer;
1033
+ } catch (_) {
1034
+ result = false;
1035
+ }
1036
+ const ret = result;
1037
+ return ret;
1038
+ },
1039
+ __wbg_instanceof_Map_b2611749102d7ba3: function(arg0) {
1040
+ let result;
1041
+ try {
1042
+ result = arg0 instanceof Map;
1043
+ } catch (_) {
1044
+ result = false;
1045
+ }
1046
+ const ret = result;
1047
+ return ret;
1048
+ },
1049
+ __wbg_instanceof_Uint8Array_828cef2aaacafc31: function(arg0) {
1050
+ let result;
1051
+ try {
1052
+ result = arg0 instanceof Uint8Array;
1053
+ } catch (_) {
1054
+ result = false;
1055
+ }
1056
+ const ret = result;
1057
+ return ret;
1058
+ },
1059
+ __wbg_isArray_e15a2ff68ffdbef2: function(arg0) {
1060
+ const ret = Array.isArray(arg0);
1061
+ return ret;
1062
+ },
1063
+ __wbg_isSafeInteger_717808ad6a54bd9e: function(arg0) {
1064
+ const ret = Number.isSafeInteger(arg0);
1065
+ return ret;
1066
+ },
1067
+ __wbg_iterator_e3c31c892080e444: function() {
1068
+ const ret = Symbol.iterator;
1069
+ return ret;
1070
+ },
1071
+ __wbg_length_7f3c00c40364105e: function(arg0) {
1072
+ const ret = arg0.length;
1073
+ return ret;
1074
+ },
1075
+ __wbg_length_d4bdea10311bd9cf: function(arg0) {
1076
+ const ret = arg0.length;
1077
+ return ret;
1078
+ },
1079
+ __wbg_new_1dbf7428bba60a42: function(arg0) {
1080
+ const ret = new Uint8Array(arg0);
1081
+ return ret;
1082
+ },
1083
+ __wbg_new_28744009d011f847: function() {
1084
+ const ret = new Map();
1085
+ return ret;
1086
+ },
1087
+ __wbg_new_343a093a3c2ffb4e: function(arg0, arg1) {
1088
+ const ret = new Error(getStringFromWasm0(arg0, arg1));
1089
+ return ret;
1090
+ },
1091
+ __wbg_new_617a8cdb8bb1130e: function() {
1092
+ const ret = new Object();
1093
+ return ret;
1094
+ },
1095
+ __wbg_new_ee2291f50781bf1d: function() {
1096
+ const ret = new Array();
1097
+ return ret;
1098
+ },
1099
+ __wbg_next_33784799010f1bbe: function(arg0) {
1100
+ const ret = arg0.next;
1101
+ return ret;
1102
+ },
1103
+ __wbg_next_f4aac29c42af995c: function() { return handleError(function (arg0) {
1104
+ const ret = arg0.next();
1105
+ return ret;
1106
+ }, arguments); },
1107
+ __wbg_prototypesetcall_bc27214492979395: function(arg0, arg1, arg2) {
1108
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
1109
+ },
1110
+ __wbg_set_145a351398b48c65: function() { return handleError(function (arg0, arg1, arg2) {
1111
+ const ret = Reflect.set(arg0, arg1, arg2);
1112
+ return ret;
1113
+ }, arguments); },
1114
+ __wbg_set_6ae97e73113c4f0b: function(arg0, arg1, arg2) {
1115
+ const ret = arg0.set(arg1, arg2);
1116
+ return ret;
1117
+ },
1118
+ __wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
1119
+ arg0[arg1] = arg2;
1120
+ },
1121
+ __wbg_set_bea140a88be9b277: function(arg0, arg1, arg2) {
1122
+ arg0[arg1 >>> 0] = arg2;
1123
+ },
1124
+ __wbg_value_f3c585ee8f5ba40c: function(arg0) {
1125
+ const ret = arg0.value;
1126
+ return ret;
1127
+ },
1128
+ __wbindgen_generic_0000000000000001: function(arg0) {
1129
+ // Cast intrinsic for `F64 -> Externref`.
1130
+ const ret = arg0;
1131
+ return ret;
1132
+ },
1133
+ __wbindgen_generic_0000000000000002: function(arg0) {
1134
+ // Cast intrinsic for `I64 -> Externref`.
1135
+ const ret = arg0;
1136
+ return ret;
1137
+ },
1138
+ __wbindgen_generic_0000000000000003: function(arg0, arg1) {
1139
+ // Cast intrinsic for `Ref(String) -> Externref`.
1140
+ const ret = getStringFromWasm0(arg0, arg1);
1141
+ return ret;
1142
+ },
1143
+ __wbindgen_generic_0000000000000004: function(arg0) {
1144
+ // Cast intrinsic for `U64 -> Externref`.
1145
+ const ret = BigInt.asUintN(64, arg0);
1146
+ return ret;
1147
+ },
1148
+ __wbindgen_init_externref_table: function() {
1149
+ const table = wasm.__wbindgen_externrefs;
1150
+ const offset = table.grow(4);
1151
+ table.set(0, undefined);
1152
+ table.set(offset + 0, undefined);
1153
+ table.set(offset + 1, null);
1154
+ table.set(offset + 2, true);
1155
+ table.set(offset + 3, false);
1156
+ },
1157
+ };
1158
+ return {
1159
+ __proto__: null,
1160
+ "./kicksdk_bg.js": import0,
1161
+ };
1162
+ }
1163
+
1164
+ const BackoffFinalization = (typeof FinalizationRegistry === 'undefined')
1165
+ ? { register: () => {}, unregister: () => {} }
1166
+ : new FinalizationRegistry(ptr => wasm.__wbg_backoff_free(ptr, 1));
1167
+ const SessionFinalization = (typeof FinalizationRegistry === 'undefined')
1168
+ ? { register: () => {}, unregister: () => {} }
1169
+ : new FinalizationRegistry(ptr => wasm.__wbg_session_free(ptr, 1));
1170
+
1171
+ function addToExternrefTable0(obj) {
1172
+ const idx = wasm.__externref_table_alloc();
1173
+ wasm.__wbindgen_externrefs.set(idx, obj);
1174
+ return idx;
1175
+ }
1176
+
1177
+ function debugString(val) {
1178
+ // primitive types
1179
+ const type = typeof val;
1180
+ if (type == 'number' || type == 'boolean' || val == null) {
1181
+ return `${val}`;
1182
+ }
1183
+ if (type == 'string') {
1184
+ return `"${val}"`;
1185
+ }
1186
+ if (type == 'symbol') {
1187
+ const description = val.description;
1188
+ if (description == null) {
1189
+ return 'Symbol';
1190
+ } else {
1191
+ return `Symbol(${description})`;
1192
+ }
1193
+ }
1194
+ if (type == 'function') {
1195
+ const name = val.name;
1196
+ if (typeof name == 'string' && name.length > 0) {
1197
+ return `Function(${name})`;
1198
+ } else {
1199
+ return 'Function';
1200
+ }
1201
+ }
1202
+ // objects
1203
+ if (Array.isArray(val)) {
1204
+ const length = val.length;
1205
+ let debug = '[';
1206
+ if (length > 0) {
1207
+ debug += debugString(val[0]);
1208
+ }
1209
+ for(let i = 1; i < length; i++) {
1210
+ debug += ', ' + debugString(val[i]);
1211
+ }
1212
+ debug += ']';
1213
+ return debug;
1214
+ }
1215
+ // Test for built-in
1216
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
1217
+ let className;
1218
+ if (builtInMatches && builtInMatches.length > 1) {
1219
+ className = builtInMatches[1];
1220
+ } else {
1221
+ // Failed to match the standard '[object ClassName]'
1222
+ return toString.call(val);
1223
+ }
1224
+ if (className == 'Object') {
1225
+ // we're a user defined class or Object
1226
+ // JSON.stringify avoids problems with cycles, and is generally much
1227
+ // easier than looping through ownProperties of `val`.
1228
+ try {
1229
+ return 'Object(' + JSON.stringify(val) + ')';
1230
+ } catch (_) {
1231
+ return 'Object';
1232
+ }
1233
+ }
1234
+ // errors
1235
+ if (val instanceof Error) {
1236
+ return `${val.name}: ${val.message}\n${val.stack}`;
1237
+ }
1238
+ // TODO we could test for more things here, like `Set`s and `Map`s.
1239
+ return className;
1240
+ }
1241
+
1242
+ function getArrayJsValueFromWasm0(ptr, len) {
1243
+ ptr = ptr >>> 0;
1244
+ const mem = getDataViewMemory0();
1245
+ const result = [];
1246
+ for (let i = ptr; i < ptr + 4 * len; i += 4) {
1247
+ result.push(wasm.__wbindgen_externrefs.get(mem.getUint32(i, true)));
1248
+ }
1249
+ wasm.__externref_drop_slice(ptr, len);
1250
+ return result;
1251
+ }
1252
+
1253
+ function getArrayU8FromWasm0(ptr, len) {
1254
+ ptr = ptr >>> 0;
1255
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
1256
+ }
1257
+
1258
+ let cachedDataViewMemory0 = null;
1259
+ function getDataViewMemory0() {
1260
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
1261
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
1262
+ }
1263
+ return cachedDataViewMemory0;
1264
+ }
1265
+
1266
+ let cachedFloat64ArrayMemory0 = null;
1267
+ function getFloat64ArrayMemory0() {
1268
+ if (cachedFloat64ArrayMemory0 === null || cachedFloat64ArrayMemory0.byteLength === 0) {
1269
+ cachedFloat64ArrayMemory0 = new Float64Array(wasm.memory.buffer);
1270
+ }
1271
+ return cachedFloat64ArrayMemory0;
1272
+ }
1273
+
1274
+ function getStringFromWasm0(ptr, len) {
1275
+ return decodeText(ptr >>> 0, len);
1276
+ }
1277
+
1278
+ let cachedUint8ArrayMemory0 = null;
1279
+ function getUint8ArrayMemory0() {
1280
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
1281
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
1282
+ }
1283
+ return cachedUint8ArrayMemory0;
1284
+ }
1285
+
1286
+ function handleError(f, args) {
1287
+ try {
1288
+ return f.apply(this, args);
1289
+ } catch (e) {
1290
+ const idx = addToExternrefTable0(e);
1291
+ wasm.__wbindgen_exn_store(idx);
1292
+ }
1293
+ }
1294
+
1295
+ function isLikeNone(x) {
1296
+ return x === undefined || x === null;
1297
+ }
1298
+
1299
+ function passArrayF64ToWasm0(arg, malloc) {
1300
+ const ptr = malloc(arg.length * 8, 8) >>> 0;
1301
+ getFloat64ArrayMemory0().set(arg, ptr / 8);
1302
+ WASM_VECTOR_LEN = arg.length;
1303
+ return ptr;
1304
+ }
1305
+
1306
+ function passArrayJsValueToWasm0(array, malloc) {
1307
+ const ptr = malloc(array.length * 4, 4) >>> 0;
1308
+ for (let i = 0; i < array.length; i++) {
1309
+ const add = addToExternrefTable0(array[i]);
1310
+ getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
1311
+ }
1312
+ WASM_VECTOR_LEN = array.length;
1313
+ return ptr;
1314
+ }
1315
+
1316
+ function passStringToWasm0(arg, malloc, realloc) {
1317
+ if (realloc === undefined) {
1318
+ const buf = cachedTextEncoder.encode(arg);
1319
+ const ptr = malloc(buf.length, 1) >>> 0;
1320
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
1321
+ WASM_VECTOR_LEN = buf.length;
1322
+ return ptr;
1323
+ }
1324
+
1325
+ let len = arg.length;
1326
+ let ptr = malloc(len, 1) >>> 0;
1327
+
1328
+ const mem = getUint8ArrayMemory0();
1329
+
1330
+ let offset = 0;
1331
+
1332
+ for (; offset < len; offset++) {
1333
+ const code = arg.charCodeAt(offset);
1334
+ if (code > 0x7F) break;
1335
+ mem[ptr + offset] = code;
1336
+ }
1337
+ if (offset !== len) {
1338
+ if (offset !== 0) {
1339
+ arg = arg.slice(offset);
1340
+ }
1341
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
1342
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
1343
+ const ret = cachedTextEncoder.encodeInto(arg, view);
1344
+
1345
+ offset += ret.written;
1346
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
1347
+ }
1348
+
1349
+ WASM_VECTOR_LEN = offset;
1350
+ return ptr;
1351
+ }
1352
+
1353
+ function takeFromExternrefTable0(idx) {
1354
+ const value = wasm.__wbindgen_externrefs.get(idx);
1355
+ wasm.__externref_table_dealloc(idx);
1356
+ return value;
1357
+ }
1358
+
1359
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
1360
+ cachedTextDecoder.decode();
1361
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
1362
+ let numBytesDecoded = 0;
1363
+ function decodeText(ptr, len) {
1364
+ numBytesDecoded += len;
1365
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
1366
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
1367
+ cachedTextDecoder.decode();
1368
+ numBytesDecoded = len;
1369
+ }
1370
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
1371
+ }
1372
+
1373
+ const cachedTextEncoder = new TextEncoder();
1374
+
1375
+ if (!('encodeInto' in cachedTextEncoder)) {
1376
+ cachedTextEncoder.encodeInto = function (arg, view) {
1377
+ const buf = cachedTextEncoder.encode(arg);
1378
+ view.set(buf);
1379
+ return {
1380
+ read: arg.length,
1381
+ written: buf.length
1382
+ };
1383
+ };
1384
+ }
1385
+
1386
+ let WASM_VECTOR_LEN = 0;
1387
+
1388
+ let wasmModule, wasmInstance, wasm;
1389
+ function __wbg_finalize_init(instance, module) {
1390
+ wasmInstance = instance;
1391
+ wasm = instance.exports;
1392
+ wasmModule = module;
1393
+ cachedDataViewMemory0 = null;
1394
+ cachedFloat64ArrayMemory0 = null;
1395
+ cachedUint8ArrayMemory0 = null;
1396
+ wasm.__wbindgen_start();
1397
+ return wasm;
1398
+ }
1399
+
1400
+ async function __wbg_load(module, imports) {
1401
+ if (typeof Response === 'function' && module instanceof Response) {
1402
+ if (!module.ok) {
1403
+ throw new Error(`failed to fetch Wasm: ${module.status} ${module.statusText} fetching '${module.url}'`);
1404
+ }
1405
+
1406
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
1407
+ try {
1408
+ return await WebAssembly.instantiateStreaming(module, imports);
1409
+ } catch (e) {
1410
+ const validResponse = expectedResponseType(module.type);
1411
+
1412
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
1413
+ console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
1414
+
1415
+ } else { throw e; }
1416
+ }
1417
+ }
1418
+
1419
+ const bytes = await module.arrayBuffer();
1420
+ return await WebAssembly.instantiate(bytes, imports);
1421
+ } else {
1422
+ const instance = await WebAssembly.instantiate(module, imports);
1423
+
1424
+ if (instance instanceof WebAssembly.Instance) {
1425
+ return { instance, module };
1426
+ } else {
1427
+ return instance;
1428
+ }
1429
+ }
1430
+
1431
+ function expectedResponseType(type) {
1432
+ switch (type) {
1433
+ case 'basic': case 'cors': case 'default': return true;
1434
+ }
1435
+ return false;
1436
+ }
1437
+ }
1438
+
1439
+ function initSync(module) {
1440
+ if (wasm !== undefined) return wasm;
1441
+
1442
+
1443
+ if (module !== undefined) {
1444
+ if (Object.getPrototypeOf(module) === Object.prototype) {
1445
+ ({module} = module)
1446
+ } else {
1447
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
1448
+ }
1449
+ }
1450
+
1451
+ const imports = __wbg_get_imports();
1452
+ if (!(module instanceof WebAssembly.Module)) {
1453
+ module = new WebAssembly.Module(module);
1454
+ }
1455
+ const instance = new WebAssembly.Instance(module, imports);
1456
+ return __wbg_finalize_init(instance, module);
1457
+ }
1458
+
1459
+ async function __wbg_init(module_or_path) {
1460
+ if (wasm !== undefined) return wasm;
1461
+
1462
+
1463
+ if (module_or_path !== undefined) {
1464
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
1465
+ ({module_or_path} = module_or_path)
1466
+ } else {
1467
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
1468
+ }
1469
+ }
1470
+
1471
+ if (module_or_path === undefined) {
1472
+ module_or_path = new URL('kicksdk_bg.wasm', import.meta.url);
1473
+ }
1474
+ const imports = __wbg_get_imports();
1475
+
1476
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
1477
+ module_or_path = fetch(module_or_path);
1478
+ }
1479
+
1480
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
1481
+
1482
+ return __wbg_finalize_init(instance, module);
1483
+ }
1484
+
1485
+ export { initSync, __wbg_init as default };