var l = (c, i, o) => new Promise((a, t) => {
  var s = (e) => {
    try {
      r(o.next(e));
    } catch (u) {
      t(u);
    }
  }, n = (e) => {
    try {
      r(o.throw(e));
    } catch (u) {
      t(u);
    }
  }, r = (e) => e.done ? a(e.value) : Promise.resolve(e.value).then(s, n);
  r((o = o.apply(c, i)).next());
});
import { useState as d, useRef as p, useEffect as f } from "react";
import { ah as m } from "./main-CxoAwMiG.js";
const b = (c = 1500) => {
  const { showToast: i } = m(), [o, a] = d(!1), t = p(null), s = (n, r) => l(null, null, function* () {
    if (n) {
      if (navigator.clipboard && navigator.clipboard.writeText)
        yield navigator.clipboard.writeText(n);
      else {
        const e = document.createElement("textarea");
        e.value = n, e.style.position = "fixed", e.style.opacity = "0", e.style.pointerEvents = "none", e.style.zIndex = "-1", document.body.appendChild(e), e.focus(), e.select();
        try {
          document.execCommand("copy");
        } finally {
          document.body.removeChild(e);
        }
      }
      a(!0), r && i(r, "success", { containerId: "link-toaster" }), t.current && clearTimeout(t.current), t.current = setTimeout(() => a(!1), c);
    }
  });
  return f(
    () => () => {
      t.current && clearTimeout(t.current);
    },
    []
  ), { copyText: s, copied: o };
};
export {
  b as u
};
