import { jsxs as c, Fragment as d, jsx as e } from "react/jsx-runtime";
import { useMemo as v } from "react";
import { u as p, a as C } from "../../index.esm-BQxOvVZs.js";
import { b as D, d as s } from "../../index.esm-Jcyi89ZF.js";
import x from "../../components/AlertDialog/index.js";
import u from "../../components/Buttons/index.js";
import { BasicFormProvider as y } from "../../components/FormProvider.js";
import F from "../../components/Layouts.js";
import I from "../../components/Maps/index.js";
import m from "../../composables/FormInputs.js";
import { useModalContext as f } from "../../context/generalContext/index.js";
import { staticOptions as g } from "../../config/index.js";
const _ = D({
  direction: s().required("Ingresar dirección"),
  complementType: s(),
  complement: s()
}), W = () => {
  const {
    closeModal: o,
    modalInfo: { id: r }
  } = f(), { setValue: l } = p(), n = C({ name: r }), a = v(() => {
    const [i] = n.split("; ");
    return { direction: i };
  }, [n]), t = (i) => {
    const h = Object.values(i).filter((b) => !!b).join("; ");
    l(r, h, { shouldDirty: !0, shouldTouch: !0, shouldValidate: !0 }), o();
  };
  return /* @__PURE__ */ c(d, { children: [
    /* @__PURE__ */ e(x.AlertDialogHeader, { variants: { variant: "govco" }, closeModal: o, children: "Encontrar Dirección" }),
    /* @__PURE__ */ e(y, { schema: _, defaultValue: a, children: /* @__PURE__ */ e(M, { onSubmit: t }) })
  ] });
}, M = ({ onSubmit: o }) => {
  const { handleSubmit: r, setValue: l } = p(), { closeModal: n } = f(), a = (t) => {
    o(t);
  };
  return /* @__PURE__ */ e(d, { children: /* @__PURE__ */ c("div", { className: "_flex _flex-col _gap-2", children: [
    /* @__PURE__ */ e(
      I,
      {
        autoLocalization: !0,
        onClickFunc: (t) => l("direction", t.formatted_address, { shouldDirty: !0, shouldTouch: !0, shouldValidate: !0 })
      }
    ),
    /* @__PURE__ */ e(m.InputFormCntx, { currentId: "direction", label: "Descripción de Actividad Principal*", inputProps: { disabled: !0 } }),
    /* @__PURE__ */ c(F.InputsWrapper, { className: "items-center _w-full", children: [
      /* @__PURE__ */ e(
        m.SelectFormCntx,
        {
          currentId: "complementType",
          label: "Tipo de complemento",
          selectOptions: g.complementType,
          optionsEntries: ["id", "label"]
        }
      ),
      /* @__PURE__ */ e(m.InputFormCntx, { currentId: "complement", label: "Complemento" })
    ] }),
    /* @__PURE__ */ c("div", { className: "_inline-flex _gap-4 _justify-end", children: [
      /* @__PURE__ */ e(u.Button, { type: "button", variant: "bordered-error", onClick: n, children: "Cancelar" }),
      /* @__PURE__ */ e(u.FormButton, { type: "button", onClick: r(a), children: "Continuar" })
    ] })
  ] }) });
};
export {
  W as default
};
