import { delegateCombine, delegateRemove } from "igniteui-webcomponents-core";
import { SummaryOperand_$type } from "igniteui-webcomponents-core";
import { IgcFormatSummaryTextEventArgs } from "./igc-format-summary-text-event-args";
import { IgcProvideCalculatorEventArgs } from "igniteui-webcomponents-core";
import { ColumnSummaryDescription as ColumnSummaryDescription_internal } from "./ColumnSummaryDescription";
import { ensureEnum, arrayFindByName } from "igniteui-webcomponents-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.
*/
export class IgcColumnSummaryDescription {
    constructor() {
        this._formatText = null;
        this._formatText_wrapped = null;
        this._provideCalculator = null;
        this._provideCalculator_wrapped = null;
        this._implementation = this.createImplementation();
        this._implementation.externalObject = this;
        this.onImplementationCreated();
    }
    createImplementation() {
        return new ColumnSummaryDescription_internal(0);
    }
    /**
     * @hidden
     */
    get i() {
        return this._implementation;
    }
    onImplementationCreated() {
    }
    _provideImplementation(i) {
        this._implementation = i;
        this._implementation.externalObject = this;
        this.onImplementationCreated();
    }
    get field() {
        return this.i.af;
    }
    set field(v) {
        this.i.af = v;
    }
    get operand() {
        return this.i.n;
    }
    set operand(v) {
        this.i.n = ensureEnum(SummaryOperand_$type, v);
    }
    /**
     * Gets or sets the name to use when displaying the calculator name.
    */
    get calculatorDisplayName() {
        return this.i.ac;
    }
    set calculatorDisplayName(v) {
        this.i.ac = v;
    }
    /**
     * Gets or sets the display name for the summary.
    */
    get displayName() {
        return this.i.ae;
    }
    set displayName(v) {
        this.i.ae = v;
    }
    /**
     * Gets or sets the format string for the summary value.
    */
    get valueFormat() {
        return this.i.ag;
    }
    set valueFormat(v) {
        this.i.ag = v;
    }
    /**
     * Gets or sets the format specifiers to use with the ValueFormat string.
    */
    get valueFormatSpecifiers() {
        return this.i.d;
    }
    set valueFormatSpecifiers(v) {
        this.i.d = v;
    }
    /**
     * Gets or sets the display format for the summary when in list display mode.
    */
    get displayFormat() {
        return this.i.ad;
    }
    set displayFormat(v) {
        this.i.ad = v;
    }
    /**
     * Gets or sets the format specifiers to use with the DisplayFormat string.
    */
    get displayFormatSpecifiers() {
        return this.i.c;
    }
    set displayFormatSpecifiers(v) {
        this.i.c = v;
    }
    /**
     * Gets or sets an INTL.DateTimeFormat or INTL.NumericFormat to use to format the value.
    */
    get formatOverride() {
        return this.i.w;
    }
    set formatOverride(v) {
        this.i.w = v;
    }
    /**
     * Gets or sets the minimum fraction digits. If FormatOverride is specificied this value is ignored.
    */
    get maxFractionDigits() {
        return this.i.u;
    }
    set maxFractionDigits(v) {
        this.i.u = +v;
    }
    findByName(name) {
        if (this.valueFormatSpecifiers != null && arrayFindByName(this.valueFormatSpecifiers, name)) {
            return arrayFindByName(this.valueFormatSpecifiers, name);
        }
        if (this.displayFormatSpecifiers != null && arrayFindByName(this.displayFormatSpecifiers, name)) {
            return arrayFindByName(this.displayFormatSpecifiers, name);
        }
        return null;
    }
    equals(other) {
        let iv = this.i.equals(other);
        return (iv);
    }
    /**
     * Called when the value is being formatted.
    */
    get formatText() {
        return this._formatText;
    }
    set formatText(ev) {
        if (this._formatText_wrapped !== null) {
            this.i.formatText = delegateRemove(this.i.formatText, this._formatText_wrapped);
            this._formatText_wrapped = null;
            this._formatText = null;
        }
        this._formatText = ev;
        this._formatText_wrapped = (o, e) => {
            let outerArgs = new IgcFormatSummaryTextEventArgs();
            outerArgs._provideImplementation(e);
            if (this.beforeFormatText) {
                this.beforeFormatText(this, outerArgs);
            }
            if (this._formatText) {
                this._formatText(this, outerArgs);
            }
        };
        this.i.formatText = delegateCombine(this.i.formatText, this._formatText_wrapped);
    }
    /**
     * Called when the summary calculator is required.
    */
    get provideCalculator() {
        return this._provideCalculator;
    }
    set provideCalculator(ev) {
        if (this._provideCalculator_wrapped !== null) {
            this.i.provideCalculator = delegateRemove(this.i.provideCalculator, this._provideCalculator_wrapped);
            this._provideCalculator_wrapped = null;
            this._provideCalculator = null;
        }
        this._provideCalculator = ev;
        this._provideCalculator_wrapped = (o, e) => {
            let outerArgs = new IgcProvideCalculatorEventArgs();
            outerArgs._provideImplementation(e);
            if (this.beforeProvideCalculator) {
                this.beforeProvideCalculator(this, outerArgs);
            }
            if (this._provideCalculator) {
                this._provideCalculator(this, outerArgs);
            }
        };
        this.i.provideCalculator = delegateCombine(this.i.provideCalculator, this._provideCalculator_wrapped);
    }
}
//# sourceMappingURL=igc-column-summary-description.js.map
