import { jsx as e, jsxs as a } from "@emotion/react/jsx-runtime";
import { useRef as F } from "react";
import b from "../FieldTypes/DataTypeComponent.js";
import y from "./usePopoverFilter.js";
import { usePopoverContainer as P } from "../../../../hooks/usePopoverContainer/usePopoverContainer.js";
import { PopoverStyled as C, PopoverContainerFieldsStyled as S, PopoverHeaderActionsStyled as g } from "../../slots/dynamicFilterSlots.js";
import { RHFormProvider as x } from "../../../hook-form/RHFormProvider/RHFormProvider.js";
import { ActionFormSubmitProgrammatic as R } from "../../../CommonActions/components/ActionFormSubmitProgrammatic/ActionFormSubmitProgrammatic.js";
import { WindowBase as D } from "../../../WindowBase/WindowBase.js";
import { ActionCancel as k } from "../../../CommonActions/components/ActionCancel/ActionCancel.js";
function V() {
  const {
    field: p,
    labelField: s,
    anchorEl: m,
    handleKeyDownPopper: c,
    handleClosePopover: d,
    onSubmit: r,
    onClose: f,
    filterFormValue: u,
    formFilter: h,
    popupValidationSchema: v,
    statusLoad: t,
    canRender: i
  } = y(), n = P(!!i), l = F(null);
  return !i || !n ? null : /* @__PURE__ */ e(
    C,
    {
      open: !0,
      disableRestoreFocus: !0,
      disableEnforceFocus: !0,
      disableAutoFocus: !0,
      transitionDuration: 0,
      anchorOrigin: { vertical: "bottom", horizontal: "left" },
      transformOrigin: { vertical: "top", horizontal: "left" },
      sx: (o) => ({
        mt: o.vars.size.baseSpacings.sp2
      }),
      arrowType: "top-left",
      anchorEl: m,
      onKeyDown: (o) => {
        c(o), o.key === "Enter" && (o.preventDefault(), l.current?.formMethods.handleSubmit(r)());
      },
      onClose: d,
      container: n,
      children: /* @__PURE__ */ e(
        x,
        {
          ref: l,
          onSubmit: r,
          values: u,
          validationSchema: v,
          statusLoad: t,
          children: /* @__PURE__ */ a(
            D,
            {
              title: s,
              iconUrl: p.urlIcon,
              variant: "text",
              emergeType: "popup",
              selected: !0,
              draggable: !1,
              children: [
                /* @__PURE__ */ e(S, { children: /* @__PURE__ */ e(b, { formFilter: h, statusLoad: t }) }),
                /* @__PURE__ */ a(g, { children: [
                  /* @__PURE__ */ e(k, { onClick: f, skeletonWidth: "68px" }),
                  /* @__PURE__ */ e(R, { onSubmit: r, skeletonWidth: "64px", "aria-label": "applyFilter" })
                ] })
              ]
            }
          )
        }
      )
    }
  );
}
export {
  V as default
};
