import { jsx as n, jsxs as l } from "react/jsx-runtime";
import { a as p } from "../useQuery-n4ls1rLk.js";
import m from "../components/Layouts.js";
import o from "../composables/FormInputs.js";
import { formClient as i } from "../config/index.js";
const u = async () => {
  const e = await i.post("external/departments").then((t) => t.data).catch((t) => {
    console.error(t);
  });
  return (e == null ? void 0 : e.Departamentos) ?? [];
}, d = async (e) => {
  const t = await i.post("external/municipalities", { departmentId: e }).then((r) => r.data).catch((r) => {
    console.error(r);
  });
  return (t == null ? void 0 : t.Municipios) ?? [];
}, F = ({ className: e, prefix: t = "", style: r }) => {
  const { data: s = [], error: a, isPending: c } = p({ queryKey: ["departments"], queryFn: u });
  return a ? /* @__PURE__ */ n("span", { className: "_text-red-500", children: a.message }) : c ? /* @__PURE__ */ n("div", { className: "_h-[42px] _w-full loader _mt-2" }) : /* @__PURE__ */ l(m.InputsWrapper, { className: e, style: r, children: [
    /* @__PURE__ */ n(o.SelectFormCntx, { currentId: t + "department", optionsEntries: ["Key", "Value"], selectOptions: s, label: "Departamento*" }),
    /* @__PURE__ */ n(
      o.SelectByAnotherField,
      {
        targetValue: t + "department",
        optionsEntries: ["Key", "Value"],
        currentId: t + "municipality",
        fetchOptions: d,
        label: "Municipio*"
      }
    )
  ] });
};
export {
  F as SelectMunicipality
};
