"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__, {
    List: ()=>List
});
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
const external_react_namespaceObject = require("react");
const schema_namespaceObject = require("@tachybase/schema");
const external_antd_namespaceObject = require("antd");
const external_classnames_namespaceObject = require("classnames");
var external_classnames_default = /*#__PURE__*/ __webpack_require__.n(external_classnames_namespaceObject);
const withDynamicSchemaProps_js_namespaceObject = require("../../../application/hoc/withDynamicSchemaProps.js");
const index_js_namespaceObject = require("../../common/index.js");
const external_core_index_js_namespaceObject = require("../../core/index.js");
const external_hooks_index_js_namespaceObject = require("../../hooks/index.js");
const external_hooks_js_namespaceObject = require("./hooks.js");
const external_List_Decorator_js_namespaceObject = require("./List.Decorator.js");
const external_List_Designer_js_namespaceObject = require("./List.Designer.js");
const external_List_Item_js_namespaceObject = require("./List.Item.js");
const external_List_style_js_namespaceObject = require("./List.style.js");
var external_List_style_js_default = /*#__PURE__*/ __webpack_require__.n(external_List_style_js_namespaceObject);
const InternalList = (props)=>{
    var _service_data, _field_value;
    const { service } = (0, external_List_Decorator_js_namespaceObject.useListBlockContext)();
    const { run, params } = service;
    const fieldSchema = (0, schema_namespaceObject.useFieldSchema)();
    const Designer = (0, external_hooks_index_js_namespaceObject.useDesigner)();
    const meta = null == service ? void 0 : null === (_service_data = service.data) || void 0 === _service_data ? void 0 : _service_data.meta;
    const field = (0, schema_namespaceObject.useField)();
    const [schemaMap] = (0, external_react_namespaceObject.useState)(new Map());
    const { wrapSSR, componentCls, hashId } = external_List_style_js_default()();
    const getSchema = (0, external_react_namespaceObject.useCallback)((key)=>{
        if (!schemaMap.has(key)) schemaMap.set(key, new schema_namespaceObject.Schema({
            type: 'object',
            properties: {
                [key]: fieldSchema.properties['item']
            }
        }));
        return schemaMap.get(key);
    }, [
        fieldSchema.properties,
        schemaMap
    ]);
    const onPaginationChange = (0, external_react_namespaceObject.useCallback)((page, pageSize)=>{
        run({
            ...null == params ? void 0 : params[0],
            page: page,
            pageSize: pageSize
        });
    }, [
        run,
        params
    ]);
    return wrapSSR(/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_core_index_js_namespaceObject.SchemaComponentOptions, {
        scope: {
            useListItemProps: external_List_Decorator_js_namespaceObject.useListItemProps,
            useListActionBarProps: external_hooks_js_namespaceObject.useListActionBarProps
        },
        children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(index_js_namespaceObject.SortableItem, {
            className: external_classnames_default()('tb-list', componentCls, hashId),
            children: [
                /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.List, {
                    ...props,
                    pagination: !!meta && !(meta.count <= meta.pageSize) && {
                        onChange: onPaginationChange,
                        total: (null == meta ? void 0 : meta.count) || 0,
                        pageSize: (null == meta ? void 0 : meta.pageSize) || 10,
                        current: (null == meta ? void 0 : meta.page) || 1
                    },
                    loading: null == service ? void 0 : service.loading,
                    children: (null === (_field_value = field.value) || void 0 === _field_value ? void 0 : _field_value.length) ? field.value.map((item, index)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(schema_namespaceObject.RecursionField, {
                            basePath: field.address,
                            name: index,
                            onlyRenderProperties: true,
                            schema: getSchema(index)
                        }, index)) : null
                }),
                /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(Designer, {})
            ]
        })
    }));
};
const List = (0, withDynamicSchemaProps_js_namespaceObject.withDynamicSchemaProps)(InternalList);
List.Item = external_List_Item_js_namespaceObject.ListItem;
List.Designer = external_List_Designer_js_namespaceObject.ListDesigner;
List.Decorator = external_List_Decorator_js_namespaceObject.ListBlockProvider;
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
});
