import { copyRichClipboard as e, copyTextToClipboard as t } from "../shared/clipboard.js";
import { useCallback as n, useEffect as r, useRef as i, useState as a } from "react";
//#region src/hooks/useClipboardCopy.ts
function o(o = 2e3) {
	let [s, c] = a(null), l = i(null), u = n(() => {
		l.current != null && (window.clearTimeout(l.current), l.current = null);
	}, []);
	r(() => () => {
		u();
	}, [u]);
	let d = n((e) => {
		e != null && (c(e), u(), l.current = window.setTimeout(() => {
			c(null), l.current = null;
		}, o));
	}, [u, o]);
	return {
		copiedKey: s,
		copyText: n(async (e, n) => {
			let r = await t(e);
			return r && d(n), r;
		}, [d]),
		copyRich: n(async (t, n) => {
			let r = await e(t);
			return r && d(n), r;
		}, [d])
	};
}
//#endregion
export { o as default, o as useClipboardCopy };

//# sourceMappingURL=useClipboardCopy.js.map