'use client';
import { jsxDEV as _jsxDEV } from "react/jsx-dev-runtime";
import { getTranslation } from '@payloadcms/translations';
import React from 'react';
import { useForm } from '../../forms/Form/context.js';
import { useEditDepth } from '../../providers/EditDepth/index.js';
import { useLocale } from '../../providers/Locale/index.js';
import { useTranslation } from '../../providers/Translation/index.js';
import { generateFieldID } from '../../utilities/generateFieldID.js';
import './index.scss';
export const FieldLabel = (props)=>{
    const { as: ElementFromProps = 'label', hideLocale = false, htmlFor: htmlForFromProps, label, localized = false, path, required = false, unstyled = false } = props;
    const { uuid } = useForm();
    const editDepth = useEditDepth();
    const htmlFor = htmlForFromProps || generateFieldID(path, editDepth, uuid);
    const { i18n } = useTranslation();
    const { code, label: localLabel } = useLocale();
    const Element = ElementFromProps === 'label' ? htmlFor ? 'label' : 'span' : ElementFromProps || 'span';
    if (label) {
        return /*#__PURE__*/ _jsxDEV(Element, {
            className: `field-label${unstyled ? ' unstyled' : ''}`,
            htmlFor: htmlFor,
            children: [
                getTranslation(label, i18n),
                required && !unstyled && /*#__PURE__*/ _jsxDEV("span", {
                    className: "required",
                    children: "*"
                }, void 0, false, {
                    fileName: "src/fields/FieldLabel/index.tsx",
                    lineNumber: 42,
                    columnNumber: 35
                }, this),
                localized && !hideLocale && /*#__PURE__*/ _jsxDEV("span", {
                    className: "localized",
                    children: [
                        "— ",
                        typeof localLabel === 'string' ? localLabel : code
                    ]
                }, void 0, true, {
                    fileName: "src/fields/FieldLabel/index.tsx",
                    lineNumber: 44,
                    columnNumber: 11
                }, this)
            ]
        }, void 0, true, {
            fileName: "src/fields/FieldLabel/index.tsx",
            lineNumber: 40,
            columnNumber: 7
        }, this);
    }
    return null;
};

//# sourceMappingURL=index.js.map