(function () {
    const config = window.griffinformsCoreDeactivationWarning;
    if (!config || !config.core_plugin_basename) {
        return;
    }

    const selector = 'tr[data-plugin="' + config.core_plugin_basename + '"] .deactivate a';

    document.addEventListener('click', function (event) {
        const link = event.target instanceof Element ? event.target.closest(selector) : null;
        if (!link) {
            return;
        }

        const message = config.title + '\n\n' + config.message;
        if (!window.confirm(message)) {
            event.preventDefault();
        }
    });
})();
