@if(!\Auth::check())
    @if($page_header)
        @if($page_header->html_code)
            <div class="community-info-page">
                <div class="additional-page-container">
                    <link rel="stylesheet" href="{{\URL::to('/')}}/themes/frontend/default/css/htmleditor/bulma.min.css">
                    <link rel="stylesheet" href="{{\URL::to('/')}}/themes/frontend/default/css/htmleditor/style.css">
                    <link rel="stylesheet" href="{{\URL::to('/')}}/themes/frontend/default/css/htmleditor/fontawesome-all.min.css">
                    
                    <div class="cmpage-description page-htmleditor">
                       <?php
							$contents=$page_header->html_code;
						?>   
						<?php
							$contents = communityTranslate(0,'websitepage-data-'.$page_header->id,$contents);
							$contents = replaceCommunityHeaderTokens($contents, $community ?? null, $homecontents ?? null, $pages ?? null);
						?>
						{!! $contents !!}	
                     </div>    	
                </div>	
            </div>
        @endif 
        
        @if($page_header->show_default_header==0)
             <style type="text/css">
                #top{
                    display:none !important;
                }
                body{
                    padding-top: 0px;
                }
             </style>	
        @endif   
        
        <style type="text/css">		            
            *, body, h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 {
              font-family: 'Source Sans Pro', sans-serif;
            }
        </style>
    @endif
@endif

@php
	$rows = $businesses ?? [];
	if ($rows && method_exists($rows, 'items')) {
		$rows = $rows->items();
	}
	$defaultHero = Theme::asset()->img('theme/images/page/display.jpg');
@endphp

<div class="container page-content clearfix">
	<div class="box chamber-business-directory-box">
		<div class="box-content">
			@if(empty($rows) || count($rows) === 0)
				<div class="alert alert-info">No businesses found.</div>
			@else
				<div style="margin-bottom:2px; margin-top:5px; font-size:18px; font-weight:normal;">Business Directory</div>
				<div class="row" style="margin:0;">
					@foreach($rows as $biz)
						@php
							$hero = '';
							if (!empty($biz->hero_photo)) {
								$hero = Image::url($biz->hero_photo);
							} elseif (!empty($biz->business_logo_rectangle)) {
								$hero = Image::url($biz->business_logo_rectangle);
							} elseif (!empty($biz->business_logo_square)) {
								$hero = Image::url($biz->business_logo_square);
							} else {
								$hero = $defaultHero;
							}

							$title = (string) ($biz->organization_name ?? '');
							$address = (string) ($biz->organization_address ?? '');
							$website = (string) ($biz->website ?? '');
							$websiteHref = '';
							if ($website !== '') {
								$websiteHref = (preg_match('/^https?:\/\//i', $website) ? $website : ('http://' . $website));
							}
						@endphp

						<div class="col-sm-4" style="padding-left:0px; margin:0px;">
							<div class="featured-business-box">
								<div class="featured-business-box-banner">
									<div class="carousel-inner">
										<div class="item active">
                                        	<a href="{{$community->present()->url('biz')}}/{{$biz->slug}}" target="_blank">
												<img src="{{ $hero }}" alt="">
                                            </a>    
										</div>
									</div>
									<span class="business-location">{!! nl2br(e($address)) !!}</span>
								</div>
								<div class="featured-title">
									@if($websiteHref !== '')
										<a href="{{ $websiteHref }}" target="_blank" rel="noopener">
											@if(strlen($title) > 35)
												{{ \Illuminate\Support\Str::limit(ucfirst($title), 35) }}
											@else
												{{ ucfirst($title) }}
											@endif
										</a>
									@else
										@if(strlen($title) > 35)
											{{ \Illuminate\Support\Str::limit(ucfirst($title), 35) }}
										@else
											{{ ucfirst($title) }}
										@endif
									@endif
								</div>
							</div>
						</div>
					@endforeach
				</div>
			@endif
		</div>
	</div>

	@if(isset($businesses) && $businesses && method_exists($businesses, 'render'))
		{!! $businesses->render() !!}
	@endif
</div>
