@vbotma/bridge 2.3.0 → 2.3.3

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/dist/index.js CHANGED
@@ -1,16 +1,16 @@
1
- import { is as O, looseObject as w, function as ne, nullish as P, boolean as J, number as G, string as x, optional as H, unknown as he, parse as B, any as ye } from "valibot";
2
- import { throwifyFpFn as A, getStorageValue as ve, setStorageValue as R, createLogger as Ee, throwifyAnyEither as V, createCbCollector as oe, BetterTaskEither as ae } from "@vbotma/toolkit";
3
- import { createLogger as St, deepSnakeToCamelObjKeys as kt } from "@vbotma/toolkit";
1
+ import { is as O, looseObject as d, function as ne, nullish as P, boolean as G, number as T, string as x, optional as H, unknown as ge, parse as V, any as ye } from "valibot";
2
+ import { throwifyFpFn as C, getStorageValue as ve, setStorageValue as R, createLogger as Ee, throwifyAnyEither as A, createCbCollector as oe, BetterTaskEither as ae } from "@vbotma/toolkit";
3
+ import { createLogger as Bt, deepSnakeToCamelObjKeys as St } from "@vbotma/toolkit";
4
4
  import { BetterPromise as se, TimeoutError as Pe } from "better-promises";
5
- import { CancelledError as Bt, TimeoutError as Ct } from "better-promises";
6
- import { function as l, either as c, option as F, taskEither as d, json as xe } from "fp-ts";
7
- import { errorClassWithData as Se, errorClass as S } from "error-kid";
8
- import { parseLaunchParamsQueryFp as ie, themeParams as ke, pipeJsonToSchema as T, miniAppsMessage as U, serializeLaunchParamsQuery as pe, parseLaunchParamsQuery as ce } from "@vbotma/transformers";
5
+ import { CancelledError as Vt, TimeoutError as Wt } from "better-promises";
6
+ import { function as w, either as c, option as F, taskEither as l, json as xe } from "fp-ts";
7
+ import { errorClassWithData as Be, errorClass as B } from "error-kid";
8
+ import { parseLaunchParamsQueryFp as ie, themeParams as Se, pipeJsonToSchema as U, miniAppsMessage as I, serializeLaunchParamsQuery as pe, parseLaunchParamsQuery as ce } from "@vbotma/transformers";
9
9
  import { signal as y, computed as _e } from "@vbotma/signals";
10
- import We from "mitt";
10
+ import ke from "mitt";
11
11
  function ue(e) {
12
12
  return O(
13
- w({ VBotWebviewProxy: w({ postEvent: ne() }) }),
13
+ d({ VBotWebviewProxy: d({ postEvent: ne() }) }),
14
14
  e
15
15
  );
16
16
  }
@@ -21,18 +21,18 @@ function j() {
21
21
  return !0;
22
22
  }
23
23
  }
