<script setup>
const emits = defineEmits(["submit"]);
defineProps({
  password_contains_uppercase: { type: String, required: true, default: "0" },
  password_contains_lowercase: { type: String, required: true, default: "0" },
  password_contains_numeric: { type: String, required: true, default: "0" },
  password_contains_symbol: { type: String, required: true, default: "0" },
  password_min_length: { type: String, required: true, default: "8" },
  two_factor_authentication: { type: String, required: true, default: "0" },
  auth_lockout_duration: { type: String, required: true, default: "15" },
  auth_lockout_attempts: { type: String, required: true, default: "5" },
  access_token_expire: { type: String, required: true, default: "900" },
  refresh_token_expire: { type: String, required: false, default: "604800" },
  password_expiration: { type: String, required: true, default: "0" },
  password_expiration_duration: { type: String, required: true, default: "90" },
  concurrent_login_disabled: { type: String, required: true, default: "0" },
  webauthn_enabled: { type: String, required: false, default: "1" },
  skip_route_guard_check: { type: String, required: false, default: "0" }
});
</script>

<template>
    <FormKit type="l-form" :bordered="false" :value="$props" @submit="$emit('submit', $event)">

        <form-kit type="l-checkbox" name="webauthn_enabled" true-value="1" false-value="0"
            label="WebAuthn (Passwordless) Authentication Enabled" class="col-12"/>

        <form-kit type="l-checkbox" name="skip_route_guard_check" true-value="1" false-value="0"
            label="Skip UI route guard permission check"
            hint="When enabled, the frontend will not check page permissions before navigation. Backend permissions are still enforced."
            class="col-12" />

        <l-field label="Password policy" stack-label>
            <FormKit type="l-checkbox" label="Upper Case" name="password_contains_uppercase" true-value="1"
                false-value="0" />
            <FormKit type="l-checkbox" label="Lower Case" name="password_contains_lowercase" true-value="1"
                false-value="0" />
            <FormKit type="l-checkbox" label="Number" name="password_contains_numeric" true-value="1" false-value="0" />
            <FormKit type="l-checkbox" label="Special Character" name="password_contains_symbol" true-value="1"
                false-value="0" />
        </l-field>

        <FormKit type="l-input" label="Password min Length" name="password_min_length" validation="required|number">
        </FormKit>

        <FormKit type="l-checkbox" name="two_factor_authentication" true-value="1" false-value="0"
            label="Two factor authentication" />

        <FormKit label="Auth lockout duration" type="l-input" name="auth_lockout_duration"
            hint="The number of minutes the user is locked out after the maximum number of failed login attempts. Default is 15 minutes."
            validation="required" />

        <FormKit label="Auth lockout attempts" type="l-input" name="auth_lockout_attempts"
            hint="The number of failed login attempts before the user is locked out. Default is 5 attempts."
            validation="required" />

        <FormKit label="Access token expiration" type="l-input" name="access_token_expire"
            hint="The access token expiration time in seconds. Default is 900 seconds (15 minutes)."
            validation="required" />
        <FormKit label="Refresh token expiration" type="l-input" name="refresh_token_expire"
            hint="The refresh token expiration time in seconds. Default is 604800 seconds (7 days)." validation="required" />

        <form-kit label="Password expiration" true-value="1" false-value="0" name="password_expiration"
            type="l-checkbox"></form-kit>
        <form-kit label="Password expiration duration" name="password_expiration_duration" type="l-input"
            hint="The number of days before the password expires. Default is 90 days." validation="required"></form-kit>

        <form-kit label="Concurrent login disabled" type="l-checkbox" name="concurrent_login_disabled" true-value="1"
            false-value="0"></form-kit>

    </FormKit>
</template>
