<script lang="ts">
	import { goto } from "$app/navigation";
	import { resolve } from "$app/paths";
	import Button from "$lib/components/ui/Button.svelte";
	import Input from "$lib/components/ui/Input.svelte";
	import DrillDown from "$lib/components/settings/DrillDown.svelte";
	import SettingsList from "$lib/components/settings/SettingsList.svelte";
	import FormRow from "$lib/components/settings/FormRow.svelte";
	import FormActions from "$lib/components/settings/FormActions.svelte";
	import Plus from "$icon/plus";
	import X from "$icon/x";

	let address = $state("");
	const valid = $derived(address.trim().length > 0);

	// mocked — knot registration is not wired up yet
	const submit = () => goto(resolve("/settings/knots"));
</script>

<DrillDown
	backLabel="Knots"
	backHref="/settings/knots"
	title="Register a knot"
	description="Enter the hostname of your knot to get started."
>
	<SettingsList padding="tight">
		<FormRow label="Knot address" for="knot-address">
			<Input id="knot-address" bind:value={address} placeholder="knot.example.com" />
		</FormRow>
	</SettingsList>

	<FormActions>
		<Button href="/settings/knots" icon={X}>Cancel</Button>
		<Button variant="primary" icon={Plus} disabled={!valid} onclick={submit}>Add</Button>
	</FormActions>
</DrillDown>
