<?php
/**
 * SEO Enhancements for Easy AI Blog Generator
 *
 * This file serves as the main loader for all SEO enhancement features,
 * including the dashboard, visualizations, and analysis tools.
 *
 * @package EasyAIBlogGenerator
 */

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

/**
 * Load the SEO enhancement files.
 */
function easyaibloggen_load_seo_enhancements() {
	// First, remove the keyword analysis from blog posts.
	require_once plugin_dir_path( __FILE__ ) . 'easyaibloggen-remove-blog-keyword-analysis.php';

	// Then load the new SEO dashboard.
	require_once plugin_dir_path( __FILE__ ) . 'easyaibloggen-seo-dashboard.php';

	// Include the visualization test file to ensure charts are working.
	require_once plugin_dir_path( __FILE__ ) . 'easyaibloggen-seo-test.php';

	// Create CSS and JS directories if they don't exist.
	$css_dir = plugin_dir_path( __FILE__ ) . 'css';
	if ( ! file_exists( $css_dir ) ) {
		wp_mkdir_p( $css_dir );
	}

	$js_dir = plugin_dir_path( __FILE__ ) . 'js';
	if ( ! file_exists( $js_dir ) ) {
		wp_mkdir_p( $js_dir );
	}

	// Create lib directory for third-party libraries if it doesn't exist.
	$lib_dir = plugin_dir_path( __FILE__ ) . 'lib';
	if ( ! file_exists( $lib_dir ) ) {
		wp_mkdir_p( $lib_dir );
	}

	// Ensure Chart.js is available locally (WordPress.org requires local loading of all scripts).
	$chartjs_file = $lib_dir . '/chart.min.js';
	if ( ! file_exists( $chartjs_file ) ) {
		// Try to copy Chart.js from CDN to local file.
		$chartjs_content = wp_remote_get( 'https://cdn.jsdelivr.net/npm/chart.js@3.9.1/dist/chart.min.js' );
		if ( ! is_wp_error( $chartjs_content ) && 200 === wp_remote_retrieve_response_code( $chartjs_content ) ) {
			$chartjs_content = wp_remote_retrieve_body( $chartjs_content );

			// Use WP_Filesystem instead of direct file operation.
			global $wp_filesystem;
			if ( empty( $wp_filesystem ) ) {
				require_once ABSPATH . '/wp-admin/includes/file.php';
				WP_Filesystem();
			}
			$wp_filesystem->put_contents( $chartjs_file, $chartjs_content, FS_CHMOD_FILE );
		}
	}
}

// Load the SEO enhancements.
easyaibloggen_load_seo_enhancements();

/**
 * Add a hook to include these files in the plugin's initialization.
 * This ensures our files are loaded after the plugin's core files.
 */
function easyaibloggen_initialize_seo_enhancements() {
	// This function is intentionally empty as the files are already loaded above.
	// It exists to provide a hook point for other plugin integrations if needed.
}
add_action( 'plugins_loaded', 'easyaibloggen_initialize_seo_enhancements', 20 );

/**
 * Register and enqueue scripts for SEO enhancements.
 */
