'use client';
import { jsxDEV as _jsxDEV } from "react/jsx-dev-runtime";
import { getTranslation } from '@payloadcms/translations';
import React from 'react';
import { useEditDepth } from '../../../providers/EditDepth/index.js';
import { useTranslation } from '../../../providers/Translation/index.js';
import './index.scss';
const baseClass = 'radio-input';
export const Radio = (props)=>{
    const { isSelected, onChange, option, path, readOnly, uuid } = props;
    const { i18n } = useTranslation();
    const editDepth = useEditDepth();
    const id = `field-${path}-${option.value}${editDepth > 1 ? `-${editDepth}` : ''}${uuid ? `-${uuid}` : ''}`;
    return /*#__PURE__*/ _jsxDEV("label", {
        htmlFor: id,
        children: /*#__PURE__*/ _jsxDEV("div", {
            className: [
                baseClass,
                isSelected && `${baseClass}--is-selected`
            ].filter(Boolean).join(' '),
            children: [
                /*#__PURE__*/ _jsxDEV("input", {
                    checked: isSelected,
                    disabled: readOnly,
                    id: id,
                    name: path,
                    onChange: ()=>typeof onChange === 'function' ? onChange(option.value) : null,
                    type: "radio"
                }, void 0, false, {
                    fileName: "src/fields/RadioGroup/Radio/index.tsx",
                    lineNumber: 34,
                    columnNumber: 9
                }, this),
                /*#__PURE__*/ _jsxDEV("span", {
                    className: [
                        `${baseClass}__styled-radio`,
                        readOnly && `${baseClass}__styled-radio--disabled`
                    ].filter(Boolean).join(' ')
                }, void 0, false, {
                    fileName: "src/fields/RadioGroup/Radio/index.tsx",
                    lineNumber: 42,
                    columnNumber: 9
                }, this),
                /*#__PURE__*/ _jsxDEV("span", {
                    className: `${baseClass}__label`,
                    children: getTranslation(option.label, i18n)
                }, void 0, false, {
                    fileName: "src/fields/RadioGroup/Radio/index.tsx",
                    lineNumber: 50,
                    columnNumber: 9
                }, this)
            ]
        }, void 0, true, {
            fileName: "src/fields/RadioGroup/Radio/index.tsx",
            lineNumber: 31,
            columnNumber: 7
        }, this)
    }, void 0, false, {
        fileName: "src/fields/RadioGroup/Radio/index.tsx",
        lineNumber: 30,
        columnNumber: 5
    }, this);
};

//# sourceMappingURL=index.js.map