\n '),e="\n \n \n ');break;case"pass":t="update",e="\n \n \n \n \n ');break;default:throw new Error("Unknown dialog type: ".concat(this.type))}return"".concat(n,'\n ")}},{key:"show",value:function(){var t=this;return new Promise(function(e){t.resolveModal(e)})}},{key:"resolveModal",value:function(t){var e=this;this.dialog.show().then(function(n){if(n.cancelled)return e.hide();if("update"===n.action||"add"===n.action){if(!e.validate())return e.resolveModal(t);n.data=e.getData()}return t(n)})}},{key:"hide",value:function(){this.dialog.hide()}},{key:"getData",value:function(){var t="add"===this.type?this.form.elements.login.value.trim():this.user.login,e=null;return"pass"===this.type&&(e=this.form.elements.oldpass.value.trim()),{login:t,password:this.form.elements.pass.value.trim(),oldPassword:e}}},{key:"validate",value:function(){if("add"===this.type){if(!this.form.elements.login.value.trim())return alert(St.strings.allrequired),!1}else if("pass"===this.type){if(!this.form.elements.oldpass.value.trim())return alert(St.strings.allrequired),!1}var t=this.form.elements.pass.value.trim(),e=this.form.elements.pass2.value.trim();return t&&e?t===e?!!At.pass_regex.test(t)||(alert(St.strings.passlenmin+"\n"+St.strings.passrules),!1):(alert(St.strings.passnotmatch),!1):(alert(St.strings.allrequired),!1)}}]),t}(),vt=function(){function t(e){(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")})(this,t),this.type=e,this.listeners=new Set}return function(t,e,n){e&&s(t.prototype,e),n&&s(t,n)}(t,[{key:"addListener",value:function(t){this.listeners.add(t)}},{key:"removeListener",value:function(t){this.listeners.delete(t)}},{key:"dispatch",value:function(t){var e=this,n=!0,i=!1,o=void 0;try{for(var r,s=function(){var n=r.value;!function(t){return function(){var e=this,n=arguments;return new Promise(function(i,o){function r(t){a(c,i,o,r,s,"next",t)}function s(t){a(c,i,o,r,s,"throw",t)}var c=t.apply(e,n);r(void 0)})}}(regeneratorRuntime.mark(function i(){return regeneratorRuntime.wrap(function(i){for(;;)switch(i.prev=i.next){case 0:return console.log("".concat(e.type,": ").concat(t?t.constructor.name:"")),i.next=3,n(e,t);case 3:case"end":return i.stop()}},i)}))()},c=this.listeners[Symbol.iterator]();!(n=(r=c.next()).done);n=!0)s()}catch(t){i=!0,o=t}finally{try{n||null==c.return||c.return()}finally{if(i)throw o}}}}],[{key:"ADD",get:function(){return"µAdd"}},{key:"API_CHANGE",get:function(){return"µApiChange"}},{key:"CHART_CLICKED",get:function(){return"µChartClicked"}},{key:"CONFIG",get:function(){return"µConfig"}},{key:"CHANGE",get:function(){return"µChange"}},{key:"CHART_READY",get:function(){return"µChartReady"}},{key:"EDIT",get:function(){return"µEdit"}},{key:"EXPORT",get:function(){return"µExport"}},{key:"IMPORT",get:function(){return"µImport"}},{key:"LOADER",get:function(){return"µLoader"}},{key:"MARKER_OVER",get:function(){return"µMarkerOver"}},{key:"MARKER_SELECT",get:function(){return"µMarkerSelect"}},{key:"OPEN_URL",get:function(){return"µOpen"}},{key:"PASSWORD",get:function(){return"µPassword"}},{key:"TRACK_READY",get:function(){return"µTrackReady"}},{key:"UI_READY",get:function(){return"µUiReady"}}]),t}(),kt=function(){function t(){(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")})(this,t),this._isAdmin=!1,this._isAuthenticated=!1,this._user=null}return function(t,e,n){e&&c(t.prototype,e),n&&c(t,n)}(t,[{key:"handleEvent",value:function(t){t.type===vt.PASSWORD&&this.isAuthenticated&&this.changePassword()}},{key:"changePassword",value:function(t){var e=this,n=t||new yt("pass",this.user);n.show().then(function(t){return e.user.changePass(t.data.password,t.data.oldPassword)}).then(function(){alert(St.strings.actionsuccess),n.hide()}).catch(function(t){alert("".concat(St.strings.actionfailure,"\n").concat(t)),e.changePassword(n)})}},{key:"user",set:function(t){this._user=t,this._isAuthenticated=!0},get:function(){return this._user}},{key:"isAdmin",set:function(){this._isAdmin=!0},get:function(){return this._isAdmin}},{key:"isAuthenticated",get:function(){return this._isAuthenticated}}]),t}(),bt=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}return function(t,e,n){e&&l(t.prototype,e),n&&l(t,n)}(t,[{key:"notify",value:function(t){this._binder&&this._binder.dispatchEvent(vt.CONFIG,t)}},{key:"binder",set:function(t){this._binder=t}},{key:"interval",get:function(){return this._interval},set:function(t){this._interval=t}},{key:"units",get:function(){return this._units},set:function(t){this._units=t}},{key:"mapapi",get:function(){return this._mapapi},set:function(t){this._mapapi=t}},{key:"gkey",get:function(){return this._gkey},set:function(t){this._gkey=t}},{key:"ol_layers",get:function(){return this._ol_layers},set:function(t){this._ol_layers=t}},{key:"init_latitude",get:function(){return this._init_latitude},set:function(t){this._init_latitude=t}},{key:"init_longitude",get:function(){return this._init_longitude},set:function(t){this._init_longitude=t}},{key:"pass_regex",get:function(){return this._pass_regex},set:function(t){this._pass_regex=t}},{key:"strokeWeight",get:function(){return this._strokeWeight},set:function(t){this._strokeWeight=t}},{key:"strokeColor",get:function(){return this._strokeColor},set:function(t){this._strokeColor=t}},{key:"strokeOpacity",get:function(){return this._strokeOpacity},set:function(t){this._strokeOpacity=t}},{key:"factor_kmh",get:function(){return this._factor_kmh},set:function(t){this._factor_kmh=t}},{key:"unit_kmh",get:function(){return this._unit_kmh},set:function(t){this._unit_kmh=t}},{key:"factor_m",get:function(){return this._factor_m},set:function(t){this._factor_m=t}},{key:"unit_m",get:function(){return this._unit_m},set:function(t){this._unit_m=t}},{key:"factor_km",get:function(){return this._factor_km},set:function(t){this._factor_km=t}},{key:"unit_km",get:function(){return this._unit_km},set:function(t){this._unit_km=t}},{key:"showLatest",get:function(){return this._showLatest},set:function(t){this._showLatest!==t&&(this._showLatest=t,this.notify("showLatest"))}}]),t}(),wt=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}return function(t,e,n){e&&u(t.prototype,e),n&&u(t,n)}(t,null,[{key:"post",value:function(t,e,n){var i=n||{};return i.method="POST",this.ajax(t,e,i)}},{key:"get",value:function(t,e,n){var i=n||{};return i.method="GET",this.ajax(t,e,i)}},{key:"ajax",value:function(t,e,n){var i=[];e=e||{};var o=(n=n||{}).method||"GET",r=new XMLHttpRequest;return new Promise(function(n,a){r.onreadystatechange=function(){if(4===r.readyState){var t="",e=!0;if(200===r.status){var i=r.responseXML;if(i){var o=i.getElementsByTagName("root");if(o.length&&"1"!==gt.getNode(o[0],"error"))n&&"function"==typeof n&&n(i),e=!1;else if(o.length){var s=gt.getNode(o[0],"message");s&&(t=s)}}}e&&a&&"function"==typeof a&&a(t)}};var s=null;if(e instanceof HTMLFormElement)s=new FormData(e),o="POST";else{for(var c in e)e.hasOwnProperty(c)&&i.push(c+"="+encodeURIComponent(e[c]));s=(s=i.join("&")).replace(/%20/g,"+")}"GET"===o&&i.length&&(t+="?"+s,s=null),r.open(o,t,!0),"POST"!==o||e instanceof HTMLFormElement||r.setRequestHeader("Content-type","application/x-www-form-urlencoded"),r.send(s)})}}]),t}(),Et=function(){function t(e,n,i,o){(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")})(this,t),this[i]=e,this[o]=n,Object.defineProperty(this,"key",{get:function(){return this[i]}}),Object.defineProperty(this,"value",{get:function(){return this[o]}})}return function(t,e,n){e&&d(t.prototype,e),n&&d(t,n)}(t,[{key:"emit",value:function(t,e){var n=e||this;this.binder.dispatchEvent(t,n)}},{key:"binder",set:function(t){this._binder=t},get:function(){return this._binder}}]),t}(),_t=function(t){function e(t,n){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),p(this,m(e).call(this,t,n,"id","login"))}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&g(t,e)}(e,Et),function(t,e,n){e&&h(t.prototype,e),n&&h(t,n)}(e,[{key:"update",value:function(t){var e=this,n=this.password;return delete this.password,wt.post("utils/handleuser.php",{action:t,login:this.login,pass:n}).then(function(n){return"add"===t&&(e.id=gt.getNodeAsInt(n,"userid")),e})}},{key:"changePass",value:function(t,e){return wt.post("utils/changepass.php",{login:this.login,pass:t,oldpass:e})}}]),e}(),Lt=new(function(){function t(){(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")})(this,t),this.auth={},this.config={},this.lang={},this.loaded||this.initialize()}return function(t,e,n){e&&y(t.prototype,e),n&&y(t,n)}(t,[{key:"initialize",value:function(){var e=t.fetch();e&&(this.initAuth(e),this.initConfig(e),this.initLang(e),this.loaded=!0)}},{key:"initAuth",value:function(t){this.auth=new kt;var e=t.getElementsByTagName("auth");if(e.length&&1===gt.getNodeAsInt(e[0],"isAuthenticated")){var n=gt.getNodeAsInt(e[0],"userId"),i=gt.getNode(e[0],"userLogin");this.auth.user=new _t(n,i),this.auth.isAdmin=1===gt.getNodeAsInt(e[0],"isAdmin")}}},{key:"initLang",value:function(t){var e=t.getElementsByTagName("lang");e.length&&(this.lang.strings=gt.getNodesArray(e[0],"strings"))}},{key:"initConfig",value:function(t){this.config=new bt;var e=t.getElementsByTagName("config");if(e.length){this.config.interval=gt.getNodeAsInt(e[0],"interval"),this.config.units=gt.getNode(e[0],"units"),this.config.mapapi=gt.getNode(e[0],"mapapi"),this.config.gkey=gt.getNode(e[0],"gkey"),this.config.ol_layers=gt.getNodesArray(e[0],"ol_layers"),this.config.init_latitude=gt.getNodeAsFloat(e[0],"init_latitude"),this.config.init_longitude=gt.getNodeAsFloat(e[0],"init_longitude");var n=gt.getNode(e[0],"pass_regex");this.config.pass_regex=new RegExp(n.substr(1,n.length-2)),this.config.strokeWeight=gt.getNodeAsInt(e[0],"strokeWeight"),this.config.strokeColor=gt.getNode(e[0],"strokeColor"),this.config.strokeOpacity=gt.getNodeAsInt(e[0],"strokeOpacity"),this.config.factor_kmh=1,this.config.unit_kmh="km/h",this.config.factor_m=1,this.config.unit_m="m",this.config.factor_km=1,this.config.unit_km="km","imperial"===this.config.units?(this.config.factor_kmh=.62,this.config.unit_kmh="mph",this.config.factor_m=3.28,this.config.unit_m="ft",this.config.factor_km=.62,this.config.unit_km="mi"):"nautical"===this.config.units&&(this.config.factor_kmh=.54,this.config.unit_kmh="kt",this.config.factor_m=1,this.config.unit_m="m",this.config.factor_km=.54,this.config.unit_km="nm"),this.config.showLatest=!1}}}],[{key:"fetch",value:function(){var t=null,e=new XMLHttpRequest;return e.open("GET","utils/getconstants.php",!1),e.send(null),200===e.status&&(t=e.responseXML),t}}]),t}()),At=Lt.config,St=Lt.lang,Ct=Lt.auth,Tt=function(){function t(e){(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")})(this,t),this.track=e;var n='
\n \n ");this.dialog=new mt(n),this.form=this.dialog.modal.querySelector("#trackForm"),this.form.onsubmit=function(){return!1}}return function(t,e,n){e&&v(t.prototype,e),n&&v(t,n)}(t,[{key:"show",value:function(){var t=this;return new Promise(function(e){t.resolveModal(e)})}},{key:"resolveModal",value:function(t){var e=this;this.dialog.show().then(function(n){if(n.cancelled)return e.hide();if("update"===n.action){if(!e.validate())return e.resolveModal(t);n.data=e.getData()}return t(n)})}},{key:"hide",value:function(){this.dialog.hide()}},{key:"getData",value:function(){return{name:this.form.elements.trackname.value.trim()}}},{key:"validate",value:function(){var t=this.form.elements.trackname.value.trim();return!(t===this.track.name||!t&&(alert(St.strings.allrequired),1))}}]),t}(),Ot=function(){function t(e,n,i){(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")})(this,t),this.data=[],this.binder=n,this._showAllOption=!1,this.hasHead=!1,this.headValue="",this.allValue="",this.T=i||Et,this.domElement=document.querySelector(e),this.binder&&(this.binder.addEventListener(vt.ADD,this),this.binder.addEventListener(vt.CHANGE,this),this.binder.addEventListener(vt.CONFIG,this),this.binder.addEventListener(vt.EDIT,this)),this.selectedId="",this.fromDom()}return function(t,e,n){e&&k(t.prototype,e),n&&k(t,n)}(t,[{key:"select",value:function(t,e){this.selectedId=t.toString(),this.render(),e||this.onChange()}},{key:"clear",value:function(){this.domElement.options.length=0,this.data.length=0,this.selectedId=""}},{key:"fromXml",value:function(t,e,n){if(t){var i=!0,o=!1,r=void 0;try{for(var a,s=t[Symbol.iterator]();!(i=(a=s.next()).done);i=!0){var c=a.value,l=new this.T(gt.getNodeAsInt(c,e),gt.getNode(c,n));this.updateDataRow(l),l.binder=this.binder,this.data.push(l)}}catch(t){o=!0,r=t}finally{try{i||null==s.return||s.return()}finally{if(o)throw r}}this.data.length&&(this.selectedId=this.data[0].key.toString()),this.render(),this.onChange()}}},{key:"fromDom",value:function(){if(this.domElement){var t=!0,e=!1,n=void 0;try{for(var i,o,r=this.domElement[Symbol.iterator]();!(t=(i=r.next()).done);t=!0){if("all"===(o=i.value).value)this._showAllOption=!0;else if(!o.disabled){var a=new this.T(parseInt(o.value),o.innerText);this.updateDataRow(a),a.binder=this.binder,this.data.push(a)}o.selected&&(this.selectedId=o.value)}}catch(t){e=!0,n=t}finally{try{t||null==r.return||r.return()}finally{if(e)throw n}}}}},{key:"handleEvent",value:function(t,e){t.type===vt.CHANGE&&e.el===this.domElement?(this.selectedId=e.id,this.onChange()):t.type===vt.EDIT&&e===this.domElement?this.onEdit():t.type===vt.ADD&&e===this.domElement?this.onAdd():t.type===vt.CONFIG&&this.onConfigChange(e)}},{key:"add",value:function(t){this.data.push(t),this.render()}},{key:"has",value:function(t){return-1!==this.data.findIndex(function(e){return e.key===t})}},{key:"remove",value:function(t){var e=this.current.key;this.data.splice(this.data.findIndex(function(e){return e.key===t}),1),t===e&&(this.selectDefault(),this.onChange()),this.render()}},{key:"selectDefault",value:function(){this.selectedId=this.data.length?this.data[0].key.toString():""}},{key:"render",value:function(){if(this.domElement.options.length=0,this.hasHead){var t=new Option(this.headValue,"0",!0,"0"===this.selectedId);t.disabled=!0,this.domElement.options.add(t)}this._showAllOption&&this.domElement.options.add(new Option(this.allValue,"all"));var e=!0,n=!1,i=void 0;try{for(var o,r,a=this.data[Symbol.iterator]();!(e=(o=a.next()).done);e=!0)r=o.value,this.domElement.options.add(new Option(r.value,r.key.toString(),!1,r.key.toString()===this.selectedId))}catch(t){n=!0,i=t}finally{try{e||null==a.return||a.return()}finally{if(n)throw i}}}},{key:"updateDataRow",value:function(){}},{key:"onChange",value:function(){}},{key:"onEdit",value:function(){}},{key:"onReload",value:function(){}},{key:"onAdd",value:function(){}},{key:"onConfigChange",value:function(){}},{key:"current",get:function(){var t=parseInt(this.selectedId);return isNaN(t)?null:this.data.find(function(e){return e.key===t})}},{key:"isSelectedAllOption",get:function(){return"all"===this.selectedId}},{key:"showAllOption",get:function(){return this._showAllOption},set:function(t){this._showAllOption!==t&&(this._showAllOption=t,!1===t&&this.selectDefault(),this.render(),this.onChange())}}]),t}(),It=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}return function(t,e,n){e&&b(t.prototype,e),n&&b(t,n)}(t,[{key:"hasComment",value:function(){return null!=this.comment&&this.comment.length}},{key:"hasImage",value:function(){return null!=this.image&&this.image.length}}],[{key:"fromXml",value:function(e){var n=new t;return n.id=gt.getAttributeAsInt(e,"id"),n.latitude=gt.getNodeAsFloat(e,"latitude"),n.longitude=gt.getNodeAsFloat(e,"longitude"),n.altitude=gt.getNodeAsInt(e,"altitude"),n.speed=gt.getNodeAsInt(e,"speed"),n.bearing=gt.getNodeAsInt(e,"bearing"),n.accuracy=gt.getNodeAsInt(e,"accuracy"),n.provider=gt.getNode(e,"provider"),n.comment=gt.getNode(e,"comment"),n.image=gt.getNode(e,"image"),n.username=gt.getNode(e,"username"),n.trackname=gt.getNode(e,"trackname"),n.trackid=gt.getNodeAsInt(e,"trackid"),n.timestamp=gt.getNodeAsInt(e,"timestamp"),n.distance=gt.getNodeAsInt(e,"distance"),n.seconds=gt.getNodeAsInt(e,"seconds"),n.totalDistance=0,n.totalSeconds=0,n}}]),t}(),Rt=function(t){function e(t,n,i){var o;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),(o=_(this,L(e).call(this,t,n,"id","name")))._user=i,o._positions=null,o._plotData=null,o._maxId=0,o._onlyLatest=!1,o._continuous=!0,o}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&A(t,e)}(e,Et),function(t,e,n){e&&E(t.prototype,e),n&&E(t,n)}(e,[{key:"clear",value:function(){this._positions=null,this._plotData=null}},{key:"fromXml",value:function(t,e){var n=[],i=[],o=0,r=0;e&&this._positions&&(n=this._positions,i=this._plotData,o=n[n.length-1].totalDistance,r=n[n.length-1].totalSeconds);var a=t.getElementsByTagName("position"),s=!0,c=!1,l=void 0;try{for(var u,d=a[Symbol.iterator]();!(s=(u=d.next()).done);s=!0){t=u.value;var f=It.fromXml(t);o+=f.distance,r+=f.seconds,f.totalDistance=o,f.totalSeconds=r,n.push(f),null!=f.altitude&&i.push({x:f.totalDistance,y:f.altitude*At.factor_m}),f.id>this._maxId&&(this._maxId=f.id)}}catch(t){c=!0,l=t}finally{try{s||null==d.return||d.return()}finally{if(c)throw l}}this._positions=n,this._plotData=i}},{key:"fetch",value:function(){var t=this,e={userid:this._user.id},n=this.hasPositions;return At.showLatest?(e.last=1,n=!1):e.trackid=this.id,this._onlyLatest===At.showLatest?e.afterid=this._maxId:(this._onlyLatest=At.showLatest,n=!1),wt.get("utils/getpositions.php",e).then(function(e){return t.fromXml(e,n),t.render(),e})}},{key:"update",value:function(t){return wt.post("utils/handletrack.php",{action:t,trackid:this.id,trackname:this.name})}},{key:"render",value:function(){this.emit(vt.TRACK_READY)}},{key:"export",value:function(t){var e="utils/export.php?type=".concat(t,"&userid=").concat(this._user.id,"&trackid=").concat(this.id);this.emit(vt.OPEN_URL,e)}},{key:"positions",get:function(){return this._positions}},{key:"user",set:function(t){this._user=t},get:function(){return this._user}},{key:"continuous",set:function(t){this._continuous=t},get:function(){return this._continuous}},{key:"onlyLatest",set:function(t){this._onlyLatest=t}},{key:"plotData",get:function(){return this._plotData}},{key:"length",get:function(){return this._positions?this._positions.length:0}},{key:"hasPositions",get:function(){return null!==this._positions}}]),e}(),Pt=function(t){function e(t,n){var i;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),i=function(t,e){return!e||"object"!==S(e)&&"function"!=typeof e?T(t):e}(this,I(e).call(this,t,n,Rt)),n&&(i.binder.addEventListener(vt.EXPORT,T(i)),i.binder.addEventListener(vt.IMPORT,T(i))),i}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&R(t,e)}(e,Ot),function(t,e,n){e&&C(t.prototype,e),n&&C(t,n)}(e,[{key:"updateDataRow",value:function(t){t.user=oe.userList.current}},{key:"handleEvent",value:function(t,n){t.type===vt.CHANGE&&(At.showLatest=!1),O(I(e.prototype),"handleEvent",this).call(this,t,n),t.type===vt.EXPORT?this.current.export(n):t.type===vt.IMPORT&&this.import(n).catch(function(t){return alert("".concat(St.strings.actionfailure,"\n").concat(t))})}},{key:"import",value:function(t){var e=this;return this.emit(!0,"import"),wt.post("utils/import.php",t).then(function(t){var n=t.getElementsByTagName("root"),i=gt.getNodeAsInt(n[0],"trackcnt");1n?void alert(gt.sprintf(St.strings.isizefailure,n)):void e.emit(vt.IMPORT,t)},this.importGpx.onclick=function(){e.inputFile.click()}),this.addUser&&(this.addUser.onclick=function(){e.emit(vt.ADD,e.userSelect)}),this.editUser&&(this.editUser.onclick=function(){e.emit(vt.EDIT,e.userSelect)}),this.editTrack&&(this.editTrack.onclick=function(){e.emit(vt.EDIT,e.trackSelect)}),this.menuClose.onclick=function(){return e.toggleSideMenu()},this.chartClose.onclick=function(){return e.hideChart()},this.emit(vt.UI_READY)}},{key:"trackReload",value:function(){t.emitDom(this.trackSelect,"change")}},{key:"userReload",value:function(){t.emitDom(this.userSelect,"change")}},{key:"toggleAutoReload",value:function(){this.isLiveOn?this.stopAutoReload():this.startAutoReload()}},{key:"startAutoReload",value:function(){var t=this;this.isLiveOn=!0,this.liveInterval=setInterval(function(){t.trackReload()},1e3*At.interval)}},{key:"stopAutoReload",value:function(){this.isLiveOn=!1,clearInterval(this.liveInterval)}},{key:"setAutoReloadTime",value:function(){var t=parseInt(prompt(St.strings.newinterval));isNaN(t)||t===At.interval||(At.interval=t,this.interval.innerHTML=At.interval.toString(),this.isLiveOn&&(this.stopAutoReload(),this.startAutoReload()),gt.setCookie("interval",At.interval,30))}},{key:"toggleSideMenu",value:function(){"»"===this.menuClose.innerHTML?(this.menu.style.width="0",this.main.style.marginRight="0",this.menuClose.style.right="0",this.menuClose.innerHTML="«"):(this.menu.style.width="165px",this.main.style.marginRight="165px",this.menuClose.style.right="165px",this.menuClose.innerHTML="»"),t.emitDom(window,"resize")}},{key:"emit",value:function(t,e){var n=e||this;this._binder.dispatchEvent(t,n)}},{key:"isChartVisible",value:function(){return"block"===this.bottom.style.display}},{key:"showChart",value:function(){this.bottom.style.display="block"}},{key:"hideChart",value:function(){this.bottom.style.display="none"}},{key:"toggleChart",value:function(){this.isChartVisible()?this.hideChart():this.showChart()}},{key:"updateSummary",value:function(t,e,n){if(At.showLatest){var i=new Date,o=new Date(1e3*t),r="";o.toDateString()!==i.toDateString()&&(r="".concat(o.getFullYear(),"-").concat("0".concat(o.getMonth()+1).slice(-2),"-").concat("0".concat(o.getDate()).slice(-2)," "));var a,s=o.toTimeString();0<=(a=s.indexOf(" "))&&(s="".concat(s.substr(0,a),' ').concat(s.substr(a+1),"")),this.summary.innerHTML='\n
\n '),e="\n \n \n ');break;case"pass":t="update",e="\n \n \n \n \n ');break;default:throw new Error("Unknown dialog type: ".concat(this.type))}return"".concat(n,'\n ")}},{key:"show",value:function(){var t=this;return new Promise(function(e){t.resolveModal(e)})}},{key:"resolveModal",value:function(t){var e=this;this.dialog.show().then(function(n){if(n.cancelled)return e.hide();if("update"===n.action||"add"===n.action){if(!e.validate())return e.resolveModal(t);n.data=e.getData()}return t(n)})}},{key:"hide",value:function(){this.dialog.hide()}},{key:"getData",value:function(){var t="add"===this.type?this.form.elements.login.value.trim():this.user.login,e=null;return"pass"===this.type&&(e=this.form.elements.oldpass.value.trim()),{login:t,password:this.form.elements.pass.value.trim(),oldPassword:e}}},{key:"validate",value:function(){if("add"===this.type){if(!this.form.elements.login.value.trim())return alert(St.strings.allrequired),!1}else if("pass"===this.type){if(!this.form.elements.oldpass.value.trim())return alert(St.strings.allrequired),!1}var t=this.form.elements.pass.value.trim(),e=this.form.elements.pass2.value.trim();return t&&e?t===e?!!At.pass_regex.test(t)||(alert(St.strings.passlenmin+"\n"+St.strings.passrules),!1):(alert(St.strings.passnotmatch),!1):(alert(St.strings.allrequired),!1)}}]),t}(),vt=function(){function t(e){(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")})(this,t),this.type=e,this.listeners=new Set}return function(t,e,n){e&&s(t.prototype,e),n&&s(t,n)}(t,[{key:"addListener",value:function(t){this.listeners.add(t)}},{key:"removeListener",value:function(t){this.listeners.delete(t)}},{key:"dispatch",value:function(t){var e=this,n=!0,i=!1,o=void 0;try{for(var r,s=function(){var n=r.value;!function(t){return function(){var e=this,n=arguments;return new Promise(function(i,o){function r(t){a(c,i,o,r,s,"next",t)}function s(t){a(c,i,o,r,s,"throw",t)}var c=t.apply(e,n);r(void 0)})}}(regeneratorRuntime.mark(function i(){return regeneratorRuntime.wrap(function(i){for(;;)switch(i.prev=i.next){case 0:return console.log("".concat(e.type,": ").concat(t?t.constructor.name:"")),i.next=3,n(e,t);case 3:case"end":return i.stop()}},i)}))()},c=this.listeners[Symbol.iterator]();!(n=(r=c.next()).done);n=!0)s()}catch(t){i=!0,o=t}finally{try{n||null==c.return||c.return()}finally{if(i)throw o}}}}],[{key:"ADD",get:function(){return"µAdd"}},{key:"API_CHANGE",get:function(){return"µApiChange"}},{key:"CHART_CLICKED",get:function(){return"µChartClicked"}},{key:"CONFIG",get:function(){return"µConfig"}},{key:"CHANGE",get:function(){return"µChange"}},{key:"CHART_READY",get:function(){return"µChartReady"}},{key:"EDIT",get:function(){return"µEdit"}},{key:"EXPORT",get:function(){return"µExport"}},{key:"IMPORT",get:function(){return"µImport"}},{key:"LOADER",get:function(){return"µLoader"}},{key:"MARKER_OVER",get:function(){return"µMarkerOver"}},{key:"MARKER_SELECT",get:function(){return"µMarkerSelect"}},{key:"OPEN_URL",get:function(){return"µOpen"}},{key:"PASSWORD",get:function(){return"µPassword"}},{key:"TRACK_READY",get:function(){return"µTrackReady"}},{key:"UI_READY",get:function(){return"µUiReady"}}]),t}(),kt=function(){function t(){(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")})(this,t),this._isAdmin=!1,this._isAuthenticated=!1,this._user=null}return function(t,e,n){e&&c(t.prototype,e),n&&c(t,n)}(t,[{key:"handleEvent",value:function(t){t.type===vt.PASSWORD&&this.isAuthenticated&&this.changePassword()}},{key:"changePassword",value:function(t){var e=this,n=t||new yt("pass",this.user);n.show().then(function(t){return e.user.changePass(t.data.password,t.data.oldPassword)}).then(function(){alert(St.strings.actionsuccess),n.hide()}).catch(function(t){alert("".concat(St.strings.actionfailure,"\n").concat(t)),e.changePassword(n)})}},{key:"user",set:function(t){this._user=t,this._isAuthenticated=!0},get:function(){return this._user}},{key:"isAdmin",set:function(){this._isAdmin=!0},get:function(){return this._isAdmin}},{key:"isAuthenticated",get:function(){return this._isAuthenticated}}]),t}(),bt=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}return function(t,e,n){e&&l(t.prototype,e),n&&l(t,n)}(t,[{key:"notify",value:function(t){this._binder&&this._binder.dispatchEvent(vt.CONFIG,t)}},{key:"binder",set:function(t){this._binder=t}},{key:"interval",get:function(){return this._interval},set:function(t){this._interval=t}},{key:"units",get:function(){return this._units},set:function(t){this._units=t}},{key:"mapapi",get:function(){return this._mapapi},set:function(t){this._mapapi=t}},{key:"gkey",get:function(){return this._gkey},set:function(t){this._gkey=t}},{key:"ol_layers",get:function(){return this._ol_layers},set:function(t){this._ol_layers=t}},{key:"init_latitude",get:function(){return this._init_latitude},set:function(t){this._init_latitude=t}},{key:"init_longitude",get:function(){return this._init_longitude},set:function(t){this._init_longitude=t}},{key:"pass_regex",get:function(){return this._pass_regex},set:function(t){this._pass_regex=t}},{key:"strokeWeight",get:function(){return this._strokeWeight},set:function(t){this._strokeWeight=t}},{key:"strokeColor",get:function(){return this._strokeColor},set:function(t){this._strokeColor=t}},{key:"strokeOpacity",get:function(){return this._strokeOpacity},set:function(t){this._strokeOpacity=t}},{key:"factor_kmh",get:function(){return this._factor_kmh},set:function(t){this._factor_kmh=t}},{key:"unit_kmh",get:function(){return this._unit_kmh},set:function(t){this._unit_kmh=t}},{key:"factor_m",get:function(){return this._factor_m},set:function(t){this._factor_m=t}},{key:"unit_m",get:function(){return this._unit_m},set:function(t){this._unit_m=t}},{key:"factor_km",get:function(){return this._factor_km},set:function(t){this._factor_km=t}},{key:"unit_km",get:function(){return this._unit_km},set:function(t){this._unit_km=t}},{key:"showLatest",get:function(){return this._showLatest},set:function(t){this._showLatest!==t&&(this._showLatest=t,this.notify("showLatest"))}}]),t}(),wt=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}return function(t,e,n){e&&u(t.prototype,e),n&&u(t,n)}(t,null,[{key:"post",value:function(t,e,n){var i=n||{};return i.method="POST",this.ajax(t,e,i)}},{key:"get",value:function(t,e,n){var i=n||{};return i.method="GET",this.ajax(t,e,i)}},{key:"ajax",value:function(t,e,n){var i=[];e=e||{};var o=(n=n||{}).method||"GET",r=new XMLHttpRequest;return new Promise(function(n,a){r.onreadystatechange=function(){if(4===r.readyState){var t="",e=!0;if(200===r.status){var i=r.responseXML;if(i){var o=i.getElementsByTagName("root");if(o.length&&"1"!==gt.getNode(o[0],"error"))n&&"function"==typeof n&&n(i),e=!1;else if(o.length){var s=gt.getNode(o[0],"message");s&&(t=s)}}}e&&a&&"function"==typeof a&&a(t)}};var s=null;if(e instanceof HTMLFormElement)s=new FormData(e),o="POST";else{for(var c in e)e.hasOwnProperty(c)&&i.push(c+"="+encodeURIComponent(e[c]));s=(s=i.join("&")).replace(/%20/g,"+")}"GET"===o&&i.length&&(t+="?"+s,s=null),r.open(o,t,!0),"POST"!==o||e instanceof HTMLFormElement||r.setRequestHeader("Content-type","application/x-www-form-urlencoded"),r.send(s)})}}]),t}(),Et=function(){function t(e,n,i,o){(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")})(this,t),this[i]=e,this[o]=n,Object.defineProperty(this,"key",{get:function(){return this[i]}}),Object.defineProperty(this,"value",{get:function(){return this[o]}})}return function(t,e,n){e&&d(t.prototype,e),n&&d(t,n)}(t,[{key:"emit",value:function(t,e){var n=e||this;this.binder.dispatchEvent(t,n)}},{key:"binder",set:function(t){this._binder=t},get:function(){return this._binder}}]),t}(),_t=function(t){function e(t,n){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),p(this,m(e).call(this,t,n,"id","login"))}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&g(t,e)}(e,Et),function(t,e,n){e&&h(t.prototype,e),n&&h(t,n)}(e,[{key:"update",value:function(t){var e=this,n=this.password;return delete this.password,wt.post("utils/handleuser.php",{action:t,login:this.login,pass:n}).then(function(n){return"add"===t&&(e.id=gt.getNodeAsInt(n,"userid")),e})}},{key:"changePass",value:function(t,e){return wt.post("utils/changepass.php",{login:this.login,pass:t,oldpass:e})}}]),e}(),Lt=new(function(){function t(){(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")})(this,t),this.auth={},this.config={},this.lang={},this.loaded||this.initialize()}return function(t,e,n){e&&y(t.prototype,e),n&&y(t,n)}(t,[{key:"initialize",value:function(){var e=t.fetch();e&&(this.initAuth(e),this.initConfig(e),this.initLang(e),this.loaded=!0)}},{key:"initAuth",value:function(t){this.auth=new kt;var e=t.getElementsByTagName("auth");if(e.length&&1===gt.getNodeAsInt(e[0],"isAuthenticated")){var n=gt.getNodeAsInt(e[0],"userId"),i=gt.getNode(e[0],"userLogin");this.auth.user=new _t(n,i),this.auth.isAdmin=1===gt.getNodeAsInt(e[0],"isAdmin")}}},{key:"initLang",value:function(t){var e=t.getElementsByTagName("lang");e.length&&(this.lang.strings=gt.getNodesArray(e[0],"strings"))}},{key:"initConfig",value:function(t){this.config=new bt;var e=t.getElementsByTagName("config");if(e.length){this.config.interval=gt.getNodeAsInt(e[0],"interval"),this.config.units=gt.getNode(e[0],"units"),this.config.mapapi=gt.getNode(e[0],"mapapi"),this.config.gkey=gt.getNode(e[0],"gkey"),this.config.ol_layers=gt.getNodesArray(e[0],"ol_layers"),this.config.init_latitude=gt.getNodeAsFloat(e[0],"init_latitude"),this.config.init_longitude=gt.getNodeAsFloat(e[0],"init_longitude");var n=gt.getNode(e[0],"pass_regex");this.config.pass_regex=new RegExp(n.substr(1,n.length-2)),this.config.strokeWeight=gt.getNodeAsInt(e[0],"strokeWeight"),this.config.strokeColor=gt.getNode(e[0],"strokeColor"),this.config.strokeOpacity=gt.getNodeAsInt(e[0],"strokeOpacity"),this.config.factor_kmh=1,this.config.unit_kmh="km/h",this.config.factor_m=1,this.config.unit_m="m",this.config.factor_km=1,this.config.unit_km="km","imperial"===this.config.units?(this.config.factor_kmh=.62,this.config.unit_kmh="mph",this.config.factor_m=3.28,this.config.unit_m="ft",this.config.factor_km=.62,this.config.unit_km="mi"):"nautical"===this.config.units&&(this.config.factor_kmh=.54,this.config.unit_kmh="kt",this.config.factor_m=1,this.config.unit_m="m",this.config.factor_km=.54,this.config.unit_km="nm"),this.config.showLatest=!1}}}],[{key:"fetch",value:function(){var t=null,e=new XMLHttpRequest;return e.open("GET","utils/getconstants.php",!1),e.send(null),200===e.status&&(t=e.responseXML),t}}]),t}()),At=Lt.config,St=Lt.lang,Ct=Lt.auth,Tt=function(){function t(e){(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")})(this,t),this.track=e;var n='
\n \n ");this.dialog=new mt(n),this.form=this.dialog.modal.querySelector("#trackForm"),this.form.onsubmit=function(){return!1}}return function(t,e,n){e&&v(t.prototype,e),n&&v(t,n)}(t,[{key:"show",value:function(){var t=this;return new Promise(function(e){t.resolveModal(e)})}},{key:"resolveModal",value:function(t){var e=this;this.dialog.show().then(function(n){if(n.cancelled)return e.hide();if("update"===n.action){if(!e.validate())return e.resolveModal(t);n.data=e.getData()}return t(n)})}},{key:"hide",value:function(){this.dialog.hide()}},{key:"getData",value:function(){return{name:this.form.elements.trackname.value.trim()}}},{key:"validate",value:function(){var t=this.form.elements.trackname.value.trim();return!(t===this.track.name||!t&&(alert(St.strings.allrequired),1))}}]),t}(),Ot=function(){function t(e,n,i){(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")})(this,t),this.data=[],this.binder=n,this._showAllOption=!1,this.hasHead=!1,this.headValue="",this.allValue="",this.T=i||Et,this.domElement=document.querySelector(e),this.binder&&(this.binder.addEventListener(vt.ADD,this),this.binder.addEventListener(vt.CHANGE,this),this.binder.addEventListener(vt.CONFIG,this),this.binder.addEventListener(vt.EDIT,this)),this.selectedId="",this.fromDom()}return function(t,e,n){e&&k(t.prototype,e),n&&k(t,n)}(t,[{key:"select",value:function(t,e){this.selectedId=t.toString(),this.render(),e||this.onChange()}},{key:"clear",value:function(){this.domElement.options.length=0,this.data.length=0,this.selectedId=""}},{key:"fromXml",value:function(t,e,n){if(t){var i=!0,o=!1,r=void 0;try{for(var a,s=t[Symbol.iterator]();!(i=(a=s.next()).done);i=!0){var c=a.value,l=new this.T(gt.getNodeAsInt(c,e),gt.getNode(c,n));this.updateDataRow(l),l.binder=this.binder,this.data.push(l)}}catch(t){o=!0,r=t}finally{try{i||null==s.return||s.return()}finally{if(o)throw r}}this.data.length&&(this.selectedId=this.data[0].key.toString()),this.render(),this.onChange()}}},{key:"fromDom",value:function(){if(this.domElement){var t=!0,e=!1,n=void 0;try{for(var i,o,r=this.domElement[Symbol.iterator]();!(t=(i=r.next()).done);t=!0){if("all"===(o=i.value).value)this._showAllOption=!0;else if(!o.disabled){var a=new this.T(parseInt(o.value),o.innerText);this.updateDataRow(a),a.binder=this.binder,this.data.push(a)}o.selected&&(this.selectedId=o.value)}}catch(t){e=!0,n=t}finally{try{t||null==r.return||r.return()}finally{if(e)throw n}}}}},{key:"handleEvent",value:function(t,e){t.type===vt.CHANGE&&e.el===this.domElement?(this.selectedId=e.id,this.onChange()):t.type===vt.EDIT&&e===this.domElement?this.onEdit():t.type===vt.ADD&&e===this.domElement?this.onAdd():t.type===vt.CONFIG&&this.onConfigChange(e)}},{key:"add",value:function(t){this.data.push(t),this.render()}},{key:"has",value:function(t){return-1!==this.data.findIndex(function(e){return e.key===t})}},{key:"remove",value:function(t){var e=this.current.key;this.data.splice(this.data.findIndex(function(e){return e.key===t}),1),t===e&&(this.selectDefault(),this.onChange()),this.render()}},{key:"selectDefault",value:function(){this.selectedId=this.data.length?this.data[0].key.toString():""}},{key:"render",value:function(){if(this.domElement.options.length=0,this.hasHead){var t=new Option(this.headValue,"0",!0,"0"===this.selectedId);t.disabled=!0,this.domElement.options.add(t)}this._showAllOption&&this.domElement.options.add(new Option(this.allValue,"all"));var e=!0,n=!1,i=void 0;try{for(var o,r,a=this.data[Symbol.iterator]();!(e=(o=a.next()).done);e=!0)r=o.value,this.domElement.options.add(new Option(r.value,r.key.toString(),!1,r.key.toString()===this.selectedId))}catch(t){n=!0,i=t}finally{try{e||null==a.return||a.return()}finally{if(n)throw i}}}},{key:"updateDataRow",value:function(){}},{key:"onChange",value:function(){}},{key:"onEdit",value:function(){}},{key:"onReload",value:function(){}},{key:"onAdd",value:function(){}},{key:"onConfigChange",value:function(){}},{key:"current",get:function(){var t=parseInt(this.selectedId);return isNaN(t)?null:this.data.find(function(e){return e.key===t})}},{key:"isSelectedAllOption",get:function(){return"all"===this.selectedId}},{key:"showAllOption",get:function(){return this._showAllOption},set:function(t){this._showAllOption!==t&&(this._showAllOption=t,!1===t&&this.selectDefault(),this.render(),this.onChange())}}]),t}(),It=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}return function(t,e,n){e&&b(t.prototype,e),n&&b(t,n)}(t,[{key:"hasComment",value:function(){return null!=this.comment&&this.comment.length}},{key:"hasImage",value:function(){return null!=this.image&&this.image.length}}],[{key:"fromXml",value:function(e){var n=new t;return n.id=gt.getAttributeAsInt(e,"id"),n.latitude=gt.getNodeAsFloat(e,"latitude"),n.longitude=gt.getNodeAsFloat(e,"longitude"),n.altitude=gt.getNodeAsInt(e,"altitude"),n.speed=gt.getNodeAsInt(e,"speed"),n.bearing=gt.getNodeAsInt(e,"bearing"),n.accuracy=gt.getNodeAsInt(e,"accuracy"),n.provider=gt.getNode(e,"provider"),n.comment=gt.getNode(e,"comment"),n.image=gt.getNode(e,"image"),n.username=gt.getNode(e,"username"),n.trackname=gt.getNode(e,"trackname"),n.trackid=gt.getNodeAsInt(e,"trackid"),n.timestamp=gt.getNodeAsInt(e,"timestamp"),n.distance=gt.getNodeAsInt(e,"distance"),n.seconds=gt.getNodeAsInt(e,"seconds"),n.totalDistance=0,n.totalSeconds=0,n}}]),t}(),Rt=function(t){function e(t,n,i){var o;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),(o=_(this,L(e).call(this,t,n,"id","name")))._user=i,o._positions=null,o._plotData=null,o._maxId=0,o._onlyLatest=!1,o._continuous=!0,o}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&A(t,e)}(e,Et),function(t,e,n){e&&E(t.prototype,e),n&&E(t,n)}(e,[{key:"clear",value:function(){this._positions=null,this._plotData=null}},{key:"fromXml",value:function(t,e){var n=[],i=[],o=0,r=0;e&&this._positions&&(n=this._positions,i=this._plotData,o=n[n.length-1].totalDistance,r=n[n.length-1].totalSeconds);var a=t.getElementsByTagName("position"),s=!0,c=!1,l=void 0;try{for(var u,d=a[Symbol.iterator]();!(s=(u=d.next()).done);s=!0){t=u.value;var f=It.fromXml(t);o+=f.distance,r+=f.seconds,f.totalDistance=o,f.totalSeconds=r,n.push(f),null!=f.altitude&&i.push({x:f.totalDistance,y:f.altitude*At.factor_m}),f.id>this._maxId&&(this._maxId=f.id)}}catch(t){c=!0,l=t}finally{try{s||null==d.return||d.return()}finally{if(c)throw l}}this._positions=n,this._plotData=i}},{key:"fetch",value:function(){var t=this,e={userid:this._user.id},n=this.hasPositions;return At.showLatest?(e.last=1,n=!1):e.trackid=this.id,this._onlyLatest===At.showLatest?e.afterid=this._maxId:(this._onlyLatest=At.showLatest,n=!1),wt.get("utils/getpositions.php",e).then(function(e){return t.fromXml(e,n),t.render(),e})}},{key:"update",value:function(t){return wt.post("utils/handletrack.php",{action:t,trackid:this.id,trackname:this.name})}},{key:"render",value:function(){this.emit(vt.TRACK_READY)}},{key:"export",value:function(t){var e="utils/export.php?type=".concat(t,"&userid=").concat(this._user.id,"&trackid=").concat(this.id);this.emit(vt.OPEN_URL,e)}},{key:"positions",get:function(){return this._positions}},{key:"user",set:function(t){this._user=t},get:function(){return this._user}},{key:"continuous",set:function(t){this._continuous=t},get:function(){return this._continuous}},{key:"onlyLatest",set:function(t){this._onlyLatest=t}},{key:"plotData",get:function(){return this._plotData}},{key:"length",get:function(){return this._positions?this._positions.length:0}},{key:"hasPositions",get:function(){return null!==this._positions}}]),e}(),Pt=function(t){function e(t,n){var i;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),i=function(t,e){return!e||"object"!==S(e)&&"function"!=typeof e?T(t):e}(this,I(e).call(this,t,n,Rt)),n&&(i.binder.addEventListener(vt.EXPORT,T(i)),i.binder.addEventListener(vt.IMPORT,T(i))),i}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&R(t,e)}(e,Ot),function(t,e,n){e&&C(t.prototype,e),n&&C(t,n)}(e,[{key:"updateDataRow",value:function(t){t.user=oe.userList.current}},{key:"handleEvent",value:function(t,n){t.type===vt.CHANGE&&(At.showLatest=!1),O(I(e.prototype),"handleEvent",this).call(this,t,n),t.type===vt.EXPORT?this.current.export(n):t.type===vt.IMPORT&&this.import(n).catch(function(t){return alert("".concat(St.strings.actionfailure,"\n").concat(t))})}},{key:"import",value:function(t){var e=this;return this.emit(!0,"import"),wt.post("utils/import.php",t).then(function(t){var n=t.getElementsByTagName("root"),i=gt.getNodeAsInt(n[0],"trackcnt");1n?void alert(gt.sprintf(St.strings.isizefailure,n)):void e.emit(vt.IMPORT,t)},this.importGpx.onclick=function(){e.inputFile.click()}),this.addUser&&(this.addUser.onclick=function(){e.emit(vt.ADD,e.userSelect)}),this.editUser&&(this.editUser.onclick=function(){e.emit(vt.EDIT,e.userSelect)}),this.editTrack&&(this.editTrack.onclick=function(){e.emit(vt.EDIT,e.trackSelect)}),this.menuClose.onclick=function(){return e.toggleSideMenu()},this.chartClose.onclick=function(){return e.hideChart()},this.emit(vt.UI_READY)}},{key:"trackReload",value:function(){t.emitDom(this.trackSelect,"change")}},{key:"userReload",value:function(){t.emitDom(this.userSelect,"change")}},{key:"toggleAutoReload",value:function(){this.isLiveOn?this.stopAutoReload():this.startAutoReload()}},{key:"startAutoReload",value:function(){var t=this;this.isLiveOn=!0,this.liveInterval=setInterval(function(){t.trackReload()},1e3*At.interval)}},{key:"stopAutoReload",value:function(){this.isLiveOn=!1,clearInterval(this.liveInterval)}},{key:"setAutoReloadTime",value:function(){var t=parseInt(prompt(St.strings.newinterval));isNaN(t)||t===At.interval||(At.interval=t,this.interval.innerHTML=At.interval.toString(),this.isLiveOn&&(this.stopAutoReload(),this.startAutoReload()),gt.setCookie("interval",At.interval,30))}},{key:"toggleSideMenu",value:function(){"»"===this.menuClose.innerHTML?(this.menu.style.width="0",this.main.style.marginRight="0",this.menuClose.style.right="0",this.menuClose.innerHTML="«"):(this.menu.style.width="165px",this.main.style.marginRight="165px",this.menuClose.style.right="165px",this.menuClose.innerHTML="»"),t.emitDom(window,"resize")}},{key:"emit",value:function(t,e){var n=e||this;this._binder.dispatchEvent(t,n)}},{key:"isChartVisible",value:function(){return"block"===this.bottom.style.display}},{key:"showChart",value:function(){this.bottom.style.display="block"}},{key:"hideChart",value:function(){this.bottom.style.display="none"}},{key:"toggleChart",value:function(){this.isChartVisible()?this.hideChart():this.showChart()}},{key:"updateSummary",value:function(t,e,n){if(At.showLatest){var i=new Date,o=new Date(1e3*t),r="";o.toDateString()!==i.toDateString()&&(r="".concat(o.getFullYear(),"-").concat("0".concat(o.getMonth()+1).slice(-2),"-").concat("0".concat(o.getDate()).slice(-2)," "));var a,s=o.toTimeString();0<=(a=s.indexOf(" "))&&(s="".concat(s.substr(0,a),' ').concat(s.substr(a+1),"")),this.summary.innerHTML='\n
"+St.strings.gmapilink,Dt.resolveModal(t)},window.gm_loaded=function(){Xt=!0};var Wt=null,Zt=null,Jt=null,Qt=null,$t=null,te={},ee="openlayers",ne=null,ie=function(){function t(e){(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")})(this,t),e.addEventListener(vt.API_CHANGE,this),e.addEventListener(vt.CHART_CLICKED,this),e.addEventListener(vt.TRACK_READY,this),e.addEventListener(vt.UI_READY,this),this.loadTime=0,this.savedBounds=null,this.api=null,this.mapElement=null,this.lastTrackId=null,this._binder=e,this.track=null}return function(t,e,n){e&&ut(t.prototype,e),n&&ut(t,n)}(t,[{key:"loadMapAPI",value:function(t){if(t){At.mapapi=t;try{this.savedBounds=this.api.getBounds()}catch(t){this.savedBounds=null}this.api.cleanup()}this.api="gmaps"===At.mapapi?ht:pt,this.waitAndInit()}},{key:"waitAndInit",value:function(){var t=this;if(1e4