function easyaibloggen_register_seo_enhancement_scripts() {
	// Only load on post edit screen.
	$screen = get_current_screen();
	if ( ! $screen || 'post' !== $screen->base ) {
		return;
	}

	// Enqueue Chart.js from local plugin directory (WordPress.org requires local loading).
	wp_enqueue_script(
		'easyaibloggen-chartjs',
		plugin_dir_url( __FILE__ ) . 'lib/chart.min.js',
		array( 'jquery' ),
		'3.9.1',
		true
	);

	// Now enqueue our visualization script.
	wp_enqueue_script(
		'easyaibloggen-seo-visualizations',
		plugin_dir_url( __FILE__ ) . 'js/easyaibloggen-seo-visualizations.js',
		array( 'jquery', 'easyaibloggen-chartjs' ),
		'1.0.0',
		true
	);

	// Make plugin URL available to JS.
	wp_localize_script(
		'easyaibloggen-seo-visualizations',
		'easyaiSEOVisualizations',
		array(
			'pluginUrl' => plugin_dir_url( __FILE__ ),
			'ajaxUrl'   => admin_url( 'admin-ajax.php' ),
			'nonce'     => wp_create_nonce( 'easyaibloggen_seo_nonce' ),
			'debug'     => defined( 'WP_DEBUG' ) && WP_DEBUG,
		)
	);

	// Also localize to jQuery for early access.
	wp_localize_script(
		'jquery',
		'easyaiSEOVisualizations',
		array(
			'pluginUrl' => plugin_dir_url( __FILE__ ),
			'ajaxUrl'   => admin_url( 'admin-ajax.php' ),
			'nonce'     => wp_create_nonce( 'easyaibloggen_seo_nonce' ),
			'debug'     => defined( 'WP_DEBUG' ) && WP_DEBUG,
		)
	);

	// Enqueue dashboard script.
	wp_enqueue_script(
		'easyaibloggen-seo-dashboard',
		plugin_dir_url( __FILE__ ) . 'js/easyaibloggen-seo-dashboard.js',
		array( 'jquery', 'easyaibloggen-chartjs', 'easyaibloggen-seo-visualizations' ),
		'1.0.0',
		true
	);

	// Localize dashboard script.
	wp_localize_script(
		'easyaibloggen-seo-dashboard',
		'easySEODashboard',
		array(
			'ajaxUrl'   => admin_url( 'admin-ajax.php' ),
			'nonce'     => wp_create_nonce( 'easyaibloggen_seo_nonce' ),
			'postId'    => get_the_ID(),
			'pluginUrl' => plugin_dir_url( __FILE__ ),
			'strings'   => array(
				'analyzing'    => esc_html__( 'Analyzing...', 'easy-ai-blog-generator' ),
				'errorMessage' => esc_html__( 'Error analyzing content.', 'easy-ai-blog-generator' ),
			),
		)
	);
}
add_action( 'admin_enqueue_scripts', 'easyaibloggen_register_seo_enhancement_scripts', 20 );

/**
 * Add a notice about the SEO scorecard for user guidance.
 */
function easyaibloggen_add_seo_troubleshooting_notice() {
	$screen = get_current_screen();
	if ( ! $screen || 'post' !== $screen->base ) {
		return;
	}

	echo wp_kses_post( '<div class="notice notice-info is-dismissible" style="margin-top: 15px;">' );
	echo wp_kses_post( '<p><strong>SEO Scorecard Available:</strong> The Easy AI Blog Generator Scorecard is now automatically shown in the SEO Content Optimization Dashboard. To see your optimization details, click "Analyze Content".</p>' );
	echo wp_kses_post( '</div>' );
}
add_action( 'admin_notices', 'easyaibloggen_add_seo_troubleshooting_notice' );

/**
 * Add critical visualization CSS to the head.
 */
