/**
 * @license Copyright (c) 2017-2025, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md.
 */

/**
 * Copies the provided text to clipboard.
 *
 * @param text - The text to copy to clipboard
 * @returns Promise that resolves when text is copied or rejects on error
 */
export function copyToClipboard( text ) {
	// Use the more modern navigator.clipboard API if available
	if ( navigator.clipboard && navigator.clipboard.writeText ) {
		return navigator.clipboard.writeText( text );
	}

	throw new Error( 'Clipboard API is not supported in this browser.' );
}
