@tma.js/sdk 2.3.0 → 2.4.0

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,5 +1,5 @@
1
- var Wt = Object.defineProperty;
2
- var Ut = (e, t, s) => t in e ? Wt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s;
1
+ var Ot = Object.defineProperty;
2
+ var Ut = (e, t, s) => t in e ? Ot(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s;
3
3
  var c = (e, t, s) => (Ut(e, typeof t != "symbol" ? t + "" : t, s), s);
4
4
  function at(e, t) {
5
5
  let s;
@@ -9,11 +9,11 @@ function at(e, t) {
9
9
  return [() => s === void 0 ? s = e(n) : s, n];
10
10
  }
11
11
  function ct(e) {
12
- const t = $(), { count: s } = t;
12
+ const t = M(), { count: s } = t;
13
13
  t.unsubscribe(e), s && !t.count && ae();
14
14
  }
15
15
  function Ht(e) {
16
- return $().subscribe(e), () => ct(e);
16
+ return M().subscribe(e), () => ct(e);
17
17
  }
18
18
  class Gt {
19
19
  constructor(t, s = {}) {
@@ -31,12 +31,12 @@ class Gt {
31
31
  second: "2-digit",
32
32
  fractionalSecondDigits: 3,
33
33
  timeZone: "UTC"
34
- }).format(n), { textColor: i, bgColor: a } = this.options, o = "font-weight: bold;padding: 0 5px;border-radius:5px";
34
+ }).format(n), { textColor: i, bgColor: o } = this.options, a = "font-weight: bold;padding: 0 5px;border-radius:5px";
35
35
  console[t](
36
36
  `%c${r}%c / %c${this.scope}`,
37
- `${o};background-color: lightblue;color:black`,
37
+ `${a};background-color: lightblue;color:black`,
38
38
  "",
39
- `${o};${i ? `color:${i};` : ""}${a ? `background-color:${a}` : ""}`,
39
+ `${a};${i ? `color:${i};` : ""}${o ? `background-color:${o}` : ""}`,
40
40
  ...s
41
41
  );
42
42
  }
@@ -55,19 +55,19 @@ class Gt {
55
55
  this.print("log", ...t);
56
56
  }
57
57
  }
