import * as tslib_1 from "tslib";
import { Component, forwardRef, Input, ChangeDetectionStrategy } from '@angular/core';
import { IgxRing } from "./igx-ring";
import { IgxRingSeriesBaseComponent } from "./igx-ring-series-base-component";
import { RingSeries } from "./RingSeries";
import { IgxIndexCollection } from "./igx-index-collection";
import { IndexCollection as IndexCollection_internal } from "./IndexCollection";
import { Number_$type } from "igniteui-angular-core";
import { SyncableObservableCollection$1 } from "igniteui-angular-core";
export var IgxRingSeriesComponent_PROVIDERS = [{ provide: IgxRingSeriesBaseComponent, useExisting: forwardRef(function () { return IgxRingSeriesComponent; }) }];
/**
 * Represents one ring in IgxDoughnutChartComponent series.
*/
var IgxRingSeriesComponent = /** @class */ (function (_super) {
    tslib_1.__extends(IgxRingSeriesComponent, _super);
    function IgxRingSeriesComponent() {
        var _this = _super.call(this) || this;
        _this._explodedSlices = null;
        _this._selectedSlices = null;
        return _this;
    }
    IgxRingSeriesComponent_1 = IgxRingSeriesComponent;
    IgxRingSeriesComponent.prototype.createImplementation = function () {
        return new RingSeries();
    };
    Object.defineProperty(IgxRingSeriesComponent.prototype, "i", {
        get: function () {
            return this._implementation;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(IgxRingSeriesComponent.prototype, "explodedSlices", {
        /**
         * Gets or sets the collection of exploded slice indices.
        */
        get: function () {
            if (this._explodedSlices === null) {
                var coll = new IgxIndexCollection();
                var innerColl = void 0;
                if (this.ring.i.ringControl.arcs.count == 0) {
                    innerColl = new IndexCollection_internal();
                }
                else {
                    innerColl = this.ring.i.ringControl.arcs.item(0).explodedSlices;
                }
                this._explodedSlices = coll._fromInner(innerColl);
            }
            return this._explodedSlices;
        },
        set: function (v) {
            if (this._explodedSlices !== null) {
                this._explodedSlices._setSyncTarget(null);
                this._explodedSlices = null;
            }
            var coll = new IgxIndexCollection();
            this._explodedSlices = coll._fromOuter(v);
            var syncColl = new SyncableObservableCollection$1(Number_$type);
            var innerColl;
            if (this.ring.i.ringControl.arcs.count == 0) {
                innerColl = new IndexCollection_internal();
            }
            else {
                innerColl = this.ring.i.ringControl.arcs.item(0).explodedSlices;
            }
            syncColl._inner = innerColl;
            syncColl.clear();
            this._explodedSlices._setSyncTarget(syncColl);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(IgxRingSeriesComponent.prototype, "selectedSlices", {
        /**
         * Gets or sets the collection of selected slice indices.
        */
        get: function () {
            if (this._selectedSlices === null) {
                var coll = new IgxIndexCollection();
                var innerColl = void 0;
                if (this.ring.i.ringControl.arcs.count == 0) {
                    innerColl = new IndexCollection_internal();
                }
                else {
                    innerColl = this.ring.i.ringControl.arcs.item(0).selectedSlices;
                }
                this._selectedSlices = coll._fromInner(innerColl);
            }
            return this._selectedSlices;
        },
        set: function (v) {
            if (this._selectedSlices !== null) {
                this._selectedSlices._setSyncTarget(null);
                this._selectedSlices = null;
            }
            var coll = new IgxIndexCollection();
            this._selectedSlices = coll._fromOuter(v);
            var syncColl = new SyncableObservableCollection$1(Number_$type);
            var innerColl;
            if (this.ring.i.ringControl.arcs.count == 0) {
                innerColl = new IndexCollection_internal();
            }
            else {
                innerColl = this.ring.i.ringControl.arcs.item(0).selectedSlices;
            }
            syncColl._inner = innerColl;
            syncColl.clear();
            this._selectedSlices._setSyncTarget(syncColl);
        },
        enumerable: true,
        configurable: true
    });
    IgxRingSeriesComponent.prototype.sychronizeCollections = function () {
        if (this._explodedSlices) {
            var inner = this._explodedSlices._inner;
            if (inner && inner !== this.ring.i.ringControl.arcs.item(0).explodedSlices) {
                this._explodedSlices._inner = this.ring.i.ringControl.arcs.item(0).explodedSlices;
                for (var i = 0; i < inner.count; i++) {
                    this._explodedSlices.add(inner.item(i));
                }
            }
        }
        if (this._selectedSlices) {
            var inner = this._selectedSlices._inner;
            if (inner && inner !== this.ring.i.ringControl.arcs.item(0).selectedSlices) {
                this._selectedSlices._inner = this.ring.i.ringControl.arcs.item(0).selectedSlices;
                for (var i = 0; i < inner.count; i++) {
                    this._selectedSlices.add(inner.item(i));
                }
            }
        }
    };
    Object.defineProperty(IgxRingSeriesComponent.prototype, "ring", {
        /**
     * Gets reference to the ring data.
    */
        get: function () {
            if (this.i.dx == null) {
                return null;
            }
            if (!this.i.dx.externalObject) {
                var e = new IgxRing();
                e._implementation = this.i.dx;
                this.i.dx.externalObject = e;
            }
            return this.i.dx.externalObject;
        },
        set: function (v) {
            v == null ? this.i.dx = null : this.i.dx = v.i;
        },
        enumerable: true,
        configurable: true
    });
    var IgxRingSeriesComponent_1;
    tslib_1.__decorate([
        Input(),
        tslib_1.__metadata("design:type", IgxIndexCollection),
        tslib_1.__metadata("design:paramtypes", [IgxIndexCollection])
    ], IgxRingSeriesComponent.prototype, "explodedSlices", null);
    tslib_1.__decorate([
        Input(),
        tslib_1.__metadata("design:type", IgxIndexCollection),
        tslib_1.__metadata("design:paramtypes", [IgxIndexCollection])
    ], IgxRingSeriesComponent.prototype, "selectedSlices", null);
    tslib_1.__decorate([
        Input(),
        tslib_1.__metadata("design:type", IgxRing),
        tslib_1.__metadata("design:paramtypes", [IgxRing])
    ], IgxRingSeriesComponent.prototype, "ring", null);
    IgxRingSeriesComponent = IgxRingSeriesComponent_1 = tslib_1.__decorate([
        Component({
            selector: 'igx-ring-series',
            template: "",
            providers: [{ provide: IgxRingSeriesBaseComponent, useExisting: forwardRef(function () { return IgxRingSeriesComponent_1; }) }],
            changeDetection: ChangeDetectionStrategy.OnPush
        }),
        tslib_1.__metadata("design:paramtypes", [])
    ], IgxRingSeriesComponent);
    return IgxRingSeriesComponent;
}(IgxRingSeriesBaseComponent));
export { IgxRingSeriesComponent };
//# sourceMappingURL=igx-ring-series-component.js.map