@php
	$catDisplayType ??= 'c_bigIcon_list';
	
	$apiResult ??= [];
	$totalCategories = (int)data_get($apiResult, 'meta.total', 0);
	$areCategoriesPaginable = (!empty(data_get($apiResult, 'links.prev')) || !empty(data_get($apiResult, 'links.next')));
	
	$categories ??= [];
	$category ??= null;
	$hasChildren ??= false;
	$catId ??= 0; /* The selected category ID */
@endphp
@if (!$hasChildren)
	
	{{-- To append in the form (will replace the category field) --}}
	
	@if (!empty($category))
		@if (!empty(data_get($category, 'children')))
			
				{{ data_get($category, 'name') }}
			
		@else
			{{ data_get($category, 'name') }} 
			[  {{ t('Edit') }} ]
		@endif
	@else
		
			{{ t('select_a_category') }}
		
	@endif
	
@else
	
	{{-- To append in the modal (will replace the modal content) --}}
	@if (!empty($category))
		
			
				@if ($catDisplayType == 'c_picture_list')
					
					@foreach($categories as $key => $cat)
						@php
							$_hasChildren = (!empty(data_get($cat, 'children'))) ? 1 : 0;
							$_parentId = data_get($cat, 'parent.id', 0);
							$_hasLink = (data_get($cat, 'id') != $catId || $_hasChildren == 1);
						@endphp
						
					@endforeach
				
				@elseif ($catDisplayType == 'c_bigIcon_list')
					
					@foreach($categories as $key => $cat)
						@php
							$_hasChildren = (!empty(data_get($cat, 'children'))) ? 1 : 0;
							$_parentId = data_get($cat, 'parent.id', 0);
							$_hasLink = (data_get($cat, 'id') != $catId || $_hasChildren == 1);
						@endphp
						
					@endforeach
					
				@else
					
					@php
						$listTab = [
							'c_border_list' => 'list-border',
						];
						$catListClass = (isset($listTab[$catDisplayType])) ? 'list ' . $listTab[$catDisplayType] : 'list';
					@endphp
					
						
							
								@foreach ($categories as $key => $items)
									
										@foreach ($items as $k => $cat)
											@php
												$_hasChildren = (!empty(data_get($cat, 'children'))) ? 1 : 0;
												$_parentId = data_get($cat, 'parent.id', 0);
												$_hasLink = (data_get($cat, 'id') != $catId || $_hasChildren == 1);
											@endphp
											- 
												@if (in_array(config('settings.listings_list.show_category_icon'), [2, 6, 7, 8]))
													 
												@endif
												@if ($_hasLink)
													
												@endif
													{{ data_get($cat, 'name') }}
												@if ($_hasLink)
													
												@endif
											@endforeach
								@endforeach
							
 
					 
				
				@endif
			
			
 
		@if ($totalCategories > 0 && $areCategoriesPaginable)