import { jsx as o, jsxs as A } from "@emotion/react/jsx-runtime";
import { forwardRef as E } from "react";
import a from "clsx";
import { useModuleDictionary as M, useEnvironment as N } from "@m4l/core";
import { NotificationCheckCircleFill as v, NotificationWarningFill as O } from "@m4l/icons";
import { Icon as W } from "@m4l/base";
import { TEST_PROP_ID as T } from "../../../../test/constants_no_mock.js";
import { ActionsContainer as P } from "../../../CommonActions/components/ActionsContainer/ActionsContainer.js";
import { ActionFormIntro as k } from "../../../CommonActions/components/ActionFormIntro/ActionFormIntro.js";
import { PropertyValue as x } from "../../../PropertyValue/PropertyValue.js";
import { useDynamicFormConditionals as z } from "../../hooks/useDynamicFormConditionals/useDynamicFormConditionals.js";
import { resolveFieldInputLabel as L } from "../../helpers/resolveFieldInputLabel/resolveFieldInputLabel.js";
import { resolveFieldSymbol as g, resolveFieldMandatory as w } from "../../helpers/resolveFieldContractAliases.js";
import { DYNAMIC_FORM_DICTIONARY as c } from "../../dictionary.js";
import { DYNAMIC_FORM_CLASSES as l } from "../../constants.js";
import { DynamicFormSubmitFeedbackStyled as B, DynamicFormContentRootStyled as U, DynamicFormFieldWrapperStyled as Y, DynamicFormActionsRowStyled as j } from "../../slots/DynamicFormSlots.js";
import { useFieldsWithFetchedOptions as G } from "../../hooks/useFieldsWithFetchedOptions/useFieldsWithFetchedOptions.js";
import { resolveFieldComponent as V } from "../../helpers/resolveFieldComponent/resolveFieldComponent.js";
import { Chip as $ } from "../../../Chip/Chip.js";
const q = E((p, d) => {
  const {
    data: u,
    currentSize: r,
    fieldWrapperClassName: f,
    dataTestId: F,
    dataMeta: S,
    coupled: s = !1,
    actionFormIntroProps: y,
    renderActions: n,
    submitFeedbackStatus: e
  } = p, { getLabel: i } = M(), { host_static_assets: h, environment_assets: C, host_api_remote: _ } = N(), b = `${h}/${C}`, { visibleFields: D } = z(u), { fields: I } = G({ fields: D }), R = !s && e ? /* @__PURE__ */ o(B, { children: /* @__PURE__ */ o(
    $,
    {
      size: r,
      label: i(
        e === "success" ? c.SUBMIT_SUCCESS_MESSAGE : c.SUBMIT_ERROR_MESSAGE
      ),
      startIcon: /* @__PURE__ */ o(
        W,
        {
          src: e === "success" ? /* @__PURE__ */ o(v, {}) : /* @__PURE__ */ o(O, {}),
          color: e === "success" ? "chips.success.contained.color" : "chips.error.contained.color"
        }
      ),
      color: e === "success" ? "success" : "error",
      opacity: !0
    }
  ) }) : null;
  return /* @__PURE__ */ A(
    U,
    {
      ref: d,
      className: a(l.contentRoot),
      ...process.env.NODE_ENV !== "production" ? { [T]: F, "data-meta": S } : {},
      children: [
        R,
        I.map((t) => {
          if (typeof t.name != "string" || t.name.trim() === "")
            return null;
          const m = V(t, {
            size: r,
            getLabel: i,
            assetBasePath: b,
            hostApiRemote: _,
            suppressLabel: !0
          });
          return m ? /* @__PURE__ */ o(
            Y,
            {
              ownerState: { semanticWidth: t.metadata?.semanticWidth },
              className: a(f, l.fieldWrapper),
              children: /* @__PURE__ */ o(
                x,
                {
                  property: L(t, i),
                  value: m,
                  isForm: !0,
                  mandatory: w(t),
                  symbol: g(t)
                }
              )
            },
            t.id
          ) : null;
        }),
        !s && /* @__PURE__ */ o(j, { children: /* @__PURE__ */ o(P, { children: n ? n() : /* @__PURE__ */ o(
          k,
          {
            size: r,
            color: "default",
            ...y
          }
        ) }) })
      ]
    }
  );
});
q.displayName = "DynamicFormContent";
export {
  q as DynamicFormContent
};
