import { useCallback } from "react";
import { useFieldSchema } from "@tachybase/schema";
import { useBlockContext } from "../../../../block-provider/BlockProvider.mjs";
import { useCollection_deprecated } from "../../../../collection-manager/index.mjs";
import { useRecord, useRecordIndex } from "../../../../record-provider/index.mjs";
import { useCompile } from "../../../hooks/index.mjs";
const useGetAriaLabelOfAction = (title)=>{
    const record = useRecord();
    const recordIndex = useRecordIndex();
    const fieldSchema = useFieldSchema();
    const compile = useCompile();
    const component = fieldSchema['x-component'];
    let recordName = (null == record ? void 0 : record.name) || (null == record ? void 0 : record.title) || (null != recordIndex ? String(recordIndex) : '');
    let action = fieldSchema['x-action'];
    let { name: collectionName } = useCollection_deprecated();
    let { name: blockName } = useBlockContext() || {};
    const actionTitle = title || compile(fieldSchema.title);
    collectionName = collectionName ? "-".concat(collectionName) : '';
    blockName = blockName ? "-".concat(blockName) : '';
    action = action ? "-".concat(action) : '';
    recordName = recordName ? "-".concat(recordName) : '';
    const getAriaLabel = useCallback((postfix)=>{
        postfix = postfix ? "-".concat(postfix) : '';
        return "action-".concat(component, "-").concat(actionTitle).concat(action).concat(collectionName).concat(blockName).concat(recordName).concat(postfix);
    }, [
        action,
        actionTitle,
        blockName,
        collectionName,
        component,
        recordName
    ]);
    return {
        getAriaLabel
    };
};
export { useGetAriaLabelOfAction };
