",{class:e}).text(t),r.append(n),$("#mobile-os-access-text").append(r)})},setMobileOsAccess:function(){var e=$("#mobile-os-access"),n=$(document.createDocumentFragment()),t=$("#mobile-os-access div a"),r="";$.each(s["mobile-os-access"].text,function(e,t){e=$("
"),$(e).addClass("error")}function isValidUnlockData(e,t){var n=!0;return e.length<8&&(showErrorUnderField("#unlock_code",{ru:"Минимальная длина кода разблокировки 8 символов",uk:"Мінімальна довжина коду розблокування 8 символів",en:"The minimum length of unlock code is 8 characters"}[localStorage.getItem("locale")||"uk"]),n=!1),PasswordValidator.isSecurityRecommendationParam()?PasswordValidator.checkPasswordRecommendation(t)||(showErrorUnderField("#new_device_password",PasswordValidator.getSecurityErrorMessage()),n=!1):t.length<6&&(showErrorUnderField("#new_device_password",{ru:"Минимальная длина пароля 6 символов",uk:"Мінімальна довжина паролю 6 символів",en:"The minimum password length is 6 characters"}[localStorage.getItem("locale")||"uk"]),n=!1),n&&PasswordValidator.isSecurityVocabularyParam()&&(PasswordValidator.checkPasswordVocabulary(t)||(showErrorUnderField("#new_device_password",PasswordValidator.getSecurityErrorMessage()),n=!1)),n}function changeStorageType(e){if(clearErrorMessage(),e&&e!==authorizationFormState.storageType&&(authorizationFormState.storageType=e,clearPassword($("#device-password-ru, #device-password-uk, #device-password-en")),clearPassword($("#password-ru, #password-uk, #password-en"))),"DEVICE"===e)visibility(["#keystore-input-ru","#keystore-input-uk","#keystore-input-en","#select-file-btn","#passwords",".keys"],!(authorizationFormState.needStoragePassword=!0)),$("#storage_password_panel").hide(),visibility([".device-list","#device-passwords","#device-password-btn"],!0),$(".enter").prop("disabled",!0),getDeviceList();else{visibility(["#keystore-input-ru","#keystore-input-uk","#keystore-input-en","#select-file-btn","#passwords",".keys","button.enter"],!(authorizationFormState.needStoragePassword=!1)),visibility([".device-list","#device-passwords","#device-password-btn","button.unlock"],!1),$(".enter").prop("disabled",!1),$("#keys").trigger("refresh",{array:[]});var t=localStorage.getItem("key_path");if(t)return SignPluginServices.getDefaultSession().getKeysListFromFileStorage(t).done(onKeysListFetched).done(function(){$("#keystore-input-ru, #keystore-input-uk, #keystore-input-en").val(t)}).fail(showErrorMessage)}}function changeDeviceList(e){clearErrorMessage(),clearPassword($("#device-password-ru, #device-password-uk, #device-password-en")),visibility([".keys",".unlock"],!1),visibility([".enter","#device-password-btn","#device-passwords"],!0),$(".enter").prop("disabled",!0),$("#device-password-ru, #device-password-uk, #device-password-en, #device-password-btn").prop("disabled",!1),(authorizationFormState.device=e)&&"initialized"!==e.deviceState&&(visibility(["#device-password-btn","#device-passwords"],!1),showErrorMessage("pukBlocked"===e.deviceState?{ru:"Устройство заблокировано или возникла непредвиденная ошибка. Обратитесь в банк.",uk:"Пристрій заблоковано або виникла непередбачена помилка. Зверніться до банку.",en:"Device is locked or unexpected error occurred. Contact your bank."}[localStorage.getItem("locale")||"uk"]:"pinBlocked"===e.deviceState&&"iToken"===e.deviceModel?{ru:"Устройство заблокировано в результате неверного ввода пароля. Выберите другое хранилище.",uk:"Пристрій заблоковано внаслідок невірного вводу пароля. Оберіть інше сховище.",en:"Device is locked as a result of an incorrect password input. Select another storage."}[localStorage.getItem("locale")||"uk"]:"notInitialized"===e.deviceState?{ru:"Выбранный токен перед использованием необходимо проинициализировать. Вы можете сделать это при регистрации нового клиента или создании ключа ЭП.",uk:"Обраний токен перед використанням необхідно проініціалізувати. Ви можете зробити це під час реєстрації нового клієнта або створення ключа ЕП.",en:"Selected token should be initialized before using. You can do this at new client registration or EDS key creation."}[localStorage.getItem("locale")||"uk"]:(visibility([".unlock"],!0),visibility([".enter"],!1),{ru:"Устройство заблокировано в результате неверного ввода пароля. Вы можете разблокировать устройство или выбрать другое хранилище.",uk:"Пристрій заблоковано внаслідок невірного вводу пароля. Ви можете розблокувати пристрій або обрати інше сховище.",en:"Device is locked as a result of incorrect password input. You can unlock the device or select another storage."}[localStorage.getItem("locale")||"uk"])))}function getDeviceList(){SignPluginServices.getDefaultSession().getDeviceList().then(function(e){var r=[],i={ru:{unnamed:"Безымянный",usb:"USB-токен"},uk:{unnamed:"Без назви",usb:"USB-токен"},en:{unnamed:"Untitled",usb:"USB-token"}}[localStorage.getItem("locale")||"uk"];$.each(e,function(e,t){var n="notInitialized"===t.deviceState?i.unnamed+"("+t.deviceSerialNumber+")":"";r.push({name:i.usb+' "'+(t.deviceName||n)+'"',id:t.deviceId,deviceState:t.deviceState,deviceModel:t.deviceModel,deviceVendor:t.deviceVendor})}),$("#device-list").trigger("refresh",{array:r}),$("#device-list").trigger("chooseById",r[0].id)},function(e){showErrorMessage(e)})}function getKeyListFromDevice(){$("#device-password-btn").prop("disabled",!0),clearErrorMessage();var n=localStorage.getItem("locale")||"uk",e=authorizationFormState.device||{},r=e.id,t=document.getElementById("device-password-"+n).input_pw;if(!r||!t)return t||$(".device-password").addClass("error"),r||$("#device-list").addClass("error"),showErrorMessage({ru:"Поле обязательно для заполнения. Проверьте информацию в полях, отмеченных красным.",uk:"Поле обов'язкове до заповнення. Перевірте інформацію в полях, відмічених червоним.",en:"Required field. Check the information in the fields marked in red."}[n]),void $("#device-password-btn").prop("disabled",!1);var i="AUTHOR"===e.deviceVendor,e="true"===localStorage.getItem("is_multi_client")?1:0;SignPluginServices.getDefaultSession().getKeyListFromDevice(r,t,e).then(function(e){if(0===e.length)return $("#device-password-btn").prop("disabled",!1),void showErrorMessage({ru:"В выбранном хранилище ключи отсутствуют !",uk:"В обраному сховищі ключі відсутні !",en:"There is no keys in selected storage !"}[n]);$("#device-password-ru, #device-password-uk, #device-password-en").prop("disabled",!0),$(".enter").prop("disabled",!1);var e=_.chain(e).map(function(e){return{id:i?!0===e.active?"ACTIVE":"NOT_ACTIVE":e.alias,name:e.alias}}).sort(function(e,t){return e.name.localeCompare(t.name)}).value(),t=$("#keys");t.trigger("refresh",{array:e}),1===_.size(e)?t.trigger("chooseById",_.first(e).id):i?(e=_.findWhere(e,{id:"ACTIVE"}),t.trigger("chooseById",e.id)):(e=localStorage.getItem("lastUsedKeyAliasFromDevice")||"",t.trigger("chooseById",e)),i||visibility([".keys"],!0)},function(e){$("#device-password-btn").prop("disabled",!1),20===(e||{}).errorCode?SignPluginServices.getDefaultSession().getDeviceList().then(function(e){$.each(e,function(e,t){r===t.deviceId&&"initialized"!==t.deviceState&&getDeviceList()})}):(showErrorMessage(e),(e=$(".device-password")).addClass("error"),clearPassword(e))})}function selectFileStorage(){clearErrorMessage(),SignPluginServices.getDefaultSession().selectFile().then(function(e){return localStorage.setItem("key_path",e),authorizationFormState.needStoragePassword=!1,SignPluginServices.getDefaultSession().getKeysListFromFileStorage(e).done(onKeysListFetched).done(function(){$("#keystore-input-ru, #keystore-input-uk, #keystore-input-en").val(e)}).fail(showErrorMessage)},function(e){SignPluginServices.getDefaultSession().forgetStorage(),showErrorMessage(e)})}function onKeysListFetched(e){null===e?($("#storage_password_panel").show(),$("#keys").parent().hide(),$("#passwords").hide(),$("#enter").prop("disabled",!0)):($("#enter").prop("disabled",!1),e=e.answer,$("#storage_password_panel").hide(),$("#keys").parent().show(),$("#passwords").show(),fillKeysList(e),0 div:first-child, p").each(function(e,t){var t=$(t),n=t.attr("class").split(" ").shift();t.attr("class",n)})})}function disableRegistryButtons(){$(".key-is-present-button").hide(),$(".key-is-absent-button").hide()}function newClientsInternalKeyRegistrationAllowed(){return"1"===_.findWhere(scenarioRegistration,{scenario:"new_clients.internal_key"}).show}function newClientsAkccKeyRegistrationAllowed(){return!!isPKIEnabled&&"1"===_.findWhere(scenarioRegistration,{scenario:"new_clients.akcc_key"}).show}function newEmployeesInternalKeyRegistrationAllowed(){return"1"===_.findWhere(scenarioRegistration,{scenario:"new_employees.internal_key"}).show}function newEmployeesAkccKeyRegistrationAllowed(){return!!isPKIEnabled&&"1"===_.findWhere(scenarioRegistration,{scenario:"new_employees.akcc_key"}).show}function newKeysInternalKeyRegistrationAllowed(){return"1"===_.findWhere(scenarioRegistration,{scenario:"new_keys.internal_key"}).show}function newKeysAkccKeyRegistrationAllowed(){return!!isPKIEnabled&&"1"===_.findWhere(scenarioRegistration,{scenario:"new_keys.akcc_key"}).show}function allScenarioRegistrationDisabled(){return!(newClientsInternalKeyRegistrationAllowed()||newClientsAkccKeyRegistrationAllowed()||newEmployeesInternalKeyRegistrationAllowed()||newEmployeesAkccKeyRegistrationAllowed()||newKeysInternalKeyRegistrationAllowed()||newKeysAkccKeyRegistrationAllowed())}function getAllowedRegistrationLinksSelectors(){var e=[];return(newClientsInternalKeyRegistrationAllowed()||newClientsAkccKeyRegistrationAllowed())&&e.push("#new-company"),(newEmployeesInternalKeyRegistrationAllowed()||newEmployeesAkccKeyRegistrationAllowed())&&e.push("#new-employee"),(newKeysInternalKeyRegistrationAllowed()||newKeysAkccKeyRegistrationAllowed())&&e.push("#new-key"),e.join(",")}function goToOnlyOneAllowedScenarioRegistration(){var e={"new_clients.internal_key":newClientsInternalKeyRegistrationAllowed(),"new_clients.akcc_key":newClientsAkccKeyRegistrationAllowed(),"new_employees.internal_key":newEmployeesInternalKeyRegistrationAllowed(),"new_employees.akcc_key":newEmployeesAkccKeyRegistrationAllowed(),"new_keys.internal_key":newKeysInternalKeyRegistrationAllowed(),"new_keys.akcc_key":newKeysAkccKeyRegistrationAllowed()},n={},e=(_.each(e,function(e,t){!0===e&&(n[t]=t)}),_.keys(n));if(1===e.length)switch(localStorage.setItem("allowed_only_one_scenario_registration",!0),n[e[0]]){case"new_clients.internal_key":isNewClient=!0,registrationType="newCompany",toRegistration();break;case"new_clients.akcc_key":isNewClient=!0,registrationType="newCompany",toRegistrationPKIEnabled();break;case"new_employees.internal_key":isNewClient=!1,registrationType="newEmployee",toRegistration();break;case"new_employees.akcc_key":isNewClient=!1,registrationType="newEmployee",toRegistrationPKIEnabled();break;case"new_keys.internal_key":isNewClient=!1,registrationType="newKey",toRegistration();break;case"new_keys.akcc_key":isNewClient=!1,registrationType="newKey",toRegistrationPKIEnabled()}else localStorage.setItem("allowed_only_one_scenario_registration",!1)}function loadScenarioRegistration(){return $.get(window.location.protocol+"//"+window.location.host+"/uweb/reference/scenario_registration")}function setTooltipPosition(){function e(e){if(!e.length)return 0;var t=e.position(),e=e.width();return t.left+e/2}var t=$(".tooltip.new-company"),n=$(".tooltip.new-employee"),r=$(".tooltip.new-key"),i=e($("a#new-company")),o=e($("a#new-employee")),a=e($("a#new-key"));t.css({left:i-t.width()/2}),n.css({left:o-n.width()/2}),r.css({left:a-r.width()/2})}function prepareChangeLocale(e){e.preventDefault(),authorizationFormState.storageType&&$(".storage-type."+e.target.id).trigger("chooseById",authorizationFormState.storageType),changeLocale(e.target.id),CmsAPI.render(["title","smartphoneApplicationLinkTitle"]),changeProductsLocalization(),changeKeysLocalization(),changeAuthNavBarLocalization(),changeTooltipsLocalization()}function initLists(){localStorage.getItem("locale");$(".storage-type.uk").chosen({class:"uk",searchable:!1,data:{id:"id",text:"name",array:[{id:"DEVICE",name:"Апаратний пристрій"},{id:"FILE",name:"Файлове сховище "}]}}).trigger("chooseById","FILE"),$(".storage-type.ru").chosen({class:"ru",searchable:!1,data:{id:"id",text:"name",array:[{id:"DEVICE",name:"Аппаратное устройство"},{id:"FILE",name:"Файловое хранилище "}]}}).trigger("chooseById","FILE"),$(".storage-type.en").chosen({class:"en",searchable:!1,data:{id:"id",text:"name",array:[{id:"DEVICE",name:"Hardware device"},{id:"FILE",name:"File storage "}]}}).trigger("chooseById","FILE"),authorizationFormState.storageType="FILE",$(".storage-type").bind("chosen:select",function(e,t){changeStorageType(t.id)}),$("#device-list").chosen({class:"device-list",searchable:!1,data:{id:"id",deviceState:"deviceState",deviceModel:"deviceModel",text:"name",array:[]}}).bind("chosen:select",function(e,t){changeDeviceList(t)}),$("#keys").chosen({class:"keys",data:{id:"id",text:"name",array:[]}}).bind("chosen:select",function(e,t){setSelectedKeyAliasToLs((authorizationFormState.key=t).alias),$("#passwords")[t.needPassword?"show":"hide"]()})}function setSelectedKeyAliasToLs(e){switch(authorizationFormState.storageType){case"FILE":localStorage.setItem("lastUsedKeyAliasFromFile",e);break;case"DEVICE":localStorage.setItem("lastUsedKeyAliasFromDevice",e)}}window.onbeforeunload=function(){},window.onload=function(){start(),setIbankVersion(),CmsAPI.render(["title","favicon","login","smartphoneApplicationLinkTitle"]),changeProductsLocalization(),changeKeysLocalization(),changeAuthNavBarLocalization(),changeTooltipsLocalization(),resetLettersLocalStorageCounter();var e=document.querySelector("#input-language"),e=(InputLangService.addInputLanguageListener(document.querySelector("#password-ru"),e),InputLangService.addInputLanguageListener(document.querySelector("#password-uk"),e),InputLangService.addInputLanguageListener(document.querySelector("#password-en"),e),document.querySelector("#storage-input-language")),e=(InputLangService.addInputLanguageListener(document.querySelector("#storage-password-ru"),e),InputLangService.addInputLanguageListener(document.querySelector("#storage-password-uk"),e),InputLangService.addInputLanguageListener(document.querySelector("#storage-password-en"),e),document.querySelector("#device-input-language"));InputLangService.addInputLanguageListener(document.querySelector("#device-password-ru"),e),InputLangService.addInputLanguageListener(document.querySelector("#device-password-uk"),e),InputLangService.addInputLanguageListener(document.querySelector("#device-password-en"),e),$("#currentYear").text((new Date).getFullYear()+" "),document.addEventListener("keydown",documentOnKeyDown),loadPasswordPastePossibilityParam().then(function(e){localStorage.setItem("is_password_paste_possible",e),!isCommonFirmware||isDeveloperMode?loadSessionAutoBreakParam().then(function(e){localStorage.setItem("jsessionid_storage_type",e?"session_storage":"cookie"),!e&&isSessionAlive()?(sessionStorage.getItem("isNonAutoBreakLoginLatched")?v:h)():(storeItem("JSESSIONID",""),storeItem("CSRF_TOKEN",""),v())}):(localStorage.setItem("jsessionid_storage_type","cookie"),(!isSessionAlive()||sessionStorage.getItem("isNonAutoBreakLoginLatched")?v:h)())});var o,n=$("#registration-items-container").find("a"),e=$("#new-company"),t=$("#new-employee"),r=$("#new-key"),i=$(".tooltip.new-company"),a=$(".tooltip.new-employee"),s=$(".tooltip.new-key"),c=$(".key-is-absent-button"),l=$(".key-is-present-button");function u(t,e,n,r){e=e||500,n=n||700,r=r||300;var i=Date.now();o=setInterval(function(){var e=Date.now()-i;n<=e&&t.fadeIn(r)},e)}function d(e){clearInterval(o),e.fadeOut(100)}function f(e,t){removeExtraClasses(n),e.find("> div:first-child").addClass("registry-item-common-on-click "+t),e.find("p").addClass("registry-item-text-on-click"),n.addClass("zoom-out"),n.find("p").addClass("text-on-zoom-out"),(t=e).removeClass("zoom-out"),t.addClass("zoom-in")}function p(){c.fadeTo("fast","1"),l.fadeTo("fast","1")}function h(){function n(){var e="Explorer"===BrowserDetect.browser&&sessionStorage.getItem("pluginSessionId")||localStorage.getItem("pluginSessionId");SignPluginServices.restoreSession(e).done(function(e){SignPluginServices.setDefaultPluginSession(e),send(null,localStorage.getItem("addr")+"/auth;jsessionid="+getStoredItem("JSESSIONID"))}).fail(function(){"session_storage"===localStorage.getItem("jsessionid_storage_type")?(storeItem("JSESSIONID",""),storeItem("CSRF_TOKEN",""),localStorage.setItem("logout",Math.random()),localStorage.setItem("life_for",""),window.location.reload()):(SignPluginServices.initPlugin(),v())})}SignPluginServices.checkPlugin().done(n).fail(function(){setTimeout(function t(){SignPluginServices.checkPlugin().always(function(e){e===SignPluginServices.ACTUAL_VERSION||e===SignPluginServices.CAN_BE_UPDATED?n():setTimeout(t,500)})},500)})}function g(){var e=new Spinner({width:20,radius:40,lines:8,length:20,corners:1,position:"absolute",left:"50%",top:"45%"}).spin();return $(".plugin-spinner-wrapper").append(e.el),e}function m(e){e.stop()}function v(){var e;$.when((e=window.location.protocol+"//"+window.location.host+"/uweb/registry/pki_sys_props",$.get(e)),loadScenarioRegistration()).then(function(e,t){var n;isPKIEnabled="true"===e[0]["pki.enable"],scenarioRegistration=t[0],$("#registration-items-container > a").hide(),$(getAllowedRegistrationLinksSelectors()).show(),allScenarioRegistrationDisabled()&&($("#auth-nav-bar").css({"justify-content":"flex-start"}),$("#auth-nav-bar > a").addClass("auth-nav-bar-item"),$("#registration").hide()),BrowserDetect.isMobile()?showOnlyMobileElements():($("#left-links-additional").removeClass("hidden"),changeAuthNavBarTab(localStorage.getItem("last_visited_tab")),setDefaultAuthNavBarTab(),checkSessionClosedError(),n=localStorage.getItem("plugin_port")?null:g(),SignPluginServices.checkPlugin().then(function(t){SignPluginServices.openSession().then(function(e){SignPluginServices.setDefaultPluginSession(e),e.startScanner().then(function(){n&&m(n),preparePage(t)}).fail(function(e){8===e.errorCode&&0===e.errorLevel&&(n&&m(n),preparePage(SignPluginServices.NOT_INSTALLED))})})}).fail(function(e){localStorage.getItem("plugin_port")||n?(n&&m(n),preparePage(e)):n=g(),setTimeout(function e(){SignPluginServices.initPlugin(),SignPluginServices.checkPlugin().always(function(t){n&&m(n),t===SignPluginServices.ACTUAL_VERSION||t===SignPluginServices.CAN_BE_UPDATED||t===SignPluginServices.NEED_TO_UPDATE?SignPluginServices.openSession().then(function(e){SignPluginServices.setDefaultPluginSession(e),e.startScanner().then(function(){preparePage(t)})}):(preparePage(t),setTimeout(e,1e3))})},1e3)}))})}e.hover(function(){u(i)},function(){d(i)}),t.hover(function(){u(a)},function(){d(a)}),r.hover(function(){u(s)},function(){d(s)}),e.on("click",function(){isNewClient=!0,registrationType="newCompany",newClientsInternalKeyRegistrationAllowed()?newClientsAkccKeyRegistrationAllowed()?(f($(this),"registry-new-company-on-click"),p()):toRegistration():toRegistrationPKIEnabled()}),t.on("click",function(){isNewClient=!1,registrationType="newEmployee",newEmployeesInternalKeyRegistrationAllowed()?newEmployeesAkccKeyRegistrationAllowed()?(f($(this),"registry-new-employee-on-click"),p()):toRegistration():toRegistrationPKIEnabled()}),r.on("click",function(){isNewClient=!1,registrationType="newKey",newKeysInternalKeyRegistrationAllowed()?newKeysAkccKeyRegistrationAllowed()?(f($(this),"registry-new-key-on-click"),p()):toRegistration():toRegistrationPKIEnabled()}),l.on("click",function(){toRegistrationPKIEnabled()}),c.on("click",function(){toRegistration()})}