@tma.js/sdk 2.6.1 → 2.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,21 +1,21 @@
1
- var Ut = Object.defineProperty;
2
- var Ot = (e, t, s) => t in e ? Ut(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s;
3
- var c = (e, t, s) => Ot(e, typeof t != "symbol" ? t + "" : t, s);
4
- function at(e, t) {
1
+ var Wt = Object.defineProperty;
2
+ var Ut = (e, t, s) => t in e ? Wt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s;
3
+ var c = (e, t, s) => Ut(e, typeof t != "symbol" ? t + "" : t, s);
4
+ function ot(e, t) {
5
5
  let s;
6
6
  const n = () => {
7
7
  s !== void 0 && t && t(s), s = void 0;
8
8
  };
9
9
  return [() => s === void 0 ? s = e(n) : s, n];
10
10
  }
11
- function ct(e) {
12
- const t = L(), { count: s } = t;
13
- t.unsubscribe(e), s && !t.count && ae();
11
+ function at(e) {
12
+ const t = V(), { count: s } = t;
13
+ t.unsubscribe(e), s && !t.count && ie();
14
14
  }
15
15
  function Ht(e) {
16
- return L().subscribe(e), () => ct(e);
16
+ return V().subscribe(e), () => at(e);
17
17
  }
18
- class Gt {
18
+ class Ot {
19
19
  constructor(t, s = {}) {
20
20
  this.scope = t, this.options = s;
21
21
  }
@@ -55,19 +55,19 @@ class Gt {
55
55
  this.print("log", ...t);
56
56
  }
57
57
  }
58
- const F = new Gt("SDK", {
58
+ const F = new Ot("SDK", {
59
59
  bgColor: "forestgreen",
60
60
  textColor: "white"
61
61
  });
62
- let H = !1;
63
- const nt = ({ name: e, payload: t }) => {
62
+ let O = !1;
63
+ const st = ({ name: e, payload: t }) => {
64
64
  F.log("Event received:", t ? { name: e, payload: t } : { name: e });
65
65
  };
66
- function Ye(e) {
67
- H !== e && (H = e, e ? Ht(nt) : ct(nt));
66
+ function Ze(e) {
67
+ O !== e && (O = e, e ? Ht(st) : at(st));
68
68
  }
69
- function jt(...e) {
70
- H && F.log(...e);
69
+ function Gt(...e) {
70
+ O && F.log(...e);
71
71
  }
72
72
  class T {
73
73
  constructor() {
@@ -146,7 +146,7 @@ function G(e, t, s) {
146
146
  }
147
147
  function J(...e) {
148
148
  let t = !1;
149
- const s = [...e];
149
+ const s = e.flat(1);
150
150
  return [
151
151
  (n) => !t && s.push(n),
152
152
  () => {
@@ -160,12 +160,12 @@ class D extends Error {
160
160
  super(s, { cause: n }), this.type = t, Object.setPrototypeOf(this, D.prototype);
161
161
  }
162
162
  }
163
- function g(e, t, s) {
163
+ function f(e, t, s) {
164
164
  return new D(e, t, s);
165
165
  }
166
- const zt = "ERR_METHOD_UNSUPPORTED", Ft = "ERR_METHOD_PARAMETER_UNSUPPORTED", Jt = "ERR_UNKNOWN_ENV", Qt = "ERR_INVOKE_CUSTOM_METHOD_RESPONSE", Yt = "ERR_TIMED_OUT", Zt = "ERR_UNEXPECTED_TYPE", ht = "ERR_PARSE", Kt = "ERR_NAVIGATION_LIST_EMPTY", Xt = "ERR_NAVIGATION_CURSOR_INVALID", Ze = "ERR_NAVIGATION_ITEM_INVALID", Ke = "ERR_SSR_INIT", te = "ERR_INVALID_PATH_BASE";
166
+ const jt = "ERR_METHOD_UNSUPPORTED", zt = "ERR_METHOD_PARAMETER_UNSUPPORTED", Ft = "ERR_UNKNOWN_ENV", Jt = "ERR_INVOKE_CUSTOM_METHOD_RESPONSE", Qt = "ERR_TIMED_OUT", Yt = "ERR_UNEXPECTED_TYPE", ct = "ERR_PARSE", Zt = "ERR_NAVIGATION_LIST_EMPTY", Kt = "ERR_NAVIGATION_CURSOR_INVALID", Ke = "ERR_NAVIGATION_ITEM_INVALID", Xe = "ERR_SSR_INIT", Xt = "ERR_INVALID_PATH_BASE";
167
167
  function E() {
168
- return g(Zt, "Value has unexpected type");
168
+ return f(Yt, "Value has unexpected type");
169
169
  }
170
170
  class M {
171
171
  constructor(t, s, n) {
@@ -182,8 +182,8 @@ class M {
182
182
  try {
183
183
  return this.parser(t);
184
184
  } catch (s) {
185
- throw g(
186
- ht,
185
+ throw f(
186
+ ct,
187
187
  `Unable to parse value${this.type ? ` as ${this.type}` : ""}`,
188
188
  s
189
189
  );
@@ -206,7 +206,7 @@ const w = x((e) => {
206
206
  return !1;
207
207
  throw E();
208
208
  }, "boolean");
209
- function pt(e, t) {
209
+ function ht(e, t) {
210
210
  const s = {};
211
211
  for (const n in e) {
212
212
  const r = e[n];
@@ -223,21 +223,21 @@ function pt(e, t) {
223
223
  const a = o(t(i));
224
224
  a !== void 0 && (s[n] = a);
225
225
  } catch (a) {
226
- throw g(ht, `Unable to parse field "${n}"`, a);
226
+ throw f(ct, `Unable to parse field "${n}"`, a);
227
227
  }
228
228
  }
229
229
  return s;
230
230
  }
231
- function Q(e) {
231
+ function pt(e) {
232
232
  let t = e;
233
233
  if (typeof t == "string" && (t = JSON.parse(t)), typeof t != "object" || t === null || Array.isArray(t))
234
234
  throw E();
235
235
  return t;
236
236
  }
237
- function d(e, t) {
237
+ function g(e, t) {
238
238
  return new M((s) => {
239
- const n = Q(s);
240
- return pt(e, (r) => n[r]);
239
+ const n = pt(s);
240
+ return ht(e, (r) => n[r]);
241
241
  }, !1, t);
242
242
  }
243
243
  const y = x((e) => {
@@ -249,43 +249,18 @@ const y = x((e) => {
249
249
  return t;
250
250
  }
251
251
  throw E();
252
- }, "number");
253
- function Y(e) {
254
- return /^#[\da-f]{6}$/i.test(e);
255
- }
256
- function ee(e) {
257
- return /^#[\da-f]{3}$/i.test(e);
258
- }
259
- function ut(e) {
260
- const t = e.replace(/\s/g, "").toLowerCase();
261
- if (Y(t))
262
- return t;
263
- if (ee(t)) {
264
- let n = "#";
265
- for (let r = 0; r < 3; r += 1)
266
- n += t[1 + r].repeat(2);
267
- return n;
268
- }
269
- const s = t.match(/^rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)$/) || t.match(/^rgba\((\d{1,3}),(\d{1,3}),(\d{1,3}),\d{1,3}\)$/);
270
- if (!s)
271
- throw new Error(`Value "${e}" does not satisfy any of known RGB formats.`);
272
- return s.slice(1).reduce((n, r) => {
273
- const i = parseInt(r, 10).toString(16);
274
- return n + (i.length === 1 ? "0" : "") + i;
275
- }, "#");
276
- }
277
- const h = x((e) => {
252
+ }, "number"), p = x((e) => {
278
253
  if (typeof e == "string" || typeof e == "number")
279
254
  return e.toString();
280
255
  throw E();
281
- }, "string"), lt = x((e) => ut(h().parse(e)), "rgb");
282
- function dt(e) {
283
- return d({
284
- eventType: h(),
256
+ }, "string");
257
+ function ut(e) {
258
+ return g({
259
+ eventType: p(),
285
260
  eventData: (t) => t
286
261
  }).parse(e);
287
262
  }
288
- function se() {
263
+ function te() {
289
264
  ["TelegramGameProxy_receiveEvent", "TelegramGameProxy", "Telegram"].forEach((e) => {
290
265
  delete window[e];
291
266
  });
@@ -297,7 +272,7 @@ function j(e, t) {
297
272
  source: window.parent
298
273
  }));
299
274
  }
300
- function ne() {
275
+ function ee() {
301
276
  [
302
277
  ["TelegramGameProxy_receiveEvent"],
303
278
  // Windows Phone.
@@ -316,48 +291,38 @@ function ne() {
316
291
  });
317
292
  });
318
293
  }
319
- const re = {
320
- clipboard_text_received: d({
321
- req_id: h(),
322
- data: (e) => e === null ? e : h().optional().parse(e)
294
+ const se = {
295
+ clipboard_text_received: g({
296
+ req_id: p(),
297
+ data: (e) => e === null ? e : p().optional().parse(e)
323
298
  }),
324
- custom_method_invoked: d({
325
- req_id: h(),
299
+ custom_method_invoked: g({
300
+ req_id: p(),
326
301
  result: (e) => e,
327
- error: h().optional()
302
+ error: p().optional()
328
303
  }),
329
- invoice_closed: d({ slug: h(), status: h() }),
330
- phone_requested: d({ status: h() }),
331
304
  popup_closed: {
332
305
  parse(e) {
333
- return d({
334
- button_id: (t) => t == null ? void 0 : h().parse(t)
306
+ return g({
307
+ button_id: (t) => t == null ? void 0 : p().parse(t)
335
308
  }).parse(e ?? {});
336
309
  }
337
310
  },
338
- qr_text_received: d({ data: h().optional() }),
339
- theme_changed: d({
340
- theme_params: (e) => {
341
- const t = lt().optional();
342
- return Object.entries(Q(e)).reduce((s, [n, r]) => (s[n] = t.parse(r), s), {});
343
- }
344
- }),
345
- viewport_changed: d({
311
+ viewport_changed: g({
346
312
  height: y(),
347
313
  width: (e) => e == null ? window.innerWidth : y().parse(e),
348
314
  is_state_stable: w(),
349
315
  is_expanded: w()
350
- }),
351
- write_access_requested: d({ status: h() })
316
+ })
352
317
  };
353
- function ie() {
318
+ function ne() {
354
319
  const e = new T(), t = new T();
355
320
  t.subscribe((n) => {
356
321
  e.emit("event", { name: n.event, payload: n.args[0] });
357
- }), ne();
322
+ }), ee();
358
323
  const [, s] = J(
359
324
  // Don't forget to remove created handlers.
360
- se,
325
+ te,
361
326
  // Add "resize" event listener to make sure, we always have fresh viewport information.
362
327
  // Desktop version of Telegram is sometimes not sending the viewport_changed
363
328
  // event. For example, when the MainButton is shown. That's why we should
@@ -378,19 +343,21 @@ function ie() {
378
343
  return;
379
344
  let r;
380
345
  try {
381
- r = dt(n.data);
346
+ r = ut(n.data);
382
347
  } catch {
383
348
  return;
384
349
  }
385
- const { eventType: i, eventData: o } = r, a = re[i];
350
+ const { eventType: i, eventData: o } = r, a = se[i];
386
351
  try {
387
- const p = a ? a.parse(o) : o;
388
- t.emit(...p ? [i, p] : [i]);
389
- } catch (p) {
352
+ const h = a ? a.parse(o) : o;
353
+ t.emit(...h ? [i, h] : [i]);
354
+ } catch (h) {
390
355
  F.error(
391
- `An error occurred processing the "${i}" event from the Telegram application. Please, file an issue here: https://github.com/Telegram-Mini-Apps/tma.js/issues/new/choose`,
356
+ `An error occurred processing the "${i}" event from the Telegram application.
357
+ Please, file an issue here:
358
+ https://github.com/Telegram-Mini-Apps/tma.js/issues/new/choose`,
392
359
  r,
393
- p
360
+ h
394
361
  );
395
362
  }
396
363
  }),
@@ -412,9 +379,9 @@ function ie() {
412
379
  }
413
380
  }, s];
414
381
  }
415
- const [oe, ae] = at(
382
+ const [re, ie] = ot(
416
383
  (e) => {
417
- const [t, s] = ie(), n = t.off.bind(t);
384
+ const [t, s] = ne(), n = t.off.bind(t);
418
385
  return t.off = (r, i) => {
419
386
  const { count: o } = t;
420
387
  n(r, i), o && !t.count && e();
@@ -422,19 +389,19 @@ const [oe, ae] = at(
422
389
  },
423
390
  ([, e]) => e()
424
391
  );
425
- function L() {
426
- return oe()[0];
392
+ function V() {
393
+ return re()[0];
427
394
  }
428
- function V(e, t) {
429
- L().off(e, t);
395
+ function L(e, t) {
396
+ V().off(e, t);
430
397
  }
431
398
  function b(e, t, s) {
432
- return L().on(e, t, s);
399
+ return V().on(e, t, s);
433
400
  }
434
- function I(e) {
401
+ function q(e) {
435
402
  return typeof e == "object" && e !== null && !Array.isArray(e);
436
403
  }
437
- function ce(e, t) {
404
+ function oe(e, t) {
438
405
  const s = e.split("."), n = t.split("."), r = Math.max(s.length, n.length);
439
406
  for (let i = 0; i < r; i += 1) {
440
407
  const o = parseInt(s[i] || "0", 10), a = parseInt(n[i] || "0", 10);
@@ -443,21 +410,21 @@ function ce(e, t) {
443
410
  }
444
411
  return 0;
445
412
  }
446
- function f(e, t) {
447
- return ce(e, t) <= 0;
413
+ function _(e, t) {
414
+ return oe(e, t) <= 0;
448
415
  }
449
416
  function v(e, t, s) {
450
417
  if (typeof s == "string") {
451
418
  if (e === "web_app_open_link") {
452
419
  if (t === "try_instant_view")
453
- return f("6.4", s);
420
+ return _("6.4", s);
454
421
  if (t === "try_browser")
455
- return f("7.6", s);
422
+ return _("7.6", s);
456
423
  }
457
424
  if (e === "web_app_set_header_color" && t === "color")
458
- return f("6.9", s);
425
+ return _("6.9", s);
459
426
  if (e === "web_app_close" && t === "return_back")
460
- return f("7.6", s);
427
+ return _("7.6", s);
461
428
  }
462
429
  switch (e) {
463
430
  case "web_app_open_tg_link":
@@ -466,27 +433,27 @@ function v(e, t, s) {
466
433
  case "web_app_set_background_color":
467
434
  case "web_app_set_header_color":
468
435
  case "web_app_trigger_haptic_feedback":
469
- return f("6.1", t);
436
+ return _("6.1", t);
470
437
  case "web_app_open_popup":
471
- return f("6.2", t);
438
+ return _("6.2", t);
472
439
  case "web_app_close_scan_qr_popup":
473
440
  case "web_app_open_scan_qr_popup":
474
441
  case "web_app_read_text_from_clipboard":
475
- return f("6.4", t);
442
+ return _("6.4", t);
476
443
  case "web_app_switch_inline_query":
477
- return f("6.7", t);
444
+ return _("6.7", t);
478
445
  case "web_app_invoke_custom_method":
479
446
  case "web_app_request_write_access":
480
447
  case "web_app_request_phone":
481
- return f("6.9", t);
448
+ return _("6.9", t);
482
449
  case "web_app_setup_settings_button":
483
- return f("6.10", t);
450
+ return _("6.10", t);
484
451
  case "web_app_biometry_get_info":
485
452
  case "web_app_biometry_open_settings":
486
453
  case "web_app_biometry_request_access":
487
454
  case "web_app_biometry_request_auth":
488
455
  case "web_app_biometry_update_token":
489
- return f("7.2", t);
456
+ return _("7.2", t);
490
457
  default:
491
458
  return [
492
459
  "iframe_ready",
@@ -503,89 +470,88 @@ function v(e, t, s) {
503
470
  ].includes(e);
504
471
  }
505
472
  }
506
- function _t(e) {
507
- return "external" in e && I(e.external) && "notify" in e.external && typeof e.external.notify == "function";
473
+ function lt(e) {
474
+ return "external" in e && q(e.external) && "notify" in e.external && typeof e.external.notify == "function";
508
475
  }
509
- function ft(e) {
510
- return "TelegramWebviewProxy" in e && I(e.TelegramWebviewProxy) && "postEvent" in e.TelegramWebviewProxy && typeof e.TelegramWebviewProxy.postEvent == "function";
476
+ function dt(e) {
477
+ return "TelegramWebviewProxy" in e && q(e.TelegramWebviewProxy) && "postEvent" in e.TelegramWebviewProxy && typeof e.TelegramWebviewProxy.postEvent == "function";
511
478
  }
512
- function gt() {
479
+ function _t() {
513
480
  try {
514
481
  return window.self !== window.top;
515
482
  } catch {
516
483
  return !0;
517
484
  }
518
485
  }
519
- let bt = "https://web.telegram.org";
520
- function Xe(e) {
521
- bt = e;
486
+ const ae = "https://web.telegram.org";
487
+ let ft = ae;
488
+ function ts(e) {
489
+ ft = e;
522
490
  }
523
- function he() {
524
- return bt;
491
+ function ce() {
492
+ return ft;
525
493
  }
526
494
  function R(e, t, s) {
527
495
  let n = {}, r;
528
- t === void 0 && s === void 0 ? n = {} : t !== void 0 && s !== void 0 ? (n = s, r = t) : t !== void 0 && ("targetOrigin" in t ? n = t : r = t);
529
- const { targetOrigin: i = he() } = n;
530
- if (jt("Posting event:", r ? { event: e, data: r } : { event: e }), gt()) {
531
- window.parent.postMessage(JSON.stringify({ eventType: e, eventData: r }), i);
532
- return;
533
- }
534
- if (_t(window)) {
496
+ if (!t && !s ? n = {} : t && s ? (n = s, r = t) : t && ("targetOrigin" in t ? n = t : r = t), Gt("Posting event:", r ? { event: e, data: r } : { event: e }), _t())
497
+ return window.parent.postMessage(
498
+ JSON.stringify({ eventType: e, eventData: r }),
499
+ n.targetOrigin || ce()
500
+ );
501
+ if (lt(window)) {
535
502
  window.external.notify(JSON.stringify({ eventType: e, eventData: r }));
536
503
  return;
537
504
  }
538
- if (ft(window)) {
505
+ if (dt(window)) {
539
506
  window.TelegramWebviewProxy.postEvent(e, JSON.stringify(r));
540
507
  return;
541
508
  }
542
- throw g(
543
- Jt,
544
- "Unable to determine current environment and possible way to send event. You are probably trying to use Mini Apps method outside of Telegram application environment."
509
+ throw f(
510
+ Ft,
511
+ "Unable to determine current environment and possible way to send event. You are probably trying to use Mini Apps method outside the Telegram application environment."
545
512
  );
546
513
  }
547
- function pe(e) {
514
+ function he(e) {
548
515
  return (t, s) => {
549
516
  if (!v(t, e))
550
- throw g(zt, `Method "${t}" is unsupported in Mini Apps version ${e}`);
551
- if (I(s)) {
552
- let n;
553
- if (t === "web_app_open_link" && "try_instant_view" in s ? n = "try_instant_view" : t === "web_app_set_header_color" && "color" in s && (n = "color"), n && !v(t, n, e))
554
- throw g(
555
- Ft,
556
- `Parameter "${n}" of "${t}" method is unsupported in Mini Apps version ${e}`
557
- );
558
- }
517
+ throw f(jt, `Method "${t}" is unsupported in Mini Apps version ${e}`);
518
+ if (q(s) && t === "web_app_set_header_color" && "color" in s && !v(t, "color", e))
519
+ throw f(
520
+ zt,
521
+ `Parameter "color" of "${t}" method is unsupported in Mini Apps version ${e}`
522
+ );
559
523
  return R(t, s);
560
524
  };
561
525
  }
562
- function wt(e) {
526
+ function gt(e) {
563
527
  return ({ req_id: t }) => t === e;
564
528
  }
565
- function mt(e) {
566
- return g(Yt, `Timeout reached: ${e}ms`);
529
+ function bt(e) {
530
+ return f(Qt, `Timeout reached: ${e}ms`);
567
531
  }
568
- function yt(e, t) {
532
+ function wt(e, t) {
569
533
  return Promise.race([
570
534
  typeof e == "function" ? e() : e,
571
535
  new Promise((s, n) => {
572
536
  setTimeout(() => {
573
- n(mt(t));
537
+ n(bt(t));
574
538
  }, t);
575
539
  })
576
540
  ]);
577
541
  }
578
- async function _(e) {
542
+ async function d(e) {
579
543
  let t;
580
- const s = new Promise((a) => {
581
- t = a;
582
- }), { event: n, capture: r, timeout: i } = e, [, o] = J(
583
- ...(Array.isArray(n) ? n : [n]).map(
584
- (a) => b(a, (p) => (!r || r(p)) && t(p))
585
- )
544
+ const s = new Promise((a) => t = a), { event: n, capture: r, timeout: i } = e, [, o] = J(
545
+ // We need to iterate over all tracked events, and create their event listeners.
546
+ (Array.isArray(n) ? n : [n]).map((a) => b(a, (h) => {
547
+ (!r || (Array.isArray(n) ? r({
548
+ event: a,
549
+ payload: h
550
+ }) : r(h))) && t(h);
551
+ }))
586
552
  );
587
553
  try {
588
- return (e.postEvent || R)(e.method, e.params), await (i ? yt(s, i) : s);
554
+ return (e.postEvent || R)(e.method, e.params), await (i ? wt(s, i) : s);
589
555
  } finally {
590
556
  o();
591
557
  }
@@ -594,7 +560,7 @@ async function S(e, t, s, n = {}) {
594
560
  const {
595
561
  result: r,
596
562
  error: i
597
- } = await _({
563
+ } = await d({
598
564
  ...n,
599
565
  method: "web_app_invoke_custom_method",
600
566
  event: "custom_method_invoked",
@@ -603,30 +569,54 @@ async function S(e, t, s, n = {}) {
603
569
  params: t,
604
570
  req_id: s
605
571
  },
606
- capture: wt(s)
572
+ capture: gt(s)
607
573
  });
608
574
  if (i)
609
- throw g(Qt, i);
575
+ throw f(Jt, i);
610
576
  return r;
611
577
  }
612
578
  function z(...e) {
613
579
  return e.map((t) => {
614
580
  if (typeof t == "string")
615
581
  return t;
616
- if (I(t))
582
+ if (q(t))
617
583
  return z(Object.entries(t).map((s) => s[1] && s[0]));
618
584
  if (Array.isArray(t))
619
585
  return z(...t);
620
586
  }).filter(Boolean).join(" ");
621
587
  }
622
- function ts(...e) {
623
- return e.reduce((t, s) => (I(s) && Object.entries(s).forEach(([n, r]) => {
588
+ function es(...e) {
589
+ return e.reduce((t, s) => (q(s) && Object.entries(s).forEach(([n, r]) => {
624
590
  const i = z(t[n], r);
625
591
  i.length && (t[n] = i);
626
592
  }), t), {});
627
593
  }
628
- function vt(e) {
629
- const t = ut(e);
594
+ function Q(e) {
595
+ return /^#[\da-f]{6}$/i.test(e);
596
+ }
597
+ function pe(e) {
598
+ return /^#[\da-f]{3}$/i.test(e);
599
+ }
600
+ function mt(e) {
601
+ const t = e.replace(/\s/g, "").toLowerCase();
602
+ if (Q(t))
603
+ return t;
604
+ if (pe(t)) {
605
+ let n = "#";
606
+ for (let r = 0; r < 3; r += 1)
607
+ n += t[1 + r].repeat(2);
608
+ return n;
609
+ }
610
+ const s = t.match(/^rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)$/) || t.match(/^rgba\((\d{1,3}),(\d{1,3}),(\d{1,3}),\d{1,3}\)$/);
611
+ if (!s)
612
+ throw new Error(`Value "${e}" does not satisfy any of known RGB formats.`);
613
+ return s.slice(1).reduce((n, r) => {
614
+ const i = parseInt(r, 10).toString(16);
615
+ return n + (i.length === 1 ? "0" : "") + i;
616
+ }, "#");
617
+ }
618
+ function yt(e) {
619
+ const t = mt(e);
630
620
  return Math.sqrt(
631
621
  [0.299, 0.587, 0.114].reduce((s, n, r) => {
632
622
  const i = parseInt(t.slice(1 + r * 2, 1 + (r + 1) * 2), 16);
@@ -664,7 +654,7 @@ class ue {
664
654
  return this.state[t];
665
655
  }
666
656
  }
667
- class Z {
657
+ class Y {
668
658
  constructor(t) {
669
659
  c(this, "state");
670
660
  /**
@@ -682,20 +672,20 @@ class Z {
682
672
  this.state = new ue(t), this.set = this.state.set.bind(this.state), this.get = this.state.get.bind(this.state), this.clone = this.state.clone.bind(this.state);
683
673
  }
684
674
  }
685
- function Et(e, t) {
675
+ function vt(e, t) {
686
676
  return (s) => v(t[s], e);
687
677
  }
688
- class K extends Z {
678
+ class Z extends Y {
689
679
  constructor(s, n, r) {
690
680
  super(s);
691
681
  /**
692
682
  * @returns True, if specified method is supported by the current component.
693
683
  */
694
684
  c(this, "supports");
695
- this.supports = Et(n, r);
685
+ this.supports = vt(n, r);
696
686
  }
697
687
  }
698
- class le extends K {
688
+ class le extends Z {
699
689
  constructor(s, n, r) {
700
690
  super({ isVisible: s }, n, {
701
691
  show: "web_app_setup_back_button",
@@ -712,7 +702,7 @@ class le extends K {
712
702
  * @param event - event to listen.
713
703
  * @param listener - listener to remove.
714
704
  */
715
- c(this, "off", (s, n) => s === "click" ? V("back_button_pressed", n) : this.state.off(s, n));
705
+ c(this, "off", (s, n) => s === "click" ? L("back_button_pressed", n) : this.state.off(s, n));
716
706
  this.postEvent = r;
717
707
  }
718
708
  set isVisible(s) {
@@ -737,28 +727,28 @@ class le extends K {
737
727
  this.isVisible = !0;
738
728
  }
739
729
  }
740
- const xt = x((e) => e instanceof Date ? e : new Date(y().parse(e) * 1e3), "Date");
741
- function X(e, t) {
730
+ const Et = x((e) => e instanceof Date ? e : new Date(y().parse(e) * 1e3), "Date");
731
+ function K(e, t) {
742
732
  return new M((s) => {
743
733
  if (typeof s != "string" && !(s instanceof URLSearchParams))
744
734
  throw E();
745
735
  const n = typeof s == "string" ? new URLSearchParams(s) : s;
746
- return pt(e, (r) => {
736
+ return ht(e, (r) => {
747
737
  const i = n.get(r);
748
738
  return i === null ? void 0 : i;
749
739
  });
750
740
  }, !1, t);
751
741
  }
752
- const de = d({
742
+ const de = g({
753
743
  id: y(),
754
- type: h(),
755
- title: h(),
744
+ type: p(),
745
+ title: p(),
756
746
  photoUrl: {
757
- type: h().optional(),
747
+ type: p().optional(),
758
748
  from: "photo_url"
759
749
  },
760
- username: h().optional()
761
- }, "Chat").optional(), rt = d({
750
+ username: p().optional()
751
+ }, "Chat").optional(), nt = g({
762
752
  addedToAttachmentMenu: {
763
753
  type: w().optional(),
764
754
  from: "added_to_attachment_menu"
@@ -768,7 +758,7 @@ const de = d({
768
758
  from: "allows_write_to_pm"
769
759
  },
770
760
  firstName: {
771
- type: h(),
761
+ type: p(),
772
762
  from: "first_name"
773
763
  },
774
764
  id: y(),
@@ -781,23 +771,23 @@ const de = d({
781
771
  from: "is_premium"
782
772
  },
783
773
  languageCode: {
784
- type: h().optional(),
774
+ type: p().optional(),
785
775
  from: "language_code"
786
776
  },
787
777
  lastName: {
788
- type: h().optional(),
778
+ type: p().optional(),
789
779
  from: "last_name"
790
780
  },
791
781
  photoUrl: {
792
- type: h().optional(),
782
+ type: p().optional(),
793
783
  from: "photo_url"
794
784
  },
795
- username: h().optional()
785
+ username: p().optional()
796
786
  }, "User").optional();
797
- function Pt() {
798
- return X({
787
+ function xt() {
788
+ return K({
799
789
  authDate: {
800
- type: xt(),
790
+ type: Et(),
801
791
  from: "auth_date"
802
792
  },
803
793
  canSendAfter: {
@@ -806,55 +796,56 @@ function Pt() {
806
796
  },
807
797
  chat: de,
808
798
  chatInstance: {
809
- type: h().optional(),
799
+ type: p().optional(),
810
800
  from: "chat_instance"
811
801
  },
812
802
  chatType: {
813
- type: h().optional(),
803
+ type: p().optional(),
814
804
  from: "chat_type"
815
805
  },
816
- hash: h(),
806
+ hash: p(),
817
807
  queryId: {
818
- type: h().optional(),
808
+ type: p().optional(),
819
809
  from: "query_id"
820
810
  },
821
- receiver: rt,
811
+ receiver: nt,
822
812
  startParam: {
823
- type: h().optional(),
813
+ type: p().optional(),
824
814
  from: "start_param"
825
815
  },
826
- user: rt
816
+ user: nt
827
817
  }, "InitData");
828
818
  }
829
- function _e(e) {
819
+ const _e = x((e) => mt(p().parse(e)), "rgb");
820
+ function fe(e) {
830
821
  return e.replace(/_[a-z]/g, (t) => t[1].toUpperCase());
831
822
  }
832
- function fe(e) {
823
+ function ge(e) {
833
824
  return e.replace(/[A-Z]/g, (t) => `_${t.toLowerCase()}`);
834
825
  }
835
- const St = x(
826
+ const Pt = x(
836
827
  (e) => {
837
- const t = lt().optional();
838
- return Object.entries(Q(e)).reduce((s, [n, r]) => (s[_e(n)] = t.parse(r), s), {});
828
+ const t = _e().optional();
829
+ return Object.entries(pt(e)).reduce((s, [n, r]) => (s[fe(n)] = t.parse(r), s), {});
839
830
  },
840
831
  "ThemeParams"
841
832
  );
842
- function tt(e) {
843
- return X({
833
+ function X(e) {
834
+ return K({
844
835
  botInline: {
845
836
  type: w().optional(),
846
837
  from: "tgWebAppBotInline"
847
838
  },
848
839
  initData: {
849
- type: Pt().optional(),
840
+ type: xt().optional(),
850
841
  from: "tgWebAppData"
851
842
  },
852
843
  initDataRaw: {
853
- type: h().optional(),
844
+ type: p().optional(),
854
845
  from: "tgWebAppData"
855
846
  },
856
847
  platform: {
857
- type: h(),
848
+ type: p(),
858
849
  from: "tgWebAppPlatform"
859
850
  },
860
851
  showSettings: {
@@ -862,60 +853,60 @@ function tt(e) {
862
853
  from: "tgWebAppShowSettings"
863
854
  },
864
855
  startParam: {
865
- type: h().optional(),
856
+ type: p().optional(),
866
857
  from: "tgWebAppStartParam"
867
858
  },
868
859
  themeParams: {
869
- type: St(),
860
+ type: Pt(),
870
861
  from: "tgWebAppThemeParams"
871
862
  },
872
863
  version: {
873
- type: h(),
864
+ type: p(),
874
865
  from: "tgWebAppVersion"
875
866
  }
876
867
  }).parse(e);
877
868
  }
878
- function Ct(e) {
879
- return tt(
869
+ function St(e) {
870
+ return X(
880
871
  e.replace(/^[^?#]*[?#]/, "").replace(/[?#]/g, "&")
881
872
  );
882
873
  }
883
- function ge() {
884
- return Ct(window.location.href);
874
+ function be() {
875
+ return St(window.location.href);
885
876
  }
886
- function Tt() {
877
+ function Ct() {
887
878
  return performance.getEntriesByType("navigation")[0];
888
879
  }
889
- function be() {
890
- const e = Tt();
880
+ function we() {
881
+ const e = Ct();
891
882
  if (!e)
892
883
  throw new Error("Unable to get first navigation entry.");
893
- return Ct(e.name);
884
+ return St(e.name);
894
885
  }
895
- function Rt(e) {
886
+ function Tt(e) {
896
887
  return `tma.js/${e.replace(/[A-Z]/g, (t) => `-${t.toLowerCase()}`)}`;
897
888
  }
898
- function At(e, t) {
899
- sessionStorage.setItem(Rt(e), JSON.stringify(t));
889
+ function Rt(e, t) {
890
+ sessionStorage.setItem(Tt(e), JSON.stringify(t));
900
891
  }
901
- function It(e) {
902
- const t = sessionStorage.getItem(Rt(e));
892
+ function At(e) {
893
+ const t = sessionStorage.getItem(Tt(e));
903
894
  try {
904
895
  return t ? JSON.parse(t) : void 0;
905
896
  } catch {
906
897
  }
907
898
  }
908
- function we() {
909
- return tt(It("launchParams") || "");
899
+ function me() {
900
+ return X(At("launchParams") || "");
910
901
  }
911
- function qt(e) {
902
+ function It(e) {
912
903
  return JSON.stringify(
913
904
  Object.fromEntries(
914
- Object.entries(e).map(([t, s]) => [fe(t), s])
905
+ Object.entries(e).map(([t, s]) => [ge(t), s])
915
906
  )
916
907
  );
917
908
  }
918
- function me(e) {
909
+ function ye(e) {
919
910
  const {
920
911
  initDataRaw: t,
921
912
  themeParams: s,
@@ -924,44 +915,44 @@ function me(e) {
924
915
  showSettings: i,
925
916
  startParam: o,
926
917
  botInline: a
927
- } = e, p = new URLSearchParams();
928
- return p.set("tgWebAppPlatform", n), p.set("tgWebAppThemeParams", qt(s)), p.set("tgWebAppVersion", r), t && p.set("tgWebAppData", t), o && p.set("tgWebAppStartParam", o), typeof i == "boolean" && p.set("tgWebAppShowSettings", i ? "1" : "0"), typeof a == "boolean" && p.set("tgWebAppBotInline", a ? "1" : "0"), p.toString();
918
+ } = e, h = new URLSearchParams();
919
+ return h.set("tgWebAppPlatform", n), h.set("tgWebAppThemeParams", It(s)), h.set("tgWebAppVersion", r), t && h.set("tgWebAppData", t), o && h.set("tgWebAppStartParam", o), typeof i == "boolean" && h.set("tgWebAppShowSettings", i ? "1" : "0"), typeof a == "boolean" && h.set("tgWebAppBotInline", a ? "1" : "0"), h.toString();
929
920
  }
930
- function kt(e) {
931
- At("launchParams", me(e));
921
+ function qt(e) {
922
+ Rt("launchParams", ye(e));
932
923
  }
933
- function ye() {
924
+ function ve() {
934
925
  for (const e of [
935
926
  // Try to retrieve launch parameters from the current location. This method can return
936
927
  // nothing in case, location was changed and then page was reloaded.
937
- ge,
938
- // Then, try using the lower level API - window.performance.
939
928
  be,
929
+ // Then, try using the lower level API - window.performance.
930
+ we,
940
931
  // Finally, try to extract launch parameters from the session storage.
941
- we
932
+ me
942
933
  ])
943
934
  try {
944
935
  const t = e();
945
- return kt(t), t;
936
+ return qt(t), t;
946
937
  } catch {
947
938
  }
948
939
  throw new Error("Unable to retrieve launch parameters from any known source.");
949
940
  }
950
- function Nt() {
951
- const e = Tt();
941
+ function kt() {
942
+ const e = Ct();
952
943
  return !!(e && e.type === "reload");
953
944
  }
954
- function ve() {
945
+ function Ee() {
955
946
  let e = 0;
956
947
  return () => (e += 1).toString();
957
948
  }
958
- const [Ee] = at(ve);
949
+ const [xe] = ot(Ee);
959
950
  function l(e, t) {
960
951
  return () => {
961
- const s = ye(), n = {
952
+ const s = ve(), n = {
962
953
  ...s,
963
- postEvent: pe(s.version),
964
- createRequestId: Ee()
954
+ postEvent: he(s.version),
955
+ createRequestId: xe()
965
956
  };
966
957
  if (typeof e == "function")
967
958
  return e(n);
@@ -970,25 +961,25 @@ function l(e, t) {
970
961
  // State should only be passed only in case, current page was reloaded. If we don't add
971
962
  // this check, state restoration will work improperly in the web version of Telegram,
972
963
  // when we are always working in the same "session" (tab).
973
- state: Nt() ? It(e) : void 0,
964
+ state: kt() ? At(e) : void 0,
974
965
  addCleanup: r
975
- }), p = (u) => (o || r(
976
- u.on("change", (Wt) => {
977
- At(e, Wt);
966
+ }), h = (u) => (o || r(
967
+ u.on("change", (Bt) => {
968
+ Rt(e, Bt);
978
969
  })
979
970
  ), u);
980
971
  return [
981
- a instanceof Promise ? a.then(p) : p(a),
972
+ a instanceof Promise ? a.then(h) : h(a),
982
973
  i
983
974
  ];
984
975
  };
985
976
  }
986
- const es = l("backButton", ({
977
+ const ss = l("backButton", ({
987
978
  postEvent: e,
988
979
  version: t,
989
980
  state: s = { isVisible: !1 }
990
981
  }) => new le(s.isVisible, t, e));
991
- class q extends K {
982
+ class k extends Z {
992
983
  constructor() {
993
984
  super(...arguments);
994
985
  /**
@@ -1001,7 +992,7 @@ class q extends K {
1001
992
  c(this, "off", this.state.off.bind(this.state));
1002
993
  }
1003
994
  }
1004
- function Dt(e) {
995
+ function Nt(e) {
1005
996
  const t = e.available ? e : {
1006
997
  available: !1,
1007
998
  device_id: "",
@@ -1019,7 +1010,7 @@ function Dt(e) {
1019
1010
  accessGranted: t.access_granted
1020
1011
  };
1021
1012
  }
1022
- class xe extends q {
1013
+ class Pe extends k {
1023
1014
  constructor({ postEvent: s, version: n, ...r }) {
1024
1015
  super(r, n, {
1025
1016
  auth: "web_app_biometry_request_auth",
@@ -1060,7 +1051,7 @@ class xe extends q {
1060
1051
  reason: s,
1061
1052
  ...n
1062
1053
  }) {
1063
- return this.authPromise || (this.authPromise = _({
1054
+ return this.authPromise || (this.authPromise = d({
1064
1055
  ...n,
1065
1056
  method: "web_app_biometry_request_auth",
1066
1057
  event: "biometry_auth_requested",
@@ -1094,14 +1085,14 @@ class xe extends q {
1094
1085
  * @returns Promise with true, if access was granted.
1095
1086
  */
1096
1087
  requestAccess({ reason: s, ...n } = {}) {
1097
- return this.accessPromise || (this.accessPromise = _({
1088
+ return this.accessPromise || (this.accessPromise = d({
1098
1089
  ...n,
1099
1090
  postEvent: this.postEvent,
1100
1091
  method: "web_app_biometry_request_access",
1101
1092
  event: "biometry_info_received",
1102
1093
  params: { reason: s || "" }
1103
1094
  }).then((r) => {
1104
- const i = Dt(r);
1095
+ const i = Nt(r);
1105
1096
  return this.set(i), i.accessGranted;
1106
1097
  }).finally(() => this.accessPromise = void 0)), this.accessPromise;
1107
1098
  }
@@ -1123,7 +1114,7 @@ class xe extends q {
1123
1114
  */
1124
1115
  async updateToken({ token: s, ...n } = {}) {
1125
1116
  return ["removed", "updated"].includes(
1126
- (await _({
1117
+ (await d({
1127
1118
  ...n,
1128
1119
  postEvent: this.postEvent,
1129
1120
  method: "web_app_biometry_update_token",
@@ -1133,19 +1124,19 @@ class xe extends q {
1133
1124
  );
1134
1125
  }
1135
1126
  }
1136
- async function Pe(e) {
1137
- return Dt(
1138
- await _({
1127
+ async function Se(e) {
1128
+ return Nt(
1129
+ await d({
1139
1130
  ...e || {},
1140
1131
  method: "web_app_biometry_get_info",
1141
1132
  event: "biometry_info_received"
1142
1133
  })
1143
1134
  );
1144
1135
  }
1145
- const ss = l(
1136
+ const ns = l(
1146
1137
  "biometryManager",
1147
- async ({ postEvent: e, version: t, state: s }) => new xe({
1148
- ...s || v("web_app_biometry_get_info", t) ? s || await Pe({ timeout: 1e3 }) : {
1138
+ async ({ postEvent: e, version: t, state: s }) => new Pe({
1139
+ ...s || v("web_app_biometry_get_info", t) ? s || await Se({ timeout: 1e3 }) : {
1149
1140
  available: !1,
1150
1141
  accessGranted: !1,
1151
1142
  accessRequested: !1,
@@ -1156,7 +1147,7 @@ const ss = l(
1156
1147
  postEvent: e
1157
1148
  })
1158
1149
  );
1159
- class et extends Z {
1150
+ class tt extends Y {
1160
1151
  constructor() {
1161
1152
  super(...arguments);
1162
1153
  /**
@@ -1169,7 +1160,7 @@ class et extends Z {
1169
1160
  c(this, "off", this.state.off.bind(this.state));
1170
1161
  }
1171
1162
  }
1172
- class Se extends et {
1163
+ class Ce extends tt {
1173
1164
  constructor(t, s) {
1174
1165
  super({ isConfirmationNeeded: t }), this.postEvent = s;
1175
1166
  }
@@ -1196,23 +1187,23 @@ class Se extends et {
1196
1187
  this.isConfirmationNeeded = !0;
1197
1188
  }
1198
1189
  }
1199
- const ns = l(
1190
+ const rs = l(
1200
1191
  "closingBehavior",
1201
1192
  ({
1202
1193
  postEvent: e,
1203
1194
  state: t = { isConfirmationNeeded: !1 }
1204
- }) => new Se(t.isConfirmationNeeded, e)
1195
+ }) => new Ce(t.isConfirmationNeeded, e)
1205
1196
  );
1206
- class st {
1197
+ class et {
1207
1198
  constructor(t, s) {
1208
1199
  /**
1209
1200
  * @returns True, if specified method is supported by the current component.
1210
1201
  */
1211
1202
  c(this, "supports");
1212
- this.supports = Et(t, s);
1203
+ this.supports = vt(t, s);
1213
1204
  }
1214
1205
  }
1215
- function Ce(e) {
1206
+ function Te(e) {
1216
1207
  if (Array.isArray(e))
1217
1208
  return e;
1218
1209
  if (typeof e == "string")
@@ -1224,9 +1215,9 @@ function Ce(e) {
1224
1215
  }
1225
1216
  throw E();
1226
1217
  }
1227
- class Te extends M {
1218
+ class Re extends M {
1228
1219
  constructor(s, n, r) {
1229
- super(Ce, n, r);
1220
+ super(Te, n, r);
1230
1221
  c(this, "itemParser");
1231
1222
  this.itemParser = typeof s == "function" ? s : s.parse.bind(s);
1232
1223
  }
@@ -1244,13 +1235,13 @@ class Te extends M {
1244
1235
  return this.itemParser = typeof s == "function" ? s : s.parse.bind(s), this;
1245
1236
  }
1246
1237
  }
1247
- function Re(e) {
1248
- return new Te((t) => t, !1, e);
1238
+ function Ae(e) {
1239
+ return new Re((t) => t, !1, e);
1249
1240
  }
1250
- function it(e, t) {
1241
+ function rt(e, t) {
1251
1242
  return Object.fromEntries(e.map((s) => [s, t]));
1252
1243
  }
1253
- class Ae extends st {
1244
+ class Ie extends et {
1254
1245
  constructor(t, s, n) {
1255
1246
  super(t, {
1256
1247
  delete: "web_app_invoke_custom_method",
@@ -1278,7 +1269,7 @@ class Ae extends st {
1278
1269
  * @param options - request execution options.
1279
1270
  */
1280
1271
  async getKeys(t = {}) {
1281
- return Re().of(h()).parse(
1272
+ return Ae().of(p()).parse(
1282
1273
  await S(
1283
1274
  "getStorageKeys",
1284
1275
  {},
@@ -1290,13 +1281,13 @@ class Ae extends st {
1290
1281
  async get(t, s = {}) {
1291
1282
  const n = Array.isArray(t) ? t : [t];
1292
1283
  if (!n.length)
1293
- return it(n, "");
1284
+ return rt(n, "");
1294
1285
  const r = await S(
1295
1286
  "getStorageValues",
1296
1287
  { keys: n },
1297
1288
  this.createRequestId(),
1298
1289
  { ...s, postEvent: this.postEvent }
1299
- ), i = d(it(n, h()), "CloudStorageData").parse(r);
1290
+ ), i = g(rt(n, p()), "CloudStorageData").parse(r);
1300
1291
  return Array.isArray(t) ? i : i[t];
1301
1292
  }
1302
1293
  /**
@@ -1314,10 +1305,10 @@ class Ae extends st {
1314
1305
  );
1315
1306
  }
1316
1307
  }
1317
- const rs = l(
1318
- ({ createRequestId: e, postEvent: t, version: s }) => new Ae(s, e, t)
1308
+ const is = l(
1309
+ ({ createRequestId: e, postEvent: t, version: s }) => new Ie(s, e, t)
1319
1310
  );
1320
- class Ie extends st {
1311
+ class qe extends et {
1321
1312
  constructor(t, s) {
1322
1313
  super(t, {
1323
1314
  impactOccurred: "web_app_trigger_haptic_feedback",
@@ -1359,10 +1350,10 @@ class Ie extends st {
1359
1350
  this.postEvent("web_app_trigger_haptic_feedback", { type: "selection_change" });
1360
1351
  }
1361
1352
  }
1362
- const is = l(
1363
- ({ version: e, postEvent: t }) => new Ie(e, t)
1353
+ const os = l(
1354
+ ({ version: e, postEvent: t }) => new qe(e, t)
1364
1355
  );
1365
- class qe {
1356
+ class ke {
1366
1357
  constructor(t) {
1367
1358
  this.initData = t;
1368
1359
  }
@@ -1435,13 +1426,13 @@ class qe {
1435
1426
  return this.initData.user;
1436
1427
  }
1437
1428
  }
1438
- const os = l(
1439
- ({ initData: e }) => e ? new qe(e) : void 0
1429
+ const as = l(
1430
+ ({ initData: e }) => e ? new ke(e) : void 0
1440
1431
  );
1441
- function as(e) {
1442
- return Pt().parse(e);
1432
+ function cs(e) {
1433
+ return xt().parse(e);
1443
1434
  }
1444
- class ke extends q {
1435
+ class Ne extends k {
1445
1436
  constructor(t, s, n) {
1446
1437
  super({ isOpened: t }, s, { open: "web_app_open_invoice" }), this.postEvent = n;
1447
1438
  }
@@ -1471,7 +1462,7 @@ class ke extends q {
1471
1462
  }
1472
1463
  this.isOpened = !0;
1473
1464
  try {
1474
- return (await _({
1465
+ return (await d({
1475
1466
  method: "web_app_open_invoice",
1476
1467
  event: "invoice_closed",
1477
1468
  params: { slug: n },
@@ -1485,10 +1476,10 @@ class ke extends q {
1485
1476
  }
1486
1477
  }
1487
1478
  }
1488
- const cs = l(
1489
- ({ version: e, postEvent: t }) => new ke(!1, e, t)
1479
+ const hs = l(
1480
+ ({ version: e, postEvent: t }) => new Ne(!1, e, t)
1490
1481
  );
1491
- class Ne extends Z {
1482
+ class De extends Y {
1492
1483
  constructor({ postEvent: s, ...n }) {
1493
1484
  super(n);
1494
1485
  c(this, "postEvent");
@@ -1503,7 +1494,7 @@ class Ne extends Z {
1503
1494
  * @param event - event to listen.
1504
1495
  * @param listener - listener to remove.
1505
1496
  */
1506
- c(this, "off", (s, n) => s === "click" ? V("main_button_pressed", n) : this.state.off(s, n));
1497
+ c(this, "off", (s, n) => s === "click" ? L("main_button_pressed", n) : this.state.off(s, n));
1507
1498
  this.postEvent = s;
1508
1499
  }
1509
1500
  /**
@@ -1633,7 +1624,7 @@ class Ne extends Z {
1633
1624
  return this.get("textColor");
1634
1625
  }
1635
1626
  }
1636
- const hs = l(
1627
+ const ps = l(
1637
1628
  "mainButton",
1638
1629
  ({
1639
1630
  postEvent: e,
@@ -1646,47 +1637,47 @@ const hs = l(
1646
1637
  textColor: t.buttonTextColor || "#ffffff",
1647
1638
  bgColor: t.buttonColor || "#000000"
1648
1639
  }
1649
- }) => new Ne({ ...s, postEvent: e })
1640
+ }) => new De({ ...s, postEvent: e })
1650
1641
  );
1651
- function De() {
1652
- return X({
1653
- contact: d({
1642
+ function Me() {
1643
+ return K({
1644
+ contact: g({
1654
1645
  userId: {
1655
1646
  type: y(),
1656
1647
  from: "user_id"
1657
1648
  },
1658
1649
  phoneNumber: {
1659
- type: h(),
1650
+ type: p(),
1660
1651
  from: "phone_number"
1661
1652
  },
1662
1653
  firstName: {
1663
- type: h(),
1654
+ type: p(),
1664
1655
  from: "first_name"
1665
1656
  },
1666
1657
  lastName: {
1667
- type: h().optional(),
1658
+ type: p().optional(),
1668
1659
  from: "last_name"
1669
1660
  }
1670
1661
  }),
1671
1662
  authDate: {
1672
- type: xt(),
1663
+ type: Et(),
1673
1664
  from: "auth_date"
1674
1665
  },
1675
- hash: h()
1666
+ hash: p()
1676
1667
  }, "RequestedContact");
1677
1668
  }
1678
- function Mt(e, t) {
1669
+ function Dt(e, t) {
1679
1670
  return (s) => {
1680
1671
  const [n, r] = t[s];
1681
1672
  return v(n, r, e);
1682
1673
  };
1683
1674
  }
1684
- function Me(e) {
1675
+ function Ve(e) {
1685
1676
  return new Promise((t) => {
1686
1677
  setTimeout(t, e);
1687
1678
  });
1688
1679
  }
1689
- class Le extends q {
1680
+ class Le extends k {
1690
1681
  constructor({ postEvent: s, createRequestId: n, version: r, botInline: i, ...o }) {
1691
1682
  super(o, r, {
1692
1683
  requestPhoneAccess: "web_app_request_phone",
@@ -1706,7 +1697,7 @@ class Le extends q {
1706
1697
  c(this, "supportsParam");
1707
1698
  this.createRequestId = n, this.postEvent = s, this.botInline = i;
1708
1699
  const a = this.supports.bind(this);
1709
- this.supports = (p) => a(p) ? p !== "switchInlineQuery" || i : !1, this.supportsParam = Mt(r, {
1700
+ this.supports = (h) => a(h) ? h !== "switchInlineQuery" || i : !1, this.supportsParam = Dt(r, {
1710
1701
  "setHeaderColor.color": ["web_app_set_header_color", "color"]
1711
1702
  });
1712
1703
  }
@@ -1717,7 +1708,7 @@ class Le extends q {
1717
1708
  async getRequestedContact({
1718
1709
  timeout: s = 1e4
1719
1710
  } = {}) {
1720
- return De().parse(
1711
+ return Me().parse(
1721
1712
  await S(
1722
1713
  "getRequestedContact",
1723
1714
  {},
@@ -1735,9 +1726,10 @@ class Le extends q {
1735
1726
  }
1736
1727
  /**
1737
1728
  * Closes the Mini App.
1729
+ * @param returnBack - should the application be wrapped into the bottom bar.
1738
1730
  */
1739
- close() {
1740
- this.postEvent("web_app_close");
1731
+ close(s) {
1732
+ this.postEvent("web_app_close", { return_back: s });
1741
1733
  }
1742
1734
  /**
1743
1735
  * The Mini App header color.
@@ -1754,10 +1746,10 @@ class Le extends q {
1754
1746
  return this.botInline;
1755
1747
  }
1756
1748
  /**
1757
- * True if current Mini App background color is recognized as dark.
1749
+ * True if the current Mini App background color is recognized as dark.
1758
1750
  */
1759
1751
  get isDark() {
1760
- return vt(this.bgColor);
1752
+ return yt(this.bgColor);
1761
1753
  }
1762
1754
  /**
1763
1755
  * Informs the Telegram app that the Mini App is ready to be displayed.
@@ -1786,15 +1778,15 @@ class Le extends q {
1786
1778
  throw new Error("Access denied.");
1787
1779
  const r = Date.now() + s;
1788
1780
  let i = 50;
1789
- return yt(async () => {
1781
+ return wt(async () => {
1790
1782
  for (; Date.now() < r; ) {
1791
1783
  try {
1792
1784
  return await this.getRequestedContact();
1793
1785
  } catch {
1794
1786
  }
1795
- await Me(i), i += 50;
1787
+ await Ve(i), i += 50;
1796
1788
  }
1797
- throw mt(s);
1789
+ throw bt(s);
1798
1790
  }, s);
1799
1791
  }
1800
1792
  /**
@@ -1807,7 +1799,7 @@ class Le extends q {
1807
1799
  * @see requestContact
1808
1800
  */
1809
1801
  async requestPhoneAccess(s = {}) {
1810
- return this.requestPhoneAccessPromise || (this.requestPhoneAccessPromise = _({
1802
+ return this.requestPhoneAccessPromise || (this.requestPhoneAccessPromise = d({
1811
1803
  ...s,
1812
1804
  method: "web_app_request_phone",
1813
1805
  event: "phone_requested",
@@ -1819,7 +1811,7 @@ class Le extends q {
1819
1811
  * @param options - additional options.
1820
1812
  */
1821
1813
  async requestWriteAccess(s = {}) {
1822
- return this.requestWriteAccessPromise || (this.requestWriteAccessPromise = _({
1814
+ return this.requestWriteAccessPromise || (this.requestWriteAccessPromise = d({
1823
1815
  ...s,
1824
1816
  method: "web_app_request_write_access",
1825
1817
  event: "write_access_requested",
@@ -1849,7 +1841,7 @@ class Le extends q {
1849
1841
  * @param color - color key or RGB color.
1850
1842
  */
1851
1843
  setHeaderColor(s) {
1852
- this.postEvent("web_app_set_header_color", Y(s) ? { color: s } : { color_key: s }), this.set("headerColor", s);
1844
+ this.postEvent("web_app_set_header_color", Q(s) ? { color: s } : { color_key: s }), this.set("headerColor", s);
1853
1845
  }
1854
1846
  /**
1855
1847
  * Updates current Mini App background color.
@@ -1877,7 +1869,7 @@ class Le extends q {
1877
1869
  this.postEvent("web_app_switch_inline_query", { query: s, chat_types: n });
1878
1870
  }
1879
1871
  }
1880
- const ps = l(
1872
+ const us = l(
1881
1873
  "miniApp",
1882
1874
  ({
1883
1875
  themeParams: e,
@@ -1889,7 +1881,7 @@ const ps = l(
1889
1881
  ...n
1890
1882
  }) => new Le({ ...n, ...s, botInline: t })
1891
1883
  );
1892
- function Ve(e) {
1884
+ function $e(e) {
1893
1885
  const t = e.message.trim(), s = (e.title || "").trim(), n = e.buttons || [];
1894
1886
  let r;
1895
1887
  if (s.length > 64)
@@ -1905,15 +1897,15 @@ function Ve(e) {
1905
1897
  if (!i.type || i.type === "default" || i.type === "destructive") {
1906
1898
  const a = i.text.trim();
1907
1899
  if (!a.length || a.length > 64) {
1908
- const p = i.type || "default";
1909
- throw new Error(`Button text with type "${p}" has incorrect size: ${i.text.length}`);
1900
+ const h = i.type || "default";
1901
+ throw new Error(`Button text with type "${h}" has incorrect size: ${i.text.length}`);
1910
1902
  }
1911
1903
  return { ...i, text: a, id: o };
1912
1904
  }
1913
1905
  return { ...i, id: o };
1914
1906
  }) : r = [{ type: "close", id: "" }], { title: s, message: t, buttons: r };
1915
1907
  }
1916
- class $e extends q {
1908
+ class Be extends k {
1917
1909
  constructor(t, s, n) {
1918
1910
  super({ isOpened: t }, s, { open: "web_app_open_popup" }), this.postEvent = n;
1919
1911
  }
@@ -1942,11 +1934,11 @@ class $e extends q {
1942
1934
  throw new Error("Popup is already opened.");
1943
1935
  this.isOpened = !0;
1944
1936
  try {
1945
- const { button_id: s = null } = await _({
1937
+ const { button_id: s = null } = await d({
1946
1938
  event: "popup_closed",
1947
1939
  method: "web_app_open_popup",
1948
1940
  postEvent: this.postEvent,
1949
- params: Ve(t)
1941
+ params: $e(t)
1950
1942
  });
1951
1943
  return s;
1952
1944
  } finally {
@@ -1954,10 +1946,10 @@ class $e extends q {
1954
1946
  }
1955
1947
  }
1956
1948
  }
1957
- const us = l(
1958
- ({ postEvent: e, version: t }) => new $e(!1, t, e)
1949
+ const ls = l(
1950
+ ({ postEvent: e, version: t }) => new Be(!1, t, e)
1959
1951
  );
1960
- class Be extends q {
1952
+ class We extends k {
1961
1953
  constructor(t, s, n) {
1962
1954
  super({ isOpened: t }, s, {
1963
1955
  close: "web_app_close_scan_qr_popup",
@@ -1985,7 +1977,7 @@ class Be extends q {
1985
1977
  const { text: s, capture: n } = (typeof t == "string" ? { text: t } : t) || {};
1986
1978
  this.isOpened = !0;
1987
1979
  try {
1988
- const i = (await _({
1980
+ const i = (await d({
1989
1981
  method: "web_app_open_scan_qr_popup",
1990
1982
  event: ["qr_text_received", "scan_qr_popup_closed"],
1991
1983
  postEvent: this.postEvent,
@@ -2001,10 +1993,10 @@ class Be extends q {
2001
1993
  }
2002
1994
  // TODO: Streaming mode, allowing to scan several QRs until closed.
2003
1995
  }
2004
- const ls = l(
2005
- ({ version: e, postEvent: t }) => new Be(!1, e, t)
1996
+ const ds = l(
1997
+ ({ version: e, postEvent: t }) => new We(!1, e, t)
2006
1998
  );
2007
- class We extends K {
1999
+ class Ue extends Z {
2008
2000
  constructor(s, n, r) {
2009
2001
  super({ isVisible: s }, n, {
2010
2002
  show: "web_app_setup_settings_button",
@@ -2021,7 +2013,7 @@ class We extends K {
2021
2013
  * @param event - event to listen.
2022
2014
  * @param listener - listener to remove.
2023
2015
  */
2024
- c(this, "off", (s, n) => s === "click" ? V("settings_button_pressed", n) : this.state.off(s, n));
2016
+ c(this, "off", (s, n) => s === "click" ? L("settings_button_pressed", n) : this.state.off(s, n));
2025
2017
  this.postEvent = r;
2026
2018
  }
2027
2019
  set isVisible(s) {
@@ -2046,18 +2038,18 @@ class We extends K {
2046
2038
  this.isVisible = !0;
2047
2039
  }
2048
2040
  }
2049
- const ds = l(
2041
+ const _s = l(
2050
2042
  "settingsButton",
2051
2043
  ({
2052
2044
  version: e,
2053
2045
  postEvent: t,
2054
2046
  state: s = { isVisible: !1 }
2055
- }) => new We(s.isVisible, e, t)
2047
+ }) => new Ue(s.isVisible, e, t)
2056
2048
  );
2057
- function Lt(e) {
2058
- return St().parse(e);
2049
+ function Mt(e) {
2050
+ return Pt().parse(e);
2059
2051
  }
2060
- class Ue extends et {
2052
+ class He extends tt {
2061
2053
  /**
2062
2054
  * @since v6.10
2063
2055
  */
@@ -2096,7 +2088,7 @@ class Ue extends et {
2096
2088
  * value is calculated according to theme bg color.
2097
2089
  */
2098
2090
  get isDark() {
2099
- return !this.bgColor || vt(this.bgColor);
2091
+ return !this.bgColor || yt(this.bgColor);
2100
2092
  }
2101
2093
  get linkColor() {
2102
2094
  return this.get("linkColor");
@@ -2128,7 +2120,7 @@ class Ue extends et {
2128
2120
  */
2129
2121
  listen() {
2130
2122
  return b("theme_changed", (t) => {
2131
- this.set(Lt(t.theme_params));
2123
+ this.set(Mt(t.theme_params));
2132
2124
  });
2133
2125
  }
2134
2126
  /**
@@ -2141,49 +2133,51 @@ class Ue extends et {
2141
2133
  return this.get("textColor");
2142
2134
  }
2143
2135
  }
2144
- const _s = l(
2136
+ const fs = l(
2145
2137
  "themeParams",
2146
2138
  ({ themeParams: e, state: t = e, addCleanup: s }) => {
2147
- const n = new Ue(t);
2139
+ const n = new He(t);
2148
2140
  return s(n.listen()), n;
2149
2141
  }
2150
2142
  );
2151
- function fs(e = {}) {
2152
- return _({
2143
+ function gs(e = {}) {
2144
+ return d({
2153
2145
  ...e,
2154
2146
  method: "web_app_request_theme",
2155
2147
  event: "theme_changed"
2156
- }).then(Lt);
2148
+ }).then(Mt);
2157
2149
  }
2158
- class Oe extends st {
2150
+ function A(e, t) {
2151
+ return e.startsWith(t) ? e : `${t}${e}`;
2152
+ }
2153
+ function I(e) {
2154
+ return new URL(
2155
+ typeof e == "string" ? e : `${e.pathname || ""}${A(e.search || "", "?")}${A(e.hash || "", "#")}`,
2156
+ "http://a"
2157
+ );
2158
+ }
2159
+ class Oe extends et {
2159
2160
  constructor(s, n, r) {
2160
2161
  super(s, { readTextFromClipboard: "web_app_read_text_from_clipboard" });
2161
2162
  /**
2162
2163
  * Checks if specified method parameter is supported by current component.
2163
2164
  */
2164
2165
  c(this, "supportsParam");
2165
- this.version = s, this.createRequestId = n, this.postEvent = r, this.supportsParam = Mt(s, {
2166
+ this.version = s, this.createRequestId = n, this.postEvent = r, this.supportsParam = Dt(s, {
2166
2167
  "openLink.tryInstantView": ["web_app_open_link", "try_instant_view"]
2167
2168
  });
2168
2169
  }
2169
- /**
2170
- * Opens a link in an external browser. The Mini App will not be closed.
2171
- *
2172
- * Note that this method can be called only in response to the user
2173
- * interaction with the Mini App interface (e.g. click inside the Mini App
2174
- * or on the main button).
2175
- * @param url - URL to be opened.
2176
- * @param tryInstantView
2177
- */
2178
2170
  openLink(s, n) {
2179
- const r = new URL(s, window.location.href).toString();
2171
+ const r = I(s).toString();
2180
2172
  if (!v("web_app_open_link", this.version)) {
2181
2173
  window.open(r, "_blank");
2182
2174
  return;
2183
2175
  }
2176
+ const i = typeof n == "boolean" ? { tryInstantView: n } : n || {};
2184
2177
  this.postEvent("web_app_open_link", {
2185
2178
  url: r,
2186
- ...typeof n == "boolean" ? { try_instant_view: n } : {}
2179
+ try_browser: i.tryBrowser,
2180
+ try_instant_view: i.tryInstantView
2187
2181
  });
2188
2182
  }
2189
2183
  /**
@@ -2211,12 +2205,12 @@ class Oe extends st {
2211
2205
  async readTextFromClipboard() {
2212
2206
  const s = this.createRequestId(), {
2213
2207
  data: n = null
2214
- } = await _({
2208
+ } = await d({
2215
2209
  method: "web_app_read_text_from_clipboard",
2216
2210
  event: "clipboard_text_received",
2217
2211
  postEvent: this.postEvent,
2218
2212
  params: { req_id: s },
2219
- capture: wt(s)
2213
+ capture: gt(s)
2220
2214
  });
2221
2215
  return n;
2222
2216
  }
@@ -2232,11 +2226,11 @@ class Oe extends st {
2232
2226
  */
2233
2227
  shareURL(s, n) {
2234
2228
  this.openTelegramLink(
2235
- "https://t.me/share/url?" + new URLSearchParams({ url: s, text: n || "" }).toString()
2229
+ "https://t.me/share/url?" + new URLSearchParams({ url: s, text: n || "" }).toString().replace(/\+/g, "%20")
2236
2230
  );
2237
2231
  }
2238
2232
  }
2239
- const gs = l(
2233
+ const bs = l(
2240
2234
  ({ version: e, postEvent: t, createRequestId: s }) => new Oe(e, s, t)
2241
2235
  );
2242
2236
  async function Vt(e = {}) {
@@ -2244,7 +2238,7 @@ async function Vt(e = {}) {
2244
2238
  is_expanded: t,
2245
2239
  is_state_stable: s,
2246
2240
  ...n
2247
- } = await _({
2241
+ } = await d({
2248
2242
  ...e,
2249
2243
  method: "web_app_request_viewport",
2250
2244
  event: "viewport_changed"
@@ -2254,7 +2248,7 @@ async function Vt(e = {}) {
2254
2248
  function P(e) {
2255
2249
  return e < 0 ? 0 : e;
2256
2250
  }
2257
- class He extends et {
2251
+ class Ge extends tt {
2258
2252
  constructor({ postEvent: s, stableHeight: n, height: r, width: i, isExpanded: o }) {
2259
2253
  super({
2260
2254
  height: P(r),
@@ -2363,7 +2357,7 @@ class He extends et {
2363
2357
  return this.stableHeight === this.height;
2364
2358
  }
2365
2359
  }
2366
- const bs = l(
2360
+ const ws = l(
2367
2361
  "viewport",
2368
2362
  async ({ state: e, platform: t, postEvent: s, addCleanup: n }) => {
2369
2363
  let r = !1, i = 0, o = 0, a = 0;
@@ -2375,28 +2369,28 @@ const bs = l(
2375
2369
  const u = await Vt({ timeout: 1e3, postEvent: s });
2376
2370
  r = u.isExpanded, i = u.height, o = u.width, a = u.isStateStable ? i : 0;
2377
2371
  }
2378
- const p = new He({
2372
+ const h = new Ge({
2379
2373
  postEvent: s,
2380
2374
  height: i,
2381
2375
  width: o,
2382
2376
  stableHeight: a,
2383
2377
  isExpanded: r
2384
2378
  });
2385
- return n(p.listen()), p;
2379
+ return n(h.listen()), h;
2386
2380
  }
2387
2381
  );
2388
2382
  function m(e, t) {
2389
2383
  document.documentElement.style.setProperty(e, t);
2390
2384
  }
2391
- function ws(e, t, s) {
2385
+ function ms(e, t, s) {
2392
2386
  s || (s = (a) => `--tg-${a}-color`);
2393
2387
  const n = s("header"), r = s("bg"), i = () => {
2394
2388
  const { headerColor: a } = e;
2395
- if (Y(a))
2389
+ if (Q(a))
2396
2390
  m(n, a);
2397
2391
  else {
2398
- const { bgColor: p, secondaryBgColor: u } = t;
2399
- a === "bg_color" && p ? m(n, p) : a === "secondary_bg_color" && u && m(n, u);
2392
+ const { bgColor: h, secondaryBgColor: u } = t;
2393
+ a === "bg_color" && h ? m(n, h) : a === "secondary_bg_color" && u && m(n, u);
2400
2394
  }
2401
2395
  m(r, e.bgColor);
2402
2396
  }, o = [
@@ -2405,7 +2399,7 @@ function ws(e, t, s) {
2405
2399
  ];
2406
2400
  return i(), () => o.forEach((a) => a());
2407
2401
  }
2408
- function ms(e, t) {
2402
+ function ys(e, t) {
2409
2403
  t || (t = (n) => `--tg-theme-${n.replace(/[A-Z]/g, (r) => `-${r.toLowerCase()}`)}`);
2410
2404
  const s = () => {
2411
2405
  Object.entries(e.getState()).forEach(([n, r]) => {
@@ -2414,20 +2408,20 @@ function ms(e, t) {
2414
2408
  };
2415
2409
  return s(), e.on("change", s);
2416
2410
  }
2417
- function ys(e, t) {
2411
+ function vs(e, t) {
2418
2412
  t || (t = (u) => `--tg-viewport-${u}`);
2419
2413
  const [
2420
2414
  s,
2421
2415
  n,
2422
2416
  r
2423
- ] = ["height", "width", "stable-height"].map((u) => t(u)), i = () => m(s, `${e.height}px`), o = () => m(n, `${e.width}px`), a = () => m(r, `${e.stableHeight}px`), p = [
2417
+ ] = ["height", "width", "stable-height"].map((u) => t(u)), i = () => m(s, `${e.height}px`), o = () => m(n, `${e.width}px`), a = () => m(r, `${e.stableHeight}px`), h = [
2424
2418
  e.on("change:height", i),
2425
2419
  e.on("change:width", o),
2426
2420
  e.on("change:stableHeight", a)
2427
2421
  ];
2428
- return i(), o(), a(), () => p.forEach((u) => u());
2422
+ return i(), o(), a(), () => h.forEach((u) => u());
2429
2423
  }
2430
- function vs(e = !0) {
2424
+ function Es(e = !0) {
2431
2425
  const t = [
2432
2426
  b("reload_iframe", () => {
2433
2427
  R("iframe_will_reload"), window.location.reload();
@@ -2444,27 +2438,27 @@ function vs(e = !0) {
2444
2438
  }
2445
2439
  return R("iframe_ready", { reload_supported: !0 }), s;
2446
2440
  }
2447
- function Es() {
2441
+ function xs() {
2448
2442
  return typeof window > "u";
2449
2443
  }
2450
- async function xs() {
2451
- if (ft(window))
2444
+ async function Ps() {
2445
+ if (dt(window))
2452
2446
  return !0;
2453
2447
  try {
2454
- return await _({ method: "web_app_request_theme", event: "theme_changed", timeout: 100 }), !0;
2448
+ return await d({ method: "web_app_request_theme", event: "theme_changed", timeout: 100 }), !0;
2455
2449
  } catch {
2456
2450
  return !1;
2457
2451
  }
2458
2452
  }
2459
- function Ps(e) {
2460
- const t = typeof e == "string" ? tt(e) : e;
2461
- kt(t);
2453
+ function Ss(e) {
2454
+ const t = typeof e == "string" ? X(e) : e;
2455
+ qt(t);
2462
2456
  function s(r) {
2463
2457
  if (typeof r == "string")
2464
2458
  try {
2465
- const { eventType: i } = dt(r);
2459
+ const { eventType: i } = ut(r);
2466
2460
  i === "web_app_request_theme" && j("theme_changed", {
2467
- theme_params: JSON.parse(qt(t.themeParams))
2461
+ theme_params: JSON.parse(It(t.themeParams))
2468
2462
  }), i === "web_app_request_viewport" && j("viewport_changed", {
2469
2463
  width: window.innerWidth,
2470
2464
  height: window.innerHeight,
@@ -2474,14 +2468,14 @@ function Ps(e) {
2474
2468
  } catch {
2475
2469
  }
2476
2470
  }
2477
- if (gt()) {
2471
+ if (_t()) {
2478
2472
  const r = window.parent.postMessage.bind(window.parent);
2479
2473
  window.parent.postMessage = (i) => {
2480
2474
  s(i), r(i);
2481
2475
  };
2482
2476
  return;
2483
2477
  }
2484
- if (_t(window)) {
2478
+ if (lt(window)) {
2485
2479
  const r = window.external.notify.bind(window.external);
2486
2480
  window.external.notify = (i) => {
2487
2481
  s(i), r(i);
@@ -2496,11 +2490,11 @@ function Ps(e) {
2496
2490
  }
2497
2491
  };
2498
2492
  }
2499
- function Ge(e) {
2493
+ function je(e) {
2500
2494
  return e instanceof D;
2501
2495
  }
2502
- function Ss(e, t) {
2503
- return Ge(e) && e.type === t;
2496
+ function Cs(e, t) {
2497
+ return je(e) && e.type === t;
2504
2498
  }
2505
2499
  function $(e, t) {
2506
2500
  let s, n, r;
@@ -2510,7 +2504,7 @@ function $(e, t) {
2510
2504
  params: n
2511
2505
  });
2512
2506
  }
2513
- class je {
2507
+ class ze {
2514
2508
  constructor(t, s, n = R) {
2515
2509
  /**
2516
2510
  * Navigation history.
@@ -2534,10 +2528,10 @@ class je {
2534
2528
  */
2535
2529
  c(this, "off", this.ee.off.bind(this.ee));
2536
2530
  if (this._index = s, this.postEvent = n, t.length === 0)
2537
- throw g(Kt, "History should not be empty.");
2531
+ throw f(Zt, "History should not be empty.");
2538
2532
  if (s < 0 || s >= t.length)
2539
- throw g(
2540
- Xt,
2533
+ throw f(
2534
+ Kt,
2541
2535
  "Index should not be zero and higher or equal than history size."
2542
2536
  );
2543
2537
  this.history = t.map((r) => $(r, ""));
@@ -2559,7 +2553,7 @@ class je {
2559
2553
  * Prevents current navigator from controlling the BackButton visibility state.
2560
2554
  */
2561
2555
  detach() {
2562
- this.attached = !1, V("back_button_pressed", this.back);
2556
+ this.attached = !1, L("back_button_pressed", this.back);
2563
2557
  }
2564
2558
  /**
2565
2559
  * Goes to the next history item.
@@ -2658,17 +2652,8 @@ function B({
2658
2652
  }) {
2659
2653
  return { ...e || { hash: "", search: "" }, ...t };
2660
2654
  }
2661
- function A(e, t) {
2662
- return e.startsWith(t) ? e : `${t}${e}`;
2663
- }
2664
- function k(e) {
2665
- return new URL(
2666
- typeof e == "string" ? e : `${e.pathname || ""}${A(e.search || "", "?")}${A(e.hash || "", "#")}`,
2667
- "http://a"
2668
- );
2669
- }
2670
2655
  function N(e) {
2671
- const t = typeof e == "string" ? e.startsWith("/") : !!(e.pathname && e.pathname.startsWith("/")), s = k(e);
2656
+ const t = typeof e == "string" ? e.startsWith("/") : !!(e.pathname && e.pathname.startsWith("/")), s = I(e);
2672
2657
  return `${t ? s.pathname : s.pathname.slice(1)}${s.search}${s.hash}`;
2673
2658
  }
2674
2659
  function W(e, t, s) {
@@ -2691,18 +2676,18 @@ async function C(e) {
2691
2676
  })
2692
2677
  ]);
2693
2678
  }
2694
- async function ze() {
2679
+ async function Fe() {
2695
2680
  if (window.history.length <= 1 || (window.history.pushState(null, ""), await C(1 - window.history.length)))
2696
2681
  return;
2697
2682
  let t = await C(-1);
2698
2683
  for (; t; )
2699
2684
  t = await C(-1);
2700
2685
  }
2701
- function $t(e) {
2702
- return k(e).pathname;
2686
+ function Lt(e) {
2687
+ return I(e).pathname;
2703
2688
  }
2704
- const ot = 0, U = 1, O = 2;
2705
- class Bt {
2689
+ const it = 0, U = 1, H = 2;
2690
+ class $t {
2706
2691
  constructor(t, s, { postEvent: n, hashMode: r = "classic", base: i } = {}) {
2707
2692
  c(this, "navigator");
2708
2693
  c(this, "ee", new T());
@@ -2719,7 +2704,7 @@ class Bt {
2719
2704
  c(this, "onPopState", ({ state: t }) => {
2720
2705
  if (t === null)
2721
2706
  return this.push(this.parsePath(window.location.href));
2722
- t === ot ? window.history.forward() : t === U && this.back(), t === O && this.forward();
2707
+ t === it ? window.history.forward() : t === U && this.back(), t === H && this.forward();
2723
2708
  });
2724
2709
  /**
2725
2710
  * Underlying navigator change event listener.
@@ -2744,13 +2729,13 @@ class Bt {
2744
2729
  * Removes event listener.
2745
2730
  */
2746
2731
  c(this, "off", this.ee.off.bind(this.ee));
2747
- this.navigator = new je(
2732
+ this.navigator = new ze(
2748
2733
  t.map((o) => W(o, "/")),
2749
2734
  s,
2750
2735
  n
2751
2736
  ), this.navigator.on("change", (o) => {
2752
2737
  this.onNavigatorChange(o);
2753
- }), this.hashMode = r, this.base = $t(i || "");
2738
+ }), this.hashMode = r, this.base = Lt(i || "");
2754
2739
  }
2755
2740
  /**
2756
2741
  * Attaches current navigator to the browser history allowing navigator to manipulate it.
@@ -2877,8 +2862,8 @@ class Bt {
2877
2862
  * // { pathname: '/tma', search: '?is=cool', hash: '#yeah' }
2878
2863
  */
2879
2864
  parsePath(t) {
2880
- let s = k(t);
2881
- return this.hashMode && (s = k(s.hash.slice(1))), {
2865
+ let s = I(t);
2866
+ return this.hashMode && (s = I(s.hash.slice(1))), {
2882
2867
  pathname: s.pathname,
2883
2868
  search: s.search,
2884
2869
  hash: s.hash
@@ -2907,7 +2892,7 @@ class Bt {
2907
2892
  async syncHistory() {
2908
2893
  window.removeEventListener("popstate", this.onPopState);
2909
2894
  const { state: t } = this, s = this.renderPath(this);
2910
- await ze(), this.hasPrev && this.hasNext ? (window.history.replaceState(U, ""), window.history.pushState(t, "", s), window.history.pushState(O, ""), await C(-1)) : this.hasPrev ? (window.history.replaceState(U, ""), window.history.pushState(t, "", s)) : this.hasNext ? (window.history.replaceState(t, s), window.history.pushState(O, ""), await C(-1)) : (window.history.replaceState(ot, ""), window.history.pushState(t, "", s)), window.addEventListener("popstate", this.onPopState);
2895
+ await Fe(), this.hasPrev && this.hasNext ? (window.history.replaceState(U, ""), window.history.pushState(t, "", s), window.history.pushState(H, ""), await C(-1)) : this.hasPrev ? (window.history.replaceState(U, ""), window.history.pushState(t, "", s)) : this.hasNext ? (window.history.replaceState(t, s), window.history.pushState(H, ""), await C(-1)) : (window.history.replaceState(it, ""), window.history.pushState(t, "", s)), window.addEventListener("popstate", this.onPopState);
2911
2896
  }
2912
2897
  /**
2913
2898
  * Current query parameters.
@@ -2925,34 +2910,34 @@ class Bt {
2925
2910
  return (this.navigator.current.params || {}).state;
2926
2911
  }
2927
2912
  }
2928
- function Fe(e) {
2913
+ function Je(e) {
2929
2914
  e || (e = {});
2930
2915
  const { href: t, hash: s } = window.location;
2931
2916
  let n = N(
2932
2917
  e.hashMode === null ? t : s.includes("?") ? s.slice(1) : `?${s.slice(1)}`
2933
2918
  );
2934
- const r = e.base ? $t(e.base) : void 0;
2919
+ const r = e.base ? Lt(e.base) : void 0;
2935
2920
  if (r) {
2936
2921
  if (!n.startsWith(r))
2937
- throw g(
2938
- te,
2922
+ throw f(
2923
+ Xt,
2939
2924
  `Path "${n}" expected to be starting with "${r}"`
2940
2925
  );
2941
2926
  n = n.slice(r.length);
2942
2927
  }
2943
- return new Bt([n], 0, e);
2928
+ return new $t([n], 0, e);
2944
2929
  }
2945
- function Cs(e) {
2930
+ function Ts(e) {
2946
2931
  const t = e.match(/#(.+)/);
2947
2932
  return t ? t[1] : null;
2948
2933
  }
2949
- function Je(e, t) {
2950
- if (Nt()) {
2934
+ function Qe(e, t) {
2935
+ if (kt()) {
2951
2936
  const s = sessionStorage.getItem(e);
2952
2937
  if (s)
2953
2938
  try {
2954
2939
  const { index: n, history: r } = JSON.parse(s);
2955
- return new Bt(
2940
+ return new $t(
2956
2941
  r,
2957
2942
  n,
2958
2943
  t
@@ -2961,10 +2946,10 @@ function Je(e, t) {
2961
2946
  console.error("Unable to restore hash navigator state.", n);
2962
2947
  }
2963
2948
  }
2964
- return Fe(t);
2949
+ return Je(t);
2965
2950
  }
2966
- function Ts(e, t) {
2967
- const s = Je(e, t), n = () => sessionStorage.setItem(e, JSON.stringify({
2951
+ function Rs(e, t) {
2952
+ const s = Qe(e, t), n = () => sessionStorage.setItem(e, JSON.stringify({
2968
2953
  index: s.index,
2969
2954
  history: s.history
2970
2955
  }));
@@ -2972,106 +2957,106 @@ function Ts(e, t) {
2972
2957
  }
2973
2958
  export {
2974
2959
  le as BackButton,
2975
- je as BasicNavigator,
2976
- xe as BiometryManager,
2977
- Bt as BrowserNavigator,
2978
- Se as ClosingBehavior,
2979
- Ae as CloudStorage,
2980
- te as ERR_INVALID_PATH_BASE,
2981
- Qt as ERR_INVOKE_CUSTOM_METHOD_RESPONSE,
2982
- Ft as ERR_METHOD_PARAMETER_UNSUPPORTED,
2983
- zt as ERR_METHOD_UNSUPPORTED,
2984
- Kt as ERR_NAVIGATION_HISTORY_EMPTY,
2985
- Xt as ERR_NAVIGATION_INDEX_INVALID,
2986
- Ze as ERR_NAVIGATION_ITEM_INVALID,
2987
- ht as ERR_PARSE,
2988
- Ke as ERR_SSR_INIT,
2989
- Yt as ERR_TIMED_OUT,
2990
- Zt as ERR_UNEXPECTED_TYPE,
2991
- Jt as ERR_UNKNOWN_ENV,
2960
+ ze as BasicNavigator,
2961
+ Pe as BiometryManager,
2962
+ $t as BrowserNavigator,
2963
+ Ce as ClosingBehavior,
2964
+ Ie as CloudStorage,
2965
+ Xt as ERR_INVALID_PATH_BASE,
2966
+ Jt as ERR_INVOKE_CUSTOM_METHOD_RESPONSE,
2967
+ zt as ERR_METHOD_PARAMETER_UNSUPPORTED,
2968
+ jt as ERR_METHOD_UNSUPPORTED,
2969
+ Zt as ERR_NAVIGATION_HISTORY_EMPTY,
2970
+ Kt as ERR_NAVIGATION_INDEX_INVALID,
2971
+ Ke as ERR_NAVIGATION_ITEM_INVALID,
2972
+ ct as ERR_PARSE,
2973
+ Xe as ERR_SSR_INIT,
2974
+ Qt as ERR_TIMED_OUT,
2975
+ Yt as ERR_UNEXPECTED_TYPE,
2976
+ Ft as ERR_UNKNOWN_ENV,
2992
2977
  T as EventEmitter,
2993
- Ie as HapticFeedback,
2994
- qe as InitData,
2995
- ke as Invoice,
2996
- Ne as MainButton,
2978
+ qe as HapticFeedback,
2979
+ ke as InitData,
2980
+ Ne as Invoice,
2981
+ De as MainButton,
2997
2982
  Le as MiniApp,
2998
- $e as Popup,
2999
- Be as QRScanner,
2983
+ Be as Popup,
2984
+ We as QRScanner,
3000
2985
  D as SDKError,
3001
- We as SettingsButton,
3002
- Ue as ThemeParams,
2986
+ Ue as SettingsButton,
2987
+ He as ThemeParams,
3003
2988
  Oe as Utils,
3004
- He as Viewport,
3005
- Re as array,
3006
- ws as bindMiniAppCSSVars,
3007
- ms as bindThemeParamsCSSVars,
3008
- ys as bindViewportCSSVars,
2989
+ Ge as Viewport,
2990
+ Ae as array,
2991
+ ms as bindMiniAppCSSVars,
2992
+ ys as bindThemeParamsCSSVars,
2993
+ vs as bindViewportCSSVars,
3009
2994
  w as boolean,
3010
- wt as captureSameReq,
2995
+ gt as captureSameReq,
3011
2996
  z as classNames,
3012
- ce as compareVersions,
3013
- Fe as createBrowserNavigatorFromLocation,
3014
- pe as createPostEvent,
3015
- k as createSafeURL,
3016
- xt as date,
3017
- Cs as getHash,
3018
- $t as getPathname,
3019
- es as initBackButton,
3020
- ss as initBiometryManager,
3021
- ns as initClosingBehavior,
3022
- rs as initCloudStorage,
3023
- is as initHapticFeedback,
3024
- os as initInitData,
3025
- cs as initInvoice,
3026
- hs as initMainButton,
3027
- ps as initMiniApp,
3028
- Ts as initNavigator,
3029
- us as initPopup,
3030
- ls as initQRScanner,
3031
- ds as initSettingsButton,
3032
- _s as initThemeParams,
3033
- gs as initUtils,
3034
- bs as initViewport,
3035
- vs as initWeb,
2997
+ oe as compareVersions,
2998
+ Je as createBrowserNavigatorFromLocation,
2999
+ he as createPostEvent,
3000
+ I as createSafeURL,
3001
+ Et as date,
3002
+ Ts as getHash,
3003
+ Lt as getPathname,
3004
+ ss as initBackButton,
3005
+ ns as initBiometryManager,
3006
+ rs as initClosingBehavior,
3007
+ is as initCloudStorage,
3008
+ os as initHapticFeedback,
3009
+ as as initInitData,
3010
+ hs as initInvoice,
3011
+ ps as initMainButton,
3012
+ us as initMiniApp,
3013
+ Rs as initNavigator,
3014
+ ls as initPopup,
3015
+ ds as initQRScanner,
3016
+ _s as initSettingsButton,
3017
+ fs as initThemeParams,
3018
+ bs as initUtils,
3019
+ ws as initViewport,
3020
+ Es as initWeb,
3036
3021
  S as invokeCustomMethod,
3037
- vt as isColorDark,
3038
- gt as isIframe,
3039
- Nt as isPageReload,
3040
- Y as isRGB,
3041
- ee as isRGBShort,
3042
- Ge as isSDKError,
3043
- Ss as isSDKErrorOfType,
3044
- Es as isSSR,
3045
- xs as isTMA,
3046
- d as json,
3047
- ts as mergeClassNames,
3048
- Ps as mockTelegramEnv,
3022
+ yt as isColorDark,
3023
+ _t as isIframe,
3024
+ kt as isPageReload,
3025
+ Q as isRGB,
3026
+ pe as isRGBShort,
3027
+ je as isSDKError,
3028
+ Cs as isSDKErrorOfType,
3029
+ xs as isSSR,
3030
+ Ps as isTMA,
3031
+ g as json,
3032
+ es as mergeClassNames,
3033
+ Ss as mockTelegramEnv,
3049
3034
  y as number,
3050
- V as off,
3035
+ L as off,
3051
3036
  b as on,
3052
- as as parseInitData,
3053
- tt as parseLaunchParams,
3054
- Lt as parseThemeParams,
3037
+ cs as parseInitData,
3038
+ X as parseLaunchParams,
3039
+ Mt as parseThemeParams,
3055
3040
  R as postEvent,
3056
- _ as request,
3057
- Pe as requestBiometryInfo,
3058
- fs as requestThemeParams,
3041
+ d as request,
3042
+ Se as requestBiometryInfo,
3043
+ gs as requestThemeParams,
3059
3044
  Vt as requestViewport,
3060
- ye as retrieveLaunchParams,
3061
- lt as rgb,
3062
- X as searchParams,
3063
- me as serializeLaunchParams,
3064
- qt as serializeThemeParams,
3045
+ ve as retrieveLaunchParams,
3046
+ _e as rgb,
3047
+ K as searchParams,
3048
+ ye as serializeLaunchParams,
3049
+ It as serializeThemeParams,
3065
3050
  m as setCSSVar,
3066
- Ye as setDebug,
3067
- Xe as setTargetOrigin,
3068
- h as string,
3051
+ Ze as setDebug,
3052
+ ts as setTargetOrigin,
3053
+ p as string,
3069
3054
  Ht as subscribe,
3070
3055
  v as supports,
3071
- he as targetOrigin,
3072
- ut as toRGB,
3073
- ct as unsubscribe,
3056
+ ce as targetOrigin,
3057
+ mt as toRGB,
3058
+ at as unsubscribe,
3074
3059
  N as urlToPath,
3075
- yt as withTimeout
3060
+ wt as withTimeout
3076
3061
  };
3077
3062
  //# sourceMappingURL=index.js.map