namespace Gremlin_BlazorServer.Services
{
	using System.Threading.Tasks;
	using Microsoft.JSInterop;

	public sealed class ClipboardService
	{
		private readonly IJSRuntime jsRuntime;

		public ClipboardService(IJSRuntime jsRuntime) => this.jsRuntime = jsRuntime;

		public ValueTask<string> ReadTextAsync() => jsRuntime.InvokeAsync<string>("navigator.clipboard.readText");

		public ValueTask WriteTextAsync(string text) => jsRuntime.InvokeVoidAsync("navigator.clipboard.writeText", text);
	}
}
