@tma.js/sdk 0.13.0 → 0.13.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,23 +1,23 @@
1
1
  var ot = Object.defineProperty;
2
2
  var nt = (s, t, e) => t in s ? ot(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e;
3
3
  var i = (s, t, e) => (nt(s, typeof t != "symbol" ? t + "" : t, e), e);
4
- import { retrieveLaunchData as U, parse as rt } from "@tma.js/launch-params";
5
- import { EventEmitter as m } from "@tma.js/event-emitter";
6
- import { supports as C, postEvent as g, on as x, off as K, request as f, detectSupportParams as it, setDebug as at, setTargetOrigin as ct, isIframe as ht } from "@tma.js/bridge";
7
- import { array as ut, string as F, json as lt } from "@tma.js/parsing";
8
- import { parse as M } from "@tma.js/theme-params";
9
- import { isColorDark as j, isRGB as pt } from "@tma.js/colors";
10
- import { compareVersions as dt, isRecord as gt, withTimeout as bt } from "@tma.js/utils";
11
- function v(s, t) {
12
- return (e) => C(t[e], s);
4
+ import { retrieveLaunchData as z, parse as rt } from "@tma.js/launch-params";
5
+ import { EventEmitter as w } from "@tma.js/event-emitter";
6
+ import { supports as P, postEvent as g, on as E, off as W, request as f, setDebug as it, setTargetOrigin as at, createPostEvent as ct, isIframe as ht } from "@tma.js/bridge";
7
+ import { array as ut, string as U, json as lt } from "@tma.js/parsing";
8
+ import { parse as D } from "@tma.js/theme-params";
9
+ import { isColorDark as K, isRGB as pt } from "@tma.js/colors";
10
+ import { compareVersions as dt, withTimeout as gt } from "@tma.js/utils";
11
+ function C(s, t) {
12
+ return (e) => P(t[e], s);
13
13
  }
14
- function _t(s, t) {
14
+ function bt(s, t) {
15
15
  return (e) => {
16
16
  const [o, n] = t[e];
17
- return C(o, n, s);
17
+ return P(o, n, s);
18
18
  };
19
19
  }
20
- class w {
20
+ class m {
21
21
  constructor(t, e) {
22
22
  this.state = t, this.ee = e;
23
23
  }
@@ -40,16 +40,16 @@ class w {
40
40
  return this.state[t];
41
41
  }
42
42
  }
43
- class ft {
43
+ class _t {
44
44
  constructor(t, e, o = g) {
45
- i(this, "ee", new m());
45
+ i(this, "ee", new w());
46
46
  i(this, "state");
47
47
  /**
48
48
  * Adds event listener.
49
49
  * @param event - event name.
50
50
  * @param listener - event listener.
51
51
  */
52
- i(this, "on", (t, e) => t === "click" ? x("back_button_pressed", e) : this.ee.on(t, e));
52
+ i(this, "on", (t, e) => t === "click" ? E("back_button_pressed", e) : this.ee.on(t, e));
53
53
  /**
54
54
  * Removes event listener.
55
55
  * @param event - event name.
@@ -57,14 +57,14 @@ class ft {
57
57
  */
58
58
  i(this, "off", (t, e) => {
59
59
  if (t === "click")
60
- return K("back_button_pressed", e);
60
+ return W("back_button_pressed", e);
61
61
  this.ee.off(t, e);
62
62
  });
63
63
  /**
64
64
  * Checks if specified method is supported by current component.
65
65
  */
66
66
  i(this, "supports");
67
- this.postEvent = o, this.state = new w({ isVisible: t }, this.ee), this.supports = v(e, {
67
+ this.postEvent = o, this.state = new m({ isVisible: t }, this.ee), this.supports = C(e, {
68
68
  show: "web_app_setup_back_button",
69
69
  hide: "web_app_setup_back_button"
70
70
  });
@@ -91,9 +91,9 @@ class ft {
91
91
  this.isVisible = !0;
92
92
  }
93
93
  }
94
- class wt {
94
+ class ft {
95
95
  constructor(t, e = g) {
96
- i(this, "ee", new m());
96
+ i(this, "ee", new w());
97
97
  i(this, "state");
98
98
  /**
99
99
  * Adds new event listener.
@@ -103,7 +103,7 @@ class wt {
103
103
  * Removes event listener.
104
104
  */
105
105
  i(this, "off", this.ee.off.bind(this.ee));
106
- this.postEvent = e, this.state = new w({ isConfirmationNeeded: t }, this.ee);
106
+ this.postEvent = e, this.state = new m({ isConfirmationNeeded: t }, this.ee);
107
107
  }
108
108
  set isConfirmationNeeded(t) {
109
109
  this.state.set("isConfirmationNeeded", t), this.postEvent("web_app_setup_closing_behavior", { need_confirmation: t });
@@ -130,17 +130,17 @@ class wt {
130
130
  this.isConfirmationNeeded = !0;
131
131
  }
132
132
  }
133
- const mt = ut().of(F());
134
- function N(s, t) {
133
+ const mt = ut().of(U());
134
+ function L(s, t) {
135
135
  return s.reduce((e, o) => (e[o] = t, e), {});
136
136
  }
137
- class Ct {
137
+ class wt {
138
138
  constructor(t, e, o = g) {
139
139
  /**
140
140
  * Checks if specified method is supported by current component.
141
141
  */
142
142
  i(this, "supports");
143
- this.createRequestId = e, this.postEvent = o, this.supports = v(t, {
143
+ this.createRequestId = e, this.postEvent = o, this.supports = C(t, {
144
144
  deleteKeys: "web_app_invoke_custom_method",
145
145
  getKeys: "web_app_invoke_custom_method",
146
146
  getValues: "web_app_invoke_custom_method",
@@ -188,9 +188,9 @@ class Ct {
188
188
  */
189
189
  async getValues(t, e) {
190
190
  if (t.length === 0)
191
- return N(t, "");
191
+ return L(t, "");
192
192
  const o = lt(
193
- N(t, F())
193
+ L(t, U())
194
194
  // fixme
195
195
  ), n = await this.invokeCustomMethod("getStorageValues", { keys: t }, e);
196
196
  return o.parse(n);
@@ -205,13 +205,13 @@ class Ct {
205
205
  await this.invokeCustomMethod("saveStorageValue", { key: t, value: e }, o);
206
206
  }
207
207
  }
208
- class vt {
208
+ class Ct {
209
209
  constructor(t, e = g) {
210
210
  /**
211
211
  * Checks if specified method is supported by current component.
212
212
  */
213
213
  i(this, "supports");
214
- this.postEvent = e, this.supports = v(t, {
214
+ this.postEvent = e, this.supports = C(t, {
215
215
  impactOccurred: "web_app_trigger_haptic_feedback",
216
216
  notificationOccurred: "web_app_trigger_haptic_feedback",
217
217
  selectionChanged: "web_app_trigger_haptic_feedback"
@@ -248,7 +248,7 @@ class vt {
248
248
  this.postEvent("web_app_trigger_haptic_feedback", { type: "selection_change" });
249
249
  }
250
250
  }
251
- class yt {
251
+ class vt {
252
252
  constructor(t, e, o = {}) {
253
253
  i(this, "state");
254
254
  const {
@@ -261,7 +261,7 @@ class yt {
261
261
  receiver: u = null,
262
262
  startParam: p = null
263
263
  } = o;
264
- this.state = new w({
264
+ this.state = new m({
265
265
  authDate: t,
266
266
  canSendAfter: r === null ? null : new Date(t.getTime() + r * 1e3),
267
267
  chat: n,
@@ -347,9 +347,9 @@ class yt {
347
347
  return this.state.get("user");
348
348
  }
349
349
  }
350
- class kt {
350
+ class yt {
351
351
  constructor(t, e, o, n, r, a, h = g) {
352
- i(this, "ee", new m());
352
+ i(this, "ee", new w());
353
353
  i(this, "state");
354
354
  /**
355
355
  * Adds new event listener.
@@ -359,7 +359,7 @@ class kt {
359
359
  * @param event - event name.
360
360
  * @param listener - event listener.
361
361
  */
362
- i(this, "on", (t, e) => t === "click" ? x("main_button_pressed", e) : this.ee.on(t, e));
362
+ i(this, "on", (t, e) => t === "click" ? E("main_button_pressed", e) : this.ee.on(t, e));
363
363
  /**
364
364
  * Removes event listener.
365
365
  * @param event - event name.
@@ -367,10 +367,10 @@ class kt {
367
367
  */
368
368
  i(this, "off", (t, e) => {
369
369
  if (t === "click")
370
- return K("main_button_pressed", e);
370
+ return W("main_button_pressed", e);
371
371
  this.ee.off(t, e);
372
372
  });
373
- this.postEvent = h, this.state = new w({
373
+ this.postEvent = h, this.state = new m({
374
374
  backgroundColor: t,
375
375
  isEnabled: e,
376
376
  isVisible: o,
@@ -512,7 +512,7 @@ class kt {
512
512
  return this.state.set("backgroundColor", t), this.commit(), this;
513
513
  }
514
514
  }
515
- function Et(s) {
515
+ function kt(s) {
516
516
  const t = s.message.trim(), e = (s.title || "").trim(), o = s.buttons || [];
517
517
  let n;
518
518
  if (e.length > 64)
@@ -536,9 +536,9 @@ function Et(s) {
536
536
  return { ...r, id: a };
537
537
  }), { title: e, message: t, buttons: n };
538
538
  }
539
- class xt {
539
+ class Et {
540
540
  constructor(t, e = g) {
541
- i(this, "ee", new m());
541
+ i(this, "ee", new w());
542
542
  i(this, "state");
543
543
  /**
544
544
  * Adds new event listener.
@@ -552,7 +552,7 @@ class xt {
552
552
  * Checks if specified method is supported by current component.
553
553
  */
554
554
  i(this, "supports");
555
- this.postEvent = e, this.state = new w({ isOpened: !1 }, this.ee), this.supports = v(t, { open: "web_app_open_popup" });
555
+ this.postEvent = e, this.state = new m({ isOpened: !1 }, this.ee), this.supports = C(t, { open: "web_app_open_popup" });
556
556
  }
557
557
  /**
558
558
  * Shows whether popup is currently opened.
@@ -580,7 +580,7 @@ class xt {
580
580
  try {
581
581
  const { button_id: e = null } = await f(
582
582
  "web_app_open_popup",
583
- Et(t),
583
+ kt(t),
584
584
  "popup_closed",
585
585
  { postEvent: this.postEvent }
586
586
  );
@@ -590,9 +590,9 @@ class xt {
590
590
  }
591
591
  }
592
592
  }
593
- class Vt {
593
+ class xt {
594
594
  constructor(t, e = g) {
595
- i(this, "ee", new m());
595
+ i(this, "ee", new w());
596
596
  i(this, "state");
597
597
  /**
598
598
  * Adds new event listener.
@@ -606,7 +606,7 @@ class Vt {
606
606
  * Checks if specified method is supported by current component.
607
607
  */
608
608
  i(this, "supports");
609
- this.postEvent = e, this.state = new w({ isOpened: !1 }, this.ee), this.supports = v(t, {
609
+ this.postEvent = e, this.state = new m({ isOpened: !1 }, this.ee), this.supports = C(t, {
610
610
  close: "web_app_close_scan_qr_popup",
611
611
  open: "web_app_open_scan_qr_popup"
612
612
  });
@@ -649,7 +649,7 @@ class Vt {
649
649
  }
650
650
  }
651
651
  }
652
- function z(s) {
652
+ function M(s) {
653
653
  const {
654
654
  accentTextColor: t = null,
655
655
  backgroundColor: e = null,
@@ -663,7 +663,7 @@ function z(s) {
663
663
  sectionBackgroundColor: u = null,
664
664
  sectionHeaderTextColor: p = null,
665
665
  subtitleTextColor: b = null,
666
- textColor: P = null
666
+ textColor: S = null
667
667
  } = s;
668
668
  return {
669
669
  accentTextColor: t,
@@ -678,12 +678,12 @@ function z(s) {
678
678
  sectionBackgroundColor: u,
679
679
  sectionHeaderTextColor: p,
680
680
  subtitleTextColor: b,
681
- textColor: P
681
+ textColor: S
682
682
  };
683
683
  }
684
684
  class q {
685
685
  constructor(t) {
686
- i(this, "ee", new m());
686
+ i(this, "ee", new w());
687
687
  i(this, "state");
688
688
  /**
689
689
  * Adds new event listener.
@@ -693,7 +693,7 @@ class q {
693
693
  * Removes event listener.
694
694
  */
695
695
  i(this, "off", this.ee.off.bind(this.ee));
696
- this.state = new w(z(t), this.ee);
696
+ this.state = new m(M(t), this.ee);
697
697
  }
698
698
  /**
699
699
  * Requests fresh information about current theme.
@@ -706,7 +706,7 @@ class q {
706
706
  ...o,
707
707
  timeout: e
708
708
  });
709
- return M(n.theme_params);
709
+ return D(n.theme_params);
710
710
  }
711
711
  /**
712
712
  * Synchronizes specified instance of ThemeParams with the actual value in the native
@@ -714,8 +714,8 @@ class q {
714
714
  * @param themeParams - ThemeParams instance.
715
715
  */
716
716
  static sync(t) {
717
- x("theme_changed", (e) => {
718
- t.state.set(z(M(e.theme_params)));
717
+ E("theme_changed", (e) => {
718
+ t.state.set(M(D(e.theme_params)));
719
719
  });
720
720
  }
721
721
  /**
@@ -756,7 +756,7 @@ class q {
756
756
  * value is calculated according to theme background color.
757
757
  */
758
758
  get isDark() {
759
- return this.backgroundColor === null || j(this.backgroundColor);
759
+ return this.backgroundColor === null || K(this.backgroundColor);
760
760
  }
761
761
  /**
762
762
  * Returns current link color.
@@ -777,12 +777,12 @@ class q {
777
777
  return this.state.get("textColor");
778
778
  }
779
779
  }
780
- function k(s) {
780
+ function y(s) {
781
781
  return s < 0 ? 0 : s;
782
782
  }
783
- class E {
783
+ class k {
784
784
  constructor(t, e, o, n, r = g) {
785
- i(this, "ee", new m());
785
+ i(this, "ee", new w());
786
786
  i(this, "state");
787
787
  /**
788
788
  * Adds new event listener.
@@ -792,11 +792,11 @@ class E {
792
792
  * Removes event listener.
793
793
  */
794
794
  i(this, "off", this.ee.off.bind(this.ee));
795
- this.postEvent = r, this.state = new w({
796
- height: k(t),
795
+ this.postEvent = r, this.state = new m({
796
+ height: y(t),
797
797
  isExpanded: n,
798
- stableHeight: k(o),
799
- width: k(e)
798
+ stableHeight: y(o),
799
+ width: y(e)
800
800
  }, this.ee);
801
801
  }
802
802
  /**
@@ -823,17 +823,17 @@ class E {
823
823
  * @param viewport - Viewport instance.
824
824
  */
825
825
  static sync(t) {
826
- x("viewport_changed", (e) => {
826
+ E("viewport_changed", (e) => {
827
827
  const {
828
828
  height: o,
829
829
  width: n,
830
830
  is_expanded: r,
831
831
  is_state_stable: a
832
- } = e, h = k(o);
832
+ } = e, h = y(o);
833
833
  t.state.set({
834
834
  height: h,
835
835
  isExpanded: r,
836
- width: k(n),
836
+ width: y(n),
837
837
  stableHeight: a ? h : void 0
838
838
  });
839
839
  });
@@ -844,7 +844,7 @@ class E {
844
844
  * @param options - method options.
845
845
  */
846
846
  static async synced(t = {}) {
847
- const { height: e, isExpanded: o, width: n } = await this.request(t), r = new E(e, n, e, o, t.postEvent);
847
+ const { height: e, isExpanded: o, width: n } = await this.request(t), r = new k(e, n, e, o, t.postEvent);
848
848
  return this.sync(r), r;
849
849
  }
850
850
  /**
@@ -931,9 +931,9 @@ function I(s) {
931
931
  );
932
932
  return t.href;
933
933
  }
934
- class St {
934
+ class Vt {
935
935
  constructor(t, e, o, n, r, a = g) {
936
- i(this, "ee", new m());
936
+ i(this, "ee", new w());
937
937
  i(this, "state");
938
938
  /**
939
939
  * Adds new event listener.
@@ -951,17 +951,17 @@ class St {
951
951
  * Checks if specified method parameter is supported by current component.
952
952
  */
953
953
  i(this, "supportsParam");
954
- this.currentVersion = o, this.currentPlatform = n, this.createRequestId = r, this.postEvent = a, this.state = new w({
954
+ this.currentVersion = o, this.currentPlatform = n, this.createRequestId = r, this.postEvent = a, this.state = new m({
955
955
  backgroundColor: e,
956
956
  headerColor: t
957
- }, this.ee), this.supports = v(o, {
957
+ }, this.ee), this.supports = C(o, {
958
958
  openInvoice: "web_app_open_invoice",
959
959
  readTextFromClipboard: "web_app_read_text_from_clipboard",
960
960
  setHeaderColor: "web_app_set_header_color",
961
961
  setBackgroundColor: "web_app_set_background_color",
962
962
  requestPhoneAccess: "web_app_request_phone",
963
963
  requestWriteAccess: "web_app_request_write_access"
964
- }), this.supportsParam = _t(o, {
964
+ }), this.supportsParam = bt(o, {
965
965
  "setHeaderColor.color": ["web_app_set_header_color", "color"],
966
966
  "openLink.tryInstantView": ["web_app_open_link", "try_instant_view"]
967
967
  });
@@ -977,7 +977,7 @@ class St {
977
977
  * computed based on the current background color.
978
978
  */
979
979
  get colorScheme() {
980
- return j(this.backgroundColor) ? "dark" : "light";
980
+ return K(this.backgroundColor) ? "dark" : "light";
981
981
  }
982
982
  /**
983
983
  * Closes the Mini App.
@@ -1010,7 +1010,7 @@ class St {
1010
1010
  */
1011
1011
  openLink(t, e) {
1012
1012
  const o = I(t);
1013
- if (!C("web_app_open_link", this.version)) {
1013
+ if (!P("web_app_open_link", this.version)) {
1014
1014
  window.open(o, "_blank");
1015
1015
  return;
1016
1016
  }
@@ -1029,7 +1029,7 @@ class St {
1029
1029
  const { hostname: e, pathname: o, search: n } = new URL(I(t));
1030
1030
  if (e !== "t.me")
1031
1031
  throw new Error(`URL has not allowed hostname: ${e}. Only "t.me" is allowed`);
1032
- if (!C("web_app_open_tg_link", this.version)) {
1032
+ if (!P("web_app_open_tg_link", this.version)) {
1033
1033
  window.location.href = t;
1034
1034
  return;
1035
1035
  }
@@ -1151,14 +1151,14 @@ class St {
1151
1151
  return this.currentVersion;
1152
1152
  }
1153
1153
  }
1154
- class $ extends Error {
1154
+ class F extends Error {
1155
1155
  constructor(t, e) {
1156
- super(`Method "${t}" is not supported in the Mini Apps version ${e}.`), Object.setPrototypeOf(this, $.prototype);
1156
+ super(`Method "${t}" is not supported in the Mini Apps version ${e}.`), Object.setPrototypeOf(this, F.prototype);
1157
1157
  }
1158
1158
  }
1159
- class A extends Error {
1159
+ class j extends Error {
1160
1160
  constructor(t, e, o) {
1161
- super(`Parameter "${e}" in method "${t}" is not supported in the Mini Apps version ${o}.`), Object.setPrototypeOf(this, A.prototype);
1161
+ super(`Parameter "${e}" in method "${t}" is not supported in the Mini Apps version ${o}.`), Object.setPrototypeOf(this, j.prototype);
1162
1162
  }
1163
1163
  }
1164
1164
  function J(s, t) {
@@ -1167,10 +1167,10 @@ function J(s, t) {
1167
1167
  function _(s, t) {
1168
1168
  t !== null && J(s, t);
1169
1169
  }
1170
- function W(s, t) {
1170
+ function N(s, t) {
1171
1171
  J(s, `${t}px`);
1172
1172
  }
1173
- function Pt(s) {
1173
+ function St(s) {
1174
1174
  const {
1175
1175
  backgroundColor: t,
1176
1176
  buttonTextColor: e,
@@ -1182,52 +1182,52 @@ function Pt(s) {
1182
1182
  } = s;
1183
1183
  _("--tg-theme-bg-color", t), _("--tg-theme-button-color", r), _("--tg-theme-button-text-color", e), _("--tg-theme-hint-color", n), _("--tg-theme-link-color", a), _("--tg-theme-secondary-bg-color", o), _("--tg-theme-text-color", h);
1184
1184
  }
1185
- function qt(s, t) {
1185
+ function Pt(s, t) {
1186
1186
  const { backgroundColor: e, secondaryBackgroundColor: o } = t, { backgroundColor: n, headerColor: r } = s;
1187
1187
  _("--tg-bg-color", n), _("--tg-header-color", r === "bg_color" ? e : o);
1188
1188
  }
1189
- function Ot(s) {
1190
- const t = () => Pt(s);
1189
+ function qt(s) {
1190
+ const t = () => St(s);
1191
1191
  s.on("changed", t), t();
1192
1192
  }
1193
- function Tt(s, t) {
1194
- const e = () => qt(s, t);
1193
+ function Ot(s, t) {
1194
+ const e = () => Pt(s, t);
1195
1195
  t.on("changed", e), s.on("backgroundColorChanged", e), s.on("headerColorChanged", e), e();
1196
1196
  }
1197
- function Bt(s) {
1197
+ function Tt(s) {
1198
1198
  const t = () => {
1199
- W("--tg-viewport-height", s.height);
1199
+ N("--tg-viewport-height", s.height);
1200
1200
  }, e = () => {
1201
- W("--tg-viewport-stable-height", s.stableHeight);
1201
+ N("--tg-viewport-stable-height", s.stableHeight);
1202
1202
  };
1203
1203
  s.on("heightChanged", t), s.on("stableHeightChanged", e), t(), e();
1204
1204
  }
1205
- function It(s) {
1205
+ function Bt(s) {
1206
1206
  return typeof s == "boolean" ? s ? { themeParams: !0, viewport: !0, webApp: !0 } : {} : s;
1207
1207
  }
1208
1208
  function G(s) {
1209
1209
  return `telegram-mini-apps-${s}`;
1210
1210
  }
1211
- function V(s, t) {
1211
+ function x(s, t) {
1212
1212
  sessionStorage.setItem(G(s), JSON.stringify(t));
1213
1213
  }
1214
- function S(s) {
1214
+ function V(s) {
1215
1215
  const t = sessionStorage.getItem(G(s));
1216
1216
  return t ? JSON.parse(t) : null;
1217
1217
  }
1218
- function $t(s, t, e) {
1219
- const { isVisible: o = !1 } = s ? S("back-button") || {} : {}, n = new ft(o, t, e);
1218
+ function It(s, t, e) {
1219
+ const { isVisible: o = !1 } = s ? V("back-button") || {} : {}, n = new _t(o, t, e);
1220
1220
  return n.on("isVisibleChanged", () => {
1221
- V("back-button", { isVisible: n.isVisible });
1221
+ x("back-button", { isVisible: n.isVisible });
1222
1222
  }), n;
1223
1223
  }
1224
- function At(s, t) {
1225
- const { isConfirmationNeeded: e = !1 } = s ? S("closing-behavior") || {} : {}, o = new wt(e, t);
1226
- return o.on("isConfirmationNeededChanged", () => V("closing-behavior", {
1224
+ function $t(s, t) {
1225
+ const { isConfirmationNeeded: e = !1 } = s ? V("closing-behavior") || {} : {}, o = new ft(e, t);
1226
+ return o.on("isConfirmationNeededChanged", () => x("closing-behavior", {
1227
1227
  isConfirmationNeeded: o.isConfirmationNeeded
1228
1228
  })), o;
1229
1229
  }
1230
- function Ht(s, t, e, o) {
1230
+ function At(s, t, e, o) {
1231
1231
  const {
1232
1232
  backgroundColor: n = t,
1233
1233
  isEnabled: r = !1,
@@ -1235,7 +1235,7 @@ function Ht(s, t, e, o) {
1235
1235
  isProgressVisible: h = !1,
1236
1236
  textColor: c = e,
1237
1237
  text: l = ""
1238
- } = s ? S("main-button") || {} : {}, u = new kt(
1238
+ } = s ? V("main-button") || {} : {}, u = new yt(
1239
1239
  n,
1240
1240
  r,
1241
1241
  a,
@@ -1243,7 +1243,7 @@ function Ht(s, t, e, o) {
1243
1243
  l,
1244
1244
  c,
1245
1245
  o
1246
- ), p = () => V("main-button", {
1246
+ ), p = () => x("main-button", {
1247
1247
  backgroundColor: u.backgroundColor,
1248
1248
  isEnabled: u.isEnabled,
1249
1249
  isVisible: u.isVisible,
@@ -1253,34 +1253,24 @@ function Ht(s, t, e, o) {
1253
1253
  });
1254
1254
  return u.on("backgroundColorChanged", p), u.on("isEnabledChanged", p), u.on("isVisibleChanged", p), u.on("isProgressVisibleChanged", p), u.on("textColorChanged", p), u.on("textChanged", p), u;
1255
1255
  }
1256
- function Rt(s, t) {
1257
- return s ? (e, o) => {
1258
- if (!C(e, t))
1259
- throw new $(e, t);
1260
- return gt(o) && it(e, o).forEach((n) => {
1261
- if (!C(e, n, t))
1262
- throw new A(e, n, t);
1263
- }), g(e, o);
1264
- } : g;
1265
- }
1266
- function Dt() {
1256
+ function Ht() {
1267
1257
  let s = 0;
1268
1258
  return () => (s += 1, s.toString());
1269
1259
  }
1270
- function Lt(s) {
1260
+ function Rt(s) {
1271
1261
  const t = new q(s);
1272
1262
  return q.sync(t), t;
1273
1263
  }
1274
- async function Mt(s, t, e) {
1264
+ async function Dt(s, t, e) {
1275
1265
  const {
1276
1266
  height: o = window.innerHeight,
1277
1267
  stableHeight: n = window.innerHeight,
1278
1268
  width: r = window.innerWidth,
1279
1269
  isExpanded: a = !1
1280
- } = s ? S("viewport") || {} : {}, c = t === "macos" || t === "web" ? (() => {
1281
- const u = new E(o, r, n, a, e);
1282
- return E.sync(u), u;
1283
- })() : await E.synced({ postEvent: e }), l = () => V("viewport", {
1270
+ } = s ? V("viewport") || {} : {}, c = t === "macos" || t === "web" ? (() => {
1271
+ const u = new k(o, r, n, a, e);
1272
+ return k.sync(u), u;
1273
+ })() : await k.synced({ postEvent: e }), l = () => x("viewport", {
1284
1274
  height: c.height,
1285
1275
  isExpanded: c.isExpanded,
1286
1276
  stableHeight: c.stableHeight,
@@ -1288,24 +1278,24 @@ async function Mt(s, t, e) {
1288
1278
  });
1289
1279
  return c.on("heightChanged", l), c.on("isExpandedChanged", l), c.on("stableHeightChanged", l), c.on("widthChanged", l), c;
1290
1280
  }
1291
- function Nt(s, t, e, o, n, r) {
1281
+ function Lt(s, t, e, o, n, r) {
1292
1282
  const {
1293
1283
  backgroundColor: a = t,
1294
1284
  headerColor: h = "bg_color"
1295
- } = s ? S("web-app") || {} : {}, c = new St(
1285
+ } = s ? V("web-app") || {} : {}, c = new Vt(
1296
1286
  h,
1297
1287
  a,
1298
1288
  e,
1299
1289
  o,
1300
1290
  n,
1301
1291
  r
1302
- ), l = () => V("web-app", {
1292
+ ), l = () => x("web-app", {
1303
1293
  backgroundColor: c.backgroundColor,
1304
1294
  headerColor: c.headerColor
1305
1295
  });
1306
1296
  return c.on("backgroundColorChanged", l), c.on("headerColorChanged", l), c;
1307
1297
  }
1308
- async function zt(s = {}) {
1298
+ async function Mt(s = {}) {
1309
1299
  const {
1310
1300
  checkCompat: t = !0,
1311
1301
  cssVars: e = !1,
@@ -1315,88 +1305,88 @@ async function zt(s = {}) {
1315
1305
  launchParams: a,
1316
1306
  debug: h = !1
1317
1307
  } = s;
1318
- h && at(h), typeof r == "string" && ct(r);
1319
- const { launchParams: c, isPageReload: l } = U({
1308
+ h && it(h), typeof r == "string" && at(r);
1309
+ const { launchParams: c, isPageReload: l } = z({
1320
1310
  currentLaunchParams: typeof a == "string" || a instanceof URLSearchParams ? rt(a) : a
1321
1311
  }), {
1322
1312
  initData: u,
1323
1313
  initDataRaw: p,
1324
1314
  version: b,
1325
- platform: P,
1326
- themeParams: H
1315
+ platform: S,
1316
+ themeParams: $
1327
1317
  } = c, {
1328
1318
  backgroundColor: Q = "#ffffff",
1329
1319
  buttonColor: Z = "#000000",
1330
1320
  buttonTextColor: X = "#ffffff"
1331
- } = H, R = Dt(), d = Rt(t, b), O = Lt(H), D = Nt(
1321
+ } = $, A = Ht(), d = t ? ct(b) : g, O = Rt($), H = Lt(
1332
1322
  l,
1333
1323
  Q,
1334
1324
  b,
1335
- P,
1336
- R,
1325
+ S,
1326
+ A,
1337
1327
  d
1338
1328
  ), {
1339
1329
  themeParams: Y,
1340
1330
  viewport: tt,
1341
1331
  webApp: et
1342
- } = It(e);
1343
- et && Tt(D, O), Y && Ot(O);
1344
- const L = await Mt(l, P, d);
1345
- if (tt && Bt(L), n && ht()) {
1346
- const y = document.createElement("style");
1347
- y.id = "telegram-custom-styles", document.head.appendChild(y), x("set_custom_style", (B) => {
1348
- y.innerHTML = B;
1332
+ } = Bt(e);
1333
+ et && Ot(H, O), Y && qt(O);
1334
+ const R = await Dt(l, S, d);
1335
+ if (tt && Tt(R), n && ht()) {
1336
+ const v = document.createElement("style");
1337
+ v.id = "telegram-custom-styles", document.head.appendChild(v), E("set_custom_style", (B) => {
1338
+ v.innerHTML = B;
1349
1339
  }), d("iframe_ready");
1350
1340
  }
1351
1341
  const T = {
1352
- backButton: $t(l, b, d),
1353
- closingBehavior: At(l, d),
1354
- cloudStorage: new Ct(b, R, d),
1355
- haptic: new vt(b, d),
1356
- mainButton: Ht(l, Z, X, d),
1357
- popup: new xt(b, d),
1342
+ backButton: It(l, b, d),
1343
+ closingBehavior: $t(l, d),
1344
+ cloudStorage: new wt(b, A, d),
1345
+ haptic: new Ct(b, d),
1346
+ mainButton: At(l, Z, X, d),
1347
+ popup: new Et(b, d),
1358
1348
  postEvent: d,
1359
- qrScanner: new Vt(b, d),
1349
+ qrScanner: new xt(b, d),
1360
1350
  themeParams: O,
1361
- viewport: L,
1362
- webApp: D
1351
+ viewport: R,
1352
+ webApp: H
1363
1353
  };
1364
1354
  if (u !== void 0) {
1365
- const { authDate: y, hash: B, ...st } = u;
1366
- T.initData = new yt(y, B, st), T.initDataRaw = p;
1355
+ const { authDate: v, hash: B, ...st } = u;
1356
+ T.initData = new vt(v, B, st), T.initDataRaw = p;
1367
1357
  }
1368
1358
  return T;
1369
1359
  }
1370
- function Xt(s = {}) {
1371
- return bt(zt(s), s.timeout || 1e3);
1360
+ function Qt(s = {}) {
1361
+ return gt(Mt(s), s.timeout || 1e3);
1372
1362
  }
1373
- function Wt() {
1363
+ function Nt() {
1374
1364
  try {
1375
- return U(), !0;
1365
+ return z(), !0;
1376
1366
  } catch {
1377
1367
  return !1;
1378
1368
  }
1379
1369
  }
1380
- function Yt() {
1381
- return Wt();
1370
+ function Zt() {
1371
+ return Nt();
1382
1372
  }
1383
1373
  export {
1384
- ft as BackButton,
1385
- wt as ClosingBehaviour,
1386
- Ct as CloudStorage,
1387
- vt as HapticFeedback,
1388
- yt as InitData,
1389
- kt as MainButton,
1390
- $ as MethodNotSupportedError,
1391
- A as ParameterUnsupportedError,
1392
- xt as Popup,
1393
- Vt as QRScanner,
1374
+ _t as BackButton,
1375
+ ft as ClosingBehaviour,
1376
+ wt as CloudStorage,
1377
+ Ct as HapticFeedback,
1378
+ vt as InitData,
1379
+ yt as MainButton,
1380
+ F as MethodNotSupportedError,
1381
+ j as ParameterUnsupportedError,
1382
+ Et as Popup,
1383
+ xt as QRScanner,
1394
1384
  q as ThemeParams,
1395
- E as Viewport,
1396
- St as WebApp,
1385
+ k as Viewport,
1386
+ Vt as WebApp,
1397
1387
  I as formatURL,
1398
- Xt as init,
1399
- Wt as isTMA,
1400
- Yt as isTWA
1388
+ Qt as init,
1389
+ Nt as isTMA,
1390
+ Zt as isTWA
1401
1391
  };
1402
1392
  //# sourceMappingURL=index.mjs.map