24
- class Be extends (/* @__PURE__ */ S(
24
+ class Ve extends (/* @__PURE__ */ B(
25
25
  "MethodUnsupportedError",
26
26
  (t, r) => [
27
27
  `Method "${t}" is unsupported in Mini Apps version ${r}`
28
28
  ]
29
29
  )) {
30
30
  }
31
- class Ce extends (/* @__PURE__ */ S("MethodParameterUnsupportedError", (t, r, n) => [
31
+ class We extends (/* @__PURE__ */ B("MethodParameterUnsupportedError", (t, r, n) => [
32
32
  `Parameter "${r}" of "${t}" method is unsupported in Mini Apps version ${n}`
33
33
  ])) {
34
34
  }
35
- class Ae extends (/* @__PURE__ */ Se(
35
+ class Ce extends (/* @__PURE__ */ Be(
36
36
  "LaunchParamsRetrieveError",
37
37
  (t) => ({ errors: t }),
38
38
  (t) => [
@@ -46,7 +46,7 @@ class Ae extends (/* @__PURE__ */ Se(
46
46
  ]
47
47
  )) {
48
48
  }
49
- class fe extends (/* @__PURE__ */ S(
49
+ class fe extends (/* @__PURE__ */ B(
50
50
  "InvalidLaunchParamsError",
51
51
  (t, r) => [
52
52
  `Invalid value for launch params: ${t}`,
@@ -54,9 +54,9 @@ class fe extends (/* @__PURE__ */ S(
54
54
  ]
55
55
  )) {
56
56
  }
57
- class le extends (/* @__PURE__ */ S("UnknownEnvError")) {
57
+ class we extends (/* @__PURE__ */ B("UnknownEnvError")) {
58
58
  }
59
- class Ve extends (/* @__PURE__ */ S(
59
+ class Ae extends (/* @__PURE__ */ B(
60
60
  "InvokeCustomMethodError",
61
61
  (t) => [`Server returned error: ${t}`]
62
62
  )) {
@@ -66,14 +66,14 @@ function Q(e) {
66
66
  return e.replace(/^[^?#]*[?#]/, "").replace(/[?#]/g, "&");
67
67
  }
68
68
  function Le() {
69
- return l.pipe(
69
+ return w.pipe(
70
70
  L(),
71
71
  c.chainW(ie)
72
72
  );
73
73
  }
74
- const rt = A(Le);
74
+ const rt = C(Le);
75
75
  function Me() {
76
- return l.pipe(
76
+ return w.pipe(
77
77
  L(),
78
78
  c.map((e) => {
79
79
  const t = new URLSearchParams(e).get("vbWebAppData");
@@ -82,7 +82,7 @@ function Me() {
82
82
  );
83
83
  }
84
84
  function nt() {
85
- return l.pipe(
85
+ return w.pipe(
86
86
  Me(),
87
87
  c.fold((e) => {
88
88
  throw e;
@@ -111,7 +111,7 @@ function L() {
111
111
  e.push({ source: r, error: new Error("Source is empty") });
112
112
  continue;
113
113
  }
114
- const a = l.pipe(
114
+ const a = w.pipe(
115
115
  ie(n),
116
116
  c.foldW((o) => o, () => !0)
117
117
  );
@@ -121,11 +121,11 @@ function L() {
121
121
  }
122
122
  return R(N, n), c.right(n);
123
123
  }
124
- return c.left(new Ae(e));
124
+ return c.left(new Ce(e));
125
125
  }
126
- const ot = A(L);
127
- function I(e, t) {
128
- const r = /* @__PURE__ */ new Map(), n = We(), a = (o, s, i = !1) => {
126
+ const ot = C(L);
127
+ function $(e, t) {
128
+ const r = /* @__PURE__ */ new Map(), n = ke(), a = (o, s, i = !1) => {
129
129
  const _ = r.get(o) || /* @__PURE__ */ new Map();
130
130
  r.set(o, _);
131
131
  const p = _.get(s) || [];
@@ -141,8 +141,8 @@ function I(e, t) {
141
141
  !r.size && e();
142
142
  const _ = () => {
143
143
  a(o, s, i);
144
- }, p = (...m) => {
145
- i && _(), o === "*" ? s({ name: m[0], payload: m[1] }) : s(...m);
144
+ }, p = (...b) => {
145
+ i && _(), o === "*" ? s({ name: b[0], payload: b[1] }) : s(...b);
146
146
  };
147
147
  n.on(o, p);
148
148
  const u = r.get(o) || /* @__PURE__ */ new Map();
@@ -159,7 +159,7 @@ function I(e, t) {
159
159
  }
160
160
  };
161
161
  }
162
- function W(e, t) {
162
+ function k(e, t) {
163
163
  window.dispatchEvent(new MessageEvent("message", {
164
164
  data: JSON.stringify({ eventType: e, eventData: t }),
165
165
  // We specify this kind of source here in order to allow the package's "on" function to
@@ -168,25 +168,25 @@ function W(e, t) {
168
168
  source: window.parent
169
169
  }));
170
170
  }
171
- const C = y(!1), $ = y("https://web.telegram.org"), qe = (e) => {
172
- h().log("Event received:", e);
173
- }, we = _e(C);
171
+ const W = y(!1), z = y("https://web.vbot.org"), qe = (e) => {
172
+ g().log("Event received:", e);
173
+ }, de = _e(W);
174
174
  function at(e) {
175
- e !== C() && (C.set(e), (e ? z : Oe)("*", qe));
175
+ e !== W() && (W.set(e), (e ? D : Oe)("*", qe));
176
176
  }
177
- const de = _e($);
177
+ const le = _e(z);
178
178
  function st(e) {
179
- $.set(e), h().log("New target origin set", e);
179
+ z.set(e), g().log("New target origin set", e);
180
180
  }
181
- const b = y((...e) => {
181
+ const m = y((...e) => {
182
182
  window.parent.postMessage(...e);
183
- }), h = y(Ee("Bridge", {
183
+ }), g = y(Ee("Bridge", {
184
184
  bgColor: "#9147ff",
185
185
  textColor: "white",
186
- shouldLog: we
186
+ shouldLog: de
187
187
  }));
188
188
  function it() {
189
- Te(), [b, $, de, C, we, h].forEach((e) => {
189
+ Ue(), [m, z, le, W, de, g].forEach((e) => {
190
190
  e.unsubAll(), "reset" in e && e.reset();
191
191
  });
192
192
  }
@@ -212,7 +212,7 @@ function q(e, t, r) {
212
212
  n.unshift(1), Y(e, t, o);
213
213
  }
214
214
  });
215
- me(
215
+ be(
216
216
  e,
217
217
  t,
218
218
  () => s,
@@ -221,13 +221,13 @@ function q(e, t, r) {
221
221
  }
222
222
  function K(e, t) {
223
223
  const r = e[t];
224
- me(e, t, () => r, (n) => {
224
+ be(e, t, () => r, (n) => {
225
225
  Object.entries(n).forEach(([a, o]) => {
226
226
  r[a] = o;
227
227
  });
228
228
  });
229
229
  }
230
- function me(e, t, r, n) {
230
+ function be(e, t, r, n) {
231
231
  Object.defineProperty(e, t, {
232
232
  enumerable: !0,
233
233
  configurable: !0,
@@ -244,26 +244,26 @@ function Y(e, t, r) {
244
244
  });
245
245
  }
246
246
  const Fe = {
247
- clipboard_text_received: w({
247
+ clipboard_text_received: d({
248
248
  req_id: x(),
249
249
  data: P(x())
250
250
  }),
251
- custom_method_invoked: w({
251
+ custom_method_invoked: d({
252
252
  req_id: x(),
253
- result: H(he()),
253
+ result: H(ge()),
254
254
  error: H(x())
255
255
  }),
256
256
  popup_closed: P(
257
- w({ button_id: P(x(), () => {
257
+ d({ button_id: P(x(), () => {
258
258
  }) }),
259
259
  {}
260
260
  ),
261
261
  viewport_changed: P(
262
- w({
263
- height: G(),
264
- width: P(G(), () => window.innerWidth),
265
- is_state_stable: J(),
266
- is_expanded: J()
262
+ d({
263
+ height: T(),
264
+ width: P(T(), () => window.innerWidth),
265
+ is_state_stable: G(),
266
+ is_expanded: G()
267
267
  }),
268
268
  // TODO: At the moment, macOS has a bug with the invalid event payload - it is always equal to
269
269
  // null. Leaving this default value until the bug is fixed.
@@ -273,8 +273,8 @@ const Fe = {
273
273
  is_expanded: !0
274
274
  })
275
275
  ),
276
- theme_changed: w({
277
- theme_params: ke()
276
+ theme_changed: d({
277
+ theme_params: Se()
278
278
  })
279
279
  };
280
280
  function X(e) {
@@ -282,20 +282,19 @@ function X(e) {
282
282
  return;
283
283
  let t;
284
284
  try {
285
- t = B(T(U()), e.data);
285
+ t = V(U(I()), e.data);
286
286
  } catch {
287
287
  return;
288
288
  }
289
289
  const { eventType: r, eventData: n } = t, a = Fe[r];
290
290
  let o;
291
291
  try {
292
- o = a ? B(a, n) : n;
292
+ o = a ? V(a, n) : n;
293
293
  } catch (s) {
294
- return h().forceError(
294
+ return g().forceError(
295
295
  [
296
296
  `An error occurred processing the "${r}" event from the VBot application.`,
297
- "Please, file an issue here:",
298
- "https://github.com/Telegram-Mini-Apps/tma.js/issues/new/choose"
297
+ "Please, file an issue here:"
299
298
  ].join(`
300
299
  `),
301
300
  t,
@@ -305,19 +304,19 @@ function X(e) {
305
304
  Re(r, o);
306
305
  }
307
306
  const {
308
- on: z,
307
+ on: D,
309
308
  off: Oe,
310
309
  emit: Re,
311
- clear: Te
312
- } = I(
310
+ clear: Ue
311
+ } = $(
313
312
  () => {
314
313
  const e = window;
315
- !e.TelegramGameProxy && (e.TelegramGameProxy = {}), q(e.TelegramGameProxy, "receiveEvent", W), K(e, "TelegramGameProxy"), !e.VBot && (e.VBot = {}), !e.VBot.WebView && (e.VBot.WebView = {}), q(e.VBot.WebView, "receiveEvent", W), K(e.VBot, "WebView"), q(e, "TelegramGameProxy_receiveEvent", W), window.addEventListener("message", X);
314
+ !e.VBotGameProxy && (e.VBotGameProxy = {}), q(e.VBotGameProxy, "receiveEvent", k), K(e, "VBotGameProxy"), !e.VBot && (e.VBot = {}), !e.VBot.WebView && (e.VBot.WebView = {}), q(e.VBot.WebView, "receiveEvent", k), K(e.VBot, "WebView"), q(e, "VBotGameProxy_receiveEvent", k), window.addEventListener("message", X);
316
315
  },
317
316
  () => {
318
317
  [
319
- ["TelegramGameProxy_receiveEvent"],
320
- ["TelegramGameProxy", "receiveEvent"],
318
+ ["VBotGameProxy_receiveEvent"],
319
+ ["VBotGameProxy", "receiveEvent"],
321
320
  ["VBot", "WebView", "receiveEvent"]
322
321
  ].forEach((e) => {
323
322
  const t = window;
@@ -329,10 +328,10 @@ const {
329
328
  "unwrap" in a && (a.unwrap(), n && n !== t && !Object.keys(n).length && delete t[e[0]]);
330
329
  }), window.removeEventListener("message", X);
331
330
  }
332
- ), Ue = (...e) => b()(...e);
331
+ ), Ie = (...e) => m()(...e);
333
332
  function je(e, t) {
334
- l.pipe(
335
- k(
333
+ w.pipe(
334
+ S(
336
335
  // @ts-expect-error It's ok, TS can't determine a specific override.
337
336
  e,
338
337
  t
@@ -342,20 +341,20 @@ function je(e, t) {
342
341
  })
343
342
  );
344
343
  }
345
- function k(e, t) {
346
- h().log("Posting event:", t ? { eventType: e, eventData: t } : { eventType: e });
344
+ function S(e, t) {
345
+ g().log("Posting event:", t ? { eventType: e, eventData: t } : { eventType: e });
347
346
  const r = window, n = JSON.stringify({ eventType: e, eventData: t });
348
- return j() ? (Ue(n, de()), c.right(void 0)) : ue(r) ? (r.VBotWebviewProxy.postEvent(e, JSON.stringify(t)), c.right(void 0)) : O(w({ external: w({ notify: ne() }) }), r) ? (r.external.notify(n), c.right(void 0)) : c.left(new le());
347
+ return j() ? (Ie(n, le()), c.right(void 0)) : ue(r) ? (r.VBotWebviewProxy.postEvent(e, JSON.stringify(t)), c.right(void 0)) : O(d({ external: d({ notify: ne() }) }), r) ? (r.external.notify(n), c.right(void 0)) : c.left(new we());
349
348
  }
350
- function D(e, t, r = {}) {
349
+ function J(e, t, r = {}) {
351
350
  const {
352
351
  // If no capture function was passed, we capture the first compatible event.
353
352
  capture: n = () => !0,
354
- postEvent: a = k
353
+ postEvent: a = S
355
354
  } = r, o = y(), [s, i] = oe();
356
355
  (Array.isArray(t) ? t : [t]).forEach((p) => {
357
356
  s(
358
- z(p, (u) => {
357
+ D(p, (u) => {
359
358
  const f = Array.isArray(t);
360
359
  n(f ? { event: p, payload: u } : u) && o.set([
361
360
  f ? { event: p, payload: u } : u
@@ -364,12 +363,12 @@ function D(e, t, r = {}) {
364
363
  );
365
364
  });
366
365
  const _ = (p) => (i(), p);
367
- return l.pipe(
366
+ return w.pipe(
368
367
  async () => a(e, r.params),
369
- d.chainW(() => ae((p, u, f) => {
370
- const m = o();
371
- if (m)
372
- return p(m[0]);
368
+ l.chainW(() => ae((p, u, f) => {
369
+ const b = o();
370
+ if (b)
371
+ return p(b[0]);
373
372
  const v = (E) => {
374
373
  E && p(E[0]);
375
374
  }, M = () => {
@@ -377,14 +376,14 @@ function D(e, t, r = {}) {
377
376
  };
378
377
  o.sub(v), f.on("finalized", M);
379
378
  }, r)),
380
- d.mapBoth(_, _)
379
+ l.mapBoth(_, _)
381
380
  );
382
381
  }
383
382
  function pt(e, t, r) {
384
383
  const { postEvent: n } = r || {};
385
- return V(
384
+ return A(
386
385
  // @ts-expect-error TypeScript will not be able to handle our overrides here.
387
- D(e, t, {
386
+ J(e, t, {
388
387
  ...r,
389
388
  postEvent: n ? (...a) => {
390
389
  try {
@@ -392,29 +391,29 @@ function pt(e, t, r) {
392
391
  } catch (o) {
393
392
  return c.left(o);
394
393
  }
395
- } : k
394
+ } : S
396
395
  })
397
396
  );
398
397
  }
399
398
  function ct(e, t) {
400
- const r = Ie(
399
+ const r = $e(
401
400
  // @ts-expect-error TS doesn't get what override we are going to use.
402
401
  e,
403
402
  t
404
403
  );
405
- return typeof r == "function" ? se.fn(() => V(r)) : r;
404
+ return typeof r == "function" ? se.fn(() => A(r)) : r;
406
405
  }
407
- function Ie(e, t) {
406
+ function $e(e, t) {
408
407
  const r = ue(window);
409
408
  if (!e)
410
- return r || l.pipe(L(), c.match(() => !1, () => !0));
409
+ return r || w.pipe(L(), c.match(() => !1, () => !0));
411
410
  if (r)
412
- return d.right(!0);
411
+ return l.right(!0);
413
412
  const { timeout: n = 100 } = t || {};
414
- return l.pipe(
415
- D("web_app_request_theme", "theme_changed", { ...t, timeout: n }),
416
- d.match(
417
- (a) => Pe.is(a) || le.is(a) ? c.right(!1) : c.left(a),
413
+ return w.pipe(
414
+ J("web_app_request_theme", "theme_changed", { ...t, timeout: n }),
415
+ l.match(
416
+ (a) => Pe.is(a) || we.is(a) ? c.right(!1) : c.left(a),
418
417
  () => c.right(!0)
419
418
  )
420
419
  );
@@ -437,14 +436,14 @@ function _t({ launchParams: e, onEvent: t, resetPostMessage: r } = {}) {
437
436
  if (j()) {
438
437
  if (!t)
439
438
  return;
440
- r && b.reset();
441
- const o = b();
442
- b.set((...s) => {
439
+ r && m.reset();
440
+ const o = m();
441
+ m.set((...s) => {
443
442
  const [i] = s, _ = () => {
444
443
  o(...s);
445
444
  };
446
445
  try {
447
- const p = B(T(U()), i);
446
+ const p = V(U(I()), i);
448
447
  t({ name: p.eventType, params: p.eventData }, _);
449
448
  } catch {
450
449
  _();
@@ -465,7 +464,7 @@ function _t({ launchParams: e, onEvent: t, resetPostMessage: r } = {}) {
465
464
  params: s ? JSON.parse(s) : void 0
466
465
  }, i) : i();
467
466
  }
468
- }, h().log("Environment was mocked by the mockVBotEnv function");
467
+ }, g().log("Environment was mocked by the mockVBotEnv function");
469
468
  }
470
469
  function ut({ launchParams: e, onEvent: t, resetPostMessage: r } = {}) {
471
470
  if (e) {
@@ -485,14 +484,14 @@ function ut({ launchParams: e, onEvent: t, resetPostMessage: r } = {}) {
485
484
  if (j()) {
486
485
  if (!t)
487
486
  return;
488
- r && b.reset();
489
- const o = b();
490
- b.set((...s) => {
487
+ r && m.reset();
488
+ const o = m();
489
+ m.set((...s) => {
491
490
  const [i] = s, _ = () => {
492
491
  o(...s);
493
492
  };
494
493
  try {
495
- const p = B(T(U()), i);
494
+ const p = V(U(I()), i);
496
495
  t({ name: p.eventType, params: p.eventData }, _);
497
496
  } catch {
498
497
  _();
@@ -513,7 +512,7 @@ function ut({ launchParams: e, onEvent: t, resetPostMessage: r } = {}) {
513
512
  params: s ? JSON.parse(s) : void 0
514
513
  }, i) : i();
515
514
  }
516
- }, h().log("Launch params are injected by the setLaunchParams function");
515
+ }, g().log("Launch params are injected by the setLaunchParams function");
517
516
  }
518
517
  function ft(e, t = "*") {
519
518
  const r = (o) => {
@@ -523,7 +522,7 @@ function ft(e, t = "*") {
523
522
  n.emit(i, _);
524
523
  } catch {
525
524
  }
526
- }, n = I(
525
+ }, n = $(
527
526
  () => {
528
527
  window.addEventListener("message", r);
529
528
  },
@@ -541,13 +540,13 @@ function ft(e, t = "*") {
541
540
  },
542
541
  // We need to override clear to also remove the window listener
543
542
  clear: () => {
544
- n.clear(), g === a && (g = void 0);
543
+ n.clear(), h === a && (h = void 0);
545
544
  }
546
545
  };
547
- return g = a, a;
546
+ return h = a, a;
548
547
  }
549
- function lt() {
550
- const e = I(
548
+ function wt() {
549
+ const e = $(
551
550
  () => {
552
551
  },
553
552
  () => {
@@ -555,11 +554,11 @@ function lt() {
555
554
  ), t = {
556
555
  ...e,
557
556
  send: (r, n) => {
558
- W(r, n);
557
+ k(r, n);
559
558
  },
560
559
  clear: () => {
561
560
  var r;
562
- e.clear(), g === t && (g = void 0), (r = window.VBotWebviewProxy) != null && r.__isWebComponentProxy && delete window.VBotWebviewProxy;
561
+ e.clear(), h === t && (h = void 0), (r = window.VBotWebviewProxy) != null && r.__isWebComponentProxy && delete window.VBotWebviewProxy;
563
562
  }
564
563
  };
565
564
  return window.VBotWebviewProxy = {
@@ -573,15 +572,15 @@ function lt() {
573
572
  }
574
573
  e.emit(r, a);
575
574
  }
576
- }, g = t, t;
575
+ }, h = t, t;
577
576
  }
578
- let g;
579
- function wt() {
580
- if (!g)
577
+ let h;
578
+ function dt() {
579
+ if (!h)
581
580
  throw new Error("HostBridge not initialized. Call defineHostBridge() or defineWebComponentBridge() first.");
582
- return g;
581
+ return h;
583
582
  }
584
- function $e(e) {
583
+ function ze(e) {
585
584
  return ({ req_id: t }) => t === e;
586
585
  }
587
586
  const Z = {
@@ -599,7 +598,7 @@ const Z = {
599
598
  "web_app_setup_closing_behavior"
600
599
  ],
601
600
  6.1: [
602
- "web_app_open_tg_link",
601
+ "web_app_open_vb_link",
603
602
  "web_app_open_invoice",
604
603
  "web_app_setup_back_button",
605
604
  "web_app_set_background_color",
@@ -682,7 +681,7 @@ function ee(e, t) {
682
681
  function te(e) {
683
682
  return e.split(".").map(Number);
684
683
  }
685
- function ze(e, t) {
684
+ function De(e, t) {
686
685
  const r = te(e), n = te(t), a = Math.max(r.length, n.length);
687
686
  for (let o = 0; o < a; o += 1) {
688
687
  const s = r[o] || 0, i = n[o] || 0;
@@ -696,32 +695,32 @@ function re(e, t, r) {
696
695
  e,
697
696
  t
698
697
  ) : ee(e);
699
- return n ? ze(n, r || t) <= 0 : !1;
698
+ return n ? De(n, r || t) <= 0 : !1;
700
699
  }
701
- function dt(e, t = "strict") {
700
+ function lt(e, t = "strict") {
702
701
  const r = typeof t == "function" ? t : (n) => {
703
- const { method: a, version: o } = n, s = "param" in n ? new Ce(a, n.param, o) : new Be(a, o);
702
+ const { method: a, version: o } = n, s = "param" in n ? new We(a, n.param, o) : new Ve(a, o);
704
703
  if (t === "strict")
705
704
  throw s;
706
- return h().forceWarn(s.message);
705
+ return g().forceWarn(s.message);
707
706
  };
708
- return ((n, a) => re(n, e) ? n === "web_app_set_header_color" && O(w({ color: ye() }), a) && !re(n, "color", e) ? r({ version: e, method: n, param: "color" }) : je(n, a) : r({ version: e, method: n }));
707
+ return ((n, a) => re(n, e) ? n === "web_app_set_header_color" && O(d({ color: ye() }), a) && !re(n, "color", e) ? r({ version: e, method: n, param: "color" }) : je(n, a) : r({ version: e, method: n }));
709
708
  }
710
- function De(e, t, r, n) {
711
- return l.pipe(
712
- D("web_app_invoke_custom_method", "custom_method_invoked", {
709
+ function Je(e, t, r, n) {
710
+ return w.pipe(
711
+ J("web_app_invoke_custom_method", "custom_method_invoked", {
713
712
  ...n || {},
714
713
  params: { method: e, params: t, req_id: r },
715
- capture: $e(r)
714
+ capture: ze(r)
716
715
  }),
717
- d.chain(({ result: a, error: o }) => o ? d.left(new Ve(o)) : d.right(a))
716
+ l.chain(({ result: a, error: o }) => o ? l.left(new Ae(o)) : l.right(a))
718
717
  );
719
718
  }
720
- function mt(e, t, r, n) {
721
- return se.fn(() => l.pipe(
719
+ function bt(e, t, r, n) {
720
+ return se.fn(() => w.pipe(
722
721
  // @ts-expect-error TypeScript is unable to determine required override.
723
- De(e, t, r, n),
724
- d.match(
722
+ Je(e, t, r, n),
723
+ l.match(
725
724
  (a) => {
726
725
  throw a;
727
726
  },
@@ -729,26 +728,26 @@ function mt(e, t, r, n) {
729
728
  )
730
729
  )());
731
730
  }
732
- function Je(e, t, r = {}) {
731
+ function Ge(e, t, r = {}) {
733
732
  const {
734
733
  // If no capture function was passed, we capture the first compatible event.
735
734
  capture: n = () => !0,
736
- postEvent: a = k
735
+ postEvent: a = S
737
736
  } = r, o = y(), [s, i] = oe();
738
737
  (Array.isArray(t) ? t : [t]).forEach((p) => {
739
738
  s(
740
- z(p, (u) => {
739
+ D(p, (u) => {
741
740
  (Array.isArray(t) ? n({ event: p, payload: u }) : n(u)) && o.set([u]);
742
741
  })
743
742
  );
744
743
  });
745
744
  const _ = (p) => (i(), p);
746
- return l.pipe(
745
+ return w.pipe(
747
746
  async () => a(e, r.params),
748
- d.chainW(() => ae((p, u, f) => {
749
- const m = o();
750
- if (m)
751
- return p(m[0]);
747
+ l.chainW(() => ae((p, u, f) => {
748
+ const b = o();
749
+ if (b)
750
+ return p(b[0]);
752
751
  const v = (E) => {
753
752
  E && p(E[0]);
754
753
  }, M = () => {
@@ -756,14 +755,14 @@ function Je(e, t, r = {}) {
756
755
  };
757
756
  o.sub(v), f.on("finalized", M);
758
757
  }, r)),
759
- d.mapBoth(_, _)
758
+ l.mapBoth(_, _)
760
759
  );
761
760
  }
762
- function bt(e, t, r) {
761
+ function mt(e, t, r) {
763
762
  const { postEvent: n } = r || {};
764
- return V(
763
+ return A(
765
764
  // @ts-expect-error TypeScript will not be able to handle our overrides here.
766
- Je(e, t, {
765
+ Ge(e, t, {
767
766
  ...r,
768
767
  postEvent: n ? (...a) => {
769
768
  try {
@@ -771,35 +770,35 @@ function bt(e, t, r) {
771
770
  } catch (o) {
772
771
  return c.left(o);
773
772
  }
774
- } : k
773
+ } : S
775
774
  })
776
775
  );
777
776
  }
778
- function gt() {
777
+ function ht() {
779
778
  Object.hasOwn || (Object.hasOwn = function(e, t) {
780
779
  return Object.prototype.hasOwnProperty.call(e, t);
781
780
  });
782
781
  }
783
- function be(e) {
782
+ function me(e) {
784
783
  return c.tryCatch(() => decodeURIComponent(
785
784
  atob(
786
785
  e.replace(/-/g, "+").replace(/_/g, "/")
787
786
  ).split("").map((t) => "%" + ("00" + t.charCodeAt(0).toString(16)).slice(-2)).join("")
788
787
  ), (t) => t);
789
788
  }
790
- const ht = A(be);
791
- function ge(e) {
789
+ const gt = C(me);
790
+ function he(e) {
792
791
  return btoa(
793
792
  encodeURIComponent(e).replace(/%([0-9A-F]{2})/g, (t, r) => String.fromCharCode(parseInt(`0x${r}`)))
794
793
  ).replace(/\+/g, "-").replace(/\//g, "_");
795
794
  }
796
- function Ge(e) {
797
- const t = ge(typeof e == "string" ? e : JSON.stringify(e));
795
+ function Te(e) {
796
+ const t = he(typeof e == "string" ? e : JSON.stringify(e));
798
797
  return t.length > 512 ? c.left(new Error("Value is too long for start parameter")) : c.right(t);
799
798
  }
800
- const yt = A(Ge);
799
+ const yt = C(Te);
801
800
  function vt(e, t) {
802
- return V(
801
+ return A(
803
802
  He(
804
803
  e,
805
804
  // @ts-expect-error TypeScript is unable to detect a correct override.
@@ -808,62 +807,62 @@ function vt(e, t) {
808
807
  );
809
808
  }
810
809
  function He(e, t) {
811
- return l.pipe(
812
- be(e),
810
+ return w.pipe(
811
+ me(e),
813
812
  c.chain((r) => t ? typeof t == "function" ? t(r) : xe.parse(r) : c.right(r))
814
813
  );
815
814
  }
816
815
  function Et(e) {
817
- return ge(e).length <= 512;
816
+ return he(e).length <= 512;
818
817
  }
819
818
  export {
820
- Bt as CancelledError,
819
+ Vt as CancelledError,
821
820
  fe as InvalidLaunchParamsError,
822
- Ve as InvokeCustomMethodFailedError,
823
- Ae as LaunchParamsRetrieveError,
824
- Ce as MethodParameterUnsupportedError,
825
- Be as MethodUnsupportedError,
826
- Ct as TimeoutError,
827
- le as UnknownEnvError,
828
- gt as applyPolyfills,
829
- $e as captureSameReq,
830
- ze as compareVersions,
831
- St as createLogger,
832
- dt as createPostEvent,
821
+ Ae as InvokeCustomMethodFailedError,
822
+ Ce as LaunchParamsRetrieveError,
823
+ We as MethodParameterUnsupportedError,
824
+ Ve as MethodUnsupportedError,
825
+ Wt as TimeoutError,
826
+ we as UnknownEnvError,
827
+ ht as applyPolyfills,
828
+ ze as captureSameReq,
829
+ De as compareVersions,
830
+ Bt as createLogger,
831
+ lt as createPostEvent,
833
832
  yt as createStartParam,
834
- Ge as createStartParamFp,
835
- we as debug,
836
- ht as decodeBase64Url,
837
- be as decodeBase64UrlFp,
833
+ Te as createStartParamFp,
834
+ de as debug,
835
+ gt as decodeBase64Url,
836
+ me as decodeBase64UrlFp,
838
837
  vt as decodeStartParam,
839
838
  He as decodeStartParamFp,
840
- kt as deepSnakeToCamelObjKeys,
839
+ St as deepSnakeToCamelObjKeys,
841
840
  ft as defineHostBridge,
842
- lt as defineWebComponentBridge,
843
- W as emitEvent,
844
- ge as encodeBase64Url,
845
- wt as getHostBridge,
841
+ wt as defineWebComponentBridge,
842
+ k as emitEvent,
843
+ he as encodeBase64Url,
844
+ dt as getHostBridge,
846
845
  ee as getReleaseVersion,
847
846
  ue as hasWebviewProxy,
848
- mt as invokeCustomMethod,
849
- De as invokeCustomMethodFp,
847
+ bt as invokeCustomMethod,
848
+ Je as invokeCustomMethodFp,
850
849
  j as isIframe,
851
850
  Et as isSafeToCreateStartParam,
852
851
  ct as isVBma,
853
- Ie as isVBmaFp,
854
- h as logger,
852
+ $e as isVBmaFp,
853
+ g as logger,
855
854
  _t as mockVBotEnv,
856
855
  Oe as off,
857
- Te as offAll,
858
- z as on,
856
+ Ue as offAll,
857
+ D as on,
859
858
  je as postEvent,
860
- k as postEventFp,
861
- Ue as postMessage,
862
- b as postMessageImpl,
863
- bt as request,
859
+ S as postEventFp,
860
+ Ie as postMessage,
861
+ m as postMessageImpl,
862
+ mt as request,
864
863
  pt as request2,
865
- D as request2Fp,
866
- Je as requestFp,
864
+ J as request2Fp,
865
+ Ge as requestFp,
867
866
  it as resetGlobals,
868
867
  rt as retrieveLaunchParams,
869
868
  Le as retrieveLaunchParamsFp,
@@ -875,6 +874,6 @@ export {
875
874
  ut as setLaunchParams,
876
875
  st as setTargetOrigin,
877
876
  re as supports,
878
- de as targetOrigin
877
+ le as targetOrigin
879
878
  };
880
879
  //# sourceMappingURL=index.js.map