@tma.js/sdk-solid 2.1.0 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { createComponent as mt, mergeProps as ht, createContext as Qt, useContext as Ft, createEffect as pt, onCleanup as Yt, createResource as Zt, createMemo as ut, from as Xt } from "solid-js";
2
- var te = Object.defineProperty, ee = (e, t, s) => t in e ? te(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s, c = (e, t, s) => (ee(e, typeof t != "symbol" ? t + "" : t, s), s);
1
+ import { createComponent as mt, mergeProps as ht, createContext as Ft, useContext as Yt, createEffect as pt, onCleanup as Zt, createResource as Xt, createMemo as ut, from as te } from "solid-js";
2
+ var ee = Object.defineProperty, se = (e, t, s) => t in e ? ee(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s, c = (e, t, s) => (se(e, typeof t != "symbol" ? t + "" : t, s), s);
3
3
  function wt(e, t) {
4
4
  let s;
5
5
  const n = () => {
@@ -9,12 +9,12 @@ function wt(e, t) {
9
9
  }
10
10
  function bt(e) {
11
11
  const t = W(), { count: s } = t;
12
- t.unsubscribe(e), s && !t.count && Se();
12
+ t.unsubscribe(e), s && !t.count && Ce();
13
13
  }
14
- function se(e) {
14
+ function ne(e) {
15
15
  return W().subscribe(e), () => bt(e);
16
16
  }
17
- class ne {
17
+ class re {
18
18
  constructor(t, s = {}) {
19
19
  this.scope = t, this.options = s;
20
20
  }
@@ -54,7 +54,7 @@ class ne {
54
54
  this.print("log", ...t);
55
55
  }
56
56
  }
57
- const $ = new ne("SDK", {
57
+ const $ = new re("SDK", {
58
58
  bgColor: "forestgreen",
59
59
  textColor: "white"
60
60
  });
@@ -62,10 +62,10 @@ let Y = !1;
62
62
  const dt = ({ event: e, args: [t] }) => {
63
63
  $.log("Event received:", t === void 0 ? { name: e } : { name: e, data: t });
64
64
  };
65
- function re(e) {
66
- Y !== e && (Y = e, e ? se(dt) : bt(dt));
65
+ function ie(e) {
66
+ Y !== e && (Y = e, e ? ne(dt) : bt(dt));
67
67
  }
68
- function ie(...e) {
68
+ function oe(...e) {
69
69
  Y && $.log(...e);
70
70
  }
71
71
  class L {
@@ -149,9 +149,9 @@ class U extends Error {
149
149
  function d(e, t, s) {
150
150
  return new U(e, t, s);
151
151
  }
152
- const oe = "ERR_METHOD_UNSUPPORTED", ae = "ERR_METHOD_PARAMETER_UNSUPPORTED", ce = "ERR_UNKNOWN_ENV", he = "ERR_INVOKE_CUSTOM_METHOD_RESPONSE", pe = "ERR_TIMED_OUT", ue = "ERR_UNEXPECTED_TYPE", vt = "ERR_PARSE", de = "ERR_NAVIGATION_LIST_EMPTY", le = "ERR_NAVIGATION_CURSOR_INVALID", Fs = "ERR_NAVIGATION_ITEM_INVALID", tt = "ERR_SSR_INIT", _e = "ERR_SSR_POST_EVENT", ge = "ERR_INVALID_PATH_BASE";
152
+ const ae = "ERR_METHOD_UNSUPPORTED", ce = "ERR_METHOD_PARAMETER_UNSUPPORTED", he = "ERR_UNKNOWN_ENV", pe = "ERR_INVOKE_CUSTOM_METHOD_RESPONSE", ue = "ERR_TIMED_OUT", de = "ERR_UNEXPECTED_TYPE", vt = "ERR_PARSE", le = "ERR_NAVIGATION_LIST_EMPTY", _e = "ERR_NAVIGATION_CURSOR_INVALID", Fs = "ERR_NAVIGATION_ITEM_INVALID", tt = "ERR_SSR_INIT", ge = "ERR_SSR_POST_EVENT", fe = "ERR_INVALID_PATH_BASE";
153
153
  function C() {
154
- return d(ue, "Value has unexpected type");
154
+ return d(de, "Value has unexpected type");
155
155
  }
156
156
  class H {
157
157
  constructor(t, s, n) {
@@ -239,14 +239,14 @@ const E = R((e) => {
239
239
  function st(e) {
240
240
  return /^#[\da-f]{6}$/i.test(e);
241
241
  }
242
- function fe(e) {
242
+ function me(e) {
243
243
  return /^#[\da-f]{3}$/i.test(e);
244
244
  }
245
245
  function Et(e) {
246
246
  const t = e.replace(/\s/g, "").toLowerCase();
247
247
  if (st(t))
248
248
  return t;
249
- if (fe(t)) {
249
+ if (me(t)) {
250
250
  let n = "#";
251
251
  for (let r = 0; r < 3; r += 1)
252
252
  n += t[1 + r].repeat(2);
@@ -265,25 +265,25 @@ const p = R((e) => {
265
265
  return e.toString();
266
266
  throw C();
267
267
  }, "string"), Pt = R((e) => Et(p().parse(e)), "rgb");
268
- function me(e) {
268
+ function we(e) {
269
269
  return f({
270
270
  eventType: p(),
271
271
  eventData: (t) => t
272
272
  }).parse(e);
273
273
  }
274
- function we() {
274
+ function be() {
275
275
  ["TelegramGameProxy_receiveEvent", "TelegramGameProxy", "Telegram"].forEach((e) => {
276
276
  delete window[e];
277
277
  });
278
278
  }
279
- function be(e, t) {
279
+ function ve(e, t) {
280
280
  window.dispatchEvent(new MessageEvent("message", {
281
281
  data: JSON.stringify({ eventType: e, eventData: t }),
282
282
  // We specify window.parent to imitate the case, the parent iframe sent us this event.
283
283
  source: window.parent
284
284
  }));
285
285
  }
286
- function ve() {
286
+ function ye() {
287
287
  [
288
288
  ["TelegramGameProxy_receiveEvent"],
289
289
  // Windows Phone.
@@ -295,16 +295,16 @@ function ve() {
295
295
  let t = window;
296
296
  e.forEach((s, n, r) => {
297
297
  if (n === r.length - 1) {
298
- t[s] = be;
298
+ t[s] = ve;
299
299
  return;
300
300
  }
301
301
  s in t || (t[s] = {}), t = t[s];
302
302
  });
303
303
  });
304
304
  }
305
- const ye = f({
305
+ const Ee = f({
306
306
  button_id: (e) => e == null ? void 0 : p().parse(e)
307
- }), Ee = {
307
+ }), Pe = {
308
308
  clipboard_text_received: f({
309
309
  req_id: p(),
310
310
  data: (e) => e === null ? e : p().optional().parse(e)
@@ -322,7 +322,7 @@ const ye = f({
322
322
  status: p()
323
323
  }),
324
324
  popup_closed: {
325
- parse: (e) => ye.parse(e ?? {})
325
+ parse: (e) => Ee.parse(e ?? {})
326
326
  },
327
327
  qr_text_received: f({
328
328
  data: p().optional()
@@ -343,12 +343,12 @@ const ye = f({
343
343
  status: p()
344
344
  })
345
345
  };
346
- function Pe() {
346
+ function xe() {
347
347
  const e = new L();
348
- ve();
348
+ ye();
349
349
  let t = [
350
350
  // Don't forget to remove created handlers.
351
- we,
351
+ be,
352
352
  // Add "resize" event listener to make sure, we always have fresh viewport information.
353
353
  // Desktop version of Telegram is sometimes not sending the viewport_changed
354
354
  // event. For example, when the MainButton is shown. That's why we should
@@ -369,11 +369,11 @@ function Pe() {
369
369
  return;
370
370
  let n;
371
371
  try {
372
- n = me(s.data);
372
+ n = we(s.data);
373
373
  } catch {
374
374
  return;
375
375
  }
376
- const { eventType: r, eventData: i } = n, o = Ee[r];
376
+ const { eventType: r, eventData: i } = n, o = Pe[r];
377
377
  try {
378
378
  const a = o ? o.parse(i) : i;
379
379
  e.emit(...a ? [r, a] : [r]);
@@ -392,9 +392,9 @@ function Pe() {
392
392
  t.forEach((s) => s()), t = [];
393
393
  }];
394
394
  }
395
- const [xe, Se] = wt(
395
+ const [Se, Ce] = wt(
396
396
  (e) => {
397
- const [t, s] = Pe(), n = t.off.bind(t);
397
+ const [t, s] = xe(), n = t.off.bind(t);
398
398
  return t.off = (r, i) => {
399
399
  const { count: o } = t;
400
400
  n(r, i), o && !t.count && e();
@@ -403,7 +403,7 @@ const [xe, Se] = wt(
403
403
  ([, e]) => e()
404
404
  );
405
405
  function W() {
406
- return xe()[0];
406
+ return Se()[0];
407
407
  }
408
408
  function j(e, t) {
409
409
  W().off(e, t);
@@ -414,7 +414,7 @@ function b(e, t, s) {
414
414
  function q(e) {
415
415
  return typeof e == "object" && e !== null && !Array.isArray(e);
416
416
  }
417
- function Ce(e, t) {
417
+ function Re(e, t) {
418
418
  const s = e.split("."), n = t.split("."), r = Math.max(s.length, n.length);
419
419
  for (let i = 0; i < r; i += 1) {
420
420
  const o = parseInt(s[i] || "0", 10), a = parseInt(n[i] || "0", 10);
@@ -424,7 +424,7 @@ function Ce(e, t) {
424
424
  return 0;
425
425
  }
426
426
  function w(e, t) {
427
- return Ce(e, t) <= 0;
427
+ return Re(e, t) <= 0;
428
428
  }
429
429
  function x(e, t, s) {
430
430
  if (typeof s == "string") {
@@ -477,74 +477,74 @@ function x(e, t, s) {
477
477
  ].includes(e);
478
478
  }
479
479
  }
480
- function Re(e) {
480
+ function Te(e) {
481
481
  return "external" in e && q(e.external) && "notify" in e.external && typeof e.external.notify == "function";
482
482
  }
483
- function Te(e) {
483
+ function xt(e) {
484
484
  return "TelegramWebviewProxy" in e && q(e.TelegramWebviewProxy) && "postEvent" in e.TelegramWebviewProxy && typeof e.TelegramWebviewProxy.postEvent == "function";
485
485
  }
486
- function xt() {
486
+ function St() {
487
487
  try {
488
488
  return window.self !== window.top;
489
489
  } catch {
490
490
  return !0;
491
491
  }
492
492
  }
493
- let St = "https://web.telegram.org";
493
+ let Ct = "https://web.telegram.org";
494
494
  function Ys(e) {
495
- St = e;
495
+ Ct = e;
496
496
  }
497
497
  function Ae() {
498
- return St;
498
+ return Ct;
499
499
  }
500
500
  function k(e, t, s) {
501
501
  let n = {}, r;
502
502
  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);
503
503
  const { targetOrigin: i = Ae() } = n;
504
- if (ie("Posting event:", r ? { event: e, data: r } : { event: e }), xt()) {
504
+ if (oe("Posting event:", r ? { event: e, data: r } : { event: e }), St()) {
505
505
  window.parent.postMessage(JSON.stringify({ eventType: e, eventData: r }), i);
506
506
  return;
507
507
  }
508
- if (Re(window)) {
508
+ if (Te(window)) {
509
509
  window.external.notify(JSON.stringify({ eventType: e, eventData: r }));
510
510
  return;
511
511
  }
512
- if (Te(window)) {
512
+ if (xt(window)) {
513
513
  window.TelegramWebviewProxy.postEvent(e, JSON.stringify(r));
514
514
  return;
515
515
  }
516
516
  throw d(
517
- ce,
517
+ he,
518
518
  "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."
519
519
  );
520
520
  }
521
521
  function Ie(e) {
522
522
  return (t, s) => {
523
523
  if (!x(t, e))
524
- throw d(oe, `Method "${t}" is unsupported in Mini Apps version ${e}`);
524
+ throw d(ae, `Method "${t}" is unsupported in Mini Apps version ${e}`);
525
525
  if (q(s)) {
526
526
  let n;
527
527
  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 && !x(t, n, e))
528
528
  throw d(
529
- ae,
529
+ ce,
530
530
  `Parameter "${n}" of "${t}" method is unsupported in Mini Apps version ${e}`
531
531
  );
532
532
  }
533
533
  return k(t, s);
534
534
  };
535
535
  }
536
- function Ct(e) {
536
+ function Rt(e) {
537
537
  return ({ req_id: t }) => t === e;
538
538
  }
539
- function Rt(e) {
540
- return d(pe, `Timeout reached: ${e}ms`);
539
+ function Tt(e) {
540
+ return d(ue, `Timeout reached: ${e}ms`);
541
541
  }
542
- function Tt(e, t) {
542
+ function At(e, t) {
543
543
  return Promise.race([
544
544
  typeof e == "function" ? e() : e,
545
545
  new Promise((s, n) => {
546
546
  setTimeout(() => {
547
- n(Rt(t));
547
+ n(Tt(t));
548
548
  }, t);
549
549
  })
550
550
  ]);
@@ -563,7 +563,7 @@ async function m(e) {
563
563
  (u) => b(u, (D) => (!i || i(D)) && t(D))
564
564
  );
565
565
  try {
566
- return o(n, e.params), await (a ? Tt(s, a) : s);
566
+ return o(n, e.params), await (a ? At(s, a) : s);
567
567
  } finally {
568
568
  h.forEach((u) => u());
569
569
  }
@@ -581,10 +581,10 @@ async function A(e, t, s, n = {}) {
581
581
  params: t,
582
582
  req_id: s
583
583
  },
584
- capture: Ct(s)
584
+ capture: Rt(s)
585
585
  });
586
586
  if (i)
587
- throw d(he, i);
587
+ throw d(pe, i);
588
588
  return r;
589
589
  }
590
590
  function X(...e) {
@@ -603,7 +603,7 @@ function Zs(...e) {
603
603
  i.length && (t[n] = i);
604
604
  }), t), {});
605
605
  }
606
- function At(e) {
606
+ function It(e) {
607
607
  const t = Et(e);
608
608
  return Math.sqrt(
609
609
  [0.299, 0.587, 0.114].reduce((s, n, r) => {
@@ -638,12 +638,12 @@ class nt {
638
638
  c(this, "state"), c(this, "get"), c(this, "set"), c(this, "clone"), this.state = new ke(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);
639
639
  }
640
640
  }
641
- function It(e, t) {
641
+ function kt(e, t) {
642
642
  return (s) => x(t[s], e);
643
643
  }
644
644
  class rt extends nt {
645
645
  constructor(t, s, n) {
646
- super(t), c(this, "supports"), this.supports = It(s, n);
646
+ super(t), c(this, "supports"), this.supports = kt(s, n);
647
647
  }
648
648
  }
649
649
  class Oe extends rt {
@@ -678,7 +678,7 @@ class Oe extends rt {
678
678
  function S() {
679
679
  return typeof window > "u";
680
680
  }
681
- const kt = R((e) => e instanceof Date ? e : new Date(E().parse(e) * 1e3), "Date");
681
+ const Ot = R((e) => e instanceof Date ? e : new Date(E().parse(e) * 1e3), "Date");
682
682
  function it(e, t) {
683
683
  return new H((s) => {
684
684
  if (typeof s != "string" && !(s instanceof URLSearchParams))
@@ -735,10 +735,10 @@ const qe = f({
735
735
  },
736
736
  username: p().optional()
737
737
  }, "User").optional();
738
- function Ot() {
738
+ function qt() {
739
739
  return it({
740
740
  authDate: {
741
- type: kt(),
741
+ type: Ot(),
742
742
  from: "auth_date"
743
743
  },
744
744
  canSendAfter: {
@@ -773,21 +773,21 @@ function Ne(e) {
773
773
  function De(e) {
774
774
  return e.replace(/[A-Z]/g, (t) => `_${t.toLowerCase()}`);
775
775
  }
776
- const qt = R(
776
+ const Nt = R(
777
777
  (e) => {
778
778
  const t = Pt().optional();
779
779
  return Object.entries(et(e)).reduce((s, [n, r]) => (s[Ne(n)] = t.parse(r), s), {});
780
780
  },
781
781
  "ThemeParams"
782
782
  );
783
- function Nt(e) {
783
+ function Dt(e) {
784
784
  return it({
785
785
  botInline: {
786
786
  type: v().optional(),
787
787
  from: "tgWebAppBotInline"
788
788
  },
789
789
  initData: {
790
- type: Ot().optional(),
790
+ type: qt().optional(),
791
791
  from: "tgWebAppData"
792
792
  },
793
793
  initDataRaw: {
@@ -807,7 +807,7 @@ function Nt(e) {
807
807
  from: "tgWebAppStartParam"
808
808
  },
809
809
  themeParams: {
810
- type: qt(),
810
+ type: Nt(),
811
811
  from: "tgWebAppThemeParams"
812
812
  },
813
813
  version: {
@@ -816,38 +816,38 @@ function Nt(e) {
816
816
  }
817
817
  }).parse(e);
818
818
  }
819
- function Dt(e) {
820
- return Nt(
819
+ function Vt(e) {
820
+ return Dt(
821
821
  e.replace(/^[^?#]*[?#]/, "").replace(/[?#]/g, "&")
822
822
  );
823
823
  }
824
824
  function Ve() {
825
- return Dt(window.location.href);
825
+ return Vt(window.location.href);
826
826
  }
827
- function Vt() {
827
+ function Mt() {
828
828
  return performance.getEntriesByType("navigation")[0];
829
829
  }
830
830
  function Me() {
831
- const e = Vt();
831
+ const e = Mt();
832
832
  if (!e)
833
833
  throw new Error("Unable to get first navigation entry.");
834
- return Dt(e.name);
834
+ return Vt(e.name);
835
835
  }
836
- function Mt(e) {
836
+ function Bt(e) {
837
837
  return `tma.js/${e.replace(/[A-Z]/g, (t) => `-${t.toLowerCase()}`)}`;
838
838
  }
839
- function Bt(e, t) {
840
- sessionStorage.setItem(Mt(e), JSON.stringify(t));
839
+ function $t(e, t) {
840
+ sessionStorage.setItem(Bt(e), JSON.stringify(t));
841
841
  }
842
- function $t(e) {
843
- const t = sessionStorage.getItem(Mt(e));
842
+ function Lt(e) {
843
+ const t = sessionStorage.getItem(Bt(e));
844
844
  try {
845
845
  return t ? JSON.parse(t) : void 0;
846
846
  } catch {
847
847
  }
848
848
  }
849
849
  function Be() {
850
- return Nt($t("launchParams") || "");
850
+ return Dt(Lt("launchParams") || "");
851
851
  }
852
852
  function $e(e) {
853
853
  return JSON.stringify(
@@ -869,7 +869,7 @@ function Le(e) {
869
869
  return h.set("tgWebAppPlatform", n), h.set("tgWebAppThemeParams", $e(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();
870
870
  }
871
871
  function Ue(e) {
872
- Bt("launchParams", Le(e));
872
+ $t("launchParams", Le(e));
873
873
  }
874
874
  function He() {
875
875
  for (const e of [
@@ -888,8 +888,8 @@ function He() {
888
888
  }
889
889
  throw new Error("Unable to retrieve launch parameters from any known source.");
890
890
  }
891
- function Lt() {
892
- const e = Vt();
891
+ function Ut() {
892
+ const e = Mt();
893
893
  return !!(e && e.type === "reload");
894
894
  }
895
895
  function We() {
@@ -913,7 +913,7 @@ function l(e, t) {
913
913
  ...n,
914
914
  postEvent: "version" in n ? Ie(n.version) : () => {
915
915
  throw d(
916
- _e,
916
+ ge,
917
917
  "postEvent function is forbidden to be called on the server side."
918
918
  );
919
919
  },
@@ -923,9 +923,9 @@ function l(e, t) {
923
923
  return typeof e == "function" ? e(r) : t(r);
924
924
  const i = t({
925
925
  ...r,
926
- state: Lt() ? $t(e) : void 0
926
+ state: Ut() ? Lt(e) : void 0
927
927
  }), o = (a) => (a.on("change", (h) => {
928
- Bt(e, h);
928
+ $t(e, h);
929
929
  }), a);
930
930
  return i instanceof Promise ? i.then(o) : o(i);
931
931
  };
@@ -940,7 +940,7 @@ class N extends rt {
940
940
  super(...arguments), c(this, "on", this.state.on.bind(this.state)), c(this, "off", this.state.off.bind(this.state));
941
941
  }
942
942
  }
943
- function Ut(e) {
943
+ function Ht(e) {
944
944
  const t = e.available ? e : {
945
945
  available: !1,
946
946
  device_id: "",
@@ -1036,7 +1036,7 @@ class _t extends N {
1036
1036
  event: "biometry_info_received",
1037
1037
  params: { reason: t || "" }
1038
1038
  }).then((n) => {
1039
- const r = Ut(n);
1039
+ const r = Ht(n);
1040
1040
  return this.set(r), r.accessGranted;
1041
1041
  }).finally(() => this.accessPromise = void 0)), this.accessPromise;
1042
1042
  }
@@ -1069,7 +1069,7 @@ class _t extends N {
1069
1069
  }
1070
1070
  }
1071
1071
  async function ze(e) {
1072
- return Ut(
1072
+ return Ht(
1073
1073
  await m({
1074
1074
  ...e || {},
1075
1075
  method: "web_app_biometry_get_info",
@@ -1129,7 +1129,7 @@ const Qe = l("closingBehavior", ({
1129
1129
  }) => new Je(t.isConfirmationNeeded, e));
1130
1130
  class at {
1131
1131
  constructor(t, s) {
1132
- c(this, "supports"), this.supports = It(t, s);
1132
+ c(this, "supports"), this.supports = kt(t, s);
1133
1133
  }
1134
1134
  }
1135
1135
  function Fe(e) {
@@ -1357,7 +1357,7 @@ const rs = l(
1357
1357
  ({ initData: e }) => e ? new ns(e) : void 0
1358
1358
  );
1359
1359
  function Xs(e) {
1360
- return Ot().parse(e);
1360
+ return qt().parse(e);
1361
1361
  }
1362
1362
  class is extends N {
1363
1363
  constructor(t, s, n) {
@@ -1570,13 +1570,13 @@ function hs() {
1570
1570
  }
1571
1571
  }),
1572
1572
  authDate: {
1573
- type: kt(),
1573
+ type: Ot(),
1574
1574
  from: "auth_date"
1575
1575
  },
1576
1576
  hash: p()
1577
1577
  }, "RequestedContact");
1578
1578
  }
1579
- function Ht(e, t) {
1579
+ function Wt(e, t) {
1580
1580
  return (s) => {
1581
1581
  const [n, r] = t[s];
1582
1582
  return x(n, r, e);
@@ -1597,7 +1597,7 @@ class us extends N {
1597
1597
  setBackgroundColor: "web_app_set_background_color"
1598
1598
  }), c(this, "botInline"), c(this, "postEvent"), c(this, "createRequestId"), c(this, "requestPhoneAccessPromise"), c(this, "requestWriteAccessPromise"), c(this, "supportsParam"), this.createRequestId = s, this.postEvent = t, this.botInline = r;
1599
1599
  const o = this.supports.bind(this);
1600
- this.supports = (a) => o(a) ? a !== "switchInlineQuery" || r : !1, this.supportsParam = Ht(n, {
1600
+ this.supports = (a) => o(a) ? a !== "switchInlineQuery" || r : !1, this.supportsParam = Wt(n, {
1601
1601
  "setHeaderColor.color": ["web_app_set_header_color", "color"]
1602
1602
  });
1603
1603
  }
@@ -1648,7 +1648,7 @@ class us extends N {
1648
1648
  * True if current Mini App background color is recognized as dark.
1649
1649
  */
1650
1650
  get isDark() {
1651
- return At(this.bgColor);
1651
+ return It(this.bgColor);
1652
1652
  }
1653
1653
  /**
1654
1654
  * Informs the Telegram app that the Mini App is ready to be displayed.
@@ -1677,7 +1677,7 @@ class us extends N {
1677
1677
  throw new Error("Access denied.");
1678
1678
  const s = Date.now() + t;
1679
1679
  let n = 50;
1680
- return Tt(async () => {
1680
+ return At(async () => {
1681
1681
  for (; Date.now() < s; ) {
1682
1682
  try {
1683
1683
  return await this.getRequestedContact();
@@ -1685,7 +1685,7 @@ class us extends N {
1685
1685
  }
1686
1686
  await ps(n), n += 50;
1687
1687
  }
1688
- throw Rt(t);
1688
+ throw Tt(t);
1689
1689
  }, t);
1690
1690
  }
1691
1691
  /**
@@ -1926,8 +1926,8 @@ const bs = l("settingsButton", ({
1926
1926
  postEvent: t,
1927
1927
  state: s = { isVisible: !1 }
1928
1928
  }) => new ws(s.isVisible, e, t));
1929
- function Wt(e) {
1930
- return qt().parse(e);
1929
+ function jt(e) {
1930
+ return Nt().parse(e);
1931
1931
  }
1932
1932
  class vs extends ot {
1933
1933
  /**
@@ -1968,7 +1968,7 @@ class vs extends ot {
1968
1968
  * value is calculated according to theme bg color.
1969
1969
  */
1970
1970
  get isDark() {
1971
- return !this.bgColor || At(this.bgColor);
1971
+ return !this.bgColor || It(this.bgColor);
1972
1972
  }
1973
1973
  get linkColor() {
1974
1974
  return this.get("linkColor");
@@ -1994,7 +1994,7 @@ class vs extends ot {
1994
1994
  */
1995
1995
  listen() {
1996
1996
  return b("theme_changed", (t) => {
1997
- this.set(Wt(t.theme_params));
1997
+ this.set(jt(t.theme_params));
1998
1998
  });
1999
1999
  }
2000
2000
  /**
@@ -2016,11 +2016,11 @@ function tn(e = {}) {
2016
2016
  ...e,
2017
2017
  method: "web_app_request_theme",
2018
2018
  event: "theme_changed"
2019
- }).then(Wt);
2019
+ }).then(jt);
2020
2020
  }
2021
2021
  class Es extends at {
2022
2022
  constructor(t, s, n) {
2023
- super(t, { readTextFromClipboard: "web_app_read_text_from_clipboard" }), c(this, "supportsParam"), this.version = t, this.createRequestId = s, this.postEvent = n, this.supportsParam = Ht(t, {
2023
+ super(t, { readTextFromClipboard: "web_app_read_text_from_clipboard" }), c(this, "supportsParam"), this.version = t, this.createRequestId = s, this.postEvent = n, this.supportsParam = Wt(t, {
2024
2024
  "openLink.tryInstantView": ["web_app_open_link", "try_instant_view"]
2025
2025
  });
2026
2026
  }
@@ -2074,7 +2074,7 @@ class Es extends at {
2074
2074
  event: "clipboard_text_received",
2075
2075
  postEvent: this.postEvent,
2076
2076
  params: { req_id: t },
2077
- capture: Ct(t)
2077
+ capture: Rt(t)
2078
2078
  });
2079
2079
  return s;
2080
2080
  }
@@ -2082,7 +2082,7 @@ class Es extends at {
2082
2082
  const Ps = l(
2083
2083
  ({ version: e, postEvent: t, createRequestId: s }) => new Es(e, s, t)
2084
2084
  );
2085
- async function jt(e = {}) {
2085
+ async function Gt(e = {}) {
2086
2086
  const {
2087
2087
  is_expanded: t,
2088
2088
  is_state_stable: s,
@@ -2097,7 +2097,7 @@ async function jt(e = {}) {
2097
2097
  function T(e) {
2098
2098
  return e < 0 ? 0 : e;
2099
2099
  }
2100
- class Gt extends ot {
2100
+ class zt extends ot {
2101
2101
  constructor({ postEvent: t, stableHeight: s, height: n, width: r, isExpanded: i }) {
2102
2102
  super({
2103
2103
  height: T(n),
@@ -2112,7 +2112,7 @@ class Gt extends ot {
2112
2112
  * @param options - options to request fresh data.
2113
2113
  */
2114
2114
  async sync(t) {
2115
- const { isStateStable: s, ...n } = await jt(t);
2115
+ const { isStateStable: s, ...n } = await Gt(t);
2116
2116
  this.set({
2117
2117
  ...n,
2118
2118
  stableHeight: s ? n.height : this.get("stableHeight")
@@ -2210,8 +2210,8 @@ async function xs(e, t = {}) {
2210
2210
  width: n,
2211
2211
  isExpanded: r,
2212
2212
  isStateStable: i
2213
- } = await jt({ ...t, postEvent: e });
2214
- return new Gt({
2213
+ } = await Gt({ ...t, postEvent: e });
2214
+ return new zt({
2215
2215
  postEvent: e,
2216
2216
  height: s,
2217
2217
  width: n,
@@ -2225,7 +2225,7 @@ function Ss({
2225
2225
  postEvent: s
2226
2226
  }) {
2227
2227
  let n = !1, r = 0, i = 0, o = 0;
2228
- return e ? (n = e.isExpanded, r = e.height, i = e.width, o = e.stableHeight) : ["macos", "tdesktop", "unigram", "webk", "weba", "web"].includes(t) && (n = !0, r = window.innerHeight, i = window.innerWidth, o = window.innerHeight), new Gt({
2228
+ return e ? (n = e.isExpanded, r = e.height, i = e.width, o = e.stableHeight) : ["macos", "tdesktop", "unigram", "webk", "weba", "web"].includes(t) && (n = !0, r = window.innerHeight, i = window.innerWidth, o = window.innerHeight), new zt({
2229
2229
  postEvent: s,
2230
2230
  height: r,
2231
2231
  width: i,
@@ -2305,6 +2305,8 @@ function Rs(e = !0) {
2305
2305
  return k("iframe_ready", { reload_supported: !0 }), s;
2306
2306
  }
2307
2307
  async function rn() {
2308
+ if (xt(window))
2309
+ return !0;
2308
2310
  try {
2309
2311
  return await m({ method: "web_app_request_theme", event: "theme_changed", timeout: 100 }), !0;
2310
2312
  } catch {
@@ -2328,10 +2330,10 @@ function z(e, t) {
2328
2330
  class As {
2329
2331
  constructor(t, s, n = k) {
2330
2332
  if (c(this, "history"), c(this, "ee", new L()), c(this, "attached", !1), c(this, "back", () => this.go(-1)), c(this, "on", this.ee.on.bind(this.ee)), c(this, "off", this.ee.off.bind(this.ee)), this._index = s, this.postEvent = n, t.length === 0)
2331
- throw d(de, "History should not be empty.");
2333
+ throw d(le, "History should not be empty.");
2332
2334
  if (s < 0 || s >= t.length)
2333
2335
  throw d(
2334
- le,
2336
+ _e,
2335
2337
  "Index should not be zero and higher or equal than history size."
2336
2338
  );
2337
2339
  this.history = t.map((r) => z(r, ""));
@@ -2492,11 +2494,11 @@ async function Is() {
2492
2494
  for (; e; )
2493
2495
  e = await I(-1);
2494
2496
  }
2495
- function zt(e) {
2497
+ function Kt(e) {
2496
2498
  return M(e).pathname;
2497
2499
  }
2498
2500
  const ft = 0, Q = 1, F = 2;
2499
- class Kt {
2501
+ class Jt {
2500
2502
  constructor(t, s, { postEvent: n, hashMode: r, base: i } = {}) {
2501
2503
  c(this, "navigator"), c(this, "ee", new L()), c(this, "hashMode"), c(this, "base"), c(this, "attached", !1), c(this, "onPopState", ({ state: o }) => {
2502
2504
  if (o === null)
@@ -2517,7 +2519,7 @@ class Kt {
2517
2519
  t.map((o) => J(o, "/")),
2518
2520
  s,
2519
2521
  n
2520
- ), this.navigator.on("change", this.onNavigatorChange), this.hashMode = r, this.base = zt(i || "");
2522
+ ), this.navigator.on("change", this.onNavigatorChange), this.hashMode = r, this.base = Kt(i || "");
2521
2523
  }
2522
2524
  /**
2523
2525
  * Attaches current navigator to the browser history allowing navigator to manipulate it.
@@ -2698,28 +2700,28 @@ function ks(e) {
2698
2700
  let n = B(
2699
2701
  e.hashMode ? s.includes("?") ? s.slice(1) : `?${s.slice(1)}` : t
2700
2702
  );
2701
- const r = e.base ? zt(e.base) : void 0;
2703
+ const r = e.base ? Kt(e.base) : void 0;
2702
2704
  if (r) {
2703
2705
  if (!n.startsWith(r))
2704
2706
  throw d(
2705
- ge,
2707
+ fe,
2706
2708
  `Path "${n}" expected to be starting with "${r}"`
2707
2709
  );
2708
2710
  n = n.slice(r.length);
2709
2711
  }
2710
- return new Kt([n], 0, e);
2712
+ return new Jt([n], 0, e);
2711
2713
  }
2712
2714
  function an(e) {
2713
2715
  const t = e.match(/#(.+)/);
2714
2716
  return t ? t[1] : null;
2715
2717
  }
2716
2718
  function Os(e, t) {
2717
- if (Lt()) {
2719
+ if (Ut()) {
2718
2720
  const s = sessionStorage.getItem(e);
2719
2721
  if (s)
2720
2722
  try {
2721
2723
  const { index: n, history: r } = JSON.parse(s);
2722
- return new Kt(r, n, t);
2724
+ return new Jt(r, n, t);
2723
2725
  } catch (n) {
2724
2726
  console.error("Unable to restore hash navigator state.", n);
2725
2727
  }
@@ -2738,9 +2740,9 @@ function _(e) {
2738
2740
  [t]: e(...n)
2739
2741
  }, r)));
2740
2742
  }
2741
- const Jt = Qt();
2743
+ const Qt = Ft();
2742
2744
  function qs() {
2743
- const e = Ft(Jt);
2745
+ const e = Yt(Qt);
2744
2746
  if (!e)
2745
2747
  throw new Error("useSDK was used outside of SDKProvider.");
2746
2748
  return e;
@@ -2752,7 +2754,7 @@ const Ns = g(Ge), hn = _(Ns), Ds = g(Ke), pn = _(Ds), Vs = g(Qe), un = _(Vs), Ms
2752
2754
  const t = /* @__PURE__ */ new Map(), s = (n, ...r) => {
2753
2755
  if (t.has(n))
2754
2756
  return t.get(n);
2755
- const [i] = Zt(() => {
2757
+ const [i] = Xt(() => {
2756
2758
  try {
2757
2759
  return n(...r);
2758
2760
  } catch (h) {
@@ -2766,7 +2768,7 @@ const Ns = g(Ge), hn = _(Ns), Ds = g(Ke), pn = _(Ds), Vs = g(Qe), un = _(Vs), Ms
2766
2768
  const h = i();
2767
2769
  if (Array.isArray(h) || !h || !("on" in h))
2768
2770
  return h;
2769
- const u = Xt((V) => (V(h), h.on("change", () => V(h)))), D = Object.getPrototypeOf(h), G = {};
2771
+ const u = te((V) => (V(h), h.on("change", () => V(h)))), D = Object.getPrototypeOf(h), G = {};
2770
2772
  return new Proxy(h, {
2771
2773
  get(V, P) {
2772
2774
  if (!(P in G)) {
@@ -2791,10 +2793,10 @@ const Ns = g(Ge), hn = _(Ns), Ds = g(Ke), pn = _(Ds), Vs = g(Qe), un = _(Vs), Ms
2791
2793
  }), t.set(n, a), a;
2792
2794
  };
2793
2795
  return pt(() => {
2794
- re(e.debug || !1);
2796
+ ie(e.debug || !1);
2795
2797
  }), pt(() => {
2796
- xt() && Yt(Rs(e.acceptCustomStyles));
2797
- }), mt(Jt.Provider, {
2798
+ St() && Zt(Rs(e.acceptCustomStyles));
2799
+ }), mt(Qt.Provider, {
2798
2800
  value: s,
2799
2801
  get children() {
2800
2802
  return e.children;
@@ -2805,22 +2807,22 @@ export {
2805
2807
  Oe as BackButton,
2806
2808
  As as BasicNavigator,
2807
2809
  _t as BiometryManager,
2808
- Kt as BrowserNavigator,
2810
+ Jt as BrowserNavigator,
2809
2811
  Je as ClosingBehavior,
2810
2812
  Xe as CloudStorage,
2811
- ge as ERR_INVALID_PATH_BASE,
2812
- he as ERR_INVOKE_CUSTOM_METHOD_RESPONSE,
2813
- ae as ERR_METHOD_PARAMETER_UNSUPPORTED,
2814
- oe as ERR_METHOD_UNSUPPORTED,
2815
- de as ERR_NAVIGATION_HISTORY_EMPTY,
2816
- le as ERR_NAVIGATION_INDEX_INVALID,
2813
+ fe as ERR_INVALID_PATH_BASE,
2814
+ pe as ERR_INVOKE_CUSTOM_METHOD_RESPONSE,
2815
+ ce as ERR_METHOD_PARAMETER_UNSUPPORTED,
2816
+ ae as ERR_METHOD_UNSUPPORTED,
2817
+ le as ERR_NAVIGATION_HISTORY_EMPTY,
2818
+ _e as ERR_NAVIGATION_INDEX_INVALID,
2817
2819
  Fs as ERR_NAVIGATION_ITEM_INVALID,
2818
2820
  vt as ERR_PARSE,
2819
2821
  tt as ERR_SSR_INIT,
2820
- _e as ERR_SSR_POST_EVENT,
2821
- pe as ERR_TIMED_OUT,
2822
- ue as ERR_UNEXPECTED_TYPE,
2823
- ce as ERR_UNKNOWN_ENV,
2822
+ ge as ERR_SSR_POST_EVENT,
2823
+ ue as ERR_TIMED_OUT,
2824
+ de as ERR_UNEXPECTED_TYPE,
2825
+ he as ERR_UNKNOWN_ENV,
2824
2826
  L as EventEmitter,
2825
2827
  es as HapticFeedback,
2826
2828
  ns as InitData,
@@ -2834,21 +2836,21 @@ export {
2834
2836
  ws as SettingsButton,
2835
2837
  vs as ThemeParams,
2836
2838
  Es as Utils,
2837
- Gt as Viewport,
2839
+ zt as Viewport,
2838
2840
  Ze as array,
2839
2841
  en as bindMiniAppCSSVars,
2840
2842
  sn as bindThemeParamsCSSVars,
2841
2843
  nn as bindViewportCSSVars,
2842
2844
  v as boolean,
2843
- Ct as captureSameReq,
2845
+ Rt as captureSameReq,
2844
2846
  X as classNames,
2845
- Ce as compareVersions,
2847
+ Re as compareVersions,
2846
2848
  ks as createBrowserNavigatorFromLocation,
2847
2849
  Ie as createPostEvent,
2848
2850
  M as createSafeURL,
2849
- kt as date,
2851
+ Ot as date,
2850
2852
  an as getHash,
2851
- zt as getPathname,
2853
+ Kt as getPathname,
2852
2854
  Ge as initBackButton,
2853
2855
  Ke as initBiometryManager,
2854
2856
  Qe as initClosingBehavior,
@@ -2867,13 +2869,14 @@ export {
2867
2869
  Cs as initViewport,
2868
2870
  Rs as initWeb,
2869
2871
  A as invokeCustomMethod,
2870
- At as isColorDark,
2871
- xt as isIframe,
2872
- Lt as isPageReload,
2872
+ It as isColorDark,
2873
+ St as isIframe,
2874
+ Ut as isPageReload,
2873
2875
  st as isRGB,
2874
- fe as isRGBShort,
2876
+ me as isRGBShort,
2875
2877
  Ts as isSDKError,
2876
2878
  on as isSDKErrorOfType,
2879
+ S as isSSR,
2877
2880
  rn as isTMA,
2878
2881
  f as json,
2879
2882
  Zs as mergeClassNames,
@@ -2881,23 +2884,23 @@ export {
2881
2884
  j as off,
2882
2885
  b as on,
2883
2886
  Xs as parseInitData,
2884
- Nt as parseLaunchParams,
2885
- Wt as parseThemeParams,
2887
+ Dt as parseLaunchParams,
2888
+ jt as parseThemeParams,
2886
2889
  k as postEvent,
2887
2890
  m as request,
2888
2891
  ze as requestBiometryInfo,
2889
2892
  tn as requestThemeParams,
2890
- jt as requestViewport,
2893
+ Gt as requestViewport,
2891
2894
  He as retrieveLaunchParams,
2892
2895
  Pt as rgb,
2893
2896
  it as searchParams,
2894
2897
  Le as serializeLaunchParams,
2895
2898
  $e as serializeThemeParams,
2896
2899
  y as setCSSVar,
2897
- re as setDebug,
2900
+ ie as setDebug,
2898
2901
  Ys as setTargetOrigin,
2899
2902
  p as string,
2900
- se as subscribe,
2903
+ ne as subscribe,
2901
2904
  x as supports,
2902
2905
  Ae as targetOrigin,
2903
2906
  Et as toRGB,
@@ -2932,7 +2935,7 @@ export {
2932
2935
  bn as withQRScanner,
2933
2936
  vn as withSettingsButton,
2934
2937
  yn as withThemeParams,
2935
- Tt as withTimeout,
2938
+ At as withTimeout,
2936
2939
  En as withUtils,
2937
2940
  Pn as withViewport
2938
2941
  };