<div class="max-w-7xl mx-auto" style="color: #e5e7eb; ">
    

    <!--[if BLOCK]><![endif]--><?php if($reauthLoading ?? false): ?>
        <?php
$__split = function ($name, $params = []) {
    return [$name, $params];
};
[$__name, $__params] = $__split('refresh-wait', []);

$__html = app('livewire')->mount($__name, $__params, 'lw-4208540403-0', $__slots ?? [], get_defined_vars());

echo $__html;

unset($__html);
unset($__name);
unset($__params);
unset($__split);
if (isset($__slots)) unset($__slots);
?>
    <?php elseif($drama): ?>
        
        <div class="lg:px-8 flex flex-col gap-8 lg:flex-row lg:gap-8 items-start mb-8">
            <div style="flex: 2 1 400px; min-width: 280px; max-width: 700px;" class="w-full">
                <!--[if BLOCK]><![endif]--><?php if($episode): ?>
                    <h1 class="text-xl sm:text-2xl md:text-3xl font-bold text-white mb-5 text-left md:text-center"><?php echo e($drama['bookName'] ?? 'Untitled'); ?> <?php echo e($episode['chapterName'] ?? 'Episode'); ?></h1>
                    
                    <div wire:init="loadEpisodeVideo">
                        <!--[if BLOCK]><![endif]--><?php if($videoReady && !empty($bestVideoUrl)): ?>
                            <div class="mt-4 text-center mb-6">
                                <?php if (isset($component)) { $__componentOriginalc04b147acd0e65cc1a77f86fb0e81580 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginalc04b147acd0e65cc1a77f86fb0e81580 = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'e60dd9d2c3a62d619c9acb38f20d5aa5::button.index','data' => ['type' => 'button','wire:click' => 'reauth']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('flux::button'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['type' => 'button','wire:click' => 'reauth']); ?>
                                    Problem with video? Click here to fix.
                                 <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginalc04b147acd0e65cc1a77f86fb0e81580)): ?>
<?php $attributes = $__attributesOriginalc04b147acd0e65cc1a77f86fb0e81580; ?>
<?php unset($__attributesOriginalc04b147acd0e65cc1a77f86fb0e81580); ?>
<?php endif; ?>
<?php if (isset($__componentOriginalc04b147acd0e65cc1a77f86fb0e81580)): ?>
<?php $component = $__componentOriginalc04b147acd0e65cc1a77f86fb0e81580; ?>
<?php unset($__componentOriginalc04b147acd0e65cc1a77f86fb0e81580); ?>
<?php endif; ?>
                            </div>

                            <?php
                                $subtitleTracks = $episode['subtitles'] ?? [];
                                $langAliases = ['in' => 'id'];
                                $preferredSubtitleLang = strtolower($langAliases[$currentLang] ?? $currentLang ?? '');
                                $needsCrossorigin = !empty($subtitleTracks);
                            ?>
                            <div class="responsive-video-wrapper-vertical" x-data>
                                <video id="vid1" controls playsinline <?php if($needsCrossorigin): ?> crossorigin="anonymous" <?php endif; ?> poster="<?php echo e($episode['chapterImg'] ?? ''); ?>">
                                    <source id ="mysrc" src="<?php echo e($bestVideoUrl); ?>" type="video/mp4">
                                    <!--[if BLOCK]><![endif]--><?php $__currentLoopData = $subtitleTracks; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $subtitle): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <?php
                                            $trackLang = strtolower($subtitle['language'] ?? '');
                                            $isDefaultTrack = $preferredSubtitleLang && $trackLang === $preferredSubtitleLang;
                                        ?>
                                        <track kind="subtitles"
                                               src="<?php echo e($subtitle['url'] ?? ''); ?>"
                                               srclang="<?php echo e($trackLang ?: 'en'); ?>"
                                               label="<?php echo e($subtitle['label'] ?? strtoupper($trackLang ?: 'sub')); ?>"
                                               <?php if($isDefaultTrack): ?> default <?php endif; ?> />
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?><!--[if ENDBLOCK]><![endif]-->
                                    Your browser does not support video.
                                </video>
                            </div>
                            <style>
                                .responsive-video-wrapper-vertical video::-webkit-media-text-track-display,
                                .responsive-video-wrapper-vertical video::-webkit-media-text-track-container {
                                    transform: translateY(-10vh);
                                }

                                .responsive-video-wrapper-vertical video::cue {
                                    /* font-size: 1rem; */
                                    line-height: 1.4;
                                    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.65);
                                }
                            </style>

                            <div id="companion"></div>

                            <!--[if BLOCK]><![endif]--><?php if($showVastAd): ?>
                            <script>
                                var player = videojs('vid1');
                                var container = document.querySelector('.responsive-video-wrapper-vertical');
                                var containerWidth = container ? container.offsetWidth : 400;
                                var companion = {
                                    elementId: "companion",
                                    maxWidth: containerWidth,
                                    maxHeight: Math.round(containerWidth * 16 / 9)
                                };
                                var vastUrl = '<?php echo e(config('drama.vast_url')); ?>';
                                if (vastUrl) {
                                    player.vast({url: vastUrl, skip: 8, companion: companion});
                                }
                            </script>
                            <?php endif; ?><!--[if ENDBLOCK]><![endif]-->
                        <?php elseif($videoReady): ?>
                            <p style="color: #a1a1aa;">No playable video found for this episode.</p>
                        <?php else: ?>
                            <div class="responsive-video-wrapper-vertical flex items-center justify-center relative overflow-hidden" style="background:#111827; min-height: 320px;">
                                <!--[if BLOCK]><![endif]--><?php if($videoReady === false): ?>
                                    <div class="text-center flex flex-col items-center justify-center gap-3">
                                        <p class="text-gray-400">Preparing secure stream…</p>
                                        <?php if (isset($component)) { $__componentOriginalb06f0c5905a9427a630c5e299af7ce46 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginalb06f0c5905a9427a630c5e299af7ce46 = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'e60dd9d2c3a62d619c9acb38f20d5aa5::icon.loading','data' => ['class' => 'mx-auto']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('flux::icon.loading'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['class' => 'mx-auto']); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginalb06f0c5905a9427a630c5e299af7ce46)): ?>
