varh=Object.defineProperty;varw=(t,r,e)=>rint?h(t,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[r]=e;varc=(t,r,e)=>(w(t,typeofr!="symbol"?r+"":r,e),e);import{a1asf}from"./app-7741c0f3.js";/*! 2FAuth version 5.0.2 - Copyright (c) 2023 Bubka - https://github.com/Bubka/2FAuth */classy{constructor(){c(this,"controller")}createNewAbortSignal(){if(this.controller){conste=newError("Cancelling existing WebAuthn API call for new one");e.name="AbortError",this.controller.abort(e)}constr=newAbortController;returnthis.controller=r,r.signal}}constd=newy;functiong(t){returnt==="localhost"||/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(t)}function_(t,r){varn,a;const{publicKey:e}=r;if(t.name==="AbortError"){if(r.signalinstanceofAbortSignal)return{phrase:"errors.aborted_by_user",type:"is-warning"}}elseif(t.name==="ConstraintError"){if(((n=e.authenticatorSelection)==null?void0:n.requireResidentKey)===!0)return{phrase:"errors.authenticator_missing_discoverable_credential_support",type:"is-danger"};if(((a=e.authenticatorSelection)==null?void0:a.userVerification)==="required")return{phrase:"errors.authenticator_missing_user_verification_support",type:"is-danger"}}else{if(t.name==="InvalidStateError")return{phrase:"errors.security_device_already_registered",type:"is-danger"};if(t.name==="NotAllowedError")return{phrase:"errors.not_allowed_operation",type:"is-danger"};if(t.name==="NotSupportedError")returne.pubKeyCredParams.filter(u=>u.type==="public-key").length===0?{phrase:"errors.no_entry_was_of_type_public_key",type:"is-danger"}:{phrase:"errors.no_authenticator_support_specified_algorithms",type:"is-danger"};if(t.name==="SecurityError"){consto=window.location.hostname;if(g(o)){if(e.rp.id!==o)return{phrase:"errors.security_error_check_rpid",type:"is-danger"}}elsereturn{phrase:"errors.2fauth_has_not_a_valid_domain",type:"is-danger"}}elseif(t.name==="TypeError"){if(e.user.id.byteLength<1||e.user.id.byteLength>64)return{phrase:"errors.user_id_not_between_1_64",type:"is-danger"}}elseif(t.name==="UnknownError")return{phrase:"errors.unknown_error",type:"is-danger"}}return{phrase:"errors.unknown_error",type:"is-danger"}}functionm(t,r){const{publicKey:e}=r;if(t.name==="AbortError"){if(r.signalinstanceofAbortSignal)return{phrase:"errors.aborted_by_user",type:"is-warning"}}else{if(t.name==="NotAllowedError")return{phrase:"errors.not_allowed_operation",type:"is-danger"};if(t.name==="SecurityError"){constn=window.location.hostname;if(g(n)){if(e.rpId!==n)return{phrase:"errors.security_error_check_rpid",type:"is-danger"}}elsereturn{phrase:"errors.2fauth_has_not_a_valid_domain",type:"is-danger"}}elseif(t.name==="UnknownError")return{phrase:"errors.unknown_error",type:"is-danger"}}return{phrase:"errors.unknown_error",type:"is-danger"}}constp=f("web");classs{asyncregister(){letr={webauthn:!0,type:"is-danger",message:""};if(!window.isSecureContext)returnr.message="errors.https_required",Promise.reject(r);if(!s.supportsWebAuthn)returnr.message="errors.browser_does_not_support_webauthn",Promise.reject(r);conste=awaitp.post("/webauthn/register/options").then(i=>i.data);leta={publicKey:s.parseIncomingServerOptions(e)};a.signal=d.createNewAbortSignal();leto;try{o=awaitnavigator.credentials.create(a)}catch(i){constl=_(i,a);returnPromise.reject({webauthn:!0,type:l.type,message:l.phrase})}constu=s.parseOutgoingCredentials(o);returnp.post("/webauthn/register",u,{returnError:!0})}asyncauthenticate(r){if(!window.isSecureContext)returnerr.message="errors.https_required",Promise.reject(err);if(!s.supportsWebAuthn)returnerr.message="errors.browser_does_not_support_webauthn",Promise.reject(err);conste=awaitp.post("/webauthn/login/options",{email:r}).then(i=>i.data);leta={publicKey:s.parseIncomingServerOptions(e)};a.signal=d.createNewAbortSignal();consto=awaitnavigator.credentials.get(a).catch(i=>{constl=m(i,a);returnPromise.reject({webauthn:!0,type:l.type,message:l.phrase})});letu=s.parseOutgoingCredentials(o);returnu.email=r,p.post("/webauthn/login",u,{returnError:!0})}staticparseIncomingServerOpt