choco-one-click-payment 1.1.27 → 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 +1180 -1143
- package/dist/index.js +33 -33
- package/index.d.ts +29 -0
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode('.choco-one-click-widget{position:fixed;top:0;left:0;right:0;bottom:0;z-index:999999;font-family:Sirius,sans-serif;--choco-widget-accent-color: #2F2F2F;pointer-events:none}.choco-one-click-widget--embedded{position:static;top:auto;left:auto;right:auto;bottom:auto;z-index:auto;pointer-events:auto;min-height:1px}.choco-one-click-widget--embedded .choco-widget-bottom-bar{position:static;box-shadow:none;border-radius:24px}.choco-one-click-widget--embedded .choco-widget-payment-sheet{position:fixed}.choco-one-click-widget *{box-sizing:border-box;font-family:Sirius,sans-serif}.choco-one-click-widget .choco-widget-bottom-bar{opacity:0;transform:translateY(16px)}.choco-one-click-widget .choco-widget-balance-section,.choco-one-click-widget .choco-widget-payment-info{opacity:0;transform:translateY(8px)}.choco-one-click-widget--visible .choco-widget-bottom-bar,.choco-one-click-widget--visible .choco-widget-balance-section,.choco-one-click-widget--visible .choco-widget-payment-info{opacity:1;transform:translateY(0)}.choco-widget-bottom-bar{position:absolute;bottom:0;left:0;right:0;background:#fff;border-radius:24px 24px 0 0;padding:16px;box-shadow:0 -4px 20px #0000001a;transition:transform .24s cubic-bezier(.4,0,.2,1),opacity .2s ease;pointer-events:auto}.choco-widget-payment-info{display:flex;flex-direction:column;gap:12px;align-items:stretch;transition:transform .22s ease,opacity .2s ease}.choco-widget-payment-info-main{display:flex;gap:12px;align-items:center}.choco-widget-payment-method{gap:12px;background:#f1f2f7;border-radius:16px;padding:5px 8px;cursor:pointer;transition:background .2s ease;border:none;font-family:inherit;text-align:left;width:100%;position:relative;height:46px}.choco-widget-payment-method:disabled{cursor:not-allowed;pointer-events:none;opacity:.5}.choco-widget-payment-method.google_pay,.choco-widget-payment-method.apple_pay{max-width:140px}.choco-widget-method-icon-placeholder{font-size:24px}.choco-widget-method-details{flex:1}.choco-widget-method-label{font-size:14px;color:#000}.choco-widget-method-value{font-size:14px;font-weight:600;color:#000;display:flex;align-items:center;gap:4px}.choco-widget-method-icon-wrapper svg{display:block;width:100%;max-width:29px;max-height:18px;margin-top:2px}.choco-widget-method-icon-wrapper:empty{display:none}.choco-widget-method-icon-wrapper.google_pay svg{height:17px;max-width:35px;border:1px solid #3C4043;padding:3px 4px 2px;border-radius:8px}.choco-widget-method-name{font-size:14px;font-weight:700}.choco-widget-method-name.google_pay,.choco-widget-method-name.apple_pay{display:none}.choco-widget-method-chevron{position:absolute;right:5px;top:0;bottom:0;margin:auto 0;width:24px;height:24px}.choco-widget-pay-button{background:var(--choco-widget-accent-color);color:#fff;border:none;border-radius:16px;height:46px;padding:0 16px;font-size:16px;font-weight:600;cursor:pointer;transition:all .2s ease;white-space:nowrap;width:100%;overflow:hidden}.choco-widget-pay-button--loading{cursor:not-allowed;pointer-events:none;position:relative}.choco-widget-pay-button--loading:before{content:"";display:block;width:16px;height:16px;border:2px solid #ffffff;border-top:2px solid transparent;border-radius:50%;animation:choco-spin 1s linear infinite;position:absolute;left:0;right:0;margin:0 auto;z-index:2}.choco-widget-pay-button--loading:after{content:"";display:block;width:100%;height:100%;background:#2f2f2f;position:absolute;left:0;top:0}.choco-widget-pay-button:disabled{opacity:.5;pointer-events:none}.choco-widget-pay-button--hidden{display:none}.choco-widget-google-pay-amount{min-width:124px;height:46px;display:flex;flex-direction:column;justify-content:center;text-align:right;width:100%}.choco-widget-google-pay-amount--hidden{display:none}.choco-widget-google-pay-amount-label{font-size:20px;font-weight:700;line-height:24px;color:#1d1d1d}.choco-widget-google-pay-amount-value{font-size:14px;line-height:18px;color:#1d1d1d;white-space:nowrap;opacity:.5}.choco-widget-google-pay-amount-value--hidden{display:none}.choco-widget-google-pay-amount-value-number{text-decoration:line-through}.choco-widget-google-pay-row--hidden{display:none}.choco-widget-wallet-blocked{pointer-events:none;opacity:.6}.choco-widget-google-pay-button-slot{width:100%}.choco-widget-google-pay-button-slot>button{width:100%!important;height:52px;min-height:52px;border-radius:12px!important;font-size:16px!important}.choco-widget-apple-pay-row--hidden{display:none}.choco-widget-apple-pay-button-slot{width:100%}.choco-widget-apple-pay-button-wrapper{position:relative;width:100%;height:52px}.choco-widget-apple-pay-button{width:100%;height:52px;min-height:52px;border:0;border-radius:12px;cursor:pointer;background:#000;color:#fff;font-size:16px;display:flex;align-items:center;justify-content:center;gap:8px;padding:0 16px}.choco-widget-apple-pay-button--native{position:absolute;top:0;right:0;bottom:0;left:0;width:100%;height:52px;opacity:.01;z-index:2}.choco-widget-apple-pay-button-overlay{position:absolute;top:0;right:0;bottom:0;left:0;display:flex;align-items:center;justify-content:center;gap:8px;background:#000;border-radius:12px;pointer-events:none;z-index:1}.choco-widget-apple-pay-button-text{font-size:16px;line-height:20px;font-weight:600;color:#fff}.choco-widget-apple-pay-button-icon{display:inline-flex;align-items:center;justify-content:center}.choco-widget-payment-sheet{position:absolute;bottom:0;left:0;right:0;top:0;background:#00000080;display:flex;align-items:flex-end;opacity:0;pointer-events:none;transition:opacity .3s ease}.choco-widget-payment-sheet--open{opacity:1;pointer-events:auto}.choco-widget-payment-sheet--open .choco-widget-sheet-content{transform:translateY(0)}.choco-widget-sheet-content{background:#fff;border-radius:24px 24px 0 0;width:100%;max-height:70vh;overflow-y:auto;transform:translateY(100%);transition:transform .3s cubic-bezier(.4,0,.2,1);padding:8px 16px 16px;position:relative;will-change:transform}.choco-widget-sheet-content--dragging{transition:none}.choco-widget-sheet-grabber{flex-shrink:0;display:flex;align-items:center;justify-content:center;cursor:grab;touch-action:none;margin-bottom:8px;-webkit-user-select:none;user-select:none}.choco-widget-sheet-grabber:active{cursor:grabbing}.choco-widget-sheet-grabber:before{content:"";width:72px;height:6px;background:#e5e5e7;border-radius:42px}.choco-widget-sheet-content{-webkit-overflow-scrolling:touch;overscroll-behavior:contain}.choco-widget-sheet-header{display:flex;align-items:center;justify-content:space-between;margin-bottom:8px;position:relative}.choco-widget-sheet-title{font-size:20px;font-weight:700;color:#000;margin:0;flex:1;text-align:center}.choco-widget-payment-sheet--edit .choco-widget-sheet-title{padding-left:30px}.choco-widget-payment-sheet--no-cards .choco-widget-sheet-title{padding-right:30px}.choco-widget-payment-sheet--delete-confirm .choco-widget-sheet-title{padding:0}.choco-widget-sheet-button{background:none;border:none;width:32px;height:32px;border-radius:50%;display:flex;align-items:center;justify-content:center;cursor:pointer;padding:0}.choco-widget-sheet-button svg{color:#000}.choco-widget-sheet-delete-confirm{display:none;padding-top:16px}.choco-widget-payment-sheet--delete-confirm .choco-widget-payment-methods,.choco-widget-payment-sheet--delete-confirm .choco-widget-cashback-section{display:none!important}.choco-widget-payment-sheet--delete-confirm .choco-widget-sheet-delete-confirm{display:block}.choco-widget-sheet-delete-confirm-text{margin:0 0 24px;font-size:16px;line-height:1.4;color:#242424;text-align:center}.choco-widget-sheet-delete-confirm-actions{display:flex;gap:12px}.choco-widget-delete-confirm-btn{flex:1;padding:14px 20px;font-size:16px;font-weight:600;font-family:inherit;border-radius:16px;border:none;cursor:pointer;transition:background .2s ease,opacity .2s ease}.choco-widget-delete-confirm-btn--cancel{background:#f1f2f7;color:#242424}.choco-widget-delete-confirm-btn--delete{background:var(--choco-widget-accent-color);color:#fff}.choco-widget-delete-confirm-btn--loading{cursor:not-allowed;pointer-events:none;position:relative}.choco-widget-sheet-delete-confirm-actions.choco-widget-sheet-delete-confirm-actions--loading .choco-widget-delete-confirm-btn{pointer-events:none;cursor:not-allowed;opacity:.7}.choco-widget-delete-confirm-btn--delete.choco-widget-delete-confirm-btn--loading:before{content:"";display:block;width:16px;height:16px;border:2px solid #ffffff;border-top:2px solid transparent;border-radius:50%;animation:choco-spin 1s linear infinite;position:absolute;left:0;right:0;margin:0 auto;z-index:2}.choco-widget-delete-confirm-btn--delete.choco-widget-delete-confirm-btn--loading:after{content:"";display:block;width:100%;height:100%;background:#cc3434;position:absolute;left:0;top:0;border-radius:16px}.choco-widget-add-card-sheet{align-items:stretch}.choco-widget-add-card-sheet .choco-widget-add-card-sheet-content{max-height:none;height:100%;display:flex;flex-direction:column;transform:none;border-radius:0;padding:0}.choco-widget-add-card-sheet--open .choco-widget-add-card-sheet-content{transform:none}.choco-widget-add-card-sheet .choco-widget-sheet-header{flex-shrink:0;margin-bottom:0;padding:12px 0;border-bottom:1px solid #eee}.choco-widget-add-card-iframe-wrapper{flex:1;min-height:0;background:#fff}.choco-widget-add-card-iframe{width:100%;height:100%;border:none;display:block}.choco-widget-balance-section{margin-bottom:12px;padding:12px 8px;background:#f1f2f7;border-radius:12px;transition:transform .22s ease,opacity .2s ease}.choco-widget-balance-section.disabled{opacity:.5;pointer-events:none}.choco-widget-balance-toggle{display:flex;align-items:center;justify-content:space-between;margin-bottom:8px;padding:4px 0}.choco-widget-balance-toggle:last-child{margin-bottom:0}.choco-widget-balance-info{display:flex;align-items:center;gap:12px}.choco-widget-balance-text{display:flex;flex-direction:column}.choco-widget-balance-label-wrapper{display:flex;align-items:center;gap:8px}.choco-widget-balance-label{font-size:16px;font-weight:500}.choco-widget-balance-sublabel{font-size:12px;color:#767485;margin-top:2px}.choco-widget-balance-icon{width:22px;height:22px}.choco-widget-balance-amount{font-size:16px;font-weight:500;color:#000}.choco-widget-toggle{position:relative;display:inline-block;width:42px;height:26px}.choco-widget-toggle input{opacity:0;width:0;height:0}.choco-widget-toggle-slider{position:absolute;cursor:pointer;top:0;left:0;right:0;bottom:0;background-color:#d4d3df;transition:.3s;border-radius:28px}.choco-widget-toggle-slider:before{position:absolute;content:"";height:22px;width:22px;left:2px;bottom:0;top:0;margin:auto;background-color:#fff;transition:.3s;border-radius:50%}.choco-widget-toggle input:checked+.choco-widget-toggle-slider{background-color:var(--choco-widget-accent-color)}.choco-widget-toggle input:checked+.choco-widget-toggle-slider:before{transform:translate(16px)}.choco-widget-cashback-section{margin-top:20px;padding-top:20px;border-top:1px solid #f0f0f0}.choco-widget-cashback-info{display:flex;align-items:center;gap:8px;padding:12px 16px;background:#fff5ee;border-radius:12px;font-size:14px;color:#ff6b00}.choco-widget-cashback-icon{font-size:20px}.choco-widget-cashback-text strong{font-weight:700}.choco-widget-payment-methods{display:flex;flex-direction:column;gap:8px}.choco-widget-method-item{display:flex;align-items:center;gap:12px;padding:10px 0;cursor:pointer;transition:all .2s ease;border:2px solid transparent;width:100%;border:0;background:none;text-align:left;font-family:inherit;font-size:inherit}.choco-widget-method-item-icon-wrapper{width:37px}.choco-widget-method-item-icon-wrapper svg{display:block;width:100%;max-width:29px;height:29px;margin:0 auto}.choco-widget-method-item-icon-wrapper.google_pay{outline:1px solid #3C4043;padding:3px 5px 2px;border-radius:15px}.choco-widget-method-item-icon-wrapper.google_pay svg{height:15px;max-width:29px}.choco-widget-method-item-label{flex:1;font-size:16px;color:#000}.choco-widget-method-item-check,.choco-widget-method-item-trash-btn{flex-shrink:0;display:flex;align-items:center;justify-content:center;padding:6px;margin:-6px 0 -6px 6px;background:none;border:none;cursor:pointer;border-radius:8px;-webkit-tap-highlight-color:transparent}.choco-widget-method-item-check{height:30px;width:30px}.choco-widget-method-item-trash-btn:hover{background:#cc343414}.choco-widget-method-item-trash{flex-shrink:0;width:20px;height:20px}.choco-widget-bottom-bar-prerender{position:absolute;bottom:0;left:0;right:0;background:#fff;border-radius:24px 24px 0 0;box-shadow:0 -4px 20px #0000001a;transition:transform .3s cubic-bezier(.4,0,.2,1);height:78px}.choco-widget-payment-loading{width:30px;height:30px;animation:choco-spin 1s linear infinite;border:3px solid var(--choco-widget-accent-color);border-top:3px solid transparent;border-radius:50%;position:absolute;top:0;bottom:0;left:0;right:0;margin:auto}@keyframes choco-spin{to{transform:rotate(360deg)}}@keyframes choco-fade-in{0%{opacity:0;transform:translate(-50%,-50%) scale(.9)}to{opacity:1;transform:translate(-50%,-50%) scale(1)}}@media(max-width:768px){.choco-widget-bottom-bar{padding:16px 16px 20px}.choco-widget-sheet-content{max-height:80vh}.choco-widget-sheet-title{font-size:18px}.choco-widget-method-item-label{font-size:17px}}@media(max-width:768px)and (min-height:812px){.choco-widget-bottom-bar,.choco-widget-sheet-content{padding-bottom:calc(20px + env(safe-area-inset-bottom,20px))}}@supports (padding: env(safe-area-inset-bottom)){.choco-widget-bottom-bar{padding-bottom:calc(16px + env(safe-area-inset-bottom))}.choco-widget-sheet-content{padding-bottom:calc(20px + env(safe-area-inset-bottom))}}')),document.head.appendChild(e)}}catch(o){console.error("vite-plugin-css-injected-by-js",o)}})();
|
|
2
|
-
const
|
|
2
|
+
const mt = {
|
|
3
3
|
ru: {
|
|
4
4
|
paymentMethod: "Способ оплаты",
|
|
5
5
|
selectMethod: "Выберите метод",
|
|
@@ -144,40 +144,40 @@ const yt = {
|
|
|
144
144
|
errorWidgetInit: "ვიჯეტის ინიციალიზაციის შეცდომა",
|
|
145
145
|
errorPaymentProcess: "გადახდის შეცდომა"
|
|
146
146
|
}
|
|
147
|
-
},
|
|
147
|
+
}, bt = {
|
|
148
148
|
KZT: "₸",
|
|
149
149
|
GEL: "₾"
|
|
150
150
|
};
|
|
151
|
-
function
|
|
151
|
+
function Et(e) {
|
|
152
152
|
return e === "production" ? "https://api-proxy.choco.kz" : "https://api-proxy.chocodev.kz";
|
|
153
153
|
}
|
|
154
154
|
let de;
|
|
155
|
-
const
|
|
156
|
-
function
|
|
155
|
+
const vt = new Uint8Array(16);
|
|
156
|
+
function Bt() {
|
|
157
157
|
if (!de && (de = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !de))
|
|
158
158
|
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
159
|
-
return de(
|
|
159
|
+
return de(vt);
|
|
160
160
|
}
|
|
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
|
|
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
|
-
const
|
|
168
|
-
randomUUID:
|
|
167
|
+
const Qt = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), ze = {
|
|
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 || {};
|
|
174
|
-
const
|
|
175
|
-
return
|
|
174
|
+
const i = e.random || (e.rng || Bt)();
|
|
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
|
|
180
|
-
return `${
|
|
178
|
+
function G(e, t = "ru", o = "KZT") {
|
|
179
|
+
const i = Number(e), s = t === "ru" ? "ru-RU" : "en-US";
|
|
180
|
+
return `${i.toLocaleString(s)} ${bt[o]}`;
|
|
181
181
|
}
|
|
182
182
|
function nt() {
|
|
183
183
|
let e = localStorage.getItem(Ke);
|
|
@@ -185,19 +185,19 @@ function nt() {
|
|
|
185
185
|
}
|
|
186
186
|
function Ce() {
|
|
187
187
|
if (typeof window > "u") return !1;
|
|
188
|
-
const e = window.safari !== void 0,
|
|
189
|
-
return e ||
|
|
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
|
+
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(),
|
|
200
|
-
return /iphone|ipad|ipod/.test(
|
|
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
|
+
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() {
|
|
203
203
|
if (typeof navigator > "u") return !1;
|
|
@@ -206,18 +206,18 @@ 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
|
-
function
|
|
212
|
+
function St(e) {
|
|
213
213
|
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
|
|
214
214
|
}
|
|
215
|
-
var fe = { exports: {} },
|
|
216
|
-
function
|
|
217
|
-
return
|
|
218
|
-
(function(
|
|
219
|
-
e.exports =
|
|
220
|
-
})(
|
|
215
|
+
var fe = { exports: {} }, Pt = fe.exports, We;
|
|
216
|
+
function kt() {
|
|
217
|
+
return We || (We = 1, (function(e, t) {
|
|
218
|
+
(function(i, s) {
|
|
219
|
+
e.exports = s();
|
|
220
|
+
})(Pt, function() {
|
|
221
221
|
return (
|
|
222
222
|
/******/
|
|
223
223
|
(function() {
|
|
@@ -225,11 +225,11 @@ function Pt() {
|
|
|
225
225
|
/***/
|
|
226
226
|
382: (
|
|
227
227
|
/***/
|
|
228
|
-
(function(
|
|
228
|
+
(function(a, d, g) {
|
|
229
229
|
Object.defineProperty(d, "__esModule", {
|
|
230
230
|
value: !0
|
|
231
231
|
}), d.Centrifuge = void 0;
|
|
232
|
-
var C = Q(g(187)), S = Q(g(471)), T = g(147),
|
|
232
|
+
var C = Q(g(187)), S = Q(g(471)), T = g(147), E = g(853);
|
|
233
233
|
function Q(f) {
|
|
234
234
|
return f && f.__esModule ? f : { default: f };
|
|
235
235
|
}
|
|
@@ -260,20 +260,20 @@ function Pt() {
|
|
|
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 Pt() {
|
|
|
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,55 +341,55 @@ function Pt() {
|
|
|
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(
|
|
384
|
-
var
|
|
385
|
-
this._debug("sending AJAX request to",
|
|
383
|
+
value: function(n, r, c, l, y) {
|
|
384
|
+
var v = this, I = "";
|
|
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",
|
|
391
|
-
for (var X in
|
|
392
|
-
|
|
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
|
+
for (var X in c)
|
|
392
|
+
c.hasOwnProperty(X) && B.setRequestHeader(X, c[X]);
|
|
393
393
|
return B.onreadystatechange = function() {
|
|
394
394
|
if (B.readyState === 4)
|
|
395
395
|
if (B.status === 200) {
|
|
@@ -408,7 +408,7 @@ function Pt() {
|
|
|
408
408
|
status: 200
|
|
409
409
|
});
|
|
410
410
|
} else
|
|
411
|
-
|
|
411
|
+
v._log("wrong status code in AJAX response", B.status), y({
|
|
412
412
|
status: B.status,
|
|
413
413
|
data: null
|
|
414
414
|
});
|
|
@@ -419,12 +419,12 @@ function Pt() {
|
|
|
419
419
|
}, {
|
|
420
420
|
key: "_log",
|
|
421
421
|
value: function() {
|
|
422
|
-
(0,
|
|
422
|
+
(0, E.log)("info", arguments);
|
|
423
423
|
}
|
|
424
424
|
}, {
|
|
425
425
|
key: "_debug",
|
|
426
426
|
value: function() {
|
|
427
|
-
this._config.debug === !0 && (0,
|
|
427
|
+
this._config.debug === !0 && (0, E.log)("debug", arguments);
|
|
428
428
|
}
|
|
429
429
|
}, {
|
|
430
430
|
key: "_websocketSupported",
|
|
@@ -433,26 +433,26 @@ function Pt() {
|
|
|
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,
|
|
453
|
+
if ((0, E.extend)(this._config, n || {}), this._debug("centrifuge config", this._config), !this._url)
|
|
454
454
|
throw new Error("url required");
|
|
455
|
-
var r = (0,
|
|
455
|
+
var r = (0, E.startsWith)(this._url, "ws") && this._url.indexOf("format=protobuf") > -1;
|
|
456
456
|
if (r || this._config.protocol === "protobuf")
|
|
457
457
|
this._setFormat("protobuf"), this._protocol = "protobuf";
|
|
458
458
|
else {
|
|
@@ -460,7 +460,7 @@ function Pt() {
|
|
|
460
460
|
throw new Error("unsupported protocol " + this._config.protocol);
|
|
461
461
|
this._setFormat("json");
|
|
462
462
|
}
|
|
463
|
-
if ((0,
|
|
463
|
+
if ((0, E.startsWith)(this._url, "http"))
|
|
464
464
|
if (this._debug("client will try to connect to SockJS endpoint"), this._config.sockjs !== null)
|
|
465
465
|
this._debug("SockJS explicitly provided in options"), this._sockjs = this._config.sockjs;
|
|
466
466
|
else {
|
|
@@ -474,8 +474,8 @@ function Pt() {
|
|
|
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,30 +505,30 @@ function Pt() {
|
|
|
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)) {
|
|
529
|
-
var
|
|
530
|
-
clearTimeout(
|
|
531
|
-
var l =
|
|
529
|
+
var c = this._callbacks[r];
|
|
530
|
+
clearTimeout(c.timeout);
|
|
531
|
+
var l = c.errback;
|
|
532
532
|
if (!l)
|
|
533
533
|
continue;
|
|
534
534
|
l({
|
|
@@ -538,8 +538,8 @@ function Pt() {
|
|
|
538
538
|
this._callbacks = {};
|
|
539
539
|
for (var y in this._subs)
|
|
540
540
|
if (this._subs.hasOwnProperty(y)) {
|
|
541
|
-
var
|
|
542
|
-
|
|
541
|
+
var v = this._subs[y];
|
|
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,15 +553,15 @@ function Pt() {
|
|
|
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
|
|
561
|
-
var
|
|
562
|
-
if (
|
|
563
|
-
var l = this._callbacks[
|
|
564
|
-
clearTimeout(this._callbacks[
|
|
560
|
+
for (var r in n) {
|
|
561
|
+
var c = r.id;
|
|
562
|
+
if (c in this._callbacks) {
|
|
563
|
+
var l = this._callbacks[c];
|
|
564
|
+
clearTimeout(this._callbacks[c].timeout), delete this._callbacks[c];
|
|
565
565
|
var y = l.errback;
|
|
566
566
|
y({
|
|
567
567
|
error: this._createErrorObject(N, 0)
|
|
@@ -570,7 +570,7 @@ function Pt() {
|
|
|
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 Pt() {
|
|
|
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
|
|
@@ -590,79 +590,79 @@ function Pt() {
|
|
|
590
590
|
if (!this._websocketSupported())
|
|
591
591
|
throw this._debug("No Websocket support and no SockJS configured, can not connect"), new Error("No Websocket support and no SockJS configured, can not connect");
|
|
592
592
|
this._config.websocket !== null ? this._websocket = this._config.websocket : this._websocket = WebSocket;
|
|
593
|
-
var
|
|
594
|
-
|
|
593
|
+
var c = this._getSubProtocol();
|
|
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
|
-
(
|
|
604
|
-
var y = {},
|
|
605
|
-
for (var I in
|
|
606
|
-
if (
|
|
607
|
-
|
|
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
|
+
var y = {}, v = !1;
|
|
605
|
+
for (var I in n._serverSubs)
|
|
606
|
+
if (n._serverSubs.hasOwnProperty(I) && n._serverSubs[I].recoverable) {
|
|
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
|
-
|
|
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
|
-
|
|
623
|
-
var y = N,
|
|
622
|
+
n._transportClosed = !0;
|
|
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
|
-
reconnect:
|
|
635
|
-
}),
|
|
636
|
-
|
|
637
|
-
var B =
|
|
638
|
-
|
|
639
|
-
|
|
634
|
+
reconnect: v
|
|
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(
|
|
659
|
-
var
|
|
658
|
+
value: function(n, r) {
|
|
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
|
-
params:
|
|
665
|
+
params: c
|
|
666
666
|
};
|
|
667
667
|
return this._methodCall(l, function(y) {
|
|
668
668
|
return y;
|
|
@@ -670,60 +670,60 @@ function Pt() {
|
|
|
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())
|
|
681
681
|
return Promise.reject(this._createErrorObject(N, 0));
|
|
682
|
-
var
|
|
683
|
-
return
|
|
682
|
+
var c = this._transportSend([r]);
|
|
683
|
+
return c ? Promise.resolve({}) : Promise.reject(this._createErrorObject(N, 0));
|
|
684
684
|
}
|
|
685
685
|
}, {
|
|
686
686
|
key: "_getHistoryParams",
|
|
687
|
-
value: function(
|
|
688
|
-
var
|
|
689
|
-
channel:
|
|
687
|
+
value: function(n, r) {
|
|
688
|
+
var c = {
|
|
689
|
+
channel: n
|
|
690
690
|
};
|
|
691
|
-
return r !== void 0 && (r.since && (
|
|
691
|
+
return r !== void 0 && (r.since && (c.since = {
|
|
692
692
|
offset: r.since.offset
|
|
693
|
-
}, r.since.epoch && (
|
|
693
|
+
}, r.since.epoch && (c.since.epoch = r.since.epoch)), r.limit !== void 0 && (c.limit = r.limit), r.reverse === !0 && (c.reverse = !0)), c;
|
|
694
694
|
}
|
|
695
695
|
}, {
|
|
696
696
|
key: "_methodCall",
|
|
697
|
-
value: function(
|
|
698
|
-
var
|
|
697
|
+
value: function(n, r) {
|
|
698
|
+
var c = this;
|
|
699
699
|
return this.isConnected() ? new Promise(function(l, y) {
|
|
700
|
-
|
|
701
|
-
l(r(
|
|
702
|
-
}, function(
|
|
703
|
-
y(
|
|
700
|
+
c._call(n).then(function(v) {
|
|
701
|
+
l(r(c._decoder.decodeCommandResult(n.method, v.result))), v.next && v.next();
|
|
702
|
+
}, function(v) {
|
|
703
|
+
y(v.error), v.next && v.next();
|
|
704
704
|
});
|
|
705
705
|
}) : Promise.reject(this._createErrorObject(N, 0));
|
|
706
706
|
}
|
|
707
707
|
}, {
|
|
708
708
|
key: "publish",
|
|
709
|
-
value: function(
|
|
710
|
-
var
|
|
709
|
+
value: function(n, r) {
|
|
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
|
};
|
|
717
|
-
return this._methodCall(
|
|
717
|
+
return this._methodCall(c, function() {
|
|
718
718
|
return {};
|
|
719
719
|
});
|
|
720
720
|
}
|
|
721
721
|
}, {
|
|
722
722
|
key: "history",
|
|
723
|
-
value: function(
|
|
724
|
-
var
|
|
723
|
+
value: function(n, r) {
|
|
724
|
+
var c = this._getHistoryParams(n, r), l = {
|
|
725
725
|
method: this._methodType.HISTORY,
|
|
726
|
-
params:
|
|
726
|
+
params: c
|
|
727
727
|
};
|
|
728
728
|
return this._methodCall(l, function(y) {
|
|
729
729
|
return {
|
|
@@ -735,78 +735,78 @@ function Pt() {
|
|
|
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
|
-
return this._methodCall(r, function(
|
|
745
|
+
return this._methodCall(r, function(c) {
|
|
746
746
|
return {
|
|
747
|
-
presence:
|
|
747
|
+
presence: c.presence
|
|
748
748
|
};
|
|
749
749
|
});
|
|
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
|
-
return this._methodCall(r, function(
|
|
760
|
+
return this._methodCall(r, function(c) {
|
|
761
761
|
return {
|
|
762
|
-
num_users:
|
|
763
|
-
num_clients:
|
|
762
|
+
num_users: c.num_users,
|
|
763
|
+
num_clients: c.num_clients
|
|
764
764
|
};
|
|
765
765
|
});
|
|
766
766
|
}
|
|
767
767
|
}, {
|
|
768
768
|
key: "_dataReceived",
|
|
769
|
-
value: function(
|
|
770
|
-
var r = this,
|
|
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) {
|
|
774
774
|
l = y;
|
|
775
|
-
}), r._dispatchSynchronized(
|
|
775
|
+
}), r._dispatchSynchronized(c, l);
|
|
776
776
|
}), this._restartPing();
|
|
777
777
|
}
|
|
778
778
|
}, {
|
|
779
779
|
key: "_dispatchSynchronized",
|
|
780
|
-
value: function(
|
|
781
|
-
var
|
|
782
|
-
|
|
783
|
-
return
|
|
780
|
+
value: function(n, r) {
|
|
781
|
+
var c = this, l = Promise.resolve(), y = function(B) {
|
|
782
|
+
n.hasOwnProperty(B) && (l = l.then(function() {
|
|
783
|
+
return c._dispatchReply(n[B]);
|
|
784
784
|
}));
|
|
785
785
|
};
|
|
786
|
-
for (var
|
|
787
|
-
y(
|
|
786
|
+
for (var v in n)
|
|
787
|
+
y(v);
|
|
788
788
|
l = l.then(function() {
|
|
789
789
|
r();
|
|
790
790
|
});
|
|
791
791
|
}
|
|
792
792
|
}, {
|
|
793
793
|
key: "_dispatchReply",
|
|
794
|
-
value: function(
|
|
795
|
-
var r,
|
|
794
|
+
value: function(n) {
|
|
795
|
+
var r, c = new Promise(function(y) {
|
|
796
796
|
r = y;
|
|
797
797
|
});
|
|
798
|
-
if (
|
|
799
|
-
return this._debug("dispatch: got undefined or null reply"), r(),
|
|
800
|
-
var l =
|
|
801
|
-
return l && l > 0 ? this._handleReply(
|
|
798
|
+
if (n == null)
|
|
799
|
+
return this._debug("dispatch: got undefined or null reply"), r(), c;
|
|
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
|
-
return new Promise(function(
|
|
808
|
-
var y = r._addMessage(
|
|
809
|
-
r._registerCall(y,
|
|
807
|
+
return new Promise(function(c, l) {
|
|
808
|
+
var y = r._addMessage(n);
|
|
809
|
+
r._registerCall(y, c, l);
|
|
810
810
|
});
|
|
811
811
|
}
|
|
812
812
|
}, {
|
|
@@ -820,23 +820,23 @@ function Pt() {
|
|
|
820
820
|
}
|
|
821
821
|
}, {
|
|
822
822
|
key: "_disconnect",
|
|
823
|
-
value: function(
|
|
824
|
-
var
|
|
825
|
-
if (
|
|
826
|
-
|
|
823
|
+
value: function(n, r) {
|
|
824
|
+
var c = r || !1;
|
|
825
|
+
if (c === !1 && (this._reconnect = !1), this._isDisconnected()) {
|
|
826
|
+
c || this._clearConnectedState(c);
|
|
827
827
|
return;
|
|
828
828
|
}
|
|
829
|
-
if (this._clearConnectedState(
|
|
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:
|
|
836
|
-
reconnect:
|
|
835
|
+
reason: n,
|
|
836
|
+
reconnect: c
|
|
837
837
|
});
|
|
838
838
|
}
|
|
839
|
-
|
|
839
|
+
c === !1 && (this._subs = {}, this._serverSubs = {}), this._transportClosed || this._transport.close();
|
|
840
840
|
}
|
|
841
841
|
}, {
|
|
842
842
|
key: "_refreshFailed",
|
|
@@ -846,43 +846,43 @@ function Pt() {
|
|
|
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
|
-
var r = this._clientID,
|
|
856
|
-
if (
|
|
855
|
+
var r = this._clientID, c = this._newXHRID(), l = function(B) {
|
|
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
|
}
|
|
@@ -891,27 +891,27 @@ function Pt() {
|
|
|
891
891
|
var y = {};
|
|
892
892
|
this._config.onRefresh(y, l);
|
|
893
893
|
} else {
|
|
894
|
-
var
|
|
895
|
-
this._xhrs[
|
|
894
|
+
var v = this._ajax(this._config.refreshEndpoint, this._config.refreshParams, this._config.refreshHeaders, this._config.refreshData, l);
|
|
895
|
+
this._xhrs[c] = v;
|
|
896
896
|
}
|
|
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",
|
|
903
|
-
var
|
|
902
|
+
this._debug("refresh error", n), this._refreshTimeout && (clearTimeout(this._refreshTimeout), this._refreshTimeout = null);
|
|
903
|
+
var c = this._config.refreshInterval + Math.round(Math.random() * 1e3);
|
|
904
904
|
this._refreshTimeout = setTimeout(function() {
|
|
905
905
|
return r._refresh();
|
|
906
|
-
},
|
|
906
|
+
}, c);
|
|
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,102 +920,102 @@ function Pt() {
|
|
|
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
|
-
var
|
|
930
|
-
if (l in r._xhrs && delete r._xhrs[l], !(R.error || R.status !== 200 || r._clientID !==
|
|
929
|
+
var c = this._clientID, l = this._newXHRID(), y = function(R) {
|
|
930
|
+
if (l in r._xhrs && delete r._xhrs[l], !(R.error || R.status !== 200 || r._clientID !== c)) {
|
|
931
931
|
var X = {};
|
|
932
932
|
if (R.data.channels)
|
|
933
933
|
for (var U in R.data.channels) {
|
|
934
934
|
var D = R.data.channels[U];
|
|
935
935
|
D.channel && (X[D.channel] = D.token);
|
|
936
936
|
}
|
|
937
|
-
var
|
|
938
|
-
if (
|
|
937
|
+
var re = X[n];
|
|
938
|
+
if (re) {
|
|
939
939
|
var Pe = {
|
|
940
940
|
method: r._methodType.SUB_REFRESH,
|
|
941
941
|
params: {
|
|
942
|
-
channel:
|
|
943
|
-
token:
|
|
942
|
+
channel: n,
|
|
943
|
+
token: re
|
|
944
944
|
}
|
|
945
|
-
}, le = r._getSub(
|
|
946
|
-
le !== null && r._call(Pe).then(function(
|
|
947
|
-
r._subRefreshResponse(
|
|
948
|
-
}, function(
|
|
949
|
-
r._subRefreshError(
|
|
945
|
+
}, le = r._getSub(n);
|
|
946
|
+
le !== null && r._call(Pe).then(function(W) {
|
|
947
|
+
r._subRefreshResponse(n, r._decoder.decodeCommandResult(r._methodType.SUB_REFRESH, W.result)), W.next && W.next();
|
|
948
|
+
}, function(W) {
|
|
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({
|
|
959
|
-
data:
|
|
959
|
+
data: v
|
|
960
960
|
}, y);
|
|
961
961
|
else {
|
|
962
|
-
var I = this._ajax(this._config.subscribeEndpoint, this._config.subscribeParams, this._config.subscribeHeaders,
|
|
962
|
+
var I = this._ajax(this._config.subscribeEndpoint, this._config.subscribeParams, this._config.subscribeHeaders, v, y);
|
|
963
963
|
this._xhrs[l] = I;
|
|
964
964
|
}
|
|
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(
|
|
974
|
-
var
|
|
975
|
-
this._debug("subscription refresh error",
|
|
976
|
-
var l = this._getSub(
|
|
973
|
+
value: function(n, r) {
|
|
974
|
+
var c = this;
|
|
975
|
+
this._debug("subscription refresh error", n, r), this._clearSubRefreshTimeout(n);
|
|
976
|
+
var l = this._getSub(n);
|
|
977
977
|
if (l !== null) {
|
|
978
|
-
var y = Math.round(Math.random() * 1e3),
|
|
979
|
-
return
|
|
978
|
+
var y = Math.round(Math.random() * 1e3), v = setTimeout(function() {
|
|
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(
|
|
987
|
-
var
|
|
988
|
-
this._debug("subscription refresh success",
|
|
989
|
-
var l = this._getSub(
|
|
986
|
+
value: function(n, r) {
|
|
987
|
+
var c = this;
|
|
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
|
|
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(
|
|
1000
|
-
var
|
|
1001
|
-
this._debug("subscribing on",
|
|
1002
|
-
var l =
|
|
1003
|
-
if (l in this._subs || (this._subs[l] =
|
|
1004
|
-
|
|
999
|
+
value: function(n, r) {
|
|
1000
|
+
var c = this;
|
|
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
|
|
1018
|
-
if (
|
|
1017
|
+
var v = n._needRecover();
|
|
1018
|
+
if (v === !0) {
|
|
1019
1019
|
y.params.recover = !0;
|
|
1020
1020
|
var I = this._getLastSeq(l), B = this._getLastGen(l);
|
|
1021
1021
|
if (I || B)
|
|
@@ -1028,88 +1028,88 @@ function Pt() {
|
|
|
1028
1028
|
X && (y.params.epoch = X);
|
|
1029
1029
|
}
|
|
1030
1030
|
this._call(y).then(function(U) {
|
|
1031
|
-
|
|
1031
|
+
c._subscribeResponse(l, v, c._decoder.decodeCommandResult(c._methodType.SUBSCRIBE, U.result)), U.next && U.next();
|
|
1032
1032
|
}, function(U) {
|
|
1033
|
-
|
|
1033
|
+
c._subscribeError(l, U.error), U.next && U.next();
|
|
1034
1034
|
});
|
|
1035
1035
|
}
|
|
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(
|
|
1071
|
-
var
|
|
1070
|
+
value: function(n, r) {
|
|
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 =
|
|
1074
|
-
return
|
|
1075
|
-
}, this._getTTLMilliseconds(
|
|
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
|
+
return c._refresh();
|
|
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
|
-
var
|
|
1079
|
-
|
|
1078
|
+
var v = this._subs[y];
|
|
1079
|
+
v._shouldResubscribe() && this._subscribe(v, l);
|
|
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
|
|
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
|
-
y = this._expandSubscribeContext(y,
|
|
1099
|
+
y = this._expandSubscribeContext(y, c), this.emit("subscribe", y);
|
|
1100
1100
|
}
|
|
1101
|
-
for (var
|
|
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) {
|
|
1107
1107
|
B.length > 1 && (!B[0].offset || B[0].offset > B[1].offset) && (B = B.reverse());
|
|
1108
1108
|
for (var R in B)
|
|
1109
|
-
B.hasOwnProperty(R) && this._handlePublication(
|
|
1109
|
+
B.hasOwnProperty(R) && this._handlePublication(v, B[R]);
|
|
1110
1110
|
}
|
|
1111
1111
|
}
|
|
1112
|
-
this._serverSubs[
|
|
1112
|
+
this._serverSubs[v] = {
|
|
1113
1113
|
seq: I.seq,
|
|
1114
1114
|
gen: I.gen,
|
|
1115
1115
|
offset: I.offset,
|
|
@@ -1126,15 +1126,15 @@ function Pt() {
|
|
|
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,76 +1144,76 @@ function Pt() {
|
|
|
1144
1144
|
}
|
|
1145
1145
|
}, {
|
|
1146
1146
|
key: "_subscribeError",
|
|
1147
|
-
value: function(
|
|
1148
|
-
var
|
|
1149
|
-
if (
|
|
1147
|
+
value: function(n, r) {
|
|
1148
|
+
var c = this._getSub(n);
|
|
1149
|
+
if (c && c._isSubscribing()) {
|
|
1150
1150
|
if (r.code === 0 && r.message === q) {
|
|
1151
1151
|
this._disconnect("timeout", !0);
|
|
1152
1152
|
return;
|
|
1153
1153
|
}
|
|
1154
|
-
|
|
1154
|
+
c._setSubscribeError(r);
|
|
1155
1155
|
}
|
|
1156
1156
|
}
|
|
1157
1157
|
}, {
|
|
1158
1158
|
key: "_expandSubscribeContext",
|
|
1159
|
-
value: function(
|
|
1160
|
-
var
|
|
1161
|
-
"recovered" in r && (
|
|
1159
|
+
value: function(n, r) {
|
|
1160
|
+
var c = !1;
|
|
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
|
-
var
|
|
1167
|
-
return "offset" in r && (
|
|
1168
|
-
offset:
|
|
1166
|
+
var v = 0;
|
|
1167
|
+
return "offset" in r && (v = r.offset), l && (n.streamPosition = {
|
|
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
|
-
y._setSubscribeSuccess(
|
|
1178
|
-
var
|
|
1179
|
-
if (
|
|
1180
|
-
|
|
1181
|
-
for (var I in
|
|
1182
|
-
|
|
1177
|
+
y._setSubscribeSuccess(c);
|
|
1178
|
+
var v = c.publications;
|
|
1179
|
+
if (v && v.length > 0) {
|
|
1180
|
+
v.length >= 2 && !v[0].offset && !v[1].offset && (v = v.reverse());
|
|
1181
|
+
for (var I in v)
|
|
1182
|
+
v.hasOwnProperty(I) && this._handlePublication(n, v[I]);
|
|
1183
1183
|
}
|
|
1184
|
-
if (
|
|
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(
|
|
1187
|
-
}, this._getTTLMilliseconds(
|
|
1188
|
-
this._subRefreshTimeouts[
|
|
1186
|
+
return l._subRefresh(n);
|
|
1187
|
+
}, this._getTTLMilliseconds(c.ttl));
|
|
1188
|
+
this._subRefreshTimeouts[n] = B;
|
|
1189
1189
|
}
|
|
1190
1190
|
}
|
|
1191
1191
|
}
|
|
1192
1192
|
}, {
|
|
1193
1193
|
key: "_handleReply",
|
|
1194
|
-
value: function(
|
|
1195
|
-
var
|
|
1196
|
-
if (!(
|
|
1194
|
+
value: function(n, r) {
|
|
1195
|
+
var c = n.id, l = n.result;
|
|
1196
|
+
if (!(c in this._callbacks)) {
|
|
1197
1197
|
r();
|
|
1198
1198
|
return;
|
|
1199
1199
|
}
|
|
1200
|
-
var y = this._callbacks[
|
|
1201
|
-
if (clearTimeout(this._callbacks[
|
|
1200
|
+
var y = this._callbacks[c];
|
|
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
|
|
1211
1211
|
});
|
|
1212
1212
|
} else {
|
|
1213
|
-
var
|
|
1214
|
-
if (!
|
|
1213
|
+
var v = y.callback;
|
|
1214
|
+
if (!v)
|
|
1215
1215
|
return;
|
|
1216
|
-
|
|
1216
|
+
v({
|
|
1217
1217
|
result: l,
|
|
1218
1218
|
next: r
|
|
1219
1219
|
});
|
|
@@ -1221,97 +1221,97 @@ function Pt() {
|
|
|
1221
1221
|
}
|
|
1222
1222
|
}, {
|
|
1223
1223
|
key: "_handleJoin",
|
|
1224
|
-
value: function(
|
|
1225
|
-
var
|
|
1224
|
+
value: function(n, r) {
|
|
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
|
-
l.emit("join",
|
|
1232
|
+
l.emit("join", c);
|
|
1233
1233
|
}
|
|
1234
1234
|
}, {
|
|
1235
1235
|
key: "_handleLeave",
|
|
1236
|
-
value: function(
|
|
1237
|
-
var
|
|
1236
|
+
value: function(n, r) {
|
|
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
|
-
l.emit("leave",
|
|
1244
|
+
l.emit("leave", c);
|
|
1245
1245
|
}
|
|
1246
1246
|
}, {
|
|
1247
1247
|
key: "_handleUnsub",
|
|
1248
|
-
value: function(
|
|
1249
|
-
var
|
|
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,
|
|
1263
1263
|
epoch: r.epoch,
|
|
1264
1264
|
recoverable: r.recoverable
|
|
1265
1265
|
};
|
|
1266
|
-
var
|
|
1267
|
-
channel:
|
|
1266
|
+
var c = {
|
|
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
|
|
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
|
-
if (r.info && (l.info = r.info), !
|
|
1282
|
-
this._isServerSub(
|
|
1281
|
+
if (r.info && (l.info = r.info), !c) {
|
|
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
|
|
1296
|
-
"type" in
|
|
1297
|
-
var y =
|
|
1294
|
+
value: function(n, r) {
|
|
1295
|
+
var c = this._decoder.decodePush(n), l = 0;
|
|
1296
|
+
"type" in c && (l = c.type);
|
|
1297
|
+
var y = c.channel;
|
|
1298
1298
|
if (l === this._pushType.PUBLICATION) {
|
|
1299
|
-
var
|
|
1300
|
-
this._handlePublication(y,
|
|
1299
|
+
var v = this._decoder.decodePushData(this._pushType.PUBLICATION, c.data);
|
|
1300
|
+
this._handlePublication(y, v);
|
|
1301
1301
|
} else if (l === this._pushType.MESSAGE) {
|
|
1302
|
-
var I = this._decoder.decodePushData(this._pushType.MESSAGE,
|
|
1302
|
+
var I = this._decoder.decodePushData(this._pushType.MESSAGE, c.data);
|
|
1303
1303
|
this._handleMessage(I);
|
|
1304
1304
|
} else if (l === this._pushType.JOIN) {
|
|
1305
|
-
var B = this._decoder.decodePushData(this._pushType.JOIN,
|
|
1305
|
+
var B = this._decoder.decodePushData(this._pushType.JOIN, c.data);
|
|
1306
1306
|
this._handleJoin(y, B);
|
|
1307
1307
|
} else if (l === this._pushType.LEAVE) {
|
|
1308
|
-
var R = this._decoder.decodePushData(this._pushType.LEAVE,
|
|
1308
|
+
var R = this._decoder.decodePushData(this._pushType.LEAVE, c.data);
|
|
1309
1309
|
this._handleLeave(y, R);
|
|
1310
1310
|
} else if (l === this._pushType.UNSUBSCRIBE) {
|
|
1311
|
-
var X = this._decoder.decodePushData(this._pushType.UNSUBSCRIBE,
|
|
1311
|
+
var X = this._decoder.decodePushData(this._pushType.UNSUBSCRIBE, c.data);
|
|
1312
1312
|
this._handleUnsub(y, X);
|
|
1313
1313
|
} else if (l === this._pushType.SUBSCRIBE) {
|
|
1314
|
-
var U = this._decoder.decodePushData(this._pushType.UNSUBSCRIBE,
|
|
1314
|
+
var U = this._decoder.decodePushData(this._pushType.UNSUBSCRIBE, c.data);
|
|
1315
1315
|
this._handleSub(y, U);
|
|
1316
1316
|
}
|
|
1317
1317
|
r();
|
|
@@ -1319,78 +1319,78 @@ function Pt() {
|
|
|
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
|
-
this._call(r).then(function(
|
|
1332
|
-
|
|
1333
|
-
}, function(
|
|
1334
|
-
|
|
1331
|
+
this._call(r).then(function(c) {
|
|
1332
|
+
n._pingResponse(n._decoder.decodeCommandResult(n._methodType.PING, c.result)), c.next && c.next();
|
|
1333
|
+
}, function(c) {
|
|
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(
|
|
1369
|
-
var
|
|
1370
|
-
message:
|
|
1368
|
+
value: function(n, r) {
|
|
1369
|
+
var c = {
|
|
1370
|
+
message: n,
|
|
1371
1371
|
code: r || 0
|
|
1372
1372
|
};
|
|
1373
|
-
return
|
|
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
|
-
errback:
|
|
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,106 +1430,106 @@ function Pt() {
|
|
|
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 = {};
|
|
1437
|
-
var
|
|
1437
|
+
var c = [];
|
|
1438
1438
|
for (var l in r)
|
|
1439
1439
|
if (r.hasOwnProperty(l)) {
|
|
1440
1440
|
var y = this._getSub(l);
|
|
1441
1441
|
if (!y)
|
|
1442
1442
|
continue;
|
|
1443
|
-
|
|
1443
|
+
c.push(l);
|
|
1444
1444
|
}
|
|
1445
|
-
if (
|
|
1445
|
+
if (c.length === 0) {
|
|
1446
1446
|
this._debug("no private channels found, no need to make request");
|
|
1447
1447
|
return;
|
|
1448
1448
|
}
|
|
1449
|
-
var
|
|
1449
|
+
var v = {
|
|
1450
1450
|
client: this._clientID,
|
|
1451
|
-
channels:
|
|
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
|
-
|
|
1456
|
-
for (var
|
|
1457
|
-
if (
|
|
1458
|
-
var Pe =
|
|
1459
|
-
|
|
1455
|
+
n._debug("authorization request failed");
|
|
1456
|
+
for (var re in c)
|
|
1457
|
+
if (c.hasOwnProperty(re)) {
|
|
1458
|
+
var Pe = c[re];
|
|
1459
|
+
n._subscribeError(Pe, n._createErrorObject("authorization request failed"));
|
|
1460
1460
|
}
|
|
1461
1461
|
return;
|
|
1462
1462
|
}
|
|
1463
1463
|
var le = {};
|
|
1464
1464
|
if (D.data.channels)
|
|
1465
|
-
for (var
|
|
1466
|
-
var ke = D.data.channels[
|
|
1465
|
+
for (var W in D.data.channels) {
|
|
1466
|
+
var ke = D.data.channels[W];
|
|
1467
1467
|
ke.channel && (le[ke.channel] = ke.token);
|
|
1468
1468
|
}
|
|
1469
1469
|
var Ue = !1;
|
|
1470
|
-
|
|
1471
|
-
for (var He in
|
|
1472
|
-
if (
|
|
1473
|
-
var
|
|
1474
|
-
var z =
|
|
1470
|
+
n._isBatching || (n.startBatching(), Ue = !0);
|
|
1471
|
+
for (var He in c)
|
|
1472
|
+
if (c.hasOwnProperty(He)) {
|
|
1473
|
+
var yt = (function() {
|
|
1474
|
+
var z = c[He], xe = le[z];
|
|
1475
1475
|
if (xe) {
|
|
1476
|
-
var
|
|
1477
|
-
method:
|
|
1476
|
+
var oe = {
|
|
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
|
-
|
|
1488
|
-
var we =
|
|
1487
|
+
oe.params.recover = !0;
|
|
1488
|
+
var we = n._getLastSeq(z), _e = n._getLastGen(z);
|
|
1489
1489
|
if (we || _e)
|
|
1490
|
-
we && (
|
|
1490
|
+
we && (oe.params.seq = we), _e && (oe.params.gen = _e);
|
|
1491
1491
|
else {
|
|
1492
|
-
var qe =
|
|
1493
|
-
qe && (
|
|
1492
|
+
var qe = n._getLastOffset(z);
|
|
1493
|
+
qe && (oe.params.offset = qe);
|
|
1494
1494
|
}
|
|
1495
|
-
var je =
|
|
1496
|
-
je && (
|
|
1495
|
+
var je = n._getLastEpoch(z);
|
|
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
|
-
if (
|
|
1506
|
+
if (yt === "continue") continue;
|
|
1507
1507
|
}
|
|
1508
|
-
Ue &&
|
|
1508
|
+
Ue && n.stopBatching();
|
|
1509
1509
|
}
|
|
1510
1510
|
};
|
|
1511
1511
|
if (this._config.onPrivateSubscribe !== null)
|
|
1512
1512
|
this._config.onPrivateSubscribe({
|
|
1513
|
-
data:
|
|
1513
|
+
data: v
|
|
1514
1514
|
}, R);
|
|
1515
1515
|
else {
|
|
1516
|
-
var X = this._ajax(this._config.subscribeEndpoint, this._config.subscribeParams, this._config.subscribeHeaders,
|
|
1516
|
+
var X = this._ajax(this._config.subscribeEndpoint, this._config.subscribeParams, this._config.subscribeHeaders, v, R);
|
|
1517
1517
|
this._xhrs[B] = X;
|
|
1518
1518
|
}
|
|
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
|
-
return l._setEvents(r), l._isUnsubscribed() && l.subscribe(
|
|
1531
|
-
var y = new S.default(this,
|
|
1532
|
-
return this._subs[
|
|
1530
|
+
return l._setEvents(r), l._isUnsubscribed() && l.subscribe(c), l;
|
|
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);
|
|
@@ -1539,18 +1539,18 @@ function Pt() {
|
|
|
1539
1539
|
/***/
|
|
1540
1540
|
579: (
|
|
1541
1541
|
/***/
|
|
1542
|
-
(function(
|
|
1542
|
+
(function(a, d, g) {
|
|
1543
1543
|
Object.defineProperty(d, "__esModule", {
|
|
1544
1544
|
value: !0
|
|
1545
1545
|
}), d.default = void 0;
|
|
1546
1546
|
var C = g(382), S = C.Centrifuge;
|
|
1547
|
-
d.default = S,
|
|
1547
|
+
d.default = S, a.exports = d.default;
|
|
1548
1548
|
})
|
|
1549
1549
|
),
|
|
1550
1550
|
/***/
|
|
1551
1551
|
147: (
|
|
1552
1552
|
/***/
|
|
1553
|
-
(function(
|
|
1553
|
+
(function(a, d) {
|
|
1554
1554
|
Object.defineProperty(d, "__esModule", {
|
|
1555
1555
|
value: !0
|
|
1556
1556
|
}), d.JsonPushType = d.JsonMethodType = d.JsonEncoder = d.JsonDecoder = void 0;
|
|
@@ -1582,7 +1582,7 @@ function Pt() {
|
|
|
1582
1582
|
SUB_REFRESH: 11
|
|
1583
1583
|
};
|
|
1584
1584
|
d.JsonMethodType = T;
|
|
1585
|
-
var
|
|
1585
|
+
var E = {
|
|
1586
1586
|
PUBLICATION: 0,
|
|
1587
1587
|
JOIN: 1,
|
|
1588
1588
|
LEAVE: 2,
|
|
@@ -1590,7 +1590,7 @@ function Pt() {
|
|
|
1590
1590
|
MESSAGE: 4,
|
|
1591
1591
|
SUBSCRIBE: 5
|
|
1592
1592
|
};
|
|
1593
|
-
d.JsonPushType =
|
|
1593
|
+
d.JsonPushType = E;
|
|
1594
1594
|
var Q = /* @__PURE__ */ (function() {
|
|
1595
1595
|
function m() {
|
|
1596
1596
|
g(this, m);
|
|
@@ -1643,7 +1643,7 @@ function Pt() {
|
|
|
1643
1643
|
/***/
|
|
1644
1644
|
471: (
|
|
1645
1645
|
/***/
|
|
1646
|
-
(function(
|
|
1646
|
+
(function(a, d, g) {
|
|
1647
1647
|
function C(h) {
|
|
1648
1648
|
"@babel/helpers - typeof";
|
|
1649
1649
|
return typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? C = function(A) {
|
|
@@ -1655,8 +1655,8 @@ function Pt() {
|
|
|
1655
1655
|
Object.defineProperty(d, "__esModule", {
|
|
1656
1656
|
value: !0
|
|
1657
1657
|
}), d.default = void 0;
|
|
1658
|
-
var S =
|
|
1659
|
-
function
|
|
1658
|
+
var S = E(g(187)), T = g(853);
|
|
1659
|
+
function E(h) {
|
|
1660
1660
|
return h && h.__esModule ? h : { default: h };
|
|
1661
1661
|
}
|
|
1662
1662
|
function Q(h, p) {
|
|
@@ -1665,8 +1665,8 @@ function Pt() {
|
|
|
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 Pt() {
|
|
|
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
|
-
var
|
|
1691
|
-
r = Reflect.construct(
|
|
1690
|
+
var c = M(this).constructor;
|
|
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 Pt() {
|
|
|
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
|
}
|
|
@@ -1739,9 +1739,9 @@ function Pt() {
|
|
|
1739
1739
|
key: "_initializePromise",
|
|
1740
1740
|
value: function() {
|
|
1741
1741
|
var r = this;
|
|
1742
|
-
this._ready = !1, this._subscriptionPromise = new Promise(function(
|
|
1742
|
+
this._ready = !1, this._subscriptionPromise = new Promise(function(c, l) {
|
|
1743
1743
|
r._resolve = function(y) {
|
|
1744
|
-
r._ready = !0,
|
|
1744
|
+
r._ready = !0, c(y);
|
|
1745
1745
|
}, r._reject = function(y) {
|
|
1746
1746
|
r._ready = !0, l(y);
|
|
1747
1747
|
};
|
|
@@ -1766,9 +1766,9 @@ function Pt() {
|
|
|
1766
1766
|
if ((0, T.isFunction)(r))
|
|
1767
1767
|
this.on("publish", r);
|
|
1768
1768
|
else if (Object.prototype.toString.call(r) === Object.prototype.toString.call({}))
|
|
1769
|
-
for (var
|
|
1770
|
-
var
|
|
1771
|
-
|
|
1769
|
+
for (var c = ["publish", "join", "leave", "unsubscribe", "subscribe", "error"], l = 0, y = c.length; l < y; l++) {
|
|
1770
|
+
var v = c[l];
|
|
1771
|
+
v in r && this.on(v, r[v]);
|
|
1772
1772
|
}
|
|
1773
1773
|
}
|
|
1774
1774
|
}
|
|
@@ -1817,8 +1817,8 @@ function Pt() {
|
|
|
1817
1817
|
value: function(r) {
|
|
1818
1818
|
if (this._status !== q) {
|
|
1819
1819
|
this._status = q;
|
|
1820
|
-
var
|
|
1821
|
-
this._recover = !1, this.emit("subscribe",
|
|
1820
|
+
var c = this._getSubscribeSuccessContext(r);
|
|
1821
|
+
this._recover = !1, this.emit("subscribe", c), this._resolve(c);
|
|
1822
1822
|
for (var l in this._promises)
|
|
1823
1823
|
clearTimeout(this._promises[l].timeout), this._promises[l].resolve(), delete this._promises[l];
|
|
1824
1824
|
}
|
|
@@ -1828,8 +1828,8 @@ function Pt() {
|
|
|
1828
1828
|
value: function(r) {
|
|
1829
1829
|
if (this._status !== N) {
|
|
1830
1830
|
this._status = N, this._error = r;
|
|
1831
|
-
var
|
|
1832
|
-
this.emit("error",
|
|
1831
|
+
var c = this._getSubscribeErrorContext();
|
|
1832
|
+
this.emit("error", c), this._reject(c);
|
|
1833
1833
|
for (var l in this._promises)
|
|
1834
1834
|
clearTimeout(this._promises[l].timeout), this._promises[l].reject(r), delete this._promises[l];
|
|
1835
1835
|
}
|
|
@@ -1845,8 +1845,8 @@ function Pt() {
|
|
|
1845
1845
|
key: "_setUnsubscribed",
|
|
1846
1846
|
value: function(r) {
|
|
1847
1847
|
if (this._centrifuge._clearSubRefreshTimeout(this.channel), this._status !== b) {
|
|
1848
|
-
var
|
|
1849
|
-
this._status = b, r === !0 && (this._recover = !1, this._noResubscribe = !0, delete this._centrifuge._lastSeq[this.channel], delete this._centrifuge._lastGen[this.channel], delete this._centrifuge._lastEpoch[this.channel]),
|
|
1848
|
+
var c = this._status === q;
|
|
1849
|
+
this._status = b, r === !0 && (this._recover = !1, this._noResubscribe = !0, delete this._centrifuge._lastSeq[this.channel], delete this._centrifuge._lastGen[this.channel], delete this._centrifuge._lastEpoch[this.channel]), c && this._triggerUnsubscribe();
|
|
1850
1850
|
}
|
|
1851
1851
|
}
|
|
1852
1852
|
}, {
|
|
@@ -1857,11 +1857,11 @@ function Pt() {
|
|
|
1857
1857
|
}, {
|
|
1858
1858
|
key: "_getSubscribeSuccessContext",
|
|
1859
1859
|
value: function(r) {
|
|
1860
|
-
var
|
|
1860
|
+
var c = {
|
|
1861
1861
|
channel: this.channel,
|
|
1862
1862
|
isResubscribe: this._isResubscribe
|
|
1863
1863
|
};
|
|
1864
|
-
return r && (
|
|
1864
|
+
return r && (c = this._centrifuge._expandSubscribeContext(c, r)), c;
|
|
1865
1865
|
}
|
|
1866
1866
|
}, {
|
|
1867
1867
|
key: "_getSubscribeErrorContext",
|
|
@@ -1876,8 +1876,8 @@ function Pt() {
|
|
|
1876
1876
|
}
|
|
1877
1877
|
}, {
|
|
1878
1878
|
key: "ready",
|
|
1879
|
-
value: function(r,
|
|
1880
|
-
this._ready && (this._isSuccess() ? r(this._getSubscribeSuccessContext()) :
|
|
1879
|
+
value: function(r, c) {
|
|
1880
|
+
this._ready && (this._isSuccess() ? r(this._getSubscribeSuccessContext()) : c(this._getSubscribeErrorContext()));
|
|
1881
1881
|
}
|
|
1882
1882
|
}, {
|
|
1883
1883
|
key: "subscribe",
|
|
@@ -1897,27 +1897,27 @@ function Pt() {
|
|
|
1897
1897
|
return Promise.resolve();
|
|
1898
1898
|
if (this._isError())
|
|
1899
1899
|
return Promise.reject(this._error);
|
|
1900
|
-
var
|
|
1901
|
-
var
|
|
1900
|
+
var c = new Promise(function(l, y) {
|
|
1901
|
+
var v = setTimeout(function() {
|
|
1902
1902
|
y({
|
|
1903
1903
|
code: 0,
|
|
1904
1904
|
message: "timeout"
|
|
1905
1905
|
});
|
|
1906
1906
|
}, r._centrifuge._config.timeout);
|
|
1907
1907
|
r._promises[r._nextPromiseId()] = {
|
|
1908
|
-
timeout:
|
|
1908
|
+
timeout: v,
|
|
1909
1909
|
resolve: l,
|
|
1910
1910
|
reject: y
|
|
1911
1911
|
};
|
|
1912
1912
|
});
|
|
1913
|
-
return
|
|
1913
|
+
return c;
|
|
1914
1914
|
}
|
|
1915
1915
|
}, {
|
|
1916
1916
|
key: "publish",
|
|
1917
1917
|
value: function(r) {
|
|
1918
|
-
var
|
|
1918
|
+
var c = this;
|
|
1919
1919
|
return this._methodCall().then(function() {
|
|
1920
|
-
return
|
|
1920
|
+
return c._centrifuge.publish(c.channel, r);
|
|
1921
1921
|
});
|
|
1922
1922
|
}
|
|
1923
1923
|
}, {
|
|
@@ -1939,23 +1939,23 @@ function Pt() {
|
|
|
1939
1939
|
}, {
|
|
1940
1940
|
key: "history",
|
|
1941
1941
|
value: function(r) {
|
|
1942
|
-
var
|
|
1942
|
+
var c = this;
|
|
1943
1943
|
return this._methodCall().then(function() {
|
|
1944
|
-
return
|
|
1944
|
+
return c._centrifuge.history(c.channel, r);
|
|
1945
1945
|
});
|
|
1946
1946
|
}
|
|
1947
1947
|
}]), A;
|
|
1948
1948
|
})(S.default);
|
|
1949
|
-
d.default = f,
|
|
1949
|
+
d.default = f, a.exports = d.default;
|
|
1950
1950
|
})
|
|
1951
1951
|
),
|
|
1952
1952
|
/***/
|
|
1953
1953
|
853: (
|
|
1954
1954
|
/***/
|
|
1955
|
-
(function(
|
|
1955
|
+
(function(a, d, g) {
|
|
1956
1956
|
Object.defineProperty(d, "__esModule", {
|
|
1957
1957
|
value: !0
|
|
1958
|
-
}), d.backoff =
|
|
1958
|
+
}), d.backoff = E, d.errorExists = Q, d.extend = _, d.isFunction = S, d.log = T, d.startsWith = C;
|
|
1959
1959
|
function C(m, P) {
|
|
1960
1960
|
return m.lastIndexOf(P, 0) === 0;
|
|
1961
1961
|
}
|
|
@@ -1968,7 +1968,7 @@ function Pt() {
|
|
|
1968
1968
|
S(k) && k.apply(g.g.console, P);
|
|
1969
1969
|
}
|
|
1970
1970
|
}
|
|
1971
|
-
function
|
|
1971
|
+
function E(m, P, k) {
|
|
1972
1972
|
var w = 0.5 * Math.random(), L = Math.min(k, P * Math.pow(2, m + 1));
|
|
1973
1973
|
return Math.floor((1 - w) * L);
|
|
1974
1974
|
}
|
|
@@ -1985,7 +1985,7 @@ function Pt() {
|
|
|
1985
1985
|
/***/
|
|
1986
1986
|
187: (
|
|
1987
1987
|
/***/
|
|
1988
|
-
(function(
|
|
1988
|
+
(function(a) {
|
|
1989
1989
|
var d = typeof Reflect == "object" ? Reflect : null, g = d && typeof d.apply == "function" ? d.apply : function(f, h, p) {
|
|
1990
1990
|
return Function.prototype.apply.call(f, h, p);
|
|
1991
1991
|
}, C;
|
|
@@ -2000,16 +2000,16 @@ function Pt() {
|
|
|
2000
2000
|
var T = Number.isNaN || function(f) {
|
|
2001
2001
|
return f !== f;
|
|
2002
2002
|
};
|
|
2003
|
-
function
|
|
2004
|
-
|
|
2003
|
+
function E() {
|
|
2004
|
+
E.init.call(this);
|
|
2005
2005
|
}
|
|
2006
|
-
|
|
2006
|
+
a.exports = E, a.exports.once = x, E.EventEmitter = E, E.prototype._events = void 0, E.prototype._eventsCount = 0, E.prototype._maxListeners = void 0;
|
|
2007
2007
|
var Q = 10;
|
|
2008
2008
|
function _(b) {
|
|
2009
2009
|
if (typeof b != "function")
|
|
2010
2010
|
throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof b);
|
|
2011
2011
|
}
|
|
2012
|
-
Object.defineProperty(
|
|
2012
|
+
Object.defineProperty(E, "defaultMaxListeners", {
|
|
2013
2013
|
enumerable: !0,
|
|
2014
2014
|
get: function() {
|
|
2015
2015
|
return Q;
|
|
@@ -2019,60 +2019,60 @@ function Pt() {
|
|
|
2019
2019
|
throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + b + ".");
|
|
2020
2020
|
Q = b;
|
|
2021
2021
|
}
|
|
2022
|
-
}),
|
|
2022
|
+
}), E.init = function() {
|
|
2023
2023
|
(this._events === void 0 || this._events === Object.getPrototypeOf(this)._events) && (this._events = /* @__PURE__ */ Object.create(null), this._eventsCount = 0), this._maxListeners = this._maxListeners || void 0;
|
|
2024
|
-
},
|
|
2024
|
+
}, E.prototype.setMaxListeners = function(f) {
|
|
2025
2025
|
if (typeof f != "number" || f < 0 || T(f))
|
|
2026
2026
|
throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + f + ".");
|
|
2027
2027
|
return this._maxListeners = f, this;
|
|
2028
2028
|
};
|
|
2029
2029
|
function m(b) {
|
|
2030
|
-
return b._maxListeners === void 0 ?
|
|
2030
|
+
return b._maxListeners === void 0 ? E.defaultMaxListeners : b._maxListeners;
|
|
2031
2031
|
}
|
|
2032
|
-
|
|
2032
|
+
E.prototype.getMaxListeners = function() {
|
|
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) {
|
|
2042
2042
|
var r;
|
|
2043
2043
|
if (h.length > 0 && (r = h[0]), r instanceof Error)
|
|
2044
2044
|
throw r;
|
|
2045
|
-
var
|
|
2046
|
-
throw
|
|
2045
|
+
var c = new Error("Unhandled error." + (r ? " (" + r.message + ")" : ""));
|
|
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")
|
|
2052
2052
|
g(l, this, h);
|
|
2053
2053
|
else
|
|
2054
|
-
for (var y = l.length,
|
|
2055
|
-
g(
|
|
2054
|
+
for (var y = l.length, v = F(l, y), p = 0; p < y; ++p)
|
|
2055
|
+
g(v[p], this, h);
|
|
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
|
-
var
|
|
2069
|
-
|
|
2068
|
+
var c = new Error("Possible EventEmitter memory leak detected. " + r.length + " " + String(f) + " listeners added. Use emitter.setMaxListeners() to increase limit");
|
|
2069
|
+
c.name = "MaxListenersExceededWarning", c.emitter = b, c.type = f, c.count = r.length, S(c);
|
|
2070
2070
|
}
|
|
2071
2071
|
return b;
|
|
2072
2072
|
}
|
|
2073
|
-
|
|
2073
|
+
E.prototype.addListener = function(f, h) {
|
|
2074
2074
|
return P(this, f, h, !1);
|
|
2075
|
-
},
|
|
2075
|
+
}, E.prototype.on = E.prototype.addListener, E.prototype.prependListener = function(f, h) {
|
|
2076
2076
|
return P(this, f, h, !0);
|
|
2077
2077
|
};
|
|
2078
2078
|
function k() {
|
|
@@ -2083,12 +2083,12 @@ function Pt() {
|
|
|
2083
2083
|
var p = { fired: !1, wrapFn: void 0, target: b, type: f, listener: h }, A = k.bind(p);
|
|
2084
2084
|
return A.listener = h, p.wrapFn = A, A;
|
|
2085
2085
|
}
|
|
2086
|
-
|
|
2086
|
+
E.prototype.once = function(f, h) {
|
|
2087
2087
|
return _(h), this.on(f, w(this, f, h)), this;
|
|
2088
|
-
},
|
|
2088
|
+
}, E.prototype.prependOnceListener = function(f, h) {
|
|
2089
2089
|
return _(h), this.prependListener(f, w(this, f, h)), this;
|
|
2090
|
-
},
|
|
2091
|
-
var p, A,
|
|
2090
|
+
}, E.prototype.removeListener = function(f, h) {
|
|
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,26 +2096,26 @@ function Pt() {
|
|
|
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
|
-
|
|
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) {
|
|
2110
2110
|
var h, p, A;
|
|
2111
2111
|
if (p = this._events, p === void 0)
|
|
2112
2112
|
return this;
|
|
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")
|
|
@@ -2132,13 +2132,13 @@ function Pt() {
|
|
|
2132
2132
|
var A = p[f];
|
|
2133
2133
|
return A === void 0 ? [] : typeof A == "function" ? h ? [A.listener || A] : [A] : h ? J(A) : F(A, A.length);
|
|
2134
2134
|
}
|
|
2135
|
-
|
|
2135
|
+
E.prototype.listeners = function(f) {
|
|
2136
2136
|
return L(this, f, !0);
|
|
2137
|
-
},
|
|
2137
|
+
}, E.prototype.rawListeners = function(f) {
|
|
2138
2138
|
return L(this, f, !1);
|
|
2139
|
-
},
|
|
2139
|
+
}, E.listenerCount = function(b, f) {
|
|
2140
2140
|
return typeof b.listenerCount == "function" ? b.listenerCount(f) : O.call(b, f);
|
|
2141
|
-
},
|
|
2141
|
+
}, E.prototype.listenerCount = O;
|
|
2142
2142
|
function O(b) {
|
|
2143
2143
|
var f = this._events;
|
|
2144
2144
|
if (f !== void 0) {
|
|
@@ -2150,7 +2150,7 @@ function Pt() {
|
|
|
2150
2150
|
}
|
|
2151
2151
|
return 0;
|
|
2152
2152
|
}
|
|
2153
|
-
|
|
2153
|
+
E.prototype.eventNames = function() {
|
|
2154
2154
|
return this._eventsCount > 0 ? C(this._events) : [];
|
|
2155
2155
|
};
|
|
2156
2156
|
function F(b, f) {
|
|
@@ -2171,12 +2171,12 @@ function Pt() {
|
|
|
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 Pt() {
|
|
|
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);
|
|
@@ -2195,12 +2195,12 @@ function Pt() {
|
|
|
2195
2195
|
})
|
|
2196
2196
|
)
|
|
2197
2197
|
/******/
|
|
2198
|
-
},
|
|
2199
|
-
function
|
|
2200
|
-
var d =
|
|
2198
|
+
}, i = {};
|
|
2199
|
+
function s(a) {
|
|
2200
|
+
var d = i[a];
|
|
2201
2201
|
if (d !== void 0)
|
|
2202
2202
|
return d.exports;
|
|
2203
|
-
var g =
|
|
2203
|
+
var g = i[a] = {
|
|
2204
2204
|
/******/
|
|
2205
2205
|
// no module.id needed
|
|
2206
2206
|
/******/
|
|
@@ -2209,10 +2209,10 @@ function Pt() {
|
|
|
2209
2209
|
exports: {}
|
|
2210
2210
|
/******/
|
|
2211
2211
|
};
|
|
2212
|
-
return o[
|
|
2212
|
+
return o[a](g, g.exports, s), g.exports;
|
|
2213
2213
|
}
|
|
2214
2214
|
(function() {
|
|
2215
|
-
|
|
2215
|
+
s.g = (function() {
|
|
2216
2216
|
if (typeof globalThis == "object") return globalThis;
|
|
2217
2217
|
try {
|
|
2218
2218
|
return this || new Function("return this")();
|
|
@@ -2221,52 +2221,52 @@ function Pt() {
|
|
|
2221
2221
|
}
|
|
2222
2222
|
})();
|
|
2223
2223
|
})();
|
|
2224
|
-
var u =
|
|
2224
|
+
var u = s(579);
|
|
2225
2225
|
return u;
|
|
2226
2226
|
})()
|
|
2227
2227
|
);
|
|
2228
2228
|
});
|
|
2229
2229
|
})(fe)), fe.exports;
|
|
2230
2230
|
}
|
|
2231
|
-
var
|
|
2232
|
-
const
|
|
2231
|
+
var wt = kt();
|
|
2232
|
+
const _t = /* @__PURE__ */ St(wt);
|
|
2233
2233
|
let he = null;
|
|
2234
|
-
function
|
|
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
|
-
const { client_url: o, token:
|
|
2238
|
-
if (
|
|
2237
|
+
const { client_url: o, token: i, channel: s } = e;
|
|
2238
|
+
if (s.includes("#") || console.warn("[Centrifuge] Channel should contain #user_id"), he) {
|
|
2239
2239
|
try {
|
|
2240
2240
|
console.log("[Centrifuge] Disconnecting previous instance..."), he.disconnect();
|
|
2241
|
-
} catch (
|
|
2242
|
-
console.error("[Centrifuge] Error while disconnecting previous instance:",
|
|
2241
|
+
} catch (a) {
|
|
2242
|
+
console.error("[Centrifuge] Error while disconnecting previous instance:", a);
|
|
2243
2243
|
}
|
|
2244
2244
|
he = null;
|
|
2245
2245
|
}
|
|
2246
2246
|
console.log("[Centrifuge] Creating new instance:", o);
|
|
2247
|
-
const u = new
|
|
2248
|
-
return u.setToken(
|
|
2249
|
-
console.log("[Centrifuge] Connected",
|
|
2250
|
-
const d = u.subscribe(
|
|
2247
|
+
const u = new _t(o);
|
|
2248
|
+
return u.setToken(i), u.on("connect", (a) => {
|
|
2249
|
+
console.log("[Centrifuge] Connected", a), console.log("[Centrifuge] Subscribing to channel:", s);
|
|
2250
|
+
const d = u.subscribe(s);
|
|
2251
2251
|
d.on("publish", (g) => {
|
|
2252
2252
|
console.log("[Centrifuge] Publish event received:", g);
|
|
2253
|
-
const C =
|
|
2254
|
-
C &&
|
|
2253
|
+
const C = Tt(g);
|
|
2254
|
+
C && t(C);
|
|
2255
2255
|
}), d.on("subscribe", (g) => {
|
|
2256
|
-
console.log("[Centrifuge] ✅ Channel subscribed successfully:",
|
|
2256
|
+
console.log("[Centrifuge] ✅ Channel subscribed successfully:", s, g);
|
|
2257
2257
|
}), d.on("error", (g) => {
|
|
2258
2258
|
console.error("[Centrifuge] ❌ Subscription error:", g);
|
|
2259
2259
|
}), d.on("unsubscribe", (g) => {
|
|
2260
2260
|
console.log("[Centrifuge] Channel unsubscribed:", g);
|
|
2261
2261
|
});
|
|
2262
|
-
}), u.on("disconnect", (
|
|
2262
|
+
}), u.on("disconnect", (a) => console.log("[Centrifuge] Disconnected", a)), u.on("error", (a) => console.error("[Centrifuge] Error", a)), console.log("[Centrifuge] Calling connect()..."), u.connect(), he = u, { centrifuge: u };
|
|
2263
2263
|
}
|
|
2264
|
-
function
|
|
2265
|
-
var o,
|
|
2264
|
+
function Tt(e) {
|
|
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,27 +2289,27 @@ 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
|
-
function
|
|
2296
|
-
var u,
|
|
2297
|
-
const
|
|
2295
|
+
function Lt(e) {
|
|
2296
|
+
var u, a, d;
|
|
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 };
|
|
2301
2301
|
if (typeof o != "object") return null;
|
|
2302
|
-
const
|
|
2302
|
+
const i = o.type ?? o.payment_method ?? o.method, s = o.card_id ?? o.cardId ?? o.id ?? ((d = o.card) == null ? void 0 : d.id) ?? null;
|
|
2303
2303
|
return {
|
|
2304
|
-
type: Ye(
|
|
2305
|
-
cardId:
|
|
2304
|
+
type: Ye(i),
|
|
2305
|
+
cardId: s != null ? String(s) : null
|
|
2306
2306
|
};
|
|
2307
2307
|
}
|
|
2308
|
-
function
|
|
2308
|
+
function Rt(e, t, o = {}) {
|
|
2309
2309
|
var P, k, w, L;
|
|
2310
|
-
const
|
|
2311
|
-
return
|
|
2312
|
-
|
|
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
|
+
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) => {
|
|
2312
|
+
i.push({
|
|
2313
2313
|
iconType: ge(O.attributes.mask),
|
|
2314
2314
|
type: "card",
|
|
2315
2315
|
cardId: O.id,
|
|
@@ -2317,26 +2317,26 @@ function Lt(e, n, o = {}) {
|
|
|
2317
2317
|
cardType: O.type,
|
|
2318
2318
|
isDefault: O.attributes.isDefault
|
|
2319
2319
|
});
|
|
2320
|
-
}), K(
|
|
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:
|
|
2324
|
-
}),
|
|
2323
|
+
label: t ? t("newCard") : "Оплата новой картой"
|
|
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,
|
|
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
|
-
const Q =
|
|
2331
|
+
const Q = Lt(e);
|
|
2332
2332
|
if ((Q == null ? void 0 : Q.type) === "kaspi_pay" && (o != null && o.isAvailable) && u && !d)
|
|
2333
2333
|
return Z;
|
|
2334
2334
|
if ((Q == null ? void 0 : Q.type) === "apple_pay" && T) return ot;
|
|
2335
|
-
if ((Q == null ? void 0 : Q.type) === "google_pay" &&
|
|
2336
|
-
if ((Q == null ? void 0 : Q.type) === "new_card" && K(
|
|
2335
|
+
if ((Q == null ? void 0 : Q.type) === "google_pay" && E) return st;
|
|
2336
|
+
if ((Q == null ? void 0 : Q.type) === "new_card" && K(s.payment_method_new_card))
|
|
2337
2337
|
return { iconType: "new_card", type: "new_card", label: "Оплата новой картой" };
|
|
2338
|
-
if ((Q == null ? void 0 : Q.type) === "card" &&
|
|
2339
|
-
const L = Q.cardId != null ?
|
|
2338
|
+
if ((Q == null ? void 0 : Q.type) === "card" && a) {
|
|
2339
|
+
const L = Q.cardId != null ? i.find((O) => !O.isExpired && String(O.id) === Q.cardId) : null;
|
|
2340
2340
|
if (L)
|
|
2341
2341
|
return {
|
|
2342
2342
|
iconType: ge(L.attributes.mask),
|
|
@@ -2346,8 +2346,8 @@ function Le(e, n = {}) {
|
|
|
2346
2346
|
cardType: L.type
|
|
2347
2347
|
};
|
|
2348
2348
|
}
|
|
2349
|
-
if (
|
|
2350
|
-
const L =
|
|
2349
|
+
if (a) {
|
|
2350
|
+
const L = i.find((O) => {
|
|
2351
2351
|
var F;
|
|
2352
2352
|
return ((F = O.attributes) == null ? void 0 : F.isDefault) && !O.isExpired;
|
|
2353
2353
|
});
|
|
@@ -2361,7 +2361,7 @@ function Le(e, n = {}) {
|
|
|
2361
2361
|
};
|
|
2362
2362
|
}
|
|
2363
2363
|
if (o != null && o.isAvailable && u && !d) return Z;
|
|
2364
|
-
const _ =
|
|
2364
|
+
const _ = a ? i.find((L) => !L.isExpired) : null;
|
|
2365
2365
|
return _ ? {
|
|
2366
2366
|
iconType: ge(_.attributes.mask),
|
|
2367
2367
|
type: "card",
|
|
@@ -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
|
|
2395
|
+
async function Ot(e, t) {
|
|
2396
2396
|
var o;
|
|
2397
2397
|
try {
|
|
2398
|
-
const
|
|
2399
|
-
return (
|
|
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) || t;
|
|
2400
2400
|
} catch {
|
|
2401
2401
|
return `HTTP ${e.status}: ${e.statusText}`;
|
|
2402
2402
|
}
|
|
2403
2403
|
}
|
|
2404
|
-
async function
|
|
2405
|
-
const o = await
|
|
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,
|
|
2409
|
-
const
|
|
2408
|
+
function Ie(e, t, o = {}) {
|
|
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
|
-
checkoutAmount:
|
|
2412
|
-
checkoutPaymentMethod:
|
|
2411
|
+
checkoutAmount: i,
|
|
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,28 +2422,28 @@ function Qe(e, n, o, s) {
|
|
|
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
|
},
|
|
2440
|
-
body: JSON.stringify(
|
|
2440
|
+
body: JSON.stringify(i)
|
|
2441
2441
|
});
|
|
2442
|
-
return u.ok || await
|
|
2442
|
+
return u.ok || await ne(u, s), u.json();
|
|
2443
2443
|
}
|
|
2444
|
-
async function
|
|
2444
|
+
async function Mt(e, t, o) {
|
|
2445
2445
|
var d, g, C, S;
|
|
2446
|
-
const
|
|
2446
|
+
const i = await fetch(`${e}/api/v2/oauth2/tokens`, {
|
|
2447
2447
|
method: "POST",
|
|
2448
2448
|
headers: {
|
|
2449
2449
|
"Content-Type": "application/json",
|
|
@@ -2451,166 +2451,166 @@ async function Ot(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
|
})
|
|
2458
2458
|
});
|
|
2459
|
-
|
|
2460
|
-
const
|
|
2459
|
+
i.ok || await ne(i, "Не удалось авторизоваться через track_id");
|
|
2460
|
+
const s = await i.json(), u = (s == null ? void 0 : s.access_token) ?? ((g = (d = s == null ? void 0 : s.data) == null ? void 0 : d.attributes) == null ? void 0 : g.access_token), a = (s == null ? void 0 : s.refresh_token) ?? ((S = (C = s == null ? void 0 : s.data) == null ? void 0 : C.attributes) == null ? void 0 : S.refresh_token) ?? null;
|
|
2461
2461
|
if (!u) throw new Error("В ответе отсутствует access_token");
|
|
2462
|
-
return { access_token: u, refresh_token:
|
|
2462
|
+
return { access_token: u, refresh_token: a };
|
|
2463
2463
|
}
|
|
2464
|
-
async function
|
|
2464
|
+
async function Nt(e, t, o) {
|
|
2465
2465
|
var d, g, C, S;
|
|
2466
|
-
const
|
|
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
|
})
|
|
2474
2474
|
});
|
|
2475
|
-
|
|
2476
|
-
const
|
|
2475
|
+
i.ok || await ne(i, "Не удалось обновить токен по refresh_token");
|
|
2476
|
+
const s = await i.json(), u = (s == null ? void 0 : s.access_token) ?? ((g = (d = s == null ? void 0 : s.data) == null ? void 0 : d.attributes) == null ? void 0 : g.access_token), a = (s == null ? void 0 : s.refresh_token) ?? ((S = (C = s == null ? void 0 : s.data) == null ? void 0 : C.attributes) == null ? void 0 : S.refresh_token) ?? null;
|
|
2477
2477
|
if (!u) throw new Error("В ответе отсутствует access_token");
|
|
2478
|
-
return { access_token: u, refresh_token:
|
|
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
|
-
return o.ok || await
|
|
2497
|
+
return o.ok || await ne(o, "Ошибка получения контекста оплаты"), o.json();
|
|
2498
2498
|
}
|
|
2499
|
-
async function
|
|
2500
|
-
const
|
|
2499
|
+
async function Dt(e, t, o) {
|
|
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
|
-
return
|
|
2507
|
+
return i.ok || await ne(i, "Не удалось удалить карту"), i.json().catch(() => ({}));
|
|
2508
2508
|
}
|
|
2509
|
-
async function
|
|
2510
|
-
const
|
|
2509
|
+
async function Xt(e, t, o) {
|
|
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
|
-
return
|
|
2520
|
+
return i.ok || await ne(i, "Не удалось отметить карту как основную"), i.json().catch(() => ({}));
|
|
2521
2521
|
}
|
|
2522
|
-
async function
|
|
2523
|
-
const
|
|
2522
|
+
async function Ut(e, t, o) {
|
|
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
|
-
if (!
|
|
2530
|
+
if (!i.ok)
|
|
2531
2531
|
throw Object.assign(
|
|
2532
|
-
new Error(`Ошибка проверки статуса заказа: ${
|
|
2533
|
-
{ status:
|
|
2532
|
+
new Error(`Ошибка проверки статуса заказа: ${i.status} ${i.statusText}`),
|
|
2533
|
+
{ status: i.status }
|
|
2534
2534
|
);
|
|
2535
|
-
const
|
|
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,
|
|
2539
|
-
const { checkoutAmount: u, checkoutPaymentMethod:
|
|
2540
|
-
|
|
2538
|
+
async function Ge(e, t, o, i, s = {}) {
|
|
2539
|
+
const { checkoutAmount: u, checkoutPaymentMethod: a, useBalanceFlag: d } = Ie(
|
|
2540
|
+
t,
|
|
2541
2541
|
{
|
|
2542
|
-
type:
|
|
2543
|
-
...
|
|
2542
|
+
type: i.type,
|
|
2543
|
+
...i.cardId && { card_id: i.cardId }
|
|
2544
2544
|
},
|
|
2545
|
-
|
|
2545
|
+
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
|
|
2556
|
-
const { checkoutAmount:
|
|
2557
|
-
|
|
2555
|
+
async function Ht(e, t, o, i = {}) {
|
|
2556
|
+
const { checkoutAmount: s, checkoutPaymentMethod: u, useBalanceFlag: a } = Ie(
|
|
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
|
|
2570
|
-
const
|
|
2569
|
+
async function xt(e, t, o) {
|
|
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
|
-
body: JSON.stringify({ validationUrl: o, domainName:
|
|
2577
|
+
body: JSON.stringify({ validationUrl: o, domainName: i })
|
|
2578
2578
|
});
|
|
2579
|
-
return
|
|
2579
|
+
return s.ok || await ne(s, "Ошибка получения Apple Pay сессии"), s.json();
|
|
2580
2580
|
}
|
|
2581
|
-
async function
|
|
2582
|
-
const { checkoutAmount: u, checkoutPaymentMethod:
|
|
2583
|
-
|
|
2584
|
-
{ type: "apple_pay", data:
|
|
2585
|
-
|
|
2581
|
+
async function Ft(e, t, o, i, s = {}) {
|
|
2582
|
+
const { checkoutAmount: u, checkoutPaymentMethod: a, useBalanceFlag: d } = Ie(
|
|
2583
|
+
t,
|
|
2584
|
+
{ type: "apple_pay", data: i },
|
|
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
|
|
2596
|
-
const { checkoutAmount: u, checkoutPaymentMethod:
|
|
2597
|
-
|
|
2598
|
-
{ type: "google_pay", data:
|
|
2599
|
-
|
|
2595
|
+
async function at(e, t, o, i, s = {}) {
|
|
2596
|
+
const { checkoutAmount: u, checkoutPaymentMethod: a, useBalanceFlag: d } = Ie(
|
|
2597
|
+
t,
|
|
2598
|
+
{ type: "google_pay", data: i },
|
|
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
|
|
2611
|
-
availableBonus: Number.isFinite(
|
|
2612
|
-
amount: Number(
|
|
2613
|
-
percent: Number(
|
|
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
|
+
availableBonus: Number.isFinite(i.availableBonus) ? Number(i.availableBonus) : 0,
|
|
2612
|
+
amount: Number(i.amount),
|
|
2613
|
+
percent: Number(i.percent)
|
|
2614
2614
|
} : null;
|
|
2615
2615
|
return {
|
|
2616
2616
|
preorderId: e.preorderId,
|
|
@@ -2634,32 +2634,36 @@ function Jt(e) {
|
|
|
2634
2634
|
onConfirmPay: typeof e.onConfirmPay == "function" ? e.onConfirmPay : null,
|
|
2635
2635
|
onPaymentMethodSelected: typeof e.onPaymentMethodSelected == "function" ? e.onPaymentMethodSelected : null,
|
|
2636
2636
|
onKaspiLink: typeof e.onKaspiLink == "function" ? e.onKaspiLink : null,
|
|
2637
|
+
onPayWithGooglePay: typeof e.onPayWithGooglePay == "function" ? e.onPayWithGooglePay : null,
|
|
2637
2638
|
onUserEvent: typeof e.onUserEvent == "function" ? e.onUserEvent : null,
|
|
2638
2639
|
onBeforeCheckout: typeof e.onBeforeCheckout == "function" ? e.onBeforeCheckout : null,
|
|
2640
|
+
idempotencyKey: e.idempotencyKey,
|
|
2639
2641
|
locale: e.locale || "ru",
|
|
2640
2642
|
containerSelector: typeof e.containerSelector == "string" ? e.containerSelector.trim() : "",
|
|
2641
2643
|
color: o || "#2F2F2F",
|
|
2642
2644
|
onlyKaspiAvailable: !!e.onlyKaspiAvailable,
|
|
2643
2645
|
disableKaspi: !!e.disableKaspi,
|
|
2644
|
-
|
|
2646
|
+
disableGooglePay: !!e.disableGooglePay,
|
|
2647
|
+
isNativeAndroid: !!e.isNativeAndroid,
|
|
2648
|
+
bonuses: s
|
|
2645
2649
|
};
|
|
2646
2650
|
}
|
|
2647
|
-
function Me(e,
|
|
2648
|
-
Re("webPayToken", e),
|
|
2651
|
+
function Me(e, t) {
|
|
2652
|
+
Re("webPayToken", e), t && Re("webPayRefreshToken", t);
|
|
2649
2653
|
}
|
|
2650
2654
|
function Ze() {
|
|
2651
2655
|
be("webPayToken"), be("webPayRefreshToken");
|
|
2652
2656
|
}
|
|
2653
2657
|
async function qt(e) {
|
|
2654
|
-
const
|
|
2655
|
-
if (
|
|
2658
|
+
const t = it("webPayRefreshToken");
|
|
2659
|
+
if (t && e.config.clientId)
|
|
2656
2660
|
try {
|
|
2657
|
-
const
|
|
2661
|
+
const i = await Nt(
|
|
2658
2662
|
e.apiUrl,
|
|
2659
2663
|
e.config.clientId,
|
|
2660
|
-
|
|
2664
|
+
t
|
|
2661
2665
|
);
|
|
2662
|
-
Me(
|
|
2666
|
+
Me(i.access_token, i.refresh_token), e.accessToken = i.access_token;
|
|
2663
2667
|
return;
|
|
2664
2668
|
} catch {
|
|
2665
2669
|
be("webPayRefreshToken");
|
|
@@ -2668,7 +2672,7 @@ async function qt(e) {
|
|
|
2668
2672
|
e.config.onError({ attributes: { message: e.t("errorMissingTrackClient") } });
|
|
2669
2673
|
return;
|
|
2670
2674
|
}
|
|
2671
|
-
const o = await
|
|
2675
|
+
const o = await Mt(
|
|
2672
2676
|
e.apiUrl,
|
|
2673
2677
|
e.config.clientId,
|
|
2674
2678
|
e.config.trackId
|
|
@@ -2692,7 +2696,7 @@ const jt = `<svg width="17" height="16" viewBox="0 0 17 16" fill="none" xmlns="h
|
|
|
2692
2696
|
</clipPath>
|
|
2693
2697
|
</defs>
|
|
2694
2698
|
</svg>
|
|
2695
|
-
`,
|
|
2699
|
+
`, Wt = `<svg width="52" height="21" viewBox="0 0 52 21" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2696
2700
|
<g clip-path="url(#clip0_23934_4296)">
|
|
2697
2701
|
<path d="M24.5944 10.0883V16.1414H22.6741V1.19278H27.7671C28.375 1.18008 28.9794 1.2879 29.5455 1.51002C30.1115 1.73213 30.628 2.06415 31.065 2.4869C31.5065 2.88399 31.8578 3.37098 32.0954 3.91513C32.3331 4.45929 32.4514 5.048 32.4426 5.64171C32.4553 6.23859 32.3387 6.83115 32.1009 7.37877C31.8631 7.92639 31.5098 8.41612 31.065 8.8144C30.1744 9.66364 29.0751 10.0879 27.7671 10.0871H24.5944V10.0883ZM24.5944 3.03318V8.25143H27.8148C28.1678 8.26189 28.5192 8.19856 28.8464 8.06547C29.1735 7.93238 29.4693 7.73247 29.7148 7.47853C29.959 7.2411 30.1532 6.95711 30.2857 6.64336C30.4183 6.3296 30.4866 5.99245 30.4866 5.65184C30.4866 5.31124 30.4183 4.97409 30.2857 4.66033C30.1532 4.34658 29.959 4.06259 29.7148 3.82516C29.4724 3.56587 29.1776 3.36106 28.8501 3.22432C28.5225 3.08757 28.1696 3.02201 27.8148 3.03199H24.5944V3.03318Z" fill="black"/>
|
|
2698
2702
|
<path d="M36.8677 5.57959C38.2871 5.57959 39.4075 5.95888 40.2289 6.71747C41.0503 7.47605 41.4606 8.51612 41.4598 9.83768V16.1413H39.623V14.722H39.5395C38.7443 15.8909 37.6868 16.4753 36.3668 16.4753C35.24 16.4753 34.2974 16.1413 33.5388 15.4734C33.1747 15.1668 32.8837 14.7829 32.6868 14.3496C32.49 13.9163 32.3923 13.4445 32.4009 12.9686C32.4009 11.9103 32.8009 11.0686 33.6008 10.4436C34.4007 9.8186 35.4686 9.5053 36.8045 9.50371C37.9448 9.50371 38.8839 9.71244 39.6218 10.1299V9.69097C39.624 9.36657 39.5539 9.04574 39.4167 8.75177C39.2795 8.45779 39.0786 8.19803 38.8286 7.99132C38.3208 7.53316 37.659 7.28317 36.9751 7.29118C35.9024 7.29118 35.0536 7.74362 34.4286 8.64852L32.7373 7.5834C33.6676 6.24753 35.0444 5.57959 36.8677 5.57959ZM34.3833 13.0104C34.382 13.2548 34.4391 13.4959 34.5499 13.7138C34.6607 13.9316 34.8219 14.1198 35.0202 14.2628C35.4449 14.5968 35.972 14.7738 36.5123 14.7637C37.3226 14.7624 38.0994 14.4398 38.6724 13.8668C39.3085 13.268 39.6266 12.5655 39.6266 11.7592C39.0278 11.2821 38.1929 11.0435 37.1218 11.0435C36.3417 11.0435 35.6913 11.2316 35.1705 11.6077C34.6445 11.9894 34.3833 12.4534 34.3833 13.0104Z" fill="black"/>
|
|
@@ -2708,7 +2712,7 @@ const jt = `<svg width="17" height="16" viewBox="0 0 17 16" fill="none" xmlns="h
|
|
|
2708
2712
|
</clipPath>
|
|
2709
2713
|
</defs>
|
|
2710
2714
|
</svg>
|
|
2711
|
-
`,
|
|
2715
|
+
`, Vt = `<svg width="25" height="12" viewBox="0 0 25 12" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2712
2716
|
<rect width="25" height="11.5385" rx="2.88462" fill="#00579F"/>
|
|
2713
2717
|
<g clip-path="url(#clip0_22788_48747)">
|
|
2714
2718
|
<path d="M9.84078 8.57012H8.36084L9.2865 2.98535H10.7664L9.84078 8.57012Z" fill="white"/>
|
|
@@ -2736,38 +2740,38 @@ const jt = `<svg width="17" height="16" viewBox="0 0 17 16" fill="none" xmlns="h
|
|
|
2736
2740
|
kaspi_pay: jt,
|
|
2737
2741
|
new_card: zt,
|
|
2738
2742
|
apple_pay: Kt,
|
|
2739
|
-
google_pay:
|
|
2740
|
-
visa:
|
|
2743
|
+
google_pay: Wt,
|
|
2744
|
+
visa: Vt,
|
|
2741
2745
|
mastercard: Yt
|
|
2742
2746
|
};
|
|
2743
2747
|
function Zt(e) {
|
|
2744
|
-
const
|
|
2745
|
-
return
|
|
2748
|
+
const t = e == null ? void 0 : e.toLowerCase();
|
|
2749
|
+
return t && Gt[t] || "";
|
|
2746
2750
|
}
|
|
2747
|
-
const
|
|
2751
|
+
const ct = `<svg width="22" height="22" viewBox="0 0 22 22" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2748
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"/>
|
|
2749
2753
|
</svg>
|
|
2750
2754
|
`, $t = '<svg class="choco-widget-method-item-trash" width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M4.16663 5.83317H15.8333" stroke="#CC3434" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/><path d="M15 5.8335V15.0002C15 15.921 14.2542 16.6668 13.3333 16.6668H6.66667C5.74583 16.6668 5 15.921 5 15.0002V5.8335" stroke="#CC3434" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/><path d="M12.5 3.12516H7.5" stroke="#CC3434" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/><path d="M8.33329 9.1665V13.3332" stroke="#CC3434" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/><path d="M11.6667 9.1665V13.3332" stroke="#CC3434" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>', en = '<svg class="choco-widget-method-item-check" width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M13.3333 4.3335L5.99996 11.6668L2.66663 8.3335" stroke="#242424" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>';
|
|
2751
2755
|
function Ee(e) {
|
|
2752
2756
|
return Zt(e == null ? void 0 : e.iconType);
|
|
2753
2757
|
}
|
|
2754
|
-
function
|
|
2755
|
-
const { editMode:
|
|
2756
|
-
return (
|
|
2757
|
-
const d = !
|
|
2758
|
-
return
|
|
2758
|
+
function At(e, t, o, i = {}) {
|
|
2759
|
+
const { editMode: s = !1 } = i;
|
|
2760
|
+
return (s ? e.filter((a) => a.type === "card") : e).map((a) => {
|
|
2761
|
+
const d = !s && !!t && t.type === a.type && t.cardId === a.cardId, g = JSON.stringify(a).replace(/'/g, "'");
|
|
2762
|
+
return s ? `
|
|
2759
2763
|
<div
|
|
2760
2764
|
class="choco-widget-method-item choco-widget-method-item--edit"
|
|
2761
2765
|
role="listitem"
|
|
2762
2766
|
>
|
|
2763
|
-
<div class="choco-widget-method-item-icon-wrapper" aria-hidden="true">${Ee(
|
|
2764
|
-
<div class="choco-widget-method-item-label">${
|
|
2767
|
+
<div class="choco-widget-method-item-icon-wrapper" aria-hidden="true">${Ee(a)}</div>
|
|
2768
|
+
<div class="choco-widget-method-item-label">${a.label}</div>
|
|
2765
2769
|
<button
|
|
2766
2770
|
type="button"
|
|
2767
2771
|
class="choco-widget-method-item-trash-btn"
|
|
2768
2772
|
data-action="delete-card"
|
|
2769
2773
|
data-method='${g}'
|
|
2770
|
-
aria-label="${
|
|
2774
|
+
aria-label="${a.label} — Удалить"
|
|
2771
2775
|
>
|
|
2772
2776
|
${$t}
|
|
2773
2777
|
</button>
|
|
@@ -2778,19 +2782,19 @@ function ct(e, n, o, s = {}) {
|
|
|
2778
2782
|
data-method='${g}'
|
|
2779
2783
|
data-action="select-method"
|
|
2780
2784
|
role="listitem"
|
|
2781
|
-
aria-label="${
|
|
2785
|
+
aria-label="${a.label}${d ? " (выбрано)" : ""}"
|
|
2782
2786
|
type="button"
|
|
2783
2787
|
>
|
|
2784
|
-
<div class="choco-widget-method-item-icon-wrapper ${
|
|
2785
|
-
<div class="choco-widget-method-item-label">${
|
|
2788
|
+
<div class="choco-widget-method-item-icon-wrapper ${a.type}" aria-hidden="true">${Ee(a)}</div>
|
|
2789
|
+
<div class="choco-widget-method-item-label">${a.label}</div>
|
|
2786
2790
|
${d ? en : ""}
|
|
2787
2791
|
</button>
|
|
2788
2792
|
`;
|
|
2789
2793
|
}).join("");
|
|
2790
2794
|
}
|
|
2791
|
-
function tn(e,
|
|
2795
|
+
function tn(e, t, o, i) {
|
|
2792
2796
|
if (!e) return "";
|
|
2793
|
-
const
|
|
2797
|
+
const s = typeof e.amount == "number" && Number.isFinite(e.amount), u = typeof e.percent == "number" && Number.isFinite(e.percent);
|
|
2794
2798
|
return `
|
|
2795
2799
|
<div class="choco-widget-balance-toggle" data-action="toggle-bonuses">
|
|
2796
2800
|
<div class="choco-widget-balance-info">
|
|
@@ -2801,50 +2805,50 @@ function tn(e, n, o, s) {
|
|
|
2801
2805
|
</div>
|
|
2802
2806
|
<div class="choco-widget-balance-label-wrapper">
|
|
2803
2807
|
<div class="choco-widget-balance-icon">
|
|
2804
|
-
${
|
|
2808
|
+
${ct}
|
|
2805
2809
|
</div>
|
|
2806
|
-
<div class="choco-widget-balance-amount">${
|
|
2810
|
+
<div class="choco-widget-balance-amount">${s ? G(e.amount, "ru", i) : 0}</div>
|
|
2807
2811
|
<label class="choco-widget-toggle">
|
|
2808
|
-
<input type="checkbox" ${
|
|
2812
|
+
<input type="checkbox" ${t ? "checked" : ""} />
|
|
2809
2813
|
<span class="choco-widget-toggle-slider"></span>
|
|
2810
2814
|
</label>
|
|
2811
2815
|
</div>
|
|
2812
2816
|
</div>
|
|
2813
2817
|
`;
|
|
2814
2818
|
}
|
|
2815
|
-
function nn(e,
|
|
2819
|
+
function nn(e, t, o, i, s, u) {
|
|
2816
2820
|
return !e && !o ? "" : `
|
|
2817
2821
|
<div class="choco-widget-balance-section">
|
|
2818
2822
|
${e ? `
|
|
2819
2823
|
<div class="choco-widget-balance-toggle" data-action="toggle-balance">
|
|
2820
2824
|
<div class="choco-widget-balance-info">
|
|
2821
2825
|
<div class="choco-widget-balance-text">
|
|
2822
|
-
<div class="choco-widget-balance-label">${
|
|
2826
|
+
<div class="choco-widget-balance-label">${s("balance")}</div>
|
|
2823
2827
|
</div>
|
|
2824
2828
|
</div>
|
|
2825
2829
|
<div class="choco-widget-balance-label-wrapper">
|
|
2826
2830
|
<div class="choco-widget-balance-icon">
|
|
2827
|
-
${
|
|
2831
|
+
${ct}
|
|
2828
2832
|
</div>
|
|
2829
2833
|
<div class="choco-widget-balance-amount">${e}</div>
|
|
2830
2834
|
<label class="choco-widget-toggle">
|
|
2831
|
-
<input type="checkbox" ${
|
|
2835
|
+
<input type="checkbox" ${t ? "checked" : ""} />
|
|
2832
2836
|
<span class="choco-widget-toggle-slider"></span>
|
|
2833
2837
|
</label>
|
|
2834
2838
|
</div>
|
|
2835
2839
|
</div>
|
|
2836
2840
|
` : ""}
|
|
2837
|
-
${tn(o,
|
|
2841
|
+
${tn(o, i, s, u)}
|
|
2838
2842
|
</div>
|
|
2839
2843
|
`;
|
|
2840
2844
|
}
|
|
2841
|
-
function rn(e,
|
|
2845
|
+
function rn(e, t) {
|
|
2842
2846
|
return e ? `
|
|
2843
2847
|
<div class="choco-widget-cashback-section">
|
|
2844
2848
|
<div class="choco-widget-cashback-info">
|
|
2845
2849
|
<span class="choco-widget-cashback-icon">🎁</span>
|
|
2846
2850
|
<span class="choco-widget-cashback-text">
|
|
2847
|
-
${
|
|
2851
|
+
${t("willGet")} <strong>${e}</strong> ${t("cashback").toLowerCase()}
|
|
2848
2852
|
</span>
|
|
2849
2853
|
</div>
|
|
2850
2854
|
</div>
|
|
@@ -2852,40 +2856,40 @@ function rn(e, n) {
|
|
|
2852
2856
|
}
|
|
2853
2857
|
function on(e) {
|
|
2854
2858
|
const {
|
|
2855
|
-
amountFormatted:
|
|
2859
|
+
amountFormatted: t,
|
|
2856
2860
|
originalAmountFormatted: o,
|
|
2857
|
-
showOriginalAmount:
|
|
2858
|
-
paymentMethod:
|
|
2861
|
+
showOriginalAmount: i = !1,
|
|
2862
|
+
paymentMethod: s,
|
|
2859
2863
|
methods: u,
|
|
2860
|
-
selectedMethod:
|
|
2864
|
+
selectedMethod: a,
|
|
2861
2865
|
balanceFormatted: d,
|
|
2862
2866
|
useBalance: g,
|
|
2863
2867
|
bonuses: C,
|
|
2864
2868
|
useBonuses: S,
|
|
2865
2869
|
cashbackFormatted: T,
|
|
2866
|
-
disabled:
|
|
2870
|
+
disabled: E,
|
|
2867
2871
|
paymentMethodDisabled: Q = !1,
|
|
2868
2872
|
loading: _,
|
|
2869
2873
|
t: m,
|
|
2870
2874
|
currency: P
|
|
2871
|
-
} = e, k = (
|
|
2875
|
+
} = e, k = (s == null ? void 0 : s.label) ?? m("selectMethod"), w = Ee(s), L = At(u, a), O = nn(d, g, C, S, m, P), F = rn(T, m), M = (a == null ? void 0 : a.type) === "google_pay", J = (a == null ? void 0 : a.type) === "apple_pay", x = M || J;
|
|
2872
2876
|
return `
|
|
2873
2877
|
<div class="choco-widget-bottom-bar" role="region" aria-label="${m("paymentMethod")}">
|
|
2874
2878
|
${O}
|
|
2875
2879
|
<div class="choco-widget-payment-info">
|
|
2876
2880
|
<div class="choco-widget-payment-info-main">
|
|
2877
2881
|
<button
|
|
2878
|
-
class="choco-widget-payment-method ${(
|
|
2882
|
+
class="choco-widget-payment-method ${(s == null ? void 0 : s.type) || ""}"
|
|
2879
2883
|
data-action="change-method"
|
|
2880
2884
|
aria-label="${m("paymentMethod")}: ${k}"
|
|
2881
2885
|
type="button"
|
|
2882
|
-
${Q ||
|
|
2886
|
+
${Q || E || _ ? "disabled" : ""}
|
|
2883
2887
|
>
|
|
2884
2888
|
<div class="choco-widget-method-label">${m("paymentMethod")}</div>
|
|
2885
2889
|
<div class="choco-widget-method-value">
|
|
2886
|
-
<div class="choco-widget-method-icon-wrapper ${
|
|
2890
|
+
<div class="choco-widget-method-icon-wrapper ${s == null ? void 0 : s.type}" aria-hidden="true">${w}</div>
|
|
2887
2891
|
<div class="choco-widget-method-details">
|
|
2888
|
-
<div class="choco-widget-method-name ${
|
|
2892
|
+
<div class="choco-widget-method-name ${s == null ? void 0 : s.type}">${k}</div>
|
|
2889
2893
|
<div class="choco-widget-method-chevron">
|
|
2890
2894
|
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2891
2895
|
<path d="M8 10L12 14L16 10" stroke="#242424" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
@@ -2895,17 +2899,17 @@ function on(e) {
|
|
|
2895
2899
|
</div>
|
|
2896
2900
|
</button>
|
|
2897
2901
|
<div class="choco-widget-google-pay-amount ${x ? "" : "choco-widget-google-pay-amount--hidden"}" aria-live="polite">
|
|
2898
|
-
<div class="choco-widget-google-pay-amount-label">${m("total")} ${
|
|
2899
|
-
${
|
|
2902
|
+
<div class="choco-widget-google-pay-amount-label">${m("total")} ${t}</div>
|
|
2903
|
+
${i ? `<div class="choco-widget-google-pay-amount-value">${m("instead")} <span class="choco-widget-google-pay-amount-value-number">${o || ""}</span></div>` : ""}
|
|
2900
2904
|
</div>
|
|
2901
2905
|
<button
|
|
2902
2906
|
class="choco-widget-pay-button ${_ ? "choco-widget-pay-button--loading" : ""} ${x ? "choco-widget-pay-button--hidden" : ""}"
|
|
2903
2907
|
data-action="pay"
|
|
2904
|
-
aria-label="${m("pay")} ${
|
|
2908
|
+
aria-label="${m("pay")} ${t}"
|
|
2905
2909
|
type="button"
|
|
2906
|
-
${
|
|
2910
|
+
${E || _ ? "disabled" : ""}
|
|
2907
2911
|
>
|
|
2908
|
-
${m("pay")} ${
|
|
2912
|
+
${m("pay")} ${t}
|
|
2909
2913
|
</button>
|
|
2910
2914
|
</div>
|
|
2911
2915
|
<div class="choco-widget-google-pay-row ${M ? "" : "choco-widget-google-pay-row--hidden"}">
|
|
@@ -2994,35 +2998,35 @@ function sn() {
|
|
|
2994
2998
|
</div>
|
|
2995
2999
|
`;
|
|
2996
3000
|
}
|
|
2997
|
-
function an(e,
|
|
2998
|
-
return
|
|
3001
|
+
function an(e, t, o, i = {}) {
|
|
3002
|
+
return At(e, t, o, i);
|
|
2999
3003
|
}
|
|
3000
3004
|
function cn(e) {
|
|
3001
3005
|
return Ee(e);
|
|
3002
3006
|
}
|
|
3003
3007
|
function An(e) {
|
|
3004
3008
|
if (typeof document > "u") return { mountTarget: null, isEmbedded: !1 };
|
|
3005
|
-
const
|
|
3006
|
-
if (
|
|
3007
|
-
const o = document.querySelector(
|
|
3009
|
+
const t = e.config.containerSelector;
|
|
3010
|
+
if (t) {
|
|
3011
|
+
const o = document.querySelector(t);
|
|
3008
3012
|
if (o instanceof HTMLElement) return { mountTarget: o, isEmbedded: !0 };
|
|
3009
3013
|
}
|
|
3010
3014
|
return { mountTarget: document.body, isEmbedded: !1 };
|
|
3011
3015
|
}
|
|
3012
|
-
function
|
|
3016
|
+
function ut(e) {
|
|
3013
3017
|
if (typeof document > "u") return !1;
|
|
3014
3018
|
e.container || (e.container = document.createElement("div"), e.container.id = "choco-one-click-widget", e.container.className = "choco-one-click-widget");
|
|
3015
|
-
const { mountTarget:
|
|
3016
|
-
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;
|
|
3017
3021
|
}
|
|
3018
3022
|
function un(e) {
|
|
3019
|
-
|
|
3023
|
+
ut(e) && (e.container.style.setProperty("--choco-widget-accent-color", e.config.color), e.container.innerHTML = sn());
|
|
3020
3024
|
}
|
|
3021
3025
|
function ln(e) {
|
|
3022
|
-
var S, T,
|
|
3023
|
-
if (!
|
|
3026
|
+
var S, T, E, Q, _;
|
|
3027
|
+
if (!ut(e)) return;
|
|
3024
3028
|
e.container.style.setProperty("--choco-widget-accent-color", e.config.color), e.container.classList.remove("choco-one-click-widget--visible");
|
|
3025
|
-
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;
|
|
3026
3030
|
e.container.innerHTML = on({
|
|
3027
3031
|
amountFormatted: G(g, e.config.locale, e.config.currency),
|
|
3028
3032
|
originalAmountFormatted: G(
|
|
@@ -3032,7 +3036,7 @@ function ln(e) {
|
|
|
3032
3036
|
),
|
|
3033
3037
|
showOriginalAmount: C,
|
|
3034
3038
|
paymentMethod: e.selectedPaymentMethod,
|
|
3035
|
-
methods:
|
|
3039
|
+
methods: t,
|
|
3036
3040
|
selectedMethod: e.selectedPaymentMethod,
|
|
3037
3041
|
balanceFormatted: u,
|
|
3038
3042
|
useBalance: e.useBalance,
|
|
@@ -3043,7 +3047,7 @@ function ln(e) {
|
|
|
3043
3047
|
paymentMethodDisabled: e.paymentMethodDisabled,
|
|
3044
3048
|
loading: e.loading,
|
|
3045
3049
|
t: (m, P) => e.t(m, P),
|
|
3046
|
-
currency:
|
|
3050
|
+
currency: i
|
|
3047
3051
|
}), e._attachEventListeners(), e.isOpen = !0, e._emitUserEvent("one_click_pay_cta_rendered", {
|
|
3048
3052
|
terminal_id: e.config.terminalId,
|
|
3049
3053
|
project_id: e.config.clientId
|
|
@@ -3056,74 +3060,74 @@ function ln(e) {
|
|
|
3056
3060
|
});
|
|
3057
3061
|
});
|
|
3058
3062
|
}
|
|
3059
|
-
function
|
|
3060
|
-
var
|
|
3061
|
-
const
|
|
3063
|
+
function Ae(e) {
|
|
3064
|
+
var i;
|
|
3065
|
+
const t = (i = e.container) == null ? void 0 : i.querySelector(
|
|
3062
3066
|
".choco-widget-payment-methods"
|
|
3063
3067
|
);
|
|
3064
|
-
if (!
|
|
3068
|
+
if (!t) return;
|
|
3065
3069
|
const o = e.getAvailablePaymentMethods();
|
|
3066
|
-
|
|
3070
|
+
t.innerHTML = an(
|
|
3067
3071
|
o,
|
|
3068
3072
|
e.selectedPaymentMethod,
|
|
3069
|
-
(
|
|
3073
|
+
(s) => e.t(s),
|
|
3070
3074
|
{ editMode: e.isPaymentSheetEditMode }
|
|
3071
|
-
),
|
|
3072
|
-
|
|
3075
|
+
), t.querySelectorAll("[data-action='delete-card']").forEach((s) => {
|
|
3076
|
+
s.addEventListener("click", (u) => {
|
|
3073
3077
|
u.stopPropagation();
|
|
3074
|
-
const
|
|
3075
|
-
pn(e,
|
|
3078
|
+
const a = JSON.parse(s.getAttribute("data-method") || "{}");
|
|
3079
|
+
pn(e, a);
|
|
3076
3080
|
});
|
|
3077
|
-
}),
|
|
3078
|
-
|
|
3079
|
-
const
|
|
3081
|
+
}), t.querySelectorAll("[data-action='select-method']").forEach((s) => {
|
|
3082
|
+
s.addEventListener("click", (u) => {
|
|
3083
|
+
const a = JSON.parse(
|
|
3080
3084
|
u.currentTarget.getAttribute("data-method") || "{}"
|
|
3081
3085
|
);
|
|
3082
|
-
|
|
3086
|
+
ft(e, a);
|
|
3083
3087
|
});
|
|
3084
3088
|
});
|
|
3085
3089
|
}
|
|
3086
|
-
function
|
|
3087
|
-
var
|
|
3088
|
-
const
|
|
3090
|
+
function lt(e) {
|
|
3091
|
+
var s, u, a;
|
|
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(
|
|
3089
3093
|
".choco-widget-method-icon-wrapper"
|
|
3090
3094
|
);
|
|
3091
|
-
|
|
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);
|
|
3092
3096
|
}
|
|
3093
3097
|
function pe(e) {
|
|
3094
|
-
var S, T,
|
|
3095
|
-
const
|
|
3098
|
+
var S, T, E, Q, _;
|
|
3099
|
+
const t = (S = e.container) == null ? void 0 : S.querySelector(".choco-widget-pay-button"), o = (T = e.container) == null ? void 0 : T.querySelector(
|
|
3096
3100
|
".choco-widget-google-pay-amount"
|
|
3097
|
-
),
|
|
3101
|
+
), i = (E = e.container) == null ? void 0 : E.querySelector(
|
|
3098
3102
|
".choco-widget-google-pay-amount-label"
|
|
3099
3103
|
);
|
|
3100
|
-
let
|
|
3104
|
+
let s = (Q = e.container) == null ? void 0 : Q.querySelector(
|
|
3101
3105
|
".choco-widget-google-pay-amount-value"
|
|
3102
3106
|
), u = (_ = e.container) == null ? void 0 : _.querySelector(
|
|
3103
3107
|
".choco-widget-google-pay-amount-value-number"
|
|
3104
3108
|
);
|
|
3105
|
-
const
|
|
3109
|
+
const a = e._getPayableAmount(), d = G(a, e.config.locale, e.config.currency), g = a < e.config.amount, C = G(
|
|
3106
3110
|
e.config.amount,
|
|
3107
3111
|
e.config.locale,
|
|
3108
3112
|
e.config.currency
|
|
3109
3113
|
);
|
|
3110
|
-
if (
|
|
3111
|
-
|
|
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) {
|
|
3115
|
+
s == null || s.remove();
|
|
3112
3116
|
return;
|
|
3113
3117
|
}
|
|
3114
|
-
!
|
|
3118
|
+
!s && o && (s = document.createElement("div"), s.className = "choco-widget-google-pay-amount-value", s.innerHTML = `${e.t("instead")} <span class="choco-widget-google-pay-amount-value-number"></span>`, o.appendChild(s), u = s.querySelector(
|
|
3115
3119
|
".choco-widget-google-pay-amount-value-number"
|
|
3116
|
-
)), u ? u.textContent = C :
|
|
3120
|
+
)), u ? u.textContent = C : s && (s.textContent = `${e.t("instead")} ${C}`);
|
|
3117
3121
|
}
|
|
3118
|
-
function
|
|
3119
|
-
var g, C, S, T,
|
|
3120
|
-
const
|
|
3122
|
+
function dt(e) {
|
|
3123
|
+
var g, C, S, T, E, Q, _, m, P, k;
|
|
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(
|
|
3121
3125
|
".choco-widget-google-pay-amount"
|
|
3122
|
-
),
|
|
3123
|
-
if (
|
|
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");
|
|
3127
|
+
if (s == null || s.classList.toggle("choco-widget-pay-button--hidden", i), u == null || u.classList.toggle(
|
|
3124
3128
|
"choco-widget-google-pay-amount--hidden",
|
|
3125
|
-
!
|
|
3126
|
-
),
|
|
3129
|
+
!i
|
|
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) {
|
|
3127
3131
|
dn(e);
|
|
3128
3132
|
const w = (_ = e.container) == null ? void 0 : _.querySelector(
|
|
3129
3133
|
'[data-action="apple-pay-button-slot"]'
|
|
@@ -3147,11 +3151,11 @@ function lt(e) {
|
|
|
3147
3151
|
pe(e), ee(e);
|
|
3148
3152
|
}
|
|
3149
3153
|
async function dn(e) {
|
|
3150
|
-
var
|
|
3151
|
-
const
|
|
3154
|
+
var a, d, g, C, S;
|
|
3155
|
+
const t = (a = e.container) == null ? void 0 : a.querySelector(
|
|
3152
3156
|
'[data-action="google-pay-button-slot"]'
|
|
3153
3157
|
);
|
|
3154
|
-
if (!
|
|
3158
|
+
if (!t || (t.innerHTML = "", ((d = e.selectedPaymentMethod) == null ? void 0 : d.type) !== "google_pay")) return;
|
|
3155
3159
|
const o = ++e._googlePayButtonRenderVersion;
|
|
3156
3160
|
try {
|
|
3157
3161
|
await e._loadGooglePaySdk();
|
|
@@ -3164,8 +3168,8 @@ async function dn(e) {
|
|
|
3164
3168
|
e.config.onError({ attributes: { message: e.t("errorGooglePayUnsupported") } });
|
|
3165
3169
|
return;
|
|
3166
3170
|
}
|
|
3167
|
-
const
|
|
3168
|
-
environment:
|
|
3171
|
+
const i = e.config.environment === "production", u = new window.google.payments.api.PaymentsClient({
|
|
3172
|
+
environment: i ? "PRODUCTION" : "TEST"
|
|
3169
3173
|
}).createButton({
|
|
3170
3174
|
onClick: () => e.handlePayment(),
|
|
3171
3175
|
buttonType: "pay",
|
|
@@ -3175,20 +3179,20 @@ async function dn(e) {
|
|
|
3175
3179
|
});
|
|
3176
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) => {
|
|
3177
3181
|
T.style.setProperty("border-radius", "12px", "important"), T.style.setProperty("font-weight", "bold", "important"), T.style.setProperty("font-size", "16px", "important");
|
|
3178
|
-
}),
|
|
3182
|
+
}), t.appendChild(u), ee(e);
|
|
3179
3183
|
}
|
|
3180
3184
|
function hn(e) {
|
|
3181
|
-
var u,
|
|
3182
|
-
const
|
|
3185
|
+
var u, a;
|
|
3186
|
+
const t = (u = e.container) == null ? void 0 : u.querySelector(
|
|
3183
3187
|
'[data-action="apple-pay-button-slot"]'
|
|
3184
3188
|
);
|
|
3185
|
-
if (!
|
|
3189
|
+
if (!t || (t.innerHTML = "", ((a = e.selectedPaymentMethod) == null ? void 0 : a.type) !== "apple_pay")) return;
|
|
3186
3190
|
const o = document.createElement("div");
|
|
3187
3191
|
o.className = "choco-widget-apple-pay-button-wrapper";
|
|
3188
|
-
const
|
|
3189
|
-
|
|
3190
|
-
const
|
|
3191
|
-
|
|
3192
|
+
const i = document.createElement("button");
|
|
3193
|
+
i.type = "button", i.className = "choco-widget-apple-pay-button choco-widget-apple-pay-button--native", i.setAttribute("aria-label", "Оплатить с Apple Pay"), i.style.setProperty("width", "100%", "important"), i.style.setProperty("height", "52px", "important"), i.style.setProperty("min-height", "52px", "important"), i.style.setProperty("border-radius", "12px", "important"), i.style.setProperty("-webkit-appearance", "-apple-pay-button"), i.style.setProperty("-apple-pay-button-type", "buy"), i.style.setProperty("-apple-pay-button-style", "black"), i.addEventListener("click", () => e.handlePayment());
|
|
3194
|
+
const s = document.createElement("div");
|
|
3195
|
+
s.className = "choco-widget-apple-pay-button-overlay", s.setAttribute("aria-hidden", "true"), s.innerHTML = `
|
|
3192
3196
|
<span class="choco-widget-apple-pay-button-text">Оплатить с</span>
|
|
3193
3197
|
<span class="choco-widget-apple-pay-button-icon">
|
|
3194
3198
|
<svg width="52" height="24" viewBox="0 0 52 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
@@ -3202,154 +3206,154 @@ function hn(e) {
|
|
|
3202
3206
|
</defs>
|
|
3203
3207
|
</svg>
|
|
3204
3208
|
</span>
|
|
3205
|
-
`, o.appendChild(
|
|
3209
|
+
`, o.appendChild(i), o.appendChild(s), t.appendChild(o), ee(e);
|
|
3206
3210
|
}
|
|
3207
|
-
function
|
|
3211
|
+
function te(e) {
|
|
3208
3212
|
e.loading = !0, ee(e);
|
|
3209
3213
|
}
|
|
3210
3214
|
function j(e) {
|
|
3211
|
-
var T,
|
|
3215
|
+
var T, E, Q, _, m, P, k, w;
|
|
3212
3216
|
e.loading = !1;
|
|
3213
|
-
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(
|
|
3214
3218
|
".choco-widget-google-pay-button-slot button"
|
|
3215
|
-
),
|
|
3219
|
+
), s = (_ = e.container) == null ? void 0 : _.querySelector(
|
|
3216
3220
|
".choco-widget-apple-pay-button-slot button"
|
|
3217
3221
|
), u = (m = e.container) == null ? void 0 : m.querySelector(
|
|
3218
3222
|
".choco-widget-google-pay-amount"
|
|
3219
|
-
),
|
|
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(
|
|
3220
3224
|
".choco-widget-balance-section"
|
|
3221
3225
|
), C = e._isInteractionBlocked(), S = e.paymentMethodDisabled || C;
|
|
3222
|
-
|
|
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");
|
|
3223
3227
|
}
|
|
3224
3228
|
function ee(e) {
|
|
3225
|
-
var T,
|
|
3226
|
-
const
|
|
3229
|
+
var T, E, Q, _, m, P, k, w;
|
|
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(
|
|
3227
3231
|
".choco-widget-google-pay-button-slot button"
|
|
3228
|
-
),
|
|
3232
|
+
), s = (_ = e.container) == null ? void 0 : _.querySelector(
|
|
3229
3233
|
".choco-widget-apple-pay-button-slot button"
|
|
3230
3234
|
), u = (m = e.container) == null ? void 0 : m.querySelector(
|
|
3231
3235
|
".choco-widget-google-pay-amount"
|
|
3232
|
-
),
|
|
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(
|
|
3233
3237
|
".choco-widget-balance-section"
|
|
3234
3238
|
), C = e._isInteractionBlocked(), S = e.paymentMethodDisabled || C;
|
|
3235
|
-
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));
|
|
3236
3240
|
}
|
|
3237
|
-
function
|
|
3241
|
+
function ht(e) {
|
|
3238
3242
|
var o;
|
|
3239
3243
|
if (e._isInteractionBlocked()) return;
|
|
3240
|
-
const
|
|
3241
|
-
|
|
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));
|
|
3242
3246
|
}
|
|
3243
|
-
function
|
|
3247
|
+
function V(e) {
|
|
3244
3248
|
var o;
|
|
3245
|
-
const
|
|
3246
|
-
if (
|
|
3249
|
+
const t = (o = e.container) == null ? void 0 : o.querySelector('[data-sheet="payment"]');
|
|
3250
|
+
if (t) {
|
|
3247
3251
|
ve(e);
|
|
3248
|
-
const
|
|
3249
|
-
|
|
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));
|
|
3250
3254
|
}
|
|
3251
3255
|
}
|
|
3252
|
-
function
|
|
3256
|
+
function ue(e) {
|
|
3253
3257
|
var g;
|
|
3254
|
-
const
|
|
3255
|
-
if (!
|
|
3256
|
-
const o =
|
|
3257
|
-
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"));
|
|
3258
3262
|
}
|
|
3259
3263
|
function $e(e) {
|
|
3260
3264
|
if (!e.addCardActionUrl || !e.container) return;
|
|
3261
|
-
const
|
|
3265
|
+
const t = e.container.querySelector('[data-sheet="add-card"]'), o = e.container.querySelector(
|
|
3262
3266
|
"#choco-widget-add-card-iframe"
|
|
3263
3267
|
);
|
|
3264
|
-
|
|
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));
|
|
3265
3269
|
}
|
|
3266
3270
|
function ae(e) {
|
|
3267
|
-
var
|
|
3268
|
-
const
|
|
3271
|
+
var i, s;
|
|
3272
|
+
const t = (i = e.container) == null ? void 0 : i.querySelector('[data-sheet="add-card"]'), o = (s = e.container) == null ? void 0 : s.querySelector(
|
|
3269
3273
|
"#choco-widget-add-card-iframe"
|
|
3270
3274
|
);
|
|
3271
|
-
|
|
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);
|
|
3272
3276
|
}
|
|
3273
3277
|
function fn(e) {
|
|
3274
|
-
e._boundAddCardMessage = (
|
|
3278
|
+
e._boundAddCardMessage = (t) => {
|
|
3275
3279
|
var o;
|
|
3276
|
-
e.isAddCardViewOpen && (o =
|
|
3280
|
+
e.isAddCardViewOpen && (o = t.data) != null && o.message && t.origin === "https://rahmetapp.kz" && te(e);
|
|
3277
3281
|
}, window.addEventListener("message", e._boundAddCardMessage);
|
|
3278
3282
|
}
|
|
3279
3283
|
function gn(e) {
|
|
3280
3284
|
e._boundAddCardMessage && (window.removeEventListener("message", e._boundAddCardMessage), e._boundAddCardMessage = null);
|
|
3281
3285
|
}
|
|
3282
|
-
function pn(e,
|
|
3283
|
-
var
|
|
3284
|
-
e._pendingDeleteMethod =
|
|
3285
|
-
const o = (
|
|
3286
|
+
function pn(e, t) {
|
|
3287
|
+
var a;
|
|
3288
|
+
e._pendingDeleteMethod = t;
|
|
3289
|
+
const o = (a = e.container) == null ? void 0 : a.querySelector('[data-sheet="payment"]');
|
|
3286
3290
|
if (!o) return;
|
|
3287
3291
|
o.classList.add("choco-widget-payment-sheet--delete-confirm");
|
|
3288
|
-
const
|
|
3289
|
-
|
|
3292
|
+
const i = o.querySelector(".choco-widget-sheet-title"), s = o.querySelector('[data-action="edit-sheet"]'), u = o.querySelector('[data-action="previous-sheet"]');
|
|
3293
|
+
i && (i.textContent = e.t("confirmDeleteCard")), s && (s.style.display = "none"), u && (u.style.display = "none");
|
|
3290
3294
|
}
|
|
3291
3295
|
function ve(e) {
|
|
3292
3296
|
var o;
|
|
3293
3297
|
e._pendingDeleteMethod = null, Ne(e, !1);
|
|
3294
|
-
const
|
|
3295
|
-
|
|
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);
|
|
3296
3300
|
}
|
|
3297
|
-
function Ne(e,
|
|
3298
|
-
var u,
|
|
3301
|
+
function Ne(e, t) {
|
|
3302
|
+
var u, a, d;
|
|
3299
3303
|
const o = (u = e.container) == null ? void 0 : u.querySelector(
|
|
3300
3304
|
".choco-widget-sheet-delete-confirm-actions"
|
|
3301
|
-
),
|
|
3305
|
+
), i = (a = e.container) == null ? void 0 : a.querySelector(
|
|
3302
3306
|
'[data-action="confirm-delete-cancel"]'
|
|
3303
|
-
),
|
|
3307
|
+
), s = (d = e.container) == null ? void 0 : d.querySelector(
|
|
3304
3308
|
'[data-action="confirm-delete-submit"]'
|
|
3305
3309
|
);
|
|
3306
|
-
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));
|
|
3307
3311
|
}
|
|
3308
|
-
async function Cn(e,
|
|
3309
|
-
var
|
|
3310
|
-
const o =
|
|
3311
|
-
if (!(!o || (
|
|
3312
|
+
async function Cn(e, t) {
|
|
3313
|
+
var i, s;
|
|
3314
|
+
const o = t == null ? void 0 : t.cardId;
|
|
3315
|
+
if (!(!o || (t == null ? void 0 : t.type) !== "card"))
|
|
3312
3316
|
try {
|
|
3313
|
-
await
|
|
3317
|
+
await Dt(e.apiUrl, e._getApiConfig(), o), e.checkoutContext = await Oe(
|
|
3314
3318
|
e.apiUrl,
|
|
3315
3319
|
e._getApiConfig()
|
|
3316
|
-
), ((
|
|
3320
|
+
), ((i = e.selectedPaymentMethod) == null ? void 0 : i.type) === "card" && ((s = e.selectedPaymentMethod) == null ? void 0 : s.cardId) === o && (e.selectedPaymentMethod = Le(
|
|
3317
3321
|
e.checkoutContext.data,
|
|
3318
3322
|
e._getKaspiOptions()
|
|
3319
|
-
), e._emitPaymentMethodSelected(),
|
|
3323
|
+
), e._emitPaymentMethodSelected(), lt(e)), Ae(e), e.config.onSuccess({ message: e.t("cardDeleted") }), e.config.onCardDeleted && e.config.onCardDeleted({ cardId: o });
|
|
3320
3324
|
} catch (u) {
|
|
3321
3325
|
e.config.onError({
|
|
3322
3326
|
attributes: { message: (u == null ? void 0 : u.message) || e.t("paymentError") }
|
|
3323
3327
|
});
|
|
3324
3328
|
}
|
|
3325
3329
|
}
|
|
3326
|
-
function
|
|
3330
|
+
function ft(e, t) {
|
|
3327
3331
|
if (!e._isInteractionBlocked()) {
|
|
3328
|
-
if (e.selectedPaymentMethod =
|
|
3329
|
-
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();
|
|
3330
3334
|
return;
|
|
3331
3335
|
}
|
|
3332
3336
|
e._emitUserEvent("one_click_pay_method_resolved", {
|
|
3333
3337
|
payment_method: e._getPaymentMethodForUserEvent()
|
|
3334
|
-
}),
|
|
3338
|
+
}), Ae(e), V(e), lt(e);
|
|
3335
3339
|
}
|
|
3336
3340
|
}
|
|
3337
|
-
function et(e,
|
|
3338
|
-
var
|
|
3339
|
-
const o =
|
|
3341
|
+
function et(e, t) {
|
|
3342
|
+
var i;
|
|
3343
|
+
const o = t.type || ((i = t.data) == null ? void 0 : i.type);
|
|
3340
3344
|
if (!o) {
|
|
3341
|
-
console.warn("Unknown event format:",
|
|
3345
|
+
console.warn("Unknown event format:", t);
|
|
3342
3346
|
return;
|
|
3343
3347
|
}
|
|
3344
3348
|
switch (o) {
|
|
3345
3349
|
case "order.paid":
|
|
3346
|
-
e._orderStatusResolved = !0, $(e),
|
|
3350
|
+
e._orderStatusResolved = !0, $(e), pt(e, t);
|
|
3347
3351
|
break;
|
|
3348
3352
|
case "order.failed":
|
|
3349
|
-
e._orderStatusResolved = !0, $(e),
|
|
3353
|
+
e._orderStatusResolved = !0, $(e), Ct(e, t);
|
|
3350
3354
|
break;
|
|
3351
3355
|
case "order.action_required":
|
|
3352
|
-
yn(e,
|
|
3356
|
+
yn(e, t);
|
|
3353
3357
|
break;
|
|
3354
3358
|
default:
|
|
3355
3359
|
console.warn("Unknown event type:", o);
|
|
@@ -3358,38 +3362,38 @@ function et(e, n) {
|
|
|
3358
3362
|
function $(e) {
|
|
3359
3363
|
e._orderStatusPollingId && (clearInterval(e._orderStatusPollingId), e._orderStatusPollingId = null);
|
|
3360
3364
|
}
|
|
3361
|
-
function
|
|
3365
|
+
function ce(e, t) {
|
|
3362
3366
|
$(e), e._orderStatusResolved = !1;
|
|
3363
|
-
const o = 6e3,
|
|
3364
|
-
let
|
|
3367
|
+
const o = 6e3, i = 5;
|
|
3368
|
+
let s = 0;
|
|
3365
3369
|
const u = async () => {
|
|
3366
3370
|
if (!e._orderStatusResolved) {
|
|
3367
|
-
if (
|
|
3371
|
+
if (s >= i) {
|
|
3368
3372
|
$(e), j(e), e.config.onError({
|
|
3369
3373
|
attributes: { message: e.t("errorNoServerResponseRetry") }
|
|
3370
3374
|
});
|
|
3371
3375
|
return;
|
|
3372
3376
|
}
|
|
3373
|
-
|
|
3377
|
+
s += 1;
|
|
3374
3378
|
try {
|
|
3375
|
-
const { data:
|
|
3379
|
+
const { data: a } = await Ut(
|
|
3376
3380
|
e.apiUrl,
|
|
3377
3381
|
e._getApiConfig(),
|
|
3378
|
-
String(
|
|
3379
|
-
), d =
|
|
3382
|
+
String(t)
|
|
3383
|
+
), d = a == null ? void 0 : a.status, g = (a == null ? void 0 : a.payload) || {};
|
|
3380
3384
|
if (d === "success") {
|
|
3381
|
-
e._orderStatusResolved = !0, $(e),
|
|
3382
|
-
id: String(g.id ||
|
|
3385
|
+
e._orderStatusResolved = !0, $(e), pt(e, {
|
|
3386
|
+
id: String(g.id || t),
|
|
3383
3387
|
attributes: { amount: g.amount, paid_at: g.paid_at || "" }
|
|
3384
3388
|
});
|
|
3385
3389
|
return;
|
|
3386
3390
|
}
|
|
3387
|
-
d === "fail" && (e._orderStatusResolved = !0, $(e),
|
|
3388
|
-
id: String(g.id ||
|
|
3391
|
+
d === "fail" && (e._orderStatusResolved = !0, $(e), Ct(e, {
|
|
3392
|
+
id: String(g.id || t),
|
|
3389
3393
|
attributes: { message: g.message || e.t("paymentError") }
|
|
3390
3394
|
}));
|
|
3391
|
-
} catch (
|
|
3392
|
-
console.warn("[Polling] checkOrderStatus error:",
|
|
3395
|
+
} catch (a) {
|
|
3396
|
+
console.warn("[Polling] checkOrderStatus error:", a);
|
|
3393
3397
|
}
|
|
3394
3398
|
}
|
|
3395
3399
|
};
|
|
@@ -3398,142 +3402,142 @@ function ue(e, n) {
|
|
|
3398
3402
|
function Xe() {
|
|
3399
3403
|
return typeof document > "u" ? !1 : document.hidden || document.visibilityState === "hidden";
|
|
3400
3404
|
}
|
|
3401
|
-
function
|
|
3402
|
-
j(e), e.config.onSuccess(
|
|
3405
|
+
function gt(e, t) {
|
|
3406
|
+
j(e), e.config.onSuccess(t);
|
|
3403
3407
|
}
|
|
3404
3408
|
function Te(e) {
|
|
3405
3409
|
if (!e._pendingSuccessPayload || Xe()) return;
|
|
3406
|
-
const
|
|
3407
|
-
e._pendingSuccessPayload = null,
|
|
3410
|
+
const t = e._pendingSuccessPayload;
|
|
3411
|
+
e._pendingSuccessPayload = null, gt(e, t);
|
|
3408
3412
|
}
|
|
3409
|
-
function
|
|
3410
|
-
var
|
|
3413
|
+
function pt(e, t) {
|
|
3414
|
+
var s, u;
|
|
3411
3415
|
e.isAddCardViewOpen && ae(e);
|
|
3412
|
-
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 };
|
|
3413
3417
|
if (Xe()) {
|
|
3414
|
-
e._pendingSuccessPayload =
|
|
3418
|
+
e._pendingSuccessPayload = i;
|
|
3415
3419
|
return;
|
|
3416
3420
|
}
|
|
3417
|
-
|
|
3421
|
+
gt(e, i);
|
|
3418
3422
|
}
|
|
3419
|
-
function
|
|
3420
|
-
var
|
|
3423
|
+
function Ct(e, t) {
|
|
3424
|
+
var i, s;
|
|
3421
3425
|
e.isAddCardViewOpen && ae(e), j(e);
|
|
3422
|
-
const o =
|
|
3423
|
-
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 });
|
|
3424
3428
|
}
|
|
3425
|
-
function yn(e,
|
|
3426
|
-
var u,
|
|
3427
|
-
const o =
|
|
3428
|
-
if (!
|
|
3429
|
+
function yn(e, t) {
|
|
3430
|
+
var u, a, d;
|
|
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";
|
|
3432
|
+
if (!i) {
|
|
3429
3433
|
console.error(e.t("errorActionUrlMissing")), e.waitingForNewCardAction && (e.waitingForNewCardAction = !1, j(e), e.config.onError({ attributes: { message: e.t("errorNoServerResponse") } }));
|
|
3430
3434
|
return;
|
|
3431
3435
|
}
|
|
3432
|
-
if (e.waitingForNewCardAction && (e.waitingForNewCardAction = !1, e._clearNewCardActionTimeout()),
|
|
3433
|
-
e.addCardActionUrl =
|
|
3436
|
+
if (e.waitingForNewCardAction && (e.waitingForNewCardAction = !1, e._clearNewCardActionTimeout()), s === "inner") {
|
|
3437
|
+
e.addCardActionUrl = i, j(e), e._showAddCardView();
|
|
3434
3438
|
return;
|
|
3435
3439
|
}
|
|
3436
|
-
if (((
|
|
3437
|
-
const g =
|
|
3438
|
-
if (g && !e._orderStatusResolved && !e._orderStatusPollingId &&
|
|
3440
|
+
if (((a = e.selectedPaymentMethod) == null ? void 0 : a.type) === "kaspi_pay") {
|
|
3441
|
+
const g = t.id || ((d = t.data) == null ? void 0 : d.id);
|
|
3442
|
+
if (g && !e._orderStatusResolved && !e._orderStatusPollingId && ce(e, String(g)), typeof e.config.onKaspiLink == "function") {
|
|
3439
3443
|
e.config.onKaspiLink({
|
|
3440
|
-
action_link:
|
|
3441
|
-
action_url:
|
|
3442
|
-
action_type:
|
|
3443
|
-
event:
|
|
3444
|
+
action_link: i,
|
|
3445
|
+
action_url: i,
|
|
3446
|
+
action_type: s,
|
|
3447
|
+
event: t
|
|
3444
3448
|
});
|
|
3445
3449
|
return;
|
|
3446
3450
|
}
|
|
3447
3451
|
}
|
|
3448
|
-
window.location.href =
|
|
3452
|
+
window.location.href = i;
|
|
3449
3453
|
}
|
|
3450
3454
|
async function mn(e) {
|
|
3451
|
-
var o,
|
|
3455
|
+
var o, i, s, u;
|
|
3452
3456
|
if (!e.selectedPaymentMethod) {
|
|
3453
3457
|
e.config.onError({
|
|
3454
3458
|
attributes: { message: e.t("errorPaymentMethodNotSelected") }
|
|
3455
3459
|
});
|
|
3456
3460
|
return;
|
|
3457
3461
|
}
|
|
3458
|
-
const { checkoutOptions:
|
|
3462
|
+
const { checkoutOptions: t } = e._getPaymentBreakdown();
|
|
3459
3463
|
if (e._isBalanceFullyCoveringAmount()) {
|
|
3460
|
-
|
|
3464
|
+
te(e);
|
|
3461
3465
|
try {
|
|
3462
|
-
const
|
|
3466
|
+
const a = await Ge(
|
|
3463
3467
|
e.apiUrl,
|
|
3464
3468
|
e._getApiConfig(),
|
|
3465
3469
|
e.deviceId,
|
|
3466
3470
|
e.selectedPaymentMethod,
|
|
3467
|
-
|
|
3471
|
+
t
|
|
3468
3472
|
);
|
|
3469
3473
|
await tt(e);
|
|
3470
|
-
const d = (
|
|
3471
|
-
return d &&
|
|
3472
|
-
} catch (
|
|
3474
|
+
const d = (a == null ? void 0 : a.id) ?? ((o = a == null ? void 0 : a.data) == null ? void 0 : o.id);
|
|
3475
|
+
return d && ce(e, String(d)), a;
|
|
3476
|
+
} catch (a) {
|
|
3473
3477
|
throw j(e), e.config.onError({
|
|
3474
|
-
attributes: { message: e._resolveErrorMessage(
|
|
3475
|
-
}),
|
|
3478
|
+
attributes: { message: e._resolveErrorMessage(a) }
|
|
3479
|
+
}), a;
|
|
3476
3480
|
}
|
|
3477
3481
|
}
|
|
3478
3482
|
if (e.selectedPaymentMethod.type === "new_card") {
|
|
3479
|
-
await bn(e,
|
|
3483
|
+
await bn(e, t);
|
|
3480
3484
|
return;
|
|
3481
3485
|
}
|
|
3482
3486
|
if (e.selectedPaymentMethod.type === "apple_pay") {
|
|
3483
|
-
await En(e,
|
|
3487
|
+
await En(e, t);
|
|
3484
3488
|
return;
|
|
3485
3489
|
}
|
|
3486
3490
|
if (e.selectedPaymentMethod.type === "google_pay") {
|
|
3487
|
-
await vn(e,
|
|
3491
|
+
await vn(e, t);
|
|
3488
3492
|
return;
|
|
3489
3493
|
}
|
|
3490
|
-
|
|
3494
|
+
te(e);
|
|
3491
3495
|
try {
|
|
3492
|
-
const
|
|
3496
|
+
const a = await Ge(
|
|
3493
3497
|
e.apiUrl,
|
|
3494
3498
|
e._getApiConfig(),
|
|
3495
3499
|
e.deviceId,
|
|
3496
3500
|
e.selectedPaymentMethod,
|
|
3497
|
-
|
|
3501
|
+
t
|
|
3498
3502
|
);
|
|
3499
3503
|
await tt(e);
|
|
3500
|
-
const d = (
|
|
3501
|
-
if (d &&
|
|
3502
|
-
const g = (
|
|
3504
|
+
const d = (a == null ? void 0 : a.id) ?? ((i = a == null ? void 0 : a.data) == null ? void 0 : i.id);
|
|
3505
|
+
if (d && ce(e, String(d)), ((s = e.selectedPaymentMethod) == null ? void 0 : s.type) === "kaspi_pay") {
|
|
3506
|
+
const g = (a == null ? void 0 : a.attributes) || ((u = a == null ? void 0 : a.data) == null ? void 0 : u.attributes) || {}, C = g.action_link || g.action_url, S = g.action_url_type || g.action_type || "redirect";
|
|
3503
3507
|
if (C)
|
|
3504
3508
|
return typeof e.config.onKaspiLink == "function" ? (e.config.onKaspiLink({
|
|
3505
3509
|
action_link: C,
|
|
3506
3510
|
action_url: C,
|
|
3507
3511
|
action_type: S,
|
|
3508
|
-
event:
|
|
3509
|
-
}),
|
|
3512
|
+
event: a
|
|
3513
|
+
}), a) : (window.location.href = C, a);
|
|
3510
3514
|
}
|
|
3511
|
-
return
|
|
3512
|
-
} catch (
|
|
3513
|
-
throw j(e), e.config.onError({ message: e._resolveErrorMessage(
|
|
3515
|
+
return a;
|
|
3516
|
+
} catch (a) {
|
|
3517
|
+
throw j(e), e.config.onError({ message: e._resolveErrorMessage(a) }), a;
|
|
3514
3518
|
}
|
|
3515
3519
|
}
|
|
3516
3520
|
async function tt(e) {
|
|
3517
|
-
var
|
|
3518
|
-
if (!(((
|
|
3521
|
+
var t, o;
|
|
3522
|
+
if (!(((t = e.selectedPaymentMethod) == null ? void 0 : t.type) !== "card" || !((o = e.selectedPaymentMethod) != null && o.cardId)))
|
|
3519
3523
|
try {
|
|
3520
|
-
await
|
|
3524
|
+
await Xt(
|
|
3521
3525
|
e.apiUrl,
|
|
3522
3526
|
e._getApiConfig(),
|
|
3523
3527
|
e.selectedPaymentMethod.cardId
|
|
3524
3528
|
);
|
|
3525
|
-
} catch (
|
|
3526
|
-
console.warn("Failed to mark selected card as default:",
|
|
3529
|
+
} catch (i) {
|
|
3530
|
+
console.warn("Failed to mark selected card as default:", i);
|
|
3527
3531
|
}
|
|
3528
3532
|
}
|
|
3529
|
-
async function bn(e,
|
|
3530
|
-
|
|
3533
|
+
async function bn(e, t) {
|
|
3534
|
+
te(e), e.waitingForNewCardAction = !0, e._setNewCardActionTimeout();
|
|
3531
3535
|
try {
|
|
3532
|
-
await
|
|
3536
|
+
await Ht(
|
|
3533
3537
|
e.apiUrl,
|
|
3534
3538
|
e._getApiConfig(),
|
|
3535
3539
|
e.deviceId,
|
|
3536
|
-
|
|
3540
|
+
t
|
|
3537
3541
|
);
|
|
3538
3542
|
} catch (o) {
|
|
3539
3543
|
e.waitingForNewCardAction = !1, e._clearNewCardActionTimeout(), j(e), e.config.onError({
|
|
@@ -3541,21 +3545,21 @@ async function bn(e, n) {
|
|
|
3541
3545
|
}), console.error("New card payment error:", o);
|
|
3542
3546
|
}
|
|
3543
3547
|
}
|
|
3544
|
-
let
|
|
3545
|
-
async function En(e,
|
|
3548
|
+
let se = null;
|
|
3549
|
+
async function En(e, t) {
|
|
3546
3550
|
const o = window.ApplePaySession;
|
|
3547
3551
|
if (!o || !o.canMakePayments()) {
|
|
3548
3552
|
e.config.onError({ attributes: { message: e.t("errorApplePayUnsupported") } });
|
|
3549
3553
|
return;
|
|
3550
3554
|
}
|
|
3551
|
-
if (
|
|
3555
|
+
if (se) {
|
|
3552
3556
|
try {
|
|
3553
|
-
|
|
3557
|
+
se.abort();
|
|
3554
3558
|
} catch {
|
|
3555
3559
|
}
|
|
3556
|
-
|
|
3560
|
+
se = null;
|
|
3557
3561
|
}
|
|
3558
|
-
const
|
|
3562
|
+
const i = {
|
|
3559
3563
|
countryCode: e.config.currency === "GEL" ? "GE" : "KZ",
|
|
3560
3564
|
currencyCode: e.config.currency,
|
|
3561
3565
|
supportedNetworks: ["visa", "masterCard"],
|
|
@@ -3565,82 +3569,85 @@ async function En(e, n) {
|
|
|
3565
3569
|
amount: String(e._getPayableAmount()),
|
|
3566
3570
|
type: "final"
|
|
3567
3571
|
}
|
|
3568
|
-
},
|
|
3569
|
-
|
|
3570
|
-
var
|
|
3572
|
+
}, s = new o(3, i);
|
|
3573
|
+
se = s, s.onvalidatemerchant = async (u) => {
|
|
3574
|
+
var a, d;
|
|
3571
3575
|
try {
|
|
3572
|
-
const g = await
|
|
3576
|
+
const g = await xt(
|
|
3573
3577
|
e.apiUrl,
|
|
3574
3578
|
e._getApiConfig(),
|
|
3575
3579
|
u.validationURL
|
|
3576
|
-
), C = ((d = (
|
|
3577
|
-
|
|
3580
|
+
), C = ((d = (a = g == null ? void 0 : g.data) == null ? void 0 : a.attributes) == null ? void 0 : d.session) || g, S = JSON.parse(atob(C));
|
|
3581
|
+
s.completeMerchantValidation(S);
|
|
3578
3582
|
} catch (g) {
|
|
3579
|
-
console.error("Apple Pay session error:", g),
|
|
3583
|
+
console.error("Apple Pay session error:", g), s.abort(), e.config.onError({ attributes: { message: e.t("errorApplePayInit") } });
|
|
3580
3584
|
}
|
|
3581
|
-
},
|
|
3582
|
-
var
|
|
3585
|
+
}, s.onpaymentauthorized = async (u) => {
|
|
3586
|
+
var a;
|
|
3583
3587
|
try {
|
|
3584
|
-
if (
|
|
3588
|
+
if (te(e), typeof e.config.onBeforeCheckout == "function") {
|
|
3585
3589
|
const C = await e.config.onBeforeCheckout();
|
|
3586
3590
|
C && typeof C == "object" && Object.assign(e.config, C);
|
|
3587
3591
|
}
|
|
3588
|
-
const d = await
|
|
3592
|
+
const d = await Ft(
|
|
3589
3593
|
e.apiUrl,
|
|
3590
3594
|
e._getApiConfig(),
|
|
3591
3595
|
e.deviceId,
|
|
3592
3596
|
u.payment,
|
|
3593
|
-
|
|
3597
|
+
t
|
|
3594
3598
|
);
|
|
3595
|
-
|
|
3596
|
-
const g = (d == null ? void 0 : d.id) ?? ((
|
|
3597
|
-
g &&
|
|
3599
|
+
s.completePayment(o.STATUS_SUCCESS), se = null;
|
|
3600
|
+
const g = (d == null ? void 0 : d.id) ?? ((a = d == null ? void 0 : d.data) == null ? void 0 : a.id);
|
|
3601
|
+
g && ce(e, String(g));
|
|
3598
3602
|
} catch (d) {
|
|
3599
|
-
console.error("Apple Pay payment error:", d),
|
|
3603
|
+
console.error("Apple Pay payment error:", d), s.completePayment(o.STATUS_FAILURE), j(e), e.config.onError({
|
|
3600
3604
|
attributes: {
|
|
3601
3605
|
message: e._resolveErrorMessage(d, "errorApplePayPayment")
|
|
3602
3606
|
}
|
|
3603
3607
|
});
|
|
3604
3608
|
}
|
|
3605
|
-
},
|
|
3606
|
-
|
|
3607
|
-
},
|
|
3609
|
+
}, s.oncancel = () => {
|
|
3610
|
+
se = null, e.config.onCancel();
|
|
3611
|
+
}, s.begin();
|
|
3608
3612
|
}
|
|
3609
|
-
async function vn(e,
|
|
3613
|
+
async function vn(e, t) {
|
|
3610
3614
|
var P, k, w, L, O, F;
|
|
3611
|
-
|
|
3612
|
-
await e._loadGooglePaySdk();
|
|
3613
|
-
} catch (M) {
|
|
3614
|
-
console.error("Google Pay SDK load error:", M), e.config.onError({ attributes: { message: e.t("errorGooglePayUnsupported") } });
|
|
3615
|
-
return;
|
|
3616
|
-
}
|
|
3617
|
-
const o = window.google;
|
|
3618
|
-
if (!(o != null && o.payments)) {
|
|
3619
|
-
e.config.onError({ attributes: { message: e.t("errorGooglePayUnsupported") } });
|
|
3620
|
-
return;
|
|
3621
|
-
}
|
|
3622
|
-
const s = (P = e.checkoutContext) == null ? void 0 : P.data, i = ((w = (k = s == null ? void 0 : s.payment_methods) == null ? void 0 : k.data) == null ? void 0 : w.attributes) || {}, u = i.google_pay_settings || {};
|
|
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 || {};
|
|
3623
3616
|
if (!(i.payment_method_google_pay === "enabled" || i.payment_method_google_pay === !0)) {
|
|
3624
3617
|
e.config.onError({ attributes: { message: e.t("errorGooglePayUnsupported") } });
|
|
3625
3618
|
return;
|
|
3626
3619
|
}
|
|
3627
|
-
const
|
|
3628
|
-
if (!
|
|
3620
|
+
const a = s == null ? void 0 : s.gateway, d = s == null ? void 0 : s.merchant_id;
|
|
3621
|
+
if (!a || !d) {
|
|
3629
3622
|
e.config.onError({
|
|
3630
3623
|
attributes: { message: e.t("errorGooglePaySettingsUnavailable") }
|
|
3631
3624
|
});
|
|
3632
3625
|
return;
|
|
3633
3626
|
}
|
|
3634
|
-
const
|
|
3635
|
-
if (
|
|
3627
|
+
const g = e.config.environment === "production", C = (s == null ? void 0 : s.merchant_name) || "Choco", S = s == null ? void 0 : s.google_merchant_id;
|
|
3628
|
+
if (g && !S) {
|
|
3636
3629
|
e.config.onError({
|
|
3637
3630
|
attributes: { message: e.t("errorGooglePaySettingsUnavailable") }
|
|
3638
3631
|
});
|
|
3639
3632
|
return;
|
|
3640
3633
|
}
|
|
3641
|
-
|
|
3642
|
-
|
|
3643
|
-
|
|
3634
|
+
if (e.config.isNativeAndroid) {
|
|
3635
|
+
await Bn(e, t, { gateway: a, gatewayMerchantId: d });
|
|
3636
|
+
return;
|
|
3637
|
+
}
|
|
3638
|
+
const T = Number(e._getCheckoutAmount()).toFixed(2);
|
|
3639
|
+
try {
|
|
3640
|
+
await e._loadGooglePaySdk();
|
|
3641
|
+
} catch (M) {
|
|
3642
|
+
console.error("Google Pay SDK load error:", M), e.config.onError({ attributes: { message: e.t("errorGooglePayUnsupported") } });
|
|
3643
|
+
return;
|
|
3644
|
+
}
|
|
3645
|
+
const E = window.google;
|
|
3646
|
+
if (!(E != null && E.payments)) {
|
|
3647
|
+
e.config.onError({ attributes: { message: e.t("errorGooglePayUnsupported") } });
|
|
3648
|
+
return;
|
|
3649
|
+
}
|
|
3650
|
+
const Q = [
|
|
3644
3651
|
{
|
|
3645
3652
|
type: "CARD",
|
|
3646
3653
|
parameters: {
|
|
@@ -3650,44 +3657,45 @@ async function vn(e, n) {
|
|
|
3650
3657
|
},
|
|
3651
3658
|
tokenizationSpecification: {
|
|
3652
3659
|
type: "PAYMENT_GATEWAY",
|
|
3653
|
-
parameters: { gateway:
|
|
3660
|
+
parameters: { gateway: a, gatewayMerchantId: d }
|
|
3654
3661
|
}
|
|
3655
3662
|
}
|
|
3656
|
-
],
|
|
3663
|
+
], _ = {
|
|
3657
3664
|
apiVersion: 2,
|
|
3658
3665
|
apiVersionMinor: 0,
|
|
3659
|
-
allowedPaymentMethods:
|
|
3666
|
+
allowedPaymentMethods: Q,
|
|
3660
3667
|
transactionInfo: {
|
|
3661
3668
|
totalPriceStatus: "FINAL",
|
|
3662
3669
|
totalPriceLabel: "Итого",
|
|
3663
|
-
totalPrice:
|
|
3670
|
+
totalPrice: T,
|
|
3664
3671
|
currencyCode: e.config.currency,
|
|
3665
3672
|
countryCode: e.config.currency === "GEL" ? "GE" : "KZ"
|
|
3666
3673
|
},
|
|
3667
|
-
merchantInfo:
|
|
3668
|
-
}
|
|
3669
|
-
|
|
3674
|
+
merchantInfo: g ? { merchantId: S, merchantName: C } : { merchantName: C }
|
|
3675
|
+
}, m = new E.payments.api.PaymentsClient({
|
|
3676
|
+
environment: g ? "PRODUCTION" : "TEST"
|
|
3677
|
+
});
|
|
3670
3678
|
try {
|
|
3671
|
-
const M = await
|
|
3679
|
+
const M = await m.isReadyToPay({
|
|
3672
3680
|
apiVersion: 2,
|
|
3673
3681
|
apiVersionMinor: 0,
|
|
3674
|
-
allowedPaymentMethods:
|
|
3682
|
+
allowedPaymentMethods: Q
|
|
3675
3683
|
});
|
|
3676
3684
|
if (!(M != null && M.result)) {
|
|
3677
3685
|
e.config.onError({ attributes: { message: e.t("errorGooglePayUnsupported") } });
|
|
3678
3686
|
return;
|
|
3679
3687
|
}
|
|
3680
|
-
|
|
3681
|
-
const J = await
|
|
3688
|
+
te(e);
|
|
3689
|
+
const J = await m.loadPaymentData(_), x = (O = (L = J == null ? void 0 : J.paymentMethodData) == null ? void 0 : L.tokenizationData) == null ? void 0 : O.token;
|
|
3682
3690
|
if (!x) throw new Error(e.t("errorGooglePayPayment"));
|
|
3683
|
-
const q = JSON.parse(x), N = await
|
|
3691
|
+
const q = JSON.parse(x), N = await at(
|
|
3684
3692
|
e.apiUrl,
|
|
3685
3693
|
e._getApiConfig(),
|
|
3686
3694
|
e.deviceId,
|
|
3687
3695
|
q,
|
|
3688
|
-
|
|
3696
|
+
t
|
|
3689
3697
|
), b = (N == null ? void 0 : N.id) ?? ((F = N == null ? void 0 : N.data) == null ? void 0 : F.id);
|
|
3690
|
-
b &&
|
|
3698
|
+
b && ce(e, String(b));
|
|
3691
3699
|
} catch (M) {
|
|
3692
3700
|
j(e), M.statusCode === "CANCELED" ? e.config.onCancel() : (e.config.onError({
|
|
3693
3701
|
attributes: {
|
|
@@ -3696,99 +3704,127 @@ async function vn(e, n) {
|
|
|
3696
3704
|
}), console.error("Google Pay error:", M));
|
|
3697
3705
|
}
|
|
3698
3706
|
}
|
|
3699
|
-
function Bn(e) {
|
|
3700
|
-
var
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
}
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
|
|
3707
|
+
async function Bn(e, t, o) {
|
|
3708
|
+
var i;
|
|
3709
|
+
if (!e.config.onPayWithGooglePay) {
|
|
3710
|
+
e.config.onError({ attributes: { message: e.t("errorGooglePayUnsupported") } });
|
|
3711
|
+
return;
|
|
3712
|
+
}
|
|
3713
|
+
te(e);
|
|
3714
|
+
try {
|
|
3715
|
+
const s = await e.config.onPayWithGooglePay({
|
|
3716
|
+
amount: Number(e._getCheckoutAmount()),
|
|
3717
|
+
gateway: o.gateway,
|
|
3718
|
+
gatewayMerchantId: o.gatewayMerchantId
|
|
3719
|
+
}), u = JSON.parse(s), a = await at(
|
|
3720
|
+
e.apiUrl,
|
|
3721
|
+
e._getApiConfig(),
|
|
3722
|
+
e.deviceId,
|
|
3723
|
+
u,
|
|
3724
|
+
t
|
|
3725
|
+
), d = (a == null ? void 0 : a.id) ?? ((i = a == null ? void 0 : a.data) == null ? void 0 : i.id);
|
|
3726
|
+
d && ce(e, String(d));
|
|
3727
|
+
} catch (s) {
|
|
3728
|
+
j(e), s.statusCode === "CANCELED" ? e.config.onCancel() : (e.config.onError({
|
|
3729
|
+
attributes: {
|
|
3730
|
+
message: e._resolveErrorMessage(s, "errorGooglePayPayment")
|
|
3731
|
+
}
|
|
3732
|
+
}), console.error("Google Pay native error:", s));
|
|
3733
|
+
}
|
|
3734
|
+
}
|
|
3735
|
+
function In(e) {
|
|
3736
|
+
var u, a, d, g, C, S, T, E, Q, _;
|
|
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", () => {
|
|
3739
|
+
e._pendingDeleteMethod ? ve(e) : V(e);
|
|
3740
|
+
}), (g = t.querySelector('[data-action="edit-sheet"]')) == null || g.addEventListener("click", () => {
|
|
3741
|
+
e.isPaymentSheetEditMode = !0, Ae(e), ue(e);
|
|
3742
|
+
}), (C = t.querySelector('[data-action="previous-sheet"]')) == null || C.addEventListener("click", () => {
|
|
3743
|
+
e.isPaymentSheetEditMode = !1, Ae(e), ue(e);
|
|
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", () => {
|
|
3709
3745
|
if (e._pendingDeleteMethod) {
|
|
3710
3746
|
const m = e._pendingDeleteMethod;
|
|
3711
|
-
Ne(e, !0), Cn(e, m).then(() =>
|
|
3747
|
+
Ne(e, !0), Cn(e, m).then(() => V(e)).finally(() => Ne(e, !1));
|
|
3712
3748
|
}
|
|
3713
|
-
}),
|
|
3749
|
+
}), t.querySelectorAll(".choco-widget-method-item").forEach((m) => {
|
|
3714
3750
|
m.addEventListener("click", (P) => {
|
|
3715
3751
|
const k = JSON.parse(
|
|
3716
3752
|
P.currentTarget.getAttribute("data-method") || "{}"
|
|
3717
3753
|
);
|
|
3718
|
-
|
|
3754
|
+
ft(e, k);
|
|
3719
3755
|
});
|
|
3720
3756
|
});
|
|
3721
|
-
const o =
|
|
3757
|
+
const o = t.querySelector('[data-sheet="payment"]');
|
|
3722
3758
|
o && (o.addEventListener("click", (m) => {
|
|
3723
|
-
m.target === o &&
|
|
3724
|
-
}),
|
|
3725
|
-
const
|
|
3726
|
-
|
|
3759
|
+
m.target === o && V(e);
|
|
3760
|
+
}), Sn(e, o));
|
|
3761
|
+
const i = t.querySelector('[data-action="toggle-balance"]');
|
|
3762
|
+
i && ((Q = i.querySelector("input[type='checkbox']")) == null || Q.addEventListener("change", (m) => {
|
|
3727
3763
|
e.useBalance = m.target.checked, e._updatePayButtonAmount();
|
|
3728
3764
|
}));
|
|
3729
|
-
const
|
|
3730
|
-
|
|
3765
|
+
const s = t.querySelector('[data-action="toggle-bonuses"]');
|
|
3766
|
+
s && ((_ = s.querySelector("input[type='checkbox']")) == null || _.addEventListener("change", (m) => {
|
|
3731
3767
|
e.useBonuses = m.target.checked, e.config.onAppliedBonus(e.useBonuses), e._updatePayButtonAmount();
|
|
3732
|
-
})), document.removeEventListener("keydown", e._boundKeyDown), document.addEventListener("keydown", e._boundKeyDown),
|
|
3768
|
+
})), document.removeEventListener("keydown", e._boundKeyDown), document.addEventListener("keydown", e._boundKeyDown), dt(e);
|
|
3733
3769
|
}
|
|
3734
|
-
function
|
|
3735
|
-
var o,
|
|
3736
|
-
e.isOpen && (
|
|
3770
|
+
function Qn(e, t) {
|
|
3771
|
+
var o, i;
|
|
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()));
|
|
3737
3773
|
}
|
|
3738
|
-
function
|
|
3739
|
-
const o =
|
|
3740
|
-
if (!o || !
|
|
3741
|
-
const
|
|
3742
|
-
let u = 0,
|
|
3774
|
+
function Sn(e, t) {
|
|
3775
|
+
const o = t.querySelector('[data-action="sheet-drag-handle"]'), i = t.querySelector(".choco-widget-sheet-content");
|
|
3776
|
+
if (!o || !i) return;
|
|
3777
|
+
const s = 80;
|
|
3778
|
+
let u = 0, a = 0;
|
|
3743
3779
|
const d = (C) => {
|
|
3744
|
-
|
|
3745
|
-
const S = Math.max(0,
|
|
3746
|
-
|
|
3780
|
+
a = C.clientY;
|
|
3781
|
+
const S = Math.max(0, a - u);
|
|
3782
|
+
i.style.transform = `translateY(${S}px)`;
|
|
3747
3783
|
}, g = (C) => {
|
|
3748
3784
|
o.releasePointerCapture(C.pointerId), o.removeEventListener("pointermove", d), o.removeEventListener("pointerup", g), o.removeEventListener("pointercancel", g);
|
|
3749
|
-
const S = Math.max(0,
|
|
3750
|
-
if (
|
|
3751
|
-
|
|
3785
|
+
const S = Math.max(0, a - u);
|
|
3786
|
+
if (i.classList.remove("choco-widget-sheet-content--dragging"), S >= s) {
|
|
3787
|
+
i.style.transform = "translateY(100%)";
|
|
3752
3788
|
const T = () => {
|
|
3753
|
-
|
|
3789
|
+
i.removeEventListener("transitionend", T), i.style.transform = "", V(e);
|
|
3754
3790
|
};
|
|
3755
|
-
|
|
3791
|
+
i.addEventListener("transitionend", T);
|
|
3756
3792
|
} else
|
|
3757
|
-
|
|
3793
|
+
i.style.transform = "";
|
|
3758
3794
|
};
|
|
3759
3795
|
o.addEventListener("pointerdown", (C) => {
|
|
3760
|
-
!e.isPaymentSheetOpen || C.button !== 0 || (C.preventDefault(), u = C.clientY,
|
|
3796
|
+
!e.isPaymentSheetOpen || C.button !== 0 || (C.preventDefault(), u = C.clientY, a = C.clientY, i.classList.add("choco-widget-sheet-content--dragging"), o.setPointerCapture(C.pointerId), o.addEventListener("pointermove", d), o.addEventListener("pointerup", g), o.addEventListener("pointercancel", g));
|
|
3761
3797
|
});
|
|
3762
3798
|
}
|
|
3763
|
-
class
|
|
3799
|
+
class ie {
|
|
3764
3800
|
// ─── Статические методы / logout ─────────────────────────────────────────────
|
|
3765
|
-
static _getAuthStorageValue(
|
|
3766
|
-
return it(
|
|
3801
|
+
static _getAuthStorageValue(t) {
|
|
3802
|
+
return it(t);
|
|
3767
3803
|
}
|
|
3768
|
-
static _setAuthStorageValue(
|
|
3769
|
-
Re(
|
|
3804
|
+
static _setAuthStorageValue(t, o) {
|
|
3805
|
+
Re(t, o);
|
|
3770
3806
|
}
|
|
3771
|
-
static _removeAuthStorageValue(
|
|
3772
|
-
be(
|
|
3807
|
+
static _removeAuthStorageValue(t) {
|
|
3808
|
+
be(t);
|
|
3773
3809
|
}
|
|
3774
3810
|
static async logout() {
|
|
3775
3811
|
Ze();
|
|
3776
3812
|
}
|
|
3777
3813
|
// ─── Конструктор ──────────────────────────────────────────────────────────────
|
|
3778
|
-
constructor(
|
|
3779
|
-
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();
|
|
3780
3816
|
}
|
|
3781
3817
|
// ─── Локализация ──────────────────────────────────────────────────────────────
|
|
3782
|
-
t(
|
|
3818
|
+
t(t, o = {}) {
|
|
3783
3819
|
var u;
|
|
3784
|
-
const
|
|
3785
|
-
return typeof
|
|
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(
|
|
3786
3822
|
/{(\w+)}/g,
|
|
3787
|
-
(
|
|
3823
|
+
(a, d) => Object.prototype.hasOwnProperty.call(o, d) ? String(o[d]) : a
|
|
3788
3824
|
);
|
|
3789
3825
|
}
|
|
3790
|
-
_resolveErrorMessage(
|
|
3791
|
-
return (
|
|
3826
|
+
_resolveErrorMessage(t, o = "paymentError") {
|
|
3827
|
+
return (t == null ? void 0 : t.message) || this.t(o);
|
|
3792
3828
|
}
|
|
3793
3829
|
// ─── Вспомогательные геттеры ─────────────────────────────────────────────────
|
|
3794
3830
|
_getApiConfig() {
|
|
@@ -3798,27 +3834,27 @@ class se {
|
|
|
3798
3834
|
return this.disabled || this.loading;
|
|
3799
3835
|
}
|
|
3800
3836
|
_getBalanceAmount() {
|
|
3801
|
-
var
|
|
3802
|
-
const
|
|
3803
|
-
return Number.isFinite(
|
|
3837
|
+
var s, u, a, d;
|
|
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]);
|
|
3839
|
+
return Number.isFinite(i) && i > 0 ? i : 0;
|
|
3804
3840
|
}
|
|
3805
3841
|
_getBonusesAmount() {
|
|
3806
3842
|
var o;
|
|
3807
|
-
const
|
|
3808
|
-
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;
|
|
3809
3845
|
}
|
|
3810
3846
|
_getBonusesPercent() {
|
|
3811
3847
|
var o;
|
|
3812
|
-
const
|
|
3813
|
-
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;
|
|
3814
3850
|
}
|
|
3815
3851
|
_getAvailableBonus() {
|
|
3816
3852
|
var o;
|
|
3817
|
-
const
|
|
3818
|
-
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;
|
|
3819
3855
|
}
|
|
3820
3856
|
_getPaymentBreakdown() {
|
|
3821
|
-
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;
|
|
3822
3858
|
return {
|
|
3823
3859
|
payableAmount: d,
|
|
3824
3860
|
checkoutOptions: {
|
|
@@ -3838,25 +3874,26 @@ class se {
|
|
|
3838
3874
|
return this._getPaymentBreakdown().checkoutOptions.checkoutAmount ?? this.config.amount;
|
|
3839
3875
|
}
|
|
3840
3876
|
_getPaymentMethodForUserEvent() {
|
|
3841
|
-
var
|
|
3842
|
-
return this._isBalanceFullyCoveringAmount() ? "balance" : ((
|
|
3877
|
+
var t;
|
|
3878
|
+
return this._isBalanceFullyCoveringAmount() ? "balance" : ((t = this.selectedPaymentMethod) == null ? void 0 : t.type) ?? null;
|
|
3843
3879
|
}
|
|
3844
3880
|
_getKaspiOptions() {
|
|
3845
3881
|
return {
|
|
3846
3882
|
onlyKaspiAvailable: this.config.onlyKaspiAvailable,
|
|
3847
|
-
disableKaspi: this.config.disableKaspi
|
|
3883
|
+
disableKaspi: this.config.disableKaspi,
|
|
3884
|
+
disableGooglePay: this.config.disableGooglePay
|
|
3848
3885
|
};
|
|
3849
3886
|
}
|
|
3850
3887
|
// ─── Эмиттеры ────────────────────────────────────────────────────────────────
|
|
3851
|
-
_emitUserEvent(
|
|
3852
|
-
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 });
|
|
3853
3890
|
}
|
|
3854
|
-
_emitPaymentMethodSelected(
|
|
3855
|
-
typeof this.config.onPaymentMethodSelected == "function" && this.config.onPaymentMethodSelected(
|
|
3891
|
+
_emitPaymentMethodSelected(t = this.selectedPaymentMethod) {
|
|
3892
|
+
typeof this.config.onPaymentMethodSelected == "function" && this.config.onPaymentMethodSelected(t || null);
|
|
3856
3893
|
}
|
|
3857
3894
|
// ─── Делегаторы в модули (вызываются из domUI/events через widget.method()) ──
|
|
3858
3895
|
_attachEventListeners() {
|
|
3859
|
-
|
|
3896
|
+
In(this);
|
|
3860
3897
|
}
|
|
3861
3898
|
_updatePayButtonAmount() {
|
|
3862
3899
|
pe(this);
|
|
@@ -3869,7 +3906,7 @@ class se {
|
|
|
3869
3906
|
}
|
|
3870
3907
|
// ─── Таймауты новой карты ─────────────────────────────────────────────────────
|
|
3871
3908
|
_setNewCardActionTimeout() {
|
|
3872
|
-
this._clearNewCardActionTimeout(), this.newCardActionRequiredTimeoutId =
|
|
3909
|
+
this._clearNewCardActionTimeout(), this.newCardActionRequiredTimeoutId = setTimeout(() => {
|
|
3873
3910
|
this.waitingForNewCardAction && (this.waitingForNewCardAction = !1, j(this), this.config.onError({
|
|
3874
3911
|
attributes: { message: this.t("errorNoServerResponseRetry") }
|
|
3875
3912
|
})), this.newCardActionRequiredTimeoutId = null;
|
|
@@ -3879,41 +3916,41 @@ class se {
|
|
|
3879
3916
|
this.newCardActionRequiredTimeoutId && (window.clearTimeout(this.newCardActionRequiredTimeoutId), this.newCardActionRequiredTimeoutId = null);
|
|
3880
3917
|
}
|
|
3881
3918
|
// ─── Хранение токенов ────────────────────────────────────────────────────────
|
|
3882
|
-
_saveTokensToStorage(
|
|
3883
|
-
Me(
|
|
3919
|
+
_saveTokensToStorage(t, o) {
|
|
3920
|
+
Me(t, o);
|
|
3884
3921
|
}
|
|
3885
3922
|
_clearAuthStorage() {
|
|
3886
3923
|
Ze();
|
|
3887
3924
|
}
|
|
3888
|
-
_getAuthStorageValue(
|
|
3889
|
-
return
|
|
3925
|
+
_getAuthStorageValue(t) {
|
|
3926
|
+
return ie._getAuthStorageValue(t);
|
|
3890
3927
|
}
|
|
3891
|
-
_setAuthStorageValue(
|
|
3892
|
-
|
|
3928
|
+
_setAuthStorageValue(t, o) {
|
|
3929
|
+
ie._setAuthStorageValue(t, o);
|
|
3893
3930
|
}
|
|
3894
|
-
_removeAuthStorageValue(
|
|
3895
|
-
|
|
3931
|
+
_removeAuthStorageValue(t) {
|
|
3932
|
+
ie._removeAuthStorageValue(t);
|
|
3896
3933
|
}
|
|
3897
3934
|
// ─── Google Pay SDK (используется из domUI + paymentFlow) ────────────────────
|
|
3898
3935
|
_loadGooglePaySdk() {
|
|
3899
|
-
var
|
|
3900
|
-
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) => {
|
|
3901
3938
|
const u = document.querySelector(
|
|
3902
3939
|
'script[data-choco-google-pay-sdk="true"]'
|
|
3903
3940
|
);
|
|
3904
3941
|
if (u) {
|
|
3905
|
-
u.addEventListener("load", () =>
|
|
3942
|
+
u.addEventListener("load", () => i(), { once: !0 }), u.addEventListener(
|
|
3906
3943
|
"error",
|
|
3907
|
-
() =>
|
|
3944
|
+
() => s(new Error("Failed to load Google Pay SDK")),
|
|
3908
3945
|
{ once: !0 }
|
|
3909
3946
|
);
|
|
3910
3947
|
return;
|
|
3911
3948
|
}
|
|
3912
|
-
const
|
|
3913
|
-
|
|
3949
|
+
const a = document.createElement("script");
|
|
3950
|
+
a.src = "https://pay.google.com/gp/p/js/pay.js", a.async = !0, a.defer = !0, a.setAttribute("data-choco-google-pay-sdk", "true"), a.onload = () => i(), a.onerror = () => s(new Error("Failed to load Google Pay SDK")), document.head.appendChild(a);
|
|
3914
3951
|
}).finally(() => {
|
|
3915
|
-
var
|
|
3916
|
-
(
|
|
3952
|
+
var i, s;
|
|
3953
|
+
(s = (i = window.google) == null ? void 0 : i.payments) != null && s.api || (this._googlePayScriptPromise = null);
|
|
3917
3954
|
}), this._googlePayScriptPromise);
|
|
3918
3955
|
}
|
|
3919
3956
|
// ─── Lifecycle listeners ──────────────────────────────────────────────────────
|
|
@@ -3942,14 +3979,14 @@ class se {
|
|
|
3942
3979
|
this.apiUrl,
|
|
3943
3980
|
this._getApiConfig()
|
|
3944
3981
|
);
|
|
3945
|
-
} catch (
|
|
3946
|
-
if (
|
|
3982
|
+
} catch (t) {
|
|
3983
|
+
if (t.status === 401)
|
|
3947
3984
|
this._removeAuthStorageValue("webPayToken"), await this._obtainTokenByRefreshOrTrackId(), this.checkoutContext = await Oe(
|
|
3948
3985
|
this.apiUrl,
|
|
3949
3986
|
this._getApiConfig()
|
|
3950
3987
|
);
|
|
3951
3988
|
else
|
|
3952
|
-
throw
|
|
3989
|
+
throw t;
|
|
3953
3990
|
}
|
|
3954
3991
|
}
|
|
3955
3992
|
// ─── Рендер ───────────────────────────────────────────────────────────────────
|
|
@@ -3961,7 +3998,7 @@ class se {
|
|
|
3961
3998
|
}
|
|
3962
3999
|
// ─── Публичный API ────────────────────────────────────────────────────────────
|
|
3963
4000
|
async init() {
|
|
3964
|
-
var
|
|
4001
|
+
var t, o;
|
|
3965
4002
|
try {
|
|
3966
4003
|
if (this._prerender(), this._attachLifecycleListeners(), !this.config.clientId)
|
|
3967
4004
|
return this.config.onError({ attributes: { message: this.t("errorMissingTrackClient") } }), !1;
|
|
@@ -3970,35 +4007,35 @@ class se {
|
|
|
3970
4007
|
this.accessToken || await this._obtainTokenByRefreshOrTrackId();
|
|
3971
4008
|
try {
|
|
3972
4009
|
await this._fetchCheckoutContextWithRetry();
|
|
3973
|
-
} catch (
|
|
3974
|
-
const u =
|
|
4010
|
+
} catch (s) {
|
|
4011
|
+
const u = s;
|
|
3975
4012
|
return this.config.onError({ attributes: { message: u.message } }), !1;
|
|
3976
4013
|
}
|
|
3977
|
-
const
|
|
3978
|
-
(o = (
|
|
3979
|
-
(
|
|
4014
|
+
const i = Ve(
|
|
4015
|
+
(o = (t = this.checkoutContext) == null ? void 0 : t.data) == null ? void 0 : o.socket_connections,
|
|
4016
|
+
(s) => et(this, s)
|
|
3980
4017
|
);
|
|
3981
|
-
return
|
|
4018
|
+
return i && (this.centrifuge = i.centrifuge), this.selectedPaymentMethod = Le(
|
|
3982
4019
|
this.checkoutContext.data,
|
|
3983
4020
|
this._getKaspiOptions()
|
|
3984
4021
|
), this._emitPaymentMethodSelected(), this._render(), !0;
|
|
3985
|
-
} catch (
|
|
3986
|
-
return console.error(`${this.t("errorWidgetInit")}:`,
|
|
4022
|
+
} catch (i) {
|
|
4023
|
+
return console.error(`${this.t("errorWidgetInit")}:`, i), this.config.onError({ attributes: { message: i.message } }), !1;
|
|
3987
4024
|
}
|
|
3988
4025
|
}
|
|
3989
4026
|
close() {
|
|
3990
4027
|
this.config.onCancel();
|
|
3991
4028
|
}
|
|
3992
4029
|
destroy() {
|
|
3993
|
-
const
|
|
3994
|
-
|
|
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(() => {
|
|
3995
4032
|
var o;
|
|
3996
4033
|
(o = this.container) == null || o.remove(), this.container = null;
|
|
3997
4034
|
}, 300)), this.isOpen = !1, this.isPaymentSheetOpen = !1, this.isAddCardViewOpen = !1, this.selectedPaymentMethod = null;
|
|
3998
4035
|
}
|
|
3999
4036
|
getAvailablePaymentMethods() {
|
|
4000
|
-
var
|
|
4001
|
-
return (
|
|
4037
|
+
var t;
|
|
4038
|
+
return (t = this.checkoutContext) != null && t.data ? Rt(
|
|
4002
4039
|
this.checkoutContext.data,
|
|
4003
4040
|
(o) => this.t(o),
|
|
4004
4041
|
this._getKaspiOptions()
|
|
@@ -4010,8 +4047,8 @@ class se {
|
|
|
4010
4047
|
async pay() {
|
|
4011
4048
|
try {
|
|
4012
4049
|
await this.createOrder();
|
|
4013
|
-
} catch (
|
|
4014
|
-
console.error(`${this.t("errorPaymentProcess")}:`,
|
|
4050
|
+
} catch (t) {
|
|
4051
|
+
console.error(`${this.t("errorPaymentProcess")}:`, t);
|
|
4015
4052
|
}
|
|
4016
4053
|
}
|
|
4017
4054
|
async handlePayment() {
|
|
@@ -4025,102 +4062,102 @@ class se {
|
|
|
4025
4062
|
return;
|
|
4026
4063
|
}
|
|
4027
4064
|
await this.pay();
|
|
4028
|
-
} catch (
|
|
4029
|
-
console.error(`${this.t("errorPaymentProcess")}:`,
|
|
4065
|
+
} catch (t) {
|
|
4066
|
+
console.error(`${this.t("errorPaymentProcess")}:`, t);
|
|
4030
4067
|
}
|
|
4031
4068
|
}
|
|
4032
4069
|
}
|
|
4033
4070
|
openPaymentSheet() {
|
|
4034
|
-
|
|
4071
|
+
ht(this);
|
|
4035
4072
|
}
|
|
4036
4073
|
closePaymentSheet() {
|
|
4037
|
-
|
|
4074
|
+
V(this);
|
|
4038
4075
|
}
|
|
4039
|
-
async updateAmount(
|
|
4040
|
-
if (typeof
|
|
4076
|
+
async updateAmount(t) {
|
|
4077
|
+
if (typeof t != "number" || !Number.isFinite(t) || t < 0)
|
|
4041
4078
|
throw new Error("amount must be a non-negative number");
|
|
4042
|
-
this.config.amount =
|
|
4079
|
+
this.config.amount = t, pe(this);
|
|
4043
4080
|
}
|
|
4044
|
-
async updateAvailableBonus(
|
|
4045
|
-
if (typeof
|
|
4081
|
+
async updateAvailableBonus(t) {
|
|
4082
|
+
if (typeof t != "number" || !Number.isFinite(t) || t < 0)
|
|
4046
4083
|
throw new Error("availableBonus must be a non-negative number");
|
|
4047
|
-
this.config.bonuses && (this.config.bonuses.availableBonus =
|
|
4084
|
+
this.config.bonuses && (this.config.bonuses.availableBonus = t), pe(this);
|
|
4048
4085
|
}
|
|
4049
|
-
async updateLocale(
|
|
4050
|
-
if (typeof
|
|
4051
|
-
throw new Error(`Unsupported locale: ${
|
|
4052
|
-
if (this.config.locale =
|
|
4053
|
-
const o = this.isPaymentSheetOpen,
|
|
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;
|
|
4090
|
+
const o = this.isPaymentSheetOpen, i = this.isAddCardViewOpen;
|
|
4054
4091
|
if (this._render(), ee(this), o) {
|
|
4055
|
-
const
|
|
4056
|
-
|
|
4092
|
+
const s = this.container.querySelector('[data-sheet="payment"]');
|
|
4093
|
+
s && (s.classList.add("choco-widget-payment-sheet--open"), this.isPaymentSheetOpen = !0);
|
|
4057
4094
|
}
|
|
4058
|
-
|
|
4095
|
+
i && $e(this);
|
|
4059
4096
|
}
|
|
4060
|
-
async setLoading(
|
|
4061
|
-
this.loading = !!
|
|
4097
|
+
async setLoading(t) {
|
|
4098
|
+
this.loading = !!t, ee(this);
|
|
4062
4099
|
}
|
|
4063
|
-
async setDisabled(
|
|
4064
|
-
this.disabled = !!
|
|
4100
|
+
async setDisabled(t) {
|
|
4101
|
+
this.disabled = !!t, ee(this);
|
|
4065
4102
|
}
|
|
4066
|
-
async setPreorderId(
|
|
4067
|
-
this.config.preorderId =
|
|
4103
|
+
async setPreorderId(t) {
|
|
4104
|
+
this.config.preorderId = t;
|
|
4068
4105
|
}
|
|
4069
|
-
async setMerchantOrderId(
|
|
4070
|
-
this.config.merchantOrderId =
|
|
4106
|
+
async setMerchantOrderId(t) {
|
|
4107
|
+
this.config.merchantOrderId = t;
|
|
4071
4108
|
}
|
|
4072
4109
|
async logout() {
|
|
4073
|
-
await
|
|
4110
|
+
await ie.logout(), this.accessToken = null;
|
|
4074
4111
|
}
|
|
4075
|
-
async updateTrackId(
|
|
4076
|
-
var o,
|
|
4077
|
-
if (this.config.trackId =
|
|
4112
|
+
async updateTrackId(t) {
|
|
4113
|
+
var o, i;
|
|
4114
|
+
if (this.config.trackId = t, !this.config.clientId)
|
|
4078
4115
|
return this.config.onError({ attributes: { message: this.t("errorMissingTrackClient") } }), !1;
|
|
4079
4116
|
try {
|
|
4080
4117
|
this._prerender(), await this._obtainTokenByRefreshOrTrackId();
|
|
4081
4118
|
try {
|
|
4082
4119
|
await this._fetchCheckoutContextWithRetry();
|
|
4083
4120
|
} catch (u) {
|
|
4084
|
-
const
|
|
4085
|
-
return this.config.onError({ attributes: { message:
|
|
4121
|
+
const a = u;
|
|
4122
|
+
return this.config.onError({ attributes: { message: a.message } }), !1;
|
|
4086
4123
|
}
|
|
4087
4124
|
this.centrifuge && (this.centrifuge.disconnect(), this.centrifuge = null);
|
|
4088
|
-
const
|
|
4089
|
-
(
|
|
4125
|
+
const s = Ve(
|
|
4126
|
+
(i = (o = this.checkoutContext) == null ? void 0 : o.data) == null ? void 0 : i.socket_connections,
|
|
4090
4127
|
(u) => et(this, u)
|
|
4091
4128
|
);
|
|
4092
|
-
return
|
|
4129
|
+
return s && (this.centrifuge = s.centrifuge), this.selectedPaymentMethod = Le(
|
|
4093
4130
|
this.checkoutContext.data,
|
|
4094
4131
|
this._getKaspiOptions()
|
|
4095
4132
|
), this._emitPaymentMethodSelected(), this.paymentMethodDisabled = !1, this._render(), !0;
|
|
4096
|
-
} catch (
|
|
4097
|
-
return console.error(`${this.t("errorWidgetInit")}:`,
|
|
4133
|
+
} catch (s) {
|
|
4134
|
+
return console.error(`${this.t("errorWidgetInit")}:`, s), this.config.onError({ attributes: { message: s.message } }), !1;
|
|
4098
4135
|
}
|
|
4099
4136
|
}
|
|
4100
|
-
async onConfirmPay(
|
|
4101
|
-
if (typeof
|
|
4102
|
-
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;
|
|
4103
4140
|
}
|
|
4104
|
-
async onPaymentMethodSelected(
|
|
4105
|
-
if (typeof
|
|
4141
|
+
async onPaymentMethodSelected(t) {
|
|
4142
|
+
if (typeof t != "function")
|
|
4106
4143
|
throw new Error("onPaymentMethodSelected callback must be a function");
|
|
4107
|
-
this.config.onPaymentMethodSelected =
|
|
4144
|
+
this.config.onPaymentMethodSelected = t, this._emitPaymentMethodSelected();
|
|
4108
4145
|
}
|
|
4109
|
-
async onKaspiLink(
|
|
4110
|
-
if (typeof
|
|
4111
|
-
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;
|
|
4112
4149
|
}
|
|
4113
|
-
async onUserEvent(
|
|
4114
|
-
if (typeof
|
|
4115
|
-
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;
|
|
4116
4153
|
}
|
|
4117
|
-
async onAppliedBonus(
|
|
4118
|
-
if (typeof
|
|
4154
|
+
async onAppliedBonus(t) {
|
|
4155
|
+
if (typeof t != "function")
|
|
4119
4156
|
throw new Error("onAppliedBonus callback must be a function");
|
|
4120
|
-
this.config.onAppliedBonus =
|
|
4157
|
+
this.config.onAppliedBonus = t;
|
|
4121
4158
|
}
|
|
4122
4159
|
}
|
|
4123
|
-
typeof window < "u" && (window.ChocoOneClickWidget =
|
|
4160
|
+
typeof window < "u" && (window.ChocoOneClickWidget = ie);
|
|
4124
4161
|
export {
|
|
4125
|
-
|
|
4162
|
+
ie as default
|
|
4126
4163
|
};
|