<script module lang="ts">
	import { defineMeta } from "@storybook/addon-svelte-csf";
	import MockAuthProvider from "$lib/components/testing/MockAuthProvider.svelte";
	import TimelineRepoEvent from "./TimelineRepoEvent.svelte";
	import type { RepoEvent } from "$lib/api/lexicons/types/sh/tangled/feed/getTimeline";

	const owner = { did: "did:plc:3p7ejjxnufohsygt5vbyxb2i", handle: "tangled.org" };

	const repo = {
		did: "did:plc:3p7ejjxnufohsygt5vbyxb2i",
		slug: "core",
		owner,
		createdAt: "2025-06-01T10:30:00Z",
		description: "The knot server, appview, and everything that makes tangled tick.",
		starCount: 42
	};

	const created = {
		$type: "sh.tangled.feed.getTimeline#repoEvent",
		cid: "bafyreib2",
		uri: "at://did:plc:3p7ejjxnufohsygt5vbyxb2i/sh.tangled.repo/core",
		repo
	} as unknown as RepoEvent;

	const forked = {
		...created,
		repo: { ...repo, slug: "core-fork" },
		source: repo
	} as unknown as RepoEvent;

	const { Story } = defineMeta({
		title: "Timeline/TimelineRepoEvent",
		component: TimelineRepoEvent,
		tags: ["autodocs"],
		args: {
			event: created,
			eventAt: "2025-06-02T09:00:00Z"
		}
	});
</script>

<Story name="Created">
	{#snippet template(args)}
		<MockAuthProvider>
			<TimelineRepoEvent {...args} />
		</MockAuthProvider>
	{/snippet}
</Story>

<Story name="Forked">
	{#snippet template(args)}
		<MockAuthProvider>
			<TimelineRepoEvent {...args} event={forked} />
		</MockAuthProvider>
	{/snippet}
</Story>
