import { writable } from 'svelte/store';

function createPriority() {
    const { subscribe, set, update } = writable({
        surfers: [
            { color: 'lightgray', priority: '', name: '' },
            { color: 'lightgray', priority: '', name: '' },
            { color: 'lightgray', priority: '', name: '' },
            { color: 'lightgray', priority: '', name: '' },
            { color: 'lightgray', priority: '', name: '' },
            { color: 'lightgray', priority: '', name: '' },        
        ],
        round: {
            name: '',
            heat: 1,
            category: ''
        },
        surfersCount: 4
    });

    const clear = () => {
        set({
            surfers: [
                { color: 'lightgray', priority: '', name: '' },
                { color: 'lightgray', priority: '', name: '' },
                { color: 'lightgray', priority: '', name: '' },
                { color: 'lightgray', priority: '', name: '' },
                { color: 'lightgray', priority: '', name: '' },
                { color: 'lightgray', priority: '', name: '' },        
            ],
            round: {
                name: '',
                heat: 1,
                category: ''
            },
            surfersCount: 4        
        });
    };

    return {
        subscribe,
        set,
        update,
        clear
    }
}

export const priorityStore = createPriority();