@raruto/leaflet-elevation 1.8.1 → 1.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
!function(t){"function"==typeof define&&define.amd?define(t):t()}((function(){"use strict";function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(e)}function e(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function i(t){for(var a=arguments.length,n=new Array(a>1?a-1:0),r=1;r<a;r++)n[r-1]=arguments[r];if(!n.length)return t;var o=n.shift();if(l(t)&&l(o))for(var s in o)l(o[s])?(t[s]||Object.assign(t,e({},s,{})),i(t[s],o[s])):Object.assign(t,e({},s,o[s]));return i.apply(void 0,[t].concat(n))}!function(t,e){"function"==typeof define&&define.amd?define(["leaflet"],t):"object"==typeof exports&&(module.exports=t(require("leaflet"))),void 0!==e&&e.L&&t(e.L)}((function(t){return t.locales={},t.locale=null,t.registerLocale=function(e,i){t.locales[e]=t.Util.extend({},t.locales[e],i)},t.setLocale=function(e){t.locale=e},t.i18n=t._=function(e,i){t.locale&&t.locales[t.locale]&&t.locales[t.locale][e]&&(e=t.locales[t.locale][e]);try{e=t.Util.template(e,i)}catch(t){}return e}}),window);var a=6e4,n=60*a,r=24*n;function o(t){var e=Math.floor(t/r),i=Math.floor((t-e*r)/n),o=Math.floor((t-e*r-i*n)/a),s=Math.round((t-e*r-i*n-o*a)/1e3);return 60===s&&(o++,s=0),60===o&&(i++,o=0),24===i&&(e++,i=0),(e?e+"d ":"")+i.toString().padStart(2,0)+":"+o.toString().padStart(2,0)+"'"+s.toString().padStart(2,0)+'"'}function s(e,i){"string"==typeof e&&(e=JSON.parse(e));var a=!0===(i=i||this).options.distanceMarkers?{lazy:!0}:L.extend({lazy:!0},i.options.distanceMarkers),n=i.options,r=n.wptIcons,o=n.wptLabels,s=L.geoJson(e,{distanceMarkers:a,style:function(t){var e=L.extend({},i.options.polyline);return i.options.theme&&(e.className+=" "+i.options.theme),e},pointToLayer:function(t,e){var a,n,s;if(i.options.waypoints){var l=t.properties,h=null!==(a=l.desc)&&void 0!==a?a:"",c=null!==(n=l.name)&&void 0!==n?n:"",d=(null!==(s=l.sym)&&void 0!==s?s:c).replace(" ","-").replace('"',"").replace("'","").toLowerCase();if([!0,"dots"].includes(i.options.waypoints)&&i._registerCheckPoint({latlng:e,label:[!0,"dots"].includes(o)?c:""},!0),[!0,"markers"].includes(i.options.waypoints)&&0!=r){r.hasOwnProperty(d)||(r[d]=L.divIcon(L.extend({},r[""].options,{html:'<i class="elevation-waypoint-icon '+d+'"></i>'})));var u=L.marker(e,{icon:r[d]});return[!0,"markers"].includes(o)&&(c||h)&&u.bindPopup("<b>"+c+"</b>"+(h.length>0?"<br>"+h:"")).openPopup(),i._addMarker(u),i.fire("waypoint_added",{point:u,element:e,properties:l}),u}}},onEachFeature:function(n,r){n.geometry&&"Point"==n.geometry.type||(r._latlngs.forEach((function(e,i,a){if(e.meta={time:null,ele:null,hr:null,cad:null,atemp:null},"alt"in e&&(e.meta.ele=e.alt),n.properties){var r=n.properties;"coordTimes"in r?e.meta.time=new Date(Date.parse(r.coordTimes[i])):"times"in r?e.meta.time=new Date(Date.parse(r.times[i])):"time"in r&&(e.meta.time=new Date(Date.parse("object"===t(r.time)?r.time[i]:r.time))),"heartRates"in r?e.meta.hr=parseInt(r.heartRates[i]):"heartRate"in r&&(e.meta.hr=parseInt("object"===t(r.heartRate)?r.heartRate[i]:r.heartRate))}})),i.addData(r),i.options.distanceMarkers&&a.lazy&&r.on("add remove",(function(t){var e=t.target;L.DistanceMarkers&&e instanceof L.Polyline&&e[t.type+"DistanceMarkers"]()})),i.track_info=L.extend({},i.track_info,{type:"geojson",name:e.name}))}});return L.Control.Elevation._d3LazyLoader.then((function(){i._fireEvt("eledata_loaded",{data:e,layer:s,name:i.track_info.name,track_info:i.track_info})})),s}function l(e){return e&&"object"===t(e)&&!Array.isArray(e)}function h(e,i){if(i=void 0===i||i,"string"==typeof e&&i)return 0==(e=e.trim()).indexOf("{")||0==e.indexOf("[");try{JSON.parse(e.toString())}catch(a){return!("object"!==t(e)||!i)||(console.warn(a),!1)}return!0}function c(t,e){if(e=void 0===e||e,"string"==typeof t&&e)return 0==(t=t.trim()).indexOf("<");var i=(t?t.ownerDocument||t:0).documentElement;return!!i&&"HTML"!==i.nodeName}function d(t,e){var i=w("a","",{href:t,target:"_new",download:e||"",style:"display:none;"}),a=document.body;a.appendChild(i),i.click(),a.removeChild(i)}function u(t,e,i){return!1===e?Promise.resolve():i instanceof Promise?i:new Promise((function(e,i){var a=document.createElement("script");a.addEventListener("load",e,{once:!0}),a.src=t,document.head.appendChild(a)}))}function p(e,i){if(!i.options.lazyLoadJS)return Promise.resolve();var a=L.Control.Elevation,n="",r=!1;switch(e){case i.__D3:n="_d3LazyLoader",r="object"!==("undefined"==typeof d3?"undefined":t(d3));break;case i.__TOGEOJSON:n="_togeojsonLazyLoader",r="object"!==("undefined"==typeof toGeoJSON?"undefined":t(toGeoJSON));break;case i.__LGEOMUTIL:n="_geomutilLazyLoader",r="object"!==t(L.GeometryUtil);case i.__LALMOSTOVER:n="_almostoverLazyLoader",r="function "!=typeof L.Handler.AlmostOver;break;case i.__LDISTANCEM:n="_distanceMarkersLazyLoader",r="function"!=typeof L.DistanceMarkers}return a[n]=u(e,r,a[n])}function _(t,e){e.classed("canvas-path",!0),t.beginPath(),t.moveTo(0,0);var i=new Path2D(e.attr("d"));t.strokeStyle=e.attr("stroke"),t.fillStyle=e.attr("fill"),t.lineWidth=1.25,t.globalCompositeOperation="source-over",t.globalAlpha=e.attr("stroke-opacity")||.3,t.stroke(i),t.globalAlpha=e.attr("fill-opacity")||.45,t.fill(i),t.globalAlpha=1,t.closePath()}function m(t,e){return e?t<e[0]?e[0]:t>e[1]?e[1]:t:t}function f(t,e){t&&e.split(" ").every((function(e){return e&&L.DomUtil.addClass(t,e)}))}function g(t,e){t&&e.split(" ").every((function(e){return e&&L.DomUtil.removeClass(t,e)}))}function v(t,e,i){return(i?f:g).call(null,t,e)}function y(t,e,i){e&&g(t,e),i&&f(t,i)}function x(t,e,i){return void 0===i?L.DomUtil.getStyle(t,e):t.style.setProperty(e,i)}function b(t,e,i,a){return x(t,e,a?i:"")}function k(t,e,i,a){return t[a?"on":"off"](e,i)}function w(t,e,i,a){var n=L.DomUtil.create(t,e||"");return i&&A(n,i),a&&C(a,n),n}function C(t,e){return t.appendChild(e)}function M(t,e,i){return t.insertAdjacentElement(i,e)}function A(t,e){for(var i in e)t.setAttribute(i,e[i])}function S(t,e){return(e||document).querySelector(t)}var z=L.DomEvent.on,E=L.DomEvent.off,D=L.DomUtil.hasClass;function T(){return Math.random().toString(36).substr(2,9)}function F(t,e){for(var i in t)e(t[i],i)}var O,I=Object.freeze({__proto__:null,deepMerge:i,formatTime:o,GeoJSONLoader:s,isObject:l,isJSONDoc:h,isXMLDoc:c,saveFile:d,lazyLoader:u,lazyLoad:p,drawCanvas:_,clamp:m,addClass:f,removeClass:g,toggleClass:v,replaceClass:y,style:x,toggleStyle:b,toggleEvent:k,create:w,append:C,insert:M,setAttributes:A,select:S,on:z,off:E,hasClass:D,randomId:T,each:F}),N={lightblue:{area:"#3366CC",alpha:.45,stroke:"#3366CC"},magenta:{area:"#FF005E"},yellow:{area:"#FF0"},purple:{area:"#732C7B"},steelblue:{area:"#4682B4"},red:{area:"#F00"},lime:{area:"#9CC222",line:"#566B13"}},P=function(t){t.width;var e=t.height,i=t.xAttr,a=t.yAttr,n=t.scaleX,r=t.scaleY,o=t.interpolation,s=void 0===o?"curveLinear":o;return d3.area().curve("string"==typeof s?d3[s]:s).x((function(t){return t.xDiagCoord=n(t[i])})).y0(e).y1((function(t){return r(t[a])}))},B=function(t){var e=t.name,i=t.color,a=t.strokeColor,n=t.strokeOpacity,r=t.fillOpacity,o=d3.create("svg:path");return e&&o.classed(e,!0),o.style("pointer-events","none"),o.attr("fill",i||"#3366CC").attr("stroke",a||"#000").attr("stroke-opacity",n||"1").attr("fill-opacity",r||"0.8"),o},G=function(t){var e=t.type,i=void 0===e?"axis":e,a=t.tickSize,n=void 0===a?6:a,r=t.tickPadding,o=void 0===r?3:r,s=t.position,l=t.height,h=t.width,c=t.axis,d=t.scale,u=t.ticks,p=t.tickFormat,_=t.label,m=t.labelX,f=t.labelY,g=t.name,v=void 0===g?"":g,y=t.onAxisMount;return function(t){var e=0,a=0;"bottom"==s&&(a=l),"right"==s&&(e=h),"x"==c&&"grid"==i?n=-l:"y"==c&&"grid"==i&&(n=-h);var r=d3["axis"+s.replace(/\b\w/g,(function(t){return t.toUpperCase()}))]().scale(d).ticks(u).tickPadding(o).tickSize(n).tickFormat(p),g=t.append("g").attr("class",[c,i,s,v].join(" ")).attr("transform","translate("+e+","+a+")").call(r);return _&&g.append("svg:text").attr("x",m).attr("y",f).text(_),y&&g.call(y),g}},H=function(t){return t.type="grid",G(t)},X=function(t){var e=t.theme,i=t.xCoord,a=void 0===i?0:i,n=t.yCoord,r=void 0===n?0:n,o=t.labels,s=void 0===o?{}:o,l=t.item,h=void 0===l?{}:l,c=t.length,d=void 0===c?0:c;return function(t){var i,n=t.select(".height-focus.line"),o=t.select(".height-focus.circle-lower"),l=t.select(".height-focus-label");if(n.node()||(n=t.append("svg:line")),o.node()||(o=t.append("svg:circle")),l.node()||(l=t.append("svg:text")),isNaN(a)||isNaN(r))return t;for(var c in o.attr("class",e+" height-focus circle-lower").attr("transform","translate("+a+","+r+")").attr("r",6).attr("cx",0).attr("cy",0),n.attr("class",e+" height-focus line").attr("x1",a).attr("x2",a).attr("y1",r).attr("y2",d),l.attr("class",e+" height-focus-label").style("pointer-events","none").attr("x",a+5).attr("y",d),s)(i=l.select(".height-focus-"+s[c].name)).size()||(i=l.append("svg:tspan").attr("class","height-focus-"+s[c].name).attr("dy","1.5em")),i.text("function"!=typeof s[c].value?s[c].value:s[c].value(h));return l.select("tspan").attr("dy",l.selectAll("tspan").size()>1?"-1.5em":"0em"),l.selectAll("tspan").attr("x",a+5),t}},j=function(t){var e=t.name,i=t.label,a=t.width,n=t.height,r=t.margins,o=void 0===r?{}:r,s=t.color,l=t.path;return function(t){return t.attr("class","legend-item legend-"+e.toLowerCase()).attr("data-name",e),t.on("click.legend",(function(){return d3.select(t.node().ownerSVGElement||t).dispatch("legend_clicked",{detail:{path:l.node(),name:e,legend:t.node(),enabled:!l.classed("leaflet-hidden")}})})),t.append("svg:rect").attr("x",a/2-50).attr("y",n+o.bottom/2).attr("width",50).attr("height",10).attr("fill",s).attr("stroke","#000").attr("stroke-opacity","0.5").attr("fill-opacity","0.25"),t.append("svg:text").text(L._(i||e)).attr("x",a/2+5).attr("font-size",10).style("text-decoration-thickness","2px").style("font-weight","700").attr("y",n+o.bottom/2).attr("dy","0.75em"),t}},R=function(t){var e=t.xCoord,i=t.yCoord,a=t.width,n=t.height,r=t.labels,o=void 0===r?{}:r,s=t.item,l=void 0===s?{}:s;return function(t){var r=t.select(".mouse-focus-line"),s=t.select(".mouse-focus-label");r.node()||(r=t.append("svg:line")),s.node()||(s=t.append("g"));var h=s.select(".mouse-focus-label-rect"),c=s.select(".mouse-focus-label-text");h.node()||(h=s.append("svg:rect")),c.node()||(c=s.append("svg:text"));var d,u=0,p=0,_={width:0,height:0};try{_=c.node().getBBox()}catch(e){return t}for(var m in e&&(u=e+(e<a/2?10:-_.width-10)),i&&(p=Math.max(i-_.height,L.Browser.webkit?0:-1/0)),r.attr("class","mouse-focus-line").attr("x2",e).attr("y2",0).attr("x1",e).attr("y1",n),s.attr("class","mouse-focus-label"),h.attr("class","mouse-focus-label-rect").attr("x",u-5).attr("y",p-5).attr("width",_.width+10).attr("height",_.height+10).attr("rx",3).attr("ry",3),c.attr("class","mouse-focus-label-text").style("font-weight","700").attr("y",p),o)(d=c.select(".mouse-focus-label-"+o[m].name)).size()||(d=c.append("svg:tspan",".mouse-focus-label-x").attr("class","mouse-focus-label-"+o[m].name).attr("dy","1.5em")),d.text("function"!=typeof o[m].value?o[m].value:o[m].value(l));return c.select("tspan").attr("dy","1em"),c.selectAll("tspan").attr("x",u),t}},U=function(t){var e=t.height,i=t.width;return function(t){t.data([{x:0,y:e}]).attr("transform",(function(t){return"translate("+t.x+","+t.y+")"}));var a=t.selectAll(".horizontal-drag-rect").data([{w:i}]),n=t.selectAll(".horizontal-drag-line").data([{w:i}]),r=t.selectAll(".horizontal-drag-label").data([{w:i-8}]),o=t.selectAll(".horizontal-drag-symbol").data([{type:d3.symbolTriangle,x:i+7,y:0,angle:-90,size:50}]);return a.exit().remove(),n.exit().remove(),r.exit().remove(),o.exit().remove(),a.enter().append("svg:rect").attr("class","horizontal-drag-rect").attr("x",0).attr("y",-8).attr("height",8).attr("fill","none").attr("pointer-events","all").merge(a).attr("width",(function(t){return t.w})),n.enter().append("svg:line").attr("class","horizontal-drag-line").attr("x1",0).merge(n).attr("x2",(function(t){return t.w})),r.enter().append("svg:text").attr("class","horizontal-drag-label").attr("text-anchor","end").attr("y",-8).merge(r).attr("x",(function(t){return t.w})),o.enter().append("svg:path").attr("class","horizontal-drag-symbol").merge(o).attr("d",d3.symbol().type((function(t){return t.type})).size((function(t){return t.size}))).attr("transform",(function(t){return"translate("+t.x+","+t.y+") rotate("+t.angle+")"})),t}},J=function(t){var e=t.point,i=t.height,a=t.width,n=t.x,r=t.y;return function(t){return isNaN(n)||isNaN(r)||(e.item&&e.item.property("isConnected")||(e.position=e.position||"bottom",e.item=t.append("g"),e.item.append("svg:line").attr("y1",0).attr("x1",0).attr("style","stroke: rgb(51, 51, 51); stroke-width: 0.5; stroke-dasharray: 2, 2;"),e.item.append("svg:circle").attr("class"," height-focus circle-lower").attr("r",3),e.label&&e.item.append("svg:text").attr("dx","4px").attr("dy","-4px")),e.item.datum({pos:e.position,x:n,y:r}).attr("class",(function(t){return"point "+t.pos})).attr("transform",(function(t){return"translate("+t.x+","+t.y+")"})),e.item.select("line").datum({y2:{top:-r,bottom:i-r}[e.position],x2:{left:-n,right:a-n}[e.position]||0}).attr("y2",(function(t){return t.y2})).attr("x2",(function(t){return t.x2})),e.label&&e.item.select("text").text(e.label)),t}},Y=function(t){var e=t.min,i=t.max,a=t.attr,n=t.name,r=t.forceBounds,o=t.scale;return function(t){a=a||n,o&&o.attr&&(a=o.attr);var s=t&&t.length?d3.extent(t,(function(t){return t[a]})):[0,1];return void 0!==e&&(e<s[0]||r)&&(s[0]=e),void 0!==i&&(i>s[1]||r)&&(s[1]=i),s}},V=function(t){var e=t.axis;return function(t,i){return"x"==e?[0,t]:"y"==e?[i,0]:void 0}},W=function(t){var e=t.data,i=t.attr,a=t.min,n=t.max,r=t.forceBounds,o=t.range;return d3.scaleLinear().range(o).domain(Y({min:a,max:n,attr:i,forceBounds:r})(e))},Z=function(t){var e=t.width,i=t.height,a=t.margins,n=void 0===a?{}:a,r=(t.ruler,e-n.left-n.right),o=i-n.top-n.bottom,s=d3.create("svg:svg").attr("class","background"),l=s.append("g"),h={grid:l.append("g").attr("class","grid"),area:l.append("g").attr("class","area"),point:l.append("g").attr("class","point"),axis:l.append("g").attr("class","axis"),brush:l.append("g").attr("class","brush"),tooltip:l.append("g").attr("class","tooltip").attr("display","none"),ruler:l.append("g").attr("class","ruler"),legend:l.append("g").attr("class","legend")},c=h.area.append("svg:mask").attr("id","elevation-clipper").attr("fill-opacity",1),d=c.append("svg:rect").attr("class","zoom").attr("fill","white"),u=h.area.append("svg:foreignObject").attr("mask","url(#"+c.attr("id")+")"),p=u.append("xhtml:canvas").attr("class","canvas-plot"),_=p.node().getContext("2d");h.tooltip.call(R({xCoord:0,yCoord:0,height:o,width:r,labels:{}}));var m=d3.brushX().on("start.cursor end.cursor brush.cursor",(function(){return h.brush.select(".overlay").attr("cursor",null)})),f={mask:c,canvas:p,context:_,brush:m},g={svg:s,g:l,panes:h,utils:f,scale:function(t){return{x:W(t.x),y:W(t.y)}},_resize:function(t){var e=t.width,i=t.height,a=t.margins,n=void 0===a?{}:a,r=t.ruler,o=e-n.left-n.right,c=i-n.top-n.bottom;s.attr("viewBox","0 0 ".concat(e," ").concat(i)).attr("width",e).attr("height",i),l.attr("transform","translate("+n.left+","+n.top+")"),/Mac|iPod|iPhone|iPad/.test(navigator.platform)&&/AppleWebkit/i.test(navigator.userAgent)&&p.style("transform","translate("+n.left+"px,"+n.top+"px)"),d.attr("x",0).attr("y",0).attr("width",o).attr("height",c),u.attr("width",o).attr("height",c),p.attr("width",o).attr("height",c),r&&h.ruler.call(U({height:c,width:o})),h.brush.call(m.extent([[0,0],[o,c]])),h.brush.select(".overlay").attr("cursor",null),g._width=o,g._height=c,g.svg.dispatch("resize",{detail:{width:o,height:c}})},pane:function(t){return h[t]||(h[t]=l.append("g").attr("class",t)),h[t]},get:function(t){return f[t]}};return g._resize({width:e,height:i,margins:n}),g},q=Object.freeze({__proto__:null,Colors:N,Area:P,Path:B,Axis:G,Grid:H,PositionMarker:X,LegendItem:j,Tooltip:R,Ruler:U,CheckPoint:J,Domain:Y,Range:V,Scale:W,Bisect:function(t){var e=t.data,i=void 0===e?[0,1]:e,a=t.scale,n=t.x,r=t.attr;return d3.bisector((function(t){return t[r]})).left(i,a.invert(n))},Chart:Z}),K=L.Class.extend({includes:L.Evented?L.Evented.prototype:L.Mixin.Events,initialize:function(t,e){var i=this;this.options=t,this.control=e,this._data=[],this._props={scales:{},paths:{},areas:{},grids:{},axes:{},legendItems:{},tooltipItems:{}},this._scales={},this._domains={},this._ranges={},this._paths={},this._brushEnabled=t.dragging,this._zoomEnabled=t.zooming;var a=this._chart=Z(t);this._container=a.svg;this._grid=a.pane("grid"),this._area=a.pane("area"),this._point=a.pane("point"),this._axis=a.pane("axis"),this._legend=a.pane("legend"),this._tooltip=a.pane("tooltip"),this._ruler=a.pane("ruler"),this._initScale(),this._mask=a.get("mask"),this._context=a.get("context"),this._brush=a.get("brush"),this._zoom=d3.zoom(),this._drag=d3.drag(),this._initInteractions(),this._maskGaps=[],e.on("eletrack_added",(function(t){i._maskGaps.push(t.index),e.once("eledata_updated",(function(t){return i._maskGaps.push(t.index)}))}))},update:function(t){return t&&(t.data&&(this._data=t.data),t.options&&(this.options=t.options)),this._updateScale(),this._updateArea(),this._updateAxis(),this._updateLegend(),this._updateClipper(),this},render:function(){var t=this;return function(e){return e.append((function(){return t._container.node()}))}},clear:function(){this._resetDrag(),this._hideDiagramIndicator(),this._area.selectAll("path").attr("d","M0 0"),this._context.clearRect(0,0,this._width(),this._height())},_drawPath:function(t){var e=this._paths[t],i=this._props.areas[t];e.datum(this._data).attr("d",P(L.extend({},i,{width:this._width(),height:this._height(),scaleX:this._scales[i.scaleX],scaleY:this._scales[i.scaleY]}))),e.classed("leaflet-hidden")||(this.options.preferCanvas?_(this._context,e):this._area.append((function(){return e.node()})))},_hasActiveLayers:function(){var t=this._paths;for(var e in t)if(!t[e].classed("leaflet-hidden"))return!0;return!1},_initBrush:function(t){var e=this,i=function(t){if(e._data.length&&("brush"!=t.type||t.sourceEvent)){var i=e._chart.panes.brush.select(".overlay").node(),a=d3.pointers(t,i)[0][0],n=e._data[e._findIndexForXCoord(a)];e.fire("mouse_move",{item:n,xCoord:a})}};this._brush.filter((function(t){return e._brushEnabled&&!t.shiftKey&&!t.button})).on("end.update",(function(t){if(e._data.length){var i=t.selection;if(i){var a=e._findIndexForXCoord(i[0]),n=e._findIndexForXCoord(i[1]);e.fire("dragged",{dragstart:e._data[a],dragend:e._data[n]})}}})).on("brush.update",i),this._chart.panes.brush.on("mouseenter.focus touchstart.focus",this.fire.bind(this,"mouse_enter")).on("mouseout.focus touchend.focus",this.fire.bind(this,"mouse_out")).on("mousemove.focus touchmove.focus",i)},_initClipper:function(){var t=this,e=this._container,i=this.options.margins,a=this._zoom;a.scaleExtent([1,10]).extent([[i.left,0],[this._width()-i.right,this._height()]]).translateExtent([[i.left,-1/0],[this._width()-i.right,1/0]]).filter((function(e){return t._zoomEnabled&&(e.shiftKey||4==e.buttons)})).on("start",(function(i){i.sourceEvent&&"mousedown"==i.sourceEvent.type&&e.style("cursor","grabbing"),1==i.transform.k&&0==i.transform.x&&(t._container.classed("zoomed",!0),t._mask&&t._point.attr("mask","url(#"+t._mask.attr("id")+")")),t.zooming=!0})).on("end",(function(i){1==i.transform.k&&0==i.transform.x&&(t._container.classed("zoomed",!1),t._mask&&t._point.attr("mask",null)),t.zooming=!1,e.style("cursor","")})).on("zoom",(function(e){t.zooming=!1,t._updateScale(),t.zooming=!0,t._scales.distance=t._x=e.transform.rescaleX(t._x),t._resetDrag(),e.sourceEvent&&"mousemove"==e.sourceEvent.type&&t._hideDiagramIndicator(),t.fire("zoom")})),e.call(a)},_initInteractions:function(){this._initBrush(),this._initRuler(),this._initClipper(),this._initLegend()},_initLegend:function(){var t=this;this._container.on("legend_clicked",(function(e){var i=e.detail,a=i.path,n=i.legend,r=i.name,o=i.enabled;if(a){var s=S("text",n),l=S("rect",n);b(s,"text-decoration-line","line-through",o),b(l,"fill-opacity","0",o),v(a,"leaflet-hidden",o),t._updateArea(),t.fire("elepath_toggle",{path:a,name:r,legend:n,enabled:o})}}))},_initRuler:function(){var t=this;if(this.options.ruler){var e=d3.format(".0f"),i=this._drag;i.on("start end",(function(e,i){var a=t._height(),n=t._ruler.data()[0].y;(n>=a||n<=0)&&t._ruler.select(".horizontal-drag-label").text(""),t._hideDiagramIndicator()})).on("drag",(function(i,a){var n=t._height(),r=d3.pointers(i,t._area.node())[0][1],o=r>0?r<n?r:n:0,s=t._y.invert(o),l=L.extend(t._ruler.data()[0],{y:o});t._ruler.data([l]).attr("transform",(function(t){return"translate("+t.x+","+t.y+")"})).classed("active",o<n),t._container.select(".horizontal-drag-label").text(e(s)+" "+(t.options.imperial?"ft":"m")),t.fire("ruler_filter",{coords:r<n&&r>0?t._findCoordsForY(r):[]})})),this._ruler.call(i)}},_initScale:function(){var t=this.options;this._registerAxisScale({axis:"x",position:"bottom",attr:t.xAttr,min:t.xAxisMin,max:t.xAxisMax,name:"distance"}),this._registerAxisScale({axis:"y",position:"left",attr:t.yAttr,min:t.yAxisMin,max:t.yAxisMax,name:"altitude"}),this._x=this._scales.distance,this._y=this._scales.altitude},_registerAreaPath:function(t){var e=this.options;t.xAttr||(t.xAttr=e.xAttr),t.yAttr||(t.yAttr=e.yAttr),void 0===t.preferCanvas&&(t.preferCanvas=e.preferCanvas);var i=B(t);this._paths[t.name]=i,this._props.areas[t.name]=t,e.legend&&(this._props.legendItems[t.name]={name:t.name,label:t.label,color:t.color,path:i})},_registerAxisGrid:function(t){this._props.grids[t.name||t.axis]=t},_registerAxisScale:function(t){var e=this.options,i=t.scale;if("function"!=typeof i){(i=L.extend({data:this._data,forceBounds:e.forceAxisBounds},i)).attr=i.attr||t.name;var a=this._domains[t.name]=Y(t),n=this._ranges[t.name]=V(t);i.range=i.range||n(this._width(),this._height()),i.domain=i.domain||a(this._data),this._props.scales[t.name]=i,t.scale=this._scales[t.name]=W(i)}return t.ticks||("x"==t.axis?t.ticks=e.xTicks:"y"==t.axis&&(t.ticks=e.yTicks)),this._props.axes[t.name]=t,i},_registerCheckPoint:function(t){var e,i,a;this._data.length&&(t.latlng?(e=this._data[this._findIndexForLatLng(t.latlng)],i=this._x(e.dist),a=this._y(e.z)):isNaN(t.dist)||(i=this._x(t.dist),e=this._data[this._findIndexForXCoord(i)],a=this._y(e.z)),this._point.call(J({point:t,width:this._width(),height:this._height(),x:i,y:a})))},_registerTooltip:function(t){this._props.tooltipItems[t.name]=t},_updateArea:function(){var t=this._paths;for(var e in this._context.clearRect(0,0,this._width(),this._height()),t)t[e].classed("leaflet-hidden")||this._drawPath(e)},_updateAxis:function(){var t=this.options;this._grid.selectAll("g").remove(),this._axis.selectAll("g").remove();var e,i,a,n=this._props.grids,r=this._props.axes,o={width:this._width(),height:this._height(),tickFormat:""},s={width:this._width(),height:this._height()};for(var l in n)e=L.extend({},o,n[l]),a=H(e),this._grid.call(a);for(var h in r)!1!==t[h]&&"summary"!==t[h]&&(e=L.extend({},s,r[h]),i=G(e),this._axis.call(i));this._axis.selectAll(".y.axis.right").each((function(t,e,i){var a=d3.select(i[e]),n=a.attr("transform"),r=n.substring(n.indexOf("(")+1,n.indexOf(")")).split(",");a.attr("transform","translate("+(+r[0]+40*e)+","+r[1]+")"),e>0&&(a.select(":scope > path").attr("opacity",.25),a.selectAll(":scope > .tick line").attr("opacity",.75))}))},_updateClipper:function(){var t=this,e=this.options.margins;this._zoom.scaleExtent([1,10]).extent([[e.left,0],[this._width()-e.right,this._height()]]).translateExtent([[e.left,-1/0],[this._width()-e.right,1/0]]),this._mask.selectAll(".gap").remove(),this._maskGaps.forEach((function(e,i){if(!(i>=t._maskGaps.length-2)){var a=t._data[t._maskGaps[i]],n=t._data[t._maskGaps[i+1]],r=t._x(t._data[t._findIndexForLatLng(a.latlng)].dist),o=t._x(t._data[t._findIndexForLatLng(n.latlng)].dist);t._mask.append("rect").attr("x",r).attr("y",0).attr("width",o-r).attr("height",t._height()).attr("class","gap").attr("fill-opacity","0.8").attr("fill","black")}}))},_updateLegend:function(){var t=this;if(!1!==this.options.legend){var e,i=this._props.legendItems;for(var a in this._legend.selectAll("g").remove(),i)e=j(L.extend({width:this._width(),height:this._height(),margins:this.options.margins},i[a])),this._legend.append("g").call(e);var n=this._legend.selectAll(".legend-item"),r=n.nodes().length,o=Array(Math.floor(r/2)).fill(null).map((function(t,e){return 2*(e+1)-(1-Math.sign(r%2))})),s=o.slice().reverse().map((function(t){return-t}));r%2!=0&&s.push(0),o=s.concat(o);var l=this._axis.selectAll(".x.axis.bottom").nodes().length,h=30+2*l,c=30*r;r&&this.options.margins.right<c&&(this.options.margins.right=c,this.fire("margins_updated")),l&&this.options.margins.bottom<h&&(this.options.margins.bottom=h,this.fire("margins_updated")),n.each((function(e,i,a){var n=d3.select(a[i]),r=(n.select("rect"),n.attr("data-name")),s=t._paths[r],h=55*o[i],c=2*l;n.attr("transform","translate("+h+", "+c+")"),r in t.options&&"disabled"==t.options[r]&&(s.classed("leaflet-hidden",!0),n.select("text").style("text-decoration-line","line-through"),n.select("rect").style("fill-opacity","0")),t._mask&&s.attr("mask","url(#"+t._mask.attr("id")+")")}))}},_updateScale:function(){if(this.zooming)return{x:this._x,y:this._y};for(var t in this._scales)this._scales[t].domain(this._domains[t](this._data)).range(this._ranges[t](this._width(),this._height()));return{x:this._x,y:this._y}},_width:function(){return this._chart._width},_height:function(){return this._chart._height},_findCoordsForY:function(t){var e,i=this._data,a=this._y.invert(t),n=i.reduce((function(t,e,i){return e.z>=a&&t.push(i),t}),[]),r=0;return n.reduce((function(t,a,o){return n[e=o+1]===n[o]+1&&e!==n.length||(t.push(n.slice(r,e).map((function(t){return i[t].latlng}))),r=e),t}),[])},_findIndexForXCoord:function(t){var e=this;return d3.bisector((function(t){return t[e.options.xAttr]})).left(this._data||[0,1],this._x.invert(t))},_findIndexForLatLng:function(t){var e=null,i=1/0;return this._data.forEach((function(a,n){var r=t.distanceTo(a.latlng);r<i&&(i=r,e=n)})),e},_resetDrag:function(){this._chart.panes.brush.select(".selection").attr("width")&&(this._chart.panes.brush.call(this._brush.clear),this._hideDiagramIndicator(),this.fire("reset_drag"))},_resetZoom:function(){this._zoom&&this._zoom.transform(this._chart.svg,d3.zoomIdentity)},_showDiagramIndicator:function(t,e){this._tooltip.attr("display",null).call(R({xCoord:e,yCoord:this._y(t[this.options.yAttr]),height:this._height(),width:this._width(),labels:this._props.tooltipItems,item:t}))},_hideDiagramIndicator:function(){this._tooltip.attr("display","none")}}),Q=L.Class.extend({initialize:function(t){switch(this.options=t,this.options.marker){case"elevation-line":this._container=d3.select(map.getPane("elevationPane")).select("svg > g").attr("class","height-focus-group");break;case"position-marker":this._marker=L.marker([0,0],{icon:this.options.markerIcon,zIndexOffset:1e6,interactive:!1})}return this._labels={},this},addTo:function(t){switch(this._map=t,this.options.marker){case"elevation-line":this._container.call(X({}));break;case"position-marker":this._marker.addTo(t,{pane:"overlayPane"})}return this},update:function(t){if(t?this._props=t:t=this._props,t)switch(t.options&&(this.options=t.options),this._map||this.addTo(t.map),this._latlng=t.item.latlng,this.options.marker){case"elevation-line":var e=this._map.latLngToLayerPoint(this._latlng);e=L.extend({},t.item,this._map._rotate?this._map.rotatedPointToMapPanePoint(e):e),this._container.classed("leaflet-hidden",!1),this._container.call(X({theme:this.options.theme,xCoord:e.x,yCoord:e.y,length:e.y-this._height()/t.maxElevation*e.z,labels:this._labels,item:e}));break;case"position-marker":g(this._marker.getElement(),"leaflet-hidden"),this._marker.setLatLng(this._latlng)}},remove:function(){switch(this._props=null,this.options.marker){case"elevation-line":this._container&&this._container.classed("leaflet-hidden",!0);break;case"position-marker":f(this._marker.getElement(),"leaflet-hidden")}},getLatLng:function(){return this._latlng},_height:function(){var t=this.options;return t.height-t.margins.top-t.margins.bottom},_registerTooltip:function(t){this._labels[t.name]=t}}),$=L.Class.extend({initialize:function(t,e){this.options=t,this.control=e,x(this._container=w("div","elevation-summary "+(t.summary?t.summary+"-summary":"")),"max-width",t.width?t.width+"px":"")},render:function(){var t=this;return function(e){return e.append((function(){return t._container}))}},reset:function(){this._container.innerHTML=""},append:function(t,e,i){return this._container.innerHTML+='<span class="'.concat(t,'"><span class="summarylabel">').concat(e,'</span><span class="summaryvalue">').concat(i,"</span></span>"),this},_registerSummary:function(t){for(var e in t)this.append(e,L._(t[e].label),"function"!=typeof t[e].value?t[e].value:t[e].value(this.control.track_info))}}),tt={autofitBounds:!0,autohide:!L.Browser.mobile,autohideMarker:!0,almostover:!0,altitude:!0,collapsed:!1,detached:!0,distance:!0,distanceMarkers:!1,decimalsX:2,decimalsY:0,dragging:!L.Browser.mobile,downloadLink:"link",elevationDiv:"#elevation-div",followMarker:!0,forceAxisBounds:!1,height:200,imperial:!1,interpolation:"curveLinear",lazyLoadJS:!0,legend:!0,margins:{top:30,right:30,bottom:30,left:40},marker:"elevation-line",markerIcon:L.divIcon({className:"elevation-position-marker",html:'<i class="elevation-position-icon"></i>',iconSize:[32,32],iconAnchor:[16,16]}),position:"topright",polyline:{className:"elevation-polyline",color:"#000",opacity:.75,weight:5,lineCap:"round"},polylineSegments:{className:"elevation-polyline-segments",color:"#F00",interactive:!1},preferCanvas:!1,reverseCoords:!1,ruler:!0,skipNullZCoords:!1,theme:"lightblue-theme",summary:"inline",slope:!1,speed:!1,sLimit:void 0,time:!1,timeFactor:3600,timeFormat:!1,timestamps:!1,sDeltaMax:void 0,sInterpolation:"curveStepAfter",sRange:void 0,width:600,waypoints:!0,wptIcons:{"":L.divIcon({className:"elevation-waypoint-marker",html:'<i class="elevation-waypoint-icon"></i>',iconSize:[30,30],iconAnchor:[8,30]})},wptLabels:!0,xAttr:"dist",xLabel:"km",xTicks:void 0,yAttr:"z",yAxisMax:void 0,yAxisMin:void 0,yLabel:"m",yTicks:void 0,zFollow:!1,zooming:!L.Browser.Mobile},et=L.Control.Elevation=L.Control.extend({includes:L.Evented?L.Evented.prototype:L.Mixin.Events,options:tt,__mileFactor:.621371,__footFactor:3.28084,__D3:"https://unpkg.com/d3@6.5.0/dist/d3.min.js",__TOGEOJSON:"https://unpkg.com/@tmcw/togeojson@4.3.0/dist/togeojson.umd.js",__LGEOMUTIL:"https://unpkg.com/leaflet-geometryutil@0.9.3/src/leaflet.geometryutil.js",__LALMOSTOVER:"https://unpkg.com/leaflet-almostover@1.0.1/src/leaflet.almostover.js",__LDISTANCEM:"https://unpkg.com/@raruto/leaflet-elevation@1.7.5/libs/leaflet-distance-marker.min.js",addData:function(t,e){var i=this;this.lazyLoad(this.__D3).then((function(){void 0===e&&t.on&&(e=t),i._addData(t),i._addLayer(e),i._fireEvt("eledata_added",{data:t,layer:e,track_info:i.track_info})}))},addTo:function(t){if(this.options.detached){var e=this._initElevationDiv();e.isConnected||M(t.getContainer(),e,"afterend"),C(e,this.onAdd(t))}else L.Control.prototype.addTo.call(this,t);return this},clear:function(){this._marker&&this._marker.remove(),this._chart&&this._clearChart(),this._layers&&this._clearLayers(),this._markers&&this._clearMarkers(),this._data=[],this.track_info={},this._fireEvt("eledata_clear"),this._updateChart()},_clearChart:function(){var t=this;this._events&&this._events.elechart_updated&&this._events.elechart_updated.forEach((function(e){return t.off("elechart_updated",e.fn,e.ctx)})),this._chart&&this._chart._container&&(this._chart._container.selectAll("g.point .point").remove(),this._chart.clear())},_clearLayers:function(){this._layers&&this._layers.eachLayer&&(this._layers.eachLayer((function(t){return t.remove()})),this._layers.clearLayers())},_clearMarkers:function(){this._markers&&this._markers.eachLayer&&(this._markers.eachLayer((function(t){return t.remove()})),this._markers.clearLayers())},disableBrush:function(){this._chart._brushEnabled=!1,this._resetDrag()},enableBrush:function(){this._chart._brushEnabled=!0},disableZoom:function(){this._chart._zoomEnabled=!1,this._chart._resetZoom()},enableZoom:function(){this._chart._zoomEnabled=!0},fitBounds:function(t){t=t||this.getBounds(),this._map&&t.isValid()&&this._map.fitBounds(t)},getBounds:function(t){return t=t||this._data,L.latLngBounds(t.map((function(t){return t.latlng})))},getZFollow:function(){return this.options.zFollow},hide:function(){x(this._container,"display","none")},initialize:function(t){this._data=[],this._layers=L.featureGroup(),this._markers=L.featureGroup(),this._markedSegments=L.polyline([]),this._chartEnabled=!0,this.track_info={},this.options=i({},this.options,t),this.options.followMarker&&(this._setMapView=L.Util.throttle(this._setMapView,300,this)),this.options.legend&&(this.options.margins.bottom+=30),this.options.theme&&(this.options.polylineSegments.className+=" "+this.options.theme),!0===this.options.wptIcons&&(this.options.wptIcons=tt.wptIcons),this._markedSegments.setStyle(this.options.polylineSegments),L.extend(N,this.options.colors||{})},lazyLoad:function(t){return p(t,this)},load:function(t){c(t)?this.loadXML(t):h(t)?this.loadGeoJSON(t):this.loadFile(t)},loadFile:function(t){var e=this;fetch(t).then((function(t){return t.text()})).then((function(i){e._downloadURL=t,e.load(i)})).catch((function(t){return console.warn(t)}))},loadGeoJSON:function(t){s(t,this)},loadXML:function(t){var e=this;this.lazyLoad(this.__TOGEOJSON).then((function(){var i=(new DOMParser).parseFromString(t,"text/xml"),a=i.documentElement.tagName.toLowerCase();a in toGeoJSON||(a="TrainingCenterDatabase"==i.documentElement.tagName?"tcx":"gpx");var n=toGeoJSON[a](i),r=i.getElementsByTagName("name");return r[0]?n.name=r[0].innerHTML:e._downloadURL&&(n.name=e._downloadURL.split("/").pop().split("#")[0].split("?")[0]),e.loadGeoJSON(n,e)}))},onAdd:function(t){var e=this;this._map=t;var i=this._container=w("div","elevation-control elevation "+this.options.theme);return this.options.detached||f(i,"leaflet-control"),this.lazyLoad(this.__D3).then((function(){e._initButton(i),e._initChart(i),e._initSummary(i),e._initMarker(t),e._initLayer(t),t.on("zoom viewreset zoomanim",e._hideMarker,e).on("resize",e._resetView,e).on("resize",e._resizeChart,e).on("rotate",e._rotateMarker,e).on("mousedown",e._resetDrag,e),z(t.getContainer(),"mousewheel",e._resetDrag,e),z(t.getContainer(),"touchstart",e._resetDrag,e),e.on("eledata_added eledata_loaded",e._updateChart,e).on("eledata_added eledata_loaded",e._updateSummary,e),e._updateChart(),e._updateSummary()})),i},onRemove:function(t){this._container=null,t.off("zoom viewreset zoomanim",this._hideMarker,this).off("resize",this._resetView,this).off("resize",this._resizeChart,this).off("mousedown",this._resetDrag,this),E(t.getContainer(),"mousewheel",this._resetDrag,this),E(t.getContainer(),"touchstart",this._resetDrag,this),this.off("eledata_added eledata_loaded",this._updateChart,this).off("eledata_added eledata_loaded",this._updateSummary,this)},redraw:function(){this._resizeChart()},setZFollow:function(t){this.options.zFollow=t},show:function(){x(this._container,"display","block")},_addData:function(t){var e=this;if(t){var i=t.geometry;if(i)switch(i.type){case"LineString":this._addGeoJSONData(i.coordinates);break;case"MultiLineString":F(i.coordinates,(function(t){return e._addGeoJSONData(t)}));break;default:console.warn("Unsopperted GeoJSON feature geometry type:"+i.type)}"FeatureCollection"===t.type&&F(t.features,(function(t){return e._addData(t)})),t._latlngs&&this._addGPXData(t._latlngs)}},_addGeoJSONData:function(t){var e=this;F(t,(function(t){e._addPoint(t[1],t[0],t[2]),e._fireEvt("elepoint_added",{point:t,index:e._data.length-1})})),this._fireEvt("eletrack_added",{coords:t,index:this._data.length-1})},_addGPXData:function(t){var e=this;F(t,(function(t){var i;e._addPoint(t.lat,t.lng,null!==(i=t.alt)&&void 0!==i?i:t.meta.ele),e._fireEvt("elepoint_added",{point:t,index:e._data.length-1})})),this._fireEvt("eletrack_added",{coords:t,index:this._data.length-1})},_addPoint:function(t,e,i){if(this.options.reverseCoords){var a=[e,t];t=a[0],e=a[1]}this._data.push({x:t,y:e,z:i,latlng:L.latLng(t,e,i)}),this._fireEvt("eledata_updated",{index:this._data.length-1})},_addLayer:function(t){t&&this._layers.addLayer(t)},_addMarker:function(t){t&&this._markers.addLayer(t)},_initElevationDiv:function(){var t=S(this.options.elevationDiv);return t||(this.options.elevationDiv="#elevation-div_"+T(),t=w("div","leaflet-control elevation elevation-div",{id:this.options.elevationDiv.substr(1)})),this.options.detached&&y(t,"leaflet-control","elevation-detached"),this.eleDiv=t,this.eleDiv},_collapse:function(){y(this._container,"elevation-expanded","elevation-collapsed")},_expand:function(){y(this._container,"elevation-collapsed","elevation-expanded")},_findItemForLatLng:function(t){return this._data[this._chart._findIndexForLatLng(t)]},_findItemForX:function(t){return this._data[this._chart._findIndexForXCoord(t)]},_fireEvt:function(t,e,i){this.fire&&this.fire(t,e,i),this._map&&this._map.fire(t,e,i)},_height:function(){if(this._chart)return this._chart._height();var t=this.options;return t.height-t.margins.top-t.margins.bottom},_hideMarker:function(){this.options.autohideMarker&&this._marker.remove()},_initChart:function(t){var e=this.options;if(e.xTicks=this._xTicks(),e.yTicks=this._yTicks(),e.detached){var i=this.eleDiv,a=i.offsetWidth,n=i.offsetHeight;a>0&&(e.width=a),n>20&&(e.height=n-20)}else{var r=this._map.getContainer().clientWidth;e._maxWidth=e._maxWidth>e.width?e._maxWidth:e.width,this._container.style.maxWidth=e._maxWidth+"px",e._maxWidth>r&&(e.width=r-30)}var o=this._chart=new K(e,this);this._x=this._chart._x,this._y=this._chart._y,d3.select(t).call(o.render()),o.on("reset_drag",this._hideMarker,this).on("mouse_enter",this._fireEvt.bind("elechart_enter"),this).on("dragged",this._dragendHandler,this).on("mouse_move",this._mousemoveHandler,this).on("mouse_out",this._mouseoutHandler,this).on("ruler_filter",this._rulerFilterHandler,this).on("zoom",this._updateChart,this).on("elepath_toggle",this._toggleChartHandler,this).on("margins_updated",this._resizeChart,this),this._fireEvt("elechart_axis"),this.options.legend&&this._fireEvt("elechart_legend"),this._fireEvt("elechart_init")},_initLayer:function(){var t=this;this._layers.on("layeradd layerremove",(function(e){var i=e.layer;v(i.getElement&&i.getElement(),t.options.polyline.className+" "+t.options.theme,"layeradd"==e.type),k(i,"mousemove",t._mousemoveLayerHandler.bind(t),"layeradd"==e.type),k(i,"mouseout",t._mouseoutHandler.bind(t),"layeradd"==e.type)}))},_initMarker:function(t){var e=t.getPane("elevationPane");e||((e=this._pane=t.createPane("elevationPane",t.getPane("norotatePane")||t.getPane("mapPane"))).style.zIndex=625,e.style.pointerEvents="none"),this._renderer&&this._renderer.remove(),this._renderer=L.svg({pane:"elevationPane"}).addTo(this._map),this._marker=new Q(this.options),this._fireEvt("elechart_marker")},_initButton:function(t){if(t.setAttribute("aria-haspopup",!0),this.options.detached||L.DomEvent.disableClickPropagation(t).disableScrollPropagation(t),L.Browser.mobile&&z(t,"click",L.DomEvent.stopPropagation),z(t,"mousewheel",this._mousewheelHandler,this),!this.options.detached){var e=this._button=w("a","elevation-toggle elevation-toggle-icon"+(this.options.autohide?"":" close-button"),{href:"#",title:L._("Elevation")},t);this.options.collapsed&&(this._collapse(),this.options.autohide?(z(t,"mouseover",this._expand,this),z(t,"mouseout",this._collapse,this)):(z(e,"click",L.DomEvent.stop),z(e,"click",this._toggle,this)),z(e,"focus",this._toggle,this),this._map.on("click",this._collapse,this))}},_initSummary:function(t){var e=this._summary=new $({summary:this.options.summary},this);d3.select(t).call(e.render()),this.summaryDiv=this._summary._container},_dragendHandler:function(t){this._hideMarker(),this.fitBounds(L.latLngBounds([t.dragstart.latlng,t.dragend.latlng])),this._fireEvt("elechart_dragged")},_mousemoveHandler:function(t){if(this._data.length&&this._chartEnabled){var e=this._findItemForX(t.xCoord);if(e){var i=t.xCoord;this._chartEnabled&&this._chart._showDiagramIndicator(e,i),this._updateMarker(e),this._setMapView(e),this._map&&f(this._map.getContainer(),"elechart-hover"),this._fireEvt("elechart_change",{data:e,xCoord:i}),this._fireEvt("elechart_hover",{data:e,xCoord:i})}}},_mousemoveLayerHandler:function(t){if(this._data.length){var e=this._findItemForLatLng(t.latlng);if(e){var i=e.xDiagCoord;this._chartEnabled&&this._chart._showDiagramIndicator(e,i),this._updateMarker(e),this._fireEvt("elechart_change",{data:e,xCoord:i})}}},_mouseoutHandler:function(){this.options.detached||(this._hideMarker(),this._chart._hideDiagramIndicator()),this._map&&g(this._map.getContainer(),"elechart-hover"),this._fireEvt("elechart_leave")},_mousewheelHandler:function(t){if(!this._map.gestureHandling||!this._map.gestureHandling._enabled){var e=this._marker.getLatLng()||this._map.getCenter(),i=this._map.getZoom()+Math.sign(t.deltaY);this._resetDrag(),this._map.flyTo(e,i)}},_registerCheckPoint:function(t){var e=this;this.on("elechart_updated",(function(){return e._chart._registerCheckPoint(t)}))},_registerAreaPath:function(t){var e=this;this.on("elechart_init",(function(){return e._chart._registerAreaPath(t)}))},_registerAxisGrid:function(t){var e=this;this.on("elechart_axis",(function(){return e._chart._registerAxisGrid(t)}))},_registerAxisScale:function(t){var e=this;this.on("elechart_axis",(function(){return e._chart._registerAxisScale(t)}))},_registerTooltip:function(t){var e=this;if(t.chart){var i=L.extend({},t,{value:t.chart});this.on("elechart_init",(function(){return e._chart._registerTooltip(i)}))}if(t.marker){var a=L.extend({},t,{value:t.marker});this.on("elechart_marker",(function(){return e._marker._registerTooltip(a)}))}},_registerSummary:function(t){var e=this;this.on("elechart_summary",(function(){return e._summary._registerSummary(t)}))},_resetDrag:function(){this._chart._resetDrag(),this._hideMarker()},_resetView:function(){this._map&&this._map._isFullscreen||(this._resetDrag(),this._hideMarker(),this.options.autofitBounds&&this.fitBounds())},_resizeChart:function(){if(this._container&&"none"!=x(this._container,"display")){var t,e=this.options;if(e.detached)t=(this.eleDiv||this._container).offsetWidth;else{var i=this._map.getContainer().clientWidth;t=e._maxWidth>i?i-30:e._maxWidth}if(t){var a=this._chart;e.width=t,a&&a._chart&&(a._chart._resize(e),e.xTicks=this._xTicks(),e.yTicks=this._yTicks(),this._updateChart())}this._updateMapSegments()}},_rulerFilterHandler:function(t){this._updateMapSegments(t.coords)},_toggle:function(){D(this._container,"elevation-expanded")?this._collapse():this._expand()},_setMapView:function(t){if(this.options.followMarker&&this._map){var e=this._map.getZoom(),i=this.options.zFollow;"number"==typeof i?this._map.setView(t.latlng,e<i?i:e,{animate:!0,duration:.25}):this._map.getBounds().contains(t.latlng)||this._map.setView(t.latlng,e,{animate:!0,duration:.25})}},_toggleChartHandler:function(t){var e=this,i=(t.path,t.name),a=t.enabled;this._chartEnabled=this._chart._hasActiveLayers(),this._layers.eachLayer((function(t){v(t.getElement&&t.getElement(),e.options.polyline.className+" "+e.options.theme,e._chartEnabled)})),this.options[i]=a||"disabled"!=this.options[i]?"disabled":"enabled",this._chartEnabled||(this._chart._hideDiagramIndicator(),this._marker.remove())},_updateChart:function(){
|
|
1
|
+
!function(t){"function"==typeof define&&define.amd?define(t):t()}((function(){"use strict";function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(e)}function e(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function i(t){for(var a=arguments.length,n=new Array(a>1?a-1:0),r=1;r<a;r++)n[r-1]=arguments[r];if(!n.length)return t;var o=n.shift();if(l(t)&&l(o))for(var s in o)l(o[s])?(t[s]||Object.assign(t,e({},s,{})),i(t[s],o[s])):Object.assign(t,e({},s,o[s]));return i.apply(void 0,[t].concat(n))}!function(t,e){"function"==typeof define&&define.amd?define(["leaflet"],t):"object"==typeof exports&&(module.exports=t(require("leaflet"))),void 0!==e&&e.L&&t(e.L)}((function(t){return t.locales={},t.locale=null,t.registerLocale=function(e,i){t.locales[e]=t.Util.extend({},t.locales[e],i)},t.setLocale=function(e){t.locale=e},t.i18n=t._=function(e,i){t.locale&&t.locales[t.locale]&&t.locales[t.locale][e]&&(e=t.locales[t.locale][e]);try{e=t.Util.template(e,i)}catch(t){}return e}}),window);var a=6e4,n=60*a,r=24*n;function o(t){var e=Math.floor(t/r),i=Math.floor((t-e*r)/n),o=Math.floor((t-e*r-i*n)/a),s=Math.round((t-e*r-i*n-o*a)/1e3);return 60===s&&(o++,s=0),60===o&&(i++,o=0),24===i&&(e++,i=0),(e?e+"d ":"")+i.toString().padStart(2,0)+":"+o.toString().padStart(2,0)+"'"+s.toString().padStart(2,0)+'"'}function s(e,i){"string"==typeof e&&(e=JSON.parse(e));var a=!0===(i=i||this).options.distanceMarkers?{lazy:!0}:L.extend({lazy:!0},i.options.distanceMarkers),n=i.options,r=n.wptIcons,o=n.wptLabels,s=L.geoJson(e,{distanceMarkers:a,style:function(t){var e=L.extend({},i.options.polyline);return i.options.theme&&(e.className+=" "+i.options.theme),e},pointToLayer:function(t,e){var a,n,s;if(i.options.waypoints){var l=t.properties,h=null!==(a=l.desc)&&void 0!==a?a:"",c=null!==(n=l.name)&&void 0!==n?n:"",d=(null!==(s=l.sym)&&void 0!==s?s:c).replace(" ","-").replace('"',"").replace("'","").toLowerCase();if([!0,"dots"].includes(i.options.waypoints)&&i._registerCheckPoint({latlng:e,label:[!0,"dots"].includes(o)?c:""},!0),[!0,"markers"].includes(i.options.waypoints)&&0!=r){r.hasOwnProperty(d)||(r[d]=L.divIcon(L.extend({},r[""].options,{html:'<i class="elevation-waypoint-icon '+d+'"></i>'})));var u=L.marker(e,{icon:r[d]});return[!0,"markers"].includes(o)&&(c||h)&&u.bindPopup("<b>"+c+"</b>"+(h.length>0?"<br>"+h:"")).openPopup(),i._addMarker(u),i.fire("waypoint_added",{point:u,element:e,properties:l}),u}}},onEachFeature:function(n,r){n.geometry&&"Point"==n.geometry.type||(r._latlngs.forEach((function(e,i,a){if(e.meta={time:null,ele:null,hr:null,cad:null,atemp:null},"alt"in e&&(e.meta.ele=e.alt),n.properties){var r=n.properties;"coordTimes"in r?e.meta.time=new Date(Date.parse(r.coordTimes[i])):"times"in r?e.meta.time=new Date(Date.parse(r.times[i])):"time"in r&&(e.meta.time=new Date(Date.parse("object"===t(r.time)?r.time[i]:r.time))),"heartRates"in r?e.meta.hr=parseInt(r.heartRates[i]):"heartRate"in r&&(e.meta.hr=parseInt("object"===t(r.heartRate)?r.heartRate[i]:r.heartRate))}})),i.addData(r),i.options.distanceMarkers&&a.lazy&&r.on("add remove",(function(t){var e=t.target;L.DistanceMarkers&&e instanceof L.Polyline&&e[t.type+"DistanceMarkers"]()})),i.track_info=L.extend({},i.track_info,{type:"geojson",name:e.name}))}});return L.Control.Elevation._d3LazyLoader.then((function(){i._fireEvt("eledata_loaded",{data:e,layer:s,name:i.track_info.name,track_info:i.track_info})})),s}function l(e){return e&&"object"===t(e)&&!Array.isArray(e)}function h(e,i){if(i=void 0===i||i,"string"==typeof e&&i)return 0==(e=e.trim()).indexOf("{")||0==e.indexOf("[");try{JSON.parse(e.toString())}catch(a){return!("object"!==t(e)||!i)||(console.warn(a),!1)}return!0}function c(t,e){if(e=void 0===e||e,"string"==typeof t&&e)return 0==(t=t.trim()).indexOf("<");var i=(t?t.ownerDocument||t:0).documentElement;return!!i&&"HTML"!==i.nodeName}function d(t,e){var i=w("a","",{href:t,target:"_new",download:e||"",style:"display:none;"}),a=document.body;a.appendChild(i),i.click(),a.removeChild(i)}function u(t,e,i){return!1===e?Promise.resolve():i instanceof Promise?i:new Promise((function(e,i){var a=document.createElement("script");a.addEventListener("load",e,{once:!0}),a.src=t,document.head.appendChild(a)}))}function p(e,i){if(!i.options.lazyLoadJS)return Promise.resolve();var a=L.Control.Elevation,n="",r=!1;switch(e){case i.__D3:n="_d3LazyLoader",r="object"!==("undefined"==typeof d3?"undefined":t(d3));break;case i.__TOGEOJSON:n="_togeojsonLazyLoader",r="object"!==("undefined"==typeof toGeoJSON?"undefined":t(toGeoJSON));break;case i.__LGEOMUTIL:n="_geomutilLazyLoader",r="object"!==t(L.GeometryUtil);case i.__LALMOSTOVER:n="_almostoverLazyLoader",r="function "!=typeof L.Handler.AlmostOver;break;case i.__LDISTANCEM:n="_distanceMarkersLazyLoader",r="function"!=typeof L.DistanceMarkers}return a[n]=u(e,r,a[n])}function _(t,e){e.classed("canvas-path",!0),t.beginPath(),t.moveTo(0,0);var i=new Path2D(e.attr("d"));t.strokeStyle=e.attr("stroke"),t.fillStyle=e.attr("fill"),t.lineWidth=1.25,t.globalCompositeOperation="source-over",t.globalAlpha=e.attr("stroke-opacity")||.3,t.stroke(i),t.globalAlpha=e.attr("fill-opacity")||.45,t.fill(i),t.globalAlpha=1,t.closePath()}function m(t,e){return e?t<e[0]?e[0]:t>e[1]?e[1]:t:t}function f(t,e){t&&e.split(" ").every((function(e){return e&&L.DomUtil.addClass(t,e)}))}function g(t,e){t&&e.split(" ").every((function(e){return e&&L.DomUtil.removeClass(t,e)}))}function v(t,e,i){return(i?f:g).call(null,t,e)}function y(t,e,i){e&&g(t,e),i&&f(t,i)}function x(t,e,i){return void 0===i?L.DomUtil.getStyle(t,e):t.style.setProperty(e,i)}function b(t,e,i,a){return x(t,e,a?i:"")}function k(t,e,i,a){return t[a?"on":"off"](e,i)}function w(t,e,i,a){var n=L.DomUtil.create(t,e||"");return i&&A(n,i),a&&C(a,n),n}function C(t,e){return t.appendChild(e)}function M(t,e,i){return t.insertAdjacentElement(i,e)}function A(t,e){for(var i in e)t.setAttribute(i,e[i])}function S(t,e){return(e||document).querySelector(t)}var z=L.DomEvent.on,E=L.DomEvent.off,D=L.DomUtil.hasClass;function T(){return Math.random().toString(36).substr(2,9)}function F(t,e){for(var i in t)e(t[i],i)}var O,I=Object.freeze({__proto__:null,deepMerge:i,formatTime:o,GeoJSONLoader:s,isObject:l,isJSONDoc:h,isXMLDoc:c,saveFile:d,lazyLoader:u,lazyLoad:p,drawCanvas:_,clamp:m,addClass:f,removeClass:g,toggleClass:v,replaceClass:y,style:x,toggleStyle:b,toggleEvent:k,create:w,append:C,insert:M,setAttributes:A,select:S,on:z,off:E,hasClass:D,randomId:T,each:F}),N={lightblue:{area:"#3366CC",alpha:.45,stroke:"#3366CC"},magenta:{area:"#FF005E"},yellow:{area:"#FF0"},purple:{area:"#732C7B"},steelblue:{area:"#4682B4"},red:{area:"#F00"},lime:{area:"#9CC222",line:"#566B13"}},P=function(t){t.width;var e=t.height,i=t.xAttr,a=t.yAttr,n=t.scaleX,r=t.scaleY,o=t.interpolation,s=void 0===o?"curveLinear":o;return d3.area().curve("string"==typeof s?d3[s]:s).x((function(t){return t.xDiagCoord=n(t[i])})).y0(e).y1((function(t){return r(t[a])}))},B=function(t){var e=t.name,i=t.color,a=t.strokeColor,n=t.strokeOpacity,r=t.fillOpacity,o=d3.create("svg:path");return e&&o.classed(e,!0),o.style("pointer-events","none"),o.attr("fill",i||"#3366CC").attr("stroke",a||"#000").attr("stroke-opacity",n||"1").attr("fill-opacity",r||"0.8"),o},G=function(t){var e=t.type,i=void 0===e?"axis":e,a=t.tickSize,n=void 0===a?6:a,r=t.tickPadding,o=void 0===r?3:r,s=t.position,l=t.height,h=t.width,c=t.axis,d=t.scale,u=t.ticks,p=t.tickFormat,_=t.label,m=t.labelX,f=t.labelY,g=t.name,v=void 0===g?"":g,y=t.onAxisMount;return function(t){var e=0,a=0;"bottom"==s&&(a=l),"right"==s&&(e=h),"x"==c&&"grid"==i?n=-l:"y"==c&&"grid"==i&&(n=-h);var r=d3["axis"+s.replace(/\b\w/g,(function(t){return t.toUpperCase()}))]().scale(d).ticks(u).tickPadding(o).tickSize(n).tickFormat(p),g=t.append("g").attr("class",[c,i,s,v].join(" ")).attr("transform","translate("+e+","+a+")").call(r);return _&&g.append("svg:text").attr("x",m).attr("y",f).text(_),y&&g.call(y),g}},H=function(t){return t.type="grid",G(t)},X=function(t){var e=t.theme,i=t.xCoord,a=void 0===i?0:i,n=t.yCoord,r=void 0===n?0:n,o=t.labels,s=void 0===o?{}:o,l=t.item,h=void 0===l?{}:l,c=t.length,d=void 0===c?0:c;return function(t){var i,n=t.select(".height-focus.line"),o=t.select(".height-focus.circle-lower"),l=t.select(".height-focus-label");if(n.node()||(n=t.append("svg:line")),o.node()||(o=t.append("svg:circle")),l.node()||(l=t.append("svg:text")),isNaN(a)||isNaN(r))return t;for(var c in o.attr("class",e+" height-focus circle-lower").attr("transform","translate("+a+","+r+")").attr("r",6).attr("cx",0).attr("cy",0),n.attr("class",e+" height-focus line").attr("x1",a).attr("x2",a).attr("y1",r).attr("y2",d),l.attr("class",e+" height-focus-label").style("pointer-events","none").attr("x",a+5).attr("y",d),s)(i=l.select(".height-focus-"+s[c].name)).size()||(i=l.append("svg:tspan").attr("class","height-focus-"+s[c].name).attr("dy","1.5em")),i.text("function"!=typeof s[c].value?s[c].value:s[c].value(h));return l.select("tspan").attr("dy",l.selectAll("tspan").size()>1?"-1.5em":"0em"),l.selectAll("tspan").attr("x",a+5),t}},j=function(t){var e=t.name,i=t.label,a=t.width,n=t.height,r=t.margins,o=void 0===r?{}:r,s=t.color,l=t.path;return function(t){return t.attr("class","legend-item legend-"+e.toLowerCase()).attr("data-name",e),t.on("click.legend",(function(){return d3.select(t.node().ownerSVGElement||t).dispatch("legend_clicked",{detail:{path:l.node(),name:e,legend:t.node(),enabled:!l.classed("leaflet-hidden")}})})),t.append("svg:rect").attr("x",a/2-50).attr("y",n+o.bottom/2).attr("width",50).attr("height",10).attr("fill",s).attr("stroke","#000").attr("stroke-opacity","0.5").attr("fill-opacity","0.25"),t.append("svg:text").text(L._(i||e)).attr("x",a/2+5).attr("font-size",10).style("text-decoration-thickness","2px").style("font-weight","700").attr("y",n+o.bottom/2).attr("dy","0.75em"),t}},R=function(t){var e=t.xCoord,i=t.yCoord,a=t.width,n=t.height,r=t.labels,o=void 0===r?{}:r,s=t.item,l=void 0===s?{}:s;return function(t){var r=t.select(".mouse-focus-line"),s=t.select(".mouse-focus-label");r.node()||(r=t.append("svg:line")),s.node()||(s=t.append("g"));var h=s.select(".mouse-focus-label-rect"),c=s.select(".mouse-focus-label-text");h.node()||(h=s.append("svg:rect")),c.node()||(c=s.append("svg:text"));var d,u=0,p=0,_={width:0,height:0};try{_=c.node().getBBox()}catch(e){return t}for(var m in e&&(u=e+(e<a/2?10:-_.width-10)),i&&(p=Math.max(i-_.height,L.Browser.webkit?0:-1/0)),r.attr("class","mouse-focus-line").attr("x2",e).attr("y2",0).attr("x1",e).attr("y1",n),s.attr("class","mouse-focus-label"),h.attr("class","mouse-focus-label-rect").attr("x",u-5).attr("y",p-5).attr("width",_.width+10).attr("height",_.height+10).attr("rx",3).attr("ry",3),c.attr("class","mouse-focus-label-text").style("font-weight","700").attr("y",p),o)(d=c.select(".mouse-focus-label-"+o[m].name)).size()||(d=c.append("svg:tspan",".mouse-focus-label-x").attr("class","mouse-focus-label-"+o[m].name).attr("dy","1.5em")),d.text("function"!=typeof o[m].value?o[m].value:o[m].value(l));return c.select("tspan").attr("dy","1em"),c.selectAll("tspan").attr("x",u),t}},U=function(t){var e=t.height,i=t.width;return function(t){t.data([{x:0,y:e}]).attr("transform",(function(t){return"translate("+t.x+","+t.y+")"}));var a=t.selectAll(".horizontal-drag-rect").data([{w:i}]),n=t.selectAll(".horizontal-drag-line").data([{w:i}]),r=t.selectAll(".horizontal-drag-label").data([{w:i-8}]),o=t.selectAll(".horizontal-drag-symbol").data([{type:d3.symbolTriangle,x:i+7,y:0,angle:-90,size:50}]);return a.exit().remove(),n.exit().remove(),r.exit().remove(),o.exit().remove(),a.enter().append("svg:rect").attr("class","horizontal-drag-rect").attr("x",0).attr("y",-8).attr("height",8).attr("fill","none").attr("pointer-events","all").merge(a).attr("width",(function(t){return t.w})),n.enter().append("svg:line").attr("class","horizontal-drag-line").attr("x1",0).merge(n).attr("x2",(function(t){return t.w})),r.enter().append("svg:text").attr("class","horizontal-drag-label").attr("text-anchor","end").attr("y",-8).merge(r).attr("x",(function(t){return t.w})),o.enter().append("svg:path").attr("class","horizontal-drag-symbol").merge(o).attr("d",d3.symbol().type((function(t){return t.type})).size((function(t){return t.size}))).attr("transform",(function(t){return"translate("+t.x+","+t.y+") rotate("+t.angle+")"})),t}},J=function(t){var e=t.point,i=t.height,a=t.width,n=t.x,r=t.y;return function(t){return isNaN(n)||isNaN(r)||(e.item&&e.item.property("isConnected")||(e.position=e.position||"bottom",e.item=t.append("g"),e.item.append("svg:line").attr("y1",0).attr("x1",0).attr("style","stroke: rgb(51, 51, 51); stroke-width: 0.5; stroke-dasharray: 2, 2;"),e.item.append("svg:circle").attr("class"," height-focus circle-lower").attr("r",3),e.label&&e.item.append("svg:text").attr("dx","4px").attr("dy","-4px")),e.item.datum({pos:e.position,x:n,y:r}).attr("class",(function(t){return"point "+t.pos})).attr("transform",(function(t){return"translate("+t.x+","+t.y+")"})),e.item.select("line").datum({y2:{top:-r,bottom:i-r}[e.position],x2:{left:-n,right:a-n}[e.position]||0}).attr("y2",(function(t){return t.y2})).attr("x2",(function(t){return t.x2})),e.label&&e.item.select("text").text(e.label)),t}},Y=function(t){var e=t.min,i=t.max,a=t.attr,n=t.name,r=t.forceBounds,o=t.scale;return function(t){a=a||n,o&&o.attr&&(a=o.attr);var s=t&&t.length?d3.extent(t,(function(t){return t[a]})):[0,1];return void 0!==e&&(e<s[0]||r)&&(s[0]=e),void 0!==i&&(i>s[1]||r)&&(s[1]=i),s}},V=function(t){var e=t.axis;return function(t,i){return"x"==e?[0,t]:"y"==e?[i,0]:void 0}},W=function(t){var e=t.data,i=t.attr,a=t.min,n=t.max,r=t.forceBounds,o=t.range;return d3.scaleLinear().range(o).domain(Y({min:a,max:n,attr:i,forceBounds:r})(e))},Z=function(t){var e=t.width,i=t.height,a=t.margins,n=void 0===a?{}:a,r=(t.ruler,e-n.left-n.right),o=i-n.top-n.bottom,s=d3.create("svg:svg").attr("class","background"),l=s.append("g"),h={grid:l.append("g").attr("class","grid"),area:l.append("g").attr("class","area"),point:l.append("g").attr("class","point"),axis:l.append("g").attr("class","axis"),brush:l.append("g").attr("class","brush"),tooltip:l.append("g").attr("class","tooltip").attr("display","none"),ruler:l.append("g").attr("class","ruler"),legend:l.append("g").attr("class","legend")},c=h.area.append("svg:mask").attr("id","elevation-clipper").attr("fill-opacity",1),d=c.append("svg:rect").attr("class","zoom").attr("fill","white"),u=h.area.append("svg:foreignObject").attr("mask","url(#"+c.attr("id")+")"),p=u.append("xhtml:canvas").attr("class","canvas-plot"),_=p.node().getContext("2d");h.tooltip.call(R({xCoord:0,yCoord:0,height:o,width:r,labels:{}}));var m=d3.brushX().on("start.cursor end.cursor brush.cursor",(function(){return h.brush.select(".overlay").attr("cursor",null)})),f={mask:c,canvas:p,context:_,brush:m},g={svg:s,g:l,panes:h,utils:f,scale:function(t){return{x:W(t.x),y:W(t.y)}},_resize:function(t){var e=t.width,i=t.height,a=t.margins,n=void 0===a?{}:a,r=t.ruler,o=e-n.left-n.right,c=i-n.top-n.bottom;s.attr("viewBox","0 0 ".concat(e," ").concat(i)).attr("width",e).attr("height",i),l.attr("transform","translate("+n.left+","+n.top+")"),/Mac|iPod|iPhone|iPad/.test(navigator.platform)&&/AppleWebkit/i.test(navigator.userAgent)&&p.style("transform","translate("+n.left+"px,"+n.top+"px)"),d.attr("x",0).attr("y",0).attr("width",o).attr("height",c),u.attr("width",o).attr("height",c),p.attr("width",o).attr("height",c),r&&h.ruler.call(U({height:c,width:o})),h.brush.call(m.extent([[0,0],[o,c]])),h.brush.select(".overlay").attr("cursor",null),g._width=o,g._height=c,g.svg.dispatch("resize",{detail:{width:o,height:c}})},pane:function(t){return h[t]||(h[t]=l.append("g").attr("class",t)),h[t]},get:function(t){return f[t]}};return g._resize({width:e,height:i,margins:n}),g},q=Object.freeze({__proto__:null,Colors:N,Area:P,Path:B,Axis:G,Grid:H,PositionMarker:X,LegendItem:j,Tooltip:R,Ruler:U,CheckPoint:J,Domain:Y,Range:V,Scale:W,Bisect:function(t){var e=t.data,i=void 0===e?[0,1]:e,a=t.scale,n=t.x,r=t.attr;return d3.bisector((function(t){return t[r]})).left(i,a.invert(n))},Chart:Z}),K=L.Class.extend({includes:L.Evented?L.Evented.prototype:L.Mixin.Events,initialize:function(t,e){var i=this;this.options=t,this.control=e,this._data=[],this._props={scales:{},paths:{},areas:{},grids:{},axes:{},legendItems:{},tooltipItems:{}},this._scales={},this._domains={},this._ranges={},this._paths={},this._brushEnabled=t.dragging,this._zoomEnabled=t.zooming;var a=this._chart=Z(t);this._container=a.svg;this._grid=a.pane("grid"),this._area=a.pane("area"),this._point=a.pane("point"),this._axis=a.pane("axis"),this._legend=a.pane("legend"),this._tooltip=a.pane("tooltip"),this._ruler=a.pane("ruler"),this._initScale(),this._mask=a.get("mask"),this._context=a.get("context"),this._brush=a.get("brush"),this._zoom=d3.zoom(),this._drag=d3.drag(),this._initInteractions(),this._maskGaps=[],e.on("eletrack_added",(function(t){i._maskGaps.push(t.index),e.once("eledata_updated",(function(t){return i._maskGaps.push(t.index)}))}))},update:function(t){return t&&(t.data&&(this._data=t.data),t.options&&(this.options=t.options)),this._updateScale(),this._updateArea(),this._updateAxis(),this._updateLegend(),this._updateClipper(),this},render:function(){var t=this;return function(e){return e.append((function(){return t._container.node()}))}},clear:function(){this._resetDrag(),this._hideDiagramIndicator(),this._area.selectAll("path").attr("d","M0 0"),this._context.clearRect(0,0,this._width(),this._height()),this._maskGaps=[],this._mask.selectAll(".gap").remove()},_drawPath:function(t){var e=this._paths[t],i=this._props.areas[t];e.datum(this._data).attr("d",P(L.extend({},i,{width:this._width(),height:this._height(),scaleX:this._scales[i.scaleX],scaleY:this._scales[i.scaleY]}))),e.classed("leaflet-hidden")||(this.options.preferCanvas?_(this._context,e):this._area.append((function(){return e.node()})))},_hasActiveLayers:function(){var t=this._paths;for(var e in t)if(!t[e].classed("leaflet-hidden"))return!0;return!1},_initBrush:function(t){var e=this,i=function(t){if(e._data.length&&("brush"!=t.type||t.sourceEvent)){var i=e._chart.panes.brush.select(".overlay").node(),a=d3.pointers(t,i)[0][0],n=e._data[e._findIndexForXCoord(a)];e.fire("mouse_move",{item:n,xCoord:a})}};this._brush.filter((function(t){return e._brushEnabled&&!t.shiftKey&&!t.button})).on("end.update",(function(t){if(e._data.length){var i=t.selection;if(i){var a=e._findIndexForXCoord(i[0]),n=e._findIndexForXCoord(i[1]);e.fire("dragged",{dragstart:e._data[a],dragend:e._data[n]})}}})).on("brush.update",i),this._chart.panes.brush.on("mouseenter.focus touchstart.focus",this.fire.bind(this,"mouse_enter")).on("mouseout.focus touchend.focus",this.fire.bind(this,"mouse_out")).on("mousemove.focus touchmove.focus",i)},_initClipper:function(){var t=this,e=this._container,i=this.options.margins,a=this._zoom;a.scaleExtent([1,10]).extent([[i.left,0],[this._width()-i.right,this._height()]]).translateExtent([[i.left,-1/0],[this._width()-i.right,1/0]]).filter((function(e){return t._zoomEnabled&&(e.shiftKey||4==e.buttons)})).on("start",(function(i){i.sourceEvent&&"mousedown"==i.sourceEvent.type&&e.style("cursor","grabbing"),1==i.transform.k&&0==i.transform.x&&(t._container.classed("zoomed",!0),t._mask&&t._point.attr("mask","url(#"+t._mask.attr("id")+")")),t.zooming=!0})).on("end",(function(i){1==i.transform.k&&0==i.transform.x&&(t._container.classed("zoomed",!1),t._mask&&t._point.attr("mask",null)),t.zooming=!1,e.style("cursor","")})).on("zoom",(function(e){t.zooming=!1,t._updateScale(),t.zooming=!0,t._scales.distance=t._x=e.transform.rescaleX(t._x),t._resetDrag(),e.sourceEvent&&"mousemove"==e.sourceEvent.type&&t._hideDiagramIndicator(),t.fire("zoom")})),e.call(a)},_initInteractions:function(){this._initBrush(),this._initRuler(),this._initClipper(),this._initLegend()},_initLegend:function(){var t=this;this._container.on("legend_clicked",(function(e){var i=e.detail,a=i.path,n=i.legend,r=i.name,o=i.enabled;if(a){var s=S("text",n),l=S("rect",n);b(s,"text-decoration-line","line-through",o),b(l,"fill-opacity","0",o),v(a,"leaflet-hidden",o),t._updateArea(),t.fire("elepath_toggle",{path:a,name:r,legend:n,enabled:o})}}))},_initRuler:function(){var t=this;if(this.options.ruler){var e=d3.format(".0f"),i=this._drag;i.on("start end",(function(e,i){var a=t._height(),n=t._ruler.data()[0].y;(n>=a||n<=0)&&t._ruler.select(".horizontal-drag-label").text(""),t._hideDiagramIndicator()})).on("drag",(function(i,a){var n=t._height(),r=d3.pointers(i,t._area.node())[0][1],o=r>0?r<n?r:n:0,s=t._y.invert(o),l=L.extend(t._ruler.data()[0],{y:o});t._ruler.data([l]).attr("transform",(function(t){return"translate("+t.x+","+t.y+")"})).classed("active",o<n),t._container.select(".horizontal-drag-label").text(e(s)+" "+(t.options.imperial?"ft":"m")),t.fire("ruler_filter",{coords:r<n&&r>0?t._findCoordsForY(r):[]})})),this._ruler.call(i)}},_initScale:function(){var t=this.options;this._registerAxisScale({axis:"x",position:"bottom",attr:t.xAttr,min:t.xAxisMin,max:t.xAxisMax,name:"distance"}),this._registerAxisScale({axis:"y",position:"left",attr:t.yAttr,min:t.yAxisMin,max:t.yAxisMax,name:"altitude"}),this._x=this._scales.distance,this._y=this._scales.altitude},_registerAreaPath:function(t){var e=this.options;t.xAttr||(t.xAttr=e.xAttr),t.yAttr||(t.yAttr=e.yAttr),void 0===t.preferCanvas&&(t.preferCanvas=e.preferCanvas);var i=B(t);this._paths[t.name]=i,this._props.areas[t.name]=t,e.legend&&(this._props.legendItems[t.name]={name:t.name,label:t.label,color:t.color,path:i})},_registerAxisGrid:function(t){this._props.grids[t.name||t.axis]=t},_registerAxisScale:function(t){var e=this.options,i=t.scale;if("function"!=typeof i){(i=L.extend({data:this._data,forceBounds:e.forceAxisBounds},i)).attr=i.attr||t.name;var a=this._domains[t.name]=Y(t),n=this._ranges[t.name]=V(t);i.range=i.range||n(this._width(),this._height()),i.domain=i.domain||a(this._data),this._props.scales[t.name]=i,t.scale=this._scales[t.name]=W(i)}return t.ticks||("x"==t.axis?t.ticks=e.xTicks:"y"==t.axis&&(t.ticks=e.yTicks)),this._props.axes[t.name]=t,i},_registerCheckPoint:function(t){var e,i,a;this._data.length&&(t.latlng?(e=this._data[this._findIndexForLatLng(t.latlng)],i=this._x(e.dist),a=this._y(e.z)):isNaN(t.dist)||(i=this._x(t.dist),e=this._data[this._findIndexForXCoord(i)],a=this._y(e.z)),this._point.call(J({point:t,width:this._width(),height:this._height(),x:i,y:a})))},_registerTooltip:function(t){this._props.tooltipItems[t.name]=t},_updateArea:function(){var t=this._paths;for(var e in this._context.clearRect(0,0,this._width(),this._height()),t)t[e].classed("leaflet-hidden")||this._drawPath(e)},_updateAxis:function(){var t=this.options;this._grid.selectAll("g").remove(),this._axis.selectAll("g").remove();var e,i,a,n=this._props.grids,r=this._props.axes,o={width:this._width(),height:this._height(),tickFormat:""},s={width:this._width(),height:this._height()};for(var l in n)e=L.extend({},o,n[l]),a=H(e),this._grid.call(a);for(var h in r)!1!==t[h]&&"summary"!==t[h]&&(e=L.extend({},s,r[h]),i=G(e),this._axis.call(i));this._axis.selectAll(".y.axis.right").each((function(t,e,i){var a=d3.select(i[e]),n=a.attr("transform"),r=n.substring(n.indexOf("(")+1,n.indexOf(")")).split(",");a.attr("transform","translate("+(+r[0]+40*e)+","+r[1]+")"),e>0&&(a.select(":scope > path").attr("opacity",.25),a.selectAll(":scope > .tick line").attr("opacity",.75))}))},_updateClipper:function(){var t=this,e=this.options.margins;this._zoom.scaleExtent([1,10]).extent([[e.left,0],[this._width()-e.right,this._height()]]).translateExtent([[e.left,-1/0],[this._width()-e.right,1/0]]),this._mask.selectAll(".gap").remove(),this._maskGaps.forEach((function(e,i){if(!(i>=t._maskGaps.length-2)){var a=t._data[t._maskGaps[i]],n=t._data[t._maskGaps[i+1]],r=t._x(t._data[t._findIndexForLatLng(a.latlng)].dist),o=t._x(t._data[t._findIndexForLatLng(n.latlng)].dist);t._mask.append("rect").attr("x",r).attr("y",0).attr("width",o-r).attr("height",t._height()).attr("class","gap").attr("fill-opacity","0.8").attr("fill","black")}}))},_updateLegend:function(){var t=this;if(!1!==this.options.legend){var e,i=this._props.legendItems;for(var a in this._legend.selectAll("g").remove(),i)e=j(L.extend({width:this._width(),height:this._height(),margins:this.options.margins},i[a])),this._legend.append("g").call(e);var n=this._legend.selectAll(".legend-item"),r=n.nodes().length,o=Array(Math.floor(r/2)).fill(null).map((function(t,e){return 2*(e+1)-(1-Math.sign(r%2))})),s=o.slice().reverse().map((function(t){return-t}));r%2!=0&&s.push(0),o=s.concat(o);var l=this._axis.selectAll(".x.axis.bottom").nodes().length,h=30+2*l,c=30*r;r&&this.options.margins.right<c&&(this.options.margins.right=c,this.fire("margins_updated")),l&&this.options.margins.bottom<h&&(this.options.margins.bottom=h,this.fire("margins_updated")),n.each((function(e,i,a){var n=d3.select(a[i]),r=(n.select("rect"),n.attr("data-name")),s=t._paths[r],h=55*o[i],c=2*l;n.attr("transform","translate("+h+", "+c+")"),r in t.options&&"disabled"==t.options[r]&&(s.classed("leaflet-hidden",!0),n.select("text").style("text-decoration-line","line-through"),n.select("rect").style("fill-opacity","0")),t._mask&&s.attr("mask","url(#"+t._mask.attr("id")+")")}))}},_updateScale:function(){if(this.zooming)return{x:this._x,y:this._y};for(var t in this._scales)this._scales[t].domain(this._domains[t](this._data)).range(this._ranges[t](this._width(),this._height()));return{x:this._x,y:this._y}},_width:function(){return this._chart._width},_height:function(){return this._chart._height},_findCoordsForY:function(t){var e,i=this._data,a=this._y.invert(t),n=i.reduce((function(t,e,i){return e.z>=a&&t.push(i),t}),[]),r=0;return n.reduce((function(t,a,o){return n[e=o+1]===n[o]+1&&e!==n.length||(t.push(n.slice(r,e).map((function(t){return i[t].latlng}))),r=e),t}),[])},_findIndexForXCoord:function(t){var e=this;return d3.bisector((function(t){return t[e.options.xAttr]})).left(this._data||[0,1],this._x.invert(t))},_findIndexForLatLng:function(t){var e=null,i=1/0;return this._data.forEach((function(a,n){var r=t.distanceTo(a.latlng);r<i&&(i=r,e=n)})),e},_resetDrag:function(){this._chart.panes.brush.select(".selection").attr("width")&&(this._chart.panes.brush.call(this._brush.clear),this._hideDiagramIndicator(),this.fire("reset_drag"))},_resetZoom:function(){this._zoom&&this._zoom.transform(this._chart.svg,d3.zoomIdentity)},_showDiagramIndicator:function(t,e){this._tooltip.attr("display",null).call(R({xCoord:e,yCoord:this._y(t[this.options.yAttr]),height:this._height(),width:this._width(),labels:this._props.tooltipItems,item:t}))},_hideDiagramIndicator:function(){this._tooltip.attr("display","none")}}),Q=L.Class.extend({initialize:function(t){switch(this.options=t,this.options.marker){case"elevation-line":this._container=d3.select(map.getPane("elevationPane")).select("svg > g").attr("class","height-focus-group");break;case"position-marker":this._marker=L.marker([0,0],{icon:this.options.markerIcon,zIndexOffset:1e6,interactive:!1})}return this._labels={},this},addTo:function(t){switch(this._map=t,this.options.marker){case"elevation-line":this._container.call(X({}));break;case"position-marker":this._marker.addTo(t,{pane:"overlayPane"})}return this},update:function(t){if(t?this._props=t:t=this._props,t)switch(t.options&&(this.options=t.options),this._map||this.addTo(t.map),this._latlng=t.item.latlng,this.options.marker){case"elevation-line":var e=this._map.latLngToLayerPoint(this._latlng);e=L.extend({},t.item,this._map._rotate?this._map.rotatedPointToMapPanePoint(e):e),this._container.classed("leaflet-hidden",!1),this._container.call(X({theme:this.options.theme,xCoord:e.x,yCoord:e.y,length:e.y-this._height()/t.maxElevation*e.z,labels:this._labels,item:e}));break;case"position-marker":g(this._marker.getElement(),"leaflet-hidden"),this._marker.setLatLng(this._latlng)}},remove:function(){switch(this._props=null,this.options.marker){case"elevation-line":this._container&&this._container.classed("leaflet-hidden",!0);break;case"position-marker":f(this._marker.getElement(),"leaflet-hidden")}},getLatLng:function(){return this._latlng},_height:function(){var t=this.options;return t.height-t.margins.top-t.margins.bottom},_registerTooltip:function(t){this._labels[t.name]=t}}),$=L.Class.extend({initialize:function(t,e){this.options=t,this.control=e,x(this._container=w("div","elevation-summary "+(t.summary?t.summary+"-summary":"")),"max-width",t.width?t.width+"px":"")},render:function(){var t=this;return function(e){return e.append((function(){return t._container}))}},reset:function(){this._container.innerHTML=""},append:function(t,e,i){return this._container.innerHTML+='<span class="'.concat(t,'"><span class="summarylabel">').concat(e,'</span><span class="summaryvalue">').concat(i,"</span></span>"),this},_registerSummary:function(t){for(var e in t)this.append(e,L._(t[e].label),"function"!=typeof t[e].value?t[e].value:t[e].value(this.control.track_info))}}),tt={autofitBounds:!0,autohide:!L.Browser.mobile,autohideMarker:!0,almostover:!0,altitude:!0,collapsed:!1,detached:!0,distance:!0,distanceMarkers:!1,decimalsX:2,decimalsY:0,dragging:!L.Browser.mobile,downloadLink:"link",elevationDiv:"#elevation-div",followMarker:!0,forceAxisBounds:!1,height:200,imperial:!1,interpolation:"curveLinear",lazyLoadJS:!0,legend:!0,margins:{top:30,right:30,bottom:30,left:40},marker:"elevation-line",markerIcon:L.divIcon({className:"elevation-position-marker",html:'<i class="elevation-position-icon"></i>',iconSize:[32,32],iconAnchor:[16,16]}),position:"topright",polyline:{className:"elevation-polyline",color:"#000",opacity:.75,weight:5,lineCap:"round"},polylineSegments:{className:"elevation-polyline-segments",color:"#F00",interactive:!1},preferCanvas:!1,reverseCoords:!1,ruler:!0,skipNullZCoords:!1,theme:"lightblue-theme",summary:"inline",slope:!1,speed:!1,sLimit:void 0,time:!1,timeFactor:3600,timeFormat:!1,timestamps:!1,sDeltaMax:void 0,sInterpolation:"curveStepAfter",sRange:void 0,width:600,waypoints:!0,wptIcons:{"":L.divIcon({className:"elevation-waypoint-marker",html:'<i class="elevation-waypoint-icon"></i>',iconSize:[30,30],iconAnchor:[8,30]})},wptLabels:!0,xAttr:"dist",xLabel:"km",xTicks:void 0,yAttr:"z",yAxisMax:void 0,yAxisMin:void 0,yLabel:"m",yTicks:void 0,zFollow:!1,zooming:!L.Browser.Mobile},et=L.Control.Elevation=L.Control.extend({includes:L.Evented?L.Evented.prototype:L.Mixin.Events,options:tt,__mileFactor:.621371,__footFactor:3.28084,__D3:"https://unpkg.com/d3@6.5.0/dist/d3.min.js",__TOGEOJSON:"https://unpkg.com/@tmcw/togeojson@4.3.0/dist/togeojson.umd.js",__LGEOMUTIL:"https://unpkg.com/leaflet-geometryutil@0.9.3/src/leaflet.geometryutil.js",__LALMOSTOVER:"https://unpkg.com/leaflet-almostover@1.0.1/src/leaflet.almostover.js",__LDISTANCEM:"https://unpkg.com/@raruto/leaflet-elevation@1.8.2/libs/leaflet-distance-marker.min.js",addData:function(t,e){var i=this;this.lazyLoad(this.__D3).then((function(){void 0===e&&t.on&&(e=t),i._addData(t),i._addLayer(e),i._fireEvt("eledata_added",{data:t,layer:e,track_info:i.track_info})}))},addTo:function(t){if(this.options.detached){var e=this._initElevationDiv();e.isConnected||M(t.getContainer(),e,"afterend"),C(e,this.onAdd(t))}else L.Control.prototype.addTo.call(this,t);return this},clear:function(){this._marker&&this._marker.remove(),this._chart&&this._clearChart(),this._layers&&this._clearLayers(),this._markers&&this._clearMarkers(),this._data=[],this.track_info={},this._fireEvt("eledata_clear"),this._updateChart()},_clearChart:function(){var t=this;this._events&&this._events.elechart_updated&&this._events.elechart_updated.forEach((function(e){return t.off("elechart_updated",e.fn,e.ctx)})),this._chart&&this._chart._container&&(this._chart._container.selectAll("g.point .point").remove(),this._chart.clear())},_clearLayers:function(){this._layers&&this._layers.eachLayer&&(this._layers.eachLayer((function(t){return t.remove()})),this._layers.clearLayers())},_clearMarkers:function(){this._markers&&this._markers.eachLayer&&(this._markers.eachLayer((function(t){return t.remove()})),this._markers.clearLayers())},disableBrush:function(){this._chart._brushEnabled=!1,this._resetDrag()},enableBrush:function(){this._chart._brushEnabled=!0},disableZoom:function(){this._chart._zoomEnabled=!1,this._chart._resetZoom()},enableZoom:function(){this._chart._zoomEnabled=!0},fitBounds:function(t){t=t||this.getBounds(),this._map&&t.isValid()&&this._map.fitBounds(t)},getBounds:function(t){return t=t||this._data,L.latLngBounds(t.map((function(t){return t.latlng})))},getZFollow:function(){return this.options.zFollow},hide:function(){x(this._container,"display","none")},initialize:function(t){this._data=[],this._layers=L.featureGroup(),this._markers=L.featureGroup(),this._markedSegments=L.polyline([]),this._chartEnabled=!0,this.track_info={},this.options=i({},this.options,t),this.options.followMarker&&(this._setMapView=L.Util.throttle(this._setMapView,300,this)),this.options.legend&&(this.options.margins.bottom+=30),this.options.theme&&(this.options.polylineSegments.className+=" "+this.options.theme),!0===this.options.wptIcons&&(this.options.wptIcons=tt.wptIcons),this._markedSegments.setStyle(this.options.polylineSegments),L.extend(N,this.options.colors||{})},lazyLoad:function(t){return p(t,this)},load:function(t){c(t)?this.loadXML(t):h(t)?this.loadGeoJSON(t):this.loadFile(t)},loadFile:function(t){var e=this;fetch(t).then((function(t){return t.text()})).then((function(i){e._downloadURL=t,e.load(i)})).catch((function(t){return console.warn(t)}))},loadGeoJSON:function(t){s(t,this)},loadXML:function(t){var e=this;this.lazyLoad(this.__TOGEOJSON).then((function(){var i=(new DOMParser).parseFromString(t,"text/xml"),a=i.documentElement.tagName.toLowerCase();a in toGeoJSON||(a="TrainingCenterDatabase"==i.documentElement.tagName?"tcx":"gpx");var n=toGeoJSON[a](i),r=i.getElementsByTagName("name");return r[0]?n.name=r[0].innerHTML:e._downloadURL&&(n.name=e._downloadURL.split("/").pop().split("#")[0].split("?")[0]),e.loadGeoJSON(n,e)}))},onAdd:function(t){var e=this;this._map=t;var i=this._container=w("div","elevation-control elevation "+this.options.theme);return this.options.detached||f(i,"leaflet-control"),this.lazyLoad(this.__D3).then((function(){e._initButton(i),e._initChart(i),e._initSummary(i),e._initMarker(t),e._initLayer(t),t.on("zoom viewreset zoomanim",e._hideMarker,e).on("resize",e._resetView,e).on("resize",e._resizeChart,e).on("rotate",e._rotateMarker,e).on("mousedown",e._resetDrag,e),z(t.getContainer(),"mousewheel",e._resetDrag,e),z(t.getContainer(),"touchstart",e._resetDrag,e),e.on("eledata_added eledata_loaded",e._updateChart,e).on("eledata_added eledata_loaded",e._updateSummary,e),e._updateChart(),e._updateSummary()})),i},onRemove:function(t){this._container=null,t.off("zoom viewreset zoomanim",this._hideMarker,this).off("resize",this._resetView,this).off("resize",this._resizeChart,this).off("mousedown",this._resetDrag,this),E(t.getContainer(),"mousewheel",this._resetDrag,this),E(t.getContainer(),"touchstart",this._resetDrag,this),this.off("eledata_added eledata_loaded",this._updateChart,this).off("eledata_added eledata_loaded",this._updateSummary,this)},redraw:function(){this._resizeChart()},setZFollow:function(t){this.options.zFollow=t},show:function(){x(this._container,"display","block")},_addData:function(t){var e=this;if(t){var i=t.geometry;if(i)switch(i.type){case"LineString":this._addGeoJSONData(i.coordinates);break;case"MultiLineString":F(i.coordinates,(function(t){return e._addGeoJSONData(t)}));break;default:console.warn("Unsopperted GeoJSON feature geometry type:"+i.type)}"FeatureCollection"===t.type&&F(t.features,(function(t){return e._addData(t)})),t._latlngs&&this._addGPXData(t._latlngs)}},_addGeoJSONData:function(t){var e=this;F(t,(function(t){e._addPoint(t[1],t[0],t[2]),e._fireEvt("elepoint_added",{point:t,index:e._data.length-1})})),this._fireEvt("eletrack_added",{coords:t,index:this._data.length-1})},_addGPXData:function(t){var e=this;F(t,(function(t){var i;e._addPoint(t.lat,t.lng,null!==(i=t.alt)&&void 0!==i?i:t.meta.ele),e._fireEvt("elepoint_added",{point:t,index:e._data.length-1})})),this._fireEvt("eletrack_added",{coords:t,index:this._data.length-1})},_addPoint:function(t,e,i){if(this.options.reverseCoords){var a=[e,t];t=a[0],e=a[1]}this._data.push({x:t,y:e,z:i,latlng:L.latLng(t,e,i)}),this._fireEvt("eledata_updated",{index:this._data.length-1})},_addLayer:function(t){t&&this._layers.addLayer(t)},_addMarker:function(t){t&&this._markers.addLayer(t)},_initElevationDiv:function(){var t=S(this.options.elevationDiv);return t||(this.options.elevationDiv="#elevation-div_"+T(),t=w("div","leaflet-control elevation elevation-div",{id:this.options.elevationDiv.substr(1)})),this.options.detached&&y(t,"leaflet-control","elevation-detached"),this.eleDiv=t,this.eleDiv},_collapse:function(){y(this._container,"elevation-expanded","elevation-collapsed")},_expand:function(){y(this._container,"elevation-collapsed","elevation-expanded")},_findItemForLatLng:function(t){return this._data[this._chart._findIndexForLatLng(t)]},_findItemForX:function(t){return this._data[this._chart._findIndexForXCoord(t)]},_fireEvt:function(t,e,i){this.fire&&this.fire(t,e,i),this._map&&this._map.fire(t,e,i)},_height:function(){if(this._chart)return this._chart._height();var t=this.options;return t.height-t.margins.top-t.margins.bottom},_hideMarker:function(){this.options.autohideMarker&&this._marker.remove()},_initChart:function(t){var e=this.options;if(e.xTicks=this._xTicks(),e.yTicks=this._yTicks(),e.detached){var i=this.eleDiv,a=i.offsetWidth,n=i.offsetHeight;a>0&&(e.width=a),n>20&&(e.height=n-20)}else{var r=this._map.getContainer().clientWidth;e._maxWidth=e._maxWidth>e.width?e._maxWidth:e.width,this._container.style.maxWidth=e._maxWidth+"px",e._maxWidth>r&&(e.width=r-30)}var o=this._chart=new K(e,this);this._x=this._chart._x,this._y=this._chart._y,d3.select(t).call(o.render()),o.on("reset_drag",this._hideMarker,this).on("mouse_enter",this._fireEvt.bind("elechart_enter"),this).on("dragged",this._dragendHandler,this).on("mouse_move",this._mousemoveHandler,this).on("mouse_out",this._mouseoutHandler,this).on("ruler_filter",this._rulerFilterHandler,this).on("zoom",this._updateChart,this).on("elepath_toggle",this._toggleChartHandler,this).on("margins_updated",this._resizeChart,this),this._fireEvt("elechart_axis"),this.options.legend&&this._fireEvt("elechart_legend"),this._fireEvt("elechart_init")},_initLayer:function(){var t=this;this._layers.on("layeradd layerremove",(function(e){var i=e.layer;v(i.getElement&&i.getElement(),t.options.polyline.className+" "+t.options.theme,"layeradd"==e.type),k(i,"mousemove",t._mousemoveLayerHandler.bind(t),"layeradd"==e.type),k(i,"mouseout",t._mouseoutHandler.bind(t),"layeradd"==e.type)}))},_initMarker:function(t){var e=t.getPane("elevationPane");e||((e=this._pane=t.createPane("elevationPane",t.getPane("norotatePane")||t.getPane("mapPane"))).style.zIndex=625,e.style.pointerEvents="none"),this._renderer&&this._renderer.remove(),this._renderer=L.svg({pane:"elevationPane"}).addTo(this._map),this._marker=new Q(this.options),this._fireEvt("elechart_marker")},_initButton:function(t){if(t.setAttribute("aria-haspopup",!0),this.options.detached||L.DomEvent.disableClickPropagation(t).disableScrollPropagation(t),L.Browser.mobile&&z(t,"click",L.DomEvent.stopPropagation),z(t,"mousewheel",this._mousewheelHandler,this),!this.options.detached){var e=this._button=w("a","elevation-toggle elevation-toggle-icon"+(this.options.autohide?"":" close-button"),{href:"#",title:L._("Elevation")},t);this.options.collapsed&&(this._collapse(),this.options.autohide?(z(t,"mouseover",this._expand,this),z(t,"mouseout",this._collapse,this)):(z(e,"click",L.DomEvent.stop),z(e,"click",this._toggle,this)),z(e,"focus",this._toggle,this),this._map.on("click",this._collapse,this))}},_initSummary:function(t){var e=this._summary=new $({summary:this.options.summary},this);d3.select(t).call(e.render()),this.summaryDiv=this._summary._container},_dragendHandler:function(t){this._hideMarker(),this.fitBounds(L.latLngBounds([t.dragstart.latlng,t.dragend.latlng])),this._fireEvt("elechart_dragged")},_mousemoveHandler:function(t){if(this._data.length&&this._chartEnabled){var e=this._findItemForX(t.xCoord);if(e){var i=t.xCoord;this._chartEnabled&&this._chart._showDiagramIndicator(e,i),this._updateMarker(e),this._setMapView(e),this._map&&f(this._map.getContainer(),"elechart-hover"),this._fireEvt("elechart_change",{data:e,xCoord:i}),this._fireEvt("elechart_hover",{data:e,xCoord:i})}}},_mousemoveLayerHandler:function(t){if(this._data.length){var e=this._findItemForLatLng(t.latlng);if(e){var i=e.xDiagCoord;this._chartEnabled&&this._chart._showDiagramIndicator(e,i),this._updateMarker(e),this._fireEvt("elechart_change",{data:e,xCoord:i})}}},_mouseoutHandler:function(){this.options.detached||(this._hideMarker(),this._chart._hideDiagramIndicator()),this._map&&g(this._map.getContainer(),"elechart-hover"),this._fireEvt("elechart_leave")},_mousewheelHandler:function(t){if(!this._map.gestureHandling||!this._map.gestureHandling._enabled){var e=this._marker.getLatLng()||this._map.getCenter(),i=this._map.getZoom()+Math.sign(t.deltaY);this._resetDrag(),this._map.flyTo(e,i)}},_registerCheckPoint:function(t){var e=this;this.on("elechart_updated",(function(){return e._chart._registerCheckPoint(t)}))},_registerAreaPath:function(t){var e=this;this.on("elechart_init",(function(){return e._chart._registerAreaPath(t)}))},_registerAxisGrid:function(t){var e=this;this.on("elechart_axis",(function(){return e._chart._registerAxisGrid(t)}))},_registerAxisScale:function(t){var e=this;this.on("elechart_axis",(function(){return e._chart._registerAxisScale(t)}))},_registerTooltip:function(t){var e=this;if(t.chart){var i=L.extend({},t,{value:t.chart});this.on("elechart_init",(function(){return e._chart._registerTooltip(i)}))}if(t.marker){var a=L.extend({},t,{value:t.marker});this.on("elechart_marker",(function(){return e._marker._registerTooltip(a)}))}},_registerSummary:function(t){var e=this;this.on("elechart_summary",(function(){return e._summary._registerSummary(t)}))},_resetDrag:function(){this._chart._resetDrag(),this._hideMarker()},_resetView:function(){this._map&&this._map._isFullscreen||(this._resetDrag(),this._hideMarker(),this.options.autofitBounds&&this.fitBounds())},_resizeChart:function(){if(this._container&&"none"!=x(this._container,"display")){var t,e=this.options;if(e.detached)t=(this.eleDiv||this._container).offsetWidth;else{var i=this._map.getContainer().clientWidth;t=e._maxWidth>i?i-30:e._maxWidth}if(t){var a=this._chart;e.width=t,a&&a._chart&&(a._chart._resize(e),e.xTicks=this._xTicks(),e.yTicks=this._yTicks(),this._updateChart())}this._updateMapSegments()}},_rulerFilterHandler:function(t){this._updateMapSegments(t.coords)},_toggle:function(){D(this._container,"elevation-expanded")?this._collapse():this._expand()},_setMapView:function(t){if(this.options.followMarker&&this._map){var e=this._map.getZoom(),i=this.options.zFollow;"number"==typeof i?this._map.setView(t.latlng,e<i?i:e,{animate:!0,duration:.25}):this._map.getBounds().contains(t.latlng)||this._map.setView(t.latlng,e,{animate:!0,duration:.25})}},_toggleChartHandler:function(t){var e=this,i=(t.path,t.name),a=t.enabled;this._chartEnabled=this._chart._hasActiveLayers(),this._layers.eachLayer((function(t){v(t.getElement&&t.getElement(),e.options.polyline.className+" "+e.options.theme,e._chartEnabled)})),this.options[i]=a||"disabled"!=this.options[i]?"disabled":"enabled",this._chartEnabled||(this._chart._hideDiagramIndicator(),this._marker.remove())},_updateChart:function(){
|
|
2
2
|
/*!this._data.length ||*/
|
|
3
3
|
this._chart&&this._container&&(this._fireEvt("elechart_axis"),this._fireEvt("elechart_area"),this._chart.update({data:this._data,options:this.options}),this._x=this._chart._x,this._y=this._chart._y,this._fireEvt("elechart_updated"))},_updateMarker:function(t){this._marker&&this._marker.update({map:this._map,item:t,maxElevation:this.track_info.elevation_max||0,options:this.options})},_rotateMarker:function(){this._marker&&this._marker.update()},_updateMapSegments:function(t){this._markedSegments.setLatLngs(t||[]),t&&this._map&&!this._map.hasLayer(this._markedSegments)&&this._markedSegments.addTo(this._map)},_updateSummary:function(){var t=this;this._summary.reset(),this.options.summary&&this._fireEvt("elechart_summary"),this.options.downloadLink&&this._downloadURL&&(this.summaryDiv.innerHTML+='<span class="download"><a href="#">'+L._("Download")+"</a></span>",S(".download a",this.summaryDiv).onclick=function(e){e.preventDefault(),t._fireEvt("eletrack_download",{downloadLink:t.options.downloadLink,confirm:d.bind(t,t._downloadURL)})})},_width:function(){if(this._chart)return this._chart._width();var t=this.options;return t.width-t.margins.left-t.margins.right},_xTicks:function(){return this.__xTicks&&(this.__xTicks=this.options.xTicks),this.__xTicks||Math.round(this._width()/75)},_yTicks:function(){return this.__yTicks&&(this.__yTicks=this.options.yTicks),this.__yTicks||Math.round(this._height()/30)}});et.addInitHook((function(){this.enableDragging=this.enableBrush,this.disableDragging=this.disableBrush,this.loadChart=this.addTo,this.loadData=this.load,this.loadGPX=this.loadXML,this.on("waypoint_added",(function(t){var e=t.point,i=e._popup;i&&(i.options.className="elevation-popup"),i&&i._content&&(i._content=decodeURI(i._content),e.bindTooltip(i._content,{direction:"auto",sticky:!0,opacity:1,className:"elevation-tooltip"}).openTooltip())})),this.on("eletrack_download",(function(t){"modal"==t.downloadLink&&"function"==typeof CustomEvent?document.dispatchEvent(new CustomEvent("eletrack_download",{detail:t})):"link"!=t.downloadLink&&!0!==t.downloadLink||t.confirm()})),this.on("eledata_loaded",(function(t){var e=this,i=this._map,a=t.layer;i?(i.once("layeradd",(function(t){return e.options.autofitBounds&&e.fitBounds(a.getBounds())})),L.Browser.mobile?this.options.polyline&&a.addTo(i):this.lazyLoad(this.__LGEOMUTIL).then((function(){e.options.almostOver&&e.lazyLoad(e.__LALMOSTOVER).then((function(){i.addHandler("almostOver",L.Handler.AlmostOver),L.GeometryUtil&&i.almostOver&&i.almostOver.enabled()&&(i.almostOver.addLayer(a),i.on("almost:move",(function(t){return e._mousemoveLayerHandler(t)})).on("almost:out",(function(t){return e._mouseoutHandler(t)})))})),e.options.distanceMarkers?e.lazyLoad(e.__LDISTANCEM).then((function(){return e.options.polyline&&a.addTo(i)})):e.options.polyline&&a.addTo(i)}))):console.warn("Undefined elevation map object")}));var t=L.Canvas.prototype._fillStroke,e=this;L.Canvas.include({_fillStroke:function(i,a){if(e._layers.hasLayer(a)){var n=e.options.theme.replace("-theme",""),r=N[n]||{},o=a.options;if(o.color=r.line||r.area||n,o.stroke=!!o.color,t.call(this,i,a),o.stroke&&0!==o.weight){var s=i.globalCompositeOperation||"source-over";i.globalCompositeOperation="destination-over",i.strokeStyle=r.outline||"#FFF",i.lineWidth=1.75*o.weight,i.stroke(),i.globalCompositeOperation=s}}else t.call(this,i,a)}}),this.on("elechart_init",(function(){this.once("elechart_change elechart_hover",(function(t){this._chartEnabled&&(this._chart._showDiagramIndicator(t.data,t.xCoord),this._chart._showDiagramIndicator(t.data,t.xCoord)),this._updateMarker(t.data)}))}))})),et.addInitHook((function(){var t=this.options,e={};t.imperial?(t.altitudeFactor=this.__footFactor,e.label="ft"):(t.altitudeFactor=t.heightFactor||t.altitudeFactor||1,e.label=t.yLabel),this.on("eledata_updated",(function(e){var i=this._data,a=e.index,n=i[a].z*t.altitudeFactor,r=this.track_info,o=r.elevation_max||-1/0,s=r.elevation_min||1/0;if(!this.options.skipNullZCoords&&a>0){var l=i[a-1].z;if(isNaN(l)){var h=this._lastValidZ,c=n;if(isNaN(h)||isNaN(c)?isNaN(h)?isNaN(c)||(l=c):l=h:l=(h+c)/2,!isNaN(l))return i.splice(a-1,1);i[a-1].z=l}}isNaN(n)||(this._lastValidZ=n),r.elevation_max=n>o?n:o,r.elevation_min=n<s?n:s,i[a].z=n})),this.on("elechart_axis",(function(){this._chart._registerAxisGrid({axis:"y",position:"left",scale:this._chart._y})})),"summary"!=this.options.altitude&&(this.on("elechart_axis",(function(){this._chart._registerAxisScale({axis:"y",position:"left",scale:this._chart._y,label:e.label,labelX:-3,labelY:-8,name:"altitude"})})),this.on("elechart_init",(function(){var t=this.options.theme.replace("-theme",""),e=N[t]||{};this._chart._registerAreaPath({name:"altitude",label:"Altitude",scaleX:"distance",scaleY:"altitude",color:e.area||t,strokeColor:this.options.detached?e.stroke:"#000",strokeOpacity:"1",fillOpacity:this.options.detached?e.alpha||"0.8":1,preferCanvas:this.options.preferCanvas})}))),this._registerTooltip({name:"y",chart:function(i){return L._("y: ")+d3.format("."+t.decimalsY+"f")(i[t.yAttr])+" "+e.label},marker:function(i){return d3.format("."+t.decimalsY+"f")(i[t.yAttr])+" "+e.label}}),this._registerSummary({maxele:{label:"Max Elevation: ",value:function(t){return(t.elevation_max||0).toFixed(2)+" "+e.label}},minele:{label:"Min Elevation: ",value:function(t){return(t.elevation_min||0).toFixed(2)+" "+e.label}}})})),et.addInitHook((function(){var t=this.options,e={};t.imperial?(t.distanceFactor=this.__mileFactor,e.label="mi"):(t.distanceFactor=t.distanceFactor||1,e.label=t.xLabel),this.on("eledata_updated",(function(e){var i=this._data,a=e.index,n=this.track_info,r=n.distance||0,o=i[a].latlng,s=a>0?i[a-1].latlng:o,l=o.distanceTo(s)*t.distanceFactor;r+=Math.round(l/1e3*1e5)/1e5,n.distance=r,i[a].dist=r})),this.on("elechart_axis",(function(){this._chart._registerAxisGrid({axis:"x",position:"bottom",scale:this._chart._x})})),"summary"!=this.options.distance&&this.on("elechart_axis",(function(){var t=this;this._chart._registerAxisScale({axis:"x",position:"bottom",scale:this._chart._x,label:e.label,labelY:25,labelX:function(){return t._width()+6},name:"distance"})})),this._registerTooltip({name:"x",chart:function(i){return L._("x: ")+d3.format("."+t.decimalsX+"f")(i[t.xAttr])+" "+e.label}}),this._registerSummary({totlen:{label:"Total Length: ",value:function(t){return(t.distance||0).toFixed(2)+" "+e.label}}})})),et.addInitHook((function(){var t=this,e=this.options,i={};i.label=e.timeLabel||"t",e.timeFactor=e.timeFactor||3600,this._timeAVGSpeed=(e.timeAVGSpeed||3.6)*(e.speedFactor||1),e.timeFormat?"time"==e.timeFormat?e.timeFormat=function(t){return new Date(t).toLocaleTimeString()}:"date"==e.timeFormat&&(e.timeFormat=function(t){return new Date(t).toLocaleDateString()}):e.timeFormat=function(t){return new Date(t).toLocaleString().replaceAll("/","-").replaceAll(","," ")},e.xTimeFormat=e.xTimeFormat||function(t){return o(t).split("'")[0]},e.time&&"summary"!=e.time&&!L.Browser.mobile&&this._registerAxisScale({axis:"x",position:"top",scale:{attr:"duration",min:0},label:i.label,labelY:-10,labelX:function(){return t._width()},name:"time",tickFormat:function(t){return 0==t?"":e.xTimeFormat(t)},onAxisMount:function(e){e.select(".domain").remove(),e.selectAll("text").attr("opacity",.65).style("font-family","Monospace").style("font-size","110%"),e.selectAll(".tick line").attr("y2",t._height()).attr("stroke-dasharray",2).attr("opacity",.75)}}),this.on("elepoint_added",(function(t){var i=this._data,a=t.index;if(!t.point.meta||!t.point.meta.time){t.point.meta=t.point.meta||{};var n=i[a].dist-i[a>0?a-1:a].dist,r=this._timeAVGSpeed;t.point.meta.time=new Date(a>0?i[a-1].time.getTime()+n/r*e.timeFactor*1e3:Date.now())}var o=t.point.meta.time;o.getTime()-60*o.getTimezoneOffset()*1e3==0&&(o=0);var s=o,l=a>0?i[a-1].time:s,h=Math.abs(s-l),c=(this.track_info.time||0)+h;this.track_info.time=c,i[a].time=o,i[a].duration=c})),this.options.timestamps&&this._registerTooltip({name:"date",chart:function(e){return L._("t: ")+t.options.timeFormat(e.time)}}),this.options.time&&(this._registerTooltip({name:"time",chart:function(t){return L._("T: ")+o(t.duration||0)}}),this._registerSummary({tottime:{label:"Total Time: ",value:function(t){return o(t.time||0)}}}))})),et.addInitHook((function(){var t=this;if(this.options.slope){var e=this.options,i={};i.label=e.slopeLabel||"%","summary"!=this.options.slope&&(this._registerAxisScale({axis:"y",position:"right",scale:{min:-1,max:1},tickPadding:16,label:i.label,labelX:25,labelY:-8,name:"slope"}),this._registerAreaPath({name:"slope",label:"Slope",yAttr:"slope",scaleX:"distance",scaleY:"slope",color:"#F00",strokeColor:"#000",strokeOpacity:"0.5",fillOpacity:"0.25"})),this.on("eledata_updated",(function(t){var e=this._data,i=t.index,a=e[i].z,n=1e3*(e[i].dist-e[i>0?i-1:i].dist),r=this.track_info,o=r.ascent||0,s=r.descent||0,l=r.slope_max||0,h=r.slope_min||0,c=0;if(!isNaN(a)){var d=i>0?a-e[i-1].z:0;d>0?o+=d:d<0&&(s-=d),0!==n&&(c=d/n*100)}if(this.options.sDeltaMax){var u=i>0?c-e[i-1].slope:0,p=this.options.sDeltaMax;Math.abs(u)>p&&(c=e[i-1].slope+p*Math.sign(u))}c=m(c,this.options.sRange),r.ascent=o,r.descent=s,r.slope_max=c>l?c:l,r.slope_min=c<h?c:h,e[i].slope=L.Util.formatNum(c,2)})),this._registerTooltip({name:"slope",chart:function(t){return L._("m: ")+t.slope+i.label},marker:function(t){return Math.round(t.slope)+i.label}}),this._registerSummary({ascent:{label:"Total Ascent: ",value:function(e){return Math.round(e.ascent||0)+" "+(t.options.imperial?"ft":"m")}},descent:{label:"Total Descent: ",value:function(e){return Math.round(e.descent||0)+" "+(t.options.imperial?"ft":"m")}},minslope:{label:"Min Slope: ",value:function(t){return Math.round(t.slope_min||0)+" "+i.label}},maxslope:{label:"Max Slope: ",value:function(t){return Math.round(t.slope_max||0)+" "+i.label}}})}})),et.addInitHook((function(){if(this.options.speed||this.options.acceleration){var t=this.options,e={};e.label=t.speedLabel||L._(t.imperial?"mph":"km/h"),t.speedFactor=t.speedFactor||1,this.options.speed&&"summary"!=this.options.speed&&(this._registerAxisScale({axis:"y",position:"right",scale:{min:0,max:1},tickPadding:16,label:e.label,labelX:25,labelY:-8,name:"speed"}),this._registerAreaPath({name:"speed",label:"Speed",yAttr:"speed",scaleX:"distance",scaleY:"speed",color:"#03ffff",strokeColor:"#000",strokeOpacity:"0.5",fillOpacity:"0.25"})),this.on("elepoint_added",(function(e){var i=this._data,a=e.index,n=i[a].time,r=n-(a>0?i[a-1].time:n),o=this.track_info,s=o.speed_max||-1/0,l=o.speed_min||1/0,h=o.speed_avg||0,c=0;if(r>0){var d=1e3*(i[a].dist-i[a>0?a-1:a].dist);c=Math.abs(d/r*t.timeFactor)*t.speedFactor}if(this.options.speedDeltaMax){var u=a>0?c-i[a-1].speed:0,p=this.options.speedDeltaMax;Math.abs(u)>p&&(c=i[a-1].speed+p*Math.sign(u))}c=m(c,this.options.speedRange),o.speed_max=c>s?c:s,o.speed_min=c<l?c:l,o.speed_avg=(c+h)/2,i[a].speed=L.Util.formatNum(c,2)})),this.options.speed&&(this._registerTooltip({name:"speed",chart:function(t){return L._("v: ")+t.speed+" "+e.label},marker:function(t){return Math.round(t.speed)+" "+e.label}}),this._registerSummary({minspeed:{label:"Min Speed: ",value:function(t){return Math.round(t.speed_min||0)+" "+e.label}},maxspeed:{label:"Max Speed: ",value:function(t){return Math.round(t.speed_max||0)+" "+e.label}},avgspeed:{label:"Avg Speed: ",value:function(t){return Math.round(t.speed_avg||0)+" "+e.label}}}))}})),et.addInitHook((function(){if(this.options.acceleration){var t=this.options,e={};e.label=t.accelerationLabel||L._(t.imperial?"ft/s²":"m/s²"),t.accelerationFactor=t.accelerationFactor||1,"summary"!=this.options.acceleration&&(this._registerAxisScale({axis:"y",position:"right",scale:{min:0,max:1},tickPadding:16,label:e.label,labelX:25,labelY:-8,name:"acceleration"}),this._registerAreaPath({name:"acceleration",label:"Acceleration",yAttr:"acceleration",scaleX:"distance",scaleY:"acceleration",color:"#050402",strokeColor:"#000",strokeOpacity:"0.5",fillOpacity:"0.25"})),this.on("elepoint_added",(function(e){var i=this._data,a=e.index,n=i[a].time,r=(n-(a>0?i[a-1].time:n))/1e3,o=this.track_info,s=o.acceleration_max||-1/0,l=o.acceleration_min||1/0,h=o.acceleration_avg||0,c=0;if(r>0){var d=i[a].speed,u=(d-(a>0?i[a-1].speed:d))*(1e3/t.timeFactor);c=Math.abs(u/r)*t.accelerationFactor}if(this.options.accelerationDeltaMax){var p=a>0?c-i[a-1].acceleration:0,_=this.options.accelerationDeltaMax;Math.abs(p)>_&&(c=i[a-1].acceleration+_*Math.sign(p))}c=m(c,this.options.accelerationRange),o.acceleration_max=c>s?c:s,o.acceleration_min=c<l?c:l,o.acceleration_avg=(c+h)/2,i[a].acceleration=L.Util.formatNum(c,2)})),this._registerTooltip({name:"acceleration",chart:function(t){return L._("a: ")+t.acceleration+" "+e.label},marker:function(t){return Math.round(t.acceleration)+" "+e.label}}),this._registerSummary({minacceleration:{label:"Min Acceleration: ",value:function(t){return Math.round(t.acceleration_min||0)+" "+e.label}},maxacceleration:{label:"Max Acceleration: ",value:function(t){return Math.round(t.acceleration_max||0)+" "+e.label}},avgacceleration:{label:"Avg Acceleration: ",value:function(t){return Math.round(t.acceleration_avg||0)+" "+e.label}}})}})),et.Utils=I,et.Components=q,et.Chart=K,O=L.i18n.bind({}),L.i18n=L._=function(t,e){return L.locale&&L.locales[L.locale]&&""==L.locales[L.locale][t]&&(L.locales[L.locale][t]=""),O.call(null,t,e)},L.control.elevation=function(t){return new et(t)}}));
|
|
4
4
|
//# sourceMappingURL=leaflet-elevation.min.js.map
|