@tma.js/sdk 2.0.1 → 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 +1 -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 +366 -377
- 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,19 +1,19 @@
|
|
|
1
1
|
var Lt = Object.defineProperty;
|
|
2
2
|
var Bt = (e, t, s) => t in e ? Lt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s;
|
|
3
3
|
var c = (e, t, s) => (Bt(e, typeof t != "symbol" ? t + "" : t, s), s);
|
|
4
|
-
function
|
|
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
|
-
t.unsubscribe(e), s && !t.count &&
|
|
13
|
+
t.unsubscribe(e), s && !t.count && ae();
|
|
14
14
|
}
|
|
15
15
|
function Ot(e) {
|
|
16
|
-
return L().subscribe(e), () =>
|
|
16
|
+
return L().subscribe(e), () => ct(e);
|
|
17
17
|
}
|
|
18
18
|
class Ut {
|
|
19
19
|
constructor(t, s = {}) {
|
|
@@ -60,11 +60,11 @@ const D = new Ut("SDK", {
|
|
|
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 ? Ot(
|
|
66
|
+
function ts(e) {
|
|
67
|
+
j !== e && (j = e, e ? Ot(st) : ct(st));
|
|
68
68
|
}
|
|
69
69
|
function Wt(...e) {
|
|
70
70
|
j && D.log(...e);
|
|
@@ -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 Ht = "ERR_METHOD_UNSUPPORTED", Gt = "ERR_METHOD_PARAMETER_UNSUPPORTED", jt = "ERR_UNKNOWN_ENV",
|
|
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,17 +239,17 @@ 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
|
-
function
|
|
245
|
+
function Xt(e) {
|
|
246
246
|
return /^#[\da-f]{3}$/i.test(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
|
-
if (
|
|
252
|
+
if (Xt(t)) {
|
|
253
253
|
let n = "#";
|
|
254
254
|
for (let r = 0; r < 3; r += 1)
|
|
255
255
|
n += t[1 + r].repeat(2);
|
|
@@ -263,30 +263,30 @@ 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 =
|
|
271
|
-
function
|
|
272
|
-
return
|
|
270
|
+
}, "string"), dt = x((e) => lt(h().parse(e)), "rgb");
|
|
271
|
+
function Kt(e) {
|
|
272
|
+
return d({
|
|
273
273
|
eventType: h(),
|
|
274
274
|
eventData: (t) => t
|
|
275
275
|
}).parse(e);
|
|
276
276
|
}
|
|
277
|
-
function
|
|
277
|
+
function te() {
|
|
278
278
|
["TelegramGameProxy_receiveEvent", "TelegramGameProxy", "Telegram"].forEach((e) => {
|
|
279
279
|
delete window[e];
|
|
280
280
|
});
|
|
281
281
|
}
|
|
282
|
-
function
|
|
282
|
+
function ee(e, t) {
|
|
283
283
|
window.dispatchEvent(new MessageEvent("message", {
|
|
284
284
|
data: JSON.stringify({ eventType: e, eventData: t }),
|
|
285
285
|
// We specify window.parent to imitate the case, the parent iframe sent us this event.
|
|
286
286
|
source: window.parent
|
|
287
287
|
}));
|
|
288
288
|
}
|
|
289
|
-
function
|
|
289
|
+
function se() {
|
|
290
290
|
[
|
|
291
291
|
["TelegramGameProxy_receiveEvent"],
|
|
292
292
|
// Windows Phone.
|
|
@@ -298,66 +298,66 @@ function ne() {
|
|
|
298
298
|
let t = window;
|
|
299
299
|
e.forEach((s, n, r) => {
|
|
300
300
|
if (n === r.length - 1) {
|
|
301
|
-
t[s] =
|
|
301
|
+
t[s] = ee;
|
|
302
302
|
return;
|
|
303
303
|
}
|
|
304
304
|
s in t || (t[s] = {}), t = t[s];
|
|
305
305
|
});
|
|
306
306
|
});
|
|
307
307
|
}
|
|
308
|
-
const
|
|
308
|
+
const ne = d({
|
|
309
309
|
button_id: (e) => e == null ? void 0 : h().parse(e)
|
|
310
|
-
}),
|
|
311
|
-
clipboard_text_received:
|
|
310
|
+
}), re = {
|
|
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
|
-
parse: (e) =>
|
|
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
|
};
|
|
349
|
-
function
|
|
349
|
+
function ie() {
|
|
350
350
|
const e = new V();
|
|
351
|
-
|
|
351
|
+
se();
|
|
352
352
|
let t = [
|
|
353
353
|
// Don't forget to remove created handlers.
|
|
354
|
-
|
|
354
|
+
te,
|
|
355
355
|
// Add "resize" event listener to make sure, we always have fresh viewport information.
|
|
356
356
|
// Desktop version of Telegram is sometimes not sending the viewport_changed
|
|
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,16 +367,16 @@ function oe() {
|
|
|
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;
|
|
374
374
|
try {
|
|
375
|
-
n =
|
|
375
|
+
n = Kt(s.data);
|
|
376
376
|
} catch {
|
|
377
377
|
return;
|
|
378
378
|
}
|
|
379
|
-
const { eventType: r, eventData: i } = n, o =
|
|
379
|
+
const { eventType: r, eventData: i } = n, o = re[r];
|
|
380
380
|
try {
|
|
381
381
|
const a = o ? o.parse(i) : i;
|
|
382
382
|
e.emit(...a ? [r, a] : [r]);
|
|
@@ -395,9 +395,9 @@ function oe() {
|
|
|
395
395
|
t.forEach((s) => s()), t = [];
|
|
396
396
|
}];
|
|
397
397
|
}
|
|
398
|
-
const [
|
|
398
|
+
const [oe, ae] = at(
|
|
399
399
|
(e) => {
|
|
400
|
-
const [t, s] =
|
|
400
|
+
const [t, s] = ie(), n = t.off.bind(t);
|
|
401
401
|
return t.off = (r, i) => {
|
|
402
402
|
const { count: o } = t;
|
|
403
403
|
n(r, i), o && !t.count && e();
|
|
@@ -406,7 +406,7 @@ const [ae, ce] = ct(
|
|
|
406
406
|
([, e]) => e()
|
|
407
407
|
);
|
|
408
408
|
function L() {
|
|
409
|
-
return
|
|
409
|
+
return oe()[0];
|
|
410
410
|
}
|
|
411
411
|
function B(e, t) {
|
|
412
412
|
L().off(e, t);
|
|
@@ -417,7 +417,7 @@ function b(e, t, s) {
|
|
|
417
417
|
function I(e) {
|
|
418
418
|
return typeof e == "object" && e !== null && !Array.isArray(e);
|
|
419
419
|
}
|
|
420
|
-
function
|
|
420
|
+
function ce(e, t) {
|
|
421
421
|
const s = e.split("."), n = t.split("."), r = Math.max(s.length, n.length);
|
|
422
422
|
for (let i = 0; i < r; i += 1) {
|
|
423
423
|
const o = parseInt(s[i] || "0", 10), a = parseInt(n[i] || "0", 10);
|
|
@@ -427,9 +427,9 @@ function he(e, t) {
|
|
|
427
427
|
return 0;
|
|
428
428
|
}
|
|
429
429
|
function g(e, t) {
|
|
430
|
-
return
|
|
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);
|
|
@@ -480,13 +480,13 @@ function v(e, t, s) {
|
|
|
480
480
|
].includes(e);
|
|
481
481
|
}
|
|
482
482
|
}
|
|
483
|
-
function
|
|
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
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 {
|
|
@@ -494,21 +494,21 @@ function ue() {
|
|
|
494
494
|
}
|
|
495
495
|
}
|
|
496
496
|
let ft = "https://web.telegram.org";
|
|
497
|
-
function
|
|
497
|
+
function ss(e) {
|
|
498
498
|
ft = e;
|
|
499
499
|
}
|
|
500
|
-
function
|
|
500
|
+
function ue() {
|
|
501
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 (Wt("Posting event:", r ? { event: e, data: r } : { event: e }),
|
|
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
|
}
|
|
511
|
-
if (
|
|
511
|
+
if (he(window)) {
|
|
512
512
|
window.external.notify(JSON.stringify({ eventType: e, eventData: r }));
|
|
513
513
|
return;
|
|
514
514
|
}
|
|
@@ -516,31 +516,31 @@ function T(e, t, s) {
|
|
|
516
516
|
window.TelegramWebviewProxy.postEvent(e, JSON.stringify(r));
|
|
517
517
|
return;
|
|
518
518
|
}
|
|
519
|
-
throw
|
|
519
|
+
throw f(
|
|
520
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
|
|
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
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
539
|
function gt(e) {
|
|
540
540
|
return ({ req_id: t }) => t === e;
|
|
541
541
|
}
|
|
542
542
|
function bt(e) {
|
|
543
|
-
return
|
|
543
|
+
return f(zt, `Timeout reached: ${e}ms`);
|
|
544
544
|
}
|
|
545
545
|
function wt(e, t) {
|
|
546
546
|
return Promise.race([
|
|
@@ -552,30 +552,30 @@ function wt(e, 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
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",
|
|
@@ -587,22 +587,22 @@ async function R(e, t, s, n = {}) {
|
|
|
587
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
|
}
|
|
@@ -615,7 +615,7 @@ function mt(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,13 +660,13 @@ 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
666
|
function yt(e, t) {
|
|
667
|
-
return (s) =>
|
|
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
|
/**
|
|
@@ -676,7 +676,7 @@ class X extends Z {
|
|
|
676
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 vt =
|
|
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"
|
|
@@ -779,16 +779,16 @@ const ge = _({
|
|
|
779
779
|
username: h().optional()
|
|
780
780
|
}, "User").optional();
|
|
781
781
|
function Et() {
|
|
782
|
-
return
|
|
782
|
+
return X({
|
|
783
783
|
authDate: {
|
|
784
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,29 +802,29 @@ function Et() {
|
|
|
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 Pt =
|
|
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"
|
|
@@ -859,47 +859,47 @@ function St(e) {
|
|
|
859
859
|
}
|
|
860
860
|
}).parse(e);
|
|
861
861
|
}
|
|
862
|
-
function
|
|
863
|
-
return
|
|
862
|
+
function St(e) {
|
|
863
|
+
return xt(
|
|
864
864
|
e.replace(/^[^?#]*[?#]/, "").replace(/[?#]/g, "&")
|
|
865
865
|
);
|
|
866
866
|
}
|
|
867
|
-
function
|
|
868
|
-
return
|
|
867
|
+
function we() {
|
|
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
|
-
return
|
|
877
|
+
return St(e.name);
|
|
878
878
|
}
|
|
879
|
-
function
|
|
879
|
+
function Rt(e) {
|
|
880
880
|
return `tma.js/${e.replace(/[A-Z]/g, (t) => `-${t.toLowerCase()}`)}`;
|
|
881
881
|
}
|
|
882
|
-
function
|
|
883
|
-
sessionStorage.setItem(
|
|
882
|
+
function At(e, t) {
|
|
883
|
+
sessionStorage.setItem(Rt(e), JSON.stringify(t));
|
|
884
884
|
}
|
|
885
|
-
function
|
|
886
|
-
const t = sessionStorage.getItem(
|
|
885
|
+
function Tt(e) {
|
|
886
|
+
const t = sessionStorage.getItem(Rt(e));
|
|
887
887
|
try {
|
|
888
888
|
return t ? JSON.parse(t) : void 0;
|
|
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
934
|
function It() {
|
|
935
|
-
const e =
|
|
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
|
-
Zt,
|
|
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: It() ?
|
|
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
|
/**
|
|
@@ -1009,7 +999,7 @@ function qt(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,7 +1074,7 @@ 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",
|
|
@@ -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
|
|
1116
|
+
async function Re(e) {
|
|
1127
1117
|
return qt(
|
|
1128
|
-
await
|
|
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,11 +1176,11 @@ 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.
|
|
@@ -1199,7 +1189,7 @@ class et {
|
|
|
1199
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
|
|
1418
|
+
function ps(e) {
|
|
1429
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: {
|
|
@@ -1662,15 +1652,15 @@ function Le() {
|
|
|
1662
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",
|
|
@@ -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(),
|
|
@@ -1776,7 +1766,7 @@ class Oe extends q {
|
|
|
1776
1766
|
return await this.getRequestedContact();
|
|
1777
1767
|
} catch {
|
|
1778
1768
|
}
|
|
1779
|
-
await
|
|
1769
|
+
await Le(i), i += 50;
|
|
1780
1770
|
}
|
|
1781
1771
|
throw bt(s);
|
|
1782
1772
|
}, s);
|
|
@@ -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
|
|
2024
|
+
}) => new He(s.isVisible, e, t));
|
|
2035
2025
|
function Nt(e) {
|
|
2036
2026
|
return Pt().parse(e);
|
|
2037
2027
|
}
|
|
2038
|
-
class
|
|
2028
|
+
class Ge extends K {
|
|
2039
2029
|
/**
|
|
2040
2030
|
* @since v6.10
|
|
2041
2031
|
*/
|
|
@@ -2113,18 +2103,18 @@ 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
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
|
/**
|
|
@@ -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,7 +2170,7 @@ 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,
|
|
@@ -2190,31 +2180,31 @@ class ze extends et {
|
|
|
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
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 Vt extends
|
|
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;
|
|
@@ -2278,11 +2268,11 @@ class Vt 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
|
});
|
|
@@ -2332,7 +2322,7 @@ 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
|
|
@@ -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,22 +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() {
|
|
2421
2411
|
if (_t(window))
|
|
2422
2412
|
return !0;
|
|
2423
2413
|
try {
|
|
2424
|
-
return await
|
|
2414
|
+
return await _({ method: "web_app_request_theme", event: "theme_changed", timeout: 100 }), !0;
|
|
2425
2415
|
} catch {
|
|
2426
2416
|
return !1;
|
|
2427
2417
|
}
|
|
2428
2418
|
}
|
|
2429
|
-
function
|
|
2419
|
+
function Je(e) {
|
|
2430
2420
|
return e instanceof $;
|
|
2431
2421
|
}
|
|
2432
2422
|
function Cs(e, t) {
|
|
2433
|
-
return
|
|
2423
|
+
return Je(e) && e.type === t;
|
|
2434
2424
|
}
|
|
2435
2425
|
function O(e, t) {
|
|
2436
2426
|
let s, n, r;
|
|
@@ -2440,8 +2430,8 @@ function O(e, t) {
|
|
|
2440
2430
|
params: n
|
|
2441
2431
|
});
|
|
2442
2432
|
}
|
|
2443
|
-
class
|
|
2444
|
-
constructor(t, s, n =
|
|
2433
|
+
class Qe {
|
|
2434
|
+
constructor(t, s, n = A) {
|
|
2445
2435
|
/**
|
|
2446
2436
|
* Navigation history.
|
|
2447
2437
|
*/
|
|
@@ -2464,9 +2454,9 @@ class Ye {
|
|
|
2464
2454
|
*/
|
|
2465
2455
|
c(this, "off", this.ee.off.bind(this.ee));
|
|
2466
2456
|
if (this._index = s, this.postEvent = n, t.length === 0)
|
|
2467
|
-
throw
|
|
2457
|
+
throw f(Qt, "History should not be empty.");
|
|
2468
2458
|
if (s < 0 || s >= t.length)
|
|
2469
|
-
throw
|
|
2459
|
+
throw f(
|
|
2470
2460
|
Yt,
|
|
2471
2461
|
"Index should not be zero and higher or equal than history size."
|
|
2472
2462
|
);
|
|
@@ -2588,12 +2578,12 @@ function U({
|
|
|
2588
2578
|
}) {
|
|
2589
2579
|
return { ...e || { hash: "", search: "" }, ...t };
|
|
2590
2580
|
}
|
|
2591
|
-
function
|
|
2581
|
+
function T(e, t) {
|
|
2592
2582
|
return e.startsWith(t) ? e : `${t}${e}`;
|
|
2593
2583
|
}
|
|
2594
2584
|
function k(e) {
|
|
2595
2585
|
return new URL(
|
|
2596
|
-
typeof e == "string" ? e : `${e.pathname || ""}${
|
|
2586
|
+
typeof e == "string" ? e : `${e.pathname || ""}${T(e.search || "", "?")}${T(e.hash || "", "#")}`,
|
|
2597
2587
|
"http://a"
|
|
2598
2588
|
);
|
|
2599
2589
|
}
|
|
@@ -2604,13 +2594,13 @@ function N(e) {
|
|
|
2604
2594
|
function W(e, t, s) {
|
|
2605
2595
|
let n, r;
|
|
2606
2596
|
typeof e == "string" ? n = e : (n = N(e), s = e.state, r = e.id);
|
|
2607
|
-
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, "/")}`);
|
|
2608
2598
|
return { id: r, pathname: i, params: { hash: a, search: o, state: s } };
|
|
2609
2599
|
}
|
|
2610
|
-
async function
|
|
2600
|
+
async function R(e) {
|
|
2611
2601
|
return e === 0 ? !0 : Promise.race([
|
|
2612
2602
|
new Promise((t) => {
|
|
2613
|
-
const s =
|
|
2603
|
+
const s = F("popstate", () => {
|
|
2614
2604
|
s(), t(!0);
|
|
2615
2605
|
});
|
|
2616
2606
|
window.history.go(e);
|
|
@@ -2621,17 +2611,17 @@ async function C(e) {
|
|
|
2621
2611
|
})
|
|
2622
2612
|
]);
|
|
2623
2613
|
}
|
|
2624
|
-
async function
|
|
2625
|
-
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)))
|
|
2626
2616
|
return;
|
|
2627
|
-
let t = await
|
|
2617
|
+
let t = await R(-1);
|
|
2628
2618
|
for (; t; )
|
|
2629
|
-
t = await
|
|
2619
|
+
t = await R(-1);
|
|
2630
2620
|
}
|
|
2631
2621
|
function $t(e) {
|
|
2632
2622
|
return k(e).pathname;
|
|
2633
2623
|
}
|
|
2634
|
-
const
|
|
2624
|
+
const ot = 0, H = 1, G = 2;
|
|
2635
2625
|
class Mt {
|
|
2636
2626
|
constructor(t, s, { postEvent: n, hashMode: r, base: i } = {}) {
|
|
2637
2627
|
c(this, "navigator");
|
|
@@ -2649,7 +2639,7 @@ class Mt {
|
|
|
2649
2639
|
c(this, "onPopState", ({ state: t }) => {
|
|
2650
2640
|
if (t === null)
|
|
2651
2641
|
return this.push(this.parsePath(window.location.href));
|
|
2652
|
-
t ===
|
|
2642
|
+
t === ot ? window.history.forward() : t === H && this.back(), t === G && this.forward();
|
|
2653
2643
|
});
|
|
2654
2644
|
/**
|
|
2655
2645
|
* Underlying navigator change event listener.
|
|
@@ -2674,7 +2664,7 @@ class Mt {
|
|
|
2674
2664
|
* Removes event listener.
|
|
2675
2665
|
*/
|
|
2676
2666
|
c(this, "off", this.ee.off.bind(this.ee));
|
|
2677
|
-
this.navigator = new
|
|
2667
|
+
this.navigator = new Qe(
|
|
2678
2668
|
t.map((o) => W(o, "/")),
|
|
2679
2669
|
s,
|
|
2680
2670
|
n
|
|
@@ -2826,8 +2816,8 @@ class Mt {
|
|
|
2826
2816
|
* @param value - path presented as string or URLLike.
|
|
2827
2817
|
*/
|
|
2828
2818
|
renderPath(t) {
|
|
2829
|
-
const s = (this.base.length === 1 ? "" : this.base) +
|
|
2830
|
-
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;
|
|
2831
2821
|
}
|
|
2832
2822
|
/**
|
|
2833
2823
|
* Synchronizes current navigator state with browser history.
|
|
@@ -2835,7 +2825,7 @@ class Mt {
|
|
|
2835
2825
|
async syncHistory() {
|
|
2836
2826
|
window.removeEventListener("popstate", this.onPopState);
|
|
2837
2827
|
const { state: t } = this, s = this.renderPath(this);
|
|
2838
|
-
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);
|
|
2839
2829
|
}
|
|
2840
2830
|
/**
|
|
2841
2831
|
* Current query parameters.
|
|
@@ -2853,7 +2843,7 @@ class Mt {
|
|
|
2853
2843
|
return (this.navigator.current.params || {}).state;
|
|
2854
2844
|
}
|
|
2855
2845
|
}
|
|
2856
|
-
function
|
|
2846
|
+
function Ze(e) {
|
|
2857
2847
|
e || (e = {});
|
|
2858
2848
|
const { href: t, hash: s } = window.location;
|
|
2859
2849
|
let n = N(
|
|
@@ -2862,19 +2852,19 @@ function Xe(e) {
|
|
|
2862
2852
|
const r = e.base ? $t(e.base) : void 0;
|
|
2863
2853
|
if (r) {
|
|
2864
2854
|
if (!n.startsWith(r))
|
|
2865
|
-
throw
|
|
2866
|
-
|
|
2855
|
+
throw f(
|
|
2856
|
+
Zt,
|
|
2867
2857
|
`Path "${n}" expected to be starting with "${r}"`
|
|
2868
2858
|
);
|
|
2869
2859
|
n = n.slice(r.length);
|
|
2870
2860
|
}
|
|
2871
2861
|
return new Mt([n], 0, e);
|
|
2872
2862
|
}
|
|
2873
|
-
function
|
|
2863
|
+
function Rs(e) {
|
|
2874
2864
|
const t = e.match(/#(.+)/);
|
|
2875
2865
|
return t ? t[1] : null;
|
|
2876
2866
|
}
|
|
2877
|
-
function
|
|
2867
|
+
function Xe(e, t) {
|
|
2878
2868
|
if (It()) {
|
|
2879
2869
|
const s = sessionStorage.getItem(e);
|
|
2880
2870
|
if (s)
|
|
@@ -2885,116 +2875,115 @@ function Ke(e, t) {
|
|
|
2885
2875
|
console.error("Unable to restore hash navigator state.", n);
|
|
2886
2876
|
}
|
|
2887
2877
|
}
|
|
2888
|
-
return
|
|
2878
|
+
return Ze(t);
|
|
2889
2879
|
}
|
|
2890
2880
|
function As(e, t) {
|
|
2891
|
-
const s =
|
|
2881
|
+
const s = Xe(e, t), n = () => sessionStorage.setItem(e, JSON.stringify({
|
|
2892
2882
|
index: s.index,
|
|
2893
2883
|
history: s.history
|
|
2894
2884
|
}));
|
|
2895
2885
|
return s.on("change", n), n(), s;
|
|
2896
2886
|
}
|
|
2897
2887
|
export {
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2888
|
+
_e as BackButton,
|
|
2889
|
+
Qe as BasicNavigator,
|
|
2890
|
+
rt as BiometryManager,
|
|
2901
2891
|
Mt as BrowserNavigator,
|
|
2902
2892
|
Ae as ClosingBehavior,
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2893
|
+
ke as CloudStorage,
|
|
2894
|
+
Zt as ERR_INVALID_PATH_BASE,
|
|
2895
|
+
Ft as ERR_INVOKE_CUSTOM_METHOD_RESPONSE,
|
|
2906
2896
|
Gt as ERR_METHOD_PARAMETER_UNSUPPORTED,
|
|
2907
2897
|
Ht as ERR_METHOD_UNSUPPORTED,
|
|
2908
2898
|
Qt as ERR_NAVIGATION_HISTORY_EMPTY,
|
|
2909
2899
|
Yt as ERR_NAVIGATION_INDEX_INVALID,
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
Ft as ERR_TIMED_OUT,
|
|
2900
|
+
es as ERR_NAVIGATION_ITEM_INVALID,
|
|
2901
|
+
ht as ERR_PARSE,
|
|
2902
|
+
pt as ERR_SSR_INIT,
|
|
2903
|
+
zt as ERR_TIMED_OUT,
|
|
2915
2904
|
Jt as ERR_UNEXPECTED_TYPE,
|
|
2916
2905
|
jt as ERR_UNKNOWN_ENV,
|
|
2917
2906
|
V as EventEmitter,
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
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,
|
|
2925
2914
|
$ as SDKError,
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2915
|
+
He as SettingsButton,
|
|
2916
|
+
Ge as ThemeParams,
|
|
2917
|
+
je as Utils,
|
|
2929
2918
|
Vt as Viewport,
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
|
|
2919
|
+
qe as array,
|
|
2920
|
+
vs as bindMiniAppCSSVars,
|
|
2921
|
+
Es as bindThemeParamsCSSVars,
|
|
2922
|
+
Ps as bindViewportCSSVars,
|
|
2934
2923
|
w as boolean,
|
|
2935
2924
|
gt as captureSameReq,
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
|
|
2925
|
+
z as classNames,
|
|
2926
|
+
ce as compareVersions,
|
|
2927
|
+
Ze as createBrowserNavigatorFromLocation,
|
|
2928
|
+
le as createPostEvent,
|
|
2940
2929
|
k as createSafeURL,
|
|
2941
2930
|
vt as date,
|
|
2942
|
-
|
|
2931
|
+
Rs as getHash,
|
|
2943
2932
|
$t as getPathname,
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
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,
|
|
2953
2942
|
As as initNavigator,
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2943
|
+
_s as initPopup,
|
|
2944
|
+
fs as initQRScanner,
|
|
2945
|
+
gs as initSettingsButton,
|
|
2946
|
+
bs as initThemeParams,
|
|
2947
|
+
ms as initUtils,
|
|
2948
|
+
ys as initViewport,
|
|
2960
2949
|
xs as initWeb,
|
|
2961
|
-
|
|
2950
|
+
C as invokeCustomMethod,
|
|
2962
2951
|
mt as isColorDark,
|
|
2963
|
-
|
|
2952
|
+
pe as isIframe,
|
|
2964
2953
|
It as isPageReload,
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2954
|
+
Q as isRGB,
|
|
2955
|
+
Xt as isRGBShort,
|
|
2956
|
+
Je as isSDKError,
|
|
2968
2957
|
Cs as isSDKErrorOfType,
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
|
|
2972
|
-
|
|
2973
|
-
|
|
2958
|
+
y as isSSR,
|
|
2959
|
+
Ss as isTMA,
|
|
2960
|
+
d as json,
|
|
2961
|
+
ns as mergeClassNames,
|
|
2962
|
+
v as number,
|
|
2974
2963
|
B as off,
|
|
2975
2964
|
b as on,
|
|
2976
|
-
|
|
2977
|
-
|
|
2965
|
+
ps as parseInitData,
|
|
2966
|
+
xt as parseLaunchParams,
|
|
2978
2967
|
Nt as parseThemeParams,
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2968
|
+
A as postEvent,
|
|
2969
|
+
_ as request,
|
|
2970
|
+
Re as requestBiometryInfo,
|
|
2971
|
+
ws as requestThemeParams,
|
|
2983
2972
|
Dt as requestViewport,
|
|
2984
2973
|
xe as retrieveLaunchParams,
|
|
2985
2974
|
dt as rgb,
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2975
|
+
X as searchParams,
|
|
2976
|
+
Ee as serializeLaunchParams,
|
|
2977
|
+
ve as serializeThemeParams,
|
|
2989
2978
|
m as setCSSVar,
|
|
2990
|
-
|
|
2991
|
-
|
|
2979
|
+
ts as setDebug,
|
|
2980
|
+
ss as setTargetOrigin,
|
|
2992
2981
|
h as string,
|
|
2993
2982
|
Ot as subscribe,
|
|
2994
|
-
|
|
2995
|
-
|
|
2983
|
+
E as supports,
|
|
2984
|
+
ue as targetOrigin,
|
|
2996
2985
|
lt as toRGB,
|
|
2997
|
-
|
|
2986
|
+
ct as unsubscribe,
|
|
2998
2987
|
N as urlToPath,
|
|
2999
2988
|
wt as withTimeout
|
|
3000
2989
|
};
|