import { DragDropModule } from '@angular/cdk/drag-drop';
import { CommonModule } from '@angular/common';
import { Component, DestroyRef, computed, effect, inject, input, output, signal } from '@angular/core';
import { takeUntilDestroyed, toObservable } from '@angular/core/rxjs-interop';
import { FormBuilder, FormControl, ReactiveFormsModule, Validators } from '@angular/forms';
import { MatButtonModule } from '@angular/material/button';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatIconModule } from '@angular/material/icon';
import { MatInputModule } from '@angular/material/input';
import { MatRadioModule } from '@angular/material/radio';
import { MatSelectModule } from '@angular/material/select';
import { NgmCommonModule } from '@metad/ocap-angular/common';
import { NgmDSCoreService } from '@metad/ocap-angular/core';
import { CalculationType, Syntax, isEntityType, nonNullable, uuid } from '@metad/ocap-core';
import { TranslateModule } from '@ngx-translate/core';
import { EMPTY, filter, switchMap } from 'rxjs';
import { NgmCalculatedMeasureComponent } from '../calculated-measure/calculated-measure.component';
import { NgmCalculationVarianceComponent } from '../calculation-variance/variance.component';
import { NgmConditionalAggregationComponent } from '../conditional-aggregation/conditional-aggregation.component';
import { NgmMeasureControlComponent } from '../measure-control/measure-control.component';
import { NgmRestrictedMeasureComponent } from '../restricted-measure/restricted-measure.component';
import * as i0 from "@angular/core";
import * as i1 from "@angular/common";
import * as i2 from "@angular/forms";
import * as i3 from "@ngx-translate/core";
import * as i4 from "@angular/cdk/drag-drop";
import * as i5 from "@angular/material/form-field";
import * as i6 from "@angular/material/icon";
import * as i7 from "@angular/material/button";
import * as i8 from "@angular/material/radio";
import * as i9 from "@angular/material/input";
import * as i10 from "@metad/ocap-angular/core";
export class NgmCalculationEditorComponent {
    /**
    |--------------------------------------------------------------------------
    | Signals
    |--------------------------------------------------------------------------
    */
    #syntax;
    constructor() {
        /**
        |--------------------------------------------------------------------------
        | Types
        |--------------------------------------------------------------------------
        */
        this.CALCULATION_TYPE = CalculationType;
        this.SYNTAX = Syntax;
        /**
        |--------------------------------------------------------------------------
        | Injectors
        |--------------------------------------------------------------------------
        */
        this.destroyRef = inject(DestroyRef);
        this.fb = inject(FormBuilder);
        this.dsCoreService = inject(NgmDSCoreService, { optional: true });
        this.dialogRef = inject((MatDialogRef), { optional: true });
        this.data = inject(MAT_DIALOG_DATA, { optional: true });
        /**
        |--------------------------------------------------------------------------
        | Inputs & Outputs
        |--------------------------------------------------------------------------
        */
        this.appearance = input('fill');
        this.dataSettings = input();
        this.value = input();
        this.apply = output();
        /**
        |--------------------------------------------------------------------------
        | Signals
        |--------------------------------------------------------------------------
        */
        this.#syntax = signal(null);
        this._dataSettings = signal(null);
        this.entityType = signal(null);
        this.entitySyntax = computed(() => this.#syntax() ?? this.entityType()?.syntax);
        this.formGroup = this.fb.group({
            __id__: uuid(),
            calculationType: [CalculationType.Calculated, Validators.required],
            name: ['', [Validators.required, this.forbiddenNameValidator()]],
            caption: [''],
            formatting: this.fb.group({
                unit: [null],
                decimal: [null]
            })
        });
        this.calculationType = this.formGroup.get('calculationType');
        this.name = this.formGroup.get('name');
        this.caption = this.formGroup.get('caption');
        this.unit = this.formGroup.get('formatting').get('unit');
        this.calculation = new FormControl();
        this.formula = new FormControl();
        /**
        |--------------------------------------------------------------------------
        | Subscriptions (effects)
        |--------------------------------------------------------------------------
        */
        this.entityTypeSub = toObservable(this._dataSettings)
            .pipe(filter(nonNullable), switchMap((dataSettings) => this.dsCoreService
            ?.getDataSource(dataSettings.dataSource)
            .pipe(switchMap((dataSource) => dataSource.selectEntityType(dataSettings.entitySet).pipe(filter(isEntityType)))) ?? EMPTY), takeUntilDestroyed())
            .subscribe((entityType) => this.entityType.set(entityType));
        if (this.data?.dsCoreService) {
            this.dsCoreService = this.data?.dsCoreService;
        }
        effect(() => {
            if (this.dataSettings()) {
                this._dataSettings.set(this.dataSettings());
            }
        }, { allowSignalWrites: true });
        effect(() => {
            if (this.value()) {
                this.initValue(this.value());
            }
        });
    }
    ngOnInit() {
        if (this.data) {
            this._dataSettings.set(this.data.dataSettings);
            this.#syntax.set(this.data.syntax);
        }
        if (this.data?.value) {
            this.initValue(this.data.value);
        }
    }
    initValue(value) {
        this.disableSelect = true;
        this.formGroup.get('calculationType').disable();
        this.formGroup.get('name').disable();
        this.formGroup.patchValue(value);
        this.formGroup.markAsPristine();
        this.calculation.setValue({
            ...value
        });
        this.calculation.markAsPristine();
        this.formula.setValue(value.formula);
        this.formula.markAsPristine();
    }
    onApply() {
        const property = {
            ...this.calculation.value,
            ...this.formGroup.value,
            calculationType: this.calculationType.value,
            formula: this.calculationType.value === CalculationType.Calculated ? this.formula.value : null,
            name: this.name.value,
            visible: true
        };
        this.dialogRef?.close(property);
        this.apply.emit(property);
    }
    onCancel() {
        this.dialogRef?.close();
        this.apply.emit(null);
    }
    forbiddenNameValidator() {
        return (control) => {
            const forbidden = !this.disableSelect &&
                this.entityType()?.properties &&
                !!Object.values(this.entityType().properties).find((item) => item.name === control.value);
            return forbidden ? { forbiddenName: { value: control.value } } : null;
        };
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.10", ngImport: i0, type: NgmCalculationEditorComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "17.3.10", type: NgmCalculationEditorComponent, isStandalone: true, selector: "ngm-calculation-editor", inputs: { appearance: { classPropertyName: "appearance", publicName: "appearance", isSignal: true, isRequired: false, transformFunction: null }, dataSettings: { classPropertyName: "dataSettings", publicName: "dataSettings", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { apply: "apply" }, ngImport: i0, template: "<div class=\"flex-1 flex overflow-hidden\">\n\n    <div class=\"ngm-theme-dark dark w-[300px] shrink-0 flex flex-col justify-start overflow-auto bg-bluegray-700 text-white p-4 group\">\n        <div class=\"w-full flex justify-start items-center mb-2\" cdkDrag cdkDragRootElement=\".cdk-overlay-pane\" cdkDragHandle\n            [cdkDragDisabled]=\"!dialogRef\"\n        >\n          @if (dialogRef) {\n            <mat-icon displayDensity=\"cosy\" class=\"-ml-2 opacity-0 group-hover:opacity-80\">drag_indicator</mat-icon>\n          }\n            <span class=\"text-lg pointer-events-none\">\n                {{ 'Ngm.Calculation.TITLE' | translate: {Default: \"Calculation Editor\"} }}\n            </span>\n        </div>\n\n        <div class=\"flex flex-col justify-start items-stretch\">\n            <mat-form-field appearance=\"fill\" color=\"accent\">\n                <mat-label>\n                    {{ 'Ngm.Calculation.Name' | translate: {Default: \"Name\"} }}\n                </mat-label>\n                <input matInput [formControl]=\"name\" required>\n                <mat-error *ngIf=\"name.invalid\">\n                    {{ 'Ngm.Calculation.NameRequired' | translate: {Default: \"Name required or existed\"} }}\n                </mat-error>\n            </mat-form-field>\n\n            <mat-form-field appearance=\"fill\" color=\"accent\">\n                <mat-label>\n                    {{ 'Ngm.Calculation.Caption' | translate: {Default: \"Caption\"} }}\n                </mat-label>\n                <input matInput [formControl]=\"caption\">\n            </mat-form-field>\n        </div>\n\n        <div class=\"flex-1 flex flex-col\">\n            <label id=\"ngm-radio-group__label my-2\">{{ 'Ngm.Calculation.TYPE' | translate: {Default: \"Type\"} }}</label>\n            <mat-radio-group color=\"accent\"\n                class=\"flex flex-col justify-start items-stretch mb-4\"\n                [formControl]=\"calculationType\">\n                <mat-radio-button [value]=\"CALCULATION_TYPE.Calculated\" class=\"p-2 rounded-lg hover:bg-white/20\">\n                    {{ 'Ngm.Calculation.CALCULATED_MEASURE' | translate: {Default: \"Calculated Measure\"} }}\n                </mat-radio-button>\n                <mat-radio-button [value]=\"CALCULATION_TYPE.Restricted\" [disabled]=\"entitySyntax()!==SYNTAX.MDX\" class=\"p-2 rounded-lg hover:bg-white/20\">\n                    {{ 'Ngm.Calculation.RESTRICTED_MEASURE' | translate: {Default: \"Restricted Measure\"} }}\n                </mat-radio-button>\n                <mat-radio-button [value]=\"CALCULATION_TYPE.Variance\" [disabled]=\"entitySyntax()!==SYNTAX.MDX\" class=\"p-2 rounded-lg hover:bg-white/20\">\n                    {{ 'Ngm.Calculation.VARIANCE_MEASURE' | translate: {Default: \"Variance Measure\"} }}\n                </mat-radio-button>\n                <mat-radio-button [value]=\"CALCULATION_TYPE.Aggregation\" [disabled]=\"entitySyntax()!==SYNTAX.MDX\" class=\"p-2 rounded-lg hover:bg-white/20\">\n                    {{ 'Ngm.Calculation.ConditionalAggregation' | translate: {Default: \"Conditional Aggregation\"} }}\n                </mat-radio-button>\n                <mat-radio-button [value]=\"CALCULATION_TYPE.D2Measure\" disabled class=\"p-2 rounded-lg hover:bg-white/20\">\n                    {{ 'Ngm.Calculation.DIMENSION_TO_MEASURE' | translate: {Default: \"Dimension to Measure\"} }}\n                </mat-radio-button>\n                <mat-radio-button [value]=\"CALCULATION_TYPE.MeasureControl\" class=\"p-2 rounded-lg hover:bg-white/20\">\n                    {{ 'Ngm.Calculation.MEASURE_CONTROL' | translate: {Default: \"Measure Control\"} }}\n                </mat-radio-button>\n            </mat-radio-group>\n\n            <div *ngIf=\"calculationType.value === CALCULATION_TYPE.Calculated\">\n                <mat-form-field class=\"w-full\" appearance=\"fill\" color=\"accent\">\n                    <mat-label>\n                        {{ 'Ngm.Calculation.Unit' | translate: {Default: \"Unit\"} }}\n                    </mat-label>\n                    <input matInput [formControl]=\"unit\">\n                </mat-form-field>\n            </div>\n        </div>\n\n        <div class=\"flex justify-start\">\n            <div ngmButtonGroup>\n                <button mat-raised-button color=\"accent\" cdkFocusInitial [disabled]=\"formGroup.invalid ||\n                    calculation.invalid ||\n                    (formGroup.pristine && formula.pristine && calculation.pristine)\"\n                    (click)=\"onApply()\"\n                >\n                    {{ 'Ngm.Common.Apply' | translate: {Default: 'Apply'} }}\n                </button>\n                <button mat-button (click)=\"onCancel()\">\n                    {{ 'Ngm.Common.Cancel' | translate: {Default: 'Cancel'} }}\n                </button>\n            </div>\n        </div>\n    </div>\n\n    <div class=\"mat-typography flex-1 flex flex-col justify-start items-stretch overflow-hidden\" cdkDropListGroup>\n        @switch (calculationType.value) {\n            @case (CALCULATION_TYPE.Calculated) {\n                <!--\n                    <ngm-calculation-sql *ngSwitchCase=\"SYNTAX.SQL\"\n                    [dataSettings]=\"_dataSettings()\"\n                    [entityType]=\"entityType()\"\n                    [coreService]=\"coreService\"\n                    [(ngModel)]=\"calculation\"\n                >\n                </ngm-calculation-sql> -->\n                <ngm-calculated-measure story class=\"max-w-full h-full\"\n                    [dataSettings]=\"_dataSettings()\"\n                    [entityType]=\"entityType()\"\n                    [syntax]=\"entitySyntax()\"\n                    [formControl]=\"formula\"\n                    >\n                </ngm-calculated-measure>\n            }\n            @case (CALCULATION_TYPE.Restricted) {\n                <ngm-restricted-measure class=\"sub-calculation\"\n                    [dataSettings]=\"_dataSettings()\"\n                    [entityType]=\"entityType()\"\n                    [formControl]=\"calculation\">\n                </ngm-restricted-measure>\n            }\n            @case (CALCULATION_TYPE.Aggregation) {\n                <ngm-conditional-aggregation class=\"sub-calculation\"\n                    [dsCoreService]=\"dsCoreService\"\n                    [dataSettings]=\"_dataSettings()\"\n                    [entityType]=\"entityType()\"\n                    [formControl]=\"calculation\">\n                </ngm-conditional-aggregation>\n            }\n            @case (CALCULATION_TYPE.Variance) {\n                <ngm-calculation-variance class=\"sub-calculation\"\n                    [dsCoreService]=\"dsCoreService\"\n                    [dataSettings]=\"_dataSettings()\"\n                    [entityType]=\"entityType()\"\n                    [formControl]=\"calculation\"\n                />\n            }\n            @case (CALCULATION_TYPE.MeasureControl) {\n                <ngm-measure-control class=\"sub-calculation\"\n                    [entityType]=\"entityType()\"\n                    [formControl]=\"calculation\"\n                    >\n                </ngm-measure-control>\n            }\n        }\n    </div>\n\n</div>", styles: [":host{display:flex;flex-direction:row;flex:1;max-width:100%;overflow:hidden}:host .mat-mdc-radio-group{--mdc-radio-state-layer-size: 28px}.mat-mdc-nav-list .mat-mdc-list-item{border-radius:.5rem;--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity));transition-duration:.3s}.mat-mdc-nav-list .mat-mdc-list-item.active{--tw-bg-opacity: 1;background-color:rgb(248 250 252 / var(--tw-bg-opacity));--tw-text-opacity: 1;color:rgb(100 116 139 / var(--tw-text-opacity))}.sub-calculation{min-width:400px;padding:1rem}::ng-deep .mdc-dialog__container .ngm-calculated-measure{min-width:600px}\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.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "directive", type: i2.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "ngmodule", type: TranslateModule }, { kind: "pipe", type: i3.TranslatePipe, name: "translate" }, { kind: "ngmodule", type: DragDropModule }, { kind: "directive", type: i4.CdkDropListGroup, selector: "[cdkDropListGroup]", inputs: ["cdkDropListGroupDisabled"], exportAs: ["cdkDropListGroup"] }, { kind: "directive", type: i4.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: i4.CdkDragHandle, selector: "[cdkDragHandle]", inputs: ["cdkDragHandleDisabled"] }, { kind: "ngmodule", type: MatFormFieldModule }, { kind: "component", type: i5.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i5.MatLabel, selector: "mat-label" }, { kind: "directive", type: i5.MatError, selector: "mat-error, [matError]", inputs: ["id"] }, { kind: "ngmodule", type: MatSelectModule }, { kind: "ngmodule", type: MatIconModule }, { kind: "component", type: i6.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "ngmodule", type: MatButtonModule }, { kind: "component", type: i7.MatButton, selector: "    button[mat-button], button[mat-raised-button], button[mat-flat-button],    button[mat-stroked-button]  ", exportAs: ["matButton"] }, { kind: "ngmodule", type: MatRadioModule }, { kind: "directive", type: i8.MatRadioGroup, selector: "mat-radio-group", inputs: ["color", "name", "labelPosition", "value", "selected", "disabled", "required"], outputs: ["change"], exportAs: ["matRadioGroup"] }, { kind: "component", type: i8.MatRadioButton, selector: "mat-radio-button", inputs: ["id", "name", "aria-label", "aria-labelledby", "aria-describedby", "disableRipple", "tabIndex", "checked", "value", "labelPosition", "disabled", "required", "color"], outputs: ["change"], exportAs: ["matRadioButton"] }, { kind: "ngmodule", type: MatInputModule }, { kind: "directive", type: i9.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl],      input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly"], exportAs: ["matInput"] }, { kind: "ngmodule", type: NgmCommonModule }, { kind: "directive", type: i10.DensityDirective, selector: "[displayDensity]", inputs: ["displayDensity"] }, { kind: "directive", type: i10.ButtonGroupDirective, selector: "[ngmButtonGroup]" }, { kind: "component", type: NgmCalculatedMeasureComponent, selector: "ngm-calculated-measure", inputs: ["dsCoreService", "dataSettings", "entityType", "syntax", "story", "disabled", "opened", "drawerOpened"], outputs: ["drawerOpenedChange"] }, { kind: "component", type: NgmCalculationVarianceComponent, selector: "ngm-calculation-variance", inputs: ["dsCoreService", "dataSettings", "entityType"] }, { kind: "component", type: NgmConditionalAggregationComponent, selector: "ngm-conditional-aggregation", inputs: ["dataSettings", "entityType", "dsCoreService"] }, { kind: "component", type: NgmRestrictedMeasureComponent, selector: "ngm-restricted-measure", inputs: ["disabled", "dataSettings", "entityType"] }, { kind: "component", type: NgmMeasureControlComponent, selector: "ngm-measure-control", inputs: ["entityType"] }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.10", ngImport: i0, type: NgmCalculationEditorComponent, decorators: [{
            type: Component,
            args: [{ standalone: true, imports: [
                        CommonModule,
                        ReactiveFormsModule,
                        TranslateModule,
                        DragDropModule,
                        MatFormFieldModule,
                        MatSelectModule,
                        MatIconModule,
                        MatButtonModule,
                        MatRadioModule,
                        MatInputModule,
                        NgmCommonModule,
                        NgmCalculatedMeasureComponent,
                        NgmCalculationVarianceComponent,
                        NgmConditionalAggregationComponent,
                        NgmRestrictedMeasureComponent,
                        NgmMeasureControlComponent
                    ], selector: 'ngm-calculation-editor', template: "<div class=\"flex-1 flex overflow-hidden\">\n\n    <div class=\"ngm-theme-dark dark w-[300px] shrink-0 flex flex-col justify-start overflow-auto bg-bluegray-700 text-white p-4 group\">\n        <div class=\"w-full flex justify-start items-center mb-2\" cdkDrag cdkDragRootElement=\".cdk-overlay-pane\" cdkDragHandle\n            [cdkDragDisabled]=\"!dialogRef\"\n        >\n          @if (dialogRef) {\n            <mat-icon displayDensity=\"cosy\" class=\"-ml-2 opacity-0 group-hover:opacity-80\">drag_indicator</mat-icon>\n          }\n            <span class=\"text-lg pointer-events-none\">\n                {{ 'Ngm.Calculation.TITLE' | translate: {Default: \"Calculation Editor\"} }}\n            </span>\n        </div>\n\n        <div class=\"flex flex-col justify-start items-stretch\">\n            <mat-form-field appearance=\"fill\" color=\"accent\">\n                <mat-label>\n                    {{ 'Ngm.Calculation.Name' | translate: {Default: \"Name\"} }}\n                </mat-label>\n                <input matInput [formControl]=\"name\" required>\n                <mat-error *ngIf=\"name.invalid\">\n                    {{ 'Ngm.Calculation.NameRequired' | translate: {Default: \"Name required or existed\"} }}\n                </mat-error>\n            </mat-form-field>\n\n            <mat-form-field appearance=\"fill\" color=\"accent\">\n                <mat-label>\n                    {{ 'Ngm.Calculation.Caption' | translate: {Default: \"Caption\"} }}\n                </mat-label>\n                <input matInput [formControl]=\"caption\">\n            </mat-form-field>\n        </div>\n\n        <div class=\"flex-1 flex flex-col\">\n            <label id=\"ngm-radio-group__label my-2\">{{ 'Ngm.Calculation.TYPE' | translate: {Default: \"Type\"} }}</label>\n            <mat-radio-group color=\"accent\"\n                class=\"flex flex-col justify-start items-stretch mb-4\"\n                [formControl]=\"calculationType\">\n                <mat-radio-button [value]=\"CALCULATION_TYPE.Calculated\" class=\"p-2 rounded-lg hover:bg-white/20\">\n                    {{ 'Ngm.Calculation.CALCULATED_MEASURE' | translate: {Default: \"Calculated Measure\"} }}\n                </mat-radio-button>\n                <mat-radio-button [value]=\"CALCULATION_TYPE.Restricted\" [disabled]=\"entitySyntax()!==SYNTAX.MDX\" class=\"p-2 rounded-lg hover:bg-white/20\">\n                    {{ 'Ngm.Calculation.RESTRICTED_MEASURE' | translate: {Default: \"Restricted Measure\"} }}\n                </mat-radio-button>\n                <mat-radio-button [value]=\"CALCULATION_TYPE.Variance\" [disabled]=\"entitySyntax()!==SYNTAX.MDX\" class=\"p-2 rounded-lg hover:bg-white/20\">\n                    {{ 'Ngm.Calculation.VARIANCE_MEASURE' | translate: {Default: \"Variance Measure\"} }}\n                </mat-radio-button>\n                <mat-radio-button [value]=\"CALCULATION_TYPE.Aggregation\" [disabled]=\"entitySyntax()!==SYNTAX.MDX\" class=\"p-2 rounded-lg hover:bg-white/20\">\n                    {{ 'Ngm.Calculation.ConditionalAggregation' | translate: {Default: \"Conditional Aggregation\"} }}\n                </mat-radio-button>\n                <mat-radio-button [value]=\"CALCULATION_TYPE.D2Measure\" disabled class=\"p-2 rounded-lg hover:bg-white/20\">\n                    {{ 'Ngm.Calculation.DIMENSION_TO_MEASURE' | translate: {Default: \"Dimension to Measure\"} }}\n                </mat-radio-button>\n                <mat-radio-button [value]=\"CALCULATION_TYPE.MeasureControl\" class=\"p-2 rounded-lg hover:bg-white/20\">\n                    {{ 'Ngm.Calculation.MEASURE_CONTROL' | translate: {Default: \"Measure Control\"} }}\n                </mat-radio-button>\n            </mat-radio-group>\n\n            <div *ngIf=\"calculationType.value === CALCULATION_TYPE.Calculated\">\n                <mat-form-field class=\"w-full\" appearance=\"fill\" color=\"accent\">\n                    <mat-label>\n                        {{ 'Ngm.Calculation.Unit' | translate: {Default: \"Unit\"} }}\n                    </mat-label>\n                    <input matInput [formControl]=\"unit\">\n                </mat-form-field>\n            </div>\n        </div>\n\n        <div class=\"flex justify-start\">\n            <div ngmButtonGroup>\n                <button mat-raised-button color=\"accent\" cdkFocusInitial [disabled]=\"formGroup.invalid ||\n                    calculation.invalid ||\n                    (formGroup.pristine && formula.pristine && calculation.pristine)\"\n                    (click)=\"onApply()\"\n                >\n                    {{ 'Ngm.Common.Apply' | translate: {Default: 'Apply'} }}\n                </button>\n                <button mat-button (click)=\"onCancel()\">\n                    {{ 'Ngm.Common.Cancel' | translate: {Default: 'Cancel'} }}\n                </button>\n            </div>\n        </div>\n    </div>\n\n    <div class=\"mat-typography flex-1 flex flex-col justify-start items-stretch overflow-hidden\" cdkDropListGroup>\n        @switch (calculationType.value) {\n            @case (CALCULATION_TYPE.Calculated) {\n                <!--\n                    <ngm-calculation-sql *ngSwitchCase=\"SYNTAX.SQL\"\n                    [dataSettings]=\"_dataSettings()\"\n                    [entityType]=\"entityType()\"\n                    [coreService]=\"coreService\"\n                    [(ngModel)]=\"calculation\"\n                >\n                </ngm-calculation-sql> -->\n                <ngm-calculated-measure story class=\"max-w-full h-full\"\n                    [dataSettings]=\"_dataSettings()\"\n                    [entityType]=\"entityType()\"\n                    [syntax]=\"entitySyntax()\"\n                    [formControl]=\"formula\"\n                    >\n                </ngm-calculated-measure>\n            }\n            @case (CALCULATION_TYPE.Restricted) {\n                <ngm-restricted-measure class=\"sub-calculation\"\n                    [dataSettings]=\"_dataSettings()\"\n                    [entityType]=\"entityType()\"\n                    [formControl]=\"calculation\">\n                </ngm-restricted-measure>\n            }\n            @case (CALCULATION_TYPE.Aggregation) {\n                <ngm-conditional-aggregation class=\"sub-calculation\"\n                    [dsCoreService]=\"dsCoreService\"\n                    [dataSettings]=\"_dataSettings()\"\n                    [entityType]=\"entityType()\"\n                    [formControl]=\"calculation\">\n                </ngm-conditional-aggregation>\n            }\n            @case (CALCULATION_TYPE.Variance) {\n                <ngm-calculation-variance class=\"sub-calculation\"\n                    [dsCoreService]=\"dsCoreService\"\n                    [dataSettings]=\"_dataSettings()\"\n                    [entityType]=\"entityType()\"\n                    [formControl]=\"calculation\"\n                />\n            }\n            @case (CALCULATION_TYPE.MeasureControl) {\n                <ngm-measure-control class=\"sub-calculation\"\n                    [entityType]=\"entityType()\"\n                    [formControl]=\"calculation\"\n                    >\n                </ngm-measure-control>\n            }\n        }\n    </div>\n\n</div>", styles: [":host{display:flex;flex-direction:row;flex:1;max-width:100%;overflow:hidden}:host .mat-mdc-radio-group{--mdc-radio-state-layer-size: 28px}.mat-mdc-nav-list .mat-mdc-list-item{border-radius:.5rem;--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity));transition-duration:.3s}.mat-mdc-nav-list .mat-mdc-list-item.active{--tw-bg-opacity: 1;background-color:rgb(248 250 252 / var(--tw-bg-opacity));--tw-text-opacity: 1;color:rgb(100 116 139 / var(--tw-text-opacity))}.sub-calculation{min-width:400px;padding:1rem}::ng-deep .mdc-dialog__container .ngm-calculated-measure{min-width:600px}\n"] }]
        }], ctorParameters: () => [] });
//# sourceMappingURL=data:application/json;base64, 