import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__ from "react/jsx-runtime";
import "react";
import * as __WEBPACK_EXTERNAL_MODULE__api_client_index_mjs__ from "../api-client/index.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__data_source_collection_CollectionManagerProvider_mjs__ from "../data-source/collection/CollectionManagerProvider.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__data_source_data_source_DataSourceManagerProvider_mjs__ from "../data-source/data-source/DataSourceManagerProvider.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__CollectionHistoryProvider_mjs__ from "./CollectionHistoryProvider.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__CollectionManagerSchemaComponentProvider_mjs__ from "./CollectionManagerSchemaComponentProvider.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__context_mjs__ from "./context.mjs";
const CollectionManagerProvider_deprecated = (props)=>/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__data_source_collection_CollectionManagerProvider_mjs__.CollectionManagerProvider, {
        children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__CollectionManagerSchemaComponentProvider_mjs__.CollectionManagerSchemaComponentProvider, {
            children: props.children
        })
    });
const RemoteCollectionManagerProvider = (props)=>{
    const api = (0, __WEBPACK_EXTERNAL_MODULE__api_client_index_mjs__.useAPIClient)();
    const dm = (0, __WEBPACK_EXTERNAL_MODULE__data_source_data_source_DataSourceManagerProvider_mjs__.useDataSourceManager)();
    const { refreshCH } = (0, __WEBPACK_EXTERNAL_MODULE__CollectionHistoryProvider_mjs__.useCollectionHistory)();
    const coptions = {
        url: 'collectionCategories:list',
        params: {
            paginate: false,
            sort: [
                'sort'
            ]
        }
    };
    const service = (0, __WEBPACK_EXTERNAL_MODULE__api_client_index_mjs__.useRequest)(()=>dm.reload().then(refreshCH));
    const result = (0, __WEBPACK_EXTERNAL_MODULE__api_client_index_mjs__.useRequest)(coptions);
    if (service.loading) return;
    const refreshCategory = async ()=>{
        const { data } = await api.request(coptions);
        result.mutate(data);
        return (null == data ? void 0 : data.data) || [];
    };
    return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(CollectionCategroriesProvider, {
        service: {
            ...result
        },
        refreshCategory: refreshCategory,
        children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(CollectionManagerProvider_deprecated, {
            ...props
        })
    });
};
const CollectionCategroriesProvider = (props)=>{
    var _service_data;
    const { service, refreshCategory } = props;
    return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__context_mjs__.CollectionCategroriesContext.Provider, {
        value: {
            data: null == service ? void 0 : null === (_service_data = service.data) || void 0 === _service_data ? void 0 : _service_data.data,
            refresh: refreshCategory,
            ...props
        },
        children: props.children
    });
};
export { CollectionCategroriesProvider, CollectionManagerProvider_deprecated, RemoteCollectionManagerProvider };