<?php $attributes = $__attributesOriginalb06f0c5905a9427a630c5e299af7ce46; ?>
<?php unset($__attributesOriginalb06f0c5905a9427a630c5e299af7ce46); ?>
<?php endif; ?>
<?php if (isset($__componentOriginalb06f0c5905a9427a630c5e299af7ce46)): ?>
<?php $component = $__componentOriginalb06f0c5905a9427a630c5e299af7ce46; ?>
<?php unset($__componentOriginalb06f0c5905a9427a630c5e299af7ce46); ?>
<?php endif; ?>
                                    </div>
                                <?php else: ?>
                                    <div class="text-center px-6">
                                        <p class="text-gray-300 mb-4">Episode data is ready. Tap below to load the video stream.</p>
                                        <?php if (isset($component)) { $__componentOriginalc04b147acd0e65cc1a77f86fb0e81580 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginalc04b147acd0e65cc1a77f86fb0e81580 = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'e60dd9d2c3a62d619c9acb38f20d5aa5::button.index','data' => ['type' => 'button','wire:click' => 'loadEpisodeVideo']] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('flux::button'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['type' => 'button','wire:click' => 'loadEpisodeVideo']); ?>
                                            Load Episode Video
                                         <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginalc04b147acd0e65cc1a77f86fb0e81580)): ?>
