/*
 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 esIst: WordDefinition = {1: [1, 2, 4, 5, 6]};
const uhr: WordDefinition = {10: [9, 10, 11]};
const nach: WordDefinition = {4: [8, 9, 10, 11]};
const vor: WordDefinition = {4: [1, 2, 3]};
const halb: WordDefinition = {5: [1, 2, 3, 4]};
const fuenf: WordDefinition = {1: [8, 9, 10, 11]};
const zehn: WordDefinition = {2: [1, 2, 3, 4]};
const viertel: WordDefinition = {3: [5, 6, 7, 8, 9, 10, 11]};
const zwanzig: WordDefinition = {2: [5, 6, 7, 8, 9, 10, 11]};
const dreiviertel: WordDefinition = {3: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]};

export const LayoutDe: Layout = {
    code: 'de',
    hours: {
        '0,12': {9: [7, 8, 9, 10, 11]},
        '1,13': {6: [1, 2, 3, 4]},
        '2,14': {6: [8, 9, 10, 11]},
        '3,15': {7: [1, 2, 3, 4]},
        '4,16': {7: [8, 9, 10, 11]},
        '5,17': {5: [8, 9, 10, 11]},
        '6,18': {8: [1, 2, 3, 4, 5]},
        '7,19': {9: [1, 2, 3, 4, 5, 6]},
        '8,20': {8: [8, 9, 10, 11]},
        '9,21': {10: [4, 5, 6, 7]},
        '10,22': {10: [1, 2, 3, 4]},
        '11,23': {5: [6, 7, 8]}
    },
    letters: [
        'ESKISTAFÜNF',
        'ZEHNZWANZIG',
        'DREIVIERTEL',
        'VORFUNKNACH',
        'HALBAELFÜNF',
        'EINSXAMZWEI',
        'DREIPMJVIER',
        'SECHSNLACHT',
        'SIEBENZWÖLF',
        'ZEHNEUNKUHR'
    ],
    minutes: {
        '0,1,2,3,4': uhr,
        '5,6,7,8,9': [fuenf, nach],
        '10,11,12,13,14': [zehn, nach],
        '15,16,17,18,19': [viertel, nach],
        '20,21,22,23,24': [zwanzig, nach],
        '25,26,27,28,29': [fuenf, vor, halb],
        '30,31,32,33,34': halb,
        '35,36,37,38,39': [fuenf, nach, halb],
        '40,41,42,43,44': [zwanzig, vor],
        '45,46,47,48,49': dreiviertel,
        '50,51,52,53,54': [zehn, vor],
        '55,56,57,58,59': [fuenf, vor]
    },
    permanent: esIst,
    prettyName: 'Deutsch',
    version: 2
};

declare namespace Fritteli {
    interface Fritteli {
        uhr: Uhr;
    }

    interface Uhr {
        register: (layout: Layout) => void;
    }
}
declare namespace $ {
    const fritteli: Fritteli.Fritteli;
}

$.fritteli.uhr.register(LayoutDe);