"use strict";(globalThis.webpackChunk=globalThis.webpackChunk||[]).push([["ui_packages_webauthn-get-element_element-entry_ts"],{97325:(e,t,n)=>{n.d(t,{Cy:()=>o,K3:()=>c,Z8:()=>u,k_:()=>a,lK:()=>h,m$:()=>s});var i=n(94982);function r(e,t,n){return e.dispatchEvent(new CustomEvent(t,{bubbles:!0,cancelable:n}))}function a(e,t){t&&(function(e,t){if(!(e instanceof HTMLFormElement))throw TypeError("The specified element is not of type HTMLFormElement.");if(!(t instanceof HTMLElement))throw TypeError("The specified element is not of type HTMLElement.");if("submit"!==t.type)throw TypeError("The specified element is not a submit button.");if(!e||e!==t.form)throw Error("The specified element is not owned by the form element.")}(e,t),(0,i.A)(t)),r(e,"submit",!0)&&e.submit()}function s(e,t){if("boolean"==typeof t)if(e instanceof HTMLInputElement)e.checked=t;else throw TypeError("only checkboxes can be set to boolean value");else if("checkbox"===e.type)throw TypeError("checkbox can't be set to string value");else e.value=t;r(e,"change",!1)}function o(e,t){for(let n in t){let i=t[n],r=e.elements.namedItem(n);r instanceof HTMLInputElement?r.value=i:r instanceof HTMLTextAreaElement&&(r.value=i)}}function u(e){if(!(e instanceof HTMLElement))return!1;let t=e.nodeName.toLowerCase(),n=(e.getAttribute("type")||"").toLowerCase();return"select"===t||"textarea"===t||"input"===t&&"submit"!==n&&"reset"!==n||e.isContentEditable}function l(e){return new URLSearchParams(e)}function c(e,t){let n=new URLSearchParams(e.search);for(let[e,i]of l(t))n.append(e,i);return n.toString()}function h(e){return l(new FormData(e)).toString()}},94982:(e,t,n)=>{function i(e){let t=e.closest("form");if(!(t instanceof HTMLFormElement))return;let n=r(t);if(e.name){let i=e.matches("input[type=submit]")?"Submit":"",r=e.value||i;n||((n=document.createElement("input")).type="hidden",n.classList.add("js-submit-button-value"),t.prepend(n)),n.name=e.name,n.value=r}else n&&n.remove()}function r(e){let t=e.querySelector("input.js-submit-button-value");return t instanceof HTMLInputElement?t:null}n.d(t,{A:()=>i,C:()=>r})},17226:(e,t,n)=>{n.r(t),n(16561)},16561:(e,t,n)=>{n.d(t,{U:()=>u});var i=n(39595),r=n(74043),a=n(97325);function s(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function o(e,t,n,i){var r,a=arguments.length,s=a<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,i);else for(var o=e.length-1;o>=0;o--)(r=e[o])&&(s=(a<3?r(s):a>3?r(t,n,s):r(t,n))||s);return a>3&&s&&Object.defineProperty(t,n,s),s}let u={Initializing:"initializing",Unsupported:"unsupported",Ready:"ready",Waiting:"waiting",Error:"error",Submitting:"submitting"};let WebauthnGetElement=class WebauthnGetElement extends HTMLElement{async connectedCallback(){this.originalButtonText=this.getCurrentButtonText(),this.originalErrorText=this.errorText.textContent,this.setState((0,r.$j)()?u.Ready:u.Unsupported),this.passkeySupport=await window.PublicKeyCredential?.isUserVerifyingPlatformAuthenticatorAvailable(),this.state!==u.Unsupported&&!this.passkeySupport&&this.passkeysUnsupportedMessage&&(this.passkeysUnsupportedMessage.hidden=!1),this.subtleLogin?this.handleWebauthnSubtle():this.showWebauthnLoginFragment()}handleWebauthnSubtle(){let e=document.querySelector(".js-webauthn-subtle");e&&(e.hidden=!1,this.updateWebauthnSubtleParentBoxVisibility(!1),e.addEventListener("webauthn-subtle-submit",()=>{this.showWebauthnLoginFragment(),this.state!==u.Unsupported&&this.prompt()}))}showWebauthnLoginFragment(){let e=document.querySelector(".js-webauthn-login-section");e&&(e.hidden=!1,this.updateWebauthnSubtleParentBoxVisibility(!0))}updateWebauthnSubtleParentBoxVisibility(e){let t=document.querySelector(".js-webauthn-hint");t&&(t.hidden=e)}getCurrentButtonText(){return this.buttonText.textContent||""}setCurrentButtonText(e){this.buttonText.textContent=e}setState(e){let t=this.button.getAttribute("data-retry-message")||this.originalButtonText,n=this.hasErrored?t:this.originalButtonText;for(let e of(this.setCurrentButtonText(n),this.button.disabled=!1,this.button.hidden=!1,this.errorText.textContent="",this.messages))e.hidden=!0;switch(e){case u.Initializing:this.button.disabled=!0;break;case u.Unsupported:this.button.disabled=!0,this.unsupportedMessage.hidden=!1,this.passkeysUnsupportedMessage&&(this.passkeysUnsupportedMessage.hidden=!0);break;case u.Ready:break;case u.Waiting:this.waitingMessage.hidden=!1,this.button.hidden=!0;break;case u.Error:this.errorMessage.hidden=!1,this.errorText.textContent=this.originalErrorText;break;case u.Submitting:this.setCurrentButtonText("Verifying\u2026"),this.button.disabled=!0;break;default:throw Error("invalid state")}this.state=e}async prompt(e,t){e?.preventDefault(),this.dispatchEvent(new CustomEvent("webauthn-get-prompt"));try{t||this.setState(u.Waiting);let e=JSON.parse(this.dataJson),n=await (0,r.Jt)((0,r.d5)(e));this.setState(u.Submitting);let i=this.closest(".js-webauthn-form");i.querySelector(".js-webauthn-response").value=JSON.stringify(n),(0,a.k_)(i)}catch(e){if(!t)throw this.hasErrored=!0,this.setState(u.Error),e}}constructor(...e){super(...e),s(this,"state",u.Initializing),s(this,"dataJson",""),s(this,"subtleLogin",!1),s(this,"hasErrored",!1)}};s(WebauthnGetElement,"attrPrefix",""),o([i.aC],WebauthnGetElement.prototype,"button",void 0),o([i.aC],WebauthnGetElement.prototype,"buttonText",void 0),o([i.zV],WebauthnGetElement.prototype,"messages",void 0),o([i.aC],WebauthnGetElement.prototype,"capitalizedDescription",void 0),o([i.aC],WebauthnGetElement.prototype,"unsupportedMessage",void 0),o([i.aC],WebauthnGetElement.prototype,"passkeysUnsupportedMessage",void 0),o([i.aC],WebauthnGetElement.prototype,"waitingMessage",void 0),o([i.aC],WebauthnGetElement.prototype,"errorMessage",void 0),o([i.aC],WebauthnGetElement.prototype,"errorText",void 0),o([i.CF],WebauthnGetElement.prototype,"dataJson",void 0),o([i.CF],WebauthnGetElement.prototype,"subtleLogin",void 0),WebauthnGetElement=o([i.p_],WebauthnGetElement)},74043:(e,t,n)=>{function i(e){let t="==".slice(0,(4-e.length%4)%4),n=atob(e.replace(/-/g,"+").replace(/_/g,"/")+t),i=new ArrayBuffer(n.length),r=new Uint8Array(i);for(let e=0;ew,Jt:()=>x,PG:()=>y,d5:()=>E,vt:()=>v});var a="copy",s="convert";function o(e,t,n){if(t===a)return n;if(t===s)return e(n);if(t instanceof Array)return n.map(n=>o(e,t[0],n));if(t instanceof Object){let i={};for(let[r,a]of Object.entries(t)){if(a.derive){let e=a.derive(n);void 0!==e&&(n[r]=e)}if(!(r in n)){if(a.required)throw Error(`Missing key: ${r}`);continue}if(null==n[r]){i[r]=null;continue}i[r]=o(e,a.schema,n[r])}return i}}function u(e,t){return{required:!0,schema:e,derive:t}}function l(e){return{required:!0,schema:e}}function c(e){return{required:!1,schema:e}}var h={type:l(a),id:l(s),transports:c(a)},d={appid:c(a),appidExclude:c(a),credProps:c(a)},p={appid:c(a),appidExclude:c(a),credProps:c(a)},b={publicKey:l({rp:l(a),user:l({id:l(s),name:l(a),displayName:l(a)}),challenge:l(s),pubKeyCredParams:l(a),timeout:c(a),excludeCredentials:c([h]),authenticatorSelection:c(a),attestation:c(a),extensions:c(d)}),signal:c(a)},f={type:l(a),id:l(a),rawId:l(s),authenticatorAttachment:c(a),response:l({clientDataJSON:l(s),attestationObject:l(s),transports:u(a,e=>{var t;return(null==(t=e.getTransports)?void 0:t.call(e))||[]})}),clientExtensionResults:u(p,e=>e.getClientExtensionResults())},m={mediation:c(a),publicKey:l({challenge:l(s),timeout:c(a),rpId:c(a),allowCredentials:c([h]),userVerification:c(a),extensions:c(d)}),signal:c(a)},g={type:l(a),id:l(a),rawId:l(s),authenticatorAttachment:c(a),response:l({clientDataJSON:l(s),authenticatorData:l(s),signature:l(s),userHandle:l(s)}),clientExtensionResults:u(p,e=>e.getClientExtensionResults())};function y(e){return o(i,b,e)}function E(e){return o(i,m,e)}function w(){return!!(navigator.credentials&&navigator.credentials.create&&navigator.credentials.get&&window.PublicKeyCredential)}async function v(e){let t=await navigator.credentials.create(e);return t.toJSON=()=>o(r,f,t),t}async function x(e){let t=await navigator.credentials.get(e);return t.toJSON=()=>o(r,g,t),t}}}]); //# sourceMappingURL=ui_packages_webauthn-get-element_element-entry_ts-42da918f8194.js.map