<div class="popup-overlay" id="confirm-popup">

    <script type="text/javascript">
        jQuery(document).ready(function ($) {

            if("{{ action }}" === "reinstall_agents") {
                AmplitudeAnalytics.reinstallAgent();
            }

            jQuery('#wt-continue').on('click', function (e) {
                jQuery('.popup-content').addClass('wtotem_loader_spinner');

                {% if action == 'update_plugin' %}
                    jQuery.post(ajaxurl, {
                        action: 'wtotem_ajax',
                        ajax_action: 'update_plugin',
                        slug: '{{ slug }}',
                        wtotem_page_nonce: '{{ page_nonce }}',
                    }, function (data) {

                        jQuery.post(ajaxurl, {
                            action: 'wtotem_ajax',
                            ajax_action: 'after_plugin_update',
                            slug: '{{ slug }}',
                            wtotem_page_nonce: '{{ page_nonce }}',
                        }, function (data) {

                            jQuery('#wtotem_notifications').html(data.notifications);

                            jQuery('.cve-logs__content').html(data.content);
                            jQuery('.cve-logs__pagination').html(data.pagination);
                            jQuery('.cve__num').html(data.count);

                            jQuery('#confirm-popup').remove();

                        });

                    });
                {% else %}
                jQuery.post(ajaxurl, {

                    action: 'wtotem_ajax',
                    ajax_action: '{{ action }}',
                    wtotem_page_nonce: '{{ page_nonce }}',
                }, function (data) {
                    jQuery('#wtotem_notifications').html(data.notifications);

                    if(data.success){
                        window.open(data.redirect_link, '_self');
                    } else {
                        jQuery('.popup-content').removeClass('wtotem_loader_spinner');
                    }
                });
                {% endif %}

            });

            jQuery('#wt-cancel').on('click', function (e) {
                jQuery('#confirm-popup').remove();
            });

            jQuery('body').on('click', '.popup-overlay', function (e) {
                if (e.target.className.includes('popup-overlay')) {
                    jQuery('.popup-overlay').addClass('d-none');
                    jQuery('#confirm-popup').remove();
                }
            });

        });
    </script>

    <div class="popup-content" style="position: relative; width: auto; margin: auto; border: 1px solid rgb(187, 187, 187); padding: 5px; border-radius: 10px;">
        <div class="confirmation-dialog">
            <h2 class="confirmation-dialog__title">{{ 'Are you sure?'|trans }}</h2>
            <p class="confirmation-dialog__text">{{ message }}</p>
            <div class="confirmation-dialog__buttons-wrapper">
                <button class="wt-button wt-button--red wt-button--size-300 wt-button--padded wt-font-700 confirmation-dialog__button" id="wt-continue">{{ 'Continue'|trans }}</button>
                <button class="wt-button wt-button--success wt-button--size-300 wt-button--padded wt-font-700 confirmation-dialog__button" id="wt-cancel">{{ 'Cancel'|trans }}</button>
            </div>
        </div>
    </div>
</div>