@tma.js/sdk 1.4.1 → 1.4.3

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,7 +1,7 @@
1
1
  var Rt = Object.defineProperty;
2
2
  var It = (r, t, e) => t in r ? Rt(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
3
3
  var o = (r, t, e) => (It(r, typeof t != "symbol" ? t + "" : t, e), e);
4
- function H(r) {
4
+ function R(r) {
5
5
  return typeof r == "object" && r !== null && !Array.isArray(r);
6
6
  }
7
7
  function ut() {
@@ -11,7 +11,7 @@ function Lt() {
11
11
  const r = ut();
12
12
  return r ? r.type === "reload" : null;
13
13
  }
14
- function I() {
14
+ function L() {
15
15
  return new TypeError("Value has unexpected type");
16
16
  }
17
17
  class F extends Error {
@@ -50,7 +50,7 @@ function $t(r) {
50
50
  return t;
51
51
  } catch {
52
52
  }
53
- throw I();
53
+ throw L();
54
54
  }
55
55
  class Tt extends z {
56
56
  constructor(e, s, n) {
@@ -66,12 +66,12 @@ class Tt extends z {
66
66
  return this.itemParser = typeof e == "function" ? e : e.parse.bind(e), this;
67
67
  }
68
68
  }
69
- function L(r, t) {
69
+ function $(r, t) {
70
70
  return () => new z(r, !1, t);
71
71
  }
72
- class G extends Error {
72
+ class j extends Error {
73
73
  constructor(t, { cause: e, type: s } = {}) {
74
- super(`Unable to parse field "${t}"${s ? ` as ${s}` : ""}`, { cause: e }), Object.setPrototypeOf(this, G.prototype);
74
+ super(`Unable to parse field "${t}"${s ? ` as ${s}` : ""}`, { cause: e }), Object.setPrototypeOf(this, j.prototype);
75
75
  }
76
76
  }
77
77
  function ht(r, t) {
@@ -92,10 +92,10 @@ function ht(r, t) {
92
92
  try {
93
93
  c = a(p);
94
94
  } catch (h) {
95
- throw h instanceof F ? new G(i, {
95
+ throw h instanceof F ? new j(i, {
96
96
  type: h.type,
97
97
  cause: h
98
- }) : new G(i, { cause: h });
98
+ }) : new j(i, { cause: h });
99
99
  }
100
100
  c !== void 0 && (e[s] = c);
101
101
  }
@@ -104,7 +104,7 @@ function ht(r, t) {
104
104
  function Bt(r) {
105
105
  return new Tt((t) => t, !1, r);
106
106
  }
107
- const k = L((r) => {
107
+ const k = $((r) => {
108
108
  if (typeof r == "boolean")
109
109
  return r;
110
110
  const t = String(r);
@@ -112,8 +112,8 @@ const k = L((r) => {
112
112
  return !0;
113
113
  if (t === "0" || t === "false")
114
114
  return !1;
115
- throw I();
116
- }, "boolean"), q = L((r) => {
115
+ throw L();
116
+ }, "boolean"), q = $((r) => {
117
117
  if (typeof r == "number")
118
118
  return r;
119
119
  if (typeof r == "string") {
@@ -121,12 +121,12 @@ const k = L((r) => {
121
121
  if (!Number.isNaN(t))
122
122
  return t;
123
123
  }
124
- throw I();
125
- }, "number"), pt = L((r) => r instanceof Date ? r : new Date(q().parse(r) * 1e3), "Date");
124
+ throw L();
125
+ }, "number"), pt = $((r) => r instanceof Date ? r : new Date(q().parse(r) * 1e3), "Date");
126
126
  function Y(r) {
127
127
  let t = r;
128
128
  if (typeof t == "string" && (t = JSON.parse(t)), typeof t != "object" || t === null || Array.isArray(t))
129
- throw I();
129
+ throw L();
130
130
  return t;
131
131
  }
132
132
  function f(r, t) {
@@ -168,15 +168,15 @@ function ft(r) {
168
168
  }, 0)
169
169
  ) < 120;
170
170
  }
171
- const u = L((r) => {
171
+ const u = $((r) => {
172
172
  if (typeof r == "string" || typeof r == "number")
173
173
  return r.toString();
174
- throw I();
175
- }, "string"), gt = L((r) => dt(u().parse(r)), "rgb");
174
+ throw L();
175
+ }, "string"), gt = $((r) => dt(u().parse(r)), "rgb");
176
176
  function X(r, t) {
177
177
  return new z((e) => {
178
178
  if (typeof e != "string" && !(e instanceof URLSearchParams))
179
- throw I();
179
+ throw L();
180
180
  const s = typeof e == "string" ? new URLSearchParams(e) : e;
181
181
  return ht(r, (n) => {
182
182
  const i = s.get(n);
@@ -196,7 +196,7 @@ function Wt() {
196
196
  username: u().optional()
197
197
  }, "Chat");
198
198
  }
199
- class Ot {
199
+ class Nt {
200
200
  constructor(t) {
201
201
  this.initData = t;
202
202
  }
@@ -342,16 +342,16 @@ function wt() {
342
342
  function tr(r) {
343
343
  return wt().parse(r);
344
344
  }
345
- function Nt(r) {
345
+ function Ot(r) {
346
346
  return r.replace(/(^|_)bg/, (t, e) => `${e}background`).replace(/_([a-z])/g, (t, e) => e.toUpperCase());
347
347
  }
348
348
  function Ht(r) {
349
349
  return r.replace(/[A-Z]/g, (t) => `_${t.toLowerCase()}`).replace(/(^|_)background/, (t, e) => `${e}bg`);
350
350
  }
351
- const _t = L(
351
+ const _t = $(
352
352
  (r) => {
353
353
  const t = gt().optional();
354
- return Object.entries(Y(r)).reduce((e, [s, n]) => (e[Nt(s)] = t.parse(n), e), {});
354
+ return Object.entries(Y(r)).reduce((e, [s, n]) => (e[Ot(s)] = t.parse(n), e), {});
355
355
  },
356
356
  "ThemeParams"
357
357
  );
@@ -612,14 +612,14 @@ function mt() {
612
612
  }
613
613
  }, "LaunchParams");
614
614
  }
615
- function jt(r) {
615
+ function Gt(r) {
616
616
  return mt().parse(r);
617
617
  }
618
618
  function yt(r) {
619
619
  const t = r.includes("?") ? r.replace("#", "&").slice(r.indexOf("?") + 1) : r.slice(r.indexOf("#") + 1);
620
- return jt(t);
620
+ return Gt(t);
621
621
  }
622
- function Gt() {
622
+ function jt() {
623
623
  return yt(window.location.href);
624
624
  }
625
625
  function Ft() {
@@ -634,7 +634,7 @@ function zt() {
634
634
  } catch {
635
635
  }
636
636
  try {
637
- return Gt();
637
+ return jt();
638
638
  } catch {
639
639
  }
640
640
  return null;
@@ -703,10 +703,10 @@ function rr() {
703
703
  }
704
704
  }
705
705
  function Xt(r) {
706
- return "external" in r && H(r.external) && "notify" in r.external && typeof r.external.notify == "function";
706
+ return "external" in r && R(r.external) && "notify" in r.external && typeof r.external.notify == "function";
707
707
  }
708
708
  function te(r) {
709
- return "TelegramWebviewProxy" in r && H(r.TelegramWebviewProxy) && "postEvent" in r.TelegramWebviewProxy && typeof r.TelegramWebviewProxy.postEvent == "function";
709
+ return "TelegramWebviewProxy" in r && R(r.TelegramWebviewProxy) && "postEvent" in r.TelegramWebviewProxy && typeof r.TelegramWebviewProxy.postEvent == "function";
710
710
  }
711
711
  function vt() {
712
712
  try {
@@ -799,12 +799,17 @@ const re = f({
799
799
  eventType: u(),
800
800
  eventData: (r) => r
801
801
  });
802
- function se(r, t) {
802
+ function se(r) {
803
+ return re.parse(r);
804
+ }
805
+ function ne(r, t) {
803
806
  window.dispatchEvent(new MessageEvent("message", {
804
- data: JSON.stringify({ eventType: r, eventData: t })
807
+ data: JSON.stringify({ eventType: r, eventData: t }),
808
+ // We specify window.parent to imitate the case, it sent us this event.
809
+ source: window.parent
805
810
  }));
806
811
  }
807
- function ne() {
812
+ function ie() {
808
813
  const r = window;
809
814
  "TelegramGameProxy_receiveEvent" in r || [
810
815
  ["TelegramGameProxy_receiveEvent"],
@@ -817,55 +822,56 @@ function ne() {
817
822
  let e = r;
818
823
  t.forEach((s, n, i) => {
819
824
  if (n === i.length - 1) {
820
- e[s] = se;
825
+ e[s] = ne;
821
826
  return;
822
827
  }
823
828
  s in e || (e[s] = {}), e = e[s];
824
829
  });
825
830
  });
826
831
  }
827
- function ie(r) {
828
- ne(), window.addEventListener("message", (t) => {
829
- try {
830
- const { eventType: e, eventData: s } = re.parse(t.data);
831
- r(e, s);
832
- } catch {
833
- }
832
+ function oe(r) {
833
+ ie(), window.addEventListener("message", (t) => {
834
+ if (t.source === window.parent)
835
+ try {
836
+ const { eventType: e, eventData: s } = se(t.data);
837
+ r(e, s);
838
+ } catch {
839
+ }
834
840
  });
835
841
  }
836
- function oe() {
842
+ function ae() {
837
843
  return f({
838
844
  req_id: u(),
839
845
  data: (r) => r === null ? r : u().optional().parse(r)
840
846
  });
841
847
  }
842
- function ae() {
848
+ function ce() {
843
849
  return f({
844
850
  req_id: u(),
845
851
  result: (r) => r,
846
852
  error: u().optional()
847
853
  });
848
854
  }
849
- function ce() {
855
+ function ue() {
850
856
  return f({
851
857
  slug: u(),
852
858
  status: u()
853
859
  });
854
860
  }
855
- function ue() {
861
+ function he() {
856
862
  return f({ status: u() });
857
863
  }
858
- function he() {
864
+ function pe() {
859
865
  return f({
860
866
  button_id: (r) => r == null ? void 0 : u().parse(r)
861
867
  });
862
868
  }
863
- function pe() {
869
+ function le() {
864
870
  return f({
865
871
  data: u().optional()
866
872
  });
867
873
  }
868
- function le() {
874
+ function de() {
869
875
  return f({
870
876
  theme_params: (r) => {
871
877
  const t = gt().optional();
@@ -873,7 +879,7 @@ function le() {
873
879
  }
874
880
  });
875
881
  }
876
- function de() {
882
+ function fe() {
877
883
  return f({
878
884
  height: q(),
879
885
  width: (r) => r == null ? window.innerWidth : q().parse(r),
@@ -881,10 +887,10 @@ function de() {
881
887
  is_expanded: k()
882
888
  });
883
889
  }
884
- function fe() {
890
+ function ge() {
885
891
  return f({ status: u() });
886
892
  }
887
- function ge() {
893
+ function we() {
888
894
  const r = new w(), t = (e, ...s) => {
889
895
  V.log("Emitting processed event:", e, ...s), r.emit(e, ...s);
890
896
  };
@@ -895,33 +901,33 @@ function ge() {
895
901
  is_state_stable: !0,
896
902
  is_expanded: !0
897
903
  });
898
- }), ie((e, s) => {
904
+ }), oe((e, s) => {
899
905
  V.log("Received raw event:", e, s);
900
906
  try {
901
907
  switch (e) {
902
908
  case "viewport_changed":
903
- return t(e, de().parse(s));
909
+ return t(e, fe().parse(s));
904
910
  case "theme_changed":
905
- return t(e, le().parse(s));
911
+ return t(e, de().parse(s));
906
912
  case "popup_closed":
907
913
  return (
908
914
  // Sent on desktop.
909
- s == null ? t(e, {}) : t(e, he().parse(s))
915
+ s == null ? t(e, {}) : t(e, pe().parse(s))
910
916
  );
911
917
  case "set_custom_style":
912
918
  return t(e, u().parse(s));
913
919
  case "qr_text_received":
914
- return t(e, pe().parse(s));
920
+ return t(e, le().parse(s));
915
921
  case "clipboard_text_received":
916
- return t(e, oe().parse(s));
922
+ return t(e, ae().parse(s));
917
923
  case "invoice_closed":
918
- return t(e, ce().parse(s));
924
+ return t(e, ue().parse(s));
919
925
  case "phone_requested":
920
- return t("phone_requested", ue().parse(s));
926
+ return t("phone_requested", he().parse(s));
921
927
  case "custom_method_invoked":
922
- return t("custom_method_invoked", ae().parse(s));
928
+ return t("custom_method_invoked", ce().parse(s));
923
929
  case "write_access_requested":
924
- return t("write_access_requested", fe().parse(s));
930
+ return t("write_access_requested", ge().parse(s));
925
931
  case "main_button_pressed":
926
932
  case "back_button_pressed":
927
933
  case "settings_button_pressed":
@@ -939,24 +945,24 @@ function ge() {
939
945
  const Q = "telegram-mini-apps-cached-emitter";
940
946
  function U() {
941
947
  const r = window;
942
- return r[Q] === void 0 && (r[Q] = ge()), r[Q];
948
+ return r[Q] === void 0 && (r[Q] = we()), r[Q];
943
949
  }
944
- function $(r, t) {
950
+ function T(r, t) {
945
951
  U().off(r, t);
946
952
  }
947
953
  function y(r, t) {
948
- return U().on(r, t), () => $(r, t);
954
+ return U().on(r, t), () => T(r, t);
949
955
  }
950
956
  function ir(r, t) {
951
- return U().once(r, t), () => $(r, t);
957
+ return U().once(r, t), () => T(r, t);
952
958
  }
953
- function we(r) {
959
+ function _e(r) {
954
960
  U().unsubscribe(r);
955
961
  }
956
962
  function or(r) {
957
- return U().subscribe(r), () => we(r);
963
+ return U().subscribe(r), () => _e(r);
958
964
  }
959
- function _e(r, t) {
965
+ function be(r, t) {
960
966
  const e = r.split("."), s = t.split("."), n = Math.max(e.length, s.length);
961
967
  for (let i = 0; i < n; i += 1) {
962
968
  const a = parseInt(e[i] || "0", 10), c = parseInt(s[i] || "0", 10);
@@ -966,9 +972,9 @@ function _e(r, t) {
966
972
  return 0;
967
973
  }
968
974
  function P(r, t) {
969
- return _e(r, t) <= 0;
975
+ return be(r, t) <= 0;
970
976
  }
971
- function R(r, t, e) {
977
+ function I(r, t, e) {
972
978
  if (typeof e == "string") {
973
979
  if (r === "web_app_open_link" && t === "try_instant_view")
974
980
  return P("6.4", e);
@@ -1002,12 +1008,12 @@ function R(r, t, e) {
1002
1008
  }
1003
1009
  }
1004
1010
  function E(r, t) {
1005
- return (e) => R(t[e], r);
1011
+ return (e) => I(t[e], r);
1006
1012
  }
1007
1013
  function St(r, t) {
1008
1014
  return (e) => {
1009
1015
  const [s, n] = t[e];
1010
- return R(s, n, r);
1016
+ return I(s, n, r);
1011
1017
  };
1012
1018
  }
1013
1019
  function d(r, t, e) {
@@ -1033,13 +1039,13 @@ function d(r, t, e) {
1033
1039
  "Unable to determine current environment and possible way to send event."
1034
1040
  );
1035
1041
  }
1036
- function be(r) {
1042
+ function me(r) {
1037
1043
  return (t, e) => {
1038
- if (!R(t, r))
1044
+ if (!I(t, r))
1039
1045
  throw new tt(t, r);
1040
- if (H(e)) {
1046
+ if (R(e)) {
1041
1047
  let s;
1042
- if (t === "web_app_open_link" && "try_instant_view" in e ? s = "try_instant_view" : t === "web_app_set_header_color" && "color" in e && (s = "color"), s && !R(t, s, r))
1048
+ if (t === "web_app_open_link" && "try_instant_view" in e ? s = "try_instant_view" : t === "web_app_set_header_color" && "color" in e && (s = "color"), s && !I(t, s, r))
1043
1049
  throw new et(t, s, r);
1044
1050
  }
1045
1051
  return d(t, e);
@@ -1053,12 +1059,12 @@ class J extends Error {
1053
1059
  function ar(r) {
1054
1060
  return r instanceof J;
1055
1061
  }
1056
- function me(r) {
1062
+ function ye(r) {
1057
1063
  return new Promise((t) => {
1058
1064
  setTimeout(t, r);
1059
1065
  });
1060
1066
  }
1061
- function ye(r) {
1067
+ function Ee(r) {
1062
1068
  return new Promise((t, e) => {
1063
1069
  setTimeout(e, r, new J(r));
1064
1070
  });
@@ -1066,15 +1072,15 @@ function ye(r) {
1066
1072
  function xt(r, t) {
1067
1073
  return Promise.race([
1068
1074
  r(),
1069
- ye(t)
1075
+ Ee(t)
1070
1076
  ]);
1071
1077
  }
1072
1078
  function m(r, t, e, s) {
1073
1079
  let n, i, a, c;
1074
- typeof t == "string" || Array.isArray(t) ? (a = Array.isArray(t) ? t : [t], n = e) : (i = t, a = Array.isArray(e) ? e : [e], n = s), H(i) && typeof i.req_id == "string" && (c = i.req_id);
1080
+ typeof t == "string" || Array.isArray(t) ? (a = Array.isArray(t) ? t : [t], n = e) : (i = t, a = Array.isArray(e) ? e : [e], n = s), R(i) && typeof i.req_id == "string" && (c = i.req_id);
1075
1081
  const { postEvent: p = d, timeout: h } = n || {}, g = n && "capture" in n ? n.capture : null, _ = () => new Promise((A, l) => {
1076
1082
  const C = a.map((v) => y(v, (M) => {
1077
- c && (!H(M) || M.req_id !== c) || typeof g == "function" && !g(M) || (x(), A(M));
1083
+ c && (!R(M) || M.req_id !== c) || typeof g == "function" && !g(M) || (x(), A(M));
1078
1084
  })), x = () => C.forEach((v) => v());
1079
1085
  try {
1080
1086
  p(r, i);
@@ -1099,7 +1105,7 @@ async function O(r, t, e, s = {}) {
1099
1105
  throw new Error(i);
1100
1106
  return n;
1101
1107
  }
1102
- class Ee {
1108
+ class Ce {
1103
1109
  constructor(t, e, s = d) {
1104
1110
  o(this, "ee", new w());
1105
1111
  o(this, "state");
@@ -1114,7 +1120,7 @@ class Ee {
1114
1120
  * @param event - event name.
1115
1121
  * @param listener - event listener.
1116
1122
  */
1117
- o(this, "off", (t, e) => t === "click" ? $("back_button_pressed", e) : this.ee.off(t, e));
1123
+ o(this, "off", (t, e) => t === "click" ? T("back_button_pressed", e) : this.ee.off(t, e));
1118
1124
  /**
1119
1125
  * Checks if specified method is supported by current component.
1120
1126
  */
@@ -1149,18 +1155,15 @@ class Ee {
1149
1155
  function nt(r, t) {
1150
1156
  return r + (r.length > 0 && t.length > 0 ? ` ${t}` : t);
1151
1157
  }
1152
- function Ce(...r) {
1158
+ function ve(...r) {
1153
1159
  return r.reduce((t, e) => {
1154
1160
  let s = "";
1155
1161
  return typeof e == "string" ? s = e : typeof e == "object" && e !== null && (s = Object.entries(e).reduce((n, [i, a]) => a ? nt(n, i) : n, "")), nt(t, s);
1156
1162
  }, "");
1157
1163
  }
1158
- function ve(r) {
1159
- return typeof r == "object" && r !== null && !Array.isArray(null);
1160
- }
1161
1164
  function cr(...r) {
1162
- return r.reduce((t, e) => (ve(e) && Object.entries(e).forEach(([s, n]) => {
1163
- const i = Ce(t[s], n);
1165
+ return r.reduce((t, e) => (R(e) && Object.entries(e).forEach(([s, n]) => {
1166
+ const i = ve(t[s], n);
1164
1167
  i.length > 0 && (t[s] = i);
1165
1168
  }), t), {});
1166
1169
  }
@@ -1330,22 +1333,22 @@ function xe() {
1330
1333
  function qt(r) {
1331
1334
  return `telegram-mini-apps-${r}`;
1332
1335
  }
1333
- function T(r, t) {
1336
+ function B(r, t) {
1334
1337
  sessionStorage.setItem(qt(r), JSON.stringify(t));
1335
1338
  }
1336
- function B(r) {
1339
+ function D(r) {
1337
1340
  const t = sessionStorage.getItem(qt(r));
1338
1341
  return t ? JSON.parse(t) : null;
1339
1342
  }
1340
1343
  function qe(r, t, e) {
1341
- const { isVisible: s = !1 } = r ? B("back-button") || {} : {}, n = new Ee(s, t, e);
1344
+ const { isVisible: s = !1 } = r ? D("back-button") || {} : {}, n = new Ce(s, t, e);
1342
1345
  return n.on("change", () => {
1343
- T("back-button", { isVisible: n.isVisible });
1346
+ B("back-button", { isVisible: n.isVisible });
1344
1347
  }), n;
1345
1348
  }
1346
1349
  function Ae(r, t) {
1347
- const { isConfirmationNeeded: e = !1 } = r ? B("closing-behavior") || {} : {}, s = new Pe(e, t);
1348
- return s.on("change", () => T("closing-behavior", {
1350
+ const { isConfirmationNeeded: e = !1 } = r ? D("closing-behavior") || {} : {}, s = new Pe(e, t);
1351
+ return s.on("change", () => B("closing-behavior", {
1349
1352
  isConfirmationNeeded: s.isConfirmationNeeded
1350
1353
  })), s;
1351
1354
  }
@@ -1370,7 +1373,7 @@ class Ve {
1370
1373
  * @param event - event name.
1371
1374
  * @param listener - event listener.
1372
1375
  */
1373
- o(this, "off", (t, e) => t === "click" ? $("main_button_pressed", e) : this.ee.off(t, e));
1376
+ o(this, "off", (t, e) => t === "click" ? T("main_button_pressed", e) : this.ee.off(t, e));
1374
1377
  const {
1375
1378
  postEvent: e = d,
1376
1379
  text: s,
@@ -1522,7 +1525,7 @@ function Re(r, t, e, s) {
1522
1525
  isLoaderVisible: c = !1,
1523
1526
  textColor: p = e,
1524
1527
  text: h = ""
1525
- } = r ? B("main-button") || {} : {}, g = new Ve({
1528
+ } = r ? D("main-button") || {} : {}, g = new Ve({
1526
1529
  backgroundColor: n,
1527
1530
  isEnabled: i,
1528
1531
  isLoaderVisible: c,
@@ -1530,7 +1533,7 @@ function Re(r, t, e, s) {
1530
1533
  postEvent: s,
1531
1534
  text: h,
1532
1535
  textColor: p
1533
- }), _ = () => T("main-button", {
1536
+ }), _ = () => B("main-button", {
1534
1537
  backgroundColor: g.backgroundColor,
1535
1538
  isEnabled: g.isEnabled,
1536
1539
  isLoaderVisible: g.isLoaderVisible,
@@ -1697,7 +1700,7 @@ class Le {
1697
1700
  return await this.getRequestedContact();
1698
1701
  } catch {
1699
1702
  }
1700
- await me(n), n += 50;
1703
+ await ye(n), n += 50;
1701
1704
  }
1702
1705
  throw new Error("Unable to retrieve requested contact.");
1703
1706
  }, t);
@@ -1787,14 +1790,14 @@ function $e(r, t, e, s, n, i) {
1787
1790
  const {
1788
1791
  backgroundColor: a = t,
1789
1792
  headerColor: c = "bg_color"
1790
- } = r ? B("mini-app") || {} : {}, p = new Le({
1793
+ } = r ? D("mini-app") || {} : {}, p = new Le({
1791
1794
  headerColor: c,
1792
1795
  backgroundColor: a,
1793
1796
  version: e,
1794
1797
  botInline: s,
1795
1798
  createRequestId: n,
1796
1799
  postEvent: i
1797
- }), h = () => T("mini-app", {
1800
+ }), h = () => B("mini-app", {
1798
1801
  backgroundColor: p.backgroundColor,
1799
1802
  headerColor: p.headerColor
1800
1803
  });
@@ -1819,7 +1822,7 @@ class Be {
1819
1822
  * @param event - event name.
1820
1823
  * @param listener - event listener.
1821
1824
  */
1822
- o(this, "off", (t, e) => t === "click" ? $("settings_button_pressed", e) : this.ee.off(t, e));
1825
+ o(this, "off", (t, e) => t === "click" ? T("settings_button_pressed", e) : this.ee.off(t, e));
1823
1826
  /**
1824
1827
  * Checks if specified method is supported by current component.
1825
1828
  */
@@ -1852,16 +1855,16 @@ class Be {
1852
1855
  }
1853
1856
  }
1854
1857
  function De(r, t, e) {
1855
- const { isVisible: s = !1 } = r ? B("settings-button") || {} : {}, n = new Be(s, t, e);
1858
+ const { isVisible: s = !1 } = r ? D("settings-button") || {} : {}, n = new Be(s, t, e);
1856
1859
  return n.on("change", () => {
1857
- T("settings-button", { isVisible: n.isVisible });
1860
+ B("settings-button", { isVisible: n.isVisible });
1858
1861
  }), n;
1859
1862
  }
1860
1863
  function We(r) {
1861
1864
  const t = new Mt(r);
1862
1865
  return t.listen(), t;
1863
1866
  }
1864
- function Oe(r) {
1867
+ function Ne(r) {
1865
1868
  return ["macos", "tdesktop", "unigram", "web", "weba"].includes(r);
1866
1869
  }
1867
1870
  async function At(r) {
@@ -1873,10 +1876,10 @@ async function At(r) {
1873
1876
  isStateStable: t.is_state_stable
1874
1877
  };
1875
1878
  }
1876
- function D(r) {
1879
+ function W(r) {
1877
1880
  return r < 0 ? 0 : r;
1878
1881
  }
1879
- class Ne {
1882
+ class Oe {
1880
1883
  constructor(t) {
1881
1884
  o(this, "ee", new w());
1882
1885
  o(this, "state");
@@ -1897,10 +1900,10 @@ class Ne {
1897
1900
  postEvent: a = d
1898
1901
  } = t;
1899
1902
  this.postEvent = a, this.state = new b({
1900
- height: D(e),
1903
+ height: W(e),
1901
1904
  isExpanded: s,
1902
- stableHeight: D(i),
1903
- width: D(n)
1905
+ stableHeight: W(i),
1906
+ width: W(n)
1904
1907
  }, this.ee);
1905
1908
  }
1906
1909
  /**
@@ -1966,9 +1969,9 @@ class Ne {
1966
1969
  is_expanded: n,
1967
1970
  is_state_stable: i
1968
1971
  } = t, a = {
1969
- height: D(e),
1972
+ height: W(e),
1970
1973
  isExpanded: n,
1971
- width: D(s)
1974
+ width: W(s)
1972
1975
  };
1973
1976
  i && (a.stableHeight = a.height), this.state.set(a);
1974
1977
  });
@@ -2005,9 +2008,9 @@ class Ne {
2005
2008
  return this.stableHeight === this.height;
2006
2009
  }
2007
2010
  }
2008
- function j(r) {
2009
- const t = new Ne(r);
2010
- return t.on("change", () => T("viewport", {
2011
+ function G(r) {
2012
+ const t = new Oe(r);
2013
+ return t.on("change", () => B("viewport", {
2011
2014
  height: t.height,
2012
2015
  isExpanded: t.isExpanded,
2013
2016
  stableHeight: t.stableHeight,
@@ -2015,11 +2018,11 @@ function j(r) {
2015
2018
  })), t.listen(), t;
2016
2019
  }
2017
2020
  function He(r, t, e, s) {
2018
- const n = r ? B("viewport") : null;
2021
+ const n = r ? D("viewport") : null;
2019
2022
  if (n)
2020
- return j({ ...n, postEvent: e });
2021
- if (Oe(t))
2022
- return j({
2023
+ return G({ ...n, postEvent: e });
2024
+ if (Ne(t))
2025
+ return G({
2023
2026
  height: window.innerHeight,
2024
2027
  isExpanded: !0,
2025
2028
  postEvent: e,
@@ -2030,12 +2033,12 @@ function He(r, t, e, s) {
2030
2033
  return At({
2031
2034
  postEvent: e,
2032
2035
  timeout: 5e3
2033
- }).then(({ height: a, isStateStable: c, ...p }) => j({
2036
+ }).then(({ height: a, isStateStable: c, ...p }) => G({
2034
2037
  ...p,
2035
2038
  height: a,
2036
2039
  stableHeight: c ? a : 0
2037
2040
  }));
2038
- const i = j({
2041
+ const i = G({
2039
2042
  width: 0,
2040
2043
  height: 0,
2041
2044
  isExpanded: !1,
@@ -2077,7 +2080,7 @@ function ot(r) {
2077
2080
  const t = () => S("--tg-viewport-height", `${r.height}px`), e = () => S("--tg-viewport-width", `${r.width}px`), s = () => S("--tg-viewport-height", `${r.stableHeight}px`);
2078
2081
  r.on("change:height", t), r.on("change:width", e), r.on("change:stableHeight", s), t(), e(), s();
2079
2082
  }
2080
- function je(r) {
2083
+ function Ge(r) {
2081
2084
  return typeof r == "object" ? r : r ? {
2082
2085
  themeParams: !0,
2083
2086
  viewport: !0,
@@ -2085,10 +2088,10 @@ function je(r) {
2085
2088
  } : {};
2086
2089
  }
2087
2090
  function at(r, t, e, s) {
2088
- const n = je(r);
2091
+ const n = Ge(r);
2089
2092
  n.miniApp && Ue(t, e), n.themeParams && Me(e), n.viewport && (s instanceof Promise ? s.then(ot) : ot(s));
2090
2093
  }
2091
- function Ge(r) {
2094
+ function je(r) {
2092
2095
  const { hostname: t, pathname: e } = new URL(r, window.location.href);
2093
2096
  if (t !== "t.me")
2094
2097
  throw new Error(`Incorrect hostname: ${t}`);
@@ -2127,7 +2130,7 @@ class Fe {
2127
2130
  async open(t, e) {
2128
2131
  if (this.isOpened)
2129
2132
  throw new Error("Invoice is already opened");
2130
- const s = e ? Ge(t) : t;
2133
+ const s = e ? je(t) : t;
2131
2134
  this.isOpened = !0;
2132
2135
  try {
2133
2136
  return (await m(
@@ -2309,7 +2312,7 @@ class Ze {
2309
2312
  */
2310
2313
  openLink(t, e) {
2311
2314
  const s = new URL(t, window.location.href).toString();
2312
- if (!R("web_app_open_link", this.version)) {
2315
+ if (!I("web_app_open_link", this.version)) {
2313
2316
  window.open(s, "_blank");
2314
2317
  return;
2315
2318
  }
@@ -2332,7 +2335,7 @@ class Ze {
2332
2335
  } = new URL(t, window.location.href);
2333
2336
  if (e !== "t.me")
2334
2337
  throw new Error(`URL has not allowed hostname: ${e}. Only "t.me" is allowed`);
2335
- if (!R("web_app_open_tg_link", this.version)) {
2338
+ if (!I("web_app_open_tg_link", this.version)) {
2336
2339
  window.location.href = t;
2337
2340
  return;
2338
2341
  }
@@ -2371,7 +2374,7 @@ function ur(r = {}) {
2371
2374
  botInline: g = !1
2372
2375
  },
2373
2376
  isPageReload: _
2374
- } = Ct(), A = Te(), l = be(c);
2377
+ } = Ct(), A = Te(), l = me(c);
2375
2378
  vt() && (n && xe(), l("iframe_ready", { reload_supported: !0 }), y("reload_iframe", () => window.location.reload()));
2376
2379
  const C = {
2377
2380
  backButton: qe(_, c, l),
@@ -2401,7 +2404,7 @@ function ur(r = {}) {
2401
2404
  themeParams: We(h),
2402
2405
  utils: new Ze(c, A, l),
2403
2406
  ...i ? {
2404
- initData: new Ot(i),
2407
+ initData: new Nt(i),
2405
2408
  initDataRaw: a
2406
2409
  } : {}
2407
2410
  }, x = He(_, p, l, e);
@@ -2422,14 +2425,14 @@ function ur(r = {}) {
2422
2425
  throw i;
2423
2426
  }
2424
2427
  }
2425
- function W(r, t) {
2428
+ function N(r, t) {
2426
2429
  return r.startsWith(t) ? r : `${t}${r}`;
2427
2430
  }
2428
2431
  function hr(r) {
2429
2432
  const t = r.match(/#(.+)/);
2430
2433
  return t ? t[1] : null;
2431
2434
  }
2432
- async function N(r) {
2435
+ async function H(r) {
2433
2436
  return r === 0 ? !0 : Promise.race([
2434
2437
  new Promise((t) => {
2435
2438
  window.addEventListener("popstate", function e() {
@@ -2443,11 +2446,11 @@ async function N(r) {
2443
2446
  ]);
2444
2447
  }
2445
2448
  async function Ke() {
2446
- if (window.history.length <= 1 || (window.history.pushState(null, ""), await N(1 - window.history.length)))
2449
+ if (window.history.length <= 1 || (window.history.pushState(null, ""), await H(1 - window.history.length)))
2447
2450
  return;
2448
- let t = await N(-1);
2451
+ let t = await H(-1);
2449
2452
  for (; t; )
2450
- t = await N(-1);
2453
+ t = await H(-1);
2451
2454
  }
2452
2455
  class Ye {
2453
2456
  constructor(t, e, {
@@ -2464,9 +2467,9 @@ class Ye {
2464
2467
  if (!i.startsWith("/") && i.length > 0)
2465
2468
  throw new Error('Pathname should start with "/"');
2466
2469
  return {
2467
- pathname: W(i, "/"),
2468
- search: a ? W(a, "?") : "",
2469
- hash: c ? W(c, "#") : ""
2470
+ pathname: N(i, "/"),
2471
+ search: a ? N(a, "?") : "",
2472
+ hash: c ? N(c, "#") : ""
2470
2473
  };
2471
2474
  }), this.logger = new Pt(`[${n}]`, s);
2472
2475
  }
@@ -2484,7 +2487,7 @@ class Ye {
2484
2487
  search: c,
2485
2488
  hash: p
2486
2489
  } = t;
2487
- e = a + (c ? W(c, "?") : "") + (p ? W(p, "#") : "");
2490
+ e = a + (c ? N(c, "?") : "") + (p ? N(p, "#") : "");
2488
2491
  }
2489
2492
  const {
2490
2493
  pathname: s,
@@ -2713,7 +2716,7 @@ class Vt extends Ye {
2713
2716
  async syncHistory() {
2714
2717
  window.removeEventListener("popstate", this.onPopState);
2715
2718
  const e = `#${this.path}`;
2716
- await Ke(), d("web_app_setup_back_button", { is_visible: this.canGoBack }), this.canGoBack && this.canGoForward ? (this.logger.log("Setting up history: [<-, *, ->]"), window.history.replaceState(Z, ""), window.history.pushState(null, "", e), window.history.pushState(K, ""), await N(-1)) : this.canGoBack ? (this.logger.log("Setting up history: [<-, *]"), window.history.replaceState(Z, ""), window.history.pushState(null, "", e)) : this.canGoForward ? (this.logger.log("Setting up history: [*, ->]"), window.history.replaceState(null, e), window.history.pushState(K, ""), await N(-1)) : (this.logger.log("Setting up history: [~, *]"), window.history.replaceState(ct, ""), window.history.pushState(null, "", e)), window.addEventListener("popstate", this.onPopState);
2719
+ await Ke(), d("web_app_setup_back_button", { is_visible: this.canGoBack }), this.canGoBack && this.canGoForward ? (this.logger.log("Setting up history: [<-, *, ->]"), window.history.replaceState(Z, ""), window.history.pushState(null, "", e), window.history.pushState(K, ""), await H(-1)) : this.canGoBack ? (this.logger.log("Setting up history: [<-, *]"), window.history.replaceState(Z, ""), window.history.pushState(null, "", e)) : this.canGoForward ? (this.logger.log("Setting up history: [*, ->]"), window.history.replaceState(null, e), window.history.pushState(K, ""), await H(-1)) : (this.logger.log("Setting up history: [~, *]"), window.history.replaceState(ct, ""), window.history.pushState(null, "", e)), window.addEventListener("popstate", this.onPopState);
2717
2720
  }
2718
2721
  emitChanged(e, s) {
2719
2722
  this.ee.emit("change", {
@@ -2733,16 +2736,16 @@ class Vt extends Ye {
2733
2736
  * Detaches current navigator from the browser history.
2734
2737
  */
2735
2738
  detach() {
2736
- this.attached && (this.logger.log("Detaching", this), this.attached = !1, window.removeEventListener("popstate", this.onPopState), $("back_button_pressed", this.back));
2739
+ this.attached && (this.logger.log("Detaching", this), this.attached = !1, window.removeEventListener("popstate", this.onPopState), T("back_button_pressed", this.back));
2737
2740
  }
2738
2741
  }
2739
2742
  export {
2740
- Ee as BackButton,
2743
+ Ce as BackButton,
2741
2744
  Pe as ClosingBehavior,
2742
2745
  ke as CloudStorage,
2743
2746
  Se as HapticFeedback,
2744
2747
  Vt as HashNavigator,
2745
- Ot as InitData,
2748
+ Nt as InitData,
2746
2749
  Fe as Invoice,
2747
2750
  Ve as MainButton,
2748
2751
  tt as MethodUnsupportedError,
@@ -2750,20 +2753,20 @@ export {
2750
2753
  Ye as Navigator,
2751
2754
  et as ParameterUnsupportedError,
2752
2755
  F as ParseError,
2753
- G as ParseSchemaFieldError,
2756
+ j as ParseSchemaFieldError,
2754
2757
  Je as Popup,
2755
2758
  Qe as QRScanner,
2756
2759
  Be as SettingsButton,
2757
2760
  Mt as ThemeParams,
2758
2761
  J as TimeoutError,
2759
2762
  Ze as Utils,
2760
- Ne as Viewport,
2763
+ Oe as Viewport,
2761
2764
  Bt as array,
2762
2765
  k as boolean,
2763
2766
  Wt as chatParser,
2764
- Ce as classNames,
2765
- _e as compareVersions,
2766
- be as createPostEvent,
2767
+ ve as classNames,
2768
+ be as compareVersions,
2769
+ me as createPostEvent,
2767
2770
  pt as date,
2768
2771
  hr as getHash,
2769
2772
  ur as init,
@@ -2773,19 +2776,20 @@ export {
2773
2776
  vt as isIframe,
2774
2777
  lt as isRGB,
2775
2778
  Dt as isRGBShort,
2776
- H as isRecord,
2777
- Oe as isStableViewportPlatform,
2779
+ R as isRecord,
2780
+ Ne as isStableViewportPlatform,
2778
2781
  rr as isTMA,
2779
2782
  ar as isTimeoutError,
2780
2783
  f as json,
2781
2784
  mt as launchParamsParser,
2782
2785
  cr as mergeClassNames,
2783
2786
  q as number,
2784
- $ as off,
2787
+ T as off,
2785
2788
  y as on,
2786
2789
  ir as once,
2787
2790
  tr as parseInitData,
2788
- jt as parseLaunchParams,
2791
+ Gt as parseLaunchParams,
2792
+ se as parseMessage,
2789
2793
  bt as parseThemeParams,
2790
2794
  d as postEvent,
2791
2795
  m as request,
@@ -2800,10 +2804,10 @@ export {
2800
2804
  nr as setTargetOrigin,
2801
2805
  u as string,
2802
2806
  or as subscribe,
2803
- R as supports,
2807
+ I as supports,
2804
2808
  _t as themeParamsParser,
2805
2809
  dt as toRGB,
2806
- we as unsubscribe,
2810
+ _e as unsubscribe,
2807
2811
  rt as userParser,
2808
2812
  xt as withTimeout
2809
2813
  };