import { useState as p, useRef as u, useEffect as f } from "react";
import a from "copy-to-clipboard";
const i = {
  en: {
    copy: "Click To Copy",
    copied: "Copied!"
  },
  zh: {
    copy: "点击复制",
    copied: "已复制!"
  }
};
function C({ content: r, locale: s = "en" }) {
  const [t, o] = p(!1), n = u(null), c = (e) => {
    e && e.stopPropagation(), a(r || (n.current?.textContent ?? "")), o(!0);
  };
  return f(() => {
    let e;
    return t && (e = setTimeout(() => o(!1), 2e3)), () => clearTimeout(e);
  }, [t]), {
    containerRef: n,
    copied: t,
    copy: c,
    texts: i[s] || i.en
  };
}
export {
  C as default
};
