from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
from six import iteritems
import collections




workouttypes_ordered = collections.OrderedDict({
    'water':'Standard Racing Shell',
    'rower':'Indoor Rower',
    'skierg':'Ski Erg',
    'bikeerg':'Bike Erg',
    'dynamic':'Dynamic Indoor Rower',
    'slides':'Indoor Rower on Slides',
    'paddle':'Paddle Adapter',
    'snow':'On-snow',
    'coastal':'Coastal',
    'c-boat':'Dutch C boat',
    'churchboat':'Finnish Church boat',
    'Ride':'Ride',
    'Bike':'Bike',
    'Run':'Run',
    'NordicSki':'NordicSki',
    'Swim':'Swim',
    'Hike':'Hike',
    'Walk':'Walk',
    'Canoeing':'Canoeing',
    'Crossfit':'Crossfit',
    'StandUpPaddling':'StandUpPaddling',
    'IceSkate':'IceSkate',
    'WeightTraining':'WeightTraining',
    'InlineSkate':'InlineSkate',
    'Kayaking':'Kayaking',
    'Workout':'Workout',
    'Yoga':'Yoga',
    'other':'Other',
    }
)

workouttypes = tuple((key, value) for key, value in workouttypes_ordered.items())



stravamapping = collections.OrderedDict({
    'water':'Rowing',
    'rower':'Rowing',
    'skierg':'NordicSki',
    'Bike':'Ride',
    'bikeerg':'Ride',
    'dynamic':'Rowing',
    'slides':'Rowing',
    'paddle':'StandUpPaddling',
    'snow':'NordicSki',
    'coastal':'Rowing',
    'c-boat':'Rowing',
    'churchboat':'Rowing',
    'Ride':'Ride',
    'Run':'Run',
    'NordicSki':'NordicSki',
    'Swim':'Swim',
    'Hike':'Hike',
    'Walk':'Walk',
    'Canoeing':'Canoeing',
    'Crossfit':'Crossfit',
    'StandUpPaddling':'StandUpPaddling',
    'IceSkate':'IceSkate',
    'WeightTraining':'WeightTraining',
    'InlineSkate':'InlineSkate',
    'Kayaking':'Kayaking',
    'Workout':'Workout',
    'Yoga':'Yoga',
    'other':'Workout',

    })

stmapping = collections.OrderedDict({
    'water':'Rowing',
    'rower':'Rowing',
    'skierg':'Skiing:Nordic',
    'Bike':'Cycling',
    'bikeerg':'Cycling',
    'dynamic':'Rowing',
    'slides':'Rowing',
    'paddle':'Other:Paddling',
    'snow':'Skiing:Nordic',
    'coastal':'Rowing',
    'c-boat':'Rowing',
    'churchboat':'Rowing',
    'Ride':'Cycling',
    'Run':'Running',
    'NordicSki':'Skiing:Nordic',
    'Swim':'Swimming',
    'Hike':'Hiking',
    'RollerSki':'Other:RollerSki',
    'Walk':'Other:Walk',
    'Canoeing':'Other:Canoeing',
    'Crossfit':'Other:Crossfit',
    'StandUpPaddling':'Other:StandUpPaddling',
    'IceSkate':'Skating',
    'WeightTraining':'Other:WeightTraining',
    'InlineSkate':'Skating:InlineSkate',
    'Kayaking':'Other:Kayaking',
    'Workout':'Other:Workout',
    'Yoga':'Other',
    'other':'Other',

    })

rkmapping = collections.OrderedDict({
    'water':'Rowing',
    'rower':'Rowing',
    'skierg':'Cross-Country Skiing',
    'Bike':'Cycling',
    'bikeerg':'Cycling',
    'dynamic':'Rowing',
    'slides':'Rowing',
    'paddle':'Other:Paddling',
    'snow':'Cross-Country Skiing',
    'coastal':'Rowing',
    'c-boat':'Rowing',
    'churchboat':'Rowing',
    'Ride':'Cycling',
    'Run':'Running',
    'NordicSki':'Cross-Country Skiing',
    'Swim':'Swimming',
    'Hike':'Hiking',
    'Walk':'Walking',
    'Canoeing':'Other',
    'Crossfit':'CrossFit',
    'StandUpPaddling':'Other',
    'IceSkate':'Skating',
    'WeightTraining':'Other',
    'InlineSkate':'Skating',
    'Kayaking':'Other',
    'Workout':'Other',
    'other':'Other',
    'Yoga':'Other',
    })

polarmapping = collections.OrderedDict({
    'water':'Rowing',
    'rower':'Rowing',
    'skierg':'Skiing',
    'Bike':'Cycling',
    'bikeerg':'Cycling',
    'dynamic':'Rowing',
    'slides':'Rowing',
    'paddle':'Other Outdoor',
    'snow':'Skiing',
    'coastal':'Rowing',
    'c-boat':'Rowing',
    'churchboat':'Rowing',
    'Ride':'Cycling',
    'Run':'Running',
    'NordicSki':'Skiing',
    'Swim':'Swimming',
    'Hike':'Hiking',
    'Walk':'Walking',
    'Canoeing':'Canoeing',
    'Crossfit':'Crossfit',
    'StandUpPaddling':'Other Outdoor',
    'IceSkate':'Skating',
    'WeightTraining':'Strength training',
    'InlineSkate':'Skating',
    'Kayaking':'Kayaking',
    'Workout':'Other Indoor',
    'other':'Other Indoor',
    'Yoga':'Yoga',
    })

