function getState (stateInputId) {
    return JSON.parse($('#' + stateInputId).attr('data-values'));
}

function setState (stateInputId, state){
    $('#' + stateInputId).attr('data-values', JSON.stringify(state));
}

function setSelectAllState (stateInputId, value) {
    $('#' + stateInputId).attr('data-all', JSON.stringify(value));
}

function getSelectAllState (stateInputId) {
    return JSON.parse($('#' + stateInputId).attr('data-all') ?? 'false');
}

function updateDom (state) {
    console.log('Méthode à surcharger !');
}

function handleSelectAllSwitchChange (event) {
    console.log('Méthode à surcharger !');
}

function refreshDomOnComplete (stateInputId) {
    $(document).ajaxComplete(() => {
        updateDom(getState(stateInputId));
        const inputTous = $('#input_TOUS');

        inputTous.prop('checked', getSelectAllState(stateInputId));
        inputTous.on('change', (event) => {
            handleSelectAllSwitchChange(event);
        });
    })
}

function toggleCheckbox (event, id) {
    event.stopPropagation();
    event.stopImmediatePropagation();
    const stateInputId = $('#divInputs').val();

    let state = getState(stateInputId);
    state = mutateState($('#' + id), state);
    setState(stateInputId, state);

    updateDom(state);
}

function mutateState (checkbox, state) {
    console.log('Méthode à surcharger !');

    return state;
}