import { Button, Input, StrongPassword } from "@wrnexus/ui"

component InvitationAccept {
  props {
    action = "/api/auth/invitations/accept"
    schema = "auth-invitation"
    token = ""
    redirect = "/account"
    organization = "your workspace"
    inviter = "A workspace administrator"
    title = "Accept your invitation"
    description = "Create your password to join the workspace."
    submitLabel = "Accept invitation"
    successMessage = "Invitation accepted."
    color = "primary"
    size = "md"
    class = ""
  }
  view {
    <section {...attrs} data-wrnexus-runtime="auth" class='w-full max-w-md rounded-[var(--wrn-radius-lg)] border border-[var(--wrn-color-border)] bg-[var(--wrn-color-surface)] p-6 text-[var(--wrn-color-text)] shadow-[var(--wrn-shadow-2)] {class}'>
      <span class="flex size-11 items-center justify-center rounded-full bg-[color-mix(in_srgb,var(--wrn-color-primary)_12%,transparent)] text-[var(--wrn-color-primary)]"><span class="icon-[lucide--user-round-plus] size-5"></span></span>
      <h1 class="mb-0 mt-4 text-2xl font-semibold">{title}</h1>
      <p class="mb-0 mt-2 text-sm text-[var(--wrn-color-muted)]">{description}</p>
      <div class="mt-5 rounded-[var(--wrn-radius-sm)] border border-[var(--wrn-color-border)] bg-[var(--wrn-color-surface-2)] p-4 text-sm"><p class="m-0 font-semibold">{organization}</p><p class="mb-0 mt-1 text-[var(--wrn-color-muted)]">Invited by {inviter}</p></div>
      <form method="post" action='{action}' data-schema='{schema}' data-redirect='{redirect}' novalidate class="mt-5 space-y-4">
        <input type="hidden" name="token" value='{token}' />
        <Input id="auth-invitation-name" name="displayName" label="Display name" autocomplete="name" placeholder="Enter your display name" icon="icon-[lucide--user]" color="{color}" size="{size}" />
        <StrongPassword label="Create password" name="password" autocomplete="new-password" minLength="12" requireLowercase="true" requireUppercase="true" requireNumber="true" requireSpecialCharacter="true" color="{color}" size="{size}" />
        <p data-error="token" class="m-0 min-h-4 text-xs text-[var(--wrn-color-danger)]"></p>
        <p data-error="_form" role="alert" class="m-0 hidden rounded-[var(--wrn-radius-sm)] bg-[color-mix(in_srgb,var(--wrn-color-danger)_10%,transparent)] p-3 text-sm text-[var(--wrn-color-danger)]"></p>
        <p data-success='{successMessage}' role="status" hidden class="m-0 rounded-[var(--wrn-radius-sm)] bg-[color-mix(in_srgb,var(--wrn-color-success)_10%,transparent)] p-3 text-sm text-[var(--wrn-color-success)]">{successMessage}</p>
        <Button type="submit" label="{submitLabel}" variant="solid" color="{color}" size="{size}" fullWidth="true" />
      </form>
    </section>
  }
}
