minotor 12.0.0 → 12.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- "use strict";const t=t=>{let e=Math.floor(t/60);const r=Math.floor(t%60);return e>=24&&(e%=24),`${e.toString().padStart(2,"0")}:${r.toString().padStart(2,"0")}`},e=t=>{const e=Math.floor(t/60),r=t%60;return e>0?`${e.toString().padStart(2,"0")}:${r.toString().padStart(2,"0")}`:`${r}min`};function r(){const t=this.buf;let e=this.pos,r=0,i=0;for(let n=0;n<28;n+=7){const s=t[e++];if(r|=(127&s)<<n,!(128&s))return this.pos=e,this.assertBounds(),this.varint64Lo=r,void(this.varint64Hi=i)}const n=t[e++];if(r|=(15&n)<<28,i=(112&n)>>4,!(128&n))return this.pos=e,this.assertBounds(),this.varint64Lo=r,void(this.varint64Hi=i);for(let n=3;n<=31;n+=7){const s=t[e++];if(i|=(127&s)<<n,!(128&s))return this.pos=e,this.assertBounds(),this.varint64Lo=r,void(this.varint64Hi=i)}throw new Error("invalid varint")}const i=4294967296;function n(t){const e="-"===t[0];e&&(t=t.slice(1));const r=1e6;let n=0,s=0;function u(e,o){const a=Number(t.slice(e,o));s*=r,n=n*r+a,n>=i&&(s+=n/i|0,n%=i)}return u(-24,-18),u(-18,-12),u(-12,-6),u(-6),e?a(n,s):o(n,s)}function s(t,e){if(({lo:t,hi:e}=function(t,e){return{lo:t>>>0,hi:e>>>0}}(t,e)),e<=2097151)return String(i*e+t);const r=16777215&(t>>>24|e<<8),n=e>>16&65535;let s=(16777215&t)+6777216*r+6710656*n,o=r+8147497*n,a=2*n;const d=1e7;return s>=d&&(o+=Math.floor(s/d),s%=d),o>=d&&(a+=Math.floor(o/d),o%=d),a.toString()+u(o)+u(s)}function o(t,e){return{lo:0|t,hi:0|e}}function a(t,e){return e=~e,t?t=1+~t:e+=1,o(t,e)}const u=t=>{const e=String(t);return"0000000".slice(e.length)+e};function d(){let t=this.buf[this.pos++];if(!(128&t))return this.assertBounds(),t;let e=127&t;if(t=this.buf[this.pos++],e|=(127&t)<<7,!(128&t))return this.assertBounds(),e;if(t=this.buf[this.pos++],e|=(127&t)<<14,!(128&t))return this.assertBounds(),e;if(t=this.buf[this.pos++],e|=(127&t)<<21,!(128&t))return this.assertBounds(),e;t=this.buf[this.pos++],e|=(15&t)<<28;for(let e=5;128&t&&e<10;e++)t=this.buf[this.pos++];if(128&t)throw new Error("invalid varint");return this.assertBounds(),e>>>0}const c=l();function l(){const t=new DataView(new ArrayBuffer(8));if(!("function"!=typeof BigInt||"function"!=typeof t.getBigInt64||"function"!=typeof t.getBigUint64||"function"!=typeof t.setBigInt64||"function"!=typeof t.setBigUint64||!globalThis.Deno&&!globalThis.Bun&&"object"==typeof process&&"object"==typeof process.env&&"1"===process.env.BUF_BIGINT_DISABLE)){const e=BigInt("-9223372036854775808"),r=BigInt("9223372036854775807"),i=BigInt("0"),n=BigInt("18446744073709551615");return{zero:BigInt(0),supported:!0,parse(t){const i="bigint"==typeof t?t:BigInt(t);if(i>r||i<e)throw new Error(`invalid int64: ${t}`);return i},uParse(t){const e="bigint"==typeof t?t:BigInt(t);if(e>n||e<i)throw new Error(`invalid uint64: ${t}`);return e},enc(e){return t.setBigInt64(0,this.parse(e),!0),{lo:t.getInt32(0,!0),hi:t.getInt32(4,!0)}},uEnc(e){return t.setBigInt64(0,this.uParse(e),!0),{lo:t.getInt32(0,!0),hi:t.getInt32(4,!0)}},dec:(e,r)=>(t.setInt32(0,e,!0),t.setInt32(4,r,!0),t.getBigInt64(0,!0)),uDec:(e,r)=>(t.setInt32(0,e,!0),t.setInt32(4,r,!0),t.getBigUint64(0,!0))}}return{zero:"0",supported:!1,parse:t=>("string"!=typeof t&&(t=t.toString()),h(t),t),uParse:t=>("string"!=typeof t&&(t=t.toString()),p(t),t),enc:t=>("string"!=typeof t&&(t=t.toString()),h(t),n(t)),uEnc:t=>("string"!=typeof t&&(t=t.toString()),p(t),n(t)),dec:(t,e)=>function(t,e){let r=o(t,e);const i=2147483648&r.hi;i&&(r=a(r.lo,r.hi));const n=s(r.lo,r.hi);return i?"-"+n:n}(t,e),uDec:(t,e)=>s(t,e)}}function h(t){if(!/^-?[0-9]+$/.test(t))throw new Error("invalid int64: "+t)}function p(t){if(!/^[0-9]+$/.test(t))throw new Error("invalid uint64: "+t)}let f;function T(){if(!f){const r=globalThis;if(!r.TextEncoder||!r.TextDecoder)throw new Error("encoding API missing: install TextEncoder and TextDecoder on globalThis");const i=new r.TextEncoder,n=new r.TextDecoder;let s;const o={encodeUtf8:t=>i.encode(t),decodeUtf8:(t,e)=>e?(s||(s=new r.TextDecoder("utf-8",{fatal:!0})),s.decode(t)):n.decode(t),checkUtf8(t){try{return encodeURIComponent(t),!0}catch(t){return!1}}};i.encodeInto&&(o.encodeUtf8Into=i.encodeInto.bind(i));const a=String.prototype.isWellFormed;a&&(o.checkUtf8=t=>a.call(t)),t=o,f=Object.assign(Object.assign({},t),{encodeUtf8Into:null!==(e=t.encodeUtf8Into)&&void 0!==e?e:_(t.encodeUtf8.bind(t))})}var t,e;return f}function _(t){return(e,r)=>{const i=t(e);return r.set(i),{written:i.byteLength}}}var E;!function(t){t[t.Varint=0]="Varint",t[t.Bit64=1]="Bit64",t[t.LengthDelimited=2]="LengthDelimited",t[t.StartGroup=3]="StartGroup",t[t.EndGroup=4]="EndGroup",t[t.Bit32=5]="Bit32"}(E||(E={}));class m{constructor(t){this.stackPos=[],this.encodeUtf8Into=t?_(t):T().encodeUtf8Into,this.buffer=R,this.viewCache=v,this.pos=0}ensureCapacity(t){const e=this.pos+t;if(e>this.buffer.length){let t=this.buffer.length||I;for(;t<e;)t*=2;const r=new Uint8Array(t);this.pos>0&&r.set(this.buffer),this.buffer=r}}view(){const t=this.buffer,e=this.viewCache;if(e.byteLength===t.byteLength)return e;const r=new DataView(t.buffer);return this.viewCache=r,r}finish(){const t=this.buffer.slice(0,this.pos);return this.pos=0,this.stackPos=[],t}fork(){return this.stackPos.push(this.pos),this.ensureCapacity(g),this.buffer[this.pos++]=0,this}join(){const t=this.stackPos.pop();if(void 0===t)throw new Error("invalid state, fork stack empty");const e=this.pos-t-g,r=y(e);return r>g&&(this.ensureCapacity(r-g),this.buffer.copyWithin(t+r,t+g,this.pos)),this.pos=t,this.uint32(e),this.pos+=e,this}tag(t,e){return this.uint32((t<<3|e)>>>0)}raw(t){return this.ensureCapacity(t.length),this.buffer.set(t,this.pos),this.pos+=t.length,this}uint32(t){if(N(t),this.ensureCapacity(5),t<128)return this.buffer[this.pos++]=t,this;for(;t>127;)this.buffer[this.pos++]=127&t|128,t>>>=7;return this.buffer[this.pos++]=t,this}int32(t){if(S(t),t>=0)return this.uint32(t);this.ensureCapacity(10);for(let e=0;e<9;e++)this.buffer[this.pos++]=127&t|128,t>>=7;return this.buffer[this.pos++]=1,this}bool(t){return this.ensureCapacity(1),this.buffer[this.pos++]=t?1:0,this}bytes(t){return this.uint32(t.byteLength),this.raw(t)}string(t){"string"!=typeof t&&(t=String(t));const e=t.length;if(e<=A){this.ensureCapacity(e+1);const r=this.buffer;let i=this.pos;r[i++]=e;let n=0;for(;n<e;n++){const e=t.charCodeAt(n);if(e>127)break;r[i++]=e}if(n==e)return this.pos=i,this}this.ensureCapacity(3*e+5);const r=y(e),i=this.buffer,n=this.pos,{written:s}=this.encodeUtf8Into(t,i.subarray(n+r)),o=y(s);return o!=r&&i.copyWithin(n+o,n+r,n+r+s),this.uint32(s),this.pos+=s,this}float(t){return function(t){if("string"==typeof t){const e=t;if(t=Number(t),Number.isNaN(t)&&"NaN"!==e)throw new Error("invalid float32: "+e)}else if("number"!=typeof t)throw new Error("invalid float32: "+typeof t);if(!Number.isFinite(Math.fround(t))&&Number.isFinite(t))throw new Error("invalid float32: "+t)}(t),this.ensureCapacity(4),this.view().setFloat32(this.pos,t,!0),this.pos+=4,this}double(t){return this.ensureCapacity(8),this.view().setFloat64(this.pos,t,!0),this.pos+=8,this}fixed32(t){return N(t),this.ensureCapacity(4),this.view().setUint32(this.pos,t,!0),this.pos+=4,this}sfixed32(t){return S(t),this.ensureCapacity(4),this.view().setInt32(this.pos,t,!0),this.pos+=4,this}sint32(t){return S(t),this.uint32((t<<1^t>>31)>>>0)}sfixed64(t){const e=c.enc(t);this.ensureCapacity(8);const r=this.view();return r.setInt32(this.pos,e.lo,!0),r.setInt32(this.pos+4,e.hi,!0),this.pos+=8,this}fixed64(t){const e=c.uEnc(t);this.ensureCapacity(8);const r=this.view();return r.setInt32(this.pos,e.lo,!0),r.setInt32(this.pos+4,e.hi,!0),this.pos+=8,this}int64(t){const e=c.enc(t);return this.writeVarint64(e.lo,e.hi)}sint64(t){const e=c.enc(t),r=e.hi>>31,i=e.lo<<1^r,n=(e.hi<<1|e.lo>>>31)^r;return this.writeVarint64(i,n)}uint64(t){const e=c.uEnc(t);return this.writeVarint64(e.lo,e.hi)}writeVarint64(t,e){this.ensureCapacity(10);const r=this.buffer;let i=this.pos;for(let n=0;n<28;n+=7){const s=t>>>n,o=!(s>>>7==0&&0==e);if(r[i++]=255&(o?128|s:s),!o)return this.pos=i,this}const n=t>>>28&15|(7&e)<<4,s=!!(e>>3);if(r[i++]=255&(s?128|n:n),!s)return this.pos=i,this;for(let t=3;t<31;t+=7){const n=e>>>t,s=!(n>>>7==0);if(r[i++]=255&(s?128|n:n),!s)return this.pos=i,this}return r[i++]=e>>>31&1,this.pos=i,this}}const I=128,g=1,R=new Uint8Array(0),v=new DataView(R.buffer),A=32;function y(t){return t<128?1:t<16384?2:t<2097152?3:t<268435456?4:5}class O{constructor(t,e=T().decodeUtf8){this.decodeUtf8=e,this.varint64Lo=0,this.varint64Hi=0,this.varint64=r,this.uint32=d,this.buf=t,this.len=t.length,this.pos=0,this.view=new DataView(t.buffer,t.byteOffset,t.byteLength)}tag(){const t=this.pos,e=this.uint32(),r=this.pos-t;if(r>5||5==r&&this.buf[this.pos-1]>15)throw new Error("illegal tag: varint overflows uint32");const i=e>>>3,n=7&e;if(i<=0||n>5)throw new Error("illegal tag: field no "+i+" wire type "+n);return[i,n]}skip(t,e,r=100){let i=this.pos;switch(t){case E.Varint:for(;128&this.buf[this.pos++];);break;case E.Bit64:this.pos+=4;case E.Bit32:this.pos+=4;break;case E.LengthDelimited:let i=this.uint32();this.pos+=i;break;case E.StartGroup:if(r<=0)throw new Error("maximum recursion depth reached");for(;;){const[t,i]=this.tag();if(i===E.EndGroup){if(void 0!==e&&t!==e)throw new Error("invalid end group tag");break}this.skip(i,t,r-1)}break;default:throw new Error("cant skip wire type "+t)}return this.assertBounds(),this.buf.subarray(i,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return 0|this.uint32()}sint32(){let t=this.uint32();return t>>>1^-(1&t)}int64(){return this.varint64(),c.dec(this.varint64Lo,this.varint64Hi)}uint64(){return this.varint64(),c.uDec(this.varint64Lo,this.varint64Hi)}sint64(){this.varint64();let t=this.varint64Lo,e=this.varint64Hi,r=-(1&t);return t=(t>>>1|(1&e)<<31)^r,e=e>>>1^r,c.dec(t,e)}bool(){const t=this.buf[this.pos];return t<128?(this.pos++,0!==t):(this.varint64(),0!==this.varint64Lo||0!==this.varint64Hi)}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return c.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return c.dec(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let t=this.uint32(),e=this.pos;return this.pos+=t,this.assertBounds(),this.buf.subarray(e,e+t)}string(t){const e=this.bytes(),r=e.length;if(r<=A){const i=new Array(r);for(let n=0;n<r;n++){const r=e[n];if(r>127)return this.decodeUtf8(e,t);i[n]=r}return String.fromCharCode.apply(String,i)}return this.decodeUtf8(e,t)}}function S(t){if("string"==typeof t)t=Number(t);else if("number"!=typeof t)throw new Error("invalid int32: "+typeof t);if(!Number.isInteger(t)||t>2147483647||t<-2147483648)throw new Error("invalid int32: "+t)}function N(t){if("string"==typeof t)t=Number(t);else if("number"!=typeof t)throw new Error("invalid uint32: "+typeof t);if(!Number.isInteger(t)||t>4294967295||t<0)throw new Error("invalid uint32: "+t)}var b,w;function P(t){switch(t){case 0:case"TRANSFER_TYPE_UNSPECIFIED":return b.TRANSFER_TYPE_UNSPECIFIED;case 1:case"TRANSFER_TYPE_RECOMMENDED_TRANSFER_POINT":return b.TRANSFER_TYPE_RECOMMENDED_TRANSFER_POINT;case 2:case"TRANSFER_TYPE_TIMED_TRANSFER":return b.TRANSFER_TYPE_TIMED_TRANSFER;case 3:case"TRANSFER_TYPE_REQUIRES_MINIMAL_TIME":return b.TRANSFER_TYPE_REQUIRES_MINIMAL_TIME;case 4:case"TRANSFER_TYPE_IN_SEAT_TRANSFER":return b.TRANSFER_TYPE_IN_SEAT_TRANSFER;default:return b.UNRECOGNIZED}}function U(t){switch(t){case 0:case"ROUTE_TYPE_UNSPECIFIED":return w.ROUTE_TYPE_UNSPECIFIED;case 1:case"ROUTE_TYPE_TRAM":return w.ROUTE_TYPE_TRAM;case 2:case"ROUTE_TYPE_SUBWAY":return w.ROUTE_TYPE_SUBWAY;case 3:case"ROUTE_TYPE_RAIL":return w.ROUTE_TYPE_RAIL;case 4:case"ROUTE_TYPE_BUS":return w.ROUTE_TYPE_BUS;case 5:case"ROUTE_TYPE_FERRY":return w.ROUTE_TYPE_FERRY;case 6:case"ROUTE_TYPE_CABLE_TRAM":return w.ROUTE_TYPE_CABLE_TRAM;case 7:case"ROUTE_TYPE_AERIAL_LIFT":return w.ROUTE_TYPE_AERIAL_LIFT;case 8:case"ROUTE_TYPE_FUNICULAR":return w.ROUTE_TYPE_FUNICULAR;case 9:case"ROUTE_TYPE_TROLLEYBUS":return w.ROUTE_TYPE_TROLLEYBUS;case 10:case"ROUTE_TYPE_MONORAIL":return w.ROUTE_TYPE_MONORAIL;default:return w.UNRECOGNIZED}}function x(){return{stopTimes:new Uint8Array(0),pickupDropOffTypes:new Uint8Array(0),stops:new Uint8Array(0),serviceRouteId:0}}!function(t){t[t.TRANSFER_TYPE_UNSPECIFIED=0]="TRANSFER_TYPE_UNSPECIFIED",t[t.TRANSFER_TYPE_RECOMMENDED_TRANSFER_POINT=1]="TRANSFER_TYPE_RECOMMENDED_TRANSFER_POINT",t[t.TRANSFER_TYPE_TIMED_TRANSFER=2]="TRANSFER_TYPE_TIMED_TRANSFER",t[t.TRANSFER_TYPE_REQUIRES_MINIMAL_TIME=3]="TRANSFER_TYPE_REQUIRES_MINIMAL_TIME",t[t.TRANSFER_TYPE_IN_SEAT_TRANSFER=4]="TRANSFER_TYPE_IN_SEAT_TRANSFER",t[t.UNRECOGNIZED=-1]="UNRECOGNIZED"}(b||(b={})),function(t){t[t.ROUTE_TYPE_UNSPECIFIED=0]="ROUTE_TYPE_UNSPECIFIED",t[t.ROUTE_TYPE_TRAM=1]="ROUTE_TYPE_TRAM",t[t.ROUTE_TYPE_SUBWAY=2]="ROUTE_TYPE_SUBWAY",t[t.ROUTE_TYPE_RAIL=3]="ROUTE_TYPE_RAIL",t[t.ROUTE_TYPE_BUS=4]="ROUTE_TYPE_BUS",t[t.ROUTE_TYPE_FERRY=5]="ROUTE_TYPE_FERRY",t[t.ROUTE_TYPE_CABLE_TRAM=6]="ROUTE_TYPE_CABLE_TRAM",t[t.ROUTE_TYPE_AERIAL_LIFT=7]="ROUTE_TYPE_AERIAL_LIFT",t[t.ROUTE_TYPE_FUNICULAR=8]="ROUTE_TYPE_FUNICULAR",t[t.ROUTE_TYPE_TROLLEYBUS=9]="ROUTE_TYPE_TROLLEYBUS",t[t.ROUTE_TYPE_MONORAIL=10]="ROUTE_TYPE_MONORAIL",t[t.UNRECOGNIZED=-1]="UNRECOGNIZED"}(w||(w={}));const L={encode:(t,e=new m)=>(0!==t.stopTimes.length&&e.uint32(10).bytes(t.stopTimes),0!==t.pickupDropOffTypes.length&&e.uint32(18).bytes(t.pickupDropOffTypes),0!==t.stops.length&&e.uint32(26).bytes(t.stops),0!==t.serviceRouteId&&e.uint32(32).uint32(t.serviceRouteId),e),decode(t,e){var r;const i=t instanceof O?t:new O(t),n=null!==(r=i.__tsProtoDecodeDepth)&&void 0!==r?r:0;if(n>=100)throw new globalThis.Error("protobuf decode recursion limit exceeded");i.__tsProtoDecodeDepth=n+1;try{const t=void 0===e?i.len:i.pos+e,r=x();for(;i.pos<t;){const t=i.uint32();switch(t>>>3){case 1:if(10!==t)break;r.stopTimes=i.bytes();continue;case 2:if(18!==t)break;r.pickupDropOffTypes=i.bytes();continue;case 3:if(26!==t)break;r.stops=i.bytes();continue;case 4:if(32!==t)break;r.serviceRouteId=i.uint32();continue}if(4==(7&t)||0===t)break;i.skip(7&t)}return r}finally{i.__tsProtoDecodeDepth=n}},fromJSON:t=>({stopTimes:j(t.stopTimes)?k(t.stopTimes):j(t.stop_times)?k(t.stop_times):new Uint8Array(0),pickupDropOffTypes:j(t.pickupDropOffTypes)?k(t.pickupDropOffTypes):j(t.pickup_drop_off_types)?k(t.pickup_drop_off_types):new Uint8Array(0),stops:j(t.stops)?k(t.stops):new Uint8Array(0),serviceRouteId:j(t.serviceRouteId)?globalThis.Number(t.serviceRouteId):j(t.service_route_id)?globalThis.Number(t.service_route_id):0}),toJSON(t){const e={};return 0!==t.stopTimes.length&&(e.stopTimes=$(t.stopTimes)),0!==t.pickupDropOffTypes.length&&(e.pickupDropOffTypes=$(t.pickupDropOffTypes)),0!==t.stops.length&&(e.stops=$(t.stops)),0!==t.serviceRouteId&&(e.serviceRouteId=Math.round(t.serviceRouteId)),e},create:t=>L.fromPartial(null!=t?t:{}),fromPartial(t){var e,r,i,n;const s=x();return s.stopTimes=null!==(e=t.stopTimes)&&void 0!==e?e:new Uint8Array(0),s.pickupDropOffTypes=null!==(r=t.pickupDropOffTypes)&&void 0!==r?r:new Uint8Array(0),s.stops=null!==(i=t.stops)&&void 0!==i?i:new Uint8Array(0),s.serviceRouteId=null!==(n=t.serviceRouteId)&&void 0!==n?n:0,s}};const D={encode:(t,e=new m)=>(0!==t.destination&&e.uint32(8).uint32(t.destination),0!==t.type&&e.uint32(16).int32(t.type),void 0!==t.minTransferTime&&e.uint32(24).uint32(t.minTransferTime),e),decode(t,e){var r;const i=t instanceof O?t:new O(t),n=null!==(r=i.__tsProtoDecodeDepth)&&void 0!==r?r:0;if(n>=100)throw new globalThis.Error("protobuf decode recursion limit exceeded");i.__tsProtoDecodeDepth=n+1;try{const t=void 0===e?i.len:i.pos+e,r={destination:0,type:0,minTransferTime:void 0};for(;i.pos<t;){const t=i.uint32();switch(t>>>3){case 1:if(8!==t)break;r.destination=i.uint32();continue;case 2:if(16!==t)break;r.type=i.int32();continue;case 3:if(24!==t)break;r.minTransferTime=i.uint32();continue}if(4==(7&t)||0===t)break;i.skip(7&t)}return r}finally{i.__tsProtoDecodeDepth=n}},fromJSON:t=>({destination:j(t.destination)?globalThis.Number(t.destination):0,type:j(t.type)?P(t.type):0,minTransferTime:j(t.minTransferTime)?globalThis.Number(t.minTransferTime):j(t.min_transfer_time)?globalThis.Number(t.min_transfer_time):void 0}),toJSON(t){const e={};return 0!==t.destination&&(e.destination=Math.round(t.destination)),0!==t.type&&(e.type=function(t){switch(t){case b.TRANSFER_TYPE_UNSPECIFIED:return"TRANSFER_TYPE_UNSPECIFIED";case b.TRANSFER_TYPE_RECOMMENDED_TRANSFER_POINT:return"TRANSFER_TYPE_RECOMMENDED_TRANSFER_POINT";case b.TRANSFER_TYPE_TIMED_TRANSFER:return"TRANSFER_TYPE_TIMED_TRANSFER";case b.TRANSFER_TYPE_REQUIRES_MINIMAL_TIME:return"TRANSFER_TYPE_REQUIRES_MINIMAL_TIME";case b.TRANSFER_TYPE_IN_SEAT_TRANSFER:return"TRANSFER_TYPE_IN_SEAT_TRANSFER";case b.UNRECOGNIZED:default:return"UNRECOGNIZED"}}(t.type)),void 0!==t.minTransferTime&&(e.minTransferTime=Math.round(t.minTransferTime)),e},create:t=>D.fromPartial(null!=t?t:{}),fromPartial(t){var e,r,i;const n={destination:0,type:0,minTransferTime:void 0};return n.destination=null!==(e=t.destination)&&void 0!==e?e:0,n.type=null!==(r=t.type)&&void 0!==r?r:0,n.minTransferTime=null!==(i=t.minTransferTime)&&void 0!==i?i:void 0,n}};const C={encode:(t,e=new m)=>(0!==t.stopIndex&&e.uint32(8).uint32(t.stopIndex),0!==t.routeId&&e.uint32(16).uint32(t.routeId),0!==t.tripIndex&&e.uint32(24).uint32(t.tripIndex),e),decode(t,e){var r;const i=t instanceof O?t:new O(t),n=null!==(r=i.__tsProtoDecodeDepth)&&void 0!==r?r:0;if(n>=100)throw new globalThis.Error("protobuf decode recursion limit exceeded");i.__tsProtoDecodeDepth=n+1;try{const t=void 0===e?i.len:i.pos+e,r={stopIndex:0,routeId:0,tripIndex:0};for(;i.pos<t;){const t=i.uint32();switch(t>>>3){case 1:if(8!==t)break;r.stopIndex=i.uint32();continue;case 2:if(16!==t)break;r.routeId=i.uint32();continue;case 3:if(24!==t)break;r.tripIndex=i.uint32();continue}if(4==(7&t)||0===t)break;i.skip(7&t)}return r}finally{i.__tsProtoDecodeDepth=n}},fromJSON:t=>({stopIndex:j(t.stopIndex)?globalThis.Number(t.stopIndex):j(t.stop_index)?globalThis.Number(t.stop_index):0,routeId:j(t.routeId)?globalThis.Number(t.routeId):j(t.route_id)?globalThis.Number(t.route_id):0,tripIndex:j(t.tripIndex)?globalThis.Number(t.tripIndex):j(t.trip_index)?globalThis.Number(t.trip_index):0}),toJSON(t){const e={};return 0!==t.stopIndex&&(e.stopIndex=Math.round(t.stopIndex)),0!==t.routeId&&(e.routeId=Math.round(t.routeId)),0!==t.tripIndex&&(e.tripIndex=Math.round(t.tripIndex)),e},create:t=>C.fromPartial(null!=t?t:{}),fromPartial(t){var e,r,i;const n={stopIndex:0,routeId:0,tripIndex:0};return n.stopIndex=null!==(e=t.stopIndex)&&void 0!==e?e:0,n.routeId=null!==(r=t.routeId)&&void 0!==r?r:0,n.tripIndex=null!==(i=t.tripIndex)&&void 0!==i?i:0,n}};const M={encode(t,e=new m){void 0!==t.origin&&C.encode(t.origin,e.uint32(10).fork()).join();for(const r of t.destinations)C.encode(r,e.uint32(18).fork()).join();return e},decode(t,e){var r;const i=t instanceof O?t:new O(t),n=null!==(r=i.__tsProtoDecodeDepth)&&void 0!==r?r:0;if(n>=100)throw new globalThis.Error("protobuf decode recursion limit exceeded");i.__tsProtoDecodeDepth=n+1;try{const t=void 0===e?i.len:i.pos+e,r={origin:void 0,destinations:[]};for(;i.pos<t;){const t=i.uint32();switch(t>>>3){case 1:if(10!==t)break;r.origin=C.decode(i,i.uint32());continue;case 2:if(18!==t)break;r.destinations.push(C.decode(i,i.uint32()));continue}if(4==(7&t)||0===t)break;i.skip(7&t)}return r}finally{i.__tsProtoDecodeDepth=n}},fromJSON:t=>({origin:j(t.origin)?C.fromJSON(t.origin):void 0,destinations:globalThis.Array.isArray(null==t?void 0:t.destinations)?t.destinations.map((t=>C.fromJSON(t))):[]}),toJSON(t){var e;const r={};return void 0!==t.origin&&(r.origin=C.toJSON(t.origin)),(null===(e=t.destinations)||void 0===e?void 0:e.length)&&(r.destinations=t.destinations.map((t=>C.toJSON(t)))),r},create:t=>M.fromPartial(null!=t?t:{}),fromPartial(t){var e;const r={origin:void 0,destinations:[]};return r.origin=void 0!==t.origin&&null!==t.origin?C.fromPartial(t.origin):void 0,r.destinations=(null===(e=t.destinations)||void 0===e?void 0:e.map((t=>C.fromPartial(t))))||[],r}};const Y={encode(t,e=new m){if(0!==t.routes.length){e.uint32(10).fork();for(const r of t.routes)e.uint32(r);e.join()}for(const r of t.transfers)D.encode(r,e.uint32(18).fork()).join();return e},decode(t,e){var r;const i=t instanceof O?t:new O(t),n=null!==(r=i.__tsProtoDecodeDepth)&&void 0!==r?r:0;if(n>=100)throw new globalThis.Error("protobuf decode recursion limit exceeded");i.__tsProtoDecodeDepth=n+1;try{const t=void 0===e?i.len:i.pos+e,r={routes:[],transfers:[]};for(;i.pos<t;){const t=i.uint32();switch(t>>>3){case 1:if(8===t){r.routes.push(i.uint32());continue}if(10===t){const t=i.uint32()+i.pos;for(;i.pos<t;)r.routes.push(i.uint32());continue}break;case 2:if(18!==t)break;r.transfers.push(D.decode(i,i.uint32()));continue}if(4==(7&t)||0===t)break;i.skip(7&t)}return r}finally{i.__tsProtoDecodeDepth=n}},fromJSON:t=>({routes:globalThis.Array.isArray(null==t?void 0:t.routes)?t.routes.map((t=>globalThis.Number(t))):[],transfers:globalThis.Array.isArray(null==t?void 0:t.transfers)?t.transfers.map((t=>D.fromJSON(t))):[]}),toJSON(t){var e,r;const i={};return(null===(e=t.routes)||void 0===e?void 0:e.length)&&(i.routes=t.routes.map((t=>Math.round(t)))),(null===(r=t.transfers)||void 0===r?void 0:r.length)&&(i.transfers=t.transfers.map((t=>D.toJSON(t)))),i},create:t=>Y.fromPartial(null!=t?t:{}),fromPartial(t){var e,r;const i={routes:[],transfers:[]};return i.routes=(null===(e=t.routes)||void 0===e?void 0:e.map((t=>t)))||[],i.transfers=(null===(r=t.transfers)||void 0===r?void 0:r.map((t=>D.fromPartial(t))))||[],i}};const F={encode(t,e=new m){if(0!==t.type&&e.uint32(8).int32(t.type),""!==t.name&&e.uint32(18).string(t.name),0!==t.routes.length){e.uint32(26).fork();for(const r of t.routes)e.uint32(r);e.join()}return e},decode(t,e){var r;const i=t instanceof O?t:new O(t),n=null!==(r=i.__tsProtoDecodeDepth)&&void 0!==r?r:0;if(n>=100)throw new globalThis.Error("protobuf decode recursion limit exceeded");i.__tsProtoDecodeDepth=n+1;try{const t=void 0===e?i.len:i.pos+e,r={type:0,name:"",routes:[]};for(;i.pos<t;){const t=i.uint32();switch(t>>>3){case 1:if(8!==t)break;r.type=i.int32();continue;case 2:if(18!==t)break;r.name=i.string();continue;case 3:if(24===t){r.routes.push(i.uint32());continue}if(26===t){const t=i.uint32()+i.pos;for(;i.pos<t;)r.routes.push(i.uint32());continue}}if(4==(7&t)||0===t)break;i.skip(7&t)}return r}finally{i.__tsProtoDecodeDepth=n}},fromJSON:t=>({type:j(t.type)?U(t.type):0,name:j(t.name)?globalThis.String(t.name):"",routes:globalThis.Array.isArray(null==t?void 0:t.routes)?t.routes.map((t=>globalThis.Number(t))):[]}),toJSON(t){var e;const r={};return 0!==t.type&&(r.type=function(t){switch(t){case w.ROUTE_TYPE_UNSPECIFIED:return"ROUTE_TYPE_UNSPECIFIED";case w.ROUTE_TYPE_TRAM:return"ROUTE_TYPE_TRAM";case w.ROUTE_TYPE_SUBWAY:return"ROUTE_TYPE_SUBWAY";case w.ROUTE_TYPE_RAIL:return"ROUTE_TYPE_RAIL";case w.ROUTE_TYPE_BUS:return"ROUTE_TYPE_BUS";case w.ROUTE_TYPE_FERRY:return"ROUTE_TYPE_FERRY";case w.ROUTE_TYPE_CABLE_TRAM:return"ROUTE_TYPE_CABLE_TRAM";case w.ROUTE_TYPE_AERIAL_LIFT:return"ROUTE_TYPE_AERIAL_LIFT";case w.ROUTE_TYPE_FUNICULAR:return"ROUTE_TYPE_FUNICULAR";case w.ROUTE_TYPE_TROLLEYBUS:return"ROUTE_TYPE_TROLLEYBUS";case w.ROUTE_TYPE_MONORAIL:return"ROUTE_TYPE_MONORAIL";case w.UNRECOGNIZED:default:return"UNRECOGNIZED"}}(t.type)),""!==t.name&&(r.name=t.name),(null===(e=t.routes)||void 0===e?void 0:e.length)&&(r.routes=t.routes.map((t=>Math.round(t)))),r},create:t=>F.fromPartial(null!=t?t:{}),fromPartial(t){var e,r,i;const n={type:0,name:"",routes:[]};return n.type=null!==(e=t.type)&&void 0!==e?e:0,n.name=null!==(r=t.name)&&void 0!==r?r:"",n.routes=(null===(i=t.routes)||void 0===i?void 0:i.map((t=>t)))||[],n}};const B={encode(t,e=new m){for(const r of t.stopsAdjacency)Y.encode(r,e.uint32(10).fork()).join();for(const r of t.routesAdjacency)L.encode(r,e.uint32(18).fork()).join();for(const r of t.serviceRoutes)F.encode(r,e.uint32(26).fork()).join();for(const r of t.tripContinuations)M.encode(r,e.uint32(34).fork()).join();for(const r of t.guaranteedTripTransfers)M.encode(r,e.uint32(42).fork()).join();return e},decode(t,e){var r;const i=t instanceof O?t:new O(t),n=null!==(r=i.__tsProtoDecodeDepth)&&void 0!==r?r:0;if(n>=100)throw new globalThis.Error("protobuf decode recursion limit exceeded");i.__tsProtoDecodeDepth=n+1;try{const t=void 0===e?i.len:i.pos+e,r={stopsAdjacency:[],routesAdjacency:[],serviceRoutes:[],tripContinuations:[],guaranteedTripTransfers:[]};for(;i.pos<t;){const t=i.uint32();switch(t>>>3){case 1:if(10!==t)break;r.stopsAdjacency.push(Y.decode(i,i.uint32()));continue;case 2:if(18!==t)break;r.routesAdjacency.push(L.decode(i,i.uint32()));continue;case 3:if(26!==t)break;r.serviceRoutes.push(F.decode(i,i.uint32()));continue;case 4:if(34!==t)break;r.tripContinuations.push(M.decode(i,i.uint32()));continue;case 5:if(42!==t)break;r.guaranteedTripTransfers.push(M.decode(i,i.uint32()));continue}if(4==(7&t)||0===t)break;i.skip(7&t)}return r}finally{i.__tsProtoDecodeDepth=n}},fromJSON:t=>({stopsAdjacency:globalThis.Array.isArray(null==t?void 0:t.stopsAdjacency)?t.stopsAdjacency.map((t=>Y.fromJSON(t))):globalThis.Array.isArray(null==t?void 0:t.stops_adjacency)?t.stops_adjacency.map((t=>Y.fromJSON(t))):[],routesAdjacency:globalThis.Array.isArray(null==t?void 0:t.routesAdjacency)?t.routesAdjacency.map((t=>L.fromJSON(t))):globalThis.Array.isArray(null==t?void 0:t.routes_adjacency)?t.routes_adjacency.map((t=>L.fromJSON(t))):[],serviceRoutes:globalThis.Array.isArray(null==t?void 0:t.serviceRoutes)?t.serviceRoutes.map((t=>F.fromJSON(t))):globalThis.Array.isArray(null==t?void 0:t.service_routes)?t.service_routes.map((t=>F.fromJSON(t))):[],tripContinuations:globalThis.Array.isArray(null==t?void 0:t.tripContinuations)?t.tripContinuations.map((t=>M.fromJSON(t))):globalThis.Array.isArray(null==t?void 0:t.trip_continuations)?t.trip_continuations.map((t=>M.fromJSON(t))):[],guaranteedTripTransfers:globalThis.Array.isArray(null==t?void 0:t.guaranteedTripTransfers)?t.guaranteedTripTransfers.map((t=>M.fromJSON(t))):globalThis.Array.isArray(null==t?void 0:t.guaranteed_trip_transfers)?t.guaranteed_trip_transfers.map((t=>M.fromJSON(t))):[]}),toJSON(t){var e,r,i,n,s;const o={};return(null===(e=t.stopsAdjacency)||void 0===e?void 0:e.length)&&(o.stopsAdjacency=t.stopsAdjacency.map((t=>Y.toJSON(t)))),(null===(r=t.routesAdjacency)||void 0===r?void 0:r.length)&&(o.routesAdjacency=t.routesAdjacency.map((t=>L.toJSON(t)))),(null===(i=t.serviceRoutes)||void 0===i?void 0:i.length)&&(o.serviceRoutes=t.serviceRoutes.map((t=>F.toJSON(t)))),(null===(n=t.tripContinuations)||void 0===n?void 0:n.length)&&(o.tripContinuations=t.tripContinuations.map((t=>M.toJSON(t)))),(null===(s=t.guaranteedTripTransfers)||void 0===s?void 0:s.length)&&(o.guaranteedTripTransfers=t.guaranteedTripTransfers.map((t=>M.toJSON(t)))),o},create:t=>B.fromPartial(null!=t?t:{}),fromPartial(t){var e,r,i,n,s;const o={stopsAdjacency:[],routesAdjacency:[],serviceRoutes:[],tripContinuations:[],guaranteedTripTransfers:[]};return o.stopsAdjacency=(null===(e=t.stopsAdjacency)||void 0===e?void 0:e.map((t=>Y.fromPartial(t))))||[],o.routesAdjacency=(null===(r=t.routesAdjacency)||void 0===r?void 0:r.map((t=>L.fromPartial(t))))||[],o.serviceRoutes=(null===(i=t.serviceRoutes)||void 0===i?void 0:i.map((t=>F.fromPartial(t))))||[],o.tripContinuations=(null===(n=t.tripContinuations)||void 0===n?void 0:n.map((t=>M.fromPartial(t))))||[],o.guaranteedTripTransfers=(null===(s=t.guaranteedTripTransfers)||void 0===s?void 0:s.map((t=>M.fromPartial(t))))||[],o}};function k(t){if(globalThis.Buffer)return Uint8Array.from(globalThis.Buffer.from(t,"base64"));{const e=globalThis.atob(t),r=new Uint8Array(e.length);for(let t=0;t<e.length;++t)r[t]=e.charCodeAt(t);return r}}function $(t){if(globalThis.Buffer)return globalThis.Buffer.from(t).toString("base64");{const e=[];return t.forEach((t=>{e.push(globalThis.String.fromCharCode(t))})),globalThis.btoa(e.join(""))}}function j(t){return null!=t}const z={REGULAR:0,NOT_AVAILABLE:1,MUST_PHONE_AGENCY:2,MUST_COORDINATE_WITH_DRIVER:3};let V=class t{constructor(t,e,r,i,n){this.id=t,this.stopTimes=e,this.pickupDropOffTypes=r,this.stops=i,this.serviceRouteId=n,this.nbStops=i.length,this.nbTrips=this.stopTimes.length/(2*this.stops.length),this.stopIndices=new Map;for(let t=0;t<i.length;t++){const e=i[t],r=this.stopIndices.get(e);r?r.push(t):this.stopIndices.set(e,[t])}}static of(e){var r,i;const{id:n,serviceRouteId:s,trips:o}=e;if(0===o.length)throw new Error("At least one trip must be provided");const a=o[0],u=new Uint32Array(a.stops.map((t=>t.id))),d=u.length;for(let t=1;t<o.length;t++){const e=o[t];if(e.stops.length!==d)throw new Error(`Trip ${t} has ${e.stops.length} stops, expected ${d}`);for(let r=0;r<d;r++)if(e.stops[r].id!==u[r])throw new Error(`Trip ${t} has different stop at index ${r}`)}const c=new Uint16Array(o.length*d*2);for(let t=0;t<o.length;t++){const e=o[t];for(let r=0;r<d;r++){const i=e.stops[r],n=2*(t*d+r);c[n]=i.arrivalTime,c[n+1]=i.departureTime}}const l=o.length*d,h=new Uint8Array(Math.ceil(l/2));for(let t=0;t<o.length;t++){const e=o[t];for(let n=0;n<d;n++){const s=e.stops[n],o=t*d+n,a=null!==(r=s.pickUpType)&&void 0!==r?r:z.REGULAR,u=null!==(i=s.dropOffType)&&void 0!==i?i:z.REGULAR,c=Math.floor(o/2),l=o%2==1;h[c]|=l?a<<6|u<<4:a<<2|u}}return new t(n,c,h,u,s)}serialize(){return{stopTimes:this.stopTimes,pickupDropOffTypes:this.pickupDropOffTypes,stops:this.stops,serviceRouteId:this.serviceRouteId}}getNbStops(){return this.nbStops}getNbTrips(){return this.nbTrips}serviceRoute(){return this.serviceRouteId}arrivalAt(t,e){const r=2*(e*this.stops.length+t),i=this.stopTimes[r];if(void 0===i)throw new Error(`Arrival time not found for stop ${this.stopId(t)} (${t}) at trip index ${e} in route ${this.serviceRouteId}`);return i}tripStopOffset(t){return t*this.nbStops}arrivalAtOffset(t,e){return this.stopTimes[2*(e+t)]}departureAtOffset(t,e){return this.stopTimes[2*(e+t)+1]}dropOffTypeAtOffset(t,e){const r=e+t,i=this.pickupDropOffTypes[r>>1];return 1&r?i>>4&3:3&i}departureFrom(t,e){const r=2*(e*this.stops.length+t)+1,i=this.stopTimes[r];if(void 0===i)throw new Error(`Departure time not found for stop ${this.stopId(t)} (${t}) at trip index ${e} in route ${this.serviceRouteId}`);return i}pickUpTypeFrom(t,e){const r=e*this.stops.length+t,i=r>>1,n=!(1&~r),s=this.pickupDropOffTypes[i];if(void 0===s)throw new Error(`Pick up type not found for stop ${this.stopId(t)} (${t}) at trip index ${e} in route ${this.serviceRouteId}`);return n?s>>6&3:s>>2&3}dropOffTypeAt(t,e){const r=e*this.stops.length+t,i=r>>1,n=!(1&~r),s=this.pickupDropOffTypes[i];if(void 0===s)throw new Error(`Drop off type not found for stop ${this.stopId(t)} (${t}) at trip index ${e} in route ${this.serviceRouteId}`);return n?s>>4&3:3&s}findEarliestTrip(t,e=0,r){if(this.nbTrips<=0)return;let i=this.nbTrips-1;if(void 0!==r&&(i=Math.min(i,r-1)),i<0)return;let n=0,s=-1;for(;n<=i;){const r=n+i>>>1;this.departureFrom(t,r)<e?n=r+1:(s=r,i=r-1)}return-1!==s?s:void 0}stopRouteIndices(t){const e=this.stopIndices.get(t);return void 0===e?[]:e}stopId(t){const e=this.stops[t];if(void 0===e)throw new Error(`StopId for stop at index ${t} not found in route ${this.serviceRouteId}`);return e}};const G=(BigInt(1)<<BigInt(20))-BigInt(1),J=1048575,W=BigInt(0),Z=BigInt(20),H=BigInt(40),Q=(t,e)=>{if(t<0||t>J)throw new Error(`${e} must be between 0 and 1048575, got ${t}`)},q=(t,e,r)=>(Q(t,"stopIndex"),Q(e,"routeId"),Q(r,"tripIndex"),BigInt(t)<<H|BigInt(e)<<Z|BigInt(r)<<W),X=(()=>{const t=new ArrayBuffer(4);return new DataView(t).setUint32(0,305419896),120===new Uint8Array(t)[0]})(),K=!0,tt=t=>{if(X===K)return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);const e=new Uint8Array(4*t.length),r=new DataView(e.buffer);for(let e=0;e<t.length;e++)r.setUint32(4*e,t[e],K);return e},et=t=>{if(t.byteLength%4!=0)throw new Error("Byte array length must be a multiple of 4 to convert to Uint32Array");if(X===K)return new Uint32Array(t.buffer,t.byteOffset,t.byteLength/4);const e=new Uint32Array(t.byteLength/4),r=new DataView(t.buffer,t.byteOffset,t.byteLength);for(let t=0;t<e.length;t++)e[t]=r.getUint32(4*t,K);return e},rt=t=>{if(X===K)return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);const e=new Uint8Array(2*t.length),r=new DataView(e.buffer);for(let e=0;e<t.length;e++)r.setUint16(2*e,t[e],K);return e},it=t=>{if(t.byteLength%2!=0)throw new Error("Byte array length must be a multiple of 2 to convert to Uint16Array");if(X===K)return new Uint16Array(t.buffer,t.byteOffset,t.byteLength/2);const e=new Uint16Array(t.byteLength/2),r=new DataView(t.buffer,t.byteOffset,t.byteLength);for(let t=0;t<e.length;t++)e[t]=r.getUint16(2*t,K);return e},nt=t=>{const e=[];return t.forEach((t=>{const r=t.serialize();e.push({stopTimes:rt(r.stopTimes),pickupDropOffTypes:r.pickupDropOffTypes,stops:tt(r.stops),serviceRouteId:r.serviceRouteId})})),e},st=t=>{switch(t){case b.TRANSFER_TYPE_UNSPECIFIED:throw new Error("Unspecified protobuf transfer type.");case b.TRANSFER_TYPE_RECOMMENDED_TRANSFER_POINT:return lt.RECOMMENDED;case b.TRANSFER_TYPE_TIMED_TRANSFER:return lt.GUARANTEED;case b.TRANSFER_TYPE_REQUIRES_MINIMAL_TIME:return lt.REQUIRES_MINIMAL_TIME;case b.TRANSFER_TYPE_IN_SEAT_TRANSFER:return lt.IN_SEAT;case b.UNRECOGNIZED:throw new Error("Unrecognized protobuf transfer type.")}},ot=t=>{switch(t){case lt.RECOMMENDED:return b.TRANSFER_TYPE_RECOMMENDED_TRANSFER_POINT;case lt.GUARANTEED:return b.TRANSFER_TYPE_TIMED_TRANSFER;case lt.REQUIRES_MINIMAL_TIME:return b.TRANSFER_TYPE_REQUIRES_MINIMAL_TIME;case lt.IN_SEAT:return b.TRANSFER_TYPE_IN_SEAT_TRANSFER}},at=t=>{switch(t){case w.ROUTE_TYPE_UNSPECIFIED:throw new Error("Unspecified protobuf route type.");case w.ROUTE_TYPE_TRAM:return ht.TRAM;case w.ROUTE_TYPE_SUBWAY:return ht.SUBWAY;case w.ROUTE_TYPE_RAIL:return ht.RAIL;case w.ROUTE_TYPE_BUS:return ht.BUS;case w.ROUTE_TYPE_FERRY:return ht.FERRY;case w.ROUTE_TYPE_CABLE_TRAM:return ht.CABLE_TRAM;case w.ROUTE_TYPE_AERIAL_LIFT:return ht.AERIAL_LIFT;case w.ROUTE_TYPE_FUNICULAR:return ht.FUNICULAR;case w.ROUTE_TYPE_TROLLEYBUS:return ht.TROLLEYBUS;case w.ROUTE_TYPE_MONORAIL:return ht.MONORAIL;case w.UNRECOGNIZED:default:throw new Error("Unrecognized protobuf route type.")}},ut=t=>{switch(t){case ht.TRAM:return w.ROUTE_TYPE_TRAM;case ht.SUBWAY:return w.ROUTE_TYPE_SUBWAY;case ht.RAIL:return w.ROUTE_TYPE_RAIL;case ht.BUS:return w.ROUTE_TYPE_BUS;case ht.FERRY:return w.ROUTE_TYPE_FERRY;case ht.CABLE_TRAM:return w.ROUTE_TYPE_CABLE_TRAM;case ht.AERIAL_LIFT:return w.ROUTE_TYPE_AERIAL_LIFT;case ht.FUNICULAR:return w.ROUTE_TYPE_FUNICULAR;case ht.TROLLEYBUS:return w.ROUTE_TYPE_TROLLEYBUS;case ht.MONORAIL:return w.ROUTE_TYPE_MONORAIL}},dt=t=>{const e=[];for(const[i,n]of t.entries()){const[t,s,o]=(r=i,[Number(r>>H&G),Number(r>>Z&G),Number(r>>W&G)]);e.push({origin:{stopIndex:t,routeId:s,tripIndex:o},destinations:n.map((t=>({stopIndex:t.stopIndex,routeId:t.routeId,tripIndex:t.tripIndex})))})}var r;return e},ct=t=>{const e=new Map;for(let r=0;r<t.length;r++){const i=t[r],n=i.origin,s=q(n.stopIndex,n.routeId,n.tripIndex),o=i.destinations.map((t=>({stopIndex:t.stopIndex,routeId:t.routeId,tripIndex:t.tripIndex})));e.set(s,o)}return e},lt={RECOMMENDED:1,GUARANTEED:2,REQUIRES_MINIMAL_TIME:3,IN_SEAT:4},ht={TRAM:1,SUBWAY:2,RAIL:3,BUS:4,FERRY:5,CABLE_TRAM:6,AERIAL_LIFT:7,FUNICULAR:8,TROLLEYBUS:9,MONORAIL:10},pt=new Set(Object.values(ht)),ft=[];class Tt{constructor(t,e,r,i,n){this.stopsAdjacency=t,this.routesAdjacency=e,this.serviceRoutes=r,this.tripContinuations=i,this.guaranteedTripTransfers=n,this.activeStops=new Set;for(let e=0;e<t.length;e++){const r=t[e];(r.routes.length>0||r.transfers&&r.transfers.length>0)&&this.activeStops.add(e)}}serialize(){const t={stopsAdjacency:(r=this.stopsAdjacency,r.map((t=>({transfers:t.transfers?t.transfers.map((t=>Object.assign({destination:t.destination,type:ot(t.type)},void 0!==t.minTransferTime&&{minTransferTime:t.minTransferTime}))):[],routes:t.routes})))),routesAdjacency:nt(this.routesAdjacency),serviceRoutes:(e=this.serviceRoutes,e.map((t=>({type:ut(t.type),name:t.name,routes:t.routes})))),tripContinuations:dt(this.tripContinuations||new Map),guaranteedTripTransfers:dt(this.guaranteedTripTransfers||new Map)};var e,r;const i=new m;return B.encode(t,i),i.finish()}static fromData(t){const e=new O(t),r=B.decode(e);return new Tt((t=>{const e=[];for(let r=0;r<t.length;r++){const i=t[r],n=[];for(let t=0;t<i.transfers.length;t++){const e=i.transfers[t],r=Object.assign({destination:e.destination,type:st(e.type)},void 0!==e.minTransferTime&&{minTransferTime:e.minTransferTime});n.push(r)}const s={routes:i.routes};n.length>0&&(s.transfers=n),e.push(s)}return e})(r.stopsAdjacency),(t=>{const e=[];for(let r=0;r<t.length;r++){const i=t[r],n=et(i.stops);e.push(new V(r,it(i.stopTimes),i.pickupDropOffTypes,n,i.serviceRouteId))}return e})(r.routesAdjacency),(t=>{const e=[];for(let r=0;r<t.length;r++){const i=t[r];e.push({type:at(i.type),name:i.name,routes:i.routes})}return e})(r.serviceRoutes),ct(r.tripContinuations),ct(r.guaranteedTripTransfers))}isActive(t){return this.activeStops.has(t)}nbStops(){return this.stopsAdjacency.length}getRoute(t){return this.routesAdjacency[t]}getTransfers(t){const e=this.stopsAdjacency[t];if(!e)throw new Error(`Stop ID ${t} not found`);return e.transfers||[]}getContinuousTrips(t,e,r){var i;const n=null===(i=this.tripContinuations)||void 0===i?void 0:i.get(q(t,e,r));return n||ft}getServiceRouteInfo(t){const e=this.serviceRoutes[t.serviceRoute()];if(!e)throw new Error(`Service route not found for route ID: ${t.serviceRoute()}`);return{type:e.type,name:e.name}}routesPassingThrough(t){const e=this.stopsAdjacency[t];if(!e)return[];const r=[];for(let t=0;t<e.routes.length;t++){const i=e.routes[t],n=this.routesAdjacency[i];n&&r.push(n)}return r}findReachableRoutes(t,e=pt){const r=new Map,i=e!==pt;for(const n of t){const t=this.stopsAdjacency[n];if(t)for(let s=0;s<t.routes.length;s++){const o=this.routesAdjacency[t.routes[s]];if(!o)continue;if(i){const t=this.serviceRoutes[o.serviceRoute()];if(!t||!e.has(t.type))continue}const a=o.stopRouteIndices(n)[0],u=r.get(o);void 0!==u?a<u&&r.set(o,a):r.set(o,a)}}return r}isTripTransferGuaranteed(t,e){var r;const i=q(t.stopIndex,t.routeId,t.tripIndex),n=null===(r=this.guaranteedTripTransfers)||void 0===r?void 0:r.get(i);if(!n)return!1;for(let t=0;t<n.length;t++){const r=n[t];if(r.stopIndex===e.stopIndex&&r.routeId===e.routeId&&r.tripIndex===e.tripIndex)return!0}return!1}findFirstBoardableTrip(t,e,r,i=0,n,s,o=0){const a=e.getNbTrips();for(let u=r;u<(null!=n?n:a);u++){if(e.pickUpTypeFrom(t,u)===z.NOT_AVAILABLE)continue;if(void 0===s)return u;if(this.isTripTransferGuaranteed(s,{stopIndex:t,routeId:e.id,tripIndex:u}))return u;if(e.departureFrom(t,u)>=i+o)return u}}getGuaranteedTripTransfers(t,e,r){var i;const n=null===(i=this.guaranteedTripTransfers)||void 0===i?void 0:i.get(q(t,e,r));return n||ft}}const _t=t=>{switch(t){case ht.TRAM:return"TRAM";case ht.SUBWAY:return"SUBWAY";case ht.RAIL:return"RAIL";case ht.BUS:return"BUS";case ht.FERRY:return"FERRY";case ht.CABLE_TRAM:return"CABLE_TRAM";case ht.AERIAL_LIFT:return"AERIAL_LIFT";case ht.FUNICULAR:return"FUNICULAR";case ht.TROLLEYBUS:return"TROLLEYBUS";case ht.MONORAIL:return"MONORAIL"}},Et=t=>{switch(t){case lt.RECOMMENDED:return"RECOMMENDED";case lt.GUARANTEED:return"GUARANTEED";case lt.REQUIRES_MINIMAL_TIME:return"REQUIRES_MINIMAL_TIME";case lt.IN_SEAT:return"IN_SEAT"}},mt={colors:{rounds:["#60a5fa","#ff9800","#14b8a6","#fb7185","#ffdf00","#b600ff","#ee82ee"],defaultRound:"#888888",originStation:"#60a5fa",destinationStation:"#ee82ee",defaultStation:"white",continuationFill:"#ffffcc"},penWidth:{continuation:2,continuationEdge:3}};function It(t){return"routeId"in t&&"stopIndex"in t&&"hopOffStopIndex"in t}function gt(t){return"from"in t&&"to"in t&&"type"in t}function Rt(t){return"from"in t&&"duration"in t}class vt{constructor(){this.lines=[]}addHeader(){return this.lines.push("digraph RoutingGraph {"," graph [overlap=false, splines=true, rankdir=TB, bgcolor=white, nodesep=0.8, ranksep=1.2, concentrate=true];",' node [fontname="Arial" margin=0.1];',' edge [fontname="Arial" fontsize=10];'),this}addComment(t){return this.lines.push("",` // ${t}`),this}addNode(t,e){const r=Object.entries(e).map((([t,e])=>`${t}="${e}"`)).join(" ");return this.lines.push(` "${t}" [${r}];`),this}addEdge(t,e,r={}){const i=Object.entries(r).map((([t,e])=>`${t}="${e}"`)).join(" "),n=i?` [${i}]`:"";return this.lines.push(` "${t}" -> "${e}"${n};`),this}addRaw(t){return this.lines.push(...t),this}build(){return this.lines.push("}"),this.lines.join("\n")}}class At{constructor(t){this.from=t.fromValue,this.to=t.toValue,this.departureTime=t.departureTimeValue,this.options=t.optionsValue}}At.Builder=class{constructor(){var t;this.toValue=new Set,this.optionsValue={maxTransfers:5,minTransferTime:(t=120,Math.round(t/60)),transportModes:pt}}from(t){return this.fromValue=t,this}to(t){return this.toValue=t instanceof Set?t:new Set([t]),this}departureTime(t){return this.departureTimeValue=t,this}maxTransfers(t){return this.optionsValue.maxTransfers=t,this}minTransferTime(t){return this.optionsValue.minTransferTime=t,this}transportModes(t){return this.optionsValue.transportModes=t,this}maxDuration(t){return this.optionsValue.maxDuration=t,this}maxInitialWaitingTime(t){return this.optionsValue.maxInitialWaitingTime=t,this}build(){return new At(this)}};class yt extends At{constructor(t){super(t),this.lastDepartureTime=t.lastDepartureTimeValue,this.rangeOptions=t.rangeOptionsValue}}yt.Builder=class extends At.Builder{constructor(){super(...arguments),this.rangeOptionsValue={optimizeBeyondLatestDeparture:!0}}lastDepartureTime(t){return this.lastDepartureTimeValue=t,this}rangeOptions(t){return this.rangeOptionsValue=Object.assign(Object.assign({},this.rangeOptionsValue),t),this}build(){return new yt(this)}};class Ot{constructor(t){this.legs=t}departureTime(){let t=0;for(let e=0;e<this.legs.length;e++){const r=this.legs[e];if("departureTime"in r)return r.departureTime-t;"duration"in r&&r.duration&&(t+=r.duration)}throw new Error("No vehicle leg found in route")}arrivalTime(){let t=0;for(let e=this.legs.length-1;e>=0;e--){const r=this.legs[e];if("arrivalTime"in r)return r.arrivalTime+t;"minTransferTime"in r&&r.minTransferTime&&(t+=r.minTransferTime)}throw new Error("No vehicle leg found in route")}totalDuration(){return 0===this.legs.length?0:Math.abs(this.arrivalTime()-this.departureTime())}toString(){return this.legs.map(((r,i)=>{const n=`From: ${r.from.name}${r.from.platform?` (Pl. ${r.from.platform})`:""}`,s=`To: ${r.to.name}${r.to.platform?` (Pl. ${r.to.platform})`:""}`,o="type"in r&&!("route"in r)?`Transfer: ${Et(r.type)}${r.minTransferTime?`, Minimum Transfer Time: ${e(r.minTransferTime)}`:""}`:"",a="duration"in r?`Access duration: ${e(r.duration)}`:"",u="route"in r&&"departureTime"in r&&"arrivalTime"in r?`Route: ${_t(r.route.type)} ${r.route.name}, Departure: ${t(r.departureTime)}, Arrival: ${t(r.arrivalTime)}`:"";return[`Leg ${i+1}:`,` ${n}`,` ${s}`,o?` ${o}`:"",a?` ${a}`:"",u?` ${u}`:""].filter((t=>""!==t.trim())).join("\n")})).join("\n")}}class St{constructor(t,e,r,i){this.destinations=t,this.routingState=e,this.stopsIndex=r,this.timetable=i}expandDestinations(t){const e=t instanceof Set?t:void 0!==t?[t]:this.destinations,r=new Set;for(const t of e)for(const e of this.stopsIndex.equivalentStops(t))r.add(e.id);return r}bestRouteToSourceStopId(t){var e;if(t instanceof Set){const e=new Set;for(const r of t){const t=this.stopsIndex.findStopBySourceStopId(r);void 0!==t&&e.add(t.id)}return 0===e.size?void 0:this.bestRoute(e)}const r=null===(e=this.stopsIndex.findStopBySourceStopId(t))||void 0===e?void 0:e.id;return void 0===r?void 0:this.bestRoute(r)}bestRoute(t){var e;const r=this.expandDestinations(t);let i,n,s;for(const t of r){const e=this.routingState.getArrival(t);void 0!==e&&(void 0===n||e.arrival<n)&&(i=t,n=e.arrival,s=e.legNumber)}if(void 0===i||void 0===s)return;const o=[];let a,u=i,d=s;for(;d>=0;){const t=null===(e=this.routingState.graph[d])||void 0===e?void 0:e[u];if(!t){if(0===d)break;throw new Error(`No edge arriving at stop ${u} at round ${d}`)}let r;if("routeId"in t){let e,i;if(t.continuationOf){let r=t;const n=[r];for(;r.continuationOf;)n.push(r.continuationOf),r=r.continuationOf;e=r,i=this.buildVehicleLeg(n)}else e=t,i=this.buildVehicleLeg([t]);r=i,a&&this.timetable.isTripTransferGuaranteed({stopIndex:e.hopOffStopIndex,routeId:e.routeId,tripIndex:e.tripIndex},{stopIndex:a.stopIndex,routeId:a.routeId,tripIndex:a.tripIndex})&&o.push(this.buildGuaranteedTransferLeg(e,a)),a=e}else if("type"in t)r=this.buildTransferLeg(t),a=void 0;else{if(!("duration"in t))break;r=this.buildAccessLeg(t),a=void 0}o.push(r),u=r.from.id,"routeId"in t&&(d-=1)}return new Ot(o.reverse())}buildServiceRouteInfo(t){const e=this.timetable.getServiceRouteInfo(t);return{type:e.type,name:e.name}}buildVehicleLeg(t){if(0===t.length)throw new Error("Cannot build vehicle leg from empty edges");const e=t[t.length-1],r=t[0],i=this.timetable.getRoute(e.routeId),n=this.timetable.getRoute(r.routeId);return{from:this.stopsIndex.findStopById(i.stopId(e.stopIndex)),to:this.stopsIndex.findStopById(n.stopId(r.hopOffStopIndex)),route:this.buildServiceRouteInfo(i),departureTime:i.departureFrom(e.stopIndex,e.tripIndex),arrivalTime:r.arrival,pickUpType:i.pickUpTypeFrom(e.stopIndex,e.tripIndex),dropOffType:n.dropOffTypeAt(r.hopOffStopIndex,r.tripIndex)}}buildTransferLeg(t){return{from:this.stopsIndex.findStopById(t.from),to:this.stopsIndex.findStopById(t.to),minTransferTime:t.minTransferTime,type:t.type}}buildAccessLeg(t){return{from:this.stopsIndex.findStopById(t.from),to:this.stopsIndex.findStopById(t.to),duration:t.duration}}buildGuaranteedTransferLeg(t,e){const r=this.timetable.getRoute(t.routeId),i=this.timetable.getRoute(e.routeId),n=r.stopId(t.hopOffStopIndex),s=i.stopId(e.stopIndex);return{from:this.stopsIndex.findStopById(n),to:this.stopsIndex.findStopById(s),type:lt.GUARANTEED}}arrivalAt(t,e){var r,i;const n=this.stopsIndex.equivalentStops(t);let s;for(const t of n){let n;if(void 0===e||(null===(r=this.routingState.getArrival(t.id))||void 0===r?void 0:r.legNumber)===e+1)n=this.routingState.getArrival(t.id);else for(let r=e+1;r>=0;r--){const e=null===(i=this.routingState.graph[r])||void 0===i?void 0:i[t.id];if(void 0!==e){n={arrival:e.arrival,legNumber:r};break}}void 0!==n&&(void 0===s||n.arrival<s.arrival)&&(s=n)}return s}}class Nt{constructor(t,e){this.timetable=t,this.stopsIndex=e}collectAccessPaths(t,e){var r;const i=this.stopsIndex.equivalentStops(t).map((t=>t.id)),n=new Map;for(const t of i){const i=n.get(t);(void 0===i||i.duration>0)&&n.set(t,{fromStopId:t,toStopId:t,duration:0});for(const i of this.timetable.getTransfers(t))if(i.type===lt.REQUIRES_MINIMAL_TIME){const s=null!==(r=i.minTransferTime)&&void 0!==r?r:e,o=n.get(i.destination);(void 0===o||o.duration&&s<o.duration)&&n.set(i.destination,{fromStopId:t,toStopId:i.destination,duration:s})}}return Array.from(n.values())}collectDepartureTimes(t,e,r){const i=new Map;for(const n of t){const{toStopId:t}=n,s=e+n.duration,o=r+n.duration;for(const e of this.timetable.routesPassingThrough(t))for(const r of e.stopRouteIndices(t)){let t=e.findEarliestTrip(r,s);if(void 0===t)continue;const a=e.getNbTrips();for(;t<a;){const s=e.departureFrom(r,t);if(s>o)break;if(e.pickUpTypeFrom(r,t)!==z.NOT_AVAILABLE){const t=s-n.duration;let e=i.get(t);void 0===e&&i.set(t,e=new Set),e.add(n)}t++}}}if(0===i.size)return[];const n=Array.from(i.entries()).sort((([t],[e])=>e-t));return n.map((([t,e])=>({depTime:t,legs:Array.from(e)})))}}const bt=65535;class wt{constructor(t,e,r,i,n=0,s){this._destinationBest=bt,this.maxArrivalTime=bt,this.reachedStops=[],this.destinations=e,this.maxDuration=s,this.maxArrivalTime=void 0===s?bt:t+s,this.destinationSet=new Set(e),this.earliestArrivalTimes=new Uint16Array(i).fill(bt),this.earliestArrivalLegs=new Uint8Array(i),this.origins=[],this.graph=[new Array(i)];for(let t=1;t<=n;t++)this.graph.push(new Array(i));this.seedAccessPaths(t,r)}seedAccessPaths(t,e){const r=new Set;for(const i of e){const e=t+i.duration;if(e>this.maxArrivalTime)continue;const n=0===i.duration?{stopId:i.fromStopId,arrival:t}:{arrival:e,from:i.fromStopId,to:i.toStopId,duration:i.duration},s=i.toStopId;e<this.earliestArrivalTimes[s]&&(this.earliestArrivalTimes[s]=e,this.graph[0][s]=n),r.add(s)}for(const t of r)this.reachedStops.push(t);this.origins=Array.from(r);for(let t=0;t<this.destinations.length;t++){const e=this.earliestArrivalTimes[this.destinations[t]];e<this._destinationBest&&(this._destinationBest=e)}}get nbStops(){return this.earliestArrivalTimes.length}arrivalTime(t){return this.earliestArrivalTimes[t]}get destinationBest(){return this._destinationBest}improvementBound(t,e){return this.arrivalTime(e)}initRound(t){}updateArrival(t,e,r){this.reachedStops.push(t),this.earliestArrivalTimes[t]=e,this.earliestArrivalLegs[t]=r,this.destinationSet.has(t)&&e<this._destinationBest&&(this._destinationBest=e)}resetFor(t,e){for(const t of this.reachedStops){this.earliestArrivalTimes[t]=bt,this.earliestArrivalLegs[t]=0;for(let e=0;e<this.graph.length;e++)this.graph[e][t]=void 0}this.reachedStops.length=0,this._destinationBest=bt,this.maxArrivalTime=void 0===this.maxDuration?bt:t+this.maxDuration,this.seedAccessPaths(t,e)}*arrivals(){for(let t=0;t<this.earliestArrivalTimes.length;t++){const e=this.earliestArrivalTimes[t];e<bt&&(yield{stop:t,arrival:e,legNumber:this.earliestArrivalLegs[t]})}}earliestArrivalAtAnyDestination(){return this._destinationBest}getArrival(t){const e=this.earliestArrivalTimes[t];if(!(e>=bt))return{arrival:e,legNumber:this.earliestArrivalLegs[t]}}isDestination(t){return this.destinationSet.has(t)}static fromTestData({nbStops:t,origins:e=[],destinations:r=[],arrivals:i=[],graph:n=[]}){const s=new wt(0,r,e.map((t=>({fromStopId:t,toStopId:t,duration:0}))),t),o=new Uint16Array(t).fill(bt),a=new Uint8Array(t);for(const[t,e,r]of i)o[t]=e,a[t]=r;s.earliestArrivalTimes=o,s.earliestArrivalLegs=a,s._destinationBest=bt;for(const t of r){const e=o[t];void 0!==e&&e<s._destinationBest&&(s._destinationBest=e)}const u=n.map((e=>{const r=new Array(t);for(const[t,i]of e)r[t]=i;return r}));return s.graph.splice(0,s.graph.length,...u),s}}class Pt{constructor(t,e,r,i){this.timetable=t,this.stopsIndex=e,this.accessFinder=r,this.raptor=i}route(t){const e=this.accessFinder.collectAccessPaths(t.from,t.options.minTransferTime),r=Array.from(t.to).flatMap((t=>this.stopsIndex.equivalentStops(t))).map((t=>t.id)),i=new wt(t.departureTime,r,e,this.timetable.nbStops(),t.options.maxTransfers+1,t.options.maxDuration);return this.raptor.run(t.options,i),new St(new Set(r),i,this.stopsIndex,this.timetable)}}class Ut{constructor(t,e){this._runs=t,this._destinations=e}get destinations(){return this._destinations}normalizeTargets(t){return t instanceof Set?new Set(t):void 0!==t?new Set([t]):new Set(this._destinations)}getRoutes(){const t=[];for(const{result:e}of this._runs){const r=e.bestRoute();void 0!==r&&t.push(r)}return t.reverse()}bestRoute(t){const e=this.normalizeTargets(t);let r,i;for(const t of this._runs)for(const n of e){const e=t.result.arrivalAt(n);void 0!==e&&((void 0===i||e.arrival<i)&&(i=e.arrival,r=t))}return null==r?void 0:r.result.bestRoute(e)}latestDepartureRoute(t){const e=this.normalizeTargets(t);for(const{result:t}of this._runs){const r=t.bestRoute(e);if(void 0!==r)return r}}fastestRoute(t){const e=this.normalizeTargets(t);let r,i=1/0;for(const t of this._runs)for(const n of e){const e=t.result.arrivalAt(n);if(void 0===e)continue;const s=e.arrival-t.departureTime;(s<i||s===i&&void 0!==r&&t.departureTime<r.departureTime)&&(i=s,r=t)}return null==r?void 0:r.result.bestRoute(e)}get size(){return this._runs.length}earliestArrivalAt(t,e){let r;for(const{result:i}of this._runs){const n=i.arrivalAt(t,e);void 0!==n&&(void 0===r||n.arrival<r.arrival)&&(r=n)}return r}shortestDurationTo(t,e){let r;for(const{departureTime:i,result:n}of this._runs){const s=n.arrivalAt(t,e);if(void 0===s)continue;const o=s.arrival-i;(void 0===r||o<r.duration)&&(r=Object.assign(Object.assign({},s),{duration:o}))}return r}allShortestDurations(){const t=new Map;for(const{departureTime:e,result:r}of this._runs)for(const{stop:i,arrival:n,legNumber:s}of r.routingState.arrivals()){const r=n-e,o=t.get(i);(void 0===o||r<o.duration)&&t.set(i,{arrival:n,legNumber:s,duration:r})}return t}allEarliestArrivals(){const t=new Map;for(const{result:e}of this._runs)for(const{stop:r,arrival:i,legNumber:n}of e.routingState.arrivals()){const e=t.get(r);(void 0===e||i<e.arrival)&&t.set(r,{arrival:i,legNumber:n})}return t}[Symbol.iterator](){return this._runs[Symbol.iterator]()}}class xt{constructor(t,e,r){this._destinationBest=bt,this.latestDeparture=r,this.roundLabels=Array.from({length:t+2},(()=>new Uint16Array(e).fill(bt))),this.changedInRound=Array.from({length:t+2},(()=>[]))}setCurrentRun(t){this.currentRun=t;const e=t.graph[0];for(const r of t.origins){const t=e[r];t&&this.updateArrival(r,t.arrival,0)}}get origins(){return this.currentRun.origins}get graph(){return this.currentRun.graph}arrivalTime(t){return this.currentRun.arrivalTime(t)}improvementBound(t,e){return this.roundLabels[t][e]}get destinationBest(){return this._destinationBest}get maxArrivalTime(){return this.currentRun.maxArrivalTime}isDestination(t){return this.currentRun.isDestination(t)}updateArrival(t,e,r){const i=this.currentRun.getArrival(t);(void 0===i||e<i.arrival||e===i.arrival&&r<i.legNumber)&&this.currentRun.updateArrival(t,e,r),e<this.roundLabels[r][t]&&(this.roundLabels[r][t]=e,this.changedInRound[r].push(t),this.currentRun.isDestination(t)&&e<this._destinationBest&&(this._destinationBest=e))}initRound(t){const e=this.changedInRound[t-1];if(0===e.length)return;const r=this.roundLabels[t-1],i=this.roundLabels[t];for(let t=0;t<e.length;t++){const n=e[t];r[n]<i[n]&&(i[n]=r[n])}e.length=0}}class Lt{constructor(t,e,r,i){this.timetable=t,this.stopsIndex=e,this.accessFinder=r,this.raptor=i}rangeRoute(t){var e,r;const{departureTime:i,lastDepartureTime:n}=t,s=Array.from(t.to).flatMap((t=>this.stopsIndex.equivalentStops(t))).map((t=>t.id)),o=0===s.length,a=this.accessFinder.collectAccessPaths(t.from,t.options.minTransferTime),u=this.accessFinder.collectDepartureTimes(a,i,n);if(0===u.length)return new Ut([],new Set(s));const d=t.options.maxTransfers+1,c=new xt(d,this.timetable.nbStops(),n),l=[],h=new Map;for(const t of s)h.set(t,bt);const p=new Set(a.map((t=>t.toStopId)).filter((t=>s.includes(t)))),f=new Set;let T=null;if(t.rangeOptions.optimizeBeyondLatestDeparture&&(T=new wt(n+1,s,a,this.timetable.nbStops(),d,t.options.maxDuration),c.setCurrentRun(T),this.raptor.run(Object.assign(Object.assign({},t.options),{maxInitialWaitingTime:void 0}),c),!o))for(const t of s){const r=T.arrivalTime(t);r<(null!==(e=h.get(t))&&void 0!==e?e:bt)&&h.set(t,r)}for(const{depTime:e,legs:i}of u){if(!o&&f.size===s.length)break;null===T?T=new wt(e,s,i,this.timetable.nbStops(),d,t.options.maxDuration):T.resetFor(e,i),c.setCurrentRun(T),this.raptor.run(Object.assign(Object.assign({},t.options),{maxInitialWaitingTime:0}),c);let n=o;if(!o)for(const t of s){const e=T.arrivalTime(t);e>=(null!==(r=h.get(t))&&void 0!==r?r:bt)||(p.has(t)&&f.has(t)?h.set(t,e):(h.set(t,e),p.has(t)&&f.add(t),n=!0))}n&&(l.push({departureTime:e,result:new St(new Set(s),T,this.stopsIndex,this.timetable)}),T=null)}return new Ut(l,new Set(s))}}class Dt{constructor(t){this.timetable=t}run(t,e){const r=new Set(e.origins);for(let i=1;i<=t.maxTransfers+1;i++){e.initRound(i);const n=e.graph[i],s=this.timetable.findReachableRoutes(r,t.transportModes);r.clear();for(const[n,o]of s)for(const s of this.scanRoute(n,o,i,e,t))r.add(s);let o=this.findTripContinuations(r,n);const a=new Set;for(;o.length>0;){a.clear();for(const t of o){const n=this.timetable.getRoute(t.routeId);for(const s of this.scanRouteContinuation(n,t.stopIndex,i,e,t))a.add(s),r.add(s)}o=this.findTripContinuations(a,n)}for(const n of this.considerTransfers(t,i,r,e))r.add(n);if(0===r.size)break}}findTripContinuations(t,e){const r=[];for(const i of t){const t=e[i];if(!t||!("routeId"in t))continue;const n=this.timetable.getContinuousTrips(t.hopOffStopIndex,t.routeId,t.tripIndex);for(const e of n)r.push({routeId:e.routeId,stopIndex:e.stopIndex,tripIndex:e.tripIndex,previousEdge:t})}return r}scanRouteContinuation(t,e,r,i,n){const s=new Set,o=i.graph[r],a=t.getNbStops(),u=t.id,d=n.tripIndex,c=t.tripStopOffset(d),l=n.previousEdge;for(let n=e;n<a;n++){const a=t.stops[n],h=t.arrivalAtOffset(n,c);t.dropOffTypeAtOffset(n,c)!==z.NOT_AVAILABLE&&h<=i.maxArrivalTime&&h<i.improvementBound(r,a)&&h<i.destinationBest&&(o[a]={routeId:u,stopIndex:e,tripIndex:d,arrival:h,hopOffStopIndex:n,continuationOf:l},i.updateArrival(a,h,r),s.add(a))}return s}scanRoute(t,e,r,i,n){const s=new Set,o=i.graph[r],a=i.graph[r-1],u=t.getNbStops(),d=t.id;let c,l=e,h=0;for(let p=e;p<u;p++){const e=t.stops[p];if(void 0!==c){const n=t.arrivalAtOffset(p,h);t.dropOffTypeAtOffset(p,h)!==z.NOT_AVAILABLE&&n<=i.maxArrivalTime&&n<i.improvementBound(r,e)&&n<i.destinationBest&&(o[e]={routeId:d,stopIndex:l,tripIndex:c,arrival:n,hopOffStopIndex:p},i.updateArrival(e,n,r),s.add(e))}const u=a[e],f=null==u?void 0:u.arrival;if(void 0!==f&&(void 0===c||f<=t.departureAtOffset(p,h))){const e=t.findEarliestTrip(p,f,c);if(void 0===e)continue;const s=u&&"routeId"in u?{stopIndex:u.hopOffStopIndex,routeId:u.routeId,tripIndex:u.tripIndex}:void 0,o=this.timetable.findFirstBoardableTrip(p,t,e,f,c,s,n.minTransferTime);if(void 0!==o){const e=t.departureFrom(p,o),s=1===r&&void 0!==n.maxInitialWaitingTime&&e-f>n.maxInitialWaitingTime,a=e>i.maxArrivalTime;s||a||(c=o,l=p,h=t.tripStopOffset(o))}}}return s}considerTransfers(t,e,r,i){const n=new Set,s=i.graph[e];for(const o of r){const r=s[o];if(!r||"type"in r)continue;const a=this.timetable.getTransfers(o);for(const u of a){let a;a=u.minTransferTime?u.minTransferTime:u.type===lt.IN_SEAT?0:t.minTransferTime;const d=r.arrival+a;d<=i.maxArrivalTime&&d<i.improvementBound(e,u.destination)&&d<i.destinationBest&&(s[u.destination]={arrival:d,from:o,to:u.destination,minTransferTime:a||void 0,type:u.type},i.updateArrival(u.destination,d,e),n.add(u.destination))}}return n}}class Ct{constructor(t=[],e=(t,e)=>t<e?-1:t>e?1:0){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let t=(this.length>>1)-1;t>=0;t--)this._down(t)}push(t){this.data.push(t),this._up(this.length++)}pop(){if(0===this.length)return;const t=this.data[0],e=this.data.pop();return--this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:e,compare:r}=this,i=e[t];for(;t>0;){const n=t-1>>1,s=e[n];if(r(i,s)>=0)break;e[t]=s,t=n}e[t]=i}_down(t){const{data:e,compare:r}=this,i=this.length>>1,n=e[t];for(;t<i;){let i=1+(t<<1);const s=i+1;if(s<this.length&&r(e[s],e[i])<0&&(i=s),r(e[i],n)>=0)break;e[t]=e[i],t=i}e[t]=n}}const Mt=Math.PI/180;function Yt(t,e,r,i){const n=i.minLng,s=i.maxLng,o=i.minLat,a=i.maxLat;if(t>=n&&t<=s)return e<o?Bt((e-o)*Mt):e>a?Bt((e-a)*Mt):0;const u=Math.min(Bt((t-n)*Mt),Bt((t-s)*Mt)),d=function(t,e){const r=1-2*e;return r<=0?t>0?90:-90:Math.atan(Math.tan(t*Mt)/r)/Mt}(e,u);return d>o&&d<a?kt(u,r,e,d):Math.min(kt(u,r,e,o),kt(u,r,e,a))}function Ft(t,e){return t.dist-e.dist}function Bt(t){const e=Math.sin(t/2);return e*e}function kt(t,e,r,i){return e*Math.cos(i*Mt)*t+Bt((r-i)*Mt)}function $t(t,e,r,i,n){return kt(Bt((t-r)*Mt),n,e,i)}const jt=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],zt=new Uint32Array(96);class Vt{static from(t){if(!t||void 0===t.byteLength||t.buffer)throw new Error("Data must be an instance of ArrayBuffer or SharedArrayBuffer.");const[e,r]=new Uint8Array(t,0,2);if(219!==e)throw new Error("Data does not appear to be in a KDBush format.");const i=r>>4;if(1!==i)throw new Error(`Got v${i} data when expected v1.`);const n=jt[15&r];if(!n)throw new Error("Unrecognized array type.");const[s]=new Uint16Array(t,2,1),[o]=new Uint32Array(t,4,1);return new Vt(o,s,n,void 0,t)}constructor(t,e=64,r=Float64Array,i=ArrayBuffer,n){if(isNaN(t)||t<0)throw new Error(`Unexpected numItems value: ${t}.`);this.numItems=+t,this.nodeSize=Math.min(Math.max(+e,2),65535),this.ArrayType=r,this.IndexArrayType=t<65536?Uint16Array:Uint32Array;const s=jt.indexOf(this.ArrayType),o=2*t*this.ArrayType.BYTES_PER_ELEMENT,a=t*this.IndexArrayType.BYTES_PER_ELEMENT,u=(8-a%8)%8;if(s<0)throw new Error(`Unexpected typed array class: ${r}.`);if(n)this.data=n,this.ids=new this.IndexArrayType(n,8,t),this.coords=new r(n,8+a+u,2*t),this._pos=2*t,this._finished=!0;else{const n=this.data=new i(8+o+a+u);this.ids=new this.IndexArrayType(n,8,t),this.coords=new r(n,8+a+u,2*t),this._pos=0,this._finished=!1,new Uint8Array(n,0,2).set([219,16+s]),new Uint16Array(n,2,1)[0]=e,new Uint32Array(n,4,1)[0]=t}}add(t,e){const r=this._pos>>1;return this.ids[r]=r,this.coords[this._pos++]=t,this.coords[this._pos++]=e,r}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return Gt(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,e,r,i){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:s,nodeSize:o}=this;zt[0]=0,zt[1]=n.length-1,zt[2]=0;let a=3;const u=[];for(;a>0;){const d=zt[--a],c=zt[--a],l=zt[--a];if(c-l<=o){for(let o=l;o<=c;o++){const a=s[2*o],d=s[2*o+1];a>=t&&a<=r&&d>=e&&d<=i&&u.push(n[o])}continue}const h=l+c>>1,p=s[2*h],f=s[2*h+1];p>=t&&p<=r&&f>=e&&f<=i&&u.push(n[h]),(0===d?t<=p:e<=f)&&(zt[a++]=l,zt[a++]=h-1,zt[a++]=1-d),(0===d?r>=p:i>=f)&&(zt[a++]=h+1,zt[a++]=c,zt[a++]=1-d)}return u}within(t,e,r){const i=[];return this.withinInto(t,e,r,i),i}withinInto(t,e,r,i){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:s,nodeSize:o}=this;zt[0]=0,zt[1]=n.length-1,zt[2]=0;let a=3,u=0;const d=r*r;for(;a>0;){const c=zt[--a],l=zt[--a],h=zt[--a];if(l-h<=o){for(let r=h;r<=l;r++)Ht(s[2*r],s[2*r+1],t,e)<=d&&(i[u++]=n[r]);continue}const p=h+l>>1,f=s[2*p],T=s[2*p+1];Ht(f,T,t,e)<=d&&(i[u++]=n[p]),(0===c?t-r<=f:e-r<=T)&&(zt[a++]=h,zt[a++]=p-1,zt[a++]=1-c),(0===c?t+r>=f:e+r>=T)&&(zt[a++]=p+1,zt[a++]=l,zt[a++]=1-c)}return u}}function Gt(t,e,r,i,n,s){if(n-i<=r)return;const o=i+n>>1;Jt(t,e,o,i,n,s),Gt(t,e,r,i,o-1,1-s),Gt(t,e,r,o+1,n,1-s)}function Jt(t,e,r,i,n,s){for(;n>i;){if(n-i>600){const o=n-i+1,a=r-i+1,u=Math.log(o),d=.5*Math.exp(2*u/3),c=.5*Math.sqrt(u*d*(o-d)/o)*(a-o/2<0?-1:1);Jt(t,e,r,Math.max(i,Math.floor(r-a*d/o+c)),Math.min(n,Math.floor(r+(o-a)*d/o+c)),s)}const o=e[2*r+s];let a=i,u=n;for(Wt(t,e,i,r),e[2*n+s]>o&&Wt(t,e,i,n);a<u;){for(Wt(t,e,a,u),a++,u--;e[2*a+s]<o;)a++;for(;e[2*u+s]>o;)u--}e[2*i+s]===o?Wt(t,e,i,u):(u++,Wt(t,e,u,n)),u<=r&&(i=u+1),r<=u&&(n=u-1)}}function Wt(t,e,r,i){Zt(t,r,i),Zt(e,2*r,2*i),Zt(e,2*r+1,2*i+1)}function Zt(t,e,r){const i=t[e];t[e]=t[r],t[r]=i}function Ht(t,e,r,i){const n=t-r,s=e-i;return n*n+s*s}const Qt=t=>t[t.length-1],qt="ENTRIES",Xt="KEYS",Kt="VALUES";var te=class{set;_type;_path;constructor(t,e){let r=t._tree,i=[...r.keys()];this.set=t,this._type=e,this._path=i.length>0?[{node:r,keys:i}]:[]}next(){let t=this.dive();return this.backtrack(),t}key(){return this.set._prefix+this._path.map((({keys:t})=>Qt(t))).filter((t=>""!==t)).join("")}value(){return Qt(this._path).node.get("")}[Symbol.iterator](){return this}result(){switch(this._type){case Kt:return this.value();case Xt:return this.key();case qt:return[this.key(),this.value()];default:throw Error(`Unknown iterator type: ${this._type}`)}}dive(){if(0===this._path.length)return{done:!0,value:void 0};let{node:t,keys:e}=Qt(this._path);if(""===Qt(e))return{done:!1,value:this.result()};let r=t.get(Qt(e));return this._path.push({node:r,keys:[...r.keys()]}),this.dive()}backtrack(){if(0===this._path.length)return;let{keys:t}=Qt(this._path);t.pop(),!(t.length>0)&&(this._path.pop(),this.backtrack())}};const ee=(t,e,r,i,n,s,o,a)=>{let u=s*o;t:for(let d of t.keys())if(""===d){let e=n[u-1];e<=r&&i.set(a,[t.get(d),e])}else{let u=s;for(let t=0;t<d.length;++t,++u){let i=d[t],s=o*u,a=s-o,c=n[s],l=Math.max(0,u-r-1),h=Math.min(o-1,u+r);for(let t=l;t<h;++t){let r=i!==e[t],o=n[a+t]+Number(r),u=n[a+t+1]+1,d=n[s+t]+1,l=n[s+t+1]=Math.min(o,u,d);l<c&&(c=l)}if(c>r)continue t}ee(t.get(d),e,r,i,n,u,o,a+d)}},re=(t,e,r=[])=>{if(0===e.length||null==t)return[t,r];for(let i of t.keys())if(""!==i&&e.startsWith(i))return r.push([t,i]),re(t.get(i),e.slice(i.length),r);return r.push([t,e]),re(void 0,"",r)},ie=(t,e)=>{if(0===e.length||!t)return t;for(let r of t.keys())if(""!==r&&e.startsWith(r))return ie(t.get(r),e.slice(r.length))},ne=(t,e)=>{let r=e.length;t:for(let i=0;t&&i<r;){for(let n of t.keys())if(""!==n&&e[i]===n[0]){let s=Math.min(r-i,n.length),o=1;for(;o<s&&e[i+o]===n[o];)o+=1;let a=t.get(n);if(o===n.length)t=a;else{let r=new Map([[n.slice(o),a]]);t.set(e.slice(i,i+o),r),t.delete(n),t=r}i+=o;continue t}let n=new Map;return t.set(e.slice(i),n),n}return t},se=(t,e,r)=>{if(0===t.length)return;let[i,n]=Qt(t);i.set(n+e,r),i.delete(n)},oe=t=>{if(0===t.length)return;let[e,r]=Qt(t);if(e.delete(r),0===e.size)oe(t.slice(0,-1));else if(1===e.size){let[r,i]=e.entries().next().value;""!==r&&se(t.slice(0,-1),r,i)}};var ae=class t{_tree;_prefix;_size=void 0;constructor(t=new Map,e=""){this._tree=t,this._prefix=e}atPrefix(e){if(!e.startsWith(this._prefix))throw Error("Mismatched prefix");let[r,i]=re(this._tree,e.slice(this._prefix.length));if(void 0===r){let[r,n]=Qt(i);for(let i of r.keys())if(""!==i&&i.startsWith(n)){let s=new Map([[i.slice(n.length),r.get(i)]]);return new t(s,e)}}return new t(r,e)}clear(){this._size=void 0,this._tree.clear()}delete(t){this._size=void 0,((t,e)=>{let[r,i]=re(t,e);if(void 0!==r)if(r.delete(""),0===r.size)oe(i);else if(1===r.size){let[t,e]=r.entries().next().value;se(i,t,e)}})(this._tree,t)}entries(){return new te(this,qt)}forEach(t){for(let[e,r]of this)t(e,r,this)}fuzzyGet(t,e){return((t,e,r)=>{let i=new Map;if("string"!=typeof e)return i;let n=e.length+1,s=n+r,o=new Uint8Array(s*n).fill(r+1);for(let t=0;t<n;++t)o[t]=t;for(let t=1;t<s;++t)o[t*n]=t;return ee(t,e,r,i,o,1,n,""),i})(this._tree,t,e)}get(t){let e=ie(this._tree,t);return void 0===e?void 0:e.get("")}has(t){return ie(this._tree,t)?.has("")??!1}keys(){return new te(this,Xt)}set(t,e){if("string"!=typeof t)throw Error("key must be a string");return this._size=void 0,ne(this._tree,t).set("",e),this}get size(){if("number"==typeof this._size)return this._size;this._size=0;let t=this.entries();for(;!t.next().done;)this._size+=1;return this._size}update(t,e){if("string"!=typeof t)throw Error("key must be a string");this._size=void 0;let r=ne(this._tree,t);return r.set("",e(r.get(""))),this}fetch(t,e){if("string"!=typeof t)throw Error("key must be a string");this._size=void 0;let r=ne(this._tree,t),i=r.get("");return void 0===i&&r.set("",i=e()),i}values(){return new te(this,Kt)}[Symbol.iterator](){return this.entries()}static from(e){let r=new t;for(let[t,i]of e)r.set(t,i);return r}static fromObject(e){return t.from(Object.entries(e))}};const ue=/[\n\r\p{Z}\p{P}]+/u,de=(t,e)=>{t.includes(e)||t.push(e)},ce=(t,e)=>{for(let r of e)t.includes(r)||t.push(r)},le=({score:t},{score:e})=>e-t,he=()=>new Map,pe=(t,e)=>Object.hasOwn(t,e)?t[e]:void 0,fe={or:(t,e)=>{for(let r of e.keys()){let i=t.get(r);if(null==i)t.set(r,e.get(r));else{let{score:t,terms:n,match:s}=e.get(r);i.score+=t,i.match=Object.assign(i.match,s),ce(i.terms,n)}}return t},and:(t,e)=>{let r=new Map;for(let i of e.keys()){let n=t.get(i);if(null==n)continue;let{score:s,terms:o,match:a}=e.get(i);ce(n.terms,o),r.set(i,{score:n.score+s,terms:n.terms,match:Object.assign(n.match,a)})}return r},and_not:(t,e)=>{for(let r of e.keys())t.delete(r);return t}},Te=(t,e,r,i,n,s)=>{let{k:o,b:a,d:u}=s;return Math.log(1+(r-e+.5)/(e+.5))*(u+t*(o+1)/(t+o*(1-a+a*i/n)))},_e=(t,e,r,i)=>{for(let n of Object.keys(t._fieldIds))if(t._fieldIds[n]===r)return void t._options.logger("warn",`SlimSearch: document with ID ${t._documentIds.get(e)} has changed before removal: term "${i}" was not present in field "${n}". Removing a document after it has changed can corrupt the index!`,"version_conflict")},Ee=(t,e,r,i)=>{let n=t._index.fetch(i,he),s=n.get(e);if(null==s)s=new Map([[r,1]]),n.set(e,s);else{let t=s.get(r);s.set(r,(t??0)+1)}},me=(t,e,r,i)=>{if(!t._index.has(i))return void _e(t,r,e,i);let n=t._index.fetch(i,he),s=n.get(e),o=s?.get(r);s&&null!=o?o<=1?s.size<=1?n.delete(e):s.delete(r):s.set(r,o-1):_e(t,r,e,i),0===t._index.get(i).size&&t._index.delete(i)},Ie=(t,e,r,i,n)=>{let s=t._fieldLength.get(e);s??t._fieldLength.set(e,s=[]),s[r]=n;let o=(t._avgFieldLength[r]||0)*i+n;t._avgFieldLength[r]=o/(i+1)},ge=(t,e)=>{let{extractField:r,stringifyField:i,tokenize:n,processTerm:s,fields:o,idField:a}=t._options,u=r(e,a);if(null==u)throw Error(`SlimSearch: document does not have ID field "${a}"`);if(((t,e)=>t._idToShortId.has(e))(t,u))throw Error(`SlimSearch: duplicate ID ${u}`);let d=((t,e)=>{let r=t._nextId;return t._idToShortId.set(e,r),t._documentIds.set(r,e),t._documentCount+=1,t._nextId+=1,r})(t,u);((t,e,r)=>{let{storeFields:i,extractField:n}=t._options;if(0===i?.length)return;let s=t._storedFields.get(e);s??t._storedFields.set(e,s={});for(let t of i){let e=n(r,t);null!=e&&(s[t]=e)}})(t,d,e);for(let a of o){let o=r(e,a);if(null==o)continue;let u=n(i(o,a),a),c=t._fieldIds[a],l=new Set(u).size;Ie(t,d,c,t._documentCount-1,l);for(let e of u){let r=s(e,a);if(Array.isArray(r))for(let e of r)Ee(t,c,d,e);else r&&Ee(t,c,d,r)}}},Re={idField:"id",extractField:(t,e)=>t[e],stringifyField:t=>t.toString(),tokenize:t=>t.split(ue),processTerm:t=>t.toLowerCase(),fields:void 0,searchOptions:void 0,storeFields:[],logger:(t,e)=>{console?.[t]?.(e)},autoVacuum:!0},ve={combineWith:"or",prefix:!1,fuzzy:!1,maxFuzzy:6,boost:{},weights:{fuzzy:.45,prefix:.375},bm25:{k:1.2,b:.7,d:.5}},Ae={combineWith:"and",prefix:(t,e,r)=>e===r.length-1},ye={minDirtFactor:.1,minDirtCount:20},Oe={batchSize:1e3,batchWait:10,...ye},Se=Symbol("*"),Ne=(t,e="or")=>{if(0===t.length)return new Map;let r=e.toLowerCase();if(!(r in fe))throw Error(`Invalid combination operator: ${e}`);return t.reduce(fe[r])},be=(t,e,r,i,n,s,o,a,u,d=new Map)=>{if(null==s)return d;for(let c of Object.keys(o)){let l=o[c],h=t._fieldIds[c],p=s.get(h);if(null==p)continue;let f=p.size,T=t._avgFieldLength[h];for(let s of p.keys()){if(!t._documentIds.has(s)){me(t,h,s,r),--f;continue}let o=a?a(t._documentIds.get(s),r,t._storedFields.get(s)):1;if(!o)continue;let _=p.get(s),E=t._fieldLength.get(s)[h],m=i*n*l*o*Te(_,f,t._documentCount,E,T,u),I=d.get(s);if(I){I.score+=m,de(I.terms,e);let t=pe(I.match,r);t?t.push(c):I.match[r]=[c]}else d.set(s,{score:m,terms:[e],match:{[r]:[c]}})}}return d},we=(t,e,r={})=>{if(e===Se)return((t,e)=>{let r=new Map,i={...t._options.searchOptions,...e};for(let[e,n]of t._documentIds){let s=i.boostDocument?i.boostDocument(n,"",t._storedFields.get(e)):1;r.set(e,{score:s,terms:[],match:{}})}return r})(t,r);if("string"!=typeof e){let i={...r,...e,queries:void 0},n=e.queries.map((e=>we(t,e,i)));return Ne(n,i.combineWith)}let{tokenize:i,processTerm:n,searchOptions:s}=t._options,o={tokenize:i,processTerm:n,...s,...r},{tokenize:a,processTerm:u}=o,d=a(e).flatMap((t=>u(t))).filter(Boolean).map((t=>(e,r,i)=>({term:e,fuzzy:"function"==typeof t.fuzzy?t.fuzzy(e,r,i):t.fuzzy??!1,prefix:"function"==typeof t.prefix?t.prefix(e,r,i):!0===t.prefix,termBoost:"function"==typeof t.boostTerm?t.boostTerm(e,r,i):1}))(o)).map((e=>((t,e,r)=>{let i,n,s={...t._options.searchOptions,...r},o=(s.fields??t._options.fields).reduce(((t,e)=>(t[e]=pe(s.boost,e)||1,t)),{}),{boostDocument:a,weights:u,maxFuzzy:d,bm25:c}=s,{fuzzy:l,prefix:h}={...ve.weights,...u},p=t._index.get(e.term),f=be(t,e.term,e.term,1,e.termBoost,p,o,a,c);if(e.prefix&&(i=t._index.atPrefix(e.term)),e.fuzzy){let r=!0===e.fuzzy?.2:e.fuzzy,i=r<1?Math.min(d,Math.round(e.term.length*r)):r;i&&(n=t._index.fuzzyGet(e.term,i))}if(i)for(let[r,s]of i){let i=r.length-e.term.length;if(!i)continue;n?.delete(r);let u=h*r.length/(r.length+.3*i);be(t,e.term,r,u,e.termBoost,s,o,a,c,f)}if(n)for(let r of n.keys()){let[i,s]=n.get(r);if(!s)continue;let u=l*r.length/(r.length+s);be(t,e.term,r,u,e.termBoost,i,o,a,c,f)}return f})(t,e,o)));return Ne(d,o.combineWith)};var Pe=class{_options;_index;_documentCount;_documentIds;_idToShortId;_fieldIds;_fieldLength;_avgFieldLength;_nextId;_storedFields;_dirtCount;_currentVacuum;_enqueuedVacuum;_enqueuedVacuumConditions;constructor(t){if(!t?.fields)throw Error('SlimSearch: option "fields" must be provided');let e=null==t.autoVacuum||!0===t.autoVacuum?Oe:t.autoVacuum;this._options={...Re,...t,autoVacuum:e,searchOptions:{...ve,...t.searchOptions},autoSuggestOptions:{...Ae,...t.autoSuggestOptions}},this._index=new ae,this._documentCount=0,this._documentIds=new Map,this._idToShortId=new Map,this._fieldIds={},this._fieldLength=new Map,this._avgFieldLength=[],this._nextId=0,this._storedFields=new Map,this._dirtCount=0,this._currentVacuum=null,this._enqueuedVacuum=null,this._enqueuedVacuumConditions=ye,this.addFields(this._options.fields)}get isVacuuming(){return null!=this._currentVacuum}get dirtCount(){return this._dirtCount}get dirtFactor(){return this._dirtCount/(1+this._documentCount+this._dirtCount)}get documentCount(){return this._documentCount}get termCount(){return this._index.size}toJSON(){let t=[];for(let[e,r]of this._index){let i={};for(let[t,e]of r)i[t]=Object.fromEntries(e);t.push([e,i])}return{documentCount:this._documentCount,nextId:this._nextId,documentIds:Object.fromEntries(this._documentIds),fieldIds:this._fieldIds,fieldLength:Object.fromEntries(this._fieldLength),averageFieldLength:this._avgFieldLength,storedFields:Object.fromEntries(this._storedFields),dirtCount:this._dirtCount,index:t,version:2}}addFields(t){for(let e=0;e<t.length;e++)this._fieldIds[t[e]]=e}};const Ue=t=>{const e=t.toLowerCase(),r=new Set([e]),i={a:["à","â","ä"],c:["ç"],e:["é","è","ê","ë"],i:["î","ï"],o:["ô","ö"],u:["ù","û","ü"],ae:["ä"],oe:["ö"],ue:["ü"]};for(const[t,n]of Object.entries(i))e.includes(t)&&n.forEach((i=>{r.add(e.replace(t,i))})),n.forEach((i=>{e.includes(i)&&r.add(e.replace(i,t))}));return Array.from(r)};var xe;function Le(t){switch(t){case 0:case"LOCATION_TYPE_UNSPECIFIED":return xe.LOCATION_TYPE_UNSPECIFIED;case 1:case"LOCATION_TYPE_SIMPLE_STOP_OR_PLATFORM":return xe.LOCATION_TYPE_SIMPLE_STOP_OR_PLATFORM;case 2:case"LOCATION_TYPE_STATION":return xe.LOCATION_TYPE_STATION;case 3:case"LOCATION_TYPE_ENTRANCE_EXIT":return xe.LOCATION_TYPE_ENTRANCE_EXIT;case 4:case"LOCATION_TYPE_GENERIC_NODE":return xe.LOCATION_TYPE_GENERIC_NODE;case 5:case"LOCATION_TYPE_BOARDING_AREA":return xe.LOCATION_TYPE_BOARDING_AREA;default:return xe.UNRECOGNIZED}}!function(t){t[t.LOCATION_TYPE_UNSPECIFIED=0]="LOCATION_TYPE_UNSPECIFIED",t[t.LOCATION_TYPE_SIMPLE_STOP_OR_PLATFORM=1]="LOCATION_TYPE_SIMPLE_STOP_OR_PLATFORM",t[t.LOCATION_TYPE_STATION=2]="LOCATION_TYPE_STATION",t[t.LOCATION_TYPE_ENTRANCE_EXIT=3]="LOCATION_TYPE_ENTRANCE_EXIT",t[t.LOCATION_TYPE_GENERIC_NODE=4]="LOCATION_TYPE_GENERIC_NODE",t[t.LOCATION_TYPE_BOARDING_AREA=5]="LOCATION_TYPE_BOARDING_AREA",t[t.UNRECOGNIZED=-1]="UNRECOGNIZED"}(xe||(xe={}));const De={encode(t,e=new m){if(""!==t.name&&e.uint32(10).string(t.name),void 0!==t.sourceStopId&&e.uint32(18).string(t.sourceStopId),void 0!==t.lat&&e.uint32(29).float(t.lat),void 0!==t.lon&&e.uint32(37).float(t.lon),0!==t.children.length){e.uint32(42).fork();for(const r of t.children)e.uint32(r);e.join()}return void 0!==t.parent&&e.uint32(48).uint32(t.parent),0!==t.locationType&&e.uint32(56).int32(t.locationType),void 0!==t.platform&&e.uint32(66).string(t.platform),e},decode(t,e){var r;const i=t instanceof O?t:new O(t),n=null!==(r=i.__tsProtoDecodeDepth)&&void 0!==r?r:0;if(n>=100)throw new globalThis.Error("protobuf decode recursion limit exceeded");i.__tsProtoDecodeDepth=n+1;try{const t=void 0===e?i.len:i.pos+e,r={name:"",sourceStopId:void 0,lat:void 0,lon:void 0,children:[],parent:void 0,locationType:0,platform:void 0};for(;i.pos<t;){const t=i.uint32();switch(t>>>3){case 1:if(10!==t)break;r.name=i.string();continue;case 2:if(18!==t)break;r.sourceStopId=i.string();continue;case 3:if(29!==t)break;r.lat=i.float();continue;case 4:if(37!==t)break;r.lon=i.float();continue;case 5:if(40===t){r.children.push(i.uint32());continue}if(42===t){const t=i.uint32()+i.pos;for(;i.pos<t;)r.children.push(i.uint32());continue}break;case 6:if(48!==t)break;r.parent=i.uint32();continue;case 7:if(56!==t)break;r.locationType=i.int32();continue;case 8:if(66!==t)break;r.platform=i.string();continue}if(4==(7&t)||0===t)break;i.skip(7&t)}return r}finally{i.__tsProtoDecodeDepth=n}},fromJSON:t=>({name:Ye(t.name)?globalThis.String(t.name):"",sourceStopId:Ye(t.sourceStopId)?globalThis.String(t.sourceStopId):Ye(t.source_stop_id)?globalThis.String(t.source_stop_id):void 0,lat:Ye(t.lat)?globalThis.Number(t.lat):void 0,lon:Ye(t.lon)?globalThis.Number(t.lon):void 0,children:globalThis.Array.isArray(null==t?void 0:t.children)?t.children.map((t=>globalThis.Number(t))):[],parent:Ye(t.parent)?globalThis.Number(t.parent):void 0,locationType:Ye(t.locationType)?Le(t.locationType):Ye(t.location_type)?Le(t.location_type):0,platform:Ye(t.platform)?globalThis.String(t.platform):void 0}),toJSON(t){var e;const r={};return""!==t.name&&(r.name=t.name),void 0!==t.sourceStopId&&(r.sourceStopId=t.sourceStopId),void 0!==t.lat&&(r.lat=Me(t.lat)),void 0!==t.lon&&(r.lon=Me(t.lon)),(null===(e=t.children)||void 0===e?void 0:e.length)&&(r.children=t.children.map((t=>Math.round(t)))),void 0!==t.parent&&(r.parent=Math.round(t.parent)),0!==t.locationType&&(r.locationType=function(t){switch(t){case xe.LOCATION_TYPE_UNSPECIFIED:return"LOCATION_TYPE_UNSPECIFIED";case xe.LOCATION_TYPE_SIMPLE_STOP_OR_PLATFORM:return"LOCATION_TYPE_SIMPLE_STOP_OR_PLATFORM";case xe.LOCATION_TYPE_STATION:return"LOCATION_TYPE_STATION";case xe.LOCATION_TYPE_ENTRANCE_EXIT:return"LOCATION_TYPE_ENTRANCE_EXIT";case xe.LOCATION_TYPE_GENERIC_NODE:return"LOCATION_TYPE_GENERIC_NODE";case xe.LOCATION_TYPE_BOARDING_AREA:return"LOCATION_TYPE_BOARDING_AREA";case xe.UNRECOGNIZED:default:return"UNRECOGNIZED"}}(t.locationType)),void 0!==t.platform&&(r.platform=t.platform),r},create:t=>De.fromPartial(null!=t?t:{}),fromPartial(t){var e,r,i,n,s,o,a,u;const d={name:"",sourceStopId:void 0,lat:void 0,lon:void 0,children:[],parent:void 0,locationType:0,platform:void 0};return d.name=null!==(e=t.name)&&void 0!==e?e:"",d.sourceStopId=null!==(r=t.sourceStopId)&&void 0!==r?r:void 0,d.lat=null!==(i=t.lat)&&void 0!==i?i:void 0,d.lon=null!==(n=t.lon)&&void 0!==n?n:void 0,d.children=(null===(s=t.children)||void 0===s?void 0:s.map((t=>t)))||[],d.parent=null!==(o=t.parent)&&void 0!==o?o:void 0,d.locationType=null!==(a=t.locationType)&&void 0!==a?a:0,d.platform=null!==(u=t.platform)&&void 0!==u?u:void 0,d}};const Ce={encode(t,e=new m){for(const r of t.stops)De.encode(r,e.uint32(18).fork()).join();return e},decode(t,e){var r;const i=t instanceof O?t:new O(t),n=null!==(r=i.__tsProtoDecodeDepth)&&void 0!==r?r:0;if(n>=100)throw new globalThis.Error("protobuf decode recursion limit exceeded");i.__tsProtoDecodeDepth=n+1;try{const t=void 0===e?i.len:i.pos+e,r={stops:[]};for(;i.pos<t;){const t=i.uint32();switch(t>>>3){case 2:if(18!==t)break;r.stops.push(De.decode(i,i.uint32()));continue}if(4==(7&t)||0===t)break;i.skip(7&t)}return r}finally{i.__tsProtoDecodeDepth=n}},fromJSON:t=>({stops:globalThis.Array.isArray(null==t?void 0:t.stops)?t.stops.map((t=>De.fromJSON(t))):[]}),toJSON(t){var e;const r={};return(null===(e=t.stops)||void 0===e?void 0:e.length)&&(r.stops=t.stops.map((t=>De.toJSON(t)))),r},create:t=>Ce.fromPartial(null!=t?t:{}),fromPartial(t){var e;const r={stops:[]};return r.stops=(null===(e=t.stops)||void 0===e?void 0:e.map((t=>De.fromPartial(t))))||[],r}};function Me(t){return"number"!=typeof t||globalThis.Number.isFinite(t)?t:globalThis.String(t)}function Ye(t){return null!=t}const Fe=t=>({stops:t.map((t=>{return{name:(e=t).name,sourceStopId:e.sourceStopId,lat:e.lat,lon:e.lon,children:e.children,parent:e.parent,locationType:$e(e.locationType),platform:e.platform};var e}))}),Be=t=>t.stops.map(((t,e)=>{return{id:e,sourceStopId:(r=t).sourceStopId,name:r.name,lat:r.lat,lon:r.lon,children:r.children,parent:r.parent,locationType:ke(r.locationType),platform:r.platform};var r})),ke=t=>{switch(t){case xe.LOCATION_TYPE_SIMPLE_STOP_OR_PLATFORM:return"SIMPLE_STOP_OR_PLATFORM";case xe.LOCATION_TYPE_STATION:return"STATION";case xe.LOCATION_TYPE_ENTRANCE_EXIT:return"ENTRANCE_EXIT";case xe.LOCATION_TYPE_GENERIC_NODE:return"GENERIC_NODE";case xe.LOCATION_TYPE_BOARDING_AREA:return"BOARDING_AREA";case xe.LOCATION_TYPE_UNSPECIFIED:throw new Error("Unspecified protobuf location type.");case xe.UNRECOGNIZED:throw new Error("Unrecognized protobuf location type.")}},$e=t=>{switch(t){case"SIMPLE_STOP_OR_PLATFORM":return xe.LOCATION_TYPE_SIMPLE_STOP_OR_PLATFORM;case"STATION":return xe.LOCATION_TYPE_STATION;case"ENTRANCE_EXIT":return xe.LOCATION_TYPE_ENTRANCE_EXIT;case"GENERIC_NODE":return xe.LOCATION_TYPE_GENERIC_NODE;case"BOARDING_AREA":return xe.LOCATION_TYPE_BOARDING_AREA}};class je{constructor(t){var e;this.stops=t,this.sourceStopsMap=new Map;const r=new Map;this.stopPoints=[];for(let i=0;i<t.length;i++){const n=t[i];void 0!==n.sourceStopId&&this.sourceStopsMap.set(n.sourceStopId,i);const s=null!==(e=n.parent)&&void 0!==e?e:i;r.has(s)||r.set(s,{id:s,name:n.parent?this.stops[n.parent].name:n.name}),n.lat&&n.lon&&this.stopPoints.push({id:i,lat:n.lat,lon:n.lon})}this.textIndex=(t=>new Pe(t))({fields:["name"],storeFields:["id"],searchOptions:{prefix:!0,fuzzy:.2},processTerm:Ue});const i=Array.from(r.values());((t,e)=>{for(let r of e)ge(t,r)})(this.textIndex,i),this.geoIndex=new Vt(this.stopPoints.length);for(let t=0;t<this.stopPoints.length;t++){const{lat:e,lon:r}=this.stopPoints[t];this.geoIndex.add(r,e)}this.geoIndex.finish()}static fromData(t){const e=new O(t),r=Ce.decode(e);return new je(Be(r))}serialize(){const t=Fe(this.stops),e=new m;return Ce.encode(t,e),e.finish()}size(){return this.stops.length}findStopsByName(t,e=5){const r=((t,e,r={})=>{let{searchOptions:i}=t._options,n={...i,...r},s=we(t,e,r),o=[];for(let[e,{score:r,terms:i,match:a}]of s){let s=i.length||1,u={id:t._documentIds.get(e),score:r*s,terms:Object.keys(a),queryTerms:i,match:a,...t._storedFields.get(e)};(null==n.filter||n.filter(u))&&o.push(u)}return e===Se&&null==n.boostDocument||o.sort(le),o})(this.textIndex,t).map((t=>this.stops[t.id]));return r.slice(0,e)}findStopsByLocation(t,e,r=5,i=.5){const n=function(t,e,r,i=1/0,n=1/0){let s=1;const o=[];void 0===i&&(i=1/0),void 0!==n&&(s=Bt(n/6371));const a=new Ct([],Ft);let u={left:0,right:t.ids.length-1,axis:0,minLng:-180,minLat:-90,maxLng:180,maxLat:90};const d=Math.cos(r*Mt);for(;u;){const n=u.right,c=u.left;if(n-c<=t.nodeSize)for(let i=c;i<=n;i++){const n=t.ids[i];{const s=$t(e,r,t.coords[2*i],t.coords[2*i+1],d);a.push({id:n,dist:s})}}else{const i=c+n>>1,s=t.coords[2*i],o=t.coords[2*i+1],l=t.ids[i];{const t=$t(e,r,s,o,d);a.push({id:l,dist:t})}const h=(u.axis+1)%2,p={left:c,right:i-1,axis:h,minLng:u.minLng,minLat:u.minLat,maxLng:0===u.axis?s:u.maxLng,maxLat:1===u.axis?o:u.maxLat,dist:0},f={left:i+1,right:n,axis:h,minLng:0===u.axis?s:u.minLng,minLat:1===u.axis?o:u.minLat,maxLng:u.maxLng,maxLat:u.maxLat,dist:0};p.dist=Yt(e,r,d,p),f.dist=Yt(e,r,d,f),a.push(p),a.push(f)}let l;for(;(l=a.pop())&&"id"in l;){if(l.dist>s)return o;if(o.push(l.id),o.length===i)return o}u=l}return o}(this.geoIndex,e,t,r,i).map((t=>{const e=this.stopPoints[t];return this.stops[e.id]}));return n}findStopById(t){return this.stops[t]}findStopBySourceStopId(t){const e=this.sourceStopsMap.get(t);if(void 0!==e)return this.findStopById(e)}equivalentStops(t){var e,r;const i=this.stops[t];if(!i)return[];const n=i.parent?null!==(r=null===(e=this.stops[i.parent])||void 0===e?void 0:e.children)&&void 0!==r?r:[]:i.children;return Array.from(new Set([t,...n])).map((t=>this.stops[t]))}*[Symbol.iterator](){for(const t of this.stops)yield t}}exports.PickUpDropOffTypes=z,exports.Plotter=class{constructor(t){this.result=t}stationNodeId(t){return`s_${t}`}vehicleEdgeNodeId(t,e,r,i){return`e_${t}_${e}_${r}_${i}`}transferEdgeNodeId(t,e,r){return`e_${t}_${e}_${r}`}accessEdgeNodeId(t,e){return`access_${t}_${e}`}continuationNodeId(t,e,r){return`continuation_${t}_${e}_${r}`}getRoundColor(t){var e;if(0===t)return mt.colors.defaultRound;const r=Math.min(t-1,mt.colors.rounds.length-1);return null!==(e=mt.colors.rounds[r])&&void 0!==e?e:"#ee82ee"}getStationFillColor(t,e){return t?mt.colors.originStation:e?mt.colors.destinationStation:mt.colors.defaultStation}escapeDotString(t){return t.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}formatStopName(t){const e=this.result.stopsIndex.findStopById(t);if(!e)return`Unknown Stop (${t})`;const r=this.escapeDotString(e.name),i=e.platform?this.escapeDotString(e.platform):"";return i?`${r}\\nPl. ${i}`:r}getStationInfo(t){var e;return{isOrigin:void 0!==(null===(e=this.result.routingState.graph[0])||void 0===e?void 0:e[t]),isDestination:this.result.routingState.destinations.includes(t)}}getVehicleEdgeFromStopId(t){const e=this.result.timetable.getRoute(t.routeId);return null==e?void 0:e.stopId(t.stopIndex)}getVehicleEdgeToStopId(t){const e=this.result.timetable.getRoute(t.routeId);return null==e?void 0:e.stopId(t.hopOffStopIndex)}createStationNode(t){if(!this.result.stopsIndex.findStopById(t))return null;const e=this.formatStopName(t),r=this.escapeDotString(String(t)),i=this.stationNodeId(t),n=this.getStationInfo(t);return` "${i}" [label="${e}\\n${r}" shape=box style=filled fillcolor="${this.getStationFillColor(n.isOrigin,n.isDestination)}"];`}createVehicleEdge(e,r){const i=this.result.timetable.getRoute(e.routeId);if(!i)return[];const n=i.stopId(e.stopIndex),s=i.stopId(e.hopOffStopIndex),o=this.stationNodeId(n),a=this.stationNodeId(s),u=this.getRoundColor(r),d=this.vehicleEdgeNodeId(n,s,e.routeId,r),c=this.result.timetable.getServiceRouteInfo(i),l=c.name,h=_t(c.type),p=t(i.departureFrom(e.stopIndex,e.tripIndex)),f=t(e.arrival),T=this.escapeDotString(l);return[` "${d}" [label="${`${this.escapeDotString(h)} ${T}\\n${`${e.routeId}:${e.tripIndex}`}\\n${p} → ${f}`}" shape=oval style=filled fillcolor="white" color="${u}"];`,` "${o}" -> "${d}" [color="${u}"];`,` "${d}" -> "${a}" [color="${u}"];`]}createAccessEdge(t){const r=this.stationNodeId(t.from),i=this.stationNodeId(t.to),n=mt.colors.defaultRound,s=this.accessEdgeNodeId(t.from,t.to);return[` "${s}" [label="${`Walk\\n${e(t.duration)}`}" shape=oval style="dashed,filled" fillcolor="white" color="${n}"];`,` "${r}" -> "${s}" [color="${n}" style="dashed"];`,` "${s}" -> "${i}" [color="${n}" style="dashed"];`]}createTransferEdge(t,r){const i=this.stationNodeId(t.from),n=this.stationNodeId(t.to),s=this.getRoundColor(r),o=this.transferEdgeNodeId(t.from,t.to,r),a=void 0!==t.minTransferTime?e(t.minTransferTime):"N/A";return[` "${o}" [label="${`Transfer\\n${this.escapeDotString(a)}`}" shape=oval style="dashed,filled" fillcolor="white" color="${s}"];`,` "${i}" -> "${o}" [color="${s}" style="dashed"];`,` "${o}" -> "${n}" [color="${s}" style="dashed"];`]}createContinuationEdge(e,r,i){var n,s;const o=this.getVehicleEdgeToStopId(e),a=this.getVehicleEdgeFromStopId(r);if(!o||!a)return[];const u=this.stationNodeId(o),d=this.stationNodeId(a),c=this.getRoundColor(i),l=this.continuationNodeId(o,a,i),h=this.result.timetable.getRoute(e.routeId),p=this.result.timetable.getRoute(r.routeId),f=h?this.result.timetable.getServiceRouteInfo(h):null,T=p?this.result.timetable.getServiceRouteInfo(p):null,_=null!==(n=null==f?void 0:f.name)&&void 0!==n?n:`Route ${String(e.routeId)}`,E=null!==(s=null==T?void 0:T.name)&&void 0!==s?s:`Route ${String(r.routeId)}`,m=f?_t(f.type):"UNKNOWN",I=T?_t(T.type):"UNKNOWN",g=t(e.arrival),R=p?t(p.departureFrom(r.stopIndex,r.tripIndex)):"N/A",v=this.escapeDotString(_),A=this.escapeDotString(E),y=this.escapeDotString(m),O=this.escapeDotString(I),S=`${y} ${v} (${`${e.routeId}:${e.tripIndex}`}) ${g}\\n↓\\n${O} ${A} (${`${r.routeId}:${r.tripIndex}`}) ${R}`,{continuationFill:N}=mt.colors,{continuation:b,continuationEdge:w}=mt.penWidth;return[` "${l}" [label="${S}" shape=oval style="filled,bold" fillcolor="${N}" color="${c}" penwidth="${b}"];`,` "${u}" -> "${l}" [color="${c}" style="bold" penwidth="${w}"];`,` "${l}" -> "${d}" [color="${c}" style="bold" penwidth="${w}"];`]}collectStations(){const t=new Set,e=this.result.routingState.graph;for(const r of e)for(let e=0;e<r.length;e++){const i=r[e];if(void 0!==i)if(t.add(e),It(i)){const e=this.getVehicleEdgeFromStopId(i),r=this.getVehicleEdgeToStopId(i);e&&t.add(e),r&&t.add(r)}else Rt(i)&&(t.add(i.from),t.add(i.to))}return t}collectContinuationChain(t,e){const r=[];let i=t,n=t.continuationOf;for(;n;){const t=this.createContinuationEdge(n,i,e);r.push(...t),i=n,n=n.continuationOf}return r}collectEdges(){const t=[],e=[],r=this.result.routingState.graph;for(let i=0;i<r.length;i++){const n=r[i];if(n)for(let r=0;r<n.length;r++){const s=n[r];void 0!==s&&(0!==i?It(s)?(t.push(...this.createVehicleEdge(s,i)),s.continuationOf&&e.push(...this.collectContinuationChain(s,i))):gt(s)&&t.push(...this.createTransferEdge(s,i)):Rt(s)&&t.push(...this.createAccessEdge(s)))}}return[...t,...e]}plotDotGraph(){const t=this.collectStations(),e=this.collectEdges(),r=new vt;r.addHeader(),r.addComment("Stations");for(const e of t){const t=this.createStationNode(e);t&&r.addRaw([t])}return r.addComment("Edges"),r.addRaw(e),r.build()}},exports.Query=At,exports.RangeQuery=yt,exports.RangeResult=Ut,exports.Result=St,exports.Route=Ot,exports.RouteTypes=ht,exports.Router=class{constructor(t,e){const r=new Dt(t),i=new Nt(t,e);this.plainRouter=new Pt(t,e,i,r),this.rangeRouter=new Lt(t,e,i,r)}route(t){return this.plainRouter.route(t)}rangeRoute(t){return this.rangeRouter.rangeRoute(t)}},exports.StopsIndex=je,exports.Timetable=Tt,exports.TransferTypes=lt,exports.pickUpDropOffTypeToString=t=>{switch(t){case z.REGULAR:return"REGULAR";case z.NOT_AVAILABLE:return"NOT_AVAILABLE";case z.MUST_PHONE_AGENCY:return"MUST_PHONE_AGENCY";case z.MUST_COORDINATE_WITH_DRIVER:return"MUST_COORDINATE_WITH_DRIVER"}},exports.routeTypeToString=_t,exports.transferTypeToString=Et;
1
+ "use strict";const t=t=>{let e=Math.floor(t/60);const r=Math.floor(t%60);return e>=24&&(e%=24),`${e.toString().padStart(2,"0")}:${r.toString().padStart(2,"0")}`},e=t=>{const e=Math.floor(t/60),r=t%60;return e>0?`${e.toString().padStart(2,"0")}:${r.toString().padStart(2,"0")}`:`${r}min`};function r(){const t=this.buf;let e=this.pos,r=0,i=0;for(let n=0;n<28;n+=7){const s=t[e++];if(r|=(127&s)<<n,!(128&s))return this.pos=e,this.assertBounds(),this.varint64Lo=r,void(this.varint64Hi=i)}const n=t[e++];if(r|=(15&n)<<28,i=(112&n)>>4,!(128&n))return this.pos=e,this.assertBounds(),this.varint64Lo=r,void(this.varint64Hi=i);for(let n=3;n<=31;n+=7){const s=t[e++];if(i|=(127&s)<<n,!(128&s))return this.pos=e,this.assertBounds(),this.varint64Lo=r,void(this.varint64Hi=i)}throw new Error("invalid varint")}const i=4294967296;function n(t){const e="-"===t[0];e&&(t=t.slice(1));const r=1e6;let n=0,s=0;function u(e,o){const a=Number(t.slice(e,o));s*=r,n=n*r+a,n>=i&&(s+=n/i|0,n%=i)}return u(-24,-18),u(-18,-12),u(-12,-6),u(-6),e?a(n,s):o(n,s)}function s(t,e){if(({lo:t,hi:e}=function(t,e){return{lo:t>>>0,hi:e>>>0}}(t,e)),e<=2097151)return String(i*e+t);const r=16777215&(t>>>24|e<<8),n=e>>16&65535;let s=(16777215&t)+6777216*r+6710656*n,o=r+8147497*n,a=2*n;const d=1e7;return s>=d&&(o+=Math.floor(s/d),s%=d),o>=d&&(a+=Math.floor(o/d),o%=d),a.toString()+u(o)+u(s)}function o(t,e){return{lo:0|t,hi:0|e}}function a(t,e){return e=~e,t?t=1+~t:e+=1,o(t,e)}const u=t=>{const e=String(t);return"0000000".slice(e.length)+e};function d(){let t=this.buf[this.pos++];if(!(128&t))return this.assertBounds(),t;let e=127&t;if(t=this.buf[this.pos++],e|=(127&t)<<7,!(128&t))return this.assertBounds(),e;if(t=this.buf[this.pos++],e|=(127&t)<<14,!(128&t))return this.assertBounds(),e;if(t=this.buf[this.pos++],e|=(127&t)<<21,!(128&t))return this.assertBounds(),e;t=this.buf[this.pos++],e|=(15&t)<<28;for(let e=5;128&t&&e<10;e++)t=this.buf[this.pos++];if(128&t)throw new Error("invalid varint");return this.assertBounds(),e>>>0}const c=l();function l(){const t=new DataView(new ArrayBuffer(8));if(!("function"!=typeof BigInt||"function"!=typeof t.getBigInt64||"function"!=typeof t.getBigUint64||"function"!=typeof t.setBigInt64||"function"!=typeof t.setBigUint64||!globalThis.Deno&&!globalThis.Bun&&"object"==typeof process&&"object"==typeof process.env&&"1"===process.env.BUF_BIGINT_DISABLE)){const e=BigInt("-9223372036854775808"),r=BigInt("9223372036854775807"),i=BigInt("0"),n=BigInt("18446744073709551615");return{zero:BigInt(0),supported:!0,parse(t){const i="bigint"==typeof t?t:BigInt(t);if(i>r||i<e)throw new Error(`invalid int64: ${t}`);return i},uParse(t){const e="bigint"==typeof t?t:BigInt(t);if(e>n||e<i)throw new Error(`invalid uint64: ${t}`);return e},enc(e){return t.setBigInt64(0,this.parse(e),!0),{lo:t.getInt32(0,!0),hi:t.getInt32(4,!0)}},uEnc(e){return t.setBigInt64(0,this.uParse(e),!0),{lo:t.getInt32(0,!0),hi:t.getInt32(4,!0)}},dec:(e,r)=>(t.setInt32(0,e,!0),t.setInt32(4,r,!0),t.getBigInt64(0,!0)),uDec:(e,r)=>(t.setInt32(0,e,!0),t.setInt32(4,r,!0),t.getBigUint64(0,!0))}}return{zero:"0",supported:!1,parse:t=>("string"!=typeof t&&(t=t.toString()),h(t),t),uParse:t=>("string"!=typeof t&&(t=t.toString()),p(t),t),enc:t=>("string"!=typeof t&&(t=t.toString()),h(t),n(t)),uEnc:t=>("string"!=typeof t&&(t=t.toString()),p(t),n(t)),dec:(t,e)=>function(t,e){let r=o(t,e);const i=2147483648&r.hi;i&&(r=a(r.lo,r.hi));const n=s(r.lo,r.hi);return i?"-"+n:n}(t,e),uDec:(t,e)=>s(t,e)}}function h(t){if(!/^-?[0-9]+$/.test(t))throw new Error("invalid int64: "+t)}function p(t){if(!/^[0-9]+$/.test(t))throw new Error("invalid uint64: "+t)}let f;function T(){if(!f){const r=globalThis;if(!r.TextEncoder||!r.TextDecoder)throw new Error("encoding API missing: install TextEncoder and TextDecoder on globalThis");const i=new r.TextEncoder,n=new r.TextDecoder;let s;const o={encodeUtf8:t=>i.encode(t),decodeUtf8:(t,e)=>e?(s||(s=new r.TextDecoder("utf-8",{fatal:!0})),s.decode(t)):n.decode(t),checkUtf8(t){try{return encodeURIComponent(t),!0}catch(t){return!1}}};i.encodeInto&&(o.encodeUtf8Into=i.encodeInto.bind(i));const a=String.prototype.isWellFormed;a&&(o.checkUtf8=t=>a.call(t)),t=o,f=Object.assign(Object.assign({},t),{encodeUtf8Into:null!==(e=t.encodeUtf8Into)&&void 0!==e?e:_(t.encodeUtf8.bind(t))})}var t,e;return f}function _(t){return(e,r)=>{const i=t(e);return r.set(i),{written:i.byteLength}}}var E;!function(t){t[t.Varint=0]="Varint",t[t.Bit64=1]="Bit64",t[t.LengthDelimited=2]="LengthDelimited",t[t.StartGroup=3]="StartGroup",t[t.EndGroup=4]="EndGroup",t[t.Bit32=5]="Bit32"}(E||(E={}));class m{constructor(t){this.stackPos=[],this.encodeUtf8Into=t?_(t):T().encodeUtf8Into,this.buffer=R,this.viewCache=v,this.pos=0}ensureCapacity(t){const e=this.pos+t;if(e>this.buffer.length){let t=this.buffer.length||I;for(;t<e;)t*=2;const r=new Uint8Array(t);this.pos>0&&r.set(this.buffer),this.buffer=r}}view(){const t=this.buffer,e=this.viewCache;if(e.byteLength===t.byteLength)return e;const r=new DataView(t.buffer);return this.viewCache=r,r}finish(){const t=this.buffer.slice(0,this.pos);return this.pos=0,this.stackPos=[],t}fork(){return this.stackPos.push(this.pos),this.ensureCapacity(g),this.buffer[this.pos++]=0,this}join(){const t=this.stackPos.pop();if(void 0===t)throw new Error("invalid state, fork stack empty");const e=this.pos-t-g,r=y(e);return r>g&&(this.ensureCapacity(r-g),this.buffer.copyWithin(t+r,t+g,this.pos)),this.pos=t,this.uint32(e),this.pos+=e,this}tag(t,e){return this.uint32((t<<3|e)>>>0)}raw(t){return this.ensureCapacity(t.length),this.buffer.set(t,this.pos),this.pos+=t.length,this}uint32(t){if(N(t),this.ensureCapacity(5),t<128)return this.buffer[this.pos++]=t,this;for(;t>127;)this.buffer[this.pos++]=127&t|128,t>>>=7;return this.buffer[this.pos++]=t,this}int32(t){if(O(t),t>=0)return this.uint32(t);this.ensureCapacity(10);for(let e=0;e<9;e++)this.buffer[this.pos++]=127&t|128,t>>=7;return this.buffer[this.pos++]=1,this}bool(t){return this.ensureCapacity(1),this.buffer[this.pos++]=t?1:0,this}bytes(t){return this.uint32(t.byteLength),this.raw(t)}string(t){"string"!=typeof t&&(t=String(t));const e=t.length;if(e<=A){this.ensureCapacity(e+1);const r=this.buffer;let i=this.pos;r[i++]=e;let n=0;for(;n<e;n++){const e=t.charCodeAt(n);if(e>127)break;r[i++]=e}if(n==e)return this.pos=i,this}this.ensureCapacity(3*e+5);const r=y(e),i=this.buffer,n=this.pos,{written:s}=this.encodeUtf8Into(t,i.subarray(n+r)),o=y(s);return o!=r&&i.copyWithin(n+o,n+r,n+r+s),this.uint32(s),this.pos+=s,this}float(t){return function(t){if("string"==typeof t){const e=t;if(t=Number(t),Number.isNaN(t)&&"NaN"!==e)throw new Error("invalid float32: "+e)}else if("number"!=typeof t)throw new Error("invalid float32: "+typeof t);if(!Number.isFinite(Math.fround(t))&&Number.isFinite(t))throw new Error("invalid float32: "+t)}(t),this.ensureCapacity(4),this.view().setFloat32(this.pos,t,!0),this.pos+=4,this}double(t){return this.ensureCapacity(8),this.view().setFloat64(this.pos,t,!0),this.pos+=8,this}fixed32(t){return N(t),this.ensureCapacity(4),this.view().setUint32(this.pos,t,!0),this.pos+=4,this}sfixed32(t){return O(t),this.ensureCapacity(4),this.view().setInt32(this.pos,t,!0),this.pos+=4,this}sint32(t){return O(t),this.uint32((t<<1^t>>31)>>>0)}sfixed64(t){const e=c.enc(t);this.ensureCapacity(8);const r=this.view();return r.setInt32(this.pos,e.lo,!0),r.setInt32(this.pos+4,e.hi,!0),this.pos+=8,this}fixed64(t){const e=c.uEnc(t);this.ensureCapacity(8);const r=this.view();return r.setInt32(this.pos,e.lo,!0),r.setInt32(this.pos+4,e.hi,!0),this.pos+=8,this}int64(t){const e=c.enc(t);return this.writeVarint64(e.lo,e.hi)}sint64(t){const e=c.enc(t),r=e.hi>>31,i=e.lo<<1^r,n=(e.hi<<1|e.lo>>>31)^r;return this.writeVarint64(i,n)}uint64(t){const e=c.uEnc(t);return this.writeVarint64(e.lo,e.hi)}writeVarint64(t,e){this.ensureCapacity(10);const r=this.buffer;let i=this.pos;for(let n=0;n<28;n+=7){const s=t>>>n,o=!(s>>>7==0&&0==e);if(r[i++]=255&(o?128|s:s),!o)return this.pos=i,this}const n=t>>>28&15|(7&e)<<4,s=!!(e>>3);if(r[i++]=255&(s?128|n:n),!s)return this.pos=i,this;for(let t=3;t<31;t+=7){const n=e>>>t,s=!(n>>>7==0);if(r[i++]=255&(s?128|n:n),!s)return this.pos=i,this}return r[i++]=e>>>31&1,this.pos=i,this}}const I=128,g=1,R=new Uint8Array(0),v=new DataView(R.buffer),A=32;function y(t){return t<128?1:t<16384?2:t<2097152?3:t<268435456?4:5}class S{constructor(t,e=T().decodeUtf8){this.decodeUtf8=e,this.varint64Lo=0,this.varint64Hi=0,this.varint64=r,this.uint32=d,this.buf=t,this.len=t.length,this.pos=0,this.view=new DataView(t.buffer,t.byteOffset,t.byteLength)}tag(){const t=this.pos,e=this.uint32(),r=this.pos-t;if(r>5||5==r&&this.buf[this.pos-1]>15)throw new Error("illegal tag: varint overflows uint32");const i=e>>>3,n=7&e;if(i<=0||n>5)throw new Error("illegal tag: field no "+i+" wire type "+n);return[i,n]}skip(t,e,r=100){let i=this.pos;switch(t){case E.Varint:for(;128&this.buf[this.pos++];);break;case E.Bit64:this.pos+=4;case E.Bit32:this.pos+=4;break;case E.LengthDelimited:let i=this.uint32();this.pos+=i;break;case E.StartGroup:if(r<=0)throw new Error("maximum recursion depth reached");for(;;){const[t,i]=this.tag();if(i===E.EndGroup){if(void 0!==e&&t!==e)throw new Error("invalid end group tag");break}this.skip(i,t,r-1)}break;default:throw new Error("cant skip wire type "+t)}return this.assertBounds(),this.buf.subarray(i,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return 0|this.uint32()}sint32(){let t=this.uint32();return t>>>1^-(1&t)}int64(){return this.varint64(),c.dec(this.varint64Lo,this.varint64Hi)}uint64(){return this.varint64(),c.uDec(this.varint64Lo,this.varint64Hi)}sint64(){this.varint64();let t=this.varint64Lo,e=this.varint64Hi,r=-(1&t);return t=(t>>>1|(1&e)<<31)^r,e=e>>>1^r,c.dec(t,e)}bool(){const t=this.buf[this.pos];return t<128?(this.pos++,0!==t):(this.varint64(),0!==this.varint64Lo||0!==this.varint64Hi)}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return c.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return c.dec(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let t=this.uint32(),e=this.pos;return this.pos+=t,this.assertBounds(),this.buf.subarray(e,e+t)}string(t){const e=this.bytes(),r=e.length;if(r<=A){const i=new Array(r);for(let n=0;n<r;n++){const r=e[n];if(r>127)return this.decodeUtf8(e,t);i[n]=r}return String.fromCharCode.apply(String,i)}return this.decodeUtf8(e,t)}}function O(t){if("string"==typeof t)t=Number(t);else if("number"!=typeof t)throw new Error("invalid int32: "+typeof t);if(!Number.isInteger(t)||t>2147483647||t<-2147483648)throw new Error("invalid int32: "+t)}function N(t){if("string"==typeof t)t=Number(t);else if("number"!=typeof t)throw new Error("invalid uint32: "+typeof t);if(!Number.isInteger(t)||t>4294967295||t<0)throw new Error("invalid uint32: "+t)}var b,w;function U(t){switch(t){case 0:case"TRANSFER_TYPE_UNSPECIFIED":return b.TRANSFER_TYPE_UNSPECIFIED;case 1:case"TRANSFER_TYPE_RECOMMENDED_TRANSFER_POINT":return b.TRANSFER_TYPE_RECOMMENDED_TRANSFER_POINT;case 2:case"TRANSFER_TYPE_TIMED_TRANSFER":return b.TRANSFER_TYPE_TIMED_TRANSFER;case 3:case"TRANSFER_TYPE_REQUIRES_MINIMAL_TIME":return b.TRANSFER_TYPE_REQUIRES_MINIMAL_TIME;case 4:case"TRANSFER_TYPE_IN_SEAT_TRANSFER":return b.TRANSFER_TYPE_IN_SEAT_TRANSFER;default:return b.UNRECOGNIZED}}function P(t){switch(t){case 0:case"ROUTE_TYPE_UNSPECIFIED":return w.ROUTE_TYPE_UNSPECIFIED;case 1:case"ROUTE_TYPE_TRAM":return w.ROUTE_TYPE_TRAM;case 2:case"ROUTE_TYPE_SUBWAY":return w.ROUTE_TYPE_SUBWAY;case 3:case"ROUTE_TYPE_RAIL":return w.ROUTE_TYPE_RAIL;case 4:case"ROUTE_TYPE_BUS":return w.ROUTE_TYPE_BUS;case 5:case"ROUTE_TYPE_FERRY":return w.ROUTE_TYPE_FERRY;case 6:case"ROUTE_TYPE_CABLE_TRAM":return w.ROUTE_TYPE_CABLE_TRAM;case 7:case"ROUTE_TYPE_AERIAL_LIFT":return w.ROUTE_TYPE_AERIAL_LIFT;case 8:case"ROUTE_TYPE_FUNICULAR":return w.ROUTE_TYPE_FUNICULAR;case 9:case"ROUTE_TYPE_TROLLEYBUS":return w.ROUTE_TYPE_TROLLEYBUS;case 10:case"ROUTE_TYPE_MONORAIL":return w.ROUTE_TYPE_MONORAIL;default:return w.UNRECOGNIZED}}function x(){return{stopTimes:new Uint8Array(0),pickupDropOffTypes:new Uint8Array(0),stops:new Uint8Array(0),serviceRouteId:0}}!function(t){t[t.TRANSFER_TYPE_UNSPECIFIED=0]="TRANSFER_TYPE_UNSPECIFIED",t[t.TRANSFER_TYPE_RECOMMENDED_TRANSFER_POINT=1]="TRANSFER_TYPE_RECOMMENDED_TRANSFER_POINT",t[t.TRANSFER_TYPE_TIMED_TRANSFER=2]="TRANSFER_TYPE_TIMED_TRANSFER",t[t.TRANSFER_TYPE_REQUIRES_MINIMAL_TIME=3]="TRANSFER_TYPE_REQUIRES_MINIMAL_TIME",t[t.TRANSFER_TYPE_IN_SEAT_TRANSFER=4]="TRANSFER_TYPE_IN_SEAT_TRANSFER",t[t.UNRECOGNIZED=-1]="UNRECOGNIZED"}(b||(b={})),function(t){t[t.ROUTE_TYPE_UNSPECIFIED=0]="ROUTE_TYPE_UNSPECIFIED",t[t.ROUTE_TYPE_TRAM=1]="ROUTE_TYPE_TRAM",t[t.ROUTE_TYPE_SUBWAY=2]="ROUTE_TYPE_SUBWAY",t[t.ROUTE_TYPE_RAIL=3]="ROUTE_TYPE_RAIL",t[t.ROUTE_TYPE_BUS=4]="ROUTE_TYPE_BUS",t[t.ROUTE_TYPE_FERRY=5]="ROUTE_TYPE_FERRY",t[t.ROUTE_TYPE_CABLE_TRAM=6]="ROUTE_TYPE_CABLE_TRAM",t[t.ROUTE_TYPE_AERIAL_LIFT=7]="ROUTE_TYPE_AERIAL_LIFT",t[t.ROUTE_TYPE_FUNICULAR=8]="ROUTE_TYPE_FUNICULAR",t[t.ROUTE_TYPE_TROLLEYBUS=9]="ROUTE_TYPE_TROLLEYBUS",t[t.ROUTE_TYPE_MONORAIL=10]="ROUTE_TYPE_MONORAIL",t[t.UNRECOGNIZED=-1]="UNRECOGNIZED"}(w||(w={}));const L={encode:(t,e=new m)=>(0!==t.stopTimes.length&&e.uint32(10).bytes(t.stopTimes),0!==t.pickupDropOffTypes.length&&e.uint32(18).bytes(t.pickupDropOffTypes),0!==t.stops.length&&e.uint32(26).bytes(t.stops),0!==t.serviceRouteId&&e.uint32(32).uint32(t.serviceRouteId),e),decode(t,e){var r;const i=t instanceof S?t:new S(t),n=null!==(r=i.__tsProtoDecodeDepth)&&void 0!==r?r:0;if(n>=100)throw new globalThis.Error("protobuf decode recursion limit exceeded");i.__tsProtoDecodeDepth=n+1;try{const t=void 0===e?i.len:i.pos+e,r=x();for(;i.pos<t;){const t=i.uint32();switch(t>>>3){case 1:if(10!==t)break;r.stopTimes=i.bytes();continue;case 2:if(18!==t)break;r.pickupDropOffTypes=i.bytes();continue;case 3:if(26!==t)break;r.stops=i.bytes();continue;case 4:if(32!==t)break;r.serviceRouteId=i.uint32();continue}if(4==(7&t)||0===t)break;i.skip(7&t)}return r}finally{i.__tsProtoDecodeDepth=n}},fromJSON:t=>({stopTimes:j(t.stopTimes)?k(t.stopTimes):j(t.stop_times)?k(t.stop_times):new Uint8Array(0),pickupDropOffTypes:j(t.pickupDropOffTypes)?k(t.pickupDropOffTypes):j(t.pickup_drop_off_types)?k(t.pickup_drop_off_types):new Uint8Array(0),stops:j(t.stops)?k(t.stops):new Uint8Array(0),serviceRouteId:j(t.serviceRouteId)?globalThis.Number(t.serviceRouteId):j(t.service_route_id)?globalThis.Number(t.service_route_id):0}),toJSON(t){const e={};return 0!==t.stopTimes.length&&(e.stopTimes=$(t.stopTimes)),0!==t.pickupDropOffTypes.length&&(e.pickupDropOffTypes=$(t.pickupDropOffTypes)),0!==t.stops.length&&(e.stops=$(t.stops)),0!==t.serviceRouteId&&(e.serviceRouteId=Math.round(t.serviceRouteId)),e},create:t=>L.fromPartial(null!=t?t:{}),fromPartial(t){var e,r,i,n;const s=x();return s.stopTimes=null!==(e=t.stopTimes)&&void 0!==e?e:new Uint8Array(0),s.pickupDropOffTypes=null!==(r=t.pickupDropOffTypes)&&void 0!==r?r:new Uint8Array(0),s.stops=null!==(i=t.stops)&&void 0!==i?i:new Uint8Array(0),s.serviceRouteId=null!==(n=t.serviceRouteId)&&void 0!==n?n:0,s}};const D={encode:(t,e=new m)=>(0!==t.destination&&e.uint32(8).uint32(t.destination),0!==t.type&&e.uint32(16).int32(t.type),void 0!==t.minTransferTime&&e.uint32(24).uint32(t.minTransferTime),e),decode(t,e){var r;const i=t instanceof S?t:new S(t),n=null!==(r=i.__tsProtoDecodeDepth)&&void 0!==r?r:0;if(n>=100)throw new globalThis.Error("protobuf decode recursion limit exceeded");i.__tsProtoDecodeDepth=n+1;try{const t=void 0===e?i.len:i.pos+e,r={destination:0,type:0,minTransferTime:void 0};for(;i.pos<t;){const t=i.uint32();switch(t>>>3){case 1:if(8!==t)break;r.destination=i.uint32();continue;case 2:if(16!==t)break;r.type=i.int32();continue;case 3:if(24!==t)break;r.minTransferTime=i.uint32();continue}if(4==(7&t)||0===t)break;i.skip(7&t)}return r}finally{i.__tsProtoDecodeDepth=n}},fromJSON:t=>({destination:j(t.destination)?globalThis.Number(t.destination):0,type:j(t.type)?U(t.type):0,minTransferTime:j(t.minTransferTime)?globalThis.Number(t.minTransferTime):j(t.min_transfer_time)?globalThis.Number(t.min_transfer_time):void 0}),toJSON(t){const e={};return 0!==t.destination&&(e.destination=Math.round(t.destination)),0!==t.type&&(e.type=function(t){switch(t){case b.TRANSFER_TYPE_UNSPECIFIED:return"TRANSFER_TYPE_UNSPECIFIED";case b.TRANSFER_TYPE_RECOMMENDED_TRANSFER_POINT:return"TRANSFER_TYPE_RECOMMENDED_TRANSFER_POINT";case b.TRANSFER_TYPE_TIMED_TRANSFER:return"TRANSFER_TYPE_TIMED_TRANSFER";case b.TRANSFER_TYPE_REQUIRES_MINIMAL_TIME:return"TRANSFER_TYPE_REQUIRES_MINIMAL_TIME";case b.TRANSFER_TYPE_IN_SEAT_TRANSFER:return"TRANSFER_TYPE_IN_SEAT_TRANSFER";case b.UNRECOGNIZED:default:return"UNRECOGNIZED"}}(t.type)),void 0!==t.minTransferTime&&(e.minTransferTime=Math.round(t.minTransferTime)),e},create:t=>D.fromPartial(null!=t?t:{}),fromPartial(t){var e,r,i;const n={destination:0,type:0,minTransferTime:void 0};return n.destination=null!==(e=t.destination)&&void 0!==e?e:0,n.type=null!==(r=t.type)&&void 0!==r?r:0,n.minTransferTime=null!==(i=t.minTransferTime)&&void 0!==i?i:void 0,n}};const C={encode:(t,e=new m)=>(0!==t.stopIndex&&e.uint32(8).uint32(t.stopIndex),0!==t.routeId&&e.uint32(16).uint32(t.routeId),0!==t.tripIndex&&e.uint32(24).uint32(t.tripIndex),e),decode(t,e){var r;const i=t instanceof S?t:new S(t),n=null!==(r=i.__tsProtoDecodeDepth)&&void 0!==r?r:0;if(n>=100)throw new globalThis.Error("protobuf decode recursion limit exceeded");i.__tsProtoDecodeDepth=n+1;try{const t=void 0===e?i.len:i.pos+e,r={stopIndex:0,routeId:0,tripIndex:0};for(;i.pos<t;){const t=i.uint32();switch(t>>>3){case 1:if(8!==t)break;r.stopIndex=i.uint32();continue;case 2:if(16!==t)break;r.routeId=i.uint32();continue;case 3:if(24!==t)break;r.tripIndex=i.uint32();continue}if(4==(7&t)||0===t)break;i.skip(7&t)}return r}finally{i.__tsProtoDecodeDepth=n}},fromJSON:t=>({stopIndex:j(t.stopIndex)?globalThis.Number(t.stopIndex):j(t.stop_index)?globalThis.Number(t.stop_index):0,routeId:j(t.routeId)?globalThis.Number(t.routeId):j(t.route_id)?globalThis.Number(t.route_id):0,tripIndex:j(t.tripIndex)?globalThis.Number(t.tripIndex):j(t.trip_index)?globalThis.Number(t.trip_index):0}),toJSON(t){const e={};return 0!==t.stopIndex&&(e.stopIndex=Math.round(t.stopIndex)),0!==t.routeId&&(e.routeId=Math.round(t.routeId)),0!==t.tripIndex&&(e.tripIndex=Math.round(t.tripIndex)),e},create:t=>C.fromPartial(null!=t?t:{}),fromPartial(t){var e,r,i;const n={stopIndex:0,routeId:0,tripIndex:0};return n.stopIndex=null!==(e=t.stopIndex)&&void 0!==e?e:0,n.routeId=null!==(r=t.routeId)&&void 0!==r?r:0,n.tripIndex=null!==(i=t.tripIndex)&&void 0!==i?i:0,n}};const M={encode(t,e=new m){void 0!==t.origin&&C.encode(t.origin,e.uint32(10).fork()).join();for(const r of t.destinations)C.encode(r,e.uint32(18).fork()).join();return e},decode(t,e){var r;const i=t instanceof S?t:new S(t),n=null!==(r=i.__tsProtoDecodeDepth)&&void 0!==r?r:0;if(n>=100)throw new globalThis.Error("protobuf decode recursion limit exceeded");i.__tsProtoDecodeDepth=n+1;try{const t=void 0===e?i.len:i.pos+e,r={origin:void 0,destinations:[]};for(;i.pos<t;){const t=i.uint32();switch(t>>>3){case 1:if(10!==t)break;r.origin=C.decode(i,i.uint32());continue;case 2:if(18!==t)break;r.destinations.push(C.decode(i,i.uint32()));continue}if(4==(7&t)||0===t)break;i.skip(7&t)}return r}finally{i.__tsProtoDecodeDepth=n}},fromJSON:t=>({origin:j(t.origin)?C.fromJSON(t.origin):void 0,destinations:globalThis.Array.isArray(null==t?void 0:t.destinations)?t.destinations.map((t=>C.fromJSON(t))):[]}),toJSON(t){var e;const r={};return void 0!==t.origin&&(r.origin=C.toJSON(t.origin)),(null===(e=t.destinations)||void 0===e?void 0:e.length)&&(r.destinations=t.destinations.map((t=>C.toJSON(t)))),r},create:t=>M.fromPartial(null!=t?t:{}),fromPartial(t){var e;const r={origin:void 0,destinations:[]};return r.origin=void 0!==t.origin&&null!==t.origin?C.fromPartial(t.origin):void 0,r.destinations=(null===(e=t.destinations)||void 0===e?void 0:e.map((t=>C.fromPartial(t))))||[],r}};const Y={encode(t,e=new m){if(0!==t.routes.length){e.uint32(10).fork();for(const r of t.routes)e.uint32(r);e.join()}for(const r of t.transfers)D.encode(r,e.uint32(18).fork()).join();return e},decode(t,e){var r;const i=t instanceof S?t:new S(t),n=null!==(r=i.__tsProtoDecodeDepth)&&void 0!==r?r:0;if(n>=100)throw new globalThis.Error("protobuf decode recursion limit exceeded");i.__tsProtoDecodeDepth=n+1;try{const t=void 0===e?i.len:i.pos+e,r={routes:[],transfers:[]};for(;i.pos<t;){const t=i.uint32();switch(t>>>3){case 1:if(8===t){r.routes.push(i.uint32());continue}if(10===t){const t=i.uint32()+i.pos;for(;i.pos<t;)r.routes.push(i.uint32());continue}break;case 2:if(18!==t)break;r.transfers.push(D.decode(i,i.uint32()));continue}if(4==(7&t)||0===t)break;i.skip(7&t)}return r}finally{i.__tsProtoDecodeDepth=n}},fromJSON:t=>({routes:globalThis.Array.isArray(null==t?void 0:t.routes)?t.routes.map((t=>globalThis.Number(t))):[],transfers:globalThis.Array.isArray(null==t?void 0:t.transfers)?t.transfers.map((t=>D.fromJSON(t))):[]}),toJSON(t){var e,r;const i={};return(null===(e=t.routes)||void 0===e?void 0:e.length)&&(i.routes=t.routes.map((t=>Math.round(t)))),(null===(r=t.transfers)||void 0===r?void 0:r.length)&&(i.transfers=t.transfers.map((t=>D.toJSON(t)))),i},create:t=>Y.fromPartial(null!=t?t:{}),fromPartial(t){var e,r;const i={routes:[],transfers:[]};return i.routes=(null===(e=t.routes)||void 0===e?void 0:e.map((t=>t)))||[],i.transfers=(null===(r=t.transfers)||void 0===r?void 0:r.map((t=>D.fromPartial(t))))||[],i}};const F={encode(t,e=new m){if(0!==t.type&&e.uint32(8).int32(t.type),""!==t.name&&e.uint32(18).string(t.name),0!==t.routes.length){e.uint32(26).fork();for(const r of t.routes)e.uint32(r);e.join()}return e},decode(t,e){var r;const i=t instanceof S?t:new S(t),n=null!==(r=i.__tsProtoDecodeDepth)&&void 0!==r?r:0;if(n>=100)throw new globalThis.Error("protobuf decode recursion limit exceeded");i.__tsProtoDecodeDepth=n+1;try{const t=void 0===e?i.len:i.pos+e,r={type:0,name:"",routes:[]};for(;i.pos<t;){const t=i.uint32();switch(t>>>3){case 1:if(8!==t)break;r.type=i.int32();continue;case 2:if(18!==t)break;r.name=i.string();continue;case 3:if(24===t){r.routes.push(i.uint32());continue}if(26===t){const t=i.uint32()+i.pos;for(;i.pos<t;)r.routes.push(i.uint32());continue}}if(4==(7&t)||0===t)break;i.skip(7&t)}return r}finally{i.__tsProtoDecodeDepth=n}},fromJSON:t=>({type:j(t.type)?P(t.type):0,name:j(t.name)?globalThis.String(t.name):"",routes:globalThis.Array.isArray(null==t?void 0:t.routes)?t.routes.map((t=>globalThis.Number(t))):[]}),toJSON(t){var e;const r={};return 0!==t.type&&(r.type=function(t){switch(t){case w.ROUTE_TYPE_UNSPECIFIED:return"ROUTE_TYPE_UNSPECIFIED";case w.ROUTE_TYPE_TRAM:return"ROUTE_TYPE_TRAM";case w.ROUTE_TYPE_SUBWAY:return"ROUTE_TYPE_SUBWAY";case w.ROUTE_TYPE_RAIL:return"ROUTE_TYPE_RAIL";case w.ROUTE_TYPE_BUS:return"ROUTE_TYPE_BUS";case w.ROUTE_TYPE_FERRY:return"ROUTE_TYPE_FERRY";case w.ROUTE_TYPE_CABLE_TRAM:return"ROUTE_TYPE_CABLE_TRAM";case w.ROUTE_TYPE_AERIAL_LIFT:return"ROUTE_TYPE_AERIAL_LIFT";case w.ROUTE_TYPE_FUNICULAR:return"ROUTE_TYPE_FUNICULAR";case w.ROUTE_TYPE_TROLLEYBUS:return"ROUTE_TYPE_TROLLEYBUS";case w.ROUTE_TYPE_MONORAIL:return"ROUTE_TYPE_MONORAIL";case w.UNRECOGNIZED:default:return"UNRECOGNIZED"}}(t.type)),""!==t.name&&(r.name=t.name),(null===(e=t.routes)||void 0===e?void 0:e.length)&&(r.routes=t.routes.map((t=>Math.round(t)))),r},create:t=>F.fromPartial(null!=t?t:{}),fromPartial(t){var e,r,i;const n={type:0,name:"",routes:[]};return n.type=null!==(e=t.type)&&void 0!==e?e:0,n.name=null!==(r=t.name)&&void 0!==r?r:"",n.routes=(null===(i=t.routes)||void 0===i?void 0:i.map((t=>t)))||[],n}};const B={encode(t,e=new m){for(const r of t.stopsAdjacency)Y.encode(r,e.uint32(10).fork()).join();for(const r of t.routesAdjacency)L.encode(r,e.uint32(18).fork()).join();for(const r of t.serviceRoutes)F.encode(r,e.uint32(26).fork()).join();for(const r of t.tripContinuations)M.encode(r,e.uint32(34).fork()).join();for(const r of t.guaranteedTripTransfers)M.encode(r,e.uint32(42).fork()).join();return e},decode(t,e){var r;const i=t instanceof S?t:new S(t),n=null!==(r=i.__tsProtoDecodeDepth)&&void 0!==r?r:0;if(n>=100)throw new globalThis.Error("protobuf decode recursion limit exceeded");i.__tsProtoDecodeDepth=n+1;try{const t=void 0===e?i.len:i.pos+e,r={stopsAdjacency:[],routesAdjacency:[],serviceRoutes:[],tripContinuations:[],guaranteedTripTransfers:[]};for(;i.pos<t;){const t=i.uint32();switch(t>>>3){case 1:if(10!==t)break;r.stopsAdjacency.push(Y.decode(i,i.uint32()));continue;case 2:if(18!==t)break;r.routesAdjacency.push(L.decode(i,i.uint32()));continue;case 3:if(26!==t)break;r.serviceRoutes.push(F.decode(i,i.uint32()));continue;case 4:if(34!==t)break;r.tripContinuations.push(M.decode(i,i.uint32()));continue;case 5:if(42!==t)break;r.guaranteedTripTransfers.push(M.decode(i,i.uint32()));continue}if(4==(7&t)||0===t)break;i.skip(7&t)}return r}finally{i.__tsProtoDecodeDepth=n}},fromJSON:t=>({stopsAdjacency:globalThis.Array.isArray(null==t?void 0:t.stopsAdjacency)?t.stopsAdjacency.map((t=>Y.fromJSON(t))):globalThis.Array.isArray(null==t?void 0:t.stops_adjacency)?t.stops_adjacency.map((t=>Y.fromJSON(t))):[],routesAdjacency:globalThis.Array.isArray(null==t?void 0:t.routesAdjacency)?t.routesAdjacency.map((t=>L.fromJSON(t))):globalThis.Array.isArray(null==t?void 0:t.routes_adjacency)?t.routes_adjacency.map((t=>L.fromJSON(t))):[],serviceRoutes:globalThis.Array.isArray(null==t?void 0:t.serviceRoutes)?t.serviceRoutes.map((t=>F.fromJSON(t))):globalThis.Array.isArray(null==t?void 0:t.service_routes)?t.service_routes.map((t=>F.fromJSON(t))):[],tripContinuations:globalThis.Array.isArray(null==t?void 0:t.tripContinuations)?t.tripContinuations.map((t=>M.fromJSON(t))):globalThis.Array.isArray(null==t?void 0:t.trip_continuations)?t.trip_continuations.map((t=>M.fromJSON(t))):[],guaranteedTripTransfers:globalThis.Array.isArray(null==t?void 0:t.guaranteedTripTransfers)?t.guaranteedTripTransfers.map((t=>M.fromJSON(t))):globalThis.Array.isArray(null==t?void 0:t.guaranteed_trip_transfers)?t.guaranteed_trip_transfers.map((t=>M.fromJSON(t))):[]}),toJSON(t){var e,r,i,n,s;const o={};return(null===(e=t.stopsAdjacency)||void 0===e?void 0:e.length)&&(o.stopsAdjacency=t.stopsAdjacency.map((t=>Y.toJSON(t)))),(null===(r=t.routesAdjacency)||void 0===r?void 0:r.length)&&(o.routesAdjacency=t.routesAdjacency.map((t=>L.toJSON(t)))),(null===(i=t.serviceRoutes)||void 0===i?void 0:i.length)&&(o.serviceRoutes=t.serviceRoutes.map((t=>F.toJSON(t)))),(null===(n=t.tripContinuations)||void 0===n?void 0:n.length)&&(o.tripContinuations=t.tripContinuations.map((t=>M.toJSON(t)))),(null===(s=t.guaranteedTripTransfers)||void 0===s?void 0:s.length)&&(o.guaranteedTripTransfers=t.guaranteedTripTransfers.map((t=>M.toJSON(t)))),o},create:t=>B.fromPartial(null!=t?t:{}),fromPartial(t){var e,r,i,n,s;const o={stopsAdjacency:[],routesAdjacency:[],serviceRoutes:[],tripContinuations:[],guaranteedTripTransfers:[]};return o.stopsAdjacency=(null===(e=t.stopsAdjacency)||void 0===e?void 0:e.map((t=>Y.fromPartial(t))))||[],o.routesAdjacency=(null===(r=t.routesAdjacency)||void 0===r?void 0:r.map((t=>L.fromPartial(t))))||[],o.serviceRoutes=(null===(i=t.serviceRoutes)||void 0===i?void 0:i.map((t=>F.fromPartial(t))))||[],o.tripContinuations=(null===(n=t.tripContinuations)||void 0===n?void 0:n.map((t=>M.fromPartial(t))))||[],o.guaranteedTripTransfers=(null===(s=t.guaranteedTripTransfers)||void 0===s?void 0:s.map((t=>M.fromPartial(t))))||[],o}};function k(t){if(globalThis.Buffer)return Uint8Array.from(globalThis.Buffer.from(t,"base64"));{const e=globalThis.atob(t),r=new Uint8Array(e.length);for(let t=0;t<e.length;++t)r[t]=e.charCodeAt(t);return r}}function $(t){if(globalThis.Buffer)return globalThis.Buffer.from(t).toString("base64");{const e=[];return t.forEach((t=>{e.push(globalThis.String.fromCharCode(t))})),globalThis.btoa(e.join(""))}}function j(t){return null!=t}const z={REGULAR:0,NOT_AVAILABLE:1,MUST_PHONE_AGENCY:2,MUST_COORDINATE_WITH_DRIVER:3};let V=class t{constructor(t,e,r,i,n){this.id=t,this.stopTimes=e,this.pickupDropOffTypes=r,this.stops=i,this.serviceRouteId=n,this.nbStops=i.length,this.nbTrips=this.stopTimes.length/(2*this.stops.length),this.stopIndices=new Map;for(let t=0;t<i.length;t++){const e=i[t],r=this.stopIndices.get(e);void 0===r?this.stopIndices.set(e,t):"number"==typeof r?this.stopIndices.set(e,[r,t]):r.push(t)}}static of(e){var r,i;const{id:n,serviceRouteId:s,trips:o}=e;if(0===o.length)throw new Error("At least one trip must be provided");const a=o[0],u=new Uint32Array(a.stops.map((t=>t.id))),d=u.length;for(let t=1;t<o.length;t++){const e=o[t];if(e.stops.length!==d)throw new Error(`Trip ${t} has ${e.stops.length} stops, expected ${d}`);for(let r=0;r<d;r++)if(e.stops[r].id!==u[r])throw new Error(`Trip ${t} has different stop at index ${r}`)}const c=new Uint16Array(o.length*d*2);for(let t=0;t<o.length;t++){const e=o[t];for(let r=0;r<d;r++){const i=e.stops[r],n=2*(t*d+r);c[n]=i.arrivalTime,c[n+1]=i.departureTime}}const l=o.length*d,h=new Uint8Array(Math.ceil(l/2));for(let t=0;t<o.length;t++){const e=o[t];for(let n=0;n<d;n++){const s=e.stops[n],o=t*d+n,a=null!==(r=s.pickUpType)&&void 0!==r?r:z.REGULAR,u=null!==(i=s.dropOffType)&&void 0!==i?i:z.REGULAR,c=Math.floor(o/2),l=o%2==1;h[c]|=l?a<<6|u<<4:a<<2|u}}return new t(n,c,h,u,s)}serialize(){return{stopTimes:this.stopTimes,pickupDropOffTypes:this.pickupDropOffTypes,stops:this.stops,serviceRouteId:this.serviceRouteId}}getNbStops(){return this.nbStops}getNbTrips(){return this.nbTrips}serviceRoute(){return this.serviceRouteId}arrivalAt(t,e){const r=2*(e*this.stops.length+t),i=this.stopTimes[r];if(void 0===i)throw new Error(`Arrival time not found for stop ${this.stopId(t)} (${t}) at trip index ${e} in route ${this.serviceRouteId}`);return i}tripStopOffset(t){return t*this.nbStops}arrivalAtOffset(t,e){return this.stopTimes[2*(e+t)]}departureAtOffset(t,e){return this.stopTimes[2*(e+t)+1]}dropOffTypeAtOffset(t,e){const r=e+t,i=this.pickupDropOffTypes[r>>1];return 1&r?i>>4&3:3&i}departureFrom(t,e){const r=2*(e*this.stops.length+t)+1,i=this.stopTimes[r];if(void 0===i)throw new Error(`Departure time not found for stop ${this.stopId(t)} (${t}) at trip index ${e} in route ${this.serviceRouteId}`);return i}pickUpTypeFrom(t,e){const r=e*this.stops.length+t,i=r>>1,n=!(1&~r),s=this.pickupDropOffTypes[i];if(void 0===s)throw new Error(`Pick up type not found for stop ${this.stopId(t)} (${t}) at trip index ${e} in route ${this.serviceRouteId}`);return n?s>>6&3:s>>2&3}dropOffTypeAt(t,e){const r=e*this.stops.length+t,i=r>>1,n=!(1&~r),s=this.pickupDropOffTypes[i];if(void 0===s)throw new Error(`Drop off type not found for stop ${this.stopId(t)} (${t}) at trip index ${e} in route ${this.serviceRouteId}`);return n?s>>4&3:3&s}findEarliestTrip(t,e=0,r){if(this.nbTrips<=0)return;let i=this.nbTrips-1;if(void 0!==r&&(i=Math.min(i,r-1)),i<0)return;let n=0,s=-1;for(;n<=i;){const r=n+i>>>1;this.departureFrom(t,r)<e?n=r+1:(s=r,i=r-1)}return-1!==s?s:void 0}stopRouteIndices(t){const e=this.stopIndices.get(t);if(void 0===e)return[];if("number"==typeof e){const r=[e];return this.stopIndices.set(t,r),r}return e}firstStopRouteIndex(t){const e=this.stopIndices.get(t);return"number"==typeof e?e:null==e?void 0:e[0]}stopId(t){const e=this.stops[t];if(void 0===e)throw new Error(`StopId for stop at index ${t} not found in route ${this.serviceRouteId}`);return e}};const G=(BigInt(1)<<BigInt(20))-BigInt(1),J=1048575,W=BigInt(0),Z=BigInt(20),H=BigInt(40),Q=(t,e)=>{if(t<0||t>J)throw new Error(`${e} must be between 0 and 1048575, got ${t}`)},q=(t,e,r)=>(Q(t,"stopIndex"),Q(e,"routeId"),Q(r,"tripIndex"),BigInt(t)<<H|BigInt(e)<<Z|BigInt(r)<<W),X=(()=>{const t=new ArrayBuffer(4);return new DataView(t).setUint32(0,305419896),120===new Uint8Array(t)[0]})(),K=!0,tt=t=>{if(X===K)return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);const e=new Uint8Array(4*t.length),r=new DataView(e.buffer);for(let e=0;e<t.length;e++)r.setUint32(4*e,t[e],K);return e},et=t=>{if(t.byteLength%4!=0)throw new Error("Byte array length must be a multiple of 4 to convert to Uint32Array");if(X===K)return new Uint32Array(t.buffer,t.byteOffset,t.byteLength/4);const e=new Uint32Array(t.byteLength/4),r=new DataView(t.buffer,t.byteOffset,t.byteLength);for(let t=0;t<e.length;t++)e[t]=r.getUint32(4*t,K);return e},rt=t=>{if(X===K)return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);const e=new Uint8Array(2*t.length),r=new DataView(e.buffer);for(let e=0;e<t.length;e++)r.setUint16(2*e,t[e],K);return e},it=t=>{if(t.byteLength%2!=0)throw new Error("Byte array length must be a multiple of 2 to convert to Uint16Array");if(X===K)return new Uint16Array(t.buffer,t.byteOffset,t.byteLength/2);const e=new Uint16Array(t.byteLength/2),r=new DataView(t.buffer,t.byteOffset,t.byteLength);for(let t=0;t<e.length;t++)e[t]=r.getUint16(2*t,K);return e},nt=t=>{const e=[];return t.forEach((t=>{const r=t.serialize();e.push({stopTimes:rt(r.stopTimes),pickupDropOffTypes:r.pickupDropOffTypes,stops:tt(r.stops),serviceRouteId:r.serviceRouteId})})),e},st=t=>{switch(t){case b.TRANSFER_TYPE_UNSPECIFIED:throw new Error("Unspecified protobuf transfer type.");case b.TRANSFER_TYPE_RECOMMENDED_TRANSFER_POINT:return lt.RECOMMENDED;case b.TRANSFER_TYPE_TIMED_TRANSFER:return lt.GUARANTEED;case b.TRANSFER_TYPE_REQUIRES_MINIMAL_TIME:return lt.REQUIRES_MINIMAL_TIME;case b.TRANSFER_TYPE_IN_SEAT_TRANSFER:return lt.IN_SEAT;case b.UNRECOGNIZED:throw new Error("Unrecognized protobuf transfer type.")}},ot=t=>{switch(t){case lt.RECOMMENDED:return b.TRANSFER_TYPE_RECOMMENDED_TRANSFER_POINT;case lt.GUARANTEED:return b.TRANSFER_TYPE_TIMED_TRANSFER;case lt.REQUIRES_MINIMAL_TIME:return b.TRANSFER_TYPE_REQUIRES_MINIMAL_TIME;case lt.IN_SEAT:return b.TRANSFER_TYPE_IN_SEAT_TRANSFER}},at=t=>{switch(t){case w.ROUTE_TYPE_UNSPECIFIED:throw new Error("Unspecified protobuf route type.");case w.ROUTE_TYPE_TRAM:return ht.TRAM;case w.ROUTE_TYPE_SUBWAY:return ht.SUBWAY;case w.ROUTE_TYPE_RAIL:return ht.RAIL;case w.ROUTE_TYPE_BUS:return ht.BUS;case w.ROUTE_TYPE_FERRY:return ht.FERRY;case w.ROUTE_TYPE_CABLE_TRAM:return ht.CABLE_TRAM;case w.ROUTE_TYPE_AERIAL_LIFT:return ht.AERIAL_LIFT;case w.ROUTE_TYPE_FUNICULAR:return ht.FUNICULAR;case w.ROUTE_TYPE_TROLLEYBUS:return ht.TROLLEYBUS;case w.ROUTE_TYPE_MONORAIL:return ht.MONORAIL;case w.UNRECOGNIZED:default:throw new Error("Unrecognized protobuf route type.")}},ut=t=>{switch(t){case ht.TRAM:return w.ROUTE_TYPE_TRAM;case ht.SUBWAY:return w.ROUTE_TYPE_SUBWAY;case ht.RAIL:return w.ROUTE_TYPE_RAIL;case ht.BUS:return w.ROUTE_TYPE_BUS;case ht.FERRY:return w.ROUTE_TYPE_FERRY;case ht.CABLE_TRAM:return w.ROUTE_TYPE_CABLE_TRAM;case ht.AERIAL_LIFT:return w.ROUTE_TYPE_AERIAL_LIFT;case ht.FUNICULAR:return w.ROUTE_TYPE_FUNICULAR;case ht.TROLLEYBUS:return w.ROUTE_TYPE_TROLLEYBUS;case ht.MONORAIL:return w.ROUTE_TYPE_MONORAIL}},dt=t=>{const e=[];for(const[i,n]of t.entries()){const[t,s,o]=(r=i,[Number(r>>H&G),Number(r>>Z&G),Number(r>>W&G)]);e.push({origin:{stopIndex:t,routeId:s,tripIndex:o},destinations:n.map((t=>({stopIndex:t.stopIndex,routeId:t.routeId,tripIndex:t.tripIndex})))})}var r;return e},ct=t=>{const e=new Map;for(let r=0;r<t.length;r++){const i=t[r],n=i.origin,s=q(n.stopIndex,n.routeId,n.tripIndex),o=i.destinations.map((t=>({stopIndex:t.stopIndex,routeId:t.routeId,tripIndex:t.tripIndex})));e.set(s,o)}return e},lt={RECOMMENDED:1,GUARANTEED:2,REQUIRES_MINIMAL_TIME:3,IN_SEAT:4},ht={TRAM:1,SUBWAY:2,RAIL:3,BUS:4,FERRY:5,CABLE_TRAM:6,AERIAL_LIFT:7,FUNICULAR:8,TROLLEYBUS:9,MONORAIL:10},pt=new Set(Object.values(ht)),ft=[];class Tt{constructor(t,e,r,i,n){this.stopsAdjacency=t,this.routesAdjacency=e,this.serviceRoutes=r,this.tripContinuations=i,this.guaranteedTripTransfers=n,this.activeStops=new Set;for(let e=0;e<t.length;e++){const r=t[e];(r.routes.length>0||r.transfers&&r.transfers.length>0)&&this.activeStops.add(e)}}serialize(){const t={stopsAdjacency:(r=this.stopsAdjacency,r.map((t=>({transfers:t.transfers?t.transfers.map((t=>Object.assign({destination:t.destination,type:ot(t.type)},void 0!==t.minTransferTime&&{minTransferTime:t.minTransferTime}))):[],routes:t.routes})))),routesAdjacency:nt(this.routesAdjacency),serviceRoutes:(e=this.serviceRoutes,e.map((t=>({type:ut(t.type),name:t.name,routes:t.routes})))),tripContinuations:dt(this.tripContinuations||new Map),guaranteedTripTransfers:dt(this.guaranteedTripTransfers||new Map)};var e,r;const i=new m;return B.encode(t,i),i.finish()}static fromData(t){const e=new S(t),r=B.decode(e);return new Tt((t=>{const e=[];for(let r=0;r<t.length;r++){const i=t[r],n=[];for(let t=0;t<i.transfers.length;t++){const e=i.transfers[t],r=Object.assign({destination:e.destination,type:st(e.type)},void 0!==e.minTransferTime&&{minTransferTime:e.minTransferTime});n.push(r)}const s={routes:i.routes};n.length>0&&(s.transfers=n),e.push(s)}return e})(r.stopsAdjacency),(t=>{const e=[],r=new Uint8Array(t.reduce(((t,e)=>t+e.pickupDropOffTypes.byteLength),0));let i=0;for(let n=0;n<t.length;n++){const s=t[n],o=et(s.stops);r.set(s.pickupDropOffTypes,i);const a=r.subarray(i,i+s.pickupDropOffTypes.byteLength);i+=s.pickupDropOffTypes.byteLength,e.push(new V(n,it(s.stopTimes),a,o,s.serviceRouteId))}return e})(r.routesAdjacency),(t=>{const e=[];for(let r=0;r<t.length;r++){const i=t[r];e.push({type:at(i.type),name:i.name,routes:i.routes})}return e})(r.serviceRoutes),ct(r.tripContinuations),ct(r.guaranteedTripTransfers))}isActive(t){return this.activeStops.has(t)}nbStops(){return this.stopsAdjacency.length}getRoute(t){return this.routesAdjacency[t]}getTransfers(t){const e=this.stopsAdjacency[t];if(!e)throw new Error(`Stop ID ${t} not found`);return e.transfers||[]}getContinuousTrips(t,e,r){var i;const n=null===(i=this.tripContinuations)||void 0===i?void 0:i.get(q(t,e,r));return n||ft}getServiceRouteInfo(t){const e=this.serviceRoutes[t.serviceRoute()];if(!e)throw new Error(`Service route not found for route ID: ${t.serviceRoute()}`);return{type:e.type,name:e.name}}routesPassingThrough(t){const e=this.stopsAdjacency[t];if(!e)return[];const r=[];for(let t=0;t<e.routes.length;t++){const i=e.routes[t],n=this.routesAdjacency[i];n&&r.push(n)}return r}findReachableRoutes(t,e=pt){const r=new Map,i=e!==pt;for(const n of t){const t=this.stopsAdjacency[n];if(t)for(let s=0;s<t.routes.length;s++){const o=this.routesAdjacency[t.routes[s]];if(!o)continue;if(i){const t=this.serviceRoutes[o.serviceRoute()];if(!t||!e.has(t.type))continue}const a=o.firstStopRouteIndex(n),u=r.get(o);void 0!==u?a<u&&r.set(o,a):r.set(o,a)}}return r}isTripTransferGuaranteed(t,e){var r;const i=q(t.stopIndex,t.routeId,t.tripIndex),n=null===(r=this.guaranteedTripTransfers)||void 0===r?void 0:r.get(i);if(!n)return!1;for(let t=0;t<n.length;t++){const r=n[t];if(r.stopIndex===e.stopIndex&&r.routeId===e.routeId&&r.tripIndex===e.tripIndex)return!0}return!1}findFirstBoardableTrip(t,e,r,i=0,n,s,o=0){const a=e.getNbTrips();for(let u=r;u<(null!=n?n:a);u++){if(e.pickUpTypeFrom(t,u)===z.NOT_AVAILABLE)continue;if(void 0===s)return u;if(this.isTripTransferGuaranteed(s,{stopIndex:t,routeId:e.id,tripIndex:u}))return u;if(e.departureFrom(t,u)>=i+o)return u}}getGuaranteedTripTransfers(t,e,r){var i;const n=null===(i=this.guaranteedTripTransfers)||void 0===i?void 0:i.get(q(t,e,r));return n||ft}}const _t=t=>{switch(t){case ht.TRAM:return"TRAM";case ht.SUBWAY:return"SUBWAY";case ht.RAIL:return"RAIL";case ht.BUS:return"BUS";case ht.FERRY:return"FERRY";case ht.CABLE_TRAM:return"CABLE_TRAM";case ht.AERIAL_LIFT:return"AERIAL_LIFT";case ht.FUNICULAR:return"FUNICULAR";case ht.TROLLEYBUS:return"TROLLEYBUS";case ht.MONORAIL:return"MONORAIL"}},Et=t=>{switch(t){case lt.RECOMMENDED:return"RECOMMENDED";case lt.GUARANTEED:return"GUARANTEED";case lt.REQUIRES_MINIMAL_TIME:return"REQUIRES_MINIMAL_TIME";case lt.IN_SEAT:return"IN_SEAT"}},mt={colors:{rounds:["#60a5fa","#ff9800","#14b8a6","#fb7185","#ffdf00","#b600ff","#ee82ee"],defaultRound:"#888888",originStation:"#60a5fa",destinationStation:"#ee82ee",defaultStation:"white",continuationFill:"#ffffcc"},penWidth:{continuation:2,continuationEdge:3}};function It(t){return"routeId"in t&&"stopIndex"in t&&"hopOffStopIndex"in t}function gt(t){return"from"in t&&"to"in t&&"type"in t}function Rt(t){return"from"in t&&"duration"in t}class vt{constructor(){this.lines=[]}addHeader(){return this.lines.push("digraph RoutingGraph {"," graph [overlap=false, splines=true, rankdir=TB, bgcolor=white, nodesep=0.8, ranksep=1.2, concentrate=true];",' node [fontname="Arial" margin=0.1];',' edge [fontname="Arial" fontsize=10];'),this}addComment(t){return this.lines.push("",` // ${t}`),this}addNode(t,e){const r=Object.entries(e).map((([t,e])=>`${t}="${e}"`)).join(" ");return this.lines.push(` "${t}" [${r}];`),this}addEdge(t,e,r={}){const i=Object.entries(r).map((([t,e])=>`${t}="${e}"`)).join(" "),n=i?` [${i}]`:"";return this.lines.push(` "${t}" -> "${e}"${n};`),this}addRaw(t){return this.lines.push(...t),this}build(){return this.lines.push("}"),this.lines.join("\n")}}class At{constructor(t){this.from=t.fromValue,this.to=t.toValue,this.departureTime=t.departureTimeValue,this.options=t.optionsValue}}At.Builder=class{constructor(){var t;this.toValue=new Set,this.optionsValue={maxTransfers:5,minTransferTime:(t=120,Math.round(t/60)),transportModes:pt}}from(t){return this.fromValue=t,this}to(t){return this.toValue=t instanceof Set?t:new Set([t]),this}departureTime(t){return this.departureTimeValue=t,this}maxTransfers(t){return this.optionsValue.maxTransfers=t,this}minTransferTime(t){return this.optionsValue.minTransferTime=t,this}transportModes(t){return this.optionsValue.transportModes=t,this}maxDuration(t){return this.optionsValue.maxDuration=t,this}maxInitialWaitingTime(t){return this.optionsValue.maxInitialWaitingTime=t,this}build(){return new At(this)}};class yt extends At{constructor(t){super(t),this.lastDepartureTime=t.lastDepartureTimeValue,this.rangeOptions=t.rangeOptionsValue}}yt.Builder=class extends At.Builder{constructor(){super(...arguments),this.rangeOptionsValue={optimizeBeyondLatestDeparture:!0}}lastDepartureTime(t){return this.lastDepartureTimeValue=t,this}rangeOptions(t){return this.rangeOptionsValue=Object.assign(Object.assign({},this.rangeOptionsValue),t),this}build(){return new yt(this)}};class St{constructor(t){this.legs=t}departureTime(){let t=0;for(let e=0;e<this.legs.length;e++){const r=this.legs[e];if("departureTime"in r)return r.departureTime-t;"duration"in r&&r.duration&&(t+=r.duration)}throw new Error("No vehicle leg found in route")}arrivalTime(){let t=0;for(let e=this.legs.length-1;e>=0;e--){const r=this.legs[e];if("arrivalTime"in r)return r.arrivalTime+t;"minTransferTime"in r&&r.minTransferTime&&(t+=r.minTransferTime)}throw new Error("No vehicle leg found in route")}totalDuration(){return 0===this.legs.length?0:Math.abs(this.arrivalTime()-this.departureTime())}toString(){return this.legs.map(((r,i)=>{const n=`From: ${r.from.name}${r.from.platform?` (Pl. ${r.from.platform})`:""}`,s=`To: ${r.to.name}${r.to.platform?` (Pl. ${r.to.platform})`:""}`,o="type"in r&&!("route"in r)?`Transfer: ${Et(r.type)}${r.minTransferTime?`, Minimum Transfer Time: ${e(r.minTransferTime)}`:""}`:"",a="duration"in r?`Access duration: ${e(r.duration)}`:"",u="route"in r&&"departureTime"in r&&"arrivalTime"in r?`Route: ${_t(r.route.type)} ${r.route.name}, Departure: ${t(r.departureTime)}, Arrival: ${t(r.arrivalTime)}`:"";return[`Leg ${i+1}:`,` ${n}`,` ${s}`,o?` ${o}`:"",a?` ${a}`:"",u?` ${u}`:""].filter((t=>""!==t.trim())).join("\n")})).join("\n")}}class Ot{constructor(t,e,r,i){this.destinations=t,this.routingState=e,this.stopsIndex=r,this.timetable=i}expandDestinations(t){const e=t instanceof Set?t:void 0!==t?[t]:this.destinations,r=new Set;for(const t of e)for(const e of this.stopsIndex.equivalentStops(t))r.add(e.id);return r}bestRouteToSourceStopId(t){var e;if(t instanceof Set){const e=new Set;for(const r of t){const t=this.stopsIndex.findStopBySourceStopId(r);void 0!==t&&e.add(t.id)}return 0===e.size?void 0:this.bestRoute(e)}const r=null===(e=this.stopsIndex.findStopBySourceStopId(t))||void 0===e?void 0:e.id;return void 0===r?void 0:this.bestRoute(r)}bestRoute(t){var e;const r=this.expandDestinations(t);let i,n,s;for(const t of r){const e=this.routingState.getArrival(t);void 0!==e&&(void 0===n||e.arrival<n)&&(i=t,n=e.arrival,s=e.legNumber)}if(void 0===i||void 0===s)return;const o=[];let a,u=i,d=s;for(;d>=0;){const t=null===(e=this.routingState.graph[d])||void 0===e?void 0:e[u];if(!t){if(0===d)break;throw new Error(`No edge arriving at stop ${u} at round ${d}`)}let r;if("routeId"in t){let e,i;if(t.continuationOf){let r=t;const n=[r];for(;r.continuationOf;)n.push(r.continuationOf),r=r.continuationOf;e=r,i=this.buildVehicleLeg(n)}else e=t,i=this.buildVehicleLeg([t]);r=i,a&&this.timetable.isTripTransferGuaranteed({stopIndex:e.hopOffStopIndex,routeId:e.routeId,tripIndex:e.tripIndex},{stopIndex:a.stopIndex,routeId:a.routeId,tripIndex:a.tripIndex})&&o.push(this.buildGuaranteedTransferLeg(e,a)),a=e}else if("type"in t)r=this.buildTransferLeg(t),a=void 0;else{if(!("duration"in t))break;r=this.buildAccessLeg(t),a=void 0}o.push(r),u=r.from.id,"routeId"in t&&(d-=1)}return new St(o.reverse())}buildServiceRouteInfo(t){const e=this.timetable.getServiceRouteInfo(t);return{type:e.type,name:e.name}}buildVehicleLeg(t){if(0===t.length)throw new Error("Cannot build vehicle leg from empty edges");const e=t[t.length-1],r=t[0],i=this.timetable.getRoute(e.routeId),n=this.timetable.getRoute(r.routeId);return{from:this.stopsIndex.findStopById(i.stopId(e.stopIndex)),to:this.stopsIndex.findStopById(n.stopId(r.hopOffStopIndex)),route:this.buildServiceRouteInfo(i),departureTime:i.departureFrom(e.stopIndex,e.tripIndex),arrivalTime:r.arrival,pickUpType:i.pickUpTypeFrom(e.stopIndex,e.tripIndex),dropOffType:n.dropOffTypeAt(r.hopOffStopIndex,r.tripIndex)}}buildTransferLeg(t){return{from:this.stopsIndex.findStopById(t.from),to:this.stopsIndex.findStopById(t.to),minTransferTime:t.minTransferTime,type:t.type}}buildAccessLeg(t){return{from:this.stopsIndex.findStopById(t.from),to:this.stopsIndex.findStopById(t.to),duration:t.duration}}buildGuaranteedTransferLeg(t,e){const r=this.timetable.getRoute(t.routeId),i=this.timetable.getRoute(e.routeId),n=r.stopId(t.hopOffStopIndex),s=i.stopId(e.stopIndex);return{from:this.stopsIndex.findStopById(n),to:this.stopsIndex.findStopById(s),type:lt.GUARANTEED}}arrivalAt(t,e){var r,i;const n=this.stopsIndex.equivalentStops(t);let s;for(const t of n){let n;if(void 0===e||(null===(r=this.routingState.getArrival(t.id))||void 0===r?void 0:r.legNumber)===e+1)n=this.routingState.getArrival(t.id);else for(let r=e+1;r>=0;r--){const e=null===(i=this.routingState.graph[r])||void 0===i?void 0:i[t.id];if(void 0!==e){n={arrival:e.arrival,legNumber:r};break}}void 0!==n&&(void 0===s||n.arrival<s.arrival)&&(s=n)}return s}}class Nt{constructor(t,e){this.timetable=t,this.stopsIndex=e}collectAccessPaths(t,e){var r;const i=this.stopsIndex.equivalentStops(t).map((t=>t.id)),n=new Map;for(const t of i){const i=n.get(t);(void 0===i||i.duration>0)&&n.set(t,{fromStopId:t,toStopId:t,duration:0});for(const i of this.timetable.getTransfers(t))if(i.type===lt.REQUIRES_MINIMAL_TIME){const s=null!==(r=i.minTransferTime)&&void 0!==r?r:e,o=n.get(i.destination);(void 0===o||o.duration&&s<o.duration)&&n.set(i.destination,{fromStopId:t,toStopId:i.destination,duration:s})}}return Array.from(n.values())}collectDepartureTimes(t,e,r){const i=new Map;for(const n of t){const{toStopId:t}=n,s=e+n.duration,o=r+n.duration;for(const e of this.timetable.routesPassingThrough(t))for(const r of e.stopRouteIndices(t)){let t=e.findEarliestTrip(r,s);if(void 0===t)continue;const a=e.getNbTrips();for(;t<a;){const s=e.departureFrom(r,t);if(s>o)break;if(e.pickUpTypeFrom(r,t)!==z.NOT_AVAILABLE){const t=s-n.duration;let e=i.get(t);void 0===e&&i.set(t,e=new Set),e.add(n)}t++}}}if(0===i.size)return[];const n=Array.from(i.entries()).sort((([t],[e])=>e-t));return n.map((([t,e])=>({depTime:t,legs:Array.from(e)})))}}const bt=65535;class wt{constructor(t,e,r,i,n=0,s){this._destinationBest=bt,this.maxArrivalTime=bt,this.reachedStops=[],this.destinations=e,this.maxDuration=s,this.maxArrivalTime=void 0===s?bt:t+s,this.destinationSet=new Set(e),this.earliestArrivalTimes=new Uint16Array(i).fill(bt),this.earliestArrivalLegs=new Uint8Array(i),this.origins=[],this.graph=[new Array(i)];for(let t=1;t<=n;t++)this.graph.push(new Array(i));this.seedAccessPaths(t,r)}seedAccessPaths(t,e){const r=new Set;for(const i of e){const e=t+i.duration;if(e>this.maxArrivalTime)continue;const n=0===i.duration?{stopId:i.fromStopId,arrival:t}:{arrival:e,from:i.fromStopId,to:i.toStopId,duration:i.duration},s=i.toStopId;e<this.earliestArrivalTimes[s]&&(this.earliestArrivalTimes[s]=e,this.graph[0][s]=n),r.add(s)}for(const t of r)this.reachedStops.push(t);this.origins=Array.from(r);for(let t=0;t<this.destinations.length;t++){const e=this.earliestArrivalTimes[this.destinations[t]];e<this._destinationBest&&(this._destinationBest=e)}}get nbStops(){return this.earliestArrivalTimes.length}arrivalTime(t){return this.earliestArrivalTimes[t]}get destinationBest(){return this._destinationBest}improvementBound(t,e){return this.arrivalTime(e)}initRound(t){}updateArrival(t,e,r){this.earliestArrivalTimes[t]===bt&&this.reachedStops.push(t),this.earliestArrivalTimes[t]=e,this.earliestArrivalLegs[t]=r,this.destinationSet.has(t)&&e<this._destinationBest&&(this._destinationBest=e)}resetFor(t,e){for(const t of this.reachedStops){this.earliestArrivalTimes[t]=bt,this.earliestArrivalLegs[t]=0;for(let e=0;e<this.graph.length;e++)this.graph[e][t]=void 0}this.reachedStops.length=0,this._destinationBest=bt,this.maxArrivalTime=void 0===this.maxDuration?bt:t+this.maxDuration,this.seedAccessPaths(t,e)}*arrivals(){for(let t=0;t<this.earliestArrivalTimes.length;t++){const e=this.earliestArrivalTimes[t];e<bt&&(yield{stop:t,arrival:e,legNumber:this.earliestArrivalLegs[t]})}}earliestArrivalAtAnyDestination(){return this._destinationBest}getArrival(t){const e=this.earliestArrivalTimes[t];if(!(e>=bt))return{arrival:e,legNumber:this.earliestArrivalLegs[t]}}isDestination(t){return this.destinationSet.has(t)}static fromTestData({nbStops:t,origins:e=[],destinations:r=[],arrivals:i=[],graph:n=[]}){const s=new wt(0,r,e.map((t=>({fromStopId:t,toStopId:t,duration:0}))),t),o=new Uint16Array(t).fill(bt),a=new Uint8Array(t);for(const[t,e,r]of i)o[t]=e,a[t]=r;s.earliestArrivalTimes=o,s.earliestArrivalLegs=a,s._destinationBest=bt;for(const t of r){const e=o[t];void 0!==e&&e<s._destinationBest&&(s._destinationBest=e)}const u=n.map((e=>{const r=new Array(t);for(const[t,i]of e)r[t]=i;return r}));s.graph.splice(0,s.graph.length,...u),s.reachedStops.length=0;const d=new Set(i.map((([t])=>t)));for(const t of n)for(const[e]of t)d.add(e);return s.reachedStops.push(...d),s}}class Ut{constructor(t,e,r,i){this.timetable=t,this.stopsIndex=e,this.accessFinder=r,this.raptor=i}route(t){const e=this.accessFinder.collectAccessPaths(t.from,t.options.minTransferTime),r=Array.from(t.to).flatMap((t=>this.stopsIndex.equivalentStops(t))).map((t=>t.id)),i=new wt(t.departureTime,r,e,this.timetable.nbStops(),t.options.maxTransfers+1,t.options.maxDuration);return this.raptor.run(t.options,i),new Ot(new Set(r),i,this.stopsIndex,this.timetable)}}class Pt{constructor(t,e){this._runs=t,this._destinations=e}get destinations(){return this._destinations}normalizeTargets(t){return t instanceof Set?new Set(t):void 0!==t?new Set([t]):new Set(this._destinations)}getRoutes(){const t=[];for(const{result:e}of this._runs){const r=e.bestRoute();void 0!==r&&t.push(r)}return t.reverse()}bestRoute(t){const e=this.normalizeTargets(t);let r,i;for(const t of this._runs)for(const n of e){const e=t.result.arrivalAt(n);void 0!==e&&((void 0===i||e.arrival<i)&&(i=e.arrival,r=t))}return null==r?void 0:r.result.bestRoute(e)}latestDepartureRoute(t){const e=this.normalizeTargets(t);for(const{result:t}of this._runs){const r=t.bestRoute(e);if(void 0!==r)return r}}fastestRoute(t){const e=this.normalizeTargets(t);let r,i=1/0;for(const t of this._runs)for(const n of e){const e=t.result.arrivalAt(n);if(void 0===e)continue;const s=e.arrival-t.departureTime;(s<i||s===i&&void 0!==r&&t.departureTime<r.departureTime)&&(i=s,r=t)}return null==r?void 0:r.result.bestRoute(e)}get size(){return this._runs.length}earliestArrivalAt(t,e){let r;for(const{result:i}of this._runs){const n=i.arrivalAt(t,e);void 0!==n&&(void 0===r||n.arrival<r.arrival)&&(r=n)}return r}shortestDurationTo(t,e){let r;for(const{departureTime:i,result:n}of this._runs){const s=n.arrivalAt(t,e);if(void 0===s)continue;const o=s.arrival-i;(void 0===r||o<r.duration)&&(r=Object.assign(Object.assign({},s),{duration:o}))}return r}allShortestDurations(){const t=new Map;for(const{departureTime:e,result:r}of this._runs)for(const{stop:i,arrival:n,legNumber:s}of r.routingState.arrivals()){const r=n-e,o=t.get(i);(void 0===o||r<o.duration)&&t.set(i,{arrival:n,legNumber:s,duration:r})}return t}allEarliestArrivals(){const t=new Map;for(const{result:e}of this._runs)for(const{stop:r,arrival:i,legNumber:n}of e.routingState.arrivals()){const e=t.get(r);(void 0===e||i<e.arrival)&&t.set(r,{arrival:i,legNumber:n})}return t}[Symbol.iterator](){return this._runs[Symbol.iterator]()}}class xt{constructor(t,e,r){this._destinationBest=bt,this.latestDeparture=r,this.roundLabels=Array.from({length:t+2},(()=>new Uint16Array(e).fill(bt))),this.changedInRound=Array.from({length:t+2},(()=>[]))}setCurrentRun(t){this.currentRun=t;const e=t.graph[0];for(const r of t.origins){const t=e[r];t&&this.updateArrival(r,t.arrival,0)}}get origins(){return this.currentRun.origins}get graph(){return this.currentRun.graph}arrivalTime(t){return this.currentRun.arrivalTime(t)}improvementBound(t,e){return this.roundLabels[t][e]}get destinationBest(){return this._destinationBest}get maxArrivalTime(){return this.currentRun.maxArrivalTime}isDestination(t){return this.currentRun.isDestination(t)}updateArrival(t,e,r){const i=this.currentRun.getArrival(t);(void 0===i||e<i.arrival||e===i.arrival&&r<i.legNumber)&&this.currentRun.updateArrival(t,e,r),e<this.roundLabels[r][t]&&(this.roundLabels[r][t]=e,this.changedInRound[r].push(t),this.currentRun.isDestination(t)&&e<this._destinationBest&&(this._destinationBest=e))}initRound(t){const e=this.changedInRound[t-1];if(0===e.length)return;const r=this.roundLabels[t-1],i=this.roundLabels[t];for(let t=0;t<e.length;t++){const n=e[t];r[n]<i[n]&&(i[n]=r[n])}e.length=0}}class Lt{constructor(t,e,r,i){this.timetable=t,this.stopsIndex=e,this.accessFinder=r,this.raptor=i}rangeRoute(t){var e,r;const{departureTime:i,lastDepartureTime:n}=t,s=Array.from(t.to).flatMap((t=>this.stopsIndex.equivalentStops(t))).map((t=>t.id)),o=0===s.length,a=this.accessFinder.collectAccessPaths(t.from,t.options.minTransferTime),u=this.accessFinder.collectDepartureTimes(a,i,n);if(0===u.length)return new Pt([],new Set(s));const d=t.options.maxTransfers+1,c=new xt(d,this.timetable.nbStops(),n),l=[],h=new Map;for(const t of s)h.set(t,bt);const p=new Set(a.map((t=>t.toStopId)).filter((t=>s.includes(t)))),f=new Set;let T=null;if(t.rangeOptions.optimizeBeyondLatestDeparture&&(T=new wt(n+1,s,a,this.timetable.nbStops(),d,t.options.maxDuration),c.setCurrentRun(T),this.raptor.run(Object.assign(Object.assign({},t.options),{maxInitialWaitingTime:void 0}),c),!o))for(const t of s){const r=T.arrivalTime(t);r<(null!==(e=h.get(t))&&void 0!==e?e:bt)&&h.set(t,r)}for(const{depTime:e,legs:i}of u){if(!o&&f.size===s.length)break;null===T?T=new wt(e,s,i,this.timetable.nbStops(),d,t.options.maxDuration):T.resetFor(e,i),c.setCurrentRun(T),this.raptor.run(Object.assign(Object.assign({},t.options),{maxInitialWaitingTime:0}),c);let n=o;if(!o)for(const t of s){const e=T.arrivalTime(t);e>=(null!==(r=h.get(t))&&void 0!==r?r:bt)||(p.has(t)&&f.has(t)?h.set(t,e):(h.set(t,e),p.has(t)&&f.add(t),n=!0))}n&&(l.push({departureTime:e,result:new Ot(new Set(s),T,this.stopsIndex,this.timetable)}),T=null)}return new Pt(l,new Set(s))}}class Dt{constructor(t){this.timetable=t}run(t,e){const r=new Set(e.origins);for(let i=1;i<=t.maxTransfers+1;i++){e.initRound(i);const n=e.graph[i],s=this.timetable.findReachableRoutes(r,t.transportModes);r.clear();for(const[n,o]of s)for(const s of this.scanRoute(n,o,i,e,t))r.add(s);let o=this.findTripContinuations(r,n);const a=new Set;for(;o.length>0;){a.clear();for(const t of o){const n=this.timetable.getRoute(t.routeId);for(const s of this.scanRouteContinuation(n,t.stopIndex,i,e,t))a.add(s),r.add(s)}o=this.findTripContinuations(a,n)}for(const n of this.considerTransfers(t,i,r,e))r.add(n);if(0===r.size)break}}findTripContinuations(t,e){const r=[];for(const i of t){const t=e[i];if(!t||!("routeId"in t))continue;const n=this.timetable.getContinuousTrips(t.hopOffStopIndex,t.routeId,t.tripIndex);for(const e of n)r.push({routeId:e.routeId,stopIndex:e.stopIndex,tripIndex:e.tripIndex,previousEdge:t})}return r}scanRouteContinuation(t,e,r,i,n){const s=new Set,o=i.graph[r],a=t.getNbStops(),u=t.id,d=n.tripIndex,c=t.tripStopOffset(d),l=n.previousEdge;for(let n=e;n<a;n++){const a=t.stops[n],h=t.arrivalAtOffset(n,c);t.dropOffTypeAtOffset(n,c)!==z.NOT_AVAILABLE&&h<=i.maxArrivalTime&&h<i.improvementBound(r,a)&&h<i.destinationBest&&(o[a]={routeId:u,stopIndex:e,tripIndex:d,arrival:h,hopOffStopIndex:n,continuationOf:l},i.updateArrival(a,h,r),s.add(a))}return s}scanRoute(t,e,r,i,n){const s=new Set,o=i.graph[r],a=i.graph[r-1],u=t.getNbStops(),d=t.id;let c,l=e,h=0;for(let p=e;p<u;p++){const e=t.stops[p];if(void 0!==c){const n=t.arrivalAtOffset(p,h);t.dropOffTypeAtOffset(p,h)!==z.NOT_AVAILABLE&&n<=i.maxArrivalTime&&n<i.improvementBound(r,e)&&n<i.destinationBest&&(o[e]={routeId:d,stopIndex:l,tripIndex:c,arrival:n,hopOffStopIndex:p},i.updateArrival(e,n,r),s.add(e))}const u=a[e],f=null==u?void 0:u.arrival;if(void 0!==f&&(void 0===c||f<=t.departureAtOffset(p,h))){const e=t.findEarliestTrip(p,f,c);if(void 0===e)continue;const s=u&&"routeId"in u?{stopIndex:u.hopOffStopIndex,routeId:u.routeId,tripIndex:u.tripIndex}:void 0,o=this.timetable.findFirstBoardableTrip(p,t,e,f,c,s,n.minTransferTime);if(void 0!==o){const e=t.departureFrom(p,o),s=1===r&&void 0!==n.maxInitialWaitingTime&&e-f>n.maxInitialWaitingTime,a=e>i.maxArrivalTime;s||a||(c=o,l=p,h=t.tripStopOffset(o))}}}return s}considerTransfers(t,e,r,i){const n=new Set,s=i.graph[e];for(const o of r){const r=s[o];if(!r||"type"in r)continue;const a=this.timetable.getTransfers(o);for(const u of a){let a;a=u.minTransferTime?u.minTransferTime:u.type===lt.IN_SEAT?0:t.minTransferTime;const d=r.arrival+a;d<=i.maxArrivalTime&&d<i.improvementBound(e,u.destination)&&d<i.destinationBest&&(s[u.destination]={arrival:d,from:o,to:u.destination,minTransferTime:a||void 0,type:u.type},i.updateArrival(u.destination,d,e),n.add(u.destination))}}return n}}class Ct{constructor(t=[],e=(t,e)=>t<e?-1:t>e?1:0){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let t=(this.length>>1)-1;t>=0;t--)this._down(t)}push(t){this.data.push(t),this._up(this.length++)}pop(){if(0===this.length)return;const t=this.data[0],e=this.data.pop();return--this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:e,compare:r}=this,i=e[t];for(;t>0;){const n=t-1>>1,s=e[n];if(r(i,s)>=0)break;e[t]=s,t=n}e[t]=i}_down(t){const{data:e,compare:r}=this,i=this.length>>1,n=e[t];for(;t<i;){let i=1+(t<<1);const s=i+1;if(s<this.length&&r(e[s],e[i])<0&&(i=s),r(e[i],n)>=0)break;e[t]=e[i],t=i}e[t]=n}}const Mt=Math.PI/180;function Yt(t,e,r,i){const n=i.minLng,s=i.maxLng,o=i.minLat,a=i.maxLat;if(t>=n&&t<=s)return e<o?Bt((e-o)*Mt):e>a?Bt((e-a)*Mt):0;const u=Math.min(Bt((t-n)*Mt),Bt((t-s)*Mt)),d=function(t,e){const r=1-2*e;return r<=0?t>0?90:-90:Math.atan(Math.tan(t*Mt)/r)/Mt}(e,u);return d>o&&d<a?kt(u,r,e,d):Math.min(kt(u,r,e,o),kt(u,r,e,a))}function Ft(t,e){return t.dist-e.dist}function Bt(t){const e=Math.sin(t/2);return e*e}function kt(t,e,r,i){return e*Math.cos(i*Mt)*t+Bt((r-i)*Mt)}function $t(t,e,r,i,n){return kt(Bt((t-r)*Mt),n,e,i)}const jt=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],zt=new Uint32Array(96);class Vt{static from(t){if(!t||void 0===t.byteLength||t.buffer)throw new Error("Data must be an instance of ArrayBuffer or SharedArrayBuffer.");const[e,r]=new Uint8Array(t,0,2);if(219!==e)throw new Error("Data does not appear to be in a KDBush format.");const i=r>>4;if(1!==i)throw new Error(`Got v${i} data when expected v1.`);const n=jt[15&r];if(!n)throw new Error("Unrecognized array type.");const[s]=new Uint16Array(t,2,1),[o]=new Uint32Array(t,4,1);return new Vt(o,s,n,void 0,t)}constructor(t,e=64,r=Float64Array,i=ArrayBuffer,n){if(isNaN(t)||t<0)throw new Error(`Unexpected numItems value: ${t}.`);this.numItems=+t,this.nodeSize=Math.min(Math.max(+e,2),65535),this.ArrayType=r,this.IndexArrayType=t<65536?Uint16Array:Uint32Array;const s=jt.indexOf(this.ArrayType),o=2*t*this.ArrayType.BYTES_PER_ELEMENT,a=t*this.IndexArrayType.BYTES_PER_ELEMENT,u=(8-a%8)%8;if(s<0)throw new Error(`Unexpected typed array class: ${r}.`);if(n)this.data=n,this.ids=new this.IndexArrayType(n,8,t),this.coords=new r(n,8+a+u,2*t),this._pos=2*t,this._finished=!0;else{const n=this.data=new i(8+o+a+u);this.ids=new this.IndexArrayType(n,8,t),this.coords=new r(n,8+a+u,2*t),this._pos=0,this._finished=!1,new Uint8Array(n,0,2).set([219,16+s]),new Uint16Array(n,2,1)[0]=e,new Uint32Array(n,4,1)[0]=t}}add(t,e){const r=this._pos>>1;return this.ids[r]=r,this.coords[this._pos++]=t,this.coords[this._pos++]=e,r}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return Gt(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,e,r,i){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:s,nodeSize:o}=this;zt[0]=0,zt[1]=n.length-1,zt[2]=0;let a=3;const u=[];for(;a>0;){const d=zt[--a],c=zt[--a],l=zt[--a];if(c-l<=o){for(let o=l;o<=c;o++){const a=s[2*o],d=s[2*o+1];a>=t&&a<=r&&d>=e&&d<=i&&u.push(n[o])}continue}const h=l+c>>1,p=s[2*h],f=s[2*h+1];p>=t&&p<=r&&f>=e&&f<=i&&u.push(n[h]),(0===d?t<=p:e<=f)&&(zt[a++]=l,zt[a++]=h-1,zt[a++]=1-d),(0===d?r>=p:i>=f)&&(zt[a++]=h+1,zt[a++]=c,zt[a++]=1-d)}return u}within(t,e,r){const i=[];return this.withinInto(t,e,r,i),i}withinInto(t,e,r,i){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:s,nodeSize:o}=this;zt[0]=0,zt[1]=n.length-1,zt[2]=0;let a=3,u=0;const d=r*r;for(;a>0;){const c=zt[--a],l=zt[--a],h=zt[--a];if(l-h<=o){for(let r=h;r<=l;r++)Ht(s[2*r],s[2*r+1],t,e)<=d&&(i[u++]=n[r]);continue}const p=h+l>>1,f=s[2*p],T=s[2*p+1];Ht(f,T,t,e)<=d&&(i[u++]=n[p]),(0===c?t-r<=f:e-r<=T)&&(zt[a++]=h,zt[a++]=p-1,zt[a++]=1-c),(0===c?t+r>=f:e+r>=T)&&(zt[a++]=p+1,zt[a++]=l,zt[a++]=1-c)}return u}}function Gt(t,e,r,i,n,s){if(n-i<=r)return;const o=i+n>>1;Jt(t,e,o,i,n,s),Gt(t,e,r,i,o-1,1-s),Gt(t,e,r,o+1,n,1-s)}function Jt(t,e,r,i,n,s){for(;n>i;){if(n-i>600){const o=n-i+1,a=r-i+1,u=Math.log(o),d=.5*Math.exp(2*u/3),c=.5*Math.sqrt(u*d*(o-d)/o)*(a-o/2<0?-1:1);Jt(t,e,r,Math.max(i,Math.floor(r-a*d/o+c)),Math.min(n,Math.floor(r+(o-a)*d/o+c)),s)}const o=e[2*r+s];let a=i,u=n;for(Wt(t,e,i,r),e[2*n+s]>o&&Wt(t,e,i,n);a<u;){for(Wt(t,e,a,u),a++,u--;e[2*a+s]<o;)a++;for(;e[2*u+s]>o;)u--}e[2*i+s]===o?Wt(t,e,i,u):(u++,Wt(t,e,u,n)),u<=r&&(i=u+1),r<=u&&(n=u-1)}}function Wt(t,e,r,i){Zt(t,r,i),Zt(e,2*r,2*i),Zt(e,2*r+1,2*i+1)}function Zt(t,e,r){const i=t[e];t[e]=t[r],t[r]=i}function Ht(t,e,r,i){const n=t-r,s=e-i;return n*n+s*s}const Qt=t=>t[t.length-1],qt="ENTRIES",Xt="KEYS",Kt="VALUES";var te=class{set;_type;_path;constructor(t,e){let r=t._tree,i=[...r.keys()];this.set=t,this._type=e,this._path=i.length>0?[{node:r,keys:i}]:[]}next(){let t=this.dive();return this.backtrack(),t}key(){return this.set._prefix+this._path.map((({keys:t})=>Qt(t))).filter((t=>""!==t)).join("")}value(){return Qt(this._path).node.get("")}[Symbol.iterator](){return this}result(){switch(this._type){case Kt:return this.value();case Xt:return this.key();case qt:return[this.key(),this.value()];default:throw Error(`Unknown iterator type: ${this._type}`)}}dive(){if(0===this._path.length)return{done:!0,value:void 0};let{node:t,keys:e}=Qt(this._path);if(""===Qt(e))return{done:!1,value:this.result()};let r=t.get(Qt(e));return this._path.push({node:r,keys:[...r.keys()]}),this.dive()}backtrack(){if(0===this._path.length)return;let{keys:t}=Qt(this._path);t.pop(),!(t.length>0)&&(this._path.pop(),this.backtrack())}};const ee=(t,e,r,i,n,s,o,a)=>{let u=s*o;t:for(let d of t.keys())if(""===d){let e=n[u-1];e<=r&&i.set(a,[t.get(d),e])}else{let u=s;for(let t=0;t<d.length;++t,++u){let i=d[t],s=o*u,a=s-o,c=n[s],l=Math.max(0,u-r-1),h=Math.min(o-1,u+r);for(let t=l;t<h;++t){let r=i!==e[t],o=n[a+t]+Number(r),u=n[a+t+1]+1,d=n[s+t]+1,l=n[s+t+1]=Math.min(o,u,d);l<c&&(c=l)}if(c>r)continue t}ee(t.get(d),e,r,i,n,u,o,a+d)}},re=(t,e,r=[])=>{if(0===e.length||null==t)return[t,r];for(let i of t.keys())if(""!==i&&e.startsWith(i))return r.push([t,i]),re(t.get(i),e.slice(i.length),r);return r.push([t,e]),re(void 0,"",r)},ie=(t,e)=>{if(0===e.length||!t)return t;for(let r of t.keys())if(""!==r&&e.startsWith(r))return ie(t.get(r),e.slice(r.length))},ne=(t,e)=>{let r=e.length;t:for(let i=0;t&&i<r;){for(let n of t.keys())if(""!==n&&e[i]===n[0]){let s=Math.min(r-i,n.length),o=1;for(;o<s&&e[i+o]===n[o];)o+=1;let a=t.get(n);if(o===n.length)t=a;else{let r=new Map([[n.slice(o),a]]);t.set(e.slice(i,i+o),r),t.delete(n),t=r}i+=o;continue t}let n=new Map;return t.set(e.slice(i),n),n}return t},se=(t,e,r)=>{if(0===t.length)return;let[i,n]=Qt(t);i.set(n+e,r),i.delete(n)},oe=t=>{if(0===t.length)return;let[e,r]=Qt(t);if(e.delete(r),0===e.size)oe(t.slice(0,-1));else if(1===e.size){let[r,i]=e.entries().next().value;""!==r&&se(t.slice(0,-1),r,i)}};var ae=class t{_tree;_prefix;_size=void 0;constructor(t=new Map,e=""){this._tree=t,this._prefix=e}atPrefix(e){if(!e.startsWith(this._prefix))throw Error("Mismatched prefix");let[r,i]=re(this._tree,e.slice(this._prefix.length));if(void 0===r){let[r,n]=Qt(i);for(let i of r.keys())if(""!==i&&i.startsWith(n)){let s=new Map([[i.slice(n.length),r.get(i)]]);return new t(s,e)}}return new t(r,e)}clear(){this._size=void 0,this._tree.clear()}delete(t){this._size=void 0,((t,e)=>{let[r,i]=re(t,e);if(void 0!==r)if(r.delete(""),0===r.size)oe(i);else if(1===r.size){let[t,e]=r.entries().next().value;se(i,t,e)}})(this._tree,t)}entries(){return new te(this,qt)}forEach(t){for(let[e,r]of this)t(e,r,this)}fuzzyGet(t,e){return((t,e,r)=>{let i=new Map;if("string"!=typeof e)return i;let n=e.length+1,s=n+r,o=new Uint8Array(s*n).fill(r+1);for(let t=0;t<n;++t)o[t]=t;for(let t=1;t<s;++t)o[t*n]=t;return ee(t,e,r,i,o,1,n,""),i})(this._tree,t,e)}get(t){let e=ie(this._tree,t);return void 0===e?void 0:e.get("")}has(t){return ie(this._tree,t)?.has("")??!1}keys(){return new te(this,Xt)}set(t,e){if("string"!=typeof t)throw Error("key must be a string");return this._size=void 0,ne(this._tree,t).set("",e),this}get size(){if("number"==typeof this._size)return this._size;this._size=0;let t=this.entries();for(;!t.next().done;)this._size+=1;return this._size}update(t,e){if("string"!=typeof t)throw Error("key must be a string");this._size=void 0;let r=ne(this._tree,t);return r.set("",e(r.get(""))),this}fetch(t,e){if("string"!=typeof t)throw Error("key must be a string");this._size=void 0;let r=ne(this._tree,t),i=r.get("");return void 0===i&&r.set("",i=e()),i}values(){return new te(this,Kt)}[Symbol.iterator](){return this.entries()}static from(e){let r=new t;for(let[t,i]of e)r.set(t,i);return r}static fromObject(e){return t.from(Object.entries(e))}};const ue=/[\n\r\p{Z}\p{P}]+/u,de=(t,e)=>{t.includes(e)||t.push(e)},ce=(t,e)=>{for(let r of e)t.includes(r)||t.push(r)},le=({score:t},{score:e})=>e-t,he=()=>new Map,pe=(t,e)=>Object.hasOwn(t,e)?t[e]:void 0,fe={or:(t,e)=>{for(let r of e.keys()){let i=t.get(r);if(null==i)t.set(r,e.get(r));else{let{score:t,terms:n,match:s}=e.get(r);i.score+=t,i.match=Object.assign(i.match,s),ce(i.terms,n)}}return t},and:(t,e)=>{let r=new Map;for(let i of e.keys()){let n=t.get(i);if(null==n)continue;let{score:s,terms:o,match:a}=e.get(i);ce(n.terms,o),r.set(i,{score:n.score+s,terms:n.terms,match:Object.assign(n.match,a)})}return r},and_not:(t,e)=>{for(let r of e.keys())t.delete(r);return t}},Te=(t,e,r,i,n,s)=>{let{k:o,b:a,d:u}=s;return Math.log(1+(r-e+.5)/(e+.5))*(u+t*(o+1)/(t+o*(1-a+a*i/n)))},_e=(t,e,r,i)=>{for(let n of Object.keys(t._fieldIds))if(t._fieldIds[n]===r)return void t._options.logger("warn",`SlimSearch: document with ID ${t._documentIds.get(e)} has changed before removal: term "${i}" was not present in field "${n}". Removing a document after it has changed can corrupt the index!`,"version_conflict")},Ee=(t,e,r,i)=>{let n=t._index.fetch(i,he),s=n.get(e);if(null==s)s=new Map([[r,1]]),n.set(e,s);else{let t=s.get(r);s.set(r,(t??0)+1)}},me=(t,e,r,i)=>{if(!t._index.has(i))return void _e(t,r,e,i);let n=t._index.fetch(i,he),s=n.get(e),o=s?.get(r);s&&null!=o?o<=1?s.size<=1?n.delete(e):s.delete(r):s.set(r,o-1):_e(t,r,e,i),0===t._index.get(i).size&&t._index.delete(i)},Ie=(t,e,r,i,n)=>{let s=t._fieldLength.get(e);s??t._fieldLength.set(e,s=[]),s[r]=n;let o=(t._avgFieldLength[r]||0)*i+n;t._avgFieldLength[r]=o/(i+1)},ge=(t,e)=>{let{extractField:r,stringifyField:i,tokenize:n,processTerm:s,fields:o,idField:a}=t._options,u=r(e,a);if(null==u)throw Error(`SlimSearch: document does not have ID field "${a}"`);if(((t,e)=>t._idToShortId.has(e))(t,u))throw Error(`SlimSearch: duplicate ID ${u}`);let d=((t,e)=>{let r=t._nextId;return t._idToShortId.set(e,r),t._documentIds.set(r,e),t._documentCount+=1,t._nextId+=1,r})(t,u);((t,e,r)=>{let{storeFields:i,extractField:n}=t._options;if(0===i?.length)return;let s=t._storedFields.get(e);s??t._storedFields.set(e,s={});for(let t of i){let e=n(r,t);null!=e&&(s[t]=e)}})(t,d,e);for(let a of o){let o=r(e,a);if(null==o)continue;let u=n(i(o,a),a),c=t._fieldIds[a],l=new Set(u).size;Ie(t,d,c,t._documentCount-1,l);for(let e of u){let r=s(e,a);if(Array.isArray(r))for(let e of r)Ee(t,c,d,e);else r&&Ee(t,c,d,r)}}},Re={idField:"id",extractField:(t,e)=>t[e],stringifyField:t=>t.toString(),tokenize:t=>t.split(ue),processTerm:t=>t.toLowerCase(),fields:void 0,searchOptions:void 0,storeFields:[],logger:(t,e)=>{console?.[t]?.(e)},autoVacuum:!0},ve={combineWith:"or",prefix:!1,fuzzy:!1,maxFuzzy:6,boost:{},weights:{fuzzy:.45,prefix:.375},bm25:{k:1.2,b:.7,d:.5}},Ae={combineWith:"and",prefix:(t,e,r)=>e===r.length-1},ye={minDirtFactor:.1,minDirtCount:20},Se={batchSize:1e3,batchWait:10,...ye},Oe=Symbol("*"),Ne=(t,e="or")=>{if(0===t.length)return new Map;let r=e.toLowerCase();if(!(r in fe))throw Error(`Invalid combination operator: ${e}`);return t.reduce(fe[r])},be=(t,e,r,i,n,s,o,a,u,d=new Map)=>{if(null==s)return d;for(let c of Object.keys(o)){let l=o[c],h=t._fieldIds[c],p=s.get(h);if(null==p)continue;let f=p.size,T=t._avgFieldLength[h];for(let s of p.keys()){if(!t._documentIds.has(s)){me(t,h,s,r),--f;continue}let o=a?a(t._documentIds.get(s),r,t._storedFields.get(s)):1;if(!o)continue;let _=p.get(s),E=t._fieldLength.get(s)[h],m=i*n*l*o*Te(_,f,t._documentCount,E,T,u),I=d.get(s);if(I){I.score+=m,de(I.terms,e);let t=pe(I.match,r);t?t.push(c):I.match[r]=[c]}else d.set(s,{score:m,terms:[e],match:{[r]:[c]}})}}return d},we=(t,e,r={})=>{if(e===Oe)return((t,e)=>{let r=new Map,i={...t._options.searchOptions,...e};for(let[e,n]of t._documentIds){let s=i.boostDocument?i.boostDocument(n,"",t._storedFields.get(e)):1;r.set(e,{score:s,terms:[],match:{}})}return r})(t,r);if("string"!=typeof e){let i={...r,...e,queries:void 0},n=e.queries.map((e=>we(t,e,i)));return Ne(n,i.combineWith)}let{tokenize:i,processTerm:n,searchOptions:s}=t._options,o={tokenize:i,processTerm:n,...s,...r},{tokenize:a,processTerm:u}=o,d=a(e).flatMap((t=>u(t))).filter(Boolean).map((t=>(e,r,i)=>({term:e,fuzzy:"function"==typeof t.fuzzy?t.fuzzy(e,r,i):t.fuzzy??!1,prefix:"function"==typeof t.prefix?t.prefix(e,r,i):!0===t.prefix,termBoost:"function"==typeof t.boostTerm?t.boostTerm(e,r,i):1}))(o)).map((e=>((t,e,r)=>{let i,n,s={...t._options.searchOptions,...r},o=(s.fields??t._options.fields).reduce(((t,e)=>(t[e]=pe(s.boost,e)||1,t)),{}),{boostDocument:a,weights:u,maxFuzzy:d,bm25:c}=s,{fuzzy:l,prefix:h}={...ve.weights,...u},p=t._index.get(e.term),f=be(t,e.term,e.term,1,e.termBoost,p,o,a,c);if(e.prefix&&(i=t._index.atPrefix(e.term)),e.fuzzy){let r=!0===e.fuzzy?.2:e.fuzzy,i=r<1?Math.min(d,Math.round(e.term.length*r)):r;i&&(n=t._index.fuzzyGet(e.term,i))}if(i)for(let[r,s]of i){let i=r.length-e.term.length;if(!i)continue;n?.delete(r);let u=h*r.length/(r.length+.3*i);be(t,e.term,r,u,e.termBoost,s,o,a,c,f)}if(n)for(let r of n.keys()){let[i,s]=n.get(r);if(!s)continue;let u=l*r.length/(r.length+s);be(t,e.term,r,u,e.termBoost,i,o,a,c,f)}return f})(t,e,o)));return Ne(d,o.combineWith)};var Ue=class{_options;_index;_documentCount;_documentIds;_idToShortId;_fieldIds;_fieldLength;_avgFieldLength;_nextId;_storedFields;_dirtCount;_currentVacuum;_enqueuedVacuum;_enqueuedVacuumConditions;constructor(t){if(!t?.fields)throw Error('SlimSearch: option "fields" must be provided');let e=null==t.autoVacuum||!0===t.autoVacuum?Se:t.autoVacuum;this._options={...Re,...t,autoVacuum:e,searchOptions:{...ve,...t.searchOptions},autoSuggestOptions:{...Ae,...t.autoSuggestOptions}},this._index=new ae,this._documentCount=0,this._documentIds=new Map,this._idToShortId=new Map,this._fieldIds={},this._fieldLength=new Map,this._avgFieldLength=[],this._nextId=0,this._storedFields=new Map,this._dirtCount=0,this._currentVacuum=null,this._enqueuedVacuum=null,this._enqueuedVacuumConditions=ye,this.addFields(this._options.fields)}get isVacuuming(){return null!=this._currentVacuum}get dirtCount(){return this._dirtCount}get dirtFactor(){return this._dirtCount/(1+this._documentCount+this._dirtCount)}get documentCount(){return this._documentCount}get termCount(){return this._index.size}toJSON(){let t=[];for(let[e,r]of this._index){let i={};for(let[t,e]of r)i[t]=Object.fromEntries(e);t.push([e,i])}return{documentCount:this._documentCount,nextId:this._nextId,documentIds:Object.fromEntries(this._documentIds),fieldIds:this._fieldIds,fieldLength:Object.fromEntries(this._fieldLength),averageFieldLength:this._avgFieldLength,storedFields:Object.fromEntries(this._storedFields),dirtCount:this._dirtCount,index:t,version:2}}addFields(t){for(let e=0;e<t.length;e++)this._fieldIds[t[e]]=e}};const Pe=t=>{const e=t.toLowerCase(),r=new Set([e]),i={a:["à","â","ä"],c:["ç"],e:["é","è","ê","ë"],i:["î","ï"],o:["ô","ö"],u:["ù","û","ü"],ae:["ä"],oe:["ö"],ue:["ü"]};for(const[t,n]of Object.entries(i))e.includes(t)&&n.forEach((i=>{r.add(e.replace(t,i))})),n.forEach((i=>{e.includes(i)&&r.add(e.replace(i,t))}));return Array.from(r)};var xe;function Le(t){switch(t){case 0:case"LOCATION_TYPE_UNSPECIFIED":return xe.LOCATION_TYPE_UNSPECIFIED;case 1:case"LOCATION_TYPE_SIMPLE_STOP_OR_PLATFORM":return xe.LOCATION_TYPE_SIMPLE_STOP_OR_PLATFORM;case 2:case"LOCATION_TYPE_STATION":return xe.LOCATION_TYPE_STATION;case 3:case"LOCATION_TYPE_ENTRANCE_EXIT":return xe.LOCATION_TYPE_ENTRANCE_EXIT;case 4:case"LOCATION_TYPE_GENERIC_NODE":return xe.LOCATION_TYPE_GENERIC_NODE;case 5:case"LOCATION_TYPE_BOARDING_AREA":return xe.LOCATION_TYPE_BOARDING_AREA;default:return xe.UNRECOGNIZED}}!function(t){t[t.LOCATION_TYPE_UNSPECIFIED=0]="LOCATION_TYPE_UNSPECIFIED",t[t.LOCATION_TYPE_SIMPLE_STOP_OR_PLATFORM=1]="LOCATION_TYPE_SIMPLE_STOP_OR_PLATFORM",t[t.LOCATION_TYPE_STATION=2]="LOCATION_TYPE_STATION",t[t.LOCATION_TYPE_ENTRANCE_EXIT=3]="LOCATION_TYPE_ENTRANCE_EXIT",t[t.LOCATION_TYPE_GENERIC_NODE=4]="LOCATION_TYPE_GENERIC_NODE",t[t.LOCATION_TYPE_BOARDING_AREA=5]="LOCATION_TYPE_BOARDING_AREA",t[t.UNRECOGNIZED=-1]="UNRECOGNIZED"}(xe||(xe={}));const De={encode(t,e=new m){if(""!==t.name&&e.uint32(10).string(t.name),void 0!==t.sourceStopId&&e.uint32(18).string(t.sourceStopId),void 0!==t.lat&&e.uint32(29).float(t.lat),void 0!==t.lon&&e.uint32(37).float(t.lon),0!==t.children.length){e.uint32(42).fork();for(const r of t.children)e.uint32(r);e.join()}return void 0!==t.parent&&e.uint32(48).uint32(t.parent),0!==t.locationType&&e.uint32(56).int32(t.locationType),void 0!==t.platform&&e.uint32(66).string(t.platform),e},decode(t,e){var r;const i=t instanceof S?t:new S(t),n=null!==(r=i.__tsProtoDecodeDepth)&&void 0!==r?r:0;if(n>=100)throw new globalThis.Error("protobuf decode recursion limit exceeded");i.__tsProtoDecodeDepth=n+1;try{const t=void 0===e?i.len:i.pos+e,r={name:"",sourceStopId:void 0,lat:void 0,lon:void 0,children:[],parent:void 0,locationType:0,platform:void 0};for(;i.pos<t;){const t=i.uint32();switch(t>>>3){case 1:if(10!==t)break;r.name=i.string();continue;case 2:if(18!==t)break;r.sourceStopId=i.string();continue;case 3:if(29!==t)break;r.lat=i.float();continue;case 4:if(37!==t)break;r.lon=i.float();continue;case 5:if(40===t){r.children.push(i.uint32());continue}if(42===t){const t=i.uint32()+i.pos;for(;i.pos<t;)r.children.push(i.uint32());continue}break;case 6:if(48!==t)break;r.parent=i.uint32();continue;case 7:if(56!==t)break;r.locationType=i.int32();continue;case 8:if(66!==t)break;r.platform=i.string();continue}if(4==(7&t)||0===t)break;i.skip(7&t)}return r}finally{i.__tsProtoDecodeDepth=n}},fromJSON:t=>({name:Ye(t.name)?globalThis.String(t.name):"",sourceStopId:Ye(t.sourceStopId)?globalThis.String(t.sourceStopId):Ye(t.source_stop_id)?globalThis.String(t.source_stop_id):void 0,lat:Ye(t.lat)?globalThis.Number(t.lat):void 0,lon:Ye(t.lon)?globalThis.Number(t.lon):void 0,children:globalThis.Array.isArray(null==t?void 0:t.children)?t.children.map((t=>globalThis.Number(t))):[],parent:Ye(t.parent)?globalThis.Number(t.parent):void 0,locationType:Ye(t.locationType)?Le(t.locationType):Ye(t.location_type)?Le(t.location_type):0,platform:Ye(t.platform)?globalThis.String(t.platform):void 0}),toJSON(t){var e;const r={};return""!==t.name&&(r.name=t.name),void 0!==t.sourceStopId&&(r.sourceStopId=t.sourceStopId),void 0!==t.lat&&(r.lat=Me(t.lat)),void 0!==t.lon&&(r.lon=Me(t.lon)),(null===(e=t.children)||void 0===e?void 0:e.length)&&(r.children=t.children.map((t=>Math.round(t)))),void 0!==t.parent&&(r.parent=Math.round(t.parent)),0!==t.locationType&&(r.locationType=function(t){switch(t){case xe.LOCATION_TYPE_UNSPECIFIED:return"LOCATION_TYPE_UNSPECIFIED";case xe.LOCATION_TYPE_SIMPLE_STOP_OR_PLATFORM:return"LOCATION_TYPE_SIMPLE_STOP_OR_PLATFORM";case xe.LOCATION_TYPE_STATION:return"LOCATION_TYPE_STATION";case xe.LOCATION_TYPE_ENTRANCE_EXIT:return"LOCATION_TYPE_ENTRANCE_EXIT";case xe.LOCATION_TYPE_GENERIC_NODE:return"LOCATION_TYPE_GENERIC_NODE";case xe.LOCATION_TYPE_BOARDING_AREA:return"LOCATION_TYPE_BOARDING_AREA";case xe.UNRECOGNIZED:default:return"UNRECOGNIZED"}}(t.locationType)),void 0!==t.platform&&(r.platform=t.platform),r},create:t=>De.fromPartial(null!=t?t:{}),fromPartial(t){var e,r,i,n,s,o,a,u;const d={name:"",sourceStopId:void 0,lat:void 0,lon:void 0,children:[],parent:void 0,locationType:0,platform:void 0};return d.name=null!==(e=t.name)&&void 0!==e?e:"",d.sourceStopId=null!==(r=t.sourceStopId)&&void 0!==r?r:void 0,d.lat=null!==(i=t.lat)&&void 0!==i?i:void 0,d.lon=null!==(n=t.lon)&&void 0!==n?n:void 0,d.children=(null===(s=t.children)||void 0===s?void 0:s.map((t=>t)))||[],d.parent=null!==(o=t.parent)&&void 0!==o?o:void 0,d.locationType=null!==(a=t.locationType)&&void 0!==a?a:0,d.platform=null!==(u=t.platform)&&void 0!==u?u:void 0,d}};const Ce={encode(t,e=new m){for(const r of t.stops)De.encode(r,e.uint32(18).fork()).join();return e},decode(t,e){var r;const i=t instanceof S?t:new S(t),n=null!==(r=i.__tsProtoDecodeDepth)&&void 0!==r?r:0;if(n>=100)throw new globalThis.Error("protobuf decode recursion limit exceeded");i.__tsProtoDecodeDepth=n+1;try{const t=void 0===e?i.len:i.pos+e,r={stops:[]};for(;i.pos<t;){const t=i.uint32();switch(t>>>3){case 2:if(18!==t)break;r.stops.push(De.decode(i,i.uint32()));continue}if(4==(7&t)||0===t)break;i.skip(7&t)}return r}finally{i.__tsProtoDecodeDepth=n}},fromJSON:t=>({stops:globalThis.Array.isArray(null==t?void 0:t.stops)?t.stops.map((t=>De.fromJSON(t))):[]}),toJSON(t){var e;const r={};return(null===(e=t.stops)||void 0===e?void 0:e.length)&&(r.stops=t.stops.map((t=>De.toJSON(t)))),r},create:t=>Ce.fromPartial(null!=t?t:{}),fromPartial(t){var e;const r={stops:[]};return r.stops=(null===(e=t.stops)||void 0===e?void 0:e.map((t=>De.fromPartial(t))))||[],r}};function Me(t){return"number"!=typeof t||globalThis.Number.isFinite(t)?t:globalThis.String(t)}function Ye(t){return null!=t}const Fe=t=>({stops:t.map((t=>{return{name:(e=t).name,sourceStopId:e.sourceStopId,lat:e.lat,lon:e.lon,children:e.children,parent:e.parent,locationType:$e(e.locationType),platform:e.platform};var e}))}),Be=t=>t.stops.map(((t,e)=>{return{id:e,sourceStopId:(r=t).sourceStopId,name:r.name,lat:r.lat,lon:r.lon,children:r.children,parent:r.parent,locationType:ke(r.locationType),platform:r.platform};var r})),ke=t=>{switch(t){case xe.LOCATION_TYPE_SIMPLE_STOP_OR_PLATFORM:return"SIMPLE_STOP_OR_PLATFORM";case xe.LOCATION_TYPE_STATION:return"STATION";case xe.LOCATION_TYPE_ENTRANCE_EXIT:return"ENTRANCE_EXIT";case xe.LOCATION_TYPE_GENERIC_NODE:return"GENERIC_NODE";case xe.LOCATION_TYPE_BOARDING_AREA:return"BOARDING_AREA";case xe.LOCATION_TYPE_UNSPECIFIED:throw new Error("Unspecified protobuf location type.");case xe.UNRECOGNIZED:throw new Error("Unrecognized protobuf location type.")}},$e=t=>{switch(t){case"SIMPLE_STOP_OR_PLATFORM":return xe.LOCATION_TYPE_SIMPLE_STOP_OR_PLATFORM;case"STATION":return xe.LOCATION_TYPE_STATION;case"ENTRANCE_EXIT":return xe.LOCATION_TYPE_ENTRANCE_EXIT;case"GENERIC_NODE":return xe.LOCATION_TYPE_GENERIC_NODE;case"BOARDING_AREA":return xe.LOCATION_TYPE_BOARDING_AREA}};class je{constructor(t){var e;this.stops=t,this.sourceStopsMap=new Map;const r=new Map;this.geoStopIds=[];for(let i=0;i<t.length;i++){const n=t[i];void 0!==n.sourceStopId&&this.sourceStopsMap.set(n.sourceStopId,i);const s=null!==(e=n.parent)&&void 0!==e?e:i;r.has(s)||r.set(s,{id:s,name:n.parent?this.stops[n.parent].name:n.name}),n.lat&&n.lon&&this.geoStopIds.push(i)}this.textIndex=(t=>new Ue(t))({fields:["name"],storeFields:["id"],searchOptions:{prefix:!0,fuzzy:.2},processTerm:Pe});const i=Array.from(r.values());((t,e)=>{for(let r of e)ge(t,r)})(this.textIndex,i),this.geoIndex=new Vt(this.geoStopIds.length);for(let t=0;t<this.geoStopIds.length;t++){const e=this.stops[this.geoStopIds[t]];this.geoIndex.add(e.lon,e.lat)}this.geoIndex.finish()}static fromData(t){const e=new S(t),r=Ce.decode(e);return new je(Be(r))}serialize(){const t=Fe(this.stops),e=new m;return Ce.encode(t,e),e.finish()}size(){return this.stops.length}findStopsByName(t,e=5){return((t,e,r={})=>{let{searchOptions:i}=t._options,n={...i,...r},s=we(t,e,r),o=[];for(let[e,{score:r,terms:i,match:a}]of s){let s=i.length||1,u={id:t._documentIds.get(e),score:r*s,terms:Object.keys(a),queryTerms:i,match:a,...t._storedFields.get(e)};(null==n.filter||n.filter(u))&&o.push(u)}return e===Oe&&null==n.boostDocument||o.sort(le),o})(this.textIndex,t).slice(0,e).map((t=>this.stops[t.id]))}findStopsByLocation(t,e,r=5,i=.5){const n=function(t,e,r,i=1/0,n=1/0){let s=1;const o=[];void 0===i&&(i=1/0),void 0!==n&&(s=Bt(n/6371));const a=new Ct([],Ft);let u={left:0,right:t.ids.length-1,axis:0,minLng:-180,minLat:-90,maxLng:180,maxLat:90};const d=Math.cos(r*Mt);for(;u;){const n=u.right,c=u.left;if(n-c<=t.nodeSize)for(let i=c;i<=n;i++){const n=t.ids[i];{const s=$t(e,r,t.coords[2*i],t.coords[2*i+1],d);a.push({id:n,dist:s})}}else{const i=c+n>>1,s=t.coords[2*i],o=t.coords[2*i+1],l=t.ids[i];{const t=$t(e,r,s,o,d);a.push({id:l,dist:t})}const h=(u.axis+1)%2,p={left:c,right:i-1,axis:h,minLng:u.minLng,minLat:u.minLat,maxLng:0===u.axis?s:u.maxLng,maxLat:1===u.axis?o:u.maxLat,dist:0},f={left:i+1,right:n,axis:h,minLng:0===u.axis?s:u.minLng,minLat:1===u.axis?o:u.minLat,maxLng:u.maxLng,maxLat:u.maxLat,dist:0};p.dist=Yt(e,r,d,p),f.dist=Yt(e,r,d,f),a.push(p),a.push(f)}let l;for(;(l=a.pop())&&"id"in l;){if(l.dist>s)return o;if(o.push(l.id),o.length===i)return o}u=l}return o}(this.geoIndex,e,t,r,i).map((t=>{const e=this.geoStopIds[t];return this.stops[e]}));return n}findStopById(t){return this.stops[t]}findStopBySourceStopId(t){const e=this.sourceStopsMap.get(t);if(void 0!==e)return this.findStopById(e)}equivalentStops(t){var e,r;const i=this.stops[t];if(!i)return[];const n=i.parent?null!==(r=null===(e=this.stops[i.parent])||void 0===e?void 0:e.children)&&void 0!==r?r:[]:i.children;return Array.from(new Set([t,...n])).map((t=>this.stops[t]))}*[Symbol.iterator](){for(const t of this.stops)yield t}}exports.PickUpDropOffTypes=z,exports.Plotter=class{constructor(t){this.result=t}stationNodeId(t){return`s_${t}`}vehicleEdgeNodeId(t,e,r,i){return`e_${t}_${e}_${r}_${i}`}transferEdgeNodeId(t,e,r){return`e_${t}_${e}_${r}`}accessEdgeNodeId(t,e){return`access_${t}_${e}`}continuationNodeId(t,e,r){return`continuation_${t}_${e}_${r}`}getRoundColor(t){var e;if(0===t)return mt.colors.defaultRound;const r=Math.min(t-1,mt.colors.rounds.length-1);return null!==(e=mt.colors.rounds[r])&&void 0!==e?e:"#ee82ee"}getStationFillColor(t,e){return t?mt.colors.originStation:e?mt.colors.destinationStation:mt.colors.defaultStation}escapeDotString(t){return t.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}formatStopName(t){const e=this.result.stopsIndex.findStopById(t);if(!e)return`Unknown Stop (${t})`;const r=this.escapeDotString(e.name),i=e.platform?this.escapeDotString(e.platform):"";return i?`${r}\\nPl. ${i}`:r}getStationInfo(t){var e;return{isOrigin:void 0!==(null===(e=this.result.routingState.graph[0])||void 0===e?void 0:e[t]),isDestination:this.result.routingState.destinations.includes(t)}}getVehicleEdgeFromStopId(t){const e=this.result.timetable.getRoute(t.routeId);return null==e?void 0:e.stopId(t.stopIndex)}getVehicleEdgeToStopId(t){const e=this.result.timetable.getRoute(t.routeId);return null==e?void 0:e.stopId(t.hopOffStopIndex)}createStationNode(t){if(!this.result.stopsIndex.findStopById(t))return null;const e=this.formatStopName(t),r=this.escapeDotString(String(t)),i=this.stationNodeId(t),n=this.getStationInfo(t);return` "${i}" [label="${e}\\n${r}" shape=box style=filled fillcolor="${this.getStationFillColor(n.isOrigin,n.isDestination)}"];`}createVehicleEdge(e,r){const i=this.result.timetable.getRoute(e.routeId);if(!i)return[];const n=i.stopId(e.stopIndex),s=i.stopId(e.hopOffStopIndex),o=this.stationNodeId(n),a=this.stationNodeId(s),u=this.getRoundColor(r),d=this.vehicleEdgeNodeId(n,s,e.routeId,r),c=this.result.timetable.getServiceRouteInfo(i),l=c.name,h=_t(c.type),p=t(i.departureFrom(e.stopIndex,e.tripIndex)),f=t(e.arrival),T=this.escapeDotString(l);return[` "${d}" [label="${`${this.escapeDotString(h)} ${T}\\n${`${e.routeId}:${e.tripIndex}`}\\n${p} → ${f}`}" shape=oval style=filled fillcolor="white" color="${u}"];`,` "${o}" -> "${d}" [color="${u}"];`,` "${d}" -> "${a}" [color="${u}"];`]}createAccessEdge(t){const r=this.stationNodeId(t.from),i=this.stationNodeId(t.to),n=mt.colors.defaultRound,s=this.accessEdgeNodeId(t.from,t.to);return[` "${s}" [label="${`Walk\\n${e(t.duration)}`}" shape=oval style="dashed,filled" fillcolor="white" color="${n}"];`,` "${r}" -> "${s}" [color="${n}" style="dashed"];`,` "${s}" -> "${i}" [color="${n}" style="dashed"];`]}createTransferEdge(t,r){const i=this.stationNodeId(t.from),n=this.stationNodeId(t.to),s=this.getRoundColor(r),o=this.transferEdgeNodeId(t.from,t.to,r),a=void 0!==t.minTransferTime?e(t.minTransferTime):"N/A";return[` "${o}" [label="${`Transfer\\n${this.escapeDotString(a)}`}" shape=oval style="dashed,filled" fillcolor="white" color="${s}"];`,` "${i}" -> "${o}" [color="${s}" style="dashed"];`,` "${o}" -> "${n}" [color="${s}" style="dashed"];`]}createContinuationEdge(e,r,i){var n,s;const o=this.getVehicleEdgeToStopId(e),a=this.getVehicleEdgeFromStopId(r);if(!o||!a)return[];const u=this.stationNodeId(o),d=this.stationNodeId(a),c=this.getRoundColor(i),l=this.continuationNodeId(o,a,i),h=this.result.timetable.getRoute(e.routeId),p=this.result.timetable.getRoute(r.routeId),f=h?this.result.timetable.getServiceRouteInfo(h):null,T=p?this.result.timetable.getServiceRouteInfo(p):null,_=null!==(n=null==f?void 0:f.name)&&void 0!==n?n:`Route ${String(e.routeId)}`,E=null!==(s=null==T?void 0:T.name)&&void 0!==s?s:`Route ${String(r.routeId)}`,m=f?_t(f.type):"UNKNOWN",I=T?_t(T.type):"UNKNOWN",g=t(e.arrival),R=p?t(p.departureFrom(r.stopIndex,r.tripIndex)):"N/A",v=this.escapeDotString(_),A=this.escapeDotString(E),y=this.escapeDotString(m),S=this.escapeDotString(I),O=`${y} ${v} (${`${e.routeId}:${e.tripIndex}`}) ${g}\\n↓\\n${S} ${A} (${`${r.routeId}:${r.tripIndex}`}) ${R}`,{continuationFill:N}=mt.colors,{continuation:b,continuationEdge:w}=mt.penWidth;return[` "${l}" [label="${O}" shape=oval style="filled,bold" fillcolor="${N}" color="${c}" penwidth="${b}"];`,` "${u}" -> "${l}" [color="${c}" style="bold" penwidth="${w}"];`,` "${l}" -> "${d}" [color="${c}" style="bold" penwidth="${w}"];`]}collectStations(){const t=new Set,e=this.result.routingState.graph;for(const r of e)for(let e=0;e<r.length;e++){const i=r[e];if(void 0!==i)if(t.add(e),It(i)){const e=this.getVehicleEdgeFromStopId(i),r=this.getVehicleEdgeToStopId(i);e&&t.add(e),r&&t.add(r)}else Rt(i)&&(t.add(i.from),t.add(i.to))}return t}collectContinuationChain(t,e){const r=[];let i=t,n=t.continuationOf;for(;n;){const t=this.createContinuationEdge(n,i,e);r.push(...t),i=n,n=n.continuationOf}return r}collectEdges(){const t=[],e=[],r=this.result.routingState.graph;for(let i=0;i<r.length;i++){const n=r[i];if(n)for(let r=0;r<n.length;r++){const s=n[r];void 0!==s&&(0!==i?It(s)?(t.push(...this.createVehicleEdge(s,i)),s.continuationOf&&e.push(...this.collectContinuationChain(s,i))):gt(s)&&t.push(...this.createTransferEdge(s,i)):Rt(s)&&t.push(...this.createAccessEdge(s)))}}return[...t,...e]}plotDotGraph(){const t=this.collectStations(),e=this.collectEdges(),r=new vt;r.addHeader(),r.addComment("Stations");for(const e of t){const t=this.createStationNode(e);t&&r.addRaw([t])}return r.addComment("Edges"),r.addRaw(e),r.build()}},exports.Query=At,exports.RangeQuery=yt,exports.RangeResult=Pt,exports.Result=Ot,exports.Route=St,exports.RouteTypes=ht,exports.Router=class{constructor(t,e){const r=new Dt(t),i=new Nt(t,e);this.plainRouter=new Ut(t,e,i,r),this.rangeRouter=new Lt(t,e,i,r)}route(t){return this.plainRouter.route(t)}rangeRoute(t){return this.rangeRouter.rangeRoute(t)}},exports.StopsIndex=je,exports.Timetable=Tt,exports.TransferTypes=lt,exports.pickUpDropOffTypeToString=t=>{switch(t){case z.REGULAR:return"REGULAR";case z.NOT_AVAILABLE:return"NOT_AVAILABLE";case z.MUST_PHONE_AGENCY:return"MUST_PHONE_AGENCY";case z.MUST_COORDINATE_WITH_DRIVER:return"MUST_COORDINATE_WITH_DRIVER"}},exports.routeTypeToString=_t,exports.transferTypeToString=Et;
2
2
  //# sourceMappingURL=router.cjs.js.map