@php
    $categories = HelpDesk::elementCategoriesByArgs($args);
@endphp

<section class="default-el">
    <div class="container">
        @if (isset($args['title']) || isset($args['view_all']) || isset($args['page_id']))
        <div class="section-head">
            <div class="content">
                <p class="sub-title">{{ isset($args['subtitle']) ? $args['subtitle'] : '' }}</p>
                <h2 class="title">{{ isset($args['title']) ? $args['title'] : '' }}</h2>
                <p class="description">{{ isset($args['description']) ? $args['description'] : '' }}</p>
            </div>

            <div>
                @if (isset($args['view_all']) && $args['view_all'] == 'true')

                <a 
                    href="{{ isset($args['page_id']) ? DzHelper::laraPageLink($args['page_id']) : 'javascript:void(0);' }}"
                    class="btn btn-outline light style-1 ms-auto p-2 group button--stroke flairBtn magneticBtn" 
                    data-block="button"
                >
                    <span class="button-flair"></span>
                    <span class="button__label font-normal xl:ps-25 px-10 inline-flex items-center gap-14">{{ __('View All') }}</span>
                    <span class="inline-flex justify-center items-center size-32 rounded-full dark:bg-primary dark:text-secondary bg-secondary text-white duration-100 dark:group-hover:bg-secondary dark:group-hover:text-white group-hover:bg-white group-hover:text-secondary z-1">
                        <i class="fa-solid fa-arrow-right text-sm"></i>
                    </span>
                </a>
                @endif
            </div>
        </div>
        @endif
        <div class="row m-b10">
            @forelse($categories as $category)
            <div class="lg:w-3/12 md:w-4/12 sm:w-1/2 w-full mb-30">
                <div class="category-box swiper-category-box">
                    <div class="category-media">    
                        @if(optional($category)->image && Storage::exists('public/category-images/'.$category->image))
                            <img src="{{ asset('storage/category-images/'.$category->image) }}" alt="">
                        @else
                            <img src="{{ asset('images/noimage.jpg') }}" alt="">
                        @endif
                    </div>
                    <div class="category-info">
                        <a href="{{ DzHelper::laraBlogCategoryLink($category->id) }}" class="category-title">{{  $category->title  }}</a>
                    </div>
                </div>
            </div>
            @empty
            @endforelse
        </div>
        @if (isset($args['pagination']) && ($args['pagination'] == true))
        <div class="col-lg-12">
            {!! $categories->links('elements.pagination') !!}
        </div>
        @endif
    </div>
</section>