@tma.js/sdk-react 2.2.2 → 2.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -31,12 +31,12 @@ class ue {
31
31
  second: "2-digit",
32
32
  fractionalSecondDigits: 3,
33
33
  timeZone: "UTC"
34
- }).format(n), { textColor: i, bgColor: a } = this.options, o = "font-weight: bold;padding: 0 5px;border-radius:5px";
34
+ }).format(n), { textColor: i, bgColor: o } = this.options, a = "font-weight: bold;padding: 0 5px;border-radius:5px";
35
35
  console[t](
36
36
  `%c${r}%c / %c${this.scope}`,
37
- `${o};background-color: lightblue;color:black`,
37
+ `${a};background-color: lightblue;color:black`,
38
38
  "",
39
- `${o};${i ? `color:${i};` : ""}${a ? `background-color:${a}` : ""}`,
39
+ `${a};${i ? `color:${i};` : ""}${o ? `background-color:${o}` : ""}`,
40
40
  ...s
41
41
  );
42
42
  }
@@ -210,18 +210,18 @@ function Tt(e, t) {
210
210
  const r = e[n];
211
211
  if (!r)
212
212
  continue;
213
- let i, a;
213
+ let i, o;
214
214
  if (typeof r == "function" || "parse" in r)
215
- i = n, a = typeof r == "function" ? r : r.parse.bind(r);
215
+ i = n, o = typeof r == "function" ? r : r.parse.bind(r);
216
216
  else {
217
- const { type: o } = r;
218
- i = r.from || n, a = typeof o == "function" ? o : o.parse.bind(o);
217
+ const { type: a } = r;
218
+ i = r.from || n, o = typeof a == "function" ? a : a.parse.bind(a);
219
219
  }
220
220
  try {
221
- const o = a(t(i));
222
- o !== void 0 && (s[n] = o);
223
- } catch (o) {
224
- throw m(St, `Unable to parse field "${n}"`, o);
221
+ const a = o(t(i));
222
+ a !== void 0 && (s[n] = a);
223
+ } catch (a) {
224
+ throw m(St, `Unable to parse field "${n}"`, a);
225
225
  }
226
226
  }
227
227
  return s;
@@ -380,9 +380,9 @@ function Se() {
380
380
  } catch {
381
381
  return;
382
382
  }
