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