function easyaibloggen_add_critical_visualization_css() {
	// Only run on post edit screen.
	$screen = get_current_screen();
	if ( ! $screen || 'post' !== $screen->base ) {
		return;
	}

	?>
	<style>
		/* Critical CSS for visualizations - prevents visualization overlay issues */
		#easyai-visualizations-panel, .easyai-seo-visualizations-panel {
			position: relative !important;
			width: 100% !important;
			opacity: 1 !important;
			box-sizing: border-box !important;
			z-index: 1 !important;
			display: block !important;
			background: #fff !important;
			border: 1px solid #e5e5e5 !important;
			box-shadow: 0 1px 1px rgba(0,0,0,0.04) !important;
			padding: 15px 20px !important;
			margin-bottom: 20px !important;
			border-radius: 0 !important;
		}
		
		.easyai-visualization-container {
			position: relative !important;
			height: 180px !important;
			width: 100% !important;
			max-width: 100% !important;
			box-sizing: border-box !important;
			overflow: visible !important;
		}
		
		.easyai-visualization-container canvas {
			max-width: 100% !important;
			max-height: 100% !important;
			display: block !important;
		}
		
		.easyai-visualizations-grid {
			display: grid !important;
			grid-template-columns: repeat(2, 1fr) !important;
			gap: 20px !important;
			width: 100% !important;
			box-sizing: border-box !important;
		}
		
		.easyai-visualization-item.easyai-visualization-full {
			grid-column: 1 / -1 !important;
		}
		
		.easyai-visualization-item {
			background: #fbfbfb !important;
			border: 1px solid #e5e5e5 !important;
			padding: 12px !important;
			border-radius: 3px !important;
			margin-bottom: 0 !important;
		}
		
		/* Loading indicators for visualizations */
		.easyai-visualization-loading {
			position: absolute !important;
			top: 0 !important;
			left: 0 !important;
			width: 100% !important;
			height: 100% !important;
			background: rgba(255, 255, 255, 0.85) !important;
			display: flex !important;
			justify-content: center !important;
			align-items: center !important;
			z-index: 100 !important;
			border-radius: 4px !important;
		}
		
		.easyai-visualization-loading span {
			display: inline-block !important;
			padding: 5px 15px !important;
			background: #f8f8f8 !important;
			border-radius: 4px !important;
			color: #0073aa !important;
			font-size: 12px !important;
			box-shadow: 0 1px 3px rgba(0,0,0,0.1) !important;
		}
		
		.easyai-visualization-loading span:before {
			content: "" !important;
			display: inline-block !important;
			width: 12px !important;
			height: 12px !important;
			border: 2px solid transparent !important;
			border-top-color: #0073aa !important;
			border-radius: 50% !important;
			margin-right: 8px !important;
			vertical-align: middle !important;
			animation: easyai-spin 1s linear infinite !important;
		}
		
		@keyframes easyai-spin {
			0% { transform: rotate(0deg); }
			100% { transform: rotate(360deg); }
		}
		
		/* Section styles */
		.easyai-visualizations-section {
			margin-bottom: 25px !important;
		}
		
		.easyai-section-heading {
			border-bottom: 1px solid #eee !important;
			padding-bottom: 8px !important;
			margin-top: 20px !important;
			margin-bottom: 15px !important;
			font-size: 14px !important;
		}
		
		/* Current keyword display */
		.easyai-current-keyword-display {
			background-color: #f9f9f9 !important;
			border: 1px solid #e5e5e5 !important;
			padding: 8px 12px !important;
			border-radius: 3px !important;
			margin-bottom: 15px !important;
			font-weight: 500 !important;
			color: #333 !important;
		}
		
		/* Heading structure tree */
		#heading-structure-tree {
			overflow-y: auto !important;
			max-height: 180px !important;
			padding: 10px !important;
		}
		
		.easyai-tree-node {
			margin-left: 15px !important;
			position: relative !important;
			padding-left: 10px !important;
			border-left: 1px solid #ddd !important;
		}
		
		/* Visualization Item headings */
		.easyai-visualization-item h4 {
			margin-top: 0 !important;
			margin-bottom: 10px !important;
			font-size: 13px !important;
			color: #23282d !important;
			font-weight: 600 !important;
		}
		
		/* Scorecard title */
		.easyai-seo-visualizations-panel h3 {
			font-size: 15px !important;
			font-weight: 600 !important;
			margin-top: 0 !important;
			margin-bottom: 10px !important;
			border-bottom: 1px solid #eee !important;
			padding-bottom: 8px !important;
			color: #23282d !important;
		}
		
		/* Media query for small screens */
		@media screen and (max-width: 782px) {
			.easyai-visualizations-grid {
				grid-template-columns: 1fr !important;
			}
		}
	</style>
	
	<!-- Debug information for administrators only -->
	<?php if ( current_user_can( 'manage_options' ) ) : ?>
	<script>
	jQuery(document).ready(function($) {
		console.log('SEO Enhancements Debug Information:');
		console.log('- WordPress Version: <?php echo esc_js( get_bloginfo( 'version' ) ); ?>');
		console.log('- Plugin Version: <?php echo esc_js( defined( 'EASYAIBLOGGEN_VERSION' ) ? EASYAIBLOGGEN_VERSION : 'Unknown' ); ?>');
		console.log('- Current Screen: <?php echo esc_js( $screen->id ); ?>');
		console.log('- Chart.js Loading: Direct enqueue method');
		
		// Debug button removed - no longer showing in top right corner
		// Debug button functionality also removed
	});
	</script>
	<?php endif; ?>
	<?php
}
add_action( 'admin_head', 'easyaibloggen_add_critical_visualization_css', 999 ); // Higher priority.

/**
 * Register scripts and styles for visualization.
 */
