import { aJ as n } from "./index-THhC4TET.js";
import { useState as i } from "react";
function c(o) {
  const r = async () => {
    const t = await fetch("/api/integrations/vital/token", {
      method: "POST",
      body: JSON.stringify({}),
      headers: {
        "Content-Type": "application/json"
      }
    });
    if (!t.ok)
      throw new Error("Failed to get link token");
    return await t.json();
  }, [a, e] = i(!1);
  return /* @__PURE__ */ n.jsx(n.Fragment, { children: o.render({
    onClick() {
      e(!0), r().then((t) => {
        e(!1), window.open(`${t.url}&token=${t.token}`, "_self");
      }).catch((t) => {
        e(!1), console.error(t);
      });
    },
    loading: a
  }) });
}
export {
  c as default
};
