@sberid/js-sdk
Version:
Javascript SDK для партнеров Сбер ID, упрощающая подключение SberbankID на сайте.
1 lines • 107 kB
JavaScript
"use strict";var e=require("fast-deep-equal"),t=require("unfetch");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var i=n(e),r=n(t),o=function(e,t){return o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},o(e,t)};var s=function(){return s=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},s.apply(this,arguments)};function a(e,t,n,i){return new(n||(n=Promise))((function(r,o){function s(e){try{c(i.next(e))}catch(e){o(e)}}function a(e){try{c(i.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((i=i.apply(e,t||[])).next())}))}function c(e,t){var n,i,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,i&&(r=2&o[0]?i.return:o[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,o[1])).done)return r;switch(i=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,i=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]<r[3])){s.label=o[1];break}if(6===o[0]&&s.label<r[1]){s.label=r[1],r=o;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(o);break}r[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],i=0}finally{n=r=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}}var u,d="https://online.sberbank.ru",l={method:"GET",credentials:"include"},f=function(e){return void 0===e&&(e=d),"".concat(e,"/CSAFront/oidc/authorize.do")};!function(e){e.SAFARI="Safari",e.PLAYSTATION_4="PlayStation 4",e.ANDROID_BROWSER="Android Browser",e.CHROME="Chrome",e.CHROMIUM="Chromium",e.ELECTRON="Electron",e.FIREFOX="Firefox",e.QUPZILLA="QupZilla",e.TIZEN="Tizen",e.BADA="Bada",e.WEBOS_BROWSER="WebOS Browser",e.BLACKBERRY="BlackBerry",e.SLIMERJS="SlimerJS",e.PHANTOMJS="PhantomJS",e.AMAZON_SILK="Amazon Silk",e.SAILFISH="Sailfish",e.SEAMONKEY="SeaMonkey",e.VIVALDI="Vivaldi",e.MICROSOFT_EDGE="Microsoft Edge",e.INTERNET_EXPLORER="Internet Explorer",e.WECHAT="WeChat",e.K_MELEON="K-Meleon",e.SLEIPNIR="Sleipnir",e.PUFFIN="Puffin",e.EPIPHANY="Epiphany",e.MAXTHON="Maxthon",e.UC_BROWSER="UC Browser",e.YANDEX_BROWSER="Yandex Browser",e.OPERA_COAST="Opera Coast",e.SWING="Swing",e.FOCUS="Focus",e.MZ_BROWSER="MZ Browser",e.NAVER_WHALE_BROWSER="NAVER Whale Browser",e.SAMSUNG_INTERNET_FOR_ANDROID="Samsung Internet for Android",e.OPERA_TOUCH="Opera Touch",e.OPERA="Opera",e.GOOGLEBOT="Googlebot",e.WINDOWS_PHONE="windows phone",e.GENERIC="Generic",e.ROKU="Roku"}(u||(u={}));var p,h,b,v,g={invalid_request:"В запросе отсутствуют обязательные атрибуты",unauthorized_client:"АС - источник запроса не зарегистрирована или заблокирована в банке либо значение атрибута client_id не соответствует формату",unsupported_response_type:"Значение атрибута response_type не равно «code»",invalid_scope:"Значение атрибута scope не содержит параметр openid в начальной позиции либо запрошенный scope содержит значения, недоступные для АС - источника запроса",access_denied:"Клиент отказался от передачи согласий",invalid_state:"Значение атрибута state не соответствует изначальному",window_closed:"Клиент закрыл окно авторизации через Сбер ID"},w="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",m={needAdditionalRedirect:!0,universalLinkUrl:(void 0===p&&(p=d),"".concat(p,"/CSAFront/oidc/sberbank_id/authorize.do")),baseUrl:f(),deeplinkUrl:"sberbankidlogin://sberbankidsso",debug:!1,generateState:!1,display:"page"},y=function(e){return void 0===e&&(e=window.location.search.slice(1)),e?(/^[?#]/.test(e)?e.slice(1):e).split("&").reduce((function(e,t){var n=t.split("="),i=n[0],r=n[1];return e[i]=r?decodeURIComponent(r.replace(/\+/g," ")):"",e}),{}):{}},_=function(e,t){var n=Object.keys(t).map((function(e){return[e,t[e]].map(encodeURIComponent).join("=")})).join("&");return e?"".concat(e).concat(n?"?":"").concat(n):n},S={info:{color:"#0c5460",background:"#d1ecf1",border:"#bee5eb"},success:{color:"#155724",background:"#d4edda",border:"#c3e6cb"},error:{color:"#721c24",background:"#f8d7da",border:"#f5c6cb"}},k=function(e,t){void 0===t&&(t="info");var n=new Date,i="[".concat(n.getHours(),":").concat(n.getMinutes(),":").concat(n.getSeconds().toString().padStart(2,"0"),":").concat(n.getMilliseconds(),"] %c[").concat(t,"]%c "),r="color: ".concat(S[t].color,";background-color: ").concat(S[t].background,";border: 1px solid ").concat(S[t].border);console.info.apply(null,[i,r,""].concat(e))},O=function(e,t){var n=function(n){!e.contains(n.target)&&E(e)&&(t(),i())},i=function(){document.removeEventListener("click",n)};document.addEventListener("click",n)},E=function(e){return!!e&&!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length)},x=function(){for(var e=document.querySelectorAll(".sbid-button-loader"),t=0;t<e.length;t+=1){e[t].classList.add("sbid-button-loader--show")}},I=function(){for(var e=document.querySelectorAll(".sbid-button-loader"),t=0;t<e.length;t+=1){e[t].classList.remove("sbid-button-loader--show")}},A=function(){return window.crypto||window.msCrypto},C=function(e){var t=new Uint8Array(e);if("undefined"!=typeof window&&A())A().getRandomValues(t);else for(var n=0;n<e;n+=1)t[n]=Math.random()*w.length|0;return function(e){for(var t=[],n=0;n<e.byteLength;n+=1){var i=e[n]%w.length;t.push(w[i])}return t.join("")}(t)},L={url:"https://sve.online.sberbank.ru/metrics/partners",init:"auto",enable:!0,buffer:1,apiKey:"da8570065d949a8a3ee551b99f31f7774909575e702289b2743fab0aad0ffe41",subId:""},R=function(e){var t,n;if(window.sberbankIdAnalytics)k(["SberVisor уже иницилизирован"],"info");else{var i=s(s(s({},L),e.sa),{sberId:(null===(t=null==e?void 0:e.oidc)||void 0===t?void 0:t.client_id)||(null===(n=null==e?void 0:e.sa)||void 0===n?void 0:n.clientId)||""});try{Promise.resolve().then((function(){return Xe})).then((function(){window.sberbankIdAnalytics=new window.SberVisor(i)})).catch((function(e){return k(["Ошибка при инициализации SberVisor",e],"error")}))}catch(e){k(["Ошибка при инициализации SberVisor",e],"error")}}},T=function(e){var t=e.eventCategory,n=e.eventAction,i=e.eventType,r=e.result,o=e.description,a=e.extendedProperties,c=e.clientName;if(window.sberbankIdAnalytics){var u,d,l=c||(u="title",(d=document.querySelector('meta[name="'.concat(u,'"]')))&&d.getAttribute("content")||""),f=window.location.origin;try{var p={eventCategory:t,eventAction:n,eventType:i,properties:s(s(s({merchUrl:f,merchantTitle:l,sdkVersion:"js_3.0.3"},r?{result:r}:{}),o?{errorDescription:o}:{}),a)};window.sberbankIdAnalytics.push(p)}catch(e){k(["Ошибка при отправке события (".concat(t,", ").concat(n,", ").concat(i,") в SberVisor"),e],"error")}}},M="Facebook Messenger",N="Facebook",B="Twitter",P="Line",D="Wechat",U="Instagram",F="Electron Application",j="Microsoft Outlook",W="Pinterest App",z="Thunderbird",H="Webview Based Browser",q="Yandex App",V="Windows Phone",G="Windows",K="macOS",Z="iOS",Q="Android",X="WebOS",Y="BlackBerry",J="Bada",$="Tizen",ee="Linux",te="Chrome OS",ne="PlayStation 4",ie="Roku",re="tablet",oe="mobile",se="desktop",ae="tv",ce=/version\/(\d+(\.?_?\d+)+)/i,ue=function(e,t){var n=t.match(e);return n&&n.length>0&&n[1]||""},de=function(e,t){var n=t.match(e);return n&&n.length>1&&n[2]||""},le=[{test:[/googlebot/i],describe:function(e){var t={name:u.GOOGLEBOT},n=ue(/googlebot\/(\d+(\.\d+))/i,e)||ue(ce,e);return n&&(t.version=n),t}},{test:[/opera/i],describe:function(e){var t={name:u.OPERA},n=ue(ce,e)||ue(/(?:opera)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/opr\/|opios/i],describe:function(e){var t={name:u.OPERA},n=ue(/(?:opr|opios)[\s/](\S+)/i,e)||ue(ce,e);return n&&(t.version=n),t}},{test:[/opt/i],describe:function(e){var t={name:u.OPERA_TOUCH},n=ue(/(?:opt)[\s/](\S+)/i,e)||ue(ce,e);return n&&(t.version=n),t}},{test:[/SamsungBrowser/i],describe:function(e){var t={name:u.SAMSUNG_INTERNET_FOR_ANDROID},n=ue(ce,e)||ue(/(?:SamsungBrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/Whale/i],describe:function(e){var t={name:u.NAVER_WHALE_BROWSER},n=ue(ce,e)||ue(/(?:whale)[\s/](\d+(?:\.\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/MZBrowser/i],describe:function(e){var t={name:u.MZ_BROWSER},n=ue(/(?:MZBrowser)[\s/](\d+(?:\.\d+)+)/i,e)||ue(ce,e);return n&&(t.version=n),t}},{test:[/focus/i],describe:function(e){var t={name:u.FOCUS},n=ue(/(?:focus)[\s/](\d+(?:\.\d+)+)/i,e)||ue(ce,e);return n&&(t.version=n),t}},{test:[/swing/i],describe:function(e){var t={name:u.SWING},n=ue(/(?:swing)[\s/](\d+(?:\.\d+)+)/i,e)||ue(ce,e);return n&&(t.version=n),t}},{test:[/coast/i],describe:function(e){var t={name:u.OPERA_COAST},n=ue(ce,e)||ue(/(?:coast)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/yabrowser/i],describe:function(e){var t={name:u.YANDEX_BROWSER},n=ue(/(?:yabrowser)[\s/](\d+(\.?_?\d+)+)/i,e)||ue(ce,e);return n&&(t.version=n),t}},{test:[/ucbrowser/i],describe:function(e){var t={name:u.UC_BROWSER},n=ue(ce,e)||ue(/(?:ucbrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/Maxthon|mxios/i],describe:function(e){var t={name:u.MAXTHON},n=ue(ce,e)||ue(/(?:Maxthon|mxios)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/epiphany/i],describe:function(e){var t={name:u.EPIPHANY},n=ue(ce,e)||ue(/(?:epiphany)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/puffin/i],describe:function(e){var t={name:u.PUFFIN},n=ue(ce,e)||ue(/(?:puffin)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/sleipnir/i],describe:function(e){var t={name:u.SLEIPNIR},n=ue(ce,e)||ue(/(?:sleipnir)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/k-meleon/i],describe:function(e){var t={name:u.K_MELEON},n=ue(ce,e)||ue(/(?:k-meleon)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/micromessenger/i],describe:function(e){var t={name:u.WECHAT},n=ue(/(?:micromessenger)[\s/](\d+(\.?_?\d+)+)/i,e)||ue(ce,e);return n&&(t.version=n),t}},{test:[/msie|trident/i],describe:function(e){var t={name:u.INTERNET_EXPLORER},n=ue(/(?:msie |rv:)(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/\sedg\//i],describe:function(e){var t={name:u.MICROSOFT_EDGE},n=ue(/\sedg\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/edg([ea]|ios)/i],describe:function(e){var t={name:u.MICROSOFT_EDGE},n=de(/edg([ea]|ios)\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/vivaldi/i],describe:function(e){var t={name:u.VIVALDI},n=ue(/vivaldi\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/seamonkey/i],describe:function(e){var t={name:u.SEAMONKEY},n=ue(/seamonkey\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/sailfish/i],describe:function(e){var t={name:u.SAILFISH},n=ue(/sailfish\s?browser\/(\d+(\.\d+)?)/i,e);return n&&(t.version=n),t}},{test:[/silk/i],describe:function(e){var t={name:u.AMAZON_SILK},n=ue(/silk\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/phantom/i],describe:function(e){var t={name:u.PHANTOMJS},n=ue(/phantomjs\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/slimerjs/i],describe:function(e){var t={name:u.SLIMERJS},n=ue(/slimerjs\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe:function(e){var t={name:u.BLACKBERRY},n=ue(ce,e)||ue(/blackberry[\d]+\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/(web|hpw)[o0]s/i],describe:function(e){var t={name:u.WEBOS_BROWSER},n=ue(ce,e)||ue(/w(?:eb)?[o0]sbrowser\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/bada/i],describe:function(e){var t={name:u.BADA},n=ue(/dolfin\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/tizen/i],describe:function(e){var t={name:u.TIZEN},n=ue(/(?:tizen\s?)?browser\/(\d+(\.?_?\d+)+)/i,e)||ue(ce,e);return n&&(t.version=n),t}},{test:[/qupzilla/i],describe:function(e){var t={name:u.QUPZILLA},n=ue(/(?:qupzilla)[\s/](\d+(\.?_?\d+)+)/i,e)||ue(ce,e);return n&&(t.version=n),t}},{test:[/firefox|iceweasel|fxios/i],describe:function(e){var t={name:u.FIREFOX},n=ue(/(?:firefox|iceweasel|fxios)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/electron/i],describe:function(e){var t={name:u.ELECTRON},n=ue(/(?:electron)\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/chromium/i],describe:function(e){var t={name:u.CHROMIUM},n=ue(/(?:chromium)[\s/](\d+(\.?_?\d+)+)/i,e)||ue(ce,e);return n&&(t.version=n),t}},{test:[/chrome|crios|crmo/i],describe:function(e){var t={name:u.CHROME},n=ue(/(?:chrome|crios|crmo)\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:function(e){var t=!e.test(/like android/i),n=e.test(/android/i);return t&&n},describe:function(e){var t={name:u.ANDROID_BROWSER},n=ue(ce,e);return n&&(t.version=n),t}},{test:[/playstation 4/i],describe:function(e){var t={name:u.PLAYSTATION_4},n=ue(ce,e);return n&&(t.version=n),t}},{test:[/safari|applewebkit/i],describe:function(e){var t={name:u.SAFARI},n=ue(ce,e);return n&&(t.version=n),t}},{test:[/.*/i],describe:function(e){var t=-1!==e.search("\\(")?/^(.*)\/(.*)[ \t]\((.*)/:/^(.*)\/(.*) /;return{name:ue(t,e),version:de(t,e)}}}],fe=[{test:[/\bFB[\w_]+\/(Messenger|MESSENGER)/],describe:function(){return{name:M}}},{test:[/\bFB[\w_]+\//],describe:function(){return{name:N}}},{test:[/\bTwitter/i],describe:function(){return{name:B}}},{test:[/\bLine\//i],describe:function(){return{name:P}}},{test:[/\bMicroMessenger\//i],describe:function(){return{name:D}}},{test:[/\bInstagram/i],describe:function(){return{name:U}}},{test:[/\bElectron/i],describe:function(){return{name:F}}},{test:[/\bOutlook/i],describe:function(){return{name:j}}},{test:[/\bPinterest/i],describe:function(){return{name:W}}},{test:[/\bThunderbird/i],describe:function(){return{name:z}}},{test:[/\bwebview/i,/; wv/],describe:function(){return{name:H}}},{test:[/\bYaApp/i,/\bYandexSearch/i],describe:function(){return{name:q}}}],pe=[{test:[/Roku\/DVP/],describe:function(e){var t=ue(/Roku\/DVP-(\d+\.\d+)/i,e);return{name:ie,version:t}}},{test:[/windows phone/i],describe:function(e){var t=ue(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i,e);return{name:V,version:t}}},{test:[/windows/i],describe:function(e){var t=ue(/Windows ((NT|XP)( \d\d?.\d)?)/i,e);return{name:G,version:t}}},{test:[/Macintosh(.*?) FxiOS(.*?)\//],describe:function(e){var t={name:Z},n=de(/(Version\/)(\d[\d.]+)/,e);return n&&(t.version=n),t}},{test:[/macintosh/i],describe:function(e){var t=ue(/mac os x (\d+(\.?_?\d+)+)/i,e).replace(/[_\s]/g,".");return{name:K,version:t}}},{test:[/(ipod|iphone|ipad)/i],describe:function(e){var t=ue(/os (\d+([_\s]\d+)*) like mac os x/i,e).replace(/[_\s]/g,".");return{name:Z,version:t}}},{test:function(e){var t=!e.test(/like android/i),n=e.test(/android/i);return t&&n},describe:function(e){var t=ue(/android[\s/-](\d+(\.\d+)*)/i,e);return{name:Q,version:t}}},{test:[/(web|hpw)[o0]s/i],describe:function(e){var t=ue(/(?:web|hpw)[o0]s\/(\d+(\.\d+)*)/i,e),n={name:X};return t&&(n.version=t),n}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe:function(e){var t=ue(/rim\stablet\sos\s(\d+(\.\d+)*)/i,e)||ue(/blackberry\d+\/(\d+([_\s]\d+)*)/i,e)||ue(/\bbb(\d+)/i,e);return{name:Y,version:t}}},{test:[/bada/i],describe:function(e){var t=ue(/bada\/(\d+(\.\d+)*)/i,e);return{name:J,version:t}}},{test:[/tizen/i],describe:function(e){var t=ue(/tizen[/\s](\d+(\.\d+)*)/i,e);return{name:$,version:t}}},{test:[/linux/i],describe:function(){return{name:ee}}},{test:[/CrOS/],describe:function(){return{name:te}}},{test:[/PlayStation 4/],describe:function(e){var t=ue(/PlayStation 4[/\s](\d+(\.\d+)*)/i,e);return{name:ne,version:t}}}],he=[{test:[/googlebot/i],describe:function(){return{type:"bot",vendor:"Google"}}},{test:[/huawei/i],describe:function(e){var t=ue(/(can-l01)/i,e)&&"Nova",n={type:oe,vendor:"Huawei",model:""};return t&&(n.model=t),n}},{test:[/nexus\s*(?:7|8|9|10).*/i],describe:function(){return{type:re,vendor:"Nexus"}}},{test:[/ipad/i],describe:function(){return{type:re,vendor:"Apple",model:"iPad"}}},{test:[/Macintosh(.*?) FxiOS(.*?)\//],describe:function(){return{type:re,vendor:"Apple",model:"iPad"}}},{test:[/kftt build/i],describe:function(){return{type:re,vendor:"Amazon",model:"Kindle Fire HD 7"}}},{test:[/silk/i],describe:function(){return{type:re,vendor:"Amazon"}}},{test:[/tablet/i],describe:function(){return{type:re}}},{test:function(e){var t=e.test(/ipod|iphone/i),n=e.test(/like (ipod|iphone)/i);return t&&!n},describe:function(e){var t=ue(/(ipod|iphone)/i,e);return{type:oe,vendor:"Apple",model:t}}},{test:[/nexus\s*[0-6].*/i,/galaxy nexus/i],describe:function(){return{type:oe,vendor:"Nexus"}}},{test:[/[^-]mobi/i],describe:function(){return{type:oe}}},{test:function(e){return e.getBrowserName()===u.BLACKBERRY},describe:function(){return{type:oe,vendor:"BlackBerry"}}},{test:function(e){return e.getBrowserName()===u.BADA},describe:function(){return{type:oe}}},{test:function(e){return e.getBrowserName()===u.WINDOWS_PHONE},describe:function(){return{type:oe,vendor:"Microsoft"}}},{test:function(e){var t,n=Number(null===(t=String(e.getOSVersion()))||void 0===t?void 0:t.split(".")[0]);return"android"===e.getOSName(!0)&&n>=3},describe:function(){return{type:re}}},{test:function(e){return"android"===e.getOSName(!0)},describe:function(){return{type:oe}}},{test:function(e){return"macos"===e.getOSName(!0)},describe:function(){return{type:se,vendor:"Apple"}}},{test:function(e){return"windows"===e.getOSName(!0)},describe:function(){return{type:se}}},{test:function(e){return"linux"===e.getOSName(!0)},describe:function(){return{type:se}}},{test:function(e){return"playstation 4"===e.getOSName(!0)},describe:function(){return{type:ae}}},{test:function(e){return"roku"===e.getOSName(!0)},describe:function(){return{type:ae}}}],be=function(e){return String(e).toLowerCase()||""},ve=function(){function e(e){if(!e)throw new Error("UserAgent parameter can't be empty ");this.ua=e,this.parsedResult={},this.parse()}return e.prototype.getUA=function(){return this.ua},e.prototype.test=function(e){return e.test(this.ua)},e.prototype.getDetailInfo=function(e){var t=this;return e.find((function(e){if("function"==typeof e.test)return e.test(t);if(e.test instanceof Array)return e.test.some((function(e){return t.test(e)}));throw new Error("Browser's test function is not valid")}))},e.prototype.parseBrowser=function(){this.parsedResult.browser={};var e=this.getDetailInfo(le);return e&&(this.parsedResult.browser=e.describe(this.getUA())),this.parsedResult.browser},e.prototype.getBrowser=function(){return this.parsedResult.browser?this.parsedResult.browser:this.parseBrowser()},e.prototype.getBrowserName=function(e){return e?be(this.getBrowser().name):this.getBrowser().name||""},e.prototype.getBrowserVersion=function(){return this.getBrowser().version},e.prototype.parseOS=function(){this.parsedResult.os={};var e=this.getDetailInfo(pe);return e&&(this.parsedResult.os=e.describe(this.getUA())),this.parsedResult.os},e.prototype.getOS=function(){return this.parsedResult.os?this.parsedResult.os:this.parseOS()},e.prototype.getOSName=function(e){var t=this.getOS().name;return e?be(t):t||""},e.prototype.getOSVersion=function(){return this.getOS().version},e.prototype.parseApp=function(){this.parsedResult.app={};var e=this.getDetailInfo(fe);return e&&(this.parsedResult.app=e.describe(this.getUA())),this.parsedResult.app},e.prototype.getApp=function(){return this.parsedResult.app?this.parsedResult.app:this.parseApp()},e.prototype.getAppName=function(e){return e?be(this.getApp().name):this.getApp().name||""},e.prototype.parsePlatform=function(){this.parsedResult.platform={};var e=this.getDetailInfo(he);return e&&(this.parsedResult.platform=e.describe(this.getUA())),this.parsedResult.platform},e.prototype.getPlatform=function(){return this.parsedResult.platform?this.parsedResult.platform:this.parsePlatform()},e.prototype.getPlatformType=function(e){var t=this.getPlatform().type;return e?be(t):t||""},e.prototype.parse=function(){return this.parseBrowser(),this.parseOS(),this.parsePlatform(),this.parseApp(),this},e.prototype.getResult=function(){return s({},this.parsedResult)},e}(),ge=function(){function e(){}return e.getParser=function(e){if("string"!=typeof e)throw new Error("UserAgent should be a string");return new ve(e)},e.parse=function(e){return new ve(e).getResult()},e}(),we=function(){function e(){this.browserMode="unknown"}return e.prototype.retry=function(e){return new Promise((function(t){var n=0,i=!1,r=window.setInterval((function(){e()&&(window.clearInterval(r),t(i)),n++>50&&(window.clearInterval(r),t(i=!0))}),10)}))},e.prototype.run=function(){var e=this;return new Promise((function(t){(new me).browser(e).detectBrowsingMode(),e.retry((function(){return"unknown"!==e.browserMode})).then((function(){t(e.browserMode)}))}))},e}(),me=function(){function e(){this.browserData=void 0}return e.prototype.browser=function(e){return this.browserData&&"object"==typeof this.browserData||(this.browserData=this.resolve(e)),this.browserData},e.prototype.resolve=function(e){switch(ge.getParser(window.navigator.userAgent).getBrowserName()){case u.SAFARI:return new ke(e);case u.FIREFOX:return new _e(e);case u.INTERNET_EXPLORER:return new Se(e);default:return"webkitRequestFileSystem"in window||"requestFileSystem"in window?new ye(e):window.PointerEvent||"MSPointerEvent"in window?new Se(e):new Oe(e)}},e}(),ye=function(){function e(e){this.navigator=navigator,this.STORAGE_QUOTA_LIMIT=12e7,this.TEMP_STORAGE_QUOTA_LIMIT=11e7,this.BrowserModeDetector=e}return e.prototype.callbackWhenWebkitTemporaryStorageQuotaNotLimited=function(){this.BrowserModeDetector.browserMode="normal"},e.prototype.callbackWhenWebkitTemporaryStorageQuotaLimited=function(){this.BrowserModeDetector.browserMode="incognito"},e.prototype.callbackWhenWebkitStorageQuotaLimited=function(){this.BrowserModeDetector.browserMode="incognito"},e.prototype.checkWebkitTemporaryStorageQuota=function(){var e=this;void 0!==this.navigator.webkitTemporaryStorage&&void 0!==this.navigator.webkitTemporaryStorage.queryUsageAndQuota?this.navigator.webkitTemporaryStorage.queryUsageAndQuota((function(t,n){n<e.TEMP_STORAGE_QUOTA_LIMIT?e.callbackWhenWebkitTemporaryStorageQuotaLimited():e.callbackWhenWebkitTemporaryStorageQuotaNotLimited()}),(function(){e.callbackWhenWebkitTemporaryStorageQuotaNotLimited()})):this.callbackWhenWebkitTemporaryStorageQuotaNotLimited()},e.prototype.checkStorageQuota=function(){var e=this;void 0!==navigator.storage&&void 0!==navigator.storage.estimate?navigator.storage.estimate().then((function(t){(null==t?void 0:t.quota)&&(null==t?void 0:t.quota)<e.STORAGE_QUOTA_LIMIT?e.callbackWhenWebkitStorageQuotaLimited():e.callbackWhenWebkitStorageQuotaNotLimited()})):this.callbackWhenWebkitStorageQuotaNotLimited()},e.prototype.callbackWhenWebkitStorageQuotaNotLimited=function(){this.checkWebkitTemporaryStorageQuota()},e.prototype.detectBrowsingMode=function(){this.checkStorageQuota()},e}(),_e=function(){function e(e){this.BrowserModeDetector=e}return e.prototype.callbackWhenIndexedDBNotWorking=function(){this.BrowserModeDetector.browserMode="incognito"},e.prototype.callbackWhenIndexedDBWorking=function(){var e=this;"unknown"===this.BrowserModeDetector.browserMode&&this.BrowserModeDetector.retry((function(){return"done"===e.db.readyState})).then((function(t){if(t)return e.callbackWhenIndexedDBNotWorking();e.db.result&&(e.BrowserModeDetector.browserMode="normal")}))},e.prototype.detectBrowsingMode=function(){this.db=indexedDB.open("i"),this.db.onsuccess=this.callbackWhenIndexedDBWorking.bind(this),this.db.onerror=this.callbackWhenIndexedDBNotWorking.bind(this)},e}(),Se=function(){function e(e){this.BrowserModeDetector=e}return e.prototype.detectBrowsingMode=function(){this.BrowserModeDetector.browserMode="normal";try{window.indexedDB||(this.BrowserModeDetector.browserMode="incognito")}catch(e){this.BrowserModeDetector.browserMode="incognito"}},e}(),ke=function(){function e(e){this.BrowserModeDetector=e}return e.prototype.tryFillLocalStorage=function(e){var t={size:e,payload:new Array(e/4+1).join("aあ"),lastModifiedDate:new Date,name:1e5+~~(1e5*Math.random())+".txt"};try{localStorage.setItem(t.name,JSON.stringify(t))}catch(e){try{localStorage.removeItem(t.name)}catch(e){}return!1}try{localStorage.removeItem(t.name)}catch(e){}return!0},e.prototype.detectBrowsingMode=function(){var e,t,n=window,i=ge.getParser(window.navigator.userAgent),r=parseInt(null===(e=i.getOSVersion())||void 0===e?void 0:e.split(".")[0],10)||0,o=parseInt(null===(t=i.getBrowserVersion())||void 0===t?void 0:t.split(".")[0],10)||0,s=i.getOSName(!0);if(!n.safariIncognito&&navigator.cookieEnabled){try{n.openDatabase&&n.openDatabase(null,null,null,null),n.localStorage.setItem("test","1")}catch(e){this.BrowserModeDetector.browserMode="incognito"}if("unknown"===this.BrowserModeDetector.browserMode)if(n.localStorage.removeItem("test"),"ios"===s&&r>=14||"macos"===s&&o>=14||"ios"===s&&0===o)this.BrowserModeDetector.browserMode="normal";else{this.tryFillLocalStorage(5242880)?this.BrowserModeDetector.browserMode="incognito":this.BrowserModeDetector.browserMode="normal"}}else this.BrowserModeDetector.browserMode="incognito"},e}(),Oe=function(){function e(e){this.BrowserModeDetector=e}return e.prototype.detectBrowsingMode=function(){this.BrowserModeDetector.browserMode="normal"},e}(),Ee=function(){function e(){}return e.get=function(e){var t=document.cookie.match(new RegExp("(?:^|; )"+e.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g,"\\$1")+"=([^;]*)"));return t?decodeURIComponent(t[1]):void 0},e.set=function(e,t,n){void 0===n&&(n={});var i=n.expires;if("number"==typeof i&&i){var r=new Date;r.setTime(r.getTime()+1e3*i),i=n.expires=r}i instanceof Date&&(n.expires=i.toUTCString()),e=encodeURIComponent(String(e)).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent).replace(/[\(\)]/g,escape),t=encodeURIComponent(String(t)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent);var o="".concat(e,"=").concat(t);for(var s in n)n[s]&&(o+="; ".concat(s),!0!==n[s]&&(o+="=".concat(n[s].split(";")[0])));document.cookie=o},e.delete=function(e){this.set(e,"",{expires:-1})},e}(),xe=((h={})[u.AMAZON_SILK]="amazon_silk",h[u.ANDROID_BROWSER]="android",h[u.BADA]="bada",h[u.BLACKBERRY]="blackberry",h[u.CHROME]="chrome",h[u.CHROMIUM]="chromium",h[u.ELECTRON]="electron",h[u.EPIPHANY]="epiphany",h[u.FIREFOX]="firefox",h[u.FOCUS]="focus",h[u.GENERIC]="generic",h[u.GOOGLEBOT]="googlebot",h[u.INTERNET_EXPLORER]="ie",h[u.K_MELEON]="k_meleon",h[u.MAXTHON]="maxthon",h[u.MICROSOFT_EDGE]="edge",h[u.MZ_BROWSER]="mz",h[u.NAVER_WHALE_BROWSER]="naver",h[u.OPERA]="opera",h[u.OPERA_COAST]="opera_coast",h[u.OPERA_TOUCH]="opera_touch",h[u.PHANTOMJS]="phantomjs",h[u.PUFFIN]="puffin",h[u.QUPZILLA]="qupzilla",h[u.SAFARI]="safari",h[u.SAILFISH]="sailfish",h[u.SAMSUNG_INTERNET_FOR_ANDROID]="samsung_internet",h[u.SEAMONKEY]="seamonkey",h[u.SLEIPNIR]="sleipnir",h[u.SWING]="swing",h[u.TIZEN]="tizen",h[u.UC_BROWSER]="uc",h[u.VIVALDI]="vivaldi",h[u.WEBOS_BROWSER]="webos",h[u.WECHAT]="wechat",h[u.YANDEX_BROWSER]="yandex",h[u.ROKU]="roku",h),Ie=["chrome","yandex","firefox","samsung_internet","opera","opera_touch"];!function(e){e.ANDROID="android",e.IOS="ios"}(b||(b={})),function(e){e.HTTP="http",e.HTTPS="https"}(v||(v={}));var Ae={android:{chrome:"com.android.chrome",yandex:"com.yandex.browser",opera:"com.opera.browser",firefox:"org.mozilla.firefox",samsung_internet:"com.sec.android.app.sbrowser"},ios:{chrome:{https:"googlechromes://",http:"googlechrome://"},yandex:{https:"yandexbrowser-open-url://https://",http:"yandexbrowser-open-url://http://"},opera_touch:{https:"touch-https://",http:"touch-http://"},firefox:{https:"firefox://open-url%3Furl%3Dhttps%3A%2F%2F",http:"firefox://open-url%3Furl%3Dhttp%3A%2F%2F"}}},Ce=function(e){return xe[e]},Le=function(){function e(e){this.proxyParams=["authApp","app_redirect_uri"],this.parser=ge.getParser(window.navigator.userAgent);var t=this.parser.getBrowserName(),n=e.display&&t!==u.INTERNET_EXPLORER?e.display:"page";this.config=s(s(s({},m),e.universalLink),{debug:!!e.debug,generateState:!!e.generateState,display:n}),e.utmProxyDisabled||(this.proxyParams=this.proxyParams.concat(["utm_source","utm_medium","utm_campaign","utm_term","utm_content"])),this.config.debug&&(k(["Инициализируем модуль UniversalLink"],"info"),k(["Параметры инициализации: ",this.config],"info"))}return e.prototype.isAllowedBrowser=function(e){return Ie.includes(e)},e.prototype.getAdditionalRedirectParams=function(e,t,n){var i={};if(this.config.needAdditionalRedirect&&Object.prototype.hasOwnProperty.call(Ae,e)&&Object.prototype.hasOwnProperty.call(Ae[e],t))switch(e){case b.ANDROID:i.package=Ae[e][t];break;case b.IOS:var r="";try{r=decodeURIComponent(n||"")}catch(e){k(["Ошибка декодирования redirect_uri",e],"error")}var o=r.includes("".concat(v.HTTPS,"://"))?v.HTTPS:v.HTTP;i.ext_redirect_uri="".concat(Ae[e][t][o]).concat(r.replace(/^https?:\/\//,""))}return i},e.prototype.generateState=function(e){return void 0===e&&(e=43),C(e)},e.prototype.buildOidcParams=function(e){var t={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n))try{t[n]=decodeURIComponent(e[n])}catch(e){t[n]="",this.config.debug&&k(["Ошибка декодирования oidc параметра",e],"error")}e.scope&&e.scope.includes("+")&&(e.scope=e.scope.split("+").join(" "));var i=Ce(this.parser.getBrowserName()),r=this.parser.getOSName(!0),o=s({},this.getAdditionalRedirectParams(r,i,t.redirect_uri));o.display=this.config.display||"page";for(var a=y(),c=Object.keys(a),u=0;u<c.length;u+=1)this.proxyParams.includes(c[u])&&(o[c[u]]=a[c[u]]);if(this.config.generateState&&"popup"===this.config.display&&!function(){var e=y();return!(!e.code&&!e.error||!e.state)}()){var d=this.generateState();Ee.set("sbid_state",d,{path:"/"}),o.state=d}return s(s({},t),o)},e.prototype.run=function(e){return void 0===e&&(e={}),a(this,void 0,void 0,(function(){var t,n,i,r,o,a,d,l,f,p,h,v;return c(this,(function(c){switch(c.label){case 0:return t=s(s({},this.config.params),e),[4,this.detect()];case 1:return n="incognito"===c.sent(),i=this.parser.getResult(),r=Ce(this.parser.getBrowserName()),o=this.parser.getOSName(!0),a=this.buildOidcParams(t),d=o===b.ANDROID&&this.isAllowedBrowser(r),l=o===b.IOS&&(r===xe[u.SAFARI]||this.isAllowedBrowser(r)&&this.config.needAdditionalRedirect),f=!n&&!i.app.name&&(l||d),p=_(this.config.deeplinkUrl,e),h=_(f?this.config.universalLinkUrl:this.config.baseUrl,e),v={isPrivate:n,isUniversalLink:f,app:i.app.name,isWebview:!!i.app.name,os:o,browser:r,link:h,deeplink:p,oidc:a},this.config.debug&&k(["Получены данные для формирования ссылки: ",v]),[2,Promise.resolve(v)]}}))}))},e.prototype.detect=function(){try{return(new we).run()}catch(e){return Promise.resolve("normal")}},e}(),Re={enable:!1,debug:!1,mode:"default",timeout:1500,baseUrl:d},Te=function(e){var t=function(t){var n;try{n=JSON.parse(t.data)}catch(e){return}e(n,t)};return window.addEventListener("message",t),function(){return window.removeEventListener("message",t)}},Me=function(e,t){!function(e,t,n){void 0===n&&(n="*"),t&&t.postMessage(JSON.stringify(e),n)}(e,t)},Ne=function(){function e(e){this.isFastLoginIframeRegistered=!1,this.isFastLoginDataFetched=!1,this.iFrameName="sberid-iframe",this.isFastLoginIframeRegistered=!1,this.isFastLoginDataFetched=!1,this.config=s(s(s({},Re),e.fastLogin),{debug:e.debug,baseUrl:e.baseUrl||d,oidcParams:e.oidc})}return e.prototype.removeLoadDataListener=function(){},e.prototype.authorization=function(e){return a(this,void 0,void 0,(function(){var t,n;return c(this,(function(i){switch(i.label){case 0:return(t=e||this.config.oidcParams)?(n=this.buildUrl(t),[4,this.createIFrame(n).catch((function(e){return e}))]):[2,new Promise((function(e,t){t({code:"error",error:"invalid_request",description:g.invalid_request})}))];case 1:return[2,i.sent()]}}))}))},e.prototype.buildUrl=function(e){var t=s({prompt:"none"},e);return _("".concat(this.config.baseUrl,"/CSAFront/oidc/authorizelow.do"),t)},e.prototype.createIFrame=function(e){return a(this,void 0,void 0,(function(){var t=this;return c(this,(function(n){return this.fastLoginIframe=function(e,t,n,i){void 0===t&&(t="sberid-iframe");var r=document.createElement("iframe");return r.setAttribute("src",e),r.setAttribute("frameborder","0"),r.setAttribute("name",t),r.setAttribute("id",t),r.width="0",r.height="0",r.style.display="none",r.style.position="absolute",r.style.left="-9999px","function"==typeof n&&(r.onload=n),"function"==typeof i&&(r.onerror=i),r}(e,this.iFrameName,(function(e){t.onFastLoginIframeCreateSuccess(e)}),(function(){throw t.destroyFastLogin(),{success:!1,error:{code:"error",error:"iframe_error",description:"Ошибка при создании iframe"}}})),document.body.append(this.fastLoginIframe),[2,new Promise((function(e,n){var i=setTimeout((function(){t.destroyFastLogin(),n({success:!1,error:{type:"timeout",description:"Ошибка при создании iframe"}})}),t.config.timeout),r=Te((function(o){"iframe is registered"===o.type&&(clearTimeout(i),t.isFastLoginIframeRegistered=!0,t.loadFastLoginData().then((function(t){e(t)})).catch((function(e){n(e)})).finally((function(){t.destroyFastLogin()})),r())}))}))]}))}))},e.prototype.onFastLoginIframeCreateSuccess=function(e){this.config.debug&&k(["Iframe для быстрого входа создан",e])},e.prototype.loadFastLoginData=function(){return a(this,void 0,void 0,(function(){var e=this;return c(this,(function(t){switch(t.label){case 0:return this.isFastLoginIframeRegistered?[4,this.fetchFastLoginData()]:[3,2];case 1:t.sent(),t.label=2;case 2:return[2,new Promise((function(t,n){e.removeLoadDataListener=Te((function(i){return a(e,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:switch(i.type){case"iframe is registered":return[3,1];case"success":return[3,3];case"error":return[3,4]}return[3,5];case 1:return[4,this.fetchFastLoginData()];case 2:return e.sent(),[3,6];case 3:return this.config.debug&&k(["Успешно получены данные при быстром входе",i.data],"success"),t(i.data),[3,6];case 4:return this.config.debug&&k(["Ошибка получения данных при быстром входе",i.data],"error"),n(i.data),[3,6];case 5:return[3,6];case 6:return[2]}}))}))}))}))]}}))}))},e.prototype.fetchFastLoginData=function(){var e;return a(this,void 0,void 0,(function(){return c(this,(function(t){return this.isFastLoginDataFetched||!this.fastLoginIframe||(Me({type:"fetch data"},null===(e=this.fastLoginIframe)||void 0===e?void 0:e.contentWindow),this.isFastLoginDataFetched=!0),[2]}))}))},e.prototype.destroyFastLogin=function(){this.config.debug&&k(["Iframe для быстрого входа удален"]),this.fastLoginIframe&&this.fastLoginIframe.remove(),this.removeLoadDataListener&&this.removeLoadDataListener(),this.isFastLoginIframeRegistered=!1,this.isFastLoginDataFetched=!1},e}(),Be=function(e,t){return a(void 0,void 0,void 0,(function(){return c(this,(function(n){switch(n.label){case 0:return[4,r.default(e,t).then((function(e){return a(void 0,void 0,void 0,(function(){var t;return c(this,(function(n){switch(n.label){case 0:if(!e.ok)return[2,{success:!1}];t=void 0,n.label=1;case 1:return n.trys.push([1,3,4,5]),[4,e.json()];case 2:return t=n.sent(),[3,5];case 3:return n.sent(),[3,5];case 4:return[7];case 5:return[2,{success:!0,data:t}]}}))}))})).catch((function(){return{success:!1}}))];case 1:return[2,n.sent()]}}))}))},Pe=function(e,t,n){return a(void 0,void 0,void 0,(function(){var i,r;return c(this,(function(o){return i=new AbortController,t.signal=i.signal,[2,Promise.race([Be(e,t),new Promise((function(t,o){r=setTimeout((function(){i.abort();var t={success:!1,error:{description:"Ошибка при выполнении запроса ".concat(e),code:"request_fail"}};o(t)}),n)}))]).finally((function(){clearTimeout(r)}))]}))}))},De=function e(){var t=this;return this.cache={},this.set=function(e,n){var i={data:n};t.cache[e]=i},this.get=function(e){var n=t.cache[e];return new Promise(n?function(e){return e(n.data)}:function(e){return e(void 0)})},this.remove=function(e){delete t.cache[e]},this.all=function(){return Object.keys(t.cache)},e.instance?e.instance:(e.instance=this,this)},Ue=function(){function e(){if(this.config={baseUrl:d},this.cache=new De,this.listeners=[],e.instance)throw new Error("Error: Instantiation failed: Use UserHelper.getInstance() instead of new.");e.instance=this}return e.getInstance=function(){return e.instance},e.prototype.setConfig=function(e){this.config=s(s({},this.config),e)},e.prototype.setListener=function(e){this.listeners.push(e)},e.prototype.callListeners=function(e){for(var t=0;t<this.listeners.length;t+=1)this.listeners[t].call(this,e)},e.prototype.getUser=function(e){return void 0===e&&(e=!0),a(this,void 0,void 0,(function(){var t,n,i;return c(this,(function(r){switch(r.label){case 0:return this.config.baseUrl&&this.config.clientId?(t="".concat(this.config.baseUrl,"/CSAFront/api/oidc/sbid?client_id=").concat(this.config.clientId),[4,this.cache.get("user")]):[2];case 1:return n=r.sent(),!e&&n?[2,n]:[4,Pe(t,l,1e4)];case 2:return(i=r.sent()).success&&(n=i.data),n?(this.cache.set("user",n),this.callListeners(n),[2,n]):[2]}}))}))},e.prototype.resetUser=function(){return a(this,void 0,void 0,(function(){var e;return c(this,(function(t){switch(t.label){case 0:return this.config.baseUrl&&this.config.clientId?(e="".concat(this.config.baseUrl,"/CSAFront/api/oidc/sbid/reset?client_id=").concat(this.config.clientId),[4,Pe(e,l,1e4)]):[2,!1];case 1:return t.sent().success?(this.cache.remove("user"),this.callListeners(),[2,!0]):[2,!1]}}))}))},e.instance=new e,e}(),Fe={default:{anonymous:"Войти по Сбер ID",personal:"Войти как {{userName}}"},resume:{anonymous:"Продолжить со Сбер ID",personal:"Продолжить как {{userName}}"},login:{anonymous:"Сбер ID",personal:"Войти как {{userName}}"},fill:{anonymous:"Заполнить со Сбер ID",personal:"Войти как {{userName}}"},custom:{anonymous:"Войти по Сбер ID",personal:"Войти как {{userName}}"}},je=function(){function e(e,t,n){var i,r,o,a,c,u,d,l,f=this;this.config={personalization:!!e.personalization,debug:!!e.debug,sa:!!(null===(i=e.sa)||void 0===i?void 0:i.enable),changeUser:!!e.changeUser,type:(null===(r=e.buttonProps)||void 0===r?void 0:r.type)||"default",loader:null===(a=null===(o=e.buttonProps)||void 0===o?void 0:o.loader)||void 0===a||a,logo:null===(u=null===(c=e.buttonProps)||void 0===c?void 0:c.logo)||void 0===u||u,size:(null===(d=e.buttonProps)||void 0===d?void 0:d.size)||"default"},this.container=t,this.text=s(s({},Fe[this.config.type]),"custom"===this.config.type?null===(l=e.buttonProps)||void 0===l?void 0:l.custom:{}),this.userHelper=Ue.getInstance(),this.userHelper.setListener(this.handleUserChange.bind(this)),this.link=this.create(),n&&this.link.addEventListener("click",(function(e){n(e,f.link)})),this.container.appendChild(this.link),this.config.changeUser&&this.initChangeUser()}return e.prototype.initChangeUser=function(){var e=this;this.changeUserElement=this.link&&this.link.querySelector(".sbid-button-change-user")||void 0,this.changeUserElement&&(this.changeUserPopupElement=this.changeUserElement.querySelector(".sbid-button-change-user__popup")||void 0,this.changeUserElement.addEventListener("click",(function(t){if(e.changeUserElement){var n="none"===e.changeUserElement.dataset.stage;e.changeUserElement.dataset.stage=n?"popup":"none",n&&e.changeUserPopupElement&&O(e.changeUserPopupElement,(function(){e.changeUserElement&&(e.changeUserElement.dataset.stage="none")}))}t.preventDefault(),t.stopPropagation()})),this.changeUserPopupElement&&this.changeUserPopupElement.addEventListener("click",this.changeUser.bind(this)))},e.prototype.changeUser=function(e){return a(this,void 0,void 0,(function(){var t,n=this;return c(this,(function(i){switch(i.label){case 0:return x(),this.config.sa&&T({eventCategory:"Login",eventAction:"sberid_Change_User_Button_Click",eventType:"Click"}),this.config.debug&&k(["Сбрасываем информацию о пользователе"],"info"),[4,this.userHelper.resetUser()];case 1:return i.sent()?(this.config.debug&&k(["Данные о пользователе удалены"],"success"),this.config.sa&&T({eventCategory:"Login",eventAction:"sberid_Change_User_Result",eventType:"Result",description:"success"}),this.changeUserElement&&(this.changeUserElement.dataset.stage="none")):(this.config.debug&&k(["Ошибка при удалении данных о пользователе"],"error"),this.config.sa&&T({eventCategory:"Login",eventAction:"sberid_Change_User_Result",eventType:"Result",description:"fail"}),this.changeUserElement&&(this.changeUserElement.dataset.stage,(t=this.changeUserElement.querySelector(".sbid-button-change-user__error")||void 0)&&(t.innerHTML="Сервис временно недоступен",O(t,(function(){n.changeUserElement&&(n.changeUserElement.dataset.stage="none")}))))),I(),e.preventDefault(),e.stopPropagation(),[2]}}))}))},e.prototype.handleUserChange=function(e){i.default(e,this.user)||(this.user=e,this.setText())},e.prototype.getSize=function(){var e=document.createElement("div"),t=document.getElementsByTagName("body")[0],n=this.create();e.className="sbid-check-button-container",e.id="i-sbid-check-button-container",e.appendChild(n),t.appendChild(e);var i=n.getBoundingClientRect();return e.remove(),i},e.prototype.isEnoughSpaceFromPersonalization=function(){var e,t=this.getSize(),n=this.config.changeUser?24:0;return!(t.width+n>=(null===(e=this.container.getBoundingClientRect())||void 0===e?void 0:e.width))},e.prototype.create=function(){var e=document.createElement("a");return e.className="sbid-button sbid-button--".concat(this.config.size),e.id="i-sbid-button-".concat(C(6)),e.dataset.personalization="false",e.innerHTML="\n ".concat(this.config.logo?'<span class="sbid-button__logo"><svg style="display: block" viewBox="0 0 26 26" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M13 0C16.0927 0 18.9337 1.08103 21.1657 2.88421L18.6371 4.74793C17.0315 3.64848 15.0899 3.00354 13 3.00354C7.48924 3.00354 3.00587 7.48999 3.00587 13.0013C3.00587 18.5126 7.48924 22.9965 13 22.9965C18.5134 22.9965 22.9968 18.5126 22.9968 13.0013C22.9968 12.9118 22.9941 12.8223 22.9924 12.7328L25.7912 10.6699C25.9289 11.4245 26 12.2055 26 13.0013C26 20.1807 20.1795 26 13 26C5.82135 26 0 20.1807 0 13.0013C0 5.81931 5.82135 0 13 0ZM23.2856 5.05241C23.9006 5.84651 24.4262 6.71169 24.8456 7.63565L13.0002 16.3673L8.05093 13.2628V9.52921L13.0002 12.6337L23.2856 5.05241Z" fill=":logoFill:"/></svg></span>':"",'\n <span class="sbid-button__text">').concat(this.getText().text,"</span>\n ").concat(this.config.changeUser?'<span class="sbid-button-change-user" data-stage="none"><svg width="4" height="18" viewBox="0 0 4 18" fill="none" xmlns="http://www.w3.org/2000/svg"><circle cx="2" cy="2" r="2" fill="white"/><circle cx="2" cy="9" r="2" fill="white"/><circle cx="2" cy="16" r="2" fill="white"/></svg><span class="sbid-button-change-user__popup">Сменить пользователя</span></span><span class="sbid-button-change-user__error"></span></span>':"","\n ").concat(this.config.loader?'<span class="sbid-button-loader"><svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 40 40" enable-background="new 0 0 40 40" xml:space="preserve"><path opacity="0.2" fill="#fff" d="M20.201,5.169c-8.254,0-14.946,6.692-14.946,14.946c0,8.255,6.692,14.946,14.946,14.946 s14.946-6.691,14.946-14.946C35.146,11.861,28.455,5.169,20.201,5.169z M20.201,31.749c-6.425,0-11.634-5.208-11.634-11.634 c0-6.425,5.209-11.634,11.634-11.634c6.425,0,11.633,5.209,11.633,11.634C31.834,26.541,26.626,31.749,20.201,31.749z"/><path fill="#fff" d="M26.013,10.047l1.654-2.866c-2.198-1.272-4.743-2.012-7.466-2.012h0v3.312h0 C22.32,8.481,24.301,9.057,26.013,10.047z"><animateTransform attributeType="xml" attributeName="transform" type="rotate" from="0 20 20" to="360 20 20" dur="0.5s" repeatCount="indefinite"/></path></svg></span>':"","\n "),e},e.prototype.getText=function(){if(this.config.personalization&&this.user){var e=[];return this.user.firstname&&e.push(this.user.firstname),this.user.surname&&e.push(this.user.surname),{text:this.text.personal.replace("{{userName}}",e.join(" ")),personalization:!0}}return{text:this.text.anonymous,personalization:!1}},e.prototype.setText=function(){if(this.isEnoughSpaceFromPersonalization()&&this.link){var e=this.link.querySelector(".sbid-button__text"),t=this.getText();e&&(e.innerHTML=t.text),this.link.dataset.personalization=t.personalization.toString()}},e.prototype.disable=function(){var e;null===(e=this.link)||void 0===e||e.setAttribute("disabled","disabled")},e.prototype.enable=function(){var e;null===(e=this.link)||void 0===e||e.removeAttribute("disabled")},e.prototype.isDisabled=function(){var e;return null===(e=this.link)||void 0===e?void 0:e.hasAttribute("disabled")},e.prototype.setUrl=function(e){var t;null===(t=this.link)||void 0===t||t.setAttribute("href",e)},e.prototype.getButtonElement=function(){return this.link},e}(),We=function(e){function t(t,n,i){var r=s(s({},t),{buttonProps:{type:"resume"}});return e.call(this,r,n,i)||this}return function(e,t){function n(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}(t,e),t.prototype.isEnoughSpaceFromPersonalization=function(){return!0},t}(je),ze={autoCloseDelay:90,autoClose:!0,enable:!1,animation:!0,sa:!1,position:"bottom-right",offset:{top:30,bottom:30,left:30,right:30},debug:!1,fastLogin:!1},He=function(e,t,n,i){return new Promise((function(r){var o=+new Date;n.style.opacity=e;var s=function(){n.style.opacity="".concat(+n.style.opacity+t*(+new Date-o)/i),o=+new Date,+n.style.opacity<1?requestAnimationFrame&&requestAnimationFrame(s)||setTimeout(s,16):r()};s()}))},qe=He.bind(null,"0",1),Ve=He.bind(null,"1",-1),Ge=function(){function e(t){var n,i,r;this.parser=ge.getParser(window.navigator.userAgent),this.onSuccessCallback=function(){},this.onErrorCallback=function(){},this.notification=document.createElement("div"),this.config=s(s(s({},ze),t.notification),{position:e.getDefaultPosition(t.notification&&t.notification.position),fastLogin:!!(null===(n=t.fastLogin)||void 0===n?void 0:n.enable),sa:!!(null===(i=t.sa)||void 0===i?void 0:i.enable),debug:!!t.debug}),this.userHelper=Ue.getInstance(),this.userHelper.setConfig({baseUrl:t.baseUrl,clientId:t.oidc.client_id}),this.userHelper.setListener(this.handleUserChange.bind(this)),this.universalLinkDetect=new Le(t),this.fastLogin=new Ne(t),this.config.sa&&"auto"===(null===(r=null==t?void 0:t.sa)||void 0===r?void 0:r.init)&&R(t),t.onSuccessCallback&&(this.onSuccessCallback=t.onSuccessCallback),t.onErrorCallback&&(this.onErrorCallback=t.onErrorCallback),this.create(t),this.setOIDCParams(t)}return e.prototype.handleUserChange=function(e){i.default(this.user,e)||(this.user=e,e||this.hide())},e.prototype.setOIDCParams=function(e){return a(this,void 0,void 0,(function(){var t,n,i,r;return c(this,(function(o){switch(o.label){case 0:return t=this.universalLinkDetect.buildOidcParams(e.oidc),n=Object.keys(t),i=n.includes("app_redirect_uri")||n.includes("authApp")||"false"===n.is_universal_link,!e.mweb2app||i?[3,2]:[4,this.universalLinkDetect.run(t)];case 1:return r=o.sent(),this.button.setUrl(r.link),[3,3];case 2:this.button.setUrl(_(f(e.baseUrl),t)),o.label=3;case 3:return this.oidcParams=s({},t),[2]}}))}))},e.prototype.silentAuthorization=function(){return a(this,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return[4,this.fastLogin.authorization(this.oidcParams)];case 1:return[2,e.sent()]}}))}))},e.prototype.create=function(e){return a(this,void 0,void 0,(function(){var t,n,i,r;return c(this,(function(o){return this.notification||(this.notification=document.createElement("div")),t=document.getElementsByTagName("body")[0],(n=document.createElement("div")).className="sbid-notification-banner",n.id="i-sbid-notification-banner",function(e,t){if(null==e?void 0:e.style)for(var n in t)e.style[n]=t[n]}(n,this.getStyle()),(i=document.createElement("div")).innerHTML="Вход по Сбер ID",i.className="sbid-notification-banner__label",n.appendChild(i),(r=document.createElement("a")).innerHTML='<svg width="12" height="12" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M6 4.65094L10.3675 0.282877C10.7431 -0.0927631 11.3485 -0.0942703 11.721 0.27826C12.0961 0.653395 12.0914 1.25686 11.7164 1.63195L7.34886 6L11.7164 10.368C12.0914 10.7431 12.0961 11.3466 11.721 11.7217C11.3485 12.0943 10.7431 12.0928 10.3675 11.7171L6 7.34906L1.63247 11.7171C1.25688 12.0928 0.651469 12.0943 0.278986 11.7217C-0.0960822 11.3466 -0.0914182 10.7431 0.283602 10.368L4.65114 6L0.283602 1.63195C-0.0914182 1.25686 -0.0960822 0.653395 0.278986 0.27826C0.651469 -0.0942703 1.25688 -0.0927631 1.63247 0.282877L6 4.65094Z" fill="#767676"/></svg>',r.className="sbid-notification-banner__close",n.appendChild(r),r.addEventListener("click",this.onClose.bind(this)),this.button=new We(e,n,e.onButtonClick||this.handleButtonClick.bind(this)),t.appendChild(n),this.notification=n,[2]}))}))},e.prototype.handleButtonClick=function(e){var t,n;return a(this,void 0,void 0,(function(){var i,r;return c(this,(function(o){switch(o.label){case 0:return e.preventDefault(),e.stopPropagation(),"true"===(null===(t=e.target)||void 0===t?void 0:t.getAttribute("disabled"))?[2,!1]:(x(),this.button.disable(),this.config.sa&&T({eventCategory:"Login",eventAction:"sberid_Banner_Login_Button_Click",eventType:"Click"}),i=(null===(n=e.target.closest(".sbid-button"))||void 0===n?void 0:n.getAttribute("href"))||"",this.user&&this.config.fastLogin?[4,this.silentAuthorization()]:[3