import { j as e } from "../../../../../../../_virtual/jsx-runtime.js";
import "react";
import "../../../../../../../node_modules/.pnpm/@formkit_auto-animate@0.8.2/node_modules/@formkit/auto-animate/index.js";
import "../../../../../../../node_modules/.pnpm/react-hot-toast@2.5.2_react-dom@18.3.0-canary-3d9b20132-20240124_react@18.3.0-canary-3d_c02c1e17bf76c343fd22d1f22394ecf5/node_modules/react-hot-toast/dist/index.js";
import { BsDatabaseAdd as c } from "../../../../../../../node_modules/.pnpm/react-icons@5.3.0_react@18.3.0-canary-3d9b20132-20240124/node_modules/react-icons/bs/index.js";
import { useDatarecords as m } from "../../../hooks/use-datarecord.js";
import { useEditorHelpers as d } from "../../../../../../../use-editor.js";
import { fieldLabel as p } from "../form-class.js";
import { Root as u, Trigger as h, Content as f, Group as x, Item as g } from "../../../../../../../node_modules/.pnpm/@radix-ui_themes@3.1.4_@types_react-dom@18.3.6_@types_react@18.3.3__@types_react@18.3.3_46b1dabc193c5ff5696ee783983c694e/node_modules/@radix-ui/themes/dist/esm/components/select.js";
import { IconButton as j } from "../../../../../../../node_modules/.pnpm/@radix-ui_themes@3.1.4_@types_react-dom@18.3.6_@types_react@18.3.3__@types_react@18.3.3_46b1dabc193c5ff5696ee783983c694e/node_modules/@radix-ui/themes/dist/esm/components/icon-button.js";
const B = (r) => {
  const { currentValue: t, onChange: o, schema: i } = r, l = d(), s = m(), n = (a) => {
    o(a);
  };
  return /* @__PURE__ */ e.jsx("div", { className: "layout-field basis-full", children: /* @__PURE__ */ e.jsxs("div", { className: "flex items-start text-center justify-between flex-wrap gap-x-4 gap-y-1 pr-1", children: [
    s.length > 0 && /* @__PURE__ */ e.jsxs("div", { className: "flex justify-between gap-1 flex-1", children: [
      /* @__PURE__ */ e.jsx("label", { className: p, children: "Database" }),
      /* @__PURE__ */ e.jsxs(
        u,
        {
          defaultValue: t,
          size: "2",
          onValueChange: (a) => n(a),
          children: [
            /* @__PURE__ */ e.jsx(
              h,
              {
                radius: "large",
                variant: "ghost",
                placeholder: i["ui:placeholder"] ?? "Select a form schema"
              }
            ),
            /* @__PURE__ */ e.jsx(f, { position: "popper", children: /* @__PURE__ */ e.jsx(x, { children: s.map((a) => /* @__PURE__ */ e.jsx(g, { value: a.id, children: a.label }, a.id)) }) })
          ]
        }
      )
    ] }),
    /* @__PURE__ */ e.jsx(
      j,
      {
        type: "button",
        onClick: () => {
          l.onShowPopup?.("add-form-schema");
        },
        variant: "ghost",
        size: "1",
        radius: "large",
        "aria-label": "Create new form",
        children: /* @__PURE__ */ e.jsx(c, { size: 20 })
      }
    )
  ] }) });
};
export {
  B as DatarecordField
};
//# sourceMappingURL=datarecord.js.map
