import { Observable , Subscriber } from 'rxjs' ; declare const window ; /**
 * Load the hCaptcha script by appending a script element to the head element.
 * The script won't be loaded again if it has already been loaded.
 * Async and defer are set to prevent blocking the renderer while loading hCaptcha.
 */ export function loadHCaptcha ( languageCode ? ) { return new Observable < void > ( ( observer ) => { if ( ! window ) { return ; } if ( typeof window . hcaptcha !== 'undefined' ) { observer . next ( ) ; observer . complete ( ) ; return ; } let src = 'https://hcaptcha.com/1/api.js?render=explicit' ; if ( languageCode ) { src += `&hl=${ languageCode }` ; } const script = document . createElement ( 'script' ) ; script . src = src ; script . async = true ; script . defer = true ; script . onerror = ( e ) => observer . error ( e ) ; script . onload = ( ) => { observer . next ( ) ; observer . complete ( ) ; } ; document . head . appendChild ( script ) ; } ) ; }