@tma.js/sdk-react 2.2.1 → 2.2.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,19 +1,19 @@
1
- import { jsx as yt } from "react/jsx-runtime";
2
- import { createContext as ie, useContext as oe, useState as Et, useEffect as S, useMemo as Pt, useRef as gt, useCallback as ae } from "react";
1
+ import { jsx as Et } from "react/jsx-runtime";
2
+ import { createContext as ie, useContext as oe, useState as Pt, useEffect as S, useMemo as Rt, useRef as ft, useCallback as ae } from "react";
3
3
  var ce = Object.defineProperty, he = (e, t, s) => t in e ? ce(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s, c = (e, t, s) => (he(e, typeof t != "symbol" ? t + "" : t, s), s);
4
- function Rt(e, t) {
4
+ function xt(e, t) {
5
5
  let s;
6
6
  const n = () => {
7
7
  s !== void 0 && t && t(s), s = void 0;
8
8
  };
9
9
  return [() => s === void 0 ? s = e(n) : s, n];
10
10
  }
11
- function xt(e) {
11
+ function Ct(e) {
12
12
  const t = j(), { count: s } = t;
13
13
  t.unsubscribe(e), s && !t.count && Ae();
14
14
  }
15
15
  function pe(e) {
16
- return j().subscribe(e), () => xt(e);
16
+ return j().subscribe(e), () => Ct(e);
17
17
  }
18
18
  class ue {
19
19
  constructor(t, s = {}) {
@@ -31,12 +31,12 @@ class ue {
31
31
  second: "2-digit",
32
32
  fractionalSecondDigits: 3,
33
33
  timeZone: "UTC"
34
- }).format(n), { textColor: i, bgColor: o } = this.options, a = "font-weight: bold;padding: 0 5px;border-radius:5px";
34
+ }).format(n), { textColor: i, bgColor: a } = this.options, o = "font-weight: bold;padding: 0 5px;border-radius:5px";
35
35
  console[t](
36
36
  `%c${r}%c / %c${this.scope}`,
37
- `${a};background-color: lightblue;color:black`,
37
+ `${o};background-color: lightblue;color:black`,
38
38
  "",
39
- `${a};${i ? `color:${i};` : ""}${o ? `background-color:${o}` : ""}`,
39
+ `${o};${i ? `color:${i};` : ""}${a ? `background-color:${a}` : ""}`,
40
40
  ...s
41
41
  );
42
42
  }
@@ -60,16 +60,16 @@ const nt = new ue("SDK", {
60
60
  textColor: "white"
61
61
  });
62
62
  let X = !1;
63
- const ft = ({ name: e, payload: t }) => {
63
+ const mt = ({ name: e, payload: t }) => {
64
64
  nt.log("Event received:", t ? { name: e, payload: t } : { name: e });
65
65
  };
66
66
  function le(e) {
67
- X !== e && (X = e, e ? pe(ft) : xt(ft));
67
+ X !== e && (X = e, e ? pe(mt) : Ct(mt));
68
68
  }
69
69
  function de(...e) {
70
70
  X && nt.log(...e);
71
71
  }
72
- class N {
72
+ class D {
73
73
  constructor() {
74
74
  c(this, "listeners", /* @__PURE__ */ new Map()), c(this, "listenersCount", 0), c(this, "subscribeListeners", []);
75
75
  }
@@ -142,7 +142,7 @@ class N {
142
142
  function tt(e, t, s) {
143
143
  return window.addEventListener(e, t, s), () => window.removeEventListener(e, t, s);
144
144
  }
145
- function Ct(...e) {
145
+ function rt(...e) {
146
146
  let t = !1;
147
147
  const s = [...e];
148
148
  return [
@@ -194,7 +194,7 @@ class G {
194
194
  function A(e, t) {
195
195
  return () => new G(e, !1, t);
196
196
  }
197
- const P = A((e) => {
197
+ const E = A((e) => {
198
198
  if (typeof e == "boolean")
199
199
  return e;
200
200
  const t = String(e);
@@ -210,23 +210,23 @@ function Tt(e, t) {
210
210
  const r = e[n];
211
211
  if (!r)
212
212
  continue;
213
- let i, o;
213
+ let i, a;
214
214
  if (typeof r == "function" || "parse" in r)
215
- i = n, o = typeof r == "function" ? r : r.parse.bind(r);
215
+ i = n, a = typeof r == "function" ? r : r.parse.bind(r);
216
216
  else {
217
- const { type: a } = r;
218
- i = r.from || n, o = typeof a == "function" ? a : a.parse.bind(a);
217
+ const { type: o } = r;
218
+ i = r.from || n, a = typeof o == "function" ? o : o.parse.bind(o);
219
219
  }
220
220
  try {
221
- const a = o(t(i));
222
- a !== void 0 && (s[n] = a);
223
- } catch (a) {
224
- throw m(St, `Unable to parse field "${n}"`, a);
221
+ const o = a(t(i));
222
+ o !== void 0 && (s[n] = o);
223
+ } catch (o) {
224
+ throw m(St, `Unable to parse field "${n}"`, o);
225
225
  }
226
226
  }
227
227
  return s;
228
228
  }
229
- function rt(e) {
229
+ function it(e) {
230
230
  let t = e;
231
231
  if (typeof t == "string" && (t = JSON.parse(t)), typeof t != "object" || t === null || Array.isArray(t))
232
232
  throw T();
@@ -234,11 +234,11 @@ function rt(e) {
234
234
  }
235
235
  function w(e, t) {
236
236
  return new G((s) => {
237
- const n = rt(s);
237
+ const n = it(s);
238
238
  return Tt(e, (r) => n[r]);
239
239
  }, !1, t);
240
240
  }
241
- const x = A((e) => {
241
+ const R = A((e) => {
242
242
  if (typeof e == "number")
243
243
  return e;
244
244
  if (typeof e == "string") {
@@ -248,7 +248,7 @@ const x = A((e) => {
248
248
  }
249
249
  throw T();
250
250
  }, "number");
251
- function it(e) {
251
+ function ot(e) {
252
252
  return /^#[\da-f]{6}$/i.test(e);
253
253
  }
254
254
  function Pe(e) {
@@ -256,7 +256,7 @@ function Pe(e) {
256
256
  }
257
257
  function At(e) {
258
258
  const t = e.replace(/\s/g, "").toLowerCase();
259
- if (it(t))
259
+ if (ot(t))
260
260
  return t;
261
261
  if (Pe(t)) {
262
262
  let n = "#";
@@ -272,14 +272,14 @@ function At(e) {
272
272
  return n + (i.length === 1 ? "0" : "") + i;
273
273
  }, "#");
274
274
  }
275
- const p = A((e) => {
275
+ const h = A((e) => {
276
276
  if (typeof e == "string" || typeof e == "number")
277
277
  return e.toString();
278
278
  throw T();
279
- }, "string"), It = A((e) => At(p().parse(e)), "rgb");
279
+ }, "string"), It = A((e) => At(h().parse(e)), "rgb");
280
280
  function kt(e) {
281
281
  return w({
282
- eventType: p(),
282
+ eventType: h(),
283
283
  eventData: (t) => t
284
284
  }).parse(e);
285
285
  }
@@ -316,44 +316,44 @@ function xe() {
316
316
  }
317
317
  const Ce = {
318
318
  clipboard_text_received: w({
319
- req_id: p(),
320
- data: (e) => e === null ? e : p().optional().parse(e)
319
+ req_id: h(),
320
+ data: (e) => e === null ? e : h().optional().parse(e)
321
321
  }),
322
322
  custom_method_invoked: w({
323
- req_id: p(),
323
+ req_id: h(),
324
324
  result: (e) => e,
325
- error: p().optional()
325
+ error: h().optional()
326
326
  }),
327
- invoice_closed: w({ slug: p(), status: p() }),
328
- phone_requested: w({ status: p() }),
327
+ invoice_closed: w({ slug: h(), status: h() }),
328
+ phone_requested: w({ status: h() }),
329
329
  popup_closed: {
330
330
  parse(e) {
331
331
  return w({
332
- button_id: (t) => t == null ? void 0 : p().parse(t)
332
+ button_id: (t) => t == null ? void 0 : h().parse(t)
333
333
  }).parse(e ?? {});
334
334
  }
335
335
  },
336
- qr_text_received: w({ data: p().optional() }),
336
+ qr_text_received: w({ data: h().optional() }),
337
337
  theme_changed: w({
338
338
  theme_params: (e) => {
339
339
  const t = It().optional();
340
- return Object.entries(rt(e)).reduce((s, [n, r]) => (s[n] = t.parse(r), s), {});
340
+ return Object.entries(it(e)).reduce((s, [n, r]) => (s[n] = t.parse(r), s), {});
341
341
  }
342
342
  }),
343
343
  viewport_changed: w({
344
- height: x(),
345
- width: (e) => e == null ? window.innerWidth : x().parse(e),
346
- is_state_stable: P(),
347
- is_expanded: P()
344
+ height: R(),
345
+ width: (e) => e == null ? window.innerWidth : R().parse(e),
346
+ is_state_stable: E(),
347
+ is_expanded: E()
348
348
  }),
349
- write_access_requested: w({ status: p() })
349
+ write_access_requested: w({ status: h() })
350
350
  };
351
351
  function Se() {
352
- const e = new N(), t = new N();
352
+ const e = new D(), t = new D();
353
353
  t.subscribe((n) => {
354
354
  e.emit("event", { name: n.event, payload: n.args[0] });
355
355
  }), xe();
356
- const [, s] = Ct(
356
+ const [, s] = rt(
357
357
  // Don't forget to remove created handlers.
358
358
  Re,
359
359
  // Add "resize" event listener to make sure, we always have fresh viewport information.
@@ -380,15 +380,15 @@ function Se() {
380
380
  } catch {
381
381
  return;
382
382
  }
383
- const { eventType: i, eventData: o } = r, a = Ce[i];
383
+ const { eventType: i, eventData: a } = r, o = Ce[i];
384
384
  try {
385
- const u = a ? a.parse(o) : o;
386
- t.emit(...u ? [i, u] : [i]);
387
- } catch (u) {
385
+ const p = o ? o.parse(a) : a;
386
+ t.emit(...p ? [i, p] : [i]);
387
+ } catch (p) {
388
388
  nt.error(
389
389
  `An error occurred processing the "${i}" event from the Telegram application. Please, file an issue here: https://github.com/Telegram-Mini-Apps/tma.js/issues/new/choose`,
390
390
  r,
391
- u
391
+ p
392
392
  );
393
393
  }
394
394
  }),
@@ -410,12 +410,12 @@ function Se() {
410
410
  }
411
411
  }, s];
412
412
  }
413
- const [Te, Ae] = Rt(
413
+ const [Te, Ae] = xt(
414
414
  (e) => {
415
415
  const [t, s] = Se(), n = t.off.bind(t);
416
416
  return t.off = (r, i) => {
417
- const { count: o } = t;
418
- n(r, i), o && !t.count && e();
417
+ const { count: a } = t;
418
+ n(r, i), a && !t.count && e();
419
419
  }, [t, s];
420
420
  },
421
421
  ([, e]) => e()
@@ -426,7 +426,7 @@ function j() {
426
426
  function z(e, t) {
427
427
  j().off(e, t);
428
428
  }
429
- function E(e, t, s) {
429
+ function y(e, t, s) {
430
430
  return j().on(e, t, s);
431
431
  }
432
432
  function V(e) {
@@ -435,21 +435,21 @@ function V(e) {
435
435
  function Ie(e, t) {
436
436
  const s = e.split("."), n = t.split("."), r = Math.max(s.length, n.length);
437
437
  for (let i = 0; i < r; i += 1) {
438
- const o = parseInt(s[i] || "0", 10), a = parseInt(n[i] || "0", 10);
439
- if (o !== a)
440
- return o > a ? 1 : -1;
438
+ const a = parseInt(s[i] || "0", 10), o = parseInt(n[i] || "0", 10);
439
+ if (a !== o)
440
+ return a > o ? 1 : -1;
441
441
  }
442
442
  return 0;
443
443
  }
444
- function y(e, t) {
444
+ function v(e, t) {
445
445
  return Ie(e, t) <= 0;
446
446
  }
447
- function C(e, t, s) {
447
+ function x(e, t, s) {
448
448
  if (typeof s == "string") {
449
449
  if (e === "web_app_open_link" && t === "try_instant_view")
450
- return y("6.4", s);
450
+ return v("6.4", s);
451
451
  if (e === "web_app_set_header_color" && t === "color")
452
- return y("6.9", s);
452
+ return v("6.9", s);
453
453
  }
454
454
  switch (e) {
455
455
  case "web_app_open_tg_link":
@@ -458,27 +458,27 @@ function C(e, t, s) {
458
458
  case "web_app_set_background_color":
459
459
  case "web_app_set_header_color":
460
460
  case "web_app_trigger_haptic_feedback":
461
- return y("6.1", t);
461
+ return v("6.1", t);
462
462
  case "web_app_open_popup":
463
- return y("6.2", t);
463
+ return v("6.2", t);
464
464
  case "web_app_close_scan_qr_popup":
465
465
  case "web_app_open_scan_qr_popup":
466
466
  case "web_app_read_text_from_clipboard":
467
- return y("6.4", t);
467
+ return v("6.4", t);
468
468
  case "web_app_switch_inline_query":
469
- return y("6.7", t);
469
+ return v("6.7", t);
470
470
  case "web_app_invoke_custom_method":
471
471
  case "web_app_request_write_access":
472
472
  case "web_app_request_phone":
473
- return y("6.9", t);
473
+ return v("6.9", t);
474
474
  case "web_app_setup_settings_button":
475
- return y("6.10", t);
475
+ return v("6.10", t);
476
476
  case "web_app_biometry_get_info":
477
477
  case "web_app_biometry_open_settings":
478
478
  case "web_app_biometry_request_access":
479
479
  case "web_app_biometry_request_auth":
480
480
  case "web_app_biometry_update_token":
481
- return y("7.2", t);
481
+ return v("7.2", t);
482
482
  default:
483
483
  return [
484
484
  "iframe_ready",
@@ -501,25 +501,25 @@ function qt(e) {
501
501
  function Ot(e) {
502
502
  return "TelegramWebviewProxy" in e && V(e.TelegramWebviewProxy) && "postEvent" in e.TelegramWebviewProxy && typeof e.TelegramWebviewProxy.postEvent == "function";
503
503
  }
504
- function ot() {
504
+ function at() {
505
505
  try {
506
506
  return window.self !== window.top;
507
507
  } catch {
508
508
  return !0;
509
509
  }
510
510
  }
511
- let Dt = "https://web.telegram.org";
511
+ let Nt = "https://web.telegram.org";
512
512
  function wn(e) {
513
- Dt = e;
513
+ Nt = e;
514
514
  }
515
515
  function ke() {
516
- return Dt;
516
+ return Nt;
517
517
  }
518
518
  function B(e, t, s) {
519
519
  let n = {}, r;
520
520
  t === void 0 && s === void 0 ? n = {} : t !== void 0 && s !== void 0 ? (n = s, r = t) : t !== void 0 && ("targetOrigin" in t ? n = t : r = t);
521
521
  const { targetOrigin: i = ke() } = n;
522
- if (de("Posting event:", r ? { event: e, data: r } : { event: e }), ot()) {
522
+ if (de("Posting event:", r ? { event: e, data: r } : { event: e }), at()) {
523
523
  window.parent.postMessage(JSON.stringify({ eventType: e, eventData: r }), i);
524
524
  return;
525
525
  }
@@ -538,11 +538,11 @@ function B(e, t, s) {
538
538
  }
539
539
  function qe(e) {
540
540
  return (t, s) => {
541
- if (!C(t, e))
541
+ if (!x(t, e))
542
542
  throw m(_e, `Method "${t}" is unsupported in Mini Apps version ${e}`);
543
543
  if (V(s)) {
544
544
  let n;
545
- if (t === "web_app_open_link" && "try_instant_view" in s ? n = "try_instant_view" : t === "web_app_set_header_color" && "color" in s && (n = "color"), n && !C(t, n, e))
545
+ if (t === "web_app_open_link" && "try_instant_view" in s ? n = "try_instant_view" : t === "web_app_set_header_color" && "color" in s && (n = "color"), n && !x(t, n, e))
546
546
  throw m(
547
547
  we,
548
548
  `Parameter "${n}" of "${t}" method is unsupported in Mini Apps version ${e}`
@@ -551,7 +551,7 @@ function qe(e) {
551
551
  return B(t, s);
552
552
  };
553
553
  }
554
- function Nt(e) {
554
+ function Dt(e) {
555
555
  return ({ req_id: t }) => t === e;
556
556
  }
557
557
  function Bt(e) {
@@ -569,21 +569,17 @@ function Mt(e, t) {
569
569
  }
570
570
  async function g(e) {
571
571
  let t;
572
- const s = new Promise((h) => {
573
- t = h;
574
- }), {
575
- method: n,
576
- event: r,
577
- capture: i,
578
- postEvent: o = B,
579
- timeout: a
580
- } = e, u = (Array.isArray(r) ? r : [r]).map(
581
- (h) => E(h, (v) => (!i || i(v)) && t(v))
572
+ const s = new Promise((o) => {
573
+ t = o;
574
+ }), { event: n, capture: r, timeout: i } = e, [, a] = rt(
575
+ ...(Array.isArray(n) ? n : [n]).map(
576
+ (o) => y(o, (p) => (!r || r(p)) && t(p))
577
+ )
582
578
  );
583
579
  try {
584
- return o(n, e.params), await (a ? Mt(s, a) : s);
580
+ return (e.postEvent || B)(e.method, e.params), await (i ? Mt(s, i) : s);
585
581
  } finally {
586
- u.forEach((h) => h());
582
+ a();
587
583
  }
588
584
  }
589
585
  async function O(e, t, s, n = {}) {
@@ -599,7 +595,7 @@ async function O(e, t, s, n = {}) {
599
595
  params: t,
600
596
  req_id: s
601
597
  },
602
- capture: Nt(s)
598
+ capture: Dt(s)
603
599
  });
604
600
  if (i)
605
601
  throw m(fe, i);
@@ -632,7 +628,7 @@ function Vt(e) {
632
628
  }
633
629
  class Oe {
634
630
  constructor(t) {
635
- c(this, "ee", new N()), c(this, "on", this.ee.on.bind(this.ee)), c(this, "off", this.ee.off.bind(this.ee)), this.state = t;
631
+ c(this, "ee", new D()), c(this, "on", this.ee.on.bind(this.ee)), c(this, "off", this.ee.off.bind(this.ee)), this.state = t;
636
632
  }
637
633
  /**
638
634
  * Clones current state and returns its copy.
@@ -651,25 +647,25 @@ class Oe {
651
647
  return this.state[t];
652
648
  }
653
649
  }
654
- class at {
650
+ class ct {
655
651
  constructor(t) {
656
652
  c(this, "state"), c(this, "get"), c(this, "set"), c(this, "clone"), this.state = new Oe(t), this.set = this.state.set.bind(this.state), this.get = this.state.get.bind(this.state), this.clone = this.state.clone.bind(this.state);
657
653
  }
658
654
  }
659
655
  function $t(e, t) {
660
- return (s) => C(t[s], e);
656
+ return (s) => x(t[s], e);
661
657
  }
662
- class ct extends at {
658
+ class ht extends ct {
663
659
  constructor(t, s, n) {
664
660
  super(t), c(this, "supports"), this.supports = $t(s, n);
665
661
  }
666
662
  }
667
- class De extends ct {
663
+ class Ne extends ht {
668
664
  constructor(t, s, n) {
669
665
  super({ isVisible: t }, s, {
670
666
  show: "web_app_setup_back_button",
671
667
  hide: "web_app_setup_back_button"
672
- }), c(this, "on", (r, i) => r === "click" ? E("back_button_pressed", i) : this.state.on(r, i)), c(this, "off", (r, i) => r === "click" ? z("back_button_pressed", i) : this.state.off(r, i)), this.postEvent = n;
668
+ }), c(this, "on", (r, i) => r === "click" ? y("back_button_pressed", i) : this.state.on(r, i)), c(this, "off", (r, i) => r === "click" ? z("back_button_pressed", i) : this.state.off(r, i)), this.postEvent = n;
673
669
  }
674
670
  set isVisible(t) {
675
671
  this.set("isVisible", t), this.postEvent("web_app_setup_back_button", { is_visible: t });
@@ -693,8 +689,8 @@ class De extends ct {
693
689
  this.isVisible = !0;
694
690
  }
695
691
  }
696
- const Lt = A((e) => e instanceof Date ? e : new Date(x().parse(e) * 1e3), "Date");
697
- function ht(e, t) {
692
+ const Lt = A((e) => e instanceof Date ? e : new Date(R().parse(e) * 1e3), "Date");
693
+ function pt(e, t) {
698
694
  return new G((s) => {
699
695
  if (typeof s != "string" && !(s instanceof URLSearchParams))
700
696
  throw T();
@@ -705,81 +701,81 @@ function ht(e, t) {
705
701
  });
706
702
  }, !1, t);
707
703
  }
708
- const Ne = w({
709
- id: x(),
710
- type: p(),
711
- title: p(),
704
+ const De = w({
705
+ id: R(),
706
+ type: h(),
707
+ title: h(),
712
708
  photoUrl: {
713
- type: p().optional(),
709
+ type: h().optional(),
714
710
  from: "photo_url"
715
711
  },
716
- username: p().optional()
717
- }, "Chat").optional(), mt = w({
712
+ username: h().optional()
713
+ }, "Chat").optional(), bt = w({
718
714
  addedToAttachmentMenu: {
719
- type: P().optional(),
715
+ type: E().optional(),
720
716
  from: "added_to_attachment_menu"
721
717
  },
722
718
  allowsWriteToPm: {
723
- type: P().optional(),
719
+ type: E().optional(),
724
720
  from: "allows_write_to_pm"
725
721
  },
726
722
  firstName: {
727
- type: p(),
723
+ type: h(),
728
724
  from: "first_name"
729
725
  },
730
- id: x(),
726
+ id: R(),
731
727
  isBot: {
732
- type: P().optional(),
728
+ type: E().optional(),
733
729
  from: "is_bot"
734
730
  },
735
731
  isPremium: {
736
- type: P().optional(),
732
+ type: E().optional(),
737
733
  from: "is_premium"
738
734
  },
739
735
  languageCode: {
740
- type: p().optional(),
736
+ type: h().optional(),
741
737
  from: "language_code"
742
738
  },
743
739
  lastName: {
744
- type: p().optional(),
740
+ type: h().optional(),
745
741
  from: "last_name"
746
742
  },
747
743
  photoUrl: {
748
- type: p().optional(),
744
+ type: h().optional(),
749
745
  from: "photo_url"
750
746
  },
751
- username: p().optional()
747
+ username: h().optional()
752
748
  }, "User").optional();
753
749
  function Ht() {
754
- return ht({
750
+ return pt({
755
751
  authDate: {
756
752
  type: Lt(),
757
753
  from: "auth_date"
758
754
  },
759
755
  canSendAfter: {
760
- type: x().optional(),
756
+ type: R().optional(),
761
757
  from: "can_send_after"
762
758
  },
763
- chat: Ne,
759
+ chat: De,
764
760
  chatInstance: {
765
- type: p().optional(),
761
+ type: h().optional(),
766
762
  from: "chat_instance"
767
763
  },
768
764
  chatType: {
769
- type: p().optional(),
765
+ type: h().optional(),
770
766
  from: "chat_type"
771
767
  },
772
- hash: p(),
768
+ hash: h(),
773
769
  queryId: {
774
- type: p().optional(),
770
+ type: h().optional(),
775
771
  from: "query_id"
776
772
  },
777
- receiver: mt,
773
+ receiver: bt,
778
774
  startParam: {
779
- type: p().optional(),
775
+ type: h().optional(),
780
776
  from: "start_param"
781
777
  },
782
- user: mt
778
+ user: bt
783
779
  }, "InitData");
784
780
  }
785
781
  function Be(e) {
@@ -791,14 +787,14 @@ function Me(e) {
791
787
  const Ut = A(
792
788
  (e) => {
793
789
  const t = It().optional();
794
- return Object.entries(rt(e)).reduce((s, [n, r]) => (s[Be(n)] = t.parse(r), s), {});
790
+ return Object.entries(it(e)).reduce((s, [n, r]) => (s[Be(n)] = t.parse(r), s), {});
795
791
  },
796
792
  "ThemeParams"
797
793
  );
798
- function pt(e) {
799
- return ht({
794
+ function ut(e) {
795
+ return pt({
800
796
  botInline: {
801
- type: P().optional(),
797
+ type: E().optional(),
802
798
  from: "tgWebAppBotInline"
803
799
  },
804
800
  initData: {
@@ -806,19 +802,19 @@ function pt(e) {
806
802
  from: "tgWebAppData"
807
803
  },
808
804
  initDataRaw: {
809
- type: p().optional(),
805
+ type: h().optional(),
810
806
  from: "tgWebAppData"
811
807
  },
812
808
  platform: {
813
- type: p(),
809
+ type: h(),
814
810
  from: "tgWebAppPlatform"
815
811
  },
816
812
  showSettings: {
817
- type: P().optional(),
813
+ type: E().optional(),
818
814
  from: "tgWebAppShowSettings"
819
815
  },
820
816
  startParam: {
821
- type: p().optional(),
817
+ type: h().optional(),
822
818
  from: "tgWebAppStartParam"
823
819
  },
824
820
  themeParams: {
@@ -826,13 +822,13 @@ function pt(e) {
826
822
  from: "tgWebAppThemeParams"
827
823
  },
828
824
  version: {
829
- type: p(),
825
+ type: h(),
830
826
  from: "tgWebAppVersion"
831
827
  }
832
828
  }).parse(e);
833
829
  }
834
830
  function Wt(e) {
835
- return pt(
831
+ return ut(
836
832
  e.replace(/^[^?#]*[?#]/, "").replace(/[?#]/g, "&")
837
833
  );
838
834
  }
@@ -862,7 +858,7 @@ function Kt(e) {
862
858
  }
863
859
  }
864
860
  function Le() {
865
- return pt(Kt("launchParams") || "");
861
+ return ut(Kt("launchParams") || "");
866
862
  }
867
863
  function Jt(e) {
868
864
  return JSON.stringify(
@@ -878,10 +874,10 @@ function He(e) {
878
874
  platform: n,
879
875
  version: r,
880
876
  showSettings: i,
881
- startParam: o,
882
- botInline: a
883
- } = e, u = new URLSearchParams();
884
- return u.set("tgWebAppPlatform", n), u.set("tgWebAppThemeParams", Jt(s)), u.set("tgWebAppVersion", r), t && u.set("tgWebAppData", t), o && u.set("tgWebAppStartParam", o), typeof i == "boolean" && u.set("tgWebAppShowSettings", i ? "1" : "0"), typeof a == "boolean" && u.set("tgWebAppBotInline", a ? "1" : "0"), u.toString();
877
+ startParam: a,
878
+ botInline: o
879
+ } = e, p = new URLSearchParams();
880
+ return p.set("tgWebAppPlatform", n), p.set("tgWebAppThemeParams", Jt(s)), p.set("tgWebAppVersion", r), t && p.set("tgWebAppData", t), a && p.set("tgWebAppStartParam", a), typeof i == "boolean" && p.set("tgWebAppShowSettings", i ? "1" : "0"), typeof o == "boolean" && p.set("tgWebAppBotInline", o ? "1" : "0"), p.toString();
885
881
  }
886
882
  function Ft(e) {
887
883
  zt("launchParams", He(e));
@@ -911,7 +907,7 @@ function Ue() {
911
907
  let e = 0;
912
908
  return () => (e += 1).toString();
913
909
  }
914
- const [We] = Rt(Ue);
910
+ const [We] = xt(Ue);
915
911
  function l(e, t) {
916
912
  return () => {
917
913
  const s = Qt(), n = {
@@ -921,20 +917,20 @@ function l(e, t) {
921
917
  };
922
918
  if (typeof e == "function")
923
919
  return e(n);
924
- const [r, i, o] = Ct(), a = t({
920
+ const [r, i, a] = rt(), o = t({
925
921
  ...n,
926
922
  // State should only be passed only in case, current page was reloaded. If we don't add
927
923
  // this check, state restoration will work improperly in the web version of Telegram,
928
924
  // when we are always working in the same "session" (tab).
929
925
  state: Yt() ? Kt(e) : void 0,
930
926
  addCleanup: r
931
- }), u = (h) => (o || r(
932
- h.on("change", (v) => {
933
- zt(e, v);
927
+ }), p = (u) => (a || r(
928
+ u.on("change", (C) => {
929
+ zt(e, C);
934
930
  })
935
- ), h);
931
+ ), u);
936
932
  return [
937
- a instanceof Promise ? a.then(u) : u(a),
933
+ o instanceof Promise ? o.then(p) : p(o),
938
934
  i
939
935
  ];
940
936
  };
@@ -943,8 +939,8 @@ const Ge = l("backButton", ({
943
939
  postEvent: e,
944
940
  version: t,
945
941
  state: s = { isVisible: !1 }
946
- }) => new De(s.isVisible, t, e));
947
- class $ extends ct {
942
+ }) => new Ne(s.isVisible, t, e));
943
+ class $ extends ht {
948
944
  constructor() {
949
945
  super(...arguments), c(this, "on", this.state.on.bind(this.state)), c(this, "off", this.state.off.bind(this.state));
950
946
  }
@@ -1089,7 +1085,7 @@ async function ze(e) {
1089
1085
  const Ke = l(
1090
1086
  "biometryManager",
1091
1087
  async ({ postEvent: e, version: t, state: s }) => new je({
1092
- ...s || C("web_app_biometry_get_info", t) ? s || await ze({ timeout: 1e3 }) : {
1088
+ ...s || x("web_app_biometry_get_info", t) ? s || await ze({ timeout: 1e3 }) : {
1093
1089
  available: !1,
1094
1090
  accessGranted: !1,
1095
1091
  accessRequested: !1,
@@ -1100,12 +1096,12 @@ const Ke = l(
1100
1096
  postEvent: e
1101
1097
  })
1102
1098
  );
1103
- class ut extends at {
1099
+ class lt extends ct {
1104
1100
  constructor() {
1105
1101
  super(...arguments), c(this, "on", this.state.on.bind(this.state)), c(this, "off", this.state.off.bind(this.state));
1106
1102
  }
1107
1103
  }
1108
- class Je extends ut {
1104
+ class Je extends lt {
1109
1105
  constructor(t, s) {
1110
1106
  super({ isConfirmationNeeded: t }), this.postEvent = s;
1111
1107
  }
@@ -1139,7 +1135,7 @@ const Fe = l(
1139
1135
  state: t = { isConfirmationNeeded: !1 }
1140
1136
  }) => new Je(t.isConfirmationNeeded, e)
1141
1137
  );
1142
- class lt {
1138
+ class dt {
1143
1139
  constructor(t, s) {
1144
1140
  c(this, "supports"), this.supports = $t(t, s);
1145
1141
  }
@@ -1177,10 +1173,10 @@ class Ye extends G {
1177
1173
  function Ze(e) {
1178
1174
  return new Ye((t) => t, !1, e);
1179
1175
  }
1180
- function bt(e, t) {
1176
+ function vt(e, t) {
1181
1177
  return Object.fromEntries(e.map((s) => [s, t]));
1182
1178
  }
1183
- class Xe extends lt {
1179
+ class Xe extends dt {
1184
1180
  constructor(t, s, n) {
1185
1181
  super(t, {
1186
1182
  delete: "web_app_invoke_custom_method",
@@ -1208,7 +1204,7 @@ class Xe extends lt {
1208
1204
  * @param options - request execution options.
1209
1205
  */
1210
1206
  async getKeys(t = {}) {
1211
- return Ze().of(p()).parse(
1207
+ return Ze().of(h()).parse(
1212
1208
  await O(
1213
1209
  "getStorageKeys",
1214
1210
  {},
@@ -1220,13 +1216,13 @@ class Xe extends lt {
1220
1216
  async get(t, s = {}) {
1221
1217
  const n = Array.isArray(t) ? t : [t];
1222
1218
  if (!n.length)
1223
- return bt(n, "");
1219
+ return vt(n, "");
1224
1220
  const r = await O(
1225
1221
  "getStorageValues",
1226
1222
  { keys: n },
1227
1223
  this.createRequestId(),
1228
1224
  { ...s, postEvent: this.postEvent }
1229
- ), i = w(bt(n, p()), "CloudStorageData").parse(r);
1225
+ ), i = w(vt(n, h()), "CloudStorageData").parse(r);
1230
1226
  return Array.isArray(t) ? i : i[t];
1231
1227
  }
1232
1228
  /**
@@ -1247,7 +1243,7 @@ class Xe extends lt {
1247
1243
  const ts = l(
1248
1244
  ({ createRequestId: e, postEvent: t, version: s }) => new Xe(s, e, t)
1249
1245
  );
1250
- class es extends lt {
1246
+ class es extends dt {
1251
1247
  constructor(t, s) {
1252
1248
  super(t, {
1253
1249
  impactOccurred: "web_app_trigger_haptic_feedback",
@@ -1394,10 +1390,10 @@ class is extends $ {
1394
1390
  const { hostname: r, pathname: i } = new URL(t, window.location.href);
1395
1391
  if (r !== "t.me")
1396
1392
  throw new Error(`Incorrect hostname: ${r}`);
1397
- const o = i.match(/^\/(\$|invoice\/)([A-Za-z0-9\-_=]+)$/);
1398
- if (!o)
1393
+ const a = i.match(/^\/(\$|invoice\/)([A-Za-z0-9\-_=]+)$/);
1394
+ if (!a)
1399
1395
  throw new Error('Link pathname has incorrect format. Expected to receive "/invoice/{slug}" or "/${slug}"');
1400
- [, , n] = o;
1396
+ [, , n] = a;
1401
1397
  }
1402
1398
  this.isOpened = !0;
1403
1399
  try {
@@ -1418,9 +1414,9 @@ class is extends $ {
1418
1414
  const os = l(
1419
1415
  ({ version: e, postEvent: t }) => new is(!1, e, t)
1420
1416
  );
1421
- class as extends at {
1417
+ class as extends ct {
1422
1418
  constructor({ postEvent: t, ...s }) {
1423
- super(s), c(this, "postEvent"), c(this, "on", (n, r) => n === "click" ? E("main_button_pressed", r) : this.state.on(n, r)), c(this, "off", (n, r) => n === "click" ? z("main_button_pressed", r) : this.state.off(n, r)), this.postEvent = t;
1419
+ super(s), c(this, "postEvent"), c(this, "on", (n, r) => n === "click" ? y("main_button_pressed", r) : this.state.on(n, r)), c(this, "off", (n, r) => n === "click" ? z("main_button_pressed", r) : this.state.off(n, r)), this.postEvent = t;
1424
1420
  }
1425
1421
  /**
1426
1422
  * The MainButton background color.
@@ -1565,22 +1561,22 @@ const cs = l(
1565
1561
  }) => new as({ ...s, postEvent: e })
1566
1562
  );
1567
1563
  function hs() {
1568
- return ht({
1564
+ return pt({
1569
1565
  contact: w({
1570
1566
  userId: {
1571
- type: x(),
1567
+ type: R(),
1572
1568
  from: "user_id"
1573
1569
  },
1574
1570
  phoneNumber: {
1575
- type: p(),
1571
+ type: h(),
1576
1572
  from: "phone_number"
1577
1573
  },
1578
1574
  firstName: {
1579
- type: p(),
1575
+ type: h(),
1580
1576
  from: "first_name"
1581
1577
  },
1582
1578
  lastName: {
1583
- type: p().optional(),
1579
+ type: h().optional(),
1584
1580
  from: "last_name"
1585
1581
  }
1586
1582
  }),
@@ -1588,13 +1584,13 @@ function hs() {
1588
1584
  type: Lt(),
1589
1585
  from: "auth_date"
1590
1586
  },
1591
- hash: p()
1587
+ hash: h()
1592
1588
  }, "RequestedContact");
1593
1589
  }
1594
1590
  function Xt(e, t) {
1595
1591
  return (s) => {
1596
1592
  const [n, r] = t[s];
1597
- return C(n, r, e);
1593
+ return x(n, r, e);
1598
1594
  };
1599
1595
  }
1600
1596
  function ps(e) {
@@ -1611,8 +1607,8 @@ class us extends $ {
1611
1607
  setHeaderColor: "web_app_set_header_color",
1612
1608
  setBackgroundColor: "web_app_set_background_color"
1613
1609
  }), c(this, "botInline"), c(this, "postEvent"), c(this, "createRequestId"), c(this, "requestPhoneAccessPromise"), c(this, "requestWriteAccessPromise"), c(this, "supportsParam"), this.createRequestId = s, this.postEvent = t, this.botInline = r;
1614
- const o = this.supports.bind(this);
1615
- this.supports = (a) => o(a) ? a !== "switchInlineQuery" || r : !1, this.supportsParam = Xt(n, {
1610
+ const a = this.supports.bind(this);
1611
+ this.supports = (o) => a(o) ? o !== "switchInlineQuery" || r : !1, this.supportsParam = Xt(n, {
1616
1612
  "setHeaderColor.color": ["web_app_set_header_color", "color"]
1617
1613
  });
1618
1614
  }
@@ -1755,7 +1751,7 @@ class us extends $ {
1755
1751
  * @param color - color key or RGB color.
1756
1752
  */
1757
1753
  setHeaderColor(t) {
1758
- this.postEvent("web_app_set_header_color", it(t) ? { color: t } : { color_key: t }), this.set("headerColor", t);
1754
+ this.postEvent("web_app_set_header_color", ot(t) ? { color: t } : { color_key: t }), this.set("headerColor", t);
1759
1755
  }
1760
1756
  /**
1761
1757
  * Updates current Mini App background color.
@@ -1805,18 +1801,18 @@ function ds(e) {
1805
1801
  if (n.length > 3)
1806
1802
  throw new Error(`Buttons have incorrect size: ${n.length}`);
1807
1803
  return n.length ? r = n.map((i) => {
1808
- const { id: o = "" } = i;
1809
- if (o.length > 64)
1810
- throw new Error(`Button ID has incorrect size: ${o}`);
1804
+ const { id: a = "" } = i;
1805
+ if (a.length > 64)
1806
+ throw new Error(`Button ID has incorrect size: ${a}`);
1811
1807
  if (!i.type || i.type === "default" || i.type === "destructive") {
1812
- const a = i.text.trim();
1813
- if (!a.length || a.length > 64) {
1814
- const u = i.type || "default";
1815
- throw new Error(`Button text with type "${u}" has incorrect size: ${i.text.length}`);
1808
+ const o = i.text.trim();
1809
+ if (!o.length || o.length > 64) {
1810
+ const p = i.type || "default";
1811
+ throw new Error(`Button text with type "${p}" has incorrect size: ${i.text.length}`);
1816
1812
  }
1817
- return { ...i, text: a, id: o };
1813
+ return { ...i, text: o, id: a };
1818
1814
  }
1819
- return { ...i, id: o };
1815
+ return { ...i, id: a };
1820
1816
  }) : r = [{ type: "close", id: "" }], { title: s, message: t, buttons: r };
1821
1817
  }
1822
1818
  class _s extends $ {
@@ -1885,37 +1881,36 @@ class gs extends $ {
1885
1881
  get isOpened() {
1886
1882
  return this.get("isOpened");
1887
1883
  }
1888
- /**
1889
- * Opens scanner with specified title shown to user. Method returns promise
1890
- * with scanned QR content in case, it was scanned. It will contain null in
1891
- * case, scanner was closed.
1892
- * @param text - title to display.
1893
- */
1894
1884
  async open(t) {
1895
1885
  if (this.isOpened)
1896
1886
  throw new Error("QR scanner is already opened.");
1887
+ const { text: s, capture: n } = (typeof t == "string" ? { text: t } : t) || {};
1897
1888
  this.isOpened = !0;
1898
1889
  try {
1899
- return (await g({
1890
+ const r = (await g({
1900
1891
  method: "web_app_open_scan_qr_popup",
1901
1892
  event: ["qr_text_received", "scan_qr_popup_closed"],
1902
1893
  postEvent: this.postEvent,
1903
- params: { text: t }
1894
+ params: { text: s },
1895
+ capture(i) {
1896
+ return i.event === "scan_qr_popup_closed" || !n || n(i.payload);
1897
+ }
1904
1898
  }) || {}).data || null;
1905
- } finally {
1906
- this.isOpened = !1;
1899
+ return r && this.close(), r;
1900
+ } catch (r) {
1901
+ throw this.isOpened = !1, r;
1907
1902
  }
1908
1903
  }
1909
1904
  }
1910
1905
  const fs = l(
1911
1906
  ({ version: e, postEvent: t }) => new gs(!1, e, t)
1912
1907
  );
1913
- class ms extends ct {
1908
+ class ms extends ht {
1914
1909
  constructor(t, s, n) {
1915
1910
  super({ isVisible: t }, s, {
1916
1911
  show: "web_app_setup_settings_button",
1917
1912
  hide: "web_app_setup_settings_button"
1918
- }), c(this, "on", (r, i) => r === "click" ? E("settings_button_pressed", i) : this.state.on(r, i)), c(this, "off", (r, i) => r === "click" ? z("settings_button_pressed", i) : this.state.off(r, i)), this.postEvent = n;
1913
+ }), c(this, "on", (r, i) => r === "click" ? y("settings_button_pressed", i) : this.state.on(r, i)), c(this, "off", (r, i) => r === "click" ? z("settings_button_pressed", i) : this.state.off(r, i)), this.postEvent = n;
1919
1914
  }
1920
1915
  set isVisible(t) {
1921
1916
  this.set("isVisible", t), this.postEvent("web_app_setup_settings_button", { is_visible: t });
@@ -1950,7 +1945,7 @@ const bs = l(
1950
1945
  function te(e) {
1951
1946
  return Ut().parse(e);
1952
1947
  }
1953
- class vs extends ut {
1948
+ class vs extends lt {
1954
1949
  /**
1955
1950
  * @since v6.10
1956
1951
  */
@@ -2014,7 +2009,7 @@ class vs extends ut {
2014
2009
  * @returns Function to stop listening.
2015
2010
  */
2016
2011
  listen() {
2017
- return E("theme_changed", (t) => {
2012
+ return y("theme_changed", (t) => {
2018
2013
  this.set(te(t.theme_params));
2019
2014
  });
2020
2015
  }
@@ -2042,7 +2037,7 @@ function mn(e = {}) {
2042
2037
  event: "theme_changed"
2043
2038
  }).then(te);
2044
2039
  }
2045
- class Es extends lt {
2040
+ class Es extends dt {
2046
2041
  constructor(t, s, n) {
2047
2042
  super(t, { readTextFromClipboard: "web_app_read_text_from_clipboard" }), c(this, "supportsParam"), this.version = t, this.createRequestId = s, this.postEvent = n, this.supportsParam = Xt(t, {
2048
2043
  "openLink.tryInstantView": ["web_app_open_link", "try_instant_view"]
@@ -2059,7 +2054,7 @@ class Es extends lt {
2059
2054
  */
2060
2055
  openLink(t, s) {
2061
2056
  const n = new URL(t, window.location.href).toString();
2062
- if (!C("web_app_open_link", this.version)) {
2057
+ if (!x("web_app_open_link", this.version)) {
2063
2058
  window.open(n, "_blank");
2064
2059
  return;
2065
2060
  }
@@ -2078,7 +2073,7 @@ class Es extends lt {
2078
2073
  const { hostname: s, pathname: n, search: r } = new URL(t, window.location.href);
2079
2074
  if (s !== "t.me")
2080
2075
  throw new Error(`URL has not allowed hostname: ${s}. Only "t.me" is allowed`);
2081
- if (!C("web_app_open_tg_link", this.version)) {
2076
+ if (!x("web_app_open_tg_link", this.version)) {
2082
2077
  window.location.href = t;
2083
2078
  return;
2084
2079
  }
@@ -2098,7 +2093,7 @@ class Es extends lt {
2098
2093
  event: "clipboard_text_received",
2099
2094
  postEvent: this.postEvent,
2100
2095
  params: { req_id: t },
2101
- capture: Nt(t)
2096
+ capture: Dt(t)
2102
2097
  });
2103
2098
  return s;
2104
2099
  }
@@ -2121,7 +2116,7 @@ async function ee(e = {}) {
2121
2116
  function q(e) {
2122
2117
  return e < 0 ? 0 : e;
2123
2118
  }
2124
- class Rs extends ut {
2119
+ class Rs extends lt {
2125
2120
  constructor({ postEvent: t, stableHeight: s, height: n, width: r, isExpanded: i }) {
2126
2121
  super({
2127
2122
  height: q(n),
@@ -2183,18 +2178,18 @@ class Rs extends ut {
2183
2178
  * @returns Function to stop listening.
2184
2179
  */
2185
2180
  listen() {
2186
- return E("viewport_changed", (t) => {
2181
+ return y("viewport_changed", (t) => {
2187
2182
  const {
2188
2183
  height: s,
2189
2184
  width: n,
2190
2185
  is_expanded: r,
2191
2186
  is_state_stable: i
2192
- } = t, o = q(s);
2187
+ } = t, a = q(s);
2193
2188
  this.set({
2194
- height: o,
2189
+ height: a,
2195
2190
  isExpanded: r,
2196
2191
  width: q(n),
2197
- ...i ? { stableHeight: o } : {}
2192
+ ...i ? { stableHeight: a } : {}
2198
2193
  });
2199
2194
  });
2200
2195
  }
@@ -2231,77 +2226,77 @@ class Rs extends ut {
2231
2226
  const xs = l(
2232
2227
  "viewport",
2233
2228
  async ({ state: e, platform: t, postEvent: s, addCleanup: n }) => {
2234
- let r = !1, i = 0, o = 0, a = 0;
2229
+ let r = !1, i = 0, a = 0, o = 0;
2235
2230
  if (e)
2236
- r = e.isExpanded, i = e.height, o = e.width, a = e.stableHeight;
2231
+ r = e.isExpanded, i = e.height, a = e.width, o = e.stableHeight;
2237
2232
  else if (["macos", "tdesktop", "unigram", "webk", "weba", "web"].includes(t))
2238
- r = !0, i = window.innerHeight, o = window.innerWidth, a = window.innerHeight;
2233
+ r = !0, i = window.innerHeight, a = window.innerWidth, o = window.innerHeight;
2239
2234
  else {
2240
- const h = await ee({ timeout: 1e3, postEvent: s });
2241
- r = h.isExpanded, i = h.height, o = h.width, a = h.isStateStable ? i : 0;
2235
+ const u = await ee({ timeout: 1e3, postEvent: s });
2236
+ r = u.isExpanded, i = u.height, a = u.width, o = u.isStateStable ? i : 0;
2242
2237
  }
2243
- const u = new Rs({
2238
+ const p = new Rs({
2244
2239
  postEvent: s,
2245
2240
  height: i,
2246
- width: o,
2247
- stableHeight: a,
2241
+ width: a,
2242
+ stableHeight: o,
2248
2243
  isExpanded: r
2249
2244
  });
2250
- return n(u.listen()), u;
2245
+ return n(p.listen()), p;
2251
2246
  }
2252
2247
  );
2253
- function R(e, t) {
2248
+ function P(e, t) {
2254
2249
  document.documentElement.style.setProperty(e, t);
2255
2250
  }
2256
2251
  function bn(e, t, s) {
2257
- s || (s = (a) => `--tg-${a}-color`);
2252
+ s || (s = (o) => `--tg-${o}-color`);
2258
2253
  const n = s("header"), r = s("bg"), i = () => {
2259
- const { headerColor: a } = e;
2260
- if (it(a))
2261
- R(n, a);
2254
+ const { headerColor: o } = e;
2255
+ if (ot(o))
2256
+ P(n, o);
2262
2257
  else {
2263
- const { bgColor: u, secondaryBgColor: h } = t;
2264
- a === "bg_color" && u ? R(n, u) : a === "secondary_bg_color" && h && R(n, h);
2258
+ const { bgColor: p, secondaryBgColor: u } = t;
2259
+ o === "bg_color" && p ? P(n, p) : o === "secondary_bg_color" && u && P(n, u);
2265
2260
  }
2266
- R(r, e.bgColor);
2267
- }, o = [
2261
+ P(r, e.bgColor);
2262
+ }, a = [
2268
2263
  t.on("change", i),
2269
2264
  e.on("change", i)
2270
2265
  ];
2271
- return i(), () => o.forEach((a) => a());
2266
+ return i(), () => a.forEach((o) => o());
2272
2267
  }
2273
2268
  function vn(e, t) {
2274
2269
  t || (t = (n) => `--tg-theme-${n.replace(/[A-Z]/g, (r) => `-${r.toLowerCase()}`)}`);
2275
2270
  const s = () => {
2276
2271
  Object.entries(e.getState()).forEach(([n, r]) => {
2277
- r && R(t(n), r);
2272
+ r && P(t(n), r);
2278
2273
  });
2279
2274
  };
2280
2275
  return s(), e.on("change", s);
2281
2276
  }
2282
2277
  function yn(e, t) {
2283
- t || (t = (h) => `--tg-viewport-${h}`);
2278
+ t || (t = (u) => `--tg-viewport-${u}`);
2284
2279
  const [
2285
2280
  s,
2286
2281
  n,
2287
2282
  r
2288
- ] = ["height", "width", "stable-height"].map((h) => t(h)), i = () => R(s, `${e.height}px`), o = () => R(n, `${e.width}px`), a = () => R(r, `${e.stableHeight}px`), u = [
2283
+ ] = ["height", "width", "stable-height"].map((u) => t(u)), i = () => P(s, `${e.height}px`), a = () => P(n, `${e.width}px`), o = () => P(r, `${e.stableHeight}px`), p = [
2289
2284
  e.on("change:height", i),
2290
- e.on("change:width", o),
2291
- e.on("change:stableHeight", a)
2285
+ e.on("change:width", a),
2286
+ e.on("change:stableHeight", o)
2292
2287
  ];
2293
- return i(), o(), a(), () => u.forEach((h) => h());
2288
+ return i(), a(), o(), () => p.forEach((u) => u());
2294
2289
  }
2295
2290
  function Cs(e = !0) {
2296
2291
  const t = [
2297
- E("reload_iframe", () => {
2292
+ y("reload_iframe", () => {
2298
2293
  B("iframe_will_reload"), window.location.reload();
2299
2294
  })
2300
2295
  ], s = () => t.forEach((n) => n());
2301
2296
  if (e) {
2302
2297
  const n = document.createElement("style");
2303
2298
  n.id = "telegram-custom-styles", document.head.appendChild(n), t.push(
2304
- E("set_custom_style", (r) => {
2299
+ y("set_custom_style", (r) => {
2305
2300
  n.innerHTML = r;
2306
2301
  }),
2307
2302
  () => document.head.removeChild(n)
@@ -2322,7 +2317,7 @@ async function En() {
2322
2317
  }
2323
2318
  }
2324
2319
  function Pn(e) {
2325
- const t = typeof e == "string" ? pt(e) : e;
2320
+ const t = typeof e == "string" ? ut(e) : e;
2326
2321
  Ft(t);
2327
2322
  function s(r) {
2328
2323
  if (typeof r == "string")
@@ -2339,7 +2334,7 @@ function Pn(e) {
2339
2334
  } catch {
2340
2335
  }
2341
2336
  }
2342
- if (ot()) {
2337
+ if (at()) {
2343
2338
  const r = window.parent.postMessage.bind(window.parent);
2344
2339
  window.parent.postMessage = (i) => {
2345
2340
  s(i), r(i);
@@ -2377,7 +2372,7 @@ function J(e, t) {
2377
2372
  }
2378
2373
  class As {
2379
2374
  constructor(t, s, n = B) {
2380
- if (c(this, "history"), c(this, "ee", new N()), c(this, "attached", !1), c(this, "back", () => this.go(-1)), c(this, "on", this.ee.on.bind(this.ee)), c(this, "off", this.ee.off.bind(this.ee)), this._index = s, this.postEvent = n, t.length === 0)
2375
+ if (c(this, "history"), c(this, "ee", new D()), c(this, "attached", !1), c(this, "back", () => this.go(-1)), c(this, "on", this.ee.on.bind(this.ee)), c(this, "off", this.ee.off.bind(this.ee)), this._index = s, this.postEvent = n, t.length === 0)
2381
2376
  throw m(ve, "History should not be empty.");
2382
2377
  if (s < 0 || s >= t.length)
2383
2378
  throw m(
@@ -2391,7 +2386,7 @@ class As {
2391
2386
  * `BackButton` clicks and calls the `back` method.
2392
2387
  */
2393
2388
  attach() {
2394
- this.attached || (this.attached = !0, this.sync(), E("back_button_pressed", this.back));
2389
+ this.attached || (this.attached = !0, this.sync(), y("back_button_pressed", this.back));
2395
2390
  }
2396
2391
  /**
2397
2392
  * Currently active history item.
@@ -2518,10 +2513,10 @@ function U(e) {
2518
2513
  function Q(e, t, s) {
2519
2514
  let n, r;
2520
2515
  typeof e == "string" ? n = e : (n = U(e), s = e.state, r = e.id);
2521
- const { pathname: i, search: o, hash: a } = new URL(n, `http://a${M(t, "/")}`);
2522
- return { id: r, pathname: i, params: { hash: a, search: o, state: s } };
2516
+ const { pathname: i, search: a, hash: o } = new URL(n, `http://a${M(t, "/")}`);
2517
+ return { id: r, pathname: i, params: { hash: o, search: a, state: s } };
2523
2518
  }
2524
- async function D(e) {
2519
+ async function N(e) {
2525
2520
  return e === 0 ? !0 : Promise.race([
2526
2521
  new Promise((t) => {
2527
2522
  const s = tt("popstate", () => {
@@ -2536,35 +2531,35 @@ async function D(e) {
2536
2531
  ]);
2537
2532
  }
2538
2533
  async function Is() {
2539
- if (window.history.length <= 1 || (window.history.pushState(null, ""), await D(1 - window.history.length)))
2534
+ if (window.history.length <= 1 || (window.history.pushState(null, ""), await N(1 - window.history.length)))
2540
2535
  return;
2541
- let e = await D(-1);
2536
+ let e = await N(-1);
2542
2537
  for (; e; )
2543
- e = await D(-1);
2538
+ e = await N(-1);
2544
2539
  }
2545
2540
  function se(e) {
2546
2541
  return H(e).pathname;
2547
2542
  }
2548
- const vt = 0, Y = 1, Z = 2;
2543
+ const yt = 0, Y = 1, Z = 2;
2549
2544
  class ne {
2550
2545
  constructor(t, s, { postEvent: n, hashMode: r = "classic", base: i } = {}) {
2551
- c(this, "navigator"), c(this, "ee", new N()), c(this, "hashMode"), c(this, "base"), c(this, "attached", !1), c(this, "onPopState", ({ state: o }) => {
2552
- if (o === null)
2546
+ c(this, "navigator"), c(this, "ee", new D()), c(this, "hashMode"), c(this, "base"), c(this, "attached", !1), c(this, "onPopState", ({ state: a }) => {
2547
+ if (a === null)
2553
2548
  return this.push(this.parsePath(window.location.href));
2554
- o === vt ? window.history.forward() : o === Y && this.back(), o === Z && this.forward();
2549
+ a === yt ? window.history.forward() : a === Y && this.back(), a === Z && this.forward();
2555
2550
  }), c(this, "onNavigatorChange", async ({
2556
- to: o,
2557
- from: a,
2558
- delta: u
2551
+ to: a,
2552
+ from: o,
2553
+ delta: p
2559
2554
  }) => {
2560
2555
  this.attached && await this.syncHistory(), this.ee.emit("change", {
2561
- delta: u,
2562
- from: F(a),
2563
- to: F(o),
2556
+ delta: p,
2557
+ from: F(o),
2558
+ to: F(a),
2564
2559
  navigator: this
2565
2560
  });
2566
2561
  }), c(this, "on", this.ee.on.bind(this.ee)), c(this, "off", this.ee.off.bind(this.ee)), this.navigator = new As(
2567
- t.map((o) => Q(o, "/")),
2562
+ t.map((a) => Q(a, "/")),
2568
2563
  s,
2569
2564
  n
2570
2565
  ), this.navigator.on("change", this.onNavigatorChange), this.hashMode = r, this.base = se(i || "");
@@ -2724,7 +2719,7 @@ class ne {
2724
2719
  async syncHistory() {
2725
2720
  window.removeEventListener("popstate", this.onPopState);
2726
2721
  const { state: t } = this, s = this.renderPath(this);
2727
- await Is(), this.hasPrev && this.hasNext ? (window.history.replaceState(Y, ""), window.history.pushState(t, "", s), window.history.pushState(Z, ""), await D(-1)) : this.hasPrev ? (window.history.replaceState(Y, ""), window.history.pushState(t, "", s)) : this.hasNext ? (window.history.replaceState(t, s), window.history.pushState(Z, ""), await D(-1)) : (window.history.replaceState(vt, ""), window.history.pushState(t, "", s)), window.addEventListener("popstate", this.onPopState);
2722
+ await Is(), this.hasPrev && this.hasNext ? (window.history.replaceState(Y, ""), window.history.pushState(t, "", s), window.history.pushState(Z, ""), await N(-1)) : this.hasPrev ? (window.history.replaceState(Y, ""), window.history.pushState(t, "", s)) : this.hasNext ? (window.history.replaceState(t, s), window.history.pushState(Z, ""), await N(-1)) : (window.history.replaceState(yt, ""), window.history.pushState(t, "", s)), window.addEventListener("popstate", this.onPopState);
2728
2723
  }
2729
2724
  /**
2730
2725
  * Current query parameters.
@@ -2785,13 +2780,13 @@ function Cn(e, t) {
2785
2780
  }
2786
2781
  function d(e, t) {
2787
2782
  function s(n) {
2788
- return function(i, o, a) {
2789
- return (u) => {
2790
- const h = {
2791
- ...u,
2792
- [i]: n(o)
2783
+ return function(i, a, o) {
2784
+ return (p) => {
2785
+ const u = {
2786
+ ...p,
2787
+ [i]: n(a)
2793
2788
  };
2794
- return /* @__PURE__ */ yt(a, { ...h });
2789
+ return /* @__PURE__ */ Et(o, { ...u });
2795
2790
  };
2796
2791
  };
2797
2792
  }
@@ -2806,7 +2801,7 @@ function Os() {
2806
2801
  }
2807
2802
  function _(e) {
2808
2803
  function t(n) {
2809
- const r = Os(), [i, o] = Et(
2804
+ const r = Os(), [i, a] = Pt(
2810
2805
  n ? void 0 : () => {
2811
2806
  if (Ss())
2812
2807
  throw new Error("Using hooks on the server side, you must explicitly specify ssr = true option");
@@ -2814,7 +2809,7 @@ function _(e) {
2814
2809
  }
2815
2810
  );
2816
2811
  return S(() => {
2817
- o(r.use(e));
2812
+ a(r.use(e));
2818
2813
  }, [r]), i;
2819
2814
  }
2820
2815
  function s(n) {
@@ -2827,19 +2822,19 @@ function _(e) {
2827
2822
  }
2828
2823
  return [t, s];
2829
2824
  }
2830
- const [Ds, Ns] = _(Ge), [Sn, Tn] = d(
2831
- Ds,
2832
- Ns
2825
+ const [Ns, Ds] = _(Ge), [Sn, Tn] = d(
2826
+ Ns,
2827
+ Ds
2833
2828
  ), [Bs, Ms] = _(Ke), [An, In] = d(
2834
2829
  Bs,
2835
2830
  Ms
2836
2831
  ), [Vs, $s] = _(Fe), [kn, qn] = d(
2837
2832
  Vs,
2838
2833
  $s
2839
- ), [Ls, Hs] = _(ts), [On, Dn] = d(
2834
+ ), [Ls, Hs] = _(ts), [On, Nn] = d(
2840
2835
  Ls,
2841
2836
  Hs
2842
- ), [Us, Ws] = _(ss), [Nn, Bn] = d(
2837
+ ), [Us, Ws] = _(ss), [Dn, Bn] = d(
2843
2838
  Us,
2844
2839
  Ws
2845
2840
  ), [Gs, js] = _(rs), [Mn, Vn] = d(Gs, js), [zs, Ks] = _(os), [$n, Ln] = d(zs, Ks), [Js, Fs] = _(cs), [Hn, Un] = d(Js, Fs), [Qs, Ys] = _(ls), [Wn, Gn] = d(Qs, Ys), [Zs, Xs] = _(ws), [jn, zn] = d(Zs, Xs), [tn, en] = _(fs), [Kn, Jn] = d(tn, en), [sn, nn] = _(bs), [Fn, Qn] = d(
@@ -2847,66 +2842,66 @@ const [Ds, Ns] = _(Ge), [Sn, Tn] = d(
2847
2842
  nn
2848
2843
  ), [rn, on] = _(ys), [Yn, Zn] = d(rn, on);
2849
2844
  function Xn() {
2850
- return Pt(Qt, []);
2845
+ return Rt(Qt, []);
2851
2846
  }
2852
2847
  const [an, cn] = _(Ps), [tr, er] = d(an, cn), [hn, pn] = _(xs), [sr, nr] = d(hn, pn);
2853
2848
  function rr({ children: e, acceptCustomStyles: t, debug: s }) {
2854
- const n = gt(!0), [r, i] = Et(/* @__PURE__ */ new Map()), o = gt(r), a = ae(
2855
- (h) => {
2856
- n.current && i((v) => (h && h(v), new Map(v)));
2849
+ const n = ft(!0), [r, i] = Pt(/* @__PURE__ */ new Map()), a = ft(r), o = ae(
2850
+ (u) => {
2851
+ n.current && i((C) => (u && u(C), new Map(C)));
2857
2852
  },
2858
2853
  []
2859
- ), u = Pt(() => ({
2860
- use(h, ...v) {
2861
- const dt = r.get(h);
2862
- if (dt)
2863
- return dt;
2854
+ ), p = Rt(() => ({
2855
+ use(u, ...C) {
2856
+ const _t = r.get(u);
2857
+ if (_t)
2858
+ return _t;
2864
2859
  let b, K;
2865
2860
  try {
2866
- b = h(...v);
2861
+ b = u(...C);
2867
2862
  } catch (f) {
2868
2863
  K = f;
2869
2864
  }
2870
2865
  function L(f) {
2871
- return r.set(h, f), f;
2866
+ return r.set(u, f), f;
2872
2867
  }
2873
2868
  if (K)
2874
2869
  return L({ error: K });
2875
2870
  let I;
2876
2871
  if (Array.isArray(b) && (I = b[1], b = b[0]), !b)
2877
2872
  return L({ result: b, cleanup: I });
2878
- function _t(f) {
2873
+ function wt(f) {
2879
2874
  if ("on" in f) {
2880
- const k = f.on("change", () => a()), wt = I;
2875
+ const k = f.on("change", () => o()), gt = I;
2881
2876
  I = () => {
2882
- wt && wt(), k();
2877
+ gt && gt(), k();
2883
2878
  };
2884
2879
  }
2885
2880
  return { result: f, cleanup: I };
2886
2881
  }
2887
2882
  return b instanceof Promise ? (b.then(
2888
- (f) => a((k) => k.set(h, _t(f))),
2889
- (f) => a((k) => k.set(h, { error: f }))
2890
- ), L({})) : L(_t(b));
2883
+ (f) => o((k) => k.set(u, wt(f))),
2884
+ (f) => o((k) => k.set(u, { error: f }))
2885
+ ), L({})) : L(wt(b));
2891
2886
  }
2892
2887
  }), [r]);
2893
2888
  return S(() => (n.current = !0, () => {
2894
2889
  n.current = !1;
2895
2890
  }), []), S(() => {
2896
- if (ot())
2891
+ if (at())
2897
2892
  return Cs(t);
2898
2893
  }, [t]), S(() => {
2899
2894
  le(s || !1);
2900
2895
  }, [s]), S(() => {
2901
- o.current = r;
2896
+ a.current = r;
2902
2897
  }, [r]), S(() => () => {
2903
- o.current.forEach((h) => {
2904
- "cleanup" in h && h.cleanup && h.cleanup();
2898
+ a.current.forEach((u) => {
2899
+ "cleanup" in u && u.cleanup && u.cleanup();
2905
2900
  });
2906
- }, []), /* @__PURE__ */ yt(re.Provider, { value: u, children: e });
2901
+ }, []), /* @__PURE__ */ Et(re.Provider, { value: p, children: e });
2907
2902
  }
2908
2903
  export {
2909
- De as BackButton,
2904
+ Ne as BackButton,
2910
2905
  As as BasicNavigator,
2911
2906
  je as BiometryManager,
2912
2907
  ne as BrowserNavigator,
@@ -2924,7 +2919,7 @@ export {
2924
2919
  me as ERR_TIMED_OUT,
2925
2920
  be as ERR_UNEXPECTED_TYPE,
2926
2921
  ge as ERR_UNKNOWN_ENV,
2927
- N as EventEmitter,
2922
+ D as EventEmitter,
2928
2923
  es as HapticFeedback,
2929
2924
  ns as InitData,
2930
2925
  is as Invoice,
@@ -2942,8 +2937,8 @@ export {
2942
2937
  bn as bindMiniAppCSSVars,
2943
2938
  vn as bindThemeParamsCSSVars,
2944
2939
  yn as bindViewportCSSVars,
2945
- P as boolean,
2946
- Nt as captureSameReq,
2940
+ E as boolean,
2941
+ Dt as captureSameReq,
2947
2942
  st as classNames,
2948
2943
  Ie as compareVersions,
2949
2944
  ks as createBrowserNavigatorFromLocation,
@@ -2971,9 +2966,9 @@ export {
2971
2966
  Cs as initWeb,
2972
2967
  O as invokeCustomMethod,
2973
2968
  Vt as isColorDark,
2974
- ot as isIframe,
2969
+ at as isIframe,
2975
2970
  Yt as isPageReload,
2976
- it as isRGB,
2971
+ ot as isRGB,
2977
2972
  Pe as isRGBShort,
2978
2973
  Ts as isSDKError,
2979
2974
  Rn as isSDKErrorOfType,
@@ -2982,11 +2977,11 @@ export {
2982
2977
  w as json,
2983
2978
  gn as mergeClassNames,
2984
2979
  Pn as mockTelegramEnv,
2985
- x as number,
2980
+ R as number,
2986
2981
  z as off,
2987
- E as on,
2982
+ y as on,
2988
2983
  fn as parseInitData,
2989
- pt as parseLaunchParams,
2984
+ ut as parseLaunchParams,
2990
2985
  te as parseThemeParams,
2991
2986
  B as postEvent,
2992
2987
  g as request,
@@ -2995,21 +2990,21 @@ export {
2995
2990
  ee as requestViewport,
2996
2991
  Qt as retrieveLaunchParams,
2997
2992
  It as rgb,
2998
- ht as searchParams,
2993
+ pt as searchParams,
2999
2994
  He as serializeLaunchParams,
3000
2995
  Jt as serializeThemeParams,
3001
- R as setCSSVar,
2996
+ P as setCSSVar,
3002
2997
  le as setDebug,
3003
2998
  wn as setTargetOrigin,
3004
- p as string,
2999
+ h as string,
3005
3000
  pe as subscribe,
3006
- C as supports,
3001
+ x as supports,
3007
3002
  ke as targetOrigin,
3008
3003
  At as toRGB,
3009
- xt as unsubscribe,
3004
+ Ct as unsubscribe,
3010
3005
  U as urlToPath,
3011
- Ns as useBackButton,
3012
- Ds as useBackButtonRaw,
3006
+ Ds as useBackButton,
3007
+ Ns as useBackButtonRaw,
3013
3008
  Ms as useBiometryManager,
3014
3009
  Bs as useBiometryManagerRaw,
3015
3010
  $s as useClosingBehavior,
@@ -3046,10 +3041,10 @@ export {
3046
3041
  An as withBiometryManagerRaw,
3047
3042
  qn as withClosingBehavior,
3048
3043
  kn as withClosingBehaviorRaw,
3049
- Dn as withCloudStorage,
3044
+ Nn as withCloudStorage,
3050
3045
  On as withCloudStorageRaw,
3051
3046
  Bn as withHapticFeedback,
3052
- Nn as withHapticFeedbackRaw,
3047
+ Dn as withHapticFeedbackRaw,
3053
3048
  Vn as withInitData,
3054
3049
  Mn as withInitDataRaw,
3055
3050
  Ln as withInvoice,