import { EventEmitter } from '@angular/core';
import { delegateCombine } from "igniteui-angular-core";
import { DataSourceSummaryOperand_$type } from "igniteui-angular-core";
import { IgxProvideCalculatorEventArgs } from "igniteui-angular-core";
import { ChartSummaryDescription as ChartSummaryDescription_internal } from "./ChartSummaryDescription";
import { ensureEnum } from "igniteui-angular-core";
/**
 * Represents a summary that is applied to a datasource. Changes to this object are not observed or expected after it is initially assigned to a collection.
*/
var IgxChartSummaryDescription = /** @class */ /*@__PURE__*/ (function () {
    function IgxChartSummaryDescription() {
        this._provideCalculator = null;
        this._zoneRunner = null;
        this._implementation = this.createImplementation();
        this._implementation.externalObject = this;
        this.onImplementationCreated();
    }
    IgxChartSummaryDescription.prototype.createImplementation = function () {
        return new ChartSummaryDescription_internal(0);
    };
    Object.defineProperty(IgxChartSummaryDescription.prototype, "i", {
        /**
         * @hidden
         */
        get: function () {
            return this._implementation;
        },
        enumerable: false,
        configurable: true
    });
    IgxChartSummaryDescription.prototype.onImplementationCreated = function () {
    };
    IgxChartSummaryDescription.prototype._provideImplementation = function (i) {
        this._implementation = i;
        this._implementation.externalObject = this;
        this.onImplementationCreated();
    };
    Object.defineProperty(IgxChartSummaryDescription.prototype, "field", {
        get: function () {
            return this.i.p;
        },
        set: function (v) {
            this.i.p = v;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(IgxChartSummaryDescription.prototype, "operand", {
        get: function () {
            return this.i.c;
        },
        set: function (v) {
            this.i.c = ensureEnum(DataSourceSummaryOperand_$type, v);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(IgxChartSummaryDescription.prototype, "alias", {
        /**
         * Gets or sets an alias for the summary. Currently only used in aggregated data situations.
        */
        get: function () {
            return this.i.n;
        },
        set: function (v) {
            this.i.n = v;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(IgxChartSummaryDescription.prototype, "calculatorDisplayName", {
        /**
         * Gets or sets the name to use when displaying the calculator name.
        */
        get: function () {
            return this.i.o;
        },
        set: function (v) {
            this.i.o = v;
        },
        enumerable: false,
        configurable: true
    });
    IgxChartSummaryDescription.prototype.findByName = function (name) {
        if (this.findEphemera) {
            if (name && name.indexOf("@@e:") == 0) {
                return this.findEphemera(name);
            }
        }
        return null;
    };
    IgxChartSummaryDescription.prototype.equals = function (other) {
        var iv = this.i.equals(other);
        return (iv);
    };
    Object.defineProperty(IgxChartSummaryDescription.prototype, "provideCalculator", {
        /**
         * Called when the summary calculator is required.
        */
        get: function () {
            var _this = this;
            if (this._provideCalculator == null) {
                this._provideCalculator = new EventEmitter();
                this.i.provideCalculator = delegateCombine(this.i.provideCalculator, function (o, e) {
                    _this._runInZone(function () {
                        var outerArgs = new IgxProvideCalculatorEventArgs();
                        outerArgs._provideImplementation(e);
                        if (_this.beforeProvideCalculator) {
                            _this.beforeProvideCalculator(_this, outerArgs);
                        }
                        _this._provideCalculator.emit({
                            sender: _this,
                            args: outerArgs
                        });
                    });
                });
            }
            return this._provideCalculator;
        },
        enumerable: false,
        configurable: true
    });
    IgxChartSummaryDescription.prototype._runInZone = function (act) {
        if (this._zoneRunner != null) {
            this._zoneRunner(act);
        }
        else {
            act();
        }
    };
    return IgxChartSummaryDescription;
}());
export { IgxChartSummaryDescription };
