import * as __WEBPACK_EXTERNAL_MODULE__application_Plugin_mjs__ from "../application/Plugin.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__data_source_data_source_DataSource_mjs__ from "../data-source/data-source/DataSource.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__data_source_data_source_DataSourceManager_mjs__ from "../data-source/data-source/DataSourceManager.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__interfaces_index_mjs__ from "./interfaces/index.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__mixins_InheritanceCollectionMixin_mjs__ from "./mixins/InheritanceCollectionMixin.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__templates_index_mjs__ from "./templates/index.mjs";
class MainDataSource extends __WEBPACK_EXTERNAL_MODULE__data_source_data_source_DataSource_mjs__.DataSource {
    async getDataSource() {
        var _service_data;
        const service = await this.app.apiClient.request({
            resource: 'collections',
            action: 'list',
            params: {
                paginate: false,
                appends: [
                    'fields',
                    'category'
                ],
                filter: {},
                sort: [
                    'sort'
                ]
            }
        });
        const collections = (null == service ? void 0 : null === (_service_data = service.data) || void 0 === _service_data ? void 0 : _service_data.data) || [];
        return {
            collections
        };
    }
}
class CollectionPlugin extends __WEBPACK_EXTERNAL_MODULE__application_Plugin_mjs__.Plugin {
    async load() {
        this.dataSourceManager.addCollectionMixins([
            __WEBPACK_EXTERNAL_MODULE__mixins_InheritanceCollectionMixin_mjs__.InheritanceCollectionMixin
        ]);
        this.addFieldInterfaces();
        this.addCollectionTemplates();
        this.addFieldInterfaces();
        this.addFieldInterfaceGroups();
        this.dataSourceManager.addDataSource(MainDataSource, {
            key: __WEBPACK_EXTERNAL_MODULE__data_source_data_source_DataSourceManager_mjs__.DEFAULT_DATA_SOURCE_KEY,
            displayName: __WEBPACK_EXTERNAL_MODULE__data_source_data_source_DataSourceManager_mjs__.DEFAULT_DATA_SOURCE_TITLE
        });
    }
    addFieldInterfaceGroups() {
        this.dataSourceManager.addFieldInterfaceGroups({
            basic: {
                label: '{{t("Basic")}}'
            },
            choices: {
                label: '{{t("Choices")}}'
            },
            media: {
                label: '{{t("Media")}}'
            },
            datetime: {
                label: '{{t("Date & Time")}}'
            },
            relation: {
                label: '{{t("Relation")}}'
            },
            advanced: {
                label: '{{t("Advanced type")}}'
            },
            systemInfo: {
                label: '{{t("System info")}}'
            },
            others: {
                label: '{{t("Others")}}'
            }
        });
    }
    addFieldInterfaces() {
        this.dataSourceManager.addFieldInterfaces([
            __WEBPACK_EXTERNAL_MODULE__interfaces_index_mjs__.CheckboxFieldInterface,
            __WEBPACK_EXTERNAL_MODULE__interfaces_index_mjs__.CheckboxGroupFieldInterface,
            __WEBPACK_EXTERNAL_MODULE__interfaces_index_mjs__.ChinaRegionFieldInterface,
            __WEBPACK_EXTERNAL_MODULE__interfaces_index_mjs__.CollectionSelectFieldInterface,
            __WEBPACK_EXTERNAL_MODULE__interfaces_index_mjs__.ColorFieldInterface,
            __WEBPACK_EXTERNAL_MODULE__interfaces_index_mjs__.CreatedAtFieldInterface,
            __WEBPACK_EXTERNAL_MODULE__interfaces_index_mjs__.CreatedByFieldInterface,
            __WEBPACK_EXTERNAL_MODULE__interfaces_index_mjs__.DatetimeFieldInterface,
            __WEBPACK_EXTERNAL_MODULE__interfaces_index_mjs__.EmailFieldInterface,
            __WEBPACK_EXTERNAL_MODULE__interfaces_index_mjs__.IconFieldInterface,
            __WEBPACK_EXTERNAL_MODULE__interfaces_index_mjs__.IdFieldInterface,
            __WEBPACK_EXTERNAL_MODULE__interfaces_index_mjs__.InputFieldInterface,
            __WEBPACK_EXTERNAL_MODULE__interfaces_index_mjs__.IntegerFieldInterface,
            __WEBPACK_EXTERNAL_MODULE__interfaces_index_mjs__.JsonFieldInterface,
            __WEBPACK_EXTERNAL_MODULE__interfaces_index_mjs__.LinkToFieldInterface,
            __WEBPACK_EXTERNAL_MODULE__interfaces_index_mjs__.M2MFieldInterface,
            __WEBPACK_EXTERNAL_MODULE__interfaces_index_mjs__.M2OFieldInterface,
            __WEBPACK_EXTERNAL_MODULE__interfaces_index_mjs__.MarkdownFieldInterface,
            __WEBPACK_EXTERNAL_MODULE__interfaces_index_mjs__.MultipleSelectFieldInterface,
            __WEBPACK_EXTERNAL_MODULE__interfaces_index_mjs__.NumberFieldInterface,
            __WEBPACK_EXTERNAL_MODULE__interfaces_index_mjs__.O2MFieldInterface,
            __WEBPACK_EXTERNAL_MODULE__interfaces_index_mjs__.O2OFieldInterface,
            __WEBPACK_EXTERNAL_MODULE__interfaces_index_mjs__.OHOFieldInterface,
            __WEBPACK_EXTERNAL_MODULE__interfaces_index_mjs__.OBOFieldInterface,
            __WEBPACK_EXTERNAL_MODULE__interfaces_index_mjs__.PasswordFieldInterface,
            __WEBPACK_EXTERNAL_MODULE__interfaces_index_mjs__.PercentFieldInterface,
            __WEBPACK_EXTERNAL_MODULE__interfaces_index_mjs__.PhoneFieldInterface,
            __WEBPACK_EXTERNAL_MODULE__interfaces_index_mjs__.RadioGroupFieldInterface,
            __WEBPACK_EXTERNAL_MODULE__interfaces_index_mjs__.RichTextFieldInterface,
            __WEBPACK_EXTERNAL_MODULE__interfaces_index_mjs__.SelectFieldInterface,
            __WEBPACK_EXTERNAL_MODULE__interfaces_index_mjs__.SubTableFieldInterface,
            __WEBPACK_EXTERNAL_MODULE__interfaces_index_mjs__.TableoidFieldInterface,
            __WEBPACK_EXTERNAL_MODULE__interfaces_index_mjs__.TextareaFieldInterface,
            __WEBPACK_EXTERNAL_MODULE__interfaces_index_mjs__.TimeFieldInterface,
            __WEBPACK_EXTERNAL_MODULE__interfaces_index_mjs__.UpdatedAtFieldInterface,
            __WEBPACK_EXTERNAL_MODULE__interfaces_index_mjs__.UpdatedByFieldInterface,
            __WEBPACK_EXTERNAL_MODULE__interfaces_index_mjs__.UrlFieldInterface,
            __WEBPACK_EXTERNAL_MODULE__interfaces_index_mjs__.SortFieldInterface,
            __WEBPACK_EXTERNAL_MODULE__interfaces_index_mjs__.UUIDFieldInterface,
            __WEBPACK_EXTERNAL_MODULE__interfaces_index_mjs__.NanoidFieldInterface,
            __WEBPACK_EXTERNAL_MODULE__interfaces_index_mjs__.UnixTimestampFieldInterface
        ]);
    }
    addCollectionTemplates() {
        this.dataSourceManager.addCollectionTemplates([
            __WEBPACK_EXTERNAL_MODULE__templates_index_mjs__.GeneralCollectionTemplate,
            __WEBPACK_EXTERNAL_MODULE__templates_index_mjs__.ExpressionCollectionTemplate,
            __WEBPACK_EXTERNAL_MODULE__templates_index_mjs__.SqlCollectionTemplate,
            __WEBPACK_EXTERNAL_MODULE__templates_index_mjs__.TreeCollectionTemplate,
            __WEBPACK_EXTERNAL_MODULE__templates_index_mjs__.ViewCollectionTemplate,
            __WEBPACK_EXTERNAL_MODULE__templates_index_mjs__.ImportCollectionTemplate
        ]);
    }
}
export { CollectionPlugin };
