export class SoundManager {
    constructor(soundSet = null) {
        this.soundSet = null;
        this.data = new Map();
        this.soundSet = soundSet;
    }
    setSoundSet(soundSet) {
        this.soundSet = soundSet;
    }
    handleSound(type, data = null) {
        switch (type) {
            case 'edit':
                this.handleEditSound(data);
                break;
            case 'slider':
                this.handleSliderSound(data);
                break;
            case 'selector':
                this.handleSelectorSound(data);
                break;
            case 'checkbox':
                this.handleCheckboxSound(data);
                break;
            case 'focus':
                this.handleFocusSound();
                break;
            case 'choose':
                this.handleChooseSound();
                break;
            case 'open':
                this.handleOpenSound();
                break;
            case 'close':
                this.handleCloseSound();
                break;
            default:
                return;
                break;
        }
    }
    handleEditSound(data) {
        const prevData = this.data.get('edit') || '';
        if (data.length <= prevData.length) {
            this.soundSet.delete && this.soundSet.delete.play();
        }
        else {
            this.soundSet.char && this.soundSet.char.play();
        }
        this.data.set('edit', data);
    }
    handleSelectorSound(data) {
        this.soundSet.scroller && this.soundSet.scroller.play();
    }
    handleSliderSound(data) {
        const prevData = this.data.get('slider');
        if (data < prevData) {
            this.soundSet.sliderLeft && this.soundSet.sliderLeft.play();
        }
        else {
            this.soundSet.sliderRight && this.soundSet.sliderRight.play();
        }
        this.data.set('slider', data);
    }
    handleFocusSound() {
        this.soundSet.move && this.soundSet.move.play();
    }
    handleOpenSound() {
        this.soundSet.open && this.soundSet.open.play();
    }
    handleCloseSound() {
        this.soundSet.close && this.soundSet.close.play();
    }
    handleChooseSound() {
        this.soundSet.choose && this.soundSet.choose.play();
    }
    handleCheckboxSound(data) {
        if (data === true) {
            this.soundSet.checked && this.soundSet.checked.play();
        }
        else {
            this.soundSet.unchecked && this.soundSet.unchecked.play();
        }
    }
}
