<script lang="ts">
import { DrawerId, openDrawer } from '@/modules/drawers'
import { widgetOptions } from '@/modules/options'
import { getHostWindow } from '@/utils/window'

export let label: string
export let isTicketForm: boolean | undefined = undefined

const handlePrivacyNoticeClick = () => {
	const { privacyNoticeUrl } = widgetOptions.getOptions()
	if (privacyNoticeUrl && !isTicketForm) {
		getHostWindow().open(privacyNoticeUrl, '_blank')
		return
	}

	openDrawer(DrawerId.GdprAndPrivacy, { useStack: true })
}
</script>

<!-- svelte-ignore a11y-click-events-have-key-events -->
<div
	role="link"
	tabindex="0"
	on:click={handlePrivacyNoticeClick}
	class="inline-flex text-xs text-slate-500 hover:text-slate-800 underline cursor-pointer transition-colors"
>
	{label}
</div>