function easyaibloggen_register_visualization_assets() {
	// Only run on post edit screen.
	$screen = get_current_screen();
	if ( ! $screen || 'post' !== $screen->base ) {
		return;
	}

	// Preload Chart.js from local plugin directory (WordPress.org requires local loading).
	echo '<link rel="preload" href="' . esc_url( plugin_dir_url( __FILE__ ) . 'lib/chart.min.js' ) . '" as="script" crossorigin="anonymous">';

	// Deregister and reregister jQuery to ensure it's loaded in the head.
	wp_deregister_script( 'jquery' );
	wp_register_script( 'jquery', includes_url( '/js/jquery/jquery.js' ), array(), '3.6.4', false );
	wp_enqueue_script( 'jquery' );

	// Register and enqueue Chart.js with maximum priority from local plugin directory.
	wp_register_script(
		'easyaibloggen-chartjs',
		plugin_dir_url( __FILE__ ) . 'lib/chart.min.js',
		array( 'jquery' ),
		'3.9.1',
		false // Load in header.
	);
	wp_enqueue_script( 'easyaibloggen-chartjs' );

	// Register and enqueue the visualization script.
	wp_register_script(
		'easyaibloggen-seo-visualizations',
		plugin_dir_url( __FILE__ ) . 'js/easyaibloggen-seo-visualizations.js',
		array( 'jquery', 'easyaibloggen-chartjs' ),
		time(), // Use current time to prevent caching during development.
		false // Load in header.
	);
	wp_enqueue_script( 'easyaibloggen-seo-visualizations' );

	// Register and enqueue visualization styles.
	wp_register_style(
		'easyaibloggen-seo-visualizations',
		plugin_dir_url( __FILE__ ) . 'css/easyaibloggen-seo-visualizations.css',
		array(),
		time() // Use current time to prevent caching during development.
	);
	wp_enqueue_style( 'easyaibloggen-seo-visualizations' );

	// Add inline script to ensure dashboard loaded event is triggered.
	wp_add_inline_script(
		'easyaibloggen-seo-visualizations',
		'
        jQuery(document).ready(function($) {
            console.log("Document ready, checking for visualization panel");
            
            // Try to trigger dashboard loaded event if not already done
            setTimeout(function() {
                if ($("#easyai-visualizations-panel").length === 0) {
                    console.log("Visualization panel not found after timeout, triggering event");
                    $(document).trigger("easyai_dashboard_loaded");
                }
            }, 1500);
        });
    '
	);
}
add_action( 'admin_enqueue_scripts', 'easyaibloggen_register_visualization_assets', 5 ); // Very early priority.

/**
 * Add visualization debug button for administrators to troubleshoot visualization issues.
 * 
 * Note: This functionality has been disabled to hide debugging tools from the UI
 */
function easyaibloggen_add_visualization_debug_button() {
	// Debug button functionality removed - no longer showing debug notice
	return;
}
add_action( 'admin_notices', 'easyaibloggen_add_visualization_debug_button' );

/**
 * Monitor AJAX calls for debugging purposes when WP_DEBUG is enabled.
 */
function easyaibloggen_monitor_ajax_calls() {
	// Only run when WP_DEBUG is enabled.
	if ( ! defined( 'WP_DEBUG' ) || ! WP_DEBUG ) {
		return;
	}

	add_filter(
		'wp_doing_ajax',
		function ( $doing_ajax ) {
			if ( $doing_ajax ) {
				// Check if action is set before accessing it.
				if ( isset( $_REQUEST['action'] ) ) {
					$action = sanitize_text_field( wp_unslash( $_REQUEST['action'] ) );

					// Log only if we're in debug mode.
					if ( defined( 'WP_DEBUG_LOG' ) && WP_DEBUG_LOG ) {
						// phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
						error_log( 'AJAX call: ' . $action );
					}

					// Check for our specific SEO analysis action.
					if ( 'easyaibloggen_analyze_seo_content' === $action ) {
						// Add debug log for SEO analysis.
						if ( defined( 'WP_DEBUG_LOG' ) && WP_DEBUG_LOG ) {
							// phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
							error_log( 'SEO analysis AJAX call detected' );
						}

						// Check nonce.
						$has_valid_nonce = false;
						if ( isset( $_REQUEST['nonce'] ) ) {
							$nonce           = sanitize_text_field( wp_unslash( $_REQUEST['nonce'] ) );
							$has_valid_nonce = wp_verify_nonce( $nonce, 'easyaibloggen_seo_nonce' );
						}

						if ( ! $has_valid_nonce && defined( 'WP_DEBUG_LOG' ) && WP_DEBUG_LOG ) {
							// phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
							error_log( 'Nonce verification failed' );
						}

						// Check post ID.
						if ( ! isset( $_REQUEST['postId'] ) ) {
							if ( defined( 'WP_DEBUG_LOG' ) && WP_DEBUG_LOG ) {
								// phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
								error_log( 'No post ID provided' );
							}
						} else {
							$post_id = intval( wp_unslash( $_REQUEST['postId'] ) );
							if ( defined( 'WP_DEBUG_LOG' ) && WP_DEBUG_LOG ) {
								// phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
								error_log( 'Post ID: ' . $post_id );
							}
						}
					}
				}
			}
			return $doing_ajax;
		}
	);
}
add_action( 'init', 'easyaibloggen_monitor_ajax_calls' );

