import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__ from "react/jsx-runtime";
import "react";
import * as __WEBPACK_EXTERNAL_MODULE__tachybase_schema__ from "@tachybase/schema";
import * as __WEBPACK_EXTERNAL_MODULE__api_client_index_mjs__ from "../../../api-client/index.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__record_provider_index_mjs__ from "../../../record-provider/index.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__action_index_mjs__ from "../action/index.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__select_index_mjs__ from "../select/index.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__shared_mjs__ from "./shared.mjs";
const ReadPretty = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.observer)((props)=>{
    const fieldNames = {
        ...__WEBPACK_EXTERNAL_MODULE__select_index_mjs__.defaultFieldNames,
        ...props.fieldNames
    };
    const field = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.useField)();
    const fieldSchema = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.useFieldSchema)();
    const record = (0, __WEBPACK_EXTERNAL_MODULE__record_provider_index_mjs__.useRecord)();
    const { snapshot } = (0, __WEBPACK_EXTERNAL_MODULE__action_index_mjs__.useActionContext)();
    const { data } = (0, __WEBPACK_EXTERNAL_MODULE__api_client_index_mjs__.useRequest)(snapshot ? async ()=>({
            data: record[fieldSchema.name]
        }) : {
        action: 'list',
        ...props.service,
        params: {
            paginate: false,
            filter: {
                [fieldNames.value]: {
                    $in: (0, __WEBPACK_EXTERNAL_MODULE__shared_mjs__.getValues)(field.value, fieldNames)
                }
            }
        }
    }, {
        refreshDeps: [
            props.service,
            field.value
        ]
    });
    return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__select_index_mjs__.Select.ReadPretty, {
        ...props,
        options: null == data ? void 0 : data.data
    });
}, {
    displayName: 'ReadPretty'
});
export { ReadPretty };