<?php $attributes = $__attributesOriginalc04b147acd0e65cc1a77f86fb0e81580; ?>
<?php unset($__attributesOriginalc04b147acd0e65cc1a77f86fb0e81580); ?>
<?php endif; ?>
<?php if (isset($__componentOriginalc04b147acd0e65cc1a77f86fb0e81580)): ?>
<?php $component = $__componentOriginalc04b147acd0e65cc1a77f86fb0e81580; ?>
<?php unset($__componentOriginalc04b147acd0e65cc1a77f86fb0e81580); ?>
<?php endif; ?>
                                    </div>
                                <?php endif; ?><!--[if ENDBLOCK]><![endif]-->
                            </div>
                        <?php endif; ?><!--[if ENDBLOCK]><![endif]-->
                    </div>
                <?php else: ?>
                    <p style="color: #a1a1aa; text-align: center;">Episode not found.</p>
                <?php endif; ?><!--[if ENDBLOCK]><![endif]-->
            </div>
            <div class="flex-1 min-w-[180px] h-[480px] lg:h-[960px] flex flex-col w-full">
                <h3 style="color: #fff; font-size: 1.1em; margin-bottom: 4px; text-align: center; flex-shrink: 0;">Select Episode</h3>
                <div style="text-align: center; color: #a1a1aa; font-size: 0.98em; margin-bottom: 8px; user-select: none;">
                    <span style="display: inline-block; animation: bounceDown 1.2s infinite alternate; font-size: 1.5em;">&#8595;</span>
                    <span style="display: block; font-size: 0.98em;">Scroll for more episodes</span>
                </div>
                <style>
                    @keyframes bounceDown {
                        0% { transform: translateY(0); }
                        100% { transform: translateY(8px); }
                    }
                </style>
                <div style="flex: 1 1 auto; overflow-y: auto;">
                    <?php if (isset($component)) { $__componentOriginal6ccb8b540d11106d2c23d26ba15333df = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal6ccb8b540d11106d2c23d26ba15333df = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.episode-gallery','data' => ['drama' => $drama,'lang' => $currentLang]] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('episode-gallery'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['drama' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute($drama),'lang' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute($currentLang)]); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal6ccb8b540d11106d2c23d26ba15333df)): ?>
<?php $attributes = $__attributesOriginal6ccb8b540d11106d2c23d26ba15333df; ?>
<?php unset($__attributesOriginal6ccb8b540d11106d2c23d26ba15333df); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal6ccb8b540d11106d2c23d26ba15333df)): ?>
<?php $component = $__componentOriginal6ccb8b540d11106d2c23d26ba15333df; ?>
<?php unset($__componentOriginal6ccb8b540d11106d2c23d26ba15333df); ?>
<?php endif; ?>
                </div>
            </div>
        </div>

    
        <!--[if BLOCK]><![endif]--><?php if($drama): ?>
            <?php if (isset($component)) { $__componentOriginal9338e69ccd208b75531c82d0f96020d2 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal9338e69ccd208b75531c82d0f96020d2 = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.drama-info','data' => ['drama' => $drama]] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('drama-info'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes(['drama' => \Illuminate\View\Compilers\BladeCompiler::sanitizeComponentAttribute($drama)]); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal9338e69ccd208b75531c82d0f96020d2)): ?>
<?php $attributes = $__attributesOriginal9338e69ccd208b75531c82d0f96020d2; ?>
<?php unset($__attributesOriginal9338e69ccd208b75531c82d0f96020d2); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal9338e69ccd208b75531c82d0f96020d2)): ?>
<?php $component = $__componentOriginal9338e69ccd208b75531c82d0f96020d2; ?>
<?php unset($__componentOriginal9338e69ccd208b75531c82d0f96020d2); ?>
<?php endif; ?>

            <!--[if BLOCK]><![endif]--><?php if($drama['bookName']): ?>
                <?php
$__split = function ($name, $params = []) {
    return [$name, $params];
};
[$__name, $__params] = $__split('related-dramas', ['title' => $drama['bookName'],'header' => 'Related Dramas']);

$__html = app('livewire')->mount($__name, $__params, 'lw-4208540403-1', $__slots ?? [], get_defined_vars());

echo $__html;

unset($__html);
unset($__name);
unset($__params);
unset($__split);
if (isset($__slots)) unset($__slots);
?>
            <?php endif; ?><!--[if ENDBLOCK]><![endif]-->
        <?php endif; ?><!--[if ENDBLOCK]><![endif]-->
    <?php endif; ?><!--[if ENDBLOCK]><![endif]-->

    
    
    <!--[if BLOCK]><![endif]--><?php if(config('drama.magiclink_enabled') && empty($isLoggedIn) && !empty($episodesWatchedToday) && $episodesWatchedToday >= config('drama.guest_daily_limit', 10)): ?>
        <script>
        document.addEventListener('DOMContentLoaded', function() {
            // Create modal
            let modal = document.createElement('div');
            modal.style.position = 'fixed';
            modal.style.top = 0;
            modal.style.left = 0;
            modal.style.width = '100vw';
            modal.style.height = '100vh';
            modal.style.background = 'rgba(0,0,0,0.85)';
            modal.style.display = 'flex';
            modal.style.alignItems = 'center';
            modal.style.justifyContent = 'center';
            modal.style.zIndex = 9999;
            modal.innerHTML = `
                <div style="background: #18181b; color: #fff; padding: 2.5em 2em; border-radius: 12px; max-width: 95vw; text-align: center; box-shadow: 0 8px 32px #000a;">
                    <h2 style="font-size: 1.5em; margin-bottom: 0.7em;">Sign in to continue</h2>
                    <p style="margin-bottom: 1.5em;">
                        You've reached the free viewing limit for today.<br>
                        Please sign in or create an account to keep watching.<br>
                        <span style="color:#38bdf8;display:block;margin-top:0.7em;">Sign-up is quick and free!</span>
                    </p>
                    <a href='<?php echo e(route('login')); ?>' style="display: inline-block; background: #2563eb; color: #fff; padding: 0.7em 2em; border-radius: 6px; font-weight: 600; text-decoration: none; font-size: 1.1em;">Sign In / Register</a>
                </div>
            `;
            document.body.appendChild(modal);
            // Optionally, redirect after a short delay
            setTimeout(function() {
                window.location.href = '<?php echo e(route('login')); ?>';
            }, 8000);
        });
        </script>
    <?php endif; ?><!--[if ENDBLOCK]><![endif]-->
</div>
<?php /**PATH /Users/buchin/Repos/dracin-git/resources/views/livewire/episode-page.blade.php ENDPATH**/ ?>