58
- const J = new Gt("SDK", {
58
+ const F = new Gt("SDK", {
59
59
  bgColor: "forestgreen",
60
60
  textColor: "white"
61
61
  });
62
- let G = !1;
62
+ let H = !1;
63
63
  const nt = ({ name: e, payload: t }) => {
64
- J.log("Event received:", t ? { name: e, payload: t } : { name: e });
64
+ F.log("Event received:", t ? { name: e, payload: t } : { name: e });
65
65
  };
66
66
  function Ye(e) {
67
- G !== e && (G = e, e ? Ht(nt) : ct(nt));
67
+ H !== e && (H = e, e ? Ht(nt) : ct(nt));
68
68
  }
69
69
  function jt(...e) {
70
- G && J.log(...e);
70
+ H && F.log(...e);
71
71
  }
72
72
  class T {
73
73
  constructor() {
@@ -141,10 +141,10 @@ class T {
141
141
  }
142
142
  }
143
143
  }
144
- function j(e, t, s) {
144
+ function G(e, t, s) {
145
145
  return window.addEventListener(e, t, s), () => window.removeEventListener(e, t, s);
146
146
  }
147
- function ht(...e) {
147
+ function J(...e) {
148
148
  let t = !1;
149
149
  const s = [...e];
150
150
  return [
@@ -155,19 +155,19 @@ function ht(...e) {
155
155
  t
156
156
  ];
157
157
  }
158
- class V extends Error {
158
+ class D extends Error {
159
159
  constructor(t, s, n) {
160
- super(s, { cause: n }), this.type = t, Object.setPrototypeOf(this, V.prototype);
160
+ super(s, { cause: n }), this.type = t, Object.setPrototypeOf(this, D.prototype);
161
161
  }
162
162
  }
163
163
  function f(e, t, s) {
164
- return new V(e, t, s);
164
+ return new D(e, t, s);
165
165
  }
166
- const zt = "ERR_METHOD_UNSUPPORTED", Ft = "ERR_METHOD_PARAMETER_UNSUPPORTED", Jt = "ERR_UNKNOWN_ENV", Qt = "ERR_INVOKE_CUSTOM_METHOD_RESPONSE", Yt = "ERR_TIMED_OUT", Zt = "ERR_UNEXPECTED_TYPE", pt = "ERR_PARSE", Kt = "ERR_NAVIGATION_LIST_EMPTY", Xt = "ERR_NAVIGATION_CURSOR_INVALID", Ze = "ERR_NAVIGATION_ITEM_INVALID", Ke = "ERR_SSR_INIT", te = "ERR_INVALID_PATH_BASE";
166
+ const zt = "ERR_METHOD_UNSUPPORTED", Ft = "ERR_METHOD_PARAMETER_UNSUPPORTED", Jt = "ERR_UNKNOWN_ENV", Qt = "ERR_INVOKE_CUSTOM_METHOD_RESPONSE", Yt = "ERR_TIMED_OUT", Zt = "ERR_UNEXPECTED_TYPE", ht = "ERR_PARSE", Kt = "ERR_NAVIGATION_LIST_EMPTY", Xt = "ERR_NAVIGATION_CURSOR_INVALID", Ze = "ERR_NAVIGATION_ITEM_INVALID", Ke = "ERR_SSR_INIT", te = "ERR_INVALID_PATH_BASE";
167
167
  function E() {
168
168
  return f(Zt, "Value has unexpected type");
169
169
  }
170
- class M {
170
+ class V {
171
171
  constructor(t, s, n) {
172
172
  this.parser = t, this.isOptional = s, this.type = n;
173
173
  }
@@ -183,7 +183,7 @@ class M {
183
183
  return this.parser(t);
184
184
  } catch (s) {
185
185
  throw f(
186
- pt,
186
+ ht,
187
187
  `Unable to parse value${this.type ? ` as ${this.type}` : ""}`,
188
188
  s
189
189
  );
@@ -194,7 +194,7 @@ class M {
194
194
  }
195
195
  }
196
196
  function P(e, t) {
197
- return () => new M(e, !1, t);
197
+ return () => new V(e, !1, t);
198
198
  }
199
199
  const b = P((e) => {
200
200
  if (typeof e == "boolean")
@@ -206,24 +206,24 @@ const b = P((e) => {
206
206
  return !1;
207
207
  throw E();
208
208
  }, "boolean");
209
- function ut(e, t) {
209
+ function pt(e, t) {
210
210
  const s = {};
211
211
  for (const n in e) {
212
212
  const r = e[n];
213
213
  if (!r)
214
214
  continue;
215
- let i, a;
215
+ let i, o;
216
216
  if (typeof r == "function" || "parse" in r)
217
- i = n, a = typeof r == "function" ? r : r.parse.bind(r);
217
+ i = n, o = typeof r == "function" ? r : r.parse.bind(r);
218
218
  else {
219
- const { type: o } = r;
220
- i = r.from || n, a = typeof o == "function" ? o : o.parse.bind(o);
219
+ const { type: a } = r;
220
+ i = r.from || n, o = typeof a == "function" ? a : a.parse.bind(a);
221
221
  }
222
222
  try {
223
- const o = a(t(i));
224
- o !== void 0 && (s[n] = o);
225
- } catch (o) {
226
- throw f(pt, `Unable to parse field "${n}"`, o);
223
+ const a = o(t(i));
224
+ a !== void 0 && (s[n] = a);
225
+ } catch (a) {
226
+ throw f(ht, `Unable to parse field "${n}"`, a);
227
227
  }
228
228
  }
229
229
  return s;
@@ -235,9 +235,9 @@ function Q(e) {
235
235
  return t;
236
236
  }
237
237
  function d(e, t) {
238
- return new M((s) => {
238
+ return new V((s) => {
239
239
  const n = Q(s);
240
- return ut(e, (r) => n[r]);
240
+ return pt(e, (r) => n[r]);
241
241
  }, !1, t);
242
242
  }
243
243
  const y = P((e) => {
@@ -256,7 +256,7 @@ function Y(e) {
256
256
  function ee(e) {
257
257
  return /^#[\da-f]{3}$/i.test(e);
258
258
  }
259
- function lt(e) {
259
+ function ut(e) {
260
260
  const t = e.replace(/\s/g, "").toLowerCase();
261
261
  if (Y(t))
262
262
  return t;
@@ -278,8 +278,8 @@ const h = P((e) => {
278
278
  if (typeof e == "string" || typeof e == "number")
279
279
  return e.toString();
280
280
  throw E();
281
- }, "string"), dt = P((e) => lt(h().parse(e)), "rgb");
282
- function _t(e) {
281
+ }, "string"), lt = P((e) => ut(h().parse(e)), "rgb");
282
+ function dt(e) {
283
283
  return d({
284
284
  eventType: h(),
285
285
  eventData: (t) => t
@@ -290,7 +290,7 @@ function se() {
290
290
  delete window[e];
291
291
  });
292
292
  }
293
- function z(e, t) {
293
+ function j(e, t) {
294
294
  window.dispatchEvent(new MessageEvent("message", {
295
295
  data: JSON.stringify({ eventType: e, eventData: t }),
296
296
  // We specify window.parent to imitate the case, the parent iframe sent us this event.
@@ -309,7 +309,7 @@ function ne() {
309
309
  let t = window;
310
310
  e.forEach((s, n, r) => {
311
311
  if (n === r.length - 1) {
312
- t[s] = z;
312
+ t[s] = j;
313
313
  return;
314
314
  }
315
315
  s in t || (t[s] = {}), t = t[s];
@@ -338,7 +338,7 @@ const re = {
338
338
  qr_text_received: d({ data: h().optional() }),
339
339
  theme_changed: d({
340
340
  theme_params: (e) => {
341
- const t = dt().optional();
341
+ const t = lt().optional();
342
342
  return Object.entries(Q(e)).reduce((s, [n, r]) => (s[n] = t.parse(r), s), {});
343
343
  }
344
344
  }),
@@ -355,7 +355,7 @@ function ie() {
355
355
  t.subscribe((n) => {
356
356
  e.emit("event", { name: n.event, payload: n.args[0] });
357
357
  }), ne();
358
- const [, s] = ht(
358
+ const [, s] = J(
359
359
  // Don't forget to remove created handlers.
360
360
  se,
361
361
  // Add "resize" event listener to make sure, we always have fresh viewport information.
@@ -363,7 +363,7 @@ function ie() {
363
363
  // event. For example, when the MainButton is shown. That's why we should
364
364
  // add our own listener to make sure, viewport information is always fresh.
365
365
  // Issue: https://github.com/Telegram-Mini-Apps/tma.js/issues/10
366
- j("resize", () => {
366
+ G("resize", () => {
367
367
  t.emit("viewport_changed", {
368
368
  width: window.innerWidth,
369
369
  height: window.innerHeight,
@@ -373,21 +373,21 @@ function ie() {
373
373
  }),
374
374
  // Add listener, which handles events sent from the Telegram web application and also events
375
375
  // generated by the local emitEvent function.
376
- j("message", (n) => {
376
+ G("message", (n) => {
377
377
  if (n.source !== window.parent)
378
378
  return;
379
379
  let r;
380
380
  try {
381
- r = _t(n.data);
381
+ r = dt(n.data);
382
382
  } catch {
383
383
  return;
384
384
  }
385
- const { eventType: i, eventData: a } = r, o = re[i];
385
+ const { eventType: i, eventData: o } = r, a = re[i];
386
386
  try {
387
- const p = o ? o.parse(a) : a;
387
+ const p = a ? a.parse(o) : o;
388
388
  t.emit(...p ? [i, p] : [i]);
389
389
  } catch (p) {
390
- J.error(
390
+ F.error(
391
391
  `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`,
392
392
  r,
393
393
  p
@@ -416,20 +416,20 @@ const [oe, ae] = at(
416
416
  (e) => {
417
417
  const [t, s] = ie(), n = t.off.bind(t);
418
418
  return t.off = (r, i) => {
419
- const { count: a } = t;
420
- n(r, i), a && !t.count && e();
419
+ const { count: o } = t;
420
+ n(r, i), o && !t.count && e();
421
421
  }, [t, s];
422
422
  },
423
423
  ([, e]) => e()
424
424
  );
425
- function $() {
425
+ function M() {
426
426
  return oe()[0];
427
427
  }
428
- function L(e, t) {
429
- $().off(e, t);
428
+ function $(e, t) {
429
+ M().off(e, t);
430
430
  }
431
431
  function w(e, t, s) {
432
- return $().on(e, t, s);
432
+ return M().on(e, t, s);
433
433
  }
434
434
  function I(e) {
435
435
  return typeof e == "object" && e !== null && !Array.isArray(e);
@@ -437,9 +437,9 @@ function I(e) {
437
437
  function ce(e, t) {
438
438
  const s = e.split("."), n = t.split("."), r = Math.max(s.length, n.length);
439
439
  for (let i = 0; i < r; i += 1) {
440
- const a = parseInt(s[i] || "0", 10), o = parseInt(n[i] || "0", 10);
441
- if (a !== o)
442
- return a > o ? 1 : -1;
440
+ const o = parseInt(s[i] || "0", 10), a = parseInt(n[i] || "0", 10);
441
+ if (o !== a)
442
+ return o > a ? 1 : -1;
443
443
  }
444
444
  return 0;
445
445
  }
@@ -497,39 +497,39 @@ function v(e, t, s) {
497
497
  ].includes(e);
498
498
  }
499
499
  }
500
- function ft(e) {
500
+ function _t(e) {
501
501
  return "external" in e && I(e.external) && "notify" in e.external && typeof e.external.notify == "function";
502
502
  }
503
- function gt(e) {
503
+ function ft(e) {
504
504
  return "TelegramWebviewProxy" in e && I(e.TelegramWebviewProxy) && "postEvent" in e.TelegramWebviewProxy && typeof e.TelegramWebviewProxy.postEvent == "function";
505
505
  }
506
- function wt() {
506
+ function gt() {
507
507
  try {
508
508
  return window.self !== window.top;
509
509
  } catch {
510
510
  return !0;
511
511
  }
512
512
  }
513
- let bt = "https://web.telegram.org";
513
+ let wt = "https://web.telegram.org";
514
514
  function Xe(e) {
515
- bt = e;
515
+ wt = e;
516
516
  }
517
517
  function he() {
518
- return bt;
518
+ return wt;
519
519
  }
520
520
  function R(e, t, s) {
521
521
  let n = {}, r;
522
522
  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);
523
523
  const { targetOrigin: i = he() } = n;
524
- if (jt("Posting event:", r ? { event: e, data: r } : { event: e }), wt()) {
524
+ if (jt("Posting event:", r ? { event: e, data: r } : { event: e }), gt()) {
525
525
  window.parent.postMessage(JSON.stringify({ eventType: e, eventData: r }), i);
526
526
  return;
527
527
  }
528
- if (ft(window)) {
528
+ if (_t(window)) {
529
529
  window.external.notify(JSON.stringify({ eventType: e, eventData: r }));
530
530
  return;
531
531
  }
532
- if (gt(window)) {
532
+ if (ft(window)) {
533
533
  window.TelegramWebviewProxy.postEvent(e, JSON.stringify(r));
534
534
  return;
535
535
  }
@@ -553,39 +553,35 @@ function pe(e) {
553
553
  return R(t, s);
554
554
  };
555
555
  }
556
- function mt(e) {
556
+ function bt(e) {
557
557
  return ({ req_id: t }) => t === e;
558
558
  }
559
- function yt(e) {
559
+ function mt(e) {
560
560
  return f(Yt, `Timeout reached: ${e}ms`);
561
561
  }
562
- function vt(e, t) {
562
+ function yt(e, t) {
563
563
  return Promise.race([
564
564
  typeof e == "function" ? e() : e,
565
565
  new Promise((s, n) => {
566
566
  setTimeout(() => {
567
- n(yt(t));
567
+ n(mt(t));
568
568
  }, t);
569
569
  })
570
570
  ]);
571
571
  }
572
572
  async function _(e) {
573
573
  let t;
574
- const s = new Promise((u) => {
575
- t = u;
576
- }), {
577
- method: n,
578
- event: r,
579
- capture: i,
580
- postEvent: a = R,
581
- timeout: o
582
- } = e, p = (Array.isArray(r) ? r : [r]).map(
583
- (u) => w(u, (k) => (!i || i(k)) && t(k))
574
+ const s = new Promise((a) => {
575
+ t = a;
576
+ }), { event: n, capture: r, timeout: i } = e, [, o] = J(
577
+ ...(Array.isArray(n) ? n : [n]).map(
578
+ (a) => w(a, (p) => (!r || r(p)) && t(p))
579
+ )
584
580
  );
585
581
  try {
586
- return a(n, e.params), await (o ? vt(s, o) : s);
582
+ return (e.postEvent || R)(e.method, e.params), await (i ? yt(s, i) : s);
587
583
  } finally {
588
- p.forEach((u) => u());
584
+ o();
589
585
  }
590
586
  }
591
587
  async function S(e, t, s, n = {}) {
@@ -601,30 +597,30 @@ async function S(e, t, s, n = {}) {
601
597
  params: t,
602
598
  req_id: s
603
599
  },
604
- capture: mt(s)
600
+ capture: bt(s)
605
601
  });
606
602
  if (i)
607
603
  throw f(Qt, i);
608
604
  return r;
609
605
  }
610
- function F(...e) {
606
+ function z(...e) {
611
607
  return e.map((t) => {
612
608
  if (typeof t == "string")
613
609
  return t;
614
610
  if (I(t))
615
- return F(Object.entries(t).map((s) => s[1] && s[0]));
611
+ return z(Object.entries(t).map((s) => s[1] && s[0]));
616
612
  if (Array.isArray(t))
617
- return F(...t);
613
+ return z(...t);
618
614
  }).filter(Boolean).join(" ");
619
615
  }
620
616
  function ts(...e) {
621
617
  return e.reduce((t, s) => (I(s) && Object.entries(s).forEach(([n, r]) => {
622
- const i = F(t[n], r);
618
+ const i = z(t[n], r);
623
619
  i.length && (t[n] = i);
624
620
  }), t), {});
625
621
  }
626
- function Et(e) {
627
- const t = lt(e);
622
+ function vt(e) {
623
+ const t = ut(e);
628
624
  return Math.sqrt(
629
625
  [0.299, 0.587, 0.114].reduce((s, n, r) => {
630
626
  const i = parseInt(t.slice(1 + r * 2, 1 + (r + 1) * 2), 16);
@@ -652,7 +648,7 @@ class ue {
652
648
  return { ...this.state };
653
649
  }
654
650
  set(t, s) {
655
- Object.entries(typeof t == "string" ? { [t]: s } : t).reduce((r, [i, a]) => this.state[i] === a || a === void 0 ? r : (this.state[i] = a, this.ee.emit(`change:${i}`, a), !0), !1) && this.ee.emit("change", this.state);
651
+ Object.entries(typeof t == "string" ? { [t]: s } : t).reduce((r, [i, o]) => this.state[i] === o || o === void 0 ? r : (this.state[i] = o, this.ee.emit(`change:${i}`, o), !0), !1) && this.ee.emit("change", this.state);
656
652
  }
657
653
  /**
658
654
  * Returns value by specified key.
@@ -680,7 +676,7 @@ class Z {
680
676
  this.state = new ue(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);
681
677
  }
682
678
  }
683
- function Pt(e, t) {
679
+ function Et(e, t) {
684
680
  return (s) => v(t[s], e);
685
681
  }
686
682
  class K extends Z {
@@ -690,7 +686,7 @@ class K extends Z {
690
686
  * @returns True, if specified method is supported by the current component.
691
687
  */
692
688
  c(this, "supports");
693
- this.supports = Pt(n, r);
689
+ this.supports = Et(n, r);
694
690
  }
695
691
  }
696
692
  class le extends K {
@@ -710,7 +706,7 @@ class le extends K {
710
706
  * @param event - event to listen.
711
707
  * @param listener - listener to remove.
712
708
  */
713
- c(this, "off", (s, n) => s === "click" ? L("back_button_pressed", n) : this.state.off(s, n));
709
+ c(this, "off", (s, n) => s === "click" ? $("back_button_pressed", n) : this.state.off(s, n));
714
710
  this.postEvent = r;
715
711
  }
716
712
  set isVisible(s) {
@@ -735,13 +731,13 @@ class le extends K {
735
731
  this.isVisible = !0;
736
732
  }
737
733
  }
738
- const xt = P((e) => e instanceof Date ? e : new Date(y().parse(e) * 1e3), "Date");
734
+ const Pt = P((e) => e instanceof Date ? e : new Date(y().parse(e) * 1e3), "Date");
739
735
  function X(e, t) {
740
- return new M((s) => {
736
+ return new V((s) => {
741
737
  if (typeof s != "string" && !(s instanceof URLSearchParams))
742
738
  throw E();
743
739
  const n = typeof s == "string" ? new URLSearchParams(s) : s;
744
- return ut(e, (r) => {
740
+ return pt(e, (r) => {
745
741
  const i = n.get(r);
746
742
  return i === null ? void 0 : i;
747
743
  });
@@ -792,10 +788,10 @@ const de = d({
792
788
  },
793
789
  username: h().optional()
794
790
  }, "User").optional();
795
- function St() {
791
+ function xt() {
796
792
  return X({
797
793
  authDate: {
798
- type: xt(),
794
+ type: Pt(),
799
795
  from: "auth_date"
800
796
  },
801
797
  canSendAfter: {
@@ -830,9 +826,9 @@ function _e(e) {
830
826
  function fe(e) {
831
827
  return e.replace(/[A-Z]/g, (t) => `_${t.toLowerCase()}`);
832
828
  }
833
- const Ct = P(
829
+ const St = P(
834
830
  (e) => {
835
- const t = dt().optional();
831
+ const t = lt().optional();
836
832
  return Object.entries(Q(e)).reduce((s, [n, r]) => (s[_e(n)] = t.parse(r), s), {});
837
833
  },
838
834
  "ThemeParams"
@@ -844,7 +840,7 @@ function tt(e) {
844
840
  from: "tgWebAppBotInline"
845
841
  },
846
842
  initData: {
847
- type: St().optional(),
843
+ type: xt().optional(),
848
844
  from: "tgWebAppData"
849
845
  },
850
846
  initDataRaw: {
@@ -864,7 +860,7 @@ function tt(e) {
864
860
  from: "tgWebAppStartParam"
865
861
  },
866
862
  themeParams: {
867
- type: Ct(),
863
+ type: St(),
868
864
  from: "tgWebAppThemeParams"
869
865
  },
870
866
  version: {
@@ -873,40 +869,40 @@ function tt(e) {
873
869
  }
874
870
  }).parse(e);
875
871
  }
876
- function Tt(e) {
872
+ function Ct(e) {
877
873
  return tt(
878
874
  e.replace(/^[^?#]*[?#]/, "").replace(/[?#]/g, "&")
879
875
  );
880
876
  }
881
877
  function ge() {
882
- return Tt(window.location.href);
878
+ return Ct(window.location.href);
883
879
  }
884
- function Rt() {
880
+ function Tt() {
885
881
  return performance.getEntriesByType("navigation")[0];
886
882
  }
887
883
  function we() {
888
- const e = Rt();
884
+ const e = Tt();
889
885
  if (!e)
890
886
  throw new Error("Unable to get first navigation entry.");
891
- return Tt(e.name);
887
+ return Ct(e.name);
892
888
  }
893
- function At(e) {
889
+ function Rt(e) {
894
890
  return `tma.js/${e.replace(/[A-Z]/g, (t) => `-${t.toLowerCase()}`)}`;
895
891
  }
896
- function It(e, t) {
897
- sessionStorage.setItem(At(e), JSON.stringify(t));
892
+ function At(e, t) {
893
+ sessionStorage.setItem(Rt(e), JSON.stringify(t));
898
894
  }
899
- function qt(e) {
900
- const t = sessionStorage.getItem(At(e));
895
+ function It(e) {
896
+ const t = sessionStorage.getItem(Rt(e));
901
897
  try {
902
898
  return t ? JSON.parse(t) : void 0;
903
899
  } catch {
904
900
  }
905
901
  }
906
902
  function be() {
907
- return tt(qt("launchParams") || "");
903
+ return tt(It("launchParams") || "");
908
904
  }
909
- function kt(e) {
905
+ function qt(e) {
910
906
  return JSON.stringify(
911
907
  Object.fromEntries(
912
908
  Object.entries(e).map(([t, s]) => [fe(t), s])
@@ -920,13 +916,13 @@ function me(e) {
920
916
  platform: n,
921
917
  version: r,
922
918
  showSettings: i,
923
- startParam: a,
924
- botInline: o
919
+ startParam: o,
920
+ botInline: a
925
921
  } = e, p = new URLSearchParams();
926
- return p.set("tgWebAppPlatform", n), p.set("tgWebAppThemeParams", kt(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();
922
+ return p.set("tgWebAppPlatform", n), p.set("tgWebAppThemeParams", qt(s)), p.set("tgWebAppVersion", r), t && p.set("tgWebAppData", t), o && p.set("tgWebAppStartParam", o), typeof i == "boolean" && p.set("tgWebAppShowSettings", i ? "1" : "0"), typeof a == "boolean" && p.set("tgWebAppBotInline", a ? "1" : "0"), p.toString();
927
923
  }
928
- function Nt(e) {
929
- It("launchParams", me(e));
924
+ function kt(e) {
925
+ At("launchParams", me(e));
930
926
  }
931
927
  function ye() {
932
928
  for (const e of [
@@ -940,13 +936,13 @@ function ye() {
940
936
  ])
941
937
  try {
942
938
  const t = e();
943
- return Nt(t), t;
939
+ return kt(t), t;
944
940
  } catch {
945
941
  }
946
942
  throw new Error("Unable to retrieve launch parameters from any known source.");
947
943
  }
948
- function Dt() {
949
- const e = Rt();
944
+ function Nt() {
945
+ const e = Tt();
950
946
  return !!(e && e.type === "reload");
951
947
  }
952
948
  function ve() {
@@ -963,20 +959,20 @@ function l(e, t) {
963
959
  };
964
960
  if (typeof e == "function")
965
961
  return e(n);
966
- const [r, i, a] = ht(), o = t({
962
+ const [r, i, o] = J(), a = t({
967
963
  ...n,
968
964
  // State should only be passed only in case, current page was reloaded. If we don't add
969
965
  // this check, state restoration will work improperly in the web version of Telegram,
970
966
  // when we are always working in the same "session" (tab).
971
- state: Dt() ? qt(e) : void 0,
967
+ state: Nt() ? It(e) : void 0,
972
968
  addCleanup: r
973
- }), p = (u) => (a || r(
974
- u.on("change", (k) => {
975
- It(e, k);
969
+ }), p = (u) => (o || r(
970
+ u.on("change", (Wt) => {
971
+ At(e, Wt);
976
972
  })
977
973
  ), u);
978
974
  return [
979
- o instanceof Promise ? o.then(p) : p(o),
975
+ a instanceof Promise ? a.then(p) : p(a),
980
976
  i
981
977
  ];
982
978
  };
@@ -999,7 +995,7 @@ class q extends K {
999
995
  c(this, "off", this.state.off.bind(this.state));
1000
996
  }
1001
997
  }
1002
- function Vt(e) {
998
+ function Dt(e) {
1003
999
  const t = e.available ? e : {
1004
1000
  available: !1,
1005
1001
  device_id: "",
@@ -1099,7 +1095,7 @@ class Pe extends q {
1099
1095
  event: "biometry_info_received",
1100
1096
  params: { reason: s || "" }
1101
1097
  }).then((r) => {
1102
- const i = Vt(r);
1098
+ const i = Dt(r);
1103
1099
  return this.set(i), i.accessGranted;
1104
1100
  }).finally(() => this.accessPromise = void 0)), this.accessPromise;
1105
1101
  }
@@ -1132,7 +1128,7 @@ class Pe extends q {
1132
1128
  }
1133
1129
  }
1134
1130
  async function xe(e) {
1135
- return Vt(
1131
+ return Dt(
1136
1132
  await _({
1137
1133
  ...e || {},
1138
1134
  method: "web_app_biometry_get_info",
@@ -1207,7 +1203,7 @@ class st {
1207
1203
  * @returns True, if specified method is supported by the current component.
1208
1204
  */
1209
1205
  c(this, "supports");
1210
- this.supports = Pt(t, s);
1206
+ this.supports = Et(t, s);
1211
1207
  }
1212
1208
  }
1213
1209
  function Ce(e) {
@@ -1222,7 +1218,7 @@ function Ce(e) {
1222
1218
  }
1223
1219
  throw E();
1224
1220
  }
1225
- class Te extends M {
1221
+ class Te extends V {
1226
1222
  constructor(s, n, r) {
1227
1223
  super(Ce, n, r);
1228
1224
  c(this, "itemParser");
@@ -1437,7 +1433,7 @@ const os = l(
1437
1433
  ({ initData: e }) => e ? new qe(e) : void 0
1438
1434
  );
1439
1435
  function as(e) {
1440
- return St().parse(e);
1436
+ return xt().parse(e);
1441
1437
  }
1442
1438
  class ke extends q {
1443
1439
  constructor(t, s, n) {
@@ -1462,10 +1458,10 @@ class ke extends q {
1462
1458
  const { hostname: r, pathname: i } = new URL(t, window.location.href);
1463
1459
  if (r !== "t.me")
1464
1460
  throw new Error(`Incorrect hostname: ${r}`);
1465
- const a = i.match(/^\/(\$|invoice\/)([A-Za-z0-9\-_=]+)$/);
1466
- if (!a)
1461
+ const o = i.match(/^\/(\$|invoice\/)([A-Za-z0-9\-_=]+)$/);
1462
+ if (!o)
1467
1463
  throw new Error('Link pathname has incorrect format. Expected to receive "/invoice/{slug}" or "/${slug}"');
1468
- [, , n] = a;
1464
+ [, , n] = o;
1469
1465
  }
1470
1466
  this.isOpened = !0;
1471
1467
  try {
@@ -1501,7 +1497,7 @@ class Ne extends Z {
1501
1497
  * @param event - event to listen.
1502
1498
  * @param listener - listener to remove.
1503
1499
  */
1504
- c(this, "off", (s, n) => s === "click" ? L("main_button_pressed", n) : this.state.off(s, n));
1500
+ c(this, "off", (s, n) => s === "click" ? $("main_button_pressed", n) : this.state.off(s, n));
1505
1501
  this.postEvent = s;
1506
1502
  }
1507
1503
  /**
@@ -1667,13 +1663,13 @@ function De() {
1667
1663
  }
1668
1664
  }),
1669
1665
  authDate: {
1670
- type: xt(),
1666
+ type: Pt(),
1671
1667
  from: "auth_date"
1672
1668
  },
1673
1669
  hash: h()
1674
1670
  }, "RequestedContact");
1675
1671
  }
1676
- function Mt(e, t) {
1672
+ function Vt(e, t) {
1677
1673
  return (s) => {
1678
1674
  const [n, r] = t[s];
1679
1675
  return v(n, r, e);
@@ -1685,8 +1681,8 @@ function Ve(e) {
1685
1681
  });
1686
1682
  }
1687
1683
  class Me extends q {
1688
- constructor({ postEvent: s, createRequestId: n, version: r, botInline: i, ...a }) {
1689
- super(a, r, {
1684
+ constructor({ postEvent: s, createRequestId: n, version: r, botInline: i, ...o }) {
1685
+ super(o, r, {
1690
1686
  requestPhoneAccess: "web_app_request_phone",
1691
1687
  requestWriteAccess: "web_app_request_write_access",
1692
1688
  switchInlineQuery: "web_app_switch_inline_query",
@@ -1703,8 +1699,8 @@ class Me extends q {
1703
1699
  */
1704
1700
  c(this, "supportsParam");
1705
1701
  this.createRequestId = n, this.postEvent = s, this.botInline = i;
1706
- const o = this.supports.bind(this);
1707
- this.supports = (p) => o(p) ? p !== "switchInlineQuery" || i : !1, this.supportsParam = Mt(r, {
1702
+ const a = this.supports.bind(this);
1703
+ this.supports = (p) => a(p) ? p !== "switchInlineQuery" || i : !1, this.supportsParam = Vt(r, {
1708
1704
  "setHeaderColor.color": ["web_app_set_header_color", "color"]
1709
1705
  });
1710
1706
  }
@@ -1755,7 +1751,7 @@ class Me extends q {
1755
1751
  * True if current Mini App background color is recognized as dark.
1756
1752
  */
1757
1753
  get isDark() {
1758
- return Et(this.bgColor);
1754
+ return vt(this.bgColor);
1759
1755
  }
1760
1756
  /**
1761
1757
  * Informs the Telegram app that the Mini App is ready to be displayed.
@@ -1784,7 +1780,7 @@ class Me extends q {
1784
1780
  throw new Error("Access denied.");
1785
1781
  const r = Date.now() + s;
1786
1782
  let i = 50;
1787
- return vt(async () => {
1783
+ return yt(async () => {
1788
1784
  for (; Date.now() < r; ) {
1789
1785
  try {
1790
1786
  return await this.getRequestedContact();
@@ -1792,7 +1788,7 @@ class Me extends q {
1792
1788
  }
1793
1789
  await Ve(i), i += 50;
1794
1790
  }
1795
- throw yt(s);
1791
+ throw mt(s);
1796
1792
  }, s);
1797
1793
  }
1798
1794
  /**
@@ -1897,18 +1893,18 @@ function $e(e) {
1897
1893
  if (n.length > 3)
1898
1894
  throw new Error(`Buttons have incorrect size: ${n.length}`);
1899
1895
  return n.length ? r = n.map((i) => {
1900
- const { id: a = "" } = i;
1901
- if (a.length > 64)
1902
- throw new Error(`Button ID has incorrect size: ${a}`);
1896
+ const { id: o = "" } = i;
1897
+ if (o.length > 64)
1898
+ throw new Error(`Button ID has incorrect size: ${o}`);
1903
1899
  if (!i.type || i.type === "default" || i.type === "destructive") {
1904
- const o = i.text.trim();
1905
- if (!o.length || o.length > 64) {
1900
+ const a = i.text.trim();
1901
+ if (!a.length || a.length > 64) {
1906
1902
  const p = i.type || "default";
1907
1903
  throw new Error(`Button text with type "${p}" has incorrect size: ${i.text.length}`);
1908
1904
  }
1909
- return { ...i, text: o, id: a };
1905
+ return { ...i, text: a, id: o };
1910
1906
  }
1911
- return { ...i, id: a };
1907
+ return { ...i, id: o };
1912
1908
  }) : r = [{ type: "close", id: "" }], { title: s, message: t, buttons: r };
1913
1909
  }
1914
1910
  class Le extends q {
@@ -1977,32 +1973,31 @@ class Be extends q {
1977
1973
  get isOpened() {
1978
1974
  return this.get("isOpened");
1979
1975
  }
1980
- /**
1981
- * Opens scanner with specified title shown to user. Method returns promise
1982
- * with scanned QR content in case, it was scanned. It will contain null in
1983
- * case, scanner was closed.
1984
- * @param text - title to display.
1985
- */
1986
1976
  async open(t) {
1987
1977
  if (this.isOpened)
1988
1978
  throw new Error("QR scanner is already opened.");
1979
+ const { text: s, capture: n } = (typeof t == "string" ? { text: t } : t) || {};
1989
1980
  this.isOpened = !0;
1990
1981
  try {
1991
- return (await _({
1982
+ const i = (await _({
1992
1983
  method: "web_app_open_scan_qr_popup",
1993
1984
  event: ["qr_text_received", "scan_qr_popup_closed"],
1994
1985
  postEvent: this.postEvent,
1995
- params: { text: t }
1986
+ params: { text: s },
1987
+ capture(o) {
1988
+ return o.event === "scan_qr_popup_closed" || !n || n(o.payload);
1989
+ }
1996
1990
  }) || {}).data || null;
1997
- } finally {
1998
- this.isOpened = !1;
1991
+ return i && this.close(), i;
1992
+ } catch (r) {
1993
+ throw this.isOpened = !1, r;
1999
1994
  }
2000
1995
  }
2001
1996
  }
2002
1997
  const ls = l(
2003
1998
  ({ version: e, postEvent: t }) => new Be(!1, e, t)
2004
1999
  );
2005
- class Oe extends K {
2000
+ class We extends K {
2006
2001
  constructor(s, n, r) {
2007
2002
  super({ isVisible: s }, n, {
2008
2003
  show: "web_app_setup_settings_button",
@@ -2019,7 +2014,7 @@ class Oe extends K {
2019
2014
  * @param event - event to listen.
2020
2015
  * @param listener - listener to remove.
2021
2016
  */
2022
- c(this, "off", (s, n) => s === "click" ? L("settings_button_pressed", n) : this.state.off(s, n));
2017
+ c(this, "off", (s, n) => s === "click" ? $("settings_button_pressed", n) : this.state.off(s, n));
2023
2018
  this.postEvent = r;
2024
2019
  }
2025
2020
  set isVisible(s) {
@@ -2050,12 +2045,12 @@ const ds = l(
2050
2045
  version: e,
2051
2046
  postEvent: t,
2052
2047
  state: s = { isVisible: !1 }
2053
- }) => new Oe(s.isVisible, e, t)
2048
+ }) => new We(s.isVisible, e, t)
2054
2049
  );
2055
- function $t(e) {
2056
- return Ct().parse(e);
2050
+ function Mt(e) {
2051
+ return St().parse(e);
2057
2052
  }
2058
- class We extends et {
2053
+ class Oe extends et {
2059
2054
  /**
2060
2055
  * @since v6.10
2061
2056
  */
@@ -2094,7 +2089,7 @@ class We extends et {
2094
2089
  * value is calculated according to theme bg color.
2095
2090
  */
2096
2091
  get isDark() {
2097
- return !this.bgColor || Et(this.bgColor);
2092
+ return !this.bgColor || vt(this.bgColor);
2098
2093
  }
2099
2094
  get linkColor() {
2100
2095
  return this.get("linkColor");
@@ -2120,7 +2115,7 @@ class We extends et {
2120
2115
  */
2121
2116
  listen() {
2122
2117
  return w("theme_changed", (t) => {
2123
- this.set($t(t.theme_params));
2118
+ this.set(Mt(t.theme_params));
2124
2119
  });
2125
2120
  }
2126
2121
  /**
@@ -2136,7 +2131,7 @@ class We extends et {
2136
2131
  const _s = l(
2137
2132
  "themeParams",
2138
2133
  ({ themeParams: e, state: t = e, addCleanup: s }) => {
2139
- const n = new We(t);
2134
+ const n = new Oe(t);
2140
2135
  return s(n.listen()), n;
2141
2136
  }
2142
2137
  );
@@ -2145,7 +2140,7 @@ function fs(e = {}) {
2145
2140
  ...e,
2146
2141
  method: "web_app_request_theme",
2147
2142
  event: "theme_changed"
2148
- }).then($t);
2143
+ }).then(Mt);
2149
2144
  }
2150
2145
  class Ue extends st {
2151
2146
  constructor(s, n, r) {
@@ -2154,7 +2149,7 @@ class Ue extends st {
2154
2149
  * Checks if specified method parameter is supported by current component.
2155
2150
  */
2156
2151
  c(this, "supportsParam");
2157
- this.version = s, this.createRequestId = n, this.postEvent = r, this.supportsParam = Mt(s, {
2152
+ this.version = s, this.createRequestId = n, this.postEvent = r, this.supportsParam = Vt(s, {
2158
2153
  "openLink.tryInstantView": ["web_app_open_link", "try_instant_view"]
2159
2154
  });
2160
2155
  }
@@ -2208,7 +2203,7 @@ class Ue extends st {
2208
2203
  event: "clipboard_text_received",
2209
2204
  postEvent: this.postEvent,
2210
2205
  params: { req_id: s },
2211
- capture: mt(s)
2206
+ capture: bt(s)
2212
2207
  });
2213
2208
  return n;
2214
2209
  }
@@ -2216,7 +2211,7 @@ class Ue extends st {
2216
2211
  const gs = l(
2217
2212
  ({ version: e, postEvent: t, createRequestId: s }) => new Ue(e, s, t)
2218
2213
  );
2219
- async function Lt(e = {}) {
2214
+ async function $t(e = {}) {
2220
2215
  const {
2221
2216
  is_expanded: t,
2222
2217
  is_state_stable: s,
@@ -2232,10 +2227,10 @@ function x(e) {
2232
2227
  return e < 0 ? 0 : e;
2233
2228
  }
2234
2229
  class He extends et {
2235
- constructor({ postEvent: s, stableHeight: n, height: r, width: i, isExpanded: a }) {
2230
+ constructor({ postEvent: s, stableHeight: n, height: r, width: i, isExpanded: o }) {
2236
2231
  super({
2237
2232
  height: x(r),
2238
- isExpanded: a,
2233
+ isExpanded: o,
2239
2234
  stableHeight: x(n),
2240
2235
  width: x(i)
2241
2236
  });
@@ -2248,7 +2243,7 @@ class He extends et {
2248
2243
  * @param options - options to request fresh data.
2249
2244
  */
2250
2245
  async sync(s) {
2251
- const { isStateStable: n, ...r } = await Lt(s);
2246
+ const { isStateStable: n, ...r } = await $t(s);
2252
2247
  this.set({
2253
2248
  ...r,
2254
2249
  stableHeight: n ? r.height : this.get("stableHeight")
@@ -2300,13 +2295,13 @@ class He extends et {
2300
2295
  height: n,
2301
2296
  width: r,
2302
2297
  is_expanded: i,
2303
- is_state_stable: a
2304
- } = s, o = x(n);
2298
+ is_state_stable: o
2299
+ } = s, a = x(n);
2305
2300
  this.set({
2306
- height: o,
2301
+ height: a,
2307
2302
  isExpanded: i,
2308
2303
  width: x(r),
2309
- ...a ? { stableHeight: o } : {}
2304
+ ...o ? { stableHeight: a } : {}
2310
2305
  });
2311
2306
  });
2312
2307
  }
@@ -2343,20 +2338,20 @@ class He extends et {
2343
2338
  const ws = l(
2344
2339
  "viewport",
2345
2340
  async ({ state: e, platform: t, postEvent: s, addCleanup: n }) => {
2346
- let r = !1, i = 0, a = 0, o = 0;
2341
+ let r = !1, i = 0, o = 0, a = 0;
2347
2342
  if (e)
2348
- r = e.isExpanded, i = e.height, a = e.width, o = e.stableHeight;
2343
+ r = e.isExpanded, i = e.height, o = e.width, a = e.stableHeight;
2349
2344
  else if (["macos", "tdesktop", "unigram", "webk", "weba", "web"].includes(t))
2350
- r = !0, i = window.innerHeight, a = window.innerWidth, o = window.innerHeight;
2345
+ r = !0, i = window.innerHeight, o = window.innerWidth, a = window.innerHeight;
2351
2346
  else {
2352
- const u = await Lt({ timeout: 1e3, postEvent: s });
2353
- r = u.isExpanded, i = u.height, a = u.width, o = u.isStateStable ? i : 0;
2347
+ const u = await $t({ timeout: 1e3, postEvent: s });
2348
+ r = u.isExpanded, i = u.height, o = u.width, a = u.isStateStable ? i : 0;
2354
2349
  }
2355
2350
  const p = new He({
2356
2351
  postEvent: s,
2357
2352
  height: i,
2358
- width: a,
2359
- stableHeight: o,
2353
+ width: o,
2354
+ stableHeight: a,
2360
2355
  isExpanded: r
2361
2356
  });
2362
2357
  return n(p.listen()), p;
@@ -2366,21 +2361,21 @@ function m(e, t) {
2366
2361
  document.documentElement.style.setProperty(e, t);
2367
2362
  }
2368
2363
  function bs(e, t, s) {
2369
- s || (s = (o) => `--tg-${o}-color`);
2364
+ s || (s = (a) => `--tg-${a}-color`);
2370
2365
  const n = s("header"), r = s("bg"), i = () => {
2371
- const { headerColor: o } = e;
2372
- if (Y(o))
2373
- m(n, o);
2366
+ const { headerColor: a } = e;
2367
+ if (Y(a))
2368
+ m(n, a);
2374
2369
  else {
2375
2370
  const { bgColor: p, secondaryBgColor: u } = t;
2376
- o === "bg_color" && p ? m(n, p) : o === "secondary_bg_color" && u && m(n, u);
2371
+ a === "bg_color" && p ? m(n, p) : a === "secondary_bg_color" && u && m(n, u);
2377
2372
  }
2378
2373
  m(r, e.bgColor);
2379
- }, a = [
2374
+ }, o = [
2380
2375
  t.on("change", i),
2381
2376
  e.on("change", i)
2382
2377
  ];
2383
- return i(), () => a.forEach((o) => o());
2378
+ return i(), () => o.forEach((a) => a());
2384
2379
  }
2385
2380
  function ms(e, t) {
2386
2381
  t || (t = (n) => `--tg-theme-${n.replace(/[A-Z]/g, (r) => `-${r.toLowerCase()}`)}`);
@@ -2397,12 +2392,12 @@ function ys(e, t) {
2397
2392
  s,
2398
2393
  n,
2399
2394
  r
2400
- ] = ["height", "width", "stable-height"].map((u) => t(u)), i = () => m(s, `${e.height}px`), a = () => m(n, `${e.width}px`), o = () => m(r, `${e.stableHeight}px`), p = [
2395
+ ] = ["height", "width", "stable-height"].map((u) => t(u)), i = () => m(s, `${e.height}px`), o = () => m(n, `${e.width}px`), a = () => m(r, `${e.stableHeight}px`), p = [
2401
2396
  e.on("change:height", i),
2402
- e.on("change:width", a),
2403
- e.on("change:stableHeight", o)
2397
+ e.on("change:width", o),
2398
+ e.on("change:stableHeight", a)
2404
2399
  ];
2405
- return i(), a(), o(), () => p.forEach((u) => u());
2400
+ return i(), o(), a(), () => p.forEach((u) => u());
2406
2401
  }
2407
2402
  function vs(e = !0) {
2408
2403
  const t = [
@@ -2425,7 +2420,7 @@ function Es() {
2425
2420
  return typeof window > "u";
2426
2421
  }
2427
2422
  async function Ps() {
2428
- if (gt(window))
2423
+ if (ft(window))
2429
2424
  return !0;
2430
2425
  try {
2431
2426
  return await _({ method: "web_app_request_theme", event: "theme_changed", timeout: 100 }), !0;
@@ -2435,14 +2430,14 @@ async function Ps() {
2435
2430
  }
2436
2431
  function xs(e) {
2437
2432
  const t = typeof e == "string" ? tt(e) : e;
2438
- Nt(t);
2433
+ kt(t);
2439
2434
  function s(r) {
2440
2435
  if (typeof r == "string")
2441
2436
  try {
2442
- const { eventType: i } = _t(r);
2443
- i === "web_app_request_theme" && z("theme_changed", {
2444
- theme_params: JSON.parse(kt(t.themeParams))
2445
- }), i === "web_app_request_viewport" && z("viewport_changed", {
2437
+ const { eventType: i } = dt(r);
2438
+ i === "web_app_request_theme" && j("theme_changed", {
2439
+ theme_params: JSON.parse(qt(t.themeParams))
2440
+ }), i === "web_app_request_viewport" && j("viewport_changed", {
2446
2441
  width: window.innerWidth,
2447
2442
  height: window.innerHeight,
2448
2443
  is_state_stable: !0,
@@ -2451,14 +2446,14 @@ function xs(e) {
2451
2446
  } catch {
2452
2447
  }
2453
2448
  }
2454
- if (wt()) {
2449
+ if (gt()) {
2455
2450
  const r = window.parent.postMessage.bind(window.parent);
2456
2451
  window.parent.postMessage = (i) => {
2457
2452
  s(i), r(i);
2458
2453
  };
2459
2454
  return;
2460
2455
  }
2461
- if (ft(window)) {
2456
+ if (_t(window)) {
2462
2457
  const r = window.external.notify.bind(window.external);
2463
2458
  window.external.notify = (i) => {
2464
2459
  s(i), r(i);
@@ -2474,12 +2469,12 @@ function xs(e) {
2474
2469
  };
2475
2470
  }
2476
2471
  function Ge(e) {
2477
- return e instanceof V;
2472
+ return e instanceof D;
2478
2473
  }
2479
2474
  function Ss(e, t) {
2480
2475
  return Ge(e) && e.type === t;
2481
2476
  }
2482
- function B(e, t) {
2477
+ function L(e, t) {
2483
2478
  let s, n, r;
2484
2479
  return typeof e == "string" ? s = e : (s = e.pathname === void 0 ? t : e.pathname, n = e.params, r = e.id), Object.freeze({
2485
2480
  id: r || (Math.random() * 2 ** 14 | 0).toString(16),
@@ -2517,7 +2512,7 @@ class je {
2517
2512
  Xt,
2518
2513
  "Index should not be zero and higher or equal than history size."
2519
2514
  );
2520
- this.history = t.map((r) => B(r, ""));
2515
+ this.history = t.map((r) => L(r, ""));
2521
2516
  }
2522
2517
  /**
2523
2518
  * Allows this navigator to control the `BackButton` visibility state. It also tracks the
@@ -2536,7 +2531,7 @@ class je {
2536
2531
  * Prevents current navigator from controlling the BackButton visibility state.
2537
2532
  */
2538
2533
  detach() {
2539
- this.attached = !1, L("back_button_pressed", this.back);
2534
+ this.attached = !1, $("back_button_pressed", this.back);
2540
2535
  }
2541
2536
  /**
2542
2537
  * Goes to the next history item.
@@ -2592,14 +2587,14 @@ class je {
2592
2587
  * @param item - item to add.
2593
2588
  */
2594
2589
  push(t) {
2595
- this.hasNext && this.history.splice(this.index + 1), this.replaceAndMove(this.index + 1, B(t, this.current.pathname));
2590
+ this.hasNext && this.history.splice(this.index + 1), this.replaceAndMove(this.index + 1, L(t, this.current.pathname));
2596
2591
  }
2597
2592
  /**
2598
2593
  * Replaces the current history item.
2599
2594
  * @param item - item to replace the current item with.
2600
2595
  */
2601
2596
  replace(t) {
2602
- this.replaceAndMove(this.index, B(t, this.current.pathname));
2597
+ this.replaceAndMove(this.index, L(t, this.current.pathname));
2603
2598
  }
2604
2599
  /**
2605
2600
  * Sets history item by the specified index.
@@ -2629,7 +2624,7 @@ class je {
2629
2624
  this.postEvent("web_app_setup_back_button", { is_visible: !!this.index });
2630
2625
  }
2631
2626
  }
2632
- function O({
2627
+ function B({
2633
2628
  params: e,
2634
2629
  ...t
2635
2630
  }) {
@@ -2638,26 +2633,26 @@ function O({
2638
2633
  function A(e, t) {
2639
2634
  return e.startsWith(t) ? e : `${t}${e}`;
2640
2635
  }
2641
- function N(e) {
2636
+ function k(e) {
2642
2637
  return new URL(
2643
2638
  typeof e == "string" ? e : `${e.pathname || ""}${A(e.search || "", "?")}${A(e.hash || "", "#")}`,
2644
2639
  "http://a"
2645
2640
  );
2646
2641
  }
2647
- function D(e) {
2648
- const t = typeof e == "string" ? e.startsWith("/") : !!(e.pathname && e.pathname.startsWith("/")), s = N(e);
2642
+ function N(e) {
2643
+ const t = typeof e == "string" ? e.startsWith("/") : !!(e.pathname && e.pathname.startsWith("/")), s = k(e);
2649
2644
  return `${t ? s.pathname : s.pathname.slice(1)}${s.search}${s.hash}`;
2650
2645
  }
2651
2646
  function W(e, t, s) {
2652
2647
  let n, r;
2653
- typeof e == "string" ? n = e : (n = D(e), s = e.state, r = e.id);
2654
- const { pathname: i, search: a, hash: o } = new URL(n, `http://a${A(t, "/")}`);
2655
- return { id: r, pathname: i, params: { hash: o, search: a, state: s } };
2648
+ typeof e == "string" ? n = e : (n = N(e), s = e.state, r = e.id);
2649
+ const { pathname: i, search: o, hash: a } = new URL(n, `http://a${A(t, "/")}`);
2650
+ return { id: r, pathname: i, params: { hash: a, search: o, state: s } };
2656
2651
  }
2657
2652
  async function C(e) {
2658
2653
  return e === 0 ? !0 : Promise.race([
2659
2654
  new Promise((t) => {
2660
- const s = j("popstate", () => {
2655
+ const s = G("popstate", () => {
2661
2656
  s(), t(!0);
2662
2657
  });
2663
2658
  window.history.go(e);
@@ -2675,11 +2670,11 @@ async function ze() {
2675
2670
  for (; t; )
2676
2671
  t = await C(-1);
2677
2672
  }
2678
- function Bt(e) {
2679
- return N(e).pathname;
2673
+ function Lt(e) {
2674
+ return k(e).pathname;
2680
2675
  }
2681
- const ot = 0, U = 1, H = 2;
2682
- class Ot {
2676
+ const ot = 0, O = 1, U = 2;
2677
+ class Bt {
2683
2678
  constructor(t, s, { postEvent: n, hashMode: r = "classic", base: i } = {}) {
2684
2679
  c(this, "navigator");
2685
2680
  c(this, "ee", new T());
@@ -2696,7 +2691,7 @@ class Ot {
2696
2691
  c(this, "onPopState", ({ state: t }) => {
2697
2692
  if (t === null)
2698
2693
  return this.push(this.parsePath(window.location.href));
2699
- t === ot ? window.history.forward() : t === U && this.back(), t === H && this.forward();
2694
+ t === ot ? window.history.forward() : t === O && this.back(), t === U && this.forward();
2700
2695
  });
2701
2696
  /**
2702
2697
  * Underlying navigator change event listener.
@@ -2708,8 +2703,8 @@ class Ot {
2708
2703
  }) => {
2709
2704
  this.attached && await this.syncHistory(), this.ee.emit("change", {
2710
2705
  delta: n,
2711
- from: O(s),
2712
- to: O(t),
2706
+ from: B(s),
2707
+ to: B(t),
2713
2708
  navigator: this
2714
2709
  });
2715
2710
  });
@@ -2722,10 +2717,10 @@ class Ot {
2722
2717
  */
2723
2718
  c(this, "off", this.ee.off.bind(this.ee));
2724
2719
  this.navigator = new je(
2725
- t.map((a) => W(a, "/")),
2720
+ t.map((o) => W(o, "/")),
2726
2721
  s,
2727
2722
  n
2728
- ), this.navigator.on("change", this.onNavigatorChange), this.hashMode = r, this.base = Bt(i || "");
2723
+ ), this.navigator.on("change", this.onNavigatorChange), this.hashMode = r, this.base = Lt(i || "");
2729
2724
  }
2730
2725
  /**
2731
2726
  * Attaches current navigator to the browser history allowing navigator to manipulate it.
@@ -2809,7 +2804,7 @@ class Ot {
2809
2804
  * Navigation history.
2810
2805
  */
2811
2806
  get history() {
2812
- return this.navigator.history.map(O);
2807
+ return this.navigator.history.map(B);
2813
2808
  }
2814
2809
  /**
2815
2810
  * Path, including pathname, search and hash.
@@ -2823,7 +2818,7 @@ class Ot {
2823
2818
  * "/pathname?search#hash"
2824
2819
  */
2825
2820
  get path() {
2826
- return D(this);
2821
+ return N(this);
2827
2822
  }
2828
2823
  /**
2829
2824
  * Current pathname. Always starts with the slash.
@@ -2852,8 +2847,8 @@ class Ot {
2852
2847
  * // { pathname: '/tma', search: '?is=cool', hash: '#yeah' }
2853
2848
  */
2854
2849
  parsePath(t) {
2855
- let s = N(t);
2856
- return this.hashMode && (s = N(s.hash.slice(1))), {
2850
+ let s = k(t);
2851
+ return this.hashMode && (s = k(s.hash.slice(1))), {
2857
2852
  pathname: s.pathname,
2858
2853
  search: s.search,
2859
2854
  hash: s.hash
@@ -2873,7 +2868,7 @@ class Ot {
2873
2868
  * @param value - path presented as string or URLLike.
2874
2869
  */
2875
2870
  renderPath(t) {
2876
- const s = (this.base.length === 1 ? "" : this.base) + A(D(t), "/");
2871
+ const s = (this.base.length === 1 ? "" : this.base) + A(N(t), "/");
2877
2872
  return this.hashMode ? A(s.slice(1), this.hashMode === "classic" ? "#" : "#/") : s;
2878
2873
  }
2879
2874
  /**
@@ -2882,7 +2877,7 @@ class Ot {
2882
2877
  async syncHistory() {
2883
2878
  window.removeEventListener("popstate", this.onPopState);
2884
2879
  const { state: t } = this, s = this.renderPath(this);
2885
- await ze(), this.hasPrev && this.hasNext ? (window.history.replaceState(U, ""), window.history.pushState(t, "", s), window.history.pushState(H, ""), await C(-1)) : this.hasPrev ? (window.history.replaceState(U, ""), window.history.pushState(t, "", s)) : this.hasNext ? (window.history.replaceState(t, s), window.history.pushState(H, ""), await C(-1)) : (window.history.replaceState(ot, ""), window.history.pushState(t, "", s)), window.addEventListener("popstate", this.onPopState);
2880
+ await ze(), this.hasPrev && this.hasNext ? (window.history.replaceState(O, ""), window.history.pushState(t, "", s), window.history.pushState(U, ""), await C(-1)) : this.hasPrev ? (window.history.replaceState(O, ""), window.history.pushState(t, "", s)) : this.hasNext ? (window.history.replaceState(t, s), window.history.pushState(U, ""), await C(-1)) : (window.history.replaceState(ot, ""), window.history.pushState(t, "", s)), window.addEventListener("popstate", this.onPopState);
2886
2881
  }
2887
2882
  /**
2888
2883
  * Current query parameters.
@@ -2903,10 +2898,10 @@ class Ot {
2903
2898
  function Fe(e) {
2904
2899
  e || (e = {});
2905
2900
  const { href: t, hash: s } = window.location;
2906
- let n = D(
2901
+ let n = N(
2907
2902
  e.hashMode === null ? t : s.includes("?") ? s.slice(1) : `?${s.slice(1)}`
2908
2903
  );
2909
- const r = e.base ? Bt(e.base) : void 0;
2904
+ const r = e.base ? Lt(e.base) : void 0;
2910
2905
  if (r) {
2911
2906
  if (!n.startsWith(r))
2912
2907
  throw f(
@@ -2915,19 +2910,19 @@ function Fe(e) {
2915
2910
  );
2916
2911
  n = n.slice(r.length);
2917
2912
  }
2918
- return new Ot([n], 0, e);
2913
+ return new Bt([n], 0, e);
2919
2914
  }
2920
2915
  function Cs(e) {
2921
2916
  const t = e.match(/#(.+)/);
2922
2917
  return t ? t[1] : null;
2923
2918
  }
2924
2919
  function Je(e, t) {
2925
- if (Dt()) {
2920
+ if (Nt()) {
2926
2921
  const s = sessionStorage.getItem(e);
2927
2922
  if (s)
2928
2923
  try {
2929
2924
  const { index: n, history: r } = JSON.parse(s);
2930
- return new Ot(r, n, t);
2925
+ return new Bt(r, n, t);
2931
2926
  } catch (n) {
2932
2927
  console.error("Unable to restore hash navigator state.", n);
2933
2928
  }
@@ -2945,7 +2940,7 @@ export {
2945
2940
  le as BackButton,
2946
2941
  je as BasicNavigator,
2947
2942
  Pe as BiometryManager,
2948
- Ot as BrowserNavigator,
2943
+ Bt as BrowserNavigator,
2949
2944
  Se as ClosingBehavior,
2950
2945
  Ae as CloudStorage,
2951
2946
  te as ERR_INVALID_PATH_BASE,
@@ -2955,7 +2950,7 @@ export {
2955
2950
  Kt as ERR_NAVIGATION_HISTORY_EMPTY,
2956
2951
  Xt as ERR_NAVIGATION_INDEX_INVALID,
2957
2952
  Ze as ERR_NAVIGATION_ITEM_INVALID,
2958
- pt as ERR_PARSE,
2953
+ ht as ERR_PARSE,
2959
2954
  Ke as ERR_SSR_INIT,
2960
2955
  Yt as ERR_TIMED_OUT,
2961
2956
  Zt as ERR_UNEXPECTED_TYPE,
@@ -2968,9 +2963,9 @@ export {
2968
2963
  Me as MiniApp,
2969
2964
  Le as Popup,
2970
2965
  Be as QRScanner,
2971
- V as SDKError,
2972
- Oe as SettingsButton,
2973
- We as ThemeParams,
2966
+ D as SDKError,
2967
+ We as SettingsButton,
2968
+ Oe as ThemeParams,
2974
2969
  Ue as Utils,
2975
2970
  He as Viewport,
2976
2971
  Re as array,
@@ -2978,15 +2973,15 @@ export {
2978
2973
  ms as bindThemeParamsCSSVars,
2979
2974
  ys as bindViewportCSSVars,
2980
2975
  b as boolean,
2981
- mt as captureSameReq,
2982
- F as classNames,
2976
+ bt as captureSameReq,
2977
+ z as classNames,
2983
2978
  ce as compareVersions,
2984
2979
  Fe as createBrowserNavigatorFromLocation,
2985
2980
  pe as createPostEvent,
2986
- N as createSafeURL,
2987
- xt as date,
2981
+ k as createSafeURL,
2982
+ Pt as date,
2988
2983
  Cs as getHash,
2989
- Bt as getPathname,
2984
+ Lt as getPathname,
2990
2985
  es as initBackButton,
2991
2986
  ss as initBiometryManager,
2992
2987
  ns as initClosingBehavior,
@@ -3005,9 +3000,9 @@ export {
3005
3000
  ws as initViewport,
3006
3001
  vs as initWeb,
3007
3002
  S as invokeCustomMethod,
3008
- Et as isColorDark,
3009
- wt as isIframe,
3010
- Dt as isPageReload,
3003
+ vt as isColorDark,
3004
+ gt as isIframe,
3005
+ Nt as isPageReload,
3011
3006
  Y as isRGB,
3012
3007
  ee as isRGBShort,
3013
3008
  Ge as isSDKError,
@@ -3018,21 +3013,21 @@ export {
3018
3013
  ts as mergeClassNames,
3019
3014
  xs as mockTelegramEnv,
3020
3015
  y as number,
3021
- L as off,
3016
+ $ as off,
3022
3017
  w as on,
3023
3018
  as as parseInitData,
3024
3019
  tt as parseLaunchParams,
3025
- $t as parseThemeParams,
3020
+ Mt as parseThemeParams,
3026
3021
  R as postEvent,
3027
3022
  _ as request,
3028
3023
  xe as requestBiometryInfo,
3029
3024
  fs as requestThemeParams,
3030
- Lt as requestViewport,
3025
+ $t as requestViewport,
3031
3026
  ye as retrieveLaunchParams,
3032
- dt as rgb,
3027
+ lt as rgb,
3033
3028
  X as searchParams,
3034
3029
  me as serializeLaunchParams,
3035
- kt as serializeThemeParams,
3030
+ qt as serializeThemeParams,
3036
3031
  m as setCSSVar,
3037
3032
  Ye as setDebug,
3038
3033
  Xe as setTargetOrigin,
@@ -3040,9 +3035,9 @@ export {
3040
3035
  Ht as subscribe,
3041
3036
  v as supports,
3042
3037
  he as targetOrigin,
3043
- lt as toRGB,
3038
+ ut as toRGB,
3044
3039
  ct as unsubscribe,
3045
- D as urlToPath,
3046
- vt as withTimeout
3040
+ N as urlToPath,
3041
+ yt as withTimeout
3047
3042
  };
3048
3043
  //# sourceMappingURL=index.js.map