@tma.js/sdk 1.5.0 → 1.5.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.mjs CHANGED
@@ -1,6 +1,6 @@
1
- var Re = Object.defineProperty;
2
- var Ie = (r, e, t) => e in r ? Re(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
3
- var o = (r, e, t) => (Ie(r, typeof e != "symbol" ? e + "" : e, t), t);
1
+ var Ie = Object.defineProperty;
2
+ var Te = (r, e, t) => e in r ? Ie(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
3
+ var o = (r, e, t) => (Te(r, typeof e != "symbol" ? e + "" : e, t), t);
4
4
  class he {
5
5
  constructor(e, t) {
6
6
  this.prefix = e, this.enabled = t;
@@ -68,7 +68,7 @@ function Qt(r) {
68
68
  function Zt(r) {
69
69
  ue = r;
70
70
  }
71
- function Te() {
71
+ function $e() {
72
72
  return ue;
73
73
  }
74
74
  function pe() {
@@ -78,19 +78,19 @@ function pe() {
78
78
  return !0;
79
79
  }
80
80
  }
81
- function M(r) {
81
+ function W(r) {
82
82
  return typeof r == "object" && r !== null && !Array.isArray(r);
83
83
  }
84
- function $e(r) {
85
- return "external" in r && M(r.external) && "notify" in r.external && typeof r.external.notify == "function";
86
- }
87
84
  function Le(r) {
88
- return "TelegramWebviewProxy" in r && M(r.TelegramWebviewProxy) && "postEvent" in r.TelegramWebviewProxy && typeof r.TelegramWebviewProxy.postEvent == "function";
85
+ return "external" in r && W(r.external) && "notify" in r.external && typeof r.external.notify == "function";
86
+ }
87
+ function Be(r) {
88
+ return "TelegramWebviewProxy" in r && W(r.TelegramWebviewProxy) && "postEvent" in r.TelegramWebviewProxy && typeof r.TelegramWebviewProxy.postEvent == "function";
89
89
  }
90
90
  function d(r, e, t) {
91
91
  let s = {}, n;
92
92
  e === void 0 && t === void 0 ? s = {} : e !== void 0 && t !== void 0 ? (s = t, n = e) : e !== void 0 && ("targetOrigin" in e ? s = e : n = e);
93
- const { targetOrigin: i = Te() } = s;
93
+ const { targetOrigin: i = $e() } = s;
94
94
  if (k.log(`Calling method "${r}"`, n), pe()) {
95
95
  window.parent.postMessage(JSON.stringify({
96
96
  eventType: r,
@@ -98,11 +98,11 @@ function d(r, e, t) {
98
98
  }), i);
99
99
  return;
100
100
  }
101
- if ($e(window)) {
101
+ if (Le(window)) {
102
102
  window.external.notify(JSON.stringify({ eventType: r, eventData: n }));
103
103
  return;
104
104
  }
105
- if (Le(window)) {
105
+ if (Be(window)) {
106
106
  window.TelegramWebviewProxy.postEvent(r, JSON.stringify(n));
107
107
  return;
108
108
  }
@@ -110,7 +110,7 @@ function d(r, e, t) {
110
110
  "Unable to determine current environment and possible way to send event."
111
111
  );
112
112
  }
113
- function Be(r, e) {
113
+ function Oe(r, e) {
114
114
  const t = r.split("."), s = e.split("."), n = Math.max(t.length, s.length);
115
115
  for (let i = 0; i < n; i += 1) {
116
116
  const a = parseInt(t[i] || "0", 10), c = parseInt(s[i] || "0", 10);
@@ -120,7 +120,7 @@ function Be(r, e) {
120
120
  return 0;
121
121
  }
122
122
  function v(r, e) {
123
- return Be(r, e) <= 0;
123
+ return Oe(r, e) <= 0;
124
124
  }
125
125
  function A(r, e, t) {
126
126
  if (typeof t == "string") {
@@ -155,24 +155,24 @@ function A(r, e, t) {
155
155
  return !0;
156
156
  }
157
157
  }
158
- class Z extends Error {
158
+ class K extends Error {
159
159
  constructor(e, t) {
160
- super(`Method "${e}" is unsupported in the Mini Apps version ${t}.`), Object.setPrototypeOf(this, Z.prototype);
160
+ super(`Method "${e}" is unsupported in the Mini Apps version ${t}.`), Object.setPrototypeOf(this, K.prototype);
161
161
  }
162
162
  }
163
- class K extends Error {
163
+ class Y extends Error {
164
164
  constructor(e, t, s) {
165
- super(`Parameter "${t}" in method "${e}" is unsupported in the Mini Apps version ${s}.`), Object.setPrototypeOf(this, K.prototype);
165
+ super(`Parameter "${t}" in method "${e}" is unsupported in the Mini Apps version ${s}.`), Object.setPrototypeOf(this, Y.prototype);
166
166
  }
167
167
  }
168
- function Oe(r) {
168
+ function De(r) {
169
169
  return (e, t) => {
170
170
  if (!A(e, r))
171
- throw new Z(e, r);
172
- if (M(t)) {
171
+ throw new K(e, r);
172
+ if (W(t)) {
173
173
  let s;
174
174
  if (e === "web_app_open_link" && "try_instant_view" in t ? s = "try_instant_view" : e === "web_app_set_header_color" && "color" in t && (s = "color"), s && !A(e, s, r))
175
- throw new K(e, s, r);
175
+ throw new Y(e, s, r);
176
176
  }
177
177
  return d(e, t);
178
178
  };
@@ -180,19 +180,19 @@ function Oe(r) {
180
180
  function le(r) {
181
181
  return ({ req_id: e }) => e === r;
182
182
  }
183
- class G extends Error {
183
+ class j extends Error {
184
184
  constructor(t, { cause: s, type: n } = {}) {
185
185
  super(`Unable to parse value${n ? ` as ${n}` : ""}`, { cause: s });
186
186
  /**
187
187
  * Parser name.
188
188
  */
189
189
  o(this, "type");
190
- this.value = t, Object.setPrototypeOf(this, G.prototype), this.type = n;
190
+ this.value = t, Object.setPrototypeOf(this, j.prototype), this.type = n;
191
191
  }
192
192
  }
193
- class U extends Error {
193
+ class G extends Error {
194
194
  constructor(e, { cause: t, type: s } = {}) {
195
- super(`Unable to parse field "${e}"${s ? ` as ${s}` : ""}`, { cause: t }), Object.setPrototypeOf(this, U.prototype);
195
+ super(`Unable to parse field "${e}"${s ? ` as ${s}` : ""}`, { cause: t }), Object.setPrototypeOf(this, G.prototype);
196
196
  }
197
197
  }
198
198
  function de(r, e) {
@@ -213,10 +213,10 @@ function de(r, e) {
213
213
  try {
214
214
  c = a(u);
215
215
  } catch (p) {
216
- throw p instanceof G ? new U(i, {
216
+ throw p instanceof j ? new G(i, {
217
217
  type: p.type,
218
218
  cause: p
219
- }) : new U(i, { cause: p });
219
+ }) : new G(i, { cause: p });
220
220
  }
221
221
  c !== void 0 && (t[s] = c);
222
222
  }
@@ -225,13 +225,13 @@ function de(r, e) {
225
225
  function V() {
226
226
  return new TypeError("Value has unexpected type");
227
227
  }
228
- function Y(r) {
228
+ function X(r) {
229
229
  let e = r;
230
230
  if (typeof e == "string" && (e = JSON.parse(e)), typeof e != "object" || e === null || Array.isArray(e))
231
231
  throw V();
232
232
  return e;
233
233
  }
234
- class j {
234
+ class F {
235
235
  constructor(e, t, s) {
236
236
  this.parser = e, this.isOptional = t, this.type = s;
237
237
  }
@@ -240,7 +240,7 @@ class j {
240
240
  try {
241
241
  return this.parser(e);
242
242
  } catch (t) {
243
- throw new G(e, { type: this.type, cause: t });
243
+ throw new j(e, { type: this.type, cause: t });
244
244
  }
245
245
  }
246
246
  optional() {
@@ -248,33 +248,33 @@ class j {
248
248
  }
249
249
  }
250
250
  function f(r, e) {
251
- return new j((t) => {
252
- const s = Y(t);
251
+ return new F((t) => {
252
+ const s = X(t);
253
253
  return de(r, (n) => s[n]);
254
254
  }, !1, e);
255
255
  }
256
256
  function R(r, e) {
257
- return () => new j(r, !1, e);
257
+ return () => new F(r, !1, e);
258
258
  }
259
259
  const h = R((r) => {
260
260
  if (typeof r == "string" || typeof r == "number")
261
261
  return r.toString();
262
262
  throw V();
263
263
  }, "string");
264
- function De(r) {
264
+ function We(r) {
265
265
  return f({
266
266
  eventType: h(),
267
267
  eventData: (e) => e
268
268
  }).parse(r);
269
269
  }
270
- function We(r, e) {
270
+ function He(r, e) {
271
271
  window.dispatchEvent(new MessageEvent("message", {
272
272
  data: JSON.stringify({ eventType: r, eventData: e }),
273
273
  // We specify window.parent to imitate the case, it sent us this event.
274
274
  source: window.parent
275
275
  }));
276
276
  }
277
- function He() {
277
+ function Ne() {
278
278
  const r = window;
279
279
  "TelegramGameProxy_receiveEvent" in r || [
280
280
  ["TelegramGameProxy_receiveEvent"],
@@ -287,66 +287,66 @@ function He() {
287
287
  let t = r;
288
288
  e.forEach((s, n, i) => {
289
289
  if (n === i.length - 1) {
290
- t[s] = We;
290
+ t[s] = He;
291
291
  return;
292
292
  }
293
293
  s in t || (t[s] = {}), t = t[s];
294
294
  });
295
295
  });
296
296
  }
297
- function Ne(r) {
298
- He(), window.addEventListener("message", (e) => {
297
+ function Ue(r) {
298
+ Ne(), window.addEventListener("message", (e) => {
299
299
  if (e.source === window.parent)
300
300
  try {
301
- const { eventType: t, eventData: s } = De(e.data);
301
+ const { eventType: t, eventData: s } = We(e.data);
302
302
  r(t, s);
303
303
  } catch {
304
304
  }
305
305
  });
306
306
  }
307
- function Ue() {
307
+ function Me() {
308
308
  return f({
309
309
  req_id: h(),
310
310
  data: (r) => r === null ? r : h().optional().parse(r)
311
311
  });
312
312
  }
313
- function Me() {
313
+ function Ge() {
314
314
  return f({
315
315
  req_id: h(),
316
316
  result: (r) => r,
317
317
  error: h().optional()
318
318
  });
319
319
  }
320
- function Ge() {
320
+ function je() {
321
321
  return f({
322
322
  slug: h(),
323
323
  status: h()
324
324
  });
325
325
  }
326
- function je() {
326
+ function Fe() {
327
327
  return f({ status: h() });
328
328
  }
329
- function Fe() {
329
+ function ze() {
330
330
  return f({
331
331
  button_id: (r) => r == null ? void 0 : h().parse(r)
332
332
  });
333
333
  }
334
- function ze() {
334
+ function Je() {
335
335
  return f({
336
336
  data: h().optional()
337
337
  });
338
338
  }
339
- function X(r) {
339
+ function ee(r) {
340
340
  return /^#[\da-f]{6}$/i.test(r);
341
341
  }
342
- function Je(r) {
342
+ function Qe(r) {
343
343
  return /^#[\da-f]{3}$/i.test(r);
344
344
  }
345
345
  function fe(r) {
346
346
  const e = r.replace(/\s/g, "").toLowerCase();
347
- if (X(e))
347
+ if (ee(e))
348
348
  return e;
349
- if (Je(e)) {
349
+ if (Qe(e)) {
350
350
  let s = "#";
351
351
  for (let n = 0; n < 3; n += 1)
352
352
  s += e[1 + n].repeat(2);
@@ -361,11 +361,11 @@ function fe(r) {
361
361
  }, "#");
362
362
  }
363
363
  const ge = R((r) => fe(h().parse(r)), "rgb");
364
- function Qe() {
364
+ function Ze() {
365
365
  return f({
366
366
  theme_params: (r) => {
367
367
  const e = ge().optional();
368
- return Object.entries(Y(r)).reduce((t, [s, n]) => (t[s] = e.parse(n), t), {});
368
+ return Object.entries(X(r)).reduce((t, [s, n]) => (t[s] = e.parse(n), t), {});
369
369
  }
370
370
  });
371
371
  }
@@ -388,7 +388,7 @@ const P = R((r) => {
388
388
  }
389
389
  throw V();
390
390
  }, "number");
391
- function Ze() {
391
+ function Ke() {
392
392
  return f({
393
393
  height: x(),
394
394
  width: (r) => r == null ? window.innerWidth : x().parse(r),
@@ -396,7 +396,7 @@ function Ze() {
396
396
  is_expanded: P()
397
397
  });
398
398
  }
399
- function Ke() {
399
+ function Ye() {
400
400
  return f({ status: h() });
401
401
  }
402
402
  class w {
@@ -481,7 +481,7 @@ class w {
481
481
  }
482
482
  }
483
483
  }
484
- function Ye() {
484
+ function Xe() {
485
485
  const r = new w(), e = (t, ...s) => {
486
486
  k.log("Emitting processed event:", t, ...s), r.emit(t, ...s);
487
487
  };
@@ -492,33 +492,33 @@ function Ye() {
492
492
  is_state_stable: !0,
493
493
  is_expanded: !0
494
494
  });
495
- }), Ne((t, s) => {
495
+ }), Ue((t, s) => {
496
496
  k.log("Received raw event:", t, s);
497
497
  try {
498
498
  switch (t) {
499
499
  case "viewport_changed":
500
- return e(t, Ze().parse(s));
500
+ return e(t, Ke().parse(s));
501
501
  case "theme_changed":
502
- return e(t, Qe().parse(s));
502
+ return e(t, Ze().parse(s));
503
503
  case "popup_closed":
504
504
  return (
505
505
  // Sent on desktop.
506
- s == null ? e(t, {}) : e(t, Fe().parse(s))
506
+ s == null ? e(t, {}) : e(t, ze().parse(s))
507
507
  );
508
508
  case "set_custom_style":
509
509
  return e(t, h().parse(s));
510
510
  case "qr_text_received":
511
- return e(t, ze().parse(s));
511
+ return e(t, Je().parse(s));
512
512
  case "clipboard_text_received":
513
- return e(t, Ue().parse(s));
513
+ return e(t, Me().parse(s));
514
514
  case "invoice_closed":
515
- return e(t, Ge().parse(s));
515
+ return e(t, je().parse(s));
516
516
  case "phone_requested":
517
- return e("phone_requested", je().parse(s));
517
+ return e("phone_requested", Fe().parse(s));
518
518
  case "custom_method_invoked":
519
- return e("custom_method_invoked", Me().parse(s));
519
+ return e("custom_method_invoked", Ge().parse(s));
520
520
  case "write_access_requested":
521
- return e("write_access_requested", Ke().parse(s));
521
+ return e("write_access_requested", Ye().parse(s));
522
522
  case "main_button_pressed":
523
523
  case "back_button_pressed":
524
524
  case "settings_button_pressed":
@@ -533,31 +533,31 @@ function Ye() {
533
533
  }
534
534
  }), r;
535
535
  }
536
- const z = "telegram-mini-apps-cached-emitter";
537
- function W() {
536
+ const J = "telegram-mini-apps-cached-emitter";
537
+ function H() {
538
538
  const r = window;
539
- return r[z] === void 0 && (r[z] = Ye()), r[z];
539
+ return r[J] === void 0 && (r[J] = Xe()), r[J];
540
540
  }
541
541
  function I(r, e) {
542
- W().off(r, e);
542
+ H().off(r, e);
543
543
  }
544
544
  function E(r, e) {
545
- return W().on(r, e), () => I(r, e);
545
+ return H().on(r, e), () => I(r, e);
546
546
  }
547
- class F extends Error {
547
+ class z extends Error {
548
548
  constructor(e) {
549
- super(`Async call timeout exceeded. Timeout: ${e}`), Object.setPrototypeOf(this, F.prototype);
549
+ super(`Async call timeout exceeded. Timeout: ${e}`), Object.setPrototypeOf(this, z.prototype);
550
550
  }
551
551
  }
552
- function Xe(r) {
552
+ function et(r) {
553
553
  return new Promise((e, t) => {
554
- setTimeout(t, r, new F(r));
554
+ setTimeout(t, r, new z(r));
555
555
  });
556
556
  }
557
557
  function we(r, e) {
558
558
  return Promise.race([
559
559
  typeof r == "function" ? r() : r,
560
- Xe(e)
560
+ et(e)
561
561
  ]);
562
562
  }
563
563
  async function y(r, e, t) {
@@ -601,30 +601,27 @@ async function O(r, e, t, s = {}) {
601
601
  return n;
602
602
  }
603
603
  function Kt(r, e) {
604
- return W().once(r, e), () => I(r, e);
604
+ return H().once(r, e), () => I(r, e);
605
605
  }
606
- function et(r) {
607
- W().unsubscribe(r);
606
+ function tt(r) {
607
+ H().unsubscribe(r);
608
608
  }
609
609
  function Yt(r) {
610
- return W().subscribe(r), () => et(r);
610
+ return H().subscribe(r), () => tt(r);
611
611
  }
612
- function se(r, e) {
613
- return r + (r.length > 0 && e.length > 0 ? ` ${e}` : e);
612
+ function U(r, e) {
613
+ return r + (r.length && e.length ? ` ${e}` : e);
614
614
  }
615
- function tt(...r) {
616
- return r.reduce((e, t) => {
617
- let s = "";
618
- return typeof t == "string" ? s = t : typeof t == "object" && t !== null && (s = Object.entries(t).reduce((n, [i, a]) => a ? se(n, i) : n, "")), se(e, s);
619
- }, "");
615
+ function _e(...r) {
616
+ return r.reduce((e, t) => typeof t == "string" ? U(e, t) : W(t) ? U(e, Object.entries(t).reduce((s, n) => n[1] ? U(s, n[0]) : s, "")) : Array.isArray(t) ? U(e, _e(...t)) : e, "");
620
617
  }
621
618
  function Xt(...r) {
622
- return r.reduce((e, t) => (M(t) && Object.entries(t).forEach(([s, n]) => {
623
- const i = tt(e[s], n);
619
+ return r.reduce((e, t) => (W(t) && Object.entries(t).forEach(([s, n]) => {
620
+ const i = _e(e[s], n);
624
621
  i.length > 0 && (e[s] = i);
625
622
  }), e), {});
626
623
  }
627
- function _e(r) {
624
+ function be(r) {
628
625
  const e = fe(r);
629
626
  return Math.sqrt(
630
627
  [0.299, 0.587, 0.114].reduce((s, n, i) => {
@@ -764,7 +761,7 @@ function nt(r) {
764
761
  }
765
762
  throw V();
766
763
  }
767
- class it extends j {
764
+ class it extends F {
768
765
  constructor(t, s, n) {
769
766
  super(nt, s, n);
770
767
  o(this, "itemParser");
@@ -1022,9 +1019,9 @@ function ie() {
1022
1019
  username: h().optional()
1023
1020
  }, "User");
1024
1021
  }
1025
- const be = R((r) => r instanceof Date ? r : new Date(x().parse(r) * 1e3), "Date");
1026
- function ee(r, e) {
1027
- return new j((t) => {
1022
+ const me = R((r) => r instanceof Date ? r : new Date(x().parse(r) * 1e3), "Date");
1023
+ function te(r, e) {
1024
+ return new F((t) => {
1028
1025
  if (typeof t != "string" && !(t instanceof URLSearchParams))
1029
1026
  throw V();
1030
1027
  const s = typeof t == "string" ? new URLSearchParams(t) : t;
@@ -1034,10 +1031,10 @@ function ee(r, e) {
1034
1031
  });
1035
1032
  }, !1, e);
1036
1033
  }
1037
- function me() {
1038
- return ee({
1034
+ function ye() {
1035
+ return te({
1039
1036
  authDate: {
1040
- type: be(),
1037
+ type: me(),
1041
1038
  from: "auth_date"
1042
1039
  },
1043
1040
  canSendAfter: {
@@ -1067,7 +1064,7 @@ function me() {
1067
1064
  }, "InitData");
1068
1065
  }
1069
1066
  function er(r) {
1070
- return me().parse(r);
1067
+ return ye().parse(r);
1071
1068
  }
1072
1069
  function pt(r) {
1073
1070
  const { hostname: e, pathname: t } = new URL(r, window.location.href);
@@ -1288,7 +1285,7 @@ class dt {
1288
1285
  return this.state.set(e), this.commit(), this;
1289
1286
  }
1290
1287
  }
1291
- const ft = ee({
1288
+ const ft = te({
1292
1289
  contact: f({
1293
1290
  userId: {
1294
1291
  type: x(),
@@ -1308,12 +1305,12 @@ const ft = ee({
1308
1305
  }
1309
1306
  }),
1310
1307
  authDate: {
1311
- type: be(),
1308
+ type: me(),
1312
1309
  from: "auth_date"
1313
1310
  },
1314
1311
  hash: h()
1315
1312
  });
1316
- function ye(r, e) {
1313
+ function Ee(r, e) {
1317
1314
  return (t) => {
1318
1315
  const [s, n] = e[t];
1319
1316
  return A(s, n, r);
@@ -1363,7 +1360,7 @@ class wt {
1363
1360
  setHeaderColor: "web_app_set_header_color",
1364
1361
  setBackgroundColor: "web_app_set_background_color"
1365
1362
  });
1366
- this.postEvent = t, this.botInline = a, this.createRequestId = c, this.supports = (p) => !(!u(p) || p === "switchInlineQuery" && !a), this.state = new m({ backgroundColor: n, headerColor: s }, this.ee), this.supportsParam = ye(i, {
1363
+ this.postEvent = t, this.botInline = a, this.createRequestId = c, this.supports = (p) => !(!u(p) || p === "switchInlineQuery" && !a), this.state = new m({ backgroundColor: n, headerColor: s }, this.ee), this.supportsParam = Ee(i, {
1367
1364
  "setHeaderColor.color": ["web_app_set_header_color", "color"]
1368
1365
  });
1369
1366
  }
@@ -1409,7 +1406,7 @@ class wt {
1409
1406
  * True if current Mini App background color recognized as dark.
1410
1407
  */
1411
1408
  get isDark() {
1412
- return _e(this.backgroundColor);
1409
+ return be(this.backgroundColor);
1413
1410
  }
1414
1411
  /**
1415
1412
  * True if phone access is currently being requested.
@@ -1514,7 +1511,7 @@ class wt {
1514
1511
  * @param color - color key or RGB color.
1515
1512
  */
1516
1513
  setHeaderColor(e) {
1517
- this.postEvent("web_app_set_header_color", X(e) ? { color: e } : { color_key: e }), this.state.set("headerColor", e);
1514
+ this.postEvent("web_app_set_header_color", ee(e) ? { color: e } : { color_key: e }), this.state.set("headerColor", e);
1518
1515
  }
1519
1516
  /**
1520
1517
  * Updates current Mini App background color.
@@ -1731,18 +1728,18 @@ function Et(r) {
1731
1728
  function Ct(r) {
1732
1729
  return r.replace(/[A-Z]/g, (e) => `_${e.toLowerCase()}`).replace(/(^|_)background/, (e, t) => `${t}bg`);
1733
1730
  }
1734
- const Ee = R(
1731
+ const Ce = R(
1735
1732
  (r) => {
1736
1733
  const e = ge().optional();
1737
- return Object.entries(Y(r)).reduce((t, [s, n]) => (t[Et(s)] = e.parse(n), t), {});
1734
+ return Object.entries(X(r)).reduce((t, [s, n]) => (t[Et(s)] = e.parse(n), t), {});
1738
1735
  },
1739
1736
  "ThemeParams"
1740
1737
  );
1741
- function Ce(r) {
1742
- return Ee().parse(r);
1738
+ function ve(r) {
1739
+ return Ce().parse(r);
1743
1740
  }
1744
1741
  function tr(r) {
1745
- return y("web_app_request_theme", "theme_changed", r).then(Ce);
1742
+ return y("web_app_request_theme", "theme_changed", r).then(ve);
1746
1743
  }
1747
1744
  function vt(r) {
1748
1745
  return JSON.stringify(
@@ -1808,7 +1805,7 @@ class Pt {
1808
1805
  * value is calculated according to theme background color.
1809
1806
  */
1810
1807
  get isDark() {
1811
- return !this.backgroundColor || _e(this.backgroundColor);
1808
+ return !this.backgroundColor || be(this.backgroundColor);
1812
1809
  }
1813
1810
  get linkColor() {
1814
1811
  return this.get("linkColor");
@@ -1834,7 +1831,7 @@ class Pt {
1834
1831
  */
1835
1832
  listen() {
1836
1833
  return E("theme_changed", (e) => {
1837
- this.state.set(Ce(e.theme_params));
1834
+ this.state.set(ve(e.theme_params));
1838
1835
  });
1839
1836
  }
1840
1837
  /**
@@ -1859,7 +1856,7 @@ class St {
1859
1856
  o(this, "supportsParam");
1860
1857
  this.version = e, this.createRequestId = t, this.postEvent = s, this.supports = C(e, {
1861
1858
  readTextFromClipboard: "web_app_read_text_from_clipboard"
1862
- }), this.supportsParam = ye(e, {
1859
+ }), this.supportsParam = Ee(e, {
1863
1860
  "openLink.tryInstantView": ["web_app_open_link", "try_instant_view"]
1864
1861
  });
1865
1862
  }
@@ -1923,7 +1920,7 @@ class St {
1923
1920
  function kt(r) {
1924
1921
  return ["macos", "tdesktop", "unigram", "web", "weba"].includes(r);
1925
1922
  }
1926
- async function ve(r) {
1923
+ async function Pe(r) {
1927
1924
  const e = await y("web_app_request_viewport", "viewport_changed", r);
1928
1925
  return {
1929
1926
  height: e.height,
@@ -1968,7 +1965,7 @@ class xt {
1968
1965
  * @param options - options to request fresh data.
1969
1966
  */
1970
1967
  sync(e) {
1971
- return ve(e).then(({ height: t, isExpanded: s, width: n, isStateStable: i }) => {
1968
+ return Pe(e).then(({ height: t, isExpanded: s, width: n, isStateStable: i }) => {
1972
1969
  this.state.set({
1973
1970
  height: t,
1974
1971
  width: n,
@@ -2075,7 +2072,7 @@ function qt(r, e) {
2075
2072
  backgroundColor: n,
2076
2073
  secondaryBackgroundColor: i
2077
2074
  } = e;
2078
- if (X(r.headerColor)) {
2075
+ if (ee(r.headerColor)) {
2079
2076
  S("--tg-header-color", r.headerColor);
2080
2077
  return;
2081
2078
  }
@@ -2109,14 +2106,14 @@ function Vt() {
2109
2106
  r.innerHTML = e;
2110
2107
  });
2111
2108
  }
2112
- function Pe(r) {
2109
+ function Se(r) {
2113
2110
  return `telegram-mini-apps-${r}`;
2114
2111
  }
2115
2112
  function T(r, e) {
2116
- sessionStorage.setItem(Pe(r), JSON.stringify(e));
2113
+ sessionStorage.setItem(Se(r), JSON.stringify(e));
2117
2114
  }
2118
2115
  function $(r) {
2119
- const e = sessionStorage.getItem(Pe(r));
2116
+ const e = sessionStorage.getItem(Se(r));
2120
2117
  return e ? JSON.parse(e) : null;
2121
2118
  }
2122
2119
  function Rt(r, e, t) {
@@ -2188,7 +2185,7 @@ function Ot(r) {
2188
2185
  const e = new Pt(r);
2189
2186
  return e.listen(), e;
2190
2187
  }
2191
- function N(r) {
2188
+ function M(r) {
2192
2189
  const e = new xt(r);
2193
2190
  return e.on("change", () => T("viewport", {
2194
2191
  height: e.height,
@@ -2200,9 +2197,9 @@ function N(r) {
2200
2197
  function Dt(r, e, t, s) {
2201
2198
  const n = r ? $("viewport") : null;
2202
2199
  if (n)
2203
- return N({ ...n, postEvent: t });
2200
+ return M({ ...n, postEvent: t });
2204
2201
  if (kt(e))
2205
- return N({
2202
+ return M({
2206
2203
  height: window.innerHeight,
2207
2204
  isExpanded: !0,
2208
2205
  postEvent: t,
@@ -2210,15 +2207,15 @@ function Dt(r, e, t, s) {
2210
2207
  width: window.innerWidth
2211
2208
  });
2212
2209
  if (s)
2213
- return ve({
2210
+ return Pe({
2214
2211
  postEvent: t,
2215
2212
  timeout: 5e3
2216
- }).then(({ height: a, isStateStable: c, ...u }) => N({
2213
+ }).then(({ height: a, isStateStable: c, ...u }) => M({
2217
2214
  ...u,
2218
2215
  height: a,
2219
2216
  stableHeight: c ? a : 0
2220
2217
  }));
2221
- const i = N({
2218
+ const i = M({
2222
2219
  width: 0,
2223
2220
  height: 0,
2224
2221
  isExpanded: !1,
@@ -2241,13 +2238,13 @@ function ae(r, e, t, s) {
2241
2238
  n.miniApp && qt(e, t), n.themeParams && At(t), n.viewport && (s instanceof Promise ? s.then(oe) : oe(s));
2242
2239
  }
2243
2240
  function Ht() {
2244
- return ee({
2241
+ return te({
2245
2242
  botInline: {
2246
2243
  type: P().optional(),
2247
2244
  from: "tgWebAppBotInline"
2248
2245
  },
2249
2246
  initData: {
2250
- type: me().optional(),
2247
+ type: ye().optional(),
2251
2248
  from: "tgWebAppData"
2252
2249
  },
2253
2250
  initDataRaw: {
@@ -2267,7 +2264,7 @@ function Ht() {
2267
2264
  from: "tgWebAppStartParam"
2268
2265
  },
2269
2266
  themeParams: {
2270
- type: Ee(),
2267
+ type: Ce(),
2271
2268
  from: "tgWebAppThemeParams"
2272
2269
  },
2273
2270
  version: {
@@ -2276,24 +2273,24 @@ function Ht() {
2276
2273
  }
2277
2274
  }, "LaunchParams");
2278
2275
  }
2279
- function Se(r) {
2276
+ function ke(r) {
2280
2277
  return Ht().parse(r);
2281
2278
  }
2282
- function ke(r) {
2279
+ function xe(r) {
2283
2280
  const e = r.includes("?") ? r.replace("#", "&").slice(r.indexOf("?") + 1) : r.slice(r.indexOf("#") + 1);
2284
- return Se(e);
2281
+ return ke(e);
2285
2282
  }
2286
2283
  function Nt() {
2287
- return ke(window.location.href);
2284
+ return xe(window.location.href);
2288
2285
  }
2289
- function xe() {
2286
+ function qe() {
2290
2287
  return performance.getEntriesByType("navigation")[0];
2291
2288
  }
2292
2289
  function Ut() {
2293
- const r = xe();
2290
+ const r = qe();
2294
2291
  if (!r)
2295
2292
  throw new Error("Unable to get first navigation entry.");
2296
- return ke(r.name);
2293
+ return xe(r.name);
2297
2294
  }
2298
2295
  function Mt(r) {
2299
2296
  const {
@@ -2307,14 +2304,14 @@ function Mt(r) {
2307
2304
  } = r, u = new URLSearchParams();
2308
2305
  return e && u.set("tgWebAppData", e), u.set("tgWebAppPlatform", s), u.set("tgWebAppThemeParams", vt(t)), u.set("tgWebAppVersion", n), a && u.set("tgWebAppStartParam", n), typeof i == "boolean" && u.set("tgWebAppShowSettings", i ? "1" : "0"), typeof c == "boolean" && u.set("tgWebAppBotInline", c ? "1" : "0"), u.toString();
2309
2306
  }
2310
- const qe = "telegram-mini-apps-launch-params";
2307
+ const Ae = "telegram-mini-apps-launch-params";
2311
2308
  function Gt() {
2312
- return Se(sessionStorage.getItem(qe) || "");
2309
+ return ke(sessionStorage.getItem(Ae) || "");
2313
2310
  }
2314
2311
  function jt(r) {
2315
- sessionStorage.setItem(qe, Mt(r));
2312
+ sessionStorage.setItem(Ae, Mt(r));
2316
2313
  }
2317
- function te() {
2314
+ function re() {
2318
2315
  const r = [];
2319
2316
  for (const e of [
2320
2317
  // Try to retrieve launch parameters from the current location. This method can return
@@ -2333,9 +2330,9 @@ function te() {
2333
2330
  }
2334
2331
  throw k.error("Unable to extract launch parameters. Received errors:", r), new Error("Unable to retrieve launch parameters from any known source.");
2335
2332
  }
2336
- function Ae() {
2333
+ function Ve() {
2337
2334
  var r;
2338
- return ((r = xe()) == null ? void 0 : r.type) === "reload";
2335
+ return ((r = qe()) == null ? void 0 : r.type) === "reload";
2339
2336
  }
2340
2337
  function rr(r = {}) {
2341
2338
  const {
@@ -2352,7 +2349,7 @@ function rr(r = {}) {
2352
2349
  platform: u,
2353
2350
  themeParams: p,
2354
2351
  botInline: g = !1
2355
- } = te(), _ = Ae(), b = Lt(), l = Oe(c);
2352
+ } = re(), _ = Ve(), b = Lt(), l = De(c);
2356
2353
  pe() && (n && Vt(), l("iframe_ready", { reload_supported: !0 }), E("reload_iframe", () => {
2357
2354
  l("iframe_will_reload"), window.location.reload();
2358
2355
  }));
@@ -2387,18 +2384,18 @@ function rr(r = {}) {
2387
2384
  initData: new ut(i),
2388
2385
  initDataRaw: a
2389
2386
  } : {}
2390
- }, H = Dt(_, u, l, t);
2391
- return H instanceof Promise || t ? Promise.resolve(H).then((re) => (ae(
2387
+ }, N = Dt(_, u, l, t);
2388
+ return N instanceof Promise || t ? Promise.resolve(N).then((se) => (ae(
2392
2389
  s,
2393
2390
  q.miniApp,
2394
2391
  q.themeParams,
2395
- re
2396
- ), { ...q, viewport: re })) : (ae(
2392
+ se
2393
+ ), { ...q, viewport: se })) : (ae(
2397
2394
  s,
2398
2395
  q.miniApp,
2399
2396
  q.themeParams,
2400
- H
2401
- ), { ...q, viewport: H });
2397
+ N
2398
+ ), { ...q, viewport: N });
2402
2399
  } catch (i) {
2403
2400
  if (t)
2404
2401
  return Promise.reject(i);
@@ -2407,13 +2404,13 @@ function rr(r = {}) {
2407
2404
  }
2408
2405
  function sr() {
2409
2406
  return {
2410
- launchParams: te(),
2411
- isPageReload: Ae()
2407
+ launchParams: re(),
2408
+ isPageReload: Ve()
2412
2409
  };
2413
2410
  }
2414
2411
  function nr() {
2415
2412
  try {
2416
- return te(), !0;
2413
+ return re(), !0;
2417
2414
  } catch {
2418
2415
  return !1;
2419
2416
  }
@@ -2644,8 +2641,8 @@ class zt {
2644
2641
  return this.entry.search;
2645
2642
  }
2646
2643
  }
2647
- const ce = 0, J = 1, Q = 2;
2648
- class Ve extends zt {
2644
+ const ce = 0, Q = 1, Z = 2;
2645
+ class Re extends zt {
2649
2646
  constructor(t, s, n = {}) {
2650
2647
  super(t, s, {
2651
2648
  ...n,
@@ -2664,9 +2661,9 @@ class Ve extends zt {
2664
2661
  this.logger.log("Void reached. Moving history forward"), window.history.forward();
2665
2662
  return;
2666
2663
  }
2667
- if (t === J)
2668
- return this.back();
2669
2664
  if (t === Q)
2665
+ return this.back();
2666
+ if (t === Z)
2670
2667
  return this.forward();
2671
2668
  });
2672
2669
  o(this, "back", () => super.back());
@@ -2692,7 +2689,7 @@ class Ve extends zt {
2692
2689
  window.location.hash.slice(1),
2693
2690
  window.location.href
2694
2691
  );
2695
- return new Ve([{ search: s, pathname: n, hash: i }], 0, t);
2692
+ return new Re([{ search: s, pathname: n, hash: i }], 0, t);
2696
2693
  }
2697
2694
  async performGo(t) {
2698
2695
  t.updated && (this.attached && await this.syncHistory(), this.emitChanged(t.before, t.after));
@@ -2709,7 +2706,7 @@ class Ve extends zt {
2709
2706
  async syncHistory() {
2710
2707
  window.removeEventListener("popstate", this.onPopState);
2711
2708
  const t = `#${this.path}`;
2712
- await Ft(), d("web_app_setup_back_button", { is_visible: this.canGoBack }), this.canGoBack && this.canGoForward ? (this.logger.log("Setting up history: [<-, *, ->]"), window.history.replaceState(J, ""), window.history.pushState(null, "", t), window.history.pushState(Q, ""), await D(-1)) : this.canGoBack ? (this.logger.log("Setting up history: [<-, *]"), window.history.replaceState(J, ""), window.history.pushState(null, "", t)) : this.canGoForward ? (this.logger.log("Setting up history: [*, ->]"), window.history.replaceState(null, t), window.history.pushState(Q, ""), await D(-1)) : (this.logger.log("Setting up history: [~, *]"), window.history.replaceState(ce, ""), window.history.pushState(null, "", t)), window.addEventListener("popstate", this.onPopState);
2709
+ await Ft(), d("web_app_setup_back_button", { is_visible: this.canGoBack }), this.canGoBack && this.canGoForward ? (this.logger.log("Setting up history: [<-, *, ->]"), window.history.replaceState(Q, ""), window.history.pushState(null, "", t), window.history.pushState(Z, ""), await D(-1)) : this.canGoBack ? (this.logger.log("Setting up history: [<-, *]"), window.history.replaceState(Q, ""), window.history.pushState(null, "", t)) : this.canGoForward ? (this.logger.log("Setting up history: [*, ->]"), window.history.replaceState(null, t), window.history.pushState(Z, ""), await D(-1)) : (this.logger.log("Setting up history: [~, *]"), window.history.replaceState(ce, ""), window.history.pushState(null, "", t)), window.addEventListener("popstate", this.onPopState);
2713
2710
  }
2714
2711
  emitChanged(t, s) {
2715
2712
  this.ee.emit("change", {
@@ -2733,28 +2730,28 @@ class Ve extends zt {
2733
2730
  }
2734
2731
  }
2735
2732
  function or(r) {
2736
- return r instanceof F;
2733
+ return r instanceof z;
2737
2734
  }
2738
2735
  export {
2739
2736
  rt as BackButton,
2740
2737
  st as ClosingBehavior,
2741
2738
  at as CloudStorage,
2742
2739
  ct as HapticFeedback,
2743
- Ve as HashNavigator,
2740
+ Re as HashNavigator,
2744
2741
  ut as InitData,
2745
2742
  lt as Invoice,
2746
2743
  dt as MainButton,
2747
- Z as MethodUnsupportedError,
2744
+ K as MethodUnsupportedError,
2748
2745
  wt as MiniApp,
2749
2746
  zt as Navigator,
2750
- K as ParameterUnsupportedError,
2751
- G as ParseError,
2752
- U as ParseSchemaFieldError,
2747
+ Y as ParameterUnsupportedError,
2748
+ j as ParseError,
2749
+ G as ParseSchemaFieldError,
2753
2750
  bt as Popup,
2754
2751
  mt as QRScanner,
2755
2752
  yt as SettingsButton,
2756
2753
  Pt as ThemeParams,
2757
- F as TimeoutError,
2754
+ z as TimeoutError,
2758
2755
  St as Utils,
2759
2756
  xt as Viewport,
2760
2757
  ot as array,
@@ -2763,20 +2760,20 @@ export {
2763
2760
  oe as bindViewportCSSVars,
2764
2761
  P as boolean,
2765
2762
  ht as chatParser,
2766
- tt as classNames,
2767
- Be as compareVersions,
2768
- Oe as createPostEvent,
2769
- be as date,
2763
+ _e as classNames,
2764
+ Oe as compareVersions,
2765
+ De as createPostEvent,
2766
+ me as date,
2770
2767
  ir as getHash,
2771
2768
  rr as init,
2772
- me as initDataParser,
2769
+ ye as initDataParser,
2773
2770
  O as invokeCustomMethod,
2774
- _e as isColorDark,
2771
+ be as isColorDark,
2775
2772
  pe as isIframe,
2776
- Ae as isPageReload,
2777
- X as isRGB,
2778
- Je as isRGBShort,
2779
- M as isRecord,
2773
+ Ve as isPageReload,
2774
+ ee as isRGB,
2775
+ Qe as isRGBShort,
2776
+ W as isRecord,
2780
2777
  kt as isStableViewportPlatform,
2781
2778
  nr as isTMA,
2782
2779
  or as isTimeoutError,
@@ -2788,17 +2785,17 @@ export {
2788
2785
  E as on,
2789
2786
  Kt as once,
2790
2787
  er as parseInitData,
2791
- Se as parseLaunchParams,
2792
- De as parseMessage,
2793
- Ce as parseThemeParams,
2788
+ ke as parseLaunchParams,
2789
+ We as parseMessage,
2790
+ ve as parseThemeParams,
2794
2791
  d as postEvent,
2795
2792
  y as request,
2796
2793
  tr as requestThemeParams,
2797
- ve as requestViewport,
2794
+ Pe as requestViewport,
2798
2795
  sr as retrieveLaunchData,
2799
- te as retrieveLaunchParams,
2796
+ re as retrieveLaunchParams,
2800
2797
  ge as rgb,
2801
- ee as searchParams,
2798
+ te as searchParams,
2802
2799
  Mt as serializeLaunchParams,
2803
2800
  vt as serializeThemeParams,
2804
2801
  S as setCSSVar,
@@ -2807,9 +2804,9 @@ export {
2807
2804
  h as string,
2808
2805
  Yt as subscribe,
2809
2806
  A as supports,
2810
- Ee as themeParamsParser,
2807
+ Ce as themeParamsParser,
2811
2808
  fe as toRGB,
2812
- et as unsubscribe,
2809
+ tt as unsubscribe,
2813
2810
  ie as userParser,
2814
2811
  we as withTimeout
2815
2812
  };