<?php
/*
 * Google Sheet configuration and settings page
 * @since 1.0.0
 */

// Exit if accessed directly
if (!defined('ABSPATH')) {
    exit();
}

global $wpdb;

$gshfjf_jet_forms = get_posts(array(
    'post_type'      => 'jet-form-builder',
    'post_status'    => 'publish',
    'numberposts'    => -1,
    'orderby'        => 'title',
    'order'          => 'ASC'
));

$gshfjf_feed = $wpdb->prefix . 'postmeta';
global $wpdb;

// 1️⃣ Get feed list from postmeta
$gshfjf_feedList = $wpdb->get_results(
    $wpdb->prepare(
        "SELECT post_id, meta_key
         FROM {$wpdb->postmeta}
         WHERE meta_value = %s",
        'gshfjf_jetform_feeds'
    )
);

// 2️⃣ Custom table
$gshfjf_table_name = $wpdb->prefix . 'gshfjf_jetform_db_settings';

foreach ($gshfjf_feedList as $gshfjf_row) {

    $gshfjf_form_id   = (int) $gshfjf_row->post_id;
    $gshfjf_feed_name = sanitize_text_field($gshfjf_row->meta_key);

    // 3️⃣ Check if already exists
    $gshfjf_exists = $wpdb->get_var(
        $wpdb->prepare(
            "SELECT id FROM {$wpdb->prefix}gshfjf_jetform_db_settings WHERE form_id = %d AND feed_name = %s",
            $gshfjf_form_id,
            $gshfjf_feed_name
        )
    );

    if (!$gshfjf_exists) {
        // 4️⃣ Insert
        $wpdb->insert(
            $gshfjf_table_name,
            array(
                'form_id'   => $gshfjf_form_id,
                'feed_name' => $gshfjf_feed_name,
                'status'    => 1,
            ),
            array('%d', '%s', '%d')
        );
    }
}


// Check if the user is authenticated
$gshfjf_authenticated = get_option('gshfjf_jetform_token');
$gshfjf_jetform_manual_setting = get_option('gshfjf_jetform_manual_setting');
$gshfjf_is_valid = get_option('gshfjf_jetform_verify');
$gshfjf_show_setting = 0;
$gshfjf_selected_method = '';

if ($gshfjf_jetform_manual_setting == 0) {
    $gshfjf_selected_method = esc_html__('Existing Client / Secret Key (Auto Setup)', 'gsheetconnector-for-jetform');
}

