@wemap/routers 13.2.1 → 13.2.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.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var e=Object.defineProperty,t=(t,r,n)=>(((t,r,n)=>{r in t?e(t,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[r]=n})(t,"symbol"!=typeof r?r+"":r,n),n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("@wemap/geo"),n=require("@wemap/maths"),o=require("@wemap/logger"),i=require("@wemap/salesman.js"),s=require("@mapbox/polyline"),a=require("@turf/boolean-point-in-polygon"),l=require("@wemap/osm");const c=class e{constructor(n,o,i={},s=e.currentUniqueId++){t(this,"level"),t(this,"bearing"),t(this,"length"),this.vertex1=n,this.vertex2=o,this.properties=i,this.id=s,this.level=r.Level.union(n.coords.level,o.coords.level),this.length=this.vertex1.distanceTo(this.vertex2),this.bearing=this.vertex1.bearingTo(this.vertex2)}static getEdgeByVertices(e,t,r){return e.find((e=>t===e.vertex1&&r===e.vertex2||r===e.vertex1&&t===e.vertex2))}reverseProperties(){const{properties:e}=this;e.incline&&(e.incline="up"===e.incline?"down":"up"),e.isOneway&&(e.isOneway=!1)}};t(c,"currentUniqueId",0);let u=c;class d{constructor(e,t,r,n){this.origin=e,this.distanceFromNearestElement=t,this.coords=r,this.nearestElement=n}}class p{constructor(e,r={}){t(this,"id",-1),this.coords=e,this.properties=r}distanceTo(e){return this.coords.distanceTo(e.coords)}bearingTo(e){return this.coords.bearingTo(e.coords)}toJson(){return{id:this.id,coords:this.coords.toCompressedJson(),...Object.keys(this.properties).length>0&&{properties:this.properties}}}equals(e){return this.coords.equals(e.coords)}static fromJson(e){const t=new p(r.Coordinates.fromCompressedJson(e.coords),e.properties);return t.id=e.id,t}}class h{constructor(e,r,n=null,o=[]){t(this,"exitVertices"),this.vertices=e,this.edges=r,this.routingBounds=n,this.routingBoundsEntryPoints=o;const i=r.filter((e=>null===e.level)).map((e=>[e.vertex1,e.vertex2])).flat(),s=r.filter((e=>null!==e.level)).map((e=>[e.vertex1,e.vertex2])).flat();this.exitVertices=new Set(i.filter((e=>s.includes(e)))),null==o||o.forEach((e=>this.exitVertices.add(e)))}getEdgeByVertices(e,t){return u.getEdgeByVertices(this.edges,e,t)}getVertexByCoords(e){return h.getVertexByCoords(this.vertices,e)}static getVertexByCoords(e,t){return e.find((e=>e.coords.equals(t)))}getVertexByName(e){return this.vertices.find((t=>t.properties.name===e))}getVerticesByName(e){return this.vertices.filter((t=>t.properties.name===e))}getEdgeByName(e){return this.edges.find((t=>t.properties.name===e))}getEdgesByName(e){return this.edges.filter((t=>t.properties.name===e))}getBoundingBox(e){if(!this.vertices.length)return null;const t=r.BoundingBox.fromCoordinates(this.vertices.map((e=>e.coords)));return e&&t.extendsWithMeasure(e),t}getProjection(e,t={}){const o="maxDistance"in t,i=t.maxDistance,s="maxBearingAngle"in t;if(s&&(!(e instanceof r.UserPosition)||null===e.bearing))return null;const a=t.maxBearingAngle,l="acceptEdgeFn"in t,c=!("useMultiLevelSegments"in t)||t.useMultiLevelSegments;let u=null;const p=t=>{if(!(e instanceof r.UserPosition))return t;const n=e.clone();return n.lat=t.lat,n.lng=t.lng,n.level=t.level,n.alt=t.alt,n.heightFromFloor=t.heightFromFloor,n.heightFromGround=t.heightFromGround,n};return this.edges.forEach((h=>{if(l&&!t.acceptEdgeFn(h))return;if(!c&&r.Level.isRange(h.level))return;if(!r.Level.intersect(h.level,e.level))return;if(s&&n.diffAngleLines(h.bearing,e.bearing)>a)return;const m=e.getSegmentProjection(h.vertex1.coords,h.vertex2.coords);if(!m)return;const f=m.distanceTo(e);o&&f>i||f<((null==u?void 0:u.distanceFromNearestElement)??Number.MAX_VALUE)&&(u=new d(e,f,p(m),h))})),s||this.vertices.forEach((t=>{let n=t.coords;if(this.exitVertices.has(t)&&null===e.level&&(n=t.coords.clone(),n.level=null),!c&&r.Level.isRange(n.level))return;if(!r.Level.intersect(n.level,e.level))return;const s=n.distanceTo(e);s<r.Constants.EPS_MM?u=new d(e,0,p(n),t):o&&s>i||s<((null==u?void 0:u.distanceFromNearestElement)??Number.MAX_VALUE)&&(u=new d(e,s,p(n),t))})),u}toJson(){return{vertices:this.vertices.map((e=>e.toJson())),edges:this.edges.map((e=>({id:e.id,vertex1Idx:this.vertices.indexOf(e.vertex1),vertex2Idx:this.vertices.indexOf(e.vertex2),...Object.keys(e.properties).length>0&&{properties:e.properties}}))),...this.routingBounds&&{routingBounds:this.routingBounds},...this.routingBoundsEntryPoints.length>0&&{routingBoundsEntryPoints:this.routingBoundsEntryPoints.map((e=>e.id))}}}static fromJson(e){var t;const r=e.vertices.map((e=>p.fromJson(e))),n=e.edges.map((e=>new u(r[e.vertex1Idx],r[e.vertex2Idx],e.properties,e.id)));return new h(r,n,e.routingBounds,null==(t=e.routingBoundsEntryPoints)?void 0:t.map((e=>r[e])))}toCompressedJson(){return{vertices:this.vertices.map((e=>e.coords.toCompressedJson())),verticesIds:this.vertices.map((e=>e.id)),edges:this.edges.map((e=>{const t=this.vertices.indexOf(e.vertex1),r=this.vertices.indexOf(e.vertex2),n=e.properties;return Object.keys(n).length>0?[t,r,n]:[t,r]}))}}static fromCompressedJson(e){const t=e.vertices.map((e=>new p(r.Coordinates.fromCompressedJson(e)))),n=e.edges.map((e=>new u(t[e[0]],t[e[1]],e.length>2?e[2]:{})));return new h(t,n)}static fromCoordinatesSegments(e){const t=[],r=[],n=e=>{const r=t.find((t=>t.coords.equals(e)));if(r)return r;const n=new p(e);return t.push(n),n};for(const o of e){let e=null;for(const t of o){const o=n(t);e&&r.push(new u(o,e)),e=o}}return new h(t,r)}getEdgesAtLevel(e,t=!0){return this.edges.filter((({level:n})=>t?r.Level.intersect(e,n):r.Level.contains(e,n)))}toDetailedString(){let e=`--- Network ---\nVertices: ${this.vertices.length}\nEdges: ${this.edges.length}\n---\nVertices\n`;return this.vertices.forEach((t=>{e+=t.id;const r=t.properties;0!==Object.keys(r).length&&(e+=` ${r}`)})),e+="---\nEdges\n",this.edges.forEach((t=>{e+=`${t.id} - [v1: ${t.vertex1.id}, v2: ${t.vertex2.id}]`;const r=t.properties;0!==Object.keys(r).length&&(e+=` ${r}`)})),e+="---",e}}function m(e,t=5){return e/(1e3*t/3600)}function f(e){const t=n.positiveMod(n.rad2deg(e),360);return t>0&&t<60?"sharp-right":t>=60&&t<140?"right":t>=140&&t<160?"slight-right":t>=160&&t<=200?"straight":t>200&&t<=220?"slight-left":t>220&&t<=300?"left":t>300&&t<360?"sharp-left":"u-turn"}function g(e){return["AIRPLANE","BOAT","BUS","FERRY","FUNICULAR","METRO","MULTI","TRAIN","TRAM"].includes(e)}function v(e,t){return e===t||g(e)&&"TRANSIT"===t||"WALK"===e&&"TRANSIT"===t}function y(e){return{...e.firstStep&&{firstStep:!0},...e.lastStep&&{lastStep:!0},number:e.number,type:e.type,coords:e.coords.toCompressedJson(),...null!==e.name&&{name:e.name},angle:Number(e.angle.toFixed(2)),previousBearing:Number(e.previousBearing.toFixed(2)),nextBearing:Number(e.nextBearing.toFixed(2)),distance:Number(e.distance.toFixed(1)),duration:Number(e.duration.toFixed(1)),levelDifference:e.levelDifference,direction:e.direction}}function b(e){return{...e,coords:r.Coordinates.fromCompressedJson(e.coords),firstStep:Boolean(e.firstStep),lastStep:Boolean(e.lastStep),name:e.name||null,levelDifference:e.levelDifference||null}}function w(e){return!!e&&("up"===e.direction||"down"===e.direction)}class E extends h{constructor(e,t,r,n,o){super(r,n),this.start=e,this.end=t,this.vertices=r,this.edges=n,this.edgesWeights=o}reverse(){const e=this.vertices.slice().reverse(),t=this.edges.slice().reverse(),r=this.edgesWeights.slice().reverse();return t.map((e=>new u(e.vertex2,e.vertex1,e.properties))),new E(this.start,this.end,e,t,r)}static fromCoordinates(e,t,r){const n=h.fromCoordinatesSegments([r]),o=n.edges.map((e=>m(e.length)));return new E(e,t,n.vertices,n.edges,o)}get hasRoute(){return Boolean(this.vertices.length)}}const T=n.deg2rad(20);class N{constructor(){t(this,"start",null),t(this,"end",null),t(this,"pathCoords",null),t(this,"stepsInfo",[])}setStart(e){return this.start=e,this}setEnd(e){return this.end=e,this}setPathCoords(e){return this.pathCoords=e,this}setStepsInfo(e){return this.stepsInfo=e,this}addStepInfo(e){return this.stepsInfo.push(e),this}setGraphRoute(e){const t=[],{start:o,end:i}=e;if(!e.hasRoute)return this;let s=null,a=o.bearingTo(e.vertices[0].coords);for(let c=0;c<e.vertices.length-1;c++){const o=e.vertices[c],i=o.coords,l=e.vertices[c+1],u=l.coords,d=e.edges[c],p=o.bearingTo(l),h=n.diffAngle(a,p+Math.PI),m=t.length?t[t.length-1]:null,{isSubwayEntrance:g,isGate:v,subwayEntranceRef:y}=o.properties,{isElevator:b,areEscalators:E,areStairs:N,isMovingWalkway:_,incline:S}=d.properties;let x;!N&&!b||!S||null!==(null==m?void 0:m.levelDifference)&&void 0!==(null==m?void 0:m.levelDifference)||(x=S);const A=c>0?e.edges[c-1]:null,I=(null==A?void 0:A.properties)||{},O=Boolean(I.incline&&I.areStairs&&(!S||!N)),R=o.properties.isSubwayEntrance,C=d.properties.name||y||null,D=e.edgesWeights[c];let M=Math.abs(n.diffAngle(Math.PI,h))>=T;const L=r.Level.isRange(d.level)&&!r.Level.isRange(i.level)||x;M=M&&!(i.level&&r.Level.isRange(i.level));const k=w(m)&&!r.Level.isRange(i.level)||O;if(!s||(M||L||k||R)){let e=null,n="turn";b?n="elevator":E?n="escalator":N?n="stairs":g?n="subway-entrance":v?n="gate":_?n="moving-walkway":L&&(n="incline-plane");let o=f(h);L&&(e=r.Level.diff(i.level,u.level)||0,o=e>0?"up":"down",x&&(o=x)),s={coords:i,...C&&{name:C},type:n,direction:o,levelDifference:e,distance:0,duration:0},t.push(s)}s.distance+=i.distanceTo(u),s.duration+=D,a=p}const l=e.vertices[e.vertices.length-1].coords;return r.Coordinates.equals(l,i)||t.push({coords:l,type:"arrive",direction:null}),this.setStart(o),this.setEnd(i),this.setPathCoords(e.vertices.map((e=>e.coords))),this.setStepsInfo(t),this}build(){const{pathCoords:e,start:t,end:r}=this;if(!e)return o.warn('StepsBuilder: Missing "pathCoords" property to build steps'),[];if(!t)return o.warn('StepsBuilder: Missing "from" property to build steps'),[];if(!r)return o.warn('StepsBuilder: Missing "to" property to build steps'),[];0===this.stepsInfo.length&&this.setGraphRoute(E.fromCoordinates(t,r,e));const{stepsInfo:i}=this;return i.map(((o,s)=>{const a=e.findIndex((e=>e.equals(o.coords)));if(-1===a)throw new Error("Cannot find step coordinates in itinerary coordinates.");const l=0===a?t:e[a-1],c=a===e.length-1?r:e[a+1],u=l.bearingTo(o.coords),d=o.coords.bearingTo(c),p=n.diffAngle(u,d+Math.PI);let h=o.type;const g=o.direction||f(p),v=0===s;let y=0;const b=s===i.length-1,w=b?e[e.length-1]:i[s+1].coords;let E=a;for(;!e[E].equals(w);)y+=e[E].distanceTo(e[E+1]),E++;return h||(h="straight"===g?"continue":g.includes("left")||g.includes("right")||"u-turn"===g?"turn":v?"depart":b?"arrive":null),{coords:o.coords,direction:"transit"===h?null:g,type:h,levelDifference:void 0!==o.levelDifference?o.levelDifference:null,name:o.name||null,number:s+1,previousBearing:u,nextBearing:d,angle:p,firstStep:v,lastStep:b,distance:y,duration:o.duration||m(y)}}))}}class _{constructor({start:e,end:n,coords:o,transitMode:i,duration:s,startTime:a,endTime:l,transportInfo:c,steps:u}){t(this,"start"),t(this,"end"),t(this,"coords"),t(this,"distance"),t(this,"transitMode"),t(this,"duration"),t(this,"startTime"),t(this,"endTime"),t(this,"steps"),t(this,"transportInfo"),this.start={name:e.name||null,coords:e.coords},this.end={name:n.name||null,coords:n.coords},this.coords=o,this.transitMode=i,this.distance=r.Utils.calcDistance(o),this.duration="number"==typeof s?s:m(this.distance),this.startTime="number"==typeof a?a:null,this.endTime="number"==typeof l?l:null,this.transportInfo=c||null,this.steps=Array.isArray(u)?u:(new N).setStart(e.coords).setEnd(n.coords).setPathCoords(o).build()}isPublicTransport(){return g(this.transitMode)}toGraph(){return h.fromCoordinatesSegments([this.coords])}static equals(e,t){var r,n;if(!(e.transitMode===t.transitMode&&Math.abs(e.duration-t.duration)<=.05&&e.startTime===t.startTime&&e.endTime===t.endTime&&e.start.name===t.start.name&&e.start.coords.equals(t.start.coords)&&e.end.name===t.end.name&&e.end.coords.equals(t.end.coords)&&e.coords.length===t.coords.length&&(e.steps===t.steps||(null==(r=e.steps)?void 0:r.length)===(null==(n=t.steps)?void 0:n.length))))return!1;let o;for(o=0;o<e.coords.length;o++)if(!e.coords[o].equals(t.coords[o]))return!1;for(o=0;o<e.steps.length;o++)if(i=e.steps[o],s=t.steps[o],!(i.coords.equals(s.coords)&&Math.abs(i.angle-s.angle)<=.005&&Math.abs(i.distance-s.distance)<=.05&&Math.abs(i.duration-s.duration)<=.05&&i.firstStep===s.firstStep&&i.lastStep===s.lastStep&&i.levelDifference===s.levelDifference&&i.type===s.type&&i.direction===s.direction&&i.name===s.name&&Math.abs(i.nextBearing-s.nextBearing)<=.005&&i.number===s.number&&Math.abs(i.previousBearing-s.previousBearing)<=.005))return!1;var i,s;if(e.transportInfo!==t.transportInfo){if(null===e.transportInfo||null===t.transportInfo)return!1;if(e.transportInfo.name!==t.transportInfo.name||e.transportInfo.routeColor!==t.transportInfo.routeColor||e.transportInfo.routeTextColor!==t.transportInfo.routeTextColor||e.transportInfo.directionName!==t.transportInfo.directionName)return!1}return!0}equals(e){return _.equals(this,e)}toJson(){return{transitMode:this.transitMode,start:{coords:this.start.coords.toCompressedJson(),...this.start.name&&{name:this.start.name}},end:{coords:this.end.coords.toCompressedJson(),...this.end.name&&{name:this.end.name}},distance:Number(this.distance.toFixed(1)),duration:Number(this.duration.toFixed(1)),coords:this.coords.map((e=>e.toCompressedJson())),steps:this.steps.map(y),...null!==this.startTime&&{startTime:this.startTime},...null!==this.endTime&&{endTime:this.endTime},...null!==this.transportInfo&&{transportInfo:this.transportInfo}}}static fromJson(e){var t;return new _(Object.assign({},e,{start:{coords:r.Coordinates.fromCompressedJson(e.start.coords),name:e.start.name||null},end:{coords:r.Coordinates.fromCompressedJson(e.end.coords),name:e.end.name||null},coords:e.coords.map(r.Coordinates.fromCompressedJson),steps:(null==(t=e.steps)?void 0:t.map(b))||null}))}static fromGraphRoute(e,t="WALK"){return new _({start:{coords:e.start},end:{coords:e.end},coords:e.vertices.map((e=>e.coords)),duration:e.edgesWeights.reduce(((e,t)=>e+t),0),transitMode:t,steps:(new N).setGraphRoute(e).build()})}multiplyLevel(e){this.start.coords.level=r.Level.multiplyBy(this.start.coords.level,e),this.end.coords.level=r.Level.multiplyBy(this.end.coords.level,e);for(const t of this.coords)t.level=r.Level.multiplyBy(t.level,e);this.steps.forEach((t=>{t.coords.level=r.Level.multiplyBy(t.coords.level,e)}))}}class S{constructor({origin:e,destination:r,duration:n,legs:o,startTime:i,endTime:s}){t(this,"origin"),t(this,"destination"),t(this,"duration"),t(this,"legs"),t(this,"_transitMode",null),t(this,"startTime"),t(this,"endTime"),t(this,"_coords",null),t(this,"_distance",null),this.origin=e,this.destination=r,this.legs=o,this.duration="number"==typeof n?n:this.legs.reduce(((e,t)=>e+t.duration),0),this.startTime="number"==typeof i?i:null,this.endTime="number"==typeof s?s:null,this.updateStepsFromLegs()}set coords(e){throw new Error("Itinerary.coords cannot be set. They are calculated from Itinerary.legs.")}get coords(){return this._coords||(this._coords=this.legs.map((e=>e.coords)).flat().filter(((e,t,r)=>0===t||!r[t-1].equals(e)))),this._coords}set steps(e){throw new Error("Itinerary.step cannot be set. They are calculated from Itinerary.legs.")}get steps(){return this.legs.map((e=>e.steps)).flat()}set price(e){throw new Error("Itinerary.price cannot be set. They are calculated from Itinerary.legs.")}get price(){return this.legs.reduce(((e,t)=>{var r;return e+((null==(r=t.transportInfo)?void 0:r.price)||0)}),0)}set transitMode(e){throw new Error("Itinerary.transitMode cannot be set. They are calculated from Itinerary.legs.")}get transitMode(){if(!this._transitMode){const e=new Set(this.legs.map((e=>e.transitMode)));if(e.delete("WALK"),e.size>1)return this._transitMode="MULTI",this._transitMode;if(1===e.size)return this._transitMode=e.values().next().value,this._transitMode;this._transitMode="WALK"}return this._transitMode}set distance(e){throw new Error("Itinerary.distance cannot be set. They are calculated from Itinerary.legs.")}get distance(){return null===this._distance&&(this._distance=r.Utils.calcDistance(this.coords)),this._distance}toGraph(){return h.fromCoordinatesSegments([this.coords])}static fromItineraries(...e){return new S({origin:e[0].origin,destination:e[e.length-1].destination,legs:e.map((e=>e.legs)).flat()})}static fromOrderedPointsArray(e,t,n){const o=e=>new r.Coordinates(e[0],e[1],null,e[2]);return this.fromOrderedCoordinates(e.map(o),o(t),o(n))}static fromOrderedCoordinates(e,t,r,n="WALK"){const o=(new N).setPathCoords(e).setStart(t).setEnd(r).build(),i=new _({start:{coords:t},end:{coords:r},coords:e,transitMode:n,steps:o});return new S({origin:t,destination:r,legs:[i]})}static equals(e,t){if(!(e.origin.equals(t.origin)&&e.destination.equals(t.destination)&&Math.abs(e.distance-t.distance)<=.05&&Math.abs(e.duration-t.duration)<=.05&&e.startTime===t.startTime&&e.endTime===t.endTime&&e.legs.length===t.legs.length))return!1;for(let r=0;r<e.legs.length;r++)if(!e.legs[r].equals(t.legs[r]))return!1;return!0}equals(e){return S.equals(this,e)}toJson(){return{origin:this.origin.toJson(),destination:this.destination.toJson(),distance:Number(this.distance.toFixed(1)),duration:Number(this.duration.toFixed(1)),transitMode:this.transitMode,legs:this.legs.map((e=>e.toJson())),...null!==this.startTime&&{startTime:this.startTime},...null!==this.endTime&&{endTime:this.endTime}}}static fromJson(e){return new S({origin:r.Coordinates.fromJson(e.origin),destination:r.Coordinates.fromJson(e.destination),duration:e.duration,legs:e.legs.map(_.fromJson),startTime:e.startTime,endTime:e.endTime})}static fromGraphRoute(e,t="WALK"){const r=_.fromGraphRoute(e,t);return new S({origin:e.start,destination:e.end,legs:[r]})}multiplyLevel(e){this.origin.level=r.Level.multiplyBy(this.origin.level,e),this.destination.level=r.Level.multiplyBy(this.destination.level,e),this.legs.forEach((t=>t.multiplyLevel(e)))}forceUnknownLevelTo0(){this.origin.level=this.origin.level||0,this.destination.level=this.destination.level||0;for(const e of this.legs){e.start.coords.level=e.start.coords.level||0,e.end.coords.level=e.end.coords.level||0;for(const t of e.coords)t.level=t.level||0;if(e.steps)for(const t of e.steps)t.coords.level=t.coords.level||0}if(this._coords)for(const e of this._coords)e.level=e.level||0}toGeoJson(){const e=(e,t,r)=>({type:"Feature",properties:{name:t,level:e.level,...r&&{type:r}},geometry:{type:"Point",coordinates:[e.lng,e.lat]}}),t=[...new Set(this.coords.map((e=>r.Level.toString(e.level))))].map(r.Level.fromString).map((e=>[e,r.Utils.createSegmentsAtLevel(this.coords,e,!0)])).map((([e,t])=>((e,t)=>({type:"Feature",properties:{level:t,name:null==t?void 0:t.toString()},geometry:{type:"MultiLineString",coordinates:e.map((e=>e.map((({lat:e,lng:t})=>[t,e]))))}}))(t,e))),n=this.legs.map(((t,r)=>e(t.start.coords,`Leg ${r} start`,"leg-start"))),o=this.legs.map(((t,r)=>e(t.end.coords,`Leg ${r} end`,"leg-end"))),i=this.steps.map((t=>e(t.coords,`Step ${t.number}`,"step")));return{type:"FeatureCollection",features:[e(this.origin,"origin","origin"),e(this.destination,"destination","destination"),...t,...n,...o,...i]}}updateStepsFromLegs(){const e=this.coords.filter(((e,t,r)=>0===t||!r[t-1].equals(e))),t=this.legs.map((e=>e.steps)).flat();t.map(((r,o)=>{const i=e.findIndex((e=>e.equals(r.coords)));if(-1===i)throw new Error("Cannot find step coordinates in itinerary coordinates.");const s=0===i?this.origin:e[i-1],a=i===e.length-1?this.destination:e[i+1];r.previousBearing=s.bearingTo(r.coords),r.nextBearing=r.coords.bearingTo(a),r.angle=n.diffAngle(r.previousBearing,r.nextBearing+Math.PI);const l=r.distance;r.distance=0;const c=o!==t.length-1?t[o+1].coords:e[e.length-1];let u=i;for(;!e[u].equals(c);)r.distance+=e[u].distanceTo(e[u+1]),u++;if(u===e.length-1&&(r.distance+=e[u].distanceTo(this.destination)),r.number=o+1,r.firstStep=0===o,r.lastStep=o===t.length-1,"arrive"===r.type&&!r.lastStep||"depart"===r.type&&!r.firstStep){const e=r.direction;e&&(e.includes("left")||e.includes("right")||"u-turn"===e)?r.type="turn":r.type="continue"}r.duration+=m(r.distance-l)}))}}var x="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function A(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var I,O,R={exports:{}};I=R,O=R.exports,function(e,t){var r="function",n="undefined",o="object",i="string",s="major",a="model",l="name",c="type",u="vendor",d="version",p="architecture",h="console",m="mobile",f="tablet",g="smarttv",v="wearable",y="embedded",b="Amazon",w="Apple",E="ASUS",T="BlackBerry",N="Browser",_="Chrome",S="Firefox",x="Google",A="Huawei",R="LG",C="Microsoft",D="Motorola",M="Opera",L="Samsung",k="Sharp",U="Sony",P="Xiaomi",q="Zebra",B="Facebook",F="Chromium OS",j="Mac OS",G=function(e){for(var t={},r=0;r<e.length;r++)t[e[r].toUpperCase()]=e[r];return t},W=function(e,t){return typeof e===i&&-1!==H(t).indexOf(H(e))},H=function(e){return e.toLowerCase()},V=function(e,t){if(typeof e===i)return e=e.replace(/^\s\s*/,""),typeof t===n?e:e.substring(0,350)},$=function(e,n){for(var i,s,a,l,c,u,d=0;d<n.length&&!c;){var p=n[d],h=n[d+1];for(i=s=0;i<p.length&&!c&&p[i];)if(c=p[i++].exec(e))for(a=0;a<h.length;a++)u=c[++s],typeof(l=h[a])===o&&l.length>0?2===l.length?typeof l[1]==r?this[l[0]]=l[1].call(this,u):this[l[0]]=l[1]:3===l.length?typeof l[1]!==r||l[1].exec&&l[1].test?this[l[0]]=u?u.replace(l[1],l[2]):t:this[l[0]]=u?l[1].call(this,u,l[2]):t:4===l.length&&(this[l[0]]=u?l[3].call(this,u.replace(l[1],l[2])):t):this[l]=u||t;d+=2}},z=function(e,r){for(var n in r)if(typeof r[n]===o&&r[n].length>0){for(var i=0;i<r[n].length;i++)if(W(r[n][i],e))return"?"===n?t:n}else if(W(r[n],e))return"?"===n?t:n;return e},Y={ME:"4.90","NT 3.11":"NT3.51","NT 4.0":"NT4.0",2e3:"NT 5.0",XP:["NT 5.1","NT 5.2"],Vista:"NT 6.0",7:"NT 6.1",8:"NT 6.2",8.1:"NT 6.3",10:["NT 6.4","NT 10.0"],RT:"ARM"},K={browser:[[/\b(?:crmo|crios)\/([\w\.]+)/i],[d,[l,"Chrome"]],[/edg(?:e|ios|a)?\/([\w\.]+)/i],[d,[l,"Edge"]],[/(opera mini)\/([-\w\.]+)/i,/(opera [mobiletab]{3,6})\b.+version\/([-\w\.]+)/i,/(opera)(?:.+version\/|[\/ ]+)([\w\.]+)/i],[l,d],[/opios[\/ ]+([\w\.]+)/i],[d,[l,M+" Mini"]],[/\bopr\/([\w\.]+)/i],[d,[l,M]],[/(kindle)\/([\w\.]+)/i,/(lunascape|maxthon|netfront|jasmine|blazer)[\/ ]?([\w\.]*)/i,/(avant |iemobile|slim)(?:browser)?[\/ ]?([\w\.]*)/i,/(ba?idubrowser)[\/ ]?([\w\.]+)/i,/(?:ms|\()(ie) ([\w\.]+)/i,/(flock|rockmelt|midori|epiphany|silk|skyfire|bolt|iron|vivaldi|iridium|phantomjs|bowser|quark|qupzilla|falkon|rekonq|puffin|brave|whale(?!.+naver)|qqbrowserlite|qq|duckduckgo)\/([-\w\.]+)/i,/(heytap|ovi)browser\/([\d\.]+)/i,/(weibo)__([\d\.]+)/i],[l,d],[/(?:\buc? ?browser|(?:juc.+)ucweb)[\/ ]?([\w\.]+)/i],[d,[l,"UC"+N]],[/microm.+\bqbcore\/([\w\.]+)/i,/\bqbcore\/([\w\.]+).+microm/i],[d,[l,"WeChat(Win) Desktop"]],[/micromessenger\/([\w\.]+)/i],[d,[l,"WeChat"]],[/konqueror\/([\w\.]+)/i],[d,[l,"Konqueror"]],[/trident.+rv[: ]([\w\.]{1,9})\b.+like gecko/i],[d,[l,"IE"]],[/ya(?:search)?browser\/([\w\.]+)/i],[d,[l,"Yandex"]],[/(avast|avg)\/([\w\.]+)/i],[[l,/(.+)/,"$1 Secure "+N],d],[/\bfocus\/([\w\.]+)/i],[d,[l,S+" Focus"]],[/\bopt\/([\w\.]+)/i],[d,[l,M+" Touch"]],[/coc_coc\w+\/([\w\.]+)/i],[d,[l,"Coc Coc"]],[/dolfin\/([\w\.]+)/i],[d,[l,"Dolphin"]],[/coast\/([\w\.]+)/i],[d,[l,M+" Coast"]],[/miuibrowser\/([\w\.]+)/i],[d,[l,"MIUI "+N]],[/fxios\/([-\w\.]+)/i],[d,[l,S]],[/\bqihu|(qi?ho?o?|360)browser/i],[[l,"360 "+N]],[/(oculus|samsung|sailfish|huawei)browser\/([\w\.]+)/i],[[l,/(.+)/,"$1 "+N],d],[/(comodo_dragon)\/([\w\.]+)/i],[[l,/_/g," "],d],[/(electron)\/([\w\.]+) safari/i,/(tesla)(?: qtcarbrowser|\/(20\d\d\.[-\w\.]+))/i,/m?(qqbrowser|baiduboxapp|2345Explorer)[\/ ]?([\w\.]+)/i],[l,d],[/(metasr)[\/ ]?([\w\.]+)/i,/(lbbrowser)/i,/\[(linkedin)app\]/i],[l],[/((?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/([\w\.]+);)/i],[[l,B],d],[/(kakao(?:talk|story))[\/ ]([\w\.]+)/i,/(naver)\(.*?(\d+\.[\w\.]+).*\)/i,/safari (line)\/([\w\.]+)/i,/\b(line)\/([\w\.]+)\/iab/i,/(chromium|instagram)[\/ ]([-\w\.]+)/i],[l,d],[/\bgsa\/([\w\.]+) .*safari\//i],[d,[l,"GSA"]],[/musical_ly(?:.+app_?version\/|_)([\w\.]+)/i],[d,[l,"TikTok"]],[/headlesschrome(?:\/([\w\.]+)| )/i],[d,[l,_+" Headless"]],[/ wv\).+(chrome)\/([\w\.]+)/i],[[l,_+" WebView"],d],[/droid.+ version\/([\w\.]+)\b.+(?:mobile safari|safari)/i],[d,[l,"Android "+N]],[/(chrome|omniweb|arora|[tizenoka]{5} ?browser)\/v?([\w\.]+)/i],[l,d],[/version\/([\w\.\,]+) .*mobile\/\w+ (safari)/i],[d,[l,"Mobile Safari"]],[/version\/([\w(\.|\,)]+) .*(mobile ?safari|safari)/i],[d,l],[/webkit.+?(mobile ?safari|safari)(\/[\w\.]+)/i],[l,[d,z,{"1.0":"/8",1.2:"/1",1.3:"/3","2.0":"/412","2.0.2":"/416","2.0.3":"/417","2.0.4":"/419","?":"/"}]],[/(webkit|khtml)\/([\w\.]+)/i],[l,d],[/(navigator|netscape\d?)\/([-\w\.]+)/i],[[l,"Netscape"],d],[/mobile vr; rv:([\w\.]+)\).+firefox/i],[d,[l,S+" Reality"]],[/ekiohf.+(flow)\/([\w\.]+)/i,/(swiftfox)/i,/(icedragon|iceweasel|camino|chimera|fennec|maemo browser|minimo|conkeror|klar)[\/ ]?([\w\.\+]+)/i,/(seamonkey|k-meleon|icecat|iceape|firebird|phoenix|palemoon|basilisk|waterfox)\/([-\w\.]+)$/i,/(firefox)\/([\w\.]+)/i,/(mozilla)\/([\w\.]+) .+rv\:.+gecko\/\d+/i,/(polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf|sleipnir|obigo|mosaic|(?:go|ice|up)[\. ]?browser)[-\/ ]?v?([\w\.]+)/i,/(links) \(([\w\.]+)/i,/panasonic;(viera)/i],[l,d],[/(cobalt)\/([\w\.]+)/i],[l,[d,/master.|lts./,""]]],cpu:[[/(?:(amd|x(?:(?:86|64)[-_])?|wow|win)64)[;\)]/i],[[p,"amd64"]],[/(ia32(?=;))/i],[[p,H]],[/((?:i[346]|x)86)[;\)]/i],[[p,"ia32"]],[/\b(aarch64|arm(v?8e?l?|_?64))\b/i],[[p,"arm64"]],[/\b(arm(?:v[67])?ht?n?[fl]p?)\b/i],[[p,"armhf"]],[/windows (ce|mobile); ppc;/i],[[p,"arm"]],[/((?:ppc|powerpc)(?:64)?)(?: mac|;|\))/i],[[p,/ower/,"",H]],[/(sun4\w)[;\)]/i],[[p,"sparc"]],[/((?:avr32|ia64(?=;))|68k(?=\))|\barm(?=v(?:[1-7]|[5-7]1)l?|;|eabi)|(?=atmel )avr|(?:irix|mips|sparc)(?:64)?\b|pa-risc)/i],[[p,H]]],device:[[/\b(sch-i[89]0\d|shw-m380s|sm-[ptx]\w{2,4}|gt-[pn]\d{2,4}|sgh-t8[56]9|nexus 10)/i],[a,[u,L],[c,f]],[/\b((?:s[cgp]h|gt|sm)-\w+|sc[g-]?[\d]+a?|galaxy nexus)/i,/samsung[- ]([-\w]+)/i,/sec-(sgh\w+)/i],[a,[u,L],[c,m]],[/(?:\/|\()(ip(?:hone|od)[\w, ]*)(?:\/|;)/i],[a,[u,w],[c,m]],[/\((ipad);[-\w\),; ]+apple/i,/applecoremedia\/[\w\.]+ \((ipad)/i,/\b(ipad)\d\d?,\d\d?[;\]].+ios/i],[a,[u,w],[c,f]],[/(macintosh);/i],[a,[u,w]],[/\b(sh-?[altvz]?\d\d[a-ekm]?)/i],[a,[u,k],[c,m]],[/\b((?:ag[rs][23]?|bah2?|sht?|btv)-a?[lw]\d{2})\b(?!.+d\/s)/i],[a,[u,A],[c,f]],[/(?:huawei|honor)([-\w ]+)[;\)]/i,/\b(nexus 6p|\w{2,4}e?-[atu]?[ln][\dx][012359c][adn]?)\b(?!.+d\/s)/i],[a,[u,A],[c,m]],[/\b(poco[\w ]+)(?: bui|\))/i,/\b; (\w+) build\/hm\1/i,/\b(hm[-_ ]?note?[_ ]?(?:\d\w)?) bui/i,/\b(redmi[\-_ ]?(?:note|k)?[\w_ ]+)(?: bui|\))/i,/\b(mi[-_ ]?(?:a\d|one|one[_ ]plus|note lte|max|cc)?[_ ]?(?:\d?\w?)[_ ]?(?:plus|se|lite)?)(?: bui|\))/i],[[a,/_/g," "],[u,P],[c,m]],[/\b(mi[-_ ]?(?:pad)(?:[\w_ ]+))(?: bui|\))/i],[[a,/_/g," "],[u,P],[c,f]],[/; (\w+) bui.+ oppo/i,/\b(cph[12]\d{3}|p(?:af|c[al]|d\w|e[ar])[mt]\d0|x9007|a101op)\b/i],[a,[u,"OPPO"],[c,m]],[/vivo (\w+)(?: bui|\))/i,/\b(v[12]\d{3}\w?[at])(?: bui|;)/i],[a,[u,"Vivo"],[c,m]],[/\b(rmx[12]\d{3})(?: bui|;|\))/i],[a,[u,"Realme"],[c,m]],[/\b(milestone|droid(?:[2-4x]| (?:bionic|x2|pro|razr))?:?( 4g)?)\b[\w ]+build\//i,/\bmot(?:orola)?[- ](\w*)/i,/((?:moto[\w\(\) ]+|xt\d{3,4}|nexus 6)(?= bui|\)))/i],[a,[u,D],[c,m]],[/\b(mz60\d|xoom[2 ]{0,2}) build\//i],[a,[u,D],[c,f]],[/((?=lg)?[vl]k\-?\d{3}) bui| 3\.[-\w; ]{10}lg?-([06cv9]{3,4})/i],[a,[u,R],[c,f]],[/(lm(?:-?f100[nv]?|-[\w\.]+)(?= bui|\))|nexus [45])/i,/\blg[-e;\/ ]+((?!browser|netcast|android tv)\w+)/i,/\blg-?([\d\w]+) bui/i],[a,[u,R],[c,m]],[/(ideatab[-\w ]+)/i,/lenovo ?(s[56]000[-\w]+|tab(?:[\w ]+)|yt[-\d\w]{6}|tb[-\d\w]{6})/i],[a,[u,"Lenovo"],[c,f]],[/(?:maemo|nokia).*(n900|lumia \d+)/i,/nokia[-_ ]?([-\w\.]*)/i],[[a,/_/g," "],[u,"Nokia"],[c,m]],[/(pixel c)\b/i],[a,[u,x],[c,f]],[/droid.+; (pixel[\daxl ]{0,6})(?: bui|\))/i],[a,[u,x],[c,m]],[/droid.+ (a?\d[0-2]{2}so|[c-g]\d{4}|so[-gl]\w+|xq-a\w[4-7][12])(?= bui|\).+chrome\/(?![1-6]{0,1}\d\.))/i],[a,[u,U],[c,m]],[/sony tablet [ps]/i,/\b(?:sony)?sgp\w+(?: bui|\))/i],[[a,"Xperia Tablet"],[u,U],[c,f]],[/ (kb2005|in20[12]5|be20[12][59])\b/i,/(?:one)?(?:plus)? (a\d0\d\d)(?: b|\))/i],[a,[u,"OnePlus"],[c,m]],[/(alexa)webm/i,/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i,/(kf[a-z]+)( bui|\)).+silk\//i],[a,[u,b],[c,f]],[/((?:sd|kf)[0349hijorstuw]+)( bui|\)).+silk\//i],[[a,/(.+)/g,"Fire Phone $1"],[u,b],[c,m]],[/(playbook);[-\w\),; ]+(rim)/i],[a,u,[c,f]],[/\b((?:bb[a-f]|st[hv])100-\d)/i,/\(bb10; (\w+)/i],[a,[u,T],[c,m]],[/(?:\b|asus_)(transfo[prime ]{4,10} \w+|eeepc|slider \w+|nexus 7|padfone|p00[cj])/i],[a,[u,E],[c,f]],[/ (z[bes]6[027][012][km][ls]|zenfone \d\w?)\b/i],[a,[u,E],[c,m]],[/(nexus 9)/i],[a,[u,"HTC"],[c,f]],[/(htc)[-;_ ]{1,2}([\w ]+(?=\)| bui)|\w+)/i,/(zte)[- ]([\w ]+?)(?: bui|\/|\))/i,/(alcatel|geeksphone|nexian|panasonic(?!(?:;|\.))|sony(?!-bra))[-_ ]?([-\w]*)/i],[u,[a,/_/g," "],[c,m]],[/droid.+; ([ab][1-7]-?[0178a]\d\d?)/i],[a,[u,"Acer"],[c,f]],[/droid.+; (m[1-5] note) bui/i,/\bmz-([-\w]{2,})/i],[a,[u,"Meizu"],[c,m]],[/(blackberry|benq|palm(?=\-)|sonyericsson|acer|asus|dell|meizu|motorola|polytron)[-_ ]?([-\w]*)/i,/(hp) ([\w ]+\w)/i,/(asus)-?(\w+)/i,/(microsoft); (lumia[\w ]+)/i,/(lenovo)[-_ ]?([-\w]+)/i,/(jolla)/i,/(oppo) ?([\w ]+) bui/i],[u,a,[c,m]],[/(kobo)\s(ereader|touch)/i,/(archos) (gamepad2?)/i,/(hp).+(touchpad(?!.+tablet)|tablet)/i,/(kindle)\/([\w\.]+)/i,/(nook)[\w ]+build\/(\w+)/i,/(dell) (strea[kpr\d ]*[\dko])/i,/(le[- ]+pan)[- ]+(\w{1,9}) bui/i,/(trinity)[- ]*(t\d{3}) bui/i,/(gigaset)[- ]+(q\w{1,9}) bui/i,/(vodafone) ([\w ]+)(?:\)| bui)/i],[u,a,[c,f]],[/(surface duo)/i],[a,[u,C],[c,f]],[/droid [\d\.]+; (fp\du?)(?: b|\))/i],[a,[u,"Fairphone"],[c,m]],[/(u304aa)/i],[a,[u,"AT&T"],[c,m]],[/\bsie-(\w*)/i],[a,[u,"Siemens"],[c,m]],[/\b(rct\w+) b/i],[a,[u,"RCA"],[c,f]],[/\b(venue[\d ]{2,7}) b/i],[a,[u,"Dell"],[c,f]],[/\b(q(?:mv|ta)\w+) b/i],[a,[u,"Verizon"],[c,f]],[/\b(?:barnes[& ]+noble |bn[rt])([\w\+ ]*) b/i],[a,[u,"Barnes & Noble"],[c,f]],[/\b(tm\d{3}\w+) b/i],[a,[u,"NuVision"],[c,f]],[/\b(k88) b/i],[a,[u,"ZTE"],[c,f]],[/\b(nx\d{3}j) b/i],[a,[u,"ZTE"],[c,m]],[/\b(gen\d{3}) b.+49h/i],[a,[u,"Swiss"],[c,m]],[/\b(zur\d{3}) b/i],[a,[u,"Swiss"],[c,f]],[/\b((zeki)?tb.*\b) b/i],[a,[u,"Zeki"],[c,f]],[/\b([yr]\d{2}) b/i,/\b(dragon[- ]+touch |dt)(\w{5}) b/i],[[u,"Dragon Touch"],a,[c,f]],[/\b(ns-?\w{0,9}) b/i],[a,[u,"Insignia"],[c,f]],[/\b((nxa|next)-?\w{0,9}) b/i],[a,[u,"NextBook"],[c,f]],[/\b(xtreme\_)?(v(1[045]|2[015]|[3469]0|7[05])) b/i],[[u,"Voice"],a,[c,m]],[/\b(lvtel\-)?(v1[12]) b/i],[[u,"LvTel"],a,[c,m]],[/\b(ph-1) /i],[a,[u,"Essential"],[c,m]],[/\b(v(100md|700na|7011|917g).*\b) b/i],[a,[u,"Envizen"],[c,f]],[/\b(trio[-\w\. ]+) b/i],[a,[u,"MachSpeed"],[c,f]],[/\btu_(1491) b/i],[a,[u,"Rotor"],[c,f]],[/(shield[\w ]+) b/i],[a,[u,"Nvidia"],[c,f]],[/(sprint) (\w+)/i],[u,a,[c,m]],[/(kin\.[onetw]{3})/i],[[a,/\./g," "],[u,C],[c,m]],[/droid.+; (cc6666?|et5[16]|mc[239][23]x?|vc8[03]x?)\)/i],[a,[u,q],[c,f]],[/droid.+; (ec30|ps20|tc[2-8]\d[kx])\)/i],[a,[u,q],[c,m]],[/smart-tv.+(samsung)/i],[u,[c,g]],[/hbbtv.+maple;(\d+)/i],[[a,/^/,"SmartTV"],[u,L],[c,g]],[/(nux; netcast.+smarttv|lg (netcast\.tv-201\d|android tv))/i],[[u,R],[c,g]],[/(apple) ?tv/i],[u,[a,w+" TV"],[c,g]],[/crkey/i],[[a,_+"cast"],[u,x],[c,g]],[/droid.+aft(\w)( bui|\))/i],[a,[u,b],[c,g]],[/\(dtv[\);].+(aquos)/i,/(aquos-tv[\w ]+)\)/i],[a,[u,k],[c,g]],[/(bravia[\w ]+)( bui|\))/i],[a,[u,U],[c,g]],[/(mitv-\w{5}) bui/i],[a,[u,P],[c,g]],[/Hbbtv.*(technisat) (.*);/i],[u,a,[c,g]],[/\b(roku)[\dx]*[\)\/]((?:dvp-)?[\d\.]*)/i,/hbbtv\/\d+\.\d+\.\d+ +\([\w\+ ]*; *([\w\d][^;]*);([^;]*)/i],[[u,V],[a,V],[c,g]],[/\b(android tv|smart[- ]?tv|opera tv|tv; rv:)\b/i],[[c,g]],[/(ouya)/i,/(nintendo) ([wids3utch]+)/i],[u,a,[c,h]],[/droid.+; (shield) bui/i],[a,[u,"Nvidia"],[c,h]],[/(playstation [345portablevi]+)/i],[a,[u,U],[c,h]],[/\b(xbox(?: one)?(?!; xbox))[\); ]/i],[a,[u,C],[c,h]],[/((pebble))app/i],[u,a,[c,v]],[/(watch)(?: ?os[,\/]|\d,\d\/)[\d\.]+/i],[a,[u,w],[c,v]],[/droid.+; (glass) \d/i],[a,[u,x],[c,v]],[/droid.+; (wt63?0{2,3})\)/i],[a,[u,q],[c,v]],[/(quest( 2| pro)?)/i],[a,[u,B],[c,v]],[/(tesla)(?: qtcarbrowser|\/[-\w\.]+)/i],[u,[c,y]],[/(aeobc)\b/i],[a,[u,b],[c,y]],[/droid .+?; ([^;]+?)(?: bui|\) applew).+? mobile safari/i],[a,[c,m]],[/droid .+?; ([^;]+?)(?: bui|\) applew).+?(?! mobile) safari/i],[a,[c,f]],[/\b((tablet|tab)[;\/]|focus\/\d(?!.+mobile))/i],[[c,f]],[/(phone|mobile(?:[;\/]| [ \w\/\.]*safari)|pda(?=.+windows ce))/i],[[c,m]],[/(android[-\w\. ]{0,9});.+buil/i],[a,[u,"Generic"]]],engine:[[/windows.+ edge\/([\w\.]+)/i],[d,[l,"EdgeHTML"]],[/webkit\/537\.36.+chrome\/(?!27)([\w\.]+)/i],[d,[l,"Blink"]],[/(presto)\/([\w\.]+)/i,/(webkit|trident|netfront|netsurf|amaya|lynx|w3m|goanna)\/([\w\.]+)/i,/ekioh(flow)\/([\w\.]+)/i,/(khtml|tasman|links)[\/ ]\(?([\w\.]+)/i,/(icab)[\/ ]([23]\.[\d\.]+)/i,/\b(libweb)/i],[l,d],[/rv\:([\w\.]{1,9})\b.+(gecko)/i],[d,l]],os:[[/microsoft (windows) (vista|xp)/i],[l,d],[/(windows) nt 6\.2; (arm)/i,/(windows (?:phone(?: os)?|mobile))[\/ ]?([\d\.\w ]*)/i,/(windows)[\/ ]?([ntce\d\. ]+\w)(?!.+xbox)/i],[l,[d,z,Y]],[/(win(?=3|9|n)|win 9x )([nt\d\.]+)/i],[[l,"Windows"],[d,z,Y]],[/ip[honead]{2,4}\b(?:.*os ([\w]+) like mac|; opera)/i,/ios;fbsv\/([\d\.]+)/i,/cfnetwork\/.+darwin/i],[[d,/_/g,"."],[l,"iOS"]],[/(mac os x) ?([\w\. ]*)/i,/(macintosh|mac_powerpc\b)(?!.+haiku)/i],[[l,j],[d,/_/g,"."]],[/droid ([\w\.]+)\b.+(android[- ]x86|harmonyos)/i],[d,l],[/(android|webos|qnx|bada|rim tablet os|maemo|meego|sailfish)[-\/ ]?([\w\.]*)/i,/(blackberry)\w*\/([\w\.]*)/i,/(tizen|kaios)[\/ ]([\w\.]+)/i,/\((series40);/i],[l,d],[/\(bb(10);/i],[d,[l,T]],[/(?:symbian ?os|symbos|s60(?=;)|series60)[-\/ ]?([\w\.]*)/i],[d,[l,"Symbian"]],[/mozilla\/[\d\.]+ \((?:mobile|tablet|tv|mobile; [\w ]+); rv:.+ gecko\/([\w\.]+)/i],[d,[l,S+" OS"]],[/web0s;.+rt(tv)/i,/\b(?:hp)?wos(?:browser)?\/([\w\.]+)/i],[d,[l,"webOS"]],[/watch(?: ?os[,\/]|\d,\d\/)([\d\.]+)/i],[d,[l,"watchOS"]],[/crkey\/([\d\.]+)/i],[d,[l,_+"cast"]],[/(cros) [\w]+(?:\)| ([\w\.]+)\b)/i],[[l,F],d],[/panasonic;(viera)/i,/(netrange)mmh/i,/(nettv)\/(\d+\.[\w\.]+)/i,/(nintendo|playstation) ([wids345portablevuch]+)/i,/(xbox); +xbox ([^\);]+)/i,/\b(joli|palm)\b ?(?:os)?\/?([\w\.]*)/i,/(mint)[\/\(\) ]?(\w*)/i,/(mageia|vectorlinux)[; ]/i,/([kxln]?ubuntu|debian|suse|opensuse|gentoo|arch(?= linux)|slackware|fedora|mandriva|centos|pclinuxos|red ?hat|zenwalk|linpus|raspbian|plan 9|minix|risc os|contiki|deepin|manjaro|elementary os|sabayon|linspire)(?: gnu\/linux)?(?: enterprise)?(?:[- ]linux)?(?:-gnu)?[-\/ ]?(?!chrom|package)([-\w\.]*)/i,/(hurd|linux) ?([\w\.]*)/i,/(gnu) ?([\w\.]*)/i,/\b([-frentopcghs]{0,5}bsd|dragonfly)[\/ ]?(?!amd|[ix346]{1,2}86)([\w\.]*)/i,/(haiku) (\w+)/i],[l,d],[/(sunos) ?([\w\.\d]*)/i],[[l,"Solaris"],d],[/((?:open)?solaris)[-\/ ]?([\w\.]*)/i,/(aix) ((\d)(?=\.|\)| )[\w\.])*/i,/\b(beos|os\/2|amigaos|morphos|openvms|fuchsia|hp-ux|serenityos)/i,/(unix) ?([\w\.]*)/i],[l,d]]},J=function(h,g){if(typeof h===o&&(g=h,h=t),!(this instanceof J))return new J(h,g).getResult();var v=typeof e!==n&&e.navigator?e.navigator:t,y=h||(v&&v.userAgent?v.userAgent:""),b=v&&v.userAgentData?v.userAgentData:t,w=g?function(e,t){var r={};for(var n in e)t[n]&&t[n].length%2==0?r[n]=t[n].concat(e[n]):r[n]=e[n];return r}(K,g):K,E=v&&v.userAgent==y;return this.getBrowser=function(){var e,n={};return n[l]=t,n[d]=t,$.call(n,y,w.browser),n[s]=typeof(e=n[d])===i?e.replace(/[^\d\.]/g,"").split(".")[0]:t,E&&v&&v.brave&&typeof v.brave.isBrave==r&&(n[l]="Brave"),n},this.getCPU=function(){var e={};return e[p]=t,$.call(e,y,w.cpu),e},this.getDevice=function(){var e={};return e[u]=t,e[a]=t,e[c]=t,$.call(e,y,w.device),E&&!e[c]&&b&&b.mobile&&(e[c]=m),E&&"Macintosh"==e[a]&&v&&typeof v.standalone!==n&&v.maxTouchPoints&&v.maxTouchPoints>2&&(e[a]="iPad",e[c]=f),e},this.getEngine=function(){var e={};return e[l]=t,e[d]=t,$.call(e,y,w.engine),e},this.getOS=function(){var e={};return e[l]=t,e[d]=t,$.call(e,y,w.os),E&&!e[l]&&b&&"Unknown"!=b.platform&&(e[l]=b.platform.replace(/chrome os/i,F).replace(/macos/i,j)),e},this.getResult=function(){return{ua:this.getUA(),browser:this.getBrowser(),engine:this.getEngine(),os:this.getOS(),device:this.getDevice(),cpu:this.getCPU()}},this.getUA=function(){return y},this.setUA=function(e){return y=typeof e===i&&e.length>350?V(e,350):e,this},this.setUA(y),this};J.VERSION="1.0.35",J.BROWSER=G([l,d,s]),J.CPU=G([p]),J.DEVICE=G([a,u,c,h,m,g,f,v,y]),J.ENGINE=J.OS=G([l,d]),I.exports&&(O=I.exports=J),O.UAParser=J;var X=typeof e!==n&&(e.jQuery||e.Zepto);if(X&&!X.ua){var Q=new J;X.ua=Q.getResult(),X.ua.get=function(){return Q.getUA()},X.ua.set=function(e){Q.setUA(e);var t=Q.getResult();for(var r in t)X.ua[r]=t[r]}}}("object"==typeof window?window:x);var C=Object.defineProperty,D=(e,t,r)=>(((e,t,r)=>{t in e?C(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(e,"symbol"!=typeof t?t+"":t,r),r);const M="Unknown",L="Safari",k="Firefox",U="Opera",P="Chrome",q="iOS-webview";class B{static getName(){if(!this._name)if("undefined"!=typeof navigator&&navigator){const{userAgent:e}=navigator;e.match(/Firefox/i)?this._name=k:e.match(/(Opera|OPR)/i)?this._name=U:e.match(/Chrome/i)?this._name=P:e.match(/Safari/i)?this._name=L:e.match(/(iPhone|iPod|iPad).*AppleWebKit(?!.*Version)/i)?this._name=q:this._name=M}else this._name=M;return this._name}static get isMobile(){if(null===this._isMobile&&(this._isMobile=!1,"undefined"!=typeof navigator&&navigator)){const e=navigator.userAgent||navigator.vendor;e&&(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(e)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(e.substr(0,4)))&&(this._isMobile=!0)}return this._isMobile}static clearCache(){this._name=null,this._isMobile=null}}D(B,"_name",null),D(B,"_isMobile",null);const F=[4215763,14529296,11869460,48895,16468400,45661,13290186];const j=Object.freeze(Object.defineProperty({__proto__:null,getQualitativeColor:function(e){return F[e%F.length]}},Symbol.toStringTag,{value:"Module"}));const G=Object.freeze(Object.defineProperty({__proto__:null,formatSO:function(e,...t){let r=e.toString();if(t.length){const e=typeof t[0],n="string"===e||"number"===e?t.slice():t[0];for(const t in n)r=r.replace(new RegExp("\\{"+t+"\\}","gi"),n[t])}return r},toUpperCase:function(e){return e.toUpperCase()}},Symbol.toStringTag,{value:"Module"})),W=4,H=3,V={wheelchair:{horrible:.1,bad:.5,intermediate:.7,good:.9,excellent:1},default:{horrible:.4,bad:.7,intermediate:.8,good:.9,excellent:1}},$={wheelchair:{asphalt:1,concrete:1,paved:1,paving_stones:.8,compacted:.7,wood:.6,metal:.5,gravel:.3,grass:.2,ground:.2},default:{asphalt:1,concrete:1,paved:1,paving_stones:.9,compacted:.8,wood:.8,metal:.7,gravel:.6,grass:.5,ground:.4}},z=class e{constructor(){t(this,"avoidStairs",!1),t(this,"avoidEscalators",!1),t(this,"avoidElevators",!1),t(this,"avoidMovingWalkways",!1),t(this,"avoidTicketRestrictedAreas",!1),t(this,"useMultiLevelSegments",!1),t(this,"projectionMaxDistance"),t(this,"isWheelchair",!1)}setAvoidStairs(e){return this.avoidStairs=e,this}setAvoidEscalators(e){return this.avoidEscalators=e,this}setAvoidElevators(e){return this.avoidElevators=e,this}setAvoidMovingWalkways(e){return this.avoidMovingWalkways=e,this}setAvoidTicketRestrictedAreas(e){return this.avoidTicketRestrictedAreas=e,this}setUseMultiLevelSegments(e){return this.useMultiLevelSegments=e,this}setIsWheelchair(e){return this.isWheelchair=e,this}static fromJson(t){const r=new e;return Object.assign(r,t),r.build()}build(){return{input:{avoidStairs:this.avoidStairs,avoidEscalators:this.avoidEscalators,avoidElevators:this.avoidElevators,avoidMovingWalkways:this.avoidMovingWalkways,avoidTicketRestrictedAreas:this.avoidTicketRestrictedAreas,isWheelchair:this.isWheelchair,projectionMaxDistance:this.projectionMaxDistance},weightEdgeFn:e=>{if(e.properties.isElevator)return 90;const t=this.isWheelchair?H:W;let r=m(e.length,t);if(e.properties.areStairs)r*=3;else if(e.properties.areEscalators)r*=1.5;else if(e.properties.isMovingWalkway)r*=.8;else if(e.properties.smoothness){const t=this.isWheelchair?"wheelchair":"default";r*=V[t][e.properties.smoothness]??1}else if(e.properties.surface){const t=this.isWheelchair?"wheelchair":"default";r*=$[t][e.properties.surface]??1}else"limited"===e.properties.wheelchair&&(r*=.5);return r},weightVertexFn:e=>e.properties.isTurnstile?10:0,acceptEdgeFn:e=>{if(e.properties.wheelchair){if(this.isWheelchair&&"no"===e.properties.wheelchair)return!1;if(!this.isWheelchair&&"designated"===e.properties.wheelchair)return!1}if(this.isWheelchair){if(e.properties.areStairs)return!1;if(e.properties.areEscalators)return!1;if(e.properties.isMovingWalkway)return!1}return(!this.avoidStairs||!e.properties.areStairs)&&((!this.avoidEscalators||!e.properties.areEscalators)&&((!this.avoidElevators||!e.properties.isElevator)&&((!this.avoidMovingWalkways||!e.properties.isMovingWalkway)&&(!this.avoidTicketRestrictedAreas||!e.properties.needTicket))))},projectionMaxDistance:this.projectionMaxDistance,useMultiLevelSegments:this.useMultiLevelSegments}}};t(z,"DEFAULT",(new z).build()),t(z,"WITHOUT_STAIRS",(new z).setAvoidStairs(!0).build()),t(z,"WHEELCHAIR",(new z).setIsWheelchair(!0).build());let Y=z;class K{constructor(e,t,r,n,o){this.prev=e,this.dist=t,this.source=r,this.targets=n,this.edges=o}routeVertices(e=this.targets[0],t=[]){const r=this.prev[e.id];return null===r?this.source===e?[...t,e]:[]:[...this.routeVertices(r,t),e]}weightedDistance(e=this.targets[0]){const t=this.dist[e.id];return t===Number.MAX_VALUE?null:t}route(e=this.targets[0]){const t=this.routeVertices(e),r=[],n=[];for(let o=1;o<t.length;o++){const e=t[o-1],i=t[o],s=u.getEdgeByVertices(this.edges,e,i),a=new u(e,i,Object.assign({},s.properties));s.vertex1===a.vertex2&&a.reverseProperties(),r.push(a),n.push(this.dist[i.id]-this.dist[e.id])}return new E(this.source.coords,e.coords,t,r,n)}toGeoJson(e){return{type:"FeatureCollection",features:[...e.vertices.map((e=>{const t=this.prev[e.id],r=this.dist[e.id],n=e===this.source,o=this.targets.includes(e),i=e.coords.level;return{type:"Feature",properties:{id:e.id,...t&&{prev:t.id},dist:r===Number.MAX_VALUE?"infinity":r,...n&&{name:"source"},...o&&{name:"target"},...null!==i&&{level:i},...e.properties},geometry:{type:"Point",coordinates:[e.coords.lng,e.coords.lat]}}})),...e.edges.map((e=>{const t=e.level;return{type:"Feature",properties:{id:e.id,...null!==t&&{level:t},...e.properties},geometry:{type:"LineString",coordinates:[[e.vertex1.coords.lng,e.vertex1.coords.lat],[e.vertex2.coords.lng,e.vertex2.coords.lat]]}}}))]}}}class J{constructor(e){t(this,"disabledEdges",new Set),this.graph=e;let r=0;e.vertices.forEach((e=>e.id=r++))}calculateShortestPathToMultipleDestinationsByVertex(e,t,r=Y.DEFAULT,n=this.graph.vertices,o=this.graph.edges){const i=new Set(n),s=Array(i.size).fill(Number.MAX_VALUE),a=new Array(i.size).fill(null),l=o.filter((e=>{var t;return((null==(t=r.acceptEdgeFn)?void 0:t.call(r,e))??!0)&&!this.disabledEdges.has(e)})),c=r.weightEdgeFn||(e=>e.length),u=r.weightVertexFn||(e=>0),d=e=>{let t=Number.MAX_VALUE,r=null;return e.forEach((e=>{const n=s[e.id];n<=t&&(t=n,r=e)})),r},p=new Set(t);for(s[e.id]=0;i.size>0;){const e=d(i);if(i.delete(e),t.includes(e)&&(p.delete(e),0===p.size))break;l.filter((t=>t.vertex1==e||!t.properties.isOneway&&t.vertex2==e)).forEach((t=>{const r=e===t.vertex1?t.vertex2:t.vertex1,n=c(t)+u(r),o=s[e.id]+n;o<s[r.id]&&(s[r.id]=o,a[r.id]=e)}))}return new K(a,s,e,t,l)}calculateShortestPathByVertex(e,t,r=Y.DEFAULT,n=this.graph.vertices,o=this.graph.edges){return this.calculateShortestPathToMultipleDestinationsByVertex(e,[t],r,n,o)}calculateComponents(){function e(e){const t=e.values().next().value;return e.delete(t),t}const t=new Set(this.graph.vertices);let r,n=[];for(;t.size>0;){const r=e(t),o=this.graph.vertices.filter((e=>e.id!==r.id)),i=this.calculateShortestPathToMultipleDestinationsByVertex(r,o),s=o.filter((e=>null!==i.weightedDistance(e)));n.push([r,...s]),s.forEach((e=>t.delete(e)))}do{r=!1;for(let e=0;e<n.length-1;e++){const t=n[e];for(let o=e+1;o<n.length;o++){const e=n[o];e.some((e=>t.includes(e)))&&(t.push(...e),n=n.filter((t=>t!==e)),r=!0)}}}while(r);return n.map((e=>[...new Set(e)]))}toGeoJson(){const e=this.calculateComponents().map(((e,t)=>({type:"Feature",geometry:{type:"MultiLineString",coordinates:this.graph.edges.filter((t=>e.includes(t.vertex1)&&e.includes(t.vertex2))).map((e=>[[e.vertex1.coords.lng,e.vertex1.coords.lat],[e.vertex2.coords.lng,e.vertex2.coords.lat]]))},properties:{stroke:"#"+j.getQualitativeColor(t).toString(16)}})));return{type:"FeatureCollection",features:e}}}class X extends K{constructor(e,t,r){super(e.prev,e.dist,e.source,e.targets,e.edges),this.sourceProjection=t,this.targetsProjections=r}static createEmpty(e,t){const r=t.length,n=new K(new Array(r).fill(null),new Array(r).fill(Number.MAX_VALUE),new p(e),t.map((e=>new p(e))),[]),o=[e,null],i=t.map((e=>[e,null]));return new X(n,o,i)}routeVertices(e=this.targetsProjections[0][0]){var t;if(e instanceof p)return super.routeVertices(e);if(!this.sourceProjection[1])return[];const r=null==(t=this.targetsProjections.find((([t])=>t===e)))?void 0:t[1];return r?super.routeVertices(r):[]}weightedDistance(e=this.targetsProjections[0][0]){var t;if(e instanceof p)return super.weightedDistance(e);if(!this.sourceProjection[1])return null;const r=null==(t=this.targetsProjections.find((([t])=>t===e)))?void 0:t[1];return r?super.weightedDistance(r):null}route(e=this.targetsProjections[0][0]){var t;if(e instanceof p)return super.route(e);const r=null==(t=this.targetsProjections.find((([t])=>t===e)))?void 0:t[1];if(!r)return new E(this.sourceProjection[0],e,[],[],[]);const n=super.route(r);return n.start=this.sourceProjection[0],n.end=e,n}}class Q extends J{calculateShortestPathToMultipleDestinations(e,t,r=Y.DEFAULT){const n=new Set,o=new Set,i=[],s={maxDistance:r.projectionMaxDistance,acceptEdgeFn:r.acceptEdgeFn,useMultiLevelSegments:r.useMultiLevelSegments},a=e=>{const t=this.graph.getProjection(e,s);if(null===t)return null;if(t.nearestElement instanceof p)return t.nearestElement;if(t.nearestElement instanceof u){const e=t.nearestElement,r=new p(t.coords,{name:`proj on ${e.properties.name||null} (tmp)`,...void 0!==e.properties.externalId&&{externalId:e.properties.externalId}});r.id=this.graph.vertices.length+n.size;const s={...e.properties,...void 0!==e.properties.externalId&&{externalId:e.properties.externalId}},a=new u(e.vertex1,r,s),l=new u(r,e.vertex2,s);n.add(r),o.add(a),o.add(l);const c=i.find((t=>t[0]===e));return c?c[1].push(r):i.push([e,[r]]),r}return null},l=a(e);if(!l)return X.createEmpty(e,t);const c=t.map((e=>[e,a(e)])),d=c.map((([,e])=>e)).filter((e=>null!==e));i.filter((e=>e[1].length>=2)),i.forEach((([e,t])=>{const r={...e.properties,name:`splitted ${e.properties.name||null} (tmp)`};for(let n=0;n<t.length;n++){const i=t[n],s=i.distanceTo(e.vertex1);for(let a=n+1;a<t.length;a++){const n=t[a],l=n.distanceTo(e.vertex1)<s?new u(n,i,r):new u(i,n,r);o.add(l)}}}));const h=this.calculateShortestPathToMultipleDestinationsByVertex(l,d,r,[...this.graph.vertices,...n],[...this.graph.edges,...o]);return new X(h,[e,l],c)}calculateShortestPath(e,t,r=Y.DEFAULT){return this.calculateShortestPathToMultipleDestinations(e,[t],r)}getShortestTrip(e,t,r=.99){const n=e.map((e=>{const t=new i.Point(0,0);return t.coords=e,t})),o=[],s=i.solve(n,r,void 0,((e,r)=>{const n=this.calculateShortestPath(e.coords,r.coords,t).route();return o.push(n),n.hasRoute?n.edgesWeights.reduce(((e,t)=>e+t),0):Number.MAX_VALUE})).map((e=>n[e])),a=[];for(let i=0;i<s.length;i++){const e=s[i],t=s[(i+1)%s.length];let r=o.find((r=>r.start===e.coords&&r.end===t.coords||r.end===e.coords&&r.start===t.coords));(null==r?void 0:r.end)===e.coords&&(r=r.reverse()),r&&a.push(r)}return a.some((e=>!e.hasRoute))?[]:a}}class Z extends Error{constructor(e,t,r=null){super(),this.start=e,this.end=t,this.details=r}get startStr(){return this.start instanceof p?`Vertex ${this.start.coords.toString()}`:this.start.toString()}get endStr(){return this.end instanceof p?`Vertex ${this.end.coords.toString()}`:Array.isArray(this.end)?this.end.map((e=>e instanceof p?e.coords.toString():e.toString())).join(","):this.end.toString()}get message(){let e=`No route found from ${this.startStr} to ${this.endStr}.`;return this.details&&(e+=` Details: ${this.details}`),e}}class ee{}var te=(e=>(e[e.OK=0]="OK",e[e.CANCELLED=1]="CANCELLED",e[e.UNKNOWN=2]="UNKNOWN",e[e.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",e[e.NOT_FOUND=5]="NOT_FOUND",e[e.UNIMPLEMENTED=12]="UNIMPLEMENTED",e[e.INTERNAL=13]="INTERNAL",e[e.UNAVAILABLE=14]="UNAVAILABLE",e[e.UNAUTHENTICATED=16]="UNAUTHENTICATED",e))(te||{});class re extends Error{constructor(e=te.UNKNOWN,r){super(r),t(this,"customMapName"),this.code=e}static notFound(e){return new re(te.NOT_FOUND,`Cannot found an itinerary. Details: ${e}`)}}class ne extends re{constructor(e=te.UNKNOWN,t,r){super(e,r),this.code=e,this.mapName=t,this.mapName=t}static notFound(e,t){return new ne(te.NOT_FOUND,e,`Cannot found an itinerary in map ${e}. Details: ${t||"No details"}`)}}class oe extends re{constructor(e=te.UNKNOWN,t,r){super(e,r),this.code=e,this.routerName=t,this.routerName=t}static notFound(e,t){return new oe(te.NOT_FOUND,e,`Cannot found an itinerary with ${e}. Details: ${t||"No details"}`)}static missingApiKey(e,t){return new oe(te.UNAUTHENTICATED,e,`API key is missing for ${e}. Details: ${t}`)}static unreachableServer(e,t){return new oe(te.NOT_FOUND,e,`Remote router server ${e} is unreachable. URL: ${t}`)}static responseNotParsing(e,t){return new oe(te.NOT_FOUND,e,`Remote router server response ${e} cannot be parsed. URL: ${t}`)}static travelModeUnimplemented(e,t){return new oe(te.UNIMPLEMENTED,e,`Travel mode "${t}" is not implemented for ${e}`)}}function ie(e,t,r,n,o,i,s="Europe/Paris"){const a=new Date(Date.UTC(e,t,r,n,o,i)),l=new Date(a.toLocaleString("en-US",{timeZone:"UTC"})),c=new Date(a.toLocaleString("en-US",{timeZone:s})),u=l.getTime()-c.getTime();return a.setTime(a.getTime()+u),a}function se(e){return new r.Coordinates(e.Lat,e.Long)}function ae(e){const[t,r]=e.split(" "),[n,o,i]=t.split("/"),[s,a,l]=r.split(":");return ie(Number(i),Number(o)-1,Number(n),Number(s),Number(a),Number(l)).getTime()}const le=new Map;le.set("CAR","Car"),le.set("WALK","Walk"),le.set("BIKE","Bike"),le.set("TRANSIT","PT");const ce=new Map;ce.set("WALK","WALK"),ce.set("BICYCLE","BIKE"),ce.set("TRAMWAY","TRAM"),ce.set("METRO","METRO"),ce.set("FUNICULAR","FUNICULAR"),ce.set("BUS","BUS"),ce.set("COACH","BUS"),ce.set("SCHOOL","BUS"),ce.set("BUS_PMR","BUS"),ce.set("MINIBUS","BUS"),ce.set("TROLLEY_BUS","BUS"),ce.set("TAXIBUS","BUS"),ce.set("SHUTTLE","BUS"),ce.set("TRAIN","TRAIN"),ce.set("HST","TRAIN"),ce.set("LOCAL_TRAIN","TRAIN"),ce.set("AIR","AIRPLANE"),ce.set("FERRY","BOAT"),ce.set("TAXI","UNKNOWN"),ce.set("CAR_POOL","UNKNOWN"),ce.set("PRIVATE_VEHICLE","CAR"),ce.set("SCOOTER","MOTO");const ue=new Map;function de(e){const t=e.match(/LINESTRING ?\((.*)\)/i),n=e.match(/POINT ?\((.*)\)/i);if(n){const[e,t]=n[1].split(" ");return[new r.Coordinates(Number(t),Number(e))]}return t[1].split(",").map((e=>{const t=e.trim().split(" ");return new r.Coordinates(Number(t[1]),Number(t[0]))}))}ue.set(0,"BUS"),ue.set(1,"WALK"),ue.set(2,"BIKE"),ue.set(3,"CAR"),ue.set(4,"UNKNOWN"),ue.set(5,"UNKNOWN"),ue.set(6,"UNKNOWN"),ue.set(7,"UNKNOWN"),ue.set(8,"UNKNOWN"),ue.set(9,"UNKNOWN"),ue.set(10,"UNKNOWN"),ue.set(11,"UNKNOWN"),ue.set(12,"UNKNOWN"),ue.set(13,"UNKNOWN"),ue.set(14,"UNKNOWN");const pe=new class extends ee{get rname(){return"cityway"}async getItineraries(e,t){const r=this.getURL(e,t),n=await fetch(r).catch((()=>{throw oe.unreachableServer(this.rname,r)})),o=await n.json().catch((()=>{throw oe.responseNotParsing(this.rname,r)}));return this.parseResponse(o)}getURL(e,t){const{origin:r,destination:n,travelMode:i,waypoints:s}=t,a=le.get(i);if(!a)throw oe.travelModeUnimplemented(this.rname,i);(s||[]).length>0&&o.warn(`${this.rname} router uses only the first 2 waypoints (asked ${null==s?void 0:s.length})`);const l=`DepartureLatitude=${r.latitude}&DepartureLongitude=${r.longitude}`,c=`ArrivalLatitude=${n.latitude}&ArrivalLongitude=${n.longitude}`,u=`TripModes=${a}`,d=new URL(e);t.departureTime&&(d.searchParams.set("Date",t.departureTime),d.searchParams.set("TypeDate","Departure"));let{search:p}=d;return p=(p?`${p}&`:"?")+`${l}&${c}&${u}`,`${d.origin}${d.pathname}${p}`}parseResponse(e){if(200!==e.StatusCode||!e.Data||!e.Data.length)throw oe.notFound(this.rname,e.Message);const t=[],r=e.Data.map((e=>e.response.trips.Trip.map((t=>({...t,...e.hasOwnProperty("PlanTripType")&&{PlanTripType:e.PlanTripType}}))))).flat();e:for(const n of r){if(n.hasOwnProperty("PlanTripType")&&"UNKNOWN"===ue.get(n.PlanTripType))continue;const e=[];for(const t of n.sections.Section){const r=t.Leg?t.Leg:t.PTRide,i=ce.get(r.TransportMode),s=[];let a,l,c;const u=new N;if("UNKNOWN"===i)continue e;if("WALK"===i||"BIKE"===i||"CAR"===i){a={name:r.Departure.Site.Name,coords:se(r.Departure.Site.Position)},l={name:r.Arrival.Site.Name,coords:se(r.Arrival.Site.Position)};for(const e of r.pathLinks.PathLink){let t;t=e.Geometry&&"Null"!==e.Geometry?de(e.Geometry):[a.coords,l.coords],t.forEach(((e,t)=>{0===t&&0!==s.length&&s[s.length-1].equals(e)||s.push(e)})),u.addStepInfo({coords:t[0],distance:e.Distance,name:e.Departure.Site.Name})}t===n.sections.Section[n.sections.Section.length-1]&&u.addStepInfo({coords:s[s.length-1]})}else{if(!g(i)){o.warn(`[CitywayParser] Unknown leg mode: ${r.TransportMode}`);continue}{a={name:r.Departure.StopPlace.Name,coords:se(r.Departure.StopPlace.Position)},l={name:r.Arrival.StopPlace.Name,coords:se(r.Arrival.StopPlace.Position)};let e=r.Line.Number;"TRAM"===i&&e.toLowerCase().includes("tram")&&(e=e.substr(5)),c={name:e,routeColor:r.Line.Color,routeTextColor:r.Line.TextColor,directionName:r.Destination};for(const t of r.steps.Step){de(t.Geometry).forEach(((e,t)=>{0===t&&0!==s.length&&s[s.length-1].equals(e)||s.push(e)}))}u.addStepInfo({coords:s[0],name:r.Line.Name,distance:r.Distance,type:"transit"})}}u.setStart(a.coords),u.setEnd(l.coords),u.setPathCoords(s);const d=new _({transitMode:i,duration:this.parseDuration(r.Duration),startTime:ae(r.Departure.Time),endTime:ae(r.Arrival.Time),coords:s,start:a,end:l,transportInfo:c,steps:u.build()});e.push(d)}const r=new S({duration:this.parseDuration(n.Duration),startTime:ae(n.Departure.Time),origin:se(n.Departure.Site.Position),endTime:ae(n.Arrival.Time),destination:se(n.Arrival.Site.Position),legs:e});t.push(r)}return t}parseDuration(e){const t=e.match(/(-)?P(?:([.,\d]+)Y)?(?:([.,\d]+)M)?(?:([.,\d]+)W)?(?:([.,\d]+)D)?T(?:([.,\d]+)H)?(?:([.,\d]+)M)?(?:([.,\d]+)S)?/),r=void 0===t[2]?0:Number(t[2]),n=void 0===t[3]?0:Number(t[3]),o=void 0===t[4]?0:Number(t[4]),i=void 0===t[5]?0:Number(t[5]),s=void 0===t[6]?0:Number(t[6]),a=void 0===t[7]?0:Number(t[7]);return(void 0===t[8]?0:Number(t[8]))+60*a+3600*s+86400*i+604800*o+2592e3*n+31557600*r}},he=new Map;he.set("Air","AIRPLANE"),he.set("Boat","BOAT"),he.set("Bus","BUS"),he.set("BusRapidTransit","BUS"),he.set("Coach","BUS"),he.set("Ferry","FERRY"),he.set("Funicular","FUNICULAR"),he.set("LocalTrain","TRAIN"),he.set("LongDistanceTrain","TRAIN"),he.set("Metro","METRO"),he.set("Métro","METRO"),he.set("RailShuttle","TRAIN"),he.set("RapidTransit","BUS"),he.set("Shuttle","BUS"),he.set("SuspendedCableCar","FUNICULAR"),he.set("Taxi","TAXI"),he.set("Train","TRAIN"),he.set("RER","TRAIN"),he.set("Tramway","TRAM"),he.set("walking","WALK"),he.set("bike","BIKE");const me=["physical_mode:Air","physical_mode:Boat","physical_mode:Bus","physical_mode:BusRapidTransit","physical_mode:Coach","physical_mode:Ferry","physical_mode:Funicular","physical_mode:LocalTrain","physical_mode:LongDistanceTrain","physical_mode:Metro","physical_mode:RailShuttle","physical_mode:RapidTransit","physical_mode:Shuttle","physical_mode:SuspendedCableCar","physical_mode:Taxi","physical_mode:Train","physical_mode:Tramway"];function fe(e){return new r.Coordinates(Number(e.lat),Number(e.lon))}function ge(e){return e[e.length-1]}function ve(e,t){const r=e.substr(0,4),n=e.substr(4,2),o=e.substr(6,2),i=e.substr(9,2),s=e.substr(11,2),a=e.substr(13,2);return ie(Number(r),Number(n)-1,Number(o),Number(i),Number(s),Number(a),t).getTime()}const ye=new class extends ee{get rname(){return"navitia"}async getItineraries(e,t){const r=this.getURL(e,t),n=r.searchParams.get("api_key");if(!n)throw oe.missingApiKey(this.rname);const o=await fetch(r,{method:"GET",headers:{Authorization:n}}).catch((()=>{throw oe.unreachableServer(this.rname,r.toString())})),i=await o.json().catch((()=>{throw oe.responseNotParsing(this.rname,r.toString())}));if(i&&i.error)throw oe.notFound(this.rname,i.error.message);const s=this.parseResponse(i);if(!s.some((e=>v(e.transitMode,t.travelMode))))throw oe.notFound(this.rname,"Selected mode of transport was not found for this itinerary.");return s}getURL(e,t){var r;const{origin:n,destination:i,waypoints:s,travelMode:a}=t;(s||[]).length>0&&o.warn(`${this.rname} router uses only the first 2 waypoints (asked ${null==s?void 0:s.length})`);const l=new URL(e),c=new URLSearchParams;c.set("from",`${n.longitude};${n.latitude}`),c.set("to",`${i.longitude};${i.latitude}`),c.set("data_freshness","realtime"),(null==(r=t.itineraryModifiers)?void 0:r.isWheelchair)&&c.set("wheelchair","true");let u=new URLSearchParams;switch(a){case"WALK":u=this.getWalkingQuery();break;case"BIKE":u=this.getBikeQuery();break;case"CAR":u=this.getCarQuery()}return[c,u].map((e=>{for(const t of e.entries())l.searchParams.append(t[0],t[1])})),l}getCarQuery(){const e=new URLSearchParams;return me.forEach((t=>{e.append("forbidden_uris[]",t)})),e.append("first_section_mode[]","walking"),e.append("first_section_mode[]","car"),e.append("last_section_mode[]","walking"),e.append("last_section_mode[]","car"),e}getWalkingQuery(){const e=new URLSearchParams;return me.forEach((t=>{e.append("forbidden_uris[]",t)})),e.append("first_section_mode[]","walking"),e.append("last_section_mode[]","walking"),e}getBikeQuery(){const e=new URLSearchParams;return me.forEach((t=>{e.append("forbidden_uris[]",t)})),e.append("first_section_mode[]","bike"),e.append("last_section_mode[]","bike"),e}getSectionCoords(e){let t,r;return t="stop_point"in e.from?e.from.stop_point.coord:"address"in e.from?e.from.address.coord:e.from.poi.coord,r="stop_point"in e.to?e.to.stop_point.coord:"address"in e.to?e.to.address.coord:e.to.poi.coord,{from:fe(t),to:fe(r)}}findStepsCoord(e,t){const n=e,o=[...n];let i=t[0],s=0;const a=[];for(const[l,c]of t.entries()){let e,u;if(0===l)u=0,e=n[0];else if(l===t.length-1)u=n.length-1,e=ge(n);else if(1===o.length)s++,u=s,e=o[0],n[u]=e;else{const t=r.Utils.trimRoute(o,o[0],i.distance);s+=t.length-1,o.splice(0,t.length-1),u=s,e=ge(t),n[u]=e}a.push({...c,coords:e}),i=c}return a}findStepCoords(e,t){var r;if("instruction_start_coordinate"in e)return fe(e.instruction_start_coordinate);const n=null==(r=t.vias)?void 0:r.find((t=>t.id===e.via_uri));return n?fe(n.access_point.coord):void 0}parseResponse(e){var t;if(!e||!e.journeys)throw oe.notFound(this.rname,null==(t=e.error)?void 0:t.message);const n=[],o=e.context.timezone;for(const i of e.journeys){const e=[];for(const n of i.sections){if("waiting"===n.type||"transfer"===n.type)continue;const{from:t,to:i}=this.getSectionCoords(n);let s=[];const a=n.geojson.coordinates.reduce(((e,[t,n])=>(s.includes(`${t}-${n}`)||(s=s.concat(`${t}-${n}`),e.push(new r.Coordinates(n,t))),e)),[]),l=(new N).setStart(t).setEnd(i).setPathCoords(a);let c,u=he.get(n.mode);if(n.path){const e=n.path.every((e=>"instruction_start_coordinate"in e||e.via_uri)),t=[];for(const r of n.path){let o;e?(o=this.findStepCoords(r,n),l.addStepInfo({name:r.name,distance:r.length,coords:o,type:"turn"})):t.push({name:r.name,distance:r.length})}e||l.setStepsInfo(this.findStepsCoord(a,t))}if("public_transport"===n.type){c={name:n.display_informations.code,routeColor:n.display_informations.color,routeTextColor:n.display_informations.text_color,directionName:n.display_informations.direction},u=he.get(n.display_informations.physical_mode);const e={coords:a[0],name:c.directionName,distance:n.geojson.properties[0].length,type:"transit"};l.setStepsInfo([e])}const d=new _({transitMode:u,duration:n.duration,startTime:ve(n.departure_date_time,o),endTime:ve(n.arrival_date_time,o),start:{name:n.from.name,coords:t},end:{name:n.to.name,coords:i},coords:a,transportInfo:c,steps:l.build()});e.push(d)}const t=new S({duration:i.duration,startTime:ve(i.departure_date_time,o),endTime:ve(i.arrival_date_time,o),origin:this.getSectionCoords(i.sections[0]).from,destination:this.getSectionCoords(ge(i.sections)).to,legs:e});n.push(t)}return n}};const be=new class extends ee{get rname(){return"deutsche-bahn"}async getItineraries(e,t){const r=this.getURL(e,t),n=await fetch(r).catch((()=>{throw oe.unreachableServer(this.rname,r)})),o=await n.json().catch((()=>{throw oe.responseNotParsing(this.rname,r)}));return this.parseResponse(o,t.origin,t.destination)}getURL(e,t){let n=e+"/route/v1/walking/";return n+=[t.origin,...t.waypoints||[],t.destination].map((e=>{if(null!==e.level){const t=r.Level.isRange(e.level)?e.level[0]:e.level;return e.longitude+","+e.latitude+","+t}return e.longitude+","+e.latitude})).join(";"),n+="?geometries=geojson&overview=full&steps=true",n}parseResponse(e,t,n){if(!e.segments)throw oe.notFound(this.rname);const o=e.segments.map((e=>{const t=r.Level.union(e.fromLevel,e.toLevel),n=e.polyline.map((({lon:e,lat:n})=>new r.Coordinates(n,e,null,t)));return new _({transitMode:"WALK",coords:n,start:{coords:n[0]},end:{coords:n[n.length-1]}})}));return[new S({origin:t,destination:n,legs:o})]}};function we(e){const t=e[0];return e.slice(1).map((e=>{const r={};return t.forEach(((t,n)=>{r[t]=e[n]})),r}))}const Ee=new Map;Ee.set("BIKE","BIKE"),Ee.set("PEDESTRIAN","WALK");function Te(e){return new r.Coordinates(e.latitude,e.longitude)}function Ne(e){return e[e.length-1]}const _e=new class extends ee{get rname(){return"geovelo"}async getItineraries(e,t){const r=this.getQueryParams(),n=this.getBodyParams(t),o=new URL(e);for(const[a,l]of Object.entries(r))o.searchParams.append(a,l.toString());const i=await fetch(o,{method:"POST",headers:{apiKey:"qWHj6ax6DMttG8DX6tH9CQARaiTgQ1Di","Content-Type":"application/json"},body:JSON.stringify(n)}).catch((()=>{throw oe.unreachableServer(this.rname,o.toString())})),s=await i.json().catch((()=>{throw oe.responseNotParsing(this.rname,o.toString())}));if(!s||0===s.length)throw oe.notFound(this.rname,"No itineraries found.");return this.parseResponse(s)}getQueryParams(){return{instructions:!0,elevations:!1,geometry:!0,single_result:!1,bike_stations:!1,objects_as_ids:!1,merge_instructions:!0,show_pushing_bike_instructions:!1}}getBodyParams(e){const{origin:t,destination:r,waypoints:n}=e;let o=[];return o=n&&n.length>1?n.map((e=>({longitude:e.longitude,latitude:e.latitude}))):[{latitude:t.latitude,longitude:t.longitude},{latitude:r.latitude,longitude:r.longitude}],{transportModes:["BIKE"],waypoints:o}}parseResponse(e){if(!e||!e.length)throw oe.notFound(this.rname);const t=[];for(const n of e){const e=[];for(const t of n.sections){const n=Te(t.waypoints[0]),o=Te(Ne(t.waypoints)),i=s.toGeoJSON(t.geometry,6);let a=[];const l=i.coordinates.reduce(((e,[t,n])=>(a.includes(`${t}-${n}`)||(a=a.concat(`${t}-${n}`),e.push(new r.Coordinates(n,t))),e)),[]),c=(new N).setStart(n).setEnd(o).setPathCoords(l),u=Ee.get(t.transportMode),d=we(t.details.instructions);for(const e of d){const{geometryIndex:t,roadLength:n,roadName:o}=e,s=i.coordinates[t],a={name:o,distance:n,coords:new r.Coordinates(s[1],s[0])};c.addStepInfo(a)}const p=new _({transitMode:u,duration:t.duration,startTime:new Date(t.estimatedDatetimeOfDeparture).getTime(),endTime:new Date(t.estimatedDatetimeOfArrival).getTime(),start:{coords:n},end:{coords:o},coords:l,steps:c.build()});e.push(p)}const o=new S({duration:n.duration,startTime:new Date(n.estimatedDatetimeOfDeparture).getTime(),endTime:new Date(n.estimatedDatetimeOfArrival).getTime(),origin:Te(n.waypoints[0]),destination:Te(Ne(n.waypoints)),legs:e});t.push(o)}return t}},Se=new Map;Se.set("Air","AIRPLANE"),Se.set("Boat","BOAT"),Se.set("Bus","BUS"),Se.set("BusRapidTransit","BUS"),Se.set("Coach","BUS"),Se.set("Ferry","FERRY"),Se.set("Funicular","FUNICULAR"),Se.set("LocalTrain","TRAIN"),Se.set("LongDistanceTrain","TRAIN"),Se.set("Metro","METRO"),Se.set("Métro","METRO"),Se.set("RailShuttle","TRAIN"),Se.set("RapidTransit","BUS"),Se.set("Shuttle","BUS"),Se.set("SuspendedCableCar","FUNICULAR"),Se.set("Taxi","TAXI"),Se.set("Train","TRAIN"),Se.set("RER","TRAIN"),Se.set("Tramway","TRAM"),Se.set("walking","WALK"),Se.set("bike","BIKE");const xe=["physical_mode:Air","physical_mode:Boat","physical_mode:Bus","physical_mode:BusRapidTransit","physical_mode:Coach","physical_mode:Ferry","physical_mode:Funicular","physical_mode:LocalTrain","physical_mode:LongDistanceTrain","physical_mode:Metro","physical_mode:RailShuttle","physical_mode:RapidTransit","physical_mode:Shuttle","physical_mode:SuspendedCableCar","physical_mode:Taxi","physical_mode:Train","physical_mode:Tramway"];function Ae(e){return new r.Coordinates(Number(e.lat),Number(e.lon))}function Ie(e){return e[e.length-1]}function Oe(e,t){const r=e.substr(0,4),n=e.substr(4,2),o=e.substr(6,2),i=e.substr(9,2),s=e.substr(11,2),a=e.substr(13,2);return ie(Number(r),Number(n)-1,Number(o),Number(i),Number(s),Number(a),t).getTime()}const Re=new class extends ee{get rname(){return"idfm"}async getItineraries(e,t){const{travelMode:r}=t;if("BIKE"===r)return _e.getItineraries("https://idfm.getwemap.com/marketplace/computedroutes",t);const n=this.getURL(e,t),o=await fetch(n,{method:"GET",headers:{apiKey:"qWHj6ax6DMttG8DX6tH9CQARaiTgQ1Di"}}).catch((()=>{throw oe.unreachableServer(this.rname,n)})),i=await o.json().catch((()=>{throw oe.responseNotParsing(this.rname,n)}));if(i&&i.error)throw oe.notFound(this.rname,i.error.message);const s=this.parseResponse(i);if(!s.some((e=>v(e.transitMode,t.travelMode))))throw oe.notFound(this.rname,"Selected mode of transport was not found for this itinerary.");return s}getURL(e,t){var r;const{origin:n,destination:i,waypoints:s,travelMode:a}=t;(s||[]).length>0&&o.warn(`${this.rname} router uses only the first 2 waypoints (asked ${null==s?void 0:s.length})`);const l=new URL(e),c=new URLSearchParams;c.set("from",`${n.longitude};${n.latitude}`),c.set("to",`${i.longitude};${i.latitude}`),c.set("data_freshness","realtime"),(null==(r=t.itineraryModifiers)?void 0:r.isWheelchair)&&c.set("wheelchair","true"),t.departureTime&&(c.set("datetime",t.departureTime),c.set("datetime_represents","departure"));let u=new URLSearchParams;switch(a){case"WALK":u=this.getWalkingQuery();break;case"BIKE":u=this.getBikeQuery();break;case"CAR":u=this.getCarQuery()}return[c,u].map((e=>{for(const t of e.entries())l.searchParams.append(t[0],t[1])})),l.toString()}getCarQuery(){const e=new URLSearchParams;return xe.forEach((t=>{e.append("forbidden_uris[]",t)})),e.append("first_section_mode[]","walking"),e.append("first_section_mode[]","car"),e.append("last_section_mode[]","walking"),e.append("last_section_mode[]","car"),e}getWalkingQuery(){const e=new URLSearchParams;return xe.forEach((t=>{e.append("forbidden_uris[]",t)})),e.append("first_section_mode[]","walking"),e.append("last_section_mode[]","walking"),e}getBikeQuery(){const e=new URLSearchParams;return xe.forEach((t=>{e.append("forbidden_uris[]",t)})),e.append("first_section_mode[]","bike"),e.append("last_section_mode[]","bike"),e}getSectionCoords(e){let t,r;return t="stop_point"in e.from?e.from.stop_point.coord:"address"in e.from?e.from.address.coord:e.from.poi.coord,r="stop_point"in e.to?e.to.stop_point.coord:"address"in e.to?e.to.address.coord:e.to.poi.coord,{from:Ae(t),to:Ae(r)}}findStepsCoord(e,t){const n=e,o=[...n];let i=t[0],s=0;const a=[];for(const[l,c]of t.entries()){let e,u;if(0===l)u=0,e=n[0];else if(l===t.length-1)u=n.length-1,e=Ie(n);else if(1===o.length)s++,u=s,e=o[0],n[u]=e;else{const t=r.Utils.trimRoute(o,o[0],i.distance);s+=t.length-1,o.splice(0,t.length-1),u=s,e=Ie(t),n[u]=e}a.push({...c,coords:e}),i=c}return a}findStepCoords(e,t){var r;if("instruction_start_coordinate"in e)return Ae(e.instruction_start_coordinate);const n=null==(r=t.vias)?void 0:r.find((t=>t.id===e.via_uri));return n?Ae(n.access_point.coord):void 0}parseResponse(e){var t;if(!e||!e.journeys)throw oe.notFound(this.rname,null==(t=e.error)?void 0:t.message);const n=[],o=e.context.timezone;for(const i of e.journeys){const e=[];for(const n of i.sections){if("waiting"===n.type||"transfer"===n.type)continue;const{from:t,to:i}=this.getSectionCoords(n);let s=[];const a=n.geojson.coordinates.reduce(((e,[t,n])=>(s.includes(`${t}-${n}`)||(s=s.concat(`${t}-${n}`),e.push(new r.Coordinates(n,t))),e)),[]),l=(new N).setStart(t).setEnd(i).setPathCoords(a);let c,u=Se.get(n.mode);if(n.path){const e=n.path.every((e=>"instruction_start_coordinate"in e||e.via_uri)),t=[];for(const r of n.path){let o;if(e){o=this.findStepCoords(r,n);const e={name:r.name,distance:r.length,coords:o};l.addStepInfo(e)}else t.push({name:r.name,distance:r.length})}e||l.setStepsInfo(this.findStepsCoord(a,t))}if("public_transport"===n.type){c={name:n.display_informations.code,routeColor:n.display_informations.color,routeTextColor:n.display_informations.text_color,directionName:n.display_informations.direction},u=Se.get(n.display_informations.physical_mode);const e={coords:a[0],name:c.directionName,distance:n.geojson.properties[0].length,type:"transit"};l.setStepsInfo([e])}const d=new _({transitMode:u,duration:n.duration,startTime:Oe(n.departure_date_time,o),endTime:Oe(n.arrival_date_time,o),start:{name:n.from.name,coords:t},end:{name:n.to.name,coords:i},coords:a,transportInfo:c,steps:l.build()});e.push(d)}const t=new S({duration:i.duration,startTime:Oe(i.departure_date_time,o),endTime:Oe(i.arrival_date_time,o),origin:this.getSectionCoords(i.sections[0]).from,destination:this.getSectionCoords(Ie(i.sections)).to,legs:e});n.push(t)}return n}},Ce=new Map;Ce.set("CAR","CAR"),Ce.set("WALK","WALK"),Ce.set("BIKE","BIKE");const De=new class extends ee{constructor(){super(...arguments),t(this,"inputModeCorrespondance",(e=>{var t;const{travelMode:r,travelModePreference:n}=e;if("WALK"===r&&(null==(t=e.itineraryModifiers)?void 0:t.isWheelchair))return"pmr";if("WALK"===r)return"walking";if("BIKE"===r)return"FASTEST"===n?"bike-fastest":"bike-safest";if("CAR"===r)return"driving";throw oe.travelModeUnimplemented(this.rname,r)}))}get rname(){return"osrm"}async getItineraries(e,t){const r=this.getURL(e,t),n=await fetch(r).catch((()=>{throw oe.unreachableServer(this.rname,r)})),o=await n.json().catch((()=>{throw oe.responseNotParsing(this.rname,r)}));return this.parseResponse(o,t.origin,t.destination,t.travelMode)}getURL(e,t){const{origin:r,destination:n}=t;let o=e+"/route/v1/"+this.inputModeCorrespondance(t)+"/";return o+=[r,...t.waypoints||[],n].map((e=>[e.longitude+","+e.latitude])).join(";"),o+="?geometries=geojson&overview=full&steps=true",t.provideItineraryAlternatives&&(o+="&alternatives=true"),o}osrmTypeToStepType(e){switch(e){case"depart":return"depart";case"turn":default:return"turn";case"roundabout":return"roundabout";case"exit roundabout":return"exit-roundabout";case"arrive":return"arrive"}}osrmModifierToStepDirection(e){switch(e){case"sharp right":return"sharp-right";case"sharp left":return"sharp-left";case"slight right":return"slight-right";case"slight left":return"slight-left";case"u turn":return"u-turn";default:return e}}coordinatesToJson({lat:e,lng:t,level:n}){return null===n?[t,e]:r.Level.isRange(n)?[t,e,n[0]]:[t,e,n]}jsonToCoordinates(e){const t=new r.Coordinates(e[1],e[0]);return e.length>2&&(t.level=e[2]),t}getModifierFromAngle(e){const t=n.positiveMod(n.rad2deg(e),360);return t>0&&t<60?"sharp right":t>=60&&t<140?"right":t>=140&&t<160?"slight right":t>=160&&t<=200?"straight":t>200&&t<=220?"slight left":t>220&&t<=300?"left":t>300&&t<360?"sharp left":"u turn"}noRouteFoundJson(e){return{code:"NoRoute",message:e}}itineraryToOsrmJson(e){const t=e.legs.length-1,r=e.steps,o=e.legs.map((({distance:e,duration:o,coords:i},s)=>{const a=r.filter((e=>i.find((t=>t.equals(e.coords))))),l=a.length-1;return{distance:e,duration:o||0,steps:a.map(((e,r,o)=>{let a=0===r&&0===s?"depart":"turn";a=r===l&&s===t?"arrive":a;const c=i.findIndex((t=>t.equals(e.coords))),u=r===l?c:i.findIndex((e=>e.equals(o[r+1].coords)));return{geometry:{type:"LineString",coordinates:i.slice(c,u+1).map(this.coordinatesToJson)},distance:e.distance,duration:e.duration||0,...e.name&&{name:e.name},maneuver:{bearing_before:n.rad2deg(e.previousBearing),bearing_after:n.rad2deg(e.nextBearing),location:this.coordinatesToJson(e.coords),modifier:this.getModifierFromAngle(e.angle),type:a}}}))}}));return{code:"Ok",routes:[{geometry:{type:"LineString",coordinates:e.coords.map(this.coordinatesToJson)},legs:o,distance:e.distance,duration:e.duration,weight_name:"routability",weight:0}],waypoints:[]}}parseResponse(e,t,r,n){const o=Ce.get(n),{routes:i}=e;if(!i)throw oe.notFound(this.rname,e.message);return i.map((e=>{const n=e.legs.map((e=>{var t;const r=e.steps.map((e=>e.geometry.coordinates.map(this.jsonToCoordinates))).flat().filter(((e,t,r)=>0===t||!r[t-1].equals(e))),n=r[0],i=r[r.length-1],s=(new N).setPathCoords(r).setStart(n).setEnd(i);return null==(t=e.steps)||t.forEach((({maneuver:e,name:t,distance:n,duration:o})=>{const i=this.jsonToCoordinates(e.location),a=r.map((e=>e.distanceTo(i))),l=a.indexOf(Math.min(...a));if(l<0)throw new Error("Osrm Parser: Cannot find step coords in leg coordinates");const c=void 0!==e.exit?e.exit.toString():t;s.addStepInfo({coords:r[l],name:c,distance:n,duration:o,type:this.osrmTypeToStepType(e.type),direction:this.osrmModifierToStepDirection(e.modifier)})})),new _({transitMode:o,duration:e.duration,coords:r,start:{coords:n},end:{coords:i},steps:s.build()})}));return new S({duration:e.duration,origin:t,destination:r,legs:n})}))}};function Me(e){return"BUS"===e.mode||"TRAM"===e.mode}function Le(e){return new r.Coordinates(e.lat,e.lon)}const ke=new Map;ke.set("CAR","CAR"),ke.set("WALK","WALK"),ke.set("BIKE","BICYCLE"),ke.set("TRANSIT","WALK,TRANSIT");const Ue=new class extends ee{get rname(){return"otp"}async getItineraries(e,t){const r=this.getURL(e,t),n=await fetch(r).catch((()=>{throw oe.unreachableServer(this.rname,r)})),o=await n.json().catch((()=>{throw oe.responseNotParsing(this.rname,r)}));return this.parseResponse(o)}getURL(e,t){const{origin:r,destination:n,waypoints:i,travelMode:s}=t,a=ke.get(s);if(!a)throw oe.travelModeUnimplemented(this.rname,s);(i||[]).length>0&&o.warn(`${this.rname} router uses only the first 2 waypoints (asked ${null==i?void 0:i.length})`);const l=`fromPlace=${r.latitude},${r.longitude}`,c=`toPlace=${n.latitude},${n.longitude}`,u=`mode=${a}`,d=new URL(e);let{search:p}=d;return p=(p?`${p}&`:"?")+`${l}&${c}&${u}`,`${d.origin}${d.pathname}${p}`}parseResponse(e){const{plan:t}=e;if(!t)throw oe.notFound(this.rname);const n=[],o=Le(t.from),i=Le(t.to);for(const a of t.itineraries){const e=[];for(const n of a.legs){const t=Le(n.from),o=Le(n.to),i=s.decode(n.legGeometry.points).map((([e,t])=>new r.Coordinates(e,t)));let a;const l=(new N).setStart(t).setEnd(o).setPathCoords(i);Me(n)?(a={name:n.routeShortName,routeColor:n.routeColor,routeTextColor:n.routeTextColor,directionName:n.headsign},l.addStepInfo({coords:i[0],name:n.headsign,type:"transit"})):n.steps.forEach((e=>{const t=i.map((t=>t.distanceTo(Le(e)))),r=t.indexOf(Math.min(...t));if(r<0)throw new Error("OTP Parser: Cannot find closest step");l.addStepInfo({coords:i[r],name:e.streetName,type:"turn"})}));const c=new _({transitMode:n.mode,duration:n.duration,startTime:n.startTime,endTime:n.endTime,start:{name:n.from.name,coords:Le(n.from)},end:{name:n.to.name,coords:Le(n.to)},coords:i,transportInfo:a,steps:l.build()});e.push(c)}const t=new S({duration:a.duration,startTime:a.startTime,endTime:a.endTime,origin:o,destination:i,legs:e});n.push(t)}return n}};const Pe=new class extends ee{get rname(){return"wemap-multi"}async getItineraries(e,t){const{origin:n,destination:o,waypoints:i}=t,s={...t,origin:n instanceof r.Coordinates?n.toJson():n,destination:o instanceof r.Coordinates?o.toJson():o,...i&&{waypoints:i.map((e=>e instanceof r.Coordinates?e.toJson():e))}},a=await fetch(e,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(s)}).catch((()=>{throw oe.unreachableServer(this.rname,e)})),l=await a.json().catch((()=>{throw oe.responseNotParsing(this.rname,e)}));if(l.error)throw oe.notFound(this.rname,l.error);return(l.itineraries||[]).map(S.fromJson)}},qe="https://routing-osrm.getwemap.com";const Be=new class extends ee{get rname(){return"tictactrip"}async getSegmentItinerary(e,t){const r=m(e.distanceTo(t));if(r<300)return null;let n=null;return n=r<1800?(await De.getItineraries(qe,{origin:e,destination:t,travelMode:"WALK",provideItineraryAlternatives:!1,optimizeWaypoints:!1}))[0]:(await De.getItineraries(qe,{origin:e,destination:t,travelMode:"CAR",provideItineraryAlternatives:!1,optimizeWaypoints:!1}))[0],n}getItineraryFromStation(e,t){return De.getItineraries(qe,{origin:e,destination:t,travelMode:"WALK"})}async getItineraries(e,t){const r=this.getBodyParams(t),n=new URL(e),o=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)}).catch((()=>{throw oe.unreachableServer(this.rname,n.toString())})),i=await o.json().catch((()=>{throw oe.responseNotParsing(this.rname,n.toString())}));return await this.parseResponse(i,t)}getBodyParams(e){const{origin:t,destination:r}=e;return{origin:{latitude:t.lat,longitude:t.lng},destination:{latitude:r.lat,longitude:r.lng},outbound_date:e.departureTime||(new Date).toISOString(),passengers:[{age:30}]}}async parseResponse(e,t){return e&&e.trips?await Promise.all(Object.values(e.trips).filter((e=>"TRAIN"===e.transportType)).map((async e=>{var n,o;const i=e.segments.map((e=>{const t=G.toUpperCase(e.transportType),n=new r.Coordinates(e.origin.latitude,e.origin.longitude),o=new r.Coordinates(e.destination.latitude,e.destination.longitude),i=[n,o],s=(new N).setStart(n).setEnd(o).setPathCoords(i);return s.setStepsInfo([{coords:n,type:"depart",direction:null},{coords:o,type:"arrive",direction:null}]),new _({start:{name:e.origin.name,coords:n},end:{name:e.destination.name,coords:o},coords:[n,o],transitMode:t,duration:60*e.durationMinutes,startTime:new Date(e.departureLocalISO).getTime(),endTime:new Date(e.arrivalLocalISO).getTime(),transportInfo:{name:e.provider.name,price:e.priceCents/100,directionName:e.destination.name},steps:s.build()})}));let s=null,a=null;const l=[],c=null==(n=e.segments[0])?void 0:n.origin;if(c){const e=new r.Coordinates(c.latitude,c.longitude),n=t.origin;s=await this.getSegmentItinerary(n,e).catch((()=>null)),s&&(s.legs[0].start.name=c.name,l.push(...s.legs))}l.push(...i);const u=null==(o=e.segments[e.segments.length-1])?void 0:o.destination;if(u){const e=new r.Coordinates(u.latitude,u.longitude),n=t.destination;a=await this.getSegmentItinerary(e,n).catch((()=>null)),a&&(a.legs[a.legs.length-1].end.name=u.name,l.push(...a.legs))}return new S({origin:new r.Coordinates(e.origin.latitude,e.origin.longitude),destination:new r.Coordinates(e.destination.latitude,e.destination.longitude),duration:60*e.durationMinutes,startTime:new Date(e.departureLocalISO).getTime(),endTime:new Date(e.arrivalLocalISO).getTime(),legs:l})}))):[]}},Fe=[pe,ye,be,Re,De,Ue,Be,Pe];const je=new class{getRouterByName(e){return Fe.find((t=>t.rname===e))}async getItineraries(e,t,r){const n=this.getRouterByName(e);if(!n)throw oe.notFound(e,`Unknown "${e}" remote router`);return n.getItineraries(t,r)}async getItinerariesWithFallback(e,t){let r;const n=[];for(const{name:a,endpointUrl:l}of t)try{if(r=await this.getItineraries(a,l,e),r.length)return r}catch(s){if(!(s instanceof oe))throw s;n.push({name:a,endpointUrl:l,error:s})}const o=t.map((({name:e})=>e)).join(", "),i=n.map((e=>`(${e.name}) Could not find an itinerary on endpoint: ${e.endpointUrl}. Details: ${e.error.message}`)).join("\n");throw oe.notFound(o,i)}};class Ge{constructor(e,r=null){t(this,"router"),this.graph=e,this.name=r,this.name=r,this.graph=e,this.router=new Q(e)}get routingBounds(){return this.graph.routingBounds}get entryPoints(){return this.graph.routingBoundsEntryPoints}isPointInside(e){return!!this.routingBounds&&a([e.lng,e.lat],this.routingBounds)}getOrderedEntryPointsSortedByDistance(e,t){const n=[...this.entryPoints];return n.sort(((n,o)=>Number(n.coords.distanceTo(e))+n.coords.distanceTo(t)-(o.coords.distanceTo(e)+o.coords.distanceTo(t))+50*(Math.abs(r.Level.diff(e.level,n.coords.level)||0)+Math.abs(r.Level.diff(t.level,n.coords.level)||0)-(Math.abs(r.Level.diff(e.level,o.coords.level)||0)+Math.abs(r.Level.diff(t.level,o.coords.level)||0)))))}getBestRouteFromEntryPointsToDestination(e,t,r){const n=this.getOrderedEntryPointsSortedByDistance(e,t);for(const o of n){const e=this.router.calculateShortestPath(o.coords,t,r).route();if(e.hasRoute)return e}return null}getBestRouteFromOriginToEntryPoints(e,t,r){const n=this.getOrderedEntryPointsSortedByDistance(e,t);for(const o of n){const t=this.router.calculateShortestPath(e,o.coords,r).route();if(t.hasRoute)return t}return null}getRouteInsideMap(e,t,r){const n=this.router.calculateShortestPath(e,t,r).route();return n.hasRoute?n:null}getTripInsideMap(e,t){return this.router.getShortestTrip(e,t)}getRoutesMultipleDestinationsInsideMap(e,t,r){return this.router.calculateShortestPathToMultipleDestinations(e,t,r)}}var We={exports:{}};
1
+ "use strict";var e=Object.defineProperty,t=(t,r,n)=>(((t,r,n)=>{r in t?e(t,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[r]=n})(t,"symbol"!=typeof r?r+"":r,n),n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("@wemap/geo"),n=require("@wemap/maths"),o=require("@wemap/logger"),i=require("@wemap/salesman.js"),s=require("@mapbox/polyline"),a=require("@turf/boolean-point-in-polygon"),l=require("@wemap/osm");const c=class e{constructor(n,o,i={},s=e.currentUniqueId++){t(this,"level"),t(this,"bearing"),t(this,"length"),this.vertex1=n,this.vertex2=o,this.properties=i,this.id=s,this.level=r.Level.union(n.coords.level,o.coords.level),this.length=this.vertex1.distanceTo(this.vertex2),this.bearing=this.vertex1.bearingTo(this.vertex2)}static getEdgeByVertices(e,t,r){return e.find((e=>t===e.vertex1&&r===e.vertex2||r===e.vertex1&&t===e.vertex2))}reverseProperties(){const{properties:e}=this;e.incline&&(e.incline="up"===e.incline?"down":"up"),e.isOneway&&(e.isOneway=!1)}};t(c,"currentUniqueId",0);let u=c;class d{constructor(e,t,r,n){this.origin=e,this.distanceFromNearestElement=t,this.coords=r,this.nearestElement=n}}class p{constructor(e,r={}){t(this,"id",-1),this.coords=e,this.properties=r}distanceTo(e){return this.coords.distanceTo(e.coords)}bearingTo(e){return this.coords.bearingTo(e.coords)}toJson(){return{id:this.id,coords:this.coords.toCompressedJson(),...Object.keys(this.properties).length>0&&{properties:this.properties}}}equals(e){return this.coords.equals(e.coords)}static fromJson(e){const t=new p(r.Coordinates.fromCompressedJson(e.coords),e.properties);return t.id=e.id,t}}class h{constructor(e,r,n=null,o=[]){t(this,"exitVertices"),this.vertices=e,this.edges=r,this.routingBounds=n,this.routingBoundsEntryPoints=o;const i=r.filter((e=>null===e.level)).map((e=>[e.vertex1,e.vertex2])).flat(),s=r.filter((e=>null!==e.level)).map((e=>[e.vertex1,e.vertex2])).flat();this.exitVertices=new Set(i.filter((e=>s.includes(e)))),null==o||o.forEach((e=>this.exitVertices.add(e)))}getEdgeByVertices(e,t){return u.getEdgeByVertices(this.edges,e,t)}getVertexByCoords(e){return h.getVertexByCoords(this.vertices,e)}static getVertexByCoords(e,t){return e.find((e=>e.coords.equals(t)))}getVertexByName(e){return this.vertices.find((t=>t.properties.name===e))}getVerticesByName(e){return this.vertices.filter((t=>t.properties.name===e))}getEdgeByName(e){return this.edges.find((t=>t.properties.name===e))}getEdgesByName(e){return this.edges.filter((t=>t.properties.name===e))}getBoundingBox(e){if(!this.vertices.length)return null;const t=r.BoundingBox.fromCoordinates(this.vertices.map((e=>e.coords)));return e&&t.extendsWithMeasure(e),t}getProjection(e,t={}){const o="maxDistance"in t,i=t.maxDistance,s="maxBearingAngle"in t;if(s&&(!(e instanceof r.UserPosition)||null===e.bearing))return null;const a=t.maxBearingAngle,l="acceptEdgeFn"in t,c=!("useMultiLevelSegments"in t)||t.useMultiLevelSegments;let u=null;const p=t=>{if(!(e instanceof r.UserPosition))return t;const n=e.clone();return n.lat=t.lat,n.lng=t.lng,n.level=t.level,n.alt=t.alt,n.heightFromFloor=t.heightFromFloor,n.heightFromGround=t.heightFromGround,n};return this.edges.forEach((h=>{if(l&&!t.acceptEdgeFn(h))return;if(!c&&r.Level.isRange(h.level))return;if(!r.Level.intersect(h.level,e.level))return;if(s&&n.diffAngleLines(h.bearing,e.bearing)>a)return;const m=e.getSegmentProjection(h.vertex1.coords,h.vertex2.coords);if(!m)return;const f=m.distanceTo(e);o&&f>i||f<((null==u?void 0:u.distanceFromNearestElement)??Number.MAX_VALUE)&&(u=new d(e,f,p(m),h))})),s||this.vertices.forEach((t=>{let n=t.coords;if(this.exitVertices.has(t)&&null===e.level&&(n=t.coords.clone(),n.level=null),!c&&r.Level.isRange(n.level))return;if(!r.Level.intersect(n.level,e.level))return;const s=n.distanceTo(e);s<r.Constants.EPS_MM?u=new d(e,0,p(n),t):o&&s>i||s<((null==u?void 0:u.distanceFromNearestElement)??Number.MAX_VALUE)&&(u=new d(e,s,p(n),t))})),u}toJson(){return{vertices:this.vertices.map((e=>e.toJson())),edges:this.edges.map((e=>({id:e.id,vertex1Idx:this.vertices.indexOf(e.vertex1),vertex2Idx:this.vertices.indexOf(e.vertex2),...Object.keys(e.properties).length>0&&{properties:e.properties}}))),...this.routingBounds&&{routingBounds:this.routingBounds},...this.routingBoundsEntryPoints.length>0&&{routingBoundsEntryPoints:this.routingBoundsEntryPoints.map((e=>e.id))}}}static fromJson(e){var t;const r=e.vertices.map((e=>p.fromJson(e))),n=e.edges.map((e=>new u(r[e.vertex1Idx],r[e.vertex2Idx],e.properties,e.id)));return new h(r,n,e.routingBounds,null==(t=e.routingBoundsEntryPoints)?void 0:t.map((e=>r[e])))}toCompressedJson(){return{vertices:this.vertices.map((e=>e.coords.toCompressedJson())),verticesIds:this.vertices.map((e=>e.id)),edges:this.edges.map((e=>{const t=this.vertices.indexOf(e.vertex1),r=this.vertices.indexOf(e.vertex2),n=e.properties;return Object.keys(n).length>0?[t,r,n]:[t,r]}))}}static fromCompressedJson(e){const t=e.vertices.map((e=>new p(r.Coordinates.fromCompressedJson(e)))),n=e.edges.map((e=>new u(t[e[0]],t[e[1]],e.length>2?e[2]:{})));return new h(t,n)}static fromCoordinatesSegments(e){const t=[],r=[],n=e=>{const r=t.find((t=>t.coords.equals(e)));if(r)return r;const n=new p(e);return t.push(n),n};for(const o of e){let e=null;for(const t of o){const o=n(t);e&&r.push(new u(o,e)),e=o}}return new h(t,r)}getEdgesAtLevel(e,t=!0){return this.edges.filter((({level:n})=>t?r.Level.intersect(e,n):r.Level.contains(e,n)))}toDetailedString(){let e=`--- Network ---\nVertices: ${this.vertices.length}\nEdges: ${this.edges.length}\n---\nVertices\n`;return this.vertices.forEach((t=>{e+=t.id;const r=t.properties;0!==Object.keys(r).length&&(e+=` ${r}`)})),e+="---\nEdges\n",this.edges.forEach((t=>{e+=`${t.id} - [v1: ${t.vertex1.id}, v2: ${t.vertex2.id}]`;const r=t.properties;0!==Object.keys(r).length&&(e+=` ${r}`)})),e+="---",e}}function m(e,t=5){return e/(1e3*t/3600)}function f(e){const t=n.positiveMod(n.rad2deg(e),360);return t>0&&t<60?"sharp-right":t>=60&&t<140?"right":t>=140&&t<160?"slight-right":t>=160&&t<=200?"straight":t>200&&t<=220?"slight-left":t>220&&t<=300?"left":t>300&&t<360?"sharp-left":"u-turn"}function g(e){return["AIRPLANE","BOAT","BUS","FERRY","FUNICULAR","METRO","MULTI","TRAIN","TRAM"].includes(e)}function v(e,t){return e===t||g(e)&&"TRANSIT"===t||"WALK"===e&&"TRANSIT"===t}function y(e){return{...e.firstStep&&{firstStep:!0},...e.lastStep&&{lastStep:!0},number:e.number,type:e.type,coords:e.coords.toCompressedJson(),...null!==e.name&&{name:e.name},...null!==e.levelDifference&&{levelDifference:e.levelDifference},angle:Number(e.angle.toFixed(2)),previousBearing:Number(e.previousBearing.toFixed(2)),nextBearing:Number(e.nextBearing.toFixed(2)),distance:Number(e.distance.toFixed(1)),duration:Number(e.duration.toFixed(1)),direction:e.direction}}function b(e){return{...e,coords:r.Coordinates.fromCompressedJson(e.coords),firstStep:Boolean(e.firstStep),lastStep:Boolean(e.lastStep),name:e.name||null,levelDifference:e.levelDifference||null}}function w(e){return!!e&&("up"===e.direction||"down"===e.direction)}class E extends h{constructor(e,t,r,n,o){super(r,n),this.start=e,this.end=t,this.vertices=r,this.edges=n,this.edgesWeights=o}reverse(){const e=this.vertices.slice().reverse(),t=this.edges.slice().reverse(),r=this.edgesWeights.slice().reverse();return t.map((e=>new u(e.vertex2,e.vertex1,e.properties))),new E(this.start,this.end,e,t,r)}static fromCoordinates(e,t,r){const n=h.fromCoordinatesSegments([r]),o=n.edges.map((e=>m(e.length)));return new E(e,t,n.vertices,n.edges,o)}get hasRoute(){return Boolean(this.vertices.length)}}const T=n.deg2rad(20);class N{constructor(){t(this,"start",null),t(this,"end",null),t(this,"pathCoords",null),t(this,"stepsInfo",[])}setStart(e){return this.start=e,this}setEnd(e){return this.end=e,this}setPathCoords(e){return this.pathCoords=e,this}setStepsInfo(e){return this.stepsInfo=e,this}addStepInfo(e){return this.stepsInfo.push(e),this}setGraphRoute(e){const t=[],{start:o,end:i}=e;if(!e.hasRoute)return this;let s=null,a=o.bearingTo(e.vertices[0].coords);for(let c=0;c<e.vertices.length-1;c++){const o=e.vertices[c],i=o.coords,l=e.vertices[c+1],u=l.coords,d=e.edges[c],p=o.bearingTo(l),h=n.diffAngle(a,p+Math.PI),m=t.length?t[t.length-1]:null,{isSubwayEntrance:g,isGate:v,subwayEntranceRef:y}=o.properties,{isElevator:b,areEscalators:E,areStairs:N,isMovingWalkway:_,incline:S}=d.properties;let x;!N&&!b||!S||null!==(null==m?void 0:m.levelDifference)&&void 0!==(null==m?void 0:m.levelDifference)||(x=S);const A=c>0?e.edges[c-1]:null,I=(null==A?void 0:A.properties)||{},O=Boolean(I.incline&&I.areStairs&&(!S||!N)),R=o.properties.isSubwayEntrance,C=d.properties.name||y||null,D=e.edgesWeights[c];let M=Math.abs(n.diffAngle(Math.PI,h))>=T;const L=r.Level.isRange(d.level)&&!r.Level.isRange(i.level)||x;M=M&&!(i.level&&r.Level.isRange(i.level));const k=w(m)&&!r.Level.isRange(i.level)||O;if(!s||(M||L||k||R)){let e=null,n="turn";b?n="elevator":E?n="escalator":N?n="stairs":g?n="subway-entrance":v?n="gate":_?n="moving-walkway":L&&(n="incline-plane");let o=f(h);L&&(e=r.Level.diff(i.level,u.level)||0,o=e>0?"up":"down",x&&(o=x)),s={coords:i,...C&&{name:C},type:n,direction:o,levelDifference:e,distance:0,duration:0},t.push(s)}s.distance+=i.distanceTo(u),s.duration+=D,a=p}const l=e.vertices[e.vertices.length-1].coords;return r.Coordinates.equals(l,i)||t.push({coords:l,type:"arrive",direction:null}),this.setStart(o),this.setEnd(i),this.setPathCoords(e.vertices.map((e=>e.coords))),this.setStepsInfo(t),this}build(){const{pathCoords:e,start:t,end:r}=this;if(!e)return o.warn('StepsBuilder: Missing "pathCoords" property to build steps'),[];if(!t)return o.warn('StepsBuilder: Missing "from" property to build steps'),[];if(!r)return o.warn('StepsBuilder: Missing "to" property to build steps'),[];0===this.stepsInfo.length&&this.setGraphRoute(E.fromCoordinates(t,r,e));const{stepsInfo:i}=this;return i.map(((o,s)=>{const a=e.findIndex((e=>e.equals(o.coords)));if(-1===a)throw new Error("Cannot find step coordinates in itinerary coordinates.");const l=0===a?t:e[a-1],c=a===e.length-1?r:e[a+1],u=l.bearingTo(o.coords),d=o.coords.bearingTo(c),p=n.diffAngle(u,d+Math.PI);let h=o.type;const g=o.direction||f(p),v=0===s;let y=0;const b=s===i.length-1,w=b?e[e.length-1]:i[s+1].coords;let E=a;for(;!e[E].equals(w);)y+=e[E].distanceTo(e[E+1]),E++;return h||(h="straight"===g?"continue":g.includes("left")||g.includes("right")||"u-turn"===g?"turn":v?"depart":b?"arrive":null),{coords:o.coords,direction:"transit"===h?null:g,type:h,levelDifference:void 0!==o.levelDifference?o.levelDifference:null,name:o.name||null,number:s+1,previousBearing:u,nextBearing:d,angle:p,firstStep:v,lastStep:b,distance:y,duration:o.duration||m(y)}}))}}class _{constructor({start:e,end:n,coords:o,transitMode:i,duration:s,startTime:a,endTime:l,transportInfo:c,steps:u}){t(this,"start"),t(this,"end"),t(this,"coords"),t(this,"distance"),t(this,"transitMode"),t(this,"duration"),t(this,"startTime"),t(this,"endTime"),t(this,"steps"),t(this,"transportInfo"),this.start={name:e.name||null,coords:e.coords},this.end={name:n.name||null,coords:n.coords},this.coords=o,this.transitMode=i,this.distance=r.Utils.calcDistance(o),this.duration="number"==typeof s?s:m(this.distance),this.startTime="number"==typeof a?a:null,this.endTime="number"==typeof l?l:null,this.transportInfo=c||null,this.steps=Array.isArray(u)?u:(new N).setStart(e.coords).setEnd(n.coords).setPathCoords(o).build()}isPublicTransport(){return g(this.transitMode)}toGraph(){return h.fromCoordinatesSegments([this.coords])}static equals(e,t){var r,n;if(!(e.transitMode===t.transitMode&&Math.abs(e.duration-t.duration)<=.05&&e.startTime===t.startTime&&e.endTime===t.endTime&&e.start.name===t.start.name&&e.start.coords.equals(t.start.coords)&&e.end.name===t.end.name&&e.end.coords.equals(t.end.coords)&&e.coords.length===t.coords.length&&(e.steps===t.steps||(null==(r=e.steps)?void 0:r.length)===(null==(n=t.steps)?void 0:n.length))))return!1;let o;for(o=0;o<e.coords.length;o++)if(!e.coords[o].equals(t.coords[o]))return!1;for(o=0;o<e.steps.length;o++)if(i=e.steps[o],s=t.steps[o],!(i.coords.equals(s.coords)&&Math.abs(i.angle-s.angle)<=.005&&Math.abs(i.distance-s.distance)<=.05&&Math.abs(i.duration-s.duration)<=.05&&i.firstStep===s.firstStep&&i.lastStep===s.lastStep&&i.levelDifference===s.levelDifference&&i.type===s.type&&i.direction===s.direction&&i.name===s.name&&Math.abs(i.nextBearing-s.nextBearing)<=.005&&i.number===s.number&&Math.abs(i.previousBearing-s.previousBearing)<=.005))return!1;var i,s;if(e.transportInfo!==t.transportInfo){if(null===e.transportInfo||null===t.transportInfo)return!1;if(e.transportInfo.name!==t.transportInfo.name||e.transportInfo.routeColor!==t.transportInfo.routeColor||e.transportInfo.routeTextColor!==t.transportInfo.routeTextColor||e.transportInfo.directionName!==t.transportInfo.directionName)return!1}return!0}equals(e){return _.equals(this,e)}toJson(){return{transitMode:this.transitMode,start:{coords:this.start.coords.toCompressedJson(),...this.start.name&&{name:this.start.name}},end:{coords:this.end.coords.toCompressedJson(),...this.end.name&&{name:this.end.name}},distance:Number(this.distance.toFixed(1)),duration:Number(this.duration.toFixed(1)),coords:this.coords.map((e=>e.toCompressedJson())),steps:this.steps.map(y),...null!==this.startTime&&{startTime:this.startTime},...null!==this.endTime&&{endTime:this.endTime},...null!==this.transportInfo&&{transportInfo:this.transportInfo}}}static fromJson(e){var t;return new _(Object.assign({},e,{start:{coords:r.Coordinates.fromCompressedJson(e.start.coords),name:e.start.name||null},end:{coords:r.Coordinates.fromCompressedJson(e.end.coords),name:e.end.name||null},coords:e.coords.map(r.Coordinates.fromCompressedJson),steps:(null==(t=e.steps)?void 0:t.map(b))||null}))}static fromGraphRoute(e,t="WALK"){return new _({start:{coords:e.start},end:{coords:e.end},coords:e.vertices.map((e=>e.coords)),duration:e.edgesWeights.reduce(((e,t)=>e+t),0),transitMode:t,steps:(new N).setGraphRoute(e).build()})}multiplyLevel(e){this.start.coords.level=r.Level.multiplyBy(this.start.coords.level,e),this.end.coords.level=r.Level.multiplyBy(this.end.coords.level,e);for(const t of this.coords)t.level=r.Level.multiplyBy(t.level,e);this.steps.forEach((t=>{t.coords.level=r.Level.multiplyBy(t.coords.level,e)}))}}class S{constructor({origin:e,destination:r,duration:n,legs:o,startTime:i,endTime:s}){t(this,"origin"),t(this,"destination"),t(this,"duration"),t(this,"legs"),t(this,"_transitMode",null),t(this,"startTime"),t(this,"endTime"),t(this,"_coords",null),t(this,"_distance",null),this.origin=e,this.destination=r,this.legs=o,this.duration="number"==typeof n?n:this.legs.reduce(((e,t)=>e+t.duration),0),this.startTime="number"==typeof i?i:null,this.endTime="number"==typeof s?s:null,this.updateStepsFromLegs()}set coords(e){throw new Error("Itinerary.coords cannot be set. They are calculated from Itinerary.legs.")}get coords(){return this._coords||(this._coords=this.legs.map((e=>e.coords)).flat().filter(((e,t,r)=>0===t||!r[t-1].equals(e)))),this._coords}set steps(e){throw new Error("Itinerary.step cannot be set. They are calculated from Itinerary.legs.")}get steps(){return this.legs.map((e=>e.steps)).flat()}set price(e){throw new Error("Itinerary.price cannot be set. They are calculated from Itinerary.legs.")}get price(){return this.legs.reduce(((e,t)=>{var r;return e+((null==(r=t.transportInfo)?void 0:r.price)||0)}),0)}set transitMode(e){throw new Error("Itinerary.transitMode cannot be set. They are calculated from Itinerary.legs.")}get transitMode(){if(!this._transitMode){const e=new Set(this.legs.map((e=>e.transitMode)));if(e.delete("WALK"),e.size>1)return this._transitMode="MULTI",this._transitMode;if(1===e.size)return this._transitMode=e.values().next().value,this._transitMode;this._transitMode="WALK"}return this._transitMode}set distance(e){throw new Error("Itinerary.distance cannot be set. They are calculated from Itinerary.legs.")}get distance(){return null===this._distance&&(this._distance=r.Utils.calcDistance(this.coords)),this._distance}toGraph(){return h.fromCoordinatesSegments([this.coords])}static fromItineraries(...e){return new S({origin:e[0].origin,destination:e[e.length-1].destination,legs:e.map((e=>e.legs)).flat()})}static fromOrderedPointsArray(e,t,n){const o=e=>new r.Coordinates(e[0],e[1],null,e[2]);return this.fromOrderedCoordinates(e.map(o),o(t),o(n))}static fromOrderedCoordinates(e,t,r,n="WALK"){const o=(new N).setPathCoords(e).setStart(t).setEnd(r).build(),i=new _({start:{coords:t},end:{coords:r},coords:e,transitMode:n,steps:o});return new S({origin:t,destination:r,legs:[i]})}static equals(e,t){if(!(e.origin.equals(t.origin)&&e.destination.equals(t.destination)&&Math.abs(e.distance-t.distance)<=.05&&Math.abs(e.duration-t.duration)<=.05&&e.startTime===t.startTime&&e.endTime===t.endTime&&e.legs.length===t.legs.length))return!1;for(let r=0;r<e.legs.length;r++)if(!e.legs[r].equals(t.legs[r]))return!1;return!0}equals(e){return S.equals(this,e)}toJson(){return{origin:this.origin.toJson(),destination:this.destination.toJson(),distance:Number(this.distance.toFixed(1)),duration:Number(this.duration.toFixed(1)),transitMode:this.transitMode,legs:this.legs.map((e=>e.toJson())),...null!==this.startTime&&{startTime:this.startTime},...null!==this.endTime&&{endTime:this.endTime}}}static fromJson(e){return new S({origin:r.Coordinates.fromJson(e.origin),destination:r.Coordinates.fromJson(e.destination),duration:e.duration,legs:e.legs.map(_.fromJson),startTime:e.startTime,endTime:e.endTime})}static fromGraphRoute(e,t="WALK"){const r=_.fromGraphRoute(e,t);return new S({origin:e.start,destination:e.end,legs:[r]})}multiplyLevel(e){this.origin.level=r.Level.multiplyBy(this.origin.level,e),this.destination.level=r.Level.multiplyBy(this.destination.level,e),this.legs.forEach((t=>t.multiplyLevel(e)))}forceUnknownLevelTo0(){this.origin.level=this.origin.level||0,this.destination.level=this.destination.level||0;for(const e of this.legs){e.start.coords.level=e.start.coords.level||0,e.end.coords.level=e.end.coords.level||0;for(const t of e.coords)t.level=t.level||0;if(e.steps)for(const t of e.steps)t.coords.level=t.coords.level||0}if(this._coords)for(const e of this._coords)e.level=e.level||0}toGeoJson(){const e=(e,t,r)=>({type:"Feature",properties:{name:t,level:e.level,...r&&{type:r}},geometry:{type:"Point",coordinates:[e.lng,e.lat]}}),t=[...new Set(this.coords.map((e=>r.Level.toString(e.level))))].map(r.Level.fromString).map((e=>[e,r.Utils.createSegmentsAtLevel(this.coords,e,!0)])).map((([e,t])=>((e,t)=>({type:"Feature",properties:{level:t,name:null==t?void 0:t.toString()},geometry:{type:"MultiLineString",coordinates:e.map((e=>e.map((({lat:e,lng:t})=>[t,e]))))}}))(t,e))),n=this.legs.map(((t,r)=>e(t.start.coords,`Leg ${r} start`,"leg-start"))),o=this.legs.map(((t,r)=>e(t.end.coords,`Leg ${r} end`,"leg-end"))),i=this.steps.map((t=>e(t.coords,`Step ${t.number}`,"step")));return{type:"FeatureCollection",features:[e(this.origin,"origin","origin"),e(this.destination,"destination","destination"),...t,...n,...o,...i]}}updateStepsFromLegs(){const e=this.coords.filter(((e,t,r)=>0===t||!r[t-1].equals(e))),t=this.legs.map((e=>e.steps)).flat();t.map(((r,o)=>{const i=e.findIndex((e=>e.equals(r.coords)));if(-1===i)throw new Error("Cannot find step coordinates in itinerary coordinates.");const s=0===i?this.origin:e[i-1],a=i===e.length-1?this.destination:e[i+1];r.previousBearing=s.bearingTo(r.coords),r.nextBearing=r.coords.bearingTo(a),r.angle=n.diffAngle(r.previousBearing,r.nextBearing+Math.PI);const l=r.distance;r.distance=0;const c=o!==t.length-1?t[o+1].coords:e[e.length-1];let u=i;for(;!e[u].equals(c);)r.distance+=e[u].distanceTo(e[u+1]),u++;if(u===e.length-1&&(r.distance+=e[u].distanceTo(this.destination)),r.number=o+1,r.firstStep=0===o,r.lastStep=o===t.length-1,"arrive"===r.type&&!r.lastStep||"depart"===r.type&&!r.firstStep){const e=r.direction;e&&(e.includes("left")||e.includes("right")||"u-turn"===e)?r.type="turn":r.type="continue"}r.duration+=m(r.distance-l)}))}}var x="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function A(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var I,O,R={exports:{}};I=R,O=R.exports,function(e,t){var r="function",n="undefined",o="object",i="string",s="major",a="model",l="name",c="type",u="vendor",d="version",p="architecture",h="console",m="mobile",f="tablet",g="smarttv",v="wearable",y="embedded",b="Amazon",w="Apple",E="ASUS",T="BlackBerry",N="Browser",_="Chrome",S="Firefox",x="Google",A="Huawei",R="LG",C="Microsoft",D="Motorola",M="Opera",L="Samsung",k="Sharp",U="Sony",P="Xiaomi",q="Zebra",B="Facebook",F="Chromium OS",j="Mac OS",G=function(e){for(var t={},r=0;r<e.length;r++)t[e[r].toUpperCase()]=e[r];return t},W=function(e,t){return typeof e===i&&-1!==H(t).indexOf(H(e))},H=function(e){return e.toLowerCase()},V=function(e,t){if(typeof e===i)return e=e.replace(/^\s\s*/,""),typeof t===n?e:e.substring(0,350)},$=function(e,n){for(var i,s,a,l,c,u,d=0;d<n.length&&!c;){var p=n[d],h=n[d+1];for(i=s=0;i<p.length&&!c&&p[i];)if(c=p[i++].exec(e))for(a=0;a<h.length;a++)u=c[++s],typeof(l=h[a])===o&&l.length>0?2===l.length?typeof l[1]==r?this[l[0]]=l[1].call(this,u):this[l[0]]=l[1]:3===l.length?typeof l[1]!==r||l[1].exec&&l[1].test?this[l[0]]=u?u.replace(l[1],l[2]):t:this[l[0]]=u?l[1].call(this,u,l[2]):t:4===l.length&&(this[l[0]]=u?l[3].call(this,u.replace(l[1],l[2])):t):this[l]=u||t;d+=2}},z=function(e,r){for(var n in r)if(typeof r[n]===o&&r[n].length>0){for(var i=0;i<r[n].length;i++)if(W(r[n][i],e))return"?"===n?t:n}else if(W(r[n],e))return"?"===n?t:n;return e},Y={ME:"4.90","NT 3.11":"NT3.51","NT 4.0":"NT4.0",2e3:"NT 5.0",XP:["NT 5.1","NT 5.2"],Vista:"NT 6.0",7:"NT 6.1",8:"NT 6.2",8.1:"NT 6.3",10:["NT 6.4","NT 10.0"],RT:"ARM"},K={browser:[[/\b(?:crmo|crios)\/([\w\.]+)/i],[d,[l,"Chrome"]],[/edg(?:e|ios|a)?\/([\w\.]+)/i],[d,[l,"Edge"]],[/(opera mini)\/([-\w\.]+)/i,/(opera [mobiletab]{3,6})\b.+version\/([-\w\.]+)/i,/(opera)(?:.+version\/|[\/ ]+)([\w\.]+)/i],[l,d],[/opios[\/ ]+([\w\.]+)/i],[d,[l,M+" Mini"]],[/\bopr\/([\w\.]+)/i],[d,[l,M]],[/(kindle)\/([\w\.]+)/i,/(lunascape|maxthon|netfront|jasmine|blazer)[\/ ]?([\w\.]*)/i,/(avant |iemobile|slim)(?:browser)?[\/ ]?([\w\.]*)/i,/(ba?idubrowser)[\/ ]?([\w\.]+)/i,/(?:ms|\()(ie) ([\w\.]+)/i,/(flock|rockmelt|midori|epiphany|silk|skyfire|bolt|iron|vivaldi|iridium|phantomjs|bowser|quark|qupzilla|falkon|rekonq|puffin|brave|whale(?!.+naver)|qqbrowserlite|qq|duckduckgo)\/([-\w\.]+)/i,/(heytap|ovi)browser\/([\d\.]+)/i,/(weibo)__([\d\.]+)/i],[l,d],[/(?:\buc? ?browser|(?:juc.+)ucweb)[\/ ]?([\w\.]+)/i],[d,[l,"UC"+N]],[/microm.+\bqbcore\/([\w\.]+)/i,/\bqbcore\/([\w\.]+).+microm/i],[d,[l,"WeChat(Win) Desktop"]],[/micromessenger\/([\w\.]+)/i],[d,[l,"WeChat"]],[/konqueror\/([\w\.]+)/i],[d,[l,"Konqueror"]],[/trident.+rv[: ]([\w\.]{1,9})\b.+like gecko/i],[d,[l,"IE"]],[/ya(?:search)?browser\/([\w\.]+)/i],[d,[l,"Yandex"]],[/(avast|avg)\/([\w\.]+)/i],[[l,/(.+)/,"$1 Secure "+N],d],[/\bfocus\/([\w\.]+)/i],[d,[l,S+" Focus"]],[/\bopt\/([\w\.]+)/i],[d,[l,M+" Touch"]],[/coc_coc\w+\/([\w\.]+)/i],[d,[l,"Coc Coc"]],[/dolfin\/([\w\.]+)/i],[d,[l,"Dolphin"]],[/coast\/([\w\.]+)/i],[d,[l,M+" Coast"]],[/miuibrowser\/([\w\.]+)/i],[d,[l,"MIUI "+N]],[/fxios\/([-\w\.]+)/i],[d,[l,S]],[/\bqihu|(qi?ho?o?|360)browser/i],[[l,"360 "+N]],[/(oculus|samsung|sailfish|huawei)browser\/([\w\.]+)/i],[[l,/(.+)/,"$1 "+N],d],[/(comodo_dragon)\/([\w\.]+)/i],[[l,/_/g," "],d],[/(electron)\/([\w\.]+) safari/i,/(tesla)(?: qtcarbrowser|\/(20\d\d\.[-\w\.]+))/i,/m?(qqbrowser|baiduboxapp|2345Explorer)[\/ ]?([\w\.]+)/i],[l,d],[/(metasr)[\/ ]?([\w\.]+)/i,/(lbbrowser)/i,/\[(linkedin)app\]/i],[l],[/((?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/([\w\.]+);)/i],[[l,B],d],[/(kakao(?:talk|story))[\/ ]([\w\.]+)/i,/(naver)\(.*?(\d+\.[\w\.]+).*\)/i,/safari (line)\/([\w\.]+)/i,/\b(line)\/([\w\.]+)\/iab/i,/(chromium|instagram)[\/ ]([-\w\.]+)/i],[l,d],[/\bgsa\/([\w\.]+) .*safari\//i],[d,[l,"GSA"]],[/musical_ly(?:.+app_?version\/|_)([\w\.]+)/i],[d,[l,"TikTok"]],[/headlesschrome(?:\/([\w\.]+)| )/i],[d,[l,_+" Headless"]],[/ wv\).+(chrome)\/([\w\.]+)/i],[[l,_+" WebView"],d],[/droid.+ version\/([\w\.]+)\b.+(?:mobile safari|safari)/i],[d,[l,"Android "+N]],[/(chrome|omniweb|arora|[tizenoka]{5} ?browser)\/v?([\w\.]+)/i],[l,d],[/version\/([\w\.\,]+) .*mobile\/\w+ (safari)/i],[d,[l,"Mobile Safari"]],[/version\/([\w(\.|\,)]+) .*(mobile ?safari|safari)/i],[d,l],[/webkit.+?(mobile ?safari|safari)(\/[\w\.]+)/i],[l,[d,z,{"1.0":"/8",1.2:"/1",1.3:"/3","2.0":"/412","2.0.2":"/416","2.0.3":"/417","2.0.4":"/419","?":"/"}]],[/(webkit|khtml)\/([\w\.]+)/i],[l,d],[/(navigator|netscape\d?)\/([-\w\.]+)/i],[[l,"Netscape"],d],[/mobile vr; rv:([\w\.]+)\).+firefox/i],[d,[l,S+" Reality"]],[/ekiohf.+(flow)\/([\w\.]+)/i,/(swiftfox)/i,/(icedragon|iceweasel|camino|chimera|fennec|maemo browser|minimo|conkeror|klar)[\/ ]?([\w\.\+]+)/i,/(seamonkey|k-meleon|icecat|iceape|firebird|phoenix|palemoon|basilisk|waterfox)\/([-\w\.]+)$/i,/(firefox)\/([\w\.]+)/i,/(mozilla)\/([\w\.]+) .+rv\:.+gecko\/\d+/i,/(polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf|sleipnir|obigo|mosaic|(?:go|ice|up)[\. ]?browser)[-\/ ]?v?([\w\.]+)/i,/(links) \(([\w\.]+)/i,/panasonic;(viera)/i],[l,d],[/(cobalt)\/([\w\.]+)/i],[l,[d,/master.|lts./,""]]],cpu:[[/(?:(amd|x(?:(?:86|64)[-_])?|wow|win)64)[;\)]/i],[[p,"amd64"]],[/(ia32(?=;))/i],[[p,H]],[/((?:i[346]|x)86)[;\)]/i],[[p,"ia32"]],[/\b(aarch64|arm(v?8e?l?|_?64))\b/i],[[p,"arm64"]],[/\b(arm(?:v[67])?ht?n?[fl]p?)\b/i],[[p,"armhf"]],[/windows (ce|mobile); ppc;/i],[[p,"arm"]],[/((?:ppc|powerpc)(?:64)?)(?: mac|;|\))/i],[[p,/ower/,"",H]],[/(sun4\w)[;\)]/i],[[p,"sparc"]],[/((?:avr32|ia64(?=;))|68k(?=\))|\barm(?=v(?:[1-7]|[5-7]1)l?|;|eabi)|(?=atmel )avr|(?:irix|mips|sparc)(?:64)?\b|pa-risc)/i],[[p,H]]],device:[[/\b(sch-i[89]0\d|shw-m380s|sm-[ptx]\w{2,4}|gt-[pn]\d{2,4}|sgh-t8[56]9|nexus 10)/i],[a,[u,L],[c,f]],[/\b((?:s[cgp]h|gt|sm)-\w+|sc[g-]?[\d]+a?|galaxy nexus)/i,/samsung[- ]([-\w]+)/i,/sec-(sgh\w+)/i],[a,[u,L],[c,m]],[/(?:\/|\()(ip(?:hone|od)[\w, ]*)(?:\/|;)/i],[a,[u,w],[c,m]],[/\((ipad);[-\w\),; ]+apple/i,/applecoremedia\/[\w\.]+ \((ipad)/i,/\b(ipad)\d\d?,\d\d?[;\]].+ios/i],[a,[u,w],[c,f]],[/(macintosh);/i],[a,[u,w]],[/\b(sh-?[altvz]?\d\d[a-ekm]?)/i],[a,[u,k],[c,m]],[/\b((?:ag[rs][23]?|bah2?|sht?|btv)-a?[lw]\d{2})\b(?!.+d\/s)/i],[a,[u,A],[c,f]],[/(?:huawei|honor)([-\w ]+)[;\)]/i,/\b(nexus 6p|\w{2,4}e?-[atu]?[ln][\dx][012359c][adn]?)\b(?!.+d\/s)/i],[a,[u,A],[c,m]],[/\b(poco[\w ]+)(?: bui|\))/i,/\b; (\w+) build\/hm\1/i,/\b(hm[-_ ]?note?[_ ]?(?:\d\w)?) bui/i,/\b(redmi[\-_ ]?(?:note|k)?[\w_ ]+)(?: bui|\))/i,/\b(mi[-_ ]?(?:a\d|one|one[_ ]plus|note lte|max|cc)?[_ ]?(?:\d?\w?)[_ ]?(?:plus|se|lite)?)(?: bui|\))/i],[[a,/_/g," "],[u,P],[c,m]],[/\b(mi[-_ ]?(?:pad)(?:[\w_ ]+))(?: bui|\))/i],[[a,/_/g," "],[u,P],[c,f]],[/; (\w+) bui.+ oppo/i,/\b(cph[12]\d{3}|p(?:af|c[al]|d\w|e[ar])[mt]\d0|x9007|a101op)\b/i],[a,[u,"OPPO"],[c,m]],[/vivo (\w+)(?: bui|\))/i,/\b(v[12]\d{3}\w?[at])(?: bui|;)/i],[a,[u,"Vivo"],[c,m]],[/\b(rmx[12]\d{3})(?: bui|;|\))/i],[a,[u,"Realme"],[c,m]],[/\b(milestone|droid(?:[2-4x]| (?:bionic|x2|pro|razr))?:?( 4g)?)\b[\w ]+build\//i,/\bmot(?:orola)?[- ](\w*)/i,/((?:moto[\w\(\) ]+|xt\d{3,4}|nexus 6)(?= bui|\)))/i],[a,[u,D],[c,m]],[/\b(mz60\d|xoom[2 ]{0,2}) build\//i],[a,[u,D],[c,f]],[/((?=lg)?[vl]k\-?\d{3}) bui| 3\.[-\w; ]{10}lg?-([06cv9]{3,4})/i],[a,[u,R],[c,f]],[/(lm(?:-?f100[nv]?|-[\w\.]+)(?= bui|\))|nexus [45])/i,/\blg[-e;\/ ]+((?!browser|netcast|android tv)\w+)/i,/\blg-?([\d\w]+) bui/i],[a,[u,R],[c,m]],[/(ideatab[-\w ]+)/i,/lenovo ?(s[56]000[-\w]+|tab(?:[\w ]+)|yt[-\d\w]{6}|tb[-\d\w]{6})/i],[a,[u,"Lenovo"],[c,f]],[/(?:maemo|nokia).*(n900|lumia \d+)/i,/nokia[-_ ]?([-\w\.]*)/i],[[a,/_/g," "],[u,"Nokia"],[c,m]],[/(pixel c)\b/i],[a,[u,x],[c,f]],[/droid.+; (pixel[\daxl ]{0,6})(?: bui|\))/i],[a,[u,x],[c,m]],[/droid.+ (a?\d[0-2]{2}so|[c-g]\d{4}|so[-gl]\w+|xq-a\w[4-7][12])(?= bui|\).+chrome\/(?![1-6]{0,1}\d\.))/i],[a,[u,U],[c,m]],[/sony tablet [ps]/i,/\b(?:sony)?sgp\w+(?: bui|\))/i],[[a,"Xperia Tablet"],[u,U],[c,f]],[/ (kb2005|in20[12]5|be20[12][59])\b/i,/(?:one)?(?:plus)? (a\d0\d\d)(?: b|\))/i],[a,[u,"OnePlus"],[c,m]],[/(alexa)webm/i,/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i,/(kf[a-z]+)( bui|\)).+silk\//i],[a,[u,b],[c,f]],[/((?:sd|kf)[0349hijorstuw]+)( bui|\)).+silk\//i],[[a,/(.+)/g,"Fire Phone $1"],[u,b],[c,m]],[/(playbook);[-\w\),; ]+(rim)/i],[a,u,[c,f]],[/\b((?:bb[a-f]|st[hv])100-\d)/i,/\(bb10; (\w+)/i],[a,[u,T],[c,m]],[/(?:\b|asus_)(transfo[prime ]{4,10} \w+|eeepc|slider \w+|nexus 7|padfone|p00[cj])/i],[a,[u,E],[c,f]],[/ (z[bes]6[027][012][km][ls]|zenfone \d\w?)\b/i],[a,[u,E],[c,m]],[/(nexus 9)/i],[a,[u,"HTC"],[c,f]],[/(htc)[-;_ ]{1,2}([\w ]+(?=\)| bui)|\w+)/i,/(zte)[- ]([\w ]+?)(?: bui|\/|\))/i,/(alcatel|geeksphone|nexian|panasonic(?!(?:;|\.))|sony(?!-bra))[-_ ]?([-\w]*)/i],[u,[a,/_/g," "],[c,m]],[/droid.+; ([ab][1-7]-?[0178a]\d\d?)/i],[a,[u,"Acer"],[c,f]],[/droid.+; (m[1-5] note) bui/i,/\bmz-([-\w]{2,})/i],[a,[u,"Meizu"],[c,m]],[/(blackberry|benq|palm(?=\-)|sonyericsson|acer|asus|dell|meizu|motorola|polytron)[-_ ]?([-\w]*)/i,/(hp) ([\w ]+\w)/i,/(asus)-?(\w+)/i,/(microsoft); (lumia[\w ]+)/i,/(lenovo)[-_ ]?([-\w]+)/i,/(jolla)/i,/(oppo) ?([\w ]+) bui/i],[u,a,[c,m]],[/(kobo)\s(ereader|touch)/i,/(archos) (gamepad2?)/i,/(hp).+(touchpad(?!.+tablet)|tablet)/i,/(kindle)\/([\w\.]+)/i,/(nook)[\w ]+build\/(\w+)/i,/(dell) (strea[kpr\d ]*[\dko])/i,/(le[- ]+pan)[- ]+(\w{1,9}) bui/i,/(trinity)[- ]*(t\d{3}) bui/i,/(gigaset)[- ]+(q\w{1,9}) bui/i,/(vodafone) ([\w ]+)(?:\)| bui)/i],[u,a,[c,f]],[/(surface duo)/i],[a,[u,C],[c,f]],[/droid [\d\.]+; (fp\du?)(?: b|\))/i],[a,[u,"Fairphone"],[c,m]],[/(u304aa)/i],[a,[u,"AT&T"],[c,m]],[/\bsie-(\w*)/i],[a,[u,"Siemens"],[c,m]],[/\b(rct\w+) b/i],[a,[u,"RCA"],[c,f]],[/\b(venue[\d ]{2,7}) b/i],[a,[u,"Dell"],[c,f]],[/\b(q(?:mv|ta)\w+) b/i],[a,[u,"Verizon"],[c,f]],[/\b(?:barnes[& ]+noble |bn[rt])([\w\+ ]*) b/i],[a,[u,"Barnes & Noble"],[c,f]],[/\b(tm\d{3}\w+) b/i],[a,[u,"NuVision"],[c,f]],[/\b(k88) b/i],[a,[u,"ZTE"],[c,f]],[/\b(nx\d{3}j) b/i],[a,[u,"ZTE"],[c,m]],[/\b(gen\d{3}) b.+49h/i],[a,[u,"Swiss"],[c,m]],[/\b(zur\d{3}) b/i],[a,[u,"Swiss"],[c,f]],[/\b((zeki)?tb.*\b) b/i],[a,[u,"Zeki"],[c,f]],[/\b([yr]\d{2}) b/i,/\b(dragon[- ]+touch |dt)(\w{5}) b/i],[[u,"Dragon Touch"],a,[c,f]],[/\b(ns-?\w{0,9}) b/i],[a,[u,"Insignia"],[c,f]],[/\b((nxa|next)-?\w{0,9}) b/i],[a,[u,"NextBook"],[c,f]],[/\b(xtreme\_)?(v(1[045]|2[015]|[3469]0|7[05])) b/i],[[u,"Voice"],a,[c,m]],[/\b(lvtel\-)?(v1[12]) b/i],[[u,"LvTel"],a,[c,m]],[/\b(ph-1) /i],[a,[u,"Essential"],[c,m]],[/\b(v(100md|700na|7011|917g).*\b) b/i],[a,[u,"Envizen"],[c,f]],[/\b(trio[-\w\. ]+) b/i],[a,[u,"MachSpeed"],[c,f]],[/\btu_(1491) b/i],[a,[u,"Rotor"],[c,f]],[/(shield[\w ]+) b/i],[a,[u,"Nvidia"],[c,f]],[/(sprint) (\w+)/i],[u,a,[c,m]],[/(kin\.[onetw]{3})/i],[[a,/\./g," "],[u,C],[c,m]],[/droid.+; (cc6666?|et5[16]|mc[239][23]x?|vc8[03]x?)\)/i],[a,[u,q],[c,f]],[/droid.+; (ec30|ps20|tc[2-8]\d[kx])\)/i],[a,[u,q],[c,m]],[/smart-tv.+(samsung)/i],[u,[c,g]],[/hbbtv.+maple;(\d+)/i],[[a,/^/,"SmartTV"],[u,L],[c,g]],[/(nux; netcast.+smarttv|lg (netcast\.tv-201\d|android tv))/i],[[u,R],[c,g]],[/(apple) ?tv/i],[u,[a,w+" TV"],[c,g]],[/crkey/i],[[a,_+"cast"],[u,x],[c,g]],[/droid.+aft(\w)( bui|\))/i],[a,[u,b],[c,g]],[/\(dtv[\);].+(aquos)/i,/(aquos-tv[\w ]+)\)/i],[a,[u,k],[c,g]],[/(bravia[\w ]+)( bui|\))/i],[a,[u,U],[c,g]],[/(mitv-\w{5}) bui/i],[a,[u,P],[c,g]],[/Hbbtv.*(technisat) (.*);/i],[u,a,[c,g]],[/\b(roku)[\dx]*[\)\/]((?:dvp-)?[\d\.]*)/i,/hbbtv\/\d+\.\d+\.\d+ +\([\w\+ ]*; *([\w\d][^;]*);([^;]*)/i],[[u,V],[a,V],[c,g]],[/\b(android tv|smart[- ]?tv|opera tv|tv; rv:)\b/i],[[c,g]],[/(ouya)/i,/(nintendo) ([wids3utch]+)/i],[u,a,[c,h]],[/droid.+; (shield) bui/i],[a,[u,"Nvidia"],[c,h]],[/(playstation [345portablevi]+)/i],[a,[u,U],[c,h]],[/\b(xbox(?: one)?(?!; xbox))[\); ]/i],[a,[u,C],[c,h]],[/((pebble))app/i],[u,a,[c,v]],[/(watch)(?: ?os[,\/]|\d,\d\/)[\d\.]+/i],[a,[u,w],[c,v]],[/droid.+; (glass) \d/i],[a,[u,x],[c,v]],[/droid.+; (wt63?0{2,3})\)/i],[a,[u,q],[c,v]],[/(quest( 2| pro)?)/i],[a,[u,B],[c,v]],[/(tesla)(?: qtcarbrowser|\/[-\w\.]+)/i],[u,[c,y]],[/(aeobc)\b/i],[a,[u,b],[c,y]],[/droid .+?; ([^;]+?)(?: bui|\) applew).+? mobile safari/i],[a,[c,m]],[/droid .+?; ([^;]+?)(?: bui|\) applew).+?(?! mobile) safari/i],[a,[c,f]],[/\b((tablet|tab)[;\/]|focus\/\d(?!.+mobile))/i],[[c,f]],[/(phone|mobile(?:[;\/]| [ \w\/\.]*safari)|pda(?=.+windows ce))/i],[[c,m]],[/(android[-\w\. ]{0,9});.+buil/i],[a,[u,"Generic"]]],engine:[[/windows.+ edge\/([\w\.]+)/i],[d,[l,"EdgeHTML"]],[/webkit\/537\.36.+chrome\/(?!27)([\w\.]+)/i],[d,[l,"Blink"]],[/(presto)\/([\w\.]+)/i,/(webkit|trident|netfront|netsurf|amaya|lynx|w3m|goanna)\/([\w\.]+)/i,/ekioh(flow)\/([\w\.]+)/i,/(khtml|tasman|links)[\/ ]\(?([\w\.]+)/i,/(icab)[\/ ]([23]\.[\d\.]+)/i,/\b(libweb)/i],[l,d],[/rv\:([\w\.]{1,9})\b.+(gecko)/i],[d,l]],os:[[/microsoft (windows) (vista|xp)/i],[l,d],[/(windows) nt 6\.2; (arm)/i,/(windows (?:phone(?: os)?|mobile))[\/ ]?([\d\.\w ]*)/i,/(windows)[\/ ]?([ntce\d\. ]+\w)(?!.+xbox)/i],[l,[d,z,Y]],[/(win(?=3|9|n)|win 9x )([nt\d\.]+)/i],[[l,"Windows"],[d,z,Y]],[/ip[honead]{2,4}\b(?:.*os ([\w]+) like mac|; opera)/i,/ios;fbsv\/([\d\.]+)/i,/cfnetwork\/.+darwin/i],[[d,/_/g,"."],[l,"iOS"]],[/(mac os x) ?([\w\. ]*)/i,/(macintosh|mac_powerpc\b)(?!.+haiku)/i],[[l,j],[d,/_/g,"."]],[/droid ([\w\.]+)\b.+(android[- ]x86|harmonyos)/i],[d,l],[/(android|webos|qnx|bada|rim tablet os|maemo|meego|sailfish)[-\/ ]?([\w\.]*)/i,/(blackberry)\w*\/([\w\.]*)/i,/(tizen|kaios)[\/ ]([\w\.]+)/i,/\((series40);/i],[l,d],[/\(bb(10);/i],[d,[l,T]],[/(?:symbian ?os|symbos|s60(?=;)|series60)[-\/ ]?([\w\.]*)/i],[d,[l,"Symbian"]],[/mozilla\/[\d\.]+ \((?:mobile|tablet|tv|mobile; [\w ]+); rv:.+ gecko\/([\w\.]+)/i],[d,[l,S+" OS"]],[/web0s;.+rt(tv)/i,/\b(?:hp)?wos(?:browser)?\/([\w\.]+)/i],[d,[l,"webOS"]],[/watch(?: ?os[,\/]|\d,\d\/)([\d\.]+)/i],[d,[l,"watchOS"]],[/crkey\/([\d\.]+)/i],[d,[l,_+"cast"]],[/(cros) [\w]+(?:\)| ([\w\.]+)\b)/i],[[l,F],d],[/panasonic;(viera)/i,/(netrange)mmh/i,/(nettv)\/(\d+\.[\w\.]+)/i,/(nintendo|playstation) ([wids345portablevuch]+)/i,/(xbox); +xbox ([^\);]+)/i,/\b(joli|palm)\b ?(?:os)?\/?([\w\.]*)/i,/(mint)[\/\(\) ]?(\w*)/i,/(mageia|vectorlinux)[; ]/i,/([kxln]?ubuntu|debian|suse|opensuse|gentoo|arch(?= linux)|slackware|fedora|mandriva|centos|pclinuxos|red ?hat|zenwalk|linpus|raspbian|plan 9|minix|risc os|contiki|deepin|manjaro|elementary os|sabayon|linspire)(?: gnu\/linux)?(?: enterprise)?(?:[- ]linux)?(?:-gnu)?[-\/ ]?(?!chrom|package)([-\w\.]*)/i,/(hurd|linux) ?([\w\.]*)/i,/(gnu) ?([\w\.]*)/i,/\b([-frentopcghs]{0,5}bsd|dragonfly)[\/ ]?(?!amd|[ix346]{1,2}86)([\w\.]*)/i,/(haiku) (\w+)/i],[l,d],[/(sunos) ?([\w\.\d]*)/i],[[l,"Solaris"],d],[/((?:open)?solaris)[-\/ ]?([\w\.]*)/i,/(aix) ((\d)(?=\.|\)| )[\w\.])*/i,/\b(beos|os\/2|amigaos|morphos|openvms|fuchsia|hp-ux|serenityos)/i,/(unix) ?([\w\.]*)/i],[l,d]]},J=function(h,g){if(typeof h===o&&(g=h,h=t),!(this instanceof J))return new J(h,g).getResult();var v=typeof e!==n&&e.navigator?e.navigator:t,y=h||(v&&v.userAgent?v.userAgent:""),b=v&&v.userAgentData?v.userAgentData:t,w=g?function(e,t){var r={};for(var n in e)t[n]&&t[n].length%2==0?r[n]=t[n].concat(e[n]):r[n]=e[n];return r}(K,g):K,E=v&&v.userAgent==y;return this.getBrowser=function(){var e,n={};return n[l]=t,n[d]=t,$.call(n,y,w.browser),n[s]=typeof(e=n[d])===i?e.replace(/[^\d\.]/g,"").split(".")[0]:t,E&&v&&v.brave&&typeof v.brave.isBrave==r&&(n[l]="Brave"),n},this.getCPU=function(){var e={};return e[p]=t,$.call(e,y,w.cpu),e},this.getDevice=function(){var e={};return e[u]=t,e[a]=t,e[c]=t,$.call(e,y,w.device),E&&!e[c]&&b&&b.mobile&&(e[c]=m),E&&"Macintosh"==e[a]&&v&&typeof v.standalone!==n&&v.maxTouchPoints&&v.maxTouchPoints>2&&(e[a]="iPad",e[c]=f),e},this.getEngine=function(){var e={};return e[l]=t,e[d]=t,$.call(e,y,w.engine),e},this.getOS=function(){var e={};return e[l]=t,e[d]=t,$.call(e,y,w.os),E&&!e[l]&&b&&"Unknown"!=b.platform&&(e[l]=b.platform.replace(/chrome os/i,F).replace(/macos/i,j)),e},this.getResult=function(){return{ua:this.getUA(),browser:this.getBrowser(),engine:this.getEngine(),os:this.getOS(),device:this.getDevice(),cpu:this.getCPU()}},this.getUA=function(){return y},this.setUA=function(e){return y=typeof e===i&&e.length>350?V(e,350):e,this},this.setUA(y),this};J.VERSION="1.0.35",J.BROWSER=G([l,d,s]),J.CPU=G([p]),J.DEVICE=G([a,u,c,h,m,g,f,v,y]),J.ENGINE=J.OS=G([l,d]),I.exports&&(O=I.exports=J),O.UAParser=J;var X=typeof e!==n&&(e.jQuery||e.Zepto);if(X&&!X.ua){var Q=new J;X.ua=Q.getResult(),X.ua.get=function(){return Q.getUA()},X.ua.set=function(e){Q.setUA(e);var t=Q.getResult();for(var r in t)X.ua[r]=t[r]}}}("object"==typeof window?window:x);var C=Object.defineProperty,D=(e,t,r)=>(((e,t,r)=>{t in e?C(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(e,"symbol"!=typeof t?t+"":t,r),r);const M="Unknown",L="Safari",k="Firefox",U="Opera",P="Chrome",q="iOS-webview";class B{static getName(){if(!this._name)if("undefined"!=typeof navigator&&navigator){const{userAgent:e}=navigator;e.match(/Firefox/i)?this._name=k:e.match(/(Opera|OPR)/i)?this._name=U:e.match(/Chrome/i)?this._name=P:e.match(/Safari/i)?this._name=L:e.match(/(iPhone|iPod|iPad).*AppleWebKit(?!.*Version)/i)?this._name=q:this._name=M}else this._name=M;return this._name}static get isMobile(){if(null===this._isMobile&&(this._isMobile=!1,"undefined"!=typeof navigator&&navigator)){const e=navigator.userAgent||navigator.vendor;e&&(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(e)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(e.substr(0,4)))&&(this._isMobile=!0)}return this._isMobile}static clearCache(){this._name=null,this._isMobile=null}}D(B,"_name",null),D(B,"_isMobile",null);const F=[4215763,14529296,11869460,48895,16468400,45661,13290186];const j=Object.freeze(Object.defineProperty({__proto__:null,getQualitativeColor:function(e){return F[e%F.length]}},Symbol.toStringTag,{value:"Module"}));const G=Object.freeze(Object.defineProperty({__proto__:null,formatSO:function(e,...t){let r=e.toString();if(t.length){const e=typeof t[0],n="string"===e||"number"===e?t.slice():t[0];for(const t in n)r=r.replace(new RegExp("\\{"+t+"\\}","gi"),n[t])}return r},toUpperCase:function(e){return e.toUpperCase()}},Symbol.toStringTag,{value:"Module"})),W=4,H=3,V={wheelchair:{horrible:.1,bad:.5,intermediate:.7,good:.9,excellent:1},default:{horrible:.4,bad:.7,intermediate:.8,good:.9,excellent:1}},$={wheelchair:{asphalt:1,concrete:1,paved:1,paving_stones:.8,compacted:.7,wood:.6,metal:.5,gravel:.3,grass:.2,ground:.2},default:{asphalt:1,concrete:1,paved:1,paving_stones:.9,compacted:.8,wood:.8,metal:.7,gravel:.6,grass:.5,ground:.4}},z=class e{constructor(){t(this,"avoidStairs",!1),t(this,"avoidEscalators",!1),t(this,"avoidElevators",!1),t(this,"avoidMovingWalkways",!1),t(this,"avoidTicketRestrictedAreas",!1),t(this,"useMultiLevelSegments",!1),t(this,"projectionMaxDistance"),t(this,"isWheelchair",!1)}setAvoidStairs(e){return this.avoidStairs=e,this}setAvoidEscalators(e){return this.avoidEscalators=e,this}setAvoidElevators(e){return this.avoidElevators=e,this}setAvoidMovingWalkways(e){return this.avoidMovingWalkways=e,this}setAvoidTicketRestrictedAreas(e){return this.avoidTicketRestrictedAreas=e,this}setUseMultiLevelSegments(e){return this.useMultiLevelSegments=e,this}setIsWheelchair(e){return this.isWheelchair=e,this}static fromJson(t){const r=new e;return Object.assign(r,t),r.build()}build(){return{input:{avoidStairs:this.avoidStairs,avoidEscalators:this.avoidEscalators,avoidElevators:this.avoidElevators,avoidMovingWalkways:this.avoidMovingWalkways,avoidTicketRestrictedAreas:this.avoidTicketRestrictedAreas,isWheelchair:this.isWheelchair,projectionMaxDistance:this.projectionMaxDistance},weightEdgeFn:e=>{if(e.properties.isElevator)return 90;const t=this.isWheelchair?H:W;let r=m(e.length,t);if(e.properties.areStairs)r*=3;else if(e.properties.areEscalators)r*=1.5;else if(e.properties.isMovingWalkway)r*=.8;else if(e.properties.smoothness){const t=this.isWheelchair?"wheelchair":"default";r*=V[t][e.properties.smoothness]??1}else if(e.properties.surface){const t=this.isWheelchair?"wheelchair":"default";r*=$[t][e.properties.surface]??1}else"limited"===e.properties.wheelchair&&(r*=.5);return r},weightVertexFn:e=>e.properties.isTurnstile?10:0,acceptEdgeFn:e=>{if(e.properties.wheelchair){if(this.isWheelchair&&"no"===e.properties.wheelchair)return!1;if(!this.isWheelchair&&"designated"===e.properties.wheelchair)return!1}if(this.isWheelchair){if(e.properties.areStairs)return!1;if(e.properties.areEscalators)return!1;if(e.properties.isMovingWalkway)return!1}return(!this.avoidStairs||!e.properties.areStairs)&&((!this.avoidEscalators||!e.properties.areEscalators)&&((!this.avoidElevators||!e.properties.isElevator)&&((!this.avoidMovingWalkways||!e.properties.isMovingWalkway)&&(!this.avoidTicketRestrictedAreas||!e.properties.needTicket))))},projectionMaxDistance:this.projectionMaxDistance,useMultiLevelSegments:this.useMultiLevelSegments}}};t(z,"DEFAULT",(new z).build()),t(z,"WITHOUT_STAIRS",(new z).setAvoidStairs(!0).build()),t(z,"WHEELCHAIR",(new z).setIsWheelchair(!0).build());let Y=z;class K{constructor(e,t,r,n,o){this.prev=e,this.dist=t,this.source=r,this.targets=n,this.edges=o}routeVertices(e=this.targets[0],t=[]){const r=this.prev[e.id];return null===r?this.source===e?[...t,e]:[]:[...this.routeVertices(r,t),e]}weightedDistance(e=this.targets[0]){const t=this.dist[e.id];return t===Number.MAX_VALUE?null:t}route(e=this.targets[0]){const t=this.routeVertices(e),r=[],n=[];for(let o=1;o<t.length;o++){const e=t[o-1],i=t[o],s=u.getEdgeByVertices(this.edges,e,i),a=new u(e,i,Object.assign({},s.properties));s.vertex1===a.vertex2&&a.reverseProperties(),r.push(a),n.push(this.dist[i.id]-this.dist[e.id])}return new E(this.source.coords,e.coords,t,r,n)}toGeoJson(e){return{type:"FeatureCollection",features:[...e.vertices.map((e=>{const t=this.prev[e.id],r=this.dist[e.id],n=e===this.source,o=this.targets.includes(e),i=e.coords.level;return{type:"Feature",properties:{id:e.id,...t&&{prev:t.id},dist:r===Number.MAX_VALUE?"infinity":r,...n&&{name:"source"},...o&&{name:"target"},...null!==i&&{level:i},...e.properties},geometry:{type:"Point",coordinates:[e.coords.lng,e.coords.lat]}}})),...e.edges.map((e=>{const t=e.level;return{type:"Feature",properties:{id:e.id,...null!==t&&{level:t},...e.properties},geometry:{type:"LineString",coordinates:[[e.vertex1.coords.lng,e.vertex1.coords.lat],[e.vertex2.coords.lng,e.vertex2.coords.lat]]}}}))]}}}class J{constructor(e){t(this,"disabledEdges",new Set),this.graph=e;let r=0;e.vertices.forEach((e=>e.id=r++))}calculateShortestPathToMultipleDestinationsByVertex(e,t,r=Y.DEFAULT,n=this.graph.vertices,o=this.graph.edges){const i=new Set(n),s=Array(i.size).fill(Number.MAX_VALUE),a=new Array(i.size).fill(null),l=o.filter((e=>{var t;return((null==(t=r.acceptEdgeFn)?void 0:t.call(r,e))??!0)&&!this.disabledEdges.has(e)})),c=r.weightEdgeFn||(e=>e.length),u=r.weightVertexFn||(e=>0),d=e=>{let t=Number.MAX_VALUE,r=null;return e.forEach((e=>{const n=s[e.id];n<=t&&(t=n,r=e)})),r},p=new Set(t);for(s[e.id]=0;i.size>0;){const e=d(i);if(i.delete(e),t.includes(e)&&(p.delete(e),0===p.size))break;l.filter((t=>t.vertex1==e||!t.properties.isOneway&&t.vertex2==e)).forEach((t=>{const r=e===t.vertex1?t.vertex2:t.vertex1,n=c(t)+u(r),o=s[e.id]+n;o<s[r.id]&&(s[r.id]=o,a[r.id]=e)}))}return new K(a,s,e,t,l)}calculateShortestPathByVertex(e,t,r=Y.DEFAULT,n=this.graph.vertices,o=this.graph.edges){return this.calculateShortestPathToMultipleDestinationsByVertex(e,[t],r,n,o)}calculateComponents(){function e(e){const t=e.values().next().value;return e.delete(t),t}const t=new Set(this.graph.vertices);let r,n=[];for(;t.size>0;){const r=e(t),o=this.graph.vertices.filter((e=>e.id!==r.id)),i=this.calculateShortestPathToMultipleDestinationsByVertex(r,o),s=o.filter((e=>null!==i.weightedDistance(e)));n.push([r,...s]),s.forEach((e=>t.delete(e)))}do{r=!1;for(let e=0;e<n.length-1;e++){const t=n[e];for(let o=e+1;o<n.length;o++){const e=n[o];e.some((e=>t.includes(e)))&&(t.push(...e),n=n.filter((t=>t!==e)),r=!0)}}}while(r);return n.map((e=>[...new Set(e)]))}toGeoJson(){const e=this.calculateComponents().map(((e,t)=>({type:"Feature",geometry:{type:"MultiLineString",coordinates:this.graph.edges.filter((t=>e.includes(t.vertex1)&&e.includes(t.vertex2))).map((e=>[[e.vertex1.coords.lng,e.vertex1.coords.lat],[e.vertex2.coords.lng,e.vertex2.coords.lat]]))},properties:{stroke:"#"+j.getQualitativeColor(t).toString(16)}})));return{type:"FeatureCollection",features:e}}}class X extends K{constructor(e,t,r){super(e.prev,e.dist,e.source,e.targets,e.edges),this.sourceProjection=t,this.targetsProjections=r}static createEmpty(e,t){const r=t.length,n=new K(new Array(r).fill(null),new Array(r).fill(Number.MAX_VALUE),new p(e),t.map((e=>new p(e))),[]),o=[e,null],i=t.map((e=>[e,null]));return new X(n,o,i)}routeVertices(e=this.targetsProjections[0][0]){var t;if(e instanceof p)return super.routeVertices(e);if(!this.sourceProjection[1])return[];const r=null==(t=this.targetsProjections.find((([t])=>t===e)))?void 0:t[1];return r?super.routeVertices(r):[]}weightedDistance(e=this.targetsProjections[0][0]){var t;if(e instanceof p)return super.weightedDistance(e);if(!this.sourceProjection[1])return null;const r=null==(t=this.targetsProjections.find((([t])=>t===e)))?void 0:t[1];return r?super.weightedDistance(r):null}route(e=this.targetsProjections[0][0]){var t;if(e instanceof p)return super.route(e);const r=null==(t=this.targetsProjections.find((([t])=>t===e)))?void 0:t[1];if(!r)return new E(this.sourceProjection[0],e,[],[],[]);const n=super.route(r);return n.start=this.sourceProjection[0],n.end=e,n}}class Q extends J{calculateShortestPathToMultipleDestinations(e,t,r=Y.DEFAULT){const n=new Set,o=new Set,i=[],s={maxDistance:r.projectionMaxDistance,acceptEdgeFn:r.acceptEdgeFn,useMultiLevelSegments:r.useMultiLevelSegments},a=e=>{const t=this.graph.getProjection(e,s);if(null===t)return null;if(t.nearestElement instanceof p)return t.nearestElement;if(t.nearestElement instanceof u){const e=t.nearestElement,r=new p(t.coords,{name:`proj on ${e.properties.name||null} (tmp)`,...void 0!==e.properties.externalId&&{externalId:e.properties.externalId}});r.id=this.graph.vertices.length+n.size;const s={...e.properties,...void 0!==e.properties.externalId&&{externalId:e.properties.externalId}},a=new u(e.vertex1,r,s),l=new u(r,e.vertex2,s);n.add(r),o.add(a),o.add(l);const c=i.find((t=>t[0]===e));return c?c[1].push(r):i.push([e,[r]]),r}return null},l=a(e);if(!l)return X.createEmpty(e,t);const c=t.map((e=>[e,a(e)])),d=c.map((([,e])=>e)).filter((e=>null!==e));i.filter((e=>e[1].length>=2)),i.forEach((([e,t])=>{const r={...e.properties,name:`splitted ${e.properties.name||null} (tmp)`};for(let n=0;n<t.length;n++){const i=t[n],s=i.distanceTo(e.vertex1);for(let a=n+1;a<t.length;a++){const n=t[a],l=n.distanceTo(e.vertex1)<s?new u(n,i,r):new u(i,n,r);o.add(l)}}}));const h=this.calculateShortestPathToMultipleDestinationsByVertex(l,d,r,[...this.graph.vertices,...n],[...this.graph.edges,...o]);return new X(h,[e,l],c)}calculateShortestPath(e,t,r=Y.DEFAULT){return this.calculateShortestPathToMultipleDestinations(e,[t],r)}getShortestTrip(e,t,r=.99){const n=e.map((e=>{const t=new i.Point(0,0);return t.coords=e,t})),o=[],s=i.solve(n,r,void 0,((e,r)=>{const n=this.calculateShortestPath(e.coords,r.coords,t).route();return o.push(n),n.hasRoute?n.edgesWeights.reduce(((e,t)=>e+t),0):Number.MAX_VALUE})).map((e=>n[e])),a=[];for(let i=0;i<s.length;i++){const e=s[i],t=s[(i+1)%s.length];let r=o.find((r=>r.start===e.coords&&r.end===t.coords||r.end===e.coords&&r.start===t.coords));(null==r?void 0:r.end)===e.coords&&(r=r.reverse()),r&&a.push(r)}return a.some((e=>!e.hasRoute))?[]:a}}class Z extends Error{constructor(e,t,r=null){super(),this.start=e,this.end=t,this.details=r}get startStr(){return this.start instanceof p?`Vertex ${this.start.coords.toString()}`:this.start.toString()}get endStr(){return this.end instanceof p?`Vertex ${this.end.coords.toString()}`:Array.isArray(this.end)?this.end.map((e=>e instanceof p?e.coords.toString():e.toString())).join(","):this.end.toString()}get message(){let e=`No route found from ${this.startStr} to ${this.endStr}.`;return this.details&&(e+=` Details: ${this.details}`),e}}class ee{}var te=(e=>(e[e.OK=0]="OK",e[e.CANCELLED=1]="CANCELLED",e[e.UNKNOWN=2]="UNKNOWN",e[e.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",e[e.NOT_FOUND=5]="NOT_FOUND",e[e.UNIMPLEMENTED=12]="UNIMPLEMENTED",e[e.INTERNAL=13]="INTERNAL",e[e.UNAVAILABLE=14]="UNAVAILABLE",e[e.UNAUTHENTICATED=16]="UNAUTHENTICATED",e))(te||{});class re extends Error{constructor(e=te.UNKNOWN,r){super(r),t(this,"customMapName"),this.code=e}static notFound(e){return new re(te.NOT_FOUND,`Cannot found an itinerary. Details: ${e}`)}}class ne extends re{constructor(e=te.UNKNOWN,t,r){super(e,r),this.code=e,this.mapName=t,this.mapName=t}static notFound(e,t){return new ne(te.NOT_FOUND,e,`Cannot found an itinerary in map ${e}. Details: ${t||"No details"}`)}}class oe extends re{constructor(e=te.UNKNOWN,t,r){super(e,r),this.code=e,this.routerName=t,this.routerName=t}static notFound(e,t){return new oe(te.NOT_FOUND,e,`Cannot found an itinerary with ${e}. Details: ${t||"No details"}`)}static missingApiKey(e,t){return new oe(te.UNAUTHENTICATED,e,`API key is missing for ${e}. Details: ${t}`)}static unreachableServer(e,t){return new oe(te.NOT_FOUND,e,`Remote router server ${e} is unreachable. URL: ${t}`)}static responseNotParsing(e,t){return new oe(te.NOT_FOUND,e,`Remote router server response ${e} cannot be parsed. URL: ${t}`)}static travelModeUnimplemented(e,t){return new oe(te.UNIMPLEMENTED,e,`Travel mode "${t}" is not implemented for ${e}`)}}function ie(e,t,r,n,o,i,s="Europe/Paris"){const a=new Date(Date.UTC(e,t,r,n,o,i)),l=new Date(a.toLocaleString("en-US",{timeZone:"UTC"})),c=new Date(a.toLocaleString("en-US",{timeZone:s})),u=l.getTime()-c.getTime();return a.setTime(a.getTime()+u),a}function se(e){return new r.Coordinates(e.Lat,e.Long)}function ae(e){const[t,r]=e.split(" "),[n,o,i]=t.split("/"),[s,a,l]=r.split(":");return ie(Number(i),Number(o)-1,Number(n),Number(s),Number(a),Number(l)).getTime()}const le=new Map;le.set("CAR","Car"),le.set("WALK","Walk"),le.set("BIKE","Bike"),le.set("TRANSIT","PT");const ce=new Map;ce.set("WALK","WALK"),ce.set("BICYCLE","BIKE"),ce.set("TRAMWAY","TRAM"),ce.set("METRO","METRO"),ce.set("FUNICULAR","FUNICULAR"),ce.set("BUS","BUS"),ce.set("COACH","BUS"),ce.set("SCHOOL","BUS"),ce.set("BUS_PMR","BUS"),ce.set("MINIBUS","BUS"),ce.set("TROLLEY_BUS","BUS"),ce.set("TAXIBUS","BUS"),ce.set("SHUTTLE","BUS"),ce.set("TRAIN","TRAIN"),ce.set("HST","TRAIN"),ce.set("LOCAL_TRAIN","TRAIN"),ce.set("AIR","AIRPLANE"),ce.set("FERRY","BOAT"),ce.set("TAXI","UNKNOWN"),ce.set("CAR_POOL","UNKNOWN"),ce.set("PRIVATE_VEHICLE","CAR"),ce.set("SCOOTER","MOTO");const ue=new Map;function de(e){const t=e.match(/LINESTRING ?\((.*)\)/i),n=e.match(/POINT ?\((.*)\)/i);if(n){const[e,t]=n[1].split(" ");return[new r.Coordinates(Number(t),Number(e))]}return t[1].split(",").map((e=>{const t=e.trim().split(" ");return new r.Coordinates(Number(t[1]),Number(t[0]))}))}ue.set(0,"BUS"),ue.set(1,"WALK"),ue.set(2,"BIKE"),ue.set(3,"CAR"),ue.set(4,"UNKNOWN"),ue.set(5,"UNKNOWN"),ue.set(6,"UNKNOWN"),ue.set(7,"UNKNOWN"),ue.set(8,"UNKNOWN"),ue.set(9,"UNKNOWN"),ue.set(10,"UNKNOWN"),ue.set(11,"UNKNOWN"),ue.set(12,"UNKNOWN"),ue.set(13,"UNKNOWN"),ue.set(14,"UNKNOWN");const pe=new class extends ee{get rname(){return"cityway"}async getItineraries(e,t){const r=this.getURL(e,t),n=await fetch(r).catch((()=>{throw oe.unreachableServer(this.rname,r)})),o=await n.json().catch((()=>{throw oe.responseNotParsing(this.rname,r)}));return this.parseResponse(o)}getURL(e,t){const{origin:r,destination:n,travelMode:i,waypoints:s}=t,a=le.get(i);if(!a)throw oe.travelModeUnimplemented(this.rname,i);(s||[]).length>0&&o.warn(`${this.rname} router uses only the first 2 waypoints (asked ${null==s?void 0:s.length})`);const l=`DepartureLatitude=${r.latitude}&DepartureLongitude=${r.longitude}`,c=`ArrivalLatitude=${n.latitude}&ArrivalLongitude=${n.longitude}`,u=`TripModes=${a}`,d=new URL(e);t.departureTime&&(d.searchParams.set("Date",t.departureTime),d.searchParams.set("TypeDate","Departure"));let{search:p}=d;return p=(p?`${p}&`:"?")+`${l}&${c}&${u}`,`${d.origin}${d.pathname}${p}`}parseResponse(e){if(200!==e.StatusCode||!e.Data||!e.Data.length)throw oe.notFound(this.rname,e.Message);const t=[],r=e.Data.map((e=>e.response.trips.Trip.map((t=>({...t,...e.hasOwnProperty("PlanTripType")&&{PlanTripType:e.PlanTripType}}))))).flat();e:for(const n of r){if(n.hasOwnProperty("PlanTripType")&&"UNKNOWN"===ue.get(n.PlanTripType))continue;const e=[];for(const t of n.sections.Section){const r=t.Leg?t.Leg:t.PTRide,i=ce.get(r.TransportMode),s=[];let a,l,c;const u=new N;if("UNKNOWN"===i)continue e;if("WALK"===i||"BIKE"===i||"CAR"===i){a={name:r.Departure.Site.Name,coords:se(r.Departure.Site.Position)},l={name:r.Arrival.Site.Name,coords:se(r.Arrival.Site.Position)};for(const e of r.pathLinks.PathLink){let t;t=e.Geometry&&"Null"!==e.Geometry?de(e.Geometry):[a.coords,l.coords],t.forEach(((e,t)=>{0===t&&0!==s.length&&s[s.length-1].equals(e)||s.push(e)})),u.addStepInfo({coords:t[0],distance:e.Distance,name:e.Departure.Site.Name})}t===n.sections.Section[n.sections.Section.length-1]&&u.addStepInfo({coords:s[s.length-1]})}else{if(!g(i)){o.warn(`[CitywayParser] Unknown leg mode: ${r.TransportMode}`);continue}{a={name:r.Departure.StopPlace.Name,coords:se(r.Departure.StopPlace.Position)},l={name:r.Arrival.StopPlace.Name,coords:se(r.Arrival.StopPlace.Position)};let e=r.Line.Number;"TRAM"===i&&e.toLowerCase().includes("tram")&&(e=e.substr(5)),c={name:e,routeColor:r.Line.Color,routeTextColor:r.Line.TextColor,directionName:r.Destination};for(const t of r.steps.Step){de(t.Geometry).forEach(((e,t)=>{0===t&&0!==s.length&&s[s.length-1].equals(e)||s.push(e)}))}u.addStepInfo({coords:s[0],name:r.Line.Name,distance:r.Distance,type:"transit"})}}u.setStart(a.coords),u.setEnd(l.coords),u.setPathCoords(s);const d=new _({transitMode:i,duration:this.parseDuration(r.Duration),startTime:ae(r.Departure.Time),endTime:ae(r.Arrival.Time),coords:s,start:a,end:l,transportInfo:c,steps:u.build()});e.push(d)}const r=new S({duration:this.parseDuration(n.Duration),startTime:ae(n.Departure.Time),origin:se(n.Departure.Site.Position),endTime:ae(n.Arrival.Time),destination:se(n.Arrival.Site.Position),legs:e});t.push(r)}return t}parseDuration(e){const t=e.match(/(-)?P(?:([.,\d]+)Y)?(?:([.,\d]+)M)?(?:([.,\d]+)W)?(?:([.,\d]+)D)?T(?:([.,\d]+)H)?(?:([.,\d]+)M)?(?:([.,\d]+)S)?/),r=void 0===t[2]?0:Number(t[2]),n=void 0===t[3]?0:Number(t[3]),o=void 0===t[4]?0:Number(t[4]),i=void 0===t[5]?0:Number(t[5]),s=void 0===t[6]?0:Number(t[6]),a=void 0===t[7]?0:Number(t[7]);return(void 0===t[8]?0:Number(t[8]))+60*a+3600*s+86400*i+604800*o+2592e3*n+31557600*r}},he=new Map;he.set("Air","AIRPLANE"),he.set("Boat","BOAT"),he.set("Bus","BUS"),he.set("BusRapidTransit","BUS"),he.set("Coach","BUS"),he.set("Ferry","FERRY"),he.set("Funicular","FUNICULAR"),he.set("LocalTrain","TRAIN"),he.set("LongDistanceTrain","TRAIN"),he.set("Metro","METRO"),he.set("Métro","METRO"),he.set("RailShuttle","TRAIN"),he.set("RapidTransit","BUS"),he.set("Shuttle","BUS"),he.set("SuspendedCableCar","FUNICULAR"),he.set("Taxi","TAXI"),he.set("Train","TRAIN"),he.set("RER","TRAIN"),he.set("Tramway","TRAM"),he.set("walking","WALK"),he.set("bike","BIKE");const me=["physical_mode:Air","physical_mode:Boat","physical_mode:Bus","physical_mode:BusRapidTransit","physical_mode:Coach","physical_mode:Ferry","physical_mode:Funicular","physical_mode:LocalTrain","physical_mode:LongDistanceTrain","physical_mode:Metro","physical_mode:RailShuttle","physical_mode:RapidTransit","physical_mode:Shuttle","physical_mode:SuspendedCableCar","physical_mode:Taxi","physical_mode:Train","physical_mode:Tramway"];function fe(e){return new r.Coordinates(Number(e.lat),Number(e.lon))}function ge(e){return e[e.length-1]}function ve(e,t){const r=e.substr(0,4),n=e.substr(4,2),o=e.substr(6,2),i=e.substr(9,2),s=e.substr(11,2),a=e.substr(13,2);return ie(Number(r),Number(n)-1,Number(o),Number(i),Number(s),Number(a),t).getTime()}const ye=new class extends ee{get rname(){return"navitia"}async getItineraries(e,t){const r=this.getURL(e,t),n=r.searchParams.get("api_key");if(!n)throw oe.missingApiKey(this.rname);const o=await fetch(r,{method:"GET",headers:{Authorization:n}}).catch((()=>{throw oe.unreachableServer(this.rname,r.toString())})),i=await o.json().catch((()=>{throw oe.responseNotParsing(this.rname,r.toString())}));if(i&&i.error)throw oe.notFound(this.rname,i.error.message);const s=this.parseResponse(i);if(!s.some((e=>v(e.transitMode,t.travelMode))))throw oe.notFound(this.rname,"Selected mode of transport was not found for this itinerary.");return s}getURL(e,t){var r;const{origin:n,destination:i,waypoints:s,travelMode:a}=t;(s||[]).length>0&&o.warn(`${this.rname} router uses only the first 2 waypoints (asked ${null==s?void 0:s.length})`);const l=new URL(e),c=new URLSearchParams;c.set("from",`${n.longitude};${n.latitude}`),c.set("to",`${i.longitude};${i.latitude}`),c.set("data_freshness","realtime"),(null==(r=t.itineraryModifiers)?void 0:r.isWheelchair)&&c.set("wheelchair","true");let u=new URLSearchParams;switch(a){case"WALK":u=this.getWalkingQuery();break;case"BIKE":u=this.getBikeQuery();break;case"CAR":u=this.getCarQuery()}return[c,u].map((e=>{for(const t of e.entries())l.searchParams.append(t[0],t[1])})),l}getCarQuery(){const e=new URLSearchParams;return me.forEach((t=>{e.append("forbidden_uris[]",t)})),e.append("first_section_mode[]","walking"),e.append("first_section_mode[]","car"),e.append("last_section_mode[]","walking"),e.append("last_section_mode[]","car"),e}getWalkingQuery(){const e=new URLSearchParams;return me.forEach((t=>{e.append("forbidden_uris[]",t)})),e.append("first_section_mode[]","walking"),e.append("last_section_mode[]","walking"),e}getBikeQuery(){const e=new URLSearchParams;return me.forEach((t=>{e.append("forbidden_uris[]",t)})),e.append("first_section_mode[]","bike"),e.append("last_section_mode[]","bike"),e}getSectionCoords(e){let t,r;return t="stop_point"in e.from?e.from.stop_point.coord:"address"in e.from?e.from.address.coord:e.from.poi.coord,r="stop_point"in e.to?e.to.stop_point.coord:"address"in e.to?e.to.address.coord:e.to.poi.coord,{from:fe(t),to:fe(r)}}findStepsCoord(e,t){const n=e,o=[...n];let i=t[0],s=0;const a=[];for(const[l,c]of t.entries()){let e,u;if(0===l)u=0,e=n[0];else if(l===t.length-1)u=n.length-1,e=ge(n);else if(1===o.length)s++,u=s,e=o[0],n[u]=e;else{const t=r.Utils.trimRoute(o,o[0],i.distance);s+=t.length-1,o.splice(0,t.length-1),u=s,e=ge(t),n[u]=e}a.push({...c,coords:e}),i=c}return a}findStepCoords(e,t){var r;if("instruction_start_coordinate"in e)return fe(e.instruction_start_coordinate);const n=null==(r=t.vias)?void 0:r.find((t=>t.id===e.via_uri));return n?fe(n.access_point.coord):void 0}parseResponse(e){var t;if(!e||!e.journeys)throw oe.notFound(this.rname,null==(t=e.error)?void 0:t.message);const n=[],o=e.context.timezone;for(const i of e.journeys){const e=[];for(const n of i.sections){if("waiting"===n.type||"transfer"===n.type)continue;const{from:t,to:i}=this.getSectionCoords(n);let s=[];const a=n.geojson.coordinates.reduce(((e,[t,n])=>(s.includes(`${t}-${n}`)||(s=s.concat(`${t}-${n}`),e.push(new r.Coordinates(n,t))),e)),[]),l=(new N).setStart(t).setEnd(i).setPathCoords(a);let c,u=he.get(n.mode);if(n.path){const e=n.path.every((e=>"instruction_start_coordinate"in e||e.via_uri)),t=[];for(const r of n.path){let o;e?(o=this.findStepCoords(r,n),l.addStepInfo({name:r.name,distance:r.length,coords:o,type:"turn"})):t.push({name:r.name,distance:r.length})}e||l.setStepsInfo(this.findStepsCoord(a,t))}if("public_transport"===n.type){c={name:n.display_informations.code,routeColor:n.display_informations.color,routeTextColor:n.display_informations.text_color,directionName:n.display_informations.direction},u=he.get(n.display_informations.physical_mode);const e={coords:a[0],name:c.directionName,distance:n.geojson.properties[0].length,type:"transit"};l.setStepsInfo([e])}const d=new _({transitMode:u,duration:n.duration,startTime:ve(n.departure_date_time,o),endTime:ve(n.arrival_date_time,o),start:{name:n.from.name,coords:t},end:{name:n.to.name,coords:i},coords:a,transportInfo:c,steps:l.build()});e.push(d)}const t=new S({duration:i.duration,startTime:ve(i.departure_date_time,o),endTime:ve(i.arrival_date_time,o),origin:this.getSectionCoords(i.sections[0]).from,destination:this.getSectionCoords(ge(i.sections)).to,legs:e});n.push(t)}return n}};const be=new class extends ee{get rname(){return"deutsche-bahn"}async getItineraries(e,t){const r=this.getURL(e,t),n=await fetch(r).catch((()=>{throw oe.unreachableServer(this.rname,r)})),o=await n.json().catch((()=>{throw oe.responseNotParsing(this.rname,r)}));return this.parseResponse(o,t.origin,t.destination)}getURL(e,t){let n=e+"/route/v1/walking/";return n+=[t.origin,...t.waypoints||[],t.destination].map((e=>{if(null!==e.level){const t=r.Level.isRange(e.level)?e.level[0]:e.level;return e.longitude+","+e.latitude+","+t}return e.longitude+","+e.latitude})).join(";"),n+="?geometries=geojson&overview=full&steps=true",n}parseResponse(e,t,n){if(!e.segments)throw oe.notFound(this.rname);const o=e.segments.map((e=>{const t=r.Level.union(e.fromLevel,e.toLevel),n=e.polyline.map((({lon:e,lat:n})=>new r.Coordinates(n,e,null,t)));return new _({transitMode:"WALK",coords:n,start:{coords:n[0]},end:{coords:n[n.length-1]}})}));return[new S({origin:t,destination:n,legs:o})]}};function we(e){const t=e[0];return e.slice(1).map((e=>{const r={};return t.forEach(((t,n)=>{r[t]=e[n]})),r}))}const Ee=new Map;Ee.set("BIKE","BIKE"),Ee.set("PEDESTRIAN","WALK");function Te(e){return new r.Coordinates(e.latitude,e.longitude)}function Ne(e){return e[e.length-1]}const _e=new class extends ee{get rname(){return"geovelo"}async getItineraries(e,t){const r=this.getQueryParams(),n=this.getBodyParams(t),o=new URL(e);for(const[a,l]of Object.entries(r))o.searchParams.append(a,l.toString());const i=await fetch(o,{method:"POST",headers:{apiKey:"qWHj6ax6DMttG8DX6tH9CQARaiTgQ1Di","Content-Type":"application/json"},body:JSON.stringify(n)}).catch((()=>{throw oe.unreachableServer(this.rname,o.toString())})),s=await i.json().catch((()=>{throw oe.responseNotParsing(this.rname,o.toString())}));if(!s||0===s.length)throw oe.notFound(this.rname,"No itineraries found.");return this.parseResponse(s)}getQueryParams(){return{instructions:!0,elevations:!1,geometry:!0,single_result:!1,bike_stations:!1,objects_as_ids:!1,merge_instructions:!0,show_pushing_bike_instructions:!1}}getBodyParams(e){const{origin:t,destination:r,waypoints:n}=e;let o=[];return o=n&&n.length>1?n.map((e=>({longitude:e.longitude,latitude:e.latitude}))):[{latitude:t.latitude,longitude:t.longitude},{latitude:r.latitude,longitude:r.longitude}],{transportModes:["BIKE"],waypoints:o}}parseResponse(e){if(!e||!e.length)throw oe.notFound(this.rname);const t=[];for(const n of e){const e=[];for(const t of n.sections){const n=Te(t.waypoints[0]),o=Te(Ne(t.waypoints)),i=s.toGeoJSON(t.geometry,6);let a=[];const l=i.coordinates.reduce(((e,[t,n])=>(a.includes(`${t}-${n}`)||(a=a.concat(`${t}-${n}`),e.push(new r.Coordinates(n,t))),e)),[]),c=(new N).setStart(n).setEnd(o).setPathCoords(l),u=Ee.get(t.transportMode),d=we(t.details.instructions);for(const e of d){const{geometryIndex:t,roadLength:n,roadName:o}=e,s=i.coordinates[t],a={name:o,distance:n,coords:new r.Coordinates(s[1],s[0])};c.addStepInfo(a)}const p=new _({transitMode:u,duration:t.duration,startTime:new Date(t.estimatedDatetimeOfDeparture).getTime(),endTime:new Date(t.estimatedDatetimeOfArrival).getTime(),start:{coords:n},end:{coords:o},coords:l,steps:c.build()});e.push(p)}const o=new S({duration:n.duration,startTime:new Date(n.estimatedDatetimeOfDeparture).getTime(),endTime:new Date(n.estimatedDatetimeOfArrival).getTime(),origin:Te(n.waypoints[0]),destination:Te(Ne(n.waypoints)),legs:e});t.push(o)}return t}},Se=new Map;Se.set("Air","AIRPLANE"),Se.set("Boat","BOAT"),Se.set("Bus","BUS"),Se.set("BusRapidTransit","BUS"),Se.set("Coach","BUS"),Se.set("Ferry","FERRY"),Se.set("Funicular","FUNICULAR"),Se.set("LocalTrain","TRAIN"),Se.set("LongDistanceTrain","TRAIN"),Se.set("Metro","METRO"),Se.set("Métro","METRO"),Se.set("RailShuttle","TRAIN"),Se.set("RapidTransit","BUS"),Se.set("Shuttle","BUS"),Se.set("SuspendedCableCar","FUNICULAR"),Se.set("Taxi","TAXI"),Se.set("Train","TRAIN"),Se.set("RER","TRAIN"),Se.set("Tramway","TRAM"),Se.set("walking","WALK"),Se.set("bike","BIKE");const xe=["physical_mode:Air","physical_mode:Boat","physical_mode:Bus","physical_mode:BusRapidTransit","physical_mode:Coach","physical_mode:Ferry","physical_mode:Funicular","physical_mode:LocalTrain","physical_mode:LongDistanceTrain","physical_mode:Metro","physical_mode:RailShuttle","physical_mode:RapidTransit","physical_mode:Shuttle","physical_mode:SuspendedCableCar","physical_mode:Taxi","physical_mode:Train","physical_mode:Tramway"];function Ae(e){return new r.Coordinates(Number(e.lat),Number(e.lon))}function Ie(e){return e[e.length-1]}function Oe(e,t){const r=e.substr(0,4),n=e.substr(4,2),o=e.substr(6,2),i=e.substr(9,2),s=e.substr(11,2),a=e.substr(13,2);return ie(Number(r),Number(n)-1,Number(o),Number(i),Number(s),Number(a),t).getTime()}const Re=new class extends ee{get rname(){return"idfm"}async getItineraries(e,t){const{travelMode:r}=t;if("BIKE"===r)return _e.getItineraries("https://idfm.getwemap.com/marketplace/computedroutes",t);const n=this.getURL(e,t),o=await fetch(n,{method:"GET",headers:{apiKey:"qWHj6ax6DMttG8DX6tH9CQARaiTgQ1Di"}}).catch((()=>{throw oe.unreachableServer(this.rname,n)})),i=await o.json().catch((()=>{throw oe.responseNotParsing(this.rname,n)}));if(i&&i.error)throw oe.notFound(this.rname,i.error.message);const s=this.parseResponse(i);if(!s.some((e=>v(e.transitMode,t.travelMode))))throw oe.notFound(this.rname,"Selected mode of transport was not found for this itinerary.");return s}getURL(e,t){var r;const{origin:n,destination:i,waypoints:s,travelMode:a}=t;(s||[]).length>0&&o.warn(`${this.rname} router uses only the first 2 waypoints (asked ${null==s?void 0:s.length})`);const l=new URL(e),c=new URLSearchParams;c.set("from",`${n.longitude};${n.latitude}`),c.set("to",`${i.longitude};${i.latitude}`),c.set("data_freshness","realtime"),(null==(r=t.itineraryModifiers)?void 0:r.isWheelchair)&&c.set("wheelchair","true"),t.departureTime&&(c.set("datetime",t.departureTime),c.set("datetime_represents","departure"));let u=new URLSearchParams;switch(a){case"WALK":u=this.getWalkingQuery();break;case"BIKE":u=this.getBikeQuery();break;case"CAR":u=this.getCarQuery()}return[c,u].map((e=>{for(const t of e.entries())l.searchParams.append(t[0],t[1])})),l.toString()}getCarQuery(){const e=new URLSearchParams;return xe.forEach((t=>{e.append("forbidden_uris[]",t)})),e.append("first_section_mode[]","walking"),e.append("first_section_mode[]","car"),e.append("last_section_mode[]","walking"),e.append("last_section_mode[]","car"),e}getWalkingQuery(){const e=new URLSearchParams;return xe.forEach((t=>{e.append("forbidden_uris[]",t)})),e.append("first_section_mode[]","walking"),e.append("last_section_mode[]","walking"),e}getBikeQuery(){const e=new URLSearchParams;return xe.forEach((t=>{e.append("forbidden_uris[]",t)})),e.append("first_section_mode[]","bike"),e.append("last_section_mode[]","bike"),e}getSectionCoords(e){let t,r;return t="stop_point"in e.from?e.from.stop_point.coord:"address"in e.from?e.from.address.coord:e.from.poi.coord,r="stop_point"in e.to?e.to.stop_point.coord:"address"in e.to?e.to.address.coord:e.to.poi.coord,{from:Ae(t),to:Ae(r)}}findStepsCoord(e,t){const n=e,o=[...n];let i=t[0],s=0;const a=[];for(const[l,c]of t.entries()){let e,u;if(0===l)u=0,e=n[0];else if(l===t.length-1)u=n.length-1,e=Ie(n);else if(1===o.length)s++,u=s,e=o[0],n[u]=e;else{const t=r.Utils.trimRoute(o,o[0],i.distance);s+=t.length-1,o.splice(0,t.length-1),u=s,e=Ie(t),n[u]=e}a.push({...c,coords:e}),i=c}return a}findStepCoords(e,t){var r;if("instruction_start_coordinate"in e)return Ae(e.instruction_start_coordinate);const n=null==(r=t.vias)?void 0:r.find((t=>t.id===e.via_uri));return n?Ae(n.access_point.coord):void 0}parseResponse(e){var t;if(!e||!e.journeys)throw oe.notFound(this.rname,null==(t=e.error)?void 0:t.message);const n=[],o=e.context.timezone;for(const i of e.journeys){const e=[];for(const n of i.sections){if("waiting"===n.type||"transfer"===n.type)continue;const{from:t,to:i}=this.getSectionCoords(n);let s=[];const a=n.geojson.coordinates.reduce(((e,[t,n])=>(s.includes(`${t}-${n}`)||(s=s.concat(`${t}-${n}`),e.push(new r.Coordinates(n,t))),e)),[]),l=(new N).setStart(t).setEnd(i).setPathCoords(a);let c,u=Se.get(n.mode);if(n.path){const e=n.path.every((e=>"instruction_start_coordinate"in e||e.via_uri)),t=[];for(const r of n.path){let o;if(e){o=this.findStepCoords(r,n);const e={name:r.name,distance:r.length,coords:o};l.addStepInfo(e)}else t.push({name:r.name,distance:r.length})}e||l.setStepsInfo(this.findStepsCoord(a,t))}if("public_transport"===n.type){c={name:n.display_informations.code,routeColor:n.display_informations.color,routeTextColor:n.display_informations.text_color,directionName:n.display_informations.direction},u=Se.get(n.display_informations.physical_mode);const e={coords:a[0],name:c.directionName,distance:n.geojson.properties[0].length,type:"transit"};l.setStepsInfo([e])}const d=new _({transitMode:u,duration:n.duration,startTime:Oe(n.departure_date_time,o),endTime:Oe(n.arrival_date_time,o),start:{name:n.from.name,coords:t},end:{name:n.to.name,coords:i},coords:a,transportInfo:c,steps:l.build()});e.push(d)}const t=new S({duration:i.duration,startTime:Oe(i.departure_date_time,o),endTime:Oe(i.arrival_date_time,o),origin:this.getSectionCoords(i.sections[0]).from,destination:this.getSectionCoords(Ie(i.sections)).to,legs:e});n.push(t)}return n}},Ce=new Map;Ce.set("CAR","CAR"),Ce.set("WALK","WALK"),Ce.set("BIKE","BIKE");const De=new class extends ee{constructor(){super(...arguments),t(this,"inputModeCorrespondance",(e=>{var t;const{travelMode:r,travelModePreference:n}=e;if("WALK"===r&&(null==(t=e.itineraryModifiers)?void 0:t.isWheelchair))return"pmr";if("WALK"===r)return"walking";if("BIKE"===r)return"FASTEST"===n?"bike-fastest":"bike-safest";if("CAR"===r)return"driving";throw oe.travelModeUnimplemented(this.rname,r)}))}get rname(){return"osrm"}async getItineraries(e,t){const r=this.getURL(e,t),n=await fetch(r).catch((()=>{throw oe.unreachableServer(this.rname,r)})),o=await n.json().catch((()=>{throw oe.responseNotParsing(this.rname,r)}));return this.parseResponse(o,t.origin,t.destination,t.travelMode)}getURL(e,t){const{origin:r,destination:n}=t;let o=e+"/route/v1/"+this.inputModeCorrespondance(t)+"/";return o+=[r,...t.waypoints||[],n].map((e=>[e.longitude+","+e.latitude])).join(";"),o+="?geometries=geojson&overview=full&steps=true",t.provideItineraryAlternatives&&(o+="&alternatives=true"),o}osrmTypeToStepType(e){switch(e){case"depart":return"depart";case"turn":default:return"turn";case"roundabout":return"roundabout";case"exit roundabout":return"exit-roundabout";case"arrive":return"arrive"}}osrmModifierToStepDirection(e){switch(e){case"sharp right":return"sharp-right";case"sharp left":return"sharp-left";case"slight right":return"slight-right";case"slight left":return"slight-left";case"u turn":return"u-turn";default:return e}}coordinatesToJson({lat:e,lng:t,level:n}){return null===n?[t,e]:r.Level.isRange(n)?[t,e,n[0]]:[t,e,n]}jsonToCoordinates(e){const t=new r.Coordinates(e[1],e[0]);return e.length>2&&(t.level=e[2]),t}getModifierFromAngle(e){const t=n.positiveMod(n.rad2deg(e),360);return t>0&&t<60?"sharp right":t>=60&&t<140?"right":t>=140&&t<160?"slight right":t>=160&&t<=200?"straight":t>200&&t<=220?"slight left":t>220&&t<=300?"left":t>300&&t<360?"sharp left":"u turn"}noRouteFoundJson(e){return{code:"NoRoute",message:e}}itineraryToOsrmJson(e){const t=e.legs.length-1,r=e.steps,o=e.legs.map((({distance:e,duration:o,coords:i},s)=>{const a=r.filter((e=>i.find((t=>t.equals(e.coords))))),l=a.length-1;return{distance:e,duration:o||0,steps:a.map(((e,r,o)=>{let a=0===r&&0===s?"depart":"turn";a=r===l&&s===t?"arrive":a;const c=i.findIndex((t=>t.equals(e.coords))),u=r===l?c:i.findIndex((e=>e.equals(o[r+1].coords)));return{geometry:{type:"LineString",coordinates:i.slice(c,u+1).map(this.coordinatesToJson)},distance:e.distance,duration:e.duration||0,...e.name&&{name:e.name},maneuver:{bearing_before:n.rad2deg(e.previousBearing),bearing_after:n.rad2deg(e.nextBearing),location:this.coordinatesToJson(e.coords),modifier:this.getModifierFromAngle(e.angle),type:a}}}))}}));return{code:"Ok",routes:[{geometry:{type:"LineString",coordinates:e.coords.map(this.coordinatesToJson)},legs:o,distance:e.distance,duration:e.duration,weight_name:"routability",weight:0}],waypoints:[]}}parseResponse(e,t,r,n){const o=Ce.get(n),{routes:i}=e;if(!i)throw oe.notFound(this.rname,e.message);return i.map((e=>{const n=e.legs.map((e=>{var t;const r=e.steps.map((e=>e.geometry.coordinates.map(this.jsonToCoordinates))).flat().filter(((e,t,r)=>0===t||!r[t-1].equals(e))),n=r[0],i=r[r.length-1],s=(new N).setPathCoords(r).setStart(n).setEnd(i);return null==(t=e.steps)||t.forEach((({maneuver:e,name:t,distance:n,duration:o})=>{const i=this.jsonToCoordinates(e.location),a=r.map((e=>e.distanceTo(i))),l=a.indexOf(Math.min(...a));if(l<0)throw new Error("Osrm Parser: Cannot find step coords in leg coordinates");const c=void 0!==e.exit?e.exit.toString():t;s.addStepInfo({coords:r[l],name:c,distance:n,duration:o,type:this.osrmTypeToStepType(e.type),direction:this.osrmModifierToStepDirection(e.modifier)})})),new _({transitMode:o,duration:e.duration,coords:r,start:{coords:n},end:{coords:i},steps:s.build()})}));return new S({duration:e.duration,origin:t,destination:r,legs:n})}))}};function Me(e){return"BUS"===e.mode||"TRAM"===e.mode}function Le(e){return new r.Coordinates(e.lat,e.lon)}const ke=new Map;ke.set("CAR","CAR"),ke.set("WALK","WALK"),ke.set("BIKE","BICYCLE"),ke.set("TRANSIT","WALK,TRANSIT");const Ue=new class extends ee{get rname(){return"otp"}async getItineraries(e,t){const r=this.getURL(e,t),n=await fetch(r).catch((()=>{throw oe.unreachableServer(this.rname,r)})),o=await n.json().catch((()=>{throw oe.responseNotParsing(this.rname,r)}));return this.parseResponse(o)}getURL(e,t){const{origin:r,destination:n,waypoints:i,travelMode:s}=t,a=ke.get(s);if(!a)throw oe.travelModeUnimplemented(this.rname,s);(i||[]).length>0&&o.warn(`${this.rname} router uses only the first 2 waypoints (asked ${null==i?void 0:i.length})`);const l=`fromPlace=${r.latitude},${r.longitude}`,c=`toPlace=${n.latitude},${n.longitude}`,u=`mode=${a}`,d=new URL(e);let{search:p}=d;return p=(p?`${p}&`:"?")+`${l}&${c}&${u}`,`${d.origin}${d.pathname}${p}`}parseResponse(e){const{plan:t}=e;if(!t)throw oe.notFound(this.rname);const n=[],o=Le(t.from),i=Le(t.to);for(const a of t.itineraries){const e=[];for(const n of a.legs){const t=Le(n.from),o=Le(n.to),i=s.decode(n.legGeometry.points).map((([e,t])=>new r.Coordinates(e,t)));let a;const l=(new N).setStart(t).setEnd(o).setPathCoords(i);Me(n)?(a={name:n.routeShortName,routeColor:n.routeColor,routeTextColor:n.routeTextColor,directionName:n.headsign},l.addStepInfo({coords:i[0],name:n.headsign,type:"transit"})):n.steps.forEach((e=>{const t=i.map((t=>t.distanceTo(Le(e)))),r=t.indexOf(Math.min(...t));if(r<0)throw new Error("OTP Parser: Cannot find closest step");l.addStepInfo({coords:i[r],name:e.streetName,type:"turn"})}));const c=new _({transitMode:n.mode,duration:n.duration,startTime:n.startTime,endTime:n.endTime,start:{name:n.from.name,coords:Le(n.from)},end:{name:n.to.name,coords:Le(n.to)},coords:i,transportInfo:a,steps:l.build()});e.push(c)}const t=new S({duration:a.duration,startTime:a.startTime,endTime:a.endTime,origin:o,destination:i,legs:e});n.push(t)}return n}};const Pe=new class extends ee{get rname(){return"wemap-multi"}async getItineraries(e,t){const{origin:n,destination:o,waypoints:i}=t,s={...t,origin:n instanceof r.Coordinates?n.toJson():n,destination:o instanceof r.Coordinates?o.toJson():o,...i&&{waypoints:i.map((e=>e instanceof r.Coordinates?e.toJson():e))}},a=await fetch(e,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(s)}).catch((()=>{throw oe.unreachableServer(this.rname,e)})),l=await a.json().catch((()=>{throw oe.responseNotParsing(this.rname,e)}));if(l.error)throw oe.notFound(this.rname,l.error);return(l.itineraries||[]).map(S.fromJson)}},qe="https://routing-osrm.getwemap.com";const Be=new class extends ee{get rname(){return"tictactrip"}async getSegmentItinerary(e,t){const r=m(e.distanceTo(t));if(r<300)return null;let n=null;return n=r<1800?(await De.getItineraries(qe,{origin:e,destination:t,travelMode:"WALK",provideItineraryAlternatives:!1,optimizeWaypoints:!1}))[0]:(await De.getItineraries(qe,{origin:e,destination:t,travelMode:"CAR",provideItineraryAlternatives:!1,optimizeWaypoints:!1}))[0],n}getItineraryFromStation(e,t){return De.getItineraries(qe,{origin:e,destination:t,travelMode:"WALK"})}async getItineraries(e,t){const r=this.getBodyParams(t),n=new URL(e),o=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)}).catch((()=>{throw oe.unreachableServer(this.rname,n.toString())})),i=await o.json().catch((()=>{throw oe.responseNotParsing(this.rname,n.toString())}));return await this.parseResponse(i,t)}getBodyParams(e){const{origin:t,destination:r}=e;return{origin:{latitude:t.lat,longitude:t.lng},destination:{latitude:r.lat,longitude:r.lng},outbound_date:e.departureTime||(new Date).toISOString(),passengers:[{age:30}]}}async parseResponse(e,t){return e&&e.trips?await Promise.all(Object.values(e.trips).filter((e=>"TRAIN"===e.transportType)).map((async e=>{var n,o;const i=e.segments.map((e=>{const t=G.toUpperCase(e.transportType),n=new r.Coordinates(e.origin.latitude,e.origin.longitude),o=new r.Coordinates(e.destination.latitude,e.destination.longitude),i=[n,o],s=(new N).setStart(n).setEnd(o).setPathCoords(i);return s.setStepsInfo([{coords:n,type:"depart",direction:null},{coords:o,type:"arrive",direction:null}]),new _({start:{name:e.origin.name,coords:n},end:{name:e.destination.name,coords:o},coords:[n,o],transitMode:t,duration:60*e.durationMinutes,startTime:new Date(e.departureLocalISO).getTime(),endTime:new Date(e.arrivalLocalISO).getTime(),transportInfo:{name:e.provider.name,price:e.priceCents/100,directionName:e.destination.name},steps:s.build()})}));let s=null,a=null;const l=[],c=null==(n=e.segments[0])?void 0:n.origin;if(c){const e=new r.Coordinates(c.latitude,c.longitude),n=t.origin;s=await this.getSegmentItinerary(n,e).catch((()=>null)),s&&(s.legs[0].start.name=c.name,l.push(...s.legs))}l.push(...i);const u=null==(o=e.segments[e.segments.length-1])?void 0:o.destination;if(u){const e=new r.Coordinates(u.latitude,u.longitude),n=t.destination;a=await this.getSegmentItinerary(e,n).catch((()=>null)),a&&(a.legs[a.legs.length-1].end.name=u.name,l.push(...a.legs))}return new S({origin:new r.Coordinates(e.origin.latitude,e.origin.longitude),destination:new r.Coordinates(e.destination.latitude,e.destination.longitude),duration:60*e.durationMinutes,startTime:new Date(e.departureLocalISO).getTime(),endTime:new Date(e.arrivalLocalISO).getTime(),legs:l})}))):[]}},Fe=[pe,ye,be,Re,De,Ue,Be,Pe];const je=new class{getRouterByName(e){return Fe.find((t=>t.rname===e))}async getItineraries(e,t,r){const n=this.getRouterByName(e);if(!n)throw oe.notFound(e,`Unknown "${e}" remote router`);return n.getItineraries(t,r)}async getItinerariesWithFallback(e,t){let r;const n=[];for(const{name:a,endpointUrl:l}of t)try{if(r=await this.getItineraries(a,l,e),r.length)return r}catch(s){if(!(s instanceof oe))throw s;n.push({name:a,endpointUrl:l,error:s})}const o=t.map((({name:e})=>e)).join(", "),i=n.map((e=>`(${e.name}) Could not find an itinerary on endpoint: ${e.endpointUrl}. Details: ${e.error.message}`)).join("\n");throw oe.notFound(o,i)}};class Ge{constructor(e,r=null){t(this,"router"),this.graph=e,this.name=r,this.name=r,this.graph=e,this.router=new Q(e)}get routingBounds(){return this.graph.routingBounds}get entryPoints(){return this.graph.routingBoundsEntryPoints}isPointInside(e){return!!this.routingBounds&&a([e.lng,e.lat],this.routingBounds)}getOrderedEntryPointsSortedByDistance(e,t){const n=[...this.entryPoints];return n.sort(((n,o)=>Number(n.coords.distanceTo(e))+n.coords.distanceTo(t)-(o.coords.distanceTo(e)+o.coords.distanceTo(t))+50*(Math.abs(r.Level.diff(e.level,n.coords.level)||0)+Math.abs(r.Level.diff(t.level,n.coords.level)||0)-(Math.abs(r.Level.diff(e.level,o.coords.level)||0)+Math.abs(r.Level.diff(t.level,o.coords.level)||0)))))}getBestRouteFromEntryPointsToDestination(e,t,r){const n=this.getOrderedEntryPointsSortedByDistance(e,t);for(const o of n){const e=this.router.calculateShortestPath(o.coords,t,r).route();if(e.hasRoute)return e}return null}getBestRouteFromOriginToEntryPoints(e,t,r){const n=this.getOrderedEntryPointsSortedByDistance(e,t);for(const o of n){const t=this.router.calculateShortestPath(e,o.coords,r).route();if(t.hasRoute)return t}return null}getRouteInsideMap(e,t,r){const n=this.router.calculateShortestPath(e,t,r).route();return n.hasRoute?n:null}getTripInsideMap(e,t){return this.router.getShortestTrip(e,t)}getRoutesMultipleDestinationsInsideMap(e,t,r){return this.router.calculateShortestPathToMultipleDestinations(e,t,r)}}var We={exports:{}};
2
2
  /**
3
3
  * @license
4
4
  * lodash (Custom Build) <https://lodash.com/>