@tma.js/sdk-solid 2.1.0 → 2.1.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.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +437 -445
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { createComponent as
|
|
2
|
-
var
|
|
3
|
-
function
|
|
1
|
+
import { createComponent as ft, mergeProps as ct, createContext as Ft, useContext as Yt, createEffect as ht, onCleanup as Zt, createResource as Xt, createMemo as pt, from as te } from "solid-js";
|
|
2
|
+
var ee = Object.defineProperty, se = (e, t, s) => t in e ? ee(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s, c = (e, t, s) => (se(e, typeof t != "symbol" ? t + "" : t, s), s);
|
|
3
|
+
function mt(e, t) {
|
|
4
4
|
let s;
|
|
5
5
|
const n = () => {
|
|
6
6
|
s !== void 0 && t && t(s), s = void 0;
|
|
7
7
|
};
|
|
8
8
|
return [() => s === void 0 ? s = e(n) : s, n];
|
|
9
9
|
}
|
|
10
|
-
function
|
|
10
|
+
function wt(e) {
|
|
11
11
|
const t = W(), { count: s } = t;
|
|
12
|
-
t.unsubscribe(e), s && !t.count &&
|
|
12
|
+
t.unsubscribe(e), s && !t.count && Ce();
|
|
13
13
|
}
|
|
14
|
-
function
|
|
15
|
-
return W().subscribe(e), () =>
|
|
14
|
+
function ne(e) {
|
|
15
|
+
return W().subscribe(e), () => wt(e);
|
|
16
16
|
}
|
|
17
|
-
class
|
|
17
|
+
class re {
|
|
18
18
|
constructor(t, s = {}) {
|
|
19
19
|
this.scope = t, this.options = s;
|
|
20
20
|
}
|
|
@@ -54,18 +54,18 @@ class ne {
|
|
|
54
54
|
this.print("log", ...t);
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
-
const $ = new
|
|
57
|
+
const $ = new re("SDK", {
|
|
58
58
|
bgColor: "forestgreen",
|
|
59
59
|
textColor: "white"
|
|
60
60
|
});
|
|
61
61
|
let Y = !1;
|
|
62
|
-
const
|
|
62
|
+
const ut = ({ event: e, args: [t] }) => {
|
|
63
63
|
$.log("Event received:", t === void 0 ? { name: e } : { name: e, data: t });
|
|
64
64
|
};
|
|
65
|
-
function
|
|
66
|
-
Y !== e && (Y = e, e ?
|
|
65
|
+
function ie(e) {
|
|
66
|
+
Y !== e && (Y = e, e ? ne(ut) : wt(ut));
|
|
67
67
|
}
|
|
68
|
-
function
|
|
68
|
+
function oe(...e) {
|
|
69
69
|
Y && $.log(...e);
|
|
70
70
|
}
|
|
71
71
|
class L {
|
|
@@ -146,12 +146,12 @@ class U extends Error {
|
|
|
146
146
|
super(s, { cause: n }), this.type = t, Object.setPrototypeOf(this, U.prototype);
|
|
147
147
|
}
|
|
148
148
|
}
|
|
149
|
-
function
|
|
149
|
+
function m(e, t, s) {
|
|
150
150
|
return new U(e, t, s);
|
|
151
151
|
}
|
|
152
|
-
const
|
|
153
|
-
function
|
|
154
|
-
return
|
|
152
|
+
const ae = "ERR_METHOD_UNSUPPORTED", ce = "ERR_METHOD_PARAMETER_UNSUPPORTED", he = "ERR_UNKNOWN_ENV", pe = "ERR_INVOKE_CUSTOM_METHOD_RESPONSE", ue = "ERR_TIMED_OUT", de = "ERR_UNEXPECTED_TYPE", bt = "ERR_PARSE", le = "ERR_NAVIGATION_LIST_EMPTY", _e = "ERR_NAVIGATION_CURSOR_INVALID", Qs = "ERR_NAVIGATION_ITEM_INVALID", vt = "ERR_SSR_INIT", ge = "ERR_INVALID_PATH_BASE";
|
|
153
|
+
function S() {
|
|
154
|
+
return m(de, "Value has unexpected type");
|
|
155
155
|
}
|
|
156
156
|
class H {
|
|
157
157
|
constructor(t, s, n) {
|
|
@@ -168,8 +168,8 @@ class H {
|
|
|
168
168
|
try {
|
|
169
169
|
return this.parser(t);
|
|
170
170
|
} catch (s) {
|
|
171
|
-
throw
|
|
172
|
-
|
|
171
|
+
throw m(
|
|
172
|
+
bt,
|
|
173
173
|
`Unable to parse value${this.type ? ` as ${this.type}` : ""}`,
|
|
174
174
|
s
|
|
175
175
|
);
|
|
@@ -190,7 +190,7 @@ const v = R((e) => {
|
|
|
190
190
|
return !0;
|
|
191
191
|
if (t === "0" || t === "false")
|
|
192
192
|
return !1;
|
|
193
|
-
throw
|
|
193
|
+
throw S();
|
|
194
194
|
}, "boolean");
|
|
195
195
|
function yt(e, t) {
|
|
196
196
|
const s = {};
|
|
@@ -209,24 +209,24 @@ function yt(e, t) {
|
|
|
209
209
|
const a = o(t(i));
|
|
210
210
|
a !== void 0 && (s[n] = a);
|
|
211
211
|
} catch (a) {
|
|
212
|
-
throw
|
|
212
|
+
throw m(bt, `Unable to parse field "${n}"`, a);
|
|
213
213
|
}
|
|
214
214
|
}
|
|
215
215
|
return s;
|
|
216
216
|
}
|
|
217
|
-
function
|
|
217
|
+
function tt(e) {
|
|
218
218
|
let t = e;
|
|
219
219
|
if (typeof t == "string" && (t = JSON.parse(t)), typeof t != "object" || t === null || Array.isArray(t))
|
|
220
|
-
throw
|
|
220
|
+
throw S();
|
|
221
221
|
return t;
|
|
222
222
|
}
|
|
223
|
-
function
|
|
223
|
+
function g(e, t) {
|
|
224
224
|
return new H((s) => {
|
|
225
|
-
const n =
|
|
225
|
+
const n = tt(s);
|
|
226
226
|
return yt(e, (r) => n[r]);
|
|
227
227
|
}, !1, t);
|
|
228
228
|
}
|
|
229
|
-
const
|
|
229
|
+
const P = R((e) => {
|
|
230
230
|
if (typeof e == "number")
|
|
231
231
|
return e;
|
|
232
232
|
if (typeof e == "string") {
|
|
@@ -234,9 +234,9 @@ const E = R((e) => {
|
|
|
234
234
|
if (!Number.isNaN(t))
|
|
235
235
|
return t;
|
|
236
236
|
}
|
|
237
|
-
throw
|
|
237
|
+
throw S();
|
|
238
238
|
}, "number");
|
|
239
|
-
function
|
|
239
|
+
function et(e) {
|
|
240
240
|
return /^#[\da-f]{6}$/i.test(e);
|
|
241
241
|
}
|
|
242
242
|
function fe(e) {
|
|
@@ -244,7 +244,7 @@ function fe(e) {
|
|
|
244
244
|
}
|
|
245
245
|
function Et(e) {
|
|
246
246
|
const t = e.replace(/\s/g, "").toLowerCase();
|
|
247
|
-
if (
|
|
247
|
+
if (et(t))
|
|
248
248
|
return t;
|
|
249
249
|
if (fe(t)) {
|
|
250
250
|
let n = "#";
|
|
@@ -263,10 +263,10 @@ function Et(e) {
|
|
|
263
263
|
const p = R((e) => {
|
|
264
264
|
if (typeof e == "string" || typeof e == "number")
|
|
265
265
|
return e.toString();
|
|
266
|
-
throw
|
|
266
|
+
throw S();
|
|
267
267
|
}, "string"), Pt = R((e) => Et(p().parse(e)), "rgb");
|
|
268
268
|
function me(e) {
|
|
269
|
-
return
|
|
269
|
+
return g({
|
|
270
270
|
eventType: p(),
|
|
271
271
|
eventData: (t) => t
|
|
272
272
|
}).parse(e);
|
|
@@ -302,44 +302,44 @@ function ve() {
|
|
|
302
302
|
});
|
|
303
303
|
});
|
|
304
304
|
}
|
|
305
|
-
const ye =
|
|
305
|
+
const ye = g({
|
|
306
306
|
button_id: (e) => e == null ? void 0 : p().parse(e)
|
|
307
307
|
}), Ee = {
|
|
308
|
-
clipboard_text_received:
|
|
308
|
+
clipboard_text_received: g({
|
|
309
309
|
req_id: p(),
|
|
310
310
|
data: (e) => e === null ? e : p().optional().parse(e)
|
|
311
311
|
}),
|
|
312
|
-
custom_method_invoked:
|
|
312
|
+
custom_method_invoked: g({
|
|
313
313
|
req_id: p(),
|
|
314
314
|
result: (e) => e,
|
|
315
315
|
error: p().optional()
|
|
316
316
|
}),
|
|
317
|
-
invoice_closed:
|
|
317
|
+
invoice_closed: g({
|
|
318
318
|
slug: p(),
|
|
319
319
|
status: p()
|
|
320
320
|
}),
|
|
321
|
-
phone_requested:
|
|
321
|
+
phone_requested: g({
|
|
322
322
|
status: p()
|
|
323
323
|
}),
|
|
324
324
|
popup_closed: {
|
|
325
325
|
parse: (e) => ye.parse(e ?? {})
|
|
326
326
|
},
|
|
327
|
-
qr_text_received:
|
|
327
|
+
qr_text_received: g({
|
|
328
328
|
data: p().optional()
|
|
329
329
|
}),
|
|
330
|
-
theme_changed:
|
|
330
|
+
theme_changed: g({
|
|
331
331
|
theme_params: (e) => {
|
|
332
332
|
const t = Pt().optional();
|
|
333
|
-
return Object.entries(
|
|
333
|
+
return Object.entries(tt(e)).reduce((s, [n, r]) => (s[n] = t.parse(r), s), {});
|
|
334
334
|
}
|
|
335
335
|
}),
|
|
336
|
-
viewport_changed:
|
|
337
|
-
height:
|
|
338
|
-
width: (e) => e == null ? window.innerWidth :
|
|
336
|
+
viewport_changed: g({
|
|
337
|
+
height: P(),
|
|
338
|
+
width: (e) => e == null ? window.innerWidth : P().parse(e),
|
|
339
339
|
is_state_stable: v(),
|
|
340
340
|
is_expanded: v()
|
|
341
341
|
}),
|
|
342
|
-
write_access_requested:
|
|
342
|
+
write_access_requested: g({
|
|
343
343
|
status: p()
|
|
344
344
|
})
|
|
345
345
|
};
|
|
@@ -392,7 +392,7 @@ function Pe() {
|
|
|
392
392
|
t.forEach((s) => s()), t = [];
|
|
393
393
|
}];
|
|
394
394
|
}
|
|
395
|
-
const [xe,
|
|
395
|
+
const [xe, Ce] = mt(
|
|
396
396
|
(e) => {
|
|
397
397
|
const [t, s] = Pe(), n = t.off.bind(t);
|
|
398
398
|
return t.off = (r, i) => {
|
|
@@ -414,7 +414,7 @@ function b(e, t, s) {
|
|
|
414
414
|
function q(e) {
|
|
415
415
|
return typeof e == "object" && e !== null && !Array.isArray(e);
|
|
416
416
|
}
|
|
417
|
-
function
|
|
417
|
+
function Se(e, t) {
|
|
418
418
|
const s = e.split("."), n = t.split("."), r = Math.max(s.length, n.length);
|
|
419
419
|
for (let i = 0; i < r; i += 1) {
|
|
420
420
|
const o = parseInt(s[i] || "0", 10), a = parseInt(n[i] || "0", 10);
|
|
@@ -424,9 +424,9 @@ function Ce(e, t) {
|
|
|
424
424
|
return 0;
|
|
425
425
|
}
|
|
426
426
|
function w(e, t) {
|
|
427
|
-
return
|
|
427
|
+
return Se(e, t) <= 0;
|
|
428
428
|
}
|
|
429
|
-
function
|
|
429
|
+
function C(e, t, s) {
|
|
430
430
|
if (typeof s == "string") {
|
|
431
431
|
if (e === "web_app_open_link" && t === "try_instant_view")
|
|
432
432
|
return w("6.4", s);
|
|
@@ -480,10 +480,10 @@ function x(e, t, s) {
|
|
|
480
480
|
function Re(e) {
|
|
481
481
|
return "external" in e && q(e.external) && "notify" in e.external && typeof e.external.notify == "function";
|
|
482
482
|
}
|
|
483
|
-
function
|
|
483
|
+
function xt(e) {
|
|
484
484
|
return "TelegramWebviewProxy" in e && q(e.TelegramWebviewProxy) && "postEvent" in e.TelegramWebviewProxy && typeof e.TelegramWebviewProxy.postEvent == "function";
|
|
485
485
|
}
|
|
486
|
-
function
|
|
486
|
+
function Ct() {
|
|
487
487
|
try {
|
|
488
488
|
return window.self !== window.top;
|
|
489
489
|
} catch {
|
|
@@ -491,7 +491,7 @@ function xt() {
|
|
|
491
491
|
}
|
|
492
492
|
}
|
|
493
493
|
let St = "https://web.telegram.org";
|
|
494
|
-
function
|
|
494
|
+
function Fs(e) {
|
|
495
495
|
St = e;
|
|
496
496
|
}
|
|
497
497
|
function Ae() {
|
|
@@ -501,7 +501,7 @@ function k(e, t, s) {
|
|
|
501
501
|
let n = {}, r;
|
|
502
502
|
t === void 0 && s === void 0 ? n = {} : t !== void 0 && s !== void 0 ? (n = s, r = t) : t !== void 0 && ("targetOrigin" in t ? n = t : r = t);
|
|
503
503
|
const { targetOrigin: i = Ae() } = n;
|
|
504
|
-
if (
|
|
504
|
+
if (oe("Posting event:", r ? { event: e, data: r } : { event: e }), Ct()) {
|
|
505
505
|
window.parent.postMessage(JSON.stringify({ eventType: e, eventData: r }), i);
|
|
506
506
|
return;
|
|
507
507
|
}
|
|
@@ -509,47 +509,47 @@ function k(e, t, s) {
|
|
|
509
509
|
window.external.notify(JSON.stringify({ eventType: e, eventData: r }));
|
|
510
510
|
return;
|
|
511
511
|
}
|
|
512
|
-
if (
|
|
512
|
+
if (xt(window)) {
|
|
513
513
|
window.TelegramWebviewProxy.postEvent(e, JSON.stringify(r));
|
|
514
514
|
return;
|
|
515
515
|
}
|
|
516
|
-
throw
|
|
517
|
-
|
|
516
|
+
throw m(
|
|
517
|
+
he,
|
|
518
518
|
"Unable to determine current environment and possible way to send event. You are probably trying to use Mini Apps method outside of Telegram application environment."
|
|
519
519
|
);
|
|
520
520
|
}
|
|
521
|
-
function
|
|
521
|
+
function Te(e) {
|
|
522
522
|
return (t, s) => {
|
|
523
|
-
if (!
|
|
524
|
-
throw
|
|
523
|
+
if (!C(t, e))
|
|
524
|
+
throw m(ae, `Method "${t}" is unsupported in Mini Apps version ${e}`);
|
|
525
525
|
if (q(s)) {
|
|
526
526
|
let n;
|
|
527
|
-
if (t === "web_app_open_link" && "try_instant_view" in s ? n = "try_instant_view" : t === "web_app_set_header_color" && "color" in s && (n = "color"), n && !
|
|
528
|
-
throw
|
|
529
|
-
|
|
527
|
+
if (t === "web_app_open_link" && "try_instant_view" in s ? n = "try_instant_view" : t === "web_app_set_header_color" && "color" in s && (n = "color"), n && !C(t, n, e))
|
|
528
|
+
throw m(
|
|
529
|
+
ce,
|
|
530
530
|
`Parameter "${n}" of "${t}" method is unsupported in Mini Apps version ${e}`
|
|
531
531
|
);
|
|
532
532
|
}
|
|
533
533
|
return k(t, s);
|
|
534
534
|
};
|
|
535
535
|
}
|
|
536
|
-
function
|
|
536
|
+
function Rt(e) {
|
|
537
537
|
return ({ req_id: t }) => t === e;
|
|
538
538
|
}
|
|
539
|
-
function
|
|
540
|
-
return
|
|
539
|
+
function At(e) {
|
|
540
|
+
return m(ue, `Timeout reached: ${e}ms`);
|
|
541
541
|
}
|
|
542
542
|
function Tt(e, t) {
|
|
543
543
|
return Promise.race([
|
|
544
544
|
typeof e == "function" ? e() : e,
|
|
545
545
|
new Promise((s, n) => {
|
|
546
546
|
setTimeout(() => {
|
|
547
|
-
n(
|
|
547
|
+
n(At(t));
|
|
548
548
|
}, t);
|
|
549
549
|
})
|
|
550
550
|
]);
|
|
551
551
|
}
|
|
552
|
-
async function
|
|
552
|
+
async function f(e) {
|
|
553
553
|
let t;
|
|
554
554
|
const s = new Promise((u) => {
|
|
555
555
|
t = u;
|
|
@@ -560,7 +560,7 @@ async function m(e) {
|
|
|
560
560
|
postEvent: o = k,
|
|
561
561
|
timeout: a
|
|
562
562
|
} = e, h = (Array.isArray(r) ? r : [r]).map(
|
|
563
|
-
(u) => b(u, (
|
|
563
|
+
(u) => b(u, (N) => (!i || i(N)) && t(N))
|
|
564
564
|
);
|
|
565
565
|
try {
|
|
566
566
|
return o(n, e.params), await (a ? Tt(s, a) : s);
|
|
@@ -568,11 +568,11 @@ async function m(e) {
|
|
|
568
568
|
h.forEach((u) => u());
|
|
569
569
|
}
|
|
570
570
|
}
|
|
571
|
-
async function
|
|
571
|
+
async function T(e, t, s, n = {}) {
|
|
572
572
|
const {
|
|
573
573
|
result: r,
|
|
574
574
|
error: i
|
|
575
|
-
} = await
|
|
575
|
+
} = await f({
|
|
576
576
|
...n,
|
|
577
577
|
method: "web_app_invoke_custom_method",
|
|
578
578
|
event: "custom_method_invoked",
|
|
@@ -581,10 +581,10 @@ async function A(e, t, s, n = {}) {
|
|
|
581
581
|
params: t,
|
|
582
582
|
req_id: s
|
|
583
583
|
},
|
|
584
|
-
capture:
|
|
584
|
+
capture: Rt(s)
|
|
585
585
|
});
|
|
586
586
|
if (i)
|
|
587
|
-
throw
|
|
587
|
+
throw m(pe, i);
|
|
588
588
|
return r;
|
|
589
589
|
}
|
|
590
590
|
function X(...e) {
|
|
@@ -597,13 +597,13 @@ function X(...e) {
|
|
|
597
597
|
return X(...t);
|
|
598
598
|
}).filter(Boolean).join(" ");
|
|
599
599
|
}
|
|
600
|
-
function
|
|
600
|
+
function Ys(...e) {
|
|
601
601
|
return e.reduce((t, s) => (q(s) && Object.entries(s).forEach(([n, r]) => {
|
|
602
602
|
const i = X(t[n], r);
|
|
603
603
|
i.length && (t[n] = i);
|
|
604
604
|
}), t), {});
|
|
605
605
|
}
|
|
606
|
-
function
|
|
606
|
+
function It(e) {
|
|
607
607
|
const t = Et(e);
|
|
608
608
|
return Math.sqrt(
|
|
609
609
|
[0.299, 0.587, 0.114].reduce((s, n, r) => {
|
|
@@ -612,7 +612,7 @@ function At(e) {
|
|
|
612
612
|
}, 0)
|
|
613
613
|
) < 120;
|
|
614
614
|
}
|
|
615
|
-
class
|
|
615
|
+
class Ie {
|
|
616
616
|
constructor(t) {
|
|
617
617
|
c(this, "ee", new L()), c(this, "on", this.ee.on.bind(this.ee)), c(this, "off", this.ee.off.bind(this.ee)), this.state = t;
|
|
618
618
|
}
|
|
@@ -633,20 +633,20 @@ class ke {
|
|
|
633
633
|
return this.state[t];
|
|
634
634
|
}
|
|
635
635
|
}
|
|
636
|
-
class
|
|
636
|
+
class st {
|
|
637
637
|
constructor(t) {
|
|
638
|
-
c(this, "state"), c(this, "get"), c(this, "set"), c(this, "clone"), this.state = new
|
|
638
|
+
c(this, "state"), c(this, "get"), c(this, "set"), c(this, "clone"), this.state = new Ie(t), this.set = this.state.set.bind(this.state), this.get = this.state.get.bind(this.state), this.clone = this.state.clone.bind(this.state);
|
|
639
639
|
}
|
|
640
640
|
}
|
|
641
|
-
function
|
|
642
|
-
return (s) =>
|
|
641
|
+
function kt(e, t) {
|
|
642
|
+
return (s) => C(t[s], e);
|
|
643
643
|
}
|
|
644
|
-
class
|
|
644
|
+
class nt extends st {
|
|
645
645
|
constructor(t, s, n) {
|
|
646
|
-
super(t), c(this, "supports"), this.supports =
|
|
646
|
+
super(t), c(this, "supports"), this.supports = kt(s, n);
|
|
647
647
|
}
|
|
648
648
|
}
|
|
649
|
-
class
|
|
649
|
+
class ke extends nt {
|
|
650
650
|
constructor(t, s, n) {
|
|
651
651
|
super({ isVisible: t }, s, {
|
|
652
652
|
show: "web_app_setup_back_button",
|
|
@@ -675,14 +675,14 @@ class Oe extends rt {
|
|
|
675
675
|
this.isVisible = !0;
|
|
676
676
|
}
|
|
677
677
|
}
|
|
678
|
-
function
|
|
678
|
+
function E() {
|
|
679
679
|
return typeof window > "u";
|
|
680
680
|
}
|
|
681
|
-
const
|
|
682
|
-
function
|
|
681
|
+
const Ot = R((e) => e instanceof Date ? e : new Date(P().parse(e) * 1e3), "Date");
|
|
682
|
+
function rt(e, t) {
|
|
683
683
|
return new H((s) => {
|
|
684
684
|
if (typeof s != "string" && !(s instanceof URLSearchParams))
|
|
685
|
-
throw
|
|
685
|
+
throw S();
|
|
686
686
|
const n = typeof s == "string" ? new URLSearchParams(s) : s;
|
|
687
687
|
return yt(e, (r) => {
|
|
688
688
|
const i = n.get(r);
|
|
@@ -690,8 +690,8 @@ function it(e, t) {
|
|
|
690
690
|
});
|
|
691
691
|
}, !1, t);
|
|
692
692
|
}
|
|
693
|
-
const
|
|
694
|
-
id:
|
|
693
|
+
const Oe = g({
|
|
694
|
+
id: P(),
|
|
695
695
|
type: p(),
|
|
696
696
|
title: p(),
|
|
697
697
|
photoUrl: {
|
|
@@ -699,7 +699,7 @@ const qe = f({
|
|
|
699
699
|
from: "photo_url"
|
|
700
700
|
},
|
|
701
701
|
username: p().optional()
|
|
702
|
-
}, "Chat").optional(),
|
|
702
|
+
}, "Chat").optional(), dt = g({
|
|
703
703
|
addedToAttachmentMenu: {
|
|
704
704
|
type: v().optional(),
|
|
705
705
|
from: "added_to_attachment_menu"
|
|
@@ -712,7 +712,7 @@ const qe = f({
|
|
|
712
712
|
type: p(),
|
|
713
713
|
from: "first_name"
|
|
714
714
|
},
|
|
715
|
-
id:
|
|
715
|
+
id: P(),
|
|
716
716
|
isBot: {
|
|
717
717
|
type: v().optional(),
|
|
718
718
|
from: "is_bot"
|
|
@@ -735,17 +735,17 @@ const qe = f({
|
|
|
735
735
|
},
|
|
736
736
|
username: p().optional()
|
|
737
737
|
}, "User").optional();
|
|
738
|
-
function
|
|
739
|
-
return
|
|
738
|
+
function qt() {
|
|
739
|
+
return rt({
|
|
740
740
|
authDate: {
|
|
741
|
-
type:
|
|
741
|
+
type: Ot(),
|
|
742
742
|
from: "auth_date"
|
|
743
743
|
},
|
|
744
744
|
canSendAfter: {
|
|
745
|
-
type:
|
|
745
|
+
type: P().optional(),
|
|
746
746
|
from: "can_send_after"
|
|
747
747
|
},
|
|
748
|
-
chat:
|
|
748
|
+
chat: Oe,
|
|
749
749
|
chatInstance: {
|
|
750
750
|
type: p().optional(),
|
|
751
751
|
from: "chat_instance"
|
|
@@ -759,35 +759,35 @@ function Ot() {
|
|
|
759
759
|
type: p().optional(),
|
|
760
760
|
from: "query_id"
|
|
761
761
|
},
|
|
762
|
-
receiver:
|
|
762
|
+
receiver: dt,
|
|
763
763
|
startParam: {
|
|
764
764
|
type: p().optional(),
|
|
765
765
|
from: "start_param"
|
|
766
766
|
},
|
|
767
|
-
user:
|
|
767
|
+
user: dt
|
|
768
768
|
}, "InitData");
|
|
769
769
|
}
|
|
770
|
-
function
|
|
770
|
+
function qe(e) {
|
|
771
771
|
return e.replace(/_[a-z]/g, (t) => t[1].toUpperCase());
|
|
772
772
|
}
|
|
773
773
|
function De(e) {
|
|
774
774
|
return e.replace(/[A-Z]/g, (t) => `_${t.toLowerCase()}`);
|
|
775
775
|
}
|
|
776
|
-
const
|
|
776
|
+
const Dt = R(
|
|
777
777
|
(e) => {
|
|
778
778
|
const t = Pt().optional();
|
|
779
|
-
return Object.entries(
|
|
779
|
+
return Object.entries(tt(e)).reduce((s, [n, r]) => (s[qe(n)] = t.parse(r), s), {});
|
|
780
780
|
},
|
|
781
781
|
"ThemeParams"
|
|
782
782
|
);
|
|
783
783
|
function Nt(e) {
|
|
784
|
-
return
|
|
784
|
+
return rt({
|
|
785
785
|
botInline: {
|
|
786
786
|
type: v().optional(),
|
|
787
787
|
from: "tgWebAppBotInline"
|
|
788
788
|
},
|
|
789
789
|
initData: {
|
|
790
|
-
type:
|
|
790
|
+
type: qt().optional(),
|
|
791
791
|
from: "tgWebAppData"
|
|
792
792
|
},
|
|
793
793
|
initDataRaw: {
|
|
@@ -807,7 +807,7 @@ function Nt(e) {
|
|
|
807
807
|
from: "tgWebAppStartParam"
|
|
808
808
|
},
|
|
809
809
|
themeParams: {
|
|
810
|
-
type:
|
|
810
|
+
type: Dt(),
|
|
811
811
|
from: "tgWebAppThemeParams"
|
|
812
812
|
},
|
|
813
813
|
version: {
|
|
@@ -816,47 +816,47 @@ function Nt(e) {
|
|
|
816
816
|
}
|
|
817
817
|
}).parse(e);
|
|
818
818
|
}
|
|
819
|
-
function
|
|
819
|
+
function Vt(e) {
|
|
820
820
|
return Nt(
|
|
821
821
|
e.replace(/^[^?#]*[?#]/, "").replace(/[?#]/g, "&")
|
|
822
822
|
);
|
|
823
823
|
}
|
|
824
|
-
function
|
|
825
|
-
return
|
|
824
|
+
function Ne() {
|
|
825
|
+
return Vt(window.location.href);
|
|
826
826
|
}
|
|
827
|
-
function
|
|
827
|
+
function Mt() {
|
|
828
828
|
return performance.getEntriesByType("navigation")[0];
|
|
829
829
|
}
|
|
830
|
-
function
|
|
831
|
-
const e =
|
|
830
|
+
function Ve() {
|
|
831
|
+
const e = Mt();
|
|
832
832
|
if (!e)
|
|
833
833
|
throw new Error("Unable to get first navigation entry.");
|
|
834
|
-
return
|
|
834
|
+
return Vt(e.name);
|
|
835
835
|
}
|
|
836
|
-
function
|
|
836
|
+
function Bt(e) {
|
|
837
837
|
return `tma.js/${e.replace(/[A-Z]/g, (t) => `-${t.toLowerCase()}`)}`;
|
|
838
838
|
}
|
|
839
|
-
function
|
|
840
|
-
sessionStorage.setItem(
|
|
839
|
+
function $t(e, t) {
|
|
840
|
+
sessionStorage.setItem(Bt(e), JSON.stringify(t));
|
|
841
841
|
}
|
|
842
|
-
function
|
|
843
|
-
const t = sessionStorage.getItem(
|
|
842
|
+
function Lt(e) {
|
|
843
|
+
const t = sessionStorage.getItem(Bt(e));
|
|
844
844
|
try {
|
|
845
845
|
return t ? JSON.parse(t) : void 0;
|
|
846
846
|
} catch {
|
|
847
847
|
}
|
|
848
848
|
}
|
|
849
|
-
function
|
|
850
|
-
return Nt(
|
|
849
|
+
function Me() {
|
|
850
|
+
return Nt(Lt("launchParams") || "");
|
|
851
851
|
}
|
|
852
|
-
function
|
|
852
|
+
function Be(e) {
|
|
853
853
|
return JSON.stringify(
|
|
854
854
|
Object.fromEntries(
|
|
855
855
|
Object.entries(e).map(([t, s]) => [De(t), s])
|
|
856
856
|
)
|
|
857
857
|
);
|
|
858
858
|
}
|
|
859
|
-
function
|
|
859
|
+
function $e(e) {
|
|
860
860
|
const {
|
|
861
861
|
initDataRaw: t,
|
|
862
862
|
themeParams: s,
|
|
@@ -866,81 +866,71 @@ function Le(e) {
|
|
|
866
866
|
startParam: o,
|
|
867
867
|
botInline: a
|
|
868
868
|
} = e, h = new URLSearchParams();
|
|
869
|
-
return h.set("tgWebAppPlatform", n), h.set("tgWebAppThemeParams",
|
|
869
|
+
return h.set("tgWebAppPlatform", n), h.set("tgWebAppThemeParams", Be(s)), h.set("tgWebAppVersion", r), t && h.set("tgWebAppData", t), o && h.set("tgWebAppStartParam", o), typeof i == "boolean" && h.set("tgWebAppShowSettings", i ? "1" : "0"), typeof a == "boolean" && h.set("tgWebAppBotInline", a ? "1" : "0"), h.toString();
|
|
870
870
|
}
|
|
871
|
-
function
|
|
872
|
-
|
|
871
|
+
function Le(e) {
|
|
872
|
+
$t("launchParams", $e(e));
|
|
873
873
|
}
|
|
874
|
-
function
|
|
874
|
+
function Ue() {
|
|
875
875
|
for (const e of [
|
|
876
876
|
// Try to retrieve launch parameters from the current location. This method can return
|
|
877
877
|
// nothing in case, location was changed and then page was reloaded.
|
|
878
|
-
|
|
878
|
+
Ne,
|
|
879
879
|
// Then, try using the lower level API - window.performance.
|
|
880
|
-
|
|
880
|
+
Ve,
|
|
881
881
|
// Finally, try to extract launch parameters from the session storage.
|
|
882
|
-
|
|
882
|
+
Me
|
|
883
883
|
])
|
|
884
884
|
try {
|
|
885
885
|
const t = e();
|
|
886
|
-
return
|
|
886
|
+
return Le(t), t;
|
|
887
887
|
} catch {
|
|
888
888
|
}
|
|
889
889
|
throw new Error("Unable to retrieve launch parameters from any known source.");
|
|
890
890
|
}
|
|
891
|
-
function
|
|
892
|
-
const e =
|
|
891
|
+
function Ut() {
|
|
892
|
+
const e = Mt();
|
|
893
893
|
return !!(e && e.type === "reload");
|
|
894
894
|
}
|
|
895
|
-
function
|
|
895
|
+
function He() {
|
|
896
896
|
let e = 0;
|
|
897
897
|
return () => (e += 1).toString();
|
|
898
898
|
}
|
|
899
|
-
const [
|
|
900
|
-
function
|
|
899
|
+
const [We] = mt(He);
|
|
900
|
+
function d(e, t) {
|
|
901
901
|
return ({ ssr: s } = {}) => {
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
);
|
|
909
|
-
n = s;
|
|
910
|
-
} else
|
|
911
|
-
n = He();
|
|
912
|
-
const r = {
|
|
902
|
+
const n = E() ? {
|
|
903
|
+
version: "6.0",
|
|
904
|
+
themeParams: {},
|
|
905
|
+
platform: "unknown",
|
|
906
|
+
...s || {}
|
|
907
|
+
} : Ue(), r = {
|
|
913
908
|
...n,
|
|
914
|
-
postEvent:
|
|
915
|
-
|
|
916
|
-
_e,
|
|
917
|
-
"postEvent function is forbidden to be called on the server side."
|
|
918
|
-
);
|
|
919
|
-
},
|
|
920
|
-
createRequestId: je()
|
|
909
|
+
postEvent: E() ? () => null : Te(n.version),
|
|
910
|
+
createRequestId: We()
|
|
921
911
|
};
|
|
922
|
-
if (
|
|
912
|
+
if (E() || typeof e == "function")
|
|
923
913
|
return typeof e == "function" ? e(r) : t(r);
|
|
924
914
|
const i = t({
|
|
925
915
|
...r,
|
|
926
|
-
state:
|
|
916
|
+
state: Ut() ? Lt(e) : void 0
|
|
927
917
|
}), o = (a) => (a.on("change", (h) => {
|
|
928
|
-
|
|
918
|
+
$t(e, h);
|
|
929
919
|
}), a);
|
|
930
920
|
return i instanceof Promise ? i.then(o) : o(i);
|
|
931
921
|
};
|
|
932
922
|
}
|
|
933
|
-
const
|
|
923
|
+
const je = d("backButton", ({
|
|
934
924
|
postEvent: e,
|
|
935
925
|
version: t,
|
|
936
926
|
state: s = { isVisible: !1 }
|
|
937
|
-
}) => new
|
|
938
|
-
class
|
|
927
|
+
}) => new ke(s.isVisible, t, e));
|
|
928
|
+
class D extends nt {
|
|
939
929
|
constructor() {
|
|
940
930
|
super(...arguments), c(this, "on", this.state.on.bind(this.state)), c(this, "off", this.state.off.bind(this.state));
|
|
941
931
|
}
|
|
942
932
|
}
|
|
943
|
-
function
|
|
933
|
+
function Ht(e) {
|
|
944
934
|
const t = e.available ? e : {
|
|
945
935
|
available: !1,
|
|
946
936
|
device_id: "",
|
|
@@ -958,7 +948,7 @@ function Ut(e) {
|
|
|
958
948
|
accessGranted: t.access_granted
|
|
959
949
|
};
|
|
960
950
|
}
|
|
961
|
-
class
|
|
951
|
+
class lt extends D {
|
|
962
952
|
constructor({ postEvent: t, version: s, ...n }) {
|
|
963
953
|
super(n, s, {
|
|
964
954
|
auth: "web_app_biometry_request_auth",
|
|
@@ -995,7 +985,7 @@ class _t extends N {
|
|
|
995
985
|
reason: t,
|
|
996
986
|
...s
|
|
997
987
|
}) {
|
|
998
|
-
return this.authPromise || (this.authPromise =
|
|
988
|
+
return this.authPromise || (this.authPromise = f({
|
|
999
989
|
...s,
|
|
1000
990
|
method: "web_app_biometry_request_auth",
|
|
1001
991
|
event: "biometry_auth_requested",
|
|
@@ -1029,14 +1019,14 @@ class _t extends N {
|
|
|
1029
1019
|
* @returns Promise with true, if access was granted.
|
|
1030
1020
|
*/
|
|
1031
1021
|
requestAccess({ reason: t, ...s } = {}) {
|
|
1032
|
-
return this.accessPromise || (this.accessPromise =
|
|
1022
|
+
return this.accessPromise || (this.accessPromise = f({
|
|
1033
1023
|
...s,
|
|
1034
1024
|
postEvent: this.postEvent,
|
|
1035
1025
|
method: "web_app_biometry_request_access",
|
|
1036
1026
|
event: "biometry_info_received",
|
|
1037
1027
|
params: { reason: t || "" }
|
|
1038
1028
|
}).then((n) => {
|
|
1039
|
-
const r =
|
|
1029
|
+
const r = Ht(n);
|
|
1040
1030
|
return this.set(r), r.accessGranted;
|
|
1041
1031
|
}).finally(() => this.accessPromise = void 0)), this.accessPromise;
|
|
1042
1032
|
}
|
|
@@ -1058,7 +1048,7 @@ class _t extends N {
|
|
|
1058
1048
|
*/
|
|
1059
1049
|
async updateToken({ token: t, ...s } = {}) {
|
|
1060
1050
|
return ["removed", "updated"].includes(
|
|
1061
|
-
(await
|
|
1051
|
+
(await f({
|
|
1062
1052
|
...s,
|
|
1063
1053
|
postEvent: this.postEvent,
|
|
1064
1054
|
method: "web_app_biometry_update_token",
|
|
@@ -1068,35 +1058,35 @@ class _t extends N {
|
|
|
1068
1058
|
);
|
|
1069
1059
|
}
|
|
1070
1060
|
}
|
|
1071
|
-
async function
|
|
1072
|
-
return
|
|
1073
|
-
await
|
|
1061
|
+
async function Ge(e) {
|
|
1062
|
+
return Ht(
|
|
1063
|
+
await f({
|
|
1074
1064
|
...e || {},
|
|
1075
1065
|
method: "web_app_biometry_get_info",
|
|
1076
1066
|
event: "biometry_info_received"
|
|
1077
1067
|
})
|
|
1078
1068
|
);
|
|
1079
1069
|
}
|
|
1080
|
-
const
|
|
1070
|
+
const ze = d("biometryManager", async ({ postEvent: e, version: t, state: s }) => {
|
|
1081
1071
|
if (s)
|
|
1082
|
-
return new
|
|
1083
|
-
if (
|
|
1084
|
-
throw
|
|
1085
|
-
|
|
1072
|
+
return new lt({ ...s, version: t, postEvent: e });
|
|
1073
|
+
if (E())
|
|
1074
|
+
throw m(
|
|
1075
|
+
vt,
|
|
1086
1076
|
"BiometryManager cannot be instantiated on the server side without passing the ssr.state object."
|
|
1087
1077
|
);
|
|
1088
|
-
return new
|
|
1089
|
-
...await
|
|
1078
|
+
return new lt({
|
|
1079
|
+
...await Ge({ timeout: 1e3 }),
|
|
1090
1080
|
version: t,
|
|
1091
1081
|
postEvent: e
|
|
1092
1082
|
});
|
|
1093
1083
|
});
|
|
1094
|
-
class
|
|
1084
|
+
class it extends st {
|
|
1095
1085
|
constructor() {
|
|
1096
1086
|
super(...arguments), c(this, "on", this.state.on.bind(this.state)), c(this, "off", this.state.off.bind(this.state));
|
|
1097
1087
|
}
|
|
1098
1088
|
}
|
|
1099
|
-
class
|
|
1089
|
+
class Ke extends it {
|
|
1100
1090
|
constructor(t, s) {
|
|
1101
1091
|
super({ isConfirmationNeeded: t }), this.postEvent = s;
|
|
1102
1092
|
}
|
|
@@ -1123,16 +1113,16 @@ class Je extends ot {
|
|
|
1123
1113
|
this.isConfirmationNeeded = !0;
|
|
1124
1114
|
}
|
|
1125
1115
|
}
|
|
1126
|
-
const
|
|
1116
|
+
const Je = d("closingBehavior", ({
|
|
1127
1117
|
postEvent: e,
|
|
1128
1118
|
state: t = { isConfirmationNeeded: !1 }
|
|
1129
|
-
}) => new
|
|
1130
|
-
class
|
|
1119
|
+
}) => new Ke(t.isConfirmationNeeded, e));
|
|
1120
|
+
class ot {
|
|
1131
1121
|
constructor(t, s) {
|
|
1132
|
-
c(this, "supports"), this.supports =
|
|
1122
|
+
c(this, "supports"), this.supports = kt(t, s);
|
|
1133
1123
|
}
|
|
1134
1124
|
}
|
|
1135
|
-
function
|
|
1125
|
+
function Qe(e) {
|
|
1136
1126
|
if (Array.isArray(e))
|
|
1137
1127
|
return e;
|
|
1138
1128
|
if (typeof e == "string")
|
|
@@ -1142,11 +1132,11 @@ function Fe(e) {
|
|
|
1142
1132
|
return t;
|
|
1143
1133
|
} catch {
|
|
1144
1134
|
}
|
|
1145
|
-
throw
|
|
1135
|
+
throw S();
|
|
1146
1136
|
}
|
|
1147
|
-
class
|
|
1137
|
+
class Fe extends H {
|
|
1148
1138
|
constructor(t, s, n) {
|
|
1149
|
-
super(
|
|
1139
|
+
super(Qe, s, n), c(this, "itemParser"), this.itemParser = typeof t == "function" ? t : t.parse.bind(t);
|
|
1150
1140
|
}
|
|
1151
1141
|
/**
|
|
1152
1142
|
* Attempts to parse passed value
|
|
@@ -1162,13 +1152,13 @@ class Ye extends H {
|
|
|
1162
1152
|
return this.itemParser = typeof t == "function" ? t : t.parse.bind(t), this;
|
|
1163
1153
|
}
|
|
1164
1154
|
}
|
|
1165
|
-
function
|
|
1166
|
-
return new
|
|
1155
|
+
function Ye(e) {
|
|
1156
|
+
return new Fe((t) => t, !1, e);
|
|
1167
1157
|
}
|
|
1168
|
-
function
|
|
1158
|
+
function _t(e, t) {
|
|
1169
1159
|
return Object.fromEntries(e.map((s) => [s, t]));
|
|
1170
1160
|
}
|
|
1171
|
-
class
|
|
1161
|
+
class Ze extends ot {
|
|
1172
1162
|
constructor(t, s, n) {
|
|
1173
1163
|
super(t, {
|
|
1174
1164
|
delete: "web_app_invoke_custom_method",
|
|
@@ -1184,7 +1174,7 @@ class Xe extends at {
|
|
|
1184
1174
|
*/
|
|
1185
1175
|
async delete(t, s = {}) {
|
|
1186
1176
|
const n = Array.isArray(t) ? t : [t];
|
|
1187
|
-
n.length && await
|
|
1177
|
+
n.length && await T(
|
|
1188
1178
|
"deleteStorageValues",
|
|
1189
1179
|
{ keys: n },
|
|
1190
1180
|
this.createRequestId(),
|
|
@@ -1196,8 +1186,8 @@ class Xe extends at {
|
|
|
1196
1186
|
* @param options - request execution options.
|
|
1197
1187
|
*/
|
|
1198
1188
|
async getKeys(t = {}) {
|
|
1199
|
-
return
|
|
1200
|
-
await
|
|
1189
|
+
return Ye().of(p()).parse(
|
|
1190
|
+
await T(
|
|
1201
1191
|
"getStorageKeys",
|
|
1202
1192
|
{},
|
|
1203
1193
|
this.createRequestId(),
|
|
@@ -1208,13 +1198,13 @@ class Xe extends at {
|
|
|
1208
1198
|
async get(t, s = {}) {
|
|
1209
1199
|
const n = Array.isArray(t) ? t : [t];
|
|
1210
1200
|
if (!n.length)
|
|
1211
|
-
return
|
|
1212
|
-
const r = await
|
|
1201
|
+
return _t(n, "");
|
|
1202
|
+
const r = await T(
|
|
1213
1203
|
"getStorageValues",
|
|
1214
1204
|
{ keys: n },
|
|
1215
1205
|
this.createRequestId(),
|
|
1216
1206
|
{ ...s, postEvent: this.postEvent }
|
|
1217
|
-
), i =
|
|
1207
|
+
), i = g(_t(n, p()), "CloudStorageData").parse(r);
|
|
1218
1208
|
return Array.isArray(t) ? i : i[t];
|
|
1219
1209
|
}
|
|
1220
1210
|
/**
|
|
@@ -1224,7 +1214,7 @@ class Xe extends at {
|
|
|
1224
1214
|
* @param options - request execution options.
|
|
1225
1215
|
*/
|
|
1226
1216
|
async set(t, s, n = {}) {
|
|
1227
|
-
await
|
|
1217
|
+
await T(
|
|
1228
1218
|
"saveStorageValue",
|
|
1229
1219
|
{ key: t, value: s },
|
|
1230
1220
|
this.createRequestId(),
|
|
@@ -1232,10 +1222,10 @@ class Xe extends at {
|
|
|
1232
1222
|
);
|
|
1233
1223
|
}
|
|
1234
1224
|
}
|
|
1235
|
-
const
|
|
1236
|
-
({ createRequestId: e, postEvent: t, version: s }) => new
|
|
1225
|
+
const Xe = d(
|
|
1226
|
+
({ createRequestId: e, postEvent: t, version: s }) => new Ze(s, e, t)
|
|
1237
1227
|
);
|
|
1238
|
-
class
|
|
1228
|
+
class ts extends ot {
|
|
1239
1229
|
constructor(t, s) {
|
|
1240
1230
|
super(t, {
|
|
1241
1231
|
impactOccurred: "web_app_trigger_haptic_feedback",
|
|
@@ -1277,10 +1267,10 @@ class es extends at {
|
|
|
1277
1267
|
this.postEvent("web_app_trigger_haptic_feedback", { type: "selection_change" });
|
|
1278
1268
|
}
|
|
1279
1269
|
}
|
|
1280
|
-
const
|
|
1281
|
-
({ version: e, postEvent: t }) => new
|
|
1270
|
+
const es = d(
|
|
1271
|
+
({ version: e, postEvent: t }) => new ts(e, t)
|
|
1282
1272
|
);
|
|
1283
|
-
class
|
|
1273
|
+
class ss {
|
|
1284
1274
|
constructor(t) {
|
|
1285
1275
|
this.initData = t;
|
|
1286
1276
|
}
|
|
@@ -1353,13 +1343,13 @@ class ns {
|
|
|
1353
1343
|
return this.initData.user;
|
|
1354
1344
|
}
|
|
1355
1345
|
}
|
|
1356
|
-
const
|
|
1357
|
-
({ initData: e }) => e ? new
|
|
1346
|
+
const ns = d(
|
|
1347
|
+
({ initData: e }) => e ? new ss(e) : void 0
|
|
1358
1348
|
);
|
|
1359
|
-
function
|
|
1360
|
-
return
|
|
1349
|
+
function Zs(e) {
|
|
1350
|
+
return qt().parse(e);
|
|
1361
1351
|
}
|
|
1362
|
-
class
|
|
1352
|
+
class rs extends D {
|
|
1363
1353
|
constructor(t, s, n) {
|
|
1364
1354
|
super({ isOpened: t }, s, { open: "web_app_open_invoice" }), this.postEvent = n;
|
|
1365
1355
|
}
|
|
@@ -1389,7 +1379,7 @@ class is extends N {
|
|
|
1389
1379
|
}
|
|
1390
1380
|
this.isOpened = !0;
|
|
1391
1381
|
try {
|
|
1392
|
-
return (await
|
|
1382
|
+
return (await f({
|
|
1393
1383
|
method: "web_app_open_invoice",
|
|
1394
1384
|
event: "invoice_closed",
|
|
1395
1385
|
params: { slug: n },
|
|
@@ -1403,10 +1393,10 @@ class is extends N {
|
|
|
1403
1393
|
}
|
|
1404
1394
|
}
|
|
1405
1395
|
}
|
|
1406
|
-
const
|
|
1407
|
-
({ version: e, postEvent: t }) => new
|
|
1396
|
+
const is = d(
|
|
1397
|
+
({ version: e, postEvent: t }) => new rs(!1, e, t)
|
|
1408
1398
|
);
|
|
1409
|
-
class
|
|
1399
|
+
class os extends st {
|
|
1410
1400
|
constructor({ postEvent: t, ...s }) {
|
|
1411
1401
|
super(s), c(this, "postEvent"), c(this, "on", (n, r) => n === "click" ? b("main_button_pressed", r) : this.state.on(n, r)), c(this, "off", (n, r) => n === "click" ? j("main_button_pressed", r) : this.state.off(n, r)), this.postEvent = t;
|
|
1412
1402
|
}
|
|
@@ -1537,7 +1527,7 @@ class as extends nt {
|
|
|
1537
1527
|
return this.set(t), this.commit(), this;
|
|
1538
1528
|
}
|
|
1539
1529
|
}
|
|
1540
|
-
const
|
|
1530
|
+
const as = d("mainButton", ({
|
|
1541
1531
|
postEvent: e,
|
|
1542
1532
|
themeParams: t,
|
|
1543
1533
|
state: s = {
|
|
@@ -1548,12 +1538,12 @@ const cs = l("mainButton", ({
|
|
|
1548
1538
|
textColor: t.buttonTextColor || "#ffffff",
|
|
1549
1539
|
backgroundColor: t.buttonColor || "#000000"
|
|
1550
1540
|
}
|
|
1551
|
-
}) => new
|
|
1552
|
-
function
|
|
1553
|
-
return
|
|
1554
|
-
contact:
|
|
1541
|
+
}) => new os({ ...s, postEvent: e }));
|
|
1542
|
+
function cs() {
|
|
1543
|
+
return rt({
|
|
1544
|
+
contact: g({
|
|
1555
1545
|
userId: {
|
|
1556
|
-
type:
|
|
1546
|
+
type: P(),
|
|
1557
1547
|
from: "user_id"
|
|
1558
1548
|
},
|
|
1559
1549
|
phoneNumber: {
|
|
@@ -1570,24 +1560,24 @@ function hs() {
|
|
|
1570
1560
|
}
|
|
1571
1561
|
}),
|
|
1572
1562
|
authDate: {
|
|
1573
|
-
type:
|
|
1563
|
+
type: Ot(),
|
|
1574
1564
|
from: "auth_date"
|
|
1575
1565
|
},
|
|
1576
1566
|
hash: p()
|
|
1577
1567
|
}, "RequestedContact");
|
|
1578
1568
|
}
|
|
1579
|
-
function
|
|
1569
|
+
function Wt(e, t) {
|
|
1580
1570
|
return (s) => {
|
|
1581
1571
|
const [n, r] = t[s];
|
|
1582
|
-
return
|
|
1572
|
+
return C(n, r, e);
|
|
1583
1573
|
};
|
|
1584
1574
|
}
|
|
1585
|
-
function
|
|
1575
|
+
function hs(e) {
|
|
1586
1576
|
return new Promise((t) => {
|
|
1587
1577
|
setTimeout(t, e);
|
|
1588
1578
|
});
|
|
1589
1579
|
}
|
|
1590
|
-
class
|
|
1580
|
+
class ps extends D {
|
|
1591
1581
|
constructor({ postEvent: t, createRequestId: s, version: n, botInline: r, ...i }) {
|
|
1592
1582
|
super(i, n, {
|
|
1593
1583
|
requestPhoneAccess: "web_app_request_phone",
|
|
@@ -1597,7 +1587,7 @@ class us extends N {
|
|
|
1597
1587
|
setBackgroundColor: "web_app_set_background_color"
|
|
1598
1588
|
}), c(this, "botInline"), c(this, "postEvent"), c(this, "createRequestId"), c(this, "requestPhoneAccessPromise"), c(this, "requestWriteAccessPromise"), c(this, "supportsParam"), this.createRequestId = s, this.postEvent = t, this.botInline = r;
|
|
1599
1589
|
const o = this.supports.bind(this);
|
|
1600
|
-
this.supports = (a) => o(a) ? a !== "switchInlineQuery" || r : !1, this.supportsParam =
|
|
1590
|
+
this.supports = (a) => o(a) ? a !== "switchInlineQuery" || r : !1, this.supportsParam = Wt(n, {
|
|
1601
1591
|
"setHeaderColor.color": ["web_app_set_header_color", "color"]
|
|
1602
1592
|
});
|
|
1603
1593
|
}
|
|
@@ -1608,8 +1598,8 @@ class us extends N {
|
|
|
1608
1598
|
async getRequestedContact({
|
|
1609
1599
|
timeout: t = 1e4
|
|
1610
1600
|
} = {}) {
|
|
1611
|
-
return
|
|
1612
|
-
await
|
|
1601
|
+
return cs().parse(
|
|
1602
|
+
await T(
|
|
1613
1603
|
"getRequestedContact",
|
|
1614
1604
|
{},
|
|
1615
1605
|
this.createRequestId(),
|
|
@@ -1648,7 +1638,7 @@ class us extends N {
|
|
|
1648
1638
|
* True if current Mini App background color is recognized as dark.
|
|
1649
1639
|
*/
|
|
1650
1640
|
get isDark() {
|
|
1651
|
-
return
|
|
1641
|
+
return It(this.bgColor);
|
|
1652
1642
|
}
|
|
1653
1643
|
/**
|
|
1654
1644
|
* Informs the Telegram app that the Mini App is ready to be displayed.
|
|
@@ -1683,9 +1673,9 @@ class us extends N {
|
|
|
1683
1673
|
return await this.getRequestedContact();
|
|
1684
1674
|
} catch {
|
|
1685
1675
|
}
|
|
1686
|
-
await
|
|
1676
|
+
await hs(n), n += 50;
|
|
1687
1677
|
}
|
|
1688
|
-
throw
|
|
1678
|
+
throw At(t);
|
|
1689
1679
|
}, t);
|
|
1690
1680
|
}
|
|
1691
1681
|
/**
|
|
@@ -1698,7 +1688,7 @@ class us extends N {
|
|
|
1698
1688
|
* @see requestContact
|
|
1699
1689
|
*/
|
|
1700
1690
|
async requestPhoneAccess(t = {}) {
|
|
1701
|
-
return this.requestPhoneAccessPromise || (this.requestPhoneAccessPromise =
|
|
1691
|
+
return this.requestPhoneAccessPromise || (this.requestPhoneAccessPromise = f({
|
|
1702
1692
|
...t,
|
|
1703
1693
|
method: "web_app_request_phone",
|
|
1704
1694
|
event: "phone_requested",
|
|
@@ -1710,7 +1700,7 @@ class us extends N {
|
|
|
1710
1700
|
* @param options - additional options.
|
|
1711
1701
|
*/
|
|
1712
1702
|
async requestWriteAccess(t = {}) {
|
|
1713
|
-
return this.requestWriteAccessPromise || (this.requestWriteAccessPromise =
|
|
1703
|
+
return this.requestWriteAccessPromise || (this.requestWriteAccessPromise = f({
|
|
1714
1704
|
...t,
|
|
1715
1705
|
method: "web_app_request_write_access",
|
|
1716
1706
|
event: "write_access_requested",
|
|
@@ -1740,7 +1730,7 @@ class us extends N {
|
|
|
1740
1730
|
* @param color - color key or RGB color.
|
|
1741
1731
|
*/
|
|
1742
1732
|
setHeaderColor(t) {
|
|
1743
|
-
this.postEvent("web_app_set_header_color",
|
|
1733
|
+
this.postEvent("web_app_set_header_color", et(t) ? { color: t } : { color_key: t }), this.set("headerColor", t);
|
|
1744
1734
|
}
|
|
1745
1735
|
/**
|
|
1746
1736
|
* Updates current Mini App background color.
|
|
@@ -1768,7 +1758,7 @@ class us extends N {
|
|
|
1768
1758
|
this.postEvent("web_app_switch_inline_query", { query: t, chat_types: s });
|
|
1769
1759
|
}
|
|
1770
1760
|
}
|
|
1771
|
-
const
|
|
1761
|
+
const us = d("miniApp", ({
|
|
1772
1762
|
themeParams: e,
|
|
1773
1763
|
botInline: t = !1,
|
|
1774
1764
|
state: s = {
|
|
@@ -1776,8 +1766,8 @@ const ds = l("miniApp", ({
|
|
|
1776
1766
|
headerColor: e.headerBgColor || "#000000"
|
|
1777
1767
|
},
|
|
1778
1768
|
...n
|
|
1779
|
-
}) => new
|
|
1780
|
-
function
|
|
1769
|
+
}) => new ps({ ...n, ...s, botInline: t }));
|
|
1770
|
+
function ds(e) {
|
|
1781
1771
|
const t = e.message.trim(), s = (e.title || "").trim(), n = e.buttons || [];
|
|
1782
1772
|
let r;
|
|
1783
1773
|
if (s.length > 64)
|
|
@@ -1801,7 +1791,7 @@ function ls(e) {
|
|
|
1801
1791
|
return { ...i, id: o };
|
|
1802
1792
|
}) : r = [{ type: "close", id: "" }], { title: s, message: t, buttons: r };
|
|
1803
1793
|
}
|
|
1804
|
-
class
|
|
1794
|
+
class ls extends D {
|
|
1805
1795
|
constructor(t, s, n) {
|
|
1806
1796
|
super({ isOpened: t }, s, { open: "web_app_open_popup" }), this.postEvent = n;
|
|
1807
1797
|
}
|
|
@@ -1830,11 +1820,11 @@ class _s extends N {
|
|
|
1830
1820
|
throw new Error("Popup is already opened.");
|
|
1831
1821
|
this.isOpened = !0;
|
|
1832
1822
|
try {
|
|
1833
|
-
const { button_id: s = null } = await
|
|
1823
|
+
const { button_id: s = null } = await f({
|
|
1834
1824
|
event: "popup_closed",
|
|
1835
1825
|
method: "web_app_open_popup",
|
|
1836
1826
|
postEvent: this.postEvent,
|
|
1837
|
-
params:
|
|
1827
|
+
params: ds(t)
|
|
1838
1828
|
});
|
|
1839
1829
|
return s;
|
|
1840
1830
|
} finally {
|
|
@@ -1842,10 +1832,10 @@ class _s extends N {
|
|
|
1842
1832
|
}
|
|
1843
1833
|
}
|
|
1844
1834
|
}
|
|
1845
|
-
const
|
|
1846
|
-
({ postEvent: e, version: t }) => new
|
|
1835
|
+
const _s = d(
|
|
1836
|
+
({ postEvent: e, version: t }) => new ls(!1, t, e)
|
|
1847
1837
|
);
|
|
1848
|
-
class
|
|
1838
|
+
class gs extends D {
|
|
1849
1839
|
constructor(t, s, n) {
|
|
1850
1840
|
super({ isOpened: t }, s, {
|
|
1851
1841
|
close: "web_app_close_scan_qr_popup",
|
|
@@ -1878,7 +1868,7 @@ class fs extends N {
|
|
|
1878
1868
|
throw new Error("QR scanner is already opened.");
|
|
1879
1869
|
this.isOpened = !0;
|
|
1880
1870
|
try {
|
|
1881
|
-
return (await
|
|
1871
|
+
return (await f({
|
|
1882
1872
|
method: "web_app_open_scan_qr_popup",
|
|
1883
1873
|
event: ["qr_text_received", "scan_qr_popup_closed"],
|
|
1884
1874
|
postEvent: this.postEvent,
|
|
@@ -1889,10 +1879,10 @@ class fs extends N {
|
|
|
1889
1879
|
}
|
|
1890
1880
|
}
|
|
1891
1881
|
}
|
|
1892
|
-
const
|
|
1893
|
-
({ version: e, postEvent: t }) => new
|
|
1882
|
+
const fs = d(
|
|
1883
|
+
({ version: e, postEvent: t }) => new gs(!1, e, t)
|
|
1894
1884
|
);
|
|
1895
|
-
class
|
|
1885
|
+
class ms extends nt {
|
|
1896
1886
|
constructor(t, s, n) {
|
|
1897
1887
|
super({ isVisible: t }, s, {
|
|
1898
1888
|
show: "web_app_setup_settings_button",
|
|
@@ -1921,15 +1911,15 @@ class ws extends rt {
|
|
|
1921
1911
|
this.isVisible = !0;
|
|
1922
1912
|
}
|
|
1923
1913
|
}
|
|
1924
|
-
const
|
|
1914
|
+
const ws = d("settingsButton", ({
|
|
1925
1915
|
version: e,
|
|
1926
1916
|
postEvent: t,
|
|
1927
1917
|
state: s = { isVisible: !1 }
|
|
1928
|
-
}) => new
|
|
1929
|
-
function
|
|
1930
|
-
return
|
|
1918
|
+
}) => new ms(s.isVisible, e, t));
|
|
1919
|
+
function jt(e) {
|
|
1920
|
+
return Dt().parse(e);
|
|
1931
1921
|
}
|
|
1932
|
-
class
|
|
1922
|
+
class bs extends it {
|
|
1933
1923
|
/**
|
|
1934
1924
|
* @since v6.10
|
|
1935
1925
|
*/
|
|
@@ -1968,7 +1958,7 @@ class vs extends ot {
|
|
|
1968
1958
|
* value is calculated according to theme bg color.
|
|
1969
1959
|
*/
|
|
1970
1960
|
get isDark() {
|
|
1971
|
-
return !this.bgColor ||
|
|
1961
|
+
return !this.bgColor || It(this.bgColor);
|
|
1972
1962
|
}
|
|
1973
1963
|
get linkColor() {
|
|
1974
1964
|
return this.get("linkColor");
|
|
@@ -1994,7 +1984,7 @@ class vs extends ot {
|
|
|
1994
1984
|
*/
|
|
1995
1985
|
listen() {
|
|
1996
1986
|
return b("theme_changed", (t) => {
|
|
1997
|
-
this.set(
|
|
1987
|
+
this.set(jt(t.theme_params));
|
|
1998
1988
|
});
|
|
1999
1989
|
}
|
|
2000
1990
|
/**
|
|
@@ -2007,20 +1997,20 @@ class vs extends ot {
|
|
|
2007
1997
|
return this.get("textColor");
|
|
2008
1998
|
}
|
|
2009
1999
|
}
|
|
2010
|
-
const
|
|
2011
|
-
const s = new
|
|
2012
|
-
return
|
|
2000
|
+
const vs = d("themeParams", ({ themeParams: e, state: t = e }) => {
|
|
2001
|
+
const s = new bs(t);
|
|
2002
|
+
return E() || s.listen(), s;
|
|
2013
2003
|
});
|
|
2014
|
-
function
|
|
2015
|
-
return
|
|
2004
|
+
function Xs(e = {}) {
|
|
2005
|
+
return f({
|
|
2016
2006
|
...e,
|
|
2017
2007
|
method: "web_app_request_theme",
|
|
2018
2008
|
event: "theme_changed"
|
|
2019
|
-
}).then(
|
|
2009
|
+
}).then(jt);
|
|
2020
2010
|
}
|
|
2021
|
-
class
|
|
2011
|
+
class ys extends ot {
|
|
2022
2012
|
constructor(t, s, n) {
|
|
2023
|
-
super(t, { readTextFromClipboard: "web_app_read_text_from_clipboard" }), c(this, "supportsParam"), this.version = t, this.createRequestId = s, this.postEvent = n, this.supportsParam =
|
|
2013
|
+
super(t, { readTextFromClipboard: "web_app_read_text_from_clipboard" }), c(this, "supportsParam"), this.version = t, this.createRequestId = s, this.postEvent = n, this.supportsParam = Wt(t, {
|
|
2024
2014
|
"openLink.tryInstantView": ["web_app_open_link", "try_instant_view"]
|
|
2025
2015
|
});
|
|
2026
2016
|
}
|
|
@@ -2035,7 +2025,7 @@ class Es extends at {
|
|
|
2035
2025
|
*/
|
|
2036
2026
|
openLink(t, s) {
|
|
2037
2027
|
const n = new URL(t, window.location.href).toString();
|
|
2038
|
-
if (!
|
|
2028
|
+
if (!C("web_app_open_link", this.version)) {
|
|
2039
2029
|
window.open(n, "_blank");
|
|
2040
2030
|
return;
|
|
2041
2031
|
}
|
|
@@ -2054,7 +2044,7 @@ class Es extends at {
|
|
|
2054
2044
|
const { hostname: s, pathname: n, search: r } = new URL(t, window.location.href);
|
|
2055
2045
|
if (s !== "t.me")
|
|
2056
2046
|
throw new Error(`URL has not allowed hostname: ${s}. Only "t.me" is allowed`);
|
|
2057
|
-
if (!
|
|
2047
|
+
if (!C("web_app_open_tg_link", this.version)) {
|
|
2058
2048
|
window.location.href = t;
|
|
2059
2049
|
return;
|
|
2060
2050
|
}
|
|
@@ -2069,41 +2059,41 @@ class Es extends at {
|
|
|
2069
2059
|
async readTextFromClipboard() {
|
|
2070
2060
|
const t = this.createRequestId(), {
|
|
2071
2061
|
data: s = null
|
|
2072
|
-
} = await
|
|
2062
|
+
} = await f({
|
|
2073
2063
|
method: "web_app_read_text_from_clipboard",
|
|
2074
2064
|
event: "clipboard_text_received",
|
|
2075
2065
|
postEvent: this.postEvent,
|
|
2076
2066
|
params: { req_id: t },
|
|
2077
|
-
capture:
|
|
2067
|
+
capture: Rt(t)
|
|
2078
2068
|
});
|
|
2079
2069
|
return s;
|
|
2080
2070
|
}
|
|
2081
2071
|
}
|
|
2082
|
-
const
|
|
2083
|
-
({ version: e, postEvent: t, createRequestId: s }) => new
|
|
2072
|
+
const Es = d(
|
|
2073
|
+
({ version: e, postEvent: t, createRequestId: s }) => new ys(e, s, t)
|
|
2084
2074
|
);
|
|
2085
|
-
async function
|
|
2075
|
+
async function Gt(e = {}) {
|
|
2086
2076
|
const {
|
|
2087
2077
|
is_expanded: t,
|
|
2088
2078
|
is_state_stable: s,
|
|
2089
2079
|
...n
|
|
2090
|
-
} = await
|
|
2080
|
+
} = await f({
|
|
2091
2081
|
...e,
|
|
2092
2082
|
method: "web_app_request_viewport",
|
|
2093
2083
|
event: "viewport_changed"
|
|
2094
2084
|
});
|
|
2095
2085
|
return { ...n, isExpanded: t, isStateStable: s };
|
|
2096
2086
|
}
|
|
2097
|
-
function
|
|
2087
|
+
function A(e) {
|
|
2098
2088
|
return e < 0 ? 0 : e;
|
|
2099
2089
|
}
|
|
2100
|
-
class
|
|
2090
|
+
class zt extends it {
|
|
2101
2091
|
constructor({ postEvent: t, stableHeight: s, height: n, width: r, isExpanded: i }) {
|
|
2102
2092
|
super({
|
|
2103
|
-
height:
|
|
2093
|
+
height: A(n),
|
|
2104
2094
|
isExpanded: i,
|
|
2105
|
-
stableHeight:
|
|
2106
|
-
width:
|
|
2095
|
+
stableHeight: A(s),
|
|
2096
|
+
width: A(r)
|
|
2107
2097
|
}), c(this, "postEvent"), this.postEvent = t;
|
|
2108
2098
|
}
|
|
2109
2099
|
/**
|
|
@@ -2112,7 +2102,7 @@ class Gt extends ot {
|
|
|
2112
2102
|
* @param options - options to request fresh data.
|
|
2113
2103
|
*/
|
|
2114
2104
|
async sync(t) {
|
|
2115
|
-
const { isStateStable: s, ...n } = await
|
|
2105
|
+
const { isStateStable: s, ...n } = await Gt(t);
|
|
2116
2106
|
this.set({
|
|
2117
2107
|
...n,
|
|
2118
2108
|
stableHeight: s ? n.height : this.get("stableHeight")
|
|
@@ -2165,11 +2155,11 @@ class Gt extends ot {
|
|
|
2165
2155
|
width: n,
|
|
2166
2156
|
is_expanded: r,
|
|
2167
2157
|
is_state_stable: i
|
|
2168
|
-
} = t, o =
|
|
2158
|
+
} = t, o = A(s);
|
|
2169
2159
|
this.set({
|
|
2170
2160
|
height: o,
|
|
2171
2161
|
isExpanded: r,
|
|
2172
|
-
width:
|
|
2162
|
+
width: A(n),
|
|
2173
2163
|
...i ? { stableHeight: o } : {}
|
|
2174
2164
|
});
|
|
2175
2165
|
});
|
|
@@ -2204,14 +2194,14 @@ class Gt extends ot {
|
|
|
2204
2194
|
return this.stableHeight === this.height;
|
|
2205
2195
|
}
|
|
2206
2196
|
}
|
|
2207
|
-
async function
|
|
2197
|
+
async function Ps(e, t = {}) {
|
|
2208
2198
|
const {
|
|
2209
2199
|
height: s,
|
|
2210
2200
|
width: n,
|
|
2211
2201
|
isExpanded: r,
|
|
2212
2202
|
isStateStable: i
|
|
2213
|
-
} = await
|
|
2214
|
-
return new
|
|
2203
|
+
} = await Gt({ ...t, postEvent: e });
|
|
2204
|
+
return new zt({
|
|
2215
2205
|
postEvent: e,
|
|
2216
2206
|
height: s,
|
|
2217
2207
|
width: n,
|
|
@@ -2219,13 +2209,13 @@ async function xs(e, t = {}) {
|
|
|
2219
2209
|
stableHeight: i ? s : 0
|
|
2220
2210
|
});
|
|
2221
2211
|
}
|
|
2222
|
-
function
|
|
2212
|
+
function xs({
|
|
2223
2213
|
state: e,
|
|
2224
2214
|
platform: t,
|
|
2225
2215
|
postEvent: s
|
|
2226
2216
|
}) {
|
|
2227
2217
|
let n = !1, r = 0, i = 0, o = 0;
|
|
2228
|
-
return e ? (n = e.isExpanded, r = e.height, i = e.width, o = e.stableHeight) : ["macos", "tdesktop", "unigram", "webk", "weba", "web"].includes(t) && (n = !0, r = window.innerHeight, i = window.innerWidth, o = window.innerHeight), new
|
|
2218
|
+
return e ? (n = e.isExpanded, r = e.height, i = e.width, o = e.stableHeight) : ["macos", "tdesktop", "unigram", "webk", "weba", "web"].includes(t) && (n = !0, r = window.innerHeight, i = window.innerWidth, o = window.innerHeight), new zt({
|
|
2229
2219
|
postEvent: s,
|
|
2230
2220
|
height: r,
|
|
2231
2221
|
width: i,
|
|
@@ -2233,26 +2223,26 @@ function Ss({
|
|
|
2233
2223
|
isExpanded: n
|
|
2234
2224
|
});
|
|
2235
2225
|
}
|
|
2236
|
-
const Cs =
|
|
2226
|
+
const Cs = d(
|
|
2237
2227
|
"viewport",
|
|
2238
2228
|
async (e) => {
|
|
2239
|
-
if (
|
|
2240
|
-
throw
|
|
2241
|
-
|
|
2229
|
+
if (E() && !e.state)
|
|
2230
|
+
throw m(
|
|
2231
|
+
vt,
|
|
2242
2232
|
"Viewport cannot be instantiated on the server side without passing the ssr.state object."
|
|
2243
2233
|
);
|
|
2244
|
-
let t =
|
|
2245
|
-
return
|
|
2234
|
+
let t = xs(e);
|
|
2235
|
+
return E() || (t.width === 0 && await Ps(e.postEvent, { timeout: 1e3 }).then((s) => t = s).catch((s) => $.error("Unable to sync viewport state", s)), t.listen()), t;
|
|
2246
2236
|
}
|
|
2247
2237
|
);
|
|
2248
2238
|
function y(e, t) {
|
|
2249
2239
|
document.documentElement.style.setProperty(e, t);
|
|
2250
2240
|
}
|
|
2251
|
-
function
|
|
2241
|
+
function tn(e, t, s) {
|
|
2252
2242
|
s || (s = (a) => `--tg-${a}-color`);
|
|
2253
2243
|
const n = s("header"), r = s("bg"), i = () => {
|
|
2254
2244
|
const { headerColor: a } = e;
|
|
2255
|
-
if (
|
|
2245
|
+
if (et(a))
|
|
2256
2246
|
y(n, a);
|
|
2257
2247
|
else {
|
|
2258
2248
|
const { bgColor: h, secondaryBgColor: u } = t;
|
|
@@ -2265,7 +2255,7 @@ function en(e, t, s) {
|
|
|
2265
2255
|
];
|
|
2266
2256
|
return i(), () => o.forEach((a) => a());
|
|
2267
2257
|
}
|
|
2268
|
-
function
|
|
2258
|
+
function en(e, t) {
|
|
2269
2259
|
t || (t = (n) => `--tg-theme-${n.replace(/[A-Z]/g, (r) => `-${r.toLowerCase()}`)}`);
|
|
2270
2260
|
const s = () => {
|
|
2271
2261
|
Object.entries(e.getState()).forEach(([n, r]) => {
|
|
@@ -2274,7 +2264,7 @@ function sn(e, t) {
|
|
|
2274
2264
|
};
|
|
2275
2265
|
return s(), e.on("change", s);
|
|
2276
2266
|
}
|
|
2277
|
-
function
|
|
2267
|
+
function sn(e, t) {
|
|
2278
2268
|
t || (t = (u) => `--tg-viewport-${u}`);
|
|
2279
2269
|
const [
|
|
2280
2270
|
s,
|
|
@@ -2287,7 +2277,7 @@ function nn(e, t) {
|
|
|
2287
2277
|
];
|
|
2288
2278
|
return i(), o(), a(), () => h.forEach((u) => u());
|
|
2289
2279
|
}
|
|
2290
|
-
function
|
|
2280
|
+
function Ss(e = !0) {
|
|
2291
2281
|
const t = [
|
|
2292
2282
|
b("reload_iframe", () => {
|
|
2293
2283
|
k("iframe_will_reload"), window.location.reload();
|
|
@@ -2304,18 +2294,20 @@ function Rs(e = !0) {
|
|
|
2304
2294
|
}
|
|
2305
2295
|
return k("iframe_ready", { reload_supported: !0 }), s;
|
|
2306
2296
|
}
|
|
2307
|
-
async function
|
|
2297
|
+
async function nn() {
|
|
2298
|
+
if (xt(window))
|
|
2299
|
+
return !0;
|
|
2308
2300
|
try {
|
|
2309
|
-
return await
|
|
2301
|
+
return await f({ method: "web_app_request_theme", event: "theme_changed", timeout: 100 }), !0;
|
|
2310
2302
|
} catch {
|
|
2311
2303
|
return !1;
|
|
2312
2304
|
}
|
|
2313
2305
|
}
|
|
2314
|
-
function
|
|
2306
|
+
function Rs(e) {
|
|
2315
2307
|
return e instanceof U;
|
|
2316
2308
|
}
|
|
2317
|
-
function
|
|
2318
|
-
return
|
|
2309
|
+
function rn(e, t) {
|
|
2310
|
+
return Rs(e) && e.type === t;
|
|
2319
2311
|
}
|
|
2320
2312
|
function z(e, t) {
|
|
2321
2313
|
let s, n, r;
|
|
@@ -2328,10 +2320,10 @@ function z(e, t) {
|
|
|
2328
2320
|
class As {
|
|
2329
2321
|
constructor(t, s, n = k) {
|
|
2330
2322
|
if (c(this, "history"), c(this, "ee", new L()), c(this, "attached", !1), c(this, "back", () => this.go(-1)), c(this, "on", this.ee.on.bind(this.ee)), c(this, "off", this.ee.off.bind(this.ee)), this._index = s, this.postEvent = n, t.length === 0)
|
|
2331
|
-
throw
|
|
2323
|
+
throw m(le, "History should not be empty.");
|
|
2332
2324
|
if (s < 0 || s >= t.length)
|
|
2333
|
-
throw
|
|
2334
|
-
|
|
2325
|
+
throw m(
|
|
2326
|
+
_e,
|
|
2335
2327
|
"Index should not be zero and higher or equal than history size."
|
|
2336
2328
|
);
|
|
2337
2329
|
this.history = t.map((r) => z(r, ""));
|
|
@@ -2485,23 +2477,23 @@ async function I(e) {
|
|
|
2485
2477
|
})
|
|
2486
2478
|
]);
|
|
2487
2479
|
}
|
|
2488
|
-
async function
|
|
2480
|
+
async function Ts() {
|
|
2489
2481
|
if (window.history.length <= 1 || (window.history.pushState(null, ""), await I(1 - window.history.length)))
|
|
2490
2482
|
return;
|
|
2491
2483
|
let e = await I(-1);
|
|
2492
2484
|
for (; e; )
|
|
2493
2485
|
e = await I(-1);
|
|
2494
2486
|
}
|
|
2495
|
-
function
|
|
2487
|
+
function Kt(e) {
|
|
2496
2488
|
return M(e).pathname;
|
|
2497
2489
|
}
|
|
2498
|
-
const
|
|
2499
|
-
class
|
|
2490
|
+
const gt = 0, Q = 1, F = 2;
|
|
2491
|
+
class Jt {
|
|
2500
2492
|
constructor(t, s, { postEvent: n, hashMode: r, base: i } = {}) {
|
|
2501
2493
|
c(this, "navigator"), c(this, "ee", new L()), c(this, "hashMode"), c(this, "base"), c(this, "attached", !1), c(this, "onPopState", ({ state: o }) => {
|
|
2502
2494
|
if (o === null)
|
|
2503
2495
|
return this.push(this.parsePath(window.location.href));
|
|
2504
|
-
o ===
|
|
2496
|
+
o === gt ? window.history.forward() : o === Q && this.back(), o === F && this.forward();
|
|
2505
2497
|
}), c(this, "onNavigatorChange", async ({
|
|
2506
2498
|
to: o,
|
|
2507
2499
|
from: a,
|
|
@@ -2517,7 +2509,7 @@ class Kt {
|
|
|
2517
2509
|
t.map((o) => J(o, "/")),
|
|
2518
2510
|
s,
|
|
2519
2511
|
n
|
|
2520
|
-
), this.navigator.on("change", this.onNavigatorChange), this.hashMode = r, this.base =
|
|
2512
|
+
), this.navigator.on("change", this.onNavigatorChange), this.hashMode = r, this.base = Kt(i || "");
|
|
2521
2513
|
}
|
|
2522
2514
|
/**
|
|
2523
2515
|
* Attaches current navigator to the browser history allowing navigator to manipulate it.
|
|
@@ -2674,7 +2666,7 @@ class Kt {
|
|
|
2674
2666
|
async syncHistory() {
|
|
2675
2667
|
window.removeEventListener("popstate", this.onPopState);
|
|
2676
2668
|
const { state: t } = this, s = this.renderPath(this);
|
|
2677
|
-
await
|
|
2669
|
+
await Ts(), this.hasPrev && this.hasNext ? (window.history.replaceState(Q, ""), window.history.pushState(t, "", s), window.history.pushState(F, ""), await I(-1)) : this.hasPrev ? (window.history.replaceState(Q, ""), window.history.pushState(t, "", s)) : this.hasNext ? (window.history.replaceState(t, s), window.history.pushState(F, ""), await I(-1)) : (window.history.replaceState(gt, ""), window.history.pushState(t, "", s)), window.addEventListener("popstate", this.onPopState);
|
|
2678
2670
|
}
|
|
2679
2671
|
/**
|
|
2680
2672
|
* Current query parameters.
|
|
@@ -2692,73 +2684,73 @@ class Kt {
|
|
|
2692
2684
|
return (this.navigator.current.params || {}).state;
|
|
2693
2685
|
}
|
|
2694
2686
|
}
|
|
2695
|
-
function
|
|
2687
|
+
function Is(e) {
|
|
2696
2688
|
e || (e = {});
|
|
2697
2689
|
const { href: t, hash: s } = window.location;
|
|
2698
2690
|
let n = B(
|
|
2699
2691
|
e.hashMode ? s.includes("?") ? s.slice(1) : `?${s.slice(1)}` : t
|
|
2700
2692
|
);
|
|
2701
|
-
const r = e.base ?
|
|
2693
|
+
const r = e.base ? Kt(e.base) : void 0;
|
|
2702
2694
|
if (r) {
|
|
2703
2695
|
if (!n.startsWith(r))
|
|
2704
|
-
throw
|
|
2696
|
+
throw m(
|
|
2705
2697
|
ge,
|
|
2706
2698
|
`Path "${n}" expected to be starting with "${r}"`
|
|
2707
2699
|
);
|
|
2708
2700
|
n = n.slice(r.length);
|
|
2709
2701
|
}
|
|
2710
|
-
return new
|
|
2702
|
+
return new Jt([n], 0, e);
|
|
2711
2703
|
}
|
|
2712
|
-
function
|
|
2704
|
+
function on(e) {
|
|
2713
2705
|
const t = e.match(/#(.+)/);
|
|
2714
2706
|
return t ? t[1] : null;
|
|
2715
2707
|
}
|
|
2716
|
-
function
|
|
2717
|
-
if (
|
|
2708
|
+
function ks(e, t) {
|
|
2709
|
+
if (Ut()) {
|
|
2718
2710
|
const s = sessionStorage.getItem(e);
|
|
2719
2711
|
if (s)
|
|
2720
2712
|
try {
|
|
2721
2713
|
const { index: n, history: r } = JSON.parse(s);
|
|
2722
|
-
return new
|
|
2714
|
+
return new Jt(r, n, t);
|
|
2723
2715
|
} catch (n) {
|
|
2724
2716
|
console.error("Unable to restore hash navigator state.", n);
|
|
2725
2717
|
}
|
|
2726
2718
|
}
|
|
2727
|
-
return
|
|
2719
|
+
return Is(t);
|
|
2728
2720
|
}
|
|
2729
|
-
function
|
|
2730
|
-
const s =
|
|
2721
|
+
function an(e, t) {
|
|
2722
|
+
const s = ks(e, t), n = () => sessionStorage.setItem(e, JSON.stringify({
|
|
2731
2723
|
index: s.index,
|
|
2732
2724
|
history: s.history
|
|
2733
2725
|
}));
|
|
2734
2726
|
return s.on("change", n), n(), s;
|
|
2735
2727
|
}
|
|
2736
|
-
function
|
|
2737
|
-
return (t, s, ...n) => (r) =>
|
|
2728
|
+
function l(e) {
|
|
2729
|
+
return (t, s, ...n) => (r) => ft(s, ct(() => ct({
|
|
2738
2730
|
[t]: e(...n)
|
|
2739
2731
|
}, r)));
|
|
2740
2732
|
}
|
|
2741
|
-
const
|
|
2742
|
-
function
|
|
2743
|
-
const e =
|
|
2733
|
+
const Qt = Ft();
|
|
2734
|
+
function Os() {
|
|
2735
|
+
const e = Yt(Qt);
|
|
2744
2736
|
if (!e)
|
|
2745
2737
|
throw new Error("useSDK was used outside of SDKProvider.");
|
|
2746
2738
|
return e;
|
|
2747
2739
|
}
|
|
2748
|
-
function
|
|
2749
|
-
return (...t) =>
|
|
2740
|
+
function _(e) {
|
|
2741
|
+
return (...t) => Os()(e, ...t);
|
|
2750
2742
|
}
|
|
2751
|
-
const
|
|
2743
|
+
const qs = _(je), cn = l(qs), Ds = _(ze), hn = l(Ds), Ns = _(Je), pn = l(Ns), Vs = _(Xe), un = l(Vs), Ms = _(es), dn = l(Ms), Bs = _(ns), ln = l(Bs), $s = _(is), _n = l($s), Ls = _(as), gn = l(Ls), Us = _(us), fn = l(Us), Hs = _(_s), mn = l(Hs), Ws = _(fs), wn = l(Ws), js = _(ws), bn = l(js), Gs = _(vs), vn = l(Gs), zs = _(Es), yn = l(zs), Ks = _(Cs), En = l(Ks), Pn = (e) => {
|
|
2752
2744
|
const t = /* @__PURE__ */ new Map(), s = (n, ...r) => {
|
|
2753
2745
|
if (t.has(n))
|
|
2754
2746
|
return t.get(n);
|
|
2755
|
-
const [i] =
|
|
2747
|
+
const [i] = Xt(() => {
|
|
2756
2748
|
try {
|
|
2757
2749
|
return n(...r);
|
|
2758
2750
|
} catch (h) {
|
|
2759
2751
|
return [h];
|
|
2760
2752
|
}
|
|
2761
|
-
}), o =
|
|
2753
|
+
}), o = pt(() => {
|
|
2762
2754
|
if (i.error)
|
|
2763
2755
|
return [i.error];
|
|
2764
2756
|
if (i.state !== "ready")
|
|
@@ -2766,14 +2758,14 @@ const Ns = g(Ge), hn = _(Ns), Ds = g(Ke), pn = _(Ds), Vs = g(Qe), un = _(Vs), Ms
|
|
|
2766
2758
|
const h = i();
|
|
2767
2759
|
if (Array.isArray(h) || !h || !("on" in h))
|
|
2768
2760
|
return h;
|
|
2769
|
-
const u =
|
|
2761
|
+
const u = te((V) => (V(h), h.on("change", () => V(h)))), N = Object.getPrototypeOf(h), G = {};
|
|
2770
2762
|
return new Proxy(h, {
|
|
2771
|
-
get(V,
|
|
2772
|
-
if (!(
|
|
2773
|
-
const
|
|
2774
|
-
G[
|
|
2763
|
+
get(V, x) {
|
|
2764
|
+
if (!(x in G)) {
|
|
2765
|
+
const at = Reflect.getOwnPropertyDescriptor(N, x);
|
|
2766
|
+
G[x] = at && "get" in at ? pt(() => u()[x]) : () => Reflect.get(V, x);
|
|
2775
2767
|
}
|
|
2776
|
-
return G[
|
|
2768
|
+
return G[x]();
|
|
2777
2769
|
}
|
|
2778
2770
|
});
|
|
2779
2771
|
});
|
|
@@ -2790,11 +2782,11 @@ const Ns = g(Ge), hn = _(Ns), Ds = g(Ke), pn = _(Ds), Vs = g(Qe), un = _(Vs), Ms
|
|
|
2790
2782
|
}
|
|
2791
2783
|
}), t.set(n, a), a;
|
|
2792
2784
|
};
|
|
2793
|
-
return
|
|
2794
|
-
|
|
2795
|
-
}),
|
|
2796
|
-
|
|
2797
|
-
}),
|
|
2785
|
+
return ht(() => {
|
|
2786
|
+
ie(e.debug || !1);
|
|
2787
|
+
}), ht(() => {
|
|
2788
|
+
Ct() && Zt(Ss(e.acceptCustomStyles));
|
|
2789
|
+
}), ft(Qt.Provider, {
|
|
2798
2790
|
value: s,
|
|
2799
2791
|
get children() {
|
|
2800
2792
|
return e.children;
|
|
@@ -2802,138 +2794,138 @@ const Ns = g(Ge), hn = _(Ns), Ds = g(Ke), pn = _(Ds), Vs = g(Qe), un = _(Vs), Ms
|
|
|
2802
2794
|
});
|
|
2803
2795
|
};
|
|
2804
2796
|
export {
|
|
2805
|
-
|
|
2797
|
+
ke as BackButton,
|
|
2806
2798
|
As as BasicNavigator,
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2799
|
+
lt as BiometryManager,
|
|
2800
|
+
Jt as BrowserNavigator,
|
|
2801
|
+
Ke as ClosingBehavior,
|
|
2802
|
+
Ze as CloudStorage,
|
|
2811
2803
|
ge as ERR_INVALID_PATH_BASE,
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
ce as ERR_UNKNOWN_ENV,
|
|
2804
|
+
pe as ERR_INVOKE_CUSTOM_METHOD_RESPONSE,
|
|
2805
|
+
ce as ERR_METHOD_PARAMETER_UNSUPPORTED,
|
|
2806
|
+
ae as ERR_METHOD_UNSUPPORTED,
|
|
2807
|
+
le as ERR_NAVIGATION_HISTORY_EMPTY,
|
|
2808
|
+
_e as ERR_NAVIGATION_INDEX_INVALID,
|
|
2809
|
+
Qs as ERR_NAVIGATION_ITEM_INVALID,
|
|
2810
|
+
bt as ERR_PARSE,
|
|
2811
|
+
vt as ERR_SSR_INIT,
|
|
2812
|
+
ue as ERR_TIMED_OUT,
|
|
2813
|
+
de as ERR_UNEXPECTED_TYPE,
|
|
2814
|
+
he as ERR_UNKNOWN_ENV,
|
|
2824
2815
|
L as EventEmitter,
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2816
|
+
ts as HapticFeedback,
|
|
2817
|
+
ss as InitData,
|
|
2818
|
+
rs as Invoice,
|
|
2819
|
+
os as MainButton,
|
|
2820
|
+
ps as MiniApp,
|
|
2821
|
+
ls as Popup,
|
|
2822
|
+
gs as QRScanner,
|
|
2832
2823
|
U as SDKError,
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2824
|
+
Pn as SDKProvider,
|
|
2825
|
+
ms as SettingsButton,
|
|
2826
|
+
bs as ThemeParams,
|
|
2827
|
+
ys as Utils,
|
|
2828
|
+
zt as Viewport,
|
|
2829
|
+
Ye as array,
|
|
2830
|
+
tn as bindMiniAppCSSVars,
|
|
2831
|
+
en as bindThemeParamsCSSVars,
|
|
2832
|
+
sn as bindViewportCSSVars,
|
|
2842
2833
|
v as boolean,
|
|
2843
|
-
|
|
2834
|
+
Rt as captureSameReq,
|
|
2844
2835
|
X as classNames,
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2836
|
+
Se as compareVersions,
|
|
2837
|
+
Is as createBrowserNavigatorFromLocation,
|
|
2838
|
+
Te as createPostEvent,
|
|
2848
2839
|
M as createSafeURL,
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
|
|
2840
|
+
Ot as date,
|
|
2841
|
+
on as getHash,
|
|
2842
|
+
Kt as getPathname,
|
|
2843
|
+
je as initBackButton,
|
|
2844
|
+
ze as initBiometryManager,
|
|
2845
|
+
Je as initClosingBehavior,
|
|
2846
|
+
Xe as initCloudStorage,
|
|
2847
|
+
es as initHapticFeedback,
|
|
2848
|
+
ns as initInitData,
|
|
2849
|
+
is as initInvoice,
|
|
2850
|
+
as as initMainButton,
|
|
2851
|
+
us as initMiniApp,
|
|
2852
|
+
an as initNavigator,
|
|
2853
|
+
_s as initPopup,
|
|
2854
|
+
fs as initQRScanner,
|
|
2855
|
+
ws as initSettingsButton,
|
|
2856
|
+
vs as initThemeParams,
|
|
2857
|
+
Es as initUtils,
|
|
2867
2858
|
Cs as initViewport,
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
|
|
2859
|
+
Ss as initWeb,
|
|
2860
|
+
T as invokeCustomMethod,
|
|
2861
|
+
It as isColorDark,
|
|
2862
|
+
Ct as isIframe,
|
|
2863
|
+
Ut as isPageReload,
|
|
2864
|
+
et as isRGB,
|
|
2874
2865
|
fe as isRGBShort,
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2866
|
+
Rs as isSDKError,
|
|
2867
|
+
rn as isSDKErrorOfType,
|
|
2868
|
+
E as isSSR,
|
|
2869
|
+
nn as isTMA,
|
|
2870
|
+
g as json,
|
|
2871
|
+
Ys as mergeClassNames,
|
|
2872
|
+
P as number,
|
|
2881
2873
|
j as off,
|
|
2882
2874
|
b as on,
|
|
2883
|
-
|
|
2875
|
+
Zs as parseInitData,
|
|
2884
2876
|
Nt as parseLaunchParams,
|
|
2885
|
-
|
|
2877
|
+
jt as parseThemeParams,
|
|
2886
2878
|
k as postEvent,
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
|
|
2879
|
+
f as request,
|
|
2880
|
+
Ge as requestBiometryInfo,
|
|
2881
|
+
Xs as requestThemeParams,
|
|
2882
|
+
Gt as requestViewport,
|
|
2883
|
+
Ue as retrieveLaunchParams,
|
|
2892
2884
|
Pt as rgb,
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
|
|
2885
|
+
rt as searchParams,
|
|
2886
|
+
$e as serializeLaunchParams,
|
|
2887
|
+
Be as serializeThemeParams,
|
|
2896
2888
|
y as setCSSVar,
|
|
2897
|
-
|
|
2898
|
-
|
|
2889
|
+
ie as setDebug,
|
|
2890
|
+
Fs as setTargetOrigin,
|
|
2899
2891
|
p as string,
|
|
2900
|
-
|
|
2901
|
-
|
|
2892
|
+
ne as subscribe,
|
|
2893
|
+
C as supports,
|
|
2902
2894
|
Ae as targetOrigin,
|
|
2903
2895
|
Et as toRGB,
|
|
2904
|
-
|
|
2896
|
+
wt as unsubscribe,
|
|
2905
2897
|
B as urlToPath,
|
|
2906
|
-
|
|
2898
|
+
qs as useBackButton,
|
|
2907
2899
|
Ds as useBiometryManager,
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
|
|
2900
|
+
Ns as useClosingBehavior,
|
|
2901
|
+
Vs as useCloudStorage,
|
|
2902
|
+
Ms as useHapticFeedback,
|
|
2903
|
+
Bs as useInitData,
|
|
2904
|
+
$s as useInvoice,
|
|
2905
|
+
Ls as useMainButton,
|
|
2906
|
+
Us as useMiniApp,
|
|
2907
|
+
Hs as usePopup,
|
|
2908
|
+
Ws as useQRScanner,
|
|
2909
|
+
Os as useSDK,
|
|
2910
|
+
js as useSettingsButton,
|
|
2911
|
+
Gs as useThemeParams,
|
|
2912
|
+
zs as useUtils,
|
|
2913
|
+
Ks as useViewport,
|
|
2914
|
+
cn as withBackButton,
|
|
2915
|
+
hn as withBiometryManager,
|
|
2916
|
+
pn as withClosingBehavior,
|
|
2917
|
+
un as withCloudStorage,
|
|
2918
|
+
dn as withHapticFeedback,
|
|
2919
|
+
ln as withInitData,
|
|
2920
|
+
_n as withInvoice,
|
|
2921
|
+
gn as withMainButton,
|
|
2922
|
+
fn as withMiniApp,
|
|
2923
|
+
mn as withPopup,
|
|
2924
|
+
wn as withQRScanner,
|
|
2925
|
+
bn as withSettingsButton,
|
|
2926
|
+
vn as withThemeParams,
|
|
2935
2927
|
Tt as withTimeout,
|
|
2936
|
-
|
|
2937
|
-
|
|
2928
|
+
yn as withUtils,
|
|
2929
|
+
En as withViewport
|
|
2938
2930
|
};
|
|
2939
2931
|
//# sourceMappingURL=index.js.map
|