import './frontend-widget.scss';
import { render } from '@wordpress/element';
import FrontendWidget from "./frontend-widget";

console.log('Frontend widget script loaded');

// Wait for DOM to be ready
document.addEventListener('DOMContentLoaded', function() {
    const targetElement = document.getElementById('acb-frontend-widget-container');
    
    if (targetElement) {
        console.log('Rendering Frontend Widget component');
        render(<FrontendWidget />, targetElement);
    } else {
        console.error('Target element acb-frontend-widget-container not found');
    }
});

// Also try immediately in case DOM is already loaded
const targetElement = document.getElementById('acb-frontend-widget-container');
if (targetElement) {
    console.log('Rendering Frontend Widget component (immediate)');
    render(<FrontendWidget />, targetElement);
}