import { useFieldSchema } from "@tachybase/schema";
import { useParamsFromRecord } from "../../../../../block-provider/BlockProvider.mjs";
import { useCollectionParentRecordData, useCollectionRecordData } from "../../../../../data-source/collection-record/CollectionRecordProvider.mjs";
function useDetailsDecoratorProps(props) {
    const params = useParamsFromRecord();
    let parentRecord;
    if (props.association) parentRecord = useDetailsParentRecord(props.association);
    return {
        params,
        parentRecord
    };
}
function useDetailsParentRecord(association) {
    const fieldSchema = useFieldSchema();
    const recordData = useCollectionRecordData();
    const parentRecordData = useCollectionParentRecordData();
    if (!association) return;
    if (fieldSchema['x-is-current']) return parentRecordData;
    return recordData;
}
export { useDetailsDecoratorProps, useDetailsParentRecord };
