(()=>{"use strict";function e(e){const t=window.location.href;e=e.replace(/[\[\]]/g,"\\$&");const n=new RegExp("[?&]"+e+"(=([^&#]*)|&|#|$)").exec(t);return n?n[2]?decodeURIComponent(n[2].replace(/\+/g," ")):"":null}function t(e,t=!1){return t&&(e=e.replace(/ /g,"+")),decodeURIComponent(Array.prototype.map.call(atob(e),e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)).join(""))}function n(e){if(Array.isArray(e)&&(e=Uint8Array.from(e)),e instanceof ArrayBuffer&&(e=new Uint8Array(e)),e instanceof Uint8Array){let t="";const n=e.byteLength;for(let a=0;ai(this,void 0,void 0,function*(){const t=this.localesDirectory+"/"+e+"/messages.json?cache=r5ktz",n=yield fetch(t);return yield n.json()})),this.supportedTranslationLocales=o}get translationLocale(){return this._translationLocale}set translationLocale(e){this._translationLocale=e}}var l=function(e,t,n,a){return new(n||(n=Promise))(function(s,o){function i(e){try{l(a.next(e))}catch(t){o(t)}}function r(e){try{l(a.throw(e))}catch(t){o(t)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(i,r)}l((a=a.apply(e,t||[])).next())})};let c,d=!1,u=null,h=!1,f=null,g=null;function p(){var n;if(d)return;if(u=e("parent"),!u)return void m("No parent.");u=decodeURIComponent(u),f=null!==(n=e("locale"))&&void 0!==n?n:"en";"1"===e("v")?function(){const n=e("data");if(!n)return void m("No data.");c=t(n)}():function(){let n=null;try{n=JSON.parse(t(e("data")))}catch(a){return void m("Cannot parse data.")}c=n.data}(),d=!0}function y(){if(h)return;if(!("credentials"in navigator))return void m(g.t("webAuthnNotSupported"));if(p(),!c)return void m("No data.");let e;try{e=function(e){const t=JSON.parse(e),n=t.challenge.replace(/-/g,"+").replace(/_/g,"/");return t.challenge=Uint8Array.from(atob(n),e=>e.charCodeAt(0)),t.allowCredentials.forEach(e=>{const t=e.id.replace(/\_/g,"/").replace(/\-/g,"+");e.id=Uint8Array.from(atob(t),e=>e.charCodeAt(0))}),t}(c)}catch(t){return void m("Cannot parse data.")}!function(e){l(this,void 0,void 0,function*(){try{const t=yield navigator.credentials.get({publicKey:e});if(h)return;const a=function(e){const t=e.response,a=new Uint8Array(t.authenticatorData),s=new Uint8Array(t.clientDataJSON),o=new Uint8Array(e.rawId),i=new Uint8Array(t.signature),r={id:e.id,rawId:n(o),type:e.type,extensions:e.getClientExtensionResults(),response:{authenticatorData:n(a),clientDataJson:n(s),signature:n(i)}};return JSON.stringify(r)}(t),s=document.getElementById("remember").checked;window.postMessage({command:"webAuthnResult",data:a,remember:s},"*"),h=!0,function(e){document.getElementById("webauthn-button").disabled=!0,document.getElementById("remember").disabled=!0;const t=document.getElementById("msg");v(t),t.textContent=e,t.classList.add("alert"),t.classList.add("alert-success"),t.classList.remove("tw-hidden")}(g.t("webAuthnSuccess"))}catch(t){m(t)}})}(e)}function m(e){const t=document.getElementById("msg");v(t),t.textContent=e,t.classList.add("alert"),t.classList.add("alert-danger"),t.classList.remove("tw-hidden")}function v(e){e.classList.remove("alert"),e.classList.remove("alert-danger"),e.classList.remove("alert-success"),e.classList.add("tw-hidden")}document.addEventListener("DOMContentLoaded",()=>l(void 0,void 0,void 0,function*(){p();try{g=new r(f,"locales")}catch(a){m("Failed to load the provided locale "+f),g=new r("en","locales")}yield g.init(),document.getElementById("remember-label").innerText=g.t("dontAskAgainOnThisDeviceFor30Days");const e=document.getElementById("webauthn-button");e.innerText=g.t("readSecurityKey"),e.onclick=y;const t=document.getElementById("title-smaller-screens"),n=document.getElementById("title-larger-screens");t.innerText=g.t("verifyYourIdentity"),n.innerText=g.t("verifyYourIdentity");document.getElementById("subtitle").innerText=g.t("followTheStepsBelowToFinishLoggingInWithSecurityKey")}))})(); //# sourceMappingURL=webauthn-fallback.a4e27e1529cc9c0658a1.js.map