!function(t,e){"use strict";var a=t.EasyChatDom,n={};function o(a){var o=(t.EasyChatLazyAssetUrls||{})[a]||"";return o?(n[a]||(n[a]=new Promise(function(t,s){var r=e.querySelector('script[data-easychat-lazy-script="'+a+'"]');if(r&&"1"===r.getAttribute("data-loaded"))t();else{var i=r||e.createElement("script");i.src=o,i.defer=!0,i.setAttribute("data-easychat-lazy-script",a),i.onload=function(){i.setAttribute("data-loaded","1"),t()},i.onerror=function(){delete n[a],s(new Error("failed_lazy_asset_"+a))},r||e.head.appendChild(i)}})),n[a]):Promise.reject(new Error("missing_lazy_asset_"+a))}function s(t,e){t&&(t.classList.toggle("easychat-lazy-loading",!!e),t.setAttribute("aria-busy",e?"true":"false"),"BUTTON"===t.tagName&&(t.disabled=!!e))}function r(a){return s(a,!0),o("qrcode").then(function(){return o("mobileConnect")}).then(function(){!function(){var a=e.getElementById("mobileSidebar");if(a&&t.bootstrap&&t.bootstrap.Offcanvas){var n=t.bootstrap.Offcanvas.getInstance(a);n&&n.hide()}}(),t.EasyChatMobileConnect&&"function"==typeof t.EasyChatMobileConnect.open&&t.EasyChatMobileConnect.open()}).catch(function(){t.EasyChatModal&&"function"==typeof t.EasyChatModal.show&&t.EasyChatModal.show("#mobileConnectModal");var a=e.getElementById("mobile-connect-status");a&&(a.textContent="Не удалось загрузить подключение приложения. Обновите страницу и попробуйте еще раз.",a.className="alert small mb-3 alert-danger")}).then(function(){s(a,!1)})}function i(){return t.PublicKeyCredential&&navigator.credentials&&navigator.credentials.create&&navigator.credentials.get&&(e=String(navigator.userAgent||""),a=String(navigator.userAgentData&&navigator.userAgentData.platform||navigator.platform||""),n=/Android/i.test(e)||/Android/i.test(a),o=/iPhone|iPad|iPod/i.test(e)||/Macintosh/i.test(e)&&navigator.maxTouchPoints>1,s=!o&&/Mac/i.test(a),r=/Win/i.test(a),o||n||s||r)?"function"!=typeof t.PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable?Promise.resolve(!1):t.PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable().then(function(t){return!!t}).catch(function(){return!1}):Promise.resolve(!1);var e,a,n,o,s,r}function c(){return i().then(function(t){return!!t&&(e.querySelectorAll(".easychat-passkey-action").forEach(function(t){t.classList.remove("d-none")}),!0)})}function l(a){return s(a,!0),o("passkeys").then(function(){return t.EasyChatPasskeys&&"function"==typeof t.EasyChatPasskeys.open?t.EasyChatPasskeys.open():(t.EasyChatModal&&"function"==typeof t.EasyChatModal.show&&t.EasyChatModal.show("#easychatPasskeyModal"),!0)}).catch(function(){t.EasyChatModal&&"function"==typeof t.EasyChatModal.show&&t.EasyChatModal.show("#easychatPasskeyModal");var a=e.getElementById("easychat-passkey-status");a&&(a.textContent="Не удалось загрузить управление passkey. Обновите страницу и попробуйте еще раз.",a.className="alert mb-3 alert-danger")}).then(function(){s(a,!1)})}t.EasyChatLazyAssets={loadScript:o,openMobileConnect:r,openPasskey:l,revealPasskeyActions:c},(a&&a.ready?a.ready:function(t){"loading"===e.readyState?e.addEventListener("DOMContentLoaded",t,{once:!0}):t()})(function(){c(),e.addEventListener("click",function(t){var e=t.target&&t.target.closest?t.target.closest("#easychat-mobile-connect-toggle, .mobile-mobile-connect-trigger"):null;e&&(t.preventDefault(),t.stopImmediatePropagation(),r(e))},!0),e.addEventListener("click",function(t){var e=t.target&&t.target.closest?t.target.closest(".easychat-passkey-action"):null;e&&(t.preventDefault(),t.stopImmediatePropagation(),l(e))},!0)})}(window,document);