@tma.js/bridge 2.2.0 → 2.2.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/dist/index.js CHANGED
@@ -1,19 +1,19 @@
1
- import { is as U, looseObject as m, function as te, nullish as E, boolean as V, number as B, string as P, optional as D, unknown as Me, parse as R, any as Ce } from "valibot";
2
- import { throwifyFpFn as $, getStorageValue as Le, setStorageValue as re, createLogger as qe, throwifyAnyEither as M, createCbCollector as ne, BetterTaskEither as oe } from "@tma.js/toolkit";
1
+ import { is as R, looseObject as m, function as ee, nullish as E, boolean as G, number as V, string as P, optional as B, unknown as Me, parse as W, any as Ce } from "valibot";
2
+ import { throwifyFpFn as T, getStorageValue as Le, setStorageValue as te, createLogger as qe, throwifyAnyEither as $, createCbCollector as re, BetterTaskEither as ne } from "@tma.js/toolkit";
3
3
  import { createLogger as fr, deepSnakeToCamelObjKeys as lr } from "@tma.js/toolkit";
4
- import { BetterPromise as ae, TimeoutError as Fe } from "better-promises";
4
+ import { BetterPromise as oe, TimeoutError as Fe } from "better-promises";
5
5
  import { CancelledError as wr, TimeoutError as hr } from "better-promises";
6
- import { errorClass as k, errorClassWithData as We } from "error-kid";
7
- import { parseLaunchParamsQueryFp as se, themeParams as Re, pipeJsonToSchema as ie, miniAppsMessage as ue, serializeLaunchParamsQuery as Ue, parseLaunchParamsQuery as Ie } from "@tma.js/transformers";
8
- import { signal as d, computed as ce } from "@tma.js/signals";
6
+ import { errorClassWithData as We, errorClass as k } from "error-kid";
7
+ import { parseLaunchParamsQueryFp as ae, themeParams as Re, pipeJsonToSchema as se, miniAppsMessage as ie, serializeLaunchParamsQuery as Ue, parseLaunchParamsQuery as Ie } from "@tma.js/transformers";
8
+ import { signal as d, computed as ue } from "@tma.js/signals";
9
9
  import Oe from "mitt";
