"use strict";
var __webpack_require__ = {};
(()=>{
    __webpack_require__.n = function(module) {
        var getter = module && module.__esModule ? function() {
            return module['default'];
        } : function() {
            return module;
        };
        __webpack_require__.d(getter, {
            a: getter
        });
        return getter;
    };
})();
(()=>{
    __webpack_require__.d = function(exports1, definition) {
        for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
            enumerable: true,
            get: definition[key]
        });
    };
})();
(()=>{
    __webpack_require__.o = function(obj, prop) {
        return Object.prototype.hasOwnProperty.call(obj, prop);
    };
})();
(()=>{
    __webpack_require__.r = function(exports1) {
        if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
            value: 'Module'
        });
        Object.defineProperty(exports1, '__esModule', {
            value: true
        });
    };
})();
var __webpack_exports__ = {};
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, {
    useGetAriaLabelOfBlockItem: ()=>useGetAriaLabelOfBlockItem
});
const external_react_namespaceObject = require("react");
const schema_namespaceObject = require("@tachybase/schema");
const external_lodash_namespaceObject = require("lodash");
var external_lodash_default = /*#__PURE__*/ __webpack_require__.n(external_lodash_namespaceObject);
const BlockProvider_js_namespaceObject = require("../../../../block-provider/BlockProvider.js");
const index_js_namespaceObject = require("../../../../data-source/index.js");
const external_hooks_index_js_namespaceObject = require("../../../hooks/index.js");
const useGetAriaLabelOfBlockItem = (defaultName)=>{
    var _fieldSchema_xcomponent, _collection_getField_uiSchema, _collection_getField;
    const fieldSchema = (0, schema_namespaceObject.useFieldSchema)();
    const compile = (0, external_hooks_index_js_namespaceObject.useCompile)();
    const component = external_lodash_default().isString(fieldSchema['x-component']) ? fieldSchema['x-component'] : null === (_fieldSchema_xcomponent = fieldSchema['x-component']) || void 0 === _fieldSchema_xcomponent ? void 0 : _fieldSchema_xcomponent.displayName;
    const collectionField = compile(fieldSchema['x-collection-field']);
    const { name: blockName } = (0, BlockProvider_js_namespaceObject.useBlockContext)() || {};
    const collection = (0, index_js_namespaceObject.useCollection)();
    const name = defaultName || blockName;
    const title = compile(fieldSchema['title']) || compile(null == collection ? void 0 : null === (_collection_getField = collection.getField(fieldSchema.name)) || void 0 === _collection_getField ? void 0 : null === (_collection_getField_uiSchema = _collection_getField.uiSchema) || void 0 === _collection_getField_uiSchema ? void 0 : _collection_getField_uiSchema.title);
    const getAriaLabel = (0, external_react_namespaceObject.useCallback)((postfix)=>{
        postfix = postfix ? "-".concat(postfix) : '';
        return [
            'block-item',
            component,
            null == collection ? void 0 : collection.name,
            name,
            collectionField,
            title,
            postfix
        ].filter(Boolean).join('-');
    }, [
        component,
        null == collection ? void 0 : collection.name,
        name,
        collectionField,
        title
    ]);
    return {
        getAriaLabel
    };
};
var __webpack_export_target__ = exports;
for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
    value: true
});
