import * as React from 'react';
import { delegateCombine, delegateRemove, TypeRegistrar } from "igniteui-react-core/ES2015/type";
import { LabelsPosition_$type } from "./LabelsPosition";
import { Visibility_$type } from "igniteui-react-core/ES2015/Visibility";
import { Style } from "igniteui-react-core/ES2015/Style";
import { LeaderLineType_$type } from "./LeaderLineType";
import { OthersCategoryType_$type } from "./OthersCategoryType";
import { PropertyUpdatedEventArgs } from "igniteui-react-core/ES2015/igr-property-updated-event-args";
import { ensureEnum, toBrushCollection, fromBrushCollection, isValidProp, getModifiedProps, ensureBool } from "igniteui-react-core/ES2015/componentUtil";
/**
 * Represents a IgxDoughnutChartComponent base series.
*/
export class IgrRingSeriesBase extends React.Component {
    constructor(props) {
        super(props);
        this._dataSource = null;
        this._tooltipTemplate = null;
        this._tooltipContent = null;
        this._tooltipContainerTemplate = null;
        this._showDefaultTooltip = false;
        this._propertyUpdated = null;
        this._propertyUpdated_wrapped = null;
        this._implementation = this.createImplementation();
        this._implementation.externalObject = this;
        this.onImplementationCreated();
    }
    createImplementation() {
        return null;
    }
    set dataSource(value) {
        this._dataSource = value;
        this.bindData();
    }
    get dataSource() {
        return this._dataSource;
    }
    bindData() {
        if (this.i != null && this.i !== undefined) {
            this.i.itemsSource = this._dataSource;
        }
    }
    get i() {
        return this._implementation;
    }
    onImplementationCreated() {
    }
    initializeProperties() {
        for (const p of Object.keys(this.props)) {
            if (isValidProp(this, p)) {
                this[p] = this.props[p];
            }
        }
    }
    componentDidMount() {
        this.initializeProperties();
    }
    shouldComponentUpdate(nextProps, nextState) {
        const mod = getModifiedProps(this.props, nextProps);
        for (const p of Object.keys(mod)) {
            if (isValidProp(this, p)) {
                this[p] = mod[p];
            }
        }
        return true;
    }
    render() {
        return null;
    }
    static _createFromInternal(internal) {
        if (!internal) {
            return null;
        }
        if (!internal.$type) {
            return null;
        }
        let name = internal.$type.name;
        let externalName = "Igr" + name;
        if (!TypeRegistrar.isRegistered(externalName)) {
            return null;
        }
        return TypeRegistrar.create(externalName);
    }
    get legend() {
        if (this.i.legend != null)
            return this.i.legend.externalObject;
    }
    set legend(v) {
        if (v != undefined && v != null)
            this.i.legend = v.i;
    }
    set tooltipTemplate(value) {
        this._tooltipTemplate = value;
        if (value == null) {
            if (this._tooltipContent !== null) {
                //this._tooltipContent.destroy();
                this._tooltipContent = null;
            }
        }
        if (this._tooltipContent != null) {
            this._tooltipContent.template = this._tooltipTemplate;
        }
        else {
            if (this.owner != null) {
                this.owner._ensureTooltipCreated(this);
            }
        }
    }
    get tooltipTemplate() {
        return this._tooltipTemplate;
    }
    set tooltipContainerTemplate(value) {
        this._tooltipContainerTemplate = value;
        if (this._tooltipContent != null) {
            this._tooltipContent.instance.containerTemplate = this._tooltipContainerTemplate;
        }
    }
    get tooltipContainerTemplate() {
        return this._tooltipContainerTemplate;
    }
    _ensureTooltipCreated(createTooltip, createWrapper) {
        if (this._tooltipTemplate == null) {
            this.i.toolTip = null;
        }
        if (this._tooltipContent == null && this._tooltipTemplate != null) {
            let tooltip = createTooltip();
            if (tooltip == null) {
                return;
            }
            this._tooltipContent = tooltip;
            tooltip.tooltipTemplate = this._tooltipTemplate;
            this.i.toolTip = createWrapper(tooltip);
        }
    }
    _ensureTooltipDestroyed() {
        if (this._tooltipContent !== null) {
            //this._tooltipContent.destroy();
            this._tooltipContent = null;
        }
    }
    /**
     * Gets or sets whether default tooltip will be shown.
    */
    get showDefaultTooltip() {
        return this._showDefaultTooltip;
    }
    set showDefaultTooltip(v) {
        this._showDefaultTooltip = ensureBool(v);
    }
    sychronizeCollections() { }
    /**
 * Gets or Sets the property name that contains the values.
*/
    get valueMemberPath() {
        return this.i.b7;
    }
    set valueMemberPath(v) {
        this.i.b7 = v;
    }
    /**
     * Gets or sets the property name that contains the labels.
    */
    get labelMemberPath() {
        return this.i.bf;
    }
    set labelMemberPath(v) {
        this.i.bf = v;
    }
    /**
     * Gets or sets the property name that contains the legend labels.
    */
    get legendLabelMemberPath() {
        return this.i.bp;
    }
    set legendLabelMemberPath(v) {
        this.i.bp = v;
    }
    /**
     * Gets or sets the position of chart labels.
    */
    get labelsPosition() {
        return this.i.aj;
    }
    set labelsPosition(v) {
        this.i.aj = ensureEnum(LabelsPosition_$type, v);
    }
    /**
     * Gets or sets whether the leader lines are visible.
    */
    get leaderLineVisibility() {
        return this.i.dq;
    }
    set leaderLineVisibility(v) {
        this.i.dq = ensureEnum(Visibility_$type, v);
    }
    /**
     * Gets or sets the fill brush.
    */
    get leaderLineFill() {
        return this.i.dk ? this.i.dk.fill : null;
    }
    set leaderLineFill(v) {
        this.ensureLeaderLineStyle();
        this.i.dk.fill = v;
    }
    /**
     * Gets or sets the stroke brush.
    */
    get leaderLineStroke() {
        return this.i.dk ? this.i.dk.stroke : null;
    }
    set leaderLineStroke(v) {
        this.ensureLeaderLineStyle();
        this.i.dk.stroke = v;
    }
    /**
     * Gets or sets the stroke thickness.
    */
    get leaderLineStrokeThickness() {
        return this.i.dk ? this.i.dk.strokeThickness : NaN;
    }
    set leaderLineStrokeThickness(v) {
        this.ensureLeaderLineStyle();
        this.i.dk.strokeThickness = +v;
    }
    /**
     * Gets or sets the opacity.
    */
    get leaderLineOpacity() {
        return this.i.dk ? this.i.dk.opacity : NaN;
    }
    set leaderLineOpacity(v) {
        this.ensureLeaderLineStyle();
        this.i.dk.opacity = +v;
    }
    ensureLeaderLineStyle() {
        if (this.i.dk) {
            return;
        }
        this.i.dk = new Style();
    }
    /**
     * Gets or sets what type of leader lines will be used for the outside end labels.
    */
    get leaderLineType() {
        return this.i.ak;
    }
    set leaderLineType(v) {
        this.i.ak = ensureEnum(LeaderLineType_$type, v);
    }
    /**
     * Gets or sets the margin between a label and its leader line. The default is 6 pixels.
    */
    get leaderLineMargin() {
        return this.i.a1;
    }
    set leaderLineMargin(v) {
        this.i.a1 = +v;
    }
    /**
     * Gets or sets the threshold value that determines if slices are grouped into the Others slice.
    */
    get othersCategoryThreshold() {
        return this.i.a2;
    }
    set othersCategoryThreshold(v) {
        this.i.a2 = +v;
    }
    /**
     * Gets or sets whether to use numeric or percent-based threshold value.
    */
    get othersCategoryType() {
        return this.i.al;
    }
    set othersCategoryType(v) {
        this.i.al = ensureEnum(OthersCategoryType_$type, v);
    }
    /**
     * Gets or sets the label of the Others slice.
    */
    get othersCategoryText() {
        return this.i.bt;
    }
    set othersCategoryText(v) {
        this.i.bt = v;
    }
    /**
     * Sets or gets a function which takes an object that produces a formatted label for displaying in the chart.
    */
    get formatLabel() {
        return this.i.am;
    }
    set formatLabel(v) {
        this.i.am = v;
    }
    /**
     * Sets or gets a function which takes an object that produces a formatted label for displaying in the chart's legend.
    */
    get formatLegendLabel() {
        return this.i.an;
    }
    set formatLegendLabel(v) {
        this.i.an = v;
    }
    /**
     * Gets or sets the pixel amount by which the labels are offset from the edge of the slices.
    */
    get labelExtent() {
        return this.i.a0;
    }
    set labelExtent(v) {
        this.i.a0 = +v;
    }
    /**
     * Gets or sets the starting angle of the chart.
     * The default zero value is equivalent to 3 o'clock.
    */
    get startAngle() {
        return this.i.a4;
    }
    set startAngle(v) {
        this.i.a4 = +v;
    }
    /**
     * Gets or sets the fill brush.
    */
    get othersCategoryFill() {
        return this.i.dl ? this.i.dl.fill : null;
    }
    set othersCategoryFill(v) {
        this.ensureOthersCategoryStyle();
        this.i.dl.fill = v;
    }
    /**
     * Gets or sets the stroke brush.
    */
    get othersCategoryStroke() {
        return this.i.dl ? this.i.dl.stroke : null;
    }
    set othersCategoryStroke(v) {
        this.ensureOthersCategoryStyle();
        this.i.dl.stroke = v;
    }
    /**
     * Gets or sets the stroke thickness.
    */
    get othersCategoryStrokeThickness() {
        return this.i.dl ? this.i.dl.strokeThickness : NaN;
    }
    set othersCategoryStrokeThickness(v) {
        this.ensureOthersCategoryStyle();
        this.i.dl.strokeThickness = +v;
    }
    /**
     * Gets or sets the opacity.
    */
    get othersCategoryOpacity() {
        return this.i.dl ? this.i.dl.opacity : NaN;
    }
    set othersCategoryOpacity(v) {
        this.ensureOthersCategoryStyle();
        this.i.dl.opacity = +v;
    }
    ensureOthersCategoryStyle() {
        if (this.i.dl) {
            return;
        }
        this.i.dl = new Style();
    }
    /**
     * Gets or sets the fill brush.
    */
    get selectedSliceFill() {
        return this.i.dm ? this.i.dm.fill : null;
    }
    set selectedSliceFill(v) {
        this.ensureSelectedStyle();
        this.i.dm.fill = v;
    }
    /**
     * Gets or sets the stroke brush.
    */
    get selectedSliceStroke() {
        return this.i.dm ? this.i.dm.stroke : null;
    }
    set selectedSliceStroke(v) {
        this.ensureSelectedStyle();
        this.i.dm.stroke = v;
    }
    /**
     * Gets or sets the stroke thickness.
    */
    get selectedSliceStrokeThickness() {
        return this.i.dm ? this.i.dm.strokeThickness : NaN;
    }
    set selectedSliceStrokeThickness(v) {
        this.ensureSelectedStyle();
        this.i.dm.strokeThickness = +v;
    }
    /**
     * Gets or sets the opacity.
    */
    get selectedSliceOpacity() {
        return this.i.dm ? this.i.dm.opacity : NaN;
    }
    set selectedSliceOpacity(v) {
        this.ensureSelectedStyle();
        this.i.dm.opacity = +v;
    }
    ensureSelectedStyle() {
        if (this.i.dm) {
            return;
        }
        this.i.dm = new Style();
    }
    /**
     * Gets or sets the palette of brushes to use for coloring the slices.
    */
    get brushes() {
        return fromBrushCollection(this.i.ag);
    }
    set brushes(v) {
        this.i.ag = toBrushCollection(v);
    }
    /**
     * Gets or sets the palette of brushes to use for outlines on the slices.
    */
    get outlines() {
        return fromBrushCollection(this.i.ah);
    }
    set outlines(v) {
        this.i.ah = toBrushCollection(v);
    }
    /**
     * Gets or sets whether all surface interactions with the plot area should be disabled.
    */
    get isSurfaceInteractionDisabled() {
        return this.i.ax;
    }
    set isSurfaceInteractionDisabled(v) {
        this.i.ax = ensureBool(v);
    }
    /**
     * Gets or sets the scaling factor of the chart's radius. Value between 0 and 1.
    */
    get radiusFactor() {
        return this.i.a3;
    }
    set radiusFactor(v) {
        this.i.a3 = +v;
    }
    /**
 * Called by the UI framework to provide a UI container for rendering this control.

* @param container  * The UI container element.
*/
    provideContainer(container) {
        this.i.ck(container);
    }
    /**
     * Event raised when a property (including "effective" and non-dependency property) value changes.
    */
    get propertyUpdated() {
        return this._propertyUpdated;
    }
    set propertyUpdated(ev) {
        if (this._propertyUpdated_wrapped !== null) {
            this.i.propertyUpdated = delegateRemove(this.i.propertyUpdated, this._propertyUpdated_wrapped);
            this._propertyUpdated_wrapped = null;
            this._propertyUpdated = null;
        }
        this._propertyUpdated = ev;
        this._propertyUpdated_wrapped = (o, e) => {
            let outerArgs = new PropertyUpdatedEventArgs();
            outerArgs._provideImplementation(e);
            if (this.beforePropertyUpdated) {
                this.beforePropertyUpdated(this, outerArgs);
            }
            if (this._propertyUpdated) {
                this._propertyUpdated(this, outerArgs);
            }
        };
        this.i.propertyUpdated = delegateCombine(this.i.propertyUpdated, this._propertyUpdated_wrapped);
    }
}