/**
 * Add visualization container styles to wp_head.
 */
function easyaibloggen_add_visualization_container_styles() {
	// Only run on post edit screen.
	$screen = get_current_screen();
	if ( ! $screen || 'post' !== $screen->base ) {
		return;
	}

	?>
	<style>
		/* Visualization Panel Styles */
		.easyai-seo-visualizations-panel {
			margin-top: 20px !important;
			background-color: #fff !important;
			border: 1px solid #e5e5e5 !important;
			border-radius: 3px !important;
			padding: 15px !important;
			box-shadow: 0 1px 3px rgba(0,0,0,0.05) !important;
		}
		
		#easyai-visualizations-panel h3 {
			margin-top: 0 !important;
			margin-bottom: 15px !important;
			font-size: 16px !important;
			color: #23282d !important;
			font-weight: 600 !important;
			border-bottom: 1px solid #eee !important;
			padding-bottom: 10px !important;
		}
		
		.easyai-visualizations-grid {
			display: grid !important;
			grid-template-columns: repeat(2, 1fr) !important;
			gap: 20px !important;
			margin-bottom: 20px !important;
		}
		
		@media (max-width: 782px) {
			.easyai-visualizations-grid {
				grid-template-columns: 1fr !important;
			}
		}
		
		.easyai-visualization-item {
			background-color: #f9f9f9 !important;
			border: 1px solid #e5e5e5 !important;
			border-radius: 3px !important;
			padding: 15px !important;
		}
		
		.easyai-visualization-full {
			grid-column: span 2 !important;
		}
		
		@media (max-width: 782px) {
			.easyai-visualization-full {
				grid-column: span 1 !important;
			}
		}
		
		.easyai-current-keyword-display {
			background-color: #f0f6fc !important;
			border: 1px solid #c5d9ed !important;
			padding: 8px 12px !important;
			border-radius: 3px !important;
			margin-bottom: 20px !important;
			color: #2271b1 !important;
			font-weight: 500 !important;
		}
		
		/* Make sure canvas elements display properly */
		.easyai-visualization-container canvas {
			max-width: 100% !important;
			height: auto !important;
			display: block !important; 
			margin: 0 auto !important;
		}
		
		/* Fix for SEO Progress and Competitor Benchmark charts */
		#seo-progress-chart, #competitor-benchmark-chart {
			width: 100% !important;
			height: 250px !important;
			max-height: 100% !important;
		}
		
		/* Critical fix for radar chart */
		#competitor-benchmark-chart {
			display: block !important;
			visibility: visible !important;
			opacity: 1 !important;
		}
		
		/* Ensure the containers for these specific charts are visible and sized properly */
		#seo-progress-chart, 
		#competitor-benchmark-chart {
			display: block !important;
			visibility: visible !important;
			min-height: 250px !important;
			min-width: 300px !important;
			width: 100% !important;
			height: 250px !important;
			margin: 0 auto !important;
		}
		
		/* Specifically target the containers of these chart canvases */
		#seo-progress-chart + .easyai-visualization-loading,
		#competitor-benchmark-chart + .easyai-visualization-loading {
			display: none !important;
		}
		
		/* Ensure parent containers are sized correctly */
		.easyai-visualization-container {
			min-height: 250px !important;
			position: relative !important;
		}
		
		/* Show canvas with no dimensions */
		canvas:not([width]):not([height]) {
			min-height: 250px !important;
			min-width: 100% !important;
			width: 100% !important;
			height: 250px !important;
			display: block !important;
		}
		
		/* Added better styling for toggle buttons */
		.easyai-toggle-help, .easyai-toggle-guide {
			background-color: #f0f0f1 !important;
			border: 1px solid #c3c4c7 !important;
			color: #2c3338 !important;
			padding: 4px 8px !important;
			border-radius: 3px !important;
			cursor: pointer !important;
			font-size: 13px !important;
			text-decoration: none !important;
			transition: all 0.2s ease !important;
		}
		
		.easyai-toggle-help:hover, .easyai-toggle-guide:hover {
			background-color: #f6f7f7 !important;
		}
		
		/* Better styling for expanded content */
		.easyai-scorecard-help-content, .easyai-interpretation-content {
			border: 1px solid #dcdcde !important;
			background-color: #f6f7f7 !important;
			padding: 15px !important;
			margin-top: 10px !important;
			border-radius: 3px !important;
		}
	</style>
	<script>
	jQuery(document).ready(function($) {
		// Log when the visualization panel gets created.
		const observer = new MutationObserver(function(mutations) {
			mutations.forEach(function(mutation) {
				if (mutation.addedNodes && mutation.addedNodes.length > 0) {
					for (let i = 0; i < mutation.addedNodes.length; i++) {
						const node = mutation.addedNodes[i];
						if (node.id === 'easyai-visualizations-panel') {
							console.log('Visualization panel added to DOM:', node);
							
							// EMERGENCY FIX: Force fix the two problematic charts.
							setTimeout(function() {
								// Check for canvas elements - force create if missing or zero sized.
								const seoProgressChart = document.getElementById('seo-progress-chart');
								const competitorBenchmarkChart = document.getElementById('competitor-benchmark-chart');
								
								console.log('Emergency check - SEO Progress canvas:', 
									seoProgressChart ? 'exists' : 'missing', 
									seoProgressChart ? `size: ${seoProgressChart.width}x${seoProgressChart.height}` : '');
								
								console.log('Emergency check - Competitor Benchmark canvas:', 
									competitorBenchmarkChart ? 'exists' : 'missing',
									competitorBenchmarkChart ? `size: ${competitorBenchmarkChart.width}x${competitorBenchmarkChart.height}` : '');
								
								// Force set width/height attributes on canvas elements.
								if (seoProgressChart) {
									seoProgressChart.width = 400;
									seoProgressChart.height = 250;
									seoProgressChart.style.width = '100%';
									seoProgressChart.style.height = '250px';
									seoProgressChart.style.display = 'block';
								}
								
								if (competitorBenchmarkChart) {
									competitorBenchmarkChart.width = 400;
									competitorBenchmarkChart.height = 250;
									competitorBenchmarkChart.style.width = '100%';
									competitorBenchmarkChart.style.height = '250px';
									competitorBenchmarkChart.style.display = 'block';
								}
							}, 1000);
						}
					}
				}
			});
		});
		
		// Start observing the body.
		observer.observe(document.body, { childList: true, subtree: true });
		
		// Also try a direct approach immediately.
		setTimeout(function() {
			const seoProgressChart = document.getElementById('seo-progress-chart');
			const competitorBenchmarkChart = document.getElementById('competitor-benchmark-chart');
			
			if (seoProgressChart) {
				seoProgressChart.width = 400;
				seoProgressChart.height = 250;
				seoProgressChart.style.width = '100%';
				seoProgressChart.style.height = '250px';
				seoProgressChart.style.display = 'block';
			}
			
			if (competitorBenchmarkChart) {
				competitorBenchmarkChart.width = 400;
				competitorBenchmarkChart.height = 250;
				competitorBenchmarkChart.style.width = '100%';
				competitorBenchmarkChart.style.height = '250px';
				competitorBenchmarkChart.style.display = 'block';
			}
		}, 2000);
	});
	</script>
	<?php
}
add_action( 'admin_head', 'easyaibloggen_add_visualization_container_styles' );