tpmapping = collections.OrderedDict({
    'water':'rowing',
    'rower':'rowing',
    'skierg':'xc-ski',
    'Bike':'bike',
    'Bikeerg':'bike',
    'dynamic':'rowing',
    'slides':'rowing',
    'paddle':'other',
    'snow':'xc-ski',
    'coastal':'rowing',
    'c-boat':'rowing',
    'churchboat':'rowing',
    'Ride':'cycling',
    'Run':'run',
    'NordicSki':'xc-ski',
    'Swim':'swim',
    'Hike':'other',
    'Walk':'walk',
    'Canoeing':'other',
    'Crossfit':'other',
    'StandUpPaddling':'other',
    'IceSkate':'other',
    'WeightTraining':'strength',
    'InlineSkate':'other',
    'Kayaking':'other',
    'Workout':'other',
    'other':'other',
    'Yoga':'other',
    })

c2mapping = collections.OrderedDict({
    'water':'water',
    'rower':'rower',
    'skierg':'skierg',
    'Bike':'bike',
    'bikeerg':'bike',
    'dynamic':'dynamic',
    'slides':'slides',
    'paddle':'paddle',
    'snow':'snow',
    'coastal':'water',
    'c-boat':'water',
    'churchboat':'water',
    'Ride':'bike',
    'Run':None,
    'NordicSki':'snow',
    'Swim':None,
    'Hike':None,
    'Walk':None,
    'Canoeing':'paddle',
    'Crossfit':None,
    'StandUpPaddling':None,
    'IceSkate':None,
    'WeightTraining':None,
    'InlineSkate':None,
    'Kayaking':None,
    'Workout':None,
    'other':None,
    'Yoga':None,

    })

c2mappinginv = {value:key for key,value in reversed(c2mapping.items()) if value is not None}

stravamappinginv = {value:key for key,value in reversed(stravamapping.items()) if value is not None}

stmappinginv = {value:key for key,value in reversed(stmapping.items()) if value is not None}

rkmappinginv = {value:key for key,value in reversed(rkmapping.items()) if value is not None}

polarmappinginv = {value:key for key,value in reversed(polarmapping.items()) if value is not None}

otwtypes = (
    'water',
    'coastal',
    'c-boat',
    'churchboat'
    )

otetypes = (
    'rower',
    'dynamic',
    'slides'
    )

rowtypes = (
    'water',
    'rower',
    'dynamic',
    'slides',
    'coastal',
    'c-boat',
    'churchboat'
    )


checktypes = [i[0] for i in workouttypes]

from bokeh.palettes import Category10,Category20, Category20c


colors = Category10[9]+Category20[19]+Category20c[19]
color_map = {checktypes[i]:colors[i] for i in range(len(checktypes))}

workoutsources = (
    ('strava','strava'),
    ('concept2','concept2'),
    ('sporttracks','sporttracks'),
    ('runkeeper','runkeeper'),
    ('mapmyfitness','mapmyfitness'),
    ('csv','painsled'),
    ('tcx','tcx'),
    ('rp','rowperfect'),
    ('mystery','mystery'),
#    ('tcxnohr','tcx (no HR)'),
    ('rowperfect3','rowperfect3'),
    ('ergdata','ergdata'),
    ('boatcoach','boatcoach'),
    ('boatcoachotw','boatcoachotw'),
#    ('bcmike','boatcoach (develop)'),
    ('painsleddesktop','painsleddesktop'),
    ('speedcoach','speedcoach'),
    ('speedcoach2','speedcoach2'),
    ('ergstick','ergstick'),
    ('fit','fit'),
    ('unknown','unknown'))

boattypes = (
    ('1x', '1x (single)'),
    ('2x', '2x (double)'),
    ('2x+', '2x+ (coxed double)'),
    ('2-', '2- (pair)'),
    ('2+', '2+ (coxed pair)'),
    ('3x+','3x+ (coxed triple)'),
    ('3x-','3x- (triple)'),
    ('4x', '4x (quad)'),
    ('4x+', '4x+ (coxed quad)'),
    ('4-', '4- (four)'),
    ('4+', '4+ (coxed four)'),
    ('8+', '8+ (eight)'),
    ('8x+', '8x+ (octuple scull)'),
)

adaptivetypes = (
    ('None','Open'),
    ('PR1', 'PR1 (Arms and Shoulders)'),
    ('PR2', 'PR2 (Trunk and Arms)'),
    ('PR3', 'PR3 (Leg Trunk and Arms)'),
    ('FES', 'FES (Functional Electrical Stimulation)'),
    )

weightcategories = (
    ('hwt','open-weight'),
    ('lwt','light-weight'),
    )

sexcategories = (
    ('male','Open'),
    ('female','Female'),
    )

waterboattype = [i[0] for i in boattypes]

privacychoices = (
    ('private','Private'),
    ('visible','Visible'),
)
