jQuery( document ).ready( function ( $ ) {
	ultimate_security_hide_show_authentication_setting();
	$( '#ultimate-security-2fa-provider' ).on( 'change', function () {
		ultimate_security_hide_show_authentication_setting();
	} );
	function ultimate_security_hide_show_authentication_setting() {
		const value = $( '#ultimate-security-2fa-provider' ).val();

		// Hide all authentication setting units by default
		$( '.ultimate-security-email-authentication-setting-unit' ).addClass( 'hidden' );
		$( '.ultimate-security-application-authentication-setting-unit' ).addClass( 'hidden' );

		// Show the relevant unit based on the selected provider
		if ( value === 'Email' ) {
			$( '.ultimate-security-email-authentication-setting-unit' ).removeClass( 'hidden' );
		} else if ( value === 'Authenticator Application' ) {
			$( '.ultimate-security-application-authentication-setting-unit' ).removeClass(
				'hidden'
			);
		}
	}
} );
// Necessary
function copyToClipboard( elementSelector ) {
	const textToCopy = document.querySelector( elementSelector ).innerText;

	if ( navigator.clipboard && navigator.clipboard.writeText ) {
		navigator.clipboard
			.writeText( textToCopy )
			.then( () => {
				// alert('Copied to clipboard!');
			} )
			.catch( ( err ) => {
				console.error( 'Clipboard API error:', err );
				alert( 'Failed to copy to clipboard.' );
			} );
	} else {
		const tempTextarea = document.createElement( 'textarea' );
		tempTextarea.value = textToCopy;
		document.body.appendChild( tempTextarea );
		tempTextarea.select();
		try {
			document.execCommand( 'copy' );
			// alert('Copied to clipboard!');
		} catch ( err ) {
			console.error( 'Fallback copy error:', err );
			// alert('Failed to copy to clipboard.');
		} finally {
			document.body.removeChild( tempTextarea );
		}
	}
}
