// (function( $ ) {
// 	'use strict';

// 	// console.log('asdf');

// })( jQuery );

(function( $ ) {
	'use strict';

	// Copy Link Button
	$(document).on('click', '.frhd__copy-link-btn', function(e) {
		e.preventDefault();
		e.stopPropagation();
		var btn = $(this);
		var url = btn.attr('data-url');
		var tooltip = btn.find('.frhd__copy-tooltip');

		if (!url) return;

		// Method 1: Modern Clipboard API (HTTPS only)
		if (navigator.clipboard && window.isSecureContext) {
			navigator.clipboard.writeText(url).then(function() {
				btn.addClass('copied');
				tooltip.text('Copied!');
				setTimeout(function() {
					btn.removeClass('copied');
					tooltip.text('Copy Link');
				}, 2000);
			});
		} else {
			// Method 2: Fallback for HTTP (Flywheel Local)
			var textArea = document.createElement('textarea');
			textArea.value = url;
			textArea.style.position = 'fixed';
			textArea.style.left = '-9999px';
			textArea.style.top = '-9999px';
			document.body.appendChild(textArea);
			textArea.focus();
			textArea.select();

			try {
				document.execCommand('copy');
				btn.addClass('copied');
				tooltip.text('Copied!');
				setTimeout(function() {
					btn.removeClass('copied');
					tooltip.text('Copy Link');
				}, 2000);
			} catch (err) {
				tooltip.text('Failed!');
				setTimeout(function() {
					tooltip.text('Copy Link');
				}, 2000);
			}

			document.body.removeChild(textArea);
		}
	});

})( jQuery );