document.addEventListener("DOMContentLoaded", function() {
    const config = {
      order: 'text-media', // or 'media-text'
      mainText: 'Headline Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore.',
      imageUrl: 'https://s3-alpha-sig.figma.com/img/37a7/42fb/1daabd5424c6093ca79a6d502b3b84ef?Expires=1724630400&Key-Pair-Id=APKAQ4GOSFWCVNEHN3O4&Signature=FgQK8BhmZm52syueYHL8d33N9v48-lePOhb~KQgE528f-GZn8a8HXap5OvWlCdKaf2nZLlFvmgWgpnuz7iekJqEAS95CknKbniYODvBDOGMVIcHrU7YthPZ~YqZSE7pEANVBVEwkB9-1zJ77gT9uEMryjd-xb44NjnBhfLPkP4B9qlqkbuehRRhLGPBnYA9q3PHpf5ocx7j0~xAbomT~EFX2bzwBu70gKN0qTFVRy8uNu8USYah2YotQH58ChxcEPokhPxENAdNCWeDodsWVFrldbeU0CgVzCrn3MLYu9Ep96r7tjAvKfgQQqC6eORHyM-citVFu1DlJx8-CUN26RQ__',
      imageCaption: ''
    };
  
    // Fetch and load the HTML component
    fetch('components/text-media-2.html')
        .then(response => response.text())
        .then(data => {
            document.getElementById('text-media-2-container').innerHTML = data;
  
            const wrapper = document.querySelector('.text-media-2');
            const h3 = document.querySelector('.text-section h3');
            const img = document.querySelector('.media-section img');
            const imgCaption = document.querySelector('.media-section .image-caption');
  
            // Update content
            h3.textContent = config.mainText;
            img.src = config.imageUrl;
  
            if (config.imageCaption) {
                imgCaption.textContent = config.imageCaption;
                img.style.width = '414px';
                img.style.height = '624px';
                imgCaption.style.display = 'block';
            } else {
                img.style.width = '414px';
                img.style.height = '680px';
                imgCaption.style.display = 'none';
            }
  
            // Set order
            if (config.order === 'text-media') {
                wrapper.classList.add('reverse');
            }
        })
        .catch(error => console.error('Error loading text-media-2 component:', error));
  });
  