import { DragDropModule } from '@angular/cdk/drag-drop';
import { ScrollingModule } from '@angular/cdk/scrolling';
import { FlatTreeControl } from '@angular/cdk/tree';
import { CommonModule } from '@angular/common';
import { ChangeDetectionStrategy, Component, HostBinding, Input, effect, inject, input } from '@angular/core';
import { ReactiveFormsModule } from '@angular/forms';
import { MatButtonModule } from '@angular/material/button';
import { MatCheckboxModule } from '@angular/material/checkbox';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatIconModule } from '@angular/material/icon';
import { MatInputModule } from '@angular/material/input';
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
import { MatTooltipModule } from '@angular/material/tooltip';
import { MatTreeModule } from '@angular/material/tree';
import { NgmCommonModule } from '@metad/ocap-angular/common';
import { NgmDSCoreService, OcapCoreModule } from '@metad/ocap-angular/core';
import { TranslateModule, TranslateService } from '@ngx-translate/core';
import { EntitySchemaDataSource, EntitySchemaFlatNode } from './data-source';
import { EntityCapacity, EntitySchemaType } from './types';
import { A11yModule } from '@angular/cdk/a11y';
import * as i0 from "@angular/core";
import * as i1 from "@angular/common";
import * as i2 from "@angular/forms";
import * as i3 from "@angular/cdk/a11y";
import * as i4 from "@angular/material/tree";
import * as i5 from "@angular/material/icon";
import * as i6 from "@angular/material/button";
import * as i7 from "@angular/cdk/drag-drop";
import * as i8 from "@angular/material/progress-spinner";
import * as i9 from "@angular/material/tooltip";
import * as i10 from "@metad/ocap-angular/common";
import * as i11 from "@metad/ocap-angular/core";
export class NgmEntitySchemaComponent {
    get searchControl() {
        return this.dataSource.searchControl;
    }
    constructor() {
        this.EntitySchemaType = EntitySchemaType;
        this._isEntitySchemaComponent = true;
        this.translateService = inject(TranslateService);
        this._dsCoreService = inject(NgmDSCoreService, { optional: true });
        this.capacities = [
            EntityCapacity.Dimension,
            EntityCapacity.Measure,
        ];
        this.dataSettings = input();
        this.getLevel = (node) => node.level;
        this.isExpandable = (node) => node.expandable;
        this.hasChild = (_, _nodeData) => _nodeData.expandable;
        effect(() => {
            const dataSettings = this.dataSettings();
            if (dataSettings?.entitySet) {
                this.dataSource.dataSourceName = dataSettings.dataSource;
                const rootNode = new EntitySchemaFlatNode({
                    type: EntitySchemaType.Entity,
                    name: dataSettings.entitySet,
                    // caption: dataSettings.entitySet,
                }, 0, true);
                this.dataSource.data = [
                    rootNode
                ];
            }
        });
    }
    ngOnInit() {
        if (this.dsCoreService) {
            this._dsCoreService = this.dsCoreService;
        }
        this.treeControl = new FlatTreeControl(this.getLevel, this.isExpandable);
        this.dataSource = new EntitySchemaDataSource(this.treeControl, this._dsCoreService, this.translateService, this.capacities);
        this.dataSource.data = [];
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.10", ngImport: i0, type: NgmEntitySchemaComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "17.3.10", type: NgmEntitySchemaComponent, isStandalone: true, selector: "ngm-entity-schema", inputs: { dsCoreService: { classPropertyName: "dsCoreService", publicName: "dsCoreService", isSignal: false, isRequired: false, transformFunction: null }, appearance: { classPropertyName: "appearance", publicName: "appearance", isSignal: false, isRequired: false, transformFunction: null }, selectedHierarchy: { classPropertyName: "selectedHierarchy", publicName: "selectedHierarchy", isSignal: false, isRequired: false, transformFunction: null }, capacities: { classPropertyName: "capacities", publicName: "capacities", isSignal: false, isRequired: false, transformFunction: null }, dataSettings: { classPropertyName: "dataSettings", publicName: "dataSettings", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class.ngm-entity-schema": "this._isEntitySchemaComponent" } }, ngImport: i0, template: "<mat-tree [dataSource]=\"dataSource\" [treeControl]=\"treeControl\">\n  <mat-tree-node *matTreeNodeDef=\"let node\" matTreeNodePadding matTreeNodePaddingIndent=\"20\"\n    cdkDrag\n    [cdkDragData]=\"node.item\"\n    [class.selected]=\"selectedHierarchy && (\n      node.item.name === selectedHierarchy || node.item.hierarchy === selectedHierarchy || node.item.raw?.hierarchy === selectedHierarchy)\"\n    draggable=\"true\"\n  >\n    <button mat-icon-button disabled displayDensity=\"compact\">\n    </button>\n\n    @if (node.error) {\n      <mat-icon color=\"warn\" fontSet=\"material-icons-round\" displayDensity=\"compact\"\n        [matTooltip]=\"node.error\" matTooltipPosition=\"after\">\n        warning_amber\n      </mat-icon>\n    }\n\n    <div class=\"ngm-entity-schema__type\">{{node.item.type?.[0]}}</div>\n    <ngm-display-behaviour [option]=\"{value: node.item.name, caption: node.item.caption ?? node.item.label}\"\n      [highlight]=\"searchControl.value\">\n    </ngm-display-behaviour>\n    <div class=\"ngm-entity-schema__drag-placeholder\" *cdkDragPlaceholder></div>\n  </mat-tree-node>\n  <mat-tree-node *matTreeNodeDef=\"let node; when: hasChild\" matTreeNodePadding matTreeNodePaddingIndent=\"20\" class=\"group\"\n    cdkDrag\n    [cdkDragData]=\"node.item\"\n    [class.selected]=\"selectedHierarchy && (\n      node.item.name === selectedHierarchy || node.item.hierarchy === selectedHierarchy || node.item.raw?.hierarchy === selectedHierarchy)\"\n    draggable=\"true\"\n  >\n    <button *ngIf=\"!node.isLoading\" mat-icon-button\n            [attr.aria-label]=\"'Toggle ' + node.item\" matTreeNodeToggle>\n      <mat-icon class=\"mat-icon-rtl-mirror\" fontSet=\"material-icons-round\">\n        {{treeControl.isExpanded(node) ? 'arrow_drop_down' : 'arrow_right'}}\n      </mat-icon>\n    </button>\n    <mat-spinner *ngIf=\"node.isLoading\" class=\"m-2\" strokeWidth=\"1\" diameter=\"15\"></mat-spinner>\n\n    <div class=\"ngm-entity-schema__type\">{{node.item.type?.[0]}}</div>\n\n    <ngm-display-behaviour class=\"flex-1\" [option]=\"{value: node.item.name, caption: node.item.caption ?? node.item.label}\"\n      [highlight]=\"searchControl.value\">\n    </ngm-display-behaviour>\n\n    <ngm-search *ngIf=\"node.item.type === EntitySchemaType.Entity\" cdkMonitorSubtreeFocus\n      class=\"overflow-hidden\"\n      displayDensity=\"cosy\"\n      [formControl]=\"searchControl\">\n    </ngm-search>\n\n    <div class=\"ngm-entity-schema__drag-placeholder\" *cdkDragPlaceholder></div>\n  </mat-tree-node>\n</mat-tree>\n", styles: [":host{position:relative;display:flex;flex-direction:column}.mat-tree-node{min-height:30px}.mat-tree-node .mat-mdc-icon-button.mat-mdc-button-base{--mdc-icon-button-state-layer-size: 30px;padding:0}.ngm-display-behaviour{flex:1;overflow:hidden}.ngm-search{width:0px}.ngm-search.ngm-search__has-value,.ngm-search.cdk-focused,.group:hover .ngm-search{width:auto}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "ngmodule", type: A11yModule }, { kind: "directive", type: i3.CdkMonitorFocus, selector: "[cdkMonitorElementFocus], [cdkMonitorSubtreeFocus]", outputs: ["cdkFocusChange"], exportAs: ["cdkMonitorFocus"] }, { kind: "ngmodule", type: MatTreeModule }, { kind: "directive", type: i4.MatTreeNodeDef, selector: "[matTreeNodeDef]", inputs: ["matTreeNodeDefWhen", "matTreeNode"] }, { kind: "directive", type: i4.MatTreeNodePadding, selector: "[matTreeNodePadding]", inputs: ["matTreeNodePadding", "matTreeNodePaddingIndent"] }, { kind: "directive", type: i4.MatTreeNodeToggle, selector: "[matTreeNodeToggle]", inputs: ["matTreeNodeToggleRecursive"] }, { kind: "component", type: i4.MatTree, selector: "mat-tree", exportAs: ["matTree"] }, { kind: "directive", type: i4.MatTreeNode, selector: "mat-tree-node", inputs: ["disabled", "tabIndex"], exportAs: ["matTreeNode"] }, { kind: "ngmodule", type: MatFormFieldModule }, { kind: "ngmodule", type: MatInputModule }, { kind: "ngmodule", type: MatIconModule }, { kind: "component", type: i5.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "ngmodule", type: MatButtonModule }, { kind: "component", type: i6.MatIconButton, selector: "button[mat-icon-button]", exportAs: ["matButton"] }, { kind: "ngmodule", type: DragDropModule }, { kind: "directive", type: i7.CdkDrag, selector: "[cdkDrag]", inputs: ["cdkDragData", "cdkDragLockAxis", "cdkDragRootElement", "cdkDragBoundary", "cdkDragStartDelay", "cdkDragFreeDragPosition", "cdkDragDisabled", "cdkDragConstrainPosition", "cdkDragPreviewClass", "cdkDragPreviewContainer"], outputs: ["cdkDragStarted", "cdkDragReleased", "cdkDragEnded", "cdkDragEntered", "cdkDragExited", "cdkDragDropped", "cdkDragMoved"], exportAs: ["cdkDrag"] }, { kind: "directive", type: i7.CdkDragPlaceholder, selector: "ng-template[cdkDragPlaceholder]", inputs: ["data"] }, { kind: "ngmodule", type: ScrollingModule }, { kind: "ngmodule", type: TranslateModule }, { kind: "ngmodule", type: MatCheckboxModule }, { kind: "ngmodule", type: MatProgressSpinnerModule }, { kind: "component", type: i8.MatProgressSpinner, selector: "mat-progress-spinner, mat-spinner", inputs: ["color", "mode", "value", "diameter", "strokeWidth"], exportAs: ["matProgressSpinner"] }, { kind: "ngmodule", type: MatTooltipModule }, { kind: "directive", type: i9.MatTooltip, selector: "[matTooltip]", inputs: ["matTooltipPosition", "matTooltipPositionAtOrigin", "matTooltipDisabled", "matTooltipShowDelay", "matTooltipHideDelay", "matTooltipTouchGestures", "matTooltip", "matTooltipClass"], exportAs: ["matTooltip"] }, { kind: "ngmodule", type: NgmCommonModule }, { kind: "component", type: i10.NgmDisplayBehaviourComponent, selector: "ngm-display-behaviour", inputs: ["displayBehaviour", "excludeSelected", "option", "highlight"] }, { kind: "component", type: i10.NgmSearchComponent, selector: "ngm-search", inputs: ["formControl", "disabled", "displayDensity"] }, { kind: "directive", type: i11.DensityDirective, selector: "[displayDensity]", inputs: ["displayDensity"] }, { kind: "ngmodule", type: OcapCoreModule }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.10", ngImport: i0, type: NgmEntitySchemaComponent, decorators: [{
            type: Component,
            args: [{ standalone: true, imports: [
                        CommonModule,
                        ReactiveFormsModule,
                        A11yModule,
                        MatTreeModule,
                        MatFormFieldModule,
                        MatInputModule,
                        MatIconModule,
                        MatButtonModule,
                        DragDropModule,
                        ScrollingModule,
                        TranslateModule,
                        MatCheckboxModule,
                        MatProgressSpinnerModule,
                        MatTooltipModule,
                        NgmCommonModule,
                        OcapCoreModule,
                    ], changeDetection: ChangeDetectionStrategy.OnPush, selector: 'ngm-entity-schema', template: "<mat-tree [dataSource]=\"dataSource\" [treeControl]=\"treeControl\">\n  <mat-tree-node *matTreeNodeDef=\"let node\" matTreeNodePadding matTreeNodePaddingIndent=\"20\"\n    cdkDrag\n    [cdkDragData]=\"node.item\"\n    [class.selected]=\"selectedHierarchy && (\n      node.item.name === selectedHierarchy || node.item.hierarchy === selectedHierarchy || node.item.raw?.hierarchy === selectedHierarchy)\"\n    draggable=\"true\"\n  >\n    <button mat-icon-button disabled displayDensity=\"compact\">\n    </button>\n\n    @if (node.error) {\n      <mat-icon color=\"warn\" fontSet=\"material-icons-round\" displayDensity=\"compact\"\n        [matTooltip]=\"node.error\" matTooltipPosition=\"after\">\n        warning_amber\n      </mat-icon>\n    }\n\n    <div class=\"ngm-entity-schema__type\">{{node.item.type?.[0]}}</div>\n    <ngm-display-behaviour [option]=\"{value: node.item.name, caption: node.item.caption ?? node.item.label}\"\n      [highlight]=\"searchControl.value\">\n    </ngm-display-behaviour>\n    <div class=\"ngm-entity-schema__drag-placeholder\" *cdkDragPlaceholder></div>\n  </mat-tree-node>\n  <mat-tree-node *matTreeNodeDef=\"let node; when: hasChild\" matTreeNodePadding matTreeNodePaddingIndent=\"20\" class=\"group\"\n    cdkDrag\n    [cdkDragData]=\"node.item\"\n    [class.selected]=\"selectedHierarchy && (\n      node.item.name === selectedHierarchy || node.item.hierarchy === selectedHierarchy || node.item.raw?.hierarchy === selectedHierarchy)\"\n    draggable=\"true\"\n  >\n    <button *ngIf=\"!node.isLoading\" mat-icon-button\n            [attr.aria-label]=\"'Toggle ' + node.item\" matTreeNodeToggle>\n      <mat-icon class=\"mat-icon-rtl-mirror\" fontSet=\"material-icons-round\">\n        {{treeControl.isExpanded(node) ? 'arrow_drop_down' : 'arrow_right'}}\n      </mat-icon>\n    </button>\n    <mat-spinner *ngIf=\"node.isLoading\" class=\"m-2\" strokeWidth=\"1\" diameter=\"15\"></mat-spinner>\n\n    <div class=\"ngm-entity-schema__type\">{{node.item.type?.[0]}}</div>\n\n    <ngm-display-behaviour class=\"flex-1\" [option]=\"{value: node.item.name, caption: node.item.caption ?? node.item.label}\"\n      [highlight]=\"searchControl.value\">\n    </ngm-display-behaviour>\n\n    <ngm-search *ngIf=\"node.item.type === EntitySchemaType.Entity\" cdkMonitorSubtreeFocus\n      class=\"overflow-hidden\"\n      displayDensity=\"cosy\"\n      [formControl]=\"searchControl\">\n    </ngm-search>\n\n    <div class=\"ngm-entity-schema__drag-placeholder\" *cdkDragPlaceholder></div>\n  </mat-tree-node>\n</mat-tree>\n", styles: [":host{position:relative;display:flex;flex-direction:column}.mat-tree-node{min-height:30px}.mat-tree-node .mat-mdc-icon-button.mat-mdc-button-base{--mdc-icon-button-state-layer-size: 30px;padding:0}.ngm-display-behaviour{flex:1;overflow:hidden}.ngm-search{width:0px}.ngm-search.ngm-search__has-value,.ngm-search.cdk-focused,.group:hover .ngm-search{width:auto}\n"] }]
        }], ctorParameters: () => [], propDecorators: { _isEntitySchemaComponent: [{
                type: HostBinding,
                args: ['class.ngm-entity-schema']
            }], dsCoreService: [{
                type: Input
            }], appearance: [{
                type: Input
            }], selectedHierarchy: [{
                type: Input
            }], capacities: [{
                type: Input
            }] } });
//# sourceMappingURL=data:application/json;base64, 