choco-one-click-payment 1.1.37 → 1.1.38

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 CHANGED
@@ -2639,6 +2639,7 @@ function jt(e) {
2639
2639
  preorderId: e.preorderId,
2640
2640
  trackId: e.trackId,
2641
2641
  clientId: e.clientId,
2642
+ projectId: e.projectId,
2642
2643
  terminalId: e.terminalId,
2643
2644
  merchantOrderId: e.merchantOrderId,
2644
2645
  amount: e.amount,
@@ -3107,7 +3108,7 @@ function fn(e) {
3107
3108
  currency: i
3108
3109
  }), e._attachEventListeners(), e.isOpen = !0, e._emitUserEvent("one_click_pay_cta_rendered", {
3109
3110
  terminal_id: e.config.terminalId,
3110
- project_id: e.config.clientId
3111
+ project_id: e.config.projectId ?? e.config.clientId
3111
3112
  }), e._emitUserEvent("one_click_pay_method_resolved", {
3112
3113
  payment_method: e._getPaymentMethodForUserEvent()
3113
3114
  }), requestAnimationFrame(() => {
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
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-toggle--disabled{opacity:.5;pointer-events:none}.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;white-space:nowrap}.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
2
  (function(Ae,ue){typeof exports=="object"&&typeof module<"u"?module.exports=ue():typeof define=="function"&&define.amd?define(ue):(Ae=typeof globalThis<"u"?globalThis:Ae||self,Ae.ChocoOneClickWidget=ue())})(this,(function(){"use strict";const Ae={ru:{paymentMethod:"Способ оплаты",selectMethod:"Выберите метод",pay:"Оплатить",paymentSuccess:"Оплата прошла успешно!",paymentError:"Ошибка оплаты",paymentMethods:"Способ оплаты",newCard:"Оплата новой картой",balance:"Списать баланс",bonus:"Списать бонусы",bonusText:"Можно оплатить до {amount}%",cashback:"Кешбэк",willGet:"Получите",total:"Итого",instead:"вместо",coupon:"Списать купон",couponUntil:"до {date}",addCard:"Добавление карты",editCards:"Редактировать карты",cardDeleted:"Карта успешно удалена",confirmDeleteCard:"Вы действительно хотите удалить карту?",cancel:"Отмена",delete:"Удалить",back:"Назад",errorMissingTrackClient:"Укажите trackId и clientId",errorNoServerResponseRetry:"Нет ответа от сервера, попробуйте заново",errorNoServerResponse:"Нет ответа от сервера",errorPaymentMethodNotSelected:"Метод оплаты не выбран",errorApplePayUnsupported:"Apple Pay не поддерживается в этом браузере",errorApplePayInit:"Ошибка инициализации Apple Pay",errorApplePayPayment:"Ошибка оплаты через Apple Pay",errorGooglePayUnsupported:"Google Pay не поддерживается в этом браузере",errorGooglePaySettingsUnavailable:"Настройки Google Pay недоступны",errorGooglePayPayment:"Ошибка оплаты через Google Pay",errorActionUrlMissing:"action_url отсутствует в событии order.action_required",errorWidgetInit:"Ошибка инициализации виджета",errorPaymentProcess:"Ошибка оплаты"},en:{paymentMethod:"Payment method",selectMethod:"Select method",pay:"Pay",paymentSuccess:"Payment successful!",paymentError:"Payment error",paymentMethods:"Payment method",newCard:"Pay with new card",balance:"Use balance",bonus:"Use bonuses",bonusText:"You can pay up to {amount}%",cashback:"Cashback",willGet:"You will get",total:"Total",instead:"instead",coupon:"Apply coupon",couponUntil:"until {date}",addCard:"Add card",editCards:"Edit cards",cardDeleted:"Card successfully deleted",confirmDeleteCard:"Are you sure you want to delete this card?",cancel:"Cancel",delete:"Delete",back:"Back",errorMissingTrackClient:"Provide trackId and clientId",errorNoServerResponseRetry:"No response from server, please try again",errorNoServerResponse:"No response from server",errorPaymentMethodNotSelected:"Payment method is not selected",errorApplePayUnsupported:"Apple Pay is not supported in this browser",errorApplePayInit:"Apple Pay initialization error",errorApplePayPayment:"Apple Pay payment error",errorGooglePayUnsupported:"Google Pay is not supported in this browser",errorGooglePaySettingsUnavailable:"Google Pay settings are unavailable",errorGooglePayPayment:"Google Pay payment error",errorActionUrlMissing:"action_url is missing in order.action_required event",errorWidgetInit:"Widget initialization error",errorPaymentProcess:"Payment error"},kk:{paymentMethod:"Төлем әдісі",selectMethod:"Әдісті таңдаңыз",pay:"Төлеу",paymentSuccess:"Төлем сәтті өтті!",paymentError:"Төлем қатесі",paymentMethods:"Төлем әдісі",newCard:"Жаңа картамен төлеу",balance:"Балансты пайдалану",bonus:"Бонусдарды пайдалану",bonusText:"{amount}%-ге дейін төлеуге болады",cashback:"Кэшбэк",willGet:"Аласыз",total:"Барлығы",instead:"орнына",coupon:"Купонды пайдалану",couponUntil:"{date} дейін",addCard:"Картаны қосу",editCards:"Карталарды өңдеу",cardDeleted:"Карта жойылды",confirmDeleteCard:"Картаны жойғыңыз келетініне сенімдісіз бе?",cancel:"Болдырмау",delete:"Жою",back:"Артқа",errorMissingTrackClient:"trackId пен clientId көрсетіңіз",errorNoServerResponseRetry:"Серверден жауап жоқ, қайтадан көріңіз",errorNoServerResponse:"Серверден жауап жоқ",errorPaymentMethodNotSelected:"Төлем әдісі таңдалмаған",errorApplePayUnsupported:"Бұл браузерде Apple Pay қолдау көрсетілмейді",errorApplePayInit:"Apple Pay инициализация қатесі",errorApplePayPayment:"Apple Pay арқылы төлем қатесі",errorGooglePayUnsupported:"Бұл браузерде Google Pay қолдау көрсетілмейді",errorGooglePaySettingsUnavailable:"Google Pay баптаулары қолжетімсіз",errorGooglePayPayment:"Google Pay арқылы төлем қатесі",errorActionUrlMissing:"order.action_required оқиғасында action_url жоқ",errorWidgetInit:"Виджетті инициализациялау қатесі",errorPaymentProcess:"Төлем қатесі"},ka:{paymentMethod:"გადახდის მეთოდი",selectMethod:"აირჩიეთ მეთოდი",pay:"გადახდა",paymentSuccess:"გადახდა წარმატებით შესრულდა!",paymentError:"გადახდის შეცდომა",paymentMethods:"გადახდის მეთოდი",newCard:"ახალი ბარათით გადახდა",balance:"ბალანსის გამოყენება",bonus:"ბონუსების გამოყენება",bonusText:"{amount}%-ზე გადახდა შესაძლებელია",cashback:"ქეშბექი",willGet:"მიიღებთ",total:"ჯამი",instead:"ნაცვლად",coupon:"კუპონის გამოყენება",couponUntil:"{date}-მდე",addCard:"ბარათის დამატება",editCards:"ბარათების რედაქტირება",cardDeleted:"ბარათი წაშლილია",confirmDeleteCard:"დარწმუნებული ხართ, რომ გსურთ ამ ბარათის წაშლა?",cancel:"გაუქმება",delete:"წაშლა",back:"უკან",errorMissingTrackClient:"მიუთითეთ trackId და clientId",errorNoServerResponseRetry:"სერვერის პასუხი არ არის, სცადეთ თავიდან",errorNoServerResponse:"სერვერის პასუხი არ არის",errorPaymentMethodNotSelected:"გადახდის მეთოდი არ არის არჩეული",errorApplePayUnsupported:"ამ ბრაუზერში Apple Pay არ არის მხარდაჭერილი",errorApplePayInit:"Apple Pay-ის ინიციალიზაციის შეცდომა",errorApplePayPayment:"Apple Pay-ით გადახდის შეცდომა",errorGooglePayUnsupported:"ამ ბრაუზერში Google Pay არ არის მხარდაჭერილი",errorGooglePaySettingsUnavailable:"Google Pay-ის პარამეტრები მიუწვდომელია",errorGooglePayPayment:"Google Pay-ით გადახდის შეცდომა",errorActionUrlMissing:"order.action_required მოვლენაში action_url არ არის",errorWidgetInit:"ვიჯეტის ინიციალიზაციის შეცდომა",errorPaymentProcess:"გადახდის შეცდომა"}},ue={KZT:"₸",GEL:"₾"};function Et(e){return e==="production"?"https://api-proxy.choco.kz":"https://api-proxy.chocodev.kz"}let he;const vt=new Uint8Array(16);function Bt(){if(!he&&(he=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!he))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return he(vt)}const X=[];for(let e=0;e<256;++e)X.push((e+256).toString(16).slice(1));function It(e,t=0){return X[e[t+0]]+X[e[t+1]]+X[e[t+2]]+X[e[t+3]]+"-"+X[e[t+4]]+X[e[t+5]]+"-"+X[e[t+6]]+X[e[t+7]]+"-"+X[e[t+8]]+X[e[t+9]]+"-"+X[e[t+10]]+X[e[t+11]]+X[e[t+12]]+X[e[t+13]]+X[e[t+14]]+X[e[t+15]]}const Je={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function fe(e,t,o){if(Je.randomUUID&&!e)return Je.randomUUID();e=e||{};const i=e.random||(e.rng||Bt)();return i[6]=i[6]&15|64,i[8]=i[8]&63|128,It(i)}const qe="choco_device_id";function V(e,t="ru",o="KZT"){const i=Number(e),s=t==="ru"?"ru-RU":"en-US";return`${i.toLocaleString(s)} ${ue[o]}`}function je(){let e=localStorage.getItem(qe);return e||(e=fe(),localStorage.setItem(qe,e)),e}function ge(){if(typeof window>"u")return!1;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);return e||s}function ze(){if(typeof navigator>"u")return 0;const e=navigator.userAgent||"",t=e.indexOf("OS");return(e.indexOf("iPhone")>-1||e.indexOf("iPad")>-1)&&t>-1?Number(e.substring(t+3,t+6).replace("_",".")):0}function we(){var u;if(typeof navigator>"u")return"unknown";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}`;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"}function pe(){if(typeof navigator>"u")return!1;const e=navigator.userAgentData;return e!=null&&e.platform&&["iOS","iPadOS"].includes(e.platform)||we()==="ios"?!0:(navigator.userAgent||"").includes("Macintosh")&&typeof document<"u"&&"ontouchend"in document}function Ce(e){if(typeof sessionStorage>"u")return!1;const t=e==="apple_pay"?"disableApplePay":e==="google_pay"?"disableGooglePay":null;return t?sessionStorage.getItem(t)==="true":!1}function Qt(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ye={exports:{}},St=ye.exports,Ke;function Pt(){return Ke||(Ke=1,(function(e,t){(function(i,s){e.exports=s()})(St,function(){return(function(){var o={382:(function(a,l,f){Object.defineProperty(l,"__esModule",{value:!0}),l.Centrifuge=void 0;var C=S(f(187)),k=S(f(471)),_=f(147),b=f(853);function S(g){return g&&g.__esModule?g:{default:g}}function T(g){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?T=function(p){return typeof p}:T=function(p){return p&&typeof Symbol=="function"&&p.constructor===Symbol&&p!==Symbol.prototype?"symbol":typeof p},T(g)}function I(g,h){if(!(g instanceof h))throw new TypeError("Cannot call a class as a function")}function w(g,h){for(var p=0;p<h.length;p++){var A=h[p];A.enumerable=A.enumerable||!1,A.configurable=!0,"value"in A&&(A.writable=!0),Object.defineProperty(g,A.key,A)}}function B(g,h,p){return h&&w(g.prototype,h),g}function v(g,h){if(typeof h!="function"&&h!==null)throw new TypeError("Super expression must either be null or a function");g.prototype=Object.create(h&&h.prototype,{constructor:{value:g,writable:!0,configurable:!0}}),h&&L(g,h)}function L(g,h){return L=Object.setPrototypeOf||function(A,n){return A.__proto__=n,A},L(g,h)}function O(g){var h=q();return function(){var A=J(g),n;if(h){var r=J(this).constructor;n=Reflect.construct(A,arguments,r)}else n=A.apply(this,arguments);return F(this,n)}}function F(g,h){if(h&&(T(h)==="object"||typeof h=="function"))return h;if(h!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return N(g)}function N(g){if(g===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return g}function q(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function J(g){return J=Object.setPrototypeOf?Object.getPrototypeOf:function(p){return p.__proto__||Object.getPrototypeOf(p)},J(g)}var x="timeout",M="connection closed",m=(function(g){v(p,g);var h=O(p);function p(A,n){var r;return I(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={protocol:"",debug:!1,name:"js",version:"",websocket:null,sockjs:null,xmlhttprequest:null,minRetry:1e3,maxRetry:2e4,timeout:5e3,ping:!0,pingInterval:25e3,pongWaitTimeout:5e3,privateChannelPrefix:"$",onTransportClose:null,sockjsServer:null,sockjsTimeout:null,sockjsTransports:["websocket","xdr-streaming","xhr-streaming","eventsource","iframe-eventsource","iframe-htmlfile","xdr-polling","xhr-polling","iframe-xhr-polling","jsonp-polling"],refreshEndpoint:"/centrifuge/refresh",refreshHeaders:{},refreshParams:{},refreshData:{},refreshAttempts:null,refreshInterval:1e3,onRefreshFailed:null,onRefresh:null,subscribeEndpoint:"/centrifuge/subscribe",subscribeHeaders:{},subscribeParams:{},subRefreshInterval:1e3,onPrivateSubscribe:null,disableWithCredentials:!1},r._configure(n),r}return B(p,[{key:"setToken",value:function(n){this._token=n}},{key:"setConnectData",value:function(n){this._connectData=n}},{key:"setRefreshHeaders",value:function(n){this._config.refreshHeaders=n}},{key:"setRefreshParams",value:function(n){this._config.refreshParams=n}},{key:"setRefreshData",value:function(n){this._config.refreshData=n}},{key:"setSubscribeHeaders",value:function(n){this._config.subscribeHeaders=n}},{key:"setSubscribeParams",value:function(n){this._config.subscribeParams=n}},{key:"_ajax",value:function(n,r,c,d,y){var E=this,P="";this._debug("sending AJAX request to",n,"with data",JSON.stringify(d));var Q;this._xmlhttprequest!==null?Q=new this._xmlhttprequest:Q=f.g.XMLHttpRequest?new f.g.XMLHttpRequest:new f.g.ActiveXObject("Microsoft.XMLHTTP");for(var R in r)r.hasOwnProperty(R)&&(P.length>0&&(P+="&"),P+=encodeURIComponent(R)+"="+encodeURIComponent(r[R]));P.length>0&&(P="?"+P),Q.open("POST",n+P,!0),"withCredentials"in Q&&(Q.withCredentials=!this._config.disableWithCredentials),Q.setRequestHeader("X-Requested-With","XMLHttpRequest"),Q.setRequestHeader("Content-Type","application/json");for(var U in c)c.hasOwnProperty(U)&&Q.setRequestHeader(U,c[U]);return Q.onreadystatechange=function(){if(Q.readyState===4)if(Q.status===200){var H,D=!1;try{H=JSON.parse(Q.responseText),D=!0}catch{y({error:"Invalid JSON. Data was: "+Q.responseText,status:200,data:null})}D&&y({data:H,status:200})}else E._log("wrong status code in AJAX response",Q.status),y({status:Q.status,data:null})},setTimeout(function(){return Q.send(JSON.stringify(d))},20),Q}},{key:"_log",value:function(){(0,b.log)("info",arguments)}},{key:"_debug",value:function(){this._config.debug===!0&&(0,b.log)("debug",arguments)}},{key:"_websocketSupported",value:function(){return this._config.websocket!==null?!0:!(typeof WebSocket!="function"&&(typeof WebSocket>"u"?"undefined":T(WebSocket))!=="object")}},{key:"_setFormat",value:function(n){if(!this._formatOverride(n)){if(n==="protobuf")throw new Error("not implemented by JSON only Centrifuge client – use client with Protobuf");this._binary=!1,this._methodType=_.JsonMethodType,this._pushType=_.JsonPushType,this._encoder=new _.JsonEncoder,this._decoder=new _.JsonDecoder}}},{key:"_formatOverride",value:function(n){return!1}},{key:"_configure",value:function(n){if(!("Promise"in f.g))throw new Error("Promise polyfill required");if((0,b.extend)(this._config,n||{}),this._debug("centrifuge config",this._config),!this._url)throw new Error("url required");var r=(0,b.startsWith)(this._url,"ws")&&this._url.indexOf("format=protobuf")>-1;if(r||this._config.protocol==="protobuf")this._setFormat("protobuf"),this._protocol="protobuf";else{if(this._config.protocol!==""&&this._config.protocol!=="json")throw new Error("unsupported protocol "+this._config.protocol);this._setFormat("json")}if((0,b.startsWith)(this._url,"http"))if(this._debug("client will try to connect to SockJS endpoint"),this._config.sockjs!==null)this._debug("SockJS explicitly provided in options"),this._sockjs=this._config.sockjs;else{if(typeof f.g.SockJS>"u")throw new Error("SockJS not found, use ws:// in url or include SockJS");this._debug("use globally defined SockJS"),this._sockjs=f.g.SockJS}else this._debug("client will connect to websocket endpoint");this._xmlhttprequest=this._config.xmlhttprequest}},{key:"_setStatus",value:function(n){this._status!==n&&(this._debug("Status",this._status,"->",n),this._status=n)}},{key:"_isDisconnected",value:function(){return this._status==="disconnected"}},{key:"_isConnecting",value:function(){return this._status==="connecting"}},{key:"_isConnected",value:function(){return this._status==="connected"}},{key:"_nextMessageId",value:function(){return++this._messageId}},{key:"_resetRetry",value:function(){this._debug("reset retries count to 0"),this._retries=0}},{key:"_getRetryInterval",value:function(){var n=(0,b.backoff)(this._retries,this._config.minRetry,this._config.maxRetry);return this._retries+=1,n}},{key:"_abortInflightXHRs",value:function(){for(var n in this._xhrs){try{this._xhrs[n].abort()}catch(r){this._debug("error aborting xhr",r)}delete this._xhrs[n]}}},{key:"_clearConnectedState",value:function(n){this._clientID=null,this._stopPing();for(var r in this._callbacks)if(this._callbacks.hasOwnProperty(r)){var c=this._callbacks[r];clearTimeout(c.timeout);var d=c.errback;if(!d)continue;d({error:this._createErrorObject("disconnected")})}this._callbacks={};for(var y in this._subs)if(this._subs.hasOwnProperty(y)){var E=this._subs[y];n?(E._isSuccess()&&(E._triggerUnsubscribe(),E._recover=!0),E._shouldResubscribe()&&E._setSubscribing()):E._setUnsubscribed()}this._abortInflightXHRs(),this._refreshTimeout!==null&&(clearTimeout(this._refreshTimeout),this._refreshTimeout=null);for(var P in this._subRefreshTimeouts)this._subRefreshTimeouts.hasOwnProperty(P)&&this._subRefreshTimeouts[P]&&this._clearSubRefreshTimeout(P);this._subRefreshTimeouts={},this._reconnect||(this._subs={})}},{key:"_isTransportOpen",value:function(){return this._isSockjs?this._transport&&this._transport.transport&&this._transport.transport.readyState===this._transport.transport.OPEN:this._transport&&this._transport.readyState===this._transport.OPEN}},{key:"_transportSend",value:function(n){if(!n.length)return!0;if(!this._isTransportOpen()){for(var r in n){var c=r.id;if(c in this._callbacks){var d=this._callbacks[c];clearTimeout(this._callbacks[c].timeout),delete this._callbacks[c];var y=d.errback;y({error:this._createErrorObject(M,0)})}}return!1}return this._transport.send(this._encoder.encodeCommands(n)),!0}},{key:"_getSubProtocol",value:function(){return this._protocol?"centrifuge-"+this._protocol:""}},{key:"_setupTransport",value:function(){var n=this;if(this._isSockjs=!1,this._sockjs!==null){var r={transports:this._config.sockjsTransports};this._config.sockjsServer!==null&&(r.server=this._config.sockjsServer),this._config.sockjsTimeout!==null&&(r.timeout=this._config.sockjsTimeout),this._isSockjs=!0,this._transport=new this._sockjs(this._url,null,r)}else{if(!this._websocketSupported())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");this._config.websocket!==null?this._websocket=this._config.websocket:this._websocket=WebSocket;var c=this._getSubProtocol();c!==""?this._transport=new this._websocket(this._url,c):this._transport=new this._websocket(this._url),this._binary===!0&&(this._transport.binaryType="arraybuffer")}this._transport.onopen=function(){n._transportClosed=!1,n._isSockjs?(n._transportName="sockjs-"+n._transport.transport,n._transport.onheartbeat=function(){return n._restartPing()}):n._transportName="websocket";var d={};(n._token||n._connectData||n._config.name||n._config.version)&&(d.params={}),n._token&&(d.params.token=n._token),n._connectData&&(d.params.data=n._connectData),n._config.name&&(d.params.name=n._config.name),n._config.version&&(d.params.version=n._config.version);var y={},E=!1;for(var P in n._serverSubs)if(n._serverSubs.hasOwnProperty(P)&&n._serverSubs[P].recoverable){E=!0;var Q={recover:!0};n._serverSubs[P].seq||n._serverSubs[P].gen?(n._serverSubs[P].seq&&(Q.seq=n._serverSubs[P].seq),n._serverSubs[P].gen&&(Q.gen=n._serverSubs[P].gen)):n._serverSubs[P].offset&&(Q.offset=n._serverSubs[P].offset),n._serverSubs[P].epoch&&(Q.epoch=n._serverSubs[P].epoch),y[P]=Q}E&&(d.params||(d.params={}),d.params.subs=y),n._latencyStart=new Date,n._call(d).then(function(R){n._connectResponse(n._decoder.decodeCommandResult(n._methodType.CONNECT,R.result),E),R.next&&R.next()},function(R){var U=R.error;U.code===109&&(n._refreshRequired=!0),n._disconnect("connect error",!0),R.next&&R.next()})},this._transport.onerror=function(d){n._debug("transport level error",d)},this._transport.onclose=function(d){n._transportClosed=!0;var y=M,E=!0;if(d&&"reason"in d&&d.reason)try{var P=JSON.parse(d.reason);n._debug("reason is an advice object",P),y=P.reason,E=P.reconnect}catch{y=d.reason,n._debug("reason is a plain string",y)}if(n._config.onTransportClose!==null&&n._config.onTransportClose({event:d,reason:y,reconnect:E}),n._disconnect(y,E),n._reconnect===!0){n._reconnecting=!0;var Q=n._getRetryInterval();n._debug("reconnect after "+Q+" milliseconds"),setTimeout(function(){n._reconnect===!0&&(n._refreshRequired?n._refresh():n._connect())},Q)}},this._transport.onmessage=function(d){n._dataReceived(d.data)}}},{key:"rpc",value:function(n){return this._rpc("",n)}},{key:"namedRPC",value:function(n,r){return this._rpc(n,r)}},{key:"_rpc",value:function(n,r){var c={data:r};n!==""&&(c.method=n);var d={method:this._methodType.RPC,params:c};return this._methodCall(d,function(y){return y})}},{key:"send",value:function(n){var r={method:this._methodType.SEND,params:{data:n}};if(!this.isConnected())return Promise.reject(this._createErrorObject(M,0));var c=this._transportSend([r]);return c?Promise.resolve({}):Promise.reject(this._createErrorObject(M,0))}},{key:"_getHistoryParams",value:function(n,r){var c={channel:n};return r!==void 0&&(r.since&&(c.since={offset:r.since.offset},r.since.epoch&&(c.since.epoch=r.since.epoch)),r.limit!==void 0&&(c.limit=r.limit),r.reverse===!0&&(c.reverse=!0)),c}},{key:"_methodCall",value:function(n,r){var c=this;return this.isConnected()?new Promise(function(d,y){c._call(n).then(function(E){d(r(c._decoder.decodeCommandResult(n.method,E.result))),E.next&&E.next()},function(E){y(E.error),E.next&&E.next()})}):Promise.reject(this._createErrorObject(M,0))}},{key:"publish",value:function(n,r){var c={method:this._methodType.PUBLISH,params:{channel:n,data:r}};return this._methodCall(c,function(){return{}})}},{key:"history",value:function(n,r){var c=this._getHistoryParams(n,r),d={method:this._methodType.HISTORY,params:c};return this._methodCall(d,function(y){return{publications:y.publications,epoch:y.epoch||"",offset:y.offset||0}})}},{key:"presence",value:function(n){var r={method:this._methodType.PRESENCE,params:{channel:n}};return this._methodCall(r,function(c){return{presence:c.presence}})}},{key:"presenceStats",value:function(n){var r={method:this._methodType.PRESENCE_STATS,params:{channel:n}};return this._methodCall(r,function(c){return{num_users:c.num_users,num_clients:c.num_clients}})}},{key:"_dataReceived",value:function(n){var r=this,c=this._decoder.decodeReplies(n);this._dispatchPromise=this._dispatchPromise.then(function(){var d;r._dispatchPromise=new Promise(function(y){d=y}),r._dispatchSynchronized(c,d)}),this._restartPing()}},{key:"_dispatchSynchronized",value:function(n,r){var c=this,d=Promise.resolve(),y=function(Q){n.hasOwnProperty(Q)&&(d=d.then(function(){return c._dispatchReply(n[Q])}))};for(var E in n)y(E);d=d.then(function(){r()})}},{key:"_dispatchReply",value:function(n){var r,c=new Promise(function(y){r=y});if(n==null)return this._debug("dispatch: got undefined or null reply"),r(),c;var d=n.id;return d&&d>0?this._handleReply(n,r):this._handlePush(n.result,r),c}},{key:"_call",value:function(n){var r=this;return new Promise(function(c,d){var y=r._addMessage(n);r._registerCall(y,c,d)})}},{key:"_connect",value:function(){if(this.isConnected()){this._debug("connect called when already connected");return}this._status!=="connecting"&&(this._debug("start connecting"),this._setStatus("connecting"),this._clientID=null,this._reconnect=!0,this._setupTransport())}},{key:"_disconnect",value:function(n,r){var c=r||!1;if(c===!1&&(this._reconnect=!1),this._isDisconnected()){c||this._clearConnectedState(c);return}if(this._clearConnectedState(c),this._debug("disconnected:",n,r),this._setStatus("disconnected"),this._refreshTimeout&&(clearTimeout(this._refreshTimeout),this._refreshTimeout=null),this._reconnecting===!1){for(var d in this._serverSubs)this._serverSubs.hasOwnProperty(d)&&this.emit("unsubscribe",{channel:d});this.emit("disconnect",{reason:n,reconnect:c})}c===!1&&(this._subs={},this._serverSubs={}),this._transportClosed||this._transport.close()}},{key:"_refreshFailed",value:function(){this._numRefreshFailed=0,this._isDisconnected()||this._disconnect("refresh failed",!1),this._config.onRefreshFailed!==null&&this._config.onRefreshFailed()}},{key:"_refresh",value:function(){var n=this;if(this._debug("refresh token"),this._config.refreshAttempts===0){this._debug("refresh attempts set to 0, do not send refresh request at all"),this._refreshFailed();return}this._refreshTimeout!==null&&(clearTimeout(this._refreshTimeout),this._refreshTimeout=null);var r=this._clientID,c=this._newXHRID(),d=function(Q){if(c in n._xhrs&&delete n._xhrs[c],n._clientID===r){if(Q.error||Q.status!==200){if(Q.error?n._debug("error refreshing connection token",Q.error):n._debug("error refreshing connection token: wrong status code",Q.status),n._numRefreshFailed++,n._refreshTimeout!==null&&(clearTimeout(n._refreshTimeout),n._refreshTimeout=null),n._config.refreshAttempts!==null&&n._numRefreshFailed>=n._config.refreshAttempts){n._refreshFailed();return}var R=Math.round(Math.random()*1e3*Math.max(n._numRefreshFailed,20)),U=n._config.refreshInterval+R;n._refreshTimeout=setTimeout(function(){return n._refresh()},U);return}if(n._numRefreshFailed=0,n._token=Q.data.token,!n._token){n._refreshFailed();return}if(n._isDisconnected()&&n._reconnect)n._debug("token refreshed, connect from scratch"),n._connect();else{n._debug("send refreshed token");var H={method:n._methodType.REFRESH,params:{token:n._token}};n._call(H).then(function(D){n._refreshResponse(n._decoder.decodeCommandResult(n._methodType.REFRESH,D.result)),D.next&&D.next()},function(D){n._refreshError(D.error),D.next&&D.next()})}}};if(this._config.onRefresh!==null){var y={};this._config.onRefresh(y,d)}else{var E=this._ajax(this._config.refreshEndpoint,this._config.refreshParams,this._config.refreshHeaders,this._config.refreshData,d);this._xhrs[c]=E}}},{key:"_refreshError",value:function(n){var r=this;this._debug("refresh error",n),this._refreshTimeout&&(clearTimeout(this._refreshTimeout),this._refreshTimeout=null);var c=this._config.refreshInterval+Math.round(Math.random()*1e3);this._refreshTimeout=setTimeout(function(){return r._refresh()},c)}},{key:"_refreshResponse",value:function(n){var r=this;this._refreshTimeout&&(clearTimeout(this._refreshTimeout),this._refreshTimeout=null),n.expires&&(this._clientID=n.client,this._refreshTimeout=setTimeout(function(){return r._refresh()},this._getTTLMilliseconds(n.ttl)))}},{key:"_newXHRID",value:function(){return this._xhrID++,this._xhrID}},{key:"_subRefresh",value:function(n){var r=this;if(this._debug("refresh subscription token for channel",n),this._subRefreshTimeouts[n]!==void 0)this._clearSubRefreshTimeout(n);else return;var c=this._clientID,d=this._newXHRID(),y=function(R){if(d in r._xhrs&&delete r._xhrs[d],!(R.error||R.status!==200||r._clientID!==c)){var U={};if(R.data.channels)for(var H in R.data.channels){var D=R.data.channels[H];D.channel&&(U[D.channel]=D.token)}var ae=U[n];if(ae){var Ue={method:r._methodType.SUB_REFRESH,params:{channel:n,token:ae}},ke=r._getSub(n);ke!==null&&r._call(Ue).then(function(W){r._subRefreshResponse(n,r._decoder.decodeCommandResult(r._methodType.SUB_REFRESH,W.result)),W.next&&W.next()},function(W){r._subRefreshError(n,W.error),W.next&&W.next()})}}},E={client:this._clientID,channels:[n]};if(this._config.onPrivateSubscribe!==null)this._config.onPrivateSubscribe({data:E},y);else{var P=this._ajax(this._config.subscribeEndpoint,this._config.subscribeParams,this._config.subscribeHeaders,E,y);this._xhrs[d]=P}}},{key:"_clearSubRefreshTimeout",value:function(n){this._subRefreshTimeouts[n]!==void 0&&(clearTimeout(this._subRefreshTimeouts[n]),delete this._subRefreshTimeouts[n])}},{key:"_subRefreshError",value:function(n,r){var c=this;this._debug("subscription refresh error",n,r),this._clearSubRefreshTimeout(n);var d=this._getSub(n);if(d!==null){var y=Math.round(Math.random()*1e3),E=setTimeout(function(){return c._subRefresh(n)},this._config.subRefreshInterval+y);this._subRefreshTimeouts[n]=E}}},{key:"_subRefreshResponse",value:function(n,r){var c=this;this._debug("subscription refresh success",n),this._clearSubRefreshTimeout(n);var d=this._getSub(n);if(d!==null&&r.expires===!0){var y=setTimeout(function(){return c._subRefresh(n)},this._getTTLMilliseconds(r.ttl));this._subRefreshTimeouts[n]=y}}},{key:"_subscribe",value:function(n,r){var c=this;this._debug("subscribing on",n.channel);var d=n.channel;if(d in this._subs||(this._subs[d]=n),!this.isConnected()){n._setNew();return}n._setSubscribing(r);var y={method:this._methodType.SUBSCRIBE,params:{channel:d}};if(n._subscribeData&&(y.params.data=n._subscribeData),(0,b.startsWith)(d,this._config.privateChannelPrefix))this._isSubscribeBatching?this._privateChannels[d]=!0:(this.startSubscribeBatching(),this._subscribe(n),this.stopSubscribeBatching());else{var E=n._needRecover();if(E===!0){y.params.recover=!0;var P=this._getLastSeq(d),Q=this._getLastGen(d);if(P||Q)P&&(y.params.seq=P),Q&&(y.params.gen=Q);else{var R=this._getLastOffset(d);R&&(y.params.offset=R)}var U=this._getLastEpoch(d);U&&(y.params.epoch=U)}this._call(y).then(function(H){c._subscribeResponse(d,E,c._decoder.decodeCommandResult(c._methodType.SUBSCRIBE,H.result)),H.next&&H.next()},function(H){c._subscribeError(d,H.error),H.next&&H.next()})}}},{key:"_unsubscribe",value:function(n){delete this._subs[n.channel],delete this._lastOffset[n.channel],delete this._lastSeq[n.channel],delete this._lastGen[n.channel],this.isConnected()&&this._addMessage({method:this._methodType.UNSUBSCRIBE,params:{channel:n.channel}})}},{key:"_getTTLMilliseconds",value:function(n){return Math.min(n*1e3,2147483647)}},{key:"getSub",value:function(n){return this._getSub(n)}},{key:"_getSub",value:function(n){var r=this._subs[n];return r||null}},{key:"_isServerSub",value:function(n){return this._serverSubs[n]!==void 0}},{key:"_connectResponse",value:function(n,r){var c=this,d=this._reconnecting;if(this._reconnecting=!1,this._resetRetry(),this._refreshRequired=!1,!this.isConnected()){this._latencyStart!==null&&(this._latency=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(){return c._refresh()},this._getTTLMilliseconds(n.ttl))),this.startBatching(),this.startSubscribeBatching();for(var y in this._subs)if(this._subs.hasOwnProperty(y)){var E=this._subs[y];E._shouldResubscribe()&&this._subscribe(E,d)}this.stopSubscribeBatching(),this.stopBatching(),this._startPing();var P={client:n.client,transport:this._transportName,latency:this._latency};n.data&&(P.data=n.data),this.emit("connect",P),n.subs&&this._processServerSubs(n.subs)}}},{key:"_processServerSubs",value:function(n){for(var r in n)if(n.hasOwnProperty(r)){var c=n[r],d=this._serverSubs[r]!==void 0,y={channel:r,isResubscribe:d};y=this._expandSubscribeContext(y,c),this.emit("subscribe",y)}for(var E in n)if(n.hasOwnProperty(E)){var P=n[E];if(P.recovered){var Q=P.publications;if(Q&&Q.length>0){Q.length>1&&(!Q[0].offset||Q[0].offset>Q[1].offset)&&(Q=Q.reverse());for(var R in Q)Q.hasOwnProperty(R)&&this._handlePublication(E,Q[R])}}this._serverSubs[E]={seq:P.seq,gen:P.gen,offset:P.offset,epoch:P.epoch,recoverable:P.recoverable}}}},{key:"_stopPing",value:function(){this._pongTimeout!==null&&(clearTimeout(this._pongTimeout),this._pongTimeout=null),this._pingTimeout!==null&&(clearTimeout(this._pingTimeout),this._pingTimeout=null)}},{key:"_startPing",value:function(){var n=this;this._config.ping!==!0||this._config.pingInterval<=0||this.isConnected()&&(this._pingTimeout=setTimeout(function(){if(!n.isConnected()){n._stopPing();return}n.ping(),n._pongTimeout=setTimeout(function(){n._disconnect("no ping",!0)},n._config.pongWaitTimeout)},this._config.pingInterval))}},{key:"_restartPing",value:function(){this._stopPing(),this._startPing()}},{key:"_subscribeError",value:function(n,r){var c=this._getSub(n);if(c&&c._isSubscribing()){if(r.code===0&&r.message===x){this._disconnect("timeout",!0);return}c._setSubscribeError(r)}}},{key:"_expandSubscribeContext",value:function(n,r){var c=!1;"recovered"in r&&(c=r.recovered),n.recovered=c;var d=!1;"positioned"in r&&(d=r.positioned);var y="";"epoch"in r&&(y=r.epoch);var E=0;return"offset"in r&&(E=r.offset),d&&(n.streamPosition={offset:E,epoch:y}),r.data&&(n.data=r.data),n}},{key:"_subscribeResponse",value:function(n,r,c){var d=this,y=this._getSub(n);if(y&&y._isSubscribing()){y._setSubscribeSuccess(c);var E=c.publications;if(E&&E.length>0){E.length>=2&&!E[0].offset&&!E[1].offset&&(E=E.reverse());for(var P in E)E.hasOwnProperty(P)&&this._handlePublication(n,E[P])}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){var Q=setTimeout(function(){return d._subRefresh(n)},this._getTTLMilliseconds(c.ttl));this._subRefreshTimeouts[n]=Q}}}},{key:"_handleReply",value:function(n,r){var c=n.id,d=n.result;if(!(c in this._callbacks)){r();return}var y=this._callbacks[c];if(clearTimeout(this._callbacks[c].timeout),delete this._callbacks[c],(0,b.errorExists)(n)){var P=y.errback;if(!P){r();return}var Q=n.error;P({error:Q,next:r})}else{var E=y.callback;if(!E)return;E({result:d,next:r})}}},{key:"_handleJoin",value:function(n,r){var c={info:r.info},d=this._getSub(n);if(!d){this._isServerSub(n)&&(c.channel=n,this.emit("join",c));return}d.emit("join",c)}},{key:"_handleLeave",value:function(n,r){var c={info:r.info},d=this._getSub(n);if(!d){this._isServerSub(n)&&(c.channel=n,this.emit("leave",c));return}d.emit("leave",c)}},{key:"_handleUnsub",value:function(n,r){var c={},d=this._getSub(n);if(!d){this._isServerSub(n)&&(delete this._serverSubs[n],c.channel=n,this.emit("unsubscribe",c));return}d.unsubscribe(),r.resubscribe===!0&&d.subscribe()}},{key:"_handleSub",value:function(n,r){this._serverSubs[n]={seq:r.seq,gen:r.gen,offset:r.offset,epoch:r.epoch,recoverable:r.recoverable};var c={channel:n,isResubscribe:!1};c=this._expandSubscribeContext(c,r),this.emit("subscribe",c)}},{key:"_handlePublication",value:function(n,r){var c=this._getSub(n),d={data:r.data,seq:r.seq,gen:r.gen,offset:r.offset};if(r.info&&(d.info=r.info),!c){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),d.channel=n,this.emit("publish",d));return}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",d)}},{key:"_handleMessage",value:function(n){this.emit("message",n.data)}},{key:"_handlePush",value:function(n,r){var c=this._decoder.decodePush(n),d=0;"type"in c&&(d=c.type);var y=c.channel;if(d===this._pushType.PUBLICATION){var E=this._decoder.decodePushData(this._pushType.PUBLICATION,c.data);this._handlePublication(y,E)}else if(d===this._pushType.MESSAGE){var P=this._decoder.decodePushData(this._pushType.MESSAGE,c.data);this._handleMessage(P)}else if(d===this._pushType.JOIN){var Q=this._decoder.decodePushData(this._pushType.JOIN,c.data);this._handleJoin(y,Q)}else if(d===this._pushType.LEAVE){var R=this._decoder.decodePushData(this._pushType.LEAVE,c.data);this._handleLeave(y,R)}else if(d===this._pushType.UNSUBSCRIBE){var U=this._decoder.decodePushData(this._pushType.UNSUBSCRIBE,c.data);this._handleUnsub(y,U)}else if(d===this._pushType.SUBSCRIBE){var H=this._decoder.decodePushData(this._pushType.UNSUBSCRIBE,c.data);this._handleSub(y,H)}r()}},{key:"_flush",value:function(){var n=this._messages.slice(0);this._messages=[],this._transportSend(n)}},{key:"_ping",value:function(){var n=this,r={method:this._methodType.PING};this._call(r).then(function(c){n._pingResponse(n._decoder.decodeCommandResult(n._methodType.PING,c.result)),c.next&&c.next()},function(c){n._debug("ping error",c.error),c.next&&c.next()})}},{key:"_pingResponse",value:function(n){this.isConnected()&&(this._stopPing(),this._startPing())}},{key:"_getLastSeq",value:function(n){var r=this._lastSeq[n];return r||0}},{key:"_getLastOffset",value:function(n){var r=this._lastOffset[n];return r||0}},{key:"_getLastGen",value:function(n){var r=this._lastGen[n];return r||0}},{key:"_getLastEpoch",value:function(n){var r=this._lastEpoch[n];return r||""}},{key:"_createErrorObject",value:function(n,r){var c={message:n,code:r||0};return c}},{key:"_registerCall",value:function(n,r,c){var d=this;this._callbacks[n]={callback:r,errback:c,timeout:null},this._callbacks[n].timeout=setTimeout(function(){delete d._callbacks[n],(0,b.isFunction)(c)&&c({error:d._createErrorObject(x)})},this._config.timeout)}},{key:"_addMessage",value:function(n){var r=this._nextMessageId();return n.id=r,this._isBatching===!0?this._messages.push(n):this._transportSend([n]),r}},{key:"isConnected",value:function(){return this._isConnected()}},{key:"connect",value:function(){this._connect()}},{key:"disconnect",value:function(){this._disconnect("client",!1)}},{key:"ping",value:function(){return this._ping()}},{key:"startBatching",value:function(){this._isBatching=!0}},{key:"stopBatching",value:function(){this._isBatching=!1,this._flush()}},{key:"startSubscribeBatching",value:function(){this._isSubscribeBatching=!0}},{key:"stopSubscribeBatching",value:function(){var n=this;this._isSubscribeBatching=!1;var r=this._privateChannels;this._privateChannels={};var c=[];for(var d in r)if(r.hasOwnProperty(d)){var y=this._getSub(d);if(!y)continue;c.push(d)}if(c.length===0){this._debug("no private channels found, no need to make request");return}var E={client:this._clientID,channels:c},P=this._clientID,Q=this._newXHRID(),R=function(D){if(Q in n._xhrs&&delete n._xhrs[Q],n._clientID===P){if(D.error||D.status!==200){n._debug("authorization request failed");for(var ae in c)if(c.hasOwnProperty(ae)){var Ue=c[ae];n._subscribeError(Ue,n._createErrorObject("authorization request failed"))}return}var ke={};if(D.data.channels)for(var W in D.data.channels){var He=D.data.channels[W];He.channel&&(ke[He.channel]=He.token)}var ft=!1;n._isBatching||(n.startBatching(),ft=!0);for(var gt in c)if(c.hasOwnProperty(gt)){var vn=(function(){var K=c[gt],pt=ke[K];if(pt){var ce={method:n._methodType.SUBSCRIBE,params:{channel:K,token:pt}},Ct=n._getSub(K);if(Ct===null)return"continue";var yt=Ct._needRecover();if(yt===!0){ce.params.recover=!0;var xe=n._getLastSeq(K),Fe=n._getLastGen(K);if(xe||Fe)xe&&(ce.params.seq=xe),Fe&&(ce.params.gen=Fe);else{var mt=n._getLastOffset(K);mt&&(ce.params.offset=mt)}var bt=n._getLastEpoch(K);bt&&(ce.params.epoch=bt)}n._call(ce).then(function(re){n._subscribeResponse(K,yt,n._decoder.decodeCommandResult(n._methodType.SUBSCRIBE,re.result)),re.next&&re.next()},function(re){n._subscribeError(K,re.error),re.next&&re.next()})}else return n._subscribeError(K,n._createErrorObject("permission denied",103)),"continue"})();if(vn==="continue")continue}ft&&n.stopBatching()}};if(this._config.onPrivateSubscribe!==null)this._config.onPrivateSubscribe({data:E},R);else{var U=this._ajax(this._config.subscribeEndpoint,this._config.subscribeParams,this._config.subscribeHeaders,E,R);this._xhrs[Q]=U}}},{key:"_setSubscribeSince",value:function(n,r){this._lastOffset[n.channel]=r.offset,this._lastEpoch[n.channel]=r.epoch,n._setNeedRecover(!0)}},{key:"subscribe",value:function(n,r,c){var d=this._getSub(n);if(d!==null)return d._setEvents(r),d._isUnsubscribed()&&d.subscribe(c),d;var y=new k.default(this,n,r);return this._subs[n]=y,y.subscribe(c),y}}]),p})(C.default);l.Centrifuge=m}),579:(function(a,l,f){Object.defineProperty(l,"__esModule",{value:!0}),l.default=void 0;var C=f(382),k=C.Centrifuge;l.default=k,a.exports=l.default}),147:(function(a,l){Object.defineProperty(l,"__esModule",{value:!0}),l.JsonPushType=l.JsonMethodType=l.JsonEncoder=l.JsonDecoder=void 0;function f(I,w){if(!(I instanceof w))throw new TypeError("Cannot call a class as a function")}function C(I,w){for(var B=0;B<w.length;B++){var v=w[B];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(I,v.key,v)}}function k(I,w,B){return w&&C(I.prototype,w),I}var _={CONNECT:0,SUBSCRIBE:1,UNSUBSCRIBE:2,PUBLISH:3,PRESENCE:4,PRESENCE_STATS:5,HISTORY:6,PING:7,SEND:8,RPC:9,REFRESH:10,SUB_REFRESH:11};l.JsonMethodType=_;var b={PUBLICATION:0,JOIN:1,LEAVE:2,UNSUBSCRIBE:3,MESSAGE:4,SUBSCRIBE:5};l.JsonPushType=b;var S=(function(){function I(){f(this,I)}return k(I,[{key:"encodeCommands",value:function(B){return B.map(function(v){return JSON.stringify(v)}).join(`
3
3
  `)}}]),I})();l.JsonEncoder=S;var T=(function(){function I(){f(this,I)}return k(I,[{key:"decodeReplies",value:function(B){return B.split(`
4
- `).filter(function(v){return v!==""}).map(function(v){return JSON.parse(v)})}},{key:"decodeCommandResult",value:function(B,v){return v}},{key:"decodePush",value:function(B){return B}},{key:"decodePushData",value:function(B,v){return v}}]),I})();l.JsonDecoder=T}),471:(function(a,l,f){function C(h){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?C=function(A){return typeof A}:C=function(A){return A&&typeof Symbol=="function"&&A.constructor===Symbol&&A!==Symbol.prototype?"symbol":typeof A},C(h)}Object.defineProperty(l,"__esModule",{value:!0}),l.default=void 0;var k=b(f(187)),_=f(853);function b(h){return h&&h.__esModule?h:{default:h}}function S(h,p){if(!(h instanceof p))throw new TypeError("Cannot call a class as a function")}function T(h,p){for(var A=0;A<p.length;A++){var n=p[A];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(h,n.key,n)}}function I(h,p,A){return p&&T(h.prototype,p),h}function w(h,p){if(typeof p!="function"&&p!==null)throw new TypeError("Super expression must either be null or a function");h.prototype=Object.create(p&&p.prototype,{constructor:{value:h,writable:!0,configurable:!0}}),p&&B(h,p)}function B(h,p){return B=Object.setPrototypeOf||function(n,r){return n.__proto__=r,n},B(h,p)}function v(h){var p=F();return function(){var n=N(h),r;if(p){var c=N(this).constructor;r=Reflect.construct(n,arguments,c)}else r=n.apply(this,arguments);return L(this,r)}}function L(h,p){if(p&&(C(p)==="object"||typeof p=="function"))return p;if(p!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return O(h)}function O(h){if(h===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return h}function F(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function N(h){return N=Object.setPrototypeOf?Object.getPrototypeOf:function(A){return A.__proto__||Object.getPrototypeOf(A)},N(h)}var q=0,J=1,x=2,M=3,m=4,g=(function(h){w(A,h);var p=v(A);function A(n,r,c){var d;return S(this,A),d=p.call(this),d.channel=r,d._centrifuge=n,d._status=q,d._error=null,d._isResubscribe=!1,d._ready=!1,d._subscriptionPromise=null,d._noResubscribe=!1,d._recoverable=!1,d._recover=!1,d._setEvents(c),d._initializePromise(),d._promises={},d._promiseId=0,d._subscribeData=null,d.on("error",function(y){this._centrifuge._debug("subscription error",y)}),d}return I(A,[{key:"_nextPromiseId",value:function(){return++this._promiseId}},{key:"_initializePromise",value:function(){var r=this;this._ready=!1,this._subscriptionPromise=new Promise(function(c,d){r._resolve=function(y){r._ready=!0,c(y)},r._reject=function(y){r._ready=!0,d(y)}}).then(function(){},function(){})}},{key:"_setNeedRecover",value:function(r){this._recoverable=r,this._recover=r}},{key:"_needRecover",value:function(){return this._recoverable===!0&&this._recover===!0}},{key:"_setEvents",value:function(r){if(r){if((0,_.isFunction)(r))this.on("publish",r);else if(Object.prototype.toString.call(r)===Object.prototype.toString.call({}))for(var c=["publish","join","leave","unsubscribe","subscribe","error"],d=0,y=c.length;d<y;d++){var E=c[d];E in r&&this.on(E,r[E])}}}},{key:"_isNew",value:function(){return this._status===q}},{key:"_isUnsubscribed",value:function(){return this._status===m}},{key:"_isSubscribing",value:function(){return this._status===J}},{key:"_isReady",value:function(){return this._status===x||this._status===M}},{key:"_isSuccess",value:function(){return this._status===x}},{key:"_isError",value:function(){return this._status===M}},{key:"_setNew",value:function(){this._status=q}},{key:"_setSubscribing",value:function(r){this._isResubscribe=r||!1,this._ready===!0&&this._initializePromise(),this._status=J}},{key:"_setSubscribeSuccess",value:function(r){if(this._status!==x){this._status=x;var c=this._getSubscribeSuccessContext(r);this._recover=!1,this.emit("subscribe",c),this._resolve(c);for(var d in this._promises)clearTimeout(this._promises[d].timeout),this._promises[d].resolve(),delete this._promises[d]}}},{key:"_setSubscribeError",value:function(r){if(this._status!==M){this._status=M,this._error=r;var c=this._getSubscribeErrorContext();this.emit("error",c),this._reject(c);for(var d in this._promises)clearTimeout(this._promises[d].timeout),this._promises[d].reject(r),delete this._promises[d]}}},{key:"_triggerUnsubscribe",value:function(){this.emit("unsubscribe",{channel:this.channel})}},{key:"_setUnsubscribed",value:function(r){if(this._centrifuge._clearSubRefreshTimeout(this.channel),this._status!==m){var c=this._status===x;this._status=m,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()}}},{key:"_shouldResubscribe",value:function(){return!this._noResubscribe}},{key:"_getSubscribeSuccessContext",value:function(r){var c={channel:this.channel,isResubscribe:this._isResubscribe};return r&&(c=this._centrifuge._expandSubscribeContext(c,r)),c}},{key:"_getSubscribeErrorContext",value:function(){var r=this._error;return r.channel=this.channel,r.isResubscribe=this._isResubscribe,r}},{key:"_setSubscribeData",value:function(r){this._subscribeData=r}},{key:"ready",value:function(r,c){this._ready&&(this._isSuccess()?r(this._getSubscribeSuccessContext()):c(this._getSubscribeErrorContext()))}},{key:"subscribe",value:function(r){this._status!==x&&(r&&r.since&&this._centrifuge._setSubscribeSince(this,r.since),r&&r.data&&this._setSubscribeData(r.data),this._noResubscribe=!1,this._centrifuge._subscribe(this))}},{key:"unsubscribe",value:function(){this._setUnsubscribed(!0),this._centrifuge._unsubscribe(this)}},{key:"_methodCall",value:function(){var r=this;if(this._isSuccess())return Promise.resolve();if(this._isError())return Promise.reject(this._error);var c=new Promise(function(d,y){var E=setTimeout(function(){y({code:0,message:"timeout"})},r._centrifuge._config.timeout);r._promises[r._nextPromiseId()]={timeout:E,resolve:d,reject:y}});return c}},{key:"publish",value:function(r){var c=this;return this._methodCall().then(function(){return c._centrifuge.publish(c.channel,r)})}},{key:"presence",value:function(){var r=this;return this._methodCall().then(function(){return r._centrifuge.presence(r.channel)})}},{key:"presenceStats",value:function(){var r=this;return this._methodCall().then(function(){return r._centrifuge.presenceStats(r.channel)})}},{key:"history",value:function(r){var c=this;return this._methodCall().then(function(){return c._centrifuge.history(c.channel,r)})}}]),A})(k.default);l.default=g,a.exports=l.default}),853:(function(a,l,f){Object.defineProperty(l,"__esModule",{value:!0}),l.backoff=b,l.errorExists=S,l.extend=T,l.isFunction=k,l.log=_,l.startsWith=C;function C(I,w){return I.lastIndexOf(w,0)===0}function k(I){return I==null?!1:typeof I=="function"}function _(I,w){if(f.g.console){var B=f.g.console[I];k(B)&&B.apply(f.g.console,w)}}function b(I,w,B){var v=.5*Math.random(),L=Math.min(B,w*Math.pow(2,I+1));return Math.floor((1-v)*L)}function S(I){return"error"in I&&I.error!==null}function T(I,w){for(var B in w)w.hasOwnProperty(B)&&(I[B]=w[B]);return I}}),187:(function(a){var l=typeof Reflect=="object"?Reflect:null,f=l&&typeof l.apply=="function"?l.apply:function(g,h,p){return Function.prototype.apply.call(g,h,p)},C;l&&typeof l.ownKeys=="function"?C=l.ownKeys:Object.getOwnPropertySymbols?C=function(g){return Object.getOwnPropertyNames(g).concat(Object.getOwnPropertySymbols(g))}:C=function(g){return Object.getOwnPropertyNames(g)};function k(m){console&&console.warn&&console.warn(m)}var _=Number.isNaN||function(g){return g!==g};function b(){b.init.call(this)}a.exports=b,a.exports.once=J,b.EventEmitter=b,b.prototype._events=void 0,b.prototype._eventsCount=0,b.prototype._maxListeners=void 0;var S=10;function T(m){if(typeof m!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof m)}Object.defineProperty(b,"defaultMaxListeners",{enumerable:!0,get:function(){return S},set:function(m){if(typeof m!="number"||m<0||_(m))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+m+".");S=m}}),b.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},b.prototype.setMaxListeners=function(g){if(typeof g!="number"||g<0||_(g))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+g+".");return this._maxListeners=g,this};function I(m){return m._maxListeners===void 0?b.defaultMaxListeners:m._maxListeners}b.prototype.getMaxListeners=function(){return I(this)},b.prototype.emit=function(g){for(var h=[],p=1;p<arguments.length;p++)h.push(arguments[p]);var A=g==="error",n=this._events;if(n!==void 0)A=A&&n.error===void 0;else if(!A)return!1;if(A){var r;if(h.length>0&&(r=h[0]),r instanceof Error)throw r;var c=new Error("Unhandled error."+(r?" ("+r.message+")":""));throw c.context=r,c}var d=n[g];if(d===void 0)return!1;if(typeof d=="function")f(d,this,h);else for(var y=d.length,E=F(d,y),p=0;p<y;++p)f(E[p],this,h);return!0};function w(m,g,h,p){var A,n,r;if(T(h),n=m._events,n===void 0?(n=m._events=Object.create(null),m._eventsCount=0):(n.newListener!==void 0&&(m.emit("newListener",g,h.listener?h.listener:h),n=m._events),r=n[g]),r===void 0)r=n[g]=h,++m._eventsCount;else if(typeof r=="function"?r=n[g]=p?[h,r]:[r,h]:p?r.unshift(h):r.push(h),A=I(m),A>0&&r.length>A&&!r.warned){r.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+r.length+" "+String(g)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=m,c.type=g,c.count=r.length,k(c)}return m}b.prototype.addListener=function(g,h){return w(this,g,h,!1)},b.prototype.on=b.prototype.addListener,b.prototype.prependListener=function(g,h){return w(this,g,h,!0)};function B(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function v(m,g,h){var p={fired:!1,wrapFn:void 0,target:m,type:g,listener:h},A=B.bind(p);return A.listener=h,p.wrapFn=A,A}b.prototype.once=function(g,h){return T(h),this.on(g,v(this,g,h)),this},b.prototype.prependOnceListener=function(g,h){return T(h),this.prependListener(g,v(this,g,h)),this},b.prototype.removeListener=function(g,h){var p,A,n,r,c;if(T(h),A=this._events,A===void 0)return this;if(p=A[g],p===void 0)return this;if(p===h||p.listener===h)--this._eventsCount===0?this._events=Object.create(null):(delete A[g],A.removeListener&&this.emit("removeListener",g,p.listener||h));else if(typeof p!="function"){for(n=-1,r=p.length-1;r>=0;r--)if(p[r]===h||p[r].listener===h){c=p[r].listener,n=r;break}if(n<0)return this;n===0?p.shift():N(p,n),p.length===1&&(A[g]=p[0]),A.removeListener!==void 0&&this.emit("removeListener",g,c||h)}return this},b.prototype.off=b.prototype.removeListener,b.prototype.removeAllListeners=function(g){var h,p,A;if(p=this._events,p===void 0)return this;if(p.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):p[g]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete p[g]),this;if(arguments.length===0){var n=Object.keys(p),r;for(A=0;A<n.length;++A)r=n[A],r!=="removeListener"&&this.removeAllListeners(r);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(h=p[g],typeof h=="function")this.removeListener(g,h);else if(h!==void 0)for(A=h.length-1;A>=0;A--)this.removeListener(g,h[A]);return this};function L(m,g,h){var p=m._events;if(p===void 0)return[];var A=p[g];return A===void 0?[]:typeof A=="function"?h?[A.listener||A]:[A]:h?q(A):F(A,A.length)}b.prototype.listeners=function(g){return L(this,g,!0)},b.prototype.rawListeners=function(g){return L(this,g,!1)},b.listenerCount=function(m,g){return typeof m.listenerCount=="function"?m.listenerCount(g):O.call(m,g)},b.prototype.listenerCount=O;function O(m){var g=this._events;if(g!==void 0){var h=g[m];if(typeof h=="function")return 1;if(h!==void 0)return h.length}return 0}b.prototype.eventNames=function(){return this._eventsCount>0?C(this._events):[]};function F(m,g){for(var h=new Array(g),p=0;p<g;++p)h[p]=m[p];return h}function N(m,g){for(;g+1<m.length;g++)m[g]=m[g+1];m.pop()}function q(m){for(var g=new Array(m.length),h=0;h<g.length;++h)g[h]=m[h].listener||m[h];return g}function J(m,g){return new Promise(function(h,p){function A(r){m.removeListener(g,n),p(r)}function n(){typeof m.removeListener=="function"&&m.removeListener("error",A),h([].slice.call(arguments))}M(m,g,n,{once:!0}),g!=="error"&&x(m,A,{once:!0})})}function x(m,g,h){typeof m.on=="function"&&M(m,"error",g,h)}function M(m,g,h,p){if(typeof m.on=="function")p.once?m.once(g,h):m.on(g,h);else if(typeof m.addEventListener=="function")m.addEventListener(g,function A(n){p.once&&m.removeEventListener(g,A),h(n)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof m)}})},i={};function s(a){var l=i[a];if(l!==void 0)return l.exports;var f=i[a]={exports:{}};return o[a](f,f.exports,s),f.exports}(function(){s.g=(function(){if(typeof globalThis=="object")return globalThis;try{return this||new Function("return this")()}catch{if(typeof window=="object")return window}})()})();var u=s(579);return u})()})})(ye)),ye.exports}var kt=Pt();const wt=Qt(kt);let me=null;function We(e,t){if(!(e!=null&&e.client_url)||!(e!=null&&e.token)||!(e!=null&&e.channel))return console.error("[Centrifuge] Invalid socket_connections"),null;const{client_url:o,token:i,channel:s}=e;if(s.includes("#")||console.warn("[Centrifuge] Channel should contain #user_id"),me){try{console.log("[Centrifuge] Disconnecting previous instance..."),me.disconnect()}catch(a){console.error("[Centrifuge] Error while disconnecting previous instance:",a)}me=null}console.log("[Centrifuge] Creating new instance:",o);const u=new wt(o);return u.setToken(i),u.on("connect",a=>{console.log("[Centrifuge] Connected",a),console.log("[Centrifuge] Subscribing to channel:",s);const l=u.subscribe(s);l.on("publish",f=>{console.log("[Centrifuge] Publish event received:",f);const C=_t(f);C&&t(C)}),l.on("subscribe",f=>{console.log("[Centrifuge] ✅ Channel subscribed successfully:",s,f)}),l.on("error",f=>{console.error("[Centrifuge] ❌ Subscription error:",f)}),l.on("unsubscribe",f=>{console.log("[Centrifuge] Channel unsubscribed:",f)})}),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(),me=u,{centrifuge:u}}function _t(e){var o,i,s;if(console.log("[Centrifuge] Raw message received:",JSON.stringify(e)),!(e!=null&&e.data))return console.warn("[Centrifuge] Empty or invalid response"),null;let t=e.data;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)}function be(e){return/^4[0-9]/.test(e)?"visa":/^5[1-5]/.test(e)||/^2[2-7]/.test(e)?"mastercard":"card"}const $={iconType:"kaspi_pay",label:"Kaspi.kz",type:"kaspi_pay"},Ve={iconType:"apple_pay",label:"Apple Pay",type:"apple_pay"},Ye={iconType:"google_pay",label:"Google Pay",type:"google_pay"};function z(e){return e==="enabled"||e===!0}function Ge(e){if(!e)return null;let t=String(e).trim().toLowerCase();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}function Tt(e){var u,a,l;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);if(!o)return null;if(typeof o=="string")return{type:Ge(o),cardId:null};if(typeof o!="object")return null;const i=o.type??o.payment_method??o.method,s=o.card_id??o.cardId??o.id??((l=o.card)==null?void 0:l.id)??null;return{type:Ge(i),cardId:s!=null?String(s):null}}function Lt(e,t,o={}){var w,B,v,L;const i=[],s=(w=e==null?void 0:e.kaspi)==null?void 0:w.data,u=((B=e==null?void 0:e.cards_v2)==null?void 0:B.data)||[],a=((L=(v=e==null?void 0:e.payment_methods)==null?void 0:v.data)==null?void 0:L.attributes)||{},l=z(a.payment_method_kaspi),f=z(a.payment_method_card),C=typeof window<"u"&&window.self===window.top,_=we()==="ios",b=!!(o!=null&&o.onlyKaspiAvailable),S=!!(o!=null&&o.disableKaspi);return s!=null&&s.isKaspiOnly&&l&&!S?[$]:b?s!=null&&s.isAvailable&&l&&!S?[$]:[]:(z(a.payment_method_apple_pay)&&!Ce("apple_pay")&&(ge()&&C||pe()||_||ze()===16)&&i.push(Ve),s!=null&&s.isAvailable&&l&&!S&&i.push($),f&&u.filter(O=>!O.isExpired).forEach(O=>{i.push({iconType:be(O.attributes.mask),type:"card",cardId:O.id,label:`•••• ${O.attributes.mask.slice(-4)}`,cardType:O.type,isDefault:O.attributes.isDefault})}),z(a.payment_method_google_pay)&&!Ce("google_pay")&&!(o!=null&&o.disableGooglePay)&&!ge()&&!pe()&&i.push(Ye),z(a.payment_method_new_card)&&i.push({iconType:"new_card",type:"new_card",label:t?t("newCard"):"Оплата новой картой"}),i)}function _e(e,t={}){var I,w,B,v;const o=(I=e==null?void 0:e.kaspi)==null?void 0:I.data,i=((w=e==null?void 0:e.cards_v2)==null?void 0:w.data)||[],s=((v=(B=e==null?void 0:e.payment_methods)==null?void 0:B.data)==null?void 0:v.attributes)||{},u=z(s.payment_method_kaspi),a=z(s.payment_method_card),l=!!(t!=null&&t.disableKaspi),f=typeof window<"u"&&window.self===window.top,k=we()==="ios",_=z(s.payment_method_apple_pay)&&!Ce("apple_pay")&&(ge()&&f||pe()||k||ze()===16),b=z(s.payment_method_google_pay)&&!Ce("google_pay")&&!(t!=null&&t.disableGooglePay)&&!ge()&&!pe();if(o!=null&&o.isKaspiOnly&&u&&!l||t!=null&&t.onlyKaspiAvailable&&(o!=null&&o.isAvailable)&&u&&!l)return $;const S=Tt(e);if((S==null?void 0:S.type)==="kaspi_pay"&&(o!=null&&o.isAvailable)&&u&&!l)return $;if((S==null?void 0:S.type)==="apple_pay"&&_)return Ve;if((S==null?void 0:S.type)==="google_pay"&&b)return Ye;if((S==null?void 0:S.type)==="new_card"&&z(s.payment_method_new_card))return{iconType:"new_card",type:"new_card",label:"Оплата новой картой"};if((S==null?void 0:S.type)==="card"&&a){const L=S.cardId!=null?i.find(O=>!O.isExpired&&String(O.id)===S.cardId):null;if(L)return{iconType:be(L.attributes.mask),type:"card",cardId:L.id,label:`•••• ${L.attributes.mask.slice(-4)}`,cardType:L.type}}if(a){const L=i.find(O=>{var F;return((F=O.attributes)==null?void 0:F.isDefault)&&!O.isExpired});if(L)return{iconType:be(L.attributes.mask),type:"card",cardId:L.id,label:`•••• ${L.attributes.mask.slice(-4)}`,cardType:L.type}}if(o!=null&&o.isAvailable&&u&&!l)return $;const T=a?i.find(L=>!L.isExpired):null;return T?{iconType:be(T.attributes.mask),type:"card",cardId:T.id,label:`••••${T.attributes.mask.slice(-4)}`,cardType:T.type}:null}function Ze(e){if(typeof localStorage>"u")return null;try{return localStorage.getItem(e)}catch{return null}}function Te(e,t){if(!(typeof localStorage>"u"))try{localStorage.setItem(e,t)}catch{}}function Ee(e){if(!(typeof localStorage>"u"))try{localStorage.removeItem(e)}catch{}}async function Rt(e,t){var o;try{const i=await e.json(),s=(o=i==null?void 0:i.errors)==null?void 0:o[0];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}catch{return`HTTP ${e.status}: ${e.statusText}`}}async function Y(e,t){const o=await Rt(e,t);throw Object.assign(new Error(o),{status:e.status})}function ve(e,t,o={}){const i=Number.isFinite(o.checkoutAmount)&&o.checkoutAmount>=0?Number(o.checkoutAmount):e.amount,s=!!o.forceBalanceMethod,u=!!o.useBalance,a=o.voucher;return{checkoutAmount:i,checkoutPaymentMethod:s?{type:"balance"}:t,useBalanceFlag:u,voucher:a}}function Be(e,t,o,i,s){return{preorder_id:e.preorderId,terminal_id:e.terminalId,merchant_order_id:e.merchantOrderId,money:{amount:String(o),currency:e.currency},payment_method:t,...e.backlink&&{backlink:e.backlink},...i&&{use_balance:!0},...s&&{voucher:s}}}async function Ie(e,t,o,i,s){const u=await fetch(`${e}/orders/v1/checkout`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t.accessToken}`,"X-Idempotency-Key":t.idempotencyKey??fe(),"X-Device-Id":o,"X-OS":"WEB"},body:JSON.stringify(i)});return u.ok||await Y(u,s),u.json()}async function Ot(e,t,o){var l,f,C,k;const i=await fetch(`${e}/api/v2/oauth2/tokens`,{method:"POST",headers:{"Content-Type":"application/json","X-Idempotency-Key":fe(),"X-Fingerprint":je()},body:JSON.stringify({client_id:t,grant_type:"authorization_track_id",track_id:o})});i.ok||await Y(i,"Не удалось авторизоваться через track_id");const s=await i.json(),u=(s==null?void 0:s.access_token)??((f=(l=s==null?void 0:s.data)==null?void 0:l.attributes)==null?void 0:f.access_token),a=(s==null?void 0:s.refresh_token)??((k=(C=s==null?void 0:s.data)==null?void 0:C.attributes)==null?void 0:k.refresh_token)??null;if(!u)throw new Error("В ответе отсутствует access_token");return{access_token:u,refresh_token:a}}async function Mt(e,t,o){var l,f,C,k;const i=await fetch(`${e}/api/v2/oauth2/tokens`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:t,grant_type:"refresh_token",refresh_token:o})});i.ok||await Y(i,"Не удалось обновить токен по refresh_token");const s=await i.json(),u=(s==null?void 0:s.access_token)??((f=(l=s==null?void 0:s.data)==null?void 0:l.attributes)==null?void 0:f.access_token),a=(s==null?void 0:s.refresh_token)??((k=(C=s==null?void 0:s.data)==null?void 0:C.attributes)==null?void 0:k.refresh_token)??null;if(!u)throw new Error("В ответе отсутствует access_token");return{access_token:u,refresh_token:a}}async function Le(e,t){const o=await fetch(`${e}/orders/v1/checkout/context`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t.accessToken}`,"X-Idempotency-Key":fe()},body:JSON.stringify({terminal_id:t.terminalId,include:["cards","payment_methods","balance","cashback"],money:{amount:String(t.amount),currency:t.currency}})});return o.ok||await Y(o,"Ошибка получения контекста оплаты"),o.json()}async function Nt(e,t,o){const i=await fetch(`${e}/payment-gateway/v1/cards/${o}`,{method:"DELETE",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t.accessToken}`}});return i.ok||await Y(i,"Не удалось удалить карту"),i.json().catch(()=>({}))}async function Dt(e,t,o){const i=await fetch(`${e}/payment-gateway/v1/cards/${o}/mark_as_default`,{method:"PUT",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t.accessToken}`}});return i.ok||await Y(i,"Не удалось отметить карту как основную"),i.json().catch(()=>({}))}async function Xt(e,t,o){const i=await fetch(`${e}/orders/v1/orders/${o}/status`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t.accessToken}`}});if(!i.ok)throw Object.assign(new Error(`Ошибка проверки статуса заказа: ${i.status} ${i.statusText}`),{status:i.status});const s=await i.json(),u=(s==null?void 0:s.data)??s;return{data:{status:u==null?void 0:u.status,payload:(u==null?void 0:u.payload)??{}}}}async function $e(e,t,o,i,s={}){const{checkoutAmount:u,checkoutPaymentMethod:a,useBalanceFlag:l,voucher:f}=ve(t,{type:i.type,...i.cardId&&{card_id:i.cardId}},s);return Ie(e,t,o,Be(t,a,u,l,f),"Ошибка создания заказа")}async function Ut(e,t,o,i={}){const{checkoutAmount:s,checkoutPaymentMethod:u,useBalanceFlag:a,voucher:l}=ve(t,{type:"new_card"},i);return Ie(e,t,o,Be(t,u,s,a,l),"Ошибка создания заказа для новой карты")}async function Ht(e,t){const o=await fetch(`${e}/loyalty/v6/coupons/by_terminal/${t.terminalId}/at_payment?order_pay_amount=${t.amount}`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t.accessToken}`}});return o.ok||await Y(o,"Ошибка получения купонов"),o.json()}async function xt(e,t,o){const i=window.location.hostname,s=await fetch(`${e}/payment-gateway/v1/apple/session`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/vnd.api+json",Authorization:`Bearer ${t.accessToken}`},body:JSON.stringify({validationUrl:o,domainName:i})});return s.ok||await Y(s,"Ошибка получения Apple Pay сессии"),s.json()}async function Ft(e,t,o,i,s={}){const{checkoutAmount:u,checkoutPaymentMethod:a,useBalanceFlag:l,voucher:f}=ve(t,{type:"apple_pay",data:i},s);return Ie(e,t,o,Be(t,a,u,l,f),"Ошибка создания заказа с Apple Pay")}async function et(e,t,o,i,s={}){const{checkoutAmount:u,checkoutPaymentMethod:a,useBalanceFlag:l,voucher:f}=ve(t,{type:"google_pay",data:i},s);return Ie(e,t,o,Be(t,a,u,l,f),"Ошибка создания заказа с Google Pay")}function Jt(e){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)?{availableBonus:Number.isFinite(i.availableBonus)?Number(i.availableBonus):0,amount:Number(i.amount),percent:Number(i.percent)}:null;return{preorderId:e.preorderId,trackId:e.trackId,clientId:e.clientId,terminalId:e.terminalId,merchantOrderId:e.merchantOrderId,amount:e.amount,currency:e.currency||"KZT",environment:e.environment||"production",backlink:e.backlink,onSuccess:e.onSuccess||(()=>{}),onAppliedBonus:e.onAppliedBonus||(()=>{}),onError:e.onError||(()=>{}),onCancel:e.onCancel||(()=>{}),onCardDeleted:typeof e.onCardDeleted=="function"?e.onCardDeleted:null,onConfirmPay:typeof e.onConfirmPay=="function"?e.onConfirmPay:null,onPaymentMethodSelected:typeof e.onPaymentMethodSelected=="function"?e.onPaymentMethodSelected:null,onKaspiLink:typeof e.onKaspiLink=="function"?e.onKaspiLink:null,onPayWithGooglePay:typeof e.onPayWithGooglePay=="function"?e.onPayWithGooglePay:null,onUserEvent:typeof e.onUserEvent=="function"?e.onUserEvent:null,onBeforeCheckout:typeof e.onBeforeCheckout=="function"?e.onBeforeCheckout:null,idempotencyKey:e.idempotencyKey,locale:e.locale||"ru",containerSelector:typeof e.containerSelector=="string"?e.containerSelector.trim():"",color:o||"#2F2F2F",onlyKaspiAvailable:!!e.onlyKaspiAvailable,disableKaspi:!!e.disableKaspi,disableGooglePay:!!e.disableGooglePay,isNativeAndroid:!!e.isNativeAndroid,bonuses:s}}function Re(e,t){Te("webPayToken",e),t&&Te("webPayRefreshToken",t)}function tt(){Ee("webPayToken"),Ee("webPayRefreshToken")}async function qt(e){const t=Ze("webPayRefreshToken");if(t&&e.config.clientId)try{const i=await Mt(e.apiUrl,e.config.clientId,t);Re(i.access_token,i.refresh_token),e.accessToken=i.access_token;return}catch{Ee("webPayRefreshToken")}if(!e.config.trackId||!e.config.clientId){e.config.onError({attributes:{message:e.t("errorMissingTrackClient")}});return}const o=await Ot(e.apiUrl,e.config.clientId,e.config.trackId);Re(o.access_token,o.refresh_token),e.accessToken=o.access_token}const jt={kaspi_pay:`<svg width="17" height="16" viewBox="0 0 17 16" fill="none" xmlns="http://www.w3.org/2000/svg">
4
+ `).filter(function(v){return v!==""}).map(function(v){return JSON.parse(v)})}},{key:"decodeCommandResult",value:function(B,v){return v}},{key:"decodePush",value:function(B){return B}},{key:"decodePushData",value:function(B,v){return v}}]),I})();l.JsonDecoder=T}),471:(function(a,l,f){function C(h){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?C=function(A){return typeof A}:C=function(A){return A&&typeof Symbol=="function"&&A.constructor===Symbol&&A!==Symbol.prototype?"symbol":typeof A},C(h)}Object.defineProperty(l,"__esModule",{value:!0}),l.default=void 0;var k=b(f(187)),_=f(853);function b(h){return h&&h.__esModule?h:{default:h}}function S(h,p){if(!(h instanceof p))throw new TypeError("Cannot call a class as a function")}function T(h,p){for(var A=0;A<p.length;A++){var n=p[A];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(h,n.key,n)}}function I(h,p,A){return p&&T(h.prototype,p),h}function w(h,p){if(typeof p!="function"&&p!==null)throw new TypeError("Super expression must either be null or a function");h.prototype=Object.create(p&&p.prototype,{constructor:{value:h,writable:!0,configurable:!0}}),p&&B(h,p)}function B(h,p){return B=Object.setPrototypeOf||function(n,r){return n.__proto__=r,n},B(h,p)}function v(h){var p=F();return function(){var n=N(h),r;if(p){var c=N(this).constructor;r=Reflect.construct(n,arguments,c)}else r=n.apply(this,arguments);return L(this,r)}}function L(h,p){if(p&&(C(p)==="object"||typeof p=="function"))return p;if(p!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return O(h)}function O(h){if(h===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return h}function F(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function N(h){return N=Object.setPrototypeOf?Object.getPrototypeOf:function(A){return A.__proto__||Object.getPrototypeOf(A)},N(h)}var q=0,J=1,x=2,M=3,m=4,g=(function(h){w(A,h);var p=v(A);function A(n,r,c){var d;return S(this,A),d=p.call(this),d.channel=r,d._centrifuge=n,d._status=q,d._error=null,d._isResubscribe=!1,d._ready=!1,d._subscriptionPromise=null,d._noResubscribe=!1,d._recoverable=!1,d._recover=!1,d._setEvents(c),d._initializePromise(),d._promises={},d._promiseId=0,d._subscribeData=null,d.on("error",function(y){this._centrifuge._debug("subscription error",y)}),d}return I(A,[{key:"_nextPromiseId",value:function(){return++this._promiseId}},{key:"_initializePromise",value:function(){var r=this;this._ready=!1,this._subscriptionPromise=new Promise(function(c,d){r._resolve=function(y){r._ready=!0,c(y)},r._reject=function(y){r._ready=!0,d(y)}}).then(function(){},function(){})}},{key:"_setNeedRecover",value:function(r){this._recoverable=r,this._recover=r}},{key:"_needRecover",value:function(){return this._recoverable===!0&&this._recover===!0}},{key:"_setEvents",value:function(r){if(r){if((0,_.isFunction)(r))this.on("publish",r);else if(Object.prototype.toString.call(r)===Object.prototype.toString.call({}))for(var c=["publish","join","leave","unsubscribe","subscribe","error"],d=0,y=c.length;d<y;d++){var E=c[d];E in r&&this.on(E,r[E])}}}},{key:"_isNew",value:function(){return this._status===q}},{key:"_isUnsubscribed",value:function(){return this._status===m}},{key:"_isSubscribing",value:function(){return this._status===J}},{key:"_isReady",value:function(){return this._status===x||this._status===M}},{key:"_isSuccess",value:function(){return this._status===x}},{key:"_isError",value:function(){return this._status===M}},{key:"_setNew",value:function(){this._status=q}},{key:"_setSubscribing",value:function(r){this._isResubscribe=r||!1,this._ready===!0&&this._initializePromise(),this._status=J}},{key:"_setSubscribeSuccess",value:function(r){if(this._status!==x){this._status=x;var c=this._getSubscribeSuccessContext(r);this._recover=!1,this.emit("subscribe",c),this._resolve(c);for(var d in this._promises)clearTimeout(this._promises[d].timeout),this._promises[d].resolve(),delete this._promises[d]}}},{key:"_setSubscribeError",value:function(r){if(this._status!==M){this._status=M,this._error=r;var c=this._getSubscribeErrorContext();this.emit("error",c),this._reject(c);for(var d in this._promises)clearTimeout(this._promises[d].timeout),this._promises[d].reject(r),delete this._promises[d]}}},{key:"_triggerUnsubscribe",value:function(){this.emit("unsubscribe",{channel:this.channel})}},{key:"_setUnsubscribed",value:function(r){if(this._centrifuge._clearSubRefreshTimeout(this.channel),this._status!==m){var c=this._status===x;this._status=m,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()}}},{key:"_shouldResubscribe",value:function(){return!this._noResubscribe}},{key:"_getSubscribeSuccessContext",value:function(r){var c={channel:this.channel,isResubscribe:this._isResubscribe};return r&&(c=this._centrifuge._expandSubscribeContext(c,r)),c}},{key:"_getSubscribeErrorContext",value:function(){var r=this._error;return r.channel=this.channel,r.isResubscribe=this._isResubscribe,r}},{key:"_setSubscribeData",value:function(r){this._subscribeData=r}},{key:"ready",value:function(r,c){this._ready&&(this._isSuccess()?r(this._getSubscribeSuccessContext()):c(this._getSubscribeErrorContext()))}},{key:"subscribe",value:function(r){this._status!==x&&(r&&r.since&&this._centrifuge._setSubscribeSince(this,r.since),r&&r.data&&this._setSubscribeData(r.data),this._noResubscribe=!1,this._centrifuge._subscribe(this))}},{key:"unsubscribe",value:function(){this._setUnsubscribed(!0),this._centrifuge._unsubscribe(this)}},{key:"_methodCall",value:function(){var r=this;if(this._isSuccess())return Promise.resolve();if(this._isError())return Promise.reject(this._error);var c=new Promise(function(d,y){var E=setTimeout(function(){y({code:0,message:"timeout"})},r._centrifuge._config.timeout);r._promises[r._nextPromiseId()]={timeout:E,resolve:d,reject:y}});return c}},{key:"publish",value:function(r){var c=this;return this._methodCall().then(function(){return c._centrifuge.publish(c.channel,r)})}},{key:"presence",value:function(){var r=this;return this._methodCall().then(function(){return r._centrifuge.presence(r.channel)})}},{key:"presenceStats",value:function(){var r=this;return this._methodCall().then(function(){return r._centrifuge.presenceStats(r.channel)})}},{key:"history",value:function(r){var c=this;return this._methodCall().then(function(){return c._centrifuge.history(c.channel,r)})}}]),A})(k.default);l.default=g,a.exports=l.default}),853:(function(a,l,f){Object.defineProperty(l,"__esModule",{value:!0}),l.backoff=b,l.errorExists=S,l.extend=T,l.isFunction=k,l.log=_,l.startsWith=C;function C(I,w){return I.lastIndexOf(w,0)===0}function k(I){return I==null?!1:typeof I=="function"}function _(I,w){if(f.g.console){var B=f.g.console[I];k(B)&&B.apply(f.g.console,w)}}function b(I,w,B){var v=.5*Math.random(),L=Math.min(B,w*Math.pow(2,I+1));return Math.floor((1-v)*L)}function S(I){return"error"in I&&I.error!==null}function T(I,w){for(var B in w)w.hasOwnProperty(B)&&(I[B]=w[B]);return I}}),187:(function(a){var l=typeof Reflect=="object"?Reflect:null,f=l&&typeof l.apply=="function"?l.apply:function(g,h,p){return Function.prototype.apply.call(g,h,p)},C;l&&typeof l.ownKeys=="function"?C=l.ownKeys:Object.getOwnPropertySymbols?C=function(g){return Object.getOwnPropertyNames(g).concat(Object.getOwnPropertySymbols(g))}:C=function(g){return Object.getOwnPropertyNames(g)};function k(m){console&&console.warn&&console.warn(m)}var _=Number.isNaN||function(g){return g!==g};function b(){b.init.call(this)}a.exports=b,a.exports.once=J,b.EventEmitter=b,b.prototype._events=void 0,b.prototype._eventsCount=0,b.prototype._maxListeners=void 0;var S=10;function T(m){if(typeof m!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof m)}Object.defineProperty(b,"defaultMaxListeners",{enumerable:!0,get:function(){return S},set:function(m){if(typeof m!="number"||m<0||_(m))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+m+".");S=m}}),b.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},b.prototype.setMaxListeners=function(g){if(typeof g!="number"||g<0||_(g))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+g+".");return this._maxListeners=g,this};function I(m){return m._maxListeners===void 0?b.defaultMaxListeners:m._maxListeners}b.prototype.getMaxListeners=function(){return I(this)},b.prototype.emit=function(g){for(var h=[],p=1;p<arguments.length;p++)h.push(arguments[p]);var A=g==="error",n=this._events;if(n!==void 0)A=A&&n.error===void 0;else if(!A)return!1;if(A){var r;if(h.length>0&&(r=h[0]),r instanceof Error)throw r;var c=new Error("Unhandled error."+(r?" ("+r.message+")":""));throw c.context=r,c}var d=n[g];if(d===void 0)return!1;if(typeof d=="function")f(d,this,h);else for(var y=d.length,E=F(d,y),p=0;p<y;++p)f(E[p],this,h);return!0};function w(m,g,h,p){var A,n,r;if(T(h),n=m._events,n===void 0?(n=m._events=Object.create(null),m._eventsCount=0):(n.newListener!==void 0&&(m.emit("newListener",g,h.listener?h.listener:h),n=m._events),r=n[g]),r===void 0)r=n[g]=h,++m._eventsCount;else if(typeof r=="function"?r=n[g]=p?[h,r]:[r,h]:p?r.unshift(h):r.push(h),A=I(m),A>0&&r.length>A&&!r.warned){r.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+r.length+" "+String(g)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=m,c.type=g,c.count=r.length,k(c)}return m}b.prototype.addListener=function(g,h){return w(this,g,h,!1)},b.prototype.on=b.prototype.addListener,b.prototype.prependListener=function(g,h){return w(this,g,h,!0)};function B(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function v(m,g,h){var p={fired:!1,wrapFn:void 0,target:m,type:g,listener:h},A=B.bind(p);return A.listener=h,p.wrapFn=A,A}b.prototype.once=function(g,h){return T(h),this.on(g,v(this,g,h)),this},b.prototype.prependOnceListener=function(g,h){return T(h),this.prependListener(g,v(this,g,h)),this},b.prototype.removeListener=function(g,h){var p,A,n,r,c;if(T(h),A=this._events,A===void 0)return this;if(p=A[g],p===void 0)return this;if(p===h||p.listener===h)--this._eventsCount===0?this._events=Object.create(null):(delete A[g],A.removeListener&&this.emit("removeListener",g,p.listener||h));else if(typeof p!="function"){for(n=-1,r=p.length-1;r>=0;r--)if(p[r]===h||p[r].listener===h){c=p[r].listener,n=r;break}if(n<0)return this;n===0?p.shift():N(p,n),p.length===1&&(A[g]=p[0]),A.removeListener!==void 0&&this.emit("removeListener",g,c||h)}return this},b.prototype.off=b.prototype.removeListener,b.prototype.removeAllListeners=function(g){var h,p,A;if(p=this._events,p===void 0)return this;if(p.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):p[g]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete p[g]),this;if(arguments.length===0){var n=Object.keys(p),r;for(A=0;A<n.length;++A)r=n[A],r!=="removeListener"&&this.removeAllListeners(r);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(h=p[g],typeof h=="function")this.removeListener(g,h);else if(h!==void 0)for(A=h.length-1;A>=0;A--)this.removeListener(g,h[A]);return this};function L(m,g,h){var p=m._events;if(p===void 0)return[];var A=p[g];return A===void 0?[]:typeof A=="function"?h?[A.listener||A]:[A]:h?q(A):F(A,A.length)}b.prototype.listeners=function(g){return L(this,g,!0)},b.prototype.rawListeners=function(g){return L(this,g,!1)},b.listenerCount=function(m,g){return typeof m.listenerCount=="function"?m.listenerCount(g):O.call(m,g)},b.prototype.listenerCount=O;function O(m){var g=this._events;if(g!==void 0){var h=g[m];if(typeof h=="function")return 1;if(h!==void 0)return h.length}return 0}b.prototype.eventNames=function(){return this._eventsCount>0?C(this._events):[]};function F(m,g){for(var h=new Array(g),p=0;p<g;++p)h[p]=m[p];return h}function N(m,g){for(;g+1<m.length;g++)m[g]=m[g+1];m.pop()}function q(m){for(var g=new Array(m.length),h=0;h<g.length;++h)g[h]=m[h].listener||m[h];return g}function J(m,g){return new Promise(function(h,p){function A(r){m.removeListener(g,n),p(r)}function n(){typeof m.removeListener=="function"&&m.removeListener("error",A),h([].slice.call(arguments))}M(m,g,n,{once:!0}),g!=="error"&&x(m,A,{once:!0})})}function x(m,g,h){typeof m.on=="function"&&M(m,"error",g,h)}function M(m,g,h,p){if(typeof m.on=="function")p.once?m.once(g,h):m.on(g,h);else if(typeof m.addEventListener=="function")m.addEventListener(g,function A(n){p.once&&m.removeEventListener(g,A),h(n)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof m)}})},i={};function s(a){var l=i[a];if(l!==void 0)return l.exports;var f=i[a]={exports:{}};return o[a](f,f.exports,s),f.exports}(function(){s.g=(function(){if(typeof globalThis=="object")return globalThis;try{return this||new Function("return this")()}catch{if(typeof window=="object")return window}})()})();var u=s(579);return u})()})})(ye)),ye.exports}var kt=Pt();const wt=Qt(kt);let me=null;function We(e,t){if(!(e!=null&&e.client_url)||!(e!=null&&e.token)||!(e!=null&&e.channel))return console.error("[Centrifuge] Invalid socket_connections"),null;const{client_url:o,token:i,channel:s}=e;if(s.includes("#")||console.warn("[Centrifuge] Channel should contain #user_id"),me){try{console.log("[Centrifuge] Disconnecting previous instance..."),me.disconnect()}catch(a){console.error("[Centrifuge] Error while disconnecting previous instance:",a)}me=null}console.log("[Centrifuge] Creating new instance:",o);const u=new wt(o);return u.setToken(i),u.on("connect",a=>{console.log("[Centrifuge] Connected",a),console.log("[Centrifuge] Subscribing to channel:",s);const l=u.subscribe(s);l.on("publish",f=>{console.log("[Centrifuge] Publish event received:",f);const C=_t(f);C&&t(C)}),l.on("subscribe",f=>{console.log("[Centrifuge] ✅ Channel subscribed successfully:",s,f)}),l.on("error",f=>{console.error("[Centrifuge] ❌ Subscription error:",f)}),l.on("unsubscribe",f=>{console.log("[Centrifuge] Channel unsubscribed:",f)})}),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(),me=u,{centrifuge:u}}function _t(e){var o,i,s;if(console.log("[Centrifuge] Raw message received:",JSON.stringify(e)),!(e!=null&&e.data))return console.warn("[Centrifuge] Empty or invalid response"),null;let t=e.data;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)}function be(e){return/^4[0-9]/.test(e)?"visa":/^5[1-5]/.test(e)||/^2[2-7]/.test(e)?"mastercard":"card"}const $={iconType:"kaspi_pay",label:"Kaspi.kz",type:"kaspi_pay"},Ve={iconType:"apple_pay",label:"Apple Pay",type:"apple_pay"},Ye={iconType:"google_pay",label:"Google Pay",type:"google_pay"};function z(e){return e==="enabled"||e===!0}function Ge(e){if(!e)return null;let t=String(e).trim().toLowerCase();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}function Tt(e){var u,a,l;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);if(!o)return null;if(typeof o=="string")return{type:Ge(o),cardId:null};if(typeof o!="object")return null;const i=o.type??o.payment_method??o.method,s=o.card_id??o.cardId??o.id??((l=o.card)==null?void 0:l.id)??null;return{type:Ge(i),cardId:s!=null?String(s):null}}function Lt(e,t,o={}){var w,B,v,L;const i=[],s=(w=e==null?void 0:e.kaspi)==null?void 0:w.data,u=((B=e==null?void 0:e.cards_v2)==null?void 0:B.data)||[],a=((L=(v=e==null?void 0:e.payment_methods)==null?void 0:v.data)==null?void 0:L.attributes)||{},l=z(a.payment_method_kaspi),f=z(a.payment_method_card),C=typeof window<"u"&&window.self===window.top,_=we()==="ios",b=!!(o!=null&&o.onlyKaspiAvailable),S=!!(o!=null&&o.disableKaspi);return s!=null&&s.isKaspiOnly&&l&&!S?[$]:b?s!=null&&s.isAvailable&&l&&!S?[$]:[]:(z(a.payment_method_apple_pay)&&!Ce("apple_pay")&&(ge()&&C||pe()||_||ze()===16)&&i.push(Ve),s!=null&&s.isAvailable&&l&&!S&&i.push($),f&&u.filter(O=>!O.isExpired).forEach(O=>{i.push({iconType:be(O.attributes.mask),type:"card",cardId:O.id,label:`•••• ${O.attributes.mask.slice(-4)}`,cardType:O.type,isDefault:O.attributes.isDefault})}),z(a.payment_method_google_pay)&&!Ce("google_pay")&&!(o!=null&&o.disableGooglePay)&&!ge()&&!pe()&&i.push(Ye),z(a.payment_method_new_card)&&i.push({iconType:"new_card",type:"new_card",label:t?t("newCard"):"Оплата новой картой"}),i)}function _e(e,t={}){var I,w,B,v;const o=(I=e==null?void 0:e.kaspi)==null?void 0:I.data,i=((w=e==null?void 0:e.cards_v2)==null?void 0:w.data)||[],s=((v=(B=e==null?void 0:e.payment_methods)==null?void 0:B.data)==null?void 0:v.attributes)||{},u=z(s.payment_method_kaspi),a=z(s.payment_method_card),l=!!(t!=null&&t.disableKaspi),f=typeof window<"u"&&window.self===window.top,k=we()==="ios",_=z(s.payment_method_apple_pay)&&!Ce("apple_pay")&&(ge()&&f||pe()||k||ze()===16),b=z(s.payment_method_google_pay)&&!Ce("google_pay")&&!(t!=null&&t.disableGooglePay)&&!ge()&&!pe();if(o!=null&&o.isKaspiOnly&&u&&!l||t!=null&&t.onlyKaspiAvailable&&(o!=null&&o.isAvailable)&&u&&!l)return $;const S=Tt(e);if((S==null?void 0:S.type)==="kaspi_pay"&&(o!=null&&o.isAvailable)&&u&&!l)return $;if((S==null?void 0:S.type)==="apple_pay"&&_)return Ve;if((S==null?void 0:S.type)==="google_pay"&&b)return Ye;if((S==null?void 0:S.type)==="new_card"&&z(s.payment_method_new_card))return{iconType:"new_card",type:"new_card",label:"Оплата новой картой"};if((S==null?void 0:S.type)==="card"&&a){const L=S.cardId!=null?i.find(O=>!O.isExpired&&String(O.id)===S.cardId):null;if(L)return{iconType:be(L.attributes.mask),type:"card",cardId:L.id,label:`•••• ${L.attributes.mask.slice(-4)}`,cardType:L.type}}if(a){const L=i.find(O=>{var F;return((F=O.attributes)==null?void 0:F.isDefault)&&!O.isExpired});if(L)return{iconType:be(L.attributes.mask),type:"card",cardId:L.id,label:`•••• ${L.attributes.mask.slice(-4)}`,cardType:L.type}}if(o!=null&&o.isAvailable&&u&&!l)return $;const T=a?i.find(L=>!L.isExpired):null;return T?{iconType:be(T.attributes.mask),type:"card",cardId:T.id,label:`••••${T.attributes.mask.slice(-4)}`,cardType:T.type}:null}function Ze(e){if(typeof localStorage>"u")return null;try{return localStorage.getItem(e)}catch{return null}}function Te(e,t){if(!(typeof localStorage>"u"))try{localStorage.setItem(e,t)}catch{}}function Ee(e){if(!(typeof localStorage>"u"))try{localStorage.removeItem(e)}catch{}}async function Rt(e,t){var o;try{const i=await e.json(),s=(o=i==null?void 0:i.errors)==null?void 0:o[0];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}catch{return`HTTP ${e.status}: ${e.statusText}`}}async function Y(e,t){const o=await Rt(e,t);throw Object.assign(new Error(o),{status:e.status})}function ve(e,t,o={}){const i=Number.isFinite(o.checkoutAmount)&&o.checkoutAmount>=0?Number(o.checkoutAmount):e.amount,s=!!o.forceBalanceMethod,u=!!o.useBalance,a=o.voucher;return{checkoutAmount:i,checkoutPaymentMethod:s?{type:"balance"}:t,useBalanceFlag:u,voucher:a}}function Be(e,t,o,i,s){return{preorder_id:e.preorderId,terminal_id:e.terminalId,merchant_order_id:e.merchantOrderId,money:{amount:String(o),currency:e.currency},payment_method:t,...e.backlink&&{backlink:e.backlink},...i&&{use_balance:!0},...s&&{voucher:s}}}async function Ie(e,t,o,i,s){const u=await fetch(`${e}/orders/v1/checkout`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t.accessToken}`,"X-Idempotency-Key":t.idempotencyKey??fe(),"X-Device-Id":o,"X-OS":"WEB"},body:JSON.stringify(i)});return u.ok||await Y(u,s),u.json()}async function Ot(e,t,o){var l,f,C,k;const i=await fetch(`${e}/api/v2/oauth2/tokens`,{method:"POST",headers:{"Content-Type":"application/json","X-Idempotency-Key":fe(),"X-Fingerprint":je()},body:JSON.stringify({client_id:t,grant_type:"authorization_track_id",track_id:o})});i.ok||await Y(i,"Не удалось авторизоваться через track_id");const s=await i.json(),u=(s==null?void 0:s.access_token)??((f=(l=s==null?void 0:s.data)==null?void 0:l.attributes)==null?void 0:f.access_token),a=(s==null?void 0:s.refresh_token)??((k=(C=s==null?void 0:s.data)==null?void 0:C.attributes)==null?void 0:k.refresh_token)??null;if(!u)throw new Error("В ответе отсутствует access_token");return{access_token:u,refresh_token:a}}async function Mt(e,t,o){var l,f,C,k;const i=await fetch(`${e}/api/v2/oauth2/tokens`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:t,grant_type:"refresh_token",refresh_token:o})});i.ok||await Y(i,"Не удалось обновить токен по refresh_token");const s=await i.json(),u=(s==null?void 0:s.access_token)??((f=(l=s==null?void 0:s.data)==null?void 0:l.attributes)==null?void 0:f.access_token),a=(s==null?void 0:s.refresh_token)??((k=(C=s==null?void 0:s.data)==null?void 0:C.attributes)==null?void 0:k.refresh_token)??null;if(!u)throw new Error("В ответе отсутствует access_token");return{access_token:u,refresh_token:a}}async function Le(e,t){const o=await fetch(`${e}/orders/v1/checkout/context`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t.accessToken}`,"X-Idempotency-Key":fe()},body:JSON.stringify({terminal_id:t.terminalId,include:["cards","payment_methods","balance","cashback"],money:{amount:String(t.amount),currency:t.currency}})});return o.ok||await Y(o,"Ошибка получения контекста оплаты"),o.json()}async function Nt(e,t,o){const i=await fetch(`${e}/payment-gateway/v1/cards/${o}`,{method:"DELETE",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t.accessToken}`}});return i.ok||await Y(i,"Не удалось удалить карту"),i.json().catch(()=>({}))}async function Dt(e,t,o){const i=await fetch(`${e}/payment-gateway/v1/cards/${o}/mark_as_default`,{method:"PUT",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t.accessToken}`}});return i.ok||await Y(i,"Не удалось отметить карту как основную"),i.json().catch(()=>({}))}async function Xt(e,t,o){const i=await fetch(`${e}/orders/v1/orders/${o}/status`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t.accessToken}`}});if(!i.ok)throw Object.assign(new Error(`Ошибка проверки статуса заказа: ${i.status} ${i.statusText}`),{status:i.status});const s=await i.json(),u=(s==null?void 0:s.data)??s;return{data:{status:u==null?void 0:u.status,payload:(u==null?void 0:u.payload)??{}}}}async function $e(e,t,o,i,s={}){const{checkoutAmount:u,checkoutPaymentMethod:a,useBalanceFlag:l,voucher:f}=ve(t,{type:i.type,...i.cardId&&{card_id:i.cardId}},s);return Ie(e,t,o,Be(t,a,u,l,f),"Ошибка создания заказа")}async function Ut(e,t,o,i={}){const{checkoutAmount:s,checkoutPaymentMethod:u,useBalanceFlag:a,voucher:l}=ve(t,{type:"new_card"},i);return Ie(e,t,o,Be(t,u,s,a,l),"Ошибка создания заказа для новой карты")}async function Ht(e,t){const o=await fetch(`${e}/loyalty/v6/coupons/by_terminal/${t.terminalId}/at_payment?order_pay_amount=${t.amount}`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t.accessToken}`}});return o.ok||await Y(o,"Ошибка получения купонов"),o.json()}async function xt(e,t,o){const i=window.location.hostname,s=await fetch(`${e}/payment-gateway/v1/apple/session`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/vnd.api+json",Authorization:`Bearer ${t.accessToken}`},body:JSON.stringify({validationUrl:o,domainName:i})});return s.ok||await Y(s,"Ошибка получения Apple Pay сессии"),s.json()}async function Ft(e,t,o,i,s={}){const{checkoutAmount:u,checkoutPaymentMethod:a,useBalanceFlag:l,voucher:f}=ve(t,{type:"apple_pay",data:i},s);return Ie(e,t,o,Be(t,a,u,l,f),"Ошибка создания заказа с Apple Pay")}async function et(e,t,o,i,s={}){const{checkoutAmount:u,checkoutPaymentMethod:a,useBalanceFlag:l,voucher:f}=ve(t,{type:"google_pay",data:i},s);return Ie(e,t,o,Be(t,a,u,l,f),"Ошибка создания заказа с Google Pay")}function Jt(e){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)?{availableBonus:Number.isFinite(i.availableBonus)?Number(i.availableBonus):0,amount:Number(i.amount),percent:Number(i.percent)}:null;return{preorderId:e.preorderId,trackId:e.trackId,clientId:e.clientId,projectId:e.projectId,terminalId:e.terminalId,merchantOrderId:e.merchantOrderId,amount:e.amount,currency:e.currency||"KZT",environment:e.environment||"production",backlink:e.backlink,onSuccess:e.onSuccess||(()=>{}),onAppliedBonus:e.onAppliedBonus||(()=>{}),onError:e.onError||(()=>{}),onCancel:e.onCancel||(()=>{}),onCardDeleted:typeof e.onCardDeleted=="function"?e.onCardDeleted:null,onConfirmPay:typeof e.onConfirmPay=="function"?e.onConfirmPay:null,onPaymentMethodSelected:typeof e.onPaymentMethodSelected=="function"?e.onPaymentMethodSelected:null,onKaspiLink:typeof e.onKaspiLink=="function"?e.onKaspiLink:null,onPayWithGooglePay:typeof e.onPayWithGooglePay=="function"?e.onPayWithGooglePay:null,onUserEvent:typeof e.onUserEvent=="function"?e.onUserEvent:null,onBeforeCheckout:typeof e.onBeforeCheckout=="function"?e.onBeforeCheckout:null,idempotencyKey:e.idempotencyKey,locale:e.locale||"ru",containerSelector:typeof e.containerSelector=="string"?e.containerSelector.trim():"",color:o||"#2F2F2F",onlyKaspiAvailable:!!e.onlyKaspiAvailable,disableKaspi:!!e.disableKaspi,disableGooglePay:!!e.disableGooglePay,isNativeAndroid:!!e.isNativeAndroid,bonuses:s}}function Re(e,t){Te("webPayToken",e),t&&Te("webPayRefreshToken",t)}function tt(){Ee("webPayToken"),Ee("webPayRefreshToken")}async function qt(e){const t=Ze("webPayRefreshToken");if(t&&e.config.clientId)try{const i=await Mt(e.apiUrl,e.config.clientId,t);Re(i.access_token,i.refresh_token),e.accessToken=i.access_token;return}catch{Ee("webPayRefreshToken")}if(!e.config.trackId||!e.config.clientId){e.config.onError({attributes:{message:e.t("errorMissingTrackClient")}});return}const o=await Ot(e.apiUrl,e.config.clientId,e.config.trackId);Re(o.access_token,o.refresh_token),e.accessToken=o.access_token}const jt={kaspi_pay:`<svg width="17" height="16" viewBox="0 0 17 16" fill="none" xmlns="http://www.w3.org/2000/svg">
5
5
  <path fill-rule="evenodd" clip-rule="evenodd" d="M8.89711 8.50443C10.4185 8.72365 10.6242 9.56386 10.7471 10.3459L10.7816 10.5699L10.8557 11.0301C11.0006 11.9088 11.303 13.7327 11.303 14.6845C11.303 14.9224 11.2806 15.105 11.2396 15.2053C11.1713 15.3599 10.9724 15.5082 10.6978 15.6319C10.0332 15.7846 9.33863 15.8671 8.62315 15.8671C8.54739 15.8671 8.47285 15.8637 8.39805 15.8616C8.10889 15.785 7.89156 15.657 7.77649 15.4821C7.42905 14.9542 7.40812 13.7781 7.40116 12.4037L7.40037 12.2443L7.39755 11.8324C7.38623 10.3774 7.37651 9.1229 7.94288 8.67272C8.16223 8.49957 8.47392 8.44225 8.89711 8.50443ZM5.58009 11.6722C5.90978 11.6548 6.12181 13.1684 6.16441 14.3162C6.19427 15.1152 6.10438 15.4439 5.96084 15.5619C5.79833 15.5113 5.63864 15.4565 5.48128 15.397C5.3763 15.219 5.29607 14.9389 5.2451 14.5721C5.08947 13.4193 5.22466 11.6925 5.58009 11.6722ZM13.8455 13.934C13.825 14.0391 13.796 14.1204 13.7602 14.1889C13.4783 14.4 13.1821 14.5938 12.872 14.7682C12.7733 14.7837 12.6856 14.7729 12.6427 14.7053C12.2318 14.0314 12.0775 11.9173 12.4752 11.7333C12.9936 11.4995 13.9224 13.5685 13.8455 13.934ZM8.50042 0C13.1296 0 16.8941 3.42166 16.9979 7.67934L17 7.82651V7.89454C16.9915 9.81778 16.2332 11.5773 14.9839 12.9392C14.9386 12.918 14.8559 12.8486 14.7062 12.6395C14.5512 12.4293 13.2148 10.5096 13.2148 8.30946C13.2148 7.87768 13.8816 7.20318 14.4717 6.61114C14.9128 6.16562 15.3306 5.74539 15.4845 5.4151C15.6804 4.98892 15.5433 4.69134 15.3265 4.59047C15.1302 4.50082 14.8355 4.56621 14.6287 4.90904C14.2893 5.46389 14.1805 5.56758 13.6855 5.93882C13.1984 6.30986 12.424 6.68338 12.424 6.19988C12.424 5.93882 12.8553 5.34757 13.0684 4.93314C13.286 4.51408 13.0515 4.21072 12.6022 4.21072C11.7198 4.21072 11.1341 5.2598 11.1341 5.62326C11.1341 5.98642 11.3229 6.03813 11.3229 6.46104C11.3229 6.88713 10.3548 7.4398 9.44281 7.4398C8.56481 7.4398 8.05566 7.27394 7.8447 6.80665L7.81777 6.74105L7.75678 6.57266C7.54046 5.98255 7.38528 5.55458 7.11514 5.10733C6.9717 4.87081 6.75038 4.70684 6.55897 4.56257C6.30881 4.38121 6.17902 4.21421 6.15193 4.08967C6.12696 3.96611 6.11352 3.73326 6.54117 3.19648C6.96793 2.66277 7.02775 2.25958 6.81418 2.05153C6.73678 1.97752 6.60482 1.93011 6.43535 1.93011C6.13562 1.93011 5.71912 2.07834 5.2899 2.48551C4.62267 3.12364 5.00146 3.72951 5.00146 3.99548C5.00146 4.26127 4.87922 4.41162 4.47882 4.77323C4.07547 5.13644 3.93627 5.44783 3.89014 6.69935C3.87247 7.3442 3.75079 7.71539 3.64156 8.04453C3.54718 8.33302 3.46038 8.60425 3.45569 8.99611C3.44822 9.43038 3.52566 9.71023 3.61604 10.0331C3.70477 10.3316 3.79902 10.6736 3.8594 11.2456C3.95544 12.1312 3.92205 12.8792 3.74744 13.6437L3.70084 13.8353L3.68995 13.8903C3.65419 14.0247 3.61168 14.1879 3.55423 14.249C1.4029 12.8228 0 10.4936 0 7.86072C0 3.51974 3.80561 0 8.50042 0Z" fill="#F14635"/>
6
6
  </svg>
7
7
  `,new_card:`<svg width="21" height="12" viewBox="0 0 21 12" fill="none" xmlns="http://www.w3.org/2000/svg">
@@ -283,7 +283,7 @@
283
283
  <div class="choco-widget-bottom-bar-prerender">
284
284
  <div class="choco-widget-payment-loading"></div>
285
285
  </div>
286
- `}function tn(e,t,o,i={}){return nt(e,t,o,i)}function nn(e){return Qe(e)}function rn(e){if(typeof document>"u")return{mountTarget:null,isEmbedded:!1};const t=e.config.containerSelector;if(t){const o=document.querySelector(t);if(o instanceof HTMLElement)return{mountTarget:o,isEmbedded:!0}}return{mountTarget:document.body,isEmbedded:!1}}function rt(e){if(typeof document>"u")return!1;e.container||(e.container=document.createElement("div"),e.container.id="choco-one-click-widget",e.container.className="choco-one-click-widget");const{mountTarget:t,isEmbedded:o}=rn(e);return t?(e.container.parentElement!==t&&t.appendChild(e.container),e.container.classList.toggle("choco-one-click-widget--embedded",o),!0):!1}function on(e){rt(e)&&(e.container.style.setProperty("--choco-widget-accent-color",e.config.color),e.container.innerHTML=en())}function sn(e){var k,_,b,S,T;if(!rt(e))return;e.container.style.setProperty("--choco-widget-accent-color",e.config.color),e.container.classList.remove("choco-one-click-widget--visible");const t=e.getAvailablePaymentMethods(),o=(k=e.checkoutContext)==null?void 0:k.data,i=e.config.currency||"KZT",s=(S=(b=(_=o==null?void 0:o.balance)==null?void 0:_.data)==null?void 0:b.money)==null?void 0:S[i],u=s>0?V(s,e.config.locale,e.config.currency):null,a=(T=o==null?void 0:o.cashback)==null?void 0:T.data,l=(a==null?void 0:a.cashbackAmount)>0?V(a.cashbackAmount,e.config.locale,e.config.currency):null,f=e._getPayableAmount(),C=f<e.config.amount;e.container.innerHTML=$t({amountFormatted:V(f,e.config.locale,e.config.currency),originalAmountFormatted:V(e.config.amount,e.config.locale,e.config.currency),showOriginalAmount:C,paymentMethod:e.selectedPaymentMethod,methods:t,selectedMethod:e.selectedPaymentMethod,balanceFormatted:u,useBalance:e.useBalance,bonuses:e.config.bonuses,useBonuses:e.useBonuses,coupon:e.selectedCoupon,useCoupon:e.useCoupon,couponDisabled:e._isCouponDisabled(),cashbackFormatted:l,disabled:e.disabled,paymentMethodDisabled:e.paymentMethodDisabled,loading:e.loading,t:(I,w)=>e.t(I,w),currency:i}),e._attachEventListeners(),e.isOpen=!0,e._emitUserEvent("one_click_pay_cta_rendered",{terminal_id:e.config.terminalId,project_id:e.config.clientId}),e._emitUserEvent("one_click_pay_method_resolved",{payment_method:e._getPaymentMethodForUserEvent()}),requestAnimationFrame(()=>{requestAnimationFrame(()=>{var I;(I=e.container)==null||I.classList.add("choco-one-click-widget--visible")})})}function le(e){var i;const t=(i=e.container)==null?void 0:i.querySelector(".choco-widget-payment-methods");if(!t)return;const o=e.getAvailablePaymentMethods();t.innerHTML=tn(o,e.selectedPaymentMethod,s=>e.t(s),{editMode:e.isPaymentSheetEditMode}),t.querySelectorAll("[data-action='delete-card']").forEach(s=>{s.addEventListener("click",u=>{u.stopPropagation();const a=JSON.parse(s.getAttribute("data-method")||"{}");ln(e,a)})}),t.querySelectorAll("[data-action='select-method']").forEach(s=>{s.addEventListener("click",u=>{const a=JSON.parse(u.currentTarget.getAttribute("data-method")||"{}");ct(e,a)})})}function ot(e){var s,u,a;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(".choco-widget-method-icon-wrapper");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=nn(e.selectedPaymentMethod)),st(e)}function Se(e){var k,_,b,S,T;const t=(k=e.container)==null?void 0:k.querySelector(".choco-widget-pay-button"),o=(_=e.container)==null?void 0:_.querySelector(".choco-widget-google-pay-amount"),i=(b=e.container)==null?void 0:b.querySelector(".choco-widget-google-pay-amount-label");let s=(S=e.container)==null?void 0:S.querySelector(".choco-widget-google-pay-amount-value"),u=(T=e.container)==null?void 0:T.querySelector(".choco-widget-google-pay-amount-value-number");const a=e._getPayableAmount(),l=V(a,e.config.locale,e.config.currency),f=a<e.config.amount,C=V(e.config.amount,e.config.locale,e.config.currency);if(t&&(t.textContent=`${e.t("pay")} ${l}`,t.setAttribute("aria-label",`${e.t("pay")} ${l}`)),i&&(i.textContent=`${e.t("total")} ${l}`),!f){s==null||s.remove();return}!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(".choco-widget-google-pay-amount-value-number")),u?u.textContent=C:s&&(s.textContent=`${e.t("instead")} ${C}`)}function st(e){var f,C,k,_,b,S,T,I,w,B;const t=((f=e.selectedPaymentMethod)==null?void 0:f.type)==="google_pay",o=((C=e.selectedPaymentMethod)==null?void 0:C.type)==="apple_pay",i=t||o,s=(k=e.container)==null?void 0:k.querySelector(".choco-widget-pay-button"),u=(_=e.container)==null?void 0:_.querySelector(".choco-widget-google-pay-amount"),a=(b=e.container)==null?void 0:b.querySelector(".choco-widget-google-pay-row"),l=(S=e.container)==null?void 0:S.querySelector(".choco-widget-apple-pay-row");if(s==null||s.classList.toggle("choco-widget-pay-button--hidden",i),u==null||u.classList.toggle("choco-widget-google-pay-amount--hidden",!i),a==null||a.classList.toggle("choco-widget-google-pay-row--hidden",!t),l==null||l.classList.toggle("choco-widget-apple-pay-row--hidden",!o),t){an(e);const v=(T=e.container)==null?void 0:T.querySelector('[data-action="apple-pay-button-slot"]');v&&(v.innerHTML="")}else if(o){e._googlePayButtonRenderVersion+=1;const v=(I=e.container)==null?void 0:I.querySelector('[data-action="google-pay-button-slot"]');v&&(v.innerHTML=""),cn(e)}else{e._googlePayButtonRenderVersion+=1;const v=(w=e.container)==null?void 0:w.querySelector('[data-action="google-pay-button-slot"]'),L=(B=e.container)==null?void 0:B.querySelector('[data-action="apple-pay-button-slot"]');v&&(v.innerHTML=""),L&&(L.innerHTML="")}Se(e),G(e)}async function an(e){var a,l,f,C,k;const t=(a=e.container)==null?void 0:a.querySelector('[data-action="google-pay-button-slot"]');if(!t||(t.innerHTML="",((l=e.selectedPaymentMethod)==null?void 0:l.type)!=="google_pay"))return;const o=++e._googlePayButtonRenderVersion;try{await e._loadGooglePaySdk()}catch{e.config.onError({attributes:{message:e.t("errorGooglePayUnsupported")}});return}if(o!==e._googlePayButtonRenderVersion)return;if(!((k=(C=(f=window.google)==null?void 0:f.payments)==null?void 0:C.api)!=null&&k.PaymentsClient)){e.config.onError({attributes:{message:e.t("errorGooglePayUnsupported")}});return}const i=e.config.environment==="production",u=new window.google.payments.api.PaymentsClient({environment:i?"PRODUCTION":"TEST"}).createButton({onClick:()=>e.handlePayment(),buttonType:"pay",buttonColor:"black",buttonLocale:e.config.locale||"ru",buttonSizeMode:"fill"});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(_=>{_.style.setProperty("border-radius","12px","important"),_.style.setProperty("font-weight","bold","important"),_.style.setProperty("font-size","16px","important")}),t.appendChild(u),G(e)}function cn(e){var u,a;const t=(u=e.container)==null?void 0:u.querySelector('[data-action="apple-pay-button-slot"]');if(!t||(t.innerHTML="",((a=e.selectedPaymentMethod)==null?void 0:a.type)!=="apple_pay"))return;const o=document.createElement("div");o.className="choco-widget-apple-pay-button-wrapper";const i=document.createElement("button");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());const s=document.createElement("div");s.className="choco-widget-apple-pay-button-overlay",s.setAttribute("aria-hidden","true"),s.innerHTML=`
286
+ `}function tn(e,t,o,i={}){return nt(e,t,o,i)}function nn(e){return Qe(e)}function rn(e){if(typeof document>"u")return{mountTarget:null,isEmbedded:!1};const t=e.config.containerSelector;if(t){const o=document.querySelector(t);if(o instanceof HTMLElement)return{mountTarget:o,isEmbedded:!0}}return{mountTarget:document.body,isEmbedded:!1}}function rt(e){if(typeof document>"u")return!1;e.container||(e.container=document.createElement("div"),e.container.id="choco-one-click-widget",e.container.className="choco-one-click-widget");const{mountTarget:t,isEmbedded:o}=rn(e);return t?(e.container.parentElement!==t&&t.appendChild(e.container),e.container.classList.toggle("choco-one-click-widget--embedded",o),!0):!1}function on(e){rt(e)&&(e.container.style.setProperty("--choco-widget-accent-color",e.config.color),e.container.innerHTML=en())}function sn(e){var k,_,b,S,T;if(!rt(e))return;e.container.style.setProperty("--choco-widget-accent-color",e.config.color),e.container.classList.remove("choco-one-click-widget--visible");const t=e.getAvailablePaymentMethods(),o=(k=e.checkoutContext)==null?void 0:k.data,i=e.config.currency||"KZT",s=(S=(b=(_=o==null?void 0:o.balance)==null?void 0:_.data)==null?void 0:b.money)==null?void 0:S[i],u=s>0?V(s,e.config.locale,e.config.currency):null,a=(T=o==null?void 0:o.cashback)==null?void 0:T.data,l=(a==null?void 0:a.cashbackAmount)>0?V(a.cashbackAmount,e.config.locale,e.config.currency):null,f=e._getPayableAmount(),C=f<e.config.amount;e.container.innerHTML=$t({amountFormatted:V(f,e.config.locale,e.config.currency),originalAmountFormatted:V(e.config.amount,e.config.locale,e.config.currency),showOriginalAmount:C,paymentMethod:e.selectedPaymentMethod,methods:t,selectedMethod:e.selectedPaymentMethod,balanceFormatted:u,useBalance:e.useBalance,bonuses:e.config.bonuses,useBonuses:e.useBonuses,coupon:e.selectedCoupon,useCoupon:e.useCoupon,couponDisabled:e._isCouponDisabled(),cashbackFormatted:l,disabled:e.disabled,paymentMethodDisabled:e.paymentMethodDisabled,loading:e.loading,t:(I,w)=>e.t(I,w),currency:i}),e._attachEventListeners(),e.isOpen=!0,e._emitUserEvent("one_click_pay_cta_rendered",{terminal_id:e.config.terminalId,project_id:e.config.projectId??e.config.clientId}),e._emitUserEvent("one_click_pay_method_resolved",{payment_method:e._getPaymentMethodForUserEvent()}),requestAnimationFrame(()=>{requestAnimationFrame(()=>{var I;(I=e.container)==null||I.classList.add("choco-one-click-widget--visible")})})}function le(e){var i;const t=(i=e.container)==null?void 0:i.querySelector(".choco-widget-payment-methods");if(!t)return;const o=e.getAvailablePaymentMethods();t.innerHTML=tn(o,e.selectedPaymentMethod,s=>e.t(s),{editMode:e.isPaymentSheetEditMode}),t.querySelectorAll("[data-action='delete-card']").forEach(s=>{s.addEventListener("click",u=>{u.stopPropagation();const a=JSON.parse(s.getAttribute("data-method")||"{}");ln(e,a)})}),t.querySelectorAll("[data-action='select-method']").forEach(s=>{s.addEventListener("click",u=>{const a=JSON.parse(u.currentTarget.getAttribute("data-method")||"{}");ct(e,a)})})}function ot(e){var s,u,a;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(".choco-widget-method-icon-wrapper");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=nn(e.selectedPaymentMethod)),st(e)}function Se(e){var k,_,b,S,T;const t=(k=e.container)==null?void 0:k.querySelector(".choco-widget-pay-button"),o=(_=e.container)==null?void 0:_.querySelector(".choco-widget-google-pay-amount"),i=(b=e.container)==null?void 0:b.querySelector(".choco-widget-google-pay-amount-label");let s=(S=e.container)==null?void 0:S.querySelector(".choco-widget-google-pay-amount-value"),u=(T=e.container)==null?void 0:T.querySelector(".choco-widget-google-pay-amount-value-number");const a=e._getPayableAmount(),l=V(a,e.config.locale,e.config.currency),f=a<e.config.amount,C=V(e.config.amount,e.config.locale,e.config.currency);if(t&&(t.textContent=`${e.t("pay")} ${l}`,t.setAttribute("aria-label",`${e.t("pay")} ${l}`)),i&&(i.textContent=`${e.t("total")} ${l}`),!f){s==null||s.remove();return}!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(".choco-widget-google-pay-amount-value-number")),u?u.textContent=C:s&&(s.textContent=`${e.t("instead")} ${C}`)}function st(e){var f,C,k,_,b,S,T,I,w,B;const t=((f=e.selectedPaymentMethod)==null?void 0:f.type)==="google_pay",o=((C=e.selectedPaymentMethod)==null?void 0:C.type)==="apple_pay",i=t||o,s=(k=e.container)==null?void 0:k.querySelector(".choco-widget-pay-button"),u=(_=e.container)==null?void 0:_.querySelector(".choco-widget-google-pay-amount"),a=(b=e.container)==null?void 0:b.querySelector(".choco-widget-google-pay-row"),l=(S=e.container)==null?void 0:S.querySelector(".choco-widget-apple-pay-row");if(s==null||s.classList.toggle("choco-widget-pay-button--hidden",i),u==null||u.classList.toggle("choco-widget-google-pay-amount--hidden",!i),a==null||a.classList.toggle("choco-widget-google-pay-row--hidden",!t),l==null||l.classList.toggle("choco-widget-apple-pay-row--hidden",!o),t){an(e);const v=(T=e.container)==null?void 0:T.querySelector('[data-action="apple-pay-button-slot"]');v&&(v.innerHTML="")}else if(o){e._googlePayButtonRenderVersion+=1;const v=(I=e.container)==null?void 0:I.querySelector('[data-action="google-pay-button-slot"]');v&&(v.innerHTML=""),cn(e)}else{e._googlePayButtonRenderVersion+=1;const v=(w=e.container)==null?void 0:w.querySelector('[data-action="google-pay-button-slot"]'),L=(B=e.container)==null?void 0:B.querySelector('[data-action="apple-pay-button-slot"]');v&&(v.innerHTML=""),L&&(L.innerHTML="")}Se(e),G(e)}async function an(e){var a,l,f,C,k;const t=(a=e.container)==null?void 0:a.querySelector('[data-action="google-pay-button-slot"]');if(!t||(t.innerHTML="",((l=e.selectedPaymentMethod)==null?void 0:l.type)!=="google_pay"))return;const o=++e._googlePayButtonRenderVersion;try{await e._loadGooglePaySdk()}catch{e.config.onError({attributes:{message:e.t("errorGooglePayUnsupported")}});return}if(o!==e._googlePayButtonRenderVersion)return;if(!((k=(C=(f=window.google)==null?void 0:f.payments)==null?void 0:C.api)!=null&&k.PaymentsClient)){e.config.onError({attributes:{message:e.t("errorGooglePayUnsupported")}});return}const i=e.config.environment==="production",u=new window.google.payments.api.PaymentsClient({environment:i?"PRODUCTION":"TEST"}).createButton({onClick:()=>e.handlePayment(),buttonType:"pay",buttonColor:"black",buttonLocale:e.config.locale||"ru",buttonSizeMode:"fill"});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(_=>{_.style.setProperty("border-radius","12px","important"),_.style.setProperty("font-weight","bold","important"),_.style.setProperty("font-size","16px","important")}),t.appendChild(u),G(e)}function cn(e){var u,a;const t=(u=e.container)==null?void 0:u.querySelector('[data-action="apple-pay-button-slot"]');if(!t||(t.innerHTML="",((a=e.selectedPaymentMethod)==null?void 0:a.type)!=="apple_pay"))return;const o=document.createElement("div");o.className="choco-widget-apple-pay-button-wrapper";const i=document.createElement("button");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());const s=document.createElement("div");s.className="choco-widget-apple-pay-button-overlay",s.setAttribute("aria-hidden","true"),s.innerHTML=`
287
287
  <span class="choco-widget-apple-pay-button-text">Оплатить с</span>
288
288
  <span class="choco-widget-apple-pay-button-icon">
289
289
  <svg width="52" height="24" viewBox="0 0 52 24" fill="none" xmlns="http://www.w3.org/2000/svg">
package/index.d.ts CHANGED
@@ -21,6 +21,13 @@ export interface ChocoOneClickConfig {
21
21
  */
22
22
  clientId: string;
23
23
 
24
+ /**
25
+ * Идентификатор проекта (приложения-хоста). Передаётся в аналитическое событие
26
+ * one_click_pay_cta_rendered как project_id. Если не указан — используется clientId.
27
+ * @optional
28
+ */
29
+ projectId?: string;
30
+
24
31
  /**
25
32
  * ID терминала от Choco
26
33
  * @required
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "choco-one-click-payment",
3
- "version": "1.1.37",
3
+ "version": "1.1.38",
4
4
  "description": "Встраиваемый виджет для быстрой оплаты с bottom sheet интерфейсом",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.esm.js",