1<script lang="ts" module>
 2	import { tv, type VariantProps } from 'tailwind-variants';
 3	export const sheetVariants = tv({
 4		base: 'bg-background data-[state=open]:animate-in data-[state=closed]:animate-out fixed z-50 flex flex-col gap-4 shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500',
 5		variants: {
 6			side: {
 7				top: 'data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top inset-x-0 top-0 h-auto border-b',
 8				bottom:
 9					'data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom inset-x-0 bottom-0 h-auto border-t',
10				left: 'data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left inset-y-0 left-0 h-full w-3/4 border-r sm:max-w-sm',
11				right:
12					'data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right inset-y-0 right-0 h-full w-3/4 border-l sm:max-w-sm'
13			}
14		},
15		defaultVariants: {
16			side: 'right'
17		}
18	});
19
20	export type Side = VariantProps<typeof sheetVariants>['side'];
21</script>
22
23<script lang="ts">
24	import { Dialog as SheetPrimitive } from 'bits-ui';
25	import XIcon from '@lucide/svelte/icons/x';
26	import type { Snippet } from 'svelte';
27	import SheetOverlay from './sheet-overlay.svelte';
28	import { cn, type WithoutChildrenOrChild } from '$lib/components/ui/utils.js';
29
30	let {
31		ref = $bindable(null),
32		class: className,
33		side = 'right',
34		portalProps,
35		children,
36		...restProps
37	}: WithoutChildrenOrChild<SheetPrimitive.ContentProps> & {
38		portalProps?: SheetPrimitive.PortalProps;
39		side?: Side;
40		children: Snippet;
41	} = $props();
42</script>
43
44<SheetPrimitive.Portal {...portalProps}>
45	<SheetOverlay />
46	<SheetPrimitive.Content
47		bind:ref
48		data-slot="sheet-content"
49		class={cn(sheetVariants({ side }), className)}
50		{...restProps}
51	>
52		{@render children?.()}
53		<SheetPrimitive.Close
54			class="absolute top-4 right-4 rounded-xs opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:outline-hidden disabled:pointer-events-none"
55		>
56			<XIcon class="size-4" />
57			<span class="sr-only">Close</span>
58		</SheetPrimitive.Close>
59	</SheetPrimitive.Content>
60</SheetPrimitive.Portal>