<?php

if (! defined('ABSPATH')) {
    exit;
} class PufferGo_Page_AI_Chat
{
    public const VERSION = '1.0.0';

    public function __construct()
    {
        if (is_admin()) {
            add_action('enqueue_block_editor_assets', array($this, 'enqueue_editor_assets'));
        }
    }

    public function enqueue_editor_assets()
    {
        return;
        puffergo_log('🔍 [Page AI Chat] enqueue_editor_assets() called');
        $screen = get_current_screen();
        puffergo_log('🔍 [Page AI Chat] Current screen: ' . ($screen ? $screen->base : 'NULL'));

        if (! $screen || ! in_array($screen->base, array('post', 'post-new'), true)) {
            puffergo_log('⚠️ [Page AI Chat] NOT loading - screen check failed');

            return;
        } puffergo_log('✅ [Page AI Chat] Screen check passed, proceeding to enqueue...');
        $plugin_url = plugin_dir_url(dirname(__FILE__));
        $plugin_dir = plugin_dir_path(dirname(__FILE__));
        $asset_file = $plugin_dir . 'build/admin/page-ai-chat/index.asset.php';

        if (file_exists($asset_file)) {
            $asset = include $asset_file;
            $dependencies = $asset['dependencies'];
            $version = $asset['version'];
        } else {
            $dependencies = array('wp-plugins', 'wp-edit-post', 'wp-editor', 'wp-element', 'wp-components', 'wp-data', 'wp-api-fetch', 'wp-i18n', 'wp-notices', );
            $version = self::VERSION;
        } $js_file = $plugin_dir . 'build/admin/page-ai-chat/index.js';
        puffergo_log('🔍 [Page AI Chat] JS file path: ' . $js_file);
        puffergo_log('🔍 [Page AI Chat] JS file exists: ' . (file_exists($js_file) ? 'YES' : 'NO'));

        if (file_exists($js_file)) {
            wp_enqueue_script('puffergo-page-ai-chat', $plugin_url . 'build/admin/page-ai-chat/index.js', $dependencies, $version, true);
            puffergo_log('✅ [Page AI Chat] JavaScript enqueued successfully!');
            puffergo_log('🔍 [Page AI Chat] Script URL: ' . $plugin_url . 'build/admin/page-ai-chat/index.js');
            puffergo_log('🔍 [Page AI Chat] Dependencies: ' . wp_json_encode($dependencies));
            wp_localize_script('puffergo-page-ai-chat', 'puffergoPageAIChat', array('restUrl' => rest_url('puffergo/v1/'), 'nonce' => wp_create_nonce('wp_rest'), ));
            puffergo_log('✅ [Page AI Chat] Script localized with config');
        } else {
            puffergo_log('❌ [Page AI Chat] JavaScript file NOT FOUND!');
        } $css_file = $plugin_dir . 'build/admin/page-ai-chat/style-index.css';
        puffergo_log('🔍 [Page AI Chat] CSS file exists: ' . (file_exists($css_file) ? 'YES' : 'NO'));

        if (file_exists($css_file)) {
            wp_enqueue_style('puffergo-page-ai-chat', $plugin_url . 'build/admin/page-ai-chat/style-index.css', array('wp-components'), $version);
            puffergo_log('✅ [Page AI Chat] CSS enqueued successfully!');
        } puffergo_log('🏁 [Page AI Chat] enqueue_editor_assets() completed');
    }
} new PufferGo_Page_AI_Chat();
