@tma.js/sdk 2.0.0 → 2.0.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/dts/errors/errors.d.ts +1 -5
- package/dist/dts/index.d.ts +2 -1
- package/dist/dts/misc/createComponentInitFn/types.d.ts +4 -5
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.iife.js +1 -1
- package/dist/index.iife.js.map +1 -1
- package/dist/index.js +411 -419
- package/dist/index.js.map +1 -1
- package/dist/index.low-level.iife.js +1 -1
- package/dist/index.low-level.iife.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var c = (e, t, s) => (
|
|
4
|
-
function
|
|
1
|
+
var Lt = Object.defineProperty;
|
|
2
|
+
var Bt = (e, t, s) => t in e ? Lt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s;
|
|
3
|
+
var c = (e, t, s) => (Bt(e, typeof t != "symbol" ? t + "" : t, s), s);
|
|
4
|
+
function at(e, t) {
|
|
5
5
|
let s;
|
|
6
6
|
const n = () => {
|
|
7
7
|
s !== void 0 && t && t(s), s = void 0;
|
|
8
8
|
};
|
|
9
9
|
return [() => s === void 0 ? s = e(n) : s, n];
|
|
10
10
|
}
|
|
11
|
-
function
|
|
11
|
+
function ct(e) {
|
|
12
12
|
const t = L(), { count: s } = t;
|
|
13
13
|
t.unsubscribe(e), s && !t.count && ae();
|
|
14
14
|
}
|
|
15
|
-
function
|
|
16
|
-
return L().subscribe(e), () =>
|
|
15
|
+
function Ot(e) {
|
|
16
|
+
return L().subscribe(e), () => ct(e);
|
|
17
17
|
}
|
|
18
|
-
class
|
|
18
|
+
class Ut {
|
|
19
19
|
constructor(t, s = {}) {
|
|
20
20
|
this.scope = t, this.options = s;
|
|
21
21
|
}
|
|
@@ -55,18 +55,18 @@ class Ot {
|
|
|
55
55
|
this.print("log", ...t);
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
-
const D = new
|
|
58
|
+
const D = new Ut("SDK", {
|
|
59
59
|
bgColor: "forestgreen",
|
|
60
60
|
textColor: "white"
|
|
61
61
|
});
|
|
62
62
|
let j = !1;
|
|
63
|
-
const
|
|
63
|
+
const st = ({ event: e, args: [t] }) => {
|
|
64
64
|
D.log("Event received:", t === void 0 ? { name: e } : { name: e, data: t });
|
|
65
65
|
};
|
|
66
|
-
function
|
|
67
|
-
j !== e && (j = e, e ?
|
|
66
|
+
function ts(e) {
|
|
67
|
+
j !== e && (j = e, e ? Ot(st) : ct(st));
|
|
68
68
|
}
|
|
69
|
-
function
|
|
69
|
+
function Wt(...e) {
|
|
70
70
|
j && D.log(...e);
|
|
71
71
|
}
|
|
72
72
|
class V {
|
|
@@ -141,7 +141,7 @@ class V {
|
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
143
|
}
|
|
144
|
-
function
|
|
144
|
+
function F(e, t, s) {
|
|
145
145
|
return window.addEventListener(e, t, s), () => window.removeEventListener(e, t, s);
|
|
146
146
|
}
|
|
147
147
|
class $ extends Error {
|
|
@@ -149,12 +149,12 @@ class $ extends Error {
|
|
|
149
149
|
super(s, { cause: n }), this.type = t, Object.setPrototypeOf(this, $.prototype);
|
|
150
150
|
}
|
|
151
151
|
}
|
|
152
|
-
function
|
|
152
|
+
function f(e, t, s) {
|
|
153
153
|
return new $(e, t, s);
|
|
154
154
|
}
|
|
155
|
-
const
|
|
155
|
+
const Ht = "ERR_METHOD_UNSUPPORTED", Gt = "ERR_METHOD_PARAMETER_UNSUPPORTED", jt = "ERR_UNKNOWN_ENV", Ft = "ERR_INVOKE_CUSTOM_METHOD_RESPONSE", zt = "ERR_TIMED_OUT", Jt = "ERR_UNEXPECTED_TYPE", ht = "ERR_PARSE", Qt = "ERR_NAVIGATION_LIST_EMPTY", Yt = "ERR_NAVIGATION_CURSOR_INVALID", es = "ERR_NAVIGATION_ITEM_INVALID", pt = "ERR_SSR_INIT", Zt = "ERR_INVALID_PATH_BASE";
|
|
156
156
|
function P() {
|
|
157
|
-
return
|
|
157
|
+
return f(Jt, "Value has unexpected type");
|
|
158
158
|
}
|
|
159
159
|
class M {
|
|
160
160
|
constructor(t, s, n) {
|
|
@@ -171,8 +171,8 @@ class M {
|
|
|
171
171
|
try {
|
|
172
172
|
return this.parser(t);
|
|
173
173
|
} catch (s) {
|
|
174
|
-
throw
|
|
175
|
-
|
|
174
|
+
throw f(
|
|
175
|
+
ht,
|
|
176
176
|
`Unable to parse value${this.type ? ` as ${this.type}` : ""}`,
|
|
177
177
|
s
|
|
178
178
|
);
|
|
@@ -182,10 +182,10 @@ class M {
|
|
|
182
182
|
return this.isOptional = !0, this;
|
|
183
183
|
}
|
|
184
184
|
}
|
|
185
|
-
function
|
|
185
|
+
function x(e, t) {
|
|
186
186
|
return () => new M(e, !1, t);
|
|
187
187
|
}
|
|
188
|
-
const w =
|
|
188
|
+
const w = x((e) => {
|
|
189
189
|
if (typeof e == "boolean")
|
|
190
190
|
return e;
|
|
191
191
|
const t = String(e);
|
|
@@ -212,24 +212,24 @@ function ut(e, t) {
|
|
|
212
212
|
const a = o(t(i));
|
|
213
213
|
a !== void 0 && (s[n] = a);
|
|
214
214
|
} catch (a) {
|
|
215
|
-
throw
|
|
215
|
+
throw f(ht, `Unable to parse field "${n}"`, a);
|
|
216
216
|
}
|
|
217
217
|
}
|
|
218
218
|
return s;
|
|
219
219
|
}
|
|
220
|
-
function
|
|
220
|
+
function J(e) {
|
|
221
221
|
let t = e;
|
|
222
222
|
if (typeof t == "string" && (t = JSON.parse(t)), typeof t != "object" || t === null || Array.isArray(t))
|
|
223
223
|
throw P();
|
|
224
224
|
return t;
|
|
225
225
|
}
|
|
226
|
-
function
|
|
226
|
+
function d(e, t) {
|
|
227
227
|
return new M((s) => {
|
|
228
|
-
const n =
|
|
228
|
+
const n = J(s);
|
|
229
229
|
return ut(e, (r) => n[r]);
|
|
230
230
|
}, !1, t);
|
|
231
231
|
}
|
|
232
|
-
const
|
|
232
|
+
const v = x((e) => {
|
|
233
233
|
if (typeof e == "number")
|
|
234
234
|
return e;
|
|
235
235
|
if (typeof e == "string") {
|
|
@@ -239,7 +239,7 @@ const y = S((e) => {
|
|
|
239
239
|
}
|
|
240
240
|
throw P();
|
|
241
241
|
}, "number");
|
|
242
|
-
function
|
|
242
|
+
function Q(e) {
|
|
243
243
|
return /^#[\da-f]{6}$/i.test(e);
|
|
244
244
|
}
|
|
245
245
|
function Xt(e) {
|
|
@@ -247,7 +247,7 @@ function Xt(e) {
|
|
|
247
247
|
}
|
|
248
248
|
function lt(e) {
|
|
249
249
|
const t = e.replace(/\s/g, "").toLowerCase();
|
|
250
|
-
if (
|
|
250
|
+
if (Q(t))
|
|
251
251
|
return t;
|
|
252
252
|
if (Xt(t)) {
|
|
253
253
|
let n = "#";
|
|
@@ -263,13 +263,13 @@ function lt(e) {
|
|
|
263
263
|
return n + (i.length === 1 ? "0" : "") + i;
|
|
264
264
|
}, "#");
|
|
265
265
|
}
|
|
266
|
-
const h =
|
|
266
|
+
const h = x((e) => {
|
|
267
267
|
if (typeof e == "string" || typeof e == "number")
|
|
268
268
|
return e.toString();
|
|
269
269
|
throw P();
|
|
270
|
-
}, "string"), dt =
|
|
270
|
+
}, "string"), dt = x((e) => lt(h().parse(e)), "rgb");
|
|
271
271
|
function Kt(e) {
|
|
272
|
-
return
|
|
272
|
+
return d({
|
|
273
273
|
eventType: h(),
|
|
274
274
|
eventData: (t) => t
|
|
275
275
|
}).parse(e);
|
|
@@ -305,44 +305,44 @@ function se() {
|
|
|
305
305
|
});
|
|
306
306
|
});
|
|
307
307
|
}
|
|
308
|
-
const ne =
|
|
308
|
+
const ne = d({
|
|
309
309
|
button_id: (e) => e == null ? void 0 : h().parse(e)
|
|
310
310
|
}), re = {
|
|
311
|
-
clipboard_text_received:
|
|
311
|
+
clipboard_text_received: d({
|
|
312
312
|
req_id: h(),
|
|
313
313
|
data: (e) => e === null ? e : h().optional().parse(e)
|
|
314
314
|
}),
|
|
315
|
-
custom_method_invoked:
|
|
315
|
+
custom_method_invoked: d({
|
|
316
316
|
req_id: h(),
|
|
317
317
|
result: (e) => e,
|
|
318
318
|
error: h().optional()
|
|
319
319
|
}),
|
|
320
|
-
invoice_closed:
|
|
320
|
+
invoice_closed: d({
|
|
321
321
|
slug: h(),
|
|
322
322
|
status: h()
|
|
323
323
|
}),
|
|
324
|
-
phone_requested:
|
|
324
|
+
phone_requested: d({
|
|
325
325
|
status: h()
|
|
326
326
|
}),
|
|
327
327
|
popup_closed: {
|
|
328
328
|
parse: (e) => ne.parse(e ?? {})
|
|
329
329
|
},
|
|
330
|
-
qr_text_received:
|
|
330
|
+
qr_text_received: d({
|
|
331
331
|
data: h().optional()
|
|
332
332
|
}),
|
|
333
|
-
theme_changed:
|
|
333
|
+
theme_changed: d({
|
|
334
334
|
theme_params: (e) => {
|
|
335
335
|
const t = dt().optional();
|
|
336
|
-
return Object.entries(
|
|
336
|
+
return Object.entries(J(e)).reduce((s, [n, r]) => (s[n] = t.parse(r), s), {});
|
|
337
337
|
}
|
|
338
338
|
}),
|
|
339
|
-
viewport_changed:
|
|
340
|
-
height:
|
|
341
|
-
width: (e) => e == null ? window.innerWidth :
|
|
339
|
+
viewport_changed: d({
|
|
340
|
+
height: v(),
|
|
341
|
+
width: (e) => e == null ? window.innerWidth : v().parse(e),
|
|
342
342
|
is_state_stable: w(),
|
|
343
343
|
is_expanded: w()
|
|
344
344
|
}),
|
|
345
|
-
write_access_requested:
|
|
345
|
+
write_access_requested: d({
|
|
346
346
|
status: h()
|
|
347
347
|
})
|
|
348
348
|
};
|
|
@@ -357,7 +357,7 @@ function ie() {
|
|
|
357
357
|
// event. For example, when the MainButton is shown. That's why we should
|
|
358
358
|
// add our own listener to make sure, viewport information is always fresh.
|
|
359
359
|
// Issue: https://github.com/Telegram-Mini-Apps/tma.js/issues/10
|
|
360
|
-
|
|
360
|
+
F("resize", () => {
|
|
361
361
|
e.emit("viewport_changed", {
|
|
362
362
|
width: window.innerWidth,
|
|
363
363
|
height: window.innerHeight,
|
|
@@ -367,7 +367,7 @@ function ie() {
|
|
|
367
367
|
}),
|
|
368
368
|
// Add listener, which handles events sent from the Telegram web application and also events
|
|
369
369
|
// generated by the local emitEvent function.
|
|
370
|
-
|
|
370
|
+
F("message", (s) => {
|
|
371
371
|
if (s.source !== window.parent)
|
|
372
372
|
return;
|
|
373
373
|
let n;
|
|
@@ -395,7 +395,7 @@ function ie() {
|
|
|
395
395
|
t.forEach((s) => s()), t = [];
|
|
396
396
|
}];
|
|
397
397
|
}
|
|
398
|
-
const [oe, ae] =
|
|
398
|
+
const [oe, ae] = at(
|
|
399
399
|
(e) => {
|
|
400
400
|
const [t, s] = ie(), n = t.off.bind(t);
|
|
401
401
|
return t.off = (r, i) => {
|
|
@@ -429,7 +429,7 @@ function ce(e, t) {
|
|
|
429
429
|
function g(e, t) {
|
|
430
430
|
return ce(e, t) <= 0;
|
|
431
431
|
}
|
|
432
|
-
function
|
|
432
|
+
function E(e, t, s) {
|
|
433
433
|
if (typeof s == "string") {
|
|
434
434
|
if (e === "web_app_open_link" && t === "try_instant_view")
|
|
435
435
|
return g("6.4", s);
|
|
@@ -483,28 +483,28 @@ function v(e, t, s) {
|
|
|
483
483
|
function he(e) {
|
|
484
484
|
return "external" in e && I(e.external) && "notify" in e.external && typeof e.external.notify == "function";
|
|
485
485
|
}
|
|
486
|
-
function
|
|
486
|
+
function _t(e) {
|
|
487
487
|
return "TelegramWebviewProxy" in e && I(e.TelegramWebviewProxy) && "postEvent" in e.TelegramWebviewProxy && typeof e.TelegramWebviewProxy.postEvent == "function";
|
|
488
488
|
}
|
|
489
|
-
function
|
|
489
|
+
function pe() {
|
|
490
490
|
try {
|
|
491
491
|
return window.self !== window.top;
|
|
492
492
|
} catch {
|
|
493
493
|
return !0;
|
|
494
494
|
}
|
|
495
495
|
}
|
|
496
|
-
let
|
|
497
|
-
function
|
|
498
|
-
|
|
496
|
+
let ft = "https://web.telegram.org";
|
|
497
|
+
function ss(e) {
|
|
498
|
+
ft = e;
|
|
499
499
|
}
|
|
500
|
-
function
|
|
501
|
-
return
|
|
500
|
+
function ue() {
|
|
501
|
+
return ft;
|
|
502
502
|
}
|
|
503
|
-
function
|
|
503
|
+
function A(e, t, s) {
|
|
504
504
|
let n = {}, r;
|
|
505
505
|
t === void 0 && s === void 0 ? n = {} : t !== void 0 && s !== void 0 ? (n = s, r = t) : t !== void 0 && ("targetOrigin" in t ? n = t : r = t);
|
|
506
|
-
const { targetOrigin: i =
|
|
507
|
-
if (
|
|
506
|
+
const { targetOrigin: i = ue() } = n;
|
|
507
|
+
if (Wt("Posting event:", r ? { event: e, data: r } : { event: e }), pe()) {
|
|
508
508
|
window.parent.postMessage(JSON.stringify({ eventType: e, eventData: r }), i);
|
|
509
509
|
return;
|
|
510
510
|
}
|
|
@@ -512,70 +512,70 @@ function T(e, t, s) {
|
|
|
512
512
|
window.external.notify(JSON.stringify({ eventType: e, eventData: r }));
|
|
513
513
|
return;
|
|
514
514
|
}
|
|
515
|
-
if (
|
|
515
|
+
if (_t(window)) {
|
|
516
516
|
window.TelegramWebviewProxy.postEvent(e, JSON.stringify(r));
|
|
517
517
|
return;
|
|
518
518
|
}
|
|
519
|
-
throw
|
|
520
|
-
|
|
519
|
+
throw f(
|
|
520
|
+
jt,
|
|
521
521
|
"Unable to determine current environment and possible way to send event. You are probably trying to use Mini Apps method outside of Telegram application environment."
|
|
522
522
|
);
|
|
523
523
|
}
|
|
524
|
-
function
|
|
524
|
+
function le(e) {
|
|
525
525
|
return (t, s) => {
|
|
526
|
-
if (!
|
|
527
|
-
throw
|
|
526
|
+
if (!E(t, e))
|
|
527
|
+
throw f(Ht, `Method "${t}" is unsupported in Mini Apps version ${e}`);
|
|
528
528
|
if (I(s)) {
|
|
529
529
|
let n;
|
|
530
|
-
if (t === "web_app_open_link" && "try_instant_view" in s ? n = "try_instant_view" : t === "web_app_set_header_color" && "color" in s && (n = "color"), n && !
|
|
531
|
-
throw
|
|
532
|
-
|
|
530
|
+
if (t === "web_app_open_link" && "try_instant_view" in s ? n = "try_instant_view" : t === "web_app_set_header_color" && "color" in s && (n = "color"), n && !E(t, n, e))
|
|
531
|
+
throw f(
|
|
532
|
+
Gt,
|
|
533
533
|
`Parameter "${n}" of "${t}" method is unsupported in Mini Apps version ${e}`
|
|
534
534
|
);
|
|
535
535
|
}
|
|
536
|
-
return
|
|
536
|
+
return A(t, s);
|
|
537
537
|
};
|
|
538
538
|
}
|
|
539
|
-
function
|
|
539
|
+
function gt(e) {
|
|
540
540
|
return ({ req_id: t }) => t === e;
|
|
541
541
|
}
|
|
542
|
-
function
|
|
543
|
-
return
|
|
542
|
+
function bt(e) {
|
|
543
|
+
return f(zt, `Timeout reached: ${e}ms`);
|
|
544
544
|
}
|
|
545
|
-
function
|
|
545
|
+
function wt(e, t) {
|
|
546
546
|
return Promise.race([
|
|
547
547
|
typeof e == "function" ? e() : e,
|
|
548
548
|
new Promise((s, n) => {
|
|
549
549
|
setTimeout(() => {
|
|
550
|
-
n(
|
|
550
|
+
n(bt(t));
|
|
551
551
|
}, t);
|
|
552
552
|
})
|
|
553
553
|
]);
|
|
554
554
|
}
|
|
555
|
-
async function
|
|
555
|
+
async function _(e) {
|
|
556
556
|
let t;
|
|
557
|
-
const s = new Promise((
|
|
558
|
-
t =
|
|
557
|
+
const s = new Promise((l) => {
|
|
558
|
+
t = l;
|
|
559
559
|
}), {
|
|
560
560
|
method: n,
|
|
561
561
|
event: r,
|
|
562
562
|
capture: i,
|
|
563
|
-
postEvent: o =
|
|
563
|
+
postEvent: o = A,
|
|
564
564
|
timeout: a
|
|
565
565
|
} = e, p = (Array.isArray(r) ? r : [r]).map(
|
|
566
|
-
(
|
|
566
|
+
(l) => b(l, (et) => (!i || i(et)) && t(et))
|
|
567
567
|
);
|
|
568
568
|
try {
|
|
569
|
-
return o(n, e.params), await (a ?
|
|
569
|
+
return o(n, e.params), await (a ? wt(s, a) : s);
|
|
570
570
|
} finally {
|
|
571
|
-
p.forEach((
|
|
571
|
+
p.forEach((l) => l());
|
|
572
572
|
}
|
|
573
573
|
}
|
|
574
|
-
async function
|
|
574
|
+
async function C(e, t, s, n = {}) {
|
|
575
575
|
const {
|
|
576
576
|
result: r,
|
|
577
577
|
error: i
|
|
578
|
-
} = await
|
|
578
|
+
} = await _({
|
|
579
579
|
...n,
|
|
580
580
|
method: "web_app_invoke_custom_method",
|
|
581
581
|
event: "custom_method_invoked",
|
|
@@ -584,29 +584,29 @@ async function R(e, t, s, n = {}) {
|
|
|
584
584
|
params: t,
|
|
585
585
|
req_id: s
|
|
586
586
|
},
|
|
587
|
-
capture:
|
|
587
|
+
capture: gt(s)
|
|
588
588
|
});
|
|
589
589
|
if (i)
|
|
590
|
-
throw
|
|
590
|
+
throw f(Ft, i);
|
|
591
591
|
return r;
|
|
592
592
|
}
|
|
593
|
-
function
|
|
593
|
+
function z(...e) {
|
|
594
594
|
return e.map((t) => {
|
|
595
595
|
if (typeof t == "string")
|
|
596
596
|
return t;
|
|
597
597
|
if (I(t))
|
|
598
|
-
return
|
|
598
|
+
return z(Object.entries(t).map((s) => s[1] && s[0]));
|
|
599
599
|
if (Array.isArray(t))
|
|
600
|
-
return
|
|
600
|
+
return z(...t);
|
|
601
601
|
}).filter(Boolean).join(" ");
|
|
602
602
|
}
|
|
603
|
-
function
|
|
603
|
+
function ns(...e) {
|
|
604
604
|
return e.reduce((t, s) => (I(s) && Object.entries(s).forEach(([n, r]) => {
|
|
605
|
-
const i =
|
|
605
|
+
const i = z(t[n], r);
|
|
606
606
|
i.length && (t[n] = i);
|
|
607
607
|
}), t), {});
|
|
608
608
|
}
|
|
609
|
-
function
|
|
609
|
+
function mt(e) {
|
|
610
610
|
const t = lt(e);
|
|
611
611
|
return Math.sqrt(
|
|
612
612
|
[0.299, 0.587, 0.114].reduce((s, n, r) => {
|
|
@@ -615,7 +615,7 @@ function wt(e) {
|
|
|
615
615
|
}, 0)
|
|
616
616
|
) < 120;
|
|
617
617
|
}
|
|
618
|
-
class
|
|
618
|
+
class de {
|
|
619
619
|
constructor(t) {
|
|
620
620
|
c(this, "ee", new V());
|
|
621
621
|
/**
|
|
@@ -645,7 +645,7 @@ class _e {
|
|
|
645
645
|
return this.state[t];
|
|
646
646
|
}
|
|
647
647
|
}
|
|
648
|
-
class
|
|
648
|
+
class Y {
|
|
649
649
|
constructor(t) {
|
|
650
650
|
c(this, "state");
|
|
651
651
|
/**
|
|
@@ -660,23 +660,23 @@ class Z {
|
|
|
660
660
|
* Clones the current state.
|
|
661
661
|
*/
|
|
662
662
|
c(this, "clone");
|
|
663
|
-
this.state = new
|
|
663
|
+
this.state = new de(t), this.set = this.state.set.bind(this.state), this.get = this.state.get.bind(this.state), this.clone = this.state.clone.bind(this.state);
|
|
664
664
|
}
|
|
665
665
|
}
|
|
666
|
-
function
|
|
667
|
-
return (s) =>
|
|
666
|
+
function yt(e, t) {
|
|
667
|
+
return (s) => E(t[s], e);
|
|
668
668
|
}
|
|
669
|
-
class
|
|
669
|
+
class Z extends Y {
|
|
670
670
|
constructor(s, n, r) {
|
|
671
671
|
super(s);
|
|
672
672
|
/**
|
|
673
673
|
* @returns True, if specified method is supported by the current component.
|
|
674
674
|
*/
|
|
675
675
|
c(this, "supports");
|
|
676
|
-
this.supports =
|
|
676
|
+
this.supports = yt(n, r);
|
|
677
677
|
}
|
|
678
678
|
}
|
|
679
|
-
class
|
|
679
|
+
class _e extends Z {
|
|
680
680
|
constructor(s, n, r) {
|
|
681
681
|
super({ isVisible: s }, n, {
|
|
682
682
|
show: "web_app_setup_back_button",
|
|
@@ -718,11 +718,11 @@ class fe extends X {
|
|
|
718
718
|
this.isVisible = !0;
|
|
719
719
|
}
|
|
720
720
|
}
|
|
721
|
-
function
|
|
721
|
+
function y() {
|
|
722
722
|
return typeof window > "u";
|
|
723
723
|
}
|
|
724
|
-
const
|
|
725
|
-
function
|
|
724
|
+
const vt = x((e) => e instanceof Date ? e : new Date(v().parse(e) * 1e3), "Date");
|
|
725
|
+
function X(e, t) {
|
|
726
726
|
return new M((s) => {
|
|
727
727
|
if (typeof s != "string" && !(s instanceof URLSearchParams))
|
|
728
728
|
throw P();
|
|
@@ -733,8 +733,8 @@ function K(e, t) {
|
|
|
733
733
|
});
|
|
734
734
|
}, !1, t);
|
|
735
735
|
}
|
|
736
|
-
const
|
|
737
|
-
id:
|
|
736
|
+
const fe = d({
|
|
737
|
+
id: v(),
|
|
738
738
|
type: h(),
|
|
739
739
|
title: h(),
|
|
740
740
|
photoUrl: {
|
|
@@ -742,7 +742,7 @@ const ge = _({
|
|
|
742
742
|
from: "photo_url"
|
|
743
743
|
},
|
|
744
744
|
username: h().optional()
|
|
745
|
-
}, "Chat").optional(),
|
|
745
|
+
}, "Chat").optional(), nt = d({
|
|
746
746
|
addedToAttachmentMenu: {
|
|
747
747
|
type: w().optional(),
|
|
748
748
|
from: "added_to_attachment_menu"
|
|
@@ -755,7 +755,7 @@ const ge = _({
|
|
|
755
755
|
type: h(),
|
|
756
756
|
from: "first_name"
|
|
757
757
|
},
|
|
758
|
-
id:
|
|
758
|
+
id: v(),
|
|
759
759
|
isBot: {
|
|
760
760
|
type: w().optional(),
|
|
761
761
|
from: "is_bot"
|
|
@@ -778,17 +778,17 @@ const ge = _({
|
|
|
778
778
|
},
|
|
779
779
|
username: h().optional()
|
|
780
780
|
}, "User").optional();
|
|
781
|
-
function
|
|
782
|
-
return
|
|
781
|
+
function Et() {
|
|
782
|
+
return X({
|
|
783
783
|
authDate: {
|
|
784
|
-
type:
|
|
784
|
+
type: vt(),
|
|
785
785
|
from: "auth_date"
|
|
786
786
|
},
|
|
787
787
|
canSendAfter: {
|
|
788
|
-
type:
|
|
788
|
+
type: v().optional(),
|
|
789
789
|
from: "can_send_after"
|
|
790
790
|
},
|
|
791
|
-
chat:
|
|
791
|
+
chat: fe,
|
|
792
792
|
chatInstance: {
|
|
793
793
|
type: h().optional(),
|
|
794
794
|
from: "chat_instance"
|
|
@@ -802,35 +802,35 @@ function vt() {
|
|
|
802
802
|
type: h().optional(),
|
|
803
803
|
from: "query_id"
|
|
804
804
|
},
|
|
805
|
-
receiver:
|
|
805
|
+
receiver: nt,
|
|
806
806
|
startParam: {
|
|
807
807
|
type: h().optional(),
|
|
808
808
|
from: "start_param"
|
|
809
809
|
},
|
|
810
|
-
user:
|
|
810
|
+
user: nt
|
|
811
811
|
}, "InitData");
|
|
812
812
|
}
|
|
813
|
-
function
|
|
813
|
+
function ge(e) {
|
|
814
814
|
return e.replace(/_[a-z]/g, (t) => t[1].toUpperCase());
|
|
815
815
|
}
|
|
816
|
-
function
|
|
816
|
+
function be(e) {
|
|
817
817
|
return e.replace(/[A-Z]/g, (t) => `_${t.toLowerCase()}`);
|
|
818
818
|
}
|
|
819
|
-
const
|
|
819
|
+
const Pt = x(
|
|
820
820
|
(e) => {
|
|
821
821
|
const t = dt().optional();
|
|
822
|
-
return Object.entries(
|
|
822
|
+
return Object.entries(J(e)).reduce((s, [n, r]) => (s[ge(n)] = t.parse(r), s), {});
|
|
823
823
|
},
|
|
824
824
|
"ThemeParams"
|
|
825
825
|
);
|
|
826
|
-
function
|
|
827
|
-
return
|
|
826
|
+
function xt(e) {
|
|
827
|
+
return X({
|
|
828
828
|
botInline: {
|
|
829
829
|
type: w().optional(),
|
|
830
830
|
from: "tgWebAppBotInline"
|
|
831
831
|
},
|
|
832
832
|
initData: {
|
|
833
|
-
type:
|
|
833
|
+
type: Et().optional(),
|
|
834
834
|
from: "tgWebAppData"
|
|
835
835
|
},
|
|
836
836
|
initDataRaw: {
|
|
@@ -850,7 +850,7 @@ function Pt(e) {
|
|
|
850
850
|
from: "tgWebAppStartParam"
|
|
851
851
|
},
|
|
852
852
|
themeParams: {
|
|
853
|
-
type:
|
|
853
|
+
type: Pt(),
|
|
854
854
|
from: "tgWebAppThemeParams"
|
|
855
855
|
},
|
|
856
856
|
version: {
|
|
@@ -860,18 +860,18 @@ function Pt(e) {
|
|
|
860
860
|
}).parse(e);
|
|
861
861
|
}
|
|
862
862
|
function St(e) {
|
|
863
|
-
return
|
|
863
|
+
return xt(
|
|
864
864
|
e.replace(/^[^?#]*[?#]/, "").replace(/[?#]/g, "&")
|
|
865
865
|
);
|
|
866
866
|
}
|
|
867
|
-
function
|
|
867
|
+
function we() {
|
|
868
868
|
return St(window.location.href);
|
|
869
869
|
}
|
|
870
|
-
function
|
|
870
|
+
function Ct() {
|
|
871
871
|
return performance.getEntriesByType("navigation")[0];
|
|
872
872
|
}
|
|
873
|
-
function
|
|
874
|
-
const e =
|
|
873
|
+
function me() {
|
|
874
|
+
const e = Ct();
|
|
875
875
|
if (!e)
|
|
876
876
|
throw new Error("Unable to get first navigation entry.");
|
|
877
877
|
return St(e.name);
|
|
@@ -879,7 +879,7 @@ function ye() {
|
|
|
879
879
|
function Rt(e) {
|
|
880
880
|
return `tma.js/${e.replace(/[A-Z]/g, (t) => `-${t.toLowerCase()}`)}`;
|
|
881
881
|
}
|
|
882
|
-
function
|
|
882
|
+
function At(e, t) {
|
|
883
883
|
sessionStorage.setItem(Rt(e), JSON.stringify(t));
|
|
884
884
|
}
|
|
885
885
|
function Tt(e) {
|
|
@@ -889,17 +889,17 @@ function Tt(e) {
|
|
|
889
889
|
} catch {
|
|
890
890
|
}
|
|
891
891
|
}
|
|
892
|
-
function
|
|
893
|
-
return
|
|
892
|
+
function ye() {
|
|
893
|
+
return xt(Tt("launchParams") || "");
|
|
894
894
|
}
|
|
895
|
-
function
|
|
895
|
+
function ve(e) {
|
|
896
896
|
return JSON.stringify(
|
|
897
897
|
Object.fromEntries(
|
|
898
|
-
Object.entries(e).map(([t, s]) => [
|
|
898
|
+
Object.entries(e).map(([t, s]) => [be(t), s])
|
|
899
899
|
)
|
|
900
900
|
);
|
|
901
901
|
}
|
|
902
|
-
function
|
|
902
|
+
function Ee(e) {
|
|
903
903
|
const {
|
|
904
904
|
initDataRaw: t,
|
|
905
905
|
themeParams: s,
|
|
@@ -909,76 +909,66 @@ function Pe(e) {
|
|
|
909
909
|
startParam: o,
|
|
910
910
|
botInline: a
|
|
911
911
|
} = e, p = new URLSearchParams();
|
|
912
|
-
return p.set("tgWebAppPlatform", n), p.set("tgWebAppThemeParams",
|
|
912
|
+
return p.set("tgWebAppPlatform", n), p.set("tgWebAppThemeParams", ve(s)), p.set("tgWebAppVersion", r), t && p.set("tgWebAppData", t), o && p.set("tgWebAppStartParam", o), typeof i == "boolean" && p.set("tgWebAppShowSettings", i ? "1" : "0"), typeof a == "boolean" && p.set("tgWebAppBotInline", a ? "1" : "0"), p.toString();
|
|
913
913
|
}
|
|
914
|
-
function
|
|
915
|
-
|
|
914
|
+
function Pe(e) {
|
|
915
|
+
At("launchParams", Ee(e));
|
|
916
916
|
}
|
|
917
917
|
function xe() {
|
|
918
918
|
for (const e of [
|
|
919
919
|
// Try to retrieve launch parameters from the current location. This method can return
|
|
920
920
|
// nothing in case, location was changed and then page was reloaded.
|
|
921
|
-
|
|
921
|
+
we,
|
|
922
922
|
// Then, try using the lower level API - window.performance.
|
|
923
|
-
|
|
923
|
+
me,
|
|
924
924
|
// Finally, try to extract launch parameters from the session storage.
|
|
925
|
-
|
|
925
|
+
ye
|
|
926
926
|
])
|
|
927
927
|
try {
|
|
928
928
|
const t = e();
|
|
929
|
-
return
|
|
929
|
+
return Pe(t), t;
|
|
930
930
|
} catch {
|
|
931
931
|
}
|
|
932
932
|
throw new Error("Unable to retrieve launch parameters from any known source.");
|
|
933
933
|
}
|
|
934
|
-
function
|
|
935
|
-
const e =
|
|
934
|
+
function It() {
|
|
935
|
+
const e = Ct();
|
|
936
936
|
return !!(e && e.type === "reload");
|
|
937
937
|
}
|
|
938
|
-
function
|
|
938
|
+
function Se() {
|
|
939
939
|
let e = 0;
|
|
940
940
|
return () => (e += 1).toString();
|
|
941
941
|
}
|
|
942
|
-
const [Ce] =
|
|
943
|
-
function
|
|
942
|
+
const [Ce] = at(Se);
|
|
943
|
+
function u(e, t) {
|
|
944
944
|
return ({ ssr: s } = {}) => {
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
);
|
|
952
|
-
n = s;
|
|
953
|
-
} else
|
|
954
|
-
n = xe();
|
|
955
|
-
const r = {
|
|
945
|
+
const n = y() ? {
|
|
946
|
+
version: "6.0",
|
|
947
|
+
themeParams: {},
|
|
948
|
+
platform: "unknown",
|
|
949
|
+
...s || {}
|
|
950
|
+
} : xe(), r = {
|
|
956
951
|
...n,
|
|
957
|
-
postEvent:
|
|
958
|
-
throw u(
|
|
959
|
-
Yt,
|
|
960
|
-
"postEvent function is forbidden to be called on the server side."
|
|
961
|
-
);
|
|
962
|
-
},
|
|
952
|
+
postEvent: y() ? () => null : le(n.version),
|
|
963
953
|
createRequestId: Ce()
|
|
964
954
|
};
|
|
965
|
-
if (
|
|
955
|
+
if (y() || typeof e == "function")
|
|
966
956
|
return typeof e == "function" ? e(r) : t(r);
|
|
967
957
|
const i = t({
|
|
968
958
|
...r,
|
|
969
|
-
state:
|
|
959
|
+
state: It() ? Tt(e) : void 0
|
|
970
960
|
}), o = (a) => (a.on("change", (p) => {
|
|
971
|
-
|
|
961
|
+
At(e, p);
|
|
972
962
|
}), a);
|
|
973
963
|
return i instanceof Promise ? i.then(o) : o(i);
|
|
974
964
|
};
|
|
975
965
|
}
|
|
976
|
-
const
|
|
966
|
+
const rs = u("backButton", ({
|
|
977
967
|
postEvent: e,
|
|
978
968
|
version: t,
|
|
979
969
|
state: s = { isVisible: !1 }
|
|
980
|
-
}) => new
|
|
981
|
-
class q extends
|
|
970
|
+
}) => new _e(s.isVisible, t, e));
|
|
971
|
+
class q extends Z {
|
|
982
972
|
constructor() {
|
|
983
973
|
super(...arguments);
|
|
984
974
|
/**
|
|
@@ -991,7 +981,7 @@ class q extends X {
|
|
|
991
981
|
c(this, "off", this.state.off.bind(this.state));
|
|
992
982
|
}
|
|
993
983
|
}
|
|
994
|
-
function
|
|
984
|
+
function qt(e) {
|
|
995
985
|
const t = e.available ? e : {
|
|
996
986
|
available: !1,
|
|
997
987
|
device_id: "",
|
|
@@ -1009,7 +999,7 @@ function It(e) {
|
|
|
1009
999
|
accessGranted: t.access_granted
|
|
1010
1000
|
};
|
|
1011
1001
|
}
|
|
1012
|
-
class
|
|
1002
|
+
class rt extends q {
|
|
1013
1003
|
constructor({ postEvent: s, version: n, ...r }) {
|
|
1014
1004
|
super(r, n, {
|
|
1015
1005
|
auth: "web_app_biometry_request_auth",
|
|
@@ -1050,7 +1040,7 @@ class it extends q {
|
|
|
1050
1040
|
reason: s,
|
|
1051
1041
|
...n
|
|
1052
1042
|
}) {
|
|
1053
|
-
return this.authPromise || (this.authPromise =
|
|
1043
|
+
return this.authPromise || (this.authPromise = _({
|
|
1054
1044
|
...n,
|
|
1055
1045
|
method: "web_app_biometry_request_auth",
|
|
1056
1046
|
event: "biometry_auth_requested",
|
|
@@ -1084,14 +1074,14 @@ class it extends q {
|
|
|
1084
1074
|
* @returns Promise with true, if access was granted.
|
|
1085
1075
|
*/
|
|
1086
1076
|
requestAccess({ reason: s, ...n } = {}) {
|
|
1087
|
-
return this.accessPromise || (this.accessPromise =
|
|
1077
|
+
return this.accessPromise || (this.accessPromise = _({
|
|
1088
1078
|
...n,
|
|
1089
1079
|
postEvent: this.postEvent,
|
|
1090
1080
|
method: "web_app_biometry_request_access",
|
|
1091
1081
|
event: "biometry_info_received",
|
|
1092
1082
|
params: { reason: s || "" }
|
|
1093
1083
|
}).then((r) => {
|
|
1094
|
-
const i =
|
|
1084
|
+
const i = qt(r);
|
|
1095
1085
|
return this.set(i), i.accessGranted;
|
|
1096
1086
|
}).finally(() => this.accessPromise = void 0)), this.accessPromise;
|
|
1097
1087
|
}
|
|
@@ -1113,7 +1103,7 @@ class it extends q {
|
|
|
1113
1103
|
*/
|
|
1114
1104
|
async updateToken({ token: s, ...n } = {}) {
|
|
1115
1105
|
return ["removed", "updated"].includes(
|
|
1116
|
-
(await
|
|
1106
|
+
(await _({
|
|
1117
1107
|
...n,
|
|
1118
1108
|
postEvent: this.postEvent,
|
|
1119
1109
|
method: "web_app_biometry_update_token",
|
|
@@ -1123,30 +1113,30 @@ class it extends q {
|
|
|
1123
1113
|
);
|
|
1124
1114
|
}
|
|
1125
1115
|
}
|
|
1126
|
-
async function
|
|
1127
|
-
return
|
|
1128
|
-
await
|
|
1116
|
+
async function Re(e) {
|
|
1117
|
+
return qt(
|
|
1118
|
+
await _({
|
|
1129
1119
|
...e || {},
|
|
1130
1120
|
method: "web_app_biometry_get_info",
|
|
1131
1121
|
event: "biometry_info_received"
|
|
1132
1122
|
})
|
|
1133
1123
|
);
|
|
1134
1124
|
}
|
|
1135
|
-
const
|
|
1125
|
+
const is = u("biometryManager", async ({ postEvent: e, version: t, state: s }) => {
|
|
1136
1126
|
if (s)
|
|
1137
|
-
return new
|
|
1138
|
-
if (
|
|
1139
|
-
throw
|
|
1140
|
-
|
|
1127
|
+
return new rt({ ...s, version: t, postEvent: e });
|
|
1128
|
+
if (y())
|
|
1129
|
+
throw f(
|
|
1130
|
+
pt,
|
|
1141
1131
|
"BiometryManager cannot be instantiated on the server side without passing the ssr.state object."
|
|
1142
1132
|
);
|
|
1143
|
-
return new
|
|
1144
|
-
...await
|
|
1133
|
+
return new rt({
|
|
1134
|
+
...await Re({ timeout: 1e3 }),
|
|
1145
1135
|
version: t,
|
|
1146
1136
|
postEvent: e
|
|
1147
1137
|
});
|
|
1148
1138
|
});
|
|
1149
|
-
class
|
|
1139
|
+
class K extends Y {
|
|
1150
1140
|
constructor() {
|
|
1151
1141
|
super(...arguments);
|
|
1152
1142
|
/**
|
|
@@ -1159,7 +1149,7 @@ class tt extends Z {
|
|
|
1159
1149
|
c(this, "off", this.state.off.bind(this.state));
|
|
1160
1150
|
}
|
|
1161
1151
|
}
|
|
1162
|
-
class Ae extends
|
|
1152
|
+
class Ae extends K {
|
|
1163
1153
|
constructor(t, s) {
|
|
1164
1154
|
super({ isConfirmationNeeded: t }), this.postEvent = s;
|
|
1165
1155
|
}
|
|
@@ -1186,20 +1176,20 @@ class Ae extends tt {
|
|
|
1186
1176
|
this.isConfirmationNeeded = !0;
|
|
1187
1177
|
}
|
|
1188
1178
|
}
|
|
1189
|
-
const
|
|
1179
|
+
const os = u("closingBehavior", ({
|
|
1190
1180
|
postEvent: e,
|
|
1191
1181
|
state: t = { isConfirmationNeeded: !1 }
|
|
1192
1182
|
}) => new Ae(t.isConfirmationNeeded, e));
|
|
1193
|
-
class
|
|
1183
|
+
class tt {
|
|
1194
1184
|
constructor(t, s) {
|
|
1195
1185
|
/**
|
|
1196
1186
|
* @returns True, if specified method is supported by the current component.
|
|
1197
1187
|
*/
|
|
1198
1188
|
c(this, "supports");
|
|
1199
|
-
this.supports =
|
|
1189
|
+
this.supports = yt(t, s);
|
|
1200
1190
|
}
|
|
1201
1191
|
}
|
|
1202
|
-
function
|
|
1192
|
+
function Te(e) {
|
|
1203
1193
|
if (Array.isArray(e))
|
|
1204
1194
|
return e;
|
|
1205
1195
|
if (typeof e == "string")
|
|
@@ -1211,9 +1201,9 @@ function Ie(e) {
|
|
|
1211
1201
|
}
|
|
1212
1202
|
throw P();
|
|
1213
1203
|
}
|
|
1214
|
-
class
|
|
1204
|
+
class Ie extends M {
|
|
1215
1205
|
constructor(s, n, r) {
|
|
1216
|
-
super(
|
|
1206
|
+
super(Te, n, r);
|
|
1217
1207
|
c(this, "itemParser");
|
|
1218
1208
|
this.itemParser = typeof s == "function" ? s : s.parse.bind(s);
|
|
1219
1209
|
}
|
|
@@ -1231,13 +1221,13 @@ class qe extends M {
|
|
|
1231
1221
|
return this.itemParser = typeof s == "function" ? s : s.parse.bind(s), this;
|
|
1232
1222
|
}
|
|
1233
1223
|
}
|
|
1234
|
-
function
|
|
1235
|
-
return new
|
|
1224
|
+
function qe(e) {
|
|
1225
|
+
return new Ie((t) => t, !1, e);
|
|
1236
1226
|
}
|
|
1237
|
-
function
|
|
1227
|
+
function it(e, t) {
|
|
1238
1228
|
return Object.fromEntries(e.map((s) => [s, t]));
|
|
1239
1229
|
}
|
|
1240
|
-
class
|
|
1230
|
+
class ke extends tt {
|
|
1241
1231
|
constructor(t, s, n) {
|
|
1242
1232
|
super(t, {
|
|
1243
1233
|
delete: "web_app_invoke_custom_method",
|
|
@@ -1253,7 +1243,7 @@ class Ne extends et {
|
|
|
1253
1243
|
*/
|
|
1254
1244
|
async delete(t, s = {}) {
|
|
1255
1245
|
const n = Array.isArray(t) ? t : [t];
|
|
1256
|
-
n.length && await
|
|
1246
|
+
n.length && await C(
|
|
1257
1247
|
"deleteStorageValues",
|
|
1258
1248
|
{ keys: n },
|
|
1259
1249
|
this.createRequestId(),
|
|
@@ -1265,8 +1255,8 @@ class Ne extends et {
|
|
|
1265
1255
|
* @param options - request execution options.
|
|
1266
1256
|
*/
|
|
1267
1257
|
async getKeys(t = {}) {
|
|
1268
|
-
return
|
|
1269
|
-
await
|
|
1258
|
+
return qe().of(h()).parse(
|
|
1259
|
+
await C(
|
|
1270
1260
|
"getStorageKeys",
|
|
1271
1261
|
{},
|
|
1272
1262
|
this.createRequestId(),
|
|
@@ -1277,13 +1267,13 @@ class Ne extends et {
|
|
|
1277
1267
|
async get(t, s = {}) {
|
|
1278
1268
|
const n = Array.isArray(t) ? t : [t];
|
|
1279
1269
|
if (!n.length)
|
|
1280
|
-
return
|
|
1281
|
-
const r = await
|
|
1270
|
+
return it(n, "");
|
|
1271
|
+
const r = await C(
|
|
1282
1272
|
"getStorageValues",
|
|
1283
1273
|
{ keys: n },
|
|
1284
1274
|
this.createRequestId(),
|
|
1285
1275
|
{ ...s, postEvent: this.postEvent }
|
|
1286
|
-
), i =
|
|
1276
|
+
), i = d(it(n, h()), "CloudStorageData").parse(r);
|
|
1287
1277
|
return Array.isArray(t) ? i : i[t];
|
|
1288
1278
|
}
|
|
1289
1279
|
/**
|
|
@@ -1293,7 +1283,7 @@ class Ne extends et {
|
|
|
1293
1283
|
* @param options - request execution options.
|
|
1294
1284
|
*/
|
|
1295
1285
|
async set(t, s, n = {}) {
|
|
1296
|
-
await
|
|
1286
|
+
await C(
|
|
1297
1287
|
"saveStorageValue",
|
|
1298
1288
|
{ key: t, value: s },
|
|
1299
1289
|
this.createRequestId(),
|
|
@@ -1301,10 +1291,10 @@ class Ne extends et {
|
|
|
1301
1291
|
);
|
|
1302
1292
|
}
|
|
1303
1293
|
}
|
|
1304
|
-
const
|
|
1305
|
-
({ createRequestId: e, postEvent: t, version: s }) => new
|
|
1294
|
+
const as = u(
|
|
1295
|
+
({ createRequestId: e, postEvent: t, version: s }) => new ke(s, e, t)
|
|
1306
1296
|
);
|
|
1307
|
-
class
|
|
1297
|
+
class Ne extends tt {
|
|
1308
1298
|
constructor(t, s) {
|
|
1309
1299
|
super(t, {
|
|
1310
1300
|
impactOccurred: "web_app_trigger_haptic_feedback",
|
|
@@ -1346,10 +1336,10 @@ class De extends et {
|
|
|
1346
1336
|
this.postEvent("web_app_trigger_haptic_feedback", { type: "selection_change" });
|
|
1347
1337
|
}
|
|
1348
1338
|
}
|
|
1349
|
-
const
|
|
1350
|
-
({ version: e, postEvent: t }) => new
|
|
1339
|
+
const cs = u(
|
|
1340
|
+
({ version: e, postEvent: t }) => new Ne(e, t)
|
|
1351
1341
|
);
|
|
1352
|
-
class
|
|
1342
|
+
class De {
|
|
1353
1343
|
constructor(t) {
|
|
1354
1344
|
this.initData = t;
|
|
1355
1345
|
}
|
|
@@ -1422,13 +1412,13 @@ class Ve {
|
|
|
1422
1412
|
return this.initData.user;
|
|
1423
1413
|
}
|
|
1424
1414
|
}
|
|
1425
|
-
const
|
|
1426
|
-
({ initData: e }) => e ? new
|
|
1415
|
+
const hs = u(
|
|
1416
|
+
({ initData: e }) => e ? new De(e) : void 0
|
|
1427
1417
|
);
|
|
1428
|
-
function
|
|
1429
|
-
return
|
|
1418
|
+
function ps(e) {
|
|
1419
|
+
return Et().parse(e);
|
|
1430
1420
|
}
|
|
1431
|
-
class
|
|
1421
|
+
class Ve extends q {
|
|
1432
1422
|
constructor(t, s, n) {
|
|
1433
1423
|
super({ isOpened: t }, s, { open: "web_app_open_invoice" }), this.postEvent = n;
|
|
1434
1424
|
}
|
|
@@ -1458,7 +1448,7 @@ class $e extends q {
|
|
|
1458
1448
|
}
|
|
1459
1449
|
this.isOpened = !0;
|
|
1460
1450
|
try {
|
|
1461
|
-
return (await
|
|
1451
|
+
return (await _({
|
|
1462
1452
|
method: "web_app_open_invoice",
|
|
1463
1453
|
event: "invoice_closed",
|
|
1464
1454
|
params: { slug: n },
|
|
@@ -1472,10 +1462,10 @@ class $e extends q {
|
|
|
1472
1462
|
}
|
|
1473
1463
|
}
|
|
1474
1464
|
}
|
|
1475
|
-
const
|
|
1476
|
-
({ version: e, postEvent: t }) => new
|
|
1465
|
+
const us = u(
|
|
1466
|
+
({ version: e, postEvent: t }) => new Ve(!1, e, t)
|
|
1477
1467
|
);
|
|
1478
|
-
class
|
|
1468
|
+
class $e extends Y {
|
|
1479
1469
|
constructor({ postEvent: s, ...n }) {
|
|
1480
1470
|
super(n);
|
|
1481
1471
|
c(this, "postEvent");
|
|
@@ -1620,7 +1610,7 @@ class Me extends Z {
|
|
|
1620
1610
|
return this.set(s), this.commit(), this;
|
|
1621
1611
|
}
|
|
1622
1612
|
}
|
|
1623
|
-
const
|
|
1613
|
+
const ls = u("mainButton", ({
|
|
1624
1614
|
postEvent: e,
|
|
1625
1615
|
themeParams: t,
|
|
1626
1616
|
state: s = {
|
|
@@ -1631,12 +1621,12 @@ const ds = l("mainButton", ({
|
|
|
1631
1621
|
textColor: t.buttonTextColor || "#ffffff",
|
|
1632
1622
|
backgroundColor: t.buttonColor || "#000000"
|
|
1633
1623
|
}
|
|
1634
|
-
}) => new
|
|
1635
|
-
function
|
|
1636
|
-
return
|
|
1637
|
-
contact:
|
|
1624
|
+
}) => new $e({ ...s, postEvent: e }));
|
|
1625
|
+
function Me() {
|
|
1626
|
+
return X({
|
|
1627
|
+
contact: d({
|
|
1638
1628
|
userId: {
|
|
1639
|
-
type:
|
|
1629
|
+
type: v(),
|
|
1640
1630
|
from: "user_id"
|
|
1641
1631
|
},
|
|
1642
1632
|
phoneNumber: {
|
|
@@ -1653,24 +1643,24 @@ function Le() {
|
|
|
1653
1643
|
}
|
|
1654
1644
|
}),
|
|
1655
1645
|
authDate: {
|
|
1656
|
-
type:
|
|
1646
|
+
type: vt(),
|
|
1657
1647
|
from: "auth_date"
|
|
1658
1648
|
},
|
|
1659
1649
|
hash: h()
|
|
1660
1650
|
}, "RequestedContact");
|
|
1661
1651
|
}
|
|
1662
|
-
function
|
|
1652
|
+
function kt(e, t) {
|
|
1663
1653
|
return (s) => {
|
|
1664
1654
|
const [n, r] = t[s];
|
|
1665
|
-
return
|
|
1655
|
+
return E(n, r, e);
|
|
1666
1656
|
};
|
|
1667
1657
|
}
|
|
1668
|
-
function
|
|
1658
|
+
function Le(e) {
|
|
1669
1659
|
return new Promise((t) => {
|
|
1670
1660
|
setTimeout(t, e);
|
|
1671
1661
|
});
|
|
1672
1662
|
}
|
|
1673
|
-
class
|
|
1663
|
+
class Be extends q {
|
|
1674
1664
|
constructor({ postEvent: s, createRequestId: n, version: r, botInline: i, ...o }) {
|
|
1675
1665
|
super(o, r, {
|
|
1676
1666
|
requestPhoneAccess: "web_app_request_phone",
|
|
@@ -1690,7 +1680,7 @@ class Oe extends q {
|
|
|
1690
1680
|
c(this, "supportsParam");
|
|
1691
1681
|
this.createRequestId = n, this.postEvent = s, this.botInline = i;
|
|
1692
1682
|
const a = this.supports.bind(this);
|
|
1693
|
-
this.supports = (p) => a(p) ? p !== "switchInlineQuery" || i : !1, this.supportsParam =
|
|
1683
|
+
this.supports = (p) => a(p) ? p !== "switchInlineQuery" || i : !1, this.supportsParam = kt(r, {
|
|
1694
1684
|
"setHeaderColor.color": ["web_app_set_header_color", "color"]
|
|
1695
1685
|
});
|
|
1696
1686
|
}
|
|
@@ -1701,8 +1691,8 @@ class Oe extends q {
|
|
|
1701
1691
|
async getRequestedContact({
|
|
1702
1692
|
timeout: s = 1e4
|
|
1703
1693
|
} = {}) {
|
|
1704
|
-
return
|
|
1705
|
-
await
|
|
1694
|
+
return Me().parse(
|
|
1695
|
+
await C(
|
|
1706
1696
|
"getRequestedContact",
|
|
1707
1697
|
{},
|
|
1708
1698
|
this.createRequestId(),
|
|
@@ -1741,7 +1731,7 @@ class Oe extends q {
|
|
|
1741
1731
|
* True if current Mini App background color is recognized as dark.
|
|
1742
1732
|
*/
|
|
1743
1733
|
get isDark() {
|
|
1744
|
-
return
|
|
1734
|
+
return mt(this.bgColor);
|
|
1745
1735
|
}
|
|
1746
1736
|
/**
|
|
1747
1737
|
* Informs the Telegram app that the Mini App is ready to be displayed.
|
|
@@ -1770,15 +1760,15 @@ class Oe extends q {
|
|
|
1770
1760
|
throw new Error("Access denied.");
|
|
1771
1761
|
const r = Date.now() + s;
|
|
1772
1762
|
let i = 50;
|
|
1773
|
-
return
|
|
1763
|
+
return wt(async () => {
|
|
1774
1764
|
for (; Date.now() < r; ) {
|
|
1775
1765
|
try {
|
|
1776
1766
|
return await this.getRequestedContact();
|
|
1777
1767
|
} catch {
|
|
1778
1768
|
}
|
|
1779
|
-
await
|
|
1769
|
+
await Le(i), i += 50;
|
|
1780
1770
|
}
|
|
1781
|
-
throw
|
|
1771
|
+
throw bt(s);
|
|
1782
1772
|
}, s);
|
|
1783
1773
|
}
|
|
1784
1774
|
/**
|
|
@@ -1791,7 +1781,7 @@ class Oe extends q {
|
|
|
1791
1781
|
* @see requestContact
|
|
1792
1782
|
*/
|
|
1793
1783
|
async requestPhoneAccess(s = {}) {
|
|
1794
|
-
return this.requestPhoneAccessPromise || (this.requestPhoneAccessPromise =
|
|
1784
|
+
return this.requestPhoneAccessPromise || (this.requestPhoneAccessPromise = _({
|
|
1795
1785
|
...s,
|
|
1796
1786
|
method: "web_app_request_phone",
|
|
1797
1787
|
event: "phone_requested",
|
|
@@ -1803,7 +1793,7 @@ class Oe extends q {
|
|
|
1803
1793
|
* @param options - additional options.
|
|
1804
1794
|
*/
|
|
1805
1795
|
async requestWriteAccess(s = {}) {
|
|
1806
|
-
return this.requestWriteAccessPromise || (this.requestWriteAccessPromise =
|
|
1796
|
+
return this.requestWriteAccessPromise || (this.requestWriteAccessPromise = _({
|
|
1807
1797
|
...s,
|
|
1808
1798
|
method: "web_app_request_write_access",
|
|
1809
1799
|
event: "write_access_requested",
|
|
@@ -1833,7 +1823,7 @@ class Oe extends q {
|
|
|
1833
1823
|
* @param color - color key or RGB color.
|
|
1834
1824
|
*/
|
|
1835
1825
|
setHeaderColor(s) {
|
|
1836
|
-
this.postEvent("web_app_set_header_color",
|
|
1826
|
+
this.postEvent("web_app_set_header_color", Q(s) ? { color: s } : { color_key: s }), this.set("headerColor", s);
|
|
1837
1827
|
}
|
|
1838
1828
|
/**
|
|
1839
1829
|
* Updates current Mini App background color.
|
|
@@ -1861,7 +1851,7 @@ class Oe extends q {
|
|
|
1861
1851
|
this.postEvent("web_app_switch_inline_query", { query: s, chat_types: n });
|
|
1862
1852
|
}
|
|
1863
1853
|
}
|
|
1864
|
-
const
|
|
1854
|
+
const ds = u("miniApp", ({
|
|
1865
1855
|
themeParams: e,
|
|
1866
1856
|
botInline: t = !1,
|
|
1867
1857
|
state: s = {
|
|
@@ -1869,8 +1859,8 @@ const _s = l("miniApp", ({
|
|
|
1869
1859
|
headerColor: e.headerBgColor || "#000000"
|
|
1870
1860
|
},
|
|
1871
1861
|
...n
|
|
1872
|
-
}) => new
|
|
1873
|
-
function
|
|
1862
|
+
}) => new Be({ ...n, ...s, botInline: t }));
|
|
1863
|
+
function Oe(e) {
|
|
1874
1864
|
const t = e.message.trim(), s = (e.title || "").trim(), n = e.buttons || [];
|
|
1875
1865
|
let r;
|
|
1876
1866
|
if (s.length > 64)
|
|
@@ -1894,7 +1884,7 @@ function Ue(e) {
|
|
|
1894
1884
|
return { ...i, id: o };
|
|
1895
1885
|
}) : r = [{ type: "close", id: "" }], { title: s, message: t, buttons: r };
|
|
1896
1886
|
}
|
|
1897
|
-
class
|
|
1887
|
+
class Ue extends q {
|
|
1898
1888
|
constructor(t, s, n) {
|
|
1899
1889
|
super({ isOpened: t }, s, { open: "web_app_open_popup" }), this.postEvent = n;
|
|
1900
1890
|
}
|
|
@@ -1923,11 +1913,11 @@ class We extends q {
|
|
|
1923
1913
|
throw new Error("Popup is already opened.");
|
|
1924
1914
|
this.isOpened = !0;
|
|
1925
1915
|
try {
|
|
1926
|
-
const { button_id: s = null } = await
|
|
1916
|
+
const { button_id: s = null } = await _({
|
|
1927
1917
|
event: "popup_closed",
|
|
1928
1918
|
method: "web_app_open_popup",
|
|
1929
1919
|
postEvent: this.postEvent,
|
|
1930
|
-
params:
|
|
1920
|
+
params: Oe(t)
|
|
1931
1921
|
});
|
|
1932
1922
|
return s;
|
|
1933
1923
|
} finally {
|
|
@@ -1935,10 +1925,10 @@ class We extends q {
|
|
|
1935
1925
|
}
|
|
1936
1926
|
}
|
|
1937
1927
|
}
|
|
1938
|
-
const
|
|
1939
|
-
({ postEvent: e, version: t }) => new
|
|
1928
|
+
const _s = u(
|
|
1929
|
+
({ postEvent: e, version: t }) => new Ue(!1, t, e)
|
|
1940
1930
|
);
|
|
1941
|
-
class
|
|
1931
|
+
class We extends q {
|
|
1942
1932
|
constructor(t, s, n) {
|
|
1943
1933
|
super({ isOpened: t }, s, {
|
|
1944
1934
|
close: "web_app_close_scan_qr_popup",
|
|
@@ -1971,7 +1961,7 @@ class He extends q {
|
|
|
1971
1961
|
throw new Error("QR scanner is already opened.");
|
|
1972
1962
|
this.isOpened = !0;
|
|
1973
1963
|
try {
|
|
1974
|
-
return (await
|
|
1964
|
+
return (await _({
|
|
1975
1965
|
method: "web_app_open_scan_qr_popup",
|
|
1976
1966
|
event: ["qr_text_received", "scan_qr_popup_closed"],
|
|
1977
1967
|
postEvent: this.postEvent,
|
|
@@ -1982,10 +1972,10 @@ class He extends q {
|
|
|
1982
1972
|
}
|
|
1983
1973
|
}
|
|
1984
1974
|
}
|
|
1985
|
-
const
|
|
1986
|
-
({ version: e, postEvent: t }) => new
|
|
1975
|
+
const fs = u(
|
|
1976
|
+
({ version: e, postEvent: t }) => new We(!1, e, t)
|
|
1987
1977
|
);
|
|
1988
|
-
class
|
|
1978
|
+
class He extends Z {
|
|
1989
1979
|
constructor(s, n, r) {
|
|
1990
1980
|
super({ isVisible: s }, n, {
|
|
1991
1981
|
show: "web_app_setup_settings_button",
|
|
@@ -2027,15 +2017,15 @@ class Ge extends X {
|
|
|
2027
2017
|
this.isVisible = !0;
|
|
2028
2018
|
}
|
|
2029
2019
|
}
|
|
2030
|
-
const
|
|
2020
|
+
const gs = u("settingsButton", ({
|
|
2031
2021
|
version: e,
|
|
2032
2022
|
postEvent: t,
|
|
2033
2023
|
state: s = { isVisible: !1 }
|
|
2034
|
-
}) => new
|
|
2035
|
-
function
|
|
2036
|
-
return
|
|
2024
|
+
}) => new He(s.isVisible, e, t));
|
|
2025
|
+
function Nt(e) {
|
|
2026
|
+
return Pt().parse(e);
|
|
2037
2027
|
}
|
|
2038
|
-
class
|
|
2028
|
+
class Ge extends K {
|
|
2039
2029
|
/**
|
|
2040
2030
|
* @since v6.10
|
|
2041
2031
|
*/
|
|
@@ -2074,7 +2064,7 @@ class je extends tt {
|
|
|
2074
2064
|
* value is calculated according to theme bg color.
|
|
2075
2065
|
*/
|
|
2076
2066
|
get isDark() {
|
|
2077
|
-
return !this.bgColor ||
|
|
2067
|
+
return !this.bgColor || mt(this.bgColor);
|
|
2078
2068
|
}
|
|
2079
2069
|
get linkColor() {
|
|
2080
2070
|
return this.get("linkColor");
|
|
@@ -2100,7 +2090,7 @@ class je extends tt {
|
|
|
2100
2090
|
*/
|
|
2101
2091
|
listen() {
|
|
2102
2092
|
return b("theme_changed", (t) => {
|
|
2103
|
-
this.set(
|
|
2093
|
+
this.set(Nt(t.theme_params));
|
|
2104
2094
|
});
|
|
2105
2095
|
}
|
|
2106
2096
|
/**
|
|
@@ -2113,25 +2103,25 @@ class je extends tt {
|
|
|
2113
2103
|
return this.get("textColor");
|
|
2114
2104
|
}
|
|
2115
2105
|
}
|
|
2116
|
-
const
|
|
2117
|
-
const s = new
|
|
2118
|
-
return
|
|
2106
|
+
const bs = u("themeParams", ({ themeParams: e, state: t = e }) => {
|
|
2107
|
+
const s = new Ge(t);
|
|
2108
|
+
return y() || s.listen(), s;
|
|
2119
2109
|
});
|
|
2120
|
-
function
|
|
2121
|
-
return
|
|
2110
|
+
function ws(e = {}) {
|
|
2111
|
+
return _({
|
|
2122
2112
|
...e,
|
|
2123
2113
|
method: "web_app_request_theme",
|
|
2124
2114
|
event: "theme_changed"
|
|
2125
|
-
}).then(
|
|
2115
|
+
}).then(Nt);
|
|
2126
2116
|
}
|
|
2127
|
-
class
|
|
2117
|
+
class je extends tt {
|
|
2128
2118
|
constructor(s, n, r) {
|
|
2129
2119
|
super(s, { readTextFromClipboard: "web_app_read_text_from_clipboard" });
|
|
2130
2120
|
/**
|
|
2131
2121
|
* Checks if specified method parameter is supported by current component.
|
|
2132
2122
|
*/
|
|
2133
2123
|
c(this, "supportsParam");
|
|
2134
|
-
this.version = s, this.createRequestId = n, this.postEvent = r, this.supportsParam =
|
|
2124
|
+
this.version = s, this.createRequestId = n, this.postEvent = r, this.supportsParam = kt(s, {
|
|
2135
2125
|
"openLink.tryInstantView": ["web_app_open_link", "try_instant_view"]
|
|
2136
2126
|
});
|
|
2137
2127
|
}
|
|
@@ -2146,7 +2136,7 @@ class ze extends et {
|
|
|
2146
2136
|
*/
|
|
2147
2137
|
openLink(s, n) {
|
|
2148
2138
|
const r = new URL(s, window.location.href).toString();
|
|
2149
|
-
if (!
|
|
2139
|
+
if (!E("web_app_open_link", this.version)) {
|
|
2150
2140
|
window.open(r, "_blank");
|
|
2151
2141
|
return;
|
|
2152
2142
|
}
|
|
@@ -2165,7 +2155,7 @@ class ze extends et {
|
|
|
2165
2155
|
const { hostname: n, pathname: r, search: i } = new URL(s, window.location.href);
|
|
2166
2156
|
if (n !== "t.me")
|
|
2167
2157
|
throw new Error(`URL has not allowed hostname: ${n}. Only "t.me" is allowed`);
|
|
2168
|
-
if (!
|
|
2158
|
+
if (!E("web_app_open_tg_link", this.version)) {
|
|
2169
2159
|
window.location.href = s;
|
|
2170
2160
|
return;
|
|
2171
2161
|
}
|
|
@@ -2180,41 +2170,41 @@ class ze extends et {
|
|
|
2180
2170
|
async readTextFromClipboard() {
|
|
2181
2171
|
const s = this.createRequestId(), {
|
|
2182
2172
|
data: n = null
|
|
2183
|
-
} = await
|
|
2173
|
+
} = await _({
|
|
2184
2174
|
method: "web_app_read_text_from_clipboard",
|
|
2185
2175
|
event: "clipboard_text_received",
|
|
2186
2176
|
postEvent: this.postEvent,
|
|
2187
2177
|
params: { req_id: s },
|
|
2188
|
-
capture:
|
|
2178
|
+
capture: gt(s)
|
|
2189
2179
|
});
|
|
2190
2180
|
return n;
|
|
2191
2181
|
}
|
|
2192
2182
|
}
|
|
2193
|
-
const
|
|
2194
|
-
({ version: e, postEvent: t, createRequestId: s }) => new
|
|
2183
|
+
const ms = u(
|
|
2184
|
+
({ version: e, postEvent: t, createRequestId: s }) => new je(e, s, t)
|
|
2195
2185
|
);
|
|
2196
|
-
async function
|
|
2186
|
+
async function Dt(e = {}) {
|
|
2197
2187
|
const {
|
|
2198
2188
|
is_expanded: t,
|
|
2199
2189
|
is_state_stable: s,
|
|
2200
2190
|
...n
|
|
2201
|
-
} = await
|
|
2191
|
+
} = await _({
|
|
2202
2192
|
...e,
|
|
2203
2193
|
method: "web_app_request_viewport",
|
|
2204
2194
|
event: "viewport_changed"
|
|
2205
2195
|
});
|
|
2206
2196
|
return { ...n, isExpanded: t, isStateStable: s };
|
|
2207
2197
|
}
|
|
2208
|
-
function
|
|
2198
|
+
function S(e) {
|
|
2209
2199
|
return e < 0 ? 0 : e;
|
|
2210
2200
|
}
|
|
2211
|
-
class
|
|
2201
|
+
class Vt extends K {
|
|
2212
2202
|
constructor({ postEvent: s, stableHeight: n, height: r, width: i, isExpanded: o }) {
|
|
2213
2203
|
super({
|
|
2214
|
-
height:
|
|
2204
|
+
height: S(r),
|
|
2215
2205
|
isExpanded: o,
|
|
2216
|
-
stableHeight:
|
|
2217
|
-
width:
|
|
2206
|
+
stableHeight: S(n),
|
|
2207
|
+
width: S(i)
|
|
2218
2208
|
});
|
|
2219
2209
|
c(this, "postEvent");
|
|
2220
2210
|
this.postEvent = s;
|
|
@@ -2225,7 +2215,7 @@ class Dt extends tt {
|
|
|
2225
2215
|
* @param options - options to request fresh data.
|
|
2226
2216
|
*/
|
|
2227
2217
|
async sync(s) {
|
|
2228
|
-
const { isStateStable: n, ...r } = await
|
|
2218
|
+
const { isStateStable: n, ...r } = await Dt(s);
|
|
2229
2219
|
this.set({
|
|
2230
2220
|
...r,
|
|
2231
2221
|
stableHeight: n ? r.height : this.get("stableHeight")
|
|
@@ -2278,11 +2268,11 @@ class Dt extends tt {
|
|
|
2278
2268
|
width: r,
|
|
2279
2269
|
is_expanded: i,
|
|
2280
2270
|
is_state_stable: o
|
|
2281
|
-
} = s, a =
|
|
2271
|
+
} = s, a = S(n);
|
|
2282
2272
|
this.set({
|
|
2283
2273
|
height: a,
|
|
2284
2274
|
isExpanded: i,
|
|
2285
|
-
width:
|
|
2275
|
+
width: S(r),
|
|
2286
2276
|
...o ? { stableHeight: a } : {}
|
|
2287
2277
|
});
|
|
2288
2278
|
});
|
|
@@ -2323,8 +2313,8 @@ async function Fe(e, t = {}) {
|
|
|
2323
2313
|
width: n,
|
|
2324
2314
|
isExpanded: r,
|
|
2325
2315
|
isStateStable: i
|
|
2326
|
-
} = await
|
|
2327
|
-
return new
|
|
2316
|
+
} = await Dt({ ...t, postEvent: e });
|
|
2317
|
+
return new Vt({
|
|
2328
2318
|
postEvent: e,
|
|
2329
2319
|
height: s,
|
|
2330
2320
|
width: n,
|
|
@@ -2332,13 +2322,13 @@ async function Fe(e, t = {}) {
|
|
|
2332
2322
|
stableHeight: i ? s : 0
|
|
2333
2323
|
});
|
|
2334
2324
|
}
|
|
2335
|
-
function
|
|
2325
|
+
function ze({
|
|
2336
2326
|
state: e,
|
|
2337
2327
|
platform: t,
|
|
2338
2328
|
postEvent: s
|
|
2339
2329
|
}) {
|
|
2340
2330
|
let n = !1, r = 0, i = 0, o = 0;
|
|
2341
|
-
return e ? (n = e.isExpanded, r = e.height, i = e.width, o = e.stableHeight) : ["macos", "tdesktop", "unigram", "webk", "weba", "web"].includes(t) && (n = !0, r = window.innerHeight, i = window.innerWidth, o = window.innerHeight), new
|
|
2331
|
+
return e ? (n = e.isExpanded, r = e.height, i = e.width, o = e.stableHeight) : ["macos", "tdesktop", "unigram", "webk", "weba", "web"].includes(t) && (n = !0, r = window.innerHeight, i = window.innerWidth, o = window.innerHeight), new Vt({
|
|
2342
2332
|
postEvent: s,
|
|
2343
2333
|
height: r,
|
|
2344
2334
|
width: i,
|
|
@@ -2346,30 +2336,30 @@ function Je({
|
|
|
2346
2336
|
isExpanded: n
|
|
2347
2337
|
});
|
|
2348
2338
|
}
|
|
2349
|
-
const
|
|
2339
|
+
const ys = u(
|
|
2350
2340
|
"viewport",
|
|
2351
2341
|
async (e) => {
|
|
2352
|
-
if (
|
|
2353
|
-
throw
|
|
2354
|
-
|
|
2342
|
+
if (y() && !e.state)
|
|
2343
|
+
throw f(
|
|
2344
|
+
pt,
|
|
2355
2345
|
"Viewport cannot be instantiated on the server side without passing the ssr.state object."
|
|
2356
2346
|
);
|
|
2357
|
-
let t =
|
|
2358
|
-
return
|
|
2347
|
+
let t = ze(e);
|
|
2348
|
+
return y() || (t.width === 0 && await Fe(e.postEvent, { timeout: 1e3 }).then((s) => t = s).catch((s) => D.error("Unable to sync viewport state", s)), t.listen()), t;
|
|
2359
2349
|
}
|
|
2360
2350
|
);
|
|
2361
2351
|
function m(e, t) {
|
|
2362
2352
|
document.documentElement.style.setProperty(e, t);
|
|
2363
2353
|
}
|
|
2364
|
-
function
|
|
2354
|
+
function vs(e, t, s) {
|
|
2365
2355
|
s || (s = (a) => `--tg-${a}-color`);
|
|
2366
2356
|
const n = s("header"), r = s("bg"), i = () => {
|
|
2367
2357
|
const { headerColor: a } = e;
|
|
2368
|
-
if (
|
|
2358
|
+
if (Q(a))
|
|
2369
2359
|
m(n, a);
|
|
2370
2360
|
else {
|
|
2371
|
-
const { bgColor: p, secondaryBgColor:
|
|
2372
|
-
a === "bg_color" && p ? m(n, p) : a === "secondary_bg_color" &&
|
|
2361
|
+
const { bgColor: p, secondaryBgColor: l } = t;
|
|
2362
|
+
a === "bg_color" && p ? m(n, p) : a === "secondary_bg_color" && l && m(n, l);
|
|
2373
2363
|
}
|
|
2374
2364
|
m(r, e.bgColor);
|
|
2375
2365
|
}, o = [
|
|
@@ -2378,7 +2368,7 @@ function Es(e, t, s) {
|
|
|
2378
2368
|
];
|
|
2379
2369
|
return i(), () => o.forEach((a) => a());
|
|
2380
2370
|
}
|
|
2381
|
-
function
|
|
2371
|
+
function Es(e, t) {
|
|
2382
2372
|
t || (t = (n) => `--tg-theme-${n.replace(/[A-Z]/g, (r) => `-${r.toLowerCase()}`)}`);
|
|
2383
2373
|
const s = () => {
|
|
2384
2374
|
Object.entries(e.getState()).forEach(([n, r]) => {
|
|
@@ -2387,23 +2377,23 @@ function Ps(e, t) {
|
|
|
2387
2377
|
};
|
|
2388
2378
|
return s(), e.on("change", s);
|
|
2389
2379
|
}
|
|
2390
|
-
function
|
|
2391
|
-
t || (t = (
|
|
2380
|
+
function Ps(e, t) {
|
|
2381
|
+
t || (t = (l) => `--tg-viewport-${l}`);
|
|
2392
2382
|
const [
|
|
2393
2383
|
s,
|
|
2394
2384
|
n,
|
|
2395
2385
|
r
|
|
2396
|
-
] = ["height", "width", "stable-height"].map((
|
|
2386
|
+
] = ["height", "width", "stable-height"].map((l) => t(l)), i = () => m(s, `${e.height}px`), o = () => m(n, `${e.width}px`), a = () => m(r, `${e.stableHeight}px`), p = [
|
|
2397
2387
|
e.on("change:height", i),
|
|
2398
2388
|
e.on("change:width", o),
|
|
2399
2389
|
e.on("change:stableHeight", a)
|
|
2400
2390
|
];
|
|
2401
|
-
return i(), o(), a(), () => p.forEach((
|
|
2391
|
+
return i(), o(), a(), () => p.forEach((l) => l());
|
|
2402
2392
|
}
|
|
2403
2393
|
function xs(e = !0) {
|
|
2404
2394
|
const t = [
|
|
2405
2395
|
b("reload_iframe", () => {
|
|
2406
|
-
|
|
2396
|
+
A("iframe_will_reload"), window.location.reload();
|
|
2407
2397
|
})
|
|
2408
2398
|
], s = () => t.forEach((n) => n());
|
|
2409
2399
|
if (e) {
|
|
@@ -2415,20 +2405,22 @@ function xs(e = !0) {
|
|
|
2415
2405
|
() => document.head.removeChild(n)
|
|
2416
2406
|
);
|
|
2417
2407
|
}
|
|
2418
|
-
return
|
|
2408
|
+
return A("iframe_ready", { reload_supported: !0 }), s;
|
|
2419
2409
|
}
|
|
2420
|
-
async function
|
|
2410
|
+
async function Ss() {
|
|
2411
|
+
if (_t(window))
|
|
2412
|
+
return !0;
|
|
2421
2413
|
try {
|
|
2422
|
-
return await
|
|
2414
|
+
return await _({ method: "web_app_request_theme", event: "theme_changed", timeout: 100 }), !0;
|
|
2423
2415
|
} catch {
|
|
2424
2416
|
return !1;
|
|
2425
2417
|
}
|
|
2426
2418
|
}
|
|
2427
|
-
function
|
|
2419
|
+
function Je(e) {
|
|
2428
2420
|
return e instanceof $;
|
|
2429
2421
|
}
|
|
2430
2422
|
function Cs(e, t) {
|
|
2431
|
-
return
|
|
2423
|
+
return Je(e) && e.type === t;
|
|
2432
2424
|
}
|
|
2433
2425
|
function O(e, t) {
|
|
2434
2426
|
let s, n, r;
|
|
@@ -2438,8 +2430,8 @@ function O(e, t) {
|
|
|
2438
2430
|
params: n
|
|
2439
2431
|
});
|
|
2440
2432
|
}
|
|
2441
|
-
class
|
|
2442
|
-
constructor(t, s, n =
|
|
2433
|
+
class Qe {
|
|
2434
|
+
constructor(t, s, n = A) {
|
|
2443
2435
|
/**
|
|
2444
2436
|
* Navigation history.
|
|
2445
2437
|
*/
|
|
@@ -2462,10 +2454,10 @@ class Ye {
|
|
|
2462
2454
|
*/
|
|
2463
2455
|
c(this, "off", this.ee.off.bind(this.ee));
|
|
2464
2456
|
if (this._index = s, this.postEvent = n, t.length === 0)
|
|
2465
|
-
throw
|
|
2457
|
+
throw f(Qt, "History should not be empty.");
|
|
2466
2458
|
if (s < 0 || s >= t.length)
|
|
2467
|
-
throw
|
|
2468
|
-
|
|
2459
|
+
throw f(
|
|
2460
|
+
Yt,
|
|
2469
2461
|
"Index should not be zero and higher or equal than history size."
|
|
2470
2462
|
);
|
|
2471
2463
|
this.history = t.map((r) => O(r, ""));
|
|
@@ -2586,12 +2578,12 @@ function U({
|
|
|
2586
2578
|
}) {
|
|
2587
2579
|
return { ...e || { hash: "", search: "" }, ...t };
|
|
2588
2580
|
}
|
|
2589
|
-
function
|
|
2581
|
+
function T(e, t) {
|
|
2590
2582
|
return e.startsWith(t) ? e : `${t}${e}`;
|
|
2591
2583
|
}
|
|
2592
2584
|
function k(e) {
|
|
2593
2585
|
return new URL(
|
|
2594
|
-
typeof e == "string" ? e : `${e.pathname || ""}${
|
|
2586
|
+
typeof e == "string" ? e : `${e.pathname || ""}${T(e.search || "", "?")}${T(e.hash || "", "#")}`,
|
|
2595
2587
|
"http://a"
|
|
2596
2588
|
);
|
|
2597
2589
|
}
|
|
@@ -2602,13 +2594,13 @@ function N(e) {
|
|
|
2602
2594
|
function W(e, t, s) {
|
|
2603
2595
|
let n, r;
|
|
2604
2596
|
typeof e == "string" ? n = e : (n = N(e), s = e.state, r = e.id);
|
|
2605
|
-
const { pathname: i, search: o, hash: a } = new URL(n, `http://a${
|
|
2597
|
+
const { pathname: i, search: o, hash: a } = new URL(n, `http://a${T(t, "/")}`);
|
|
2606
2598
|
return { id: r, pathname: i, params: { hash: a, search: o, state: s } };
|
|
2607
2599
|
}
|
|
2608
|
-
async function
|
|
2600
|
+
async function R(e) {
|
|
2609
2601
|
return e === 0 ? !0 : Promise.race([
|
|
2610
2602
|
new Promise((t) => {
|
|
2611
|
-
const s =
|
|
2603
|
+
const s = F("popstate", () => {
|
|
2612
2604
|
s(), t(!0);
|
|
2613
2605
|
});
|
|
2614
2606
|
window.history.go(e);
|
|
@@ -2619,18 +2611,18 @@ async function C(e) {
|
|
|
2619
2611
|
})
|
|
2620
2612
|
]);
|
|
2621
2613
|
}
|
|
2622
|
-
async function
|
|
2623
|
-
if (window.history.length <= 1 || (window.history.pushState(null, ""), await
|
|
2614
|
+
async function Ye() {
|
|
2615
|
+
if (window.history.length <= 1 || (window.history.pushState(null, ""), await R(1 - window.history.length)))
|
|
2624
2616
|
return;
|
|
2625
|
-
let t = await
|
|
2617
|
+
let t = await R(-1);
|
|
2626
2618
|
for (; t; )
|
|
2627
|
-
t = await
|
|
2619
|
+
t = await R(-1);
|
|
2628
2620
|
}
|
|
2629
|
-
function
|
|
2621
|
+
function $t(e) {
|
|
2630
2622
|
return k(e).pathname;
|
|
2631
2623
|
}
|
|
2632
|
-
const
|
|
2633
|
-
class
|
|
2624
|
+
const ot = 0, H = 1, G = 2;
|
|
2625
|
+
class Mt {
|
|
2634
2626
|
constructor(t, s, { postEvent: n, hashMode: r, base: i } = {}) {
|
|
2635
2627
|
c(this, "navigator");
|
|
2636
2628
|
c(this, "ee", new V());
|
|
@@ -2647,7 +2639,7 @@ class $t {
|
|
|
2647
2639
|
c(this, "onPopState", ({ state: t }) => {
|
|
2648
2640
|
if (t === null)
|
|
2649
2641
|
return this.push(this.parsePath(window.location.href));
|
|
2650
|
-
t ===
|
|
2642
|
+
t === ot ? window.history.forward() : t === H && this.back(), t === G && this.forward();
|
|
2651
2643
|
});
|
|
2652
2644
|
/**
|
|
2653
2645
|
* Underlying navigator change event listener.
|
|
@@ -2672,11 +2664,11 @@ class $t {
|
|
|
2672
2664
|
* Removes event listener.
|
|
2673
2665
|
*/
|
|
2674
2666
|
c(this, "off", this.ee.off.bind(this.ee));
|
|
2675
|
-
this.navigator = new
|
|
2667
|
+
this.navigator = new Qe(
|
|
2676
2668
|
t.map((o) => W(o, "/")),
|
|
2677
2669
|
s,
|
|
2678
2670
|
n
|
|
2679
|
-
), this.navigator.on("change", this.onNavigatorChange), this.hashMode = r, this.base =
|
|
2671
|
+
), this.navigator.on("change", this.onNavigatorChange), this.hashMode = r, this.base = $t(i || "");
|
|
2680
2672
|
}
|
|
2681
2673
|
/**
|
|
2682
2674
|
* Attaches current navigator to the browser history allowing navigator to manipulate it.
|
|
@@ -2824,8 +2816,8 @@ class $t {
|
|
|
2824
2816
|
* @param value - path presented as string or URLLike.
|
|
2825
2817
|
*/
|
|
2826
2818
|
renderPath(t) {
|
|
2827
|
-
const s = (this.base.length === 1 ? "" : this.base) +
|
|
2828
|
-
return this.hashMode ?
|
|
2819
|
+
const s = (this.base.length === 1 ? "" : this.base) + T(N(t), "/");
|
|
2820
|
+
return this.hashMode ? T(s.slice(1), this.hashMode === "default" ? "#" : "#/") : s;
|
|
2829
2821
|
}
|
|
2830
2822
|
/**
|
|
2831
2823
|
* Synchronizes current navigator state with browser history.
|
|
@@ -2833,7 +2825,7 @@ class $t {
|
|
|
2833
2825
|
async syncHistory() {
|
|
2834
2826
|
window.removeEventListener("popstate", this.onPopState);
|
|
2835
2827
|
const { state: t } = this, s = this.renderPath(this);
|
|
2836
|
-
await
|
|
2828
|
+
await Ye(), this.hasPrev && this.hasNext ? (window.history.replaceState(H, ""), window.history.pushState(t, "", s), window.history.pushState(G, ""), await R(-1)) : this.hasPrev ? (window.history.replaceState(H, ""), window.history.pushState(t, "", s)) : this.hasNext ? (window.history.replaceState(t, s), window.history.pushState(G, ""), await R(-1)) : (window.history.replaceState(ot, ""), window.history.pushState(t, "", s)), window.addEventListener("popstate", this.onPopState);
|
|
2837
2829
|
}
|
|
2838
2830
|
/**
|
|
2839
2831
|
* Current query parameters.
|
|
@@ -2851,148 +2843,148 @@ class $t {
|
|
|
2851
2843
|
return (this.navigator.current.params || {}).state;
|
|
2852
2844
|
}
|
|
2853
2845
|
}
|
|
2854
|
-
function
|
|
2846
|
+
function Ze(e) {
|
|
2855
2847
|
e || (e = {});
|
|
2856
2848
|
const { href: t, hash: s } = window.location;
|
|
2857
2849
|
let n = N(
|
|
2858
2850
|
e.hashMode ? s.includes("?") ? s.slice(1) : `?${s.slice(1)}` : t
|
|
2859
2851
|
);
|
|
2860
|
-
const r = e.base ?
|
|
2852
|
+
const r = e.base ? $t(e.base) : void 0;
|
|
2861
2853
|
if (r) {
|
|
2862
2854
|
if (!n.startsWith(r))
|
|
2863
|
-
throw
|
|
2855
|
+
throw f(
|
|
2864
2856
|
Zt,
|
|
2865
2857
|
`Path "${n}" expected to be starting with "${r}"`
|
|
2866
2858
|
);
|
|
2867
2859
|
n = n.slice(r.length);
|
|
2868
2860
|
}
|
|
2869
|
-
return new
|
|
2861
|
+
return new Mt([n], 0, e);
|
|
2870
2862
|
}
|
|
2871
|
-
function
|
|
2863
|
+
function Rs(e) {
|
|
2872
2864
|
const t = e.match(/#(.+)/);
|
|
2873
2865
|
return t ? t[1] : null;
|
|
2874
2866
|
}
|
|
2875
|
-
function
|
|
2876
|
-
if (
|
|
2867
|
+
function Xe(e, t) {
|
|
2868
|
+
if (It()) {
|
|
2877
2869
|
const s = sessionStorage.getItem(e);
|
|
2878
2870
|
if (s)
|
|
2879
2871
|
try {
|
|
2880
2872
|
const { index: n, history: r } = JSON.parse(s);
|
|
2881
|
-
return new
|
|
2873
|
+
return new Mt(r, n, t);
|
|
2882
2874
|
} catch (n) {
|
|
2883
2875
|
console.error("Unable to restore hash navigator state.", n);
|
|
2884
2876
|
}
|
|
2885
2877
|
}
|
|
2886
|
-
return
|
|
2878
|
+
return Ze(t);
|
|
2887
2879
|
}
|
|
2888
2880
|
function As(e, t) {
|
|
2889
|
-
const s =
|
|
2881
|
+
const s = Xe(e, t), n = () => sessionStorage.setItem(e, JSON.stringify({
|
|
2890
2882
|
index: s.index,
|
|
2891
2883
|
history: s.history
|
|
2892
2884
|
}));
|
|
2893
2885
|
return s.on("change", n), n(), s;
|
|
2894
2886
|
}
|
|
2895
2887
|
export {
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2888
|
+
_e as BackButton,
|
|
2889
|
+
Qe as BasicNavigator,
|
|
2890
|
+
rt as BiometryManager,
|
|
2891
|
+
Mt as BrowserNavigator,
|
|
2900
2892
|
Ae as ClosingBehavior,
|
|
2901
|
-
|
|
2893
|
+
ke as CloudStorage,
|
|
2902
2894
|
Zt as ERR_INVALID_PATH_BASE,
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
Yt as ERR_SSR_POST_EVENT,
|
|
2895
|
+
Ft as ERR_INVOKE_CUSTOM_METHOD_RESPONSE,
|
|
2896
|
+
Gt as ERR_METHOD_PARAMETER_UNSUPPORTED,
|
|
2897
|
+
Ht as ERR_METHOD_UNSUPPORTED,
|
|
2898
|
+
Qt as ERR_NAVIGATION_HISTORY_EMPTY,
|
|
2899
|
+
Yt as ERR_NAVIGATION_INDEX_INVALID,
|
|
2900
|
+
es as ERR_NAVIGATION_ITEM_INVALID,
|
|
2901
|
+
ht as ERR_PARSE,
|
|
2902
|
+
pt as ERR_SSR_INIT,
|
|
2912
2903
|
zt as ERR_TIMED_OUT,
|
|
2913
|
-
|
|
2914
|
-
|
|
2904
|
+
Jt as ERR_UNEXPECTED_TYPE,
|
|
2905
|
+
jt as ERR_UNKNOWN_ENV,
|
|
2915
2906
|
V as EventEmitter,
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2907
|
+
Ne as HapticFeedback,
|
|
2908
|
+
De as InitData,
|
|
2909
|
+
Ve as Invoice,
|
|
2910
|
+
$e as MainButton,
|
|
2911
|
+
Be as MiniApp,
|
|
2912
|
+
Ue as Popup,
|
|
2913
|
+
We as QRScanner,
|
|
2923
2914
|
$ as SDKError,
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
2915
|
+
He as SettingsButton,
|
|
2916
|
+
Ge as ThemeParams,
|
|
2917
|
+
je as Utils,
|
|
2918
|
+
Vt as Viewport,
|
|
2919
|
+
qe as array,
|
|
2920
|
+
vs as bindMiniAppCSSVars,
|
|
2921
|
+
Es as bindThemeParamsCSSVars,
|
|
2922
|
+
Ps as bindViewportCSSVars,
|
|
2932
2923
|
w as boolean,
|
|
2933
|
-
|
|
2934
|
-
|
|
2924
|
+
gt as captureSameReq,
|
|
2925
|
+
z as classNames,
|
|
2935
2926
|
ce as compareVersions,
|
|
2936
|
-
|
|
2937
|
-
|
|
2927
|
+
Ze as createBrowserNavigatorFromLocation,
|
|
2928
|
+
le as createPostEvent,
|
|
2938
2929
|
k as createSafeURL,
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2930
|
+
vt as date,
|
|
2931
|
+
Rs as getHash,
|
|
2932
|
+
$t as getPathname,
|
|
2933
|
+
rs as initBackButton,
|
|
2934
|
+
is as initBiometryManager,
|
|
2935
|
+
os as initClosingBehavior,
|
|
2936
|
+
as as initCloudStorage,
|
|
2937
|
+
cs as initHapticFeedback,
|
|
2938
|
+
hs as initInitData,
|
|
2939
|
+
us as initInvoice,
|
|
2940
|
+
ls as initMainButton,
|
|
2941
|
+
ds as initMiniApp,
|
|
2951
2942
|
As as initNavigator,
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2943
|
+
_s as initPopup,
|
|
2944
|
+
fs as initQRScanner,
|
|
2945
|
+
gs as initSettingsButton,
|
|
2946
|
+
bs as initThemeParams,
|
|
2947
|
+
ms as initUtils,
|
|
2948
|
+
ys as initViewport,
|
|
2958
2949
|
xs as initWeb,
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2950
|
+
C as invokeCustomMethod,
|
|
2951
|
+
mt as isColorDark,
|
|
2952
|
+
pe as isIframe,
|
|
2953
|
+
It as isPageReload,
|
|
2954
|
+
Q as isRGB,
|
|
2964
2955
|
Xt as isRGBShort,
|
|
2965
|
-
|
|
2956
|
+
Je as isSDKError,
|
|
2966
2957
|
Cs as isSDKErrorOfType,
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
2958
|
+
y as isSSR,
|
|
2959
|
+
Ss as isTMA,
|
|
2960
|
+
d as json,
|
|
2961
|
+
ns as mergeClassNames,
|
|
2962
|
+
v as number,
|
|
2971
2963
|
B as off,
|
|
2972
2964
|
b as on,
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2965
|
+
ps as parseInitData,
|
|
2966
|
+
xt as parseLaunchParams,
|
|
2967
|
+
Nt as parseThemeParams,
|
|
2968
|
+
A as postEvent,
|
|
2969
|
+
_ as request,
|
|
2970
|
+
Re as requestBiometryInfo,
|
|
2971
|
+
ws as requestThemeParams,
|
|
2972
|
+
Dt as requestViewport,
|
|
2981
2973
|
xe as retrieveLaunchParams,
|
|
2982
2974
|
dt as rgb,
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
|
|
2975
|
+
X as searchParams,
|
|
2976
|
+
Ee as serializeLaunchParams,
|
|
2977
|
+
ve as serializeThemeParams,
|
|
2986
2978
|
m as setCSSVar,
|
|
2987
|
-
|
|
2988
|
-
|
|
2979
|
+
ts as setDebug,
|
|
2980
|
+
ss as setTargetOrigin,
|
|
2989
2981
|
h as string,
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
2982
|
+
Ot as subscribe,
|
|
2983
|
+
E as supports,
|
|
2984
|
+
ue as targetOrigin,
|
|
2993
2985
|
lt as toRGB,
|
|
2994
|
-
|
|
2986
|
+
ct as unsubscribe,
|
|
2995
2987
|
N as urlToPath,
|
|
2996
|
-
|
|
2988
|
+
wt as withTimeout
|
|
2997
2989
|
};
|
|
2998
2990
|
//# sourceMappingURL=index.js.map
|