/**
 * @license
 * Copyright Tyler Technologies, Inc. 
 * License: Apache-2.0
 */
import { CIRCULAR_PROGRESS_CONSTANTS } from './circular-progress-constants';
export class CircularProgressFoundation {
    constructor(_adapter) {
        this._adapter = _adapter;
        this._determinate = false;
        this._progress = 0;
        this._theme = 'primary';
        this._track = false;
    }
    initialize() {
        this._adapter.initialize();
        this._applyDeterminate();
    }
    _applyDeterminate() {
        this._adapter.setDeterminate(this._determinate);
        if (this._determinate) {
            this._adapter.setProgress(this._progress);
        }
    }
    get determinate() {
        return this._determinate;
    }
    set determinate(value) {
        value = Boolean(value);
        if (this._determinate !== value) {
            this._determinate = value;
            this._applyDeterminate();
            this._adapter.toggleHostAttribute(CIRCULAR_PROGRESS_CONSTANTS.attributes.DETERMINATE, this._determinate);
        }
    }
    get progress() {
        return this._progress;
    }
    set progress(value) {
        if (isNaN(value)) {
            value = 0;
        }
        if (this._progress !== value) {
            this._progress = value;
            if (this._determinate) {
                this._adapter.setProgress(this._progress);
            }
            this._adapter.setHostAttribute(CIRCULAR_PROGRESS_CONSTANTS.attributes.PROGRESS, `${this._progress}`);
        }
    }
    get theme() {
        return this._theme;
    }
    set theme(value) {
        if (this._theme !== value) {
            this._theme = value;
            this._adapter.toggleHostAttribute(CIRCULAR_PROGRESS_CONSTANTS.attributes.THEME, !!this._theme, this._theme);
        }
    }
    get track() {
        return this._track;
    }
    set track(value) {
        value = Boolean(value);
        if (this._track !== value) {
            this._track = value;
            this._adapter.toggleHostAttribute(CIRCULAR_PROGRESS_CONSTANTS.attributes.TRACK, this._track);
        }
    }
}
