import { aW as l, aK as s, S as f } from "./index-GTnBs7av.js";
import { useState as m, useEffect as d } from "react";
const h = ({}) => {
  const [a, p] = m(), [u, n] = m(), { data: e } = l.viewer.appBasecamp3.projects.useQuery(), j = l.viewer.appBasecamp3.projectMutation.useMutation();
  return d(
    function() {
      var o, r, i;
      n({
        value: e == null ? void 0 : e.projects.currentProject,
        // eslint-disable-next-line @typescript-eslint/no-explicit-any
        label: (r = (o = e == null ? void 0 : e.projects) == null ? void 0 : o.find((c) => c.id === (e == null ? void 0 : e.currentProject))) == null ? void 0 : r.name
      }), p(
        // eslint-disable-next-line @typescript-eslint/no-explicit-any
        (i = e == null ? void 0 : e.projects) == null ? void 0 : i.map((c) => ({
          value: c.id,
          label: c.name
        }))
      );
    },
    [e]
  ), /* @__PURE__ */ s.jsxs("div", { className: "mt-2 text-sm", children: [
    /* @__PURE__ */ s.jsxs("div", { className: "flex gap-3", children: [
      /* @__PURE__ */ s.jsx("div", { className: "items-center", children: /* @__PURE__ */ s.jsx("p", { className: "py-2", children: "Link a Basecamp project to this event:" }) }),
      /* @__PURE__ */ s.jsx(
        f,
        {
          placeholder: "Select project",
          options: a,
          isLoading: !a,
          className: "md:min-w-[120px]",
          onChange: (t) => {
            t && (j.mutate({ projectId: t == null ? void 0 : t.value.toString() }), n(t));
          },
          value: u
        }
      )
    ] }),
    /* @__PURE__ */ s.jsxs("div", { className: "mt-2", children: [
      "Please note that as of now you can only link ",
      /* @__PURE__ */ s.jsx("span", { className: "italic", children: "one" }),
      " of your projects to cal.com"
    ] })
  ] });
};
export {
  h as default
};
