@extends('breadcrumbs.auth.main')

@section('authpage')

  <div class="container">
      <div class="card login-card">
        <div class="row no-gutters">
          <div class="col-md-5">
            <img src="{{ asset(config('customization.authbanner')) }}" alt="login" class="login-card-img">
          </div>
          <div class="col-md-7">
            <div class="card-body">
              <div class="brand-wrapper">
                <img src="{{ asset(config('adminlte.logo_img_xl')) }}" alt="logo" class="logo rounded mr-2">
              </div> <!-- main content start -->

                @if(\App\Facades\Options::getOption('enable_registrations') == true || session()->has('ALLOW_REGISTRATION_OVERRIDE'))
                    <p class="login-card-description">{{__('Sign up for an account')}}</p>

                    @if(session()->has('ALLOW_REGISTRATION_OVERRIDE') && session('ALLOW_REGISTRATION_OVERRIDE') === true)
                        <div class="alert alert-info">
                            <strong><i class="fas fa-info-circle"></i> {{ __('Invite only registration') }}</strong>
                            <p>{{ __('You are signing up with an invitation. Please use the original email address you were invited with to complete your registration. Any other email address will not work.') }}</p>
                            <p>{{ __('If you close the browser or otherwise clear your cookies, this page will NOT be available again if registrations are still closed.') }}</p>
                        </div>
                    @endif

                    @if(\App\Facades\Options::getOption('pw_security_policy') !== 'off')

                        <div class="alert alert-warning alert-dismissible">
                            <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
                            <p><b>{{__('Basic password security')}}</b></p>
                            <p>{{__("For your security, we implement strict password policies. It's also advisable to let your password manager or browser generate and save passwords for you (if it's a private device).")}}</p>

                            <p>{{__('Passwords must be a combination of:')}} </p>
                            <ul>
                                @switch(\App\Facades\Options::getOption('pw_security_policy'))

                                    @case('low')
                                        <li>{{ __('A minimum of 10 characters') }}</li>
                                        @break

                                    @case('medium')
                                        <li>{{ __('A minimum of 12 characters;') }}</li>
                                        <li>{{ __('At least one special character;') }}</li>
                                        <li>{{ __('Lower case and upper case characters') }}</li>
                                        @break

                                    @case('high')
                                        <li>{{ __('A minimum of 20 characters;') }}</li>
                                        <li>{{ __('At least one special character;') }}</li>
                                        <li>{{ __('Lower case and upper case characters') }}</li>
                                        <li>{{ __('At least one numerical character') }}</li>
                                        @break

                                @endswitch
                            </ul>
                        </div>

                    @endif

                    @if($demoActive)
                        <div class="alert alert-warning">
                            <p class="font-weight-bold"><i class="fas fa-exclamation-triangle"></i>{{ __('Warning') }}</p>
                            <p>{{ __('Do not use real credentials here. The application is in demo mode. Additionally, the database is wiped every day.') }}</p>

                            <p>{{ __("Also note: If a game license is required to sign up, you may find valid MC usernames at NameMC. No special validation is performed other than contacting Mojang's authentication servers to verify the username's existence, therefore, you can use any username for testing purposes.") }}</p>
                        </div>
                    @endif

                    <form action="{{ route('register') }}" method="POST" id="registerForm">
                        @csrf
                        <div class="form-group">
                            <label for="name" class="sr-only">{{__('Name')}}</label>
                            <input type="text" name="name" id="name" class="form-control" placeholder="{{__('Name')}}">
                        </div>
                        <div class="form-group mb-4">
                            <label for="email" class="sr-only">{{__('Email address')}}</label>
                            <input type="email" name="email" id="email" class="form-control" placeholder="{{__('Email address')}}">
                        </div>
                        <div class="form-group mb-4">
                            <label for="password" class="sr-only">{{__('Password')}}</label>
                            <input type="password" name="password" id="password" class="form-control" placeholder="{{__('Password')}}">
                        </div>
                        <div class="form-group mb-2">
                            <label for="passwordc" class="sr-only">{{__('Confirm Password')}}</label>
                            <input type="password" id="passwordc" name="password_confirmation" class="form-control" placeholder="{{__('Confirm Password')}}" />
                        </div>

                        <div class="form-group mb-4 mt-5">
                            <label for="dob" class="sr-only">{{__('Date of birth')}}</label>
                            <input type="text" class="form-control" name="dob" id="dob" placeholder="Date of birth">
                            <span class="text-muted text-sm"><i class="fas fa-info-circle"></i> {!! __("<b>Why do we need this?</b> We use your age information to make sure you meet age requirements for certain positions, and to make sure that everyone is compliant with our terms of service.") !!} </span>
                        </div>

                        @if(\App\Facades\Options::getOption('requireGameLicense') && \App\Facades\Options::getOption('currentGame') == 'MINECRAFT')
                            <div class="form-group mt-5">
                                <label for="mcusername" class="sr-only">{{__('Minecraft Username (Premium)')}}</label>
                                <input type="text" name="uuid" class="form-control" id="mcusername" placeholder="{{__('Minecraft Username (Premium)')}}" />
                            </div>
                        @endif

                        <div class="form-group mt-3">
                            <label for="legal"><input type="checkbox" name="acceptTerms"> {!! __('I have read and agree with the :appName <a href=":communityGuidelinesUrlConfigValue" target="_blank">Community Guidelines</a>, <a href=":privacyPolicyUrlConfigValue" target="_blank">Privacy Policy</a> and <a href=":termsUrlConfigValue" target="_blank">Terms of Service</a>.', ['communityGuidelinesUrlConfigValue' => config('app.guidelines_url'), 'privacyPolicyUrlConfigValue' => config('app.privacy_url'), 'termsUrlConfigValue' => config('app.terms_url'), 'appName' => config('app.name')]) !!}</label>
                        </div>

                        <input name="register" id="register" class="btn btn-block login-btn mb-4" type="submit" value="{{__('Sign up')}}">
                    </form>

                    <script>
                        flatpickr('#dob', {
                            altInput: true,
                            altFormat: "F j, Y",
                            dateFormat: "Y-m-d",
                        });
                    </script>
                @else
                    <div class="alert alert-danger">
                        <b><i class="fa fa-exclamation-triangle"></i> {{ __('Sorry, but new signups are currently closed.') }}</b>
                        <p>{{ __('Due to an internal policy, new accounts cannot be created, and so you will not be able to sign up for an account. If you already have an account with us, you can still sign-in as you usually would.') }}</p>
                    </div>

                    <div class="alert alert-warning">
                        <b><i class="fas fa-question-circle"></i> {{ __('I\'m trying to sign up so I can apply for a vacancy here. What does this restriction mean for me?') }}</b>
                        <p>{{ __('Effectively, this means that you will not be able to apply for any of our vacancies unless you already have an account. However, if you\'ve received an invitation to create an account or apply for a vacancy, you still can, but you must use the sign-up invitation link sent to your email address.') }}</p>
                        <p>{!! __('Alternatively, if you don\'t have an invitation, feel free to :requestInviteLink.', ['requestInviteLink' => '<a href="#" id="toggleInviteRequestForm">' . __('request an invite') . '</a>']) !!}</p>
                    </div>

                    <div id="inviteRequestFormContainer" style="display:none;">
                        <form action="{{ route('invitations.request') }}" method="POST" id="inviteRequestForm">
                            @csrf
                            <div class="form-group">
                                <label for="inviteEmail" class="sr-only">{{ __('Email address') }}</label>
                                <input type="email" name="email" id="inviteEmail" class="form-control" placeholder="{{ __('Enter your email address') }}" required>
                            </div>
                            <input type="submit" class="btn btn-primary btn-block" value="{{ __('Request Invite') }}">
                        </form>
                    </div>
                    <script>
                        document.addEventListener('DOMContentLoaded', function() {
                            var toggleLink = document.getElementById('toggleInviteRequestForm');
                            var formContainer = document.getElementById('inviteRequestFormContainer');
                            toggleLink.addEventListener('click', function(e) {
                                e.preventDefault();
                                formContainer.style.display = (formContainer.style.display === 'none') ? 'block' : 'none';
                            });
                        });
                    </script>

                @endif

                <p class="login-card-footer-text">{{__('Have an account with us?')}} <a href="{{ route('login') }}" class="text-reset">{{__('Sign in here')}}</a></p>
                <nav class="login-card-footer-nav">
                  <a href="{{ config('app.terms_url') }}">{{__('Terms of Service')}}</a>
                  <a href="{{ config('app.privacy_url') }}">{{__('Privacy Policy')}}</a>
                    <a href="{{ config('app.guidelines_url') }}">{{__('Community Guidelines')}}</a>
                </nav>
            </div>
          </div>
        </div>
      </div>
    </div>

@stop
