"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var Label_exports = {};
__export(Label_exports, {
  default: () => Label,
  getSizeHeight: () => getSizeHeight
});
module.exports = __toCommonJS(Label_exports);
var import_jsx_runtime = require("react/jsx-runtime");
var import_colorToString = require("../../../../../../utils/colorToString");
var import_FormContext = require("../../../../context/FormContext");
var import_css = require("@emotion/css");
var import_use_style = require("../../../../../../../runtimes/react/use-style");
var import_responsive_style = require("../../../../../../utils/responsive-style");
function getSizeHeight(size) {
  switch (size) {
    case import_FormContext.Sizes.SMALL:
      return 14;
    case import_FormContext.Sizes.MEDIUM:
      return 18;
    case import_FormContext.Sizes.LARGE:
      return 22;
    default:
      throw new Error(`Invalid form size "${size}"`);
  }
}
function getContrastColor(contrast) {
  switch (contrast) {
    case import_FormContext.Contrasts.LIGHT:
      return "rgba(0, 0, 0, 0.8)";
    case import_FormContext.Contrasts.DARK:
      return "rgba(255, 255, 255, 0.95)";
    default:
      throw new Error(`Invalid form contrast "${contrast}"`);
  }
}
function Label({
  as,
  className,
  ...restOfProps
}) {
  const Component = as ?? "label";
  const { contrast, size, labelTextStyle, labelTextColor } = (0, import_FormContext.useFormContext)();
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
    Component,
    {
      ...restOfProps,
      className: (0, import_css.cx)(
        (0, import_use_style.useStyle)({ display: "block", margin: "0 0 0.25em 0" }),
        (0, import_use_style.useStyle)((0, import_responsive_style.useResponsiveTextStyle)(labelTextStyle)),
        (0, import_use_style.useStyle)(
          (0, import_responsive_style.useResponsiveStyle)(
            [size, contrast, labelTextColor],
            ([size2 = import_FormContext.Sizes.MEDIUM, contrast2 = import_FormContext.Contrasts.LIGHT, textColor]) => ({
              minHeight: getSizeHeight(size2),
              color: textColor == null ? getContrastColor(contrast2) : (0, import_colorToString.colorToString)(textColor)
            })
          )
        ),
        className
      )
    }
  );
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  getSizeHeight
});
//# sourceMappingURL=index.js.map