<?php $recaptcha = customer_recaptcha(); ?>

<?php if (isset($recaptcha->is_google_recaptcha) && $recaptcha->is_google_recaptcha == 1 && isset($page_type) && $page_type == 'staff'): ?>
    <input type="hidden" name="g-recaptcha-response" id="recaptchaResponse">
    <script>
        grecaptcha.ready(function() {
            grecaptcha.execute('<?= $recaptcha->google_recaptcha_site_key; ?>', {
                    action: 'submit'
                })
                .then(function(token) {
                    document.getElementById('recaptchaResponse').value = token;
                });
        });
    </script>
<?php else: ?>

    <?php if (isset($this->settings['is_recaptcha']) && $this->settings['is_recaptcha'] == 1): ?>
        <?php if (isset($this->settings['recaptcha']->recaptcha_type) && $this->settings['recaptcha']->recaptcha_type == 'v3'): ?>
            <input type="hidden" name="g-recaptcha-response" id="recaptchaResponse">
            <script>
                grecaptcha.ready(function() {
                    grecaptcha.execute('<?= $this->settings['recaptcha']->new_site_key; ?>', {
                            action: 'submit'
                        })
                        .then(function(token) {
                            document.getElementById('recaptchaResponse').value = token;
                        });
                });
            </script>
        <?php else: ?>
        
            <?php if (isset($this->settings['recaptcha']->site_key) && !empty($this->settings['recaptcha']->site_key)): ?>
                <div class="g-recaptcha"
                    data-sitekey="<?= $this->settings['recaptcha']->site_key; ?>"></div>
            <?php endif; ?>
        <?php endif; ?>
    <?php endif; ?>

<?php endif; ?>