// Check if the user is authenticated when saving existing API method
if ((!empty($gshfjf_authenticated) && $gshfjf_is_valid == 'valid' && $gshfjf_jetform_manual_setting == 0)) {
    $gshfjf_show_setting = 1;
} else {
?>
    <?php
    if ($gshfjf_jetform_manual_setting == 0) {
        $gshfjf_selected_method = esc_html__('Existing Client / Secret Key (Auto Setup).', 'gsheetconnector-for-jetform'); ?>
        <div class="wrap w-100 m-0">
            <div class="inner-wrap  w-100 bg-white p-40">
                <div class="gsc-setup-alert">
                    <div class="gsc-alert-icon">
                        <svg width="30px" height="30px" viewBox="-0.5 0 25 25" fill="none" xmlns="http://www.w3.org/2000/svg">
                            <path d="M18.2202 21.25H5.78015C5.14217 21.2775 4.50834 21.1347 3.94373 20.8364C3.37911 20.5381 2.90402 20.095 2.56714 19.5526C2.23026 19.0101 2.04372 18.3877 2.02667 17.7494C2.00963 17.111 2.1627 16.4797 2.47015 15.92L8.69013 5.10999C9.03495 4.54078 9.52077 4.07013 10.1006 3.74347C10.6804 3.41681 11.3346 3.24518 12.0001 3.24518C12.6656 3.24518 13.3199 3.41681 13.8997 3.74347C14.4795 4.07013 14.9654 4.54078 15.3102 5.10999L21.5302 15.92C21.8376 16.4797 21.9907 17.111 21.9736 17.7494C21.9566 18.3877 21.7701 19.0101 21.4332 19.5526C21.0963 20.095 20.6211 20.5381 20.0565 20.8364C19.4919 21.1347 18.8581 21.2775 18.2202 21.25V21.25Z" stroke="#9a3412" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" />
                            <path d="M10.8809 17.15C10.8809 17.0021 10.9102 16.8556 10.9671 16.7191C11.024 16.5825 11.1074 16.4586 11.2125 16.3545C11.3175 16.2504 11.4422 16.1681 11.5792 16.1124C11.7163 16.0567 11.8629 16.0287 12.0109 16.03C12.2291 16.034 12.4413 16.1021 12.621 16.226C12.8006 16.3499 12.9398 16.5241 13.0211 16.7266C13.1023 16.9292 13.122 17.1512 13.0778 17.3649C13.0335 17.5786 12.9272 17.7745 12.7722 17.9282C12.6172 18.0818 12.4203 18.1863 12.2062 18.2287C11.9921 18.2711 11.7703 18.2494 11.5685 18.1663C11.3666 18.0833 11.1938 17.9426 11.0715 17.7618C10.9492 17.5811 10.8829 17.3683 10.8809 17.15ZM11.2409 14.42L11.1009 9.20001C11.0876 9.07453 11.1008 8.94766 11.1398 8.82764C11.1787 8.70761 11.2424 8.5971 11.3268 8.5033C11.4112 8.40949 11.5144 8.33449 11.6296 8.28314C11.7449 8.2318 11.8697 8.20526 11.9959 8.20526C12.1221 8.20526 12.2469 8.2318 12.3621 8.28314C12.4774 8.33449 12.5805 8.40949 12.6649 8.5033C12.7493 8.5971 12.8131 8.70761 12.852 8.82764C12.8909 8.94766 12.9042 9.07453 12.8909 9.20001L12.7609 14.42C12.7609 14.6215 12.6808 14.8149 12.5383 14.9574C12.3957 15.0999 12.2024 15.18 12.0009 15.18C11.7993 15.18 11.606 15.0999 11.4635 14.9574C11.321 14.8149 11.2409 14.6215 11.2409 14.42Z" fill="#9a3412" />
                        </svg>
                    </div>
                    <div class="gsc-alert-content">
                        <div class="feed-alert-header"><?php esc_html_e('Google Sheets Setup Required', 'gsheetconnector-for-jetform'); ?></div>
                        <p><?php esc_html_e('your selected Method is : ', 'gsheetconnector-for-jetform'); ?><?php echo esc_html($gshfjf_selected_method); ?></p>
                        <p><?php esc_html_e('To start sending form entries to Google Sheets, please connect your Google account first.', 'gsheetconnector-for-jetform'); ?></p>
                        <ul>
                            <li><?php esc_html_e('✔ Click on the Sign in with Google button', 'gsheetconnector-for-jetform'); ?></li>
                            <li><?php esc_html_e('✔ Log in using your Google account', 'gsheetconnector-for-jetform'); ?></li>
                            <li><?php esc_html_e('✔ Select the Google account where your Sheets are stored', 'gsheetconnector-for-jetform'); ?></li>
                            <li><?php esc_html_e('✔ Grant access to: Google Drive & Google Sheets', 'gsheetconnector-for-jetform'); ?></li>
                            <li><?php esc_html_e('✔ Save the authentication code if prompted', 'gsheetconnector-for-jetform'); ?></li>
                        </ul>
                        <a href="admin.php?page=jetform-google-sheet-config&tab=integration" class="gsc-alert-btn link-hover-white">
                            <?php esc_html_e('Go to Integration Setup', 'gsheetconnector-for-jetform'); ?>
                        </a>
                    </div>
                </div>
            </div>
        </div>
    <?php
    }
    ?>
<?php
}

