@tma.js/sdk 2.2.0 → 2.3.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,21 +1,21 @@
1
- var Vt = Object.defineProperty;
2
- var $t = (e, t, s) => t in e ? Vt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s;
3
- var c = (e, t, s) => ($t(e, typeof t != "symbol" ? t + "" : t, s), s);
4
- function it(e, t) {
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;
3
+ var c = (e, t, s) => (Ut(e, typeof t != "symbol" ? t + "" : t, s), s);
4
+ function at(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 ot(e) {
12
- const t = M(), { count: s } = t;
13
- t.unsubscribe(e), s && !t.count && ne();
11
+ function ct(e) {
12
+ const t = $(), { count: s } = t;
13
+ t.unsubscribe(e), s && !t.count && ae();
14
14
  }
15
- function Mt(e) {
16
- return M().subscribe(e), () => ot(e);
15
+ function Ht(e) {
16
+ return $().subscribe(e), () => ct(e);
17
17
  }
18
- class Lt {
18
+ class Gt {
19
19
  constructor(t, s = {}) {
20
20
  this.scope = t, this.options = s;
21
21
  }
@@ -55,21 +55,21 @@ class Lt {
55
55
  this.print("log", ...t);
56
56
  }
57
57
  }
58
- const F = new Lt("SDK", {
58
+ const J = new Gt("SDK", {
59
59
  bgColor: "forestgreen",
60
60
  textColor: "white"
61
61
  });
62
62
  let G = !1;
63
- const et = ({ name: e, payload: t }) => {
64
- F.log("Event received:", t ? { name: e, payload: t } : { name: e });
63
+ const nt = ({ name: e, payload: t }) => {
64
+ J.log("Event received:", t ? { name: e, payload: t } : { name: e });
65
65
  };
66
66
  function Ye(e) {
67
- G !== e && (G = e, e ? Mt(et) : ot(et));
67
+ G !== e && (G = e, e ? Ht(nt) : ct(nt));
68
68
  }
69
- function Bt(...e) {
70
- G && F.log(...e);
69
+ function jt(...e) {
70
+ G && J.log(...e);
71
71
  }
72
- class R {
72
+ class T {
73
73
  constructor() {
74
74
  c(this, "listeners", /* @__PURE__ */ new Map());
75
75
  c(this, "listenersCount", 0);
@@ -144,7 +144,7 @@ class R {
144
144
  function j(e, t, s) {
145
145
  return window.addEventListener(e, t, s), () => window.removeEventListener(e, t, s);
146
146
  }
147
- function at(...e) {
147
+ function ht(...e) {
148
148
  let t = !1;
149
149
  const s = [...e];
150
150
  return [
@@ -163,11 +163,11 @@ class V extends Error {
163
163
  function f(e, t, s) {
164
164
  return new V(e, t, s);
165
165
  }
166
- const Ot = "ERR_METHOD_UNSUPPORTED", Ut = "ERR_METHOD_PARAMETER_UNSUPPORTED", Wt = "ERR_UNKNOWN_ENV", Ht = "ERR_INVOKE_CUSTOM_METHOD_RESPONSE", Gt = "ERR_TIMED_OUT", jt = "ERR_UNEXPECTED_TYPE", ct = "ERR_PARSE", zt = "ERR_NAVIGATION_LIST_EMPTY", Ft = "ERR_NAVIGATION_CURSOR_INVALID", Ze = "ERR_NAVIGATION_ITEM_INVALID", Ke = "ERR_SSR_INIT", Jt = "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", 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";
167
167
  function E() {
168
- return f(jt, "Value has unexpected type");
168
+ return f(Zt, "Value has unexpected type");
169
169
  }
170
- class $ {
170
+ class M {
171
171
  constructor(t, s, n) {
172
172
  this.parser = t, this.isOptional = s, this.type = n;
173
173
  }
@@ -183,7 +183,7 @@ class $ {
183
183
  return this.parser(t);
184
184
  } catch (s) {
185
185
  throw f(
186
- ct,
186
+ pt,
187
187
  `Unable to parse value${this.type ? ` as ${this.type}` : ""}`,
188
188
  s
189
189
  );
@@ -194,9 +194,9 @@ class $ {
194
194
  }
195
195
  }
196
196
  function P(e, t) {
197
- return () => new $(e, !1, t);
197
+ return () => new M(e, !1, t);
198
198
  }
199
- const w = P((e) => {
199
+ const b = P((e) => {
200
200
  if (typeof e == "boolean")
201
201
  return e;
202
202
  const t = String(e);
@@ -206,7 +206,7 @@ const w = P((e) => {
206
206
  return !1;
207
207
  throw E();
208
208
  }, "boolean");
209
- function ht(e, t) {
209
+ function ut(e, t) {
210
210
  const s = {};
211
211
  for (const n in e) {
212
212
  const r = e[n];
@@ -223,21 +223,21 @@ function ht(e, t) {
223
223
  const o = a(t(i));
224
224
  o !== void 0 && (s[n] = o);
225
225
  } catch (o) {
226
- throw f(ct, `Unable to parse field "${n}"`, o);
226
+ throw f(pt, `Unable to parse field "${n}"`, o);
227
227
  }
228
228
  }
229
229
  return s;
230
230
  }
231
- function J(e) {
231
+ function Q(e) {
232
232
  let t = e;
233
233
  if (typeof t == "string" && (t = JSON.parse(t)), typeof t != "object" || t === null || Array.isArray(t))
234
234
  throw E();
235
235
  return t;
236
236
  }
237
237
  function d(e, t) {
238
- return new $((s) => {
239
- const n = J(s);
240
- return ht(e, (r) => n[r]);
238
+ return new M((s) => {
239
+ const n = Q(s);
240
+ return ut(e, (r) => n[r]);
241
241
  }, !1, t);
242
242
  }
243
243
  const y = P((e) => {
@@ -250,17 +250,17 @@ const y = P((e) => {
250
250
  }
251
251
  throw E();
252
252
  }, "number");
253
- function Q(e) {
253
+ function Y(e) {
254
254
  return /^#[\da-f]{6}$/i.test(e);
255
255
  }
256
- function Qt(e) {
256
+ function ee(e) {
257
257
  return /^#[\da-f]{3}$/i.test(e);
258
258
  }
259
- function pt(e) {
259
+ function lt(e) {
260
260
  const t = e.replace(/\s/g, "").toLowerCase();
261
- if (Q(t))
261
+ if (Y(t))
262
262
  return t;
263
- if (Qt(t)) {
263
+ if (ee(t)) {
264
264
  let n = "#";
265
265
  for (let r = 0; r < 3; r += 1)
266
266
  n += t[1 + r].repeat(2);
@@ -278,26 +278,26 @@ const h = P((e) => {
278
278
  if (typeof e == "string" || typeof e == "number")
279
279
  return e.toString();
280
280
  throw E();
281
- }, "string"), ut = P((e) => pt(h().parse(e)), "rgb");
282
- function Yt(e) {
281
+ }, "string"), dt = P((e) => lt(h().parse(e)), "rgb");
282
+ function _t(e) {
283
283
  return d({
284
284
  eventType: h(),
285
285
  eventData: (t) => t
286
286
  }).parse(e);
287
287
  }
288
- function Zt() {
288
+ function se() {
289
289
  ["TelegramGameProxy_receiveEvent", "TelegramGameProxy", "Telegram"].forEach((e) => {
290
290
  delete window[e];
291
291
  });
292
292
  }
293
- function Kt(e, t) {
293
+ function z(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.
297
297
  source: window.parent
298
298
  }));
299
299
  }
300
- function Xt() {
300
+ function ne() {
301
301
  [
302
302
  ["TelegramGameProxy_receiveEvent"],
303
303
  // Windows Phone.
@@ -309,14 +309,14 @@ function Xt() {
309
309
  let t = window;
310
310
  e.forEach((s, n, r) => {
311
311
  if (n === r.length - 1) {
312
- t[s] = Kt;
312
+ t[s] = z;
313
313
  return;
314
314
  }
315
315
  s in t || (t[s] = {}), t = t[s];
316
316
  });
317
317
  });
318
318
  }
319
- const te = {
319
+ const re = {
320
320
  clipboard_text_received: d({
321
321
  req_id: h(),
322
322
  data: (e) => e === null ? e : h().optional().parse(e)
@@ -338,26 +338,26 @@ const te = {
338
338
  qr_text_received: d({ data: h().optional() }),
339
339
  theme_changed: d({
340
340
  theme_params: (e) => {
341
- const t = ut().optional();
342
- return Object.entries(J(e)).reduce((s, [n, r]) => (s[n] = t.parse(r), s), {});
341
+ const t = dt().optional();
342
+ return Object.entries(Q(e)).reduce((s, [n, r]) => (s[n] = t.parse(r), s), {});
343
343
  }
344
344
  }),
345
345
  viewport_changed: d({
346
346
  height: y(),
347
347
  width: (e) => e == null ? window.innerWidth : y().parse(e),
348
- is_state_stable: w(),
349
- is_expanded: w()
348
+ is_state_stable: b(),
349
+ is_expanded: b()
350
350
  }),
351
351
  write_access_requested: d({ status: h() })
352
352
  };
353
- function ee() {
354
- const e = new R(), t = new R();
353
+ function ie() {
354
+ const e = new T(), t = new T();
355
355
  t.subscribe((n) => {
356
356
  e.emit("event", { name: n.event, payload: n.args[0] });
357
- }), Xt();
358
- const [, s] = at(
357
+ }), ne();
358
+ const [, s] = ht(
359
359
  // Don't forget to remove created handlers.
360
- Zt,
360
+ se,
361
361
  // Add "resize" event listener to make sure, we always have fresh viewport information.
362
362
  // Desktop version of Telegram is sometimes not sending the viewport_changed
363
363
  // event. For example, when the MainButton is shown. That's why we should
@@ -378,16 +378,16 @@ function ee() {
378
378
  return;
379
379
  let r;
380
380
  try {
381
- r = Yt(n.data);
381
+ r = _t(n.data);
382
382
  } catch {
383
383
  return;
384
384
  }
385
- const { eventType: i, eventData: a } = r, o = te[i];
385
+ const { eventType: i, eventData: a } = r, o = re[i];
386
386
  try {
387
387
  const p = o ? o.parse(a) : a;
388
388
  t.emit(...p ? [i, p] : [i]);
389
389
  } catch (p) {
390
- F.error(
390
+ J.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
@@ -412,9 +412,9 @@ function ee() {
412
412
  }
413
413
  }, s];
414
414
  }
415
- const [se, ne] = it(
415
+ const [oe, ae] = at(
416
416
  (e) => {
417
- const [t, s] = ee(), n = t.off.bind(t);
417
+ const [t, s] = ie(), n = t.off.bind(t);
418
418
  return t.off = (r, i) => {
419
419
  const { count: a } = t;
420
420
  n(r, i), a && !t.count && e();
@@ -422,19 +422,19 @@ const [se, ne] = it(
422
422
  },
423
423
  ([, e]) => e()
424
424
  );
425
- function M() {
426
- return se()[0];
425
+ function $() {
426
+ return oe()[0];
427
427
  }
428
428
  function L(e, t) {
429
- M().off(e, t);
429
+ $().off(e, t);
430
430
  }
431
- function b(e, t, s) {
432
- return M().on(e, t, s);
431
+ function w(e, t, s) {
432
+ return $().on(e, t, s);
433
433
  }
434
434
  function I(e) {
435
435
  return typeof e == "object" && e !== null && !Array.isArray(e);
436
436
  }
437
- function re(e, t) {
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
440
  const a = parseInt(s[i] || "0", 10), o = parseInt(n[i] || "0", 10);
@@ -444,7 +444,7 @@ function re(e, t) {
444
444
  return 0;
445
445
  }
446
446
  function g(e, t) {
447
- return re(e, t) <= 0;
447
+ return ce(e, t) <= 0;
448
448
  }
449
449
  function v(e, t, s) {
450
450
  if (typeof s == "string") {
@@ -497,74 +497,74 @@ function v(e, t, s) {
497
497
  ].includes(e);
498
498
  }
499
499
  }
500
- function ie(e) {
500
+ function ft(e) {
501
501
  return "external" in e && I(e.external) && "notify" in e.external && typeof e.external.notify == "function";
502
502
  }
503
- function lt(e) {
503
+ function gt(e) {
504
504
  return "TelegramWebviewProxy" in e && I(e.TelegramWebviewProxy) && "postEvent" in e.TelegramWebviewProxy && typeof e.TelegramWebviewProxy.postEvent == "function";
505
505
  }
506
- function oe() {
506
+ function wt() {
507
507
  try {
508
508
  return window.self !== window.top;
509
509
  } catch {
510
510
  return !0;
511
511
  }
512
512
  }
513
- let dt = "https://web.telegram.org";
513
+ let bt = "https://web.telegram.org";
514
514
  function Xe(e) {
515
- dt = e;
515
+ bt = e;
516
516
  }
517
- function ae() {
518
- return dt;
517
+ function he() {
518
+ return bt;
519
519
  }
520
- function A(e, t, s) {
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
- const { targetOrigin: i = ae() } = n;
524
- if (Bt("Posting event:", r ? { event: e, data: r } : { event: e }), oe()) {
523
+ const { targetOrigin: i = he() } = n;
524
+ if (jt("Posting event:", r ? { event: e, data: r } : { event: e }), wt()) {
525
525
  window.parent.postMessage(JSON.stringify({ eventType: e, eventData: r }), i);
526
526
  return;
527
527
  }
528
- if (ie(window)) {
528
+ if (ft(window)) {
529
529
  window.external.notify(JSON.stringify({ eventType: e, eventData: r }));
530
530
  return;
531
531
  }
532
- if (lt(window)) {
532
+ if (gt(window)) {
533
533
  window.TelegramWebviewProxy.postEvent(e, JSON.stringify(r));
534
534
  return;
535
535
  }
536
536
  throw f(
537
- Wt,
537
+ Jt,
538
538
  "Unable to determine current environment and possible way to send event. You are probably trying to use Mini Apps method outside of Telegram application environment."
539
539
  );
540
540
  }
541
- function ce(e) {
541
+ function pe(e) {
542
542
  return (t, s) => {
543
543
  if (!v(t, e))
544
- throw f(Ot, `Method "${t}" is unsupported in Mini Apps version ${e}`);
544
+ throw f(zt, `Method "${t}" is unsupported in Mini Apps version ${e}`);
545
545
  if (I(s)) {
546
546
  let n;
547
547
  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 && !v(t, n, e))
548
548
  throw f(
549
- Ut,
549
+ Ft,
550
550
  `Parameter "${n}" of "${t}" method is unsupported in Mini Apps version ${e}`
551
551
  );
552
552
  }
553
- return A(t, s);
553
+ return R(t, s);
554
554
  };
555
555
  }
556
- function _t(e) {
556
+ function mt(e) {
557
557
  return ({ req_id: t }) => t === e;
558
558
  }
559
- function ft(e) {
560
- return f(Gt, `Timeout reached: ${e}ms`);
559
+ function yt(e) {
560
+ return f(Yt, `Timeout reached: ${e}ms`);
561
561
  }
562
- function gt(e, t) {
562
+ function vt(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(ft(t));
567
+ n(yt(t));
568
568
  }, t);
569
569
  })
570
570
  ]);
@@ -577,13 +577,13 @@ async function _(e) {
577
577
  method: n,
578
578
  event: r,
579
579
  capture: i,
580
- postEvent: a = A,
580
+ postEvent: a = R,
581
581
  timeout: o
582
582
  } = e, p = (Array.isArray(r) ? r : [r]).map(
583
- (u) => b(u, (k) => (!i || i(k)) && t(k))
583
+ (u) => w(u, (k) => (!i || i(k)) && t(k))
584
584
  );
585
585
  try {
586
- return a(n, e.params), await (o ? gt(s, o) : s);
586
+ return a(n, e.params), await (o ? vt(s, o) : s);
587
587
  } finally {
588
588
  p.forEach((u) => u());
589
589
  }
@@ -601,30 +601,30 @@ async function S(e, t, s, n = {}) {
601
601
  params: t,
602
602
  req_id: s
603
603
  },
604
- capture: _t(s)
604
+ capture: mt(s)
605
605
  });
606
606
  if (i)
607
- throw f(Ht, i);
607
+ throw f(Qt, i);
608
608
  return r;
609
609
  }
610
- function z(...e) {
610
+ function F(...e) {
611
611
  return e.map((t) => {
612
612
  if (typeof t == "string")
613
613
  return t;
614
614
  if (I(t))
615
- return z(Object.entries(t).map((s) => s[1] && s[0]));
615
+ return F(Object.entries(t).map((s) => s[1] && s[0]));
616
616
  if (Array.isArray(t))
617
- return z(...t);
617
+ return F(...t);
618
618
  }).filter(Boolean).join(" ");
619
619
  }
620
620
  function ts(...e) {
621
621
  return e.reduce((t, s) => (I(s) && Object.entries(s).forEach(([n, r]) => {
622
- const i = z(t[n], r);
622
+ const i = F(t[n], r);
623
623
  i.length && (t[n] = i);
624
624
  }), t), {});
625
625
  }
626
- function bt(e) {
627
- const t = pt(e);
626
+ function Et(e) {
627
+ const t = lt(e);
628
628
  return Math.sqrt(
629
629
  [0.299, 0.587, 0.114].reduce((s, n, r) => {
630
630
  const i = parseInt(t.slice(1 + r * 2, 1 + (r + 1) * 2), 16);
@@ -632,9 +632,9 @@ function bt(e) {
632
632
  }, 0)
633
633
  ) < 120;
634
634
  }
635
- class he {
635
+ class ue {
636
636
  constructor(t) {
637
- c(this, "ee", new R());
637
+ c(this, "ee", new T());
638
638
  /**
639
639
  * Adds new event listener.
640
640
  */
@@ -662,7 +662,7 @@ class he {
662
662
  return this.state[t];
663
663
  }
664
664
  }
665
- class Y {
665
+ class Z {
666
666
  constructor(t) {
667
667
  c(this, "state");
668
668
  /**
@@ -677,23 +677,23 @@ class Y {
677
677
  * Clones the current state.
678
678
  */
679
679
  c(this, "clone");
680
- this.state = new he(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);
680
+ 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
681
  }
682
682
  }
683
- function wt(e, t) {
683
+ function Pt(e, t) {
684
684
  return (s) => v(t[s], e);
685
685
  }
686
- class Z extends Y {
686
+ class K extends Z {
687
687
  constructor(s, n, r) {
688
688
  super(s);
689
689
  /**
690
690
  * @returns True, if specified method is supported by the current component.
691
691
  */
692
692
  c(this, "supports");
693
- this.supports = wt(n, r);
693
+ this.supports = Pt(n, r);
694
694
  }
695
695
  }
696
- class pe extends Z {
696
+ class le extends K {
697
697
  constructor(s, n, r) {
698
698
  super({ isVisible: s }, n, {
699
699
  show: "web_app_setup_back_button",
@@ -704,7 +704,7 @@ class pe extends Z {
704
704
  * @param event - event to listen.
705
705
  * @param listener - listener to add.
706
706
  */
707
- c(this, "on", (s, n) => s === "click" ? b("back_button_pressed", n) : this.state.on(s, n));
707
+ c(this, "on", (s, n) => s === "click" ? w("back_button_pressed", n) : this.state.on(s, n));
708
708
  /**
709
709
  * Removes the event listener.
710
710
  * @param event - event to listen.
@@ -735,19 +735,19 @@ class pe extends Z {
735
735
  this.isVisible = !0;
736
736
  }
737
737
  }
738
- const mt = P((e) => e instanceof Date ? e : new Date(y().parse(e) * 1e3), "Date");
739
- function K(e, t) {
740
- return new $((s) => {
738
+ const xt = P((e) => e instanceof Date ? e : new Date(y().parse(e) * 1e3), "Date");
739
+ function X(e, t) {
740
+ return new M((s) => {
741
741
  if (typeof s != "string" && !(s instanceof URLSearchParams))
742
742
  throw E();
743
743
  const n = typeof s == "string" ? new URLSearchParams(s) : s;
744
- return ht(e, (r) => {
744
+ return ut(e, (r) => {
745
745
  const i = n.get(r);
746
746
  return i === null ? void 0 : i;
747
747
  });
748
748
  }, !1, t);
749
749
  }
750
- const ue = d({
750
+ const de = d({
751
751
  id: y(),
752
752
  type: h(),
753
753
  title: h(),
@@ -756,13 +756,13 @@ const ue = d({
756
756
  from: "photo_url"
757
757
  },
758
758
  username: h().optional()
759
- }, "Chat").optional(), st = d({
759
+ }, "Chat").optional(), rt = d({
760
760
  addedToAttachmentMenu: {
761
- type: w().optional(),
761
+ type: b().optional(),
762
762
  from: "added_to_attachment_menu"
763
763
  },
764
764
  allowsWriteToPm: {
765
- type: w().optional(),
765
+ type: b().optional(),
766
766
  from: "allows_write_to_pm"
767
767
  },
768
768
  firstName: {
@@ -771,11 +771,11 @@ const ue = d({
771
771
  },
772
772
  id: y(),
773
773
  isBot: {
774
- type: w().optional(),
774
+ type: b().optional(),
775
775
  from: "is_bot"
776
776
  },
777
777
  isPremium: {
778
- type: w().optional(),
778
+ type: b().optional(),
779
779
  from: "is_premium"
780
780
  },
781
781
  languageCode: {
@@ -792,17 +792,17 @@ const ue = d({
792
792
  },
793
793
  username: h().optional()
794
794
  }, "User").optional();
795
- function yt() {
796
- return K({
795
+ function St() {
796
+ return X({
797
797
  authDate: {
798
- type: mt(),
798
+ type: xt(),
799
799
  from: "auth_date"
800
800
  },
801
801
  canSendAfter: {
802
802
  type: y().optional(),
803
803
  from: "can_send_after"
804
804
  },
805
- chat: ue,
805
+ chat: de,
806
806
  chatInstance: {
807
807
  type: h().optional(),
808
808
  from: "chat_instance"
@@ -816,35 +816,35 @@ function yt() {
816
816
  type: h().optional(),
817
817
  from: "query_id"
818
818
  },
819
- receiver: st,
819
+ receiver: rt,
820
820
  startParam: {
821
821
  type: h().optional(),
822
822
  from: "start_param"
823
823
  },
824
- user: st
824
+ user: rt
825
825
  }, "InitData");
826
826
  }
827
- function le(e) {
827
+ function _e(e) {
828
828
  return e.replace(/_[a-z]/g, (t) => t[1].toUpperCase());
829
829
  }
830
- function de(e) {
830
+ function fe(e) {
831
831
  return e.replace(/[A-Z]/g, (t) => `_${t.toLowerCase()}`);
832
832
  }
833
- const vt = P(
833
+ const Ct = P(
834
834
  (e) => {
835
- const t = ut().optional();
836
- return Object.entries(J(e)).reduce((s, [n, r]) => (s[le(n)] = t.parse(r), s), {});
835
+ const t = dt().optional();
836
+ return Object.entries(Q(e)).reduce((s, [n, r]) => (s[_e(n)] = t.parse(r), s), {});
837
837
  },
838
838
  "ThemeParams"
839
839
  );
840
- function Et(e) {
841
- return K({
840
+ function tt(e) {
841
+ return X({
842
842
  botInline: {
843
- type: w().optional(),
843
+ type: b().optional(),
844
844
  from: "tgWebAppBotInline"
845
845
  },
846
846
  initData: {
847
- type: yt().optional(),
847
+ type: St().optional(),
848
848
  from: "tgWebAppData"
849
849
  },
850
850
  initDataRaw: {
@@ -856,7 +856,7 @@ function Et(e) {
856
856
  from: "tgWebAppPlatform"
857
857
  },
858
858
  showSettings: {
859
- type: w().optional(),
859
+ type: b().optional(),
860
860
  from: "tgWebAppShowSettings"
861
861
  },
862
862
  startParam: {
@@ -864,7 +864,7 @@ function Et(e) {
864
864
  from: "tgWebAppStartParam"
865
865
  },
866
866
  themeParams: {
867
- type: vt(),
867
+ type: Ct(),
868
868
  from: "tgWebAppThemeParams"
869
869
  },
870
870
  version: {
@@ -873,47 +873,47 @@ function Et(e) {
873
873
  }
874
874
  }).parse(e);
875
875
  }
876
- function Pt(e) {
877
- return Et(
876
+ function Tt(e) {
877
+ return tt(
878
878
  e.replace(/^[^?#]*[?#]/, "").replace(/[?#]/g, "&")
879
879
  );
880
880
  }
881
- function _e() {
882
- return Pt(window.location.href);
881
+ function ge() {
882
+ return Tt(window.location.href);
883
883
  }
884
- function xt() {
884
+ function Rt() {
885
885
  return performance.getEntriesByType("navigation")[0];
886
886
  }
887
- function fe() {
888
- const e = xt();
887
+ function we() {
888
+ const e = Rt();
889
889
  if (!e)
890
890
  throw new Error("Unable to get first navigation entry.");
891
- return Pt(e.name);
891
+ return Tt(e.name);
892
892
  }
893
- function St(e) {
893
+ function At(e) {
894
894
  return `tma.js/${e.replace(/[A-Z]/g, (t) => `-${t.toLowerCase()}`)}`;
895
895
  }
896
- function Ct(e, t) {
897
- sessionStorage.setItem(St(e), JSON.stringify(t));
896
+ function It(e, t) {
897
+ sessionStorage.setItem(At(e), JSON.stringify(t));
898
898
  }
899
- function Rt(e) {
900
- const t = sessionStorage.getItem(St(e));
899
+ function qt(e) {
900
+ const t = sessionStorage.getItem(At(e));
901
901
  try {
902
902
  return t ? JSON.parse(t) : void 0;
903
903
  } catch {
904
904
  }
905
905
  }
906
- function ge() {
907
- return Et(Rt("launchParams") || "");
906
+ function be() {
907
+ return tt(qt("launchParams") || "");
908
908
  }
909
- function be(e) {
909
+ function kt(e) {
910
910
  return JSON.stringify(
911
911
  Object.fromEntries(
912
- Object.entries(e).map(([t, s]) => [de(t), s])
912
+ Object.entries(e).map(([t, s]) => [fe(t), s])
913
913
  )
914
914
  );
915
915
  }
916
- function we(e) {
916
+ function me(e) {
917
917
  const {
918
918
  initDataRaw: t,
919
919
  themeParams: s,
@@ -923,56 +923,56 @@ function we(e) {
923
923
  startParam: a,
924
924
  botInline: o
925
925
  } = e, p = new URLSearchParams();
926
- return p.set("tgWebAppPlatform", n), p.set("tgWebAppThemeParams", be(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();
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();
927
927
  }
928
- function me(e) {
929
- Ct("launchParams", we(e));
928
+ function Nt(e) {
929
+ It("launchParams", me(e));
930
930
  }
931
931
  function ye() {
932
932
  for (const e of [
933
933
  // Try to retrieve launch parameters from the current location. This method can return
934
934
  // nothing in case, location was changed and then page was reloaded.
935
- _e,
935
+ ge,
936
936
  // Then, try using the lower level API - window.performance.
937
- fe,
937
+ we,
938
938
  // Finally, try to extract launch parameters from the session storage.
939
- ge
939
+ be
940
940
  ])
941
941
  try {
942
942
  const t = e();
943
- return me(t), t;
943
+ return Nt(t), t;
944
944
  } catch {
945
945
  }
946
946
  throw new Error("Unable to retrieve launch parameters from any known source.");
947
947
  }
948
- function At() {
949
- const e = xt();
948
+ function Dt() {
949
+ const e = Rt();
950
950
  return !!(e && e.type === "reload");
951
951
  }
952
952
  function ve() {
953
953
  let e = 0;
954
954
  return () => (e += 1).toString();
955
955
  }
956
- const [Ee] = it(ve);
956
+ const [Ee] = at(ve);
957
957
  function l(e, t) {
958
958
  return () => {
959
959
  const s = ye(), n = {
960
960
  ...s,
961
- postEvent: ce(s.version),
961
+ postEvent: pe(s.version),
962
962
  createRequestId: Ee()
963
963
  };
964
964
  if (typeof e == "function")
965
965
  return e(n);
966
- const [r, i, a] = at(), o = t({
966
+ const [r, i, a] = ht(), o = t({
967
967
  ...n,
968
968
  // State should only be passed only in case, current page was reloaded. If we don't add
969
969
  // this check, state restoration will work improperly in the web version of Telegram,
970
970
  // when we are always working in the same "session" (tab).
971
- state: At() ? Rt(e) : void 0,
971
+ state: Dt() ? qt(e) : void 0,
972
972
  addCleanup: r
973
973
  }), p = (u) => (a || r(
974
974
  u.on("change", (k) => {
975
- Ct(e, k);
975
+ It(e, k);
976
976
  })
977
977
  ), u);
978
978
  return [
@@ -985,8 +985,8 @@ const es = l("backButton", ({
985
985
  postEvent: e,
986
986
  version: t,
987
987
  state: s = { isVisible: !1 }
988
- }) => new pe(s.isVisible, t, e));
989
- class q extends Z {
988
+ }) => new le(s.isVisible, t, e));
989
+ class q extends K {
990
990
  constructor() {
991
991
  super(...arguments);
992
992
  /**
@@ -999,7 +999,7 @@ class q extends Z {
999
999
  c(this, "off", this.state.off.bind(this.state));
1000
1000
  }
1001
1001
  }
1002
- function Tt(e) {
1002
+ function Vt(e) {
1003
1003
  const t = e.available ? e : {
1004
1004
  available: !1,
1005
1005
  device_id: "",
@@ -1099,7 +1099,7 @@ class Pe extends q {
1099
1099
  event: "biometry_info_received",
1100
1100
  params: { reason: s || "" }
1101
1101
  }).then((r) => {
1102
- const i = Tt(r);
1102
+ const i = Vt(r);
1103
1103
  return this.set(i), i.accessGranted;
1104
1104
  }).finally(() => this.accessPromise = void 0)), this.accessPromise;
1105
1105
  }
@@ -1132,7 +1132,7 @@ class Pe extends q {
1132
1132
  }
1133
1133
  }
1134
1134
  async function xe(e) {
1135
- return Tt(
1135
+ return Vt(
1136
1136
  await _({
1137
1137
  ...e || {},
1138
1138
  method: "web_app_biometry_get_info",
@@ -1154,7 +1154,7 @@ const ss = l(
1154
1154
  postEvent: e
1155
1155
  })
1156
1156
  );
1157
- class X extends Y {
1157
+ class et extends Z {
1158
1158
  constructor() {
1159
1159
  super(...arguments);
1160
1160
  /**
@@ -1167,7 +1167,7 @@ class X extends Y {
1167
1167
  c(this, "off", this.state.off.bind(this.state));
1168
1168
  }
1169
1169
  }
1170
- class Se extends X {
1170
+ class Se extends et {
1171
1171
  constructor(t, s) {
1172
1172
  super({ isConfirmationNeeded: t }), this.postEvent = s;
1173
1173
  }
@@ -1201,13 +1201,13 @@ const ns = l(
1201
1201
  state: t = { isConfirmationNeeded: !1 }
1202
1202
  }) => new Se(t.isConfirmationNeeded, e)
1203
1203
  );
1204
- class tt {
1204
+ class st {
1205
1205
  constructor(t, s) {
1206
1206
  /**
1207
1207
  * @returns True, if specified method is supported by the current component.
1208
1208
  */
1209
1209
  c(this, "supports");
1210
- this.supports = wt(t, s);
1210
+ this.supports = Pt(t, s);
1211
1211
  }
1212
1212
  }
1213
1213
  function Ce(e) {
@@ -1222,7 +1222,7 @@ function Ce(e) {
1222
1222
  }
1223
1223
  throw E();
1224
1224
  }
1225
- class Re extends $ {
1225
+ class Te extends M {
1226
1226
  constructor(s, n, r) {
1227
1227
  super(Ce, n, r);
1228
1228
  c(this, "itemParser");
@@ -1242,13 +1242,13 @@ class Re extends $ {
1242
1242
  return this.itemParser = typeof s == "function" ? s : s.parse.bind(s), this;
1243
1243
  }
1244
1244
  }
1245
- function Ae(e) {
1246
- return new Re((t) => t, !1, e);
1245
+ function Re(e) {
1246
+ return new Te((t) => t, !1, e);
1247
1247
  }
1248
- function nt(e, t) {
1248
+ function it(e, t) {
1249
1249
  return Object.fromEntries(e.map((s) => [s, t]));
1250
1250
  }
1251
- class Te extends tt {
1251
+ class Ae extends st {
1252
1252
  constructor(t, s, n) {
1253
1253
  super(t, {
1254
1254
  delete: "web_app_invoke_custom_method",
@@ -1276,7 +1276,7 @@ class Te extends tt {
1276
1276
  * @param options - request execution options.
1277
1277
  */
1278
1278
  async getKeys(t = {}) {
1279
- return Ae().of(h()).parse(
1279
+ return Re().of(h()).parse(
1280
1280
  await S(
1281
1281
  "getStorageKeys",
1282
1282
  {},
@@ -1288,13 +1288,13 @@ class Te extends tt {
1288
1288
  async get(t, s = {}) {
1289
1289
  const n = Array.isArray(t) ? t : [t];
1290
1290
  if (!n.length)
1291
- return nt(n, "");
1291
+ return it(n, "");
1292
1292
  const r = await S(
1293
1293
  "getStorageValues",
1294
1294
  { keys: n },
1295
1295
  this.createRequestId(),
1296
1296
  { ...s, postEvent: this.postEvent }
1297
- ), i = d(nt(n, h()), "CloudStorageData").parse(r);
1297
+ ), i = d(it(n, h()), "CloudStorageData").parse(r);
1298
1298
  return Array.isArray(t) ? i : i[t];
1299
1299
  }
1300
1300
  /**
@@ -1313,9 +1313,9 @@ class Te extends tt {
1313
1313
  }
1314
1314
  }
1315
1315
  const rs = l(
1316
- ({ createRequestId: e, postEvent: t, version: s }) => new Te(s, e, t)
1316
+ ({ createRequestId: e, postEvent: t, version: s }) => new Ae(s, e, t)
1317
1317
  );
1318
- class Ie extends tt {
1318
+ class Ie extends st {
1319
1319
  constructor(t, s) {
1320
1320
  super(t, {
1321
1321
  impactOccurred: "web_app_trigger_haptic_feedback",
@@ -1437,7 +1437,7 @@ const os = l(
1437
1437
  ({ initData: e }) => e ? new qe(e) : void 0
1438
1438
  );
1439
1439
  function as(e) {
1440
- return yt().parse(e);
1440
+ return St().parse(e);
1441
1441
  }
1442
1442
  class ke extends q {
1443
1443
  constructor(t, s, n) {
@@ -1486,7 +1486,7 @@ class ke extends q {
1486
1486
  const cs = l(
1487
1487
  ({ version: e, postEvent: t }) => new ke(!1, e, t)
1488
1488
  );
1489
- class Ne extends Y {
1489
+ class Ne extends Z {
1490
1490
  constructor({ postEvent: s, ...n }) {
1491
1491
  super(n);
1492
1492
  c(this, "postEvent");
@@ -1495,7 +1495,7 @@ class Ne extends Y {
1495
1495
  * @param event - event to listen.
1496
1496
  * @param listener - listener to add.
1497
1497
  */
1498
- c(this, "on", (s, n) => s === "click" ? b("main_button_pressed", n) : this.state.on(s, n));
1498
+ c(this, "on", (s, n) => s === "click" ? w("main_button_pressed", n) : this.state.on(s, n));
1499
1499
  /**
1500
1500
  * Removes the event listener.
1501
1501
  * @param event - event to listen.
@@ -1647,7 +1647,7 @@ const hs = l(
1647
1647
  }) => new Ne({ ...s, postEvent: e })
1648
1648
  );
1649
1649
  function De() {
1650
- return K({
1650
+ return X({
1651
1651
  contact: d({
1652
1652
  userId: {
1653
1653
  type: y(),
@@ -1667,13 +1667,13 @@ function De() {
1667
1667
  }
1668
1668
  }),
1669
1669
  authDate: {
1670
- type: mt(),
1670
+ type: xt(),
1671
1671
  from: "auth_date"
1672
1672
  },
1673
1673
  hash: h()
1674
1674
  }, "RequestedContact");
1675
1675
  }
1676
- function It(e, t) {
1676
+ function Mt(e, t) {
1677
1677
  return (s) => {
1678
1678
  const [n, r] = t[s];
1679
1679
  return v(n, r, e);
@@ -1684,7 +1684,7 @@ function Ve(e) {
1684
1684
  setTimeout(t, e);
1685
1685
  });
1686
1686
  }
1687
- class $e extends q {
1687
+ class Me extends q {
1688
1688
  constructor({ postEvent: s, createRequestId: n, version: r, botInline: i, ...a }) {
1689
1689
  super(a, r, {
1690
1690
  requestPhoneAccess: "web_app_request_phone",
@@ -1704,7 +1704,7 @@ class $e extends q {
1704
1704
  c(this, "supportsParam");
1705
1705
  this.createRequestId = n, this.postEvent = s, this.botInline = i;
1706
1706
  const o = this.supports.bind(this);
1707
- this.supports = (p) => o(p) ? p !== "switchInlineQuery" || i : !1, this.supportsParam = It(r, {
1707
+ this.supports = (p) => o(p) ? p !== "switchInlineQuery" || i : !1, this.supportsParam = Mt(r, {
1708
1708
  "setHeaderColor.color": ["web_app_set_header_color", "color"]
1709
1709
  });
1710
1710
  }
@@ -1755,7 +1755,7 @@ class $e extends q {
1755
1755
  * True if current Mini App background color is recognized as dark.
1756
1756
  */
1757
1757
  get isDark() {
1758
- return bt(this.bgColor);
1758
+ return Et(this.bgColor);
1759
1759
  }
1760
1760
  /**
1761
1761
  * Informs the Telegram app that the Mini App is ready to be displayed.
@@ -1784,7 +1784,7 @@ class $e extends q {
1784
1784
  throw new Error("Access denied.");
1785
1785
  const r = Date.now() + s;
1786
1786
  let i = 50;
1787
- return gt(async () => {
1787
+ return vt(async () => {
1788
1788
  for (; Date.now() < r; ) {
1789
1789
  try {
1790
1790
  return await this.getRequestedContact();
@@ -1792,7 +1792,7 @@ class $e extends q {
1792
1792
  }
1793
1793
  await Ve(i), i += 50;
1794
1794
  }
1795
- throw ft(s);
1795
+ throw yt(s);
1796
1796
  }, s);
1797
1797
  }
1798
1798
  /**
@@ -1847,7 +1847,7 @@ class $e extends q {
1847
1847
  * @param color - color key or RGB color.
1848
1848
  */
1849
1849
  setHeaderColor(s) {
1850
- this.postEvent("web_app_set_header_color", Q(s) ? { color: s } : { color_key: s }), this.set("headerColor", s);
1850
+ this.postEvent("web_app_set_header_color", Y(s) ? { color: s } : { color_key: s }), this.set("headerColor", s);
1851
1851
  }
1852
1852
  /**
1853
1853
  * Updates current Mini App background color.
@@ -1885,9 +1885,9 @@ const ps = l(
1885
1885
  headerColor: e.headerBgColor || "#000000"
1886
1886
  },
1887
1887
  ...n
1888
- }) => new $e({ ...n, ...s, botInline: t })
1888
+ }) => new Me({ ...n, ...s, botInline: t })
1889
1889
  );
1890
- function Me(e) {
1890
+ function $e(e) {
1891
1891
  const t = e.message.trim(), s = (e.title || "").trim(), n = e.buttons || [];
1892
1892
  let r;
1893
1893
  if (s.length > 64)
@@ -1944,7 +1944,7 @@ class Le extends q {
1944
1944
  event: "popup_closed",
1945
1945
  method: "web_app_open_popup",
1946
1946
  postEvent: this.postEvent,
1947
- params: Me(t)
1947
+ params: $e(t)
1948
1948
  });
1949
1949
  return s;
1950
1950
  } finally {
@@ -2002,7 +2002,7 @@ class Be extends q {
2002
2002
  const ls = l(
2003
2003
  ({ version: e, postEvent: t }) => new Be(!1, e, t)
2004
2004
  );
2005
- class Oe extends Z {
2005
+ class Oe extends K {
2006
2006
  constructor(s, n, r) {
2007
2007
  super({ isVisible: s }, n, {
2008
2008
  show: "web_app_setup_settings_button",
@@ -2013,7 +2013,7 @@ class Oe extends Z {
2013
2013
  * @param event - event to listen.
2014
2014
  * @param listener - listener to add.
2015
2015
  */
2016
- c(this, "on", (s, n) => s === "click" ? b("settings_button_pressed", n) : this.state.on(s, n));
2016
+ c(this, "on", (s, n) => s === "click" ? w("settings_button_pressed", n) : this.state.on(s, n));
2017
2017
  /**
2018
2018
  * Removes the event listener.
2019
2019
  * @param event - event to listen.
@@ -2052,10 +2052,10 @@ const ds = l(
2052
2052
  state: s = { isVisible: !1 }
2053
2053
  }) => new Oe(s.isVisible, e, t)
2054
2054
  );
2055
- function qt(e) {
2056
- return vt().parse(e);
2055
+ function $t(e) {
2056
+ return Ct().parse(e);
2057
2057
  }
2058
- class Ue extends X {
2058
+ class We extends et {
2059
2059
  /**
2060
2060
  * @since v6.10
2061
2061
  */
@@ -2094,7 +2094,7 @@ class Ue extends X {
2094
2094
  * value is calculated according to theme bg color.
2095
2095
  */
2096
2096
  get isDark() {
2097
- return !this.bgColor || bt(this.bgColor);
2097
+ return !this.bgColor || Et(this.bgColor);
2098
2098
  }
2099
2099
  get linkColor() {
2100
2100
  return this.get("linkColor");
@@ -2119,8 +2119,8 @@ class Ue extends X {
2119
2119
  * @returns Function to stop listening.
2120
2120
  */
2121
2121
  listen() {
2122
- return b("theme_changed", (t) => {
2123
- this.set(qt(t.theme_params));
2122
+ return w("theme_changed", (t) => {
2123
+ this.set($t(t.theme_params));
2124
2124
  });
2125
2125
  }
2126
2126
  /**
@@ -2136,7 +2136,7 @@ class Ue extends X {
2136
2136
  const _s = l(
2137
2137
  "themeParams",
2138
2138
  ({ themeParams: e, state: t = e, addCleanup: s }) => {
2139
- const n = new Ue(t);
2139
+ const n = new We(t);
2140
2140
  return s(n.listen()), n;
2141
2141
  }
2142
2142
  );
@@ -2145,16 +2145,16 @@ function fs(e = {}) {
2145
2145
  ...e,
2146
2146
  method: "web_app_request_theme",
2147
2147
  event: "theme_changed"
2148
- }).then(qt);
2148
+ }).then($t);
2149
2149
  }
2150
- class We extends tt {
2150
+ class Ue extends st {
2151
2151
  constructor(s, n, r) {
2152
2152
  super(s, { readTextFromClipboard: "web_app_read_text_from_clipboard" });
2153
2153
  /**
2154
2154
  * Checks if specified method parameter is supported by current component.
2155
2155
  */
2156
2156
  c(this, "supportsParam");
2157
- this.version = s, this.createRequestId = n, this.postEvent = r, this.supportsParam = It(s, {
2157
+ this.version = s, this.createRequestId = n, this.postEvent = r, this.supportsParam = Mt(s, {
2158
2158
  "openLink.tryInstantView": ["web_app_open_link", "try_instant_view"]
2159
2159
  });
2160
2160
  }
@@ -2208,15 +2208,15 @@ class We extends tt {
2208
2208
  event: "clipboard_text_received",
2209
2209
  postEvent: this.postEvent,
2210
2210
  params: { req_id: s },
2211
- capture: _t(s)
2211
+ capture: mt(s)
2212
2212
  });
2213
2213
  return n;
2214
2214
  }
2215
2215
  }
2216
2216
  const gs = l(
2217
- ({ version: e, postEvent: t, createRequestId: s }) => new We(e, s, t)
2217
+ ({ version: e, postEvent: t, createRequestId: s }) => new Ue(e, s, t)
2218
2218
  );
2219
- async function kt(e = {}) {
2219
+ async function Lt(e = {}) {
2220
2220
  const {
2221
2221
  is_expanded: t,
2222
2222
  is_state_stable: s,
@@ -2231,7 +2231,7 @@ async function kt(e = {}) {
2231
2231
  function x(e) {
2232
2232
  return e < 0 ? 0 : e;
2233
2233
  }
2234
- class He extends X {
2234
+ class He extends et {
2235
2235
  constructor({ postEvent: s, stableHeight: n, height: r, width: i, isExpanded: a }) {
2236
2236
  super({
2237
2237
  height: x(r),
@@ -2248,7 +2248,7 @@ class He extends X {
2248
2248
  * @param options - options to request fresh data.
2249
2249
  */
2250
2250
  async sync(s) {
2251
- const { isStateStable: n, ...r } = await kt(s);
2251
+ const { isStateStable: n, ...r } = await Lt(s);
2252
2252
  this.set({
2253
2253
  ...r,
2254
2254
  stableHeight: n ? r.height : this.get("stableHeight")
@@ -2295,7 +2295,7 @@ class He extends X {
2295
2295
  * @returns Function to stop listening.
2296
2296
  */
2297
2297
  listen() {
2298
- return b("viewport_changed", (s) => {
2298
+ return w("viewport_changed", (s) => {
2299
2299
  const {
2300
2300
  height: n,
2301
2301
  width: r,
@@ -2340,7 +2340,7 @@ class He extends X {
2340
2340
  return this.stableHeight === this.height;
2341
2341
  }
2342
2342
  }
2343
- const bs = l(
2343
+ const ws = l(
2344
2344
  "viewport",
2345
2345
  async ({ state: e, platform: t, postEvent: s, addCleanup: n }) => {
2346
2346
  let r = !1, i = 0, a = 0, o = 0;
@@ -2349,7 +2349,7 @@ const bs = l(
2349
2349
  else if (["macos", "tdesktop", "unigram", "webk", "weba", "web"].includes(t))
2350
2350
  r = !0, i = window.innerHeight, a = window.innerWidth, o = window.innerHeight;
2351
2351
  else {
2352
- const u = await kt({ timeout: 1e3, postEvent: s });
2352
+ const u = await Lt({ timeout: 1e3, postEvent: s });
2353
2353
  r = u.isExpanded, i = u.height, a = u.width, o = u.isStateStable ? i : 0;
2354
2354
  }
2355
2355
  const p = new He({
@@ -2365,11 +2365,11 @@ const bs = l(
2365
2365
  function m(e, t) {
2366
2366
  document.documentElement.style.setProperty(e, t);
2367
2367
  }
2368
- function ws(e, t, s) {
2368
+ function bs(e, t, s) {
2369
2369
  s || (s = (o) => `--tg-${o}-color`);
2370
2370
  const n = s("header"), r = s("bg"), i = () => {
2371
2371
  const { headerColor: o } = e;
2372
- if (Q(o))
2372
+ if (Y(o))
2373
2373
  m(n, o);
2374
2374
  else {
2375
2375
  const { bgColor: p, secondaryBgColor: u } = t;
@@ -2406,26 +2406,26 @@ function ys(e, t) {
2406
2406
  }
2407
2407
  function vs(e = !0) {
2408
2408
  const t = [
2409
- b("reload_iframe", () => {
2410
- A("iframe_will_reload"), window.location.reload();
2409
+ w("reload_iframe", () => {
2410
+ R("iframe_will_reload"), window.location.reload();
2411
2411
  })
2412
2412
  ], s = () => t.forEach((n) => n());
2413
2413
  if (e) {
2414
2414
  const n = document.createElement("style");
2415
2415
  n.id = "telegram-custom-styles", document.head.appendChild(n), t.push(
2416
- b("set_custom_style", (r) => {
2416
+ w("set_custom_style", (r) => {
2417
2417
  n.innerHTML = r;
2418
2418
  }),
2419
2419
  () => document.head.removeChild(n)
2420
2420
  );
2421
2421
  }
2422
- return A("iframe_ready", { reload_supported: !0 }), s;
2422
+ return R("iframe_ready", { reload_supported: !0 }), s;
2423
2423
  }
2424
2424
  function Es() {
2425
2425
  return typeof window > "u";
2426
2426
  }
2427
2427
  async function Ps() {
2428
- if (lt(window))
2428
+ if (gt(window))
2429
2429
  return !0;
2430
2430
  try {
2431
2431
  return await _({ method: "web_app_request_theme", event: "theme_changed", timeout: 100 }), !0;
@@ -2433,10 +2433,50 @@ async function Ps() {
2433
2433
  return !1;
2434
2434
  }
2435
2435
  }
2436
+ function xs(e) {
2437
+ const t = typeof e == "string" ? tt(e) : e;
2438
+ Nt(t);
2439
+ function s(r) {
2440
+ if (typeof r == "string")
2441
+ 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", {
2446
+ width: window.innerWidth,
2447
+ height: window.innerHeight,
2448
+ is_state_stable: !0,
2449
+ is_expanded: !0
2450
+ });
2451
+ } catch {
2452
+ }
2453
+ }
2454
+ if (wt()) {
2455
+ const r = window.parent.postMessage.bind(window.parent);
2456
+ window.parent.postMessage = (i) => {
2457
+ s(i), r(i);
2458
+ };
2459
+ return;
2460
+ }
2461
+ if (ft(window)) {
2462
+ const r = window.external.notify.bind(window.external);
2463
+ window.external.notify = (i) => {
2464
+ s(i), r(i);
2465
+ };
2466
+ return;
2467
+ }
2468
+ const n = window.TelegramWebviewProxy;
2469
+ window.TelegramWebviewProxy = {
2470
+ ...n || {},
2471
+ postEvent(...r) {
2472
+ s(JSON.stringify({ eventType: r[0], eventData: r[1] })), n && n.postEvent(...r);
2473
+ }
2474
+ };
2475
+ }
2436
2476
  function Ge(e) {
2437
2477
  return e instanceof V;
2438
2478
  }
2439
- function xs(e, t) {
2479
+ function Ss(e, t) {
2440
2480
  return Ge(e) && e.type === t;
2441
2481
  }
2442
2482
  function B(e, t) {
@@ -2448,12 +2488,12 @@ function B(e, t) {
2448
2488
  });
2449
2489
  }
2450
2490
  class je {
2451
- constructor(t, s, n = A) {
2491
+ constructor(t, s, n = R) {
2452
2492
  /**
2453
2493
  * Navigation history.
2454
2494
  */
2455
2495
  c(this, "history");
2456
- c(this, "ee", new R());
2496
+ c(this, "ee", new T());
2457
2497
  /**
2458
2498
  * True, if current navigator is currently attached.
2459
2499
  */
@@ -2471,10 +2511,10 @@ class je {
2471
2511
  */
2472
2512
  c(this, "off", this.ee.off.bind(this.ee));
2473
2513
  if (this._index = s, this.postEvent = n, t.length === 0)
2474
- throw f(zt, "History should not be empty.");
2514
+ throw f(Kt, "History should not be empty.");
2475
2515
  if (s < 0 || s >= t.length)
2476
2516
  throw f(
2477
- Ft,
2517
+ Xt,
2478
2518
  "Index should not be zero and higher or equal than history size."
2479
2519
  );
2480
2520
  this.history = t.map((r) => B(r, ""));
@@ -2484,7 +2524,7 @@ class je {
2484
2524
  * `BackButton` clicks and calls the `back` method.
2485
2525
  */
2486
2526
  attach() {
2487
- this.attached || (this.attached = !0, this.sync(), b("back_button_pressed", this.back));
2527
+ this.attached || (this.attached = !0, this.sync(), w("back_button_pressed", this.back));
2488
2528
  }
2489
2529
  /**
2490
2530
  * Currently active history item.
@@ -2595,12 +2635,12 @@ function O({
2595
2635
  }) {
2596
2636
  return { ...e || { hash: "", search: "" }, ...t };
2597
2637
  }
2598
- function T(e, t) {
2638
+ function A(e, t) {
2599
2639
  return e.startsWith(t) ? e : `${t}${e}`;
2600
2640
  }
2601
2641
  function N(e) {
2602
2642
  return new URL(
2603
- typeof e == "string" ? e : `${e.pathname || ""}${T(e.search || "", "?")}${T(e.hash || "", "#")}`,
2643
+ typeof e == "string" ? e : `${e.pathname || ""}${A(e.search || "", "?")}${A(e.hash || "", "#")}`,
2604
2644
  "http://a"
2605
2645
  );
2606
2646
  }
@@ -2608,10 +2648,10 @@ function D(e) {
2608
2648
  const t = typeof e == "string" ? e.startsWith("/") : !!(e.pathname && e.pathname.startsWith("/")), s = N(e);
2609
2649
  return `${t ? s.pathname : s.pathname.slice(1)}${s.search}${s.hash}`;
2610
2650
  }
2611
- function U(e, t, s) {
2651
+ function W(e, t, s) {
2612
2652
  let n, r;
2613
2653
  typeof e == "string" ? n = e : (n = D(e), s = e.state, r = e.id);
2614
- const { pathname: i, search: a, hash: o } = new URL(n, `http://a${T(t, "/")}`);
2654
+ const { pathname: i, search: a, hash: o } = new URL(n, `http://a${A(t, "/")}`);
2615
2655
  return { id: r, pathname: i, params: { hash: o, search: a, state: s } };
2616
2656
  }
2617
2657
  async function C(e) {
@@ -2635,14 +2675,14 @@ async function ze() {
2635
2675
  for (; t; )
2636
2676
  t = await C(-1);
2637
2677
  }
2638
- function Nt(e) {
2678
+ function Bt(e) {
2639
2679
  return N(e).pathname;
2640
2680
  }
2641
- const rt = 0, W = 1, H = 2;
2642
- class Dt {
2681
+ const ot = 0, U = 1, H = 2;
2682
+ class Ot {
2643
2683
  constructor(t, s, { postEvent: n, hashMode: r = "classic", base: i } = {}) {
2644
2684
  c(this, "navigator");
2645
- c(this, "ee", new R());
2685
+ c(this, "ee", new T());
2646
2686
  c(this, "hashMode");
2647
2687
  c(this, "base");
2648
2688
  /**
@@ -2656,7 +2696,7 @@ class Dt {
2656
2696
  c(this, "onPopState", ({ state: t }) => {
2657
2697
  if (t === null)
2658
2698
  return this.push(this.parsePath(window.location.href));
2659
- t === rt ? window.history.forward() : t === W && this.back(), t === H && this.forward();
2699
+ t === ot ? window.history.forward() : t === U && this.back(), t === H && this.forward();
2660
2700
  });
2661
2701
  /**
2662
2702
  * Underlying navigator change event listener.
@@ -2682,10 +2722,10 @@ class Dt {
2682
2722
  */
2683
2723
  c(this, "off", this.ee.off.bind(this.ee));
2684
2724
  this.navigator = new je(
2685
- t.map((a) => U(a, "/")),
2725
+ t.map((a) => W(a, "/")),
2686
2726
  s,
2687
2727
  n
2688
- ), this.navigator.on("change", this.onNavigatorChange), this.hashMode = r, this.base = Nt(i || "");
2728
+ ), this.navigator.on("change", this.onNavigatorChange), this.hashMode = r, this.base = Bt(i || "");
2689
2729
  }
2690
2730
  /**
2691
2731
  * Attaches current navigator to the browser history allowing navigator to manipulate it.
@@ -2820,11 +2860,11 @@ class Dt {
2820
2860
  };
2821
2861
  }
2822
2862
  push(t, s) {
2823
- const n = U(t, this.path), { state: r = s } = n.params;
2863
+ const n = W(t, this.path), { state: r = s } = n.params;
2824
2864
  this.navigator.push({ ...n, params: { ...n.params, state: r } });
2825
2865
  }
2826
2866
  replace(t, s) {
2827
- const n = U(t, this.path), { state: r = s } = n.params;
2867
+ const n = W(t, this.path), { state: r = s } = n.params;
2828
2868
  this.navigator.replace({ ...n, params: { ...n.params, state: r } });
2829
2869
  }
2830
2870
  /**
@@ -2833,8 +2873,8 @@ class Dt {
2833
2873
  * @param value - path presented as string or URLLike.
2834
2874
  */
2835
2875
  renderPath(t) {
2836
- const s = (this.base.length === 1 ? "" : this.base) + T(D(t), "/");
2837
- return this.hashMode ? T(s.slice(1), this.hashMode === "classic" ? "#" : "#/") : s;
2876
+ const s = (this.base.length === 1 ? "" : this.base) + A(D(t), "/");
2877
+ return this.hashMode ? A(s.slice(1), this.hashMode === "classic" ? "#" : "#/") : s;
2838
2878
  }
2839
2879
  /**
2840
2880
  * Synchronizes current navigator state with browser history.
@@ -2842,7 +2882,7 @@ class Dt {
2842
2882
  async syncHistory() {
2843
2883
  window.removeEventListener("popstate", this.onPopState);
2844
2884
  const { state: t } = this, s = this.renderPath(this);
2845
- await ze(), this.hasPrev && this.hasNext ? (window.history.replaceState(W, ""), window.history.pushState(t, "", s), window.history.pushState(H, ""), await C(-1)) : this.hasPrev ? (window.history.replaceState(W, ""), window.history.pushState(t, "", s)) : this.hasNext ? (window.history.replaceState(t, s), window.history.pushState(H, ""), await C(-1)) : (window.history.replaceState(rt, ""), window.history.pushState(t, "", s)), window.addEventListener("popstate", this.onPopState);
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);
2846
2886
  }
2847
2887
  /**
2848
2888
  * Current query parameters.
@@ -2866,35 +2906,35 @@ function Fe(e) {
2866
2906
  let n = D(
2867
2907
  e.hashMode === null ? t : s.includes("?") ? s.slice(1) : `?${s.slice(1)}`
2868
2908
  );
2869
- const r = e.base ? Nt(e.base) : void 0;
2909
+ const r = e.base ? Bt(e.base) : void 0;
2870
2910
  if (r) {
2871
2911
  if (!n.startsWith(r))
2872
2912
  throw f(
2873
- Jt,
2913
+ te,
2874
2914
  `Path "${n}" expected to be starting with "${r}"`
2875
2915
  );
2876
2916
  n = n.slice(r.length);
2877
2917
  }
2878
- return new Dt([n], 0, e);
2918
+ return new Ot([n], 0, e);
2879
2919
  }
2880
- function Ss(e) {
2920
+ function Cs(e) {
2881
2921
  const t = e.match(/#(.+)/);
2882
2922
  return t ? t[1] : null;
2883
2923
  }
2884
2924
  function Je(e, t) {
2885
- if (At()) {
2925
+ if (Dt()) {
2886
2926
  const s = sessionStorage.getItem(e);
2887
2927
  if (s)
2888
2928
  try {
2889
2929
  const { index: n, history: r } = JSON.parse(s);
2890
- return new Dt(r, n, t);
2930
+ return new Ot(r, n, t);
2891
2931
  } catch (n) {
2892
2932
  console.error("Unable to restore hash navigator state.", n);
2893
2933
  }
2894
2934
  }
2895
2935
  return Fe(t);
2896
2936
  }
2897
- function Cs(e, t) {
2937
+ function Ts(e, t) {
2898
2938
  const s = Je(e, t), n = () => sessionStorage.setItem(e, JSON.stringify({
2899
2939
  index: s.index,
2900
2940
  history: s.history
@@ -2902,51 +2942,51 @@ function Cs(e, t) {
2902
2942
  return s.on("change", n), n(), s;
2903
2943
  }
2904
2944
  export {
2905
- pe as BackButton,
2945
+ le as BackButton,
2906
2946
  je as BasicNavigator,
2907
2947
  Pe as BiometryManager,
2908
- Dt as BrowserNavigator,
2948
+ Ot as BrowserNavigator,
2909
2949
  Se as ClosingBehavior,
2910
- Te as CloudStorage,
2911
- Jt as ERR_INVALID_PATH_BASE,
2912
- Ht as ERR_INVOKE_CUSTOM_METHOD_RESPONSE,
2913
- Ut as ERR_METHOD_PARAMETER_UNSUPPORTED,
2914
- Ot as ERR_METHOD_UNSUPPORTED,
2915
- zt as ERR_NAVIGATION_HISTORY_EMPTY,
2916
- Ft as ERR_NAVIGATION_INDEX_INVALID,
2950
+ Ae as CloudStorage,
2951
+ te as ERR_INVALID_PATH_BASE,
2952
+ Qt as ERR_INVOKE_CUSTOM_METHOD_RESPONSE,
2953
+ Ft as ERR_METHOD_PARAMETER_UNSUPPORTED,
2954
+ zt as ERR_METHOD_UNSUPPORTED,
2955
+ Kt as ERR_NAVIGATION_HISTORY_EMPTY,
2956
+ Xt as ERR_NAVIGATION_INDEX_INVALID,
2917
2957
  Ze as ERR_NAVIGATION_ITEM_INVALID,
2918
- ct as ERR_PARSE,
2958
+ pt as ERR_PARSE,
2919
2959
  Ke as ERR_SSR_INIT,
2920
- Gt as ERR_TIMED_OUT,
2921
- jt as ERR_UNEXPECTED_TYPE,
2922
- Wt as ERR_UNKNOWN_ENV,
2923
- R as EventEmitter,
2960
+ Yt as ERR_TIMED_OUT,
2961
+ Zt as ERR_UNEXPECTED_TYPE,
2962
+ Jt as ERR_UNKNOWN_ENV,
2963
+ T as EventEmitter,
2924
2964
  Ie as HapticFeedback,
2925
2965
  qe as InitData,
2926
2966
  ke as Invoice,
2927
2967
  Ne as MainButton,
2928
- $e as MiniApp,
2968
+ Me as MiniApp,
2929
2969
  Le as Popup,
2930
2970
  Be as QRScanner,
2931
2971
  V as SDKError,
2932
2972
  Oe as SettingsButton,
2933
- Ue as ThemeParams,
2934
- We as Utils,
2973
+ We as ThemeParams,
2974
+ Ue as Utils,
2935
2975
  He as Viewport,
2936
- Ae as array,
2937
- ws as bindMiniAppCSSVars,
2976
+ Re as array,
2977
+ bs as bindMiniAppCSSVars,
2938
2978
  ms as bindThemeParamsCSSVars,
2939
2979
  ys as bindViewportCSSVars,
2940
- w as boolean,
2941
- _t as captureSameReq,
2942
- z as classNames,
2943
- re as compareVersions,
2980
+ b as boolean,
2981
+ mt as captureSameReq,
2982
+ F as classNames,
2983
+ ce as compareVersions,
2944
2984
  Fe as createBrowserNavigatorFromLocation,
2945
- ce as createPostEvent,
2985
+ pe as createPostEvent,
2946
2986
  N as createSafeURL,
2947
- mt as date,
2948
- Ss as getHash,
2949
- Nt as getPathname,
2987
+ xt as date,
2988
+ Cs as getHash,
2989
+ Bt as getPathname,
2950
2990
  es as initBackButton,
2951
2991
  ss as initBiometryManager,
2952
2992
  ns as initClosingBehavior,
@@ -2956,52 +2996,53 @@ export {
2956
2996
  cs as initInvoice,
2957
2997
  hs as initMainButton,
2958
2998
  ps as initMiniApp,
2959
- Cs as initNavigator,
2999
+ Ts as initNavigator,
2960
3000
  us as initPopup,
2961
3001
  ls as initQRScanner,
2962
3002
  ds as initSettingsButton,
2963
3003
  _s as initThemeParams,
2964
3004
  gs as initUtils,
2965
- bs as initViewport,
3005
+ ws as initViewport,
2966
3006
  vs as initWeb,
2967
3007
  S as invokeCustomMethod,
2968
- bt as isColorDark,
2969
- oe as isIframe,
2970
- At as isPageReload,
2971
- Q as isRGB,
2972
- Qt as isRGBShort,
3008
+ Et as isColorDark,
3009
+ wt as isIframe,
3010
+ Dt as isPageReload,
3011
+ Y as isRGB,
3012
+ ee as isRGBShort,
2973
3013
  Ge as isSDKError,
2974
- xs as isSDKErrorOfType,
3014
+ Ss as isSDKErrorOfType,
2975
3015
  Es as isSSR,
2976
3016
  Ps as isTMA,
2977
3017
  d as json,
2978
3018
  ts as mergeClassNames,
3019
+ xs as mockTelegramEnv,
2979
3020
  y as number,
2980
3021
  L as off,
2981
- b as on,
3022
+ w as on,
2982
3023
  as as parseInitData,
2983
- Et as parseLaunchParams,
2984
- qt as parseThemeParams,
2985
- A as postEvent,
3024
+ tt as parseLaunchParams,
3025
+ $t as parseThemeParams,
3026
+ R as postEvent,
2986
3027
  _ as request,
2987
3028
  xe as requestBiometryInfo,
2988
3029
  fs as requestThemeParams,
2989
- kt as requestViewport,
3030
+ Lt as requestViewport,
2990
3031
  ye as retrieveLaunchParams,
2991
- ut as rgb,
2992
- K as searchParams,
2993
- we as serializeLaunchParams,
2994
- be as serializeThemeParams,
3032
+ dt as rgb,
3033
+ X as searchParams,
3034
+ me as serializeLaunchParams,
3035
+ kt as serializeThemeParams,
2995
3036
  m as setCSSVar,
2996
3037
  Ye as setDebug,
2997
3038
  Xe as setTargetOrigin,
2998
3039
  h as string,
2999
- Mt as subscribe,
3040
+ Ht as subscribe,
3000
3041
  v as supports,
3001
- ae as targetOrigin,
3002
- pt as toRGB,
3003
- ot as unsubscribe,
3042
+ he as targetOrigin,
3043
+ lt as toRGB,
3044
+ ct as unsubscribe,
3004
3045
  D as urlToPath,
3005
- gt as withTimeout
3046
+ vt as withTimeout
3006
3047
  };
3007
3048
  //# sourceMappingURL=index.js.map