{% extends "/layouts/main.twig" %}
{% set active_menu = '/admin/settings' %}

{% set xdata = 'settings' %}
{% block title p__('title', 'API configuration')|title %}

{% block template %}
	<div>
		{% include "snippets/back.twig" with {link: 'admin/settings/features', label: 'Features'} %}

		<h1 class="mt-4">{{ p__('heading', 'API configuration') }}</h1>
	</div>

	<x-form>
		<form class="flex flex-col gap-8" @submit.prevent="submit" x-ref="form">
			<div class="flex flex-col gap-2">
				<section class="flex flex-col gap-6 box" data-density="comfortable">
					<h2 class="col-span-2">{{ p__('heading', 'Configuration') }}</h2>

					<div class="flex items-center justify-between p-3 rounded-lg bg-intermediate">
						{{ p__('label', 'Admin API') }}

						<label class="inline-flex items-center gap-2 cursor-pointer">
							<input type="checkbox" name="features[admin_api][is_enabled]" class="hidden peer" {{ option.features.admin_api.is_enabled is defined and option.features.admin_api.is_enabled ? 'checked' : '' }}>

							<span class="h-6 w-10 rounded-3xl bg-line relative block peer-checked:bg-success transition-all after:h-5 after:w-5 after:top-0.5 after:absolute after:left-0 after:ms-0.5 after:transition-all after:rounded-full after:bg-white peer-checked:after:left-4"></span>

							<span class="text-content-dimmed peer-checked:hidden">
								{{ p__('input-value', 'Disabled') }}
							</span>

							<span class="hidden text-success peer-checked:inline">
								{{ p__('input-value', 'Enabled') }}
							</span>
						</label>
					</div>

					<div class="flex items-center justify-between p-3 rounded-lg bg-intermediate">
						{{ p__('label', 'User API') }}

						<label class="inline-flex items-center gap-2 cursor-pointer">
							<input type="checkbox" name="features[api][is_enabled]" class="hidden peer" {{ option.features.api.is_enabled is defined and option.features.api.is_enabled ? 'checked' : '' }}>

							<span class="h-6 w-10 rounded-3xl bg-line relative block peer-checked:bg-success transition-all after:h-5 after:w-5 after:top-0.5 after:absolute after:left-0 after:ms-0.5 after:transition-all after:rounded-full after:bg-white peer-checked:after:left-4"></span>

							<span class="text-content-dimmed peer-checked:hidden">
								{{ p__('input-value', 'Disabled') }}
							</span>

							<span class="hidden text-success peer-checked:inline">
								{{ p__('input-value', 'Enabled') }}
							</span>
						</label>
					</div>
				</section>
			</div>

			<div class="flex justify-end gap-4">
				<a href="admin/settings" class="button button-outline">
					{{ p__('button', 'Cancel') }}
				</a>

				<button class="button button-accent" type="submit" :processing="isProcessing">
					{% include "/snippets/spinner.twig" %}

					{{ p__('button', 'Save changes') }}
				</button>
			</div>
		</form>
	</x-form>
{% endblock %}
