@vbotma/bridge 2.2.10 → 2.3.2

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 D, number as G, string as x, optional as N, unknown as he, parse as W, any as ye } from "valibot";
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
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 St, deepSnakeToCamelObjKeys as kt } 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,27 +54,27 @@ 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
  )) {
63
63
  }
64
- const H = "launchParams";
64
+ const N = "launchParams";
65
65
  function Q(e) {
66
66
  return e.replace(/^[^?#]*[?#]/, "").replace(/[?#]/g, "&");
67
67
  }
68
68
  function Le() {
69
- return l.pipe(
70
- V(),
69
+ return w.pipe(
70
+ L(),
71
71
  c.chainW(ie)
72
72
  );
73
73
  }
74
74
  const rt = C(Le);
75
75
  function Me() {
76
- return l.pipe(
77
- V(),
76
+ return w.pipe(
77
+ L(),
78
78
  c.map((e) => {
79
79
  const t = new URLSearchParams(e).get("vbWebAppData");
80
80
  return t ? F.some(t) : F.none;
@@ -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;
@@ -91,7 +91,7 @@ function nt() {
91
91
  }, (e) => e)
92
92
  );
93
93
  }
94
- function V() {
94
+ function L() {
95
95
  const e = [];
96
96
  for (const [t, r] of [
97
97
  // Try to retrieve launch parameters from the current location. This method
@@ -104,14 +104,14 @@ function V() {
104
104
  return n && Q(n.name);
105
105
  }, "performance navigation entries"],
106
106
  // Finally, try using the session storage.
107
- [() => ve(H), "local storage"]
107
+ [() => ve(N), "local storage"]
108
108
  ]) {
109
109
  const n = t();
110
110
  if (!n) {
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
  );
@@ -119,13 +119,13 @@ function V() {
119
119
  e.push({ source: r, error: a });
120
120
  continue;
121
121
  }
122
- return R(H, n), c.right(n);
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 = C(V);
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 M(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 M(e, t) {
168
168
  source: window.parent
169
169
  }));
170
170
  }
171
- const B = y(!1), $ = y("https://web.telegram.org"), qe = (e) => {
172
- h().log("Event received:", e);
173
- }, we = _e(B);
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 !== B() && (B.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, B, 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: N(he()),
254
- error: N(x())
253
+ result: H(ge()),
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: D(),
266
- is_expanded: D()
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 = W(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 ? W(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", M), K(e, "TelegramGameProxy"), !e.VBot && (e.VBot = {}), !e.VBot.WebView && (e.VBot.WebView = {}), q(e.VBot.WebView, "receiveEvent", M), K(e.VBot, "WebView"), q(e, "TelegramGameProxy_receiveEvent", M), 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
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,20 +363,20 @@ function J(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
- }, L = () => {
374
+ }, M = () => {
376
375
  o.unsub(v);
377
376
  };
378
- o.sub(v), f.on("finalized", L);
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) {
@@ -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
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(V(), 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(
413
+ return w.pipe(
415
414
  J("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),
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 = W(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 = W(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,12 +554,11 @@ function lt() {
555
554
  ), t = {
556
555
  ...e,
557
556
  send: (r, n) => {
558
- const a = JSON.stringify({ eventType: r, eventData: n });
559
- window.postMessage(a, window.location.origin || "*");
557
+ k(r, n);
560
558
  },
561
559
  clear: () => {
562
560
  var r;
563
- 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;
564
562
  }
565
563
  };
566
564
  return window.VBotWebviewProxy = {
@@ -574,15 +572,15 @@ function lt() {
574
572
  }
575
573
  e.emit(r, a);
576
574
  }
577
- }, g = t, t;
575
+ }, h = t, t;
578
576
  }
579
- let g;
580
- function wt() {
581
- if (!g)
577
+ let h;
578
+ function dt() {
579
+ if (!h)
582
580
  throw new Error("HostBridge not initialized. Call defineHostBridge() or defineWebComponentBridge() first.");
583
- return g;
581
+ return h;
584
582
  }
585
- function $e(e) {
583
+ function ze(e) {
586
584
  return ({ req_id: t }) => t === e;
587
585
  }
588
586
  const Z = {
@@ -683,7 +681,7 @@ function ee(e, t) {
683
681
  function te(e) {
684
682
  return e.split(".").map(Number);
685
683
  }
686
- function ze(e, t) {
684
+ function De(e, t) {
687
685
  const r = te(e), n = te(t), a = Math.max(r.length, n.length);
688
686
  for (let o = 0; o < a; o += 1) {
689
687
  const s = r[o] || 0, i = n[o] || 0;
@@ -697,32 +695,32 @@ function re(e, t, r) {
697
695
  e,
698
696
  t
699
697
  ) : ee(e);
700
- return n ? ze(n, r || t) <= 0 : !1;
698
+ return n ? De(n, r || t) <= 0 : !1;
701
699
  }
702
- function dt(e, t = "strict") {
700
+ function lt(e, t = "strict") {
703
701
  const r = typeof t == "function" ? t : (n) => {
704
- 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);
705
703
  if (t === "strict")
706
704
  throw s;
707
- return h().forceWarn(s.message);
705
+ return g().forceWarn(s.message);
708
706
  };
709
- 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 }));
710
708
  }
711
709
  function Je(e, t, r, n) {
712
- return l.pipe(
710
+ return w.pipe(
713
711
  J("web_app_invoke_custom_method", "custom_method_invoked", {
714
712
  ...n || {},
715
713
  params: { method: e, params: t, req_id: r },
716
- capture: $e(r)
714
+ capture: ze(r)
717
715
  }),
718
- 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))
719
717
  );
720
718
  }
721
- function mt(e, t, r, n) {
722
- return se.fn(() => l.pipe(
719
+ function bt(e, t, r, n) {
720
+ return se.fn(() => w.pipe(
723
721
  // @ts-expect-error TypeScript is unable to determine required override.
724
722
  Je(e, t, r, n),
725
- d.match(
723
+ l.match(
726
724
  (a) => {
727
725
  throw a;
728
726
  },
@@ -730,41 +728,41 @@ function mt(e, t, r, n) {
730
728
  )
731
729
  )());
732
730
  }
733
- function De(e, t, r = {}) {
731
+ function Ge(e, t, r = {}) {
734
732
  const {
735
733
  // If no capture function was passed, we capture the first compatible event.
736
734
  capture: n = () => !0,
737
- postEvent: a = k
735
+ postEvent: a = S
738
736
  } = r, o = y(), [s, i] = oe();
739
737
  (Array.isArray(t) ? t : [t]).forEach((p) => {
740
738
  s(
741
- z(p, (u) => {
739
+ D(p, (u) => {
742
740
  (Array.isArray(t) ? n({ event: p, payload: u }) : n(u)) && o.set([u]);
743
741
  })
744
742
  );
745
743
  });
746
744
  const _ = (p) => (i(), p);
747
- return l.pipe(
745
+ return w.pipe(
748
746
  async () => a(e, r.params),
749
- d.chainW(() => ae((p, u, f) => {
750
- const m = o();
751
- if (m)
752
- return p(m[0]);
747
+ l.chainW(() => ae((p, u, f) => {
748
+ const b = o();
749
+ if (b)
750
+ return p(b[0]);
753
751
  const v = (E) => {
754
752
  E && p(E[0]);
755
- }, L = () => {
753
+ }, M = () => {
756
754
  o.unsub(v);
757
755
  };
758
- o.sub(v), f.on("finalized", L);
756
+ o.sub(v), f.on("finalized", M);
759
757
  }, r)),
760
- d.mapBoth(_, _)
758
+ l.mapBoth(_, _)
761
759
  );
762
760
  }
763
- function bt(e, t, r) {
761
+ function mt(e, t, r) {
764
762
  const { postEvent: n } = r || {};
765
763
  return A(
766
764
  // @ts-expect-error TypeScript will not be able to handle our overrides here.
767
- De(e, t, {
765
+ Ge(e, t, {
768
766
  ...r,
769
767
  postEvent: n ? (...a) => {
770
768
  try {
@@ -772,110 +770,110 @@ function bt(e, t, r) {
772
770
  } catch (o) {
773
771
  return c.left(o);
774
772
  }
775
- } : k
773
+ } : S
776
774
  })
777
775
  );
778
776
  }
779
- function gt() {
777
+ function ht() {
780
778
  Object.hasOwn || (Object.hasOwn = function(e, t) {
781
779
  return Object.prototype.hasOwnProperty.call(e, t);
782
780
  });
783
781
  }
784
- function be(e) {
782
+ function me(e) {
785
783
  return c.tryCatch(() => decodeURIComponent(
786
784
  atob(
787
785
  e.replace(/-/g, "+").replace(/_/g, "/")
788
786
  ).split("").map((t) => "%" + ("00" + t.charCodeAt(0).toString(16)).slice(-2)).join("")
789
787
  ), (t) => t);
790
788
  }
791
- const ht = C(be);
792
- function ge(e) {
789
+ const gt = C(me);
790
+ function he(e) {
793
791
  return btoa(
794
792
  encodeURIComponent(e).replace(/%([0-9A-F]{2})/g, (t, r) => String.fromCharCode(parseInt(`0x${r}`)))
795
793
  ).replace(/\+/g, "-").replace(/\//g, "_");
796
794
  }
797
- function Ge(e) {
798
- 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));
799
797
  return t.length > 512 ? c.left(new Error("Value is too long for start parameter")) : c.right(t);
800
798
  }
801
- const yt = C(Ge);
799
+ const yt = C(Te);
802
800
  function vt(e, t) {
803
801
  return A(
804
- Ne(
802
+ He(
805
803
  e,
806
804
  // @ts-expect-error TypeScript is unable to detect a correct override.
807
805
  typeof t == "function" ? (r) => c.tryCatch(() => t(r), (n) => n) : t
808
806
  )
809
807
  );
810
808
  }
811
- function Ne(e, t) {
812
- return l.pipe(
813
- be(e),
809
+ function He(e, t) {
810
+ return w.pipe(
811
+ me(e),
814
812
  c.chain((r) => t ? typeof t == "function" ? t(r) : xe.parse(r) : c.right(r))
815
813
  );
816
814
  }
817
815
  function Et(e) {
818
- return ge(e).length <= 512;
816
+ return he(e).length <= 512;
819
817
  }
820
818
  export {
821
- Bt as CancelledError,
819
+ Vt as CancelledError,
822
820
  fe as InvalidLaunchParamsError,
823
- Ve as InvokeCustomMethodFailedError,
824
- Ae as LaunchParamsRetrieveError,
825
- Ce as MethodParameterUnsupportedError,
826
- Be as MethodUnsupportedError,
827
- Ct as TimeoutError,
828
- le as UnknownEnvError,
829
- gt as applyPolyfills,
830
- $e as captureSameReq,
831
- ze as compareVersions,
832
- St as createLogger,
833
- 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,
834
832
  yt as createStartParam,
835
- Ge as createStartParamFp,
836
- we as debug,
837
- ht as decodeBase64Url,
838
- be as decodeBase64UrlFp,
833
+ Te as createStartParamFp,
834
+ de as debug,
835
+ gt as decodeBase64Url,
836
+ me as decodeBase64UrlFp,
839
837
  vt as decodeStartParam,
840
- Ne as decodeStartParamFp,
841
- kt as deepSnakeToCamelObjKeys,
838
+ He as decodeStartParamFp,
839
+ St as deepSnakeToCamelObjKeys,
842
840
  ft as defineHostBridge,
843
- lt as defineWebComponentBridge,
844
- M as emitEvent,
845
- ge as encodeBase64Url,
846
- wt as getHostBridge,
841
+ wt as defineWebComponentBridge,
842
+ k as emitEvent,
843
+ he as encodeBase64Url,
844
+ dt as getHostBridge,
847
845
  ee as getReleaseVersion,
848
846
  ue as hasWebviewProxy,
849
- mt as invokeCustomMethod,
847
+ bt as invokeCustomMethod,
850
848
  Je as invokeCustomMethodFp,
851
849
  j as isIframe,
852
850
  Et as isSafeToCreateStartParam,
853
851
  ct as isVBma,
854
- Ie as isVBmaFp,
855
- h as logger,
852
+ $e as isVBmaFp,
853
+ g as logger,
856
854
  _t as mockVBotEnv,
857
855
  Oe as off,
858
- Te as offAll,
859
- z as on,
856
+ Ue as offAll,
857
+ D as on,
860
858
  je as postEvent,
861
- k as postEventFp,
862
- Ue as postMessage,
863
- b as postMessageImpl,
864
- bt as request,
859
+ S as postEventFp,
860
+ Ie as postMessage,
861
+ m as postMessageImpl,
862
+ mt as request,
865
863
  pt as request2,
866
864
  J as request2Fp,
867
- De as requestFp,
865
+ Ge as requestFp,
868
866
  it as resetGlobals,
869
867
  rt as retrieveLaunchParams,
870
868
  Le as retrieveLaunchParamsFp,
871
869
  nt as retrieveRawInitData,
872
870
  Me as retrieveRawInitDataFp,
873
871
  ot as retrieveRawLaunchParams,
874
- V as retrieveRawLaunchParamsFp,
872
+ L as retrieveRawLaunchParamsFp,
875
873
  at as setDebug,
876
874
  ut as setLaunchParams,
877
875
  st as setTargetOrigin,
878
876
  re as supports,
879
- de as targetOrigin
877
+ le as targetOrigin
880
878
  };
881
879
  //# sourceMappingURL=index.js.map