import { ComponentStylingModel, ComponentStylingPropertiesControlComponent, genericPropertiesControlFor } from '@anglr/dynamic/layout-editor';
import { StackPanelFlexExtensionModel, StackPanelModel } from './stackPanel.model';
/**
 * Stack panel layout metadata
 */
export class StackPanelLayoutEditorMetadata {
    //######################### constructor #########################
    constructor() {
        //######################### public properties - implementation of LayoutEditorMetadataDescriptor #########################
        /**
         * @inheritdoc
         */
        this.metaInfo = {
            name: 'Stack',
            description: 'Layout component that stacks items horizontally or vertically',
            group: 'Layout',
            optionsMetadata: {
                propertiesMetadata: [
                    {
                        modelType: ComponentStylingModel,
                        propertiesControls: [
                            ComponentStylingPropertiesControlComponent,
                        ],
                    },
                    {
                        modelType: StackPanelModel,
                        propertiesControls: [
                            genericPropertiesControlFor(['horizontal', 'wrap'])
                        ],
                    },
                ],
                childPropertiesMetadata: [
                    {
                        modelType: StackPanelFlexExtensionModel,
                        propertiesControls: [
                            genericPropertiesControlFor(['flex'])
                        ],
                    },
                ]
            }
        };
        /**
         * @inheritdoc
         */
        this.addDescendant = (metadata, options, index) => {
            var _a;
            (_a = options.children) !== null && _a !== void 0 ? _a : (options.children = []);
            options.children.splice(index, 0, metadata);
        };
        /**
         * @inheritdoc
         */
        this.canDropMetadata = () => true;
        /**
         * @inheritdoc
         */
        this.isHorizontalDrop = options => !!(options === null || options === void 0 ? void 0 : options.horizontal);
        /**
         * @inheritdoc
         */
        this.removeDescendant = (id, options) => {
            var _a;
            (_a = options.children) !== null && _a !== void 0 ? _a : (options.children = []);
            const index = options.children.findIndex(itm => itm.id === id);
            options.children.splice(index, 1);
        };
        Object.freeze(this);
    }
}
//# sourceMappingURL=stackPanel.layoutMetadata.js.map