/*
 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

import {Layout, WordDefinition} from '../domain/layout';

const il_est: WordDefinition = {1: [1, 2, 4, 5, 6]};
const et: WordDefinition = {8: [1, 2]};
const moins: WordDefinition = {7: [1, 2, 3, 4, 5]};
const demie: WordDefinition = {10: [4, 5, 6, 7, 8]};
const heures: WordDefinition = {6: [6, 7, 8, 9, 10, 11]};
const le: WordDefinition = {7: [7, 8]};
const cinq: WordDefinition = {9: [7, 8, 9, 10]};
const dix: WordDefinition = {7: [9, 10, 11]};
const quart: WordDefinition = {8: [4, 5, 6, 7, 8]};
const vingt: WordDefinition = {9: [1, 2, 3, 4, 5]};
const vingtcinq: WordDefinition = {9: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]};

export const Layout_fr: Layout = {
    code: 'fr',
    getHour: (time: Date) => {
        const hour = time.getHours();
        if (time.getMinutes() >= 35) {
            return (hour + 1) % 24;
        }
        return hour;
    },
    hours: {
        '0': {5: [6, 7, 8, 9, 10, 11]},
        '1,13': [
            {3: [5, 6, 7]},
            heures
        ],
        '2,14': [
            {1: [8, 9, 10, 11]},
            heures
        ],
        '3,15': [
            {2: [7, 8, 9, 10, 11]},
            heures
        ],
        '4,16': [
            {2: [1, 2, 3, 4, 5, 6]},
            heures
        ],
        '5,17': [
            {4: [8, 9, 10, 11]},
            heures
        ],
        '6,18': [
            {4: [5, 6, 7]},
            heures
        ],
        '7,19': [
            {3: [8, 9, 10, 11]},
            heures
        ],
        '8,20': [
            {4: [1, 2, 3, 4]},
            heures
        ],
        '9,21': [
            {3: [1, 2, 3, 4]},
            heures
        ],
        '10,22': [
            {5: [3, 4, 5]},
            heures
        ],
        '11,23': [
            {6: [1, 2, 3, 4]},
            heures
        ],
        '12': {5: [1, 2, 3, 4]}
    },
    letters: [
        'ILNESTODEUX',
        'QUATRETROIS',
        'NEUFUNESEPT',
        'HUITSIXCINQ',
        'MIDIXMINUIT',
        'ONZERHEURES',
        'MOINSOLEDIX',
        'ETRQUARTPMD',
        'VINGT-CINQU',
        'ETSDEMIEPAM'
    ],
    minutes: {
        '5,6,7,8,9': cinq,
        '10,11,12,13,14': dix,
        '15,16,17,18,19': [et, quart],
        '20,21,22,23,24': vingt,
        '25,26,27,28,29': vingtcinq,
        '30,31,32,33,34': [et, demie],
        '35,36,37,38,39': [moins, vingtcinq],
        '40,41,42,43,44': [moins, vingt],
        '45,46,47,48,49': [moins, le, quart],
        '50,51,52,53,54': [moins, dix],
        '55,56,57,58,59': [moins, cinq]
    },
    permanent: il_est,
    prettyName: 'Français',
    version: 2
};