383
- const { eventType: i, eventData: a } = r, o = Ce[i];
383
+ const { eventType: i, eventData: o } = r, a = Ce[i];
384
384
  try {
385
- const p = o ? o.parse(a) : a;
385
+ const p = a ? a.parse(o) : o;
386
386
  t.emit(...p ? [i, p] : [i]);
387
387
  } catch (p) {
388
388
  nt.error(
@@ -414,8 +414,8 @@ const [Te, Ae] = xt(
414
414
  (e) => {
415
415
  const [t, s] = Se(), n = t.off.bind(t);
416
416
  return t.off = (r, i) => {
417
- const { count: a } = t;
418
- n(r, i), a && !t.count && e();
417
+ const { count: o } = t;
418
+ n(r, i), o && !t.count && e();
419
419
  }, [t, s];
420
420
  },
421
421
  ([, e]) => e()
@@ -435,9 +435,9 @@ function V(e) {
435
435
  function Ie(e, t) {
436
436
  const s = e.split("."), n = t.split("."), r = Math.max(s.length, n.length);
437
437
  for (let i = 0; i < r; i += 1) {
438
- const a = parseInt(s[i] || "0", 10), o = parseInt(n[i] || "0", 10);
439
- if (a !== o)
440
- return a > o ? 1 : -1;
438
+ const o = parseInt(s[i] || "0", 10), a = parseInt(n[i] || "0", 10);
439
+ if (o !== a)
440
+ return o > a ? 1 : -1;
441
441
  }
442
442
  return 0;
443
443
  }
@@ -569,17 +569,17 @@ function Mt(e, t) {
569
569
  }
570
570
  async function g(e) {
571
571
  let t;
572
- const s = new Promise((o) => {
573
- t = o;
574
- }), { event: n, capture: r, timeout: i } = e, [, a] = rt(
572
+ const s = new Promise((a) => {
573
+ t = a;
574
+ }), { event: n, capture: r, timeout: i } = e, [, o] = rt(
575
575
  ...(Array.isArray(n) ? n : [n]).map(
576
- (o) => y(o, (p) => (!r || r(p)) && t(p))
576
+ (a) => y(a, (p) => (!r || r(p)) && t(p))
577
577
  )
578
578
  );
579
579
  try {
580
580
  return (e.postEvent || B)(e.method, e.params), await (i ? Mt(s, i) : s);
581
581
  } finally {
582
- a();
582
+ o();
583
583
  }
584
584
  }
585
585
  async function O(e, t, s, n = {}) {
@@ -652,12 +652,12 @@ class ct {
652
652
  c(this, "state"), c(this, "get"), c(this, "set"), c(this, "clone"), this.state = new Oe(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);
653
653
  }
654
654
  }
655
- function $t(e, t) {
655
+ function Lt(e, t) {
656
656
  return (s) => x(t[s], e);
657
657
  }
658
658
  class ht extends ct {
659
659
  constructor(t, s, n) {
660
- super(t), c(this, "supports"), this.supports = $t(s, n);
660
+ super(t), c(this, "supports"), this.supports = Lt(s, n);
661
661
  }
662
662
  }
663
663
  class Ne extends ht {
@@ -689,7 +689,7 @@ class Ne extends ht {
689
689
  this.isVisible = !0;
690
690
  }
691
691
  }
692
- const Lt = A((e) => e instanceof Date ? e : new Date(R().parse(e) * 1e3), "Date");
692
+ const $t = A((e) => e instanceof Date ? e : new Date(R().parse(e) * 1e3), "Date");
693
693
  function pt(e, t) {
694
694
  return new G((s) => {
695
695
  if (typeof s != "string" && !(s instanceof URLSearchParams))
@@ -746,10 +746,10 @@ const De = w({
746
746
  },
747
747
  username: h().optional()
748
748
  }, "User").optional();
749
- function Ht() {
749
+ function Ut() {
750
750
  return pt({
751
751
  authDate: {
752
- type: Lt(),
752
+ type: $t(),
753
753
  from: "auth_date"
754
754
  },
755
755
  canSendAfter: {
@@ -784,7 +784,7 @@ function Be(e) {
784
784
  function Me(e) {
785
785
  return e.replace(/[A-Z]/g, (t) => `_${t.toLowerCase()}`);
786
786
  }
787
- const Ut = A(
787
+ const Ht = A(
788
788
  (e) => {
789
789
  const t = It().optional();
790
790
  return Object.entries(it(e)).reduce((s, [n, r]) => (s[Be(n)] = t.parse(r), s), {});
@@ -798,7 +798,7 @@ function ut(e) {
798
798
  from: "tgWebAppBotInline"
799
799
  },
800
800
  initData: {
801
- type: Ht().optional(),
801
+ type: Ut().optional(),
802
802
  from: "tgWebAppData"
803
803
  },
804
804
  initDataRaw: {
@@ -818,7 +818,7 @@ function ut(e) {
818
818
  from: "tgWebAppStartParam"
819
819
  },
820
820
  themeParams: {
821
- type: Ut(),
821
+ type: Ht(),
822
822
  from: "tgWebAppThemeParams"
823
823
  },
824
824
  version: {
@@ -838,7 +838,7 @@ function Ve() {
838
838
  function Gt() {
839
839
  return performance.getEntriesByType("navigation")[0];
840
840
  }
841
- function $e() {
841
+ function Le() {
842
842
  const e = Gt();
843
843
  if (!e)
844
844
  throw new Error("Unable to get first navigation entry.");
@@ -857,7 +857,7 @@ function Kt(e) {
857
857
  } catch {
858
858
  }
859
859
  }
860
- function Le() {
860
+ function $e() {
861
861
  return ut(Kt("launchParams") || "");
862
862
  }
863
863
  function Jt(e) {
@@ -867,20 +867,20 @@ function Jt(e) {
867
867
  )
868
868
  );
869
869
  }
870
- function He(e) {
870
+ function Ue(e) {
871
871
  const {
872
872
  initDataRaw: t,
873
873
  themeParams: s,
874
874
  platform: n,
875
875
  version: r,
876
876
  showSettings: i,
877
- startParam: a,
878
- botInline: o
877
+ startParam: o,
878
+ botInline: a
879
879
  } = e, p = new URLSearchParams();
880
- return p.set("tgWebAppPlatform", n), p.set("tgWebAppThemeParams", Jt(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();
880
+ return p.set("tgWebAppPlatform", n), p.set("tgWebAppThemeParams", Jt(s)), p.set("tgWebAppVersion", r), t && p.set("tgWebAppData", t), o && p.set("tgWebAppStartParam", o), typeof i == "boolean" && p.set("tgWebAppShowSettings", i ? "1" : "0"), typeof a == "boolean" && p.set("tgWebAppBotInline", a ? "1" : "0"), p.toString();
881
881
  }
882
882
  function Ft(e) {
883
- zt("launchParams", He(e));
883
+ zt("launchParams", Ue(e));
884
884
  }
885
885
  function Qt() {
886
886
  for (const e of [
@@ -888,9 +888,9 @@ function Qt() {
888
888
  // nothing in case, location was changed and then page was reloaded.
889
889
  Ve,
890
890
  // Then, try using the lower level API - window.performance.
891
- $e,
891
+ Le,
892
892
  // Finally, try to extract launch parameters from the session storage.
893
- Le
893
+ $e
894
894
  ])
895
895
  try {
896
896
  const t = e();
@@ -903,11 +903,11 @@ function Yt() {
903
903
  const e = Gt();
904
904
  return !!(e && e.type === "reload");
905
905
  }
906
- function Ue() {
906
+ function He() {
907
907
  let e = 0;
908
908
  return () => (e += 1).toString();
909
909
  }
910
- const [We] = xt(Ue);
910
+ const [We] = xt(He);
911
911
  function l(e, t) {
912
912
  return () => {
913
913
  const s = Qt(), n = {
@@ -917,20 +917,20 @@ function l(e, t) {
917
917
  };
918
918
  if (typeof e == "function")
919
919
  return e(n);
920
- const [r, i, a] = rt(), o = t({
920
+ const [r, i, o] = rt(), a = t({
921
921
  ...n,
922
922
  // State should only be passed only in case, current page was reloaded. If we don't add
923
923
  // this check, state restoration will work improperly in the web version of Telegram,
924
924
  // when we are always working in the same "session" (tab).
925
925
  state: Yt() ? Kt(e) : void 0,
926
926
  addCleanup: r
927
- }), p = (u) => (a || r(
927
+ }), p = (u) => (o || r(
928
928
  u.on("change", (C) => {
929
929
  zt(e, C);
930
930
  })
931
931
  ), u);
932
932
  return [
933
- o instanceof Promise ? o.then(p) : p(o),
933
+ a instanceof Promise ? a.then(p) : p(a),
934
934
  i
935
935
  ];
936
936
  };
@@ -940,7 +940,7 @@ const Ge = l("backButton", ({
940
940
  version: t,
941
941
  state: s = { isVisible: !1 }
942
942
  }) => new Ne(s.isVisible, t, e));
943
- class $ extends ht {
943
+ class L extends ht {
944
944
  constructor() {
945
945
  super(...arguments), c(this, "on", this.state.on.bind(this.state)), c(this, "off", this.state.off.bind(this.state));
946
946
  }
@@ -963,7 +963,7 @@ function Zt(e) {
963
963
  accessGranted: t.access_granted
964
964
  };
965
965
  }
966
- class je extends $ {
966
+ class je extends L {
967
967
  constructor({ postEvent: t, version: s, ...n }) {
968
968
  super(n, s, {
969
969
  auth: "web_app_biometry_request_auth",
@@ -1137,7 +1137,7 @@ const Fe = l(
1137
1137
  );
1138
1138
  class dt {
1139
1139
  constructor(t, s) {
1140
- c(this, "supports"), this.supports = $t(t, s);
1140
+ c(this, "supports"), this.supports = Lt(t, s);
1141
1141
  }
1142
1142
  }
1143
1143
  function Qe(e) {
@@ -1365,9 +1365,9 @@ const rs = l(
1365
1365
  ({ initData: e }) => e ? new ns(e) : void 0
1366
1366
  );
1367
1367
  function fn(e) {
1368
- return Ht().parse(e);
1368
+ return Ut().parse(e);
1369
1369
  }
1370
- class is extends $ {
1370
+ class is extends L {
1371
1371
  constructor(t, s, n) {
1372
1372
  super({ isOpened: t }, s, { open: "web_app_open_invoice" }), this.postEvent = n;
1373
1373
  }
@@ -1390,10 +1390,10 @@ class is extends $ {
1390
1390
  const { hostname: r, pathname: i } = new URL(t, window.location.href);
1391
1391
  if (r !== "t.me")
1392
1392
  throw new Error(`Incorrect hostname: ${r}`);
1393
- const a = i.match(/^\/(\$|invoice\/)([A-Za-z0-9\-_=]+)$/);
1394
- if (!a)
1393
+ const o = i.match(/^\/(\$|invoice\/)([A-Za-z0-9\-_=]+)$/);
1394
+ if (!o)
1395
1395
  throw new Error('Link pathname has incorrect format. Expected to receive "/invoice/{slug}" or "/${slug}"');
1396
- [, , n] = a;
1396
+ [, , n] = o;
1397
1397
  }
1398
1398
  this.isOpened = !0;
1399
1399
  try {
@@ -1581,7 +1581,7 @@ function hs() {
1581
1581
  }
1582
1582
  }),
1583
1583
  authDate: {
1584
- type: Lt(),
1584
+ type: $t(),
1585
1585
  from: "auth_date"
1586
1586
  },
1587
1587
  hash: h()
@@ -1598,7 +1598,7 @@ function ps(e) {
1598
1598
  setTimeout(t, e);
1599
1599
  });
1600
1600
  }
1601
- class us extends $ {
1601
+ class us extends L {
1602
1602
  constructor({ postEvent: t, createRequestId: s, version: n, botInline: r, ...i }) {
1603
1603
  super(i, n, {
1604
1604
  requestPhoneAccess: "web_app_request_phone",
@@ -1607,8 +1607,8 @@ class us extends $ {
1607
1607
  setHeaderColor: "web_app_set_header_color",
1608
1608
  setBackgroundColor: "web_app_set_background_color"
1609
1609
  }), 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;
1610
- const a = this.supports.bind(this);
1611
- this.supports = (o) => a(o) ? o !== "switchInlineQuery" || r : !1, this.supportsParam = Xt(n, {
1610
+ const o = this.supports.bind(this);
1611
+ this.supports = (a) => o(a) ? a !== "switchInlineQuery" || r : !1, this.supportsParam = Xt(n, {
1612
1612
  "setHeaderColor.color": ["web_app_set_header_color", "color"]
1613
1613
  });
1614
1614
  }
@@ -1801,21 +1801,21 @@ function ds(e) {
1801
1801
  if (n.length > 3)
1802
1802
  throw new Error(`Buttons have incorrect size: ${n.length}`);
1803
1803
  return n.length ? r = n.map((i) => {
1804
- const { id: a = "" } = i;
1805
- if (a.length > 64)
1806
- throw new Error(`Button ID has incorrect size: ${a}`);
1804
+ const { id: o = "" } = i;
1805
+ if (o.length > 64)
1806
+ throw new Error(`Button ID has incorrect size: ${o}`);
1807
1807
  if (!i.type || i.type === "default" || i.type === "destructive") {
1808
- const o = i.text.trim();
1809
- if (!o.length || o.length > 64) {
1808
+ const a = i.text.trim();
1809
+ if (!a.length || a.length > 64) {
1810
1810
  const p = i.type || "default";
1811
1811
  throw new Error(`Button text with type "${p}" has incorrect size: ${i.text.length}`);
1812
1812
  }
1813
- return { ...i, text: o, id: a };
1813
+ return { ...i, text: a, id: o };
1814
1814
  }
1815
- return { ...i, id: a };
1815
+ return { ...i, id: o };
1816
1816
  }) : r = [{ type: "close", id: "" }], { title: s, message: t, buttons: r };
1817
1817
  }
1818
- class _s extends $ {
1818
+ class _s extends L {
1819
1819
  constructor(t, s, n) {
1820
1820
  super({ isOpened: t }, s, { open: "web_app_open_popup" }), this.postEvent = n;
1821
1821
  }
@@ -1859,7 +1859,7 @@ class _s extends $ {
1859
1859
  const ws = l(
1860
1860
  ({ postEvent: e, version: t }) => new _s(!1, t, e)
1861
1861
  );
1862
- class gs extends $ {
1862
+ class gs extends L {
1863
1863
  constructor(t, s, n) {
1864
1864
  super({ isOpened: t }, s, {
1865
1865
  close: "web_app_close_scan_qr_popup",
@@ -1943,7 +1943,7 @@ const bs = l(
1943
1943
  }) => new ms(s.isVisible, e, t)
1944
1944
  );
1945
1945
  function te(e) {
1946
- return Ut().parse(e);
1946
+ return Ht().parse(e);
1947
1947
  }
1948
1948
  class vs extends lt {
1949
1949
  /**
@@ -2070,7 +2070,7 @@ class Es extends dt {
2070
2070
  * @throws {Error} URL has not allowed hostname.
2071
2071
  */
2072
2072
  openTelegramLink(t) {
2073
- const { hostname: s, pathname: n, search: r } = new URL(t, window.location.href);
2073
+ const { hostname: s, pathname: n, search: r } = new URL(t, "https://t.me");
2074
2074
  if (s !== "t.me")
2075
2075
  throw new Error(`URL has not allowed hostname: ${s}. Only "t.me" is allowed`);
2076
2076
  if (!x("web_app_open_tg_link", this.version)) {
@@ -2097,6 +2097,20 @@ class Es extends dt {
2097
2097
  });
2098
2098
  return s;
2099
2099
  }
2100
+ /**
2101
+ * Shares specified URL with the passed to the chats, selected by user. After being called,
2102
+ * it closes the mini application.
2103
+ *
2104
+ * This method uses Telegram's Share Links.
2105
+ * @param url - URL to share.
2106
+ * @param text - text to append after the URL.
2107
+ * @see https://core.telegram.org/api/links#share-links
2108
+ */
2109
+ shareURL(t, s) {
2110
+ this.openTelegramLink(
2111
+ "https://t.me/share?" + new URLSearchParams({ url: t, text: s || "" }).toString()
2112
+ );
2113
+ }
2100
2114
  }
2101
2115
  const Ps = l(
2102
2116
  ({ version: e, postEvent: t, createRequestId: s }) => new Es(e, s, t)
@@ -2184,12 +2198,12 @@ class Rs extends lt {
2184
2198
  width: n,
2185
2199
  is_expanded: r,
2186
2200
  is_state_stable: i
2187
- } = t, a = q(s);
2201
+ } = t, o = q(s);
2188
2202
  this.set({
2189
- height: a,
2203
+ height: o,
2190
2204
  isExpanded: r,
2191
2205
  width: q(n),
2192
- ...i ? { stableHeight: a } : {}
2206
+ ...i ? { stableHeight: o } : {}
2193
2207
  });
2194
2208
  });
2195
2209
  }
@@ -2226,20 +2240,20 @@ class Rs extends lt {
2226
2240
  const xs = l(
2227
2241
  "viewport",
2228
2242
  async ({ state: e, platform: t, postEvent: s, addCleanup: n }) => {
2229
- let r = !1, i = 0, a = 0, o = 0;
2243
+ let r = !1, i = 0, o = 0, a = 0;
2230
2244
  if (e)
2231
- r = e.isExpanded, i = e.height, a = e.width, o = e.stableHeight;
2245
+ r = e.isExpanded, i = e.height, o = e.width, a = e.stableHeight;
2232
2246
  else if (["macos", "tdesktop", "unigram", "webk", "weba", "web"].includes(t))
2233
- r = !0, i = window.innerHeight, a = window.innerWidth, o = window.innerHeight;
2247
+ r = !0, i = window.innerHeight, o = window.innerWidth, a = window.innerHeight;
2234
2248
  else {
2235
2249
  const u = await ee({ timeout: 1e3, postEvent: s });
2236
- r = u.isExpanded, i = u.height, a = u.width, o = u.isStateStable ? i : 0;
2250
+ r = u.isExpanded, i = u.height, o = u.width, a = u.isStateStable ? i : 0;
2237
2251
  }
2238
2252
  const p = new Rs({
2239
2253
  postEvent: s,
2240
2254
  height: i,
2241
- width: a,
2242
- stableHeight: o,
2255
+ width: o,
2256
+ stableHeight: a,
2243
2257
  isExpanded: r
2244
2258
  });
2245
2259
  return n(p.listen()), p;
@@ -2249,21 +2263,21 @@ function P(e, t) {
2249
2263
  document.documentElement.style.setProperty(e, t);
2250
2264
  }
2251
2265
  function bn(e, t, s) {
2252
- s || (s = (o) => `--tg-${o}-color`);
2266
+ s || (s = (a) => `--tg-${a}-color`);
2253
2267
  const n = s("header"), r = s("bg"), i = () => {
2254
- const { headerColor: o } = e;
2255
- if (ot(o))
2256
- P(n, o);
2268
+ const { headerColor: a } = e;
2269
+ if (ot(a))
2270
+ P(n, a);
2257
2271
  else {
2258
2272
  const { bgColor: p, secondaryBgColor: u } = t;
2259
- o === "bg_color" && p ? P(n, p) : o === "secondary_bg_color" && u && P(n, u);
2273
+ a === "bg_color" && p ? P(n, p) : a === "secondary_bg_color" && u && P(n, u);
2260
2274
  }
2261
2275
  P(r, e.bgColor);
2262
- }, a = [
2276
+ }, o = [
2263
2277
  t.on("change", i),
2264
2278
  e.on("change", i)
2265
2279
  ];
2266
- return i(), () => a.forEach((o) => o());
2280
+ return i(), () => o.forEach((a) => a());
2267
2281
  }
2268
2282
  function vn(e, t) {
2269
2283
  t || (t = (n) => `--tg-theme-${n.replace(/[A-Z]/g, (r) => `-${r.toLowerCase()}`)}`);
@@ -2280,12 +2294,12 @@ function yn(e, t) {
2280
2294
  s,
2281
2295
  n,
2282
2296
  r
2283
- ] = ["height", "width", "stable-height"].map((u) => t(u)), i = () => P(s, `${e.height}px`), a = () => P(n, `${e.width}px`), o = () => P(r, `${e.stableHeight}px`), p = [
2297
+ ] = ["height", "width", "stable-height"].map((u) => t(u)), i = () => P(s, `${e.height}px`), o = () => P(n, `${e.width}px`), a = () => P(r, `${e.stableHeight}px`), p = [
2284
2298
  e.on("change:height", i),
2285
- e.on("change:width", a),
2286
- e.on("change:stableHeight", o)
2299
+ e.on("change:width", o),
2300
+ e.on("change:stableHeight", a)
2287
2301
  ];
2288
- return i(), a(), o(), () => p.forEach((u) => u());
2302
+ return i(), o(), a(), () => p.forEach((u) => u());
2289
2303
  }
2290
2304
  function Cs(e = !0) {
2291
2305
  const t = [
@@ -2500,21 +2514,21 @@ function F({
2500
2514
  function M(e, t) {
2501
2515
  return e.startsWith(t) ? e : `${t}${e}`;
2502
2516
  }
2503
- function H(e) {
2517
+ function U(e) {
2504
2518
  return new URL(
2505
2519
  typeof e == "string" ? e : `${e.pathname || ""}${M(e.search || "", "?")}${M(e.hash || "", "#")}`,
2506
2520
  "http://a"
2507
2521
  );
2508
2522
  }
2509
- function U(e) {
2510
- const t = typeof e == "string" ? e.startsWith("/") : !!(e.pathname && e.pathname.startsWith("/")), s = H(e);
2523
+ function H(e) {
2524
+ const t = typeof e == "string" ? e.startsWith("/") : !!(e.pathname && e.pathname.startsWith("/")), s = U(e);
2511
2525
  return `${t ? s.pathname : s.pathname.slice(1)}${s.search}${s.hash}`;
2512
2526
  }
2513
2527
  function Q(e, t, s) {
2514
2528
  let n, r;
2515
- typeof e == "string" ? n = e : (n = U(e), s = e.state, r = e.id);
2516
- const { pathname: i, search: a, hash: o } = new URL(n, `http://a${M(t, "/")}`);
2517
- return { id: r, pathname: i, params: { hash: o, search: a, state: s } };
2529
+ typeof e == "string" ? n = e : (n = H(e), s = e.state, r = e.id);
2530
+ const { pathname: i, search: o, hash: a } = new URL(n, `http://a${M(t, "/")}`);
2531
+ return { id: r, pathname: i, params: { hash: a, search: o, state: s } };
2518
2532
  }
2519
2533
  async function N(e) {
2520
2534
  return e === 0 ? !0 : Promise.race([
@@ -2538,31 +2552,33 @@ async function Is() {
2538
2552
  e = await N(-1);
2539
2553
  }
2540
2554
  function se(e) {
2541
- return H(e).pathname;
2555
+ return U(e).pathname;
2542
2556
  }
2543
2557
  const yt = 0, Y = 1, Z = 2;
2544
2558
  class ne {
2545
2559
  constructor(t, s, { postEvent: n, hashMode: r = "classic", base: i } = {}) {
2546
- c(this, "navigator"), c(this, "ee", new D()), c(this, "hashMode"), c(this, "base"), c(this, "attached", !1), c(this, "onPopState", ({ state: a }) => {
2547
- if (a === null)
2560
+ c(this, "navigator"), c(this, "ee", new D()), c(this, "hashMode"), c(this, "base"), c(this, "attached", !1), c(this, "onPopState", ({ state: o }) => {
2561
+ if (o === null)
2548
2562
  return this.push(this.parsePath(window.location.href));
2549
- a === yt ? window.history.forward() : a === Y && this.back(), a === Z && this.forward();
2563
+ o === yt ? window.history.forward() : o === Y && this.back(), o === Z && this.forward();
2550
2564
  }), c(this, "onNavigatorChange", async ({
2551
- to: a,
2552
- from: o,
2565
+ to: o,
2566
+ from: a,
2553
2567
  delta: p
2554
2568
  }) => {
2555
2569
  this.attached && await this.syncHistory(), this.ee.emit("change", {
2556
2570
  delta: p,
2557
- from: F(o),
2558
- to: F(a),
2571
+ from: F(a),
2572
+ to: F(o),
2559
2573
  navigator: this
2560
2574
  });
2561
2575
  }), c(this, "on", this.ee.on.bind(this.ee)), c(this, "off", this.ee.off.bind(this.ee)), this.navigator = new As(
2562
- t.map((a) => Q(a, "/")),
2576
+ t.map((o) => Q(o, "/")),
2563
2577
  s,
2564
2578
  n
2565
- ), this.navigator.on("change", this.onNavigatorChange), this.hashMode = r, this.base = se(i || "");
2579
+ ), this.navigator.on("change", (o) => {
2580
+ this.onNavigatorChange(o);
2581
+ }), this.hashMode = r, this.base = se(i || "");
2566
2582
  }
2567
2583
  /**
2568
2584
  * Attaches current navigator to the browser history allowing navigator to manipulate it.
@@ -2660,7 +2676,7 @@ class ne {
2660
2676
  * "/pathname?search#hash"
2661
2677
  */
2662
2678
  get path() {
2663
- return U(this);
2679
+ return H(this);
2664
2680
  }
2665
2681
  /**
2666
2682
  * Current pathname. Always starts with the slash.
@@ -2689,8 +2705,8 @@ class ne {
2689
2705
  * // { pathname: '/tma', search: '?is=cool', hash: '#yeah' }
2690
2706
  */
2691
2707
  parsePath(t) {
2692
- let s = H(t);
2693
- return this.hashMode && (s = H(s.hash.slice(1))), {
2708
+ let s = U(t);
2709
+ return this.hashMode && (s = U(s.hash.slice(1))), {
2694
2710
  pathname: s.pathname,
2695
2711
  search: s.search,
2696
2712
  hash: s.hash
@@ -2710,7 +2726,7 @@ class ne {
2710
2726
  * @param value - path presented as string or URLLike.
2711
2727
  */
2712
2728
  renderPath(t) {
2713
- const s = (this.base.length === 1 ? "" : this.base) + M(U(t), "/");
2729
+ const s = (this.base.length === 1 ? "" : this.base) + M(H(t), "/");
2714
2730
  return this.hashMode ? M(s.slice(1), this.hashMode === "classic" ? "#" : "#/") : s;
2715
2731
  }
2716
2732
  /**
@@ -2740,7 +2756,7 @@ class ne {
2740
2756
  function ks(e) {
2741
2757
  e || (e = {});
2742
2758
  const { href: t, hash: s } = window.location;
2743
- let n = U(
2759
+ let n = H(
2744
2760
  e.hashMode === null ? t : s.includes("?") ? s.slice(1) : `?${s.slice(1)}`
2745
2761
  );
2746
2762
  const r = e.base ? se(e.base) : void 0;
@@ -2764,7 +2780,11 @@ function qs(e, t) {
2764
2780
  if (s)
2765
2781
  try {
2766
2782
  const { index: n, history: r } = JSON.parse(s);
2767
- return new ne(r, n, t);
2783
+ return new ne(
2784
+ r,
2785
+ n,
2786
+ t
2787
+ );
2768
2788
  } catch (n) {
2769
2789
  console.error("Unable to restore hash navigator state.", n);
2770
2790
  }
@@ -2780,13 +2800,13 @@ function Cn(e, t) {
2780
2800
  }
2781
2801
  function d(e, t) {
2782
2802
  function s(n) {
2783
- return function(i, a, o) {
2803
+ return function(i, o, a) {
2784
2804
  return (p) => {
2785
2805
  const u = {
2786
2806
  ...p,
2787
- [i]: n(a)
2807
+ [i]: n(o)
2788
2808
  };
2789
- return /* @__PURE__ */ Et(o, { ...u });
2809
+ return /* @__PURE__ */ Et(a, { ...u });
2790
2810
  };
2791
2811
  };
2792
2812
  }
@@ -2801,7 +2821,7 @@ function Os() {
2801
2821
  }
2802
2822
  function _(e) {
2803
2823
  function t(n) {
2804
- const r = Os(), [i, a] = Pt(
2824
+ const r = Os(), [i, o] = Pt(
2805
2825
  n ? void 0 : () => {
2806
2826
  if (Ss())
2807
2827
  throw new Error("Using hooks on the server side, you must explicitly specify ssr = true option");
@@ -2809,7 +2829,7 @@ function _(e) {
2809
2829
  }
2810
2830
  );
2811
2831
  return S(() => {
2812
- a(r.use(e));
2832
+ o(r.use(e));
2813
2833
  }, [r]), i;
2814
2834
  }
2815
2835
  function s(n) {
@@ -2828,16 +2848,16 @@ const [Ns, Ds] = _(Ge), [Sn, Tn] = d(
2828
2848
  ), [Bs, Ms] = _(Ke), [An, In] = d(
2829
2849
  Bs,
2830
2850
  Ms
2831
- ), [Vs, $s] = _(Fe), [kn, qn] = d(
2851
+ ), [Vs, Ls] = _(Fe), [kn, qn] = d(
2832
2852
  Vs,
2833
- $s
2834
- ), [Ls, Hs] = _(ts), [On, Nn] = d(
2835
- Ls,
2836
- Hs
2837
- ), [Us, Ws] = _(ss), [Dn, Bn] = d(
2838
- Us,
2853
+ Ls
2854
+ ), [$s, Us] = _(ts), [On, Nn] = d(
2855
+ $s,
2856
+ Us
2857
+ ), [Hs, Ws] = _(ss), [Dn, Bn] = d(
2858
+ Hs,
2839
2859
  Ws
2840
- ), [Gs, js] = _(rs), [Mn, Vn] = d(Gs, js), [zs, Ks] = _(os), [$n, Ln] = d(zs, Ks), [Js, Fs] = _(cs), [Hn, Un] = d(Js, Fs), [Qs, Ys] = _(ls), [Wn, Gn] = d(Qs, Ys), [Zs, Xs] = _(ws), [jn, zn] = d(Zs, Xs), [tn, en] = _(fs), [Kn, Jn] = d(tn, en), [sn, nn] = _(bs), [Fn, Qn] = d(
2860
+ ), [Gs, js] = _(rs), [Mn, Vn] = d(Gs, js), [zs, Ks] = _(os), [Ln, $n] = d(zs, Ks), [Js, Fs] = _(cs), [Un, Hn] = d(Js, Fs), [Qs, Ys] = _(ls), [Wn, Gn] = d(Qs, Ys), [Zs, Xs] = _(ws), [jn, zn] = d(Zs, Xs), [tn, en] = _(fs), [Kn, Jn] = d(tn, en), [sn, nn] = _(bs), [Fn, Qn] = d(
2841
2861
  sn,
2842
2862
  nn
2843
2863
  ), [rn, on] = _(ys), [Yn, Zn] = d(rn, on);
@@ -2846,7 +2866,7 @@ function Xn() {
2846
2866
  }
2847
2867
  const [an, cn] = _(Ps), [tr, er] = d(an, cn), [hn, pn] = _(xs), [sr, nr] = d(hn, pn);
2848
2868
  function rr({ children: e, acceptCustomStyles: t, debug: s }) {
2849
- const n = ft(!0), [r, i] = Pt(/* @__PURE__ */ new Map()), a = ft(r), o = ae(
2869
+ const n = ft(!0), [r, i] = Pt(/* @__PURE__ */ new Map()), o = ft(r), a = ae(
2850
2870
  (u) => {
2851
2871
  n.current && i((C) => (u && u(C), new Map(C)));
2852
2872
  },
@@ -2862,17 +2882,17 @@ function rr({ children: e, acceptCustomStyles: t, debug: s }) {
2862
2882
  } catch (f) {
2863
2883
  K = f;
2864
2884
  }
2865
- function L(f) {
2885
+ function $(f) {
2866
2886
  return r.set(u, f), f;
2867
2887
  }
2868
2888
  if (K)
2869
- return L({ error: K });
2889
+ return $({ error: K });
2870
2890
  let I;
2871
2891
  if (Array.isArray(b) && (I = b[1], b = b[0]), !b)
2872
- return L({ result: b, cleanup: I });
2892
+ return $({ result: b, cleanup: I });
2873
2893
  function wt(f) {
2874
2894
  if ("on" in f) {
2875
- const k = f.on("change", () => o()), gt = I;
2895
+ const k = f.on("change", () => a()), gt = I;
2876
2896
  I = () => {
2877
2897
  gt && gt(), k();
2878
2898
  };
@@ -2880,9 +2900,9 @@ function rr({ children: e, acceptCustomStyles: t, debug: s }) {
2880
2900
  return { result: f, cleanup: I };
2881
2901
  }
2882
2902
  return b instanceof Promise ? (b.then(
2883
- (f) => o((k) => k.set(u, wt(f))),
2884
- (f) => o((k) => k.set(u, { error: f }))
2885
- ), L({})) : L(wt(b));
2903
+ (f) => a((k) => k.set(u, wt(f))),
2904
+ (f) => a((k) => k.set(u, { error: f }))
2905
+ ), $({})) : $(wt(b));
2886
2906
  }
2887
2907
  }), [r]);
2888
2908
  return S(() => (n.current = !0, () => {
@@ -2893,9 +2913,9 @@ function rr({ children: e, acceptCustomStyles: t, debug: s }) {
2893
2913
  }, [t]), S(() => {
2894
2914
  le(s || !1);
2895
2915
  }, [s]), S(() => {
2896
- a.current = r;
2916
+ o.current = r;
2897
2917
  }, [r]), S(() => () => {
2898
- a.current.forEach((u) => {
2918
+ o.current.forEach((u) => {
2899
2919
  "cleanup" in u && u.cleanup && u.cleanup();
2900
2920
  });
2901
2921
  }, []), /* @__PURE__ */ Et(re.Provider, { value: p, children: e });
@@ -2943,8 +2963,8 @@ export {
2943
2963
  Ie as compareVersions,
2944
2964
  ks as createBrowserNavigatorFromLocation,
2945
2965
  qe as createPostEvent,
2946
- H as createSafeURL,
2947
- Lt as date,
2966
+ U as createSafeURL,
2967
+ $t as date,
2948
2968
  xn as getHash,
2949
2969
  se as getPathname,
2950
2970
  Ge as initBackButton,
@@ -2991,7 +3011,7 @@ export {
2991
3011
  Qt as retrieveLaunchParams,
2992
3012
  It as rgb,
2993
3013
  pt as searchParams,
2994
- He as serializeLaunchParams,
3014
+ Ue as serializeLaunchParams,
2995
3015
  Jt as serializeThemeParams,
2996
3016
  P as setCSSVar,
2997
3017
  le as setDebug,
@@ -3002,17 +3022,17 @@ export {
3002
3022
  ke as targetOrigin,
3003
3023
  At as toRGB,
3004
3024
  Ct as unsubscribe,
3005
- U as urlToPath,
3025
+ H as urlToPath,
3006
3026
  Ds as useBackButton,
3007
3027
  Ns as useBackButtonRaw,
3008
3028
  Ms as useBiometryManager,
3009
3029
  Bs as useBiometryManagerRaw,
3010
- $s as useClosingBehavior,
3030
+ Ls as useClosingBehavior,
3011
3031
  Vs as useClosingBehaviorRaw,
3012
- Hs as useCloudStorage,
3013
- Ls as useCloudStorageRaw,
3032
+ Us as useCloudStorage,
3033
+ $s as useCloudStorageRaw,
3014
3034
  Ws as useHapticFeedback,
3015
- Us as useHapticFeedbackRaw,
3035
+ Hs as useHapticFeedbackRaw,
3016
3036
  js as useInitData,
3017
3037
  Gs as useInitDataRaw,
3018
3038
  Ks as useInvoice,
@@ -3047,10 +3067,10 @@ export {
3047
3067
  Dn as withHapticFeedbackRaw,
3048
3068
  Vn as withInitData,
3049
3069
  Mn as withInitDataRaw,
3050
- Ln as withInvoice,
3051
- $n as withInvoiceRaw,
3052
- Un as withMainButton,
3053
- Hn as withMainButtonRaw,
3070
+ $n as withInvoice,
3071
+ Ln as withInvoiceRaw,
3072
+ Hn as withMainButton,
3073
+ Un as withMainButtonRaw,
3054
3074
  Gn as withMiniApp,
3055
3075
  Wn as withMiniAppRaw,
3056
3076
  zn as withPopup,