"use strict";
var __webpack_require__ = {};
(()=>{
    __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__, {
    useCollection_deprecated: ()=>useCollection_deprecated
});
const external_react_namespaceObject = require("react");
const index_js_namespaceObject = require("../../api-client/index.js");
const CollectionProvider_js_namespaceObject = require("../../data-source/collection/CollectionProvider.js");
const useCollection_deprecated = ()=>{
    var _collection_getOptions;
    const collection = (0, CollectionProvider_js_namespaceObject.useCollection)();
    const api = (0, index_js_namespaceObject.useAPIClient)();
    const resource = null == api ? void 0 : api.resource(null == collection ? void 0 : collection.name);
    const currentFields = (0, external_react_namespaceObject.useMemo)(()=>(null == collection ? void 0 : collection.fields) || [], [
        collection
    ]);
    const inheritedFields = (0, external_react_namespaceObject.useMemo)(()=>{
        var _collection_getInheritedFields;
        return (null == collection ? void 0 : null === (_collection_getInheritedFields = collection.getInheritedFields) || void 0 === _collection_getInheritedFields ? void 0 : _collection_getInheritedFields.call(collection)) || [];
    }, [
        collection
    ]);
    const totalFields = (0, external_react_namespaceObject.useMemo)(()=>{
        var _collection_getAllFields, _collection_getFields;
        return (null == collection ? void 0 : null === (_collection_getAllFields = collection.getAllFields) || void 0 === _collection_getAllFields ? void 0 : _collection_getAllFields.call(collection)) || (null == collection ? void 0 : null === (_collection_getFields = collection.getFields) || void 0 === _collection_getFields ? void 0 : _collection_getFields.call(collection)) || [];
    }, [
        collection
    ]);
    const foreignKeyFields = (0, external_react_namespaceObject.useMemo)(()=>{
        var _collection_getForeignKeyFields;
        return (null == collection ? void 0 : null === (_collection_getForeignKeyFields = collection.getForeignKeyFields) || void 0 === _collection_getForeignKeyFields ? void 0 : _collection_getForeignKeyFields.call(collection)) || [];
    }, [
        collection
    ]);
    const getTreeParentField = (0, external_react_namespaceObject.useCallback)(()=>null == totalFields ? void 0 : totalFields.find((field)=>field.treeParent), [
        totalFields
    ]);
    const getField = (0, external_react_namespaceObject.useCallback)((name)=>{
        var _collection_getField;
        return null == collection ? void 0 : null === (_collection_getField = collection.getField) || void 0 === _collection_getField ? void 0 : _collection_getField.call(collection, name);
    }, [
        collection
    ]);
    const getPrimaryKey = (0, external_react_namespaceObject.useCallback)(()=>null == collection ? void 0 : collection.getPrimaryKey(), [
        collection
    ]);
    return {
        ...null == collection ? void 0 : null === (_collection_getOptions = collection.getOptions) || void 0 === _collection_getOptions ? void 0 : _collection_getOptions.call(collection),
        resource,
        getTreeParentField,
        fields: totalFields,
        getField,
        getPrimaryKey,
        currentFields,
        inheritedFields,
        foreignKeyFields
    };
};
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
});
