/**
 * Cloudflare Turnstile type declarations
 *
 * @see https://developers.cloudflare.com/turnstile/get-started/client-side-rendering/
 */

interface TurnstileRenderOptions {
	sitekey: string;
	callback?: (token: string) => void;
	'error-callback'?: (error: string) => void;
	'expired-callback'?: () => void;
	theme?: 'light' | 'dark' | 'auto';
	language?: string;
	action?: string;
	cData?: string;
	tabindex?: number;
	'response-field'?: boolean;
	'response-field-name'?: string;
	size?: 'normal' | 'compact';
	retry?: 'auto' | 'never';
	'retry-interval'?: number;
	'refresh-expired'?: 'auto' | 'manual' | 'never';
	appearance?: 'always' | 'execute' | 'interaction-only';
}

interface Turnstile {
	render: (container: HTMLElement | string, options: TurnstileRenderOptions) => string;
	reset: (widgetId: string) => void;
	remove: (widgetId: string) => void;
	getResponse: (widgetId: string) => string | undefined;
	isExpired: (widgetId: string) => boolean;
}

declare global {
	interface Window {
		turnstile: Turnstile;
	}
}

export {};
