import { jsxs as m, Fragment as u, jsx as t } from "react/jsx-runtime";
import { useMemo as v } from "react";
import { u as d, a as C } from "../../index.esm-BQxOvVZs.js";
import { b as D, d as a } from "../../index.esm-Jcyi89ZF.js";
import x from "../../components/AlertDialog/index.js";
import p 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 s from "../../composables/FormInputs.js";
import { useModalContext as f } from "../../context/generalContext/index.js";
import { staticOptions as g } from "../../config/index.js";
import "../../_commonjsHelpers-2ufMB8rV.js";
import "react-dom";
import "../../components/Icons.js";
import "../../utils/functions.js";
import "../../clsx-7d8NmkQq.js";
import "../../utils/components/RenderIf.js";
import "../../components/AlertDialog/variants.js";
import "../../index-xVF7D3FM.js";
import "../../components/Buttons/variants.js";
import "../../composables/Modal.js";
import "../../hooks/useAnimatePresence.js";
import "../../SVGVisualElement-aqO4D4Z5.js";
import "../../use-unmount-effect-Wy5iLAex.js";
import "../../index-T7wQHOux.js";
import "../../LayoutGroupContext-3euHzeKi.js";
import "./FormModal.js";
import "../RenderFeatureComponents.js";
import "../../useQuery-n4ls1rLk.js";
import "../../hooks/useHasNextSiblingByAttribute.js";
import "../../index-20bzTFSx.js";
import "../../utils/components/RenderEach.js";
import "../../components/Inputs/variants.js";
import "../../motion-dVICNqWI.js";
import "../../hooks/useDeepCompareEffect.js";
import "../../context/index.js";
import "../../axios-f2q_J-wz.js";
const _ = D({
  direction: a().required("Ingresar dirección"),
  complementType: a(),
  complement: a()
}), ut = () => {
  const {
    closeModal: r,
    modalInfo: { id: e }
  } = f(), { setValue: c } = d(), i = C({ name: e }), l = v(() => {
    const [n] = i.split("; ");
    return { direction: n };
  }, [i]), o = (n) => {
    const h = Object.values(n).filter((b) => !!b).join("; ");
    c(e, h, { shouldDirty: !0, shouldTouch: !0, shouldValidate: !0 }), r();
  };
  return /* @__PURE__ */ m(u, { children: [
    /* @__PURE__ */ t(x.AlertDialogHeader, { variants: { variant: "govco" }, closeModal: r, children: "Encontrar Dirección" }),
    /* @__PURE__ */ t(y, { schema: _, defaultValue: l, children: /* @__PURE__ */ t(M, { onSubmit: o }) })
  ] });
}, M = ({ onSubmit: r }) => {
  const { handleSubmit: e, setValue: c } = d(), { closeModal: i } = f(), l = (o) => {
    r(o);
  };
  return /* @__PURE__ */ t(u, { children: /* @__PURE__ */ m("div", { className: "_flex _flex-col _gap-2", children: [
    /* @__PURE__ */ t(
      I,
      {
        autoLocalization: !0,
        onClickFunc: (o) => c("direction", o.formatted_address, { shouldDirty: !0, shouldTouch: !0, shouldValidate: !0 })
      }
    ),
    /* @__PURE__ */ t(s.InputFormCntx, { currentId: "direction", label: "Descripción de Actividad Principal*", inputProps: { disabled: !0 } }),
    /* @__PURE__ */ m(F.InputsWrapper, { className: "items-center _w-full", children: [
      /* @__PURE__ */ t(
        s.SelectFormCntx,
        {
          currentId: "complementType",
          label: "Tipo de complemento",
          selectOptions: g.complementType,
          optionsEntries: ["id", "label"]
        }
      ),
      /* @__PURE__ */ t(s.InputFormCntx, { currentId: "complement", label: "Complemento" })
    ] }),
    /* @__PURE__ */ m("div", { className: "_inline-flex _gap-4 _justify-end", children: [
      /* @__PURE__ */ t(p.Button, { type: "button", variant: "bordered-error", onClick: i, children: "Cancelar" }),
      /* @__PURE__ */ t(p.FormButton, { type: "button", onClick: e(l), children: "Continuar" })
    ] })
  ] }) });
};
export {
  ut as default
};
