"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const jsxRuntime = require("react/jsx-runtime");
const React = require("react");
const classNames = require("../../utils/classNames.cjs");
const config_context = require("../config/config.context.cjs");
const label_component = require("../label/label.component.cjs");
const statusWrapper_component = require("../statusWrapper/statusWrapper.component.cjs");
const validationErrors_component = require("../validationErrors/validationErrors.component.cjs");
require("./inputWrapper.theme.css.cjs");
function _interopNamespaceDefault(e) {
  const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
  if (e) {
    for (const k in e) {
      if (k !== "default") {
        const d = Object.getOwnPropertyDescriptor(e, k);
        Object.defineProperty(n, k, d.get ? d : {
          enumerable: true,
          get: () => e[k]
        });
      }
    }
  }
  n.default = e;
  return Object.freeze(n);
}
const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
const InputWrapper = React__namespace.forwardRef(({ className, children, leftOverlay, rightOverlay, validationMode, validationErrorMessages, errorIcon, disabled, pending, error, statusPosition, hideIconOnStatus, disableOnPending, scrollValidationErrorsIntoView, statusClassName, validationErrorsClassName, label, required, requiredIndicator, labelClassName, labelId, displaySize, ...nativeProps }, ref) => {
  const globals = config_context.useArmstrongConfig({
    validationMode,
    hideInputErrorIconOnStatus: hideIconOnStatus,
    disableControlOnPending: disableOnPending,
    requiredIndicator,
    scrollValidationErrorsIntoView,
    inputStatusPosition: statusPosition,
    validationErrorIcon: errorIcon,
    inputDisplaySize: displaySize
  });
  const shouldShowValidationErrorsList = globals.validationMode === "both" || globals.validationMode === "message";
  const shouldShowErrorIcon = !!(validationErrorMessages == null ? void 0 : validationErrorMessages.length) && (globals.validationMode === "both" || globals.validationMode === "icon") || error;
  const showLeftOverlay = leftOverlay && (globals.inputStatusPosition !== "left" || !globals.hideInputErrorIconOnStatus || !pending && !shouldShowErrorIcon);
  const showRightOverlay = rightOverlay && (globals.inputStatusPosition !== "right" || !globals.hideInputErrorIconOnStatus || !pending && !shouldShowErrorIcon);
  return jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsxs("div", { ref, className: classNames.concat("arm-input", "arm-input-wrapper", className), "data-disabled": disabled || pending && globals.disableControlOnPending ? true : void 0, "data-error": error || !!(validationErrorMessages == null ? void 0 : validationErrorMessages.length) ? true : void 0, "data-left-overlay": showLeftOverlay || globals.inputStatusPosition === "left" && (shouldShowErrorIcon || pending) ? true : void 0, "data-right-overlay": showRightOverlay || globals.inputStatusPosition === "right" && (shouldShowErrorIcon || pending) ? true : void 0, ...nativeProps, children: [label && jsxRuntime.jsx(label_component.Label, { className: classNames.concat("arm-input-base-label", labelClassName), required, requiredIndicator: globals.requiredIndicator, htmlFor: labelId, displaySize: globals.inputDisplaySize, children: label }), jsxRuntime.jsx("div", { className: "arm-input-inner", children: jsxRuntime.jsx(statusWrapper_component.StatusWrapper, { error: error || !!(validationErrorMessages == null ? void 0 : validationErrorMessages.length), pending, statusPosition: globals.inputStatusPosition, errorIcon: globals.validationErrorIcon, validationMode: globals.validationMode, className: statusClassName, children: jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [showLeftOverlay && jsxRuntime.jsx("div", { className: "arm-input-overlay arm-input-overlay-left", children: leftOverlay }), children, showRightOverlay && jsxRuntime.jsx("div", { className: "arm-input-overlay arm-input-overlay-right", children: rightOverlay })] }) }) }), !!(validationErrorMessages == null ? void 0 : validationErrorMessages.length) && shouldShowValidationErrorsList && jsxRuntime.jsx(validationErrors_component.ValidationErrors, { className: validationErrorsClassName, validationMode: globals.validationMode, validationErrors: validationErrorMessages, scrollIntoView: globals.scrollValidationErrorsIntoView })] }) });
});
InputWrapper.displayName = "InputWrapper";
exports.InputWrapper = InputWrapper;
//# sourceMappingURL=inputWrapper.component.cjs.map
