@extends('layouts.app')

@section('content')

    {!!
        $content
    !!}
    
<script>
	
function resizeIframe() {
	
	var iframes = document.querySelectorAll('iframe');
	console.log('Resizing iframes:', iframes.length);
	iframes.forEach(function(iframe) {
		// Example: set height to content height if same-origin, else keep fixed
		try {
			var doc = iframe.contentDocument || iframe.contentWindow.document;
			if (doc && doc.body) {
				var scrollHeight = doc.body.scrollHeight;
				var bodyHeight = doc.body.offsetHeight;
				iframe.style.height = (scrollHeight > bodyHeight ? bodyHeight : scrollHeight ) + 'px';

			}
            iframe.setAttribute('scrolling', 'no');
            iframe.style.overflow = 'hidden';
            iframe.contentWindow.document.body.style.overflow = 'hidden';
			iframe.contentWindow.document.body.style.height = 'fit-content';
			console.log('Resized iframe:', iframe.src, 'to height:', iframe.style.height);
		} catch (e) {
			// Cross-origin, cannot access content
			// Optionally, keep fixed height or handle differently
		}
	});
}

// Resize every 1 second
setInterval(resizeIframe, 1000);
</script>
@endsection