10
- function pe(e) {
11
- return U(
12
- m({ TelegramWebviewProxy: m({ postEvent: te() }) }),
10
+ function ce(e) {
11
+ return R(
12
+ m({ TelegramWebviewProxy: m({ postEvent: ee() }) }),
13
13
  e
14
14
  );
15
15
  }
16
- function _e() {
16
+ function pe() {
17
17
  try {
18
18
  return window.self !== window.top;
19
19
  } catch {
@@ -28,7 +28,7 @@ var je = function(e, t, r) {
28
28
  function ze(e) {
29
29
  return e;
30
30
  }
31
- function S(e, t, r, n, a, o, s, i, c) {
31
+ function _e(e, t, r, n, a, o, s, i, c) {
32
32
  switch (arguments.length) {
33
33
  case 1:
34
34
  return e;
@@ -66,7 +66,7 @@ function S(e, t, r, n, a, o, s, i, c) {
66
66
  };
67
67
  }
68
68
  }
69
- function l(e, t, r, n, a, o, s, i, c) {
69
+ function f(e, t, r, n, a, o, s, i, c) {
70
70
  switch (arguments.length) {
71
71
  case 1:
72
72
  return e;
@@ -93,7 +93,7 @@ function l(e, t, r, n, a, o, s, i, c) {
93
93
  }
94
94
  }
95
95
  }
96
- var C = function(e, t) {
96
+ var M = function(e, t) {
97
97
  var r = typeof e == "number" ? function(n) {
98
98
  return n.length >= e;
99
99
  } : e;
@@ -111,7 +111,7 @@ var C = function(e, t) {
111
111
  return { _tag: "Left", left: e };
112
112
  }, Ne = function(e) {
113
113
  return { _tag: "Right", right: e };
114
- }, w = De, _ = Ne, fe = /* @__PURE__ */ C(2, function(e, t) {
114
+ }, w = De, _ = Ne, fe = /* @__PURE__ */ M(2, function(e, t) {
115
115
  return v(e) ? e : t(e.right);
116
116
  }), Je = function(e) {
117
117
  return function(t) {
@@ -129,7 +129,7 @@ var C = function(e, t) {
129
129
  return function(r) {
130
130
  return v(r) ? e(r.left) : t(r.right);
131
131
  };
132
- }, Ke = le, I = le, Ye = I, O = function(e, t) {
132
+ }, Ke = le, U = le, Ye = U, I = function(e, t) {
133
133
  try {
134
134
  return _(e());
135
135
  } catch (r) {
@@ -143,10 +143,10 @@ var C = function(e, t) {
143
143
  };
144
144
  }, ot = nt;
145
145
  function at(e) {
146
- return S(_, e.of);
146
+ return _e(_, e.of);
147
147
  }
148
148
  function st(e) {
149
- return S(w, e.of);
149
+ return _e(w, e.of);
150
150
  }
151
151
  function it(e) {
152
152
  return function(t, r) {
@@ -163,14 +163,14 @@ function ut(e) {
163
163
  function ct(e) {
164
164
  return function(t, r) {
165
165
  return function(n) {
166
- return e.map(n, I(t, r));
166
+ return e.map(n, U(t, r));
167
167
  };
168
168
  };
169
169
  }
170
170
  var me = function(e, t) {
171
- return l(e, _t(t));
171
+ return f(e, _t(t));
172
172
  }, pt = function(e, t) {
173
- return l(e, ft(t));
173
+ return f(e, ft(t));
174
174
  }, _t = function(e) {
175
175
  return function(t) {
176
176
  return function() {
@@ -190,7 +190,7 @@ var me = function(e, t) {
190
190
  return function() {
191
191
  return Promise.resolve(e);
192
192
  };
193
- }, lt = /* @__PURE__ */ C(2, function(e, t) {
193
+ }, lt = /* @__PURE__ */ M(2, function(e, t) {
194
194
  return function() {
195
195
  return Promise.resolve().then(e).then(function(r) {
196
196
  return t(r)();
@@ -207,16 +207,16 @@ var me = function(e, t) {
207
207
  of: we,
208
208
  ap: pt,
209
209
  chain: lt
210
- }, wt = /* @__PURE__ */ st(de), ve = /* @__PURE__ */ at(de), be = /* @__PURE__ */ ct(ge), ye = /* @__PURE__ */ C(3, ut(ge)), Ee = /* @__PURE__ */ C(2, it(mt)), ht = Ee, Pe = Ee;
211
- class gt extends k("MethodUnsupportedError", (t, r) => [
210
+ }, wt = /* @__PURE__ */ st(de), ve = /* @__PURE__ */ at(de), be = /* @__PURE__ */ ct(ge), ye = /* @__PURE__ */ M(3, ut(ge)), Ee = /* @__PURE__ */ M(2, it(mt)), ht = Ee, Pe = Ee;
211
+ class gt extends (/* @__PURE__ */ k("MethodUnsupportedError", (t, r) => [
212
212
  `Method "${t}" is unsupported in Mini Apps version ${r}`
213
- ]) {
213
+ ])) {
214
214
  }
215
- class dt extends k("MethodParameterUnsupportedError", (t, r, n) => [
215
+ class dt extends (/* @__PURE__ */ k("MethodParameterUnsupportedError", (t, r, n) => [
216
216
  `Parameter "${r}" of "${t}" method is unsupported in Mini Apps version ${n}`
217
- ]) {
217
+ ])) {
218
218
  }
219
- class vt extends We(
219
+ class vt extends (/* @__PURE__ */ We(
220
220
  "LaunchParamsRetrieveError",
221
221
  (t) => ({ errors: t }),
222
222
  (t) => [
@@ -230,78 +230,93 @@ class vt extends We(
230
230
  ].join(`
231
231
  `)
232
232
  ]
233
- ) {
233
+ )) {
234
234
  }
235
- class bt extends k("InvalidLaunchParamsError", (t, r) => [
235
+ class bt extends (/* @__PURE__ */ k("InvalidLaunchParamsError", (t, r) => [
236
236
  `Invalid value for launch params: ${t}`,
237
237
  { cause: r }
238
- ]) {
238
+ ])) {
239
239
  }
240
- class xe extends k("UnknownEnvError") {
240
+ class xe extends (/* @__PURE__ */ k("UnknownEnvError")) {
241
241
  }
242
- class yt extends k(
242
+ class yt extends (/* @__PURE__ */ k(
243
243
  "InvokeCustomMethodError",
244
244
  (t) => [`Server returned error: ${t}`]
245
- ) {
245
+ )) {
246
246
  }
247
- const N = "launchParams";
248
- function J(e) {
247
+ const D = "launchParams";
248
+ function N(e) {
249
249
  return e.replace(/^[^?#]*[?#]/, "").replace(/[?#]/g, "&");
250
250
  }
251
- const Et = S(L, Xe(se)), Jt = $(Et), Pt = S(L, Je((e) => {
252
- const t = new URLSearchParams(e).get("tgWebAppData");
253
- return t ? tt(t) : et;
254
- })), Qt = S(
255
- Pt,
256
- Ye((e) => {
257
- throw e;
258
- }, (e) => e),
259
- ot(() => {
260
- }, (e) => e)
261
- );
262
- function L() {
251
+ function Et() {
252
+ return f(
253
+ C(),
254
+ Xe(ae)
255
+ );
256
+ }
257
+ const Jt = T(Et);
258
+ function Pt() {
259
+ return f(
260
+ C(),
261
+ Je((e) => {
262
+ const t = new URLSearchParams(e).get("tgWebAppData");
263
+ return t ? tt(t) : et;
264
+ })
265
+ );
266
+ }
267
+ function Qt() {
268
+ return f(
269
+ Pt(),
270
+ Ye((e) => {
271
+ throw e;
272
+ }, (e) => e),
273
+ ot(() => {
274
+ }, (e) => e)
275
+ );
276
+ }
277
+ function C() {
263
278
  const e = [];
264
279
  for (const [t, r] of [
265
280
  // Try to retrieve launch parameters from the current location. This method
266
281
  // can return nothing in case, location was changed, and then the page was
267
282
  // reloaded.
268
- [() => J(window.location.href), "window.location.href"],
283
+ [() => N(window.location.href), "window.location.href"],
269
284
  // Then, try using the lower level API - window.performance.
270
285
  [() => {
271
286
  const n = performance.getEntriesByType("navigation")[0];
272
- return n && J(n.name);
287
+ return n && N(n.name);
273
288
  }, "performance navigation entries"],
274
289
  // Finally, try using the session storage.
275
- [() => Le(N), "local storage"]
290
+ [() => Le(D), "local storage"]
276
291
  ]) {
277
292
  const n = t();
278
293
  if (!n) {
279
294
  e.push({ source: r, error: new Error("Source is empty") });
280
295
  continue;
281
296
  }
282
- const a = l(
283
- se(n),
297
+ const a = f(
298
+ ae(n),
284
299
  Ke((o) => o, () => !0)
285
300
  );
286
301
  if (typeof a != "boolean") {
287
302
  e.push({ source: r, error: a });
288
303
  continue;
289
304
  }
290
- return re(N, n), _(n);
305
+ return te(D, n), _(n);
291
306
  }
292
307
  return w(new vt(e));
293
308
  }
294
- const Ht = $(L);
309
+ const Ht = T(C);
295
310
  function xt(e, t) {
296
311
  const r = /* @__PURE__ */ new Map(), n = Oe(), a = (o, s, i = !1) => {
297
312
  const c = r.get(o) || /* @__PURE__ */ new Map();
298
313
  r.set(o, c);
299
314
  const u = c.get(s) || [];
300
315
  c.set(s, u);
301
- const p = u.findIndex((f) => f[1] === i);
316
+ const p = u.findIndex((l) => l[1] === i);
302
317
  if (p >= 0 && (n.off(o, u[p][0]), u.splice(p, 1), !u.length && (c.delete(s), !c.size))) {
303
- const f = r.size;
304
- r.delete(o), f && !r.size && t();
318
+ const l = r.size;
319
+ r.delete(o), l && !r.size && t();
305
320
  }
306
321
  };
307
322
  return {
@@ -315,8 +330,8 @@ function xt(e, t) {
315
330
  n.on(o, u);
316
331
  const p = r.get(o) || /* @__PURE__ */ new Map();
317
332
  r.set(o, p);
318
- const f = p.get(s) || [];
319
- return p.set(s, f), f.push([u, i || !1]), c;
333
+ const l = p.get(s) || [];
334
+ return p.set(s, l), l.push([u, i || !1]), c;
320
335
  },
321
336
  off: a,
322
337
  // eslint-disable-next-line @typescript-eslint/unbound-method
@@ -327,7 +342,7 @@ function xt(e, t) {
327
342
  }
328
343
  };
329
344
  }
330
- function F(e, t) {
345
+ function q(e, t) {
331
346
  window.dispatchEvent(new MessageEvent("message", {
332
347
  data: JSON.stringify({ eventType: e, eventData: t }),
333
348
  // We specify this kind of source here in order to allow the package's "on" function to
@@ -336,15 +351,15 @@ function F(e, t) {
336
351
  source: window.parent
337
352
  }));
338
353
  }
339
- const T = d(!1), j = d("https://web.telegram.org"), kt = (e) => {
354
+ const A = d(!1), O = d("https://web.telegram.org"), kt = (e) => {
340
355
  g().log("Event received:", e);
341
- }, ke = ce(T);
356
+ }, ke = ue(A);
342
357
  function Kt(e) {
343
- e !== T() && (T.set(e), (e ? z : At)("*", kt));
358
+ e !== A() && (A.set(e), (e ? j : At)("*", kt));
344
359
  }
345
- const Se = ce(j);
360
+ const Se = ue(O);
346
361
  function Yt(e) {
347
- j.set(e), g().log("New target origin set", e);
362
+ O.set(e), g().log("New target origin set", e);
348
363
  }
349
364
  const x = d((...e) => {
350
365
  window.parent.postMessage(...e);
@@ -354,11 +369,11 @@ const x = d((...e) => {
354
369
  shouldLog: ke
355
370
  }));
356
371
  function Xt() {
357
- $t(), [x, j, Se, T, ke, g].forEach((e) => {
372
+ $t(), [x, O, Se, A, ke, g].forEach((e) => {
358
373
  e.unsubAll(), "reset" in e && e.reset();
359
374
  });
360
375
  }
361
- function W(e, t, r) {
376
+ function F(e, t, r) {
362
377
  const n = [r], a = e[t];
363
378
  typeof a == "function" && n.push(a);
364
379
  const o = (...i) => {
@@ -374,10 +389,10 @@ function W(e, t, r) {
374
389
  return;
375
390
  }
376
391
  if (i === 2) {
377
- H(e, t, n[1]);
392
+ Q(e, t, n[1]);
378
393
  return;
379
394
  }
380
- n.unshift(1), H(e, t, o);
395
+ n.unshift(1), Q(e, t, o);
381
396
  }
382
397
  });
383
398
  Ae(
@@ -387,7 +402,7 @@ function W(e, t, r) {
387
402
  (i) => n.push(i)
388
403
  );
389
404
  }
390
- function Q(e, t) {
405
+ function J(e, t) {
391
406
  const r = e[t];
392
407
  Ae(e, t, () => r, (n) => {
393
408
  Object.entries(n).forEach(([a, o]) => {
@@ -403,7 +418,7 @@ function Ae(e, t, r, n) {
403
418
  set: n
404
419
  });
405
420
  }
406
- function H(e, t, r) {
421
+ function Q(e, t, r) {
407
422
  Object.defineProperty(e, t, {
408
423
  enumerable: !0,
409
424
  configurable: !0,
@@ -418,8 +433,8 @@ const St = {
418
433
  }),
419
434
  custom_method_invoked: m({
420
435
  req_id: P(),
421
- result: D(Me()),
422
- error: D(P())
436
+ result: B(Me()),
437
+ error: B(P())
423
438
  }),
424
439
  popup_closed: E(
425
440
  m({ button_id: E(P(), () => {
@@ -428,10 +443,10 @@ const St = {
428
443
  ),
429
444
  viewport_changed: E(
430
445
  m({
431
- height: B(),
432
- width: E(B(), () => window.innerWidth),
433
- is_state_stable: V(),
434
- is_expanded: V()
446
+ height: V(),
447
+ width: E(V(), () => window.innerWidth),
448
+ is_state_stable: G(),
449
+ is_expanded: G()
435
450
  }),
436
451
  // TODO: At the moment, macOS has a bug with the invalid event payload - it is always equal to
437
452
  // null. Leaving this default value until the bug is fixed.
@@ -445,19 +460,19 @@ const St = {
445
460
  theme_params: Re()
446
461
  })
447
462
  };
448
- function K(e) {
463
+ function H(e) {
449
464
  if (e.source !== window.parent)
450
465
  return;
451
466
  let t;
452
467
  try {
453
- t = R(ie(ue()), e.data);
468
+ t = W(se(ie()), e.data);
454
469
  } catch {
455
470
  return;
456
471
  }
457
472
  const { eventType: r, eventData: n } = t, a = St[r];
458
473
  let o;
459
474
  try {
460
- o = a ? R(a, n) : n;
475
+ o = a ? W(a, n) : n;
461
476
  } catch (s) {
462
477
  return g().forceError(
463
478
  [
@@ -473,14 +488,14 @@ function K(e) {
473
488
  Tt(r, o);
474
489
  }
475
490
  const {
476
- on: z,
491
+ on: j,
477
492
  off: At,
478
493
  emit: Tt,
479
494
  clear: $t
480
495
  } = xt(
481
496
  () => {
482
497
  const e = window;
483
- !e.TelegramGameProxy && (e.TelegramGameProxy = {}), W(e.TelegramGameProxy, "receiveEvent", F), Q(e, "TelegramGameProxy"), !e.Telegram && (e.Telegram = {}), !e.Telegram.WebView && (e.Telegram.WebView = {}), W(e.Telegram.WebView, "receiveEvent", F), Q(e.Telegram, "WebView"), W(e, "TelegramGameProxy_receiveEvent", F), window.addEventListener("message", K);
498
+ !e.TelegramGameProxy && (e.TelegramGameProxy = {}), F(e.TelegramGameProxy, "receiveEvent", q), J(e, "TelegramGameProxy"), !e.Telegram && (e.Telegram = {}), !e.Telegram.WebView && (e.Telegram.WebView = {}), F(e.Telegram.WebView, "receiveEvent", q), J(e.Telegram, "WebView"), F(e, "TelegramGameProxy_receiveEvent", q), window.addEventListener("message", H);
484
499
  },
485
500
  () => {
486
501
  [
@@ -495,12 +510,12 @@ const {
495
510
  return;
496
511
  const [n, a] = r;
497
512
  "unwrap" in a && (a.unwrap(), n && n !== t && !Object.keys(n).length && delete t[e[0]]);
498
- }), window.removeEventListener("message", K);
513
+ }), window.removeEventListener("message", H);
499
514
  }
500
515
  ), Mt = (...e) => x()(...e);
501
516
  function Ct(e, t) {
502
- l(
503
- A(
517
+ f(
518
+ S(
504
519
  // @ts-expect-error It's ok, TS can't determine a specific override.
505
520
  e,
506
521
  t
@@ -510,49 +525,49 @@ function Ct(e, t) {
510
525
  })
511
526
  );
512
527
  }
513
- function A(e, t) {
528
+ function S(e, t) {
514
529
  g().log("Posting event:", t ? { eventType: e, eventData: t } : { eventType: e });
515
530
  const r = window, n = JSON.stringify({ eventType: e, eventData: t });
516
- return _e() ? (Mt(n, Se()), _(void 0)) : pe(r) ? (r.TelegramWebviewProxy.postEvent(e, JSON.stringify(t)), _(void 0)) : U(m({ external: m({ notify: te() }) }), r) ? (r.external.notify(n), _(void 0)) : w(new xe());
531
+ return pe() ? (Mt(n, Se()), _(void 0)) : ce(r) ? (r.TelegramWebviewProxy.postEvent(e, JSON.stringify(t)), _(void 0)) : R(m({ external: m({ notify: ee() }) }), r) ? (r.external.notify(n), _(void 0)) : w(new xe());
517
532
  }
518
- function G(e, t, r = {}) {
533
+ function z(e, t, r = {}) {
519
534
  const {
520
535
  // If no capture function was passed, we capture the first compatible event.
521
536
  capture: n = () => !0,
522
- postEvent: a = A
523
- } = r, o = d(), [s, i] = ne();
537
+ postEvent: a = S
538
+ } = r, o = d(), [s, i] = re();
524
539
  (Array.isArray(t) ? t : [t]).forEach((u) => {
525
540
  s(
526
- z(u, (p) => {
527
- const f = Array.isArray(t);
528
- n(f ? { event: u, payload: p } : p) && o.set([
529
- f ? { event: u, payload: p } : p
541
+ j(u, (p) => {
542
+ const l = Array.isArray(t);
543
+ n(l ? { event: u, payload: p } : p) && o.set([
544
+ l ? { event: u, payload: p } : p
530
545
  ]);
531
546
  })
532
547
  );
533
548
  });
534
549
  const c = (u) => (i(), u);
535
- return l(
550
+ return f(
536
551
  async () => a(e, r.params),
537
- Pe(() => oe((u, p, f) => {
552
+ Pe(() => ne((u, p, l) => {
538
553
  const h = o();
539
554
  if (h)
540
555
  return u(h[0]);
541
556
  const b = (y) => {
542
557
  y && u(y[0]);
543
- }, q = () => {
558
+ }, L = () => {
544
559
  o.unsub(b);
545
560
  };
546
- o.sub(b), f.on("finalized", q);
561
+ o.sub(b), l.on("finalized", L);
547
562
  }, r)),
548
563
  ye(c, c)
549
564
  );
550
565
  }
551
566
  function Zt(e, t, r) {
552
567
  const { postEvent: n } = r || {};
553
- return M(
568
+ return $(
554
569
  // @ts-expect-error TypeScript will not be able to handle our overrides here.
555
- G(e, t, {
570
+ z(e, t, {
556
571
  ...r,
557
572
  postEvent: n ? (...a) => {
558
573
  try {
@@ -560,7 +575,7 @@ function Zt(e, t, r) {
560
575
  } catch (o) {
561
576
  return w(o);
562
577
  }
563
- } : A
578
+ } : S
564
579
  })
565
580
  );
566
581
  }
@@ -570,17 +585,17 @@ function er(e, t) {
570
585
  e,
571
586
  t
572
587
  );
573
- return typeof r == "function" ? ae.fn(() => M(r)) : r;
588
+ return typeof r == "function" ? oe.fn(() => $(r)) : r;
574
589
  }
575
590
  function Lt(e, t) {
576
- const r = pe(window);
591
+ const r = ce(window);
577
592
  if (!e)
578
- return r || l(L(), I(() => !1, () => !0));
593
+ return r || f(C(), U(() => !1, () => !0));
579
594
  if (r)
580
595
  return ve(!0);
581
596
  const { timeout: n = 100 } = t || {};
582
- return l(
583
- G("web_app_request_theme", "theme_changed", { ...t, timeout: n }),
597
+ return f(
598
+ z("web_app_request_theme", "theme_changed", { ...t, timeout: n }),
584
599
  be(
585
600
  (a) => Fe.is(a) || xe.is(a) ? _(!1) : w(a),
586
601
  () => _(!0)
@@ -600,9 +615,9 @@ function tr({ launchParams: e, onEvent: t, resetPostMessage: r } = {}) {
600
615
  } catch (s) {
601
616
  throw new bt(o, s);
602
617
  }
603
- re("launchParams", o);
618
+ te("launchParams", o);
604
619
  }
605
- if (_e()) {
620
+ if (pe()) {
606
621
  if (!t)
607
622
  return;
608
623
  r && x.reset();
@@ -612,7 +627,7 @@ function tr({ launchParams: e, onEvent: t, resetPostMessage: r } = {}) {
612
627
  o(...s);
613
628
  };
614
629
  try {
615
- const u = R(ie(ue()), i);
630
+ const u = W(se(ie()), i);
616
631
  t({ name: u.eventType, params: u.eventData }, c);
617
632
  } catch {
618
633
  c();
@@ -638,7 +653,7 @@ function tr({ launchParams: e, onEvent: t, resetPostMessage: r } = {}) {
638
653
  function qt(e) {
639
654
  return ({ req_id: t }) => t === e;
640
655
  }
641
- const Y = {
656
+ const K = {
642
657
  "6.0": [
643
658
  "iframe_ready",
644
659
  "iframe_will_reload",
@@ -726,14 +741,14 @@ const Y = {
726
741
  ],
727
742
  9.1: ["web_app_hide_keyboard"]
728
743
  };
729
- function X(e, t) {
730
- return Object.keys(Y).find((n) => Y[n].some((a) => t ? typeof a == "object" && a.method === e && a.param === t : a === e)) || null;
744
+ function Y(e, t) {
745
+ return Object.keys(K).find((n) => K[n].some((a) => t ? typeof a == "object" && a.method === e && a.param === t : a === e)) || null;
731
746
  }
732
- function Z(e) {
747
+ function X(e) {
733
748
  return e.split(".").map(Number);
734
749
  }
735
750
  function Ft(e, t) {
736
- const r = Z(e), n = Z(t), a = Math.max(r.length, n.length);
751
+ const r = X(e), n = X(t), a = Math.max(r.length, n.length);
737
752
  for (let o = 0; o < a; o += 1) {
738
753
  const s = r[o] || 0, i = n[o] || 0;
739
754
  if (s !== i)
@@ -741,11 +756,11 @@ function Ft(e, t) {
741
756
  }
742
757
  return 0;
743
758
  }
744
- function ee(e, t, r) {
745
- const n = r ? X(
759
+ function Z(e, t, r) {
760
+ const n = r ? Y(
746
761
  e,
747
762
  t
748
- ) : X(e);
763
+ ) : Y(e);
749
764
  return n ? Ft(n, r || t) <= 0 : !1;
750
765
  }
751
766
  function rr(e, t = "strict") {
@@ -755,11 +770,11 @@ function rr(e, t = "strict") {
755
770
  throw s;
756
771
  return g().forceWarn(s.message);
757
772
  };
758
- return (n, a) => ee(n, e) ? n === "web_app_set_header_color" && U(m({ color: Ce() }), a) && !ee(n, "color", e) ? r({ version: e, method: n, param: "color" }) : Ct(n, a) : r({ version: e, method: n });
773
+ return (n, a) => Z(n, e) ? n === "web_app_set_header_color" && R(m({ color: Ce() }), a) && !Z(n, "color", e) ? r({ version: e, method: n, param: "color" }) : Ct(n, a) : r({ version: e, method: n });
759
774
  }
760
775
  function Wt(e, t, r, n) {
761
- return l(
762
- G("web_app_invoke_custom_method", "custom_method_invoked", {
776
+ return f(
777
+ z("web_app_invoke_custom_method", "custom_method_invoked", {
763
778
  ...n || {},
764
779
  params: { method: e, params: t, req_id: r },
765
780
  capture: qt(r)
@@ -768,7 +783,7 @@ function Wt(e, t, r, n) {
768
783
  );
769
784
  }
770
785
  function nr(e, t, r, n) {
771
- return ae.fn(() => l(
786
+ return oe.fn(() => f(
772
787
  // @ts-expect-error TypeScript is unable to determine required override.
773
788
  Wt(e, t, r, n),
774
789
  be(
@@ -783,35 +798,35 @@ function Rt(e, t, r = {}) {
783
798
  const {
784
799
  // If no capture function was passed, we capture the first compatible event.
785
800
  capture: n = () => !0,
786
- postEvent: a = A
787
- } = r, o = d(), [s, i] = ne();
801
+ postEvent: a = S
802
+ } = r, o = d(), [s, i] = re();
788
803
  (Array.isArray(t) ? t : [t]).forEach((u) => {
789
804
  s(
790
- z(u, (p) => {
805
+ j(u, (p) => {
791
806
  (Array.isArray(t) ? n({ event: u, payload: p }) : n(p)) && o.set([p]);
792
807
  })
793
808
  );
794
809
  });
795
810
  const c = (u) => (i(), u);
796
- return l(
811
+ return f(
797
812
  async () => a(e, r.params),
798
- Pe(() => oe((u, p, f) => {
813
+ Pe(() => ne((u, p, l) => {
799
814
  const h = o();
800
815
  if (h)
801
816
  return u(h[0]);
802
817
  const b = (y) => {
803
818
  y && u(y[0]);
804
- }, q = () => {
819
+ }, L = () => {
805
820
  o.unsub(b);
806
821
  };
807
- o.sub(b), f.on("finalized", q);
822
+ o.sub(b), l.on("finalized", L);
808
823
  }, r)),
809
824
  ye(c, c)
810
825
  );
811
826
  }
812
827
  function or(e, t, r) {
813
828
  const { postEvent: n } = r || {};
814
- return M(
829
+ return $(
815
830
  // @ts-expect-error TypeScript will not be able to handle our overrides here.
816
831
  Rt(e, t, {
817
832
  ...r,
@@ -821,7 +836,7 @@ function or(e, t, r) {
821
836
  } catch (o) {
822
837
  return w(o);
823
838
  }
824
- } : A
839
+ } : S
825
840
  })
826
841
  );
827
842
  }
@@ -831,20 +846,20 @@ function ar() {
831
846
  });
832
847
  }
833
848
  function Te(e) {
834
- return O(() => decodeURIComponent(
849
+ return I(() => decodeURIComponent(
835
850
  atob(
836
851
  e.replace(/-/g, "+").replace(/_/g, "/")
837
852
  ).split("").map((t) => "%" + ("00" + t.charCodeAt(0).toString(16)).slice(-2)).join("")
838
853
  ), (t) => t);
839
854
  }
840
- const sr = $(Te);
855
+ const sr = T(Te);
841
856
  function $e(e) {
842
857
  return btoa(
843
858
  encodeURIComponent(e).replace(/%([0-9A-F]{2})/g, (t, r) => String.fromCharCode(parseInt(`0x${r}`)))
844
859
  ).replace(/\+/g, "-").replace(/\//g, "_");
845
860
  }
846
861
  var Ut = function(e) {
847
- return O(function() {
862
+ return I(function() {
848
863
  return JSON.parse(e);
849
864
  }, ze);
850
865
  };
@@ -852,18 +867,18 @@ function It(e) {
852
867
  const t = $e(typeof e == "string" ? e : JSON.stringify(e));
853
868
  return t.length > 512 ? w(new Error("Value is too long for start parameter")) : _(t);
854
869
  }
855
- const ir = $(It);
870
+ const ir = T(It);
856
871
  function ur(e, t) {
857
- return M(
872
+ return $(
858
873
  Ot(
859
874
  e,
860
875
  // @ts-expect-error TypeScript is unable to detect a correct override.
861
- typeof t == "function" ? (r) => O(() => t(r), (n) => n) : t
876
+ typeof t == "function" ? (r) => I(() => t(r), (n) => n) : t
862
877
  )
863
878
  );
864
879
  }
865
880
  function Ot(e, t) {
866
- return l(
881
+ return f(
867
882
  Te(e),
868
883
  Ze((r) => t ? typeof t == "function" ? t(r) : Ut(r) : _(r))
869
884
  );
@@ -893,13 +908,13 @@ export {
893
908
  ur as decodeStartParam,
894
909
  Ot as decodeStartParamFp,
895
910
  lr as deepSnakeToCamelObjKeys,
896
- F as emitEvent,
911
+ q as emitEvent,
897
912
  $e as encodeBase64Url,
898
- X as getReleaseVersion,
899
- pe as hasWebviewProxy,
913
+ Y as getReleaseVersion,
914
+ ce as hasWebviewProxy,
900
915
  nr as invokeCustomMethod,
901
916
  Wt as invokeCustomMethodFp,
902
- _e as isIframe,
917
+ pe as isIframe,
903
918
  cr as isSafeToCreateStartParam,
904
919
  er as isTMA,
905
920
  Lt as isTMAFp,
@@ -907,14 +922,14 @@ export {
907
922
  tr as mockTelegramEnv,
908
923
  At as off,
909
924
  $t as offAll,
910
- z as on,
925
+ j as on,
911
926
  Ct as postEvent,
912
- A as postEventFp,
927
+ S as postEventFp,
913
928
  Mt as postMessage,
914
929
  x as postMessageImpl,
915
930
  or as request,
916
931
  Zt as request2,
917
- G as request2Fp,
932
+ z as request2Fp,
918
933
  Rt as requestFp,
919
934
  Xt as resetGlobals,
920
935
  Jt as retrieveLaunchParams,
@@ -922,10 +937,10 @@ export {
922
937
  Qt as retrieveRawInitData,
923
938
  Pt as retrieveRawInitDataFp,
924
939
  Ht as retrieveRawLaunchParams,
925
- L as retrieveRawLaunchParamsFp,
940
+ C as retrieveRawLaunchParamsFp,
926
941
  Kt as setDebug,
927
942
  Yt as setTargetOrigin,
928
- ee as supports,
943
+ Z as supports,
929
944
  Se as targetOrigin
930
945
  };
931
946
  //# sourceMappingURL=index.js.map