@tma.js/sdk 2.1.0 → 2.3.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 Dt = Object.defineProperty;
2
- var Vt = (e, t, s) => t in e ? Dt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s;
3
- var c = (e, t, s) => (Vt(e, typeof t != "symbol" ? t + "" : t, s), s);
4
- function it(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), s);
4
+ function at(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 ot(e) {
12
- const t = M(), { count: s } = t;
13
- t.unsubscribe(e), s && !t.count && ne();
11
+ function ct(e) {
12
+ const t = $(), { count: s } = t;
13
+ t.unsubscribe(e), s && !t.count && ae();
14
14
  }
15
- function $t(e) {
16
- return M().subscribe(e), () => ot(e);
15
+ function Ht(e) {
16
+ return $().subscribe(e), () => ct(e);
17
17
  }
18
- class Mt {
18
+ class Gt {
19
19
  constructor(t, s = {}) {
20
20
  this.scope = t, this.options = s;
21
21
  }
@@ -55,21 +55,21 @@ class Mt {
55
55
  this.print("log", ...t);
56
56
  }
57
57
  }
58
- const F = new Mt("SDK", {
58
+ const J = new Gt("SDK", {
59
59
  bgColor: "forestgreen",
60
60
  textColor: "white"
61
61
  });
62
62
  let G = !1;
63
- const et = ({ event: e, args: [t] }) => {
64
- F.log("Event received:", t === void 0 ? { name: e } : { name: e, data: t });
63
+ const nt = ({ name: e, payload: t }) => {
64
+ J.log("Event received:", t ? { name: e, payload: t } : { name: e });
65
65
  };
66
- function Ze(e) {
67
- G !== e && (G = e, e ? $t(et) : ot(et));
66
+ function Ye(e) {
67
+ G !== e && (G = e, e ? Ht(nt) : ct(nt));
68
68
  }
69
- function Lt(...e) {
70
- G && F.log(...e);
69
+ function jt(...e) {
70
+ G && J.log(...e);
71
71
  }
72
- class D {
72
+ class T {
73
73
  constructor() {
74
74
  c(this, "listeners", /* @__PURE__ */ new Map());
75
75
  c(this, "listenersCount", 0);
@@ -144,6 +144,17 @@ class D {
144
144
  function j(e, t, s) {
145
145
  return window.addEventListener(e, t, s), () => window.removeEventListener(e, t, s);
146
146
  }
147
+ function ht(...e) {
148
+ let t = !1;
149
+ const s = [...e];
150
+ return [
151
+ (n) => !t && s.push(n),
152
+ () => {
153
+ t || (t = !0, s.forEach((n) => n()));
154
+ },
155
+ t
156
+ ];
157
+ }
147
158
  class V extends Error {
148
159
  constructor(t, s, n) {
149
160
  super(s, { cause: n }), this.type = t, Object.setPrototypeOf(this, V.prototype);
@@ -152,11 +163,11 @@ class V extends Error {
152
163
  function f(e, t, s) {
153
164
  return new V(e, t, s);
154
165
  }
155
- const Bt = "ERR_METHOD_UNSUPPORTED", Ot = "ERR_METHOD_PARAMETER_UNSUPPORTED", Ut = "ERR_UNKNOWN_ENV", Wt = "ERR_INVOKE_CUSTOM_METHOD_RESPONSE", Ht = "ERR_TIMED_OUT", Gt = "ERR_UNEXPECTED_TYPE", at = "ERR_PARSE", jt = "ERR_NAVIGATION_LIST_EMPTY", zt = "ERR_NAVIGATION_CURSOR_INVALID", Ke = "ERR_NAVIGATION_ITEM_INVALID", Xe = "ERR_SSR_INIT", Ft = "ERR_INVALID_PATH_BASE";
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", pt = "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";
156
167
  function E() {
157
- return f(Gt, "Value has unexpected type");
168
+ return f(Zt, "Value has unexpected type");
158
169
  }
159
- class $ {
170
+ class M {
160
171
  constructor(t, s, n) {
161
172
  this.parser = t, this.isOptional = s, this.type = n;
162
173
  }
@@ -172,7 +183,7 @@ class $ {
172
183
  return this.parser(t);
173
184
  } catch (s) {
174
185
  throw f(
175
- at,
186
+ pt,
176
187
  `Unable to parse value${this.type ? ` as ${this.type}` : ""}`,
177
188
  s
178
189
  );
@@ -183,9 +194,9 @@ class $ {
183
194
  }
184
195
  }
185
196
  function P(e, t) {
186
- return () => new $(e, !1, t);
197
+ return () => new M(e, !1, t);
187
198
  }
188
- const w = P((e) => {
199
+ const b = P((e) => {
189
200
  if (typeof e == "boolean")
190
201
  return e;
191
202
  const t = String(e);
@@ -195,7 +206,7 @@ const w = P((e) => {
195
206
  return !1;
196
207
  throw E();
197
208
  }, "boolean");
198
- function ct(e, t) {
209
+ function ut(e, t) {
199
210
  const s = {};
200
211
  for (const n in e) {
201
212
  const r = e[n];
@@ -212,21 +223,21 @@ function ct(e, t) {
212
223
  const o = a(t(i));
213
224
  o !== void 0 && (s[n] = o);
214
225
  } catch (o) {
215
- throw f(at, `Unable to parse field "${n}"`, o);
226
+ throw f(pt, `Unable to parse field "${n}"`, o);
216
227
  }
217
228
  }
218
229
  return s;
219
230
  }
220
- function J(e) {
231
+ function Q(e) {
221
232
  let t = e;
222
233
  if (typeof t == "string" && (t = JSON.parse(t)), typeof t != "object" || t === null || Array.isArray(t))
223
234
  throw E();
224
235
  return t;
225
236
  }
226
237
  function d(e, t) {
227
- return new $((s) => {
228
- const n = J(s);
229
- return ct(e, (r) => n[r]);
238
+ return new M((s) => {
239
+ const n = Q(s);
240
+ return ut(e, (r) => n[r]);
230
241
  }, !1, t);
231
242
  }
232
243
  const y = P((e) => {
@@ -239,17 +250,17 @@ const y = P((e) => {
239
250
  }
240
251
  throw E();
241
252
  }, "number");
242
- function Q(e) {
253
+ function Y(e) {
243
254
  return /^#[\da-f]{6}$/i.test(e);
244
255
  }
245
- function Jt(e) {
256
+ function ee(e) {
246
257
  return /^#[\da-f]{3}$/i.test(e);
247
258
  }
248
- function ht(e) {
259
+ function lt(e) {
249
260
  const t = e.replace(/\s/g, "").toLowerCase();
250
- if (Q(t))
261
+ if (Y(t))
251
262
  return t;
252
- if (Jt(t)) {
263
+ if (ee(t)) {
253
264
  let n = "#";
254
265
  for (let r = 0; r < 3; r += 1)
255
266
  n += t[1 + r].repeat(2);
@@ -267,26 +278,26 @@ const h = P((e) => {
267
278
  if (typeof e == "string" || typeof e == "number")
268
279
  return e.toString();
269
280
  throw E();
270
- }, "string"), pt = P((e) => ht(h().parse(e)), "rgb");
271
- function Qt(e) {
281
+ }, "string"), dt = P((e) => lt(h().parse(e)), "rgb");
282
+ function _t(e) {
272
283
  return d({
273
284
  eventType: h(),
274
285
  eventData: (t) => t
275
286
  }).parse(e);
276
287
  }
277
- function Yt() {
288
+ function se() {
278
289
  ["TelegramGameProxy_receiveEvent", "TelegramGameProxy", "Telegram"].forEach((e) => {
279
290
  delete window[e];
280
291
  });
281
292
  }
282
- function Zt(e, t) {
293
+ function z(e, t) {
283
294
  window.dispatchEvent(new MessageEvent("message", {
284
295
  data: JSON.stringify({ eventType: e, eventData: t }),
285
296
  // We specify window.parent to imitate the case, the parent iframe sent us this event.
286
297
  source: window.parent
287
298
  }));
288
299
  }
289
- function Kt() {
300
+ function ne() {
290
301
  [
291
302
  ["TelegramGameProxy_receiveEvent"],
292
303
  // Windows Phone.
@@ -298,16 +309,14 @@ function Kt() {
298
309
  let t = window;
299
310
  e.forEach((s, n, r) => {
300
311
  if (n === r.length - 1) {
301
- t[s] = Zt;
312
+ t[s] = z;
302
313
  return;
303
314
  }
304
315
  s in t || (t[s] = {}), t = t[s];
305
316
  });
306
317
  });
307
318
  }
308
- const Xt = d({
309
- button_id: (e) => e == null ? void 0 : h().parse(e)
310
- }), te = {
319
+ const re = {
311
320
  clipboard_text_received: d({
312
321
  req_id: h(),
313
322
  data: (e) => e === null ? e : h().optional().parse(e)
@@ -317,48 +326,45 @@ const Xt = d({
317
326
  result: (e) => e,
318
327
  error: h().optional()
319
328
  }),
320
- invoice_closed: d({
321
- slug: h(),
322
- status: h()
323
- }),
324
- phone_requested: d({
325
- status: h()
326
- }),
329
+ invoice_closed: d({ slug: h(), status: h() }),
330
+ phone_requested: d({ status: h() }),
327
331
  popup_closed: {
328
- parse: (e) => Xt.parse(e ?? {})
332
+ parse(e) {
333
+ return d({
334
+ button_id: (t) => t == null ? void 0 : h().parse(t)
335
+ }).parse(e ?? {});
336
+ }
329
337
  },
330
- qr_text_received: d({
331
- data: h().optional()
332
- }),
338
+ qr_text_received: d({ data: h().optional() }),
333
339
  theme_changed: d({
334
340
  theme_params: (e) => {
335
- const t = pt().optional();
336
- return Object.entries(J(e)).reduce((s, [n, r]) => (s[n] = t.parse(r), s), {});
341
+ const t = dt().optional();
342
+ return Object.entries(Q(e)).reduce((s, [n, r]) => (s[n] = t.parse(r), s), {});
337
343
  }
338
344
  }),
339
345
  viewport_changed: d({
340
346
  height: y(),
341
347
  width: (e) => e == null ? window.innerWidth : y().parse(e),
342
- is_state_stable: w(),
343
- is_expanded: w()
348
+ is_state_stable: b(),
349
+ is_expanded: b()
344
350
  }),
345
- write_access_requested: d({
346
- status: h()
347
- })
351
+ write_access_requested: d({ status: h() })
348
352
  };
349
- function ee() {
350
- const e = new D();
351
- Kt();
352
- let t = [
353
+ function ie() {
354
+ const e = new T(), t = new T();
355
+ t.subscribe((n) => {
356
+ e.emit("event", { name: n.event, payload: n.args[0] });
357
+ }), ne();
358
+ const [, s] = ht(
353
359
  // Don't forget to remove created handlers.
354
- Yt,
360
+ se,
355
361
  // Add "resize" event listener to make sure, we always have fresh viewport information.
356
362
  // Desktop version of Telegram is sometimes not sending the viewport_changed
357
363
  // event. For example, when the MainButton is shown. That's why we should
358
364
  // add our own listener to make sure, viewport information is always fresh.
359
365
  // Issue: https://github.com/Telegram-Mini-Apps/tma.js/issues/10
360
366
  j("resize", () => {
361
- e.emit("viewport_changed", {
367
+ t.emit("viewport_changed", {
362
368
  width: window.innerWidth,
363
369
  height: window.innerHeight,
364
370
  is_state_stable: !0,
@@ -367,37 +373,48 @@ function ee() {
367
373
  }),
368
374
  // Add listener, which handles events sent from the Telegram web application and also events
369
375
  // generated by the local emitEvent function.
370
- j("message", (s) => {
371
- if (s.source !== window.parent)
376
+ j("message", (n) => {
377
+ if (n.source !== window.parent)
372
378
  return;
373
- let n;
379
+ let r;
374
380
  try {
375
- n = Qt(s.data);
381
+ r = _t(n.data);
376
382
  } catch {
377
383
  return;
378
384
  }
379
- const { eventType: r, eventData: i } = n, a = te[r];
385
+ const { eventType: i, eventData: a } = r, o = re[i];
380
386
  try {
381
- const o = a ? a.parse(i) : i;
382
- e.emit(...o ? [r, o] : [r]);
383
- } catch (o) {
384
- F.error(
385
- `An error occurred processing the "${r}" event from the Telegram application. Please, file an issue here: https://github.com/Telegram-Mini-Apps/tma.js/issues/new/choose`,
386
- n,
387
- o
387
+ const p = o ? o.parse(a) : a;
388
+ t.emit(...p ? [i, p] : [i]);
389
+ } catch (p) {
390
+ J.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`,
392
+ r,
393
+ p
388
394
  );
389
395
  }
390
396
  }),
391
- // Clear emitter bound events.
392
- () => e.clear()
393
- ];
394
- return [e, () => {
395
- t.forEach((s) => s()), t = [];
396
- }];
397
+ // Clear emitters.
398
+ () => e.clear(),
399
+ () => t.clear()
400
+ );
401
+ return [{
402
+ on: t.on.bind(t),
403
+ off: t.off.bind(t),
404
+ subscribe(n) {
405
+ return e.on("event", n);
406
+ },
407
+ unsubscribe(n) {
408
+ e.off("event", n);
409
+ },
410
+ get count() {
411
+ return t.count + e.count;
412
+ }
413
+ }, s];
397
414
  }
398
- const [se, ne] = it(
415
+ const [oe, ae] = at(
399
416
  (e) => {
400
- const [t, s] = ee(), n = t.off.bind(t);
417
+ const [t, s] = ie(), n = t.off.bind(t);
401
418
  return t.off = (r, i) => {
402
419
  const { count: a } = t;
403
420
  n(r, i), a && !t.count && e();
@@ -405,19 +422,19 @@ const [se, ne] = it(
405
422
  },
406
423
  ([, e]) => e()
407
424
  );
408
- function M() {
409
- return se()[0];
425
+ function $() {
426
+ return oe()[0];
410
427
  }
411
428
  function L(e, t) {
412
- M().off(e, t);
429
+ $().off(e, t);
413
430
  }
414
- function b(e, t, s) {
415
- return M().on(e, t, s);
431
+ function w(e, t, s) {
432
+ return $().on(e, t, s);
416
433
  }
417
- function T(e) {
434
+ function I(e) {
418
435
  return typeof e == "object" && e !== null && !Array.isArray(e);
419
436
  }
420
- function re(e, t) {
437
+ function ce(e, t) {
421
438
  const s = e.split("."), n = t.split("."), r = Math.max(s.length, n.length);
422
439
  for (let i = 0; i < r; i += 1) {
423
440
  const a = parseInt(s[i] || "0", 10), o = parseInt(n[i] || "0", 10);
@@ -427,7 +444,7 @@ function re(e, t) {
427
444
  return 0;
428
445
  }
429
446
  function g(e, t) {
430
- return re(e, t) <= 0;
447
+ return ce(e, t) <= 0;
431
448
  }
432
449
  function v(e, t, s) {
433
450
  if (typeof s == "string") {
@@ -480,74 +497,74 @@ function v(e, t, s) {
480
497
  ].includes(e);
481
498
  }
482
499
  }
483
- function ie(e) {
484
- return "external" in e && T(e.external) && "notify" in e.external && typeof e.external.notify == "function";
500
+ function ft(e) {
501
+ return "external" in e && I(e.external) && "notify" in e.external && typeof e.external.notify == "function";
485
502
  }
486
- function ut(e) {
487
- return "TelegramWebviewProxy" in e && T(e.TelegramWebviewProxy) && "postEvent" in e.TelegramWebviewProxy && typeof e.TelegramWebviewProxy.postEvent == "function";
503
+ function gt(e) {
504
+ return "TelegramWebviewProxy" in e && I(e.TelegramWebviewProxy) && "postEvent" in e.TelegramWebviewProxy && typeof e.TelegramWebviewProxy.postEvent == "function";
488
505
  }
489
- function oe() {
506
+ function wt() {
490
507
  try {
491
508
  return window.self !== window.top;
492
509
  } catch {
493
510
  return !0;
494
511
  }
495
512
  }
496
- let lt = "https://web.telegram.org";
497
- function ts(e) {
498
- lt = e;
513
+ let bt = "https://web.telegram.org";
514
+ function Xe(e) {
515
+ bt = e;
499
516
  }
500
- function ae() {
501
- return lt;
517
+ function he() {
518
+ return bt;
502
519
  }
503
520
  function R(e, t, s) {
504
521
  let n = {}, r;
505
522
  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);
506
- const { targetOrigin: i = ae() } = n;
507
- if (Lt("Posting event:", r ? { event: e, data: r } : { event: e }), oe()) {
523
+ const { targetOrigin: i = he() } = n;
524
+ if (jt("Posting event:", r ? { event: e, data: r } : { event: e }), wt()) {
508
525
  window.parent.postMessage(JSON.stringify({ eventType: e, eventData: r }), i);
509
526
  return;
510
527
  }
511
- if (ie(window)) {
528
+ if (ft(window)) {
512
529
  window.external.notify(JSON.stringify({ eventType: e, eventData: r }));
513
530
  return;
514
531
  }
515
- if (ut(window)) {
532
+ if (gt(window)) {
516
533
  window.TelegramWebviewProxy.postEvent(e, JSON.stringify(r));
517
534
  return;
518
535
  }
519
536
  throw f(
520
- Ut,
537
+ Jt,
521
538
  "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."
522
539
  );
523
540
  }
524
- function ce(e) {
541
+ function pe(e) {
525
542
  return (t, s) => {
526
543
  if (!v(t, e))
527
- throw f(Bt, `Method "${t}" is unsupported in Mini Apps version ${e}`);
528
- if (T(s)) {
544
+ throw f(zt, `Method "${t}" is unsupported in Mini Apps version ${e}`);
545
+ if (I(s)) {
529
546
  let n;
530
547
  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))
531
548
  throw f(
532
- Ot,
549
+ Ft,
533
550
  `Parameter "${n}" of "${t}" method is unsupported in Mini Apps version ${e}`
534
551
  );
535
552
  }
536
553
  return R(t, s);
537
554
  };
538
555
  }
539
- function dt(e) {
556
+ function mt(e) {
540
557
  return ({ req_id: t }) => t === e;
541
558
  }
542
- function _t(e) {
543
- return f(Ht, `Timeout reached: ${e}ms`);
559
+ function yt(e) {
560
+ return f(Yt, `Timeout reached: ${e}ms`);
544
561
  }
545
- function ft(e, t) {
562
+ function vt(e, t) {
546
563
  return Promise.race([
547
564
  typeof e == "function" ? e() : e,
548
565
  new Promise((s, n) => {
549
566
  setTimeout(() => {
550
- n(_t(t));
567
+ n(yt(t));
551
568
  }, t);
552
569
  })
553
570
  ]);
@@ -563,15 +580,15 @@ async function _(e) {
563
580
  postEvent: a = R,
564
581
  timeout: o
565
582
  } = e, p = (Array.isArray(r) ? r : [r]).map(
566
- (u) => b(u, (q) => (!i || i(q)) && t(q))
583
+ (u) => w(u, (k) => (!i || i(k)) && t(k))
567
584
  );
568
585
  try {
569
- return a(n, e.params), await (o ? ft(s, o) : s);
586
+ return a(n, e.params), await (o ? vt(s, o) : s);
570
587
  } finally {
571
588
  p.forEach((u) => u());
572
589
  }
573
590
  }
574
- async function C(e, t, s, n = {}) {
591
+ async function S(e, t, s, n = {}) {
575
592
  const {
576
593
  result: r,
577
594
  error: i
@@ -584,30 +601,30 @@ async function C(e, t, s, n = {}) {
584
601
  params: t,
585
602
  req_id: s
586
603
  },
587
- capture: dt(s)
604
+ capture: mt(s)
588
605
  });
589
606
  if (i)
590
- throw f(Wt, i);
607
+ throw f(Qt, i);
591
608
  return r;
592
609
  }
593
- function z(...e) {
610
+ function F(...e) {
594
611
  return e.map((t) => {
595
612
  if (typeof t == "string")
596
613
  return t;
597
- if (T(t))
598
- return z(Object.entries(t).map((s) => s[1] && s[0]));
614
+ if (I(t))
615
+ return F(Object.entries(t).map((s) => s[1] && s[0]));
599
616
  if (Array.isArray(t))
600
- return z(...t);
617
+ return F(...t);
601
618
  }).filter(Boolean).join(" ");
602
619
  }
603
- function es(...e) {
604
- return e.reduce((t, s) => (T(s) && Object.entries(s).forEach(([n, r]) => {
605
- const i = z(t[n], r);
620
+ function ts(...e) {
621
+ return e.reduce((t, s) => (I(s) && Object.entries(s).forEach(([n, r]) => {
622
+ const i = F(t[n], r);
606
623
  i.length && (t[n] = i);
607
624
  }), t), {});
608
625
  }
609
- function gt(e) {
610
- const t = ht(e);
626
+ function Et(e) {
627
+ const t = lt(e);
611
628
  return Math.sqrt(
612
629
  [0.299, 0.587, 0.114].reduce((s, n, r) => {
613
630
  const i = parseInt(t.slice(1 + r * 2, 1 + (r + 1) * 2), 16);
@@ -615,9 +632,9 @@ function gt(e) {
615
632
  }, 0)
616
633
  ) < 120;
617
634
  }
618
- class he {
635
+ class ue {
619
636
  constructor(t) {
620
- c(this, "ee", new D());
637
+ c(this, "ee", new T());
621
638
  /**
622
639
  * Adds new event listener.
623
640
  */
@@ -645,7 +662,7 @@ class he {
645
662
  return this.state[t];
646
663
  }
647
664
  }
648
- class Y {
665
+ class Z {
649
666
  constructor(t) {
650
667
  c(this, "state");
651
668
  /**
@@ -660,23 +677,23 @@ class Y {
660
677
  * Clones the current state.
661
678
  */
662
679
  c(this, "clone");
663
- this.state = new he(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);
680
+ 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);
664
681
  }
665
682
  }
666
- function bt(e, t) {
683
+ function Pt(e, t) {
667
684
  return (s) => v(t[s], e);
668
685
  }
669
- class Z extends Y {
686
+ class K extends Z {
670
687
  constructor(s, n, r) {
671
688
  super(s);
672
689
  /**
673
690
  * @returns True, if specified method is supported by the current component.
674
691
  */
675
692
  c(this, "supports");
676
- this.supports = bt(n, r);
693
+ this.supports = Pt(n, r);
677
694
  }
678
695
  }
679
- class pe extends Z {
696
+ class le extends K {
680
697
  constructor(s, n, r) {
681
698
  super({ isVisible: s }, n, {
682
699
  show: "web_app_setup_back_button",
@@ -687,7 +704,7 @@ class pe extends Z {
687
704
  * @param event - event to listen.
688
705
  * @param listener - listener to add.
689
706
  */
690
- c(this, "on", (s, n) => s === "click" ? b("back_button_pressed", n) : this.state.on(s, n));
707
+ c(this, "on", (s, n) => s === "click" ? w("back_button_pressed", n) : this.state.on(s, n));
691
708
  /**
692
709
  * Removes the event listener.
693
710
  * @param event - event to listen.
@@ -718,19 +735,19 @@ class pe extends Z {
718
735
  this.isVisible = !0;
719
736
  }
720
737
  }
721
- const wt = P((e) => e instanceof Date ? e : new Date(y().parse(e) * 1e3), "Date");
722
- function K(e, t) {
723
- return new $((s) => {
738
+ const xt = P((e) => e instanceof Date ? e : new Date(y().parse(e) * 1e3), "Date");
739
+ function X(e, t) {
740
+ return new M((s) => {
724
741
  if (typeof s != "string" && !(s instanceof URLSearchParams))
725
742
  throw E();
726
743
  const n = typeof s == "string" ? new URLSearchParams(s) : s;
727
- return ct(e, (r) => {
744
+ return ut(e, (r) => {
728
745
  const i = n.get(r);
729
746
  return i === null ? void 0 : i;
730
747
  });
731
748
  }, !1, t);
732
749
  }
733
- const ue = d({
750
+ const de = d({
734
751
  id: y(),
735
752
  type: h(),
736
753
  title: h(),
@@ -739,13 +756,13 @@ const ue = d({
739
756
  from: "photo_url"
740
757
  },
741
758
  username: h().optional()
742
- }, "Chat").optional(), st = d({
759
+ }, "Chat").optional(), rt = d({
743
760
  addedToAttachmentMenu: {
744
- type: w().optional(),
761
+ type: b().optional(),
745
762
  from: "added_to_attachment_menu"
746
763
  },
747
764
  allowsWriteToPm: {
748
- type: w().optional(),
765
+ type: b().optional(),
749
766
  from: "allows_write_to_pm"
750
767
  },
751
768
  firstName: {
@@ -754,11 +771,11 @@ const ue = d({
754
771
  },
755
772
  id: y(),
756
773
  isBot: {
757
- type: w().optional(),
774
+ type: b().optional(),
758
775
  from: "is_bot"
759
776
  },
760
777
  isPremium: {
761
- type: w().optional(),
778
+ type: b().optional(),
762
779
  from: "is_premium"
763
780
  },
764
781
  languageCode: {
@@ -775,17 +792,17 @@ const ue = d({
775
792
  },
776
793
  username: h().optional()
777
794
  }, "User").optional();
778
- function mt() {
779
- return K({
795
+ function St() {
796
+ return X({
780
797
  authDate: {
781
- type: wt(),
798
+ type: xt(),
782
799
  from: "auth_date"
783
800
  },
784
801
  canSendAfter: {
785
802
  type: y().optional(),
786
803
  from: "can_send_after"
787
804
  },
788
- chat: ue,
805
+ chat: de,
789
806
  chatInstance: {
790
807
  type: h().optional(),
791
808
  from: "chat_instance"
@@ -799,35 +816,35 @@ function mt() {
799
816
  type: h().optional(),
800
817
  from: "query_id"
801
818
  },
802
- receiver: st,
819
+ receiver: rt,
803
820
  startParam: {
804
821
  type: h().optional(),
805
822
  from: "start_param"
806
823
  },
807
- user: st
824
+ user: rt
808
825
  }, "InitData");
809
826
  }
810
- function le(e) {
827
+ function _e(e) {
811
828
  return e.replace(/_[a-z]/g, (t) => t[1].toUpperCase());
812
829
  }
813
- function de(e) {
830
+ function fe(e) {
814
831
  return e.replace(/[A-Z]/g, (t) => `_${t.toLowerCase()}`);
815
832
  }
816
- const yt = P(
833
+ const Ct = P(
817
834
  (e) => {
818
- const t = pt().optional();
819
- return Object.entries(J(e)).reduce((s, [n, r]) => (s[le(n)] = t.parse(r), s), {});
835
+ const t = dt().optional();
836
+ return Object.entries(Q(e)).reduce((s, [n, r]) => (s[_e(n)] = t.parse(r), s), {});
820
837
  },
821
838
  "ThemeParams"
822
839
  );
823
- function vt(e) {
824
- return K({
840
+ function tt(e) {
841
+ return X({
825
842
  botInline: {
826
- type: w().optional(),
843
+ type: b().optional(),
827
844
  from: "tgWebAppBotInline"
828
845
  },
829
846
  initData: {
830
- type: mt().optional(),
847
+ type: St().optional(),
831
848
  from: "tgWebAppData"
832
849
  },
833
850
  initDataRaw: {
@@ -839,7 +856,7 @@ function vt(e) {
839
856
  from: "tgWebAppPlatform"
840
857
  },
841
858
  showSettings: {
842
- type: w().optional(),
859
+ type: b().optional(),
843
860
  from: "tgWebAppShowSettings"
844
861
  },
845
862
  startParam: {
@@ -847,7 +864,7 @@ function vt(e) {
847
864
  from: "tgWebAppStartParam"
848
865
  },
849
866
  themeParams: {
850
- type: yt(),
867
+ type: Ct(),
851
868
  from: "tgWebAppThemeParams"
852
869
  },
853
870
  version: {
@@ -856,47 +873,47 @@ function vt(e) {
856
873
  }
857
874
  }).parse(e);
858
875
  }
859
- function Et(e) {
860
- return vt(
876
+ function Tt(e) {
877
+ return tt(
861
878
  e.replace(/^[^?#]*[?#]/, "").replace(/[?#]/g, "&")
862
879
  );
863
880
  }
864
- function _e() {
865
- return Et(window.location.href);
881
+ function ge() {
882
+ return Tt(window.location.href);
866
883
  }
867
- function Pt() {
884
+ function Rt() {
868
885
  return performance.getEntriesByType("navigation")[0];
869
886
  }
870
- function fe() {
871
- const e = Pt();
887
+ function we() {
888
+ const e = Rt();
872
889
  if (!e)
873
890
  throw new Error("Unable to get first navigation entry.");
874
- return Et(e.name);
891
+ return Tt(e.name);
875
892
  }
876
- function xt(e) {
893
+ function At(e) {
877
894
  return `tma.js/${e.replace(/[A-Z]/g, (t) => `-${t.toLowerCase()}`)}`;
878
895
  }
879
- function Ct(e, t) {
880
- sessionStorage.setItem(xt(e), JSON.stringify(t));
896
+ function It(e, t) {
897
+ sessionStorage.setItem(At(e), JSON.stringify(t));
881
898
  }
882
- function St(e) {
883
- const t = sessionStorage.getItem(xt(e));
899
+ function qt(e) {
900
+ const t = sessionStorage.getItem(At(e));
884
901
  try {
885
902
  return t ? JSON.parse(t) : void 0;
886
903
  } catch {
887
904
  }
888
905
  }
889
- function ge() {
890
- return vt(St("launchParams") || "");
906
+ function be() {
907
+ return tt(qt("launchParams") || "");
891
908
  }
892
- function be(e) {
909
+ function kt(e) {
893
910
  return JSON.stringify(
894
911
  Object.fromEntries(
895
- Object.entries(e).map(([t, s]) => [de(t), s])
912
+ Object.entries(e).map(([t, s]) => [fe(t), s])
896
913
  )
897
914
  );
898
915
  }
899
- function we(e) {
916
+ function me(e) {
900
917
  const {
901
918
  initDataRaw: t,
902
919
  themeParams: s,
@@ -906,67 +923,56 @@ function we(e) {
906
923
  startParam: a,
907
924
  botInline: o
908
925
  } = e, p = new URLSearchParams();
909
- return p.set("tgWebAppPlatform", n), p.set("tgWebAppThemeParams", be(s)), p.set("tgWebAppVersion", r), t && p.set("tgWebAppData", t), a && p.set("tgWebAppStartParam", a), typeof i == "boolean" && p.set("tgWebAppShowSettings", i ? "1" : "0"), typeof o == "boolean" && p.set("tgWebAppBotInline", o ? "1" : "0"), p.toString();
926
+ return p.set("tgWebAppPlatform", n), p.set("tgWebAppThemeParams", kt(s)), p.set("tgWebAppVersion", r), t && p.set("tgWebAppData", t), a && p.set("tgWebAppStartParam", a), typeof i == "boolean" && p.set("tgWebAppShowSettings", i ? "1" : "0"), typeof o == "boolean" && p.set("tgWebAppBotInline", o ? "1" : "0"), p.toString();
910
927
  }
911
- function me(e) {
912
- Ct("launchParams", we(e));
928
+ function Nt(e) {
929
+ It("launchParams", me(e));
913
930
  }
914
931
  function ye() {
915
932
  for (const e of [
916
933
  // Try to retrieve launch parameters from the current location. This method can return
917
934
  // nothing in case, location was changed and then page was reloaded.
918
- _e,
935
+ ge,
919
936
  // Then, try using the lower level API - window.performance.
920
- fe,
937
+ we,
921
938
  // Finally, try to extract launch parameters from the session storage.
922
- ge
939
+ be
923
940
  ])
924
941
  try {
925
942
  const t = e();
926
- return me(t), t;
943
+ return Nt(t), t;
927
944
  } catch {
928
945
  }
929
946
  throw new Error("Unable to retrieve launch parameters from any known source.");
930
947
  }
931
- function Rt() {
932
- const e = Pt();
948
+ function Dt() {
949
+ const e = Rt();
933
950
  return !!(e && e.type === "reload");
934
951
  }
935
952
  function ve() {
936
953
  let e = 0;
937
954
  return () => (e += 1).toString();
938
955
  }
939
- function Ee() {
940
- let e = !1;
941
- const t = [];
942
- return [
943
- (s) => !e && t.push(s),
944
- () => {
945
- e || (e = !0, t.forEach((s) => s()));
946
- },
947
- e
948
- ];
949
- }
950
- const [Pe] = it(ve);
956
+ const [Ee] = at(ve);
951
957
  function l(e, t) {
952
958
  return () => {
953
959
  const s = ye(), n = {
954
960
  ...s,
955
- postEvent: ce(s.version),
956
- createRequestId: Pe()
961
+ postEvent: pe(s.version),
962
+ createRequestId: Ee()
957
963
  };
958
964
  if (typeof e == "function")
959
965
  return e(n);
960
- const [r, i, a] = Ee(), o = t({
966
+ const [r, i, a] = ht(), o = t({
961
967
  ...n,
962
968
  // State should only be passed only in case, current page was reloaded. If we don't add
963
969
  // this check, state restoration will work improperly in the web version of Telegram,
964
970
  // when we are always working in the same "session" (tab).
965
- state: Rt() ? St(e) : void 0,
971
+ state: Dt() ? qt(e) : void 0,
966
972
  addCleanup: r
967
973
  }), p = (u) => (a || r(
968
- u.on("change", (q) => {
969
- Ct(e, q);
974
+ u.on("change", (k) => {
975
+ It(e, k);
970
976
  })
971
977
  ), u);
972
978
  return [
@@ -975,12 +981,12 @@ function l(e, t) {
975
981
  ];
976
982
  };
977
983
  }
978
- const ss = l("backButton", ({
984
+ const es = l("backButton", ({
979
985
  postEvent: e,
980
986
  version: t,
981
987
  state: s = { isVisible: !1 }
982
- }) => new pe(s.isVisible, t, e));
983
- class I extends Z {
988
+ }) => new le(s.isVisible, t, e));
989
+ class q extends K {
984
990
  constructor() {
985
991
  super(...arguments);
986
992
  /**
@@ -993,7 +999,7 @@ class I extends Z {
993
999
  c(this, "off", this.state.off.bind(this.state));
994
1000
  }
995
1001
  }
996
- function At(e) {
1002
+ function Vt(e) {
997
1003
  const t = e.available ? e : {
998
1004
  available: !1,
999
1005
  device_id: "",
@@ -1011,7 +1017,7 @@ function At(e) {
1011
1017
  accessGranted: t.access_granted
1012
1018
  };
1013
1019
  }
1014
- class xe extends I {
1020
+ class Pe extends q {
1015
1021
  constructor({ postEvent: s, version: n, ...r }) {
1016
1022
  super(r, n, {
1017
1023
  auth: "web_app_biometry_request_auth",
@@ -1093,7 +1099,7 @@ class xe extends I {
1093
1099
  event: "biometry_info_received",
1094
1100
  params: { reason: s || "" }
1095
1101
  }).then((r) => {
1096
- const i = At(r);
1102
+ const i = Vt(r);
1097
1103
  return this.set(i), i.accessGranted;
1098
1104
  }).finally(() => this.accessPromise = void 0)), this.accessPromise;
1099
1105
  }
@@ -1125,8 +1131,8 @@ class xe extends I {
1125
1131
  );
1126
1132
  }
1127
1133
  }
1128
- async function Ce(e) {
1129
- return At(
1134
+ async function xe(e) {
1135
+ return Vt(
1130
1136
  await _({
1131
1137
  ...e || {},
1132
1138
  method: "web_app_biometry_get_info",
@@ -1134,15 +1140,21 @@ async function Ce(e) {
1134
1140
  })
1135
1141
  );
1136
1142
  }
1137
- const ns = l(
1143
+ const ss = l(
1138
1144
  "biometryManager",
1139
- async ({ postEvent: e, version: t, state: s }) => new xe({
1140
- ...s || await Ce({ timeout: 1e3 }),
1145
+ async ({ postEvent: e, version: t, state: s }) => new Pe({
1146
+ ...s || v("web_app_biometry_get_info", t) ? s || await xe({ timeout: 1e3 }) : {
1147
+ available: !1,
1148
+ accessGranted: !1,
1149
+ accessRequested: !1,
1150
+ tokenSaved: !1,
1151
+ deviceId: ""
1152
+ },
1141
1153
  version: t,
1142
1154
  postEvent: e
1143
1155
  })
1144
1156
  );
1145
- class X extends Y {
1157
+ class et extends Z {
1146
1158
  constructor() {
1147
1159
  super(...arguments);
1148
1160
  /**
@@ -1155,7 +1167,7 @@ class X extends Y {
1155
1167
  c(this, "off", this.state.off.bind(this.state));
1156
1168
  }
1157
1169
  }
1158
- class Se extends X {
1170
+ class Se extends et {
1159
1171
  constructor(t, s) {
1160
1172
  super({ isConfirmationNeeded: t }), this.postEvent = s;
1161
1173
  }
@@ -1182,23 +1194,23 @@ class Se extends X {
1182
1194
  this.isConfirmationNeeded = !0;
1183
1195
  }
1184
1196
  }
1185
- const rs = l(
1197
+ const ns = l(
1186
1198
  "closingBehavior",
1187
1199
  ({
1188
1200
  postEvent: e,
1189
1201
  state: t = { isConfirmationNeeded: !1 }
1190
1202
  }) => new Se(t.isConfirmationNeeded, e)
1191
1203
  );
1192
- class tt {
1204
+ class st {
1193
1205
  constructor(t, s) {
1194
1206
  /**
1195
1207
  * @returns True, if specified method is supported by the current component.
1196
1208
  */
1197
1209
  c(this, "supports");
1198
- this.supports = bt(t, s);
1210
+ this.supports = Pt(t, s);
1199
1211
  }
1200
1212
  }
1201
- function Re(e) {
1213
+ function Ce(e) {
1202
1214
  if (Array.isArray(e))
1203
1215
  return e;
1204
1216
  if (typeof e == "string")
@@ -1210,9 +1222,9 @@ function Re(e) {
1210
1222
  }
1211
1223
  throw E();
1212
1224
  }
1213
- class Ae extends $ {
1225
+ class Te extends M {
1214
1226
  constructor(s, n, r) {
1215
- super(Re, n, r);
1227
+ super(Ce, n, r);
1216
1228
  c(this, "itemParser");
1217
1229
  this.itemParser = typeof s == "function" ? s : s.parse.bind(s);
1218
1230
  }
@@ -1230,13 +1242,13 @@ class Ae extends $ {
1230
1242
  return this.itemParser = typeof s == "function" ? s : s.parse.bind(s), this;
1231
1243
  }
1232
1244
  }
1233
- function Te(e) {
1234
- return new Ae((t) => t, !1, e);
1245
+ function Re(e) {
1246
+ return new Te((t) => t, !1, e);
1235
1247
  }
1236
- function nt(e, t) {
1248
+ function it(e, t) {
1237
1249
  return Object.fromEntries(e.map((s) => [s, t]));
1238
1250
  }
1239
- class Ie extends tt {
1251
+ class Ae extends st {
1240
1252
  constructor(t, s, n) {
1241
1253
  super(t, {
1242
1254
  delete: "web_app_invoke_custom_method",
@@ -1252,7 +1264,7 @@ class Ie extends tt {
1252
1264
  */
1253
1265
  async delete(t, s = {}) {
1254
1266
  const n = Array.isArray(t) ? t : [t];
1255
- n.length && await C(
1267
+ n.length && await S(
1256
1268
  "deleteStorageValues",
1257
1269
  { keys: n },
1258
1270
  this.createRequestId(),
@@ -1264,8 +1276,8 @@ class Ie extends tt {
1264
1276
  * @param options - request execution options.
1265
1277
  */
1266
1278
  async getKeys(t = {}) {
1267
- return Te().of(h()).parse(
1268
- await C(
1279
+ return Re().of(h()).parse(
1280
+ await S(
1269
1281
  "getStorageKeys",
1270
1282
  {},
1271
1283
  this.createRequestId(),
@@ -1276,13 +1288,13 @@ class Ie extends tt {
1276
1288
  async get(t, s = {}) {
1277
1289
  const n = Array.isArray(t) ? t : [t];
1278
1290
  if (!n.length)
1279
- return nt(n, "");
1280
- const r = await C(
1291
+ return it(n, "");
1292
+ const r = await S(
1281
1293
  "getStorageValues",
1282
1294
  { keys: n },
1283
1295
  this.createRequestId(),
1284
1296
  { ...s, postEvent: this.postEvent }
1285
- ), i = d(nt(n, h()), "CloudStorageData").parse(r);
1297
+ ), i = d(it(n, h()), "CloudStorageData").parse(r);
1286
1298
  return Array.isArray(t) ? i : i[t];
1287
1299
  }
1288
1300
  /**
@@ -1292,7 +1304,7 @@ class Ie extends tt {
1292
1304
  * @param options - request execution options.
1293
1305
  */
1294
1306
  async set(t, s, n = {}) {
1295
- await C(
1307
+ await S(
1296
1308
  "saveStorageValue",
1297
1309
  { key: t, value: s },
1298
1310
  this.createRequestId(),
@@ -1300,10 +1312,10 @@ class Ie extends tt {
1300
1312
  );
1301
1313
  }
1302
1314
  }
1303
- const is = l(
1304
- ({ createRequestId: e, postEvent: t, version: s }) => new Ie(s, e, t)
1315
+ const rs = l(
1316
+ ({ createRequestId: e, postEvent: t, version: s }) => new Ae(s, e, t)
1305
1317
  );
1306
- class qe extends tt {
1318
+ class Ie extends st {
1307
1319
  constructor(t, s) {
1308
1320
  super(t, {
1309
1321
  impactOccurred: "web_app_trigger_haptic_feedback",
@@ -1345,10 +1357,10 @@ class qe extends tt {
1345
1357
  this.postEvent("web_app_trigger_haptic_feedback", { type: "selection_change" });
1346
1358
  }
1347
1359
  }
1348
- const os = l(
1349
- ({ version: e, postEvent: t }) => new qe(e, t)
1360
+ const is = l(
1361
+ ({ version: e, postEvent: t }) => new Ie(e, t)
1350
1362
  );
1351
- class ke {
1363
+ class qe {
1352
1364
  constructor(t) {
1353
1365
  this.initData = t;
1354
1366
  }
@@ -1421,13 +1433,13 @@ class ke {
1421
1433
  return this.initData.user;
1422
1434
  }
1423
1435
  }
1424
- const as = l(
1425
- ({ initData: e }) => e ? new ke(e) : void 0
1436
+ const os = l(
1437
+ ({ initData: e }) => e ? new qe(e) : void 0
1426
1438
  );
1427
- function cs(e) {
1428
- return mt().parse(e);
1439
+ function as(e) {
1440
+ return St().parse(e);
1429
1441
  }
1430
- class Ne extends I {
1442
+ class ke extends q {
1431
1443
  constructor(t, s, n) {
1432
1444
  super({ isOpened: t }, s, { open: "web_app_open_invoice" }), this.postEvent = n;
1433
1445
  }
@@ -1471,10 +1483,10 @@ class Ne extends I {
1471
1483
  }
1472
1484
  }
1473
1485
  }
1474
- const hs = l(
1475
- ({ version: e, postEvent: t }) => new Ne(!1, e, t)
1486
+ const cs = l(
1487
+ ({ version: e, postEvent: t }) => new ke(!1, e, t)
1476
1488
  );
1477
- class De extends Y {
1489
+ class Ne extends Z {
1478
1490
  constructor({ postEvent: s, ...n }) {
1479
1491
  super(n);
1480
1492
  c(this, "postEvent");
@@ -1483,7 +1495,7 @@ class De extends Y {
1483
1495
  * @param event - event to listen.
1484
1496
  * @param listener - listener to add.
1485
1497
  */
1486
- c(this, "on", (s, n) => s === "click" ? b("main_button_pressed", n) : this.state.on(s, n));
1498
+ c(this, "on", (s, n) => s === "click" ? w("main_button_pressed", n) : this.state.on(s, n));
1487
1499
  /**
1488
1500
  * Removes the event listener.
1489
1501
  * @param event - event to listen.
@@ -1492,6 +1504,12 @@ class De extends Y {
1492
1504
  c(this, "off", (s, n) => s === "click" ? L("main_button_pressed", n) : this.state.off(s, n));
1493
1505
  this.postEvent = s;
1494
1506
  }
1507
+ /**
1508
+ * The MainButton background color.
1509
+ */
1510
+ get bgColor() {
1511
+ return this.get("bgColor");
1512
+ }
1495
1513
  /**
1496
1514
  * Sends current local state to the Telegram application.
1497
1515
  */
@@ -1501,10 +1519,35 @@ class De extends Y {
1501
1519
  is_active: this.isEnabled,
1502
1520
  is_progress_visible: this.isLoaderVisible,
1503
1521
  text: this.text,
1504
- color: this.backgroundColor,
1522
+ color: this.bgColor,
1505
1523
  text_color: this.textColor
1506
1524
  });
1507
1525
  }
1526
+ /**
1527
+ * Disables the MainButton.
1528
+ * @see Does not work on Android: https://github.com/Telegram-Mini-Apps/issues/issues/1
1529
+ */
1530
+ disable() {
1531
+ return this.isEnabled = !1, this;
1532
+ }
1533
+ /**
1534
+ * Enables the MainButton.
1535
+ */
1536
+ enable() {
1537
+ return this.isEnabled = !0, this;
1538
+ }
1539
+ /**
1540
+ * Hides the MainButton.
1541
+ */
1542
+ hide() {
1543
+ return this.isVisible = !1, this;
1544
+ }
1545
+ /**
1546
+ * Hides the MainButton loading indicator.
1547
+ */
1548
+ hideLoader() {
1549
+ return this.isLoaderVisible = !1, this;
1550
+ }
1508
1551
  set isEnabled(s) {
1509
1552
  this.setParams({ isEnabled: s });
1510
1553
  }
@@ -1532,49 +1575,6 @@ class De extends Y {
1532
1575
  get isVisible() {
1533
1576
  return this.get("isVisible");
1534
1577
  }
1535
- /**
1536
- * The MainButton background color.
1537
- */
1538
- get backgroundColor() {
1539
- return this.get("backgroundColor");
1540
- }
1541
- /**
1542
- * The MainButton text.
1543
- */
1544
- get text() {
1545
- return this.get("text");
1546
- }
1547
- /**
1548
- * The MainButton text color.
1549
- */
1550
- get textColor() {
1551
- return this.get("textColor");
1552
- }
1553
- /**
1554
- * Disables the MainButton.
1555
- * @see Does not work on Android: https://github.com/Telegram-Mini-Apps/issues/issues/1
1556
- */
1557
- disable() {
1558
- return this.isEnabled = !1, this;
1559
- }
1560
- /**
1561
- * Enables the MainButton.
1562
- */
1563
- enable() {
1564
- return this.isEnabled = !0, this;
1565
- }
1566
- /**
1567
- * Hides the MainButton.
1568
- */
1569
- hide() {
1570
- return this.isVisible = !1, this;
1571
- }
1572
- /**
1573
- * Hides the MainButton loading indicator.
1574
- */
1575
- hideLoader() {
1576
- return this.isLoaderVisible = !1, this;
1577
- }
1578
1578
  /**
1579
1579
  * Shows the MainButton.
1580
1580
  *
@@ -1606,10 +1606,10 @@ class De extends Y {
1606
1606
  }
1607
1607
  /**
1608
1608
  * Updates current Main Button color.
1609
- * @param backgroundColor - color to set.
1609
+ * @param bgColor - color to set.
1610
1610
  */
1611
- setBackgroundColor(s) {
1612
- return this.setParams({ backgroundColor: s });
1611
+ setBgColor(s) {
1612
+ return this.setParams({ bgColor: s });
1613
1613
  }
1614
1614
  /**
1615
1615
  * Allows setting multiple Main Button parameters.
@@ -1618,8 +1618,20 @@ class De extends Y {
1618
1618
  setParams(s) {
1619
1619
  return this.set(s), this.commit(), this;
1620
1620
  }
1621
+ /**
1622
+ * The MainButton text.
1623
+ */
1624
+ get text() {
1625
+ return this.get("text");
1626
+ }
1627
+ /**
1628
+ * The MainButton text color.
1629
+ */
1630
+ get textColor() {
1631
+ return this.get("textColor");
1632
+ }
1621
1633
  }
1622
- const ps = l(
1634
+ const hs = l(
1623
1635
  "mainButton",
1624
1636
  ({
1625
1637
  postEvent: e,
@@ -1630,12 +1642,12 @@ const ps = l(
1630
1642
  text: "",
1631
1643
  isLoaderVisible: !1,
1632
1644
  textColor: t.buttonTextColor || "#ffffff",
1633
- backgroundColor: t.buttonColor || "#000000"
1645
+ bgColor: t.buttonColor || "#000000"
1634
1646
  }
1635
- }) => new De({ ...s, postEvent: e })
1647
+ }) => new Ne({ ...s, postEvent: e })
1636
1648
  );
1637
- function Ve() {
1638
- return K({
1649
+ function De() {
1650
+ return X({
1639
1651
  contact: d({
1640
1652
  userId: {
1641
1653
  type: y(),
@@ -1655,24 +1667,24 @@ function Ve() {
1655
1667
  }
1656
1668
  }),
1657
1669
  authDate: {
1658
- type: wt(),
1670
+ type: xt(),
1659
1671
  from: "auth_date"
1660
1672
  },
1661
1673
  hash: h()
1662
1674
  }, "RequestedContact");
1663
1675
  }
1664
- function Tt(e, t) {
1676
+ function Mt(e, t) {
1665
1677
  return (s) => {
1666
1678
  const [n, r] = t[s];
1667
1679
  return v(n, r, e);
1668
1680
  };
1669
1681
  }
1670
- function $e(e) {
1682
+ function Ve(e) {
1671
1683
  return new Promise((t) => {
1672
1684
  setTimeout(t, e);
1673
1685
  });
1674
1686
  }
1675
- class Me extends I {
1687
+ class Me extends q {
1676
1688
  constructor({ postEvent: s, createRequestId: n, version: r, botInline: i, ...a }) {
1677
1689
  super(a, r, {
1678
1690
  requestPhoneAccess: "web_app_request_phone",
@@ -1692,7 +1704,7 @@ class Me extends I {
1692
1704
  c(this, "supportsParam");
1693
1705
  this.createRequestId = n, this.postEvent = s, this.botInline = i;
1694
1706
  const o = this.supports.bind(this);
1695
- this.supports = (p) => o(p) ? p !== "switchInlineQuery" || i : !1, this.supportsParam = Tt(r, {
1707
+ this.supports = (p) => o(p) ? p !== "switchInlineQuery" || i : !1, this.supportsParam = Mt(r, {
1696
1708
  "setHeaderColor.color": ["web_app_set_header_color", "color"]
1697
1709
  });
1698
1710
  }
@@ -1703,8 +1715,8 @@ class Me extends I {
1703
1715
  async getRequestedContact({
1704
1716
  timeout: s = 1e4
1705
1717
  } = {}) {
1706
- return Ve().parse(
1707
- await C(
1718
+ return De().parse(
1719
+ await S(
1708
1720
  "getRequestedContact",
1709
1721
  {},
1710
1722
  this.createRequestId(),
@@ -1743,7 +1755,7 @@ class Me extends I {
1743
1755
  * True if current Mini App background color is recognized as dark.
1744
1756
  */
1745
1757
  get isDark() {
1746
- return gt(this.bgColor);
1758
+ return Et(this.bgColor);
1747
1759
  }
1748
1760
  /**
1749
1761
  * Informs the Telegram app that the Mini App is ready to be displayed.
@@ -1772,15 +1784,15 @@ class Me extends I {
1772
1784
  throw new Error("Access denied.");
1773
1785
  const r = Date.now() + s;
1774
1786
  let i = 50;
1775
- return ft(async () => {
1787
+ return vt(async () => {
1776
1788
  for (; Date.now() < r; ) {
1777
1789
  try {
1778
1790
  return await this.getRequestedContact();
1779
1791
  } catch {
1780
1792
  }
1781
- await $e(i), i += 50;
1793
+ await Ve(i), i += 50;
1782
1794
  }
1783
- throw _t(s);
1795
+ throw yt(s);
1784
1796
  }, s);
1785
1797
  }
1786
1798
  /**
@@ -1835,7 +1847,7 @@ class Me extends I {
1835
1847
  * @param color - color key or RGB color.
1836
1848
  */
1837
1849
  setHeaderColor(s) {
1838
- this.postEvent("web_app_set_header_color", Q(s) ? { color: s } : { color_key: s }), this.set("headerColor", s);
1850
+ this.postEvent("web_app_set_header_color", Y(s) ? { color: s } : { color_key: s }), this.set("headerColor", s);
1839
1851
  }
1840
1852
  /**
1841
1853
  * Updates current Mini App background color.
@@ -1863,7 +1875,7 @@ class Me extends I {
1863
1875
  this.postEvent("web_app_switch_inline_query", { query: s, chat_types: n });
1864
1876
  }
1865
1877
  }
1866
- const us = l(
1878
+ const ps = l(
1867
1879
  "miniApp",
1868
1880
  ({
1869
1881
  themeParams: e,
@@ -1875,7 +1887,7 @@ const us = l(
1875
1887
  ...n
1876
1888
  }) => new Me({ ...n, ...s, botInline: t })
1877
1889
  );
1878
- function Le(e) {
1890
+ function $e(e) {
1879
1891
  const t = e.message.trim(), s = (e.title || "").trim(), n = e.buttons || [];
1880
1892
  let r;
1881
1893
  if (s.length > 64)
@@ -1899,7 +1911,7 @@ function Le(e) {
1899
1911
  return { ...i, id: a };
1900
1912
  }) : r = [{ type: "close", id: "" }], { title: s, message: t, buttons: r };
1901
1913
  }
1902
- class Be extends I {
1914
+ class Le extends q {
1903
1915
  constructor(t, s, n) {
1904
1916
  super({ isOpened: t }, s, { open: "web_app_open_popup" }), this.postEvent = n;
1905
1917
  }
@@ -1932,7 +1944,7 @@ class Be extends I {
1932
1944
  event: "popup_closed",
1933
1945
  method: "web_app_open_popup",
1934
1946
  postEvent: this.postEvent,
1935
- params: Le(t)
1947
+ params: $e(t)
1936
1948
  });
1937
1949
  return s;
1938
1950
  } finally {
@@ -1940,10 +1952,10 @@ class Be extends I {
1940
1952
  }
1941
1953
  }
1942
1954
  }
1943
- const ls = l(
1944
- ({ postEvent: e, version: t }) => new Be(!1, t, e)
1955
+ const us = l(
1956
+ ({ postEvent: e, version: t }) => new Le(!1, t, e)
1945
1957
  );
1946
- class Oe extends I {
1958
+ class Be extends q {
1947
1959
  constructor(t, s, n) {
1948
1960
  super({ isOpened: t }, s, {
1949
1961
  close: "web_app_close_scan_qr_popup",
@@ -1987,10 +1999,10 @@ class Oe extends I {
1987
1999
  }
1988
2000
  }
1989
2001
  }
1990
- const ds = l(
1991
- ({ version: e, postEvent: t }) => new Oe(!1, e, t)
2002
+ const ls = l(
2003
+ ({ version: e, postEvent: t }) => new Be(!1, e, t)
1992
2004
  );
1993
- class Ue extends Z {
2005
+ class Oe extends K {
1994
2006
  constructor(s, n, r) {
1995
2007
  super({ isVisible: s }, n, {
1996
2008
  show: "web_app_setup_settings_button",
@@ -2001,7 +2013,7 @@ class Ue extends Z {
2001
2013
  * @param event - event to listen.
2002
2014
  * @param listener - listener to add.
2003
2015
  */
2004
- c(this, "on", (s, n) => s === "click" ? b("settings_button_pressed", n) : this.state.on(s, n));
2016
+ c(this, "on", (s, n) => s === "click" ? w("settings_button_pressed", n) : this.state.on(s, n));
2005
2017
  /**
2006
2018
  * Removes the event listener.
2007
2019
  * @param event - event to listen.
@@ -2032,18 +2044,18 @@ class Ue extends Z {
2032
2044
  this.isVisible = !0;
2033
2045
  }
2034
2046
  }
2035
- const _s = l(
2047
+ const ds = l(
2036
2048
  "settingsButton",
2037
2049
  ({
2038
2050
  version: e,
2039
2051
  postEvent: t,
2040
2052
  state: s = { isVisible: !1 }
2041
- }) => new Ue(s.isVisible, e, t)
2053
+ }) => new Oe(s.isVisible, e, t)
2042
2054
  );
2043
- function It(e) {
2044
- return yt().parse(e);
2055
+ function $t(e) {
2056
+ return Ct().parse(e);
2045
2057
  }
2046
- class We extends X {
2058
+ class We extends et {
2047
2059
  /**
2048
2060
  * @since v6.10
2049
2061
  */
@@ -2082,7 +2094,7 @@ class We extends X {
2082
2094
  * value is calculated according to theme bg color.
2083
2095
  */
2084
2096
  get isDark() {
2085
- return !this.bgColor || gt(this.bgColor);
2097
+ return !this.bgColor || Et(this.bgColor);
2086
2098
  }
2087
2099
  get linkColor() {
2088
2100
  return this.get("linkColor");
@@ -2107,8 +2119,8 @@ class We extends X {
2107
2119
  * @returns Function to stop listening.
2108
2120
  */
2109
2121
  listen() {
2110
- return b("theme_changed", (t) => {
2111
- this.set(It(t.theme_params));
2122
+ return w("theme_changed", (t) => {
2123
+ this.set($t(t.theme_params));
2112
2124
  });
2113
2125
  }
2114
2126
  /**
@@ -2121,28 +2133,28 @@ class We extends X {
2121
2133
  return this.get("textColor");
2122
2134
  }
2123
2135
  }
2124
- const fs = l(
2136
+ const _s = l(
2125
2137
  "themeParams",
2126
2138
  ({ themeParams: e, state: t = e, addCleanup: s }) => {
2127
2139
  const n = new We(t);
2128
2140
  return s(n.listen()), n;
2129
2141
  }
2130
2142
  );
2131
- function gs(e = {}) {
2143
+ function fs(e = {}) {
2132
2144
  return _({
2133
2145
  ...e,
2134
2146
  method: "web_app_request_theme",
2135
2147
  event: "theme_changed"
2136
- }).then(It);
2148
+ }).then($t);
2137
2149
  }
2138
- class He extends tt {
2150
+ class Ue extends st {
2139
2151
  constructor(s, n, r) {
2140
2152
  super(s, { readTextFromClipboard: "web_app_read_text_from_clipboard" });
2141
2153
  /**
2142
2154
  * Checks if specified method parameter is supported by current component.
2143
2155
  */
2144
2156
  c(this, "supportsParam");
2145
- this.version = s, this.createRequestId = n, this.postEvent = r, this.supportsParam = Tt(s, {
2157
+ this.version = s, this.createRequestId = n, this.postEvent = r, this.supportsParam = Mt(s, {
2146
2158
  "openLink.tryInstantView": ["web_app_open_link", "try_instant_view"]
2147
2159
  });
2148
2160
  }
@@ -2196,15 +2208,15 @@ class He extends tt {
2196
2208
  event: "clipboard_text_received",
2197
2209
  postEvent: this.postEvent,
2198
2210
  params: { req_id: s },
2199
- capture: dt(s)
2211
+ capture: mt(s)
2200
2212
  });
2201
2213
  return n;
2202
2214
  }
2203
2215
  }
2204
- const bs = l(
2205
- ({ version: e, postEvent: t, createRequestId: s }) => new He(e, s, t)
2216
+ const gs = l(
2217
+ ({ version: e, postEvent: t, createRequestId: s }) => new Ue(e, s, t)
2206
2218
  );
2207
- async function qt(e = {}) {
2219
+ async function Lt(e = {}) {
2208
2220
  const {
2209
2221
  is_expanded: t,
2210
2222
  is_state_stable: s,
@@ -2219,7 +2231,7 @@ async function qt(e = {}) {
2219
2231
  function x(e) {
2220
2232
  return e < 0 ? 0 : e;
2221
2233
  }
2222
- class Ge extends X {
2234
+ class He extends et {
2223
2235
  constructor({ postEvent: s, stableHeight: n, height: r, width: i, isExpanded: a }) {
2224
2236
  super({
2225
2237
  height: x(r),
@@ -2236,7 +2248,7 @@ class Ge extends X {
2236
2248
  * @param options - options to request fresh data.
2237
2249
  */
2238
2250
  async sync(s) {
2239
- const { isStateStable: n, ...r } = await qt(s);
2251
+ const { isStateStable: n, ...r } = await Lt(s);
2240
2252
  this.set({
2241
2253
  ...r,
2242
2254
  stableHeight: n ? r.height : this.get("stableHeight")
@@ -2283,7 +2295,7 @@ class Ge extends X {
2283
2295
  * @returns Function to stop listening.
2284
2296
  */
2285
2297
  listen() {
2286
- return b("viewport_changed", (s) => {
2298
+ return w("viewport_changed", (s) => {
2287
2299
  const {
2288
2300
  height: n,
2289
2301
  width: r,
@@ -2337,10 +2349,10 @@ const ws = l(
2337
2349
  else if (["macos", "tdesktop", "unigram", "webk", "weba", "web"].includes(t))
2338
2350
  r = !0, i = window.innerHeight, a = window.innerWidth, o = window.innerHeight;
2339
2351
  else {
2340
- const u = await qt({ timeout: 1e3, postEvent: s });
2352
+ const u = await Lt({ timeout: 1e3, postEvent: s });
2341
2353
  r = u.isExpanded, i = u.height, a = u.width, o = u.isStateStable ? i : 0;
2342
2354
  }
2343
- const p = new Ge({
2355
+ const p = new He({
2344
2356
  postEvent: s,
2345
2357
  height: i,
2346
2358
  width: a,
@@ -2353,11 +2365,11 @@ const ws = l(
2353
2365
  function m(e, t) {
2354
2366
  document.documentElement.style.setProperty(e, t);
2355
2367
  }
2356
- function ms(e, t, s) {
2368
+ function bs(e, t, s) {
2357
2369
  s || (s = (o) => `--tg-${o}-color`);
2358
2370
  const n = s("header"), r = s("bg"), i = () => {
2359
2371
  const { headerColor: o } = e;
2360
- if (Q(o))
2372
+ if (Y(o))
2361
2373
  m(n, o);
2362
2374
  else {
2363
2375
  const { bgColor: p, secondaryBgColor: u } = t;
@@ -2370,7 +2382,7 @@ function ms(e, t, s) {
2370
2382
  ];
2371
2383
  return i(), () => a.forEach((o) => o());
2372
2384
  }
2373
- function ys(e, t) {
2385
+ function ms(e, t) {
2374
2386
  t || (t = (n) => `--tg-theme-${n.replace(/[A-Z]/g, (r) => `-${r.toLowerCase()}`)}`);
2375
2387
  const s = () => {
2376
2388
  Object.entries(e.getState()).forEach(([n, r]) => {
@@ -2379,7 +2391,7 @@ function ys(e, t) {
2379
2391
  };
2380
2392
  return s(), e.on("change", s);
2381
2393
  }
2382
- function vs(e, t) {
2394
+ function ys(e, t) {
2383
2395
  t || (t = (u) => `--tg-viewport-${u}`);
2384
2396
  const [
2385
2397
  s,
@@ -2392,16 +2404,16 @@ function vs(e, t) {
2392
2404
  ];
2393
2405
  return i(), a(), o(), () => p.forEach((u) => u());
2394
2406
  }
2395
- function Es(e = !0) {
2407
+ function vs(e = !0) {
2396
2408
  const t = [
2397
- b("reload_iframe", () => {
2409
+ w("reload_iframe", () => {
2398
2410
  R("iframe_will_reload"), window.location.reload();
2399
2411
  })
2400
2412
  ], s = () => t.forEach((n) => n());
2401
2413
  if (e) {
2402
2414
  const n = document.createElement("style");
2403
2415
  n.id = "telegram-custom-styles", document.head.appendChild(n), t.push(
2404
- b("set_custom_style", (r) => {
2416
+ w("set_custom_style", (r) => {
2405
2417
  n.innerHTML = r;
2406
2418
  }),
2407
2419
  () => document.head.removeChild(n)
@@ -2409,11 +2421,11 @@ function Es(e = !0) {
2409
2421
  }
2410
2422
  return R("iframe_ready", { reload_supported: !0 }), s;
2411
2423
  }
2412
- function Ps() {
2424
+ function Es() {
2413
2425
  return typeof window > "u";
2414
2426
  }
2415
- async function xs() {
2416
- if (ut(window))
2427
+ async function Ps() {
2428
+ if (gt(window))
2417
2429
  return !0;
2418
2430
  try {
2419
2431
  return await _({ method: "web_app_request_theme", event: "theme_changed", timeout: 100 }), !0;
@@ -2421,11 +2433,51 @@ async function xs() {
2421
2433
  return !1;
2422
2434
  }
2423
2435
  }
2424
- function je(e) {
2436
+ function xs(e) {
2437
+ const t = typeof e == "string" ? tt(e) : e;
2438
+ Nt(t);
2439
+ function s(r) {
2440
+ if (typeof r == "string")
2441
+ try {
2442
+ const { eventType: i } = _t(r);
2443
+ i === "web_app_request_theme" && z("theme_changed", {
2444
+ theme_params: JSON.parse(kt(t.themeParams))
2445
+ }), i === "web_app_request_viewport" && z("viewport_changed", {
2446
+ width: window.innerWidth,
2447
+ height: window.innerHeight,
2448
+ is_state_stable: !0,
2449
+ is_expanded: !0
2450
+ });
2451
+ } catch {
2452
+ }
2453
+ }
2454
+ if (wt()) {
2455
+ const r = window.parent.postMessage.bind(window.parent);
2456
+ window.parent.postMessage = (i) => {
2457
+ s(i), r(i);
2458
+ };
2459
+ return;
2460
+ }
2461
+ if (ft(window)) {
2462
+ const r = window.external.notify.bind(window.external);
2463
+ window.external.notify = (i) => {
2464
+ s(i), r(i);
2465
+ };
2466
+ return;
2467
+ }
2468
+ const n = window.TelegramWebviewProxy;
2469
+ window.TelegramWebviewProxy = {
2470
+ ...n || {},
2471
+ postEvent(...r) {
2472
+ s(JSON.stringify({ eventType: r[0], eventData: r[1] })), n && n.postEvent(...r);
2473
+ }
2474
+ };
2475
+ }
2476
+ function Ge(e) {
2425
2477
  return e instanceof V;
2426
2478
  }
2427
- function Cs(e, t) {
2428
- return je(e) && e.type === t;
2479
+ function Ss(e, t) {
2480
+ return Ge(e) && e.type === t;
2429
2481
  }
2430
2482
  function B(e, t) {
2431
2483
  let s, n, r;
@@ -2435,13 +2487,13 @@ function B(e, t) {
2435
2487
  params: n
2436
2488
  });
2437
2489
  }
2438
- class ze {
2490
+ class je {
2439
2491
  constructor(t, s, n = R) {
2440
2492
  /**
2441
2493
  * Navigation history.
2442
2494
  */
2443
2495
  c(this, "history");
2444
- c(this, "ee", new D());
2496
+ c(this, "ee", new T());
2445
2497
  /**
2446
2498
  * True, if current navigator is currently attached.
2447
2499
  */
@@ -2459,10 +2511,10 @@ class ze {
2459
2511
  */
2460
2512
  c(this, "off", this.ee.off.bind(this.ee));
2461
2513
  if (this._index = s, this.postEvent = n, t.length === 0)
2462
- throw f(jt, "History should not be empty.");
2514
+ throw f(Kt, "History should not be empty.");
2463
2515
  if (s < 0 || s >= t.length)
2464
2516
  throw f(
2465
- zt,
2517
+ Xt,
2466
2518
  "Index should not be zero and higher or equal than history size."
2467
2519
  );
2468
2520
  this.history = t.map((r) => B(r, ""));
@@ -2472,7 +2524,7 @@ class ze {
2472
2524
  * `BackButton` clicks and calls the `back` method.
2473
2525
  */
2474
2526
  attach() {
2475
- this.attached || (this.attached = !0, this.sync(), b("back_button_pressed", this.back));
2527
+ this.attached || (this.attached = !0, this.sync(), w("back_button_pressed", this.back));
2476
2528
  }
2477
2529
  /**
2478
2530
  * Currently active history item.
@@ -2586,23 +2638,23 @@ function O({
2586
2638
  function A(e, t) {
2587
2639
  return e.startsWith(t) ? e : `${t}${e}`;
2588
2640
  }
2589
- function k(e) {
2641
+ function N(e) {
2590
2642
  return new URL(
2591
2643
  typeof e == "string" ? e : `${e.pathname || ""}${A(e.search || "", "?")}${A(e.hash || "", "#")}`,
2592
2644
  "http://a"
2593
2645
  );
2594
2646
  }
2595
- function N(e) {
2596
- const t = typeof e == "string" ? e.startsWith("/") : !!(e.pathname && e.pathname.startsWith("/")), s = k(e);
2647
+ function D(e) {
2648
+ const t = typeof e == "string" ? e.startsWith("/") : !!(e.pathname && e.pathname.startsWith("/")), s = N(e);
2597
2649
  return `${t ? s.pathname : s.pathname.slice(1)}${s.search}${s.hash}`;
2598
2650
  }
2599
- function U(e, t, s) {
2651
+ function W(e, t, s) {
2600
2652
  let n, r;
2601
- typeof e == "string" ? n = e : (n = N(e), s = e.state, r = e.id);
2653
+ typeof e == "string" ? n = e : (n = D(e), s = e.state, r = e.id);
2602
2654
  const { pathname: i, search: a, hash: o } = new URL(n, `http://a${A(t, "/")}`);
2603
2655
  return { id: r, pathname: i, params: { hash: o, search: a, state: s } };
2604
2656
  }
2605
- async function S(e) {
2657
+ async function C(e) {
2606
2658
  return e === 0 ? !0 : Promise.race([
2607
2659
  new Promise((t) => {
2608
2660
  const s = j("popstate", () => {
@@ -2616,21 +2668,21 @@ async function S(e) {
2616
2668
  })
2617
2669
  ]);
2618
2670
  }
2619
- async function Fe() {
2620
- if (window.history.length <= 1 || (window.history.pushState(null, ""), await S(1 - window.history.length)))
2671
+ async function ze() {
2672
+ if (window.history.length <= 1 || (window.history.pushState(null, ""), await C(1 - window.history.length)))
2621
2673
  return;
2622
- let t = await S(-1);
2674
+ let t = await C(-1);
2623
2675
  for (; t; )
2624
- t = await S(-1);
2676
+ t = await C(-1);
2625
2677
  }
2626
- function kt(e) {
2627
- return k(e).pathname;
2678
+ function Bt(e) {
2679
+ return N(e).pathname;
2628
2680
  }
2629
- const rt = 0, W = 1, H = 2;
2630
- class Nt {
2681
+ const ot = 0, U = 1, H = 2;
2682
+ class Ot {
2631
2683
  constructor(t, s, { postEvent: n, hashMode: r = "classic", base: i } = {}) {
2632
2684
  c(this, "navigator");
2633
- c(this, "ee", new D());
2685
+ c(this, "ee", new T());
2634
2686
  c(this, "hashMode");
2635
2687
  c(this, "base");
2636
2688
  /**
@@ -2644,7 +2696,7 @@ class Nt {
2644
2696
  c(this, "onPopState", ({ state: t }) => {
2645
2697
  if (t === null)
2646
2698
  return this.push(this.parsePath(window.location.href));
2647
- t === rt ? window.history.forward() : t === W && this.back(), t === H && this.forward();
2699
+ t === ot ? window.history.forward() : t === U && this.back(), t === H && this.forward();
2648
2700
  });
2649
2701
  /**
2650
2702
  * Underlying navigator change event listener.
@@ -2669,11 +2721,11 @@ class Nt {
2669
2721
  * Removes event listener.
2670
2722
  */
2671
2723
  c(this, "off", this.ee.off.bind(this.ee));
2672
- this.navigator = new ze(
2673
- t.map((a) => U(a, "/")),
2724
+ this.navigator = new je(
2725
+ t.map((a) => W(a, "/")),
2674
2726
  s,
2675
2727
  n
2676
- ), this.navigator.on("change", this.onNavigatorChange), this.hashMode = r, this.base = kt(i || "");
2728
+ ), this.navigator.on("change", this.onNavigatorChange), this.hashMode = r, this.base = Bt(i || "");
2677
2729
  }
2678
2730
  /**
2679
2731
  * Attaches current navigator to the browser history allowing navigator to manipulate it.
@@ -2771,7 +2823,7 @@ class Nt {
2771
2823
  * "/pathname?search#hash"
2772
2824
  */
2773
2825
  get path() {
2774
- return N(this);
2826
+ return D(this);
2775
2827
  }
2776
2828
  /**
2777
2829
  * Current pathname. Always starts with the slash.
@@ -2800,19 +2852,19 @@ class Nt {
2800
2852
  * // { pathname: '/tma', search: '?is=cool', hash: '#yeah' }
2801
2853
  */
2802
2854
  parsePath(t) {
2803
- let s = k(t);
2804
- return this.hashMode && (s = k(s.hash.slice(1))), {
2855
+ let s = N(t);
2856
+ return this.hashMode && (s = N(s.hash.slice(1))), {
2805
2857
  pathname: s.pathname,
2806
2858
  search: s.search,
2807
2859
  hash: s.hash
2808
2860
  };
2809
2861
  }
2810
2862
  push(t, s) {
2811
- const n = U(t, this.path), { state: r = s } = n.params;
2863
+ const n = W(t, this.path), { state: r = s } = n.params;
2812
2864
  this.navigator.push({ ...n, params: { ...n.params, state: r } });
2813
2865
  }
2814
2866
  replace(t, s) {
2815
- const n = U(t, this.path), { state: r = s } = n.params;
2867
+ const n = W(t, this.path), { state: r = s } = n.params;
2816
2868
  this.navigator.replace({ ...n, params: { ...n.params, state: r } });
2817
2869
  }
2818
2870
  /**
@@ -2821,7 +2873,7 @@ class Nt {
2821
2873
  * @param value - path presented as string or URLLike.
2822
2874
  */
2823
2875
  renderPath(t) {
2824
- const s = (this.base.length === 1 ? "" : this.base) + A(N(t), "/");
2876
+ const s = (this.base.length === 1 ? "" : this.base) + A(D(t), "/");
2825
2877
  return this.hashMode ? A(s.slice(1), this.hashMode === "classic" ? "#" : "#/") : s;
2826
2878
  }
2827
2879
  /**
@@ -2830,7 +2882,7 @@ class Nt {
2830
2882
  async syncHistory() {
2831
2883
  window.removeEventListener("popstate", this.onPopState);
2832
2884
  const { state: t } = this, s = this.renderPath(this);
2833
- await Fe(), this.hasPrev && this.hasNext ? (window.history.replaceState(W, ""), window.history.pushState(t, "", s), window.history.pushState(H, ""), await S(-1)) : this.hasPrev ? (window.history.replaceState(W, ""), window.history.pushState(t, "", s)) : this.hasNext ? (window.history.replaceState(t, s), window.history.pushState(H, ""), await S(-1)) : (window.history.replaceState(rt, ""), window.history.pushState(t, "", s)), window.addEventListener("popstate", this.onPopState);
2885
+ await ze(), 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(ot, ""), window.history.pushState(t, "", s)), window.addEventListener("popstate", this.onPopState);
2834
2886
  }
2835
2887
  /**
2836
2888
  * Current query parameters.
@@ -2848,148 +2900,149 @@ class Nt {
2848
2900
  return (this.navigator.current.params || {}).state;
2849
2901
  }
2850
2902
  }
2851
- function Je(e) {
2903
+ function Fe(e) {
2852
2904
  e || (e = {});
2853
2905
  const { href: t, hash: s } = window.location;
2854
- let n = N(
2906
+ let n = D(
2855
2907
  e.hashMode === null ? t : s.includes("?") ? s.slice(1) : `?${s.slice(1)}`
2856
2908
  );
2857
- const r = e.base ? kt(e.base) : void 0;
2909
+ const r = e.base ? Bt(e.base) : void 0;
2858
2910
  if (r) {
2859
2911
  if (!n.startsWith(r))
2860
2912
  throw f(
2861
- Ft,
2913
+ te,
2862
2914
  `Path "${n}" expected to be starting with "${r}"`
2863
2915
  );
2864
2916
  n = n.slice(r.length);
2865
2917
  }
2866
- return new Nt([n], 0, e);
2918
+ return new Ot([n], 0, e);
2867
2919
  }
2868
- function Ss(e) {
2920
+ function Cs(e) {
2869
2921
  const t = e.match(/#(.+)/);
2870
2922
  return t ? t[1] : null;
2871
2923
  }
2872
- function Qe(e, t) {
2873
- if (Rt()) {
2924
+ function Je(e, t) {
2925
+ if (Dt()) {
2874
2926
  const s = sessionStorage.getItem(e);
2875
2927
  if (s)
2876
2928
  try {
2877
2929
  const { index: n, history: r } = JSON.parse(s);
2878
- return new Nt(r, n, t);
2930
+ return new Ot(r, n, t);
2879
2931
  } catch (n) {
2880
2932
  console.error("Unable to restore hash navigator state.", n);
2881
2933
  }
2882
2934
  }
2883
- return Je(t);
2935
+ return Fe(t);
2884
2936
  }
2885
- function Rs(e, t) {
2886
- const s = Qe(e, t), n = () => sessionStorage.setItem(e, JSON.stringify({
2937
+ function Ts(e, t) {
2938
+ const s = Je(e, t), n = () => sessionStorage.setItem(e, JSON.stringify({
2887
2939
  index: s.index,
2888
2940
  history: s.history
2889
2941
  }));
2890
2942
  return s.on("change", n), n(), s;
2891
2943
  }
2892
2944
  export {
2893
- pe as BackButton,
2894
- ze as BasicNavigator,
2895
- xe as BiometryManager,
2896
- Nt as BrowserNavigator,
2945
+ le as BackButton,
2946
+ je as BasicNavigator,
2947
+ Pe as BiometryManager,
2948
+ Ot as BrowserNavigator,
2897
2949
  Se as ClosingBehavior,
2898
- Ie as CloudStorage,
2899
- Ft as ERR_INVALID_PATH_BASE,
2900
- Wt as ERR_INVOKE_CUSTOM_METHOD_RESPONSE,
2901
- Ot as ERR_METHOD_PARAMETER_UNSUPPORTED,
2902
- Bt as ERR_METHOD_UNSUPPORTED,
2903
- jt as ERR_NAVIGATION_HISTORY_EMPTY,
2904
- zt as ERR_NAVIGATION_INDEX_INVALID,
2905
- Ke as ERR_NAVIGATION_ITEM_INVALID,
2906
- at as ERR_PARSE,
2907
- Xe as ERR_SSR_INIT,
2908
- Ht as ERR_TIMED_OUT,
2909
- Gt as ERR_UNEXPECTED_TYPE,
2910
- Ut as ERR_UNKNOWN_ENV,
2911
- D as EventEmitter,
2912
- qe as HapticFeedback,
2913
- ke as InitData,
2914
- Ne as Invoice,
2915
- De as MainButton,
2950
+ Ae as CloudStorage,
2951
+ te as ERR_INVALID_PATH_BASE,
2952
+ Qt as ERR_INVOKE_CUSTOM_METHOD_RESPONSE,
2953
+ Ft as ERR_METHOD_PARAMETER_UNSUPPORTED,
2954
+ zt as ERR_METHOD_UNSUPPORTED,
2955
+ Kt as ERR_NAVIGATION_HISTORY_EMPTY,
2956
+ Xt as ERR_NAVIGATION_INDEX_INVALID,
2957
+ Ze as ERR_NAVIGATION_ITEM_INVALID,
2958
+ pt as ERR_PARSE,
2959
+ Ke as ERR_SSR_INIT,
2960
+ Yt as ERR_TIMED_OUT,
2961
+ Zt as ERR_UNEXPECTED_TYPE,
2962
+ Jt as ERR_UNKNOWN_ENV,
2963
+ T as EventEmitter,
2964
+ Ie as HapticFeedback,
2965
+ qe as InitData,
2966
+ ke as Invoice,
2967
+ Ne as MainButton,
2916
2968
  Me as MiniApp,
2917
- Be as Popup,
2918
- Oe as QRScanner,
2969
+ Le as Popup,
2970
+ Be as QRScanner,
2919
2971
  V as SDKError,
2920
- Ue as SettingsButton,
2972
+ Oe as SettingsButton,
2921
2973
  We as ThemeParams,
2922
- He as Utils,
2923
- Ge as Viewport,
2924
- Te as array,
2925
- ms as bindMiniAppCSSVars,
2926
- ys as bindThemeParamsCSSVars,
2927
- vs as bindViewportCSSVars,
2928
- w as boolean,
2929
- dt as captureSameReq,
2930
- z as classNames,
2931
- re as compareVersions,
2932
- Je as createBrowserNavigatorFromLocation,
2933
- ce as createPostEvent,
2934
- k as createSafeURL,
2935
- wt as date,
2936
- Ss as getHash,
2937
- kt as getPathname,
2938
- ss as initBackButton,
2939
- ns as initBiometryManager,
2940
- rs as initClosingBehavior,
2941
- is as initCloudStorage,
2942
- os as initHapticFeedback,
2943
- as as initInitData,
2944
- hs as initInvoice,
2945
- ps as initMainButton,
2946
- us as initMiniApp,
2947
- Rs as initNavigator,
2948
- ls as initPopup,
2949
- ds as initQRScanner,
2950
- _s as initSettingsButton,
2951
- fs as initThemeParams,
2952
- bs as initUtils,
2974
+ Ue as Utils,
2975
+ He as Viewport,
2976
+ Re as array,
2977
+ bs as bindMiniAppCSSVars,
2978
+ ms as bindThemeParamsCSSVars,
2979
+ ys as bindViewportCSSVars,
2980
+ b as boolean,
2981
+ mt as captureSameReq,
2982
+ F as classNames,
2983
+ ce as compareVersions,
2984
+ Fe as createBrowserNavigatorFromLocation,
2985
+ pe as createPostEvent,
2986
+ N as createSafeURL,
2987
+ xt as date,
2988
+ Cs as getHash,
2989
+ Bt as getPathname,
2990
+ es as initBackButton,
2991
+ ss as initBiometryManager,
2992
+ ns as initClosingBehavior,
2993
+ rs as initCloudStorage,
2994
+ is as initHapticFeedback,
2995
+ os as initInitData,
2996
+ cs as initInvoice,
2997
+ hs as initMainButton,
2998
+ ps as initMiniApp,
2999
+ Ts as initNavigator,
3000
+ us as initPopup,
3001
+ ls as initQRScanner,
3002
+ ds as initSettingsButton,
3003
+ _s as initThemeParams,
3004
+ gs as initUtils,
2953
3005
  ws as initViewport,
2954
- Es as initWeb,
2955
- C as invokeCustomMethod,
2956
- gt as isColorDark,
2957
- oe as isIframe,
2958
- Rt as isPageReload,
2959
- Q as isRGB,
2960
- Jt as isRGBShort,
2961
- je as isSDKError,
2962
- Cs as isSDKErrorOfType,
2963
- Ps as isSSR,
2964
- xs as isTMA,
3006
+ vs as initWeb,
3007
+ S as invokeCustomMethod,
3008
+ Et as isColorDark,
3009
+ wt as isIframe,
3010
+ Dt as isPageReload,
3011
+ Y as isRGB,
3012
+ ee as isRGBShort,
3013
+ Ge as isSDKError,
3014
+ Ss as isSDKErrorOfType,
3015
+ Es as isSSR,
3016
+ Ps as isTMA,
2965
3017
  d as json,
2966
- es as mergeClassNames,
3018
+ ts as mergeClassNames,
3019
+ xs as mockTelegramEnv,
2967
3020
  y as number,
2968
3021
  L as off,
2969
- b as on,
2970
- cs as parseInitData,
2971
- vt as parseLaunchParams,
2972
- It as parseThemeParams,
3022
+ w as on,
3023
+ as as parseInitData,
3024
+ tt as parseLaunchParams,
3025
+ $t as parseThemeParams,
2973
3026
  R as postEvent,
2974
3027
  _ as request,
2975
- Ce as requestBiometryInfo,
2976
- gs as requestThemeParams,
2977
- qt as requestViewport,
3028
+ xe as requestBiometryInfo,
3029
+ fs as requestThemeParams,
3030
+ Lt as requestViewport,
2978
3031
  ye as retrieveLaunchParams,
2979
- pt as rgb,
2980
- K as searchParams,
2981
- we as serializeLaunchParams,
2982
- be as serializeThemeParams,
3032
+ dt as rgb,
3033
+ X as searchParams,
3034
+ me as serializeLaunchParams,
3035
+ kt as serializeThemeParams,
2983
3036
  m as setCSSVar,
2984
- Ze as setDebug,
2985
- ts as setTargetOrigin,
3037
+ Ye as setDebug,
3038
+ Xe as setTargetOrigin,
2986
3039
  h as string,
2987
- $t as subscribe,
3040
+ Ht as subscribe,
2988
3041
  v as supports,
2989
- ae as targetOrigin,
2990
- ht as toRGB,
2991
- ot as unsubscribe,
2992
- N as urlToPath,
2993
- ft as withTimeout
3042
+ he as targetOrigin,
3043
+ lt as toRGB,
3044
+ ct as unsubscribe,
3045
+ D as urlToPath,
3046
+ vt as withTimeout
2994
3047
  };
2995
3048
  //# sourceMappingURL=index.js.map