<div class="flex flex-col relative w-full max-w-6xl">

    <div class="md:grid md:grid-cols-3 print:grid">

        <div class="col-start-2 col-span-2 row-start-1 flex justify-center">

            <div class="w-full">

                <div class="text-block px-8 pb-8">

                    <?php if($content->header): ?>
                        <h<?php echo e($header ? '1' : '2'); ?>><?php echo e($content->header); ?></h<?php echo e($header ? '1': '2'); ?>>
                    <?php endif; ?>

                    <?php if($content->body): ?>
                        <div class="content-text body">
                            <?php echo $content->body; ?>

                        </div>
                    <?php endif; ?>
                </div>

                <?php if($content->layout !== 'inline' && $content->title): ?>

                    <div class="relative text-block mt-4">

                        <div class="absolute right-0 -mr-4 h-10 w-10 flex items-center justify-center">
                            <div class="opacity-50 text-xl"><fa-icon icon="fas fa-user-tie"></fa-icon></div>
                        </div>
                        <div class="border-b border-color pb-1 items-baseline mb-1">
                            <h2><?php echo e($content->title); ?></h2>
                        </div>

                    </div>

                <?php endif; ?>

                <?php if($content->layout === 'list'): ?>
                    <div class="relative text-block mt-4 pl-2 md:pl-0" dusk="staff-profile-layout-list">
                        <?php
                            // Identify the manager
                            $manager = $content->staff_profiles->firstWhere('departments', 'Head of Information Technology and Innovations');
                            
                            // Filter out the manager from the list
                            $staffProfilesWithoutManager = $content->staff_profiles->reject(function ($profile) { 
				                return $profile->departments === 'Head of Information Technology and Innovations';
                            });

                            // Sort the rest of the staff profiles
                            $sortedProfiles = $staffProfilesWithoutManager->sortBy('name', SORT_NATURAL | SORT_FLAG_CASE);

                            // Combine the manager and the sorted profiles
                            $finalProfiles = collect();

                            if ($manager) {
                                $finalProfiles->push($manager);
                            }
                            
                            $finalProfiles = $finalProfiles->merge($sortedProfiles);
                        ?>

                        <?php $__currentLoopData = $finalProfiles; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $sp): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <?php if($sp->bio): ?>
                                <a class="flex items-center relative my-4 rounded-r text-color bg-highlight" 
                                    href="<?php echo e($page->full_slug); ?>#<?php echo e($sp->anchor); ?>"
                                    dusk="staff-profile-link-<?php echo e($sp->id); ?>"
                                >
                            <?php else: ?>
                                <div class="flex items-center relative rounded-r bg-highlight my-4" dusk="staff-profile-link-<?php echo e($sp->id); ?>">
                            <?php endif; ?>

                                <div class="">
                                    <div class="relative w-20 pb-[133%] overflow-hidden rounded-l staff-profile-list-photo">
                                        <?php if($sp->photos->count()): ?>
                                            <photo-container :photo='<?php echo json_encode($sp->photos->first(), 15, 512) ?>' :max-size="200" :no-enlarge="true"></photo-container>
                                        <?php else: ?> 
                                            <div class="w-full h-full flex items-center justify-center absolute">
                                                <img class="absolute h-24" src="/images/icon_white.svg" alt="Brentwood Icon" />
                                            </div>
                                        <?php endif; ?>
                                    </div>
                                </div>
                                <div class="ml-4">
                                    <h3 class="mt-0 link"><?php echo e($sp->full_name); ?></h3>
                                    <div class=""><?php echo e($sp->departments); ?></div>
                                    <?php if($sp->credentials): ?>
                                        <div class="italic flex">
                                            <div class="text-gray-400 pr-1"><fa-icon icon="fas fa-graduation-cap"></fa-icon></div>
                                            <div class=""><?php echo e($sp->credentials); ?></div>
                                        </div>
                                    <?php endif; ?>
                                </div>
                            <?php if($sp->bio): ?>
                                </a>
                            <?php else: ?>
                                </div>
                            <?php endif; ?>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </div>
                <?php endif; ?>

                <?php if($content->layout === 'grid'): ?>

                    <div class="grid grid-cols-2 md:grid-cols-3 w-full mt-4 gap-2 md:gap-4 text-block pl-4 md:pl-0" dusk="staff-profile-layout-grid">

                        <?php $__currentLoopData = $content->staff_profiles; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $sp): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <div class="<?php echo e($sp->bio ? 'link' : ''); ?> md:text-center md:flex items-center justify-center border-b rounded-t staff-profile-list-grid-link" 
                                    dusk="staff-profile-link-<?php echo e($sp->id); ?>"
                                >
                                    <?php if($sp->bio): ?>
                                        <a class="w-full h-full py-1 block" href="<?php echo e($page->full_slug); ?>#<?php echo e($sp->anchor); ?>"><?php echo e($sp->full_name); ?></a>
                                    <?php else: ?>
                                        <?php echo e($sp->full_name); ?>

                                    <?php endif; ?>
                                </div>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

                    </div>

                <?php endif; ?>


                <?php if($content->layout === 'thumbnails'): ?>
                    <div class="relative text-block mt-4" dusk="staff-profile-layout-thumbnails">

                        <div class="grid grid-cols-2 md:grid-cols-3 gap-2">
                            <?php $__currentLoopData = $content->staff_profiles; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $sp): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <div class="relative w-full" dusk="staff-profile-link-<?php echo e($sp->id); ?>">

                                    <?php if($sp->bio): ?>
                                        <a class="" href="<?php echo e($page->full_slug); ?>#<?php echo e($sp->anchor); ?>">
                                    <?php endif; ?>

                                        <div class="relative w-full pb-[133%] overflow-hidden rounded staff-profile-list-photo">
                                            <?php if($sp->photos->count()): ?>
                                                <photo-container :photo='<?php echo json_encode($sp->photos->first(), 15, 512) ?>' :max-size="200" :no-enlarge="true"></photo-container>
                                            <?php else: ?> 
                                                <div class="w-full h-full flex items-center justify-center absolute">
                                                    <img class="absolute h-24" src="/images/icon_white.svg" alt="Brentwood Icon" />
                                                </div>
                                            <?php endif; ?>
                                        </div>
                                        <div class="text-white text-shadow leading-none absolute bottom-0 z-3 w-full bg-black bg-opacity-30 px-2 pt-1 pb-px">
                                            <span class="font-semibold"><?php echo e($sp->full_name); ?></span><br/>
                                            <span class="text-sm"><?php echo e($sp->departments); ?></span>
                                        </div>

                                    <?php if($sp->bio): ?>
                                        </a>
                                    <?php endif; ?>

                                </div>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </div>

                    </div>
                <?php endif; ?>

            </div>

        </div>

        <div class="col-start-1 row-start-1">
            <?php if($content->layout === 'inline'): ?>
                <?php echo $__env->make('staff-profiles.inline', ['staff_profiles' => $content->staff_profiles, 'title' => $content->title], \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
            <?php endif; ?>
        </div>

    </div>

    <?php $__currentLoopData = $content->staff_profiles; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $staff_profile): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
        <expander uuid="staff-profile-<?php echo e($staff_profile->id); ?>" :filter="false" :preview="<?php echo e(request('preview') ? 'true' : 'false'); ?>" :modal="true" max-width="max-w-prose" anchor="<?php echo e($staff_profile->anchor); ?>" >
            <staff-profile :staff-profile='<?php echo json_encode($staff_profile, 15, 512) ?>'></staff-profile>
        </expander>
    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

</div>
<?php /**PATH /var/www/html/resources/views/content-elements/staff-profile-list.blade.php ENDPATH**/ ?>