@tma.js/sdk 1.5.0 → 1.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,16 +1,16 @@
1
- var Re = Object.defineProperty;
2
- var Ie = (r, e, t) => e in r ? Re(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
3
- var o = (r, e, t) => (Ie(r, typeof e != "symbol" ? e + "" : e, t), t);
4
- class he {
5
- constructor(e, t) {
6
- this.prefix = e, this.enabled = t;
1
+ var It = Object.defineProperty;
2
+ var Tt = (r, t, e) => t in r ? It(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
3
+ var o = (r, t, e) => (Tt(r, typeof t != "symbol" ? t + "" : t, e), e);
4
+ class ht {
5
+ constructor(t, e) {
6
+ this.prefix = t, this.enabled = e;
7
7
  }
8
8
  /**
9
9
  * Prints message into a console in case, logger is currently enabled.
10
10
  * @param level - log level.
11
11
  * @param args - arguments.
12
12
  */
13
- print(e, ...t) {
13
+ print(t, ...e) {
14
14
  if (!this.enabled)
15
15
  return;
16
16
  const s = /* @__PURE__ */ new Date(), n = Intl.DateTimeFormat("en-GB", {
@@ -20,7 +20,7 @@ class he {
20
20
  fractionalSecondDigits: 3,
21
21
  timeZone: "UTC"
22
22
  }).format(s);
23
- console[e](`[${n}]`, this.prefix, ...t);
23
+ console[t](`[${n}]`, this.prefix, ...e);
24
24
  }
25
25
  /**
26
26
  * Disables the logger.
@@ -32,8 +32,8 @@ class he {
32
32
  * Prints error message into a console.
33
33
  * @param args
34
34
  */
35
- error(...e) {
36
- this.print("error", ...e);
35
+ error(...t) {
36
+ this.print("error", ...t);
37
37
  }
38
38
  /**
39
39
  * Enables the logger.
@@ -45,64 +45,64 @@ class he {
45
45
  * Prints log message into a console.
46
46
  * @param args
47
47
  */
48
- log(...e) {
49
- this.print("log", ...e);
48
+ log(...t) {
49
+ this.print("log", ...t);
50
50
  }
51
51
  /**
52
52
  * Prints warning message into a console.
53
53
  * @param args
54
54
  */
55
- warn(...e) {
56
- this.print("warn", ...e);
55
+ warn(...t) {
56
+ this.print("warn", ...t);
57
57
  }
58
58
  }
59
- let ue = "https://web.telegram.org";
60
- const k = new he("[SDK]", !1);
61
- function Qt(r) {
59
+ let ut = "https://web.telegram.org";
60
+ const k = new ht("[SDK]", !1);
61
+ function Qe(r) {
62
62
  if (r) {
63
63
  k.enable();
64
64
  return;
65
65
  }
66
66
  k.disable();
67
67
  }
68
- function Zt(r) {
69
- ue = r;
68
+ function Ze(r) {
69
+ ut = r;
70
70
  }
71
- function Te() {
72
- return ue;
71
+ function $t() {
72
+ return ut;
73
73
  }
74
- function pe() {
74
+ function pt() {
75
75
  try {
76
76
  return window.self !== window.top;
77
77
  } catch {
78
78
  return !0;
79
79
  }
80
80
  }
81
- function M(r) {
81
+ function W(r) {
82
82
  return typeof r == "object" && r !== null && !Array.isArray(r);
83
83
  }
84
- function $e(r) {
85
- return "external" in r && M(r.external) && "notify" in r.external && typeof r.external.notify == "function";
84
+ function Lt(r) {
85
+ return "external" in r && W(r.external) && "notify" in r.external && typeof r.external.notify == "function";
86
86
  }
87
- function Le(r) {
88
- return "TelegramWebviewProxy" in r && M(r.TelegramWebviewProxy) && "postEvent" in r.TelegramWebviewProxy && typeof r.TelegramWebviewProxy.postEvent == "function";
87
+ function Bt(r) {
88
+ return "TelegramWebviewProxy" in r && W(r.TelegramWebviewProxy) && "postEvent" in r.TelegramWebviewProxy && typeof r.TelegramWebviewProxy.postEvent == "function";
89
89
  }
90
- function d(r, e, t) {
90
+ function d(r, t, e) {
91
91
  let s = {}, n;
92
- e === void 0 && t === void 0 ? s = {} : e !== void 0 && t !== void 0 ? (s = t, n = e) : e !== void 0 && ("targetOrigin" in e ? s = e : n = e);
93
- const { targetOrigin: i = Te() } = s;
94
- if (k.log(`Calling method "${r}"`, n), pe()) {
92
+ t === void 0 && e === void 0 ? s = {} : t !== void 0 && e !== void 0 ? (s = e, n = t) : t !== void 0 && ("targetOrigin" in t ? s = t : n = t);
93
+ const { targetOrigin: i = $t() } = s;
94
+ if (k.log(`Calling method "${r}"`, n), pt()) {
95
95
  window.parent.postMessage(JSON.stringify({
96
96
  eventType: r,
97
97
  eventData: n
98
98
  }), i);
99
99
  return;
100
100
  }
101
- if ($e(window)) {
101
+ if (Lt(window)) {
102
102
  window.external.notify(JSON.stringify({ eventType: r, eventData: n }));
103
103
  return;
104
104
  }
105
- if (Le(window)) {
105
+ if (Bt(window)) {
106
106
  window.TelegramWebviewProxy.postEvent(r, JSON.stringify(n));
107
107
  return;
108
108
  }
@@ -110,24 +110,24 @@ function d(r, e, t) {
110
110
  "Unable to determine current environment and possible way to send event."
111
111
  );
112
112
  }
113
- function Be(r, e) {
114
- const t = r.split("."), s = e.split("."), n = Math.max(t.length, s.length);
113
+ function Dt(r, t) {
114
+ const e = r.split("."), s = t.split("."), n = Math.max(e.length, s.length);
115
115
  for (let i = 0; i < n; i += 1) {
116
- const a = parseInt(t[i] || "0", 10), c = parseInt(s[i] || "0", 10);
116
+ const a = parseInt(e[i] || "0", 10), c = parseInt(s[i] || "0", 10);
117
117
  if (a !== c)
118
118
  return a > c ? 1 : -1;
119
119
  }
120
120
  return 0;
121
121
  }
122
- function v(r, e) {
123
- return Be(r, e) <= 0;
122
+ function v(r, t) {
123
+ return Dt(r, t) <= 0;
124
124
  }
125
- function A(r, e, t) {
126
- if (typeof t == "string") {
127
- if (r === "web_app_open_link" && e === "try_instant_view")
128
- return v("6.4", t);
129
- if (r === "web_app_set_header_color" && e === "color")
130
- return v("6.9", t);
125
+ function A(r, t, e) {
126
+ if (typeof e == "string") {
127
+ if (r === "web_app_open_link" && t === "try_instant_view")
128
+ return v("6.4", e);
129
+ if (r === "web_app_set_header_color" && t === "color")
130
+ return v("6.9", e);
131
131
  }
132
132
  switch (r) {
133
133
  case "web_app_open_tg_link":
@@ -136,67 +136,67 @@ function A(r, e, t) {
136
136
  case "web_app_set_background_color":
137
137
  case "web_app_set_header_color":
138
138
  case "web_app_trigger_haptic_feedback":
139
- return v("6.1", e);
139
+ return v("6.1", t);
140
140
  case "web_app_open_popup":
141
- return v("6.2", e);
141
+ return v("6.2", t);
142
142
  case "web_app_close_scan_qr_popup":
143
143
  case "web_app_open_scan_qr_popup":
144
144
  case "web_app_read_text_from_clipboard":
145
- return v("6.4", e);
145
+ return v("6.4", t);
146
146
  case "web_app_switch_inline_query":
147
- return v("6.7", e);
147
+ return v("6.7", t);
148
148
  case "web_app_invoke_custom_method":
149
149
  case "web_app_request_write_access":
150
150
  case "web_app_request_phone":
151
- return v("6.9", e);
151
+ return v("6.9", t);
152
152
  case "web_app_setup_settings_button":
153
- return v("6.10", e);
153
+ return v("6.10", t);
154
154
  default:
155
155
  return !0;
156
156
  }
157
157
  }
158
- class Z extends Error {
159
- constructor(e, t) {
160
- super(`Method "${e}" is unsupported in the Mini Apps version ${t}.`), Object.setPrototypeOf(this, Z.prototype);
158
+ class K extends Error {
159
+ constructor(t, e) {
160
+ super(`Method "${t}" is unsupported in the Mini Apps version ${e}.`), Object.setPrototypeOf(this, K.prototype);
161
161
  }
162
162
  }
163
- class K extends Error {
164
- constructor(e, t, s) {
165
- super(`Parameter "${t}" in method "${e}" is unsupported in the Mini Apps version ${s}.`), Object.setPrototypeOf(this, K.prototype);
163
+ class Y extends Error {
164
+ constructor(t, e, s) {
165
+ super(`Parameter "${e}" in method "${t}" is unsupported in the Mini Apps version ${s}.`), Object.setPrototypeOf(this, Y.prototype);
166
166
  }
167
167
  }
168
- function Oe(r) {
169
- return (e, t) => {
170
- if (!A(e, r))
171
- throw new Z(e, r);
172
- if (M(t)) {
168
+ function Ot(r) {
169
+ return (t, e) => {
170
+ if (!A(t, r))
171
+ throw new K(t, r);
172
+ if (W(e)) {
173
173
  let s;
174
- if (e === "web_app_open_link" && "try_instant_view" in t ? s = "try_instant_view" : e === "web_app_set_header_color" && "color" in t && (s = "color"), s && !A(e, s, r))
175
- throw new K(e, s, r);
174
+ if (t === "web_app_open_link" && "try_instant_view" in e ? s = "try_instant_view" : t === "web_app_set_header_color" && "color" in e && (s = "color"), s && !A(t, s, r))
175
+ throw new Y(t, s, r);
176
176
  }
177
- return d(e, t);
177
+ return d(t, e);
178
178
  };
179
179
  }
180
- function le(r) {
181
- return ({ req_id: e }) => e === r;
180
+ function lt(r) {
181
+ return ({ req_id: t }) => t === r;
182
182
  }
183
- class G extends Error {
184
- constructor(t, { cause: s, type: n } = {}) {
183
+ class j extends Error {
184
+ constructor(e, { cause: s, type: n } = {}) {
185
185
  super(`Unable to parse value${n ? ` as ${n}` : ""}`, { cause: s });
186
186
  /**
187
187
  * Parser name.
188
188
  */
189
189
  o(this, "type");
190
- this.value = t, Object.setPrototypeOf(this, G.prototype), this.type = n;
190
+ this.value = e, Object.setPrototypeOf(this, j.prototype), this.type = n;
191
191
  }
192
192
  }
193
- class U extends Error {
194
- constructor(e, { cause: t, type: s } = {}) {
195
- super(`Unable to parse field "${e}"${s ? ` as ${s}` : ""}`, { cause: t }), Object.setPrototypeOf(this, U.prototype);
193
+ class G extends Error {
194
+ constructor(t, { cause: e, type: s } = {}) {
195
+ super(`Unable to parse field "${t}"${s ? ` as ${s}` : ""}`, { cause: e }), Object.setPrototypeOf(this, G.prototype);
196
196
  }
197
197
  }
198
- function de(r, e) {
199
- const t = {};
198
+ function dt(r, t) {
199
+ const e = {};
200
200
  for (const s in r) {
201
201
  const n = r[s];
202
202
  if (!n)
@@ -209,72 +209,72 @@ function de(r, e) {
209
209
  i = n.from || s, a = typeof p == "function" ? p : p.parse.bind(p);
210
210
  }
211
211
  let c;
212
- const u = e(i);
212
+ const u = t(i);
213
213
  try {
214
214
  c = a(u);
215
215
  } catch (p) {
216
- throw p instanceof G ? new U(i, {
216
+ throw p instanceof j ? new G(i, {
217
217
  type: p.type,
218
218
  cause: p
219
- }) : new U(i, { cause: p });
219
+ }) : new G(i, { cause: p });
220
220
  }
221
- c !== void 0 && (t[s] = c);
221
+ c !== void 0 && (e[s] = c);
222
222
  }
223
- return t;
223
+ return e;
224
224
  }
225
225
  function V() {
226
226
  return new TypeError("Value has unexpected type");
227
227
  }
228
- function Y(r) {
229
- let e = r;
230
- if (typeof e == "string" && (e = JSON.parse(e)), typeof e != "object" || e === null || Array.isArray(e))
228
+ function X(r) {
229
+ let t = r;
230
+ if (typeof t == "string" && (t = JSON.parse(t)), typeof t != "object" || t === null || Array.isArray(t))
231
231
  throw V();
232
- return e;
232
+ return t;
233
233
  }
234
- class j {
235
- constructor(e, t, s) {
236
- this.parser = e, this.isOptional = t, this.type = s;
234
+ class F {
235
+ constructor(t, e, s) {
236
+ this.parser = t, this.isOptional = e, this.type = s;
237
237
  }
238
- parse(e) {
239
- if (!(this.isOptional && e === void 0))
238
+ parse(t) {
239
+ if (!(this.isOptional && t === void 0))
240
240
  try {
241
- return this.parser(e);
242
- } catch (t) {
243
- throw new G(e, { type: this.type, cause: t });
241
+ return this.parser(t);
242
+ } catch (e) {
243
+ throw new j(t, { type: this.type, cause: e });
244
244
  }
245
245
  }
246
246
  optional() {
247
247
  return this.isOptional = !0, this;
248
248
  }
249
249
  }
250
- function f(r, e) {
251
- return new j((t) => {
252
- const s = Y(t);
253
- return de(r, (n) => s[n]);
254
- }, !1, e);
250
+ function f(r, t) {
251
+ return new F((e) => {
252
+ const s = X(e);
253
+ return dt(r, (n) => s[n]);
254
+ }, !1, t);
255
255
  }
256
- function R(r, e) {
257
- return () => new j(r, !1, e);
256
+ function R(r, t) {
257
+ return () => new F(r, !1, t);
258
258
  }
259
259
  const h = R((r) => {
260
260
  if (typeof r == "string" || typeof r == "number")
261
261
  return r.toString();
262
262
  throw V();
263
263
  }, "string");
264
- function De(r) {
264
+ function Wt(r) {
265
265
  return f({
266
266
  eventType: h(),
267
- eventData: (e) => e
267
+ eventData: (t) => t
268
268
  }).parse(r);
269
269
  }
270
- function We(r, e) {
270
+ function Ht(r, t) {
271
271
  window.dispatchEvent(new MessageEvent("message", {
272
- data: JSON.stringify({ eventType: r, eventData: e }),
272
+ data: JSON.stringify({ eventType: r, eventData: t }),
273
273
  // We specify window.parent to imitate the case, it sent us this event.
274
274
  source: window.parent
275
275
  }));
276
276
  }
277
- function He() {
277
+ function Nt() {
278
278
  const r = window;
279
279
  "TelegramGameProxy_receiveEvent" in r || [
280
280
  ["TelegramGameProxy_receiveEvent"],
@@ -283,112 +283,112 @@ function He() {
283
283
  // Desktop.
284
284
  ["Telegram", "WebView", "receiveEvent"]
285
285
  // Android and iOS.
286
- ].forEach((e) => {
287
- let t = r;
288
- e.forEach((s, n, i) => {
286
+ ].forEach((t) => {
287
+ let e = r;
288
+ t.forEach((s, n, i) => {
289
289
  if (n === i.length - 1) {
290
- t[s] = We;
290
+ e[s] = Ht;
291
291
  return;
292
292
  }
293
- s in t || (t[s] = {}), t = t[s];
293
+ s in e || (e[s] = {}), e = e[s];
294
294
  });
295
295
  });
296
296
  }
297
- function Ne(r) {
298
- He(), window.addEventListener("message", (e) => {
299
- if (e.source === window.parent)
297
+ function Ut(r) {
298
+ Nt(), window.addEventListener("message", (t) => {
299
+ if (t.source === window.parent)
300
300
  try {
301
- const { eventType: t, eventData: s } = De(e.data);
302
- r(t, s);
301
+ const { eventType: e, eventData: s } = Wt(t.data);
302
+ r(e, s);
303
303
  } catch {
304
304
  }
305
305
  });
306
306
  }
307
- function Ue() {
307
+ function Mt() {
308
308
  return f({
309
309
  req_id: h(),
310
310
  data: (r) => r === null ? r : h().optional().parse(r)
311
311
  });
312
312
  }
313
- function Me() {
313
+ function Gt() {
314
314
  return f({
315
315
  req_id: h(),
316
316
  result: (r) => r,
317
317
  error: h().optional()
318
318
  });
319
319
  }
320
- function Ge() {
320
+ function jt() {
321
321
  return f({
322
322
  slug: h(),
323
323
  status: h()
324
324
  });
325
325
  }
326
- function je() {
326
+ function Ft() {
327
327
  return f({ status: h() });
328
328
  }
329
- function Fe() {
329
+ function zt() {
330
330
  return f({
331
331
  button_id: (r) => r == null ? void 0 : h().parse(r)
332
332
  });
333
333
  }
334
- function ze() {
334
+ function Jt() {
335
335
  return f({
336
336
  data: h().optional()
337
337
  });
338
338
  }
339
- function X(r) {
339
+ function tt(r) {
340
340
  return /^#[\da-f]{6}$/i.test(r);
341
341
  }
342
- function Je(r) {
342
+ function Qt(r) {
343
343
  return /^#[\da-f]{3}$/i.test(r);
344
344
  }
345
- function fe(r) {
346
- const e = r.replace(/\s/g, "").toLowerCase();
347
- if (X(e))
348
- return e;
349
- if (Je(e)) {
345
+ function ft(r) {
346
+ const t = r.replace(/\s/g, "").toLowerCase();
347
+ if (tt(t))
348
+ return t;
349
+ if (Qt(t)) {
350
350
  let s = "#";
351
351
  for (let n = 0; n < 3; n += 1)
352
- s += e[1 + n].repeat(2);
352
+ s += t[1 + n].repeat(2);
353
353
  return s;
354
354
  }
355
- const t = e.match(/^rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)$/) || e.match(/^rgba\((\d{1,3}),(\d{1,3}),(\d{1,3}),\d{1,3}\)$/);
356
- if (t === null)
355
+ const e = t.match(/^rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)$/) || t.match(/^rgba\((\d{1,3}),(\d{1,3}),(\d{1,3}),\d{1,3}\)$/);
356
+ if (e === null)
357
357
  throw new Error(`Value "${r}" does not satisfy any of known RGB formats.`);
358
- return t.slice(1).reduce((s, n) => {
358
+ return e.slice(1).reduce((s, n) => {
359
359
  const i = parseInt(n, 10).toString(16);
360
360
  return s + (i.length === 1 ? "0" : "") + i;
361
361
  }, "#");
362
362
  }
363
- const ge = R((r) => fe(h().parse(r)), "rgb");
364
- function Qe() {
363
+ const gt = R((r) => ft(h().parse(r)), "rgb");
364
+ function Zt() {
365
365
  return f({
366
366
  theme_params: (r) => {
367
- const e = ge().optional();
368
- return Object.entries(Y(r)).reduce((t, [s, n]) => (t[s] = e.parse(n), t), {});
367
+ const t = gt().optional();
368
+ return Object.entries(X(r)).reduce((e, [s, n]) => (e[s] = t.parse(n), e), {});
369
369
  }
370
370
  });
371
371
  }
372
372
  const P = R((r) => {
373
373
  if (typeof r == "boolean")
374
374
  return r;
375
- const e = String(r);
376
- if (e === "1" || e === "true")
375
+ const t = String(r);
376
+ if (t === "1" || t === "true")
377
377
  return !0;
378
- if (e === "0" || e === "false")
378
+ if (t === "0" || t === "false")
379
379
  return !1;
380
380
  throw V();
381
381
  }, "boolean"), x = R((r) => {
382
382
  if (typeof r == "number")
383
383
  return r;
384
384
  if (typeof r == "string") {
385
- const e = Number(r);
386
- if (!Number.isNaN(e))
387
- return e;
385
+ const t = Number(r);
386
+ if (!Number.isNaN(t))
387
+ return t;
388
388
  }
389
389
  throw V();
390
390
  }, "number");
391
- function Ze() {
391
+ function Kt() {
392
392
  return f({
393
393
  height: x(),
394
394
  width: (r) => r == null ? window.innerWidth : x().parse(r),
@@ -396,7 +396,7 @@ function Ze() {
396
396
  is_expanded: P()
397
397
  });
398
398
  }
399
- function Ke() {
399
+ function Yt() {
400
400
  return f({ status: h() });
401
401
  }
402
402
  class w {
@@ -410,15 +410,15 @@ class w {
410
410
  * @param listener - event listener.
411
411
  * @param once - should listener called only once.
412
412
  */
413
- addListener(e, t, s) {
414
- let n = this.listeners.get(e);
415
- return n || (n = [], this.listeners.set(e, n)), n.push([t, s]), () => this.off(e, t);
413
+ addListener(t, e, s) {
414
+ let n = this.listeners.get(t);
415
+ return n || (n = [], this.listeners.set(t, n)), n.push([e, s]), () => this.off(t, e);
416
416
  }
417
- emit(e, ...t) {
418
- this.subscribeListeners.forEach((n) => n(e, ...t));
419
- const s = this.listeners.get(e);
417
+ emit(t, ...e) {
418
+ this.subscribeListeners.forEach((n) => n(t, ...e));
419
+ const s = this.listeners.get(t);
420
420
  s && s.forEach(([n, i], a) => {
421
- n(...t), i && s.splice(a, 1);
421
+ n(...e), i && s.splice(a, 1);
422
422
  });
423
423
  }
424
424
  /**
@@ -427,8 +427,8 @@ class w {
427
427
  * @param listener - event listener.
428
428
  * @returns Function to remove event listener.
429
429
  */
430
- on(e, t) {
431
- return this.addListener(e, t, !1);
430
+ on(t, e) {
431
+ return this.addListener(t, e, !1);
432
432
  }
433
433
  /**
434
434
  * Adds event listener following the logic, described in `on` method, but calls specified
@@ -438,8 +438,8 @@ class w {
438
438
  * @returns Function to remove event listener.
439
439
  * @see on
440
440
  */
441
- once(e, t) {
442
- return this.addListener(e, t, !0);
441
+ once(t, e) {
442
+ return this.addListener(t, e, !0);
443
443
  }
444
444
  /**
445
445
  * Removes event listener. In case, specified listener was bound several times, it removes
@@ -447,11 +447,11 @@ class w {
447
447
  * @param event - event name.
448
448
  * @param listener - event listener.
449
449
  */
450
- off(e, t) {
451
- const s = this.listeners.get(e);
450
+ off(t, e) {
451
+ const s = this.listeners.get(t);
452
452
  if (s) {
453
453
  for (let n = 0; n < s.length; n += 1)
454
- if (t === s[n][0]) {
454
+ if (e === s[n][0]) {
455
455
  s.splice(n, 1);
456
456
  return;
457
457
  }
@@ -464,8 +464,8 @@ class w {
464
464
  * @see on
465
465
  * @see once
466
466
  */
467
- subscribe(e) {
468
- return this.subscribeListeners.push(e), () => this.unsubscribe(e);
467
+ subscribe(t) {
468
+ return this.subscribeListeners.push(t), () => this.unsubscribe(t);
469
469
  }
470
470
  /**
471
471
  * Removes global event listener. In case, specified listener was bound several times, it removes
@@ -473,100 +473,100 @@ class w {
473
473
  * @param listener - events listener.
474
474
  * @returns Function to remove event listener.
475
475
  */
476
- unsubscribe(e) {
477
- for (let t = 0; t < this.subscribeListeners.length; t += 1)
478
- if (this.subscribeListeners[t] === e) {
479
- this.subscribeListeners.splice(t, 1);
476
+ unsubscribe(t) {
477
+ for (let e = 0; e < this.subscribeListeners.length; e += 1)
478
+ if (this.subscribeListeners[e] === t) {
479
+ this.subscribeListeners.splice(e, 1);
480
480
  return;
481
481
  }
482
482
  }
483
483
  }
484
- function Ye() {
485
- const r = new w(), e = (t, ...s) => {
486
- k.log("Emitting processed event:", t, ...s), r.emit(t, ...s);
484
+ function Xt() {
485
+ const r = new w(), t = (e, ...s) => {
486
+ k.log("Emitting processed event:", e, ...s), r.emit(e, ...s);
487
487
  };
488
488
  return window.addEventListener("resize", () => {
489
- e("viewport_changed", {
489
+ t("viewport_changed", {
490
490
  width: window.innerWidth,
491
491
  height: window.innerHeight,
492
492
  is_state_stable: !0,
493
493
  is_expanded: !0
494
494
  });
495
- }), Ne((t, s) => {
496
- k.log("Received raw event:", t, s);
495
+ }), Ut((e, s) => {
496
+ k.log("Received raw event:", e, s);
497
497
  try {
498
- switch (t) {
498
+ switch (e) {
499
499
  case "viewport_changed":
500
- return e(t, Ze().parse(s));
500
+ return t(e, Kt().parse(s));
501
501
  case "theme_changed":
502
- return e(t, Qe().parse(s));
502
+ return t(e, Zt().parse(s));
503
503
  case "popup_closed":
504
504
  return (
505
505
  // Sent on desktop.
506
- s == null ? e(t, {}) : e(t, Fe().parse(s))
506
+ s == null ? t(e, {}) : t(e, zt().parse(s))
507
507
  );
508
508
  case "set_custom_style":
509
- return e(t, h().parse(s));
509
+ return t(e, h().parse(s));
510
510
  case "qr_text_received":
511
- return e(t, ze().parse(s));
511
+ return t(e, Jt().parse(s));
512
512
  case "clipboard_text_received":
513
- return e(t, Ue().parse(s));
513
+ return t(e, Mt().parse(s));
514
514
  case "invoice_closed":
515
- return e(t, Ge().parse(s));
515
+ return t(e, jt().parse(s));
516
516
  case "phone_requested":
517
- return e("phone_requested", je().parse(s));
517
+ return t("phone_requested", Ft().parse(s));
518
518
  case "custom_method_invoked":
519
- return e("custom_method_invoked", Me().parse(s));
519
+ return t("custom_method_invoked", Gt().parse(s));
520
520
  case "write_access_requested":
521
- return e("write_access_requested", Ke().parse(s));
521
+ return t("write_access_requested", Yt().parse(s));
522
522
  case "main_button_pressed":
523
523
  case "back_button_pressed":
524
524
  case "settings_button_pressed":
525
525
  case "scan_qr_popup_closed":
526
526
  case "reload_iframe":
527
- return e(t);
527
+ return t(e);
528
528
  default:
529
- return e(t, s);
529
+ return t(e, s);
530
530
  }
531
531
  } catch (n) {
532
532
  k.error("Error processing event:", n);
533
533
  }
534
534
  }), r;
535
535
  }
536
- const z = "telegram-mini-apps-cached-emitter";
537
- function W() {
536
+ const J = "telegram-mini-apps-cached-emitter";
537
+ function H() {
538
538
  const r = window;
539
- return r[z] === void 0 && (r[z] = Ye()), r[z];
539
+ return r[J] === void 0 && (r[J] = Xt()), r[J];
540
540
  }
541
- function I(r, e) {
542
- W().off(r, e);
541
+ function I(r, t) {
542
+ H().off(r, t);
543
543
  }
544
- function E(r, e) {
545
- return W().on(r, e), () => I(r, e);
544
+ function E(r, t) {
545
+ return H().on(r, t), () => I(r, t);
546
546
  }
547
- class F extends Error {
548
- constructor(e) {
549
- super(`Async call timeout exceeded. Timeout: ${e}`), Object.setPrototypeOf(this, F.prototype);
547
+ class z extends Error {
548
+ constructor(t) {
549
+ super(`Async call timeout exceeded. Timeout: ${t}`), Object.setPrototypeOf(this, z.prototype);
550
550
  }
551
551
  }
552
- function Xe(r) {
553
- return new Promise((e, t) => {
554
- setTimeout(t, r, new F(r));
552
+ function te(r) {
553
+ return new Promise((t, e) => {
554
+ setTimeout(e, r, new z(r));
555
555
  });
556
556
  }
557
- function we(r, e) {
557
+ function wt(r, t) {
558
558
  return Promise.race([
559
559
  typeof r == "function" ? r() : r,
560
- Xe(e)
560
+ te(t)
561
561
  ]);
562
562
  }
563
- async function y(r, e, t) {
563
+ async function y(r, t, e) {
564
564
  let s;
565
565
  const n = new Promise((b) => {
566
566
  s = b;
567
- }), i = e ? {
568
- ...t,
569
- event: e,
567
+ }), i = t ? {
568
+ ...e,
569
+ event: t,
570
570
  method: r
571
571
  } : r, {
572
572
  method: a,
@@ -578,12 +578,12 @@ async function y(r, e, t) {
578
578
  (b) => E(b, (l) => (!u || u(l)) && s(l))
579
579
  );
580
580
  try {
581
- return p(a, i.params), await (g ? we(n, g) : n);
581
+ return p(a, i.params), await (g ? wt(n, g) : n);
582
582
  } finally {
583
583
  _.forEach((b) => b());
584
584
  }
585
585
  }
586
- async function O(r, e, t, s = {}) {
586
+ async function D(r, t, e, s = {}) {
587
587
  const {
588
588
  result: n,
589
589
  error: i
@@ -591,54 +591,51 @@ async function O(r, e, t, s = {}) {
591
591
  ...s,
592
592
  params: {
593
593
  method: r,
594
- params: e,
595
- req_id: t
594
+ params: t,
595
+ req_id: e
596
596
  },
597
- capture: le(t)
597
+ capture: lt(e)
598
598
  });
599
599
  if (i)
600
600
  throw new Error(i);
601
601
  return n;
602
602
  }
603
- function Kt(r, e) {
604
- return W().once(r, e), () => I(r, e);
603
+ function Ke(r, t) {
604
+ return H().once(r, t), () => I(r, t);
605
605
  }
606
- function et(r) {
607
- W().unsubscribe(r);
606
+ function ee(r) {
607
+ H().unsubscribe(r);
608
608
  }
609
- function Yt(r) {
610
- return W().subscribe(r), () => et(r);
609
+ function Ye(r) {
610
+ return H().subscribe(r), () => ee(r);
611
611
  }
612
- function se(r, e) {
613
- return r + (r.length > 0 && e.length > 0 ? ` ${e}` : e);
612
+ function U(r, t) {
613
+ return r + (r.length && t.length ? ` ${t}` : t);
614
614
  }
615
- function tt(...r) {
616
- return r.reduce((e, t) => {
617
- let s = "";
618
- return typeof t == "string" ? s = t : typeof t == "object" && t !== null && (s = Object.entries(t).reduce((n, [i, a]) => a ? se(n, i) : n, "")), se(e, s);
619
- }, "");
615
+ function _t(...r) {
616
+ return r.reduce((t, e) => typeof e == "string" ? U(t, e) : W(e) ? U(t, Object.entries(e).reduce((s, n) => n[1] ? U(s, n[0]) : s, "")) : Array.isArray(e) ? U(t, _t(...e)) : t, "");
620
617
  }
621
- function Xt(...r) {
622
- return r.reduce((e, t) => (M(t) && Object.entries(t).forEach(([s, n]) => {
623
- const i = tt(e[s], n);
624
- i.length > 0 && (e[s] = i);
625
- }), e), {});
618
+ function Xe(...r) {
619
+ return r.reduce((t, e) => (W(e) && Object.entries(e).forEach(([s, n]) => {
620
+ const i = _t(t[s], n);
621
+ i.length > 0 && (t[s] = i);
622
+ }), t), {});
626
623
  }
627
- function _e(r) {
628
- const e = fe(r);
624
+ function bt(r) {
625
+ const t = ft(r);
629
626
  return Math.sqrt(
630
627
  [0.299, 0.587, 0.114].reduce((s, n, i) => {
631
- const a = parseInt(e.slice(1 + i * 2, 1 + (i + 1) * 2), 16);
628
+ const a = parseInt(t.slice(1 + i * 2, 1 + (i + 1) * 2), 16);
632
629
  return s + a * a * n;
633
630
  }, 0)
634
631
  ) < 120;
635
632
  }
636
633
  class m {
637
- constructor(e, t) {
638
- this.state = e, this.ee = t;
634
+ constructor(t, e) {
635
+ this.state = t, this.ee = e;
639
636
  }
640
- internalSet(e, t) {
641
- return this.state[e] === t || t === void 0 ? !1 : (this.state[e] = t, this.ee.emit(`change:${e}`, t), !0);
637
+ internalSet(t, e) {
638
+ return this.state[t] === e || e === void 0 ? !1 : (this.state[t] = e, this.ee.emit(`change:${t}`, e), !0);
642
639
  }
643
640
  /**
644
641
  * Returns copy of current state.
@@ -646,28 +643,28 @@ class m {
646
643
  clone() {
647
644
  return { ...this.state };
648
645
  }
649
- set(e, t) {
646
+ set(t, e) {
650
647
  let s = !1;
651
- if (typeof e == "string")
652
- s = this.internalSet(e, t);
648
+ if (typeof t == "string")
649
+ s = this.internalSet(t, e);
653
650
  else
654
- for (const n in e)
655
- this.internalSet(n, e[n]) && (s = !0);
651
+ for (const n in t)
652
+ this.internalSet(n, t[n]) && (s = !0);
656
653
  s && this.ee.emit("change");
657
654
  }
658
655
  /**
659
656
  * Returns value by specified key.
660
657
  * @param key - state key.
661
658
  */
662
- get(e) {
663
- return this.state[e];
659
+ get(t) {
660
+ return this.state[t];
664
661
  }
665
662
  }
666
- function C(r, e) {
667
- return (t) => A(e[t], r);
663
+ function C(r, t) {
664
+ return (e) => A(t[e], r);
668
665
  }
669
- class rt {
670
- constructor(e, t, s = d) {
666
+ class re {
667
+ constructor(t, e, s = d) {
671
668
  o(this, "ee", new w());
672
669
  o(this, "state");
673
670
  /**
@@ -675,24 +672,24 @@ class rt {
675
672
  * @param event - event name.
676
673
  * @param listener - event listener.
677
674
  */
678
- o(this, "on", (e, t) => e === "click" ? E("back_button_pressed", t) : this.ee.on(e, t));
675
+ o(this, "on", (t, e) => t === "click" ? E("back_button_pressed", e) : this.ee.on(t, e));
679
676
  /**
680
677
  * Removes event listener.
681
678
  * @param event - event name.
682
679
  * @param listener - event listener.
683
680
  */
684
- o(this, "off", (e, t) => e === "click" ? I("back_button_pressed", t) : this.ee.off(e, t));
681
+ o(this, "off", (t, e) => t === "click" ? I("back_button_pressed", e) : this.ee.off(t, e));
685
682
  /**
686
683
  * Checks if specified method is supported by current component.
687
684
  */
688
685
  o(this, "supports");
689
- this.postEvent = s, this.state = new m({ isVisible: e }, this.ee), this.supports = C(t, {
686
+ this.postEvent = s, this.state = new m({ isVisible: t }, this.ee), this.supports = C(e, {
690
687
  show: "web_app_setup_back_button",
691
688
  hide: "web_app_setup_back_button"
692
689
  });
693
690
  }
694
- set isVisible(e) {
695
- this.state.set("isVisible", e), this.postEvent("web_app_setup_back_button", { is_visible: e });
691
+ set isVisible(t) {
692
+ this.state.set("isVisible", t), this.postEvent("web_app_setup_back_button", { is_visible: t });
696
693
  }
697
694
  /**
698
695
  * True if BackButton is currently visible.
@@ -713,8 +710,8 @@ class rt {
713
710
  this.isVisible = !0;
714
711
  }
715
712
  }
716
- class st {
717
- constructor(e, t = d) {
713
+ class se {
714
+ constructor(t, e = d) {
718
715
  o(this, "ee", new w());
719
716
  o(this, "state");
720
717
  /**
@@ -725,10 +722,10 @@ class st {
725
722
  * Removes event listener.
726
723
  */
727
724
  o(this, "off", this.ee.off.bind(this.ee));
728
- this.postEvent = t, this.state = new m({ isConfirmationNeeded: e }, this.ee);
725
+ this.postEvent = e, this.state = new m({ isConfirmationNeeded: t }, this.ee);
729
726
  }
730
- set isConfirmationNeeded(e) {
731
- this.state.set("isConfirmationNeeded", e), this.postEvent("web_app_setup_closing_behavior", { need_confirmation: e });
727
+ set isConfirmationNeeded(t) {
728
+ this.state.set("isConfirmationNeeded", t), this.postEvent("web_app_setup_closing_behavior", { need_confirmation: t });
732
729
  }
733
730
  /**
734
731
  * Returns true, if the confirmation dialog enabled while the user is trying
@@ -752,45 +749,45 @@ class st {
752
749
  this.isConfirmationNeeded = !0;
753
750
  }
754
751
  }
755
- function nt(r) {
752
+ function ne(r) {
756
753
  if (Array.isArray(r))
757
754
  return r;
758
755
  if (typeof r == "string")
759
756
  try {
760
- const e = JSON.parse(r);
761
- if (Array.isArray(e))
762
- return e;
757
+ const t = JSON.parse(r);
758
+ if (Array.isArray(t))
759
+ return t;
763
760
  } catch {
764
761
  }
765
762
  throw V();
766
763
  }
767
- class it extends j {
768
- constructor(t, s, n) {
769
- super(nt, s, n);
764
+ class ie extends F {
765
+ constructor(e, s, n) {
766
+ super(ne, s, n);
770
767
  o(this, "itemParser");
771
- this.itemParser = typeof t == "function" ? t : t.parse.bind(t);
768
+ this.itemParser = typeof e == "function" ? e : e.parse.bind(e);
772
769
  }
773
- parse(t) {
774
- const s = super.parse(t);
770
+ parse(e) {
771
+ const s = super.parse(e);
775
772
  return s === void 0 ? s : s.map(this.itemParser);
776
773
  }
777
- of(t) {
778
- return this.itemParser = typeof t == "function" ? t : t.parse.bind(t), this;
774
+ of(e) {
775
+ return this.itemParser = typeof e == "function" ? e : e.parse.bind(e), this;
779
776
  }
780
777
  }
781
- function ot(r) {
782
- return new it((e) => e, !1, r);
778
+ function oe(r) {
779
+ return new ie((t) => t, !1, r);
783
780
  }
784
- function ne(r, e) {
785
- return r.reduce((t, s) => (t[s] = e, t), {});
781
+ function nt(r, t) {
782
+ return r.reduce((e, s) => (e[s] = t, e), {});
786
783
  }
787
- class at {
788
- constructor(e, t, s = d) {
784
+ class ae {
785
+ constructor(t, e, s = d) {
789
786
  /**
790
787
  * Checks if specified method is supported by current component.
791
788
  */
792
789
  o(this, "supports");
793
- this.createRequestId = t, this.postEvent = s, this.supports = C(e, {
790
+ this.createRequestId = e, this.postEvent = s, this.supports = C(t, {
794
791
  delete: "web_app_invoke_custom_method",
795
792
  get: "web_app_invoke_custom_method",
796
793
  getKeys: "web_app_invoke_custom_method",
@@ -802,41 +799,41 @@ class at {
802
799
  * @param keyOrKeys - key or keys to delete.
803
800
  * @param options - request execution options.
804
801
  */
805
- async delete(e, t = {}) {
806
- const s = Array.isArray(e) ? e : [e];
807
- s.length !== 0 && await O(
802
+ async delete(t, e = {}) {
803
+ const s = Array.isArray(t) ? t : [t];
804
+ s.length !== 0 && await D(
808
805
  "deleteStorageValues",
809
806
  { keys: s },
810
807
  this.createRequestId(),
811
- { ...t, postEvent: this.postEvent }
808
+ { ...e, postEvent: this.postEvent }
812
809
  );
813
810
  }
814
811
  /**
815
812
  * Returns list of all keys presented in the cloud storage.
816
813
  * @param options - request execution options.
817
814
  */
818
- async getKeys(e = {}) {
819
- const t = await O(
815
+ async getKeys(t = {}) {
816
+ const e = await D(
820
817
  "getStorageKeys",
821
818
  {},
822
819
  this.createRequestId(),
823
- { ...e, postEvent: this.postEvent }
820
+ { ...t, postEvent: this.postEvent }
824
821
  );
825
- return ot().of(h()).parse(t);
822
+ return oe().of(h()).parse(e);
826
823
  }
827
- async get(e, t = {}) {
828
- const s = Array.isArray(e) ? e : [e];
824
+ async get(t, e = {}) {
825
+ const s = Array.isArray(t) ? t : [t];
829
826
  if (s.length === 0)
830
- return ne(s, "");
827
+ return nt(s, "");
831
828
  const n = f(
832
- ne(s, h())
833
- ), i = await O(
829
+ nt(s, h())
830
+ ), i = await D(
834
831
  "getStorageValues",
835
832
  { keys: s },
836
833
  this.createRequestId(),
837
- { ...t, postEvent: this.postEvent }
834
+ { ...e, postEvent: this.postEvent }
838
835
  ).then((a) => n.parse(a));
839
- return Array.isArray(e) ? i : i[e];
836
+ return Array.isArray(t) ? i : i[t];
840
837
  }
841
838
  /**
842
839
  * Saves specified value by key.
@@ -844,22 +841,22 @@ class at {
844
841
  * @param value - storage value.
845
842
  * @param options - request execution options.
846
843
  */
847
- async set(e, t, s = {}) {
848
- await O(
844
+ async set(t, e, s = {}) {
845
+ await D(
849
846
  "saveStorageValue",
850
- { key: e, value: t },
847
+ { key: t, value: e },
851
848
  this.createRequestId(),
852
849
  { ...s, postEvent: this.postEvent }
853
850
  );
854
851
  }
855
852
  }
856
- class ct {
857
- constructor(e, t = d) {
853
+ class ce {
854
+ constructor(t, e = d) {
858
855
  /**
859
856
  * Checks if specified method is supported by current component.
860
857
  */
861
858
  o(this, "supports");
862
- this.postEvent = t, this.supports = C(e, {
859
+ this.postEvent = e, this.supports = C(t, {
863
860
  impactOccurred: "web_app_trigger_haptic_feedback",
864
861
  notificationOccurred: "web_app_trigger_haptic_feedback",
865
862
  selectionChanged: "web_app_trigger_haptic_feedback"
@@ -870,10 +867,10 @@ class ct {
870
867
  * appropriate haptics based on style value passed.
871
868
  * @param style - impact style.
872
869
  */
873
- impactOccurred(e) {
870
+ impactOccurred(t) {
874
871
  this.postEvent("web_app_trigger_haptic_feedback", {
875
872
  type: "impact",
876
- impact_style: e
873
+ impact_style: t
877
874
  });
878
875
  }
879
876
  /**
@@ -882,10 +879,10 @@ class ct {
882
879
  * type value passed.
883
880
  * @param type - notification type.
884
881
  */
885
- notificationOccurred(e) {
882
+ notificationOccurred(t) {
886
883
  this.postEvent("web_app_trigger_haptic_feedback", {
887
884
  type: "notification",
888
- notification_type: e
885
+ notification_type: t
889
886
  });
890
887
  }
891
888
  /**
@@ -899,7 +896,7 @@ class ct {
899
896
  this.postEvent("web_app_trigger_haptic_feedback", { type: "selection_change" });
900
897
  }
901
898
  }
902
- function ht() {
899
+ function he() {
903
900
  return f({
904
901
  id: x(),
905
902
  type: h(),
@@ -911,9 +908,9 @@ function ht() {
911
908
  username: h().optional()
912
909
  }, "Chat");
913
910
  }
914
- class ut {
915
- constructor(e) {
916
- this.initData = e;
911
+ class ue {
912
+ constructor(t) {
913
+ this.initData = t;
917
914
  }
918
915
  /**
919
916
  * @see InitDataParsed.authDate
@@ -932,8 +929,8 @@ class ut {
932
929
  * the [answerWebAppQuery](https://core.telegram.org/bots/api#answerwebappquery) method.
933
930
  */
934
931
  get canSendAfterDate() {
935
- const { canSendAfter: e } = this;
936
- return e === void 0 ? void 0 : new Date(this.authDate.getTime() + e * 1e3);
932
+ const { canSendAfter: t } = this;
933
+ return t === void 0 ? void 0 : new Date(this.authDate.getTime() + t * 1e3);
937
934
  }
938
935
  /**
939
936
  * @see InitDataParsed.chat
@@ -984,7 +981,7 @@ class ut {
984
981
  return this.initData.user;
985
982
  }
986
983
  }
987
- function ie() {
984
+ function it() {
988
985
  return f({
989
986
  addedToAttachmentMenu: {
990
987
  type: P().optional(),
@@ -1022,29 +1019,29 @@ function ie() {
1022
1019
  username: h().optional()
1023
1020
  }, "User");
1024
1021
  }
1025
- const be = R((r) => r instanceof Date ? r : new Date(x().parse(r) * 1e3), "Date");
1026
- function ee(r, e) {
1027
- return new j((t) => {
1028
- if (typeof t != "string" && !(t instanceof URLSearchParams))
1022
+ const mt = R((r) => r instanceof Date ? r : new Date(x().parse(r) * 1e3), "Date");
1023
+ function et(r, t) {
1024
+ return new F((e) => {
1025
+ if (typeof e != "string" && !(e instanceof URLSearchParams))
1029
1026
  throw V();
1030
- const s = typeof t == "string" ? new URLSearchParams(t) : t;
1031
- return de(r, (n) => {
1027
+ const s = typeof e == "string" ? new URLSearchParams(e) : e;
1028
+ return dt(r, (n) => {
1032
1029
  const i = s.get(n);
1033
1030
  return i === null ? void 0 : i;
1034
1031
  });
1035
- }, !1, e);
1032
+ }, !1, t);
1036
1033
  }
1037
- function me() {
1038
- return ee({
1034
+ function yt() {
1035
+ return et({
1039
1036
  authDate: {
1040
- type: be(),
1037
+ type: mt(),
1041
1038
  from: "auth_date"
1042
1039
  },
1043
1040
  canSendAfter: {
1044
1041
  type: x().optional(),
1045
1042
  from: "can_send_after"
1046
1043
  },
1047
- chat: ht().optional(),
1044
+ chat: he().optional(),
1048
1045
  chatInstance: {
1049
1046
  type: h().optional(),
1050
1047
  from: "chat_instance"
@@ -1058,28 +1055,28 @@ function me() {
1058
1055
  type: h().optional(),
1059
1056
  from: "query_id"
1060
1057
  },
1061
- receiver: ie().optional(),
1058
+ receiver: it().optional(),
1062
1059
  startParam: {
1063
1060
  type: h().optional(),
1064
1061
  from: "start_param"
1065
1062
  },
1066
- user: ie().optional()
1063
+ user: it().optional()
1067
1064
  }, "InitData");
1068
1065
  }
1069
- function er(r) {
1070
- return me().parse(r);
1066
+ function tr(r) {
1067
+ return yt().parse(r);
1071
1068
  }
1072
- function pt(r) {
1073
- const { hostname: e, pathname: t } = new URL(r, window.location.href);
1074
- if (e !== "t.me")
1075
- throw new Error(`Incorrect hostname: ${e}`);
1076
- const s = t.match(/^\/(\$|invoice\/)([A-Za-z0-9\-_=]+)$/);
1069
+ function pe(r) {
1070
+ const { hostname: t, pathname: e } = new URL(r, window.location.href);
1071
+ if (t !== "t.me")
1072
+ throw new Error(`Incorrect hostname: ${t}`);
1073
+ const s = e.match(/^\/(\$|invoice\/)([A-Za-z0-9\-_=]+)$/);
1077
1074
  if (s === null)
1078
1075
  throw new Error('Link pathname has incorrect format. Expected to receive "/invoice/{slug}" or "/${slug}"');
1079
1076
  return s[2];
1080
1077
  }
1081
- class lt {
1082
- constructor(e, t = d) {
1078
+ class le {
1079
+ constructor(t, e = d) {
1083
1080
  o(this, "ee", new w());
1084
1081
  o(this, "state");
1085
1082
  /**
@@ -1094,10 +1091,10 @@ class lt {
1094
1091
  * Checks if specified method is supported by current component.
1095
1092
  */
1096
1093
  o(this, "supports");
1097
- this.postEvent = t, this.state = new m({ isOpened: !1 }, this.ee), this.supports = C(e, { open: "web_app_open_invoice" });
1094
+ this.postEvent = e, this.state = new m({ isOpened: !1 }, this.ee), this.supports = C(t, { open: "web_app_open_invoice" });
1098
1095
  }
1099
- set isOpened(e) {
1100
- this.state.set("isOpened", e);
1096
+ set isOpened(t) {
1097
+ this.state.set("isOpened", t);
1101
1098
  }
1102
1099
  /**
1103
1100
  * True if invoice is currently opened.
@@ -1105,10 +1102,10 @@ class lt {
1105
1102
  get isOpened() {
1106
1103
  return this.state.get("isOpened");
1107
1104
  }
1108
- async open(e, t) {
1105
+ async open(t, e) {
1109
1106
  if (this.isOpened)
1110
1107
  throw new Error("Invoice is already opened");
1111
- const s = t ? pt(e) : e;
1108
+ const s = e ? pe(t) : t;
1112
1109
  this.isOpened = !0;
1113
1110
  try {
1114
1111
  return (await y("web_app_open_invoice", "invoice_closed", {
@@ -1123,8 +1120,8 @@ class lt {
1123
1120
  }
1124
1121
  }
1125
1122
  }
1126
- class dt {
1127
- constructor(e) {
1123
+ class de {
1124
+ constructor(t) {
1128
1125
  o(this, "ee", new w());
1129
1126
  o(this, "state");
1130
1127
  o(this, "postEvent");
@@ -1133,28 +1130,28 @@ class dt {
1133
1130
  * @param event - event name.
1134
1131
  * @param listener - event listener.
1135
1132
  */
1136
- o(this, "on", (e, t) => (
1133
+ o(this, "on", (t, e) => (
1137
1134
  // FIXME: Event 'main_button_pressed' is still being received on Android
1138
1135
  // even if the main button is disabled.
1139
1136
  // Issue: https://github.com/Telegram-Mini-Apps/tma.js/issues/3
1140
- e === "click" ? E("main_button_pressed", t) : this.ee.on(e, t)
1137
+ t === "click" ? E("main_button_pressed", e) : this.ee.on(t, e)
1141
1138
  ));
1142
1139
  /**
1143
1140
  * Removes event listener.
1144
1141
  * @param event - event name.
1145
1142
  * @param listener - event listener.
1146
1143
  */
1147
- o(this, "off", (e, t) => e === "click" ? I("main_button_pressed", t) : this.ee.off(e, t));
1144
+ o(this, "off", (t, e) => t === "click" ? I("main_button_pressed", e) : this.ee.off(t, e));
1148
1145
  const {
1149
- postEvent: t = d,
1146
+ postEvent: e = d,
1150
1147
  text: s,
1151
1148
  textColor: n,
1152
1149
  backgroundColor: i,
1153
1150
  isEnabled: a,
1154
1151
  isVisible: c,
1155
1152
  isLoaderVisible: u
1156
- } = e;
1157
- this.postEvent = t, this.state = new m({
1153
+ } = t;
1154
+ this.postEvent = e, this.state = new m({
1158
1155
  backgroundColor: i,
1159
1156
  isEnabled: a,
1160
1157
  isVisible: c,
@@ -1176,8 +1173,8 @@ class dt {
1176
1173
  text_color: this.textColor
1177
1174
  });
1178
1175
  }
1179
- set isEnabled(e) {
1180
- this.setParams({ isEnabled: e });
1176
+ set isEnabled(t) {
1177
+ this.setParams({ isEnabled: t });
1181
1178
  }
1182
1179
  /**
1183
1180
  * True if the Main Button is currently enabled.
@@ -1185,8 +1182,8 @@ class dt {
1185
1182
  get isEnabled() {
1186
1183
  return this.state.get("isEnabled");
1187
1184
  }
1188
- set isLoaderVisible(e) {
1189
- this.setParams({ isLoaderVisible: e });
1185
+ set isLoaderVisible(t) {
1186
+ this.setParams({ isLoaderVisible: t });
1190
1187
  }
1191
1188
  /**
1192
1189
  * True if the Main Button loader is currently visible.
@@ -1194,8 +1191,8 @@ class dt {
1194
1191
  get isLoaderVisible() {
1195
1192
  return this.state.get("isLoaderVisible");
1196
1193
  }
1197
- set isVisible(e) {
1198
- this.setParams({ isVisible: e });
1194
+ set isVisible(t) {
1195
+ this.setParams({ isVisible: t });
1199
1196
  }
1200
1197
  /**
1201
1198
  * True if the Main Button is currently visible.
@@ -1263,32 +1260,32 @@ class dt {
1263
1260
  * Sets new Main Button text. Minimal length for text is 1 symbol, and maximum is 64 symbols.
1264
1261
  * @param text - new text.
1265
1262
  */
1266
- setText(e) {
1267
- return this.setParams({ text: e });
1263
+ setText(t) {
1264
+ return this.setParams({ text: t });
1268
1265
  }
1269
1266
  /**
1270
1267
  * Sets new Main Button text color.
1271
1268
  * @param textColor - new text color.
1272
1269
  */
1273
- setTextColor(e) {
1274
- return this.setParams({ textColor: e });
1270
+ setTextColor(t) {
1271
+ return this.setParams({ textColor: t });
1275
1272
  }
1276
1273
  /**
1277
1274
  * Updates current Main Button color.
1278
1275
  * @param backgroundColor - color to set.
1279
1276
  */
1280
- setBackgroundColor(e) {
1281
- return this.setParams({ backgroundColor: e });
1277
+ setBackgroundColor(t) {
1278
+ return this.setParams({ backgroundColor: t });
1282
1279
  }
1283
1280
  /**
1284
1281
  * Allows setting multiple Main Button parameters.
1285
1282
  * @param params - Main Button parameters.
1286
1283
  */
1287
- setParams(e) {
1288
- return this.state.set(e), this.commit(), this;
1284
+ setParams(t) {
1285
+ return this.state.set(t), this.commit(), this;
1289
1286
  }
1290
1287
  }
1291
- const ft = ee({
1288
+ const fe = et({
1292
1289
  contact: f({
1293
1290
  userId: {
1294
1291
  type: x(),
@@ -1308,24 +1305,24 @@ const ft = ee({
1308
1305
  }
1309
1306
  }),
1310
1307
  authDate: {
1311
- type: be(),
1308
+ type: mt(),
1312
1309
  from: "auth_date"
1313
1310
  },
1314
1311
  hash: h()
1315
1312
  });
1316
- function ye(r, e) {
1317
- return (t) => {
1318
- const [s, n] = e[t];
1313
+ function Et(r, t) {
1314
+ return (e) => {
1315
+ const [s, n] = t[e];
1319
1316
  return A(s, n, r);
1320
1317
  };
1321
1318
  }
1322
- function gt(r) {
1323
- return new Promise((e) => {
1324
- setTimeout(e, r);
1319
+ function ge(r) {
1320
+ return new Promise((t) => {
1321
+ setTimeout(t, r);
1325
1322
  });
1326
1323
  }
1327
- class wt {
1328
- constructor(e) {
1324
+ class we {
1325
+ constructor(t) {
1329
1326
  o(this, "ee", new w());
1330
1327
  o(this, "state");
1331
1328
  o(this, "botInline");
@@ -1350,20 +1347,20 @@ class wt {
1350
1347
  */
1351
1348
  o(this, "supportsParam");
1352
1349
  const {
1353
- postEvent: t = d,
1350
+ postEvent: e = d,
1354
1351
  headerColor: s,
1355
1352
  backgroundColor: n,
1356
1353
  version: i,
1357
1354
  botInline: a,
1358
1355
  createRequestId: c
1359
- } = e, u = C(i, {
1356
+ } = t, u = C(i, {
1360
1357
  requestPhoneAccess: "web_app_request_phone",
1361
1358
  requestWriteAccess: "web_app_request_write_access",
1362
1359
  switchInlineQuery: "web_app_switch_inline_query",
1363
1360
  setHeaderColor: "web_app_set_header_color",
1364
1361
  setBackgroundColor: "web_app_set_background_color"
1365
1362
  });
1366
- this.postEvent = t, this.botInline = a, this.createRequestId = c, this.supports = (p) => !(!u(p) || p === "switchInlineQuery" && !a), this.state = new m({ backgroundColor: n, headerColor: s }, this.ee), this.supportsParam = ye(i, {
1363
+ this.postEvent = e, this.botInline = a, this.createRequestId = c, this.supports = (p) => !(!u(p) || p === "switchInlineQuery" && !a), this.state = new m({ backgroundColor: n, headerColor: s }, this.ee), this.supportsParam = Et(i, {
1367
1364
  "setHeaderColor.color": ["web_app_set_header_color", "color"]
1368
1365
  });
1369
1366
  }
@@ -1371,7 +1368,7 @@ class wt {
1371
1368
  * Attempts to get requested contact.
1372
1369
  */
1373
1370
  async getRequestedContact() {
1374
- return O(
1371
+ return D(
1375
1372
  "getRequestedContact",
1376
1373
  {},
1377
1374
  this.createRequestId(),
@@ -1379,7 +1376,7 @@ class wt {
1379
1376
  postEvent: this.postEvent,
1380
1377
  timeout: 1e4
1381
1378
  }
1382
- ).then((e) => ft.parse(e));
1379
+ ).then((t) => fe.parse(t));
1383
1380
  }
1384
1381
  /**
1385
1382
  * The Mini App background color.
@@ -1409,7 +1406,7 @@ class wt {
1409
1406
  * True if current Mini App background color recognized as dark.
1410
1407
  */
1411
1408
  get isDark() {
1412
- return _e(this.backgroundColor);
1409
+ return bt(this.backgroundColor);
1413
1410
  }
1414
1411
  /**
1415
1412
  * True if phone access is currently being requested.
@@ -1441,25 +1438,25 @@ class wt {
1441
1438
  * failed.
1442
1439
  * @param options - additional options.
1443
1440
  */
1444
- async requestContact({ timeout: e = 5e3 } = {}) {
1441
+ async requestContact({ timeout: t = 5e3 } = {}) {
1445
1442
  try {
1446
1443
  return await this.getRequestedContact();
1447
1444
  } catch {
1448
1445
  }
1449
1446
  if (await this.requestPhoneAccess() !== "sent")
1450
1447
  throw new Error("Access denied.");
1451
- const s = Date.now() + e;
1448
+ const s = Date.now() + t;
1452
1449
  let n = 50;
1453
- return we(async () => {
1450
+ return wt(async () => {
1454
1451
  for (; Date.now() < s; ) {
1455
1452
  try {
1456
1453
  return await this.getRequestedContact();
1457
1454
  } catch {
1458
1455
  }
1459
- await gt(n), n += 50;
1456
+ await ge(n), n += 50;
1460
1457
  }
1461
1458
  throw new Error("Unable to retrieve requested contact.");
1462
- }, e);
1459
+ }, t);
1463
1460
  }
1464
1461
  /**
1465
1462
  * Requests current user phone access. Method returns promise, which resolves
@@ -1470,13 +1467,13 @@ class wt {
1470
1467
  * @param options - additional options.
1471
1468
  * @see requestContact
1472
1469
  */
1473
- requestPhoneAccess(e = {}) {
1470
+ requestPhoneAccess(t = {}) {
1474
1471
  if (this.requestingPhoneAccess)
1475
1472
  throw new Error("Phone access is already being requested.");
1476
1473
  return this.requestingPhoneAccess = !0, y("web_app_request_phone", "phone_requested", {
1477
- ...e,
1474
+ ...t,
1478
1475
  postEvent: this.postEvent
1479
- }).then((t) => t.status).finally(() => {
1476
+ }).then((e) => e.status).finally(() => {
1480
1477
  this.requestingPhoneAccess = !1;
1481
1478
  });
1482
1479
  }
@@ -1484,13 +1481,13 @@ class wt {
1484
1481
  * Requests write message access to current user.
1485
1482
  * @param options - additional options.
1486
1483
  */
1487
- requestWriteAccess(e = {}) {
1484
+ requestWriteAccess(t = {}) {
1488
1485
  if (this.requestingWriteAccess)
1489
1486
  throw new Error("Write access is already being requested.");
1490
1487
  return this.requestingWriteAccess = !0, y("web_app_request_write_access", "write_access_requested", {
1491
- ...e,
1488
+ ...t,
1492
1489
  postEvent: this.postEvent
1493
- }).then((t) => t.status).finally(() => {
1490
+ }).then((e) => e.status).finally(() => {
1494
1491
  this.requestingWriteAccess = !1;
1495
1492
  });
1496
1493
  }
@@ -1503,25 +1500,25 @@ class wt {
1503
1500
  * @param data - data to send to bot.
1504
1501
  * @throws {Error} data has incorrect size.
1505
1502
  */
1506
- sendData(e) {
1507
- const { size: t } = new Blob([e]);
1508
- if (t === 0 || t > 4096)
1509
- throw new Error(`Passed data has incorrect size: ${t}`);
1510
- this.postEvent("web_app_data_send", { data: e });
1503
+ sendData(t) {
1504
+ const { size: e } = new Blob([t]);
1505
+ if (e === 0 || e > 4096)
1506
+ throw new Error(`Passed data has incorrect size: ${e}`);
1507
+ this.postEvent("web_app_data_send", { data: t });
1511
1508
  }
1512
1509
  /**
1513
1510
  * Updates current Mini App header color.
1514
1511
  * @param color - color key or RGB color.
1515
1512
  */
1516
- setHeaderColor(e) {
1517
- this.postEvent("web_app_set_header_color", X(e) ? { color: e } : { color_key: e }), this.state.set("headerColor", e);
1513
+ setHeaderColor(t) {
1514
+ this.postEvent("web_app_set_header_color", tt(t) ? { color: t } : { color_key: t }), this.state.set("headerColor", t);
1518
1515
  }
1519
1516
  /**
1520
1517
  * Updates current Mini App background color.
1521
1518
  * @param color - RGB color.
1522
1519
  */
1523
- setBackgroundColor(e) {
1524
- this.postEvent("web_app_set_background_color", { color: e }), this.state.set("backgroundColor", e);
1520
+ setBackgroundColor(t) {
1521
+ this.postEvent("web_app_set_background_color", { color: t }), this.state.set("backgroundColor", t);
1525
1522
  }
1526
1523
  /**
1527
1524
  * Inserts the bot's username and the specified inline query in the current chat's input field.
@@ -1533,22 +1530,22 @@ class wt {
1533
1530
  * @param chatTypes - List of chat types which could be chosen to send the message. Could be
1534
1531
  * empty list.
1535
1532
  */
1536
- switchInlineQuery(e, t = []) {
1533
+ switchInlineQuery(t, e = []) {
1537
1534
  if (!this.supports("switchInlineQuery") && !this.isBotInline)
1538
1535
  throw new Error("Method is unsupported because Mini App should be launched in inline mode.");
1539
1536
  this.postEvent("web_app_switch_inline_query", {
1540
- query: e,
1541
- chat_types: t
1537
+ query: t,
1538
+ chat_types: e
1542
1539
  });
1543
1540
  }
1544
1541
  }
1545
- function _t(r) {
1546
- const e = r.message.trim(), t = (r.title || "").trim(), s = r.buttons || [];
1542
+ function _e(r) {
1543
+ const t = r.message.trim(), e = (r.title || "").trim(), s = r.buttons || [];
1547
1544
  let n;
1548
- if (t.length > 64)
1549
- throw new Error(`Title has incorrect size: ${t.length}`);
1550
- if (e.length === 0 || e.length > 256)
1551
- throw new Error(`Message has incorrect size: ${e.length}`);
1545
+ if (e.length > 64)
1546
+ throw new Error(`Title has incorrect size: ${e.length}`);
1547
+ if (t.length === 0 || t.length > 256)
1548
+ throw new Error(`Message has incorrect size: ${t.length}`);
1552
1549
  if (s.length > 3)
1553
1550
  throw new Error(`Buttons have incorrect size: ${s.length}`);
1554
1551
  return s.length === 0 ? n = [{ type: "close", id: "" }] : n = s.map((i) => {
@@ -1564,10 +1561,10 @@ function _t(r) {
1564
1561
  return { ...i, text: c, id: a };
1565
1562
  }
1566
1563
  return { ...i, id: a };
1567
- }), { title: t, message: e, buttons: n };
1564
+ }), { title: e, message: t, buttons: n };
1568
1565
  }
1569
- class bt {
1570
- constructor(e, t = d) {
1566
+ class be {
1567
+ constructor(t, e = d) {
1571
1568
  o(this, "ee", new w());
1572
1569
  o(this, "state");
1573
1570
  /**
@@ -1582,10 +1579,10 @@ class bt {
1582
1579
  * Checks if specified method is supported by current component.
1583
1580
  */
1584
1581
  o(this, "supports");
1585
- this.postEvent = t, this.state = new m({ isOpened: !1 }, this.ee), this.supports = C(e, { open: "web_app_open_popup" });
1582
+ this.postEvent = e, this.state = new m({ isOpened: !1 }, this.ee), this.supports = C(t, { open: "web_app_open_popup" });
1586
1583
  }
1587
- set isOpened(e) {
1588
- this.state.set("isOpened", e);
1584
+ set isOpened(t) {
1585
+ this.state.set("isOpened", t);
1589
1586
  }
1590
1587
  /**
1591
1588
  * True if popup is currently opened.
@@ -1606,19 +1603,19 @@ class bt {
1606
1603
  * @param options - popup parameters.
1607
1604
  * @throws {Error} Popup is already opened.
1608
1605
  */
1609
- open(e) {
1606
+ open(t) {
1610
1607
  if (this.isOpened)
1611
1608
  throw new Error("Popup is already opened.");
1612
1609
  return this.isOpened = !0, y("web_app_open_popup", "popup_closed", {
1613
1610
  postEvent: this.postEvent,
1614
- params: _t(e)
1615
- }).then(({ button_id: t = null }) => t).finally(() => {
1611
+ params: _e(t)
1612
+ }).then(({ button_id: e = null }) => e).finally(() => {
1616
1613
  this.isOpened = !1;
1617
1614
  });
1618
1615
  }
1619
1616
  }
1620
- class mt {
1621
- constructor(e, t = d) {
1617
+ class me {
1618
+ constructor(t, e = d) {
1622
1619
  o(this, "ee", new w());
1623
1620
  o(this, "state");
1624
1621
  /**
@@ -1633,7 +1630,7 @@ class mt {
1633
1630
  * Checks if specified method is supported by current component.
1634
1631
  */
1635
1632
  o(this, "supports");
1636
- this.postEvent = t, this.state = new m({ isOpened: !1 }, this.ee), this.supports = C(e, {
1633
+ this.postEvent = e, this.state = new m({ isOpened: !1 }, this.ee), this.supports = C(t, {
1637
1634
  close: "web_app_close_scan_qr_popup",
1638
1635
  open: "web_app_open_scan_qr_popup"
1639
1636
  });
@@ -1644,8 +1641,8 @@ class mt {
1644
1641
  close() {
1645
1642
  this.postEvent("web_app_close_scan_qr_popup"), this.isOpened = !1;
1646
1643
  }
1647
- set isOpened(e) {
1648
- this.state.set("isOpened", e);
1644
+ set isOpened(t) {
1645
+ this.state.set("isOpened", t);
1649
1646
  }
1650
1647
  /**
1651
1648
  * Returns true in case, QR scanner is currently opened.
@@ -1659,27 +1656,27 @@ class mt {
1659
1656
  * case, scanner was closed.
1660
1657
  * @param text - title to display.
1661
1658
  */
1662
- async open(e) {
1659
+ async open(t) {
1663
1660
  if (this.isOpened)
1664
1661
  throw new Error("QR scanner is already opened.");
1665
1662
  this.isOpened = !0;
1666
1663
  try {
1667
- const t = await y(
1664
+ const e = await y(
1668
1665
  "web_app_open_scan_qr_popup",
1669
1666
  ["qr_text_received", "scan_qr_popup_closed"],
1670
1667
  {
1671
1668
  postEvent: this.postEvent,
1672
- params: { text: e }
1669
+ params: { text: t }
1673
1670
  }
1674
1671
  );
1675
- return typeof t == "object" && typeof t.data == "string" ? t.data : null;
1672
+ return typeof e == "object" && typeof e.data == "string" ? e.data : null;
1676
1673
  } finally {
1677
1674
  this.isOpened = !1;
1678
1675
  }
1679
1676
  }
1680
1677
  }
1681
- class yt {
1682
- constructor(e, t, s = d) {
1678
+ class ye {
1679
+ constructor(t, e, s = d) {
1683
1680
  o(this, "ee", new w());
1684
1681
  o(this, "state");
1685
1682
  /**
@@ -1687,24 +1684,24 @@ class yt {
1687
1684
  * @param event - event name.
1688
1685
  * @param listener - event listener.
1689
1686
  */
1690
- o(this, "on", (e, t) => e === "click" ? E("settings_button_pressed", t) : this.ee.on(e, t));
1687
+ o(this, "on", (t, e) => t === "click" ? E("settings_button_pressed", e) : this.ee.on(t, e));
1691
1688
  /**
1692
1689
  * Removes event listener.
1693
1690
  * @param event - event name.
1694
1691
  * @param listener - event listener.
1695
1692
  */
1696
- o(this, "off", (e, t) => e === "click" ? I("settings_button_pressed", t) : this.ee.off(e, t));
1693
+ o(this, "off", (t, e) => t === "click" ? I("settings_button_pressed", e) : this.ee.off(t, e));
1697
1694
  /**
1698
1695
  * Checks if specified method is supported by current component.
1699
1696
  */
1700
1697
  o(this, "supports");
1701
- this.postEvent = s, this.state = new m({ isVisible: e }, this.ee), this.supports = C(t, {
1698
+ this.postEvent = s, this.state = new m({ isVisible: t }, this.ee), this.supports = C(e, {
1702
1699
  show: "web_app_setup_settings_button",
1703
1700
  hide: "web_app_setup_settings_button"
1704
1701
  });
1705
1702
  }
1706
- set isVisible(e) {
1707
- this.state.set("isVisible", e), this.postEvent("web_app_setup_settings_button", { is_visible: e });
1703
+ set isVisible(t) {
1704
+ this.state.set("isVisible", t), this.postEvent("web_app_setup_settings_button", { is_visible: t });
1708
1705
  }
1709
1706
  /**
1710
1707
  * True if SettingsButton is currently visible.
@@ -1725,32 +1722,32 @@ class yt {
1725
1722
  this.isVisible = !0;
1726
1723
  }
1727
1724
  }
1728
- function Et(r) {
1729
- return r.replace(/(^|_)bg/, (e, t) => `${t}background`).replace(/_([a-z])/g, (e, t) => t.toUpperCase());
1725
+ function Ee(r) {
1726
+ return r.replace(/(^|_)bg/, (t, e) => `${e}background`).replace(/_([a-z])/g, (t, e) => e.toUpperCase());
1730
1727
  }
1731
- function Ct(r) {
1732
- return r.replace(/[A-Z]/g, (e) => `_${e.toLowerCase()}`).replace(/(^|_)background/, (e, t) => `${t}bg`);
1728
+ function Ce(r) {
1729
+ return r.replace(/[A-Z]/g, (t) => `_${t.toLowerCase()}`).replace(/(^|_)background/, (t, e) => `${e}bg`);
1733
1730
  }
1734
- const Ee = R(
1731
+ const Ct = R(
1735
1732
  (r) => {
1736
- const e = ge().optional();
1737
- return Object.entries(Y(r)).reduce((t, [s, n]) => (t[Et(s)] = e.parse(n), t), {});
1733
+ const t = gt().optional();
1734
+ return Object.entries(X(r)).reduce((e, [s, n]) => (e[Ee(s)] = t.parse(n), e), {});
1738
1735
  },
1739
1736
  "ThemeParams"
1740
1737
  );
1741
- function Ce(r) {
1742
- return Ee().parse(r);
1738
+ function vt(r) {
1739
+ return Ct().parse(r);
1743
1740
  }
1744
- function tr(r) {
1745
- return y("web_app_request_theme", "theme_changed", r).then(Ce);
1741
+ function er(r) {
1742
+ return y("web_app_request_theme", "theme_changed", r).then(vt);
1746
1743
  }
1747
- function vt(r) {
1744
+ function ve(r) {
1748
1745
  return JSON.stringify(
1749
- Object.entries(r).reduce((e, [t, s]) => (s && (e[Ct(t)] = s), e), {})
1746
+ Object.entries(r).reduce((t, [e, s]) => (s && (t[Ce(e)] = s), t), {})
1750
1747
  );
1751
1748
  }
1752
- class Pt {
1753
- constructor(e) {
1749
+ class Pe {
1750
+ constructor(t) {
1754
1751
  o(this, "ee", new w());
1755
1752
  o(this, "state");
1756
1753
  /**
@@ -1761,7 +1758,7 @@ class Pt {
1761
1758
  * Removes event listener.
1762
1759
  */
1763
1760
  o(this, "off", this.ee.off.bind(this.ee));
1764
- this.state = new m(e, this.ee);
1761
+ this.state = new m(t, this.ee);
1765
1762
  }
1766
1763
  /**
1767
1764
  * @since v6.10
@@ -1785,8 +1782,8 @@ class Pt {
1785
1782
  * Retrieves palette color value by its name.
1786
1783
  * @param key - palette key name.
1787
1784
  */
1788
- get(e) {
1789
- return this.state.get(e);
1785
+ get(t) {
1786
+ return this.state.get(t);
1790
1787
  }
1791
1788
  /**
1792
1789
  * Returns the copy of the internal state of the current component instance.
@@ -1808,7 +1805,7 @@ class Pt {
1808
1805
  * value is calculated according to theme background color.
1809
1806
  */
1810
1807
  get isDark() {
1811
- return !this.backgroundColor || _e(this.backgroundColor);
1808
+ return !this.backgroundColor || bt(this.backgroundColor);
1812
1809
  }
1813
1810
  get linkColor() {
1814
1811
  return this.get("linkColor");
@@ -1833,8 +1830,8 @@ class Pt {
1833
1830
  * @returns Function to stop listening.
1834
1831
  */
1835
1832
  listen() {
1836
- return E("theme_changed", (e) => {
1837
- this.state.set(Ce(e.theme_params));
1833
+ return E("theme_changed", (t) => {
1834
+ this.state.set(vt(t.theme_params));
1838
1835
  });
1839
1836
  }
1840
1837
  /**
@@ -1847,8 +1844,8 @@ class Pt {
1847
1844
  return this.get("textColor");
1848
1845
  }
1849
1846
  }
1850
- class St {
1851
- constructor(e, t, s = d) {
1847
+ class Se {
1848
+ constructor(t, e, s = d) {
1852
1849
  /**
1853
1850
  * Checks if specified method is supported by current component.
1854
1851
  */
@@ -1857,9 +1854,9 @@ class St {
1857
1854
  * Checks if specified method parameter is supported by current component.
1858
1855
  */
1859
1856
  o(this, "supportsParam");
1860
- this.version = e, this.createRequestId = t, this.postEvent = s, this.supports = C(e, {
1857
+ this.version = t, this.createRequestId = e, this.postEvent = s, this.supports = C(t, {
1861
1858
  readTextFromClipboard: "web_app_read_text_from_clipboard"
1862
- }), this.supportsParam = ye(e, {
1859
+ }), this.supportsParam = Et(t, {
1863
1860
  "openLink.tryInstantView": ["web_app_open_link", "try_instant_view"]
1864
1861
  });
1865
1862
  }
@@ -1872,15 +1869,15 @@ class St {
1872
1869
  * @param url - URL to be opened.
1873
1870
  * @param tryInstantView
1874
1871
  */
1875
- openLink(e, t) {
1876
- const s = new URL(e, window.location.href).toString();
1872
+ openLink(t, e) {
1873
+ const s = new URL(t, window.location.href).toString();
1877
1874
  if (!A("web_app_open_link", this.version)) {
1878
1875
  window.open(s, "_blank");
1879
1876
  return;
1880
1877
  }
1881
1878
  this.postEvent("web_app_open_link", {
1882
1879
  url: s,
1883
- ...typeof t == "boolean" ? { try_instant_view: t } : {}
1880
+ ...typeof e == "boolean" ? { try_instant_view: e } : {}
1884
1881
  });
1885
1882
  }
1886
1883
  /**
@@ -1889,16 +1886,16 @@ class St {
1889
1886
  * @param url - URL to be opened.
1890
1887
  * @throws {Error} URL has not allowed hostname.
1891
1888
  */
1892
- openTelegramLink(e) {
1889
+ openTelegramLink(t) {
1893
1890
  const {
1894
- hostname: t,
1891
+ hostname: e,
1895
1892
  pathname: s,
1896
1893
  search: n
1897
- } = new URL(e, window.location.href);
1898
- if (t !== "t.me")
1899
- throw new Error(`URL has not allowed hostname: ${t}. Only "t.me" is allowed`);
1894
+ } = new URL(t, window.location.href);
1895
+ if (e !== "t.me")
1896
+ throw new Error(`URL has not allowed hostname: ${e}. Only "t.me" is allowed`);
1900
1897
  if (!A("web_app_open_tg_link", this.version)) {
1901
- window.location.href = e;
1898
+ window.location.href = t;
1902
1899
  return;
1903
1900
  }
1904
1901
  this.postEvent("web_app_open_tg_link", { path_full: s + n });
@@ -1910,33 +1907,33 @@ class St {
1910
1907
  * - Access to clipboard is not allowed
1911
1908
  */
1912
1909
  async readTextFromClipboard() {
1913
- const e = this.createRequestId(), {
1914
- data: t = null
1910
+ const t = this.createRequestId(), {
1911
+ data: e = null
1915
1912
  } = await y("web_app_read_text_from_clipboard", "clipboard_text_received", {
1916
1913
  postEvent: this.postEvent,
1917
- params: { req_id: e },
1918
- capture: le(e)
1914
+ params: { req_id: t },
1915
+ capture: lt(t)
1919
1916
  });
1920
- return t;
1917
+ return e;
1921
1918
  }
1922
1919
  }
1923
- function kt(r) {
1920
+ function ke(r) {
1924
1921
  return ["macos", "tdesktop", "unigram", "web", "weba"].includes(r);
1925
1922
  }
1926
- async function ve(r) {
1927
- const e = await y("web_app_request_viewport", "viewport_changed", r);
1923
+ async function Pt(r) {
1924
+ const t = await y("web_app_request_viewport", "viewport_changed", r);
1928
1925
  return {
1929
- height: e.height,
1930
- width: e.width,
1931
- isExpanded: e.is_expanded,
1932
- isStateStable: e.is_state_stable
1926
+ height: t.height,
1927
+ width: t.width,
1928
+ isExpanded: t.is_expanded,
1929
+ isStateStable: t.is_state_stable
1933
1930
  };
1934
1931
  }
1935
1932
  function L(r) {
1936
1933
  return r < 0 ? 0 : r;
1937
1934
  }
1938
- class xt {
1939
- constructor(e) {
1935
+ class xe {
1936
+ constructor(t) {
1940
1937
  o(this, "ee", new w());
1941
1938
  o(this, "state");
1942
1939
  o(this, "postEvent");
@@ -1949,14 +1946,14 @@ class xt {
1949
1946
  */
1950
1947
  o(this, "off", this.ee.off.bind(this.ee));
1951
1948
  const {
1952
- height: t,
1949
+ height: e,
1953
1950
  isExpanded: s,
1954
1951
  width: n,
1955
1952
  stableHeight: i,
1956
1953
  postEvent: a = d
1957
- } = e;
1954
+ } = t;
1958
1955
  this.postEvent = a, this.state = new m({
1959
- height: L(t),
1956
+ height: L(e),
1960
1957
  isExpanded: s,
1961
1958
  stableHeight: L(i),
1962
1959
  width: L(n)
@@ -1967,13 +1964,13 @@ class xt {
1967
1964
  * instance.
1968
1965
  * @param options - options to request fresh data.
1969
1966
  */
1970
- sync(e) {
1971
- return ve(e).then(({ height: t, isExpanded: s, width: n, isStateStable: i }) => {
1967
+ sync(t) {
1968
+ return Pt(t).then(({ height: e, isExpanded: s, width: n, isStateStable: i }) => {
1972
1969
  this.state.set({
1973
- height: t,
1970
+ height: e,
1974
1971
  width: n,
1975
1972
  isExpanded: s,
1976
- stableHeight: i ? t : this.state.get("stableHeight")
1973
+ stableHeight: i ? e : this.state.get("stableHeight")
1977
1974
  });
1978
1975
  });
1979
1976
  }
@@ -2018,14 +2015,14 @@ class xt {
2018
2015
  * @returns Function to stop listening.
2019
2016
  */
2020
2017
  listen() {
2021
- return E("viewport_changed", (e) => {
2018
+ return E("viewport_changed", (t) => {
2022
2019
  const {
2023
- height: t,
2020
+ height: e,
2024
2021
  width: s,
2025
2022
  is_expanded: n,
2026
2023
  is_state_stable: i
2027
- } = e, a = {
2028
- height: L(t),
2024
+ } = t, a = {
2025
+ height: L(e),
2029
2026
  isExpanded: n,
2030
2027
  width: L(s)
2031
2028
  };
@@ -2064,18 +2061,18 @@ class xt {
2064
2061
  return this.stableHeight === this.height;
2065
2062
  }
2066
2063
  }
2067
- function S(r, e) {
2068
- document.documentElement.style.setProperty(r, e);
2064
+ function S(r, t) {
2065
+ document.documentElement.style.setProperty(r, t);
2069
2066
  }
2070
- function qt(r, e) {
2071
- const t = () => {
2067
+ function qe(r, t) {
2068
+ const e = () => {
2072
2069
  S("--tg-background-color", r.backgroundColor);
2073
2070
  }, s = () => {
2074
2071
  const {
2075
2072
  backgroundColor: n,
2076
2073
  secondaryBackgroundColor: i
2077
- } = e;
2078
- if (X(r.headerColor)) {
2074
+ } = t;
2075
+ if (tt(r.headerColor)) {
2079
2076
  S("--tg-header-color", r.headerColor);
2080
2077
  return;
2081
2078
  }
@@ -2085,61 +2082,61 @@ function qt(r, e) {
2085
2082
  }
2086
2083
  r.headerColor === "secondary_bg_color" && i && S("--tg-header-color", i);
2087
2084
  };
2088
- e.on("change", s), r.on("change:backgroundColor", t), r.on("change:headerColor", s), t(), s();
2085
+ t.on("change", s), r.on("change:backgroundColor", e), r.on("change:headerColor", s), e(), s();
2089
2086
  }
2090
- function At(r) {
2091
- const e = () => {
2092
- const t = r.getState();
2093
- Object.entries(t).forEach(([s, n]) => {
2087
+ function Ae(r) {
2088
+ const t = () => {
2089
+ const e = r.getState();
2090
+ Object.entries(e).forEach(([s, n]) => {
2094
2091
  if (n) {
2095
2092
  const i = s.replace(/[A-Z]/g, (a) => `-${a.toLowerCase()}`);
2096
2093
  S(`--tg-theme-${i}`, n);
2097
2094
  }
2098
2095
  });
2099
2096
  };
2100
- r.on("change", e), e();
2097
+ r.on("change", t), t();
2101
2098
  }
2102
- function oe(r) {
2103
- const e = () => S("--tg-viewport-height", `${r.height}px`), t = () => S("--tg-viewport-width", `${r.width}px`), s = () => S("--tg-viewport-stable-height", `${r.stableHeight}px`);
2104
- r.on("change:height", e), r.on("change:width", t), r.on("change:stableHeight", s), e(), t(), s();
2099
+ function ot(r) {
2100
+ const t = () => S("--tg-viewport-height", `${r.height}px`), e = () => S("--tg-viewport-width", `${r.width}px`), s = () => S("--tg-viewport-stable-height", `${r.stableHeight}px`);
2101
+ r.on("change:height", t), r.on("change:width", e), r.on("change:stableHeight", s), t(), e(), s();
2105
2102
  }
2106
- function Vt() {
2103
+ function Ve() {
2107
2104
  const r = document.createElement("style");
2108
- r.id = "telegram-custom-styles", document.head.appendChild(r), E("set_custom_style", (e) => {
2109
- r.innerHTML = e;
2105
+ r.id = "telegram-custom-styles", document.head.appendChild(r), E("set_custom_style", (t) => {
2106
+ r.innerHTML = t;
2110
2107
  });
2111
2108
  }
2112
- function Pe(r) {
2109
+ function St(r) {
2113
2110
  return `telegram-mini-apps-${r}`;
2114
2111
  }
2115
- function T(r, e) {
2116
- sessionStorage.setItem(Pe(r), JSON.stringify(e));
2112
+ function T(r, t) {
2113
+ sessionStorage.setItem(St(r), JSON.stringify(t));
2117
2114
  }
2118
2115
  function $(r) {
2119
- const e = sessionStorage.getItem(Pe(r));
2120
- return e ? JSON.parse(e) : null;
2116
+ const t = sessionStorage.getItem(St(r));
2117
+ return t ? JSON.parse(t) : null;
2121
2118
  }
2122
- function Rt(r, e, t) {
2123
- const { isVisible: s = !1 } = r ? $("back-button") || {} : {}, n = new rt(s, e, t);
2119
+ function Re(r, t, e) {
2120
+ const { isVisible: s = !1 } = r ? $("back-button") || {} : {}, n = new re(s, t, e);
2124
2121
  return n.on("change", () => {
2125
2122
  T("back-button", { isVisible: n.isVisible });
2126
2123
  }), n;
2127
2124
  }
2128
- function It(r, e) {
2129
- const { isConfirmationNeeded: t = !1 } = r ? $("closing-behavior") || {} : {}, s = new st(t, e);
2125
+ function Ie(r, t) {
2126
+ const { isConfirmationNeeded: e = !1 } = r ? $("closing-behavior") || {} : {}, s = new se(e, t);
2130
2127
  return s.on("change", () => T("closing-behavior", {
2131
2128
  isConfirmationNeeded: s.isConfirmationNeeded
2132
2129
  })), s;
2133
2130
  }
2134
- function Tt(r, e, t, s) {
2131
+ function Te(r, t, e, s) {
2135
2132
  const {
2136
- backgroundColor: n = e,
2133
+ backgroundColor: n = t,
2137
2134
  isEnabled: i = !1,
2138
2135
  isVisible: a = !1,
2139
2136
  isLoaderVisible: c = !1,
2140
- textColor: u = t,
2137
+ textColor: u = e,
2141
2138
  text: p = ""
2142
- } = r ? $("main-button") || {} : {}, g = new dt({
2139
+ } = r ? $("main-button") || {} : {}, g = new de({
2143
2140
  backgroundColor: n,
2144
2141
  isEnabled: i,
2145
2142
  isLoaderVisible: c,
@@ -2157,14 +2154,14 @@ function Tt(r, e, t, s) {
2157
2154
  });
2158
2155
  return g.on("change", _), g;
2159
2156
  }
2160
- function $t(r, e, t, s, n, i) {
2157
+ function $e(r, t, e, s, n, i) {
2161
2158
  const {
2162
- backgroundColor: a = e,
2159
+ backgroundColor: a = t,
2163
2160
  headerColor: c = "bg_color"
2164
- } = r ? $("mini-app") || {} : {}, u = new wt({
2161
+ } = r ? $("mini-app") || {} : {}, u = new we({
2165
2162
  headerColor: c,
2166
2163
  backgroundColor: a,
2167
- version: t,
2164
+ version: e,
2168
2165
  botInline: s,
2169
2166
  createRequestId: n,
2170
2167
  postEvent: i
@@ -2174,80 +2171,80 @@ function $t(r, e, t, s, n, i) {
2174
2171
  });
2175
2172
  return u.on("change", p), u;
2176
2173
  }
2177
- function Lt() {
2174
+ function Le() {
2178
2175
  let r = 0;
2179
2176
  return () => (r += 1, r.toString());
2180
2177
  }
2181
- function Bt(r, e, t) {
2182
- const { isVisible: s = !1 } = r ? $("settings-button") || {} : {}, n = new yt(s, e, t);
2178
+ function Be(r, t, e) {
2179
+ const { isVisible: s = !1 } = r ? $("settings-button") || {} : {}, n = new ye(s, t, e);
2183
2180
  return n.on("change", () => {
2184
2181
  T("settings-button", { isVisible: n.isVisible });
2185
2182
  }), n;
2186
2183
  }
2187
- function Ot(r) {
2188
- const e = new Pt(r);
2189
- return e.listen(), e;
2190
- }
2191
- function N(r) {
2192
- const e = new xt(r);
2193
- return e.on("change", () => T("viewport", {
2194
- height: e.height,
2195
- isExpanded: e.isExpanded,
2196
- stableHeight: e.stableHeight,
2197
- width: e.width
2198
- })), e.listen(), e;
2199
- }
2200
- function Dt(r, e, t, s) {
2184
+ function De(r) {
2185
+ const t = new Pe(r);
2186
+ return t.listen(), t;
2187
+ }
2188
+ function M(r) {
2189
+ const t = new xe(r);
2190
+ return t.on("change", () => T("viewport", {
2191
+ height: t.height,
2192
+ isExpanded: t.isExpanded,
2193
+ stableHeight: t.stableHeight,
2194
+ width: t.width
2195
+ })), t.listen(), t;
2196
+ }
2197
+ function Oe(r, t, e, s) {
2201
2198
  const n = r ? $("viewport") : null;
2202
2199
  if (n)
2203
- return N({ ...n, postEvent: t });
2204
- if (kt(e))
2205
- return N({
2200
+ return M({ ...n, postEvent: e });
2201
+ if (ke(t))
2202
+ return M({
2206
2203
  height: window.innerHeight,
2207
2204
  isExpanded: !0,
2208
- postEvent: t,
2205
+ postEvent: e,
2209
2206
  stableHeight: window.innerHeight,
2210
2207
  width: window.innerWidth
2211
2208
  });
2212
2209
  if (s)
2213
- return ve({
2214
- postEvent: t,
2210
+ return Pt({
2211
+ postEvent: e,
2215
2212
  timeout: 5e3
2216
- }).then(({ height: a, isStateStable: c, ...u }) => N({
2213
+ }).then(({ height: a, isStateStable: c, ...u }) => M({
2217
2214
  ...u,
2218
2215
  height: a,
2219
2216
  stableHeight: c ? a : 0
2220
2217
  }));
2221
- const i = N({
2218
+ const i = M({
2222
2219
  width: 0,
2223
2220
  height: 0,
2224
2221
  isExpanded: !1,
2225
- postEvent: t,
2222
+ postEvent: e,
2226
2223
  stableHeight: 0
2227
2224
  });
2228
- return i.sync({ postEvent: t, timeout: 5e3 }).catch((a) => {
2225
+ return i.sync({ postEvent: e, timeout: 5e3 }).catch((a) => {
2229
2226
  console.error("Unable to actualize viewport state", a);
2230
2227
  }), i;
2231
2228
  }
2232
- function Wt(r) {
2229
+ function We(r) {
2233
2230
  return typeof r == "object" ? r : r ? {
2234
2231
  themeParams: !0,
2235
2232
  viewport: !0,
2236
2233
  miniApp: !0
2237
2234
  } : {};
2238
2235
  }
2239
- function ae(r, e, t, s) {
2240
- const n = Wt(r);
2241
- n.miniApp && qt(e, t), n.themeParams && At(t), n.viewport && (s instanceof Promise ? s.then(oe) : oe(s));
2236
+ function at(r, t, e, s) {
2237
+ const n = We(r);
2238
+ n.miniApp && qe(t, e), n.themeParams && Ae(e), n.viewport && (s instanceof Promise ? s.then(ot) : ot(s));
2242
2239
  }
2243
- function Ht() {
2244
- return ee({
2240
+ function He() {
2241
+ return et({
2245
2242
  botInline: {
2246
2243
  type: P().optional(),
2247
2244
  from: "tgWebAppBotInline"
2248
2245
  },
2249
2246
  initData: {
2250
- type: me().optional(),
2247
+ type: yt().optional(),
2251
2248
  from: "tgWebAppData"
2252
2249
  },
2253
2250
  initDataRaw: {
@@ -2267,7 +2264,7 @@ function Ht() {
2267
2264
  from: "tgWebAppStartParam"
2268
2265
  },
2269
2266
  themeParams: {
2270
- type: Ee(),
2267
+ type: Ct(),
2271
2268
  from: "tgWebAppThemeParams"
2272
2269
  },
2273
2270
  version: {
@@ -2276,71 +2273,72 @@ function Ht() {
2276
2273
  }
2277
2274
  }, "LaunchParams");
2278
2275
  }
2279
- function Se(r) {
2280
- return Ht().parse(r);
2276
+ function kt(r) {
2277
+ return He().parse(r);
2281
2278
  }
2282
- function ke(r) {
2283
- const e = r.includes("?") ? r.replace("#", "&").slice(r.indexOf("?") + 1) : r.slice(r.indexOf("#") + 1);
2284
- return Se(e);
2279
+ function xt(r) {
2280
+ return kt(
2281
+ r.replace(/^[^?#]*[?#]/, "").replace(/[?#]/g, "&")
2282
+ );
2285
2283
  }
2286
- function Nt() {
2287
- return ke(window.location.href);
2284
+ function Ne() {
2285
+ return xt(window.location.href);
2288
2286
  }
2289
- function xe() {
2287
+ function qt() {
2290
2288
  return performance.getEntriesByType("navigation")[0];
2291
2289
  }
2292
- function Ut() {
2293
- const r = xe();
2290
+ function Ue() {
2291
+ const r = qt();
2294
2292
  if (!r)
2295
2293
  throw new Error("Unable to get first navigation entry.");
2296
- return ke(r.name);
2294
+ return xt(r.name);
2297
2295
  }
2298
- function Mt(r) {
2296
+ function Me(r) {
2299
2297
  const {
2300
- initDataRaw: e,
2301
- themeParams: t,
2298
+ initDataRaw: t,
2299
+ themeParams: e,
2302
2300
  platform: s,
2303
2301
  version: n,
2304
2302
  showSettings: i,
2305
2303
  startParam: a,
2306
2304
  botInline: c
2307
2305
  } = r, u = new URLSearchParams();
2308
- return e && u.set("tgWebAppData", e), u.set("tgWebAppPlatform", s), u.set("tgWebAppThemeParams", vt(t)), u.set("tgWebAppVersion", n), a && u.set("tgWebAppStartParam", n), typeof i == "boolean" && u.set("tgWebAppShowSettings", i ? "1" : "0"), typeof c == "boolean" && u.set("tgWebAppBotInline", c ? "1" : "0"), u.toString();
2306
+ return t && u.set("tgWebAppData", t), u.set("tgWebAppPlatform", s), u.set("tgWebAppThemeParams", ve(e)), u.set("tgWebAppVersion", n), a && u.set("tgWebAppStartParam", n), typeof i == "boolean" && u.set("tgWebAppShowSettings", i ? "1" : "0"), typeof c == "boolean" && u.set("tgWebAppBotInline", c ? "1" : "0"), u.toString();
2309
2307
  }
2310
- const qe = "telegram-mini-apps-launch-params";
2311
- function Gt() {
2312
- return Se(sessionStorage.getItem(qe) || "");
2308
+ const At = "telegram-mini-apps-launch-params";
2309
+ function Ge() {
2310
+ return kt(sessionStorage.getItem(At) || "");
2313
2311
  }
2314
- function jt(r) {
2315
- sessionStorage.setItem(qe, Mt(r));
2312
+ function je(r) {
2313
+ sessionStorage.setItem(At, Me(r));
2316
2314
  }
2317
- function te() {
2315
+ function rt() {
2318
2316
  const r = [];
2319
- for (const e of [
2317
+ for (const t of [
2320
2318
  // Try to retrieve launch parameters from the current location. This method can return
2321
2319
  // nothing in case, location was changed and then page was reloaded.
2322
- Nt,
2320
+ Ne,
2323
2321
  // Then, try using the lower level API - window.performance.
2324
- Ut,
2322
+ Ue,
2325
2323
  // Finally, try to extract launch parameters from the session storage.
2326
- Gt
2324
+ Ge
2327
2325
  ])
2328
2326
  try {
2329
- const t = e();
2330
- return jt(t), t;
2331
- } catch (t) {
2332
- r.push(t);
2327
+ const e = t();
2328
+ return je(e), e;
2329
+ } catch (e) {
2330
+ r.push(e);
2333
2331
  }
2334
2332
  throw k.error("Unable to extract launch parameters. Received errors:", r), new Error("Unable to retrieve launch parameters from any known source.");
2335
2333
  }
2336
- function Ae() {
2334
+ function Vt() {
2337
2335
  var r;
2338
- return ((r = xe()) == null ? void 0 : r.type) === "reload";
2336
+ return ((r = qt()) == null ? void 0 : r.type) === "reload";
2339
2337
  }
2340
2338
  function rr(r = {}) {
2341
2339
  const {
2342
- async: e = !1,
2343
- complete: t = e,
2340
+ async: t = !1,
2341
+ complete: e = t,
2344
2342
  cssVars: s = !1,
2345
2343
  acceptCustomStyles: n = !1
2346
2344
  } = r;
@@ -2352,24 +2350,24 @@ function rr(r = {}) {
2352
2350
  platform: u,
2353
2351
  themeParams: p,
2354
2352
  botInline: g = !1
2355
- } = te(), _ = Ae(), b = Lt(), l = Oe(c);
2356
- pe() && (n && Vt(), l("iframe_ready", { reload_supported: !0 }), E("reload_iframe", () => {
2353
+ } = rt(), _ = Vt(), b = Le(), l = Ot(c);
2354
+ pt() && (n && Ve(), l("iframe_ready", { reload_supported: !0 }), E("reload_iframe", () => {
2357
2355
  l("iframe_will_reload"), window.location.reload();
2358
2356
  }));
2359
2357
  const q = {
2360
- backButton: Rt(_, c, l),
2361
- closingBehavior: It(_, l),
2362
- cloudStorage: new at(c, b, l),
2358
+ backButton: Re(_, c, l),
2359
+ closingBehavior: Ie(_, l),
2360
+ cloudStorage: new ae(c, b, l),
2363
2361
  createRequestId: b,
2364
- hapticFeedback: new ct(c, l),
2365
- invoice: new lt(c, l),
2366
- mainButton: Tt(
2362
+ hapticFeedback: new ce(c, l),
2363
+ invoice: new le(c, l),
2364
+ mainButton: Te(
2367
2365
  _,
2368
2366
  p.buttonColor || "#000000",
2369
2367
  p.buttonTextColor || "#ffffff",
2370
2368
  l
2371
2369
  ),
2372
- miniApp: $t(
2370
+ miniApp: $e(
2373
2371
  _,
2374
2372
  p.backgroundColor || "#ffffff",
2375
2373
  c,
@@ -2377,86 +2375,86 @@ function rr(r = {}) {
2377
2375
  b,
2378
2376
  l
2379
2377
  ),
2380
- popup: new bt(c, l),
2378
+ popup: new be(c, l),
2381
2379
  postEvent: l,
2382
- qrScanner: new mt(c, l),
2383
- settingsButton: Bt(_, c, l),
2384
- themeParams: Ot(p),
2385
- utils: new St(c, b, l),
2380
+ qrScanner: new me(c, l),
2381
+ settingsButton: Be(_, c, l),
2382
+ themeParams: De(p),
2383
+ utils: new Se(c, b, l),
2386
2384
  ...i ? {
2387
- initData: new ut(i),
2385
+ initData: new ue(i),
2388
2386
  initDataRaw: a
2389
2387
  } : {}
2390
- }, H = Dt(_, u, l, t);
2391
- return H instanceof Promise || t ? Promise.resolve(H).then((re) => (ae(
2388
+ }, N = Oe(_, u, l, e);
2389
+ return N instanceof Promise || e ? Promise.resolve(N).then((st) => (at(
2392
2390
  s,
2393
2391
  q.miniApp,
2394
2392
  q.themeParams,
2395
- re
2396
- ), { ...q, viewport: re })) : (ae(
2393
+ st
2394
+ ), { ...q, viewport: st })) : (at(
2397
2395
  s,
2398
2396
  q.miniApp,
2399
2397
  q.themeParams,
2400
- H
2401
- ), { ...q, viewport: H });
2398
+ N
2399
+ ), { ...q, viewport: N });
2402
2400
  } catch (i) {
2403
- if (t)
2401
+ if (e)
2404
2402
  return Promise.reject(i);
2405
2403
  throw i;
2406
2404
  }
2407
2405
  }
2408
2406
  function sr() {
2409
2407
  return {
2410
- launchParams: te(),
2411
- isPageReload: Ae()
2408
+ launchParams: rt(),
2409
+ isPageReload: Vt()
2412
2410
  };
2413
2411
  }
2414
2412
  function nr() {
2415
2413
  try {
2416
- return te(), !0;
2414
+ return rt(), !0;
2417
2415
  } catch {
2418
2416
  return !1;
2419
2417
  }
2420
2418
  }
2421
2419
  function ir(r) {
2422
- const e = r.match(/#(.+)/);
2423
- return e ? e[1] : null;
2420
+ const t = r.match(/#(.+)/);
2421
+ return t ? t[1] : null;
2424
2422
  }
2425
- async function D(r) {
2423
+ async function O(r) {
2426
2424
  return r === 0 ? !0 : Promise.race([
2427
- new Promise((e) => {
2428
- window.addEventListener("popstate", function t() {
2429
- window.removeEventListener("popstate", t), e(!0);
2425
+ new Promise((t) => {
2426
+ window.addEventListener("popstate", function e() {
2427
+ window.removeEventListener("popstate", e), t(!0);
2430
2428
  }), window.history.go(r);
2431
2429
  }),
2432
2430
  // Usually, it takes about 1ms to emit this event, but we use some buffer.
2433
- new Promise((e) => {
2434
- setTimeout(e, 50, !1);
2431
+ new Promise((t) => {
2432
+ setTimeout(t, 50, !1);
2435
2433
  })
2436
2434
  ]);
2437
2435
  }
2438
- async function Ft() {
2439
- if (window.history.length <= 1 || (window.history.pushState(null, ""), await D(1 - window.history.length)))
2436
+ async function Fe() {
2437
+ if (window.history.length <= 1 || (window.history.pushState(null, ""), await O(1 - window.history.length)))
2440
2438
  return;
2441
- let e = await D(-1);
2442
- for (; e; )
2443
- e = await D(-1);
2439
+ let t = await O(-1);
2440
+ for (; t; )
2441
+ t = await O(-1);
2444
2442
  }
2445
- function B(r, e) {
2446
- return r.startsWith(e) ? r : `${e}${r}`;
2443
+ function B(r, t) {
2444
+ return r.startsWith(t) ? r : `${t}${r}`;
2447
2445
  }
2448
- class zt {
2449
- constructor(e, t, {
2446
+ class ze {
2447
+ constructor(t, e, {
2450
2448
  debug: s = !1,
2451
2449
  loggerPrefix: n = "Navigator"
2452
2450
  }) {
2453
2451
  o(this, "logger");
2454
2452
  o(this, "entries");
2455
- if (this.entriesCursor = t, e.length === 0)
2453
+ if (this.entriesCursor = e, t.length === 0)
2456
2454
  throw new Error("Entries list should not be empty.");
2457
- if (t >= e.length)
2455
+ if (e >= t.length)
2458
2456
  throw new Error("Cursor should be less than entries count.");
2459
- this.entries = e.map(({ pathname: i = "", search: a, hash: c }) => {
2457
+ this.entries = t.map(({ pathname: i = "", search: a, hash: c }) => {
2460
2458
  if (!i.startsWith("/") && i.length > 0)
2461
2459
  throw new Error('Pathname should start with "/"');
2462
2460
  return {
@@ -2464,29 +2462,29 @@ class zt {
2464
2462
  search: a ? B(a, "?") : "",
2465
2463
  hash: c ? B(c, "#") : ""
2466
2464
  };
2467
- }), this.logger = new he(`[${n}]`, s);
2465
+ }), this.logger = new ht(`[${n}]`, s);
2468
2466
  }
2469
2467
  /**
2470
2468
  * Converts entry to the navigation entry.
2471
2469
  * @param entry - entry data
2472
2470
  */
2473
- formatEntry(e) {
2474
- let t;
2475
- if (typeof e == "string")
2476
- t = e;
2471
+ formatEntry(t) {
2472
+ let e;
2473
+ if (typeof t == "string")
2474
+ e = t;
2477
2475
  else {
2478
2476
  const {
2479
2477
  pathname: a = "",
2480
2478
  search: c,
2481
2479
  hash: u
2482
- } = e;
2483
- t = a + (c ? B(c, "?") : "") + (u ? B(u, "#") : "");
2480
+ } = t;
2481
+ e = a + (c ? B(c, "?") : "") + (u ? B(u, "#") : "");
2484
2482
  }
2485
2483
  const {
2486
2484
  pathname: s,
2487
2485
  search: n,
2488
2486
  hash: i
2489
- } = new URL(t, `https://localhost${this.path}`);
2487
+ } = new URL(e, `https://localhost${this.path}`);
2490
2488
  return {
2491
2489
  pathname: s,
2492
2490
  search: n,
@@ -2533,23 +2531,23 @@ class zt {
2533
2531
  * Moves entries cursor by specified delta.
2534
2532
  * @param delta - cursor delta.
2535
2533
  */
2536
- go(e) {
2537
- this.logger.log(`called go(${e})`);
2538
- const t = Math.min(
2534
+ go(t) {
2535
+ this.logger.log(`called go(${t})`);
2536
+ const e = Math.min(
2539
2537
  this.entries.length - 1,
2540
- Math.max(this.entriesCursor + e, 0)
2538
+ Math.max(this.entriesCursor + t, 0)
2541
2539
  );
2542
- if (this.entriesCursor === t)
2540
+ if (this.entriesCursor === e)
2543
2541
  return this.performGo({
2544
2542
  updated: !1,
2545
- delta: e
2543
+ delta: t
2546
2544
  });
2547
2545
  const s = this.entry;
2548
- this.entriesCursor = t;
2546
+ this.entriesCursor = e;
2549
2547
  const n = this.entry;
2550
2548
  return this.logger.log("State changed", { before: s, after: n }), this.performGo({
2551
2549
  updated: !0,
2552
- delta: e,
2550
+ delta: t,
2553
2551
  before: s,
2554
2552
  after: n
2555
2553
  });
@@ -2558,7 +2556,7 @@ class zt {
2558
2556
  * Returns copy of navigator entries.
2559
2557
  */
2560
2558
  getEntries() {
2561
- return this.entries.map((e) => ({ ...e }));
2559
+ return this.entries.map((t) => ({ ...t }));
2562
2560
  }
2563
2561
  /**
2564
2562
  * Current hash.
@@ -2589,10 +2587,10 @@ class zt {
2589
2587
  * push("#my-hash"); // "/home" -> "/home#my-hash"
2590
2588
  * push("johny#my-hash"); // "/home/root" -> "/home/johny#my-hash"
2591
2589
  */
2592
- push(e) {
2590
+ push(t) {
2593
2591
  this.entriesCursor !== this.entries.length - 1 && this.entries.splice(this.entriesCursor + 1);
2594
- const t = this.formatEntry(e), s = this.entry;
2595
- this.entriesCursor += 1, this.entries[this.entriesCursor] = t;
2592
+ const e = this.formatEntry(t), s = this.entry;
2593
+ this.entriesCursor += 1, this.entries[this.entriesCursor] = e;
2596
2594
  const n = this.entry;
2597
2595
  return this.logger.log("State changed", { before: s, after: n }), this.performPush({
2598
2596
  before: s,
@@ -2619,15 +2617,15 @@ class zt {
2619
2617
  * @see push
2620
2618
  * @returns True if changes were done.
2621
2619
  */
2622
- replace(e) {
2623
- const t = this.formatEntry(e);
2624
- if (this.search === t.search && this.pathname === t.pathname && this.hash === t.hash)
2620
+ replace(t) {
2621
+ const e = this.formatEntry(t);
2622
+ if (this.search === e.search && this.pathname === e.pathname && this.hash === e.hash)
2625
2623
  return this.performReplace({
2626
2624
  updated: !1,
2627
- entry: t
2625
+ entry: e
2628
2626
  });
2629
2627
  const s = this.entry;
2630
- this.entries[this.entriesCursor] = t;
2628
+ this.entries[this.entriesCursor] = e;
2631
2629
  const n = this.entry;
2632
2630
  return this.logger.log("State changed", { before: s, after: n }), this.performReplace({
2633
2631
  updated: !0,
@@ -2644,10 +2642,10 @@ class zt {
2644
2642
  return this.entry.search;
2645
2643
  }
2646
2644
  }
2647
- const ce = 0, J = 1, Q = 2;
2648
- class Ve extends zt {
2649
- constructor(t, s, n = {}) {
2650
- super(t, s, {
2645
+ const ct = 0, Q = 1, Z = 2;
2646
+ class Rt extends ze {
2647
+ constructor(e, s, n = {}) {
2648
+ super(e, s, {
2651
2649
  ...n,
2652
2650
  loggerPrefix: "HashNavigator"
2653
2651
  });
@@ -2657,16 +2655,16 @@ class Ve extends zt {
2657
2655
  * Handles window "popstate" event.
2658
2656
  * @param state - event state.
2659
2657
  */
2660
- o(this, "onPopState", async ({ state: t }) => {
2661
- if (this.logger.log('"popstate" event received. State:', t), t === null)
2658
+ o(this, "onPopState", async ({ state: e }) => {
2659
+ if (this.logger.log('"popstate" event received. State:', e), e === null)
2662
2660
  return this.push(window.location.hash.slice(1));
2663
- if (t === ce) {
2661
+ if (e === ct) {
2664
2662
  this.logger.log("Void reached. Moving history forward"), window.history.forward();
2665
2663
  return;
2666
2664
  }
2667
- if (t === J)
2665
+ if (e === Q)
2668
2666
  return this.back();
2669
- if (t === Q)
2667
+ if (e === Z)
2670
2668
  return this.forward();
2671
2669
  });
2672
2670
  o(this, "back", () => super.back());
@@ -2683,7 +2681,7 @@ class Ve extends zt {
2683
2681
  * Creates navigator from current window location hash.
2684
2682
  * @param options - options passed to constructor.
2685
2683
  */
2686
- static fromLocation(t) {
2684
+ static fromLocation(e) {
2687
2685
  const {
2688
2686
  search: s,
2689
2687
  pathname: n,
@@ -2692,29 +2690,29 @@ class Ve extends zt {
2692
2690
  window.location.hash.slice(1),
2693
2691
  window.location.href
2694
2692
  );
2695
- return new Ve([{ search: s, pathname: n, hash: i }], 0, t);
2693
+ return new Rt([{ search: s, pathname: n, hash: i }], 0, e);
2696
2694
  }
2697
- async performGo(t) {
2698
- t.updated && (this.attached && await this.syncHistory(), this.emitChanged(t.before, t.after));
2695
+ async performGo(e) {
2696
+ e.updated && (this.attached && await this.syncHistory(), this.emitChanged(e.before, e.after));
2699
2697
  }
2700
- async performPush({ before: t, after: s }) {
2701
- this.attached && await this.syncHistory(), this.emitChanged(t, s);
2698
+ async performPush({ before: e, after: s }) {
2699
+ this.attached && await this.syncHistory(), this.emitChanged(e, s);
2702
2700
  }
2703
- async performReplace(t) {
2704
- t.updated && (this.attached && window.history.replaceState(null, "", `#${this.path}`), this.emitChanged(t.before, t.after));
2701
+ async performReplace(e) {
2702
+ e.updated && (this.attached && window.history.replaceState(null, "", `#${this.path}`), this.emitChanged(e.before, e.after));
2705
2703
  }
2706
2704
  /**
2707
2705
  * Synchronizes current navigator state with browser history.
2708
2706
  */
2709
2707
  async syncHistory() {
2710
2708
  window.removeEventListener("popstate", this.onPopState);
2711
- const t = `#${this.path}`;
2712
- await Ft(), d("web_app_setup_back_button", { is_visible: this.canGoBack }), this.canGoBack && this.canGoForward ? (this.logger.log("Setting up history: [<-, *, ->]"), window.history.replaceState(J, ""), window.history.pushState(null, "", t), window.history.pushState(Q, ""), await D(-1)) : this.canGoBack ? (this.logger.log("Setting up history: [<-, *]"), window.history.replaceState(J, ""), window.history.pushState(null, "", t)) : this.canGoForward ? (this.logger.log("Setting up history: [*, ->]"), window.history.replaceState(null, t), window.history.pushState(Q, ""), await D(-1)) : (this.logger.log("Setting up history: [~, *]"), window.history.replaceState(ce, ""), window.history.pushState(null, "", t)), window.addEventListener("popstate", this.onPopState);
2709
+ const e = `#${this.path}`;
2710
+ await Fe(), d("web_app_setup_back_button", { is_visible: this.canGoBack }), this.canGoBack && this.canGoForward ? (this.logger.log("Setting up history: [<-, *, ->]"), window.history.replaceState(Q, ""), window.history.pushState(null, "", e), window.history.pushState(Z, ""), await O(-1)) : this.canGoBack ? (this.logger.log("Setting up history: [<-, *]"), window.history.replaceState(Q, ""), window.history.pushState(null, "", e)) : this.canGoForward ? (this.logger.log("Setting up history: [*, ->]"), window.history.replaceState(null, e), window.history.pushState(Z, ""), await O(-1)) : (this.logger.log("Setting up history: [~, *]"), window.history.replaceState(ct, ""), window.history.pushState(null, "", e)), window.addEventListener("popstate", this.onPopState);
2713
2711
  }
2714
- emitChanged(t, s) {
2712
+ emitChanged(e, s) {
2715
2713
  this.ee.emit("change", {
2716
2714
  navigator: this,
2717
- from: t,
2715
+ from: e,
2718
2716
  to: s
2719
2717
  });
2720
2718
  }
@@ -2733,83 +2731,83 @@ class Ve extends zt {
2733
2731
  }
2734
2732
  }
2735
2733
  function or(r) {
2736
- return r instanceof F;
2734
+ return r instanceof z;
2737
2735
  }
2738
2736
  export {
2739
- rt as BackButton,
2740
- st as ClosingBehavior,
2741
- at as CloudStorage,
2742
- ct as HapticFeedback,
2743
- Ve as HashNavigator,
2744
- ut as InitData,
2745
- lt as Invoice,
2746
- dt as MainButton,
2747
- Z as MethodUnsupportedError,
2748
- wt as MiniApp,
2749
- zt as Navigator,
2750
- K as ParameterUnsupportedError,
2751
- G as ParseError,
2752
- U as ParseSchemaFieldError,
2753
- bt as Popup,
2754
- mt as QRScanner,
2755
- yt as SettingsButton,
2756
- Pt as ThemeParams,
2757
- F as TimeoutError,
2758
- St as Utils,
2759
- xt as Viewport,
2760
- ot as array,
2761
- qt as bindMiniAppCSSVars,
2762
- At as bindThemeCSSVars,
2763
- oe as bindViewportCSSVars,
2737
+ re as BackButton,
2738
+ se as ClosingBehavior,
2739
+ ae as CloudStorage,
2740
+ ce as HapticFeedback,
2741
+ Rt as HashNavigator,
2742
+ ue as InitData,
2743
+ le as Invoice,
2744
+ de as MainButton,
2745
+ K as MethodUnsupportedError,
2746
+ we as MiniApp,
2747
+ ze as Navigator,
2748
+ Y as ParameterUnsupportedError,
2749
+ j as ParseError,
2750
+ G as ParseSchemaFieldError,
2751
+ be as Popup,
2752
+ me as QRScanner,
2753
+ ye as SettingsButton,
2754
+ Pe as ThemeParams,
2755
+ z as TimeoutError,
2756
+ Se as Utils,
2757
+ xe as Viewport,
2758
+ oe as array,
2759
+ qe as bindMiniAppCSSVars,
2760
+ Ae as bindThemeCSSVars,
2761
+ ot as bindViewportCSSVars,
2764
2762
  P as boolean,
2765
- ht as chatParser,
2766
- tt as classNames,
2767
- Be as compareVersions,
2768
- Oe as createPostEvent,
2769
- be as date,
2763
+ he as chatParser,
2764
+ _t as classNames,
2765
+ Dt as compareVersions,
2766
+ Ot as createPostEvent,
2767
+ mt as date,
2770
2768
  ir as getHash,
2771
2769
  rr as init,
2772
- me as initDataParser,
2773
- O as invokeCustomMethod,
2774
- _e as isColorDark,
2775
- pe as isIframe,
2776
- Ae as isPageReload,
2777
- X as isRGB,
2778
- Je as isRGBShort,
2779
- M as isRecord,
2780
- kt as isStableViewportPlatform,
2770
+ yt as initDataParser,
2771
+ D as invokeCustomMethod,
2772
+ bt as isColorDark,
2773
+ pt as isIframe,
2774
+ Vt as isPageReload,
2775
+ tt as isRGB,
2776
+ Qt as isRGBShort,
2777
+ W as isRecord,
2778
+ ke as isStableViewportPlatform,
2781
2779
  nr as isTMA,
2782
2780
  or as isTimeoutError,
2783
2781
  f as json,
2784
- Ht as launchParamsParser,
2785
- Xt as mergeClassNames,
2782
+ He as launchParamsParser,
2783
+ Xe as mergeClassNames,
2786
2784
  x as number,
2787
2785
  I as off,
2788
2786
  E as on,
2789
- Kt as once,
2790
- er as parseInitData,
2791
- Se as parseLaunchParams,
2792
- De as parseMessage,
2793
- Ce as parseThemeParams,
2787
+ Ke as once,
2788
+ tr as parseInitData,
2789
+ kt as parseLaunchParams,
2790
+ Wt as parseMessage,
2791
+ vt as parseThemeParams,
2794
2792
  d as postEvent,
2795
2793
  y as request,
2796
- tr as requestThemeParams,
2797
- ve as requestViewport,
2794
+ er as requestThemeParams,
2795
+ Pt as requestViewport,
2798
2796
  sr as retrieveLaunchData,
2799
- te as retrieveLaunchParams,
2800
- ge as rgb,
2801
- ee as searchParams,
2802
- Mt as serializeLaunchParams,
2803
- vt as serializeThemeParams,
2797
+ rt as retrieveLaunchParams,
2798
+ gt as rgb,
2799
+ et as searchParams,
2800
+ Me as serializeLaunchParams,
2801
+ ve as serializeThemeParams,
2804
2802
  S as setCSSVar,
2805
- Qt as setDebug,
2806
- Zt as setTargetOrigin,
2803
+ Qe as setDebug,
2804
+ Ze as setTargetOrigin,
2807
2805
  h as string,
2808
- Yt as subscribe,
2806
+ Ye as subscribe,
2809
2807
  A as supports,
2810
- Ee as themeParamsParser,
2811
- fe as toRGB,
2812
- et as unsubscribe,
2813
- ie as userParser,
2814
- we as withTimeout
2808
+ Ct as themeParamsParser,
2809
+ ft as toRGB,
2810
+ ee as unsubscribe,
2811
+ it as userParser,
2812
+ wt as withTimeout
2815
2813
  };