<script lang="ts">
import BoatIcon from 'phosphor-svelte/lib/BoatIcon';
import BugIcon from 'phosphor-svelte/lib/BugIcon';
import ChatCircleIcon from 'phosphor-svelte/lib/ChatCircleIcon';
import EnvelopeSimpleOpenIcon from 'phosphor-svelte/lib/EnvelopeSimpleOpenIcon';
import FolderSimpleIcon from 'phosphor-svelte/lib/FolderSimpleIcon';
import TrashIcon from 'phosphor-svelte/lib/TrashIcon';
import * as z from 'zod';
import { page } from '$app/state';
import Field from '#lib/components/site/Field.svelte';
import Footer from '#lib/components/site/Footer.svelte';
import Navbar from '#lib/components/site/Navbar.svelte';
import { Button } from '#lib/components/ui/button/index.js';
import { Input } from '#lib/components/ui/input/index.js';
import { Textarea } from '#lib/components/ui/textarea/index.js';
import { earlyAccessMessage } from '#lib/caissons.js';
import { email as emailRule, firstErrors } from '#lib/forms.js';
const schema = z.object({
name: z.string().trim().min(1, 'Enter your name').max(100, 'Use 100 characters or fewer'),
email: emailRule,
company: z.string().trim().max(100, 'Use 100 characters or fewer'),
message: z.string().trim().min(10, 'Tell us a little more, at least 10 characters').max(5000, 'Use 5,000 characters or fewer')
});
let values = $state({ name: '', email: '', company: '', message: page.url.searchParams.get('message')?.slice(0, 5000) ?? '' });
const topics = [
{ id: 'caissons', label: 'Early access to caissons', icon: FolderSimpleIcon, starter: earlyAccessMessage, tip: 'How many agents you run, and on which repositories.' },
{ id: 'move', label: 'Move an organization', icon: BoatIcon, starter: 'We want to move our organization to Sailfork. ', tip: 'Where you are moving from and roughly how many repositories.' },
{ id: 'bug', label: 'Report a bug', icon: BugIcon, starter: 'I found a bug. I was trying to ', tip: 'What you tried and what happened, with the repository and the command if it is about git.' },
{ id: 'delete', label: 'Delete my account', icon: TrashIcon, starter: 'Please delete my Sailfork account and its data. ', tip: 'Write from the email on your account, so we can tell it is you.' },
{ id: 'other', label: 'Something else', icon: ChatCircleIcon, starter: '', tip: 'Anything else, from questions to ideas.' }
] as const;
type TopicId = (typeof topics)[number]['id'];
// A message that is still only a starter (or empty) can be swapped; anything the person typed stays.
const untouched = (message: string) => message.trim() === '' || topics.some((t) => t.starter !== '' && message === t.starter);
let topic = $state<TopicId | undefined>(topics.find((t) => t.starter !== '' && values.message.startsWith(t.starter.trim()))?.id);
const pick = (id: TopicId) => {
topic = id;
const t = topics.find((x) => x.id === id);
if (t && untouched(values.message)) values.message = t.starter;
};
const tip = $derived(topics.find((t) => t.id === topic)?.tip);
let errors = $state<Record<string, string>>({});
let pending = $state(false);
let sent = $state<{ name: string; email: string }>();
const submit = (event: SubmitEvent) => {
event.preventDefault();
const parsed = schema.safeParse(values);
errors = parsed.success ? {} : firstErrors(parsed.error);
if (!parsed.success) return;
pending = true;
// UI only: nothing is sent; the pause stands in for the request.
setTimeout(() => {
sent = { name: parsed.data.name, email: parsed.data.email };
pending = false;
}, 900);
};
</script>
<svelte:head>
<title>Contact Sailfork</title>
<meta name="description" content="Questions, bug reports or account requests for Sailfork." />
</svelte:head>
<Navbar />
<main class="border-t border-border py-16 sm:py-20">
<div class="mx-auto grid max-w-7xl gap-12 px-4 sm:px-6 lg:grid-cols-12 lg:px-8">
<div class="lg:col-span-4">
<h1 class="type-title">Talk to us</h1>
<p class="type-body mt-3 max-w-[38ch] text-muted-foreground">
Questions, bug reports, a large repository you want to move, or a request to delete your account. Fenil, who
runs Sailfork, reads every message.
</p>
<p class="type-small mt-6 flex items-center gap-2 text-muted-foreground">
<EnvelopeSimpleOpenIcon aria-hidden="true" class="size-4 text-primary" />Replies within one business day.
</p>
</div>
<div class="lg:col-span-6 lg:col-start-6">
{#if sent}
<div role="status">
<div class="grid grid-cols-[2.5rem_minmax(0,1fr)] gap-x-3 border-y border-border py-4">
<EnvelopeSimpleOpenIcon aria-hidden="true" class="mt-0.5 size-5 text-primary" />
<div class="min-w-0">
<p class="type-heading">Message sent</p>
<p class="type-body mt-1 text-muted-foreground">
Thanks, {sent.name}. We’ll reply to {sent.email} within one business day.
</p>
</div>
</div>
<Button href="/" variant="outline" class="mt-6">Back to home</Button>
</div>
{:else}
<form novalidate class="grid gap-6" onsubmit={submit}>
<fieldset>
<legend class="type-ui">What is it about?</legend>
<div class="mt-3 flex flex-wrap gap-2">
{#each topics as t (t.id)}
<label
class={[
'type-small inline-flex h-9 cursor-pointer items-center gap-2 rounded-md border px-3 transition-colors has-focus-visible:ring-3 has-focus-visible:ring-ring/50',
topic === t.id ? 'border-primary bg-primary text-primary-foreground' : 'border-input text-muted-foreground hover:bg-muted hover:text-foreground'
]}
>
<input type="radio" class="sr-only" name="topic" value={t.id} checked={topic === t.id} onchange={() => pick(t.id)} />
<t.icon class="size-4" aria-hidden="true" />{t.label}
</label>
{/each}
</div>
</fieldset>
<div class="grid gap-6 sm:grid-cols-2">
<Field id="name" label="Name" error={errors.name}>
{#snippet children({ describedBy })}
<Input
id="name"
name="name"
autocomplete="name"
required
bind:value={values.name}
aria-invalid={errors.name ? true : undefined}
aria-describedby={describedBy}
/>
{/snippet}
</Field>
<Field id="email" label="Work email" error={errors.email}>
{#snippet children({ describedBy })}
<Input
id="email"
name="email"
type="email"
autocomplete="email"
required
bind:value={values.email}
aria-invalid={errors.email ? true : undefined}
aria-describedby={describedBy}
/>
{/snippet}
</Field>
</div>
<Field id="company" label="Company" hint="Optional" error={errors.company}>
{#snippet children({ describedBy })}
<Input
id="company"
name="company"
autocomplete="organization"
bind:value={values.company}
aria-invalid={errors.company ? true : undefined}
aria-describedby={describedBy}
/>
{/snippet}
</Field>
<Field id="message" label="How can we help?" hint={tip ? `Good to include: ${tip}` : undefined} error={errors.message}>
{#snippet children({ describedBy })}
<Textarea
id="message"
name="message"
rows={6}
required
bind:value={values.message}
aria-invalid={errors.message ? true : undefined}
aria-describedby={describedBy}
/>
{/snippet}
</Field>
<div>
<Button type="submit" size="lg" class="px-4" disabled={pending}>
{pending ? 'Sending…' : 'Send message'}
</Button>
</div>
</form>
{/if}
</div>
</div>
</main>
<Footer />