@tma.js/sdk 2.5.1 → 2.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
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
- var c = (e, t, s) => Ut(e, typeof t != "symbol" ? t + "" : t, s);
1
+ var Ut = Object.defineProperty;
2
+ var Ot = (e, t, s) => t in e ? Ut(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s;
3
+ var c = (e, t, s) => Ot(e, typeof t != "symbol" ? t + "" : t, s);
4
4
  function at(e, t) {
5
5
  let s;
6
6
  const n = () => {
@@ -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 = M(), { count: s } = t;
12
+ const t = L(), { count: s } = t;
13
13
  t.unsubscribe(e), s && !t.count && ae();
14
14
  }
15
15
  function Ht(e) {
16
- return M().subscribe(e), () => ct(e);
16
+ return L().subscribe(e), () => ct(e);
17
17
  }
18
18
  class Gt {
19
19
  constructor(t, s = {}) {
@@ -69,7 +69,7 @@ function Ye(e) {
69
69
  function jt(...e) {
70
70
  H && F.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);
@@ -160,14 +160,14 @@ class D extends Error {
160
160
  super(s, { cause: n }), this.type = t, Object.setPrototypeOf(this, D.prototype);
161
161
  }
162
162
  }
163
- function f(e, t, s) {
163
+ function g(e, t, s) {
164
164
  return new D(e, t, s);
165
165
  }
166
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
- return f(Zt, "Value has unexpected type");
168
+ return g(Zt, "Value has unexpected type");
169
169
  }
170
- class V {
170
+ class M {
171
171
  constructor(t, s, n) {
172
172
  this.parser = t, this.isOptional = s, this.type = n;
173
173
  }
@@ -182,7 +182,7 @@ class V {
182
182
  try {
183
183
  return this.parser(t);
184
184
  } catch (s) {
185
- throw f(
185
+ throw g(
186
186
  ht,
187
187
  `Unable to parse value${this.type ? ` as ${this.type}` : ""}`,
188
188
  s
@@ -193,10 +193,10 @@ class V {
193
193
  return this.isOptional = !0, this;
194
194
  }
195
195
  }
196
- function P(e, t) {
197
- return () => new V(e, !1, t);
196
+ function x(e, t) {
197
+ return () => new M(e, !1, t);
198
198
  }
199
- const b = P((e) => {
199
+ const w = x((e) => {
200
200
  if (typeof e == "boolean")
201
201
  return e;
202
202
  const t = String(e);
@@ -223,7 +223,7 @@ function pt(e, t) {
223
223
  const a = o(t(i));
224
224
  a !== void 0 && (s[n] = a);
225
225
  } catch (a) {
226
- throw f(ht, `Unable to parse field "${n}"`, a);
226
+ throw g(ht, `Unable to parse field "${n}"`, a);
227
227
  }
228
228
  }
229
229
  return s;
@@ -235,12 +235,12 @@ function Q(e) {
235
235
  return t;
236
236
  }
237
237
  function d(e, t) {
238
- return new V((s) => {
238
+ return new M((s) => {
239
239
  const n = Q(s);
240
240
  return pt(e, (r) => n[r]);
241
241
  }, !1, t);
242
242
  }
243
- const y = P((e) => {
243
+ const y = x((e) => {
244
244
  if (typeof e == "number")
245
245
  return e;
246
246
  if (typeof e == "string") {
@@ -274,11 +274,11 @@ function ut(e) {
274
274
  return n + (i.length === 1 ? "0" : "") + i;
275
275
  }, "#");
276
276
  }
277
- const h = P((e) => {
277
+ const h = x((e) => {
278
278
  if (typeof e == "string" || typeof e == "number")
279
279
  return e.toString();
280
280
  throw E();
281
- }, "string"), lt = P((e) => ut(h().parse(e)), "rgb");
281
+ }, "string"), lt = x((e) => ut(h().parse(e)), "rgb");
282
282
  function dt(e) {
283
283
  return d({
284
284
  eventType: h(),
@@ -345,13 +345,13 @@ const re = {
345
345
  viewport_changed: d({
346
346
  height: y(),
347
347
  width: (e) => e == null ? window.innerWidth : y().parse(e),
348
- is_state_stable: b(),
349
- is_expanded: b()
348
+ is_state_stable: w(),
349
+ is_expanded: w()
350
350
  }),
351
351
  write_access_requested: d({ status: h() })
352
352
  };
353
353
  function ie() {
354
- const e = new R(), t = new R();
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
357
  }), ne();
@@ -422,14 +422,14 @@ const [oe, ae] = at(
422
422
  },
423
423
  ([, e]) => e()
424
424
  );
425
- function M() {
425
+ function L() {
426
426
  return oe()[0];
427
427
  }
428
- function L(e, t) {
429
- M().off(e, t);
428
+ function V(e, t) {
429
+ L().off(e, t);
430
430
  }
431
- function w(e, t, s) {
432
- return M().on(e, t, s);
431
+ function b(e, t, s) {
432
+ return L().on(e, t, s);
433
433
  }
434
434
  function I(e) {
435
435
  return typeof e == "object" && e !== null && !Array.isArray(e);
@@ -443,15 +443,21 @@ function ce(e, t) {
443
443
  }
444
444
  return 0;
445
445
  }
446
- function g(e, t) {
446
+ function f(e, t) {
447
447
  return ce(e, t) <= 0;
448
448
  }
449
449
  function v(e, t, s) {
450
450
  if (typeof s == "string") {
451
- if (e === "web_app_open_link" && t === "try_instant_view")
452
- return g("6.4", s);
451
+ if (e === "web_app_open_link") {
452
+ if (t === "try_instant_view")
453
+ return f("6.4", s);
454
+ if (t === "try_browser")
455
+ return f("7.6", s);
456
+ }
453
457
  if (e === "web_app_set_header_color" && t === "color")
454
- return g("6.9", s);
458
+ return f("6.9", s);
459
+ if (e === "web_app_close" && t === "return_back")
460
+ return f("7.6", s);
455
461
  }
456
462
  switch (e) {
457
463
  case "web_app_open_tg_link":
@@ -460,27 +466,27 @@ function v(e, t, s) {
460
466
  case "web_app_set_background_color":
461
467
  case "web_app_set_header_color":
462
468
  case "web_app_trigger_haptic_feedback":
463
- return g("6.1", t);
469
+ return f("6.1", t);
464
470
  case "web_app_open_popup":
465
- return g("6.2", t);
471
+ return f("6.2", t);
466
472
  case "web_app_close_scan_qr_popup":
467
473
  case "web_app_open_scan_qr_popup":
468
474
  case "web_app_read_text_from_clipboard":
469
- return g("6.4", t);
475
+ return f("6.4", t);
470
476
  case "web_app_switch_inline_query":
471
- return g("6.7", t);
477
+ return f("6.7", t);
472
478
  case "web_app_invoke_custom_method":
473
479
  case "web_app_request_write_access":
474
480
  case "web_app_request_phone":
475
- return g("6.9", t);
481
+ return f("6.9", t);
476
482
  case "web_app_setup_settings_button":
477
- return g("6.10", t);
483
+ return f("6.10", t);
478
484
  case "web_app_biometry_get_info":
479
485
  case "web_app_biometry_open_settings":
480
486
  case "web_app_biometry_request_access":
481
487
  case "web_app_biometry_request_auth":
482
488
  case "web_app_biometry_update_token":
483
- return g("7.2", t);
489
+ return f("7.2", t);
484
490
  default:
485
491
  return [
486
492
  "iframe_ready",
@@ -510,14 +516,14 @@ function gt() {
510
516
  return !0;
511
517
  }
512
518
  }
513
- let wt = "https://web.telegram.org";
519
+ let bt = "https://web.telegram.org";
514
520
  function Xe(e) {
515
- wt = e;
521
+ bt = e;
516
522
  }
517
523
  function he() {
518
- return wt;
524
+ return bt;
519
525
  }
520
- function T(e, t, s) {
526
+ function R(e, t, s) {
521
527
  let n = {}, r;
522
528
  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
529
  const { targetOrigin: i = he() } = n;
@@ -533,7 +539,7 @@ function T(e, t, s) {
533
539
  window.TelegramWebviewProxy.postEvent(e, JSON.stringify(r));
534
540
  return;
535
541
  }
536
- throw f(
542
+ throw g(
537
543
  Jt,
538
544
  "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
545
  );
@@ -541,23 +547,23 @@ function T(e, t, s) {
541
547
  function pe(e) {
542
548
  return (t, s) => {
543
549
  if (!v(t, e))
544
- throw f(zt, `Method "${t}" is unsupported in Mini Apps version ${e}`);
550
+ throw g(zt, `Method "${t}" is unsupported in Mini Apps version ${e}`);
545
551
  if (I(s)) {
546
552
  let n;
547
553
  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
- throw f(
554
+ throw g(
549
555
  Ft,
550
556
  `Parameter "${n}" of "${t}" method is unsupported in Mini Apps version ${e}`
551
557
  );
552
558
  }
553
- return T(t, s);
559
+ return R(t, s);
554
560
  };
555
561
  }
556
- function bt(e) {
562
+ function wt(e) {
557
563
  return ({ req_id: t }) => t === e;
558
564
  }
559
565
  function mt(e) {
560
- return f(Yt, `Timeout reached: ${e}ms`);
566
+ return g(Yt, `Timeout reached: ${e}ms`);
561
567
  }
562
568
  function yt(e, t) {
563
569
  return Promise.race([
@@ -575,11 +581,11 @@ async function _(e) {
575
581
  t = a;
576
582
  }), { event: n, capture: r, timeout: i } = e, [, o] = J(
577
583
  ...(Array.isArray(n) ? n : [n]).map(
578
- (a) => w(a, (p) => (!r || r(p)) && t(p))
584
+ (a) => b(a, (p) => (!r || r(p)) && t(p))
579
585
  )
580
586
  );
581
587
  try {
582
- return (e.postEvent || T)(e.method, e.params), await (i ? yt(s, i) : s);
588
+ return (e.postEvent || R)(e.method, e.params), await (i ? yt(s, i) : s);
583
589
  } finally {
584
590
  o();
585
591
  }
@@ -597,10 +603,10 @@ async function S(e, t, s, n = {}) {
597
603
  params: t,
598
604
  req_id: s
599
605
  },
600
- capture: bt(s)
606
+ capture: wt(s)
601
607
  });
602
608
  if (i)
603
- throw f(Qt, i);
609
+ throw g(Qt, i);
604
610
  return r;
605
611
  }
606
612
  function z(...e) {
@@ -630,7 +636,7 @@ function vt(e) {
630
636
  }
631
637
  class ue {
632
638
  constructor(t) {
633
- c(this, "ee", new R());
639
+ c(this, "ee", new T());
634
640
  /**
635
641
  * Adds new event listener.
636
642
  */
@@ -700,13 +706,13 @@ class le extends K {
700
706
  * @param event - event to listen.
701
707
  * @param listener - listener to add.
702
708
  */
703
- c(this, "on", (s, n) => s === "click" ? w("back_button_pressed", n) : this.state.on(s, n));
709
+ c(this, "on", (s, n) => s === "click" ? b("back_button_pressed", n) : this.state.on(s, n));
704
710
  /**
705
711
  * Removes the event listener.
706
712
  * @param event - event to listen.
707
713
  * @param listener - listener to remove.
708
714
  */
709
- c(this, "off", (s, n) => s === "click" ? L("back_button_pressed", n) : this.state.off(s, n));
715
+ c(this, "off", (s, n) => s === "click" ? V("back_button_pressed", n) : this.state.off(s, n));
710
716
  this.postEvent = r;
711
717
  }
712
718
  set isVisible(s) {
@@ -731,9 +737,9 @@ class le extends K {
731
737
  this.isVisible = !0;
732
738
  }
733
739
  }
734
- const Pt = P((e) => e instanceof Date ? e : new Date(y().parse(e) * 1e3), "Date");
740
+ const xt = x((e) => e instanceof Date ? e : new Date(y().parse(e) * 1e3), "Date");
735
741
  function X(e, t) {
736
- return new V((s) => {
742
+ return new M((s) => {
737
743
  if (typeof s != "string" && !(s instanceof URLSearchParams))
738
744
  throw E();
739
745
  const n = typeof s == "string" ? new URLSearchParams(s) : s;
@@ -754,11 +760,11 @@ const de = d({
754
760
  username: h().optional()
755
761
  }, "Chat").optional(), rt = d({
756
762
  addedToAttachmentMenu: {
757
- type: b().optional(),
763
+ type: w().optional(),
758
764
  from: "added_to_attachment_menu"
759
765
  },
760
766
  allowsWriteToPm: {
761
- type: b().optional(),
767
+ type: w().optional(),
762
768
  from: "allows_write_to_pm"
763
769
  },
764
770
  firstName: {
@@ -767,11 +773,11 @@ const de = d({
767
773
  },
768
774
  id: y(),
769
775
  isBot: {
770
- type: b().optional(),
776
+ type: w().optional(),
771
777
  from: "is_bot"
772
778
  },
773
779
  isPremium: {
774
- type: b().optional(),
780
+ type: w().optional(),
775
781
  from: "is_premium"
776
782
  },
777
783
  languageCode: {
@@ -788,10 +794,10 @@ const de = d({
788
794
  },
789
795
  username: h().optional()
790
796
  }, "User").optional();
791
- function xt() {
797
+ function Pt() {
792
798
  return X({
793
799
  authDate: {
794
- type: Pt(),
800
+ type: xt(),
795
801
  from: "auth_date"
796
802
  },
797
803
  canSendAfter: {
@@ -826,7 +832,7 @@ function _e(e) {
826
832
  function fe(e) {
827
833
  return e.replace(/[A-Z]/g, (t) => `_${t.toLowerCase()}`);
828
834
  }
829
- const St = P(
835
+ const St = x(
830
836
  (e) => {
831
837
  const t = lt().optional();
832
838
  return Object.entries(Q(e)).reduce((s, [n, r]) => (s[_e(n)] = t.parse(r), s), {});
@@ -836,11 +842,11 @@ const St = P(
836
842
  function tt(e) {
837
843
  return X({
838
844
  botInline: {
839
- type: b().optional(),
845
+ type: w().optional(),
840
846
  from: "tgWebAppBotInline"
841
847
  },
842
848
  initData: {
843
- type: xt().optional(),
849
+ type: Pt().optional(),
844
850
  from: "tgWebAppData"
845
851
  },
846
852
  initDataRaw: {
@@ -852,7 +858,7 @@ function tt(e) {
852
858
  from: "tgWebAppPlatform"
853
859
  },
854
860
  showSettings: {
855
- type: b().optional(),
861
+ type: w().optional(),
856
862
  from: "tgWebAppShowSettings"
857
863
  },
858
864
  startParam: {
@@ -877,29 +883,29 @@ function Ct(e) {
877
883
  function ge() {
878
884
  return Ct(window.location.href);
879
885
  }
880
- function Rt() {
886
+ function Tt() {
881
887
  return performance.getEntriesByType("navigation")[0];
882
888
  }
883
- function we() {
884
- const e = Rt();
889
+ function be() {
890
+ const e = Tt();
885
891
  if (!e)
886
892
  throw new Error("Unable to get first navigation entry.");
887
893
  return Ct(e.name);
888
894
  }
889
- function Tt(e) {
895
+ function Rt(e) {
890
896
  return `tma.js/${e.replace(/[A-Z]/g, (t) => `-${t.toLowerCase()}`)}`;
891
897
  }
892
898
  function At(e, t) {
893
- sessionStorage.setItem(Tt(e), JSON.stringify(t));
899
+ sessionStorage.setItem(Rt(e), JSON.stringify(t));
894
900
  }
895
901
  function It(e) {
896
- const t = sessionStorage.getItem(Tt(e));
902
+ const t = sessionStorage.getItem(Rt(e));
897
903
  try {
898
904
  return t ? JSON.parse(t) : void 0;
899
905
  } catch {
900
906
  }
901
907
  }
902
- function be() {
908
+ function we() {
903
909
  return tt(It("launchParams") || "");
904
910
  }
905
911
  function qt(e) {
@@ -930,9 +936,9 @@ function ye() {
930
936
  // nothing in case, location was changed and then page was reloaded.
931
937
  ge,
932
938
  // Then, try using the lower level API - window.performance.
933
- we,
939
+ be,
934
940
  // Finally, try to extract launch parameters from the session storage.
935
- be
941
+ we
936
942
  ])
937
943
  try {
938
944
  const t = e();
@@ -942,7 +948,7 @@ function ye() {
942
948
  throw new Error("Unable to retrieve launch parameters from any known source.");
943
949
  }
944
950
  function Nt() {
945
- const e = Rt();
951
+ const e = Tt();
946
952
  return !!(e && e.type === "reload");
947
953
  }
948
954
  function ve() {
@@ -1013,7 +1019,7 @@ function Dt(e) {
1013
1019
  accessGranted: t.access_granted
1014
1020
  };
1015
1021
  }
1016
- class Pe extends q {
1022
+ class xe extends q {
1017
1023
  constructor({ postEvent: s, version: n, ...r }) {
1018
1024
  super(r, n, {
1019
1025
  auth: "web_app_biometry_request_auth",
@@ -1127,7 +1133,7 @@ class Pe extends q {
1127
1133
  );
1128
1134
  }
1129
1135
  }
1130
- async function xe(e) {
1136
+ async function Pe(e) {
1131
1137
  return Dt(
1132
1138
  await _({
1133
1139
  ...e || {},
@@ -1138,8 +1144,8 @@ async function xe(e) {
1138
1144
  }
1139
1145
  const ss = l(
1140
1146
  "biometryManager",
1141
- async ({ postEvent: e, version: t, state: s }) => new Pe({
1142
- ...s || v("web_app_biometry_get_info", t) ? s || await xe({ timeout: 1e3 }) : {
1147
+ async ({ postEvent: e, version: t, state: s }) => new xe({
1148
+ ...s || v("web_app_biometry_get_info", t) ? s || await Pe({ timeout: 1e3 }) : {
1143
1149
  available: !1,
1144
1150
  accessGranted: !1,
1145
1151
  accessRequested: !1,
@@ -1218,7 +1224,7 @@ function Ce(e) {
1218
1224
  }
1219
1225
  throw E();
1220
1226
  }
1221
- class Re extends V {
1227
+ class Te extends M {
1222
1228
  constructor(s, n, r) {
1223
1229
  super(Ce, n, r);
1224
1230
  c(this, "itemParser");
@@ -1238,8 +1244,8 @@ class Re extends V {
1238
1244
  return this.itemParser = typeof s == "function" ? s : s.parse.bind(s), this;
1239
1245
  }
1240
1246
  }
1241
- function Te(e) {
1242
- return new Re((t) => t, !1, e);
1247
+ function Re(e) {
1248
+ return new Te((t) => t, !1, e);
1243
1249
  }
1244
1250
  function it(e, t) {
1245
1251
  return Object.fromEntries(e.map((s) => [s, t]));
@@ -1272,7 +1278,7 @@ class Ae extends st {
1272
1278
  * @param options - request execution options.
1273
1279
  */
1274
1280
  async getKeys(t = {}) {
1275
- return Te().of(h()).parse(
1281
+ return Re().of(h()).parse(
1276
1282
  await S(
1277
1283
  "getStorageKeys",
1278
1284
  {},
@@ -1433,7 +1439,7 @@ const os = l(
1433
1439
  ({ initData: e }) => e ? new qe(e) : void 0
1434
1440
  );
1435
1441
  function as(e) {
1436
- return xt().parse(e);
1442
+ return Pt().parse(e);
1437
1443
  }
1438
1444
  class ke extends q {
1439
1445
  constructor(t, s, n) {
@@ -1491,13 +1497,13 @@ class Ne extends Z {
1491
1497
  * @param event - event to listen.
1492
1498
  * @param listener - listener to add.
1493
1499
  */
1494
- c(this, "on", (s, n) => s === "click" ? w("main_button_pressed", n) : this.state.on(s, n));
1500
+ c(this, "on", (s, n) => s === "click" ? b("main_button_pressed", n) : this.state.on(s, n));
1495
1501
  /**
1496
1502
  * Removes the event listener.
1497
1503
  * @param event - event to listen.
1498
1504
  * @param listener - listener to remove.
1499
1505
  */
1500
- c(this, "off", (s, n) => s === "click" ? L("main_button_pressed", n) : this.state.off(s, n));
1506
+ c(this, "off", (s, n) => s === "click" ? V("main_button_pressed", n) : this.state.off(s, n));
1501
1507
  this.postEvent = s;
1502
1508
  }
1503
1509
  /**
@@ -1663,24 +1669,24 @@ function De() {
1663
1669
  }
1664
1670
  }),
1665
1671
  authDate: {
1666
- type: Pt(),
1672
+ type: xt(),
1667
1673
  from: "auth_date"
1668
1674
  },
1669
1675
  hash: h()
1670
1676
  }, "RequestedContact");
1671
1677
  }
1672
- function Vt(e, t) {
1678
+ function Mt(e, t) {
1673
1679
  return (s) => {
1674
1680
  const [n, r] = t[s];
1675
1681
  return v(n, r, e);
1676
1682
  };
1677
1683
  }
1678
- function Ve(e) {
1684
+ function Me(e) {
1679
1685
  return new Promise((t) => {
1680
1686
  setTimeout(t, e);
1681
1687
  });
1682
1688
  }
1683
- class Me extends q {
1689
+ class Le extends q {
1684
1690
  constructor({ postEvent: s, createRequestId: n, version: r, botInline: i, ...o }) {
1685
1691
  super(o, r, {
1686
1692
  requestPhoneAccess: "web_app_request_phone",
@@ -1700,7 +1706,7 @@ class Me extends q {
1700
1706
  c(this, "supportsParam");
1701
1707
  this.createRequestId = n, this.postEvent = s, this.botInline = i;
1702
1708
  const a = this.supports.bind(this);
1703
- this.supports = (p) => a(p) ? p !== "switchInlineQuery" || i : !1, this.supportsParam = Vt(r, {
1709
+ this.supports = (p) => a(p) ? p !== "switchInlineQuery" || i : !1, this.supportsParam = Mt(r, {
1704
1710
  "setHeaderColor.color": ["web_app_set_header_color", "color"]
1705
1711
  });
1706
1712
  }
@@ -1786,7 +1792,7 @@ class Me extends q {
1786
1792
  return await this.getRequestedContact();
1787
1793
  } catch {
1788
1794
  }
1789
- await Ve(i), i += 50;
1795
+ await Me(i), i += 50;
1790
1796
  }
1791
1797
  throw mt(s);
1792
1798
  }, s);
@@ -1881,9 +1887,9 @@ const ps = l(
1881
1887
  headerColor: e.headerBgColor || "#000000"
1882
1888
  },
1883
1889
  ...n
1884
- }) => new Me({ ...n, ...s, botInline: t })
1890
+ }) => new Le({ ...n, ...s, botInline: t })
1885
1891
  );
1886
- function Le(e) {
1892
+ function Ve(e) {
1887
1893
  const t = e.message.trim(), s = (e.title || "").trim(), n = e.buttons || [];
1888
1894
  let r;
1889
1895
  if (s.length > 64)
@@ -1940,7 +1946,7 @@ class $e extends q {
1940
1946
  event: "popup_closed",
1941
1947
  method: "web_app_open_popup",
1942
1948
  postEvent: this.postEvent,
1943
- params: Le(t)
1949
+ params: Ve(t)
1944
1950
  });
1945
1951
  return s;
1946
1952
  } finally {
@@ -1959,7 +1965,7 @@ class Be extends q {
1959
1965
  }), this.postEvent = n;
1960
1966
  }
1961
1967
  /**
1962
- * Closes scanner.
1968
+ * Closes the scanner.
1963
1969
  */
1964
1970
  close() {
1965
1971
  this.postEvent("web_app_close_scan_qr_popup"), this.isOpened = !1;
@@ -1968,14 +1974,14 @@ class Be extends q {
1968
1974
  this.set("isOpened", t);
1969
1975
  }
1970
1976
  /**
1971
- * Returns true in case, QR scanner is currently opened.
1977
+ * Returns true if the scanner is currently opened.
1972
1978
  */
1973
1979
  get isOpened() {
1974
1980
  return this.get("isOpened");
1975
1981
  }
1976
1982
  async open(t) {
1977
1983
  if (this.isOpened)
1978
- throw new Error("QR scanner is already opened.");
1984
+ throw new Error("The scanner is already opened");
1979
1985
  const { text: s, capture: n } = (typeof t == "string" ? { text: t } : t) || {};
1980
1986
  this.isOpened = !0;
1981
1987
  try {
@@ -1989,10 +1995,11 @@ class Be extends q {
1989
1995
  }
1990
1996
  }) || {}).data || null;
1991
1997
  return i && this.close(), i;
1992
- } catch (r) {
1993
- throw this.isOpened = !1, r;
1998
+ } finally {
1999
+ this.isOpened = !1;
1994
2000
  }
1995
2001
  }
2002
+ // TODO: Streaming mode, allowing to scan several QRs until closed.
1996
2003
  }
1997
2004
  const ls = l(
1998
2005
  ({ version: e, postEvent: t }) => new Be(!1, e, t)
@@ -2008,13 +2015,13 @@ class We extends K {
2008
2015
  * @param event - event to listen.
2009
2016
  * @param listener - listener to add.
2010
2017
  */
2011
- c(this, "on", (s, n) => s === "click" ? w("settings_button_pressed", n) : this.state.on(s, n));
2018
+ c(this, "on", (s, n) => s === "click" ? b("settings_button_pressed", n) : this.state.on(s, n));
2012
2019
  /**
2013
2020
  * Removes the event listener.
2014
2021
  * @param event - event to listen.
2015
2022
  * @param listener - listener to remove.
2016
2023
  */
2017
- c(this, "off", (s, n) => s === "click" ? L("settings_button_pressed", n) : this.state.off(s, n));
2024
+ c(this, "off", (s, n) => s === "click" ? V("settings_button_pressed", n) : this.state.off(s, n));
2018
2025
  this.postEvent = r;
2019
2026
  }
2020
2027
  set isVisible(s) {
@@ -2047,10 +2054,10 @@ const ds = l(
2047
2054
  state: s = { isVisible: !1 }
2048
2055
  }) => new We(s.isVisible, e, t)
2049
2056
  );
2050
- function Mt(e) {
2057
+ function Lt(e) {
2051
2058
  return St().parse(e);
2052
2059
  }
2053
- class Oe extends et {
2060
+ class Ue extends et {
2054
2061
  /**
2055
2062
  * @since v6.10
2056
2063
  */
@@ -2109,13 +2116,19 @@ class Oe extends et {
2109
2116
  get sectionHeaderTextColor() {
2110
2117
  return this.get("sectionHeaderTextColor");
2111
2118
  }
2119
+ /**
2120
+ * @since v7.6
2121
+ */
2122
+ get sectionSeparatorColor() {
2123
+ return this.get("sectionHeaderTextColor");
2124
+ }
2112
2125
  /**
2113
2126
  * Starts listening to the external theme changes and applies them.
2114
2127
  * @returns Function to stop listening.
2115
2128
  */
2116
2129
  listen() {
2117
- return w("theme_changed", (t) => {
2118
- this.set(Mt(t.theme_params));
2130
+ return b("theme_changed", (t) => {
2131
+ this.set(Lt(t.theme_params));
2119
2132
  });
2120
2133
  }
2121
2134
  /**
@@ -2131,7 +2144,7 @@ class Oe extends et {
2131
2144
  const _s = l(
2132
2145
  "themeParams",
2133
2146
  ({ themeParams: e, state: t = e, addCleanup: s }) => {
2134
- const n = new Oe(t);
2147
+ const n = new Ue(t);
2135
2148
  return s(n.listen()), n;
2136
2149
  }
2137
2150
  );
@@ -2140,16 +2153,16 @@ function fs(e = {}) {
2140
2153
  ...e,
2141
2154
  method: "web_app_request_theme",
2142
2155
  event: "theme_changed"
2143
- }).then(Mt);
2156
+ }).then(Lt);
2144
2157
  }
2145
- class Ue extends st {
2158
+ class Oe extends st {
2146
2159
  constructor(s, n, r) {
2147
2160
  super(s, { readTextFromClipboard: "web_app_read_text_from_clipboard" });
2148
2161
  /**
2149
2162
  * Checks if specified method parameter is supported by current component.
2150
2163
  */
2151
2164
  c(this, "supportsParam");
2152
- this.version = s, this.createRequestId = n, this.postEvent = r, this.supportsParam = Vt(s, {
2165
+ this.version = s, this.createRequestId = n, this.postEvent = r, this.supportsParam = Mt(s, {
2153
2166
  "openLink.tryInstantView": ["web_app_open_link", "try_instant_view"]
2154
2167
  });
2155
2168
  }
@@ -2203,7 +2216,7 @@ class Ue extends st {
2203
2216
  event: "clipboard_text_received",
2204
2217
  postEvent: this.postEvent,
2205
2218
  params: { req_id: s },
2206
- capture: bt(s)
2219
+ capture: wt(s)
2207
2220
  });
2208
2221
  return n;
2209
2222
  }
@@ -2224,9 +2237,9 @@ class Ue extends st {
2224
2237
  }
2225
2238
  }
2226
2239
  const gs = l(
2227
- ({ version: e, postEvent: t, createRequestId: s }) => new Ue(e, s, t)
2240
+ ({ version: e, postEvent: t, createRequestId: s }) => new Oe(e, s, t)
2228
2241
  );
2229
- async function Lt(e = {}) {
2242
+ async function Vt(e = {}) {
2230
2243
  const {
2231
2244
  is_expanded: t,
2232
2245
  is_state_stable: s,
@@ -2238,16 +2251,16 @@ async function Lt(e = {}) {
2238
2251
  });
2239
2252
  return { ...n, isExpanded: t, isStateStable: s };
2240
2253
  }
2241
- function x(e) {
2254
+ function P(e) {
2242
2255
  return e < 0 ? 0 : e;
2243
2256
  }
2244
2257
  class He extends et {
2245
2258
  constructor({ postEvent: s, stableHeight: n, height: r, width: i, isExpanded: o }) {
2246
2259
  super({
2247
- height: x(r),
2260
+ height: P(r),
2248
2261
  isExpanded: o,
2249
- stableHeight: x(n),
2250
- width: x(i)
2262
+ stableHeight: P(n),
2263
+ width: P(i)
2251
2264
  });
2252
2265
  c(this, "postEvent");
2253
2266
  this.postEvent = s;
@@ -2258,7 +2271,7 @@ class He extends et {
2258
2271
  * @param options - options to request fresh data.
2259
2272
  */
2260
2273
  async sync(s) {
2261
- const { isStateStable: n, ...r } = await Lt(s);
2274
+ const { isStateStable: n, ...r } = await Vt(s);
2262
2275
  this.set({
2263
2276
  ...r,
2264
2277
  stableHeight: n ? r.height : this.get("stableHeight")
@@ -2305,17 +2318,17 @@ class He extends et {
2305
2318
  * @returns Function to stop listening.
2306
2319
  */
2307
2320
  listen() {
2308
- return w("viewport_changed", (s) => {
2321
+ return b("viewport_changed", (s) => {
2309
2322
  const {
2310
2323
  height: n,
2311
2324
  width: r,
2312
2325
  is_expanded: i,
2313
2326
  is_state_stable: o
2314
- } = s, a = x(n);
2327
+ } = s, a = P(n);
2315
2328
  this.set({
2316
2329
  height: a,
2317
2330
  isExpanded: i,
2318
- width: x(r),
2331
+ width: P(r),
2319
2332
  ...o ? { stableHeight: a } : {}
2320
2333
  });
2321
2334
  });
@@ -2350,7 +2363,7 @@ class He extends et {
2350
2363
  return this.stableHeight === this.height;
2351
2364
  }
2352
2365
  }
2353
- const ws = l(
2366
+ const bs = l(
2354
2367
  "viewport",
2355
2368
  async ({ state: e, platform: t, postEvent: s, addCleanup: n }) => {
2356
2369
  let r = !1, i = 0, o = 0, a = 0;
@@ -2359,7 +2372,7 @@ const ws = l(
2359
2372
  else if (["macos", "tdesktop", "unigram", "webk", "weba", "web"].includes(t))
2360
2373
  r = !0, i = window.innerHeight, o = window.innerWidth, a = window.innerHeight;
2361
2374
  else {
2362
- const u = await Lt({ timeout: 1e3, postEvent: s });
2375
+ const u = await Vt({ timeout: 1e3, postEvent: s });
2363
2376
  r = u.isExpanded, i = u.height, o = u.width, a = u.isStateStable ? i : 0;
2364
2377
  }
2365
2378
  const p = new He({
@@ -2375,7 +2388,7 @@ const ws = l(
2375
2388
  function m(e, t) {
2376
2389
  document.documentElement.style.setProperty(e, t);
2377
2390
  }
2378
- function bs(e, t, s) {
2391
+ function ws(e, t, s) {
2379
2392
  s || (s = (a) => `--tg-${a}-color`);
2380
2393
  const n = s("header"), r = s("bg"), i = () => {
2381
2394
  const { headerColor: a } = e;
@@ -2416,25 +2429,25 @@ function ys(e, t) {
2416
2429
  }
2417
2430
  function vs(e = !0) {
2418
2431
  const t = [
2419
- w("reload_iframe", () => {
2420
- T("iframe_will_reload"), window.location.reload();
2432
+ b("reload_iframe", () => {
2433
+ R("iframe_will_reload"), window.location.reload();
2421
2434
  })
2422
2435
  ], s = () => t.forEach((n) => n());
2423
2436
  if (e) {
2424
2437
  const n = document.createElement("style");
2425
2438
  n.id = "telegram-custom-styles", document.head.appendChild(n), t.push(
2426
- w("set_custom_style", (r) => {
2439
+ b("set_custom_style", (r) => {
2427
2440
  n.innerHTML = r;
2428
2441
  }),
2429
2442
  () => document.head.removeChild(n)
2430
2443
  );
2431
2444
  }
2432
- return T("iframe_ready", { reload_supported: !0 }), s;
2445
+ return R("iframe_ready", { reload_supported: !0 }), s;
2433
2446
  }
2434
2447
  function Es() {
2435
2448
  return typeof window > "u";
2436
2449
  }
2437
- async function Ps() {
2450
+ async function xs() {
2438
2451
  if (ft(window))
2439
2452
  return !0;
2440
2453
  try {
@@ -2443,7 +2456,7 @@ async function Ps() {
2443
2456
  return !1;
2444
2457
  }
2445
2458
  }
2446
- function xs(e) {
2459
+ function Ps(e) {
2447
2460
  const t = typeof e == "string" ? tt(e) : e;
2448
2461
  kt(t);
2449
2462
  function s(r) {
@@ -2498,12 +2511,12 @@ function $(e, t) {
2498
2511
  });
2499
2512
  }
2500
2513
  class je {
2501
- constructor(t, s, n = T) {
2514
+ constructor(t, s, n = R) {
2502
2515
  /**
2503
2516
  * Navigation history.
2504
2517
  */
2505
2518
  c(this, "history");
2506
- c(this, "ee", new R());
2519
+ c(this, "ee", new T());
2507
2520
  /**
2508
2521
  * True, if current navigator is currently attached.
2509
2522
  */
@@ -2521,9 +2534,9 @@ class je {
2521
2534
  */
2522
2535
  c(this, "off", this.ee.off.bind(this.ee));
2523
2536
  if (this._index = s, this.postEvent = n, t.length === 0)
2524
- throw f(Kt, "History should not be empty.");
2537
+ throw g(Kt, "History should not be empty.");
2525
2538
  if (s < 0 || s >= t.length)
2526
- throw f(
2539
+ throw g(
2527
2540
  Xt,
2528
2541
  "Index should not be zero and higher or equal than history size."
2529
2542
  );
@@ -2534,7 +2547,7 @@ class je {
2534
2547
  * `BackButton` clicks and calls the `back` method.
2535
2548
  */
2536
2549
  attach() {
2537
- this.attached || (this.attached = !0, this.sync(), w("back_button_pressed", this.back));
2550
+ this.attached || (this.attached = !0, this.sync(), b("back_button_pressed", this.back));
2538
2551
  }
2539
2552
  /**
2540
2553
  * Currently active history item.
@@ -2546,7 +2559,7 @@ class je {
2546
2559
  * Prevents current navigator from controlling the BackButton visibility state.
2547
2560
  */
2548
2561
  detach() {
2549
- this.attached = !1, L("back_button_pressed", this.back);
2562
+ this.attached = !1, V("back_button_pressed", this.back);
2550
2563
  }
2551
2564
  /**
2552
2565
  * Goes to the next history item.
@@ -2688,11 +2701,11 @@ async function ze() {
2688
2701
  function $t(e) {
2689
2702
  return k(e).pathname;
2690
2703
  }
2691
- const ot = 0, O = 1, U = 2;
2704
+ const ot = 0, U = 1, O = 2;
2692
2705
  class Bt {
2693
2706
  constructor(t, s, { postEvent: n, hashMode: r = "classic", base: i } = {}) {
2694
2707
  c(this, "navigator");
2695
- c(this, "ee", new R());
2708
+ c(this, "ee", new T());
2696
2709
  c(this, "hashMode");
2697
2710
  c(this, "base");
2698
2711
  /**
@@ -2706,7 +2719,7 @@ class Bt {
2706
2719
  c(this, "onPopState", ({ state: t }) => {
2707
2720
  if (t === null)
2708
2721
  return this.push(this.parsePath(window.location.href));
2709
- t === ot ? window.history.forward() : t === O && this.back(), t === U && this.forward();
2722
+ t === ot ? window.history.forward() : t === U && this.back(), t === O && this.forward();
2710
2723
  });
2711
2724
  /**
2712
2725
  * Underlying navigator change event listener.
@@ -2894,7 +2907,7 @@ class Bt {
2894
2907
  async syncHistory() {
2895
2908
  window.removeEventListener("popstate", this.onPopState);
2896
2909
  const { state: t } = this, s = this.renderPath(this);
2897
- 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);
2910
+ await ze(), this.hasPrev && this.hasNext ? (window.history.replaceState(U, ""), window.history.pushState(t, "", s), window.history.pushState(O, ""), await C(-1)) : this.hasPrev ? (window.history.replaceState(U, ""), window.history.pushState(t, "", s)) : this.hasNext ? (window.history.replaceState(t, s), window.history.pushState(O, ""), await C(-1)) : (window.history.replaceState(ot, ""), window.history.pushState(t, "", s)), window.addEventListener("popstate", this.onPopState);
2898
2911
  }
2899
2912
  /**
2900
2913
  * Current query parameters.
@@ -2921,7 +2934,7 @@ function Fe(e) {
2921
2934
  const r = e.base ? $t(e.base) : void 0;
2922
2935
  if (r) {
2923
2936
  if (!n.startsWith(r))
2924
- throw f(
2937
+ throw g(
2925
2938
  te,
2926
2939
  `Path "${n}" expected to be starting with "${r}"`
2927
2940
  );
@@ -2950,7 +2963,7 @@ function Je(e, t) {
2950
2963
  }
2951
2964
  return Fe(t);
2952
2965
  }
2953
- function Rs(e, t) {
2966
+ function Ts(e, t) {
2954
2967
  const s = Je(e, t), n = () => sessionStorage.setItem(e, JSON.stringify({
2955
2968
  index: s.index,
2956
2969
  history: s.history
@@ -2960,7 +2973,7 @@ function Rs(e, t) {
2960
2973
  export {
2961
2974
  le as BackButton,
2962
2975
  je as BasicNavigator,
2963
- Pe as BiometryManager,
2976
+ xe as BiometryManager,
2964
2977
  Bt as BrowserNavigator,
2965
2978
  Se as ClosingBehavior,
2966
2979
  Ae as CloudStorage,
@@ -2976,31 +2989,31 @@ export {
2976
2989
  Yt as ERR_TIMED_OUT,
2977
2990
  Zt as ERR_UNEXPECTED_TYPE,
2978
2991
  Jt as ERR_UNKNOWN_ENV,
2979
- R as EventEmitter,
2992
+ T as EventEmitter,
2980
2993
  Ie as HapticFeedback,
2981
2994
  qe as InitData,
2982
2995
  ke as Invoice,
2983
2996
  Ne as MainButton,
2984
- Me as MiniApp,
2997
+ Le as MiniApp,
2985
2998
  $e as Popup,
2986
2999
  Be as QRScanner,
2987
3000
  D as SDKError,
2988
3001
  We as SettingsButton,
2989
- Oe as ThemeParams,
2990
- Ue as Utils,
3002
+ Ue as ThemeParams,
3003
+ Oe as Utils,
2991
3004
  He as Viewport,
2992
- Te as array,
2993
- bs as bindMiniAppCSSVars,
3005
+ Re as array,
3006
+ ws as bindMiniAppCSSVars,
2994
3007
  ms as bindThemeParamsCSSVars,
2995
3008
  ys as bindViewportCSSVars,
2996
- b as boolean,
2997
- bt as captureSameReq,
3009
+ w as boolean,
3010
+ wt as captureSameReq,
2998
3011
  z as classNames,
2999
3012
  ce as compareVersions,
3000
3013
  Fe as createBrowserNavigatorFromLocation,
3001
3014
  pe as createPostEvent,
3002
3015
  k as createSafeURL,
3003
- Pt as date,
3016
+ xt as date,
3004
3017
  Cs as getHash,
3005
3018
  $t as getPathname,
3006
3019
  es as initBackButton,
@@ -3012,13 +3025,13 @@ export {
3012
3025
  cs as initInvoice,
3013
3026
  hs as initMainButton,
3014
3027
  ps as initMiniApp,
3015
- Rs as initNavigator,
3028
+ Ts as initNavigator,
3016
3029
  us as initPopup,
3017
3030
  ls as initQRScanner,
3018
3031
  ds as initSettingsButton,
3019
3032
  _s as initThemeParams,
3020
3033
  gs as initUtils,
3021
- ws as initViewport,
3034
+ bs as initViewport,
3022
3035
  vs as initWeb,
3023
3036
  S as invokeCustomMethod,
3024
3037
  vt as isColorDark,
@@ -3029,21 +3042,21 @@ export {
3029
3042
  Ge as isSDKError,
3030
3043
  Ss as isSDKErrorOfType,
3031
3044
  Es as isSSR,
3032
- Ps as isTMA,
3045
+ xs as isTMA,
3033
3046
  d as json,
3034
3047
  ts as mergeClassNames,
3035
- xs as mockTelegramEnv,
3048
+ Ps as mockTelegramEnv,
3036
3049
  y as number,
3037
- L as off,
3038
- w as on,
3050
+ V as off,
3051
+ b as on,
3039
3052
  as as parseInitData,
3040
3053
  tt as parseLaunchParams,
3041
- Mt as parseThemeParams,
3042
- T as postEvent,
3054
+ Lt as parseThemeParams,
3055
+ R as postEvent,
3043
3056
  _ as request,
3044
- xe as requestBiometryInfo,
3057
+ Pe as requestBiometryInfo,
3045
3058
  fs as requestThemeParams,
3046
- Lt as requestViewport,
3059
+ Vt as requestViewport,
3047
3060
  ye as retrieveLaunchParams,
3048
3061
  lt as rgb,
3049
3062
  X as searchParams,