(this.webpackJsonpfittrackee_client=this.webpackJsonpfittrackee_client||[]).push([[0],{194:function(e){e.exports=JSON.parse('{"Workouts":"Workouts","Workout":"Workout","Workout Date":"Workout Date","Add a workout":"Add a workout","Are you sure you want to delete this workout?":"Are you sure you want to delete this workout?","Ave. speed":"Ave. speed","Ascent":"Ascent","Average speed":"Average speed","Chart":"Chart","data from gpx, without any cleaning":"data from gpx, without any cleaning","Date":"Date","Delete workout":"Delete workout","Descent":"Descent","Distance":"Distance","distance":"distance","Duration":"Duration","duration":"duration","Edit a workout":"Edit a workout","Edit workout":"Edit workout","elevation":"elevation","End":"End","Farest distance":"Farest distance","Filter":"Filter","From":"From","gpxFile":"gpx file","Longest duration":"Longest duration","Max. altitude":"Max. altitude","Max. speed":"Max. speed","Min. altitude":"Min. altitude","no folder inside":"no folder inside","files max":"files max","max size":"max size","No data to display":"No data to display","No Map":"No Map","No next workout":"No next workout","No next segment":"No next segment","No notes":"No notes","No previous workout":"No previous workout","No previous segment":"No previous segment","Notes":"Notes","pauses":"pauses","Personal records":"Personal records","See next workout":"See next workout","See next segment":"See next segment","See previous workout":"See previous workout","See previous segment":"See previous segment","segment":"segment","Segments":"Segments","speed":"speed","Start":"Start","Title":"Title","To":"To","total duration":"total duration","with gpx file":"with gpx file","without gpx file":"without gpx file","zipFile":"or zip file containing gpx files"}')},195:function(e){e.exports=JSON.parse('{"Actions":"Actions","Active":"Active","workouts exist":"workouts exist","Add admin rights":"Add admin rights","Add/remove admin rights, delete user account.":"Add/remove admin rights, delete user account.","Administration":"Administration","Application":"Application","Application configuration":"Application configuration","Back":"Back","Disable":"Disable","Enable":"Enable","Enable/disable sports.":"Enable/disable sports.","FitTrackee administration":"FitTrackee administration","id":"id","if 0, no limitation":"if 0, no limitation","Image":"Image","Label":"Label","Max. number of active users":"Max. number of active users","Max. files of zip archive":"Max. files of zip archive","Max. size of uploaded files":"Max. size of uploaded files","Max. size of uploaded files (in Mb)":"Max. size of uploaded files (in Mb)","Max. size of zip archive":"Max. size of zip archive","Max. size of zip archive (in Mb)":"Max. size of zip archive (in Mb)","Registration is currently disabled.":"Registration is currently disabled.","Registration is currently enabled.":"Registration is currently enabled.","Remove admin rights":"Remove admin rights","Sports":"Sports","Update application configuration (maximum number of registered users, maximum files size).":"Update application configuration (maximum number of registered users, maximum files size).","uploads":"uploads","user":"user","Users":"Users","users":"users"}')},196:function(e){e.exports=JSON.parse('{"workouts count":"workouts count","Add workout":"Add workout","admin rights":"admin rights","ascending":"ascending","Back":"Back","Back to home":"Back to home","Cancel":"Cancel","Confirmation":"Confirmation","Dashboard":"Dashboard","descending":"descending","Edit":"Edit","day":"day","days":"days","Next":"Next","No":"No","no":"no","No records.":"No records.","No workouts.":"No workouts.","Page not found":"Page not found","Previous":"Prev","registration date":"registration date","Sort":"Sort","Sort by":"Sort by","Sport":"Sport","sport":"sport","Sports":"Sports","sports":"sports","Statistics":"Statistics","Submit":"Submit","to":"to","user name":"user name","Workout":"Workout","Workouts":"Workouts","workout":"workout","workouts":"workouts","Yes":"Yes","yes":"yes"}')},197:function(e){e.exports=JSON.parse('{"Personal records":"Personal records","This month":"This month","Upload one !":"Upload one !"}')},198:function(e){e.exports=JSON.parse('{"3 to 12 characters required for username.":"3 to 12 characters required for username.","8 characters required for password.":"8 characters required for password.","An error occurred. Please contact the administrator.":"An error occurred. Please contact the administrator.","workouts":"workouts","Error during picture deletion.":"Error during picture deletion.","Error during picture update.":"Error during picture update.","Error during picture update, file size exceeds max size.":"Error during picture update, file size exceeds max size.","Error. Registration is disabled.":"Error. Registration is disabled.","Error. Please try again or contact the administrator.":"Error. Please try again or contact the administrator.","File extension not allowed.":"File extension not allowed.","File size is greater than the allowed size":"File size is greater than the allowed size","Incorrect id":"Incorrect id","Invalid credentials.":"Invalid credentials.","Invalid payload.":"Invalid payload.","Invalid token. Please log in again.":"Invalid token. Please log in again.","No file part.":"No file part.","No picture.":"No picture.","No selected file.":"No selected file.","no correct file.":"no correct file.","no gpx file for this workout":"no gpx file for this workout","Password and password confirmation don\'t match.":"Password and password confirmation don\'t match.","Provide a valid auth token":"Provide a valid auth token","records":"records","Signature expired. Please log in again.":"Signature expired. Please log in again.","Sorry. That user already exists.":"Sorry. That user already exists.","Sport can not be disabled, workouts exist.":"Sport can not be disabled, workouts exist.","Sport does not exist.":"Sport does not exist.","sports":"sports","statistics":"statistiques","User does not exist.":"User does not exist.","Valid email must be provided.\\n":"Valid email must be provided.","You can not delete your account, no other user has admin rights.":"You can not delete your account, no other user has admin rights.","You do not have permissions.":"You do not have permissions."}')},199:function(e){e.exports=JSON.parse('{"Cycling (Sport)":"Cycling (Sport)","Cycling (Transport)":"Cycling (Transport)","Hiking":"Hiking","Mountain Biking":"Mountain Biking","Running":"Running","Walking":"Walking"}')},200:function(e){e.exports=JSON.parse('{"workouts":"workouts","distance":"distance","duration":"duration","month":"month","Statistics":"Statistics","year":"year","week":"week"}')},201:function(e){e.exports=JSON.parse('{"Admin":"Admin","Are you sure you want to delete this account? All data will be deleted, this cannot be undone.":"Are you sure you want to delete this account? All data will be deleted, this cannot be undone.","Are you sure you want to delete your account? All data will be deleted, this cannot be undone.":"Are you sure you want to delete your account? All data will be deleted, this cannot be undone.","Bio":"Bio","Birth Date":"Birth Date","Check your email. If your address is in our database, you\'ll received an email with a link to reset your password.":"Check your email. If your address is in our database, you\'ll received an email with a link to reset your password.","Delete my account":"Delete my account","Delete picture":"Delete picture","Delete user account":"Delete user account","Edit Profile":"Edit Profile","Email":"Email","Enter a username":"Enter a username","Enter an email address":"Enter an email address","Enter a password":"Enter a password","Enter the password confirmation":"Enter the password confirmation","First day of week":"First day of week","First Name":"First Name","Forgot password?":"Forgot password?","Invalid token. Please request a new token.":"Invalid token. Please request a new token.","Language":"Language","Last Name":"Last Name","Location":"Location","loggedOut":"You are now logged out. Click <1>here to log back in.","Login":"Login","login":"login","Logout":"Logout","Monday":"Monday","Password":"Password","Password Confirmation":"Password Confirmation","Password reset":"Password reset","password reset":"password reset","Profile":"Profile","Profile Edition":"Profile Edition","Register":"Register","register":"register","Registration Date":"Registration Date","Reset your password":"Reset your password","reset your password":"reset your password","Send":"Send","Sunday":"Sunday","Timezone":"Timezone","updatedPasswordText":"Your password have been updated. Click <1>here to log in.","Username":"Username"}')},202:function(e){e.exports=JSON.parse('{"Workouts":"S\xe9ances","Workout":"S\xe9ance","Workout Date":"Date de l\'s\xe9ance","Add a workout":"Ajouter une s\xe9ance","Are you sure you want to delete this workout?":"Etes-vous s\xfbr de vouloir supprimer cette s\xe9ance ?","Ave. speed":"Vitesse moyenne","Ascent":"D\xe9nivel\xe9 positif","Average speed":"Vitesse moyenne","Chart":"Analyse","data from gpx, without any cleaning":"donn\xe9es issues du fichier gpx, sans correction","Date":"Date","Delete workout":"Supprimer l\'s\xe9ance","Descent":"D\xe9nivel\xe9 n\xe9gatif","Distance":"Distance","distance":"distance","Duration":"Dur\xe9e","duration":"dur\xe9e","Edit a workout":"Editer une s\xe9ance","Edit workout":"Editer une workout","elevation":"altitude","End":"Arriv\xe9e","Farest distance":"Distance la + longue","Filter":"Filtrer","From":"A partir de","gpxFile":"fichier gpx","Longest duration":"Dur\xe9e la + longue","Max. altitude":"Altitude max","Max. speed":"Vitesse max","Min. altitude":"Altitude min","no folder inside":"pas de r\xe9pertoire","files max":" fichiers max","max size":"taille max","No data to display":"Pas de donn\xe9es \xe0 afficher","No Map":"Pas de carte","No next workout":"Pas d\'s\xe9ance suivante","No next segment":"Pas de segment suivant","No notes":"Pas de notes","No previous workout":"Pas d\'s\xe9ance pr\xe9c\xe9dente","No previous segment":"Pas de segment pr\xe9c\xe9dent","Notes":"Notes","pauses":"pauses","Personal records":"Records personnels","See next workout":"Voir l\'s\xe9ance suivante","See next segment":"Voir le segment suivant","See previous workout":"Voir l\'s\xe9ance pr\xe9c\xe9dente","See previous segment":"Voir le segment pr\xe9c\xe9dent","segment":"segment","Segments":"Segments","Start":"D\xe9part","speed":"vitesse","Title":"Titre","To":"Jusqu\'au","total duration":"dur\xe9e totale","with gpx file":"avec un fichier gpx","without gpx file":"sans fichier gpx","zipFile":"ou un fichier zip contenant des fichiers gpx"}')},203:function(e){e.exports=JSON.parse('{"Actions":"Actions","Active":"Active","Add admin rights":"Ajouter des droits d\'admin","Add/remove admin rights, delete user account.":"Ajouter/retirer des droits d\'adminsitration, supprimer des comptes utilisateurs.","Administration":"Administration","workouts exist":"des s\xe9ances existent","Application":"Application","Application configuration":"Configuration de l\'application","Back":"Retour","Disable":"d\xe9sactiver","Enable":"activer","Enable/disable sports.":"Activer/d\xe9sactiver des sports.","FitTrackee administration":"Administration de FitTrackee","id":"id","if 0, no limitation":"si \xe9gal \xe0 0, pas limite d\'inscription","Image":"Image","Label":"Label","Max. number of active users":"Nombre maximum d\'utilisateurs actifs","Max. files of zip archive":"Nombre max. de fichiers dans une archive zip","Max. size of uploaded files":"Taille max. des fichiers","Max. size of uploaded files (in Mb)":"Taille max. des fichiers (en Mo)","Max. size of zip archive":"Taille max. des archives zip","Max. size of zip archive (in Mb)":"Taille max. des archives zip (en Mo)","Registration is currently disabled.":"Les inscriptions sont actuellement d\xe9sactiv\xe9es.","Registration is currently enabled.":"Les inscriptions sont actuellement activ\xe9es.","Remove admin rights":"Retirer des droits d\'admin","Sports":"Sports","Update application configuration (maximum number of registered users, maximum files size).":"Configurer l\'application (nombre maximum d\'utilisateurs inscrits, taille maximale des fichers).","uploads":"fichiers","user":"user","Users":"Utilisateurs","users":"utilisateurs"}')},204:function(e){e.exports=JSON.parse('{"workouts count":"nombre d\'s\xe9ances","Add workout":"Ajouter une s\xe9ance","admin rights":"droits d\'admin","ascending":"ascendant","Back":"Revenir \xe0 la page pr\xe9c\xe9dente","Back to home":"Retour \xe0 l\'accueil","Cancel":"Annuler","Confirmation":"Confirmation","Dashboard":"Tableau de Bord","descending":"descendant","Edit":"Modifier","day":"jour","days":"jours","Next":"Page suivante","No":"Non","no":"non","No records.":"Pas de records.","No workouts.":"Pas d\'s\xe9ances.","Page not found":"Page introuvable","Previous":"Page pr\xe9c\xe9dente","registration date":"date d\'inscription","Sort":"Tri","Sort by":"Trier par","Sport":"Sport","sport":"sport","Sports":"Sports","sports":"sports","Statistics":"Statistiques","Submit":"Valider","to":"\xe0","user name":"utilisateur","Workout":"S\xe9ance","Workouts":"S\xe9ances","workout":"s\xe9ance","workouts":"s\xe9ances","Yes":"Oui","yes":"oui"}')},205:function(e){e.exports=JSON.parse('{"Personal records":"Mes records","This month":"Ce mois","Upload one !":"Ajoutez votre premi\xe8re s\xe9ance !"}')},206:function(e){e.exports=JSON.parse('{"3 to 12 characters required for username.":"3 \xe0 12 caract\xe8res requis pour le nom.","8 characters required for password.":"8 caract\xe8res minimum pour le mot de passe.","An error occurred. Please contact the administrator.":"Une erreur s\'est produite. Merci de contacter l\'administrateur.","workouts":"s\xe9ances","Error during picture deletion.":"Erreur lors de la suppression de l\'image.","Error during picture update.":"Erreur lors de la mise \xe0 jour de l\'image.","Error during picture update, file size exceeds max size.":"Erreur lors de la mise \xe0 jour de l\'image, la taille du ficher d\xe9passe la taille maximum autoris\xe9e","Error. Registration is disabled.":"Erreur. L\'inscription est d\xe9sactiv\xe9e.","Error. Please try again or contact the administrator.":"Erreur. Veuillez r\xe9essayer ou contacter l\'administrateur","File extension not allowed.":"Extension de fichier non autoris\xe9e.","File size is greater than the allowed size":"La taille du fichier est sup\xe9rieure \xe0 la limite autoris\xe9e","Incorrect id":"Id incorrect","Invalid credentials.":"Identifiants invalides.","Invalid payload.":"Donn\xe9es incorrectes.","Invalid token. Please log in again.":"Jeton invalide. Merci de vous reconnecter.","No file part.":"Pas de fichier fourni.","No picture.":"Pas d\'image.","No selected file.":"Pas de fichier s\xe9lectionn\xe9.","no correct file.":"fichier incorrect","no gpx file for this workout":"pas de fichier gpx pour cette s\xe9ance","Password and password confirmation don\'t match.":"Les mots de passe saisis sont diff\xe9rents.","Provide a valid auth token":"Merci de fournir un jeton valide","records":"records","Signature expired. Please log in again.":"Signature expir\xe9e. Merci de vous reconnecter.","Sorry. That user already exists.":"D\xe9sol\xe9. Cet utilisateur existe d\xe9j\xe0.","Sport can not be disabled, workouts exist.":"Le sport ne peut \xeatre d\xe9sactiv\xe9, des s\xe9ancees existent","Sport does not exist.":"Le sport n\'existe pas.","sports":"sports","statistics":"statistics","User does not exist.":"L\'utilisateur n\'existe pas.","Valid email must be provided.\\n":"L\'email fourni n\'est pas valide.","You can not delete your account, no other user has admin rights.":"Vous ne pouvez pas supprimer votre compte, aucun autre utilisateur n\'a des droits d\'administration.","You do not have permissions.":"Vous n\'avez pas les permissions n\xe9cessaires."}')},207:function(e){e.exports=JSON.parse('{"Cycling (Sport)":"V\xe9lo (Sport)","Cycling (Transport)":"V\xe9lo (Transport)","Hiking":"Randonn\xe9e","Mountain Biking":"VTT","Running":"Course","Walking":"Marche"}')},208:function(e){e.exports=JSON.parse('{"workouts":"s\xe9ances","distance":"distance","duration":"dur\xe9e","month":"mois","Statistics":"Statistiques","year":"ann\xe9e","week":"semaine"}')},209:function(e){e.exports=JSON.parse('{"Admin":"Admin","Are you sure you want to delete this account? All data will be deleted, this cannot be undone.":"Etes-vous s\xfbr de vouloir supprimer ce compte ? Toutes les donn\xe9es seront d\xe9finitivement effac\xe9s.","Are you sure you want to delete your account? All data will be deleted, this cannot be undone.":"Etes-vous s\xfbr de vouloir supprimer votre compte ? Toutes les donn\xe9es seront d\xe9finitivement effac\xe9s.","Bio":"Bio","Birth Date":"Date de naissance","Check your email. If your address is in our database, you\'ll received an email with a link to reset your password.":"V\xe9rifiez vore boite mail. Si vote adresse est dans notre base de donn\xe9es, vous recevrez un email avec un lien pour r\xe9initialiser votre mot de passe","Delete my account":"Supprimer mon compte","Delete picture":"Supprimer l\'image","Delete user account":"Supprimer le compte","Edit Profile":"Editer le profil","Email":"Email","Enter a username":"Saisir un nom","Enter an email address":"Saisir une adresse e-mail","Enter a password":"Saisir un mot de passe","Enter the password confirmation":"Confirmer le mot de passe","First day of week":"Premier jour de la semaine","First Name":"Pr\xe9nom","Forgot password?":"Mot de passe oubli\xe9 ?","Invalid token. Please request a new token.":"Token invalid. Veuillez demander un nouveau token.","Language":"Langue","Last Name":"Nom","Location":"Lieu","loggedOut":"Vous \xeates d\xe9connect\xe9. Cliquez <1>ici pour vous reconnecter.","Login":"Se connecter","login":"se connecter","Logout":"Se d\xe9connecter","Monday":"Lundi","Password":"Mot de passe","Password Confirmation":"Confirmation du mot de passe","Password reset":"R\xe9initialiser votre mot de passe","password reset":"r\xe9initialiser votre mot de passe","Profile":"Profil","Profile Edition":"Edition du profil","Register":"S\'inscrire","register":"s\'inscrire","Registration Date":"Date d\'inscription","Reset your password":"R\xe9initialiser votre mot de passe","reset your password":"r\xe9initialiser votre mot de passe","Send":"Envoyer","Sunday":"Dimanche","Timezone":"Fuseau horaire","updatedPasswordText":"Votre mot de passe a \xe9t\xe9 mis \xe0 jour. Cliquez <1>ici pour vous connecter.","Username":"Nom d\'utilisateur"}')},268:function(e,t,s){},276:function(e,t){},458:function(e,t,s){"use strict";s.r(t),s.d(t,"history",(function(){return Ta})),s.d(t,"rootNode",(function(){return Fa})),s.d(t,"store",(function(){return za}));var a=s(1),r=s(25),o=s(2),c=s.n(o),n=s(478),i=s(49),l=s.n(i),d=s(190),u=s(53),m=s(191),j=s(77),p=s(192),h=s(193);const b={en:{workouts:s(194),administration:s(195),common:s(196),dashboard:s(197),messages:s(198),sports:s(199),statistics:s(200),user:s(201)},fr:{workouts:s(202),administration:s(203),common:s(204),dashboard:s(205),messages:s(206),sports:s(207),statistics:s(208),user:s(209)}};j.a.use(h.a).use(p.a).init({debug:!1,lng:"en",fallbackLng:"en",keySeparator:!1,interpolation:{escapeValue:!1},resources:b,ns:["common"],defaultNS:"common"});var x=j.a,O=s(6),g=s(15),f=(s(268),s(16)),w=s(461);class v extends c.a.PureComponent{render(){const e=this.props,t=e.message,s=e.messages,r=e.t,o=""!==t&&t?t.split("|").length>1?"".concat(r("messages:".concat(t.split("|")[0])),": ").concat(r("messages:".concat(t.split("|")[1]))):r("messages:".concat(t)):"";return Object(a.jsxs)("div",{className:"error-message",children:[""!==o&&Object(a.jsx)("code",{children:o}),s&&s.length>0&&Object(a.jsx)("code",{children:Object(a.jsx)("ul",{children:s.map((e=>Object(a.jsx)("li",{children:r("messages:".concat(e.value))},e.id)))})})]})}}var k=s(8),y=s(480),N=s(479),_=s(213);const S=["bytes","KB","MB","GB","TB"],D=(e,t=!0)=>{const s=Math.floor(Math.log(e)/Math.log(1024));if(!e)return t?"0 bytes":{size:0,suffix:"bytes"};const a=(e/Math.pow(1024,s)).toFixed(1),r=S[s];return t?"".concat(a).concat(r):{size:a,suffix:r}},C="/api/",E=[{key:"workouts_count",label:"workouts count"},{key:"admin",label:"admin rights"},{key:"created_at",label:"registration date"},{key:"username",label:"user name"}],A=[{key:"asc",label:"ascending"},{key:"desc",label:"descending"}],M=()=>!!window.localStorage.authToken,T=e=>{const t={};e.noAuthorization||(t.Authorization="Bearer ".concat(window.localStorage.getItem("authToken"))),e.type&&(t["Content-Type"]=e.type);const s={method:e.method,headers:t};"application/json"===e.type&&e.body?s.body=JSON.stringify(e.body):e.body&&(s.body=e.body);const a=new Request("".concat(C).concat(e.url),s);return fetch(a).then((t=>"DELETE"===e.method||413===t.status?t:t.json())).catch((e=>(console.error(e),new Error("An error occurred. Please contact the administrator."))))},P=(e,t)=>{if(!e)return"";const s=_.DateTime.fromISO(Object(y.a)(new Date(e),"yyyy-MM-dd'T'HH:mm:ss.SSSxxx")).setZone(t);return Object(N.a)(s.toFormat("yyyy-MM-dd HH:mm:ss"),"yyyy-MM-dd HH:mm:ss",new Date)},F=(e,t)=>{const s=e.label.toLowerCase(),a=t.label.toLowerCase();return s>a?1:st.map((t=>Object(k.a)(Object(k.a)({},t),{},{label:e("".concat(s,":").concat(t.label))}))).sort(F),R=(e,t)=>{let s=e;return t.id||"users"===e&&t.username?s="".concat(s,"/").concat(t.username?t.username:t.id):Object.keys(t).length>0&&(s+="?",Object.keys(t).filter((e=>t[e])).map(((e,a)=>s+="".concat(0===a?"":"&").concat(e,"=").concat(t[e])))),s};class L{static getData(e,t={}){const s=R(e,t);return T({url:s,method:"GET",type:"application/json"})}static addData(e,t){return T({url:e,method:"POST",body:t,type:"application/json"})}static addDataWithFile(e,t){return T({url:e,method:"POST",body:t})}static postData(e,t){const s={url:"".concat(e).concat(t.id?"/".concat(t.id):""),method:"POST",body:t,type:"application/json"};return T(s)}static updateData(e,t){const s={url:"".concat(e).concat(t.id?"/".concat(t.id):t.username?"/".concat(t.username):""),method:"PATCH",body:t,type:"application/json"};return T(s)}static deleteData(e,t){const s={url:"".concat(e,"/").concat(t),method:"DELETE",type:"application/json"};return T(s)}}const U=(e,t)=>({type:"SET_DATA",data:t,target:e}),I=e=>({type:"SET_ERROR",message:e}),W=e=>({type:"SET_LOADING",loading:e}),H=(e,t,s,a=!0)=>r=>(r(W(!0)),s&&s.id&&"workouts"!==t&&isNaN(s.id)?(r(W(!1)),r(I("".concat(t,"|Incorrect id")))):(r(I("")),L[e](t,s).then((s=>{if("success"===s.status)if(a){if("users"===t&&"getData"===e)return r(((e,t,s)=>({type:"SET_PAGINATED_DATA",data:t,pagination:s,target:e}))(t,s.data,s.pagination));r(U(t,s.data))}else"updateData"===e&&"sports"===t?r((e=>({type:"UPDATE_SPORT_DATA",data:e}))(s.data.sports[0])):"updateData"===e&&"users"===t&&r((e=>({type:"UPDATE_USER_DATA",data:e}))(s.data.users[0]));else r(I("".concat(t,"|").concat(s.message||s.status)));r(W(!1))})).catch((e=>{r(W(!1)),r(I("".concat(t,"|").concat(e)))})))),q=e=>t=>{j.a.changeLanguage(e).then(t((e=>({type:"SET_LANGUAGE",language:e}))(e)))},B=e=>({type:"SET_APP_CONFIG",data:e}),V=e=>t=>L.getData(e).then((s=>{"success"===s.status?"config"===e?t(B(s.data)):"stats/all"===e&&t({type:"SET_APP_STATS",data:s.data}):t(I("application|".concat(s.message)))})).catch((e=>t(I("application|".concat(e)))));class G extends c.a.Component{constructor(e,t){super(e,t),this.state={formData:{},isInEdition:!1}}componentDidMount(){this.initForm()}componentDidUpdate(e){this.props.appConfig!==e.appConfig&&this.initForm()}initForm(){const e=this.props.appConfig,t={};Object.keys(e).map((s=>null===e[s]?t[s]="":["max_single_file_size","max_zip_file_size"].includes(s)?t[s]=+(e[s]/1048576).toFixed(2):t[s]=e[s])),this.setState({formData:t})}handleFormChange(e){const t=this.state.formData;t[e.target.name]=+e.target.value,this.setState(t)}toggleInEdition(e){e.preventDefault();const t=this.state.isInEdition;this.setState({isInEdition:!t})}render(){const e=this.props,t=e.message,s=e.onHandleConfigFormSubmit,r=e.t,o=this.state,c=o.formData,n=o.isInEdition;return Object(a.jsxs)("div",{children:[t&&Object(a.jsx)(v,{message:t,t:r}),Object.keys(c).length>0&&Object(a.jsx)("div",{className:"row",children:Object(a.jsx)("div",{className:"col-md-12",children:Object(a.jsxs)("div",{className:"card",children:[Object(a.jsx)("div",{className:"card-header",children:Object(a.jsx)("strong",{children:r("administration:Application configuration")})}),Object(a.jsx)("div",{className:"card-body",children:Object(a.jsxs)("form",{className:"app-config-form ".concat(n?"":"form-disabled"),onSubmit:e=>{this.toggleInEdition(e),s(c)},children:[Object(a.jsxs)("div",{className:"form-group row",children:[Object(a.jsxs)("label",{className:"col-sm-6 col-form-label",htmlFor:"max_users",children:[r("administration:Max. number of active users"),Object(a.jsx)("sup",{children:Object(a.jsx)("i",{className:"fa fa-question-circle","aria-hidden":"true",title:r("administration:if 0, no limitation")})}),":"]}),Object(a.jsx)("input",{className:"col-sm-5",id:"max_users",name:"max_users",type:"number",min:"0",value:c.max_users,onChange:e=>this.handleFormChange(e)})]}),Object(a.jsxs)("div",{className:"form-group row",children:[Object(a.jsxs)("label",{className:"col-sm-6 col-form-label",htmlFor:"max_single_file_size",children:[r("administration:Max. size of uploaded files (in Mb)"),":"]}),Object(a.jsx)("input",{className:"col-sm-5",id:"max_single_file_size",name:"max_single_file_size",type:"number",step:"0.1",min:"0",value:c.max_single_file_size,onChange:e=>this.handleFormChange(e)})]}),Object(a.jsxs)("div",{className:"form-group row",children:[Object(a.jsxs)("label",{className:"col-sm-6 col-form-label",htmlFor:"max_zip_file_size",children:[r("administration:Max. size of zip archive (in Mb)"),":"]}),Object(a.jsx)("input",{className:"col-sm-5",id:"max_zip_file_size",name:"max_zip_file_size",type:"number",step:"0.1",min:"0",value:c.max_zip_file_size,onChange:e=>this.handleFormChange(e)})]}),Object(a.jsxs)("div",{className:"form-group row",children:[Object(a.jsx)("label",{className:"col-sm-6 col-form-label",htmlFor:"gpx_limit_import",children:r("administration:Max. files of zip archive")}),Object(a.jsx)("input",{className:"col-sm-5",id:"gpx_limit_import",name:"gpx_limit_import",type:"number",min:"0",value:c.gpx_limit_import,onChange:e=>this.handleFormChange(e)})]}),n?Object(a.jsxs)(a.Fragment,{children:[Object(a.jsx)("input",{type:"submit",className:"btn btn-primary",value:r("common:Submit")}),Object(a.jsx)("input",{type:"submit",className:"btn btn-secondary",onClick:e=>this.toggleInEdition(e),value:r("common:Cancel")})]}):Object(a.jsxs)(a.Fragment,{children:[Object(a.jsx)("input",{type:"submit",className:"btn btn-primary",onClick:e=>{this.toggleInEdition(e)},value:r("common:Edit")}),Object(a.jsx)("input",{type:"submit",className:"btn btn-secondary",onClick:()=>Ta.push("/admin"),value:r("common:Back")})]})]})})]})})})]})}}var J=Object(O.c)((e=>({message:e.message})),(e=>({onHandleConfigFormSubmit:t=>{const s=Object.assign({},t);s.max_single_file_size*=1048576,s.max_zip_file_size*=1048576,e((e=>t=>L.updateData("config",e).then((e=>{"success"===e.status?t(B(e.data)):t(I("application|".concat(e.message)))})).catch((e=>t(I("application|".concat(e))))))(s))}})))(G),K=s(11);class Y extends c.a.Component{componentDidMount(){this.props.loadAppStats()}render(){const e=this.props,t=e.appStats,s=e.t,r=D(t.uploads_dir_size,!1);return Object(a.jsxs)("div",{className:"row",children:[Object(a.jsx)("div",{className:"col-lg-3 col-md-6 col-sm-6",children:Object(a.jsx)("div",{className:"card workout-card",children:Object(a.jsxs)("div",{className:"card-body row",children:[Object(a.jsx)("div",{className:"col-3",children:Object(a.jsx)("i",{className:"fa fa-users fa-3x fa-color"})}),Object(a.jsxs)("div",{className:"col-9 text-right",children:[Object(a.jsx)("div",{className:"huge",children:t.users?t.users:0}),Object(a.jsx)("div",{children:"".concat(1===t.users?s("administration:user"):s("administration:users"))})]})]})})}),Object(a.jsx)("div",{className:"col-lg-3 col-md-6 col-sm-6",children:Object(a.jsx)("div",{className:"card workout-card",children:Object(a.jsxs)("div",{className:"card-body row",children:[Object(a.jsx)("div",{className:"col-3",children:Object(a.jsx)("i",{className:"fa fa-tags fa-3x fa-color"})}),Object(a.jsxs)("div",{className:"col-9 text-right",children:[Object(a.jsx)("div",{className:"huge",children:t.sports?t.sports:0}),Object(a.jsx)("div",{children:"".concat(1===t.sports?s("common:sport"):s("common:sports"))})]})]})})}),Object(a.jsx)("div",{className:"col-lg-3 col-md-6 col-sm-6",children:Object(a.jsx)("div",{className:"card workout-card",children:Object(a.jsxs)("div",{className:"card-body row",children:[Object(a.jsx)("div",{className:"col-3",children:Object(a.jsx)("i",{className:"fa fa-calendar fa-3x fa-color"})}),Object(a.jsxs)("div",{className:"col-9 text-right",children:[Object(a.jsx)("div",{className:"huge",children:t.workouts?t.workouts:0}),Object(a.jsx)("div",{children:"".concat(1===t.workouts?s("common:workout"):s("common:workouts"))})]})]})})}),Object(a.jsx)("div",{className:"col-lg-3 col-md-6 col-sm-6",children:Object(a.jsx)("div",{className:"card workout-card",children:Object(a.jsxs)("div",{className:"card-body row",children:[Object(a.jsx)("div",{className:"col-3",children:Object(a.jsx)("i",{className:"fa fa-folder-open fa-3x fa-color"})}),Object(a.jsxs)("div",{className:"col-9 text-right",children:[Object(a.jsx)("div",{className:"huge",children:r.size}),Object(a.jsxs)("div",{children:[r.suffix," (",s("administration:uploads"),")"]})]})]})})})]})}}var X=Object(w.a)()(Object(O.c)((e=>({appStats:e.application.statistics})),(e=>({loadAppStats:()=>{e(V("stats/all"))}})))(Y));function $(e){const t=e.appConfig,s=e.t;return Object(a.jsxs)("div",{className:"card workout-card",children:[Object(a.jsx)("div",{className:"card-header",children:Object(a.jsx)("strong",{children:s("administration:Administration")})}),Object(a.jsxs)("div",{className:"card-body",children:[Object(a.jsx)(X,{}),Object(a.jsx)("br",{}),Object(a.jsxs)("dl",{className:"admin-items",children:[Object(a.jsx)("dt",{children:Object(a.jsx)(K.a,{to:{pathname:"/admin/application"},children:s("administration:Application")})}),Object(a.jsxs)("dd",{children:[s("administration:Update application configuration (maximum number of registered users, maximum files size)."),Object(a.jsx)("br",{}),Object(a.jsx)("strong",{children:s("administration:Registration is currently ".concat(t.is_registration_enabled?"enabled":"disabled","."))})]}),Object(a.jsx)("br",{}),Object(a.jsx)("dt",{children:Object(a.jsx)(K.a,{to:{pathname:"/admin/sports"},children:s("administration:Sports")})}),Object(a.jsx)("dd",{children:s("administration:Enable/disable sports.")}),Object(a.jsx)("br",{}),Object(a.jsx)("dt",{children:Object(a.jsx)(K.a,{to:{pathname:"/admin/users"},children:s("administration:Users")})}),Object(a.jsx)("dd",{children:s("administration:Add/remove admin rights, delete user account.")})]})]})]})}class Z extends c.a.Component{componentDidMount(){this.props.loadSports()}render(){const e=this.props,t=e.message,s=e.sports,r=e.t,o=e.updateSport;return Object(a.jsxs)("div",{children:[t&&Object(a.jsx)(v,{message:t,t:r}),Object(a.jsx)("div",{className:"row",children:Object(a.jsx)("div",{className:"col",children:Object(a.jsxs)("div",{className:"card",children:[Object(a.jsx)("div",{className:"card-header",children:Object(a.jsx)("strong",{children:r("administration:Sports")})}),Object(a.jsxs)("div",{className:"card-body",children:[s.length>0&&Object(a.jsxs)("table",{className:"table",children:[Object(a.jsx)("thead",{children:Object(a.jsxs)("tr",{children:[Object(a.jsx)("th",{children:r("administration:id")}),Object(a.jsx)("th",{children:r("administration:Image")}),Object(a.jsx)("th",{children:r("administration:Label")}),Object(a.jsx)("th",{children:r("administration:Active")}),Object(a.jsx)("th",{children:r("administration:Actions")})]})}),Object(a.jsx)("tbody",{children:s.map((e=>Object(a.jsxs)("tr",{children:[Object(a.jsxs)("td",{children:[Object(a.jsx)("span",{className:"heading-span-absolute",children:r("administration:id")}),e.id]}),Object(a.jsxs)("td",{children:[Object(a.jsx)("span",{className:"heading-span-absolute",children:r("administration:Image")}),Object(a.jsx)("img",{className:"admin-img",src:e.img?e.img:"/img/photo.png",alt:"sport logo"})]}),Object(a.jsxs)("td",{children:[Object(a.jsx)("span",{className:"heading-span-absolute",children:r("administration:Label")}),r("sports:".concat(e.label))]}),Object(a.jsxs)("td",{children:[Object(a.jsx)("span",{className:"heading-span-absolute",children:r("administration:Active")}),e.is_active?Object(a.jsx)("i",{className:"fa fa-check-square-o custom-fa","aria-hidden":"true","data-toggle":"tooltip"}):Object(a.jsx)("i",{className:"fa fa-square-o custom-fa","aria-hidden":"true","data-toggle":"tooltip"})]}),Object(a.jsxs)("td",{children:[Object(a.jsx)("span",{className:"heading-span-absolute",children:r("administration:Actions")}),Object(a.jsx)("input",{type:"submit",className:"btn btn-".concat(e.is_active?"dark":"primary"," btn-sm"),value:e.is_active?r("administration:Disable"):r("administration:Enable"),onClick:()=>o(e.id,!e.is_active)}),e.has_workouts&&Object(a.jsxs)("span",{className:"admin-message",children:[Object(a.jsx)("i",{className:"fa fa-warning custom-fa","aria-hidden":"true"}),r("administration:workouts exist")]})]})]},e.id)))})]}),Object(a.jsx)("input",{type:"submit",className:"btn btn-secondary",onClick:()=>Ta.push("/admin/"),value:r("common:Back")})]})]})})})]})}}var Q=Object(O.c)((e=>({message:e.message,sports:e.sports.data,user:e.user})),(e=>({loadSports:()=>{e(H("getData","sports"))},updateSport:(t,s)=>{e(H("updateData","sports",{id:t,is_active:s},!1))}})))(Z);class ee extends c.a.PureComponent{getUrl(e){const t=this.props,s=t.query,a=t.pathname,r=Object.assign({},s);let o=s.page?+s.page:1;switch(e){case"prev":o-=1;break;case"next":o+=1;break;default:o=+e}return r.page=o,R(a,r)}render(){const e=this.props,t=e.pagination,s=e.t;return Object(a.jsx)(a.Fragment,{children:t&&Object.keys(t).length>0&&Object(a.jsx)("nav",{"aria-label":"Page navigation example",children:Object(a.jsxs)("ul",{className:"pagination justify-content-center",children:[Object(a.jsx)("li",{className:"page-item ".concat(t.has_prev?"":"disabled"),children:Object(a.jsx)(K.a,{className:"page-link",to:this.getUrl("prev"),"aria-disabled":!t.has_prev,children:s("common:Previous")})}),(r=t.pages,Array.from({length:r},((e,t)=>t+1))).map((e=>Object(a.jsx)("li",{className:"page-item ".concat(e===t.page?"active":""),children:Object(a.jsx)(K.a,{className:"page-link",to:this.getUrl(e),children:e})},e))),Object(a.jsx)("li",{className:"page-item ".concat(t.has_next?"":"disabled"),children:Object(a.jsx)(K.a,{className:"page-link",to:this.getUrl("next"),"aria-disabled":!t.has_next,children:s("common:Next")})})]})})});var r}}class te extends c.a.Component{constructor(e,t){super(e,t),this.state={page:null,per_page:null,order_by:"created_at",order:"asc"}}componentDidMount(){this.props.loadUsers(this.initState())}componentDidUpdate(e){e.location.query!==this.props.location.query&&this.props.loadUsers(this.props.location.query)}initState(){const e=this.props.location.query,t={page:e.page,per_page:e.per_page,order_by:e.order_by?e.order_by:"created_at",order:e.order?e.order:"asc"};return this.setState(t),t}updatePage(e,t){const s=Object.assign({},this.state);s[e]=t,this.setState(s);const a=R(this.props.location.pathname,s);Ta.push(a)}render(){const e=this.props,t=e.authUser,s=e.location,r=e.message,o=e.t,c=e.pagination,n=e.updateUser,i=e.users,l=z(o,E),d=z(o,A);return Object(a.jsxs)("div",{children:[r&&Object(a.jsx)(v,{message:r,t:o}),Object(a.jsx)("div",{className:"container",children:Object(a.jsx)("div",{className:"row",children:Object(a.jsx)("div",{className:"col",children:Object(a.jsxs)("div",{className:"card",children:[Object(a.jsx)("div",{className:"card-header",children:Object(a.jsx)("strong",{children:o("administration:Users")})}),Object(a.jsxs)("div",{className:"card-body",children:[Object(a.jsxs)("div",{className:"row user-filters",children:[Object(a.jsx)("div",{className:"col-lg-4 col-md-6 col-sm-12",children:Object(a.jsxs)("label",{htmlFor:"order_by",children:[o("common:Sort by"),":"," ",Object(a.jsx)("select",{id:"order_by",name:"order_by",value:this.state.order_by,onChange:e=>this.updatePage("order_by",e.target.value),children:l.map((e=>Object(a.jsx)("option",{value:e.key,children:e.label},e.key)))})," "]})}),Object(a.jsx)("div",{className:"col-lg-4 col-md-6 col-sm-12",children:Object(a.jsxs)("label",{htmlFor:"sort",children:[o("common:Sort"),":"," ",Object(a.jsx)("select",{id:"sort",name:"sort",value:this.state.order,onChange:e=>this.updatePage("order",e.target.value),children:d.map((e=>Object(a.jsx)("option",{value:e.key,children:e.label},e.key)))})," "]})})]}),Object(a.jsxs)("table",{className:"table",children:[Object(a.jsx)("thead",{children:Object(a.jsxs)("tr",{children:[Object(a.jsx)("th",{children:"#"}),Object(a.jsx)("th",{children:o("user:Username")}),Object(a.jsx)("th",{children:o("user:Email")}),Object(a.jsx)("th",{children:o("user:Registration Date")}),Object(a.jsx)("th",{children:o("workouts:Workouts")}),Object(a.jsx)("th",{children:o("user:Admin")}),Object(a.jsx)("th",{children:o("administration:Actions")})]})}),Object(a.jsx)("tbody",{children:i.map((e=>Object(a.jsxs)("tr",{children:[Object(a.jsxs)("td",{children:[Object(a.jsx)("span",{className:"heading-span-absolute",children:"#"}),!0===e.picture?Object(a.jsx)("img",{alt:"Avatar",src:"".concat(C,"users/").concat(e.username,"/picture?").concat(Date.now()),className:"img-fluid App-nav-profile-img"}):Object(a.jsx)("i",{className:"fa fa-user-circle-o fa-2x no-picture","aria-hidden":"true"})]}),Object(a.jsxs)("td",{children:[Object(a.jsx)("span",{className:"heading-span-absolute",children:o("user:Username")}),Object(a.jsx)(K.a,{to:"/users/".concat(e.username),children:e.username})]}),Object(a.jsxs)("td",{children:[Object(a.jsx)("span",{className:"heading-span-absolute",children:o("user:Email")}),e.email]}),Object(a.jsxs)("td",{children:[Object(a.jsx)("span",{className:"heading-span-absolute",children:o("user:Registration Date")}),Object(y.a)(new Date(e.created_at),"dd/MM/yyyy HH:mm")]}),Object(a.jsxs)("td",{children:[Object(a.jsx)("span",{className:"heading-span-absolute",children:o("workouts:Workouts")}),e.nb_workouts]}),Object(a.jsxs)("td",{children:[Object(a.jsx)("span",{className:"heading-span-absolute",children:o("user:Admin")}),e.admin?Object(a.jsx)("i",{className:"fa fa-check-square-o custom-fa","aria-hidden":"true","data-toggle":"tooltip"}):Object(a.jsx)("i",{className:"fa fa-square-o custom-fa","aria-hidden":"true","data-toggle":"tooltip"})]}),Object(a.jsxs)("td",{children:[Object(a.jsx)("span",{className:"heading-span-absolute",children:o("administration:Actions")}),Object(a.jsx)("input",{type:"submit",className:"btn btn-".concat(e.admin?"dark":"primary"," btn-sm"),disabled:e.username===t.username,value:e.admin?o("administration:Remove admin rights"):o("administration:Add admin rights"),onClick:()=>n(e.username,!e.admin)})]})]},e.username)))})]}),Object(a.jsx)(ee,{pagination:c,pathname:s.pathname,query:this.state,t:o}),Object(a.jsx)("input",{type:"submit",className:"btn btn-secondary",onClick:()=>Ta.push("/admin/"),value:o("common:Back")})]})]})})})})]})}}var se=Object(O.c)((e=>({authUser:e.user,location:e.router.location,message:e.message,pagination:e.users.pagination,users:e.users.data})),(e=>({loadUsers:t=>{e(H("getData","users",t))},updateUser:(t,s)=>{e(H("updateData","users",{username:t,admin:s},!1))}})))(te),ae=s(214);function re(){const e=Object(ae.a)().t;return Object(a.jsxs)("div",{children:[Object(a.jsx)(f.a,{children:Object(a.jsx)("title",{children:"fittrackee - 404"})}),Object(a.jsx)("h1",{className:"page-title",children:e("Page not found")})]})}var oe=Object(w.a)()(Object(O.c)((e=>({appConfig:e.application.config,user:e.user})))((function(e){const t=e.appConfig,s=e.t,r=e.user;return Object(a.jsxs)(a.Fragment,{children:[Object(a.jsx)(f.a,{children:Object(a.jsxs)("title",{children:["FitTrackee - ",s("administration:Administration")]})}),Object(a.jsx)("div",{className:"container dashboard",children:r.admin?Object(a.jsxs)(g.d,{children:[Object(a.jsx)(g.b,{exact:!0,path:"/admin",render:()=>Object(a.jsx)($,{appConfig:t,t:s})}),Object(a.jsx)(g.b,{exact:!0,path:"/admin/application",render:()=>Object(a.jsx)(J,{appConfig:t,t:s})}),Object(a.jsx)(g.b,{exact:!0,path:"/admin/sports",render:()=>Object(a.jsx)(Q,{t:s})}),Object(a.jsx)(g.b,{exact:!0,path:"/admin/users",render:()=>Object(a.jsx)(se,{t:s})}),Object(a.jsx)(g.b,{component:re})]}):Object(a.jsx)(re,{})})]})}))),ce=s(462),ne=s(20),ie=s(482),le=s(217),de=s.n(le);const ue=["#55a8a3","#98C3A9","#D0838A","#ECC77E","#926692","#929292","#428bca"],me=[{record_type:"AS",label:"Ave. speed"},{record_type:"FD",label:"Farest distance"},{record_type:"LD",label:"Longest duration"},{record_type:"MS",label:"Max. speed"}],je=(e,t=null,s=null)=>(t||(t="yyyy/MM/dd"),s||(s="HH:mm"),{workout_date:e?Object(y.a)(e,t):null,workout_time:e?Object(y.a)(e,s):null}),pe=e=>{let t=new Date(0);return t=Object(ie.a)(t.setSeconds(e),1),t.getTime()},he=e=>{for(let t=0;t{const s=e.label.toLowerCase(),a=t.label.toLowerCase();return s>a?1:se.filter((e=>!s||e.is_active)).map((e=>Object(k.a)(Object(k.a)({},e),{},{label:t("sports:".concat(e.label))}))).sort(be);class Oe{static loginOrRegisterOrPasswordReset(e,t){const s={url:"auth/".concat(e),method:"POST",noAuthorization:!0,body:t,type:"application/json"};return T(s)}static deletePicture(){return T({url:"auth/picture",method:"DELETE"})}}const ge=e=>({type:"PICTURE_ERROR",message:e}),fe=e=>({type:"PROFILE_UPDATE_ERROR",message:e}),we=()=>e=>window.localStorage.getItem("authToken")?e(ve()):{type:"LOGOUT"},ve=()=>e=>L.getData("auth/profile").then((t=>"success"===t.status?(e(H("getData","sports")),t.data.isAuthenticated=!0,t.data.language&&e(q(t.data.language)),e({type:"PROFILE_SUCCESS",profil:t.data})):e({type:"PROFILE_ERROR",message:t.message}))).catch((e=>{throw e})),ke=(e,t)=>s=>{if("register"===t||"password/update"===t){const a=((e,t=!1)=>{const s=[];return!t&&(e.username.length<3||e.username.length>12)&&s.push("3 to 12 characters required for username."),e.password!==e.password_conf&&s.push("Password and password confirmation don't match."),e.password.length<8&&s.push("8 characters required for password."),s})(e,"password/update"===t);if(a.length>0)return s({type:"AUTH_ERRORS",messages:(e=>{let t=0;return e.map((e=>{const s={id:t,value:e};return t++,s}))})(a)})}return s(((e,t)=>s=>Oe.loginOrRegisterOrPasswordReset(e,t).then((t=>{if("success"===t.status){if("password/reset-request"===e)return Ta.push({pathname:"/password-reset/sent"});if("password/update"===e)return Ta.push({pathname:"/updated-password"});if("login"===e||"register"===e)return window.localStorage.setItem("authToken",t.auth_token),"register"===e&&s(V("config")),s(ve())}return s({type:"AUTH_ERROR",message:t.message})})).catch((e=>{throw e})))(t,e))},ye=(e,t=!1)=>s=>L.deleteData("users",e).then((e=>{204===e.status?(s(V("config")),t?Ta.push("/admin/users"):(s({type:"LOGOUT"}),Ta.push("/"))):e.json().then((e=>s(I("".concat(e.message)))))})).catch((e=>s(I("user|".concat(e))))),Ne=e=>({type:"SET_GPX",gpxContent:e}),_e=e=>({type:"SET_CHART_DATA",chartData:e}),Se=e=>t=>L.updateData("workouts",e).then((e=>{"success"===e.status?(t(we()),Ta.push("/workouts/".concat(e.data.workouts[0].id))):t(I("workouts|".concat(e.message))),t(W(!1))})).catch((e=>{t(W(!1)),t(I("workouts|".concat(e)))})),De=e=>t=>L.getData("workouts",e).then((e=>{"success"===e.status?e.data.workouts.length>0&&t({type:"PUSH_WORKOUTS",workouts:e.data.workouts}):t(I("workouts|".concat(e.message)))})).catch((e=>t(I("workouts|".concat(e)))));var Ce=Object(O.c)((e=>({appConfig:e.application.config,loading:e.loading})),(e=>({onAddWorkout:t=>{e(W(!0));const s=new FormData;s.append("file",t.target.form.gpxFile.files[0]),s.append("data",'{"sport_id": '.concat(t.target.form.sport.value,', "notes": "').concat(t.target.form.notes.value,'"}')),e((e=>t=>L.addDataWithFile("workouts",e).then((e=>{"created"===e.status?0===e.data.workouts.length?t(I("workouts|no correct file.")):1===e.data.workouts.length?(t(we()),Ta.push("/workouts/".concat(e.data.workouts[0].id))):(t(we()),Ta.push("/")):413===e.status?t(I("workouts|File size is greater than the allowed size")):t(I("workouts|".concat(e.message))),t(W(!1))})).catch((e=>{t(W(!1)),t(I("workouts|".concat(e)))})))(s))},onEditWorkout:(t,s)=>{e(Se({id:s.id,notes:t.target.form.notes.value,sport_id:+t.target.form.sport.value,title:t.target.form.title.value}))}})))((function(e){const t=e.appConfig,s=e.loading,r=e.onAddWorkout,o=e.onEditWorkout,c=e.sports,n=e.t,i=e.workout,l=i?i.sport_id:"",d=xe(c,n,!0),u="".concat(n("workouts:no folder inside"),", ").concat(t.gpx_limit_import," ").concat(n("workouts:files max"),", ").concat(n("workouts:max size"),": ").concat(D(t.max_zip_file_size)),m=D(t.max_single_file_size);return Object(a.jsxs)("form",{encType:"multipart/form-data",method:"post",onSubmit:e=>e.preventDefault(),children:[Object(a.jsx)("div",{className:"form-group",children:Object(a.jsxs)("label",{children:[n("common:Sport"),":",Object(a.jsxs)("select",{className:"form-control input-lg",defaultValue:l,disabled:s,name:"sport",required:!0,children:[Object(a.jsx)("option",{value:""}),d.map((e=>Object(a.jsx)("option",{value:e.id,children:e.label},e.id)))]})]})}),i?Object(a.jsx)("div",{className:"form-group",children:Object(a.jsxs)("label",{children:[n("workouts:Title"),":",Object(a.jsx)("input",{name:"title",defaultValue:i?i.title:"",disabled:s,className:"form-control input-lg"})]})}):Object(a.jsx)("div",{className:"form-group",children:Object(a.jsxs)("label",{children:[Object(a.jsxs)(ce.a,{i18nKey:"workouts:gpxFile",children:[Object(a.jsx)("strong",{children:"gpx"})," file"]}),Object(a.jsx)("sup",{children:Object(a.jsx)("i",{className:"fa fa-question-circle","aria-hidden":"true","data-toggle":"tooltip",title:"".concat(n("workouts:max size"),": ").concat(m)})})," ",Object(a.jsxs)(ce.a,{i18nKey:"workouts:zipFile",children:["or ",Object(a.jsx)("strong",{children:" zip"})," file containing ",Object(a.jsx)("strong",{children:"gpx "}),"files"]}),Object(a.jsx)("sup",{children:Object(a.jsx)("i",{className:"fa fa-question-circle","aria-hidden":"true","data-toggle":"tooltip","data-placement":"top",title:u})})," ",":",Object(a.jsx)("input",{accept:".gpx, .zip",className:"form-control form-control-file gpx-file",disabled:s,name:"gpxFile",required:!0,type:"file"})]})}),Object(a.jsx)("div",{className:"form-group",children:Object(a.jsxs)("label",{children:[n("workouts:Notes"),":",Object(a.jsx)("textarea",{name:"notes",defaultValue:i?i.notes:"",disabled:s,className:"form-control input-lg",maxLength:"500"})]})}),s?Object(a.jsx)("div",{className:"loader"}):Object(a.jsxs)("div",{children:[Object(a.jsx)("input",{type:"submit",className:"btn btn-primary",onClick:e=>i?o(e,i):r(e),value:n("common:Submit")}),Object(a.jsx)("input",{type:"submit",className:"btn btn-secondary",onClick:()=>Ta.push("/"),value:n("common:Cancel")})]})]})}));var Ee=Object(O.c)((e=>({user:e.user})),(e=>({onAddOrEdit:(t,s)=>{const a=t.target.form.duration.value.split(":"),r=60*+a[0]*60+60*+a[1]+ +a[2],o={workout_date:"".concat(t.target.form.workout_date.value," ").concat(t.target.form.workout_time.value),distance:+t.target.form.distance.value,duration:r,notes:t.target.form.notes.value,sport_id:+t.target.form.sport_id.value,title:t.target.form.title.value};var c;s?(o.id=s.id,e(Se(o))):e((c=o,e=>L.addData("workouts/no_gpx",c).then((t=>{"created"===t.status?(e(we()),Ta.push("/workouts/".concat(t.data.workouts[0].id))):e(I("workouts|".concat(t.message)))})).catch((t=>e(I("workouts|".concat(t)))))))}})))((function(e){const t=e.onAddOrEdit,s=e.sports,r=e.t,o=e.user,c=e.workout,n=xe(s,r,!0);let i,l,d="";if(c){const e=je(P(c.workout_date,o.timezone),"yyyy-MM-dd");i=e.workout_date,l=e.workout_time,d=c.sport_id}return Object(a.jsxs)("form",{onSubmit:e=>e.preventDefault(),children:[Object(a.jsx)("div",{className:"form-group",children:Object(a.jsxs)("label",{children:[r("workouts:Title"),":",Object(a.jsx)("input",{name:"title",defaultValue:c?c.title:"",className:"form-control input-lg"})]})}),Object(a.jsx)("div",{className:"form-group",children:Object(a.jsxs)("label",{children:[r("common:Sport"),":",Object(a.jsxs)("select",{className:"form-control input-lg",defaultValue:d,name:"sport_id",required:!0,children:[Object(a.jsx)("option",{value:""}),n.map((e=>Object(a.jsx)("option",{value:e.id,children:e.label},e.id)))]})]})}),Object(a.jsx)("div",{className:"form-group",children:Object(a.jsxs)("label",{children:[r("workouts:Workout Date"),":",Object(a.jsx)("div",{className:"container",children:Object(a.jsxs)("div",{className:"row",children:[Object(a.jsx)("input",{name:"workout_date",defaultValue:i,className:"form-control col-md",required:!0,type:"date"}),Object(a.jsx)("input",{name:"workout_time",defaultValue:l,className:"form-control col-md",required:!0,type:"time"})]})})]})}),Object(a.jsx)("div",{className:"form-group",children:Object(a.jsxs)("label",{children:[r("workouts:Duration"),":",Object(a.jsx)("input",{name:"duration",defaultValue:c?c.duration:"",className:"form-control col-xs-4",pattern:"^([0-9]*[0-9]):([0-5][0-9]):([0-5][0-9])$",placeholder:"hh:mm:ss",required:!0,type:"text"})]})}),Object(a.jsx)("div",{className:"form-group",children:Object(a.jsxs)("label",{children:[r("workouts:Distance")," (km):",Object(a.jsx)("input",{name:"distance",defaultValue:c?c.distance:"",className:"form-control input-lg",min:0,required:!0,step:"0.001",type:"number"})]})}),Object(a.jsx)("div",{className:"form-group",children:Object(a.jsxs)("label",{children:[r("workouts:Notes"),":",Object(a.jsx)("textarea",{name:"notes",defaultValue:c?c.notes:"",className:"form-control input-lg",maxLength:"500"})]})}),Object(a.jsx)("input",{type:"submit",className:"btn btn-primary",onClick:e=>t(e,c),value:r("common:Submit")}),Object(a.jsx)("input",{type:"submit",className:"btn btn-secondary",onClick:()=>Ta.push("/"),value:r("common:Cancel")})]})}));class Ae extends c.a.Component{constructor(e,t){super(e,t),this.state={withGpx:!0}}handleRadioChange(e){this.setState({withGpx:"withGpx"===e.target.name?e.target.value:!e.target.value})}render(){const e=this.props,t=e.loading,s=e.message,r=e.sports,o=e.t,c=e.workout,n=this.state.withGpx;return Object(a.jsxs)("div",{children:[Object(a.jsx)(f.a,{children:Object(a.jsxs)("title",{children:["FitTrackee -"," ",o(c?"workouts:Edit a workout":"workouts:Add a workout")]})}),Object(a.jsx)("br",{}),Object(a.jsx)("br",{}),Object(a.jsx)(v,{message:s,t:o}),Object(a.jsx)("div",{className:"container",children:Object(a.jsxs)("div",{className:"row",children:[Object(a.jsx)("div",{className:"col-md-2"}),Object(a.jsx)("div",{className:"col-md-8",children:Object(a.jsxs)("div",{className:"card add-workout",children:[Object(a.jsx)("h2",{className:"card-header text-center",children:o(c?"workouts:Edit a workout":"workouts:Add a workout")}),Object(a.jsx)("div",{className:"card-body",children:c?c.with_gpx?Object(a.jsx)(Ce,{workout:c,sports:r,t:o}):Object(a.jsx)(Ee,{workout:c,sports:r,t:o}):Object(a.jsxs)("div",{children:[Object(a.jsx)("form",{children:Object(a.jsxs)("div",{className:"form-group row",children:[Object(a.jsx)("div",{className:"col",children:Object(a.jsxs)("label",{className:"radioLabel",children:[Object(a.jsx)("input",{className:"add-workout-radio",type:"radio",name:"withGpx",disabled:t,checked:n,onChange:e=>this.handleRadioChange(e)}),o("workouts:with gpx file")]})}),Object(a.jsx)("div",{className:"col",children:Object(a.jsxs)("label",{className:"radioLabel",children:[Object(a.jsx)("input",{className:"add-workout-radio",type:"radio",name:"withoutGpx",disabled:t,checked:!n,onChange:e=>this.handleRadioChange(e)}),o("workouts:without gpx file")]})})]})}),n?Object(a.jsx)(Ce,{sports:r,t:o}):Object(a.jsx)(Ee,{sports:r,t:o})]})})]})}),Object(a.jsx)("div",{className:"col-md-2"})]})})]})}}var Me=Object(w.a)()(Object(O.c)((e=>({loading:e.loading})))(Ae));var Te=Object(O.c)((e=>({message:e.message,sports:e.sports.data,user:e.user})))((function(e){const t=e.message,s=e.sports;return Object(a.jsx)("div",{children:Object(a.jsx)(Me,{workout:null,message:t,sports:s})})}));function Pe(e){const t=Object(ae.a)().t;return Object(a.jsx)("div",{className:"custom-modal-backdrop",children:Object(a.jsx)("div",{className:"custom-modal",children:Object(a.jsxs)("div",{className:"modal-content",children:[Object(a.jsxs)("div",{className:"modal-header",children:[Object(a.jsx)("h5",{className:"modal-title",children:e.title}),Object(a.jsx)("button",{type:"button",className:"close","aria-label":"Close",onClick:()=>e.close(),children:Object(a.jsx)("span",{"aria-hidden":"true",children:"\xd7"})})]}),Object(a.jsx)("div",{className:"modal-body",children:Object(a.jsx)("p",{children:e.text})}),Object(a.jsxs)("div",{className:"modal-footer",children:[Object(a.jsx)("button",{type:"button",className:"btn btn-primary",onClick:()=>e.confirm(),children:t("common:Yes")}),Object(a.jsx)("button",{type:"button",className:"btn btn-secondary",onClick:()=>e.close(),children:t("common:No")})]})]})})})}function Fe(e){const t=e.dataType,s=e.displayModal,r=e.segmentId,o=e.sport,c=e.t,n=e.title,i=e.user,l=e.workout,d=l?je(P(l.workout_date,i.timezone)):null,u="segment"===t&&1!==r?"/workouts/".concat(l.id,"/segment/").concat(r-1):"workout"===t&&l.previous_workout?"/workouts/".concat(l.previous_workout):null,m="segment"===t&&rs(!0),title:c("workouts:Delete workout")})]}):Object(a.jsxs)(a.Fragment,{children:[Object(a.jsx)(K.a,{to:"/workouts/".concat(l.id),children:n})," ","- ",c("workouts:segment")," ",r]}),Object(a.jsx)("br",{}),d&&Object(a.jsx)("span",{className:"workout-date",children:"".concat(d.workout_date," - ").concat(d.workout_time)})]}),Object(a.jsx)("div",{className:"col-auto",children:m?Object(a.jsx)(K.a,{className:"unlink",to:m,children:Object(a.jsx)("i",{className:"fa fa-chevron-right","aria-hidden":"true",title:c("workouts:See next ".concat(t))})}):Object(a.jsx)("i",{className:"fa fa-chevron-right inactive-link","aria-hidden":"true",title:c("workouts:No next ".concat(t))})})]})})}var ze=s(21);class Re extends c.a.Component{constructor(e,t){super(e,t),this.state={displayDistance:!0,dataToHide:[]}}componentDidMount(){"workout"===this.props.dataType?this.props.loadWorkoutData(this.props.workout.id):this.props.loadSegmentData(this.props.workout.id,this.props.segmentId)}componentDidUpdate(e){("workout"===this.props.dataType&&e.workout.id!==this.props.workout.id||"workout"===this.props.dataType&&"segment"===e.dataType)&&this.props.loadWorkoutData(this.props.workout.id),"segment"===this.props.dataType&&e.segmentId!==this.props.segmentId&&this.props.loadSegmentData(this.props.workout.id,this.props.segmentId)}componentWillUnmount(){this.props.loadWorkoutData(null)}handleRadioChange(e){this.setState({displayDistance:"distance"===e.target.name?e.target.value:!e.target.value})}handleLegendChange(e){const t=this.state.dataToHide,s=e.target.name;t.find((e=>e===s))?t.splice(t.indexOf(s),1):t.push(s),this.setState({dataToHide:t})}displayData(e){return!this.state.dataToHide.find((t=>t===e))}render(){const e=this.props,t=e.chartData,s=e.t,r=e.updateCoordinates,o=this.state.displayDistance,c=t?parseInt(t.length/10,10):0;let n,i;return o?(n="distance",i="linear"):(n="duration",i="time"),Object(a.jsx)("div",{className:"container",children:t&&t.length>0?Object(a.jsxs)("div",{children:[Object(a.jsxs)("div",{className:"row chart-radio",children:[Object(a.jsxs)("label",{className:"radioLabel col-md-1",children:[Object(a.jsx)("input",{type:"radio",name:"distance",checked:o,onChange:e=>this.handleRadioChange(e)}),s("workouts:distance")]}),Object(a.jsxs)("label",{className:"radioLabel col-md-1",children:[Object(a.jsx)("input",{type:"radio",name:"duration",checked:!o,onChange:e=>this.handleRadioChange(e)}),s("workouts:duration")]})]}),Object(a.jsxs)("div",{className:"row chart-radio",children:[Object(a.jsx)("div",{className:"col-md-5"}),Object(a.jsxs)("label",{className:"radioLabel col-md-1",children:[Object(a.jsx)("input",{type:"checkbox",name:"speed",checked:this.displayData("speed"),onChange:e=>this.handleLegendChange(e)}),s("workouts:speed")]}),Object(a.jsxs)("label",{className:"radioLabel col-md-1",children:[Object(a.jsx)("input",{type:"checkbox",name:"elevation",checked:this.displayData("elevation"),onChange:e=>this.handleLegendChange(e)}),s("workouts:elevation")]}),Object(a.jsx)("div",{className:"col-md-5"})]}),Object(a.jsx)("div",{className:"row chart",children:Object(a.jsx)(ze.f,{height:300,children:Object(a.jsxs)(ze.d,{data:t,margin:{top:15,right:30,left:20,bottom:15},onMouseMove:e=>r(e.activePayload),onMouseLeave:()=>r(null),children:[Object(a.jsx)(ze.h,{allowDecimals:!1,dataKey:n,label:{value:s("workouts:".concat(n)),offset:0,position:"bottom"},scale:i,interval:c,tickFormatter:e=>o?e:Object(y.a)(e,"HH:mm:ss"),type:"number"}),Object(a.jsx)(ze.i,{label:{value:"".concat(s("workouts:speed")," (km/h)"),angle:-90,position:"left"},yAxisId:"left"}),Object(a.jsx)(ze.i,{label:{value:"".concat(s("workouts:elevation")," (m)"),angle:-90,position:"right"},yAxisId:"right",orientation:"right"}),this.displayData("elevation")&&Object(a.jsx)(ze.a,{yAxisId:"right",type:"linear",dataKey:"elevation",name:s("workouts:elevation"),fill:"#e5e5e5",stroke:"#cccccc",dot:!1,unit:" m"}),this.displayData("speed")&&Object(a.jsx)(ze.e,{yAxisId:"left",type:"linear",dataKey:"speed",name:s("workouts:speed"),stroke:"#8884d8",strokeWidth:2,dot:!1,unit:" km/h"}),Object(a.jsx)(ze.g,{labelFormatter:e=>o?"".concat(s("workouts:distance"),": ").concat(e," km"):"".concat(s("workouts:duration"),": ").concat(Object(y.a)(e,"HH:mm:ss"))})]})})}),Object(a.jsx)("div",{className:"chart-info",children:s("workouts:data from gpx, without any cleaning")})]}):s("workouts:No data to display")})}}var Le=Object(O.c)((e=>({chartData:e.chartData})),(e=>({loadWorkoutData:t=>{e((e=>t=>{if(e)return L.getData("workouts/".concat(e,"/chart_data")).then((e=>{"success"===e.status?t(_e(he(e.data.chart_data))):t(I("workouts|".concat(e.message)))})).catch((e=>t(I("workouts|".concat(e)))));t(_e(null))})(t))},loadSegmentData:(t,s)=>{e(((e,t)=>s=>{if(e)return L.getData("workouts/".concat(e,"/chart_data/segment/").concat(t)).then((e=>{"success"===e.status?s(_e(he(e.data.chart_data))):s(I("workouts|".concat(e.message)))})).catch((e=>s(I("workouts|".concat(e)))));s(_e(null))})(t,s))}})))(Re);function Ue(e){const t=e.t,s=e.workout;return Object(a.jsx)("div",{className:"container",children:s.weather_start&&s.weather_end&&Object(a.jsxs)("table",{className:"table table-borderless weather-table text-center",children:[Object(a.jsx)("thead",{children:Object(a.jsxs)("tr",{children:[Object(a.jsx)("th",{}),Object(a.jsxs)("th",{children:[t("workouts:Start"),Object(a.jsx)("br",{}),Object(a.jsx)("img",{className:"weather-img",src:"/img/weather/".concat(s.weather_start.icon,".png"),alt:"workout weather (".concat(s.weather_start.icon,")"),title:s.weather_start.summary})]}),Object(a.jsxs)("th",{children:[t("workouts:End"),Object(a.jsx)("br",{}),Object(a.jsx)("img",{className:"weather-img",src:"/img/weather/".concat(s.weather_end.icon,".png"),alt:"workout weather (".concat(s.weather_end.icon,")"),title:s.weather_end.summary})]})]})}),Object(a.jsxs)("tbody",{children:[Object(a.jsxs)("tr",{children:[Object(a.jsx)("td",{children:Object(a.jsx)("img",{className:"weather-img-small",src:"/img/weather/temperature.png",alt:"Temperatures"})}),Object(a.jsxs)("td",{children:[Number(s.weather_start.temperature).toFixed(1),"\xb0C"]}),Object(a.jsxs)("td",{children:[Number(s.weather_end.temperature).toFixed(1),"\xb0C"]})]}),Object(a.jsxs)("tr",{children:[Object(a.jsx)("td",{children:Object(a.jsx)("img",{className:"weather-img-small",src:"/img/weather/pour-rain.png",alt:"Temperatures"})}),Object(a.jsxs)("td",{children:[Number(100*s.weather_start.humidity).toFixed(1),"%"]}),Object(a.jsxs)("td",{children:[Number(100*s.weather_end.humidity).toFixed(1),"%"]})]}),Object(a.jsxs)("tr",{children:[Object(a.jsx)("td",{children:Object(a.jsx)("img",{className:"weather-img-small",src:"/img/weather/breeze.png",alt:"Temperatures"})}),Object(a.jsxs)("td",{children:[Number(s.weather_start.wind).toFixed(1),"m/s"]}),Object(a.jsxs)("td",{children:[Number(s.weather_end.wind).toFixed(1),"m/s"]})]})]})]})})}function Ie(e){const t=e.t,s=e.workout,r="0:00:00"!==s.pauses&&null!==s.pauses;return Object(a.jsxs)("div",{className:"workout-details",children:[Object(a.jsxs)("p",{children:[Object(a.jsx)("i",{className:"fa fa-clock-o custom-fa","aria-hidden":"true"}),t("workouts:Duration"),": ",s.moving,s.records&&s.records.find((e=>"LD"===e.record_type))&&Object(a.jsx)("sup",{children:Object(a.jsx)("i",{className:"fa fa-trophy custom-fa","aria-hidden":"true"})}),r&&Object(a.jsxs)("span",{children:[Object(a.jsx)("br",{}),"(",t("workouts:pauses"),": ",s.pauses,","," ",t("workouts:total duration"),": ",s.duration,")"]})]}),Object(a.jsxs)("p",{children:[Object(a.jsx)("i",{className:"fa fa-road custom-fa","aria-hidden":"true"}),t("workouts:Distance"),": ",s.distance," km",s.records&&s.records.find((e=>"FD"===e.record_type))&&Object(a.jsx)("sup",{children:Object(a.jsx)("i",{className:"fa fa-trophy custom-fa","aria-hidden":"true"})})]}),Object(a.jsxs)("p",{children:[Object(a.jsx)("i",{className:"fa fa-tachometer custom-fa","aria-hidden":"true"}),t("workouts:Average speed"),": ",s.ave_speed," km/h",s.records&&s.records.find((e=>"AS"===e.record_type))&&Object(a.jsx)("sup",{children:Object(a.jsx)("i",{className:"fa fa-trophy custom-fa","aria-hidden":"true"})}),Object(a.jsx)("br",{}),t("workouts:Max. speed"),": ",s.max_speed," km/h",s.records&&s.records.find((e=>"MS"===e.record_type))&&Object(a.jsx)("sup",{children:Object(a.jsx)("i",{className:"fa fa-trophy custom-fa","aria-hidden":"true"})})]}),s.min_alt&&s.max_alt&&Object(a.jsxs)("p",{children:[Object(a.jsx)("i",{className:"fi-mountains custom-fa"}),t("workouts:Min. altitude"),": ",s.min_alt,"m",Object(a.jsx)("br",{}),t("workouts:Max. altitude"),": ",s.max_alt,"m"]}),s.ascent&&s.descent&&Object(a.jsxs)("p",{children:[Object(a.jsx)("i",{className:"fa fa-location-arrow custom-fa"}),t("workouts:Ascent"),": ",s.ascent,"m",Object(a.jsx)("br",{}),t("workouts:Descent"),": ",s.descent,"m"]}),Object(a.jsx)(Ue,{workout:s,t:t})]})}var We=s(466),He=s(463),qe=s(484),Be=s(464),Ve=s(465),Ge=s(228),Je=s.n(Ge);function Ke({bounds:e,coordinates:t,jsonData:s,mapAttribution:r}){return Object(He.a)().fitBounds(e),Object(a.jsxs)(a.Fragment,{children:[Object(a.jsx)(qe.a,{attribution:r,url:"".concat(C,"workouts/map_tile/{s}/{z}/{x}/{y}.png")}),Object(a.jsx)(Be.a,{data:s},Je()(s)),t.latitude&&Object(a.jsx)(Ve.a,{position:[t.latitude,t.longitude]})]})}class Ye extends c.a.Component{constructor(e,t){super(e,t),this.state={zoom:13}}componentDidMount(){"workout"===this.props.dataType?this.props.loadWorkoutGpx(this.props.workout.id):this.props.loadSegmentGpx(this.props.workout.id,this.props.segmentId)}componentDidUpdate(e){("workout"===this.props.dataType&&e.workout.id!==this.props.workout.id||"workout"===this.props.dataType&&"segment"===e.dataType)&&this.props.loadWorkoutGpx(this.props.workout.id),"segment"===this.props.dataType&&e.segmentId!==this.props.segmentId&&this.props.loadSegmentGpx(this.props.workout.id,this.props.segmentId)}componentWillUnmount(){this.props.loadWorkoutGpx(null)}render(){const e=this.props,t=e.coordinates,s=e.gpxContent,r=e.mapAttribution,o=e.workout,c=(e=>{let t;if(e){const s=(new DOMParser).parseFromString(e,"text/xml");t=de.a.gpx(s)}return{jsonData:t}})(s).jsonData,n=[[o.bounds[0],o.bounds[1]],[o.bounds[2],o.bounds[3]]];return Object(a.jsx)("div",{children:c&&Object(a.jsx)(We.a,{zoom:this.state.zoom,bounds:n,boundsOptions:{padding:[10,10]},children:Object(a.jsx)(Ke,{bounds:n,coordinates:t,jsonData:c,mapAttribution:r})})})}}var Xe=Object(O.c)((e=>({gpxContent:e.gpx,mapAttribution:e.application.config.map_attribution})),(e=>({loadWorkoutGpx:t=>{e((e=>t=>{if(e)return L.getData("workouts/".concat(e,"/gpx")).then((e=>{"success"===e.status?t(Ne(e.data.gpx)):t(I("workouts|".concat(e.message)))})).catch((e=>t(I("workouts|".concat(e)))));t(Ne(null))})(t))},loadSegmentGpx:(t,s)=>{e(((e,t)=>s=>{if(e)return L.getData("workouts/".concat(e,"/gpx/segment/").concat(t)).then((e=>{"success"===e.status?s(Ne(e.data.gpx)):s(I("workouts|".concat(e.message)))})).catch((e=>s(I("workouts|".concat(e)))));s(Ne(null))})(t,s))}})))(Ye);function $e(e){const t=e.t;return Object(a.jsx)("div",{className:"workout-no-map text-center",children:t("workouts:No Map")})}function Ze(e){const t=e.notes,s=e.t;return Object(a.jsx)("div",{className:"row",children:Object(a.jsx)("div",{className:"col",children:Object(a.jsx)("div",{className:"card workout-card",children:Object(a.jsxs)("div",{className:"card-body",children:["Notes",Object(a.jsx)("div",{className:"workout-notes",children:t||s("workouts:No notes")})]})})})})}function Qe(e){const t=e.segments,s=e.t;return Object(a.jsx)("div",{className:"row",children:Object(a.jsx)("div",{className:"col",children:Object(a.jsx)("div",{className:"card workout-card",children:Object(a.jsxs)("div",{className:"card-body",children:[s("workouts:Segments"),Object(a.jsx)("div",{className:"workout-segments",children:Object(a.jsx)("ul",{children:t.map(((e,t)=>Object(a.jsxs)("li",{className:"workout-segments-list",children:[Object(a.jsxs)(K.a,{to:"/workouts/".concat(e.workout_id,"/segment/").concat(t+1),children:[s("workouts:segment")," ",t+1]})," ","(",s("workouts:distance"),": ",e.distance," km,"," ",s("workouts:duration"),": ",e.duration,")"]},"segment-".concat(t))))})})]})})})})}class et extends c.a.Component{constructor(e,t){super(e,t),this.state={displayModal:!1,coordinates:{latitude:null,longitude:null}}}componentDidMount(){this.props.loadWorkout(this.props.match.params.workoutId)}componentDidUpdate(e){e.match.params.workoutId!==this.props.match.params.workoutId&&this.props.loadWorkout(this.props.match.params.workoutId)}displayModal(e){this.setState((t=>Object(k.a)(Object(k.a)({},t),{},{displayModal:e})))}updateCoordinates(e){const t=e&&e.length>0?{latitude:e[0].payload.latitude,longitude:e[0].payload.longitude}:{latitude:null,longitude:null};this.setState((e=>Object(k.a)(Object(k.a)({},e),{},{coordinates:t})))}render(){const e=this.props,t=e.message,s=e.onDeleteWorkout,r=e.sports,o=e.t,c=e.user,n=e.workouts,i=this.state,l=i.coordinates,d=i.displayModal,u=Object(ne.a)(n,1)[0],m=u?u.title:o("workouts:Workout"),j=u?r.filter((e=>e.id===u.sport_id)):[],p=Object(ne.a)(j,1)[0],h=parseInt(this.props.match.params.segmentId),b=h>=0?"segment":"workout";return Object(a.jsxs)("div",{className:"workout-page",children:[Object(a.jsx)(f.a,{children:Object(a.jsxs)("title",{children:["FitTrackee - ",m]})}),t?Object(a.jsx)(v,{message:t,t:o}):Object(a.jsxs)("div",{className:"container",children:[d&&Object(a.jsx)(Pe,{title:o("common:Confirmation"),text:o("workouts:Are you sure you want to delete this workout?"),confirm:()=>{s(u.id),this.displayModal(!1)},close:()=>this.displayModal(!1)}),u&&p&&1===n.length&&Object(a.jsxs)("div",{children:[Object(a.jsx)("div",{className:"row",children:Object(a.jsx)("div",{className:"col",children:Object(a.jsxs)("div",{className:"card workout-card",children:[Object(a.jsx)("div",{className:"card-header",children:Object(a.jsx)(Fe,{workout:u,dataType:b,segmentId:h,sport:p,t:o,title:m,user:c,displayModal:()=>this.displayModal(!0)})}),Object(a.jsx)("div",{className:"card-body",children:Object(a.jsxs)("div",{className:"row",children:[Object(a.jsx)("div",{className:"col-md-8",children:u.with_gpx?Object(a.jsx)(Xe,{workout:u,coordinates:l,dataType:b,segmentId:h}):Object(a.jsx)($e,{t:o})}),Object(a.jsx)("div",{className:"col",children:Object(a.jsx)(Ie,{workout:"workout"===b?u:u.segments[h-1],t:o})})]})})]})})}),u.with_gpx&&Object(a.jsx)("div",{className:"row",children:Object(a.jsx)("div",{className:"col",children:Object(a.jsx)("div",{className:"card workout-card",children:Object(a.jsx)("div",{className:"card-body",children:Object(a.jsx)("div",{className:"row",children:Object(a.jsxs)("div",{className:"col",children:[Object(a.jsx)("div",{className:"chart-title",children:o("workouts:Chart")}),Object(a.jsx)(Le,{workout:u,dataType:b,segmentId:h,t:o,updateCoordinates:e=>this.updateCoordinates(e)})]})})})})})}),"workout"===b&&Object(a.jsxs)(a.Fragment,{children:[Object(a.jsx)(Ze,{notes:u.notes,t:o}),u.segments.length>1&&Object(a.jsx)(Qe,{segments:u.segments,t:o})]})]})]})]})}}var tt=Object(w.a)()(Object(O.c)((e=>({workouts:e.workouts.data,message:e.message,sports:e.sports.data,user:e.user})),(e=>({loadWorkout:t=>{e(H("getData","workouts",{id:t}))},onDeleteWorkout:t=>{var s;e((s=t,e=>L.deleteData("workouts",s).then((t=>{var a;204===t.status?Promise.resolve(e((a=s,{type:"REMOVE_WORKOUT",workoutId:a}))).then((()=>e(we()))).then((()=>Ta.push("/"))):e(I("workouts|".concat(t.status)))})).catch((t=>e(I("workouts|".concat(t)))))))}})))(et));class st extends c.a.Component{componentDidMount(){this.props.loadWorkout(this.props.match.params.workoutId)}render(){const e=this.props,t=e.message,s=e.sports,r=e.workouts,o=Object(ne.a)(r,1)[0];return Object(a.jsx)("div",{children:s.length>0&&Object(a.jsx)(Me,{workout:o,message:t,sports:s})})}}var at=Object(O.c)((e=>({workouts:e.workouts.data,message:e.message,sports:e.sports.data,user:e.user})),(e=>({loadWorkout:t=>{e(H("getData","workouts",{id:t}))}})))(st);var rt=Object(O.c)((e=>({user:e.user})))((function(){return Object(a.jsx)("div",{children:M()?Object(a.jsxs)(g.d,{children:[Object(a.jsx)(g.b,{exact:!0,path:"/workouts/add",component:Te}),Object(a.jsx)(g.b,{exact:!0,path:"/workouts/:workoutId",component:tt}),Object(a.jsx)(g.b,{exact:!0,path:"/workouts/:workoutId/edit",component:at}),Object(a.jsx)(g.b,{path:"/workouts/:workoutId/segment/:segmentId",component:tt}),Object(a.jsx)(g.b,{component:re})]}):Object(a.jsx)(g.a,{to:"/login"})})}));class ot extends c.a.PureComponent{render(){const e=this.props.t;return Object(a.jsx)("div",{className:"card text-center",children:Object(a.jsxs)("div",{className:"card-body",children:[e("common:No workouts.")," ",Object(a.jsx)(K.a,{to:{pathname:"/workouts/add"},children:e("dashboard:Upload one !")})]})})}}class ct extends c.a.PureComponent{render(){const e=this.props,t=e.loadWorkouts,s=e.sports,r=e.t,o=e.updateParams,c=xe(s,r);return Object(a.jsx)("div",{className:"card",children:Object(a.jsx)("div",{className:"card-body workout-filter",children:Object(a.jsxs)("form",{onSubmit:e=>e.preventDefault(),children:[Object(a.jsxs)("div",{className:"form-group",children:[Object(a.jsxs)("label",{children:[r("workouts:From"),":",Object(a.jsx)("input",{className:"form-control col-md",name:"from",onChange:e=>o(e),type:"date"})]}),Object(a.jsxs)("label",{children:[r("workouts:To"),":",Object(a.jsx)("input",{className:"form-control col-md",name:"to",onChange:e=>o(e),type:"date"})]})]}),Object(a.jsx)("div",{className:"form-group",children:Object(a.jsxs)("label",{children:[r("common:Sport"),":",Object(a.jsxs)("select",{className:"form-control input-lg",name:"sport_id",onChange:e=>o(e),children:[Object(a.jsx)("option",{value:""}),c.map((e=>Object(a.jsx)("option",{value:e.id,children:e.label},e.id)))]})]})}),Object(a.jsx)("div",{className:"form-group",children:Object(a.jsxs)("label",{children:[r("workouts:Distance")," (km):",Object(a.jsx)("div",{className:"container",children:Object(a.jsxs)("div",{className:"row",children:[Object(a.jsx)("div",{className:"col-5",children:Object(a.jsx)("input",{className:"form-control",min:0,name:"distance_from",onChange:e=>o(e),step:"1",type:"number"})}),Object(a.jsx)("div",{className:"col-2 align-middle text-center",children:r("common:to")}),Object(a.jsx)("div",{className:"col-5",children:Object(a.jsx)("input",{className:"form-control",min:0,name:"distance_to",onChange:e=>o(e),step:"1",type:"number"})})]})})]})}),Object(a.jsx)("div",{className:"form-group",children:Object(a.jsxs)("label",{children:[r("workouts:Duration"),":",Object(a.jsx)("div",{className:"container",children:Object(a.jsxs)("div",{className:"row",children:[Object(a.jsx)("div",{className:"col-5",children:Object(a.jsx)("input",{className:"form-control",name:"duration_from",onChange:e=>o(e),pattern:"^([0-9]*[0-9]):([0-5][0-9])$",placeholder:"hh:mm",type:"text"})}),Object(a.jsx)("div",{className:"col-2 align-middle text-center",children:r("common:to")}),Object(a.jsx)("div",{className:"col-5",children:Object(a.jsx)("input",{className:"form-control",name:"duration_to",onChange:e=>o(e),pattern:"^([0-9]*[0-9]):([0-5][0-9])$",placeholder:"hh:mm",type:"text"})})]})})]})}),Object(a.jsx)("div",{className:"form-group",children:Object(a.jsxs)("label",{children:[r("workouts:Average speed")," (km/h):",Object(a.jsx)("div",{className:"container",children:Object(a.jsxs)("div",{className:"row",children:[Object(a.jsx)("div",{className:"col-5",children:Object(a.jsx)("input",{className:"form-control",min:0,name:"ave_speed_from",onChange:e=>o(e),step:"1",type:"number"})}),Object(a.jsx)("div",{className:"col-2 align-middle text-center",children:r("common:to")}),Object(a.jsx)("div",{className:"col-5",children:Object(a.jsx)("input",{className:"form-control",min:0,name:"ave_speed_to",onChange:e=>o(e),step:"1",type:"number"})})]})})]})}),Object(a.jsx)("div",{className:"form-group",children:Object(a.jsxs)("label",{children:[r("workouts:Max. speed")," (km/h):",Object(a.jsx)("div",{className:"container",children:Object(a.jsxs)("div",{className:"row",children:[Object(a.jsx)("div",{className:"col-5",children:Object(a.jsx)("input",{className:"form-control",min:0,name:"max_speed_from",onChange:e=>o(e),step:"1",type:"number"})}),Object(a.jsx)("div",{className:"col-2 align-middle text-center",children:r("common:to")}),Object(a.jsx)("div",{className:"col-5",children:Object(a.jsx)("input",{className:"form-control",min:0,name:"max_speed_to",onChange:e=>o(e),step:"1",type:"number"})})]})})]})}),Object(a.jsx)("input",{className:"btn btn-primary btn-lg btn-block",onClick:()=>t(),type:"submit",value:r("workouts:Filter")})]})})})}}class nt extends c.a.PureComponent{render(){const e=this.props,t=e.display,s=e.workout;return Object(a.jsxs)("div",{className:"workout-map".concat("list"===t?"-list":""),children:[Object(a.jsx)("img",{src:"".concat(C,"workouts/map/").concat(s.map,"?").concat(Date.now()),alt:"workout map"}),Object(a.jsxs)("div",{className:"map-attribution".concat("list"===t?"-list":""),children:[Object(a.jsx)("span",{className:"map-attribution-text",children:"\xa9"}),Object(a.jsx)("a",{className:"map-attribution-text",href:"http://www.openstreetmap.org/copyright",target:"_blank",rel:"noopener noreferrer",children:"OpenStreetMap"})]})]})}}class it extends c.a.PureComponent{render(){const e=this.props,t=e.loading,s=e.sports,r=e.t,o=e.user,c=e.workouts;return Object(a.jsx)("div",{className:"card workout-card",children:Object(a.jsxs)("div",{className:"card-body",children:[Object(a.jsxs)("table",{className:"table",children:[Object(a.jsx)("thead",{children:Object(a.jsxs)("tr",{children:[Object(a.jsx)("th",{scope:"col"}),Object(a.jsx)("th",{scope:"col",children:r("common:Workout")}),Object(a.jsx)("th",{scope:"col",children:r("workouts:Date")}),Object(a.jsx)("th",{scope:"col",children:r("workouts:Distance")}),Object(a.jsx)("th",{scope:"col",children:r("workouts:Duration")}),Object(a.jsx)("th",{scope:"col",children:r("workouts:Ave. speed")}),Object(a.jsx)("th",{scope:"col",children:r("workouts:Max. speed")})]})}),Object(a.jsx)("tbody",{children:!t&&s&&c.map(((e,t)=>Object(a.jsxs)("tr",{children:[Object(a.jsxs)("td",{children:[Object(a.jsx)("span",{className:"heading-span-absolute",children:r("common:Sport")}),Object(a.jsx)("img",{className:"workout-sport",src:s.filter((t=>t.id===e.sport_id)).map((e=>e.img)),alt:"workout sport logo"})]}),Object(a.jsxs)("td",{className:"workout-title",children:[Object(a.jsx)("span",{className:"heading-span-absolute",children:r("common:Workout")}),Object(a.jsx)(K.a,{to:"/workouts/".concat(e.id),children:e.title}),e.map&&Object(a.jsx)(nt,{workout:e,display:"list"})]}),Object(a.jsxs)("td",{children:[Object(a.jsx)("span",{className:"heading-span-absolute",children:r("workouts:Date")}),Object(y.a)(P(e.workout_date,o.timezone),"dd/MM/yyyy HH:mm")]}),Object(a.jsxs)("td",{className:"text-right",children:[Object(a.jsx)("span",{className:"heading-span-absolute",children:r("workouts:Distance")}),Number(e.distance).toFixed(2)," km"]}),Object(a.jsxs)("td",{className:"text-right",children:[Object(a.jsx)("span",{className:"heading-span-absolute",children:r("workouts:Duration")}),e.moving]}),Object(a.jsxs)("td",{className:"text-right",children:[Object(a.jsx)("span",{className:"heading-span-absolute",children:r("workouts:Ave. speed")}),e.ave_speed," km/h"]}),Object(a.jsxs)("td",{className:"text-right",children:[Object(a.jsx)("span",{className:"heading-span-absolute",children:r("workouts:Max. speed")}),e.max_speed," km/h"]})]},t)))})]}),t&&Object(a.jsx)("div",{className:"loader"})]})})}}class lt extends c.a.Component{constructor(e,t){super(e,t),this.state={params:{page:1,per_page:10}}}componentDidMount(){this.props.loadWorkouts(this.state.params)}setParams(e){const t=this.state.params;""===e.target.value?delete t[e.target.name]:t[e.target.name]=e.target.value,t.page=1,this.setState(t)}render(){const e=this.props,t=e.loading,s=e.loadWorkouts,r=e.loadMoreWorkouts,o=e.message,c=e.sports,n=e.t,i=e.user,l=e.workouts,d=this.state.params,u=!(l.length>0)||null===l[l.length-1].previous_workout;return Object(a.jsxs)("div",{children:[Object(a.jsx)(f.a,{children:Object(a.jsxs)("title",{children:["FitTrackee - ",n("common:Workouts")]})}),o?Object(a.jsx)(v,{message:o,t:n}):Object(a.jsx)("div",{className:"container history",children:Object(a.jsxs)("div",{className:"row",children:[Object(a.jsx)("div",{className:"col-md-3",children:Object(a.jsx)(ct,{sports:c,loadWorkouts:()=>s(d),t:n,updateParams:e=>this.setParams(e)})}),Object(a.jsxs)("div",{className:"col-md-9 workouts-result",children:[Object(a.jsx)(it,{workouts:l,loading:t,sports:c,t:n,user:i}),!u&&Object(a.jsx)("input",{type:"submit",className:"btn btn-default btn-md btn-block",value:"Load more workouts",onClick:()=>{d.page+=1,r(d),this.setState(d)}}),0===l.length&&Object(a.jsx)(ot,{t:n})]})]})})]})}}var dt=Object(w.a)()(Object(O.c)((e=>({workouts:e.workouts.data,loading:e.loading,message:e.message,sports:e.sports.data,user:e.user})),(e=>({loadWorkouts:t=>{e(H("getData","workouts",t))},loadMoreWorkouts:t=>{e(De(t))}})))(lt));var ut=Object(w.a)()(Object(O.c)((e=>({appConfig:e.application.config,pathname:e.router.location.pathname,message:e.message})),(e=>({onDeletePicture:()=>{e((e=>Oe.deletePicture().then((t=>204===t.status?e(ve()):e(ge(t.message)))).catch((e=>{throw e}))))},onUploadPicture:t=>{e((e=>t=>{e.preventDefault();const s=new FormData;return s.append("file",e.target.picture.files[0]),e.target.reset(),L.addDataWithFile("auth/picture",s).then((e=>{if("success"===e.status)return t(ve());const s=413===e.status?"Error during picture update, file size exceeds max size.":e.message;return t(ge(s))})).catch((e=>{throw e}))})(t))}})))((function({appConfig:e,displayModal:t,editable:s,isDeletable:r,message:o,onDeletePicture:c,onUploadPicture:n,pathname:i,t:l,user:d}){const u=d.created_at?Object(y.a)(new Date(d.created_at),"dd/MM/yyyy HH:mm"):"",m=d.birth_date?Object(y.a)(new Date(d.birth_date),"dd/MM/yyyy"):"",j=D(e.max_single_file_size);return Object(a.jsxs)("div",{children:[Object(a.jsx)(f.a,{children:Object(a.jsxs)("title",{children:["FitTrackee - ",l("user:Profile")]})}),Object(a.jsx)(v,{message:o,t:l}),Object(a.jsxs)("div",{className:"container",children:[Object(a.jsx)("h1",{className:"page-title",children:l("user:Profile")}),Object(a.jsx)("div",{className:"row",children:Object(a.jsx)("div",{className:"col-md-12",children:Object(a.jsxs)("div",{className:"card",children:[Object(a.jsx)("div",{className:"card-header userName",children:Object(a.jsx)("strong",{children:d.username})}),Object(a.jsxs)("div",{className:"card-body",children:[Object(a.jsxs)("div",{className:"row",children:[Object(a.jsxs)("div",{className:"col-md-8",children:[Object(a.jsxs)("p",{children:[Object(a.jsx)("span",{className:"user-label",children:l("user:Email")}),": ",d.email]}),Object(a.jsxs)("p",{children:[Object(a.jsx)("span",{className:"user-label",children:l("user:Registration Date")}),": ",u]}),Object(a.jsxs)("p",{children:[Object(a.jsx)("span",{className:"user-label",children:l("user:First Name")}),": ",d.first_name]}),Object(a.jsxs)("p",{children:[Object(a.jsx)("span",{className:"user-label",children:l("user:Last Name")}),": ",d.last_name]}),Object(a.jsxs)("p",{children:[Object(a.jsx)("span",{className:"user-label",children:l("user:Birth Date")}),": ",m]}),Object(a.jsxs)("p",{children:[Object(a.jsx)("span",{className:"user-label",children:l("user:Location")}),": ",d.location]}),Object(a.jsxs)("p",{children:[Object(a.jsx)("span",{className:"user-label",children:l("user:Bio")}),":"," ",d.bio]}),Object(a.jsxs)("p",{children:[Object(a.jsx)("span",{className:"user-label",children:l("user:Language")}),": ",d.language]}),Object(a.jsxs)("p",{children:[Object(a.jsx)("span",{className:"user-label",children:l("user:Timezone")}),": ",d.timezone]}),Object(a.jsxs)("p",{children:[Object(a.jsx)("span",{className:"user-label",children:l("user:First day of week")}),": ",d.weekm?l("user:Monday"):l("user:Sunday")]})]}),Object(a.jsxs)("div",{className:"col-md-4",children:[!0===d.picture&&Object(a.jsxs)("div",{children:[Object(a.jsx)("img",{alt:"Profile",src:"".concat(C,"users/").concat(d.username,"/picture")+"?".concat(Date.now()),className:"img-fluid App-profile-img-small"}),s&&Object(a.jsxs)(a.Fragment,{children:[Object(a.jsx)("br",{}),Object(a.jsx)("button",{type:"submit",onClick:()=>c(),children:l("user:Delete picture")}),Object(a.jsx)("br",{}),Object(a.jsx)("br",{})]})]}),s&&Object(a.jsxs)("form",{encType:"multipart/form-data",onSubmit:e=>n(e),children:[Object(a.jsx)("input",{type:"file",name:"picture",accept:".png,.jpg,.gif"}),Object(a.jsx)("br",{}),Object(a.jsx)("button",{type:"submit",children:l("user:Send")})," (max. size: ".concat(j,")")]})," "]})]}),s&&Object(a.jsx)("button",{className:"btn btn-primary",onClick:()=>Ta.push("/profile/edit"),children:l("common:Edit")}),r&&Object(a.jsx)("button",{className:"btn btn-danger",onClick:()=>t(!0),children:l("user:Delete user account")}),Object(a.jsx)("button",{className:"btn btn-secondary",onClick:()=>"/profile"===i?Ta.push("/"):Ta.go(-1),children:l("/profile"===i?"common:Back to home":"common:Back")})]})]})})})]})]})})));var mt=Object(w.a)()(Object(O.c)((e=>({user:e.user})))((function({t:e,user:t}){return Object(a.jsx)("div",{children:Object(a.jsx)(ut,{editable:!0,t:e,user:t})})}))),jt=s(467),pt=s(468),ht=s(469),bt=s(470),xt=s(229),Ot=s(233),gt=s(471),ft=s(472),wt=s(106),vt=s(473),kt=s(481),yt=s(483);function Nt(e){const t=e.isDisabled,s=e.isMore,r=e.sportImg,o=e.workout;return Object(a.jsx)(K.a,{className:"calendar-workout".concat(s),to:"/workouts/".concat(o.id),children:Object(a.jsxs)(a.Fragment,{children:[Object(a.jsx)("img",{alt:"workout sport logo",className:"workout-sport ".concat(t),src:r,title:o.title}),o.records.length>0&&Object(a.jsx)("sup",{children:Object(a.jsx)("i",{className:"fa fa-trophy custom-fa-small","aria-hidden":"true",title:o.records.map((e=>" ".concat(me.filter((t=>t.record_type===e.record_type))[0].label)))})})]})})}class _t extends c.a.Component{constructor(e,t){super(e,t),this.state={isHidden:!0}}handleDisplayMore(){this.setState({isHidden:!this.state.isHidden})}render(){const e=this.props,t=e.dayWorkouts,s=e.isDisabled,r=e.sports,o=this.state.isHidden;return Object(a.jsxs)("div",{children:[t.map((e=>Object(a.jsx)(Nt,{workout:e,isDisabled:s,isMore:"",sportImg:r.filter((t=>t.id===e.sport_id)).map((e=>e.img))},e.id))),t.length>2&&Object(a.jsx)("i",{className:"fa fa-".concat(o?"plus":"times"," calendar-more"),"aria-hidden":"true",onClick:()=>this.handleDisplayMore(),title:"show more workouts"}),!o&&Object(a.jsx)("div",{className:"calendar-display-more",children:t.map((e=>Object(a.jsx)(Nt,{workout:e,isDisabled:s,isMore:"-more",sportImg:r.filter((t=>t.id===e.sport_id)).map((e=>e.img))},e.id)))})]})}}const St=(e,t)=>{const s=Object(jt.a)(e),a=Object(pt.a)(e),r=t?1:0;return{start:Object(ht.a)(s,{weekStartsOn:r}),end:Object(bt.a)(a)}};class Dt extends c.a.Component{constructor(e,t){super(e,t);const s=new Date;this.state={currentMonth:s,startDate:St(s,e.weekm).start,endDate:St(s,e.weekm).end,weekStartOnMonday:e.weekm}}componentDidMount(){this.props.loadMonthWorkouts(this.state.startDate,this.state.endDate)}renderHeader(e){return Object(a.jsxs)("div",{className:"header row flex-middle",children:[Object(a.jsx)("div",{className:"col col-start",onClick:()=>this.handlePrevMonth(),children:Object(a.jsx)("i",{className:"fa fa-chevron-left","aria-hidden":"true"})}),Object(a.jsx)("div",{className:"col col-center",children:Object(a.jsx)("span",{children:Object(y.a)(this.state.currentMonth,"MMM yyyy",e)})}),Object(a.jsx)("div",{className:"col col-end",onClick:()=>this.handleNextMonth(),children:Object(a.jsx)("i",{className:"fa fa-chevron-right","aria-hidden":"true"})})]})}renderDays(e){const t=[],s=this.state.startDate;for(let r=0;r<7;r++)t.push(Object(a.jsx)("div",{className:"col col-center",children:Object(y.a)(Object(xt.a)(s,r),"EEE",e)},r));return Object(a.jsx)("div",{className:"days row",children:t})}filterWorkouts(e){const t=this.props,s=t.workouts,a=t.user;return s?s.filter((t=>Object(Ot.a)(P(t.workout_date,a.timezone),e))):[]}renderCells(){const e=this.state,t=e.currentMonth,s=e.startDate,r=e.endDate,o=e.weekStartOnMonday,c=this.props.sports,n=[];let i=[],l=s,d="";for(;l<=r;){for(let e=0;e<7;e++){d=Object(y.a)(l,"d");const s=this.filterWorkouts(l),r=Object(gt.a)(l,t)?"":"-disabled",n=o?[5,6].includes(e):[0,6].includes(e);i.push(Object(a.jsx)("div",{className:"col cell ".concat(n?" weekend":"").concat(Object(ft.a)(l)?" today":""),children:Object(a.jsxs)("div",{className:"img".concat(r),children:[Object(a.jsx)("span",{className:"number",children:d}),Object(a.jsx)(_t,{dayWorkouts:s,isDisabled:r,sports:c})]})},l)),l=Object(xt.a)(l,1)}n.push(Object(a.jsx)("div",{className:"row",children:i},l)),i=[]}return Object(a.jsx)("div",{className:"body",children:n})}updateStateDate(e){const t=St(e,this.state.weekStartOnMonday),s=t.start,a=t.end;this.setState({currentMonth:e,startDate:s,endDate:a}),this.props.loadMonthWorkouts(s,a)}handleNextMonth(){const e=Object(wt.a)(this.state.currentMonth,1);this.updateStateDate(e)}handlePrevMonth(){const e=Object(vt.a)(this.state.currentMonth,1);this.updateStateDate(e)}render(){const e={locale:"fr"===this.props.language?kt.a:yt.a};return Object(a.jsx)("div",{className:"card workout-card",children:Object(a.jsxs)("div",{className:"calendar",children:[this.renderHeader(e),this.renderDays(e),this.renderCells()]})})}}var Ct=Object(O.c)((e=>({workouts:e.calendarWorkouts.data,language:e.language,sports:e.sports.data,user:e.user})),(e=>({loadMonthWorkouts:(t,s)=>{const a="yyyy-MM-dd";var r,o;e((r=Object(y.a)(t,a),o=Object(y.a)(s,a),e=>L.getData("workouts",{from:r,to:o,order:"desc",per_page:100}).then((t=>{"success"===t.status?e({type:"UPDATE_CALENDAR",workouts:t.data.workouts}):e(I("workouts|".concat(t.message)))})).catch((t=>e(I("workouts|".concat(t)))))))}})))(Dt);function Et(e){const t=e.records,s=e.sports,r=e.t,o=e.user,c=xe(s,r),n=t.reduce(((e,t)=>{const s=c.find((e=>e.id===t.sport_id));return void 0===e[s.label]&&(e[s.label]={img:s.img,records:[]}),e[s.label].records.push(((e,t)=>{let s;switch(e.record_type){case"AS":case"MS":s="".concat(e.value," km/h");break;case"FD":s="".concat(e.value," km");break;default:s=e.value}const a=me.filter((t=>t.record_type===e.record_type)),r=Object(ne.a)(a,1)[0];return{workout_date:je(P(e.workout_date,t)).workout_date,workout_id:e.workout_id,id:e.id,record_type:r.label,value:s}})(t,o.timezone)),e}),{});return Object(a.jsxs)("div",{className:"card workout-card",children:[Object(a.jsx)("div",{className:"card-header",children:r("workouts:Personal records")}),Object(a.jsx)("div",{className:"card-body",children:0===Object.keys(n).length?r("common:No records."):Object.keys(n).sort().map((e=>Object(a.jsxs)("div",{children:[Object(a.jsxs)("span",{className:"heading-span",children:[Object(a.jsx)("img",{alt:"".concat(e," logo"),className:"record-logo",src:n[e].img}),e]}),Object(a.jsxs)("table",{className:"table table-borderless table-sm record-table",children:[Object(a.jsx)("thead",{children:Object(a.jsx)("tr",{children:Object(a.jsxs)("th",{colSpan:"3",children:[Object(a.jsx)("img",{alt:"".concat(e," logo"),className:"record-logo",src:n[e].img}),e]})})}),Object(a.jsx)("tbody",{children:n[e].records.map((e=>Object(a.jsxs)("tr",{className:"record-tr",children:[Object(a.jsx)("td",{className:"record-td",children:r("workouts:".concat(e.record_type))}),Object(a.jsx)("td",{className:"record-td text-right",children:e.value}),Object(a.jsx)("td",{className:"record-td text-right",children:Object(a.jsx)(K.a,{to:"/workouts/".concat(e.workout_id),children:e.workout_date})})]},e.id)))})]})]},e)))})]})}var At=s(230),Mt=s(474);const Tt=[{duration:"week",dateFormat:"yyyy-MM-dd",xAxis:"dd/MM"},{duration:"month",dateFormat:"yyyy-MM",xAxis:"MM/yyyy"},{duration:"year",dateFormat:"yyyy",xAxis:"yyyy"}],Pt=(e,t=!1)=>{let s="0";t&&(s=String(Math.floor(e/86400)),e%=86400);const a=String(Math.floor(e/3600)).padStart(2,"0");e%=3600;const r=String(Math.floor(e/60)).padStart(2,"0"),o=String(e%60).padStart(2,"0");return t?"".concat("0"===s?"":"".concat(s,"d:")).concat("00"===a?"":"".concat(a,"h:")).concat(r,"m:").concat(o,"s"):"".concat("00"===a?"":"".concat(a,":")).concat(r,":").concat(o)},Ft=(e,t)=>0===t?"":"distance"===e?"".concat(t.toFixed(2)," km"):"duration"===e?Pt(t):t,zt=(e,t)=>{switch(e){case"week":return Object(xt.a)(t,7);case"year":return Object(At.a)(t,1);case"month":default:return Object(wt.a)(t,1)}},Rt=(e,t,s,a,r)=>{const o=[],c=[],n=[];for(let i=((e,t,s)=>{switch(e){case"week":return Object(ht.a)(t,{weekStartsOn:s?1:0});case"year":return Object(Mt.a)(t);case"month":default:return Object(jt.a)(t)}})(s.duration,s.start,r);i<=s.end;i=zt(s.duration,i)){const r=Tt.filter((e=>e.duration===s.duration)),l=Object(ne.a)(r,1)[0],d=Object(y.a)(i,l.dateFormat),u=Object(y.a)(i,l.xAxis),m={date:u},j={date:u},p={date:u};e[d]&&Object.keys(e[d]).filter((e=>!a||a.includes(+e))).map((s=>{const a=t.filter((e=>e.id===+s))[0].label;return m[a]=e[d][s].nb_workouts,j[a]=e[d][s].total_distance,p[a]=e[d][s].total_duration,null})),o.push(m),c.push(j),n.push(p)}return{workouts:o,distance:c,duration:n}},Lt=(e,t)=>"duration"===e?Pt(t,!0):"distance"===e?t.toFixed(2):t;function Ut(e){if(e.active){const t=e.displayedData,s=e.payload,r=e.label;let o=0;return s.map((e=>o+=e.value)),Object(a.jsxs)("div",{className:"custom-tooltip",children:[Object(a.jsx)("p",{className:"custom-tooltip-label",children:r}),s.map((e=>Object(a.jsxs)("p",{style:{color:e.fill},children:[e.name,": ",Lt(t,e.value)," ",e.unit]},e.name))),s.length>0&&Object(a.jsxs)("p",{children:["Total: ",Lt(t,o)]})]})}return null}function It(e){const t=e.displayedData,s=e.x,r=e.y,o=e.width,c=e.value;if(!c)return null;const n=Ft(t,c);return Object(a.jsx)("g",{children:Object(a.jsx)("text",{x:s+o/2,y:r-10,fill:"#666",fontSize:"11",textAnchor:"middle",dominantBaseline:"middle",children:n})})}class Wt extends c.a.PureComponent{constructor(e,t){super(e,t),this.state={displayedData:"distance"}}handleRadioChange(e){this.setState({displayedData:e.target.name})}render(){const e=this.state.displayedData,t=this.props,s=t.sports,r=t.stats,o=t.t;return 0===Object.keys(r).length?o("common:No workouts."):Object(a.jsxs)("div",{className:"chart-stats",children:[Object(a.jsxs)("div",{className:"row chart-radio",children:[Object(a.jsxs)("label",{className:"radioLabel col",children:[Object(a.jsx)("input",{type:"radio",name:"distance",checked:"distance"===e,onChange:e=>this.handleRadioChange(e)}),o("statistics:distance")]}),Object(a.jsxs)("label",{className:"radioLabel col",children:[Object(a.jsx)("input",{type:"radio",name:"duration",checked:"duration"===e,onChange:e=>this.handleRadioChange(e)}),o("statistics:duration")]}),Object(a.jsxs)("label",{className:"radioLabel col",children:[Object(a.jsx)("input",{type:"radio",name:"workouts",checked:"workouts"===e,onChange:e=>this.handleRadioChange(e)}),o("statistics:workouts")]})]}),Object(a.jsx)(ze.f,{height:300,children:Object(a.jsxs)(ze.c,{data:r[e],margin:{top:15,bottom:0},children:[Object(a.jsx)(ze.h,{dataKey:"date",interval:0}),Object(a.jsx)(ze.i,{tickFormatter:t=>Ft(e,t)}),Object(a.jsx)(ze.g,{content:Object(a.jsx)(Ut,{displayedData:e})}),s.map(((t,r)=>Object(a.jsx)(ze.b,{isAnimationActive:!1,dataKey:t.label,stackId:"a",fill:ue[r],label:r===s.length-1?Object(a.jsx)(It,{displayedData:e}):"",name:o("sports:".concat(t.label))},t.id)))]})})]})}}class Ht extends c.a.PureComponent{componentDidMount(){this.updateData()}componentDidUpdate(e){(this.props.user.username&&this.props.user.username!==e.user.username||this.props.statsParams!==e.statsParams)&&this.updateData()}updateData(){this.props.user.username&&this.props.loadWorkouts(this.props.user.username,this.props.user.weekm,this.props.statsParams)}render(){const e=this.props,t=e.displayedSports,s=e.sports,r=e.statistics,o=e.statsParams,c=e.displayEmpty,n=e.t,i=e.user;if(!c&&0===Object.keys(r).length)return Object(a.jsx)("span",{children:n("common:No workouts.")});const l=Rt(r,s,o,t,i.weekm);return Object(a.jsx)(Wt,{sports:s,stats:l,t:n})}}var qt=Object(O.c)((e=>({sports:e.sports.data,statistics:e.statistics.data,user:e.user})),(e=>({loadWorkouts:(t,s,a)=>{const r="yyyy-MM-dd",o="week"===a.duration?"".concat(a.duration).concat(s?"m":""):a.duration,c={from:Object(y.a)(a.start,r),to:Object(y.a)(a.end,r),time:o};e(((e,t,s)=>a=>L.getData("stats/".concat(e,"/").concat(t),s).then((e=>{"success"===e.status?a(U("statistics",e.data)):a(I("statistics|".concat(e.message)))})).catch((e=>a(I("statistics|".concat(e))))))(t,a.type,c))}})))(Ht);class Bt extends c.a.Component{constructor(e,t){super(e,t);const s=new Date;this.state={start:Object(jt.a)(s),end:Object(pt.a)(s),duration:"week",type:"by_time"}}render(){const e=this.props.t;return Object(a.jsxs)("div",{className:"card workout-card",children:[Object(a.jsx)("div",{className:"card-header",children:e("dashboard:This month")}),Object(a.jsx)("div",{className:"card-body",children:Object(a.jsx)(qt,{displayEmpty:!1,statsParams:this.state,t:e})})]})}}function Vt(e){const t=e.t,s=e.user,r=s.total_duration.match(/day/g)?"".concat(s.total_duration.split(" ")[0]," ").concat(s.total_duration.match(/days/g)?t("common:days"):t("common:day")):"0 ".concat(t("common:days"),",");let o=s.total_duration.match(/day/g)?s.total_duration.split(", ")[1]:s.total_duration;return o="".concat(o.split(":")[0],"h ").concat(o.split(":")[1],"min"),Object(a.jsxs)("div",{className:"row",children:[Object(a.jsx)("div",{className:"col-lg-3 col-md-6 col-sm-6",children:Object(a.jsx)("div",{className:"card workout-card",children:Object(a.jsxs)("div",{className:"card-body row",children:[Object(a.jsx)("div",{className:"col-3",children:Object(a.jsx)("i",{className:"fa fa-calendar fa-3x fa-color"})}),Object(a.jsxs)("div",{className:"col-9 text-right",children:[Object(a.jsx)("div",{className:"huge",children:s.nb_workouts}),Object(a.jsx)("div",{children:"".concat(1===s.nb_workouts?t("common:workout"):t("common:workouts"))})]})]})})}),Object(a.jsx)("div",{className:"col-lg-3 col-md-6 col-sm-6",children:Object(a.jsx)("div",{className:"card workout-card",children:Object(a.jsxs)("div",{className:"card-body row",children:[Object(a.jsx)("div",{className:"col-3",children:Object(a.jsx)("i",{className:"fa fa-road fa-3x fa-color"})}),Object(a.jsxs)("div",{className:"col-9 text-right",children:[Object(a.jsx)("div",{className:"huge",children:Number(s.total_distance).toFixed(2)}),Object(a.jsx)("div",{children:"km"})]})]})})}),Object(a.jsx)("div",{className:"col-lg-3 col-md-6 col-sm-6",children:Object(a.jsx)("div",{className:"card workout-card",children:Object(a.jsxs)("div",{className:"card-body row",children:[Object(a.jsx)("div",{className:"col-3",children:Object(a.jsx)("i",{className:"fa fa-clock-o fa-3x fa-color"})}),Object(a.jsxs)("div",{className:"col-9 text-right",children:[Object(a.jsx)("div",{className:"huge",children:r}),Object(a.jsx)("div",{children:o})]})]})})}),Object(a.jsx)("div",{className:"col-lg-3 col-md-6 col-sm-6",children:Object(a.jsx)("div",{className:"card workout-card",children:Object(a.jsxs)("div",{className:"card-body row",children:[Object(a.jsx)("div",{className:"col-3",children:Object(a.jsx)("i",{className:"fa fa-tags fa-3x fa-color"})}),Object(a.jsxs)("div",{className:"col-9 text-right",children:[Object(a.jsx)("div",{className:"huge",children:s.nb_sports}),Object(a.jsx)("div",{children:"".concat(1===s.nb_sports?t("common:sport"):t("common:sports"))})]})]})})})]})}function Gt(e){const t=e.sports,s=e.t,r=e.user,o=e.workout;return Object(a.jsxs)("div",{className:"card workout-card text-center",children:[Object(a.jsx)("div",{className:"card-header",children:Object(a.jsxs)(K.a,{to:"/workouts/".concat(o.id),children:[t.filter((e=>e.id===o.sport_id)).map((e=>s("sports:".concat(e.label))))," ","-"," ",Object(y.a)(P(o.workout_date,r.timezone),"dd/MM/yyyy HH:mm")]})}),Object(a.jsx)("div",{className:"card-body",children:Object(a.jsxs)("div",{className:"row",children:[o.map&&Object(a.jsx)("div",{className:"col",children:Object(a.jsx)(nt,{workout:o})}),Object(a.jsx)("div",{className:"col",children:Object(a.jsxs)("p",{children:[Object(a.jsx)("i",{className:"fa fa-clock-o","aria-hidden":"true"})," ",s("workouts:Duration"),": ",o.moving,o.map?Object(a.jsxs)("span",{children:[Object(a.jsx)("br",{}),Object(a.jsx)("br",{})]}):" - ",Object(a.jsx)("i",{className:"fa fa-road","aria-hidden":"true"})," ",s("workouts:Distance"),": ",o.distance," km"]})})]})})]})}class Jt extends c.a.Component{constructor(e,t){super(e,t),this.state={page:1}}componentDidMount(){this.props.loadWorkouts()}render(){const e=this.props,t=e.loadMoreWorkouts,s=e.message,r=e.records,o=e.sports,c=e.t,n=e.user,i=e.workouts,l=!(i.length>0)||null===i[i.length-1].previous_workout,d=this.state.page;return Object(a.jsxs)("div",{children:[Object(a.jsx)(f.a,{children:Object(a.jsxs)("title",{children:["FitTrackee - ",c("common:Dashboard")]})}),s?Object(a.jsx)(v,{message:s,t:c}):i&&n.total_duration&&o.length>0&&Object(a.jsxs)("div",{className:"container dashboard",children:[Object(a.jsx)(Vt,{user:n,t:c}),Object(a.jsxs)("div",{className:"row",children:[Object(a.jsxs)("div",{className:"col-md-4",children:[Object(a.jsx)(Bt,{t:c}),Object(a.jsx)(Et,{t:c,records:r,sports:o,user:n})]}),Object(a.jsxs)("div",{className:"col-md-8",children:[Object(a.jsx)(Ct,{weekm:n.weekm}),i.length>0?i.map((e=>Object(a.jsx)(Gt,{workout:e,sports:o,t:c,user:n},e.id))):Object(a.jsx)(ot,{t:c}),!l&&Object(a.jsx)("input",{type:"submit",className:"btn btn-default btn-md btn-block",value:"Load more workouts",onClick:()=>{t(d+1),this.setState({page:d+1})}})]})]})]})]})}}var Kt=Object(w.a)()(Object(O.c)((e=>({workouts:e.workouts.data,message:e.message,records:e.records.data,sports:e.sports.data,user:e.user})),(e=>({loadWorkouts:()=>{e(H("getData","workouts",{page:1})),e(H("getData","records"))},loadMoreWorkouts:t=>{e(De({page:t}))}})))(Jt));function Yt(){return Object(a.jsx)("footer",{className:"footer",children:Object(a.jsxs)("div",{className:"container",children:[Object(a.jsx)("strong",{children:"FitTrackee"})," v","0.4.4"," -"," ",Object(a.jsx)("a",{href:"https://github.com/SamR1/FitTrackee",target:"_blank",rel:"noopener noreferrer",children:"source code"})," ","under"," ",Object(a.jsx)("a",{href:"https://choosealicense.com/licenses/gpl-3.0/",target:"_blank",rel:"noopener noreferrer",children:"GPLv3"})," ","license -"," ",Object(a.jsx)("a",{href:"https://samr1.github.io/FitTrackee/",target:"_blank",rel:"noopener noreferrer",children:"documentation"})]})})}class Xt extends c.a.Component{componentDidMount(){this.props.UserLogout()}render(){return Object(a.jsx)("div",{className:"container dashboard",children:Object(a.jsxs)("div",{className:"row",children:[Object(a.jsx)("div",{className:"col-2"}),Object(a.jsx)("div",{className:"card col-8",children:Object(a.jsx)("div",{className:"card-body",children:Object(a.jsx)("div",{className:"text-center",children:Object(a.jsxs)(ce.a,{i18nKey:"user:loggedOut",children:["You are now logged out. Click ",Object(a.jsx)(K.a,{to:"/login",children:"here"})," to log back in."]})})})}),Object(a.jsx)("div",{className:"col-2"})]})})}}var $t=Object(O.c)((e=>({user:e.user})),(e=>({UserLogout:()=>{e({type:"LOGOUT"})}})))(Xt);function Zt(){return(Zt=Object.assign||function(e){for(var t=1;t=0||(r[s]=e[s]);return r}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,s)&&(r[s]=e[s])}return r}var es=o.createElement("path",{d:"m466.916 27.803h-421.832c-24.859 0-45.084 20.225-45.084 45.084v366.226c0 24.859 20.225 45.084 45.084 45.084h421.832c24.859 0 45.084-20.225 45.084-45.084v-366.226c0-24.859-20.225-45.084-45.084-45.084z",fill:"#f0f9ff"}),ts=o.createElement("path",{d:"m198.58 188.334-181.344-150.862c-7.75 6.107-13.456 14.691-15.905 24.554l164.142 136.551h33.102z",fill:"#f40055"}),ss=o.createElement("path",{d:"m313.425 198.576h33.93l163.447-135.973c-2.325-9.923-7.93-18.592-15.613-24.796l-181.764 151.211z",fill:"#c20044"}),as=o.createElement("path",{d:"m165.472 313.425-164.141 136.549c2.449 9.863 8.155 18.447 15.905 24.553l181.344-150.861-.005-10.241z",fill:"#f40055"}),rs=o.createElement("path",{d:"m313.425 313.425v9.557l181.765 151.211c7.683-6.204 13.288-14.874 15.613-24.796l-163.446-135.971z",fill:"#c20044"}),os=o.createElement("path",{d:"m53.273 27.803 145.302 120.879v-120.879z",fill:"#406bd4"}),cs=o.createElement("path",{d:"m313.425 150.571v-122.768h148.082z",fill:"#3257b0"}),ns=o.createElement("path",{d:"m394.732 198.575 117.268-97.556v97.556z",fill:"#3257b0"}),is=o.createElement("g",{fill:"#406bd4"},o.createElement("path",{d:"m0 99.317v99.258h119.313z"}),o.createElement("path",{d:"m0 313.425v97.699l117.44-97.699z"}),o.createElement("path",{d:"m50.49 484.197 148.085-122.676v122.676z"})),ls=o.createElement("path",{d:"m313.425 484.197v-124.139l149.221 124.139z",fill:"#3257b0"}),ds=o.createElement("path",{d:"m512 409.423-115.395-95.998h115.395z",fill:"#3257b0"}),us=o.createElement("path",{d:"m512 222.142h-222.142v-194.339h-67.716v194.339h-222.142v67.716h222.142v194.339h67.716v-194.339h222.142z",fill:"#f40055"}),ms=o.createElement("path",{d:"m289.858 222.142v-194.339h-33.858v456.394h33.858v-194.339h222.142v-67.716z",fill:"#c20044"});function js(e,t){let s=e.title,a=e.titleId,r=Qt(e,["title","titleId"]);return o.createElement("svg",Zt({id:"Capa_1",enableBackground:"new 0 0 512 512",height:512,viewBox:"0 0 512 512",width:512,xmlns:"http://www.w3.org/2000/svg",ref:t,"aria-labelledby":a},r),s?o.createElement("title",{id:a},s):null,es,ts,ss,as,rs,os,cs,ns,is,ls,ds,us,ms)}const ps=o.forwardRef(js);s.p;function hs(){return(hs=Object.assign||function(e){for(var t=1;t=0||(r[s]=e[s]);return r}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,s)&&(r[s]=e[s])}return r}var xs=o.createElement("path",{d:"m173.899 31.804h-8.707l-4.397-4h-115.711c-24.859-.001-45.084 20.224-45.084 45.083v366.226c0 24.859 20.225 45.084 45.084 45.084h115.711l6.348-4h6.755v-448.393z",fill:"#406bd4"}),Os=o.createElement("path",{d:"m466.916 27.803h-115.711l-4.523 4h-5.141v448.393h4.141l5.523 4h115.711c24.859 0 45.084-20.225 45.084-45.084v-366.225c0-24.859-20.225-45.084-45.084-45.084z",fill:"#c20044"}),gs=o.createElement("path",{d:"m160.795 27.803h190.409v456.394h-190.409z",fill:"#f0f9ff"}),fs=o.createElement("path",{d:"m256 27.803h95.205v456.394h-95.205z",fill:"#cee5f5"});function ws(e,t){let s=e.title,a=e.titleId,r=bs(e,["title","titleId"]);return o.createElement("svg",hs({id:"Capa_1",enableBackground:"new 0 0 512 512",height:512,viewBox:"0 0 512 512",width:512,xmlns:"http://www.w3.org/2000/svg",ref:t,"aria-labelledby":a},r),s?o.createElement("title",{id:a},s):null,xs,Os,gs,fs)}const vs=o.forwardRef(ws);s.p;const ks=[{name:"en",selected:!0,flag:Object(a.jsx)(ps,{})},{name:"fr",selected:!1,flag:Object(a.jsx)(vs,{})}];class ys extends o.Component{constructor(e){super(e),this.state={isOpen:!1}}toggleDropdown(){this.setState((e=>({isOpen:!e.isOpen})))}render(){const e=this.state.isOpen,t=this.props,s=t.language,r=t.onUpdateLanguage;return Object(a.jsx)("div",{className:"dropdown-wrapper",onClick:()=>this.toggleDropdown(),children:Object(a.jsx)("ul",{className:"dropdown-list i18n-flag",children:ks.filter((t=>e?t:t.name===s)).map((t=>Object(a.jsxs)("li",{className:"dropdown-item".concat(t.name===s&&e?" dropdown-item-selected":""),onClick:()=>r(t.name,s),children:[t.flag," ",t.name]},t.name)))})})}}var Ns=Object(O.c)((e=>({language:e.language})),(e=>({onUpdateLanguage:(t,s)=>{t!==s&&e(q(t))}})))(ys);class _s extends c.a.PureComponent{render(){const e=this.props,t=e.admin,s=e.isAuthenticated,r=e.picture,o=e.t,c=e.username;return Object(a.jsx)("header",{children:Object(a.jsx)("nav",{className:"navbar navbar-expand-lg navbar-light bg-light",children:Object(a.jsxs)("div",{className:"container",children:[Object(a.jsx)("span",{className:"navbar-brand",children:"FitTrackee"}),Object(a.jsx)("button",{className:"navbar-toggler",type:"button","data-toggle":"collapse","data-target":"#navbarSupportedContent","aria-controls":"navbarSupportedContent","aria-expanded":"false","aria-label":"Toggle navigation",children:Object(a.jsx)("span",{className:"navbar-toggler-icon"})}),Object(a.jsxs)("div",{className:"collapse navbar-collapse",id:"navbarSupportedContent",children:[Object(a.jsxs)("ul",{className:"navbar-nav mr-auto",children:[Object(a.jsx)("li",{className:"nav-item",children:Object(a.jsx)(K.a,{className:"nav-link",to:{pathname:"/"},children:o("common:Dashboard")})}),s&&Object(a.jsx)("li",{className:"nav-item",children:Object(a.jsx)(K.a,{className:"nav-link",to:{pathname:"/workouts/history"},children:o("Workouts")})}),s&&Object(a.jsx)("li",{className:"nav-item",children:Object(a.jsx)(K.a,{className:"nav-link",to:{pathname:"/workouts/statistics"},children:o("common:Statistics")})}),t&&Object(a.jsx)("li",{className:"nav-item",children:Object(a.jsx)(K.a,{className:"nav-link",to:{pathname:"/admin"},children:"Admin"})}),s&&Object(a.jsx)("li",{className:"nav-item",children:Object(a.jsx)(K.a,{className:"nav-link",to:{pathname:"/workouts/add"},children:Object(a.jsx)("strong",{children:o("common:Add workout")})})})]}),Object(a.jsxs)("ul",{className:"navbar-nav flex-row ml-md-auto d-none d-md-flex",children:[!s&&Object(a.jsx)("li",{className:"nav-item",children:Object(a.jsx)(K.a,{className:"nav-link",to:{pathname:"/register"},children:o("user:Register")})}),!s&&Object(a.jsx)("li",{className:"nav-item",children:Object(a.jsx)(K.a,{className:"nav-link",to:{pathname:"/login"},children:o("user:Login")})}),s&&Object(a.jsxs)(a.Fragment,{children:[!0===r?Object(a.jsx)("img",{alt:"Avatar",src:"".concat(C,"users/").concat(c,"/picture?").concat(Date.now()),className:"img-fluid App-nav-profile-img"}):Object(a.jsx)("i",{className:"fa fa-user-circle-o fa-2x no-picture","aria-hidden":"true"}),Object(a.jsx)("li",{className:"nav-item",children:Object(a.jsx)(K.a,{className:"nav-link",to:{pathname:"/profile"},children:c})}),Object(a.jsx)("li",{className:"nav-item",children:Object(a.jsx)(K.a,{className:"nav-link",to:{pathname:"/logout"},children:o("user:Logout")})})]}),Object(a.jsx)("li",{children:Object(a.jsx)(Ns,{})})]})]})]})})})}}var Ss=Object(w.a)()(Object(O.c)((({user:e})=>({admin:e.admin,isAuthenticated:e.isAuthenticated,picture:e.picture,username:e.username})))(_s));function Ds(){return(Ds=Object.assign||function(e){for(var t=1;t=0||(r[s]=e[s]);return r}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,s)&&(r[s]=e[s])}return r}var Es=o.createElement("g",null,o.createElement("g",null,o.createElement("path",{d:"M468.683,287.265h-69.07c-4.147,0-7.508,3.361-7.508,7.508c0,4.147,3.361,7.508,7.508,7.508h69.07 c4.147,0,7.508-3.361,7.508-7.508C476.191,290.626,472.83,287.265,468.683,287.265z"}))),As=o.createElement("g",null,o.createElement("g",null,o.createElement("path",{d:"M105.012,268.377L85.781,256l19.231-12.376c3.487-2.243,4.495-6.888,2.251-10.376c-2.244-3.486-6.888-4.497-10.376-2.25 l-17.471,11.243v-20.776c0-4.147-3.361-7.508-7.508-7.508c-4.147,0-7.508,3.361-7.508,7.508v20.775l-17.47-11.243 c-3.486-2.245-8.132-1.238-10.376,2.25c-2.245,3.487-1.237,8.133,2.25,10.376L58.034,256l-19.231,12.376 c-3.487,2.244-4.495,6.889-2.25,10.376c1.435,2.23,3.852,3.446,6.32,3.446c1.391,0,2.799-0.386,4.056-1.196l17.47-11.243v20.775 c0,4.147,3.361,7.508,7.508,7.508c4.147,0,7.508-3.361,7.508-7.508V269.76l17.471,11.243c1.257,0.809,2.664,1.196,4.056,1.196 c2.467,0,4.885-1.216,6.32-3.446C109.507,275.266,108.499,270.62,105.012,268.377z"}))),Ms=o.createElement("g",null,o.createElement("g",null,o.createElement("path",{d:"M194.441,268.377L175.21,256l19.231-12.376c3.487-2.244,4.495-6.889,2.25-10.376c-2.245-3.486-6.888-4.497-10.376-2.25 l-17.47,11.243v-20.775c0-4.147-3.361-7.508-7.508-7.508c-4.147,0-7.508,3.361-7.508,7.508v20.776l-17.471-11.243 c-3.487-2.245-8.133-1.238-10.376,2.25c-2.245,3.487-1.237,8.133,2.25,10.376L147.463,256l-19.231,12.376 c-3.487,2.244-4.495,6.889-2.25,10.376c1.435,2.23,3.852,3.446,6.32,3.446c1.391,0,2.799-0.386,4.056-1.196l17.471-11.243v20.776 c0,4.147,3.361,7.508,7.508,7.508c4.147,0,7.508-3.361,7.508-7.508V269.76l17.47,11.243c1.257,0.809,2.664,1.196,4.056,1.196 c2.467,0,4.885-1.216,6.32-3.446C198.936,275.266,197.928,270.62,194.441,268.377z"}))),Ts=o.createElement("g",null,o.createElement("g",null,o.createElement("path",{d:"M283.871,268.377L264.64,256l19.231-12.376c3.487-2.243,4.495-6.888,2.251-10.376c-2.245-3.486-6.888-4.497-10.376-2.25 l-17.471,11.243v-20.775c0-4.147-3.361-7.508-7.508-7.508c-4.147,0-7.508,3.361-7.508,7.508v20.775l-17.471-11.243 c-3.486-2.245-8.134-1.238-10.376,2.25c-2.245,3.487-1.237,8.133,2.25,10.376L236.892,256l-19.231,12.376 c-3.487,2.244-4.495,6.889-2.25,10.376c1.435,2.23,3.852,3.446,6.32,3.446c1.391,0,2.799-0.386,4.056-1.196l17.471-11.243v20.775 c0,4.147,3.361,7.508,7.508,7.508c4.147,0,7.508-3.361,7.508-7.508V269.76l17.471,11.243c1.257,0.809,2.664,1.196,4.056,1.196 c2.467,0,4.886-1.216,6.32-3.446C288.366,275.266,287.358,270.62,283.871,268.377z"}))),Ps=o.createElement("g",null,o.createElement("g",null,o.createElement("path",{d:"M373.3,268.377L354.069,256l19.231-12.376c3.487-2.244,4.495-6.889,2.25-10.376c-2.244-3.486-6.888-4.497-10.376-2.25 l-17.471,11.243v-20.776c0-4.147-3.361-7.508-7.508-7.508c-4.147,0-7.508,3.361-7.508,7.508v20.775l-17.47-11.243 c-3.486-2.245-8.132-1.238-10.376,2.25c-2.245,3.487-1.237,8.133,2.25,10.376L326.322,256l-19.231,12.376 c-3.487,2.244-4.495,6.889-2.25,10.376c1.435,2.23,3.852,3.446,6.32,3.446c1.391,0,2.799-0.386,4.056-1.196l17.47-11.243v20.776 c0,4.147,3.361,7.508,7.508,7.508c4.147,0,7.508-3.361,7.508-7.508V269.76l17.471,11.243c1.257,0.809,2.664,1.196,4.056,1.196 c2.467,0,4.885-1.216,6.32-3.446C377.795,275.266,376.787,270.62,373.3,268.377z"}))),Fs=o.createElement("g",null,o.createElement("g",null,o.createElement("path",{d:"M271.792,330.359H15.016V181.642h93.1c4.147,0,7.508-3.361,7.508-7.508c0-4.147-3.361-7.508-7.508-7.508H12.513 C5.613,166.626,0,172.24,0,179.14v153.722c0,6.9,5.613,12.513,12.513,12.513h259.278c4.147,0,7.508-3.361,7.508-7.508 C279.299,333.72,275.939,330.359,271.792,330.359z"}))),zs=o.createElement("g",null,o.createElement("g",null,o.createElement("path",{d:"M499.487,166.626H162.174c-4.147,0-7.508,3.361-7.508,7.508c0,4.147,3.361,7.508,7.508,7.508h334.811v148.716H323.848 c-4.147,0-7.508,3.361-7.508,7.508c0,4.147,3.361,7.508,7.508,7.508h175.64c6.9,0,12.513-5.613,12.513-12.513V179.14 C512.001,172.24,506.387,166.626,499.487,166.626z"})));function Rs(e,t){let s=e.title,a=e.titleId,r=Cs(e,["title","titleId"]);return o.createElement("svg",Ds({id:"Layer_1",xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",x:"0px",y:"0px",viewBox:"0 0 512.001 512.001",style:{enableBackground:"new 0 0 512.001 512.001"},xmlSpace:"preserve",ref:t,"aria-labelledby":a},r),s?o.createElement("title",{id:a},s):null,Es,As,Ms,Ts,Ps,Fs,zs)}const Ls=o.forwardRef(Rs);s.p;function Us(){return(Us=Object.assign||function(e){for(var t=1;t=0||(r[s]=e[s]);return r}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,s)&&(r[s]=e[s])}return r}var Ws=o.createElement("g",null,o.createElement("path",{d:"M339.798,260.429c0.13-0.026,0.257-0.061,0.385-0.094c0.109-0.028,0.219-0.051,0.326-0.084 c0.125-0.038,0.247-0.085,0.369-0.129c0.108-0.039,0.217-0.074,0.324-0.119c0.115-0.048,0.226-0.104,0.338-0.157 c0.109-0.052,0.22-0.1,0.327-0.158c0.107-0.057,0.208-0.122,0.312-0.184c0.107-0.064,0.215-0.124,0.319-0.194 c0.111-0.074,0.214-0.156,0.321-0.236c0.09-0.067,0.182-0.13,0.27-0.202c0.162-0.133,0.316-0.275,0.466-0.421 c0.027-0.026,0.056-0.048,0.083-0.075c0.028-0.028,0.052-0.059,0.079-0.088c0.144-0.148,0.284-0.3,0.416-0.46 c0.077-0.094,0.144-0.192,0.216-0.289c0.074-0.1,0.152-0.197,0.221-0.301c0.074-0.111,0.139-0.226,0.207-0.34 c0.057-0.096,0.118-0.19,0.171-0.289c0.062-0.115,0.114-0.234,0.169-0.351c0.049-0.104,0.101-0.207,0.146-0.314 c0.048-0.115,0.086-0.232,0.128-0.349c0.041-0.114,0.085-0.227,0.12-0.343c0.036-0.118,0.062-0.238,0.092-0.358 c0.029-0.118,0.063-0.234,0.086-0.353c0.028-0.141,0.045-0.283,0.065-0.425c0.014-0.1,0.033-0.199,0.043-0.3 c0.025-0.249,0.038-0.498,0.038-0.748V92.76c0-4.143-3.357-7.5-7.5-7.5h-236.25c-0.066,0-0.13,0.008-0.196,0.01 c-0.143,0.004-0.285,0.01-0.427,0.022c-0.113,0.009-0.225,0.022-0.337,0.037c-0.128,0.016-0.255,0.035-0.382,0.058 c-0.119,0.021-0.237,0.046-0.354,0.073c-0.119,0.028-0.238,0.058-0.356,0.092c-0.117,0.033-0.232,0.069-0.346,0.107 c-0.117,0.04-0.234,0.082-0.349,0.128c-0.109,0.043-0.216,0.087-0.322,0.135c-0.118,0.053-0.235,0.11-0.351,0.169 c-0.099,0.051-0.196,0.103-0.292,0.158c-0.116,0.066-0.23,0.136-0.343,0.208c-0.093,0.06-0.184,0.122-0.274,0.185 c-0.106,0.075-0.211,0.153-0.314,0.235c-0.094,0.075-0.186,0.152-0.277,0.231c-0.09,0.079-0.179,0.158-0.266,0.242 c-0.099,0.095-0.194,0.194-0.288,0.294c-0.047,0.05-0.097,0.094-0.142,0.145c-0.027,0.03-0.048,0.063-0.074,0.093 c-0.094,0.109-0.182,0.223-0.27,0.338c-0.064,0.084-0.13,0.168-0.19,0.254c-0.078,0.112-0.15,0.227-0.222,0.343 c-0.059,0.095-0.12,0.189-0.174,0.286c-0.063,0.112-0.118,0.227-0.175,0.342c-0.052,0.105-0.106,0.21-0.153,0.317 c-0.049,0.113-0.092,0.23-0.135,0.345c-0.043,0.113-0.087,0.225-0.124,0.339c-0.037,0.115-0.067,0.232-0.099,0.349 c-0.032,0.12-0.066,0.239-0.093,0.36c-0.025,0.113-0.042,0.228-0.062,0.342c-0.022,0.13-0.044,0.26-0.06,0.39 c-0.013,0.108-0.019,0.218-0.027,0.328c-0.01,0.14-0.019,0.28-0.021,0.421c-0.001,0.041-0.006,0.081-0.006,0.122v46.252 c0,4.143,3.357,7.5,7.5,7.5s7.5-3.357,7.5-7.5v-29.595l66.681,59.037c-0.348,0.245-0.683,0.516-0.995,0.827l-65.687,65.687v-49.288 c0-4.143-3.357-7.5-7.5-7.5s-7.5,3.357-7.5,7.5v9.164h-38.75c-4.143,0-7.5,3.357-7.5,7.5s3.357,7.5,7.5,7.5h38.75v43.231 c0,4.143,3.357,7.5,7.5,7.5h236.25c0.247,0,0.494-0.013,0.74-0.037c0.115-0.011,0.226-0.033,0.339-0.049 C339.542,260.469,339.67,260.454,339.798,260.429z M330.834,234.967l-65.688-65.687c-0.042-0.042-0.087-0.077-0.13-0.117 l49.383-41.897c3.158-2.68,3.546-7.412,0.866-10.571c-2.678-3.157-7.41-3.547-10.571-0.866l-84.381,71.59l-98.444-87.158h208.965 V234.967z M185.878,179.888c0.535-0.535,0.969-1.131,1.308-1.765l28.051,24.835c1.418,1.255,3.194,1.885,4.972,1.885 c1.726,0,3.451-0.593,4.853-1.781l28.587-24.254c0.26,0.38,0.553,0.743,0.89,1.08l65.687,65.687H120.191L185.878,179.888z"}),o.createElement("path",{d:"M7.5,170.676h126.667c4.143,0,7.5-3.357,7.5-7.5s-3.357-7.5-7.5-7.5H7.5c-4.143,0-7.5,3.357-7.5,7.5 S3.357,170.676,7.5,170.676z"}),o.createElement("path",{d:"M20.625,129.345H77.5c4.143,0,7.5-3.357,7.5-7.5s-3.357-7.5-7.5-7.5H20.625c-4.143,0-7.5,3.357-7.5,7.5 S16.482,129.345,20.625,129.345z"}),o.createElement("path",{d:"M62.5,226.51h-55c-4.143,0-7.5,3.357-7.5,7.5s3.357,7.5,7.5,7.5h55c4.143,0,7.5-3.357,7.5-7.5S66.643,226.51,62.5,226.51z"}));function Hs(e,t){let s=e.title,a=e.titleId,r=Is(e,["title","titleId"]);return o.createElement("svg",Us({id:"Capa_1",xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",x:"0px",y:"0px",viewBox:"0 0 345.834 345.834",style:{enableBackground:"new 0 0 345.834 345.834"},xmlSpace:"preserve",ref:t,"aria-labelledby":a},r),s?o.createElement("title",{id:a},s):null,Ws)}const qs=o.forwardRef(Hs);s.p;function Bs(e){const t=Object(ae.a)().t,s=e.action;return Object(a.jsx)("div",{className:"container dashboard",children:Object(a.jsxs)("div",{className:"row",children:[Object(a.jsx)("div",{className:"col-2"}),Object(a.jsx)("div",{className:"card col-8",children:Object(a.jsx)("div",{className:"card-body",children:Object(a.jsxs)("div",{className:"text-center ",children:["sent"===s&&Object(a.jsxs)(a.Fragment,{children:[Object(a.jsx)("div",{className:"svg-icon",children:Object(a.jsx)(qs,{})}),t("user:Check your email. If your address is in our database, you'll received an email with a link to reset your password.")]}),"updated"===s&&Object(a.jsxs)(a.Fragment,{children:[Object(a.jsx)("div",{className:"svg-icon",children:Object(a.jsx)(Ls,{})}),Object(a.jsxs)(ce.a,{i18nKey:"user:updatedPasswordText",children:["Your password have been updated. Click",Object(a.jsx)(K.a,{to:"/login",children:"here"})," to log in."]})]})]})})}),Object(a.jsx)("div",{className:"col-2"})]})})}var Vs=s(231),Gs=s.n(Vs);class Js extends c.a.Component{constructor(e,t){super(e,t),this.state={formData:{},displayModal:!1}}componentDidMount(){this.initForm()}componentDidUpdate(e){e.user!==this.props.user&&this.initForm()}initForm(){const e=this.props.user,t={};Object.keys(e).map((s=>null===e[s]?t[s]="":t[s]="birth_date"===s?Object(y.a)(new Date(e[s]),"yyyy-MM-DD"):e[s])),this.setState({formData:t})}handleFormChange(e){const t=this.state.formData;"weekm"===e.target.name?t.weekm="Monday"===e.target.value:t[e.target.name]=e.target.value,this.setState(t)}displayModal(e){this.setState((t=>Object(k.a)(Object(k.a)({},t),{},{displayModal:e})))}render(){const e=this.props,t=e.message,s=e.onDeleteUser,r=e.onHandleProfileFormSubmit,o=e.t,c=e.user,n=this.state,i=n.displayModal,l=n.formData;return Object(a.jsxs)("div",{children:[Object(a.jsx)(f.a,{children:Object(a.jsxs)("title",{children:["FitTrackee - ",o("user:Profile Edition")]})}),l.isAuthenticated&&Object(a.jsxs)("div",{className:"container",children:[i&&Object(a.jsx)(Pe,{title:o("common:Confirmation"),text:o("user:Are you sure you want to delete your account? All data will be deleted, this cannot be undone."),confirm:()=>{s(c.username),this.displayModal(!1)},close:()=>this.displayModal(!1)}),Object(a.jsx)("h1",{className:"page-title",children:o("user:Profile Edition")}),Object(a.jsxs)("div",{className:"row",children:[Object(a.jsx)("div",{className:"col-md-2"}),Object(a.jsx)("div",{className:"col-md-8",children:Object(a.jsxs)("div",{className:"card",children:[Object(a.jsx)("div",{className:"card-header",children:c.username}),Object(a.jsx)("div",{className:"card-body",children:Object(a.jsx)("div",{className:"row",children:Object(a.jsxs)("div",{className:"col-md-12",children:[Object(a.jsxs)("form",{onSubmit:e=>{e.preventDefault(),r(l)},children:[Object(a.jsx)("div",{className:"form-group",children:Object(a.jsxs)("label",{children:[o("user:Email"),":",Object(a.jsx)("input",{name:"email",className:"form-control input-lg",type:"text",value:l.email,readOnly:!0})]})}),Object(a.jsx)("div",{className:"form-group",children:Object(a.jsxs)("label",{children:[o("user:Registration Date"),":",Object(a.jsx)("input",{name:"createdAt",className:"form-control input-lg",type:"text",value:l.created_at,disabled:!0})]})}),Object(a.jsx)("div",{className:"form-group",children:Object(a.jsxs)("label",{children:[o("user:Password"),":",Object(a.jsx)("input",{name:"password",className:"form-control input-lg",type:"password",onChange:e=>this.handleFormChange(e)})]})}),Object(a.jsx)("div",{className:"form-group",children:Object(a.jsxs)("label",{children:[o("user:Password Confirmation"),":",Object(a.jsx)("input",{name:"password_conf",className:"form-control input-lg",type:"password",onChange:e=>this.handleFormChange(e)})]})}),Object(a.jsx)("hr",{}),Object(a.jsx)("div",{className:"form-group",children:Object(a.jsxs)("label",{children:[o("user:First Name"),":",Object(a.jsx)("input",{name:"first_name",className:"form-control input-lg",type:"text",value:l.first_name,onChange:e=>this.handleFormChange(e)})]})}),Object(a.jsx)("div",{className:"form-group",children:Object(a.jsxs)("label",{children:[o("user:Last Name"),":",Object(a.jsx)("input",{name:"last_name",className:"form-control input-lg",type:"text",value:l.last_name,onChange:e=>this.handleFormChange(e)})]})}),Object(a.jsx)("div",{className:"form-group",children:Object(a.jsxs)("label",{children:[o("user:Birth Date"),Object(a.jsx)("input",{name:"birth_date",className:"form-control input-lg",type:"date",value:l.birth_date,onChange:e=>this.handleFormChange(e)})]})}),Object(a.jsx)("div",{className:"form-group",children:Object(a.jsxs)("label",{children:[o("user:Location"),":",Object(a.jsx)("input",{name:"location",className:"form-control input-lg",type:"text",value:l.location,onChange:e=>this.handleFormChange(e)})]})}),Object(a.jsx)("div",{className:"form-group",children:Object(a.jsxs)("label",{children:[o("user:Bio"),":",Object(a.jsx)("textarea",{name:"bio",className:"form-control input-lg",maxLength:"200",value:l.bio,onChange:e=>this.handleFormChange(e)})]})}),Object(a.jsx)("div",{className:"form-group",children:Object(a.jsxs)("label",{children:[o("user:Language"),":",Object(a.jsx)("select",{name:"language",className:"form-control input-lg",value:l.language,onChange:e=>this.handleFormChange(e),children:ks.map((e=>Object(a.jsx)("option",{value:e.name,children:e.name},e.name)))})]})}),Object(a.jsx)("div",{className:"form-group",children:Object(a.jsxs)("label",{children:[o("user:Timezone"),":",Object(a.jsx)(Gs.a,{className:"form-control timezone-custom",onChange:e=>{const t={target:{name:"timezone",value:e||"Europe/Paris"}};this.handleFormChange(t)},value:l.timezone})]})}),Object(a.jsx)("div",{className:"form-group",children:Object(a.jsxs)("label",{children:[o("user:First day of week"),":",Object(a.jsxs)("select",{name:"weekm",className:"form-control input-lg",value:l.weekm?"Monday":"Sunday",onChange:e=>this.handleFormChange(e),children:[Object(a.jsx)("option",{value:"Sunday",children:o("user:Sunday")}),Object(a.jsx)("option",{value:"Monday",children:o("user:Monday")})]})]})}),Object(a.jsx)("button",{type:"submit",className:"btn btn-primary",children:o("common:Submit")}),Object(a.jsx)("button",{className:"btn btn-danger",onClick:e=>{e.preventDefault(),this.displayModal(!0)},children:o("user:Delete my account")}),Object(a.jsx)("button",{type:"submit",className:"btn btn-secondary",onClick:()=>Ta.push("/profile"),children:o("common:Cancel")})]}),Object(a.jsx)(v,{message:t,t:o})]})})})]})}),Object(a.jsx)("div",{className:"col-md-2"})]})]})]})}}var Ks=Object(w.a)()(Object(O.c)((e=>({location:e.router.location,message:e.message,user:e.user})),(e=>({onDeleteUser:t=>{e(ye(t))},onHandleProfileFormSubmit:t=>{e((e=>t=>!e.password===e.password_conf?t(fe("Password and password confirmation don't match.")):(delete e.id,L.postData("auth/profile/edit",e).then((e=>{if("success"===e.status)return t(ve()),Ta.push("/profile");t(fe(e.message))})).catch((e=>{throw e}))))(t))}})))(Js)),Ys=s(475),Xs=s(476),$s=s(477),Zs=s(232);const Qs=["week","month","year"];class ea extends c.a.Component{constructor(e,t){super(e,t);const s=new Date;this.state={displayedSports:e.sports.map((e=>e.id)),statsParams:{start:Object(jt.a)(Object(vt.a)(s,11)),end:Object(pt.a)(s),duration:"month",type:"by_time"}}}componentDidUpdate(e){this.props.sports!==e.sports&&this.updateDisplayedSports()}updateDisplayedSports(){const e=this.props.sports;this.setState({displayedSports:e.map((e=>e.id))})}handleOnChangeDuration(e){const t=e.target.name,s=new Date,a="year"===t?Object(Mt.a)(Object(Ys.a)(s,9)):"week"===t?Object(jt.a)(Object(vt.a)(s,2)):Object(jt.a)(Object(vt.a)(s,11)),r="year"===t?Object(Xs.a)(s):"week"===t?Object(bt.a)(s):Object(pt.a)(s);this.setState({statsParams:{duration:t,end:r,start:a,type:"by_time"}})}handleOnChangeSports(e){const t=this.state.displayedSports;t.includes(e)?this.setState({displayedSports:t.filter((t=>t!==e))}):this.setState({displayedSports:t.concat([e])})}handleOnClickArrows(e){const t=this.state.statsParams,s=t.start,a=t.end,r=t.duration;let o,c;e?(o="year"===r?Object(Mt.a)(Object(Ys.a)(s,1)):"week"===r?Object(ht.a)(Object($s.a)(s,1)):Object(jt.a)(Object(vt.a)(s,1)),c="year"===r?Object(Xs.a)(Object(Ys.a)(a,1)):"week"===r?Object(bt.a)(Object($s.a)(a,1)):Object(pt.a)(Object(vt.a)(a,1))):(o="year"===r?Object(Mt.a)(Object(At.a)(s,1)):"week"===r?Object(ht.a)(Object(Zs.a)(s,1)):Object(jt.a)(Object(wt.a)(s,1)),c="year"===r?Object(Xs.a)(Object(At.a)(a,1)):"week"===r?Object(bt.a)(Object(Zs.a)(a,1)):Object(pt.a)(Object(wt.a)(a,1))),this.setState({statsParams:{duration:r,end:c,start:o,type:"by_time"}})}render(){const e=this.state,t=e.displayedSports,s=e.statsParams,r=this.props,o=r.sports,c=r.t,n=r.user,i=xe(o.filter((e=>n.sports_list.includes(e.id))),c);return Object(a.jsxs)(a.Fragment,{children:[Object(a.jsx)(f.a,{children:Object(a.jsxs)("title",{children:["FitTrackee - ",c("statistics:Statistics")]})}),Object(a.jsxs)("div",{className:"container dashboard",children:[Object(a.jsxs)("div",{className:"card workout-card",children:[Object(a.jsx)("div",{className:"card-header",children:c("statistics:Statistics")}),Object(a.jsxs)("div",{className:"card-body".concat(0===n.nb_workouts?" stats-disabled":""),children:[Object(a.jsxs)("div",{className:"chart-filters row",children:[Object(a.jsx)("div",{className:"col chart-arrows",children:Object(a.jsx)("p",{className:"text-center",children:Object(a.jsx)("i",{className:"fa fa-chevron-left","aria-hidden":"true",onClick:()=>this.handleOnClickArrows(!0)})})}),Object(a.jsx)("div",{className:"col-md-3 time-frames justify-content-around",children:Qs.map((e=>Object(a.jsx)("div",{className:"time-frame",children:Object(a.jsxs)("label",{children:[Object(a.jsx)("input",{type:"radio",id:e,name:e,checked:e===s.duration,onChange:e=>this.handleOnChangeDuration(e)}),Object(a.jsx)("span",{children:c("statistics:".concat(e))})]})},e)))}),Object(a.jsx)("div",{className:"col chart-arrows",children:Object(a.jsx)("p",{className:"text-center",children:Object(a.jsx)("i",{className:"fa fa-chevron-right","aria-hidden":"true",onClick:()=>this.handleOnClickArrows(!1)})})})]}),Object(a.jsx)(qt,{displayEmpty:!0,displayedSports:t,statsParams:s,t:c}),Object(a.jsx)("div",{className:"row chart-workouts",children:i.map((e=>Object(a.jsxs)("label",{className:"col workout-label",children:[Object(a.jsx)("input",{type:"checkbox",checked:t.includes(e.id),name:e.label,onChange:()=>this.handleOnChangeSports(e.id)}),Object(a.jsx)("span",{style:{color:ue[e.id-1]},children:" ".concat(e.label)})]},e.id)))})]})]}),0===n.nb_workouts&&Object(a.jsx)(ot,{t:c})]})]})}}var ta=Object(w.a)()(Object(O.c)((e=>({sports:e.sports.data,user:e.user})))(ea));function sa(e){const t=Object(ae.a)().t,s="user:".concat(e.formType.charAt(0).toUpperCase()).concat(e.formType.slice(1));return Object(a.jsxs)("div",{children:[Object(a.jsx)(f.a,{children:Object(a.jsxs)("title",{children:["FitTrackee - ",t("user:".concat(e.formType))]})}),Object(a.jsx)("h1",{className:"page-title",children:t(s)}),Object(a.jsx)("div",{className:"container",children:Object(a.jsxs)("div",{className:"row",children:[Object(a.jsx)("div",{className:"col-md-3"}),Object(a.jsxs)("div",{className:"col-md-6",children:[Object(a.jsx)("br",{}),"register"!==e.formType||e.isRegistrationAllowed?Object(a.jsxs)(a.Fragment,{children:[Object(a.jsxs)("form",{onSubmit:t=>e.handleUserFormSubmit(t,e.formType),children:["register"===e.formType&&Object(a.jsx)("div",{className:"form-group",children:Object(a.jsx)("input",{className:"form-control input-lg",name:"username",placeholder:t("user:Enter a username"),required:!0,type:"text",value:e.userForm.username,onChange:e.onHandleFormChange})}),"password reset"!==e.formType&&Object(a.jsx)("div",{className:"form-group",children:Object(a.jsx)("input",{className:"form-control input-lg",name:"email",placeholder:t("user:Enter an email address"),required:!0,type:"email",value:e.userForm.email,onChange:e.onHandleFormChange})}),"reset your password"!==e.formType&&Object(a.jsxs)(a.Fragment,{children:[Object(a.jsx)("div",{className:"form-group",children:Object(a.jsx)("input",{className:"form-control input-lg",name:"password",placeholder:t("user:Enter a password"),required:!0,type:"password",value:e.userForm.password,onChange:e.onHandleFormChange})}),"login"!==e.formType&&Object(a.jsx)("div",{className:"form-group",children:Object(a.jsx)("input",{className:"form-control input-lg",name:"password_conf",placeholder:t("user:Enter the password confirmation"),required:!0,type:"password",value:e.userForm.password_conf,onChange:e.onHandleFormChange})})]}),Object(a.jsx)("input",{type:"submit",className:"btn btn-primary btn-lg btn-block",value:t("Submit")})]}),Object(a.jsx)("p",{className:"password-forget",children:"login"===e.formType&&Object(a.jsx)(K.a,{to:{pathname:"/password-reset/request"},children:t("user:Forgot password?")})})]}):Object(a.jsxs)("div",{className:"card",children:[Object(a.jsx)("div",{className:"card-body",children:"Registration is disabled."}),Object(a.jsx)("div",{className:"card-body",children:Object(a.jsx)("button",{type:"submit",className:"btn btn-secondary btn-lg btn-block",onClick:()=>Ta.go(-1),children:"Back"})})]})]}),Object(a.jsx)("div",{className:"col-md-3"})]})})]})}class aa extends c.a.Component{constructor(e,t){super(e,t),this.state={formData:{username:"",email:"",password:"",password_conf:""}}}componentDidUpdate(e){e.location.pathname!==this.props.location.pathname&&this.emptyForm()}emptyForm(){const e=this.state.formData;Object.keys(e).map((t=>e[t]="")),this.setState(e)}onHandleFormChange(e){const t=this.state.formData;t[e.target.name]=e.target.value,this.setState(t)}render(){const e=this.props,t=e.formType,s=e.isRegistrationAllowed,r=e.message,o=e.messages,c=e.onHandleUserFormSubmit,n=e.t,i=this.state.formData,l=this.props.location.query.token;return Object(a.jsx)("div",{children:M()||"password reset"===t&&!l?Object(a.jsx)(g.a,{to:"/"}):Object(a.jsxs)("div",{children:[Object(a.jsx)(v,{message:r,messages:o,t:n}),Object(a.jsx)(sa,{isRegistrationAllowed:s,formType:t,userForm:i,onHandleFormChange:e=>this.onHandleFormChange(e),handleUserFormSubmit:e=>{e.preventDefault(),"password reset"===t&&(i.token=l),c(i,t)}})]})})}}var ra=Object(w.a)()(Object(O.c)((e=>({isRegistrationAllowed:e.application.config.is_registration_enabled,location:e.router.location,message:e.message,messages:e.messages})),(e=>({onHandleUserFormSubmit:(t,s)=>{e(ke(t,s="password reset"===s?"password/update":"reset your password"===s?"password/reset-request":s))}})))(aa));class oa extends c.a.Component{constructor(e,t){super(e,t),this.state={displayModal:!1}}componentDidMount(){this.props.loadUser(this.props.match.params.userName)}componentDidUpdate(e){e.match.params.userName!==this.props.match.params.userName&&this.props.loadUser(this.props.match.params.userName)}displayModal(e){this.setState((t=>Object(k.a)(Object(k.a)({},t),{},{displayModal:e})))}render(){const e=this.props,t=e.t,s=e.currentUser,r=e.onDeleteUser,o=e.users,c=this.state.displayModal,n=Object(ne.a)(o,1)[0],i=!!n&&s.username===n.username;return Object(a.jsxs)("div",{children:[c&&Object(a.jsx)(Pe,{title:t("common:Confirmation"),text:t("user:Are you sure you want to delete this account? All data will be deleted, this cannot be undone."),confirm:()=>{r(n.username),this.displayModal(!1)},close:()=>this.displayModal(!1)}),n&&Object(a.jsx)(ut,{editable:i,isDeletable:s.admin&&!i,onDeleteUser:r,displayModal:e=>this.displayModal(e),t:t,user:n})]})}}var ca=Object(w.a)()(Object(O.c)((e=>({currentUser:e.user,users:e.users.data})),(e=>({onDeleteUser:t=>{e(ye(t,!0))},loadUser:t=>{e(H("getData","users",{username:t}))}})))(oa));class na extends c.a.Component{constructor(e){super(e),this.props=e}componentDidMount(){this.props.loadAppConfig()}render(){return Object(a.jsxs)("div",{className:"App",children:[Object(a.jsx)(Ss,{}),Object(a.jsxs)(g.d,{children:[Object(a.jsx)(g.b,{exact:!0,path:"/",component:Kt}),Object(a.jsx)(g.b,{exact:!0,path:"/register",render:()=>Object(a.jsx)(ra,{formType:"register"})}),Object(a.jsx)(g.b,{exact:!0,path:"/login",render:()=>Object(a.jsx)(ra,{formType:"login"})}),Object(a.jsx)(g.b,{exact:!0,path:"/password-reset",render:()=>Object(a.jsx)(ra,{formType:"password reset"})}),Object(a.jsx)(g.b,{exact:!0,path:"/password-reset/request",render:()=>Object(a.jsx)(ra,{formType:"reset your password"})}),Object(a.jsx)(g.b,{exact:!0,path:"/password-reset/sent",render:()=>Object(a.jsx)(Bs,{action:"sent"})}),Object(a.jsx)(g.b,{exact:!0,path:"/updated-password",render:()=>Object(a.jsx)(Bs,{action:"updated"})}),Object(a.jsx)(g.b,{exact:!0,path:"/password-reset/sent",component:Bs}),Object(a.jsx)(g.b,{exact:!0,path:"/logout",component:$t}),Object(a.jsx)(g.b,{exact:!0,path:"/profile/edit",component:Ks}),Object(a.jsx)(g.b,{exact:!0,path:"/profile",component:mt}),Object(a.jsx)(g.b,{exact:!0,path:"/workouts/history",component:dt}),Object(a.jsx)(g.b,{exact:!0,path:"/workouts/statistics",component:ta}),Object(a.jsx)(g.b,{exact:!0,path:"/users/:userName",component:ca}),Object(a.jsx)(g.b,{path:"/workouts",component:rt}),Object(a.jsx)(g.b,{path:"/admin",component:oe}),Object(a.jsx)(g.b,{component:re})]}),Object(a.jsx)(Yt,{})]})}}var ia=Object(O.c)((()=>({})),(e=>({loadAppConfig:()=>{e(V("config"))}})))(na),la=s(74);function da({store:e,history:t,children:s}){return Object(a.jsx)(O.a,{store:e,children:Object(a.jsx)(la.a,{history:t,children:s})})}const ua=Boolean("localhost"===window.location.hostname||"[::1]"===window.location.hostname||window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/));function ma(e){navigator.serviceWorker.register(e).then((e=>{e.onupdatefound=()=>{const t=e.installing;t.onstatechange=()=>{"installed"===t.state&&(navigator.serviceWorker.controller?console.log("New content is available; please refresh."):console.log("Content is cached for offline use."))}}})).catch((e=>{console.error("Error during service worker registration:",e)}))}const ja={data:[]};var pa={language:"en",message:"",messages:[],user:{isAuthenticated:!1},workouts:Object(k.a)({},ja),application:{statistics:{},config:{gpx_limit_import:null,is_registration_enabled:null,max_single_file_size:null,max_users:null,max_zip_file_size:null,registration:null}},calendarWorkouts:Object(k.a)({},ja),chartData:[],gpx:null,loading:!1,records:Object(k.a)({},ja),sports:Object(k.a)({},ja),statistics:{data:{}},users:Object(k.a)({},ja)};const ha=(e,t,s)=>s.target!==t?e:"SET_DATA"===s.type?Object(k.a)(Object(k.a)({},e),{},{data:s.data[s.target]}):"SET_PAGINATED_DATA"===s.type?Object(k.a)(Object(k.a)({},e),{},{data:s.data[s.target],pagination:s.pagination}):e,ba=(e=pa.workouts,t)=>{switch(t.type){case"LOGOUT":return pa.workouts;case"PUSH_WORKOUTS":return Object(k.a)(Object(k.a)({},e),{},{data:e.data.concat(t.workouts)});case"REMOVE_WORKOUT":return Object(k.a)(Object(k.a)({},e),{},{data:e.data.filter((e=>e.id!==t.workoutId))});default:return ha(e,"workouts",t)}},xa=(e=pa.application,t)=>"SET_APP_CONFIG"===t.type?Object(k.a)(Object(k.a)({},e),{},{config:t.data}):"SET_APP_STATS"===t.type?Object(k.a)(Object(k.a)({},e),{},{statistics:t.data}):e,Oa=(e=pa.calendarWorkouts,t)=>{switch(t.type){case"LOGOUT":return pa.calendarWorkouts;case"UPDATE_CALENDAR":return Object(k.a)(Object(k.a)({},e),{},{data:t.workouts});default:return ha(e,"calendarWorkouts",t)}},ga=(e=pa.chartData,t)=>"SET_CHART_DATA"===t.type?t.chartData:e,fa=(e=pa.gpx,t)=>"SET_GPX"===t.type?t.gpxContent:e,wa=(e=pa.language,t)=>"SET_LANGUAGE"===t.type?t.language:e,va=(e=pa.loading,t)=>"SET_LOADING"===t.type?t.loading:e,ka=(e=pa.message,t)=>{switch(t.type){case"AUTH_ERROR":case"PROFILE_ERROR":case"PROFILE_UPDATE_ERROR":case"PICTURE_ERROR":case"SET_ERROR":return t.message;case"LOGOUT":case"PROFILE_SUCCESS":case"SET_RESULTS":case"@@router/LOCATION_CHANGE":return"";default:return e}},ya=(e=pa.messages,t)=>{switch(t.type){case"AUTH_ERRORS":return t.messages;case"LOGOUT":case"PROFILE_SUCCESS":case"@@router/LOCATION_CHANGE":return[];default:return e}},Na=(e=pa.records,t)=>"LOGOUT"===t.type?pa.records:ha(e,"records",t),_a=(e=pa.sports,t)=>"UPDATE_SPORT_DATA"===t.type?Object(k.a)(Object(k.a)({},e),{},{data:e.data.map((e=>(e.id===t.data.id&&(e.is_active=t.data.is_active),e)))}):ha(e,"sports",t),Sa=(e=pa.users,t)=>"UPDATE_USER_DATA"===t.type?Object(k.a)(Object(k.a)({},e),{},{data:e.data.map((e=>(e.username===t.data.username&&(e.admin=t.data.admin),e)))}):ha(e,"users",t),Da=(e=pa.user,t)=>{switch(t.type){case"AUTH_ERROR":case"PROFILE_ERROR":case"LOGOUT":return window.localStorage.removeItem("authToken"),pa.user;case"PROFILE_SUCCESS":return t.profil;default:return e}},Ca=(e=pa.statistics,t)=>"LOGOUT"===t.type?pa.statistics:ha(e,"statistics",t);const Ea=["/login","/register","/password-reset","/password-reset/request","/password-reset/sent","/updated-password"],Aa=(e,t)=>("string"===typeof e||e instanceof String?e=t:e.pathname=t,e),Ma=e=>(window.localStorage.authToken||Ea.includes(e.pathname)||(e=Aa(e,"/login")),window.localStorage.authToken&&Ea.includes(e.pathname)&&(e=Aa(e,"/")),e),Ta=((Pa=Object(r.a)()).location=Ma(Pa.location),Object(k.a)(Object(k.a)({},Pa),{},{push:(e,...t)=>Pa.push(Ma(e),...t),replace:(e,...t)=>Pa.replace(Ma(e),...t)}));var Pa;Ta.listen((()=>{window.scrollTo(0,0)}));const Fa=document.getElementById("root"),za=Object(u.e)((Ra=Ta,Object(u.c)({workouts:ba,application:xa,calendarWorkouts:Oa,chartData:ga,gpx:fa,language:wa,loading:va,message:ka,messages:ya,records:Na,router:Object(la.b)(Ra),sports:_a,statistics:Ca,user:Da,users:Sa})),window.__STATE__,(window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__||u.d)(Object(u.a)(Object(d.a)(Ta),m.a)));var Ra;null!==window.localStorage.authToken&&za.dispatch(we()),l.a.render(Object(a.jsx)(da,{store:za,history:Ta,children:Object(a.jsx)(n.a,{i18n:x,children:Object(a.jsx)(ia,{})})}),Fa),function(){if("serviceWorker"in navigator){if(new URL("",window.location).origin!==window.location.origin)return;window.addEventListener("load",(()=>{const e="".concat("","/service-worker.js");ua?function(e){fetch(e).then((t=>{404===t.status||-1===t.headers.get("content-type").indexOf("javascript")?navigator.serviceWorker.ready.then((e=>{e.unregister().then((()=>{window.location.reload()}))})):ma(e)})).catch((()=>{console.log("No internet connection found. App is running in offline mode.")}))}(e):ma(e)}))}}()}},[[458,1,2]]]); //# sourceMappingURL=main.75e5c894.chunk.js.map