( function () {
	try {
		// if the edd_acr_timezone is already set, don't capture it again
		if ( document.cookie.includes( 'edd_acr_timezone=' ) ) {
			return;
		}

		// Capture timezone using Intl API
		if ( typeof Intl !== 'undefined' && Intl.DateTimeFormat ) {
			let timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
			if ( timezone ) {
				document.cookie = 'edd_acr_timezone=' + encodeURIComponent( timezone ) + '; path=/; max-age=' + ( 30 * 24 * 60 * 60 ) + '; SameSite=Lax';
			}
		}

	// Generate simple browser fingerprint
	let platformInfo = '';
	if ( navigator.userAgentData?.platform ) {
		platformInfo = navigator.userAgentData.platform;
	}

	let components = [
		navigator.userAgent || '',
		navigator.language || '',
		screen.colorDepth || '',
		screen.width + 'x' + screen.height,
		new Date().getTimezoneOffset(),
		navigator.hardwareConcurrency || '',
		platformInfo
	];
	let fingerprintString = components.join( '|' );

		// Simple hash function
		let hash = 0;
		for ( let i = 0; i < fingerprintString.length; i++ ) {
			let char = fingerprintString.codePointAt( i );
			hash = ( ( hash << 5 ) - hash ) + char;
			hash = hash & hash;
		}
		let fingerprint = hash.toString( 36 );

		if ( fingerprint ) {
			document.cookie = 'edd_acr_fingerprint=' + encodeURIComponent( fingerprint ) + '; path=/; max-age=' + ( 30 * 24 * 60 * 60 ) + '; SameSite=Lax';
		}
	} catch ( e ) {
		console.log( '[EDD ACR] Failed to capture browser data:', e );
	}
} )();