if ($gshfjf_show_setting == 1) { ?>
    <div class="wrap w-100 m-0">
        <div class="inner-wrap  w-100 bg-white p-40">
            <!-- Feed message display block -->
            <div class="feed-error-message feed-error-message gsc-msg gsc-error d-block fw-400 text-dark text-center pt-10 pb-10 d-none"></div>
            <div class="feed-success-message gsc-msg gsc-success d-block fw-400 text-dark text-center pt-10 pb-10 d-none"></div>
            <div class="card-wp">
                <div class="gshfjf-main">
                    <div class="heading mt-0"> <?php echo esc_html(__('Sheet Sync Feeds', 'gsheetconnector-for-jetform')); ?></div>
                    <p><?php echo esc_html(__("Create, connect, manage, and monitor how your form submissions are automatically synced to Google Sheets in real time.", 'gsheetconnector-for-jetform')); ?>
                    <div class="gshfjf-row">
                        <div>
                            <button class="gshfjf-btn btn btn-primary gshfjf-btn mt-20" id="add-new-feed">
                                <?php echo esc_html__('+ Add Form Feed', 'gsheetconnector-for-jetform'); ?>
                            </button>
                            <button class="gshfjf-close-btn btn btn-primary mt-20" id="close-feed" style="display:none">
                                <?php echo esc_html__('- Close Form Feed', 'gsheetconnector-for-jetform'); ?>
                            </button>
                        </div>
                        <div class="gsc-jet-feed shadow-box mt-50 p-30">
                            <div class="heading"> <?php echo esc_html(__('Create Sheet Sync Feeds', 'gsheetconnector-for-jetform')); ?></div>
                            <p><?php echo esc_html(__("Select a form and give your feed a name to start syncing form submissions with Google Sheets in real time.", 'gsheetconnector-for-jetform')); ?>
                            <div class="add-feed-form">
                                <form method="post">
                                    <div class="row">
                                        <div class="col-4">
                                            <div class="mr-10">
                                                <label
                                                    for="feed_name"><?php echo esc_html__('Feed Name', 'gsheetconnector-for-jetform'); ?></label>
                                                <input type="text" id="feed_name" class="feedName form-control mt-5" name="feed_name" />
                                                <div class="input-msg d-none"><?php echo esc_html('Please fill out this field', 'gsheetconnector-for-jetform'); ?></div>
                                            </div>
                                        </div>

                                        <div class="col-4">
                                            <div class="mr-10">
                                                <label
                                                    for="gsc-jetform_form_select"><?php echo esc_html__('Select Form', 'gsheetconnector-for-jetform'); ?></label>
                                                <div class="auto-select mt-5 w-100">
                                                    <select id="gsc-jetform_form_select" name="gsc-jetforms" class="gsc-jetforms auto-select-display w-100">

                                                        <option value="">
                                                            <?php echo esc_html('Select Form', 'gsheetconnector-for-jetform'); ?>
                                                        </option>

                                                        <?php
                                                        // Display fetched JetForm Forms
                                                        if (!empty($gshfjf_jet_forms)) {

                                                            foreach ($gshfjf_jet_forms as $gshfjf_form) {

                                                                // Get form title
                                                                $gshfjf_form_title = trim($gshfjf_form->post_title);

                                                                // If title is empty, create fallback title
                                                                if ($gshfjf_form_title === '') {
                                                                    $gshfjf_form_title = 'Untitled Form (#' . $gshfjf_form->ID . ')';
                                                                }
                                                        ?>
                                                                <option value="<?php echo esc_attr($gshfjf_form->ID); ?>">
                                                                    <?php echo esc_html($gshfjf_form_title); ?>
                                                                </option>

                                                        <?php
                                                            }
                                                        }
                                                        ?>

                                                    </select>
                                                    <div class="input-msg d-none"><?php echo esc_html('Please fill out this field', 'gsheetconnector-for-jetform'); ?></div>
                                                </div>
                                            </div>
                                        </div>

                                        <div class="col-4 mt-25">
                                            <div class="mr-10">
                                                <input type="hidden" name="gshfjf-ajax-nonce" id="gshfjf-ajax-nonce"
                                                    value="<?php echo esc_attr(wp_create_nonce('gshfjf-ajax-nonce')); ?>" />
                                                <input type="button" name="gshfjf-execute-submit-feed" class="gshfjf-jetform-sub-btn btn btn-primary"
                                                    value="<?php echo esc_html__('Submit', 'gsheetconnector-for-jetform'); ?>">
                                                <span class="gshfjf-fetch-load">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
                                            </div>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                    <div class="gshfjf-jetform-feeds-list form-feed-table-common mt-30">
                        <?php
                        // $paged = isset($_GET['paged']) ? max(1, intval($_GET['paged'])) : 1;
                        $paged = 1;

                        if (
                            isset($_GET['paged'], $_GET['_wpnonce']) &&
                            wp_verify_nonce(sanitize_text_field(wp_unslash($_GET['_wpnonce'])), 'gshfjf_pagination_nonce')
                        ) {
                            $paged = max(1, intval($_GET['paged']));
                        }
                        $per_page = 10;
                        $gshfjf_offset = ($paged - 1) * $per_page;
                        global $wpdb;

                        // $gshfjf_table_name = $wpdb->prefix . 'gshfjf_jetform_db_settings';
                        $gshfjf_total_items = (int) $wpdb->get_var(
                            "SELECT COUNT(*) FROM {$wpdb->prefix}gshfjf_jetform_db_settings"
                        );
                        $gshfjf_total_pages = ceil($gshfjf_total_items / $per_page);

                        $gshfjf_feedList = $wpdb->get_results(
                            $wpdb->prepare(
                                "SELECT * FROM {$wpdb->prefix}gshfjf_jetform_db_settings ORDER BY id DESC LIMIT %d OFFSET %d",
                                $per_page,
                                $gshfjf_offset
                            )
                        );

                        ?>

                        <table id="gsc-jetformformtable" class="full-table">

                            <?php if (!empty($gshfjf_feedList)) : ?>

                                <tr>
                                    <th class="pt-15 pb-15 pl-20 pr-20 text-left bg-white text-dark fw-600"><?php echo esc_html__('Form ID', 'gsheetconnector-for-jetform'); ?></th>
                                    <th class="pt-15 pb-15 pl-20 pr-20 text-left bg-white text-dark fw-600"><?php echo esc_html__('Feed Name', 'gsheetconnector-for-jetform'); ?></th>
                                    <th class="pt-15 pb-15 pl-20 pr-20 text-left bg-white text-dark fw-600"><?php echo esc_html__('Form Name', 'gsheetconnector-for-jetform'); ?></th>
                                    <th class="pt-15 pb-15 pl-20 pr-20 text-left bg-white text-dark fw-600"><?php echo esc_html__('Timestamp', 'gsheetconnector-for-jetform'); ?></th>
                                    <th class="pt-15 pb-15 pl-20 pr-20 text-left bg-white text-dark fw-600"><?php echo esc_html__('Actions', 'gsheetconnector-for-jetform'); ?></th>
                                    <th class="pt-15 pb-15 pl-20 pr-20 text-left bg-white text-dark fw-600"><?php echo esc_html__('Status', 'gsheetconnector-for-jetform'); ?></th>
                                </tr>

                                <?php foreach ($gshfjf_feedList as $gshfjf_value) :

                                    $gshfjf_feed_id = (int) $gshfjf_value->id;
                                    $gshfjf_form_id = (int) $gshfjf_value->form_id;

                                    $gshfjf_form_name = $wpdb->get_var(
                                        $wpdb->prepare(
                                            "SELECT post_title FROM {$wpdb->posts} WHERE ID = %d AND post_type = %s",
                                            $gshfjf_form_id,
                                            'jet-form-builder'
                                        )
                                    );
                                ?>

                                    <tr id="feed-<?php echo esc_attr($gshfjf_feed_id); ?>"
                                        class="<?php echo ((int) $gshfjf_value->status === 0) ? 'gshfjfrow-disabled' : ''; ?>">

                                        <td class="pt-15 pb-15 pl-20 pr-20 text-left"><?php echo esc_html($gshfjf_form_id); ?></td>

                                        <td class="pt-15 pb-15 pl-20 pr-20 text-left"><?php echo esc_html($gshfjf_value->feed_name); ?></td>

                                        <!-- <td class="pt-15 pb-15 pl-20 pr-20 text-left">< ?php echo esc_html($gshfjf_form_name); ?></td> -->
                                        <td class="pt-15 pb-15 pl-20 pr-20 text-left">
                                            <?php

                                            $gshfjf_form_title = trim((string) $gshfjf_form_name);

                                            if ($gshfjf_form_title === '') {
                                                $gshfjf_form_title = 'Untitled Form (#' . $gshfjf_form_id . ')';
                                            }

                                            echo esc_html($gshfjf_form_title);

                                            ?>
                                        </td>

                                        <td class="pt-15 pb-15 pl-20 pr-20 text-left">
                                            <?php
                                            echo esc_html(
                                                date_i18n(
                                                    get_option('date_format') . ' ' . get_option('time_format'),
                                                    strtotime($gshfjf_value->created_at)
                                                )
                                            );
                                            $gshfjf_timezone_string = get_option('timezone_string');

                                            if (!empty($gshfjf_timezone_string)) {

                                                // City timezone selected (e.g. Asia/Kolkata)
                                                $gshfjf_display_timezone = $gshfjf_timezone_string;
                                            } else {

                                                // UTC offset selected (e.g. UTC-7, UTC+5:30)
                                                $gshfjf_offset = get_option('gmt_offset');

                                                $gshfjf_hours   = (int) $gshfjf_offset;
                                                $gshfjf_minutes = abs(($gshfjf_offset - $gshfjf_hours) * 60);

                                                $gshfjf_sign = ($gshfjf_offset < 0) ? '-' : '+';

                                                $gshfjf_display_timezone = 'UTC' . $gshfjf_sign . abs($gshfjf_hours);

                                                if ($gshfjf_minutes > 0) {
                                                    $gshfjf_display_timezone .= ':' . str_pad($gshfjf_minutes, 2, '0', STR_PAD_LEFT);
                                                }
                                            }

                                            echo " (" . esc_html($gshfjf_display_timezone) . ")";
                                            ?>
                                        </td>

                                        <!-- View Form Column with link to form preview -->
                                        <td class="gshfjf-actions pt-15 pb-15 pl-20 pr-20 d-flex align-center text-left">

                                            <?php
                                            $gshfjf_edit_url = add_query_arg(
                                                array(
                                                    'post_type' => 'jet-form-builder',
                                                    'page'      => 'jetform-google-sheet-config',
                                                    'tab'       => 'google-sheet',
                                                    'form_id'   => $gshfjf_form_id,
                                                    'feed_id'   => $gshfjf_feed_id,
                                                    '_wpnonce'  => wp_create_nonce('gshfjf-ajax-nonce'),
                                                ),
                                                admin_url('edit.php')
                                            );
                                            ?>

                                            <a href="<?php echo esc_url($gshfjf_edit_url); ?>">
                                                <i class="fa-regular fa-pen-to-square"></i>
                                            </a>

                                            <a href="#"
                                                class="delete gshfjf-gs-btn delete-feed"
                                                data-feed-id="<?php echo esc_attr($gshfjf_feed_id); ?>"><i class="fa-regular fa-trash-can"></i>
                                            </a>
                                        </td>

                                        <!-- STATUS COLUMN (ALWAYS ACTIVE) -->
                                        <td class="gshfjf-status-col pt-15 pb-15 pl-20 pr-20 text-left">
                                            <div class="custom-check">
                                                <input
                                                    type="checkbox"
                                                    class="check-toggle"
                                                    id="gshfjf_jetform_status_<?php echo esc_attr($gshfjf_feed_id); ?>"
                                                    value="1"
                                                    <?php checked((int) $gshfjf_value->status, 1); ?>>

                                                <label
                                                    for="gshfjf_jetform_status_<?php echo esc_attr($gshfjf_feed_id); ?>"
                                                    class="button-toggle"></label>
                                            </div>
                                        </td>

                                    </tr>

                                <?php endforeach; ?>



                            <?php endif; ?>

                        </table>
                    </div>

                    <?php if ($gshfjf_total_pages > 1) : ?>

                        <?php
                        // $paged = isset($_GET['paged']) ? absint($_GET['paged']) : 1;
                        $paged = 1;

                        if (
                            isset($_GET['paged'], $_GET['_wpnonce']) &&
                            wp_verify_nonce(sanitize_text_field(wp_unslash($_GET['_wpnonce'])), 'gshfjf_pagination_nonce')
                        ) {
                            $paged = absint($_GET['paged']);
                        }
                        $gshfjf_base_url = add_query_arg(
                            array(
                                'page'   => isset($_GET['page']) ? sanitize_text_field(wp_unslash($_GET['page'])) : '',
                                'paged'  => '%#%',
                                '_wpnonce' => wp_create_nonce('gshfjf_pagination_nonce'),
                            ),
                            admin_url('admin.php')
                        );

                        $gshfjf_pagination = paginate_links(array(
                            'base'      => $gshfjf_base_url,
                            'format'    => '',
                            'prev_text' => esc_html__('« Prev', 'gsheetconnector-for-jetform'),
                            'next_text' => esc_html__('Next »', 'gsheetconnector-for-jetform'),
                            'total'     => (int) $gshfjf_total_pages,
                            'current'   => (int) $paged,
                            'type'      => 'array',
                        ));
                        ?>

                        <div class="gshfjf-pagination mt-40 text-center">
                            <ul class="gsc-pagination-list">
                                <?php if (!empty($gshfjf_pagination)) : ?>
                                    <?php foreach ($gshfjf_pagination as $gshfjf_page_link) : ?>
                                        <li><?php echo wp_kses_post($gshfjf_page_link); ?></li>
                                    <?php endforeach; ?>
                                <?php endif; ?>
                            </ul>
                        </div>

                    <?php endif; ?>

                </div>
            </div>
            <div id="gshfjf-confirm-delete-popup-free" class="gshfjf-popup-overlay d-none">
                <div class="gshfjf-popup text-center">
                    <div class="gsc-modal-icon">
                        <svg width="30px" height="30px" viewBox="-0.5 0 25 25" fill="none" xmlns="http://www.w3.org/2000/svg">
                            <path d="M18.2202 21.25H5.78015C5.14217 21.2775 4.50834 21.1347 3.94373 20.8364C3.37911 20.5381 2.90402 20.095 2.56714 19.5526C2.23026 19.0101 2.04372 18.3877 2.02667 17.7494C2.00963 17.111 2.1627 16.4797 2.47015 15.92L8.69013 5.10999C9.03495 4.54078 9.52077 4.07013 10.1006 3.74347C10.6804 3.41681 11.3346 3.24518 12.0001 3.24518C12.6656 3.24518 13.3199 3.41681 13.8997 3.74347C14.4795 4.07013 14.9654 4.54078 15.3102 5.10999L21.5302 15.92C21.8376 16.4797 21.9907 17.111 21.9736 17.7494C21.9566 18.3877 21.7701 19.0101 21.4332 19.5526C21.0963 20.095 20.6211 20.5381 20.0565 20.8364C19.4919 21.1347 18.8581 21.2775 18.2202 21.25V21.25Z" stroke="#d97706" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path>
                            <path d="M10.8809 17.15C10.8809 17.0021 10.9102 16.8556 10.9671 16.7191C11.024 16.5825 11.1074 16.4586 11.2125 16.3545C11.3175 16.2504 11.4422 16.1681 11.5792 16.1124C11.7163 16.0567 11.8629 16.0287 12.0109 16.03C12.2291 16.034 12.4413 16.1021 12.621 16.226C12.8006 16.3499 12.9398 16.5241 13.0211 16.7266C13.1023 16.9292 13.122 17.1512 13.0778 17.3649C13.0335 17.5786 12.9272 17.7745 12.7722 17.9282C12.6172 18.0818 12.4203 18.1863 12.2062 18.2287C11.9921 18.2711 11.7703 18.2494 11.5685 18.1663C11.3666 18.0833 11.1938 17.9426 11.0715 17.7618C10.9492 17.5811 10.8829 17.3683 10.8809 17.15ZM11.2409 14.42L11.1009 9.20001C11.0876 9.07453 11.1008 8.94766 11.1398 8.82764C11.1787 8.70761 11.2424 8.5971 11.3268 8.5033C11.4112 8.40949 11.5144 8.33449 11.6296 8.28314C11.7449 8.2318 11.8697 8.20526 11.9959 8.20526C12.1221 8.20526 12.2469 8.2318 12.3621 8.28314C12.4774 8.33449 12.5805 8.40949 12.6649 8.5033C12.7493 8.5971 12.8131 8.70761 12.852 8.82764C12.8909 8.94766 12.9042 9.07453 12.8909 9.20001L12.7609 14.42C12.7609 14.6215 12.6808 14.8149 12.5383 14.9574C12.3957 15.0999 12.2024 15.18 12.0009 15.18C11.7993 15.18 11.606 15.0999 11.4635 14.9574C11.321 14.8149 11.2409 14.6215 11.2409 14.42Z" fill="#d97706"></path>
                        </svg>
                    </div>
                    <div class="gsc-modal-title"><?php echo esc_html__('Delete Feed', 'gsheetconnector-for-jetform'); ?></div>
                    <p class="gsc-modal-text"><?php echo esc_html__('Are you sure you want to delete this feed? This action cannot be undone.', 'gsheetconnector-for-jetform'); ?></p>
                    <div class="popup-actions d-flex justify-center gap-10">
                        <button type="button" class="btn btn-deactivate" id="gshfjf-delete-popup-cancel-free">
                            <?php echo esc_html__('Cancel', 'gsheetconnector-for-jetform'); ?>
                        </button>
                        <button type="button" class="btn btn-primary" id="gshfjf-delete-popup-confirm-free">
                            <?php echo esc_html__('Delete', 'gsheetconnector-for-jetform'); ?>
                        </button>
                    </div>
                </div>
            </div>
        </div>
    </div>
<?php
} ?>