import { jsx, jsxs } from "react/jsx-runtime";
import "react";
import { toArr, useField } from "@tachybase/schema";
import { defaultFieldNames } from "./defaultFieldNames.mjs";
const ReadPretty = (props)=>{
    const { fieldNames = defaultFieldNames } = props;
    const values = toArr(props.value);
    const len = values.length;
    const field = useField();
    let dataSource = field.dataSource;
    const data = [];
    for (const item of values)if ('object' == typeof item) data.push(item);
    else {
        const curr = null == dataSource ? void 0 : dataSource.find((v)=>v[fieldNames.value] === item);
        dataSource = (null == curr ? void 0 : curr[fieldNames.children]) || [];
        data.push(curr || {
            label: item,
            value: item
        });
    }
    return /*#__PURE__*/ jsx("div", {
        children: data.map((item, index)=>/*#__PURE__*/ jsxs("span", {
                children: [
                    'object' == typeof item ? item[fieldNames.label] : item,
                    len > index + 1 && ' / '
                ]
            }, index))
    });
};
export { ReadPretty };
