'use client';
"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
function _export(target, all) {
    for(var name in all)Object.defineProperty(target, name, {
        enumerable: true,
        get: all[name]
    });
}
_export(exports, {
    useFieldBase_unstable: function() {
        return useFieldBase_unstable;
    },
    useField_unstable: function() {
        return useField_unstable;
    }
});
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
const _reacticons = require("@fluentui/react-icons");
const _reactlabel = require("@fluentui/react-label");
const _reactutilities = require("@fluentui/react-utilities");
const validationMessageIcons = {
    error: /*#__PURE__*/ _react.createElement(_reacticons.DiamondDismiss12Filled, null),
    warning: /*#__PURE__*/ _react.createElement(_reacticons.Warning12Filled, null),
    success: /*#__PURE__*/ _react.createElement(_reacticons.CheckmarkCircle12Filled, null),
    none: undefined
};
const useField_unstable = (props, ref)=>{
    const { orientation = 'vertical', size = 'medium', ...fieldProps } = props;
    const state = useFieldBase_unstable(fieldProps, ref);
    const defaultIcon = validationMessageIcons[state.validationState];
    return {
        ...state,
        // eslint-disable-next-line @typescript-eslint/no-deprecated
        components: {
            ...state.components,
            label: _reactlabel.Label
        },
        label: _reactutilities.slot.optional(props.label, {
            defaultProps: {
                size,
                ...state.label
            },
            elementType: _reactlabel.Label
        }),
        validationMessageIcon: _reactutilities.slot.optional(props.validationMessageIcon, {
            renderByDefault: !!defaultIcon,
            defaultProps: {
                children: defaultIcon
            },
            elementType: 'span'
        }),
        orientation,
        size
    };
};
const useFieldBase_unstable = (props, ref)=>{
    const { children, required = false, validationState = props.validationMessage ? 'error' : 'none' } = props;
    const baseId = (0, _reactutilities.useId)('field-');
    const generatedControlId = baseId + '__control';
    const root = _reactutilities.slot.always((0, _reactutilities.getIntrinsicElementProps)('div', {
        ...props,
        ref
    }, /*excludedPropNames:*/ [
        'children'
    ]), {
        elementType: 'div'
    });
    const label = _reactutilities.slot.optional(props.label, {
        defaultProps: {
            htmlFor: generatedControlId,
            id: baseId + '__label',
            required
        },
        elementType: 'label'
    });
    const validationMessage = _reactutilities.slot.optional(props.validationMessage, {
        defaultProps: {
            id: baseId + '__validationMessage',
            role: validationState === 'error' || validationState === 'warning' ? 'alert' : undefined
        },
        elementType: 'div'
    });
    const hint = _reactutilities.slot.optional(props.hint, {
        defaultProps: {
            id: baseId + '__hint'
        },
        elementType: 'div'
    });
    const validationMessageIcon = _reactutilities.slot.optional(props.validationMessageIcon, {
        renderByDefault: false,
        elementType: 'span'
    });
    return {
        children,
        generatedControlId,
        required,
        validationState,
        components: {
            root: 'div',
            label: 'label',
            validationMessage: 'div',
            validationMessageIcon: 'span',
            hint: 'div'
        },
        root,
        label,
        validationMessageIcon,
        validationMessage,
        hint
    };
};
