import { __ } from '@wordpress/i18n'; class WindowService { async copyToClipboard(text: string): Promise { try { // Try modern clipboard API first await navigator.clipboard.writeText(text); } catch (err) { // Fallback for older browsers or when clipboard API is not available const textArea = document.createElement('textarea'); textArea.value = text; textArea.style.position = 'fixed'; textArea.style.left = '-999999px'; document.body.appendChild(textArea); textArea.focus(); textArea.select(); try { const successful = document.execCommand('copy'); if (!successful) { throw new Error(__('Copy command failed.', 'timetailor-salon-booking')); } } catch (err) { document.body.removeChild(textArea); throw new Error(__('Failed to copy. Please copy manually.', 'timetailor-salon-booking')); } document.body.removeChild(textArea); } } } export const windowService = new WindowService();