choco-one-click-payment 1.1.28 → 1.1.29
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.esm.js +581 -580
- package/dist/index.js +16 -16
- package/index.d.ts +7 -0
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -161,13 +161,13 @@ function Bt() {
|
|
|
161
161
|
const H = [];
|
|
162
162
|
for (let e = 0; e < 256; ++e)
|
|
163
163
|
H.push((e + 256).toString(16).slice(1));
|
|
164
|
-
function It(e,
|
|
165
|
-
return H[e[
|
|
164
|
+
function It(e, t = 0) {
|
|
165
|
+
return H[e[t + 0]] + H[e[t + 1]] + H[e[t + 2]] + H[e[t + 3]] + "-" + H[e[t + 4]] + H[e[t + 5]] + "-" + H[e[t + 6]] + H[e[t + 7]] + "-" + H[e[t + 8]] + H[e[t + 9]] + "-" + H[e[t + 10]] + H[e[t + 11]] + H[e[t + 12]] + H[e[t + 13]] + H[e[t + 14]] + H[e[t + 15]];
|
|
166
166
|
}
|
|
167
167
|
const Qt = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), ze = {
|
|
168
168
|
randomUUID: Qt
|
|
169
169
|
};
|
|
170
|
-
function Be(e,
|
|
170
|
+
function Be(e, t, o) {
|
|
171
171
|
if (ze.randomUUID && !e)
|
|
172
172
|
return ze.randomUUID();
|
|
173
173
|
e = e || {};
|
|
@@ -175,8 +175,8 @@ function Be(e, n, o) {
|
|
|
175
175
|
return i[6] = i[6] & 15 | 64, i[8] = i[8] & 63 | 128, It(i);
|
|
176
176
|
}
|
|
177
177
|
const Ke = "choco_device_id";
|
|
178
|
-
function G(e,
|
|
179
|
-
const i = Number(e), s =
|
|
178
|
+
function G(e, t = "ru", o = "KZT") {
|
|
179
|
+
const i = Number(e), s = t === "ru" ? "ru-RU" : "en-US";
|
|
180
180
|
return `${i.toLocaleString(s)} ${bt[o]}`;
|
|
181
181
|
}
|
|
182
182
|
function nt() {
|
|
@@ -185,18 +185,18 @@ function nt() {
|
|
|
185
185
|
}
|
|
186
186
|
function Ce() {
|
|
187
187
|
if (typeof window > "u") return !1;
|
|
188
|
-
const e = window.safari !== void 0,
|
|
188
|
+
const e = window.safari !== void 0, t = window.navigator.userAgent || "", o = !!t.match(/iPad/i) || !!t.match(/iPhone/i), i = !!t.match(/WebKit/i), s = o && i && !t.match(/CriOS/i);
|
|
189
189
|
return e || s;
|
|
190
190
|
}
|
|
191
191
|
function rt() {
|
|
192
192
|
if (typeof navigator > "u") return 0;
|
|
193
|
-
const e = navigator.userAgent || "",
|
|
194
|
-
return (e.indexOf("iPhone") > -1 || e.indexOf("iPad") > -1) &&
|
|
193
|
+
const e = navigator.userAgent || "", t = e.indexOf("OS");
|
|
194
|
+
return (e.indexOf("iPhone") > -1 || e.indexOf("iPad") > -1) && t > -1 ? Number(e.substring(t + 3, t + 6).replace("_", ".")) : 0;
|
|
195
195
|
}
|
|
196
196
|
function De() {
|
|
197
197
|
var u;
|
|
198
198
|
if (typeof navigator > "u") return "unknown";
|
|
199
|
-
const e = (navigator.userAgent || navigator.vendor || "").toLowerCase(),
|
|
199
|
+
const e = (navigator.userAgent || navigator.vendor || "").toLowerCase(), t = (navigator.platform || "").toLowerCase(), o = (((u = navigator.userAgentData) == null ? void 0 : u.platform) || "").toLowerCase(), i = `${e} ${t} ${o}`;
|
|
200
200
|
return /iphone|ipad|ipod/.test(i) || i.includes("macintosh") && typeof document < "u" && "ontouchend" in document ? "ios" : i.includes("android") ? "android" : i.includes("windows") ? "windows" : i.includes("mac") ? "macos" : "other";
|
|
201
201
|
}
|
|
202
202
|
function ye() {
|
|
@@ -206,15 +206,15 @@ function ye() {
|
|
|
206
206
|
}
|
|
207
207
|
function me(e) {
|
|
208
208
|
if (typeof sessionStorage > "u") return !1;
|
|
209
|
-
const
|
|
210
|
-
return
|
|
209
|
+
const t = e === "apple_pay" ? "disableApplePay" : e === "google_pay" ? "disableGooglePay" : null;
|
|
210
|
+
return t ? sessionStorage.getItem(t) === "true" : !1;
|
|
211
211
|
}
|
|
212
212
|
function St(e) {
|
|
213
213
|
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
|
|
214
214
|
}
|
|
215
215
|
var fe = { exports: {} }, Pt = fe.exports, We;
|
|
216
216
|
function kt() {
|
|
217
|
-
return We || (We = 1, (function(e,
|
|
217
|
+
return We || (We = 1, (function(e, t) {
|
|
218
218
|
(function(i, s) {
|
|
219
219
|
e.exports = s();
|
|
220
220
|
})(Pt, function() {
|
|
@@ -260,20 +260,20 @@ function kt() {
|
|
|
260
260
|
f.prototype = Object.create(h && h.prototype, { constructor: { value: f, writable: !0, configurable: !0 } }), h && L(f, h);
|
|
261
261
|
}
|
|
262
262
|
function L(f, h) {
|
|
263
|
-
return L = Object.setPrototypeOf || function(A,
|
|
264
|
-
return A.__proto__ =
|
|
263
|
+
return L = Object.setPrototypeOf || function(A, n) {
|
|
264
|
+
return A.__proto__ = n, A;
|
|
265
265
|
}, L(f, h);
|
|
266
266
|
}
|
|
267
267
|
function O(f) {
|
|
268
268
|
var h = J();
|
|
269
269
|
return function() {
|
|
270
|
-
var A = x(f),
|
|
270
|
+
var A = x(f), n;
|
|
271
271
|
if (h) {
|
|
272
272
|
var r = x(this).constructor;
|
|
273
|
-
|
|
273
|
+
n = Reflect.construct(A, arguments, r);
|
|
274
274
|
} else
|
|
275
|
-
|
|
276
|
-
return F(this,
|
|
275
|
+
n = A.apply(this, arguments);
|
|
276
|
+
return F(this, n);
|
|
277
277
|
};
|
|
278
278
|
}
|
|
279
279
|
function F(f, h) {
|
|
@@ -306,7 +306,7 @@ function kt() {
|
|
|
306
306
|
var q = "timeout", N = "connection closed", b = /* @__PURE__ */ (function(f) {
|
|
307
307
|
w(p, f);
|
|
308
308
|
var h = O(p);
|
|
309
|
-
function p(A,
|
|
309
|
+
function p(A, n) {
|
|
310
310
|
var r;
|
|
311
311
|
return m(this, p), r = h.call(this), r._url = A, r._websocket = null, r._sockjs = null, r._isSockjs = !1, r._xmlhttprequest = null, r._binary = !1, r._methodType = null, r._pushType = null, r._encoder = null, r._decoder = null, r._status = "disconnected", r._reconnect = !0, r._reconnecting = !1, r._transport = null, r._transportName = null, r._transportClosed = !0, r._messageId = 0, r._clientID = null, r._refreshRequired = !1, r._subs = {}, r._serverSubs = {}, r._lastSeq = {}, r._lastGen = {}, r._lastOffset = {}, r._lastEpoch = {}, r._messages = [], r._isBatching = !1, r._isSubscribeBatching = !1, r._privateChannels = {}, r._numRefreshFailed = 0, r._refreshTimeout = null, r._pingTimeout = null, r._pongTimeout = null, r._subRefreshTimeouts = {}, r._retries = 0, r._callbacks = {}, r._latency = null, r._latencyStart = null, r._connectData = null, r._token = null, r._xhrID = 0, r._xhrs = {}, r._dispatchPromise = Promise.resolve(), r._protocol = "", r._config = {
|
|
312
312
|
protocol: "",
|
|
@@ -341,53 +341,53 @@ function kt() {
|
|
|
341
341
|
subRefreshInterval: 1e3,
|
|
342
342
|
onPrivateSubscribe: null,
|
|
343
343
|
disableWithCredentials: !1
|
|
344
|
-
}, r._configure(
|
|
344
|
+
}, r._configure(n), r;
|
|
345
345
|
}
|
|
346
346
|
return k(p, [{
|
|
347
347
|
key: "setToken",
|
|
348
|
-
value: function(
|
|
349
|
-
this._token =
|
|
348
|
+
value: function(n) {
|
|
349
|
+
this._token = n;
|
|
350
350
|
}
|
|
351
351
|
}, {
|
|
352
352
|
key: "setConnectData",
|
|
353
|
-
value: function(
|
|
354
|
-
this._connectData =
|
|
353
|
+
value: function(n) {
|
|
354
|
+
this._connectData = n;
|
|
355
355
|
}
|
|
356
356
|
}, {
|
|
357
357
|
key: "setRefreshHeaders",
|
|
358
|
-
value: function(
|
|
359
|
-
this._config.refreshHeaders =
|
|
358
|
+
value: function(n) {
|
|
359
|
+
this._config.refreshHeaders = n;
|
|
360
360
|
}
|
|
361
361
|
}, {
|
|
362
362
|
key: "setRefreshParams",
|
|
363
|
-
value: function(
|
|
364
|
-
this._config.refreshParams =
|
|
363
|
+
value: function(n) {
|
|
364
|
+
this._config.refreshParams = n;
|
|
365
365
|
}
|
|
366
366
|
}, {
|
|
367
367
|
key: "setRefreshData",
|
|
368
|
-
value: function(
|
|
369
|
-
this._config.refreshData =
|
|
368
|
+
value: function(n) {
|
|
369
|
+
this._config.refreshData = n;
|
|
370
370
|
}
|
|
371
371
|
}, {
|
|
372
372
|
key: "setSubscribeHeaders",
|
|
373
|
-
value: function(
|
|
374
|
-
this._config.subscribeHeaders =
|
|
373
|
+
value: function(n) {
|
|
374
|
+
this._config.subscribeHeaders = n;
|
|
375
375
|
}
|
|
376
376
|
}, {
|
|
377
377
|
key: "setSubscribeParams",
|
|
378
|
-
value: function(
|
|
379
|
-
this._config.subscribeParams =
|
|
378
|
+
value: function(n) {
|
|
379
|
+
this._config.subscribeParams = n;
|
|
380
380
|
}
|
|
381
381
|
}, {
|
|
382
382
|
key: "_ajax",
|
|
383
|
-
value: function(
|
|
383
|
+
value: function(n, r, c, l, y) {
|
|
384
384
|
var v = this, I = "";
|
|
385
|
-
this._debug("sending AJAX request to",
|
|
385
|
+
this._debug("sending AJAX request to", n, "with data", JSON.stringify(l));
|
|
386
386
|
var B;
|
|
387
387
|
this._xmlhttprequest !== null ? B = new this._xmlhttprequest() : B = g.g.XMLHttpRequest ? new g.g.XMLHttpRequest() : new g.g.ActiveXObject("Microsoft.XMLHTTP");
|
|
388
388
|
for (var R in r)
|
|
389
389
|
r.hasOwnProperty(R) && (I.length > 0 && (I += "&"), I += encodeURIComponent(R) + "=" + encodeURIComponent(r[R]));
|
|
390
|
-
I.length > 0 && (I = "?" + I), B.open("POST",
|
|
390
|
+
I.length > 0 && (I = "?" + I), B.open("POST", n + I, !0), "withCredentials" in B && (B.withCredentials = !this._config.disableWithCredentials), B.setRequestHeader("X-Requested-With", "XMLHttpRequest"), B.setRequestHeader("Content-Type", "application/json");
|
|
391
391
|
for (var X in c)
|
|
392
392
|
c.hasOwnProperty(X) && B.setRequestHeader(X, c[X]);
|
|
393
393
|
return B.onreadystatechange = function() {
|
|
@@ -433,24 +433,24 @@ function kt() {
|
|
|
433
433
|
}
|
|
434
434
|
}, {
|
|
435
435
|
key: "_setFormat",
|
|
436
|
-
value: function(
|
|
437
|
-
if (!this._formatOverride(
|
|
438
|
-
if (
|
|
436
|
+
value: function(n) {
|
|
437
|
+
if (!this._formatOverride(n)) {
|
|
438
|
+
if (n === "protobuf")
|
|
439
439
|
throw new Error("not implemented by JSON only Centrifuge client – use client with Protobuf");
|
|
440
440
|
this._binary = !1, this._methodType = T.JsonMethodType, this._pushType = T.JsonPushType, this._encoder = new T.JsonEncoder(), this._decoder = new T.JsonDecoder();
|
|
441
441
|
}
|
|
442
442
|
}
|
|
443
443
|
}, {
|
|
444
444
|
key: "_formatOverride",
|
|
445
|
-
value: function(
|
|
445
|
+
value: function(n) {
|
|
446
446
|
return !1;
|
|
447
447
|
}
|
|
448
448
|
}, {
|
|
449
449
|
key: "_configure",
|
|
450
|
-
value: function(
|
|
450
|
+
value: function(n) {
|
|
451
451
|
if (!("Promise" in g.g))
|
|
452
452
|
throw new Error("Promise polyfill required");
|
|
453
|
-
if ((0, E.extend)(this._config,
|
|
453
|
+
if ((0, E.extend)(this._config, n || {}), this._debug("centrifuge config", this._config), !this._url)
|
|
454
454
|
throw new Error("url required");
|
|
455
455
|
var r = (0, E.startsWith)(this._url, "ws") && this._url.indexOf("format=protobuf") > -1;
|
|
456
456
|
if (r || this._config.protocol === "protobuf")
|
|
@@ -474,8 +474,8 @@ function kt() {
|
|
|
474
474
|
}
|
|
475
475
|
}, {
|
|
476
476
|
key: "_setStatus",
|
|
477
|
-
value: function(
|
|
478
|
-
this._status !==
|
|
477
|
+
value: function(n) {
|
|
478
|
+
this._status !== n && (this._debug("Status", this._status, "->", n), this._status = n);
|
|
479
479
|
}
|
|
480
480
|
}, {
|
|
481
481
|
key: "_isDisconnected",
|
|
@@ -505,24 +505,24 @@ function kt() {
|
|
|
505
505
|
}, {
|
|
506
506
|
key: "_getRetryInterval",
|
|
507
507
|
value: function() {
|
|
508
|
-
var
|
|
509
|
-
return this._retries += 1,
|
|
508
|
+
var n = (0, E.backoff)(this._retries, this._config.minRetry, this._config.maxRetry);
|
|
509
|
+
return this._retries += 1, n;
|
|
510
510
|
}
|
|
511
511
|
}, {
|
|
512
512
|
key: "_abortInflightXHRs",
|
|
513
513
|
value: function() {
|
|
514
|
-
for (var
|
|
514
|
+
for (var n in this._xhrs) {
|
|
515
515
|
try {
|
|
516
|
-
this._xhrs[
|
|
516
|
+
this._xhrs[n].abort();
|
|
517
517
|
} catch (r) {
|
|
518
518
|
this._debug("error aborting xhr", r);
|
|
519
519
|
}
|
|
520
|
-
delete this._xhrs[
|
|
520
|
+
delete this._xhrs[n];
|
|
521
521
|
}
|
|
522
522
|
}
|
|
523
523
|
}, {
|
|
524
524
|
key: "_clearConnectedState",
|
|
525
|
-
value: function(
|
|
525
|
+
value: function(n) {
|
|
526
526
|
this._clientID = null, this._stopPing();
|
|
527
527
|
for (var r in this._callbacks)
|
|
528
528
|
if (this._callbacks.hasOwnProperty(r)) {
|
|
@@ -539,7 +539,7 @@ function kt() {
|
|
|
539
539
|
for (var y in this._subs)
|
|
540
540
|
if (this._subs.hasOwnProperty(y)) {
|
|
541
541
|
var v = this._subs[y];
|
|
542
|
-
|
|
542
|
+
n ? (v._isSuccess() && (v._triggerUnsubscribe(), v._recover = !0), v._shouldResubscribe() && v._setSubscribing()) : v._setUnsubscribed();
|
|
543
543
|
}
|
|
544
544
|
this._abortInflightXHRs(), this._refreshTimeout !== null && (clearTimeout(this._refreshTimeout), this._refreshTimeout = null);
|
|
545
545
|
for (var I in this._subRefreshTimeouts)
|
|
@@ -553,11 +553,11 @@ function kt() {
|
|
|
553
553
|
}
|
|
554
554
|
}, {
|
|
555
555
|
key: "_transportSend",
|
|
556
|
-
value: function(
|
|
557
|
-
if (!
|
|
556
|
+
value: function(n) {
|
|
557
|
+
if (!n.length)
|
|
558
558
|
return !0;
|
|
559
559
|
if (!this._isTransportOpen()) {
|
|
560
|
-
for (var r in
|
|
560
|
+
for (var r in n) {
|
|
561
561
|
var c = r.id;
|
|
562
562
|
if (c in this._callbacks) {
|
|
563
563
|
var l = this._callbacks[c];
|
|
@@ -570,7 +570,7 @@ function kt() {
|
|
|
570
570
|
}
|
|
571
571
|
return !1;
|
|
572
572
|
}
|
|
573
|
-
return this._transport.send(this._encoder.encodeCommands(
|
|
573
|
+
return this._transport.send(this._encoder.encodeCommands(n)), !0;
|
|
574
574
|
}
|
|
575
575
|
}, {
|
|
576
576
|
key: "_getSubProtocol",
|
|
@@ -580,7 +580,7 @@ function kt() {
|
|
|
580
580
|
}, {
|
|
581
581
|
key: "_setupTransport",
|
|
582
582
|
value: function() {
|
|
583
|
-
var
|
|
583
|
+
var n = this;
|
|
584
584
|
if (this._isSockjs = !1, this._sockjs !== null) {
|
|
585
585
|
var r = {
|
|
586
586
|
transports: this._config.sockjsTransports
|
|
@@ -594,72 +594,72 @@ function kt() {
|
|
|
594
594
|
c !== "" ? this._transport = new this._websocket(this._url, c) : this._transport = new this._websocket(this._url), this._binary === !0 && (this._transport.binaryType = "arraybuffer");
|
|
595
595
|
}
|
|
596
596
|
this._transport.onopen = function() {
|
|
597
|
-
|
|
598
|
-
return
|
|
599
|
-
}) :
|
|
597
|
+
n._transportClosed = !1, n._isSockjs ? (n._transportName = "sockjs-" + n._transport.transport, n._transport.onheartbeat = function() {
|
|
598
|
+
return n._restartPing();
|
|
599
|
+
}) : n._transportName = "websocket";
|
|
600
600
|
var l = {
|
|
601
601
|
// method: this._methodType.CONNECT
|
|
602
602
|
};
|
|
603
|
-
(
|
|
603
|
+
(n._token || n._connectData || n._config.name || n._config.version) && (l.params = {}), n._token && (l.params.token = n._token), n._connectData && (l.params.data = n._connectData), n._config.name && (l.params.name = n._config.name), n._config.version && (l.params.version = n._config.version);
|
|
604
604
|
var y = {}, v = !1;
|
|
605
|
-
for (var I in
|
|
606
|
-
if (
|
|
605
|
+
for (var I in n._serverSubs)
|
|
606
|
+
if (n._serverSubs.hasOwnProperty(I) && n._serverSubs[I].recoverable) {
|
|
607
607
|
v = !0;
|
|
608
608
|
var B = {
|
|
609
609
|
recover: !0
|
|
610
610
|
};
|
|
611
|
-
|
|
611
|
+
n._serverSubs[I].seq || n._serverSubs[I].gen ? (n._serverSubs[I].seq && (B.seq = n._serverSubs[I].seq), n._serverSubs[I].gen && (B.gen = n._serverSubs[I].gen)) : n._serverSubs[I].offset && (B.offset = n._serverSubs[I].offset), n._serverSubs[I].epoch && (B.epoch = n._serverSubs[I].epoch), y[I] = B;
|
|
612
612
|
}
|
|
613
|
-
v && (l.params || (l.params = {}), l.params.subs = y),
|
|
614
|
-
|
|
613
|
+
v && (l.params || (l.params = {}), l.params.subs = y), n._latencyStart = /* @__PURE__ */ new Date(), n._call(l).then(function(R) {
|
|
614
|
+
n._connectResponse(n._decoder.decodeCommandResult(n._methodType.CONNECT, R.result), v), R.next && R.next();
|
|
615
615
|
}, function(R) {
|
|
616
616
|
var X = R.error;
|
|
617
|
-
X.code === 109 && (
|
|
617
|
+
X.code === 109 && (n._refreshRequired = !0), n._disconnect("connect error", !0), R.next && R.next();
|
|
618
618
|
});
|
|
619
619
|
}, this._transport.onerror = function(l) {
|
|
620
|
-
|
|
620
|
+
n._debug("transport level error", l);
|
|
621
621
|
}, this._transport.onclose = function(l) {
|
|
622
|
-
|
|
622
|
+
n._transportClosed = !0;
|
|
623
623
|
var y = N, v = !0;
|
|
624
624
|
if (l && "reason" in l && l.reason)
|
|
625
625
|
try {
|
|
626
626
|
var I = JSON.parse(l.reason);
|
|
627
|
-
|
|
627
|
+
n._debug("reason is an advice object", I), y = I.reason, v = I.reconnect;
|
|
628
628
|
} catch {
|
|
629
|
-
y = l.reason,
|
|
629
|
+
y = l.reason, n._debug("reason is a plain string", y);
|
|
630
630
|
}
|
|
631
|
-
if (
|
|
631
|
+
if (n._config.onTransportClose !== null && n._config.onTransportClose({
|
|
632
632
|
event: l,
|
|
633
633
|
reason: y,
|
|
634
634
|
reconnect: v
|
|
635
|
-
}),
|
|
636
|
-
|
|
637
|
-
var B =
|
|
638
|
-
|
|
639
|
-
|
|
635
|
+
}), n._disconnect(y, v), n._reconnect === !0) {
|
|
636
|
+
n._reconnecting = !0;
|
|
637
|
+
var B = n._getRetryInterval();
|
|
638
|
+
n._debug("reconnect after " + B + " milliseconds"), setTimeout(function() {
|
|
639
|
+
n._reconnect === !0 && (n._refreshRequired ? n._refresh() : n._connect());
|
|
640
640
|
}, B);
|
|
641
641
|
}
|
|
642
642
|
}, this._transport.onmessage = function(l) {
|
|
643
|
-
|
|
643
|
+
n._dataReceived(l.data);
|
|
644
644
|
};
|
|
645
645
|
}
|
|
646
646
|
}, {
|
|
647
647
|
key: "rpc",
|
|
648
|
-
value: function(
|
|
649
|
-
return this._rpc("",
|
|
648
|
+
value: function(n) {
|
|
649
|
+
return this._rpc("", n);
|
|
650
650
|
}
|
|
651
651
|
}, {
|
|
652
652
|
key: "namedRPC",
|
|
653
|
-
value: function(
|
|
654
|
-
return this._rpc(
|
|
653
|
+
value: function(n, r) {
|
|
654
|
+
return this._rpc(n, r);
|
|
655
655
|
}
|
|
656
656
|
}, {
|
|
657
657
|
key: "_rpc",
|
|
658
|
-
value: function(
|
|
658
|
+
value: function(n, r) {
|
|
659
659
|
var c = {
|
|
660
660
|
data: r
|
|
661
661
|
};
|
|
662
|
-
|
|
662
|
+
n !== "" && (c.method = n);
|
|
663
663
|
var l = {
|
|
664
664
|
method: this._methodType.RPC,
|
|
665
665
|
params: c
|
|
@@ -670,11 +670,11 @@ function kt() {
|
|
|
670
670
|
}
|
|
671
671
|
}, {
|
|
672
672
|
key: "send",
|
|
673
|
-
value: function(
|
|
673
|
+
value: function(n) {
|
|
674
674
|
var r = {
|
|
675
675
|
method: this._methodType.SEND,
|
|
676
676
|
params: {
|
|
677
|
-
data:
|
|
677
|
+
data: n
|
|
678
678
|
}
|
|
679
679
|
};
|
|
680
680
|
if (!this.isConnected())
|
|
@@ -684,9 +684,9 @@ function kt() {
|
|
|
684
684
|
}
|
|
685
685
|
}, {
|
|
686
686
|
key: "_getHistoryParams",
|
|
687
|
-
value: function(
|
|
687
|
+
value: function(n, r) {
|
|
688
688
|
var c = {
|
|
689
|
-
channel:
|
|
689
|
+
channel: n
|
|
690
690
|
};
|
|
691
691
|
return r !== void 0 && (r.since && (c.since = {
|
|
692
692
|
offset: r.since.offset
|
|
@@ -694,11 +694,11 @@ function kt() {
|
|
|
694
694
|
}
|
|
695
695
|
}, {
|
|
696
696
|
key: "_methodCall",
|
|
697
|
-
value: function(
|
|
697
|
+
value: function(n, r) {
|
|
698
698
|
var c = this;
|
|
699
699
|
return this.isConnected() ? new Promise(function(l, y) {
|
|
700
|
-
c._call(
|
|
701
|
-
l(r(c._decoder.decodeCommandResult(
|
|
700
|
+
c._call(n).then(function(v) {
|
|
701
|
+
l(r(c._decoder.decodeCommandResult(n.method, v.result))), v.next && v.next();
|
|
702
702
|
}, function(v) {
|
|
703
703
|
y(v.error), v.next && v.next();
|
|
704
704
|
});
|
|
@@ -706,11 +706,11 @@ function kt() {
|
|
|
706
706
|
}
|
|
707
707
|
}, {
|
|
708
708
|
key: "publish",
|
|
709
|
-
value: function(
|
|
709
|
+
value: function(n, r) {
|
|
710
710
|
var c = {
|
|
711
711
|
method: this._methodType.PUBLISH,
|
|
712
712
|
params: {
|
|
713
|
-
channel:
|
|
713
|
+
channel: n,
|
|
714
714
|
data: r
|
|
715
715
|
}
|
|
716
716
|
};
|
|
@@ -720,8 +720,8 @@ function kt() {
|
|
|
720
720
|
}
|
|
721
721
|
}, {
|
|
722
722
|
key: "history",
|
|
723
|
-
value: function(
|
|
724
|
-
var c = this._getHistoryParams(
|
|
723
|
+
value: function(n, r) {
|
|
724
|
+
var c = this._getHistoryParams(n, r), l = {
|
|
725
725
|
method: this._methodType.HISTORY,
|
|
726
726
|
params: c
|
|
727
727
|
};
|
|
@@ -735,11 +735,11 @@ function kt() {
|
|
|
735
735
|
}
|
|
736
736
|
}, {
|
|
737
737
|
key: "presence",
|
|
738
|
-
value: function(
|
|
738
|
+
value: function(n) {
|
|
739
739
|
var r = {
|
|
740
740
|
method: this._methodType.PRESENCE,
|
|
741
741
|
params: {
|
|
742
|
-
channel:
|
|
742
|
+
channel: n
|
|
743
743
|
}
|
|
744
744
|
};
|
|
745
745
|
return this._methodCall(r, function(c) {
|
|
@@ -750,11 +750,11 @@ function kt() {
|
|
|
750
750
|
}
|
|
751
751
|
}, {
|
|
752
752
|
key: "presenceStats",
|
|
753
|
-
value: function(
|
|
753
|
+
value: function(n) {
|
|
754
754
|
var r = {
|
|
755
755
|
method: this._methodType.PRESENCE_STATS,
|
|
756
756
|
params: {
|
|
757
|
-
channel:
|
|
757
|
+
channel: n
|
|
758
758
|
}
|
|
759
759
|
};
|
|
760
760
|
return this._methodCall(r, function(c) {
|
|
@@ -766,8 +766,8 @@ function kt() {
|
|
|
766
766
|
}
|
|
767
767
|
}, {
|
|
768
768
|
key: "_dataReceived",
|
|
769
|
-
value: function(
|
|
770
|
-
var r = this, c = this._decoder.decodeReplies(
|
|
769
|
+
value: function(n) {
|
|
770
|
+
var r = this, c = this._decoder.decodeReplies(n);
|
|
771
771
|
this._dispatchPromise = this._dispatchPromise.then(function() {
|
|
772
772
|
var l;
|
|
773
773
|
r._dispatchPromise = new Promise(function(y) {
|
|
@@ -777,13 +777,13 @@ function kt() {
|
|
|
777
777
|
}
|
|
778
778
|
}, {
|
|
779
779
|
key: "_dispatchSynchronized",
|
|
780
|
-
value: function(
|
|
780
|
+
value: function(n, r) {
|
|
781
781
|
var c = this, l = Promise.resolve(), y = function(B) {
|
|
782
|
-
|
|
783
|
-
return c._dispatchReply(
|
|
782
|
+
n.hasOwnProperty(B) && (l = l.then(function() {
|
|
783
|
+
return c._dispatchReply(n[B]);
|
|
784
784
|
}));
|
|
785
785
|
};
|
|
786
|
-
for (var v in
|
|
786
|
+
for (var v in n)
|
|
787
787
|
y(v);
|
|
788
788
|
l = l.then(function() {
|
|
789
789
|
r();
|
|
@@ -791,21 +791,21 @@ function kt() {
|
|
|
791
791
|
}
|
|
792
792
|
}, {
|
|
793
793
|
key: "_dispatchReply",
|
|
794
|
-
value: function(
|
|
794
|
+
value: function(n) {
|
|
795
795
|
var r, c = new Promise(function(y) {
|
|
796
796
|
r = y;
|
|
797
797
|
});
|
|
798
|
-
if (
|
|
798
|
+
if (n == null)
|
|
799
799
|
return this._debug("dispatch: got undefined or null reply"), r(), c;
|
|
800
|
-
var l =
|
|
801
|
-
return l && l > 0 ? this._handleReply(
|
|
800
|
+
var l = n.id;
|
|
801
|
+
return l && l > 0 ? this._handleReply(n, r) : this._handlePush(n.result, r), c;
|
|
802
802
|
}
|
|
803
803
|
}, {
|
|
804
804
|
key: "_call",
|
|
805
|
-
value: function(
|
|
805
|
+
value: function(n) {
|
|
806
806
|
var r = this;
|
|
807
807
|
return new Promise(function(c, l) {
|
|
808
|
-
var y = r._addMessage(
|
|
808
|
+
var y = r._addMessage(n);
|
|
809
809
|
r._registerCall(y, c, l);
|
|
810
810
|
});
|
|
811
811
|
}
|
|
@@ -820,19 +820,19 @@ function kt() {
|
|
|
820
820
|
}
|
|
821
821
|
}, {
|
|
822
822
|
key: "_disconnect",
|
|
823
|
-
value: function(
|
|
823
|
+
value: function(n, r) {
|
|
824
824
|
var c = r || !1;
|
|
825
825
|
if (c === !1 && (this._reconnect = !1), this._isDisconnected()) {
|
|
826
826
|
c || this._clearConnectedState(c);
|
|
827
827
|
return;
|
|
828
828
|
}
|
|
829
|
-
if (this._clearConnectedState(c), this._debug("disconnected:",
|
|
829
|
+
if (this._clearConnectedState(c), this._debug("disconnected:", n, r), this._setStatus("disconnected"), this._refreshTimeout && (clearTimeout(this._refreshTimeout), this._refreshTimeout = null), this._reconnecting === !1) {
|
|
830
830
|
for (var l in this._serverSubs)
|
|
831
831
|
this._serverSubs.hasOwnProperty(l) && this.emit("unsubscribe", {
|
|
832
832
|
channel: l
|
|
833
833
|
});
|
|
834
834
|
this.emit("disconnect", {
|
|
835
|
-
reason:
|
|
835
|
+
reason: n,
|
|
836
836
|
reconnect: c
|
|
837
837
|
});
|
|
838
838
|
}
|
|
@@ -846,43 +846,43 @@ function kt() {
|
|
|
846
846
|
}, {
|
|
847
847
|
key: "_refresh",
|
|
848
848
|
value: function() {
|
|
849
|
-
var
|
|
849
|
+
var n = this;
|
|
850
850
|
if (this._debug("refresh token"), this._config.refreshAttempts === 0) {
|
|
851
851
|
this._debug("refresh attempts set to 0, do not send refresh request at all"), this._refreshFailed();
|
|
852
852
|
return;
|
|
853
853
|
}
|
|
854
854
|
this._refreshTimeout !== null && (clearTimeout(this._refreshTimeout), this._refreshTimeout = null);
|
|
855
855
|
var r = this._clientID, c = this._newXHRID(), l = function(B) {
|
|
856
|
-
if (c in
|
|
856
|
+
if (c in n._xhrs && delete n._xhrs[c], n._clientID === r) {
|
|
857
857
|
if (B.error || B.status !== 200) {
|
|
858
|
-
if (B.error ?
|
|
859
|
-
|
|
858
|
+
if (B.error ? n._debug("error refreshing connection token", B.error) : n._debug("error refreshing connection token: wrong status code", B.status), n._numRefreshFailed++, n._refreshTimeout !== null && (clearTimeout(n._refreshTimeout), n._refreshTimeout = null), n._config.refreshAttempts !== null && n._numRefreshFailed >= n._config.refreshAttempts) {
|
|
859
|
+
n._refreshFailed();
|
|
860
860
|
return;
|
|
861
861
|
}
|
|
862
|
-
var R = Math.round(Math.random() * 1e3 * Math.max(
|
|
863
|
-
|
|
864
|
-
return
|
|
862
|
+
var R = Math.round(Math.random() * 1e3 * Math.max(n._numRefreshFailed, 20)), X = n._config.refreshInterval + R;
|
|
863
|
+
n._refreshTimeout = setTimeout(function() {
|
|
864
|
+
return n._refresh();
|
|
865
865
|
}, X);
|
|
866
866
|
return;
|
|
867
867
|
}
|
|
868
|
-
if (
|
|
869
|
-
|
|
868
|
+
if (n._numRefreshFailed = 0, n._token = B.data.token, !n._token) {
|
|
869
|
+
n._refreshFailed();
|
|
870
870
|
return;
|
|
871
871
|
}
|
|
872
|
-
if (
|
|
873
|
-
|
|
872
|
+
if (n._isDisconnected() && n._reconnect)
|
|
873
|
+
n._debug("token refreshed, connect from scratch"), n._connect();
|
|
874
874
|
else {
|
|
875
|
-
|
|
875
|
+
n._debug("send refreshed token");
|
|
876
876
|
var U = {
|
|
877
|
-
method:
|
|
877
|
+
method: n._methodType.REFRESH,
|
|
878
878
|
params: {
|
|
879
|
-
token:
|
|
879
|
+
token: n._token
|
|
880
880
|
}
|
|
881
881
|
};
|
|
882
|
-
|
|
883
|
-
|
|
882
|
+
n._call(U).then(function(D) {
|
|
883
|
+
n._refreshResponse(n._decoder.decodeCommandResult(n._methodType.REFRESH, D.result)), D.next && D.next();
|
|
884
884
|
}, function(D) {
|
|
885
|
-
|
|
885
|
+
n._refreshError(D.error), D.next && D.next();
|
|
886
886
|
});
|
|
887
887
|
}
|
|
888
888
|
}
|
|
@@ -897,9 +897,9 @@ function kt() {
|
|
|
897
897
|
}
|
|
898
898
|
}, {
|
|
899
899
|
key: "_refreshError",
|
|
900
|
-
value: function(
|
|
900
|
+
value: function(n) {
|
|
901
901
|
var r = this;
|
|
902
|
-
this._debug("refresh error",
|
|
902
|
+
this._debug("refresh error", n), this._refreshTimeout && (clearTimeout(this._refreshTimeout), this._refreshTimeout = null);
|
|
903
903
|
var c = this._config.refreshInterval + Math.round(Math.random() * 1e3);
|
|
904
904
|
this._refreshTimeout = setTimeout(function() {
|
|
905
905
|
return r._refresh();
|
|
@@ -907,11 +907,11 @@ function kt() {
|
|
|
907
907
|
}
|
|
908
908
|
}, {
|
|
909
909
|
key: "_refreshResponse",
|
|
910
|
-
value: function(
|
|
910
|
+
value: function(n) {
|
|
911
911
|
var r = this;
|
|
912
|
-
this._refreshTimeout && (clearTimeout(this._refreshTimeout), this._refreshTimeout = null),
|
|
912
|
+
this._refreshTimeout && (clearTimeout(this._refreshTimeout), this._refreshTimeout = null), n.expires && (this._clientID = n.client, this._refreshTimeout = setTimeout(function() {
|
|
913
913
|
return r._refresh();
|
|
914
|
-
}, this._getTTLMilliseconds(
|
|
914
|
+
}, this._getTTLMilliseconds(n.ttl)));
|
|
915
915
|
}
|
|
916
916
|
}, {
|
|
917
917
|
key: "_newXHRID",
|
|
@@ -920,10 +920,10 @@ function kt() {
|
|
|
920
920
|
}
|
|
921
921
|
}, {
|
|
922
922
|
key: "_subRefresh",
|
|
923
|
-
value: function(
|
|
923
|
+
value: function(n) {
|
|
924
924
|
var r = this;
|
|
925
|
-
if (this._debug("refresh subscription token for channel",
|
|
926
|
-
this._clearSubRefreshTimeout(
|
|
925
|
+
if (this._debug("refresh subscription token for channel", n), this._subRefreshTimeouts[n] !== void 0)
|
|
926
|
+
this._clearSubRefreshTimeout(n);
|
|
927
927
|
else
|
|
928
928
|
return;
|
|
929
929
|
var c = this._clientID, l = this._newXHRID(), y = function(R) {
|
|
@@ -934,25 +934,25 @@ function kt() {
|
|
|
934
934
|
var D = R.data.channels[U];
|
|
935
935
|
D.channel && (X[D.channel] = D.token);
|
|
936
936
|
}
|
|
937
|
-
var re = X[
|
|
937
|
+
var re = X[n];
|
|
938
938
|
if (re) {
|
|
939
939
|
var Pe = {
|
|
940
940
|
method: r._methodType.SUB_REFRESH,
|
|
941
941
|
params: {
|
|
942
|
-
channel:
|
|
942
|
+
channel: n,
|
|
943
943
|
token: re
|
|
944
944
|
}
|
|
945
|
-
}, le = r._getSub(
|
|
945
|
+
}, le = r._getSub(n);
|
|
946
946
|
le !== null && r._call(Pe).then(function(W) {
|
|
947
|
-
r._subRefreshResponse(
|
|
947
|
+
r._subRefreshResponse(n, r._decoder.decodeCommandResult(r._methodType.SUB_REFRESH, W.result)), W.next && W.next();
|
|
948
948
|
}, function(W) {
|
|
949
|
-
r._subRefreshError(
|
|
949
|
+
r._subRefreshError(n, W.error), W.next && W.next();
|
|
950
950
|
});
|
|
951
951
|
}
|
|
952
952
|
}
|
|
953
953
|
}, v = {
|
|
954
954
|
client: this._clientID,
|
|
955
|
-
channels: [
|
|
955
|
+
channels: [n]
|
|
956
956
|
};
|
|
957
957
|
if (this._config.onPrivateSubscribe !== null)
|
|
958
958
|
this._config.onPrivateSubscribe({
|
|
@@ -965,56 +965,56 @@ function kt() {
|
|
|
965
965
|
}
|
|
966
966
|
}, {
|
|
967
967
|
key: "_clearSubRefreshTimeout",
|
|
968
|
-
value: function(
|
|
969
|
-
this._subRefreshTimeouts[
|
|
968
|
+
value: function(n) {
|
|
969
|
+
this._subRefreshTimeouts[n] !== void 0 && (clearTimeout(this._subRefreshTimeouts[n]), delete this._subRefreshTimeouts[n]);
|
|
970
970
|
}
|
|
971
971
|
}, {
|
|
972
972
|
key: "_subRefreshError",
|
|
973
|
-
value: function(
|
|
973
|
+
value: function(n, r) {
|
|
974
974
|
var c = this;
|
|
975
|
-
this._debug("subscription refresh error",
|
|
976
|
-
var l = this._getSub(
|
|
975
|
+
this._debug("subscription refresh error", n, r), this._clearSubRefreshTimeout(n);
|
|
976
|
+
var l = this._getSub(n);
|
|
977
977
|
if (l !== null) {
|
|
978
978
|
var y = Math.round(Math.random() * 1e3), v = setTimeout(function() {
|
|
979
|
-
return c._subRefresh(
|
|
979
|
+
return c._subRefresh(n);
|
|
980
980
|
}, this._config.subRefreshInterval + y);
|
|
981
|
-
this._subRefreshTimeouts[
|
|
981
|
+
this._subRefreshTimeouts[n] = v;
|
|
982
982
|
}
|
|
983
983
|
}
|
|
984
984
|
}, {
|
|
985
985
|
key: "_subRefreshResponse",
|
|
986
|
-
value: function(
|
|
986
|
+
value: function(n, r) {
|
|
987
987
|
var c = this;
|
|
988
|
-
this._debug("subscription refresh success",
|
|
989
|
-
var l = this._getSub(
|
|
988
|
+
this._debug("subscription refresh success", n), this._clearSubRefreshTimeout(n);
|
|
989
|
+
var l = this._getSub(n);
|
|
990
990
|
if (l !== null && r.expires === !0) {
|
|
991
991
|
var y = setTimeout(function() {
|
|
992
|
-
return c._subRefresh(
|
|
992
|
+
return c._subRefresh(n);
|
|
993
993
|
}, this._getTTLMilliseconds(r.ttl));
|
|
994
|
-
this._subRefreshTimeouts[
|
|
994
|
+
this._subRefreshTimeouts[n] = y;
|
|
995
995
|
}
|
|
996
996
|
}
|
|
997
997
|
}, {
|
|
998
998
|
key: "_subscribe",
|
|
999
|
-
value: function(
|
|
999
|
+
value: function(n, r) {
|
|
1000
1000
|
var c = this;
|
|
1001
|
-
this._debug("subscribing on",
|
|
1002
|
-
var l =
|
|
1003
|
-
if (l in this._subs || (this._subs[l] =
|
|
1004
|
-
|
|
1001
|
+
this._debug("subscribing on", n.channel);
|
|
1002
|
+
var l = n.channel;
|
|
1003
|
+
if (l in this._subs || (this._subs[l] = n), !this.isConnected()) {
|
|
1004
|
+
n._setNew();
|
|
1005
1005
|
return;
|
|
1006
1006
|
}
|
|
1007
|
-
|
|
1007
|
+
n._setSubscribing(r);
|
|
1008
1008
|
var y = {
|
|
1009
1009
|
method: this._methodType.SUBSCRIBE,
|
|
1010
1010
|
params: {
|
|
1011
1011
|
channel: l
|
|
1012
1012
|
}
|
|
1013
1013
|
};
|
|
1014
|
-
if (
|
|
1015
|
-
this._isSubscribeBatching ? this._privateChannels[l] = !0 : (this.startSubscribeBatching(), this._subscribe(
|
|
1014
|
+
if (n._subscribeData && (y.params.data = n._subscribeData), (0, E.startsWith)(l, this._config.privateChannelPrefix))
|
|
1015
|
+
this._isSubscribeBatching ? this._privateChannels[l] = !0 : (this.startSubscribeBatching(), this._subscribe(n), this.stopSubscribeBatching());
|
|
1016
1016
|
else {
|
|
1017
|
-
var v =
|
|
1017
|
+
var v = n._needRecover();
|
|
1018
1018
|
if (v === !0) {
|
|
1019
1019
|
y.params.recover = !0;
|
|
1020
1020
|
var I = this._getLastSeq(l), B = this._getLastGen(l);
|
|
@@ -1036,43 +1036,43 @@ function kt() {
|
|
|
1036
1036
|
}
|
|
1037
1037
|
}, {
|
|
1038
1038
|
key: "_unsubscribe",
|
|
1039
|
-
value: function(
|
|
1040
|
-
delete this._subs[
|
|
1039
|
+
value: function(n) {
|
|
1040
|
+
delete this._subs[n.channel], delete this._lastOffset[n.channel], delete this._lastSeq[n.channel], delete this._lastGen[n.channel], this.isConnected() && this._addMessage({
|
|
1041
1041
|
method: this._methodType.UNSUBSCRIBE,
|
|
1042
1042
|
params: {
|
|
1043
|
-
channel:
|
|
1043
|
+
channel: n.channel
|
|
1044
1044
|
}
|
|
1045
1045
|
});
|
|
1046
1046
|
}
|
|
1047
1047
|
}, {
|
|
1048
1048
|
key: "_getTTLMilliseconds",
|
|
1049
|
-
value: function(
|
|
1050
|
-
return Math.min(
|
|
1049
|
+
value: function(n) {
|
|
1050
|
+
return Math.min(n * 1e3, 2147483647);
|
|
1051
1051
|
}
|
|
1052
1052
|
}, {
|
|
1053
1053
|
key: "getSub",
|
|
1054
|
-
value: function(
|
|
1055
|
-
return this._getSub(
|
|
1054
|
+
value: function(n) {
|
|
1055
|
+
return this._getSub(n);
|
|
1056
1056
|
}
|
|
1057
1057
|
}, {
|
|
1058
1058
|
key: "_getSub",
|
|
1059
|
-
value: function(
|
|
1060
|
-
var r = this._subs[
|
|
1059
|
+
value: function(n) {
|
|
1060
|
+
var r = this._subs[n];
|
|
1061
1061
|
return r || null;
|
|
1062
1062
|
}
|
|
1063
1063
|
}, {
|
|
1064
1064
|
key: "_isServerSub",
|
|
1065
|
-
value: function(
|
|
1066
|
-
return this._serverSubs[
|
|
1065
|
+
value: function(n) {
|
|
1066
|
+
return this._serverSubs[n] !== void 0;
|
|
1067
1067
|
}
|
|
1068
1068
|
}, {
|
|
1069
1069
|
key: "_connectResponse",
|
|
1070
|
-
value: function(
|
|
1070
|
+
value: function(n, r) {
|
|
1071
1071
|
var c = this, l = this._reconnecting;
|
|
1072
1072
|
if (this._reconnecting = !1, this._resetRetry(), this._refreshRequired = !1, !this.isConnected()) {
|
|
1073
|
-
this._latencyStart !== null && (this._latency = (/* @__PURE__ */ new Date()).getTime() - this._latencyStart.getTime(), this._latencyStart = null), this._clientID =
|
|
1073
|
+
this._latencyStart !== null && (this._latency = (/* @__PURE__ */ new Date()).getTime() - this._latencyStart.getTime(), this._latencyStart = null), this._clientID = n.client, this._setStatus("connected"), this._refreshTimeout && clearTimeout(this._refreshTimeout), n.expires && (this._refreshTimeout = setTimeout(function() {
|
|
1074
1074
|
return c._refresh();
|
|
1075
|
-
}, this._getTTLMilliseconds(
|
|
1075
|
+
}, this._getTTLMilliseconds(n.ttl))), this.startBatching(), this.startSubscribeBatching();
|
|
1076
1076
|
for (var y in this._subs)
|
|
1077
1077
|
if (this._subs.hasOwnProperty(y)) {
|
|
1078
1078
|
var v = this._subs[y];
|
|
@@ -1080,27 +1080,27 @@ function kt() {
|
|
|
1080
1080
|
}
|
|
1081
1081
|
this.stopSubscribeBatching(), this.stopBatching(), this._startPing();
|
|
1082
1082
|
var I = {
|
|
1083
|
-
client:
|
|
1083
|
+
client: n.client,
|
|
1084
1084
|
transport: this._transportName,
|
|
1085
1085
|
latency: this._latency
|
|
1086
1086
|
};
|
|
1087
|
-
|
|
1087
|
+
n.data && (I.data = n.data), this.emit("connect", I), n.subs && this._processServerSubs(n.subs);
|
|
1088
1088
|
}
|
|
1089
1089
|
}
|
|
1090
1090
|
}, {
|
|
1091
1091
|
key: "_processServerSubs",
|
|
1092
|
-
value: function(
|
|
1093
|
-
for (var r in
|
|
1094
|
-
if (
|
|
1095
|
-
var c =
|
|
1092
|
+
value: function(n) {
|
|
1093
|
+
for (var r in n)
|
|
1094
|
+
if (n.hasOwnProperty(r)) {
|
|
1095
|
+
var c = n[r], l = this._serverSubs[r] !== void 0, y = {
|
|
1096
1096
|
channel: r,
|
|
1097
1097
|
isResubscribe: l
|
|
1098
1098
|
};
|
|
1099
1099
|
y = this._expandSubscribeContext(y, c), this.emit("subscribe", y);
|
|
1100
1100
|
}
|
|
1101
|
-
for (var v in
|
|
1102
|
-
if (
|
|
1103
|
-
var I =
|
|
1101
|
+
for (var v in n)
|
|
1102
|
+
if (n.hasOwnProperty(v)) {
|
|
1103
|
+
var I = n[v];
|
|
1104
1104
|
if (I.recovered) {
|
|
1105
1105
|
var B = I.publications;
|
|
1106
1106
|
if (B && B.length > 0) {
|
|
@@ -1126,15 +1126,15 @@ function kt() {
|
|
|
1126
1126
|
}, {
|
|
1127
1127
|
key: "_startPing",
|
|
1128
1128
|
value: function() {
|
|
1129
|
-
var
|
|
1129
|
+
var n = this;
|
|
1130
1130
|
this._config.ping !== !0 || this._config.pingInterval <= 0 || this.isConnected() && (this._pingTimeout = setTimeout(function() {
|
|
1131
|
-
if (!
|
|
1132
|
-
|
|
1131
|
+
if (!n.isConnected()) {
|
|
1132
|
+
n._stopPing();
|
|
1133
1133
|
return;
|
|
1134
1134
|
}
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
},
|
|
1135
|
+
n.ping(), n._pongTimeout = setTimeout(function() {
|
|
1136
|
+
n._disconnect("no ping", !0);
|
|
1137
|
+
}, n._config.pongWaitTimeout);
|
|
1138
1138
|
}, this._config.pingInterval));
|
|
1139
1139
|
}
|
|
1140
1140
|
}, {
|
|
@@ -1144,8 +1144,8 @@ function kt() {
|
|
|
1144
1144
|
}
|
|
1145
1145
|
}, {
|
|
1146
1146
|
key: "_subscribeError",
|
|
1147
|
-
value: function(
|
|
1148
|
-
var c = this._getSub(
|
|
1147
|
+
value: function(n, r) {
|
|
1148
|
+
var c = this._getSub(n);
|
|
1149
1149
|
if (c && c._isSubscribing()) {
|
|
1150
1150
|
if (r.code === 0 && r.message === q) {
|
|
1151
1151
|
this._disconnect("timeout", !0);
|
|
@@ -1156,55 +1156,55 @@ function kt() {
|
|
|
1156
1156
|
}
|
|
1157
1157
|
}, {
|
|
1158
1158
|
key: "_expandSubscribeContext",
|
|
1159
|
-
value: function(
|
|
1159
|
+
value: function(n, r) {
|
|
1160
1160
|
var c = !1;
|
|
1161
|
-
"recovered" in r && (c = r.recovered),
|
|
1161
|
+
"recovered" in r && (c = r.recovered), n.recovered = c;
|
|
1162
1162
|
var l = !1;
|
|
1163
1163
|
"positioned" in r && (l = r.positioned);
|
|
1164
1164
|
var y = "";
|
|
1165
1165
|
"epoch" in r && (y = r.epoch);
|
|
1166
1166
|
var v = 0;
|
|
1167
|
-
return "offset" in r && (v = r.offset), l && (
|
|
1167
|
+
return "offset" in r && (v = r.offset), l && (n.streamPosition = {
|
|
1168
1168
|
offset: v,
|
|
1169
1169
|
epoch: y
|
|
1170
|
-
}), r.data && (
|
|
1170
|
+
}), r.data && (n.data = r.data), n;
|
|
1171
1171
|
}
|
|
1172
1172
|
}, {
|
|
1173
1173
|
key: "_subscribeResponse",
|
|
1174
|
-
value: function(
|
|
1175
|
-
var l = this, y = this._getSub(
|
|
1174
|
+
value: function(n, r, c) {
|
|
1175
|
+
var l = this, y = this._getSub(n);
|
|
1176
1176
|
if (y && y._isSubscribing()) {
|
|
1177
1177
|
y._setSubscribeSuccess(c);
|
|
1178
1178
|
var v = c.publications;
|
|
1179
1179
|
if (v && v.length > 0) {
|
|
1180
1180
|
v.length >= 2 && !v[0].offset && !v[1].offset && (v = v.reverse());
|
|
1181
1181
|
for (var I in v)
|
|
1182
|
-
v.hasOwnProperty(I) && this._handlePublication(
|
|
1182
|
+
v.hasOwnProperty(I) && this._handlePublication(n, v[I]);
|
|
1183
1183
|
}
|
|
1184
|
-
if (c.recoverable && (!r || !c.recovered) && (this._lastSeq[
|
|
1184
|
+
if (c.recoverable && (!r || !c.recovered) && (this._lastSeq[n] = c.seq || 0, this._lastGen[n] = c.gen || 0, this._lastOffset[n] = c.offset || 0), this._lastEpoch[n] = c.epoch || "", c.recoverable && (y._recoverable = !0), c.expires === !0) {
|
|
1185
1185
|
var B = setTimeout(function() {
|
|
1186
|
-
return l._subRefresh(
|
|
1186
|
+
return l._subRefresh(n);
|
|
1187
1187
|
}, this._getTTLMilliseconds(c.ttl));
|
|
1188
|
-
this._subRefreshTimeouts[
|
|
1188
|
+
this._subRefreshTimeouts[n] = B;
|
|
1189
1189
|
}
|
|
1190
1190
|
}
|
|
1191
1191
|
}
|
|
1192
1192
|
}, {
|
|
1193
1193
|
key: "_handleReply",
|
|
1194
|
-
value: function(
|
|
1195
|
-
var c =
|
|
1194
|
+
value: function(n, r) {
|
|
1195
|
+
var c = n.id, l = n.result;
|
|
1196
1196
|
if (!(c in this._callbacks)) {
|
|
1197
1197
|
r();
|
|
1198
1198
|
return;
|
|
1199
1199
|
}
|
|
1200
1200
|
var y = this._callbacks[c];
|
|
1201
|
-
if (clearTimeout(this._callbacks[c].timeout), delete this._callbacks[c], (0, E.errorExists)(
|
|
1201
|
+
if (clearTimeout(this._callbacks[c].timeout), delete this._callbacks[c], (0, E.errorExists)(n)) {
|
|
1202
1202
|
var I = y.errback;
|
|
1203
1203
|
if (!I) {
|
|
1204
1204
|
r();
|
|
1205
1205
|
return;
|
|
1206
1206
|
}
|
|
1207
|
-
var B =
|
|
1207
|
+
var B = n.error;
|
|
1208
1208
|
I({
|
|
1209
1209
|
error: B,
|
|
1210
1210
|
next: r
|
|
@@ -1221,42 +1221,42 @@ function kt() {
|
|
|
1221
1221
|
}
|
|
1222
1222
|
}, {
|
|
1223
1223
|
key: "_handleJoin",
|
|
1224
|
-
value: function(
|
|
1224
|
+
value: function(n, r) {
|
|
1225
1225
|
var c = {
|
|
1226
1226
|
info: r.info
|
|
1227
|
-
}, l = this._getSub(
|
|
1227
|
+
}, l = this._getSub(n);
|
|
1228
1228
|
if (!l) {
|
|
1229
|
-
this._isServerSub(
|
|
1229
|
+
this._isServerSub(n) && (c.channel = n, this.emit("join", c));
|
|
1230
1230
|
return;
|
|
1231
1231
|
}
|
|
1232
1232
|
l.emit("join", c);
|
|
1233
1233
|
}
|
|
1234
1234
|
}, {
|
|
1235
1235
|
key: "_handleLeave",
|
|
1236
|
-
value: function(
|
|
1236
|
+
value: function(n, r) {
|
|
1237
1237
|
var c = {
|
|
1238
1238
|
info: r.info
|
|
1239
|
-
}, l = this._getSub(
|
|
1239
|
+
}, l = this._getSub(n);
|
|
1240
1240
|
if (!l) {
|
|
1241
|
-
this._isServerSub(
|
|
1241
|
+
this._isServerSub(n) && (c.channel = n, this.emit("leave", c));
|
|
1242
1242
|
return;
|
|
1243
1243
|
}
|
|
1244
1244
|
l.emit("leave", c);
|
|
1245
1245
|
}
|
|
1246
1246
|
}, {
|
|
1247
1247
|
key: "_handleUnsub",
|
|
1248
|
-
value: function(
|
|
1249
|
-
var c = {}, l = this._getSub(
|
|
1248
|
+
value: function(n, r) {
|
|
1249
|
+
var c = {}, l = this._getSub(n);
|
|
1250
1250
|
if (!l) {
|
|
1251
|
-
this._isServerSub(
|
|
1251
|
+
this._isServerSub(n) && (delete this._serverSubs[n], c.channel = n, this.emit("unsubscribe", c));
|
|
1252
1252
|
return;
|
|
1253
1253
|
}
|
|
1254
1254
|
l.unsubscribe(), r.resubscribe === !0 && l.subscribe();
|
|
1255
1255
|
}
|
|
1256
1256
|
}, {
|
|
1257
1257
|
key: "_handleSub",
|
|
1258
|
-
value: function(
|
|
1259
|
-
this._serverSubs[
|
|
1258
|
+
value: function(n, r) {
|
|
1259
|
+
this._serverSubs[n] = {
|
|
1260
1260
|
seq: r.seq,
|
|
1261
1261
|
gen: r.gen,
|
|
1262
1262
|
offset: r.offset,
|
|
@@ -1264,35 +1264,35 @@ function kt() {
|
|
|
1264
1264
|
recoverable: r.recoverable
|
|
1265
1265
|
};
|
|
1266
1266
|
var c = {
|
|
1267
|
-
channel:
|
|
1267
|
+
channel: n,
|
|
1268
1268
|
isResubscribe: !1
|
|
1269
1269
|
};
|
|
1270
1270
|
c = this._expandSubscribeContext(c, r), this.emit("subscribe", c);
|
|
1271
1271
|
}
|
|
1272
1272
|
}, {
|
|
1273
1273
|
key: "_handlePublication",
|
|
1274
|
-
value: function(
|
|
1275
|
-
var c = this._getSub(
|
|
1274
|
+
value: function(n, r) {
|
|
1275
|
+
var c = this._getSub(n), l = {
|
|
1276
1276
|
data: r.data,
|
|
1277
1277
|
seq: r.seq,
|
|
1278
1278
|
gen: r.gen,
|
|
1279
1279
|
offset: r.offset
|
|
1280
1280
|
};
|
|
1281
1281
|
if (r.info && (l.info = r.info), !c) {
|
|
1282
|
-
this._isServerSub(
|
|
1282
|
+
this._isServerSub(n) && (r.seq !== void 0 && (this._serverSubs[n].seq = r.seq), r.gen !== void 0 && (this._serverSubs[n].gen = r.gen), r.offset !== void 0 && (this._serverSubs[n].offset = r.offset), l.channel = n, this.emit("publish", l));
|
|
1283
1283
|
return;
|
|
1284
1284
|
}
|
|
1285
|
-
r.seq !== void 0 && (this._lastSeq[
|
|
1285
|
+
r.seq !== void 0 && (this._lastSeq[n] = r.seq), r.gen !== void 0 && (this._lastGen[n] = r.gen), r.offset !== void 0 && (this._lastOffset[n] = r.offset), c.emit("publish", l);
|
|
1286
1286
|
}
|
|
1287
1287
|
}, {
|
|
1288
1288
|
key: "_handleMessage",
|
|
1289
|
-
value: function(
|
|
1290
|
-
this.emit("message",
|
|
1289
|
+
value: function(n) {
|
|
1290
|
+
this.emit("message", n.data);
|
|
1291
1291
|
}
|
|
1292
1292
|
}, {
|
|
1293
1293
|
key: "_handlePush",
|
|
1294
|
-
value: function(
|
|
1295
|
-
var c = this._decoder.decodePush(
|
|
1294
|
+
value: function(n, r) {
|
|
1295
|
+
var c = this._decoder.decodePush(n), l = 0;
|
|
1296
1296
|
"type" in c && (l = c.type);
|
|
1297
1297
|
var y = c.channel;
|
|
1298
1298
|
if (l === this._pushType.PUBLICATION) {
|
|
@@ -1319,78 +1319,78 @@ function kt() {
|
|
|
1319
1319
|
}, {
|
|
1320
1320
|
key: "_flush",
|
|
1321
1321
|
value: function() {
|
|
1322
|
-
var
|
|
1323
|
-
this._messages = [], this._transportSend(
|
|
1322
|
+
var n = this._messages.slice(0);
|
|
1323
|
+
this._messages = [], this._transportSend(n);
|
|
1324
1324
|
}
|
|
1325
1325
|
}, {
|
|
1326
1326
|
key: "_ping",
|
|
1327
1327
|
value: function() {
|
|
1328
|
-
var
|
|
1328
|
+
var n = this, r = {
|
|
1329
1329
|
method: this._methodType.PING
|
|
1330
1330
|
};
|
|
1331
1331
|
this._call(r).then(function(c) {
|
|
1332
|
-
|
|
1332
|
+
n._pingResponse(n._decoder.decodeCommandResult(n._methodType.PING, c.result)), c.next && c.next();
|
|
1333
1333
|
}, function(c) {
|
|
1334
|
-
|
|
1334
|
+
n._debug("ping error", c.error), c.next && c.next();
|
|
1335
1335
|
});
|
|
1336
1336
|
}
|
|
1337
1337
|
}, {
|
|
1338
1338
|
key: "_pingResponse",
|
|
1339
|
-
value: function(
|
|
1339
|
+
value: function(n) {
|
|
1340
1340
|
this.isConnected() && (this._stopPing(), this._startPing());
|
|
1341
1341
|
}
|
|
1342
1342
|
}, {
|
|
1343
1343
|
key: "_getLastSeq",
|
|
1344
|
-
value: function(
|
|
1345
|
-
var r = this._lastSeq[
|
|
1344
|
+
value: function(n) {
|
|
1345
|
+
var r = this._lastSeq[n];
|
|
1346
1346
|
return r || 0;
|
|
1347
1347
|
}
|
|
1348
1348
|
}, {
|
|
1349
1349
|
key: "_getLastOffset",
|
|
1350
|
-
value: function(
|
|
1351
|
-
var r = this._lastOffset[
|
|
1350
|
+
value: function(n) {
|
|
1351
|
+
var r = this._lastOffset[n];
|
|
1352
1352
|
return r || 0;
|
|
1353
1353
|
}
|
|
1354
1354
|
}, {
|
|
1355
1355
|
key: "_getLastGen",
|
|
1356
|
-
value: function(
|
|
1357
|
-
var r = this._lastGen[
|
|
1356
|
+
value: function(n) {
|
|
1357
|
+
var r = this._lastGen[n];
|
|
1358
1358
|
return r || 0;
|
|
1359
1359
|
}
|
|
1360
1360
|
}, {
|
|
1361
1361
|
key: "_getLastEpoch",
|
|
1362
|
-
value: function(
|
|
1363
|
-
var r = this._lastEpoch[
|
|
1362
|
+
value: function(n) {
|
|
1363
|
+
var r = this._lastEpoch[n];
|
|
1364
1364
|
return r || "";
|
|
1365
1365
|
}
|
|
1366
1366
|
}, {
|
|
1367
1367
|
key: "_createErrorObject",
|
|
1368
|
-
value: function(
|
|
1368
|
+
value: function(n, r) {
|
|
1369
1369
|
var c = {
|
|
1370
|
-
message:
|
|
1370
|
+
message: n,
|
|
1371
1371
|
code: r || 0
|
|
1372
1372
|
};
|
|
1373
1373
|
return c;
|
|
1374
1374
|
}
|
|
1375
1375
|
}, {
|
|
1376
1376
|
key: "_registerCall",
|
|
1377
|
-
value: function(
|
|
1377
|
+
value: function(n, r, c) {
|
|
1378
1378
|
var l = this;
|
|
1379
|
-
this._callbacks[
|
|
1379
|
+
this._callbacks[n] = {
|
|
1380
1380
|
callback: r,
|
|
1381
1381
|
errback: c,
|
|
1382
1382
|
timeout: null
|
|
1383
|
-
}, this._callbacks[
|
|
1384
|
-
delete l._callbacks[
|
|
1383
|
+
}, this._callbacks[n].timeout = setTimeout(function() {
|
|
1384
|
+
delete l._callbacks[n], (0, E.isFunction)(c) && c({
|
|
1385
1385
|
error: l._createErrorObject(q)
|
|
1386
1386
|
});
|
|
1387
1387
|
}, this._config.timeout);
|
|
1388
1388
|
}
|
|
1389
1389
|
}, {
|
|
1390
1390
|
key: "_addMessage",
|
|
1391
|
-
value: function(
|
|
1391
|
+
value: function(n) {
|
|
1392
1392
|
var r = this._nextMessageId();
|
|
1393
|
-
return
|
|
1393
|
+
return n.id = r, this._isBatching === !0 ? this._messages.push(n) : this._transportSend([n]), r;
|
|
1394
1394
|
}
|
|
1395
1395
|
}, {
|
|
1396
1396
|
key: "isConnected",
|
|
@@ -1430,7 +1430,7 @@ function kt() {
|
|
|
1430
1430
|
}, {
|
|
1431
1431
|
key: "stopSubscribeBatching",
|
|
1432
1432
|
value: function() {
|
|
1433
|
-
var
|
|
1433
|
+
var n = this;
|
|
1434
1434
|
this._isSubscribeBatching = !1;
|
|
1435
1435
|
var r = this._privateChannels;
|
|
1436
1436
|
this._privateChannels = {};
|
|
@@ -1450,13 +1450,13 @@ function kt() {
|
|
|
1450
1450
|
client: this._clientID,
|
|
1451
1451
|
channels: c
|
|
1452
1452
|
}, I = this._clientID, B = this._newXHRID(), R = function(D) {
|
|
1453
|
-
if (B in
|
|
1453
|
+
if (B in n._xhrs && delete n._xhrs[B], n._clientID === I) {
|
|
1454
1454
|
if (D.error || D.status !== 200) {
|
|
1455
|
-
|
|
1455
|
+
n._debug("authorization request failed");
|
|
1456
1456
|
for (var re in c)
|
|
1457
1457
|
if (c.hasOwnProperty(re)) {
|
|
1458
1458
|
var Pe = c[re];
|
|
1459
|
-
|
|
1459
|
+
n._subscribeError(Pe, n._createErrorObject("authorization request failed"));
|
|
1460
1460
|
}
|
|
1461
1461
|
return;
|
|
1462
1462
|
}
|
|
@@ -1467,45 +1467,45 @@ function kt() {
|
|
|
1467
1467
|
ke.channel && (le[ke.channel] = ke.token);
|
|
1468
1468
|
}
|
|
1469
1469
|
var Ue = !1;
|
|
1470
|
-
|
|
1470
|
+
n._isBatching || (n.startBatching(), Ue = !0);
|
|
1471
1471
|
for (var He in c)
|
|
1472
1472
|
if (c.hasOwnProperty(He)) {
|
|
1473
1473
|
var yt = (function() {
|
|
1474
1474
|
var z = c[He], xe = le[z];
|
|
1475
1475
|
if (xe) {
|
|
1476
1476
|
var oe = {
|
|
1477
|
-
method:
|
|
1477
|
+
method: n._methodType.SUBSCRIBE,
|
|
1478
1478
|
params: {
|
|
1479
1479
|
channel: z,
|
|
1480
1480
|
token: xe
|
|
1481
1481
|
}
|
|
1482
|
-
}, Fe =
|
|
1482
|
+
}, Fe = n._getSub(z);
|
|
1483
1483
|
if (Fe === null)
|
|
1484
1484
|
return "continue";
|
|
1485
1485
|
var Je = Fe._needRecover();
|
|
1486
1486
|
if (Je === !0) {
|
|
1487
1487
|
oe.params.recover = !0;
|
|
1488
|
-
var we =
|
|
1488
|
+
var we = n._getLastSeq(z), _e = n._getLastGen(z);
|
|
1489
1489
|
if (we || _e)
|
|
1490
1490
|
we && (oe.params.seq = we), _e && (oe.params.gen = _e);
|
|
1491
1491
|
else {
|
|
1492
|
-
var qe =
|
|
1492
|
+
var qe = n._getLastOffset(z);
|
|
1493
1493
|
qe && (oe.params.offset = qe);
|
|
1494
1494
|
}
|
|
1495
|
-
var je =
|
|
1495
|
+
var je = n._getLastEpoch(z);
|
|
1496
1496
|
je && (oe.params.epoch = je);
|
|
1497
1497
|
}
|
|
1498
|
-
|
|
1499
|
-
|
|
1498
|
+
n._call(oe).then(function(Y) {
|
|
1499
|
+
n._subscribeResponse(z, Je, n._decoder.decodeCommandResult(n._methodType.SUBSCRIBE, Y.result)), Y.next && Y.next();
|
|
1500
1500
|
}, function(Y) {
|
|
1501
|
-
|
|
1501
|
+
n._subscribeError(z, Y.error), Y.next && Y.next();
|
|
1502
1502
|
});
|
|
1503
1503
|
} else
|
|
1504
|
-
return
|
|
1504
|
+
return n._subscribeError(z, n._createErrorObject("permission denied", 103)), "continue";
|
|
1505
1505
|
})();
|
|
1506
1506
|
if (yt === "continue") continue;
|
|
1507
1507
|
}
|
|
1508
|
-
Ue &&
|
|
1508
|
+
Ue && n.stopBatching();
|
|
1509
1509
|
}
|
|
1510
1510
|
};
|
|
1511
1511
|
if (this._config.onPrivateSubscribe !== null)
|
|
@@ -1519,17 +1519,17 @@ function kt() {
|
|
|
1519
1519
|
}
|
|
1520
1520
|
}, {
|
|
1521
1521
|
key: "_setSubscribeSince",
|
|
1522
|
-
value: function(
|
|
1523
|
-
this._lastOffset[
|
|
1522
|
+
value: function(n, r) {
|
|
1523
|
+
this._lastOffset[n.channel] = r.offset, this._lastEpoch[n.channel] = r.epoch, n._setNeedRecover(!0);
|
|
1524
1524
|
}
|
|
1525
1525
|
}, {
|
|
1526
1526
|
key: "subscribe",
|
|
1527
|
-
value: function(
|
|
1528
|
-
var l = this._getSub(
|
|
1527
|
+
value: function(n, r, c) {
|
|
1528
|
+
var l = this._getSub(n);
|
|
1529
1529
|
if (l !== null)
|
|
1530
1530
|
return l._setEvents(r), l._isUnsubscribed() && l.subscribe(c), l;
|
|
1531
|
-
var y = new S.default(this,
|
|
1532
|
-
return this._subs[
|
|
1531
|
+
var y = new S.default(this, n, r);
|
|
1532
|
+
return this._subs[n] = y, y.subscribe(c), y;
|
|
1533
1533
|
}
|
|
1534
1534
|
}]), p;
|
|
1535
1535
|
})(C.default);
|
|
@@ -1665,8 +1665,8 @@ function kt() {
|
|
|
1665
1665
|
}
|
|
1666
1666
|
function _(h, p) {
|
|
1667
1667
|
for (var A = 0; A < p.length; A++) {
|
|
1668
|
-
var
|
|
1669
|
-
|
|
1668
|
+
var n = p[A];
|
|
1669
|
+
n.enumerable = n.enumerable || !1, n.configurable = !0, "value" in n && (n.writable = !0), Object.defineProperty(h, n.key, n);
|
|
1670
1670
|
}
|
|
1671
1671
|
}
|
|
1672
1672
|
function m(h, p, A) {
|
|
@@ -1678,19 +1678,19 @@ function kt() {
|
|
|
1678
1678
|
h.prototype = Object.create(p && p.prototype, { constructor: { value: h, writable: !0, configurable: !0 } }), p && k(h, p);
|
|
1679
1679
|
}
|
|
1680
1680
|
function k(h, p) {
|
|
1681
|
-
return k = Object.setPrototypeOf || function(
|
|
1682
|
-
return
|
|
1681
|
+
return k = Object.setPrototypeOf || function(n, r) {
|
|
1682
|
+
return n.__proto__ = r, n;
|
|
1683
1683
|
}, k(h, p);
|
|
1684
1684
|
}
|
|
1685
1685
|
function w(h) {
|
|
1686
1686
|
var p = F();
|
|
1687
1687
|
return function() {
|
|
1688
|
-
var
|
|
1688
|
+
var n = M(h), r;
|
|
1689
1689
|
if (p) {
|
|
1690
1690
|
var c = M(this).constructor;
|
|
1691
|
-
r = Reflect.construct(
|
|
1691
|
+
r = Reflect.construct(n, arguments, c);
|
|
1692
1692
|
} else
|
|
1693
|
-
r =
|
|
1693
|
+
r = n.apply(this, arguments);
|
|
1694
1694
|
return L(this, r);
|
|
1695
1695
|
};
|
|
1696
1696
|
}
|
|
@@ -1724,9 +1724,9 @@ function kt() {
|
|
|
1724
1724
|
var J = 0, x = 1, q = 2, N = 3, b = 4, f = /* @__PURE__ */ (function(h) {
|
|
1725
1725
|
P(A, h);
|
|
1726
1726
|
var p = w(A);
|
|
1727
|
-
function A(
|
|
1727
|
+
function A(n, r, c) {
|
|
1728
1728
|
var l;
|
|
1729
|
-
return Q(this, A), l = p.call(this), l.channel = r, l._centrifuge =
|
|
1729
|
+
return Q(this, A), l = p.call(this), l.channel = r, l._centrifuge = n, l._status = J, l._error = null, l._isResubscribe = !1, l._ready = !1, l._subscriptionPromise = null, l._noResubscribe = !1, l._recoverable = !1, l._recover = !1, l._setEvents(c), l._initializePromise(), l._promises = {}, l._promiseId = 0, l._subscribeData = null, l.on("error", function(y) {
|
|
1730
1730
|
this._centrifuge._debug("subscription error", y);
|
|
1731
1731
|
}), l;
|
|
1732
1732
|
}
|
|
@@ -2033,9 +2033,9 @@ function kt() {
|
|
|
2033
2033
|
return m(this);
|
|
2034
2034
|
}, E.prototype.emit = function(f) {
|
|
2035
2035
|
for (var h = [], p = 1; p < arguments.length; p++) h.push(arguments[p]);
|
|
2036
|
-
var A = f === "error",
|
|
2037
|
-
if (
|
|
2038
|
-
A = A &&
|
|
2036
|
+
var A = f === "error", n = this._events;
|
|
2037
|
+
if (n !== void 0)
|
|
2038
|
+
A = A && n.error === void 0;
|
|
2039
2039
|
else if (!A)
|
|
2040
2040
|
return !1;
|
|
2041
2041
|
if (A) {
|
|
@@ -2045,7 +2045,7 @@ function kt() {
|
|
|
2045
2045
|
var c = new Error("Unhandled error." + (r ? " (" + r.message + ")" : ""));
|
|
2046
2046
|
throw c.context = r, c;
|
|
2047
2047
|
}
|
|
2048
|
-
var l =
|
|
2048
|
+
var l = n[f];
|
|
2049
2049
|
if (l === void 0)
|
|
2050
2050
|
return !1;
|
|
2051
2051
|
if (typeof l == "function")
|
|
@@ -2056,14 +2056,14 @@ function kt() {
|
|
|
2056
2056
|
return !0;
|
|
2057
2057
|
};
|
|
2058
2058
|
function P(b, f, h, p) {
|
|
2059
|
-
var A,
|
|
2060
|
-
if (_(h),
|
|
2059
|
+
var A, n, r;
|
|
2060
|
+
if (_(h), n = b._events, n === void 0 ? (n = b._events = /* @__PURE__ */ Object.create(null), b._eventsCount = 0) : (n.newListener !== void 0 && (b.emit(
|
|
2061
2061
|
"newListener",
|
|
2062
2062
|
f,
|
|
2063
2063
|
h.listener ? h.listener : h
|
|
2064
|
-
),
|
|
2065
|
-
r =
|
|
2066
|
-
else if (typeof r == "function" ? r =
|
|
2064
|
+
), n = b._events), r = n[f]), r === void 0)
|
|
2065
|
+
r = n[f] = h, ++b._eventsCount;
|
|
2066
|
+
else if (typeof r == "function" ? r = n[f] = p ? [h, r] : [r, h] : p ? r.unshift(h) : r.push(h), A = m(b), A > 0 && r.length > A && !r.warned) {
|
|
2067
2067
|
r.warned = !0;
|
|
2068
2068
|
var c = new Error("Possible EventEmitter memory leak detected. " + r.length + " " + String(f) + " listeners added. Use emitter.setMaxListeners() to increase limit");
|
|
2069
2069
|
c.name = "MaxListenersExceededWarning", c.emitter = b, c.type = f, c.count = r.length, S(c);
|
|
@@ -2088,7 +2088,7 @@ function kt() {
|
|
|
2088
2088
|
}, E.prototype.prependOnceListener = function(f, h) {
|
|
2089
2089
|
return _(h), this.prependListener(f, w(this, f, h)), this;
|
|
2090
2090
|
}, E.prototype.removeListener = function(f, h) {
|
|
2091
|
-
var p, A,
|
|
2091
|
+
var p, A, n, r, c;
|
|
2092
2092
|
if (_(h), A = this._events, A === void 0)
|
|
2093
2093
|
return this;
|
|
2094
2094
|
if (p = A[f], p === void 0)
|
|
@@ -2096,14 +2096,14 @@ function kt() {
|
|
|
2096
2096
|
if (p === h || p.listener === h)
|
|
2097
2097
|
--this._eventsCount === 0 ? this._events = /* @__PURE__ */ Object.create(null) : (delete A[f], A.removeListener && this.emit("removeListener", f, p.listener || h));
|
|
2098
2098
|
else if (typeof p != "function") {
|
|
2099
|
-
for (
|
|
2099
|
+
for (n = -1, r = p.length - 1; r >= 0; r--)
|
|
2100
2100
|
if (p[r] === h || p[r].listener === h) {
|
|
2101
|
-
c = p[r].listener,
|
|
2101
|
+
c = p[r].listener, n = r;
|
|
2102
2102
|
break;
|
|
2103
2103
|
}
|
|
2104
|
-
if (
|
|
2104
|
+
if (n < 0)
|
|
2105
2105
|
return this;
|
|
2106
|
-
|
|
2106
|
+
n === 0 ? p.shift() : M(p, n), p.length === 1 && (A[f] = p[0]), A.removeListener !== void 0 && this.emit("removeListener", f, c || h);
|
|
2107
2107
|
}
|
|
2108
2108
|
return this;
|
|
2109
2109
|
}, E.prototype.off = E.prototype.removeListener, E.prototype.removeAllListeners = function(f) {
|
|
@@ -2113,9 +2113,9 @@ function kt() {
|
|
|
2113
2113
|
if (p.removeListener === void 0)
|
|
2114
2114
|
return arguments.length === 0 ? (this._events = /* @__PURE__ */ Object.create(null), this._eventsCount = 0) : p[f] !== void 0 && (--this._eventsCount === 0 ? this._events = /* @__PURE__ */ Object.create(null) : delete p[f]), this;
|
|
2115
2115
|
if (arguments.length === 0) {
|
|
2116
|
-
var
|
|
2117
|
-
for (A = 0; A <
|
|
2118
|
-
r =
|
|
2116
|
+
var n = Object.keys(p), r;
|
|
2117
|
+
for (A = 0; A < n.length; ++A)
|
|
2118
|
+
r = n[A], r !== "removeListener" && this.removeAllListeners(r);
|
|
2119
2119
|
return this.removeAllListeners("removeListener"), this._events = /* @__PURE__ */ Object.create(null), this._eventsCount = 0, this;
|
|
2120
2120
|
}
|
|
2121
2121
|
if (h = p[f], typeof h == "function")
|
|
@@ -2171,12 +2171,12 @@ function kt() {
|
|
|
2171
2171
|
function x(b, f) {
|
|
2172
2172
|
return new Promise(function(h, p) {
|
|
2173
2173
|
function A(r) {
|
|
2174
|
-
b.removeListener(f,
|
|
2174
|
+
b.removeListener(f, n), p(r);
|
|
2175
2175
|
}
|
|
2176
|
-
function
|
|
2176
|
+
function n() {
|
|
2177
2177
|
typeof b.removeListener == "function" && b.removeListener("error", A), h([].slice.call(arguments));
|
|
2178
2178
|
}
|
|
2179
|
-
N(b, f,
|
|
2179
|
+
N(b, f, n, { once: !0 }), f !== "error" && q(b, A, { once: !0 });
|
|
2180
2180
|
});
|
|
2181
2181
|
}
|
|
2182
2182
|
function q(b, f, h) {
|
|
@@ -2186,8 +2186,8 @@ function kt() {
|
|
|
2186
2186
|
if (typeof b.on == "function")
|
|
2187
2187
|
p.once ? b.once(f, h) : b.on(f, h);
|
|
2188
2188
|
else if (typeof b.addEventListener == "function")
|
|
2189
|
-
b.addEventListener(f, function A(
|
|
2190
|
-
p.once && b.removeEventListener(f, A), h(
|
|
2189
|
+
b.addEventListener(f, function A(n) {
|
|
2190
|
+
p.once && b.removeEventListener(f, A), h(n);
|
|
2191
2191
|
});
|
|
2192
2192
|
else
|
|
2193
2193
|
throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type ' + typeof b);
|
|
@@ -2231,7 +2231,7 @@ function kt() {
|
|
|
2231
2231
|
var wt = kt();
|
|
2232
2232
|
const _t = /* @__PURE__ */ St(wt);
|
|
2233
2233
|
let he = null;
|
|
2234
|
-
function Ve(e,
|
|
2234
|
+
function Ve(e, t) {
|
|
2235
2235
|
if (!(e != null && e.client_url) || !(e != null && e.token) || !(e != null && e.channel))
|
|
2236
2236
|
return console.error("[Centrifuge] Invalid socket_connections"), null;
|
|
2237
2237
|
const { client_url: o, token: i, channel: s } = e;
|
|
@@ -2251,7 +2251,7 @@ function Ve(e, n) {
|
|
|
2251
2251
|
d.on("publish", (g) => {
|
|
2252
2252
|
console.log("[Centrifuge] Publish event received:", g);
|
|
2253
2253
|
const C = Tt(g);
|
|
2254
|
-
C &&
|
|
2254
|
+
C && t(C);
|
|
2255
2255
|
}), d.on("subscribe", (g) => {
|
|
2256
2256
|
console.log("[Centrifuge] ✅ Channel subscribed successfully:", s, g);
|
|
2257
2257
|
}), d.on("error", (g) => {
|
|
@@ -2265,8 +2265,8 @@ function Tt(e) {
|
|
|
2265
2265
|
var o, i, s;
|
|
2266
2266
|
if (console.log("[Centrifuge] Raw message received:", JSON.stringify(e)), !(e != null && e.data))
|
|
2267
2267
|
return console.warn("[Centrifuge] Empty or invalid response"), null;
|
|
2268
|
-
let
|
|
2269
|
-
return (o =
|
|
2268
|
+
let t = e.data;
|
|
2269
|
+
return (o = t.data) != null && o.type ? t = t.data : (s = (i = t.data) == null ? void 0 : i.data) != null && s.type && (t = t.data.data), console.log("[Centrifuge] Parsed message:", t), t.type ? t : (console.warn("[Centrifuge] Message has no type:", t), null);
|
|
2270
2270
|
}
|
|
2271
2271
|
function ge(e) {
|
|
2272
2272
|
return /^4[0-9]/.test(e) ? "visa" : /^5[1-5]/.test(e) || /^2[2-7]/.test(e) ? "mastercard" : "card";
|
|
@@ -2289,12 +2289,12 @@ function K(e) {
|
|
|
2289
2289
|
}
|
|
2290
2290
|
function Ye(e) {
|
|
2291
2291
|
if (!e) return null;
|
|
2292
|
-
let
|
|
2293
|
-
return
|
|
2292
|
+
let t = String(e).trim().toLowerCase();
|
|
2293
|
+
return t.startsWith("payment_method_") && (t = t.replace("payment_method_", "")), t === "kaspi" ? "kaspi_pay" : t === "apple" ? "apple_pay" : t === "google" ? "google_pay" : t === "newcard" ? "new_card" : t === "card" ? "card" : ["kaspi_pay", "apple_pay", "google_pay", "new_card"].includes(t) ? t : null;
|
|
2294
2294
|
}
|
|
2295
2295
|
function Lt(e) {
|
|
2296
2296
|
var u, a, d;
|
|
2297
|
-
const
|
|
2297
|
+
const t = e, o = ((u = t == null ? void 0 : t.context) == null ? void 0 : u.last_payment_method) ?? (t == null ? void 0 : t.last_payment_method) ?? ((a = t == null ? void 0 : t.attributes) == null ? void 0 : a.last_payment_method);
|
|
2298
2298
|
if (!o) return null;
|
|
2299
2299
|
if (typeof o == "string")
|
|
2300
2300
|
return { type: Ye(o), cardId: null };
|
|
@@ -2305,7 +2305,7 @@ function Lt(e) {
|
|
|
2305
2305
|
cardId: s != null ? String(s) : null
|
|
2306
2306
|
};
|
|
2307
2307
|
}
|
|
2308
|
-
function Rt(e,
|
|
2308
|
+
function Rt(e, t, o = {}) {
|
|
2309
2309
|
var P, k, w, L;
|
|
2310
2310
|
const i = [], s = (P = e == null ? void 0 : e.kaspi) == null ? void 0 : P.data, u = ((k = e == null ? void 0 : e.cards_v2) == null ? void 0 : k.data) || [], a = ((L = (w = e == null ? void 0 : e.payment_methods) == null ? void 0 : w.data) == null ? void 0 : L.attributes) || {}, d = K(a.payment_method_kaspi), g = K(a.payment_method_card), C = typeof window < "u" && window.self === window.top, T = De() === "ios", E = !!(o != null && o.onlyKaspiAvailable), Q = !!(o != null && o.disableKaspi);
|
|
2311
2311
|
return s != null && s.isKaspiOnly && d && !Q ? [Z] : E ? s != null && s.isAvailable && d && !Q ? [Z] : [] : (K(a.payment_method_apple_pay) && !me("apple_pay") && (Ce() && C || ye() || T || rt() === 16) && i.push(ot), s != null && s.isAvailable && d && !Q && i.push(Z), g && u.filter((O) => !O.isExpired).forEach((O) => {
|
|
@@ -2320,13 +2320,13 @@ function Rt(e, n, o = {}) {
|
|
|
2320
2320
|
}), K(a.payment_method_google_pay) && !me("google_pay") && !(o != null && o.disableGooglePay) && !Ce() && !ye() && i.push(st), K(a.payment_method_new_card) && i.push({
|
|
2321
2321
|
iconType: "new_card",
|
|
2322
2322
|
type: "new_card",
|
|
2323
|
-
label:
|
|
2323
|
+
label: t ? t("newCard") : "Оплата новой картой"
|
|
2324
2324
|
}), i);
|
|
2325
2325
|
}
|
|
2326
|
-
function Le(e,
|
|
2326
|
+
function Le(e, t = {}) {
|
|
2327
2327
|
var m, P, k, w;
|
|
2328
|
-
const o = (m = e == null ? void 0 : e.kaspi) == null ? void 0 : m.data, i = ((P = e == null ? void 0 : e.cards_v2) == null ? void 0 : P.data) || [], s = ((w = (k = e == null ? void 0 : e.payment_methods) == null ? void 0 : k.data) == null ? void 0 : w.attributes) || {}, u = K(s.payment_method_kaspi), a = K(s.payment_method_card), d = !!(
|
|
2329
|
-
if (o != null && o.isKaspiOnly && u && !d ||
|
|
2328
|
+
const o = (m = e == null ? void 0 : e.kaspi) == null ? void 0 : m.data, i = ((P = e == null ? void 0 : e.cards_v2) == null ? void 0 : P.data) || [], s = ((w = (k = e == null ? void 0 : e.payment_methods) == null ? void 0 : k.data) == null ? void 0 : w.attributes) || {}, u = K(s.payment_method_kaspi), a = K(s.payment_method_card), d = !!(t != null && t.disableKaspi), g = typeof window < "u" && window.self === window.top, S = De() === "ios", T = K(s.payment_method_apple_pay) && !me("apple_pay") && (Ce() && g || ye() || S || rt() === 16), E = K(s.payment_method_google_pay) && !me("google_pay") && !(t != null && t.disableGooglePay) && !Ce() && !ye();
|
|
2329
|
+
if (o != null && o.isKaspiOnly && u && !d || t != null && t.onlyKaspiAvailable && (o != null && o.isAvailable) && u && !d)
|
|
2330
2330
|
return Z;
|
|
2331
2331
|
const Q = Lt(e);
|
|
2332
2332
|
if ((Q == null ? void 0 : Q.type) === "kaspi_pay" && (o != null && o.isAvailable) && u && !d)
|
|
@@ -2378,10 +2378,10 @@ function it(e) {
|
|
|
2378
2378
|
return null;
|
|
2379
2379
|
}
|
|
2380
2380
|
}
|
|
2381
|
-
function Re(e,
|
|
2381
|
+
function Re(e, t) {
|
|
2382
2382
|
if (!(typeof localStorage > "u"))
|
|
2383
2383
|
try {
|
|
2384
|
-
localStorage.setItem(e,
|
|
2384
|
+
localStorage.setItem(e, t);
|
|
2385
2385
|
} catch {
|
|
2386
2386
|
}
|
|
2387
2387
|
}
|
|
@@ -2392,28 +2392,28 @@ function be(e) {
|
|
|
2392
2392
|
} catch {
|
|
2393
2393
|
}
|
|
2394
2394
|
}
|
|
2395
|
-
async function Ot(e,
|
|
2395
|
+
async function Ot(e, t) {
|
|
2396
2396
|
var o;
|
|
2397
2397
|
try {
|
|
2398
2398
|
const i = await e.json(), s = (o = i == null ? void 0 : i.errors) == null ? void 0 : o[0];
|
|
2399
|
-
return (s == null ? void 0 : s.title) || (s == null ? void 0 : s.detail) || (i == null ? void 0 : i.message) || (i == null ? void 0 : i.error) ||
|
|
2399
|
+
return (s == null ? void 0 : s.title) || (s == null ? void 0 : s.detail) || (i == null ? void 0 : i.message) || (i == null ? void 0 : i.error) || t;
|
|
2400
2400
|
} catch {
|
|
2401
2401
|
return `HTTP ${e.status}: ${e.statusText}`;
|
|
2402
2402
|
}
|
|
2403
2403
|
}
|
|
2404
|
-
async function ne(e,
|
|
2405
|
-
const o = await Ot(e,
|
|
2404
|
+
async function ne(e, t) {
|
|
2405
|
+
const o = await Ot(e, t);
|
|
2406
2406
|
throw Object.assign(new Error(o), { status: e.status });
|
|
2407
2407
|
}
|
|
2408
|
-
function Ie(e,
|
|
2408
|
+
function Ie(e, t, o = {}) {
|
|
2409
2409
|
const i = Number.isFinite(o.checkoutAmount) && o.checkoutAmount >= 0 ? Number(o.checkoutAmount) : e.amount, s = !!o.forceBalanceMethod, u = !!o.useBalance;
|
|
2410
2410
|
return {
|
|
2411
2411
|
checkoutAmount: i,
|
|
2412
|
-
checkoutPaymentMethod: s ? { type: "balance" } :
|
|
2412
|
+
checkoutPaymentMethod: s ? { type: "balance" } : t,
|
|
2413
2413
|
useBalanceFlag: u
|
|
2414
2414
|
};
|
|
2415
2415
|
}
|
|
2416
|
-
function Qe(e,
|
|
2416
|
+
function Qe(e, t, o, i) {
|
|
2417
2417
|
return {
|
|
2418
2418
|
preorder_id: e.preorderId,
|
|
2419
2419
|
terminal_id: e.terminalId,
|
|
@@ -2422,18 +2422,18 @@ function Qe(e, n, o, i) {
|
|
|
2422
2422
|
amount: String(o),
|
|
2423
2423
|
currency: e.currency
|
|
2424
2424
|
},
|
|
2425
|
-
payment_method:
|
|
2425
|
+
payment_method: t,
|
|
2426
2426
|
...e.backlink && { backlink: e.backlink },
|
|
2427
2427
|
...i && { use_balance: !0 }
|
|
2428
2428
|
};
|
|
2429
2429
|
}
|
|
2430
|
-
async function Se(e,
|
|
2430
|
+
async function Se(e, t, o, i, s) {
|
|
2431
2431
|
const u = await fetch(`${e}/orders/v1/checkout`, {
|
|
2432
2432
|
method: "POST",
|
|
2433
2433
|
headers: {
|
|
2434
2434
|
"Content-Type": "application/json",
|
|
2435
|
-
Authorization: `Bearer ${
|
|
2436
|
-
"X-Idempotency-Key": Be(),
|
|
2435
|
+
Authorization: `Bearer ${t.accessToken}`,
|
|
2436
|
+
"X-Idempotency-Key": t.idempotencyKey ?? Be(),
|
|
2437
2437
|
"X-Device-Id": o,
|
|
2438
2438
|
"X-OS": "WEB"
|
|
2439
2439
|
},
|
|
@@ -2441,7 +2441,7 @@ async function Se(e, n, o, i, s) {
|
|
|
2441
2441
|
});
|
|
2442
2442
|
return u.ok || await ne(u, s), u.json();
|
|
2443
2443
|
}
|
|
2444
|
-
async function Mt(e,
|
|
2444
|
+
async function Mt(e, t, o) {
|
|
2445
2445
|
var d, g, C, S;
|
|
2446
2446
|
const i = await fetch(`${e}/api/v2/oauth2/tokens`, {
|
|
2447
2447
|
method: "POST",
|
|
@@ -2451,7 +2451,7 @@ async function Mt(e, n, o) {
|
|
|
2451
2451
|
"X-Fingerprint": nt()
|
|
2452
2452
|
},
|
|
2453
2453
|
body: JSON.stringify({
|
|
2454
|
-
client_id:
|
|
2454
|
+
client_id: t,
|
|
2455
2455
|
grant_type: "authorization_track_id",
|
|
2456
2456
|
track_id: o
|
|
2457
2457
|
})
|
|
@@ -2461,13 +2461,13 @@ async function Mt(e, n, o) {
|
|
|
2461
2461
|
if (!u) throw new Error("В ответе отсутствует access_token");
|
|
2462
2462
|
return { access_token: u, refresh_token: a };
|
|
2463
2463
|
}
|
|
2464
|
-
async function Nt(e,
|
|
2464
|
+
async function Nt(e, t, o) {
|
|
2465
2465
|
var d, g, C, S;
|
|
2466
2466
|
const i = await fetch(`${e}/api/v2/oauth2/tokens`, {
|
|
2467
2467
|
method: "POST",
|
|
2468
2468
|
headers: { "Content-Type": "application/json" },
|
|
2469
2469
|
body: JSON.stringify({
|
|
2470
|
-
client_id:
|
|
2470
|
+
client_id: t,
|
|
2471
2471
|
grant_type: "refresh_token",
|
|
2472
2472
|
refresh_token: o
|
|
2473
2473
|
})
|
|
@@ -2477,54 +2477,54 @@ async function Nt(e, n, o) {
|
|
|
2477
2477
|
if (!u) throw new Error("В ответе отсутствует access_token");
|
|
2478
2478
|
return { access_token: u, refresh_token: a };
|
|
2479
2479
|
}
|
|
2480
|
-
async function Oe(e,
|
|
2480
|
+
async function Oe(e, t) {
|
|
2481
2481
|
const o = await fetch(`${e}/orders/v1/checkout/context`, {
|
|
2482
2482
|
method: "POST",
|
|
2483
2483
|
headers: {
|
|
2484
2484
|
"Content-Type": "application/json",
|
|
2485
|
-
Authorization: `Bearer ${
|
|
2486
|
-
"X-Idempotency-Key": Be()
|
|
2485
|
+
Authorization: `Bearer ${t.accessToken}`,
|
|
2486
|
+
"X-Idempotency-Key": t.idempotencyKey ?? Be()
|
|
2487
2487
|
},
|
|
2488
2488
|
body: JSON.stringify({
|
|
2489
|
-
terminal_id:
|
|
2489
|
+
terminal_id: t.terminalId,
|
|
2490
2490
|
include: ["cards", "payment_methods", "balance", "cashback"],
|
|
2491
2491
|
money: {
|
|
2492
|
-
amount: String(
|
|
2493
|
-
currency:
|
|
2492
|
+
amount: String(t.amount),
|
|
2493
|
+
currency: t.currency
|
|
2494
2494
|
}
|
|
2495
2495
|
})
|
|
2496
2496
|
});
|
|
2497
2497
|
return o.ok || await ne(o, "Ошибка получения контекста оплаты"), o.json();
|
|
2498
2498
|
}
|
|
2499
|
-
async function Dt(e,
|
|
2499
|
+
async function Dt(e, t, o) {
|
|
2500
2500
|
const i = await fetch(`${e}/payment-gateway/v1/cards/${o}`, {
|
|
2501
2501
|
method: "DELETE",
|
|
2502
2502
|
headers: {
|
|
2503
2503
|
"Content-Type": "application/json",
|
|
2504
|
-
Authorization: `Bearer ${
|
|
2504
|
+
Authorization: `Bearer ${t.accessToken}`
|
|
2505
2505
|
}
|
|
2506
2506
|
});
|
|
2507
2507
|
return i.ok || await ne(i, "Не удалось удалить карту"), i.json().catch(() => ({}));
|
|
2508
2508
|
}
|
|
2509
|
-
async function Xt(e,
|
|
2509
|
+
async function Xt(e, t, o) {
|
|
2510
2510
|
const i = await fetch(
|
|
2511
2511
|
`${e}/payment-gateway/v1/cards/${o}/mark_as_default`,
|
|
2512
2512
|
{
|
|
2513
2513
|
method: "PUT",
|
|
2514
2514
|
headers: {
|
|
2515
2515
|
"Content-Type": "application/json",
|
|
2516
|
-
Authorization: `Bearer ${
|
|
2516
|
+
Authorization: `Bearer ${t.accessToken}`
|
|
2517
2517
|
}
|
|
2518
2518
|
}
|
|
2519
2519
|
);
|
|
2520
2520
|
return i.ok || await ne(i, "Не удалось отметить карту как основную"), i.json().catch(() => ({}));
|
|
2521
2521
|
}
|
|
2522
|
-
async function Ut(e,
|
|
2522
|
+
async function Ut(e, t, o) {
|
|
2523
2523
|
const i = await fetch(`${e}/orders/v1/orders/${o}/status`, {
|
|
2524
2524
|
method: "GET",
|
|
2525
2525
|
headers: {
|
|
2526
2526
|
"Content-Type": "application/json",
|
|
2527
|
-
Authorization: `Bearer ${
|
|
2527
|
+
Authorization: `Bearer ${t.accessToken}`
|
|
2528
2528
|
}
|
|
2529
2529
|
});
|
|
2530
2530
|
if (!i.ok)
|
|
@@ -2535,9 +2535,9 @@ async function Ut(e, n, o) {
|
|
|
2535
2535
|
const s = await i.json(), u = (s == null ? void 0 : s.data) ?? s;
|
|
2536
2536
|
return { data: { status: u == null ? void 0 : u.status, payload: (u == null ? void 0 : u.payload) ?? {} } };
|
|
2537
2537
|
}
|
|
2538
|
-
async function Ge(e,
|
|
2538
|
+
async function Ge(e, t, o, i, s = {}) {
|
|
2539
2539
|
const { checkoutAmount: u, checkoutPaymentMethod: a, useBalanceFlag: d } = Ie(
|
|
2540
|
-
|
|
2540
|
+
t,
|
|
2541
2541
|
{
|
|
2542
2542
|
type: i.type,
|
|
2543
2543
|
...i.cardId && { card_id: i.cardId }
|
|
@@ -2546,68 +2546,68 @@ async function Ge(e, n, o, i, s = {}) {
|
|
|
2546
2546
|
);
|
|
2547
2547
|
return Se(
|
|
2548
2548
|
e,
|
|
2549
|
-
|
|
2549
|
+
t,
|
|
2550
2550
|
o,
|
|
2551
|
-
Qe(
|
|
2551
|
+
Qe(t, a, u, d),
|
|
2552
2552
|
"Ошибка создания заказа"
|
|
2553
2553
|
);
|
|
2554
2554
|
}
|
|
2555
|
-
async function Ht(e,
|
|
2555
|
+
async function Ht(e, t, o, i = {}) {
|
|
2556
2556
|
const { checkoutAmount: s, checkoutPaymentMethod: u, useBalanceFlag: a } = Ie(
|
|
2557
|
-
|
|
2557
|
+
t,
|
|
2558
2558
|
{ type: "new_card" },
|
|
2559
2559
|
i
|
|
2560
2560
|
);
|
|
2561
2561
|
return Se(
|
|
2562
2562
|
e,
|
|
2563
|
-
|
|
2563
|
+
t,
|
|
2564
2564
|
o,
|
|
2565
|
-
Qe(
|
|
2565
|
+
Qe(t, u, s, a),
|
|
2566
2566
|
"Ошибка создания заказа для новой карты"
|
|
2567
2567
|
);
|
|
2568
2568
|
}
|
|
2569
|
-
async function xt(e,
|
|
2569
|
+
async function xt(e, t, o) {
|
|
2570
2570
|
const i = window.location.hostname, s = await fetch(`${e}/payment-gateway/v1/apple/session`, {
|
|
2571
2571
|
method: "POST",
|
|
2572
2572
|
headers: {
|
|
2573
2573
|
"Content-Type": "application/json",
|
|
2574
2574
|
Accept: "application/vnd.api+json",
|
|
2575
|
-
Authorization: `Bearer ${
|
|
2575
|
+
Authorization: `Bearer ${t.accessToken}`
|
|
2576
2576
|
},
|
|
2577
2577
|
body: JSON.stringify({ validationUrl: o, domainName: i })
|
|
2578
2578
|
});
|
|
2579
2579
|
return s.ok || await ne(s, "Ошибка получения Apple Pay сессии"), s.json();
|
|
2580
2580
|
}
|
|
2581
|
-
async function Ft(e,
|
|
2581
|
+
async function Ft(e, t, o, i, s = {}) {
|
|
2582
2582
|
const { checkoutAmount: u, checkoutPaymentMethod: a, useBalanceFlag: d } = Ie(
|
|
2583
|
-
|
|
2583
|
+
t,
|
|
2584
2584
|
{ type: "apple_pay", data: i },
|
|
2585
2585
|
s
|
|
2586
2586
|
);
|
|
2587
2587
|
return Se(
|
|
2588
2588
|
e,
|
|
2589
|
-
|
|
2589
|
+
t,
|
|
2590
2590
|
o,
|
|
2591
|
-
Qe(
|
|
2591
|
+
Qe(t, a, u, d),
|
|
2592
2592
|
"Ошибка создания заказа с Apple Pay"
|
|
2593
2593
|
);
|
|
2594
2594
|
}
|
|
2595
|
-
async function at(e,
|
|
2595
|
+
async function at(e, t, o, i, s = {}) {
|
|
2596
2596
|
const { checkoutAmount: u, checkoutPaymentMethod: a, useBalanceFlag: d } = Ie(
|
|
2597
|
-
|
|
2597
|
+
t,
|
|
2598
2598
|
{ type: "google_pay", data: i },
|
|
2599
2599
|
s
|
|
2600
2600
|
);
|
|
2601
2601
|
return Se(
|
|
2602
2602
|
e,
|
|
2603
|
-
|
|
2603
|
+
t,
|
|
2604
2604
|
o,
|
|
2605
|
-
Qe(
|
|
2605
|
+
Qe(t, a, u, d),
|
|
2606
2606
|
"Ошибка создания заказа с Google Pay"
|
|
2607
2607
|
);
|
|
2608
2608
|
}
|
|
2609
2609
|
function Jt(e) {
|
|
2610
|
-
const
|
|
2610
|
+
const t = typeof e.color == "string" ? e.color.trim() : "", o = t && /^[0-9a-fA-F]{3}([0-9a-fA-F]{3})?$/.test(t) ? `#${t}` : t, i = e.bonuses, s = i && typeof i == "object" && Number.isFinite(i.amount) && Number.isFinite(i.percent) ? {
|
|
2611
2611
|
availableBonus: Number.isFinite(i.availableBonus) ? Number(i.availableBonus) : 0,
|
|
2612
2612
|
amount: Number(i.amount),
|
|
2613
2613
|
percent: Number(i.percent)
|
|
@@ -2637,6 +2637,7 @@ function Jt(e) {
|
|
|
2637
2637
|
onPayWithGooglePay: typeof e.onPayWithGooglePay == "function" ? e.onPayWithGooglePay : null,
|
|
2638
2638
|
onUserEvent: typeof e.onUserEvent == "function" ? e.onUserEvent : null,
|
|
2639
2639
|
onBeforeCheckout: typeof e.onBeforeCheckout == "function" ? e.onBeforeCheckout : null,
|
|
2640
|
+
idempotencyKey: e.idempotencyKey,
|
|
2640
2641
|
locale: e.locale || "ru",
|
|
2641
2642
|
containerSelector: typeof e.containerSelector == "string" ? e.containerSelector.trim() : "",
|
|
2642
2643
|
color: o || "#2F2F2F",
|
|
@@ -2647,20 +2648,20 @@ function Jt(e) {
|
|
|
2647
2648
|
bonuses: s
|
|
2648
2649
|
};
|
|
2649
2650
|
}
|
|
2650
|
-
function Me(e,
|
|
2651
|
-
Re("webPayToken", e),
|
|
2651
|
+
function Me(e, t) {
|
|
2652
|
+
Re("webPayToken", e), t && Re("webPayRefreshToken", t);
|
|
2652
2653
|
}
|
|
2653
2654
|
function Ze() {
|
|
2654
2655
|
be("webPayToken"), be("webPayRefreshToken");
|
|
2655
2656
|
}
|
|
2656
2657
|
async function qt(e) {
|
|
2657
|
-
const
|
|
2658
|
-
if (
|
|
2658
|
+
const t = it("webPayRefreshToken");
|
|
2659
|
+
if (t && e.config.clientId)
|
|
2659
2660
|
try {
|
|
2660
2661
|
const i = await Nt(
|
|
2661
2662
|
e.apiUrl,
|
|
2662
2663
|
e.config.clientId,
|
|
2663
|
-
|
|
2664
|
+
t
|
|
2664
2665
|
);
|
|
2665
2666
|
Me(i.access_token, i.refresh_token), e.accessToken = i.access_token;
|
|
2666
2667
|
return;
|
|
@@ -2744,8 +2745,8 @@ const jt = `<svg width="17" height="16" viewBox="0 0 17 16" fill="none" xmlns="h
|
|
|
2744
2745
|
mastercard: Yt
|
|
2745
2746
|
};
|
|
2746
2747
|
function Zt(e) {
|
|
2747
|
-
const
|
|
2748
|
-
return
|
|
2748
|
+
const t = e == null ? void 0 : e.toLowerCase();
|
|
2749
|
+
return t && Gt[t] || "";
|
|
2749
2750
|
}
|
|
2750
2751
|
const ct = `<svg width="22" height="22" viewBox="0 0 22 22" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2751
2752
|
<path d="M19.7045 10.7313C15.0567 10.7313 11.2687 6.94328 11.2687 2.26866C11.2687 2.10746 11.1612 2 11 2C10.8388 2 10.7313 2.10746 10.7313 2.26866C10.7313 6.94328 6.94328 10.7313 2.26866 10.7313C2.10746 10.7313 2 10.8388 2 11C2 11.1612 2.10746 11.2687 2.26866 11.2687C6.94328 11.2687 10.7313 15.0567 10.7313 19.7313C10.7313 19.8925 10.8388 20 11 20C11.1612 20 11.2687 19.8925 11.2687 19.7313C11.2687 15.0567 15.0567 11.2687 19.7313 11.2687C19.8925 11.2687 20 11.1612 20 11C20 10.8388 19.8657 10.7313 19.7045 10.7313Z" fill="#2F2F2F"/>
|
|
@@ -2754,10 +2755,10 @@ const ct = `<svg width="22" height="22" viewBox="0 0 22 22" fill="none" xmlns="h
|
|
|
2754
2755
|
function Ee(e) {
|
|
2755
2756
|
return Zt(e == null ? void 0 : e.iconType);
|
|
2756
2757
|
}
|
|
2757
|
-
function At(e,
|
|
2758
|
+
function At(e, t, o, i = {}) {
|
|
2758
2759
|
const { editMode: s = !1 } = i;
|
|
2759
2760
|
return (s ? e.filter((a) => a.type === "card") : e).map((a) => {
|
|
2760
|
-
const d = !s && !!
|
|
2761
|
+
const d = !s && !!t && t.type === a.type && t.cardId === a.cardId, g = JSON.stringify(a).replace(/'/g, "'");
|
|
2761
2762
|
return s ? `
|
|
2762
2763
|
<div
|
|
2763
2764
|
class="choco-widget-method-item choco-widget-method-item--edit"
|
|
@@ -2791,7 +2792,7 @@ function At(e, n, o, i = {}) {
|
|
|
2791
2792
|
`;
|
|
2792
2793
|
}).join("");
|
|
2793
2794
|
}
|
|
2794
|
-
function tn(e,
|
|
2795
|
+
function tn(e, t, o, i) {
|
|
2795
2796
|
if (!e) return "";
|
|
2796
2797
|
const s = typeof e.amount == "number" && Number.isFinite(e.amount), u = typeof e.percent == "number" && Number.isFinite(e.percent);
|
|
2797
2798
|
return `
|
|
@@ -2808,14 +2809,14 @@ function tn(e, n, o, i) {
|
|
|
2808
2809
|
</div>
|
|
2809
2810
|
<div class="choco-widget-balance-amount">${s ? G(e.amount, "ru", i) : 0}</div>
|
|
2810
2811
|
<label class="choco-widget-toggle">
|
|
2811
|
-
<input type="checkbox" ${
|
|
2812
|
+
<input type="checkbox" ${t ? "checked" : ""} />
|
|
2812
2813
|
<span class="choco-widget-toggle-slider"></span>
|
|
2813
2814
|
</label>
|
|
2814
2815
|
</div>
|
|
2815
2816
|
</div>
|
|
2816
2817
|
`;
|
|
2817
2818
|
}
|
|
2818
|
-
function nn(e,
|
|
2819
|
+
function nn(e, t, o, i, s, u) {
|
|
2819
2820
|
return !e && !o ? "" : `
|
|
2820
2821
|
<div class="choco-widget-balance-section">
|
|
2821
2822
|
${e ? `
|
|
@@ -2831,7 +2832,7 @@ function nn(e, n, o, i, s, u) {
|
|
|
2831
2832
|
</div>
|
|
2832
2833
|
<div class="choco-widget-balance-amount">${e}</div>
|
|
2833
2834
|
<label class="choco-widget-toggle">
|
|
2834
|
-
<input type="checkbox" ${
|
|
2835
|
+
<input type="checkbox" ${t ? "checked" : ""} />
|
|
2835
2836
|
<span class="choco-widget-toggle-slider"></span>
|
|
2836
2837
|
</label>
|
|
2837
2838
|
</div>
|
|
@@ -2841,13 +2842,13 @@ function nn(e, n, o, i, s, u) {
|
|
|
2841
2842
|
</div>
|
|
2842
2843
|
`;
|
|
2843
2844
|
}
|
|
2844
|
-
function rn(e,
|
|
2845
|
+
function rn(e, t) {
|
|
2845
2846
|
return e ? `
|
|
2846
2847
|
<div class="choco-widget-cashback-section">
|
|
2847
2848
|
<div class="choco-widget-cashback-info">
|
|
2848
2849
|
<span class="choco-widget-cashback-icon">🎁</span>
|
|
2849
2850
|
<span class="choco-widget-cashback-text">
|
|
2850
|
-
${
|
|
2851
|
+
${t("willGet")} <strong>${e}</strong> ${t("cashback").toLowerCase()}
|
|
2851
2852
|
</span>
|
|
2852
2853
|
</div>
|
|
2853
2854
|
</div>
|
|
@@ -2855,7 +2856,7 @@ function rn(e, n) {
|
|
|
2855
2856
|
}
|
|
2856
2857
|
function on(e) {
|
|
2857
2858
|
const {
|
|
2858
|
-
amountFormatted:
|
|
2859
|
+
amountFormatted: t,
|
|
2859
2860
|
originalAmountFormatted: o,
|
|
2860
2861
|
showOriginalAmount: i = !1,
|
|
2861
2862
|
paymentMethod: s,
|
|
@@ -2898,17 +2899,17 @@ function on(e) {
|
|
|
2898
2899
|
</div>
|
|
2899
2900
|
</button>
|
|
2900
2901
|
<div class="choco-widget-google-pay-amount ${x ? "" : "choco-widget-google-pay-amount--hidden"}" aria-live="polite">
|
|
2901
|
-
<div class="choco-widget-google-pay-amount-label">${m("total")} ${
|
|
2902
|
+
<div class="choco-widget-google-pay-amount-label">${m("total")} ${t}</div>
|
|
2902
2903
|
${i ? `<div class="choco-widget-google-pay-amount-value">${m("instead")} <span class="choco-widget-google-pay-amount-value-number">${o || ""}</span></div>` : ""}
|
|
2903
2904
|
</div>
|
|
2904
2905
|
<button
|
|
2905
2906
|
class="choco-widget-pay-button ${_ ? "choco-widget-pay-button--loading" : ""} ${x ? "choco-widget-pay-button--hidden" : ""}"
|
|
2906
2907
|
data-action="pay"
|
|
2907
|
-
aria-label="${m("pay")} ${
|
|
2908
|
+
aria-label="${m("pay")} ${t}"
|
|
2908
2909
|
type="button"
|
|
2909
2910
|
${E || _ ? "disabled" : ""}
|
|
2910
2911
|
>
|
|
2911
|
-
${m("pay")} ${
|
|
2912
|
+
${m("pay")} ${t}
|
|
2912
2913
|
</button>
|
|
2913
2914
|
</div>
|
|
2914
2915
|
<div class="choco-widget-google-pay-row ${M ? "" : "choco-widget-google-pay-row--hidden"}">
|
|
@@ -2997,17 +2998,17 @@ function sn() {
|
|
|
2997
2998
|
</div>
|
|
2998
2999
|
`;
|
|
2999
3000
|
}
|
|
3000
|
-
function an(e,
|
|
3001
|
-
return At(e,
|
|
3001
|
+
function an(e, t, o, i = {}) {
|
|
3002
|
+
return At(e, t, o, i);
|
|
3002
3003
|
}
|
|
3003
3004
|
function cn(e) {
|
|
3004
3005
|
return Ee(e);
|
|
3005
3006
|
}
|
|
3006
3007
|
function An(e) {
|
|
3007
3008
|
if (typeof document > "u") return { mountTarget: null, isEmbedded: !1 };
|
|
3008
|
-
const
|
|
3009
|
-
if (
|
|
3010
|
-
const o = document.querySelector(
|
|
3009
|
+
const t = e.config.containerSelector;
|
|
3010
|
+
if (t) {
|
|
3011
|
+
const o = document.querySelector(t);
|
|
3011
3012
|
if (o instanceof HTMLElement) return { mountTarget: o, isEmbedded: !0 };
|
|
3012
3013
|
}
|
|
3013
3014
|
return { mountTarget: document.body, isEmbedded: !1 };
|
|
@@ -3015,8 +3016,8 @@ function An(e) {
|
|
|
3015
3016
|
function ut(e) {
|
|
3016
3017
|
if (typeof document > "u") return !1;
|
|
3017
3018
|
e.container || (e.container = document.createElement("div"), e.container.id = "choco-one-click-widget", e.container.className = "choco-one-click-widget");
|
|
3018
|
-
const { mountTarget:
|
|
3019
|
-
return
|
|
3019
|
+
const { mountTarget: t, isEmbedded: o } = An(e);
|
|
3020
|
+
return t ? (e.container.parentElement !== t && t.appendChild(e.container), e.container.classList.toggle("choco-one-click-widget--embedded", o), !0) : !1;
|
|
3020
3021
|
}
|
|
3021
3022
|
function un(e) {
|
|
3022
3023
|
ut(e) && (e.container.style.setProperty("--choco-widget-accent-color", e.config.color), e.container.innerHTML = sn());
|
|
@@ -3025,7 +3026,7 @@ function ln(e) {
|
|
|
3025
3026
|
var S, T, E, Q, _;
|
|
3026
3027
|
if (!ut(e)) return;
|
|
3027
3028
|
e.container.style.setProperty("--choco-widget-accent-color", e.config.color), e.container.classList.remove("choco-one-click-widget--visible");
|
|
3028
|
-
const
|
|
3029
|
+
const t = e.getAvailablePaymentMethods(), o = (S = e.checkoutContext) == null ? void 0 : S.data, i = e.config.currency || "KZT", s = (Q = (E = (T = o == null ? void 0 : o.balance) == null ? void 0 : T.data) == null ? void 0 : E.money) == null ? void 0 : Q[i], u = s > 0 ? G(s, e.config.locale, e.config.currency) : null, a = (_ = o == null ? void 0 : o.cashback) == null ? void 0 : _.data, d = (a == null ? void 0 : a.cashbackAmount) > 0 ? G(a.cashbackAmount, e.config.locale, e.config.currency) : null, g = e._getPayableAmount(), C = g < e.config.amount;
|
|
3029
3030
|
e.container.innerHTML = on({
|
|
3030
3031
|
amountFormatted: G(g, e.config.locale, e.config.currency),
|
|
3031
3032
|
originalAmountFormatted: G(
|
|
@@ -3035,7 +3036,7 @@ function ln(e) {
|
|
|
3035
3036
|
),
|
|
3036
3037
|
showOriginalAmount: C,
|
|
3037
3038
|
paymentMethod: e.selectedPaymentMethod,
|
|
3038
|
-
methods:
|
|
3039
|
+
methods: t,
|
|
3039
3040
|
selectedMethod: e.selectedPaymentMethod,
|
|
3040
3041
|
balanceFormatted: u,
|
|
3041
3042
|
useBalance: e.useBalance,
|
|
@@ -3061,23 +3062,23 @@ function ln(e) {
|
|
|
3061
3062
|
}
|
|
3062
3063
|
function Ae(e) {
|
|
3063
3064
|
var i;
|
|
3064
|
-
const
|
|
3065
|
+
const t = (i = e.container) == null ? void 0 : i.querySelector(
|
|
3065
3066
|
".choco-widget-payment-methods"
|
|
3066
3067
|
);
|
|
3067
|
-
if (!
|
|
3068
|
+
if (!t) return;
|
|
3068
3069
|
const o = e.getAvailablePaymentMethods();
|
|
3069
|
-
|
|
3070
|
+
t.innerHTML = an(
|
|
3070
3071
|
o,
|
|
3071
3072
|
e.selectedPaymentMethod,
|
|
3072
3073
|
(s) => e.t(s),
|
|
3073
3074
|
{ editMode: e.isPaymentSheetEditMode }
|
|
3074
|
-
),
|
|
3075
|
+
), t.querySelectorAll("[data-action='delete-card']").forEach((s) => {
|
|
3075
3076
|
s.addEventListener("click", (u) => {
|
|
3076
3077
|
u.stopPropagation();
|
|
3077
3078
|
const a = JSON.parse(s.getAttribute("data-method") || "{}");
|
|
3078
3079
|
pn(e, a);
|
|
3079
3080
|
});
|
|
3080
|
-
}),
|
|
3081
|
+
}), t.querySelectorAll("[data-action='select-method']").forEach((s) => {
|
|
3081
3082
|
s.addEventListener("click", (u) => {
|
|
3082
3083
|
const a = JSON.parse(
|
|
3083
3084
|
u.currentTarget.getAttribute("data-method") || "{}"
|
|
@@ -3088,14 +3089,14 @@ function Ae(e) {
|
|
|
3088
3089
|
}
|
|
3089
3090
|
function lt(e) {
|
|
3090
3091
|
var s, u, a;
|
|
3091
|
-
const
|
|
3092
|
+
const t = (s = e.container) == null ? void 0 : s.querySelector(".choco-widget-payment-method"), o = (u = e.container) == null ? void 0 : u.querySelector(".choco-widget-method-name"), i = (a = e.container) == null ? void 0 : a.querySelector(
|
|
3092
3093
|
".choco-widget-method-icon-wrapper"
|
|
3093
3094
|
);
|
|
3094
|
-
|
|
3095
|
+
t && e.selectedPaymentMethod && (t.className = `choco-widget-payment-method ${e.selectedPaymentMethod.type}`), o && e.selectedPaymentMethod && (o.className = `choco-widget-method-name ${e.selectedPaymentMethod.type}`, o.textContent = e.selectedPaymentMethod.label), i && e.selectedPaymentMethod && (i.className = `choco-widget-method-icon-wrapper ${e.selectedPaymentMethod.type}`, i.innerHTML = cn(e.selectedPaymentMethod)), dt(e);
|
|
3095
3096
|
}
|
|
3096
3097
|
function pe(e) {
|
|
3097
3098
|
var S, T, E, Q, _;
|
|
3098
|
-
const
|
|
3099
|
+
const t = (S = e.container) == null ? void 0 : S.querySelector(".choco-widget-pay-button"), o = (T = e.container) == null ? void 0 : T.querySelector(
|
|
3099
3100
|
".choco-widget-google-pay-amount"
|
|
3100
3101
|
), i = (E = e.container) == null ? void 0 : E.querySelector(
|
|
3101
3102
|
".choco-widget-google-pay-amount-label"
|
|
@@ -3110,7 +3111,7 @@ function pe(e) {
|
|
|
3110
3111
|
e.config.locale,
|
|
3111
3112
|
e.config.currency
|
|
3112
3113
|
);
|
|
3113
|
-
if (
|
|
3114
|
+
if (t && (t.textContent = `${e.t("pay")} ${d}`, t.setAttribute("aria-label", `${e.t("pay")} ${d}`)), i && (i.textContent = `${e.t("total")} ${d}`), !g) {
|
|
3114
3115
|
s == null || s.remove();
|
|
3115
3116
|
return;
|
|
3116
3117
|
}
|
|
@@ -3120,13 +3121,13 @@ function pe(e) {
|
|
|
3120
3121
|
}
|
|
3121
3122
|
function dt(e) {
|
|
3122
3123
|
var g, C, S, T, E, Q, _, m, P, k;
|
|
3123
|
-
const
|
|
3124
|
+
const t = ((g = e.selectedPaymentMethod) == null ? void 0 : g.type) === "google_pay", o = ((C = e.selectedPaymentMethod) == null ? void 0 : C.type) === "apple_pay", i = t || o, s = (S = e.container) == null ? void 0 : S.querySelector(".choco-widget-pay-button"), u = (T = e.container) == null ? void 0 : T.querySelector(
|
|
3124
3125
|
".choco-widget-google-pay-amount"
|
|
3125
3126
|
), a = (E = e.container) == null ? void 0 : E.querySelector(".choco-widget-google-pay-row"), d = (Q = e.container) == null ? void 0 : Q.querySelector(".choco-widget-apple-pay-row");
|
|
3126
3127
|
if (s == null || s.classList.toggle("choco-widget-pay-button--hidden", i), u == null || u.classList.toggle(
|
|
3127
3128
|
"choco-widget-google-pay-amount--hidden",
|
|
3128
3129
|
!i
|
|
3129
|
-
), a == null || a.classList.toggle("choco-widget-google-pay-row--hidden", !
|
|
3130
|
+
), a == null || a.classList.toggle("choco-widget-google-pay-row--hidden", !t), d == null || d.classList.toggle("choco-widget-apple-pay-row--hidden", !o), t) {
|
|
3130
3131
|
dn(e);
|
|
3131
3132
|
const w = (_ = e.container) == null ? void 0 : _.querySelector(
|
|
3132
3133
|
'[data-action="apple-pay-button-slot"]'
|
|
@@ -3151,10 +3152,10 @@ function dt(e) {
|
|
|
3151
3152
|
}
|
|
3152
3153
|
async function dn(e) {
|
|
3153
3154
|
var a, d, g, C, S;
|
|
3154
|
-
const
|
|
3155
|
+
const t = (a = e.container) == null ? void 0 : a.querySelector(
|
|
3155
3156
|
'[data-action="google-pay-button-slot"]'
|
|
3156
3157
|
);
|
|
3157
|
-
if (!
|
|
3158
|
+
if (!t || (t.innerHTML = "", ((d = e.selectedPaymentMethod) == null ? void 0 : d.type) !== "google_pay")) return;
|
|
3158
3159
|
const o = ++e._googlePayButtonRenderVersion;
|
|
3159
3160
|
try {
|
|
3160
3161
|
await e._loadGooglePaySdk();
|
|
@@ -3178,14 +3179,14 @@ async function dn(e) {
|
|
|
3178
3179
|
});
|
|
3179
3180
|
u.classList.add("choco-widget-google-pay-button"), u.style.setProperty("width", "100%", "important"), u.style.setProperty("height", "52px", "important"), u.style.setProperty("min-height", "52px", "important"), u.style.setProperty("border-radius", "12px", "important"), u.style.setProperty("font-size", "16px", "important"), u.style.setProperty("font-weight", "bold", "important"), u.querySelectorAll("*").forEach((T) => {
|
|
3180
3181
|
T.style.setProperty("border-radius", "12px", "important"), T.style.setProperty("font-weight", "bold", "important"), T.style.setProperty("font-size", "16px", "important");
|
|
3181
|
-
}),
|
|
3182
|
+
}), t.appendChild(u), ee(e);
|
|
3182
3183
|
}
|
|
3183
3184
|
function hn(e) {
|
|
3184
3185
|
var u, a;
|
|
3185
|
-
const
|
|
3186
|
+
const t = (u = e.container) == null ? void 0 : u.querySelector(
|
|
3186
3187
|
'[data-action="apple-pay-button-slot"]'
|
|
3187
3188
|
);
|
|
3188
|
-
if (!
|
|
3189
|
+
if (!t || (t.innerHTML = "", ((a = e.selectedPaymentMethod) == null ? void 0 : a.type) !== "apple_pay")) return;
|
|
3189
3190
|
const o = document.createElement("div");
|
|
3190
3191
|
o.className = "choco-widget-apple-pay-button-wrapper";
|
|
3191
3192
|
const i = document.createElement("button");
|
|
@@ -3205,7 +3206,7 @@ function hn(e) {
|
|
|
3205
3206
|
</defs>
|
|
3206
3207
|
</svg>
|
|
3207
3208
|
</span>
|
|
3208
|
-
`, o.appendChild(i), o.appendChild(s),
|
|
3209
|
+
`, o.appendChild(i), o.appendChild(s), t.appendChild(o), ee(e);
|
|
3209
3210
|
}
|
|
3210
3211
|
function te(e) {
|
|
3211
3212
|
e.loading = !0, ee(e);
|
|
@@ -3213,7 +3214,7 @@ function te(e) {
|
|
|
3213
3214
|
function j(e) {
|
|
3214
3215
|
var T, E, Q, _, m, P, k, w;
|
|
3215
3216
|
e.loading = !1;
|
|
3216
|
-
const
|
|
3217
|
+
const t = (T = e.container) == null ? void 0 : T.querySelector(".choco-widget-payment-method"), o = (E = e.container) == null ? void 0 : E.querySelector(".choco-widget-pay-button"), i = (Q = e.container) == null ? void 0 : Q.querySelector(
|
|
3217
3218
|
".choco-widget-google-pay-button-slot button"
|
|
3218
3219
|
), s = (_ = e.container) == null ? void 0 : _.querySelector(
|
|
3219
3220
|
".choco-widget-apple-pay-button-slot button"
|
|
@@ -3222,11 +3223,11 @@ function j(e) {
|
|
|
3222
3223
|
), a = (P = e.container) == null ? void 0 : P.querySelector(".choco-widget-google-pay-row"), d = (k = e.container) == null ? void 0 : k.querySelector(".choco-widget-apple-pay-row"), g = (w = e.container) == null ? void 0 : w.querySelector(
|
|
3223
3224
|
".choco-widget-balance-section"
|
|
3224
3225
|
), C = e._isInteractionBlocked(), S = e.paymentMethodDisabled || C;
|
|
3225
|
-
|
|
3226
|
+
t && (t.disabled = S), o && (o.disabled = C, o.classList.remove("choco-widget-pay-button--loading")), i && (i.disabled = C), s && (s.disabled = C), u == null || u.classList.toggle("choco-widget-wallet-blocked", C), u == null || u.setAttribute("aria-disabled", String(C)), a == null || a.classList.toggle("choco-widget-wallet-blocked", C), a == null || a.setAttribute("aria-disabled", String(C)), d == null || d.classList.toggle("choco-widget-wallet-blocked", C), d == null || d.setAttribute("aria-disabled", String(C)), g == null || g.classList.remove("disabled");
|
|
3226
3227
|
}
|
|
3227
3228
|
function ee(e) {
|
|
3228
3229
|
var T, E, Q, _, m, P, k, w;
|
|
3229
|
-
const
|
|
3230
|
+
const t = (T = e.container) == null ? void 0 : T.querySelector(".choco-widget-payment-method"), o = (E = e.container) == null ? void 0 : E.querySelector(".choco-widget-pay-button"), i = (Q = e.container) == null ? void 0 : Q.querySelector(
|
|
3230
3231
|
".choco-widget-google-pay-button-slot button"
|
|
3231
3232
|
), s = (_ = e.container) == null ? void 0 : _.querySelector(
|
|
3232
3233
|
".choco-widget-apple-pay-button-slot button"
|
|
@@ -3235,56 +3236,56 @@ function ee(e) {
|
|
|
3235
3236
|
), a = (P = e.container) == null ? void 0 : P.querySelector(".choco-widget-google-pay-row"), d = (k = e.container) == null ? void 0 : k.querySelector(".choco-widget-apple-pay-row"), g = (w = e.container) == null ? void 0 : w.querySelector(
|
|
3236
3237
|
".choco-widget-balance-section"
|
|
3237
3238
|
), C = e._isInteractionBlocked(), S = e.paymentMethodDisabled || C;
|
|
3238
|
-
g == null || g.classList.toggle("disabled", C),
|
|
3239
|
+
g == null || g.classList.toggle("disabled", C), t && (t.disabled = S), o && (o.disabled = C, o.classList.toggle("choco-widget-pay-button--loading", e.loading)), i && (i.disabled = C), s && (s.disabled = C), u == null || u.classList.toggle("choco-widget-wallet-blocked", C), u == null || u.setAttribute("aria-disabled", String(C)), a == null || a.classList.toggle("choco-widget-wallet-blocked", C), a == null || a.setAttribute("aria-disabled", String(C)), d == null || d.classList.toggle("choco-widget-wallet-blocked", C), d == null || d.setAttribute("aria-disabled", String(C));
|
|
3239
3240
|
}
|
|
3240
3241
|
function ht(e) {
|
|
3241
3242
|
var o;
|
|
3242
3243
|
if (e._isInteractionBlocked()) return;
|
|
3243
|
-
const
|
|
3244
|
-
|
|
3244
|
+
const t = (o = e.container) == null ? void 0 : o.querySelector('[data-sheet="payment"]');
|
|
3245
|
+
t && (t.classList.add("choco-widget-payment-sheet--open"), e.isPaymentSheetOpen = !0, ue(e));
|
|
3245
3246
|
}
|
|
3246
3247
|
function V(e) {
|
|
3247
3248
|
var o;
|
|
3248
|
-
const
|
|
3249
|
-
if (
|
|
3249
|
+
const t = (o = e.container) == null ? void 0 : o.querySelector('[data-sheet="payment"]');
|
|
3250
|
+
if (t) {
|
|
3250
3251
|
ve(e);
|
|
3251
|
-
const i =
|
|
3252
|
-
i && (i.style.transform = "", i.classList.remove("choco-widget-sheet-content--dragging")),
|
|
3252
|
+
const i = t.querySelector(".choco-widget-sheet-content");
|
|
3253
|
+
i && (i.style.transform = "", i.classList.remove("choco-widget-sheet-content--dragging")), t.classList.remove("choco-widget-payment-sheet--open"), e.isPaymentSheetOpen = !1, e.isPaymentSheetEditMode && (e.isPaymentSheetEditMode = !1, Ae(e), ue(e));
|
|
3253
3254
|
}
|
|
3254
3255
|
}
|
|
3255
3256
|
function ue(e) {
|
|
3256
3257
|
var g;
|
|
3257
|
-
const
|
|
3258
|
-
if (!
|
|
3259
|
-
const o =
|
|
3260
|
-
e.isPaymentSheetEditMode ? (
|
|
3258
|
+
const t = (g = e.container) == null ? void 0 : g.querySelector('[data-sheet="payment"]');
|
|
3259
|
+
if (!t) return;
|
|
3260
|
+
const o = t.querySelector(".choco-widget-sheet-title"), i = t.querySelector('[data-action="close-sheet"]'), s = t.querySelector('[data-action="edit-sheet"]'), u = t.querySelector('[data-action="previous-sheet"]'), d = e.getAvailablePaymentMethods().some((C) => C.type === "card");
|
|
3261
|
+
e.isPaymentSheetEditMode ? (t.classList.add("choco-widget-payment-sheet--edit"), o && (o.textContent = e.t("editCards")), i && (i.style.display = "none"), s && (s.style.display = "none"), u && (u.style.display = "")) : (t.classList.remove("choco-widget-payment-sheet--edit"), t.classList.toggle("choco-widget-payment-sheet--no-cards", !d), o && (o.textContent = e.t("paymentMethods")), i && (i.style.display = ""), s && (s.style.display = d ? "" : "none"), u && (u.style.display = "none"));
|
|
3261
3262
|
}
|
|
3262
3263
|
function $e(e) {
|
|
3263
3264
|
if (!e.addCardActionUrl || !e.container) return;
|
|
3264
|
-
const
|
|
3265
|
+
const t = e.container.querySelector('[data-sheet="add-card"]'), o = e.container.querySelector(
|
|
3265
3266
|
"#choco-widget-add-card-iframe"
|
|
3266
3267
|
);
|
|
3267
|
-
|
|
3268
|
+
t && o && (o.src = e.addCardActionUrl, t.classList.add("choco-widget-payment-sheet--open"), t.style.display = "flex", t.setAttribute("aria-hidden", "false"), e.isAddCardViewOpen = !0, fn(e));
|
|
3268
3269
|
}
|
|
3269
3270
|
function ae(e) {
|
|
3270
3271
|
var i, s;
|
|
3271
|
-
const
|
|
3272
|
+
const t = (i = e.container) == null ? void 0 : i.querySelector('[data-sheet="add-card"]'), o = (s = e.container) == null ? void 0 : s.querySelector(
|
|
3272
3273
|
"#choco-widget-add-card-iframe"
|
|
3273
3274
|
);
|
|
3274
|
-
|
|
3275
|
+
t && (t.classList.remove("choco-widget-payment-sheet--open"), t.style.display = "none", t.setAttribute("aria-hidden", "true")), o && (o.src = "about:blank"), e.addCardActionUrl = null, e.isAddCardViewOpen = !1, gn(e);
|
|
3275
3276
|
}
|
|
3276
3277
|
function fn(e) {
|
|
3277
|
-
e._boundAddCardMessage = (
|
|
3278
|
+
e._boundAddCardMessage = (t) => {
|
|
3278
3279
|
var o;
|
|
3279
|
-
e.isAddCardViewOpen && (o =
|
|
3280
|
+
e.isAddCardViewOpen && (o = t.data) != null && o.message && t.origin === "https://rahmetapp.kz" && te(e);
|
|
3280
3281
|
}, window.addEventListener("message", e._boundAddCardMessage);
|
|
3281
3282
|
}
|
|
3282
3283
|
function gn(e) {
|
|
3283
3284
|
e._boundAddCardMessage && (window.removeEventListener("message", e._boundAddCardMessage), e._boundAddCardMessage = null);
|
|
3284
3285
|
}
|
|
3285
|
-
function pn(e,
|
|
3286
|
+
function pn(e, t) {
|
|
3286
3287
|
var a;
|
|
3287
|
-
e._pendingDeleteMethod =
|
|
3288
|
+
e._pendingDeleteMethod = t;
|
|
3288
3289
|
const o = (a = e.container) == null ? void 0 : a.querySelector('[data-sheet="payment"]');
|
|
3289
3290
|
if (!o) return;
|
|
3290
3291
|
o.classList.add("choco-widget-payment-sheet--delete-confirm");
|
|
@@ -3294,10 +3295,10 @@ function pn(e, n) {
|
|
|
3294
3295
|
function ve(e) {
|
|
3295
3296
|
var o;
|
|
3296
3297
|
e._pendingDeleteMethod = null, Ne(e, !1);
|
|
3297
|
-
const
|
|
3298
|
-
|
|
3298
|
+
const t = (o = e.container) == null ? void 0 : o.querySelector('[data-sheet="payment"]');
|
|
3299
|
+
t == null || t.classList.remove("choco-widget-payment-sheet--delete-confirm"), ue(e);
|
|
3299
3300
|
}
|
|
3300
|
-
function Ne(e,
|
|
3301
|
+
function Ne(e, t) {
|
|
3301
3302
|
var u, a, d;
|
|
3302
3303
|
const o = (u = e.container) == null ? void 0 : u.querySelector(
|
|
3303
3304
|
".choco-widget-sheet-delete-confirm-actions"
|
|
@@ -3306,12 +3307,12 @@ function Ne(e, n) {
|
|
|
3306
3307
|
), s = (d = e.container) == null ? void 0 : d.querySelector(
|
|
3307
3308
|
'[data-action="confirm-delete-submit"]'
|
|
3308
3309
|
);
|
|
3309
|
-
o == null || o.classList.toggle("choco-widget-sheet-delete-confirm-actions--loading",
|
|
3310
|
+
o == null || o.classList.toggle("choco-widget-sheet-delete-confirm-actions--loading", t), i && (i.disabled = t), s && (s.disabled = t, s.classList.toggle("choco-widget-delete-confirm-btn--loading", t));
|
|
3310
3311
|
}
|
|
3311
|
-
async function Cn(e,
|
|
3312
|
+
async function Cn(e, t) {
|
|
3312
3313
|
var i, s;
|
|
3313
|
-
const o =
|
|
3314
|
-
if (!(!o || (
|
|
3314
|
+
const o = t == null ? void 0 : t.cardId;
|
|
3315
|
+
if (!(!o || (t == null ? void 0 : t.type) !== "card"))
|
|
3315
3316
|
try {
|
|
3316
3317
|
await Dt(e.apiUrl, e._getApiConfig(), o), e.checkoutContext = await Oe(
|
|
3317
3318
|
e.apiUrl,
|
|
@@ -3326,10 +3327,10 @@ async function Cn(e, n) {
|
|
|
3326
3327
|
});
|
|
3327
3328
|
}
|
|
3328
3329
|
}
|
|
3329
|
-
function ft(e,
|
|
3330
|
+
function ft(e, t) {
|
|
3330
3331
|
if (!e._isInteractionBlocked()) {
|
|
3331
|
-
if (e.selectedPaymentMethod =
|
|
3332
|
-
e._emitUserEvent("one_click_pay_method_resolved", { payment_method:
|
|
3332
|
+
if (e.selectedPaymentMethod = t, e._emitPaymentMethodSelected(), t.type === "new_card") {
|
|
3333
|
+
e._emitUserEvent("one_click_pay_method_resolved", { payment_method: t.type }), V(e), e.handlePayment();
|
|
3333
3334
|
return;
|
|
3334
3335
|
}
|
|
3335
3336
|
e._emitUserEvent("one_click_pay_method_resolved", {
|
|
@@ -3337,22 +3338,22 @@ function ft(e, n) {
|
|
|
3337
3338
|
}), Ae(e), V(e), lt(e);
|
|
3338
3339
|
}
|
|
3339
3340
|
}
|
|
3340
|
-
function et(e,
|
|
3341
|
+
function et(e, t) {
|
|
3341
3342
|
var i;
|
|
3342
|
-
const o =
|
|
3343
|
+
const o = t.type || ((i = t.data) == null ? void 0 : i.type);
|
|
3343
3344
|
if (!o) {
|
|
3344
|
-
console.warn("Unknown event format:",
|
|
3345
|
+
console.warn("Unknown event format:", t);
|
|
3345
3346
|
return;
|
|
3346
3347
|
}
|
|
3347
3348
|
switch (o) {
|
|
3348
3349
|
case "order.paid":
|
|
3349
|
-
e._orderStatusResolved = !0, $(e), pt(e,
|
|
3350
|
+
e._orderStatusResolved = !0, $(e), pt(e, t);
|
|
3350
3351
|
break;
|
|
3351
3352
|
case "order.failed":
|
|
3352
|
-
e._orderStatusResolved = !0, $(e), Ct(e,
|
|
3353
|
+
e._orderStatusResolved = !0, $(e), Ct(e, t);
|
|
3353
3354
|
break;
|
|
3354
3355
|
case "order.action_required":
|
|
3355
|
-
yn(e,
|
|
3356
|
+
yn(e, t);
|
|
3356
3357
|
break;
|
|
3357
3358
|
default:
|
|
3358
3359
|
console.warn("Unknown event type:", o);
|
|
@@ -3361,7 +3362,7 @@ function et(e, n) {
|
|
|
3361
3362
|
function $(e) {
|
|
3362
3363
|
e._orderStatusPollingId && (clearInterval(e._orderStatusPollingId), e._orderStatusPollingId = null);
|
|
3363
3364
|
}
|
|
3364
|
-
function ce(e,
|
|
3365
|
+
function ce(e, t) {
|
|
3365
3366
|
$(e), e._orderStatusResolved = !1;
|
|
3366
3367
|
const o = 6e3, i = 5;
|
|
3367
3368
|
let s = 0;
|
|
@@ -3378,17 +3379,17 @@ function ce(e, n) {
|
|
|
3378
3379
|
const { data: a } = await Ut(
|
|
3379
3380
|
e.apiUrl,
|
|
3380
3381
|
e._getApiConfig(),
|
|
3381
|
-
String(
|
|
3382
|
+
String(t)
|
|
3382
3383
|
), d = a == null ? void 0 : a.status, g = (a == null ? void 0 : a.payload) || {};
|
|
3383
3384
|
if (d === "success") {
|
|
3384
3385
|
e._orderStatusResolved = !0, $(e), pt(e, {
|
|
3385
|
-
id: String(g.id ||
|
|
3386
|
+
id: String(g.id || t),
|
|
3386
3387
|
attributes: { amount: g.amount, paid_at: g.paid_at || "" }
|
|
3387
3388
|
});
|
|
3388
3389
|
return;
|
|
3389
3390
|
}
|
|
3390
3391
|
d === "fail" && (e._orderStatusResolved = !0, $(e), Ct(e, {
|
|
3391
|
-
id: String(g.id ||
|
|
3392
|
+
id: String(g.id || t),
|
|
3392
3393
|
attributes: { message: g.message || e.t("paymentError") }
|
|
3393
3394
|
}));
|
|
3394
3395
|
} catch (a) {
|
|
@@ -3401,33 +3402,33 @@ function ce(e, n) {
|
|
|
3401
3402
|
function Xe() {
|
|
3402
3403
|
return typeof document > "u" ? !1 : document.hidden || document.visibilityState === "hidden";
|
|
3403
3404
|
}
|
|
3404
|
-
function gt(e,
|
|
3405
|
-
j(e), e.config.onSuccess(
|
|
3405
|
+
function gt(e, t) {
|
|
3406
|
+
j(e), e.config.onSuccess(t);
|
|
3406
3407
|
}
|
|
3407
3408
|
function Te(e) {
|
|
3408
3409
|
if (!e._pendingSuccessPayload || Xe()) return;
|
|
3409
|
-
const
|
|
3410
|
-
e._pendingSuccessPayload = null, gt(e,
|
|
3410
|
+
const t = e._pendingSuccessPayload;
|
|
3411
|
+
e._pendingSuccessPayload = null, gt(e, t);
|
|
3411
3412
|
}
|
|
3412
|
-
function pt(e,
|
|
3413
|
+
function pt(e, t) {
|
|
3413
3414
|
var s, u;
|
|
3414
3415
|
e.isAddCardViewOpen && ae(e);
|
|
3415
|
-
const o =
|
|
3416
|
+
const o = t.attributes || ((s = t.data) == null ? void 0 : s.attributes) || {}, i = { id: t.id || ((u = t.data) == null ? void 0 : u.id), attributes: o };
|
|
3416
3417
|
if (Xe()) {
|
|
3417
3418
|
e._pendingSuccessPayload = i;
|
|
3418
3419
|
return;
|
|
3419
3420
|
}
|
|
3420
3421
|
gt(e, i);
|
|
3421
3422
|
}
|
|
3422
|
-
function Ct(e,
|
|
3423
|
+
function Ct(e, t) {
|
|
3423
3424
|
var i, s;
|
|
3424
3425
|
e.isAddCardViewOpen && ae(e), j(e);
|
|
3425
|
-
const o =
|
|
3426
|
-
e.config.onError({ id:
|
|
3426
|
+
const o = t.attributes || ((i = t.data) == null ? void 0 : i.attributes) || {};
|
|
3427
|
+
e.config.onError({ id: t.id || ((s = t.data) == null ? void 0 : s.id), attributes: o });
|
|
3427
3428
|
}
|
|
3428
|
-
function yn(e,
|
|
3429
|
+
function yn(e, t) {
|
|
3429
3430
|
var u, a, d;
|
|
3430
|
-
const o =
|
|
3431
|
+
const o = t.attributes || ((u = t.data) == null ? void 0 : u.attributes) || {}, i = o.action_link || o.action_url, s = o.action_url_type || o.action_type || "redirect";
|
|
3431
3432
|
if (!i) {
|
|
3432
3433
|
console.error(e.t("errorActionUrlMissing")), e.waitingForNewCardAction && (e.waitingForNewCardAction = !1, j(e), e.config.onError({ attributes: { message: e.t("errorNoServerResponse") } }));
|
|
3433
3434
|
return;
|
|
@@ -3437,13 +3438,13 @@ function yn(e, n) {
|
|
|
3437
3438
|
return;
|
|
3438
3439
|
}
|
|
3439
3440
|
if (((a = e.selectedPaymentMethod) == null ? void 0 : a.type) === "kaspi_pay") {
|
|
3440
|
-
const g =
|
|
3441
|
+
const g = t.id || ((d = t.data) == null ? void 0 : d.id);
|
|
3441
3442
|
if (g && !e._orderStatusResolved && !e._orderStatusPollingId && ce(e, String(g)), typeof e.config.onKaspiLink == "function") {
|
|
3442
3443
|
e.config.onKaspiLink({
|
|
3443
3444
|
action_link: i,
|
|
3444
3445
|
action_url: i,
|
|
3445
3446
|
action_type: s,
|
|
3446
|
-
event:
|
|
3447
|
+
event: t
|
|
3447
3448
|
});
|
|
3448
3449
|
return;
|
|
3449
3450
|
}
|
|
@@ -3458,7 +3459,7 @@ async function mn(e) {
|
|
|
3458
3459
|
});
|
|
3459
3460
|
return;
|
|
3460
3461
|
}
|
|
3461
|
-
const { checkoutOptions:
|
|
3462
|
+
const { checkoutOptions: t } = e._getPaymentBreakdown();
|
|
3462
3463
|
if (e._isBalanceFullyCoveringAmount()) {
|
|
3463
3464
|
te(e);
|
|
3464
3465
|
try {
|
|
@@ -3467,7 +3468,7 @@ async function mn(e) {
|
|
|
3467
3468
|
e._getApiConfig(),
|
|
3468
3469
|
e.deviceId,
|
|
3469
3470
|
e.selectedPaymentMethod,
|
|
3470
|
-
|
|
3471
|
+
t
|
|
3471
3472
|
);
|
|
3472
3473
|
await tt(e);
|
|
3473
3474
|
const d = (a == null ? void 0 : a.id) ?? ((o = a == null ? void 0 : a.data) == null ? void 0 : o.id);
|
|
@@ -3479,15 +3480,15 @@ async function mn(e) {
|
|
|
3479
3480
|
}
|
|
3480
3481
|
}
|
|
3481
3482
|
if (e.selectedPaymentMethod.type === "new_card") {
|
|
3482
|
-
await bn(e,
|
|
3483
|
+
await bn(e, t);
|
|
3483
3484
|
return;
|
|
3484
3485
|
}
|
|
3485
3486
|
if (e.selectedPaymentMethod.type === "apple_pay") {
|
|
3486
|
-
await En(e,
|
|
3487
|
+
await En(e, t);
|
|
3487
3488
|
return;
|
|
3488
3489
|
}
|
|
3489
3490
|
if (e.selectedPaymentMethod.type === "google_pay") {
|
|
3490
|
-
await vn(e,
|
|
3491
|
+
await vn(e, t);
|
|
3491
3492
|
return;
|
|
3492
3493
|
}
|
|
3493
3494
|
te(e);
|
|
@@ -3497,7 +3498,7 @@ async function mn(e) {
|
|
|
3497
3498
|
e._getApiConfig(),
|
|
3498
3499
|
e.deviceId,
|
|
3499
3500
|
e.selectedPaymentMethod,
|
|
3500
|
-
|
|
3501
|
+
t
|
|
3501
3502
|
);
|
|
3502
3503
|
await tt(e);
|
|
3503
3504
|
const d = (a == null ? void 0 : a.id) ?? ((i = a == null ? void 0 : a.data) == null ? void 0 : i.id);
|
|
@@ -3517,8 +3518,8 @@ async function mn(e) {
|
|
|
3517
3518
|
}
|
|
3518
3519
|
}
|
|
3519
3520
|
async function tt(e) {
|
|
3520
|
-
var
|
|
3521
|
-
if (!(((
|
|
3521
|
+
var t, o;
|
|
3522
|
+
if (!(((t = e.selectedPaymentMethod) == null ? void 0 : t.type) !== "card" || !((o = e.selectedPaymentMethod) != null && o.cardId)))
|
|
3522
3523
|
try {
|
|
3523
3524
|
await Xt(
|
|
3524
3525
|
e.apiUrl,
|
|
@@ -3529,14 +3530,14 @@ async function tt(e) {
|
|
|
3529
3530
|
console.warn("Failed to mark selected card as default:", i);
|
|
3530
3531
|
}
|
|
3531
3532
|
}
|
|
3532
|
-
async function bn(e,
|
|
3533
|
+
async function bn(e, t) {
|
|
3533
3534
|
te(e), e.waitingForNewCardAction = !0, e._setNewCardActionTimeout();
|
|
3534
3535
|
try {
|
|
3535
3536
|
await Ht(
|
|
3536
3537
|
e.apiUrl,
|
|
3537
3538
|
e._getApiConfig(),
|
|
3538
3539
|
e.deviceId,
|
|
3539
|
-
|
|
3540
|
+
t
|
|
3540
3541
|
);
|
|
3541
3542
|
} catch (o) {
|
|
3542
3543
|
e.waitingForNewCardAction = !1, e._clearNewCardActionTimeout(), j(e), e.config.onError({
|
|
@@ -3545,7 +3546,7 @@ async function bn(e, n) {
|
|
|
3545
3546
|
}
|
|
3546
3547
|
}
|
|
3547
3548
|
let se = null;
|
|
3548
|
-
async function En(e,
|
|
3549
|
+
async function En(e, t) {
|
|
3549
3550
|
const o = window.ApplePaySession;
|
|
3550
3551
|
if (!o || !o.canMakePayments()) {
|
|
3551
3552
|
e.config.onError({ attributes: { message: e.t("errorApplePayUnsupported") } });
|
|
@@ -3593,7 +3594,7 @@ async function En(e, n) {
|
|
|
3593
3594
|
e._getApiConfig(),
|
|
3594
3595
|
e.deviceId,
|
|
3595
3596
|
u.payment,
|
|
3596
|
-
|
|
3597
|
+
t
|
|
3597
3598
|
);
|
|
3598
3599
|
s.completePayment(o.STATUS_SUCCESS), se = null;
|
|
3599
3600
|
const g = (d == null ? void 0 : d.id) ?? ((a = d == null ? void 0 : d.data) == null ? void 0 : a.id);
|
|
@@ -3609,7 +3610,7 @@ async function En(e, n) {
|
|
|
3609
3610
|
se = null, e.config.onCancel();
|
|
3610
3611
|
}, s.begin();
|
|
3611
3612
|
}
|
|
3612
|
-
async function vn(e,
|
|
3613
|
+
async function vn(e, t) {
|
|
3613
3614
|
var P, k, w, L, O, F;
|
|
3614
3615
|
const o = (P = e.checkoutContext) == null ? void 0 : P.data, i = ((w = (k = o == null ? void 0 : o.payment_methods) == null ? void 0 : k.data) == null ? void 0 : w.attributes) || {}, s = i.google_pay_settings || {};
|
|
3615
3616
|
if (!(i.payment_method_google_pay === "enabled" || i.payment_method_google_pay === !0)) {
|
|
@@ -3631,7 +3632,7 @@ async function vn(e, n) {
|
|
|
3631
3632
|
return;
|
|
3632
3633
|
}
|
|
3633
3634
|
if (e.config.isNativeAndroid) {
|
|
3634
|
-
await Bn(e,
|
|
3635
|
+
await Bn(e, t, { gateway: a, gatewayMerchantId: d });
|
|
3635
3636
|
return;
|
|
3636
3637
|
}
|
|
3637
3638
|
const T = Number(e._getCheckoutAmount()).toFixed(2);
|
|
@@ -3692,7 +3693,7 @@ async function vn(e, n) {
|
|
|
3692
3693
|
e._getApiConfig(),
|
|
3693
3694
|
e.deviceId,
|
|
3694
3695
|
q,
|
|
3695
|
-
|
|
3696
|
+
t
|
|
3696
3697
|
), b = (N == null ? void 0 : N.id) ?? ((F = N == null ? void 0 : N.data) == null ? void 0 : F.id);
|
|
3697
3698
|
b && ce(e, String(b));
|
|
3698
3699
|
} catch (M) {
|
|
@@ -3703,7 +3704,7 @@ async function vn(e, n) {
|
|
|
3703
3704
|
}), console.error("Google Pay error:", M));
|
|
3704
3705
|
}
|
|
3705
3706
|
}
|
|
3706
|
-
async function Bn(e,
|
|
3707
|
+
async function Bn(e, t, o) {
|
|
3707
3708
|
var i;
|
|
3708
3709
|
if (!e.config.onPayWithGooglePay) {
|
|
3709
3710
|
e.config.onError({ attributes: { message: e.t("errorGooglePayUnsupported") } });
|
|
@@ -3720,7 +3721,7 @@ async function Bn(e, n, o) {
|
|
|
3720
3721
|
e._getApiConfig(),
|
|
3721
3722
|
e.deviceId,
|
|
3722
3723
|
u,
|
|
3723
|
-
|
|
3724
|
+
t
|
|
3724
3725
|
), d = (a == null ? void 0 : a.id) ?? ((i = a == null ? void 0 : a.data) == null ? void 0 : i.id);
|
|
3725
3726
|
d && ce(e, String(d));
|
|
3726
3727
|
} catch (s) {
|
|
@@ -3733,19 +3734,19 @@ async function Bn(e, n, o) {
|
|
|
3733
3734
|
}
|
|
3734
3735
|
function In(e) {
|
|
3735
3736
|
var u, a, d, g, C, S, T, E, Q, _;
|
|
3736
|
-
const
|
|
3737
|
-
(u =
|
|
3737
|
+
const t = e.container;
|
|
3738
|
+
(u = t.querySelector('[data-action="pay"]')) == null || u.addEventListener("click", () => e.handlePayment()), (a = t.querySelector('[data-action="change-method"]')) == null || a.addEventListener("click", () => ht(e)), t.querySelectorAll('[data-action="close"]').forEach((m) => m.addEventListener("click", () => e.close())), (d = t.querySelector('[data-action="close-sheet"]')) == null || d.addEventListener("click", () => {
|
|
3738
3739
|
e._pendingDeleteMethod ? ve(e) : V(e);
|
|
3739
|
-
}), (g =
|
|
3740
|
+
}), (g = t.querySelector('[data-action="edit-sheet"]')) == null || g.addEventListener("click", () => {
|
|
3740
3741
|
e.isPaymentSheetEditMode = !0, Ae(e), ue(e);
|
|
3741
|
-
}), (C =
|
|
3742
|
+
}), (C = t.querySelector('[data-action="previous-sheet"]')) == null || C.addEventListener("click", () => {
|
|
3742
3743
|
e.isPaymentSheetEditMode = !1, Ae(e), ue(e);
|
|
3743
|
-
}), (S =
|
|
3744
|
+
}), (S = t.querySelector('[data-action="close-add-card"]')) == null || S.addEventListener("click", () => ae(e)), (T = t.querySelector('[data-action="confirm-delete-cancel"]')) == null || T.addEventListener("click", () => ve(e)), (E = t.querySelector('[data-action="confirm-delete-submit"]')) == null || E.addEventListener("click", () => {
|
|
3744
3745
|
if (e._pendingDeleteMethod) {
|
|
3745
3746
|
const m = e._pendingDeleteMethod;
|
|
3746
3747
|
Ne(e, !0), Cn(e, m).then(() => V(e)).finally(() => Ne(e, !1));
|
|
3747
3748
|
}
|
|
3748
|
-
}),
|
|
3749
|
+
}), t.querySelectorAll(".choco-widget-method-item").forEach((m) => {
|
|
3749
3750
|
m.addEventListener("click", (P) => {
|
|
3750
3751
|
const k = JSON.parse(
|
|
3751
3752
|
P.currentTarget.getAttribute("data-method") || "{}"
|
|
@@ -3753,25 +3754,25 @@ function In(e) {
|
|
|
3753
3754
|
ft(e, k);
|
|
3754
3755
|
});
|
|
3755
3756
|
});
|
|
3756
|
-
const o =
|
|
3757
|
+
const o = t.querySelector('[data-sheet="payment"]');
|
|
3757
3758
|
o && (o.addEventListener("click", (m) => {
|
|
3758
3759
|
m.target === o && V(e);
|
|
3759
3760
|
}), Sn(e, o));
|
|
3760
|
-
const i =
|
|
3761
|
+
const i = t.querySelector('[data-action="toggle-balance"]');
|
|
3761
3762
|
i && ((Q = i.querySelector("input[type='checkbox']")) == null || Q.addEventListener("change", (m) => {
|
|
3762
3763
|
e.useBalance = m.target.checked, e._updatePayButtonAmount();
|
|
3763
3764
|
}));
|
|
3764
|
-
const s =
|
|
3765
|
+
const s = t.querySelector('[data-action="toggle-bonuses"]');
|
|
3765
3766
|
s && ((_ = s.querySelector("input[type='checkbox']")) == null || _.addEventListener("change", (m) => {
|
|
3766
3767
|
e.useBonuses = m.target.checked, e.config.onAppliedBonus(e.useBonuses), e._updatePayButtonAmount();
|
|
3767
3768
|
})), document.removeEventListener("keydown", e._boundKeyDown), document.addEventListener("keydown", e._boundKeyDown), dt(e);
|
|
3768
3769
|
}
|
|
3769
|
-
function Qn(e,
|
|
3770
|
+
function Qn(e, t) {
|
|
3770
3771
|
var o, i;
|
|
3771
|
-
e.isOpen && (
|
|
3772
|
+
e.isOpen && (t.key === "Escape" && (t.preventDefault(), e._pendingDeleteMethod ? ve(e) : e.isAddCardViewOpen ? ae(e) : e.isPaymentSheetOpen ? V(e) : e.close()), t.key === "Enter" && ((i = (o = t.target) == null ? void 0 : o.dataset) == null ? void 0 : i.action) === "pay" && (t.preventDefault(), e.handlePayment()));
|
|
3772
3773
|
}
|
|
3773
|
-
function Sn(e,
|
|
3774
|
-
const o =
|
|
3774
|
+
function Sn(e, t) {
|
|
3775
|
+
const o = t.querySelector('[data-action="sheet-drag-handle"]'), i = t.querySelector(".choco-widget-sheet-content");
|
|
3775
3776
|
if (!o || !i) return;
|
|
3776
3777
|
const s = 80;
|
|
3777
3778
|
let u = 0, a = 0;
|
|
@@ -3797,33 +3798,33 @@ function Sn(e, n) {
|
|
|
3797
3798
|
}
|
|
3798
3799
|
class ie {
|
|
3799
3800
|
// ─── Статические методы / logout ─────────────────────────────────────────────
|
|
3800
|
-
static _getAuthStorageValue(
|
|
3801
|
-
return it(
|
|
3801
|
+
static _getAuthStorageValue(t) {
|
|
3802
|
+
return it(t);
|
|
3802
3803
|
}
|
|
3803
|
-
static _setAuthStorageValue(
|
|
3804
|
-
Re(
|
|
3804
|
+
static _setAuthStorageValue(t, o) {
|
|
3805
|
+
Re(t, o);
|
|
3805
3806
|
}
|
|
3806
|
-
static _removeAuthStorageValue(
|
|
3807
|
-
be(
|
|
3807
|
+
static _removeAuthStorageValue(t) {
|
|
3808
|
+
be(t);
|
|
3808
3809
|
}
|
|
3809
3810
|
static async logout() {
|
|
3810
3811
|
Ze();
|
|
3811
3812
|
}
|
|
3812
3813
|
// ─── Конструктор ──────────────────────────────────────────────────────────────
|
|
3813
|
-
constructor(
|
|
3814
|
-
this.config = Jt(
|
|
3814
|
+
constructor(t) {
|
|
3815
|
+
this.config = Jt(t), this.accessToken = null, this.deviceId = nt(), this.apiUrl = Et(this.config.environment), this.translations = mt, this.checkoutContext = null, this.centrifuge = null, this.selectedPaymentMethod = null, this.container = null, this.isOpen = !1, this.isPaymentSheetOpen = !1, this.isPaymentSheetEditMode = !1, this.loading = !1, this.disabled = !1, this.paymentMethodDisabled = !1, this.useBalance = !1, this.useBonuses = !1, this.addCardActionUrl = null, this.isAddCardViewOpen = !1, this.waitingForNewCardAction = !1, this.newCardActionRequiredTimeoutId = null, this._googlePayScriptPromise = null, this._googlePayButtonRenderVersion = 0, this._orderStatusPollingId = null, this._orderStatusResolved = !1, this._pendingDeleteMethod = null, this._pendingSuccessPayload = null, this._lifecycleListenersAttached = !1, this._boundAddCardMessage = null, this._boundKeyDown = (o) => Qn(this, o), this._boundVisibilityChange = () => this._onVisibilityChange(), this._boundWindowFocus = () => this._onWindowFocus(), this._boundPageShow = () => this._onPageShow();
|
|
3815
3816
|
}
|
|
3816
3817
|
// ─── Локализация ──────────────────────────────────────────────────────────────
|
|
3817
|
-
t(
|
|
3818
|
+
t(t, o = {}) {
|
|
3818
3819
|
var u;
|
|
3819
|
-
const i = this.config.locale || "ru", s = ((u = this.translations[i]) == null ? void 0 : u[
|
|
3820
|
-
return typeof s != "string" ?
|
|
3820
|
+
const i = this.config.locale || "ru", s = ((u = this.translations[i]) == null ? void 0 : u[t]) || this.translations.ru[t];
|
|
3821
|
+
return typeof s != "string" ? t : s.replace(
|
|
3821
3822
|
/{(\w+)}/g,
|
|
3822
3823
|
(a, d) => Object.prototype.hasOwnProperty.call(o, d) ? String(o[d]) : a
|
|
3823
3824
|
);
|
|
3824
3825
|
}
|
|
3825
|
-
_resolveErrorMessage(
|
|
3826
|
-
return (
|
|
3826
|
+
_resolveErrorMessage(t, o = "paymentError") {
|
|
3827
|
+
return (t == null ? void 0 : t.message) || this.t(o);
|
|
3827
3828
|
}
|
|
3828
3829
|
// ─── Вспомогательные геттеры ─────────────────────────────────────────────────
|
|
3829
3830
|
_getApiConfig() {
|
|
@@ -3834,26 +3835,26 @@ class ie {
|
|
|
3834
3835
|
}
|
|
3835
3836
|
_getBalanceAmount() {
|
|
3836
3837
|
var s, u, a, d;
|
|
3837
|
-
const
|
|
3838
|
+
const t = (d = (a = (u = (s = this.checkoutContext) == null ? void 0 : s.data) == null ? void 0 : u.balance) == null ? void 0 : a.data) == null ? void 0 : d.money, o = this.config.currency || "KZT", i = Number(t == null ? void 0 : t[o]);
|
|
3838
3839
|
return Number.isFinite(i) && i > 0 ? i : 0;
|
|
3839
3840
|
}
|
|
3840
3841
|
_getBonusesAmount() {
|
|
3841
3842
|
var o;
|
|
3842
|
-
const
|
|
3843
|
-
return Number.isFinite(
|
|
3843
|
+
const t = Number((o = this.config.bonuses) == null ? void 0 : o.amount);
|
|
3844
|
+
return Number.isFinite(t) && t > 0 ? t : 0;
|
|
3844
3845
|
}
|
|
3845
3846
|
_getBonusesPercent() {
|
|
3846
3847
|
var o;
|
|
3847
|
-
const
|
|
3848
|
-
return !Number.isFinite(
|
|
3848
|
+
const t = Number((o = this.config.bonuses) == null ? void 0 : o.percent);
|
|
3849
|
+
return !Number.isFinite(t) || t <= 0 ? 0 : t >= 100 ? 100 : t;
|
|
3849
3850
|
}
|
|
3850
3851
|
_getAvailableBonus() {
|
|
3851
3852
|
var o;
|
|
3852
|
-
const
|
|
3853
|
-
return Number.isFinite(
|
|
3853
|
+
const t = Number((o = this.config.bonuses) == null ? void 0 : o.availableBonus);
|
|
3854
|
+
return Number.isFinite(t) && t > 0 ? t : 0;
|
|
3854
3855
|
}
|
|
3855
3856
|
_getPaymentBreakdown() {
|
|
3856
|
-
const
|
|
3857
|
+
const t = this.config.amount, o = this._getBalanceAmount(), i = this.useBalance ? Math.min(o, t) : 0, s = t - i, u = this.useBalance && i >= t, a = this.useBonuses ? this._getAvailableBonus() : 0, d = Math.max(s - a, 0), g = this.useBalance ? t : d, C = this.useBalance && !u;
|
|
3857
3858
|
return {
|
|
3858
3859
|
payableAmount: d,
|
|
3859
3860
|
checkoutOptions: {
|
|
@@ -3873,8 +3874,8 @@ class ie {
|
|
|
3873
3874
|
return this._getPaymentBreakdown().checkoutOptions.checkoutAmount ?? this.config.amount;
|
|
3874
3875
|
}
|
|
3875
3876
|
_getPaymentMethodForUserEvent() {
|
|
3876
|
-
var
|
|
3877
|
-
return this._isBalanceFullyCoveringAmount() ? "balance" : ((
|
|
3877
|
+
var t;
|
|
3878
|
+
return this._isBalanceFullyCoveringAmount() ? "balance" : ((t = this.selectedPaymentMethod) == null ? void 0 : t.type) ?? null;
|
|
3878
3879
|
}
|
|
3879
3880
|
_getKaspiOptions() {
|
|
3880
3881
|
return {
|
|
@@ -3884,11 +3885,11 @@ class ie {
|
|
|
3884
3885
|
};
|
|
3885
3886
|
}
|
|
3886
3887
|
// ─── Эмиттеры ────────────────────────────────────────────────────────────────
|
|
3887
|
-
_emitUserEvent(
|
|
3888
|
-
typeof this.config.onUserEvent == "function" && this.config.onUserEvent({ eventName:
|
|
3888
|
+
_emitUserEvent(t, o = {}) {
|
|
3889
|
+
typeof this.config.onUserEvent == "function" && this.config.onUserEvent({ eventName: t, eventProperties: o });
|
|
3889
3890
|
}
|
|
3890
|
-
_emitPaymentMethodSelected(
|
|
3891
|
-
typeof this.config.onPaymentMethodSelected == "function" && this.config.onPaymentMethodSelected(
|
|
3891
|
+
_emitPaymentMethodSelected(t = this.selectedPaymentMethod) {
|
|
3892
|
+
typeof this.config.onPaymentMethodSelected == "function" && this.config.onPaymentMethodSelected(t || null);
|
|
3892
3893
|
}
|
|
3893
3894
|
// ─── Делегаторы в модули (вызываются из domUI/events через widget.method()) ──
|
|
3894
3895
|
_attachEventListeners() {
|
|
@@ -3915,25 +3916,25 @@ class ie {
|
|
|
3915
3916
|
this.newCardActionRequiredTimeoutId && (window.clearTimeout(this.newCardActionRequiredTimeoutId), this.newCardActionRequiredTimeoutId = null);
|
|
3916
3917
|
}
|
|
3917
3918
|
// ─── Хранение токенов ────────────────────────────────────────────────────────
|
|
3918
|
-
_saveTokensToStorage(
|
|
3919
|
-
Me(
|
|
3919
|
+
_saveTokensToStorage(t, o) {
|
|
3920
|
+
Me(t, o);
|
|
3920
3921
|
}
|
|
3921
3922
|
_clearAuthStorage() {
|
|
3922
3923
|
Ze();
|
|
3923
3924
|
}
|
|
3924
|
-
_getAuthStorageValue(
|
|
3925
|
-
return ie._getAuthStorageValue(
|
|
3925
|
+
_getAuthStorageValue(t) {
|
|
3926
|
+
return ie._getAuthStorageValue(t);
|
|
3926
3927
|
}
|
|
3927
|
-
_setAuthStorageValue(
|
|
3928
|
-
ie._setAuthStorageValue(
|
|
3928
|
+
_setAuthStorageValue(t, o) {
|
|
3929
|
+
ie._setAuthStorageValue(t, o);
|
|
3929
3930
|
}
|
|
3930
|
-
_removeAuthStorageValue(
|
|
3931
|
-
ie._removeAuthStorageValue(
|
|
3931
|
+
_removeAuthStorageValue(t) {
|
|
3932
|
+
ie._removeAuthStorageValue(t);
|
|
3932
3933
|
}
|
|
3933
3934
|
// ─── Google Pay SDK (используется из domUI + paymentFlow) ────────────────────
|
|
3934
3935
|
_loadGooglePaySdk() {
|
|
3935
|
-
var
|
|
3936
|
-
return typeof window > "u" || typeof document > "u" ? Promise.reject(new Error("Google Pay SDK requires browser environment")) : (o = (
|
|
3936
|
+
var t, o;
|
|
3937
|
+
return typeof window > "u" || typeof document > "u" ? Promise.reject(new Error("Google Pay SDK requires browser environment")) : (o = (t = window.google) == null ? void 0 : t.payments) != null && o.api ? Promise.resolve() : this._googlePayScriptPromise ? this._googlePayScriptPromise : (this._googlePayScriptPromise = new Promise((i, s) => {
|
|
3937
3938
|
const u = document.querySelector(
|
|
3938
3939
|
'script[data-choco-google-pay-sdk="true"]'
|
|
3939
3940
|
);
|
|
@@ -3978,14 +3979,14 @@ class ie {
|
|
|
3978
3979
|
this.apiUrl,
|
|
3979
3980
|
this._getApiConfig()
|
|
3980
3981
|
);
|
|
3981
|
-
} catch (
|
|
3982
|
-
if (
|
|
3982
|
+
} catch (t) {
|
|
3983
|
+
if (t.status === 401)
|
|
3983
3984
|
this._removeAuthStorageValue("webPayToken"), await this._obtainTokenByRefreshOrTrackId(), this.checkoutContext = await Oe(
|
|
3984
3985
|
this.apiUrl,
|
|
3985
3986
|
this._getApiConfig()
|
|
3986
3987
|
);
|
|
3987
3988
|
else
|
|
3988
|
-
throw
|
|
3989
|
+
throw t;
|
|
3989
3990
|
}
|
|
3990
3991
|
}
|
|
3991
3992
|
// ─── Рендер ───────────────────────────────────────────────────────────────────
|
|
@@ -3997,7 +3998,7 @@ class ie {
|
|
|
3997
3998
|
}
|
|
3998
3999
|
// ─── Публичный API ────────────────────────────────────────────────────────────
|
|
3999
4000
|
async init() {
|
|
4000
|
-
var
|
|
4001
|
+
var t, o;
|
|
4001
4002
|
try {
|
|
4002
4003
|
if (this._prerender(), this._attachLifecycleListeners(), !this.config.clientId)
|
|
4003
4004
|
return this.config.onError({ attributes: { message: this.t("errorMissingTrackClient") } }), !1;
|
|
@@ -4011,7 +4012,7 @@ class ie {
|
|
|
4011
4012
|
return this.config.onError({ attributes: { message: u.message } }), !1;
|
|
4012
4013
|
}
|
|
4013
4014
|
const i = Ve(
|
|
4014
|
-
(o = (
|
|
4015
|
+
(o = (t = this.checkoutContext) == null ? void 0 : t.data) == null ? void 0 : o.socket_connections,
|
|
4015
4016
|
(s) => et(this, s)
|
|
4016
4017
|
);
|
|
4017
4018
|
return i && (this.centrifuge = i.centrifuge), this.selectedPaymentMethod = Le(
|
|
@@ -4026,15 +4027,15 @@ class ie {
|
|
|
4026
4027
|
this.config.onCancel();
|
|
4027
4028
|
}
|
|
4028
4029
|
destroy() {
|
|
4029
|
-
const
|
|
4030
|
-
|
|
4030
|
+
const t = document.getElementById("choco-one-click-widget");
|
|
4031
|
+
t && (t.style.display = "none"), this._clearNewCardActionTimeout(), $(this), this._pendingSuccessPayload = null, this._detachLifecycleListeners(), this.isAddCardViewOpen && ae(this), this.centrifuge && (this.centrifuge.disconnect(), this.centrifuge = null), document.removeEventListener("keydown", this._boundKeyDown), this.container && (this.container.classList.remove("choco-one-click-widget--visible"), setTimeout(() => {
|
|
4031
4032
|
var o;
|
|
4032
4033
|
(o = this.container) == null || o.remove(), this.container = null;
|
|
4033
4034
|
}, 300)), this.isOpen = !1, this.isPaymentSheetOpen = !1, this.isAddCardViewOpen = !1, this.selectedPaymentMethod = null;
|
|
4034
4035
|
}
|
|
4035
4036
|
getAvailablePaymentMethods() {
|
|
4036
|
-
var
|
|
4037
|
-
return (
|
|
4037
|
+
var t;
|
|
4038
|
+
return (t = this.checkoutContext) != null && t.data ? Rt(
|
|
4038
4039
|
this.checkoutContext.data,
|
|
4039
4040
|
(o) => this.t(o),
|
|
4040
4041
|
this._getKaspiOptions()
|
|
@@ -4046,8 +4047,8 @@ class ie {
|
|
|
4046
4047
|
async pay() {
|
|
4047
4048
|
try {
|
|
4048
4049
|
await this.createOrder();
|
|
4049
|
-
} catch (
|
|
4050
|
-
console.error(`${this.t("errorPaymentProcess")}:`,
|
|
4050
|
+
} catch (t) {
|
|
4051
|
+
console.error(`${this.t("errorPaymentProcess")}:`, t);
|
|
4051
4052
|
}
|
|
4052
4053
|
}
|
|
4053
4054
|
async handlePayment() {
|
|
@@ -4061,8 +4062,8 @@ class ie {
|
|
|
4061
4062
|
return;
|
|
4062
4063
|
}
|
|
4063
4064
|
await this.pay();
|
|
4064
|
-
} catch (
|
|
4065
|
-
console.error(`${this.t("errorPaymentProcess")}:`,
|
|
4065
|
+
} catch (t) {
|
|
4066
|
+
console.error(`${this.t("errorPaymentProcess")}:`, t);
|
|
4066
4067
|
}
|
|
4067
4068
|
}
|
|
4068
4069
|
}
|
|
@@ -4072,20 +4073,20 @@ class ie {
|
|
|
4072
4073
|
closePaymentSheet() {
|
|
4073
4074
|
V(this);
|
|
4074
4075
|
}
|
|
4075
|
-
async updateAmount(
|
|
4076
|
-
if (typeof
|
|
4076
|
+
async updateAmount(t) {
|
|
4077
|
+
if (typeof t != "number" || !Number.isFinite(t) || t < 0)
|
|
4077
4078
|
throw new Error("amount must be a non-negative number");
|
|
4078
|
-
this.config.amount =
|
|
4079
|
+
this.config.amount = t, pe(this);
|
|
4079
4080
|
}
|
|
4080
|
-
async updateAvailableBonus(
|
|
4081
|
-
if (typeof
|
|
4081
|
+
async updateAvailableBonus(t) {
|
|
4082
|
+
if (typeof t != "number" || !Number.isFinite(t) || t < 0)
|
|
4082
4083
|
throw new Error("availableBonus must be a non-negative number");
|
|
4083
|
-
this.config.bonuses && (this.config.bonuses.availableBonus =
|
|
4084
|
+
this.config.bonuses && (this.config.bonuses.availableBonus = t), pe(this);
|
|
4084
4085
|
}
|
|
4085
|
-
async updateLocale(
|
|
4086
|
-
if (typeof
|
|
4087
|
-
throw new Error(`Unsupported locale: ${
|
|
4088
|
-
if (this.config.locale =
|
|
4086
|
+
async updateLocale(t) {
|
|
4087
|
+
if (typeof t != "string" || !this.translations[t])
|
|
4088
|
+
throw new Error(`Unsupported locale: ${t}`);
|
|
4089
|
+
if (this.config.locale = t, !this.container) return;
|
|
4089
4090
|
const o = this.isPaymentSheetOpen, i = this.isAddCardViewOpen;
|
|
4090
4091
|
if (this._render(), ee(this), o) {
|
|
4091
4092
|
const s = this.container.querySelector('[data-sheet="payment"]');
|
|
@@ -4093,24 +4094,24 @@ class ie {
|
|
|
4093
4094
|
}
|
|
4094
4095
|
i && $e(this);
|
|
4095
4096
|
}
|
|
4096
|
-
async setLoading(
|
|
4097
|
-
this.loading = !!
|
|
4097
|
+
async setLoading(t) {
|
|
4098
|
+
this.loading = !!t, ee(this);
|
|
4098
4099
|
}
|
|
4099
|
-
async setDisabled(
|
|
4100
|
-
this.disabled = !!
|
|
4100
|
+
async setDisabled(t) {
|
|
4101
|
+
this.disabled = !!t, ee(this);
|
|
4101
4102
|
}
|
|
4102
|
-
async setPreorderId(
|
|
4103
|
-
this.config.preorderId =
|
|
4103
|
+
async setPreorderId(t) {
|
|
4104
|
+
this.config.preorderId = t;
|
|
4104
4105
|
}
|
|
4105
|
-
async setMerchantOrderId(
|
|
4106
|
-
this.config.merchantOrderId =
|
|
4106
|
+
async setMerchantOrderId(t) {
|
|
4107
|
+
this.config.merchantOrderId = t;
|
|
4107
4108
|
}
|
|
4108
4109
|
async logout() {
|
|
4109
4110
|
await ie.logout(), this.accessToken = null;
|
|
4110
4111
|
}
|
|
4111
|
-
async updateTrackId(
|
|
4112
|
+
async updateTrackId(t) {
|
|
4112
4113
|
var o, i;
|
|
4113
|
-
if (this.config.trackId =
|
|
4114
|
+
if (this.config.trackId = t, !this.config.clientId)
|
|
4114
4115
|
return this.config.onError({ attributes: { message: this.t("errorMissingTrackClient") } }), !1;
|
|
4115
4116
|
try {
|
|
4116
4117
|
this._prerender(), await this._obtainTokenByRefreshOrTrackId();
|
|
@@ -4133,27 +4134,27 @@ class ie {
|
|
|
4133
4134
|
return console.error(`${this.t("errorWidgetInit")}:`, s), this.config.onError({ attributes: { message: s.message } }), !1;
|
|
4134
4135
|
}
|
|
4135
4136
|
}
|
|
4136
|
-
async onConfirmPay(
|
|
4137
|
-
if (typeof
|
|
4138
|
-
this.config.onConfirmPay =
|
|
4137
|
+
async onConfirmPay(t) {
|
|
4138
|
+
if (typeof t != "function") throw new Error("onConfirmPay callback must be a function");
|
|
4139
|
+
this.config.onConfirmPay = t;
|
|
4139
4140
|
}
|
|
4140
|
-
async onPaymentMethodSelected(
|
|
4141
|
-
if (typeof
|
|
4141
|
+
async onPaymentMethodSelected(t) {
|
|
4142
|
+
if (typeof t != "function")
|
|
4142
4143
|
throw new Error("onPaymentMethodSelected callback must be a function");
|
|
4143
|
-
this.config.onPaymentMethodSelected =
|
|
4144
|
+
this.config.onPaymentMethodSelected = t, this._emitPaymentMethodSelected();
|
|
4144
4145
|
}
|
|
4145
|
-
async onKaspiLink(
|
|
4146
|
-
if (typeof
|
|
4147
|
-
this.config.onKaspiLink =
|
|
4146
|
+
async onKaspiLink(t) {
|
|
4147
|
+
if (typeof t != "function") throw new Error("onKaspiLink callback must be a function");
|
|
4148
|
+
this.config.onKaspiLink = t;
|
|
4148
4149
|
}
|
|
4149
|
-
async onUserEvent(
|
|
4150
|
-
if (typeof
|
|
4151
|
-
this.config.onUserEvent =
|
|
4150
|
+
async onUserEvent(t) {
|
|
4151
|
+
if (typeof t != "function") throw new Error("onUserEvent callback must be a function");
|
|
4152
|
+
this.config.onUserEvent = t;
|
|
4152
4153
|
}
|
|
4153
|
-
async onAppliedBonus(
|
|
4154
|
-
if (typeof
|
|
4154
|
+
async onAppliedBonus(t) {
|
|
4155
|
+
if (typeof t != "function")
|
|
4155
4156
|
throw new Error("onAppliedBonus callback must be a function");
|
|
4156
|
-
this.config.onAppliedBonus =
|
|
4157
|
+
this.config.onAppliedBonus = t;
|
|
4157
4158
|
}
|
|
4158
4159
|
}
|
|
4159
4160
|
typeof window < "u" && (window.ChocoOneClickWidget = ie);
|